diff --git a/dist/README.md b/dist/README.md index 6789abaf2ac..f3a3855bc94 100644 --- a/dist/README.md +++ b/dist/README.md @@ -51,7 +51,7 @@ object. This property must be set before the plotly.js script tag, for example: Plotly.js defaults to US English (en-US) and includes British English (en) in the standard bundle. Many other localizations are available - here is an example using Swiss-German (de-CH), see the contents of this directory for the full list. -They are also available on our CDN as https://cdn.plot.ly/plotly-locale-de-ch-latest.js OR https://cdn.plot.ly/plotly-locale-de-ch-1.42.5.js +They are also available on our CDN as https://cdn.plot.ly/plotly-locale-de-ch-latest.js OR https://cdn.plot.ly/plotly-locale-de-ch-1.43.0.js Note that the file names are all lowercase, even though the region is uppercase when you apply a locale. *After* the plotly.js script tag, add: @@ -74,12 +74,12 @@ The main plotly.js bundle includes all the official (non-beta) trace modules. It be can imported as minified javascript - using dist file `dist/plotly.min.js` -- using CDN URL https://cdn.plot.ly/plotly-latest.min.js OR https://cdn.plot.ly/plotly-1.42.5.min.js +- using CDN URL https://cdn.plot.ly/plotly-latest.min.js OR https://cdn.plot.ly/plotly-1.43.0.min.js or as raw javascript: - using the `plotly.js-dist` npm package (starting in `v1.39.0`) - using dist file `dist/plotly.js` -- using CDN URL https://cdn.plot.ly/plotly-latest.js OR https://cdn.plot.ly/plotly-1.42.5.js +- using CDN URL https://cdn.plot.ly/plotly-latest.js OR https://cdn.plot.ly/plotly-1.43.0.js - using CommonJS with `require('plotly.js')` If you would like to have access to the attribute meta information (including attribute descriptions as on the [schema reference page](https://plot.ly/javascript/reference/)), use dist file `dist/plotly-with-meta.js` @@ -88,7 +88,7 @@ The main plotly.js bundle weights in at: | plotly.js | plotly.min.js | plotly.min.js + gzip | plotly-with-meta.js | |-----------|---------------|----------------------|---------------------| -| 5.9 MB | 2.7 MB | 832.5 kB | 6.2 MB | +| 6 MB | 2.8 MB | 843 kB | 6.2 MB | ## Partial bundles @@ -111,7 +111,7 @@ The `basic` partial bundle contains trace modules `scatter`, `bar` and `pie`. | Raw size | Minified size | Minified + gzip size | |------|-----------------|------------------------| -| 2.2 MB | 786.4 kB | 257.2 kB | +| 2.3 MB | 805.9 kB | 263.4 kB | #### CDN links @@ -119,8 +119,8 @@ The `basic` partial bundle contains trace modules `scatter`, `bar` and `pie`. | ------ | --- | | Latest | https://cdn.plot.ly/plotly-basic-latest.js | | Latest minified | https://cdn.plot.ly/plotly-basic-latest.min.js | -| Tagged | https://cdn.plot.ly/plotly-basic-1.42.5.js | -| Tagged minified | https://cdn.plot.ly/plotly-basic-1.42.5.min.js | +| Tagged | https://cdn.plot.ly/plotly-basic-1.43.0.js | +| Tagged minified | https://cdn.plot.ly/plotly-basic-1.43.0.min.js | #### npm package (starting in `v1.39.0`) @@ -157,7 +157,7 @@ The `cartesian` partial bundle contains trace modules `scatter`, `bar`, `box`, ` | Raw size | Minified size | Minified + gzip size | |------|-----------------|------------------------| -| 2.5 MB | 898.9 kB | 292.6 kB | +| 2.6 MB | 918.8 kB | 299.1 kB | #### CDN links @@ -165,8 +165,8 @@ The `cartesian` partial bundle contains trace modules `scatter`, `bar`, `box`, ` | ------ | --- | | Latest | https://cdn.plot.ly/plotly-cartesian-latest.js | | Latest minified | https://cdn.plot.ly/plotly-cartesian-latest.min.js | -| Tagged | https://cdn.plot.ly/plotly-cartesian-1.42.5.js | -| Tagged minified | https://cdn.plot.ly/plotly-cartesian-1.42.5.min.js | +| Tagged | https://cdn.plot.ly/plotly-cartesian-1.43.0.js | +| Tagged minified | https://cdn.plot.ly/plotly-cartesian-1.43.0.min.js | #### npm package (starting in `v1.39.0`) @@ -203,7 +203,7 @@ The `geo` partial bundle contains trace modules `scatter`, `scattergeo` and `cho | Raw size | Minified size | Minified + gzip size | |------|-----------------|------------------------| -| 2.2 MB | 805.3 kB | 265.3 kB | +| 2.3 MB | 823.7 kB | 271.3 kB | #### CDN links @@ -211,8 +211,8 @@ The `geo` partial bundle contains trace modules `scatter`, `scattergeo` and `cho | ------ | --- | | Latest | https://cdn.plot.ly/plotly-geo-latest.js | | Latest minified | https://cdn.plot.ly/plotly-geo-latest.min.js | -| Tagged | https://cdn.plot.ly/plotly-geo-1.42.5.js | -| Tagged minified | https://cdn.plot.ly/plotly-geo-1.42.5.min.js | +| Tagged | https://cdn.plot.ly/plotly-geo-1.43.0.js | +| Tagged minified | https://cdn.plot.ly/plotly-geo-1.43.0.min.js | #### npm package (starting in `v1.39.0`) @@ -249,7 +249,7 @@ The `gl3d` partial bundle contains trace modules `scatter`, `scatter3d`, `surfac | Raw size | Minified size | Minified + gzip size | |------|-----------------|------------------------| -| 3.3 MB | 1.3 MB | 414 kB | +| 3.3 MB | 1.3 MB | 422.9 kB | #### CDN links @@ -257,8 +257,8 @@ The `gl3d` partial bundle contains trace modules `scatter`, `scatter3d`, `surfac | ------ | --- | | Latest | https://cdn.plot.ly/plotly-gl3d-latest.js | | Latest minified | https://cdn.plot.ly/plotly-gl3d-latest.min.js | -| Tagged | https://cdn.plot.ly/plotly-gl3d-1.42.5.js | -| Tagged minified | https://cdn.plot.ly/plotly-gl3d-1.42.5.min.js | +| Tagged | https://cdn.plot.ly/plotly-gl3d-1.43.0.js | +| Tagged minified | https://cdn.plot.ly/plotly-gl3d-1.43.0.min.js | #### npm package (starting in `v1.39.0`) @@ -295,7 +295,7 @@ The `gl2d` partial bundle contains trace modules `scatter`, `scattergl`, `splom` | Raw size | Minified size | Minified + gzip size | |------|-----------------|------------------------| -| 3.3 MB | 1.3 MB | 433.7 kB | +| 3.4 MB | 1.4 MB | 440.9 kB | #### CDN links @@ -303,8 +303,8 @@ The `gl2d` partial bundle contains trace modules `scatter`, `scattergl`, `splom` | ------ | --- | | Latest | https://cdn.plot.ly/plotly-gl2d-latest.js | | Latest minified | https://cdn.plot.ly/plotly-gl2d-latest.min.js | -| Tagged | https://cdn.plot.ly/plotly-gl2d-1.42.5.js | -| Tagged minified | https://cdn.plot.ly/plotly-gl2d-1.42.5.min.js | +| Tagged | https://cdn.plot.ly/plotly-gl2d-1.43.0.js | +| Tagged minified | https://cdn.plot.ly/plotly-gl2d-1.43.0.min.js | #### npm package (starting in `v1.39.0`) @@ -341,7 +341,7 @@ The `mapbox` partial bundle contains trace modules `scatter` and `scattermapbox` | Raw size | Minified size | Minified + gzip size | |------|-----------------|------------------------| -| 2.7 MB | 1.3 MB | 403.1 kB | +| 2.8 MB | 1.3 MB | 409.1 kB | #### CDN links @@ -349,8 +349,8 @@ The `mapbox` partial bundle contains trace modules `scatter` and `scattermapbox` | ------ | --- | | Latest | https://cdn.plot.ly/plotly-mapbox-latest.js | | Latest minified | https://cdn.plot.ly/plotly-mapbox-latest.min.js | -| Tagged | https://cdn.plot.ly/plotly-mapbox-1.42.5.js | -| Tagged minified | https://cdn.plot.ly/plotly-mapbox-1.42.5.min.js | +| Tagged | https://cdn.plot.ly/plotly-mapbox-1.43.0.js | +| Tagged minified | https://cdn.plot.ly/plotly-mapbox-1.43.0.min.js | #### npm package (starting in `v1.39.0`) @@ -387,7 +387,7 @@ The `finance` partial bundle contains trace modules `scatter`, `bar`, `histogram | Raw size | Minified size | Minified + gzip size | |------|-----------------|------------------------| -| 2.3 MB | 818.1 kB | 266.9 kB | +| 2.3 MB | 837.9 kB | 273.1 kB | #### CDN links @@ -395,8 +395,8 @@ The `finance` partial bundle contains trace modules `scatter`, `bar`, `histogram | ------ | --- | | Latest | https://cdn.plot.ly/plotly-finance-latest.js | | Latest minified | https://cdn.plot.ly/plotly-finance-latest.min.js | -| Tagged | https://cdn.plot.ly/plotly-finance-1.42.5.js | -| Tagged minified | https://cdn.plot.ly/plotly-finance-1.42.5.min.js | +| Tagged | https://cdn.plot.ly/plotly-finance-1.43.0.js | +| Tagged minified | https://cdn.plot.ly/plotly-finance-1.43.0.min.js | #### npm package (starting in `v1.39.0`) diff --git a/dist/plot-schema.json b/dist/plot-schema.json index 4b794ea6bc8..83c3a657786 100644 --- a/dist/plot-schema.json +++ b/dist/plot-schema.json @@ -387,6 +387,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -507,6 +513,14 @@ "editType": "style", "description": "Do the hover effects highlight individual points (markers or line points) or do they highlight filled regions? If the fill is *toself* or *tonext* and there are no markers or text, then the default is *fills*, otherwise it is *points*." }, + "hovertemplate": { + "valType": "string", + "role": "info", + "dflt": "", + "arrayOk": true, + "editType": "none", + "description": "Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example \"Price: %{y:$.2f}\". See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. Anything contained in tag `` is displayed in the secondary box, for example \"{fullData.name}\"." + }, "line": { "color": { "valType": "color", @@ -1344,46 +1358,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -1467,7 +1528,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.line.color`is set to a numerical array. If true, `marker.line.cmin` will correspond to the last color in the array and `marker.line.cmax` will correspond to the first color." }, "role": "object", @@ -1579,7 +1640,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color." }, "showscale": { @@ -2102,6 +2163,12 @@ "description": "Sets the source reference on plot.ly for hovertext .", "editType": "none" }, + "hovertemplatesrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for hovertemplate .", + "editType": "none" + }, "textpositionsrc": { "valType": "string", "role": "info", @@ -2332,6 +2399,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -2388,6 +2461,14 @@ "editType": "style", "description": "Sets hover text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. To be seen, trace `hoverinfo` must contain a *text* flag." }, + "hovertemplate": { + "valType": "string", + "role": "info", + "dflt": "", + "arrayOk": true, + "editType": "none", + "description": "Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example \"Price: %{y:$.2f}\". See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. Anything contained in tag `` is displayed in the secondary box, for example \"{fullData.name}\"." + }, "textposition": { "valType": "enumerated", "role": "info", @@ -2661,7 +2742,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.line.color`is set to a numerical array. If true, `marker.line.cmin` will correspond to the last color in the array and `marker.line.cmax` will correspond to the first color." }, "role": "object", @@ -2736,7 +2817,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color." }, "showscale": { @@ -3137,46 +3218,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -3638,6 +3766,12 @@ "description": "Sets the source reference on plot.ly for hovertext .", "editType": "none" }, + "hovertemplatesrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for hovertemplate .", + "editType": "none" + }, "textpositionsrc": { "valType": "string", "role": "info", @@ -3924,6 +4058,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "y": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -4829,6 +4969,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "z": { "valType": "data_array", "editType": "calc", @@ -5018,7 +5164,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color." }, "showscale": { @@ -5419,46 +5565,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -5793,6 +5986,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -5957,9 +6156,16 @@ "dflt": null, "role": "style", "editType": "calc", - "impliedEdits": {}, "description": "Obsolete: since v1.42 each bin attribute is auto-determined separately and `autobiny` is not needed. However, we accept `autobiny: true` or `false` and will update `ybins` accordingly before deleting `autobiny` from the trace." }, + "hovertemplate": { + "valType": "string", + "role": "info", + "dflt": "", + "arrayOk": true, + "editType": "none", + "description": "Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example \"Price: %{y:$.2f}\". See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. variable `binNumber` Anything contained in tag `` is displayed in the secondary box, for example \"{fullData.name}\"." + }, "marker": { "line": { "width": { @@ -6029,7 +6235,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.line.color`is set to a numerical array. If true, `marker.line.cmin` will correspond to the last color in the array and `marker.line.cmax` will correspond to the first color." }, "role": "object", @@ -6104,7 +6310,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color." }, "showscale": { @@ -6505,46 +6711,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -6987,6 +7240,12 @@ "role": "info", "description": "Sets the source reference on plot.ly for text .", "editType": "none" + }, + "hovertemplatesrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for hovertemplate .", + "editType": "none" } }, "layoutAttributes": { @@ -7245,6 +7504,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -7379,7 +7644,6 @@ "dflt": null, "role": "style", "editType": "calc", - "impliedEdits": {}, "description": "Obsolete: since v1.42 each bin attribute is auto-determined separately and `autobiny` is not needed. However, we accept `autobiny: true` or `false` and will update `ybins` accordingly before deleting `autobiny` from the trace." }, "xgap": { @@ -7467,7 +7731,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color." }, "showscale": { @@ -7868,46 +8132,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -8237,6 +8548,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -8371,7 +8688,6 @@ "dflt": null, "role": "style", "editType": "calc", - "impliedEdits": {}, "description": "Obsolete: since v1.42 each bin attribute is auto-determined separately and `autobiny` is not needed. However, we accept `autobiny: true` or `false` and will update `ybins` accordingly before deleting `autobiny` from the trace." }, "autocontour": { @@ -8626,7 +8942,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color." }, "showscale": { @@ -9027,46 +9343,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -9375,6 +9738,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "labels": { "valType": "data_array", "editType": "calc", @@ -9506,6 +9875,14 @@ "editType": "none", "description": "Determines which trace information appear on hover. If `none` or `skip` are set, no information is displayed upon hovering. But, if `none` is set, click and hover events are still fired." }, + "hovertemplate": { + "valType": "string", + "role": "info", + "dflt": "", + "arrayOk": true, + "editType": "none", + "description": "Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example \"Price: %{y:$.2f}\". See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. variables `label`, `color`, `value`, `percent` and `text`. Anything contained in tag `` is displayed in the secondary box, for example \"{fullData.name}\"." + }, "textposition": { "valType": "enumerated", "role": "info", @@ -9634,74 +10011,7 @@ "arrayOk": true }, "editType": "calc", - "description": "Sets the font used for `textinfo` lying outside the pie.", - "role": "object", - "familysrc": { - "valType": "string", - "role": "info", - "description": "Sets the source reference on plot.ly for family .", - "editType": "none" - }, - "sizesrc": { - "valType": "string", - "role": "info", - "description": "Sets the source reference on plot.ly for size .", - "editType": "none" - }, - "colorsrc": { - "valType": "string", - "role": "info", - "description": "Sets the source reference on plot.ly for color .", - "editType": "none" - } - }, - "title": { - "valType": "string", - "dflt": "", - "role": "info", - "editType": "calc", - "description": "Sets the title of the pie chart. If it is empty, no title is displayed." - }, - "titleposition": { - "valType": "enumerated", - "values": [ - "top left", - "top center", - "top right", - "middle center", - "bottom left", - "bottom center", - "bottom right" - ], - "role": "info", - "editType": "calc", - "description": "Specifies the location of the `title`." - }, - "titlefont": { - "family": { - "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "editType": "calc", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", - "arrayOk": true - }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc", - "arrayOk": true - }, - "color": { - "valType": "color", - "role": "style", - "editType": "plot", - "arrayOk": true - }, - "editType": "calc", - "description": "Sets the font used for `title`.", + "description": "Sets the font used for `textinfo` lying outside the pie.", "role": "object", "familysrc": { "valType": "string", @@ -9722,6 +10032,77 @@ "editType": "none" } }, + "title": { + "text": { + "valType": "string", + "dflt": "", + "role": "info", + "editType": "calc", + "description": "Sets the title of the pie chart. If it is empty, no title is displayed. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." + }, + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "calc", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "arrayOk": true + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc", + "arrayOk": true + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot", + "arrayOk": true + }, + "editType": "calc", + "description": "Sets the font used for `title`. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "role": "object", + "familysrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for family .", + "editType": "none" + }, + "sizesrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for size .", + "editType": "none" + }, + "colorsrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for color .", + "editType": "none" + } + }, + "position": { + "valType": "enumerated", + "values": [ + "top left", + "top center", + "top right", + "middle center", + "bottom left", + "bottom center", + "bottom right" + ], + "role": "info", + "editType": "calc", + "description": "Specifies the location of the `title`. Note that the title's position used to be set by the now deprecated `titleposition` attribute." + }, + "editType": "calc", + "role": "object" + }, "domain": { "x": { "valType": "info_array", @@ -9836,6 +10217,56 @@ "editType": "calc", "description": "Sets the fraction of larger radius to pull the sectors out from the center. This can be a constant to pull all slices apart from each other equally or an array to highlight one or more slices." }, + "_deprecated": { + "title": { + "valType": "string", + "dflt": "", + "role": "info", + "editType": "calc", + "description": "Deprecated in favor of `title.text`. Note that value of `title` is no longer a simple *string* but a set of sub-attributes." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "calc", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "arrayOk": true + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc", + "arrayOk": true + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot", + "arrayOk": true + }, + "editType": "calc", + "description": "Deprecated in favor of `title.font`." + }, + "titleposition": { + "valType": "enumerated", + "values": [ + "top left", + "top center", + "top right", + "middle center", + "bottom left", + "bottom center", + "bottom right" + ], + "role": "info", + "editType": "calc", + "description": "Deprecated in favor of `title.position`." + } + }, "idssrc": { "valType": "string", "role": "info", @@ -9878,6 +10309,12 @@ "description": "Sets the source reference on plot.ly for hoverinfo .", "editType": "none" }, + "hovertemplatesrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for hovertemplate .", + "editType": "none" + }, "textpositionsrc": { "valType": "string", "role": "info", @@ -10128,6 +10565,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "z": { "valType": "data_array", "editType": "calc", @@ -10490,7 +10933,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color." }, "showscale": { @@ -10891,46 +11334,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -11246,6 +11736,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "a": { "valType": "data_array", "editType": "calc", @@ -11802,7 +12298,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.line.color`is set to a numerical array. If true, `marker.line.cmin` will correspond to the last color in the array and `marker.line.cmax` will correspond to the first color." }, "role": "object", @@ -11914,7 +12410,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color." }, "showscale": { @@ -12315,46 +12811,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -12836,6 +13379,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "y": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -13782,6 +14331,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -14495,46 +15050,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "calc" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "calc" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "calc", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "calc" }, - "description": "Sets this color bar's title font.", "editType": "calc", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "calc" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "calc" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "calc" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "calc" + } }, "editType": "calc", "role": "object", @@ -14731,7 +15333,7 @@ "bottom right" ], "dflt": "top center", - "arrayOk": false, + "arrayOk": true, "role": "style", "editType": "calc", "description": "Sets the positions of the `text` elements with respects to the (x,y) coordinates." @@ -15261,6 +15863,12 @@ "description": "Sets the source reference on plot.ly for hovertext .", "editType": "none" }, + "textpositionsrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for textposition .", + "editType": "none" + }, "hoverinfosrc": { "valType": "string", "role": "info", @@ -15440,6 +16048,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "z": { "valType": "data_array", "description": "Sets the z coordinates.", @@ -15923,46 +16537,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "calc" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "calc" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "calc", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "calc" }, - "description": "Sets this color bar's title font.", "editType": "calc", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "calc" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "calc" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "calc" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "calc" + } }, "editType": "calc", "role": "object", @@ -16662,6 +17323,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -16799,7 +17466,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. If true, `cmin` will correspond to the last color in the array and `cmax` will correspond to the first color." }, "showscale": { @@ -17200,46 +17867,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -17750,6 +18464,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "role": "data", @@ -17875,7 +18595,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. If true, `cmin` will correspond to the last color in the array and `cmax` will correspond to the first color." }, "showscale": { @@ -18276,46 +18996,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -18703,6 +19470,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "role": "data", @@ -18852,7 +19625,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. If true, `cmin` will correspond to the last color in the array and `cmax` will correspond to the first color." }, "showscale": { @@ -19253,46 +20026,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -19695,6 +20515,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "lon": { "valType": "data_array", "description": "Sets the longitude coordinates (in degrees East).", @@ -20590,46 +21416,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "calc" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "calc" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "calc", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "calc" }, - "description": "Sets this color bar's title font.", "editType": "calc", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "calc" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "calc" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "calc" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "calc" + } }, "editType": "calc", "role": "object", @@ -21229,6 +22102,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "locations": { "valType": "data_array", "editType": "calc", @@ -21414,7 +22293,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color." }, "showscale": { @@ -21815,46 +22694,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -22118,6 +23044,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -23096,46 +24028,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "calc" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "calc" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "calc", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "calc" }, - "description": "Sets this color bar's title font.", "editType": "calc", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "calc" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "calc" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "calc" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "calc" + } }, "editType": "calc", "role": "object", @@ -23379,6 +24358,14 @@ "editType": "calc", "description": "Sets the opacity of the trace." }, + "hovertemplate": { + "valType": "string", + "role": "info", + "dflt": "", + "arrayOk": true, + "editType": "none", + "description": "Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example \"Price: %{y:$.2f}\". See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. Anything contained in tag `` is displayed in the secondary box, for example \"{fullData.name}\"." + }, "error_x": { "visible": { "valType": "boolean", @@ -23717,6 +24704,12 @@ "role": "info", "description": "Sets the source reference on plot.ly for textposition .", "editType": "none" + }, + "hovertemplatesrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for hovertemplate .", + "editType": "none" } } }, @@ -23921,6 +24914,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "dimensions": { "items": { "dimension": { @@ -24049,7 +25048,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color." }, "showscale": { @@ -24788,46 +25787,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -24902,7 +25948,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.line.color`is set to a numerical array. If true, `marker.line.cmin` will correspond to the last color in the array and `marker.line.cmax` will correspond to the first color." }, "width": { @@ -25297,6 +26343,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -25692,6 +26744,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "z": { "valType": "data_array", "editType": "calc", @@ -26240,46 +27298,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "calc" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "calc" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "calc", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "calc" }, - "description": "Sets this color bar's title font.", "editType": "calc", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "calc" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "calc" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "calc" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "calc" + } }, "editType": "calc", "role": "object", @@ -26475,6 +27580,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "domain": { "x": { "valType": "info_array", @@ -26861,7 +27972,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `line.color`is set to a numerical array. If true, `line.cmin` will correspond to the last color in the array and `line.cmax` will correspond to the first color." }, "showscale": { @@ -27262,46 +28373,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -27407,6 +28565,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "domain": { "x": { "valType": "info_array", @@ -27720,7 +28884,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `line.color`is set to a numerical array. If true, `line.cmin` will correspond to the last color in the array and `line.cmax` will correspond to the first color." }, "showscale": { @@ -28121,46 +29285,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -28404,6 +29615,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "lon": { "valType": "data_array", "description": "Sets the longitude coordinates (in degrees East).", @@ -28983,46 +30200,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "calc" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "calc" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "calc", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "calc" }, - "description": "Sets this color bar's title font.", "editType": "calc", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "calc" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "calc" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "calc" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "calc" + } }, "editType": "calc", "role": "object", @@ -29346,6 +30610,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "hoverinfo": { "valType": "flaglist", "role": "info", @@ -29746,6 +31016,14 @@ "editType": "none" } }, + "hovertemplate": { + "valType": "string", + "role": "info", + "dflt": "", + "arrayOk": true, + "editType": "calc", + "description": "Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example \"Price: %{y:$.2f}\". See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. variables `value` and `label`. Anything contained in tag `` is displayed in the secondary box, for example \"{fullData.name}\"." + }, "description": "The nodes of the Sankey plot.", "editType": "calc", "role": "object", @@ -29760,6 +31038,12 @@ "role": "info", "description": "Sets the source reference on plot.ly for color .", "editType": "none" + }, + "hovertemplatesrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for hovertemplate .", + "editType": "none" } }, "link": { @@ -29932,6 +31216,14 @@ "editType": "none" } }, + "hovertemplate": { + "valType": "string", + "role": "info", + "dflt": "", + "arrayOk": true, + "editType": "calc", + "description": "Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example \"y: %{y}\". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example \"Price: %{y:$.2f}\". See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. variables `value` and `label`. Anything contained in tag `` is displayed in the secondary box, for example \"{fullData.name}\"." + }, "description": "The links of the Sankey plot.", "editType": "calc", "role": "object", @@ -29964,6 +31256,12 @@ "role": "info", "description": "Sets the source reference on plot.ly for value .", "editType": "none" + }, + "hovertemplatesrc": { + "valType": "string", + "role": "info", + "description": "Sets the source reference on plot.ly for hovertemplate .", + "editType": "none" } }, "idssrc": { @@ -30180,6 +31478,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "domain": { "x": { "valType": "info_array", @@ -30849,6 +32153,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "carpet": { "valType": "string", "role": "info", @@ -30930,42 +32240,47 @@ "editType": "calc" }, "title": { - "valType": "string", - "role": "info", - "editType": "calc", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "dflt": "", + "role": "info", "editType": "calc", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "calc", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "editType": "calc", + "description": "Sets this axis' title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "role": "object" }, - "color": { - "valType": "color", - "role": "style", - "editType": "calc" + "offset": { + "valType": "number", + "role": "info", + "dflt": 10, + "editType": "calc", + "description": "An additional amount by which to offset the title from the tick labels, given in pixels. Note that this used to be set by the now deprecated `titleoffset` attribute." }, "editType": "calc", - "description": "Sets this axis' title font.", "role": "object" }, - "titleoffset": { - "valType": "number", - "role": "info", - "dflt": 10, - "editType": "calc", - "description": "An additional amount by which to offset the title from the tick labels, given in pixels" - }, "type": { "valType": "enumerated", "values": [ @@ -31418,6 +32733,44 @@ "editType": "calc", "description": "The stride between grid lines along the axis" }, + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "calc", + "description": "Deprecated in favor of `title.text`. Note that value of `title` is no longer a simple *string* but a set of sub-attributes." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "calc", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "editType": "calc", + "description": "Deprecated in favor of `title.font`." + }, + "titleoffset": { + "valType": "number", + "role": "info", + "dflt": 10, + "editType": "calc", + "description": "Deprecated in favor of `title.offset`." + } + }, "editType": "calc", "role": "object", "tickvalssrc": { @@ -31455,42 +32808,47 @@ "editType": "calc" }, "title": { - "valType": "string", - "role": "info", - "editType": "calc", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "dflt": "", + "role": "info", "editType": "calc", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "calc", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "editType": "calc", + "description": "Sets this axis' title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "role": "object" }, - "color": { - "valType": "color", - "role": "style", - "editType": "calc" + "offset": { + "valType": "number", + "role": "info", + "dflt": 10, + "editType": "calc", + "description": "An additional amount by which to offset the title from the tick labels, given in pixels. Note that this used to be set by the now deprecated `titleoffset` attribute." }, "editType": "calc", - "description": "Sets this axis' title font.", "role": "object" }, - "titleoffset": { - "valType": "number", - "role": "info", - "dflt": 10, - "editType": "calc", - "description": "An additional amount by which to offset the title from the tick labels, given in pixels" - }, "type": { "valType": "enumerated", "values": [ @@ -31943,6 +33301,44 @@ "editType": "calc", "description": "The stride between grid lines along the axis" }, + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "calc", + "description": "Deprecated in favor of `title.text`. Note that value of `title` is no longer a simple *string* but a set of sub-attributes." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "calc", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "editType": "calc", + "description": "Deprecated in favor of `title.font`." + }, + "titleoffset": { + "valType": "number", + "role": "info", + "dflt": 10, + "editType": "calc", + "description": "Deprecated in favor of `title.offset`." + } + }, "editType": "calc", "role": "object", "tickvalssrc": { @@ -32247,6 +33643,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "carpet": { "valType": "string", "role": "info", @@ -32780,7 +34182,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.line.color`is set to a numerical array. If true, `marker.line.cmin` will correspond to the last color in the array and `marker.line.cmax` will correspond to the first color." }, "role": "object", @@ -32892,7 +34294,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color." }, "showscale": { @@ -33293,46 +34695,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -33805,6 +35254,12 @@ "editType": "calc", "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "carpet": { "valType": "string", "role": "info", @@ -34158,7 +35613,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color." }, "showscale": { @@ -34559,46 +36014,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -34794,6 +36296,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -35256,6 +36764,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "x": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -35786,6 +37300,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "mode": { "valType": "flaglist", "flags": [ @@ -36665,46 +38185,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -36788,7 +38355,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.line.color`is set to a numerical array. If true, `marker.line.cmin` will correspond to the last color in the array and `marker.line.cmax` will correspond to the first color." }, "role": "object", @@ -36900,7 +38467,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color." }, "showscale": { @@ -37380,6 +38947,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "mode": { "valType": "flaglist", "flags": [ @@ -38312,46 +39885,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "calc" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "calc" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "calc" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "calc", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "calc" }, - "description": "Sets this color bar's title font.", "editType": "calc", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "calc" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "calc" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "calc" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "calc" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "calc" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "calc" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "calc" + } }, "editType": "calc", "role": "object", @@ -38910,6 +40530,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "r": { "valType": "data_array", "editType": "calc+clearAxisTypes", @@ -39063,7 +40689,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.line.color`is set to a numerical array. If true, `marker.line.cmin` will correspond to the last color in the array and `marker.line.cmax` will correspond to the first color." }, "role": "object", @@ -39138,7 +40764,7 @@ "valType": "boolean", "role": "style", "dflt": false, - "editType": "calc", + "editType": "plot", "description": "Reverses the color mapping if true. Has an effect only if in `marker.color`is set to a numerical array. If true, `marker.cmin` will correspond to the last color in the array and `marker.cmax` will correspond to the first color." }, "showscale": { @@ -39539,46 +41165,93 @@ "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear." }, "title": { - "valType": "string", - "role": "info", - "description": "Sets the title of the color bar.", - "editType": "colorbars" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "role": "info", + "description": "Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", "editType": "colorbars" }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "colorbars" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute.", + "editType": "colorbars", + "role": "object" }, - "color": { - "valType": "color", + "side": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], "role": "style", + "dflt": "top", + "description": "Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute.", "editType": "colorbars" }, - "description": "Sets this color bar's title font.", "editType": "colorbars", "role": "object" }, - "titleside": { - "valType": "enumerated", - "values": [ - "right", - "top", - "bottom" - ], - "role": "style", - "dflt": "top", - "description": "Determines the location of the colorbar title with respect to the color bar.", - "editType": "colorbars" + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "description": "Deprecated in favor of color bar's `title.text`. Note that value of color bar's `title` is no longer a simple *string* but a set of sub-attributes.", + "editType": "colorbars" + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "editType": "colorbars" + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "colorbars" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "colorbars" + }, + "description": "Deprecated in favor of color bar's `title.font`.", + "editType": "colorbars" + }, + "titleside": { + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ], + "role": "style", + "dflt": "top", + "description": "Deprecated in favor of color bar's `title.side`.", + "editType": "colorbars" + } }, "editType": "colorbars", "role": "object", @@ -39995,6 +41668,12 @@ }, "role": "object" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves." + }, "r": { "valType": "data_array", "editType": "calc", @@ -40417,33 +42096,136 @@ "role": "object" }, "title": { - "valType": "string", - "role": "info", - "editType": "layoutstyle", - "description": "Sets the plot's title." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "layoutstyle", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + "description": "Sets the plot's title. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "size": { + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "layoutstyle", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "layoutstyle" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "layoutstyle" + }, + "editType": "layoutstyle", + "description": "Sets the title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" + }, + "xref": { + "valType": "enumerated", + "dflt": "container", + "values": [ + "container", + "paper" + ], + "role": "info", + "editType": "layoutstyle", + "description": "Sets the container `x` refers to. *container* spans the entire `width` of the plot. *paper* refers to the width of the plotting area only." + }, + "yref": { + "valType": "enumerated", + "dflt": "container", + "values": [ + "container", + "paper" + ], + "role": "info", + "editType": "layoutstyle", + "description": "Sets the container `y` refers to. *container* spans the entire `height` of the plot. *paper* refers to the height of the plotting area only." + }, + "x": { "valType": "number", + "min": 0, + "max": 1, + "dflt": 0.5, "role": "style", - "min": 1, - "editType": "layoutstyle" + "editType": "layoutstyle", + "description": "Sets the x position with respect to `xref` in normalized coordinates from *0* (left) to *1* (right)." }, - "color": { - "valType": "color", + "y": { + "valType": "number", + "min": 0, + "max": 1, + "dflt": "auto", "role": "style", - "editType": "layoutstyle" + "editType": "layoutstyle", + "description": "Sets the y position with respect to `yref` in normalized coordinates from *0* (bottom) to *1* (top). *auto* places the baseline of the title onto the vertical center of the top margin." + }, + "xanchor": { + "valType": "enumerated", + "dflt": "auto", + "values": [ + "auto", + "left", + "center", + "right" + ], + "role": "info", + "editType": "layoutstyle", + "description": "Sets the title's horizontal alignment with respect to its x position. *left* means that the title starts at x, *right* means that the title ends at x and *center* means that the title's center is at x. *auto* divides `xref` by three and calculates the `xanchor` value automatically based on the value of `x`." + }, + "yanchor": { + "valType": "enumerated", + "dflt": "auto", + "values": [ + "auto", + "top", + "middle", + "bottom" + ], + "role": "info", + "editType": "layoutstyle", + "description": "Sets the title's vertical alignment with respect to its y position. *top* means that the title's cap line is at y, *bottom* means that the title's baseline is at y and *middle* means that the title's midline is at y. *auto* divides `yref` by three and calculates the `yanchor` value automatically based on the value of `y`." + }, + "pad": { + "t": { + "valType": "number", + "dflt": 0, + "role": "style", + "editType": "layoutstyle", + "description": "The amount of padding (in px) along the top of the component." + }, + "r": { + "valType": "number", + "dflt": 0, + "role": "style", + "editType": "layoutstyle", + "description": "The amount of padding (in px) on the right side of the component." + }, + "b": { + "valType": "number", + "dflt": 0, + "role": "style", + "editType": "layoutstyle", + "description": "The amount of padding (in px) along the bottom of the component." + }, + "l": { + "valType": "number", + "dflt": 0, + "role": "style", + "editType": "layoutstyle", + "description": "The amount of padding (in px) on the left side of the component." + }, + "editType": "layoutstyle", + "description": "Sets the padding of the title. Each padding value only applies when the corresponding `xanchor`/`yanchor` value is set accordingly. E.g. for left padding to take effect, `xanchor` must be set to *left*. The same rule applies if `xanchor`/`yanchor` is determined automatically. Padding is muted if the respective anchor value is *middle*/*center*.", + "role": "object" }, "editType": "layoutstyle", - "description": "Sets the title font.", "role": "object" }, "autosize": { @@ -40570,12 +42352,122 @@ "editType": "calc", "description": "Sets the default trace colors." }, + "colorscale": { + "editType": "calc", + "sequential": { + "valType": "colorscale", + "dflt": [ + [ + 0, + "rgb(220,220,220)" + ], + [ + 0.2, + "rgb(245,195,157)" + ], + [ + 0.4, + "rgb(245,160,105)" + ], + [ + 1, + "rgb(178,10,28)" + ] + ], + "role": "style", + "editType": "calc", + "description": "Sets the default sequential colorscale for positive values. Note that `autocolorscale` must be true for this attribute to work." + }, + "sequentialminus": { + "valType": "colorscale", + "dflt": [ + [ + 0, + "rgb(5,10,172)" + ], + [ + 0.35, + "rgb(40,60,190)" + ], + [ + 0.5, + "rgb(70,100,245)" + ], + [ + 0.6, + "rgb(90,120,245)" + ], + [ + 0.7, + "rgb(106,137,247)" + ], + [ + 1, + "rgb(220,220,220)" + ] + ], + "role": "style", + "editType": "calc", + "description": "Sets the default sequential colorscale for negative values. Note that `autocolorscale` must be true for this attribute to work." + }, + "diverging": { + "valType": "colorscale", + "dflt": [ + [ + 0, + "rgb(5,10,172)" + ], + [ + 0.35, + "rgb(106,137,247)" + ], + [ + 0.5, + "rgb(190,190,190)" + ], + [ + 0.6, + "rgb(220,170,132)" + ], + [ + 0.7, + "rgb(230,145,90)" + ], + [ + 1, + "rgb(178,10,28)" + ] + ], + "role": "style", + "editType": "calc", + "description": "Sets the default diverging colorscale. Note that `autocolorscale` must be true for this attribute to work." + }, + "role": "object" + }, "datarevision": { "valType": "any", "role": "info", "editType": "calc", "description": "If provided, a changed value tells `Plotly.react` that one or more data arrays has changed. This way you can modify arrays in-place rather than making a complete new copy for an incremental change. If NOT provided, `Plotly.react` assumes that data arrays are being treated as immutable, thus any data array with a different identity from its predecessor contains new data." }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Used to allow user interactions with the plot to persist after `Plotly.react` calls that are unaware of these interactions. If `uirevision` is omitted, or if it is given and it changed from the previous `Plotly.react` call, the exact new figure is used. If `uirevision` is truthy and did NOT change, any attribute that has been affected by user interactions and did not receive a different value in the new figure will keep the interaction value. `layout.uirevision` attribute serves as the default for `uirevision` attributes in various sub-containers. For finer control you can set these sub-attributes directly. For example, if your app separately controls the data on the x and y axes you might set `xaxis.uirevision=*time*` and `yaxis.uirevision=*cost*`. Then if only the y data is changed, you can update `yaxis.uirevision=*quantity*` and the y axis range will reset but the x axis range will retain any user-driven zoom." + }, + "editrevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in `editable: true` configuration, other than trace names and axis titles. Defaults to `layout.uirevision`." + }, + "selectionrevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in selected points from all traces." + }, "template": { "valType": "any", "role": "info", @@ -40612,9 +42504,46 @@ "editType": "modebar", "description": "Sets the color of the active or hovered on icons in the modebar." }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes related to the modebar, including `hovermode`, `dragmode`, and `showspikes` at both the root level and inside subplots. Defaults to `layout.uirevision`." + }, "editType": "modebar", "role": "object" }, + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "layoutstyle", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the contents of the title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "layoutstyle", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "layoutstyle" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "layoutstyle" + }, + "editType": "layoutstyle", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." + } + }, "clickmode": { "valType": "flaglist", "role": "info", @@ -40638,7 +42567,8 @@ "select", "lasso", "orbit", - "turntable" + "turntable", + false ], "dflt": "zoom", "editType": "modebar", @@ -40955,33 +42885,37 @@ "description": "Sets default for all colors associated with this axis all at once: line, font, tick, and grid colors. Grid color is lightened by blending this with the plot background Individual pieces can override this." }, "title": { - "valType": "string", - "role": "info", - "editType": "ticks", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "ticks", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." - }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "ticks" + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "color": { - "valType": "color", - "role": "style", - "editType": "ticks" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "ticks", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "ticks" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "ticks" + }, + "editType": "ticks", + "description": "Sets this axis' title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" }, "editType": "ticks", - "description": "Sets this axis' title font.", "role": "object" }, "type": { @@ -40991,7 +42925,8 @@ "linear", "log", "date", - "category" + "category", + "multicategory" ], "dflt": "-", "role": "info", @@ -41160,6 +43095,17 @@ "editType": "ticks", "description": "Determines whether ticks are drawn or not. If **, this axis' ticks are not drawn. If *outside* (*inside*), this axis' are drawn outside (inside) the axis lines." }, + "tickson": { + "valType": "enumerated", + "values": [ + "labels", + "boundaries" + ], + "role": "info", + "dflt": "labels", + "editType": "ticks", + "description": "Determines where ticks and grid lines are drawn with respect to their corresponding tick labels. Only has an effect for axes of `type` *category* or *multicategory*. When set to *boundaries*, ticks and grid lines are drawn half a category to the left/bottom of labels." + }, "mirror": { "valType": "enumerated", "values": [ @@ -41504,6 +43450,27 @@ "editType": "ticks", "description": "Sets the width (in px) of the zero line." }, + "showdividers": { + "valType": "boolean", + "dflt": true, + "role": "style", + "editType": "ticks", + "description": "Determines whether or not a dividers are drawn between the category levels of this axis. Only has an effect on *multicategory* axes." + }, + "dividercolor": { + "valType": "color", + "dflt": "#444", + "role": "style", + "editType": "ticks", + "description": "Sets the color of the dividers Only has an effect on *multicategory* axes." + }, + "dividerwidth": { + "valType": "number", + "dflt": 1, + "role": "style", + "editType": "ticks", + "description": "Sets the width (in px) of the dividers Only has an effect on *multicategory* axes." + }, "anchor": { "valType": "enumerated", "values": [ @@ -41601,6 +43568,12 @@ "editType": "calc", "description": "Sets the order in which categories on this axis appear. Only has an effect if `categoryorder` is set to *array*. Used with `categoryorder`." }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in axis `range`, `autorange`, and `title` if in `editable: true` configuration. Defaults to `layout.uirevision`." + }, "editType": "calc", "_deprecated": { "autotick": { @@ -41608,6 +43581,35 @@ "role": "info", "editType": "ticks", "description": "Obsolete. Set `tickmode` to *auto* for old `autotick` *true* behavior. Set `tickmode` to *linear* for `autotick` *false*." + }, + "title": { + "valType": "string", + "role": "info", + "editType": "ticks", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the axis' title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "ticks", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "ticks" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "ticks" + }, + "editType": "ticks", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." } }, "rangeslider": { @@ -41953,33 +43955,37 @@ "description": "Sets default for all colors associated with this axis all at once: line, font, tick, and grid colors. Grid color is lightened by blending this with the plot background Individual pieces can override this." }, "title": { - "valType": "string", - "role": "info", - "editType": "ticks", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "ticks", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." - }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "ticks" + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "color": { - "valType": "color", - "role": "style", - "editType": "ticks" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "ticks", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "ticks" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "ticks" + }, + "editType": "ticks", + "description": "Sets this axis' title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" }, "editType": "ticks", - "description": "Sets this axis' title font.", "role": "object" }, "type": { @@ -41989,7 +43995,8 @@ "linear", "log", "date", - "category" + "category", + "multicategory" ], "dflt": "-", "role": "info", @@ -42158,6 +44165,17 @@ "editType": "ticks", "description": "Determines whether ticks are drawn or not. If **, this axis' ticks are not drawn. If *outside* (*inside*), this axis' are drawn outside (inside) the axis lines." }, + "tickson": { + "valType": "enumerated", + "values": [ + "labels", + "boundaries" + ], + "role": "info", + "dflt": "labels", + "editType": "ticks", + "description": "Determines where ticks and grid lines are drawn with respect to their corresponding tick labels. Only has an effect for axes of `type` *category* or *multicategory*. When set to *boundaries*, ticks and grid lines are drawn half a category to the left/bottom of labels." + }, "mirror": { "valType": "enumerated", "values": [ @@ -42502,6 +44520,27 @@ "editType": "ticks", "description": "Sets the width (in px) of the zero line." }, + "showdividers": { + "valType": "boolean", + "dflt": true, + "role": "style", + "editType": "ticks", + "description": "Determines whether or not a dividers are drawn between the category levels of this axis. Only has an effect on *multicategory* axes." + }, + "dividercolor": { + "valType": "color", + "dflt": "#444", + "role": "style", + "editType": "ticks", + "description": "Sets the color of the dividers Only has an effect on *multicategory* axes." + }, + "dividerwidth": { + "valType": "number", + "dflt": 1, + "role": "style", + "editType": "ticks", + "description": "Sets the width (in px) of the dividers Only has an effect on *multicategory* axes." + }, "anchor": { "valType": "enumerated", "values": [ @@ -42599,6 +44638,12 @@ "editType": "calc", "description": "Sets the order in which categories on this axis appear. Only has an effect if `categoryorder` is set to *array*. Used with `categoryorder`." }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in axis `range`, `autorange`, and `title` if in `editable: true` configuration. Defaults to `layout.uirevision`." + }, "editType": "calc", "_deprecated": { "autotick": { @@ -42606,6 +44651,35 @@ "role": "info", "editType": "ticks", "description": "Obsolete. Set `tickmode` to *auto* for old `autotick` *true* behavior. Set `tickmode` to *linear* for `autotick` *false*." + }, + "title": { + "valType": "string", + "role": "info", + "editType": "ticks", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the axis' title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "ticks", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "ticks" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "ticks" + }, + "editType": "ticks", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." } }, "calendar": { @@ -42740,33 +44814,37 @@ }, "aaxis": { "title": { - "valType": "string", - "role": "info", - "editType": "plot", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "plot", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." - }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "plot" + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "color": { - "valType": "color", - "role": "style", - "editType": "plot" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Sets this axis' title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" }, "editType": "plot", - "description": "Sets this axis' title font.", "role": "object" }, "color": { @@ -43101,7 +45179,44 @@ "description": "The minimum value visible on this axis. The maximum is determined by the sum minus the minimum values of the other two axes. The full view corresponds to all the minima set to zero.", "editType": "plot" }, + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "plot", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the axis' title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." + } + }, "editType": "plot", + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in axis `min`, and `title` if in `editable: true` configuration. Defaults to `ternary.uirevision`." + }, "role": "object", "tickvalssrc": { "valType": "string", @@ -43118,33 +45233,37 @@ }, "baxis": { "title": { - "valType": "string", - "role": "info", - "editType": "plot", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "plot", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "plot" - }, - "color": { - "valType": "color", - "role": "style", - "editType": "plot" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Sets this axis' title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" }, "editType": "plot", - "description": "Sets this axis' title font.", "role": "object" }, "color": { @@ -43479,7 +45598,44 @@ "description": "The minimum value visible on this axis. The maximum is determined by the sum minus the minimum values of the other two axes. The full view corresponds to all the minima set to zero.", "editType": "plot" }, + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "plot", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the axis' title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." + } + }, "editType": "plot", + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in axis `min`, and `title` if in `editable: true` configuration. Defaults to `ternary.uirevision`." + }, "role": "object", "tickvalssrc": { "valType": "string", @@ -43496,33 +45652,37 @@ }, "caxis": { "title": { - "valType": "string", - "role": "info", - "editType": "plot", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "plot", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "plot" - }, - "color": { - "valType": "color", - "role": "style", - "editType": "plot" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Sets this axis' title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" }, "editType": "plot", - "description": "Sets this axis' title font.", "role": "object" }, "color": { @@ -43857,7 +46017,44 @@ "description": "The minimum value visible on this axis. The maximum is determined by the sum minus the minimum values of the other two axes. The full view corresponds to all the minima set to zero.", "editType": "plot" }, + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "plot", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the axis' title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." + } + }, "editType": "plot", + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in axis `min`, and `title` if in `editable: true` configuration. Defaults to `ternary.uirevision`." + }, "role": "object", "tickvalssrc": { "valType": "string", @@ -43873,6 +46070,12 @@ } }, "editType": "plot", + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in axis `min` and `title`, if not overridden in the individual axes. Defaults to `layout.uirevision`." + }, "_isSubplotObj": true, "role": "object" }, @@ -44161,33 +46364,37 @@ "description": "Sets the order in which categories on this axis appear. Only has an effect if `categoryorder` is set to *array*. Used with `categoryorder`." }, "title": { - "valType": "string", - "role": "info", - "editType": "plot", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "plot", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "plot" - }, - "color": { - "valType": "color", - "role": "style", - "editType": "plot" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Sets this axis' title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" }, "editType": "plot", - "description": "Sets this axis' title font.", "role": "object" }, "type": { @@ -44594,6 +46801,37 @@ "editType": "plot", "description": "Sets the width (in px) of the zero line." }, + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "plot", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the axis' title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." + } + }, "editType": "plot", "calendar": { "valType": "enumerated", @@ -44724,33 +46962,37 @@ "description": "Sets the order in which categories on this axis appear. Only has an effect if `categoryorder` is set to *array*. Used with `categoryorder`." }, "title": { - "valType": "string", - "role": "info", - "editType": "plot", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "plot", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." - }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "plot" + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "color": { - "valType": "color", - "role": "style", - "editType": "plot" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Sets this axis' title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" }, "editType": "plot", - "description": "Sets this axis' title font.", "role": "object" }, "type": { @@ -45157,6 +47399,37 @@ "editType": "plot", "description": "Sets the width (in px) of the zero line." }, + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "plot", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the axis' title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." + } + }, "editType": "plot", "calendar": { "valType": "enumerated", @@ -45287,33 +47560,37 @@ "description": "Sets the order in which categories on this axis appear. Only has an effect if `categoryorder` is set to *array*. Used with `categoryorder`." }, "title": { - "valType": "string", - "role": "info", - "editType": "plot", - "description": "Sets the title of this axis." - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "plot", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." - }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "plot" + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated." }, - "color": { - "valType": "color", - "role": "style", - "editType": "plot" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Sets this axis' title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" }, "editType": "plot", - "description": "Sets this axis' title font.", "role": "object" }, "type": { @@ -45720,6 +47997,37 @@ "editType": "plot", "description": "Sets the width (in px) of the zero line." }, + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "plot", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the axis' title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." + } + }, "editType": "plot", "calendar": { "valType": "enumerated", @@ -45776,7 +48084,6 @@ "pan", false ], - "dflt": "turntable", "editType": "plot", "description": "Determines the mode of drag interactions for this scene." }, @@ -45791,6 +48098,12 @@ "editType": "modebar", "description": "Determines the mode of hover interactions for this scene." }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in camera attributes. Defaults to `layout.uirevision`." + }, "editType": "plot", "_deprecated": { "cameraposition": { @@ -46610,6 +48923,12 @@ "role": "object" }, "editType": "plot", + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in the view (projection and center). Defaults to `layout.uirevision`." + }, "_isSubplotObj": true, "role": "object" }, @@ -46939,6 +49258,12 @@ "role": "object" }, "editType": "plot", + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in the view: `center`, `zoom`, `bearing`, `pitch`. Defaults to `layout.uirevision`." + }, "_isSubplotObj": true, "role": "object" }, @@ -47157,34 +49482,38 @@ "description": "Determines on which side of radial axis line the tick and tick labels appear." }, "title": { - "valType": "string", - "role": "info", - "editType": "plot", - "description": "Sets the title of this axis.", - "dflt": "" - }, - "titlefont": { - "family": { + "text": { "valType": "string", - "role": "style", - "noBlank": true, - "strict": true, + "role": "info", "editType": "plot", - "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." - }, - "size": { - "valType": "number", - "role": "style", - "min": 1, - "editType": "plot" + "description": "Sets the title of this axis. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.", + "dflt": "" }, - "color": { - "valType": "color", - "role": "style", - "editType": "plot" + "font": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "plot", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "plot" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "plot" + }, + "editType": "plot", + "description": "Sets this axis' title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.", + "role": "object" }, "editType": "plot", - "description": "Sets this axis' title font.", "role": "object" }, "hoverformat": { @@ -47194,7 +49523,44 @@ "editType": "none", "description": "Sets the hover text formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/blob/master/README.md#locale_format And for dates see: https://github.com/d3/d3-time-format/blob/master/README.md#locale_format We add one item to d3's date formatter: *%{n}f* for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat *%H~%M~%S.%2f* would display *09~15~23.46*" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in axis `range`, `autorange`, `angle`, and `title` if in `editable: true` configuration. Defaults to `polar.uirevision`." + }, "editType": "plot", + "_deprecated": { + "title": { + "valType": "string", + "role": "info", + "editType": "ticks", + "description": "Value of `title` is no longer a simple *string* but a set of sub-attributes. To set the axis' title, please use `title.text` now." + }, + "titlefont": { + "family": { + "valType": "string", + "role": "style", + "noBlank": true, + "strict": true, + "editType": "ticks", + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*." + }, + "size": { + "valType": "number", + "role": "style", + "min": 1, + "editType": "ticks" + }, + "color": { + "valType": "color", + "role": "style", + "editType": "ticks" + }, + "editType": "ticks", + "description": "Former `titlefont` is now the sub-attribute `font` of `title`. To customize title font properties, please use `title.font` now." + } + }, "color": { "valType": "color", "dflt": "#444", @@ -47639,6 +50005,12 @@ "editType": "none", "description": "Sets the hover text formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/blob/master/README.md#locale_format And for dates see: https://github.com/d3/d3-time-format/blob/master/README.md#locale_format We add one item to d3's date formatter: *%{n}f* for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat *%H~%M~%S.%2f* would display *09~15~23.46*" }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in axis `rotation`. Defaults to `polar.uirevision`." + }, "editType": "plot", "color": { "valType": "color", @@ -47988,6 +50360,12 @@ "editType": "plot", "description": "Determines if the radial axis grid lines and angular axis line are drawn as *circular* sectors or as *linear* (polygon) sectors. Has an effect only when the angular axis has `type` *category*. Note that `radialaxis.angle` is snapped to the angle of the closest vertex when `gridshape` is *circular* (so that radial axis scale is the same as the data scale)." }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of user-driven changes in axis attributes, if not overridden in the individual axes. Defaults to `layout.uirevision`." + }, "editType": "calc", "_isSubplotObj": true, "role": "object" @@ -48333,6 +50711,24 @@ "editType": "legend", "description": "Sets the legend's vertical position anchor This anchor binds the `y` position to the *top*, *middle* or *bottom* of the legend." }, + "uirevision": { + "valType": "any", + "role": "info", + "editType": "none", + "description": "Controls persistence of legend-driven changes in trace and pie label visibility. Defaults to `layout.uirevision`." + }, + "valign": { + "valType": "enumerated", + "values": [ + "top", + "middle", + "bottom" + ], + "dflt": "middle", + "role": "style", + "editType": "legend", + "description": "Sets the vertical alignment of the symbols with respect to their associated text." + }, "editType": "legend", "role": "object" }, diff --git a/dist/plotly-basic.js b/dist/plotly-basic.js index 3824e5ca43a..1c718fd2eaf 100644 --- a/dist/plotly-basic.js +++ b/dist/plotly-basic.js @@ -1,5 +1,5 @@ /** -* plotly.js (basic) v1.42.5 +* plotly.js (basic) v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license @@ -39,8 +39,8 @@ var rules = { "X .cursor-ne-resize": "cursor:ne-resize;", "X .cursor-grab": "cursor:-webkit-grab;cursor:grab;", "X .modebar": "position:absolute;top:2px;right:2px;z-index:1001;", - "X .modebar--hover": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", - "X:hover .modebar--hover": "opacity:1;", + "X .modebar--hover>:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", + "X:hover .modebar--hover .modebar-group": "opacity:1;", "X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;", "X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;", "X .modebar-btn svg": "position:relative;top:2px;", @@ -71,7 +71,7 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":161}],2:[function(_dereq_,module,exports){ +},{"../src/lib":159}],2:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -214,7 +214,7 @@ module.exports = { module.exports = _dereq_('../src/traces/bar'); -},{"../src/traces/bar":261}],4:[function(_dereq_,module,exports){ +},{"../src/traces/bar":260}],4:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -227,7 +227,7 @@ module.exports = _dereq_('../src/traces/bar'); module.exports = _dereq_('../src/core'); -},{"../src/core":145}],5:[function(_dereq_,module,exports){ +},{"../src/core":142}],5:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -260,7 +260,7 @@ module.exports = Plotly; module.exports = _dereq_('../src/traces/pie'); -},{"../src/traces/pie":275}],7:[function(_dereq_,module,exports){ +},{"../src/traces/pie":274}],7:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -15106,7 +15106,7 @@ module.exports = templatedArray('annotation', { } }); -},{"../../plot_api/plot_template":195,"../../plots/cartesian/constants":211,"../../plots/font_attributes":232,"./arrow_paths":27}],29:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":193,"../../plots/cartesian/constants":209,"../../plots/font_attributes":230,"./arrow_paths":27}],29:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15195,7 +15195,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":161,"../../plots/cartesian/axes":205,"./draw":34}],30:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/cartesian/axes":203,"./draw":34}],30:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15334,7 +15334,7 @@ function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":161,"../../plot_api/plot_template":195,"../../registry":245}],31:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plot_api/plot_template":193,"../../registry":243}],31:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15414,7 +15414,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":161,"../color":43}],32:[function(_dereq_,module,exports){ +},{"../../lib":159,"../color":43}],32:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15477,7 +15477,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":184,"fast-isnumeric":10}],33:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":182,"fast-isnumeric":10}],33:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15583,7 +15583,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":161,"../../plots/array_container_defaults":201,"../../plots/cartesian/axes":205,"./attributes":28,"./common_defaults":31}],34:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/array_container_defaults":199,"../../plots/cartesian/axes":203,"./attributes":28,"./common_defaults":31}],34:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15997,14 +15997,14 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { x: borderfull + xShift - 1, y: borderfull + yShift }) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; annText.call(svgTextUtils.positionText, textx, texty) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } annTextClip.select('rect').call(Drawing.setRect, borderfull, borderfull, @@ -16170,7 +16170,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }); }, doneFn: function() { - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -16253,7 +16253,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }, doneFn: function() { setCursor(annTextGroupInner); - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -16277,13 +16277,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { modifyBase(ya._name + '.autorange', true); } - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); }); } else annText.call(textLayout); } -},{"../../lib":161,"../../lib/setcursor":180,"../../lib/svg_text_utils":182,"../../plot_api/plot_template":195,"../../plots/cartesian/axes":205,"../../plots/plots":238,"../../registry":245,"../color":43,"../dragelement":65,"../drawing":68,"../fx":85,"./draw_arrow_head":35,"d3":8}],35:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../lib/setcursor":178,"../../lib/svg_text_utils":180,"../../plot_api/plot_template":193,"../../plots/cartesian/axes":203,"../../plots/plots":236,"../../registry":243,"../color":43,"../dragelement":61,"../drawing":64,"../fx":82,"./draw_arrow_head":35,"d3":8}],35:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16471,7 +16471,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":216,"./attributes":28,"./calc_autorange":29,"./click":30,"./convert_coords":32,"./defaults":33,"./draw":34}],37:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":214,"./attributes":28,"./calc_autorange":29,"./click":30,"./convert_coords":32,"./defaults":33,"./draw":34}],37:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16559,7 +16559,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":188,"../../plot_api/plot_template":195,"../annotations/attributes":28}],38:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":186,"../../plot_api/plot_template":193,"../annotations/attributes":28}],38:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16624,7 +16624,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":161,"../../plots/cartesian/axes":205}],39:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/cartesian/axes":203}],39:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16700,7 +16700,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":161,"../../plots/array_container_defaults":201,"../../plots/cartesian/axes":205,"../annotations/common_defaults":31,"./attributes":37}],40:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/array_container_defaults":199,"../../plots/cartesian/axes":203,"../annotations/common_defaults":31,"./attributes":37}],40:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16752,7 +16752,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":235,"../annotations/draw":34}],41:[function(_dereq_,module,exports){ +},{"../../plots/gl3d/project":233,"../annotations/draw":34}],41:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16800,7 +16800,7 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":161,"../../registry":245,"./attributes":37,"./convert":38,"./defaults":39,"./draw":40}],42:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../registry":243,"./attributes":37,"./convert":38,"./defaults":39,"./draw":40}],42:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17154,23 +17154,43 @@ module.exports = overrideAll({ exponentformat: axesAttrs.exponentformat, showexponent: axesAttrs.showexponent, title: { - valType: 'string', - - + text: { + valType: 'string', + + + }, + font: fontAttrs({ + + }), + side: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } }, - titlefont: fontAttrs({ - - }), - titleside: { - valType: 'enumerated', - values: ['right', 'top', 'bottom'], - - dflt: 'top', - + + _deprecated: { + title: { + valType: 'string', + + + }, + titlefont: fontAttrs({ + + }), + titleside: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":155,"../../plot_api/edit_types":188,"../../plots/cartesian/layout_attributes":218,"../../plots/font_attributes":232}],45:[function(_dereq_,module,exports){ +},{"../../lib/extend":153,"../../plot_api/edit_types":186,"../../plots/cartesian/layout_attributes":216,"../../plots/font_attributes":230}],45:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17179,10 +17199,10 @@ module.exports = overrideAll({ * LICENSE file in the root directory of this source tree. */ - 'use strict'; var drawColorbar = _dereq_('./draw'); +var flipScale = _dereq_('../colorscale/helpers').flipScale; /** * connectColorbar: create a colorbar from a trace, using its module to @@ -17222,12 +17242,16 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) { var cb = cd[0].t.cb = drawColorbar(gd, cbId); - cb.fillgradient(container.colorscale) + var scl = container.reversescale ? + flipScale(container.colorscale) : + container.colorscale; + + cb.fillgradient(scl) .zrange([container[moduleOpts.min], container[moduleOpts.max]]) .options(container.colorbar)(); }; -},{"./draw":48}],46:[function(_dereq_,module,exports){ +},{"../colorscale/helpers":54,"./draw":48}],46:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17317,12 +17341,12 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); - coerce('title', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'titlefont', layout.font); - coerce('titleside'); + coerce('title.text', layout._dfltTitle.colorbar); + Lib.coerceFont(coerce, 'title.font', layout.font); + coerce('title.side'); }; -},{"../../lib":161,"../../plot_api/plot_template":195,"../../plots/cartesian/tick_label_defaults":225,"../../plots/cartesian/tick_mark_defaults":226,"../../plots/cartesian/tick_value_defaults":227,"./attributes":44}],48:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plot_api/plot_template":193,"../../plots/cartesian/tick_label_defaults":223,"../../plots/cartesian/tick_mark_defaults":224,"../../plots/cartesian/tick_value_defaults":225,"./attributes":44}],48:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17509,9 +17533,9 @@ module.exports = function draw(gd, id) { showticksuffix: opts.showticksuffix, ticksuffix: opts.ticksuffix, title: opts.title, - titlefont: opts.titlefont, showline: true, anchor: 'free', + side: 'right', position: 1 }, cbAxisOut = { @@ -17522,6 +17546,7 @@ module.exports = function draw(gd, id) { letter: 'y', font: fullLayout.font, noHover: true, + noTickson: true, calendar: fullLayout.calendar // not really necessary (yet?) }; @@ -17542,11 +17567,11 @@ module.exports = function draw(gd, id) { // save for other callers to access this axis component.axis = cbAxisOut; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { - cbAxisOut.titleside = opts.titleside; + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { + cbAxisOut.title.side = opts.title.side; cbAxisOut.titlex = opts.x + xpadFrac; cbAxisOut.titley = yBottomFrac + - (opts.titleside === 'top' ? lenFrac - ypadFrac : ypadFrac); + (opts.title.side === 'top' ? lenFrac - ypadFrac : ypadFrac); } if(opts.line.color && opts.tickmode === 'auto') { @@ -17606,17 +17631,18 @@ module.exports = function draw(gd, id) { Math.round(gs.l) + ',-' + Math.round(gs.t) + ')'); - cbAxisOut._axislayer = container.select('.cbaxis'); + var axisLayer = container.select('.cbaxis'); + var titleHeight = 0; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // draw the title so we know how much room it needs // when we squish the axis. This one only applies to // top or bottom titles, not right side. var x = gs.l + (opts.x + xpadFrac) * gs.w, - fontSize = cbAxisOut.titlefont.size, + fontSize = cbAxisOut.title.font.size, y; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; } @@ -17630,7 +17656,7 @@ module.exports = function draw(gd, id) { } function drawAxis() { - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // squish the axis top to make room for the title var titleGroup = container.select('.cbtitle'), titleText = titleGroup.select('text'), @@ -17661,7 +17687,7 @@ module.exports = function draw(gd, id) { // TODO: configurable titleHeight += 5; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; } @@ -17682,8 +17708,7 @@ module.exports = function draw(gd, id) { .attr('transform', 'translate(0,' + Math.round(gs.h * (1 - cbAxisOut.domain[1])) + ')'); - cbAxisOut._axislayer.attr('transform', 'translate(0,' + - Math.round(-gs.t) + ')'); + axisLayer.attr('transform', 'translate(0,' + Math.round(-gs.t) + ')'); var fills = container.select('.cbfills') .selectAll('rect.cbfill') @@ -17750,12 +17775,7 @@ module.exports = function draw(gd, id) { }); // force full redraw of labels and ticks - cbAxisOut._axislayer.selectAll('g.' + cbAxisOut._id + 'tick,path') - .remove(); - - cbAxisOut._pos = xLeft + thickPx + - (opts.outlinewidth||0) / 2 - (opts.ticks === 'outside' ? 1 : 0); - cbAxisOut.side = 'right'; + axisLayer.selectAll('g.' + cbAxisOut._id + 'tick,path').remove(); // separate out axis and title drawing, // so we don't need such complicated logic in Titles.draw @@ -17763,11 +17783,33 @@ module.exports = function draw(gd, id) { // this title call only handles side=right return Lib.syncOrAsync([ function() { - return Axes.doTicksSingle(gd, cbAxisOut, true); + var shift = xLeft + thickPx + + (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0); + + var vals = Axes.calcTicks(cbAxisOut); + var transFn = Axes.makeTransFn(cbAxisOut); + var labelFns = Axes.makeLabelFns(cbAxisOut, shift); + var tickSign = Axes.getTickSigns(cbAxisOut)[2]; + + Axes.drawTicks(gd, cbAxisOut, { + vals: cbAxisOut.ticks === 'inside' ? Axes.clipEnds(cbAxisOut, vals) : vals, + layer: axisLayer, + path: Axes.makeTickPath(cbAxisOut, shift, tickSign), + transFn: transFn + }); + + return Axes.drawLabels(gd, cbAxisOut, { + vals: vals, + layer: axisLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); }, function() { - if(['top', 'bottom'].indexOf(opts.titleside) === -1) { - var fontSize = cbAxisOut.titlefont.size, + if(['top', 'bottom'].indexOf(opts.title.side) === -1) { + var fontSize = cbAxisOut.title.font.size, y = cbAxisOut._offset + cbAxisOut._length / 2, x = gs.l + (cbAxisOut.position || 0) * gs.w + ((cbAxisOut.side === 'right') ? 10 + fontSize * ((cbAxisOut.showticklabels ? 1 : 0.5)) : @@ -17779,7 +17821,7 @@ module.exports = function draw(gd, id) { drawTitle('h' + cbAxisOut._id + 'title', { avoid: { selection: d3.select(gd).selectAll('g.' + cbAxisOut._id + 'tick'), - side: opts.titleside, + side: opts.title.side, offsetLeft: gs.l, offsetTop: 0, maxShift: fullLayout.width @@ -17792,15 +17834,10 @@ module.exports = function draw(gd, id) { } function drawTitle(titleClass, titleOpts) { - var trace = getTrace(); - var propName = 'colorbar.title'; - var containerName = trace._module.colorbar.container; - if(containerName) propName = containerName + '.' + propName; - var dfltTitleOpts = { propContainer: cbAxisOut, - propName: propName, - traceIndex: trace.index, + propName: getPropName('title'), + traceIndex: getTrace().index, placeholder: fullLayout._dfltTitle.colorbar, containerGroup: container.select('.cbtitle') }; @@ -17824,7 +17861,7 @@ module.exports = function draw(gd, id) { // TODO: why are we redrawing multiple times now with this? // I guess autoMargin doesn't like being post-promise? var innerWidth = thickPx + opts.outlinewidth / 2 + - Drawing.bBox(cbAxisOut._axislayer.node()).width; + Drawing.bBox(axisLayer.node()).width; titleEl = titleCont.select('text'); if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) { var mathJaxNode = titleCont @@ -17832,11 +17869,11 @@ module.exports = function draw(gd, id) { .node(), titleWidth; if(mathJaxNode && - ['top', 'bottom'].indexOf(opts.titleside) !== -1) { + ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; } else { - // note: the formula below works for all titlesides, + // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift // transform gets removed by Drawing.bBox @@ -17865,7 +17902,7 @@ module.exports = function draw(gd, id) { container.selectAll('.cboutline').attr({ x: xLeft, y: yTopPx + opts.ypad + - (opts.titleside === 'top' ? titleHeight : 0), + (opts.title.side === 'top' ? titleHeight : 0), width: Math.max(thickPx, 2), height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2) }) @@ -17952,11 +17989,10 @@ module.exports = function draw(gd, id) { setCursor(container); if(xf !== undefined && yf !== undefined) { - Registry.call('restyle', - gd, - {'colorbar.x': xf, 'colorbar.y': yf}, - getTrace().index - ); + var update = {}; + update[getPropName('x')] = xf; + update[getPropName('y')] = yf; + Registry.call('_guiRestyle', gd, update, getTrace().index); } } }); @@ -17974,6 +18010,14 @@ module.exports = function draw(gd, id) { } } + function getPropName(suffix) { + var trace = getTrace(); + var propName = 'colorbar.'; + var containerName = trace._module.colorbar.container; + if(containerName) propName = containerName + '.' + propName; + return propName + suffix; + } + // setter/getters for every item defined in opts Object.keys(opts).forEach(function(name) { component[name] = function(v) { @@ -18007,7 +18051,7 @@ module.exports = function draw(gd, id) { return component; }; -},{"../../constants/alignment":141,"../../lib":161,"../../lib/extend":155,"../../lib/setcursor":180,"../../lib/svg_text_utils":182,"../../plots/cartesian/axes":205,"../../plots/cartesian/axis_defaults":207,"../../plots/cartesian/layout_attributes":218,"../../plots/cartesian/position_defaults":221,"../../plots/plots":238,"../../registry":245,"../color":43,"../dragelement":65,"../drawing":68,"../titles":134,"./attributes":44,"./constants":46,"d3":8,"tinycolor2":26}],49:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../lib":159,"../../lib/extend":153,"../../lib/setcursor":178,"../../lib/svg_text_utils":180,"../../plots/cartesian/axes":203,"../../plots/cartesian/axis_defaults":205,"../../plots/cartesian/layout_attributes":216,"../../plots/cartesian/position_defaults":219,"../../plots/plots":236,"../../registry":243,"../color":43,"../dragelement":61,"../drawing":64,"../titles":131,"./attributes":44,"./constants":46,"d3":8,"tinycolor2":26}],49:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18026,7 +18070,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":161}],50:[function(_dereq_,module,exports){ +},{"../../lib":159}],50:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18037,7 +18081,7 @@ module.exports = function hasColorbar(container) { 'use strict'; -var palettes = _dereq_('./scales.js'); +var palettes = _dereq_('./scales.js').scales; var paletteStr = Object.keys(palettes); function code(s) { @@ -18184,7 +18228,7 @@ module.exports = function colorScaleAttrs(context, opts) { valType: 'boolean', dflt: false, - editType: 'calc', + editType: 'plot', }; @@ -18201,7 +18245,7 @@ module.exports = function colorScaleAttrs(context, opts) { return attrs; }; -},{"./scales.js":62}],51:[function(_dereq_,module,exports){ +},{"./scales.js":58}],51:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18210,49 +18254,19 @@ module.exports = function colorScaleAttrs(context, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); -var scales = _dereq_('./scales'); -var flipScale = _dereq_('./flip_scale'); - - -module.exports = function calc(trace, vals, containerStr, cLetter) { - var container = trace; - var inputContainer = trace._input; - var fullInputContainer = trace._fullInput; - - // set by traces with groupby transforms - var updateStyle = trace.updateStyle; - - function doUpdate(attr, inputVal, fullVal) { - if(fullVal === undefined) fullVal = inputVal; - - if(updateStyle) { - updateStyle(trace._input, containerStr ? (containerStr + '.' + attr) : attr, inputVal); - } - else { - inputContainer[attr] = inputVal; - } - - container[attr] = fullVal; - if(fullInputContainer && (trace !== trace._fullInput)) { - if(updateStyle) { - updateStyle(trace._fullInput, containerStr ? (containerStr + '.' + attr) : attr, fullVal); - } - else { - fullInputContainer[attr] = fullVal; - } - } - } +module.exports = function calc(gd, trace, opts) { + var fullLayout = gd._fullLayout; + var vals = opts.vals; + var containerStr = opts.containerStr; + var cLetter = opts.cLetter; - if(containerStr) { - container = Lib.nestedProperty(container, containerStr).get(); - inputContainer = Lib.nestedProperty(inputContainer, containerStr).get(); - fullInputContainer = Lib.nestedProperty(fullInputContainer, containerStr).get() || {}; - } + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() : + trace; var autoAttr = cLetter + 'auto'; var minAttr = cLetter + 'min'; @@ -18275,37 +18289,19 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { max += 0.5; } - doUpdate(minAttr, min); - doUpdate(maxAttr, max); - - /* - * If auto was explicitly false but min or max was missing, - * we filled in the missing piece here but later the trace does - * not look auto. - * Otherwise make sure the trace still looks auto as far as later - * changes are concerned. - */ - doUpdate(autoAttr, (auto !== false || (min === undefined && max === undefined))); + container['_' + minAttr] = container[minAttr] = min; + container['_' + maxAttr] = container[maxAttr] = max; if(container.autocolorscale) { - if(min * max < 0) scl = scales.RdBu; - else if(min >= 0) scl = scales.Reds; - else scl = scales.Blues; - - // reversescale is handled at the containerOut level - doUpdate('colorscale', scl, container.reversescale ? flipScale(scl) : scl); + if(min * max < 0) scl = fullLayout.colorscale.diverging; + else if(min >= 0) scl = fullLayout.colorscale.sequential; + else scl = fullLayout.colorscale.sequentialminus; - // We pushed a colorscale back to input, which will change the default autocolorscale next time - // to avoid spurious redraws from Plotly.react, update resulting autocolorscale now - // This is a conscious decision so that changing the data later does not unexpectedly - // give you a new colorscale - if(!inputContainer.autocolorscale) { - doUpdate('autocolorscale', false); - } + container._colorscale = container.colorscale = scl; } }; -},{"../../lib":161,"./flip_scale":55,"./scales":62}],52:[function(_dereq_,module,exports){ +},{"../../lib":159}],52:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18316,12 +18312,68 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { 'use strict'; -var scales = _dereq_('./scales'); +var Lib = _dereq_('../../lib'); +var hasColorscale = _dereq_('./helpers').hasColorscale; +module.exports = function crossTraceDefaults(fullData) { + function replace(cont, k) { + var val = cont['_' + k]; + if(val !== undefined) { + cont[k] = val; + } + } + + function relinkColorAtts(trace, cAttrs) { + var cont = cAttrs.container ? + Lib.nestedProperty(trace, cAttrs.container).get() : + trace; + + if(cont) { + var isAuto = cont.zauto || cont.cauto; + var minAttr = cAttrs.min; + var maxAttr = cAttrs.max; + + if(isAuto || cont[minAttr] === undefined) { + replace(cont, minAttr); + } + if(isAuto || cont[maxAttr] === undefined) { + replace(cont, maxAttr); + } + if(cont.autocolorscale) { + replace(cont, 'colorscale'); + } + } + } + + for(var i = 0; i < fullData.length; i++) { + var trace = fullData[i]; + var _module = trace._module; + + if(_module.colorbar) { + relinkColorAtts(trace, _module.colorbar); + } + + // TODO could generalize _module.colorscale and use it here? + + if(hasColorscale(trace, 'marker.line')) { + relinkColorAtts(trace, { + container: 'marker.line', + min: 'cmin', + max: 'cmax' + }); + } -module.exports = scales.RdBu; + if(hasColorscale(trace, 'line')) { + relinkColorAtts(trace, { + container: 'line', + min: 'cmin', + max: 'cmax' + }); + } + } +}; -},{"./scales":62}],53:[function(_dereq_,module,exports){ +},{"../../lib":159,"./helpers":54}],53:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18330,33 +18382,32 @@ module.exports = scales.RdBu; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); - var hasColorbar = _dereq_('../colorbar/has_colorbar'); var colorbarDefaults = _dereq_('../colorbar/defaults'); -var isValidScale = _dereq_('./is_valid_scale'); -var flipScale = _dereq_('./flip_scale'); +var isValidScale = _dereq_('./scales').isValid; -module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { - var prefix = opts.prefix, - cLetter = opts.cLetter, - containerStr = prefix.slice(0, prefix.length - 1), - containerIn = prefix ? - Lib.nestedProperty(traceIn, containerStr).get() || {} : - traceIn, - containerOut = prefix ? - Lib.nestedProperty(traceOut, containerStr).get() || {} : - traceOut, - minIn = containerIn[cLetter + 'min'], - maxIn = containerIn[cLetter + 'max'], - sclIn = containerIn.colorscale; +function npMaybe(cont, prefix) { + var containerStr = prefix.slice(0, prefix.length - 1); + return prefix ? + Lib.nestedProperty(cont, containerStr).get() || {} : + cont; +} +module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { + var prefix = opts.prefix; + var cLetter = opts.cLetter; + var containerIn = npMaybe(traceIn, prefix); + var containerOut = npMaybe(traceOut, prefix); + var template = npMaybe(traceOut._template || {}, prefix) || {}; + + var minIn = containerIn[cLetter + 'min']; + var maxIn = containerIn[cLetter + 'max']; var validMinMax = isNumeric(minIn) && isNumeric(maxIn) && (minIn < maxIn); coerce(prefix + cLetter + 'auto', !validMinMax); coerce(prefix + cLetter + 'min'); @@ -18364,19 +18415,17 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, // handles both the trace case (autocolorscale is false by default) and // the marker and marker.line case (autocolorscale is true by default) + var sclIn = containerIn.colorscale; + var sclTemplate = template.colorscale; var autoColorscaleDflt; if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn); + if(sclTemplate !== undefined) autoColorscaleDflt = !isValidScale(sclTemplate); coerce(prefix + 'autocolorscale', autoColorscaleDflt); - var sclOut = coerce(prefix + 'colorscale'); - - // reversescale is handled at the containerOut level - var reverseScale = coerce(prefix + 'reversescale'); - if(reverseScale) containerOut.colorscale = flipScale(sclOut); - // ... until Scatter.colorbar can handle marker line colorbars - if(prefix === 'marker.line.') return; + coerce(prefix + 'colorscale'); + coerce(prefix + 'reversescale'); - if(!opts.noScale) { + if(!opts.noScale && prefix !== 'marker.line.') { // handles both the trace case where the dflt is listed in attributes and // the marker case where the dflt is determined by hasColorbar var showScaleDflt; @@ -18387,109 +18436,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, } }; -},{"../../lib":161,"../colorbar/defaults":47,"../colorbar/has_colorbar":49,"./flip_scale":55,"./is_valid_scale":59,"fast-isnumeric":10}],54:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -/** - * Extract colorscale into numeric domain and color range. - * - * @param {array} scl colorscale array of arrays - * @param {number} cmin minimum color value (used to clamp scale) - * @param {number} cmax maximum color value (used to clamp scale) - */ -module.exports = function extractScale(scl, cmin, cmax) { - var N = scl.length, - domain = new Array(N), - range = new Array(N); - - for(var i = 0; i < N; i++) { - var si = scl[i]; - - domain[i] = cmin + si[0] * (cmax - cmin); - range[i] = si[1]; - } - - return { - domain: domain, - range: range - }; -}; - -},{}],55:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function flipScale(scl) { - var N = scl.length, - sclNew = new Array(N), - si; - - for(var i = N - 1, j = 0; i >= 0; i--, j++) { - si = scl[i]; - sclNew[j] = [1 - si[0], si[1]]; - } - - return sclNew; -}; - -},{}],56:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var defaultScale = _dereq_('./default_scale'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function getScale(scl, dflt) { - if(!dflt) dflt = defaultScale; - if(!scl) return dflt; - - function parseScale() { - try { - scl = scales[scl] || JSON.parse(scl); - } - catch(e) { - scl = dflt; - } - } - - if(typeof scl === 'string') { - parseScale(); - // occasionally scl is double-JSON encoded... - if(typeof scl === 'string') parseScale(); - } - - if(!isValidScaleArray(scl)) return dflt; - return scl; -}; - -},{"./default_scale":52,"./is_valid_scale_array":60,"./scales":62}],57:[function(_dereq_,module,exports){ +},{"../../lib":159,"../colorbar/defaults":47,"../colorbar/has_colorbar":49,"./scales":58,"fast-isnumeric":10}],54:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18500,11 +18447,16 @@ module.exports = function getScale(scl, dflt) { 'use strict'; +var d3 = _dereq_('d3'); +var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); + var Lib = _dereq_('../../lib'); -var isValidScale = _dereq_('./is_valid_scale'); +var Color = _dereq_('../color'); + +var isValidScale = _dereq_('./scales').isValid; -module.exports = function hasColorscale(trace, containerStr) { +function hasColorscale(trace, containerStr) { var container = containerStr ? Lib.nestedProperty(trace, containerStr).get() || {} : trace; @@ -18529,117 +18481,61 @@ module.exports = function hasColorscale(trace, containerStr) { Lib.isPlainObject(container.colorbar) ) ); -}; - -},{"../../lib":161,"./is_valid_scale":59,"fast-isnumeric":10}],58:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -exports.scales = _dereq_('./scales'); - -exports.defaultScale = _dereq_('./default_scale'); - -exports.attributes = _dereq_('./attributes'); - -exports.handleDefaults = _dereq_('./defaults'); - -exports.calc = _dereq_('./calc'); - -exports.hasColorscale = _dereq_('./has_colorscale'); - -exports.isValidScale = _dereq_('./is_valid_scale'); - -exports.getScale = _dereq_('./get_scale'); - -exports.flipScale = _dereq_('./flip_scale'); - -exports.extractScale = _dereq_('./extract_scale'); - -exports.makeColorScaleFunc = _dereq_('./make_color_scale_func'); - -},{"./attributes":50,"./calc":51,"./default_scale":52,"./defaults":53,"./extract_scale":54,"./flip_scale":55,"./get_scale":56,"./has_colorscale":57,"./is_valid_scale":59,"./make_color_scale_func":61,"./scales":62}],59:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function isValidScale(scl) { - if(scales[scl] !== undefined) return true; - else return isValidScaleArray(scl); -}; +} -},{"./is_valid_scale_array":60,"./scales":62}],60:[function(_dereq_,module,exports){ /** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var tinycolor = _dereq_('tinycolor2'); - - -module.exports = function isValidScaleArray(scl) { - var highestVal = 0; + * Extract colorscale into numeric domain and color range. + * + * @param {object} cont colorscale container (e.g. trace, marker) + * - colorscale {array of arrays} + * - cmin/zmin {number} + * - cmax/zmax {number} + * - reversescale {boolean} + * @param {object} opts + * - cLetter {string} 'c' (for cmin/cmax) or 'z' (for zmin/zmax) + * + * @return {object} + * - domain {array} + * - range {array} + */ +function extractScale(cont, opts) { + var cLetter = opts.cLetter; - if(!Array.isArray(scl) || scl.length < 2) return false; + var scl = cont.reversescale ? + flipScale(cont.colorscale) : + cont.colorscale; - if(!scl[0] || !scl[scl.length - 1]) return false; + // minimum color value (used to clamp scale) + var cmin = cont[cLetter + 'min']; + // maximum color value (used to clamp scale) + var cmax = cont[cLetter + 'max']; - if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + var N = scl.length; + var domain = new Array(N); + var range = new Array(N); - for(var i = 0; i < scl.length; i++) { + for(var i = 0; i < N; i++) { var si = scl[i]; - - if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { - return false; - } - - highestVal = +si[0]; + domain[i] = cmin + si[0] * (cmax - cmin); + range[i] = si[1]; } - return true; -}; - -},{"tinycolor2":26}],61:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; + return { + domain: domain, + range: range + }; +} -var d3 = _dereq_('d3'); -var tinycolor = _dereq_('tinycolor2'); -var isNumeric = _dereq_('fast-isnumeric'); +function flipScale(scl) { + var N = scl.length; + var sclNew = new Array(N); -var Color = _dereq_('../color'); + for(var i = N - 1, j = 0; i >= 0; i--, j++) { + var si = scl[i]; + sclNew[j] = [1 - si[0], si[1]]; + } + return sclNew; +} /** * General colorscale function generator. @@ -18654,7 +18550,7 @@ var Color = _dereq_('../color'); * * @return {function} */ -module.exports = function makeColorScaleFunc(specs, opts) { +function makeColorScaleFunc(specs, opts) { opts = opts || {}; var domain = specs.domain, @@ -18706,7 +18602,7 @@ module.exports = function makeColorScaleFunc(specs, opts) { sclFunc.range = function() { return range; }; return sclFunc; -}; +} function colorArray2rbga(colorArray) { var colorObj = { @@ -18719,7 +18615,14 @@ function colorArray2rbga(colorArray) { return tinycolor(colorObj).toRgbString(); } -},{"../color":43,"d3":8,"fast-isnumeric":10,"tinycolor2":26}],62:[function(_dereq_,module,exports){ +module.exports = { + hasColorscale: hasColorscale, + extractScale: extractScale, + flipScale: flipScale, + makeColorScaleFunc: makeColorScaleFunc +}; + +},{"../../lib":159,"../color":43,"./scales":58,"d3":8,"fast-isnumeric":10,"tinycolor2":26}],55:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18730,8 +18633,116 @@ function colorArray2rbga(colorArray) { 'use strict'; +var scales = _dereq_('./scales'); +var helpers = _dereq_('./helpers'); module.exports = { + moduleType: 'component', + name: 'colorscale', + + attributes: _dereq_('./attributes'), + layoutAttributes: _dereq_('./layout_attributes'), + + supplyLayoutDefaults: _dereq_('./layout_defaults'), + handleDefaults: _dereq_('./defaults'), + crossTraceDefaults: _dereq_('./cross_trace_defaults'), + + calc: _dereq_('./calc'), + + // ./scales.js is required in lib/coerce.js ; + // it needs to be a seperate module to avoid circular a dependency + scales: scales.scales, + defaultScale: scales.defaultScale, + getScale: scales.get, + isValidScale: scales.isValid, + + hasColorscale: helpers.hasColorscale, + flipScale: helpers.flipScale, + extractScale: helpers.extractScale, + makeColorScaleFunc: helpers.makeColorScaleFunc +}; + +},{"./attributes":50,"./calc":51,"./cross_trace_defaults":52,"./defaults":53,"./helpers":54,"./layout_attributes":56,"./layout_defaults":57,"./scales":58}],56:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var scales = _dereq_('./scales').scales; + +var msg = 'Note that `autocolorscale` must be true for this attribute to work.'; + +module.exports = { + editType: 'calc', + sequential: { + valType: 'colorscale', + dflt: scales.Reds, + + editType: 'calc', + + }, + sequentialminus: { + valType: 'colorscale', + dflt: scales.Blues, + + editType: 'calc', + + }, + diverging: { + valType: 'colorscale', + dflt: scales.RdBu, + + editType: 'calc', + + } +}; + +},{"./scales":58}],57:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var Lib = _dereq_('../../lib'); +var colorscaleAttrs = _dereq_('./layout_attributes'); +var Template = _dereq_('../../plot_api/plot_template'); + +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var colorscaleIn = layoutIn.colorscale; + var colorscaleOut = Template.newContainer(layoutOut, 'colorscale'); + function coerce(attr, dflt) { + return Lib.coerce(colorscaleIn, colorscaleOut, colorscaleAttrs, attr, dflt); + } + + coerce('sequential'); + coerce('sequentialminus'); + coerce('diverging'); +}; + +},{"../../lib":159,"../../plot_api/plot_template":193,"./layout_attributes":56}],58:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var tinycolor = _dereq_('tinycolor2'); + +var scales = { 'Greys': [ [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] ], @@ -18862,7 +18873,67 @@ module.exports = { ] }; -},{}],63:[function(_dereq_,module,exports){ +var defaultScale = scales.RdBu; + +function getScale(scl, dflt) { + if(!dflt) dflt = defaultScale; + if(!scl) return dflt; + + function parseScale() { + try { + scl = scales[scl] || JSON.parse(scl); + } catch(e) { + scl = dflt; + } + } + + if(typeof scl === 'string') { + parseScale(); + // occasionally scl is double-JSON encoded... + if(typeof scl === 'string') parseScale(); + } + + if(!isValidScaleArray(scl)) return dflt; + return scl; +} + + +function isValidScaleArray(scl) { + var highestVal = 0; + + if(!Array.isArray(scl) || scl.length < 2) return false; + + if(!scl[0] || !scl[scl.length - 1]) return false; + + if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + + for(var i = 0; i < scl.length; i++) { + var si = scl[i]; + + if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { + return false; + } + + highestVal = +si[0]; + } + + return true; +} + +function isValidScale(scl) { + if(scales[scl] !== undefined) return true; + else return isValidScaleArray(scl); +} + +module.exports = { + scales: scales, + defaultScale: defaultScale, + + get: getScale, + isValid: isValidScale +}; + +},{"tinycolor2":26}],59:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18895,7 +18966,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],64:[function(_dereq_,module,exports){ +},{}],60:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18933,7 +19004,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":161}],65:[function(_dereq_,module,exports){ +},{"../../lib":159}],61:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19060,8 +19131,6 @@ dragElement.init = function init(options) { var clampFn = options.clampFn || _clampFn; function onStart(e) { - e.preventDefault(); - // make dragging and dragged into properties of gd // so that others can look at and modify them gd._dragged = false; @@ -19103,11 +19172,15 @@ dragElement.init = function init(options) { document.documentElement.style.cursor = window.getComputedStyle(element).cursor; } - document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onDone); - document.addEventListener('touchmove', onMove); document.addEventListener('touchend', onDone); + if(options.dragmode !== false) { + e.preventDefault(); + document.addEventListener('mousemove', onMove); + document.addEventListener('touchmove', onMove); + } + return; } @@ -19131,13 +19204,15 @@ dragElement.init = function init(options) { } function onDone(e) { - document.removeEventListener('mousemove', onMove); + if(options.dragmode !== false) { + e.preventDefault(); + document.removeEventListener('mousemove', onMove); + document.removeEventListener('touchmove', onMove); + } + document.removeEventListener('mouseup', onDone); - document.removeEventListener('touchmove', onMove); document.removeEventListener('touchend', onDone); - e.preventDefault(); - if(hasHover) { Lib.removeElement(dragCover); } @@ -19230,7 +19305,7 @@ function pointerOffset(e) { ); } -},{"../../constants/interactions":142,"../../lib":161,"../../plots/cartesian/constants":211,"../../registry":245,"./align":63,"./cursor":64,"./unhover":66,"has-hover":12,"has-passive-events":13,"mouse-event-offset":16}],66:[function(_dereq_,module,exports){ +},{"../../constants/interactions":139,"../../lib":159,"../../plots/cartesian/constants":209,"../../registry":243,"./align":59,"./cursor":60,"./unhover":62,"has-hover":12,"has-passive-events":13,"mouse-event-offset":16}],62:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19288,7 +19363,7 @@ unhover.raw = function unhoverRaw(gd, evt) { } }; -},{"../../lib/events":154,"../../lib/get_graph_div":159,"../../lib/throttle":183,"../fx/constants":80}],67:[function(_dereq_,module,exports){ +},{"../../lib/events":152,"../../lib/get_graph_div":157,"../../lib/throttle":181,"../fx/constants":76}],63:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19313,7 +19388,7 @@ exports.dash = { }; -},{}],68:[function(_dereq_,module,exports){ +},{}],64:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19514,7 +19589,11 @@ drawing.fillGroupStyle = function(s) { s.style('stroke-width', 0) .each(function(d) { var shape = d3.select(this); - shape.call(Color.fill, d[0].trace.fillcolor); + // N.B. 'd' won't be a calcdata item when + // fill !== 'none' on a segment-less and marker-less trace + if(d[0].trace) { + shape.call(Color.fill, d[0].trace.fillcolor); + } }); }; @@ -19955,7 +20034,7 @@ drawing.tryColorscale = function(marker, prefix) { if(scl && Lib.isArrayOrTypedArray(colorArray)) { return Colorscale.makeColorScaleFunc( - Colorscale.extractScale(scl, cont.cmin, cont.cmax) + Colorscale.extractScale(cont, {cLetter: 'c'}) ); } } @@ -20316,32 +20395,28 @@ function nodeHash(node) { node.getAttribute('style'); } -/* - * make a robust clipPath url from a local id - * note! We'd better not be exporting from a page - * with a or the svg will not be portable! +/** + * Set clipPath URL in a way that work for all situations. + * + * In details, graphs on pages with HTML tags need to prepend + * the clip path ids with the page's base url EXCEPT during toImage exports. + * + * @param {d3 selection} s : node to add clip-path attribute + * @param {string} localId : local clip-path (w/o base url) id + * @param {DOM element || object} gd + * - context._baseUrl {string} + * - context._exportedPlot {boolean} */ -drawing.setClipUrl = function(s, localId) { +drawing.setClipUrl = function(s, localId, gd) { if(!localId) { s.attr('clip-path', null); return; } - if(drawing.baseUrl === undefined) { - var base = d3.select('base'); - - // Stash base url once and for all! - // We may have to stash this elsewhere when - // we'll try to support for child windows - // more info -> https://github.com/plotly/plotly.js/issues/702 - if(base.size() && base.attr('href')) { - drawing.baseUrl = window.location.href.split('#')[0]; - } else { - drawing.baseUrl = ''; - } - } + var context = gd._context; + var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - s.attr('clip-path', 'url(' + drawing.baseUrl + '#' + localId + ')'); + s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')'); }; drawing.getTranslate = function(element) { @@ -20473,7 +20548,7 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../constants/alignment":141,"../../constants/interactions":142,"../../constants/xmlns_namespaces":144,"../../lib":161,"../../lib/svg_text_utils":182,"../../registry":245,"../../traces/scatter/make_bubble_size_func":299,"../../traces/scatter/subtypes":306,"../color":43,"../colorscale":58,"./symbol_defs":69,"d3":8,"fast-isnumeric":10,"tinycolor2":26}],69:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../constants/interactions":139,"../../constants/xmlns_namespaces":141,"../../lib":159,"../../lib/svg_text_utils":180,"../../registry":243,"../../traces/scatter/make_bubble_size_func":298,"../../traces/scatter/subtypes":305,"../color":43,"../colorscale":55,"./symbol_defs":65,"d3":8,"fast-isnumeric":10,"tinycolor2":26}],65:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -20961,7 +21036,7 @@ module.exports = { } }; -},{"d3":8}],70:[function(_dereq_,module,exports){ +},{"d3":8}],66:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21076,7 +21151,7 @@ module.exports = { } }; -},{}],71:[function(_dereq_,module,exports){ +},{}],67:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21158,7 +21233,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max); } -},{"../../plots/cartesian/axes":205,"../../registry":245,"./compute_error":72,"fast-isnumeric":10}],72:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":203,"../../registry":243,"./compute_error":68,"fast-isnumeric":10}],68:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21262,7 +21337,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],73:[function(_dereq_,module,exports){ +},{}],69:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21338,7 +21413,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":161,"../../plot_api/plot_template":195,"../../registry":245,"./attributes":70,"fast-isnumeric":10}],74:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plot_api/plot_template":193,"../../registry":243,"./attributes":66,"fast-isnumeric":10}],70:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21407,7 +21482,7 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":161,"../../plot_api/edit_types":188,"./attributes":70,"./calc":71,"./compute_error":72,"./defaults":73,"./plot":75,"./style":76}],75:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plot_api/edit_types":186,"./attributes":66,"./calc":67,"./compute_error":68,"./defaults":69,"./plot":71,"./style":72}],71:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21425,7 +21500,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); var subTypes = _dereq_('../../traces/scatter/subtypes'); -module.exports = function plot(traces, plotinfo, transitionOpts) { +module.exports = function plot(gd, traces, plotinfo, transitionOpts) { var isNew; var xa = plotinfo.xaxis; @@ -21476,7 +21551,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { .style('opacity', 1); } - Drawing.setClipUrl(errorbars, plotinfo.layerClipId); + Drawing.setClipUrl(errorbars, plotinfo.layerClipId, gd); errorbars.each(function(d) { var errorbar = d3.select(this); @@ -21581,7 +21656,7 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":306,"../drawing":68,"d3":8,"fast-isnumeric":10}],76:[function(_dereq_,module,exports){ +},{"../../traces/scatter/subtypes":305,"../drawing":64,"d3":8,"fast-isnumeric":10}],72:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21618,7 +21693,7 @@ module.exports = function style(traces) { }); }; -},{"../color":43,"d3":8}],77:[function(_dereq_,module,exports){ +},{"../color":43,"d3":8}],73:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21664,7 +21739,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":232}],78:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":230}],74:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21701,6 +21776,8 @@ module.exports = function calc(gd) { fillFn(trace.hoverinfo, cd, 'hi', makeCoerceHoverInfo(trace)); + if(trace.hovertemplate) fillFn(trace.hovertemplate, cd, 'ht'); + if(!trace.hoverlabel) continue; fillFn(trace.hoverlabel.bgcolor, cd, 'hbg'); @@ -21720,7 +21797,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":161,"../../registry":245}],79:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../registry":243}],75:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21758,7 +21835,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":245,"./hover":83}],80:[function(_dereq_,module,exports){ +},{"../../registry":243,"./hover":79}],76:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21790,7 +21867,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],81:[function(_dereq_,module,exports){ +},{}],77:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21813,7 +21890,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, layout.hoverlabel); }; -},{"../../lib":161,"./attributes":77,"./hoverlabel_defaults":84}],82:[function(_dereq_,module,exports){ +},{"../../lib":159,"./attributes":73,"./hoverlabel_defaults":80}],78:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22056,7 +22133,7 @@ function getPointData(val, pointNumber) { } } -},{"../../lib":161}],83:[function(_dereq_,module,exports){ +},{"../../lib":159}],79:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22185,13 +22262,17 @@ exports.loneHover = function loneHover(hoverItem, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; var container3 = d3.select(opts.container); @@ -22205,7 +22286,6 @@ exports.loneHover = function loneHover(hoverItem, opts) { container: container3, outerContainer: outerContainer3 }; - var hoverLabel = createHoverText([pointData], fullOpts, opts.gd); alignHoverText(hoverLabel, fullOpts.rotateLabels); @@ -22239,13 +22319,17 @@ exports.multiHovers = function multiHovers(hoverItems, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; }); @@ -22721,7 +22805,14 @@ function _hover(gd, evt, subplot, noHoverEvent) { // other people and send it to the event for(itemnum = 0; itemnum < hoverData.length; itemnum++) { var pt = hoverData[itemnum]; - newhoverdata.push(helpers.makeEventData(pt, pt.trace, pt.cd)); + var eventData = helpers.makeEventData(pt, pt.trace, pt.cd); + + var ht = false; + if(pt.cd[pt.index] && pt.cd[pt.index].ht) ht = pt.cd[pt.index].ht; + hoverData[itemnum].hovertemplate = ht || pt.trace.hovertemplate || false; + hoverData[itemnum].eventData = [eventData]; + + newhoverdata.push(eventData); } gd._hoverdata = newhoverdata; @@ -22779,6 +22870,8 @@ function _hover(gd, evt, subplot, noHoverEvent) { }); } +var EXTRA_STRING_REGEX = /([\s\S]*)<\/extra>/; + function createHoverText(hoverData, opts, gd) { var hovermode = opts.hovermode; var rotateLabels = opts.rotateLabels; @@ -22822,11 +22915,13 @@ function createHoverText(hoverData, opts, gd) { if(allHaveZ && hoverData[i].zLabel === undefined) allHaveZ = false; traceHoverinfo = hoverData[i].hoverinfo || hoverData[i].trace.hoverinfo; - var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); - if(parts.indexOf('all') === -1 && - parts.indexOf(hovermode) === -1) { - showCommonLabel = false; - break; + if(traceHoverinfo) { + var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); + if(parts.indexOf('all') === -1 && + parts.indexOf(hovermode) === -1) { + showCommonLabel = false; + break; + } } } @@ -23009,6 +23104,19 @@ function createHoverText(hoverData, opts, gd) { text = name; } + // hovertemplate + var hovertemplate = d.hovertemplate || false; + var hovertemplateLabels = d.hovertemplateLabels || d; + var eventData = d.eventData[0] || {}; + if(hovertemplate) { + text = Lib.hovertemplateString(hovertemplate, hovertemplateLabels, eventData); + + text = text.replace(EXTRA_STRING_REGEX, function(match, extra) { + name = extra; // Assign name for secondary text label + return ''; // Remove from main text label + }); + } + // main label var tx = g.select('text.nums') .call(Drawing.font, @@ -23407,7 +23515,7 @@ function cleanPoint(d, hovermode) { var infomode = d.hoverinfo || d.trace.hoverinfo; - if(infomode !== 'all') { + if(infomode && infomode !== 'all') { infomode = Array.isArray(infomode) ? infomode : infomode.split('+'); if(infomode.indexOf('x') === -1) d.xLabel = undefined; if(infomode.indexOf('y') === -1) d.yLabel = undefined; @@ -23593,8 +23701,11 @@ function hoverChanged(gd, evt, oldhoverdata) { for(var i = oldhoverdata.length - 1; i >= 0; i--) { var oldPt = oldhoverdata[i]; var newPt = gd._hoverdata[i]; + if(oldPt.curveNumber !== newPt.curveNumber || - String(oldPt.pointNumber) !== String(newPt.pointNumber)) { + String(oldPt.pointNumber) !== String(newPt.pointNumber) || + String(oldPt.pointNumbers) !== String(newPt.pointNumbers) + ) { return true; } } @@ -23610,7 +23721,7 @@ function spikesChanged(gd, oldspikepoints) { return false; } -},{"../../lib":161,"../../lib/events":154,"../../lib/override_cursor":172,"../../lib/svg_text_utils":182,"../../plots/cartesian/axes":205,"../../registry":245,"../color":43,"../dragelement":65,"../drawing":68,"./constants":80,"./helpers":82,"d3":8,"fast-isnumeric":10,"tinycolor2":26}],84:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../lib/events":152,"../../lib/override_cursor":170,"../../lib/svg_text_utils":180,"../../plots/cartesian/axes":203,"../../registry":243,"../color":43,"../dragelement":61,"../drawing":64,"./constants":76,"./helpers":78,"d3":8,"fast-isnumeric":10,"tinycolor2":26}],80:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23632,7 +23743,49 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts Lib.coerceFont(coerce, 'hoverlabel.font', opts.font); }; -},{"../../lib":161}],85:[function(_dereq_,module,exports){ +},{"../../lib":159}],81:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function(opts, extra) { + opts = opts || {}; + extra = extra || {}; + + var descPart = extra.description ? ' ' + extra.description : ''; + var keys = extra.keys || []; + if(keys.length > 0) { + var quotedKeys = []; + for(var i = 0; i < keys.length; i++) { + quotedKeys[i] = '`' + keys[i] + '`'; + } + descPart = descPart + 'Finally, the template string has access to '; + if(keys.length === 1) { + descPart = 'variable ' + quotedKeys[0]; + } else { + descPart = 'variables ' + quotedKeys.slice(0, -1).join(', ') + ' and ' + quotedKeys.slice(-1) + '.'; + } + } + + var hovertemplate = { + valType: 'string', + + dflt: '', + arrayOk: true, + editType: 'none', + + }; + + return hovertemplate; +}; + +},{}],82:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23712,7 +23865,7 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":161,"../dragelement":65,"./attributes":77,"./calc":78,"./click":79,"./constants":80,"./defaults":81,"./helpers":82,"./hover":83,"./layout_attributes":86,"./layout_defaults":87,"./layout_global_defaults":88,"d3":8}],86:[function(_dereq_,module,exports){ +},{"../../lib":159,"../dragelement":61,"./attributes":73,"./calc":74,"./click":75,"./constants":76,"./defaults":77,"./helpers":78,"./hover":79,"./layout_attributes":83,"./layout_defaults":84,"./layout_global_defaults":85,"d3":8}],83:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23745,7 +23898,7 @@ module.exports = { dragmode: { valType: 'enumerated', - values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'], + values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable', false], dflt: 'zoom', editType: 'modebar', @@ -23807,7 +23960,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":232,"./constants":80}],87:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":230,"./constants":76}],84:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23880,7 +24033,7 @@ function isHoriz(fullData) { return out; } -},{"../../lib":161,"./layout_attributes":86}],88:[function(_dereq_,module,exports){ +},{"../../lib":159,"./layout_attributes":83}],85:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23903,7 +24056,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":161,"./hoverlabel_defaults":84,"./layout_attributes":86}],89:[function(_dereq_,module,exports){ +},{"../../lib":159,"./hoverlabel_defaults":80,"./layout_attributes":83}],86:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24288,7 +24441,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":161,"../../lib/regex":176,"../../plot_api/plot_template":195,"../../plots/cartesian/constants":211,"../../plots/domain":231}],90:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../lib/regex":174,"../../plot_api/plot_template":193,"../../plots/cartesian/constants":209,"../../plots/domain":229}],87:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24423,7 +24576,7 @@ module.exports = templatedArray('image', { editType: 'arraydraw' }); -},{"../../plot_api/plot_template":195,"../../plots/cartesian/constants":211}],91:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":193,"../../plots/cartesian/constants":209}],88:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24506,7 +24659,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":184,"fast-isnumeric":10}],92:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":182,"fast-isnumeric":10}],89:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24567,7 +24720,7 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":161,"../../plots/array_container_defaults":201,"../../plots/cartesian/axes":205,"./attributes":90}],93:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/array_container_defaults":199,"../../plots/cartesian/axes":203,"./attributes":87}],90:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24738,9 +24891,10 @@ module.exports = function draw(gd) { yId = ya ? ya._id : '', clipAxes = xId + yId; - thisImage.call(Drawing.setClipUrl, clipAxes ? - ('clip' + fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + thisImage, + clipAxes ? ('clip' + fullLayout._uid + clipAxes) : null, + gd ); } @@ -24788,7 +24942,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":144,"../../plots/cartesian/axes":205,"../drawing":68,"d3":8}],94:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":141,"../../plots/cartesian/axes":203,"../drawing":64,"d3":8}],91:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24812,56 +24966,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":216,"./attributes":90,"./convert_coords":91,"./defaults":92,"./draw":93}],95:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - - -/** - * Determine the position anchor property of x/y xanchor/yanchor components. - * - * - values < 1/3 align the low side at that fraction, - * - values [1/3, 2/3] align the center at that fraction, - * - values > 2/3 align the right at that fraction. - */ - -exports.isRightAnchor = function isRightAnchor(opts) { - return ( - opts.xanchor === 'right' || - (opts.xanchor === 'auto' && opts.x >= 2 / 3) - ); -}; - -exports.isCenterAnchor = function isCenterAnchor(opts) { - return ( - opts.xanchor === 'center' || - (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) - ); -}; - -exports.isBottomAnchor = function isBottomAnchor(opts) { - return ( - opts.yanchor === 'bottom' || - (opts.yanchor === 'auto' && opts.y <= 1 / 3) - ); -}; - -exports.isMiddleAnchor = function isMiddleAnchor(opts) { - return ( - opts.yanchor === 'middle' || - (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) - ); -}; - -},{}],96:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":214,"./attributes":87,"./convert_coords":88,"./defaults":89,"./draw":90}],92:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24959,11 +25064,25 @@ module.exports = { editType: 'legend', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + valign: { + valType: 'enumerated', + values: ['top', 'middle', 'bottom'], + dflt: 'middle', + + editType: 'legend', + }, editType: 'legend' }; -},{"../../plots/font_attributes":232,"../color/attributes":42}],97:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":230,"../color/attributes":42}],93:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24982,7 +25101,7 @@ module.exports = { textOffsetX: 40 }; -},{}],98:[function(_dereq_,module,exports){ +},{}],94:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25051,7 +25170,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { basePlotLayoutAttributes, 'showlegend', legendReallyHasATrace && legendTraceCount > 1); - if(showLegend === false) return; + if(showLegend === false && !containerIn.uirevision) return; var containerOut = Template.newContainer(layoutOut, 'legend'); @@ -25059,6 +25178,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); } + coerce('uirevision', layoutOut.uirevision); + + if(showLegend === false) return; + coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); @@ -25067,7 +25190,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('orientation'); if(containerOut.orientation === 'h') { var xaxis = layoutIn.xaxis; - if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { + if(Registry.getComponentMethod('rangeslider', 'isVisible')(xaxis)) { defaultX = 0; defaultXAnchor = 'left'; defaultY = 1.1; @@ -25088,10 +25211,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('xanchor', defaultXAnchor); coerce('y', defaultY); coerce('yanchor', defaultYAnchor); + coerce('valign'); Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); }; -},{"../../lib":161,"../../plot_api/plot_template":195,"../../plots/layout_attributes":236,"../../registry":245,"./attributes":96,"./helpers":102}],99:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plot_api/plot_template":193,"../../plots/layout_attributes":234,"../../registry":243,"./attributes":92,"./helpers":98}],95:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25124,7 +25248,6 @@ var FROM_BR = alignmentConstants.FROM_BR; var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); -var anchorUtils = _dereq_('./anchor_utils'); var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; @@ -25248,17 +25371,17 @@ module.exports = function draw(gd) { lx = gs.l + gs.w * opts.x, ly = gs.t + gs.h * (1 - opts.y); - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= opts._width; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= opts._height; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -25318,7 +25441,7 @@ module.exports = function draw(gd) { y: opts.borderwidth }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; @@ -25356,7 +25479,7 @@ module.exports = function draw(gd) { y: opts.borderwidth + scrollBoxY }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -25433,7 +25556,7 @@ module.exports = function draw(gd) { }, doneFn: function() { if(xf !== undefined && yf !== undefined) { - Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf}); + Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf}); } }, clickFn: function(numClicks, e) { @@ -25540,7 +25663,7 @@ function drawTexts(g, gd, maxLength) { update.name = newName; } - return Registry.call('restyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, traceIndex); }); } else { textLayout(textEl); @@ -25630,6 +25753,7 @@ function computeTextDimensions(g, gd) { // to avoid getBoundingClientRect var textY = lineHeight * (0.3 + (1 - textLines) / 2); svgTextUtils.positionText(text, constants.textOffsetX, textY); + legendItem.lineHeight = lineHeight; } height = Math.max(height, 16) + 3; @@ -25793,18 +25917,18 @@ function expandMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -25824,10 +25948,10 @@ function expandHorizontalMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } @@ -25842,7 +25966,7 @@ function expandHorizontalMargin(gd) { }); } -},{"../../constants/alignment":141,"../../constants/interactions":142,"../../lib":161,"../../lib/events":154,"../../lib/svg_text_utils":182,"../../plots/plots":238,"../../registry":245,"../color":43,"../dragelement":65,"../drawing":68,"./anchor_utils":95,"./constants":97,"./get_legend_data":100,"./handle_click":101,"./helpers":102,"./style":104,"d3":8}],100:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../constants/interactions":139,"../../lib":159,"../../lib/events":152,"../../lib/svg_text_utils":180,"../../plots/plots":236,"../../registry":243,"../color":43,"../dragelement":61,"../drawing":64,"./constants":93,"./get_legend_data":96,"./handle_click":97,"./helpers":98,"./style":100,"d3":8}],96:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25948,7 +26072,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":245,"./helpers":102}],101:[function(_dereq_,module,exports){ +},{"../../registry":243,"./helpers":98}],97:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26062,7 +26186,7 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices); + Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices); } else { var hasLegendgroup = legendgroup && legendgroup.length; var traceIndicesInGroup = []; @@ -26168,11 +26292,11 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', gd, attrUpdate, attrIndices); + Registry.call('_guiRestyle', gd, attrUpdate, attrIndices); } }; -},{"../../lib":161,"../../registry":245}],102:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../registry":243}],98:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26196,7 +26320,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],103:[function(_dereq_,module,exports){ +},{}],99:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26220,7 +26344,7 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":96,"./defaults":98,"./draw":99,"./style":104}],104:[function(_dereq_,module,exports){ +},{"./attributes":92,"./defaults":94,"./draw":95,"./style":100}],100:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26248,6 +26372,19 @@ module.exports = function style(s, gd) { var layers = Lib.ensureSingle(traceGroup, 'g', 'layers'); layers.style('opacity', d[0].trace.opacity); + // Marker vertical alignment + var valign = gd._fullLayout.legend.valign; + var lineHeight = d[0].lineHeight; + var height = d[0].height; + + if(valign === 'middle' || !lineHeight || !height) { + layers.attr('transform', null); // this here is a fun d3 trick to unset DOM attributes + } else { + var factor = {top: 1, bottom: -1}[valign]; + var markerOffsetY = factor * (0.5 * (lineHeight - height + 3)); + layers.attr('transform', 'translate(0,' + markerOffsetY + ')'); + } + var fill = layers .selectAll('g.legendfill') .data([d]); @@ -26567,7 +26704,7 @@ module.exports = function style(s, gd) { } }; -},{"../../lib":161,"../../registry":245,"../../traces/pie/style_one":280,"../../traces/scatter/subtypes":306,"../color":43,"../drawing":68,"d3":8}],105:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../registry":243,"../../traces/pie/style_one":279,"../../traces/scatter/subtypes":305,"../color":43,"../drawing":64,"d3":8}],101:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26831,7 +26968,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -26887,7 +27024,7 @@ function handleDrag3d(gd, ev) { var val2d = (val === 'pan') ? val : 'zoom'; layoutUpdate.dragmode = val2d; - Registry.call('relayout', gd, layoutUpdate); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.resetCameraDefault3d = { @@ -26926,7 +27063,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -26940,54 +27077,48 @@ modeBarButtons.hoverClosest3d = { click: handleHover3d }; -function handleHover3d(gd, ev) { +function getNextHover3d(gd, ev) { var button = ev.currentTarget; - var val = button._previousVal || false; - var layout = gd.layout; + var val = button._previousVal; var fullLayout = gd._fullLayout; var sceneIds = fullLayout._subplots.gl3d; var axes = ['xaxis', 'yaxis', 'zaxis']; - var spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor']; // initialize 'current spike' object to be stored in the DOM var currentSpikes = {}; - var axisSpikes = {}; var layoutUpdate = {}; if(val) { - layoutUpdate = Lib.extendDeep(layout, val); + layoutUpdate = val; button._previousVal = null; } else { - layoutUpdate = { - 'allaxes.showspikes': false - }; - for(var i = 0; i < sceneIds.length; i++) { - var sceneId = sceneIds[i], - sceneLayout = fullLayout[sceneId], - sceneSpikes = currentSpikes[sceneId] = {}; + var sceneId = sceneIds[i]; + var sceneLayout = fullLayout[sceneId]; - sceneSpikes.hovermode = sceneLayout.hovermode; - layoutUpdate[sceneId + '.hovermode'] = false; + var hovermodeAStr = sceneId + '.hovermode'; + currentSpikes[hovermodeAStr] = sceneLayout.hovermode; + layoutUpdate[hovermodeAStr] = false; // copy all the current spike attrs for(var j = 0; j < 3; j++) { var axis = axes[j]; - axisSpikes = sceneSpikes[axis] = {}; - - for(var k = 0; k < spikeAttrs.length; k++) { - var spikeAttr = spikeAttrs[k]; - axisSpikes[spikeAttr] = sceneLayout[axis][spikeAttr]; - } + var spikeAStr = sceneId + '.' + axis + '.showspikes'; + layoutUpdate[spikeAStr] = false; + currentSpikes[spikeAStr] = sceneLayout[axis].showspikes; } } - button._previousVal = Lib.extendDeep({}, currentSpikes); + button._previousVal = currentSpikes; } + return layoutUpdate; +} - Registry.call('relayout', gd, layoutUpdate); +function handleHover3d(gd, ev) { + var layoutUpdate = getNextHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.zoomInGeo = { @@ -27043,7 +27174,7 @@ function handleGeo(gd, ev) { var scale = geoLayout.projection.scale; var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; - Registry.call('relayout', gd, id + '.projection.scale', newScale); + Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); } else if(attr === 'reset') { resetView(gd, 'geo'); } @@ -27071,18 +27202,20 @@ modeBarButtons.hoverClosestPie = { click: toggleHover }; -function toggleHover(gd) { +function getNextHover(gd) { var fullLayout = gd._fullLayout; - var onHoverVal; + if(fullLayout.hovermode) return false; + if(fullLayout._has('cartesian')) { - onHoverVal = fullLayout._isHoriz ? 'y' : 'x'; + return fullLayout._isHoriz ? 'y' : 'x'; } - else onHoverVal = 'closest'; - - var newHover = gd._fullLayout.hovermode ? false : onHoverVal; + return 'closest'; +} - Registry.call('relayout', gd, 'hovermode', newHover); +function toggleHover(gd) { + var newHover = getNextHover(gd); + Registry.call('_guiRelayout', gd, 'hovermode', newHover); } // buttons when more then one plot types are present @@ -27096,12 +27229,10 @@ modeBarButtons.toggleHover = { icon: Icons.tooltip_basic, gravity: 'ne', click: function(gd, ev) { - toggleHover(gd); + var layoutUpdate = getNextHover3d(gd, ev); + layoutUpdate.hovermode = getNextHover(gd); - // the 3d hovermode update must come - // last so that layout.hovermode update does not - // override scene?.hovermode?.layout. - handleHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } }; @@ -27137,7 +27268,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } }; @@ -27184,10 +27315,10 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', gd, aObj); + Registry.call('_guiRelayout', gd, aObj); } -},{"../../../build/ploticon":2,"../../lib":161,"../../plots/cartesian/axis_ids":208,"../../plots/plots":238,"../../registry":245}],106:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":159,"../../plots/cartesian/axis_ids":206,"../../plots/plots":236,"../../registry":243}],102:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27201,7 +27332,7 @@ function resetView(gd, subplotType) { exports.manage = _dereq_('./manage'); -},{"./manage":107}],107:[function(_dereq_,module,exports){ +},{"./manage":103}],103:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27233,7 +27364,7 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar) { + if(!context.displayModeBar && !context.watermark) { if(modeBar) { modeBar.destroy(); delete fullLayout._modeBar; @@ -27261,11 +27392,15 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); } + else if(!context.displayModeBar && context.watermark) { + buttonGroups = []; + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, - context.modeBarButtonsToAdd + context.modeBarButtonsToAdd, + context.showSendToCloud ); } @@ -27274,7 +27409,7 @@ module.exports = function manageModeBar(gd) { }; // logic behind which buttons are displayed by default -function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { +function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; @@ -27305,7 +27440,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { } // buttons common to all plot types - addGroup(['toImage', 'sendDataToCloud']); + var commonGroup = ['toImage']; + if(showSendToCloud) commonGroup.push('sendDataToCloud'); + addGroup(commonGroup); var zoomGroup = []; var hoverGroup = []; @@ -27456,7 +27593,7 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":208,"../../registry":245,"../../traces/scatter/subtypes":306,"./buttons":105,"./modebar":108}],108:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axis_ids":206,"../../registry":243,"../../traces/scatter/subtypes":305,"./buttons":101,"./modebar":104}],104:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27539,11 +27676,16 @@ proto.update = function(graphInfo, buttons) { this.updateButtons(buttons); - if(context.displaylogo) { + if(context.watermark || context.displaylogo) { + var logoGroup = this.getLogo(); + if(context.watermark) { + logoGroup.className = logoGroup.className + ' watermark'; + } + if(fullLayout.modebar.orientation === 'v') { - this.element.prepend(this.getLogo()); + this.element.prepend(logoGroup); } else { - this.element.appendChild(this.getLogo()); + this.element.appendChild(logoGroup); } this.hasLogo = true; @@ -27802,7 +27944,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../../build/ploticon":2,"../../lib":161,"d3":8,"fast-isnumeric":10}],109:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":159,"d3":8,"fast-isnumeric":10}],105:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27938,7 +28080,7 @@ module.exports = { editType: 'plot' }; -},{"../../plot_api/plot_template":195,"../../plots/font_attributes":232,"../color/attributes":42}],110:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":193,"../../plots/font_attributes":230,"../color/attributes":42}],106:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27967,7 +28109,7 @@ module.exports = { darkAmount: 10 }; -},{}],111:[function(_dereq_,module,exports){ +},{}],107:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28060,7 +28202,7 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":161,"../../plot_api/plot_template":195,"../../plots/array_container_defaults":201,"../color":43,"./attributes":109,"./constants":110}],112:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plot_api/plot_template":193,"../../plots/array_container_defaults":199,"../color":43,"./attributes":105,"./constants":106}],108:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28080,7 +28222,6 @@ var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var alignmentConstants = _dereq_('../../constants/alignment'); var LINE_SPACING = alignmentConstants.LINE_SPACING; @@ -28132,7 +28273,7 @@ module.exports = function draw(gd) { button.on('click', function() { if(gd._dragged) return; - Registry.call('relayout', gd, update); + Registry.call('_guiRelayout', gd, update); }); button.on('mouseover', function() { @@ -28281,21 +28422,21 @@ function reposition(gd, buttons, opts, axName, selector) { var ly = graphSize.t + graphSize.h * (1 - opts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= width; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(opts)) { + if(Lib.isCenterAnchor(opts)) { lx -= width / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(opts)) { + if(Lib.isMiddleAnchor(opts)) { ly -= height / 2; yanchor = 'middle'; } @@ -28317,7 +28458,7 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', 'translate(' + lx + ',' + ly + ')'); } -},{"../../constants/alignment":141,"../../lib":161,"../../lib/svg_text_utils":182,"../../plots/cartesian/axis_ids":208,"../../plots/plots":238,"../../registry":245,"../color":43,"../drawing":68,"../legend/anchor_utils":95,"./constants":110,"./get_update_object":113,"d3":8}],113:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../lib":159,"../../lib/svg_text_utils":180,"../../plots/cartesian/axis_ids":206,"../../plots/plots":236,"../../registry":243,"../color":43,"../drawing":64,"./constants":106,"./get_update_object":109,"d3":8}],109:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28374,7 +28515,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":8}],114:[function(_dereq_,module,exports){ +},{"d3":8}],110:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28401,7 +28542,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":109,"./defaults":111,"./draw":112}],115:[function(_dereq_,module,exports){ +},{"./attributes":105,"./defaults":107,"./draw":108}],111:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28475,7 +28616,7 @@ module.exports = { editType: 'calc' }; -},{"../color/attributes":42}],116:[function(_dereq_,module,exports){ +},{"../color/attributes":42}],112:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28509,7 +28650,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":204,"../../plots/cartesian/axis_ids":208,"./constants":117}],117:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/autorange":202,"../../plots/cartesian/axis_ids":206,"./constants":113}],113:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28565,7 +28706,7 @@ module.exports = { extraPad: 15 }; -},{}],118:[function(_dereq_,module,exports){ +},{}],114:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28651,7 +28792,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":161,"../../plot_api/plot_template":195,"../../plots/cartesian/axis_ids":208,"./attributes":115,"./oppaxis_attributes":121}],119:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plot_api/plot_template":193,"../../plots/cartesian/axis_ids":206,"./attributes":111,"./oppaxis_attributes":118}],115:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28673,7 +28814,7 @@ var Color = _dereq_('../color'); var Titles = _dereq_('../titles'); var Cartesian = _dereq_('../../plots/cartesian'); -var Axes = _dereq_('../../plots/cartesian/axes'); +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); var dragElement = _dereq_('../dragelement'); var setCursor = _dereq_('../../lib/setcursor'); @@ -28681,8 +28822,13 @@ var setCursor = _dereq_('../../lib/setcursor'); var constants = _dereq_('./constants'); module.exports = function(gd) { - var fullLayout = gd._fullLayout, - rangeSliderData = makeRangeSliderData(fullLayout); + var fullLayout = gd._fullLayout; + var rangeSliderData = fullLayout._rangeSliderData; + for(var i = 0; i < rangeSliderData.length; i++) { + var opts = rangeSliderData[i][constants.name]; + // fullLayout._uid may not exist when we call makeData + opts._clipId = opts._id + '-' + fullLayout._uid; + } /* * @@ -28709,10 +28855,6 @@ module.exports = function(gd) { .selectAll('g.' + constants.containerClassName) .data(rangeSliderData, keyFunction); - rangeSliders.enter().append('g') - .classed(constants.containerClassName, true) - .attr('pointer-events', 'all'); - // remove exiting sliders and their corresponding clip paths rangeSliders.exit().each(function(axisOpts) { var opts = axisOpts[constants.name]; @@ -28722,48 +28864,51 @@ module.exports = function(gd) { // return early if no range slider is visible if(rangeSliderData.length === 0) return; + rangeSliders.enter().append('g') + .classed(constants.containerClassName, true) + .attr('pointer-events', 'all'); + // for all present range sliders rangeSliders.each(function(axisOpts) { - var rangeSlider = d3.select(this), - opts = axisOpts[constants.name], - oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)], - oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)]; + var rangeSlider = d3.select(this); + var opts = axisOpts[constants.name]; + var oppAxisOpts = fullLayout[axisIDs.id2name(axisOpts.anchor)]; + var oppAxisRangeOpts = opts[axisIDs.id2name(axisOpts.anchor)]; // update range // Expand slider range to the axis range - // TODO: what if the ranges are reversed? if(opts.range) { - var outRange = opts.range; - var axRange = axisOpts.range; + var rng = Lib.simpleMap(opts.range, axisOpts.r2l); + var axRng = Lib.simpleMap(axisOpts.range, axisOpts.r2l); + var newRng; + + if(axRng[0] < axRng[1]) { + newRng = [ + Math.min(rng[0], axRng[0]), + Math.max(rng[1], axRng[1]) + ]; + } else { + newRng = [ + Math.max(rng[0], axRng[0]), + Math.min(rng[1], axRng[1]) + ]; + } - outRange[0] = axisOpts.l2r(Math.min(axisOpts.r2l(outRange[0]), axisOpts.r2l(axRange[0]))); - outRange[1] = axisOpts.l2r(Math.max(axisOpts.r2l(outRange[1]), axisOpts.r2l(axRange[1]))); - opts._input.range = outRange.slice(); + opts.range = opts._input.range = Lib.simpleMap(newRng, axisOpts.l2r); } axisOpts.cleanRange('rangeslider.range'); - // update range slider dimensions var margin = fullLayout.margin; var graphSize = fullLayout._size; var domain = axisOpts.domain; - var tickHeight = (axisOpts._boundingBox || {}).height || 0; - - var oppBottom = Infinity; - var subplotData = Axes.getSubplots(gd, axisOpts); - for(var i = 0; i < subplotData.length; i++) { - var oppAxis = Axes.getFromId(gd, subplotData[i].substr(subplotData[i].indexOf('y'))); - oppBottom = Math.min(oppBottom, oppAxis.domain[0]); - } + var tickHeight = opts._tickHeight; - opts._id = constants.name + axisOpts._id; - opts._clipId = opts._id + '-' + fullLayout._uid; + var oppBottom = opts._oppBottom; opts._width = graphSize.w * (domain[1] - domain[0]); - opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; - opts._offsetShift = Math.floor(opts.borderwidth / 2); var x = Math.round(margin.l + (graphSize.w * domain[0])); @@ -28826,41 +28971,14 @@ module.exports = function(gd) { placeholder: fullLayout._dfltTitle.x, attributes: { x: axisOpts._offset + axisOpts._length / 2, - y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size, + y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.title.font.size, 'text-anchor': 'middle' } }); } - - // update margins - Plots.autoMargin(gd, opts._id, { - x: domain[0], - y: oppBottom, - l: 0, - r: 0, - t: 0, - b: opts._height + margin.b + tickHeight, - pad: constants.extraPad + opts._offsetShift * 2 - }); }); }; -function makeRangeSliderData(fullLayout) { - var axes = Axes.list({ _fullLayout: fullLayout }, 'x', true), - name = constants.name, - out = []; - - if(fullLayout._has('gl2d')) return out; - - for(var i = 0; i < axes.length; i++) { - var ax = axes[i]; - - if(ax[name] && ax[name].visible) out.push(ax); - } - - return out; -} - function setupDragElement(rangeSlider, gd, axisOpts, opts) { var slideBox = rangeSlider.select('rect.' + constants.slideBoxClassName).node(), grabAreaMin = rangeSlider.select('rect.' + constants.grabAreaMinClassName).node(), @@ -28940,7 +29058,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) { dataMax = clamp(opts.p2d(opts._pixelMax)); window.requestAnimationFrame(function() { - Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); + Registry.call('_guiRelayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); }); } @@ -29047,15 +29165,14 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) { } function drawRangePlot(rangeSlider, gd, axisOpts, opts) { - var subplotData = Axes.getSubplots(gd, axisOpts), - calcData = gd.calcdata; + var calcData = gd.calcdata; var rangePlots = rangeSlider.selectAll('g.' + constants.rangePlotClassName) - .data(subplotData, Lib.identity); + .data(axisOpts._subplotsWith, Lib.identity); rangePlots.enter().append('g') .attr('class', function(id) { return constants.rangePlotClassName + ' ' + id; }) - .call(Drawing.setClipUrl, opts._clipId); + .call(Drawing.setClipUrl, opts._clipId, gd); rangePlots.order(); @@ -29067,7 +29184,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var plotgroup = d3.select(this), isMainPlot = (i === 0); - var oppAxisOpts = Axes.getFromId(gd, id, 'y'), + var oppAxisOpts = axisIDs.getFromId(gd, id, 'y'), oppAxisName = oppAxisOpts._name, oppAxisRangeOpts = opts[oppAxisName]; @@ -29099,6 +29216,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var xa = mockFigure._fullLayout.xaxis; var ya = mockFigure._fullLayout[oppAxisName]; + xa.clearCalc(); + xa.setScale(); + ya.clearCalc(); + ya.setScale(); + var plotinfo = { id: id, plotgroup: plotgroup, @@ -29251,7 +29373,77 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":161,"../../lib/setcursor":180,"../../plots/cartesian":217,"../../plots/cartesian/axes":205,"../../plots/plots":238,"../../registry":245,"../color":43,"../dragelement":65,"../drawing":68,"../titles":134,"./constants":117,"d3":8}],120:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../lib/setcursor":178,"../../plots/cartesian":215,"../../plots/cartesian/axis_ids":206,"../../plots/plots":236,"../../registry":243,"../color":43,"../dragelement":61,"../drawing":64,"../titles":131,"./constants":113,"d3":8}],116:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); +var constants = _dereq_('./constants'); +var name = constants.name; + +function isVisible(ax) { + var rangeSlider = ax && ax[name]; + return rangeSlider && rangeSlider.visible; +} +exports.isVisible = isVisible; + +exports.makeData = function(fullLayout) { + var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true); + var margin = fullLayout.margin; + var rangeSliderData = []; + + if(!fullLayout._has('gl2d')) { + for(var i = 0; i < axes.length; i++) { + var ax = axes[i]; + + if(isVisible(ax)) { + rangeSliderData.push(ax); + + var opts = ax[name]; + opts._id = name + ax._id; + opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; + opts._offsetShift = Math.floor(opts.borderwidth / 2); + } + } + } + + fullLayout._rangeSliderData = rangeSliderData; +}; + +exports.autoMarginOpts = function(gd, ax) { + var opts = ax[name]; + + var oppBottom = Infinity; + var counterAxes = ax._counterAxes; + for(var j = 0; j < counterAxes.length; j++) { + var counterId = counterAxes[j]; + var oppAxis = axisIDs.getFromId(gd, counterId); + oppBottom = Math.min(oppBottom, oppAxis.domain[0]); + } + opts._oppBottom = oppBottom; + + var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0; + opts._tickHeight = tickHeight; + + return { + x: 0, + y: oppBottom, + l: 0, + r: 0, + t: 0, + b: opts._height + gd._fullLayout.margin.b + tickHeight, + pad: constants.extraPad + opts._offsetShift * 2 + }; +}; + +},{"../../plots/cartesian/axis_ids":206,"./constants":113}],117:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29265,6 +29457,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { var Lib = _dereq_('../../lib'); var attrs = _dereq_('./attributes'); var oppAxisAttrs = _dereq_('./oppaxis_attributes'); +var helpers = _dereq_('./helpers'); module.exports = { moduleType: 'component', @@ -29283,10 +29476,13 @@ module.exports = { layoutAttributes: _dereq_('./attributes'), handleDefaults: _dereq_('./defaults'), calcAutorange: _dereq_('./calc_autorange'), - draw: _dereq_('./draw') + draw: _dereq_('./draw'), + isVisible: helpers.isVisible, + makeData: helpers.makeData, + autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":161,"./attributes":115,"./calc_autorange":116,"./defaults":118,"./draw":119,"./oppaxis_attributes":121}],121:[function(_dereq_,module,exports){ +},{"../../lib":159,"./attributes":111,"./calc_autorange":112,"./defaults":114,"./draw":115,"./helpers":116,"./oppaxis_attributes":118}],118:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29324,7 +29520,7 @@ module.exports = { editType: 'calc' }; -},{}],122:[function(_dereq_,module,exports){ +},{}],119:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29460,7 +29656,7 @@ module.exports = templatedArray('shape', { editType: 'arraydraw' }); -},{"../../lib/extend":155,"../../plot_api/plot_template":195,"../../traces/scatter/attributes":282,"../annotations/attributes":28,"../drawing/attributes":67}],123:[function(_dereq_,module,exports){ +},{"../../lib/extend":153,"../../plot_api/plot_template":193,"../../traces/scatter/attributes":281,"../annotations/attributes":28,"../drawing/attributes":63}],120:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29469,7 +29665,6 @@ module.exports = templatedArray('shape', { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); @@ -29547,7 +29742,7 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { } function shapeBounds(ax, v0, v1, path, paramsToUse) { - var convertVal = (ax.type === 'category') ? ax.r2c : ax.d2c; + var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; if(!path) return; @@ -29578,7 +29773,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":161,"../../plots/cartesian/axes":205,"./constants":124,"./helpers":127}],124:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/cartesian/axes":203,"./constants":121,"./helpers":124}],121:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29642,7 +29837,7 @@ module.exports = { } }; -},{}],125:[function(_dereq_,module,exports){ +},{}],122:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29767,7 +29962,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":161,"../../plots/array_container_defaults":201,"../../plots/cartesian/axes":205,"./attributes":122,"./helpers":127}],126:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/array_container_defaults":199,"../../plots/cartesian/axes":203,"./attributes":119,"./helpers":124}],123:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29890,9 +30085,10 @@ function setClipPath(shapePath, gd, shapeOptions) { // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 var clipAxes = (shapeOptions.xref + shapeOptions.yref).replace(/paper/g, ''); - shapePath.call(Drawing.setClipUrl, clipAxes ? - ('clip' + gd._fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } @@ -30076,7 +30272,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { // Don't rely on clipPath being activated during re-layout setClipPath(shapePath, gd, shapeOptions); - Registry.call('relayout', gd, editHelpers.getUpdateObj()); + Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj()); } function abortDrag() { @@ -30263,9 +30459,10 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(xref !== 'paper' && !xa.autorange) clipAxes += xref; if(yref !== 'paper' && !ya.autorange) clipAxes += yref; - shapePath.call(Drawing.setClipUrl, clipAxes ? - 'clip' + gd._fullLayout._uid + clipAxes : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } } @@ -30397,7 +30594,7 @@ function movePath(pathIn, moveX, moveY) { }); } -},{"../../lib":161,"../../lib/setcursor":180,"../../plot_api/plot_template":195,"../../plots/cartesian/axes":205,"../../registry":245,"../color":43,"../dragelement":65,"../drawing":68,"./constants":124,"./helpers":127}],127:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../lib/setcursor":178,"../../plot_api/plot_template":193,"../../plots/cartesian/axes":203,"../../registry":243,"../color":43,"../dragelement":61,"../drawing":64,"./constants":121,"./helpers":124}],124:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30522,7 +30719,7 @@ exports.roundPositionForSharpStrokeRendering = function(pos, strokeWidth) { return strokeWidthIsOdd ? posValAsInt + 0.5 : posValAsInt; }; -},{"../../lib":161,"./constants":124}],128:[function(_dereq_,module,exports){ +},{"../../lib":159,"./constants":121}],125:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30549,7 +30746,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":216,"./attributes":122,"./calc_autorange":123,"./defaults":125,"./draw":126}],129:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":214,"./attributes":119,"./calc_autorange":120,"./defaults":122,"./draw":123}],126:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30651,7 +30848,7 @@ module.exports = overrideAll(templatedArray('slider', { }, - pad: extendDeepAll({}, padAttrs, { + pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { }, {t: {dflt: 20}}), xanchor: { @@ -30792,7 +30989,7 @@ module.exports = overrideAll(templatedArray('slider', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":155,"../../plot_api/edit_types":188,"../../plot_api/plot_template":195,"../../plots/animation_attributes":200,"../../plots/font_attributes":232,"../../plots/pad_attributes":237,"./constants":130}],130:[function(_dereq_,module,exports){ +},{"../../lib/extend":153,"../../plot_api/edit_types":186,"../../plot_api/plot_template":193,"../../plots/animation_attributes":198,"../../plots/font_attributes":230,"../../plots/pad_attributes":235,"./constants":127}],127:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30886,7 +31083,7 @@ module.exports = { currentValueInset: 0, }; -},{}],131:[function(_dereq_,module,exports){ +},{}],128:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31003,7 +31200,7 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":161,"../../plots/array_container_defaults":201,"./attributes":129,"./constants":130}],132:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/array_container_defaults":199,"./attributes":126,"./constants":127}],129:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31021,7 +31218,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var constants = _dereq_('./constants'); @@ -31213,21 +31409,21 @@ function findDimensions(gd, sliderOpts) { dims.height = dims.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + dims.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(sliderOpts)) { + if(Lib.isRightAnchor(sliderOpts)) { dims.lx -= dims.outerLength; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(sliderOpts)) { + if(Lib.isCenterAnchor(sliderOpts)) { dims.lx -= dims.outerLength / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(sliderOpts)) { + if(Lib.isBottomAnchor(sliderOpts)) { dims.ly -= dims.height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(sliderOpts)) { + if(Lib.isMiddleAnchor(sliderOpts)) { dims.ly -= dims.height / 2; yanchor = 'middle'; } @@ -31634,7 +31830,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":141,"../../lib":161,"../../lib/svg_text_utils":182,"../../plot_api/plot_template":195,"../../plots/plots":238,"../color":43,"../drawing":68,"../legend/anchor_utils":95,"./constants":130,"d3":8}],133:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../lib":159,"../../lib/svg_text_utils":180,"../../plot_api/plot_template":193,"../../plots/plots":236,"../color":43,"../drawing":64,"./constants":127,"d3":8}],130:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31657,7 +31853,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":129,"./constants":130,"./defaults":131,"./draw":132}],134:[function(_dereq_,module,exports){ +},{"./attributes":126,"./constants":127,"./defaults":128,"./draw":129}],131:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31727,19 +31923,21 @@ function draw(gd, titleClass, options) { var group = options.containerGroup; var fullLayout = gd._fullLayout; - var titlefont = cont.titlefont || {}; - var font = titlefont.family; - var fontSize = titlefont.size; - var fontColor = titlefont.color; var opacity = 1; var isplaceholder = false; - var txt = (cont.title || '').trim(); + var title = cont.title; + var txt = (title && title.text ? title.text : '').trim(); + + var font = title && title.font ? title.font : {}; + var fontFamily = font.family; + var fontSize = font.size; + var fontColor = font.color; // only make this title editable if we positively identify its property // as one that has editing enabled. var editAttr; - if(prop === 'title') editAttr = 'titleText'; + if(prop === 'title.text') editAttr = 'titleText'; else if(prop.indexOf('axis') !== -1) editAttr = 'axisTitleText'; else if(prop.indexOf('colorbar' !== -1)) editAttr = 'colorbarTitleText'; var editable = gd._context.edits[editAttr]; @@ -31797,7 +31995,7 @@ function draw(gd, titleClass, options) { titleEl.attr('transform', transformVal); titleEl.style({ - 'font-family': font, + 'font-family': fontFamily, 'font-size': d3.round(fontSize, 2) + 'px', fill: Color.rgb(fontColor), opacity: opacity * Color.opacity(fontColor), @@ -31897,9 +32095,9 @@ function draw(gd, titleClass, options) { el.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { if(traceIndex !== undefined) { - Registry.call('restyle', gd, prop, text, traceIndex); + Registry.call('_guiRestyle', gd, prop, text, traceIndex); } else { - Registry.call('relayout', gd, prop, text); + Registry.call('_guiRelayout', gd, prop, text); } }) .on('cancel', function() { @@ -31916,7 +32114,7 @@ function draw(gd, titleClass, options) { return group; } -},{"../../constants/interactions":142,"../../lib":161,"../../lib/svg_text_utils":182,"../../plots/plots":238,"../../registry":245,"../color":43,"../drawing":68,"d3":8,"fast-isnumeric":10}],135:[function(_dereq_,module,exports){ +},{"../../constants/interactions":139,"../../lib":159,"../../lib/svg_text_utils":180,"../../plots/plots":236,"../../registry":243,"../color":43,"../drawing":64,"d3":8,"fast-isnumeric":10}],132:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32045,7 +32243,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { }, - pad: extendFlat({}, padAttrs, { + pad: extendFlat(padAttrs({editType: 'arraydraw'}), { }), @@ -32074,7 +32272,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":155,"../../plot_api/edit_types":188,"../../plot_api/plot_template":195,"../../plots/font_attributes":232,"../../plots/pad_attributes":237,"../color/attributes":42}],136:[function(_dereq_,module,exports){ +},{"../../lib/extend":153,"../../plot_api/edit_types":186,"../../plot_api/plot_template":193,"../../plots/font_attributes":230,"../../plots/pad_attributes":235,"../color/attributes":42}],133:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32155,7 +32353,7 @@ module.exports = { } }; -},{}],137:[function(_dereq_,module,exports){ +},{}],134:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32238,7 +32436,7 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":161,"../../plots/array_container_defaults":201,"./attributes":135,"./constants":136}],138:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/array_container_defaults":199,"./attributes":132,"./constants":133}],135:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32257,7 +32455,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var LINE_SPACING = _dereq_('../../constants/alignment').LINE_SPACING; @@ -32807,21 +33004,21 @@ function findDimensions(gd, menuOpts) { dims.ly = graphSize.t + graphSize.h * (1 - menuOpts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(menuOpts)) { + if(Lib.isRightAnchor(menuOpts)) { dims.lx -= paddedWidth; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(menuOpts)) { + if(Lib.isCenterAnchor(menuOpts)) { dims.lx -= paddedWidth / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(menuOpts)) { + if(Lib.isBottomAnchor(menuOpts)) { dims.ly -= paddedHeight; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(menuOpts)) { + if(Lib.isMiddleAnchor(menuOpts)) { dims.ly -= paddedHeight / 2; yanchor = 'middle'; } @@ -32888,9 +33085,9 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":141,"../../lib":161,"../../lib/svg_text_utils":182,"../../plot_api/plot_template":195,"../../plots/plots":238,"../color":43,"../drawing":68,"../legend/anchor_utils":95,"./constants":136,"./scrollbox":140,"d3":8}],139:[function(_dereq_,module,exports){ -arguments[4][133][0].apply(exports,arguments) -},{"./attributes":135,"./constants":136,"./defaults":137,"./draw":138,"dup":133}],140:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../lib":159,"../../lib/svg_text_utils":180,"../../plot_api/plot_template":193,"../../plots/plots":236,"../color":43,"../drawing":64,"./constants":133,"./scrollbox":137,"d3":8}],136:[function(_dereq_,module,exports){ +arguments[4][130][0].apply(exports,arguments) +},{"./attributes":132,"./constants":133,"./defaults":134,"./draw":135,"dup":130}],137:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33147,7 +33344,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { height: Math.ceil(clipB) - Math.floor(clipT) }); - this.container.call(Drawing.setClipUrl, clipId); + this.container.call(Drawing.setClipUrl, clipId, this.gd); this.bg.attr({ x: l, @@ -33361,7 +33558,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":161,"../color":43,"../drawing":68,"d3":8}],141:[function(_dereq_,module,exports){ +},{"../../lib":159,"../color":43,"../drawing":64,"d3":8}],138:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33405,12 +33602,17 @@ module.exports = { // multiple of fontSize to get the vertical offset between lines LINE_SPACING: 1.3, - // multiple of fontSize to shift from the baseline to the midline + // multiple of fontSize to shift from the baseline + // to the cap (captical letter) line // (to use when we don't calculate this shift from Drawing.bBox) - // To be precise this should be half the cap height (capital letter) - // of the font, and according to wikipedia: + // This is an approximation since in reality cap height can differ + // from font to font. However, according to Wikipedia // an "average" font might have a cap height of 70% of the em // https://en.wikipedia.org/wiki/Em_(typography)#History + CAP_SHIFT: 0.70, + + // half the cap height (distance between baseline and cap line) + // of an "average" font (for more info see above). MID_SHIFT: 0.35, OPPOSITE_SIDE: { @@ -33421,7 +33623,7 @@ module.exports = { } }; -},{}],142:[function(_dereq_,module,exports){ +},{}],139:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33448,7 +33650,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],143:[function(_dereq_,module,exports){ +},{}],140:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33513,7 +33715,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],144:[function(_dereq_,module,exports){ +},{}],141:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33537,7 +33739,7 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],145:[function(_dereq_,module,exports){ +},{}],142:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33549,7 +33751,7 @@ exports.svgAttrs = { 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.42.5'; +exports.version = '1.43.0'; // inject promise polyfill _dereq_('es6-promise').polyfill(); @@ -33558,7 +33760,7 @@ _dereq_('es6-promise').polyfill(); _dereq_('../build/plotcss'); // inject default MathJax config -_dereq_('./fonts/mathjax_config'); +_dereq_('./fonts/mathjax_config')(); // include registry module and expose register method var Registry = _dereq_('./registry'); @@ -33569,7 +33771,8 @@ var plotApi = _dereq_('./plot_api'); var methodNames = Object.keys(plotApi); for(var i = 0; i < methodNames.length; i++) { var name = methodNames[i]; - exports[name] = plotApi[name]; + // _ -> private API methods, but still registered for internal use + if(name.charAt(0) !== '_') exports[name] = plotApi[name]; register({ moduleType: 'apiMethod', name: name, @@ -33593,7 +33796,8 @@ register([ _dereq_('./components/rangeslider'), _dereq_('./components/rangeselector'), _dereq_('./components/grid'), - _dereq_('./components/errorbars') + _dereq_('./components/errorbars'), + _dereq_('./components/colorscale') ]); // locales en and en-US are required for default behavior @@ -33615,7 +33819,7 @@ exports.Queue = _dereq_('./lib/queue'); // export d3 used in the bundle exports.d3 = _dereq_('d3'); -},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":36,"./components/annotations3d":41,"./components/errorbars":74,"./components/fx":85,"./components/grid":89,"./components/images":94,"./components/legend":103,"./components/rangeselector":114,"./components/rangeslider":120,"./components/shapes":128,"./components/sliders":133,"./components/updatemenus":139,"./fonts/mathjax_config":146,"./lib/queue":175,"./locale-en":186,"./locale-en-us":185,"./plot_api":190,"./plot_api/plot_schema":194,"./plots/plots":238,"./registry":245,"./snapshot":250,"./traces/scatter":294,"d3":8,"es6-promise":9}],146:[function(_dereq_,module,exports){ +},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":36,"./components/annotations3d":41,"./components/colorscale":55,"./components/errorbars":70,"./components/fx":82,"./components/grid":86,"./components/images":91,"./components/legend":99,"./components/rangeselector":110,"./components/rangeslider":117,"./components/shapes":125,"./components/sliders":130,"./components/updatemenus":136,"./fonts/mathjax_config":143,"./lib/queue":173,"./locale-en":184,"./locale-en-us":183,"./plot_api":188,"./plot_api/plot_schema":192,"./plots/plots":236,"./registry":243,"./snapshot":248,"./traces/scatter":293,"d3":8,"es6-promise":9}],143:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33628,31 +33832,89 @@ exports.d3 = _dereq_('d3'); /* global MathJax:false */ +module.exports = function() { + if(typeof MathJax !== 'undefined') { + var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; + + if(globalConfig) { + MathJax.Hub.Config({ + messageStyle: 'none', + skipStartupTypeset: true, + displayAlign: 'left', + tex2jax: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + } + }); + MathJax.Hub.Configured(); + } + } +}; + +},{}],144:[function(_dereq_,module,exports){ /** - * Check and configure MathJax +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + + +/** + * Determine the position anchor property of x/y xanchor/yanchor components. + * + * - values < 1/3 align the low side at that fraction, + * - values [1/3, 2/3] align the center at that fraction, + * - values > 2/3 align the right at that fraction. */ -if(typeof MathJax !== 'undefined') { - exports.MathJax = true; - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } +exports.isLeftAnchor = function isLeftAnchor(opts) { + return ( + opts.xanchor === 'left' || + (opts.xanchor === 'auto' && opts.x <= 1 / 3) + ); +}; -} else { - exports.MathJax = false; -} +exports.isCenterAnchor = function isCenterAnchor(opts) { + return ( + opts.xanchor === 'center' || + (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) + ); +}; -},{}],147:[function(_dereq_,module,exports){ +exports.isRightAnchor = function isRightAnchor(opts) { + return ( + opts.xanchor === 'right' || + (opts.xanchor === 'auto' && opts.x >= 2 / 3) + ); +}; + +exports.isTopAnchor = function isTopAnchor(opts) { + return ( + opts.yanchor === 'top' || + (opts.yanchor === 'auto' && opts.y >= 2 / 3) + ); +}; + +exports.isMiddleAnchor = function isMiddleAnchor(opts) { + return ( + opts.yanchor === 'middle' || + (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) + ); +}; + +exports.isBottomAnchor = function isBottomAnchor(opts) { + return ( + opts.yanchor === 'bottom' || + (opts.yanchor === 'auto' && opts.y <= 1 / 3) + ); +}; + +},{}],145:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33893,7 +34155,7 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":168}],148:[function(_dereq_,module,exports){ +},{"./mod":166}],146:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34029,7 +34291,30 @@ exports.concat = function() { return out; }; -},{}],149:[function(_dereq_,module,exports){ +exports.maxRowLength = function(z) { + return _rowLength(z, Math.max, 0); +}; + +exports.minRowLength = function(z) { + return _rowLength(z, Math.min, Infinity); +}; + +function _rowLength(z, fn, len0) { + if(isArrayOrTypedArray(z)) { + if(isArrayOrTypedArray(z[0])) { + var len = len0; + for(var i = 0; i < z.length; i++) { + len = fn(len, z[i].length); + } + return len; + } else { + return z.length; + } + } + return 0; +} + +},{}],147:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34062,7 +34347,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":143,"fast-isnumeric":10}],150:[function(_dereq_,module,exports){ +},{"../constants/numerical":140,"fast-isnumeric":10}],148:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34090,7 +34375,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],151:[function(_dereq_,module,exports){ +},{}],149:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34113,7 +34398,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],152:[function(_dereq_,module,exports){ +},{}],150:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34122,18 +34407,17 @@ module.exports = function clearResponsive(gd) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); var baseTraceAttrs = _dereq_('../plots/attributes'); -var getColorscale = _dereq_('../components/colorscale/get_scale'); -var colorscaleNames = Object.keys(_dereq_('../components/colorscale/scales')); +var scales = _dereq_('../components/colorscale/scales'); +var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; + var nestedProperty = _dereq_('./nested_property'); var counterRegex = _dereq_('./regex').counter; -var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; var modHalf = _dereq_('./mod').modHalf; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -34251,7 +34535,7 @@ exports.valObjectMeta = { coerceFunction: function(v, propOut, dflt) { - propOut.set(getColorscale(v, dflt)); + propOut.set(scales.get(v, dflt)); } }, angle: { @@ -34585,7 +34869,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/get_scale":56,"../components/colorscale/scales":62,"../constants/interactions":142,"../plots/attributes":202,"./array":148,"./mod":168,"./nested_property":169,"./regex":176,"fast-isnumeric":10,"tinycolor2":26}],153:[function(_dereq_,module,exports){ +},{"../components/colorscale/scales":58,"../constants/interactions":139,"../plots/attributes":200,"./array":146,"./mod":166,"./nested_property":167,"./regex":174,"fast-isnumeric":10,"tinycolor2":26}],151:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35188,7 +35472,7 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":143,"../registry":245,"./loggers":165,"./mod":168,"d3":8,"fast-isnumeric":10}],154:[function(_dereq_,module,exports){ +},{"../constants/numerical":140,"../registry":243,"./loggers":163,"./mod":166,"d3":8,"fast-isnumeric":10}],152:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35362,7 +35646,7 @@ var Events = { module.exports = Events; -},{"events":7}],155:[function(_dereq_,module,exports){ +},{"events":7}],153:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35478,7 +35762,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":162}],156:[function(_dereq_,module,exports){ +},{"./is_plain_object.js":160}],154:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35529,7 +35813,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],157:[function(_dereq_,module,exports){ +},{}],155:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35576,7 +35860,7 @@ function isCalcData(cont) { ); } -},{}],158:[function(_dereq_,module,exports){ +},{}],156:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35822,7 +36106,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":168}],159:[function(_dereq_,module,exports){ +},{"./mod":166}],157:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35860,7 +36144,7 @@ module.exports = function(gd) { return gd; // otherwise assume that gd is a DOM element }; -},{}],160:[function(_dereq_,module,exports){ +},{}],158:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35876,7 +36160,7 @@ module.exports = function(gd) { module.exports = function identity(d) { return d; }; -},{}],161:[function(_dereq_,module,exports){ +},{}],159:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35910,6 +36194,8 @@ lib.isArrayOrTypedArray = arrayModule.isArrayOrTypedArray; lib.isArray1D = arrayModule.isArray1D; lib.ensureArray = arrayModule.ensureArray; lib.concat = arrayModule.concat; +lib.maxRowLength = arrayModule.maxRowLength; +lib.minRowLength = arrayModule.minRowLength; var modModule = _dereq_('./mod'); lib.mod = modModule.mod; @@ -35979,6 +36265,14 @@ lib.pathArc = anglesModule.pathArc; lib.pathSector = anglesModule.pathSector; lib.pathAnnulus = anglesModule.pathAnnulus; +var anchorUtils = _dereq_('./anchor_utils'); +lib.isLeftAnchor = anchorUtils.isLeftAnchor; +lib.isCenterAnchor = anchorUtils.isCenterAnchor; +lib.isRightAnchor = anchorUtils.isRightAnchor; +lib.isTopAnchor = anchorUtils.isTopAnchor; +lib.isMiddleAnchor = anchorUtils.isMiddleAnchor; +lib.isBottomAnchor = anchorUtils.isBottomAnchor; + var geom2dModule = _dereq_('./geometry2d'); lib.segmentsIntersect = geom2dModule.segmentsIntersect; lib.segmentDistance = geom2dModule.segmentDistance; @@ -36513,7 +36807,13 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) objOut[k] = v.slice(0, arrayLen); + else if(Array.isArray(v)) { + if(k === 'colorscale') { + objOut[k] = v.slice(); + } else { + objOut[k] = v.slice(0, arrayLen); + } + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -36858,10 +37158,10 @@ lib.numSeparate = function(value, separators, separatethousands) { return x1 + x2; }; -var TEMPLATE_STRING_REGEX = /%{([^\s%{}]*)}/g; +var TEMPLATE_STRING_REGEX = /%{([^\s%{}:]*)(:[^}]*)?}/g; var SIMPLE_PROPERTY_REGEX = /^\w*$/; -/* +/** * Substitute values from an object into a string * * Examples: @@ -36873,7 +37173,6 @@ var SIMPLE_PROPERTY_REGEX = /^\w*$/; * * @return {string} templated string */ - lib.templateString = function(string, obj) { // Not all that useful, but cache nestedProperty instantiation // just in case it speeds things up *slightly*: @@ -36888,6 +37187,67 @@ lib.templateString = function(string, obj) { }); }; +var TEMPLATE_STRING_FORMAT_SEPARATOR = /^:/; +var numberOfHoverTemplateWarnings = 0; +var maximumNumberOfHoverTemplateWarnings = 10; +/** + * Substitute values from an object into a string and optionally formats them using d3-format, + * or fallback to associated labels. + * + * Examples: + * Lib.templateString('name: %{trace}', {trace: 'asdf'}) --> 'name: asdf' + * Lib.templateString('name: %{trace[0].name}', {trace: [{name: 'asdf'}]}) --> 'name: asdf' + * Lib.templateString('price: %{y:$.2f}', {y: 1}) --> 'price: $1.00' + * + * @param {string} input string containing %{...:...} template strings + * @param {obj} data object containing fallback text when no formatting is specified, ex.: {yLabel: 'formattedYValue'} + * @param {obj} data objects containing substitution values + * + * @return {string} templated string + */ +lib.hovertemplateString = function(string, labels) { + var args = arguments; + // Not all that useful, but cache nestedProperty instantiation + // just in case it speeds things up *slightly*: + var getterCache = {}; + + return string.replace(TEMPLATE_STRING_REGEX, function(match, key, format) { + var obj, value, i; + for(i = 2; i < args.length; i++) { + obj = args[i]; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; + } + + if(value === undefined) { + if(numberOfHoverTemplateWarnings < maximumNumberOfHoverTemplateWarnings) { + lib.warn('Variable \'' + key + '\' in hovertemplate could not be found!'); + value = match; + } + + if(numberOfHoverTemplateWarnings === maximumNumberOfHoverTemplateWarnings) { + lib.warn('Too many hovertemplate warnings - additional warnings will be suppressed'); + } + numberOfHoverTemplateWarnings++; + } + + if(format) { + value = d3.format(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value); + } else { + if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + } + return value; + }); +}; + /* * alphanumeric string sort, tailored for subplot IDs like scene2, scene10, x10y13 etc */ @@ -36930,7 +37290,7 @@ lib.pseudoRandom = function() { return randSeed / 4294967296; }; -},{"../constants/numerical":143,"./angles":147,"./array":148,"./clean_number":149,"./clear_responsive":151,"./coerce":152,"./dates":153,"./extend":155,"./filter_unique":156,"./filter_visible":157,"./geometry2d":158,"./get_graph_div":159,"./identity":160,"./is_plain_object":162,"./keyed_container":163,"./localize":164,"./loggers":165,"./make_trace_groups":166,"./matrix":167,"./mod":168,"./nested_property":169,"./noop":170,"./notifier":171,"./push_unique":174,"./regex":176,"./relative_attr":177,"./relink_private":178,"./search":179,"./stats":181,"./throttle":183,"./to_log_range":184,"d3":8,"fast-isnumeric":10}],162:[function(_dereq_,module,exports){ +},{"../constants/numerical":140,"./anchor_utils":144,"./angles":145,"./array":146,"./clean_number":147,"./clear_responsive":149,"./coerce":150,"./dates":151,"./extend":153,"./filter_unique":154,"./filter_visible":155,"./geometry2d":156,"./get_graph_div":157,"./identity":158,"./is_plain_object":160,"./keyed_container":161,"./localize":162,"./loggers":163,"./make_trace_groups":164,"./matrix":165,"./mod":166,"./nested_property":167,"./noop":168,"./notifier":169,"./push_unique":172,"./regex":174,"./relative_attr":175,"./relink_private":176,"./search":177,"./stats":179,"./throttle":181,"./to_log_range":182,"d3":8,"fast-isnumeric":10}],160:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36959,7 +37319,7 @@ module.exports = function isPlainObject(obj) { ); }; -},{}],163:[function(_dereq_,module,exports){ +},{}],161:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37152,7 +37512,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":169}],164:[function(_dereq_,module,exports){ +},{"./nested_property":167}],162:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37208,7 +37568,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":245}],165:[function(_dereq_,module,exports){ +},{"../registry":243}],163:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37294,7 +37654,7 @@ function apply(f, args) { } } -},{"../plot_api/plot_config":193}],166:[function(_dereq_,module,exports){ +},{"../plot_api/plot_config":191}],164:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37331,7 +37691,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{}],167:[function(_dereq_,module,exports){ +},{}],165:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37441,7 +37801,7 @@ exports.apply2DTransform2 = function(transform) { }; }; -},{}],168:[function(_dereq_,module,exports){ +},{}],166:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37476,7 +37836,7 @@ module.exports = { modHalf: modHalf }; -},{}],169:[function(_dereq_,module,exports){ +},{}],167:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37723,7 +38083,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":148,"fast-isnumeric":10}],170:[function(_dereq_,module,exports){ +},{"./array":146,"fast-isnumeric":10}],168:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37739,7 +38099,7 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],171:[function(_dereq_,module,exports){ +},{}],169:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37821,7 +38181,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":8,"fast-isnumeric":10}],172:[function(_dereq_,module,exports){ +},{"d3":8,"fast-isnumeric":10}],170:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37870,7 +38230,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":180}],173:[function(_dereq_,module,exports){ +},{"./setcursor":178}],171:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38123,7 +38483,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":143,"./matrix":167}],174:[function(_dereq_,module,exports){ +},{"../constants/numerical":140,"./matrix":165}],172:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38163,7 +38523,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],175:[function(_dereq_,module,exports){ +},{}],173:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38374,7 +38734,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":161,"../plot_api/plot_config":193}],176:[function(_dereq_,module,exports){ +},{"../lib":159,"../plot_api/plot_config":191}],174:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38393,16 +38753,18 @@ module.exports = queue; * @param {Optional(string)} tail: a fixed piece after the id * eg counterRegex('scene', '.annotations') for scene2.annotations etc. * @param {boolean} openEnded: if true, the string may continue past the match. + * @param {boolean} matchBeginning: if false, the string may start before the match. */ -exports.counter = function(head, tail, openEnded) { +exports.counter = function(head, tail, openEnded, matchBeginning) { var fullTail = (tail || '') + (openEnded ? '' : '$'); + var startWithPrefix = matchBeginning === false ? '' : '^'; if(head === 'xy') { - return new RegExp('^x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + 'x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); } - return new RegExp('^' + head + '([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],177:[function(_dereq_,module,exports){ +},{}],175:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38455,7 +38817,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],178:[function(_dereq_,module,exports){ +},{}],176:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38518,7 +38880,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":148,"./is_plain_object":162}],179:[function(_dereq_,module,exports){ +},{"./array":146,"./is_plain_object":160}],177:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38706,7 +39068,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"./identity":160,"./loggers":165,"fast-isnumeric":10}],180:[function(_dereq_,module,exports){ +},{"./identity":158,"./loggers":163,"fast-isnumeric":10}],178:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38729,7 +39091,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],181:[function(_dereq_,module,exports){ +},{}],179:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38830,7 +39192,7 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":148,"fast-isnumeric":10}],182:[function(_dereq_,module,exports){ +},{"./array":146,"fast-isnumeric":10}],180:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39605,7 +39967,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":141,"../constants/xmlns_namespaces":144,"../lib":161,"d3":8}],183:[function(_dereq_,module,exports){ +},{"../constants/alignment":138,"../constants/xmlns_namespaces":141,"../lib":159,"d3":8}],181:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39709,7 +40071,7 @@ function _clearTimeout(cache) { } } -},{}],184:[function(_dereq_,module,exports){ +},{}],182:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39737,7 +40099,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":10}],185:[function(_dereq_,module,exports){ +},{"fast-isnumeric":10}],183:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39759,7 +40121,7 @@ module.exports = { } }; -},{}],186:[function(_dereq_,module,exports){ +},{}],184:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39802,7 +40164,7 @@ module.exports = { } }; -},{}],187:[function(_dereq_,module,exports){ +},{}],185:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39860,7 +40222,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":245}],188:[function(_dereq_,module,exports){ +},{"../registry":243}],186:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39986,7 +40348,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":161}],189:[function(_dereq_,module,exports){ +},{"../lib":159}],187:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40042,6 +40404,8 @@ exports.cleanLayout = function(layout) { } var axisAttrRegex = (Plots.subplotsRegistry.cartesian || {}).attrRegex; + var polarAttrRegex = (Plots.subplotsRegistry.polar || {}).attrRegex; + var ternaryAttrRegex = (Plots.subplotsRegistry.ternary || {}).attrRegex; var sceneAttrRegex = (Plots.subplotsRegistry.gl3d || {}).attrRegex; var keys = Object.keys(layout); @@ -40080,6 +40444,24 @@ exports.cleanLayout = function(layout) { } delete ax.autotick; } + + cleanTitle(ax); + } + + // modifications for polar + else if(polarAttrRegex && polarAttrRegex.test(key)) { + var polar = layout[key]; + + cleanTitle(polar.radialaxis); + } + + // modifications for ternary + else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + var ternary = layout[key]; + + cleanTitle(ternary.aaxis); + cleanTitle(ternary.baxis); + cleanTitle(ternary.caxis); } // modifications for 3D scenes @@ -40103,11 +40485,16 @@ exports.cleanLayout = function(layout) { scene.camera = { eye: {x: eye[0], y: eye[1], z: eye[2]}, center: {x: center[0], y: center[1], z: center[2]}, - up: {x: mat[1], y: mat[5], z: mat[9]} + up: {x: 0, y: 0, z: 1} // we just ignore calculating camera z up in this case }; delete scene.cameraposition; } + + // clean axis titles + cleanTitle(scene.xaxis); + cleanTitle(scene.yaxis); + cleanTitle(scene.zaxis); } } @@ -40165,6 +40552,9 @@ exports.cleanLayout = function(layout) { } } + // clean plot title + cleanTitle(layout); + /* * Moved from rotate -> orbit for dragmode */ @@ -40174,6 +40564,11 @@ exports.cleanLayout = function(layout) { // supported, but new tinycolor does not because they're not valid css Color.clean(layout); + // clean the layout container in layout.template + if(layout.template && layout.template.layout) { + exports.cleanLayout(layout.template.layout); + } + return layout; }; @@ -40185,6 +40580,46 @@ function cleanAxRef(container, attr) { } } +/** + * Cleans up old title attribute structure (flat) in favor of the new one (nested). + * + * @param {Object} titleContainer - an object potentially including deprecated title attributes + */ +function cleanTitle(titleContainer) { + if(titleContainer) { + + // title -> title.text + // (although title used to be a string attribute, + // numbers are accepted as well) + if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') { + titleContainer.title = { + text: titleContainer.title + }; + } + + rewireAttr('titlefont', 'font'); + rewireAttr('titleposition', 'position'); + rewireAttr('titleside', 'side'); + rewireAttr('titleoffset', 'offset'); + } + + function rewireAttr(oldAttrName, newAttrName) { + var oldAttrSet = titleContainer[oldAttrName]; + var newAttrSet = titleContainer.title && titleContainer.title[newAttrName]; + + if(oldAttrSet && !newAttrSet) { + + // Ensure title object exists + if(!titleContainer.title) { + titleContainer.title = {}; + } + + titleContainer.title[newAttrName] = titleContainer[oldAttrName]; + delete titleContainer[oldAttrName]; + } + } +} + /* * cleanData: Make a few changes to the data for backward compatibility * before it gets used for anything. Modifies the data traces users provide. @@ -40388,6 +40823,13 @@ exports.cleanData = function(data) { delete trace.autobiny; delete trace.ybins; } + + cleanTitle(trace); + if(trace.colorbar) cleanTitle(trace.colorbar); + if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar); + if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar); + if(trace.aaxis) cleanTitle(trace.aaxis); + if(trace.baxis) cleanTitle(trace.baxis); } }; @@ -40428,11 +40870,14 @@ function commonPrefix(name1, name2, show1, show2) { function cleanTextPosition(textposition) { var posY = 'middle', posX = 'center'; - if(textposition.indexOf('top') !== -1) posY = 'top'; - else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; - if(textposition.indexOf('left') !== -1) posX = 'left'; - else if(textposition.indexOf('right') !== -1) posX = 'right'; + if(typeof textposition === 'string') { + if(textposition.indexOf('top') !== -1) posY = 'top'; + else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; + + if(textposition.indexOf('left') !== -1) posX = 'left'; + else if(textposition.indexOf('right') !== -1) posX = 'right'; + } return posY + ' ' + posX; } @@ -40608,7 +41053,7 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":43,"../lib":161,"../plots/cartesian/axis_ids":208,"../plots/plots":238,"../registry":245,"fast-isnumeric":10,"gl-mat4/fromQuat":11}],190:[function(_dereq_,module,exports){ +},{"../components/color":43,"../lib":159,"../plots/cartesian/axis_ids":206,"../plots/plots":236,"../registry":243,"fast-isnumeric":10,"gl-mat4/fromQuat":11}],188:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40627,6 +41072,10 @@ exports.restyle = main.restyle; exports.relayout = main.relayout; exports.redraw = main.redraw; exports.update = main.update; +exports._guiRestyle = main._guiRestyle; +exports._guiRelayout = main._guiRelayout; +exports._guiUpdate = main._guiUpdate; +exports._storeDirectGUIEdit = main._storeDirectGUIEdit; exports.react = main.react; exports.extendTraces = main.extendTraces; exports.prependTraces = main.prependTraces; @@ -40647,7 +41096,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":247,"./plot_api":192,"./template_api":197,"./to_image":198,"./validate":199}],191:[function(_dereq_,module,exports){ +},{"../snapshot/download":245,"./plot_api":190,"./template_api":195,"./to_image":196,"./validate":197}],189:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40659,7 +41108,6 @@ exports.validateTemplate = templateApi.validateTemplate; 'use strict'; -var nestedProperty = _dereq_('../lib/nested_property'); var isPlainObject = _dereq_('../lib/is_plain_object'); var noop = _dereq_('../lib/noop'); var Loggers = _dereq_('../lib/loggers'); @@ -40716,11 +41164,15 @@ var isRemoveVal = exports.isRemoveVal = function isRemoveVal(val) { * the flags for which actions we're going to perform to display these (and * any other) changes. If we're already `recalc`ing, we don't need to redraw * individual items + * @param {function} _nestedProperty + * a (possibly modified for gui edits) nestedProperty constructor + * The modified version takes a 3rd argument, for a prefix to the attribute + * string necessary for storing GUI edits * * @returns {bool} `true` if it managed to complete drawing of the changes * `false` would mean the parent should replot. */ -exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags) { +exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags, _nestedProperty) { var componentType = np.astr, supplyComponentDefaults = Registry.getComponentMethod(componentType, 'supplyLayoutDefaults'), draw = Registry.getComponentMethod(componentType, 'draw'), @@ -40760,7 +41212,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, // redoing supplyDefaults // TODO: this assumes componentArray is in gd.layout - which will not be // true after we extend this to restyle - componentArrayFull = nestedProperty(fullLayout, componentType).get(); + componentArrayFull = _nestedProperty(fullLayout, componentType).get(); var deletes = [], firstIndexChange = -1, @@ -40771,7 +41223,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, objEdits, objKeys, objVal, - adding; + adding, prefix; // first make the add and edit changes for(i = 0; i < componentNums.length; i++) { @@ -40810,7 +41262,9 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, } else { for(j = 0; j < objKeys.length; j++) { - nestedProperty(componentArray[componentNum], objKeys[j]).set(objEdits[objKeys[j]]); + prefix = componentType + '[' + componentNum + '].'; + _nestedProperty(componentArray[componentNum], objKeys[j], prefix) + .set(objEdits[objKeys[j]]); } } } @@ -40861,7 +41315,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":162,"../lib/loggers":165,"../lib/nested_property":169,"../lib/noop":170,"../lib/search":179,"../registry":245,"./container_array_match":187}],192:[function(_dereq_,module,exports){ +},{"../lib/is_plain_object":160,"../lib/loggers":163,"../lib/noop":168,"../lib/search":177,"../registry":243,"./container_array_match":185}],190:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40879,6 +41333,8 @@ var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); var Lib = _dereq_('../lib'); +var nestedProperty = Lib.nestedProperty; + var Events = _dereq_('../lib/events'); var Queue = _dereq_('../lib/queue'); @@ -40974,9 +41430,6 @@ exports.plot = function(gd, data, layout, config) { // so we can share cached text across tabs Drawing.makeTester(); - // clear stashed base url - delete Drawing.baseUrl; - // collect promises for any async actions during plotting // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all @@ -41021,7 +41474,7 @@ exports.plot = function(gd, data, layout, config) { // Legacy polar plots if(!fullLayout._has('polar') && data && data[0] && data[0].r) { Lib.log('Legacy polar charts are deprecated!'); - return plotPolar(gd, data, layout); + return plotLegacyPolar(gd, data, layout); } // so we don't try to re-call Plotly.plot from inside @@ -41197,8 +41650,7 @@ exports.plot = function(gd, data, layout, config) { return Lib.syncOrAsync([ Registry.getComponentMethod('shapes', 'calcAutorange'), Registry.getComponentMethod('annotations', 'calcAutorange'), - doAutoRangeAndConstraints, - Registry.getComponentMethod('rangeslider', 'calcAutorange') + doAutoRangeAndConstraints ], gd); } @@ -41210,11 +41662,16 @@ exports.plot = function(gd, data, layout, config) { // store initial ranges *after* enforcing constraints, otherwise // we will never look like we're at the initial ranges if(graphWasEmpty) Axes.saveRangeInitial(gd); + + // this one is different from shapes/annotations calcAutorange + // the others incorporate those components into ax._extremes, + // this one actually sets the ranges in rangesliders. + Registry.getComponentMethod('rangeslider', 'calcAutorange')(gd); } // draw ticks, titles, and calculate axis scaling (._b, ._m) function drawAxes() { - return Axes.doTicks(gd, graphWasEmpty ? '' : 'redraw'); + return Axes.draw(gd, graphWasEmpty ? '' : 'redraw'); } var seq = [ @@ -41283,7 +41740,16 @@ function opaqueSetBackground(gd, bgColor) { } function setPlotContext(gd, config) { - if(!gd._context) gd._context = Lib.extendDeep({}, defaultConfig); + if(!gd._context) { + gd._context = Lib.extendDeep({}, defaultConfig); + + // stash href, used to make robust clipPath URLs + var base = d3.select('base'); + gd._context._baseUrl = base.size() && base.attr('href') ? + window.location.href.split('#')[0] : + ''; + } + var context = gd._context; var i, keys, key; @@ -41329,6 +41795,9 @@ function setPlotContext(gd, config) { } } } + + // not part of the user-facing config options + context._exportedPlot = config._exportedPlot; } // staticPlot forces a bunch of others: @@ -41358,7 +41827,7 @@ function setPlotContext(gd, config) { context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0; } -function plotPolar(gd, data, layout) { +function plotLegacyPolar(gd, data, layout) { // build or reuse the container skeleton var plotContainer = d3.select(gd).selectAll('.plot-container') .data([0]); @@ -41399,7 +41868,7 @@ function plotPolar(gd, data, layout) { // editable title var opacity = 1; - var txt = gd._fullLayout.title; + var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; if(txt === '' || !txt) opacity = 0; var titleLayout = function() { @@ -41433,7 +41902,7 @@ function plotPolar(gd, data, layout) { var setContenteditable = function() { this.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { - gd.framework({layout: {title: text}}); + gd.framework({layout: {title: {text: text}}}); this.text(text) .call(titleLayout); this.call(setContenteditable); @@ -41706,7 +42175,7 @@ function getExtendProperties(gd, update, indices, maxPoints) { * instance that references the key and value for this particular trace. */ trace = gd.data[indices[j]]; - prop = Lib.nestedProperty(trace, key); + prop = nestedProperty(trace, key); /* * Target is the existing gd.data.trace.dataArray value like "x" or "marker.size" @@ -42177,7 +42646,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) { * If the array is too short, it will wrap around (useful for * style files that want to specify cyclical default values). */ -exports.restyle = function restyle(gd, astr, val, _traces) { +function restyle(gd, astr, val, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -42247,7 +42716,8 @@ exports.restyle = function restyle(gd, astr, val, _traces) { gd.emit('plotly_restyle', specs.eventData); return gd; }); -}; +} +exports.restyle = restyle; // for undo: undefined initial vals must be turned into nulls // so that we unset rather than ignore them @@ -42256,11 +42726,77 @@ function undefinedToNull(val) { return val; } +/** + * Factory function to wrap nestedProperty with GUI edits if necessary + * with GUI edits we add an optional prefix to the nestedProperty constructor + * to prepend to the attribute string in the preGUI store. + */ +function makeNP(preGUI, guiEditFlag) { + if(!guiEditFlag) return nestedProperty; + + return function(container, attr, prefix) { + var np = nestedProperty(container, attr); + var npSet = np.set; + np.set = function(val) { + var fullAttr = (prefix || '') + attr; + storeCurrent(fullAttr, np.get(), val, preGUI); + npSet(val); + }; + return np; + }; +} + +function storeCurrent(attr, val, newVal, preGUI) { + if(Array.isArray(val) || Array.isArray(newVal)) { + var arrayVal = Array.isArray(val) ? val : []; + var arrayNew = Array.isArray(newVal) ? newVal : []; + var maxLen = Math.max(arrayVal.length, arrayNew.length); + for(var i = 0; i < maxLen; i++) { + storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); + } + } + else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + var objVal = Lib.isPlainObject(val) ? val : {}; + var objNew = Lib.isPlainObject(newVal) ? newVal : {}; + var objBoth = Lib.extendFlat({}, objVal, objNew); + for(var key in objBoth) { + storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); + } + } + else if(preGUI[attr] === undefined) { + preGUI[attr] = undefinedToNull(val); + } +} + +/** + * storeDirectGUIEdit: for routines that skip restyle/relayout and mock it + * by emitting a plotly_restyle or plotly_relayout event, this routine + * keeps track of the initial state in _preGUI for use by uirevision + * Does *not* apply these changes to data/layout - that's the responsibility + * of the calling routine. + * + * @param {object} container: the input attributes container (eg `layout` or a `trace`) + * @param {object} preGUI: where original values should be stored, either + * `layout._preGUI` or `layout._tracePreGUI[uid]` + * @param {object} edits: the {attr: val} object as normally passed to `relayout` etc + */ +exports._storeDirectGUIEdit = function(container, preGUI, edits) { + for(var attr in edits) { + var np = nestedProperty(container, attr); + storeCurrent(attr, np.get(), edits[attr], preGUI); + } +}; + function _restyle(gd, aobj, traces) { - var fullLayout = gd._fullLayout, - fullData = gd._fullData, - data = gd.data, - i; + var fullLayout = gd._fullLayout; + var fullData = gd._fullData; + var data = gd.data; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var eventData = Lib.extendDeepAll({}, aobj); + var i; + + cleanDeprecatedAttributeKeys(aobj); // initialize flags var flags = editTypes.traceFlags(); @@ -42284,6 +42820,16 @@ function _restyle(gd, aobj, traces) { function rangeAttr(axName) { return 'LAYOUT' + axName + '.range'; } + function getFullTrace(traceIndex) { + // usually fullData maps 1:1 onto data, but with groupby transforms + // the fullData index can be greater. Take the *first* matching trace. + for(var j = traceIndex; j < fullData.length; j++) { + if(fullData[j]._input === data[traceIndex]) return fullData[j]; + } + // should never get here - and if we *do* it should cause an error + // later on undefined fullTrace is passed to nestedProperty. + } + // for attrs that interact (like scales & autoscales), save the // old vals before making the change // val=undefined will not set a value, just record what the value was. @@ -42299,9 +42845,11 @@ function _restyle(gd, aobj, traces) { var extraparam; if(attr.substr(0, 6) === 'LAYOUT') { - extraparam = Lib.nestedProperty(gd.layout, attr.replace('LAYOUT', '')); + extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', '')); } else { - extraparam = Lib.nestedProperty(data[traces[i]], attr); + var tracei = traces[i]; + var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid]; + extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr); } if(!(attr in undoit)) { @@ -42356,7 +42904,7 @@ function _restyle(gd, aobj, traces) { redoit[ai] = vi; if(ai.substr(0, 6) === 'LAYOUT') { - param = Lib.nestedProperty(gd.layout, ai.replace('LAYOUT', '')); + param = layoutNP(gd.layout, ai.replace('LAYOUT', '')); undoit[ai] = [undefinedToNull(param.get())]; // since we're allowing val to be an array, allow it here too, // even though that's meaningless @@ -42371,8 +42919,9 @@ function _restyle(gd, aobj, traces) { undoit[ai] = a0(); for(i = 0; i < traces.length; i++) { cont = data[traces[i]]; - contFull = fullData[traces[i]]; - param = Lib.nestedProperty(cont, ai); + contFull = getFullTrace(traces[i]); + var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid]; + param = makeNP(preGUI, guiEditFlag)(cont, ai); oldVal = param.get(); newVal = Array.isArray(vi) ? vi[i % vi.length] : vi; @@ -42382,7 +42931,7 @@ function _restyle(gd, aobj, traces) { var prefix = ai.substr(0, ai.length - finalPart.length - 1); var prefixDot = prefix ? prefix + '.' : ''; var innerContFull = prefix ? - Lib.nestedProperty(contFull, prefix).get() : contFull; + nestedProperty(contFull, prefix).get() : contFull; valObject = PlotSchema.getTraceValObject(contFull, param.parts); @@ -42429,14 +42978,14 @@ function _restyle(gd, aobj, traces) { Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo); if(oldVal === 'pie') { - Lib.nestedProperty(cont, 'marker.color') - .set(Lib.nestedProperty(cont, 'marker.colors').get()); + nestedProperty(cont, 'marker.color') + .set(nestedProperty(cont, 'marker.colors').get()); // super kludgy - but if all pies are gone we won't remove them otherwise fullLayout._pielayer.selectAll('g.trace').remove(); } else if(Registry.traceIs(cont, 'cartesian')) { - Lib.nestedProperty(cont, 'marker.colors') - .set(Lib.nestedProperty(cont, 'marker.color').get()); + nestedProperty(cont, 'marker.colors') + .set(nestedProperty(cont, 'marker.color').get()); } } @@ -42507,7 +43056,7 @@ function _restyle(gd, aobj, traces) { // swap hovermode if set to "compare x/y data" if(ai === 'orientationaxes') { - var hovermode = Lib.nestedProperty(gd.layout, 'hovermode'); + var hovermode = nestedProperty(gd.layout, 'hovermode'); if(hovermode.get() === 'x') { hovermode.set('y'); } else if(hovermode.get() === 'y') { @@ -42546,10 +43095,53 @@ function _restyle(gd, aobj, traces) { undoit: undoit, redoit: redoit, traces: traces, - eventData: Lib.extendDeepNoArrays([], [redoit, traces]) + eventData: Lib.extendDeepNoArrays([], [eventData, traces]) }; } +/** + * Converts deprecated attribute keys to + * the current API to ensure backwards compatibility. + * + * This is needed for the update mechanism to determine which + * subroutines to run based on the actual attribute + * definitions (that don't include the deprecated ones). + * + * E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'} + * and {titlefont: {...}} to {'title.font': {...}}. + * + * @param aobj + */ +function cleanDeprecatedAttributeKeys(aobj) { + var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false); + var colorbarRegex = /colorbar\.title$/; + var keys = Object.keys(aobj); + var i, key, value; + + for(i = 0; i < keys.length; i++) { + key = keys[i]; + value = aobj[key]; + + if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) && + (typeof value === 'string' || typeof value === 'number')) { + replace(key, key.replace('title', 'title.text')); + } else if(key.indexOf('titlefont') > -1) { + replace(key, key.replace('titlefont', 'title.font')); + } else if(key.indexOf('titleposition') > -1) { + replace(key, key.replace('titleposition', 'title.position')); + } else if(key.indexOf('titleside') > -1) { + replace(key, key.replace('titleside', 'title.side')); + } else if(key.indexOf('titleoffset') > -1) { + replace(key, key.replace('titleoffset', 'title.offset')); + } + } + + function replace(oldAttrStr, newAttrStr) { + aobj[newAttrStr] = aobj[oldAttrStr]; + delete aobj[oldAttrStr]; + } +} + /** * relayout: update layout attributes of an existing plot * @@ -42570,7 +43162,7 @@ function _restyle(gd, aobj, traces) { * attribute object `{astr1: val1, astr2: val2 ...}` * allows setting multiple attributes simultaneously */ -exports.relayout = function relayout(gd, astr, val) { +function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -42633,7 +43225,8 @@ exports.relayout = function relayout(gd, astr, val) { gd.emit('plotly_relayout', specs.eventData); return gd; }); -}; +} +exports.relayout = relayout; // Optimization mostly for large splom traces where // Plots.supplyDefaults can take > 100ms @@ -42661,13 +43254,24 @@ function addAxRangeSequence(seq, rangesAltered) { // N.B. leave as sequence of subroutines (for now) instead of // subroutine of its own so that finalDraw always gets // executed after drawData - var doTicks = rangesAltered ? - function(gd) { return Axes.doTicks(gd, Object.keys(rangesAltered), true); } : - function(gd) { return Axes.doTicks(gd, 'redraw'); }; + var drawAxes = rangesAltered ? + function(gd) { + var opts = {skipTitle: true}; + for(var id in rangesAltered) { + if(Axes.getFromId(gd, id).automargin) { + opts = {}; + break; + } + } + return Axes.draw(gd, Object.keys(rangesAltered), opts); + } : + function(gd) { + return Axes.draw(gd, 'redraw'); + }; seq.push( subroutines.doAutoRangeAndConstraints, - doTicks, + drawAxes, subroutines.drawData, subroutines.finalDraw ); @@ -42678,14 +43282,19 @@ var AX_AUTORANGE_RE = /^[xyz]axis[0-9]*\.autorange$/; var AX_DOMAIN_RE = /^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/; function _relayout(gd, aobj) { - var layout = gd.layout, - fullLayout = gd._fullLayout, - keys = Object.keys(aobj), - axes = Axes.list(gd), - arrayEdits = {}, - arrayStr, - i, - j; + var layout = gd.layout; + var fullLayout = gd._fullLayout; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var keys = Object.keys(aobj); + var axes = Axes.list(gd); + var eventData = Lib.extendDeepAll({}, aobj); + var arrayEdits = {}; + + var arrayStr, i, j; + + cleanDeprecatedAttributeKeys(aobj); + keys = Object.keys(aobj); // look for 'allaxes', split out into all axes // in case of 3D the axis are nested within a scene which is held in _id @@ -42725,7 +43334,7 @@ function _relayout(gd, aobj) { // via a parent) do not override with this auto-generated extra if(attr in aobj || helpers.hasParent(aobj, attr)) return; - var p = Lib.nestedProperty(layout, attr); + var p = layoutNP(layout, attr); if(!(attr in undoit)) { undoit[attr] = undefinedToNull(p.get()); } @@ -42750,7 +43359,7 @@ function _relayout(gd, aobj) { throw new Error('cannot set ' + ai + 'and a parent attribute simultaneously'); } - var p = Lib.nestedProperty(layout, ai); + var p = layoutNP(layout, ai); var vi = aobj[ai]; var plen = p.parts.length; // p.parts may end with an index integer if the property is an array @@ -42762,8 +43371,8 @@ function _relayout(gd, aobj) { var pleafPlus = p.parts[pend - 1] + '.' + pleaf; // trunk nodes (everything except the leaf) var ptrunk = p.parts.slice(0, pend).join('.'); - var parentIn = Lib.nestedProperty(gd.layout, ptrunk).get(); - var parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + var parentIn = nestedProperty(gd.layout, ptrunk).get(); + var parentFull = nestedProperty(fullLayout, ptrunk).get(); var vOld = p.get(); if(vi === undefined) continue; @@ -42808,12 +43417,12 @@ function _relayout(gd, aobj) { // check autorange vs range else if(pleafPlus.match(AX_RANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - var axFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + var axFull = nestedProperty(fullLayout, ptrunk).get(); if(axFull._inputDomain) { // if we're autoranging and this axis has a constrained domain, // reset it so we don't get locked into a shrunken size @@ -42821,7 +43430,7 @@ function _relayout(gd, aobj) { } } else if(pleafPlus.match(AX_DOMAIN_RE)) { - Lib.nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); + nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } // toggling axis type between log and linear: we need to convert @@ -42890,10 +43499,10 @@ function _relayout(gd, aobj) { doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleaf.match(AX_NAME_PATTERN)) { - var fullProp = Lib.nestedProperty(fullLayout, ai).get(), + var fullProp = nestedProperty(fullLayout, ai).get(), newType = (vi || {}).type; // This can potentially cause strange behavior if the autotype is not @@ -42915,8 +43524,6 @@ function _relayout(gd, aobj) { arrayStr = containerArrayMatch.array; i = containerArrayMatch.index; var propStr = containerArrayMatch.property; - var componentArray = Lib.nestedProperty(layout, arrayStr); - var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; if(i !== '' && propStr === '') { @@ -42926,7 +43533,7 @@ function _relayout(gd, aobj) { if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { - undoit[ai] = obji; + undoit[ai] = (nestedProperty(layout, arrayStr).get() || [])[i]; } else { Lib.warn('unrecognized full object value', aobj); } @@ -42970,7 +43577,7 @@ function _relayout(gd, aobj) { // now we've collected component edits - execute them all together for(arrayStr in arrayEdits) { var finished = manageArrays.applyContainerArrayChanges(gd, - Lib.nestedProperty(layout, arrayStr), arrayEdits[arrayStr], flags); + layoutNP(layout, arrayStr), arrayEdits[arrayStr], flags, layoutNP); if(!finished) flags.plot = true; } @@ -43013,7 +43620,7 @@ function _relayout(gd, aobj) { rangesAltered: rangesAltered, undoit: undoit, redoit: redoit, - eventData: Lib.extendDeep({}, redoit) + eventData: eventData }; } @@ -43048,7 +43655,7 @@ function updateAutosize(gd) { * integer or array of integers for the traces to alter (all if omitted) * */ -exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { +function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -43128,7 +43735,235 @@ exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { return gd; }); -}; +} +exports.update = update; + +/* + * internal-use-only restyle/relayout/update variants that record the initial + * values in (fullLayout|fullTrace)._preGUI so changes can be persisted across + * Plotly.react data updates, dependent on uirevision attributes + */ +function guiEdit(func) { + return function wrappedEdit(gd) { + gd._fullLayout._guiEditing = true; + var p = func.apply(null, arguments); + gd._fullLayout._guiEditing = false; + return p; + }; +} +exports._guiRestyle = guiEdit(restyle); +exports._guiRelayout = guiEdit(relayout); +exports._guiUpdate = guiEdit(update); + +// For connecting edited layout attributes to uirevision attrs +// If no `attr` we use `match[1] + '.uirevision'` +// Ordered by most common edits first, to minimize our search time +var layoutUIControlPatterns = [ + {pattern: /^hiddenlabels/, attr: 'legend.uirevision'}, + {pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/}, + + // showspikes and modes include those nested inside scenes + {pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'}, + {pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'}, + + {pattern: /^(scene\d*)\.camera/}, + {pattern: /^(geo\d*)\.(projection|center)/}, + {pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/}, + {pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/}, + {pattern: /^(polar\d*\.angularaxis)\.rotation/}, + {pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/}, + + {pattern: /^legend\.(x|y)$/, attr: 'editrevision'}, + {pattern: /^(shapes|annotations)/, attr: 'editrevision'}, + {pattern: /^title\.text$/, attr: 'editrevision'} +]; + +// same for trace attributes: if `attr` is given it's in layout, +// or with no `attr` we use `trace.uirevision` +var traceUIControlPatterns = [ + {pattern: /^selectedpoints$/, attr: 'selectionrevision'}, + // "visible" includes trace.transforms[i].styles[j].value.visible + {pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'}, + {pattern: /^dimensions\[\d+\]\.constraintrange/}, + + // below this you must be in editable: true mode + // TODO: I still put name and title with `trace.uirevision` + // reasonable or should these be `editrevision`? + // Also applies to axis titles up in the layout section + + // "name" also includes transform.styles + {pattern: /(^|value\.)name$/}, + // including nested colorbar attributes (ie marker.colorbar) + {pattern: /colorbar\.title\.text$/}, + {pattern: /colorbar\.(x|y)$/, attr: 'editrevision'} +]; + +function findUIPattern(key, patternSpecs) { + for(var i = 0; i < patternSpecs.length; i++) { + var spec = patternSpecs[i]; + var match = key.match(spec.pattern); + if(match) { + return {head: match[1], attr: spec.attr}; + } + } +} + +// We're finding the new uirevision before supplyDefaults, so do the +// inheritance manually. Note that only `undefined` inherits - other +// falsy values are returned. +function getNewRev(revAttr, container) { + var newRev = nestedProperty(container, revAttr).get(); + if(newRev !== undefined) return newRev; + + var parts = revAttr.split('.'); + parts.pop(); + while(parts.length > 1) { + parts.pop(); + newRev = nestedProperty(container, parts.join('.') + '.uirevision').get(); + if(newRev !== undefined) return newRev; + } + + return container.uirevision; +} + +function getFullTraceIndexFromUid(uid, fullData) { + for(var i = 0; i < fullData.length; i++) { + if(fullData[i]._fullInput.uid === uid) return i; + } + return -1; +} + +function getTraceIndexFromUid(uid, data, tracei) { + for(var i = 0; i < data.length; i++) { + if(data[i].uid === uid) return i; + } + // fall back on trace order, but only if user didn't provide a uid for that trace + return data[tracei].uid ? -1 : tracei; +} + +function valsMatch(v1, v2) { + var v1IsObj = Lib.isPlainObject(v1); + var v1IsArray = Array.isArray(v1); + if(v1IsObj || v1IsArray) { + return ( + (v1IsObj && Lib.isPlainObject(v2)) || + (v1IsArray && Array.isArray(v2)) + ) && JSON.stringify(v1) === JSON.stringify(v2); + } + return v1 === v2; +} + +function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { + var layoutPreGUI = oldFullLayout._preGUI; + var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal; + var bothInheritAutorange = []; + var newRangeAccepted = {}; + for(key in layoutPreGUI) { + match = findUIPattern(key, layoutUIControlPatterns); + if(match) { + revAttr = match.attr || (match.head + '.uirevision'); + oldRev = nestedProperty(oldFullLayout, revAttr).get(); + newRev = oldRev && getNewRev(revAttr, layout); + if(newRev && (newRev === oldRev)) { + preGUIVal = layoutPreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(layout, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + if(newVal === undefined && key.substr(key.length - 9) === 'autorange') { + bothInheritAutorange.push(key.substr(0, key.length - 10)); + } + newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key); + } + // if we got this far, the new value was accepted as the new starting + // point (either because it changed or revision changed) + // so remove it from _preGUI for next time. + delete layoutPreGUI[key]; + + if(key.substr(key.length - 8, 6) === 'range[') { + newRangeAccepted[key.substr(0, key.length - 9)] = 1; + } + } + + // Special logic for `autorange`, since it interacts with `range`: + // If the new figure's matching `range` was kept, and `autorange` + // wasn't supplied explicitly in either the original or the new figure, + // we shouldn't alter that - but we may just have done that, so fix it. + for(var i = 0; i < bothInheritAutorange.length; i++) { + var axAttr = bothInheritAutorange[i]; + if(newRangeAccepted[axAttr]) { + var newAx = nestedProperty(layout, axAttr).get(); + if(newAx) delete newAx.autorange; + } + } + + // Now traces - try to match them up by uid (in case we added/deleted in + // the middle), then fall back on index. + var allTracePreGUI = oldFullLayout._tracePreGUI; + for(var uid in allTracePreGUI) { + var tracePreGUI = allTracePreGUI[uid]; + var newTrace = null; + var fullInput; + for(key in tracePreGUI) { + // wait until we know we have preGUI values to look for traces + // but if we don't find both, stop looking at this uid + if(!newTrace) { + var fulli = getFullTraceIndexFromUid(uid, oldFullData); + if(fulli < 0) { + // Somehow we didn't even have this trace in oldFullData... + // I guess this could happen with `deleteTraces` or something + delete allTracePreGUI[uid]; + break; + } + var fullTrace = oldFullData[fulli]; + fullInput = fullTrace._fullInput; + + var newTracei = getTraceIndexFromUid(uid, data, fullInput.index); + if(newTracei < 0) { + // No match in new data + delete allTracePreGUI[uid]; + break; + } + newTrace = data[newTracei]; + } + + match = findUIPattern(key, traceUIControlPatterns); + if(match) { + if(match.attr) { + oldRev = nestedProperty(oldFullLayout, match.attr).get(); + newRev = oldRev && getNewRev(match.attr, layout); + } + else { + oldRev = fullInput.uirevision; + // inheritance for trace.uirevision is simple, just layout.uirevision + newRev = newTrace.uirevision; + if(newRev === undefined) newRev = layout.uirevision; + } + + if(newRev && newRev === oldRev) { + preGUIVal = tracePreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(newTrace, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + newNP.set(undefinedToNull(nestedProperty(fullInput, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); + } + delete tracePreGUI[key]; + } + } +} /** * Plotly.react: @@ -43192,6 +44027,8 @@ exports.react = function(gd, data, layout, config) { gd.layout = layout || {}; helpers.cleanLayout(gd.layout); + applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout); + // "true" skips updating calcdata and remapping arrays from calcTransforms, // which supplyDefaults usually does at the end, but we may need to NOT do // if the diff (which we haven't determined yet) says we'll recalc @@ -44246,7 +45083,7 @@ function makePlotFramework(gd) { gd.emit('plotly_framework'); } -},{"../components/color":43,"../components/colorbar/connect":45,"../components/drawing":68,"../constants/xmlns_namespaces":144,"../lib":161,"../lib/events":154,"../lib/queue":175,"../lib/svg_text_utils":182,"../plots/cartesian/axes":205,"../plots/cartesian/constants":211,"../plots/cartesian/graph_interact":215,"../plots/plots":238,"../plots/polar/legacy":241,"../registry":245,"./edit_types":188,"./helpers":189,"./manage_arrays":191,"./plot_config":193,"./plot_schema":194,"./subroutines":196,"d3":8,"fast-isnumeric":10,"has-hover":12}],193:[function(_dereq_,module,exports){ +},{"../components/color":43,"../components/colorbar/connect":45,"../components/drawing":64,"../constants/xmlns_namespaces":141,"../lib":159,"../lib/events":152,"../lib/queue":173,"../lib/svg_text_utils":180,"../plots/cartesian/axes":203,"../plots/cartesian/constants":209,"../plots/cartesian/graph_interact":213,"../plots/plots":236,"../plots/polar/legacy":239,"../registry":243,"./edit_types":186,"./helpers":187,"./manage_arrays":189,"./plot_config":191,"./plot_schema":192,"./subroutines":194,"d3":8,"fast-isnumeric":10,"has-hover":12}],191:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -44339,12 +45176,34 @@ module.exports = { */ showAxisRangeEntryBoxes: true, - // link to open this plot in plotly + /* + * Add a text link to open this plot in plotly? + * This link shows up in the bottom right corner of the plot, and works + * identically to the newer ModeBar button controlled by `showSendToCloud` + * unless `sendData: false` is used. + */ showLink: false, - // if we show a link, does it contain data or just link to a plotly file? + /* + * If we show a text link (`showLink: true`), does it contain data or just + * a reference to a plotly cloud file? This option should only be used on + * plot.ly or another plotly server, and is not supported by the newer + * ModeBar button `showSendToCloud`. + */ sendData: true, + /* + * Should we include a ModeBar button, labeled "Edit in Chart Studio", + * that sends this chart to plot.ly or another plotly server as specified + * by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0 + * this button was included by default, now it is opt-in using this flag. + * + * Note that this button can (depending on `plotlyServerURL`) send your data + * to an external server. However that server doesn't persist your data + * until you arrive at the Chart Studio and explicitly click "Save". + */ + showSendToCloud: false, + // text appearing in the sendData link linkText: 'Edit chart', @@ -44382,6 +45241,9 @@ module.exports = { // add the plotly logo on the end of the mode bar displaylogo: true, + // watermark the images with the company's logo + watermark: false, + // increase the pixel ratio for Gl plot images plotGlPixelRatio: 2, @@ -44448,7 +45310,7 @@ module.exports = { locales: {} }; -},{}],194:[function(_dereq_,module,exports){ +},{}],192:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45134,7 +45996,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":161,"../plots/animation_attributes":200,"../plots/attributes":202,"../plots/frame_attributes":233,"../plots/layout_attributes":236,"../plots/polar/legacy/area_attributes":239,"../plots/polar/legacy/axis_attributes":240,"../registry":245,"./edit_types":188}],195:[function(_dereq_,module,exports){ +},{"../lib":159,"../plots/animation_attributes":198,"../plots/attributes":200,"../plots/frame_attributes":231,"../plots/layout_attributes":234,"../plots/polar/legacy/area_attributes":237,"../plots/polar/legacy/axis_attributes":238,"../registry":243,"./edit_types":186}],193:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45448,7 +46310,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":161,"../plots/attributes":202}],196:[function(_dereq_,module,exports){ +},{"../lib":159,"../plots/attributes":200}],194:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45478,6 +46340,10 @@ var enforceAxisConstraints = axisConstraints.enforce; var cleanAxisConstraints = axisConstraints.clean; var doAutoRange = _dereq_('../plots/cartesian/autorange').doAutoRange; +var SVG_TEXT_ANCHOR_START = 'start'; +var SVG_TEXT_ANCHOR_MIDDLE = 'middle'; +var SVG_TEXT_ANCHOR_END = 'end'; + exports.layoutStyles = function(gd) { return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd); }; @@ -45502,7 +46368,7 @@ function lsInner(gd) { var gs = fullLayout._size; var pad = gs.p; var axList = Axes.list(gd, '', true); - var i, subplot, plotinfo, xa, ya; + var i, subplot, plotinfo, ax, xa, ya; fullLayout._paperdiv.style({ width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px', @@ -45538,10 +46404,7 @@ function lsInner(gd) { // some preparation of axis position info for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - - // reset scale in case the margins have changed - ax.setScale(); + ax = axList[i]; var counterAx = ax._anchorAxis; @@ -45560,11 +46423,6 @@ function lsInner(gd) { ax._mainMirrorPosition = (ax.mirror && counterAx) ? getLinePosition(ax, counterAx, alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; - - // Figure out which subplot to draw ticks, labels, & axis lines on - // do this as a separate loop so we already have all the - // _mainAxis and _anchorAxis links set - ax._mainSubplot = findMainSubplot(ax, fullLayout); } // figure out which backgrounds we need to draw, @@ -45675,7 +46533,7 @@ function lsInner(gd) { layerClipId = null; } - Drawing.setClipUrl(plotinfo.plot, plotClipId); + Drawing.setClipUrl(plotinfo.plot, plotClipId, gd); // stash layer clipId value (null or same as clipId) // to DRY up Drawing.setClipUrl calls on trace-module and trace layers @@ -45805,48 +46663,6 @@ function lsInner(gd) { return gd._promises.length && Promise.all(gd._promises); } -function findMainSubplot(ax, fullLayout) { - var subplotList = fullLayout._subplots; - var ids = subplotList.cartesian.concat(subplotList.gl2d || []); - var mockGd = {_fullLayout: fullLayout}; - - var isX = ax._id.charAt(0) === 'x'; - var anchorAx = ax._mainAxis._anchorAxis; - var mainSubplotID = ''; - var nextBestMainSubplotID = ''; - var anchorID = ''; - - // First try the main ID with the anchor - if(anchorAx) { - anchorID = anchorAx._mainAxis._id; - mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); - } - - // Then look for a subplot with the counteraxis overlaying the anchor - // If that fails just use the first subplot including this axis - if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { - mainSubplotID = ''; - - for(var j = 0; j < ids.length; j++) { - var id = ids[j]; - var yIndex = id.indexOf('y'); - var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); - var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); - - if(idPart === ax._id) { - if(!nextBestMainSubplotID) nextBestMainSubplotID = id; - var counterAx = Axes.getFromId(mockGd, counterPart); - if(anchorID && counterAx.overlaying === anchorID) { - mainSubplotID = id; - break; - } - } - } - } - - return mainSubplotID || nextBestMainSubplotID; -} - function shouldShowLinesOrTicks(ax, subplot) { return (ax.ticks || ax.showline) && (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); @@ -45901,18 +46717,92 @@ function findCounterAxisLineWidth(ax, side, counterAx, axList) { exports.drawMainTitle = function(gd) { var fullLayout = gd._fullLayout; + var textAnchor = getMainTitleTextAnchor(fullLayout); + var dy = getMainTitleDy(fullLayout); + Titles.draw(gd, 'gtitle', { propContainer: fullLayout, - propName: 'title', + propName: 'title.text', placeholder: fullLayout._dfltTitle.plot, attributes: { - x: fullLayout.width / 2, - y: fullLayout._size.t / 2, - 'text-anchor': 'middle' + x: getMainTitleX(fullLayout, textAnchor), + y: getMainTitleY(fullLayout, dy), + 'text-anchor': textAnchor, + dy: dy } }); }; +function getMainTitleX(fullLayout, textAnchor) { + var title = fullLayout.title; + var gs = fullLayout._size; + var hPadShift = 0; + + if(textAnchor === SVG_TEXT_ANCHOR_START) { + hPadShift = title.pad.l; + } else if(textAnchor === SVG_TEXT_ANCHOR_END) { + hPadShift = -title.pad.r; + } + + switch(title.xref) { + case 'paper': + return gs.l + gs.w * title.x + hPadShift; + case 'container': + default: + return fullLayout.width * title.x + hPadShift; + } +} + +function getMainTitleY(fullLayout, dy) { + var title = fullLayout.title; + var gs = fullLayout._size; + var vPadShift = 0; + + if(dy === '0em' || !dy) { + vPadShift = -title.pad.b; + } else if(dy === alignmentConstants.CAP_SHIFT + 'em') { + vPadShift = title.pad.t; + } + + if(title.y === 'auto') { + return gs.t / 2; + } else { + switch(title.yref) { + case 'paper': + return gs.t + gs.h - gs.h * title.y + vPadShift; + case 'container': + default: + return fullLayout.height - fullLayout.height * title.y + vPadShift; + } + } +} + +function getMainTitleTextAnchor(fullLayout) { + var title = fullLayout.title; + + var textAnchor = SVG_TEXT_ANCHOR_MIDDLE; + if(Lib.isRightAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_END; + } else if(Lib.isLeftAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_START; + } + + return textAnchor; +} + +function getMainTitleDy(fullLayout) { + var title = fullLayout.title; + + var dy = '0em'; + if(Lib.isTopAnchor(title)) { + dy = alignmentConstants.CAP_SHIFT + 'em'; + } else if(Lib.isMiddleAnchor(title)) { + dy = alignmentConstants.MID_SHIFT + 'em'; + } + + return dy; +} + exports.doTraceStyle = function(gd) { var calcdata = gd.calcdata; var editStyleCalls = []; @@ -45990,7 +46880,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.doTicks(gd, 'redraw'); + Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -46125,6 +47015,8 @@ exports.doAutoRangeAndConstraints = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; cleanAxisConstraints(gd, ax); + // in case margins changed, update scale + ax.setScale(); doAutoRange(gd, ax); } @@ -46156,7 +47048,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('updatemenus', 'draw')(gd); }; -},{"../components/color":43,"../components/drawing":68,"../components/modebar":106,"../components/titles":134,"../constants/alignment":141,"../lib":161,"../lib/clear_gl_canvases":150,"../plots/cartesian/autorange":204,"../plots/cartesian/axes":205,"../plots/cartesian/constraints":213,"../plots/plots":238,"../registry":245,"d3":8}],197:[function(_dereq_,module,exports){ +},{"../components/color":43,"../components/drawing":64,"../components/modebar":102,"../components/titles":131,"../constants/alignment":138,"../lib":159,"../lib/clear_gl_canvases":148,"../plots/cartesian/autorange":202,"../plots/cartesian/axes":203,"../plots/cartesian/constraints":211,"../plots/plots":236,"../registry":243,"d3":8}],195:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46630,7 +47522,7 @@ function format(opts) { return opts; } -},{"../lib":161,"../plots/attributes":202,"../plots/plots":238,"./plot_config":193,"./plot_schema":194,"./plot_template":195}],198:[function(_dereq_,module,exports){ +},{"../lib":159,"../plots/attributes":200,"../plots/plots":236,"./plot_config":191,"./plot_schema":192,"./plot_template":193}],196:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46750,6 +47642,7 @@ function toImage(gd, opts) { // extend config for static plot var configImage = Lib.extendFlat({}, config, { + _exportedPlot: true, staticPlot: true, setBackground: setBackground }); @@ -46820,7 +47713,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":161,"../snapshot/helpers":249,"../snapshot/svgtoimg":251,"../snapshot/tosvg":253,"./plot_api":192}],199:[function(_dereq_,module,exports){ +},{"../lib":159,"../snapshot/helpers":247,"../snapshot/svgtoimg":249,"../snapshot/tosvg":251,"./plot_api":190}],197:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47266,7 +48159,7 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":161,"../plots/plots":238,"./plot_config":193,"./plot_schema":194}],200:[function(_dereq_,module,exports){ +},{"../lib":159,"../plots/plots":236,"./plot_config":191,"./plot_schema":192}],198:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47368,7 +48261,7 @@ module.exports = { } }; -},{}],201:[function(_dereq_,module,exports){ +},{}],199:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47464,7 +48357,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":161,"../plot_api/plot_template":195}],202:[function(_dereq_,module,exports){ +},{"../lib":159,"../plot_api/plot_template":193}],200:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47586,10 +48479,16 @@ module.exports = { _isLinkedToArray: 'transform', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + } }; -},{"../components/fx/attributes":77}],203:[function(_dereq_,module,exports){ +},{"../components/fx/attributes":73}],201:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47618,7 +48517,7 @@ module.exports = { } }; -},{}],204:[function(_dereq_,module,exports){ +},{}],202:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47633,6 +48532,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; +var Registry = _dereq_('../../registry'); module.exports = { getAutoRange: getAutoRange, @@ -47857,10 +48757,6 @@ function concatExtremes(gd, ax) { } function doAutoRange(gd, ax) { - if(!ax._length) ax.setScale(); - - var axIn; - if(ax.autorange) { ax.range = getAutoRange(gd, ax); @@ -47870,20 +48766,28 @@ function doAutoRange(gd, ax) { // doAutoRange will get called on fullLayout, // but we want to report its results back to layout - axIn = ax._input; + var axIn = ax._input; + + // before we edit _input, store preGUI values + var edits = {}; + edits[ax._attr + '.range'] = ax.range; + edits[ax._attr + '.autorange'] = ax.autorange; + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, edits); + axIn.range = ax.range.slice(); axIn.autorange = ax.autorange; } - if(ax._anchorAxis && ax._anchorAxis.rangeslider) { - var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name]; + var anchorAx = ax._anchorAxis; + + if(anchorAx && anchorAx.rangeslider) { + var axeRangeOpts = anchorAx.rangeslider[ax._name]; if(axeRangeOpts) { if(axeRangeOpts.rangemode === 'auto') { axeRangeOpts.range = getAutoRange(gd, ax); } } - axIn = ax._anchorAxis._input; - axIn.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); } } @@ -48101,7 +49005,7 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":143,"../../lib":161,"fast-isnumeric":10}],205:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":159,"../../registry":243,"fast-isnumeric":10}],203:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48261,6 +49165,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t ax.d2c(targetArray[i]); } } + // TODO what to do for transforms? } else { ax = axes.getFromTrace(gd, trace, d2cTarget); } @@ -48301,7 +49206,7 @@ axes.counterLetter = function(id) { axes.minDtick = function(ax, newDiff, newFirst, allow) { // doesn't make sense to do forced min dTick on log or category axes, // and the plot itself may decide to cancel (ie non-grouped bars) - if(['log', 'category'].indexOf(ax.type) !== -1 || !allow) { + if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; } // undefined means there's nothing there yet @@ -48333,18 +49238,15 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // save a copy of the initial axis ranges in fullLayout // use them in mode bar and dblclick events axes.saveRangeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._rangeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.range[0] === ax._rangeInitial[0] && - ax.range[1] === ax._rangeInitial[1] - ) + var hasChanged = isNew || !( + ax.range[0] === ax._rangeInitial[0] && + ax.range[1] === ax._rangeInitial[1] ); if((isNew && ax.autorange === false) || (overwrite && hasChanged)) { @@ -48358,21 +49260,16 @@ axes.saveRangeInitial = function(gd, overwrite) { // save a copy of the initial spike visibility axes.saveShowSpikeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false, - allSpikesEnabled = 'on'; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; + var allSpikesEnabled = 'on'; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._showSpikeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.showspikes === ax._showspikes - ) - ); + var hasChanged = isNew || !(ax.showspikes === ax._showspikes); - if((isNew) || (overwrite && hasChanged)) { + if(isNew || (overwrite && hasChanged)) { ax._showSpikeInitial = ax.showspikes; hasOneAxisChanged = true; } @@ -48389,7 +49286,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { var dataMin = Lib.aggNums(Math.min, null, data); var dataMax = Lib.aggNums(Math.max, null, data); - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { return { start: dataMin - 0.5, end: dataMax + 0.5, @@ -48407,8 +49304,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { type: 'linear', range: [dataMin, dataMax] }; - } - else { + } else { dummyAx = { type: ax.type, range: Lib.simpleMap([dataMin, dataMax], ax.c2r, 0, calendar), @@ -48493,10 +49389,10 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { - var edgecount = 0, - midcount = 0, - intcount = 0, - blankCount = 0; + var edgecount = 0; + var midcount = 0; + var intcount = 0; + var blankCount = 0; function nearEdge(v) { // is a value within 1% of a bin edge? @@ -48587,14 +49483,14 @@ axes.prepTicks = function(ax) { // calculate max number of (auto) ticks to display based on plot size if(ax.tickmode === 'auto' || !ax.dtick) { - var nt = ax.nticks, - minPx; + var nt = ax.nticks; + var minPx; + if(!nt) { - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; nt = ax._length / minPx; - } - else { + } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; nt = Lib.constrain(ax._length / minPx, 4, 9) + 1; } @@ -48656,7 +49552,7 @@ axes.calcTicks = function calcTicks(ax) { // return the full set of tick vals var vals = []; - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { endTick = (axrev) ? Math.max(-0.5, endTick) : Math.min(ax._categories.length - 0.5, endTick); } @@ -48700,23 +49596,22 @@ axes.calcTicks = function calcTicks(ax) { }; function arrayTicks(ax) { - var vals = ax.tickvals, - text = ax.ticktext, - ticksOut = new Array(vals.length), - rng = Lib.simpleMap(ax.range, ax.r2l), - r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001, - r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001, - tickMin = Math.min(r0expanded, r1expanded), - tickMax = Math.max(r0expanded, r1expanded), - vali, - i, - j = 0; + var vals = ax.tickvals; + var text = ax.ticktext; + var ticksOut = new Array(vals.length); + var rng = Lib.simpleMap(ax.range, ax.r2l); + var r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001; + var r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001; + var tickMin = Math.min(r0expanded, r1expanded); + var tickMax = Math.max(r0expanded, r1expanded); + var j = 0; // without a text array, just format the given values as any other ticks // except with more precision to the numbers if(!Array.isArray(text)) text = []; // make sure showing ticks doesn't accidentally add new categories + // TODO multicategory, if we allow ticktext / tickvals var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; // array ticks on log axes always show the full number @@ -48725,8 +49620,8 @@ function arrayTicks(ax) { ax.dtick = 'L' + Math.pow(10, Math.floor(Math.min(ax.range[0], ax.range[1])) - 1); } - for(i = 0; i < vals.length; i++) { - vali = tickVal2l(vals[i]); + for(var i = 0; i < vals.length; i++) { + var vali = tickVal2l(vals[i]); if(vali > tickMin && vali < tickMax) { if(text[i] === undefined) ticksOut[j] = axes.tickText(ax, vali); else ticksOut[j] = tickTextObj(ax, vali, String(text[i])); @@ -48739,17 +49634,17 @@ function arrayTicks(ax) { return ticksOut; } -var roundBase10 = [2, 5, 10], - roundBase24 = [1, 2, 3, 6, 12], - roundBase60 = [1, 2, 5, 10, 15, 30], - // 2&3 day ticks are weird, but need something btwn 1&7 - roundDays = [1, 2, 3, 7, 14], - // approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) - // these don't have to be exact, just close enough to round to the right value - roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1], - roundLog2 = [-0.301, 0, 0.301, 0.699, 1], - // N.B. `thetaunit; 'radians' angular axes must be converted to degrees - roundAngles = [15, 30, 45, 90, 180]; +var roundBase10 = [2, 5, 10]; +var roundBase24 = [1, 2, 3, 6, 12]; +var roundBase60 = [1, 2, 5, 10, 15, 30]; +// 2&3 day ticks are weird, but need something btwn 1&7 +var roundDays = [1, 2, 3, 7, 14]; +// approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) +// these don't have to be exact, just close enough to round to the right value +var roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1]; +var roundLog2 = [-0.301, 0, 0.301, 0.699, 1]; +// N.B. `thetaunit; 'radians' angular axes must be converted to degrees +var roundAngles = [15, 30, 45, 90, 180]; function roundDTick(roughDTick, base, roundingSet) { return base * Lib.roundUp(roughDTick / base, roundingSet); @@ -48840,7 +49735,7 @@ axes.autoTicks = function(ax, roughDTick) { ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } } - else if(ax.type === 'category') { + else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); } @@ -48880,7 +49775,7 @@ function autoTickRound(ax) { dtick = 1; } - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { ax._tickround = null; } if(ax.type === 'date') { @@ -48972,36 +49867,34 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { // calculate the first tick on an axis axes.tickFirst = function(ax) { - var r2l = ax.r2l || Number, - rng = Lib.simpleMap(ax.range, r2l), - axrev = rng[1] < rng[0], - sRound = axrev ? Math.floor : Math.ceil, - // add a tiny extra bit to make sure we get ticks - // that may have been rounded out - r0 = rng[0] * 1.0001 - rng[1] * 0.0001, - dtick = ax.dtick, - tick0 = r2l(ax.tick0); + var r2l = ax.r2l || Number; + var rng = Lib.simpleMap(ax.range, r2l); + var axrev = rng[1] < rng[0]; + var sRound = axrev ? Math.floor : Math.ceil; + // add a tiny extra bit to make sure we get ticks + // that may have been rounded out + var r0 = rng[0] * 1.0001 - rng[1] * 0.0001; + var dtick = ax.dtick; + var tick0 = r2l(ax.tick0); if(isNumeric(dtick)) { var tmin = sRound((r0 - tick0) / dtick) * dtick + tick0; // make sure no ticks outside the category list - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { tmin = Lib.constrain(tmin, 0, ax._categories.length - 1); } return tmin; } - var tType = dtick.charAt(0), - dtNum = Number(dtick.substr(1)); + var tType = dtick.charAt(0); + var dtNum = Number(dtick.substr(1)); // Dates: months (or years) if(tType === 'M') { - var cnt = 0, - t0 = tick0, - t1, - mult, - newDTick; + var cnt = 0; + var t0 = tick0; + var t1, mult, newDTick; // This algorithm should work for *any* nonlinear (but close to linear!) // tick spacing. Limit to 10 iterations, for gregorian months it's normally <=3. @@ -49043,16 +49936,18 @@ axes.tickFirst = function(ax) { // hover is a (truthy) flag for whether to show numbers with a bit // more precision for hovertext axes.tickText = function(ax, x, hover) { - var out = tickTextObj(ax, x), - hideexp, - arrayMode = ax.tickmode === 'array', - extraPrecision = hover || arrayMode, - i, - tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; + var out = tickTextObj(ax, x); + var arrayMode = ax.tickmode === 'array'; + var extraPrecision = hover || arrayMode; + var axType = ax.type; + // TODO multicategory, if we allow ticktext / tickvals + var tickVal2l = axType === 'category' ? ax.d2l_noadd : ax.d2l; + var i; if(arrayMode && Array.isArray(ax.ticktext)) { - var rng = Lib.simpleMap(ax.range, ax.r2l), - minDiff = Math.abs(rng[1] - rng[0]) / 10000; + var rng = Lib.simpleMap(ax.range, ax.r2l); + var minDiff = Math.abs(rng[1] - rng[0]) / 10000; + for(i = 0; i < ax.ticktext.length; i++) { if(Math.abs(x - tickVal2l(ax.tickvals[i])) < minDiff) break; } @@ -49063,28 +49958,25 @@ axes.tickText = function(ax, x, hover) { } function isHidden(showAttr) { - var first_or_last; - if(showAttr === undefined) return true; if(hover) return showAttr === 'none'; - first_or_last = { + var firstOrLast = { first: ax._tmin, last: ax._tmax }[showAttr]; - return showAttr !== 'all' && x !== first_or_last; + return showAttr !== 'all' && x !== firstOrLast; } - if(hover) { - hideexp = 'never'; - } else { - hideexp = ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - } + var hideexp = hover ? + 'never' : + ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - if(ax.type === 'date') formatDate(ax, out, hover, extraPrecision); - else if(ax.type === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); - else if(ax.type === 'category') formatCategory(ax, out); + if(axType === 'date') formatDate(ax, out, hover, extraPrecision); + else if(axType === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); + else if(axType === 'category') formatCategory(ax, out); + else if(axType === 'multicategory') formatMultiCategory(ax, out, hover); else if(isAngular(ax)) formatAngle(ax, out, hover, extraPrecision, hideexp); else formatLinear(ax, out, hover, extraPrecision, hideexp); @@ -49092,6 +49984,20 @@ axes.tickText = function(ax, x, hover) { if(ax.tickprefix && !isHidden(ax.showtickprefix)) out.text = ax.tickprefix + out.text; if(ax.ticksuffix && !isHidden(ax.showticksuffix)) out.text += ax.ticksuffix; + // Setup ticks and grid lines boundaries + // at 1/2 a 'category' to the left/bottom + if(ax.tickson === 'boundaries' || ax.showdividers) { + var inbounds = function(v) { + var p = ax.l2p(v); + return p >= 0 && p <= ax._length ? v : null; + }; + + out.xbnd = [ + inbounds(out.x - 0.5), + inbounds(out.x + ax.dtick - 0.5) + ]; + } + return out; }; @@ -49141,8 +50047,8 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround, - fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); + var tr = ax._tickround; + var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); if(extraPrecision) { // second or sub-second precision: extra always shows max digits. @@ -49151,8 +50057,8 @@ function formatDate(ax, out, hover, extraPrecision) { else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr]; } - var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat), - headStr; + var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat); + var headStr; var splitIndex = dateStr.indexOf('\n'); if(splitIndex !== -1) { @@ -49269,6 +50175,22 @@ function formatCategory(ax, out) { out.text = String(tt); } +function formatMultiCategory(ax, out, hover) { + var v = Math.round(out.x); + var cats = ax._categories[v] || []; + var tt = cats[1] === undefined ? '' : String(cats[1]); + var tt2 = cats[0] === undefined ? '' : String(cats[0]); + + if(hover) { + // TODO is this what we want? + out.text = tt2 + ' - ' + tt; + } else { + // setup for secondary labels + out.text = tt; + out.text2 = tt2; + } +} + function formatLinear(ax, out, hover, extraPrecision, hideexp) { if(hideexp === 'never') { // If this is a hover label, then we must *never* hide the exponent @@ -49374,14 +50296,13 @@ function beyondSI(exponent) { } function numFormat(v, ax, fmtoverride, hover) { - // negative? - var isNeg = v < 0, - // max number of digits past decimal point to show - tickRound = ax._tickround, - exponentFormat = fmtoverride || ax.exponentformat || 'B', - exponent = ax._tickexponent, - tickformat = axes.getTickFormat(ax), - separatethousands = ax.separatethousands; + var isNeg = v < 0; + // max number of digits past decimal point to show + var tickRound = ax._tickround; + var exponentFormat = fmtoverride || ax.exponentformat || 'B'; + var exponent = ax._tickexponent; + var tickformat = axes.getTickFormat(ax); + var separatethousands = ax.separatethousands; // special case for hover: set exponent just for this value, and // add a couple more digits of precision over tick labels @@ -49554,6 +50475,9 @@ axes.getTickFormat = function(ax) { // as an array of items like 'xy', 'x2y', 'x2y2'... // sorted by x (x,x2,x3...) then y // optionally restrict to only subplots containing axis object ax +// +// NOTE: this is currently only used OUTSIDE plotly.js (toolpanel, webapp) +// ideally we get rid of it there (or just copy this there) and remove it here axes.getSubplots = function(gd, ax) { var subplotObj = gd._fullLayout._subplots; var allSubplots = subplotObj.cartesian.concat(subplotObj.gl2d || []); @@ -49572,18 +50496,20 @@ axes.getSubplots = function(gd, ax) { }; // find all subplots with axis 'ax' +// NOTE: this is only used in axes.getSubplots (only used outside plotly.js) and +// gl2d/convert (where it restricts axis subplots to only those with gl2d) axes.findSubplotsWithAxis = function(subplots, ax) { var axMatch = new RegExp( (ax._id.charAt(0) === 'x') ? ('^' + ax._id + 'y') : (ax._id + '$') ); - var subplotsWithAxis = []; + var subplotsWithAx = []; for(var i = 0; i < subplots.length; i++) { var sp = subplots[i]; - if(axMatch.test(sp)) subplotsWithAxis.push(sp); + if(axMatch.test(sp)) subplotsWithAx.push(sp); } - return subplotsWithAxis; + return subplotsWithAx; }; // makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings @@ -49636,24 +50562,25 @@ axes.makeClipPaths = function(gd) { * * @param {DOM element} gd : graph div * @param {string or array of strings} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update + * @param {object} opts: + * - @param {boolean} skipTitle : optional flag to skip axis title draw/update * - * Signature 1: Axes.doTicks(gd, 'redraw') + * Signature 1: Axes.draw(gd, 'redraw') * use this to clear and redraw all axes on graph * - * Signature 2: Axes.doTicks(gd, '') + * Signature 2: Axes.draw(gd, '') * use this to draw all axes on graph w/o the selectAll().remove() * of the 'redraw' signature * - * Signature 3: Axes.doTicks(gd, [axId, axId2, ...]) + * Signature 3: Axes.draw(gd, [axId, axId2, ...]) * where the items are axis id string, * use this to update multiple axes in one call * - * N.B doTicks updates: + * N.B draw updates: * - ax._r (stored range for use by zoom/pan) * - ax._rl (stored linearized range for use by zoom/pan) */ -axes.doTicks = function(gd, arg, skipTitle) { +axes.draw = function(gd, arg, opts) { var fullLayout = gd._fullLayout; if(arg === 'redraw') { @@ -49665,6 +50592,8 @@ axes.doTicks = function(gd, arg, skipTitle) { plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove(); if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); @@ -49674,13 +50603,13 @@ axes.doTicks = function(gd, arg, skipTitle) { var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; - Lib.syncOrAsync(axList.map(function(axid) { + return Lib.syncOrAsync(axList.map(function(axId) { return function() { - if(!axid) return; + if(!axId) return; - var axDone = axes.doTicksSingle(gd, axid, skipTitle); + var ax = axes.getFromId(gd, axId); + var axDone = axes.drawOne(gd, ax, opts); - var ax = axes.getFromId(gd, axid); ax._r = ax.range.slice(); ax._rl = Lib.simpleMap(ax._r, ax.r2l); @@ -49690,692 +50619,1077 @@ axes.doTicks = function(gd, arg, skipTitle) { }; /** - * Per-axis drawing routine! - * - * This routine draws axis ticks and much more (... grids, labels, title etc.) - * Supports multiple argument signatures. - * N.B. this thing is async in general (because of MathJax rendering) + * Draw one cartesian axis * - * @param {DOM element} gd : graph div - * @param {string or object} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * @return {promise} - * - * Signature 1: Axes.doTicks(gd, ax) - * where ax is an axis object as in fullLayout - * - * Signature 2: Axes.doTicks(gd, axId) - * where axId is a axis id string + * @param {DOM element} gd + * @param {object} ax (full) axis object + * @param {object} opts + * - @param {boolean} skipTitle (set to true to skip axis title draw call) */ -axes.doTicksSingle = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; - var independent = false; - var ax; +axes.drawOne = function(gd, ax, opts) { + opts = opts || {}; - if(Lib.isPlainObject(arg)) { - ax = arg; - independent = true; - } else { - ax = axes.getFromId(gd, arg); - } + var i, sp, plotinfo; - // set scaling to pixels ax.setScale(); - var axid = ax._id; - var axLetter = axid.charAt(0); - var counterLetter = axes.counterLetter(axid); + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var counterLetter = axes.counterLetter(axId); + var mainSubplot = ax._mainSubplot; + var mainLinePosition = ax._mainLinePosition; + var mainMirrorPosition = ax._mainMirrorPosition; + var mainPlotinfo = fullLayout._plots[mainSubplot]; + var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; + var subplotsWithAx = ax._subplotsWith; + var vals = ax._vals = axes.calcTicks(ax); - var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; - var tcls = axid + 'tick'; - var gcls = axid + 'grid'; - var zcls = axid + 'zl'; - var pad = (ax.linewidth || 1) / 2; - var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); - var labelShift = 0; - var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); - var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); - var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); - var sides, transfn, tickpathfn, subplots; - var tickLabels; - var i; - if(ax._counterangle && ax.ticks === 'outside') { - var caRad = ax._counterangle * Math.PI / 180; - labelStandoff = ax.ticklen * Math.cos(caRad) + 1; - labelShift = ax.ticklen * Math.sin(caRad); + // Add a couple of axis properties that should cause us to recreate + // elements. Used in d3 data function. + var axInfo = [ax.mirror, mainLinePosition, mainMirrorPosition].join('_'); + for(i = 0; i < vals.length; i++) { + vals[i].axInfo = axInfo; } - if(ax.showticklabels && (ax.ticks === 'outside' || ax.showline)) { - labelStandoff += 0.2 * ax.tickfont.size; - } + if(!ax.visible) return; - // positioning arguments for x vs y axes - if(axLetter === 'x') { - sides = ['bottom', 'top']; - transfn = ax._transfn || function(d) { - return 'translate(' + (ax._offset + ax.l2p(d.x)) + ',0)'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M0,' + shift + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len); - } - else return 'M0,' + shift + 'v' + len; - }; - } - else if(axLetter === 'y') { - sides = ['left', 'right']; - transfn = ax._transfn || function(d) { - return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M' + shift + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); - } - else return 'M' + shift + ',0h' + len; - }; - } - else if(isAngular(ax)) { - sides = ['left', 'right']; - transfn = ax._transfn; - tickpathfn = function(shift, len) { - return 'M' + shift + ',0h' + len; - }; - } - else { - Lib.warn('Unrecognized doTicks axis:', axid); - return; + // stash selections to avoid DOM queries e.g. + // - stash tickLabels selection, so that drawTitle can use it to scoot title + ax._selections = {}; + // stash tick angle (including the computed 'auto' values) per tick-label class + ax._tickAngles = {}; + + var transFn = axes.makeTransFn(ax); + var tickVals; + // We remove zero lines, grid lines, and inside ticks if they're within 1px of the end + // The key case here is removing zero lines when the axis bound is zero + var valsClipped; + + if(ax.tickson === 'boundaries') { + var boundaryVals = getBoundaryVals(ax, vals); + valsClipped = axes.clipEnds(ax, boundaryVals); + tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals; + } else { + valsClipped = axes.clipEnds(ax, vals); + tickVals = ax.ticks === 'inside' ? valsClipped : vals; } - var axside = ax.side || sides[0]; - // which direction do the side[0], side[1], and free ticks go? - // then we flip if outside XOR y axis - var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; - if((ax.ticks !== 'inside') === (axLetter === 'x')) { - ticksign = ticksign.map(function(v) { return -v; }); - } + var gridVals = ax._gridVals = valsClipped; + var dividerVals = getDividerVals(ax, vals); - if(!ax.visible) return; + if(!fullLayout._hasOnlyLargeSploms) { + // keep track of which subplots (by main conteraxis) we've already + // drawn grids for, so we don't overdraw overlaying subplots + var finishedGrids = {}; - if(ax._tickFilter) { - vals = vals.filter(ax._tickFilter); - } + for(i = 0; i < subplotsWithAx.length; i++) { + sp = subplotsWithAx[i]; + plotinfo = fullLayout._plots[sp]; - // Remove zero lines, grid lines, and inside ticks if they're within - // 1 pixel of the end. - // The key case here is removing zero lines when the axis bound is zero. - // Don't clip angular values. - var valsClipped = ax._valsClipped = isAngular(ax) ? - vals : - vals.filter(function(d) { return clipEnds(ax, d.x); }); + var counterAxis = plotinfo[counterLetter + 'axis']; + var mainCounterID = counterAxis._mainAxis._id; + if(finishedGrids[mainCounterID]) continue; + finishedGrids[mainCounterID] = 1; - function drawTicks(container, tickpath) { - var ticks = container.selectAll('path.' + tcls) - .data(ax.ticks === 'inside' ? valsClipped : vals, datafn); + var gridPath = axLetter === 'x' ? + 'M0,' + counterAxis._offset + 'v' + counterAxis._length : + 'M' + counterAxis._offset + ',0h' + counterAxis._length; - if(tickpath && ax.ticks) { - ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) - .classed('crisp', 1) - .call(Color.stroke, ax.tickcolor) - .style('stroke-width', tickWidth + 'px') - .attr('d', tickpath); - ticks.attr('transform', transfn); - ticks.exit().remove(); + axes.drawGrid(gd, ax, { + vals: gridVals, + counterAxis: counterAxis, + layer: plotinfo.gridlayer.select('.' + axId), + path: gridPath, + transFn: transFn + }); + axes.drawZeroLine(gd, ax, { + counterAxis: counterAxis, + layer: plotinfo.zerolinelayer, + path: gridPath, + transFn: transFn + }); } - else ticks.remove(); } - function drawLabels(container, position) { - // tick labels - for now just the main labels. - // TODO: mirror labels, esp for subplots - tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); + var tickSigns = axes.getTickSigns(ax); + var tickSubplots = []; - if(!isNumeric(position)) { - tickLabels.remove(); - drawAxTitle(); - return; - } - if(!ax.showticklabels) { - tickLabels.remove(); - drawAxTitle(); - calcBoundingBox(); - return; + if(ax.ticks) { + var mainTickPath = axes.makeTickPath(ax, mainLinePosition, tickSigns[2]); + var mirrorTickPath; + var fullTickPath; + if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { + mirrorTickPath = axes.makeTickPath(ax, mainMirrorPosition, tickSigns[3]); + fullTickPath = mainTickPath + mirrorTickPath; + } else { + mirrorTickPath = ''; + fullTickPath = mainTickPath; } - var labelx, labely, labelanchor, labelpos0, flipit; - if(axLetter === 'x') { - flipit = (axside === 'bottom') ? 1 : -1; - labelx = function(d) { return d.dx + labelShift * flipit; }; - labelpos0 = position + (labelStandoff + pad) * flipit; - labely = function(d) { - return d.dy + labelpos0 + d.fontSize * - ((axside === 'bottom') ? 1 : -0.2); - }; - labelanchor = function(angle) { - if(!isNumeric(angle) || angle === 0 || angle === 180) { - return 'middle'; - } - return (angle * flipit < 0) ? 'end' : 'start'; - }; - } - else if(axLetter === 'y') { - flipit = (axside === 'right') ? 1 : -1; - labely = function(d) { - return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit; - }; - labelx = function(d) { - return d.dx + position + (labelStandoff + pad + - ((Math.abs(ax.tickangle) === 90) ? d.fontSize / 2 : 0)) * flipit; - }; - labelanchor = function(angle) { - if(isNumeric(angle) && Math.abs(angle) === 90) { - return 'middle'; - } - return axside === 'right' ? 'start' : 'end'; + var tickPath; + if(ax.showdividers && ax.ticks === 'outside' && ax.tickson === 'boundaries') { + var dividerLookup = {}; + for(i = 0; i < dividerVals.length; i++) { + dividerLookup[dividerVals[i].x] = 1; + } + tickPath = function(d) { + return dividerLookup[d.x] ? mirrorTickPath : fullTickPath; }; + } else { + tickPath = fullTickPath; } - else if(isAngular(ax)) { - ax._labelShift = labelShift; - ax._labelStandoff = labelStandoff; - ax._pad = pad; - - labelx = ax._labelx; - labely = ax._labely; - labelanchor = ax._labelanchor; - } - - var maxFontSize = 0, - autoangle = 0, - labelsReady = []; - tickLabels.enter().append('g').classed(tcls, 1) - .append('text') - // only so tex has predictable alignment that we can - // alter later - .attr('text-anchor', 'middle') - .each(function(d) { - var thisLabel = d3.select(this), - newPromise = gd._promises.length; - thisLabel - .call(svgTextUtils.positionText, labelx(d), labely(d)) - .call(Drawing.font, d.font, d.fontSize, d.fontColor) - .text(d.text) - .call(svgTextUtils.convertToTspans, gd); - newPromise = gd._promises[newPromise]; - if(newPromise) { - // if we have an async label, we'll deal with that - // all here so take it out of gd._promises and - // instead position the label and promise this in - // labelsReady - labelsReady.push(gd._promises.pop().then(function() { - positionLabels(thisLabel, ax.tickangle); - })); - } - else { - // sync label: just position it now. - positionLabels(thisLabel, ax.tickangle); - } - }); - tickLabels.exit().remove(); - tickLabels.each(function(d) { - maxFontSize = Math.max(maxFontSize, d.fontSize); + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: mainAxLayer, + path: tickPath, + transFn: transFn }); - if(isAngular(ax)) { - tickLabels.each(function(d) { - d3.select(this).select('text') - .call(svgTextUtils.positionText, labelx(d), labely(d)); + tickSubplots = Object.keys(ax._linepositions || {}); + } + + for(i = 0; i < tickSubplots.length; i++) { + sp = tickSubplots[i]; + plotinfo = fullLayout._plots[sp]; + // [bottom or left, top or right], free and main are handled above + var linepositions = ax._linepositions[sp] || []; + var spTickPath = axes.makeTickPath(ax, linepositions[0], tickSigns[0]) + + axes.makeTickPath(ax, linepositions[1], tickSigns[1]); + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: plotinfo[axLetter + 'axislayer'], + path: spTickPath, + transFn: transFn + }); + } + + var seq = []; + + // tick labels - for now just the main labels. + // TODO: mirror labels, esp for subplots + + seq.push(function() { + var labelFns = axes.makeLabelFns(ax, mainLinePosition); + return axes.drawLabels(gd, ax, { + vals: vals, + layer: mainAxLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn, + }); + }); + + if(ax.type === 'multicategory') { + var labelLength = 0; + var pad = {x: 2, y: 10}[axLetter]; + var sgn = tickSigns[2] * (ax.ticks === 'inside' ? -1 : 1); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick') + pad; + labelLength += ax._tickAngles[axId + 'tick'] ? ax.tickfont.size * LINE_SPACING : 0; + var secondaryPosition = mainLinePosition + labelLength * sgn; + var secondaryLabelFns = axes.makeLabelFns(ax, secondaryPosition); + + return axes.drawLabels(gd, ax, { + vals: getSecondaryLabelVals(ax, vals), + layer: mainAxLayer, + cls: axId + 'tick2', + repositionOnUpdate: true, + secondary: true, + transFn: transFn, + labelXFn: secondaryLabelFns.labelXFn, + labelYFn: secondaryLabelFns.labelYFn, + labelAnchorFn: secondaryLabelFns.labelAnchorFn, }); - } + }); - // How much to shift a multi-line label to center it vertically. - function getAnchorHeight(lineCount, lineHeight, angle) { - var h = (lineCount - 1) * lineHeight; - if(axLetter === 'x') { - if(angle < -60 || 60 < angle) { - return -0.5 * h; - } else if(axside === 'top') { - return -h; - } - } else { - angle *= axside === 'left' ? 1 : -1; - if(angle < -30) { - return -h; - } else if(angle < 30) { - return -0.5 * h; - } - } - return 0; - } - - function positionLabels(s, angle) { - s.each(function(d) { - var anchor = labelanchor(angle, d); - var thisLabel = d3.select(this), - mathjaxGroup = thisLabel.select('.text-math-group'), - transform = transfn.call(thisLabel.node(), d) + - ((isNumeric(angle) && +angle !== 0) ? - (' rotate(' + angle + ',' + labelx(d) + ',' + - (labely(d) - d.fontSize / 2) + ')') : - ''); - var anchorHeight = getAnchorHeight( - svgTextUtils.lineCount(thisLabel), - LINE_SPACING * d.fontSize, - isNumeric(angle) ? +angle : 0); - if(anchorHeight) { - transform += ' translate(0, ' + anchorHeight + ')'; - } - if(mathjaxGroup.empty()) { - thisLabel.select('text').attr({ - transform: transform, - 'text-anchor': anchor - }); - } - else { - var mjShift = - Drawing.bBox(mathjaxGroup.node()).width * - {end: -0.5, start: 0.5}[anchor]; - mathjaxGroup.attr('transform', transform + - (mjShift ? 'translate(' + mjShift + ',0)' : '')); - } + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick2'); + ax._labelLength = labelLength; + + return drawDividers(gd, ax, { + vals: dividerVals, + layer: mainAxLayer, + path: axes.makeTickPath(ax, mainLinePosition, sgn, labelLength), + transFn: transFn }); - } + }); + } - // make sure all labels are correctly positioned at their base angle - // the positionLabels call above is only for newly drawn labels. - // do this without waiting, using the last calculated angle to - // minimize flicker, then do it again when we know all labels are - // there, putting back the prescribed angle to check for overlaps. - positionLabels(tickLabels, ax._lastangle || ax.tickangle); - - function allLabelsReady() { - return labelsReady.length && Promise.all(labelsReady); - } - - function fixLabelOverlaps() { - positionLabels(tickLabels, ax.tickangle); - - // check for auto-angling if x labels overlap - // don't auto-angle at all for log axes with - // base and digit format - if(axLetter === 'x' && !isNumeric(ax.tickangle) && - (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')) { - var lbbArray = []; - tickLabels.each(function(d) { - var s = d3.select(this), - thisLabel = s.select('.text-math-group'), - x = ax.l2p(d.x); - if(thisLabel.empty()) thisLabel = s.select('text'); - - var bb = Drawing.bBox(thisLabel.node()); - - lbbArray.push({ - // ignore about y, just deal with x overlaps - top: 0, - bottom: 10, - height: 10, - left: x - bb.width / 2, - // impose a 2px gap - right: x + bb.width / 2 + 2, - width: bb.width + 2 - }); - }); - for(i = 0; i < lbbArray.length - 1; i++) { - if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { - // any overlap at all - set 30 degrees - autoangle = 30; - break; - } - } - if(autoangle) { - var tickspacing = Math.abs( - (vals[vals.length - 1].x - vals[0].x) * ax._m - ) / (vals.length - 1); - if(tickspacing < maxFontSize * 2.5) { - autoangle = 90; - } - positionLabels(tickLabels, autoangle); - } - ax._lastangle = autoangle; - } + function extendRange(range, newRange) { + range[0] = Math.min(range[0], newRange[0]); + range[1] = Math.max(range[1], newRange[1]); + } - // update the axis title - // (so it can move out of the way if needed) - // TODO: separate out scoot so we don't need to do - // a full redraw of the title (mostly relevant for MathJax) - drawAxTitle(); - return axid + ' done'; - } + function calcBoundingBox() { + if(ax.showticklabels) { + var gdBB = gd.getBoundingClientRect(); + var bBox = mainAxLayer.node().getBoundingClientRect(); + + /* + * the way we're going to use this, the positioning that matters + * is relative to the origin of gd. This is important particularly + * if gd is scrollable, and may have been scrolled between the time + * we calculate this and the time we use it + */ - function calcBoundingBox() { - if(ax.showticklabels) { - var gdBB = gd.getBoundingClientRect(); - var bBox = container.node().getBoundingClientRect(); + ax._boundingBox = { + width: bBox.width, + height: bBox.height, + left: bBox.left - gdBB.left, + right: bBox.right - gdBB.left, + top: bBox.top - gdBB.top, + bottom: bBox.bottom - gdBB.top + }; + } else { + var gs = fullLayout._size; + var pos; - /* - * the way we're going to use this, the positioning that matters - * is relative to the origin of gd. This is important particularly - * if gd is scrollable, and may have been scrolled between the time - * we calculate this and the time we use it - */ + // set dummy bbox for ticklabel-less axes + + if(axLetter === 'x') { + pos = ax.anchor === 'free' ? + gs.t + gs.h * (1 - ax.position) : + gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); ax._boundingBox = { - width: bBox.width, - height: bBox.height, - left: bBox.left - gdBB.left, - right: bBox.right - gdBB.left, - top: bBox.top - gdBB.top, - bottom: bBox.bottom - gdBB.top + top: pos, + bottom: pos, + left: ax._offset, + right: ax._offset + ax._length, + width: ax._length, + height: 0 }; } else { - var gs = fullLayout._size; - var pos; - - // set dummy bbox for ticklabel-less axes + pos = ax.anchor === 'free' ? + gs.l + gs.w * ax.position : + gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - if(axLetter === 'x') { - pos = ax.anchor === 'free' ? - gs.t + gs.h * (1 - ax.position) : - gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); - - ax._boundingBox = { - top: pos, - bottom: pos, - left: ax._offset, - right: ax._offset + ax._length, - width: ax._length, - height: 0 - }; - } else { - pos = ax.anchor === 'free' ? - gs.l + gs.w * ax.position : - gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - - ax._boundingBox = { - left: pos, - right: pos, - bottom: ax._offset + ax._length, - top: ax._offset, - height: ax._length, - width: 0 - }; - } + ax._boundingBox = { + left: pos, + right: pos, + bottom: ax._offset + ax._length, + top: ax._offset, + height: ax._length, + width: 0 + }; } + } - /* - * for spikelines: what's the full domain of positions in the - * opposite direction that are associated with this axis? - * This means any axes that we make a subplot with, plus the - * position of the axis itself if it's free. - */ - if(subplots) { - var fullRange = ax._counterSpan = [Infinity, -Infinity]; - - for(i = 0; i < subplots.length; i++) { - var subplot = fullLayout._plots[subplots[i]]; - var counterAxis = subplot[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + /* + * for spikelines: what's the full domain of positions in the + * opposite direction that are associated with this axis? + * This means any axes that we make a subplot with, plus the + * position of the axis itself if it's free. + */ + if(subplotsWithAx) { + var fullRange = ax._counterSpan = [Infinity, -Infinity]; - extendRange(fullRange, [ - counterAxis._offset, - counterAxis._offset + counterAxis._length - ]); - } + for(var i = 0; i < subplotsWithAx.length; i++) { + var plotinfo = fullLayout._plots[subplotsWithAx[i]]; + var counterAxis = plotinfo[(axLetter === 'x') ? 'yaxis' : 'xaxis']; - if(ax.anchor === 'free') { - extendRange(fullRange, (axLetter === 'x') ? - [ax._boundingBox.bottom, ax._boundingBox.top] : - [ax._boundingBox.right, ax._boundingBox.left]); - } + extendRange(fullRange, [ + counterAxis._offset, + counterAxis._offset + counterAxis._length + ]); } - function extendRange(range, newRange) { - range[0] = Math.min(range[0], newRange[0]); - range[1] = Math.max(range[1], newRange[1]); + if(ax.anchor === 'free') { + extendRange(fullRange, (axLetter === 'x') ? + [ax._boundingBox.bottom, ax._boundingBox.top] : + [ax._boundingBox.right, ax._boundingBox.left]); } } + } - function doAutoMargins() { - var pushKey = ax._name + '.automargin'; - if(axLetter !== 'x' && axLetter !== 'y') { return; } - if(!ax.automargin) { - Plots.autoMargin(gd, pushKey); - return; - } + var hasRangeSlider = Registry.getComponentMethod('rangeslider', 'isVisible')(ax); - var s = ax.side[0]; - var push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + function doAutoMargins() { + var push, rangeSliderPush; + + if(hasRangeSlider) { + rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); + } + Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); + + var s = ax.side.charAt(0); + if(ax.automargin && (!hasRangeSlider || s !== 'b')) { + push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; if(axLetter === 'x') { push.y = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 't' ? 1 : 0]); + ax._anchorAxis.domain[s === 't' ? 1 : 0]); push[s] += ax._boundingBox.height; - } - else { + } else { push.x = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 'r' ? 1 : 0]); + ax._anchorAxis.domain[s === 'r' ? 1 : 0]); push[s] += ax._boundingBox.width; } - if(ax.title !== fullLayout._dfltTitle[axLetter]) { - push[s] += ax.titlefont.size; + if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { + push[s] += ax.title.font.size; } - - Plots.autoMargin(gd, pushKey, push); } - var done = Lib.syncOrAsync([ - allLabelsReady, - fixLabelOverlaps, - calcBoundingBox, - doAutoMargins - ]); - if(done && done.then) gd._promises.push(done); - return done; + Plots.autoMargin(gd, axAutoMarginID(ax), push); } - function drawAxTitle() { - if(skipTitle) return; + seq.push(calcBoundingBox, doAutoMargins); - // now this only applies to regular cartesian axes; colorbars and - // others ALWAYS call doTicks with skipTitle=true so they can - // configure their own titles. + if(!opts.skipTitle && + !(hasRangeSlider && ax._boundingBox && ax.side === 'bottom') + ) { + seq.push(function() { return drawTitle(gd, ax); }); + } - // rangeslider takes over a bottom title so drop it here - if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; + return Lib.syncOrAsync(seq); +}; - var avoid = { - selection: tickLabels, - side: ax.side - }; - var axLetter = axid.charAt(0); - var gs = gd._fullLayout._size; - var offsetBase = 1.5; - var fontSize = ax.titlefont.size; +function getBoundaryVals(ax, vals) { + var out = []; + var i; - var transform, counterAxis, x, y; + // boundaryVals are never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; - if(tickLabels.size()) { - var translation = Drawing.getTranslate(tickLabels.node().parentNode); - avoid.offsetLeft = translation.x; - avoid.offsetTop = translation.y; + if(vals.length) { + for(i = 0; i < vals.length; i++) { + _push(vals[i], 0); } + _push(vals[i - 1], 1); + } - var titleStandoff = 10 + fontSize * offsetBase + - (ax.linewidth ? ax.linewidth - 1 : 0); + return out; +} - if(axLetter === 'x') { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : - axisIds.getFromId(gd, ax.anchor); +function getSecondaryLabelVals(ax, vals) { + var out = []; + var lookup = {}; - x = ax._offset + ax._length / 2; + for(var i = 0; i < vals.length; i++) { + var d = vals[i]; + if(lookup[d.text2]) { + lookup[d.text2].push(d.x); + } else { + lookup[d.text2] = [d.x]; + } + } - if(ax.side === 'top') { - y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); - } - else { - y = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1.5 : 0.5); - } - y += counterAxis._offset; + for(var k in lookup) { + out.push(tickTextObj(ax, Lib.interp(lookup[k], 0.5), k)); + } + + return out; +} - if(!avoid.side) avoid.side = 'bottom'; +function getDividerVals(ax, vals) { + var out = []; + var i, current; + + // never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); } - else { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + }; - y = ax._offset + ax._length / 2; - if(ax.side === 'right') { - x = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1 : 0.5); - } - else { - x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + if(ax.showdividers && vals.length) { + for(i = 0; i < vals.length; i++) { + var d = vals[i]; + if(d.text2 !== current) { + _push(d, 0); } - x += counterAxis._offset; + current = d.text2; + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getLabelLevelSpan(ax, cls) { + var axLetter = ax._id.charAt(0); + var angle = ax._tickAngles[cls] || 0; + var rad = Lib.deg2rad(angle); + var sinA = Math.sin(rad); + var cosA = Math.cos(rad); + var maxX = 0; + var maxY = 0; + + // N.B. Drawing.bBox does not take into account rotate transforms + + ax._selections[cls].each(function() { + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + var w = bb.width; + var h = bb.height; + maxX = Math.max(maxX, cosA * w, sinA * h); + maxY = Math.max(maxY, sinA * w, cosA * h); + }); + + return {x: maxY, y: maxX}[axLetter]; +} + +/** + * Which direction do the 'ax.side' values, and free ticks go? + * + * @param {object} ax (full) axis object + * - {string} _id (starting with 'x' or 'y') + * - {string} side + * - {string} ticks + * @return {array} all entries are either -1 or 1 + * - [0]: sign for top/right ticks (i.e. negative SVG direction) + * - [1]: sign for bottom/left ticks (i.e. positive SVG direction) + * - [2]: sign for ticks corresponding to 'ax.side' + * - [3]: sign for ticks mirroring 'ax.side' + */ +axes.getTickSigns = function(ax) { + var axLetter = ax._id.charAt(0); + var sideOpposite = {x: 'top', y: 'right'}[axLetter]; + var main = ax.side === sideOpposite ? 1 : -1; + var out = [-1, 1, main, -main]; + // then we flip if outside XOR y axis + if((ax.ticks !== 'inside') === (axLetter === 'x')) { + out = out.map(function(v) { return -v; }); + } + return out; +}; - transform = {rotate: '-90', offset: 0}; - if(!avoid.side) avoid.side = 'left'; +/** + * Make axis translate transform function + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} _offset + * - {fn} l2p + * @return {fn} function of calcTicks items + */ +axes.makeTransFn = function(ax) { + var axLetter = ax._id.charAt(0); + var offset = ax._offset; + return axLetter === 'x' ? + function(d) { return 'translate(' + (offset + ax.l2p(d.x)) + ',0)'; } : + function(d) { return 'translate(0,' + (offset + ax.l2p(d.x)) + ')'; }; +}; + +/** + * Make axis tick path string + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} ticklen + * - {number} linewidth + * @param {number} shift along direction of ticklen + * @param {1 or -1} sng tick sign + * @param {number (optional)} len tick length + * @return {string} + */ +axes.makeTickPath = function(ax, shift, sgn, len) { + len = len !== undefined ? len : ax.ticklen; + + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + + return axLetter === 'x' ? + 'M0,' + (shift + pad * sgn) + 'v' + (len * sgn) : + 'M' + (shift + pad * sgn) + ',0h' + (len * sgn); +}; + +/** + * Make axis tick label x, y and anchor functions + * + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} ticklen + * - {string} side + * - {number} linewidth + * - {number} tickfont.size + * - {boolean} showline + * @param {number} shift + * @param {number} angle [in degrees] ... + * @return {object} + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + * - {number} labelStandoff + * - {number} labelShift + */ +axes.makeLabelFns = function(ax, shift, angle) { + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside'; + + var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0; + var labelShift = 0; + + if(angle && ax.ticks === 'outside') { + var rad = Lib.deg2rad(angle); + labelStandoff = ax.ticklen * Math.cos(rad) + 1; + labelShift = ax.ticklen * Math.sin(rad); + } + + if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) { + labelStandoff += 0.2 * ax.tickfont.size; + } + + // Used in polar angular label x/y functions + // TODO generalize makeLabelFns so that it just work for angular axes + var out = { + labelStandoff: labelStandoff, + labelShift: labelShift + }; + + var x0, y0, ff, flipIt; + if(axLetter === 'x') { + flipIt = ax.side === 'bottom' ? 1 : -1; + x0 = labelShift * flipIt; + y0 = shift + (labelStandoff + pad) * flipIt; + ff = ax.side === 'bottom' ? 1 : -0.2; + + out.labelXFn = function(d) { return d.dx + x0; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * ff; }; + out.labelAnchorFn = function(a) { + if(!isNumeric(a) || a === 0 || a === 180) { + return 'middle'; + } + return (a * flipIt < 0) ? 'end' : 'start'; + }; + } else if(axLetter === 'y') { + flipIt = ax.side === 'right' ? 1 : -1; + x0 = labelStandoff + pad; + y0 = -labelShift * flipIt; + ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0; + + out.labelXFn = function(d) { return d.dx + shift + (x0 + d.fontSize * ff) * flipIt; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; }; + out.labelAnchorFn = function(a) { + if(isNumeric(a) && Math.abs(a) === 90) { + return 'middle'; + } + return ax.side === 'right' ? 'start' : 'end'; + }; + } + + return out; +}; + +function tickDataFn(d) { + return [d.text, d.x, d.axInfo, d.font, d.fontSize, d.fontColor].join('_'); +} + +/** + * Draw axis ticks + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} linewidth + * - {string} tickcolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawTicks = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'tick'; + + var ticks = opts.layer.selectAll('path.' + cls) + .data(ax.ticks ? opts.vals : [], tickDataFn); + + ticks.exit().remove(); + + ticks.enter().append('path') + .classed(cls, 1) + .classed('ticks', 1) + .classed('crisp', opts.crisp !== false) + .call(Color.stroke, ax.tickcolor) + .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') + .attr('d', opts.path); + + ticks.attr('transform', opts.transFn); +}; + +/** + * Draw axis grid + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showgrid + * - {string} gridcolor + * - {string} gridwidth + * - {boolean} zeroline + * - {string} type + * - {string} dtick + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * optional - only required if this axis supports zero lines + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawGrid = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'grid'; + var vals = opts.vals; + var counterAx = opts.counterAxis; + if(ax.showgrid === false) { + vals = []; + } + else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + var isArrayMode = ax.tickmode === 'array'; + for(var i = 0; i < vals.length; i++) { + var xi = vals[i].x; + if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) { + vals = vals.slice(0, i).concat(vals.slice(i + 1)); + // In array mode you can in principle have multiple + // ticks at 0, so test them all. Otherwise once we found + // one we can stop. + if(isArrayMode) i--; + else break; + } } + } + + var grid = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + grid.exit().remove(); + + grid.enter().append('path') + .classed(cls, 1) + .classed('crisp', opts.crisp !== false); + + ax._gw = Drawing.crispRound(gd, ax.gridwidth, 1); + + grid.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.gridcolor || '#ddd') + .style('stroke-width', ax._gw + 'px'); + + if(typeof opts.path === 'function') grid.attr('d', opts.path); +}; + +/** + * Draw axis zero-line + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} zeroline + * - {number} zerolinewidth + * - {string} zerolinecolor + * - {number (optional)} _gridWidthCrispRound + * @param {object} opts + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawZeroLine = function(gd, ax, opts) { + opts = opts || opts; - Titles.draw(gd, axid + 'title', { - propContainer: ax, - propName: ax._name + '.title', - placeholder: fullLayout._dfltTitle[axLetter], - avoid: avoid, - transform: transform, - attributes: {x: x, y: y, 'text-anchor': 'middle'} + var cls = ax._id + 'zl'; + var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis); + + var zl = opts.layer.selectAll('path.' + cls) + .data(show ? [{x: 0, id: ax._id}] : []); + + zl.exit().remove(); + + zl.enter().append('path') + .classed(cls, 1) + .classed('zl', 1) + .classed('crisp', opts.crisp !== false) + .each(function() { + // use the fact that only one element can enter to trigger a sort. + // If several zerolines enter at the same time we will sort once per, + // but generally this should be a minimal overhead. + opts.layer.selectAll('path').sort(function(da, db) { + return axisIds.idSort(da.id, db.id); + }); }); - } - function drawGrid(plotinfo, counteraxis) { - if(fullLayout._hasOnlyLargeSploms) return; - - var gridcontainer = plotinfo.gridlayer.selectAll('.' + axid); - var zlcontainer = plotinfo.zerolinelayer; - var gridpath = ax._gridpath || ((axLetter === 'x' ? - ('M0,' + counteraxis._offset + 'v') : - ('M' + counteraxis._offset + ',0h') - ) + counteraxis._length); - var grid = gridcontainer.selectAll('path.' + gcls) - .data((ax.showgrid === false) ? [] : valsClipped, datafn); - grid.enter().append('path').classed(gcls, 1) - .classed('crisp', 1) - .attr('d', gridpath) + zl.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); +}; + +/** + * Draw axis tick labels + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showticklabels + * - {number} tickangle + * - {object (optional)} _selections + * - {object} (optional)} _tickAngles + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string (optional)} cls (node className) + * - {boolean} repositionOnUpdate (set to true to reposition update selection) + * - {boolean} secondary + * - {fn} transFn + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + */ +axes.drawLabels = function(gd, ax, opts) { + opts = opts || {}; + + var axId = ax._id; + var axLetter = axId.charAt(0); + var cls = opts.cls || axId + 'tick'; + var vals = opts.vals; + var labelXFn = opts.labelXFn; + var labelYFn = opts.labelYFn; + var labelAnchorFn = opts.labelAnchorFn; + var tickAngle = opts.secondary ? 0 : ax.tickangle; + var lastAngle = (ax._tickAngles || {})[cls]; + + var tickLabels = opts.layer.selectAll('g.' + cls) + .data(ax.showticklabels ? vals : [], tickDataFn); + + var labelsReady = []; + + tickLabels.enter().append('g') + .classed(cls, 1) + .append('text') + // only so tex has predictable alignment that we can + // alter later + .attr('text-anchor', 'middle') .each(function(d) { - if(ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - Math.abs(d.x) < ax.dtick / 100) { - d3.select(this).remove(); + var thisLabel = d3.select(this); + var newPromise = gd._promises.length; + + thisLabel + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)) + .call(Drawing.font, d.font, d.fontSize, d.fontColor) + .text(d.text) + .call(svgTextUtils.convertToTspans, gd); + + if(gd._promises[newPromise]) { + // if we have an async label, we'll deal with that + // all here so take it out of gd._promises and + // instead position the label and promise this in + // labelsReady + labelsReady.push(gd._promises.pop().then(function() { + positionLabels(thisLabel, tickAngle); + })); + } else { + // sync label: just position it now. + positionLabels(thisLabel, tickAngle); } }); - grid.attr('transform', transfn) - .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', gridWidth + 'px'); - if(typeof gridpath === 'function') grid.attr('d', gridpath); - grid.exit().remove(); - - // zero line - if(zlcontainer) { - var zlData = {x: 0, id: axid}; - var showZl = axes.shouldShowZeroLine(gd, ax, counteraxis); - var zl = zlcontainer.selectAll('path.' + zcls) - .data(showZl ? [zlData] : []); - zl.enter().append('path').classed(zcls, 1).classed('zl', 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function() { - // use the fact that only one element can enter to trigger a sort. - // If several zerolines enter at the same time we will sort once per, - // but generally this should be a minimal overhead. - zlcontainer.selectAll('path').sort(function(da, db) { - return axisIds.idSort(da.id, db.id); - }); - }); - zl.attr('transform', transfn) - .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', zeroLineWidth + 'px'); - zl.exit().remove(); - } + + tickLabels.exit().remove(); + + if(opts.repositionOnUpdate) { + tickLabels.each(function(d) { + d3.select(this).select('text') + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)); + }); } - if(independent) { - drawTicks(ax._axislayer, tickpathfn(ax._pos + pad * ticksign[2], ticksign[2] * ax.ticklen)); - if(ax._counteraxis) { - var fictionalPlotinfo = { - gridlayer: ax._gridlayer, - zerolinelayer: ax._zerolinelayer - }; - drawGrid(fictionalPlotinfo, ax._counteraxis); + // How much to shift a multi-line label to center it vertically. + function getAnchorHeight(lineCount, lineHeight, angle) { + var h = (lineCount - 1) * lineHeight; + if(axLetter === 'x') { + if(angle < -60 || 60 < angle) { + return -0.5 * h; + } else if(ax.side === 'top') { + return -h; + } + } else { + angle *= ax.side === 'left' ? 1 : -1; + if(angle < -30) { + return -h; + } else if(angle < 30) { + return -0.5 * h; + } } - return drawLabels(ax._axislayer, ax._pos); + return 0; } - else if(fullLayout._has('cartesian')) { - subplots = axes.getSubplots(gd, ax); - // keep track of which subplots (by main conteraxis) we've already - // drawn grids for, so we don't overdraw overlaying subplots - var finishedGrids = {}; - - subplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; - var counterAxis = plotinfo[counterLetter + 'axis']; + function positionLabels(s, angle) { + s.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + var anchor = labelAnchorFn(angle, d); + + var transform = opts.transFn.call(thisLabel.node(), d) + + ((isNumeric(angle) && +angle !== 0) ? + (' rotate(' + angle + ',' + labelXFn(d) + ',' + + (labelYFn(d) - d.fontSize / 2) + ')') : + ''); + + var anchorHeight = getAnchorHeight( + svgTextUtils.lineCount(thisLabel), + LINE_SPACING * d.fontSize, + isNumeric(angle) ? +angle : 0 + ); - var mainCounterID = counterAxis._mainAxis._id; - if(finishedGrids[mainCounterID]) return; - finishedGrids[mainCounterID] = 1; + if(anchorHeight) { + transform += ' translate(0, ' + anchorHeight + ')'; + } - drawGrid(plotinfo, counterAxis, subplot); + if(mathjaxGroup.empty()) { + thisLabel.select('text').attr({ + transform: transform, + 'text-anchor': anchor + }); + } else { + var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; + var mjShift = mjWidth * {end: -0.5, start: 0.5}[anchor]; + mathjaxGroup.attr('transform', transform + (mjShift ? 'translate(' + mjShift + ',0)' : '')); + } }); + } - var mainSubplot = ax._mainSubplot; - var mainPlotinfo = fullLayout._plots[mainSubplot]; - var tickSubplots = []; + // make sure all labels are correctly positioned at their base angle + // the positionLabels call above is only for newly drawn labels. + // do this without waiting, using the last calculated angle to + // minimize flicker, then do it again when we know all labels are + // there, putting back the prescribed angle to check for overlaps. + positionLabels(tickLabels, lastAngle || tickAngle); - if(ax.ticks) { - var mainSign = ticksign[2]; - var tickpath = tickpathfn(ax._mainLinePosition + pad * mainSign, mainSign * ax.ticklen); - if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { - tickpath += tickpathfn(ax._mainMirrorPosition - pad * mainSign, -mainSign * ax.ticklen); - } - drawTicks(mainPlotinfo[axLetter + 'axislayer'], tickpath); + function allLabelsReady() { + return labelsReady.length && Promise.all(labelsReady); + } - tickSubplots = Object.keys(ax._linepositions || {}); - } + function fixLabelOverlaps() { + positionLabels(tickLabels, tickAngle); + + var autoangle = null; - tickSubplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; + // check for auto-angling if x labels overlap + // don't auto-angle at all for log axes with + // base and digit format + if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) && + (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D') + ) { + autoangle = 0; - var container = plotinfo[axLetter + 'axislayer']; + var maxFontSize = 0; + var lbbArray = []; + var i; - // [bottom or left, top or right] - // free and main are handled above - var linepositions = ax._linepositions[subplot] || []; + tickLabels.each(function(d) { + maxFontSize = Math.max(maxFontSize, d.fontSize); + + var x = ax.l2p(d.x); + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + + lbbArray.push({ + // ignore about y, just deal with x overlaps + top: 0, + bottom: 10, + height: 10, + left: x - bb.width / 2, + // impose a 2px gap + right: x + bb.width / 2 + 2, + width: bb.width + 2 + }); + }); + + if((ax.tickson === 'boundaries' || ax.showdividers) && !opts.secondary) { + var gap = 2; + if(ax.ticks) gap += ax.tickwidth / 2; + + // TODO should secondary labels also fall into this fix-overlap regime? + + for(i = 0; i < lbbArray.length; i++) { + var xbnd = vals[i].xbnd; + var lbb = lbbArray[i]; + if( + (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || + (xbnd[1] !== null && (ax.l2p(xbnd[1]) - lbb.right) < gap) + ) { + autoangle = 90; + break; + } + } + } else { + var vLen = vals.length; + var tickSpacing = Math.abs((vals[vLen - 1].x - vals[0].x) * ax._m) / (vLen - 1); + var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory'; - function tickPathSide(sidei) { - var tsign = ticksign[sidei]; - return tickpathfn(linepositions[sidei] + pad * tsign, tsign * ax.ticklen); + // any overlap at all - set 30 degrees or 90 degrees + for(i = 0; i < lbbArray.length - 1; i++) { + if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { + autoangle = rotate90 ? 90 : 30; + break; + } + } } - drawTicks(container, tickPathSide(0) + tickPathSide(1)); - }); + if(autoangle) { + positionLabels(tickLabels, autoangle); + } + } - var mainContainer = mainPlotinfo[axLetter + 'axislayer']; + if(ax._tickAngles) { + ax._tickAngles[cls] = autoangle === null ? + (isNumeric(tickAngle) ? tickAngle : 0) : + autoangle; + } + } - return drawLabels(mainContainer, ax._mainLinePosition); + if(ax._selections) { + ax._selections[cls] = tickLabels; } + + var done = Lib.syncOrAsync([allLabelsReady, fixLabelOverlaps]); + if(done && done.then) gd._promises.push(done); + return done; }; +/** + * Draw axis dividers + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} showdividers + * - {number} dividerwidth + * - {string} dividercolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {fn} path + * - {fn} transFn + */ +function drawDividers(gd, ax, opts) { + var cls = ax._id + 'divider'; + var vals = opts.vals; + + var dividers = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + dividers.exit().remove(); + + dividers.enter().insert('path', ':first-child') + .classed(cls, 1) + .classed('crisp', 1) + .call(Color.stroke, ax.dividercolor) + .style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px'); + + dividers + .attr('transform', opts.transFn) + .attr('d', opts.path); +} + +function drawTitle(gd, ax) { + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var gs = fullLayout._size; + var fontSize = ax.title.font.size; + + var titleStandoff; + if(ax.type === 'multicategory') { + titleStandoff = ax._labelLength; + } else { + var offsetBase = 1.5; + titleStandoff = 10 + fontSize * offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); + } + + var transform, counterAxis, x, y; + + if(axLetter === 'x') { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + x = ax._offset + ax._length / 2; + + if(ax.side === 'top') { + y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); + } else { + y = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1.5 : 0.5); + } + y += counterAxis._offset; + } else { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + y = ax._offset + ax._length / 2; + + if(ax.side === 'right') { + x = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1 : 0.5); + } else { + x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + } + x += counterAxis._offset; + + transform = {rotate: '-90', offset: 0}; + } + + var avoid; + + if(ax.type !== 'multicategory') { + var tickLabels = ax._selections[ax._id + 'tick']; + + avoid = { + selection: tickLabels, + side: ax.side + }; + + if(tickLabels && tickLabels.node() && tickLabels.node().parentNode) { + var translation = Drawing.getTranslate(tickLabels.node().parentNode); + avoid.offsetLeft = translation.x; + avoid.offsetTop = translation.y; + } + } + + return Titles.draw(gd, axId + 'title', { + propContainer: ax, + propName: ax._name + '.title.text', + placeholder: fullLayout._dfltTitle[axLetter], + avoid: avoid, + transform: transform, + attributes: {x: x, y: y, 'text-anchor': 'middle'} + }); +} + axes.shouldShowZeroLine = function(gd, ax, counterAxis) { var rng = Lib.simpleMap(ax.range, ax.r2l); return ( (rng[0] * rng[1] <= 0) && ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - ax._valsClipped.length && + ax._gridVals.length && ( clipEnds(ax, 0) || !anyCounterAxLineAtZero(gd, ax, counterAxis, rng) || @@ -50384,6 +51698,10 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { ); }; +axes.clipEnds = function(ax, vals) { + return vals.filter(function(d) { return clipEnds(ax, d.x); }); +}; + function clipEnds(ax, l) { var p = ax.l2p(l); return (p > 1 && p < ax._length - 1); @@ -50459,6 +51777,12 @@ function hasBarsOrFill(gd, ax) { return false; } +function selectTickLabel(gTick) { + var s = d3.select(gTick); + var mj = s.select('.text-math-group'); + return mj.empty() ? s.select('text') : mj; +} + /** * Find all margin pushers for 2D axes and reserve them for later use * Both label and rangeslider automargin calculations happen later so @@ -50473,14 +51797,17 @@ axes.allowAutoMargin = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; if(ax.automargin) { - Plots.allowAutoMargin(gd, ax._name + '.automargin'); + Plots.allowAutoMargin(gd, axAutoMarginID(ax)); } - if(ax.rangeslider && ax.rangeslider.visible) { - Plots.allowAutoMargin(gd, 'rangeslider' + ax._id); + if(Registry.getComponentMethod('rangeslider', 'isVisible')(ax)) { + Plots.allowAutoMargin(gd, rangeSliderAutoMarginID(ax)); } } }; +function axAutoMarginID(ax) { return ax._id + '.automargin'; } +function rangeSliderAutoMarginID(ax) { return ax._id + '.rangeslider'; } + // swap all the presentation attributes of the axes showing these traces axes.swap = function(gd, traces) { var axGroups = makeAxisGroups(gd, traces); @@ -50536,11 +51863,10 @@ function mergeAxisGroups(intoSet, fromSet) { } function swapAxisGroup(gd, xIds, yIds) { - var i, - j, - xFullAxes = [], - yFullAxes = [], - layout = gd.layout; + var xFullAxes = []; + var yFullAxes = []; + var layout = gd.layout; + var i, j; for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i])); for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i])); @@ -50553,12 +51879,12 @@ function swapAxisGroup(gd, xIds, yIds) { var numericTypes = ['linear', 'log']; for(i = 0; i < allAxKeys.length; i++) { - var keyi = allAxKeys[i], - xVal = xFullAxes[0][keyi], - yVal = yFullAxes[0][keyi], - allEqual = true, - coerceLinearX = false, - coerceLinearY = false; + var keyi = allAxKeys[i]; + var xVal = xFullAxes[0][keyi]; + var yVal = yFullAxes[0][keyi]; + var allEqual = true; + var coerceLinearX = false; + var coerceLinearY = false; if(keyi.charAt(0) === '_' || typeof xVal === 'function' || noSwapAttrs.indexOf(keyi) !== -1) { continue; @@ -50604,17 +51930,18 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes, dfltTitle) { // in case the value is the default for either axis, // look at the first axis in each list and see if // this key's value is undefined - var np = Lib.nestedProperty, - xVal = np(layout[xFullAxes[0]._name], key).get(), - yVal = np(layout[yFullAxes[0]._name], key).get(), - i; + var np = Lib.nestedProperty; + var xVal = np(layout[xFullAxes[0]._name], key).get(); + var yVal = np(layout[yFullAxes[0]._name], key).get(); + var i; + if(key === 'title') { // special handling of placeholder titles - if(xVal === dfltTitle.x) { - xVal = dfltTitle.y; + if(xVal && xVal.text === dfltTitle.x) { + xVal.text = dfltTitle.y; } - if(yVal === dfltTitle.y) { - yVal = dfltTitle.x; + if(yVal && yVal.text === dfltTitle.y) { + yVal.text = dfltTitle.x; } } @@ -50630,7 +51957,7 @@ function isAngular(ax) { return ax._id === 'angularaxis'; } -},{"../../components/color":43,"../../components/drawing":68,"../../components/titles":134,"../../constants/alignment":141,"../../constants/numerical":143,"../../lib":161,"../../lib/svg_text_utils":182,"../../plots/plots":238,"../../registry":245,"./autorange":204,"./axis_autotype":206,"./axis_ids":208,"./clean_ticks":210,"./layout_attributes":218,"./set_convert":224,"d3":8,"fast-isnumeric":10}],206:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/drawing":64,"../../components/titles":131,"../../constants/alignment":138,"../../constants/numerical":140,"../../lib":159,"../../lib/svg_text_utils":180,"../../plots/plots":236,"../../registry":243,"./autorange":202,"./axis_autotype":204,"./axis_ids":206,"./clean_ticks":208,"./layout_attributes":216,"./set_convert":222,"d3":8,"fast-isnumeric":10}],204:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50647,7 +51974,10 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var BADNUM = _dereq_('../../constants/numerical').BADNUM; -module.exports = function autoType(array, calendar) { +module.exports = function autoType(array, calendar, opts) { + opts = opts || {}; + + if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory'; if(moreDates(array, calendar)) return 'date'; if(category(array)) return 'category'; if(linearOK(array)) return 'linear'; @@ -50715,7 +52045,14 @@ function category(a) { return curvecats > curvenums * 2; } -},{"../../constants/numerical":143,"../../lib":161,"fast-isnumeric":10}],207:[function(_dereq_,module,exports){ +// very-loose requirements for multicategory, +// trace modules that should never auto-type to multicategory +// should be declared with 'noMultiCategory' +function multiCategory(a) { + return Lib.isArrayOrTypedArray(a[0]) && Lib.isArrayOrTypedArray(a[1]); +} + +},{"../../constants/numerical":140,"../../lib":159,"fast-isnumeric":10}],205:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50746,6 +52083,7 @@ var setConvert = _dereq_('./set_convert'); * outerTicks: boolean, should ticks default to outside? * showGrid: boolean, should gridlines be shown by default? * noHover: boolean, this axis doesn't support hover effects? + * noTickson: boolean, this axis doesn't support 'tickson' * data: the plot data, used to manage categories * bgColor: the plot background color, to calculate default gridline colors */ @@ -50786,8 +52124,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, // try to get default title from splom trace, fallback to graph-wide value var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter]; - coerce('title', dfltTitle); - Lib.coerceFont(coerce, 'titlefont', { + coerce('title.text', dfltTitle); + Lib.coerceFont(coerce, 'title.font', { family: font.family, size: Math.round(font.size * 1.2), color: dfltFontColor @@ -50807,10 +52145,29 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, if(options.automargin) coerce('automargin'); + var isMultiCategory = containerOut.type === 'multicategory'; + + if(!options.noTickson && + (containerOut.type === 'category' || isMultiCategory) && + (containerOut.ticks || containerOut.showgrid) + ) { + var ticksonDflt; + if(isMultiCategory) ticksonDflt = 'boundaries'; + coerce('tickson', ticksonDflt); + } + + if(isMultiCategory) { + var showDividers = coerce('showdividers'); + if(showDividers) { + coerce('dividercolor'); + coerce('dividerwidth'); + } + } + return containerOut; }; -},{"../../lib":161,"../../registry":245,"./category_order_defaults":209,"./layout_attributes":218,"./line_grid_defaults":220,"./set_convert":224,"./tick_label_defaults":225,"./tick_mark_defaults":226,"./tick_value_defaults":227}],208:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../registry":243,"./category_order_defaults":207,"./layout_attributes":216,"./line_grid_defaults":218,"./set_convert":222,"./tick_label_defaults":223,"./tick_mark_defaults":224,"./tick_value_defaults":225}],206:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50928,7 +52285,7 @@ exports.idSort = function(id1, id2) { return +(id1.substr(1) || 1) - +(id2.substr(1) || 1); }; -},{"../../registry":245,"./constants":211}],209:[function(_dereq_,module,exports){ +},{"../../registry":243,"./constants":209}],207:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51022,7 +52379,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],210:[function(_dereq_,module,exports){ +},{}],208:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51111,7 +52468,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":143,"../../lib":161,"fast-isnumeric":10}],211:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":159,"fast-isnumeric":10}],209:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51193,7 +52550,7 @@ module.exports = { } }; -},{"../../lib/regex":176}],212:[function(_dereq_,module,exports){ +},{"../../lib/regex":174}],210:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51347,7 +52704,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[scaleanchor] = 1; } -},{"../../lib":161,"./axis_ids":208}],213:[function(_dereq_,module,exports){ +},{"../../lib":159,"./axis_ids":206}],211:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51489,7 +52846,6 @@ exports.enforce = function enforceAxisConstraints(gd) { var getPad = makePadFn(ax); updateDomain(ax, factor); - ax.setScale(); var m = Math.abs(ax._m); var extremes = concatExtremes(gd, ax); var minArray = extremes.min; @@ -51556,9 +52912,10 @@ function updateDomain(ax, factor) { center + (inputDomain[0] - center) / factor, center + (inputDomain[1] - center) / factor ]; + ax.setScale(); } -},{"../../constants/alignment":141,"../../constants/numerical":143,"./autorange":204,"./axis_ids":208,"./scale_zoom":222}],214:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../constants/numerical":140,"./autorange":202,"./axis_ids":206,"./scale_zoom":220}],212:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51580,6 +52937,7 @@ var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Fx = _dereq_('../../components/fx'); +var Axes = _dereq_('./axes'); var setCursor = _dereq_('../../lib/setcursor'); var dragElement = _dereq_('../../components/dragelement'); var FROM_TL = _dereq_('../../constants/alignment').FROM_TL; @@ -51588,7 +52946,6 @@ var redrawReglTraces = _dereq_('../../plot_api/subroutines').redrawReglTraces; var Plots = _dereq_('../plots'); -var doTicksSingle = _dereq_('./axes').doTicksSingle; var getFromId = _dereq_('./axis_ids').getFromId; var prepSelect = _dereq_('./select').prepSelect; var clearSelect = _dereq_('./select').clearSelect; @@ -51832,7 +53189,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { .on('edit', function(text) { var v = ax.d2r(text); if(v !== undefined) { - Registry.call('relayout', gd, attrStr, v); + Registry.call('_guiRelayout', gd, attrStr, v); } }); } @@ -52077,6 +53434,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { return; } + // prevent axis drawing from monkeying with margins until we're done + gd._fullLayout._replotting = true; + if(xActive === 'ew' || yActive === 'ns') { if(xActive) dragAxList(xaxes, dx); if(yActive) dragAxList(yaxes, dy); @@ -52180,8 +53540,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { updates = {}; for(i = 0; i < activeAxIds.length; i++) { var axId = activeAxIds[i]; - doTicksSingle(gd, axId, true); var ax = getFromId(gd, axId); + Axes.drawOne(gd, ax, {skipTitle: true}); updates[ax._name + '.range[0]'] = ax.range[0]; updates[ax._name + '.range[1]'] = ax.range[1]; } @@ -52273,7 +53633,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, attrs); } // dragTail - finish a drag event with a redraw @@ -52287,7 +53647,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // accumulated MathJax promises - wait for them before we relayout. Lib.syncOrAsync([ Plots.previousPromises, - function() { Registry.call('relayout', gd, updates); } + function() { + gd._fullLayout._replotting = false; + Registry.call('_guiRelayout', gd, updates); + } ], gd); } @@ -52745,7 +54108,7 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":43,"../../components/dragelement":65,"../../components/drawing":68,"../../components/fx":85,"../../constants/alignment":141,"../../lib":161,"../../lib/clear_gl_canvases":150,"../../lib/setcursor":180,"../../lib/svg_text_utils":182,"../../plot_api/subroutines":196,"../../registry":245,"../plots":238,"./axes":205,"./axis_ids":208,"./constants":211,"./scale_zoom":222,"./select":223,"d3":8,"has-passive-events":13,"tinycolor2":26}],215:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/dragelement":61,"../../components/drawing":64,"../../components/fx":82,"../../constants/alignment":138,"../../lib":159,"../../lib/clear_gl_canvases":148,"../../lib/setcursor":178,"../../lib/svg_text_utils":180,"../../plot_api/subroutines":194,"../../registry":243,"../plots":236,"./axes":203,"./axis_ids":206,"./constants":209,"./scale_zoom":220,"./select":221,"d3":8,"has-passive-events":13,"tinycolor2":26}],213:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52913,7 +54276,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":65,"../../components/fx":85,"../../lib/setcursor":180,"./constants":211,"./dragbox":214,"d3":8}],216:[function(_dereq_,module,exports){ +},{"../../components/dragelement":61,"../../components/fx":82,"../../lib/setcursor":178,"./constants":209,"./dragbox":212,"d3":8}],214:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52988,7 +54351,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":161,"../../registry":245}],217:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../registry":243}],215:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53253,7 +54616,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback // layers that allow `cliponaxis: false` if(className !== 'scatterlayer' && className !== 'barlayer') { - Drawing.setClipUrl(sel, plotinfo.layerClipId); + Drawing.setClipUrl(sel, plotinfo.layerClipId, gd); } }); @@ -53611,7 +54974,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":68,"../../constants/xmlns_namespaces":144,"../../lib":161,"../../registry":245,"../get_data":234,"../plots":238,"./attributes":203,"./axis_ids":208,"./constants":211,"./graph_interact":215,"./layout_attributes":218,"./layout_defaults":219,"./transition_axes":228,"d3":8}],218:[function(_dereq_,module,exports){ +},{"../../components/drawing":64,"../../constants/xmlns_namespaces":141,"../../lib":159,"../../registry":243,"../get_data":232,"../plots":236,"./attributes":201,"./axis_ids":206,"./constants":209,"./graph_interact":213,"./layout_attributes":216,"./layout_defaults":217,"./transition_axes":226,"d3":8}],216:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53646,21 +55009,24 @@ module.exports = { }, title: { - valType: 'string', - - editType: 'ticks', - + text: { + valType: 'string', + + editType: 'ticks', + + }, + font: fontAttrs({ + editType: 'ticks', + + }), + editType: 'ticks' }, - titlefont: fontAttrs({ - editType: 'ticks', - - }), type: { valType: 'enumerated', // '-' means we haven't yet run autotype or couldn't find any data // it gets turned into linear in gd._fullLayout but not copied back // to gd.data like the others are. - values: ['-', 'linear', 'log', 'date', 'category'], + values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', editType: 'calc', @@ -53789,6 +55155,14 @@ module.exports = { editType: 'ticks', + }, + tickson: { + valType: 'enumerated', + values: ['labels', 'boundaries'], + + dflt: 'labels', + editType: 'ticks', + }, mirror: { valType: 'enumerated', @@ -54042,6 +55416,30 @@ module.exports = { editType: 'ticks', }, + + showdividers: { + valType: 'boolean', + dflt: true, + + editType: 'ticks', + + }, + dividercolor: { + valType: 'color', + dflt: colorAttrs.defaultLine, + + editType: 'ticks', + + }, + dividerwidth: { + valType: 'number', + dflt: 1, + + editType: 'ticks', + + }, + // TODO dividerlen: that would override "to label base" length? + // positioning attributes // anchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -54123,6 +55521,12 @@ module.exports = { editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'calc', @@ -54132,11 +55536,21 @@ module.exports = { editType: 'ticks', - } + }, + title: { + valType: 'string', + + editType: 'ticks', + + }, + titlefont: fontAttrs({ + editType: 'ticks', + + }) } }; -},{"../../components/color/attributes":42,"../../components/drawing/attributes":67,"../../lib/extend":155,"../../plot_api/plot_template":195,"../font_attributes":232,"./constants":211}],219:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":42,"../../components/drawing/attributes":63,"../../lib/extend":153,"../../plot_api/plot_template":193,"../font_attributes":230,"./constants":209}],217:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54295,9 +55709,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; }); axLayoutOut._annIndices = []; axLayoutOut._shapeIndices = []; + axLayoutOut._subplotsWith = []; + axLayoutOut._counterAxes = []; // set up some private properties - axLayoutOut._name = axName; + axLayoutOut._name = axLayoutOut._attr = axName; var id = axLayoutOut._id = name2id(axName); var overlayableAxes = getOverlayableAxes(axLetter, axName); @@ -54315,6 +55731,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id] }; + coerce('uirevision', layoutOut.uirevision); + handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions); handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut); @@ -54376,11 +55794,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var anchoredAxis = layoutOut[id2name(axLayoutOut.anchor)]; - var fixedRangeDflt = ( - anchoredAxis && - anchoredAxis.rangeslider && - anchoredAxis.rangeslider.visible - ); + var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis); coerce('fixedrange', fixedRangeDflt); } @@ -54405,7 +55819,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } }; -},{"../../components/color":43,"../../lib":161,"../../plot_api/plot_template":195,"../../registry":245,"../layout_attributes":236,"./axis_defaults":207,"./axis_ids":208,"./constraint_defaults":212,"./layout_attributes":218,"./position_defaults":221,"./type_defaults":229}],220:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../lib":159,"../../plot_api/plot_template":193,"../../registry":243,"../layout_attributes":234,"./axis_defaults":205,"./axis_ids":206,"./constraint_defaults":210,"./layout_attributes":216,"./position_defaults":219,"./type_defaults":227}],218:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54470,7 +55884,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":42,"../../lib":161,"tinycolor2":26}],221:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":42,"../../lib":159,"tinycolor2":26}],219:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54554,7 +55968,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":161,"fast-isnumeric":10}],222:[function(_dereq_,module,exports){ +},{"../../lib":159,"fast-isnumeric":10}],220:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54582,7 +55996,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ]; }; -},{"../../constants/alignment":141}],223:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138}],221:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55251,13 +56665,22 @@ function isOnlyOnePointSelected(searchTraces) { function updateSelectedState(gd, searchTraces, eventData) { var i, searchInfo, cd, trace; + // before anything else, update preGUI if necessary + for(i = 0; i < searchTraces.length; i++) { + var fullInputTrace = searchTraces[i].cd[0].trace._fullInput; + var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid]; + if(tracePreGUI.selectedpoints === undefined) { + tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null; + } + } + if(eventData) { var pts = eventData.points || []; for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; - trace.selectedpoints = []; - trace._input.selectedpoints = []; + trace._input.selectedpoints = trace._fullInput.selectedpoints = []; + if(trace._fullInput !== trace) trace.selectedpoints = []; } for(i = 0; i < pts.length; i++) { @@ -55267,10 +56690,14 @@ function updateSelectedState(gd, searchTraces, eventData) { if(pt.pointIndices) { [].push.apply(data.selectedpoints, pt.pointIndices); - [].push.apply(fullData.selectedpoints, pt.pointIndices); + if(trace._fullInput !== trace) { + [].push.apply(fullData.selectedpoints, pt.pointIndices); + } } else { data.selectedpoints.push(pt.pointIndex); - fullData.selectedpoints.push(pt.pointIndex); + if(trace._fullInput !== trace) { + fullData.selectedpoints.push(pt.pointIndex); + } } } } @@ -55279,6 +56706,9 @@ function updateSelectedState(gd, searchTraces, eventData) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; delete trace._input.selectedpoints; + if(trace._fullInput !== trace) { + delete trace._fullInput.selectedpoints; + } } } @@ -55356,7 +56786,7 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":43,"../../components/fx":85,"../../components/fx/helpers":82,"../../lib/clear_gl_canvases":150,"../../lib/polygon":173,"../../lib/throttle":183,"../../plot_api/subroutines":196,"../../registry":245,"./axis_ids":208,"./constants":211,"polybooljs":17}],224:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/fx":82,"../../components/fx/helpers":78,"../../lib/clear_gl_canvases":148,"../../lib/polygon":171,"../../lib/throttle":181,"../../plot_api/subroutines":194,"../../registry":243,"./axis_ids":206,"./constants":209,"polybooljs":17}],222:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55389,6 +56819,10 @@ function fromLog(v) { return Math.pow(10, v); } +function isValidCategory(v) { + return v !== null && v !== undefined; +} + /** * Define the conversion functions for an axis data is used in 5 ways: * @@ -55482,7 +56916,7 @@ module.exports = function setConvert(ax, fullLayout) { * a disconnect between the array and the index returned */ function setCategoryIndex(v) { - if(v !== null && v !== undefined) { + if(isValidCategory(v)) { if(ax._categoriesMap === undefined) { ax._categoriesMap = {}; } @@ -55501,14 +56935,58 @@ module.exports = function setConvert(ax, fullLayout) { return BADNUM; } + function setMultiCategoryIndex(arrayIn, len) { + var arrayOut = new Array(len); + var i; + + // [ [arrayIn[0][i], arrayIn[1][i]], for i .. len ] + var tmp = new Array(len); + // [ [cnt, {$cat: index}], for j .. arrayIn.length ] + var seen = [[0, {}], [0, {}]]; + + if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) { + for(i = 0; i < len; i++) { + var v0 = arrayIn[0][i]; + var v1 = arrayIn[1][i]; + if(isValidCategory(v0) && isValidCategory(v1)) { + tmp[i] = [v0, v1]; + if(!(v0 in seen[0][1])) { + seen[0][1][v0] = seen[0][0]++; + } + if(!(v1 in seen[1][1])) { + seen[1][1][v1] = seen[1][0]++; + } + } + } + + tmp.sort(function(a, b) { + var ind0 = seen[0][1]; + var d = ind0[a[0]] - ind0[b[0]]; + if(d) return d; + + var ind1 = seen[1][1]; + return ind1[a[1]] - ind1[b[1]]; + }); + } + + for(i = 0; i < len; i++) { + arrayOut[i] = setCategoryIndex(tmp[i]); + } + + return arrayOut; + } + function getCategoryIndex(v) { - // d2l/d2c variant that that won't add categories but will also - // allow numbers to be mapped to the linearized axis positions if(ax._categoriesMap) { - var index = ax._categoriesMap[v]; - if(index !== undefined) return index; + return ax._categoriesMap[v]; } + } + function getCategoryPosition(v) { + // d2l/d2c variant that that won't add categories but will also + // allow numbers to be mapped to the linearized axis positions + var index = getCategoryIndex(v); + if(index !== undefined) return index; if(isNumeric(v)) return +v; } @@ -55594,15 +57072,15 @@ module.exports = function setConvert(ax, fullLayout) { ax.d2c = ax.d2l = setCategoryIndex; ax.r2d = ax.c2d = ax.l2d = getCategoryName; - ax.d2r = ax.d2l_noadd = getCategoryIndex; + ax.d2r = ax.d2l_noadd = getCategoryPosition; ax.r2c = function(v) { - var index = getCategoryIndex(v); + var index = getCategoryPosition(v); return index !== undefined ? index : ax.fraction2r(0.5); }; ax.l2r = ax.c2r = ensureNumber; - ax.r2l = getCategoryIndex; + ax.r2l = getCategoryPosition; ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; ax.p2d = function(px) { return getCategoryName(p2l(px)); }; @@ -55614,6 +57092,34 @@ module.exports = function setConvert(ax, fullLayout) { return ensureNumber(v); }; } + else if(ax.type === 'multicategory') { + // N.B. multicategory axes don't define d2c and d2l, + // as 'data-to-calcdata' conversion needs to take into + // account all data array items as in ax.makeCalcdata. + + ax.r2d = ax.c2d = ax.l2d = getCategoryName; + ax.d2r = ax.d2l_noadd = getCategoryPosition; + + ax.r2c = function(v) { + var index = getCategoryPosition(v); + return index !== undefined ? index : ax.fraction2r(0.5); + }; + + ax.r2c_just_indices = getCategoryIndex; + + ax.l2r = ax.c2r = ensureNumber; + ax.r2l = getCategoryPosition; + + ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; + ax.p2d = function(px) { return getCategoryName(p2l(px)); }; + ax.r2p = ax.d2p; + ax.p2r = p2l; + + ax.cleanPos = function(v) { + if(Array.isArray(v) || (typeof v === 'string' && v !== '')) return v; + return ensureNumber(v); + }; + } // find the range value at the specified (linear) fraction of the axis ax.fraction2r = function(v) { @@ -55707,11 +57213,6 @@ module.exports = function setConvert(ax, fullLayout) { ax.setScale = function(usePrivateRange) { var gs = fullLayout._size; - // TODO cleaner way to handle this case - if(!ax._categories) ax._categories = []; - // Add a map to optimize the performance of category collection - if(!ax._categoriesMap) ax._categoriesMap = {}; - // make sure we have a domain (pull it in from the axis // this one is overlaying if necessary) if(ax.overlaying) { @@ -55766,7 +57267,7 @@ module.exports = function setConvert(ax, fullLayout) { if(axLetter in trace) { arrayIn = trace[axLetter]; - len = trace._length || arrayIn.length; + len = trace._length || Lib.minRowLength(arrayIn); if(Lib.isTypedArray(arrayIn) && (axType === 'linear' || axType === 'log')) { if(len === arrayIn.length) { @@ -55776,6 +57277,10 @@ module.exports = function setConvert(ax, fullLayout) { } } + if(axType === 'multicategory') { + return setMultiCategoryIndex(arrayIn, len); + } + arrayOut = new Array(len); for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); @@ -55852,7 +57357,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":143,"../../lib":161,"./axis_ids":208,"./constants":211,"d3":8,"fast-isnumeric":10}],225:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":159,"./axis_ids":206,"./constants":209,"d3":8,"fast-isnumeric":10}],223:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55953,7 +57458,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../lib":161,"../array_container_defaults":201,"./layout_attributes":218}],226:[function(_dereq_,module,exports){ +},{"../../lib":159,"../array_container_defaults":199,"./layout_attributes":216}],224:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55986,7 +57491,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":161,"./layout_attributes":218}],227:[function(_dereq_,module,exports){ +},{"../../lib":159,"./layout_attributes":216}],225:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55995,22 +57500,18 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); - module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { var tickmode; if(containerIn.tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; - } - else { - var tickmodeDefault = - Array.isArray(containerIn.tickvals) ? 'array' : + } else { + var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : containerIn.dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); @@ -56025,15 +57526,14 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe containerIn.dtick, axType); containerOut.tick0 = cleanTicks.tick0( containerIn.tick0, axType, containerOut.calendar, dtick); - } - else { + } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto'; else coerce('ticktext'); } }; -},{"./clean_ticks":210}],228:[function(_dereq_,module,exports){ +},{"./clean_ticks":208}],226:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56155,14 +57655,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo } function ticksAndAnnotations(xa, ya) { - var activeAxIds = [], - i; - - activeAxIds = [xa._id, ya._id]; + var activeAxIds = [xa._id, ya._id]; + var i; - for(i = 0; i < activeAxIds.length; i++) { - Axes.doTicksSingle(gd, activeAxIds[i], true); - } + Axes.drawOne(gd, xa, {skipTitle: true}); + Axes.drawOne(gd, ya, {skipTitle: true}); function redrawObjs(objArray, method, shortCircuit) { for(i = 0; i < objArray.length; i++) { @@ -56361,7 +57858,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo return Promise.resolve(); }; -},{"../../components/drawing":68,"../../registry":245,"./axes":205,"./constants":211,"d3":8}],229:[function(_dereq_,module,exports){ +},{"../../components/drawing":64,"../../registry":243,"./axes":203,"./constants":209,"d3":8}],227:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56372,7 +57869,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo 'use strict'; -var Registry = _dereq_('../../registry'); +var traceIs = _dereq_('../../registry').traceIs; var autoType = _dereq_('./axis_autotype'); /* @@ -56421,6 +57918,7 @@ function setAutoType(ax, data) { var calAttr = axLetter + 'calendar'; var calendar = d0[calAttr]; + var opts = {noMultiCategory: !traceIs(d0, 'cartesian') || traceIs(d0, 'noMultiCategory')}; var i; // check all boxes on this x axis to see @@ -56431,8 +57929,7 @@ function setAutoType(ax, data) { for(i = 0; i < data.length; i++) { var trace = data[i]; - if(!Registry.traceIs(trace, 'box-violin') || - (trace[axLetter + 'axis'] || axLetter) !== id) continue; + if(!traceIs(trace, 'box-violin') || (trace[axLetter + 'axis'] || axLetter) !== id) continue; if(trace[posLetter] !== undefined) boxPositions.push(trace[posLetter][0]); else if(trace.name !== undefined) boxPositions.push(trace.name); @@ -56441,7 +57938,7 @@ function setAutoType(ax, data) { if(trace[calAttr] !== calendar) calendar = undefined; } - ax.type = autoType(boxPositions, calendar); + ax.type = autoType(boxPositions, calendar, opts); } else if(d0.type === 'splom') { var dimensions = d0.dimensions; @@ -56449,13 +57946,13 @@ function setAutoType(ax, data) { for(i = 0; i < dimensions.length; i++) { var dim = dimensions[i]; if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) { - ax.type = autoType(dim.values, calendar); + ax.type = autoType(dim.values, calendar, opts); break; } } } else { - ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar); + ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -56486,9 +57983,9 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace), - isBox = Registry.traceIs(trace, 'box-violin'), - isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); + var posLetter = getBoxPosLetter(trace); + var isBox = traceIs(trace, 'box-violin'); + var isCandlestick = traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox && @@ -56499,7 +57996,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":245,"./axis_autotype":206}],230:[function(_dereq_,module,exports){ +},{"../../registry":243,"./axis_autotype":204}],228:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56923,7 +58420,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":161,"../registry":245}],231:[function(_dereq_,module,exports){ +},{"../lib":159,"../registry":243}],229:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57031,7 +58528,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { coerce('domain.y', dfltY); }; -},{"../lib/extend":155}],232:[function(_dereq_,module,exports){ +},{"../lib/extend":153}],230:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57096,7 +58593,7 @@ module.exports = function(opts) { return attrs; }; -},{}],233:[function(_dereq_,module,exports){ +},{}],231:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57142,7 +58639,7 @@ module.exports = { } }; -},{}],234:[function(_dereq_,module,exports){ +},{}],232:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57270,7 +58767,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":245,"./cartesian/constants":211}],235:[function(_dereq_,module,exports){ +},{"../registry":243,"./cartesian/constants":209}],233:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57304,7 +58801,7 @@ function project(camera, v) { module.exports = project; -},{}],236:[function(_dereq_,module,exports){ +},{}],234:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57317,6 +58814,9 @@ module.exports = project; var fontAttrs = _dereq_('./font_attributes'); var colorAttrs = _dereq_('../components/color/attributes'); +var colorscaleAttrs = _dereq_('../components/colorscale/layout_attributes'); +var padAttrs = _dereq_('./pad_attributes'); +var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', @@ -57329,15 +58829,71 @@ globalFont.color.dflt = colorAttrs.defaultLine; module.exports = { font: globalFont, title: { - valType: 'string', - - editType: 'layoutstyle', - + text: { + valType: 'string', + + editType: 'layoutstyle', + + }, + font: fontAttrs({ + editType: 'layoutstyle', + + }), + xref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + yref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + x: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.5, + + editType: 'layoutstyle', + + }, + y: { + valType: 'number', + min: 0, + max: 1, + dflt: 'auto', + + editType: 'layoutstyle', + + }, + xanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'left', 'center', 'right'], + + editType: 'layoutstyle', + + }, + yanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'top', 'middle', 'bottom'], + + editType: 'layoutstyle', + + }, + pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { + + }), + editType: 'layoutstyle' }, - titlefont: fontAttrs({ - editType: 'layoutstyle', - - }), autosize: { valType: 'boolean', @@ -57456,11 +59012,30 @@ module.exports = { editType: 'calc', }, + colorscale: colorscaleAttrs, datarevision: { valType: 'any', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editrevision: { + valType: 'any', + + editType: 'none', + + }, + selectionrevision: { + valType: 'any', + + editType: 'none', + }, template: { valType: 'any', @@ -57494,12 +59069,30 @@ module.exports = { editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'modebar' + }, + _deprecated: { + title: { + valType: 'string', + + editType: 'layoutstyle', + + }, + titlefont: fontAttrs({ + editType: 'layoutstyle', + + }) } }; -},{"../components/color/attributes":42,"./font_attributes":232}],237:[function(_dereq_,module,exports){ +},{"../components/color/attributes":42,"../components/colorscale/layout_attributes":56,"../lib/extend":153,"./font_attributes":230,"./pad_attributes":235}],235:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57510,42 +59103,51 @@ module.exports = { 'use strict'; -// This is used exclusively by components inside component arrays, -// hence the 'arraydraw' editType. If this ever gets used elsewhere -// we could generalize it as a function ala font_attributes -module.exports = { - t: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - r: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - b: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - l: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - editType: 'arraydraw' +/** + * Creates a set of padding attributes. + * + * @param {object} opts + * @param {string} editType: + * the editType for all pieces of this padding definition + * + * @return {object} attributes object containing {t, r, b, l} as specified + */ +module.exports = function(opts) { + var editType = opts.editType; + return { + t: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + r: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + b: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + l: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + editType: editType + }; }; -},{}],238:[function(_dereq_,module,exports){ +},{}],236:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57997,6 +59599,7 @@ plots.supplyDefaults = function(gd, opts) { for(i = 0; i < crossTraceDefaultsFuncs.length; i++) { crossTraceDefaultsFuncs[i](newFullData, newFullLayout); } + Registry.getComponentMethod('colorscale', 'crossTraceDefaults')(newFullData, newFullLayout); // turn on flag to optimize large splom-only graphs // mostly by omitting SVG layers during Cartesian.drawFramework @@ -58027,16 +59630,30 @@ plots.supplyDefaults = function(gd, opts) { // relink functions and _ attributes to promote consistency between plots relinkPrivateKeys(newFullLayout, oldFullLayout); - // TODO may return a promise - plots.doAutoMargin(gd); - - // set scale after auto margin routine - var axList = axisIDs.list(gd); - for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - ax.setScale(); + // For persisting GUI-driven changes in layout + // _preGUI and _tracePreGUI were already copied over in relinkPrivateKeys + if(!newFullLayout._preGUI) newFullLayout._preGUI = {}; + // track trace GUI changes by uid rather than by trace index + if(!newFullLayout._tracePreGUI) newFullLayout._tracePreGUI = {}; + var tracePreGUI = newFullLayout._tracePreGUI; + var uids = {}; + var uid; + for(uid in tracePreGUI) uids[uid] = 'old'; + for(i = 0; i < newFullData.length; i++) { + uid = newFullData[i]._fullInput.uid; + if(!uids[uid]) tracePreGUI[uid] = {}; + uids[uid] = 'new'; + } + for(uid in uids) { + if(uids[uid] === 'old') delete tracePreGUI[uid]; } + // set up containers for margin calculations + initMargins(newFullLayout); + + // collect and do some initial calculations for rangesliders + Registry.getComponentMethod('rangeslider', 'makeData')(newFullLayout); + // update object references in calcdata if(!skipUpdateCalc && oldCalcdata.length === newFullData.length) { plots.supplyDefaultsUpdateCalc(oldCalcdata, newFullData); @@ -58345,6 +59962,12 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa plotinfo.id = id; } + // add these axis ids to each others' subplot lists + xaxis._counterAxes.push(yaxis._id); + yaxis._counterAxes.push(xaxis._id); + xaxis._subplotsWith.push(id); + yaxis._subplotsWith.push(id); + // update x and y axis layout object refs plotinfo.xaxis = xaxis; plotinfo.yaxis = yaxis; @@ -58372,8 +59995,9 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // while we're at it, link overlaying axes to their main axes and // anchored axes to the axes they're anchored to var axList = axisIDs.list(mockGd, null, true); + var ax; for(i = 0; i < axList.length; i++) { - var ax = axList[i]; + ax = axList[i]; var mainAx = null; if(ax.overlaying) { @@ -58401,8 +60025,53 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa null : axisIDs.getFromId(mockGd, ax.anchor); } + + // finally, we can find the main subplot for each axis + // (on which the ticks & labels are drawn) + for(i = 0; i < axList.length; i++) { + ax = axList[i]; + ax._counterAxes.sort(axisIDs.idSort); + ax._subplotsWith.sort(Lib.subplotSort); + ax._mainSubplot = findMainSubplot(ax, newFullLayout); + } }; +function findMainSubplot(ax, fullLayout) { + var mockGd = {_fullLayout: fullLayout}; + + var isX = ax._id.charAt(0) === 'x'; + var anchorAx = ax._mainAxis._anchorAxis; + var mainSubplotID = ''; + var nextBestMainSubplotID = ''; + var anchorID = ''; + + // First try the main ID with the anchor + if(anchorAx) { + anchorID = anchorAx._mainAxis._id; + mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); + } + + // Then look for a subplot with the counteraxis overlaying the anchor + // If that fails just use the first subplot including this axis + if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { + mainSubplotID = ''; + + var counterIDs = ax._counterAxes; + for(var j = 0; j < counterIDs.length; j++) { + var counterPart = counterIDs[j]; + var id = isX ? (ax._id + counterPart) : (counterPart + ax._id); + if(!nextBestMainSubplotID) nextBestMainSubplotID = id; + var counterAx = axisIDs.getFromId(mockGd, counterPart); + if(anchorID && counterAx.overlaying === anchorID) { + mainSubplotID = id; + break; + } + } + } + + return mainSubplotID || nextBestMainSubplotID; +} + // This function clears any trace attributes with valType: color and // no set dflt filed in the plot schema. This is needed because groupby (which // is the only transform for which this currently applies) supplies parent @@ -58670,6 +60339,8 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac coerce('type'); coerce('name', layout._traceWord + ' ' + traceInIndex); + coerce('uirevision', layout.uirevision); + // we want even invisible traces to make their would-be subplots visible // so coerce the subplot id(s) now no matter what var _module = plots.getModule(traceOut); @@ -58743,7 +60414,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac if(_module) { _module.supplyDefaults(traceIn, traceOut, defaultColor, layout); - Lib.coerceHoverinfo(traceIn, traceOut, layout); + if(!traceOut.hovertemplate) Lib.coerceHoverinfo(traceIn, traceOut, layout); } if(!Registry.traceIs(traceOut, 'noOpacity')) coerce('opacity'); @@ -58872,14 +60543,25 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { var globalFont = Lib.coerceFont(coerce, 'font'); - coerce('title', layoutOut._dfltTitle.plot); + coerce('title.text', layoutOut._dfltTitle.plot); - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: globalFont.family, size: Math.round(globalFont.size * 1.4), color: globalFont.color }); + coerce('title.xref'); + coerce('title.yref'); + coerce('title.x'); + coerce('title.y'); + coerce('title.xanchor'); + coerce('title.yanchor'); + coerce('title.pad.t'); + coerce('title.pad.r'); + coerce('title.pad.b'); + coerce('title.pad.l'); + // Make sure that autosize is defaulted to *true* // on layouts with no set width and height for backward compatibly, // in particular https://plot.ly/javascript/responsive-fluid-layout/ @@ -58912,12 +60594,16 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('colorway'); coerce('datarevision'); + var uirevision = coerce('uirevision'); + coerce('editrevision', uirevision); + coerce('selectionrevision', uirevision); coerce('modebar.orientation'); coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); + coerce('modebar.uirevision', uirevision); Registry.getComponentMethod( 'calendars', @@ -59199,7 +60885,20 @@ plots.allowAutoMargin = function(gd, id) { gd._fullLayout._pushmarginIds[id] = 1; }; -function setupAutoMargin(fullLayout) { +function initMargins(fullLayout) { + var margin = fullLayout.margin; + + if(!fullLayout._size) { + var gs = fullLayout._size = { + l: Math.round(margin.l), + r: Math.round(margin.r), + t: Math.round(margin.t), + b: Math.round(margin.b), + p: Math.round(margin.pad) + }; + gs.w = Math.round(fullLayout.width) - gs.l - gs.r; + gs.h = Math.round(fullLayout.height) - gs.t - gs.b; + } if(!fullLayout._pushmargin) fullLayout._pushmargin = {}; if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {}; } @@ -59222,8 +60921,6 @@ function setupAutoMargin(fullLayout) { plots.autoMargin = function(gd, id, o) { var fullLayout = gd._fullLayout; - setupAutoMargin(fullLayout); - var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -59267,18 +60964,19 @@ plots.autoMargin = function(gd, id, o) { plots.doAutoMargin = function(gd) { var fullLayout = gd._fullLayout; if(!fullLayout._size) fullLayout._size = {}; - setupAutoMargin(fullLayout); + initMargins(fullLayout); - var gs = fullLayout._size, - oldmargins = JSON.stringify(gs); + var gs = fullLayout._size; + var oldmargins = JSON.stringify(gs); + var margin = fullLayout.margin; // adjust margins for outside components // fullLayout.margin is the requested margin, // fullLayout._size has margins and plotsize after adjustment - var ml = Math.max(fullLayout.margin.l || 0, 0); - var mr = Math.max(fullLayout.margin.r || 0, 0); - var mt = Math.max(fullLayout.margin.t || 0, 0); - var mb = Math.max(fullLayout.margin.b || 0, 0); + var ml = margin.l; + var mr = margin.r; + var mt = margin.t; + var mb = margin.b; var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -59348,7 +61046,7 @@ plots.doAutoMargin = function(gd) { gs.r = Math.round(mr); gs.t = Math.round(mt); gs.b = Math.round(mb); - gs.p = Math.round(fullLayout.margin.pad); + gs.p = Math.round(margin.pad); gs.w = Math.round(fullLayout.width) - gs.l - gs.r; gs.h = Math.round(fullLayout.height) - gs.t - gs.b; @@ -60229,7 +61927,7 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl subplot.traceHash = traceHash; }; -},{"../components/color":43,"../constants/numerical":143,"../lib":161,"../plot_api/plot_schema":194,"../plot_api/plot_template":195,"../plots/cartesian/axis_ids":208,"../registry":245,"./animation_attributes":200,"./attributes":202,"./command":230,"./font_attributes":232,"./frame_attributes":233,"./layout_attributes":236,"d3":8,"fast-isnumeric":10}],239:[function(_dereq_,module,exports){ +},{"../components/color":43,"../constants/numerical":140,"../lib":159,"../plot_api/plot_schema":192,"../plot_api/plot_template":193,"../plots/cartesian/axis_ids":206,"../registry":243,"./animation_attributes":198,"./attributes":200,"./command":228,"./font_attributes":230,"./frame_attributes":231,"./layout_attributes":234,"d3":8,"fast-isnumeric":10}],237:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60273,7 +61971,7 @@ module.exports = { } }; -},{"../../../lib/extend":155,"../../../traces/scatter/attributes":282}],240:[function(_dereq_,module,exports){ +},{"../../../lib/extend":153,"../../../traces/scatter/attributes":281}],238:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60395,7 +62093,7 @@ module.exports = overrideAll({ } }, 'plot', 'nested'); -},{"../../../lib/extend":155,"../../../plot_api/edit_types":188,"../../cartesian/layout_attributes":218}],241:[function(_dereq_,module,exports){ +},{"../../../lib/extend":153,"../../../plot_api/edit_types":186,"../../cartesian/layout_attributes":216}],239:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60410,7 +62108,7 @@ var Polar = module.exports = _dereq_('./micropolar'); Polar.manager = _dereq_('./micropolar_manager'); -},{"./micropolar":242,"./micropolar_manager":243}],242:[function(_dereq_,module,exports){ +},{"./micropolar":240,"./micropolar_manager":241}],240:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60628,8 +62326,8 @@ var µ = module.exports = { version: '0.2.2' }; centeringOffset[0] = Math.max(0, centeringOffset[0]); centeringOffset[1] = Math.max(0, centeringOffset[1]); svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title); + if (axisConfig.title && axisConfig.title.text) { + var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); var titleBBox = title.node().getBBox(); title.attr({ x: chartCenter[0] - titleBBox.width / 2, @@ -61830,7 +63528,7 @@ var µ = module.exports = { version: '0.2.2' }; return exports; }; -},{"../../../constants/alignment":141,"../../../lib":161,"d3":8}],243:[function(_dereq_,module,exports){ +},{"../../../constants/alignment":138,"../../../lib":159,"d3":8}],241:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61916,7 +63614,7 @@ manager.fillLayout = function(_gd) { _gd._fullLayout = extendDeepAll(dflts, _gd.layout); }; -},{"../../../components/color":43,"../../../lib":161,"./micropolar":242,"./undo_manager":244,"d3":8}],244:[function(_dereq_,module,exports){ +},{"../../../components/color":43,"../../../lib":159,"./micropolar":240,"./undo_manager":242,"d3":8}],242:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61982,7 +63680,7 @@ module.exports = function UndoManager() { }; }; -},{}],245:[function(_dereq_,module,exports){ +},{}],243:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62424,7 +64122,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/extend":155,"./lib/is_plain_object":162,"./lib/loggers":165,"./lib/noop":170,"./lib/push_unique":174,"./plots/attributes":202,"./plots/layout_attributes":236}],246:[function(_dereq_,module,exports){ +},{"./lib/extend":153,"./lib/is_plain_object":160,"./lib/loggers":163,"./lib/noop":168,"./lib/push_unique":172,"./plots/attributes":200,"./plots/layout_attributes":234}],244:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62451,7 +64149,7 @@ function cloneLayoutOverride(tileClass) { autosize: true, width: 150, height: 150, - title: '', + title: {text: ''}, showlegend: false, margin: {l: 5, r: 5, t: 5, b: 5, pad: 0}, annotations: [] @@ -62460,7 +64158,7 @@ function cloneLayoutOverride(tileClass) { case 'thumbnail': override = { - title: '', + title: {text: ''}, hidesources: true, showlegend: false, borderwidth: 0, @@ -62508,7 +64206,7 @@ module.exports = function clonePlot(graphObj, options) { for(i = 0; i < keys.length; i++) { if(keyIsAxis(keys[i])) { - newLayout[keys[i]].title = ''; + newLayout[keys[i]].title = {text: ''}; } } @@ -62536,7 +64234,7 @@ module.exports = function clonePlot(graphObj, options) { var axesImageOverride = {}; if(options.tileClass === 'thumbnail') { axesImageOverride = { - title: '', + title: {text: ''}, showaxeslabels: false, showticklabels: false, linetickenable: false @@ -62598,7 +64296,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":161}],247:[function(_dereq_,module,exports){ +},{"../lib":159}],245:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62666,7 +64364,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":161,"../plot_api/to_image":198,"./filesaver":248}],248:[function(_dereq_,module,exports){ +},{"../lib":159,"../plot_api/to_image":196,"./filesaver":246}],246:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62738,7 +64436,7 @@ var fileSaver = function(url, name) { module.exports = fileSaver; -},{}],249:[function(_dereq_,module,exports){ +},{}],247:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62775,7 +64473,7 @@ exports.getRedrawFunc = function(gd) { }; }; -},{}],250:[function(_dereq_,module,exports){ +},{}],248:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62801,7 +64499,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":246,"./download":247,"./helpers":249,"./svgtoimg":251,"./toimage":252,"./tosvg":253}],251:[function(_dereq_,module,exports){ +},{"./cloneplot":244,"./download":245,"./helpers":247,"./svgtoimg":249,"./toimage":250,"./tosvg":251}],249:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62917,7 +64615,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":161,"events":7}],252:[function(_dereq_,module,exports){ +},{"../lib":159,"events":7}],250:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62996,7 +64694,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":161,"../registry":245,"./cloneplot":246,"./helpers":249,"./svgtoimg":251,"./tosvg":253,"events":7}],253:[function(_dereq_,module,exports){ +},{"../lib":159,"../registry":243,"./cloneplot":244,"./helpers":247,"./svgtoimg":249,"./tosvg":251,"events":7}],251:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63178,7 +64876,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":43,"../components/drawing":68,"../constants/xmlns_namespaces":144,"../lib":161,"d3":8}],254:[function(_dereq_,module,exports){ +},{"../components/color":43,"../components/drawing":64,"../constants/xmlns_namespaces":141,"../lib":159,"d3":8}],252:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63213,7 +64911,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":161}],255:[function(_dereq_,module,exports){ +},{"../../lib":159}],253:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63225,9 +64923,11 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); +var constants = _dereq_('./constants.js'); var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -63276,6 +64976,9 @@ module.exports = { text: scatterAttrs.text, hovertext: scatterAttrs.hovertext, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), textposition: { valType: 'enumerated', @@ -63383,7 +65086,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":44,"../../components/colorscale/attributes":50,"../../lib/extend":155,"../../plots/font_attributes":232,"../scatter/attributes":282}],256:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":44,"../../components/colorscale/attributes":50,"../../components/fx/hovertemplate_attributes":81,"../../lib/extend":153,"../../plots/font_attributes":230,"../scatter/attributes":281,"./constants.js":255}],254:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63395,7 +65098,7 @@ module.exports = { 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var arraysToCalcdata = _dereq_('./arrays_to_calcdata'); var calcSelection = _dereq_('../scatter/calc_selection'); @@ -63428,10 +65131,18 @@ module.exports = function calc(gd, trace) { // auto-z and autocolorscale if applicable if(hasColorscale(trace, 'marker')) { - colorscaleCalc(trace, trace.marker.color, 'marker', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - colorscaleCalc(trace, trace.marker.line.color, 'marker.line', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } arraysToCalcdata(cd, trace); @@ -63440,7 +65151,23 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../../components/colorscale/calc":51,"../../components/colorscale/has_colorscale":57,"../../plots/cartesian/axes":205,"../scatter/calc_selection":284,"./arrays_to_calcdata":254}],257:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":51,"../../components/colorscale/helpers":54,"../../plots/cartesian/axes":203,"../scatter/calc_selection":283,"./arrays_to_calcdata":252}],255:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + eventDataKeys: [] +}; + +},{}],256:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63569,9 +65296,14 @@ function initBase(gd, pa, sa, calcTraces) { // time. But included here for completeness. var scalendar = trace.orientation === 'h' ? trace.xcalendar : trace.ycalendar; + // 'base' on categorical axes makes no sense + var d2c = sa.type === 'category' || sa.type === 'multicategory' ? + function() { return null; } : + sa.d2c; + if(isArrayOrTypedArray(base)) { for(j = 0; j < Math.min(base.length, cd.length); j++) { - b = sa.d2c(base[j], 0, scalendar); + b = d2c(base[j], 0, scalendar); if(isNumeric(b)) { cd[j].b = +b; cd[j].hasB = 1; @@ -63582,7 +65314,7 @@ function initBase(gd, pa, sa, calcTraces) { cd[j].b = 0; } } else { - b = sa.d2c(base, 0, scalendar); + b = d2c(base, 0, scalendar); var hasBase = isNumeric(b); b = hasBase ? b : 0; for(j = 0; j < cd.length; j++) { @@ -64161,7 +65893,7 @@ module.exports = { setGroupPositions: setGroupPositions }; -},{"../../constants/numerical":143,"../../lib":161,"../../plots/cartesian/axes":205,"../../registry":245,"./sieve.js":266,"fast-isnumeric":10}],258:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":159,"../../plots/cartesian/axes":203,"../../registry":243,"./sieve.js":265,"fast-isnumeric":10}],257:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64201,6 +65933,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); + coerce('hovertemplate'); var textPosition = coerce('textposition'); @@ -64241,7 +65974,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/color":43,"../../lib":161,"../../registry":245,"../bar/style_defaults":268,"../scatter/xy_defaults":308,"./attributes":255}],259:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../lib":159,"../../registry":243,"../bar/style_defaults":267,"../scatter/xy_defaults":307,"./attributes":253}],258:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64310,7 +66043,7 @@ exports.getValue = function(arrayOrScalar, index) { return value; }; -},{"fast-isnumeric":10,"tinycolor2":26}],260:[function(_dereq_,module,exports){ +},{"fast-isnumeric":10,"tinycolor2":26}],259:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64450,6 +66183,7 @@ function hoverPoints(pointData, xval, yval, hovermode) { fillHoverText(di, trace, pointData); Registry.getComponentMethod('errorbars', 'hoverInfo')(di, trace, pointData); + pointData.hovertemplate = trace.hovertemplate; return [pointData]; } @@ -64467,7 +66201,7 @@ module.exports = { getTraceColor: getTraceColor }; -},{"../../components/color":43,"../../components/fx":85,"../../registry":245,"../scatter/fill_hover_text":290}],261:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/fx":82,"../../registry":243,"../scatter/fill_hover_text":289}],260:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64505,7 +66239,7 @@ Bar.meta = { module.exports = Bar; -},{"../../plots/cartesian":217,"../scatter/marker_colorbar":300,"./arrays_to_calcdata":254,"./attributes":255,"./calc":256,"./cross_trace_calc":257,"./defaults":258,"./hover":260,"./layout_attributes":262,"./layout_defaults":263,"./plot":264,"./select":265,"./style":267}],262:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":215,"../scatter/marker_colorbar":299,"./arrays_to_calcdata":252,"./attributes":253,"./calc":254,"./cross_trace_calc":256,"./defaults":257,"./hover":259,"./layout_attributes":261,"./layout_defaults":262,"./plot":263,"./select":264,"./style":266}],261:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64553,7 +66287,7 @@ module.exports = { } }; -},{}],263:[function(_dereq_,module,exports){ +},{}],262:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64611,7 +66345,7 @@ module.exports = function(layoutIn, layoutOut, fullData) { coerce('bargroupgap'); }; -},{"../../lib":161,"../../plots/cartesian/axes":205,"../../registry":245,"./layout_attributes":262}],264:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/cartesian/axes":203,"../../registry":243,"./layout_attributes":261}],263:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64738,7 +66472,7 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { .style('vector-effect', 'non-scaling-stroke') .attr('d', 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z') - .call(Drawing.setClipUrl, plotinfo.layerClipId); + .call(Drawing.setClipUrl, plotinfo.layerClipId, gd); appendBarText(gd, bar, cd, i, x0, x1, y0, y1); @@ -64750,11 +66484,11 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { // lastly, clip points groups of `cliponaxis !== false` traces // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = cd0.trace.cliponaxis === false; - Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId); + Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId, gd); }); // error bars are on the top - Registry.getComponentMethod('errorbars', 'plot')(bartraces, plotinfo); + Registry.getComponentMethod('errorbars', 'plot')(gd, bartraces, plotinfo); }; function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) { @@ -65051,7 +66785,7 @@ function getTextPosition(trace, index) { return helpers.coerceEnumerated(attributeTextPosition, value); } -},{"../../components/color":43,"../../components/drawing":68,"../../lib":161,"../../lib/svg_text_utils":182,"../../registry":245,"./attributes":255,"./helpers":259,"./style":267,"d3":8,"fast-isnumeric":10}],265:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/drawing":64,"../../lib":159,"../../lib/svg_text_utils":180,"../../registry":243,"./attributes":253,"./helpers":258,"./style":266,"d3":8,"fast-isnumeric":10}],264:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65094,7 +66828,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],266:[function(_dereq_,module,exports){ +},{}],265:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65203,7 +66937,7 @@ Sieve.prototype.getLabel = function getLabel(position, value) { return prefix + label; }; -},{"../../constants/numerical":143,"../../lib":161}],267:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":159}],266:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65377,7 +67111,7 @@ module.exports = { getBarColor: getBarColor }; -},{"../../components/color":43,"../../components/drawing":68,"../../lib":161,"../../registry":245,"./attributes":255,"./helpers":259,"d3":8}],268:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/drawing":64,"../../lib":159,"../../registry":243,"./attributes":253,"./helpers":258,"d3":8}],267:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65386,11 +67120,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout) { @@ -65416,7 +67149,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, default coerce('unselected.marker.color'); }; -},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57}],269:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54}],268:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65430,6 +67163,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, default var colorAttrs = _dereq_('../../components/color/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); var plotAttrs = _dereq_('../../plots/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var domainAttrs = _dereq_('../../plots/domain').attributes; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -65537,6 +67271,9 @@ module.exports = { hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { flags: ['label', 'text', 'value', 'percent', 'name'] }), + hovertemplate: hovertemplateAttrs({}, { + keys: ['label', 'color', 'value', 'percent', 'text'] + }), textposition: { valType: 'enumerated', @@ -65557,26 +67294,30 @@ module.exports = { }), title: { - valType: 'string', - dflt: '', - - editType: 'calc', - - }, - titleposition: { - valType: 'enumerated', - values: [ - 'top left', 'top center', 'top right', - 'middle center', - 'bottom left', 'bottom center', 'bottom right' - ], - - editType: 'calc', - + text: { + valType: 'string', + dflt: '', + + editType: 'calc', + + }, + font: extendFlat({}, textFontAttrs, { + + }), + position: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + + editType: 'calc', + + }, + + editType: 'calc' }, - titlefont: extendFlat({}, textFontAttrs, { - - }), // position and shape domain: domainAttrs({name: 'pie', trace: true, editType: 'calc'}), @@ -65633,10 +67374,34 @@ module.exports = { arrayOk: true, editType: 'calc', + }, + + _deprecated: { + title: { + valType: 'string', + dflt: '', + + editType: 'calc', + + }, + titlefont: extendFlat({}, textFontAttrs, { + + }), + titleposition: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + + editType: 'calc', + + } } }; -},{"../../components/color/attributes":42,"../../lib/extend":155,"../../plots/attributes":202,"../../plots/domain":231,"../../plots/font_attributes":232}],270:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":42,"../../components/fx/hovertemplate_attributes":81,"../../lib/extend":153,"../../plots/attributes":200,"../../plots/domain":229,"../../plots/font_attributes":230}],269:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65668,7 +67433,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../plots/get_data":234,"../../registry":245}],271:[function(_dereq_,module,exports){ +},{"../../plots/get_data":232,"../../registry":243}],270:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65859,7 +67624,7 @@ function generateExtendedColors(colorList) { return pieColors; } -},{"../../components/color":43,"../../lib":161,"./helpers":274,"fast-isnumeric":10,"tinycolor2":26}],272:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../lib":159,"./helpers":273,"fast-isnumeric":10,"tinycolor2":26}],271:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65913,6 +67678,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var textData = coerce('text'); var textInfo = coerce('textinfo', Array.isArray(textData) ? 'text+percent' : 'percent'); coerce('hovertext'); + coerce('hovertemplate'); if(textInfo && textInfo !== 'none') { var textPosition = coerce('textposition'), @@ -65938,11 +67704,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleDomainDefaults(traceOut, layout, coerce); var hole = coerce('hole'); - var title = coerce('title'); + var title = coerce('title.text'); if(title) { - var titlePosition = coerce('titleposition', hole ? 'middle center' : 'top center'); - if(!hole && titlePosition === 'middle center') traceOut.titleposition = 'top center'; - coerceFont(coerce, 'titlefont', layout.font); + var titlePosition = coerce('title.position', hole ? 'middle center' : 'top center'); + if(!hole && titlePosition === 'middle center') traceOut.title.position = 'top center'; + coerceFont(coerce, 'title.font', layout.font); } coerce('sort'); @@ -65952,7 +67718,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('pull'); }; -},{"../../lib":161,"../../plots/domain":231,"./attributes":269}],273:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../plots/domain":229,"./attributes":268}],272:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65979,6 +67745,8 @@ module.exports = function eventData(pt, trace) { label: pt.label, color: pt.color, value: pt.v, + percent: pt.percent, + text: pt.text, // pt.v (and pt.i below) for backward compatibility v: pt.v @@ -65995,7 +67763,7 @@ module.exports = function eventData(pt, trace) { return out; }; -},{"../../components/fx/helpers":82}],274:[function(_dereq_,module,exports){ +},{"../../components/fx/helpers":78}],273:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66037,7 +67805,7 @@ exports.castOption = function castOption(item, indices) { else if(item) return item; }; -},{"../../lib":161}],275:[function(_dereq_,module,exports){ +},{"../../lib":159}],274:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66073,7 +67841,7 @@ Pie.meta = { module.exports = Pie; -},{"./attributes":269,"./base_plot":270,"./calc":271,"./defaults":272,"./layout_attributes":276,"./layout_defaults":277,"./plot":278,"./style":279,"./style_one":280}],276:[function(_dereq_,module,exports){ +},{"./attributes":268,"./base_plot":269,"./calc":270,"./defaults":271,"./layout_attributes":275,"./layout_defaults":276,"./plot":277,"./style":278,"./style_one":279}],275:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66109,7 +67877,7 @@ module.exports = { } }; -},{}],277:[function(_dereq_,module,exports){ +},{}],276:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66133,7 +67901,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { coerce('extendpiecolors'); }; -},{"../../lib":161,"./layout_attributes":276}],278:[function(_dereq_,module,exports){ +},{"../../lib":159,"./layout_attributes":275}],277:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66235,20 +68003,25 @@ module.exports = function plot(gd, cdpie) { // in case we dragged over the pie from another subplot, // or if hover is turned off - if(hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo) { + if(trace2.hovertemplate || (hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo)) { var rInscribed = getInscribedRadiusFraction(pt, cd0); var hoverCenterX = cx + pt.pxmid[0] * (1 - rInscribed); var hoverCenterY = cy + pt.pxmid[1] * (1 - rInscribed); var separators = fullLayout.separators; var thisText = []; - if(hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); - if(hoverinfo.indexOf('text') !== -1) { - var texti = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); + pt.text = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('text') !== -1) { + var texti = pt.text; if(texti) thisText.push(texti); } - if(hoverinfo.indexOf('value') !== -1) thisText.push(helpers.formatPieValue(pt.v, separators)); - if(hoverinfo.indexOf('percent') !== -1) thisText.push(helpers.formatPiePercent(pt.v / cd0.vTotal, separators)); + pt.value = pt.v; + pt.valueLabel = helpers.formatPieValue(pt.v, separators); + if(hoverinfo && hoverinfo.indexOf('value') !== -1) thisText.push(pt.valueLabel); + pt.percent = pt.v / cd0.vTotal; + pt.percentLabel = helpers.formatPiePercent(pt.percent, separators); + if(hoverinfo && hoverinfo.indexOf('percent') !== -1) thisText.push(pt.percentLabel); var hoverLabel = trace.hoverlabel; var hoverFont = hoverLabel.font; @@ -66258,13 +68031,18 @@ module.exports = function plot(gd, cdpie) { x1: hoverCenterX + rInscribed * cd0.r, y: hoverCenterY, text: thisText.join('
'), - name: hoverinfo.indexOf('name') !== -1 ? trace2.name : undefined, + name: (trace2.hovertemplate || hoverinfo.indexOf('name') !== -1) ? trace2.name : undefined, idealAlign: pt.pxmid[0] < 0 ? 'left' : 'right', color: helpers.castOption(hoverLabel.bgcolor, pt.pts) || pt.color, borderColor: helpers.castOption(hoverLabel.bordercolor, pt.pts), fontFamily: helpers.castOption(hoverFont.family, pt.pts), fontSize: helpers.castOption(hoverFont.size, pt.pts), - fontColor: helpers.castOption(hoverFont.color, pt.pts) + fontColor: helpers.castOption(hoverFont.color, pt.pts), + + trace: trace2, + hovertemplate: helpers.castOption(trace2.hovertemplate, pt.pts), + hovertemplateLabels: pt, + eventData: [eventData(pt, trace2)] }, { container: fullLayout2._hoverlayer.node(), outerContainer: fullLayout2._paper.node(), @@ -66448,7 +68226,7 @@ module.exports = function plot(gd, cdpie) { // add the title var titleTextGroup = d3.select(this).selectAll('g.titletext') - .data(trace.title ? [0] : []); + .data(trace.title.text ? [0] : []); titleTextGroup.enter().append('g') .classed('titletext', true); @@ -66460,18 +68238,18 @@ module.exports = function plot(gd, cdpie) { s.attr('data-notex', 1); }); - titleText.text(trace.title) + titleText.text(trace.title.text) .attr({ 'class': 'titletext', transform: '', 'text-anchor': 'middle', }) - .call(Drawing.font, trace.titlefont) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var transform; - if(trace.titleposition === 'middle center') { + if(trace.title.position === 'middle center') { transform = positionTitleInside(cd0); } else { transform = positionTitleOutside(cd0, fullLayout._size); @@ -66599,11 +68377,11 @@ function prerenderTitles(cdpie, gd) { cd0 = cdpie[i][0]; trace = cd0.trace; - if(trace.title) { + if(trace.title.text) { var dummyTitle = Drawing.tester.append('text') .attr('data-notex', 1) - .text(trace.title) - .call(Drawing.font, trace.titlefont) + .text(trace.title.text) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var bBox = Drawing.bBox(dummyTitle.node(), true); cd0.titleBox = { @@ -66705,7 +68483,7 @@ function positionTitleInside(cd0) { y: cd0.cy, scale: cd0.trace.hole * cd0.r * 2 / textDiameter, tx: 0, - ty: - cd0.titleBox.height / 2 + cd0.trace.titlefont.size + ty: - cd0.titleBox.height / 2 + cd0.trace.title.font.size }; } @@ -66728,25 +68506,25 @@ function positionTitleOutside(cd0, plotSize) { // we reason below as if the baseline is the top middle point of the text box. // so we must add the font size to approximate the y-coord. of the top. // note that this correction must happen after scaling. - translate.ty += trace.titlefont.size; + translate.ty += trace.title.font.size; maxPull = getMaxPull(trace); - if(trace.titleposition.indexOf('top') !== -1) { + if(trace.title.position.indexOf('top') !== -1) { topMiddle.y -= (1 + maxPull) * cd0.r; translate.ty -= cd0.titleBox.height; } - else if(trace.titleposition.indexOf('bottom') !== -1) { + else if(trace.title.position.indexOf('bottom') !== -1) { topMiddle.y += (1 + maxPull) * cd0.r; } - if(trace.titleposition.indexOf('left') !== -1) { + if(trace.title.position.indexOf('left') !== -1) { // we start the text at the left edge of the pie maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x -= (1 + maxPull) * cd0.r; translate.tx += cd0.titleBox.width / 2; - } else if(trace.titleposition.indexOf('center') !== -1) { + } else if(trace.title.position.indexOf('center') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); - } else if(trace.titleposition.indexOf('right') !== -1) { + } else if(trace.title.position.indexOf('right') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x += (1 + maxPull) * cd0.r; translate.tx -= cd0.titleBox.width / 2; @@ -66900,7 +68678,7 @@ function scalePies(cdpie, plotSize) { pieBoxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); pieBoxHeight = plotSize.h * (trace.domain.y[1] - trace.domain.y[0]); // leave some space for the title, if it will be displayed outside - if(trace.title && trace.titleposition !== 'middle center') { + if(trace.title.text && trace.title.position !== 'middle center') { pieBoxHeight -= getTitleSpace(cd0, plotSize); } @@ -66910,7 +68688,7 @@ function scalePies(cdpie, plotSize) { cd0.cx = plotSize.l + plotSize.w * (trace.domain.x[1] + trace.domain.x[0]) / 2; cd0.cy = plotSize.t + plotSize.h * (1 - trace.domain.y[0]) - pieBoxHeight / 2; - if(trace.title && trace.titleposition.indexOf('bottom') !== -1) { + if(trace.title.text && trace.title.position.indexOf('bottom') !== -1) { cd0.cy -= getTitleSpace(cd0, plotSize); } @@ -66989,7 +68767,7 @@ function setCoords(cd) { } } -},{"../../components/color":43,"../../components/drawing":68,"../../components/fx":85,"../../lib":161,"../../lib/svg_text_utils":182,"./event_data":273,"./helpers":274,"d3":8}],279:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/drawing":64,"../../components/fx":82,"../../lib":159,"../../lib/svg_text_utils":180,"./event_data":272,"./helpers":273,"d3":8}],278:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67018,7 +68796,7 @@ module.exports = function style(gd) { }); }; -},{"./style_one":280,"d3":8}],280:[function(_dereq_,module,exports){ +},{"./style_one":279,"d3":8}],279:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67042,7 +68820,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":43,"./helpers":274}],281:[function(_dereq_,module,exports){ +},{"../../components/color":43,"./helpers":273}],280:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67094,7 +68872,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":161}],282:[function(_dereq_,module,exports){ +},{"../../lib":159}],281:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67105,6 +68883,7 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -67216,6 +68995,9 @@ module.exports = { editType: 'style', }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), line: { color: { valType: 'color', @@ -67490,7 +69272,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":44,"../../components/colorscale/attributes":50,"../../components/drawing":68,"../../components/drawing/attributes":67,"../../lib/extend":155,"../../plots/font_attributes":232,"./constants":286}],283:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":44,"../../components/colorscale/attributes":50,"../../components/drawing":64,"../../components/drawing/attributes":63,"../../components/fx/hovertemplate_attributes":81,"../../lib/extend":153,"../../plots/font_attributes":230,"./constants":285}],282:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67580,7 +69362,7 @@ function calc(gd, trace) { } arraysToCalcdata(cd, trace); - calcColorscale(trace); + calcColorscale(gd, trace); calcSelection(cd, trace); if(stackGroupOpts) { @@ -67780,7 +69562,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":143,"../../lib":161,"../../plots/cartesian/axes":205,"./arrays_to_calcdata":281,"./calc_selection":284,"./colorscale_calc":285,"./subtypes":306,"fast-isnumeric":10}],284:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":159,"../../plots/cartesian/axes":203,"./arrays_to_calcdata":280,"./calc_selection":283,"./colorscale_calc":284,"./subtypes":305,"fast-isnumeric":10}],283:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67799,7 +69581,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":161}],285:[function(_dereq_,module,exports){ +},{"../../lib":159}],284:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67808,31 +69590,41 @@ module.exports = function calcSelection(cd, trace) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var subTypes = _dereq_('./subtypes'); - -module.exports = function calcMarkerColorscale(trace) { +module.exports = function calcMarkerColorscale(gd, trace) { if(subTypes.hasLines(trace) && hasColorscale(trace, 'line')) { - calcColorscale(trace, trace.line.color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } if(subTypes.hasMarkers(trace)) { if(hasColorscale(trace, 'marker')) { - calcColorscale(trace, trace.marker.color, 'marker', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - calcColorscale(trace, trace.marker.line.color, 'marker.line', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } } }; -},{"../../components/colorscale/calc":51,"../../components/colorscale/has_colorscale":57,"./subtypes":306}],286:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":51,"../../components/colorscale/helpers":54,"./subtypes":305}],285:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67856,10 +69648,12 @@ module.exports = { // number of viewport sizes away from the visible region // at which we clip all lines to the perimeter - maxScreensAway: 20 + maxScreensAway: 20, + + eventDataKeys: [] }; -},{}],287:[function(_dereq_,module,exports){ +},{}],286:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68042,7 +69836,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":283}],288:[function(_dereq_,module,exports){ +},{"./calc":282}],287:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68081,7 +69875,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],289:[function(_dereq_,module,exports){ +},{}],288:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68159,7 +69953,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout dfltHoverOn.push('fills'); } coerce('hoveron', dfltHoverOn.join('+') || 'points'); - + if(traceOut.hoveron !== 'fills') coerce('hovertemplate'); var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults'); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'}); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'}); @@ -68167,7 +69961,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":161,"../../registry":245,"./attributes":282,"./constants":286,"./fillcolor_defaults":291,"./line_defaults":295,"./line_shape_defaults":297,"./marker_defaults":301,"./stack_defaults":304,"./subtypes":306,"./text_defaults":307,"./xy_defaults":308}],290:[function(_dereq_,module,exports){ +},{"../../lib":159,"../../registry":243,"./attributes":281,"./constants":285,"./fillcolor_defaults":290,"./line_defaults":294,"./line_shape_defaults":296,"./marker_defaults":300,"./stack_defaults":303,"./subtypes":305,"./text_defaults":306,"./xy_defaults":307}],289:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68210,7 +70004,7 @@ function isValid(v) { return v || v === 0; } -},{"../../lib":161}],291:[function(_dereq_,module,exports){ +},{"../../lib":159}],290:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68248,7 +70042,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":43,"../../lib":161}],292:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../lib":159}],291:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68301,7 +70095,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":43,"./subtypes":306}],293:[function(_dereq_,module,exports){ +},{"../../components/color":43,"./subtypes":305}],292:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68397,7 +70191,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { y1: yc + rad, yLabelVal: yLabelVal, - spikeDistance: dxy(di) + spikeDistance: dxy(di), + hovertemplate: trace.hovertemplate }); fillHoverText(di, trace, pointData); @@ -68481,7 +70276,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { x1: xmax, y0: yAvg, y1: yAvg, - color: color + color: color, + hovertemplate: '%{name}' }); delete pointData.index; @@ -68496,7 +70292,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":43,"../../components/fx":85,"../../lib":161,"../../registry":245,"./fill_hover_text":290,"./get_trace_color":292}],294:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/fx":82,"../../lib":159,"../../registry":243,"./fill_hover_text":289,"./get_trace_color":291}],293:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68543,7 +70339,7 @@ Scatter.meta = { module.exports = Scatter; -},{"../../plots/cartesian":217,"./arrays_to_calcdata":281,"./attributes":282,"./calc":283,"./cross_trace_calc":287,"./cross_trace_defaults":288,"./defaults":289,"./hover":293,"./marker_colorbar":300,"./plot":302,"./select":303,"./style":305,"./subtypes":306}],295:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":215,"./arrays_to_calcdata":280,"./attributes":281,"./calc":282,"./cross_trace_calc":286,"./cross_trace_defaults":287,"./defaults":288,"./hover":292,"./marker_colorbar":299,"./plot":301,"./select":302,"./style":304,"./subtypes":305}],294:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68555,7 +70351,7 @@ module.exports = Scatter; 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) { @@ -68574,7 +70370,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57,"../../lib":161}],296:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54,"../../lib":159}],295:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69039,7 +70835,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":143,"../../lib":161,"./constants":286}],297:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":159,"./constants":285}],296:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69058,7 +70854,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],298:[function(_dereq_,module,exports){ +},{}],297:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69151,7 +70947,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],299:[function(_dereq_,module,exports){ +},{}],298:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69193,7 +70989,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":10}],300:[function(_dereq_,module,exports){ +},{"fast-isnumeric":10}],299:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69211,7 +71007,7 @@ module.exports = { max: 'cmax' }; -},{}],301:[function(_dereq_,module,exports){ +},{}],300:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69220,11 +71016,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var subTypes = _dereq_('./subtypes'); @@ -69294,7 +71089,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57,"./subtypes":306}],302:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54,"./subtypes":305}],301:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69385,7 +71180,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition function createFills(gd, traceJoin, plotinfo) { traceJoin.each(function(d) { var fills = ensureSingle(d3.select(this), 'g', 'fills'); - Drawing.setClipUrl(fills, plotinfo.layerClipId); + Drawing.setClipUrl(fills, plotinfo.layerClipId, gd); var trace = d[0].trace; @@ -69437,7 +71232,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition var text = ensureSingle(tr, 'g', 'text'); // error bars are at the bottom - Registry.getComponentMethod('errorbars', 'plot')(errorBarGroup, plotinfo, transitionOpts); + Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts); if(trace.visible !== true) return; @@ -69592,7 +71387,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.lineGroupStyle) .each(makeUpdate(true)); - Drawing.setClipUrl(lineJoin, plotinfo.layerClipId); + Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd); function clearFill(selection) { transition(selection).attr('d', 'M0,0Z'); @@ -69820,8 +71615,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = trace.cliponaxis === false; var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId; - Drawing.setClipUrl(points, clipUrl); - Drawing.setClipUrl(text, clipUrl); + Drawing.setClipUrl(points, clipUrl, gd); + Drawing.setClipUrl(text, clipUrl, gd); } function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { @@ -69866,7 +71661,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":68,"../../lib":161,"../../lib/polygon":173,"../../registry":245,"./line_points":296,"./link_traces":298,"./subtypes":306,"d3":8}],303:[function(_dereq_,module,exports){ +},{"../../components/drawing":64,"../../lib":159,"../../lib/polygon":171,"../../registry":243,"./line_points":295,"./link_traces":297,"./subtypes":305,"d3":8}],302:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69921,7 +71716,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":306}],304:[function(_dereq_,module,exports){ +},{"./subtypes":305}],303:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70027,7 +71822,7 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],305:[function(_dereq_,module,exports){ +},{}],304:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70099,7 +71894,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":68,"../../registry":245,"d3":8}],306:[function(_dereq_,module,exports){ +},{"../../components/drawing":64,"../../registry":243,"d3":8}],305:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70138,7 +71933,7 @@ module.exports = { } }; -},{"../../lib":161}],307:[function(_dereq_,module,exports){ +},{"../../lib":159}],306:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70168,7 +71963,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":161}],308:[function(_dereq_,module,exports){ +},{"../../lib":159}],307:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70177,34 +71972,32 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var Lib = _dereq_('../../lib'); var Registry = _dereq_('../../registry'); - module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { - var len, - x = coerce('x'), - y = coerce('y'); + var x = coerce('x'); + var y = coerce('y'); + var len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); if(x) { + var xlen = Lib.minRowLength(x); if(y) { - len = Math.min(x.length, y.length); - } - else { - len = x.length; + len = Math.min(xlen, Lib.minRowLength(y)); + } else { + len = xlen; coerce('y0'); coerce('dy'); } - } - else { + } else { if(!y) return 0; - len = traceOut.y.length; + len = Lib.minRowLength(y); coerce('x0'); coerce('dx'); } @@ -70214,5 +72007,5 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../registry":245}]},{},[5])(5) +},{"../../lib":159,"../../registry":243}]},{},[5])(5) }); diff --git a/dist/plotly-basic.min.js b/dist/plotly-basic.min.js index cfe3e4f6f2f..b08cecace49 100644 --- a/dist/plotly-basic.min.js +++ b/dist/plotly-basic.min.js @@ -1,7 +1,7 @@ /** -* plotly.js (basic - minified) v1.42.5 +* plotly.js (basic - minified) v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,r,n){function a(o,l){if(!r[o]){if(!e[o]){var s="function"==typeof require&&require;if(!l&&s)return s(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};e[o][0].call(u.exports,function(t){return a(e[o][1][t]||t)},u,u.exports,t,e,r,n)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;oplotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":261}],4:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":145}],5:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./pie")]),e.exports=n},{"./bar":3,"./core":4,"./pie":6}],6:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":275}],7:[function(t,e,r){var n=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},i=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var l,s=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),l=0===c.x}catch(t){l=!1}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,a){var i,o,l;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),l=o[e]):(o=t._events=n(null),t._eventsCount=0),l){if("function"==typeof l?l=o[e]=a?[r,l]:[l,r]:a?l.unshift(r):l.push(r),!l.warned&&(i=u(t))&&i>0&&l.length>i){l.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+l.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=l.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else l=o[e]=r,++t._eventsCount;return t}function d(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var s=new Error('Unhandled "error" event. ('+e+")");throw s.context=e,s}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,a=v(t,n),i=0;i=0;o--)if(r[o]===e||r[o].listener===e){l=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(var r=e,n=r+1,a=t.length;n=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],8:[function(t,e,r){!function(){var t={version:"3.5.17"},r=[].slice,n=function(t){return r.call(t)},a=this.document;function i(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(a)try{n(a.documentElement.childNodes)[0].nodeType}catch(t){n=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),a)try{a.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var l=this.Element.prototype,s=l.setAttribute,c=l.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;l.setAttribute=function(t,e){s.call(this,t,e+"")},l.setAttributeNS=function(t,e,r){c.call(this,t,e,r+"")},u.setProperty=function(t,e,r){f.call(this,t,e+"",r)}}function d(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function h(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)<0?n=i+1:a=i}return n},right:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)>0?a=i:n=i+1}return n}}}t.ascending=d,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++an&&(r=n)}else{for(;++a=n){r=n;break}for(;++an&&(r=n)}return r},t.max=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++ar&&(r=n)}else{for(;++a=n){r=n;break}for(;++ar&&(r=n)}return r},t.extent=function(t,e){var r,n,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=n){r=a=n;break}for(;++in&&(r=n),a=n){r=a=n;break}for(;++in&&(r=n),a1)return o/(s-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(d);function y(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return d(t(e),r)}:t)},t.shuffle=function(t,e,r){(i=arguments.length)<3&&(r=t.length,i<2&&(e=0));for(var n,a,i=r-e;i;)a=Math.random()*i--|0,n=t[i+e],t[i+e]=t[a+e],t[a+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],a=new Array(r<0?0:r);e=0;)for(e=(n=t[a]).length;--e>=0;)r[--o]=n[e];return r};var m=Math.abs;function x(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(m(r)),o=-1;if(t*=i,e*=i,(r*=i)<0)for(;(n=t+r*++o)>e;)a.push(n/i);else for(;(n=t+r*++o)=a.length)return r?r.call(n,i):e?i.sort(e):i;for(var s,c,u,f,d=-1,p=i.length,h=a[l++],g=new b;++d=a.length)return e;var n=[],o=i[r++];return e.forEach(function(e,a){n.push({key:e,values:t(a,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return a.push(t),n},n.sortKeys=function(t){return i[a.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new O;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function V(t){return q(t,Z),t}var U=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},X=function(t,e){var r=t.matches||t[z(t,"matchesSelector")];return(X=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(U=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,X=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var Z=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return U(t,this)}}function W(t){return"function"==typeof t?t:function(){return G(t,this)}}Z.select=function(t){var e,r,n,a,i=[];t=Y(t);for(var o=-1,l=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Q.hasOwnProperty(r)?{space:Q[r],local:t}:t}},Z.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each($(r,e[r]));return this}return this.each($(e,r))},Z.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,a=-1;if(e=r.classList){for(;++a=0;)(r=n[a])&&(i&&i!==r.nextSibling&&i.parentNode.insertBefore(r,i),i=r);return this},Z.sort=function(t){t=function(t){arguments.length||(t=d);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var s=ht.get(e);function c(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return s&&(e=s,l=vt),o?r?function(){var t=l(r,n(arguments));c.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=r}:c:r?R:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(r=a.match(n)){var i=this[a];this.removeEventListener(r[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=dt,dt.append=Z.append,dt.empty=Z.empty,dt.node=Z.node,dt.call=Z.call,dt.size=Z.size,dt.select=function(t){for(var e,r,n,a,i,o=[],l=-1,s=this.length;++l=n&&(n=e+1);!(o=l[n])&&++n0?1:t<0?-1:0}function Dt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function zt(t){return t>1?0:t<-1?Tt:Math.acos(t)}function Et(t){return t>1?St:t<-1?-St:Math.asin(t)}function Rt(t){return((t=Math.exp(t))+1/t)/2}function Nt(t){return(t=Math.sin(t/2))*t}var It=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,a=t[0],i=t[1],o=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-i,d=u*u+f*f;if(d0&&(e=e.transition().duration(g)),e.call(w.event)}function L(){c&&c.domain(s.range().map(function(t){return(t-d.x)/d.k}).map(s.invert)),f&&f.domain(u.range().map(function(t){return(t-d.y)/d.k}).map(u.invert))}function S(t){v++||t({type:"zoomstart"})}function C(t){L(),t({type:"zoom",scale:d.k,translate:[d.x,d.y]})}function O(t){--v||(t({type:"zoomend"}),r=null)}function P(){var e=this,r=_.of(e,arguments),n=0,a=t.select(o(e)).on(m,function(){n=1,T(t.mouse(e),i),C(r)}).on(x,function(){a.on(m,null).on(x,null),l(n),O(r)}),i=k(t.mouse(e)),l=xt(e);fl.call(e),S(r)}function D(){var e,r=this,n=_.of(r,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+o,c="touchend"+o,u=[],f=t.select(r),p=xt(r);function h(){var n=t.touches(r);return e=d.k,n.forEach(function(t){t.identifier in a&&(a[t.identifier]=k(t))}),n}function g(){var e=t.event.target;t.select(e).on(s,v).on(c,m),u.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){y=p[0];var x=p[1],b=y[0]-x[0],_=y[1]-x[1];i=b*b+_*_}}function v(){var o,s,c,u,f=t.touches(r);fl.call(r);for(var d=0,p=f.length;d360?t-=360:t<0&&(t+=360),t<60?n+(a-n)*t/60:t<180?a:t<240?n+(a-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(a=r<=.5?r*(1+e):r+e-r*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Yt?e.l:(e=de((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Ut(this.h,this.s,this.l)},t.hcl=Gt;var Xt=Gt.prototype=new Ht;function Zt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Yt(r,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Yt(t,e,r){return this instanceof Yt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Yt?new Yt(t.l,t.a,t.b):t instanceof Gt?Zt(t.h,t.c,t.l):de((t=ie(t)).r,t.g,t.b):new Yt(t,e,r)}Xt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Wt*(arguments.length?t:1)))},Xt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Wt*(arguments.length?t:1)))},Xt.rgb=function(){return Zt(this.h,this.c,this.l).rgb()},t.lab=Yt;var Wt=18,Jt=.95047,Qt=1,$t=1.08883,Kt=Yt.prototype=new Ht;function te(t,e,r){var n=(t+16)/116,a=n+e/500,i=n-r/200;return new ie(ae(3.2404542*(a=re(a)*Jt)-1.5371385*(n=re(n)*Qt)-.4985314*(i=re(i)*$t)),ae(-.969266*a+1.8760108*n+.041556*i),ae(.0556434*a-.2040259*n+1.0572252*i))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Ot,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,r){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ue(""+t,ie,Ut):new ie(t,e,r)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function le(t){return oe(t)+""}Kt.brighter=function(t){return new Yt(Math.min(100,this.l+Wt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Yt(Math.max(0,this.l-Wt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var se=ie.prototype=new Ht;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,r){var n,a,i,o=0,l=0,s=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=n[2].split(","),n[1]){case"hsl":return r(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(he(a[0]),he(a[1]),he(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,l=240&i,l|=l>>4,s=15&i,s|=s<<4):7===t.length&&(o=(16711680&i)>>16,l=(65280&i)>>8,s=255&i)),e(o,l,s))}function fe(t,e,r){var n,a,i=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),l=o-i,s=(o+i)/2;return l?(a=s<.5?l/(o+i):l/(2-o-i),n=t==o?(e-r)/l+(e0&&s<1?0:n),new qt(n,a,s)}function de(t,e,r){var n=ne((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(r=pe(r)))/Jt),a=ne((.2126729*t+.7151522*e+.072175*r)/Qt);return Yt(116*a-16,500*(n-a),200*(a-ne((.0193339*t+.119192*e+.9503041*r)/$t)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function he(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}se.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,a=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=a.call(o,c)}catch(t){return void l.error.call(o,t)}l.load.call(o,t)}else l.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var r=t.event;t.event=e;try{l.progress.call(o,c)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,a){if(2===arguments.length&&"function"==typeof n&&(a=n,n=null),c.open(t,e,!0),null==r||"accept"in s||(s.accept=r+",*/*"),c.setRequestHeader)for(var i in s)c.setRequestHeader(i,s[i]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=u&&(c.responseType=u),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),l.beforesend.call(o,c),c.send(null==n?null:n),o},o.abort=function(){return c.abort(),o},t.rebind(o,l,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=ye(P),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function a(t,r,n){arguments.length<3&&(n=r,r=null);var a=me(t,e,null==r?i:o(r),n);return a.row=function(t){return arguments.length?a.response(null==(r=t)?i:o(t)):r},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function l(e){return e.map(s).join(t)}function s(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var r;return a.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(a(t),r)}:a})},a.parseRows=function(t,e){var r,a,i={},o={},l=[],s=t.length,c=0,u=0;function f(){if(c>=s)return o;if(a)return a=!1,i;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Te,e)),_e=0):(_e=1,ke(Te))}function Ae(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Le(){for(var t,e=xe,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Se(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Ce[8+n/3]};var Oe=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Pe=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Se(e,r))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),r))))}});function De(t){return t+""}var ze=t.time={},Ee=Date;function Re(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Re.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ne.setUTCDate.apply(this._,arguments)},setDay:function(){Ne.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ne.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ne.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ne.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ne.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ne.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ne.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ne.setTime.apply(this._,arguments)}};var Ne=Date.prototype;function Ie(t,e,r){function n(e){var r=t(e),n=i(r,1);return e-r1)for(;o68?1900:2e3),r+a[0].length):-1}function Je(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function Qe(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function $e(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ar(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=m(e)/60|0,a=m(e)%60;return r+qe(n,"0",2)+qe(a,"0",2)}function ir(t,e,r){He.lastIndex=0;var n=He.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),i.push(t.substring(r-=l,r+l)),!((s+=l+1)>e));)l=a[o=(o+1)%a.length];return i.reverse().join(n)}:P;return function(e){var n=Oe.exec(e),a=n[1]||" ",l=n[2]||">",s=n[3]||"-",c=n[4]||"",u=n[5],f=+n[6],d=n[7],p=n[8],h=n[9],g=1,v="",y="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===a&&"="===l)&&(u=a="0",l="="),h){case"n":d=!0,h="g";break;case"%":g=100,y="%",h="f";break;case"p":g=100,y="%",h="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+h.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":g=-1,h="r"}"$"===c&&(v=i[0],y=i[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):"e"!=h&&"f"!=h||(p=Math.max(0,Math.min(20,p)))),h=Pe.get(h)||De;var b=u&&d;return function(e){var n=y;if(m&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===s?"":s;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),n=c.symbol+y}else e*=g;var _,w,k=(e=h(e,p)).lastIndexOf(".");if(k<0){var M=x?e.lastIndexOf("e"):-1;M<0?(_=e,w=""):(_=e.substring(0,M),w=e.substring(M))}else _=e.substring(0,k),w=r+e.substring(k+1);!u&&d&&(_=o(_,1/0));var T=v.length+_.length+w.length+(b?0:i.length),A=T"===l?A+i+e:"^"===l?A.substring(0,T>>=1)+i+e+A.substring(T):i+(b?e:A+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,a=e.time,i=e.periods,o=e.days,l=e.shortDays,s=e.months,c=e.shortMonths;function u(t){var e=t.length;function r(r){for(var n,a,i,o=[],l=-1,s=0;++l=c)return-1;if(37===(a=e.charCodeAt(l++))){if(o=e.charAt(l++),!(i=w[o in Be?e.charAt(l++):o])||(n=i(t,r,n))<0)return-1}else if(a!=r.charCodeAt(n++))return-1}return n}u.utc=function(t){var e=u(t);function r(t){try{var r=new(Ee=Re);return r._=t,e(r)}finally{Ee=Date}}return r.parse=function(t){try{Ee=Re;var r=e.parse(t);return r&&r._}finally{Ee=Date}},r.toString=e.toString,r},u.multi=u.utc.multi=or;var d=t.map(),p=Ve(o),h=Ue(o),g=Ve(l),v=Ue(l),y=Ve(s),m=Ue(s),x=Ve(c),b=Ue(c);i.forEach(function(t,e){d.set(t.toLowerCase(),e)});var _={a:function(t){return l[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:u(r),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+ze.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(ze.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(ze.mondayOfYear(t),e,2)},x:u(n),X:u(a),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:ar,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=h.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){y.lastIndex=0;var n=y.exec(e.slice(r));return n?(t.m=m.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:$e,e:$e,H:tr,I:tr,j:Ke,L:nr,m:Qe,M:er,p:function(t,e,r){var n=d.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:Xe,w:Ge,W:Ze,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:We,Y:Ye,Z:Je,"%":ir};return u}(e)}};var lr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function sr(){}t.format=lr.numberFormat,t.geo={},sr.prototype={s:0,t:0,add:function(t){ur(t,this.t,cr),ur(cr.s,this.s,this),this.s?this.t+=cr.t:this.s=cr.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cr=new sr;function ur(t,e,r){var n=r.s=t+e,a=n-t,i=n-a;r.t=t-i+(e-a)}function fr(t,e){t&&pr.hasOwnProperty(t.type)&&pr[t.type](t,e)}t.geo.stream=function(t,e){t&&dr.hasOwnProperty(t.type)?dr[t.type](t,e):fr(t,e)};var dr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,a=r.length;++n=0?1:-1,l=o*i,s=Math.cos(e),c=Math.sin(e),u=a*c,f=n*s+u*Math.cos(l),d=u*o*Math.sin(l);Sr.add(Math.atan2(d,f)),r=t,n=s,a=c}Cr.point=function(o,l){Cr.point=i,r=(t=o)*Ct,n=Math.cos(l=(e=l)*Ct/2+Tt/4),a=Math.sin(l)},Cr.lineEnd=function(){i(t,e)}}function Pr(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Dr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function zr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Er(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Rr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Nr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Ir(t){return[Math.atan2(t[1],t[0]),Et(t[2])]}function Fr(t,e){return m(t[0]-e[0])kt?a=90:c<-kt&&(r=-90),f[0]=e,f[1]=n}};function p(t,i){u.push(f=[e=t,n=t]),ia&&(a=i)}function h(t,o){var l=Pr([t*Ct,o*Ct]);if(s){var c=zr(s,l),u=zr([c[1],-c[0],0],c);Nr(u),u=Ir(u);var f=t-i,d=f>0?1:-1,h=u[0]*Ot*d,g=m(f)>180;if(g^(d*ia&&(a=v);else if(g^(d*i<(h=(h+360)%360-180)&&ha&&(a=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>i?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else p(t,o);s=l,i=t}function g(){d.point=h}function v(){f[0]=e,f[1]=n,d.point=p,s=null}function y(t,e){if(s){var r=t-i;c+=m(r)>180?r+(r>0?360:-360):r}else o=t,l=e;Cr.point(t,e),h(t,e)}function x(){Cr.lineStart()}function b(){y(o,l),Cr.lineEnd(),m(c)>kt&&(e=-(n=180)),f[0]=e,f[1]=n,s=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):l.push(g=p);for(var s,c,p,h=-1/0,g=(o=0,l[c=l.length-1]);o<=c;g=p,++o)p=l[o],(s=_(g[1],p[0]))>h&&(h=s,e=p[0],n=g[1])}return u=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,a]]}}(),t.geo.centroid=function(e){yr=mr=xr=br=_r=wr=kr=Mr=Tr=Ar=Lr=0,t.geo.stream(e,Br);var r=Tr,n=Ar,a=Lr,i=r*r+n*n+a*a;return i=0;--l)a.point((f=u[l])[0],f[1]);else n(p.x,p.p.x,-1,a);p=p.p}u=(p=p.o).z,h=!h}while(!p.v);a.lineEnd()}}}function Yr(t){if(e=t.length){for(var e,r,n=0,a=t[0];++n=0?1:-1,k=w*_,M=k>Tt,T=h*x;if(Sr.add(Math.atan2(T*w*Math.sin(k),g*b+T*Math.cos(k))),i+=M?_+w*At:_,M^d>=r^y>=r){var A=zr(Pr(f),Pr(t));Nr(A);var L=zr(a,A);Nr(L);var S=(M^_>=0?-1:1)*Et(L[2]);(n>S||n===S&&(A[0]||A[1]))&&(o+=M^_>=0?1:-1)}if(!v++)break;d=y,h=x,g=b,f=t}}return(i<-kt||i0){for(x||(o.polygonStart(),x=!0),o.lineStart();++i1&&2&e&&r.push(r.pop().concat(r.shift())),l.push(r.filter(Qr))}return u}}function Qr(t){return t.length>1}function $r(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:R,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-St-kt:St-t[1])-((e=e.x)[0]<0?e[1]-St-kt:St-e[1])}var tn=Jr(Xr,function(t){var e,r=NaN,n=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var l=i>0?Tt:-Tt,s=m(i-r);m(s-Tt)0?St:-St),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),t.point(i,n),e=0):a!==l&&s>=Tt&&(m(r-a)kt?Math.atan((Math.sin(e)*(i=Math.cos(n))*Math.sin(r)-Math.sin(n)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+n)/2}(r,n,i,o),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),e=0),t.point(r=i,n=o),a=l},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var a;if(null==t)a=r*St,n.point(-Tt,a),n.point(0,a),n.point(Tt,a),n.point(Tt,0),n.point(Tt,-a),n.point(0,-a),n.point(-Tt,-a),n.point(-Tt,0),n.point(-Tt,a);else if(m(t[0]-e[0])>kt){var i=t[0]0)){if(i/=d,d<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=r-s,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>u&&(u=i)}else if(d>0){if(i0)){if(i/=p,p<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=n-c,p||!(i<0)){if(i/=p,p<0){if(i>f)return;i>u&&(u=i)}else if(p>0){if(i0&&(a.a={x:s+u*d,y:c+u*p}),f<1&&(a.b={x:s+f*d,y:c+f*p}),a}}}}}}var rn=1e9;function nn(e,r,n,a){return function(s){var c,u,f,d,p,h,g,v,y,m,x,b=s,_=$r(),w=en(e,r,n,a),k={point:A,lineStart:function(){k.point=L,u&&u.push(f=[]);m=!0,y=!1,g=v=NaN},lineEnd:function(){c&&(L(d,p),h&&y&&_.rejoin(),c.push(_.buffer()));k.point=A,y&&s.lineEnd()},polygonStart:function(){s=_,c=[],u=[],x=!0},polygonEnd:function(){s=b,c=t.merge(c);var r=function(t){for(var e=0,r=u.length,n=t[1],a=0;an&&Dt(c,i,t)>0&&++e:i[1]<=n&&Dt(c,i,t)<0&&--e,c=i;return 0!==e}([e,a]),n=x&&r,i=c.length;(n||i)&&(s.polygonStart(),n&&(s.lineStart(),M(null,null,1,s),s.lineEnd()),i&&Zr(c,o,r,M,s),s.polygonEnd()),c=u=f=null}};function M(t,o,s,c){var u=0,f=0;if(null==t||(u=i(t,s))!==(f=i(o,s))||l(t,o)<0^s>0)do{c.point(0===u||3===u?e:n,u>1?a:r)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function T(t,i){return e<=t&&t<=n&&r<=i&&i<=a}function A(t,e){T(t,e)&&s.point(t,e)}function L(t,e){var r=T(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(u&&f.push([t,e]),m)d=t,p=e,h=r,m=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&y)s.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(y||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),x=!1):r&&(s.lineStart(),s.point(t,e),x=!1)}g=t,v=e,y=r}return k};function i(t,a){return m(t[0]-e)0?0:3:m(t[0]-n)0?2:1:m(t[1]-r)0?1:0:a>0?3:2}function o(t,e){return l(t.x,e.x)}function l(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Tt/3,n=Cn(t),a=n(e,r);return a.parallels=function(t){return arguments.length?n(e=t[0]*Tt/180,r=t[1]*Tt/180):[e/Tt*180,r/Tt*180]},a}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,a=1+r*(2*n-r),i=Math.sqrt(a)/n;function o(t,e){var r=Math.sqrt(a-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),i-r*Math.cos(t)]}return o.invert=function(t,e){var r=i-e;return[Math.atan2(t,r)/n,Et((a-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(l){return arguments.length?(i=nn(t=+l[0][0],e=+l[0][1],r=+l[1][0],n=+l[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,r){e=[t,r]}};function c(t){var i=t[0],o=t[1];return e=null,r(i,o),e||(n(i,o),e)||a(i,o),e}return c.invert=function(t){var e=i.scale(),r=i.translate(),n=(t[0]-r[0])/e,a=(t[1]-r[1])/e;return(a>=.12&&a<.234&&n>=-.425&&n<-.214?o:a>=.166&&a<.234&&n>=-.214&&n<-.115?l:i).invert(t)},c.stream=function(t){var e=i.stream(t),r=o.stream(t),n=l.stream(t);return{point:function(t,a){e.point(t,a),r.point(t,a),n.point(t,a)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),l.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),l.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),u=+t[0],f=+t[1];return r=i.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(s).point,n=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(s).point,a=l.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(s).point,c},c.scale(1070)};var ln,sn,cn,un,fn,dn,pn={point:R,lineStart:R,lineEnd:R,polygonStart:function(){sn=0,pn.lineStart=hn},polygonEnd:function(){pn.lineStart=pn.lineEnd=pn.point=R,ln+=m(sn/2)}};function hn(){var t,e,r,n;function a(t,e){sn+=n*t-r*e,r=t,n=e}pn.point=function(i,o){pn.point=a,t=r=i,e=n=o},pn.lineEnd=function(){a(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);edn&&(dn=e)},lineStart:R,lineEnd:R,polygonStart:R,polygonEnd:R};function vn(){var t=yn(4.5),e=[],r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=yn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function a(t,n){e.push("M",t,",",n),r.point=i}function i(t,r){e.push("L",t,",",r)}function o(){r.point=n}function l(){e.push("Z")}return r}function yn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var mn,xn={point:bn,lineStart:_n,lineEnd:wn,polygonStart:function(){xn.lineStart=kn},polygonEnd:function(){xn.point=bn,xn.lineStart=_n,xn.lineEnd=wn}};function bn(t,e){xr+=t,br+=e,++_r}function _n(){var t,e;function r(r,n){var a=r-t,i=n-e,o=Math.sqrt(a*a+i*i);wr+=o*(t+r)/2,kr+=o*(e+n)/2,Mr+=o,bn(t=r,e=n)}xn.point=function(n,a){xn.point=r,bn(t=n,e=a)}}function wn(){xn.point=bn}function kn(){var t,e,r,n;function a(t,e){var a=t-r,i=e-n,o=Math.sqrt(a*a+i*i);wr+=o*(r+t)/2,kr+=o*(n+e)/2,Mr+=o,Tr+=(o=n*t-r*e)*(r+t),Ar+=o*(n+e),Lr+=3*o,bn(r=t,n=e)}xn.point=function(i,o){xn.point=a,bn(t=r=i,e=n=o)},xn.lineEnd=function(){a(t,e)}}function Mn(t){var e=4.5,r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:R};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,At)}function a(e,n){t.moveTo(e,n),r.point=i}function i(e,r){t.lineTo(e,r)}function o(){r.point=n}function l(){t.closePath()}return r}function Tn(t){var e=.5,r=Math.cos(30*Ct),n=16;function a(e){return(n?function(e){var r,a,o,l,s,c,u,f,d,p,h,g,v={point:y,lineStart:m,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=m}};function y(r,n){r=t(r,n),e.point(r[0],r[1])}function m(){f=NaN,v.point=x,e.lineStart()}function x(r,a){var o=Pr([r,a]),l=t(r,a);i(f,d,u,p,h,g,f=l[0],d=l[1],u=r,p=o[0],h=o[1],g=o[2],n,e),e.point(f,d)}function b(){v.point=y,e.lineEnd()}function _(){m(),v.point=w,v.lineEnd=k}function w(t,e){x(r=t,e),a=f,o=d,l=p,s=h,c=g,v.point=x}function k(){i(f,d,u,p,h,g,a,o,r,l,s,c,n,e),v.lineEnd=b,b()}return v}:function(e){return Ln(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function i(n,a,o,l,s,c,u,f,d,p,h,g,v,y){var x=u-n,b=f-a,_=x*x+b*b;if(_>4*e&&v--){var w=l+p,k=s+h,M=c+g,T=Math.sqrt(w*w+k*k+M*M),A=Math.asin(M/=T),L=m(m(M)-1)e||m((x*P+b*D)/_-.5)>.3||l*p+s*h+c*g0&&16,a):Math.sqrt(e)},a}function An(t){this.stream=t}function Ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sn(t){return Cn(function(){return t})()}function Cn(e){var r,n,a,i,o,l,s=Tn(function(t,e){return[(t=r(t,e))[0]*c+i,o-t[1]*c]}),c=150,u=480,f=250,d=0,p=0,h=0,g=0,v=0,y=tn,x=P,b=null,_=null;function w(t){return[(t=a(t[0]*Ct,t[1]*Ct))[0]*c+i,o-t[1]*c]}function k(t){return(t=a.invert((t[0]-i)/c,(o-t[1])/c))&&[t[0]*Ot,t[1]*Ot]}function M(){a=Gr(n=zn(h,g,v),r);var t=r(d,p);return i=u-t[0]*c,o=f+t[1]*c,T()}function T(){return l&&(l.valid=!1,l=null),w}return w.stream=function(t){return l&&(l.valid=!1),(l=On(y(n,s(x(t))))).valid=!0,l},w.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,tn):function(t){var e=Math.cos(t),r=e>0,n=m(e)>kt;return Jr(a,function(t){var e,l,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var p,h=[f,d],g=a(f,d),v=r?g?0:o(f,d):g?o(f+(f<0?Tt:-Tt),d):0;if(!e&&(c=s=g)&&t.lineStart(),g!==s&&(p=i(e,h),(Fr(e,p)||Fr(h,p))&&(h[0]+=kt,h[1]+=kt,g=a(h[0],h[1]))),g!==s)u=0,g?(t.lineStart(),p=i(h,e),t.point(p[0],p[1])):(p=i(e,h),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(n&&e&&r^g){var y;v&l||!(y=i(h,e,!0))||(u=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!g||e&&Fr(e,h)||t.point(h[0],h[1]),e=h,s=g,l=v},lineEnd:function(){s&&t.lineEnd(),e=null},clean:function(){return u|(c&&s)<<1}}},In(t,6*Ct),r?[0,-t]:[-Tt,t-Tt]);function a(t,r){return Math.cos(t)*Math.cos(r)>e}function i(t,r,n){var a=[1,0,0],i=zr(Pr(t),Pr(r)),o=Dr(i,i),l=i[0],s=o-l*l;if(!s)return!n&&t;var c=e*o/s,u=-e*l/s,f=zr(a,i),d=Rr(a,c);Er(d,Rr(i,u));var p=f,h=Dr(d,p),g=Dr(p,p),v=h*h-g*(Dr(d,d)-1);if(!(v<0)){var y=Math.sqrt(v),x=Rr(p,(-h-y)/g);if(Er(x,d),x=Ir(x),!n)return x;var b,_=t[0],w=r[0],k=t[1],M=r[1];w<_&&(b=_,_=w,w=b);var T=w-_,A=m(T-Tt)0^x[1]<(m(x[0]-_)Tt^(_<=x[0]&&x[0]<=w)){var L=Rr(p,(-h+y)/g);return Er(L,d),[x,Ir(L)]}}}function o(e,n){var a=r?t:Tt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),n<-a?i|=4:n>a&&(i|=8),i}}((b=+t)*Ct),T()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):P,T()):_},w.scale=function(t){return arguments.length?(c=+t,M()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],M()):[u,f]},w.center=function(t){return arguments.length?(d=t[0]%360*Ct,p=t[1]%360*Ct,M()):[d*Ot,p*Ot]},w.rotate=function(t){return arguments.length?(h=t[0]%360*Ct,g=t[1]%360*Ct,v=t.length>2?t[2]%360*Ct:0,M()):[h*Ot,g*Ot,v*Ot]},t.rebind(w,s,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&k,M()}}function On(t){return Ln(t,function(e,r){t.point(e*Ct,r*Ct)})}function Pn(t,e){return[t,e]}function Dn(t,e){return[t>Tt?t-At:t<-Tt?t+At:t,e]}function zn(t,e,r){return t?e||r?Gr(Rn(t),Nn(e,r)):Rn(t):e||r?Nn(e,r):Dn}function En(t){return function(e,r){return[(e+=t)>Tt?e-At:e<-Tt?e+At:e,r]}}function Rn(t){var e=En(t);return e.invert=En(-t),e}function Nn(t,e){var r=Math.cos(t),n=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*r+l*n;return[Math.atan2(s*a-u*i,l*r-c*n),Et(u*a+s*i)]}return o.invert=function(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*a-s*i;return[Math.atan2(s*a+c*i,l*r+u*n),Et(u*r-l*n)]},o}function In(t,e){var r=Math.cos(t),n=Math.sin(t);return function(a,i,o,l){var s=o*e;null!=a?(a=Fn(r,a),i=Fn(r,i),(o>0?ai)&&(a+=o*At)):(a=t+o*At,i=t-.5*s);for(var c,u=a;o>0?u>i:u2?t[2]*Ct:0),e.invert=function(e){return(e=t.invert(e[0]*Ct,e[1]*Ct))[0]*=Ot,e[1]*=Ot,e},e},Dn.invert=Pn,t.geo.circle=function(){var t,e,r=[0,0],n=6;function a(){var t="function"==typeof r?r.apply(this,arguments):r,n=zn(-t[0]*Ct,-t[1]*Ct,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=n(t,e)),t[0]*=Ot,t[1]*=Ot}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(r=t,a):r},a.angle=function(r){return arguments.length?(e=In((t=+r)*Ct,n*Ct),a):t},a.precision=function(r){return arguments.length?(e=In(t*Ct,(n=+r)*Ct),a):n},a.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Ct,a=t[1]*Ct,i=e[1]*Ct,o=Math.sin(n),l=Math.cos(n),s=Math.sin(a),c=Math.cos(a),u=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-s*f*l)*r),s*u+c*f*l)},t.geo.graticule=function(){var e,r,n,a,i,o,l,s,c,u,f,d,p=10,h=p,g=90,v=360,y=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(a/g)*g,n,g).map(f).concat(t.range(Math.ceil(s/v)*v,l,v).map(d)).concat(t.range(Math.ceil(r/p)*p,e,p).filter(function(t){return m(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/h)*h,i,h).filter(function(t){return m(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(d(l).slice(1),f(n).reverse().slice(1),d(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(a=+t[0][0],n=+t[1][0],s=+t[0][1],l=+t[1][1],a>n&&(t=a,a=n,n=t),s>l&&(t=s,s=l,l=t),x.precision(y)):[[a,s],[n,l]]},x.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),o>i&&(t=o,o=i,i=t),x.precision(y)):[[r,o],[e,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],h=+t[1],x):[p,h]},x.precision=function(t){return arguments.length?(y=+t,c=Bn(o,i,90),u=jn(r,e,y),f=Bn(s,l,90),d=jn(a,n,y),x):y},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,r,n=Hn,a=qn;function i(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||a.apply(this,arguments))},i.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,i):n},i.target=function(t){return arguments.length?(a=t,r="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return r=t[0]*Ct,n=t[1]*Ct,a=e[0]*Ct,i=e[1]*Ct,o=Math.cos(n),l=Math.sin(n),s=Math.cos(i),c=Math.sin(i),u=o*Math.cos(r),f=o*Math.sin(r),d=s*Math.cos(a),p=s*Math.sin(a),h=2*Math.asin(Math.sqrt(Nt(i-n)+o*s*Nt(a-r))),g=1/Math.sin(h),(v=h?function(t){var e=Math.sin(t*=h)*g,r=Math.sin(h-t)*g,n=r*u+e*d,a=r*f+e*p,i=r*l+e*c;return[Math.atan2(a,n)*Ot,Math.atan2(i,Math.sqrt(n*n+a*a))*Ot]}:function(){return[r*Ot,n*Ot]}).distance=h,v;var r,n,a,i,o,l,s,c,u,f,d,p,h,g,v},t.geo.length=function(e){return mn=0,t.geo.stream(e,Vn),mn};var Vn={sphere:R,point:R,lineStart:function(){var t,e,r;function n(n,a){var i=Math.sin(a*=Ct),o=Math.cos(a),l=m((n*=Ct)-t),s=Math.cos(l);mn+=Math.atan2(Math.sqrt((l=o*Math.sin(l))*l+(l=r*i-e*o*s)*l),e*i+r*o*s),t=n,e=i,r=o}Vn.point=function(a,i){t=a*Ct,e=Math.sin(i*=Ct),r=Math.cos(i),Vn.point=n},Vn.lineEnd=function(){Vn.point=Vn.lineEnd=R}},lineEnd:R,polygonStart:R,polygonEnd:R};function Un(t,e){function r(e,r){var n=Math.cos(e),a=Math.cos(r),i=t(n*a);return[i*a*Math.sin(e),i*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),a=e(n),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,n*o),Math.asin(n&&r*i/n)]},r}var Gn=Un(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sn(Gn)}).raw=Gn;var Xn=Un(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},P);function Zn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Tt/4+t/2)},a=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),i=r*Math.pow(n(t),a)/a;if(!a)return Jn;function o(t,e){i>0?e<-St+kt&&(e=-St+kt):e>St-kt&&(e=St-kt);var r=i/Math.pow(n(e),a);return[r*Math.sin(a*t),i-r*Math.cos(a*t)]}return o.invert=function(t,e){var r=i-e,n=Pt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(i/n,1/a))-St]},o}function Yn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),a=r/n+t;if(m(n)1&&Dt(t[r[n-2]],t[r[n-1]],t[a])<=0;)--n;r[n++]=a}return r.slice(0,n)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sn(Kn)}).raw=Kn,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=Qn(ta),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,r=ra;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,a=ve(e),i=ve(r),o=t.length,l=[],s=[];for(n=0;n=0;--n)p.push(t[l[c[n]][2]]);for(n=+f;nkt)l=l.L;else{if(!((a=i-wa(l,o))>kt)){n>-kt?(e=l.P,r=l):a>-kt?(e=l,r=l.N):e=r=l;break}if(!l.R){e=l;break}l=l.R}var s=ya(t);if(fa.insert(e,s),e||r){if(e===r)return La(e),r=ya(e.site),fa.insert(s,r),s.edge=r.edge=Oa(e.site,s.site),Aa(e),void Aa(r);if(r){La(e),La(r);var c=e.site,u=c.x,f=c.y,d=t.x-u,p=t.y-f,h=r.site,g=h.x-u,v=h.y-f,y=2*(d*v-p*g),m=d*d+p*p,x=g*g+v*v,b={x:(v*m-p*x)/y+u,y:(d*x-g*m)/y+f};Pa(r.edge,c,h,b),s.edge=Oa(c,t,null,b),r.edge=Oa(t,h,null,b),Aa(e),Aa(r)}else s.edge=Oa(e.site,s.site)}}function _a(t,e){var r=t.site,n=r.x,a=r.y,i=a-e;if(!i)return n;var o=t.P;if(!o)return-1/0;var l=(r=o.site).x,s=r.y,c=s-e;if(!c)return l;var u=l-n,f=1/i-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-i/2)))/f+n:(n+l)/2}function wa(t,e){var r=t.N;if(r)return _a(r,e);var n=t.site;return n.y===e?n.x:1/0}function ka(t){this.site=t,this.edges=[]}function Ma(t,e){return e.angle-t.angle}function Ta(){Ea(this),this.x=this.y=this.arc=this.site=this.cy=null}function Aa(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,a=t.site,i=r.site;if(n!==i){var o=a.x,l=a.y,s=n.x-o,c=n.y-l,u=i.x-o,f=2*(s*(v=i.y-l)-c*u);if(!(f>=-Mt)){var d=s*s+c*c,p=u*u+v*v,h=(v*d-c*p)/f,g=(s*p-u*d)/f,v=g+l,y=ga.pop()||new Ta;y.arc=t,y.site=a,y.x=h+o,y.y=v+Math.sqrt(h*h+g*g),y.cy=v,t.circle=y;for(var m=null,x=pa._;x;)if(y.y=l)return;if(d>h){if(i){if(i.y>=c)return}else i={x:v,y:s};r={x:v,y:c}}else{if(i){if(i.y1)if(d>h){if(i){if(i.y>=c)return}else i={x:(s-a)/n,y:s};r={x:(c-a)/n,y:c}}else{if(i){if(i.y=l)return}else i={x:o,y:n*o+a};r={x:l,y:n*l+a}}else{if(i){if(i.xkt||m(a-r)>kt)&&(l.splice(o,0,new Da((y=i.site,x=u,b=m(n-f)kt?{x:f,y:m(e-f)kt?{x:m(r-h)kt?{x:d,y:m(e-d)kt?{x:m(r-p)=r&&c.x<=a&&c.y>=n&&c.y<=o?[[r,o],[a,o],[a,n],[r,n]]:[]).point=t[l]}),e}function l(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/kt)*kt,y:Math.round(a(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Fa(l(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fa(l(t)).cells.forEach(function(r,n){for(var a,i,o,l,s=r.site,c=r.edges.sort(Ma),u=-1,f=c.length,d=c[f-1].edge,p=d.l===s?d.r:d.l;++ui&&(a=e.slice(i,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(n=n[0])?l[o]?l[o]+=n:l[++o]=n:(l[++o]=null,s.push({i:o,x:Ga(r,n)})),i=Ya.lastIndex;return ig&&(g=s.x),s.y>v&&(v=s.y),c.push(s.x),u.push(s.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-h;function M(t,e,r,n,a,i,o,l){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var s=t.x,c=t.y;if(null!=s)if(m(s-r)+m(c-n)<.01)T(t,e,r,n,a,i,o,l);else{var u=t.point;t.x=t.y=t.point=null,T(t,u,s,c,a,i,o,l),T(t,e,r,n,a,i,o,l)}else t.x=r,t.y=n,t.point=e}else T(t,e,r,n,a,i,o,l)}function T(t,e,r,n,a,i,o,l){var s=.5*(a+o),c=.5*(i+l),u=r>=s,f=n>=c,d=f<<1|u;t.leaf=!1,u?a=s:o=s,f?i=c:l=c,M(t=t.nodes[d]||(t.nodes[d]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(A,t,+y(t,++f),+x(t,f),p,h,g,v)}}),e,r,n,a,i,o,l)}w>k?v=h+w:g=p+k;var A={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(A,t,+y(t,++f),+x(t,f),p,h,g,v)}};if(A.visit=function(t){!function t(e,r,n,a,i,o){if(!e(r,n,a,i,o)){var l=.5*(n+i),s=.5*(a+o),c=r.nodes;c[0]&&t(e,c[0],n,a,l,s),c[1]&&t(e,c[1],l,a,i,s),c[2]&&t(e,c[2],n,s,l,o),c[3]&&t(e,c[3],l,s,i,o)}}(t,A,p,h,g,v)},A.find=function(t){return function(t,e,r,n,a,i,o){var l,s=1/0;return function t(c,u,f,d,p){if(!(u>i||f>o||d=_)<<1|e>=b,k=w+4;w=0&&!(n=t.interpolators[a](e,r)););return n}function Ja(t,e){var r,n=[],a=[],i=t.length,o=e.length,l=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function ii(t){return 1-Math.cos(t*St)}function oi(t){return Math.pow(2,10*(t-1))}function li(t){return 1-Math.sqrt(1-t*t)}function si(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ci(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ui(t){var e,r,n,a=[t.a,t.b],i=[t.c,t.d],o=di(a),l=fi(a,i),s=di(((e=i)[0]+=(n=-l)*(r=a)[0],e[1]+=n*r[1],e))||0;a[0]*i[1]=0?t.slice(0,n):t,i=n>=0?t.slice(n+1):"in";return a=$a.get(a)||Qa,i=Ka.get(i)||P,e=i(a.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,a=e.c,i=e.l,o=r.h-n,l=r.c-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.c:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Zt(n+o*t,a+l*t,i+s*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,a=e.s,i=e.l,o=r.h-n,l=r.s-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.s:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ut(n+o*t,a+l*t,i+s*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,a=e.a,i=e.b,o=r.l-n,l=r.a-a,s=r.b-i;return function(t){return te(n+o*t,a+l*t,i+s*t)+""}},t.interpolateRound=ci,t.transform=function(e){var r=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ui(e?e.matrix:pi)})(e)},ui.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pi={a:1,b:0,c:0,d:1,e:0,f:0};function hi(t){return t.length?t.pop()+",":""}function gi(e,r){var n=[],a=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push("translate(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,a),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(hi(r)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&r.push(hi(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,a),function(t,e,r,n){t!==e?n.push({i:r.push(hi(r)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&r.push(hi(r)+"skewX("+e+")")}(e.skew,r.skew,n,a),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push(hi(r)+"scale(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(hi(r)+"scale("+e+")")}(e.scale,r.scale,n,a),e=r=null,function(t){for(var e,r=-1,i=a.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,s.end({type:"end",alpha:n=0})):t>0&&(s.start({type:"start",alpha:n=t}),e=Me(l.tick)),l):n},l.start=function(){var t,e,r,n=y.length,s=m.length,u=c[0],h=c[1];for(t=0;t=0;)r.push(a[n])}function Ci(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(u=c[s]),u.parent=i,u.depth=i.depth+1;r&&(i.value=0),i.children=c}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Ci(a,function(e){var n,a;t&&(n=e.children)&&n.sort(t),r&&(a=e.parent)&&(a.value+=e.value)}),l}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Si(t,function(t){t.children&&(t.value=0)}),Ci(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var a=e.call(this,t,n);return function t(e,r,n,a){var i=e.children;if(e.x=r,e.y=e.depth*a,e.dx=n,e.dy=a,i&&(o=i.length)){var o,l,s,c=-1;for(n=e.value?n/e.value:0;++cl&&(l=n),o.push(n)}for(r=0;ra&&(n=r,a=e);return n}function Vi(t){return t.reduce(Ui,0)}function Ui(t,e){return t+e[1]}function Gi(t,e){return Xi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Xi(t,e){for(var r=-1,n=+t[0],a=(t[1]-n)/e,i=[];++r<=e;)i[r]=a*r+n;return i}function Zi(e){return[t.min(e),t.max(e)]}function Yi(t,e){return t.value-e.value}function Wi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function Qi(t,e){var r=e.x-t.x,n=e.y-t.y,a=t.r+e.r;return.999*a*a>r*r+n*n}function $i(t){if((e=t.children)&&(s=e.length)){var e,r,n,a,i,o,l,s,c=1/0,u=-1/0,f=1/0,d=-1/0;if(e.forEach(Ki),(r=e[0]).x=-r.r,r.y=0,x(r),s>1&&((n=e[1]).x=n.r,n.y=0,x(n),s>2))for(eo(r,n,a=e[2]),x(a),Wi(r,a),r._pack_prev=a,Wi(a,n),n=r._pack_next,i=3;i0)for(o=-1;++o=f[0]&&s<=f[1]&&((l=c[t.bisect(d,s,1,h)-1]).y+=g,l.push(i[o]));return c}return i.value=function(t){return arguments.length?(r=t,i):r},i.range=function(t){return arguments.length?(n=ve(t),i):n},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Xi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Yi),n=0,a=[1,1];function i(t,i){var o=r.call(this,t,i),l=o[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,Ci(l,function(t){t.r=+u(t.value)}),Ci(l,$i),n){var f=n*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;Ci(l,function(t){t.r+=f}),Ci(l,$i),Ci(l,function(t){t.r-=f})}return function t(e,r,n,a){var i=e.children;e.x=r+=a*e.x;e.y=n+=a*e.y;e.r*=a;if(i)for(var o=-1,l=i.length;++op.x&&(p=t),t.depth>h.depth&&(h=t)});var g=r(d,p)/2-d.x,v=n[0]/(p.x+r(p,d)/2+g),y=n[1]/(h.depth||1);Si(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*y})}return c}function o(t){var e=t.children,n=t.parent.children,a=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+r(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+r(t._,a._));t.parent.A=function(t,e,n){if(e){for(var a,i=t,o=t,l=e,s=i.parent.children[0],c=i.m,u=o.m,f=l.m,d=s.m;l=ao(l),i=no(i),l&&i;)s=no(s),(o=ao(o)).a=t,(a=l.z+f-i.z-c+r(l._,i._))>0&&(io(oo(l,t,n),t,a),c+=a,u+=a),f+=l.m,c+=i.m,d+=s.m,u+=o.m;l&&!ao(o)&&(o.t=l,o.m+=f-u),i&&!no(s)&&(s.t=i,s.m+=c-d,n=t)}return n}(t,a,t.parent.A||n[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=n[0],t.y=t.depth*n[1]}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t)?s:null,i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null==(n=t)?null:s,i):a?n:null},Li(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],a=!1;function i(i,o){var l,s=e.call(this,i,o),c=s[0],u=0;Ci(c,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=l?u+=r(e,l):0,e.y=0,l=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(c),d=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(c),p=f.x-r(f,d)/2,h=d.x+r(d,f)/2;return Ci(c,a?function(t){t.x=(t.x-c.x)*n[0],t.y=(c.y-t.y)*n[1]}:function(t){t.x=(t.x-p)/(h-p)*n[0],t.y=(1-(c.y?t.y/c.y:1))*n[1]}),s}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t),i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null!=(n=t),i):a?n:null},Li(i,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,a=[1,1],i=null,o=lo,l=!1,s="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var r,n,a=-1,i=t.length;++a0;)l.push(r=c[a-1]),l.area+=r.area,"squarify"!==s||(n=p(l,g))<=d?(c.pop(),d=n):(l.area-=l.pop().area,h(l,g,i,!1),g=Math.min(i.dx,i.dy),l.length=l.area=0,d=1/0);l.length&&(h(l,g,i,!0),l.length=l.area=0),e.forEach(f)}}function d(t){var e=t.children;if(e&&e.length){var r,n=o(t),a=e.slice(),i=[];for(u(a,n.dx*n.dy/t.value),i.area=0;r=a.pop();)i.push(r),i.area+=r.area,null!=r.z&&(h(i,r.z?n.dx:n.dy,n,!a.length),i.length=i.area=0);e.forEach(d)}}function p(t,e){for(var r,n=t.area,a=0,i=1/0,o=-1,l=t.length;++oa&&(a=r));return e*=e,(n*=n)?Math.max(e*a*c/n,n/(e*i*c)):1/0}function h(t,e,r,a){var i,o=-1,l=t.length,s=r.x,c=r.y,u=e?n(t.area/e):0;if(e==r.dx){for((a||u>r.dy)&&(u=r.dy);++or.dx)&&(u=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,l=a?yi:vi;return i=t(e,r,l,n),o=t(r,e,l,Wa),s}function s(t){return i(t)}s.invert=function(t){return o(t)};s.domain=function(t){return arguments.length?(e=t.map(Number),l()):e};s.range=function(t){return arguments.length?(r=t,l()):r};s.rangeRound=function(t){return s.range(t).interpolate(ci)};s.clamp=function(t){return arguments.length?(a=t,l()):a};s.interpolate=function(t){return arguments.length?(n=t,l()):n};s.ticks=function(t){return bo(e,t)};s.tickFormat=function(t,r){return _o(e,t,r)};s.nice=function(t){return mo(e,t),l()};s.copy=function(){return t(e,r,n,a)};return l()}([0,1],[0,1],Wa,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function l(t){return a?Math.pow(n,t):-Math.pow(n,-t)}function s(t){return r(o(t))}s.invert=function(t){return l(r.invert(t))};s.domain=function(t){return arguments.length?(a=t[0]>=0,r.domain((i=t.map(Number)).map(o)),s):i};s.base=function(t){return arguments.length?(n=+t,r.domain(i.map(o)),s):n};s.nice=function(){var t=po(i.map(o),a?Math:To);return r.domain(t),i=t.map(l),s};s.ticks=function(){var t=co(i),e=[],r=t[0],s=t[1],c=Math.floor(o(r)),u=Math.ceil(o(s)),f=n%1?2:n;if(isFinite(u-c)){if(a){for(;c0;d--)e.push(l(c)*d);for(c=0;e[c]s;u--);e=e.slice(c,u)}return e};s.tickFormat=function(e,r){if(!arguments.length)return Mo;arguments.length<2?r=Mo:"function"!=typeof r&&(r=t.format(r));var a=Math.max(1,n*e/s.ticks().length);return function(t){var e=t/l(Math.round(o(t)));return e*n0?a[t-1]:r[0],tf?0:1;if(c=Lt)return s(c,p)+(l?s(l,1-p):"")+"Z";var h,g,v,y,m,x,b,_,w,k,M,T,A=0,L=0,S=[];if((y=(+o.apply(this,arguments)||0)/2)&&(v=n===Do?Math.sqrt(l*l+c*c):+n.apply(this,arguments),p||(L*=-1),c&&(L=Et(v/c*Math.sin(y))),l&&(A=Et(v/l*Math.sin(y)))),c){m=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var C=Math.abs(f-u-2*L)<=Tt?0:1;if(L&&Fo(m,x,b,_)===p^C){var O=(u+f)/2;m=c*Math.cos(O),x=c*Math.sin(O),b=_=null}}else m=x=0;if(l){w=l*Math.cos(f-A),k=l*Math.sin(f-A),M=l*Math.cos(u+A),T=l*Math.sin(u+A);var P=Math.abs(u-f+2*A)<=Tt?0:1;if(A&&Fo(w,k,M,T)===1-p^P){var D=(u+f)/2;w=l*Math.cos(D),k=l*Math.sin(D),M=T=null}}else w=k=0;if(d>kt&&(h=Math.min(Math.abs(c-l)/2,+r.apply(this,arguments)))>.001){g=l0?0:1}function Bo(t,e,r,n,a){var i=t[0]-e[0],o=t[1]-e[1],l=(a?n:-n)/Math.sqrt(i*i+o*o),s=l*o,c=-l*i,u=t[0]+s,f=t[1]+c,d=e[0]+s,p=e[1]+c,h=(u+d)/2,g=(f+p)/2,v=d-u,y=p-f,m=v*v+y*y,x=r-n,b=u*p-d*f,_=(y<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-b*b)),w=(b*y-v*_)/m,k=(-b*v-y*_)/m,M=(b*y+v*_)/m,T=(-b*v+y*_)/m,A=w-h,L=k-g,S=M-h,C=T-g;return A*A+L*L>S*S+C*C&&(w=M,k=T),[[w-s,k-c],[w*r/x,k*r/x]]}function jo(t){var e=ea,r=ra,n=Xr,a=qo,i=a.key,o=.7;function l(i){var l,s=[],c=[],u=-1,f=i.length,d=ve(e),p=ve(r);function h(){s.push("M",a(t(c),o))}for(;++u1&&a.push("H",n[0]);return a.join("")},"step-before":Uo,"step-after":Go,basis:Yo,"basis-open":function(t){if(t.length<4)return qo(t);var e,r=[],n=-1,a=t.length,i=[0],o=[0];for(;++n<3;)e=t[n],i.push(e[0]),o.push(e[1]);r.push(Wo($o,i)+","+Wo($o,o)),--n;for(;++n9&&(a=3*e/Math.sqrt(a),o[l]=a*r,o[l+1]=a*n));l=-1;for(;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+o[l]*o[l])),i.push([a||0,o[l]*a||0]);return i}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Vo(t){return t.join("L")+"Z"}function Uo(t){for(var e=0,r=t.length,n=t[0],a=[n[0],",",n[1]];++e1){l=e[1],i=t[s],s++,n+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-l[0])+","+(i[1]-l[1])+","+i[0]+","+i[1];for(var c=2;cTt)+",1 "+e}function s(t,e,r,n){return"Q 0,0 "+n}return i.radius=function(t){return arguments.length?(r=ve(t),i):r},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(n=ve(t),i):n},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Hn,e=qn,r=al;function n(n,a){var i=t.call(this,n,a),o=e.call(this,n,a),l=(i.y+o.y)/2,s=[i,{x:i.x,y:l},{x:o.x,y:l},o];return"M"+(s=s.map(r))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=al,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-St;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=ol,e=il;function r(r,n){return(sl.get(t.call(this,r,n))||ll)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var sl=t.map({circle:ll,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*ul)),r=e*ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=sl.keys();var cl=Math.sqrt(3),ul=Math.tan(30*Ct);Z.transition=function(t){for(var e,r,n=hl||++yl,a=bl(t),i=[],o=gl||{time:Date.now(),ease:ai,delay:0,duration:250},l=-1,s=this.length;++l0;)c[--d].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[n]:delete t[r],1}f||(i=a.time,o=Me(function(t){var e=f.delay;if(o.t=e+i,e<=t)return d(t-e);o.c=d},0,i),f=u[n]={tween:new b,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++u.count)}vl.call=Z.call,vl.empty=Z.empty,vl.node=Z.node,vl.size=Z.size,t.transition=function(e,r){return e&&e.transition?hl?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vl,vl.select=function(t){var e,r,n,a=this.id,i=this.namespace,o=[];t=Y(t);for(var l=-1,s=this.length;++lrect,.s>rect").attr("width",l[1]-l[0])}function g(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function v(){var f,v,y=this,m=t.select(t.event.target),x=n.of(y,arguments),b=t.select(y),_=m.datum(),w=!/^(n|s)$/.test(_)&&a,k=!/^(e|w)$/.test(_)&&i,M=m.classed("extent"),T=xt(y),A=t.mouse(y),L=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(M||(f=null,A[0]-=l[1],A[1]-=s[1],M=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==M&&(A[0]+=l[1],A[1]+=s[1],M=0,F())});if(t.event.changedTouches?L.on("touchmove.brush",O).on("touchend.brush",D):L.on("mousemove.brush",O).on("mouseup.brush",D),b.interrupt().selectAll("*").interrupt(),M)A[0]=l[0]-A[0],A[1]=s[0]-A[1];else if(_){var S=+/w$/.test(_),C=+/^n/.test(_);v=[l[1-S]-A[0],s[1-C]-A[1]],A[0]=l[S],A[1]=s[C]}else t.event.altKey&&(f=A.slice());function O(){var e=t.mouse(y),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),M||(t.event.altKey?(f||(f=[(l[0]+l[1])/2,(s[0]+s[1])/2]),A[0]=l[+(e[0]1?{floor:function(e){for(;l(e=t.floor(e));)e=zl(e-1);return e},ceil:function(e){for(;l(e=t.ceil(e));)e=zl(+e+1);return e}}:t))},a.ticks=function(t,e){var r=co(a.domain()),n=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],zl(+r[1]+1),e<1?1:e)},a.tickFormat=function(){return n},a.copy=function(){return Dl(e.copy(),r,n)},yo(a,e)}function zl(t){return new Date(t)}Sl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Pl:Ol,Pl.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Pl.toString=Ol.toString,ze.second=Ie(function(t){return new Ee(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),ze.seconds=ze.second.range,ze.seconds.utc=ze.second.utc.range,ze.minute=Ie(function(t){return new Ee(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),ze.minutes=ze.minute.range,ze.minutes.utc=ze.minute.utc.range,ze.hour=Ie(function(t){var e=t.getTimezoneOffset()/60;return new Ee(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),ze.hours=ze.hour.range,ze.hours.utc=ze.hour.utc.range,ze.month=Ie(function(t){return(t=ze.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),ze.months=ze.month.range,ze.months.utc=ze.month.utc.range;var El=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Rl=[[ze.second,1],[ze.second,5],[ze.second,15],[ze.second,30],[ze.minute,1],[ze.minute,5],[ze.minute,15],[ze.minute,30],[ze.hour,1],[ze.hour,3],[ze.hour,6],[ze.hour,12],[ze.day,1],[ze.day,2],[ze.week,1],[ze.month,1],[ze.month,3],[ze.year,1]],Nl=Sl.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Xr]]),Il={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(zl)},floor:P,ceil:P};Rl.year=ze.year,ze.scale=function(){return Dl(t.scale.linear(),Rl,Nl)};var Fl=Rl.map(function(t){return[t[0].utc,t[1]]}),Bl=Cl.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Xr]]);function jl(t){return JSON.parse(t.responseText)}function Hl(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Fl.year=ze.year.utc,ze.scale.utc=function(){return Dl(t.scale.linear(),Fl,Bl)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return me(t,"application/json",jl,e)},t.html=function(t,e){return me(t,"text/html",Hl,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],9:[function(t,e,r){(function(n,a){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,l=void 0,s=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(l?l(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,d="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],16:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(l=e,l===window||l===document||l===document.body?n:l.getBoundingClientRect());var l;return r[0]=a-o.left,r[1]=i-o.top,r}},{}],17:[function(t,e,r){var n,a=t("./lib/build-log"),i=t("./lib/epsilon"),o=t("./lib/intersecter"),l=t("./lib/segment-chainer"),s=t("./lib/segment-selector"),c=t("./lib/geojson"),u=!1,f=i();function d(t,e,r){var a=n.segments(t),i=n.segments(e),o=r(n.combine(a,i));return n.polygon(o)}n={buildLog:function(t){return!0===t?u=a():!1===t&&(u=!1),!1!==u&&u.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,u);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,u).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:s.union(t.combined,u),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:s.intersect(t.combined,u),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:s.difference(t.combined,u),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:s.differenceRev(t.combined,u),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:s.xor(t.combined,u),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:l(t.segments,f,u),inverted:t.inverted}},polygonFromGeoJSON:function(t){return c.toPolygon(n,t)},polygonToGeoJSON:function(t){return c.fromPolygon(n,f,t)},union:function(t,e){return d(t,e,n.selectUnion)},intersect:function(t,e){return d(t,e,n.selectIntersect)},difference:function(t,e){return d(t,e,n.selectDifference)},differenceRev:function(t,e){return d(t,e,n.selectDifferenceRev)},xor:function(t,e){return d(t,e,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),e.exports=n},{"./lib/build-log":18,"./lib/epsilon":19,"./lib/geojson":20,"./lib/intersecter":21,"./lib/segment-chainer":23,"./lib/segment-selector":24}],18:[function(t,e,r){e.exports=function(){var t,e=0,r=!1;function n(e,r){return t.list.push({type:e,data:r?JSON.parse(JSON.stringify(r)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return n("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return n("div_seg",{seg:t,pt:e}),n("chop",{seg:t,pt:e})},statusRemove:function(t){return n("pop_seg",{seg:t})},segmentUpdate:function(t){return n("seg_update",{seg:t})},segmentNew:function(t,e){return n("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return n("rem_seg",{seg:t})},tempStatus:function(t,e,r){return n("temp_status",{seg:t,above:e,below:r})},rewind:function(t){return n("rewind",{seg:t})},status:function(t,e,r){return n("status",{seg:t,above:e,below:r})},vert:function(e){return e===r?t:(r=e,n("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),n("log",{txt:t})},reset:function(){return n("reset")},selected:function(t){return n("selected",{segs:t})},chainStart:function(t){return n("chain_start",{seg:t})},chainRemoveHead:function(t,e){return n("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return n("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return n("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return n("chain_match",{index:t})},chainClose:function(t){return n("chain_close",{index:t})},chainAddHead:function(t,e){return n("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return n("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return n("chain_con",{index1:t,index2:e})},chainReverse:function(t){return n("chain_rev",{index:t})},chainJoin:function(t,e){return n("chain_join",{index1:t,index2:e})},done:function(){return n("done")}}}},{}],19:[function(t,e,r){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,r,n){var a=r[0],i=r[1],o=n[0],l=n[1],s=e[0];return(o-a)*(e[1]-i)-(l-i)*(s-a)>=-t},pointBetween:function(e,r,n){var a=e[1]-r[1],i=n[0]-r[0],o=e[0]-r[0],l=n[1]-r[1],s=o*i+a*l;return!(s-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-a>t&&(i-c)*(a-u)/(o-u)+c-n>t&&(l=!l),i=c,o=u}return l}};return e}},{}],20:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),a=1;a0})}function u(t,n){var a=t.seg,i=n.seg,o=a.start,l=a.end,c=i.start,u=i.end;r&&r.checkIntersection(a,i);var f=e.linesIntersect(o,l,c,u);if(!1===f){if(!e.pointsCollinear(o,l,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(l,c))return!1;var d=e.pointsSame(o,c),p=e.pointsSame(l,u);if(d&&p)return n;var h=!d&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(l,c,u);if(d)return g?s(n,l):s(t,u),n;h&&(p||(g?s(n,l):s(t,u)),s(n,o))}else 0===f.alongA&&(-1===f.alongB?s(t,c):0===f.alongB?s(t,f.pt):1===f.alongB&&s(t,u)),0===f.alongB&&(-1===f.alongA?s(n,o):0===f.alongA?s(n,f.pt):1===f.alongA&&s(n,l));return!1}for(var f=[];!i.isEmpty();){var d=i.getHead();if(r&&r.vert(d.pt[0]),d.isStart){r&&r.segmentNew(d.seg,d.primary);var p=c(d),h=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(h){var t=u(d,h);if(t)return t}return!!g&&u(d,g)}r&&r.tempStatus(d.seg,!!h&&h.seg,!!g&&g.seg);var y,m,x=v();if(x)t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=d.seg.myFill,r&&r.segmentUpdate(x.seg),d.other.remove(),d.remove();if(i.getHead()!==d){r&&r.rewind(d.seg);continue}t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=g?g.seg.myFill.above:a,d.seg.myFill.above=m?!d.seg.myFill.below:d.seg.myFill.below):null===d.seg.otherFill&&(y=g?d.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:d.primary?o:a,d.seg.otherFill={above:y,below:y}),r&&r.status(d.seg,!!h&&h.seg,!!g&&g.seg),d.other.status=p.insert(n.node({ev:d}))}else{var b=d.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(l.exists(b.prev)&&l.exists(b.next)&&u(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!d.primary){var _=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=_}f.push(d.seg)}i.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,a,i,o=t[t.length-1],s=0;s1)for(var r=1;r1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=O(t,360),e=O(e,100),r=O(r,100),0===e)n=a=i=r;else{var l=r<.5?r*(1+e):r+e-r*e,s=2*r-l;n=o(s,l,t+1/3),a=o(s,l,t),i=o(s,l,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(e.h,s,u),f=!0,d="hsl"),e.hasOwnProperty("a")&&(i=e.a));var p,h,g;return i=C(i),{ok:f,format:e.format||d,r:o(255,l(a.r,0)),g:o(255,l(a.g,0)),b:o(255,l(a.b,0)),a:i}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=i(100*this._a)/100,this._format=s.format||u.format,this._gradientType=s.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=u.ok,this._tc_id=a++}function u(t,e,r){t=O(t,255),e=O(e,255),r=O(r,255);var n,a,i=l(t,e,r),s=o(t,e,r),c=(i+s)/2;if(i==s)n=a=0;else{var u=i-s;switch(a=c>.5?u/(2-i-s):u/(i+s),i){case t:n=(e-r)/u+(e>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(c(n));return i}function A(t,e){e=e||6;for(var r=c(t).toHsv(),n=r.h,a=r.s,i=r.v,o=[],l=1/e;e--;)o.push(c({h:n,s:a,v:i})),i=(i+l)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,a=this.toRgb();return e=a.r/255,r=a.g/255,n=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=C(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return d(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,a){var o=[z(i(t).toString(16)),z(i(e).toString(16)),z(i(r).toString(16)),z(R(n))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*O(this._r,255))+"%",g:i(100*O(this._g,255))+"%",b:i(100*O(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%)":"rgba("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[d(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=c(t);r="#"+p(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(T,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(M,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:E(t[n]));t=r}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:s(),g:s(),b:s()})},c.mix=function(t,e,r){r=0===r?0:r||50;var n=c(t).toRgb(),a=c(e).toRgb(),i=r/100;return c({r:(a.r-n.r)*i+n.r,g:(a.g-n.g)*i+n.g,b:(a.b-n.b)*i+n.b,a:(a.a-n.a)*i+n.a})},c.readability=function(e,r){var n=c(e),a=c(r);return(t.max(n.getLuminance(),a.getLuminance())+.05)/(t.min(n.getLuminance(),a.getLuminance())+.05)},c.isReadable=function(t,e,r){var n,a,i=c.readability(t,e);switch(a=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},c.mostReadable=function(t,e,r){var n,a,i,o,l=null,s=0;a=(r=r||{}).includeFallbackColors,i=r.level,o=r.size;for(var u=0;us&&(s=n,l=c(e[u]));return c.isReadable(t,l,{level:i,size:o})||!a?l:(r.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],r))};var L=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=c.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(L);function C(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function O(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,l(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function P(t){return o(1,l(0,t))}function D(t){return parseInt(t,16)}function z(t){return 1==t.length?"0"+t:""+t}function E(t){return t<=1&&(t=100*t+"%"),t}function R(e){return t.round(255*parseFloat(e)).toString(16)}function N(t){return D(t)/255}var I,F,B,j=(F="[\\s|\\(]+("+(I="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",B="[\\s|\\(]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",{CSS_UNIT:new RegExp(I),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+B),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+B),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+B),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function H(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],27:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],28:[function(t,e,r){"use strict";var n=t("./arrow_paths"),a=t("../../plots/font_attributes"),i=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:a({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",i.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",i.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:a({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":195,"../../plots/cartesian/constants":211,"../../plots/font_attributes":232,"./arrow_paths":27}],29:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=a.getFromId(t,e.xref),n=a.getFromId(t,e.yref);e._extremes={},r&&l(e,r),n&&l(e,n)})}function l(t,e){var r,n=e._id,i=n.charAt(0),o=t[i],l=t["a"+i],s=t[i+"ref"],c=t["a"+i+"ref"],u=t["_"+i+"padplus"],f=t["_"+i+"padminus"],d={x:1,y:-1}[i]*t[i+"shift"],p=3*t.arrowsize*t.arrowwidth||0,h=p+d,g=p-d,v=3*t.startarrowsize*t.arrowwidth||0,y=v+d,m=v-d;if(c===s){var x=a.findExtremes(e,[e.r2c(o)],{ppadplus:h,ppadminus:g}),b=a.findExtremes(e,[e.r2c(l)],{ppadplus:Math.max(u,y),ppadminus:Math.max(f,m)});r={min:[x.min[0],b.min[0]],max:[x.max[0],b.max[0]]}}else y=l?y+l:y,m=l?m-l:m,r=a.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(u,h,y),ppadminus:Math.max(f,g,m)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([i,o],t)}},{"../../lib":161,"../../plots/cartesian/axes":205,"./draw":34}],30:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,a,i,o,s,c,u=t._fullLayout.annotations,f=[],d=[],p=[],h=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,l,s=o(t,e),c=s.on,u=s.off.concat(s.explicitOff),f={},d=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var V=!1,U=["x","y"],G=0;G1)&&(K===$?((st=tt.r2fraction(e["a"+Q]))<0||st>1)&&(V=!0):V=!0),X=tt._offset+tt.r2p(e[Q]),W=.5}else"x"===Q?(Y=e[Q],X=b.l+b.w*Y):(Y=1-e[Q],X=b.t+b.h*Y),W=e.showarrow?.5:Y;if(e.showarrow){lt.head=X;var ct=e["a"+Q];J=rt*q(.5,e.xanchor)-nt*q(.5,e.yanchor),K===$?(lt.tail=tt._offset+tt.r2p(ct),Z=J):(lt.tail=X+ct,Z=J+ct),lt.text=lt.tail+J;var ut=x["x"===Q?"width":"height"];if("paper"===$&&(lt.head=o.constrain(lt.head,1,ut-1)),"pixel"===K){var ft=-Math.max(lt.tail-3,lt.text),dt=Math.min(lt.tail+3,lt.text)-ut;ft>0?(lt.tail+=ft,lt.text+=ft):dt>0&&(lt.tail-=dt,lt.text-=dt)}lt.tail+=ot,lt.head+=ot}else Z=J=at*q(W,it),lt.text=X+J;lt.text+=ot,J+=ot,Z+=ot,e["_"+Q+"padplus"]=at/2+Z,e["_"+Q+"padminus"]=at/2-Z,e["_"+Q+"size"]=at,e["_"+Q+"shift"]=J}if(t._dragging||!V){var pt=0,ht=0;if("left"!==e.align&&(pt=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(ht=(D-m)*("middle"===e.valign?.5:1)),u)n.select("svg").attr({x:N+pt-1,y:N+ht}).call(c.setClipUrl,F?A:null);else{var gt=N+ht-h.top,vt=N+pt-h.left;H.call(f.positionText,vt,gt).call(c.setClipUrl,F?A:null)}B.select("rect").call(c.setRect,N,N,w,D),I.call(c.setRect,E/2,E/2,R-E,j-E),z.call(c.setTranslate,Math.round(L.x.text-R/2),Math.round(L.y.text-j/2)),O.attr({transform:"rotate("+S+","+L.x.text+","+L.y.text+")"});var yt,mt=function(r,n){C.selectAll(".annotation-arrow-g").remove();var u=L.x.head,f=L.y.head,d=L.x.tail+r,h=L.y.tail+n,y=L.x.text+r,m=L.y.text+n,x=o.rotationXYMatrix(S,y,m),w=o.apply2DTransform(x),A=o.apply2DTransform2(x),P=+I.attr("width"),D=+I.attr("height"),E=y-.5*P,R=E+P,N=m-.5*D,F=N+D,B=[[E,N,E,F],[E,F,R,F],[R,F,R,N],[R,N,E,N]].map(A);if(!B.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){B.forEach(function(t){var e=o.segmentsIntersect(d,h,u,f,t[0],t[1],t[2],t[3]);e&&(d=e.x,h=e.y)});var j=e.arrowwidth,H=e.arrowcolor,q=e.arrowside,V=C.append("g").style({opacity:s.opacity(H)}).classed("annotation-arrow-g",!0),U=V.append("path").attr("d","M"+d+","+h+"L"+u+","+f).style("stroke-width",j+"px").call(s.stroke,s.rgb(H));if(g(U,q,e),_.annotationPosition&&U.node().parentNode&&!i){var G=u,X=f;if(e.standoff){var Z=Math.sqrt(Math.pow(u-d,2)+Math.pow(f-h,2));G+=e.standoff*(d-u)/Z,X+=e.standoff*(h-f)/Z}var Y,W,J=V.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(d-G)+","+(h-X),transform:"translate("+G+","+X+")"}).style("stroke-width",j+6+"px").call(s.stroke,"rgba(0,0,0,0)").call(s.fill,"rgba(0,0,0,0)");p.init({element:J.node(),gd:t,prepFn:function(){var t=c.getTranslate(z);Y=t.x,W=t.y,l&&l.autorange&&k(l._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(Y,W),a=n[0]+t,i=n[1]+r;z.call(c.setTranslate,a,i),M("x",l?l.p2r(l.r2p(e.x)+t):e.x+t/b.w),M("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/b.h),e.axref===e.xref&&M("ax",l.p2r(l.r2p(e.ax)+t)),e.ayref===e.yref&&M("ay",v.p2r(v.r2p(e.ay)+r)),V.attr("transform","translate("+t+","+r+")"),O.attr({transform:"rotate("+S+","+a+","+i+")"})},doneFn:function(){a.call("relayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&mt(0,0),P)p.init({element:z.node(),gd:t,prepFn:function(){yt=O.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?M("ax",l.p2r(l.r2p(e.ax)+t)):M("ax",e.ax+t),e.ayref===e.yref?M("ay",v.p2r(v.r2p(e.ay)+r)):M("ay",e.ay+r),mt(t,r);else{if(i)return;var a,o;if(l)a=l.p2r(l.r2p(e.x)+t);else{var s=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-s/2;a=p.align(c+t/b.w,s,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-r/b.h,u,0,1,e.yanchor)}M("x",a),M("y",o),l&&v||(n=p.getCursor(l?.5:a,v?.5:o,e.xanchor,e.yanchor))}O.attr({transform:"translate("+t+","+r+")"+yt}),d(z,n)},doneFn:function(){d(z),a.call("relayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else z.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,y=f.backoff*p+r.standoff,m=d.backoff*h+r.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},l={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-l.x,b=o.y-l.y;if(c=(s=Math.atan2(b,x))+Math.PI,y&&m&&y+m>Math.sqrt(x*x+b*b))return void P();if(y){if(y*y>x*x+b*b)return void P();var _=y*Math.cos(s),w=y*Math.sin(s);l.x+=_,l.y+=w,t.attr({x2:l.x,y2:l.y})}if(m){if(m*m>x*x+b*b)return void P();var k=m*Math.cos(s),M=m*Math.sin(s);o.x-=k,o.y-=M,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var T=u.getTotalLength(),A="";if(T1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+l+'"]').remove():(s._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(s.x)*r[0],e.yaxis.r2l(s.y)*r[1],e.zaxis.r2l(s.z)*r[2]]),n(t.graphDiv,s,l,t.id,s._xa,s._ya))}}},{"../../plots/gl3d/project":235,"../annotations/draw":34}],41:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var i=r.attrRegex,o=Object.keys(t),l=0;l=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var l=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+l+", "+n[3]+")":"rgb("+l+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(n(t))},i.opacity=function(t){return t?n(t).getAlpha():0},i.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},i.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var a=n(e||s).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-r.a)+r.r*r.a,g:i.g*(1-r.a)+r.g*r.a,b:i.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},i.contrast=function(t,e,r){var a=n(t);return 1!==a.getAlpha()&&(a=n(i.combine(t,s))),(a.isDark()?e?a.lighten(e):s:r?a.darken(r):l).toString()},i.stroke=function(t,e){var r=n(e);t.style({stroke:i.tinyRGB(r),"stroke-opacity":r.getAlpha()})},i.fill=function(t,e){var r=n(e);t.style({fill:i.tinyRGB(r),"fill-opacity":r.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,r,n,a,o=Object.keys(t);for(e=0;e0?L>=E:L<=E));S++)L>N&&L0?L>=E:L<=E));S++)L>C[0]&&L1){var it=Math.pow(10,Math.floor(Math.log(at)/Math.LN10));rt*=it*c.roundUp(at/it,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(tt.tick0=0)}tt.dtick=rt}tt.domain=[J+Z,J+U-Z],tt.setScale();var ot=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(M.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(M.cbbg,!0),t.append("g").classed(M.cbfills,!0),t.append("g").classed(M.cblines,!0),t.append("g").classed(M.cbaxis,!0).classed(M.crisp,!0),t.append("g").classed(M.cbtitleunshift,!0).append("g").classed(M.cbtitle,!0),t.append("rect").classed(M.cboutline,!0),t.select(".cbtitle").datum(0)})});ot.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var lt=ot.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")");tt._axislayer=ot.select(".cbaxis");var st=0;if(-1!==["top","bottom"].indexOf(r.titleside)){var ct,ut=k.l+(r.x+G)*k.w,ft=tt.titlefont.size;ct="top"===r.titleside?(1-(J+U-Z))*k.h+k.t+3+.75*ft:(1-(J+Z))*k.h+k.t-3-.25*ft,yt(tt._id+"title",{attributes:{x:ut,y:ct,"text-anchor":"start"}})}var dt,pt,ht,gt=c.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.titleside)){var i=ot.select(".cbtitle"),o=i.select("text"),s=[-r.outlinewidth/2,r.outlinewidth/2],u=i.select(".h"+tt._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),u?(st=d.bBox(u).height)>f&&(s[1]-=(st-f)/2):o.node()&&!o.classed(M.jsPlaceholder)&&(st=d.bBox(o.node()).height),st){if(st+=5,"top"===r.titleside)tt.domain[1]-=st/k.h,s[1]*=-1;else{tt.domain[0]+=st/k.h;var p=g.lineCount(o);s[1]+=(1-p)*f}i.attr("transform","translate("+s+")"),tt.setScale()}}ot.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-tt.domain[1]))+")"),tt._axislayer.attr("transform","translate(0,"+Math.round(-k.t)+")");var h=ot.select(".cbfills").selectAll("rect.cbfill").data(P);h.enter().append("rect").classed(M.cbfill,!0).style("stroke","none"),h.exit().remove();var m=C.map(tt.c2p).map(Math.round).sort(function(t,e){return t-e});h.each(function(i,o){var l=[0===o?C[0]:(P[o]+P[o-1])/2,o===P.length-1?C[1]:(P[o]+P[o+1])/2].map(tt.c2p).map(Math.round);l[1]=c.constrain(l[1]+(l[1]>l[0])?1:-1,m[0],m[1]);var s=n.select(this).attr({x:Y,width:Math.max(H,2),y:n.min(l),height:Math.max(n.max(l)-n.min(l),2)});if(r.fillgradient)d.gradient(s,t,e,"vertical",r.fillgradient,"fill");else{var u=z(i).replace("e-","");s.attr("fill",a(u).toHexString())}});var x=ot.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?O:[]);return x.enter().append("path").classed(M.cbline,!0),x.exit().remove(),x.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round(tt.c2p(t))+r.line.width/2%1)+"h"+H).call(d.lineGroupStyle,r.line.width,D(t),r.line.dash)}),tt._axislayer.selectAll("g."+tt._id+"tick,path").remove(),tt._pos=Y+H+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),tt.side="right",c.syncOrAsync([function(){return l.doTicksSingle(t,tt,!0)},function(){if(-1===["top","bottom"].indexOf(r.titleside)){var e=tt.titlefont.size,a=tt._offset+tt._length/2,i=k.l+(tt.position||0)*k.w+("right"===tt.side?10+e*(tt.showticklabels?1:.5):-10-e*(tt.showticklabels?.5:0));yt("h"+tt._id+"title",{avoid:{selection:n.select(t).selectAll("g."+tt._id+"tick"),side:r.titleside,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var n=H+r.outlinewidth/2+d.bBox(tt._axislayer.node()).width;if((F=lt.select("text")).node()&&!F.classed(M.jsPlaceholder)){var a,o=lt.select(".h"+tt._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(r.titleside)?d.bBox(o).width:d.bBox(lt.node()).right-Y-k.l,n=Math.max(n,a)}var l=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,s=Q-$;ot.select(".cbbg").attr({x:Y-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:$-X,width:Math.max(l,2),height:Math.max(s+2*X,2)}).call(p.fill,r.bgcolor).call(p.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),ot.selectAll(".cboutline").attr({x:Y,y:$+r.ypad+("top"===r.titleside?st:0),width:Math.max(H,2),height:Math.max(s-2*r.ypad-st,2)}).call(p.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var c=({center:.5,right:1}[r.xanchor]||0)*l;ot.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=m[r.yanchor],h=x[r.yanchor];"pixels"===r.lenmode?(u.y=r.y,u.t=s*f,u.b=s*h):(u.t=u.b=0,u.yt=r.y+r.len*f,u.yb=r.y-r.len*h);var g=m[r.xanchor],v=x[r.xanchor];if("pixels"===r.thicknessmode)u.x=r.x,u.l=l*g,u.r=l*v;else{var y=l-H;u.l=y*g,u.r=y*v,u.xl=r.x-r.thickness*g,u.xr=r.x+r.thickness*v}i.autoMargin(t,e,u)}],t);if(gt&>.then&&(t._promises||[]).push(gt),t._context.edits.colorbarPosition)s.init({element:ot.node(),gd:t,prepFn:function(){dt=ot.attr("transform"),f(ot)},moveFn:function(t,e){ot.attr("transform",dt+" translate("+t+","+e+")"),pt=s.align(W+t/k.w,q,0,1,r.xanchor),ht=s.align(J-e/k.h,U,0,1,r.yanchor);var n=s.getCursor(pt,ht,r.xanchor,r.yanchor);f(ot,n)},doneFn:function(){f(ot),void 0!==pt&&void 0!==ht&&o.call("restyle",t,{"colorbar.x":pt,"colorbar.y":ht},A().index)}});return gt}function vt(t,e){return c.coerce(K,tt,w,t,e)}function yt(e,r){var n=A(),a="colorbar.title",i=n._module.colorbar.container;i&&(a=i+"."+a);var o={propContainer:tt,propName:a,traceIndex:n.index,placeholder:v._dfltTitle.colorbar,containerGroup:ot.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;ot.selectAll("."+l+",."+l+"-math-group").remove(),h.draw(t,e,u(o,r||{}))}v._infolayer.selectAll("g."+e).remove()}function A(){var r,n,a=e.substr(2);for(r=0;r=0?a.Reds:a.Blues,l.reversescale?i(m):m),s.autocolorscale||f("autocolorscale",!1))}},{"../../lib":161,"./flip_scale":55,"./scales":62}],52:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":62}],53:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,r,c,u){var f,d=u.prefix,p=u.cLetter,h=d.slice(0,d.length-1),g=d?a.nestedProperty(t,h).get()||{}:t,v=d?a.nestedProperty(e,h).get()||{}:e,y=g[p+"min"],m=g[p+"max"],x=g.colorscale;c(d+p+"auto",!(n(y)&&n(m)&&y=0;a--,i++)e=t[a],n[i]=[1-e[0],e[1]];return n}},{}],56:[function(t,e,r){"use strict";var n=t("./scales"),a=t("./default_scale"),i=t("./is_valid_scale_array");e.exports=function(t,e){if(e||(e=a),!t)return e;function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return"string"==typeof t&&(r(),"string"==typeof t&&r()),i(t)?t:e}},{"./default_scale":52,"./is_valid_scale_array":60,"./scales":62}],57:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=t("./is_valid_scale");e.exports=function(t,e){var r=e?a.nestedProperty(t,e).get()||{}:t,o=r.color,l=!1;if(a.isArrayOrTypedArray(o))for(var s=0;s4/3-l?o:l}},{}],64:[function(t,e,r){"use strict";var n=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,i){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:n.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":161}],65:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),l=t("../../lib"),s=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function d(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,r,n,f,h,g,v,y,m=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;m._mouseDownTime||(m._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,r){return Math.abs(t)b&&(x=Math.max(x-1,1)),m._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!y){var r;try{r=new MouseEvent("click",e)}catch(t){var n=p(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(m),m._dragged=!1}else m._dragged=!1}},u.coverSlip=d},{"../../constants/interactions":142,"../../lib":161,"../../plots/cartesian/constants":211,"../../registry":245,"./align":63,"./cursor":64,"./unhover":66,"has-hover":12,"has-passive-events":13,"mouse-event-offset":16}],66:[function(t,e,r){"use strict";var n=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),l=e.exports={};l.wrapped=function(t,e,r){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),l.raw(t,e,r)},l.raw=function(t,e){var r=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":154,"../../lib/get_graph_div":159,"../../lib/throttle":183,"../fx/constants":80}],67:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],68:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,h=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){c.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(l.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,a){t.call(v.setPosition,e,r).call(v.setSize,n,a)},v.translatePoint=function(t,e,r,n){var i=r.c2p(t.x),o=n.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var a=n.select(this);v.translatePoint(t,a,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,a,i){e.attr("display",r.isPtWithinRange(t,a)&&n.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,l=i.ycalendar,s="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(s).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,a,o,l)})})}},v.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=r||i.width||0,s=a||i.dash||"";l.stroke(e,n||i.color),v.dashLine(e,s,o)},v.lineGroupStyle=function(t,e,r,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,s=a||i.dash||"";n.select(this).call(l.stroke,r||i.color).call(v.dashLine,s,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(l.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){n.select(this).call(l.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var m=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=n.format("~.1f"),M={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,a,o,s){for(var u=o.length,f=M[a],d=new Array(u),p=0;p=100,e.attr("d",b(u,s))}var f,d,p,h=!1;if(t.so)p=o.outlierwidth,d=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,d="mlc"in t?t.mlcc=n.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?l.defaultLine:o.color,c.isArrayOrTypedArray(i.color)&&(f=l.defaultLine,h=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):i.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(l.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var y=i.gradient,m=t.mgt;if(m?h=!0:m=y&&y.type,Array.isArray(m)&&(m=m[0],M[m]||(m=0)),m&&"none"!==m){var x=t.mgc;x?h=!0:x=y.color;var _=r.uid;h&&(_+="-"+t.i),v.gradient(e,a,_,m,[[0,x],[1,f]],"fill")}else l.fill(e,f);p&&l.stroke(e,d)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=h.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.marker||{},i=r.marker||{},l=n.marker||{},s=a.opacity,u=i.opacity,f=l.opacity,d=void 0!==u,h=void 0!==f;(c.isArrayOrTypedArray(s)||d||h)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?d?u:e:h?f:p*e});var g=a.color,v=i.color,y=l.color;(v||y)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:y||e});var m=a.size,x=i.size,b=l.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||m/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.textfont||{},i=r.textfont||{},o=n.textfont||{},s=a.color,c=i.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||s;return t.selected?c||e:u||(c?e:l.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];r.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&i.push(function(t,e){l.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&i.push(function(t,e){var n=e.mx||a.symbol||0,i=r.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(n),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=n.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var l=t.tp||e.textposition,s=L(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,s,f).text(o).call(u.convertToTspans,r).call(A,l,s,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=n.select(this),i=r.selectedTextColorFn(t),o=t.tp||e.textposition,s=L(t,e);l.fill(a,i),A(a,o,s,t.mrc2||t.mrc)})}};var S=.5;function C(t,e,r,a){var i=t[0]-e[0],o=t[1]-e[1],l=r[0]-e[0],s=r[1]-e[1],c=Math.pow(i*i+o*o,S/2),u=Math.pow(l*l+s*s,S/2),f=(u*u*i-c*c*l)*a,d=(u*u*o-c*c*s)*a,p=3*u*(c+u),h=3*c*(c+u);return[[n.round(e[0]+(p&&f/p),2),n.round(e[1]+(p&&d/p),2)],[n.round(e[0]-(h&&f/h),2),n.round(e[1]-(h&&d/h),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],a=[];for(r=1;r=1e4&&(v.savedBBoxes={},D=0),r&&(v.savedBBoxes[r]=y),D++,c.extendFlat({},y)},v.setClipUrl=function(t,e){if(e){if(void 0===v.baseUrl){var r=n.select("base");r.size()&&r.attr("href")?v.baseUrl=window.location.href.split("#")[0]:v.baseUrl=""}t.attr("clip-path","url("+v.baseUrl+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||0,r=r||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+r+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||1,r=r||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+r+")").trim(),t[a]("transform",i),i};var E=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(E,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var R=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,a=n.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),l=parseFloat(i.attr("y")||0),s=(a.attr("transform")||"").match(R);t=1===e&&1===r?[]:["translate("+o+","+l+")","scale("+e+","+r+")","translate("+-o+","+-l+")"],s&&t.push(s),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":141,"../../constants/interactions":142,"../../constants/xmlns_namespaces":144,"../../lib":161,"../../lib/svg_text_utils":182,"../../registry":245,"../../traces/scatter/make_bubble_size_func":299,"../../traces/scatter/subtypes":306,"../color":43,"../colorscale":58,"./symbol_defs":69,d3:8,"fast-isnumeric":10,tinycolor2:26}],69:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+a+i+a+i+o+i+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),a=n.round(-t,2),i=n.round(-.309*t,2);return"M"+e+","+i+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+r+"V"+r+"L0,"+e+"L-"+a+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+a+"H"+r+"L"+e+",0L"+r+",-"+a+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),a=n.round(.951*e,2),i=n.round(.363*e,2),o=n.round(.588*e,2),l=n.round(-e,2),s=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+s+"H"+a+"L"+i+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+i+","+c+"L-"+a+","+s+"H-"+r+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),a=n.round(.76*t,2);return"M-"+a+",0l-"+r+",-"+e+"h"+a+"l"+r+",-"+e+"l"+r+","+e+"h"+a+"l-"+r+","+e+"l"+r+","+e+"h-"+a+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+a+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+a+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:8}],70:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],71:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function l(t,e,r,a){var l=e["error_"+a]||{},s=[];if(l.visible&&-1!==["linear","log"].indexOf(r.type)){for(var c=o(l),u=0;u0;t.each(function(t){var u,f=t[0].trace,d=f.error_x||{},p=f.error_y||{};f.ids&&(u=function(t){return t.id});var h=o.hasMarkers(f)&&f.marker.maxdisplayed>0;p.visible||d.visible||(t=[]);var g=n.select(this).selectAll("g.errorbar").data(t,u);if(g.exit().remove(),t.length){d.visible||g.selectAll("path.xerror").remove(),p.visible||g.selectAll("path.yerror").remove(),g.style("opacity",1);var v=g.enter().append("g").classed("errorbar",!0);c&&v.style("opacity",0).transition().duration(r.duration).style("opacity",1),i.setClipUrl(g,e.layerClipId),g.each(function(t){var e=n.select(this),i=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,l,s);if(!h||t.vis){var o,u=e.select("path.yerror");if(p.visible&&a(i.x)&&a(i.yh)&&a(i.ys)){var f=p.width;o="M"+(i.x-f)+","+i.yh+"h"+2*f+"m-"+f+",0V"+i.ys,i.noYS||(o+="m-"+f+",0h"+2*f),!u.size()?u=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):c&&(u=u.transition().duration(r.duration).ease(r.easing)),u.attr("d",o)}else u.remove();var g=e.select("path.xerror");if(d.visible&&a(i.y)&&a(i.xh)&&a(i.xs)){var v=(d.copy_ystyle?p:d).width;o="M"+i.xh+","+(i.y-v)+"v"+2*v+"m0,-"+v+"H"+i.xs,i.noXS||(o+="m0,-"+v+"v"+2*v),!g.size()?g=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):c&&(g=g.transition().duration(r.duration).ease(r.easing)),g.attr("d",o)}else g.remove()}})}})}},{"../../traces/scatter/subtypes":306,"../drawing":68,d3:8,"fast-isnumeric":10}],76:[function(t,e,r){"use strict";var n=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},i=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(a.stroke,r.color),i.copy_ystyle&&(i=r),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":43,d3:8}],77:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":232}],78:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry");function i(t,e,r,a){a=a||n.identity,Array.isArray(t)&&(e[0][r]=a(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var l=0;l=0&&r.index-1&&o.length>x&&(o=x>3?o.substr(0,x-3)+"...":o.substr(0,x))}void 0!==t.zLabel?(void 0!==t.xLabel&&(c+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(c+="y: "+t.yLabel+"
"),c+=(c?"z: ":"")+t.zLabel):O&&t[a+"Label"]===M?c=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(c=t.yLabel):c=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(c+=(c?"
":"")+t.text),void 0!==t.extraText&&(c+=(c?"
":"")+t.extraText),""===c&&(""===o&&e.remove(),c=o);var b=e.select("text.nums").call(u.font,t.fontFamily||h,t.fontSize||g,t.fontColor||m).text(c).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),_=e.select("text.name"),T=0;o&&o!==c?(_.call(u.font,t.fontFamily||h,t.fontSize||g,v).text(o).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),T=_.node().getBoundingClientRect().width+2*k):(_.remove(),e.select("rect").remove()),e.select("path").style({fill:p,stroke:m});var A,P,D=b.node().getBoundingClientRect(),z=t.xa._offset+(t.x0+t.x1)/2,E=t.ya._offset+(t.y0+t.y1)/2,R=Math.abs(t.x1-t.x0),N=Math.abs(t.y1-t.y0),I=D.width+w+k+T;t.ty0=L-D.top,t.bx=D.width+2*k,t.by=D.height+2*k,t.anchor="start",t.txwidth=D.width,t.tx2width=T,t.offset=0,i?(t.pos=z,A=E+N/2+I<=C,P=E-N/2-I>=0,"top"!==t.idealAlign&&A||!P?A?(E+=N/2,t.anchor="start"):t.anchor="middle":(E-=N/2,t.anchor="end")):(t.pos=E,A=z+R/2+I<=S,P=z-R/2-I>=0,"left"!==t.idealAlign&&A||!P?A?(z+=R/2,t.anchor="start"):t.anchor="middle":(z-=R/2,t.anchor="end")),b.attr("text-anchor",t.anchor),T&&_.attr("text-anchor",t.anchor),e.attr("transform","translate("+z+","+E+")"+(i?"rotate("+y+")":""))}),N}function T(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var a="end"===t.anchor?-1:1,i=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],l=o*(w+k),c=l+o*(t.txwidth+k),f=0,d=t.offset;"middle"===t.anchor&&(l-=t.tx2width/2,c+=t.txwidth/2+k),e&&(d*=-_,f=t.offset*b),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(d-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+d)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(d-w)+"Z"),i.call(s.positionText,l+f,d+t.ty0-t.by/2+k),t.tx2width&&(r.select("text.name").call(s.positionText,c+o*k+f,d+t.ty0-t.by/2+k),r.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,d-t.by/2-1,t.tx2width,t.by+2))}})}function A(t,e){var r=t.index,n=t.trace||{},a=t.cd[0],i=t.cd[r]||{},l=Array.isArray(r)?function(t,e){return o.castOption(a,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(i,n,t,e)};function s(e,r,n){var a=l(r,n);a&&(t[e]=a)}if(s("hoverinfo","hi","hoverinfo"),s("bgcolor","hbg","hoverlabel.bgcolor"),s("borderColor","hbc","hoverlabel.bordercolor"),s("fontFamily","htf","hoverlabel.font.family"),s("fontSize","hts","hoverlabel.font.size"),s("fontColor","htc","hoverlabel.font.color"),s("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function L(t,e){var r,n,a=e.container,o=e.fullLayout,l=e.event,s=!!t.hLinePoint,c=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),c||s){var d=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(s){var p,h,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(p=l.pointerX,h=l.pointerY):(p=r._offset+g.x,h=n._offset+g.y);var v,y,m=i.readability(g.color,d)<1.5?f.contrast(d):g.color,x=n.spikemode,b=n.spikethickness,_=n.spikecolor||m,w=n._boundingBox,k=(w.left+w.right)/2w[0]._length||et<0||et>k[0]._length)return d.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,R="xval"in e?g.flat(s,e.xval):g.p2c(w,tt),N="yval"in e?g.flat(s,e.yval):g.p2c(k,et),!a(R[0])||!a(N[0]))return o.warn("Fx.hover failed",e,t),d.unhoverRaw(t,e)}var at=1/0;for(F=0;FZ&&(J.splice(0,Z),at=J[0].distance),m&&0!==W&&0===J.length){X.distance=W,X.index=!1;var ct=j._module.hoverPoints(X,U,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=W})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var dt=ft[0];a(dt.x0)&&a(dt.y0)&&(ut=vt(dt),(!$.vLinePoint||$.vLinePoint.spikeDistance>ut.spikeDistance)&&($.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var ht=pt[0];a(ht.x0)&&a(ht.y0)&&(ut=vt(ht),(!$.hLinePoint||$.hLinePoint.spikeDistance>ut.spikeDistance)&&($.hLinePoint=ut))}}}}function gt(t,e){for(var r,n=null,a=1/0,i=0;i1||J.length>1)||"closest"===E&&K&&J.length>1,Ct=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),Ot={hovermode:E,rotateLabels:St,bgColor:Ct,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},Pt=M(J,Ot,t);if(function(t,e,r){var n,a,i,o,l,s,c,u=0,f=1,d=t.map(function(t,n){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!n&&o&&o[0]>o[1]!==i&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?x:1)/2,pmin:0,pmax:i?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],r=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=r.pos+r.dp+r.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;n=!1}if(!(i<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=i;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos>e.pmax-1&&(s.del=!0,c--);for(o=0;o=0;l--)t[l].dp-=i;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(;!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&v.pmin===y.pmin&&v.pmax===y.pmax){for(l=g.length-1;l>=0;l--)g[l].dp+=a;for(h.push.apply(h,g),d.splice(o+1,1),c=0,l=h.length-1;l>=0;l--)c+=h[l].dp;for(i=c/h.length,l=h.length-1;l>=0;l--)h[l].dp-=i;n=!1}else o++}d.forEach(p)}for(o=d.length-1;o>=0;o--){var m=d[o];for(l=m.length-1;l>=0;l--){var b=m[l],_=t[b.i];_.offset=b.dp,_.del=b.del}}}(J,St?"xa":"ya",u),T(Pt,St),e.target&&e.target.tagName){var Dt=h.getComponentMethod("annotations","hasClickToShow")(t,At);c(n.select(e.target),Dt?"pointer":"")}if(!e.target||i||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var a=r[n],i=t._hoverdata[n];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber))return!0}return!1}(t,0,Tt))return;Tt&&t.emit("plotly_unhover",{event:e,points:Tt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:R,yvals:N})}(t,e,r,i)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0},a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M([r],o,e.gd);return T(l,o.rotateLabels),l.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0}}),a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M(r,o,e.gd),s=0;return l.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){d||p||h||"independent"===M("pattern")&&(d=!0),v._hasSubplotGrid=d;var x,b,_="top to bottom"===M("roworder"),w=d?.2:.1,k=d?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",M,w,x,m),y:u("y",M,k,b,y,_)}}else delete e.grid}function M(t,e){return n.coerce(r,v,s,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,a,i,o,l,s,u,d=t.grid||{},p=e._subplots,h=r._hasSubplotGrid,g=r.rows,v=r.columns,y="independent"===r.pattern,m=r._axisMap={};if(h){var x=d.subplots||[];s=r.subplots=new Array(g);var b=1;for(n=0;n=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],96:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes");e.exports={bgcolor:{valType:"color",editType:"legend"},bordercolor:{valType:"color",dflt:a.defaultLine,editType:"legend"},borderwidth:{valType:"number",min:0,dflt:0,editType:"legend"},font:n({editType:"legend"}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v",editType:"legend"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"],editType:"legend"},tracegroupgap:{valType:"number",min:0,dflt:10,editType:"legend"},x:{valType:"number",min:-2,max:3,dflt:1.02,editType:"legend"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left",editType:"legend"},y:{valType:"number",min:-2,max:3,dflt:1,editType:"legend"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"legend"},editType:"legend"}},{"../../plots/font_attributes":232,"../color/attributes":42}],97:[function(t,e,r){"use strict";e.exports={scrollBarWidth:6,scrollBarMinHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4,textOffsetX:40}},{}],98:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib"),i=t("../../plot_api/plot_template"),o=t("./attributes"),l=t("../../plots/layout_attributes"),s=t("./helpers");e.exports=function(t,e,r){for(var c,u,f,d,p=t.legend||{},h=0,g=!1,v="normal",y=0;y1)){var x=i.newContainer(e,"legend");if(_("bgcolor",e.paper_bgcolor),_("bordercolor"),_("borderwidth"),a.coerceFont(_,"font",e.font),_("orientation"),"h"===x.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(c=0,f="left",u=1.1,d="bottom"):(c=0,f="left",u=-.1,d="top")}_("traceorder",v),s.isGrouped(e.legend)&&_("tracegroupgap"),_("x",c),_("xanchor",f),_("y",u),_("yanchor",d),a.noneOrAll(p,x,["x","y"])}function _(t,e){return a.coerce(p,x,o,t,e)}}},{"../../lib":161,"../../plot_api/plot_template":195,"../../plots/layout_attributes":236,"../../registry":245,"./attributes":96,"./helpers":102}],99:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib/events"),s=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),d=t("./handle_click"),p=t("./constants"),h=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,y=g.FROM_TL,m=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=t("./anchor_utils"),k=h.DBLCLICKDELAY;function M(t,e,r,n,a){var i=r.data()[0][0].trace,o={event:a,node:r.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=r.datum()[0].label),!1!==l.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){d(r,t,n)},k);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==l.triggerHandler(t,"plotly_legenddoubleclick",o)&&d(r,t,n)}}function T(t,e,r){var n=t.data()[0][0],i=e._fullLayout,l=n.trace,s=o.traceIs(l,"pie"),u=l.index,d=s?n.label:l.name,h=e._context.edits.legendText&&!s,g=a.ensureSingle(t,"text","legendtext");function y(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,a,i=t.select("g[class*=math-group]"),o=i.node(),l=e._fullLayout.legend.font.size*v;if(o){var s=c.bBox(o);n=s.height,a=s.width,c.setTranslate(i,0,n/4)}else{var u=t.select(".legendtext"),d=f.lineCount(u),h=u.node();n=l*d,a=h?c.bBox(h).width:0;var g=l*(.3+(1-d)/2);f.positionText(u,p.textOffsetX,g)}n=Math.max(n,16)+3,r.height=n,r.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,i.legend.font).text(h?A(d,r):d),f.positionText(g,p.textOffsetX,0),h?g.call(f.makeEditable,{gd:e,text:d}).call(y).on("edit",function(t){this.text(A(t,r)).call(y);var i=n.trace._fullInput||{},l={};if(o.hasTransform(i,"groupby")){var s=o.getTransformIndices(i,"groupby"),c=s[s.length-1],f=a.keyedContainer(i,"transforms["+c+"].styles","target","value.name");f.set(n.trace._group,t),l=f.constructUpdate()}else l.name=t;return o.call("restyle",e,l,u)}):y(g)}function A(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function L(t,e){var r,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimek&&(i=Math.max(i-1,1)),M(e,r,t,i,n.event)}})}function S(t,e,r){var a=t._fullLayout,i=a.legend,o=i.borderwidth,l=_.isGrouped(i),s=0;if(i._width=0,i._height=0,_.isVertical(i))l&&e.each(function(t,e){c.setTranslate(this,0,e*i.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;c.setTranslate(this,o,5+o+i._height+r/2),i._height+=r,i._width=Math.max(i._width,n)}),i._width+=45+2*o,i._height+=10+2*o,l&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),s=40;else if(l){for(var u=[i._width],f=e.data(),d=0,p=f.length;do+w-k,r.each(function(t){var e=t[0],r=v?40+t[0].width:x;o+b+k+r>a._size.w&&(b=0,y+=m,i._height=i._height+m,m=0),c.setTranslate(this,o+b,5+o+e.height/2+y),i._width+=k+r,i._height=Math.max(i._height,e.height),b+=k+r,m=Math.max(e.height,m)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var M=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");c.setRect(r,0,-e.height/2,(M?0:i._width)+s,e.height)})}function C(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");var n="top";w.isBottomAnchor(e)?n="bottom":w.isMiddleAnchor(e)&&(n="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[r],r:e._width*m[r],b:e._height*m[n],t:e._height*y[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var l=e.legend,f=e.showlegend&&x(t.calcdata,l),d=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void i.autoMargin(t,"legend");for(var h=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[r],r:e._width*m[r],b:0,t:0})}(t):C(t);var d=e._size,h=d.l+d.w*l.x,g=d.t+d.h*(1-l.y);w.isRightAnchor(l)?h-=l._width:w.isCenterAnchor(l)&&(h-=l._width/2),w.isBottomAnchor(l)?g-=l._height:w.isMiddleAnchor(l)&&(g-=l._height/2);var v=l._width,x=d.w;v>x?(h=d.l,v=x):(h+v>u&&(h=u-v),h<0&&(h=0),v=Math.min(u-h,l._width));var b,_,k,T,A=l._height,L=d.h;if(A>L?(g=d.t,A=L):(g+A>f&&(g=f-A),g<0&&(g=0),A=Math.min(f-g,l._height)),c.setTranslate(P,h,g),R.on(".drag",null),P.on("wheel",null),l._height<=A||t._context.staticPlot)z.attr({width:v-l.borderwidth,height:A-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),c.setTranslate(E,0,0),D.select("rect").attr({width:v-2*l.borderwidth,height:A-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth}),c.setClipUrl(E,r),c.setRect(R,0,0,0,0),delete l._scrollY;else{var F,B,j=Math.max(p.scrollBarMinHeight,A*A/l._height),H=A-j-2*p.scrollBarMargin,q=l._height-A,V=H/q,U=Math.min(l._scrollY||0,q);z.attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),D.select("rect").attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth+U}),c.setClipUrl(E,r),X(U,j,V),P.on("wheel",function(){X(U=a.constrain(l._scrollY+n.event.deltaY/H*q,0,q),j,V),0!==U&&U!==q&&n.event.preventDefault()});var G=n.behavior.drag().on("dragstart",function(){F=n.event.sourceEvent.clientY,B=U}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||X(U=a.constrain((t.clientY-F)/V+B,0,q),j,V)});R.call(G)}function X(e,r,n){l._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(E,0,-e),c.setRect(R,v,p.scrollBarMargin+e*n,p.scrollBarWidth,r),D.select("rect").attr({y:l.borderwidth+e})}t._context.edits.legendPosition&&(P.classed("cursor-move",!0),s.init({element:P.node(),gd:t,prepFn:function(){var t=c.getTranslate(P);k=t.x,T=t.y},moveFn:function(t,e){var r=k+t,n=T+e;c.setTranslate(P,r,n),b=s.align(r,0,d.l,d.l+d.w,l.xanchor),_=s.align(n,0,d.t+d.h,d.t,l.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("relayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(r,n){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});a.size()>0&&M(t,P,a,r,n)}}))}],t)}}},{"../../constants/alignment":141,"../../constants/interactions":142,"../../lib":161,"../../lib/events":154,"../../lib/svg_text_utils":182,"../../plots/plots":238,"../../registry":245,"../color":43,"../dragelement":65,"../drawing":68,"./anchor_utils":95,"./constants":97,"./get_legend_data":100,"./handle_click":101,"./helpers":102,"./style":104,d3:8}],100:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var r,i,o={},l=[],s=!1,c={},u=0;function f(t,r){if(""!==t&&a.isGrouped(e))-1===l.indexOf(t)?(l.push(t),s=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+u;l.push(n),o[n]=[[r]],u++}}for(r=0;rr[1])return r[1]}return a}function h(t){return t[0]}if(u||f||d){var g={},v={};if(u){g.mc=p("marker.color",h),g.mx=p("marker.symbol",h),g.mo=p("marker.opacity",i.mean,[.2,1]),g.mlc=p("marker.line.color",h),g.mlw=p("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=p("marker.size",i.mean,[2,16]);g.ms=y,v.marker.size=y}d&&(v.line={width:p("line.width",h,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",h),g.ts=10,g.tc=p("textfont.color",h),g.tf=p("textfont.family",h)),r=[i.minExtend(l,g)],(a=i.minExtend(c,v)).selectedpoints=null}var m=n.select(this).select("g.legendpoints"),x=m.selectAll("path.scatterpts").data(u?r:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,a,e),u&&(r[0].mrc=3);var b=m.selectAll("g.pointtext").data(f?r:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,o=n.select(this);o.style("stroke-width",i+"px").call(l.fill,a.fillcolor),i&&l.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,s=n.select(this);s.style("fill","none").call(o.dashLine,a.line.dash,i),i&&l.stroke(s,a.line.color)})})}},{"../../lib":161,"../../registry":245,"../../traces/pie/style_one":280,"../../traces/scatter/subtypes":306,"../color":43,"../drawing":68,d3:8}],105:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),l=t("../../../build/ploticon"),s=o._,c=e.exports={};function u(t,e){var r,a,o=e.currentTarget,l=o.getAttribute("data-attr"),s=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=i.list(t,null,!0),d="on";if("zoom"===l){var p,h="in"===s?.5:2,g=(1+h)/2,v=(1-h)/2;for(a=0;a1?(_=["toggleHover"],w=["resetViews"]):f?(b=["zoomInGeo","zoomOutGeo"],_=["hoverClosestGeo"],w=["resetGeo"]):u?(_=["hoverClosest3d"],w=["resetCameraDefault3d","resetCameraLastSave3d"]):g?(_=["toggleHover"],w=["resetViewMapbox"]):_=p?["hoverClosestGl2d"]:d?["hoverClosestPie"]:["toggleHover"];c&&(_=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!c&&!p||y||(b=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==w[0]&&(w=["resetScale2d"]));u?k=["zoom3d","pan3d","orbitRotation","tableRotation"]:(c||p)&&!y||h?k=["zoom2d","pan2d"]:g||f?k=["pan2d"]:v&&(k=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),a=0,i=0;i0?d+c:c;return{ppad:c,ppadplus:u?h:g,ppadminus:u?g:h}}return{ppad:c}}function u(t,e,r,n,a){var l="category"===t.type?t.r2c:t.d2c;if(void 0!==e)return[l(e),l(r)];if(n){var s,c,u,f,d=1/0,p=-1/0,h=n.match(i.segmentRE);for("date"===t.type&&(l=o.decodeDate(l)),s=0;sp&&(p=f)));return p>=d?[d,p]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:R?V(r.xanchor)+r.x0:V(r.x0),cy:N?U(r.yanchor)-r.y0:U(r.y0),r:i}).style(a).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:R?V(r.xanchor)+r.x1:V(r.x1),cy:N?U(r.yanchor)-r.y1:U(r.y1),r:i}).style(a).classed("cursor-grab",!0),n}():e,Y={element:Z.node(),gd:t,prepFn:function(n){R&&(_=V(r.xanchor));N&&(w=U(r.yanchor));"path"===r.type?P=r.path:(y=R?r.x0:V(r.x0),m=N?r.y0:U(r.y0),x=R?r.x1:V(r.x1),b=N?r.y1:U(r.y1));yb?(k=m,L="y0",M=b,S="y1"):(k=b,L="y1",M=m,S="y0");W(n),$(p,r),function(t,e,r){var n=e.xref,a=e.yref,o=i.getFromId(r,n),s=i.getFromId(r,a),c="";"paper"===n||o.autorange||(c+=n);"paper"===a||s.autorange||(c+=a);t.call(l.setClipUrl,c?"clip"+r._fullLayout._uid+c:null)}(e,r,t),Y.moveFn="move"===D?J:Q},doneFn:function(){u(e),K(p),h(e,t,r),n.call("relayout",t,B.getUpdateObj())},clickFn:function(){K(p)}};function W(t){if(I)D="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Y.element.getBoundingClientRect(),n=r.right-r.left,a=r.bottom-r.top,i=t.clientX-r.left,o=t.clientY-r.top,l=!F&&n>z&&a>E&&!t.shiftKey?c.getCursor(i/n,1-o/a):"move";u(e,l),D=l.split("-")[0]}}function J(n,a){if("path"===r.type){var i=function(t){return t},o=i,l=i;R?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?j("yanchor",r.yanchor=X(w+a)):(l=function(t){return X(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(P,o,l))}else R?j("xanchor",r.xanchor=G(_+n)):(j("x0",r.x0=G(y+n)),j("x1",r.x1=G(x+n))),N?j("yanchor",r.yanchor=X(w+a)):(j("y0",r.y0=X(m+a)),j("y1",r.y1=X(b+a)));e.attr("d",g(t,r)),$(p,r)}function Q(n,a){if(F){var i=function(t){return t},o=i,l=i;R?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?j("yanchor",r.yanchor=X(w+a)):(l=function(t){return X(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(P,o,l))}else if(I){if("resize-over-start-point"===D){var s=y+n,c=N?m-a:m+a;j("x0",r.x0=R?s:G(s)),j("y0",r.y0=N?c:X(c))}else if("resize-over-end-point"===D){var u=x+n,f=N?b-a:b+a;j("x1",r.x1=R?u:G(u)),j("y1",r.y1=N?f:X(f))}}else{var h=~D.indexOf("n")?k+a:k,B=~D.indexOf("s")?M+a:M,Z=~D.indexOf("w")?T+n:T,Y=~D.indexOf("e")?A+n:A;~D.indexOf("n")&&N&&(h=k-a),~D.indexOf("s")&&N&&(B=M-a),(!N&&B-h>E||N&&h-B>E)&&(j(L,r[L]=N?h:X(h)),j(S,r[S]=N?B:X(B))),Y-Z>z&&(j(C,r[C]=R?Z:G(Z)),j(O,r[O]=R?Y:G(Y)))}e.attr("d",g(t,r)),$(p,r)}function $(t,e){(R||N)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=V(R?e.xanchor:a.midRange(r?[e.x0,e.x1]:d.extractPathCoords(e.path,f.paramIsX))),o=U(N?e.yanchor:a.midRange(r?[e.y0,e.y1]:d.extractPathCoords(e.path,f.paramIsY)));if(i=d.roundPositionForSharpStrokeRendering(i,1),o=d.roundPositionForSharpStrokeRendering(o,1),R&&N){var l="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",l)}else if(R){var s="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",s)}else{var c="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",c)}}()}function K(t){t.selectAll(".visual-cue").remove()}c.init(Y),Z.node().onmousemove=W}(t,x,r,e,p)}}function h(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");t.call(l.setClipUrl,n?"clip"+e._fullLayout._uid+n:null)}function g(t,e){var r,n,o,l,s,c,u,p,h=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),y=t._fullLayout._size;if(g?(r=d.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return y.l+y.w*t},v?(o=d.shapePositionToRange(v),l=function(t){return v._offset+v.r2p(o(t,!0))}):l=function(t){return y.t+y.h*(1-t)},"path"===h)return g&&"date"===g.type&&(n=d.decodeDate(n)),v&&"date"===v.type&&(l=d.decodeDate(l)),function(t,e,r){var n=t.path,i=t.xsizemode,o=t.ysizemode,l=t.xanchor,s=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,c=t.charAt(0),u=f.paramIsX[c],d=f.paramIsY[c],p=f.numParams[c],h=t.substr(1).replace(f.paramRE,function(t){return u[n]?t="pixel"===i?e(l)+Number(t):e(t):d[n]&&(t="pixel"===o?r(s)-Number(t):r(t)),++n>p&&(t="X"),t});return n>p&&(h=h.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),c+h})}(e,n,l);if("pixel"===e.xsizemode){var m=n(e.xanchor);s=m+e.x0,c=m+e.x1}else s=n(e.x0),c=n(e.x1);if("pixel"===e.ysizemode){var x=l(e.yanchor);u=x-e.y0,p=x-e.y1}else u=l(e.y0),p=l(e.y1);if("line"===h)return"M"+s+","+u+"L"+c+","+p;if("rect"===h)return"M"+s+","+u+"H"+c+"V"+p+"H"+s+"Z";var b=(s+c)/2,_=(u+p)/2,w=Math.abs(b-s),k=Math.abs(_-u),M="A"+w+","+k,T=b+w+","+_;return"M"+T+M+" 0 1,1 "+(b+","+(_-k))+M+" 0 0,1 "+T+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],l=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return n>=l?t:(i[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var a=0;a0&&(l=l.transition().duration(e.transition.duration).ease(e.transition.easing)),l.attr("transform","translate("+(o-.5*f.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function S(t,e){var r=t._dims;return r.inputAreaStart+f.stepInset+(r.inputAreaLength-2*f.stepInset)*Math.min(1,Math.max(0,e))}function C(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-f.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*f.stepInset-2*r.inputAreaStart)))}function O(t,e,r){var n=r._dims,a=l.ensureSingle(t,"rect",f.railTouchRectClass,function(n){n.call(T,e,t,r).style("pointer-events","all")});a.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,f.tickOffset+r.ticklen+n.labelHeight)}).call(i.fill,r.bgcolor).attr("opacity",0),o.setTranslate(a,0,n.currentValueTotalHeight)}function P(t,e){var r=e._dims,n=r.inputAreaLength-2*f.railInset,a=l.ensureSingle(t,"rect",f.railRectClass);a.attr({width:n,height:f.railWidth,rx:f.railRadius,ry:f.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,f.railInset,.5*(r.inputAreaWidth-f.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[f.name],n=[],a=0;a0?[0]:[]);function l(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,v(e))}if(i.enter().append("g").classed(f.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){n.select(this).selectAll("g."+f.groupClassName).each(l)}).remove(),0!==r.length){var s=i.selectAll("g."+f.groupClassName).data(r,y);s.enter().append("g").classed(f.groupClassName,!0),s.exit().each(l).remove();for(var c=0;c0||d<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[m.side];e.attr("transform","translate("+g+")")}}}D.call(z),O&&(C?D.on(".opacity",null):(L=0,S=!0,D.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),D.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("restyle",t,g,e,y):o.call("relayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(z)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return D.classed("js-placeholder",S),_}};var d=/ [XY][0-9]* /},{"../../constants/interactions":142,"../../lib":161,"../../lib/svg_text_utils":182,"../../plots/plots":238,"../../registry":245,"../color":43,"../drawing":68,d3:8,"fast-isnumeric":10}],135:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,l=t("../../plots/pad_attributes"),s=t("../../plot_api/plot_template").templatedArray,c=s("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(s("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i({},l,{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":155,"../../plot_api/edit_types":188,"../../plot_api/plot_template":195,"../../plots/font_attributes":232,"../../plots/pad_attributes":237,"../color/attributes":42}],136:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],137:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,l=i.buttons;function s(t,e,r){function o(r,a){return n.coerce(t,e,i,r,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function r(r,a){return n.coerce(t,e,l,r,a)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:s})}},{"../../lib":161,"../../plots/array_container_defaults":201,"./attributes":135,"./constants":136}],138:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../legend/anchor_utils"),u=t("../../plot_api/plot_template").arrayEditor,f=t("../../constants/alignment").LINE_SPACING,d=t("./constants"),p=t("./scrollbox");function h(t){return t._index}function g(t,e){return+t.attr(d.menuIndexAttrName)===e._index}function v(t,e,r,n,a,i,o,l){e.active=o,u(t.layout,d.name,e).applyUpdate("active",o),"buttons"===e.type?m(t,n,null,null,e):"dropdown"===e.type&&(a.attr(d.menuIndexAttrName,"-1"),y(t,n,a,i,e),l||m(t,n,a,i,e))}function y(t,e,r,n,a){var i=l.ensureSingle(e,"g",d.headerClassName,function(t){t.style("pointer-events","all")}),s=a._dims,c=a.active,u=a.buttons[c]||d.blankHeaderOpts,f={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},p={width:s.headerWidth,height:s.headerHeight};i.call(x,a,u,t).call(L,a,f,p),l.ensureSingle(e,"text",d.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(d.arrowSymbol[a.direction])}).attr({x:s.headerWidth-d.arrowOffsetX+a.pad.l,y:s.headerHeight/2+d.textOffsetY+a.pad.t}),i.on("click",function(){r.call(S,String(g(r,a)?-1:a._index)),m(t,e,r,n,a)}),i.on("mouseover",function(){i.call(k)}),i.on("mouseout",function(){i.call(M,a)}),o.setTranslate(e,s.lx,s.ly)}function m(t,e,r,i,o){r||(r=e).attr("pointer-events","all");var s=function(t){return-1==+t.attr(d.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?d.dropdownButtonClassName:d.buttonClassName,u=r.selectAll("g."+c).data(l.filterVisible(s)),f=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(f.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var h=0,g=0,y=o._dims,m=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(m?g=y.headerHeight+d.gapButtonHeader:h=y.headerWidth+d.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(g=-d.gapButtonHeader+d.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(h=-d.gapButtonHeader+d.gapButton-y.openWidth);var b={x:y.lx+h+o.pad.l,y:y.ly+g+o.pad.t,yPad:d.gapButton,xPad:d.gapButton,index:0},_={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(l,s){var c=n.select(this);c.call(x,o,l,t).call(L,o,b),c.on("click",function(){n.event.defaultPrevented||(v(t,o,0,e,r,i,s),l.execute&&a.executeAPICommand(t,l.method,l.args),t.emit("plotly_buttonclicked",{menu:o,button:l,active:o.active}))}),c.on("mouseover",function(){c.call(k)}),c.on("mouseout",function(){c.call(M,o),u.call(w,o)})}),u.call(w,o),m?(_.w=Math.max(y.openWidth,y.headerWidth),_.h=b.y-_.t):(_.w=b.x-_.l,_.h=Math.max(y.openHeight,y.headerHeight)),_.direction=o.direction,i&&(u.size()?function(t,e,r,n,a,i){var o,l,s,c=a.direction,u="up"===c||"down"===c,f=a._dims,p=a.active;if(u)for(l=0,s=0;s0?[0]:[]);if(o.enter().append("g").classed(d.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+d.headerGroupClassName).each(i)}).remove(),0!==r.length){var s=o.selectAll("g."+d.headerGroupClassName).data(r,h);s.enter().append("g").classed(d.headerGroupClassName,!0);for(var c=l.ensureSingle(o,"g",d.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,T=l.barLength+2*l.barPad,A=l.barWidth+2*l.barPad,L=h,S=v+y;S+A>c&&(S=c-A);var C=this.container.selectAll("rect.scrollbar-horizontal").data(M?[0]:[]);C.exit().on(".drag",null).remove(),C.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,l.barColor),M?(this.hbar=C.attr({rx:l.barRadius,ry:l.barRadius,x:L,y:S,width:T,height:A}),this._hbarXMin=L+T/2,this._hbarTranslateMax=w-T):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var O=y>k,P=l.barWidth+2*l.barPad,D=l.barLength+2*l.barPad,z=h+g,E=v;z+P>s&&(z=s-P);var R=this.container.selectAll("rect.scrollbar-vertical").data(O?[0]:[]);R.exit().on(".drag",null).remove(),R.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,l.barColor),O?(this.vbar=R.attr({rx:l.barRadius,ry:l.barRadius,x:z,y:E,width:P,height:D}),this._vbarYMin=E+D/2,this._vbarTranslateMax=k-D):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var N=this.id,I=u-.5,F=O?f+P+.5:f+.5,B=d-.5,j=M?p+A+.5:p+.5,H=o._topdefs.selectAll("#"+N).data(M||O?[0]:[]);if(H.exit().remove(),H.enter().append("clipPath").attr("id",N).append("rect"),M||O?(this._clipRect=H.select("rect").attr({x:Math.floor(I),y:Math.floor(B),width:Math.ceil(F)-Math.floor(I),height:Math.ceil(j)-Math.floor(B)}),this.container.call(i.setClipUrl,N),this.bg.attr({x:h,y:v,width:g,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),M||O){var q=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));M&&this.hbar.on(".drag",null).call(V),O&&this.vbar.on(".drag",null).call(V)}this.setTranslate(e,r)},l.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},l.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},l.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},l.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,a=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,a)-r)/(a-r)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,l=i+this._vbarTranslateMax;e=(o.constrain(n.event.y,i,l)-i)/(l-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},l.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/r;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var l=e/n;this.vbar.call(i.setTranslate,t,e+l*this._vbarTranslateMax)}}},{"../../lib":161,"../color":43,"../drawing":68,d3:8}],141:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],142:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],143:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],144:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],145:[function(t,e,r){"use strict";r.version="1.42.5",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config");for(var n=t("./registry"),a=r.register=n.register,i=t("./plot_api"),o=Object.keys(i),l=0;ll-1e-15}function c(t,e){return i(e-t,l)}function u(t,e){if(s(e))return!0;var r,n;e[0](n=a(n,l))&&(n+=l);var i=a(t,l),o=i+l;return i>=r&&i<=n||o>=r&&o<=n}function f(t,e,r,n,a,i,c){a=a||0,i=i||0;var u,f,d,p,h,g=s([r,n]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(u=0,f=o,d=l):r=a&&t<=i);var a,i},pathArc:function(t,e,r,n,a){return f(null,t,e,r,n,a,0)},pathSector:function(t,e,r,n,a){return f(null,t,e,r,n,a,1)},pathAnnulus:function(t,e,r,n,a,i){return f(t,e,r,n,a,i,1)}}},{"./mod":168}],148:[function(t,e,r){"use strict";var n=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function l(t){return n(t)||o(t)}r.isTypedArray=o,r.isArrayOrTypedArray=l,r.isArray1D=function(t){return!l(t[0])},r.ensureArray=function(t,e){return n(t)||(t=[]),t.length=e,t},r.concat=function(){var t,e,r,a,i,o,l,s,c=[],u=!0,f=0;for(r=0;ra.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,a){t%1||!n(t)||void 0!==a.min&&ta.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var a="number"==typeof t;!0!==n.strict&&a?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){a(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(u(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var a=n.regex||s(r);"string"==typeof t&&a.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!s(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=n&&t<=a?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),y=t.charAt(0);!c||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:m);if(!k)return u;var M=k[1],T=k[3]||"1",A=Number(k[5]||1),L=Number(k[7]||0),S=Number(k[9]||0),C=Number(k[11]||0);if(c){if(2===M.length)return u;var O;M=Number(M);try{var P=v.getComponentMethod("calendars","getCal")(e);if(w){var D="i"===T.charAt(T.length-1);T=parseInt(T,10),O=P.newDate(M,P.toMonthIndex(M,T,D),A)}else O=P.newDate(M,Number(T),A)}catch(t){return u}return O?(O.toJD()-g)*f+L*d+S*p+C*h:u}M=2===M.length?(Number(M)+2e3-b)%100+b:Number(M),T-=1;var z=new Date(Date.UTC(2e3,T,A,L,S));return z.setUTCFullYear(M),z.getUTCMonth()!==T?u:z.getUTCDate()!==A?u:z.getTime()+C*h},n=r.MIN_MS=r.dateTime2ms("-9999"),a=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==u};var k=90*f,M=3*d,T=5*p;function A(t,e,r,n,a){if((e||r||n||a)&&(t+=" "+w(e,2)+":"+w(r,2),(n||a)&&(t+=":"+w(n,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=a))return u;e||(e=0);var i,o,l,c,m,x,b=Math.floor(10*s(t+.05,1)),w=Math.round(t-b/10);if(_(r)){var L=Math.floor(w/f)+g,S=Math.floor(s(t,f));try{i=v.getComponentMethod("calendars","getCal")(r).fromJD(L).formatDate("yyyy-mm-dd")}catch(t){i=y("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=n+f&&t<=a-f))return u;var e=Math.floor(10*s(t+.05,1)),r=new Date(Math.round(t-e/10));return A(i.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===u)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return l.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return l.error("unrecognized date",t),e;return t};var L=/%\d?f/g;function S(t,e,r,n){t=t.replace(L,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(a)}var C=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,a,i){if(a=_(a)&&a,!e)if("y"===r)e=i.year;else if("m"===r)e=i.month;else{if("d"!==r)return function(t,e){var r=s(t+.05,f),n=w(Math.floor(r/d),2)+":"+w(s(Math.floor(r/p),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(s(t/h,60),C[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+a}return n}(t,r)+"\n"+S(i.dayMonthYear,t,n,a);e=i.dayMonth+"\n"+i.year}return S(e,t,n,a)};var O=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=s(t,f);if(t=Math.round(t-n),r)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(r),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){l.error("invalid ms "+t+" in calendar "+r)}var c=new Date(t+O);return c.setUTCMonth(c.getUTCMonth()+e)+n-O},r.findExactDates=function(t,e){for(var r,n,a=0,i=0,l=0,s=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}function s(t,e,r,n,a){var i=n*t+a*e;if(i<0)return n*n+a*a;if(i>r){var o=n-t,l=a-e;return o*o+l*l}var s=n*e-a*t;return s*s/r}r.segmentsIntersect=l,r.segmentDistance=function(t,e,r,n,a,i,o,c){if(l(t,e,r,n,a,i,o,c))return 0;var u=r-t,f=n-e,d=o-a,p=c-i,h=u*u+f*f,g=d*d+p*p,v=Math.min(s(u,f,h,a-t,i-e),s(u,f,h,o-t,c-e),s(d,p,g,t-a,e-i),s(d,p,g,r-a,n-i));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,l){if(t===a&&l===i||(n={},a=t,i=l),n[r])return n[r];var s=t.getPointAtLength(o(r-l/2,e)),c=t.getPointAtLength(o(r+l/2,e)),u=Math.atan((c.y-s.y)/(c.x-s.x)),f=t.getPointAtLength(o(r,e)),d={x:(4*f.x+s.x+c.x)/6,y:(4*f.y+s.y+c.y)/6,theta:u};return n[r]=d,d},r.clearLocationCache=function(){a=null},r.getVisibleSegment=function(t,e,r){var n,a,i=e.left,o=e.right,l=e.top,s=e.bottom,c=0,u=t.getTotalLength(),f=u;function d(e){var r=t.getPointAtLength(e);0===e?n=r:e===u&&(a=r);var c=r.xo?r.x-o:0,f=r.ys?r.y-s:0;return Math.sqrt(c*c+f*f)}for(var p=d(c);p;){if((c+=p+r)>f)return;p=d(c)}for(p=d(f);p;){if(c>(f-=p+r))return;p=d(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(n.x-a.x)<.1&&Math.abs(n.y-a.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var a,i,o,l=(n=n||{}).pathLength||t.getTotalLength(),s=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(l)[r]?-1:1,f=0,d=0,p=l;f0?p=a:d=a,f++}return i}},{"./mod":168}],159:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],160:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],161:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../constants/numerical"),o=i.FP_SAFE,l=i.BADNUM,s=e.exports={};s.nestedProperty=t("./nested_property"),s.keyedContainer=t("./keyed_container"),s.relativeAttr=t("./relative_attr"),s.isPlainObject=t("./is_plain_object"),s.toLogRange=t("./to_log_range"),s.relinkPrivateKeys=t("./relink_private");var c=t("./array");s.isTypedArray=c.isTypedArray,s.isArrayOrTypedArray=c.isArrayOrTypedArray,s.isArray1D=c.isArray1D,s.ensureArray=c.ensureArray,s.concat=c.concat;var u=t("./mod");s.mod=u.mod,s.modHalf=u.modHalf;var f=t("./coerce");s.valObjectMeta=f.valObjectMeta,s.coerce=f.coerce,s.coerce2=f.coerce2,s.coerceFont=f.coerceFont,s.coerceHoverinfo=f.coerceHoverinfo,s.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,s.validate=f.validate;var d=t("./dates");s.dateTime2ms=d.dateTime2ms,s.isDateTime=d.isDateTime,s.ms2DateTime=d.ms2DateTime,s.ms2DateTimeLocal=d.ms2DateTimeLocal,s.cleanDate=d.cleanDate,s.isJSDate=d.isJSDate,s.formatDate=d.formatDate,s.incrementMonth=d.incrementMonth,s.dateTick0=d.dateTick0,s.dfltRange=d.dfltRange,s.findExactDates=d.findExactDates,s.MIN_MS=d.MIN_MS,s.MAX_MS=d.MAX_MS;var p=t("./search");s.findBin=p.findBin,s.sorterAsc=p.sorterAsc,s.sorterDes=p.sorterDes,s.distinctVals=p.distinctVals,s.roundUp=p.roundUp,s.sort=p.sort,s.findIndexOfMin=p.findIndexOfMin;var h=t("./stats");s.aggNums=h.aggNums,s.len=h.len,s.mean=h.mean,s.midRange=h.midRange,s.variance=h.variance,s.stdev=h.stdev,s.interp=h.interp;var g=t("./matrix");s.init2dArray=g.init2dArray,s.transposeRagged=g.transposeRagged,s.dot=g.dot,s.translationMatrix=g.translationMatrix,s.rotationMatrix=g.rotationMatrix,s.rotationXYMatrix=g.rotationXYMatrix,s.apply2DTransform=g.apply2DTransform,s.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");s.deg2rad=v.deg2rad,s.rad2deg=v.rad2deg,s.angleDelta=v.angleDelta,s.angleDist=v.angleDist,s.isFullCircle=v.isFullCircle,s.isAngleInsideSector=v.isAngleInsideSector,s.isPtInsideSector=v.isPtInsideSector,s.pathArc=v.pathArc,s.pathSector=v.pathSector,s.pathAnnulus=v.pathAnnulus;var y=t("./geometry2d");s.segmentsIntersect=y.segmentsIntersect,s.segmentDistance=y.segmentDistance,s.getTextLocation=y.getTextLocation,s.clearLocationCache=y.clearLocationCache,s.getVisibleSegment=y.getVisibleSegment,s.findPointOnPath=y.findPointOnPath;var m=t("./extend");s.extendFlat=m.extendFlat,s.extendDeep=m.extendDeep,s.extendDeepAll=m.extendDeepAll,s.extendDeepNoArrays=m.extendDeepNoArrays;var x=t("./loggers");s.log=x.log,s.warn=x.warn,s.error=x.error;var b=t("./regex");s.counterRegex=b.counter;var _=t("./throttle");function w(t){var e={};for(var r in t)for(var n=t[r],a=0;ao?l:a(t)?Number(t):l:l},s.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},s.noop=t("./noop"),s.identity=t("./identity"),s.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},s.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},s.simpleMap=function(t,e,r,n){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,r)?a>10?(s.warn("randstr failed uniqueness"),c):t(e,r,n,(a||0)+1):c},s.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},s.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,a,i,o=t.length,l=2*o,s=2*e-1,c=new Array(s),u=new Array(o);for(r=0;r=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=o&&(a=l-1-a),i+=t[a]*c[n];u[r]=i}return u},s.syncOrAsync=function(t,e,r){var n;function a(){return s.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(a).then(void 0,s.promiseError);return r&&r(e)},s.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},s.noneOrAll=function(t,e,r){if(t){var n,a=!1,i=!0;for(n=0;n1?a+o[1]:"";if(i&&(o.length>1||l.length>4||r))for(;n.test(l);)l=l.replace(n,"$1"+i+"$2");return l+s};var T=/%{([^\s%{}]*)}/g,A=/^\w*$/;s.templateString=function(t,e){var r={};return t.replace(T,function(t,n){return A.test(n)?e[n]||"":(r[n]=r[n]||s.nestedProperty(e,n).get,r[n]()||"")})};s.subplotSort=function(t,e){for(var r=Math.min(t.length,e.length)+1,n=0,a=0,i=0;i=48&&o<=57,c=l>=48&&l<=57;if(s&&(n=10*n+o-48),c&&(a=10*a+l-48),!s||!c){if(n!==a)return n-a;if(o!==l)return o-l}}return a-n};var L=2e9;s.seedPseudoRandom=function(){L=2e9},s.pseudoRandom=function(){var t=L;return L=(69069*L+1)%4294967296,Math.abs(L-t)<429496729?s.pseudoRandom():L/4294967296}},{"../constants/numerical":143,"./angles":147,"./array":148,"./clean_number":149,"./clear_responsive":151,"./coerce":152,"./dates":153,"./extend":155,"./filter_unique":156,"./filter_visible":157,"./geometry2d":158,"./get_graph_div":159,"./identity":160,"./is_plain_object":162,"./keyed_container":163,"./localize":164,"./loggers":165,"./make_trace_groups":166,"./matrix":167,"./mod":168,"./nested_property":169,"./noop":170,"./notifier":171,"./push_unique":174,"./regex":176,"./relative_attr":177,"./relink_private":178,"./search":179,"./stats":181,"./throttle":183,"./to_log_range":184,d3:8,"fast-isnumeric":10}],162:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],163:[function(t,e,r){"use strict";var n=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,r,i){var o,l,s;r=r||"name",i=i||"value";var c={};e&&e.length?(s=n(t,e),l=s.get()):l=t,e=e||"";var u={};if(l)for(o=0;o2)return c[e]=2|c[e],d.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],169:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,c=e.split(".");s/g),o=0;oi||c===a||cl||e&&s(t))}:function(t,e){var s=t[0],c=t[1];if(s===a||si||c===a||cl)return!1;var u,f,d,p,h,g=r.length,v=r[0][0],y=r[0][1],m=0;for(u=1;uMath.max(f,v)||c>Math.max(d,y)))if(cu||Math.abs(n(o,d))>a)return!0;return!1};i.filter=function(t,e){var r=[t[0]],n=0,a=0;function i(i){t.push(i);var l=r.length,s=n;r.splice(a+1);for(var c=s+1;c1&&i(t.pop());return{addPt:i,raw:t,filtered:r}}},{"../constants/numerical":143,"./matrix":167}],174:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ra.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function c(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,u,f=0,d=e.length,p=0,h=d>1?(e[d-1]-e[0])/(d-1):1;for(u=h>=0?r?o:l:r?c:s,t+=1e-9*h*(r?-1:1)*(h>=0?1:-1);f90&&a.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,a=e[n]-e[0]||1,i=a/(n||1)/1e4,o=[e[0]],l=0;le[l]+i&&(a=Math.min(a,e[l+1]-e[l]),o.push(e[l+1]));return{vals:o,minDiff:a}},r.roundUp=function(t,e,r){for(var n,a=0,i=e.length-1,o=0,l=r?0:1,s=r?1:0,c=r?Math.ceil:Math.floor;a0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||i;for(var r,n=1/0,a=0;ai.length)&&(o=i.length),n(e)||(e=!1),a(i[0])){for(s=new Array(o),l=0;lt.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":148,"fast-isnumeric":10}],182:[function(t,e,r){"use strict";var n=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function l(t,e){return t.node().getBoundingClientRect()[e]}var s=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var L=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&L.match(s),O=n.select(t.node().parentNode);if(!O.empty()){var P=t.attr("class")?t.attr("class").split(" ")[0]:"text";return P+="-math",O.selectAll("svg."+P).remove(),O.selectAll("g."+P+"-group").remove(),t.style("display",null).attr({"data-unformatted":L,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),i={fontSize:r};!function(t,e,r){var i,o,l,s;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),l=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+a.randstr({},64);return s=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(s.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(s.select(".MathJax_SVG").empty()||!s.select("svg").node())a.log("There was an error in the tex syntax.",t),r();else{var o=s.select("svg").node().getBoundingClientRect();r(s.select(".MathJax_SVG"),e,o)}if(s.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==l&&(MathJax.Hub.processSectionDelay=l),MathJax.Hub.Config(o)})}(S[2],i,function(n,a,i){O.selectAll("svg."+P).remove(),O.selectAll("g."+P+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return D(),void e();var s=O.append("g").classed(P+"-group",!0).attr({"pointer-events":"none","data-unformatted":L,"data-math":"Y"});s.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:P,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=l(o,"width"),f=l(o,"height"),d=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(r||l(t,"height"))/4;"y"===P[0]?(s.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===P[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===P[0]?o.attr({x:0,y:p}):o.attr({x:d,y:+t.attr("y")+p-f/2}),v&&v.call(t,s),e(s)})})):D(),t}function D(){O.empty()||(P=t.attr("class")+"-math",O.select("svg."+P).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var r,l=!1,s=[],c=-1;function u(){c++;var e=document.createElementNS(i.svg,"tspan");n.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),r=e;var a=s;if(s=[{node:e}],a.length>1)for(var l=1;l doesnt match end tag <"+t+">. Pretending it did match.",e),r=s[s.length-1].node}else a.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(r=t,s=[{node:t}]);for(var O=e.split(m),P=0;P|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},d={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},h="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,m=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,M=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function T(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&C(n)}var A=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var L={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function C(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):L[e])||t})}function O(t,e,r){var n,a,i,o=r.horizontalAlign,l=r.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-n.height}:"middle"===l?function(){return s.top+(s.height-n.height)/2}:function(){return s.top},i="right"===o?function(){return s.right-n.width}:"center"===o?function(){return s.left+(s.width-n.width)/2}:function(){return s.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:i()-c.left+"px","z-index":1e3}),this}}r.convertEntities=C,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function a(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var i=a("x",e),o=a("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},r.makeEditable=function(t,e){var r=e.gd,a=e.delegate,i=n.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function l(){!function(){var a=n.select(r).select(".svg-container"),o=a.append("div"),l=t.node().style,c=parseFloat(l.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":l.fontFamily||"Arial","font-size":c,color:e.fill||l.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(O(t,a,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=n.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),n.select(this).call(O(t,a,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(s)}(),t.style({opacity:0});var a,l=o.attr("class");(a=l?"."+l.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(a).style({opacity:0})}function s(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?l():o.on("click",l),n.rebind(t,i,"on")}},{"../constants/alignment":141,"../constants/xmlns_namespaces":144,"../lib":161,d3:8}],183:[function(t,e,r){"use strict";var n={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var i=n[t],o=Date.now();if(!i){for(var l in n)n[l].tsi.ts+e?s():i.timer=setTimeout(function(){s(),i.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)a(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],184:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":10}],185:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],186:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],187:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,a=n.layoutArrayContainers,i=n.layoutArrayRegexes,o=t.split("[")[0],l=0;l0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var n=(l.subplotsRegistry.cartesian||{}).attrRegex,i=(l.subplotsRegistry.gl3d||{}).attrRegex,s=Object.keys(t);for(e=0;e3?(A.x=1.02,A.xanchor="left"):A.x<-2&&(A.x=-.02,A.xanchor="right"),A.y>3?(A.y=1.02,A.yanchor="bottom"):A.y<-2&&(A.y=-.02,A.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=m(e);r;){if(r in t)return!0;r=m(r)}return!1};var x=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&o.warn("Full array edits are incompatible with other edits",f);var m=r[""][""];if(u(m))e.set(null);else{if(!Array.isArray(m))return o.warn("Unrecognized full array edit value",f,m),!0;e.set(m)}return!g&&(d(v,y),p(t),!0)}var x,b,_,w,k,M,T,A=Object.keys(r).map(Number).sort(l),L=e.get(),S=L||[],C=n(y,f).get(),O=[],P=-1,D=S.length;for(x=0;xS.length-(T?0:1))o.warn("index out of range",f,_);else if(void 0!==M)k.length>1&&o.warn("Insertion & removal are incompatible with edits to the same index.",f,_),u(M)?O.push(_):T?("add"===M&&(M={}),S.splice(_,0,M),C&&C.splice(_,0,{})):o.warn("Unrecognized full object edit value",f,_,M),-1===P&&(P=_);else for(b=0;b=0;x--)S.splice(O[x],1),C&&C.splice(O[x],1);if(S.length?L||e.set(S):e.set(null),g)return!1;if(d(v,y),h!==i){var z;if(-1===P)z=A;else{for(D=Math.max(S.length,D),z=[],x=0;x=P);x++)z.push(_);for(x=P;x=t.data.length||a<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(a,n+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+r+" must be unique.")}}function z(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),D(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&D(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function E(t,e,r,n,i){!function(t,e,r,n){var a=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var i in D(t,r,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==r.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in n)||!Array.isArray(n[i])||n[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var l=function(t,e,r,n){var i,l,s,c,u,f=o.isPlainObject(n),d=[];for(var p in Array.isArray(r)||(r=[r]),r=P(r,t.data.length-1),e)for(var h=0;h=0&&r=0&&r0&&"string"!=typeof C.parts[P];)P--;var D=C.parts[P],z=C.parts[P-1]+"."+D,E=C.parts.slice(0,P).join("."),R=o.nestedProperty(t.layout,E).get(),I=o.nestedProperty(l,E).get(),F=C.get();if(void 0!==O){m[S]=O,x[S]="reverse"===D?O:N(F);var B=u.getLayoutValObject(l,C.parts);if(B&&B.impliedEdits&&null!==O)for(var V in B.impliedEdits)b(o.relativeAttr(S,V),B.impliedEdits[V]);if(-1!==["width","height"].indexOf(S))if(O){b("autosize",null);var G="height"===S?"width":"height";b(G,l[G])}else l[S]=t._initialAutoSize[S];else if("autosize"===S)b("width",O?null:l.width),b("height",O?null:l.height);else if(z.match(j))L(z),o.nestedProperty(l,E+"._inputRange").set(null);else if(z.match(H)){L(z),o.nestedProperty(l,E+"._inputRange").set(null);var X=o.nestedProperty(l,E).get();X._inputDomain&&(X._input.domain=X._inputDomain.slice())}else z.match(q)&&o.nestedProperty(l,E+"._inputDomain").set(null);if("type"===D){var Z=R,Y="linear"===I.type&&"log"===O,W="log"===I.type&&"linear"===O;if(Y||W){if(Z&&Z.range)if(I.autorange)Y&&(Z.range=Z.range[1]>Z.range[0]?[1,2]:[2,1]);else{var J=Z.range[0],Q=Z.range[1];Y?(J<=0&&Q<=0&&b(E+".autorange",!0),J<=0?J=Q/1e6:Q<=0&&(Q=J/1e6),b(E+".range[0]",Math.log(J)/Math.LN10),b(E+".range[1]",Math.log(Q)/Math.LN10)):(b(E+".range[0]",Math.pow(10,J)),b(E+".range[1]",Math.pow(10,Q)))}else b(E+".autorange",!0);Array.isArray(l._subplots.polar)&&l._subplots.polar.length&&l[C.parts[0]]&&"radialaxis"===C.parts[1]&&delete l[C.parts[0]]._subplot.viewInitial["radialaxis.range"],c.getComponentMethod("annotations","convertCoords")(t,I,O,b),c.getComponentMethod("images","convertCoords")(t,I,O,b)}else b(E+".autorange",!0),b(E+".range",null);o.nestedProperty(l,E+"._inputRange").set(null)}else if(D.match(T)){var $=o.nestedProperty(l,S).get(),K=(O||{}).type;K&&"-"!==K||(K="linear"),c.getComponentMethod("annotations","convertCoords")(t,$,K,b),c.getComponentMethod("images","convertCoords")(t,$,K,b)}var tt=_.containerArrayMatch(S);if(tt){r=tt.array,n=tt.index;var et=tt.property,rt=(o.nestedProperty(i,r)||[])[n]||{},nt=B||{editType:"calc"};""!==n&&""===et&&(_.isAddVal(O)?x[S]=null:_.isRemoveVal(O)?x[S]=rt:o.warn("unrecognized full object value",e)),M.update(y,nt),d[r]||(d[r]={});var at=d[r][n];at||(at=d[r][n]={}),at[et]=O,delete e[S]}else"reverse"===D?(R.range?R.range.reverse():(b(E+".autorange",!0),R.range=[1,0]),I.autorange?y.calc=!0:y.plot=!0):(l._has("scatter-like")&&l._has("regl")&&"dragmode"===S&&("lasso"===O||"select"===O)&&"lasso"!==F&&"select"!==F?y.plot=!0:B?M.update(y,B):y.calc=!0,C.set(O))}}for(r in d){_.applyContainerArrayChanges(t,o.nestedProperty(i,r),d[r],y)||(y.plot=!0)}var it=l._axisConstraintGroups||[];for(k in A)for(n=0;n=a.length?a[0]:a[t]:a}function s(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function c(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(i,u){function d(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,f.transition(t,e.frame.data,e.frame.layout,w.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function p(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&d()};e()}var h,g,v=0;function y(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var m=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))m.push({type:"object",data:y(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(h=0;h0&&MM)&&T.push(g);m=T}}m.length>0?function(e){if(0!==e.length){for(var a=0;a=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(u[g]||h[g]||{}).name,y=e[n].name,m=u[v]||h[v];v&&y&&"number"==typeof y&&m&&A<5&&(A++,o.warn('addFrames: overwriting frame "'+(u[v]||h[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===A&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),h[g]={name:g},p.push({frame:f.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:d+n})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(a=p[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;u[a.name="frame "+t._transitionData._counter++];);if(u[a.name]){for(i=0;i=0;r--)n=e[r],i.push({type:"delete",index:n}),l.unshift({type:"insert",index:n,value:a[n]});var c=f.modifyFrames,u=f.modifyFrames,d=[t,l],p=[t,i];return s&&s.add(t,c,d,u,p),f.modifyFrames(t,i)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return f.cleanPlot([],{},r,e),f.purge(t),l.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":43,"../components/colorbar/connect":45,"../components/drawing":68,"../constants/xmlns_namespaces":144,"../lib":161,"../lib/events":154,"../lib/queue":175,"../lib/svg_text_utils":182,"../plots/cartesian/axes":205,"../plots/cartesian/constants":211,"../plots/cartesian/graph_interact":215,"../plots/plots":238,"../plots/polar/legacy":241,"../registry":245,"./edit_types":188,"./helpers":189,"./manage_arrays":191,"./plot_config":193,"./plot_schema":194,"./subroutines":196,d3:8,"fast-isnumeric":10,"has-hover":12}],193:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],194:[function(t,e,r){"use strict";var n=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),l=t("../plots/frame_attributes"),s=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),d=a.extendFlat,p=a.extendDeepAll,h=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",y=[g,v,"_arrayAttrRegexps","_deprecated"];function m(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(x(e[r]))r++;else if(r=i.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!x(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):h(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(h(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=s.length)return!1;a=(r=(n.transformsRegistry[s[u].type]||{}).attributes)&&r[e[2]],l=3}else if("area"===t.type)a=c[o];else{var f=t._module;if(f||(f=(n.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(r=f.attributes)&&r[o])){var d=f.basePlotModule;d&&d.attributes&&(a=d.attributes[o])}a||(a=i[o])}return m(a,e,l)},r.getLayoutValObject=function(t,e){return m(function(t,e){var r,a,i,l,s=t._basePlotModules;if(s){var c;for(r=0;r=a&&(r._input||{})._templateitemname;l&&(o=a);var s,c=e+"["+o+"]";function u(){s={},l&&(s[c]={},s[c][i]=l)}function f(t,e){l?n.nestedProperty(s[c],t).set(e):s[c+"."+t]=e}function d(){var t=s;return u(),t}return u(),{modifyBase:function(t,e){s[t]=e},modifyItem:f,getUpdateObj:d,applyUpdate:function(e,r){e&&f(e,r);var a=d();for(var i in a)n.nestedProperty(t,i).set(a[i])}}}},{"../lib":161,"../plots/attributes":202}],196:[function(t,e,r){"use strict";var n=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),l=t("../lib/clear_gl_canvases"),s=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),d=t("../plots/cartesian/axes"),p=t("../constants/alignment"),h=t("../plots/cartesian/constraints"),g=h.enforce,v=h.clean,y=t("../plots/cartesian/autorange").doAutoRange;function m(t,e,r){for(var n=0;n=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function x(t){var e,a,i,l,u,h=t._fullLayout,g=h._size,v=g.p,y=d.list(t,"",!0);if(h._paperdiv.style({width:t._context.responsive&&h.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":h.width+"px",height:t._context.responsive&&h.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":h.height+"px"}).selectAll(".main-svg").call(c.setSize,h.width,h.height),t._context.setBackground(t,h.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!h._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-v-n:e._offset+e._length+v+n:g.t+g.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+v+n:e._offset-v-n:g.l+g.w*(t.position||0)+n%1}for(e=0;ek?u.push({code:"unused",traceType:m,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:m,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var i=e[n],o=p(e,n,r);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&u.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&h(i)&&t(i,o)}}({data:v,layout:d},""),u.length)return u.map(g)}},{"../lib":161,"../plots/attributes":202,"../plots/plots":238,"./plot_config":193,"./plot_schema":194,"./plot_template":195}],198:[function(t,e,r){"use strict";var n=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),l=t("../snapshot/svgtoimg"),s={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,u,f;function d(t){return!(t in e)||a.validate(e[t],s[t])}if(e=e||{},a.isPlainObject(t)?(r=t.data||[],u=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),r=a.extendDeep([],t.data),u=a.extendDeep({},t.layout),f=t._context),!d("width")||!d("height"))throw new Error("Height and width should be pixel values.");if(!d("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function h(t,r){return a.coerce(e,p,s,t,r)}var g=h("format"),v=h("width"),y=h("height"),m=h("scale"),x=h("setBackground"),b=h("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},u);v&&(w.width=v),y&&(w.height=y);var k=a.extendFlat({},f,{staticPlot:!0,setBackground:x}),M=i.getRedrawFunc(_);function T(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function A(){return new Promise(function(t,e){var r=o(_,g,m),i=_._fullLayout.width,s=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(b?r:"data:image/svg+xml,"+encodeURIComponent(r));var c=document.createElement("canvas");c.id=a.randstr(),l({format:g,width:i,height:s,scale:m,canvas:c,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,k).then(M).then(T).then(A).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":161,"../snapshot/helpers":249,"../snapshot/svgtoimg":251,"../snapshot/tosvg":253,"./plot_api":192}],199:[function(t,e,r){"use strict";var n=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),l=n.isPlainObject,s=Array.isArray,c=n.isArrayOrTypedArray;function u(t,e,r,a,i,o){o=o||[];for(var f=Object.keys(t),d=0;dx.length&&a.push(p("unused",i,y.concat(x.length)));var M,T,A,L,S,C=x.length,O=Array.isArray(k);if(O&&(C=Math.min(C,k.length)),2===b.dimensions)for(T=0;Tx[T].length&&a.push(p("unused",i,y.concat(T,x[T].length)));var P=x[T].length;for(M=0;M<(O?Math.min(P,k[T].length):P);M++)A=O?k[T][M]:k,L=m[T][M],S=x[T][M],n.validate(L,A)?S!==L&&S!==+L&&a.push(p("dynamic",i,y.concat(T,M),L,S)):a.push(p("value",i,y.concat(T,M),L))}else a.push(p("array",i,y.concat(T),m[T]));else for(T=0;T1&&d.push(p("object","layout"))),a.supplyDefaults(h);for(var g=h._fullData,v=r.length,y=0;y0&&((b=T-o(v)-o(y))>A?_/b>L&&(m=v,x=y,L=_/b):_/T>L&&(m={val:v.val,pad:0},x={val:y.val,pad:0},L=_/T));if(d===p){var S=d-1,C=d+1;if(k)if(0===d)i=[0,1];else{var O=(d>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),P=d/(1-Math.min(.5,O/T));i=d>0?[0,P]:[P,0]}else i=M?[Math.max(0,S),Math.max(1,C)]:[S,C]}else k?(m.val>=0&&(m={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):M&&(m.val-L*o(m)<0&&(m={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),L=(x.val-m.val)/(T-o(m)-o(x)),i=[m.val-L*o(m),x.val+L*o(x)];return h&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function l(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function s(t,e){var r,n,a,i=e._id,o=t._fullData,l=t._fullLayout,s=[],f=[];function d(t,e){for(r=0;r=r&&(c.extrapad||!o)){l=!1;break}a(e,c.val)&&c.pad<=r&&(o||!c.extrapad)&&(t.splice(s,1),s--)}if(l){var u=i&&0===e;t.push({val:e,pad:u?0:r,extrapad:!u&&o})}}function d(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:o,makePadFn:l,doAutoRange:function(t,e){e._length||e.setScale();var r;e.autorange&&(e.range=o(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l),(r=e._input).range=e.range.slice(),r.autorange=e.autorange);if(e._anchorAxis&&e._anchorAxis.rangeslider){var n=e._anchorAxis.rangeslider[e._name];n&&"auto"===n.rangemode&&(n.range=o(t,e)),(r=e._anchorAxis._input).rangeslider[e._name]=a.extendFlat({},n)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var a,o,l,s,f,p,h,g,v,y=[],m=[],x=e.length,b=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function M(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var T=M((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),A=M((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),L=M(r.vpadplus||r.vpad),S=M(r.vpadminus||r.vpad);if(!k){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=P;a--)O(a);return{min:y,max:m}},concatExtremes:s}},{"../../constants/numerical":143,"../../lib":161,"fast-isnumeric":10}],205:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),d=t("./layout_attributes"),p=t("./clean_ticks"),h=t("../../constants/numerical"),g=h.ONEAVGYEAR,v=h.ONEAVGMONTH,y=h.ONEDAY,m=h.ONEHOUR,x=h.ONEMIN,b=h.ONESEC,_=h.MINUS_SIGN,w=h.BADNUM,k=t("../../constants/alignment").MID_SHIFT,M=t("../../constants/alignment").LINE_SPACING,T=e.exports={};T.setConvert=t("./set_convert");var A=t("./axis_autotype"),L=t("./axis_ids");T.id2name=L.id2name,T.name2id=L.name2id,T.cleanId=L.cleanId,T.list=L.list,T.listIds=L.listIds,T.getFromId=L.getFromId,T.getFromTrace=L.getFromTrace;var S=t("./autorange");T.getAutoRange=S.getAutoRange,T.findExtremes=S.findExtremes,T.coerceRef=function(t,e,r,n,a,i){var o=n.charAt(n.length-1),s=r._fullLayout._subplots[o+"axis"],c=n+"ref",u={};return a||(a=s[0]||i),i||(i=a),u[c]={valType:"enumerated",values:s.concat(i?[i]:[]),dflt:a},l.coerce(t,e,u,c)},T.coercePosition=function(t,e,r,n,a,i){var o,s;if("paper"===n||"pixel"===n)o=l.ensureNumber,s=r(a,i);else{var c=T.getFromId(e,n);s=r(a,i=c.fraction2r(i)),o=c.cleanPos}t[a]=o(s)},T.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?l.ensureNumber:T.getFromId(e,r).cleanPos)(t)};var C=T.getDataConversions=function(t,e,r,n){var a,i="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(i)){if(a={type:A(n),_categories:[]},T.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.saveRangeInitial=function(t,e){for(var r=T.list(t,"",!0),n=!1,a=0;a.3*d||u(n)||u(i))){var p=r.dtick/2;t+=t+p.8){var o=Number(r.substr(1));i.exactYears>.8&&o%12==0?t=T.tickIncrement(t,"M6","reverse")+1.5*y:i.exactMonths>.8?t=T.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var s=T.tickIncrement(t,r);if(s<=n)return s}return t}(x,t,m,c,i)),v=x,0;v<=u;)v=T.tickIncrement(v,m,!1,i),0;return{start:e.c2r(x,0,i),end:e.c2r(v,0,i),size:m,_dataSpan:u-c}},T.prepTicks=function(t){var e=l.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=l.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),T.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},T.calcTicks=function(t){T.prepTicks(t);var e=l.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e,r,n=t.tickvals,a=t.ticktext,i=new Array(n.length),o=l.simpleMap(t.range,t.r2l),s=1.0001*o[0]-1e-4*o[1],c=1.0001*o[1]-1e-4*o[0],u=Math.min(s,c),f=Math.max(s,c),d=0;Array.isArray(a)||(a=[]);var p="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(r=0;ru&&e=n:c<=n)&&!(i.length>s||c===o);c=T.tickIncrement(c,t.dtick,a,t.calendar))o=c,i.push(c);J(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(i.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&i<=10||e>=15*y)t._tickround="d";else if(e>=x&&i<=16||e>=m)t._tickround="M";else if(e>=b&&i<=19||e>=x)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var l=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var s=Math.max(Math.abs(l[0]),Math.abs(l[1])),c=Math.floor(Math.log(s)/Math.LN10+.01);Math.abs(c)>3&&(V(t.exponentformat)&&!U(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function H(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}T.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=l.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,r=n(10),t.dtick="M"+12*B(e,r,D)):i>v?(e/=v,t.dtick="M"+B(e,1,z)):i>y?(t.dtick=B(e,y,R),t.tick0=l.dateTick0(t.calendar,!0)):i>m?t.dtick=B(e,m,z):i>x?t.dtick=B(e,x,E):i>b?t.dtick=B(e,b,E):(r=n(10),t.dtick=B(e,r,D))}else if("log"===t.type){t.tick0=0;var o=l.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var s=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/s,r=n(10),t.dtick="L"+B(e,r,D)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):J(t)?(t.tick0=0,r=1,t.dtick=B(e,r,F)):(t.tick0=0,r=n(10),t.dtick=B(e,r,D));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},T.tickIncrement=function(t,e,r,i){var o=r?-1:1;if(a(e))return t+o*e;var s=e.charAt(0),c=o*Number(e.substr(1));if("M"===s)return l.incrementMonth(t,c,i);if("L"===s)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===s){var u="D2"===e?I:N,f=t+.01*o,d=l.roundUp(l.mod(f,1),u,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.r2l||Number,r=l.simpleMap(t.range,e),i=r[1]"+s,t._prevDateHead=s));e.text=c}(t,o,r,c):"log"===t.type?function(t,e,r,n,i){var o=t.dtick,s=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===i&&(i="");n&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,s),t,i,n);else if(a(o)||"D"===u&&l.mod(s+.01,1)<.1){var f=Math.round(s),d=Math.abs(f),p=t.exponentformat;"power"===p||V(p)&&U(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+d+"",e.fontSize*=1.25):("e"===p||"E"===p)&&d>2?e.text="1"+p+(f>0?"+":_)+d:(e.text=G(Math.pow(10,s),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,l.mod(s,1)))),e.fontSize*=.75}if("D1"===t.dtick){var h=String(e.text).charAt(0);"0"!==h&&"1"!==h||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(s<0?.5:.25)))}}(t,o,0,c,n):"category"===t.type?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,o):J(t)?function(t,e,r,n,a){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,a,n);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,a=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/a),Math.round(r/a)]}(i);if(o[1]>=100)e.text=G(l.deg2rad(e.x),t,a,n);else{var s=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),s&&(e.text=_+e.text)}}}}(t,o,r,c,n):function(t,e,r,n,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,n)}(t,o,0,c,n),t.tickprefix&&!p(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!p(t.showticksuffix)&&(o.text+=t.ticksuffix),o},T.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return T.hoverLabelText(t,e)+" - "+T.hoverLabelText(t,r);var n="log"===t.type&&e<=0,a=T.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+a:a};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function V(t){return"SI"===t||"B"===t}function U(t){return t>14||t<-15}function G(t,e,r,n){var i=t<0,o=e._tickround,s=r||e.exponentformat||"B",c=e._tickexponent,u=T.getTickFormat(e),f=e.separatethousands;if(n){var d={exponentformat:s,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(d),o=(Number(d._tickround)||0)+4,c=d._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,h=Math.pow(10,-o)/2;if("none"===s&&(c=0),(t=Math.abs(t))"+p+"":"B"===s&&9===c?t+="B":V(s)&&(t+=q[c/3+5]));return i?_+t:t}function X(t,e){var r=t.l2p(e);return r>1&&r=0,i=u(t,e[1])<=0;return(r||a)&&(n||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},l=0;l2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":245,"./constants":211}],209:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var l,s=r("categoryorder",a);"array"===s&&(l=r("categoryarray")),o||"array"!==s||(s=e.categoryorder="trace"),"trace"===s?e._initialCategories=[]:"array"===s?e._initialCategories=l.slice():(l=function(t,e){var r,n,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;nl*x)||k)for(r=0;rz&&NP&&(P=N);p/=(P-O)/(2*D),O=u.l2r(O),P=u.l2r(P),u.range=u._input.range=L=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function E(t,e,r,n,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",a+"Z")}function R(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function N(t,e,r,n,a,i){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),I(t,e,a,i)}function I(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function B(t){L&&t.data&&t._context.showTips&&(l.notifier(l._(t,"Double-click to zoom back out"),"long"),L=!1)}function j(t){return"lasso"===t||"select"===t}function H(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,A)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(i){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function V(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,i,c,d,L,S){var I,U,G,X,Z,Y,W,J,Q,$,K,tt,et,rt,nt,at,it,ot,lt,st,ct,ut=t._fullLayout._zoomlayer,ft=L+S==="nsew",dt=1===(L+S).length;function pt(){if(I=e.xaxis,U=e.yaxis,Q=I._length,$=U._length,W=I._offset,J=U._offset,(G={})[I._id]=I,(X={})[U._id]=U,L&&S)for(var r=e.overlays,n=0;n-1&&w(a,t,Z,Y,e.id,At),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===r&&dt){var l=L?U:I,c="s"===L||"w"===S?0:1,u=l._name+".range["+c+"]",d=function(t,e){var r,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,a))):(r=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,n.format("."+String(r)+"g")(a))}(l,c),p="left",h="middle";if(l.fixedrange)return;L?(h="n"===L?"top":"bottom","right"===l.side&&(p="right")):"e"===S&&(p="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(s.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(d),fill:l.tickfont?l.tickfont.color:"#444",horizontalAlign:p,verticalAlign:h}).on("edit",function(e){var r=l.d2r(e);void 0!==r&&o.call("relayout",t,u,r)})}}function Ct(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min(Q,e+vt)),a=Math.max(0,Math.min($,r+yt)),i=Math.abs(n-vt),o=Math.abs(a-yt);function l(){wt="",mt.r=mt.l,mt.t=mt.b,Mt.attr("d","M0,0Z")}mt.l=Math.min(vt,n),mt.r=Math.max(vt,n),mt.t=Math.min(yt,a),mt.b=Math.max(yt,a),nt?i>A||o>A?(wt="xy",i/Q>o/$?(o=i*$/Q,yt>a?mt.t=yt-o:mt.b=yt+o):(i=o*Q/$,vt>n?mt.l=vt-i:mt.r=vt+i),Mt.attr("d",H(mt))):l():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Et);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var a,i=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=Nt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(at){for(S||(s=.5),a=0;ag[1]-.01&&(e.domain=l),a.noneOrAll(t.domain,e.domain,l)}return r("layer"),e}},{"../../lib":161,"fast-isnumeric":10}],222:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*r;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":141}],223:[function(t,e,r){"use strict";var n=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),l=t("../../lib/polygon"),s=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),d=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),h=p.MINSELECT,g=l.filter,v=l.tester;function y(t){return t._id}function m(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h,g,v=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,m=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var x=function(t,e){var r,n,a=t[0],i=-1,o=[];for(n=0;n0?function(t,e){var r,n,a,i=[];for(a=0;a0&&i.push(r);if(1===i.length&&i[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=r.selectedpoints.length)>1)return!1}return 1===a}(l)&&(d=A(x))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",n)}function A(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,a=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function L(t,e,r){var n,i,o,l;if(r){var s=r.points||[];for(n=0;n-1&&m(e,A,a.xaxes,a.yaxes,a.subplot,a,U),"event"===r&&A.emit("plotly_selected",void 0);o.click(A,e)})},a.doneFn=function(){X.remove(),s.done(Z).then(function(){s.clear(Z),a.gd.emit("plotly_selected",b),d&&a.selectionDefs&&(d.subtract=V,a.selectionDefs.push(d),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:C,selectOnClick:m}},{"../../components/color":43,"../../components/fx":85,"../../components/fx/helpers":82,"../../lib/clear_gl_canvases":150,"../../lib/polygon":173,"../../lib/throttle":183,"../../plot_api/subroutines":196,"../../registry":245,"./axis_ids":208,"./constants":211,polybooljs:17}],224:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,l=i.ms2DateTime,s=i.dateTime2ms,c=i.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,d=u.BADNUM,p=u.LOG_CLIP,h=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function u(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],a=t.range[1];return.5*(n+a-2*p*Math.abs(n-a))}return d}function y(e,r,n){var o=s(e,n||t.calendar);if(o===d){if(!a(e))return d;e=+e;var l=Math.floor(10*i.mod(e+.05,1)),c=Math.round(e-l/10);o=s(new Date(c))+l/10}return o}function m(e,r,n){return l(e,r,n||t.calendar)}function x(e){return t._categories[Math.round(e)]}function b(e){if(t._categoriesMap){var r=t._categoriesMap[e];if(void 0!==r)return r}if(a(e))return+e}function _(e){return a(e)?n.round(t._b+t._m*e,2):d}function w(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=_,t.p2l=w,t.c2p="log"===t.type?function(t,e){return _(u(t,e))}:_,t.p2c="log"===t.type?function(t){return v(w(t))}:w,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=w,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(w(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=w,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=y,t.c2d=t.c2r=t.l2d=t.l2r=m,t.d2p=t.r2p=function(e,r,n){return t.l2p(y(e,0,n))},t.p2d=t.p2r=function(t,e,r){return m(w(t),e,r)},t.cleanPos=function(e){return i.cleanDate(e,d,t.calendar)}):"category"===t.type&&(t.d2c=t.d2l=function(e){if(null!=e){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return d},t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=b,t.r2c=function(e){var r=b(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=b,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(w(t))},t.r2p=t.d2p,t.p2r=w,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,l,s=i.nestedProperty(t,e).get();if(l=(l="date"===t.type?i.dfltRange(t.calendar):"y"===r?h.DFLTRANGEY:n.dfltRange||h.DFLTRANGEX).slice(),s&&2===s.length)for("date"===t.type&&(s[0]=i.cleanDate(s[0],d,t.calendar),s[1]=i.cleanDate(s[1],d,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(s[o],t.calendar)){t[e]=l;break}if(t.r2l(s[0])===t.r2l(s[1])){var c=i.constrain(t.r2l(s[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);s[0]=t.l2r(c-1e3),s[1]=t.l2r(c+1e3);break}}else{if(!a(s[o])){if(!a(s[1-o])){t[e]=l;break}s[o]=s[1-o]*(o?10:.1)}if(s[o]<-f?s[o]=-f:s[o]>f&&(s[o]=f),s[0]===s[1]){var u=Math.max(1,Math.abs(1e-6*s[0]));s[0]-=u,s[1]+=u}}else i.nestedProperty(t,e).set(l)},t.setScale=function(n){var a=e._size;if(t._categories||(t._categories=[]),t._categoriesMap||(t._categoriesMap={}),t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=n&&t._r?"_r":"range",l=t.calendar;t.cleanRange(o);var s=t.r2l(t[o][0],l),c=t.r2l(t[o][1],l);if("y"===r?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-c),t._b=-t._m*c):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,a,o,l,s=t.type,c="date"===s&&e[r+"calendar"];if(r in e){if(n=e[r],l=e._length||n.length,i.isTypedArray(n)&&("linear"===s||"log"===s)){if(l===n.length)return n;if(n.subarray)return n.subarray(0,l)}for(a=new Array(l),o=0;o rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,r._offset).call(i.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(i.setPointGroupScale,1,1),n.selectAll(".textpoint").call(i.setTextPointsScale,1,1),n.call(i.hideOutsideRangePoints,t)}function x(e,r){var n,l,s,u=g[e.xaxis._id],f=g[e.yaxis._id],d=[];if(u){l=(n=t._fullLayout[u.axisName])._r,s=u.to,d[0]=(l[0]*(1-r)+r*s[0]-l[0])/(l[1]-l[0])*e.xaxis._length;var p=l[1]-l[0],h=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[2]=e.xaxis._length*(1-r+r*h/p)}else d[0]=0,d[2]=e.xaxis._length;if(f){l=(n=t._fullLayout[f.axisName])._r,s=f.to,d[1]=(l[1]*(1-r)+r*s[1]-l[1])/(l[0]-l[1])*e.yaxis._length;var v=l[1]-l[0],y=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[3]=e.yaxis._length*(1-r+r*y/v)}else d[1]=0,d[3]=e.yaxis._length;!function(e,r){var n,i=[];for(i=[e._id,r._id],n=0;nr.duration?(function(){for(var e={},r=0;r0&&(a["_"+r+"axes"]||{})[e])return a;if((a[r+"axis"]||r)===e){if(o(a,r))return a;if((a[r]||[]).length||a[r+"0"])return a}}}(e,r,l);if(!s)return;if("histogram"===s.type&&l==={v:"y",h:"x"}[s.orientation||"v"])return void(t.type="linear");var c,u=l+"calendar",f=s[u];if(o(s,l)){var d=i(s),p=[];for(c=0;c0?".":"")+i;a.isPlainObject(o)?s(o,e,l,n+1):e(l,i,o)}})}r.manageCommandObserver=function(t,e,n,o){var l={},s=!0;e&&e._commandObserver&&(l=e._commandObserver),l.cache||(l.cache={}),l.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,n,l.lookupTable);if(e&&e._commandObserver){if(c)return l;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,l}if(c){i(t,c,l.cache),l.check=function(){if(s){var e=i(t,c,l.cache);return e.changed&&o&&void 0!==l.lookupTable[e.value]&&(l.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:l.lookupTable[e.value]})).then(l.enable,l.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;f=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),r.attr(i);var o=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),a=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+a})}}(t,o),l.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),a=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,a={};function o(t){for(var r=!0,i=0;i1&&z.length>1){for(i.getComponentMethod("grid","sizeDefaults")(c,l),o=0;o15&&z.length>15&&0===l.shapes.length&&0===l.images.length,l._hasCartesian=l._has("cartesian"),l._hasGeo=l._has("geo"),l._hasGL3D=l._has("gl3d"),l._hasGL2D=l._has("gl2d"),l._hasTernary=l._has("ternary"),l._hasPie=l._has("pie"),v.linkSubplots(d,l,u,a),v.cleanPlot(d,l,u,a),h(l,a),v.doAutoMargin(t);var F=f.list(t);for(o=0;o0){var f=1-2*l;n=Math.round(f*n),i=Math.round(f*i)}}var d=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-i)>1;(g||h)&&(h&&(r.width=n),g&&(r.height=i)),t._initialAutoSize||(t._initialAutoSize={width:n,height:i}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var a,o,l,c=i.componentsRegistry,u=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in c)(l=c[a]).includeBasePlot&&l.includeBasePlot(t,e);for(var d in u.length||u.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[d].sort(s.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var s=void 0!==r.xl?r.xl:r.x,c=void 0!==r.xr?r.xr:r.x,u=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;a[e]={l:{val:s,size:r.l+o},r:{val:c,size:r.r+o},b:{val:f,size:r.b+o},t:{val:u,size:r.t+o}},i[e]=1}else delete a[e],delete i[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),T(e);var r=e._size,n=JSON.stringify(r),o=Math.max(e.margin.l||0,0),l=Math.max(e.margin.r||0,0),s=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin,f=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var d in u)f[d]||delete u[d];for(var p in u.base={l:{val:0,size:o},r:{val:1,size:l},t:{val:1,size:s},b:{val:0,size:c}},u){var h=u[p].l||{},g=u[p].b||{},v=h.val,y=h.size,m=g.val,x=g.size;for(var b in u){if(a(y)&&u[b].r){var _=u[b].r.val,w=u[b].r.size;if(_>v){var k=(y*_+(w-e.width)*v)/(_-v),M=(w*(1-v)+(y-e.width)*(1-_))/(_-v);k>=0&&M>=0&&k+M>o+l&&(o=k,l=M)}}if(a(x)&&u[b].t){var A=u[b].t.val,L=u[b].t.size;if(A>m){var S=(x*A+(L-e.height)*m)/(A-m),C=(L*(1-m)+(x-e.height)*(1-A))/(A-m);S>=0&&C>=0&&S+C>c+s&&(c=S,s=C)}}}}}if(r.l=Math.round(o),r.r=Math.round(l),r.t=Math.round(s),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,r,n,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,l=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(s.isPlainObject(t)){var e,n,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!s.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;a[e]=c(t[e])}return a}return Array.isArray(t)?t.map(c):s.isTypedArray(t)?s.simpleMap(t,s.identity):s.isJSDate(t)?s.ms2DateTimeLocal(+t):t}var u={data:(i||[]).map(function(t){var r=c(t);return e&&delete r.fit,r})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),l&&(u.frames=c(l)),"object"===n?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var r,n,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,l,c=0,u=0;function f(){return c++,function(){var r;u++,p||u!==c||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var h=t._fullLayout._basePlotModules,g=!1;if(r)for(l=0;l=0;l--)if(o[l].enabled){r._indexToPoints=o[l]._indexToPoints;break}n&&n.calc&&(i=n.calc(t,r))}Array.isArray(i)&&i[0]||(i=[{x:u,y:u}]),i[0].t||(i[0].t={}),i[0].trace=r,h[e]=i}}for(m&&A(c),a=0;a=0?d.angularAxis.domain:n.extent(k),S=Math.abs(k[1]-k[0]);T&&!M&&(S=0);var C=L.slice();A&&M&&(C[1]+=S);var O=d.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),d.angularAxis.ticksStep&&(O=(C[1]-C[0])/O);var P=d.angularAxis.ticksStep||(C[1]-C[0])/(O*(d.minorTicks+1));w&&(P=Math.max(Math.round(P),1)),C[2]||(C[2]=P);var D=n.range.apply(this,C);if(D=D.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=n.scale.linear().domain(C.slice(0,2)).range("clockwise"===d.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=A?S:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var z=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),E=this.appendChild(this.ownerDocument.importNode(z.documentElement,!0));t=n.select(E)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var R,N=t.select(".chart-group"),I={fill:"none",stroke:d.tickColor},F={"font-size":d.font.size,"font-family":d.font.family,fill:d.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+d.font.outlineColor}).join(",")};if(d.showLegend){R=t.select(".legend-group").attr({transform:"translate("+[x,d.margin.top]+")"}).style({display:"block"});var B=p.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:R,elements:B,reverseOrder:d.legend.reverseOrder})})();var j=R.node().getBBox();x=Math.min(d.width-j.width-d.margin.left-d.margin.right,d.height-d.margin.top-d.margin.bottom)/2,x=Math.max(10,x),_=[d.margin.left+x,d.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),R.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else R=t.select(".legend-group").style({display:"none"});t.attr({width:d.width,height:d.height}).style({opacity:d.opacity}),N.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(d.width-(d.margin.left+d.margin.right+2*x+(j?j.width:0)))/2,(d.height-(d.margin.top+d.margin.bottom+2*x))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),t.select(".outer-group").attr("transform","translate("+H+")"),d.title){var q=t.select("g.title-group text").style(F).text(d.title),V=q.node().getBBox();q.attr({x:_[0]-V.width/2,y:_[1]-x-20})}var U=t.select(".radial.axis-group");if(d.radialAxis.gridLinesVisible){var G=U.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(I),G.attr("r",r),G.exit().remove()}U.select("circle.outside-circle").attr({r:x}).style(I);var X=t.select("circle.background-circle").attr({r:x}).style({fill:d.backgroundColor,stroke:d.stroke});function Z(t,e){return l(t)%360+d.orientation}if(d.radialAxis.visible){var Y=n.svg.axis().scale(r).ticks(5).tickSize(5);U.call(Y).attr({transform:"rotate("+d.radialAxis.orientation+")"}),U.selectAll(".domain").style(I),U.selectAll("g>text").text(function(t,e){return this.textContent+d.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===d.radialAxis.tickOrientation?"rotate("+-d.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),U.selectAll("g>line").style({stroke:"black"})}var W=t.select(".angular.axis-group").selectAll("g.angular-tick").data(D),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+Z(t)+")"}}).style({display:d.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(d.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(d.minorTicks+1)==0)}).style(I),J.selectAll(".minor").style({stroke:d.minorTickColor}),W.select("line.grid-line").attr({x1:d.tickLength?x-d.tickLength:0,x2:x}).style({display:d.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(F);var Q=W.select("text.axis-text").attr({x:x+d.labelOffset,dy:i+"em",transform:function(t,e){var r=Z(t),n=x+d.labelOffset,a=d.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-r+" "+n+" 0)":"radial"==a?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:d.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(d.minorTicks+1)!=0?"":w?w[t]+d.angularAxis.ticksSuffix:t+d.angularAxis.ticksSuffix}).style(F);d.angularAxis.rewriteTicks&&Q.text(function(t,e){return e%(d.minorTicks+1)!=0?"":d.angularAxis.rewriteTicks(this.textContent,e)});var $=n.max(N.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));R.attr({transform:"translate("+[x+$,d.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||K){var et=[];p.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=d.orientation,n.direction=d.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return a(o[r].defaultConfig(),t)});o[r]().config(n)()})}var at,it,ot=t.select(".guides-group"),lt=t.select(".tooltips-group"),st=o.tooltipPanel().config({container:lt,fontSize:8})(),ct=o.tooltipPanel().config({container:lt,fontSize:8})(),ut=o.tooltipPanel().config({container:lt,hasTick:!0})();if(!M){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});N.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(X).angle;ft.attr({x2:-x,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-d.orientation)%360;at=l.invert(n);var a=o.util.convertToCartesian(x+12,r+180);st.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var dt=ot.select("circle").style({stroke:"grey",fill:"none"});N.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(X).radius;dt.attr({r:n}).style({opacity:.5}),it=r.invert(o.util.getMousePos(X).radius);var a=o.util.convertToCartesian(n,d.radialAxis.orientation);ct.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){dt.style({opacity:0}),ut.hide(),st.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var a=n.select(this),i=this.style.fill,l="black",s=this.style.opacity||1;if(a.attr({"data-opacity":s}),i&&"none"!==i){a.attr({"data-fill":i}),l=n.hsl(i).darker().toString(),a.style({fill:l,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};M&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=t.node().getBoundingClientRect(),p=[f.left+f.width/2-H[0]-d.left,f.top+f.height/2-H[1]-d.top];ut.config({color:l}).text(u),ut.move(p)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),l=n.hsl(i).darker().toString(),a.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var r=n.select(this),a=r.attr("data-fill");a?r.style({fill:a,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(c),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),a(s.data[e],o.Axis.defaultConfig().data[0]),a(s.data[e],t)}),a(s.layout,o.Axis.defaultConfig().layout),a(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return t},n.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var a=e||6,i=[],o=[];n.range(0,360+a,a).forEach(function(e,r){var n=e*Math.PI/180,a=t(n);i.push(e),o.push(a)});var l={t:i,r:o};return r&&(l.name=r),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],a=e[1],i={};return i.x=r,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,r)+Math.PI)/Math.PI,i.radius=Math.sqrt(r*r+a*a),i},o.util.duplicatesCount=function(t){for(var e,r={},n={},a=0,i=t.length;a0)){var s=n.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({class:"line",d:u(l),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return h.fill(r,a,i)},"fill-opacity":0,stroke:function(t,e){return h.stroke(r,a,i)},"stroke-width":function(t,e){return h["stroke-width"](r,a,i)},"stroke-dasharray":function(t,e){return h["stroke-dasharray"](r,a,i)},opacity:function(t,e){return h.opacity(r,a,i)},display:function(t,e){return h.display(r,a,i)}})}};var f=e.angularScale.range(),d=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=n.svg.arc().startAngle(function(t){return-d/2}).endAngle(function(t){return d/2}).innerRadius(function(t){return e.radialScale(s+(t[2]||0))}).outerRadius(function(t){return e.radialScale(s+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,r,a){n.select(this).attr({class:"mark arc",d:p,transform:function(t,r){return"rotate("+(e.orientation+l(t[0])+90)+")"}})};var h={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,a){return r[t[a].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(h).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),a(t[r],o.PolyChart.defaultConfig()),a(t[r],e)}),this):t},i.getColorScale=function(){},n.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,i=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var i=a({},e.elements[r]);return i.name=t,i.color=[].concat(e.elements[r].color)[n],i})}),o=n.merge(i);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var l=e.container;("string"==typeof l||l.nodeName)&&(l=n.select(l));var s=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,d=l.classed("legend-group",!0).selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var h=n.range(o.length),g=n.scale[u?"linear":"ordinal"]().domain(h).range(s),v=n.scale[u?"linear":"ordinal"]().domain(h)[u?"range":"rangePoints"]([0,f]);if(u){var y=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var m=d.select(".legend-marks").selectAll("path.legend-mark").data(o);m.enter().append("path").classed("legend-mark",!0),m.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var r,a,i,o=t.symbol;return i=3*(a=c),"line"===(r=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(i)():n.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),m.exit().remove()}var x=n.svg.axis().scale(v).orient("right"),b=d.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(a(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){var n=(t=i.container.selectAll("g."+l).data([0])).enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:i.padding+s,dy:.3*+i.fontSize}),c};return c.text=function(a){var o=n.hsl(i.color).l,l=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":i.fontSize+"px"}).text(f);var d=i.padding,p=e.node().getBBox(),h={fill:i.color,stroke:l,"stroke-width":"2px"},g=p.width+2*d+s,v=p.height+2*d;return r.attr({d:"M"+[[s,-v/2],[s,-v/4],[i.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(h),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return a(i,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=a({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=i.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var l=a({},t.layout);if([[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var s=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(l.margin).forEach(function(t,e){u[c[s.indexOf(t.key)]]=t.value}),l.margin=u}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),r.layout=l}return r}};return t}},{"../../../constants/alignment":141,"../../../lib":161,d3:8}],243:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),l=t("./undo_manager"),s=a.extendDeepAll,c=e.exports={};c.framework=function(t){var e,r,a,i,u,f=new l;function d(r,l){return l&&(u=l),n.select(n.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?s(e,r):r,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return d.isPolar=!0,d.svg=function(){return a.svg()},d.getConfig=function(){return e},d.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},d.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},d.setUndoPoint=function(){var t,n,a=this,i=o.util.cloneJson(e);t=i,n=r,f.add({undo:function(){n&&a(n)},redo:function(){a(t)}}),r=o.util.cloneJson(i)},d.undo=function(){f.undo()},d.redo=function(){f.redo()},d},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../../components/color":43,"../../../lib":161,"./micropolar":242,"./undo_manager":244,d3:8}],244:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function a(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(a(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(a(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r-1&&(u[d[r]].title="");for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(s,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(s,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||d.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),d.node().setAttributeNS(l.xmlns,"xmlns",l.svg),d.node().setAttributeNS(l.xmlns,"xmlns:xlink",l.xlink),"svg"===e&&r&&(d.attr("width",r*h),d.attr("height",r*g),d.attr("viewBox","0 0 "+h+" "+g));var _=(new window.XMLSerializer).serializeToString(d.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":43,"../components/drawing":68,"../constants/xmlns_namespaces":144,"../lib":161,d3:8}],254:[function(t,e,r){"use strict";var n=t("../../lib").mergeArray;e.exports=function(t,e){for(var r=0;rf+c||!n(u))&&(p=!0,g(d,t))}for(var v=0;vi))return e}return void 0!==r?r:t.dflt},r.coerceColor=function(t,e,r){return a(e).isValid()?e:void 0!==r?r:t.dflt},r.coerceEnumerated=function(t,e,r){return t.coerceNumber&&(e=+e),-1!==t.values.indexOf(e)?e:void 0!==r?r:t.dflt},r.getValue=function(t,e){var r;return Array.isArray(t)?e.01?C:function(t,e){return Math.abs(t-e)>=2?C(t):t>e?Math.ceil(t):Math.floor(t)};_=S(_,w),w=S(w,_),k=S(k,M),M=S(M,k)}i.ensureSingle(T,"path").style("vector-effect","non-scaling-stroke").attr("d","M"+_+","+k+"V"+M+"H"+w+"V"+k+"Z").call(s.setClipUrl,e.layerClipId),function(t,e,r,n,a,l,c,u){var y;function m(e,r,n){var a=i.ensureSingle(e,"text").text(r).attr({class:"bartext bartext-"+y,transform:"","text-anchor":"middle","data-notex":1}).call(s.font,n).call(o.convertToTspans,t);return a}var x=r[0].trace,b=x.orientation,_=function(t,e){var r=p.getValue(t.text,e);return p.coerceString(f,r)}(x,n);if(y=function(t,e){var r=p.getValue(t.textposition,e);return p.coerceEnumerated(d,r)}(x,n),!_||"none"===y)return void e.select("text").remove();var w,k,M,T,A,L,S=t._fullLayout.font,C=h.getBarColor(r[n],x),O=h.getInsideTextFont(x,n,S,C),P=h.getOutsideTextFont(x,n,S),D=t._fullLayout.barmode,z="relative"===D,E="stack"===D||z,R=r[n],N=!E||R._outmost,I=Math.abs(l-a)-2*g,F=Math.abs(u-c)-2*g;"outside"===y&&(N||R.hasB||(y="inside"));if("auto"===y)if(N){y="inside",w=m(e,_,O),k=s.bBox(w.node()),M=k.width,T=k.height;var B=M>0&&T>0,j=M<=I&&T<=F,H=M<=F&&T<=I,q="h"===b?I>=M*(F/T):F>=T*(I/M);B&&(j||H||q)?y="inside":(y="outside",w.remove(),w=null)}else y="inside";if(!w&&(w=m(e,_,"outside"===y?P:O),k=s.bBox(w.node()),M=k.width,T=k.height,M<=0||T<=0))return void w.remove();"outside"===y?(L="both"===x.constraintext||"outside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s="h"===i?Math.abs(n-r):Math.abs(e-t);s>2*g&&(l=g);var c=1;o&&(c="h"===i?Math.min(1,s/a.height):Math.min(1,s/a.width));var u,f,d,p,h=(a.left+a.right)/2,y=(a.top+a.bottom)/2;u=c*a.width,f=c*a.height,"h"===i?er?(d=(t+e)/2,p=n+l+f/2):(d=(t+e)/2,p=n-l-f/2);return v(h,y,d,p,c,!1)}(a,l,c,u,k,b,L)):(L="both"===x.constraintext||"inside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h=a.width,y=a.height,m=(a.left+a.right)/2,x=(a.top+a.bottom)/2,b=Math.abs(e-t),_=Math.abs(n-r);b>2*g&&_>2*g?(b-=2*(f=g),_-=2*f):f=0;h<=b&&y<=_?(d=!1,p=1):h<=_&&y<=b?(d=!0,p=1):hr?(c=(t+e)/2,u=n-f-s/2):(c=(t+e)/2,u=n+f+s/2);return v(m,x,c,u,p,d)}(a,l,c,u,k,b,L));w.attr("transform",A)}(t,T,r,u,_,w,k,M),e.layerClipId&&s.hideOutsideRangePoint(c,T.select("text"),y,m,b.xcalendar,b.ycalendar)}else T.remove();function C(t){return 0===x.bargap&&0===x.bargroupgap?n.round(Math.round(t)-L,2):t}});var w=!1===u.trace.cliponaxis;s.setClipUrl(c,w?null:e.layerClipId)});c.getComponentMethod("errorbars","plot")(b,e)}},{"../../components/color":43,"../../components/drawing":68,"../../lib":161,"../../lib/svg_text_utils":182,"../../registry":245,"./attributes":255,"./helpers":259,"./style":267,d3:8,"fast-isnumeric":10}],265:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,a=t.xaxis,i=t.yaxis,o=[];if(!1===e)for(r=0;r1||0===i.bargap&&0===i.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),r.selectAll("g.points").each(function(e){p(n.select(this),e[0].trace,t)}),l.getComponentMethod("errorbars","style")(r)},styleOnSelect:function(t,e){var r=e[0].node3,a=e[0].trace;a.selectedpoints?function(t,e,r){i.selectedPointStyle(t.selectAll("path"),e),function(t,e,r){t.each(function(t){var a,l=n.select(this);if(t.selected){a=o.extendFlat({},h(l,t,e,r));var s=e.selected.textfont&&e.selected.textfont.color;s&&(a.color=s),i.font(l,a)}else i.selectedTextStyle(l,e)})}(t.selectAll("text"),e,r)}(r,a,t):p(r,a,t)},getInsideTextFont:v,getOutsideTextFont:y,getBarColor:x}},{"../../components/color":43,"../../components/drawing":68,"../../lib":161,"../../registry":245,"./attributes":255,"./helpers":259,d3:8}],268:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l){r("marker.color",o),a(t,"marker")&&i(t,e,l,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),a(t,"marker.line")&&i(t,e,l,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57}],269:[function(t,e,r){"use strict";var n=t("../../components/color/attributes"),a=t("../../plots/font_attributes"),i=t("../../plots/attributes"),o=t("../../plots/domain").attributes,l=t("../../lib/extend").extendFlat,s=a({editType:"calc",arrayOk:!0,colorEditType:"plot"});e.exports={labels:{valType:"data_array",editType:"calc"},label0:{valType:"number",dflt:0,editType:"calc"},dlabel:{valType:"number",dflt:1,editType:"calc"},values:{valType:"data_array",editType:"calc"},marker:{colors:{valType:"data_array",editType:"calc"},line:{color:{valType:"color",dflt:n.defaultLine,arrayOk:!0,editType:"style"},width:{valType:"number",min:0,dflt:0,arrayOk:!0,editType:"style"},editType:"calc"},editType:"calc"},text:{valType:"data_array",editType:"calc"},hovertext:{valType:"string",dflt:"",arrayOk:!0,editType:"style"},scalegroup:{valType:"string",dflt:"",editType:"calc"},textinfo:{valType:"flaglist",flags:["label","text","value","percent"],extras:["none"],editType:"calc"},hoverinfo:l({},i.hoverinfo,{flags:["label","text","value","percent","name"]}),textposition:{valType:"enumerated",values:["inside","outside","auto","none"],dflt:"auto",arrayOk:!0,editType:"calc"},textfont:l({},s,{}),insidetextfont:l({},s,{}),outsidetextfont:l({},s,{}),title:{valType:"string",dflt:"",editType:"calc"},titleposition:{valType:"enumerated",values:["top left","top center","top right","middle center","bottom left","bottom center","bottom right"],editType:"calc"},titlefont:l({},s,{}),domain:o({name:"pie",trace:!0,editType:"calc"}),hole:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},sort:{valType:"boolean",dflt:!0,editType:"calc"},direction:{valType:"enumerated",values:["clockwise","counterclockwise"],dflt:"counterclockwise",editType:"calc"},rotation:{valType:"number",min:-360,max:360,dflt:0,editType:"calc"},pull:{valType:"number",min:0,max:1,dflt:0,arrayOk:!0,editType:"calc"}}},{"../../components/color/attributes":42,"../../lib/extend":155,"../../plots/attributes":202,"../../plots/domain":231,"../../plots/font_attributes":232}],270:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/get_data").getModuleCalcData;r.name="pie",r.plot=function(t){var e=n.getModule("pie"),r=a(t.calcdata,e)[0];r.length&&e.plot(t,r)},r.clean=function(t,e,r,n){var a=n._has&&n._has("pie"),i=e._has&&e._has("pie");a&&!i&&n._pielayer.selectAll("g.trace").remove()}},{"../../plots/get_data":234,"../../registry":245}],271:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib").isArrayOrTypedArray,i=t("tinycolor2"),o=t("../../components/color"),l=t("./helpers");r.calc=function(t,e){var r,s,c,u,f,d=e.values,p=a(d)&&d.length,h=e.labels,g=e.marker.colors||[],v=[],y=t._fullLayout,m=y._piecolormap,x={},b=0,_=y.hiddenlabels||[];if(e.dlabel)for(h=new Array(d.length),r=0;r")}}return v},r.crossTraceCalc=function(t){var e=t._fullLayout,r=t.calcdata,n=e.piecolorway,a=e._piecolormap;e.extendpiecolors&&(n=function(t){var e,r=JSON.stringify(t),n=s[r];if(!n){for(n=t.slice(),e=0;e0?1:-1)/2,y:i/(1+r*r/(n*n)),outside:!0}}function p(t,e){var r=t.trace,n=e.h*(r.domain.y[1]-r.domain.y[0]);return Math.min(t.titleBox.height,n/2)}function h(t){var e,r=t.pull;if(Array.isArray(r))for(r=0,e=0;er&&(r=t.pull[e]);return r}e.exports=function(t,e){var r=t._fullLayout;!function(t,e){for(var r,n,a=0;aa.vTotal/2?1:0)}(e),g.attr("stroke-linejoin","round"),g.each(function(){var g=n.select(this).selectAll("g.slice").data(e);g.enter().append("g").classed("slice",!0),g.exit().remove();var m=[[[],[]],[[],[]]],x=!1;g.each(function(e){if(e.hidden)n.select(this).selectAll("path,g").remove();else{e.pointNumber=e.i,e.curveNumber=y.index,m[e.pxmid[1]<0?0:1][e.pxmid[0]<0?0:1].push(e);var p=v.cx,h=v.cy,g=n.select(this),b=g.selectAll("path.surface").data([e]),_=!1,w=!1;if(b.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),g.select("path.textline").remove(),g.on("mouseover",function(){var i=t._fullLayout,o=t._fullData[y.index];if(!t._dragging&&!1!==i.hovermode){var l=o.hoverinfo;if(Array.isArray(l)&&(l=a.castHoverinfo({hoverinfo:[c.castOption(l,e.pts)],_module:y._module},i,0)),"all"===l&&(l="label+text+value+percent+name"),"none"!==l&&"skip"!==l&&l){var s=f(e,v),d=p+e.pxmid[0]*(1-s),g=h+e.pxmid[1]*(1-s),m=r.separators,x=[];if(-1!==l.indexOf("label")&&x.push(e.label),-1!==l.indexOf("text")){var b=c.castOption(o.hovertext||o.text,e.pts);b&&x.push(b)}-1!==l.indexOf("value")&&x.push(c.formatPieValue(e.v,m)),-1!==l.indexOf("percent")&&x.push(c.formatPiePercent(e.v/v.vTotal,m));var k=y.hoverlabel,M=k.font;a.loneHover({x0:d-s*v.r,x1:d+s*v.r,y:g,text:x.join("
"),name:-1!==l.indexOf("name")?o.name:void 0,idealAlign:e.pxmid[0]<0?"left":"right",color:c.castOption(k.bgcolor,e.pts)||e.color,borderColor:c.castOption(k.bordercolor,e.pts),fontFamily:c.castOption(M.family,e.pts),fontSize:c.castOption(M.size,e.pts),fontColor:c.castOption(M.color,e.pts)},{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:t}),_=!0}t.emit("plotly_hover",{points:[u(e,o)],event:n.event}),w=!0}}).on("mouseout",function(r){var i=t._fullLayout,o=t._fullData[y.index];w&&(r.originalEvent=n.event,t.emit("plotly_unhover",{points:[u(e,o)],event:n.event}),w=!1),_&&(a.loneUnhover(i._hoverlayer.node()),_=!1)}).on("click",function(){var r=t._fullLayout,i=t._fullData[y.index];t._dragging||!1===r.hovermode||(t._hoverdata=[u(e,i)],a.click(t,n.event))}),y.pull){var k=+c.castOption(y.pull,e.pts)||0;k>0&&(p+=k*e.pxmid[0],h+=k*e.pxmid[1])}e.cxFinal=p,e.cyFinal=h;var M=y.hole;if(e.v===v.vTotal){var T="M"+(p+e.px0[0])+","+(h+e.px0[1])+O(e.px0,e.pxmid,!0,1)+O(e.pxmid,e.px0,!0,1)+"Z";M?b.attr("d","M"+(p+M*e.px0[0])+","+(h+M*e.px0[1])+O(e.px0,e.pxmid,!1,M)+O(e.pxmid,e.px0,!1,M)+"Z"+T):b.attr("d",T)}else{var A=O(e.px0,e.px1,!0,1);if(M){var L=1-M;b.attr("d","M"+(p+M*e.px1[0])+","+(h+M*e.px1[1])+O(e.px1,e.px0,!1,M)+"l"+L*e.px0[0]+","+L*e.px0[1]+A+"Z")}else b.attr("d","M"+p+","+h+"l"+e.px0[0]+","+e.px0[1]+A+"Z")}var S=c.castOption(y.textposition,e.pts),C=g.selectAll("g.slicetext").data(e.text&&"none"!==S?[0]:[]);C.enter().append("g").classed("slicetext",!0),C.exit().remove(),C.each(function(){var r=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});r.text(e.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(o.font,"outside"===S?function(t,e,r){var n=c.castOption(t.outsidetextfont.color,e.pts)||c.castOption(t.textfont.color,e.pts)||r.color,a=c.castOption(t.outsidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,i=c.castOption(t.outsidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n,family:a,size:i}}(y,e,t._fullLayout.font):function(t,e,r){var n=c.castOption(t.insidetextfont.color,e.pts);!n&&t._input.textfont&&(n=c.castOption(t._input.textfont.color,e.pts));var a=c.castOption(t.insidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,o=c.castOption(t.insidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n||i.contrast(e.color),family:a,size:o}}(y,e,t._fullLayout.font)).call(s.convertToTspans,t);var a,u=o.bBox(r.node());"outside"===S?a=d(u,e):(a=function(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,i=Math.PI*Math.min(e.v/r.vTotal,.5),o=1-r.trace.hole,l=f(e,r),s={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(s.scale>=1)return s;var c=a+1/(2*Math.tan(i)),u=r.r*Math.min(1/(Math.sqrt(c*c+.5)+c),o/(Math.sqrt(a*a+o/2)+a)),d={scale:2*u/t.height,rCenter:Math.cos(u/r.r)-u*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},p=1/a,h=p+1/(2*Math.tan(i)),g=r.r*Math.min(1/(Math.sqrt(h*h+.5)+h),o/(Math.sqrt(p*p+o/2)+p)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},y=v.scale>d.scale?v:d;return s.scale<1&&y.scale>s.scale?y:s}(u,e,v),"auto"===S&&a.scale<1&&(r.call(o.font,y.outsidetextfont),y.outsidetextfont.family===y.insidetextfont.family&&y.outsidetextfont.size===y.insidetextfont.size||(u=o.bBox(r.node())),a=d(u,e)));var g=p+e.pxmid[0]*a.rCenter+(a.x||0),m=h+e.pxmid[1]*a.rCenter+(a.y||0);a.outside&&(e.yLabelMin=m-u.height/2,e.yLabelMid=m,e.yLabelMax=m+u.height/2,e.labelExtraX=0,e.labelExtraY=0,x=!0),r.attr("transform","translate("+g+","+m+")"+(a.scale<1?"scale("+a.scale+")":"")+(a.rotate?"rotate("+a.rotate+")":"")+"translate("+-(u.left+u.right)/2+","+-(u.top+u.bottom)/2+")")})}function O(t,r,n,a){return"a"+a*v.r+","+a*v.r+" 0 "+e.largeArc+(n?" 1 ":" 0 ")+a*(r[0]-t[0])+","+a*(r[1]-t[1])}});var b=n.select(this).selectAll("g.titletext").data(y.title?[0]:[]);b.enter().append("g").classed("titletext",!0),b.exit().remove(),b.each(function(){var e,a=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});a.text(y.title).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(o.font,y.titlefont).call(s.convertToTspans,t),e="middle center"===y.titleposition?function(t){var e=Math.sqrt(t.titleBox.width*t.titleBox.width+t.titleBox.height*t.titleBox.height);return{x:t.cx,y:t.cy,scale:t.trace.hole*t.r*2/e,tx:0,ty:-t.titleBox.height/2+t.trace.titlefont.size}}(v):function(t,e){var r,n,a=1,i=1,o=t.trace,l={x:t.cx,y:t.cy},s={tx:0,ty:0};s.ty+=o.titlefont.size,n=h(o),-1!==o.titleposition.indexOf("top")?(l.y-=(1+n)*t.r,s.ty-=t.titleBox.height):-1!==o.titleposition.indexOf("bottom")&&(l.y+=(1+n)*t.r);-1!==o.titleposition.indexOf("left")?(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x-=(1+n)*t.r,s.tx+=t.titleBox.width/2):-1!==o.titleposition.indexOf("center")?r=e.w*(o.domain.x[1]-o.domain.x[0]):-1!==o.titleposition.indexOf("right")&&(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x+=(1+n)*t.r,s.tx-=t.titleBox.width/2);return a=r/t.titleBox.width,i=p(t,e)/t.titleBox.height,{x:l.x,y:l.y,scale:Math.min(a,i),tx:s.tx,ty:s.ty}}(v,r._size),a.attr("transform","translate("+e.x+","+e.y+")"+(e.scale<1?"scale("+e.scale+")":"")+"translate("+e.tx+","+e.ty+")")}),x&&function(t,e){var r,n,a,i,o,l,s,u,f,d,p,h,g;function v(t,e){return t.pxmid[1]-e.pxmid[1]}function y(t,e){return e.pxmid[1]-t.pxmid[1]}function m(t,r){r||(r={});var a,u,f,p,h,g,v=r.labelExtraY+(n?r.yLabelMax:r.yLabelMin),y=n?t.yLabelMin:t.yLabelMax,m=n?t.yLabelMax:t.yLabelMin,x=t.cyFinal+o(t.px0[1],t.px1[1]),b=v-y;if(b*s>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(u=0;u=(c.castOption(e.pull,f.pts)||0)||((t.pxmid[1]-f.pxmid[1])*s>0?(p=f.cyFinal+o(f.px0[1],f.px1[1]),(b=p-y-t.labelExtraY)*s>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-x)*s>0&&(a=3*l*Math.abs(u-d.indexOf(t)),h=f.cxFinal+i(f.px0[0],f.px1[0]),(g=h+a-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*l>0&&(t.labelExtraX+=g)))}for(n=0;n<2;n++)for(a=n?v:y,o=n?Math.max:Math.min,s=n?1:-1,r=0;r<2;r++){for(i=r?Math.max:Math.min,l=r?1:-1,(u=t[n][r]).sort(a),f=t[1-n][r],d=f.concat(u),h=[],p=0;pMath.abs(c)?o+="l"+c*t.pxmid[0]/t.pxmid[1]+","+c+"H"+(a+t.labelExtraX+l):o+="l"+t.labelExtraX+","+s+"v"+(c-s)+"h"+l}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+l;e.append("path").classed("textline",!0).call(i.stroke,y.outsidetextfont.color).attr({"stroke-width":Math.min(2,y.outsidetextfont.size/8),d:o,fill:"none"})}})})});setTimeout(function(){g.selectAll("tspan").each(function(){var t=n.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":43,"../../components/drawing":68,"../../components/fx":85,"../../lib":161,"../../lib/svg_text_utils":182,"./event_data":273,"./helpers":274,d3:8}],279:[function(t,e,r){"use strict";var n=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each(function(t){n.select(this).call(a,t,e)})})}},{"./style_one":280,d3:8}],280:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("./helpers").castOption;e.exports=function(t,e,r){var i=r.marker.line,o=a(i.color,e.pts)||n.defaultLine,l=a(i.width,e.pts)||0;t.style({"stroke-width":l}).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":43,"./helpers":274}],281:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rl&&T[v].gap;)v--;for(m=T[v].s,h=T.length-1;h>v;h--)T[h].s=m;for(;lA[u]&&u=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===r.xaxis&&i.yaxis===r.yaxis){i.opacity=void 0;break}}}}}},{}],289:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),l=t("./subtypes"),s=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),d=t("./line_shape_defaults"),p=t("./text_defaults"),h=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,a){return n.coerce(t,e,i,r,a)}var y=s(t,e,g,v);if(y||(e.visible=!1),e.visible){var m=c(t,e,g,v),x=!m&&yG!=(I=D[O][1])>=G&&(E=D[O-1][0],R=D[O][0],I-N&&(z=E+(R-E)*(G-N)/(I-N),H=Math.min(H,z),q=Math.max(q,z)));H=Math.max(H,0),q=Math.min(q,d._length);var X=l.defaultLine;return l.opacity(f.fillcolor)?X=f.fillcolor:l.opacity((f.line||{}).color)&&(X=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:H,x1:q,y0:G,y1:G,color:X}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":43,"../../components/fx":85,"../../lib":161,"../../registry":245,"./fill_hover_text":290,"./get_trace_color":292}],294:[function(t,e,r){"use strict";var n={},a=t("./subtypes");n.hasLines=a.hasLines,n.hasMarkers=a.hasMarkers,n.hasText=a.hasText,n.isBubble=a.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":217,"./arrays_to_calcdata":281,"./attributes":282,"./calc":283,"./cross_trace_calc":287,"./cross_trace_defaults":288,"./defaults":289,"./hover":293,"./marker_colorbar":300,"./plot":302,"./select":303,"./style":305,"./subtypes":306}],295:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l,s){var c=(t.marker||{}).color;(l("line.color",r),a(t,"line"))?i(t,e,o,l,{prefix:"line.",cLetter:"c",noScale:!0}):l("line.color",!n(c)&&c||r);l("line.width"),(s||{}).noDash||l("line.dash")}},{"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57,"../../lib":161}],296:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),a=n.BADNUM,i=n.LOG_CLIP,o=i+.5,l=i-.5,s=t("../../lib"),c=s.segmentsIntersect,u=s.constrain,f=t("./constants");e.exports=function(t,e){var r,n,i,d,p,h,g,v,y,m,x,b,_,w,k,M,T,A,L=e.xaxis,S=e.yaxis,C="log"===L.type,O="log"===S.type,P=L._length,D=S._length,z=e.connectGaps,E=e.baseTolerance,R=e.shape,N="linear"===R,I=[],F=f.minTolerance,B=new Array(t.length),j=0;function H(e){var r=t[e];if(!r)return!1;var n=L.c2p(r.x),i=S.c2p(r.y);if(n===a){if(C&&(n=L.c2p(r.x,!0)),n===a)return!1;O&&i===a&&(n*=Math.abs(L._m*D*(L._m>0?o:l)/(S._m*P*(S._m>0?o:l)))),n*=1e3}if(i===a){if(O&&(i=S.c2p(r.y,!0)),i===a)return!1;i*=1e3}return[n,i]}function q(t,e,r,n){var a=r-t,i=n-e,o=.5-t,l=.5-e,s=a*a+i*i,c=a*o+i*l;if(c>0&&ctt||t[1]rt)return[u(t[0],K,tt),u(t[1],et,rt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,a){var i=at(n),o=at(a),l=[];if(i&&o&&it(i,o))return l;i&&l.push(i),o&&l.push(o);var c=2*s.constrain((n[t]+a[t])/2,e,r)-((i||n)[t]+(o||a)[t]);c&&((i&&o?c>0==i[t]>o[t]?i:o:i||o)[t]+=c);return l}}function lt(t){var e=t[0],r=t[1],n=e===B[j-1][0],a=r===B[j-1][1];if(!n||!a)if(j>1){var i=e===B[j-2][0],o=r===B[j-2][1];n&&(e===K||e===tt)&&i?o?j--:B[j-1]=t:a&&(r===et||r===rt)&&o?i?j--:B[j-1]=t:B[j++]=t}else B[j++]=t}function st(t){B[j-1][0]!==t[0]&&B[j-1][1]!==t[1]&<([Z,Y]),lt(t),W=null,Z=Y=0}function ct(t){if(T=t[0]/P,A=t[1]/D,G=t[0]tt?tt:0,X=t[1]rt?rt:0,G||X){if(j)if(W){var e=Q(W,t);e.length>1&&(st(e[0]),B[j++]=e[1])}else J=Q(B[j-1],t)[0],B[j++]=J;else B[j++]=[G||t[0],X||t[1]];var r=B[j-1];G&&X&&(r[0]!==G||r[1]!==X)?(W&&(Z!==G&&Y!==X?lt(Z&&Y?(n=W,i=(a=t)[0]-n[0],o=(a[1]-n[1])/i,(n[1]*a[0]-a[1]*n[0])/i>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[Z||G,Y||X]):Z&&Y&<([Z,Y])),lt([G,X])):Z-G&&Y-X&<([G||Z,X||Y]),W=t,Z=G,Y=X}else W&&st(Q(W,t)[0]),B[j++]=t;var n,a,i,o}for("linear"===R||"spline"===R?Q=function(t,e){for(var r=[],n=0,a=0;a<4;a++){var i=nt[a],o=c(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&U(o,t)V(h,ut))break;i=h,(_=y[0]*v[0]+y[1]*v[1])>x?(x=_,d=h,g=!1):_=t.length||!h)break;ct(h),n=h}}else ct(d)}W&<([Z||W[0],Y||W[1]]),I.push(B.slice(0,j))}return I}},{"../../constants/numerical":143,"../../lib":161,"./constants":286}],297:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],298:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var a,i,o,l,s,c={},u=!1,f=-1,d=0,p=-1;for(i=0;i=0?s=p:(s=p=d,d++),s0?Math.max(e,a):0}}},{"fast-isnumeric":10}],300:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],301:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,l,s,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(r=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",r),a(t,"marker")&&i(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c.noSelect||(s("selected.marker.color"),s("unselected.marker.color"),s("selected.marker.size"),s("unselected.marker.size")),c.noLine||(s("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?n.background:n.defaultLine),a(t,"marker.line")&&i(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0)),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode")),c.gradient)&&("none"!==s("marker.gradient.type")&&s("marker.gradient.color"))}},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57,"./subtypes":306}],302:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,l=i.identity,s=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),d=t("../../lib/polygon").tester;function p(t,e,r,f,p,h,g){var v;!function(t,e,r,a,o){var l=r.xaxis,s=r.yaxis,u=n.extent(i.simpleMap(l.range,l.r2c)),f=n.extent(i.simpleMap(s.range,s.r2c)),d=a[0].trace;if(!c.hasMarkers(d))return;var p=d.marker.maxdisplayed;if(0===p)return;var h=a.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(h.length/p),v=0;o.forEach(function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function m(t){return y?t.transition():t}var x=r.xaxis,b=r.yaxis,_=f[0].trace,w=_.line,k=n.select(h),M=o(k,"g","errorbars"),T=o(k,"g","lines"),A=o(k,"g","points"),L=o(k,"g","text");if(a.getComponentMethod("errorbars","plot")(M,r,g),!0===_.visible){var S,C;m(k).style("opacity",_.opacity);var O=_.fill.charAt(_.fill.length-1);"x"!==O&&"y"!==O&&(O=""),r.isRangePlot||(f[0].node3=k);var P="",D=[],z=_._prevtrace;z&&(P=z._prevRevpath||"",C=z._nextFill,D=z._polygons);var E,R,N,I,F,B,j,H,q,V="",U="",G=[],X=i.noop;if(S=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(C&&C.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(N=s.steps(w.shape),I=s.steps(w.shape.split("").reverse().join(""))):N=I="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?s.smoothclosed(t.slice(1),w.smoothing):s.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return I(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)m(r.style("opacity",0).attr("d",E).call(s.lineGroupStyle)).style("opacity",1);else{var a=m(r);a.attr("d",E),s.singleLineStyle(f,a)}}}}}var Z=T.selectAll(".js-line").data(G);m(Z.exit()).style("opacity",0).remove(),Z.each(X(!1)),Z.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(s.lineGroupStyle).each(X(!0)),s.setClipUrl(Z,r.layerClipId),G.length?(S?(S.datum(f),B&&H&&(O?("y"===O?B[1]=H[1]=b.c2p(0,!0):"x"===O&&(B[0]=H[0]=x.c2p(0,!0)),m(S).attr("d","M"+H+"L"+B+"L"+V.substr(1)).call(s.singleFillStyle)):m(S).attr("d",V+"Z").call(s.singleFillStyle))):C&&("tonext"===_.fill.substr(0,6)&&V&&P?("tonext"===_.fill?m(C).attr("d",V+"Z"+P+"Z").call(s.singleFillStyle):m(C).attr("d",V+"L"+P.substr(1)+"Z").call(s.singleFillStyle),_._polygons=_._polygons.concat(D)):(W(C),_._polygons=null)),_._prevRevpath=U,_._prevPolygons=q):(S?W(S):C&&W(C),_._polygons=_._prevRevpath=_._prevPolygons=null),A.datum(f),L.datum(f),function(e,a,i){var o,u=i[0].trace,f=c.hasMarkers(u),d=c.hasText(u),p=tt(u),h=et,g=et;if(f||d){var v=l,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?Q:J:_&&!w&&(v=$),f&&(h=v),d&&(g=v)}var k,M=(o=e.selectAll("path.point").data(h,p)).enter().append("path").classed("point",!0);y&&M.call(s.pointStyle,u,t).call(s.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=s.makePointStyleFns(u)),o.each(function(e){var a=n.select(this),i=m(a);s.translatePoint(e,i,x,b)?(s.singlePointStyle(e,i,u,k,t),r.layerClipId&&s.hideOutsideRangePoint(e,i,x,b,u.xcalendar,u.ycalendar),u.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),a=m(e.select("text"));s.translatePoint(t,a,x,b)?r.layerClipId&&s.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(s.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),r=b.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){m(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(A,L,f);var Y=!1===_.cliponaxis?null:r.layerClipId;s.setClipUrl(A,Y),s.setClipUrl(L,Y)}function W(t){m(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function Q(t){return t.filter(function(t){return t.vis})}function $(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,a,i,c){var u,d,h=!i,g=!!i&&i.duration>0,v=f(t,e,r);((u=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,r){e.each(function(t){var e=o(n.select(this),"g","fills");s.setClipUrl(e,r.layerClipId);var a=t[0].trace,i=[];a._ownfill&&i.push("_ownFill"),a._nexttrace&&i.push("_nextFill");var c=e.selectAll("g").data(i,l);c.enter().append("g"),c.exit().each(function(t){a[t]=null}).remove(),c.order().each(function(t){a[t]=o(n.select(this),"path","js-fill")})})}(0,u,e),g)?(c&&(d=c()),n.transition().duration(i.duration).ease(i.easing).each("end",function(){d&&d()}).each("interrupt",function(){d&&d()}).each(function(){a.selectAll("g.trace").each(function(r,n){p(t,n,e,r,v,this,i)})})):u.each(function(r,n){p(t,n,e,r,v,this,i)});h&&u.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":68,"../../lib":161,"../../lib/polygon":173,"../../registry":245,"./line_points":296,"./link_traces":298,"./subtypes":306,d3:8}],303:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,a,i,o,l=t.cd,s=t.xaxis,c=t.yaxis,u=[],f=l[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;margin-left:0px;margin-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var i in a){var o=i.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");n.addStyleRule(o,a[i])}},{"../src/lib":159}],2:[function(t,e,r){"use strict";e.exports={undo:{width:857.1,height:1e3,path:"m857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z",transform:"matrix(1 0 0 -1 0 850)"},home:{width:928.6,height:1e3,path:"m786 296v-267q0-15-11-26t-25-10h-214v214h-143v-214h-214q-15 0-25 10t-11 26v267q0 1 0 2t0 2l321 264 321-264q1-1 1-4z m124 39l-34-41q-5-5-12-6h-2q-7 0-12 3l-386 322-386-322q-7-4-13-4-7 2-12 7l-35 41q-4 5-3 13t6 12l401 334q18 15 42 15t43-15l136-114v109q0 8 5 13t13 5h107q8 0 13-5t5-13v-227l122-102q5-5 6-12t-4-13z",transform:"matrix(1 0 0 -1 0 850)"},"camera-retro":{width:1e3,height:1e3,path:"m518 386q0 8-5 13t-13 5q-37 0-63-27t-26-63q0-8 5-13t13-5 12 5 5 13q0 23 16 38t38 16q8 0 13 5t5 13z m125-73q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101z m-572-320h858v71h-858v-71z m643 320q0 89-62 152t-152 62-151-62-63-152 63-151 151-63 152 63 62 151z m-571 358h214v72h-214v-72z m-72-107h858v143h-462l-36-71h-360v-72z m929 143v-714q0-30-21-51t-50-21h-858q-29 0-50 21t-21 51v714q0 30 21 51t50 21h858q29 0 50-21t21-51z",transform:"matrix(1 0 0 -1 0 850)"},zoombox:{width:1e3,height:1e3,path:"m1000-25l-250 251c40 63 63 138 63 218 0 224-182 406-407 406-224 0-406-182-406-406s183-406 407-406c80 0 155 22 218 62l250-250 125 125z m-812 250l0 438 437 0 0-438-437 0z m62 375l313 0 0-312-313 0 0 312z",transform:"matrix(1 0 0 -1 0 850)"},pan:{width:1e3,height:1e3,path:"m1000 350l-187 188 0-125-250 0 0 250 125 0-188 187-187-187 125 0 0-250-250 0 0 125-188-188 186-187 0 125 252 0 0-250-125 0 187-188 188 188-125 0 0 250 250 0 0-126 187 188z",transform:"matrix(1 0 0 -1 0 850)"},zoom_plus:{width:875,height:1e3,path:"m1 787l0-875 875 0 0 875-875 0z m687-500l-187 0 0-187-125 0 0 187-188 0 0 125 188 0 0 187 125 0 0-187 187 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},zoom_minus:{width:875,height:1e3,path:"m0 788l0-876 875 0 0 876-875 0z m688-500l-500 0 0 125 500 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},autoscale:{width:1e3,height:1e3,path:"m250 850l-187 0-63 0 0-62 0-188 63 0 0 188 187 0 0 62z m688 0l-188 0 0-62 188 0 0-188 62 0 0 188 0 62-62 0z m-875-938l0 188-63 0 0-188 0-62 63 0 187 0 0 62-187 0z m875 188l0-188-188 0 0-62 188 0 62 0 0 62 0 188-62 0z m-125 188l-1 0-93-94-156 156 156 156 92-93 2 0 0 250-250 0 0-2 93-92-156-156-156 156 94 92 0 2-250 0 0-250 0 0 93 93 157-156-157-156-93 94 0 0 0-250 250 0 0 0-94 93 156 157 156-157-93-93 0 0 250 0 0 250z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_basic:{width:1500,height:1e3,path:"m375 725l0 0-375-375 375-374 0-1 1125 0 0 750-1125 0z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_compare:{width:1125,height:1e3,path:"m187 786l0 2-187-188 188-187 0 0 937 0 0 373-938 0z m0-499l0 1-187-188 188-188 0 0 937 0 0 376-938-1z",transform:"matrix(1 0 0 -1 0 850)"},plotlylogo:{width:1542,height:1e3,path:"m0-10h182v-140h-182v140z m228 146h183v-286h-183v286z m225 714h182v-1000h-182v1000z m225-285h182v-715h-182v715z m225 142h183v-857h-183v857z m231-428h182v-429h-182v429z m225-291h183v-138h-183v138z",transform:"matrix(1 0 0 -1 0 850)"},"z-axis":{width:1e3,height:1e3,path:"m833 5l-17 108v41l-130-65 130-66c0 0 0 38 0 39 0-1 36-14 39-25 4-15-6-22-16-30-15-12-39-16-56-20-90-22-187-23-279-23-261 0-341 34-353 59 3 60 228 110 228 110-140-8-351-35-351-116 0-120 293-142 474-142 155 0 477 22 477 142 0 50-74 79-163 96z m-374 94c-58-5-99-21-99-40 0-24 65-43 144-43 79 0 143 19 143 43 0 19-42 34-98 40v216h87l-132 135-133-135h88v-216z m167 515h-136v1c16 16 31 34 46 52l84 109v54h-230v-71h124v-1c-16-17-28-32-44-51l-89-114v-51h245v72z",transform:"matrix(1 0 0 -1 0 850)"},"3d_rotate":{width:1e3,height:1e3,path:"m922 660c-5 4-9 7-14 11-359 263-580-31-580-31l-102 28 58-400c0 1 1 1 2 2 118 108 351 249 351 249s-62 27-100 42c88 83 222 183 347 122 16-8 30-17 44-27-2 1-4 2-6 4z m36-329c0 0 64 229-88 296-62 27-124 14-175-11 157-78 225-208 249-266 8-19 11-31 11-31 2 5 6 15 11 32-5-13-8-20-8-20z m-775-239c70-31 117-50 198-32-121 80-199 346-199 346l-96-15-58-12c0 0 55-226 155-287z m603 133l-317-139c0 0 4-4 19-14 7-5 24-15 24-15s-177-147-389 4c235-287 536-112 536-112l31-22 100 299-4-1z m-298-153c6-4 14-9 24-15 0 0-17 10-24 15z",transform:"matrix(1 0 0 -1 0 850)"},camera:{width:1e3,height:1e3,path:"m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z m400 150h-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28l-31-94c-6-15-23-28-40-28h-120c-55 0-100-45-100-100v-450c0-55 45-100 100-100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250-250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35-35z",transform:"matrix(1 0 0 -1 0 850)"},movie:{width:1e3,height:1e3,path:"m938 413l-188-125c0 37-17 71-44 94 64 38 107 107 107 187 0 121-98 219-219 219-121 0-219-98-219-219 0-61 25-117 66-156h-115c30 33 49 76 49 125 0 103-84 187-187 187s-188-84-188-187c0-57 26-107 65-141-38-22-65-62-65-109v-250c0-70 56-126 125-126h500c69 0 125 56 125 126l188-126c34 0 62 28 62 63v375c0 35-28 63-62 63z m-750 0c-69 0-125 56-125 125s56 125 125 125 125-56 125-125-56-125-125-125z m406-1c-87 0-157 70-157 157 0 86 70 156 157 156s156-70 156-156-70-157-156-157z",transform:"matrix(1 0 0 -1 0 850)"},question:{width:857.1,height:1e3,path:"m500 82v107q0 8-5 13t-13 5h-107q-8 0-13-5t-5-13v-107q0-8 5-13t13-5h107q8 0 13 5t5 13z m143 375q0 49-31 91t-77 65-95 23q-136 0-207-119-9-14 4-24l74-55q4-4 10-4 9 0 14 7 30 38 48 51 19 14 48 14 27 0 48-15t21-33q0-21-11-34t-38-25q-35-16-65-48t-29-70v-20q0-8 5-13t13-5h107q8 0 13 5t5 13q0 10 12 27t30 28q18 10 28 16t25 19 25 27 16 34 7 45z m214-107q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z",transform:"matrix(1 0 0 -1 0 850)"},disk:{width:857.1,height:1e3,path:"m214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z",transform:"matrix(1 0 0 -1 0 850)"},lasso:{width:1031,height:1e3,path:"m1018 538c-36 207-290 336-568 286-277-48-473-256-436-463 10-57 36-108 76-151-13-66 11-137 68-183 34-28 75-41 114-42l-55-70 0 0c-2-1-3-2-4-3-10-14-8-34 5-45 14-11 34-8 45 4 1 1 2 3 2 5l0 0 113 140c16 11 31 24 45 40 4 3 6 7 8 11 48-3 100 0 151 9 278 48 473 255 436 462z m-624-379c-80 14-149 48-197 96 42 42 109 47 156 9 33-26 47-66 41-105z m-187-74c-19 16-33 37-39 60 50-32 109-55 174-68-42-25-95-24-135 8z m360 75c-34-7-69-9-102-8 8 62-16 128-68 170-73 59-175 54-244-5-9 20-16 40-20 61-28 159 121 317 333 354s407-60 434-217c28-159-121-318-333-355z",transform:"matrix(1 0 0 -1 0 850)"},selectbox:{width:1e3,height:1e3,path:"m0 850l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-285l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z",transform:"matrix(1 0 0 -1 0 850)"},spikeline:{width:1e3,height:1e3,path:"M512 409c0-57-46-104-103-104-57 0-104 47-104 104 0 57 47 103 104 103 57 0 103-46 103-103z m-327-39l92 0 0 92-92 0z m-185 0l92 0 0 92-92 0z m370-186l92 0 0 93-92 0z m0-184l92 0 0 92-92 0z",transform:"matrix(1.5 0 0 -1.5 0 850)"},newplotlylogo:{name:"newplotlylogo",svg:"plotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":260}],4:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":142}],5:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./pie")]),e.exports=n},{"./bar":3,"./core":4,"./pie":6}],6:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":274}],7:[function(t,e,r){var n=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},i=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var l,s=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),l=0===c.x}catch(t){l=!1}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,a){var i,o,l;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),l=o[e]):(o=t._events=n(null),t._eventsCount=0),l){if("function"==typeof l?l=o[e]=a?[r,l]:[l,r]:a?l.unshift(r):l.push(r),!l.warned&&(i=u(t))&&i>0&&l.length>i){l.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+l.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=l.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else l=o[e]=r,++t._eventsCount;return t}function d(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var s=new Error('Unhandled "error" event. ('+e+")");throw s.context=e,s}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,a=v(t,n),i=0;i=0;o--)if(r[o]===e||r[o].listener===e){l=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(var r=e,n=r+1,a=t.length;n=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],8:[function(t,e,r){!function(){var t={version:"3.5.17"},r=[].slice,n=function(t){return r.call(t)},a=this.document;function i(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(a)try{n(a.documentElement.childNodes)[0].nodeType}catch(t){n=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),a)try{a.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var l=this.Element.prototype,s=l.setAttribute,c=l.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;l.setAttribute=function(t,e){s.call(this,t,e+"")},l.setAttributeNS=function(t,e,r){c.call(this,t,e,r+"")},u.setProperty=function(t,e,r){f.call(this,t,e+"",r)}}function d(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function h(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)<0?n=i+1:a=i}return n},right:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)>0?a=i:n=i+1}return n}}}t.ascending=d,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++an&&(r=n)}else{for(;++a=n){r=n;break}for(;++an&&(r=n)}return r},t.max=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++ar&&(r=n)}else{for(;++a=n){r=n;break}for(;++ar&&(r=n)}return r},t.extent=function(t,e){var r,n,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=n){r=a=n;break}for(;++in&&(r=n),a=n){r=a=n;break}for(;++in&&(r=n),a1)return o/(s-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(d);function y(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return d(t(e),r)}:t)},t.shuffle=function(t,e,r){(i=arguments.length)<3&&(r=t.length,i<2&&(e=0));for(var n,a,i=r-e;i;)a=Math.random()*i--|0,n=t[i+e],t[i+e]=t[a+e],t[a+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],a=new Array(r<0?0:r);e=0;)for(e=(n=t[a]).length;--e>=0;)r[--o]=n[e];return r};var m=Math.abs;function x(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(m(r)),o=-1;if(t*=i,e*=i,(r*=i)<0)for(;(n=t+r*++o)>e;)a.push(n/i);else for(;(n=t+r*++o)=a.length)return r?r.call(n,i):e?i.sort(e):i;for(var s,c,u,f,d=-1,p=i.length,h=a[l++],g=new b;++d=a.length)return e;var n=[],o=i[r++];return e.forEach(function(e,a){n.push({key:e,values:t(a,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return a.push(t),n},n.sortKeys=function(t){return i[a.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new O;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function V(t){return q(t,Y),t}var U=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},X=function(t,e){var r=t.matches||t[z(t,"matchesSelector")];return(X=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(U=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,X=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var Y=t.selection.prototype=[];function Z(t){return"function"==typeof t?t:function(){return U(t,this)}}function W(t){return"function"==typeof t?t:function(){return G(t,this)}}Y.select=function(t){var e,r,n,a,i=[];t=Z(t);for(var o=-1,l=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),$.hasOwnProperty(r)?{space:$[r],local:t}:t}},Y.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each(Q(r,e[r]));return this}return this.each(Q(e,r))},Y.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,a=-1;if(e=r.classList){for(;++a=0;)(r=n[a])&&(i&&i!==r.nextSibling&&i.parentNode.insertBefore(r,i),i=r);return this},Y.sort=function(t){t=function(t){arguments.length||(t=d);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var s=ht.get(e);function c(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return s&&(e=s,l=vt),o?r?function(){var t=l(r,n(arguments));c.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=r}:c:r?R:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(r=a.match(n)){var i=this[a];this.removeEventListener(r[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=dt,dt.append=Y.append,dt.empty=Y.empty,dt.node=Y.node,dt.call=Y.call,dt.size=Y.size,dt.select=function(t){for(var e,r,n,a,i,o=[],l=-1,s=this.length;++l=n&&(n=e+1);!(o=l[n])&&++n0?1:t<0?-1:0}function Pt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function zt(t){return t>1?0:t<-1?Mt:Math.acos(t)}function Et(t){return t>1?St:t<-1?-St:Math.asin(t)}function Rt(t){return((t=Math.exp(t))+1/t)/2}function It(t){return(t=Math.sin(t/2))*t}var Nt=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,a=t[0],i=t[1],o=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-i,d=u*u+f*f;if(d0&&(e=e.transition().duration(g)),e.call(w.event)}function L(){c&&c.domain(s.range().map(function(t){return(t-d.x)/d.k}).map(s.invert)),f&&f.domain(u.range().map(function(t){return(t-d.y)/d.k}).map(u.invert))}function S(t){v++||t({type:"zoomstart"})}function C(t){L(),t({type:"zoom",scale:d.k,translate:[d.x,d.y]})}function O(t){--v||(t({type:"zoomend"}),r=null)}function D(){var e=this,r=_.of(e,arguments),n=0,a=t.select(o(e)).on(m,function(){n=1,M(t.mouse(e),i),C(r)}).on(x,function(){a.on(m,null).on(x,null),l(n),O(r)}),i=k(t.mouse(e)),l=xt(e);fl.call(e),S(r)}function P(){var e,r=this,n=_.of(r,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+o,c="touchend"+o,u=[],f=t.select(r),p=xt(r);function h(){var n=t.touches(r);return e=d.k,n.forEach(function(t){t.identifier in a&&(a[t.identifier]=k(t))}),n}function g(){var e=t.event.target;t.select(e).on(s,v).on(c,m),u.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){y=p[0];var x=p[1],b=y[0]-x[0],_=y[1]-x[1];i=b*b+_*_}}function v(){var o,s,c,u,f=t.touches(r);fl.call(r);for(var d=0,p=f.length;d360?t-=360:t<0&&(t+=360),t<60?n+(a-n)*t/60:t<180?a:t<240?n+(a-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(a=r<=.5?r*(1+e):r+e-r*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Zt?e.l:(e=de((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Ut(this.h,this.s,this.l)},t.hcl=Gt;var Xt=Gt.prototype=new Ht;function Yt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Zt(r,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Zt(t,e,r){return this instanceof Zt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Zt?new Zt(t.l,t.a,t.b):t instanceof Gt?Yt(t.h,t.c,t.l):de((t=ie(t)).r,t.g,t.b):new Zt(t,e,r)}Xt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Wt*(arguments.length?t:1)))},Xt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Wt*(arguments.length?t:1)))},Xt.rgb=function(){return Yt(this.h,this.c,this.l).rgb()},t.lab=Zt;var Wt=18,Jt=.95047,$t=1,Qt=1.08883,Kt=Zt.prototype=new Ht;function te(t,e,r){var n=(t+16)/116,a=n+e/500,i=n-r/200;return new ie(ae(3.2404542*(a=re(a)*Jt)-1.5371385*(n=re(n)*$t)-.4985314*(i=re(i)*Qt)),ae(-.969266*a+1.8760108*n+.041556*i),ae(.0556434*a-.2040259*n+1.0572252*i))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Ot,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,r){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ue(""+t,ie,Ut):new ie(t,e,r)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function le(t){return oe(t)+""}Kt.brighter=function(t){return new Zt(Math.min(100,this.l+Wt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Zt(Math.max(0,this.l-Wt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var se=ie.prototype=new Ht;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,r){var n,a,i,o=0,l=0,s=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=n[2].split(","),n[1]){case"hsl":return r(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(he(a[0]),he(a[1]),he(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,l=240&i,l|=l>>4,s=15&i,s|=s<<4):7===t.length&&(o=(16711680&i)>>16,l=(65280&i)>>8,s=255&i)),e(o,l,s))}function fe(t,e,r){var n,a,i=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),l=o-i,s=(o+i)/2;return l?(a=s<.5?l/(o+i):l/(2-o-i),n=t==o?(e-r)/l+(e0&&s<1?0:n),new qt(n,a,s)}function de(t,e,r){var n=ne((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(r=pe(r)))/Jt),a=ne((.2126729*t+.7151522*e+.072175*r)/$t);return Zt(116*a-16,500*(n-a),200*(a-ne((.0193339*t+.119192*e+.9503041*r)/Qt)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function he(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}se.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,a=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=a.call(o,c)}catch(t){return void l.error.call(o,t)}l.load.call(o,t)}else l.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var r=t.event;t.event=e;try{l.progress.call(o,c)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,a){if(2===arguments.length&&"function"==typeof n&&(a=n,n=null),c.open(t,e,!0),null==r||"accept"in s||(s.accept=r+",*/*"),c.setRequestHeader)for(var i in s)c.setRequestHeader(i,s[i]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=u&&(c.responseType=u),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),l.beforesend.call(o,c),c.send(null==n?null:n),o},o.abort=function(){return c.abort(),o},t.rebind(o,l,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=ye(D),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function a(t,r,n){arguments.length<3&&(n=r,r=null);var a=me(t,e,null==r?i:o(r),n);return a.row=function(t){return arguments.length?a.response(null==(r=t)?i:o(t)):r},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function l(e){return e.map(s).join(t)}function s(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var r;return a.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(a(t),r)}:a})},a.parseRows=function(t,e){var r,a,i={},o={},l=[],s=t.length,c=0,u=0;function f(){if(c>=s)return o;if(a)return a=!1,i;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Me,e)),_e=0):(_e=1,ke(Me))}function Ae(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Le(){for(var t,e=xe,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Se(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Ce[8+n/3]};var Oe=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,De=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Se(e,r))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),r))))}});function Pe(t){return t+""}var ze=t.time={},Ee=Date;function Re(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Re.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ie.setUTCDate.apply(this._,arguments)},setDay:function(){Ie.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ie.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ie.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ie.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ie.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ie.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ie.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ie.setTime.apply(this._,arguments)}};var Ie=Date.prototype;function Ne(t,e,r){function n(e){var r=t(e),n=i(r,1);return e-r1)for(;o68?1900:2e3),r+a[0].length):-1}function Je(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function $e(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function Qe(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ar(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=m(e)/60|0,a=m(e)%60;return r+qe(n,"0",2)+qe(a,"0",2)}function ir(t,e,r){He.lastIndex=0;var n=He.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),i.push(t.substring(r-=l,r+l)),!((s+=l+1)>e));)l=a[o=(o+1)%a.length];return i.reverse().join(n)}:D;return function(e){var n=Oe.exec(e),a=n[1]||" ",l=n[2]||">",s=n[3]||"-",c=n[4]||"",u=n[5],f=+n[6],d=n[7],p=n[8],h=n[9],g=1,v="",y="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===a&&"="===l)&&(u=a="0",l="="),h){case"n":d=!0,h="g";break;case"%":g=100,y="%",h="f";break;case"p":g=100,y="%",h="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+h.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":g=-1,h="r"}"$"===c&&(v=i[0],y=i[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):"e"!=h&&"f"!=h||(p=Math.max(0,Math.min(20,p)))),h=De.get(h)||Pe;var b=u&&d;return function(e){var n=y;if(m&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===s?"":s;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),n=c.symbol+y}else e*=g;var _,w,k=(e=h(e,p)).lastIndexOf(".");if(k<0){var T=x?e.lastIndexOf("e"):-1;T<0?(_=e,w=""):(_=e.substring(0,T),w=e.substring(T))}else _=e.substring(0,k),w=r+e.substring(k+1);!u&&d&&(_=o(_,1/0));var M=v.length+_.length+w.length+(b?0:i.length),A=M"===l?A+i+e:"^"===l?A.substring(0,M>>=1)+i+e+A.substring(M):i+(b?e:A+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,a=e.time,i=e.periods,o=e.days,l=e.shortDays,s=e.months,c=e.shortMonths;function u(t){var e=t.length;function r(r){for(var n,a,i,o=[],l=-1,s=0;++l=c)return-1;if(37===(a=e.charCodeAt(l++))){if(o=e.charAt(l++),!(i=w[o in je?e.charAt(l++):o])||(n=i(t,r,n))<0)return-1}else if(a!=r.charCodeAt(n++))return-1}return n}u.utc=function(t){var e=u(t);function r(t){try{var r=new(Ee=Re);return r._=t,e(r)}finally{Ee=Date}}return r.parse=function(t){try{Ee=Re;var r=e.parse(t);return r&&r._}finally{Ee=Date}},r.toString=e.toString,r},u.multi=u.utc.multi=or;var d=t.map(),p=Ve(o),h=Ue(o),g=Ve(l),v=Ue(l),y=Ve(s),m=Ue(s),x=Ve(c),b=Ue(c);i.forEach(function(t,e){d.set(t.toLowerCase(),e)});var _={a:function(t){return l[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:u(r),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+ze.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(ze.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(ze.mondayOfYear(t),e,2)},x:u(n),X:u(a),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:ar,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=h.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){y.lastIndex=0;var n=y.exec(e.slice(r));return n?(t.m=m.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:Qe,e:Qe,H:tr,I:tr,j:Ke,L:nr,m:$e,M:er,p:function(t,e,r){var n=d.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:Xe,w:Ge,W:Ye,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:We,Y:Ze,Z:Je,"%":ir};return u}(e)}};var lr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function sr(){}t.format=lr.numberFormat,t.geo={},sr.prototype={s:0,t:0,add:function(t){ur(t,this.t,cr),ur(cr.s,this.s,this),this.s?this.t+=cr.t:this.s=cr.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cr=new sr;function ur(t,e,r){var n=r.s=t+e,a=n-t,i=n-a;r.t=t-i+(e-a)}function fr(t,e){t&&pr.hasOwnProperty(t.type)&&pr[t.type](t,e)}t.geo.stream=function(t,e){t&&dr.hasOwnProperty(t.type)?dr[t.type](t,e):fr(t,e)};var dr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,a=r.length;++n=0?1:-1,l=o*i,s=Math.cos(e),c=Math.sin(e),u=a*c,f=n*s+u*Math.cos(l),d=u*o*Math.sin(l);Sr.add(Math.atan2(d,f)),r=t,n=s,a=c}Cr.point=function(o,l){Cr.point=i,r=(t=o)*Ct,n=Math.cos(l=(e=l)*Ct/2+Mt/4),a=Math.sin(l)},Cr.lineEnd=function(){i(t,e)}}function Dr(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Pr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function zr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Er(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Rr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Ir(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Nr(t){return[Math.atan2(t[1],t[0]),Et(t[2])]}function Fr(t,e){return m(t[0]-e[0])kt?a=90:c<-kt&&(r=-90),f[0]=e,f[1]=n}};function p(t,i){u.push(f=[e=t,n=t]),ia&&(a=i)}function h(t,o){var l=Dr([t*Ct,o*Ct]);if(s){var c=zr(s,l),u=zr([c[1],-c[0],0],c);Ir(u),u=Nr(u);var f=t-i,d=f>0?1:-1,h=u[0]*Ot*d,g=m(f)>180;if(g^(d*ia&&(a=v);else if(g^(d*i<(h=(h+360)%360-180)&&ha&&(a=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>i?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else p(t,o);s=l,i=t}function g(){d.point=h}function v(){f[0]=e,f[1]=n,d.point=p,s=null}function y(t,e){if(s){var r=t-i;c+=m(r)>180?r+(r>0?360:-360):r}else o=t,l=e;Cr.point(t,e),h(t,e)}function x(){Cr.lineStart()}function b(){y(o,l),Cr.lineEnd(),m(c)>kt&&(e=-(n=180)),f[0]=e,f[1]=n,s=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):l.push(g=p);for(var s,c,p,h=-1/0,g=(o=0,l[c=l.length-1]);o<=c;g=p,++o)p=l[o],(s=_(g[1],p[0]))>h&&(h=s,e=p[0],n=g[1])}return u=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,a]]}}(),t.geo.centroid=function(e){yr=mr=xr=br=_r=wr=kr=Tr=Mr=Ar=Lr=0,t.geo.stream(e,jr);var r=Mr,n=Ar,a=Lr,i=r*r+n*n+a*a;return i=0;--l)a.point((f=u[l])[0],f[1]);else n(p.x,p.p.x,-1,a);p=p.p}u=(p=p.o).z,h=!h}while(!p.v);a.lineEnd()}}}function Zr(t){if(e=t.length){for(var e,r,n=0,a=t[0];++n=0?1:-1,k=w*_,T=k>Mt,M=h*x;if(Sr.add(Math.atan2(M*w*Math.sin(k),g*b+M*Math.cos(k))),i+=T?_+w*At:_,T^d>=r^y>=r){var A=zr(Dr(f),Dr(t));Ir(A);var L=zr(a,A);Ir(L);var S=(T^_>=0?-1:1)*Et(L[2]);(n>S||n===S&&(A[0]||A[1]))&&(o+=T^_>=0?1:-1)}if(!v++)break;d=y,h=x,g=b,f=t}}return(i<-kt||i0){for(x||(o.polygonStart(),x=!0),o.lineStart();++i1&&2&e&&r.push(r.pop().concat(r.shift())),l.push(r.filter($r))}return u}}function $r(t){return t.length>1}function Qr(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:R,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-St-kt:St-t[1])-((e=e.x)[0]<0?e[1]-St-kt:St-e[1])}var tn=Jr(Xr,function(t){var e,r=NaN,n=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var l=i>0?Mt:-Mt,s=m(i-r);m(s-Mt)0?St:-St),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),t.point(i,n),e=0):a!==l&&s>=Mt&&(m(r-a)kt?Math.atan((Math.sin(e)*(i=Math.cos(n))*Math.sin(r)-Math.sin(n)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+n)/2}(r,n,i,o),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),e=0),t.point(r=i,n=o),a=l},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var a;if(null==t)a=r*St,n.point(-Mt,a),n.point(0,a),n.point(Mt,a),n.point(Mt,0),n.point(Mt,-a),n.point(0,-a),n.point(-Mt,-a),n.point(-Mt,0),n.point(-Mt,a);else if(m(t[0]-e[0])>kt){var i=t[0]0)){if(i/=d,d<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=r-s,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>u&&(u=i)}else if(d>0){if(i0)){if(i/=p,p<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=n-c,p||!(i<0)){if(i/=p,p<0){if(i>f)return;i>u&&(u=i)}else if(p>0){if(i0&&(a.a={x:s+u*d,y:c+u*p}),f<1&&(a.b={x:s+f*d,y:c+f*p}),a}}}}}}var rn=1e9;function nn(e,r,n,a){return function(s){var c,u,f,d,p,h,g,v,y,m,x,b=s,_=Qr(),w=en(e,r,n,a),k={point:A,lineStart:function(){k.point=L,u&&u.push(f=[]);m=!0,y=!1,g=v=NaN},lineEnd:function(){c&&(L(d,p),h&&y&&_.rejoin(),c.push(_.buffer()));k.point=A,y&&s.lineEnd()},polygonStart:function(){s=_,c=[],u=[],x=!0},polygonEnd:function(){s=b,c=t.merge(c);var r=function(t){for(var e=0,r=u.length,n=t[1],a=0;an&&Pt(c,i,t)>0&&++e:i[1]<=n&&Pt(c,i,t)<0&&--e,c=i;return 0!==e}([e,a]),n=x&&r,i=c.length;(n||i)&&(s.polygonStart(),n&&(s.lineStart(),T(null,null,1,s),s.lineEnd()),i&&Yr(c,o,r,T,s),s.polygonEnd()),c=u=f=null}};function T(t,o,s,c){var u=0,f=0;if(null==t||(u=i(t,s))!==(f=i(o,s))||l(t,o)<0^s>0)do{c.point(0===u||3===u?e:n,u>1?a:r)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function M(t,i){return e<=t&&t<=n&&r<=i&&i<=a}function A(t,e){M(t,e)&&s.point(t,e)}function L(t,e){var r=M(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(u&&f.push([t,e]),m)d=t,p=e,h=r,m=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&y)s.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(y||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),x=!1):r&&(s.lineStart(),s.point(t,e),x=!1)}g=t,v=e,y=r}return k};function i(t,a){return m(t[0]-e)0?0:3:m(t[0]-n)0?2:1:m(t[1]-r)0?1:0:a>0?3:2}function o(t,e){return l(t.x,e.x)}function l(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Mt/3,n=Cn(t),a=n(e,r);return a.parallels=function(t){return arguments.length?n(e=t[0]*Mt/180,r=t[1]*Mt/180):[e/Mt*180,r/Mt*180]},a}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,a=1+r*(2*n-r),i=Math.sqrt(a)/n;function o(t,e){var r=Math.sqrt(a-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),i-r*Math.cos(t)]}return o.invert=function(t,e){var r=i-e;return[Math.atan2(t,r)/n,Et((a-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(l){return arguments.length?(i=nn(t=+l[0][0],e=+l[0][1],r=+l[1][0],n=+l[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,r){e=[t,r]}};function c(t){var i=t[0],o=t[1];return e=null,r(i,o),e||(n(i,o),e)||a(i,o),e}return c.invert=function(t){var e=i.scale(),r=i.translate(),n=(t[0]-r[0])/e,a=(t[1]-r[1])/e;return(a>=.12&&a<.234&&n>=-.425&&n<-.214?o:a>=.166&&a<.234&&n>=-.214&&n<-.115?l:i).invert(t)},c.stream=function(t){var e=i.stream(t),r=o.stream(t),n=l.stream(t);return{point:function(t,a){e.point(t,a),r.point(t,a),n.point(t,a)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),l.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),l.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),u=+t[0],f=+t[1];return r=i.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(s).point,n=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(s).point,a=l.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(s).point,c},c.scale(1070)};var ln,sn,cn,un,fn,dn,pn={point:R,lineStart:R,lineEnd:R,polygonStart:function(){sn=0,pn.lineStart=hn},polygonEnd:function(){pn.lineStart=pn.lineEnd=pn.point=R,ln+=m(sn/2)}};function hn(){var t,e,r,n;function a(t,e){sn+=n*t-r*e,r=t,n=e}pn.point=function(i,o){pn.point=a,t=r=i,e=n=o},pn.lineEnd=function(){a(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);edn&&(dn=e)},lineStart:R,lineEnd:R,polygonStart:R,polygonEnd:R};function vn(){var t=yn(4.5),e=[],r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=yn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function a(t,n){e.push("M",t,",",n),r.point=i}function i(t,r){e.push("L",t,",",r)}function o(){r.point=n}function l(){e.push("Z")}return r}function yn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var mn,xn={point:bn,lineStart:_n,lineEnd:wn,polygonStart:function(){xn.lineStart=kn},polygonEnd:function(){xn.point=bn,xn.lineStart=_n,xn.lineEnd=wn}};function bn(t,e){xr+=t,br+=e,++_r}function _n(){var t,e;function r(r,n){var a=r-t,i=n-e,o=Math.sqrt(a*a+i*i);wr+=o*(t+r)/2,kr+=o*(e+n)/2,Tr+=o,bn(t=r,e=n)}xn.point=function(n,a){xn.point=r,bn(t=n,e=a)}}function wn(){xn.point=bn}function kn(){var t,e,r,n;function a(t,e){var a=t-r,i=e-n,o=Math.sqrt(a*a+i*i);wr+=o*(r+t)/2,kr+=o*(n+e)/2,Tr+=o,Mr+=(o=n*t-r*e)*(r+t),Ar+=o*(n+e),Lr+=3*o,bn(r=t,n=e)}xn.point=function(i,o){xn.point=a,bn(t=r=i,e=n=o)},xn.lineEnd=function(){a(t,e)}}function Tn(t){var e=4.5,r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:R};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,At)}function a(e,n){t.moveTo(e,n),r.point=i}function i(e,r){t.lineTo(e,r)}function o(){r.point=n}function l(){t.closePath()}return r}function Mn(t){var e=.5,r=Math.cos(30*Ct),n=16;function a(e){return(n?function(e){var r,a,o,l,s,c,u,f,d,p,h,g,v={point:y,lineStart:m,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=m}};function y(r,n){r=t(r,n),e.point(r[0],r[1])}function m(){f=NaN,v.point=x,e.lineStart()}function x(r,a){var o=Dr([r,a]),l=t(r,a);i(f,d,u,p,h,g,f=l[0],d=l[1],u=r,p=o[0],h=o[1],g=o[2],n,e),e.point(f,d)}function b(){v.point=y,e.lineEnd()}function _(){m(),v.point=w,v.lineEnd=k}function w(t,e){x(r=t,e),a=f,o=d,l=p,s=h,c=g,v.point=x}function k(){i(f,d,u,p,h,g,a,o,r,l,s,c,n,e),v.lineEnd=b,b()}return v}:function(e){return Ln(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function i(n,a,o,l,s,c,u,f,d,p,h,g,v,y){var x=u-n,b=f-a,_=x*x+b*b;if(_>4*e&&v--){var w=l+p,k=s+h,T=c+g,M=Math.sqrt(w*w+k*k+T*T),A=Math.asin(T/=M),L=m(m(T)-1)e||m((x*D+b*P)/_-.5)>.3||l*p+s*h+c*g0&&16,a):Math.sqrt(e)},a}function An(t){this.stream=t}function Ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sn(t){return Cn(function(){return t})()}function Cn(e){var r,n,a,i,o,l,s=Mn(function(t,e){return[(t=r(t,e))[0]*c+i,o-t[1]*c]}),c=150,u=480,f=250,d=0,p=0,h=0,g=0,v=0,y=tn,x=D,b=null,_=null;function w(t){return[(t=a(t[0]*Ct,t[1]*Ct))[0]*c+i,o-t[1]*c]}function k(t){return(t=a.invert((t[0]-i)/c,(o-t[1])/c))&&[t[0]*Ot,t[1]*Ot]}function T(){a=Gr(n=zn(h,g,v),r);var t=r(d,p);return i=u-t[0]*c,o=f+t[1]*c,M()}function M(){return l&&(l.valid=!1,l=null),w}return w.stream=function(t){return l&&(l.valid=!1),(l=On(y(n,s(x(t))))).valid=!0,l},w.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,tn):function(t){var e=Math.cos(t),r=e>0,n=m(e)>kt;return Jr(a,function(t){var e,l,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var p,h=[f,d],g=a(f,d),v=r?g?0:o(f,d):g?o(f+(f<0?Mt:-Mt),d):0;if(!e&&(c=s=g)&&t.lineStart(),g!==s&&(p=i(e,h),(Fr(e,p)||Fr(h,p))&&(h[0]+=kt,h[1]+=kt,g=a(h[0],h[1]))),g!==s)u=0,g?(t.lineStart(),p=i(h,e),t.point(p[0],p[1])):(p=i(e,h),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(n&&e&&r^g){var y;v&l||!(y=i(h,e,!0))||(u=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!g||e&&Fr(e,h)||t.point(h[0],h[1]),e=h,s=g,l=v},lineEnd:function(){s&&t.lineEnd(),e=null},clean:function(){return u|(c&&s)<<1}}},Nn(t,6*Ct),r?[0,-t]:[-Mt,t-Mt]);function a(t,r){return Math.cos(t)*Math.cos(r)>e}function i(t,r,n){var a=[1,0,0],i=zr(Dr(t),Dr(r)),o=Pr(i,i),l=i[0],s=o-l*l;if(!s)return!n&&t;var c=e*o/s,u=-e*l/s,f=zr(a,i),d=Rr(a,c);Er(d,Rr(i,u));var p=f,h=Pr(d,p),g=Pr(p,p),v=h*h-g*(Pr(d,d)-1);if(!(v<0)){var y=Math.sqrt(v),x=Rr(p,(-h-y)/g);if(Er(x,d),x=Nr(x),!n)return x;var b,_=t[0],w=r[0],k=t[1],T=r[1];w<_&&(b=_,_=w,w=b);var M=w-_,A=m(M-Mt)0^x[1]<(m(x[0]-_)Mt^(_<=x[0]&&x[0]<=w)){var L=Rr(p,(-h+y)/g);return Er(L,d),[x,Nr(L)]}}}function o(e,n){var a=r?t:Mt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),n<-a?i|=4:n>a&&(i|=8),i}}((b=+t)*Ct),M()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):D,M()):_},w.scale=function(t){return arguments.length?(c=+t,T()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],T()):[u,f]},w.center=function(t){return arguments.length?(d=t[0]%360*Ct,p=t[1]%360*Ct,T()):[d*Ot,p*Ot]},w.rotate=function(t){return arguments.length?(h=t[0]%360*Ct,g=t[1]%360*Ct,v=t.length>2?t[2]%360*Ct:0,T()):[h*Ot,g*Ot,v*Ot]},t.rebind(w,s,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&k,T()}}function On(t){return Ln(t,function(e,r){t.point(e*Ct,r*Ct)})}function Dn(t,e){return[t,e]}function Pn(t,e){return[t>Mt?t-At:t<-Mt?t+At:t,e]}function zn(t,e,r){return t?e||r?Gr(Rn(t),In(e,r)):Rn(t):e||r?In(e,r):Pn}function En(t){return function(e,r){return[(e+=t)>Mt?e-At:e<-Mt?e+At:e,r]}}function Rn(t){var e=En(t);return e.invert=En(-t),e}function In(t,e){var r=Math.cos(t),n=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*r+l*n;return[Math.atan2(s*a-u*i,l*r-c*n),Et(u*a+s*i)]}return o.invert=function(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*a-s*i;return[Math.atan2(s*a+c*i,l*r+u*n),Et(u*r-l*n)]},o}function Nn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(a,i,o,l){var s=o*e;null!=a?(a=Fn(r,a),i=Fn(r,i),(o>0?ai)&&(a+=o*At)):(a=t+o*At,i=t-.5*s);for(var c,u=a;o>0?u>i:u2?t[2]*Ct:0),e.invert=function(e){return(e=t.invert(e[0]*Ct,e[1]*Ct))[0]*=Ot,e[1]*=Ot,e},e},Pn.invert=Dn,t.geo.circle=function(){var t,e,r=[0,0],n=6;function a(){var t="function"==typeof r?r.apply(this,arguments):r,n=zn(-t[0]*Ct,-t[1]*Ct,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=n(t,e)),t[0]*=Ot,t[1]*=Ot}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(r=t,a):r},a.angle=function(r){return arguments.length?(e=Nn((t=+r)*Ct,n*Ct),a):t},a.precision=function(r){return arguments.length?(e=Nn(t*Ct,(n=+r)*Ct),a):n},a.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Ct,a=t[1]*Ct,i=e[1]*Ct,o=Math.sin(n),l=Math.cos(n),s=Math.sin(a),c=Math.cos(a),u=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-s*f*l)*r),s*u+c*f*l)},t.geo.graticule=function(){var e,r,n,a,i,o,l,s,c,u,f,d,p=10,h=p,g=90,v=360,y=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(a/g)*g,n,g).map(f).concat(t.range(Math.ceil(s/v)*v,l,v).map(d)).concat(t.range(Math.ceil(r/p)*p,e,p).filter(function(t){return m(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/h)*h,i,h).filter(function(t){return m(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(d(l).slice(1),f(n).reverse().slice(1),d(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(a=+t[0][0],n=+t[1][0],s=+t[0][1],l=+t[1][1],a>n&&(t=a,a=n,n=t),s>l&&(t=s,s=l,l=t),x.precision(y)):[[a,s],[n,l]]},x.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),o>i&&(t=o,o=i,i=t),x.precision(y)):[[r,o],[e,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],h=+t[1],x):[p,h]},x.precision=function(t){return arguments.length?(y=+t,c=jn(o,i,90),u=Bn(r,e,y),f=jn(s,l,90),d=Bn(a,n,y),x):y},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,r,n=Hn,a=qn;function i(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||a.apply(this,arguments))},i.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,i):n},i.target=function(t){return arguments.length?(a=t,r="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return r=t[0]*Ct,n=t[1]*Ct,a=e[0]*Ct,i=e[1]*Ct,o=Math.cos(n),l=Math.sin(n),s=Math.cos(i),c=Math.sin(i),u=o*Math.cos(r),f=o*Math.sin(r),d=s*Math.cos(a),p=s*Math.sin(a),h=2*Math.asin(Math.sqrt(It(i-n)+o*s*It(a-r))),g=1/Math.sin(h),(v=h?function(t){var e=Math.sin(t*=h)*g,r=Math.sin(h-t)*g,n=r*u+e*d,a=r*f+e*p,i=r*l+e*c;return[Math.atan2(a,n)*Ot,Math.atan2(i,Math.sqrt(n*n+a*a))*Ot]}:function(){return[r*Ot,n*Ot]}).distance=h,v;var r,n,a,i,o,l,s,c,u,f,d,p,h,g,v},t.geo.length=function(e){return mn=0,t.geo.stream(e,Vn),mn};var Vn={sphere:R,point:R,lineStart:function(){var t,e,r;function n(n,a){var i=Math.sin(a*=Ct),o=Math.cos(a),l=m((n*=Ct)-t),s=Math.cos(l);mn+=Math.atan2(Math.sqrt((l=o*Math.sin(l))*l+(l=r*i-e*o*s)*l),e*i+r*o*s),t=n,e=i,r=o}Vn.point=function(a,i){t=a*Ct,e=Math.sin(i*=Ct),r=Math.cos(i),Vn.point=n},Vn.lineEnd=function(){Vn.point=Vn.lineEnd=R}},lineEnd:R,polygonStart:R,polygonEnd:R};function Un(t,e){function r(e,r){var n=Math.cos(e),a=Math.cos(r),i=t(n*a);return[i*a*Math.sin(e),i*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),a=e(n),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,n*o),Math.asin(n&&r*i/n)]},r}var Gn=Un(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sn(Gn)}).raw=Gn;var Xn=Un(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},D);function Yn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Mt/4+t/2)},a=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),i=r*Math.pow(n(t),a)/a;if(!a)return Jn;function o(t,e){i>0?e<-St+kt&&(e=-St+kt):e>St-kt&&(e=St-kt);var r=i/Math.pow(n(e),a);return[r*Math.sin(a*t),i-r*Math.cos(a*t)]}return o.invert=function(t,e){var r=i-e,n=Dt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(i/n,1/a))-St]},o}function Zn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),a=r/n+t;if(m(n)1&&Pt(t[r[n-2]],t[r[n-1]],t[a])<=0;)--n;r[n++]=a}return r.slice(0,n)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sn(Kn)}).raw=Kn,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=$n(ta),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,r=ra;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,a=ve(e),i=ve(r),o=t.length,l=[],s=[];for(n=0;n=0;--n)p.push(t[l[c[n]][2]]);for(n=+f;nkt)l=l.L;else{if(!((a=i-wa(l,o))>kt)){n>-kt?(e=l.P,r=l):a>-kt?(e=l,r=l.N):e=r=l;break}if(!l.R){e=l;break}l=l.R}var s=ya(t);if(fa.insert(e,s),e||r){if(e===r)return La(e),r=ya(e.site),fa.insert(s,r),s.edge=r.edge=Oa(e.site,s.site),Aa(e),void Aa(r);if(r){La(e),La(r);var c=e.site,u=c.x,f=c.y,d=t.x-u,p=t.y-f,h=r.site,g=h.x-u,v=h.y-f,y=2*(d*v-p*g),m=d*d+p*p,x=g*g+v*v,b={x:(v*m-p*x)/y+u,y:(d*x-g*m)/y+f};Da(r.edge,c,h,b),s.edge=Oa(c,t,null,b),r.edge=Oa(t,h,null,b),Aa(e),Aa(r)}else s.edge=Oa(e.site,s.site)}}function _a(t,e){var r=t.site,n=r.x,a=r.y,i=a-e;if(!i)return n;var o=t.P;if(!o)return-1/0;var l=(r=o.site).x,s=r.y,c=s-e;if(!c)return l;var u=l-n,f=1/i-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-i/2)))/f+n:(n+l)/2}function wa(t,e){var r=t.N;if(r)return _a(r,e);var n=t.site;return n.y===e?n.x:1/0}function ka(t){this.site=t,this.edges=[]}function Ta(t,e){return e.angle-t.angle}function Ma(){Ea(this),this.x=this.y=this.arc=this.site=this.cy=null}function Aa(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,a=t.site,i=r.site;if(n!==i){var o=a.x,l=a.y,s=n.x-o,c=n.y-l,u=i.x-o,f=2*(s*(v=i.y-l)-c*u);if(!(f>=-Tt)){var d=s*s+c*c,p=u*u+v*v,h=(v*d-c*p)/f,g=(s*p-u*d)/f,v=g+l,y=ga.pop()||new Ma;y.arc=t,y.site=a,y.x=h+o,y.y=v+Math.sqrt(h*h+g*g),y.cy=v,t.circle=y;for(var m=null,x=pa._;x;)if(y.y=l)return;if(d>h){if(i){if(i.y>=c)return}else i={x:v,y:s};r={x:v,y:c}}else{if(i){if(i.y1)if(d>h){if(i){if(i.y>=c)return}else i={x:(s-a)/n,y:s};r={x:(c-a)/n,y:c}}else{if(i){if(i.y=l)return}else i={x:o,y:n*o+a};r={x:l,y:n*l+a}}else{if(i){if(i.xkt||m(a-r)>kt)&&(l.splice(o,0,new Pa((y=i.site,x=u,b=m(n-f)kt?{x:f,y:m(e-f)kt?{x:m(r-h)kt?{x:d,y:m(e-d)kt?{x:m(r-p)=r&&c.x<=a&&c.y>=n&&c.y<=o?[[r,o],[a,o],[a,n],[r,n]]:[]).point=t[l]}),e}function l(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/kt)*kt,y:Math.round(a(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Fa(l(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fa(l(t)).cells.forEach(function(r,n){for(var a,i,o,l,s=r.site,c=r.edges.sort(Ta),u=-1,f=c.length,d=c[f-1].edge,p=d.l===s?d.r:d.l;++ui&&(a=e.slice(i,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(n=n[0])?l[o]?l[o]+=n:l[++o]=n:(l[++o]=null,s.push({i:o,x:Ga(r,n)})),i=Za.lastIndex;return ig&&(g=s.x),s.y>v&&(v=s.y),c.push(s.x),u.push(s.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-h;function T(t,e,r,n,a,i,o,l){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var s=t.x,c=t.y;if(null!=s)if(m(s-r)+m(c-n)<.01)M(t,e,r,n,a,i,o,l);else{var u=t.point;t.x=t.y=t.point=null,M(t,u,s,c,a,i,o,l),M(t,e,r,n,a,i,o,l)}else t.x=r,t.y=n,t.point=e}else M(t,e,r,n,a,i,o,l)}function M(t,e,r,n,a,i,o,l){var s=.5*(a+o),c=.5*(i+l),u=r>=s,f=n>=c,d=f<<1|u;t.leaf=!1,u?a=s:o=s,f?i=c:l=c,T(t=t.nodes[d]||(t.nodes[d]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}}),e,r,n,a,i,o,l)}w>k?v=h+w:g=p+k;var A={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}};if(A.visit=function(t){!function t(e,r,n,a,i,o){if(!e(r,n,a,i,o)){var l=.5*(n+i),s=.5*(a+o),c=r.nodes;c[0]&&t(e,c[0],n,a,l,s),c[1]&&t(e,c[1],l,a,i,s),c[2]&&t(e,c[2],n,s,l,o),c[3]&&t(e,c[3],l,s,i,o)}}(t,A,p,h,g,v)},A.find=function(t){return function(t,e,r,n,a,i,o){var l,s=1/0;return function t(c,u,f,d,p){if(!(u>i||f>o||d=_)<<1|e>=b,k=w+4;w=0&&!(n=t.interpolators[a](e,r)););return n}function Ja(t,e){var r,n=[],a=[],i=t.length,o=e.length,l=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function ii(t){return 1-Math.cos(t*St)}function oi(t){return Math.pow(2,10*(t-1))}function li(t){return 1-Math.sqrt(1-t*t)}function si(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ci(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ui(t){var e,r,n,a=[t.a,t.b],i=[t.c,t.d],o=di(a),l=fi(a,i),s=di(((e=i)[0]+=(n=-l)*(r=a)[0],e[1]+=n*r[1],e))||0;a[0]*i[1]=0?t.slice(0,n):t,i=n>=0?t.slice(n+1):"in";return a=Qa.get(a)||$a,i=Ka.get(i)||D,e=i(a.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,a=e.c,i=e.l,o=r.h-n,l=r.c-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.c:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Yt(n+o*t,a+l*t,i+s*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,a=e.s,i=e.l,o=r.h-n,l=r.s-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.s:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ut(n+o*t,a+l*t,i+s*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,a=e.a,i=e.b,o=r.l-n,l=r.a-a,s=r.b-i;return function(t){return te(n+o*t,a+l*t,i+s*t)+""}},t.interpolateRound=ci,t.transform=function(e){var r=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ui(e?e.matrix:pi)})(e)},ui.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pi={a:1,b:0,c:0,d:1,e:0,f:0};function hi(t){return t.length?t.pop()+",":""}function gi(e,r){var n=[],a=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push("translate(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,a),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(hi(r)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&r.push(hi(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,a),function(t,e,r,n){t!==e?n.push({i:r.push(hi(r)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&r.push(hi(r)+"skewX("+e+")")}(e.skew,r.skew,n,a),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push(hi(r)+"scale(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(hi(r)+"scale("+e+")")}(e.scale,r.scale,n,a),e=r=null,function(t){for(var e,r=-1,i=a.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,s.end({type:"end",alpha:n=0})):t>0&&(s.start({type:"start",alpha:n=t}),e=Te(l.tick)),l):n},l.start=function(){var t,e,r,n=y.length,s=m.length,u=c[0],h=c[1];for(t=0;t=0;)r.push(a[n])}function Ci(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(u=c[s]),u.parent=i,u.depth=i.depth+1;r&&(i.value=0),i.children=c}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Ci(a,function(e){var n,a;t&&(n=e.children)&&n.sort(t),r&&(a=e.parent)&&(a.value+=e.value)}),l}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Si(t,function(t){t.children&&(t.value=0)}),Ci(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var a=e.call(this,t,n);return function t(e,r,n,a){var i=e.children;if(e.x=r,e.y=e.depth*a,e.dx=n,e.dy=a,i&&(o=i.length)){var o,l,s,c=-1;for(n=e.value?n/e.value:0;++cl&&(l=n),o.push(n)}for(r=0;ra&&(n=r,a=e);return n}function Vi(t){return t.reduce(Ui,0)}function Ui(t,e){return t+e[1]}function Gi(t,e){return Xi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Xi(t,e){for(var r=-1,n=+t[0],a=(t[1]-n)/e,i=[];++r<=e;)i[r]=a*r+n;return i}function Yi(e){return[t.min(e),t.max(e)]}function Zi(t,e){return t.value-e.value}function Wi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function $i(t,e){var r=e.x-t.x,n=e.y-t.y,a=t.r+e.r;return.999*a*a>r*r+n*n}function Qi(t){if((e=t.children)&&(s=e.length)){var e,r,n,a,i,o,l,s,c=1/0,u=-1/0,f=1/0,d=-1/0;if(e.forEach(Ki),(r=e[0]).x=-r.r,r.y=0,x(r),s>1&&((n=e[1]).x=n.r,n.y=0,x(n),s>2))for(eo(r,n,a=e[2]),x(a),Wi(r,a),r._pack_prev=a,Wi(a,n),n=r._pack_next,i=3;i0)for(o=-1;++o=f[0]&&s<=f[1]&&((l=c[t.bisect(d,s,1,h)-1]).y+=g,l.push(i[o]));return c}return i.value=function(t){return arguments.length?(r=t,i):r},i.range=function(t){return arguments.length?(n=ve(t),i):n},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Xi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Zi),n=0,a=[1,1];function i(t,i){var o=r.call(this,t,i),l=o[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,Ci(l,function(t){t.r=+u(t.value)}),Ci(l,Qi),n){var f=n*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;Ci(l,function(t){t.r+=f}),Ci(l,Qi),Ci(l,function(t){t.r-=f})}return function t(e,r,n,a){var i=e.children;e.x=r+=a*e.x;e.y=n+=a*e.y;e.r*=a;if(i)for(var o=-1,l=i.length;++op.x&&(p=t),t.depth>h.depth&&(h=t)});var g=r(d,p)/2-d.x,v=n[0]/(p.x+r(p,d)/2+g),y=n[1]/(h.depth||1);Si(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*y})}return c}function o(t){var e=t.children,n=t.parent.children,a=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+r(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+r(t._,a._));t.parent.A=function(t,e,n){if(e){for(var a,i=t,o=t,l=e,s=i.parent.children[0],c=i.m,u=o.m,f=l.m,d=s.m;l=ao(l),i=no(i),l&&i;)s=no(s),(o=ao(o)).a=t,(a=l.z+f-i.z-c+r(l._,i._))>0&&(io(oo(l,t,n),t,a),c+=a,u+=a),f+=l.m,c+=i.m,d+=s.m,u+=o.m;l&&!ao(o)&&(o.t=l,o.m+=f-u),i&&!no(s)&&(s.t=i,s.m+=c-d,n=t)}return n}(t,a,t.parent.A||n[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=n[0],t.y=t.depth*n[1]}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t)?s:null,i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null==(n=t)?null:s,i):a?n:null},Li(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],a=!1;function i(i,o){var l,s=e.call(this,i,o),c=s[0],u=0;Ci(c,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=l?u+=r(e,l):0,e.y=0,l=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(c),d=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(c),p=f.x-r(f,d)/2,h=d.x+r(d,f)/2;return Ci(c,a?function(t){t.x=(t.x-c.x)*n[0],t.y=(c.y-t.y)*n[1]}:function(t){t.x=(t.x-p)/(h-p)*n[0],t.y=(1-(c.y?t.y/c.y:1))*n[1]}),s}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t),i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null!=(n=t),i):a?n:null},Li(i,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,a=[1,1],i=null,o=lo,l=!1,s="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var r,n,a=-1,i=t.length;++a0;)l.push(r=c[a-1]),l.area+=r.area,"squarify"!==s||(n=p(l,g))<=d?(c.pop(),d=n):(l.area-=l.pop().area,h(l,g,i,!1),g=Math.min(i.dx,i.dy),l.length=l.area=0,d=1/0);l.length&&(h(l,g,i,!0),l.length=l.area=0),e.forEach(f)}}function d(t){var e=t.children;if(e&&e.length){var r,n=o(t),a=e.slice(),i=[];for(u(a,n.dx*n.dy/t.value),i.area=0;r=a.pop();)i.push(r),i.area+=r.area,null!=r.z&&(h(i,r.z?n.dx:n.dy,n,!a.length),i.length=i.area=0);e.forEach(d)}}function p(t,e){for(var r,n=t.area,a=0,i=1/0,o=-1,l=t.length;++oa&&(a=r));return e*=e,(n*=n)?Math.max(e*a*c/n,n/(e*i*c)):1/0}function h(t,e,r,a){var i,o=-1,l=t.length,s=r.x,c=r.y,u=e?n(t.area/e):0;if(e==r.dx){for((a||u>r.dy)&&(u=r.dy);++or.dx)&&(u=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,l=a?yi:vi;return i=t(e,r,l,n),o=t(r,e,l,Wa),s}function s(t){return i(t)}s.invert=function(t){return o(t)};s.domain=function(t){return arguments.length?(e=t.map(Number),l()):e};s.range=function(t){return arguments.length?(r=t,l()):r};s.rangeRound=function(t){return s.range(t).interpolate(ci)};s.clamp=function(t){return arguments.length?(a=t,l()):a};s.interpolate=function(t){return arguments.length?(n=t,l()):n};s.ticks=function(t){return bo(e,t)};s.tickFormat=function(t,r){return _o(e,t,r)};s.nice=function(t){return mo(e,t),l()};s.copy=function(){return t(e,r,n,a)};return l()}([0,1],[0,1],Wa,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function l(t){return a?Math.pow(n,t):-Math.pow(n,-t)}function s(t){return r(o(t))}s.invert=function(t){return l(r.invert(t))};s.domain=function(t){return arguments.length?(a=t[0]>=0,r.domain((i=t.map(Number)).map(o)),s):i};s.base=function(t){return arguments.length?(n=+t,r.domain(i.map(o)),s):n};s.nice=function(){var t=po(i.map(o),a?Math:Mo);return r.domain(t),i=t.map(l),s};s.ticks=function(){var t=co(i),e=[],r=t[0],s=t[1],c=Math.floor(o(r)),u=Math.ceil(o(s)),f=n%1?2:n;if(isFinite(u-c)){if(a){for(;c0;d--)e.push(l(c)*d);for(c=0;e[c]s;u--);e=e.slice(c,u)}return e};s.tickFormat=function(e,r){if(!arguments.length)return To;arguments.length<2?r=To:"function"!=typeof r&&(r=t.format(r));var a=Math.max(1,n*e/s.ticks().length);return function(t){var e=t/l(Math.round(o(t)));return e*n0?a[t-1]:r[0],tf?0:1;if(c=Lt)return s(c,p)+(l?s(l,1-p):"")+"Z";var h,g,v,y,m,x,b,_,w,k,T,M,A=0,L=0,S=[];if((y=(+o.apply(this,arguments)||0)/2)&&(v=n===Po?Math.sqrt(l*l+c*c):+n.apply(this,arguments),p||(L*=-1),c&&(L=Et(v/c*Math.sin(y))),l&&(A=Et(v/l*Math.sin(y)))),c){m=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var C=Math.abs(f-u-2*L)<=Mt?0:1;if(L&&Fo(m,x,b,_)===p^C){var O=(u+f)/2;m=c*Math.cos(O),x=c*Math.sin(O),b=_=null}}else m=x=0;if(l){w=l*Math.cos(f-A),k=l*Math.sin(f-A),T=l*Math.cos(u+A),M=l*Math.sin(u+A);var D=Math.abs(u-f+2*A)<=Mt?0:1;if(A&&Fo(w,k,T,M)===1-p^D){var P=(u+f)/2;w=l*Math.cos(P),k=l*Math.sin(P),T=M=null}}else w=k=0;if(d>kt&&(h=Math.min(Math.abs(c-l)/2,+r.apply(this,arguments)))>.001){g=l0?0:1}function jo(t,e,r,n,a){var i=t[0]-e[0],o=t[1]-e[1],l=(a?n:-n)/Math.sqrt(i*i+o*o),s=l*o,c=-l*i,u=t[0]+s,f=t[1]+c,d=e[0]+s,p=e[1]+c,h=(u+d)/2,g=(f+p)/2,v=d-u,y=p-f,m=v*v+y*y,x=r-n,b=u*p-d*f,_=(y<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-b*b)),w=(b*y-v*_)/m,k=(-b*v-y*_)/m,T=(b*y+v*_)/m,M=(-b*v+y*_)/m,A=w-h,L=k-g,S=T-h,C=M-g;return A*A+L*L>S*S+C*C&&(w=T,k=M),[[w-s,k-c],[w*r/x,k*r/x]]}function Bo(t){var e=ea,r=ra,n=Xr,a=qo,i=a.key,o=.7;function l(i){var l,s=[],c=[],u=-1,f=i.length,d=ve(e),p=ve(r);function h(){s.push("M",a(t(c),o))}for(;++u1&&a.push("H",n[0]);return a.join("")},"step-before":Uo,"step-after":Go,basis:Zo,"basis-open":function(t){if(t.length<4)return qo(t);var e,r=[],n=-1,a=t.length,i=[0],o=[0];for(;++n<3;)e=t[n],i.push(e[0]),o.push(e[1]);r.push(Wo(Qo,i)+","+Wo(Qo,o)),--n;for(;++n9&&(a=3*e/Math.sqrt(a),o[l]=a*r,o[l+1]=a*n));l=-1;for(;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+o[l]*o[l])),i.push([a||0,o[l]*a||0]);return i}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Vo(t){return t.join("L")+"Z"}function Uo(t){for(var e=0,r=t.length,n=t[0],a=[n[0],",",n[1]];++e1){l=e[1],i=t[s],s++,n+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-l[0])+","+(i[1]-l[1])+","+i[0]+","+i[1];for(var c=2;cMt)+",1 "+e}function s(t,e,r,n){return"Q 0,0 "+n}return i.radius=function(t){return arguments.length?(r=ve(t),i):r},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(n=ve(t),i):n},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Hn,e=qn,r=al;function n(n,a){var i=t.call(this,n,a),o=e.call(this,n,a),l=(i.y+o.y)/2,s=[i,{x:i.x,y:l},{x:o.x,y:l},o];return"M"+(s=s.map(r))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=al,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-St;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=ol,e=il;function r(r,n){return(sl.get(t.call(this,r,n))||ll)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var sl=t.map({circle:ll,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*ul)),r=e*ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=sl.keys();var cl=Math.sqrt(3),ul=Math.tan(30*Ct);Y.transition=function(t){for(var e,r,n=hl||++yl,a=bl(t),i=[],o=gl||{time:Date.now(),ease:ai,delay:0,duration:250},l=-1,s=this.length;++l0;)c[--d].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[n]:delete t[r],1}f||(i=a.time,o=Te(function(t){var e=f.delay;if(o.t=e+i,e<=t)return d(t-e);o.c=d},0,i),f=u[n]={tween:new b,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++u.count)}vl.call=Y.call,vl.empty=Y.empty,vl.node=Y.node,vl.size=Y.size,t.transition=function(e,r){return e&&e.transition?hl?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vl,vl.select=function(t){var e,r,n,a=this.id,i=this.namespace,o=[];t=Z(t);for(var l=-1,s=this.length;++lrect,.s>rect").attr("width",l[1]-l[0])}function g(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function v(){var f,v,y=this,m=t.select(t.event.target),x=n.of(y,arguments),b=t.select(y),_=m.datum(),w=!/^(n|s)$/.test(_)&&a,k=!/^(e|w)$/.test(_)&&i,T=m.classed("extent"),M=xt(y),A=t.mouse(y),L=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(T||(f=null,A[0]-=l[1],A[1]-=s[1],T=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==T&&(A[0]+=l[1],A[1]+=s[1],T=0,F())});if(t.event.changedTouches?L.on("touchmove.brush",O).on("touchend.brush",P):L.on("mousemove.brush",O).on("mouseup.brush",P),b.interrupt().selectAll("*").interrupt(),T)A[0]=l[0]-A[0],A[1]=s[0]-A[1];else if(_){var S=+/w$/.test(_),C=+/^n/.test(_);v=[l[1-S]-A[0],s[1-C]-A[1]],A[0]=l[S],A[1]=s[C]}else t.event.altKey&&(f=A.slice());function O(){var e=t.mouse(y),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),T||(t.event.altKey?(f||(f=[(l[0]+l[1])/2,(s[0]+s[1])/2]),A[0]=l[+(e[0]1?{floor:function(e){for(;l(e=t.floor(e));)e=zl(e-1);return e},ceil:function(e){for(;l(e=t.ceil(e));)e=zl(+e+1);return e}}:t))},a.ticks=function(t,e){var r=co(a.domain()),n=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],zl(+r[1]+1),e<1?1:e)},a.tickFormat=function(){return n},a.copy=function(){return Pl(e.copy(),r,n)},yo(a,e)}function zl(t){return new Date(t)}Sl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Dl:Ol,Dl.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Dl.toString=Ol.toString,ze.second=Ne(function(t){return new Ee(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),ze.seconds=ze.second.range,ze.seconds.utc=ze.second.utc.range,ze.minute=Ne(function(t){return new Ee(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),ze.minutes=ze.minute.range,ze.minutes.utc=ze.minute.utc.range,ze.hour=Ne(function(t){var e=t.getTimezoneOffset()/60;return new Ee(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),ze.hours=ze.hour.range,ze.hours.utc=ze.hour.utc.range,ze.month=Ne(function(t){return(t=ze.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),ze.months=ze.month.range,ze.months.utc=ze.month.utc.range;var El=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Rl=[[ze.second,1],[ze.second,5],[ze.second,15],[ze.second,30],[ze.minute,1],[ze.minute,5],[ze.minute,15],[ze.minute,30],[ze.hour,1],[ze.hour,3],[ze.hour,6],[ze.hour,12],[ze.day,1],[ze.day,2],[ze.week,1],[ze.month,1],[ze.month,3],[ze.year,1]],Il=Sl.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Xr]]),Nl={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(zl)},floor:D,ceil:D};Rl.year=ze.year,ze.scale=function(){return Pl(t.scale.linear(),Rl,Il)};var Fl=Rl.map(function(t){return[t[0].utc,t[1]]}),jl=Cl.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Xr]]);function Bl(t){return JSON.parse(t.responseText)}function Hl(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Fl.year=ze.year.utc,ze.scale.utc=function(){return Pl(t.scale.linear(),Fl,jl)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return me(t,"application/json",Bl,e)},t.html=function(t,e){return me(t,"text/html",Hl,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],9:[function(t,e,r){(function(n,a){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,l=void 0,s=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(l?l(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,d="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],16:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(l=e,l===window||l===document||l===document.body?n:l.getBoundingClientRect());var l;return r[0]=a-o.left,r[1]=i-o.top,r}},{}],17:[function(t,e,r){var n,a=t("./lib/build-log"),i=t("./lib/epsilon"),o=t("./lib/intersecter"),l=t("./lib/segment-chainer"),s=t("./lib/segment-selector"),c=t("./lib/geojson"),u=!1,f=i();function d(t,e,r){var a=n.segments(t),i=n.segments(e),o=r(n.combine(a,i));return n.polygon(o)}n={buildLog:function(t){return!0===t?u=a():!1===t&&(u=!1),!1!==u&&u.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,u);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,u).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:s.union(t.combined,u),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:s.intersect(t.combined,u),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:s.difference(t.combined,u),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:s.differenceRev(t.combined,u),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:s.xor(t.combined,u),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:l(t.segments,f,u),inverted:t.inverted}},polygonFromGeoJSON:function(t){return c.toPolygon(n,t)},polygonToGeoJSON:function(t){return c.fromPolygon(n,f,t)},union:function(t,e){return d(t,e,n.selectUnion)},intersect:function(t,e){return d(t,e,n.selectIntersect)},difference:function(t,e){return d(t,e,n.selectDifference)},differenceRev:function(t,e){return d(t,e,n.selectDifferenceRev)},xor:function(t,e){return d(t,e,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),e.exports=n},{"./lib/build-log":18,"./lib/epsilon":19,"./lib/geojson":20,"./lib/intersecter":21,"./lib/segment-chainer":23,"./lib/segment-selector":24}],18:[function(t,e,r){e.exports=function(){var t,e=0,r=!1;function n(e,r){return t.list.push({type:e,data:r?JSON.parse(JSON.stringify(r)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return n("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return n("div_seg",{seg:t,pt:e}),n("chop",{seg:t,pt:e})},statusRemove:function(t){return n("pop_seg",{seg:t})},segmentUpdate:function(t){return n("seg_update",{seg:t})},segmentNew:function(t,e){return n("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return n("rem_seg",{seg:t})},tempStatus:function(t,e,r){return n("temp_status",{seg:t,above:e,below:r})},rewind:function(t){return n("rewind",{seg:t})},status:function(t,e,r){return n("status",{seg:t,above:e,below:r})},vert:function(e){return e===r?t:(r=e,n("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),n("log",{txt:t})},reset:function(){return n("reset")},selected:function(t){return n("selected",{segs:t})},chainStart:function(t){return n("chain_start",{seg:t})},chainRemoveHead:function(t,e){return n("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return n("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return n("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return n("chain_match",{index:t})},chainClose:function(t){return n("chain_close",{index:t})},chainAddHead:function(t,e){return n("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return n("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return n("chain_con",{index1:t,index2:e})},chainReverse:function(t){return n("chain_rev",{index:t})},chainJoin:function(t,e){return n("chain_join",{index1:t,index2:e})},done:function(){return n("done")}}}},{}],19:[function(t,e,r){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,r,n){var a=r[0],i=r[1],o=n[0],l=n[1],s=e[0];return(o-a)*(e[1]-i)-(l-i)*(s-a)>=-t},pointBetween:function(e,r,n){var a=e[1]-r[1],i=n[0]-r[0],o=e[0]-r[0],l=n[1]-r[1],s=o*i+a*l;return!(s-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-a>t&&(i-c)*(a-u)/(o-u)+c-n>t&&(l=!l),i=c,o=u}return l}};return e}},{}],20:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),a=1;a0})}function u(t,n){var a=t.seg,i=n.seg,o=a.start,l=a.end,c=i.start,u=i.end;r&&r.checkIntersection(a,i);var f=e.linesIntersect(o,l,c,u);if(!1===f){if(!e.pointsCollinear(o,l,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(l,c))return!1;var d=e.pointsSame(o,c),p=e.pointsSame(l,u);if(d&&p)return n;var h=!d&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(l,c,u);if(d)return g?s(n,l):s(t,u),n;h&&(p||(g?s(n,l):s(t,u)),s(n,o))}else 0===f.alongA&&(-1===f.alongB?s(t,c):0===f.alongB?s(t,f.pt):1===f.alongB&&s(t,u)),0===f.alongB&&(-1===f.alongA?s(n,o):0===f.alongA?s(n,f.pt):1===f.alongA&&s(n,l));return!1}for(var f=[];!i.isEmpty();){var d=i.getHead();if(r&&r.vert(d.pt[0]),d.isStart){r&&r.segmentNew(d.seg,d.primary);var p=c(d),h=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(h){var t=u(d,h);if(t)return t}return!!g&&u(d,g)}r&&r.tempStatus(d.seg,!!h&&h.seg,!!g&&g.seg);var y,m,x=v();if(x)t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=d.seg.myFill,r&&r.segmentUpdate(x.seg),d.other.remove(),d.remove();if(i.getHead()!==d){r&&r.rewind(d.seg);continue}t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=g?g.seg.myFill.above:a,d.seg.myFill.above=m?!d.seg.myFill.below:d.seg.myFill.below):null===d.seg.otherFill&&(y=g?d.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:d.primary?o:a,d.seg.otherFill={above:y,below:y}),r&&r.status(d.seg,!!h&&h.seg,!!g&&g.seg),d.other.status=p.insert(n.node({ev:d}))}else{var b=d.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(l.exists(b.prev)&&l.exists(b.next)&&u(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!d.primary){var _=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=_}f.push(d.seg)}i.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,a,i,o=t[t.length-1],s=0;s1)for(var r=1;r1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=O(t,360),e=O(e,100),r=O(r,100),0===e)n=a=i=r;else{var l=r<.5?r*(1+e):r+e-r*e,s=2*r-l;n=o(s,l,t+1/3),a=o(s,l,t),i=o(s,l,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(e.h,s,u),f=!0,d="hsl"),e.hasOwnProperty("a")&&(i=e.a));var p,h,g;return i=C(i),{ok:f,format:e.format||d,r:o(255,l(a.r,0)),g:o(255,l(a.g,0)),b:o(255,l(a.b,0)),a:i}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=i(100*this._a)/100,this._format=s.format||u.format,this._gradientType=s.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=u.ok,this._tc_id=a++}function u(t,e,r){t=O(t,255),e=O(e,255),r=O(r,255);var n,a,i=l(t,e,r),s=o(t,e,r),c=(i+s)/2;if(i==s)n=a=0;else{var u=i-s;switch(a=c>.5?u/(2-i-s):u/(i+s),i){case t:n=(e-r)/u+(e>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(c(n));return i}function A(t,e){e=e||6;for(var r=c(t).toHsv(),n=r.h,a=r.s,i=r.v,o=[],l=1/e;e--;)o.push(c({h:n,s:a,v:i})),i=(i+l)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,a=this.toRgb();return e=a.r/255,r=a.g/255,n=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=C(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return d(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,a){var o=[z(i(t).toString(16)),z(i(e).toString(16)),z(i(r).toString(16)),z(R(n))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*O(this._r,255))+"%",g:i(100*O(this._g,255))+"%",b:i(100*O(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%)":"rgba("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[d(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=c(t);r="#"+p(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(T,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:E(t[n]));t=r}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:s(),g:s(),b:s()})},c.mix=function(t,e,r){r=0===r?0:r||50;var n=c(t).toRgb(),a=c(e).toRgb(),i=r/100;return c({r:(a.r-n.r)*i+n.r,g:(a.g-n.g)*i+n.g,b:(a.b-n.b)*i+n.b,a:(a.a-n.a)*i+n.a})},c.readability=function(e,r){var n=c(e),a=c(r);return(t.max(n.getLuminance(),a.getLuminance())+.05)/(t.min(n.getLuminance(),a.getLuminance())+.05)},c.isReadable=function(t,e,r){var n,a,i=c.readability(t,e);switch(a=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},c.mostReadable=function(t,e,r){var n,a,i,o,l=null,s=0;a=(r=r||{}).includeFallbackColors,i=r.level,o=r.size;for(var u=0;us&&(s=n,l=c(e[u]));return c.isReadable(t,l,{level:i,size:o})||!a?l:(r.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],r))};var L=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=c.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(L);function C(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function O(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,l(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function D(t){return o(1,l(0,t))}function P(t){return parseInt(t,16)}function z(t){return 1==t.length?"0"+t:""+t}function E(t){return t<=1&&(t=100*t+"%"),t}function R(e){return t.round(255*parseFloat(e)).toString(16)}function I(t){return P(t)/255}var N,F,j,B=(F="[\\s|\\(]+("+(N="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+N+")[,|\\s]+("+N+")\\s*\\)?",j="[\\s|\\(]+("+N+")[,|\\s]+("+N+")[,|\\s]+("+N+")[,|\\s]+("+N+")\\s*\\)?",{CSS_UNIT:new RegExp(N),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+j),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+j),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+j),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function H(t){return!!B.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],27:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],28:[function(t,e,r){"use strict";var n=t("./arrow_paths"),a=t("../../plots/font_attributes"),i=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:a({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",i.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",i.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:a({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":193,"../../plots/cartesian/constants":209,"../../plots/font_attributes":230,"./arrow_paths":27}],29:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=a.getFromId(t,e.xref),n=a.getFromId(t,e.yref);e._extremes={},r&&l(e,r),n&&l(e,n)})}function l(t,e){var r,n=e._id,i=n.charAt(0),o=t[i],l=t["a"+i],s=t[i+"ref"],c=t["a"+i+"ref"],u=t["_"+i+"padplus"],f=t["_"+i+"padminus"],d={x:1,y:-1}[i]*t[i+"shift"],p=3*t.arrowsize*t.arrowwidth||0,h=p+d,g=p-d,v=3*t.startarrowsize*t.arrowwidth||0,y=v+d,m=v-d;if(c===s){var x=a.findExtremes(e,[e.r2c(o)],{ppadplus:h,ppadminus:g}),b=a.findExtremes(e,[e.r2c(l)],{ppadplus:Math.max(u,y),ppadminus:Math.max(f,m)});r={min:[x.min[0],b.min[0]],max:[x.max[0],b.max[0]]}}else y=l?y+l:y,m=l?m-l:m,r=a.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(u,h,y),ppadminus:Math.max(f,g,m)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([i,o],t)}},{"../../lib":159,"../../plots/cartesian/axes":203,"./draw":34}],30:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,a,i,o,s,c,u=t._fullLayout.annotations,f=[],d=[],p=[],h=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,l,s=o(t,e),c=s.on,u=s.off.concat(s.explicitOff),f={},d=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var V=!1,U=["x","y"],G=0;G1)&&(K===Q?((st=tt.r2fraction(e["a"+$]))<0||st>1)&&(V=!0):V=!0),X=tt._offset+tt.r2p(e[$]),W=.5}else"x"===$?(Z=e[$],X=b.l+b.w*Z):(Z=1-e[$],X=b.t+b.h*Z),W=e.showarrow?.5:Z;if(e.showarrow){lt.head=X;var ct=e["a"+$];J=rt*q(.5,e.xanchor)-nt*q(.5,e.yanchor),K===Q?(lt.tail=tt._offset+tt.r2p(ct),Y=J):(lt.tail=X+ct,Y=J+ct),lt.text=lt.tail+J;var ut=x["x"===$?"width":"height"];if("paper"===Q&&(lt.head=o.constrain(lt.head,1,ut-1)),"pixel"===K){var ft=-Math.max(lt.tail-3,lt.text),dt=Math.min(lt.tail+3,lt.text)-ut;ft>0?(lt.tail+=ft,lt.text+=ft):dt>0&&(lt.tail-=dt,lt.text-=dt)}lt.tail+=ot,lt.head+=ot}else Y=J=at*q(W,it),lt.text=X+J;lt.text+=ot,J+=ot,Y+=ot,e["_"+$+"padplus"]=at/2+Y,e["_"+$+"padminus"]=at/2-Y,e["_"+$+"size"]=at,e["_"+$+"shift"]=J}if(t._dragging||!V){var pt=0,ht=0;if("left"!==e.align&&(pt=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(ht=(P-m)*("middle"===e.valign?.5:1)),u)n.select("svg").attr({x:I+pt-1,y:I+ht}).call(c.setClipUrl,F?A:null,t);else{var gt=I+ht-h.top,vt=I+pt-h.left;H.call(f.positionText,vt,gt).call(c.setClipUrl,F?A:null,t)}j.select("rect").call(c.setRect,I,I,w,P),N.call(c.setRect,E/2,E/2,R-E,B-E),z.call(c.setTranslate,Math.round(L.x.text-R/2),Math.round(L.y.text-B/2)),O.attr({transform:"rotate("+S+","+L.x.text+","+L.y.text+")"});var yt,mt=function(r,n){C.selectAll(".annotation-arrow-g").remove();var u=L.x.head,f=L.y.head,d=L.x.tail+r,h=L.y.tail+n,y=L.x.text+r,m=L.y.text+n,x=o.rotationXYMatrix(S,y,m),w=o.apply2DTransform(x),A=o.apply2DTransform2(x),D=+N.attr("width"),P=+N.attr("height"),E=y-.5*D,R=E+D,I=m-.5*P,F=I+P,j=[[E,I,E,F],[E,F,R,F],[R,F,R,I],[R,I,E,I]].map(A);if(!j.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){j.forEach(function(t){var e=o.segmentsIntersect(d,h,u,f,t[0],t[1],t[2],t[3]);e&&(d=e.x,h=e.y)});var B=e.arrowwidth,H=e.arrowcolor,q=e.arrowside,V=C.append("g").style({opacity:s.opacity(H)}).classed("annotation-arrow-g",!0),U=V.append("path").attr("d","M"+d+","+h+"L"+u+","+f).style("stroke-width",B+"px").call(s.stroke,s.rgb(H));if(g(U,q,e),_.annotationPosition&&U.node().parentNode&&!i){var G=u,X=f;if(e.standoff){var Y=Math.sqrt(Math.pow(u-d,2)+Math.pow(f-h,2));G+=e.standoff*(d-u)/Y,X+=e.standoff*(h-f)/Y}var Z,W,J=V.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(d-G)+","+(h-X),transform:"translate("+G+","+X+")"}).style("stroke-width",B+6+"px").call(s.stroke,"rgba(0,0,0,0)").call(s.fill,"rgba(0,0,0,0)");p.init({element:J.node(),gd:t,prepFn:function(){var t=c.getTranslate(z);Z=t.x,W=t.y,l&&l.autorange&&k(l._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(Z,W),a=n[0]+t,i=n[1]+r;z.call(c.setTranslate,a,i),T("x",l?l.p2r(l.r2p(e.x)+t):e.x+t/b.w),T("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/b.h),e.axref===e.xref&&T("ax",l.p2r(l.r2p(e.ax)+t)),e.ayref===e.yref&&T("ay",v.p2r(v.r2p(e.ay)+r)),V.attr("transform","translate("+t+","+r+")"),O.attr({transform:"rotate("+S+","+a+","+i+")"})},doneFn:function(){a.call("_guiRelayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&mt(0,0),D)p.init({element:z.node(),gd:t,prepFn:function(){yt=O.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?T("ax",l.p2r(l.r2p(e.ax)+t)):T("ax",e.ax+t),e.ayref===e.yref?T("ay",v.p2r(v.r2p(e.ay)+r)):T("ay",e.ay+r),mt(t,r);else{if(i)return;var a,o;if(l)a=l.p2r(l.r2p(e.x)+t);else{var s=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-s/2;a=p.align(c+t/b.w,s,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-r/b.h,u,0,1,e.yanchor)}T("x",a),T("y",o),l&&v||(n=p.getCursor(l?.5:a,v?.5:o,e.xanchor,e.yanchor))}O.attr({transform:"translate("+t+","+r+")"+yt}),d(z,n)},doneFn:function(){d(z),a.call("_guiRelayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else z.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,y=f.backoff*p+r.standoff,m=d.backoff*h+r.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},l={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-l.x,b=o.y-l.y;if(c=(s=Math.atan2(b,x))+Math.PI,y&&m&&y+m>Math.sqrt(x*x+b*b))return void D();if(y){if(y*y>x*x+b*b)return void D();var _=y*Math.cos(s),w=y*Math.sin(s);l.x+=_,l.y+=w,t.attr({x2:l.x,y2:l.y})}if(m){if(m*m>x*x+b*b)return void D();var k=m*Math.cos(s),T=m*Math.sin(s);o.x-=k,o.y-=T,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var M=u.getTotalLength(),A="";if(M1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+l+'"]').remove():(s._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(s.x)*r[0],e.yaxis.r2l(s.y)*r[1],e.zaxis.r2l(s.z)*r[2]]),n(t.graphDiv,s,l,t.id,s._xa,s._ya))}}},{"../../plots/gl3d/project":233,"../annotations/draw":34}],41:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var i=r.attrRegex,o=Object.keys(t),l=0;l=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var l=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+l+", "+n[3]+")":"rgb("+l+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(n(t))},i.opacity=function(t){return t?n(t).getAlpha():0},i.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},i.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var a=n(e||s).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-r.a)+r.r*r.a,g:i.g*(1-r.a)+r.g*r.a,b:i.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},i.contrast=function(t,e,r){var a=n(t);return 1!==a.getAlpha()&&(a=n(i.combine(t,s))),(a.isDark()?e?a.lighten(e):s:r?a.darken(r):l).toString()},i.stroke=function(t,e){var r=n(e);t.style({stroke:i.tinyRGB(r),"stroke-opacity":r.getAlpha()})},i.fill=function(t,e){var r=n(e);t.style({fill:i.tinyRGB(r),"fill-opacity":r.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,r,n,a,o=Object.keys(t);for(e=0;e0?S>=R:S<=R));C++)S>N&&S0?S>=R:S<=R));C++)S>O[0]&&S1){var ot=Math.pow(10,Math.floor(Math.log(it)/Math.LN10));nt*=ot*c.roundUp(it/ot,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(et.tick0=0)}et.dtick=nt}et.domain=[$+Z,$+G-Z],et.setScale();var lt=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(T.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(T.cbbg,!0),t.append("g").classed(T.cbfills,!0),t.append("g").classed(T.cblines,!0),t.append("g").classed(T.cbaxis,!0).classed(T.crisp,!0),t.append("g").classed(T.cbtitleunshift,!0).append("g").classed(T.cbtitle,!0),t.append("rect").classed(T.cboutline,!0),t.select(".cbtitle").datum(0)})});lt.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var st=lt.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")"),ct=lt.select(".cbaxis"),ut=0;if(-1!==["top","bottom"].indexOf(r.title.side)){var ft,dt=k.l+(r.x+X)*k.w,pt=et.title.font.size;ft="top"===r.title.side?(1-($+G-Z))*k.h+k.t+3+.75*pt:(1-($+Z))*k.h+k.t-3-.25*pt,xt(et._id+"title",{attributes:{x:dt,y:ft,"text-anchor":"start"}})}var ht,gt,vt,yt=c.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.title.side)){var i=lt.select(".cbtitle"),o=i.select("text"),s=[-r.outlinewidth/2,r.outlinewidth/2],u=i.select(".h"+et._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),u?(ut=d.bBox(u).height)>f&&(s[1]-=(ut-f)/2):o.node()&&!o.classed(T.jsPlaceholder)&&(ut=d.bBox(o.node()).height),ut){if(ut+=5,"top"===r.title.side)et.domain[1]-=ut/k.h,s[1]*=-1;else{et.domain[0]+=ut/k.h;var p=g.lineCount(o);s[1]+=(1-p)*f}i.attr("transform","translate("+s+")"),et.setScale()}}lt.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-et.domain[1]))+")"),ct.attr("transform","translate(0,"+Math.round(-k.t)+")");var h=lt.select(".cbfills").selectAll("rect.cbfill").data(P);h.enter().append("rect").classed(T.cbfill,!0).style("stroke","none"),h.exit().remove();var m=O.map(et.c2p).map(Math.round).sort(function(t,e){return t-e});h.each(function(i,o){var l=[0===o?O[0]:(P[o]+P[o-1])/2,o===P.length-1?O[1]:(P[o]+P[o+1])/2].map(et.c2p).map(Math.round);l[1]=c.constrain(l[1]+(l[1]>l[0])?1:-1,m[0],m[1]);var s=n.select(this).attr({x:W,width:Math.max(q,2),y:n.min(l),height:Math.max(n.max(l)-n.min(l),2)});if(r.fillgradient)d.gradient(s,t,e,"vertical",r.fillgradient,"fill");else{var u=E(i).replace("e-","");s.attr("fill",a(u).toHexString())}});var x=lt.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?D:[]);return x.enter().append("path").classed(T.cbline,!0),x.exit().remove(),x.each(function(t){n.select(this).attr("d","M"+W+","+(Math.round(et.c2p(t))+r.line.width/2%1)+"h"+q).call(d.lineGroupStyle,r.line.width,z(t),r.line.dash)}),ct.selectAll("g."+et._id+"tick,path").remove(),c.syncOrAsync([function(){var e=W+q+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),n=l.calcTicks(et),a=l.makeTransFn(et),i=l.makeLabelFns(et,e),o=l.getTickSigns(et)[2];return l.drawTicks(t,et,{vals:"inside"===et.ticks?l.clipEnds(et,n):n,layer:ct,path:l.makeTickPath(et,e,o),transFn:a}),l.drawLabels(t,et,{vals:n,layer:ct,transFn:a,labelXFn:i.labelXFn,labelYFn:i.labelYFn,labelAnchorFn:i.labelAnchorFn})},function(){if(-1===["top","bottom"].indexOf(r.title.side)){var e=et.title.font.size,a=et._offset+et._length/2,i=k.l+(et.position||0)*k.w+("right"===et.side?10+e*(et.showticklabels?1:.5):-10-e*(et.showticklabels?.5:0));xt("h"+et._id+"title",{avoid:{selection:n.select(t).selectAll("g."+et._id+"tick"),side:r.title.side,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var n=q+r.outlinewidth/2+d.bBox(ct.node()).width;if((j=st.select("text")).node()&&!j.classed(T.jsPlaceholder)){var a,o=st.select(".h"+et._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(r.title.side)?d.bBox(o).width:d.bBox(st.node()).right-W-k.l,n=Math.max(n,a)}var l=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,s=Q-K;lt.select(".cbbg").attr({x:W-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:K-Y,width:Math.max(l,2),height:Math.max(s+2*Y,2)}).call(p.fill,r.bgcolor).call(p.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),lt.selectAll(".cboutline").attr({x:W,y:K+r.ypad+("top"===r.title.side?ut:0),width:Math.max(q,2),height:Math.max(s-2*r.ypad-ut,2)}).call(p.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var c=({center:.5,right:1}[r.xanchor]||0)*l;lt.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=m[r.yanchor],h=x[r.yanchor];"pixels"===r.lenmode?(u.y=r.y,u.t=s*f,u.b=s*h):(u.t=u.b=0,u.yt=r.y+r.len*f,u.yb=r.y-r.len*h);var g=m[r.xanchor],v=x[r.xanchor];if("pixels"===r.thicknessmode)u.x=r.x,u.l=l*g,u.r=l*v;else{var y=l-q;u.l=y*g,u.r=y*v,u.xl=r.x-r.thickness*g,u.xr=r.x+r.thickness*v}i.autoMargin(t,e,u)}],t);if(yt&&yt.then&&(t._promises||[]).push(yt),t._context.edits.colorbarPosition)s.init({element:lt.node(),gd:t,prepFn:function(){ht=lt.attr("transform"),f(lt)},moveFn:function(t,e){lt.attr("transform",ht+" translate("+t+","+e+")"),gt=s.align(J+t/k.w,V,0,1,r.xanchor),vt=s.align($-e/k.h,G,0,1,r.yanchor);var n=s.getCursor(gt,vt,r.xanchor,r.yanchor);f(lt,n)},doneFn:function(){if(f(lt),void 0!==gt&&void 0!==vt){var e={};e[L("x")]=gt,e[L("y")]=vt,o.call("_guiRestyle",t,e,A().index)}}});return yt}function mt(t,e){return c.coerce(tt,et,w,t,e)}function xt(e,r){var n={propContainer:et,propName:L("title"),traceIndex:A().index,placeholder:v._dfltTitle.colorbar,containerGroup:lt.select(".cbtitle")},a="h"===e.charAt(0)?e.substr(1):"h"+e;lt.selectAll("."+a+",."+a+"-math-group").remove(),h.draw(t,e,u(n,r||{}))}v._infolayer.selectAll("g."+e).remove()}function A(){var r,n,a=e.substr(2);for(r=0;r=0?a.colorscale.sequential:a.colorscale.sequentialminus,s._colorscale=s.colorscale=h)}},{"../../lib":159}],52:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./helpers").hasColorscale;e.exports=function(t){function e(t,e){var r=t["_"+e];void 0!==r&&(t[e]=r)}function r(t,r){var a=r.container?n.nestedProperty(t,r.container).get():t;if(a){var i=a.zauto||a.cauto,o=r.min,l=r.max;(i||void 0===a[o])&&e(a,o),(i||void 0===a[l])&&e(a,l),a.autocolorscale&&e(a,"colorscale")}}for(var i=0;i=0;n--,a++){var i=t[n];r[a]=[1-i[0],i[1]]}return r}function u(t){var e={r:t[0],g:t[1],b:t[2],a:t[3]};return a(e).toRgbString()}e.exports={hasColorscale:function(t,e){var r=e?o.nestedProperty(t,e).get()||{}:t,n=r.color,a=!1;if(o.isArrayOrTypedArray(n))for(var l=0;l4/3-l?o:l}},{}],60:[function(t,e,r){"use strict";var n=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,i){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:n.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":159}],61:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),l=t("../../lib"),s=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function d(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,r,n,f,h,g,v,y,m=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;m._mouseDownTime||(m._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,r){return Math.abs(t)b&&(x=Math.max(x-1,1)),m._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!y){var r;try{r=new MouseEvent("click",e)}catch(t){var n=p(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(m),m._dragged=!1}else m._dragged=!1}},u.coverSlip=d},{"../../constants/interactions":139,"../../lib":159,"../../plots/cartesian/constants":209,"../../registry":243,"./align":59,"./cursor":60,"./unhover":62,"has-hover":12,"has-passive-events":13,"mouse-event-offset":16}],62:[function(t,e,r){"use strict";var n=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),l=e.exports={};l.wrapped=function(t,e,r){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),l.raw(t,e,r)},l.raw=function(t,e){var r=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":152,"../../lib/get_graph_div":157,"../../lib/throttle":181,"../fx/constants":76}],63:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],64:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,h=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){c.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(l.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,a){t.call(v.setPosition,e,r).call(v.setSize,n,a)},v.translatePoint=function(t,e,r,n){var i=r.c2p(t.x),o=n.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var a=n.select(this);v.translatePoint(t,a,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,a,i){e.attr("display",r.isPtWithinRange(t,a)&&n.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,l=i.ycalendar,s="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(s).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,a,o,l)})})}},v.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=r||i.width||0,s=a||i.dash||"";l.stroke(e,n||i.color),v.dashLine(e,s,o)},v.lineGroupStyle=function(t,e,r,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,s=a||i.dash||"";n.select(this).call(l.stroke,r||i.color).call(v.dashLine,s,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(l.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){var e=n.select(this);t[0].trace&&e.call(l.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var m=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=n.format("~.1f"),T={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,a,o,s){for(var u=o.length,f=T[a],d=new Array(u),p=0;p=100,e.attr("d",b(u,s))}var f,d,p,h=!1;if(t.so)p=o.outlierwidth,d=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,d="mlc"in t?t.mlcc=n.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?l.defaultLine:o.color,c.isArrayOrTypedArray(i.color)&&(f=l.defaultLine,h=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):i.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(l.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var y=i.gradient,m=t.mgt;if(m?h=!0:m=y&&y.type,Array.isArray(m)&&(m=m[0],T[m]||(m=0)),m&&"none"!==m){var x=t.mgc;x?h=!0:x=y.color;var _=r.uid;h&&(_+="-"+t.i),v.gradient(e,a,_,m,[[0,x],[1,f]],"fill")}else l.fill(e,f);p&&l.stroke(e,d)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=h.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.marker||{},i=r.marker||{},l=n.marker||{},s=a.opacity,u=i.opacity,f=l.opacity,d=void 0!==u,h=void 0!==f;(c.isArrayOrTypedArray(s)||d||h)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?d?u:e:h?f:p*e});var g=a.color,v=i.color,y=l.color;(v||y)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:y||e});var m=a.size,x=i.size,b=l.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||m/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.textfont||{},i=r.textfont||{},o=n.textfont||{},s=a.color,c=i.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||s;return t.selected?c||e:u||(c?e:l.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];r.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&i.push(function(t,e){l.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&i.push(function(t,e){var n=e.mx||a.symbol||0,i=r.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(n),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=n.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var l=t.tp||e.textposition,s=L(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,s,f).text(o).call(u.convertToTspans,r).call(A,l,s,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=n.select(this),i=r.selectedTextColorFn(t),o=t.tp||e.textposition,s=L(t,e);l.fill(a,i),A(a,o,s,t.mrc2||t.mrc)})}};var S=.5;function C(t,e,r,a){var i=t[0]-e[0],o=t[1]-e[1],l=r[0]-e[0],s=r[1]-e[1],c=Math.pow(i*i+o*o,S/2),u=Math.pow(l*l+s*s,S/2),f=(u*u*i-c*c*l)*a,d=(u*u*o-c*c*s)*a,p=3*u*(c+u),h=3*c*(c+u);return[[n.round(e[0]+(p&&f/p),2),n.round(e[1]+(p&&d/p),2)],[n.round(e[0]-(h&&f/h),2),n.round(e[1]-(h&&d/h),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],a=[];for(r=1;r=1e4&&(v.savedBBoxes={},P=0),r&&(v.savedBBoxes[r]=y),P++,c.extendFlat({},y)},v.setClipUrl=function(t,e,r){if(e){var n=r._context,a=n._exportedPlot?"":n._baseUrl||"";t.attr("clip-path","url("+a+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||0,r=r||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+r+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||1,r=r||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+r+")").trim(),t[a]("transform",i),i};var E=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(E,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var R=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,a=n.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),l=parseFloat(i.attr("y")||0),s=(a.attr("transform")||"").match(R);t=1===e&&1===r?[]:["translate("+o+","+l+")","scale("+e+","+r+")","translate("+-o+","+-l+")"],s&&t.push(s),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":138,"../../constants/interactions":139,"../../constants/xmlns_namespaces":141,"../../lib":159,"../../lib/svg_text_utils":180,"../../registry":243,"../../traces/scatter/make_bubble_size_func":298,"../../traces/scatter/subtypes":305,"../color":43,"../colorscale":55,"./symbol_defs":65,d3:8,"fast-isnumeric":10,tinycolor2:26}],65:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+a+i+a+i+o+i+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),a=n.round(-t,2),i=n.round(-.309*t,2);return"M"+e+","+i+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+r+"V"+r+"L0,"+e+"L-"+a+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+a+"H"+r+"L"+e+",0L"+r+",-"+a+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),a=n.round(.951*e,2),i=n.round(.363*e,2),o=n.round(.588*e,2),l=n.round(-e,2),s=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+s+"H"+a+"L"+i+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+i+","+c+"L-"+a+","+s+"H-"+r+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),a=n.round(.76*t,2);return"M-"+a+",0l-"+r+",-"+e+"h"+a+"l"+r+",-"+e+"l"+r+","+e+"h"+a+"l-"+r+","+e+"l"+r+","+e+"h-"+a+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+a+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+a+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:8}],66:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],67:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function l(t,e,r,a){var l=e["error_"+a]||{},s=[];if(l.visible&&-1!==["linear","log"].indexOf(r.type)){for(var c=o(l),u=0;u0;e.each(function(e){var f,d=e[0].trace,p=d.error_x||{},h=d.error_y||{};d.ids&&(f=function(t){return t.id});var g=o.hasMarkers(d)&&d.marker.maxdisplayed>0;h.visible||p.visible||(e=[]);var v=n.select(this).selectAll("g.errorbar").data(e,f);if(v.exit().remove(),e.length){p.visible||v.selectAll("path.xerror").remove(),h.visible||v.selectAll("path.yerror").remove(),v.style("opacity",1);var y=v.enter().append("g").classed("errorbar",!0);u&&y.style("opacity",0).transition().duration(l.duration).style("opacity",1),i.setClipUrl(v,r.layerClipId,t),v.each(function(t){var e=n.select(this),r=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,s,c);if(!g||t.vis){var i,o=e.select("path.yerror");if(h.visible&&a(r.x)&&a(r.yh)&&a(r.ys)){var f=h.width;i="M"+(r.x-f)+","+r.yh+"h"+2*f+"m-"+f+",0V"+r.ys,r.noYS||(i+="m-"+f+",0h"+2*f),!o.size()?o=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):u&&(o=o.transition().duration(l.duration).ease(l.easing)),o.attr("d",i)}else o.remove();var d=e.select("path.xerror");if(p.visible&&a(r.y)&&a(r.xh)&&a(r.xs)){var v=(p.copy_ystyle?h:p).width;i="M"+r.xh+","+(r.y-v)+"v"+2*v+"m0,-"+v+"H"+r.xs,r.noXS||(i+="m0,-"+v+"v"+2*v),!d.size()?d=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):u&&(d=d.transition().duration(l.duration).ease(l.easing)),d.attr("d",i)}else d.remove()}})}})}},{"../../traces/scatter/subtypes":305,"../drawing":64,d3:8,"fast-isnumeric":10}],72:[function(t,e,r){"use strict";var n=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},i=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(a.stroke,r.color),i.copy_ystyle&&(i=r),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":43,d3:8}],73:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":230}],74:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry");function i(t,e,r,a){a=a||n.identity,Array.isArray(t)&&(e[0][r]=a(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var l=0;l=0&&r.indexw[0]._length||et<0||et>k[0]._length)return d.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,R="xval"in e?g.flat(s,e.xval):g.p2c(w,tt),I="yval"in e?g.flat(s,e.yval):g.p2c(k,et),!a(R[0])||!a(I[0]))return o.warn("Fx.hover failed",e,t),d.unhoverRaw(t,e)}var at=1/0;for(F=0;F<$.length;F++)if((j=$[F])&&j[0]&&j[0].trace&&!0===j[0].trace.visible&&(B=j[0].trace,-1===["carpet","contourcarpet"].indexOf(B._module.name))){if("splom"===B.type?H=s[q=0]:(H=g.getSubplot(B),q=s.indexOf(H)),V=E,X={cd:j,trace:B,xa:w[q],ya:k[q],maxHoverDistance:Z,maxSpikeDistance:W,index:!1,distance:Math.min(at,Z),spikeDistance:1/0,xSpike:void 0,ySpike:void 0,color:f.defaultLine,name:B.name,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},u[H]&&(X.subplot=u[H]._subplot),u._splomScenes&&u._splomScenes[B.uid]&&(X.scene=u._splomScenes[B.uid]),Y=J.length,"array"===V){var it=e[F];"pointNumber"in it?(X.index=it.pointNumber,V="closest"):(V="","xval"in it&&(U=it.xval,V="x"),"yval"in it&&(G=it.yval,V=V?"closest":"y"))}else U=R[q],G=I[q];if(0!==Z)if(B._module&&B._module.hoverPoints){var ot=B._module.hoverPoints(X,U,G,V,u._hoverlayer);if(ot)for(var lt,st=0;stY&&(J.splice(0,Y),at=J[0].distance),m&&0!==W&&0===J.length){X.distance=W,X.index=!1;var ct=B._module.hoverPoints(X,U,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=W})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var dt=ft[0];a(dt.x0)&&a(dt.y0)&&(ut=vt(dt),(!Q.vLinePoint||Q.vLinePoint.spikeDistance>ut.spikeDistance)&&(Q.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var ht=pt[0];a(ht.x0)&&a(ht.y0)&&(ut=vt(ht),(!Q.hLinePoint||Q.hLinePoint.spikeDistance>ut.spikeDistance)&&(Q.hLinePoint=ut))}}}}function gt(t,e){for(var r,n=null,a=1/0,i=0;i1||J.length>1)||"closest"===E&&K&&J.length>1,Dt=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),Pt={hovermode:E,rotateLabels:Ot,bgColor:Dt,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},zt=M(J,Pt,t);if(function(t,e,r){var n,a,i,o,l,s,c,u=0,f=1,d=t.map(function(t,n){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!n&&o&&o[0]>o[1]!==i&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?x:1)/2,pmin:0,pmax:i?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],r=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=r.pos+r.dp+r.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;n=!1}if(!(i<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=i;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos>e.pmax-1&&(s.del=!0,c--);for(o=0;o=0;l--)t[l].dp-=i;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(;!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&v.pmin===y.pmin&&v.pmax===y.pmax){for(l=g.length-1;l>=0;l--)g[l].dp+=a;for(h.push.apply(h,g),d.splice(o+1,1),c=0,l=h.length-1;l>=0;l--)c+=h[l].dp;for(i=c/h.length,l=h.length-1;l>=0;l--)h[l].dp-=i;n=!1}else o++}d.forEach(p)}for(o=d.length-1;o>=0;o--){var m=d[o];for(l=m.length-1;l>=0;l--){var b=m[l],_=t[b.i];_.offset=b.dp,_.del=b.del}}}(J,Ot?"xa":"ya",u),A(zt,Ot),e.target&&e.target.tagName){var Et=h.getComponentMethod("annotations","hasClickToShow")(t,At);c(n.select(e.target),Et?"pointer":"")}if(!e.target||i||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var a=r[n],i=t._hoverdata[n];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber)||String(a.pointNumbers)!==String(i.pointNumbers))return!0}return!1}(t,0,Mt))return;Mt&&t.emit("plotly_unhover",{event:e,points:Mt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:R,yvals:I})}(t,e,r,i)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1},a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M([r],o,e.gd);return A(l,o.rotateLabels),l.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1}}),a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M(r,o,e.gd),s=0;return l.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5([\s\S]*)<\/extra>/;function M(t,e,r){var a=e.hovermode,i=e.rotateLabels,l=e.bgColor,c=e.container,d=e.outerContainer,p=e.commonLabelOpts||{},h=e.fontFamily||v.HOVERFONT,g=e.fontSize||v.HOVERFONTSIZE,m=t[0],x=m.xa,b=m.ya,_="y"===a?"yLabel":"xLabel",M=m[_],A=(String(M)||"").split(" ")[0],L=d.node().getBoundingClientRect(),S=L.top,C=L.width,O=L.height,D=void 0!==M&&m.distance<=e.hoverdistance&&("x"===a||"y"===a);if(D){var P,z,E=!0;for(P=0;P-1&&c.length>b&&(c=b>3?c.substr(0,b-3)+"...":c.substr(0,b))}void 0!==t.zLabel?(void 0!==t.xLabel&&(d+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(d+="y: "+t.yLabel+"
"),d+=(d?"z: ":"")+t.zLabel):D&&t[a+"Label"]===M?d=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(d=t.yLabel):d=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(d+=(d?"
":"")+t.text),void 0!==t.extraText&&(d+=(d?"
":"")+t.extraText),""===d&&(""===c&&e.remove(),d=c);var _=t.hovertemplate||!1,A=t.hovertemplateLabels||t,L=t.eventData[0]||{};_&&(d=(d=o.hovertemplateString(_,A,L)).replace(T,function(t,e){return c=e,""}));var P=e.select("text.nums").call(u.font,t.fontFamily||h,t.fontSize||g,t.fontColor||x).text(d).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),z=e.select("text.name"),E=0;c&&c!==d?(z.call(u.font,t.fontFamily||h,t.fontSize||g,m).text(c).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),E=z.node().getBoundingClientRect().width+2*k):(z.remove(),e.select("rect").remove()),e.select("path").style({fill:v,stroke:x});var R,I,N=P.node().getBoundingClientRect(),F=t.xa._offset+(t.x0+t.x1)/2,j=t.ya._offset+(t.y0+t.y1)/2,B=Math.abs(t.x1-t.x0),H=Math.abs(t.y1-t.y0),q=N.width+w+k+E;t.ty0=S-N.top,t.bx=N.width+2*k,t.by=N.height+2*k,t.anchor="start",t.txwidth=N.width,t.tx2width=E,t.offset=0,i?(t.pos=F,R=j+H/2+q<=O,I=j-H/2-q>=0,"top"!==t.idealAlign&&R||!I?R?(j+=H/2,t.anchor="start"):t.anchor="middle":(j-=H/2,t.anchor="end")):(t.pos=j,R=F+B/2+q<=C,I=F-B/2-q>=0,"left"!==t.idealAlign&&R||!I?R?(F+=B/2,t.anchor="start"):t.anchor="middle":(F-=B/2,t.anchor="end")),P.attr("text-anchor",t.anchor),E&&z.attr("text-anchor",t.anchor),e.attr("transform","translate("+F+","+j+")"+(i?"rotate("+y+")":""))}),N}function A(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var a="end"===t.anchor?-1:1,i=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],l=o*(w+k),c=l+o*(t.txwidth+k),f=0,d=t.offset;"middle"===t.anchor&&(l-=t.tx2width/2,c+=t.txwidth/2+k),e&&(d*=-_,f=t.offset*b),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(d-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+d)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(d-w)+"Z"),i.call(s.positionText,l+f,d+t.ty0-t.by/2+k),t.tx2width&&(r.select("text.name").call(s.positionText,c+o*k+f,d+t.ty0-t.by/2+k),r.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,d-t.by/2-1,t.tx2width,t.by+2))}})}function L(t,e){var r=t.index,n=t.trace||{},a=t.cd[0],i=t.cd[r]||{},l=Array.isArray(r)?function(t,e){return o.castOption(a,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(i,n,t,e)};function s(e,r,n){var a=l(r,n);a&&(t[e]=a)}if(s("hoverinfo","hi","hoverinfo"),s("bgcolor","hbg","hoverlabel.bgcolor"),s("borderColor","hbc","hoverlabel.bordercolor"),s("fontFamily","htf","hoverlabel.font.family"),s("fontSize","hts","hoverlabel.font.size"),s("fontColor","htc","hoverlabel.font.color"),s("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return f&&"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function S(t,e){var r,n,a=e.container,o=e.fullLayout,l=e.event,s=!!t.hLinePoint,c=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),c||s){var d=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(s){var p,h,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(p=l.pointerX,h=l.pointerY):(p=r._offset+g.x,h=n._offset+g.y);var v,y,m=i.readability(g.color,d)<1.5?f.contrast(d):g.color,x=n.spikemode,b=n.spikethickness,_=n.spikecolor||m,w=n._boundingBox,k=(w.left+w.right)/20){for(var n=[],a=0;a-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){d||p||h||"independent"===T("pattern")&&(d=!0),v._hasSubplotGrid=d;var x,b,_="top to bottom"===T("roworder"),w=d?.2:.1,k=d?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",T,w,x,m),y:u("y",T,k,b,y,_)}}else delete e.grid}function T(t,e){return n.coerce(r,v,s,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,a,i,o,l,s,u,d=t.grid||{},p=e._subplots,h=r._hasSubplotGrid,g=r.rows,v=r.columns,y="independent"===r.pattern,m=r._axisMap={};if(h){var x=d.subplots||[];s=r.subplots=new Array(g);var b=1;for(n=0;n1);if(!1!==x||p.uirevision){var b=i.newContainer(e,"legend");if(w("uirevision",e.uirevision),!1!==x){if(w("bgcolor",e.paper_bgcolor),w("bordercolor"),w("borderwidth"),a.coerceFont(w,"font",e.font),w("orientation"),"h"===b.orientation){var _=t.xaxis;n.getComponentMethod("rangeslider","isVisible")(_)?(c=0,f="left",u=1.1,d="bottom"):(c=0,f="left",u=-.1,d="top")}w("traceorder",v),s.isGrouped(e.legend)&&w("tracegroupgap"),w("x",c),w("xanchor",f),w("y",u),w("yanchor",d),w("valign"),a.noneOrAll(p,b,["x","y"])}}function w(t,e){return a.coerce(p,b,o,t,e)}}},{"../../lib":159,"../../plot_api/plot_template":193,"../../plots/layout_attributes":234,"../../registry":243,"./attributes":92,"./helpers":98}],95:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib/events"),s=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),d=t("./handle_click"),p=t("./constants"),h=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,y=g.FROM_TL,m=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=h.DBLCLICKDELAY;function k(t,e,r,n,a){var i=r.data()[0][0].trace,o={event:a,node:r.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=r.datum()[0].label),!1!==l.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){d(r,t,n)},w);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==l.triggerHandler(t,"plotly_legenddoubleclick",o)&&d(r,t,n)}}function T(t,e,r){var n=t.data()[0][0],i=e._fullLayout,l=n.trace,s=o.traceIs(l,"pie"),u=l.index,d=s?n.label:l.name,h=e._context.edits.legendText&&!s,g=a.ensureSingle(t,"text","legendtext");function y(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,a,i=t.select("g[class*=math-group]"),o=i.node(),l=e._fullLayout.legend.font.size*v;if(o){var s=c.bBox(o);n=s.height,a=s.width,c.setTranslate(i,0,n/4)}else{var u=t.select(".legendtext"),d=f.lineCount(u),h=u.node();n=l*d,a=h?c.bBox(h).width:0;var g=l*(.3+(1-d)/2);f.positionText(u,p.textOffsetX,g),r.lineHeight=l}n=Math.max(n,16)+3,r.height=n,r.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,i.legend.font).text(h?M(d,r):d),f.positionText(g,p.textOffsetX,0),h?g.call(f.makeEditable,{gd:e,text:d}).call(y).on("edit",function(t){this.text(M(t,r)).call(y);var i=n.trace._fullInput||{},l={};if(o.hasTransform(i,"groupby")){var s=o.getTransformIndices(i,"groupby"),c=s[s.length-1],f=a.keyedContainer(i,"transforms["+c+"].styles","target","value.name");f.set(n.trace._group,t),l=f.constructUpdate()}else l.name=t;return o.call("_guiRestyle",e,l,u)}):y(g)}function M(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function A(t,e){var r,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimew&&(i=Math.max(i-1,1)),k(e,r,t,i,n.event)}})}function L(t,e,r){var a=t._fullLayout,i=a.legend,o=i.borderwidth,l=_.isGrouped(i),s=0;if(i._width=0,i._height=0,_.isVertical(i))l&&e.each(function(t,e){c.setTranslate(this,0,e*i.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;c.setTranslate(this,o,5+o+i._height+r/2),i._height+=r,i._width=Math.max(i._width,n)}),i._width+=45+2*o,i._height+=10+2*o,l&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),s=40;else if(l){for(var u=[i._width],f=e.data(),d=0,p=f.length;do+w-k,r.each(function(t){var e=t[0],r=v?40+t[0].width:x;o+b+k+r>a._size.w&&(b=0,y+=m,i._height=i._height+m,m=0),c.setTranslate(this,o+b,5+o+e.height/2+y),i._width+=k+r,i._height=Math.max(i._height,e.height),b+=k+r,m=Math.max(e.height,m)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var T=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");c.setRect(r,0,-e.height/2,(T?0:i._width)+s,e.height)})}function S(t){var e=t._fullLayout.legend,r="left";a.isRightAnchor(e)?r="right":a.isCenterAnchor(e)&&(r="center");var n="top";a.isBottomAnchor(e)?n="bottom":a.isMiddleAnchor(e)&&(n="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[r],r:e._width*m[r],b:e._height*m[n],t:e._height*y[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var l=e.legend,f=e.showlegend&&x(t.calcdata,l),d=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void i.autoMargin(t,"legend");for(var h=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";a.isRightAnchor(e)?r="right":a.isCenterAnchor(e)&&(r="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[r],r:e._width*m[r],b:0,t:0})}(t):S(t);var d=e._size,h=d.l+d.w*l.x,g=d.t+d.h*(1-l.y);a.isRightAnchor(l)?h-=l._width:a.isCenterAnchor(l)&&(h-=l._width/2),a.isBottomAnchor(l)?g-=l._height:a.isMiddleAnchor(l)&&(g-=l._height/2);var v=l._width,x=d.w;v>x?(h=d.l,v=x):(h+v>u&&(h=u-v),h<0&&(h=0),v=Math.min(u-h,l._width));var b,_,w,T,M=l._height,A=d.h;if(M>A?(g=d.t,M=A):(g+M>f&&(g=f-M),g<0&&(g=0),M=Math.min(f-g,l._height)),c.setTranslate(O,h,g),E.on(".drag",null),O.on("wheel",null),l._height<=M||t._context.staticPlot)P.attr({width:v-l.borderwidth,height:M-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),c.setTranslate(z,0,0),D.select("rect").attr({width:v-2*l.borderwidth,height:M-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth}),c.setClipUrl(z,r,t),c.setRect(E,0,0,0,0),delete l._scrollY;else{var N,F,j=Math.max(p.scrollBarMinHeight,M*M/l._height),B=M-j-2*p.scrollBarMargin,H=l._height-M,q=B/H,V=Math.min(l._scrollY||0,H);P.attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:M-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),D.select("rect").attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:M-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth+V}),c.setClipUrl(z,r,t),G(V,j,q),O.on("wheel",function(){G(V=a.constrain(l._scrollY+n.event.deltaY/B*H,0,H),j,q),0!==V&&V!==H&&n.event.preventDefault()});var U=n.behavior.drag().on("dragstart",function(){N=n.event.sourceEvent.clientY,F=V}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||G(V=a.constrain((t.clientY-N)/q+F,0,H),j,q)});E.call(U)}function G(e,r,n){l._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(z,0,-e),c.setRect(E,v,p.scrollBarMargin+e*n,p.scrollBarWidth,r),D.select("rect").attr({y:l.borderwidth+e})}t._context.edits.legendPosition&&(O.classed("cursor-move",!0),s.init({element:O.node(),gd:t,prepFn:function(){var t=c.getTranslate(O);w=t.x,T=t.y},moveFn:function(t,e){var r=w+t,n=T+e;c.setTranslate(O,r,n),b=s.align(r,0,d.l,d.l+d.w,l.xanchor),_=s.align(n,0,d.t+d.h,d.t,l.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("_guiRelayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(r,n){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});a.size()>0&&k(t,O,a,r,n)}}))}],t)}}},{"../../constants/alignment":138,"../../constants/interactions":139,"../../lib":159,"../../lib/events":152,"../../lib/svg_text_utils":180,"../../plots/plots":236,"../../registry":243,"../color":43,"../dragelement":61,"../drawing":64,"./constants":93,"./get_legend_data":96,"./handle_click":97,"./helpers":98,"./style":100,d3:8}],96:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var r,i,o={},l=[],s=!1,c={},u=0;function f(t,r){if(""!==t&&a.isGrouped(e))-1===l.indexOf(t)?(l.push(t),s=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+u;l.push(n),o[n]=[[r]],u++}}for(r=0;rr[1])return r[1]}return a}function h(t){return t[0]}if(u||f||d){var g={},v={};if(u){g.mc=p("marker.color",h),g.mx=p("marker.symbol",h),g.mo=p("marker.opacity",i.mean,[.2,1]),g.mlc=p("marker.line.color",h),g.mlw=p("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=p("marker.size",i.mean,[2,16]);g.ms=y,v.marker.size=y}d&&(v.line={width:p("line.width",h,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",h),g.ts=10,g.tc=p("textfont.color",h),g.tf=p("textfont.family",h)),r=[i.minExtend(l,g)],(a=i.minExtend(c,v)).selectedpoints=null}var m=n.select(this).select("g.legendpoints"),x=m.selectAll("path.scatterpts").data(u?r:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,a,e),u&&(r[0].mrc=3);var b=m.selectAll("g.pointtext").data(f?r:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,o=n.select(this);o.style("stroke-width",i+"px").call(l.fill,a.fillcolor),i&&l.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,s=n.select(this);s.style("fill","none").call(o.dashLine,a.line.dash,i),i&&l.stroke(s,a.line.color)})})}},{"../../lib":159,"../../registry":243,"../../traces/pie/style_one":279,"../../traces/scatter/subtypes":305,"../color":43,"../drawing":64,d3:8}],101:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),l=t("../../../build/ploticon"),s=o._,c=e.exports={};function u(t,e){var r,a,o=e.currentTarget,l=o.getAttribute("data-attr"),s=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=i.list(t,null,!0),d="on";if("zoom"===l){var p,h="in"===s?.5:2,g=(1+h)/2,v=(1-h)/2;for(a=0;a1?(k=["toggleHover"],T=["resetViews"]):d?(w=["zoomInGeo","zoomOutGeo"],k=["hoverClosestGeo"],T=["resetGeo"]):f?(k=["hoverClosest3d"],T=["resetCameraDefault3d","resetCameraLastSave3d"]):v?(k=["toggleHover"],T=["resetViewMapbox"]):k=h?["hoverClosestGl2d"]:p?["hoverClosestPie"]:["toggleHover"];u&&(k=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!u&&!h||m||(w=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==T[0]&&(T=["resetScale2d"]));f?M=["zoom3d","pan3d","orbitRotation","tableRotation"]:(u||h)&&!m||g?M=["zoom2d","pan2d"]:v||d?M=["pan2d"]:y&&(M=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),a=0,i=0;i0?d+c:c;return{ppad:c,ppadplus:u?h:g,ppadminus:u?g:h}}return{ppad:c}}function u(t,e,r,n,a){var l="category"===t.type||"multicategory"===t.type?t.r2c:t.d2c;if(void 0!==e)return[l(e),l(r)];if(n){var s,c,u,f,d=1/0,p=-1/0,h=n.match(i.segmentRE);for("date"===t.type&&(l=o.decodeDate(l)),s=0;sp&&(p=f)));return p>=d?[d,p]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:R?V(r.xanchor)+r.x0:V(r.x0),cy:I?U(r.yanchor)-r.y0:U(r.y0),r:i}).style(a).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:R?V(r.xanchor)+r.x1:V(r.x1),cy:I?U(r.yanchor)-r.y1:U(r.y1),r:i}).style(a).classed("cursor-grab",!0),n}():e,Z={element:Y.node(),gd:t,prepFn:function(n){R&&(_=V(r.xanchor));I&&(w=U(r.yanchor));"path"===r.type?D=r.path:(y=R?r.x0:V(r.x0),m=I?r.y0:U(r.y0),x=R?r.x1:V(r.x1),b=I?r.y1:U(r.y1));yb?(k=m,L="y0",T=b,S="y1"):(k=b,L="y1",T=m,S="y0");W(n),Q(p,r),function(t,e,r){var n=e.xref,a=e.yref,o=i.getFromId(r,n),s=i.getFromId(r,a),c="";"paper"===n||o.autorange||(c+=n);"paper"===a||s.autorange||(c+=a);l.setClipUrl(t,c?"clip"+r._fullLayout._uid+c:null,r)}(e,r,t),Z.moveFn="move"===P?J:$},doneFn:function(){u(e),K(p),h(e,t,r),n.call("_guiRelayout",t,j.getUpdateObj())},clickFn:function(){K(p)}};function W(t){if(N)P="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Z.element.getBoundingClientRect(),n=r.right-r.left,a=r.bottom-r.top,i=t.clientX-r.left,o=t.clientY-r.top,l=!F&&n>z&&a>E&&!t.shiftKey?c.getCursor(i/n,1-o/a):"move";u(e,l),P=l.split("-")[0]}}function J(n,a){if("path"===r.type){var i=function(t){return t},o=i,l=i;R?B("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),I?B("yanchor",r.yanchor=X(w+a)):(l=function(t){return X(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),B("path",r.path=v(D,o,l))}else R?B("xanchor",r.xanchor=G(_+n)):(B("x0",r.x0=G(y+n)),B("x1",r.x1=G(x+n))),I?B("yanchor",r.yanchor=X(w+a)):(B("y0",r.y0=X(m+a)),B("y1",r.y1=X(b+a)));e.attr("d",g(t,r)),Q(p,r)}function $(n,a){if(F){var i=function(t){return t},o=i,l=i;R?B("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),I?B("yanchor",r.yanchor=X(w+a)):(l=function(t){return X(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),B("path",r.path=v(D,o,l))}else if(N){if("resize-over-start-point"===P){var s=y+n,c=I?m-a:m+a;B("x0",r.x0=R?s:G(s)),B("y0",r.y0=I?c:X(c))}else if("resize-over-end-point"===P){var u=x+n,f=I?b-a:b+a;B("x1",r.x1=R?u:G(u)),B("y1",r.y1=I?f:X(f))}}else{var h=~P.indexOf("n")?k+a:k,j=~P.indexOf("s")?T+a:T,Y=~P.indexOf("w")?M+n:M,Z=~P.indexOf("e")?A+n:A;~P.indexOf("n")&&I&&(h=k-a),~P.indexOf("s")&&I&&(j=T-a),(!I&&j-h>E||I&&h-j>E)&&(B(L,r[L]=I?h:X(h)),B(S,r[S]=I?j:X(j))),Z-Y>z&&(B(C,r[C]=R?Y:G(Y)),B(O,r[O]=R?Z:G(Z)))}e.attr("d",g(t,r)),Q(p,r)}function Q(t,e){(R||I)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=V(R?e.xanchor:a.midRange(r?[e.x0,e.x1]:d.extractPathCoords(e.path,f.paramIsX))),o=U(I?e.yanchor:a.midRange(r?[e.y0,e.y1]:d.extractPathCoords(e.path,f.paramIsY)));if(i=d.roundPositionForSharpStrokeRendering(i,1),o=d.roundPositionForSharpStrokeRendering(o,1),R&&I){var l="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",l)}else if(R){var s="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",s)}else{var c="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",c)}}()}function K(t){t.selectAll(".visual-cue").remove()}c.init(Z),Y.node().onmousemove=W}(t,x,r,e,p)}}function h(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");l.setClipUrl(t,n?"clip"+e._fullLayout._uid+n:null,e)}function g(t,e){var r,n,o,l,s,c,u,p,h=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),y=t._fullLayout._size;if(g?(r=d.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return y.l+y.w*t},v?(o=d.shapePositionToRange(v),l=function(t){return v._offset+v.r2p(o(t,!0))}):l=function(t){return y.t+y.h*(1-t)},"path"===h)return g&&"date"===g.type&&(n=d.decodeDate(n)),v&&"date"===v.type&&(l=d.decodeDate(l)),function(t,e,r){var n=t.path,i=t.xsizemode,o=t.ysizemode,l=t.xanchor,s=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,c=t.charAt(0),u=f.paramIsX[c],d=f.paramIsY[c],p=f.numParams[c],h=t.substr(1).replace(f.paramRE,function(t){return u[n]?t="pixel"===i?e(l)+Number(t):e(t):d[n]&&(t="pixel"===o?r(s)-Number(t):r(t)),++n>p&&(t="X"),t});return n>p&&(h=h.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),c+h})}(e,n,l);if("pixel"===e.xsizemode){var m=n(e.xanchor);s=m+e.x0,c=m+e.x1}else s=n(e.x0),c=n(e.x1);if("pixel"===e.ysizemode){var x=l(e.yanchor);u=x-e.y0,p=x-e.y1}else u=l(e.y0),p=l(e.y1);if("line"===h)return"M"+s+","+u+"L"+c+","+p;if("rect"===h)return"M"+s+","+u+"H"+c+"V"+p+"H"+s+"Z";var b=(s+c)/2,_=(u+p)/2,w=Math.abs(b-s),k=Math.abs(_-u),T="A"+w+","+k,M=b+w+","+_;return"M"+M+T+" 0 1,1 "+(b+","+(_-k))+T+" 0 0,1 "+M+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],l=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return n>=l?t:(i[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var a=0;a0&&(l=l.transition().duration(e.transition.duration).ease(e.transition.easing)),l.attr("transform","translate("+(o-.5*u.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function L(t,e){var r=t._dims;return r.inputAreaStart+u.stepInset+(r.inputAreaLength-2*u.stepInset)*Math.min(1,Math.max(0,e))}function S(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-u.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*u.stepInset-2*r.inputAreaStart)))}function C(t,e,r){var n=r._dims,a=l.ensureSingle(t,"rect",u.railTouchRectClass,function(n){n.call(T,e,t,r).style("pointer-events","all")});a.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,u.tickOffset+r.ticklen+n.labelHeight)}).call(i.fill,r.bgcolor).attr("opacity",0),o.setTranslate(a,0,n.currentValueTotalHeight)}function O(t,e){var r=e._dims,n=r.inputAreaLength-2*u.railInset,a=l.ensureSingle(t,"rect",u.railRectClass);a.attr({width:n,height:u.railWidth,rx:u.railRadius,ry:u.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,u.railInset,.5*(r.inputAreaWidth-u.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[u.name],n=[],a=0;a0?[0]:[]);function l(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,g(e))}if(i.enter().append("g").classed(u.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){n.select(this).selectAll("g."+u.groupClassName).each(l)}).remove(),0!==r.length){var s=i.selectAll("g."+u.groupClassName).data(r,v);s.enter().append("g").classed(u.groupClassName,!0),s.exit().each(l).remove();for(var c=0;c0||d<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[m.side];e.attr("transform","translate("+g+")")}}}z.call(E),D&&(A?z.on(".opacity",null):(k=0,T=!0,z.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),z.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("_guiRestyle",t,g,e,y):o.call("_guiRelayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(E)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return z.classed("js-placeholder",T),_}};var d=/ [XY][0-9]* /},{"../../constants/interactions":139,"../../lib":159,"../../lib/svg_text_utils":180,"../../plots/plots":236,"../../registry":243,"../color":43,"../drawing":64,d3:8,"fast-isnumeric":10}],132:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,l=t("../../plots/pad_attributes"),s=t("../../plot_api/plot_template").templatedArray,c=s("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(s("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i(l({editType:"arraydraw"}),{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":153,"../../plot_api/edit_types":186,"../../plot_api/plot_template":193,"../../plots/font_attributes":230,"../../plots/pad_attributes":235,"../color/attributes":42}],133:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],134:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,l=i.buttons;function s(t,e,r){function o(r,a){return n.coerce(t,e,i,r,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function r(r,a){return n.coerce(t,e,l,r,a)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:s})}},{"../../lib":159,"../../plots/array_container_defaults":199,"./attributes":132,"./constants":133}],135:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../plot_api/plot_template").arrayEditor,u=t("../../constants/alignment").LINE_SPACING,f=t("./constants"),d=t("./scrollbox");function p(t){return t._index}function h(t,e){return+t.attr(f.menuIndexAttrName)===e._index}function g(t,e,r,n,a,i,o,l){e.active=o,c(t.layout,f.name,e).applyUpdate("active",o),"buttons"===e.type?y(t,n,null,null,e):"dropdown"===e.type&&(a.attr(f.menuIndexAttrName,"-1"),v(t,n,a,i,e),l||y(t,n,a,i,e))}function v(t,e,r,n,a){var i=l.ensureSingle(e,"g",f.headerClassName,function(t){t.style("pointer-events","all")}),s=a._dims,c=a.active,u=a.buttons[c]||f.blankHeaderOpts,d={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},p={width:s.headerWidth,height:s.headerHeight};i.call(m,a,u,t).call(A,a,d,p),l.ensureSingle(e,"text",f.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(f.arrowSymbol[a.direction])}).attr({x:s.headerWidth-f.arrowOffsetX+a.pad.l,y:s.headerHeight/2+f.textOffsetY+a.pad.t}),i.on("click",function(){r.call(L,String(h(r,a)?-1:a._index)),y(t,e,r,n,a)}),i.on("mouseover",function(){i.call(w)}),i.on("mouseout",function(){i.call(k,a)}),o.setTranslate(e,s.lx,s.ly)}function y(t,e,r,i,o){r||(r=e).attr("pointer-events","all");var s=function(t){return-1==+t.attr(f.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?f.dropdownButtonClassName:f.buttonClassName,u=r.selectAll("g."+c).data(l.filterVisible(s)),d=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(d.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var h=0,v=0,y=o._dims,x=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(x?v=y.headerHeight+f.gapButtonHeader:h=y.headerWidth+f.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(v=-f.gapButtonHeader+f.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(h=-f.gapButtonHeader+f.gapButton-y.openWidth);var b={x:y.lx+h+o.pad.l,y:y.ly+v+o.pad.t,yPad:f.gapButton,xPad:f.gapButton,index:0},T={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(l,s){var c=n.select(this);c.call(m,o,l,t).call(A,o,b),c.on("click",function(){n.event.defaultPrevented||(g(t,o,0,e,r,i,s),l.execute&&a.executeAPICommand(t,l.method,l.args),t.emit("plotly_buttonclicked",{menu:o,button:l,active:o.active}))}),c.on("mouseover",function(){c.call(w)}),c.on("mouseout",function(){c.call(k,o),u.call(_,o)})}),u.call(_,o),x?(T.w=Math.max(y.openWidth,y.headerWidth),T.h=b.y-T.t):(T.w=b.x-T.l,T.h=Math.max(y.openHeight,y.headerHeight)),T.direction=o.direction,i&&(u.size()?function(t,e,r,n,a,i){var o,l,s,c=a.direction,u="up"===c||"down"===c,d=a._dims,p=a.active;if(u)for(l=0,s=0;s0?[0]:[]);if(o.enter().append("g").classed(f.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+f.headerGroupClassName).each(i)}).remove(),0!==r.length){var s=o.selectAll("g."+f.headerGroupClassName).data(r,p);s.enter().append("g").classed(f.headerGroupClassName,!0);for(var c=l.ensureSingle(o,"g",f.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,M=l.barLength+2*l.barPad,A=l.barWidth+2*l.barPad,L=h,S=v+y;S+A>c&&(S=c-A);var C=this.container.selectAll("rect.scrollbar-horizontal").data(T?[0]:[]);C.exit().on(".drag",null).remove(),C.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,l.barColor),T?(this.hbar=C.attr({rx:l.barRadius,ry:l.barRadius,x:L,y:S,width:M,height:A}),this._hbarXMin=L+M/2,this._hbarTranslateMax=w-M):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var O=y>k,D=l.barWidth+2*l.barPad,P=l.barLength+2*l.barPad,z=h+g,E=v;z+D>s&&(z=s-D);var R=this.container.selectAll("rect.scrollbar-vertical").data(O?[0]:[]);R.exit().on(".drag",null).remove(),R.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,l.barColor),O?(this.vbar=R.attr({rx:l.barRadius,ry:l.barRadius,x:z,y:E,width:D,height:P}),this._vbarYMin=E+P/2,this._vbarTranslateMax=k-P):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var I=this.id,N=u-.5,F=O?f+D+.5:f+.5,j=d-.5,B=T?p+A+.5:p+.5,H=o._topdefs.selectAll("#"+I).data(T||O?[0]:[]);if(H.exit().remove(),H.enter().append("clipPath").attr("id",I).append("rect"),T||O?(this._clipRect=H.select("rect").attr({x:Math.floor(N),y:Math.floor(j),width:Math.ceil(F)-Math.floor(N),height:Math.ceil(B)-Math.floor(j)}),this.container.call(i.setClipUrl,I,this.gd),this.bg.attr({x:h,y:v,width:g,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),T||O){var q=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));T&&this.hbar.on(".drag",null).call(V),O&&this.vbar.on(".drag",null).call(V)}this.setTranslate(e,r)},l.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},l.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},l.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},l.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,a=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,a)-r)/(a-r)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,l=i+this._vbarTranslateMax;e=(o.constrain(n.event.y,i,l)-i)/(l-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},l.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/r;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var l=e/n;this.vbar.call(i.setTranslate,t,e+l*this._vbarTranslateMax)}}},{"../../lib":159,"../color":43,"../drawing":64,d3:8}],138:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,CAP_SHIFT:.7,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],139:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],140:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],141:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],142:[function(t,e,r){"use strict";r.version="1.43.0",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config")();for(var n=t("./registry"),a=r.register=n.register,i=t("./plot_api"),o=Object.keys(i),l=0;l1/3&&t.x<2/3},r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isTopAnchor=function(t){return"top"===t.yanchor||"auto"===t.yanchor&&t.y>=2/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3}},{}],145:[function(t,e,r){"use strict";var n=t("./mod"),a=n.mod,i=n.modHalf,o=Math.PI,l=2*o;function s(t){return Math.abs(t[1]-t[0])>l-1e-15}function c(t,e){return i(e-t,l)}function u(t,e){if(s(e))return!0;var r,n;e[0](n=a(n,l))&&(n+=l);var i=a(t,l),o=i+l;return i>=r&&i<=n||o>=r&&o<=n}function f(t,e,r,n,a,i,c){a=a||0,i=i||0;var u,f,d,p,h,g=s([r,n]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(u=0,f=o,d=l):r=a&&t<=i);var a,i},pathArc:function(t,e,r,n,a){return f(null,t,e,r,n,a,0)},pathSector:function(t,e,r,n,a){return f(null,t,e,r,n,a,1)},pathAnnulus:function(t,e,r,n,a,i){return f(t,e,r,n,a,i,1)}}},{"./mod":166}],146:[function(t,e,r){"use strict";var n=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function l(t){return n(t)||o(t)}function s(t,e,r){if(l(t)){if(l(t[0])){for(var n=r,a=0;aa.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,a){t%1||!n(t)||void 0!==a.min&&ta.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var a="number"==typeof t;!0!==n.strict&&a?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){a(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o.get(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(u(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var a=n.regex||c(r);"string"==typeof t&&a.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!c(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=n&&t<=a?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),y=t.charAt(0);!c||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:m);if(!k)return u;var T=k[1],M=k[3]||"1",A=Number(k[5]||1),L=Number(k[7]||0),S=Number(k[9]||0),C=Number(k[11]||0);if(c){if(2===T.length)return u;var O;T=Number(T);try{var D=v.getComponentMethod("calendars","getCal")(e);if(w){var P="i"===M.charAt(M.length-1);M=parseInt(M,10),O=D.newDate(T,D.toMonthIndex(T,M,P),A)}else O=D.newDate(T,Number(M),A)}catch(t){return u}return O?(O.toJD()-g)*f+L*d+S*p+C*h:u}T=2===T.length?(Number(T)+2e3-b)%100+b:Number(T),M-=1;var z=new Date(Date.UTC(2e3,M,A,L,S));return z.setUTCFullYear(T),z.getUTCMonth()!==M?u:z.getUTCDate()!==A?u:z.getTime()+C*h},n=r.MIN_MS=r.dateTime2ms("-9999"),a=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==u};var k=90*f,T=3*d,M=5*p;function A(t,e,r,n,a){if((e||r||n||a)&&(t+=" "+w(e,2)+":"+w(r,2),(n||a)&&(t+=":"+w(n,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=a))return u;e||(e=0);var i,o,l,c,m,x,b=Math.floor(10*s(t+.05,1)),w=Math.round(t-b/10);if(_(r)){var L=Math.floor(w/f)+g,S=Math.floor(s(t,f));try{i=v.getComponentMethod("calendars","getCal")(r).fromJD(L).formatDate("yyyy-mm-dd")}catch(t){i=y("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=n+f&&t<=a-f))return u;var e=Math.floor(10*s(t+.05,1)),r=new Date(Math.round(t-e/10));return A(i.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===u)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return l.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return l.error("unrecognized date",t),e;return t};var L=/%\d?f/g;function S(t,e,r,n){t=t.replace(L,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(a)}var C=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,a,i){if(a=_(a)&&a,!e)if("y"===r)e=i.year;else if("m"===r)e=i.month;else{if("d"!==r)return function(t,e){var r=s(t+.05,f),n=w(Math.floor(r/d),2)+":"+w(s(Math.floor(r/p),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(s(t/h,60),C[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+a}return n}(t,r)+"\n"+S(i.dayMonthYear,t,n,a);e=i.dayMonth+"\n"+i.year}return S(e,t,n,a)};var O=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=s(t,f);if(t=Math.round(t-n),r)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(r),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){l.error("invalid ms "+t+" in calendar "+r)}var c=new Date(t+O);return c.setUTCMonth(c.getUTCMonth()+e)+n-O},r.findExactDates=function(t,e){for(var r,n,a=0,i=0,l=0,s=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}function s(t,e,r,n,a){var i=n*t+a*e;if(i<0)return n*n+a*a;if(i>r){var o=n-t,l=a-e;return o*o+l*l}var s=n*e-a*t;return s*s/r}r.segmentsIntersect=l,r.segmentDistance=function(t,e,r,n,a,i,o,c){if(l(t,e,r,n,a,i,o,c))return 0;var u=r-t,f=n-e,d=o-a,p=c-i,h=u*u+f*f,g=d*d+p*p,v=Math.min(s(u,f,h,a-t,i-e),s(u,f,h,o-t,c-e),s(d,p,g,t-a,e-i),s(d,p,g,r-a,n-i));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,l){if(t===a&&l===i||(n={},a=t,i=l),n[r])return n[r];var s=t.getPointAtLength(o(r-l/2,e)),c=t.getPointAtLength(o(r+l/2,e)),u=Math.atan((c.y-s.y)/(c.x-s.x)),f=t.getPointAtLength(o(r,e)),d={x:(4*f.x+s.x+c.x)/6,y:(4*f.y+s.y+c.y)/6,theta:u};return n[r]=d,d},r.clearLocationCache=function(){a=null},r.getVisibleSegment=function(t,e,r){var n,a,i=e.left,o=e.right,l=e.top,s=e.bottom,c=0,u=t.getTotalLength(),f=u;function d(e){var r=t.getPointAtLength(e);0===e?n=r:e===u&&(a=r);var c=r.xo?r.x-o:0,f=r.ys?r.y-s:0;return Math.sqrt(c*c+f*f)}for(var p=d(c);p;){if((c+=p+r)>f)return;p=d(c)}for(p=d(f);p;){if(c>(f-=p+r))return;p=d(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(n.x-a.x)<.1&&Math.abs(n.y-a.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var a,i,o,l=(n=n||{}).pathLength||t.getTotalLength(),s=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(l)[r]?-1:1,f=0,d=0,p=l;f0?p=a:d=a,f++}return i}},{"./mod":166}],157:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],158:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],159:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../constants/numerical"),o=i.FP_SAFE,l=i.BADNUM,s=e.exports={};s.nestedProperty=t("./nested_property"),s.keyedContainer=t("./keyed_container"),s.relativeAttr=t("./relative_attr"),s.isPlainObject=t("./is_plain_object"),s.toLogRange=t("./to_log_range"),s.relinkPrivateKeys=t("./relink_private");var c=t("./array");s.isTypedArray=c.isTypedArray,s.isArrayOrTypedArray=c.isArrayOrTypedArray,s.isArray1D=c.isArray1D,s.ensureArray=c.ensureArray,s.concat=c.concat,s.maxRowLength=c.maxRowLength,s.minRowLength=c.minRowLength;var u=t("./mod");s.mod=u.mod,s.modHalf=u.modHalf;var f=t("./coerce");s.valObjectMeta=f.valObjectMeta,s.coerce=f.coerce,s.coerce2=f.coerce2,s.coerceFont=f.coerceFont,s.coerceHoverinfo=f.coerceHoverinfo,s.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,s.validate=f.validate;var d=t("./dates");s.dateTime2ms=d.dateTime2ms,s.isDateTime=d.isDateTime,s.ms2DateTime=d.ms2DateTime,s.ms2DateTimeLocal=d.ms2DateTimeLocal,s.cleanDate=d.cleanDate,s.isJSDate=d.isJSDate,s.formatDate=d.formatDate,s.incrementMonth=d.incrementMonth,s.dateTick0=d.dateTick0,s.dfltRange=d.dfltRange,s.findExactDates=d.findExactDates,s.MIN_MS=d.MIN_MS,s.MAX_MS=d.MAX_MS;var p=t("./search");s.findBin=p.findBin,s.sorterAsc=p.sorterAsc,s.sorterDes=p.sorterDes,s.distinctVals=p.distinctVals,s.roundUp=p.roundUp,s.sort=p.sort,s.findIndexOfMin=p.findIndexOfMin;var h=t("./stats");s.aggNums=h.aggNums,s.len=h.len,s.mean=h.mean,s.midRange=h.midRange,s.variance=h.variance,s.stdev=h.stdev,s.interp=h.interp;var g=t("./matrix");s.init2dArray=g.init2dArray,s.transposeRagged=g.transposeRagged,s.dot=g.dot,s.translationMatrix=g.translationMatrix,s.rotationMatrix=g.rotationMatrix,s.rotationXYMatrix=g.rotationXYMatrix,s.apply2DTransform=g.apply2DTransform,s.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");s.deg2rad=v.deg2rad,s.rad2deg=v.rad2deg,s.angleDelta=v.angleDelta,s.angleDist=v.angleDist,s.isFullCircle=v.isFullCircle,s.isAngleInsideSector=v.isAngleInsideSector,s.isPtInsideSector=v.isPtInsideSector,s.pathArc=v.pathArc,s.pathSector=v.pathSector,s.pathAnnulus=v.pathAnnulus;var y=t("./anchor_utils");s.isLeftAnchor=y.isLeftAnchor,s.isCenterAnchor=y.isCenterAnchor,s.isRightAnchor=y.isRightAnchor,s.isTopAnchor=y.isTopAnchor,s.isMiddleAnchor=y.isMiddleAnchor,s.isBottomAnchor=y.isBottomAnchor;var m=t("./geometry2d");s.segmentsIntersect=m.segmentsIntersect,s.segmentDistance=m.segmentDistance,s.getTextLocation=m.getTextLocation,s.clearLocationCache=m.clearLocationCache,s.getVisibleSegment=m.getVisibleSegment,s.findPointOnPath=m.findPointOnPath;var x=t("./extend");s.extendFlat=x.extendFlat,s.extendDeep=x.extendDeep,s.extendDeepAll=x.extendDeepAll,s.extendDeepNoArrays=x.extendDeepNoArrays;var b=t("./loggers");s.log=b.log,s.warn=b.warn,s.error=b.error;var _=t("./regex");s.counterRegex=_.counter;var w=t("./throttle");function k(t){var e={};for(var r in t)for(var n=t[r],a=0;ao?l:a(t)?Number(t):l:l},s.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},s.noop=t("./noop"),s.identity=t("./identity"),s.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},s.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},s.simpleMap=function(t,e,r,n){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,r)?a>10?(s.warn("randstr failed uniqueness"),c):t(e,r,n,(a||0)+1):c},s.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},s.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,a,i,o=t.length,l=2*o,s=2*e-1,c=new Array(s),u=new Array(o);for(r=0;r=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=o&&(a=l-1-a),i+=t[a]*c[n];u[r]=i}return u},s.syncOrAsync=function(t,e,r){var n;function a(){return s.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(a).then(void 0,s.promiseError);return r&&r(e)},s.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},s.noneOrAll=function(t,e,r){if(t){var n,a=!1,i=!0;for(n=0;n1?a+o[1]:"";if(i&&(o.length>1||l.length>4||r))for(;n.test(l);)l=l.replace(n,"$1"+i+"$2");return l+s};var A=/%{([^\s%{}:]*)(:[^}]*)?}/g,L=/^\w*$/;s.templateString=function(t,e){var r={};return t.replace(A,function(t,n){return L.test(n)?e[n]||"":(r[n]=r[n]||s.nestedProperty(e,n).get,r[n]()||"")})};var S=/^:/,C=0;s.hovertemplateString=function(t,e){var r=arguments,a={};return t.replace(A,function(t,i,o){var l,c,u;for(u=2;u=48&&o<=57,c=l>=48&&l<=57;if(s&&(n=10*n+o-48),c&&(a=10*a+l-48),!s||!c){if(n!==a)return n-a;if(o!==l)return o-l}}return a-n};var O=2e9;s.seedPseudoRandom=function(){O=2e9},s.pseudoRandom=function(){var t=O;return O=(69069*O+1)%4294967296,Math.abs(O-t)<429496729?s.pseudoRandom():O/4294967296}},{"../constants/numerical":140,"./anchor_utils":144,"./angles":145,"./array":146,"./clean_number":147,"./clear_responsive":149,"./coerce":150,"./dates":151,"./extend":153,"./filter_unique":154,"./filter_visible":155,"./geometry2d":156,"./get_graph_div":157,"./identity":158,"./is_plain_object":160,"./keyed_container":161,"./localize":162,"./loggers":163,"./make_trace_groups":164,"./matrix":165,"./mod":166,"./nested_property":167,"./noop":168,"./notifier":169,"./push_unique":172,"./regex":174,"./relative_attr":175,"./relink_private":176,"./search":177,"./stats":179,"./throttle":181,"./to_log_range":182,d3:8,"fast-isnumeric":10}],160:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],161:[function(t,e,r){"use strict";var n=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,r,i){var o,l,s;r=r||"name",i=i||"value";var c={};e&&e.length?(s=n(t,e),l=s.get()):l=t,e=e||"";var u={};if(l)for(o=0;o2)return c[e]=2|c[e],d.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],167:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,c=e.split(".");s/g),o=0;oi||c===a||cl||e&&s(t))}:function(t,e){var s=t[0],c=t[1];if(s===a||si||c===a||cl)return!1;var u,f,d,p,h,g=r.length,v=r[0][0],y=r[0][1],m=0;for(u=1;uMath.max(f,v)||c>Math.max(d,y)))if(cu||Math.abs(n(o,d))>a)return!0;return!1};i.filter=function(t,e){var r=[t[0]],n=0,a=0;function i(i){t.push(i);var l=r.length,s=n;r.splice(a+1);for(var c=s+1;c1&&i(t.pop());return{addPt:i,raw:t,filtered:r}}},{"../constants/numerical":140,"./matrix":165}],172:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ra.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function c(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,u,f=0,d=e.length,p=0,h=d>1?(e[d-1]-e[0])/(d-1):1;for(u=h>=0?r?o:l:r?c:s,t+=1e-9*h*(r?-1:1)*(h>=0?1:-1);f90&&a.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,a=e[n]-e[0]||1,i=a/(n||1)/1e4,o=[e[0]],l=0;le[l]+i&&(a=Math.min(a,e[l+1]-e[l]),o.push(e[l+1]));return{vals:o,minDiff:a}},r.roundUp=function(t,e,r){for(var n,a=0,i=e.length-1,o=0,l=r?0:1,s=r?1:0,c=r?Math.ceil:Math.floor;a0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||i;for(var r,n=1/0,a=0;ai.length)&&(o=i.length),n(e)||(e=!1),a(i[0])){for(s=new Array(o),l=0;lt.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":146,"fast-isnumeric":10}],180:[function(t,e,r){"use strict";var n=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function l(t,e){return t.node().getBoundingClientRect()[e]}var s=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var L=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&L.match(s),O=n.select(t.node().parentNode);if(!O.empty()){var D=t.attr("class")?t.attr("class").split(" ")[0]:"text";return D+="-math",O.selectAll("svg."+D).remove(),O.selectAll("g."+D+"-group").remove(),t.style("display",null).attr({"data-unformatted":L,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),i={fontSize:r};!function(t,e,r){var i,o,l,s;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),l=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+a.randstr({},64);return s=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(s.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(s.select(".MathJax_SVG").empty()||!s.select("svg").node())a.log("There was an error in the tex syntax.",t),r();else{var o=s.select("svg").node().getBoundingClientRect();r(s.select(".MathJax_SVG"),e,o)}if(s.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==l&&(MathJax.Hub.processSectionDelay=l),MathJax.Hub.Config(o)})}(S[2],i,function(n,a,i){O.selectAll("svg."+D).remove(),O.selectAll("g."+D+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return P(),void e();var s=O.append("g").classed(D+"-group",!0).attr({"pointer-events":"none","data-unformatted":L,"data-math":"Y"});s.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:D,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=l(o,"width"),f=l(o,"height"),d=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(r||l(t,"height"))/4;"y"===D[0]?(s.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===D[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===D[0]?o.attr({x:0,y:p}):o.attr({x:d,y:+t.attr("y")+p-f/2}),v&&v.call(t,s),e(s)})})):P(),t}function P(){O.empty()||(D=t.attr("class")+"-math",O.select("svg."+D).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var r,l=!1,s=[],c=-1;function u(){c++;var e=document.createElementNS(i.svg,"tspan");n.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),r=e;var a=s;if(s=[{node:e}],a.length>1)for(var l=1;l doesnt match end tag <"+t+">. Pretending it did match.",e),r=s[s.length-1].node}else a.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(r=t,s=[{node:t}]);for(var O=e.split(m),D=0;D|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},d={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},h="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,m=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,T=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function M(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&C(n)}var A=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var L={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function C(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):L[e])||t})}function O(t,e,r){var n,a,i,o=r.horizontalAlign,l=r.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-n.height}:"middle"===l?function(){return s.top+(s.height-n.height)/2}:function(){return s.top},i="right"===o?function(){return s.right-n.width}:"center"===o?function(){return s.left+(s.width-n.width)/2}:function(){return s.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:i()-c.left+"px","z-index":1e3}),this}}r.convertEntities=C,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function a(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var i=a("x",e),o=a("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},r.makeEditable=function(t,e){var r=e.gd,a=e.delegate,i=n.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function l(){!function(){var a=n.select(r).select(".svg-container"),o=a.append("div"),l=t.node().style,c=parseFloat(l.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":l.fontFamily||"Arial","font-size":c,color:e.fill||l.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(O(t,a,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=n.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),n.select(this).call(O(t,a,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(s)}(),t.style({opacity:0});var a,l=o.attr("class");(a=l?"."+l.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(a).style({opacity:0})}function s(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?l():o.on("click",l),n.rebind(t,i,"on")}},{"../constants/alignment":138,"../constants/xmlns_namespaces":141,"../lib":159,d3:8}],181:[function(t,e,r){"use strict";var n={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var i=n[t],o=Date.now();if(!i){for(var l in n)n[l].tsi.ts+e?s():i.timer=setTimeout(function(){s(),i.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)a(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],182:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":10}],183:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],184:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],185:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,a=n.layoutArrayContainers,i=n.layoutArrayRegexes,o=t.split("[")[0],l=0;l0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var i=(l.subplotsRegistry.cartesian||{}).attrRegex,s=(l.subplotsRegistry.polar||{}).attrRegex,u=(l.subplotsRegistry.ternary||{}).attrRegex,h=(l.subplotsRegistry.gl3d||{}).attrRegex,g=Object.keys(t);for(e=0;e3?(D.x=1.02,D.xanchor="left"):D.x<-2&&(D.x=-.02,D.xanchor="right"),D.y>3?(D.y=1.02,D.yanchor="bottom"):D.y<-2&&(D.y=-.02,D.yanchor="top")),p(t),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t.template&&t.template.layout&&r.cleanLayout(t.template.layout),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=x(e);r;){if(r in t)return!0;r=x(r)}return!1};var b=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&i.warn("Full array edits are incompatible with other edits",f);var m=r[""][""];if(c(m))e.set(null);else{if(!Array.isArray(m))return i.warn("Unrecognized full array edit value",f,m),!0;e.set(m)}return!g&&(d(v,y),p(t),!0)}var x,b,_,w,k,T,M,A,L=Object.keys(r).map(Number).sort(o),S=e.get(),C=S||[],O=u(y,f).get(),D=[],P=-1,z=C.length;for(x=0;xC.length-(M?0:1))i.warn("index out of range",f,_);else if(void 0!==T)k.length>1&&i.warn("Insertion & removal are incompatible with edits to the same index.",f,_),c(T)?D.push(_):M?("add"===T&&(T={}),C.splice(_,0,T),O&&O.splice(_,0,{})):i.warn("Unrecognized full object edit value",f,_,T),-1===P&&(P=_);else for(b=0;b=0;x--)C.splice(D[x],1),O&&O.splice(D[x],1);if(C.length?S||e.set(C):e.set(null),g)return!1;if(d(v,y),h!==a){var E;if(-1===P)E=L;else{for(z=Math.max(C.length,z),E=[],x=0;x=P);x++)E.push(_);for(x=P;x=t.data.length||a<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(a,n+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+r+" must be unique.")}}function E(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),z(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&z(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function R(t,e,r,n,i){!function(t,e,r,n){var a=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var i in z(t,r,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==r.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in n)||!Array.isArray(n[i])||n[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var s=function(t,e,r,n){var i,s,c,u,f,d=o.isPlainObject(n),p=[];for(var h in Array.isArray(r)||(r=[r]),r=P(r,t.data.length-1),e)for(var g=0;g-1?s(r,r.replace("titlefont","title.font")):r.indexOf("titleposition")>-1?s(r,r.replace("titleposition","title.position")):r.indexOf("titleside")>-1?s(r,r.replace("titleside","title.side")):r.indexOf("titleoffset")>-1&&s(r,r.replace("titleoffset","title.offset")):s(r,r.replace("title","title.text"));function s(e,r){t[r]=t[e],delete t[e]}}function V(t,e,r){if(t=o.getGraphDiv(t),k.clearPromiseQueue(t),t.framework&&t.framework.isPolar)return Promise.resolve(t);var n={};if("string"==typeof e)n[e]=r;else{if(!o.isPlainObject(e))return o.warn("Relayout fail.",e,r),Promise.reject();n=o.extendFlat({},e)}Object.keys(n).length&&(t.changed=!0);var a=W(t,n),i=a.flags;i.calc&&(t.calcdata=void 0);var l=[d.previousPromises];i.layoutReplot?l.push(T.layoutReplot):Object.keys(n).length&&(U(t,i,a)||d.supplyDefaults(t),i.legend&&l.push(T.doLegend),i.layoutstyle&&l.push(T.layoutStyles),i.axrange&&G(l,a.rangesAltered),i.ticks&&l.push(T.doTicksRelayout),i.modebar&&l.push(T.doModeBar),i.camera&&l.push(T.doCamera),l.push(S)),l.push(d.rehover),c.add(t,V,[t,a.undoit],V,[t,a.redoit]);var s=o.syncOrAsync(l,t);return s&&s.then||(s=Promise.resolve(t)),s.then(function(){return t.emit("plotly_relayout",a.eventData),t})}function U(t,e,r){var n;if(!e.axrange)return!1;for(n in e)if("axrange"!==n&&e[n])return!1;for(n in r.rangesAltered){var a=h.id2name(n),i=t.layout[a],o=t._fullLayout[a];o.autorange=i.autorange,o.range=i.range.slice(),o.cleanRange()}return!0}function G(t,e){var r=e?function(t){var r={skipTitle:!0};for(var n in e)if(h.getFromId(t,n).automargin){r={};break}return h.draw(t,Object.keys(e),r)}:function(t){return h.draw(t,"redraw")};t.push(T.doAutoRangeAndConstraints,r,T.drawData,T.finalDraw)}r.plot=function(t,e,a,i){var l;if(t=o.getGraphDiv(t),s.init(t),o.isPlainObject(e)){var c=e;e=c.data,a=c.layout,i=c.config,l=c.frames}if(!1===s.triggerHandler(t,"plotly_beforeplot",[e,a,i]))return Promise.reject();e||a||o.isPlotDiv(t)||o.warn("Calling Plotly.plot as if redrawing but this container doesn't yet have a plot.",t),D(t,i),a||(a={}),n.select(t).classed("js-plotly-plot",!0),g.makeTester(),Array.isArray(t._promises)||(t._promises=[]);var f=0===(t.data||[]).length&&Array.isArray(e);if(Array.isArray(e)&&(k.cleanData(e),f?t.data=e:t.data.push.apply(t.data,e),t.empty=!1),t.layout&&!f||(t.layout=k.cleanLayout(a)),t._dragging&&!t._transitioning)return t._replotPending=!0,Promise.reject();t._replotPending=!1,d.supplyDefaults(t);var v=t._fullLayout,x=v._has("cartesian");if(!v._has("polar")&&e&&e[0]&&e[0].r)return o.log("Legacy polar charts are deprecated!"),function(t,e,r){var a=n.select(t).selectAll(".plot-container").data([0]);a.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=a.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e);r&&(t.layout=r);p.manager.fillLayout(t),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=p.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var l=t.framework.svg(),s=1,c=t._fullLayout.title?t._fullLayout.title.text:"";""!==c&&c||(s=0);var u=function(){this.call(b.convertToTspans,t)},f=l.select(".title-group text").call(u);if(t._context.edits.titleText){var h=o._(t,"Click to enter Plot title");c&&c!==h||(s=.2,f.attr({"data-unformatted":h}).text(h).style({opacity:s}).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)}));var g=function(){this.call(b.makeEditable,{gd:t}).on("edit",function(e){t.framework({layout:{title:{text:e}}}),this.text(e).call(u),this.call(g)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(u)})};f.call(g)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),d.addLinks(t),Promise.resolve()}(t,e,a);v._replotting=!0,f&<(t),t.framework!==lt&&(t.framework=lt,lt(t)),g.initGradients(t),f&&h.saveShowSpikeInitial(t);var _=!t.calcdata||t.calcdata.length!==(t._fullData||[]).length;_&&d.doCalcdata(t);for(var w=0;w=0&&r=0&&r0&&"string"!=typeof z.parts[R];)R--;var I=z.parts[R],N=z.parts[R-1]+"."+I,B=z.parts.slice(0,R).join("."),H=l(t.layout,B).get(),V=l(s,B).get(),U=z.get();if(void 0!==E){T[P]=E,L[P]="reverse"===I?E:F(U);var G=f.getLayoutValObject(s,z.parts);if(G&&G.impliedEdits&&null!==E)for(var W in G.impliedEdits)S(o.relativeAttr(P,W),G.impliedEdits[W]);if(-1!==["width","height"].indexOf(P))if(E){S("autosize",null);var $="height"===P?"width":"height";S($,s[$])}else s[P]=t._initialAutoSize[P];else if("autosize"===P)S("width",E?null:s.width),S("height",E?null:s.height);else if(N.match(X))D(N),l(s,B+"._inputRange").set(null);else if(N.match(Y)){D(N),l(s,B+"._inputRange").set(null);var Q=l(s,B).get();Q._inputDomain&&(Q._input.domain=Q._inputDomain.slice())}else N.match(Z)&&l(s,B+"._inputDomain").set(null);if("type"===I){var K=H,tt="linear"===V.type&&"log"===E,et="log"===V.type&&"linear"===E;if(tt||et){if(K&&K.range)if(V.autorange)tt&&(K.range=K.range[1]>K.range[0]?[1,2]:[2,1]);else{var rt=K.range[0],nt=K.range[1];tt?(rt<=0&&nt<=0&&S(B+".autorange",!0),rt<=0?rt=nt/1e6:nt<=0&&(nt=rt/1e6),S(B+".range[0]",Math.log(rt)/Math.LN10),S(B+".range[1]",Math.log(nt)/Math.LN10)):(S(B+".range[0]",Math.pow(10,rt)),S(B+".range[1]",Math.pow(10,nt)))}else S(B+".autorange",!0);Array.isArray(s._subplots.polar)&&s._subplots.polar.length&&s[z.parts[0]]&&"radialaxis"===z.parts[1]&&delete s[z.parts[0]]._subplot.viewInitial["radialaxis.range"],u.getComponentMethod("annotations","convertCoords")(t,V,E,S),u.getComponentMethod("images","convertCoords")(t,V,E,S)}else S(B+".autorange",!0),S(B+".range",null);l(s,B+"._inputRange").set(null)}else if(I.match(A)){var at=l(s,P).get(),it=(E||{}).type;it&&"-"!==it||(it="linear"),u.getComponentMethod("annotations","convertCoords")(t,at,it,S),u.getComponentMethod("images","convertCoords")(t,at,it,S)}var ot=w.containerArrayMatch(P);if(ot){r=ot.array,n=ot.index;var lt=ot.property,st=G||{editType:"calc"};""!==n&&""===lt&&(w.isAddVal(E)?L[P]=null:w.isRemoveVal(E)?L[P]=(l(i,r).get()||[])[n]:o.warn("unrecognized full object value",e)),M.update(_,st),y[r]||(y[r]={});var ct=y[r][n];ct||(ct=y[r][n]={}),ct[lt]=E,delete e[P]}else"reverse"===I?(H.range?H.range.reverse():(S(B+".autorange",!0),H.range=[1,0]),V.autorange?_.calc=!0:_.plot=!0):(s._has("scatter-like")&&s._has("regl")&&"dragmode"===P&&("lasso"===E||"select"===E)&&"lasso"!==U&&"select"!==U?_.plot=!0:G?M.update(_,G):_.calc=!0,z.set(E))}}for(r in y){w.applyContainerArrayChanges(t,d(i,r),y[r],_,d)||(_.plot=!0)}var ut=s._axisConstraintGroups||[];for(C in O)for(n=0;n1;)if(n.pop(),void 0!==(r=l(e,n.join(".")+".uirevision").get()))return r;return e.uirevision}function nt(t,e){for(var r=0;r=a.length?a[0]:a[t]:a}function s(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function c(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(i,u){function f(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,d.transition(t,e.frame.data,e.frame.layout,k.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function p(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&f()};e()}var h,g,v=0;function y(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var m=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))m.push({type:"object",data:y(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(h=0;h0&&TT)&&M.push(g);m=M}}m.length>0?function(e){if(0!==e.length){for(var a=0;a=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(u[g]||h[g]||{}).name,y=e[n].name,m=u[v]||h[v];v&&y&&"number"==typeof y&&m&&L<5&&(L++,o.warn('addFrames: overwriting frame "'+(u[v]||h[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===L&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),h[g]={name:g},p.push({frame:d.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:f+n})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(a=p[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;u[a.name="frame "+t._transitionData._counter++];);if(u[a.name]){for(i=0;i=0;r--)n=e[r],i.push({type:"delete",index:n}),l.unshift({type:"insert",index:n,value:a[n]});var s=d.modifyFrames,u=d.modifyFrames,f=[t,l],p=[t,i];return c&&c.add(t,s,f,u,p),d.modifyFrames(t,i)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return d.cleanPlot([],{},r,e),d.purge(t),s.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":43,"../components/colorbar/connect":45,"../components/drawing":64,"../constants/xmlns_namespaces":141,"../lib":159,"../lib/events":152,"../lib/queue":173,"../lib/svg_text_utils":180,"../plots/cartesian/axes":203,"../plots/cartesian/constants":209,"../plots/cartesian/graph_interact":213,"../plots/plots":236,"../plots/polar/legacy":239,"../registry":243,"./edit_types":186,"./helpers":187,"./manage_arrays":189,"./plot_config":191,"./plot_schema":192,"./subroutines":194,d3:8,"fast-isnumeric":10,"has-hover":12}],191:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,showSendToCloud:!1,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,watermark:!1,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],192:[function(t,e,r){"use strict";var n=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),l=t("../plots/frame_attributes"),s=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),d=a.extendFlat,p=a.extendDeepAll,h=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",y=[g,v,"_arrayAttrRegexps","_deprecated"];function m(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(x(e[r]))r++;else if(r=i.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!x(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):h(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(h(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=s.length)return!1;a=(r=(n.transformsRegistry[s[u].type]||{}).attributes)&&r[e[2]],l=3}else if("area"===t.type)a=c[o];else{var f=t._module;if(f||(f=(n.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(r=f.attributes)&&r[o])){var d=f.basePlotModule;d&&d.attributes&&(a=d.attributes[o])}a||(a=i[o])}return m(a,e,l)},r.getLayoutValObject=function(t,e){return m(function(t,e){var r,a,i,l,s=t._basePlotModules;if(s){var c;for(r=0;r=a&&(r._input||{})._templateitemname;l&&(o=a);var s,c=e+"["+o+"]";function u(){s={},l&&(s[c]={},s[c][i]=l)}function f(t,e){l?n.nestedProperty(s[c],t).set(e):s[c+"."+t]=e}function d(){var t=s;return u(),t}return u(),{modifyBase:function(t,e){s[t]=e},modifyItem:f,getUpdateObj:d,applyUpdate:function(e,r){e&&f(e,r);var a=d();for(var i in a)n.nestedProperty(t,i).set(a[i])}}}},{"../lib":159,"../plots/attributes":200}],194:[function(t,e,r){"use strict";var n=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),l=t("../lib/clear_gl_canvases"),s=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),d=t("../plots/cartesian/axes"),p=t("../constants/alignment"),h=t("../plots/cartesian/constraints"),g=h.enforce,v=h.clean,y=t("../plots/cartesian/autorange").doAutoRange,m="start",x="middle",b="end";function _(t,e,r){for(var n=0;n=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function w(t){var e,a,i,l,u,h,g=t._fullLayout,v=g._size,y=v.p,m=d.list(t,"",!0);if(g._paperdiv.style({width:t._context.responsive&&g.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":g.width+"px",height:t._context.responsive&&g.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":g.height+"px"}).selectAll(".main-svg").call(c.setSize,g.width,g.height),t._context.setBackground(t,g.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!g._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-y-n:e._offset+e._length+y+n:v.t+v.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+y+n:e._offset-y-n:v.l+v.w*(t.position||0)+n%1}for(e=0;ek?u.push({code:"unused",traceType:m,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:m,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var i=e[n],o=p(e,n,r);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&u.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&h(i)&&t(i,o)}}({data:v,layout:d},""),u.length)return u.map(g)}},{"../lib":159,"../plots/attributes":200,"../plots/plots":236,"./plot_config":191,"./plot_schema":192,"./plot_template":193}],196:[function(t,e,r){"use strict";var n=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),l=t("../snapshot/svgtoimg"),s={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,u,f;function d(t){return!(t in e)||a.validate(e[t],s[t])}if(e=e||{},a.isPlainObject(t)?(r=t.data||[],u=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),r=a.extendDeep([],t.data),u=a.extendDeep({},t.layout),f=t._context),!d("width")||!d("height"))throw new Error("Height and width should be pixel values.");if(!d("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function h(t,r){return a.coerce(e,p,s,t,r)}var g=h("format"),v=h("width"),y=h("height"),m=h("scale"),x=h("setBackground"),b=h("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},u);v&&(w.width=v),y&&(w.height=y);var k=a.extendFlat({},f,{_exportedPlot:!0,staticPlot:!0,setBackground:x}),T=i.getRedrawFunc(_);function M(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function A(){return new Promise(function(t,e){var r=o(_,g,m),i=_._fullLayout.width,s=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(b?r:"data:image/svg+xml,"+encodeURIComponent(r));var c=document.createElement("canvas");c.id=a.randstr(),l({format:g,width:i,height:s,scale:m,canvas:c,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,k).then(T).then(M).then(A).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":159,"../snapshot/helpers":247,"../snapshot/svgtoimg":249,"../snapshot/tosvg":251,"./plot_api":190}],197:[function(t,e,r){"use strict";var n=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),l=n.isPlainObject,s=Array.isArray,c=n.isArrayOrTypedArray;function u(t,e,r,a,i,o){o=o||[];for(var f=Object.keys(t),d=0;dx.length&&a.push(p("unused",i,y.concat(x.length)));var T,M,A,L,S,C=x.length,O=Array.isArray(k);if(O&&(C=Math.min(C,k.length)),2===b.dimensions)for(M=0;Mx[M].length&&a.push(p("unused",i,y.concat(M,x[M].length)));var D=x[M].length;for(T=0;T<(O?Math.min(D,k[M].length):D);T++)A=O?k[M][T]:k,L=m[M][T],S=x[M][T],n.validate(L,A)?S!==L&&S!==+L&&a.push(p("dynamic",i,y.concat(M,T),L,S)):a.push(p("value",i,y.concat(M,T),L))}else a.push(p("array",i,y.concat(M),m[M]));else for(M=0;M1&&d.push(p("object","layout"))),a.supplyDefaults(h);for(var g=h._fullData,v=r.length,y=0;y0&&((b=M-o(v)-o(y))>A?_/b>L&&(m=v,x=y,L=_/b):_/M>L&&(m={val:v.val,pad:0},x={val:y.val,pad:0},L=_/M));if(d===p){var S=d-1,C=d+1;if(k)if(0===d)i=[0,1];else{var O=(d>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),D=d/(1-Math.min(.5,O/M));i=d>0?[0,D]:[D,0]}else i=T?[Math.max(0,S),Math.max(1,C)]:[S,C]}else k?(m.val>=0&&(m={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):T&&(m.val-L*o(m)<0&&(m={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),L=(x.val-m.val)/(M-o(m)-o(x)),i=[m.val-L*o(m),x.val+L*o(x)];return h&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function s(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function c(t,e){var r,n,a,i=e._id,o=t._fullData,l=t._fullLayout,s=[],c=[];function d(t,e){for(r=0;r=r&&(c.extrapad||!o)){l=!1;break}a(e,c.val)&&c.pad<=r&&(o||!c.extrapad)&&(t.splice(s,1),s--)}if(l){var u=i&&0===e;t.push({val:e,pad:u?0:r,extrapad:!u&&o})}}function p(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:l,makePadFn:s,doAutoRange:function(t,e){if(e.autorange){e.range=l(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l);var r=e._input,n={};n[e._attr+".range"]=e.range,n[e._attr+".autorange"]=e.autorange,o.call("_storeDirectGUIEdit",t.layout,t._fullLayout._preGUI,n),r.range=e.range.slice(),r.autorange=e.autorange}var i=e._anchorAxis;if(i&&i.rangeslider){var s=i.rangeslider[e._name];s&&"auto"===s.rangemode&&(s.range=l(t,e)),i._input.rangeslider[e._name]=a.extendFlat({},s)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var a,o,l,s,c,d,h,g,v,y=[],m=[],x=e.length,b=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function T(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var M=T((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),A=T((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),L=T(r.vpadplus||r.vpad),S=T(r.vpadminus||r.vpad);if(!k){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=D;a--)O(a);return{min:y,max:m}},concatExtremes:c}},{"../../constants/numerical":140,"../../lib":159,"../../registry":243,"fast-isnumeric":10}],203:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),d=t("./layout_attributes"),p=t("./clean_ticks"),h=t("../../constants/numerical"),g=h.ONEAVGYEAR,v=h.ONEAVGMONTH,y=h.ONEDAY,m=h.ONEHOUR,x=h.ONEMIN,b=h.ONESEC,_=h.MINUS_SIGN,w=h.BADNUM,k=t("../../constants/alignment").MID_SHIFT,T=t("../../constants/alignment").LINE_SPACING,M=e.exports={};M.setConvert=t("./set_convert");var A=t("./axis_autotype"),L=t("./axis_ids");M.id2name=L.id2name,M.name2id=L.name2id,M.cleanId=L.cleanId,M.list=L.list,M.listIds=L.listIds,M.getFromId=L.getFromId,M.getFromTrace=L.getFromTrace;var S=t("./autorange");M.getAutoRange=S.getAutoRange,M.findExtremes=S.findExtremes,M.coerceRef=function(t,e,r,n,a,i){var o=n.charAt(n.length-1),s=r._fullLayout._subplots[o+"axis"],c=n+"ref",u={};return a||(a=s[0]||i),i||(i=a),u[c]={valType:"enumerated",values:s.concat(i?[i]:[]),dflt:a},l.coerce(t,e,u,c)},M.coercePosition=function(t,e,r,n,a,i){var o,s;if("paper"===n||"pixel"===n)o=l.ensureNumber,s=r(a,i);else{var c=M.getFromId(e,n);s=r(a,i=c.fraction2r(i)),o=c.cleanPos}t[a]=o(s)},M.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?l.ensureNumber:M.getFromId(e,r).cleanPos)(t)};var C=M.getDataConversions=function(t,e,r,n){var a,i="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(i)){if(a={type:A(n),_categories:[]},M.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},M.saveRangeInitial=function(t,e){for(var r=M.list(t,"",!0),n=!1,a=0;a.3*d||u(n)||u(i))){var p=r.dtick/2;t+=t+p.8){var o=Number(r.substr(1));i.exactYears>.8&&o%12==0?t=M.tickIncrement(t,"M6","reverse")+1.5*y:i.exactMonths>.8?t=M.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var s=M.tickIncrement(t,r);if(s<=n)return s}return t}(x,t,m,c,i)),v=x,0;v<=u;)v=M.tickIncrement(v,m,!1,i),0;return{start:e.c2r(x,0,i),end:e.c2r(v,0,i),size:m,_dataSpan:u-c}},M.prepTicks=function(t){var e=l.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type||"multicategory"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=l.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),M.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),B(t)},M.calcTicks=function(t){M.prepTicks(t);var e=l.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e=t.tickvals,r=t.ticktext,n=new Array(e.length),a=l.simpleMap(t.range,t.r2l),i=1.0001*a[0]-1e-4*a[1],o=1.0001*a[1]-1e-4*a[0],s=Math.min(i,o),c=Math.max(i,o),u=0;Array.isArray(r)||(r=[]);var f="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(var d=0;ds&&p=n:c<=n)&&!(i.length>s||c===o);c=M.tickIncrement(c,t.dtick,a,t.calendar))o=c,i.push(c);et(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(i.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&i<=10||e>=15*y)t._tickround="d";else if(e>=x&&i<=16||e>=m)t._tickround="M";else if(e>=b&&i<=19||e>=x)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var l=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var s=Math.max(Math.abs(l[0]),Math.abs(l[1])),c=Math.floor(Math.log(s)/Math.LN10+.01);Math.abs(c)>3&&(V(t.exponentformat)&&!U(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function H(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}M.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=l.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,r=n(10),t.dtick="M"+12*j(e,r,P)):i>v?(e/=v,t.dtick="M"+j(e,1,z)):i>y?(t.dtick=j(e,y,R),t.tick0=l.dateTick0(t.calendar,!0)):i>m?t.dtick=j(e,m,z):i>x?t.dtick=j(e,x,E):i>b?t.dtick=j(e,b,E):(r=n(10),t.dtick=j(e,r,P))}else if("log"===t.type){t.tick0=0;var o=l.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var s=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/s,r=n(10),t.dtick="L"+j(e,r,P)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type||"multicategory"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):et(t)?(t.tick0=0,r=1,t.dtick=j(e,r,F)):(t.tick0=0,r=n(10),t.dtick=j(e,r,P));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},M.tickIncrement=function(t,e,r,i){var o=r?-1:1;if(a(e))return t+o*e;var s=e.charAt(0),c=o*Number(e.substr(1));if("M"===s)return l.incrementMonth(t,c,i);if("L"===s)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===s){var u="D2"===e?N:I,f=t+.01*o,d=l.roundUp(l.mod(f,1),u,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(e)},M.tickFirst=function(t){var e=t.r2l||Number,r=l.simpleMap(t.range,e),i=r[1]"+s,t._prevDateHead=s));e.text=c}(t,i,r,s):"log"===c?function(t,e,r,n,i){var o=t.dtick,s=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===i&&(i="");n&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,s),t,i,n);else if(a(o)||"D"===u&&l.mod(s+.01,1)<.1){var f=Math.round(s),d=Math.abs(f),p=t.exponentformat;"power"===p||V(p)&&U(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+d+"",e.fontSize*=1.25):("e"===p||"E"===p)&&d>2?e.text="1"+p+(f>0?"+":_)+d:(e.text=G(Math.pow(10,s),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,l.mod(s,1)))),e.fontSize*=.75}if("D1"===t.dtick){var h=String(e.text).charAt(0);"0"!==h&&"1"!==h||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(s<0?.5:.25)))}}(t,i,0,s,h):"category"===c?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,i):"multicategory"===c?function(t,e,r){var n=Math.round(e.x),a=t._categories[n]||[],i=void 0===a[1]?"":String(a[1]),o=void 0===a[0]?"":String(a[0]);r?e.text=o+" - "+i:(e.text=i,e.text2=o)}(t,i,r):et(t)?function(t,e,r,n,a){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,a,n);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,a=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/a),Math.round(r/a)]}(i);if(o[1]>=100)e.text=G(l.deg2rad(e.x),t,a,n);else{var s=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),s&&(e.text=_+e.text)}}}}(t,i,r,s,h):function(t,e,r,n,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,n)}(t,i,0,s,h),t.tickprefix&&!p(t.showtickprefix)&&(i.text=t.tickprefix+i.text),t.ticksuffix&&!p(t.showticksuffix)&&(i.text+=t.ticksuffix),"boundaries"===t.tickson||t.showdividers){var g=function(e){var r=t.l2p(e);return r>=0&&r<=t._length?e:null};i.xbnd=[g(i.x-.5),g(i.x+t.dtick-.5)]}return i},M.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return M.hoverLabelText(t,e)+" - "+M.hoverLabelText(t,r);var n="log"===t.type&&e<=0,a=M.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+a:a};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function V(t){return"SI"===t||"B"===t}function U(t){return t>14||t<-15}function G(t,e,r,n){var i=t<0,o=e._tickround,s=r||e.exponentformat||"B",c=e._tickexponent,u=M.getTickFormat(e),f=e.separatethousands;if(n){var d={exponentformat:s,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};B(d),o=(Number(d._tickround)||0)+4,c=d._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,h=Math.pow(10,-o)/2;if("none"===s&&(c=0),(t=Math.abs(t))"+p+"":"B"===s&&9===c?t+="B":V(s)&&(t+=q[c/3+5]));return i?_+t:t}function X(t,e){var r=t._id.charAt(0),n=t._tickAngles[e]||0,a=l.deg2rad(n),i=Math.sin(a),o=Math.cos(a),s=0,c=0;return t._selections[e].each(function(){var t=W(this),e=f.bBox(t.node()),r=e.width,n=e.height;s=Math.max(s,o*r,i*n),c=Math.max(c,i*r,o*n)}),{x:c,y:s}[r]}function Y(t){return[t.text,t.x,t.axInfo,t.font,t.fontSize,t.fontColor].join("_")}function Z(t,e){var r=t.l2p(e);return r>1&&r=0,i=u(t,e[1])<=0;return(r||a)&&(n||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},l=0;l2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":243,"./constants":209}],207:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var l,s=r("categoryorder",a);"array"===s&&(l=r("categoryarray")),o||"array"!==s||(s=e.categoryorder="trace"),"trace"===s?e._initialCategories=[]:"array"===s?e._initialCategories=l.slice():(l=function(t,e){var r,n,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;nl*x)||k)for(r=0;rz&&ID&&(D=I);p/=(D-O)/(2*P),O=u.l2r(O),D=u.l2r(D),u.range=u._input.range=L=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function E(t,e,r,n,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",a+"Z")}function R(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function I(t,e,r,n,a,i){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),N(t,e,a,i)}function N(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function j(t){L&&t.data&&t._context.showTips&&(l.notifier(l._(t,"Double-click to zoom back out"),"long"),L=!1)}function B(t){return"lasso"===t||"select"===t}function H(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,A)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(i){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function V(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,i,c,p,L,S){var N,U,G,X,Y,Z,W,J,$,Q,K,tt,et,rt,nt,at,it,ot,lt,st,ct,ut=t._fullLayout._zoomlayer,ft=L+S==="nsew",dt=1===(L+S).length;function pt(){if(N=e.xaxis,U=e.yaxis,$=N._length,Q=U._length,W=N._offset,J=U._offset,(G={})[N._id]=N,(X={})[U._id]=U,L&&S)for(var r=e.overlays,n=0;n-1&&w(a,t,Y,Z,e.id,At),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===r&&dt){var l=L?U:N,c="s"===L||"w"===S?0:1,u=l._name+".range["+c+"]",d=function(t,e){var r,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,a))):(r=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,n.format("."+String(r)+"g")(a))}(l,c),p="left",h="middle";if(l.fixedrange)return;L?(h="n"===L?"top":"bottom","right"===l.side&&(p="right")):"e"===S&&(p="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(s.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(d),fill:l.tickfont?l.tickfont.color:"#444",horizontalAlign:p,verticalAlign:h}).on("edit",function(e){var r=l.d2r(e);void 0!==r&&o.call("_guiRelayout",t,u,r)})}}function Ct(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min($,e+vt)),a=Math.max(0,Math.min(Q,r+yt)),i=Math.abs(n-vt),o=Math.abs(a-yt);function l(){wt="",mt.r=mt.l,mt.t=mt.b,Tt.attr("d","M0,0Z")}mt.l=Math.min(vt,n),mt.r=Math.max(vt,n),mt.t=Math.min(yt,a),mt.b=Math.max(yt,a),nt?i>A||o>A?(wt="xy",i/$>o/Q?(o=i*Q/$,yt>a?mt.t=yt-o:mt.b=yt+o):(i=o*$/Q,vt>n?mt.l=vt-i:mt.r=vt+i),Tt.attr("d",H(mt))):l():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Et);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var a,i=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=It.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(at){for(S||(s=.5),a=0;ag[1]-.01&&(e.domain=l),a.noneOrAll(t.domain,e.domain,l)}return r("layer"),e}},{"../../lib":159,"fast-isnumeric":10}],220:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*r;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":138}],221:[function(t,e,r){"use strict";var n=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),l=t("../../lib/polygon"),s=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),d=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),h=p.MINSELECT,g=l.filter,v=l.tester;function y(t){return t._id}function m(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h,g,v=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,m=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var x=function(t,e){var r,n,a=t[0],i=-1,o=[];for(n=0;n0?function(t,e){var r,n,a,i=[];for(a=0;a0&&i.push(r);if(1===i.length&&i[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=r.selectedpoints.length)>1)return!1}return 1===a}(l)&&(d=A(x))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",n)}function A(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,a=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function L(t,e,r){var n,i,o,l;for(n=0;n-1&&m(e,A,a.xaxes,a.yaxes,a.subplot,a,U),"event"===r&&A.emit("plotly_selected",void 0);o.click(A,e)})},a.doneFn=function(){X.remove(),s.done(Y).then(function(){s.clear(Y),a.gd.emit("plotly_selected",b),d&&a.selectionDefs&&(d.subtract=V,a.selectionDefs.push(d),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:C,selectOnClick:m}},{"../../components/color":43,"../../components/fx":82,"../../components/fx/helpers":78,"../../lib/clear_gl_canvases":148,"../../lib/polygon":171,"../../lib/throttle":181,"../../plot_api/subroutines":194,"../../registry":243,"./axis_ids":206,"./constants":209,polybooljs:17}],222:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,l=i.ms2DateTime,s=i.dateTime2ms,c=i.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,d=u.BADNUM,p=u.LOG_CLIP,h=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}function y(t){return null!=t}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function u(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],a=t.range[1];return.5*(n+a-2*p*Math.abs(n-a))}return d}function m(e,r,n){var o=s(e,n||t.calendar);if(o===d){if(!a(e))return d;e=+e;var l=Math.floor(10*i.mod(e+.05,1)),c=Math.round(e-l/10);o=s(new Date(c))+l/10}return o}function x(e,r,n){return l(e,r,n||t.calendar)}function b(e){return t._categories[Math.round(e)]}function _(e){if(y(e)){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return d}function w(e){if(t._categoriesMap)return t._categoriesMap[e]}function k(t){var e=w(t);return void 0!==e?e:a(t)?+t:void 0}function T(e){return a(e)?n.round(t._b+t._m*e,2):d}function M(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=T,t.p2l=M,t.c2p="log"===t.type?function(t,e){return T(u(t,e))}:T,t.p2c="log"===t.type?function(t){return v(M(t))}:M,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=M,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(M(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=M,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=m,t.c2d=t.c2r=t.l2d=t.l2r=x,t.d2p=t.r2p=function(e,r,n){return t.l2p(m(e,0,n))},t.p2d=t.p2r=function(t,e,r){return x(M(t),e,r)},t.cleanPos=function(e){return i.cleanDate(e,d,t.calendar)}):"category"===t.type?(t.d2c=t.d2l=_,t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var r=k(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(M(t))},t.r2p=t.d2p,t.p2r=M,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}):"multicategory"===t.type&&(t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var r=k(e);return void 0!==r?r:t.fraction2r(.5)},t.r2c_just_indices=w,t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(M(t))},t.r2p=t.d2p,t.p2r=M,t.cleanPos=function(t){return Array.isArray(t)||"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,l,s=i.nestedProperty(t,e).get();if(l=(l="date"===t.type?i.dfltRange(t.calendar):"y"===r?h.DFLTRANGEY:n.dfltRange||h.DFLTRANGEX).slice(),s&&2===s.length)for("date"===t.type&&(s[0]=i.cleanDate(s[0],d,t.calendar),s[1]=i.cleanDate(s[1],d,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(s[o],t.calendar)){t[e]=l;break}if(t.r2l(s[0])===t.r2l(s[1])){var c=i.constrain(t.r2l(s[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);s[0]=t.l2r(c-1e3),s[1]=t.l2r(c+1e3);break}}else{if(!a(s[o])){if(!a(s[1-o])){t[e]=l;break}s[o]=s[1-o]*(o?10:.1)}if(s[o]<-f?s[o]=-f:s[o]>f&&(s[o]=f),s[0]===s[1]){var u=Math.max(1,Math.abs(1e-6*s[0]));s[0]-=u,s[1]+=u}}else i.nestedProperty(t,e).set(l)},t.setScale=function(n){var a=e._size;if(t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=n&&t._r?"_r":"range",l=t.calendar;t.cleanRange(o);var s=t.r2l(t[o][0],l),c=t.r2l(t[o][1],l);if("y"===r?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-c),t._b=-t._m*c):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,a,o,l,s=t.type,c="date"===s&&e[r+"calendar"];if(r in e){if(n=e[r],l=e._length||i.minRowLength(n),i.isTypedArray(n)&&("linear"===s||"log"===s)){if(l===n.length)return n;if(n.subarray)return n.subarray(0,l)}if("multicategory"===s)return function(t,e){var r,n=new Array(e),a=new Array(e),o=[[0,{}],[0,{}]];if(i.isArrayOrTypedArray(t[0])&&i.isArrayOrTypedArray(t[1])){for(r=0;r rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,r._offset).call(i.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(i.setPointGroupScale,1,1),n.selectAll(".textpoint").call(i.setTextPointsScale,1,1),n.call(i.hideOutsideRangePoints,t)}function x(e,r){var n,l,s,u=g[e.xaxis._id],f=g[e.yaxis._id],d=[];if(u){l=(n=t._fullLayout[u.axisName])._r,s=u.to,d[0]=(l[0]*(1-r)+r*s[0]-l[0])/(l[1]-l[0])*e.xaxis._length;var p=l[1]-l[0],h=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[2]=e.xaxis._length*(1-r+r*h/p)}else d[0]=0,d[2]=e.xaxis._length;if(f){l=(n=t._fullLayout[f.axisName])._r,s=f.to,d[1]=(l[1]*(1-r)+r*s[1]-l[1])/(l[0]-l[1])*e.yaxis._length;var v=l[1]-l[0],y=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[3]=e.yaxis._length*(1-r+r*y/v)}else d[1]=0,d[3]=e.yaxis._length;!function(e,r){var n,i=[e._id,r._id];function l(e,r,a){for(n=0;nr.duration?(function(){for(var e={},r=0;r0&&(a["_"+r+"axes"]||{})[e])return a;if((a[r+"axis"]||r)===e){if(o(a,r))return a;if((a[r]||[]).length||a[r+"0"])return a}}}(e,r,l);if(!s)return;if("histogram"===s.type&&l==={v:"y",h:"x"}[s.orientation||"v"])return void(t.type="linear");var c,u=l+"calendar",f=s[u],d={noMultiCategory:!n(s,"cartesian")||n(s,"noMultiCategory")};if(o(s,l)){var p=i(s),h=[];for(c=0;c0?".":"")+i;a.isPlainObject(o)?s(o,e,l,n+1):e(l,i,o)}})}r.manageCommandObserver=function(t,e,n,o){var l={},s=!0;e&&e._commandObserver&&(l=e._commandObserver),l.cache||(l.cache={}),l.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,n,l.lookupTable);if(e&&e._commandObserver){if(c)return l;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,l}if(c){i(t,c,l.cache),l.check=function(){if(s){var e=i(t,c,l.cache);return e.changed&&o&&void 0!==l.lookupTable[e.value]&&(l.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:l.lookupTable[e.value]})).then(l.enable,l.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;f=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),r.attr(i);var o=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),a=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+a})}}(t,o),l.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),a=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,a={};function o(t){for(var r=!0,i=0;i1&&z.length>1){for(i.getComponentMethod("grid","sizeDefaults")(c,l),o=0;o15&&z.length>15&&0===l.shapes.length&&0===l.images.length,l._hasCartesian=l._has("cartesian"),l._hasGeo=l._has("geo"),l._hasGL3D=l._has("gl3d"),l._hasGL2D=l._has("gl2d"),l._hasTernary=l._has("ternary"),l._hasPie=l._has("pie"),v.linkSubplots(f,l,u,a),v.cleanPlot(f,l,u,a),h(l,a),l._preGUI||(l._preGUI={}),l._tracePreGUI||(l._tracePreGUI={});var F,j=l._tracePreGUI,B={};for(F in j)B[F]="old";for(o=0;o0){var f=1-2*l;n=Math.round(f*n),i=Math.round(f*i)}}var d=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-i)>1;(g||h)&&(h&&(r.width=n),g&&(r.height=i)),t._initialAutoSize||(t._initialAutoSize={width:n,height:i}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var a,o,l,c=i.componentsRegistry,u=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in c)(l=c[a]).includeBasePlot&&l.includeBasePlot(t,e);for(var d in u.length||u.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[d].sort(s.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var s=void 0!==r.xl?r.xl:r.x,c=void 0!==r.xr?r.xr:r.x,u=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;a[e]={l:{val:s,size:r.l+o},r:{val:c,size:r.r+o},b:{val:f,size:r.b+o},t:{val:u,size:r.t+o}},i[e]=1}else delete a[e],delete i[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),A(e);var r=e._size,n=JSON.stringify(r),o=e.margin,l=o.l,s=o.r,c=o.t,u=o.b,f=e._pushmargin,d=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var p in f)d[p]||delete f[p];for(var h in f.base={l:{val:0,size:l},r:{val:1,size:s},t:{val:1,size:c},b:{val:0,size:u}},f){var g=f[h].l||{},v=f[h].b||{},y=g.val,m=g.size,x=v.val,b=v.size;for(var _ in f){if(a(m)&&f[_].r){var w=f[_].r.val,k=f[_].r.size;if(w>y){var T=(m*w+(k-e.width)*y)/(w-y),M=(k*(1-y)+(m-e.width)*(1-w))/(w-y);T>=0&&M>=0&&T+M>l+s&&(l=T,s=M)}}if(a(b)&&f[_].t){var L=f[_].t.val,S=f[_].t.size;if(L>x){var C=(b*L+(S-e.height)*x)/(L-x),O=(S*(1-x)+(b-e.height)*(1-L))/(L-x);C>=0&&O>=0&&C+O>u+c&&(u=C,c=O)}}}}}if(r.l=Math.round(l),r.r=Math.round(s),r.t=Math.round(c),r.b=Math.round(u),r.p=Math.round(o.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,r,n,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,l=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(s.isPlainObject(t)){var e,n,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!s.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;a[e]=c(t[e])}return a}return Array.isArray(t)?t.map(c):s.isTypedArray(t)?s.simpleMap(t,s.identity):s.isJSDate(t)?s.ms2DateTimeLocal(+t):t}var u={data:(i||[]).map(function(t){var r=c(t);return e&&delete r.fit,r})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),l&&(u.frames=c(l)),"object"===n?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var r,n,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,l,c=0,u=0;function f(){return c++,function(){var r;u++,p||u!==c||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var h=t._fullLayout._basePlotModules,g=!1;if(r)for(l=0;l=0;l--)if(o[l].enabled){r._indexToPoints=o[l]._indexToPoints;break}n&&n.calc&&(i=n.calc(t,r))}Array.isArray(i)&&i[0]||(i=[{x:u,y:u}]),i[0].t||(i[0].t={}),i[0].trace=r,h[e]=i}}for(m&&L(c),a=0;a=0?d.angularAxis.domain:n.extent(k),S=Math.abs(k[1]-k[0]);M&&!T&&(S=0);var C=L.slice();A&&T&&(C[1]+=S);var O=d.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),d.angularAxis.ticksStep&&(O=(C[1]-C[0])/O);var D=d.angularAxis.ticksStep||(C[1]-C[0])/(O*(d.minorTicks+1));w&&(D=Math.max(Math.round(D),1)),C[2]||(C[2]=D);var P=n.range.apply(this,C);if(P=P.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=n.scale.linear().domain(C.slice(0,2)).range("clockwise"===d.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=A?S:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var z=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),E=this.appendChild(this.ownerDocument.importNode(z.documentElement,!0));t=n.select(E)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var R,I=t.select(".chart-group"),N={fill:"none",stroke:d.tickColor},F={"font-size":d.font.size,"font-family":d.font.family,fill:d.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+d.font.outlineColor}).join(",")};if(d.showLegend){R=t.select(".legend-group").attr({transform:"translate("+[x,d.margin.top]+")"}).style({display:"block"});var j=p.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:R,elements:j,reverseOrder:d.legend.reverseOrder})})();var B=R.node().getBBox();x=Math.min(d.width-B.width-d.margin.left-d.margin.right,d.height-d.margin.top-d.margin.bottom)/2,x=Math.max(10,x),_=[d.margin.left+x,d.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),R.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else R=t.select(".legend-group").style({display:"none"});t.attr({width:d.width,height:d.height}).style({opacity:d.opacity}),I.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(d.width-(d.margin.left+d.margin.right+2*x+(B?B.width:0)))/2,(d.height-(d.margin.top+d.margin.bottom+2*x))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),t.select(".outer-group").attr("transform","translate("+H+")"),d.title&&d.title.text){var q=t.select("g.title-group text").style(F).text(d.title.text),V=q.node().getBBox();q.attr({x:_[0]-V.width/2,y:_[1]-x-20})}var U=t.select(".radial.axis-group");if(d.radialAxis.gridLinesVisible){var G=U.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(N),G.attr("r",r),G.exit().remove()}U.select("circle.outside-circle").attr({r:x}).style(N);var X=t.select("circle.background-circle").attr({r:x}).style({fill:d.backgroundColor,stroke:d.stroke});function Y(t,e){return l(t)%360+d.orientation}if(d.radialAxis.visible){var Z=n.svg.axis().scale(r).ticks(5).tickSize(5);U.call(Z).attr({transform:"rotate("+d.radialAxis.orientation+")"}),U.selectAll(".domain").style(N),U.selectAll("g>text").text(function(t,e){return this.textContent+d.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===d.radialAxis.tickOrientation?"rotate("+-d.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),U.selectAll("g>line").style({stroke:"black"})}var W=t.select(".angular.axis-group").selectAll("g.angular-tick").data(P),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+Y(t)+")"}}).style({display:d.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(d.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(d.minorTicks+1)==0)}).style(N),J.selectAll(".minor").style({stroke:d.minorTickColor}),W.select("line.grid-line").attr({x1:d.tickLength?x-d.tickLength:0,x2:x}).style({display:d.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(F);var $=W.select("text.axis-text").attr({x:x+d.labelOffset,dy:i+"em",transform:function(t,e){var r=Y(t),n=x+d.labelOffset,a=d.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-r+" "+n+" 0)":"radial"==a?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:d.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(d.minorTicks+1)!=0?"":w?w[t]+d.angularAxis.ticksSuffix:t+d.angularAxis.ticksSuffix}).style(F);d.angularAxis.rewriteTicks&&$.text(function(t,e){return e%(d.minorTicks+1)!=0?"":d.angularAxis.rewriteTicks(this.textContent,e)});var Q=n.max(I.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));R.attr({transform:"translate("+[x+Q,d.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||K){var et=[];p.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=d.orientation,n.direction=d.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return a(o[r].defaultConfig(),t)});o[r]().config(n)()})}var at,it,ot=t.select(".guides-group"),lt=t.select(".tooltips-group"),st=o.tooltipPanel().config({container:lt,fontSize:8})(),ct=o.tooltipPanel().config({container:lt,fontSize:8})(),ut=o.tooltipPanel().config({container:lt,hasTick:!0})();if(!T){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});I.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(X).angle;ft.attr({x2:-x,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-d.orientation)%360;at=l.invert(n);var a=o.util.convertToCartesian(x+12,r+180);st.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var dt=ot.select("circle").style({stroke:"grey",fill:"none"});I.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(X).radius;dt.attr({r:n}).style({opacity:.5}),it=r.invert(o.util.getMousePos(X).radius);var a=o.util.convertToCartesian(n,d.radialAxis.orientation);ct.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){dt.style({opacity:0}),ut.hide(),st.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var a=n.select(this),i=this.style.fill,l="black",s=this.style.opacity||1;if(a.attr({"data-opacity":s}),i&&"none"!==i){a.attr({"data-fill":i}),l=n.hsl(i).darker().toString(),a.style({fill:l,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};T&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=t.node().getBoundingClientRect(),p=[f.left+f.width/2-H[0]-d.left,f.top+f.height/2-H[1]-d.top];ut.config({color:l}).text(u),ut.move(p)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),l=n.hsl(i).darker().toString(),a.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var r=n.select(this),a=r.attr("data-fill");a?r.style({fill:a,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(c),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),a(s.data[e],o.Axis.defaultConfig().data[0]),a(s.data[e],t)}),a(s.layout,o.Axis.defaultConfig().layout),a(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return t},n.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var a=e||6,i=[],o=[];n.range(0,360+a,a).forEach(function(e,r){var n=e*Math.PI/180,a=t(n);i.push(e),o.push(a)});var l={t:i,r:o};return r&&(l.name=r),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],a=e[1],i={};return i.x=r,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,r)+Math.PI)/Math.PI,i.radius=Math.sqrt(r*r+a*a),i},o.util.duplicatesCount=function(t){for(var e,r={},n={},a=0,i=t.length;a0)){var s=n.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({class:"line",d:u(l),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return h.fill(r,a,i)},"fill-opacity":0,stroke:function(t,e){return h.stroke(r,a,i)},"stroke-width":function(t,e){return h["stroke-width"](r,a,i)},"stroke-dasharray":function(t,e){return h["stroke-dasharray"](r,a,i)},opacity:function(t,e){return h.opacity(r,a,i)},display:function(t,e){return h.display(r,a,i)}})}};var f=e.angularScale.range(),d=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=n.svg.arc().startAngle(function(t){return-d/2}).endAngle(function(t){return d/2}).innerRadius(function(t){return e.radialScale(s+(t[2]||0))}).outerRadius(function(t){return e.radialScale(s+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,r,a){n.select(this).attr({class:"mark arc",d:p,transform:function(t,r){return"rotate("+(e.orientation+l(t[0])+90)+")"}})};var h={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,a){return r[t[a].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(h).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),a(t[r],o.PolyChart.defaultConfig()),a(t[r],e)}),this):t},i.getColorScale=function(){},n.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,i=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var i=a({},e.elements[r]);return i.name=t,i.color=[].concat(e.elements[r].color)[n],i})}),o=n.merge(i);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var l=e.container;("string"==typeof l||l.nodeName)&&(l=n.select(l));var s=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,d=l.classed("legend-group",!0).selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var h=n.range(o.length),g=n.scale[u?"linear":"ordinal"]().domain(h).range(s),v=n.scale[u?"linear":"ordinal"]().domain(h)[u?"range":"rangePoints"]([0,f]);if(u){var y=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var m=d.select(".legend-marks").selectAll("path.legend-mark").data(o);m.enter().append("path").classed("legend-mark",!0),m.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var r,a,i,o=t.symbol;return i=3*(a=c),"line"===(r=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(i)():n.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),m.exit().remove()}var x=n.svg.axis().scale(v).orient("right"),b=d.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(a(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){var n=(t=i.container.selectAll("g."+l).data([0])).enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:i.padding+s,dy:.3*+i.fontSize}),c};return c.text=function(a){var o=n.hsl(i.color).l,l=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":i.fontSize+"px"}).text(f);var d=i.padding,p=e.node().getBBox(),h={fill:i.color,stroke:l,"stroke-width":"2px"},g=p.width+2*d+s,v=p.height+2*d;return r.attr({d:"M"+[[s,-v/2],[s,-v/4],[i.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(h),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return a(i,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=a({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=i.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var l=a({},t.layout);if([[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var s=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(l.margin).forEach(function(t,e){u[c[s.indexOf(t.key)]]=t.value}),l.margin=u}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),r.layout=l}return r}};return t}},{"../../../constants/alignment":138,"../../../lib":159,d3:8}],241:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),l=t("./undo_manager"),s=a.extendDeepAll,c=e.exports={};c.framework=function(t){var e,r,a,i,u,f=new l;function d(r,l){return l&&(u=l),n.select(n.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?s(e,r):r,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return d.isPolar=!0,d.svg=function(){return a.svg()},d.getConfig=function(){return e},d.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},d.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},d.setUndoPoint=function(){var t,n,a=this,i=o.util.cloneJson(e);t=i,n=r,f.add({undo:function(){n&&a(n)},redo:function(){a(t)}}),r=o.util.cloneJson(i)},d.undo=function(){f.undo()},d.redo=function(){f.redo()},d},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../../components/color":43,"../../../lib":159,"./micropolar":240,"./undo_manager":242,d3:8}],242:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function a(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(a(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(a(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r-1&&(u[d[r]].title={text:""});for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(s,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(s,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||d.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),d.node().setAttributeNS(l.xmlns,"xmlns",l.svg),d.node().setAttributeNS(l.xmlns,"xmlns:xlink",l.xlink),"svg"===e&&r&&(d.attr("width",r*h),d.attr("height",r*g),d.attr("viewBox","0 0 "+h+" "+g));var _=(new window.XMLSerializer).serializeToString(d.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":43,"../components/drawing":64,"../constants/xmlns_namespaces":141,"../lib":159,d3:8}],252:[function(t,e,r){"use strict";var n=t("../../lib").mergeArray;e.exports=function(t,e){for(var r=0;rf+c||!n(u))&&(p=!0,g(d,t))}for(var v=0;vi))return e}return void 0!==r?r:t.dflt},r.coerceColor=function(t,e,r){return a(e).isValid()?e:void 0!==r?r:t.dflt},r.coerceEnumerated=function(t,e,r){return t.coerceNumber&&(e=+e),-1!==t.values.indexOf(e)?e:void 0!==r?r:t.dflt},r.getValue=function(t,e){var r;return Array.isArray(t)?e.01?C:function(t,e){return Math.abs(t-e)>=2?C(t):t>e?Math.ceil(t):Math.floor(t)};_=S(_,w),w=S(w,_),k=S(k,T),T=S(T,k)}i.ensureSingle(M,"path").style("vector-effect","non-scaling-stroke").attr("d","M"+_+","+k+"V"+T+"H"+w+"V"+k+"Z").call(s.setClipUrl,e.layerClipId,t),function(t,e,r,n,a,l,c,u){var y;function m(e,r,n){var a=i.ensureSingle(e,"text").text(r).attr({class:"bartext bartext-"+y,transform:"","text-anchor":"middle","data-notex":1}).call(s.font,n).call(o.convertToTspans,t);return a}var x=r[0].trace,b=x.orientation,_=function(t,e){var r=p.getValue(t.text,e);return p.coerceString(f,r)}(x,n);if(y=function(t,e){var r=p.getValue(t.textposition,e);return p.coerceEnumerated(d,r)}(x,n),!_||"none"===y)return void e.select("text").remove();var w,k,T,M,A,L,S=t._fullLayout.font,C=h.getBarColor(r[n],x),O=h.getInsideTextFont(x,n,S,C),D=h.getOutsideTextFont(x,n,S),P=t._fullLayout.barmode,z="relative"===P,E="stack"===P||z,R=r[n],I=!E||R._outmost,N=Math.abs(l-a)-2*g,F=Math.abs(u-c)-2*g;"outside"===y&&(I||R.hasB||(y="inside"));if("auto"===y)if(I){y="inside",w=m(e,_,O),k=s.bBox(w.node()),T=k.width,M=k.height;var j=T>0&&M>0,B=T<=N&&M<=F,H=T<=F&&M<=N,q="h"===b?N>=T*(F/M):F>=M*(N/T);j&&(B||H||q)?y="inside":(y="outside",w.remove(),w=null)}else y="inside";if(!w&&(w=m(e,_,"outside"===y?D:O),k=s.bBox(w.node()),T=k.width,M=k.height,T<=0||M<=0))return void w.remove();"outside"===y?(L="both"===x.constraintext||"outside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s="h"===i?Math.abs(n-r):Math.abs(e-t);s>2*g&&(l=g);var c=1;o&&(c="h"===i?Math.min(1,s/a.height):Math.min(1,s/a.width));var u,f,d,p,h=(a.left+a.right)/2,y=(a.top+a.bottom)/2;u=c*a.width,f=c*a.height,"h"===i?er?(d=(t+e)/2,p=n+l+f/2):(d=(t+e)/2,p=n-l-f/2);return v(h,y,d,p,c,!1)}(a,l,c,u,k,b,L)):(L="both"===x.constraintext||"inside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h=a.width,y=a.height,m=(a.left+a.right)/2,x=(a.top+a.bottom)/2,b=Math.abs(e-t),_=Math.abs(n-r);b>2*g&&_>2*g?(b-=2*(f=g),_-=2*f):f=0;h<=b&&y<=_?(d=!1,p=1):h<=_&&y<=b?(d=!0,p=1):hr?(c=(t+e)/2,u=n-f-s/2):(c=(t+e)/2,u=n+f+s/2);return v(m,x,c,u,p,d)}(a,l,c,u,k,b,L));w.attr("transform",A)}(t,M,r,u,_,w,k,T),e.layerClipId&&s.hideOutsideRangePoint(c,M.select("text"),y,m,b.xcalendar,b.ycalendar)}else M.remove();function C(t){return 0===x.bargap&&0===x.bargroupgap?n.round(Math.round(t)-L,2):t}});var w=!1===u.trace.cliponaxis;s.setClipUrl(c,w?null:e.layerClipId,t)});c.getComponentMethod("errorbars","plot")(t,b,e)}},{"../../components/color":43,"../../components/drawing":64,"../../lib":159,"../../lib/svg_text_utils":180,"../../registry":243,"./attributes":253,"./helpers":258,"./style":266,d3:8,"fast-isnumeric":10}],264:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,a=t.xaxis,i=t.yaxis,o=[];if(!1===e)for(r=0;r1||0===i.bargap&&0===i.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),r.selectAll("g.points").each(function(e){p(n.select(this),e[0].trace,t)}),l.getComponentMethod("errorbars","style")(r)},styleOnSelect:function(t,e){var r=e[0].node3,a=e[0].trace;a.selectedpoints?function(t,e,r){i.selectedPointStyle(t.selectAll("path"),e),function(t,e,r){t.each(function(t){var a,l=n.select(this);if(t.selected){a=o.extendFlat({},h(l,t,e,r));var s=e.selected.textfont&&e.selected.textfont.color;s&&(a.color=s),i.font(l,a)}else i.selectedTextStyle(l,e)})}(t.selectAll("text"),e,r)}(r,a,t):p(r,a,t)},getInsideTextFont:v,getOutsideTextFont:y,getBarColor:x}},{"../../components/color":43,"../../components/drawing":64,"../../lib":159,"../../registry":243,"./attributes":253,"./helpers":258,d3:8}],267:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l){r("marker.color",o),a(t,"marker")&&i(t,e,l,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),a(t,"marker.line")&&i(t,e,l,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54}],268:[function(t,e,r){"use strict";var n=t("../../components/color/attributes"),a=t("../../plots/font_attributes"),i=t("../../plots/attributes"),o=t("../../components/fx/hovertemplate_attributes"),l=t("../../plots/domain").attributes,s=t("../../lib/extend").extendFlat,c=a({editType:"calc",arrayOk:!0,colorEditType:"plot"});e.exports={labels:{valType:"data_array",editType:"calc"},label0:{valType:"number",dflt:0,editType:"calc"},dlabel:{valType:"number",dflt:1,editType:"calc"},values:{valType:"data_array",editType:"calc"},marker:{colors:{valType:"data_array",editType:"calc"},line:{color:{valType:"color",dflt:n.defaultLine,arrayOk:!0,editType:"style"},width:{valType:"number",min:0,dflt:0,arrayOk:!0,editType:"style"},editType:"calc"},editType:"calc"},text:{valType:"data_array",editType:"calc"},hovertext:{valType:"string",dflt:"",arrayOk:!0,editType:"style"},scalegroup:{valType:"string",dflt:"",editType:"calc"},textinfo:{valType:"flaglist",flags:["label","text","value","percent"],extras:["none"],editType:"calc"},hoverinfo:s({},i.hoverinfo,{flags:["label","text","value","percent","name"]}),hovertemplate:o({},{keys:["label","color","value","percent","text"]}),textposition:{valType:"enumerated",values:["inside","outside","auto","none"],dflt:"auto",arrayOk:!0,editType:"calc"},textfont:s({},c,{}),insidetextfont:s({},c,{}),outsidetextfont:s({},c,{}),title:{text:{valType:"string",dflt:"",editType:"calc"},font:s({},c,{}),position:{valType:"enumerated",values:["top left","top center","top right","middle center","bottom left","bottom center","bottom right"],editType:"calc"},editType:"calc"},domain:l({name:"pie",trace:!0,editType:"calc"}),hole:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},sort:{valType:"boolean",dflt:!0,editType:"calc"},direction:{valType:"enumerated",values:["clockwise","counterclockwise"],dflt:"counterclockwise",editType:"calc"},rotation:{valType:"number",min:-360,max:360,dflt:0,editType:"calc"},pull:{valType:"number",min:0,max:1,dflt:0,arrayOk:!0,editType:"calc"},_deprecated:{title:{valType:"string",dflt:"",editType:"calc"},titlefont:s({},c,{}),titleposition:{valType:"enumerated",values:["top left","top center","top right","middle center","bottom left","bottom center","bottom right"],editType:"calc"}}}},{"../../components/color/attributes":42,"../../components/fx/hovertemplate_attributes":81,"../../lib/extend":153,"../../plots/attributes":200,"../../plots/domain":229,"../../plots/font_attributes":230}],269:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/get_data").getModuleCalcData;r.name="pie",r.plot=function(t){var e=n.getModule("pie"),r=a(t.calcdata,e)[0];r.length&&e.plot(t,r)},r.clean=function(t,e,r,n){var a=n._has&&n._has("pie"),i=e._has&&e._has("pie");a&&!i&&n._pielayer.selectAll("g.trace").remove()}},{"../../plots/get_data":232,"../../registry":243}],270:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib").isArrayOrTypedArray,i=t("tinycolor2"),o=t("../../components/color"),l=t("./helpers");r.calc=function(t,e){var r,s,c,u,f,d=e.values,p=a(d)&&d.length,h=e.labels,g=e.marker.colors||[],v=[],y=t._fullLayout,m=y._piecolormap,x={},b=0,_=y.hiddenlabels||[];if(e.dlabel)for(h=new Array(d.length),r=0;r")}}return v},r.crossTraceCalc=function(t){var e=t._fullLayout,r=t.calcdata,n=e.piecolorway,a=e._piecolormap;e.extendpiecolors&&(n=function(t){var e,r=JSON.stringify(t),n=s[r];if(!n){for(n=t.slice(),e=0;e0?1:-1)/2,y:i/(1+r*r/(n*n)),outside:!0}}function p(t,e){var r=t.trace,n=e.h*(r.domain.y[1]-r.domain.y[0]);return Math.min(t.titleBox.height,n/2)}function h(t){var e,r=t.pull;if(Array.isArray(r))for(r=0,e=0;er&&(r=t.pull[e]);return r}e.exports=function(t,e){var r=t._fullLayout;!function(t,e){for(var r,n,a=0;aa.vTotal/2?1:0)}(e),g.attr("stroke-linejoin","round"),g.each(function(){var g=n.select(this).selectAll("g.slice").data(e);g.enter().append("g").classed("slice",!0),g.exit().remove();var m=[[[],[]],[[],[]]],x=!1;g.each(function(e){if(e.hidden)n.select(this).selectAll("path,g").remove();else{e.pointNumber=e.i,e.curveNumber=y.index,m[e.pxmid[1]<0?0:1][e.pxmid[0]<0?0:1].push(e);var p=v.cx,h=v.cy,g=n.select(this),b=g.selectAll("path.surface").data([e]),_=!1,w=!1;if(b.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),g.select("path.textline").remove(),g.on("mouseover",function(){var i=t._fullLayout,o=t._fullData[y.index];if(!t._dragging&&!1!==i.hovermode){var l=o.hoverinfo;if(Array.isArray(l)&&(l=a.castHoverinfo({hoverinfo:[c.castOption(l,e.pts)],_module:y._module},i,0)),"all"===l&&(l="label+text+value+percent+name"),o.hovertemplate||"none"!==l&&"skip"!==l&&l){var s=f(e,v),d=p+e.pxmid[0]*(1-s),g=h+e.pxmid[1]*(1-s),m=r.separators,x=[];if(l&&-1!==l.indexOf("label")&&x.push(e.label),e.text=c.castOption(o.hovertext||o.text,e.pts),l&&-1!==l.indexOf("text")){var b=e.text;b&&x.push(b)}e.value=e.v,e.valueLabel=c.formatPieValue(e.v,m),l&&-1!==l.indexOf("value")&&x.push(e.valueLabel),e.percent=e.v/v.vTotal,e.percentLabel=c.formatPiePercent(e.percent,m),l&&-1!==l.indexOf("percent")&&x.push(e.percentLabel);var k=y.hoverlabel,T=k.font;a.loneHover({x0:d-s*v.r,x1:d+s*v.r,y:g,text:x.join("
"),name:o.hovertemplate||-1!==l.indexOf("name")?o.name:void 0,idealAlign:e.pxmid[0]<0?"left":"right",color:c.castOption(k.bgcolor,e.pts)||e.color,borderColor:c.castOption(k.bordercolor,e.pts),fontFamily:c.castOption(T.family,e.pts),fontSize:c.castOption(T.size,e.pts),fontColor:c.castOption(T.color,e.pts),trace:o,hovertemplate:c.castOption(o.hovertemplate,e.pts),hovertemplateLabels:e,eventData:[u(e,o)]},{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:t}),_=!0}t.emit("plotly_hover",{points:[u(e,o)],event:n.event}),w=!0}}).on("mouseout",function(r){var i=t._fullLayout,o=t._fullData[y.index];w&&(r.originalEvent=n.event,t.emit("plotly_unhover",{points:[u(e,o)],event:n.event}),w=!1),_&&(a.loneUnhover(i._hoverlayer.node()),_=!1)}).on("click",function(){var r=t._fullLayout,i=t._fullData[y.index];t._dragging||!1===r.hovermode||(t._hoverdata=[u(e,i)],a.click(t,n.event))}),y.pull){var k=+c.castOption(y.pull,e.pts)||0;k>0&&(p+=k*e.pxmid[0],h+=k*e.pxmid[1])}e.cxFinal=p,e.cyFinal=h;var T=y.hole;if(e.v===v.vTotal){var M="M"+(p+e.px0[0])+","+(h+e.px0[1])+O(e.px0,e.pxmid,!0,1)+O(e.pxmid,e.px0,!0,1)+"Z";T?b.attr("d","M"+(p+T*e.px0[0])+","+(h+T*e.px0[1])+O(e.px0,e.pxmid,!1,T)+O(e.pxmid,e.px0,!1,T)+"Z"+M):b.attr("d",M)}else{var A=O(e.px0,e.px1,!0,1);if(T){var L=1-T;b.attr("d","M"+(p+T*e.px1[0])+","+(h+T*e.px1[1])+O(e.px1,e.px0,!1,T)+"l"+L*e.px0[0]+","+L*e.px0[1]+A+"Z")}else b.attr("d","M"+p+","+h+"l"+e.px0[0]+","+e.px0[1]+A+"Z")}var S=c.castOption(y.textposition,e.pts),C=g.selectAll("g.slicetext").data(e.text&&"none"!==S?[0]:[]);C.enter().append("g").classed("slicetext",!0),C.exit().remove(),C.each(function(){var r=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});r.text(e.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(o.font,"outside"===S?function(t,e,r){var n=c.castOption(t.outsidetextfont.color,e.pts)||c.castOption(t.textfont.color,e.pts)||r.color,a=c.castOption(t.outsidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,i=c.castOption(t.outsidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n,family:a,size:i}}(y,e,t._fullLayout.font):function(t,e,r){var n=c.castOption(t.insidetextfont.color,e.pts);!n&&t._input.textfont&&(n=c.castOption(t._input.textfont.color,e.pts));var a=c.castOption(t.insidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,o=c.castOption(t.insidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n||i.contrast(e.color),family:a,size:o}}(y,e,t._fullLayout.font)).call(s.convertToTspans,t);var a,u=o.bBox(r.node());"outside"===S?a=d(u,e):(a=function(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,i=Math.PI*Math.min(e.v/r.vTotal,.5),o=1-r.trace.hole,l=f(e,r),s={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(s.scale>=1)return s;var c=a+1/(2*Math.tan(i)),u=r.r*Math.min(1/(Math.sqrt(c*c+.5)+c),o/(Math.sqrt(a*a+o/2)+a)),d={scale:2*u/t.height,rCenter:Math.cos(u/r.r)-u*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},p=1/a,h=p+1/(2*Math.tan(i)),g=r.r*Math.min(1/(Math.sqrt(h*h+.5)+h),o/(Math.sqrt(p*p+o/2)+p)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},y=v.scale>d.scale?v:d;return s.scale<1&&y.scale>s.scale?y:s}(u,e,v),"auto"===S&&a.scale<1&&(r.call(o.font,y.outsidetextfont),y.outsidetextfont.family===y.insidetextfont.family&&y.outsidetextfont.size===y.insidetextfont.size||(u=o.bBox(r.node())),a=d(u,e)));var g=p+e.pxmid[0]*a.rCenter+(a.x||0),m=h+e.pxmid[1]*a.rCenter+(a.y||0);a.outside&&(e.yLabelMin=m-u.height/2,e.yLabelMid=m,e.yLabelMax=m+u.height/2,e.labelExtraX=0,e.labelExtraY=0,x=!0),r.attr("transform","translate("+g+","+m+")"+(a.scale<1?"scale("+a.scale+")":"")+(a.rotate?"rotate("+a.rotate+")":"")+"translate("+-(u.left+u.right)/2+","+-(u.top+u.bottom)/2+")")})}function O(t,r,n,a){return"a"+a*v.r+","+a*v.r+" 0 "+e.largeArc+(n?" 1 ":" 0 ")+a*(r[0]-t[0])+","+a*(r[1]-t[1])}});var b=n.select(this).selectAll("g.titletext").data(y.title.text?[0]:[]);b.enter().append("g").classed("titletext",!0),b.exit().remove(),b.each(function(){var e,a=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});a.text(y.title.text).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(o.font,y.title.font).call(s.convertToTspans,t),e="middle center"===y.title.position?function(t){var e=Math.sqrt(t.titleBox.width*t.titleBox.width+t.titleBox.height*t.titleBox.height);return{x:t.cx,y:t.cy,scale:t.trace.hole*t.r*2/e,tx:0,ty:-t.titleBox.height/2+t.trace.title.font.size}}(v):function(t,e){var r,n,a=1,i=1,o=t.trace,l={x:t.cx,y:t.cy},s={tx:0,ty:0};s.ty+=o.title.font.size,n=h(o),-1!==o.title.position.indexOf("top")?(l.y-=(1+n)*t.r,s.ty-=t.titleBox.height):-1!==o.title.position.indexOf("bottom")&&(l.y+=(1+n)*t.r);-1!==o.title.position.indexOf("left")?(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x-=(1+n)*t.r,s.tx+=t.titleBox.width/2):-1!==o.title.position.indexOf("center")?r=e.w*(o.domain.x[1]-o.domain.x[0]):-1!==o.title.position.indexOf("right")&&(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x+=(1+n)*t.r,s.tx-=t.titleBox.width/2);return a=r/t.titleBox.width,i=p(t,e)/t.titleBox.height,{x:l.x,y:l.y,scale:Math.min(a,i),tx:s.tx,ty:s.ty}}(v,r._size),a.attr("transform","translate("+e.x+","+e.y+")"+(e.scale<1?"scale("+e.scale+")":"")+"translate("+e.tx+","+e.ty+")")}),x&&function(t,e){var r,n,a,i,o,l,s,u,f,d,p,h,g;function v(t,e){return t.pxmid[1]-e.pxmid[1]}function y(t,e){return e.pxmid[1]-t.pxmid[1]}function m(t,r){r||(r={});var a,u,f,p,h,g,v=r.labelExtraY+(n?r.yLabelMax:r.yLabelMin),y=n?t.yLabelMin:t.yLabelMax,m=n?t.yLabelMax:t.yLabelMin,x=t.cyFinal+o(t.px0[1],t.px1[1]),b=v-y;if(b*s>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(u=0;u=(c.castOption(e.pull,f.pts)||0)||((t.pxmid[1]-f.pxmid[1])*s>0?(p=f.cyFinal+o(f.px0[1],f.px1[1]),(b=p-y-t.labelExtraY)*s>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-x)*s>0&&(a=3*l*Math.abs(u-d.indexOf(t)),h=f.cxFinal+i(f.px0[0],f.px1[0]),(g=h+a-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*l>0&&(t.labelExtraX+=g)))}for(n=0;n<2;n++)for(a=n?v:y,o=n?Math.max:Math.min,s=n?1:-1,r=0;r<2;r++){for(i=r?Math.max:Math.min,l=r?1:-1,(u=t[n][r]).sort(a),f=t[1-n][r],d=f.concat(u),h=[],p=0;pMath.abs(c)?o+="l"+c*t.pxmid[0]/t.pxmid[1]+","+c+"H"+(a+t.labelExtraX+l):o+="l"+t.labelExtraX+","+s+"v"+(c-s)+"h"+l}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+l;e.append("path").classed("textline",!0).call(i.stroke,y.outsidetextfont.color).attr({"stroke-width":Math.min(2,y.outsidetextfont.size/8),d:o,fill:"none"})}})})});setTimeout(function(){g.selectAll("tspan").each(function(){var t=n.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":43,"../../components/drawing":64,"../../components/fx":82,"../../lib":159,"../../lib/svg_text_utils":180,"./event_data":272,"./helpers":273,d3:8}],278:[function(t,e,r){"use strict";var n=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each(function(t){n.select(this).call(a,t,e)})})}},{"./style_one":279,d3:8}],279:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("./helpers").castOption;e.exports=function(t,e,r){var i=r.marker.line,o=a(i.color,e.pts)||n.defaultLine,l=a(i.width,e.pts)||0;t.style({"stroke-width":l}).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":43,"./helpers":273}],280:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rl&&M[v].gap;)v--;for(m=M[v].s,h=M.length-1;h>v;h--)M[h].s=m;for(;lA[u]&&u=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===r.xaxis&&i.yaxis===r.yaxis){i.opacity=void 0;break}}}}}},{}],288:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),l=t("./subtypes"),s=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),d=t("./line_shape_defaults"),p=t("./text_defaults"),h=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,a){return n.coerce(t,e,i,r,a)}var y=s(t,e,g,v);if(y||(e.visible=!1),e.visible){var m=c(t,e,g,v),x=!m&&yG!=(N=P[O][1])>=G&&(E=P[O-1][0],R=P[O][0],N-I&&(z=E+(R-E)*(G-I)/(N-I),H=Math.min(H,z),q=Math.max(q,z)));H=Math.max(H,0),q=Math.min(q,d._length);var X=l.defaultLine;return l.opacity(f.fillcolor)?X=f.fillcolor:l.opacity((f.line||{}).color)&&(X=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:H,x1:q,y0:G,y1:G,color:X,hovertemplate:"%{name}"}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":43,"../../components/fx":82,"../../lib":159,"../../registry":243,"./fill_hover_text":289,"./get_trace_color":291}],293:[function(t,e,r){"use strict";var n={},a=t("./subtypes");n.hasLines=a.hasLines,n.hasMarkers=a.hasMarkers,n.hasText=a.hasText,n.isBubble=a.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":215,"./arrays_to_calcdata":280,"./attributes":281,"./calc":282,"./cross_trace_calc":286,"./cross_trace_defaults":287,"./defaults":288,"./hover":292,"./marker_colorbar":299,"./plot":301,"./select":302,"./style":304,"./subtypes":305}],294:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l,s){var c=(t.marker||{}).color;(l("line.color",r),a(t,"line"))?i(t,e,o,l,{prefix:"line.",cLetter:"c",noScale:!0}):l("line.color",!n(c)&&c||r);l("line.width"),(s||{}).noDash||l("line.dash")}},{"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54,"../../lib":159}],295:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),a=n.BADNUM,i=n.LOG_CLIP,o=i+.5,l=i-.5,s=t("../../lib"),c=s.segmentsIntersect,u=s.constrain,f=t("./constants");e.exports=function(t,e){var r,n,i,d,p,h,g,v,y,m,x,b,_,w,k,T,M,A,L=e.xaxis,S=e.yaxis,C="log"===L.type,O="log"===S.type,D=L._length,P=S._length,z=e.connectGaps,E=e.baseTolerance,R=e.shape,I="linear"===R,N=[],F=f.minTolerance,j=new Array(t.length),B=0;function H(e){var r=t[e];if(!r)return!1;var n=L.c2p(r.x),i=S.c2p(r.y);if(n===a){if(C&&(n=L.c2p(r.x,!0)),n===a)return!1;O&&i===a&&(n*=Math.abs(L._m*P*(L._m>0?o:l)/(S._m*D*(S._m>0?o:l)))),n*=1e3}if(i===a){if(O&&(i=S.c2p(r.y,!0)),i===a)return!1;i*=1e3}return[n,i]}function q(t,e,r,n){var a=r-t,i=n-e,o=.5-t,l=.5-e,s=a*a+i*i,c=a*o+i*l;if(c>0&&ctt||t[1]rt)return[u(t[0],K,tt),u(t[1],et,rt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,a){var i=at(n),o=at(a),l=[];if(i&&o&&it(i,o))return l;i&&l.push(i),o&&l.push(o);var c=2*s.constrain((n[t]+a[t])/2,e,r)-((i||n)[t]+(o||a)[t]);c&&((i&&o?c>0==i[t]>o[t]?i:o:i||o)[t]+=c);return l}}function lt(t){var e=t[0],r=t[1],n=e===j[B-1][0],a=r===j[B-1][1];if(!n||!a)if(B>1){var i=e===j[B-2][0],o=r===j[B-2][1];n&&(e===K||e===tt)&&i?o?B--:j[B-1]=t:a&&(r===et||r===rt)&&o?i?B--:j[B-1]=t:j[B++]=t}else j[B++]=t}function st(t){j[B-1][0]!==t[0]&&j[B-1][1]!==t[1]&<([Y,Z]),lt(t),W=null,Y=Z=0}function ct(t){if(M=t[0]/D,A=t[1]/P,G=t[0]tt?tt:0,X=t[1]rt?rt:0,G||X){if(B)if(W){var e=$(W,t);e.length>1&&(st(e[0]),j[B++]=e[1])}else J=$(j[B-1],t)[0],j[B++]=J;else j[B++]=[G||t[0],X||t[1]];var r=j[B-1];G&&X&&(r[0]!==G||r[1]!==X)?(W&&(Y!==G&&Z!==X?lt(Y&&Z?(n=W,i=(a=t)[0]-n[0],o=(a[1]-n[1])/i,(n[1]*a[0]-a[1]*n[0])/i>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[Y||G,Z||X]):Y&&Z&<([Y,Z])),lt([G,X])):Y-G&&Z-X&<([G||Y,X||Z]),W=t,Y=G,Z=X}else W&&st($(W,t)[0]),j[B++]=t;var n,a,i,o}for("linear"===R||"spline"===R?$=function(t,e){for(var r=[],n=0,a=0;a<4;a++){var i=nt[a],o=c(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&U(o,t)V(h,ut))break;i=h,(_=y[0]*v[0]+y[1]*v[1])>x?(x=_,d=h,g=!1):_=t.length||!h)break;ct(h),n=h}}else ct(d)}W&<([Y||W[0],Z||W[1]]),N.push(j.slice(0,B))}return N}},{"../../constants/numerical":140,"../../lib":159,"./constants":285}],296:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],297:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var a,i,o,l,s,c={},u=!1,f=-1,d=0,p=-1;for(i=0;i=0?s=p:(s=p=d,d++),s0?Math.max(e,a):0}}},{"fast-isnumeric":10}],299:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],300:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,l,s,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(r=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",r),a(t,"marker")&&i(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c.noSelect||(s("selected.marker.color"),s("unselected.marker.color"),s("selected.marker.size"),s("unselected.marker.size")),c.noLine||(s("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?n.background:n.defaultLine),a(t,"marker.line")&&i(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0)),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode")),c.gradient)&&("none"!==s("marker.gradient.type")&&s("marker.gradient.color"))}},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54,"./subtypes":305}],301:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,l=i.identity,s=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),d=t("../../lib/polygon").tester;function p(t,e,r,f,p,h,g){var v;!function(t,e,r,a,o){var l=r.xaxis,s=r.yaxis,u=n.extent(i.simpleMap(l.range,l.r2c)),f=n.extent(i.simpleMap(s.range,s.r2c)),d=a[0].trace;if(!c.hasMarkers(d))return;var p=d.marker.maxdisplayed;if(0===p)return;var h=a.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(h.length/p),v=0;o.forEach(function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function m(t){return y?t.transition():t}var x=r.xaxis,b=r.yaxis,_=f[0].trace,w=_.line,k=n.select(h),T=o(k,"g","errorbars"),M=o(k,"g","lines"),A=o(k,"g","points"),L=o(k,"g","text");if(a.getComponentMethod("errorbars","plot")(t,T,r,g),!0===_.visible){var S,C;m(k).style("opacity",_.opacity);var O=_.fill.charAt(_.fill.length-1);"x"!==O&&"y"!==O&&(O=""),r.isRangePlot||(f[0].node3=k);var D="",P=[],z=_._prevtrace;z&&(D=z._prevRevpath||"",C=z._nextFill,P=z._polygons);var E,R,I,N,F,j,B,H,q,V="",U="",G=[],X=i.noop;if(S=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(C&&C.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(I=s.steps(w.shape),N=s.steps(w.shape.split("").reverse().join(""))):I=N="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?s.smoothclosed(t.slice(1),w.smoothing):s.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return N(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)m(r.style("opacity",0).attr("d",E).call(s.lineGroupStyle)).style("opacity",1);else{var a=m(r);a.attr("d",E),s.singleLineStyle(f,a)}}}}}var Y=M.selectAll(".js-line").data(G);m(Y.exit()).style("opacity",0).remove(),Y.each(X(!1)),Y.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(s.lineGroupStyle).each(X(!0)),s.setClipUrl(Y,r.layerClipId,t),G.length?(S?(S.datum(f),j&&H&&(O?("y"===O?j[1]=H[1]=b.c2p(0,!0):"x"===O&&(j[0]=H[0]=x.c2p(0,!0)),m(S).attr("d","M"+H+"L"+j+"L"+V.substr(1)).call(s.singleFillStyle)):m(S).attr("d",V+"Z").call(s.singleFillStyle))):C&&("tonext"===_.fill.substr(0,6)&&V&&D?("tonext"===_.fill?m(C).attr("d",V+"Z"+D+"Z").call(s.singleFillStyle):m(C).attr("d",V+"L"+D.substr(1)+"Z").call(s.singleFillStyle),_._polygons=_._polygons.concat(P)):(W(C),_._polygons=null)),_._prevRevpath=U,_._prevPolygons=q):(S?W(S):C&&W(C),_._polygons=_._prevRevpath=_._prevPolygons=null),A.datum(f),L.datum(f),function(e,a,i){var o,u=i[0].trace,f=c.hasMarkers(u),d=c.hasText(u),p=tt(u),h=et,g=et;if(f||d){var v=l,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?$:J:_&&!w&&(v=Q),f&&(h=v),d&&(g=v)}var k,T=(o=e.selectAll("path.point").data(h,p)).enter().append("path").classed("point",!0);y&&T.call(s.pointStyle,u,t).call(s.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=s.makePointStyleFns(u)),o.each(function(e){var a=n.select(this),i=m(a);s.translatePoint(e,i,x,b)?(s.singlePointStyle(e,i,u,k,t),r.layerClipId&&s.hideOutsideRangePoint(e,i,x,b,u.xcalendar,u.ycalendar),u.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),a=m(e.select("text"));s.translatePoint(t,a,x,b)?r.layerClipId&&s.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(s.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),r=b.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){m(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(A,L,f);var Z=!1===_.cliponaxis?null:r.layerClipId;s.setClipUrl(A,Z,t),s.setClipUrl(L,Z,t)}function W(t){m(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function $(t){return t.filter(function(t){return t.vis})}function Q(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,a,i,c){var u,d,h=!i,g=!!i&&i.duration>0,v=f(t,e,r);((u=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,r){e.each(function(e){var a=o(n.select(this),"g","fills");s.setClipUrl(a,r.layerClipId,t);var i=e[0].trace,c=[];i._ownfill&&c.push("_ownFill"),i._nexttrace&&c.push("_nextFill");var u=a.selectAll("g").data(c,l);u.enter().append("g"),u.exit().each(function(t){i[t]=null}).remove(),u.order().each(function(t){i[t]=o(n.select(this),"path","js-fill")})})}(t,u,e),g)?(c&&(d=c()),n.transition().duration(i.duration).ease(i.easing).each("end",function(){d&&d()}).each("interrupt",function(){d&&d()}).each(function(){a.selectAll("g.trace").each(function(r,n){p(t,n,e,r,v,this,i)})})):u.each(function(r,n){p(t,n,e,r,v,this,i)});h&&u.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":64,"../../lib":159,"../../lib/polygon":171,"../../registry":243,"./line_points":295,"./link_traces":297,"./subtypes":305,d3:8}],302:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,a,i,o,l=t.cd,s=t.xaxis,c=t.yaxis,u=[],f=l[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", + "X:hover .modebar--hover .modebar-group": "opacity:1;", "X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;", "X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;", "X .modebar-btn svg": "position:relative;top:2px;", @@ -71,7 +71,7 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":170}],2:[function(_dereq_,module,exports){ +},{"../src/lib":168}],2:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -214,7 +214,7 @@ module.exports = { module.exports = _dereq_('../src/traces/bar'); -},{"../src/traces/bar":275}],4:[function(_dereq_,module,exports){ +},{"../src/traces/bar":274}],4:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -227,7 +227,7 @@ module.exports = _dereq_('../src/traces/bar'); module.exports = _dereq_('../src/traces/box'); -},{"../src/traces/box":289}],5:[function(_dereq_,module,exports){ +},{"../src/traces/box":288}],5:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -240,7 +240,7 @@ module.exports = _dereq_('../src/traces/box'); module.exports = _dereq_('../src/traces/contour'); -},{"../src/traces/contour":309}],6:[function(_dereq_,module,exports){ +},{"../src/traces/contour":308}],6:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -253,7 +253,7 @@ module.exports = _dereq_('../src/traces/contour'); module.exports = _dereq_('../src/core'); -},{"../src/core":154}],7:[function(_dereq_,module,exports){ +},{"../src/core":151}],7:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -266,7 +266,7 @@ module.exports = _dereq_('../src/core'); module.exports = _dereq_('../src/traces/heatmap'); -},{"../src/traces/heatmap":325}],8:[function(_dereq_,module,exports){ +},{"../src/traces/heatmap":324}],8:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -279,7 +279,7 @@ module.exports = _dereq_('../src/traces/heatmap'); module.exports = _dereq_('../src/traces/histogram'); -},{"../src/traces/histogram":343}],9:[function(_dereq_,module,exports){ +},{"../src/traces/histogram":342}],9:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -292,7 +292,7 @@ module.exports = _dereq_('../src/traces/histogram'); module.exports = _dereq_('../src/traces/histogram2d'); -},{"../src/traces/histogram2d":350}],10:[function(_dereq_,module,exports){ +},{"../src/traces/histogram2d":349}],10:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -305,7 +305,7 @@ module.exports = _dereq_('../src/traces/histogram2d'); module.exports = _dereq_('../src/traces/histogram2dcontour'); -},{"../src/traces/histogram2dcontour":354}],11:[function(_dereq_,module,exports){ +},{"../src/traces/histogram2dcontour":353}],11:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -346,7 +346,7 @@ module.exports = Plotly; module.exports = _dereq_('../src/traces/pie'); -},{"../src/traces/pie":361}],13:[function(_dereq_,module,exports){ +},{"../src/traces/pie":360}],13:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -359,7 +359,7 @@ module.exports = _dereq_('../src/traces/pie'); module.exports = _dereq_('../src/traces/scatterternary'); -},{"../src/traces/scatterternary":400}],14:[function(_dereq_,module,exports){ +},{"../src/traces/scatterternary":399}],14:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -372,7 +372,7 @@ module.exports = _dereq_('../src/traces/scatterternary'); module.exports = _dereq_('../src/traces/violin'); -},{"../src/traces/violin":408}],15:[function(_dereq_,module,exports){ +},{"../src/traces/violin":407}],15:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -15218,7 +15218,7 @@ module.exports = templatedArray('annotation', { } }); -},{"../../plot_api/plot_template":204,"../../plots/cartesian/constants":220,"../../plots/font_attributes":241,"./arrow_paths":35}],37:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":202,"../../plots/cartesian/constants":218,"../../plots/font_attributes":239,"./arrow_paths":35}],37:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15307,7 +15307,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":170,"../../plots/cartesian/axes":214,"./draw":42}],38:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212,"./draw":42}],38:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15446,7 +15446,7 @@ function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":170,"../../plot_api/plot_template":204,"../../registry":259}],39:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plot_api/plot_template":202,"../../registry":257}],39:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15526,7 +15526,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":170,"../color":51}],40:[function(_dereq_,module,exports){ +},{"../../lib":168,"../color":51}],40:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15589,7 +15589,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":193,"fast-isnumeric":18}],41:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":191,"fast-isnumeric":18}],41:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15695,7 +15695,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":170,"../../plots/array_container_defaults":210,"../../plots/cartesian/axes":214,"./attributes":36,"./common_defaults":39}],42:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/array_container_defaults":208,"../../plots/cartesian/axes":212,"./attributes":36,"./common_defaults":39}],42:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16109,14 +16109,14 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { x: borderfull + xShift - 1, y: borderfull + yShift }) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; annText.call(svgTextUtils.positionText, textx, texty) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } annTextClip.select('rect').call(Drawing.setRect, borderfull, borderfull, @@ -16282,7 +16282,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }); }, doneFn: function() { - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -16365,7 +16365,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }, doneFn: function() { setCursor(annTextGroupInner); - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -16389,13 +16389,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { modifyBase(ya._name + '.autorange', true); } - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); }); } else annText.call(textLayout); } -},{"../../lib":170,"../../lib/setcursor":189,"../../lib/svg_text_utils":191,"../../plot_api/plot_template":204,"../../plots/cartesian/axes":214,"../../plots/plots":247,"../../registry":259,"../color":51,"../dragelement":73,"../drawing":76,"../fx":93,"./draw_arrow_head":43,"d3":16}],43:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../lib/setcursor":187,"../../lib/svg_text_utils":189,"../../plot_api/plot_template":202,"../../plots/cartesian/axes":212,"../../plots/plots":245,"../../registry":257,"../color":51,"../dragelement":69,"../drawing":72,"../fx":90,"./draw_arrow_head":43,"d3":16}],43:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16583,7 +16583,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":225,"./attributes":36,"./calc_autorange":37,"./click":38,"./convert_coords":40,"./defaults":41,"./draw":42}],45:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":223,"./attributes":36,"./calc_autorange":37,"./click":38,"./convert_coords":40,"./defaults":41,"./draw":42}],45:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16671,7 +16671,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":197,"../../plot_api/plot_template":204,"../annotations/attributes":36}],46:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":195,"../../plot_api/plot_template":202,"../annotations/attributes":36}],46:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16736,7 +16736,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":170,"../../plots/cartesian/axes":214}],47:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212}],47:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16812,7 +16812,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":170,"../../plots/array_container_defaults":210,"../../plots/cartesian/axes":214,"../annotations/common_defaults":39,"./attributes":45}],48:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/array_container_defaults":208,"../../plots/cartesian/axes":212,"../annotations/common_defaults":39,"./attributes":45}],48:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16864,7 +16864,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":244,"../annotations/draw":42}],49:[function(_dereq_,module,exports){ +},{"../../plots/gl3d/project":242,"../annotations/draw":42}],49:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16912,7 +16912,7 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":170,"../../registry":259,"./attributes":45,"./convert":46,"./defaults":47,"./draw":48}],50:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257,"./attributes":45,"./convert":46,"./defaults":47,"./draw":48}],50:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17266,23 +17266,43 @@ module.exports = overrideAll({ exponentformat: axesAttrs.exponentformat, showexponent: axesAttrs.showexponent, title: { - valType: 'string', - - + text: { + valType: 'string', + + + }, + font: fontAttrs({ + + }), + side: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } }, - titlefont: fontAttrs({ - - }), - titleside: { - valType: 'enumerated', - values: ['right', 'top', 'bottom'], - - dflt: 'top', - + + _deprecated: { + title: { + valType: 'string', + + + }, + titlefont: fontAttrs({ + + }), + titleside: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":164,"../../plot_api/edit_types":197,"../../plots/cartesian/layout_attributes":227,"../../plots/font_attributes":241}],53:[function(_dereq_,module,exports){ +},{"../../lib/extend":162,"../../plot_api/edit_types":195,"../../plots/cartesian/layout_attributes":225,"../../plots/font_attributes":239}],53:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17291,10 +17311,10 @@ module.exports = overrideAll({ * LICENSE file in the root directory of this source tree. */ - 'use strict'; var drawColorbar = _dereq_('./draw'); +var flipScale = _dereq_('../colorscale/helpers').flipScale; /** * connectColorbar: create a colorbar from a trace, using its module to @@ -17334,12 +17354,16 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) { var cb = cd[0].t.cb = drawColorbar(gd, cbId); - cb.fillgradient(container.colorscale) + var scl = container.reversescale ? + flipScale(container.colorscale) : + container.colorscale; + + cb.fillgradient(scl) .zrange([container[moduleOpts.min], container[moduleOpts.max]]) .options(container.colorbar)(); }; -},{"./draw":56}],54:[function(_dereq_,module,exports){ +},{"../colorscale/helpers":62,"./draw":56}],54:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17429,12 +17453,12 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); - coerce('title', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'titlefont', layout.font); - coerce('titleside'); + coerce('title.text', layout._dfltTitle.colorbar); + Lib.coerceFont(coerce, 'title.font', layout.font); + coerce('title.side'); }; -},{"../../lib":170,"../../plot_api/plot_template":204,"../../plots/cartesian/tick_label_defaults":234,"../../plots/cartesian/tick_mark_defaults":235,"../../plots/cartesian/tick_value_defaults":236,"./attributes":52}],56:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plot_api/plot_template":202,"../../plots/cartesian/tick_label_defaults":232,"../../plots/cartesian/tick_mark_defaults":233,"../../plots/cartesian/tick_value_defaults":234,"./attributes":52}],56:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17621,9 +17645,9 @@ module.exports = function draw(gd, id) { showticksuffix: opts.showticksuffix, ticksuffix: opts.ticksuffix, title: opts.title, - titlefont: opts.titlefont, showline: true, anchor: 'free', + side: 'right', position: 1 }, cbAxisOut = { @@ -17634,6 +17658,7 @@ module.exports = function draw(gd, id) { letter: 'y', font: fullLayout.font, noHover: true, + noTickson: true, calendar: fullLayout.calendar // not really necessary (yet?) }; @@ -17654,11 +17679,11 @@ module.exports = function draw(gd, id) { // save for other callers to access this axis component.axis = cbAxisOut; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { - cbAxisOut.titleside = opts.titleside; + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { + cbAxisOut.title.side = opts.title.side; cbAxisOut.titlex = opts.x + xpadFrac; cbAxisOut.titley = yBottomFrac + - (opts.titleside === 'top' ? lenFrac - ypadFrac : ypadFrac); + (opts.title.side === 'top' ? lenFrac - ypadFrac : ypadFrac); } if(opts.line.color && opts.tickmode === 'auto') { @@ -17718,17 +17743,18 @@ module.exports = function draw(gd, id) { Math.round(gs.l) + ',-' + Math.round(gs.t) + ')'); - cbAxisOut._axislayer = container.select('.cbaxis'); + var axisLayer = container.select('.cbaxis'); + var titleHeight = 0; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // draw the title so we know how much room it needs // when we squish the axis. This one only applies to // top or bottom titles, not right side. var x = gs.l + (opts.x + xpadFrac) * gs.w, - fontSize = cbAxisOut.titlefont.size, + fontSize = cbAxisOut.title.font.size, y; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; } @@ -17742,7 +17768,7 @@ module.exports = function draw(gd, id) { } function drawAxis() { - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // squish the axis top to make room for the title var titleGroup = container.select('.cbtitle'), titleText = titleGroup.select('text'), @@ -17773,7 +17799,7 @@ module.exports = function draw(gd, id) { // TODO: configurable titleHeight += 5; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; } @@ -17794,8 +17820,7 @@ module.exports = function draw(gd, id) { .attr('transform', 'translate(0,' + Math.round(gs.h * (1 - cbAxisOut.domain[1])) + ')'); - cbAxisOut._axislayer.attr('transform', 'translate(0,' + - Math.round(-gs.t) + ')'); + axisLayer.attr('transform', 'translate(0,' + Math.round(-gs.t) + ')'); var fills = container.select('.cbfills') .selectAll('rect.cbfill') @@ -17862,12 +17887,7 @@ module.exports = function draw(gd, id) { }); // force full redraw of labels and ticks - cbAxisOut._axislayer.selectAll('g.' + cbAxisOut._id + 'tick,path') - .remove(); - - cbAxisOut._pos = xLeft + thickPx + - (opts.outlinewidth||0) / 2 - (opts.ticks === 'outside' ? 1 : 0); - cbAxisOut.side = 'right'; + axisLayer.selectAll('g.' + cbAxisOut._id + 'tick,path').remove(); // separate out axis and title drawing, // so we don't need such complicated logic in Titles.draw @@ -17875,11 +17895,33 @@ module.exports = function draw(gd, id) { // this title call only handles side=right return Lib.syncOrAsync([ function() { - return Axes.doTicksSingle(gd, cbAxisOut, true); + var shift = xLeft + thickPx + + (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0); + + var vals = Axes.calcTicks(cbAxisOut); + var transFn = Axes.makeTransFn(cbAxisOut); + var labelFns = Axes.makeLabelFns(cbAxisOut, shift); + var tickSign = Axes.getTickSigns(cbAxisOut)[2]; + + Axes.drawTicks(gd, cbAxisOut, { + vals: cbAxisOut.ticks === 'inside' ? Axes.clipEnds(cbAxisOut, vals) : vals, + layer: axisLayer, + path: Axes.makeTickPath(cbAxisOut, shift, tickSign), + transFn: transFn + }); + + return Axes.drawLabels(gd, cbAxisOut, { + vals: vals, + layer: axisLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); }, function() { - if(['top', 'bottom'].indexOf(opts.titleside) === -1) { - var fontSize = cbAxisOut.titlefont.size, + if(['top', 'bottom'].indexOf(opts.title.side) === -1) { + var fontSize = cbAxisOut.title.font.size, y = cbAxisOut._offset + cbAxisOut._length / 2, x = gs.l + (cbAxisOut.position || 0) * gs.w + ((cbAxisOut.side === 'right') ? 10 + fontSize * ((cbAxisOut.showticklabels ? 1 : 0.5)) : @@ -17891,7 +17933,7 @@ module.exports = function draw(gd, id) { drawTitle('h' + cbAxisOut._id + 'title', { avoid: { selection: d3.select(gd).selectAll('g.' + cbAxisOut._id + 'tick'), - side: opts.titleside, + side: opts.title.side, offsetLeft: gs.l, offsetTop: 0, maxShift: fullLayout.width @@ -17904,15 +17946,10 @@ module.exports = function draw(gd, id) { } function drawTitle(titleClass, titleOpts) { - var trace = getTrace(); - var propName = 'colorbar.title'; - var containerName = trace._module.colorbar.container; - if(containerName) propName = containerName + '.' + propName; - var dfltTitleOpts = { propContainer: cbAxisOut, - propName: propName, - traceIndex: trace.index, + propName: getPropName('title'), + traceIndex: getTrace().index, placeholder: fullLayout._dfltTitle.colorbar, containerGroup: container.select('.cbtitle') }; @@ -17936,7 +17973,7 @@ module.exports = function draw(gd, id) { // TODO: why are we redrawing multiple times now with this? // I guess autoMargin doesn't like being post-promise? var innerWidth = thickPx + opts.outlinewidth / 2 + - Drawing.bBox(cbAxisOut._axislayer.node()).width; + Drawing.bBox(axisLayer.node()).width; titleEl = titleCont.select('text'); if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) { var mathJaxNode = titleCont @@ -17944,11 +17981,11 @@ module.exports = function draw(gd, id) { .node(), titleWidth; if(mathJaxNode && - ['top', 'bottom'].indexOf(opts.titleside) !== -1) { + ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; } else { - // note: the formula below works for all titlesides, + // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift // transform gets removed by Drawing.bBox @@ -17977,7 +18014,7 @@ module.exports = function draw(gd, id) { container.selectAll('.cboutline').attr({ x: xLeft, y: yTopPx + opts.ypad + - (opts.titleside === 'top' ? titleHeight : 0), + (opts.title.side === 'top' ? titleHeight : 0), width: Math.max(thickPx, 2), height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2) }) @@ -18064,11 +18101,10 @@ module.exports = function draw(gd, id) { setCursor(container); if(xf !== undefined && yf !== undefined) { - Registry.call('restyle', - gd, - {'colorbar.x': xf, 'colorbar.y': yf}, - getTrace().index - ); + var update = {}; + update[getPropName('x')] = xf; + update[getPropName('y')] = yf; + Registry.call('_guiRestyle', gd, update, getTrace().index); } } }); @@ -18086,6 +18122,14 @@ module.exports = function draw(gd, id) { } } + function getPropName(suffix) { + var trace = getTrace(); + var propName = 'colorbar.'; + var containerName = trace._module.colorbar.container; + if(containerName) propName = containerName + '.' + propName; + return propName + suffix; + } + // setter/getters for every item defined in opts Object.keys(opts).forEach(function(name) { component[name] = function(v) { @@ -18119,7 +18163,7 @@ module.exports = function draw(gd, id) { return component; }; -},{"../../constants/alignment":149,"../../lib":170,"../../lib/extend":164,"../../lib/setcursor":189,"../../lib/svg_text_utils":191,"../../plots/cartesian/axes":214,"../../plots/cartesian/axis_defaults":216,"../../plots/cartesian/layout_attributes":227,"../../plots/cartesian/position_defaults":230,"../../plots/plots":247,"../../registry":259,"../color":51,"../dragelement":73,"../drawing":76,"../titles":142,"./attributes":52,"./constants":54,"d3":16,"tinycolor2":34}],57:[function(_dereq_,module,exports){ +},{"../../constants/alignment":146,"../../lib":168,"../../lib/extend":162,"../../lib/setcursor":187,"../../lib/svg_text_utils":189,"../../plots/cartesian/axes":212,"../../plots/cartesian/axis_defaults":214,"../../plots/cartesian/layout_attributes":225,"../../plots/cartesian/position_defaults":228,"../../plots/plots":245,"../../registry":257,"../color":51,"../dragelement":69,"../drawing":72,"../titles":139,"./attributes":52,"./constants":54,"d3":16,"tinycolor2":34}],57:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18138,7 +18182,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":170}],58:[function(_dereq_,module,exports){ +},{"../../lib":168}],58:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18149,7 +18193,7 @@ module.exports = function hasColorbar(container) { 'use strict'; -var palettes = _dereq_('./scales.js'); +var palettes = _dereq_('./scales.js').scales; var paletteStr = Object.keys(palettes); function code(s) { @@ -18296,7 +18340,7 @@ module.exports = function colorScaleAttrs(context, opts) { valType: 'boolean', dflt: false, - editType: 'calc', + editType: 'plot', }; @@ -18313,7 +18357,7 @@ module.exports = function colorScaleAttrs(context, opts) { return attrs; }; -},{"./scales.js":70}],59:[function(_dereq_,module,exports){ +},{"./scales.js":66}],59:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18322,49 +18366,19 @@ module.exports = function colorScaleAttrs(context, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); -var scales = _dereq_('./scales'); -var flipScale = _dereq_('./flip_scale'); - - -module.exports = function calc(trace, vals, containerStr, cLetter) { - var container = trace; - var inputContainer = trace._input; - var fullInputContainer = trace._fullInput; - - // set by traces with groupby transforms - var updateStyle = trace.updateStyle; - - function doUpdate(attr, inputVal, fullVal) { - if(fullVal === undefined) fullVal = inputVal; - - if(updateStyle) { - updateStyle(trace._input, containerStr ? (containerStr + '.' + attr) : attr, inputVal); - } - else { - inputContainer[attr] = inputVal; - } - - container[attr] = fullVal; - if(fullInputContainer && (trace !== trace._fullInput)) { - if(updateStyle) { - updateStyle(trace._fullInput, containerStr ? (containerStr + '.' + attr) : attr, fullVal); - } - else { - fullInputContainer[attr] = fullVal; - } - } - } +module.exports = function calc(gd, trace, opts) { + var fullLayout = gd._fullLayout; + var vals = opts.vals; + var containerStr = opts.containerStr; + var cLetter = opts.cLetter; - if(containerStr) { - container = Lib.nestedProperty(container, containerStr).get(); - inputContainer = Lib.nestedProperty(inputContainer, containerStr).get(); - fullInputContainer = Lib.nestedProperty(fullInputContainer, containerStr).get() || {}; - } + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() : + trace; var autoAttr = cLetter + 'auto'; var minAttr = cLetter + 'min'; @@ -18387,37 +18401,19 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { max += 0.5; } - doUpdate(minAttr, min); - doUpdate(maxAttr, max); - - /* - * If auto was explicitly false but min or max was missing, - * we filled in the missing piece here but later the trace does - * not look auto. - * Otherwise make sure the trace still looks auto as far as later - * changes are concerned. - */ - doUpdate(autoAttr, (auto !== false || (min === undefined && max === undefined))); + container['_' + minAttr] = container[minAttr] = min; + container['_' + maxAttr] = container[maxAttr] = max; if(container.autocolorscale) { - if(min * max < 0) scl = scales.RdBu; - else if(min >= 0) scl = scales.Reds; - else scl = scales.Blues; - - // reversescale is handled at the containerOut level - doUpdate('colorscale', scl, container.reversescale ? flipScale(scl) : scl); + if(min * max < 0) scl = fullLayout.colorscale.diverging; + else if(min >= 0) scl = fullLayout.colorscale.sequential; + else scl = fullLayout.colorscale.sequentialminus; - // We pushed a colorscale back to input, which will change the default autocolorscale next time - // to avoid spurious redraws from Plotly.react, update resulting autocolorscale now - // This is a conscious decision so that changing the data later does not unexpectedly - // give you a new colorscale - if(!inputContainer.autocolorscale) { - doUpdate('autocolorscale', false); - } + container._colorscale = container.colorscale = scl; } }; -},{"../../lib":170,"./flip_scale":63,"./scales":70}],60:[function(_dereq_,module,exports){ +},{"../../lib":168}],60:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18428,12 +18424,68 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { 'use strict'; -var scales = _dereq_('./scales'); +var Lib = _dereq_('../../lib'); +var hasColorscale = _dereq_('./helpers').hasColorscale; +module.exports = function crossTraceDefaults(fullData) { + function replace(cont, k) { + var val = cont['_' + k]; + if(val !== undefined) { + cont[k] = val; + } + } + + function relinkColorAtts(trace, cAttrs) { + var cont = cAttrs.container ? + Lib.nestedProperty(trace, cAttrs.container).get() : + trace; + + if(cont) { + var isAuto = cont.zauto || cont.cauto; + var minAttr = cAttrs.min; + var maxAttr = cAttrs.max; + + if(isAuto || cont[minAttr] === undefined) { + replace(cont, minAttr); + } + if(isAuto || cont[maxAttr] === undefined) { + replace(cont, maxAttr); + } + if(cont.autocolorscale) { + replace(cont, 'colorscale'); + } + } + } + + for(var i = 0; i < fullData.length; i++) { + var trace = fullData[i]; + var _module = trace._module; + + if(_module.colorbar) { + relinkColorAtts(trace, _module.colorbar); + } + + // TODO could generalize _module.colorscale and use it here? + + if(hasColorscale(trace, 'marker.line')) { + relinkColorAtts(trace, { + container: 'marker.line', + min: 'cmin', + max: 'cmax' + }); + } -module.exports = scales.RdBu; + if(hasColorscale(trace, 'line')) { + relinkColorAtts(trace, { + container: 'line', + min: 'cmin', + max: 'cmax' + }); + } + } +}; -},{"./scales":70}],61:[function(_dereq_,module,exports){ +},{"../../lib":168,"./helpers":62}],61:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18442,33 +18494,32 @@ module.exports = scales.RdBu; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); - var hasColorbar = _dereq_('../colorbar/has_colorbar'); var colorbarDefaults = _dereq_('../colorbar/defaults'); -var isValidScale = _dereq_('./is_valid_scale'); -var flipScale = _dereq_('./flip_scale'); +var isValidScale = _dereq_('./scales').isValid; + +function npMaybe(cont, prefix) { + var containerStr = prefix.slice(0, prefix.length - 1); + return prefix ? + Lib.nestedProperty(cont, containerStr).get() || {} : + cont; +} module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { - var prefix = opts.prefix, - cLetter = opts.cLetter, - containerStr = prefix.slice(0, prefix.length - 1), - containerIn = prefix ? - Lib.nestedProperty(traceIn, containerStr).get() || {} : - traceIn, - containerOut = prefix ? - Lib.nestedProperty(traceOut, containerStr).get() || {} : - traceOut, - minIn = containerIn[cLetter + 'min'], - maxIn = containerIn[cLetter + 'max'], - sclIn = containerIn.colorscale; + var prefix = opts.prefix; + var cLetter = opts.cLetter; + var containerIn = npMaybe(traceIn, prefix); + var containerOut = npMaybe(traceOut, prefix); + var template = npMaybe(traceOut._template || {}, prefix) || {}; + var minIn = containerIn[cLetter + 'min']; + var maxIn = containerIn[cLetter + 'max']; var validMinMax = isNumeric(minIn) && isNumeric(maxIn) && (minIn < maxIn); coerce(prefix + cLetter + 'auto', !validMinMax); coerce(prefix + cLetter + 'min'); @@ -18476,19 +18527,17 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, // handles both the trace case (autocolorscale is false by default) and // the marker and marker.line case (autocolorscale is true by default) + var sclIn = containerIn.colorscale; + var sclTemplate = template.colorscale; var autoColorscaleDflt; if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn); + if(sclTemplate !== undefined) autoColorscaleDflt = !isValidScale(sclTemplate); coerce(prefix + 'autocolorscale', autoColorscaleDflt); - var sclOut = coerce(prefix + 'colorscale'); - - // reversescale is handled at the containerOut level - var reverseScale = coerce(prefix + 'reversescale'); - if(reverseScale) containerOut.colorscale = flipScale(sclOut); - // ... until Scatter.colorbar can handle marker line colorbars - if(prefix === 'marker.line.') return; + coerce(prefix + 'colorscale'); + coerce(prefix + 'reversescale'); - if(!opts.noScale) { + if(!opts.noScale && prefix !== 'marker.line.') { // handles both the trace case where the dflt is listed in attributes and // the marker case where the dflt is determined by hasColorbar var showScaleDflt; @@ -18499,109 +18548,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, } }; -},{"../../lib":170,"../colorbar/defaults":55,"../colorbar/has_colorbar":57,"./flip_scale":63,"./is_valid_scale":67,"fast-isnumeric":18}],62:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -/** - * Extract colorscale into numeric domain and color range. - * - * @param {array} scl colorscale array of arrays - * @param {number} cmin minimum color value (used to clamp scale) - * @param {number} cmax maximum color value (used to clamp scale) - */ -module.exports = function extractScale(scl, cmin, cmax) { - var N = scl.length, - domain = new Array(N), - range = new Array(N); - - for(var i = 0; i < N; i++) { - var si = scl[i]; - - domain[i] = cmin + si[0] * (cmax - cmin); - range[i] = si[1]; - } - - return { - domain: domain, - range: range - }; -}; - -},{}],63:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function flipScale(scl) { - var N = scl.length, - sclNew = new Array(N), - si; - - for(var i = N - 1, j = 0; i >= 0; i--, j++) { - si = scl[i]; - sclNew[j] = [1 - si[0], si[1]]; - } - - return sclNew; -}; - -},{}],64:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var defaultScale = _dereq_('./default_scale'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function getScale(scl, dflt) { - if(!dflt) dflt = defaultScale; - if(!scl) return dflt; - - function parseScale() { - try { - scl = scales[scl] || JSON.parse(scl); - } - catch(e) { - scl = dflt; - } - } - - if(typeof scl === 'string') { - parseScale(); - // occasionally scl is double-JSON encoded... - if(typeof scl === 'string') parseScale(); - } - - if(!isValidScaleArray(scl)) return dflt; - return scl; -}; - -},{"./default_scale":60,"./is_valid_scale_array":68,"./scales":70}],65:[function(_dereq_,module,exports){ +},{"../../lib":168,"../colorbar/defaults":55,"../colorbar/has_colorbar":57,"./scales":66,"fast-isnumeric":18}],62:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18612,11 +18559,16 @@ module.exports = function getScale(scl, dflt) { 'use strict'; +var d3 = _dereq_('d3'); +var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); + var Lib = _dereq_('../../lib'); -var isValidScale = _dereq_('./is_valid_scale'); +var Color = _dereq_('../color'); + +var isValidScale = _dereq_('./scales').isValid; -module.exports = function hasColorscale(trace, containerStr) { +function hasColorscale(trace, containerStr) { var container = containerStr ? Lib.nestedProperty(trace, containerStr).get() || {} : trace; @@ -18641,117 +18593,61 @@ module.exports = function hasColorscale(trace, containerStr) { Lib.isPlainObject(container.colorbar) ) ); -}; - -},{"../../lib":170,"./is_valid_scale":67,"fast-isnumeric":18}],66:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -exports.scales = _dereq_('./scales'); - -exports.defaultScale = _dereq_('./default_scale'); - -exports.attributes = _dereq_('./attributes'); - -exports.handleDefaults = _dereq_('./defaults'); - -exports.calc = _dereq_('./calc'); - -exports.hasColorscale = _dereq_('./has_colorscale'); - -exports.isValidScale = _dereq_('./is_valid_scale'); - -exports.getScale = _dereq_('./get_scale'); - -exports.flipScale = _dereq_('./flip_scale'); - -exports.extractScale = _dereq_('./extract_scale'); - -exports.makeColorScaleFunc = _dereq_('./make_color_scale_func'); - -},{"./attributes":58,"./calc":59,"./default_scale":60,"./defaults":61,"./extract_scale":62,"./flip_scale":63,"./get_scale":64,"./has_colorscale":65,"./is_valid_scale":67,"./make_color_scale_func":69,"./scales":70}],67:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function isValidScale(scl) { - if(scales[scl] !== undefined) return true; - else return isValidScaleArray(scl); -}; +} -},{"./is_valid_scale_array":68,"./scales":70}],68:[function(_dereq_,module,exports){ /** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var tinycolor = _dereq_('tinycolor2'); - - -module.exports = function isValidScaleArray(scl) { - var highestVal = 0; + * Extract colorscale into numeric domain and color range. + * + * @param {object} cont colorscale container (e.g. trace, marker) + * - colorscale {array of arrays} + * - cmin/zmin {number} + * - cmax/zmax {number} + * - reversescale {boolean} + * @param {object} opts + * - cLetter {string} 'c' (for cmin/cmax) or 'z' (for zmin/zmax) + * + * @return {object} + * - domain {array} + * - range {array} + */ +function extractScale(cont, opts) { + var cLetter = opts.cLetter; - if(!Array.isArray(scl) || scl.length < 2) return false; + var scl = cont.reversescale ? + flipScale(cont.colorscale) : + cont.colorscale; - if(!scl[0] || !scl[scl.length - 1]) return false; + // minimum color value (used to clamp scale) + var cmin = cont[cLetter + 'min']; + // maximum color value (used to clamp scale) + var cmax = cont[cLetter + 'max']; - if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + var N = scl.length; + var domain = new Array(N); + var range = new Array(N); - for(var i = 0; i < scl.length; i++) { + for(var i = 0; i < N; i++) { var si = scl[i]; - - if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { - return false; - } - - highestVal = +si[0]; + domain[i] = cmin + si[0] * (cmax - cmin); + range[i] = si[1]; } - return true; -}; - -},{"tinycolor2":34}],69:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; + return { + domain: domain, + range: range + }; +} -var d3 = _dereq_('d3'); -var tinycolor = _dereq_('tinycolor2'); -var isNumeric = _dereq_('fast-isnumeric'); +function flipScale(scl) { + var N = scl.length; + var sclNew = new Array(N); -var Color = _dereq_('../color'); + for(var i = N - 1, j = 0; i >= 0; i--, j++) { + var si = scl[i]; + sclNew[j] = [1 - si[0], si[1]]; + } + return sclNew; +} /** * General colorscale function generator. @@ -18766,7 +18662,7 @@ var Color = _dereq_('../color'); * * @return {function} */ -module.exports = function makeColorScaleFunc(specs, opts) { +function makeColorScaleFunc(specs, opts) { opts = opts || {}; var domain = specs.domain, @@ -18818,7 +18714,7 @@ module.exports = function makeColorScaleFunc(specs, opts) { sclFunc.range = function() { return range; }; return sclFunc; -}; +} function colorArray2rbga(colorArray) { var colorObj = { @@ -18831,7 +18727,14 @@ function colorArray2rbga(colorArray) { return tinycolor(colorObj).toRgbString(); } -},{"../color":51,"d3":16,"fast-isnumeric":18,"tinycolor2":34}],70:[function(_dereq_,module,exports){ +module.exports = { + hasColorscale: hasColorscale, + extractScale: extractScale, + flipScale: flipScale, + makeColorScaleFunc: makeColorScaleFunc +}; + +},{"../../lib":168,"../color":51,"./scales":66,"d3":16,"fast-isnumeric":18,"tinycolor2":34}],63:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18842,8 +18745,116 @@ function colorArray2rbga(colorArray) { 'use strict'; +var scales = _dereq_('./scales'); +var helpers = _dereq_('./helpers'); + +module.exports = { + moduleType: 'component', + name: 'colorscale', + + attributes: _dereq_('./attributes'), + layoutAttributes: _dereq_('./layout_attributes'), + + supplyLayoutDefaults: _dereq_('./layout_defaults'), + handleDefaults: _dereq_('./defaults'), + crossTraceDefaults: _dereq_('./cross_trace_defaults'), + + calc: _dereq_('./calc'), + + // ./scales.js is required in lib/coerce.js ; + // it needs to be a seperate module to avoid circular a dependency + scales: scales.scales, + defaultScale: scales.defaultScale, + getScale: scales.get, + isValidScale: scales.isValid, + + hasColorscale: helpers.hasColorscale, + flipScale: helpers.flipScale, + extractScale: helpers.extractScale, + makeColorScaleFunc: helpers.makeColorScaleFunc +}; + +},{"./attributes":58,"./calc":59,"./cross_trace_defaults":60,"./defaults":61,"./helpers":62,"./layout_attributes":64,"./layout_defaults":65,"./scales":66}],64:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var scales = _dereq_('./scales').scales; + +var msg = 'Note that `autocolorscale` must be true for this attribute to work.'; module.exports = { + editType: 'calc', + sequential: { + valType: 'colorscale', + dflt: scales.Reds, + + editType: 'calc', + + }, + sequentialminus: { + valType: 'colorscale', + dflt: scales.Blues, + + editType: 'calc', + + }, + diverging: { + valType: 'colorscale', + dflt: scales.RdBu, + + editType: 'calc', + + } +}; + +},{"./scales":66}],65:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var Lib = _dereq_('../../lib'); +var colorscaleAttrs = _dereq_('./layout_attributes'); +var Template = _dereq_('../../plot_api/plot_template'); + +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var colorscaleIn = layoutIn.colorscale; + var colorscaleOut = Template.newContainer(layoutOut, 'colorscale'); + function coerce(attr, dflt) { + return Lib.coerce(colorscaleIn, colorscaleOut, colorscaleAttrs, attr, dflt); + } + + coerce('sequential'); + coerce('sequentialminus'); + coerce('diverging'); +}; + +},{"../../lib":168,"../../plot_api/plot_template":202,"./layout_attributes":64}],66:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var tinycolor = _dereq_('tinycolor2'); + +var scales = { 'Greys': [ [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] ], @@ -18974,7 +18985,67 @@ module.exports = { ] }; -},{}],71:[function(_dereq_,module,exports){ +var defaultScale = scales.RdBu; + +function getScale(scl, dflt) { + if(!dflt) dflt = defaultScale; + if(!scl) return dflt; + + function parseScale() { + try { + scl = scales[scl] || JSON.parse(scl); + } catch(e) { + scl = dflt; + } + } + + if(typeof scl === 'string') { + parseScale(); + // occasionally scl is double-JSON encoded... + if(typeof scl === 'string') parseScale(); + } + + if(!isValidScaleArray(scl)) return dflt; + return scl; +} + + +function isValidScaleArray(scl) { + var highestVal = 0; + + if(!Array.isArray(scl) || scl.length < 2) return false; + + if(!scl[0] || !scl[scl.length - 1]) return false; + + if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + + for(var i = 0; i < scl.length; i++) { + var si = scl[i]; + + if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { + return false; + } + + highestVal = +si[0]; + } + + return true; +} + +function isValidScale(scl) { + if(scales[scl] !== undefined) return true; + else return isValidScaleArray(scl); +} + +module.exports = { + scales: scales, + defaultScale: defaultScale, + + get: getScale, + isValid: isValidScale +}; + +},{"tinycolor2":34}],67:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19007,7 +19078,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],72:[function(_dereq_,module,exports){ +},{}],68:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19045,7 +19116,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":170}],73:[function(_dereq_,module,exports){ +},{"../../lib":168}],69:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19172,8 +19243,6 @@ dragElement.init = function init(options) { var clampFn = options.clampFn || _clampFn; function onStart(e) { - e.preventDefault(); - // make dragging and dragged into properties of gd // so that others can look at and modify them gd._dragged = false; @@ -19215,11 +19284,15 @@ dragElement.init = function init(options) { document.documentElement.style.cursor = window.getComputedStyle(element).cursor; } - document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onDone); - document.addEventListener('touchmove', onMove); document.addEventListener('touchend', onDone); + if(options.dragmode !== false) { + e.preventDefault(); + document.addEventListener('mousemove', onMove); + document.addEventListener('touchmove', onMove); + } + return; } @@ -19243,13 +19316,15 @@ dragElement.init = function init(options) { } function onDone(e) { - document.removeEventListener('mousemove', onMove); + if(options.dragmode !== false) { + e.preventDefault(); + document.removeEventListener('mousemove', onMove); + document.removeEventListener('touchmove', onMove); + } + document.removeEventListener('mouseup', onDone); - document.removeEventListener('touchmove', onMove); document.removeEventListener('touchend', onDone); - e.preventDefault(); - if(hasHover) { Lib.removeElement(dragCover); } @@ -19342,7 +19417,7 @@ function pointerOffset(e) { ); } -},{"../../constants/interactions":151,"../../lib":170,"../../plots/cartesian/constants":220,"../../registry":259,"./align":71,"./cursor":72,"./unhover":74,"has-hover":20,"has-passive-events":21,"mouse-event-offset":24}],74:[function(_dereq_,module,exports){ +},{"../../constants/interactions":148,"../../lib":168,"../../plots/cartesian/constants":218,"../../registry":257,"./align":67,"./cursor":68,"./unhover":70,"has-hover":20,"has-passive-events":21,"mouse-event-offset":24}],70:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19400,7 +19475,7 @@ unhover.raw = function unhoverRaw(gd, evt) { } }; -},{"../../lib/events":163,"../../lib/get_graph_div":168,"../../lib/throttle":192,"../fx/constants":88}],75:[function(_dereq_,module,exports){ +},{"../../lib/events":161,"../../lib/get_graph_div":166,"../../lib/throttle":190,"../fx/constants":84}],71:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19425,7 +19500,7 @@ exports.dash = { }; -},{}],76:[function(_dereq_,module,exports){ +},{}],72:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19626,7 +19701,11 @@ drawing.fillGroupStyle = function(s) { s.style('stroke-width', 0) .each(function(d) { var shape = d3.select(this); - shape.call(Color.fill, d[0].trace.fillcolor); + // N.B. 'd' won't be a calcdata item when + // fill !== 'none' on a segment-less and marker-less trace + if(d[0].trace) { + shape.call(Color.fill, d[0].trace.fillcolor); + } }); }; @@ -20067,7 +20146,7 @@ drawing.tryColorscale = function(marker, prefix) { if(scl && Lib.isArrayOrTypedArray(colorArray)) { return Colorscale.makeColorScaleFunc( - Colorscale.extractScale(scl, cont.cmin, cont.cmax) + Colorscale.extractScale(cont, {cLetter: 'c'}) ); } } @@ -20428,32 +20507,28 @@ function nodeHash(node) { node.getAttribute('style'); } -/* - * make a robust clipPath url from a local id - * note! We'd better not be exporting from a page - * with a or the svg will not be portable! +/** + * Set clipPath URL in a way that work for all situations. + * + * In details, graphs on pages with HTML tags need to prepend + * the clip path ids with the page's base url EXCEPT during toImage exports. + * + * @param {d3 selection} s : node to add clip-path attribute + * @param {string} localId : local clip-path (w/o base url) id + * @param {DOM element || object} gd + * - context._baseUrl {string} + * - context._exportedPlot {boolean} */ -drawing.setClipUrl = function(s, localId) { +drawing.setClipUrl = function(s, localId, gd) { if(!localId) { s.attr('clip-path', null); return; } - if(drawing.baseUrl === undefined) { - var base = d3.select('base'); - - // Stash base url once and for all! - // We may have to stash this elsewhere when - // we'll try to support for child windows - // more info -> https://github.com/plotly/plotly.js/issues/702 - if(base.size() && base.attr('href')) { - drawing.baseUrl = window.location.href.split('#')[0]; - } else { - drawing.baseUrl = ''; - } - } + var context = gd._context; + var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - s.attr('clip-path', 'url(' + drawing.baseUrl + '#' + localId + ')'); + s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')'); }; drawing.getTranslate = function(element) { @@ -20585,7 +20660,7 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../constants/alignment":149,"../../constants/interactions":151,"../../constants/xmlns_namespaces":153,"../../lib":170,"../../lib/svg_text_utils":191,"../../registry":259,"../../traces/scatter/make_bubble_size_func":385,"../../traces/scatter/subtypes":392,"../color":51,"../colorscale":66,"./symbol_defs":77,"d3":16,"fast-isnumeric":18,"tinycolor2":34}],77:[function(_dereq_,module,exports){ +},{"../../constants/alignment":146,"../../constants/interactions":148,"../../constants/xmlns_namespaces":150,"../../lib":168,"../../lib/svg_text_utils":189,"../../registry":257,"../../traces/scatter/make_bubble_size_func":384,"../../traces/scatter/subtypes":391,"../color":51,"../colorscale":63,"./symbol_defs":73,"d3":16,"fast-isnumeric":18,"tinycolor2":34}],73:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21073,7 +21148,7 @@ module.exports = { } }; -},{"d3":16}],78:[function(_dereq_,module,exports){ +},{"d3":16}],74:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21188,7 +21263,7 @@ module.exports = { } }; -},{}],79:[function(_dereq_,module,exports){ +},{}],75:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21270,7 +21345,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max); } -},{"../../plots/cartesian/axes":214,"../../registry":259,"./compute_error":80,"fast-isnumeric":18}],80:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":212,"../../registry":257,"./compute_error":76,"fast-isnumeric":18}],76:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21374,7 +21449,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],81:[function(_dereq_,module,exports){ +},{}],77:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21450,7 +21525,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":170,"../../plot_api/plot_template":204,"../../registry":259,"./attributes":78,"fast-isnumeric":18}],82:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plot_api/plot_template":202,"../../registry":257,"./attributes":74,"fast-isnumeric":18}],78:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21519,7 +21594,7 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":170,"../../plot_api/edit_types":197,"./attributes":78,"./calc":79,"./compute_error":80,"./defaults":81,"./plot":83,"./style":84}],83:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plot_api/edit_types":195,"./attributes":74,"./calc":75,"./compute_error":76,"./defaults":77,"./plot":79,"./style":80}],79:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21537,7 +21612,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); var subTypes = _dereq_('../../traces/scatter/subtypes'); -module.exports = function plot(traces, plotinfo, transitionOpts) { +module.exports = function plot(gd, traces, plotinfo, transitionOpts) { var isNew; var xa = plotinfo.xaxis; @@ -21588,7 +21663,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { .style('opacity', 1); } - Drawing.setClipUrl(errorbars, plotinfo.layerClipId); + Drawing.setClipUrl(errorbars, plotinfo.layerClipId, gd); errorbars.each(function(d) { var errorbar = d3.select(this); @@ -21693,7 +21768,7 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":392,"../drawing":76,"d3":16,"fast-isnumeric":18}],84:[function(_dereq_,module,exports){ +},{"../../traces/scatter/subtypes":391,"../drawing":72,"d3":16,"fast-isnumeric":18}],80:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21730,7 +21805,7 @@ module.exports = function style(traces) { }); }; -},{"../color":51,"d3":16}],85:[function(_dereq_,module,exports){ +},{"../color":51,"d3":16}],81:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21776,7 +21851,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":241}],86:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":239}],82:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21813,6 +21888,8 @@ module.exports = function calc(gd) { fillFn(trace.hoverinfo, cd, 'hi', makeCoerceHoverInfo(trace)); + if(trace.hovertemplate) fillFn(trace.hovertemplate, cd, 'ht'); + if(!trace.hoverlabel) continue; fillFn(trace.hoverlabel.bgcolor, cd, 'hbg'); @@ -21832,7 +21909,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":170,"../../registry":259}],87:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257}],83:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21870,7 +21947,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":259,"./hover":91}],88:[function(_dereq_,module,exports){ +},{"../../registry":257,"./hover":87}],84:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21902,7 +21979,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],89:[function(_dereq_,module,exports){ +},{}],85:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21925,7 +22002,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, layout.hoverlabel); }; -},{"../../lib":170,"./attributes":85,"./hoverlabel_defaults":92}],90:[function(_dereq_,module,exports){ +},{"../../lib":168,"./attributes":81,"./hoverlabel_defaults":88}],86:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22168,7 +22245,7 @@ function getPointData(val, pointNumber) { } } -},{"../../lib":170}],91:[function(_dereq_,module,exports){ +},{"../../lib":168}],87:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22297,13 +22374,17 @@ exports.loneHover = function loneHover(hoverItem, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; var container3 = d3.select(opts.container); @@ -22317,7 +22398,6 @@ exports.loneHover = function loneHover(hoverItem, opts) { container: container3, outerContainer: outerContainer3 }; - var hoverLabel = createHoverText([pointData], fullOpts, opts.gd); alignHoverText(hoverLabel, fullOpts.rotateLabels); @@ -22351,13 +22431,17 @@ exports.multiHovers = function multiHovers(hoverItems, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; }); @@ -22833,7 +22917,14 @@ function _hover(gd, evt, subplot, noHoverEvent) { // other people and send it to the event for(itemnum = 0; itemnum < hoverData.length; itemnum++) { var pt = hoverData[itemnum]; - newhoverdata.push(helpers.makeEventData(pt, pt.trace, pt.cd)); + var eventData = helpers.makeEventData(pt, pt.trace, pt.cd); + + var ht = false; + if(pt.cd[pt.index] && pt.cd[pt.index].ht) ht = pt.cd[pt.index].ht; + hoverData[itemnum].hovertemplate = ht || pt.trace.hovertemplate || false; + hoverData[itemnum].eventData = [eventData]; + + newhoverdata.push(eventData); } gd._hoverdata = newhoverdata; @@ -22891,6 +22982,8 @@ function _hover(gd, evt, subplot, noHoverEvent) { }); } +var EXTRA_STRING_REGEX = /([\s\S]*)<\/extra>/; + function createHoverText(hoverData, opts, gd) { var hovermode = opts.hovermode; var rotateLabels = opts.rotateLabels; @@ -22934,11 +23027,13 @@ function createHoverText(hoverData, opts, gd) { if(allHaveZ && hoverData[i].zLabel === undefined) allHaveZ = false; traceHoverinfo = hoverData[i].hoverinfo || hoverData[i].trace.hoverinfo; - var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); - if(parts.indexOf('all') === -1 && - parts.indexOf(hovermode) === -1) { - showCommonLabel = false; - break; + if(traceHoverinfo) { + var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); + if(parts.indexOf('all') === -1 && + parts.indexOf(hovermode) === -1) { + showCommonLabel = false; + break; + } } } @@ -23121,6 +23216,19 @@ function createHoverText(hoverData, opts, gd) { text = name; } + // hovertemplate + var hovertemplate = d.hovertemplate || false; + var hovertemplateLabels = d.hovertemplateLabels || d; + var eventData = d.eventData[0] || {}; + if(hovertemplate) { + text = Lib.hovertemplateString(hovertemplate, hovertemplateLabels, eventData); + + text = text.replace(EXTRA_STRING_REGEX, function(match, extra) { + name = extra; // Assign name for secondary text label + return ''; // Remove from main text label + }); + } + // main label var tx = g.select('text.nums') .call(Drawing.font, @@ -23519,7 +23627,7 @@ function cleanPoint(d, hovermode) { var infomode = d.hoverinfo || d.trace.hoverinfo; - if(infomode !== 'all') { + if(infomode && infomode !== 'all') { infomode = Array.isArray(infomode) ? infomode : infomode.split('+'); if(infomode.indexOf('x') === -1) d.xLabel = undefined; if(infomode.indexOf('y') === -1) d.yLabel = undefined; @@ -23705,8 +23813,11 @@ function hoverChanged(gd, evt, oldhoverdata) { for(var i = oldhoverdata.length - 1; i >= 0; i--) { var oldPt = oldhoverdata[i]; var newPt = gd._hoverdata[i]; + if(oldPt.curveNumber !== newPt.curveNumber || - String(oldPt.pointNumber) !== String(newPt.pointNumber)) { + String(oldPt.pointNumber) !== String(newPt.pointNumber) || + String(oldPt.pointNumbers) !== String(newPt.pointNumbers) + ) { return true; } } @@ -23722,7 +23833,7 @@ function spikesChanged(gd, oldspikepoints) { return false; } -},{"../../lib":170,"../../lib/events":163,"../../lib/override_cursor":181,"../../lib/svg_text_utils":191,"../../plots/cartesian/axes":214,"../../registry":259,"../color":51,"../dragelement":73,"../drawing":76,"./constants":88,"./helpers":90,"d3":16,"fast-isnumeric":18,"tinycolor2":34}],92:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../lib/events":161,"../../lib/override_cursor":179,"../../lib/svg_text_utils":189,"../../plots/cartesian/axes":212,"../../registry":257,"../color":51,"../dragelement":69,"../drawing":72,"./constants":84,"./helpers":86,"d3":16,"fast-isnumeric":18,"tinycolor2":34}],88:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23744,7 +23855,49 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts Lib.coerceFont(coerce, 'hoverlabel.font', opts.font); }; -},{"../../lib":170}],93:[function(_dereq_,module,exports){ +},{"../../lib":168}],89:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function(opts, extra) { + opts = opts || {}; + extra = extra || {}; + + var descPart = extra.description ? ' ' + extra.description : ''; + var keys = extra.keys || []; + if(keys.length > 0) { + var quotedKeys = []; + for(var i = 0; i < keys.length; i++) { + quotedKeys[i] = '`' + keys[i] + '`'; + } + descPart = descPart + 'Finally, the template string has access to '; + if(keys.length === 1) { + descPart = 'variable ' + quotedKeys[0]; + } else { + descPart = 'variables ' + quotedKeys.slice(0, -1).join(', ') + ' and ' + quotedKeys.slice(-1) + '.'; + } + } + + var hovertemplate = { + valType: 'string', + + dflt: '', + arrayOk: true, + editType: 'none', + + }; + + return hovertemplate; +}; + +},{}],90:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23824,7 +23977,7 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":170,"../dragelement":73,"./attributes":85,"./calc":86,"./click":87,"./constants":88,"./defaults":89,"./helpers":90,"./hover":91,"./layout_attributes":94,"./layout_defaults":95,"./layout_global_defaults":96,"d3":16}],94:[function(_dereq_,module,exports){ +},{"../../lib":168,"../dragelement":69,"./attributes":81,"./calc":82,"./click":83,"./constants":84,"./defaults":85,"./helpers":86,"./hover":87,"./layout_attributes":91,"./layout_defaults":92,"./layout_global_defaults":93,"d3":16}],91:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23857,7 +24010,7 @@ module.exports = { dragmode: { valType: 'enumerated', - values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'], + values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable', false], dflt: 'zoom', editType: 'modebar', @@ -23919,7 +24072,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":241,"./constants":88}],95:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":239,"./constants":84}],92:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23992,7 +24145,7 @@ function isHoriz(fullData) { return out; } -},{"../../lib":170,"./layout_attributes":94}],96:[function(_dereq_,module,exports){ +},{"../../lib":168,"./layout_attributes":91}],93:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24015,7 +24168,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":170,"./hoverlabel_defaults":92,"./layout_attributes":94}],97:[function(_dereq_,module,exports){ +},{"../../lib":168,"./hoverlabel_defaults":88,"./layout_attributes":91}],94:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24400,7 +24553,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":170,"../../lib/regex":185,"../../plot_api/plot_template":204,"../../plots/cartesian/constants":220,"../../plots/domain":240}],98:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../lib/regex":183,"../../plot_api/plot_template":202,"../../plots/cartesian/constants":218,"../../plots/domain":238}],95:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24535,7 +24688,7 @@ module.exports = templatedArray('image', { editType: 'arraydraw' }); -},{"../../plot_api/plot_template":204,"../../plots/cartesian/constants":220}],99:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":202,"../../plots/cartesian/constants":218}],96:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24618,7 +24771,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":193,"fast-isnumeric":18}],100:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":191,"fast-isnumeric":18}],97:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24679,7 +24832,7 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":170,"../../plots/array_container_defaults":210,"../../plots/cartesian/axes":214,"./attributes":98}],101:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/array_container_defaults":208,"../../plots/cartesian/axes":212,"./attributes":95}],98:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24850,9 +25003,10 @@ module.exports = function draw(gd) { yId = ya ? ya._id : '', clipAxes = xId + yId; - thisImage.call(Drawing.setClipUrl, clipAxes ? - ('clip' + fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + thisImage, + clipAxes ? ('clip' + fullLayout._uid + clipAxes) : null, + gd ); } @@ -24900,7 +25054,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":153,"../../plots/cartesian/axes":214,"../drawing":76,"d3":16}],102:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":150,"../../plots/cartesian/axes":212,"../drawing":72,"d3":16}],99:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24924,56 +25078,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":225,"./attributes":98,"./convert_coords":99,"./defaults":100,"./draw":101}],103:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - - -/** - * Determine the position anchor property of x/y xanchor/yanchor components. - * - * - values < 1/3 align the low side at that fraction, - * - values [1/3, 2/3] align the center at that fraction, - * - values > 2/3 align the right at that fraction. - */ - -exports.isRightAnchor = function isRightAnchor(opts) { - return ( - opts.xanchor === 'right' || - (opts.xanchor === 'auto' && opts.x >= 2 / 3) - ); -}; - -exports.isCenterAnchor = function isCenterAnchor(opts) { - return ( - opts.xanchor === 'center' || - (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) - ); -}; - -exports.isBottomAnchor = function isBottomAnchor(opts) { - return ( - opts.yanchor === 'bottom' || - (opts.yanchor === 'auto' && opts.y <= 1 / 3) - ); -}; - -exports.isMiddleAnchor = function isMiddleAnchor(opts) { - return ( - opts.yanchor === 'middle' || - (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) - ); -}; - -},{}],104:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":223,"./attributes":95,"./convert_coords":96,"./defaults":97,"./draw":98}],100:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25071,11 +25176,25 @@ module.exports = { editType: 'legend', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + valign: { + valType: 'enumerated', + values: ['top', 'middle', 'bottom'], + dflt: 'middle', + + editType: 'legend', + }, editType: 'legend' }; -},{"../../plots/font_attributes":241,"../color/attributes":50}],105:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":239,"../color/attributes":50}],101:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25094,7 +25213,7 @@ module.exports = { textOffsetX: 40 }; -},{}],106:[function(_dereq_,module,exports){ +},{}],102:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25163,7 +25282,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { basePlotLayoutAttributes, 'showlegend', legendReallyHasATrace && legendTraceCount > 1); - if(showLegend === false) return; + if(showLegend === false && !containerIn.uirevision) return; var containerOut = Template.newContainer(layoutOut, 'legend'); @@ -25171,6 +25290,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); } + coerce('uirevision', layoutOut.uirevision); + + if(showLegend === false) return; + coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); @@ -25179,7 +25302,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('orientation'); if(containerOut.orientation === 'h') { var xaxis = layoutIn.xaxis; - if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { + if(Registry.getComponentMethod('rangeslider', 'isVisible')(xaxis)) { defaultX = 0; defaultXAnchor = 'left'; defaultY = 1.1; @@ -25200,10 +25323,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('xanchor', defaultXAnchor); coerce('y', defaultY); coerce('yanchor', defaultYAnchor); + coerce('valign'); Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); }; -},{"../../lib":170,"../../plot_api/plot_template":204,"../../plots/layout_attributes":245,"../../registry":259,"./attributes":104,"./helpers":110}],107:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plot_api/plot_template":202,"../../plots/layout_attributes":243,"../../registry":257,"./attributes":100,"./helpers":106}],103:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25236,7 +25360,6 @@ var FROM_BR = alignmentConstants.FROM_BR; var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); -var anchorUtils = _dereq_('./anchor_utils'); var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; @@ -25360,17 +25483,17 @@ module.exports = function draw(gd) { lx = gs.l + gs.w * opts.x, ly = gs.t + gs.h * (1 - opts.y); - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= opts._width; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= opts._height; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -25430,7 +25553,7 @@ module.exports = function draw(gd) { y: opts.borderwidth }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; @@ -25468,7 +25591,7 @@ module.exports = function draw(gd) { y: opts.borderwidth + scrollBoxY }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -25545,7 +25668,7 @@ module.exports = function draw(gd) { }, doneFn: function() { if(xf !== undefined && yf !== undefined) { - Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf}); + Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf}); } }, clickFn: function(numClicks, e) { @@ -25652,7 +25775,7 @@ function drawTexts(g, gd, maxLength) { update.name = newName; } - return Registry.call('restyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, traceIndex); }); } else { textLayout(textEl); @@ -25742,6 +25865,7 @@ function computeTextDimensions(g, gd) { // to avoid getBoundingClientRect var textY = lineHeight * (0.3 + (1 - textLines) / 2); svgTextUtils.positionText(text, constants.textOffsetX, textY); + legendItem.lineHeight = lineHeight; } height = Math.max(height, 16) + 3; @@ -25905,18 +26029,18 @@ function expandMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -25936,10 +26060,10 @@ function expandHorizontalMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } @@ -25954,7 +26078,7 @@ function expandHorizontalMargin(gd) { }); } -},{"../../constants/alignment":149,"../../constants/interactions":151,"../../lib":170,"../../lib/events":163,"../../lib/svg_text_utils":191,"../../plots/plots":247,"../../registry":259,"../color":51,"../dragelement":73,"../drawing":76,"./anchor_utils":103,"./constants":105,"./get_legend_data":108,"./handle_click":109,"./helpers":110,"./style":112,"d3":16}],108:[function(_dereq_,module,exports){ +},{"../../constants/alignment":146,"../../constants/interactions":148,"../../lib":168,"../../lib/events":161,"../../lib/svg_text_utils":189,"../../plots/plots":245,"../../registry":257,"../color":51,"../dragelement":69,"../drawing":72,"./constants":101,"./get_legend_data":104,"./handle_click":105,"./helpers":106,"./style":108,"d3":16}],104:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26060,7 +26184,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":259,"./helpers":110}],109:[function(_dereq_,module,exports){ +},{"../../registry":257,"./helpers":106}],105:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26174,7 +26298,7 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices); + Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices); } else { var hasLegendgroup = legendgroup && legendgroup.length; var traceIndicesInGroup = []; @@ -26280,11 +26404,11 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', gd, attrUpdate, attrIndices); + Registry.call('_guiRestyle', gd, attrUpdate, attrIndices); } }; -},{"../../lib":170,"../../registry":259}],110:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257}],106:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26308,7 +26432,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],111:[function(_dereq_,module,exports){ +},{}],107:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26332,7 +26456,7 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":104,"./defaults":106,"./draw":107,"./style":112}],112:[function(_dereq_,module,exports){ +},{"./attributes":100,"./defaults":102,"./draw":103,"./style":108}],108:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26360,6 +26484,19 @@ module.exports = function style(s, gd) { var layers = Lib.ensureSingle(traceGroup, 'g', 'layers'); layers.style('opacity', d[0].trace.opacity); + // Marker vertical alignment + var valign = gd._fullLayout.legend.valign; + var lineHeight = d[0].lineHeight; + var height = d[0].height; + + if(valign === 'middle' || !lineHeight || !height) { + layers.attr('transform', null); // this here is a fun d3 trick to unset DOM attributes + } else { + var factor = {top: 1, bottom: -1}[valign]; + var markerOffsetY = factor * (0.5 * (lineHeight - height + 3)); + layers.attr('transform', 'translate(0,' + markerOffsetY + ')'); + } + var fill = layers .selectAll('g.legendfill') .data([d]); @@ -26679,7 +26816,7 @@ module.exports = function style(s, gd) { } }; -},{"../../lib":170,"../../registry":259,"../../traces/pie/style_one":366,"../../traces/scatter/subtypes":392,"../color":51,"../drawing":76,"d3":16}],113:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257,"../../traces/pie/style_one":365,"../../traces/scatter/subtypes":391,"../color":51,"../drawing":72,"d3":16}],109:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26943,7 +27080,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -26999,7 +27136,7 @@ function handleDrag3d(gd, ev) { var val2d = (val === 'pan') ? val : 'zoom'; layoutUpdate.dragmode = val2d; - Registry.call('relayout', gd, layoutUpdate); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.resetCameraDefault3d = { @@ -27038,7 +27175,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -27052,54 +27189,48 @@ modeBarButtons.hoverClosest3d = { click: handleHover3d }; -function handleHover3d(gd, ev) { +function getNextHover3d(gd, ev) { var button = ev.currentTarget; - var val = button._previousVal || false; - var layout = gd.layout; + var val = button._previousVal; var fullLayout = gd._fullLayout; var sceneIds = fullLayout._subplots.gl3d; var axes = ['xaxis', 'yaxis', 'zaxis']; - var spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor']; // initialize 'current spike' object to be stored in the DOM var currentSpikes = {}; - var axisSpikes = {}; var layoutUpdate = {}; if(val) { - layoutUpdate = Lib.extendDeep(layout, val); + layoutUpdate = val; button._previousVal = null; } else { - layoutUpdate = { - 'allaxes.showspikes': false - }; - for(var i = 0; i < sceneIds.length; i++) { - var sceneId = sceneIds[i], - sceneLayout = fullLayout[sceneId], - sceneSpikes = currentSpikes[sceneId] = {}; + var sceneId = sceneIds[i]; + var sceneLayout = fullLayout[sceneId]; - sceneSpikes.hovermode = sceneLayout.hovermode; - layoutUpdate[sceneId + '.hovermode'] = false; + var hovermodeAStr = sceneId + '.hovermode'; + currentSpikes[hovermodeAStr] = sceneLayout.hovermode; + layoutUpdate[hovermodeAStr] = false; // copy all the current spike attrs for(var j = 0; j < 3; j++) { var axis = axes[j]; - axisSpikes = sceneSpikes[axis] = {}; - - for(var k = 0; k < spikeAttrs.length; k++) { - var spikeAttr = spikeAttrs[k]; - axisSpikes[spikeAttr] = sceneLayout[axis][spikeAttr]; - } + var spikeAStr = sceneId + '.' + axis + '.showspikes'; + layoutUpdate[spikeAStr] = false; + currentSpikes[spikeAStr] = sceneLayout[axis].showspikes; } } - button._previousVal = Lib.extendDeep({}, currentSpikes); + button._previousVal = currentSpikes; } + return layoutUpdate; +} - Registry.call('relayout', gd, layoutUpdate); +function handleHover3d(gd, ev) { + var layoutUpdate = getNextHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.zoomInGeo = { @@ -27155,7 +27286,7 @@ function handleGeo(gd, ev) { var scale = geoLayout.projection.scale; var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; - Registry.call('relayout', gd, id + '.projection.scale', newScale); + Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); } else if(attr === 'reset') { resetView(gd, 'geo'); } @@ -27183,18 +27314,20 @@ modeBarButtons.hoverClosestPie = { click: toggleHover }; -function toggleHover(gd) { +function getNextHover(gd) { var fullLayout = gd._fullLayout; - var onHoverVal; + if(fullLayout.hovermode) return false; + if(fullLayout._has('cartesian')) { - onHoverVal = fullLayout._isHoriz ? 'y' : 'x'; + return fullLayout._isHoriz ? 'y' : 'x'; } - else onHoverVal = 'closest'; - - var newHover = gd._fullLayout.hovermode ? false : onHoverVal; + return 'closest'; +} - Registry.call('relayout', gd, 'hovermode', newHover); +function toggleHover(gd) { + var newHover = getNextHover(gd); + Registry.call('_guiRelayout', gd, 'hovermode', newHover); } // buttons when more then one plot types are present @@ -27208,12 +27341,10 @@ modeBarButtons.toggleHover = { icon: Icons.tooltip_basic, gravity: 'ne', click: function(gd, ev) { - toggleHover(gd); + var layoutUpdate = getNextHover3d(gd, ev); + layoutUpdate.hovermode = getNextHover(gd); - // the 3d hovermode update must come - // last so that layout.hovermode update does not - // override scene?.hovermode?.layout. - handleHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } }; @@ -27249,7 +27380,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } }; @@ -27296,10 +27427,10 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', gd, aObj); + Registry.call('_guiRelayout', gd, aObj); } -},{"../../../build/ploticon":2,"../../lib":170,"../../plots/cartesian/axis_ids":217,"../../plots/plots":247,"../../registry":259}],114:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":168,"../../plots/cartesian/axis_ids":215,"../../plots/plots":245,"../../registry":257}],110:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27313,7 +27444,7 @@ function resetView(gd, subplotType) { exports.manage = _dereq_('./manage'); -},{"./manage":115}],115:[function(_dereq_,module,exports){ +},{"./manage":111}],111:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27345,7 +27476,7 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar) { + if(!context.displayModeBar && !context.watermark) { if(modeBar) { modeBar.destroy(); delete fullLayout._modeBar; @@ -27373,11 +27504,15 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); } + else if(!context.displayModeBar && context.watermark) { + buttonGroups = []; + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, - context.modeBarButtonsToAdd + context.modeBarButtonsToAdd, + context.showSendToCloud ); } @@ -27386,7 +27521,7 @@ module.exports = function manageModeBar(gd) { }; // logic behind which buttons are displayed by default -function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { +function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; @@ -27417,7 +27552,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { } // buttons common to all plot types - addGroup(['toImage', 'sendDataToCloud']); + var commonGroup = ['toImage']; + if(showSendToCloud) commonGroup.push('sendDataToCloud'); + addGroup(commonGroup); var zoomGroup = []; var hoverGroup = []; @@ -27568,7 +27705,7 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":217,"../../registry":259,"../../traces/scatter/subtypes":392,"./buttons":113,"./modebar":116}],116:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axis_ids":215,"../../registry":257,"../../traces/scatter/subtypes":391,"./buttons":109,"./modebar":112}],112:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27651,11 +27788,16 @@ proto.update = function(graphInfo, buttons) { this.updateButtons(buttons); - if(context.displaylogo) { + if(context.watermark || context.displaylogo) { + var logoGroup = this.getLogo(); + if(context.watermark) { + logoGroup.className = logoGroup.className + ' watermark'; + } + if(fullLayout.modebar.orientation === 'v') { - this.element.prepend(this.getLogo()); + this.element.prepend(logoGroup); } else { - this.element.appendChild(this.getLogo()); + this.element.appendChild(logoGroup); } this.hasLogo = true; @@ -27914,7 +28056,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../../build/ploticon":2,"../../lib":170,"d3":16,"fast-isnumeric":18}],117:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":168,"d3":16,"fast-isnumeric":18}],113:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28050,7 +28192,7 @@ module.exports = { editType: 'plot' }; -},{"../../plot_api/plot_template":204,"../../plots/font_attributes":241,"../color/attributes":50}],118:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":202,"../../plots/font_attributes":239,"../color/attributes":50}],114:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28079,7 +28221,7 @@ module.exports = { darkAmount: 10 }; -},{}],119:[function(_dereq_,module,exports){ +},{}],115:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28172,7 +28314,7 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":170,"../../plot_api/plot_template":204,"../../plots/array_container_defaults":210,"../color":51,"./attributes":117,"./constants":118}],120:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plot_api/plot_template":202,"../../plots/array_container_defaults":208,"../color":51,"./attributes":113,"./constants":114}],116:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28192,7 +28334,6 @@ var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var alignmentConstants = _dereq_('../../constants/alignment'); var LINE_SPACING = alignmentConstants.LINE_SPACING; @@ -28244,7 +28385,7 @@ module.exports = function draw(gd) { button.on('click', function() { if(gd._dragged) return; - Registry.call('relayout', gd, update); + Registry.call('_guiRelayout', gd, update); }); button.on('mouseover', function() { @@ -28393,21 +28534,21 @@ function reposition(gd, buttons, opts, axName, selector) { var ly = graphSize.t + graphSize.h * (1 - opts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= width; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(opts)) { + if(Lib.isCenterAnchor(opts)) { lx -= width / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(opts)) { + if(Lib.isMiddleAnchor(opts)) { ly -= height / 2; yanchor = 'middle'; } @@ -28429,7 +28570,7 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', 'translate(' + lx + ',' + ly + ')'); } -},{"../../constants/alignment":149,"../../lib":170,"../../lib/svg_text_utils":191,"../../plots/cartesian/axis_ids":217,"../../plots/plots":247,"../../registry":259,"../color":51,"../drawing":76,"../legend/anchor_utils":103,"./constants":118,"./get_update_object":121,"d3":16}],121:[function(_dereq_,module,exports){ +},{"../../constants/alignment":146,"../../lib":168,"../../lib/svg_text_utils":189,"../../plots/cartesian/axis_ids":215,"../../plots/plots":245,"../../registry":257,"../color":51,"../drawing":72,"./constants":114,"./get_update_object":117,"d3":16}],117:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28486,7 +28627,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":16}],122:[function(_dereq_,module,exports){ +},{"d3":16}],118:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28513,7 +28654,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":117,"./defaults":119,"./draw":120}],123:[function(_dereq_,module,exports){ +},{"./attributes":113,"./defaults":115,"./draw":116}],119:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28587,7 +28728,7 @@ module.exports = { editType: 'calc' }; -},{"../color/attributes":50}],124:[function(_dereq_,module,exports){ +},{"../color/attributes":50}],120:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28621,7 +28762,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":213,"../../plots/cartesian/axis_ids":217,"./constants":125}],125:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/autorange":211,"../../plots/cartesian/axis_ids":215,"./constants":121}],121:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28677,7 +28818,7 @@ module.exports = { extraPad: 15 }; -},{}],126:[function(_dereq_,module,exports){ +},{}],122:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28763,7 +28904,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":170,"../../plot_api/plot_template":204,"../../plots/cartesian/axis_ids":217,"./attributes":123,"./oppaxis_attributes":129}],127:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plot_api/plot_template":202,"../../plots/cartesian/axis_ids":215,"./attributes":119,"./oppaxis_attributes":126}],123:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28785,7 +28926,7 @@ var Color = _dereq_('../color'); var Titles = _dereq_('../titles'); var Cartesian = _dereq_('../../plots/cartesian'); -var Axes = _dereq_('../../plots/cartesian/axes'); +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); var dragElement = _dereq_('../dragelement'); var setCursor = _dereq_('../../lib/setcursor'); @@ -28793,8 +28934,13 @@ var setCursor = _dereq_('../../lib/setcursor'); var constants = _dereq_('./constants'); module.exports = function(gd) { - var fullLayout = gd._fullLayout, - rangeSliderData = makeRangeSliderData(fullLayout); + var fullLayout = gd._fullLayout; + var rangeSliderData = fullLayout._rangeSliderData; + for(var i = 0; i < rangeSliderData.length; i++) { + var opts = rangeSliderData[i][constants.name]; + // fullLayout._uid may not exist when we call makeData + opts._clipId = opts._id + '-' + fullLayout._uid; + } /* * @@ -28821,10 +28967,6 @@ module.exports = function(gd) { .selectAll('g.' + constants.containerClassName) .data(rangeSliderData, keyFunction); - rangeSliders.enter().append('g') - .classed(constants.containerClassName, true) - .attr('pointer-events', 'all'); - // remove exiting sliders and their corresponding clip paths rangeSliders.exit().each(function(axisOpts) { var opts = axisOpts[constants.name]; @@ -28834,48 +28976,51 @@ module.exports = function(gd) { // return early if no range slider is visible if(rangeSliderData.length === 0) return; + rangeSliders.enter().append('g') + .classed(constants.containerClassName, true) + .attr('pointer-events', 'all'); + // for all present range sliders rangeSliders.each(function(axisOpts) { - var rangeSlider = d3.select(this), - opts = axisOpts[constants.name], - oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)], - oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)]; + var rangeSlider = d3.select(this); + var opts = axisOpts[constants.name]; + var oppAxisOpts = fullLayout[axisIDs.id2name(axisOpts.anchor)]; + var oppAxisRangeOpts = opts[axisIDs.id2name(axisOpts.anchor)]; // update range // Expand slider range to the axis range - // TODO: what if the ranges are reversed? if(opts.range) { - var outRange = opts.range; - var axRange = axisOpts.range; + var rng = Lib.simpleMap(opts.range, axisOpts.r2l); + var axRng = Lib.simpleMap(axisOpts.range, axisOpts.r2l); + var newRng; + + if(axRng[0] < axRng[1]) { + newRng = [ + Math.min(rng[0], axRng[0]), + Math.max(rng[1], axRng[1]) + ]; + } else { + newRng = [ + Math.max(rng[0], axRng[0]), + Math.min(rng[1], axRng[1]) + ]; + } - outRange[0] = axisOpts.l2r(Math.min(axisOpts.r2l(outRange[0]), axisOpts.r2l(axRange[0]))); - outRange[1] = axisOpts.l2r(Math.max(axisOpts.r2l(outRange[1]), axisOpts.r2l(axRange[1]))); - opts._input.range = outRange.slice(); + opts.range = opts._input.range = Lib.simpleMap(newRng, axisOpts.l2r); } axisOpts.cleanRange('rangeslider.range'); - // update range slider dimensions var margin = fullLayout.margin; var graphSize = fullLayout._size; var domain = axisOpts.domain; - var tickHeight = (axisOpts._boundingBox || {}).height || 0; - - var oppBottom = Infinity; - var subplotData = Axes.getSubplots(gd, axisOpts); - for(var i = 0; i < subplotData.length; i++) { - var oppAxis = Axes.getFromId(gd, subplotData[i].substr(subplotData[i].indexOf('y'))); - oppBottom = Math.min(oppBottom, oppAxis.domain[0]); - } + var tickHeight = opts._tickHeight; - opts._id = constants.name + axisOpts._id; - opts._clipId = opts._id + '-' + fullLayout._uid; + var oppBottom = opts._oppBottom; opts._width = graphSize.w * (domain[1] - domain[0]); - opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; - opts._offsetShift = Math.floor(opts.borderwidth / 2); var x = Math.round(margin.l + (graphSize.w * domain[0])); @@ -28938,41 +29083,14 @@ module.exports = function(gd) { placeholder: fullLayout._dfltTitle.x, attributes: { x: axisOpts._offset + axisOpts._length / 2, - y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size, + y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.title.font.size, 'text-anchor': 'middle' } }); } - - // update margins - Plots.autoMargin(gd, opts._id, { - x: domain[0], - y: oppBottom, - l: 0, - r: 0, - t: 0, - b: opts._height + margin.b + tickHeight, - pad: constants.extraPad + opts._offsetShift * 2 - }); }); }; -function makeRangeSliderData(fullLayout) { - var axes = Axes.list({ _fullLayout: fullLayout }, 'x', true), - name = constants.name, - out = []; - - if(fullLayout._has('gl2d')) return out; - - for(var i = 0; i < axes.length; i++) { - var ax = axes[i]; - - if(ax[name] && ax[name].visible) out.push(ax); - } - - return out; -} - function setupDragElement(rangeSlider, gd, axisOpts, opts) { var slideBox = rangeSlider.select('rect.' + constants.slideBoxClassName).node(), grabAreaMin = rangeSlider.select('rect.' + constants.grabAreaMinClassName).node(), @@ -29052,7 +29170,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) { dataMax = clamp(opts.p2d(opts._pixelMax)); window.requestAnimationFrame(function() { - Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); + Registry.call('_guiRelayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); }); } @@ -29159,15 +29277,14 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) { } function drawRangePlot(rangeSlider, gd, axisOpts, opts) { - var subplotData = Axes.getSubplots(gd, axisOpts), - calcData = gd.calcdata; + var calcData = gd.calcdata; var rangePlots = rangeSlider.selectAll('g.' + constants.rangePlotClassName) - .data(subplotData, Lib.identity); + .data(axisOpts._subplotsWith, Lib.identity); rangePlots.enter().append('g') .attr('class', function(id) { return constants.rangePlotClassName + ' ' + id; }) - .call(Drawing.setClipUrl, opts._clipId); + .call(Drawing.setClipUrl, opts._clipId, gd); rangePlots.order(); @@ -29179,7 +29296,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var plotgroup = d3.select(this), isMainPlot = (i === 0); - var oppAxisOpts = Axes.getFromId(gd, id, 'y'), + var oppAxisOpts = axisIDs.getFromId(gd, id, 'y'), oppAxisName = oppAxisOpts._name, oppAxisRangeOpts = opts[oppAxisName]; @@ -29211,6 +29328,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var xa = mockFigure._fullLayout.xaxis; var ya = mockFigure._fullLayout[oppAxisName]; + xa.clearCalc(); + xa.setScale(); + ya.clearCalc(); + ya.setScale(); + var plotinfo = { id: id, plotgroup: plotgroup, @@ -29363,7 +29485,77 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":170,"../../lib/setcursor":189,"../../plots/cartesian":226,"../../plots/cartesian/axes":214,"../../plots/plots":247,"../../registry":259,"../color":51,"../dragelement":73,"../drawing":76,"../titles":142,"./constants":125,"d3":16}],128:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../lib/setcursor":187,"../../plots/cartesian":224,"../../plots/cartesian/axis_ids":215,"../../plots/plots":245,"../../registry":257,"../color":51,"../dragelement":69,"../drawing":72,"../titles":139,"./constants":121,"d3":16}],124:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); +var constants = _dereq_('./constants'); +var name = constants.name; + +function isVisible(ax) { + var rangeSlider = ax && ax[name]; + return rangeSlider && rangeSlider.visible; +} +exports.isVisible = isVisible; + +exports.makeData = function(fullLayout) { + var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true); + var margin = fullLayout.margin; + var rangeSliderData = []; + + if(!fullLayout._has('gl2d')) { + for(var i = 0; i < axes.length; i++) { + var ax = axes[i]; + + if(isVisible(ax)) { + rangeSliderData.push(ax); + + var opts = ax[name]; + opts._id = name + ax._id; + opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; + opts._offsetShift = Math.floor(opts.borderwidth / 2); + } + } + } + + fullLayout._rangeSliderData = rangeSliderData; +}; + +exports.autoMarginOpts = function(gd, ax) { + var opts = ax[name]; + + var oppBottom = Infinity; + var counterAxes = ax._counterAxes; + for(var j = 0; j < counterAxes.length; j++) { + var counterId = counterAxes[j]; + var oppAxis = axisIDs.getFromId(gd, counterId); + oppBottom = Math.min(oppBottom, oppAxis.domain[0]); + } + opts._oppBottom = oppBottom; + + var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0; + opts._tickHeight = tickHeight; + + return { + x: 0, + y: oppBottom, + l: 0, + r: 0, + t: 0, + b: opts._height + gd._fullLayout.margin.b + tickHeight, + pad: constants.extraPad + opts._offsetShift * 2 + }; +}; + +},{"../../plots/cartesian/axis_ids":215,"./constants":121}],125:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29377,6 +29569,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { var Lib = _dereq_('../../lib'); var attrs = _dereq_('./attributes'); var oppAxisAttrs = _dereq_('./oppaxis_attributes'); +var helpers = _dereq_('./helpers'); module.exports = { moduleType: 'component', @@ -29395,10 +29588,13 @@ module.exports = { layoutAttributes: _dereq_('./attributes'), handleDefaults: _dereq_('./defaults'), calcAutorange: _dereq_('./calc_autorange'), - draw: _dereq_('./draw') + draw: _dereq_('./draw'), + isVisible: helpers.isVisible, + makeData: helpers.makeData, + autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":170,"./attributes":123,"./calc_autorange":124,"./defaults":126,"./draw":127,"./oppaxis_attributes":129}],129:[function(_dereq_,module,exports){ +},{"../../lib":168,"./attributes":119,"./calc_autorange":120,"./defaults":122,"./draw":123,"./helpers":124,"./oppaxis_attributes":126}],126:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29436,7 +29632,7 @@ module.exports = { editType: 'calc' }; -},{}],130:[function(_dereq_,module,exports){ +},{}],127:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29572,7 +29768,7 @@ module.exports = templatedArray('shape', { editType: 'arraydraw' }); -},{"../../lib/extend":164,"../../plot_api/plot_template":204,"../../traces/scatter/attributes":368,"../annotations/attributes":36,"../drawing/attributes":75}],131:[function(_dereq_,module,exports){ +},{"../../lib/extend":162,"../../plot_api/plot_template":202,"../../traces/scatter/attributes":367,"../annotations/attributes":36,"../drawing/attributes":71}],128:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29581,7 +29777,6 @@ module.exports = templatedArray('shape', { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); @@ -29659,7 +29854,7 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { } function shapeBounds(ax, v0, v1, path, paramsToUse) { - var convertVal = (ax.type === 'category') ? ax.r2c : ax.d2c; + var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; if(!path) return; @@ -29690,7 +29885,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":170,"../../plots/cartesian/axes":214,"./constants":132,"./helpers":135}],132:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212,"./constants":129,"./helpers":132}],129:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29754,7 +29949,7 @@ module.exports = { } }; -},{}],133:[function(_dereq_,module,exports){ +},{}],130:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29879,7 +30074,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":170,"../../plots/array_container_defaults":210,"../../plots/cartesian/axes":214,"./attributes":130,"./helpers":135}],134:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/array_container_defaults":208,"../../plots/cartesian/axes":212,"./attributes":127,"./helpers":132}],131:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30002,9 +30197,10 @@ function setClipPath(shapePath, gd, shapeOptions) { // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 var clipAxes = (shapeOptions.xref + shapeOptions.yref).replace(/paper/g, ''); - shapePath.call(Drawing.setClipUrl, clipAxes ? - ('clip' + gd._fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } @@ -30188,7 +30384,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { // Don't rely on clipPath being activated during re-layout setClipPath(shapePath, gd, shapeOptions); - Registry.call('relayout', gd, editHelpers.getUpdateObj()); + Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj()); } function abortDrag() { @@ -30375,9 +30571,10 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(xref !== 'paper' && !xa.autorange) clipAxes += xref; if(yref !== 'paper' && !ya.autorange) clipAxes += yref; - shapePath.call(Drawing.setClipUrl, clipAxes ? - 'clip' + gd._fullLayout._uid + clipAxes : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } } @@ -30509,7 +30706,7 @@ function movePath(pathIn, moveX, moveY) { }); } -},{"../../lib":170,"../../lib/setcursor":189,"../../plot_api/plot_template":204,"../../plots/cartesian/axes":214,"../../registry":259,"../color":51,"../dragelement":73,"../drawing":76,"./constants":132,"./helpers":135}],135:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../lib/setcursor":187,"../../plot_api/plot_template":202,"../../plots/cartesian/axes":212,"../../registry":257,"../color":51,"../dragelement":69,"../drawing":72,"./constants":129,"./helpers":132}],132:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30634,7 +30831,7 @@ exports.roundPositionForSharpStrokeRendering = function(pos, strokeWidth) { return strokeWidthIsOdd ? posValAsInt + 0.5 : posValAsInt; }; -},{"../../lib":170,"./constants":132}],136:[function(_dereq_,module,exports){ +},{"../../lib":168,"./constants":129}],133:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30661,7 +30858,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":225,"./attributes":130,"./calc_autorange":131,"./defaults":133,"./draw":134}],137:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":223,"./attributes":127,"./calc_autorange":128,"./defaults":130,"./draw":131}],134:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30763,7 +30960,7 @@ module.exports = overrideAll(templatedArray('slider', { }, - pad: extendDeepAll({}, padAttrs, { + pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { }, {t: {dflt: 20}}), xanchor: { @@ -30904,7 +31101,7 @@ module.exports = overrideAll(templatedArray('slider', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":164,"../../plot_api/edit_types":197,"../../plot_api/plot_template":204,"../../plots/animation_attributes":209,"../../plots/font_attributes":241,"../../plots/pad_attributes":246,"./constants":138}],138:[function(_dereq_,module,exports){ +},{"../../lib/extend":162,"../../plot_api/edit_types":195,"../../plot_api/plot_template":202,"../../plots/animation_attributes":207,"../../plots/font_attributes":239,"../../plots/pad_attributes":244,"./constants":135}],135:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30998,7 +31195,7 @@ module.exports = { currentValueInset: 0, }; -},{}],139:[function(_dereq_,module,exports){ +},{}],136:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31115,7 +31312,7 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":170,"../../plots/array_container_defaults":210,"./attributes":137,"./constants":138}],140:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/array_container_defaults":208,"./attributes":134,"./constants":135}],137:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31133,7 +31330,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var constants = _dereq_('./constants'); @@ -31325,21 +31521,21 @@ function findDimensions(gd, sliderOpts) { dims.height = dims.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + dims.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(sliderOpts)) { + if(Lib.isRightAnchor(sliderOpts)) { dims.lx -= dims.outerLength; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(sliderOpts)) { + if(Lib.isCenterAnchor(sliderOpts)) { dims.lx -= dims.outerLength / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(sliderOpts)) { + if(Lib.isBottomAnchor(sliderOpts)) { dims.ly -= dims.height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(sliderOpts)) { + if(Lib.isMiddleAnchor(sliderOpts)) { dims.ly -= dims.height / 2; yanchor = 'middle'; } @@ -31746,7 +31942,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":149,"../../lib":170,"../../lib/svg_text_utils":191,"../../plot_api/plot_template":204,"../../plots/plots":247,"../color":51,"../drawing":76,"../legend/anchor_utils":103,"./constants":138,"d3":16}],141:[function(_dereq_,module,exports){ +},{"../../constants/alignment":146,"../../lib":168,"../../lib/svg_text_utils":189,"../../plot_api/plot_template":202,"../../plots/plots":245,"../color":51,"../drawing":72,"./constants":135,"d3":16}],138:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31769,7 +31965,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":137,"./constants":138,"./defaults":139,"./draw":140}],142:[function(_dereq_,module,exports){ +},{"./attributes":134,"./constants":135,"./defaults":136,"./draw":137}],139:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31839,19 +32035,21 @@ function draw(gd, titleClass, options) { var group = options.containerGroup; var fullLayout = gd._fullLayout; - var titlefont = cont.titlefont || {}; - var font = titlefont.family; - var fontSize = titlefont.size; - var fontColor = titlefont.color; var opacity = 1; var isplaceholder = false; - var txt = (cont.title || '').trim(); + var title = cont.title; + var txt = (title && title.text ? title.text : '').trim(); + + var font = title && title.font ? title.font : {}; + var fontFamily = font.family; + var fontSize = font.size; + var fontColor = font.color; // only make this title editable if we positively identify its property // as one that has editing enabled. var editAttr; - if(prop === 'title') editAttr = 'titleText'; + if(prop === 'title.text') editAttr = 'titleText'; else if(prop.indexOf('axis') !== -1) editAttr = 'axisTitleText'; else if(prop.indexOf('colorbar' !== -1)) editAttr = 'colorbarTitleText'; var editable = gd._context.edits[editAttr]; @@ -31909,7 +32107,7 @@ function draw(gd, titleClass, options) { titleEl.attr('transform', transformVal); titleEl.style({ - 'font-family': font, + 'font-family': fontFamily, 'font-size': d3.round(fontSize, 2) + 'px', fill: Color.rgb(fontColor), opacity: opacity * Color.opacity(fontColor), @@ -32009,9 +32207,9 @@ function draw(gd, titleClass, options) { el.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { if(traceIndex !== undefined) { - Registry.call('restyle', gd, prop, text, traceIndex); + Registry.call('_guiRestyle', gd, prop, text, traceIndex); } else { - Registry.call('relayout', gd, prop, text); + Registry.call('_guiRelayout', gd, prop, text); } }) .on('cancel', function() { @@ -32028,7 +32226,7 @@ function draw(gd, titleClass, options) { return group; } -},{"../../constants/interactions":151,"../../lib":170,"../../lib/svg_text_utils":191,"../../plots/plots":247,"../../registry":259,"../color":51,"../drawing":76,"d3":16,"fast-isnumeric":18}],143:[function(_dereq_,module,exports){ +},{"../../constants/interactions":148,"../../lib":168,"../../lib/svg_text_utils":189,"../../plots/plots":245,"../../registry":257,"../color":51,"../drawing":72,"d3":16,"fast-isnumeric":18}],140:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32157,7 +32355,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { }, - pad: extendFlat({}, padAttrs, { + pad: extendFlat(padAttrs({editType: 'arraydraw'}), { }), @@ -32186,7 +32384,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":164,"../../plot_api/edit_types":197,"../../plot_api/plot_template":204,"../../plots/font_attributes":241,"../../plots/pad_attributes":246,"../color/attributes":50}],144:[function(_dereq_,module,exports){ +},{"../../lib/extend":162,"../../plot_api/edit_types":195,"../../plot_api/plot_template":202,"../../plots/font_attributes":239,"../../plots/pad_attributes":244,"../color/attributes":50}],141:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32267,7 +32465,7 @@ module.exports = { } }; -},{}],145:[function(_dereq_,module,exports){ +},{}],142:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32350,7 +32548,7 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":170,"../../plots/array_container_defaults":210,"./attributes":143,"./constants":144}],146:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/array_container_defaults":208,"./attributes":140,"./constants":141}],143:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32369,7 +32567,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var LINE_SPACING = _dereq_('../../constants/alignment').LINE_SPACING; @@ -32919,21 +33116,21 @@ function findDimensions(gd, menuOpts) { dims.ly = graphSize.t + graphSize.h * (1 - menuOpts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(menuOpts)) { + if(Lib.isRightAnchor(menuOpts)) { dims.lx -= paddedWidth; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(menuOpts)) { + if(Lib.isCenterAnchor(menuOpts)) { dims.lx -= paddedWidth / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(menuOpts)) { + if(Lib.isBottomAnchor(menuOpts)) { dims.ly -= paddedHeight; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(menuOpts)) { + if(Lib.isMiddleAnchor(menuOpts)) { dims.ly -= paddedHeight / 2; yanchor = 'middle'; } @@ -33000,9 +33197,9 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":149,"../../lib":170,"../../lib/svg_text_utils":191,"../../plot_api/plot_template":204,"../../plots/plots":247,"../color":51,"../drawing":76,"../legend/anchor_utils":103,"./constants":144,"./scrollbox":148,"d3":16}],147:[function(_dereq_,module,exports){ -arguments[4][141][0].apply(exports,arguments) -},{"./attributes":143,"./constants":144,"./defaults":145,"./draw":146,"dup":141}],148:[function(_dereq_,module,exports){ +},{"../../constants/alignment":146,"../../lib":168,"../../lib/svg_text_utils":189,"../../plot_api/plot_template":202,"../../plots/plots":245,"../color":51,"../drawing":72,"./constants":141,"./scrollbox":145,"d3":16}],144:[function(_dereq_,module,exports){ +arguments[4][138][0].apply(exports,arguments) +},{"./attributes":140,"./constants":141,"./defaults":142,"./draw":143,"dup":138}],145:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33259,7 +33456,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { height: Math.ceil(clipB) - Math.floor(clipT) }); - this.container.call(Drawing.setClipUrl, clipId); + this.container.call(Drawing.setClipUrl, clipId, this.gd); this.bg.attr({ x: l, @@ -33473,7 +33670,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":170,"../color":51,"../drawing":76,"d3":16}],149:[function(_dereq_,module,exports){ +},{"../../lib":168,"../color":51,"../drawing":72,"d3":16}],146:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33517,12 +33714,17 @@ module.exports = { // multiple of fontSize to get the vertical offset between lines LINE_SPACING: 1.3, - // multiple of fontSize to shift from the baseline to the midline + // multiple of fontSize to shift from the baseline + // to the cap (captical letter) line // (to use when we don't calculate this shift from Drawing.bBox) - // To be precise this should be half the cap height (capital letter) - // of the font, and according to wikipedia: + // This is an approximation since in reality cap height can differ + // from font to font. However, according to Wikipedia // an "average" font might have a cap height of 70% of the em // https://en.wikipedia.org/wiki/Em_(typography)#History + CAP_SHIFT: 0.70, + + // half the cap height (distance between baseline and cap line) + // of an "average" font (for more info see above). MID_SHIFT: 0.35, OPPOSITE_SIDE: { @@ -33533,7 +33735,7 @@ module.exports = { } }; -},{}],150:[function(_dereq_,module,exports){ +},{}],147:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33571,7 +33773,7 @@ module.exports = { } }; -},{}],151:[function(_dereq_,module,exports){ +},{}],148:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33598,7 +33800,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],152:[function(_dereq_,module,exports){ +},{}],149:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33663,7 +33865,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],153:[function(_dereq_,module,exports){ +},{}],150:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33687,7 +33889,7 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],154:[function(_dereq_,module,exports){ +},{}],151:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33699,7 +33901,7 @@ exports.svgAttrs = { 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.42.5'; +exports.version = '1.43.0'; // inject promise polyfill _dereq_('es6-promise').polyfill(); @@ -33708,7 +33910,7 @@ _dereq_('es6-promise').polyfill(); _dereq_('../build/plotcss'); // inject default MathJax config -_dereq_('./fonts/mathjax_config'); +_dereq_('./fonts/mathjax_config')(); // include registry module and expose register method var Registry = _dereq_('./registry'); @@ -33719,7 +33921,8 @@ var plotApi = _dereq_('./plot_api'); var methodNames = Object.keys(plotApi); for(var i = 0; i < methodNames.length; i++) { var name = methodNames[i]; - exports[name] = plotApi[name]; + // _ -> private API methods, but still registered for internal use + if(name.charAt(0) !== '_') exports[name] = plotApi[name]; register({ moduleType: 'apiMethod', name: name, @@ -33743,7 +33946,8 @@ register([ _dereq_('./components/rangeslider'), _dereq_('./components/rangeselector'), _dereq_('./components/grid'), - _dereq_('./components/errorbars') + _dereq_('./components/errorbars'), + _dereq_('./components/colorscale') ]); // locales en and en-US are required for default behavior @@ -33765,7 +33969,7 @@ exports.Queue = _dereq_('./lib/queue'); // export d3 used in the bundle exports.d3 = _dereq_('d3'); -},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":44,"./components/annotations3d":49,"./components/errorbars":82,"./components/fx":93,"./components/grid":97,"./components/images":102,"./components/legend":111,"./components/rangeselector":122,"./components/rangeslider":128,"./components/shapes":136,"./components/sliders":141,"./components/updatemenus":147,"./fonts/mathjax_config":155,"./lib/queue":184,"./locale-en":195,"./locale-en-us":194,"./plot_api":199,"./plot_api/plot_schema":203,"./plots/plots":247,"./registry":259,"./snapshot":264,"./traces/scatter":380,"d3":16,"es6-promise":17}],155:[function(_dereq_,module,exports){ +},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":44,"./components/annotations3d":49,"./components/colorscale":63,"./components/errorbars":78,"./components/fx":90,"./components/grid":94,"./components/images":99,"./components/legend":107,"./components/rangeselector":118,"./components/rangeslider":125,"./components/shapes":133,"./components/sliders":138,"./components/updatemenus":144,"./fonts/mathjax_config":152,"./lib/queue":182,"./locale-en":193,"./locale-en-us":192,"./plot_api":197,"./plot_api/plot_schema":201,"./plots/plots":245,"./registry":257,"./snapshot":262,"./traces/scatter":379,"d3":16,"es6-promise":17}],152:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33778,31 +33982,89 @@ exports.d3 = _dereq_('d3'); /* global MathJax:false */ +module.exports = function() { + if(typeof MathJax !== 'undefined') { + var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; + + if(globalConfig) { + MathJax.Hub.Config({ + messageStyle: 'none', + skipStartupTypeset: true, + displayAlign: 'left', + tex2jax: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + } + }); + MathJax.Hub.Configured(); + } + } +}; + +},{}],153:[function(_dereq_,module,exports){ /** - * Check and configure MathJax +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + + +/** + * Determine the position anchor property of x/y xanchor/yanchor components. + * + * - values < 1/3 align the low side at that fraction, + * - values [1/3, 2/3] align the center at that fraction, + * - values > 2/3 align the right at that fraction. */ -if(typeof MathJax !== 'undefined') { - exports.MathJax = true; - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } +exports.isLeftAnchor = function isLeftAnchor(opts) { + return ( + opts.xanchor === 'left' || + (opts.xanchor === 'auto' && opts.x <= 1 / 3) + ); +}; -} else { - exports.MathJax = false; -} +exports.isCenterAnchor = function isCenterAnchor(opts) { + return ( + opts.xanchor === 'center' || + (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) + ); +}; -},{}],156:[function(_dereq_,module,exports){ +exports.isRightAnchor = function isRightAnchor(opts) { + return ( + opts.xanchor === 'right' || + (opts.xanchor === 'auto' && opts.x >= 2 / 3) + ); +}; + +exports.isTopAnchor = function isTopAnchor(opts) { + return ( + opts.yanchor === 'top' || + (opts.yanchor === 'auto' && opts.y >= 2 / 3) + ); +}; + +exports.isMiddleAnchor = function isMiddleAnchor(opts) { + return ( + opts.yanchor === 'middle' || + (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) + ); +}; + +exports.isBottomAnchor = function isBottomAnchor(opts) { + return ( + opts.yanchor === 'bottom' || + (opts.yanchor === 'auto' && opts.y <= 1 / 3) + ); +}; + +},{}],154:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34043,7 +34305,7 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":177}],157:[function(_dereq_,module,exports){ +},{"./mod":175}],155:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34179,7 +34441,30 @@ exports.concat = function() { return out; }; -},{}],158:[function(_dereq_,module,exports){ +exports.maxRowLength = function(z) { + return _rowLength(z, Math.max, 0); +}; + +exports.minRowLength = function(z) { + return _rowLength(z, Math.min, Infinity); +}; + +function _rowLength(z, fn, len0) { + if(isArrayOrTypedArray(z)) { + if(isArrayOrTypedArray(z[0])) { + var len = len0; + for(var i = 0; i < z.length; i++) { + len = fn(len, z[i].length); + } + return len; + } else { + return z.length; + } + } + return 0; +} + +},{}],156:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34212,7 +34497,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":152,"fast-isnumeric":18}],159:[function(_dereq_,module,exports){ +},{"../constants/numerical":149,"fast-isnumeric":18}],157:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34240,7 +34525,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],160:[function(_dereq_,module,exports){ +},{}],158:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34263,7 +34548,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],161:[function(_dereq_,module,exports){ +},{}],159:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34272,18 +34557,17 @@ module.exports = function clearResponsive(gd) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); var baseTraceAttrs = _dereq_('../plots/attributes'); -var getColorscale = _dereq_('../components/colorscale/get_scale'); -var colorscaleNames = Object.keys(_dereq_('../components/colorscale/scales')); +var scales = _dereq_('../components/colorscale/scales'); +var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; + var nestedProperty = _dereq_('./nested_property'); var counterRegex = _dereq_('./regex').counter; -var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; var modHalf = _dereq_('./mod').modHalf; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -34401,7 +34685,7 @@ exports.valObjectMeta = { coerceFunction: function(v, propOut, dflt) { - propOut.set(getColorscale(v, dflt)); + propOut.set(scales.get(v, dflt)); } }, angle: { @@ -34735,7 +35019,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/get_scale":64,"../components/colorscale/scales":70,"../constants/interactions":151,"../plots/attributes":211,"./array":157,"./mod":177,"./nested_property":178,"./regex":185,"fast-isnumeric":18,"tinycolor2":34}],162:[function(_dereq_,module,exports){ +},{"../components/colorscale/scales":66,"../constants/interactions":148,"../plots/attributes":209,"./array":155,"./mod":175,"./nested_property":176,"./regex":183,"fast-isnumeric":18,"tinycolor2":34}],160:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35338,7 +35622,7 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":152,"../registry":259,"./loggers":174,"./mod":177,"d3":16,"fast-isnumeric":18}],163:[function(_dereq_,module,exports){ +},{"../constants/numerical":149,"../registry":257,"./loggers":172,"./mod":175,"d3":16,"fast-isnumeric":18}],161:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35512,7 +35796,7 @@ var Events = { module.exports = Events; -},{"events":15}],164:[function(_dereq_,module,exports){ +},{"events":15}],162:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35628,7 +35912,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":171}],165:[function(_dereq_,module,exports){ +},{"./is_plain_object.js":169}],163:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35679,7 +35963,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],166:[function(_dereq_,module,exports){ +},{}],164:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35726,7 +36010,7 @@ function isCalcData(cont) { ); } -},{}],167:[function(_dereq_,module,exports){ +},{}],165:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35972,7 +36256,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":177}],168:[function(_dereq_,module,exports){ +},{"./mod":175}],166:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36010,7 +36294,7 @@ module.exports = function(gd) { return gd; // otherwise assume that gd is a DOM element }; -},{}],169:[function(_dereq_,module,exports){ +},{}],167:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36026,7 +36310,7 @@ module.exports = function(gd) { module.exports = function identity(d) { return d; }; -},{}],170:[function(_dereq_,module,exports){ +},{}],168:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36060,6 +36344,8 @@ lib.isArrayOrTypedArray = arrayModule.isArrayOrTypedArray; lib.isArray1D = arrayModule.isArray1D; lib.ensureArray = arrayModule.ensureArray; lib.concat = arrayModule.concat; +lib.maxRowLength = arrayModule.maxRowLength; +lib.minRowLength = arrayModule.minRowLength; var modModule = _dereq_('./mod'); lib.mod = modModule.mod; @@ -36129,6 +36415,14 @@ lib.pathArc = anglesModule.pathArc; lib.pathSector = anglesModule.pathSector; lib.pathAnnulus = anglesModule.pathAnnulus; +var anchorUtils = _dereq_('./anchor_utils'); +lib.isLeftAnchor = anchorUtils.isLeftAnchor; +lib.isCenterAnchor = anchorUtils.isCenterAnchor; +lib.isRightAnchor = anchorUtils.isRightAnchor; +lib.isTopAnchor = anchorUtils.isTopAnchor; +lib.isMiddleAnchor = anchorUtils.isMiddleAnchor; +lib.isBottomAnchor = anchorUtils.isBottomAnchor; + var geom2dModule = _dereq_('./geometry2d'); lib.segmentsIntersect = geom2dModule.segmentsIntersect; lib.segmentDistance = geom2dModule.segmentDistance; @@ -36663,7 +36957,13 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) objOut[k] = v.slice(0, arrayLen); + else if(Array.isArray(v)) { + if(k === 'colorscale') { + objOut[k] = v.slice(); + } else { + objOut[k] = v.slice(0, arrayLen); + } + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -37008,10 +37308,10 @@ lib.numSeparate = function(value, separators, separatethousands) { return x1 + x2; }; -var TEMPLATE_STRING_REGEX = /%{([^\s%{}]*)}/g; +var TEMPLATE_STRING_REGEX = /%{([^\s%{}:]*)(:[^}]*)?}/g; var SIMPLE_PROPERTY_REGEX = /^\w*$/; -/* +/** * Substitute values from an object into a string * * Examples: @@ -37023,7 +37323,6 @@ var SIMPLE_PROPERTY_REGEX = /^\w*$/; * * @return {string} templated string */ - lib.templateString = function(string, obj) { // Not all that useful, but cache nestedProperty instantiation // just in case it speeds things up *slightly*: @@ -37038,6 +37337,67 @@ lib.templateString = function(string, obj) { }); }; +var TEMPLATE_STRING_FORMAT_SEPARATOR = /^:/; +var numberOfHoverTemplateWarnings = 0; +var maximumNumberOfHoverTemplateWarnings = 10; +/** + * Substitute values from an object into a string and optionally formats them using d3-format, + * or fallback to associated labels. + * + * Examples: + * Lib.templateString('name: %{trace}', {trace: 'asdf'}) --> 'name: asdf' + * Lib.templateString('name: %{trace[0].name}', {trace: [{name: 'asdf'}]}) --> 'name: asdf' + * Lib.templateString('price: %{y:$.2f}', {y: 1}) --> 'price: $1.00' + * + * @param {string} input string containing %{...:...} template strings + * @param {obj} data object containing fallback text when no formatting is specified, ex.: {yLabel: 'formattedYValue'} + * @param {obj} data objects containing substitution values + * + * @return {string} templated string + */ +lib.hovertemplateString = function(string, labels) { + var args = arguments; + // Not all that useful, but cache nestedProperty instantiation + // just in case it speeds things up *slightly*: + var getterCache = {}; + + return string.replace(TEMPLATE_STRING_REGEX, function(match, key, format) { + var obj, value, i; + for(i = 2; i < args.length; i++) { + obj = args[i]; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; + } + + if(value === undefined) { + if(numberOfHoverTemplateWarnings < maximumNumberOfHoverTemplateWarnings) { + lib.warn('Variable \'' + key + '\' in hovertemplate could not be found!'); + value = match; + } + + if(numberOfHoverTemplateWarnings === maximumNumberOfHoverTemplateWarnings) { + lib.warn('Too many hovertemplate warnings - additional warnings will be suppressed'); + } + numberOfHoverTemplateWarnings++; + } + + if(format) { + value = d3.format(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value); + } else { + if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + } + return value; + }); +}; + /* * alphanumeric string sort, tailored for subplot IDs like scene2, scene10, x10y13 etc */ @@ -37080,7 +37440,7 @@ lib.pseudoRandom = function() { return randSeed / 4294967296; }; -},{"../constants/numerical":152,"./angles":156,"./array":157,"./clean_number":158,"./clear_responsive":160,"./coerce":161,"./dates":162,"./extend":164,"./filter_unique":165,"./filter_visible":166,"./geometry2d":167,"./get_graph_div":168,"./identity":169,"./is_plain_object":171,"./keyed_container":172,"./localize":173,"./loggers":174,"./make_trace_groups":175,"./matrix":176,"./mod":177,"./nested_property":178,"./noop":179,"./notifier":180,"./push_unique":183,"./regex":185,"./relative_attr":186,"./relink_private":187,"./search":188,"./stats":190,"./throttle":192,"./to_log_range":193,"d3":16,"fast-isnumeric":18}],171:[function(_dereq_,module,exports){ +},{"../constants/numerical":149,"./anchor_utils":153,"./angles":154,"./array":155,"./clean_number":156,"./clear_responsive":158,"./coerce":159,"./dates":160,"./extend":162,"./filter_unique":163,"./filter_visible":164,"./geometry2d":165,"./get_graph_div":166,"./identity":167,"./is_plain_object":169,"./keyed_container":170,"./localize":171,"./loggers":172,"./make_trace_groups":173,"./matrix":174,"./mod":175,"./nested_property":176,"./noop":177,"./notifier":178,"./push_unique":181,"./regex":183,"./relative_attr":184,"./relink_private":185,"./search":186,"./stats":188,"./throttle":190,"./to_log_range":191,"d3":16,"fast-isnumeric":18}],169:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37109,7 +37469,7 @@ module.exports = function isPlainObject(obj) { ); }; -},{}],172:[function(_dereq_,module,exports){ +},{}],170:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37302,7 +37662,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":178}],173:[function(_dereq_,module,exports){ +},{"./nested_property":176}],171:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37358,7 +37718,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":259}],174:[function(_dereq_,module,exports){ +},{"../registry":257}],172:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37444,7 +37804,7 @@ function apply(f, args) { } } -},{"../plot_api/plot_config":202}],175:[function(_dereq_,module,exports){ +},{"../plot_api/plot_config":200}],173:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37481,7 +37841,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{}],176:[function(_dereq_,module,exports){ +},{}],174:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37591,7 +37951,7 @@ exports.apply2DTransform2 = function(transform) { }; }; -},{}],177:[function(_dereq_,module,exports){ +},{}],175:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37626,7 +37986,7 @@ module.exports = { modHalf: modHalf }; -},{}],178:[function(_dereq_,module,exports){ +},{}],176:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37873,7 +38233,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":157,"fast-isnumeric":18}],179:[function(_dereq_,module,exports){ +},{"./array":155,"fast-isnumeric":18}],177:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37889,7 +38249,7 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],180:[function(_dereq_,module,exports){ +},{}],178:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37971,7 +38331,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":16,"fast-isnumeric":18}],181:[function(_dereq_,module,exports){ +},{"d3":16,"fast-isnumeric":18}],179:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38020,7 +38380,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":189}],182:[function(_dereq_,module,exports){ +},{"./setcursor":187}],180:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38273,7 +38633,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":152,"./matrix":176}],183:[function(_dereq_,module,exports){ +},{"../constants/numerical":149,"./matrix":174}],181:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38313,7 +38673,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],184:[function(_dereq_,module,exports){ +},{}],182:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38524,7 +38884,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":170,"../plot_api/plot_config":202}],185:[function(_dereq_,module,exports){ +},{"../lib":168,"../plot_api/plot_config":200}],183:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38543,16 +38903,18 @@ module.exports = queue; * @param {Optional(string)} tail: a fixed piece after the id * eg counterRegex('scene', '.annotations') for scene2.annotations etc. * @param {boolean} openEnded: if true, the string may continue past the match. + * @param {boolean} matchBeginning: if false, the string may start before the match. */ -exports.counter = function(head, tail, openEnded) { +exports.counter = function(head, tail, openEnded, matchBeginning) { var fullTail = (tail || '') + (openEnded ? '' : '$'); + var startWithPrefix = matchBeginning === false ? '' : '^'; if(head === 'xy') { - return new RegExp('^x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + 'x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); } - return new RegExp('^' + head + '([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],186:[function(_dereq_,module,exports){ +},{}],184:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38605,7 +38967,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],187:[function(_dereq_,module,exports){ +},{}],185:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38668,7 +39030,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":157,"./is_plain_object":171}],188:[function(_dereq_,module,exports){ +},{"./array":155,"./is_plain_object":169}],186:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38856,7 +39218,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"./identity":169,"./loggers":174,"fast-isnumeric":18}],189:[function(_dereq_,module,exports){ +},{"./identity":167,"./loggers":172,"fast-isnumeric":18}],187:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38879,7 +39241,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],190:[function(_dereq_,module,exports){ +},{}],188:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38980,7 +39342,7 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":157,"fast-isnumeric":18}],191:[function(_dereq_,module,exports){ +},{"./array":155,"fast-isnumeric":18}],189:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39755,7 +40117,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":149,"../constants/xmlns_namespaces":153,"../lib":170,"d3":16}],192:[function(_dereq_,module,exports){ +},{"../constants/alignment":146,"../constants/xmlns_namespaces":150,"../lib":168,"d3":16}],190:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39859,7 +40221,7 @@ function _clearTimeout(cache) { } } -},{}],193:[function(_dereq_,module,exports){ +},{}],191:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39887,7 +40249,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":18}],194:[function(_dereq_,module,exports){ +},{"fast-isnumeric":18}],192:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39909,7 +40271,7 @@ module.exports = { } }; -},{}],195:[function(_dereq_,module,exports){ +},{}],193:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39952,7 +40314,7 @@ module.exports = { } }; -},{}],196:[function(_dereq_,module,exports){ +},{}],194:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40010,7 +40372,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":259}],197:[function(_dereq_,module,exports){ +},{"../registry":257}],195:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40136,7 +40498,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":170}],198:[function(_dereq_,module,exports){ +},{"../lib":168}],196:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40192,6 +40554,8 @@ exports.cleanLayout = function(layout) { } var axisAttrRegex = (Plots.subplotsRegistry.cartesian || {}).attrRegex; + var polarAttrRegex = (Plots.subplotsRegistry.polar || {}).attrRegex; + var ternaryAttrRegex = (Plots.subplotsRegistry.ternary || {}).attrRegex; var sceneAttrRegex = (Plots.subplotsRegistry.gl3d || {}).attrRegex; var keys = Object.keys(layout); @@ -40230,6 +40594,24 @@ exports.cleanLayout = function(layout) { } delete ax.autotick; } + + cleanTitle(ax); + } + + // modifications for polar + else if(polarAttrRegex && polarAttrRegex.test(key)) { + var polar = layout[key]; + + cleanTitle(polar.radialaxis); + } + + // modifications for ternary + else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + var ternary = layout[key]; + + cleanTitle(ternary.aaxis); + cleanTitle(ternary.baxis); + cleanTitle(ternary.caxis); } // modifications for 3D scenes @@ -40253,11 +40635,16 @@ exports.cleanLayout = function(layout) { scene.camera = { eye: {x: eye[0], y: eye[1], z: eye[2]}, center: {x: center[0], y: center[1], z: center[2]}, - up: {x: mat[1], y: mat[5], z: mat[9]} + up: {x: 0, y: 0, z: 1} // we just ignore calculating camera z up in this case }; delete scene.cameraposition; } + + // clean axis titles + cleanTitle(scene.xaxis); + cleanTitle(scene.yaxis); + cleanTitle(scene.zaxis); } } @@ -40315,6 +40702,9 @@ exports.cleanLayout = function(layout) { } } + // clean plot title + cleanTitle(layout); + /* * Moved from rotate -> orbit for dragmode */ @@ -40324,6 +40714,11 @@ exports.cleanLayout = function(layout) { // supported, but new tinycolor does not because they're not valid css Color.clean(layout); + // clean the layout container in layout.template + if(layout.template && layout.template.layout) { + exports.cleanLayout(layout.template.layout); + } + return layout; }; @@ -40335,6 +40730,46 @@ function cleanAxRef(container, attr) { } } +/** + * Cleans up old title attribute structure (flat) in favor of the new one (nested). + * + * @param {Object} titleContainer - an object potentially including deprecated title attributes + */ +function cleanTitle(titleContainer) { + if(titleContainer) { + + // title -> title.text + // (although title used to be a string attribute, + // numbers are accepted as well) + if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') { + titleContainer.title = { + text: titleContainer.title + }; + } + + rewireAttr('titlefont', 'font'); + rewireAttr('titleposition', 'position'); + rewireAttr('titleside', 'side'); + rewireAttr('titleoffset', 'offset'); + } + + function rewireAttr(oldAttrName, newAttrName) { + var oldAttrSet = titleContainer[oldAttrName]; + var newAttrSet = titleContainer.title && titleContainer.title[newAttrName]; + + if(oldAttrSet && !newAttrSet) { + + // Ensure title object exists + if(!titleContainer.title) { + titleContainer.title = {}; + } + + titleContainer.title[newAttrName] = titleContainer[oldAttrName]; + delete titleContainer[oldAttrName]; + } + } +} + /* * cleanData: Make a few changes to the data for backward compatibility * before it gets used for anything. Modifies the data traces users provide. @@ -40538,6 +40973,13 @@ exports.cleanData = function(data) { delete trace.autobiny; delete trace.ybins; } + + cleanTitle(trace); + if(trace.colorbar) cleanTitle(trace.colorbar); + if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar); + if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar); + if(trace.aaxis) cleanTitle(trace.aaxis); + if(trace.baxis) cleanTitle(trace.baxis); } }; @@ -40578,11 +41020,14 @@ function commonPrefix(name1, name2, show1, show2) { function cleanTextPosition(textposition) { var posY = 'middle', posX = 'center'; - if(textposition.indexOf('top') !== -1) posY = 'top'; - else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; - if(textposition.indexOf('left') !== -1) posX = 'left'; - else if(textposition.indexOf('right') !== -1) posX = 'right'; + if(typeof textposition === 'string') { + if(textposition.indexOf('top') !== -1) posY = 'top'; + else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; + + if(textposition.indexOf('left') !== -1) posX = 'left'; + else if(textposition.indexOf('right') !== -1) posX = 'right'; + } return posY + ' ' + posX; } @@ -40758,7 +41203,7 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":51,"../lib":170,"../plots/cartesian/axis_ids":217,"../plots/plots":247,"../registry":259,"fast-isnumeric":18,"gl-mat4/fromQuat":19}],199:[function(_dereq_,module,exports){ +},{"../components/color":51,"../lib":168,"../plots/cartesian/axis_ids":215,"../plots/plots":245,"../registry":257,"fast-isnumeric":18,"gl-mat4/fromQuat":19}],197:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40777,6 +41222,10 @@ exports.restyle = main.restyle; exports.relayout = main.relayout; exports.redraw = main.redraw; exports.update = main.update; +exports._guiRestyle = main._guiRestyle; +exports._guiRelayout = main._guiRelayout; +exports._guiUpdate = main._guiUpdate; +exports._storeDirectGUIEdit = main._storeDirectGUIEdit; exports.react = main.react; exports.extendTraces = main.extendTraces; exports.prependTraces = main.prependTraces; @@ -40797,7 +41246,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":261,"./plot_api":201,"./template_api":206,"./to_image":207,"./validate":208}],200:[function(_dereq_,module,exports){ +},{"../snapshot/download":259,"./plot_api":199,"./template_api":204,"./to_image":205,"./validate":206}],198:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40809,7 +41258,6 @@ exports.validateTemplate = templateApi.validateTemplate; 'use strict'; -var nestedProperty = _dereq_('../lib/nested_property'); var isPlainObject = _dereq_('../lib/is_plain_object'); var noop = _dereq_('../lib/noop'); var Loggers = _dereq_('../lib/loggers'); @@ -40866,11 +41314,15 @@ var isRemoveVal = exports.isRemoveVal = function isRemoveVal(val) { * the flags for which actions we're going to perform to display these (and * any other) changes. If we're already `recalc`ing, we don't need to redraw * individual items + * @param {function} _nestedProperty + * a (possibly modified for gui edits) nestedProperty constructor + * The modified version takes a 3rd argument, for a prefix to the attribute + * string necessary for storing GUI edits * * @returns {bool} `true` if it managed to complete drawing of the changes * `false` would mean the parent should replot. */ -exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags) { +exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags, _nestedProperty) { var componentType = np.astr, supplyComponentDefaults = Registry.getComponentMethod(componentType, 'supplyLayoutDefaults'), draw = Registry.getComponentMethod(componentType, 'draw'), @@ -40910,7 +41362,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, // redoing supplyDefaults // TODO: this assumes componentArray is in gd.layout - which will not be // true after we extend this to restyle - componentArrayFull = nestedProperty(fullLayout, componentType).get(); + componentArrayFull = _nestedProperty(fullLayout, componentType).get(); var deletes = [], firstIndexChange = -1, @@ -40921,7 +41373,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, objEdits, objKeys, objVal, - adding; + adding, prefix; // first make the add and edit changes for(i = 0; i < componentNums.length; i++) { @@ -40960,7 +41412,9 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, } else { for(j = 0; j < objKeys.length; j++) { - nestedProperty(componentArray[componentNum], objKeys[j]).set(objEdits[objKeys[j]]); + prefix = componentType + '[' + componentNum + '].'; + _nestedProperty(componentArray[componentNum], objKeys[j], prefix) + .set(objEdits[objKeys[j]]); } } } @@ -41011,7 +41465,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":171,"../lib/loggers":174,"../lib/nested_property":178,"../lib/noop":179,"../lib/search":188,"../registry":259,"./container_array_match":196}],201:[function(_dereq_,module,exports){ +},{"../lib/is_plain_object":169,"../lib/loggers":172,"../lib/noop":177,"../lib/search":186,"../registry":257,"./container_array_match":194}],199:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -41029,6 +41483,8 @@ var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); var Lib = _dereq_('../lib'); +var nestedProperty = Lib.nestedProperty; + var Events = _dereq_('../lib/events'); var Queue = _dereq_('../lib/queue'); @@ -41124,9 +41580,6 @@ exports.plot = function(gd, data, layout, config) { // so we can share cached text across tabs Drawing.makeTester(); - // clear stashed base url - delete Drawing.baseUrl; - // collect promises for any async actions during plotting // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all @@ -41171,7 +41624,7 @@ exports.plot = function(gd, data, layout, config) { // Legacy polar plots if(!fullLayout._has('polar') && data && data[0] && data[0].r) { Lib.log('Legacy polar charts are deprecated!'); - return plotPolar(gd, data, layout); + return plotLegacyPolar(gd, data, layout); } // so we don't try to re-call Plotly.plot from inside @@ -41347,8 +41800,7 @@ exports.plot = function(gd, data, layout, config) { return Lib.syncOrAsync([ Registry.getComponentMethod('shapes', 'calcAutorange'), Registry.getComponentMethod('annotations', 'calcAutorange'), - doAutoRangeAndConstraints, - Registry.getComponentMethod('rangeslider', 'calcAutorange') + doAutoRangeAndConstraints ], gd); } @@ -41360,11 +41812,16 @@ exports.plot = function(gd, data, layout, config) { // store initial ranges *after* enforcing constraints, otherwise // we will never look like we're at the initial ranges if(graphWasEmpty) Axes.saveRangeInitial(gd); + + // this one is different from shapes/annotations calcAutorange + // the others incorporate those components into ax._extremes, + // this one actually sets the ranges in rangesliders. + Registry.getComponentMethod('rangeslider', 'calcAutorange')(gd); } // draw ticks, titles, and calculate axis scaling (._b, ._m) function drawAxes() { - return Axes.doTicks(gd, graphWasEmpty ? '' : 'redraw'); + return Axes.draw(gd, graphWasEmpty ? '' : 'redraw'); } var seq = [ @@ -41433,7 +41890,16 @@ function opaqueSetBackground(gd, bgColor) { } function setPlotContext(gd, config) { - if(!gd._context) gd._context = Lib.extendDeep({}, defaultConfig); + if(!gd._context) { + gd._context = Lib.extendDeep({}, defaultConfig); + + // stash href, used to make robust clipPath URLs + var base = d3.select('base'); + gd._context._baseUrl = base.size() && base.attr('href') ? + window.location.href.split('#')[0] : + ''; + } + var context = gd._context; var i, keys, key; @@ -41479,6 +41945,9 @@ function setPlotContext(gd, config) { } } } + + // not part of the user-facing config options + context._exportedPlot = config._exportedPlot; } // staticPlot forces a bunch of others: @@ -41508,7 +41977,7 @@ function setPlotContext(gd, config) { context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0; } -function plotPolar(gd, data, layout) { +function plotLegacyPolar(gd, data, layout) { // build or reuse the container skeleton var plotContainer = d3.select(gd).selectAll('.plot-container') .data([0]); @@ -41549,7 +42018,7 @@ function plotPolar(gd, data, layout) { // editable title var opacity = 1; - var txt = gd._fullLayout.title; + var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; if(txt === '' || !txt) opacity = 0; var titleLayout = function() { @@ -41583,7 +42052,7 @@ function plotPolar(gd, data, layout) { var setContenteditable = function() { this.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { - gd.framework({layout: {title: text}}); + gd.framework({layout: {title: {text: text}}}); this.text(text) .call(titleLayout); this.call(setContenteditable); @@ -41856,7 +42325,7 @@ function getExtendProperties(gd, update, indices, maxPoints) { * instance that references the key and value for this particular trace. */ trace = gd.data[indices[j]]; - prop = Lib.nestedProperty(trace, key); + prop = nestedProperty(trace, key); /* * Target is the existing gd.data.trace.dataArray value like "x" or "marker.size" @@ -42327,7 +42796,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) { * If the array is too short, it will wrap around (useful for * style files that want to specify cyclical default values). */ -exports.restyle = function restyle(gd, astr, val, _traces) { +function restyle(gd, astr, val, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -42397,7 +42866,8 @@ exports.restyle = function restyle(gd, astr, val, _traces) { gd.emit('plotly_restyle', specs.eventData); return gd; }); -}; +} +exports.restyle = restyle; // for undo: undefined initial vals must be turned into nulls // so that we unset rather than ignore them @@ -42406,11 +42876,77 @@ function undefinedToNull(val) { return val; } +/** + * Factory function to wrap nestedProperty with GUI edits if necessary + * with GUI edits we add an optional prefix to the nestedProperty constructor + * to prepend to the attribute string in the preGUI store. + */ +function makeNP(preGUI, guiEditFlag) { + if(!guiEditFlag) return nestedProperty; + + return function(container, attr, prefix) { + var np = nestedProperty(container, attr); + var npSet = np.set; + np.set = function(val) { + var fullAttr = (prefix || '') + attr; + storeCurrent(fullAttr, np.get(), val, preGUI); + npSet(val); + }; + return np; + }; +} + +function storeCurrent(attr, val, newVal, preGUI) { + if(Array.isArray(val) || Array.isArray(newVal)) { + var arrayVal = Array.isArray(val) ? val : []; + var arrayNew = Array.isArray(newVal) ? newVal : []; + var maxLen = Math.max(arrayVal.length, arrayNew.length); + for(var i = 0; i < maxLen; i++) { + storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); + } + } + else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + var objVal = Lib.isPlainObject(val) ? val : {}; + var objNew = Lib.isPlainObject(newVal) ? newVal : {}; + var objBoth = Lib.extendFlat({}, objVal, objNew); + for(var key in objBoth) { + storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); + } + } + else if(preGUI[attr] === undefined) { + preGUI[attr] = undefinedToNull(val); + } +} + +/** + * storeDirectGUIEdit: for routines that skip restyle/relayout and mock it + * by emitting a plotly_restyle or plotly_relayout event, this routine + * keeps track of the initial state in _preGUI for use by uirevision + * Does *not* apply these changes to data/layout - that's the responsibility + * of the calling routine. + * + * @param {object} container: the input attributes container (eg `layout` or a `trace`) + * @param {object} preGUI: where original values should be stored, either + * `layout._preGUI` or `layout._tracePreGUI[uid]` + * @param {object} edits: the {attr: val} object as normally passed to `relayout` etc + */ +exports._storeDirectGUIEdit = function(container, preGUI, edits) { + for(var attr in edits) { + var np = nestedProperty(container, attr); + storeCurrent(attr, np.get(), edits[attr], preGUI); + } +}; + function _restyle(gd, aobj, traces) { - var fullLayout = gd._fullLayout, - fullData = gd._fullData, - data = gd.data, - i; + var fullLayout = gd._fullLayout; + var fullData = gd._fullData; + var data = gd.data; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var eventData = Lib.extendDeepAll({}, aobj); + var i; + + cleanDeprecatedAttributeKeys(aobj); // initialize flags var flags = editTypes.traceFlags(); @@ -42434,6 +42970,16 @@ function _restyle(gd, aobj, traces) { function rangeAttr(axName) { return 'LAYOUT' + axName + '.range'; } + function getFullTrace(traceIndex) { + // usually fullData maps 1:1 onto data, but with groupby transforms + // the fullData index can be greater. Take the *first* matching trace. + for(var j = traceIndex; j < fullData.length; j++) { + if(fullData[j]._input === data[traceIndex]) return fullData[j]; + } + // should never get here - and if we *do* it should cause an error + // later on undefined fullTrace is passed to nestedProperty. + } + // for attrs that interact (like scales & autoscales), save the // old vals before making the change // val=undefined will not set a value, just record what the value was. @@ -42449,9 +42995,11 @@ function _restyle(gd, aobj, traces) { var extraparam; if(attr.substr(0, 6) === 'LAYOUT') { - extraparam = Lib.nestedProperty(gd.layout, attr.replace('LAYOUT', '')); + extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', '')); } else { - extraparam = Lib.nestedProperty(data[traces[i]], attr); + var tracei = traces[i]; + var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid]; + extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr); } if(!(attr in undoit)) { @@ -42506,7 +43054,7 @@ function _restyle(gd, aobj, traces) { redoit[ai] = vi; if(ai.substr(0, 6) === 'LAYOUT') { - param = Lib.nestedProperty(gd.layout, ai.replace('LAYOUT', '')); + param = layoutNP(gd.layout, ai.replace('LAYOUT', '')); undoit[ai] = [undefinedToNull(param.get())]; // since we're allowing val to be an array, allow it here too, // even though that's meaningless @@ -42521,8 +43069,9 @@ function _restyle(gd, aobj, traces) { undoit[ai] = a0(); for(i = 0; i < traces.length; i++) { cont = data[traces[i]]; - contFull = fullData[traces[i]]; - param = Lib.nestedProperty(cont, ai); + contFull = getFullTrace(traces[i]); + var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid]; + param = makeNP(preGUI, guiEditFlag)(cont, ai); oldVal = param.get(); newVal = Array.isArray(vi) ? vi[i % vi.length] : vi; @@ -42532,7 +43081,7 @@ function _restyle(gd, aobj, traces) { var prefix = ai.substr(0, ai.length - finalPart.length - 1); var prefixDot = prefix ? prefix + '.' : ''; var innerContFull = prefix ? - Lib.nestedProperty(contFull, prefix).get() : contFull; + nestedProperty(contFull, prefix).get() : contFull; valObject = PlotSchema.getTraceValObject(contFull, param.parts); @@ -42579,14 +43128,14 @@ function _restyle(gd, aobj, traces) { Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo); if(oldVal === 'pie') { - Lib.nestedProperty(cont, 'marker.color') - .set(Lib.nestedProperty(cont, 'marker.colors').get()); + nestedProperty(cont, 'marker.color') + .set(nestedProperty(cont, 'marker.colors').get()); // super kludgy - but if all pies are gone we won't remove them otherwise fullLayout._pielayer.selectAll('g.trace').remove(); } else if(Registry.traceIs(cont, 'cartesian')) { - Lib.nestedProperty(cont, 'marker.colors') - .set(Lib.nestedProperty(cont, 'marker.color').get()); + nestedProperty(cont, 'marker.colors') + .set(nestedProperty(cont, 'marker.color').get()); } } @@ -42657,7 +43206,7 @@ function _restyle(gd, aobj, traces) { // swap hovermode if set to "compare x/y data" if(ai === 'orientationaxes') { - var hovermode = Lib.nestedProperty(gd.layout, 'hovermode'); + var hovermode = nestedProperty(gd.layout, 'hovermode'); if(hovermode.get() === 'x') { hovermode.set('y'); } else if(hovermode.get() === 'y') { @@ -42696,10 +43245,53 @@ function _restyle(gd, aobj, traces) { undoit: undoit, redoit: redoit, traces: traces, - eventData: Lib.extendDeepNoArrays([], [redoit, traces]) + eventData: Lib.extendDeepNoArrays([], [eventData, traces]) }; } +/** + * Converts deprecated attribute keys to + * the current API to ensure backwards compatibility. + * + * This is needed for the update mechanism to determine which + * subroutines to run based on the actual attribute + * definitions (that don't include the deprecated ones). + * + * E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'} + * and {titlefont: {...}} to {'title.font': {...}}. + * + * @param aobj + */ +function cleanDeprecatedAttributeKeys(aobj) { + var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false); + var colorbarRegex = /colorbar\.title$/; + var keys = Object.keys(aobj); + var i, key, value; + + for(i = 0; i < keys.length; i++) { + key = keys[i]; + value = aobj[key]; + + if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) && + (typeof value === 'string' || typeof value === 'number')) { + replace(key, key.replace('title', 'title.text')); + } else if(key.indexOf('titlefont') > -1) { + replace(key, key.replace('titlefont', 'title.font')); + } else if(key.indexOf('titleposition') > -1) { + replace(key, key.replace('titleposition', 'title.position')); + } else if(key.indexOf('titleside') > -1) { + replace(key, key.replace('titleside', 'title.side')); + } else if(key.indexOf('titleoffset') > -1) { + replace(key, key.replace('titleoffset', 'title.offset')); + } + } + + function replace(oldAttrStr, newAttrStr) { + aobj[newAttrStr] = aobj[oldAttrStr]; + delete aobj[oldAttrStr]; + } +} + /** * relayout: update layout attributes of an existing plot * @@ -42720,7 +43312,7 @@ function _restyle(gd, aobj, traces) { * attribute object `{astr1: val1, astr2: val2 ...}` * allows setting multiple attributes simultaneously */ -exports.relayout = function relayout(gd, astr, val) { +function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -42783,7 +43375,8 @@ exports.relayout = function relayout(gd, astr, val) { gd.emit('plotly_relayout', specs.eventData); return gd; }); -}; +} +exports.relayout = relayout; // Optimization mostly for large splom traces where // Plots.supplyDefaults can take > 100ms @@ -42811,13 +43404,24 @@ function addAxRangeSequence(seq, rangesAltered) { // N.B. leave as sequence of subroutines (for now) instead of // subroutine of its own so that finalDraw always gets // executed after drawData - var doTicks = rangesAltered ? - function(gd) { return Axes.doTicks(gd, Object.keys(rangesAltered), true); } : - function(gd) { return Axes.doTicks(gd, 'redraw'); }; + var drawAxes = rangesAltered ? + function(gd) { + var opts = {skipTitle: true}; + for(var id in rangesAltered) { + if(Axes.getFromId(gd, id).automargin) { + opts = {}; + break; + } + } + return Axes.draw(gd, Object.keys(rangesAltered), opts); + } : + function(gd) { + return Axes.draw(gd, 'redraw'); + }; seq.push( subroutines.doAutoRangeAndConstraints, - doTicks, + drawAxes, subroutines.drawData, subroutines.finalDraw ); @@ -42828,14 +43432,19 @@ var AX_AUTORANGE_RE = /^[xyz]axis[0-9]*\.autorange$/; var AX_DOMAIN_RE = /^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/; function _relayout(gd, aobj) { - var layout = gd.layout, - fullLayout = gd._fullLayout, - keys = Object.keys(aobj), - axes = Axes.list(gd), - arrayEdits = {}, - arrayStr, - i, - j; + var layout = gd.layout; + var fullLayout = gd._fullLayout; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var keys = Object.keys(aobj); + var axes = Axes.list(gd); + var eventData = Lib.extendDeepAll({}, aobj); + var arrayEdits = {}; + + var arrayStr, i, j; + + cleanDeprecatedAttributeKeys(aobj); + keys = Object.keys(aobj); // look for 'allaxes', split out into all axes // in case of 3D the axis are nested within a scene which is held in _id @@ -42875,7 +43484,7 @@ function _relayout(gd, aobj) { // via a parent) do not override with this auto-generated extra if(attr in aobj || helpers.hasParent(aobj, attr)) return; - var p = Lib.nestedProperty(layout, attr); + var p = layoutNP(layout, attr); if(!(attr in undoit)) { undoit[attr] = undefinedToNull(p.get()); } @@ -42900,7 +43509,7 @@ function _relayout(gd, aobj) { throw new Error('cannot set ' + ai + 'and a parent attribute simultaneously'); } - var p = Lib.nestedProperty(layout, ai); + var p = layoutNP(layout, ai); var vi = aobj[ai]; var plen = p.parts.length; // p.parts may end with an index integer if the property is an array @@ -42912,8 +43521,8 @@ function _relayout(gd, aobj) { var pleafPlus = p.parts[pend - 1] + '.' + pleaf; // trunk nodes (everything except the leaf) var ptrunk = p.parts.slice(0, pend).join('.'); - var parentIn = Lib.nestedProperty(gd.layout, ptrunk).get(); - var parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + var parentIn = nestedProperty(gd.layout, ptrunk).get(); + var parentFull = nestedProperty(fullLayout, ptrunk).get(); var vOld = p.get(); if(vi === undefined) continue; @@ -42958,12 +43567,12 @@ function _relayout(gd, aobj) { // check autorange vs range else if(pleafPlus.match(AX_RANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - var axFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + var axFull = nestedProperty(fullLayout, ptrunk).get(); if(axFull._inputDomain) { // if we're autoranging and this axis has a constrained domain, // reset it so we don't get locked into a shrunken size @@ -42971,7 +43580,7 @@ function _relayout(gd, aobj) { } } else if(pleafPlus.match(AX_DOMAIN_RE)) { - Lib.nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); + nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } // toggling axis type between log and linear: we need to convert @@ -43040,10 +43649,10 @@ function _relayout(gd, aobj) { doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleaf.match(AX_NAME_PATTERN)) { - var fullProp = Lib.nestedProperty(fullLayout, ai).get(), + var fullProp = nestedProperty(fullLayout, ai).get(), newType = (vi || {}).type; // This can potentially cause strange behavior if the autotype is not @@ -43065,8 +43674,6 @@ function _relayout(gd, aobj) { arrayStr = containerArrayMatch.array; i = containerArrayMatch.index; var propStr = containerArrayMatch.property; - var componentArray = Lib.nestedProperty(layout, arrayStr); - var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; if(i !== '' && propStr === '') { @@ -43076,7 +43683,7 @@ function _relayout(gd, aobj) { if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { - undoit[ai] = obji; + undoit[ai] = (nestedProperty(layout, arrayStr).get() || [])[i]; } else { Lib.warn('unrecognized full object value', aobj); } @@ -43120,7 +43727,7 @@ function _relayout(gd, aobj) { // now we've collected component edits - execute them all together for(arrayStr in arrayEdits) { var finished = manageArrays.applyContainerArrayChanges(gd, - Lib.nestedProperty(layout, arrayStr), arrayEdits[arrayStr], flags); + layoutNP(layout, arrayStr), arrayEdits[arrayStr], flags, layoutNP); if(!finished) flags.plot = true; } @@ -43163,7 +43770,7 @@ function _relayout(gd, aobj) { rangesAltered: rangesAltered, undoit: undoit, redoit: redoit, - eventData: Lib.extendDeep({}, redoit) + eventData: eventData }; } @@ -43198,7 +43805,7 @@ function updateAutosize(gd) { * integer or array of integers for the traces to alter (all if omitted) * */ -exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { +function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -43278,7 +43885,235 @@ exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { return gd; }); -}; +} +exports.update = update; + +/* + * internal-use-only restyle/relayout/update variants that record the initial + * values in (fullLayout|fullTrace)._preGUI so changes can be persisted across + * Plotly.react data updates, dependent on uirevision attributes + */ +function guiEdit(func) { + return function wrappedEdit(gd) { + gd._fullLayout._guiEditing = true; + var p = func.apply(null, arguments); + gd._fullLayout._guiEditing = false; + return p; + }; +} +exports._guiRestyle = guiEdit(restyle); +exports._guiRelayout = guiEdit(relayout); +exports._guiUpdate = guiEdit(update); + +// For connecting edited layout attributes to uirevision attrs +// If no `attr` we use `match[1] + '.uirevision'` +// Ordered by most common edits first, to minimize our search time +var layoutUIControlPatterns = [ + {pattern: /^hiddenlabels/, attr: 'legend.uirevision'}, + {pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/}, + + // showspikes and modes include those nested inside scenes + {pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'}, + {pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'}, + + {pattern: /^(scene\d*)\.camera/}, + {pattern: /^(geo\d*)\.(projection|center)/}, + {pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/}, + {pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/}, + {pattern: /^(polar\d*\.angularaxis)\.rotation/}, + {pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/}, + + {pattern: /^legend\.(x|y)$/, attr: 'editrevision'}, + {pattern: /^(shapes|annotations)/, attr: 'editrevision'}, + {pattern: /^title\.text$/, attr: 'editrevision'} +]; + +// same for trace attributes: if `attr` is given it's in layout, +// or with no `attr` we use `trace.uirevision` +var traceUIControlPatterns = [ + {pattern: /^selectedpoints$/, attr: 'selectionrevision'}, + // "visible" includes trace.transforms[i].styles[j].value.visible + {pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'}, + {pattern: /^dimensions\[\d+\]\.constraintrange/}, + + // below this you must be in editable: true mode + // TODO: I still put name and title with `trace.uirevision` + // reasonable or should these be `editrevision`? + // Also applies to axis titles up in the layout section + + // "name" also includes transform.styles + {pattern: /(^|value\.)name$/}, + // including nested colorbar attributes (ie marker.colorbar) + {pattern: /colorbar\.title\.text$/}, + {pattern: /colorbar\.(x|y)$/, attr: 'editrevision'} +]; + +function findUIPattern(key, patternSpecs) { + for(var i = 0; i < patternSpecs.length; i++) { + var spec = patternSpecs[i]; + var match = key.match(spec.pattern); + if(match) { + return {head: match[1], attr: spec.attr}; + } + } +} + +// We're finding the new uirevision before supplyDefaults, so do the +// inheritance manually. Note that only `undefined` inherits - other +// falsy values are returned. +function getNewRev(revAttr, container) { + var newRev = nestedProperty(container, revAttr).get(); + if(newRev !== undefined) return newRev; + + var parts = revAttr.split('.'); + parts.pop(); + while(parts.length > 1) { + parts.pop(); + newRev = nestedProperty(container, parts.join('.') + '.uirevision').get(); + if(newRev !== undefined) return newRev; + } + + return container.uirevision; +} + +function getFullTraceIndexFromUid(uid, fullData) { + for(var i = 0; i < fullData.length; i++) { + if(fullData[i]._fullInput.uid === uid) return i; + } + return -1; +} + +function getTraceIndexFromUid(uid, data, tracei) { + for(var i = 0; i < data.length; i++) { + if(data[i].uid === uid) return i; + } + // fall back on trace order, but only if user didn't provide a uid for that trace + return data[tracei].uid ? -1 : tracei; +} + +function valsMatch(v1, v2) { + var v1IsObj = Lib.isPlainObject(v1); + var v1IsArray = Array.isArray(v1); + if(v1IsObj || v1IsArray) { + return ( + (v1IsObj && Lib.isPlainObject(v2)) || + (v1IsArray && Array.isArray(v2)) + ) && JSON.stringify(v1) === JSON.stringify(v2); + } + return v1 === v2; +} + +function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { + var layoutPreGUI = oldFullLayout._preGUI; + var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal; + var bothInheritAutorange = []; + var newRangeAccepted = {}; + for(key in layoutPreGUI) { + match = findUIPattern(key, layoutUIControlPatterns); + if(match) { + revAttr = match.attr || (match.head + '.uirevision'); + oldRev = nestedProperty(oldFullLayout, revAttr).get(); + newRev = oldRev && getNewRev(revAttr, layout); + if(newRev && (newRev === oldRev)) { + preGUIVal = layoutPreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(layout, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + if(newVal === undefined && key.substr(key.length - 9) === 'autorange') { + bothInheritAutorange.push(key.substr(0, key.length - 10)); + } + newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key); + } + // if we got this far, the new value was accepted as the new starting + // point (either because it changed or revision changed) + // so remove it from _preGUI for next time. + delete layoutPreGUI[key]; + + if(key.substr(key.length - 8, 6) === 'range[') { + newRangeAccepted[key.substr(0, key.length - 9)] = 1; + } + } + + // Special logic for `autorange`, since it interacts with `range`: + // If the new figure's matching `range` was kept, and `autorange` + // wasn't supplied explicitly in either the original or the new figure, + // we shouldn't alter that - but we may just have done that, so fix it. + for(var i = 0; i < bothInheritAutorange.length; i++) { + var axAttr = bothInheritAutorange[i]; + if(newRangeAccepted[axAttr]) { + var newAx = nestedProperty(layout, axAttr).get(); + if(newAx) delete newAx.autorange; + } + } + + // Now traces - try to match them up by uid (in case we added/deleted in + // the middle), then fall back on index. + var allTracePreGUI = oldFullLayout._tracePreGUI; + for(var uid in allTracePreGUI) { + var tracePreGUI = allTracePreGUI[uid]; + var newTrace = null; + var fullInput; + for(key in tracePreGUI) { + // wait until we know we have preGUI values to look for traces + // but if we don't find both, stop looking at this uid + if(!newTrace) { + var fulli = getFullTraceIndexFromUid(uid, oldFullData); + if(fulli < 0) { + // Somehow we didn't even have this trace in oldFullData... + // I guess this could happen with `deleteTraces` or something + delete allTracePreGUI[uid]; + break; + } + var fullTrace = oldFullData[fulli]; + fullInput = fullTrace._fullInput; + + var newTracei = getTraceIndexFromUid(uid, data, fullInput.index); + if(newTracei < 0) { + // No match in new data + delete allTracePreGUI[uid]; + break; + } + newTrace = data[newTracei]; + } + + match = findUIPattern(key, traceUIControlPatterns); + if(match) { + if(match.attr) { + oldRev = nestedProperty(oldFullLayout, match.attr).get(); + newRev = oldRev && getNewRev(match.attr, layout); + } + else { + oldRev = fullInput.uirevision; + // inheritance for trace.uirevision is simple, just layout.uirevision + newRev = newTrace.uirevision; + if(newRev === undefined) newRev = layout.uirevision; + } + + if(newRev && newRev === oldRev) { + preGUIVal = tracePreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(newTrace, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + newNP.set(undefinedToNull(nestedProperty(fullInput, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); + } + delete tracePreGUI[key]; + } + } +} /** * Plotly.react: @@ -43342,6 +44177,8 @@ exports.react = function(gd, data, layout, config) { gd.layout = layout || {}; helpers.cleanLayout(gd.layout); + applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout); + // "true" skips updating calcdata and remapping arrays from calcTransforms, // which supplyDefaults usually does at the end, but we may need to NOT do // if the diff (which we haven't determined yet) says we'll recalc @@ -44396,7 +45233,7 @@ function makePlotFramework(gd) { gd.emit('plotly_framework'); } -},{"../components/color":51,"../components/colorbar/connect":53,"../components/drawing":76,"../constants/xmlns_namespaces":153,"../lib":170,"../lib/events":163,"../lib/queue":184,"../lib/svg_text_utils":191,"../plots/cartesian/axes":214,"../plots/cartesian/constants":220,"../plots/cartesian/graph_interact":224,"../plots/plots":247,"../plots/polar/legacy":250,"../registry":259,"./edit_types":197,"./helpers":198,"./manage_arrays":200,"./plot_config":202,"./plot_schema":203,"./subroutines":205,"d3":16,"fast-isnumeric":18,"has-hover":20}],202:[function(_dereq_,module,exports){ +},{"../components/color":51,"../components/colorbar/connect":53,"../components/drawing":72,"../constants/xmlns_namespaces":150,"../lib":168,"../lib/events":161,"../lib/queue":182,"../lib/svg_text_utils":189,"../plots/cartesian/axes":212,"../plots/cartesian/constants":218,"../plots/cartesian/graph_interact":222,"../plots/plots":245,"../plots/polar/legacy":248,"../registry":257,"./edit_types":195,"./helpers":196,"./manage_arrays":198,"./plot_config":200,"./plot_schema":201,"./subroutines":203,"d3":16,"fast-isnumeric":18,"has-hover":20}],200:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -44489,12 +45326,34 @@ module.exports = { */ showAxisRangeEntryBoxes: true, - // link to open this plot in plotly + /* + * Add a text link to open this plot in plotly? + * This link shows up in the bottom right corner of the plot, and works + * identically to the newer ModeBar button controlled by `showSendToCloud` + * unless `sendData: false` is used. + */ showLink: false, - // if we show a link, does it contain data or just link to a plotly file? + /* + * If we show a text link (`showLink: true`), does it contain data or just + * a reference to a plotly cloud file? This option should only be used on + * plot.ly or another plotly server, and is not supported by the newer + * ModeBar button `showSendToCloud`. + */ sendData: true, + /* + * Should we include a ModeBar button, labeled "Edit in Chart Studio", + * that sends this chart to plot.ly or another plotly server as specified + * by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0 + * this button was included by default, now it is opt-in using this flag. + * + * Note that this button can (depending on `plotlyServerURL`) send your data + * to an external server. However that server doesn't persist your data + * until you arrive at the Chart Studio and explicitly click "Save". + */ + showSendToCloud: false, + // text appearing in the sendData link linkText: 'Edit chart', @@ -44532,6 +45391,9 @@ module.exports = { // add the plotly logo on the end of the mode bar displaylogo: true, + // watermark the images with the company's logo + watermark: false, + // increase the pixel ratio for Gl plot images plotGlPixelRatio: 2, @@ -44598,7 +45460,7 @@ module.exports = { locales: {} }; -},{}],203:[function(_dereq_,module,exports){ +},{}],201:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45284,7 +46146,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":170,"../plots/animation_attributes":209,"../plots/attributes":211,"../plots/frame_attributes":242,"../plots/layout_attributes":245,"../plots/polar/legacy/area_attributes":248,"../plots/polar/legacy/axis_attributes":249,"../registry":259,"./edit_types":197}],204:[function(_dereq_,module,exports){ +},{"../lib":168,"../plots/animation_attributes":207,"../plots/attributes":209,"../plots/frame_attributes":240,"../plots/layout_attributes":243,"../plots/polar/legacy/area_attributes":246,"../plots/polar/legacy/axis_attributes":247,"../registry":257,"./edit_types":195}],202:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45598,7 +46460,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":170,"../plots/attributes":211}],205:[function(_dereq_,module,exports){ +},{"../lib":168,"../plots/attributes":209}],203:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45628,6 +46490,10 @@ var enforceAxisConstraints = axisConstraints.enforce; var cleanAxisConstraints = axisConstraints.clean; var doAutoRange = _dereq_('../plots/cartesian/autorange').doAutoRange; +var SVG_TEXT_ANCHOR_START = 'start'; +var SVG_TEXT_ANCHOR_MIDDLE = 'middle'; +var SVG_TEXT_ANCHOR_END = 'end'; + exports.layoutStyles = function(gd) { return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd); }; @@ -45652,7 +46518,7 @@ function lsInner(gd) { var gs = fullLayout._size; var pad = gs.p; var axList = Axes.list(gd, '', true); - var i, subplot, plotinfo, xa, ya; + var i, subplot, plotinfo, ax, xa, ya; fullLayout._paperdiv.style({ width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px', @@ -45688,10 +46554,7 @@ function lsInner(gd) { // some preparation of axis position info for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - - // reset scale in case the margins have changed - ax.setScale(); + ax = axList[i]; var counterAx = ax._anchorAxis; @@ -45710,11 +46573,6 @@ function lsInner(gd) { ax._mainMirrorPosition = (ax.mirror && counterAx) ? getLinePosition(ax, counterAx, alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; - - // Figure out which subplot to draw ticks, labels, & axis lines on - // do this as a separate loop so we already have all the - // _mainAxis and _anchorAxis links set - ax._mainSubplot = findMainSubplot(ax, fullLayout); } // figure out which backgrounds we need to draw, @@ -45825,7 +46683,7 @@ function lsInner(gd) { layerClipId = null; } - Drawing.setClipUrl(plotinfo.plot, plotClipId); + Drawing.setClipUrl(plotinfo.plot, plotClipId, gd); // stash layer clipId value (null or same as clipId) // to DRY up Drawing.setClipUrl calls on trace-module and trace layers @@ -45955,48 +46813,6 @@ function lsInner(gd) { return gd._promises.length && Promise.all(gd._promises); } -function findMainSubplot(ax, fullLayout) { - var subplotList = fullLayout._subplots; - var ids = subplotList.cartesian.concat(subplotList.gl2d || []); - var mockGd = {_fullLayout: fullLayout}; - - var isX = ax._id.charAt(0) === 'x'; - var anchorAx = ax._mainAxis._anchorAxis; - var mainSubplotID = ''; - var nextBestMainSubplotID = ''; - var anchorID = ''; - - // First try the main ID with the anchor - if(anchorAx) { - anchorID = anchorAx._mainAxis._id; - mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); - } - - // Then look for a subplot with the counteraxis overlaying the anchor - // If that fails just use the first subplot including this axis - if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { - mainSubplotID = ''; - - for(var j = 0; j < ids.length; j++) { - var id = ids[j]; - var yIndex = id.indexOf('y'); - var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); - var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); - - if(idPart === ax._id) { - if(!nextBestMainSubplotID) nextBestMainSubplotID = id; - var counterAx = Axes.getFromId(mockGd, counterPart); - if(anchorID && counterAx.overlaying === anchorID) { - mainSubplotID = id; - break; - } - } - } - } - - return mainSubplotID || nextBestMainSubplotID; -} - function shouldShowLinesOrTicks(ax, subplot) { return (ax.ticks || ax.showline) && (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); @@ -46051,18 +46867,92 @@ function findCounterAxisLineWidth(ax, side, counterAx, axList) { exports.drawMainTitle = function(gd) { var fullLayout = gd._fullLayout; + var textAnchor = getMainTitleTextAnchor(fullLayout); + var dy = getMainTitleDy(fullLayout); + Titles.draw(gd, 'gtitle', { propContainer: fullLayout, - propName: 'title', + propName: 'title.text', placeholder: fullLayout._dfltTitle.plot, attributes: { - x: fullLayout.width / 2, - y: fullLayout._size.t / 2, - 'text-anchor': 'middle' + x: getMainTitleX(fullLayout, textAnchor), + y: getMainTitleY(fullLayout, dy), + 'text-anchor': textAnchor, + dy: dy } }); }; +function getMainTitleX(fullLayout, textAnchor) { + var title = fullLayout.title; + var gs = fullLayout._size; + var hPadShift = 0; + + if(textAnchor === SVG_TEXT_ANCHOR_START) { + hPadShift = title.pad.l; + } else if(textAnchor === SVG_TEXT_ANCHOR_END) { + hPadShift = -title.pad.r; + } + + switch(title.xref) { + case 'paper': + return gs.l + gs.w * title.x + hPadShift; + case 'container': + default: + return fullLayout.width * title.x + hPadShift; + } +} + +function getMainTitleY(fullLayout, dy) { + var title = fullLayout.title; + var gs = fullLayout._size; + var vPadShift = 0; + + if(dy === '0em' || !dy) { + vPadShift = -title.pad.b; + } else if(dy === alignmentConstants.CAP_SHIFT + 'em') { + vPadShift = title.pad.t; + } + + if(title.y === 'auto') { + return gs.t / 2; + } else { + switch(title.yref) { + case 'paper': + return gs.t + gs.h - gs.h * title.y + vPadShift; + case 'container': + default: + return fullLayout.height - fullLayout.height * title.y + vPadShift; + } + } +} + +function getMainTitleTextAnchor(fullLayout) { + var title = fullLayout.title; + + var textAnchor = SVG_TEXT_ANCHOR_MIDDLE; + if(Lib.isRightAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_END; + } else if(Lib.isLeftAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_START; + } + + return textAnchor; +} + +function getMainTitleDy(fullLayout) { + var title = fullLayout.title; + + var dy = '0em'; + if(Lib.isTopAnchor(title)) { + dy = alignmentConstants.CAP_SHIFT + 'em'; + } else if(Lib.isMiddleAnchor(title)) { + dy = alignmentConstants.MID_SHIFT + 'em'; + } + + return dy; +} + exports.doTraceStyle = function(gd) { var calcdata = gd.calcdata; var editStyleCalls = []; @@ -46140,7 +47030,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.doTicks(gd, 'redraw'); + Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -46275,6 +47165,8 @@ exports.doAutoRangeAndConstraints = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; cleanAxisConstraints(gd, ax); + // in case margins changed, update scale + ax.setScale(); doAutoRange(gd, ax); } @@ -46306,7 +47198,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('updatemenus', 'draw')(gd); }; -},{"../components/color":51,"../components/drawing":76,"../components/modebar":114,"../components/titles":142,"../constants/alignment":149,"../lib":170,"../lib/clear_gl_canvases":159,"../plots/cartesian/autorange":213,"../plots/cartesian/axes":214,"../plots/cartesian/constraints":222,"../plots/plots":247,"../registry":259,"d3":16}],206:[function(_dereq_,module,exports){ +},{"../components/color":51,"../components/drawing":72,"../components/modebar":110,"../components/titles":139,"../constants/alignment":146,"../lib":168,"../lib/clear_gl_canvases":157,"../plots/cartesian/autorange":211,"../plots/cartesian/axes":212,"../plots/cartesian/constraints":220,"../plots/plots":245,"../registry":257,"d3":16}],204:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46780,7 +47672,7 @@ function format(opts) { return opts; } -},{"../lib":170,"../plots/attributes":211,"../plots/plots":247,"./plot_config":202,"./plot_schema":203,"./plot_template":204}],207:[function(_dereq_,module,exports){ +},{"../lib":168,"../plots/attributes":209,"../plots/plots":245,"./plot_config":200,"./plot_schema":201,"./plot_template":202}],205:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46900,6 +47792,7 @@ function toImage(gd, opts) { // extend config for static plot var configImage = Lib.extendFlat({}, config, { + _exportedPlot: true, staticPlot: true, setBackground: setBackground }); @@ -46970,7 +47863,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":170,"../snapshot/helpers":263,"../snapshot/svgtoimg":265,"../snapshot/tosvg":267,"./plot_api":201}],208:[function(_dereq_,module,exports){ +},{"../lib":168,"../snapshot/helpers":261,"../snapshot/svgtoimg":263,"../snapshot/tosvg":265,"./plot_api":199}],206:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47416,7 +48309,7 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":170,"../plots/plots":247,"./plot_config":202,"./plot_schema":203}],209:[function(_dereq_,module,exports){ +},{"../lib":168,"../plots/plots":245,"./plot_config":200,"./plot_schema":201}],207:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47518,7 +48411,7 @@ module.exports = { } }; -},{}],210:[function(_dereq_,module,exports){ +},{}],208:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47614,7 +48507,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":170,"../plot_api/plot_template":204}],211:[function(_dereq_,module,exports){ +},{"../lib":168,"../plot_api/plot_template":202}],209:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47736,10 +48629,16 @@ module.exports = { _isLinkedToArray: 'transform', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + } }; -},{"../components/fx/attributes":85}],212:[function(_dereq_,module,exports){ +},{"../components/fx/attributes":81}],210:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47768,7 +48667,7 @@ module.exports = { } }; -},{}],213:[function(_dereq_,module,exports){ +},{}],211:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47783,6 +48682,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; +var Registry = _dereq_('../../registry'); module.exports = { getAutoRange: getAutoRange, @@ -48007,10 +48907,6 @@ function concatExtremes(gd, ax) { } function doAutoRange(gd, ax) { - if(!ax._length) ax.setScale(); - - var axIn; - if(ax.autorange) { ax.range = getAutoRange(gd, ax); @@ -48020,20 +48916,28 @@ function doAutoRange(gd, ax) { // doAutoRange will get called on fullLayout, // but we want to report its results back to layout - axIn = ax._input; + var axIn = ax._input; + + // before we edit _input, store preGUI values + var edits = {}; + edits[ax._attr + '.range'] = ax.range; + edits[ax._attr + '.autorange'] = ax.autorange; + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, edits); + axIn.range = ax.range.slice(); axIn.autorange = ax.autorange; } - if(ax._anchorAxis && ax._anchorAxis.rangeslider) { - var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name]; + var anchorAx = ax._anchorAxis; + + if(anchorAx && anchorAx.rangeslider) { + var axeRangeOpts = anchorAx.rangeslider[ax._name]; if(axeRangeOpts) { if(axeRangeOpts.rangemode === 'auto') { axeRangeOpts.range = getAutoRange(gd, ax); } } - axIn = ax._anchorAxis._input; - axIn.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); } } @@ -48251,7 +49155,7 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":152,"../../lib":170,"fast-isnumeric":18}],214:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168,"../../registry":257,"fast-isnumeric":18}],212:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48411,6 +49315,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t ax.d2c(targetArray[i]); } } + // TODO what to do for transforms? } else { ax = axes.getFromTrace(gd, trace, d2cTarget); } @@ -48451,7 +49356,7 @@ axes.counterLetter = function(id) { axes.minDtick = function(ax, newDiff, newFirst, allow) { // doesn't make sense to do forced min dTick on log or category axes, // and the plot itself may decide to cancel (ie non-grouped bars) - if(['log', 'category'].indexOf(ax.type) !== -1 || !allow) { + if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; } // undefined means there's nothing there yet @@ -48483,18 +49388,15 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // save a copy of the initial axis ranges in fullLayout // use them in mode bar and dblclick events axes.saveRangeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._rangeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.range[0] === ax._rangeInitial[0] && - ax.range[1] === ax._rangeInitial[1] - ) + var hasChanged = isNew || !( + ax.range[0] === ax._rangeInitial[0] && + ax.range[1] === ax._rangeInitial[1] ); if((isNew && ax.autorange === false) || (overwrite && hasChanged)) { @@ -48508,21 +49410,16 @@ axes.saveRangeInitial = function(gd, overwrite) { // save a copy of the initial spike visibility axes.saveShowSpikeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false, - allSpikesEnabled = 'on'; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; + var allSpikesEnabled = 'on'; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._showSpikeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.showspikes === ax._showspikes - ) - ); + var hasChanged = isNew || !(ax.showspikes === ax._showspikes); - if((isNew) || (overwrite && hasChanged)) { + if(isNew || (overwrite && hasChanged)) { ax._showSpikeInitial = ax.showspikes; hasOneAxisChanged = true; } @@ -48539,7 +49436,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { var dataMin = Lib.aggNums(Math.min, null, data); var dataMax = Lib.aggNums(Math.max, null, data); - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { return { start: dataMin - 0.5, end: dataMax + 0.5, @@ -48557,8 +49454,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { type: 'linear', range: [dataMin, dataMax] }; - } - else { + } else { dummyAx = { type: ax.type, range: Lib.simpleMap([dataMin, dataMax], ax.c2r, 0, calendar), @@ -48643,10 +49539,10 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { - var edgecount = 0, - midcount = 0, - intcount = 0, - blankCount = 0; + var edgecount = 0; + var midcount = 0; + var intcount = 0; + var blankCount = 0; function nearEdge(v) { // is a value within 1% of a bin edge? @@ -48737,14 +49633,14 @@ axes.prepTicks = function(ax) { // calculate max number of (auto) ticks to display based on plot size if(ax.tickmode === 'auto' || !ax.dtick) { - var nt = ax.nticks, - minPx; + var nt = ax.nticks; + var minPx; + if(!nt) { - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; nt = ax._length / minPx; - } - else { + } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; nt = Lib.constrain(ax._length / minPx, 4, 9) + 1; } @@ -48806,7 +49702,7 @@ axes.calcTicks = function calcTicks(ax) { // return the full set of tick vals var vals = []; - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { endTick = (axrev) ? Math.max(-0.5, endTick) : Math.min(ax._categories.length - 0.5, endTick); } @@ -48850,23 +49746,22 @@ axes.calcTicks = function calcTicks(ax) { }; function arrayTicks(ax) { - var vals = ax.tickvals, - text = ax.ticktext, - ticksOut = new Array(vals.length), - rng = Lib.simpleMap(ax.range, ax.r2l), - r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001, - r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001, - tickMin = Math.min(r0expanded, r1expanded), - tickMax = Math.max(r0expanded, r1expanded), - vali, - i, - j = 0; + var vals = ax.tickvals; + var text = ax.ticktext; + var ticksOut = new Array(vals.length); + var rng = Lib.simpleMap(ax.range, ax.r2l); + var r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001; + var r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001; + var tickMin = Math.min(r0expanded, r1expanded); + var tickMax = Math.max(r0expanded, r1expanded); + var j = 0; // without a text array, just format the given values as any other ticks // except with more precision to the numbers if(!Array.isArray(text)) text = []; // make sure showing ticks doesn't accidentally add new categories + // TODO multicategory, if we allow ticktext / tickvals var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; // array ticks on log axes always show the full number @@ -48875,8 +49770,8 @@ function arrayTicks(ax) { ax.dtick = 'L' + Math.pow(10, Math.floor(Math.min(ax.range[0], ax.range[1])) - 1); } - for(i = 0; i < vals.length; i++) { - vali = tickVal2l(vals[i]); + for(var i = 0; i < vals.length; i++) { + var vali = tickVal2l(vals[i]); if(vali > tickMin && vali < tickMax) { if(text[i] === undefined) ticksOut[j] = axes.tickText(ax, vali); else ticksOut[j] = tickTextObj(ax, vali, String(text[i])); @@ -48889,17 +49784,17 @@ function arrayTicks(ax) { return ticksOut; } -var roundBase10 = [2, 5, 10], - roundBase24 = [1, 2, 3, 6, 12], - roundBase60 = [1, 2, 5, 10, 15, 30], - // 2&3 day ticks are weird, but need something btwn 1&7 - roundDays = [1, 2, 3, 7, 14], - // approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) - // these don't have to be exact, just close enough to round to the right value - roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1], - roundLog2 = [-0.301, 0, 0.301, 0.699, 1], - // N.B. `thetaunit; 'radians' angular axes must be converted to degrees - roundAngles = [15, 30, 45, 90, 180]; +var roundBase10 = [2, 5, 10]; +var roundBase24 = [1, 2, 3, 6, 12]; +var roundBase60 = [1, 2, 5, 10, 15, 30]; +// 2&3 day ticks are weird, but need something btwn 1&7 +var roundDays = [1, 2, 3, 7, 14]; +// approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) +// these don't have to be exact, just close enough to round to the right value +var roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1]; +var roundLog2 = [-0.301, 0, 0.301, 0.699, 1]; +// N.B. `thetaunit; 'radians' angular axes must be converted to degrees +var roundAngles = [15, 30, 45, 90, 180]; function roundDTick(roughDTick, base, roundingSet) { return base * Lib.roundUp(roughDTick / base, roundingSet); @@ -48990,7 +49885,7 @@ axes.autoTicks = function(ax, roughDTick) { ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } } - else if(ax.type === 'category') { + else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); } @@ -49030,7 +49925,7 @@ function autoTickRound(ax) { dtick = 1; } - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { ax._tickround = null; } if(ax.type === 'date') { @@ -49122,36 +50017,34 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { // calculate the first tick on an axis axes.tickFirst = function(ax) { - var r2l = ax.r2l || Number, - rng = Lib.simpleMap(ax.range, r2l), - axrev = rng[1] < rng[0], - sRound = axrev ? Math.floor : Math.ceil, - // add a tiny extra bit to make sure we get ticks - // that may have been rounded out - r0 = rng[0] * 1.0001 - rng[1] * 0.0001, - dtick = ax.dtick, - tick0 = r2l(ax.tick0); + var r2l = ax.r2l || Number; + var rng = Lib.simpleMap(ax.range, r2l); + var axrev = rng[1] < rng[0]; + var sRound = axrev ? Math.floor : Math.ceil; + // add a tiny extra bit to make sure we get ticks + // that may have been rounded out + var r0 = rng[0] * 1.0001 - rng[1] * 0.0001; + var dtick = ax.dtick; + var tick0 = r2l(ax.tick0); if(isNumeric(dtick)) { var tmin = sRound((r0 - tick0) / dtick) * dtick + tick0; // make sure no ticks outside the category list - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { tmin = Lib.constrain(tmin, 0, ax._categories.length - 1); } return tmin; } - var tType = dtick.charAt(0), - dtNum = Number(dtick.substr(1)); + var tType = dtick.charAt(0); + var dtNum = Number(dtick.substr(1)); // Dates: months (or years) if(tType === 'M') { - var cnt = 0, - t0 = tick0, - t1, - mult, - newDTick; + var cnt = 0; + var t0 = tick0; + var t1, mult, newDTick; // This algorithm should work for *any* nonlinear (but close to linear!) // tick spacing. Limit to 10 iterations, for gregorian months it's normally <=3. @@ -49193,16 +50086,18 @@ axes.tickFirst = function(ax) { // hover is a (truthy) flag for whether to show numbers with a bit // more precision for hovertext axes.tickText = function(ax, x, hover) { - var out = tickTextObj(ax, x), - hideexp, - arrayMode = ax.tickmode === 'array', - extraPrecision = hover || arrayMode, - i, - tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; + var out = tickTextObj(ax, x); + var arrayMode = ax.tickmode === 'array'; + var extraPrecision = hover || arrayMode; + var axType = ax.type; + // TODO multicategory, if we allow ticktext / tickvals + var tickVal2l = axType === 'category' ? ax.d2l_noadd : ax.d2l; + var i; if(arrayMode && Array.isArray(ax.ticktext)) { - var rng = Lib.simpleMap(ax.range, ax.r2l), - minDiff = Math.abs(rng[1] - rng[0]) / 10000; + var rng = Lib.simpleMap(ax.range, ax.r2l); + var minDiff = Math.abs(rng[1] - rng[0]) / 10000; + for(i = 0; i < ax.ticktext.length; i++) { if(Math.abs(x - tickVal2l(ax.tickvals[i])) < minDiff) break; } @@ -49213,28 +50108,25 @@ axes.tickText = function(ax, x, hover) { } function isHidden(showAttr) { - var first_or_last; - if(showAttr === undefined) return true; if(hover) return showAttr === 'none'; - first_or_last = { + var firstOrLast = { first: ax._tmin, last: ax._tmax }[showAttr]; - return showAttr !== 'all' && x !== first_or_last; + return showAttr !== 'all' && x !== firstOrLast; } - if(hover) { - hideexp = 'never'; - } else { - hideexp = ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - } + var hideexp = hover ? + 'never' : + ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - if(ax.type === 'date') formatDate(ax, out, hover, extraPrecision); - else if(ax.type === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); - else if(ax.type === 'category') formatCategory(ax, out); + if(axType === 'date') formatDate(ax, out, hover, extraPrecision); + else if(axType === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); + else if(axType === 'category') formatCategory(ax, out); + else if(axType === 'multicategory') formatMultiCategory(ax, out, hover); else if(isAngular(ax)) formatAngle(ax, out, hover, extraPrecision, hideexp); else formatLinear(ax, out, hover, extraPrecision, hideexp); @@ -49242,6 +50134,20 @@ axes.tickText = function(ax, x, hover) { if(ax.tickprefix && !isHidden(ax.showtickprefix)) out.text = ax.tickprefix + out.text; if(ax.ticksuffix && !isHidden(ax.showticksuffix)) out.text += ax.ticksuffix; + // Setup ticks and grid lines boundaries + // at 1/2 a 'category' to the left/bottom + if(ax.tickson === 'boundaries' || ax.showdividers) { + var inbounds = function(v) { + var p = ax.l2p(v); + return p >= 0 && p <= ax._length ? v : null; + }; + + out.xbnd = [ + inbounds(out.x - 0.5), + inbounds(out.x + ax.dtick - 0.5) + ]; + } + return out; }; @@ -49291,8 +50197,8 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround, - fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); + var tr = ax._tickround; + var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); if(extraPrecision) { // second or sub-second precision: extra always shows max digits. @@ -49301,8 +50207,8 @@ function formatDate(ax, out, hover, extraPrecision) { else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr]; } - var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat), - headStr; + var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat); + var headStr; var splitIndex = dateStr.indexOf('\n'); if(splitIndex !== -1) { @@ -49419,6 +50325,22 @@ function formatCategory(ax, out) { out.text = String(tt); } +function formatMultiCategory(ax, out, hover) { + var v = Math.round(out.x); + var cats = ax._categories[v] || []; + var tt = cats[1] === undefined ? '' : String(cats[1]); + var tt2 = cats[0] === undefined ? '' : String(cats[0]); + + if(hover) { + // TODO is this what we want? + out.text = tt2 + ' - ' + tt; + } else { + // setup for secondary labels + out.text = tt; + out.text2 = tt2; + } +} + function formatLinear(ax, out, hover, extraPrecision, hideexp) { if(hideexp === 'never') { // If this is a hover label, then we must *never* hide the exponent @@ -49524,14 +50446,13 @@ function beyondSI(exponent) { } function numFormat(v, ax, fmtoverride, hover) { - // negative? - var isNeg = v < 0, - // max number of digits past decimal point to show - tickRound = ax._tickround, - exponentFormat = fmtoverride || ax.exponentformat || 'B', - exponent = ax._tickexponent, - tickformat = axes.getTickFormat(ax), - separatethousands = ax.separatethousands; + var isNeg = v < 0; + // max number of digits past decimal point to show + var tickRound = ax._tickround; + var exponentFormat = fmtoverride || ax.exponentformat || 'B'; + var exponent = ax._tickexponent; + var tickformat = axes.getTickFormat(ax); + var separatethousands = ax.separatethousands; // special case for hover: set exponent just for this value, and // add a couple more digits of precision over tick labels @@ -49704,6 +50625,9 @@ axes.getTickFormat = function(ax) { // as an array of items like 'xy', 'x2y', 'x2y2'... // sorted by x (x,x2,x3...) then y // optionally restrict to only subplots containing axis object ax +// +// NOTE: this is currently only used OUTSIDE plotly.js (toolpanel, webapp) +// ideally we get rid of it there (or just copy this there) and remove it here axes.getSubplots = function(gd, ax) { var subplotObj = gd._fullLayout._subplots; var allSubplots = subplotObj.cartesian.concat(subplotObj.gl2d || []); @@ -49722,18 +50646,20 @@ axes.getSubplots = function(gd, ax) { }; // find all subplots with axis 'ax' +// NOTE: this is only used in axes.getSubplots (only used outside plotly.js) and +// gl2d/convert (where it restricts axis subplots to only those with gl2d) axes.findSubplotsWithAxis = function(subplots, ax) { var axMatch = new RegExp( (ax._id.charAt(0) === 'x') ? ('^' + ax._id + 'y') : (ax._id + '$') ); - var subplotsWithAxis = []; + var subplotsWithAx = []; for(var i = 0; i < subplots.length; i++) { var sp = subplots[i]; - if(axMatch.test(sp)) subplotsWithAxis.push(sp); + if(axMatch.test(sp)) subplotsWithAx.push(sp); } - return subplotsWithAxis; + return subplotsWithAx; }; // makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings @@ -49786,24 +50712,25 @@ axes.makeClipPaths = function(gd) { * * @param {DOM element} gd : graph div * @param {string or array of strings} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update + * @param {object} opts: + * - @param {boolean} skipTitle : optional flag to skip axis title draw/update * - * Signature 1: Axes.doTicks(gd, 'redraw') + * Signature 1: Axes.draw(gd, 'redraw') * use this to clear and redraw all axes on graph * - * Signature 2: Axes.doTicks(gd, '') + * Signature 2: Axes.draw(gd, '') * use this to draw all axes on graph w/o the selectAll().remove() * of the 'redraw' signature * - * Signature 3: Axes.doTicks(gd, [axId, axId2, ...]) + * Signature 3: Axes.draw(gd, [axId, axId2, ...]) * where the items are axis id string, * use this to update multiple axes in one call * - * N.B doTicks updates: + * N.B draw updates: * - ax._r (stored range for use by zoom/pan) * - ax._rl (stored linearized range for use by zoom/pan) */ -axes.doTicks = function(gd, arg, skipTitle) { +axes.draw = function(gd, arg, opts) { var fullLayout = gd._fullLayout; if(arg === 'redraw') { @@ -49815,6 +50742,8 @@ axes.doTicks = function(gd, arg, skipTitle) { plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove(); if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); @@ -49824,13 +50753,13 @@ axes.doTicks = function(gd, arg, skipTitle) { var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; - Lib.syncOrAsync(axList.map(function(axid) { + return Lib.syncOrAsync(axList.map(function(axId) { return function() { - if(!axid) return; + if(!axId) return; - var axDone = axes.doTicksSingle(gd, axid, skipTitle); + var ax = axes.getFromId(gd, axId); + var axDone = axes.drawOne(gd, ax, opts); - var ax = axes.getFromId(gd, axid); ax._r = ax.range.slice(); ax._rl = Lib.simpleMap(ax._r, ax.r2l); @@ -49840,692 +50769,1077 @@ axes.doTicks = function(gd, arg, skipTitle) { }; /** - * Per-axis drawing routine! + * Draw one cartesian axis * - * This routine draws axis ticks and much more (... grids, labels, title etc.) - * Supports multiple argument signatures. - * N.B. this thing is async in general (because of MathJax rendering) - * - * @param {DOM element} gd : graph div - * @param {string or object} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * @return {promise} - * - * Signature 1: Axes.doTicks(gd, ax) - * where ax is an axis object as in fullLayout - * - * Signature 2: Axes.doTicks(gd, axId) - * where axId is a axis id string + * @param {DOM element} gd + * @param {object} ax (full) axis object + * @param {object} opts + * - @param {boolean} skipTitle (set to true to skip axis title draw call) */ -axes.doTicksSingle = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; - var independent = false; - var ax; +axes.drawOne = function(gd, ax, opts) { + opts = opts || {}; - if(Lib.isPlainObject(arg)) { - ax = arg; - independent = true; - } else { - ax = axes.getFromId(gd, arg); - } + var i, sp, plotinfo; - // set scaling to pixels ax.setScale(); - var axid = ax._id; - var axLetter = axid.charAt(0); - var counterLetter = axes.counterLetter(axid); + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var counterLetter = axes.counterLetter(axId); + var mainSubplot = ax._mainSubplot; + var mainLinePosition = ax._mainLinePosition; + var mainMirrorPosition = ax._mainMirrorPosition; + var mainPlotinfo = fullLayout._plots[mainSubplot]; + var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; + var subplotsWithAx = ax._subplotsWith; + var vals = ax._vals = axes.calcTicks(ax); - var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; - var tcls = axid + 'tick'; - var gcls = axid + 'grid'; - var zcls = axid + 'zl'; - var pad = (ax.linewidth || 1) / 2; - var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); - var labelShift = 0; - var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); - var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); - var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); - var sides, transfn, tickpathfn, subplots; - var tickLabels; - var i; - if(ax._counterangle && ax.ticks === 'outside') { - var caRad = ax._counterangle * Math.PI / 180; - labelStandoff = ax.ticklen * Math.cos(caRad) + 1; - labelShift = ax.ticklen * Math.sin(caRad); + // Add a couple of axis properties that should cause us to recreate + // elements. Used in d3 data function. + var axInfo = [ax.mirror, mainLinePosition, mainMirrorPosition].join('_'); + for(i = 0; i < vals.length; i++) { + vals[i].axInfo = axInfo; } - if(ax.showticklabels && (ax.ticks === 'outside' || ax.showline)) { - labelStandoff += 0.2 * ax.tickfont.size; - } + if(!ax.visible) return; - // positioning arguments for x vs y axes - if(axLetter === 'x') { - sides = ['bottom', 'top']; - transfn = ax._transfn || function(d) { - return 'translate(' + (ax._offset + ax.l2p(d.x)) + ',0)'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M0,' + shift + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len); - } - else return 'M0,' + shift + 'v' + len; - }; - } - else if(axLetter === 'y') { - sides = ['left', 'right']; - transfn = ax._transfn || function(d) { - return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M' + shift + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); - } - else return 'M' + shift + ',0h' + len; - }; - } - else if(isAngular(ax)) { - sides = ['left', 'right']; - transfn = ax._transfn; - tickpathfn = function(shift, len) { - return 'M' + shift + ',0h' + len; - }; - } - else { - Lib.warn('Unrecognized doTicks axis:', axid); - return; + // stash selections to avoid DOM queries e.g. + // - stash tickLabels selection, so that drawTitle can use it to scoot title + ax._selections = {}; + // stash tick angle (including the computed 'auto' values) per tick-label class + ax._tickAngles = {}; + + var transFn = axes.makeTransFn(ax); + var tickVals; + // We remove zero lines, grid lines, and inside ticks if they're within 1px of the end + // The key case here is removing zero lines when the axis bound is zero + var valsClipped; + + if(ax.tickson === 'boundaries') { + var boundaryVals = getBoundaryVals(ax, vals); + valsClipped = axes.clipEnds(ax, boundaryVals); + tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals; + } else { + valsClipped = axes.clipEnds(ax, vals); + tickVals = ax.ticks === 'inside' ? valsClipped : vals; } - var axside = ax.side || sides[0]; - // which direction do the side[0], side[1], and free ticks go? - // then we flip if outside XOR y axis - var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; - if((ax.ticks !== 'inside') === (axLetter === 'x')) { - ticksign = ticksign.map(function(v) { return -v; }); - } + var gridVals = ax._gridVals = valsClipped; + var dividerVals = getDividerVals(ax, vals); - if(!ax.visible) return; + if(!fullLayout._hasOnlyLargeSploms) { + // keep track of which subplots (by main conteraxis) we've already + // drawn grids for, so we don't overdraw overlaying subplots + var finishedGrids = {}; - if(ax._tickFilter) { - vals = vals.filter(ax._tickFilter); - } + for(i = 0; i < subplotsWithAx.length; i++) { + sp = subplotsWithAx[i]; + plotinfo = fullLayout._plots[sp]; - // Remove zero lines, grid lines, and inside ticks if they're within - // 1 pixel of the end. - // The key case here is removing zero lines when the axis bound is zero. - // Don't clip angular values. - var valsClipped = ax._valsClipped = isAngular(ax) ? - vals : - vals.filter(function(d) { return clipEnds(ax, d.x); }); + var counterAxis = plotinfo[counterLetter + 'axis']; + var mainCounterID = counterAxis._mainAxis._id; + if(finishedGrids[mainCounterID]) continue; + finishedGrids[mainCounterID] = 1; - function drawTicks(container, tickpath) { - var ticks = container.selectAll('path.' + tcls) - .data(ax.ticks === 'inside' ? valsClipped : vals, datafn); + var gridPath = axLetter === 'x' ? + 'M0,' + counterAxis._offset + 'v' + counterAxis._length : + 'M' + counterAxis._offset + ',0h' + counterAxis._length; - if(tickpath && ax.ticks) { - ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) - .classed('crisp', 1) - .call(Color.stroke, ax.tickcolor) - .style('stroke-width', tickWidth + 'px') - .attr('d', tickpath); - ticks.attr('transform', transfn); - ticks.exit().remove(); + axes.drawGrid(gd, ax, { + vals: gridVals, + counterAxis: counterAxis, + layer: plotinfo.gridlayer.select('.' + axId), + path: gridPath, + transFn: transFn + }); + axes.drawZeroLine(gd, ax, { + counterAxis: counterAxis, + layer: plotinfo.zerolinelayer, + path: gridPath, + transFn: transFn + }); } - else ticks.remove(); } - function drawLabels(container, position) { - // tick labels - for now just the main labels. - // TODO: mirror labels, esp for subplots - tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); + var tickSigns = axes.getTickSigns(ax); + var tickSubplots = []; - if(!isNumeric(position)) { - tickLabels.remove(); - drawAxTitle(); - return; - } - if(!ax.showticklabels) { - tickLabels.remove(); - drawAxTitle(); - calcBoundingBox(); - return; + if(ax.ticks) { + var mainTickPath = axes.makeTickPath(ax, mainLinePosition, tickSigns[2]); + var mirrorTickPath; + var fullTickPath; + if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { + mirrorTickPath = axes.makeTickPath(ax, mainMirrorPosition, tickSigns[3]); + fullTickPath = mainTickPath + mirrorTickPath; + } else { + mirrorTickPath = ''; + fullTickPath = mainTickPath; } - var labelx, labely, labelanchor, labelpos0, flipit; - if(axLetter === 'x') { - flipit = (axside === 'bottom') ? 1 : -1; - labelx = function(d) { return d.dx + labelShift * flipit; }; - labelpos0 = position + (labelStandoff + pad) * flipit; - labely = function(d) { - return d.dy + labelpos0 + d.fontSize * - ((axside === 'bottom') ? 1 : -0.2); - }; - labelanchor = function(angle) { - if(!isNumeric(angle) || angle === 0 || angle === 180) { - return 'middle'; - } - return (angle * flipit < 0) ? 'end' : 'start'; - }; - } - else if(axLetter === 'y') { - flipit = (axside === 'right') ? 1 : -1; - labely = function(d) { - return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit; - }; - labelx = function(d) { - return d.dx + position + (labelStandoff + pad + - ((Math.abs(ax.tickangle) === 90) ? d.fontSize / 2 : 0)) * flipit; - }; - labelanchor = function(angle) { - if(isNumeric(angle) && Math.abs(angle) === 90) { - return 'middle'; - } - return axside === 'right' ? 'start' : 'end'; + var tickPath; + if(ax.showdividers && ax.ticks === 'outside' && ax.tickson === 'boundaries') { + var dividerLookup = {}; + for(i = 0; i < dividerVals.length; i++) { + dividerLookup[dividerVals[i].x] = 1; + } + tickPath = function(d) { + return dividerLookup[d.x] ? mirrorTickPath : fullTickPath; }; + } else { + tickPath = fullTickPath; } - else if(isAngular(ax)) { - ax._labelShift = labelShift; - ax._labelStandoff = labelStandoff; - ax._pad = pad; - - labelx = ax._labelx; - labely = ax._labely; - labelanchor = ax._labelanchor; - } - - var maxFontSize = 0, - autoangle = 0, - labelsReady = []; - tickLabels.enter().append('g').classed(tcls, 1) - .append('text') - // only so tex has predictable alignment that we can - // alter later - .attr('text-anchor', 'middle') - .each(function(d) { - var thisLabel = d3.select(this), - newPromise = gd._promises.length; - thisLabel - .call(svgTextUtils.positionText, labelx(d), labely(d)) - .call(Drawing.font, d.font, d.fontSize, d.fontColor) - .text(d.text) - .call(svgTextUtils.convertToTspans, gd); - newPromise = gd._promises[newPromise]; - if(newPromise) { - // if we have an async label, we'll deal with that - // all here so take it out of gd._promises and - // instead position the label and promise this in - // labelsReady - labelsReady.push(gd._promises.pop().then(function() { - positionLabels(thisLabel, ax.tickangle); - })); - } - else { - // sync label: just position it now. - positionLabels(thisLabel, ax.tickangle); - } - }); - tickLabels.exit().remove(); - tickLabels.each(function(d) { - maxFontSize = Math.max(maxFontSize, d.fontSize); + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: mainAxLayer, + path: tickPath, + transFn: transFn }); - if(isAngular(ax)) { - tickLabels.each(function(d) { - d3.select(this).select('text') - .call(svgTextUtils.positionText, labelx(d), labely(d)); + tickSubplots = Object.keys(ax._linepositions || {}); + } + + for(i = 0; i < tickSubplots.length; i++) { + sp = tickSubplots[i]; + plotinfo = fullLayout._plots[sp]; + // [bottom or left, top or right], free and main are handled above + var linepositions = ax._linepositions[sp] || []; + var spTickPath = axes.makeTickPath(ax, linepositions[0], tickSigns[0]) + + axes.makeTickPath(ax, linepositions[1], tickSigns[1]); + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: plotinfo[axLetter + 'axislayer'], + path: spTickPath, + transFn: transFn + }); + } + + var seq = []; + + // tick labels - for now just the main labels. + // TODO: mirror labels, esp for subplots + + seq.push(function() { + var labelFns = axes.makeLabelFns(ax, mainLinePosition); + return axes.drawLabels(gd, ax, { + vals: vals, + layer: mainAxLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn, + }); + }); + + if(ax.type === 'multicategory') { + var labelLength = 0; + var pad = {x: 2, y: 10}[axLetter]; + var sgn = tickSigns[2] * (ax.ticks === 'inside' ? -1 : 1); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick') + pad; + labelLength += ax._tickAngles[axId + 'tick'] ? ax.tickfont.size * LINE_SPACING : 0; + var secondaryPosition = mainLinePosition + labelLength * sgn; + var secondaryLabelFns = axes.makeLabelFns(ax, secondaryPosition); + + return axes.drawLabels(gd, ax, { + vals: getSecondaryLabelVals(ax, vals), + layer: mainAxLayer, + cls: axId + 'tick2', + repositionOnUpdate: true, + secondary: true, + transFn: transFn, + labelXFn: secondaryLabelFns.labelXFn, + labelYFn: secondaryLabelFns.labelYFn, + labelAnchorFn: secondaryLabelFns.labelAnchorFn, }); - } + }); - // How much to shift a multi-line label to center it vertically. - function getAnchorHeight(lineCount, lineHeight, angle) { - var h = (lineCount - 1) * lineHeight; - if(axLetter === 'x') { - if(angle < -60 || 60 < angle) { - return -0.5 * h; - } else if(axside === 'top') { - return -h; - } - } else { - angle *= axside === 'left' ? 1 : -1; - if(angle < -30) { - return -h; - } else if(angle < 30) { - return -0.5 * h; - } - } - return 0; - } - - function positionLabels(s, angle) { - s.each(function(d) { - var anchor = labelanchor(angle, d); - var thisLabel = d3.select(this), - mathjaxGroup = thisLabel.select('.text-math-group'), - transform = transfn.call(thisLabel.node(), d) + - ((isNumeric(angle) && +angle !== 0) ? - (' rotate(' + angle + ',' + labelx(d) + ',' + - (labely(d) - d.fontSize / 2) + ')') : - ''); - var anchorHeight = getAnchorHeight( - svgTextUtils.lineCount(thisLabel), - LINE_SPACING * d.fontSize, - isNumeric(angle) ? +angle : 0); - if(anchorHeight) { - transform += ' translate(0, ' + anchorHeight + ')'; - } - if(mathjaxGroup.empty()) { - thisLabel.select('text').attr({ - transform: transform, - 'text-anchor': anchor - }); - } - else { - var mjShift = - Drawing.bBox(mathjaxGroup.node()).width * - {end: -0.5, start: 0.5}[anchor]; - mathjaxGroup.attr('transform', transform + - (mjShift ? 'translate(' + mjShift + ',0)' : '')); - } + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick2'); + ax._labelLength = labelLength; + + return drawDividers(gd, ax, { + vals: dividerVals, + layer: mainAxLayer, + path: axes.makeTickPath(ax, mainLinePosition, sgn, labelLength), + transFn: transFn }); - } + }); + } - // make sure all labels are correctly positioned at their base angle - // the positionLabels call above is only for newly drawn labels. - // do this without waiting, using the last calculated angle to - // minimize flicker, then do it again when we know all labels are - // there, putting back the prescribed angle to check for overlaps. - positionLabels(tickLabels, ax._lastangle || ax.tickangle); - - function allLabelsReady() { - return labelsReady.length && Promise.all(labelsReady); - } - - function fixLabelOverlaps() { - positionLabels(tickLabels, ax.tickangle); - - // check for auto-angling if x labels overlap - // don't auto-angle at all for log axes with - // base and digit format - if(axLetter === 'x' && !isNumeric(ax.tickangle) && - (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')) { - var lbbArray = []; - tickLabels.each(function(d) { - var s = d3.select(this), - thisLabel = s.select('.text-math-group'), - x = ax.l2p(d.x); - if(thisLabel.empty()) thisLabel = s.select('text'); - - var bb = Drawing.bBox(thisLabel.node()); - - lbbArray.push({ - // ignore about y, just deal with x overlaps - top: 0, - bottom: 10, - height: 10, - left: x - bb.width / 2, - // impose a 2px gap - right: x + bb.width / 2 + 2, - width: bb.width + 2 - }); - }); - for(i = 0; i < lbbArray.length - 1; i++) { - if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { - // any overlap at all - set 30 degrees - autoangle = 30; - break; - } - } - if(autoangle) { - var tickspacing = Math.abs( - (vals[vals.length - 1].x - vals[0].x) * ax._m - ) / (vals.length - 1); - if(tickspacing < maxFontSize * 2.5) { - autoangle = 90; - } - positionLabels(tickLabels, autoangle); - } - ax._lastangle = autoangle; - } + function extendRange(range, newRange) { + range[0] = Math.min(range[0], newRange[0]); + range[1] = Math.max(range[1], newRange[1]); + } - // update the axis title - // (so it can move out of the way if needed) - // TODO: separate out scoot so we don't need to do - // a full redraw of the title (mostly relevant for MathJax) - drawAxTitle(); - return axid + ' done'; - } + function calcBoundingBox() { + if(ax.showticklabels) { + var gdBB = gd.getBoundingClientRect(); + var bBox = mainAxLayer.node().getBoundingClientRect(); - function calcBoundingBox() { - if(ax.showticklabels) { - var gdBB = gd.getBoundingClientRect(); - var bBox = container.node().getBoundingClientRect(); + /* + * the way we're going to use this, the positioning that matters + * is relative to the origin of gd. This is important particularly + * if gd is scrollable, and may have been scrolled between the time + * we calculate this and the time we use it + */ - /* - * the way we're going to use this, the positioning that matters - * is relative to the origin of gd. This is important particularly - * if gd is scrollable, and may have been scrolled between the time - * we calculate this and the time we use it - */ + ax._boundingBox = { + width: bBox.width, + height: bBox.height, + left: bBox.left - gdBB.left, + right: bBox.right - gdBB.left, + top: bBox.top - gdBB.top, + bottom: bBox.bottom - gdBB.top + }; + } else { + var gs = fullLayout._size; + var pos; + + // set dummy bbox for ticklabel-less axes + + if(axLetter === 'x') { + pos = ax.anchor === 'free' ? + gs.t + gs.h * (1 - ax.position) : + gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); ax._boundingBox = { - width: bBox.width, - height: bBox.height, - left: bBox.left - gdBB.left, - right: bBox.right - gdBB.left, - top: bBox.top - gdBB.top, - bottom: bBox.bottom - gdBB.top + top: pos, + bottom: pos, + left: ax._offset, + right: ax._offset + ax._length, + width: ax._length, + height: 0 }; } else { - var gs = fullLayout._size; - var pos; + pos = ax.anchor === 'free' ? + gs.l + gs.w * ax.position : + gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - // set dummy bbox for ticklabel-less axes - - if(axLetter === 'x') { - pos = ax.anchor === 'free' ? - gs.t + gs.h * (1 - ax.position) : - gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); - - ax._boundingBox = { - top: pos, - bottom: pos, - left: ax._offset, - right: ax._offset + ax._length, - width: ax._length, - height: 0 - }; - } else { - pos = ax.anchor === 'free' ? - gs.l + gs.w * ax.position : - gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - - ax._boundingBox = { - left: pos, - right: pos, - bottom: ax._offset + ax._length, - top: ax._offset, - height: ax._length, - width: 0 - }; - } + ax._boundingBox = { + left: pos, + right: pos, + bottom: ax._offset + ax._length, + top: ax._offset, + height: ax._length, + width: 0 + }; } + } - /* - * for spikelines: what's the full domain of positions in the - * opposite direction that are associated with this axis? - * This means any axes that we make a subplot with, plus the - * position of the axis itself if it's free. - */ - if(subplots) { - var fullRange = ax._counterSpan = [Infinity, -Infinity]; - - for(i = 0; i < subplots.length; i++) { - var subplot = fullLayout._plots[subplots[i]]; - var counterAxis = subplot[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + /* + * for spikelines: what's the full domain of positions in the + * opposite direction that are associated with this axis? + * This means any axes that we make a subplot with, plus the + * position of the axis itself if it's free. + */ + if(subplotsWithAx) { + var fullRange = ax._counterSpan = [Infinity, -Infinity]; - extendRange(fullRange, [ - counterAxis._offset, - counterAxis._offset + counterAxis._length - ]); - } + for(var i = 0; i < subplotsWithAx.length; i++) { + var plotinfo = fullLayout._plots[subplotsWithAx[i]]; + var counterAxis = plotinfo[(axLetter === 'x') ? 'yaxis' : 'xaxis']; - if(ax.anchor === 'free') { - extendRange(fullRange, (axLetter === 'x') ? - [ax._boundingBox.bottom, ax._boundingBox.top] : - [ax._boundingBox.right, ax._boundingBox.left]); - } + extendRange(fullRange, [ + counterAxis._offset, + counterAxis._offset + counterAxis._length + ]); } - function extendRange(range, newRange) { - range[0] = Math.min(range[0], newRange[0]); - range[1] = Math.max(range[1], newRange[1]); + if(ax.anchor === 'free') { + extendRange(fullRange, (axLetter === 'x') ? + [ax._boundingBox.bottom, ax._boundingBox.top] : + [ax._boundingBox.right, ax._boundingBox.left]); } } + } - function doAutoMargins() { - var pushKey = ax._name + '.automargin'; - if(axLetter !== 'x' && axLetter !== 'y') { return; } - if(!ax.automargin) { - Plots.autoMargin(gd, pushKey); - return; - } + var hasRangeSlider = Registry.getComponentMethod('rangeslider', 'isVisible')(ax); - var s = ax.side[0]; - var push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + function doAutoMargins() { + var push, rangeSliderPush; + + if(hasRangeSlider) { + rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); + } + Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); + + var s = ax.side.charAt(0); + if(ax.automargin && (!hasRangeSlider || s !== 'b')) { + push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; if(axLetter === 'x') { push.y = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 't' ? 1 : 0]); + ax._anchorAxis.domain[s === 't' ? 1 : 0]); push[s] += ax._boundingBox.height; - } - else { + } else { push.x = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 'r' ? 1 : 0]); + ax._anchorAxis.domain[s === 'r' ? 1 : 0]); push[s] += ax._boundingBox.width; } - if(ax.title !== fullLayout._dfltTitle[axLetter]) { - push[s] += ax.titlefont.size; + if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { + push[s] += ax.title.font.size; } - - Plots.autoMargin(gd, pushKey, push); } - var done = Lib.syncOrAsync([ - allLabelsReady, - fixLabelOverlaps, - calcBoundingBox, - doAutoMargins - ]); - if(done && done.then) gd._promises.push(done); - return done; + Plots.autoMargin(gd, axAutoMarginID(ax), push); } - function drawAxTitle() { - if(skipTitle) return; + seq.push(calcBoundingBox, doAutoMargins); - // now this only applies to regular cartesian axes; colorbars and - // others ALWAYS call doTicks with skipTitle=true so they can - // configure their own titles. + if(!opts.skipTitle && + !(hasRangeSlider && ax._boundingBox && ax.side === 'bottom') + ) { + seq.push(function() { return drawTitle(gd, ax); }); + } - // rangeslider takes over a bottom title so drop it here - if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; + return Lib.syncOrAsync(seq); +}; - var avoid = { - selection: tickLabels, - side: ax.side - }; - var axLetter = axid.charAt(0); - var gs = gd._fullLayout._size; - var offsetBase = 1.5; - var fontSize = ax.titlefont.size; +function getBoundaryVals(ax, vals) { + var out = []; + var i; - var transform, counterAxis, x, y; + // boundaryVals are never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; - if(tickLabels.size()) { - var translation = Drawing.getTranslate(tickLabels.node().parentNode); - avoid.offsetLeft = translation.x; - avoid.offsetTop = translation.y; + if(vals.length) { + for(i = 0; i < vals.length; i++) { + _push(vals[i], 0); } + _push(vals[i - 1], 1); + } - var titleStandoff = 10 + fontSize * offsetBase + - (ax.linewidth ? ax.linewidth - 1 : 0); + return out; +} - if(axLetter === 'x') { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : - axisIds.getFromId(gd, ax.anchor); +function getSecondaryLabelVals(ax, vals) { + var out = []; + var lookup = {}; - x = ax._offset + ax._length / 2; + for(var i = 0; i < vals.length; i++) { + var d = vals[i]; + if(lookup[d.text2]) { + lookup[d.text2].push(d.x); + } else { + lookup[d.text2] = [d.x]; + } + } - if(ax.side === 'top') { - y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); - } - else { - y = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1.5 : 0.5); - } - y += counterAxis._offset; + for(var k in lookup) { + out.push(tickTextObj(ax, Lib.interp(lookup[k], 0.5), k)); + } + + return out; +} + +function getDividerVals(ax, vals) { + var out = []; + var i, current; - if(!avoid.side) avoid.side = 'bottom'; + // never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); } - else { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + }; - y = ax._offset + ax._length / 2; - if(ax.side === 'right') { - x = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1 : 0.5); - } - else { - x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + if(ax.showdividers && vals.length) { + for(i = 0; i < vals.length; i++) { + var d = vals[i]; + if(d.text2 !== current) { + _push(d, 0); } - x += counterAxis._offset; + current = d.text2; + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getLabelLevelSpan(ax, cls) { + var axLetter = ax._id.charAt(0); + var angle = ax._tickAngles[cls] || 0; + var rad = Lib.deg2rad(angle); + var sinA = Math.sin(rad); + var cosA = Math.cos(rad); + var maxX = 0; + var maxY = 0; + + // N.B. Drawing.bBox does not take into account rotate transforms + + ax._selections[cls].each(function() { + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + var w = bb.width; + var h = bb.height; + maxX = Math.max(maxX, cosA * w, sinA * h); + maxY = Math.max(maxY, sinA * w, cosA * h); + }); + + return {x: maxY, y: maxX}[axLetter]; +} + +/** + * Which direction do the 'ax.side' values, and free ticks go? + * + * @param {object} ax (full) axis object + * - {string} _id (starting with 'x' or 'y') + * - {string} side + * - {string} ticks + * @return {array} all entries are either -1 or 1 + * - [0]: sign for top/right ticks (i.e. negative SVG direction) + * - [1]: sign for bottom/left ticks (i.e. positive SVG direction) + * - [2]: sign for ticks corresponding to 'ax.side' + * - [3]: sign for ticks mirroring 'ax.side' + */ +axes.getTickSigns = function(ax) { + var axLetter = ax._id.charAt(0); + var sideOpposite = {x: 'top', y: 'right'}[axLetter]; + var main = ax.side === sideOpposite ? 1 : -1; + var out = [-1, 1, main, -main]; + // then we flip if outside XOR y axis + if((ax.ticks !== 'inside') === (axLetter === 'x')) { + out = out.map(function(v) { return -v; }); + } + return out; +}; + +/** + * Make axis translate transform function + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} _offset + * - {fn} l2p + * @return {fn} function of calcTicks items + */ +axes.makeTransFn = function(ax) { + var axLetter = ax._id.charAt(0); + var offset = ax._offset; + return axLetter === 'x' ? + function(d) { return 'translate(' + (offset + ax.l2p(d.x)) + ',0)'; } : + function(d) { return 'translate(0,' + (offset + ax.l2p(d.x)) + ')'; }; +}; + +/** + * Make axis tick path string + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} ticklen + * - {number} linewidth + * @param {number} shift along direction of ticklen + * @param {1 or -1} sng tick sign + * @param {number (optional)} len tick length + * @return {string} + */ +axes.makeTickPath = function(ax, shift, sgn, len) { + len = len !== undefined ? len : ax.ticklen; + + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + + return axLetter === 'x' ? + 'M0,' + (shift + pad * sgn) + 'v' + (len * sgn) : + 'M' + (shift + pad * sgn) + ',0h' + (len * sgn); +}; + +/** + * Make axis tick label x, y and anchor functions + * + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} ticklen + * - {string} side + * - {number} linewidth + * - {number} tickfont.size + * - {boolean} showline + * @param {number} shift + * @param {number} angle [in degrees] ... + * @return {object} + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + * - {number} labelStandoff + * - {number} labelShift + */ +axes.makeLabelFns = function(ax, shift, angle) { + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside'; + + var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0; + var labelShift = 0; + + if(angle && ax.ticks === 'outside') { + var rad = Lib.deg2rad(angle); + labelStandoff = ax.ticklen * Math.cos(rad) + 1; + labelShift = ax.ticklen * Math.sin(rad); + } + + if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) { + labelStandoff += 0.2 * ax.tickfont.size; + } + + // Used in polar angular label x/y functions + // TODO generalize makeLabelFns so that it just work for angular axes + var out = { + labelStandoff: labelStandoff, + labelShift: labelShift + }; + + var x0, y0, ff, flipIt; + if(axLetter === 'x') { + flipIt = ax.side === 'bottom' ? 1 : -1; + x0 = labelShift * flipIt; + y0 = shift + (labelStandoff + pad) * flipIt; + ff = ax.side === 'bottom' ? 1 : -0.2; + + out.labelXFn = function(d) { return d.dx + x0; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * ff; }; + out.labelAnchorFn = function(a) { + if(!isNumeric(a) || a === 0 || a === 180) { + return 'middle'; + } + return (a * flipIt < 0) ? 'end' : 'start'; + }; + } else if(axLetter === 'y') { + flipIt = ax.side === 'right' ? 1 : -1; + x0 = labelStandoff + pad; + y0 = -labelShift * flipIt; + ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0; + + out.labelXFn = function(d) { return d.dx + shift + (x0 + d.fontSize * ff) * flipIt; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; }; + out.labelAnchorFn = function(a) { + if(isNumeric(a) && Math.abs(a) === 90) { + return 'middle'; + } + return ax.side === 'right' ? 'start' : 'end'; + }; + } - transform = {rotate: '-90', offset: 0}; - if(!avoid.side) avoid.side = 'left'; + return out; +}; + +function tickDataFn(d) { + return [d.text, d.x, d.axInfo, d.font, d.fontSize, d.fontColor].join('_'); +} + +/** + * Draw axis ticks + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} linewidth + * - {string} tickcolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawTicks = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'tick'; + + var ticks = opts.layer.selectAll('path.' + cls) + .data(ax.ticks ? opts.vals : [], tickDataFn); + + ticks.exit().remove(); + + ticks.enter().append('path') + .classed(cls, 1) + .classed('ticks', 1) + .classed('crisp', opts.crisp !== false) + .call(Color.stroke, ax.tickcolor) + .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') + .attr('d', opts.path); + + ticks.attr('transform', opts.transFn); +}; + +/** + * Draw axis grid + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showgrid + * - {string} gridcolor + * - {string} gridwidth + * - {boolean} zeroline + * - {string} type + * - {string} dtick + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * optional - only required if this axis supports zero lines + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawGrid = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'grid'; + var vals = opts.vals; + var counterAx = opts.counterAxis; + if(ax.showgrid === false) { + vals = []; + } + else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + var isArrayMode = ax.tickmode === 'array'; + for(var i = 0; i < vals.length; i++) { + var xi = vals[i].x; + if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) { + vals = vals.slice(0, i).concat(vals.slice(i + 1)); + // In array mode you can in principle have multiple + // ticks at 0, so test them all. Otherwise once we found + // one we can stop. + if(isArrayMode) i--; + else break; + } } + } + + var grid = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + grid.exit().remove(); + + grid.enter().append('path') + .classed(cls, 1) + .classed('crisp', opts.crisp !== false); + + ax._gw = Drawing.crispRound(gd, ax.gridwidth, 1); + + grid.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.gridcolor || '#ddd') + .style('stroke-width', ax._gw + 'px'); + + if(typeof opts.path === 'function') grid.attr('d', opts.path); +}; + +/** + * Draw axis zero-line + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} zeroline + * - {number} zerolinewidth + * - {string} zerolinecolor + * - {number (optional)} _gridWidthCrispRound + * @param {object} opts + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawZeroLine = function(gd, ax, opts) { + opts = opts || opts; + + var cls = ax._id + 'zl'; + var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis); - Titles.draw(gd, axid + 'title', { - propContainer: ax, - propName: ax._name + '.title', - placeholder: fullLayout._dfltTitle[axLetter], - avoid: avoid, - transform: transform, - attributes: {x: x, y: y, 'text-anchor': 'middle'} + var zl = opts.layer.selectAll('path.' + cls) + .data(show ? [{x: 0, id: ax._id}] : []); + + zl.exit().remove(); + + zl.enter().append('path') + .classed(cls, 1) + .classed('zl', 1) + .classed('crisp', opts.crisp !== false) + .each(function() { + // use the fact that only one element can enter to trigger a sort. + // If several zerolines enter at the same time we will sort once per, + // but generally this should be a minimal overhead. + opts.layer.selectAll('path').sort(function(da, db) { + return axisIds.idSort(da.id, db.id); + }); }); - } - function drawGrid(plotinfo, counteraxis) { - if(fullLayout._hasOnlyLargeSploms) return; - - var gridcontainer = plotinfo.gridlayer.selectAll('.' + axid); - var zlcontainer = plotinfo.zerolinelayer; - var gridpath = ax._gridpath || ((axLetter === 'x' ? - ('M0,' + counteraxis._offset + 'v') : - ('M' + counteraxis._offset + ',0h') - ) + counteraxis._length); - var grid = gridcontainer.selectAll('path.' + gcls) - .data((ax.showgrid === false) ? [] : valsClipped, datafn); - grid.enter().append('path').classed(gcls, 1) - .classed('crisp', 1) - .attr('d', gridpath) + zl.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); +}; + +/** + * Draw axis tick labels + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showticklabels + * - {number} tickangle + * - {object (optional)} _selections + * - {object} (optional)} _tickAngles + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string (optional)} cls (node className) + * - {boolean} repositionOnUpdate (set to true to reposition update selection) + * - {boolean} secondary + * - {fn} transFn + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + */ +axes.drawLabels = function(gd, ax, opts) { + opts = opts || {}; + + var axId = ax._id; + var axLetter = axId.charAt(0); + var cls = opts.cls || axId + 'tick'; + var vals = opts.vals; + var labelXFn = opts.labelXFn; + var labelYFn = opts.labelYFn; + var labelAnchorFn = opts.labelAnchorFn; + var tickAngle = opts.secondary ? 0 : ax.tickangle; + var lastAngle = (ax._tickAngles || {})[cls]; + + var tickLabels = opts.layer.selectAll('g.' + cls) + .data(ax.showticklabels ? vals : [], tickDataFn); + + var labelsReady = []; + + tickLabels.enter().append('g') + .classed(cls, 1) + .append('text') + // only so tex has predictable alignment that we can + // alter later + .attr('text-anchor', 'middle') .each(function(d) { - if(ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - Math.abs(d.x) < ax.dtick / 100) { - d3.select(this).remove(); + var thisLabel = d3.select(this); + var newPromise = gd._promises.length; + + thisLabel + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)) + .call(Drawing.font, d.font, d.fontSize, d.fontColor) + .text(d.text) + .call(svgTextUtils.convertToTspans, gd); + + if(gd._promises[newPromise]) { + // if we have an async label, we'll deal with that + // all here so take it out of gd._promises and + // instead position the label and promise this in + // labelsReady + labelsReady.push(gd._promises.pop().then(function() { + positionLabels(thisLabel, tickAngle); + })); + } else { + // sync label: just position it now. + positionLabels(thisLabel, tickAngle); } }); - grid.attr('transform', transfn) - .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', gridWidth + 'px'); - if(typeof gridpath === 'function') grid.attr('d', gridpath); - grid.exit().remove(); - - // zero line - if(zlcontainer) { - var zlData = {x: 0, id: axid}; - var showZl = axes.shouldShowZeroLine(gd, ax, counteraxis); - var zl = zlcontainer.selectAll('path.' + zcls) - .data(showZl ? [zlData] : []); - zl.enter().append('path').classed(zcls, 1).classed('zl', 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function() { - // use the fact that only one element can enter to trigger a sort. - // If several zerolines enter at the same time we will sort once per, - // but generally this should be a minimal overhead. - zlcontainer.selectAll('path').sort(function(da, db) { - return axisIds.idSort(da.id, db.id); - }); - }); - zl.attr('transform', transfn) - .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', zeroLineWidth + 'px'); - zl.exit().remove(); - } + + tickLabels.exit().remove(); + + if(opts.repositionOnUpdate) { + tickLabels.each(function(d) { + d3.select(this).select('text') + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)); + }); } - if(independent) { - drawTicks(ax._axislayer, tickpathfn(ax._pos + pad * ticksign[2], ticksign[2] * ax.ticklen)); - if(ax._counteraxis) { - var fictionalPlotinfo = { - gridlayer: ax._gridlayer, - zerolinelayer: ax._zerolinelayer - }; - drawGrid(fictionalPlotinfo, ax._counteraxis); + // How much to shift a multi-line label to center it vertically. + function getAnchorHeight(lineCount, lineHeight, angle) { + var h = (lineCount - 1) * lineHeight; + if(axLetter === 'x') { + if(angle < -60 || 60 < angle) { + return -0.5 * h; + } else if(ax.side === 'top') { + return -h; + } + } else { + angle *= ax.side === 'left' ? 1 : -1; + if(angle < -30) { + return -h; + } else if(angle < 30) { + return -0.5 * h; + } } - return drawLabels(ax._axislayer, ax._pos); + return 0; } - else if(fullLayout._has('cartesian')) { - subplots = axes.getSubplots(gd, ax); - - // keep track of which subplots (by main conteraxis) we've already - // drawn grids for, so we don't overdraw overlaying subplots - var finishedGrids = {}; - subplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; - var counterAxis = plotinfo[counterLetter + 'axis']; + function positionLabels(s, angle) { + s.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + var anchor = labelAnchorFn(angle, d); + + var transform = opts.transFn.call(thisLabel.node(), d) + + ((isNumeric(angle) && +angle !== 0) ? + (' rotate(' + angle + ',' + labelXFn(d) + ',' + + (labelYFn(d) - d.fontSize / 2) + ')') : + ''); + + var anchorHeight = getAnchorHeight( + svgTextUtils.lineCount(thisLabel), + LINE_SPACING * d.fontSize, + isNumeric(angle) ? +angle : 0 + ); - var mainCounterID = counterAxis._mainAxis._id; - if(finishedGrids[mainCounterID]) return; - finishedGrids[mainCounterID] = 1; + if(anchorHeight) { + transform += ' translate(0, ' + anchorHeight + ')'; + } - drawGrid(plotinfo, counterAxis, subplot); + if(mathjaxGroup.empty()) { + thisLabel.select('text').attr({ + transform: transform, + 'text-anchor': anchor + }); + } else { + var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; + var mjShift = mjWidth * {end: -0.5, start: 0.5}[anchor]; + mathjaxGroup.attr('transform', transform + (mjShift ? 'translate(' + mjShift + ',0)' : '')); + } }); + } - var mainSubplot = ax._mainSubplot; - var mainPlotinfo = fullLayout._plots[mainSubplot]; - var tickSubplots = []; + // make sure all labels are correctly positioned at their base angle + // the positionLabels call above is only for newly drawn labels. + // do this without waiting, using the last calculated angle to + // minimize flicker, then do it again when we know all labels are + // there, putting back the prescribed angle to check for overlaps. + positionLabels(tickLabels, lastAngle || tickAngle); - if(ax.ticks) { - var mainSign = ticksign[2]; - var tickpath = tickpathfn(ax._mainLinePosition + pad * mainSign, mainSign * ax.ticklen); - if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { - tickpath += tickpathfn(ax._mainMirrorPosition - pad * mainSign, -mainSign * ax.ticklen); - } - drawTicks(mainPlotinfo[axLetter + 'axislayer'], tickpath); + function allLabelsReady() { + return labelsReady.length && Promise.all(labelsReady); + } - tickSubplots = Object.keys(ax._linepositions || {}); - } + function fixLabelOverlaps() { + positionLabels(tickLabels, tickAngle); + + var autoangle = null; - tickSubplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; + // check for auto-angling if x labels overlap + // don't auto-angle at all for log axes with + // base and digit format + if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) && + (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D') + ) { + autoangle = 0; + + var maxFontSize = 0; + var lbbArray = []; + var i; + + tickLabels.each(function(d) { + maxFontSize = Math.max(maxFontSize, d.fontSize); + + var x = ax.l2p(d.x); + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + + lbbArray.push({ + // ignore about y, just deal with x overlaps + top: 0, + bottom: 10, + height: 10, + left: x - bb.width / 2, + // impose a 2px gap + right: x + bb.width / 2 + 2, + width: bb.width + 2 + }); + }); - var container = plotinfo[axLetter + 'axislayer']; + if((ax.tickson === 'boundaries' || ax.showdividers) && !opts.secondary) { + var gap = 2; + if(ax.ticks) gap += ax.tickwidth / 2; - // [bottom or left, top or right] - // free and main are handled above - var linepositions = ax._linepositions[subplot] || []; + // TODO should secondary labels also fall into this fix-overlap regime? - function tickPathSide(sidei) { - var tsign = ticksign[sidei]; - return tickpathfn(linepositions[sidei] + pad * tsign, tsign * ax.ticklen); + for(i = 0; i < lbbArray.length; i++) { + var xbnd = vals[i].xbnd; + var lbb = lbbArray[i]; + if( + (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || + (xbnd[1] !== null && (ax.l2p(xbnd[1]) - lbb.right) < gap) + ) { + autoangle = 90; + break; + } + } + } else { + var vLen = vals.length; + var tickSpacing = Math.abs((vals[vLen - 1].x - vals[0].x) * ax._m) / (vLen - 1); + var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory'; + + // any overlap at all - set 30 degrees or 90 degrees + for(i = 0; i < lbbArray.length - 1; i++) { + if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { + autoangle = rotate90 ? 90 : 30; + break; + } + } } - drawTicks(container, tickPathSide(0) + tickPathSide(1)); - }); + if(autoangle) { + positionLabels(tickLabels, autoangle); + } + } - var mainContainer = mainPlotinfo[axLetter + 'axislayer']; + if(ax._tickAngles) { + ax._tickAngles[cls] = autoangle === null ? + (isNumeric(tickAngle) ? tickAngle : 0) : + autoangle; + } + } - return drawLabels(mainContainer, ax._mainLinePosition); + if(ax._selections) { + ax._selections[cls] = tickLabels; } + + var done = Lib.syncOrAsync([allLabelsReady, fixLabelOverlaps]); + if(done && done.then) gd._promises.push(done); + return done; }; +/** + * Draw axis dividers + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} showdividers + * - {number} dividerwidth + * - {string} dividercolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {fn} path + * - {fn} transFn + */ +function drawDividers(gd, ax, opts) { + var cls = ax._id + 'divider'; + var vals = opts.vals; + + var dividers = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + dividers.exit().remove(); + + dividers.enter().insert('path', ':first-child') + .classed(cls, 1) + .classed('crisp', 1) + .call(Color.stroke, ax.dividercolor) + .style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px'); + + dividers + .attr('transform', opts.transFn) + .attr('d', opts.path); +} + +function drawTitle(gd, ax) { + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var gs = fullLayout._size; + var fontSize = ax.title.font.size; + + var titleStandoff; + if(ax.type === 'multicategory') { + titleStandoff = ax._labelLength; + } else { + var offsetBase = 1.5; + titleStandoff = 10 + fontSize * offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); + } + + var transform, counterAxis, x, y; + + if(axLetter === 'x') { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + x = ax._offset + ax._length / 2; + + if(ax.side === 'top') { + y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); + } else { + y = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1.5 : 0.5); + } + y += counterAxis._offset; + } else { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + y = ax._offset + ax._length / 2; + + if(ax.side === 'right') { + x = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1 : 0.5); + } else { + x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + } + x += counterAxis._offset; + + transform = {rotate: '-90', offset: 0}; + } + + var avoid; + + if(ax.type !== 'multicategory') { + var tickLabels = ax._selections[ax._id + 'tick']; + + avoid = { + selection: tickLabels, + side: ax.side + }; + + if(tickLabels && tickLabels.node() && tickLabels.node().parentNode) { + var translation = Drawing.getTranslate(tickLabels.node().parentNode); + avoid.offsetLeft = translation.x; + avoid.offsetTop = translation.y; + } + } + + return Titles.draw(gd, axId + 'title', { + propContainer: ax, + propName: ax._name + '.title.text', + placeholder: fullLayout._dfltTitle[axLetter], + avoid: avoid, + transform: transform, + attributes: {x: x, y: y, 'text-anchor': 'middle'} + }); +} + axes.shouldShowZeroLine = function(gd, ax, counterAxis) { var rng = Lib.simpleMap(ax.range, ax.r2l); return ( (rng[0] * rng[1] <= 0) && ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - ax._valsClipped.length && + ax._gridVals.length && ( clipEnds(ax, 0) || !anyCounterAxLineAtZero(gd, ax, counterAxis, rng) || @@ -50534,6 +51848,10 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { ); }; +axes.clipEnds = function(ax, vals) { + return vals.filter(function(d) { return clipEnds(ax, d.x); }); +}; + function clipEnds(ax, l) { var p = ax.l2p(l); return (p > 1 && p < ax._length - 1); @@ -50609,6 +51927,12 @@ function hasBarsOrFill(gd, ax) { return false; } +function selectTickLabel(gTick) { + var s = d3.select(gTick); + var mj = s.select('.text-math-group'); + return mj.empty() ? s.select('text') : mj; +} + /** * Find all margin pushers for 2D axes and reserve them for later use * Both label and rangeslider automargin calculations happen later so @@ -50623,14 +51947,17 @@ axes.allowAutoMargin = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; if(ax.automargin) { - Plots.allowAutoMargin(gd, ax._name + '.automargin'); + Plots.allowAutoMargin(gd, axAutoMarginID(ax)); } - if(ax.rangeslider && ax.rangeslider.visible) { - Plots.allowAutoMargin(gd, 'rangeslider' + ax._id); + if(Registry.getComponentMethod('rangeslider', 'isVisible')(ax)) { + Plots.allowAutoMargin(gd, rangeSliderAutoMarginID(ax)); } } }; +function axAutoMarginID(ax) { return ax._id + '.automargin'; } +function rangeSliderAutoMarginID(ax) { return ax._id + '.rangeslider'; } + // swap all the presentation attributes of the axes showing these traces axes.swap = function(gd, traces) { var axGroups = makeAxisGroups(gd, traces); @@ -50686,11 +52013,10 @@ function mergeAxisGroups(intoSet, fromSet) { } function swapAxisGroup(gd, xIds, yIds) { - var i, - j, - xFullAxes = [], - yFullAxes = [], - layout = gd.layout; + var xFullAxes = []; + var yFullAxes = []; + var layout = gd.layout; + var i, j; for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i])); for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i])); @@ -50703,12 +52029,12 @@ function swapAxisGroup(gd, xIds, yIds) { var numericTypes = ['linear', 'log']; for(i = 0; i < allAxKeys.length; i++) { - var keyi = allAxKeys[i], - xVal = xFullAxes[0][keyi], - yVal = yFullAxes[0][keyi], - allEqual = true, - coerceLinearX = false, - coerceLinearY = false; + var keyi = allAxKeys[i]; + var xVal = xFullAxes[0][keyi]; + var yVal = yFullAxes[0][keyi]; + var allEqual = true; + var coerceLinearX = false; + var coerceLinearY = false; if(keyi.charAt(0) === '_' || typeof xVal === 'function' || noSwapAttrs.indexOf(keyi) !== -1) { continue; @@ -50754,17 +52080,18 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes, dfltTitle) { // in case the value is the default for either axis, // look at the first axis in each list and see if // this key's value is undefined - var np = Lib.nestedProperty, - xVal = np(layout[xFullAxes[0]._name], key).get(), - yVal = np(layout[yFullAxes[0]._name], key).get(), - i; + var np = Lib.nestedProperty; + var xVal = np(layout[xFullAxes[0]._name], key).get(); + var yVal = np(layout[yFullAxes[0]._name], key).get(); + var i; + if(key === 'title') { // special handling of placeholder titles - if(xVal === dfltTitle.x) { - xVal = dfltTitle.y; + if(xVal && xVal.text === dfltTitle.x) { + xVal.text = dfltTitle.y; } - if(yVal === dfltTitle.y) { - yVal = dfltTitle.x; + if(yVal && yVal.text === dfltTitle.y) { + yVal.text = dfltTitle.x; } } @@ -50780,7 +52107,7 @@ function isAngular(ax) { return ax._id === 'angularaxis'; } -},{"../../components/color":51,"../../components/drawing":76,"../../components/titles":142,"../../constants/alignment":149,"../../constants/numerical":152,"../../lib":170,"../../lib/svg_text_utils":191,"../../plots/plots":247,"../../registry":259,"./autorange":213,"./axis_autotype":215,"./axis_ids":217,"./clean_ticks":219,"./layout_attributes":227,"./set_convert":233,"d3":16,"fast-isnumeric":18}],215:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/drawing":72,"../../components/titles":139,"../../constants/alignment":146,"../../constants/numerical":149,"../../lib":168,"../../lib/svg_text_utils":189,"../../plots/plots":245,"../../registry":257,"./autorange":211,"./axis_autotype":213,"./axis_ids":215,"./clean_ticks":217,"./layout_attributes":225,"./set_convert":231,"d3":16,"fast-isnumeric":18}],213:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50797,7 +52124,10 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var BADNUM = _dereq_('../../constants/numerical').BADNUM; -module.exports = function autoType(array, calendar) { +module.exports = function autoType(array, calendar, opts) { + opts = opts || {}; + + if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory'; if(moreDates(array, calendar)) return 'date'; if(category(array)) return 'category'; if(linearOK(array)) return 'linear'; @@ -50865,7 +52195,14 @@ function category(a) { return curvecats > curvenums * 2; } -},{"../../constants/numerical":152,"../../lib":170,"fast-isnumeric":18}],216:[function(_dereq_,module,exports){ +// very-loose requirements for multicategory, +// trace modules that should never auto-type to multicategory +// should be declared with 'noMultiCategory' +function multiCategory(a) { + return Lib.isArrayOrTypedArray(a[0]) && Lib.isArrayOrTypedArray(a[1]); +} + +},{"../../constants/numerical":149,"../../lib":168,"fast-isnumeric":18}],214:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50896,6 +52233,7 @@ var setConvert = _dereq_('./set_convert'); * outerTicks: boolean, should ticks default to outside? * showGrid: boolean, should gridlines be shown by default? * noHover: boolean, this axis doesn't support hover effects? + * noTickson: boolean, this axis doesn't support 'tickson' * data: the plot data, used to manage categories * bgColor: the plot background color, to calculate default gridline colors */ @@ -50936,8 +52274,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, // try to get default title from splom trace, fallback to graph-wide value var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter]; - coerce('title', dfltTitle); - Lib.coerceFont(coerce, 'titlefont', { + coerce('title.text', dfltTitle); + Lib.coerceFont(coerce, 'title.font', { family: font.family, size: Math.round(font.size * 1.2), color: dfltFontColor @@ -50957,10 +52295,29 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, if(options.automargin) coerce('automargin'); + var isMultiCategory = containerOut.type === 'multicategory'; + + if(!options.noTickson && + (containerOut.type === 'category' || isMultiCategory) && + (containerOut.ticks || containerOut.showgrid) + ) { + var ticksonDflt; + if(isMultiCategory) ticksonDflt = 'boundaries'; + coerce('tickson', ticksonDflt); + } + + if(isMultiCategory) { + var showDividers = coerce('showdividers'); + if(showDividers) { + coerce('dividercolor'); + coerce('dividerwidth'); + } + } + return containerOut; }; -},{"../../lib":170,"../../registry":259,"./category_order_defaults":218,"./layout_attributes":227,"./line_grid_defaults":229,"./set_convert":233,"./tick_label_defaults":234,"./tick_mark_defaults":235,"./tick_value_defaults":236}],217:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257,"./category_order_defaults":216,"./layout_attributes":225,"./line_grid_defaults":227,"./set_convert":231,"./tick_label_defaults":232,"./tick_mark_defaults":233,"./tick_value_defaults":234}],215:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51078,7 +52435,7 @@ exports.idSort = function(id1, id2) { return +(id1.substr(1) || 1) - +(id2.substr(1) || 1); }; -},{"../../registry":259,"./constants":220}],218:[function(_dereq_,module,exports){ +},{"../../registry":257,"./constants":218}],216:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51172,7 +52529,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],219:[function(_dereq_,module,exports){ +},{}],217:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51261,7 +52618,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":152,"../../lib":170,"fast-isnumeric":18}],220:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168,"fast-isnumeric":18}],218:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51343,7 +52700,7 @@ module.exports = { } }; -},{"../../lib/regex":185}],221:[function(_dereq_,module,exports){ +},{"../../lib/regex":183}],219:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51497,7 +52854,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[scaleanchor] = 1; } -},{"../../lib":170,"./axis_ids":217}],222:[function(_dereq_,module,exports){ +},{"../../lib":168,"./axis_ids":215}],220:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51639,7 +52996,6 @@ exports.enforce = function enforceAxisConstraints(gd) { var getPad = makePadFn(ax); updateDomain(ax, factor); - ax.setScale(); var m = Math.abs(ax._m); var extremes = concatExtremes(gd, ax); var minArray = extremes.min; @@ -51706,9 +53062,10 @@ function updateDomain(ax, factor) { center + (inputDomain[0] - center) / factor, center + (inputDomain[1] - center) / factor ]; + ax.setScale(); } -},{"../../constants/alignment":149,"../../constants/numerical":152,"./autorange":213,"./axis_ids":217,"./scale_zoom":231}],223:[function(_dereq_,module,exports){ +},{"../../constants/alignment":146,"../../constants/numerical":149,"./autorange":211,"./axis_ids":215,"./scale_zoom":229}],221:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51730,6 +53087,7 @@ var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Fx = _dereq_('../../components/fx'); +var Axes = _dereq_('./axes'); var setCursor = _dereq_('../../lib/setcursor'); var dragElement = _dereq_('../../components/dragelement'); var FROM_TL = _dereq_('../../constants/alignment').FROM_TL; @@ -51738,7 +53096,6 @@ var redrawReglTraces = _dereq_('../../plot_api/subroutines').redrawReglTraces; var Plots = _dereq_('../plots'); -var doTicksSingle = _dereq_('./axes').doTicksSingle; var getFromId = _dereq_('./axis_ids').getFromId; var prepSelect = _dereq_('./select').prepSelect; var clearSelect = _dereq_('./select').clearSelect; @@ -51982,7 +53339,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { .on('edit', function(text) { var v = ax.d2r(text); if(v !== undefined) { - Registry.call('relayout', gd, attrStr, v); + Registry.call('_guiRelayout', gd, attrStr, v); } }); } @@ -52227,6 +53584,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { return; } + // prevent axis drawing from monkeying with margins until we're done + gd._fullLayout._replotting = true; + if(xActive === 'ew' || yActive === 'ns') { if(xActive) dragAxList(xaxes, dx); if(yActive) dragAxList(yaxes, dy); @@ -52330,8 +53690,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { updates = {}; for(i = 0; i < activeAxIds.length; i++) { var axId = activeAxIds[i]; - doTicksSingle(gd, axId, true); var ax = getFromId(gd, axId); + Axes.drawOne(gd, ax, {skipTitle: true}); updates[ax._name + '.range[0]'] = ax.range[0]; updates[ax._name + '.range[1]'] = ax.range[1]; } @@ -52423,7 +53783,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, attrs); } // dragTail - finish a drag event with a redraw @@ -52437,7 +53797,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // accumulated MathJax promises - wait for them before we relayout. Lib.syncOrAsync([ Plots.previousPromises, - function() { Registry.call('relayout', gd, updates); } + function() { + gd._fullLayout._replotting = false; + Registry.call('_guiRelayout', gd, updates); + } ], gd); } @@ -52895,7 +54258,7 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":51,"../../components/dragelement":73,"../../components/drawing":76,"../../components/fx":93,"../../constants/alignment":149,"../../lib":170,"../../lib/clear_gl_canvases":159,"../../lib/setcursor":189,"../../lib/svg_text_utils":191,"../../plot_api/subroutines":205,"../../registry":259,"../plots":247,"./axes":214,"./axis_ids":217,"./constants":220,"./scale_zoom":231,"./select":232,"d3":16,"has-passive-events":21,"tinycolor2":34}],224:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/dragelement":69,"../../components/drawing":72,"../../components/fx":90,"../../constants/alignment":146,"../../lib":168,"../../lib/clear_gl_canvases":157,"../../lib/setcursor":187,"../../lib/svg_text_utils":189,"../../plot_api/subroutines":203,"../../registry":257,"../plots":245,"./axes":212,"./axis_ids":215,"./constants":218,"./scale_zoom":229,"./select":230,"d3":16,"has-passive-events":21,"tinycolor2":34}],222:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53063,7 +54426,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":73,"../../components/fx":93,"../../lib/setcursor":189,"./constants":220,"./dragbox":223,"d3":16}],225:[function(_dereq_,module,exports){ +},{"../../components/dragelement":69,"../../components/fx":90,"../../lib/setcursor":187,"./constants":218,"./dragbox":221,"d3":16}],223:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53138,7 +54501,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":170,"../../registry":259}],226:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257}],224:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53403,7 +54766,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback // layers that allow `cliponaxis: false` if(className !== 'scatterlayer' && className !== 'barlayer') { - Drawing.setClipUrl(sel, plotinfo.layerClipId); + Drawing.setClipUrl(sel, plotinfo.layerClipId, gd); } }); @@ -53761,7 +55124,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":76,"../../constants/xmlns_namespaces":153,"../../lib":170,"../../registry":259,"../get_data":243,"../plots":247,"./attributes":212,"./axis_ids":217,"./constants":220,"./graph_interact":224,"./layout_attributes":227,"./layout_defaults":228,"./transition_axes":237,"d3":16}],227:[function(_dereq_,module,exports){ +},{"../../components/drawing":72,"../../constants/xmlns_namespaces":150,"../../lib":168,"../../registry":257,"../get_data":241,"../plots":245,"./attributes":210,"./axis_ids":215,"./constants":218,"./graph_interact":222,"./layout_attributes":225,"./layout_defaults":226,"./transition_axes":235,"d3":16}],225:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53796,21 +55159,24 @@ module.exports = { }, title: { - valType: 'string', - - editType: 'ticks', - + text: { + valType: 'string', + + editType: 'ticks', + + }, + font: fontAttrs({ + editType: 'ticks', + + }), + editType: 'ticks' }, - titlefont: fontAttrs({ - editType: 'ticks', - - }), type: { valType: 'enumerated', // '-' means we haven't yet run autotype or couldn't find any data // it gets turned into linear in gd._fullLayout but not copied back // to gd.data like the others are. - values: ['-', 'linear', 'log', 'date', 'category'], + values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', editType: 'calc', @@ -53939,6 +55305,14 @@ module.exports = { editType: 'ticks', + }, + tickson: { + valType: 'enumerated', + values: ['labels', 'boundaries'], + + dflt: 'labels', + editType: 'ticks', + }, mirror: { valType: 'enumerated', @@ -54192,6 +55566,30 @@ module.exports = { editType: 'ticks', }, + + showdividers: { + valType: 'boolean', + dflt: true, + + editType: 'ticks', + + }, + dividercolor: { + valType: 'color', + dflt: colorAttrs.defaultLine, + + editType: 'ticks', + + }, + dividerwidth: { + valType: 'number', + dflt: 1, + + editType: 'ticks', + + }, + // TODO dividerlen: that would override "to label base" length? + // positioning attributes // anchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -54273,6 +55671,12 @@ module.exports = { editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'calc', @@ -54282,11 +55686,21 @@ module.exports = { editType: 'ticks', - } + }, + title: { + valType: 'string', + + editType: 'ticks', + + }, + titlefont: fontAttrs({ + editType: 'ticks', + + }) } }; -},{"../../components/color/attributes":50,"../../components/drawing/attributes":75,"../../lib/extend":164,"../../plot_api/plot_template":204,"../font_attributes":241,"./constants":220}],228:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":50,"../../components/drawing/attributes":71,"../../lib/extend":162,"../../plot_api/plot_template":202,"../font_attributes":239,"./constants":218}],226:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54445,9 +55859,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; }); axLayoutOut._annIndices = []; axLayoutOut._shapeIndices = []; + axLayoutOut._subplotsWith = []; + axLayoutOut._counterAxes = []; // set up some private properties - axLayoutOut._name = axName; + axLayoutOut._name = axLayoutOut._attr = axName; var id = axLayoutOut._id = name2id(axName); var overlayableAxes = getOverlayableAxes(axLetter, axName); @@ -54465,6 +55881,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id] }; + coerce('uirevision', layoutOut.uirevision); + handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions); handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut); @@ -54526,11 +55944,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var anchoredAxis = layoutOut[id2name(axLayoutOut.anchor)]; - var fixedRangeDflt = ( - anchoredAxis && - anchoredAxis.rangeslider && - anchoredAxis.rangeslider.visible - ); + var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis); coerce('fixedrange', fixedRangeDflt); } @@ -54555,7 +55969,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } }; -},{"../../components/color":51,"../../lib":170,"../../plot_api/plot_template":204,"../../registry":259,"../layout_attributes":245,"./axis_defaults":216,"./axis_ids":217,"./constraint_defaults":221,"./layout_attributes":227,"./position_defaults":230,"./type_defaults":238}],229:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../lib":168,"../../plot_api/plot_template":202,"../../registry":257,"../layout_attributes":243,"./axis_defaults":214,"./axis_ids":215,"./constraint_defaults":219,"./layout_attributes":225,"./position_defaults":228,"./type_defaults":236}],227:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54620,7 +56034,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":50,"../../lib":170,"tinycolor2":34}],230:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":50,"../../lib":168,"tinycolor2":34}],228:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54704,7 +56118,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":170,"fast-isnumeric":18}],231:[function(_dereq_,module,exports){ +},{"../../lib":168,"fast-isnumeric":18}],229:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54732,7 +56146,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ]; }; -},{"../../constants/alignment":149}],232:[function(_dereq_,module,exports){ +},{"../../constants/alignment":146}],230:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55401,13 +56815,22 @@ function isOnlyOnePointSelected(searchTraces) { function updateSelectedState(gd, searchTraces, eventData) { var i, searchInfo, cd, trace; + // before anything else, update preGUI if necessary + for(i = 0; i < searchTraces.length; i++) { + var fullInputTrace = searchTraces[i].cd[0].trace._fullInput; + var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid]; + if(tracePreGUI.selectedpoints === undefined) { + tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null; + } + } + if(eventData) { var pts = eventData.points || []; for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; - trace.selectedpoints = []; - trace._input.selectedpoints = []; + trace._input.selectedpoints = trace._fullInput.selectedpoints = []; + if(trace._fullInput !== trace) trace.selectedpoints = []; } for(i = 0; i < pts.length; i++) { @@ -55417,10 +56840,14 @@ function updateSelectedState(gd, searchTraces, eventData) { if(pt.pointIndices) { [].push.apply(data.selectedpoints, pt.pointIndices); - [].push.apply(fullData.selectedpoints, pt.pointIndices); + if(trace._fullInput !== trace) { + [].push.apply(fullData.selectedpoints, pt.pointIndices); + } } else { data.selectedpoints.push(pt.pointIndex); - fullData.selectedpoints.push(pt.pointIndex); + if(trace._fullInput !== trace) { + fullData.selectedpoints.push(pt.pointIndex); + } } } } @@ -55429,6 +56856,9 @@ function updateSelectedState(gd, searchTraces, eventData) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; delete trace._input.selectedpoints; + if(trace._fullInput !== trace) { + delete trace._fullInput.selectedpoints; + } } } @@ -55506,7 +56936,7 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":51,"../../components/fx":93,"../../components/fx/helpers":90,"../../lib/clear_gl_canvases":159,"../../lib/polygon":182,"../../lib/throttle":192,"../../plot_api/subroutines":205,"../../registry":259,"./axis_ids":217,"./constants":220,"polybooljs":25}],233:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/fx":90,"../../components/fx/helpers":86,"../../lib/clear_gl_canvases":157,"../../lib/polygon":180,"../../lib/throttle":190,"../../plot_api/subroutines":203,"../../registry":257,"./axis_ids":215,"./constants":218,"polybooljs":25}],231:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55539,6 +56969,10 @@ function fromLog(v) { return Math.pow(10, v); } +function isValidCategory(v) { + return v !== null && v !== undefined; +} + /** * Define the conversion functions for an axis data is used in 5 ways: * @@ -55632,7 +57066,7 @@ module.exports = function setConvert(ax, fullLayout) { * a disconnect between the array and the index returned */ function setCategoryIndex(v) { - if(v !== null && v !== undefined) { + if(isValidCategory(v)) { if(ax._categoriesMap === undefined) { ax._categoriesMap = {}; } @@ -55651,14 +57085,58 @@ module.exports = function setConvert(ax, fullLayout) { return BADNUM; } + function setMultiCategoryIndex(arrayIn, len) { + var arrayOut = new Array(len); + var i; + + // [ [arrayIn[0][i], arrayIn[1][i]], for i .. len ] + var tmp = new Array(len); + // [ [cnt, {$cat: index}], for j .. arrayIn.length ] + var seen = [[0, {}], [0, {}]]; + + if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) { + for(i = 0; i < len; i++) { + var v0 = arrayIn[0][i]; + var v1 = arrayIn[1][i]; + if(isValidCategory(v0) && isValidCategory(v1)) { + tmp[i] = [v0, v1]; + if(!(v0 in seen[0][1])) { + seen[0][1][v0] = seen[0][0]++; + } + if(!(v1 in seen[1][1])) { + seen[1][1][v1] = seen[1][0]++; + } + } + } + + tmp.sort(function(a, b) { + var ind0 = seen[0][1]; + var d = ind0[a[0]] - ind0[b[0]]; + if(d) return d; + + var ind1 = seen[1][1]; + return ind1[a[1]] - ind1[b[1]]; + }); + } + + for(i = 0; i < len; i++) { + arrayOut[i] = setCategoryIndex(tmp[i]); + } + + return arrayOut; + } + function getCategoryIndex(v) { - // d2l/d2c variant that that won't add categories but will also - // allow numbers to be mapped to the linearized axis positions if(ax._categoriesMap) { - var index = ax._categoriesMap[v]; - if(index !== undefined) return index; + return ax._categoriesMap[v]; } + } + function getCategoryPosition(v) { + // d2l/d2c variant that that won't add categories but will also + // allow numbers to be mapped to the linearized axis positions + var index = getCategoryIndex(v); + if(index !== undefined) return index; if(isNumeric(v)) return +v; } @@ -55744,15 +57222,15 @@ module.exports = function setConvert(ax, fullLayout) { ax.d2c = ax.d2l = setCategoryIndex; ax.r2d = ax.c2d = ax.l2d = getCategoryName; - ax.d2r = ax.d2l_noadd = getCategoryIndex; + ax.d2r = ax.d2l_noadd = getCategoryPosition; ax.r2c = function(v) { - var index = getCategoryIndex(v); + var index = getCategoryPosition(v); return index !== undefined ? index : ax.fraction2r(0.5); }; ax.l2r = ax.c2r = ensureNumber; - ax.r2l = getCategoryIndex; + ax.r2l = getCategoryPosition; ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; ax.p2d = function(px) { return getCategoryName(p2l(px)); }; @@ -55764,6 +57242,34 @@ module.exports = function setConvert(ax, fullLayout) { return ensureNumber(v); }; } + else if(ax.type === 'multicategory') { + // N.B. multicategory axes don't define d2c and d2l, + // as 'data-to-calcdata' conversion needs to take into + // account all data array items as in ax.makeCalcdata. + + ax.r2d = ax.c2d = ax.l2d = getCategoryName; + ax.d2r = ax.d2l_noadd = getCategoryPosition; + + ax.r2c = function(v) { + var index = getCategoryPosition(v); + return index !== undefined ? index : ax.fraction2r(0.5); + }; + + ax.r2c_just_indices = getCategoryIndex; + + ax.l2r = ax.c2r = ensureNumber; + ax.r2l = getCategoryPosition; + + ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; + ax.p2d = function(px) { return getCategoryName(p2l(px)); }; + ax.r2p = ax.d2p; + ax.p2r = p2l; + + ax.cleanPos = function(v) { + if(Array.isArray(v) || (typeof v === 'string' && v !== '')) return v; + return ensureNumber(v); + }; + } // find the range value at the specified (linear) fraction of the axis ax.fraction2r = function(v) { @@ -55857,11 +57363,6 @@ module.exports = function setConvert(ax, fullLayout) { ax.setScale = function(usePrivateRange) { var gs = fullLayout._size; - // TODO cleaner way to handle this case - if(!ax._categories) ax._categories = []; - // Add a map to optimize the performance of category collection - if(!ax._categoriesMap) ax._categoriesMap = {}; - // make sure we have a domain (pull it in from the axis // this one is overlaying if necessary) if(ax.overlaying) { @@ -55916,7 +57417,7 @@ module.exports = function setConvert(ax, fullLayout) { if(axLetter in trace) { arrayIn = trace[axLetter]; - len = trace._length || arrayIn.length; + len = trace._length || Lib.minRowLength(arrayIn); if(Lib.isTypedArray(arrayIn) && (axType === 'linear' || axType === 'log')) { if(len === arrayIn.length) { @@ -55926,6 +57427,10 @@ module.exports = function setConvert(ax, fullLayout) { } } + if(axType === 'multicategory') { + return setMultiCategoryIndex(arrayIn, len); + } + arrayOut = new Array(len); for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); @@ -56002,7 +57507,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":152,"../../lib":170,"./axis_ids":217,"./constants":220,"d3":16,"fast-isnumeric":18}],234:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168,"./axis_ids":215,"./constants":218,"d3":16,"fast-isnumeric":18}],232:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56103,7 +57608,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../lib":170,"../array_container_defaults":210,"./layout_attributes":227}],235:[function(_dereq_,module,exports){ +},{"../../lib":168,"../array_container_defaults":208,"./layout_attributes":225}],233:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56136,7 +57641,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":170,"./layout_attributes":227}],236:[function(_dereq_,module,exports){ +},{"../../lib":168,"./layout_attributes":225}],234:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56145,22 +57650,18 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); - module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { var tickmode; if(containerIn.tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; - } - else { - var tickmodeDefault = - Array.isArray(containerIn.tickvals) ? 'array' : + } else { + var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : containerIn.dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); @@ -56175,15 +57676,14 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe containerIn.dtick, axType); containerOut.tick0 = cleanTicks.tick0( containerIn.tick0, axType, containerOut.calendar, dtick); - } - else { + } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto'; else coerce('ticktext'); } }; -},{"./clean_ticks":219}],237:[function(_dereq_,module,exports){ +},{"./clean_ticks":217}],235:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56305,14 +57805,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo } function ticksAndAnnotations(xa, ya) { - var activeAxIds = [], - i; + var activeAxIds = [xa._id, ya._id]; + var i; - activeAxIds = [xa._id, ya._id]; - - for(i = 0; i < activeAxIds.length; i++) { - Axes.doTicksSingle(gd, activeAxIds[i], true); - } + Axes.drawOne(gd, xa, {skipTitle: true}); + Axes.drawOne(gd, ya, {skipTitle: true}); function redrawObjs(objArray, method, shortCircuit) { for(i = 0; i < objArray.length; i++) { @@ -56511,7 +58008,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo return Promise.resolve(); }; -},{"../../components/drawing":76,"../../registry":259,"./axes":214,"./constants":220,"d3":16}],238:[function(_dereq_,module,exports){ +},{"../../components/drawing":72,"../../registry":257,"./axes":212,"./constants":218,"d3":16}],236:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56522,7 +58019,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo 'use strict'; -var Registry = _dereq_('../../registry'); +var traceIs = _dereq_('../../registry').traceIs; var autoType = _dereq_('./axis_autotype'); /* @@ -56571,6 +58068,7 @@ function setAutoType(ax, data) { var calAttr = axLetter + 'calendar'; var calendar = d0[calAttr]; + var opts = {noMultiCategory: !traceIs(d0, 'cartesian') || traceIs(d0, 'noMultiCategory')}; var i; // check all boxes on this x axis to see @@ -56581,8 +58079,7 @@ function setAutoType(ax, data) { for(i = 0; i < data.length; i++) { var trace = data[i]; - if(!Registry.traceIs(trace, 'box-violin') || - (trace[axLetter + 'axis'] || axLetter) !== id) continue; + if(!traceIs(trace, 'box-violin') || (trace[axLetter + 'axis'] || axLetter) !== id) continue; if(trace[posLetter] !== undefined) boxPositions.push(trace[posLetter][0]); else if(trace.name !== undefined) boxPositions.push(trace.name); @@ -56591,7 +58088,7 @@ function setAutoType(ax, data) { if(trace[calAttr] !== calendar) calendar = undefined; } - ax.type = autoType(boxPositions, calendar); + ax.type = autoType(boxPositions, calendar, opts); } else if(d0.type === 'splom') { var dimensions = d0.dimensions; @@ -56599,13 +58096,13 @@ function setAutoType(ax, data) { for(i = 0; i < dimensions.length; i++) { var dim = dimensions[i]; if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) { - ax.type = autoType(dim.values, calendar); + ax.type = autoType(dim.values, calendar, opts); break; } } } else { - ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar); + ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -56636,9 +58133,9 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace), - isBox = Registry.traceIs(trace, 'box-violin'), - isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); + var posLetter = getBoxPosLetter(trace); + var isBox = traceIs(trace, 'box-violin'); + var isCandlestick = traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox && @@ -56649,7 +58146,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":259,"./axis_autotype":215}],239:[function(_dereq_,module,exports){ +},{"../../registry":257,"./axis_autotype":213}],237:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57073,7 +58570,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":170,"../registry":259}],240:[function(_dereq_,module,exports){ +},{"../lib":168,"../registry":257}],238:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57181,7 +58678,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { coerce('domain.y', dfltY); }; -},{"../lib/extend":164}],241:[function(_dereq_,module,exports){ +},{"../lib/extend":162}],239:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57246,7 +58743,7 @@ module.exports = function(opts) { return attrs; }; -},{}],242:[function(_dereq_,module,exports){ +},{}],240:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57292,7 +58789,7 @@ module.exports = { } }; -},{}],243:[function(_dereq_,module,exports){ +},{}],241:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57420,7 +58917,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":259,"./cartesian/constants":220}],244:[function(_dereq_,module,exports){ +},{"../registry":257,"./cartesian/constants":218}],242:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57454,7 +58951,7 @@ function project(camera, v) { module.exports = project; -},{}],245:[function(_dereq_,module,exports){ +},{}],243:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57467,6 +58964,9 @@ module.exports = project; var fontAttrs = _dereq_('./font_attributes'); var colorAttrs = _dereq_('../components/color/attributes'); +var colorscaleAttrs = _dereq_('../components/colorscale/layout_attributes'); +var padAttrs = _dereq_('./pad_attributes'); +var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', @@ -57479,15 +58979,71 @@ globalFont.color.dflt = colorAttrs.defaultLine; module.exports = { font: globalFont, title: { - valType: 'string', - - editType: 'layoutstyle', - + text: { + valType: 'string', + + editType: 'layoutstyle', + + }, + font: fontAttrs({ + editType: 'layoutstyle', + + }), + xref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + yref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + x: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.5, + + editType: 'layoutstyle', + + }, + y: { + valType: 'number', + min: 0, + max: 1, + dflt: 'auto', + + editType: 'layoutstyle', + + }, + xanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'left', 'center', 'right'], + + editType: 'layoutstyle', + + }, + yanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'top', 'middle', 'bottom'], + + editType: 'layoutstyle', + + }, + pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { + + }), + editType: 'layoutstyle' }, - titlefont: fontAttrs({ - editType: 'layoutstyle', - - }), autosize: { valType: 'boolean', @@ -57606,11 +59162,30 @@ module.exports = { editType: 'calc', }, + colorscale: colorscaleAttrs, datarevision: { valType: 'any', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editrevision: { + valType: 'any', + + editType: 'none', + + }, + selectionrevision: { + valType: 'any', + + editType: 'none', + }, template: { valType: 'any', @@ -57644,12 +59219,30 @@ module.exports = { editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'modebar' + }, + _deprecated: { + title: { + valType: 'string', + + editType: 'layoutstyle', + + }, + titlefont: fontAttrs({ + editType: 'layoutstyle', + + }) } }; -},{"../components/color/attributes":50,"./font_attributes":241}],246:[function(_dereq_,module,exports){ +},{"../components/color/attributes":50,"../components/colorscale/layout_attributes":64,"../lib/extend":162,"./font_attributes":239,"./pad_attributes":244}],244:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57660,42 +59253,51 @@ module.exports = { 'use strict'; -// This is used exclusively by components inside component arrays, -// hence the 'arraydraw' editType. If this ever gets used elsewhere -// we could generalize it as a function ala font_attributes -module.exports = { - t: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - r: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - b: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - l: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - editType: 'arraydraw' +/** + * Creates a set of padding attributes. + * + * @param {object} opts + * @param {string} editType: + * the editType for all pieces of this padding definition + * + * @return {object} attributes object containing {t, r, b, l} as specified + */ +module.exports = function(opts) { + var editType = opts.editType; + return { + t: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + r: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + b: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + l: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + editType: editType + }; }; -},{}],247:[function(_dereq_,module,exports){ +},{}],245:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58147,6 +59749,7 @@ plots.supplyDefaults = function(gd, opts) { for(i = 0; i < crossTraceDefaultsFuncs.length; i++) { crossTraceDefaultsFuncs[i](newFullData, newFullLayout); } + Registry.getComponentMethod('colorscale', 'crossTraceDefaults')(newFullData, newFullLayout); // turn on flag to optimize large splom-only graphs // mostly by omitting SVG layers during Cartesian.drawFramework @@ -58177,16 +59780,30 @@ plots.supplyDefaults = function(gd, opts) { // relink functions and _ attributes to promote consistency between plots relinkPrivateKeys(newFullLayout, oldFullLayout); - // TODO may return a promise - plots.doAutoMargin(gd); - - // set scale after auto margin routine - var axList = axisIDs.list(gd); - for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - ax.setScale(); + // For persisting GUI-driven changes in layout + // _preGUI and _tracePreGUI were already copied over in relinkPrivateKeys + if(!newFullLayout._preGUI) newFullLayout._preGUI = {}; + // track trace GUI changes by uid rather than by trace index + if(!newFullLayout._tracePreGUI) newFullLayout._tracePreGUI = {}; + var tracePreGUI = newFullLayout._tracePreGUI; + var uids = {}; + var uid; + for(uid in tracePreGUI) uids[uid] = 'old'; + for(i = 0; i < newFullData.length; i++) { + uid = newFullData[i]._fullInput.uid; + if(!uids[uid]) tracePreGUI[uid] = {}; + uids[uid] = 'new'; + } + for(uid in uids) { + if(uids[uid] === 'old') delete tracePreGUI[uid]; } + // set up containers for margin calculations + initMargins(newFullLayout); + + // collect and do some initial calculations for rangesliders + Registry.getComponentMethod('rangeslider', 'makeData')(newFullLayout); + // update object references in calcdata if(!skipUpdateCalc && oldCalcdata.length === newFullData.length) { plots.supplyDefaultsUpdateCalc(oldCalcdata, newFullData); @@ -58495,6 +60112,12 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa plotinfo.id = id; } + // add these axis ids to each others' subplot lists + xaxis._counterAxes.push(yaxis._id); + yaxis._counterAxes.push(xaxis._id); + xaxis._subplotsWith.push(id); + yaxis._subplotsWith.push(id); + // update x and y axis layout object refs plotinfo.xaxis = xaxis; plotinfo.yaxis = yaxis; @@ -58522,8 +60145,9 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // while we're at it, link overlaying axes to their main axes and // anchored axes to the axes they're anchored to var axList = axisIDs.list(mockGd, null, true); + var ax; for(i = 0; i < axList.length; i++) { - var ax = axList[i]; + ax = axList[i]; var mainAx = null; if(ax.overlaying) { @@ -58551,8 +60175,53 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa null : axisIDs.getFromId(mockGd, ax.anchor); } + + // finally, we can find the main subplot for each axis + // (on which the ticks & labels are drawn) + for(i = 0; i < axList.length; i++) { + ax = axList[i]; + ax._counterAxes.sort(axisIDs.idSort); + ax._subplotsWith.sort(Lib.subplotSort); + ax._mainSubplot = findMainSubplot(ax, newFullLayout); + } }; +function findMainSubplot(ax, fullLayout) { + var mockGd = {_fullLayout: fullLayout}; + + var isX = ax._id.charAt(0) === 'x'; + var anchorAx = ax._mainAxis._anchorAxis; + var mainSubplotID = ''; + var nextBestMainSubplotID = ''; + var anchorID = ''; + + // First try the main ID with the anchor + if(anchorAx) { + anchorID = anchorAx._mainAxis._id; + mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); + } + + // Then look for a subplot with the counteraxis overlaying the anchor + // If that fails just use the first subplot including this axis + if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { + mainSubplotID = ''; + + var counterIDs = ax._counterAxes; + for(var j = 0; j < counterIDs.length; j++) { + var counterPart = counterIDs[j]; + var id = isX ? (ax._id + counterPart) : (counterPart + ax._id); + if(!nextBestMainSubplotID) nextBestMainSubplotID = id; + var counterAx = axisIDs.getFromId(mockGd, counterPart); + if(anchorID && counterAx.overlaying === anchorID) { + mainSubplotID = id; + break; + } + } + } + + return mainSubplotID || nextBestMainSubplotID; +} + // This function clears any trace attributes with valType: color and // no set dflt filed in the plot schema. This is needed because groupby (which // is the only transform for which this currently applies) supplies parent @@ -58820,6 +60489,8 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac coerce('type'); coerce('name', layout._traceWord + ' ' + traceInIndex); + coerce('uirevision', layout.uirevision); + // we want even invisible traces to make their would-be subplots visible // so coerce the subplot id(s) now no matter what var _module = plots.getModule(traceOut); @@ -58893,7 +60564,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac if(_module) { _module.supplyDefaults(traceIn, traceOut, defaultColor, layout); - Lib.coerceHoverinfo(traceIn, traceOut, layout); + if(!traceOut.hovertemplate) Lib.coerceHoverinfo(traceIn, traceOut, layout); } if(!Registry.traceIs(traceOut, 'noOpacity')) coerce('opacity'); @@ -59022,14 +60693,25 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { var globalFont = Lib.coerceFont(coerce, 'font'); - coerce('title', layoutOut._dfltTitle.plot); + coerce('title.text', layoutOut._dfltTitle.plot); - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: globalFont.family, size: Math.round(globalFont.size * 1.4), color: globalFont.color }); + coerce('title.xref'); + coerce('title.yref'); + coerce('title.x'); + coerce('title.y'); + coerce('title.xanchor'); + coerce('title.yanchor'); + coerce('title.pad.t'); + coerce('title.pad.r'); + coerce('title.pad.b'); + coerce('title.pad.l'); + // Make sure that autosize is defaulted to *true* // on layouts with no set width and height for backward compatibly, // in particular https://plot.ly/javascript/responsive-fluid-layout/ @@ -59062,12 +60744,16 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('colorway'); coerce('datarevision'); + var uirevision = coerce('uirevision'); + coerce('editrevision', uirevision); + coerce('selectionrevision', uirevision); coerce('modebar.orientation'); coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); + coerce('modebar.uirevision', uirevision); Registry.getComponentMethod( 'calendars', @@ -59349,7 +61035,20 @@ plots.allowAutoMargin = function(gd, id) { gd._fullLayout._pushmarginIds[id] = 1; }; -function setupAutoMargin(fullLayout) { +function initMargins(fullLayout) { + var margin = fullLayout.margin; + + if(!fullLayout._size) { + var gs = fullLayout._size = { + l: Math.round(margin.l), + r: Math.round(margin.r), + t: Math.round(margin.t), + b: Math.round(margin.b), + p: Math.round(margin.pad) + }; + gs.w = Math.round(fullLayout.width) - gs.l - gs.r; + gs.h = Math.round(fullLayout.height) - gs.t - gs.b; + } if(!fullLayout._pushmargin) fullLayout._pushmargin = {}; if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {}; } @@ -59372,8 +61071,6 @@ function setupAutoMargin(fullLayout) { plots.autoMargin = function(gd, id, o) { var fullLayout = gd._fullLayout; - setupAutoMargin(fullLayout); - var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -59417,18 +61114,19 @@ plots.autoMargin = function(gd, id, o) { plots.doAutoMargin = function(gd) { var fullLayout = gd._fullLayout; if(!fullLayout._size) fullLayout._size = {}; - setupAutoMargin(fullLayout); + initMargins(fullLayout); - var gs = fullLayout._size, - oldmargins = JSON.stringify(gs); + var gs = fullLayout._size; + var oldmargins = JSON.stringify(gs); + var margin = fullLayout.margin; // adjust margins for outside components // fullLayout.margin is the requested margin, // fullLayout._size has margins and plotsize after adjustment - var ml = Math.max(fullLayout.margin.l || 0, 0); - var mr = Math.max(fullLayout.margin.r || 0, 0); - var mt = Math.max(fullLayout.margin.t || 0, 0); - var mb = Math.max(fullLayout.margin.b || 0, 0); + var ml = margin.l; + var mr = margin.r; + var mt = margin.t; + var mb = margin.b; var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -59498,7 +61196,7 @@ plots.doAutoMargin = function(gd) { gs.r = Math.round(mr); gs.t = Math.round(mt); gs.b = Math.round(mb); - gs.p = Math.round(fullLayout.margin.pad); + gs.p = Math.round(margin.pad); gs.w = Math.round(fullLayout.width) - gs.l - gs.r; gs.h = Math.round(fullLayout.height) - gs.t - gs.b; @@ -60379,7 +62077,7 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl subplot.traceHash = traceHash; }; -},{"../components/color":51,"../constants/numerical":152,"../lib":170,"../plot_api/plot_schema":203,"../plot_api/plot_template":204,"../plots/cartesian/axis_ids":217,"../registry":259,"./animation_attributes":209,"./attributes":211,"./command":239,"./font_attributes":241,"./frame_attributes":242,"./layout_attributes":245,"d3":16,"fast-isnumeric":18}],248:[function(_dereq_,module,exports){ +},{"../components/color":51,"../constants/numerical":149,"../lib":168,"../plot_api/plot_schema":201,"../plot_api/plot_template":202,"../plots/cartesian/axis_ids":215,"../registry":257,"./animation_attributes":207,"./attributes":209,"./command":237,"./font_attributes":239,"./frame_attributes":240,"./layout_attributes":243,"d3":16,"fast-isnumeric":18}],246:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60423,7 +62121,7 @@ module.exports = { } }; -},{"../../../lib/extend":164,"../../../traces/scatter/attributes":368}],249:[function(_dereq_,module,exports){ +},{"../../../lib/extend":162,"../../../traces/scatter/attributes":367}],247:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60545,7 +62243,7 @@ module.exports = overrideAll({ } }, 'plot', 'nested'); -},{"../../../lib/extend":164,"../../../plot_api/edit_types":197,"../../cartesian/layout_attributes":227}],250:[function(_dereq_,module,exports){ +},{"../../../lib/extend":162,"../../../plot_api/edit_types":195,"../../cartesian/layout_attributes":225}],248:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60560,7 +62258,7 @@ var Polar = module.exports = _dereq_('./micropolar'); Polar.manager = _dereq_('./micropolar_manager'); -},{"./micropolar":251,"./micropolar_manager":252}],251:[function(_dereq_,module,exports){ +},{"./micropolar":249,"./micropolar_manager":250}],249:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60778,8 +62476,8 @@ var µ = module.exports = { version: '0.2.2' }; centeringOffset[0] = Math.max(0, centeringOffset[0]); centeringOffset[1] = Math.max(0, centeringOffset[1]); svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title); + if (axisConfig.title && axisConfig.title.text) { + var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); var titleBBox = title.node().getBBox(); title.attr({ x: chartCenter[0] - titleBBox.width / 2, @@ -61980,7 +63678,7 @@ var µ = module.exports = { version: '0.2.2' }; return exports; }; -},{"../../../constants/alignment":149,"../../../lib":170,"d3":16}],252:[function(_dereq_,module,exports){ +},{"../../../constants/alignment":146,"../../../lib":168,"d3":16}],250:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62066,7 +63764,7 @@ manager.fillLayout = function(_gd) { _gd._fullLayout = extendDeepAll(dflts, _gd.layout); }; -},{"../../../components/color":51,"../../../lib":170,"./micropolar":251,"./undo_manager":253,"d3":16}],253:[function(_dereq_,module,exports){ +},{"../../../components/color":51,"../../../lib":168,"./micropolar":249,"./undo_manager":251,"d3":16}],251:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62132,7 +63830,7 @@ module.exports = function UndoManager() { }; }; -},{}],254:[function(_dereq_,module,exports){ +},{}],252:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62202,6 +63900,12 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o subplotLayoutOut = Template.newContainer(layoutOut, id, baseId); + // All subplot containers get a `uirevision` inheriting from the base. + // Currently all subplots containers have some user interaction + // attributes, but if we ever add one that doesn't, we would need an + // option to skip this step. + coerce('uirevision', layoutOut.uirevision); + var dfltDomains = {}; dfltDomains[partition] = [i / idsLength, (i + 1) / idsLength]; handleDomainDefaults(subplotLayoutOut, layoutOut, coerce, dfltDomains); @@ -62211,7 +63915,7 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o } }; -},{"../lib":170,"../plot_api/plot_template":204,"./domain":240}],255:[function(_dereq_,module,exports){ +},{"../lib":168,"../plot_api/plot_template":202,"./domain":238}],253:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62295,7 +63999,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../lib":170,"../../plots/get_data":243,"./layout_attributes":256,"./layout_defaults":257,"./ternary":258}],256:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/get_data":241,"./layout_attributes":254,"./layout_defaults":255,"./ternary":256}],254:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62315,7 +64019,6 @@ var extendFlat = _dereq_('../../lib/extend').extendFlat; var ternaryAxesAttrs = { title: axesAttrs.title, - titlefont: axesAttrs.titlefont, color: axesAttrs.color, // ticks tickmode: axesAttrs.tickmode, @@ -62356,10 +64059,14 @@ var ternaryAxesAttrs = { min: 0, + }, + _deprecated: { + title: axesAttrs._deprecated.title, + titlefont: axesAttrs._deprecated.titlefont } }; -module.exports = overrideAll({ +var attrs = module.exports = overrideAll({ domain: domainAttrs({name: 'ternary'}), bgcolor: { @@ -62380,7 +64087,22 @@ module.exports = overrideAll({ caxis: ternaryAxesAttrs }, 'plot', 'from-root'); -},{"../../components/color/attributes":50,"../../lib/extend":164,"../../plot_api/edit_types":197,"../cartesian/layout_attributes":227,"../domain":240}],257:[function(_dereq_,module,exports){ +// set uirevisions outside of `overrideAll` so we can get `editType: none` +attrs.uirevision = { + valType: 'any', + + editType: 'none', + +}; + +attrs.aaxis.uirevision = attrs.baxis.uirevision = attrs.caxis.uirevision = { + valType: 'any', + + editType: 'none', + +}; + +},{"../../components/color/attributes":50,"../../lib/extend":162,"../../plot_api/edit_types":195,"../cartesian/layout_attributes":225,"../domain":238}],255:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62429,7 +64151,7 @@ function handleTernaryDefaults(ternaryLayoutIn, ternaryLayoutOut, coerce, option containerOut = Template.newContainer(ternaryLayoutOut, axName); containerOut._name = axName; - handleAxisDefaults(containerIn, containerOut, options); + handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut); } // if the min values contradict each other, set them all to default (0) @@ -62448,13 +64170,15 @@ function handleTernaryDefaults(ternaryLayoutIn, ternaryLayoutOut, coerce, option } } -function handleAxisDefaults(containerIn, containerOut, options) { +function handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut) { var axAttrs = layoutAttributes[containerOut._name]; function coerce(attr, dflt) { return Lib.coerce(containerIn, containerOut, axAttrs, attr, dflt); } + coerce('uirevision', ternaryLayoutOut.uirevision); + containerOut.type = 'linear'; // no other types allowed for ternary var dfltColor = coerce('color'); @@ -62466,10 +64190,10 @@ function handleAxisDefaults(containerIn, containerOut, options) { letterUpper = axName.charAt(0).toUpperCase(), dfltTitle = 'Component ' + letterUpper; - var title = coerce('title', dfltTitle); + var title = coerce('title.text', dfltTitle); containerOut._hovertitle = title === dfltTitle ? title : letterUpper; - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: options.font.family, size: Math.round(options.font.size * 1.2), color: dfltFontColor @@ -62510,7 +64234,7 @@ function handleAxisDefaults(containerIn, containerOut, options) { coerce('layer'); } -},{"../../components/color":51,"../../lib":170,"../../plot_api/plot_template":204,"../cartesian/line_grid_defaults":229,"../cartesian/tick_label_defaults":234,"../cartesian/tick_mark_defaults":235,"../cartesian/tick_value_defaults":236,"../subplot_defaults":254,"./layout_attributes":256}],258:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../lib":168,"../../plot_api/plot_template":202,"../cartesian/line_grid_defaults":227,"../cartesian/tick_label_defaults":232,"../cartesian/tick_mark_defaults":233,"../cartesian/tick_value_defaults":234,"../subplot_defaults":252,"./layout_attributes":254}],256:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62590,6 +64314,7 @@ proto.plot = function(ternaryCalcData, fullLayout) { proto.makeFramework = function(fullLayout) { var _this = this; + var gd = _this.graphDiv; var ternaryLayout = fullLayout[_this.id]; var clipId = _this.clipId = 'clip' + _this.layoutId + _this.id; @@ -62609,8 +64334,8 @@ proto.makeFramework = function(fullLayout) { _this.plotContainer = Lib.ensureSingle(_this.container, 'g', _this.id); _this.updateLayers(ternaryLayout); - Drawing.setClipUrl(_this.layers.backplot, clipId); - Drawing.setClipUrl(_this.layers.grids, clipId); + Drawing.setClipUrl(_this.layers.backplot, clipId, gd); + Drawing.setClipUrl(_this.layers.grids, clipId, gd); }; proto.updateLayers = function(ternaryLayout) { @@ -62671,9 +64396,6 @@ proto.updateLayers = function(ternaryLayout) { } else if(d === 'grids') { grids.forEach(function(d) { layers[d] = s.append('g').classed('grid ' + d, true); - - var fictID = (d === 'bgrid') ? 'x' : 'y'; - layers[d].append('g').classed(fictID, true); }); } }); @@ -62763,23 +64485,16 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { // fictitious angles and domain, but then rotate and translate // it into place at the end var aaxis = _this.aaxis = extendFlat({}, ternaryLayout.aaxis, { - visible: true, range: [amin, sum - bmin - cmin], side: 'left', - _counterangle: 30, // tickangle = 'auto' means 0 anyway for a y axis, need to coerce to 0 here // so we can shift by 30. tickangle: (+ternaryLayout.aaxis.tickangle || 0) - 30, domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h], - _axislayer: _this.layers.aaxis, - _gridlayer: _this.layers.agrid, anchor: 'free', position: 0, - _pos: 0, // _this.xaxis.domain[0] * graphSize.w, _id: 'y', - _length: w, - _gridpath: 'M0,0l' + h + ',-' + (w / 2), - automargin: false // don't use automargins routine for labels + _length: w }); setConvert(aaxis, _this.graphDiv._fullLayout); aaxis.setScale(); @@ -62787,45 +64502,28 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { // baxis goes across the bottom (backward). We can set it up as an x axis // without any enclosing transformation. var baxis = _this.baxis = extendFlat({}, ternaryLayout.baxis, { - visible: true, range: [sum - amin - cmin, bmin], side: 'bottom', - _counterangle: 30, domain: _this.xaxis.domain, - _axislayer: _this.layers.baxis, - _gridlayer: _this.layers.bgrid, - _counteraxis: _this.aaxis, anchor: 'free', position: 0, - _pos: 0, // (1 - yDomain0) * graphSize.h, _id: 'x', - _length: w, - _gridpath: 'M0,0l-' + (w / 2) + ',-' + h, - automargin: false // don't use automargins routine for labels + _length: w }); setConvert(baxis, _this.graphDiv._fullLayout); baxis.setScale(); - aaxis._counteraxis = baxis; // caxis goes down the right side. Set it up as a y axis, with // post-transformation similar to aaxis var caxis = _this.caxis = extendFlat({}, ternaryLayout.caxis, { - visible: true, range: [sum - amin - bmin, cmin], side: 'right', - _counterangle: 30, tickangle: (+ternaryLayout.caxis.tickangle || 0) + 30, domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h], - _axislayer: _this.layers.caxis, - _gridlayer: _this.layers.cgrid, - _counteraxis: _this.baxis, anchor: 'free', position: 0, - _pos: 0, // _this.xaxis.domain[1] * graphSize.w, _id: 'y', - _length: w, - _gridpath: 'M0,0l-' + h + ',' + (w / 2), - automargin: false // don't use automargins routine for labels + _length: w }); setConvert(caxis, _this.graphDiv._fullLayout); caxis.setScale(); @@ -62863,10 +64561,6 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { _this.drawAxes(true); - // remove crispEdges - all the off-square angles in ternary plots - // make these counterproductive. - _this.plotContainer.selectAll('.crisp').classed('crisp', false); - _this.layers.aline.select('path') .attr('d', aaxis.showline ? 'M' + x0 + ',' + (y0 + h) + 'l' + (w / 2) + ',-' + h : 'M0,0') @@ -62889,7 +64583,8 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { Drawing.setClipUrl( _this.layers.frontplot, - _this._hasClipOnAxisFalse ? null : _this.clipId + _this._hasClipOnAxisFalse ? null : _this.clipId, + _this.graphDiv ); }; @@ -62901,80 +64596,122 @@ proto.drawAxes = function(doTitles) { var aaxis = _this.aaxis; var baxis = _this.baxis; var caxis = _this.caxis; - var newTickLayout; - - newTickLayout = strTickLayout(aaxis); - if(_this.aTickLayout !== newTickLayout) { - layers.aaxis.selectAll('.ytick').remove(); - _this.aTickLayout = newTickLayout; - } - newTickLayout = strTickLayout(baxis); - if(_this.bTickLayout !== newTickLayout) { - layers.baxis.selectAll('.xtick').remove(); - _this.bTickLayout = newTickLayout; - } - - newTickLayout = strTickLayout(caxis); - if(_this.cTickLayout !== newTickLayout) { - layers.caxis.selectAll('.ytick').remove(); - _this.cTickLayout = newTickLayout; - } - - // 3rd arg true below skips titles, so we can configure them - // correctly later on. - Axes.doTicksSingle(gd, aaxis, true); - Axes.doTicksSingle(gd, baxis, true); - Axes.doTicksSingle(gd, caxis, true); + _this.drawAx(aaxis); + _this.drawAx(baxis); + _this.drawAx(caxis); if(doTitles) { var apad = Math.max(aaxis.showticklabels ? aaxis.tickfont.size / 2 : 0, (caxis.showticklabels ? caxis.tickfont.size * 0.75 : 0) + (caxis.ticks === 'outside' ? caxis.ticklen * 0.87 : 0)); - _this.layers['a-title'] = Titles.draw(gd, 'a' + titlesuffix, { + var bpad = (baxis.showticklabels ? baxis.tickfont.size : 0) + + (baxis.ticks === 'outside' ? baxis.ticklen : 0) + 3; + + layers['a-title'] = Titles.draw(gd, 'a' + titlesuffix, { propContainer: aaxis, propName: _this.id + '.aaxis.title', placeholder: _(gd, 'Click to enter Component A title'), attributes: { x: _this.x0 + _this.w / 2, - y: _this.y0 - aaxis.titlefont.size / 3 - apad, + y: _this.y0 - aaxis.title.font.size / 3 - apad, 'text-anchor': 'middle' } }); - - - var bpad = (baxis.showticklabels ? baxis.tickfont.size : 0) + - (baxis.ticks === 'outside' ? baxis.ticklen : 0) + 3; - - _this.layers['b-title'] = Titles.draw(gd, 'b' + titlesuffix, { + layers['b-title'] = Titles.draw(gd, 'b' + titlesuffix, { propContainer: baxis, propName: _this.id + '.baxis.title', placeholder: _(gd, 'Click to enter Component B title'), attributes: { x: _this.x0 - bpad, - y: _this.y0 + _this.h + baxis.titlefont.size * 0.83 + bpad, + y: _this.y0 + _this.h + baxis.title.font.size * 0.83 + bpad, 'text-anchor': 'middle' } }); - - _this.layers['c-title'] = Titles.draw(gd, 'c' + titlesuffix, { + layers['c-title'] = Titles.draw(gd, 'c' + titlesuffix, { propContainer: caxis, propName: _this.id + '.caxis.title', placeholder: _(gd, 'Click to enter Component C title'), attributes: { x: _this.x0 + _this.w + bpad, - y: _this.y0 + _this.h + caxis.titlefont.size * 0.83 + bpad, + y: _this.y0 + _this.h + caxis.title.font.size * 0.83 + bpad, 'text-anchor': 'middle' } }); } }; +proto.drawAx = function(ax) { + var _this = this; + var gd = _this.graphDiv; + var axName = ax._name; + var axLetter = axName.charAt(0); + var axId = ax._id; + var axLayer = _this.layers[axName]; + var counterAngle = 30; + + var stashKey = axLetter + 'tickLayout'; + var newTickLayout = strTickLayout(ax); + if(_this[stashKey] !== newTickLayout) { + axLayer.selectAll('.' + axId + 'tick').remove(); + _this[stashKey] = newTickLayout; + } + + ax.setScale(); + + var vals = Axes.calcTicks(ax); + var valsClipped = Axes.clipEnds(ax, vals); + var transFn = Axes.makeTransFn(ax); + var tickSign = Axes.getTickSigns(ax)[2]; + + var caRad = Lib.deg2rad(counterAngle); + var pad = tickSign * (ax.linewidth || 1) / 2; + var len = tickSign * ax.ticklen; + var w = _this.w; + var h = _this.h; + + var tickPath = axLetter === 'b' ? + 'M0,' + pad + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len) : + 'M' + pad + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); + + var gridPath = { + a: 'M0,0l' + h + ',-' + (w / 2), + b: 'M0,0l-' + (w / 2) + ',-' + h, + c: 'M0,0l-' + h + ',' + (w / 2) + }[axLetter]; + + Axes.drawTicks(gd, ax, { + vals: ax.ticks === 'inside' ? valsClipped : vals, + layer: axLayer, + path: tickPath, + transFn: transFn, + crisp: false + }); + + Axes.drawGrid(gd, ax, { + vals: valsClipped, + layer: _this.layers[axLetter + 'grid'], + path: gridPath, + transFn: transFn, + crisp: false + }); + + var labelFns = Axes.makeLabelFns(ax, 0, counterAngle); + + Axes.drawLabels(gd, ax, { + vals: vals, + layer: axLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); +}; + function strTickLayout(axLayout) { return axLayout.ticks + String(axLayout.ticklen) + String(axLayout.showticklabels); } - // hard coded paths for zoom corners // uses the same sizing as cartesian, length is MINZOOM/2, width is 3px var CLEN = constants.MINZOOM / 2 + 0.87; @@ -63040,18 +64777,22 @@ proto.initInteractions = function() { var x0, y0, mins0, span0, mins, lum, path0, dimmed, zb, corners; + function makeUpdate(_mins) { + var attrs = {}; + attrs[_this.id + '.aaxis.min'] = _mins.a; + attrs[_this.id + '.baxis.min'] = _mins.b; + attrs[_this.id + '.caxis.min'] = _mins.c; + return attrs; + } + function clickZoomPan(numClicks, evt) { var clickMode = gd._fullLayout.clickmode; removeZoombox(gd); if(numClicks === 2) { - var attrs = {}; - attrs[_this.id + '.aaxis.min'] = 0; - attrs[_this.id + '.baxis.min'] = 0; - attrs[_this.id + '.caxis.min'] = 0; gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, makeUpdate({a: 0, b: 0, c: 0})); } if(clickMode.indexOf('select') > -1 && numClicks === 1) { @@ -63155,12 +64896,7 @@ proto.initInteractions = function() { if(mins === mins0) return; - var attrs = {}; - attrs[_this.id + '.aaxis.min'] = mins.a; - attrs[_this.id + '.baxis.min'] = mins.b; - attrs[_this.id + '.caxis.min'] = mins.c; - - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, makeUpdate(mins)); if(SHOWZOOMOUTTIP && gd.data && gd._context.showTips) { Lib.notifier(_(gd, 'Double-click to zoom back out'), 'long'); @@ -63224,7 +64960,6 @@ proto.initInteractions = function() { _this.caxis.range = [_this.sum - mins.a - mins.b, mins.c]; _this.drawAxes(false); - _this.plotContainer.selectAll('.crisp').classed('crisp', false); if(_this._hasClipOnAxisFalse) { _this.plotContainer @@ -63234,12 +64969,7 @@ proto.initInteractions = function() { } function dragDone() { - var attrs = {}; - attrs[_this.id + '.aaxis.min'] = mins.a; - attrs[_this.id + '.baxis.min'] = mins.b; - attrs[_this.id + '.caxis.min'] = mins.c; - - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, makeUpdate(mins)); } // finally, set up hover and click @@ -63266,7 +64996,7 @@ function removeZoombox(gd) { .remove(); } -},{"../../components/color":51,"../../components/dragelement":73,"../../components/drawing":76,"../../components/fx":93,"../../components/titles":142,"../../lib":170,"../../lib/extend":164,"../../registry":259,"../cartesian/axes":214,"../cartesian/constants":220,"../cartesian/select":232,"../cartesian/set_convert":233,"../plots":247,"d3":16,"tinycolor2":34}],259:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/dragelement":69,"../../components/drawing":72,"../../components/fx":90,"../../components/titles":139,"../../lib":168,"../../lib/extend":162,"../../registry":257,"../cartesian/axes":212,"../cartesian/constants":218,"../cartesian/select":230,"../cartesian/set_convert":231,"../plots":245,"d3":16,"tinycolor2":34}],257:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63708,7 +65438,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/extend":164,"./lib/is_plain_object":171,"./lib/loggers":174,"./lib/noop":179,"./lib/push_unique":183,"./plots/attributes":211,"./plots/layout_attributes":245}],260:[function(_dereq_,module,exports){ +},{"./lib/extend":162,"./lib/is_plain_object":169,"./lib/loggers":172,"./lib/noop":177,"./lib/push_unique":181,"./plots/attributes":209,"./plots/layout_attributes":243}],258:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63735,7 +65465,7 @@ function cloneLayoutOverride(tileClass) { autosize: true, width: 150, height: 150, - title: '', + title: {text: ''}, showlegend: false, margin: {l: 5, r: 5, t: 5, b: 5, pad: 0}, annotations: [] @@ -63744,7 +65474,7 @@ function cloneLayoutOverride(tileClass) { case 'thumbnail': override = { - title: '', + title: {text: ''}, hidesources: true, showlegend: false, borderwidth: 0, @@ -63792,7 +65522,7 @@ module.exports = function clonePlot(graphObj, options) { for(i = 0; i < keys.length; i++) { if(keyIsAxis(keys[i])) { - newLayout[keys[i]].title = ''; + newLayout[keys[i]].title = {text: ''}; } } @@ -63820,7 +65550,7 @@ module.exports = function clonePlot(graphObj, options) { var axesImageOverride = {}; if(options.tileClass === 'thumbnail') { axesImageOverride = { - title: '', + title: {text: ''}, showaxeslabels: false, showticklabels: false, linetickenable: false @@ -63882,7 +65612,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":170}],261:[function(_dereq_,module,exports){ +},{"../lib":168}],259:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63950,7 +65680,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":170,"../plot_api/to_image":207,"./filesaver":262}],262:[function(_dereq_,module,exports){ +},{"../lib":168,"../plot_api/to_image":205,"./filesaver":260}],260:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64022,7 +65752,7 @@ var fileSaver = function(url, name) { module.exports = fileSaver; -},{}],263:[function(_dereq_,module,exports){ +},{}],261:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64059,7 +65789,7 @@ exports.getRedrawFunc = function(gd) { }; }; -},{}],264:[function(_dereq_,module,exports){ +},{}],262:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64085,7 +65815,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":260,"./download":261,"./helpers":263,"./svgtoimg":265,"./toimage":266,"./tosvg":267}],265:[function(_dereq_,module,exports){ +},{"./cloneplot":258,"./download":259,"./helpers":261,"./svgtoimg":263,"./toimage":264,"./tosvg":265}],263:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64201,7 +65931,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":170,"events":15}],266:[function(_dereq_,module,exports){ +},{"../lib":168,"events":15}],264:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64280,7 +66010,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":170,"../registry":259,"./cloneplot":260,"./helpers":263,"./svgtoimg":265,"./tosvg":267,"events":15}],267:[function(_dereq_,module,exports){ +},{"../lib":168,"../registry":257,"./cloneplot":258,"./helpers":261,"./svgtoimg":263,"./tosvg":265,"events":15}],265:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64462,7 +66192,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":51,"../components/drawing":76,"../constants/xmlns_namespaces":153,"../lib":170,"d3":16}],268:[function(_dereq_,module,exports){ +},{"../components/color":51,"../components/drawing":72,"../constants/xmlns_namespaces":150,"../lib":168,"d3":16}],266:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64497,7 +66227,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":170}],269:[function(_dereq_,module,exports){ +},{"../../lib":168}],267:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64509,9 +66239,11 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); +var constants = _dereq_('./constants.js'); var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -64560,6 +66292,9 @@ module.exports = { text: scatterAttrs.text, hovertext: scatterAttrs.hovertext, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), textposition: { valType: 'enumerated', @@ -64667,7 +66402,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../lib/extend":164,"../../plots/font_attributes":241,"../scatter/attributes":368}],270:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../components/fx/hovertemplate_attributes":89,"../../lib/extend":162,"../../plots/font_attributes":239,"../scatter/attributes":367,"./constants.js":269}],268:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64679,7 +66414,7 @@ module.exports = { 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var arraysToCalcdata = _dereq_('./arrays_to_calcdata'); var calcSelection = _dereq_('../scatter/calc_selection'); @@ -64712,10 +66447,18 @@ module.exports = function calc(gd, trace) { // auto-z and autocolorscale if applicable if(hasColorscale(trace, 'marker')) { - colorscaleCalc(trace, trace.marker.color, 'marker', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - colorscaleCalc(trace, trace.marker.line.color, 'marker.line', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } arraysToCalcdata(cd, trace); @@ -64724,7 +66467,23 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../../components/colorscale/calc":59,"../../components/colorscale/has_colorscale":65,"../../plots/cartesian/axes":214,"../scatter/calc_selection":370,"./arrays_to_calcdata":268}],271:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":59,"../../components/colorscale/helpers":62,"../../plots/cartesian/axes":212,"../scatter/calc_selection":369,"./arrays_to_calcdata":266}],269:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + eventDataKeys: [] +}; + +},{}],270:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64853,9 +66612,14 @@ function initBase(gd, pa, sa, calcTraces) { // time. But included here for completeness. var scalendar = trace.orientation === 'h' ? trace.xcalendar : trace.ycalendar; + // 'base' on categorical axes makes no sense + var d2c = sa.type === 'category' || sa.type === 'multicategory' ? + function() { return null; } : + sa.d2c; + if(isArrayOrTypedArray(base)) { for(j = 0; j < Math.min(base.length, cd.length); j++) { - b = sa.d2c(base[j], 0, scalendar); + b = d2c(base[j], 0, scalendar); if(isNumeric(b)) { cd[j].b = +b; cd[j].hasB = 1; @@ -64866,7 +66630,7 @@ function initBase(gd, pa, sa, calcTraces) { cd[j].b = 0; } } else { - b = sa.d2c(base, 0, scalendar); + b = d2c(base, 0, scalendar); var hasBase = isNumeric(b); b = hasBase ? b : 0; for(j = 0; j < cd.length; j++) { @@ -65445,7 +67209,7 @@ module.exports = { setGroupPositions: setGroupPositions }; -},{"../../constants/numerical":152,"../../lib":170,"../../plots/cartesian/axes":214,"../../registry":259,"./sieve.js":280,"fast-isnumeric":18}],272:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168,"../../plots/cartesian/axes":212,"../../registry":257,"./sieve.js":279,"fast-isnumeric":18}],271:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65485,6 +67249,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); + coerce('hovertemplate'); var textPosition = coerce('textposition'); @@ -65525,7 +67290,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/color":51,"../../lib":170,"../../registry":259,"../bar/style_defaults":282,"../scatter/xy_defaults":394,"./attributes":269}],273:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../lib":168,"../../registry":257,"../bar/style_defaults":281,"../scatter/xy_defaults":393,"./attributes":267}],272:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65594,7 +67359,7 @@ exports.getValue = function(arrayOrScalar, index) { return value; }; -},{"fast-isnumeric":18,"tinycolor2":34}],274:[function(_dereq_,module,exports){ +},{"fast-isnumeric":18,"tinycolor2":34}],273:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65734,6 +67499,7 @@ function hoverPoints(pointData, xval, yval, hovermode) { fillHoverText(di, trace, pointData); Registry.getComponentMethod('errorbars', 'hoverInfo')(di, trace, pointData); + pointData.hovertemplate = trace.hovertemplate; return [pointData]; } @@ -65751,7 +67517,7 @@ module.exports = { getTraceColor: getTraceColor }; -},{"../../components/color":51,"../../components/fx":93,"../../registry":259,"../scatter/fill_hover_text":376}],275:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/fx":90,"../../registry":257,"../scatter/fill_hover_text":375}],274:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65789,7 +67555,7 @@ Bar.meta = { module.exports = Bar; -},{"../../plots/cartesian":226,"../scatter/marker_colorbar":386,"./arrays_to_calcdata":268,"./attributes":269,"./calc":270,"./cross_trace_calc":271,"./defaults":272,"./hover":274,"./layout_attributes":276,"./layout_defaults":277,"./plot":278,"./select":279,"./style":281}],276:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":224,"../scatter/marker_colorbar":385,"./arrays_to_calcdata":266,"./attributes":267,"./calc":268,"./cross_trace_calc":270,"./defaults":271,"./hover":273,"./layout_attributes":275,"./layout_defaults":276,"./plot":277,"./select":278,"./style":280}],275:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65837,7 +67603,7 @@ module.exports = { } }; -},{}],277:[function(_dereq_,module,exports){ +},{}],276:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65895,7 +67661,7 @@ module.exports = function(layoutIn, layoutOut, fullData) { coerce('bargroupgap'); }; -},{"../../lib":170,"../../plots/cartesian/axes":214,"../../registry":259,"./layout_attributes":276}],278:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212,"../../registry":257,"./layout_attributes":275}],277:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66022,7 +67788,7 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { .style('vector-effect', 'non-scaling-stroke') .attr('d', 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z') - .call(Drawing.setClipUrl, plotinfo.layerClipId); + .call(Drawing.setClipUrl, plotinfo.layerClipId, gd); appendBarText(gd, bar, cd, i, x0, x1, y0, y1); @@ -66034,11 +67800,11 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { // lastly, clip points groups of `cliponaxis !== false` traces // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = cd0.trace.cliponaxis === false; - Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId); + Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId, gd); }); // error bars are on the top - Registry.getComponentMethod('errorbars', 'plot')(bartraces, plotinfo); + Registry.getComponentMethod('errorbars', 'plot')(gd, bartraces, plotinfo); }; function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) { @@ -66335,7 +68101,7 @@ function getTextPosition(trace, index) { return helpers.coerceEnumerated(attributeTextPosition, value); } -},{"../../components/color":51,"../../components/drawing":76,"../../lib":170,"../../lib/svg_text_utils":191,"../../registry":259,"./attributes":269,"./helpers":273,"./style":281,"d3":16,"fast-isnumeric":18}],279:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/drawing":72,"../../lib":168,"../../lib/svg_text_utils":189,"../../registry":257,"./attributes":267,"./helpers":272,"./style":280,"d3":16,"fast-isnumeric":18}],278:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66378,7 +68144,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],280:[function(_dereq_,module,exports){ +},{}],279:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66487,7 +68253,7 @@ Sieve.prototype.getLabel = function getLabel(position, value) { return prefix + label; }; -},{"../../constants/numerical":152,"../../lib":170}],281:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168}],280:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66661,7 +68427,7 @@ module.exports = { getBarColor: getBarColor }; -},{"../../components/color":51,"../../components/drawing":76,"../../lib":170,"../../registry":259,"./attributes":269,"./helpers":273,"d3":16}],282:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/drawing":72,"../../lib":168,"../../registry":257,"./attributes":267,"./helpers":272,"d3":16}],281:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66670,11 +68436,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout) { @@ -66700,7 +68465,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, default coerce('unselected.marker.color'); }; -},{"../../components/color":51,"../../components/colorscale/defaults":61,"../../components/colorscale/has_colorscale":65}],283:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/colorscale/defaults":61,"../../components/colorscale/helpers":62}],282:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66892,7 +68657,7 @@ module.exports = { } }; -},{"../../components/color/attributes":50,"../../lib/extend":164,"../scatter/attributes":368}],284:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":50,"../../lib/extend":162,"../scatter/attributes":367}],283:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67073,7 +68838,10 @@ function getPos(trace, posLetter, posAxis, val, num) { pos0 = num; } - var pos0c = posAxis.d2c(pos0, 0, trace[posLetter + 'calendar']); + var pos0c = posAxis.type === 'multicategory' ? + posAxis.r2c_just_indices(pos0) : + posAxis.d2c(pos0, 0, trace[posLetter + 'calendar']); + return val.map(function() { return pos0c; }); } @@ -67128,7 +68896,7 @@ function sortByVal(a, b) { return a.v - b.v; } function extractVal(o) { return o.v; } -},{"../../lib":170,"../../plots/cartesian/axes":214,"fast-isnumeric":18}],285:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212,"fast-isnumeric":18}],284:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67244,7 +69012,7 @@ module.exports = { setPositionOffset: setPositionOffset }; -},{"../../lib":170,"../../plots/cartesian/axes":214}],286:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212}],285:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67292,16 +69060,15 @@ function handleSampleDefaults(traceIn, traceOut, coerce, layout) { if(y && y.length) { defaultOrientation = 'v'; if(hasX) { - len = Math.min(x.length, y.length); - } - else { + len = Math.min(Lib.minRowLength(x), Lib.minRowLength(y)); + } else { coerce('x0'); - len = y.length; + len = Lib.minRowLength(y); } } else if(hasX) { defaultOrientation = 'h'; coerce('y0'); - len = x.length; + len = Lib.minRowLength(x); } else { traceOut.visible = false; return; @@ -67362,7 +69129,7 @@ module.exports = { handlePointsDefaults: handlePointsDefaults }; -},{"../../components/color":51,"../../lib":170,"../../registry":259,"./attributes":283}],287:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../lib":168,"../../registry":257,"./attributes":282}],286:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67388,7 +69155,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],288:[function(_dereq_,module,exports){ +},{}],287:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67651,7 +69418,7 @@ module.exports = { hoverOnPoints: hoverOnPoints }; -},{"../../components/color":51,"../../components/fx":93,"../../lib":170,"../../plots/cartesian/axes":214,"../scatter/fill_hover_text":376}],289:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/fx":90,"../../lib":168,"../../plots/cartesian/axes":212,"../scatter/fill_hover_text":375}],288:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67687,7 +69454,7 @@ Box.meta = { module.exports = Box; -},{"../../plots/cartesian":226,"./attributes":283,"./calc":284,"./cross_trace_calc":285,"./defaults":286,"./event_data":287,"./hover":288,"./layout_attributes":290,"./layout_defaults":291,"./plot":292,"./select":293,"./style":294}],290:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":224,"./attributes":282,"./calc":283,"./cross_trace_calc":284,"./defaults":285,"./event_data":286,"./hover":287,"./layout_attributes":289,"./layout_defaults":290,"./plot":291,"./select":292,"./style":293}],289:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67728,7 +69495,7 @@ module.exports = { } }; -},{}],291:[function(_dereq_,module,exports){ +},{}],290:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67771,7 +69538,7 @@ module.exports = { _supply: _supply }; -},{"../../lib":170,"../../registry":259,"./layout_attributes":290}],292:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257,"./layout_attributes":289}],291:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68111,7 +69878,7 @@ module.exports = { plotBoxMean: plotBoxMean }; -},{"../../components/drawing":76,"../../lib":170,"d3":16}],293:[function(_dereq_,module,exports){ +},{"../../components/drawing":72,"../../lib":168,"d3":16}],292:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68160,7 +69927,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],294:[function(_dereq_,module,exports){ +},{}],293:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68234,7 +70001,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/color":51,"../../components/drawing":76,"d3":16}],295:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/drawing":72,"d3":16}],294:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68413,7 +70180,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../components/drawing/attributes":75,"../../constants/filter_ops":150,"../../lib/extend":164,"../../plots/font_attributes":241,"../heatmap/attributes":317,"../scatter/attributes":368}],296:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../components/drawing/attributes":71,"../../constants/filter_ops":147,"../../lib/extend":162,"../../plots/font_attributes":239,"../heatmap/attributes":316,"../scatter/attributes":367}],295:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68437,7 +70204,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../heatmap/calc":318,"./set_contours":314}],297:[function(_dereq_,module,exports){ +},{"../heatmap/calc":317,"./set_contours":313}],296:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68504,7 +70271,7 @@ module.exports = function(pathinfo, operation, perimeter, trace) { } }; -},{}],298:[function(_dereq_,module,exports){ +},{}],297:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68555,7 +70322,7 @@ module.exports = function colorbar(gd, cd) { .options(trace.colorbar)(); }; -},{"../../components/colorbar/draw":56,"./end_plus":306,"./make_color_map":311}],299:[function(_dereq_,module,exports){ +},{"../../components/colorbar/draw":56,"./end_plus":305,"./make_color_map":310}],298:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68633,7 +70400,7 @@ module.exports = { } }; -},{}],300:[function(_dereq_,module,exports){ +},{}],299:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68728,7 +70495,7 @@ function handleConstraintValueDefaults(coerce, contours) { } } -},{"../../components/color":51,"../../constants/filter_ops":150,"./label_defaults":310,"fast-isnumeric":18}],301:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../constants/filter_ops":147,"./label_defaults":309,"fast-isnumeric":18}],300:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68807,7 +70574,7 @@ function makeInequalitySettings(operation) { }; } -},{"../../constants/filter_ops":150,"fast-isnumeric":18}],302:[function(_dereq_,module,exports){ +},{"../../constants/filter_ops":147,"fast-isnumeric":18}],301:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68836,7 +70603,7 @@ module.exports = function handleContourDefaults(traceIn, traceOut, coerce, coerc if(autoContour || !contourSize) coerce('ncontours'); }; -},{}],303:[function(_dereq_,module,exports){ +},{}],302:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68924,7 +70691,7 @@ function copyPathinfo(pi) { }); } -},{"../../lib":170}],304:[function(_dereq_,module,exports){ +},{"../../lib":168}],303:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68973,7 +70740,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../lib":170,"../heatmap/xyz_defaults":332,"./attributes":295,"./constraint_defaults":300,"./contours_defaults":302,"./style_defaults":316}],305:[function(_dereq_,module,exports){ +},{"../../lib":168,"../heatmap/xyz_defaults":330,"./attributes":294,"./constraint_defaults":299,"./contours_defaults":301,"./style_defaults":315}],304:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69037,7 +70804,7 @@ module.exports = function emptyPathinfo(contours, plotinfo, cd0) { return pathinfo; }; -},{"../../lib":170,"./constraint_mapping":301,"./end_plus":306}],306:[function(_dereq_,module,exports){ +},{"../../lib":168,"./constraint_mapping":300,"./end_plus":305}],305:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69057,7 +70824,7 @@ module.exports = function endPlus(contours) { return contours.end + contours.size / 1e6; }; -},{}],307:[function(_dereq_,module,exports){ +},{}],306:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69357,7 +71124,7 @@ function getInterpPx(pi, loc, step) { } } -},{"../../lib":170,"./constants":299}],308:[function(_dereq_,module,exports){ +},{"../../lib":168,"./constants":298}],307:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69393,7 +71160,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return hoverData; }; -},{"../../components/color":51,"../heatmap/hover":324}],309:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../heatmap/hover":323}],308:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69425,7 +71192,7 @@ Contour.meta = { module.exports = Contour; -},{"../../plots/cartesian":226,"./attributes":295,"./calc":296,"./colorbar":298,"./defaults":304,"./hover":308,"./plot":313,"./style":315}],310:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":224,"./attributes":294,"./calc":295,"./colorbar":297,"./defaults":303,"./hover":307,"./plot":312,"./style":314}],309:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69455,7 +71222,7 @@ module.exports = function handleLabelDefaults(coerce, layout, lineColor, opts) { if(opts.hasHover !== false) coerce('zhoverformat'); }; -},{"../../lib":170}],311:[function(_dereq_,module,exports){ +},{"../../lib":168}],310:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69484,11 +71251,13 @@ module.exports = function makeColorMap(trace) { nc = 1; } - var scl = trace.colorscale, - len = scl.length; + var scl = trace.reversescale ? + Colorscale.flipScale(trace.colorscale) : + trace.colorscale; - var domain = new Array(len), - range = new Array(len); + var len = scl.length; + var domain = new Array(len); + var range = new Array(len); var si, i; @@ -69539,7 +71308,7 @@ module.exports = function makeColorMap(trace) { }); }; -},{"../../components/colorscale":66,"./end_plus":306,"d3":16}],312:[function(_dereq_,module,exports){ +},{"../../components/colorscale":63,"./end_plus":305,"d3":16}],311:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69631,7 +71400,7 @@ function getMarchingIndex(val, corners) { return (mi === 15) ? 0 : mi; } -},{"./constants":299}],313:[function(_dereq_,module,exports){ +},{"./constants":298}],312:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69663,7 +71432,6 @@ var costConstants = constants.LABELOPTIMIZER; exports.plot = function plot(gd, plotinfo, cdcontours, contourLayer) { var xa = plotinfo.xaxis; var ya = plotinfo.yaxis; - var fullLayout = gd._fullLayout; Lib.makeTraceGroups(contourLayer, cdcontours, 'contour').each(function(cd) { var plotGroup = d3.select(this); @@ -69712,7 +71480,7 @@ exports.plot = function plot(gd, plotinfo, cdcontours, contourLayer) { makeBackground(plotGroup, perimeter, contours); makeFills(plotGroup, fillPathinfo, perimeter, contours); makeLinesAndLabels(plotGroup, pathinfo, gd, cd0, contours, perimeter); - clipGaps(plotGroup, plotinfo, fullLayout._clips, cd0, perimeter); + clipGaps(plotGroup, plotinfo, gd, cd0, perimeter); }); }; @@ -69864,8 +71632,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) { // In this case we'll remove the lines after making the labels. var linegroup = exports.createLines(lineContainer, showLines || showLabels, pathinfo); - var lineClip = exports.createLineClip(lineContainer, clipLinesForLabels, - gd._fullLayout._clips, cd0.trace.uid); + var lineClip = exports.createLineClip(lineContainer, clipLinesForLabels, gd, cd0.trace.uid); var labelGroup = plotgroup.selectAll('g.contourlabels') .data(showLabels ? [0] : []); @@ -69889,17 +71656,37 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) { .attr('data-notex', 1) .call(Drawing.font, contours.labelfont); - var xLen = pathinfo[0].xaxis._length; - var yLen = pathinfo[0].yaxis._length; + var xa = pathinfo[0].xaxis; + var ya = pathinfo[0].yaxis; + var xLen = xa._length; + var yLen = ya._length; + var xRng = xa.range; + var yRng = ya.range; + var x0 = Math.max(perimeter[0][0], 0); + var x1 = Math.min(perimeter[2][0], xLen); + var y0 = Math.max(perimeter[0][1], 0); + var y1 = Math.min(perimeter[2][1], yLen); // visible bounds of the contour trace (and the midpoints, to // help with cost calculations) - var bounds = { - left: Math.max(perimeter[0][0], 0), - right: Math.min(perimeter[2][0], xLen), - top: Math.max(perimeter[0][1], 0), - bottom: Math.min(perimeter[2][1], yLen) - }; + var bounds = {}; + + if(xRng[0] < xRng[1]) { + bounds.left = x0; + bounds.right = x1; + } else { + bounds.left = x1; + bounds.right = x0; + } + + if(yRng[0] < yRng[1]) { + bounds.top = y0; + bounds.bottom = y1; + } else { + bounds.top = y1; + bounds.bottom = y0; + } + bounds.middle = (bounds.top + bounds.bottom) / 2; bounds.center = (bounds.left + bounds.right) / 2; @@ -69987,7 +71774,8 @@ exports.createLines = function(lineContainer, makeLines, pathinfo) { return linegroup; }; -exports.createLineClip = function(lineContainer, clipLinesForLabels, clips, uid) { +exports.createLineClip = function(lineContainer, clipLinesForLabels, gd, uid) { + var clips = gd._fullLayout._clips; var clipId = clipLinesForLabels ? ('clipline' + uid) : null; var lineClip = clips.selectAll('#' + clipId) @@ -69998,7 +71786,7 @@ exports.createLineClip = function(lineContainer, clipLinesForLabels, clips, uid) .classed('contourlineclip', true) .attr('id', clipId); - Drawing.setClipUrl(lineContainer, clipId); + Drawing.setClipUrl(lineContainer, clipId, gd); return lineClip; }; @@ -70229,7 +72017,8 @@ exports.drawLabels = function(labelGroup, labelData, gd, lineClip, labelClipPath } }; -function clipGaps(plotGroup, plotinfo, clips, cd0, perimeter) { +function clipGaps(plotGroup, plotinfo, gd, cd0, perimeter) { + var clips = gd._fullLayout._clips; var clipId = 'clip' + cd0.trace.uid; var clipPath = clips.selectAll('#' + clipId) @@ -70268,7 +72057,7 @@ function clipGaps(plotGroup, plotinfo, clips, cd0, perimeter) { } else clipId = null; - plotGroup.call(Drawing.setClipUrl, clipId); + Drawing.setClipUrl(plotGroup, clipId, gd); } function makeClipMask(cd0) { @@ -70291,7 +72080,7 @@ function makeClipMask(cd0) { return z; } -},{"../../components/drawing":76,"../../lib":170,"../../lib/svg_text_utils":191,"../../plots/cartesian/axes":214,"../../plots/cartesian/set_convert":233,"../heatmap/plot":329,"./close_boundaries":297,"./constants":299,"./convert_to_constraints":303,"./empty_pathinfo":305,"./find_all_paths":307,"./make_crossings":312,"d3":16}],314:[function(_dereq_,module,exports){ +},{"../../components/drawing":72,"../../lib":168,"../../lib/svg_text_utils":189,"../../plots/cartesian/axes":212,"../../plots/cartesian/set_convert":231,"../heatmap/plot":327,"./close_boundaries":296,"./constants":298,"./convert_to_constraints":302,"./empty_pathinfo":304,"./find_all_paths":306,"./make_crossings":311,"d3":16}],313:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70395,7 +72184,7 @@ function autoContours(start, end, ncontours) { return dummyAx; } -},{"../../lib":170,"../../plots/cartesian/axes":214}],315:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212}],314:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70477,7 +72266,7 @@ module.exports = function style(gd) { heatmapStyle(gd); }; -},{"../../components/drawing":76,"../heatmap/style":330,"./make_color_map":311,"d3":16}],316:[function(_dereq_,module,exports){ +},{"../../components/drawing":72,"../heatmap/style":328,"./make_color_map":310,"d3":16}],315:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70522,7 +72311,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, layout, handleLabelDefaults(coerce, layout, lineColor, opts); }; -},{"../../components/colorscale/defaults":61,"./label_defaults":310}],317:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":61,"./label_defaults":309}],316:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70625,7 +72414,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../lib/extend":164,"../scatter/attributes":368}],318:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../lib/extend":162,"../scatter/attributes":367}],317:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70644,7 +72433,6 @@ var Axes = _dereq_('../../plots/cartesian/axes'); var histogram2dCalc = _dereq_('../histogram2d/calc'); var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var convertColumnData = _dereq_('./convert_column_xyz'); -var maxRowLength = _dereq_('./max_row_length'); var clean2dArray = _dereq_('./clean_2d_array'); var interp2d = _dereq_('./interp2d'); var findEmpties = _dereq_('./find_empties'); @@ -70744,7 +72532,7 @@ module.exports = function calc(gd, trace) { } // create arrays of brick boundaries, to be used by autorange and heatmap.plot - var xlen = maxRowLength(z); + var xlen = Lib.maxRowLength(z); var xIn = trace.xtype === 'scaled' ? '' : x; var xArray = makeBoundArray(trace, xIn, x0, dx, xlen, xa); var yIn = trace.ytype === 'scaled' ? '' : y; @@ -70774,7 +72562,11 @@ module.exports = function calc(gd, trace) { // auto-z and autocolorscale if applicable if(!isContour || trace.contours.type !== 'constraint') { - colorscaleCalc(trace, z, '', 'z'); + colorscaleCalc(gd, trace, { + vals: z, + containerStr: '', + cLetter: 'z' + }); } if(isContour && trace.contours && trace.contours.coloring === 'heatmap') { @@ -70790,7 +72582,7 @@ module.exports = function calc(gd, trace) { return [cd0]; }; -},{"../../components/colorscale/calc":59,"../../lib":170,"../../plots/cartesian/axes":214,"../../registry":259,"../histogram2d/calc":346,"./clean_2d_array":319,"./convert_column_xyz":321,"./find_empties":323,"./interp2d":326,"./make_bound_array":327,"./max_row_length":328}],319:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":59,"../../lib":168,"../../plots/cartesian/axes":212,"../../registry":257,"../histogram2d/calc":345,"./clean_2d_array":318,"./convert_column_xyz":320,"./find_empties":322,"./interp2d":325,"./make_bound_array":326}],318:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70835,7 +72627,7 @@ module.exports = function clean2dArray(zOld, transpose) { return zNew; }; -},{"fast-isnumeric":18}],320:[function(_dereq_,module,exports){ +},{"fast-isnumeric":18}],319:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70851,7 +72643,7 @@ module.exports = { max: 'zmax' }; -},{}],321:[function(_dereq_,module,exports){ +},{}],320:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70868,43 +72660,36 @@ var BADNUM = _dereq_('../../constants/numerical').BADNUM; module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, arrayVarNames) { var colLen = trace._length; - var col1 = trace[var1Name].slice(0, colLen); - var col2 = trace[var2Name].slice(0, colLen); + var col1 = ax1.makeCalcdata(trace, var1Name); + var col2 = ax2.makeCalcdata(trace, var2Name); var textCol = trace.text; var hasColumnText = (textCol !== undefined && Lib.isArray1D(textCol)); - var col1Calendar = trace[var1Name + 'calendar']; - var col2Calendar = trace[var2Name + 'calendar']; - - var i, j, arrayVar, newArray, arrayVarName; - - for(i = 0; i < colLen; i++) { - col1[i] = ax1.d2c(col1[i], 0, col1Calendar); - col2[i] = ax2.d2c(col2[i], 0, col2Calendar); - } + var i, j; - var col1dv = Lib.distinctVals(col1), - col1vals = col1dv.vals, - col2dv = Lib.distinctVals(col2), - col2vals = col2dv.vals, - newArrays = []; + var col1dv = Lib.distinctVals(col1); + var col1vals = col1dv.vals; + var col2dv = Lib.distinctVals(col2); + var col2vals = col2dv.vals; + var newArrays = []; + var text; for(i = 0; i < arrayVarNames.length; i++) { newArrays[i] = Lib.init2dArray(col2vals.length, col1vals.length); } - var i1, i2, text; - - if(hasColumnText) text = Lib.init2dArray(col2vals.length, col1vals.length); + if(hasColumnText) { + text = Lib.init2dArray(col2vals.length, col1vals.length); + } for(i = 0; i < colLen; i++) { if(col1[i] !== BADNUM && col2[i] !== BADNUM) { - i1 = Lib.findBin(col1[i] + col1dv.minDiff / 2, col1vals); - i2 = Lib.findBin(col2[i] + col2dv.minDiff / 2, col2vals); + var i1 = Lib.findBin(col1[i] + col1dv.minDiff / 2, col1vals); + var i2 = Lib.findBin(col2[i] + col2dv.minDiff / 2, col2vals); for(j = 0; j < arrayVarNames.length; j++) { - arrayVarName = arrayVarNames[j]; - arrayVar = trace[arrayVarName]; - newArray = newArrays[j]; + var arrayVarName = arrayVarNames[j]; + var arrayVar = trace[arrayVarName]; + var newArray = newArrays[j]; newArray[i2][i1] = arrayVar[i]; } @@ -70920,7 +72705,7 @@ module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, if(hasColumnText) trace._text = text; }; -},{"../../constants/numerical":152,"../../lib":170}],322:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168}],321:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70960,7 +72745,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}); }; -},{"../../components/colorscale/defaults":61,"../../lib":170,"./attributes":317,"./style_defaults":331,"./xyz_defaults":332}],323:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":61,"../../lib":168,"./attributes":316,"./style_defaults":329,"./xyz_defaults":330}],322:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70971,7 +72756,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout 'use strict'; -var maxRowLength = _dereq_('./max_row_length'); +var maxRowLength = _dereq_('../../lib').maxRowLength; /* Return a list of empty points in 2D array z * each empty point z[i][j] gives an array [i, j, neighborCount] @@ -71066,7 +72851,7 @@ module.exports = function findEmpties(z) { return empties.sort(function(a, b) { return b[2] - a[2]; }); }; -},{"./max_row_length":328}],324:[function(_dereq_,module,exports){ +},{"../../lib":168}],323:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71195,7 +72980,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay })]; }; -},{"../../components/fx":93,"../../lib":170,"../../plots/cartesian/axes":214}],325:[function(_dereq_,module,exports){ +},{"../../components/fx":90,"../../lib":168,"../../plots/cartesian/axes":212}],324:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71227,7 +73012,7 @@ Heatmap.meta = { module.exports = Heatmap; -},{"../../plots/cartesian":226,"./attributes":317,"./calc":318,"./colorbar":320,"./defaults":322,"./hover":324,"./plot":329,"./style":330}],326:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":224,"./attributes":316,"./calc":317,"./colorbar":319,"./defaults":321,"./hover":323,"./plot":327,"./style":328}],325:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71362,7 +73147,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { return maxFractionalChange; } -},{"../../lib":170}],327:[function(_dereq_,module,exports){ +},{"../../lib":168}],326:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71432,10 +73217,15 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, var calendar = trace[ax._id.charAt(0) + 'calendar']; - if(isHist || ax.type === 'category') v0 = ax.r2c(v0In, 0, calendar) || 0; - else if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) v0 = arrayIn[0]; - else if(v0In === undefined) v0 = 0; - else v0 = ax.d2c(v0In, 0, calendar); + if(isHist || ax.type === 'category' || ax.type === 'multicategory') { + v0 = ax.r2c(v0In, 0, calendar) || 0; + } else if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) { + v0 = arrayIn[0]; + } else if(v0In === undefined) { + v0 = 0; + } else { + v0 = ax.d2c(v0In, 0, calendar); + } for(i = (isContour || isGL2D) ? 0 : -0.5; i < numbricks; i++) { arrayOut.push(v0 + dv * i); @@ -71445,29 +73235,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, return arrayOut; }; -},{"../../lib":170,"../../registry":259}],328:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function maxRowLength(z) { - var len = 0; - - for(var i = 0; i < z.length; i++) { - len = Math.max(len, z[i].length); - } - - return len; -}; - -},{}],329:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257}],327:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71487,8 +73255,6 @@ var Lib = _dereq_('../../lib'); var Colorscale = _dereq_('../../components/colorscale'); var xmlnsNamespaces = _dereq_('../../constants/xmlns_namespaces'); -var maxRowLength = _dereq_('./max_row_length'); - module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { var xa = plotinfo.xaxis; var ya = plotinfo.yaxis; @@ -71508,7 +73274,7 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { // get z dims var m = z.length; - var n = maxRowLength(z); + var n = Lib.maxRowLength(z); var xrev = false; var yrev = false; @@ -71613,11 +73379,7 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { var context = canvas.getContext('2d'); var sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - trace.colorscale, - trace.zmin, - trace.zmax - ), + Colorscale.extractScale(trace, {cLetter: 'z'}), { noNumericCheck: true, returnArray: true } ); @@ -71888,7 +73650,7 @@ function putColor(pixels, pxIndex, c) { pixels[pxIndex + 3] = Math.round(c[3] * 255); } -},{"../../components/colorscale":66,"../../constants/xmlns_namespaces":153,"../../lib":170,"../../registry":259,"./max_row_length":328,"d3":16,"tinycolor2":34}],330:[function(_dereq_,module,exports){ +},{"../../components/colorscale":63,"../../constants/xmlns_namespaces":150,"../../lib":168,"../../registry":257,"d3":16,"tinycolor2":34}],328:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71909,7 +73671,7 @@ module.exports = function style(gd) { }); }; -},{"d3":16}],331:[function(_dereq_,module,exports){ +},{"d3":16}],329:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71932,7 +73694,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { coerce('zhoverformat'); }; -},{}],332:[function(_dereq_,module,exports){ +},{}],330:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71941,7 +73703,6 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -71961,10 +73722,13 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x x = coerce(xName); y = coerce(yName); + var xlen = Lib.minRowLength(x); + var ylen = Lib.minRowLength(y); + // column z must be accompanied by xName and yName arrays - if(!(x && x.length && y && y.length)) return 0; + if(xlen === 0 || ylen === 0) return 0; - traceOut._length = Math.min(x.length, y.length, z.length); + traceOut._length = Math.min(xlen, ylen, z.length); } else { x = coordDefaults(xName, coerce); @@ -71985,10 +73749,8 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x }; function coordDefaults(coordStr, coerce) { - var coord = coerce(coordStr), - coordType = coord ? - coerce(coordStr + 'type', 'array') : - 'scaled'; + var coord = coerce(coordStr); + var coordType = coord ? coerce(coordStr + 'type', 'array') : 'scaled'; if(coordType === 'scaled') { coerce(coordStr + '0'); @@ -72030,7 +73792,7 @@ function isValidZ(z) { return (allRowsAreArrays && oneRowIsFilled && hasOneNumber); } -},{"../../lib":170,"../../registry":259,"fast-isnumeric":18}],333:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257,"fast-isnumeric":18}],331:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72042,7 +73804,9 @@ function isValidZ(z) { 'use strict'; var barAttrs = _dereq_('../bar/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var makeBinAttrs = _dereq_('./bin_attributes'); +var constants = _dereq_('./constants'); module.exports = { x: { @@ -72135,14 +73899,13 @@ module.exports = { dflt: null, editType: 'calc', - impliedEdits: { - 'ybins.start': undefined, - 'ybins.end': undefined, - 'ybins.size': undefined - }, }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), + marker: barAttrs.marker, selected: barAttrs.selected, @@ -72153,7 +73916,7 @@ module.exports = { } }; -},{"../bar/attributes":269,"./bin_attributes":335}],334:[function(_dereq_,module,exports){ +},{"../../components/fx/hovertemplate_attributes":89,"../bar/attributes":267,"./bin_attributes":333,"./constants":337}],332:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72179,7 +73942,7 @@ module.exports = function doAvg(size, counts) { return total; }; -},{}],335:[function(_dereq_,module,exports){ +},{}],333:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72214,7 +73977,7 @@ module.exports = function makeBinAttrs(axLetter, match) { }; }; -},{}],336:[function(_dereq_,module,exports){ +},{}],334:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72290,7 +74053,7 @@ module.exports = { } }; -},{"fast-isnumeric":18}],337:[function(_dereq_,module,exports){ +},{"fast-isnumeric":18}],335:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72468,7 +74231,7 @@ function dateParts(v, pa, calendar) { return parts; } -},{"../../constants/numerical":152,"../../plots/cartesian/axes":214}],338:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../plots/cartesian/axes":212}],336:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72722,16 +74485,18 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { var isFirstVisible = true; for(i = 0; i < traces.length; i++) { tracei = traces[i]; - pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData); - allPos = Lib.concat(allPos, pos0); - delete tracei._autoBinFinished; - if(trace.visible === true) { - if(isFirstVisible) { - isFirstVisible = false; - } - else { - delete tracei._autoBin; - tracei._autoBinFinished = 1; + if(tracei.visible) { + pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData); + allPos = Lib.concat(allPos, pos0); + delete tracei._autoBinFinished; + if(trace.visible === true) { + if(isFirstVisible) { + isFirstVisible = false; + } + else { + delete tracei._autoBin; + tracei._autoBinFinished = 1; + } } } } @@ -72741,7 +74506,8 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { // Edge case: single-valued histogram overlaying others // Use them all together to calculate the bin size for the single-valued one - if(isOverlay && newBinSpec._dataSpan === 0 && pa.type !== 'category') { + if(isOverlay && newBinSpec._dataSpan === 0 && + pa.type !== 'category' && pa.type !== 'multicategory') { // Several single-valued histograms! Stop infinite recursion, // just return an extra flag that tells handleSingleValueOverlays // to sort out this trace too @@ -72798,7 +74564,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { Lib.aggNums(Math.min, null, pos0); var dummyAx = { - type: pa.type === 'category' ? 'linear' : pa.type, + type: (pa.type === 'category' || pa.type === 'multicategory') ? 'linear' : pa.type, r2l: pa.r2l, dtick: binOpts.size, tick0: mainStart, @@ -72998,7 +74764,23 @@ function cdf(size, direction, currentBin) { } } -},{"../../lib":170,"../../plots/cartesian/axes":214,"../bar/arrays_to_calcdata":268,"./average":334,"./bin_functions":336,"./bin_label_vals":337,"./norm_functions":344,"fast-isnumeric":18}],339:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212,"../bar/arrays_to_calcdata":266,"./average":332,"./bin_functions":334,"./bin_label_vals":335,"./norm_functions":343,"fast-isnumeric":18}],337:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + eventDataKeys: ['binNumber'] +}; + +},{}],338:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73112,7 +74894,7 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) { } }; -},{"../../lib":170,"./attributes":333}],340:[function(_dereq_,module,exports){ +},{"../../lib":168,"./attributes":331}],339:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73151,7 +74933,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var sampleLetter = orientation === 'v' ? 'x' : 'y'; var aggLetter = orientation === 'v' ? 'y' : 'x'; - var len = (x && y) ? Math.min(x.length && y.length) : (traceOut[sampleLetter] || []).length; + var len = (x && y) ? + Math.min(Lib.minRowLength(x) && Lib.minRowLength(y)) : + Lib.minRowLength(traceOut[sampleLetter] || []); if(!len) { traceOut.visible = false; @@ -73171,6 +74955,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout // autobin(x|y) are only included here to appease Plotly.validate coerce('autobin' + sampleLetter); + coerce('hovertemplate'); + handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout); // override defaultColor for error bars with defaultLine @@ -73181,7 +74967,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/color":51,"../../lib":170,"../../registry":259,"../bar/style_defaults":282,"./attributes":333}],341:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../lib":168,"../../registry":257,"../bar/style_defaults":281,"./attributes":331}],340:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73227,7 +75013,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],342:[function(_dereq_,module,exports){ +},{}],341:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73257,10 +75043,12 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { pointData[posLetter + 'Label'] = hoverLabelText(pointData[posLetter + 'a'], di.ph0, di.ph1); } + if(trace.hovermplate) pointData.hovertemplate = trace.hovertemplate; + return pts; }; -},{"../../plots/cartesian/axes":214,"../bar/hover":274}],343:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":212,"../bar/hover":273}],342:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73314,7 +75102,7 @@ Histogram.meta = { module.exports = Histogram; -},{"../../plots/cartesian":226,"../bar/cross_trace_calc":271,"../bar/layout_attributes":276,"../bar/layout_defaults":277,"../bar/plot":278,"../bar/select":279,"../bar/style":281,"../scatter/marker_colorbar":386,"./attributes":333,"./calc":338,"./cross_trace_defaults":339,"./defaults":340,"./event_data":341,"./hover":342}],344:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":224,"../bar/cross_trace_calc":270,"../bar/layout_attributes":275,"../bar/layout_defaults":276,"../bar/plot":277,"../bar/select":278,"../bar/style":280,"../scatter/marker_colorbar":385,"./attributes":331,"./calc":336,"./cross_trace_defaults":338,"./defaults":339,"./event_data":340,"./hover":341}],343:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73349,7 +75137,7 @@ module.exports = { } }; -},{}],345:[function(_dereq_,module,exports){ +},{}],344:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73408,7 +75196,7 @@ module.exports = extendFlat( { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../lib/extend":164,"../heatmap/attributes":317,"../histogram/attributes":333,"../histogram/bin_attributes":335}],346:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../lib/extend":162,"../heatmap/attributes":316,"../histogram/attributes":331,"../histogram/bin_attributes":333}],345:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73673,7 +75461,7 @@ function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) { return out; } -},{"../../lib":170,"../../plots/cartesian/axes":214,"../histogram/average":334,"../histogram/bin_functions":336,"../histogram/bin_label_vals":337,"../histogram/norm_functions":344}],347:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212,"../histogram/average":332,"../histogram/bin_functions":334,"../histogram/bin_label_vals":335,"../histogram/norm_functions":343}],346:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73768,7 +75556,7 @@ function cleanBins(trace, binDirection, fullLayout, autoBins) { } } -},{"../../constants/numerical":152,"../../lib":170,"../../plots/cartesian/axis_ids":217,"./attributes":345,"fast-isnumeric":18}],348:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168,"../../plots/cartesian/axis_ids":215,"./attributes":344,"fast-isnumeric":18}],347:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73802,7 +75590,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout ); }; -},{"../../components/colorscale/defaults":61,"../../lib":170,"../heatmap/style_defaults":331,"./attributes":345,"./sample_defaults":351}],349:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":61,"../../lib":168,"../heatmap/style_defaults":329,"./attributes":344,"./sample_defaults":350}],348:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73836,7 +75624,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return pts; }; -},{"../../plots/cartesian/axes":214,"../heatmap/hover":324}],350:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":212,"../heatmap/hover":323}],349:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73872,7 +75660,7 @@ Histogram2D.meta = { module.exports = Histogram2D; -},{"../../plots/cartesian":226,"../heatmap/calc":318,"../heatmap/colorbar":320,"../heatmap/plot":329,"../heatmap/style":330,"../histogram/event_data":341,"./attributes":345,"./cross_trace_defaults":347,"./defaults":348,"./hover":349}],351:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":224,"../heatmap/calc":317,"../heatmap/colorbar":319,"../heatmap/plot":327,"../heatmap/style":328,"../histogram/event_data":340,"./attributes":344,"./cross_trace_defaults":346,"./defaults":347,"./hover":348}],350:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73881,24 +75669,26 @@ module.exports = Histogram2D; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Registry = _dereq_('../../registry'); +var Lib = _dereq_('../../lib'); module.exports = function handleSampleDefaults(traceIn, traceOut, coerce, layout) { var x = coerce('x'); var y = coerce('y'); + var xlen = Lib.minRowLength(x); + var ylen = Lib.minRowLength(y); // we could try to accept x0 and dx, etc... // but that's a pretty weird use case. // for now require both x and y explicitly specified. - if(!(x && x.length && y && y.length)) { + if(!xlen || !ylen) { traceOut.visible = false; return; } - traceOut._length = Math.min(x.length, y.length); + traceOut._length = Math.min(xlen, ylen); var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); @@ -73915,7 +75705,7 @@ module.exports = function handleSampleDefaults(traceIn, traceOut, coerce, layout coerce('autobiny'); }; -},{"../../registry":259}],352:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257}],351:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73961,7 +75751,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../lib/extend":164,"../contour/attributes":295,"../histogram2d/attributes":345}],353:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../lib/extend":162,"../contour/attributes":294,"../histogram2d/attributes":344}],352:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73997,7 +75787,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleStyleDefaults(traceIn, traceOut, coerce, layout); }; -},{"../../lib":170,"../contour/contours_defaults":302,"../contour/style_defaults":316,"../histogram2d/sample_defaults":351,"./attributes":352}],354:[function(_dereq_,module,exports){ +},{"../../lib":168,"../contour/contours_defaults":301,"../contour/style_defaults":315,"../histogram2d/sample_defaults":350,"./attributes":351}],353:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74032,7 +75822,7 @@ Histogram2dContour.meta = { module.exports = Histogram2dContour; -},{"../../plots/cartesian":226,"../contour/calc":296,"../contour/colorbar":298,"../contour/hover":308,"../contour/plot":313,"../contour/style":315,"../histogram2d/cross_trace_defaults":347,"./attributes":352,"./defaults":353}],355:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":224,"../contour/calc":295,"../contour/colorbar":297,"../contour/hover":307,"../contour/plot":312,"../contour/style":314,"../histogram2d/cross_trace_defaults":346,"./attributes":351,"./defaults":352}],354:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74046,6 +75836,7 @@ module.exports = Histogram2dContour; var colorAttrs = _dereq_('../../components/color/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); var plotAttrs = _dereq_('../../plots/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var domainAttrs = _dereq_('../../plots/domain').attributes; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -74153,6 +75944,9 @@ module.exports = { hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { flags: ['label', 'text', 'value', 'percent', 'name'] }), + hovertemplate: hovertemplateAttrs({}, { + keys: ['label', 'color', 'value', 'percent', 'text'] + }), textposition: { valType: 'enumerated', @@ -74173,26 +75967,30 @@ module.exports = { }), title: { - valType: 'string', - dflt: '', - - editType: 'calc', - - }, - titleposition: { - valType: 'enumerated', - values: [ - 'top left', 'top center', 'top right', - 'middle center', - 'bottom left', 'bottom center', 'bottom right' - ], - - editType: 'calc', - + text: { + valType: 'string', + dflt: '', + + editType: 'calc', + + }, + font: extendFlat({}, textFontAttrs, { + + }), + position: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + + editType: 'calc', + + }, + + editType: 'calc' }, - titlefont: extendFlat({}, textFontAttrs, { - - }), // position and shape domain: domainAttrs({name: 'pie', trace: true, editType: 'calc'}), @@ -74249,10 +76047,34 @@ module.exports = { arrayOk: true, editType: 'calc', + }, + + _deprecated: { + title: { + valType: 'string', + dflt: '', + + editType: 'calc', + + }, + titlefont: extendFlat({}, textFontAttrs, { + + }), + titleposition: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + + editType: 'calc', + + } } }; -},{"../../components/color/attributes":50,"../../lib/extend":164,"../../plots/attributes":211,"../../plots/domain":240,"../../plots/font_attributes":241}],356:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":50,"../../components/fx/hovertemplate_attributes":89,"../../lib/extend":162,"../../plots/attributes":209,"../../plots/domain":238,"../../plots/font_attributes":239}],355:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74284,7 +76106,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../plots/get_data":243,"../../registry":259}],357:[function(_dereq_,module,exports){ +},{"../../plots/get_data":241,"../../registry":257}],356:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74475,7 +76297,7 @@ function generateExtendedColors(colorList) { return pieColors; } -},{"../../components/color":51,"../../lib":170,"./helpers":360,"fast-isnumeric":18,"tinycolor2":34}],358:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../lib":168,"./helpers":359,"fast-isnumeric":18,"tinycolor2":34}],357:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74529,6 +76351,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var textData = coerce('text'); var textInfo = coerce('textinfo', Array.isArray(textData) ? 'text+percent' : 'percent'); coerce('hovertext'); + coerce('hovertemplate'); if(textInfo && textInfo !== 'none') { var textPosition = coerce('textposition'), @@ -74554,11 +76377,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleDomainDefaults(traceOut, layout, coerce); var hole = coerce('hole'); - var title = coerce('title'); + var title = coerce('title.text'); if(title) { - var titlePosition = coerce('titleposition', hole ? 'middle center' : 'top center'); - if(!hole && titlePosition === 'middle center') traceOut.titleposition = 'top center'; - coerceFont(coerce, 'titlefont', layout.font); + var titlePosition = coerce('title.position', hole ? 'middle center' : 'top center'); + if(!hole && titlePosition === 'middle center') traceOut.title.position = 'top center'; + coerceFont(coerce, 'title.font', layout.font); } coerce('sort'); @@ -74568,7 +76391,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('pull'); }; -},{"../../lib":170,"../../plots/domain":240,"./attributes":355}],359:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/domain":238,"./attributes":354}],358:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74595,6 +76418,8 @@ module.exports = function eventData(pt, trace) { label: pt.label, color: pt.color, value: pt.v, + percent: pt.percent, + text: pt.text, // pt.v (and pt.i below) for backward compatibility v: pt.v @@ -74611,7 +76436,7 @@ module.exports = function eventData(pt, trace) { return out; }; -},{"../../components/fx/helpers":90}],360:[function(_dereq_,module,exports){ +},{"../../components/fx/helpers":86}],359:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74653,7 +76478,7 @@ exports.castOption = function castOption(item, indices) { else if(item) return item; }; -},{"../../lib":170}],361:[function(_dereq_,module,exports){ +},{"../../lib":168}],360:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74689,7 +76514,7 @@ Pie.meta = { module.exports = Pie; -},{"./attributes":355,"./base_plot":356,"./calc":357,"./defaults":358,"./layout_attributes":362,"./layout_defaults":363,"./plot":364,"./style":365,"./style_one":366}],362:[function(_dereq_,module,exports){ +},{"./attributes":354,"./base_plot":355,"./calc":356,"./defaults":357,"./layout_attributes":361,"./layout_defaults":362,"./plot":363,"./style":364,"./style_one":365}],361:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74725,7 +76550,7 @@ module.exports = { } }; -},{}],363:[function(_dereq_,module,exports){ +},{}],362:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74749,7 +76574,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { coerce('extendpiecolors'); }; -},{"../../lib":170,"./layout_attributes":362}],364:[function(_dereq_,module,exports){ +},{"../../lib":168,"./layout_attributes":361}],363:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74851,20 +76676,25 @@ module.exports = function plot(gd, cdpie) { // in case we dragged over the pie from another subplot, // or if hover is turned off - if(hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo) { + if(trace2.hovertemplate || (hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo)) { var rInscribed = getInscribedRadiusFraction(pt, cd0); var hoverCenterX = cx + pt.pxmid[0] * (1 - rInscribed); var hoverCenterY = cy + pt.pxmid[1] * (1 - rInscribed); var separators = fullLayout.separators; var thisText = []; - if(hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); - if(hoverinfo.indexOf('text') !== -1) { - var texti = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); + pt.text = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('text') !== -1) { + var texti = pt.text; if(texti) thisText.push(texti); } - if(hoverinfo.indexOf('value') !== -1) thisText.push(helpers.formatPieValue(pt.v, separators)); - if(hoverinfo.indexOf('percent') !== -1) thisText.push(helpers.formatPiePercent(pt.v / cd0.vTotal, separators)); + pt.value = pt.v; + pt.valueLabel = helpers.formatPieValue(pt.v, separators); + if(hoverinfo && hoverinfo.indexOf('value') !== -1) thisText.push(pt.valueLabel); + pt.percent = pt.v / cd0.vTotal; + pt.percentLabel = helpers.formatPiePercent(pt.percent, separators); + if(hoverinfo && hoverinfo.indexOf('percent') !== -1) thisText.push(pt.percentLabel); var hoverLabel = trace.hoverlabel; var hoverFont = hoverLabel.font; @@ -74874,13 +76704,18 @@ module.exports = function plot(gd, cdpie) { x1: hoverCenterX + rInscribed * cd0.r, y: hoverCenterY, text: thisText.join('
'), - name: hoverinfo.indexOf('name') !== -1 ? trace2.name : undefined, + name: (trace2.hovertemplate || hoverinfo.indexOf('name') !== -1) ? trace2.name : undefined, idealAlign: pt.pxmid[0] < 0 ? 'left' : 'right', color: helpers.castOption(hoverLabel.bgcolor, pt.pts) || pt.color, borderColor: helpers.castOption(hoverLabel.bordercolor, pt.pts), fontFamily: helpers.castOption(hoverFont.family, pt.pts), fontSize: helpers.castOption(hoverFont.size, pt.pts), - fontColor: helpers.castOption(hoverFont.color, pt.pts) + fontColor: helpers.castOption(hoverFont.color, pt.pts), + + trace: trace2, + hovertemplate: helpers.castOption(trace2.hovertemplate, pt.pts), + hovertemplateLabels: pt, + eventData: [eventData(pt, trace2)] }, { container: fullLayout2._hoverlayer.node(), outerContainer: fullLayout2._paper.node(), @@ -75064,7 +76899,7 @@ module.exports = function plot(gd, cdpie) { // add the title var titleTextGroup = d3.select(this).selectAll('g.titletext') - .data(trace.title ? [0] : []); + .data(trace.title.text ? [0] : []); titleTextGroup.enter().append('g') .classed('titletext', true); @@ -75076,18 +76911,18 @@ module.exports = function plot(gd, cdpie) { s.attr('data-notex', 1); }); - titleText.text(trace.title) + titleText.text(trace.title.text) .attr({ 'class': 'titletext', transform: '', 'text-anchor': 'middle', }) - .call(Drawing.font, trace.titlefont) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var transform; - if(trace.titleposition === 'middle center') { + if(trace.title.position === 'middle center') { transform = positionTitleInside(cd0); } else { transform = positionTitleOutside(cd0, fullLayout._size); @@ -75215,11 +77050,11 @@ function prerenderTitles(cdpie, gd) { cd0 = cdpie[i][0]; trace = cd0.trace; - if(trace.title) { + if(trace.title.text) { var dummyTitle = Drawing.tester.append('text') .attr('data-notex', 1) - .text(trace.title) - .call(Drawing.font, trace.titlefont) + .text(trace.title.text) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var bBox = Drawing.bBox(dummyTitle.node(), true); cd0.titleBox = { @@ -75321,7 +77156,7 @@ function positionTitleInside(cd0) { y: cd0.cy, scale: cd0.trace.hole * cd0.r * 2 / textDiameter, tx: 0, - ty: - cd0.titleBox.height / 2 + cd0.trace.titlefont.size + ty: - cd0.titleBox.height / 2 + cd0.trace.title.font.size }; } @@ -75344,25 +77179,25 @@ function positionTitleOutside(cd0, plotSize) { // we reason below as if the baseline is the top middle point of the text box. // so we must add the font size to approximate the y-coord. of the top. // note that this correction must happen after scaling. - translate.ty += trace.titlefont.size; + translate.ty += trace.title.font.size; maxPull = getMaxPull(trace); - if(trace.titleposition.indexOf('top') !== -1) { + if(trace.title.position.indexOf('top') !== -1) { topMiddle.y -= (1 + maxPull) * cd0.r; translate.ty -= cd0.titleBox.height; } - else if(trace.titleposition.indexOf('bottom') !== -1) { + else if(trace.title.position.indexOf('bottom') !== -1) { topMiddle.y += (1 + maxPull) * cd0.r; } - if(trace.titleposition.indexOf('left') !== -1) { + if(trace.title.position.indexOf('left') !== -1) { // we start the text at the left edge of the pie maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x -= (1 + maxPull) * cd0.r; translate.tx += cd0.titleBox.width / 2; - } else if(trace.titleposition.indexOf('center') !== -1) { + } else if(trace.title.position.indexOf('center') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); - } else if(trace.titleposition.indexOf('right') !== -1) { + } else if(trace.title.position.indexOf('right') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x += (1 + maxPull) * cd0.r; translate.tx -= cd0.titleBox.width / 2; @@ -75516,7 +77351,7 @@ function scalePies(cdpie, plotSize) { pieBoxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); pieBoxHeight = plotSize.h * (trace.domain.y[1] - trace.domain.y[0]); // leave some space for the title, if it will be displayed outside - if(trace.title && trace.titleposition !== 'middle center') { + if(trace.title.text && trace.title.position !== 'middle center') { pieBoxHeight -= getTitleSpace(cd0, plotSize); } @@ -75526,7 +77361,7 @@ function scalePies(cdpie, plotSize) { cd0.cx = plotSize.l + plotSize.w * (trace.domain.x[1] + trace.domain.x[0]) / 2; cd0.cy = plotSize.t + plotSize.h * (1 - trace.domain.y[0]) - pieBoxHeight / 2; - if(trace.title && trace.titleposition.indexOf('bottom') !== -1) { + if(trace.title.text && trace.title.position.indexOf('bottom') !== -1) { cd0.cy -= getTitleSpace(cd0, plotSize); } @@ -75605,7 +77440,7 @@ function setCoords(cd) { } } -},{"../../components/color":51,"../../components/drawing":76,"../../components/fx":93,"../../lib":170,"../../lib/svg_text_utils":191,"./event_data":359,"./helpers":360,"d3":16}],365:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/drawing":72,"../../components/fx":90,"../../lib":168,"../../lib/svg_text_utils":189,"./event_data":358,"./helpers":359,"d3":16}],364:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75634,7 +77469,7 @@ module.exports = function style(gd) { }); }; -},{"./style_one":366,"d3":16}],366:[function(_dereq_,module,exports){ +},{"./style_one":365,"d3":16}],365:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75658,7 +77493,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":51,"./helpers":360}],367:[function(_dereq_,module,exports){ +},{"../../components/color":51,"./helpers":359}],366:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75710,7 +77545,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":170}],368:[function(_dereq_,module,exports){ +},{"../../lib":168}],367:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75721,6 +77556,7 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -75832,6 +77668,9 @@ module.exports = { editType: 'style', }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), line: { color: { valType: 'color', @@ -76106,7 +77945,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../components/drawing":76,"../../components/drawing/attributes":75,"../../lib/extend":164,"../../plots/font_attributes":241,"./constants":372}],369:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../components/drawing":72,"../../components/drawing/attributes":71,"../../components/fx/hovertemplate_attributes":89,"../../lib/extend":162,"../../plots/font_attributes":239,"./constants":371}],368:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76196,7 +78035,7 @@ function calc(gd, trace) { } arraysToCalcdata(cd, trace); - calcColorscale(trace); + calcColorscale(gd, trace); calcSelection(cd, trace); if(stackGroupOpts) { @@ -76396,7 +78235,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":152,"../../lib":170,"../../plots/cartesian/axes":214,"./arrays_to_calcdata":367,"./calc_selection":370,"./colorscale_calc":371,"./subtypes":392,"fast-isnumeric":18}],370:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168,"../../plots/cartesian/axes":212,"./arrays_to_calcdata":366,"./calc_selection":369,"./colorscale_calc":370,"./subtypes":391,"fast-isnumeric":18}],369:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76415,7 +78254,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":170}],371:[function(_dereq_,module,exports){ +},{"../../lib":168}],370:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76424,31 +78263,41 @@ module.exports = function calcSelection(cd, trace) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var subTypes = _dereq_('./subtypes'); - -module.exports = function calcMarkerColorscale(trace) { +module.exports = function calcMarkerColorscale(gd, trace) { if(subTypes.hasLines(trace) && hasColorscale(trace, 'line')) { - calcColorscale(trace, trace.line.color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } if(subTypes.hasMarkers(trace)) { if(hasColorscale(trace, 'marker')) { - calcColorscale(trace, trace.marker.color, 'marker', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - calcColorscale(trace, trace.marker.line.color, 'marker.line', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } } }; -},{"../../components/colorscale/calc":59,"../../components/colorscale/has_colorscale":65,"./subtypes":392}],372:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":59,"../../components/colorscale/helpers":62,"./subtypes":391}],371:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76472,10 +78321,12 @@ module.exports = { // number of viewport sizes away from the visible region // at which we clip all lines to the perimeter - maxScreensAway: 20 + maxScreensAway: 20, + + eventDataKeys: [] }; -},{}],373:[function(_dereq_,module,exports){ +},{}],372:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76658,7 +78509,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":369}],374:[function(_dereq_,module,exports){ +},{"./calc":368}],373:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76697,7 +78548,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],375:[function(_dereq_,module,exports){ +},{}],374:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76775,7 +78626,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout dfltHoverOn.push('fills'); } coerce('hoveron', dfltHoverOn.join('+') || 'points'); - + if(traceOut.hoveron !== 'fills') coerce('hovertemplate'); var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults'); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'}); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'}); @@ -76783,7 +78634,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":170,"../../registry":259,"./attributes":368,"./constants":372,"./fillcolor_defaults":377,"./line_defaults":381,"./line_shape_defaults":383,"./marker_defaults":387,"./stack_defaults":390,"./subtypes":392,"./text_defaults":393,"./xy_defaults":394}],376:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257,"./attributes":367,"./constants":371,"./fillcolor_defaults":376,"./line_defaults":380,"./line_shape_defaults":382,"./marker_defaults":386,"./stack_defaults":389,"./subtypes":391,"./text_defaults":392,"./xy_defaults":393}],375:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76826,7 +78677,7 @@ function isValid(v) { return v || v === 0; } -},{"../../lib":170}],377:[function(_dereq_,module,exports){ +},{"../../lib":168}],376:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76864,7 +78715,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":51,"../../lib":170}],378:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../lib":168}],377:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76917,7 +78768,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":51,"./subtypes":392}],379:[function(_dereq_,module,exports){ +},{"../../components/color":51,"./subtypes":391}],378:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77013,7 +78864,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { y1: yc + rad, yLabelVal: yLabelVal, - spikeDistance: dxy(di) + spikeDistance: dxy(di), + hovertemplate: trace.hovertemplate }); fillHoverText(di, trace, pointData); @@ -77097,7 +78949,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { x1: xmax, y0: yAvg, y1: yAvg, - color: color + color: color, + hovertemplate: '%{name}' }); delete pointData.index; @@ -77112,7 +78965,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":51,"../../components/fx":93,"../../lib":170,"../../registry":259,"./fill_hover_text":376,"./get_trace_color":378}],380:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/fx":90,"../../lib":168,"../../registry":257,"./fill_hover_text":375,"./get_trace_color":377}],379:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77159,7 +79012,7 @@ Scatter.meta = { module.exports = Scatter; -},{"../../plots/cartesian":226,"./arrays_to_calcdata":367,"./attributes":368,"./calc":369,"./cross_trace_calc":373,"./cross_trace_defaults":374,"./defaults":375,"./hover":379,"./marker_colorbar":386,"./plot":388,"./select":389,"./style":391,"./subtypes":392}],381:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":224,"./arrays_to_calcdata":366,"./attributes":367,"./calc":368,"./cross_trace_calc":372,"./cross_trace_defaults":373,"./defaults":374,"./hover":378,"./marker_colorbar":385,"./plot":387,"./select":388,"./style":390,"./subtypes":391}],380:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77171,7 +79024,7 @@ module.exports = Scatter; 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) { @@ -77190,7 +79043,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":61,"../../components/colorscale/has_colorscale":65,"../../lib":170}],382:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":61,"../../components/colorscale/helpers":62,"../../lib":168}],381:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77655,7 +79508,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":152,"../../lib":170,"./constants":372}],383:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168,"./constants":371}],382:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77674,7 +79527,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],384:[function(_dereq_,module,exports){ +},{}],383:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77767,7 +79620,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],385:[function(_dereq_,module,exports){ +},{}],384:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77809,7 +79662,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":18}],386:[function(_dereq_,module,exports){ +},{"fast-isnumeric":18}],385:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77827,7 +79680,7 @@ module.exports = { max: 'cmax' }; -},{}],387:[function(_dereq_,module,exports){ +},{}],386:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77836,11 +79689,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var subTypes = _dereq_('./subtypes'); @@ -77910,7 +79762,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":51,"../../components/colorscale/defaults":61,"../../components/colorscale/has_colorscale":65,"./subtypes":392}],388:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../components/colorscale/defaults":61,"../../components/colorscale/helpers":62,"./subtypes":391}],387:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78001,7 +79853,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition function createFills(gd, traceJoin, plotinfo) { traceJoin.each(function(d) { var fills = ensureSingle(d3.select(this), 'g', 'fills'); - Drawing.setClipUrl(fills, plotinfo.layerClipId); + Drawing.setClipUrl(fills, plotinfo.layerClipId, gd); var trace = d[0].trace; @@ -78053,7 +79905,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition var text = ensureSingle(tr, 'g', 'text'); // error bars are at the bottom - Registry.getComponentMethod('errorbars', 'plot')(errorBarGroup, plotinfo, transitionOpts); + Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts); if(trace.visible !== true) return; @@ -78208,7 +80060,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.lineGroupStyle) .each(makeUpdate(true)); - Drawing.setClipUrl(lineJoin, plotinfo.layerClipId); + Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd); function clearFill(selection) { transition(selection).attr('d', 'M0,0Z'); @@ -78436,8 +80288,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = trace.cliponaxis === false; var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId; - Drawing.setClipUrl(points, clipUrl); - Drawing.setClipUrl(text, clipUrl); + Drawing.setClipUrl(points, clipUrl, gd); + Drawing.setClipUrl(text, clipUrl, gd); } function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { @@ -78482,7 +80334,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":76,"../../lib":170,"../../lib/polygon":182,"../../registry":259,"./line_points":382,"./link_traces":384,"./subtypes":392,"d3":16}],389:[function(_dereq_,module,exports){ +},{"../../components/drawing":72,"../../lib":168,"../../lib/polygon":180,"../../registry":257,"./line_points":381,"./link_traces":383,"./subtypes":391,"d3":16}],388:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78537,7 +80389,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":392}],390:[function(_dereq_,module,exports){ +},{"./subtypes":391}],389:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78643,7 +80495,7 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],391:[function(_dereq_,module,exports){ +},{}],390:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78715,7 +80567,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":76,"../../registry":259,"d3":16}],392:[function(_dereq_,module,exports){ +},{"../../components/drawing":72,"../../registry":257,"d3":16}],391:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78754,7 +80606,7 @@ module.exports = { } }; -},{"../../lib":170}],393:[function(_dereq_,module,exports){ +},{"../../lib":168}],392:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78784,7 +80636,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":170}],394:[function(_dereq_,module,exports){ +},{"../../lib":168}],393:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78793,34 +80645,32 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var Lib = _dereq_('../../lib'); var Registry = _dereq_('../../registry'); - module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { - var len, - x = coerce('x'), - y = coerce('y'); + var x = coerce('x'); + var y = coerce('y'); + var len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); if(x) { + var xlen = Lib.minRowLength(x); if(y) { - len = Math.min(x.length, y.length); - } - else { - len = x.length; + len = Math.min(xlen, Lib.minRowLength(y)); + } else { + len = xlen; coerce('y0'); coerce('dy'); } - } - else { + } else { if(!y) return 0; - len = traceOut.y.length; + len = Lib.minRowLength(y); coerce('x0'); coerce('dx'); } @@ -78830,7 +80680,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../registry":259}],395:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../registry":257}],394:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78933,7 +80783,7 @@ module.exports = { hoveron: scatterAttrs.hoveron, }; -},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../components/drawing/attributes":75,"../../lib/extend":164,"../../plots/attributes":211,"../scatter/attributes":368}],396:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../components/drawing/attributes":71,"../../lib/extend":162,"../../plots/attributes":209,"../scatter/attributes":367}],395:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79008,14 +80858,14 @@ module.exports = function calc(gd, trace) { } calcMarkerSize(trace, serieslen); - calcColorscale(trace); + calcColorscale(gd, trace); arraysToCalcdata(cd, trace); calcSelection(cd, trace); return cd; }; -},{"../scatter/arrays_to_calcdata":367,"../scatter/calc":369,"../scatter/calc_selection":370,"../scatter/colorscale_calc":371,"fast-isnumeric":18}],397:[function(_dereq_,module,exports){ +},{"../scatter/arrays_to_calcdata":366,"../scatter/calc":368,"../scatter/calc_selection":369,"../scatter/colorscale_calc":370,"fast-isnumeric":18}],396:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79119,7 +80969,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":170,"../scatter/constants":372,"../scatter/fillcolor_defaults":377,"../scatter/line_defaults":381,"../scatter/line_shape_defaults":383,"../scatter/marker_defaults":387,"../scatter/subtypes":392,"../scatter/text_defaults":393,"./attributes":395}],398:[function(_dereq_,module,exports){ +},{"../../lib":168,"../scatter/constants":371,"../scatter/fillcolor_defaults":376,"../scatter/line_defaults":380,"../scatter/line_shape_defaults":382,"../scatter/marker_defaults":386,"../scatter/subtypes":391,"../scatter/text_defaults":392,"./attributes":394}],397:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79151,7 +81001,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],399:[function(_dereq_,module,exports){ +},{}],398:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79223,7 +81073,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { return scatterPointData; }; -},{"../../plots/cartesian/axes":214,"../scatter/hover":379}],400:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":212,"../scatter/hover":378}],399:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79258,7 +81108,7 @@ ScatterTernary.meta = { module.exports = ScatterTernary; -},{"../../plots/ternary":255,"../scatter/marker_colorbar":386,"../scatter/select":389,"../scatter/style":391,"./attributes":395,"./calc":396,"./defaults":397,"./event_data":398,"./hover":399,"./plot":401}],401:[function(_dereq_,module,exports){ +},{"../../plots/ternary":253,"../scatter/marker_colorbar":385,"../scatter/select":388,"../scatter/style":390,"./attributes":394,"./calc":395,"./defaults":396,"./event_data":397,"./hover":398,"./plot":400}],400:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79291,7 +81141,7 @@ module.exports = function plot(gd, ternary, moduleCalcData) { scatterPlot(gd, plotinfo, moduleCalcData, scatterLayer); }; -},{"../scatter/plot":388}],402:[function(_dereq_,module,exports){ +},{"../scatter/plot":387}],401:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79478,7 +81328,7 @@ module.exports = { } }; -},{"../../lib/extend":164,"../box/attributes":283}],403:[function(_dereq_,module,exports){ +},{"../../lib/extend":162,"../box/attributes":282}],402:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79604,7 +81454,9 @@ function calcSpan(trace, cdi, valAxis, bandwidth) { function calcSpanItem(index) { var s = spanIn[index]; - var sc = valAxis.d2c(s, 0, trace[cdi.valLetter + 'calendar']); + var sc = valAxis.type === 'multicategory' ? + valAxis.r2c(s) : + valAxis.d2c(s, 0, trace[cdi.valLetter + 'calendar']); return sc === BADNUM ? spanLoose[index] : sc; } @@ -79627,7 +81479,7 @@ function calcSpan(trace, cdi, valAxis, bandwidth) { return spanOut; } -},{"../../constants/numerical":152,"../../lib":170,"../../plots/cartesian/axes":214,"../box/calc":284,"./helpers":406}],404:[function(_dereq_,module,exports){ +},{"../../constants/numerical":149,"../../lib":168,"../../plots/cartesian/axes":212,"../box/calc":283,"./helpers":405}],403:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79677,7 +81529,7 @@ module.exports = function crossTraceCalc(gd, plotinfo) { } }; -},{"../box/cross_trace_calc":285}],405:[function(_dereq_,module,exports){ +},{"../box/cross_trace_calc":284}],404:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79734,7 +81586,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(!meanLineVisible) traceOut.meanline = {visible: false}; }; -},{"../../components/color":51,"../../lib":170,"../box/defaults":286,"./attributes":402}],406:[function(_dereq_,module,exports){ +},{"../../components/color":51,"../../lib":168,"../box/defaults":285,"./attributes":401}],405:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79807,7 +81659,7 @@ exports.getKdeValue = function(calcItem, trace, valueDist) { exports.extractVal = function(o) { return o.v; }; -},{"../../lib":170}],407:[function(_dereq_,module,exports){ +},{"../../lib":168}],406:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79916,7 +81768,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return closeData; }; -},{"../../lib":170,"../../plots/cartesian/axes":214,"../box/hover":288,"./helpers":406}],408:[function(_dereq_,module,exports){ +},{"../../lib":168,"../../plots/cartesian/axes":212,"../box/hover":287,"./helpers":405}],407:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79949,7 +81801,7 @@ module.exports = { } }; -},{"../../plots/cartesian":226,"../box/select":293,"../scatter/style":391,"./attributes":402,"./calc":403,"./cross_trace_calc":404,"./defaults":405,"./hover":407,"./layout_attributes":409,"./layout_defaults":410,"./plot":411,"./style":412}],409:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":224,"../box/select":292,"../scatter/style":390,"./attributes":401,"./calc":402,"./cross_trace_calc":403,"./defaults":404,"./hover":406,"./layout_attributes":408,"./layout_defaults":409,"./plot":410,"./style":411}],408:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79975,7 +81827,7 @@ module.exports = { }) }; -},{"../../lib":170,"../box/layout_attributes":290}],410:[function(_dereq_,module,exports){ +},{"../../lib":168,"../box/layout_attributes":289}],409:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79997,7 +81849,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { boxLayoutDefaults._supply(layoutIn, layoutOut, fullData, coerce, 'violin'); }; -},{"../../lib":170,"../box/layout_defaults":291,"./layout_attributes":409}],411:[function(_dereq_,module,exports){ +},{"../../lib":168,"../box/layout_defaults":290,"./layout_attributes":408}],410:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80197,7 +82049,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) { }); }; -},{"../../components/drawing":76,"../../lib":170,"../box/plot":292,"../scatter/line_points":382,"./helpers":406,"d3":16}],412:[function(_dereq_,module,exports){ +},{"../../components/drawing":72,"../../lib":168,"../box/plot":291,"../scatter/line_points":381,"./helpers":405,"d3":16}],411:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80252,5 +82104,5 @@ module.exports = function style(gd, cd) { }); }; -},{"../../components/color":51,"../scatter/style":391,"d3":16}]},{},[11])(11) +},{"../../components/color":51,"../scatter/style":390,"d3":16}]},{},[11])(11) }); diff --git a/dist/plotly-cartesian.min.js b/dist/plotly-cartesian.min.js index ed3f20af931..aaaa875e388 100644 --- a/dist/plotly-cartesian.min.js +++ b/dist/plotly-cartesian.min.js @@ -1,7 +1,7 @@ /** -* plotly.js (cartesian - minified) v1.42.5 +* plotly.js (cartesian - minified) v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,r,n){function a(o,l){if(!r[o]){if(!e[o]){var s="function"==typeof require&&require;if(!l&&s)return s(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};e[o][0].call(u.exports,function(t){return a(e[o][1][t]||t)},u,u.exports,t,e,r,n)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;oplotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":275}],4:[function(t,e,r){"use strict";e.exports=t("../src/traces/box")},{"../src/traces/box":289}],5:[function(t,e,r){"use strict";e.exports=t("../src/traces/contour")},{"../src/traces/contour":309}],6:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":154}],7:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmap")},{"../src/traces/heatmap":325}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram")},{"../src/traces/histogram":343}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2d")},{"../src/traces/histogram2d":350}],10:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2dcontour")},{"../src/traces/histogram2dcontour":354}],11:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./box"),t("./heatmap"),t("./histogram"),t("./histogram2d"),t("./histogram2dcontour"),t("./pie"),t("./contour"),t("./scatterternary"),t("./violin")]),e.exports=n},{"./bar":3,"./box":4,"./contour":5,"./core":6,"./heatmap":7,"./histogram":8,"./histogram2d":9,"./histogram2dcontour":10,"./pie":12,"./scatterternary":13,"./violin":14}],12:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":361}],13:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterternary")},{"../src/traces/scatterternary":400}],14:[function(t,e,r){"use strict";e.exports=t("../src/traces/violin")},{"../src/traces/violin":408}],15:[function(t,e,r){var n=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},i=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var l,s=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),l=0===c.x}catch(t){l=!1}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,a){var i,o,l;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),l=o[e]):(o=t._events=n(null),t._eventsCount=0),l){if("function"==typeof l?l=o[e]=a?[r,l]:[l,r]:a?l.unshift(r):l.push(r),!l.warned&&(i=u(t))&&i>0&&l.length>i){l.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+l.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=l.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else l=o[e]=r,++t._eventsCount;return t}function d(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var s=new Error('Unhandled "error" event. ('+e+")");throw s.context=e,s}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,a=v(t,n),i=0;i=0;o--)if(r[o]===e||r[o].listener===e){l=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(var r=e,n=r+1,a=t.length;n=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],16:[function(t,e,r){!function(){var t={version:"3.5.17"},r=[].slice,n=function(t){return r.call(t)},a=this.document;function i(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(a)try{n(a.documentElement.childNodes)[0].nodeType}catch(t){n=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),a)try{a.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var l=this.Element.prototype,s=l.setAttribute,c=l.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;l.setAttribute=function(t,e){s.call(this,t,e+"")},l.setAttributeNS=function(t,e,r){c.call(this,t,e,r+"")},u.setProperty=function(t,e,r){f.call(this,t,e+"",r)}}function d(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function h(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)<0?n=i+1:a=i}return n},right:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)>0?a=i:n=i+1}return n}}}t.ascending=d,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++an&&(r=n)}else{for(;++a=n){r=n;break}for(;++an&&(r=n)}return r},t.max=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++ar&&(r=n)}else{for(;++a=n){r=n;break}for(;++ar&&(r=n)}return r},t.extent=function(t,e){var r,n,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=n){r=a=n;break}for(;++in&&(r=n),a=n){r=a=n;break}for(;++in&&(r=n),a1)return o/(s-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(d);function y(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return d(t(e),r)}:t)},t.shuffle=function(t,e,r){(i=arguments.length)<3&&(r=t.length,i<2&&(e=0));for(var n,a,i=r-e;i;)a=Math.random()*i--|0,n=t[i+e],t[i+e]=t[a+e],t[a+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],a=new Array(r<0?0:r);e=0;)for(e=(n=t[a]).length;--e>=0;)r[--o]=n[e];return r};var m=Math.abs;function x(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(m(r)),o=-1;if(t*=i,e*=i,(r*=i)<0)for(;(n=t+r*++o)>e;)a.push(n/i);else for(;(n=t+r*++o)=a.length)return r?r.call(n,i):e?i.sort(e):i;for(var s,c,u,f,d=-1,p=i.length,h=a[l++],g=new b;++d=a.length)return e;var n=[],o=i[r++];return e.forEach(function(e,a){n.push({key:e,values:t(a,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return a.push(t),n},n.sortKeys=function(t){return i[a.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new O;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function V(t){return q(t,X),t}var U=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},Z=function(t,e){var r=t.matches||t[D(t,"matchesSelector")];return(Z=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(U=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,Z=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var X=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return U(t,this)}}function W(t){return"function"==typeof t?t:function(){return G(t,this)}}X.select=function(t){var e,r,n,a,i=[];t=Y(t);for(var o=-1,l=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Q.hasOwnProperty(r)?{space:Q[r],local:t}:t}},X.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each($(r,e[r]));return this}return this.each($(e,r))},X.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,a=-1;if(e=r.classList){for(;++a=0;)(r=n[a])&&(i&&i!==r.nextSibling&&i.parentNode.insertBefore(r,i),i=r);return this},X.sort=function(t){t=function(t){arguments.length||(t=d);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var s=ht.get(e);function c(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return s&&(e=s,l=vt),o?r?function(){var t=l(r,n(arguments));c.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=r}:c:r?I:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(r=a.match(n)){var i=this[a];this.removeEventListener(r[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=dt,dt.append=X.append,dt.empty=X.empty,dt.node=X.node,dt.call=X.call,dt.size=X.size,dt.select=function(t){for(var e,r,n,a,i,o=[],l=-1,s=this.length;++l=n&&(n=e+1);!(o=l[n])&&++n0?1:t<0?-1:0}function Pt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function Dt(t){return t>1?0:t<-1?Mt:Math.acos(t)}function Et(t){return t>1?St:t<-1?-St:Math.asin(t)}function It(t){return((t=Math.exp(t))+1/t)/2}function Nt(t){return(t=Math.sin(t/2))*t}var Rt=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,a=t[0],i=t[1],o=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-i,d=u*u+f*f;if(d0&&(e=e.transition().duration(g)),e.call(w.event)}function L(){c&&c.domain(s.range().map(function(t){return(t-d.x)/d.k}).map(s.invert)),f&&f.domain(u.range().map(function(t){return(t-d.y)/d.k}).map(u.invert))}function S(t){v++||t({type:"zoomstart"})}function C(t){L(),t({type:"zoom",scale:d.k,translate:[d.x,d.y]})}function O(t){--v||(t({type:"zoomend"}),r=null)}function z(){var e=this,r=_.of(e,arguments),n=0,a=t.select(o(e)).on(m,function(){n=1,M(t.mouse(e),i),C(r)}).on(x,function(){a.on(m,null).on(x,null),l(n),O(r)}),i=k(t.mouse(e)),l=xt(e);fl.call(e),S(r)}function P(){var e,r=this,n=_.of(r,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+o,c="touchend"+o,u=[],f=t.select(r),p=xt(r);function h(){var n=t.touches(r);return e=d.k,n.forEach(function(t){t.identifier in a&&(a[t.identifier]=k(t))}),n}function g(){var e=t.event.target;t.select(e).on(s,v).on(c,m),u.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){y=p[0];var x=p[1],b=y[0]-x[0],_=y[1]-x[1];i=b*b+_*_}}function v(){var o,s,c,u,f=t.touches(r);fl.call(r);for(var d=0,p=f.length;d360?t-=360:t<0&&(t+=360),t<60?n+(a-n)*t/60:t<180?a:t<240?n+(a-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(a=r<=.5?r*(1+e):r+e-r*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Yt?e.l:(e=de((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Ut(this.h,this.s,this.l)},t.hcl=Gt;var Zt=Gt.prototype=new Ht;function Xt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Yt(r,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Yt(t,e,r){return this instanceof Yt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Yt?new Yt(t.l,t.a,t.b):t instanceof Gt?Xt(t.h,t.c,t.l):de((t=ie(t)).r,t.g,t.b):new Yt(t,e,r)}Zt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Wt*(arguments.length?t:1)))},Zt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Wt*(arguments.length?t:1)))},Zt.rgb=function(){return Xt(this.h,this.c,this.l).rgb()},t.lab=Yt;var Wt=18,Jt=.95047,Qt=1,$t=1.08883,Kt=Yt.prototype=new Ht;function te(t,e,r){var n=(t+16)/116,a=n+e/500,i=n-r/200;return new ie(ae(3.2404542*(a=re(a)*Jt)-1.5371385*(n=re(n)*Qt)-.4985314*(i=re(i)*$t)),ae(-.969266*a+1.8760108*n+.041556*i),ae(.0556434*a-.2040259*n+1.0572252*i))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Ot,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,r){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ue(""+t,ie,Ut):new ie(t,e,r)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function le(t){return oe(t)+""}Kt.brighter=function(t){return new Yt(Math.min(100,this.l+Wt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Yt(Math.max(0,this.l-Wt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var se=ie.prototype=new Ht;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,r){var n,a,i,o=0,l=0,s=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=n[2].split(","),n[1]){case"hsl":return r(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(he(a[0]),he(a[1]),he(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,l=240&i,l|=l>>4,s=15&i,s|=s<<4):7===t.length&&(o=(16711680&i)>>16,l=(65280&i)>>8,s=255&i)),e(o,l,s))}function fe(t,e,r){var n,a,i=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),l=o-i,s=(o+i)/2;return l?(a=s<.5?l/(o+i):l/(2-o-i),n=t==o?(e-r)/l+(e0&&s<1?0:n),new qt(n,a,s)}function de(t,e,r){var n=ne((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(r=pe(r)))/Jt),a=ne((.2126729*t+.7151522*e+.072175*r)/Qt);return Yt(116*a-16,500*(n-a),200*(a-ne((.0193339*t+.119192*e+.9503041*r)/$t)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function he(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}se.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,a=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=a.call(o,c)}catch(t){return void l.error.call(o,t)}l.load.call(o,t)}else l.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var r=t.event;t.event=e;try{l.progress.call(o,c)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,a){if(2===arguments.length&&"function"==typeof n&&(a=n,n=null),c.open(t,e,!0),null==r||"accept"in s||(s.accept=r+",*/*"),c.setRequestHeader)for(var i in s)c.setRequestHeader(i,s[i]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=u&&(c.responseType=u),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),l.beforesend.call(o,c),c.send(null==n?null:n),o},o.abort=function(){return c.abort(),o},t.rebind(o,l,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=ye(z),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function a(t,r,n){arguments.length<3&&(n=r,r=null);var a=me(t,e,null==r?i:o(r),n);return a.row=function(t){return arguments.length?a.response(null==(r=t)?i:o(t)):r},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function l(e){return e.map(s).join(t)}function s(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var r;return a.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(a(t),r)}:a})},a.parseRows=function(t,e){var r,a,i={},o={},l=[],s=t.length,c=0,u=0;function f(){if(c>=s)return o;if(a)return a=!1,i;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Me,e)),_e=0):(_e=1,ke(Me))}function Ae(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Le(){for(var t,e=xe,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Se(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Ce[8+n/3]};var Oe=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ze=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Se(e,r))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),r))))}});function Pe(t){return t+""}var De=t.time={},Ee=Date;function Ie(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Ie.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ne.setUTCDate.apply(this._,arguments)},setDay:function(){Ne.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ne.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ne.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ne.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ne.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ne.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ne.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ne.setTime.apply(this._,arguments)}};var Ne=Date.prototype;function Re(t,e,r){function n(e){var r=t(e),n=i(r,1);return e-r1)for(;o68?1900:2e3),r+a[0].length):-1}function Je(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function Qe(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function $e(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ar(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=m(e)/60|0,a=m(e)%60;return r+qe(n,"0",2)+qe(a,"0",2)}function ir(t,e,r){He.lastIndex=0;var n=He.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),i.push(t.substring(r-=l,r+l)),!((s+=l+1)>e));)l=a[o=(o+1)%a.length];return i.reverse().join(n)}:z;return function(e){var n=Oe.exec(e),a=n[1]||" ",l=n[2]||">",s=n[3]||"-",c=n[4]||"",u=n[5],f=+n[6],d=n[7],p=n[8],h=n[9],g=1,v="",y="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===a&&"="===l)&&(u=a="0",l="="),h){case"n":d=!0,h="g";break;case"%":g=100,y="%",h="f";break;case"p":g=100,y="%",h="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+h.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":g=-1,h="r"}"$"===c&&(v=i[0],y=i[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):"e"!=h&&"f"!=h||(p=Math.max(0,Math.min(20,p)))),h=ze.get(h)||Pe;var b=u&&d;return function(e){var n=y;if(m&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===s?"":s;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),n=c.symbol+y}else e*=g;var _,w,k=(e=h(e,p)).lastIndexOf(".");if(k<0){var T=x?e.lastIndexOf("e"):-1;T<0?(_=e,w=""):(_=e.substring(0,T),w=e.substring(T))}else _=e.substring(0,k),w=r+e.substring(k+1);!u&&d&&(_=o(_,1/0));var M=v.length+_.length+w.length+(b?0:i.length),A=M"===l?A+i+e:"^"===l?A.substring(0,M>>=1)+i+e+A.substring(M):i+(b?e:A+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,a=e.time,i=e.periods,o=e.days,l=e.shortDays,s=e.months,c=e.shortMonths;function u(t){var e=t.length;function r(r){for(var n,a,i,o=[],l=-1,s=0;++l=c)return-1;if(37===(a=e.charCodeAt(l++))){if(o=e.charAt(l++),!(i=w[o in Be?e.charAt(l++):o])||(n=i(t,r,n))<0)return-1}else if(a!=r.charCodeAt(n++))return-1}return n}u.utc=function(t){var e=u(t);function r(t){try{var r=new(Ee=Ie);return r._=t,e(r)}finally{Ee=Date}}return r.parse=function(t){try{Ee=Ie;var r=e.parse(t);return r&&r._}finally{Ee=Date}},r.toString=e.toString,r},u.multi=u.utc.multi=or;var d=t.map(),p=Ve(o),h=Ue(o),g=Ve(l),v=Ue(l),y=Ve(s),m=Ue(s),x=Ve(c),b=Ue(c);i.forEach(function(t,e){d.set(t.toLowerCase(),e)});var _={a:function(t){return l[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:u(r),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+De.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(De.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(De.mondayOfYear(t),e,2)},x:u(n),X:u(a),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:ar,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=h.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){y.lastIndex=0;var n=y.exec(e.slice(r));return n?(t.m=m.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:$e,e:$e,H:tr,I:tr,j:Ke,L:nr,m:Qe,M:er,p:function(t,e,r){var n=d.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:Ze,w:Ge,W:Xe,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:We,Y:Ye,Z:Je,"%":ir};return u}(e)}};var lr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function sr(){}t.format=lr.numberFormat,t.geo={},sr.prototype={s:0,t:0,add:function(t){ur(t,this.t,cr),ur(cr.s,this.s,this),this.s?this.t+=cr.t:this.s=cr.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cr=new sr;function ur(t,e,r){var n=r.s=t+e,a=n-t,i=n-a;r.t=t-i+(e-a)}function fr(t,e){t&&pr.hasOwnProperty(t.type)&&pr[t.type](t,e)}t.geo.stream=function(t,e){t&&dr.hasOwnProperty(t.type)?dr[t.type](t,e):fr(t,e)};var dr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,a=r.length;++n=0?1:-1,l=o*i,s=Math.cos(e),c=Math.sin(e),u=a*c,f=n*s+u*Math.cos(l),d=u*o*Math.sin(l);Sr.add(Math.atan2(d,f)),r=t,n=s,a=c}Cr.point=function(o,l){Cr.point=i,r=(t=o)*Ct,n=Math.cos(l=(e=l)*Ct/2+Mt/4),a=Math.sin(l)},Cr.lineEnd=function(){i(t,e)}}function zr(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Pr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Dr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Er(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Ir(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Nr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Rr(t){return[Math.atan2(t[1],t[0]),Et(t[2])]}function Fr(t,e){return m(t[0]-e[0])kt?a=90:c<-kt&&(r=-90),f[0]=e,f[1]=n}};function p(t,i){u.push(f=[e=t,n=t]),ia&&(a=i)}function h(t,o){var l=zr([t*Ct,o*Ct]);if(s){var c=Dr(s,l),u=Dr([c[1],-c[0],0],c);Nr(u),u=Rr(u);var f=t-i,d=f>0?1:-1,h=u[0]*Ot*d,g=m(f)>180;if(g^(d*ia&&(a=v);else if(g^(d*i<(h=(h+360)%360-180)&&ha&&(a=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>i?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else p(t,o);s=l,i=t}function g(){d.point=h}function v(){f[0]=e,f[1]=n,d.point=p,s=null}function y(t,e){if(s){var r=t-i;c+=m(r)>180?r+(r>0?360:-360):r}else o=t,l=e;Cr.point(t,e),h(t,e)}function x(){Cr.lineStart()}function b(){y(o,l),Cr.lineEnd(),m(c)>kt&&(e=-(n=180)),f[0]=e,f[1]=n,s=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):l.push(g=p);for(var s,c,p,h=-1/0,g=(o=0,l[c=l.length-1]);o<=c;g=p,++o)p=l[o],(s=_(g[1],p[0]))>h&&(h=s,e=p[0],n=g[1])}return u=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,a]]}}(),t.geo.centroid=function(e){yr=mr=xr=br=_r=wr=kr=Tr=Mr=Ar=Lr=0,t.geo.stream(e,Br);var r=Mr,n=Ar,a=Lr,i=r*r+n*n+a*a;return i=0;--l)a.point((f=u[l])[0],f[1]);else n(p.x,p.p.x,-1,a);p=p.p}u=(p=p.o).z,h=!h}while(!p.v);a.lineEnd()}}}function Yr(t){if(e=t.length){for(var e,r,n=0,a=t[0];++n=0?1:-1,k=w*_,T=k>Mt,M=h*x;if(Sr.add(Math.atan2(M*w*Math.sin(k),g*b+M*Math.cos(k))),i+=T?_+w*At:_,T^d>=r^y>=r){var A=Dr(zr(f),zr(t));Nr(A);var L=Dr(a,A);Nr(L);var S=(T^_>=0?-1:1)*Et(L[2]);(n>S||n===S&&(A[0]||A[1]))&&(o+=T^_>=0?1:-1)}if(!v++)break;d=y,h=x,g=b,f=t}}return(i<-kt||i0){for(x||(o.polygonStart(),x=!0),o.lineStart();++i1&&2&e&&r.push(r.pop().concat(r.shift())),l.push(r.filter(Qr))}return u}}function Qr(t){return t.length>1}function $r(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:I,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-St-kt:St-t[1])-((e=e.x)[0]<0?e[1]-St-kt:St-e[1])}var tn=Jr(Zr,function(t){var e,r=NaN,n=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var l=i>0?Mt:-Mt,s=m(i-r);m(s-Mt)0?St:-St),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),t.point(i,n),e=0):a!==l&&s>=Mt&&(m(r-a)kt?Math.atan((Math.sin(e)*(i=Math.cos(n))*Math.sin(r)-Math.sin(n)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+n)/2}(r,n,i,o),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),e=0),t.point(r=i,n=o),a=l},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var a;if(null==t)a=r*St,n.point(-Mt,a),n.point(0,a),n.point(Mt,a),n.point(Mt,0),n.point(Mt,-a),n.point(0,-a),n.point(-Mt,-a),n.point(-Mt,0),n.point(-Mt,a);else if(m(t[0]-e[0])>kt){var i=t[0]0)){if(i/=d,d<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=r-s,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>u&&(u=i)}else if(d>0){if(i0)){if(i/=p,p<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=n-c,p||!(i<0)){if(i/=p,p<0){if(i>f)return;i>u&&(u=i)}else if(p>0){if(i0&&(a.a={x:s+u*d,y:c+u*p}),f<1&&(a.b={x:s+f*d,y:c+f*p}),a}}}}}}var rn=1e9;function nn(e,r,n,a){return function(s){var c,u,f,d,p,h,g,v,y,m,x,b=s,_=$r(),w=en(e,r,n,a),k={point:A,lineStart:function(){k.point=L,u&&u.push(f=[]);m=!0,y=!1,g=v=NaN},lineEnd:function(){c&&(L(d,p),h&&y&&_.rejoin(),c.push(_.buffer()));k.point=A,y&&s.lineEnd()},polygonStart:function(){s=_,c=[],u=[],x=!0},polygonEnd:function(){s=b,c=t.merge(c);var r=function(t){for(var e=0,r=u.length,n=t[1],a=0;an&&Pt(c,i,t)>0&&++e:i[1]<=n&&Pt(c,i,t)<0&&--e,c=i;return 0!==e}([e,a]),n=x&&r,i=c.length;(n||i)&&(s.polygonStart(),n&&(s.lineStart(),T(null,null,1,s),s.lineEnd()),i&&Xr(c,o,r,T,s),s.polygonEnd()),c=u=f=null}};function T(t,o,s,c){var u=0,f=0;if(null==t||(u=i(t,s))!==(f=i(o,s))||l(t,o)<0^s>0)do{c.point(0===u||3===u?e:n,u>1?a:r)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function M(t,i){return e<=t&&t<=n&&r<=i&&i<=a}function A(t,e){M(t,e)&&s.point(t,e)}function L(t,e){var r=M(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(u&&f.push([t,e]),m)d=t,p=e,h=r,m=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&y)s.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(y||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),x=!1):r&&(s.lineStart(),s.point(t,e),x=!1)}g=t,v=e,y=r}return k};function i(t,a){return m(t[0]-e)0?0:3:m(t[0]-n)0?2:1:m(t[1]-r)0?1:0:a>0?3:2}function o(t,e){return l(t.x,e.x)}function l(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Mt/3,n=Cn(t),a=n(e,r);return a.parallels=function(t){return arguments.length?n(e=t[0]*Mt/180,r=t[1]*Mt/180):[e/Mt*180,r/Mt*180]},a}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,a=1+r*(2*n-r),i=Math.sqrt(a)/n;function o(t,e){var r=Math.sqrt(a-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),i-r*Math.cos(t)]}return o.invert=function(t,e){var r=i-e;return[Math.atan2(t,r)/n,Et((a-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(l){return arguments.length?(i=nn(t=+l[0][0],e=+l[0][1],r=+l[1][0],n=+l[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,r){e=[t,r]}};function c(t){var i=t[0],o=t[1];return e=null,r(i,o),e||(n(i,o),e)||a(i,o),e}return c.invert=function(t){var e=i.scale(),r=i.translate(),n=(t[0]-r[0])/e,a=(t[1]-r[1])/e;return(a>=.12&&a<.234&&n>=-.425&&n<-.214?o:a>=.166&&a<.234&&n>=-.214&&n<-.115?l:i).invert(t)},c.stream=function(t){var e=i.stream(t),r=o.stream(t),n=l.stream(t);return{point:function(t,a){e.point(t,a),r.point(t,a),n.point(t,a)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),l.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),l.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),u=+t[0],f=+t[1];return r=i.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(s).point,n=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(s).point,a=l.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(s).point,c},c.scale(1070)};var ln,sn,cn,un,fn,dn,pn={point:I,lineStart:I,lineEnd:I,polygonStart:function(){sn=0,pn.lineStart=hn},polygonEnd:function(){pn.lineStart=pn.lineEnd=pn.point=I,ln+=m(sn/2)}};function hn(){var t,e,r,n;function a(t,e){sn+=n*t-r*e,r=t,n=e}pn.point=function(i,o){pn.point=a,t=r=i,e=n=o},pn.lineEnd=function(){a(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);edn&&(dn=e)},lineStart:I,lineEnd:I,polygonStart:I,polygonEnd:I};function vn(){var t=yn(4.5),e=[],r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=yn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function a(t,n){e.push("M",t,",",n),r.point=i}function i(t,r){e.push("L",t,",",r)}function o(){r.point=n}function l(){e.push("Z")}return r}function yn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var mn,xn={point:bn,lineStart:_n,lineEnd:wn,polygonStart:function(){xn.lineStart=kn},polygonEnd:function(){xn.point=bn,xn.lineStart=_n,xn.lineEnd=wn}};function bn(t,e){xr+=t,br+=e,++_r}function _n(){var t,e;function r(r,n){var a=r-t,i=n-e,o=Math.sqrt(a*a+i*i);wr+=o*(t+r)/2,kr+=o*(e+n)/2,Tr+=o,bn(t=r,e=n)}xn.point=function(n,a){xn.point=r,bn(t=n,e=a)}}function wn(){xn.point=bn}function kn(){var t,e,r,n;function a(t,e){var a=t-r,i=e-n,o=Math.sqrt(a*a+i*i);wr+=o*(r+t)/2,kr+=o*(n+e)/2,Tr+=o,Mr+=(o=n*t-r*e)*(r+t),Ar+=o*(n+e),Lr+=3*o,bn(r=t,n=e)}xn.point=function(i,o){xn.point=a,bn(t=r=i,e=n=o)},xn.lineEnd=function(){a(t,e)}}function Tn(t){var e=4.5,r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:I};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,At)}function a(e,n){t.moveTo(e,n),r.point=i}function i(e,r){t.lineTo(e,r)}function o(){r.point=n}function l(){t.closePath()}return r}function Mn(t){var e=.5,r=Math.cos(30*Ct),n=16;function a(e){return(n?function(e){var r,a,o,l,s,c,u,f,d,p,h,g,v={point:y,lineStart:m,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=m}};function y(r,n){r=t(r,n),e.point(r[0],r[1])}function m(){f=NaN,v.point=x,e.lineStart()}function x(r,a){var o=zr([r,a]),l=t(r,a);i(f,d,u,p,h,g,f=l[0],d=l[1],u=r,p=o[0],h=o[1],g=o[2],n,e),e.point(f,d)}function b(){v.point=y,e.lineEnd()}function _(){m(),v.point=w,v.lineEnd=k}function w(t,e){x(r=t,e),a=f,o=d,l=p,s=h,c=g,v.point=x}function k(){i(f,d,u,p,h,g,a,o,r,l,s,c,n,e),v.lineEnd=b,b()}return v}:function(e){return Ln(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function i(n,a,o,l,s,c,u,f,d,p,h,g,v,y){var x=u-n,b=f-a,_=x*x+b*b;if(_>4*e&&v--){var w=l+p,k=s+h,T=c+g,M=Math.sqrt(w*w+k*k+T*T),A=Math.asin(T/=M),L=m(m(T)-1)e||m((x*z+b*P)/_-.5)>.3||l*p+s*h+c*g0&&16,a):Math.sqrt(e)},a}function An(t){this.stream=t}function Ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sn(t){return Cn(function(){return t})()}function Cn(e){var r,n,a,i,o,l,s=Mn(function(t,e){return[(t=r(t,e))[0]*c+i,o-t[1]*c]}),c=150,u=480,f=250,d=0,p=0,h=0,g=0,v=0,y=tn,x=z,b=null,_=null;function w(t){return[(t=a(t[0]*Ct,t[1]*Ct))[0]*c+i,o-t[1]*c]}function k(t){return(t=a.invert((t[0]-i)/c,(o-t[1])/c))&&[t[0]*Ot,t[1]*Ot]}function T(){a=Gr(n=Dn(h,g,v),r);var t=r(d,p);return i=u-t[0]*c,o=f+t[1]*c,M()}function M(){return l&&(l.valid=!1,l=null),w}return w.stream=function(t){return l&&(l.valid=!1),(l=On(y(n,s(x(t))))).valid=!0,l},w.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,tn):function(t){var e=Math.cos(t),r=e>0,n=m(e)>kt;return Jr(a,function(t){var e,l,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var p,h=[f,d],g=a(f,d),v=r?g?0:o(f,d):g?o(f+(f<0?Mt:-Mt),d):0;if(!e&&(c=s=g)&&t.lineStart(),g!==s&&(p=i(e,h),(Fr(e,p)||Fr(h,p))&&(h[0]+=kt,h[1]+=kt,g=a(h[0],h[1]))),g!==s)u=0,g?(t.lineStart(),p=i(h,e),t.point(p[0],p[1])):(p=i(e,h),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(n&&e&&r^g){var y;v&l||!(y=i(h,e,!0))||(u=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!g||e&&Fr(e,h)||t.point(h[0],h[1]),e=h,s=g,l=v},lineEnd:function(){s&&t.lineEnd(),e=null},clean:function(){return u|(c&&s)<<1}}},Rn(t,6*Ct),r?[0,-t]:[-Mt,t-Mt]);function a(t,r){return Math.cos(t)*Math.cos(r)>e}function i(t,r,n){var a=[1,0,0],i=Dr(zr(t),zr(r)),o=Pr(i,i),l=i[0],s=o-l*l;if(!s)return!n&&t;var c=e*o/s,u=-e*l/s,f=Dr(a,i),d=Ir(a,c);Er(d,Ir(i,u));var p=f,h=Pr(d,p),g=Pr(p,p),v=h*h-g*(Pr(d,d)-1);if(!(v<0)){var y=Math.sqrt(v),x=Ir(p,(-h-y)/g);if(Er(x,d),x=Rr(x),!n)return x;var b,_=t[0],w=r[0],k=t[1],T=r[1];w<_&&(b=_,_=w,w=b);var M=w-_,A=m(M-Mt)0^x[1]<(m(x[0]-_)Mt^(_<=x[0]&&x[0]<=w)){var L=Ir(p,(-h+y)/g);return Er(L,d),[x,Rr(L)]}}}function o(e,n){var a=r?t:Mt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),n<-a?i|=4:n>a&&(i|=8),i}}((b=+t)*Ct),M()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):z,M()):_},w.scale=function(t){return arguments.length?(c=+t,T()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],T()):[u,f]},w.center=function(t){return arguments.length?(d=t[0]%360*Ct,p=t[1]%360*Ct,T()):[d*Ot,p*Ot]},w.rotate=function(t){return arguments.length?(h=t[0]%360*Ct,g=t[1]%360*Ct,v=t.length>2?t[2]%360*Ct:0,T()):[h*Ot,g*Ot,v*Ot]},t.rebind(w,s,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&k,T()}}function On(t){return Ln(t,function(e,r){t.point(e*Ct,r*Ct)})}function zn(t,e){return[t,e]}function Pn(t,e){return[t>Mt?t-At:t<-Mt?t+At:t,e]}function Dn(t,e,r){return t?e||r?Gr(In(t),Nn(e,r)):In(t):e||r?Nn(e,r):Pn}function En(t){return function(e,r){return[(e+=t)>Mt?e-At:e<-Mt?e+At:e,r]}}function In(t){var e=En(t);return e.invert=En(-t),e}function Nn(t,e){var r=Math.cos(t),n=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*r+l*n;return[Math.atan2(s*a-u*i,l*r-c*n),Et(u*a+s*i)]}return o.invert=function(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*a-s*i;return[Math.atan2(s*a+c*i,l*r+u*n),Et(u*r-l*n)]},o}function Rn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(a,i,o,l){var s=o*e;null!=a?(a=Fn(r,a),i=Fn(r,i),(o>0?ai)&&(a+=o*At)):(a=t+o*At,i=t-.5*s);for(var c,u=a;o>0?u>i:u2?t[2]*Ct:0),e.invert=function(e){return(e=t.invert(e[0]*Ct,e[1]*Ct))[0]*=Ot,e[1]*=Ot,e},e},Pn.invert=zn,t.geo.circle=function(){var t,e,r=[0,0],n=6;function a(){var t="function"==typeof r?r.apply(this,arguments):r,n=Dn(-t[0]*Ct,-t[1]*Ct,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=n(t,e)),t[0]*=Ot,t[1]*=Ot}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(r=t,a):r},a.angle=function(r){return arguments.length?(e=Rn((t=+r)*Ct,n*Ct),a):t},a.precision=function(r){return arguments.length?(e=Rn(t*Ct,(n=+r)*Ct),a):n},a.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Ct,a=t[1]*Ct,i=e[1]*Ct,o=Math.sin(n),l=Math.cos(n),s=Math.sin(a),c=Math.cos(a),u=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-s*f*l)*r),s*u+c*f*l)},t.geo.graticule=function(){var e,r,n,a,i,o,l,s,c,u,f,d,p=10,h=p,g=90,v=360,y=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(a/g)*g,n,g).map(f).concat(t.range(Math.ceil(s/v)*v,l,v).map(d)).concat(t.range(Math.ceil(r/p)*p,e,p).filter(function(t){return m(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/h)*h,i,h).filter(function(t){return m(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(d(l).slice(1),f(n).reverse().slice(1),d(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(a=+t[0][0],n=+t[1][0],s=+t[0][1],l=+t[1][1],a>n&&(t=a,a=n,n=t),s>l&&(t=s,s=l,l=t),x.precision(y)):[[a,s],[n,l]]},x.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),o>i&&(t=o,o=i,i=t),x.precision(y)):[[r,o],[e,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],h=+t[1],x):[p,h]},x.precision=function(t){return arguments.length?(y=+t,c=Bn(o,i,90),u=jn(r,e,y),f=Bn(s,l,90),d=jn(a,n,y),x):y},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,r,n=Hn,a=qn;function i(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||a.apply(this,arguments))},i.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,i):n},i.target=function(t){return arguments.length?(a=t,r="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return r=t[0]*Ct,n=t[1]*Ct,a=e[0]*Ct,i=e[1]*Ct,o=Math.cos(n),l=Math.sin(n),s=Math.cos(i),c=Math.sin(i),u=o*Math.cos(r),f=o*Math.sin(r),d=s*Math.cos(a),p=s*Math.sin(a),h=2*Math.asin(Math.sqrt(Nt(i-n)+o*s*Nt(a-r))),g=1/Math.sin(h),(v=h?function(t){var e=Math.sin(t*=h)*g,r=Math.sin(h-t)*g,n=r*u+e*d,a=r*f+e*p,i=r*l+e*c;return[Math.atan2(a,n)*Ot,Math.atan2(i,Math.sqrt(n*n+a*a))*Ot]}:function(){return[r*Ot,n*Ot]}).distance=h,v;var r,n,a,i,o,l,s,c,u,f,d,p,h,g,v},t.geo.length=function(e){return mn=0,t.geo.stream(e,Vn),mn};var Vn={sphere:I,point:I,lineStart:function(){var t,e,r;function n(n,a){var i=Math.sin(a*=Ct),o=Math.cos(a),l=m((n*=Ct)-t),s=Math.cos(l);mn+=Math.atan2(Math.sqrt((l=o*Math.sin(l))*l+(l=r*i-e*o*s)*l),e*i+r*o*s),t=n,e=i,r=o}Vn.point=function(a,i){t=a*Ct,e=Math.sin(i*=Ct),r=Math.cos(i),Vn.point=n},Vn.lineEnd=function(){Vn.point=Vn.lineEnd=I}},lineEnd:I,polygonStart:I,polygonEnd:I};function Un(t,e){function r(e,r){var n=Math.cos(e),a=Math.cos(r),i=t(n*a);return[i*a*Math.sin(e),i*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),a=e(n),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,n*o),Math.asin(n&&r*i/n)]},r}var Gn=Un(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sn(Gn)}).raw=Gn;var Zn=Un(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},z);function Xn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Mt/4+t/2)},a=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),i=r*Math.pow(n(t),a)/a;if(!a)return Jn;function o(t,e){i>0?e<-St+kt&&(e=-St+kt):e>St-kt&&(e=St-kt);var r=i/Math.pow(n(e),a);return[r*Math.sin(a*t),i-r*Math.cos(a*t)]}return o.invert=function(t,e){var r=i-e,n=zt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(i/n,1/a))-St]},o}function Yn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),a=r/n+t;if(m(n)1&&Pt(t[r[n-2]],t[r[n-1]],t[a])<=0;)--n;r[n++]=a}return r.slice(0,n)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sn(Kn)}).raw=Kn,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=Qn(ta),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,r=ra;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,a=ve(e),i=ve(r),o=t.length,l=[],s=[];for(n=0;n=0;--n)p.push(t[l[c[n]][2]]);for(n=+f;nkt)l=l.L;else{if(!((a=i-wa(l,o))>kt)){n>-kt?(e=l.P,r=l):a>-kt?(e=l,r=l.N):e=r=l;break}if(!l.R){e=l;break}l=l.R}var s=ya(t);if(fa.insert(e,s),e||r){if(e===r)return La(e),r=ya(e.site),fa.insert(s,r),s.edge=r.edge=Oa(e.site,s.site),Aa(e),void Aa(r);if(r){La(e),La(r);var c=e.site,u=c.x,f=c.y,d=t.x-u,p=t.y-f,h=r.site,g=h.x-u,v=h.y-f,y=2*(d*v-p*g),m=d*d+p*p,x=g*g+v*v,b={x:(v*m-p*x)/y+u,y:(d*x-g*m)/y+f};za(r.edge,c,h,b),s.edge=Oa(c,t,null,b),r.edge=Oa(t,h,null,b),Aa(e),Aa(r)}else s.edge=Oa(e.site,s.site)}}function _a(t,e){var r=t.site,n=r.x,a=r.y,i=a-e;if(!i)return n;var o=t.P;if(!o)return-1/0;var l=(r=o.site).x,s=r.y,c=s-e;if(!c)return l;var u=l-n,f=1/i-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-i/2)))/f+n:(n+l)/2}function wa(t,e){var r=t.N;if(r)return _a(r,e);var n=t.site;return n.y===e?n.x:1/0}function ka(t){this.site=t,this.edges=[]}function Ta(t,e){return e.angle-t.angle}function Ma(){Ea(this),this.x=this.y=this.arc=this.site=this.cy=null}function Aa(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,a=t.site,i=r.site;if(n!==i){var o=a.x,l=a.y,s=n.x-o,c=n.y-l,u=i.x-o,f=2*(s*(v=i.y-l)-c*u);if(!(f>=-Tt)){var d=s*s+c*c,p=u*u+v*v,h=(v*d-c*p)/f,g=(s*p-u*d)/f,v=g+l,y=ga.pop()||new Ma;y.arc=t,y.site=a,y.x=h+o,y.y=v+Math.sqrt(h*h+g*g),y.cy=v,t.circle=y;for(var m=null,x=pa._;x;)if(y.y=l)return;if(d>h){if(i){if(i.y>=c)return}else i={x:v,y:s};r={x:v,y:c}}else{if(i){if(i.y1)if(d>h){if(i){if(i.y>=c)return}else i={x:(s-a)/n,y:s};r={x:(c-a)/n,y:c}}else{if(i){if(i.y=l)return}else i={x:o,y:n*o+a};r={x:l,y:n*l+a}}else{if(i){if(i.xkt||m(a-r)>kt)&&(l.splice(o,0,new Pa((y=i.site,x=u,b=m(n-f)kt?{x:f,y:m(e-f)kt?{x:m(r-h)kt?{x:d,y:m(e-d)kt?{x:m(r-p)=r&&c.x<=a&&c.y>=n&&c.y<=o?[[r,o],[a,o],[a,n],[r,n]]:[]).point=t[l]}),e}function l(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/kt)*kt,y:Math.round(a(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Fa(l(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fa(l(t)).cells.forEach(function(r,n){for(var a,i,o,l,s=r.site,c=r.edges.sort(Ta),u=-1,f=c.length,d=c[f-1].edge,p=d.l===s?d.r:d.l;++ui&&(a=e.slice(i,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(n=n[0])?l[o]?l[o]+=n:l[++o]=n:(l[++o]=null,s.push({i:o,x:Ga(r,n)})),i=Ya.lastIndex;return ig&&(g=s.x),s.y>v&&(v=s.y),c.push(s.x),u.push(s.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-h;function T(t,e,r,n,a,i,o,l){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var s=t.x,c=t.y;if(null!=s)if(m(s-r)+m(c-n)<.01)M(t,e,r,n,a,i,o,l);else{var u=t.point;t.x=t.y=t.point=null,M(t,u,s,c,a,i,o,l),M(t,e,r,n,a,i,o,l)}else t.x=r,t.y=n,t.point=e}else M(t,e,r,n,a,i,o,l)}function M(t,e,r,n,a,i,o,l){var s=.5*(a+o),c=.5*(i+l),u=r>=s,f=n>=c,d=f<<1|u;t.leaf=!1,u?a=s:o=s,f?i=c:l=c,T(t=t.nodes[d]||(t.nodes[d]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}}),e,r,n,a,i,o,l)}w>k?v=h+w:g=p+k;var A={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}};if(A.visit=function(t){!function t(e,r,n,a,i,o){if(!e(r,n,a,i,o)){var l=.5*(n+i),s=.5*(a+o),c=r.nodes;c[0]&&t(e,c[0],n,a,l,s),c[1]&&t(e,c[1],l,a,i,s),c[2]&&t(e,c[2],n,s,l,o),c[3]&&t(e,c[3],l,s,i,o)}}(t,A,p,h,g,v)},A.find=function(t){return function(t,e,r,n,a,i,o){var l,s=1/0;return function t(c,u,f,d,p){if(!(u>i||f>o||d=_)<<1|e>=b,k=w+4;w=0&&!(n=t.interpolators[a](e,r)););return n}function Ja(t,e){var r,n=[],a=[],i=t.length,o=e.length,l=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function ii(t){return 1-Math.cos(t*St)}function oi(t){return Math.pow(2,10*(t-1))}function li(t){return 1-Math.sqrt(1-t*t)}function si(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ci(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ui(t){var e,r,n,a=[t.a,t.b],i=[t.c,t.d],o=di(a),l=fi(a,i),s=di(((e=i)[0]+=(n=-l)*(r=a)[0],e[1]+=n*r[1],e))||0;a[0]*i[1]=0?t.slice(0,n):t,i=n>=0?t.slice(n+1):"in";return a=$a.get(a)||Qa,i=Ka.get(i)||z,e=i(a.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,a=e.c,i=e.l,o=r.h-n,l=r.c-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.c:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Xt(n+o*t,a+l*t,i+s*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,a=e.s,i=e.l,o=r.h-n,l=r.s-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.s:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ut(n+o*t,a+l*t,i+s*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,a=e.a,i=e.b,o=r.l-n,l=r.a-a,s=r.b-i;return function(t){return te(n+o*t,a+l*t,i+s*t)+""}},t.interpolateRound=ci,t.transform=function(e){var r=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ui(e?e.matrix:pi)})(e)},ui.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pi={a:1,b:0,c:0,d:1,e:0,f:0};function hi(t){return t.length?t.pop()+",":""}function gi(e,r){var n=[],a=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push("translate(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,a),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(hi(r)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&r.push(hi(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,a),function(t,e,r,n){t!==e?n.push({i:r.push(hi(r)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&r.push(hi(r)+"skewX("+e+")")}(e.skew,r.skew,n,a),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push(hi(r)+"scale(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(hi(r)+"scale("+e+")")}(e.scale,r.scale,n,a),e=r=null,function(t){for(var e,r=-1,i=a.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,s.end({type:"end",alpha:n=0})):t>0&&(s.start({type:"start",alpha:n=t}),e=Te(l.tick)),l):n},l.start=function(){var t,e,r,n=y.length,s=m.length,u=c[0],h=c[1];for(t=0;t=0;)r.push(a[n])}function Ci(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(u=c[s]),u.parent=i,u.depth=i.depth+1;r&&(i.value=0),i.children=c}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Ci(a,function(e){var n,a;t&&(n=e.children)&&n.sort(t),r&&(a=e.parent)&&(a.value+=e.value)}),l}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Si(t,function(t){t.children&&(t.value=0)}),Ci(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var a=e.call(this,t,n);return function t(e,r,n,a){var i=e.children;if(e.x=r,e.y=e.depth*a,e.dx=n,e.dy=a,i&&(o=i.length)){var o,l,s,c=-1;for(n=e.value?n/e.value:0;++cl&&(l=n),o.push(n)}for(r=0;ra&&(n=r,a=e);return n}function Vi(t){return t.reduce(Ui,0)}function Ui(t,e){return t+e[1]}function Gi(t,e){return Zi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Zi(t,e){for(var r=-1,n=+t[0],a=(t[1]-n)/e,i=[];++r<=e;)i[r]=a*r+n;return i}function Xi(e){return[t.min(e),t.max(e)]}function Yi(t,e){return t.value-e.value}function Wi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function Qi(t,e){var r=e.x-t.x,n=e.y-t.y,a=t.r+e.r;return.999*a*a>r*r+n*n}function $i(t){if((e=t.children)&&(s=e.length)){var e,r,n,a,i,o,l,s,c=1/0,u=-1/0,f=1/0,d=-1/0;if(e.forEach(Ki),(r=e[0]).x=-r.r,r.y=0,x(r),s>1&&((n=e[1]).x=n.r,n.y=0,x(n),s>2))for(eo(r,n,a=e[2]),x(a),Wi(r,a),r._pack_prev=a,Wi(a,n),n=r._pack_next,i=3;i0)for(o=-1;++o=f[0]&&s<=f[1]&&((l=c[t.bisect(d,s,1,h)-1]).y+=g,l.push(i[o]));return c}return i.value=function(t){return arguments.length?(r=t,i):r},i.range=function(t){return arguments.length?(n=ve(t),i):n},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Zi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Yi),n=0,a=[1,1];function i(t,i){var o=r.call(this,t,i),l=o[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,Ci(l,function(t){t.r=+u(t.value)}),Ci(l,$i),n){var f=n*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;Ci(l,function(t){t.r+=f}),Ci(l,$i),Ci(l,function(t){t.r-=f})}return function t(e,r,n,a){var i=e.children;e.x=r+=a*e.x;e.y=n+=a*e.y;e.r*=a;if(i)for(var o=-1,l=i.length;++op.x&&(p=t),t.depth>h.depth&&(h=t)});var g=r(d,p)/2-d.x,v=n[0]/(p.x+r(p,d)/2+g),y=n[1]/(h.depth||1);Si(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*y})}return c}function o(t){var e=t.children,n=t.parent.children,a=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+r(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+r(t._,a._));t.parent.A=function(t,e,n){if(e){for(var a,i=t,o=t,l=e,s=i.parent.children[0],c=i.m,u=o.m,f=l.m,d=s.m;l=ao(l),i=no(i),l&&i;)s=no(s),(o=ao(o)).a=t,(a=l.z+f-i.z-c+r(l._,i._))>0&&(io(oo(l,t,n),t,a),c+=a,u+=a),f+=l.m,c+=i.m,d+=s.m,u+=o.m;l&&!ao(o)&&(o.t=l,o.m+=f-u),i&&!no(s)&&(s.t=i,s.m+=c-d,n=t)}return n}(t,a,t.parent.A||n[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=n[0],t.y=t.depth*n[1]}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t)?s:null,i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null==(n=t)?null:s,i):a?n:null},Li(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],a=!1;function i(i,o){var l,s=e.call(this,i,o),c=s[0],u=0;Ci(c,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=l?u+=r(e,l):0,e.y=0,l=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(c),d=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(c),p=f.x-r(f,d)/2,h=d.x+r(d,f)/2;return Ci(c,a?function(t){t.x=(t.x-c.x)*n[0],t.y=(c.y-t.y)*n[1]}:function(t){t.x=(t.x-p)/(h-p)*n[0],t.y=(1-(c.y?t.y/c.y:1))*n[1]}),s}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t),i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null!=(n=t),i):a?n:null},Li(i,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,a=[1,1],i=null,o=lo,l=!1,s="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var r,n,a=-1,i=t.length;++a0;)l.push(r=c[a-1]),l.area+=r.area,"squarify"!==s||(n=p(l,g))<=d?(c.pop(),d=n):(l.area-=l.pop().area,h(l,g,i,!1),g=Math.min(i.dx,i.dy),l.length=l.area=0,d=1/0);l.length&&(h(l,g,i,!0),l.length=l.area=0),e.forEach(f)}}function d(t){var e=t.children;if(e&&e.length){var r,n=o(t),a=e.slice(),i=[];for(u(a,n.dx*n.dy/t.value),i.area=0;r=a.pop();)i.push(r),i.area+=r.area,null!=r.z&&(h(i,r.z?n.dx:n.dy,n,!a.length),i.length=i.area=0);e.forEach(d)}}function p(t,e){for(var r,n=t.area,a=0,i=1/0,o=-1,l=t.length;++oa&&(a=r));return e*=e,(n*=n)?Math.max(e*a*c/n,n/(e*i*c)):1/0}function h(t,e,r,a){var i,o=-1,l=t.length,s=r.x,c=r.y,u=e?n(t.area/e):0;if(e==r.dx){for((a||u>r.dy)&&(u=r.dy);++or.dx)&&(u=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,l=a?yi:vi;return i=t(e,r,l,n),o=t(r,e,l,Wa),s}function s(t){return i(t)}s.invert=function(t){return o(t)};s.domain=function(t){return arguments.length?(e=t.map(Number),l()):e};s.range=function(t){return arguments.length?(r=t,l()):r};s.rangeRound=function(t){return s.range(t).interpolate(ci)};s.clamp=function(t){return arguments.length?(a=t,l()):a};s.interpolate=function(t){return arguments.length?(n=t,l()):n};s.ticks=function(t){return bo(e,t)};s.tickFormat=function(t,r){return _o(e,t,r)};s.nice=function(t){return mo(e,t),l()};s.copy=function(){return t(e,r,n,a)};return l()}([0,1],[0,1],Wa,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function l(t){return a?Math.pow(n,t):-Math.pow(n,-t)}function s(t){return r(o(t))}s.invert=function(t){return l(r.invert(t))};s.domain=function(t){return arguments.length?(a=t[0]>=0,r.domain((i=t.map(Number)).map(o)),s):i};s.base=function(t){return arguments.length?(n=+t,r.domain(i.map(o)),s):n};s.nice=function(){var t=po(i.map(o),a?Math:Mo);return r.domain(t),i=t.map(l),s};s.ticks=function(){var t=co(i),e=[],r=t[0],s=t[1],c=Math.floor(o(r)),u=Math.ceil(o(s)),f=n%1?2:n;if(isFinite(u-c)){if(a){for(;c0;d--)e.push(l(c)*d);for(c=0;e[c]s;u--);e=e.slice(c,u)}return e};s.tickFormat=function(e,r){if(!arguments.length)return To;arguments.length<2?r=To:"function"!=typeof r&&(r=t.format(r));var a=Math.max(1,n*e/s.ticks().length);return function(t){var e=t/l(Math.round(o(t)));return e*n0?a[t-1]:r[0],tf?0:1;if(c=Lt)return s(c,p)+(l?s(l,1-p):"")+"Z";var h,g,v,y,m,x,b,_,w,k,T,M,A=0,L=0,S=[];if((y=(+o.apply(this,arguments)||0)/2)&&(v=n===Po?Math.sqrt(l*l+c*c):+n.apply(this,arguments),p||(L*=-1),c&&(L=Et(v/c*Math.sin(y))),l&&(A=Et(v/l*Math.sin(y)))),c){m=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var C=Math.abs(f-u-2*L)<=Mt?0:1;if(L&&Fo(m,x,b,_)===p^C){var O=(u+f)/2;m=c*Math.cos(O),x=c*Math.sin(O),b=_=null}}else m=x=0;if(l){w=l*Math.cos(f-A),k=l*Math.sin(f-A),T=l*Math.cos(u+A),M=l*Math.sin(u+A);var z=Math.abs(u-f+2*A)<=Mt?0:1;if(A&&Fo(w,k,T,M)===1-p^z){var P=(u+f)/2;w=l*Math.cos(P),k=l*Math.sin(P),T=M=null}}else w=k=0;if(d>kt&&(h=Math.min(Math.abs(c-l)/2,+r.apply(this,arguments)))>.001){g=l0?0:1}function Bo(t,e,r,n,a){var i=t[0]-e[0],o=t[1]-e[1],l=(a?n:-n)/Math.sqrt(i*i+o*o),s=l*o,c=-l*i,u=t[0]+s,f=t[1]+c,d=e[0]+s,p=e[1]+c,h=(u+d)/2,g=(f+p)/2,v=d-u,y=p-f,m=v*v+y*y,x=r-n,b=u*p-d*f,_=(y<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-b*b)),w=(b*y-v*_)/m,k=(-b*v-y*_)/m,T=(b*y+v*_)/m,M=(-b*v+y*_)/m,A=w-h,L=k-g,S=T-h,C=M-g;return A*A+L*L>S*S+C*C&&(w=T,k=M),[[w-s,k-c],[w*r/x,k*r/x]]}function jo(t){var e=ea,r=ra,n=Zr,a=qo,i=a.key,o=.7;function l(i){var l,s=[],c=[],u=-1,f=i.length,d=ve(e),p=ve(r);function h(){s.push("M",a(t(c),o))}for(;++u1&&a.push("H",n[0]);return a.join("")},"step-before":Uo,"step-after":Go,basis:Yo,"basis-open":function(t){if(t.length<4)return qo(t);var e,r=[],n=-1,a=t.length,i=[0],o=[0];for(;++n<3;)e=t[n],i.push(e[0]),o.push(e[1]);r.push(Wo($o,i)+","+Wo($o,o)),--n;for(;++n9&&(a=3*e/Math.sqrt(a),o[l]=a*r,o[l+1]=a*n));l=-1;for(;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+o[l]*o[l])),i.push([a||0,o[l]*a||0]);return i}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Vo(t){return t.join("L")+"Z"}function Uo(t){for(var e=0,r=t.length,n=t[0],a=[n[0],",",n[1]];++e1){l=e[1],i=t[s],s++,n+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-l[0])+","+(i[1]-l[1])+","+i[0]+","+i[1];for(var c=2;cMt)+",1 "+e}function s(t,e,r,n){return"Q 0,0 "+n}return i.radius=function(t){return arguments.length?(r=ve(t),i):r},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(n=ve(t),i):n},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Hn,e=qn,r=al;function n(n,a){var i=t.call(this,n,a),o=e.call(this,n,a),l=(i.y+o.y)/2,s=[i,{x:i.x,y:l},{x:o.x,y:l},o];return"M"+(s=s.map(r))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=al,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-St;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=ol,e=il;function r(r,n){return(sl.get(t.call(this,r,n))||ll)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var sl=t.map({circle:ll,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*ul)),r=e*ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=sl.keys();var cl=Math.sqrt(3),ul=Math.tan(30*Ct);X.transition=function(t){for(var e,r,n=hl||++yl,a=bl(t),i=[],o=gl||{time:Date.now(),ease:ai,delay:0,duration:250},l=-1,s=this.length;++l0;)c[--d].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[n]:delete t[r],1}f||(i=a.time,o=Te(function(t){var e=f.delay;if(o.t=e+i,e<=t)return d(t-e);o.c=d},0,i),f=u[n]={tween:new b,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++u.count)}vl.call=X.call,vl.empty=X.empty,vl.node=X.node,vl.size=X.size,t.transition=function(e,r){return e&&e.transition?hl?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vl,vl.select=function(t){var e,r,n,a=this.id,i=this.namespace,o=[];t=Y(t);for(var l=-1,s=this.length;++lrect,.s>rect").attr("width",l[1]-l[0])}function g(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function v(){var f,v,y=this,m=t.select(t.event.target),x=n.of(y,arguments),b=t.select(y),_=m.datum(),w=!/^(n|s)$/.test(_)&&a,k=!/^(e|w)$/.test(_)&&i,T=m.classed("extent"),M=xt(y),A=t.mouse(y),L=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(T||(f=null,A[0]-=l[1],A[1]-=s[1],T=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==T&&(A[0]+=l[1],A[1]+=s[1],T=0,F())});if(t.event.changedTouches?L.on("touchmove.brush",O).on("touchend.brush",P):L.on("mousemove.brush",O).on("mouseup.brush",P),b.interrupt().selectAll("*").interrupt(),T)A[0]=l[0]-A[0],A[1]=s[0]-A[1];else if(_){var S=+/w$/.test(_),C=+/^n/.test(_);v=[l[1-S]-A[0],s[1-C]-A[1]],A[0]=l[S],A[1]=s[C]}else t.event.altKey&&(f=A.slice());function O(){var e=t.mouse(y),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),T||(t.event.altKey?(f||(f=[(l[0]+l[1])/2,(s[0]+s[1])/2]),A[0]=l[+(e[0]1?{floor:function(e){for(;l(e=t.floor(e));)e=Dl(e-1);return e},ceil:function(e){for(;l(e=t.ceil(e));)e=Dl(+e+1);return e}}:t))},a.ticks=function(t,e){var r=co(a.domain()),n=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],Dl(+r[1]+1),e<1?1:e)},a.tickFormat=function(){return n},a.copy=function(){return Pl(e.copy(),r,n)},yo(a,e)}function Dl(t){return new Date(t)}Sl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?zl:Ol,zl.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},zl.toString=Ol.toString,De.second=Re(function(t){return new Ee(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),De.seconds=De.second.range,De.seconds.utc=De.second.utc.range,De.minute=Re(function(t){return new Ee(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),De.minutes=De.minute.range,De.minutes.utc=De.minute.utc.range,De.hour=Re(function(t){var e=t.getTimezoneOffset()/60;return new Ee(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),De.hours=De.hour.range,De.hours.utc=De.hour.utc.range,De.month=Re(function(t){return(t=De.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),De.months=De.month.range,De.months.utc=De.month.utc.range;var El=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Il=[[De.second,1],[De.second,5],[De.second,15],[De.second,30],[De.minute,1],[De.minute,5],[De.minute,15],[De.minute,30],[De.hour,1],[De.hour,3],[De.hour,6],[De.hour,12],[De.day,1],[De.day,2],[De.week,1],[De.month,1],[De.month,3],[De.year,1]],Nl=Sl.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Zr]]),Rl={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(Dl)},floor:z,ceil:z};Il.year=De.year,De.scale=function(){return Pl(t.scale.linear(),Il,Nl)};var Fl=Il.map(function(t){return[t[0].utc,t[1]]}),Bl=Cl.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Zr]]);function jl(t){return JSON.parse(t.responseText)}function Hl(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Fl.year=De.year.utc,De.scale.utc=function(){return Pl(t.scale.linear(),Fl,Bl)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return me(t,"application/json",jl,e)},t.html=function(t,e){return me(t,"text/html",Hl,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],17:[function(t,e,r){(function(n,a){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,l=void 0,s=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(l?l(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,d="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],24:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(l=e,l===window||l===document||l===document.body?n:l.getBoundingClientRect());var l;return r[0]=a-o.left,r[1]=i-o.top,r}},{}],25:[function(t,e,r){var n,a=t("./lib/build-log"),i=t("./lib/epsilon"),o=t("./lib/intersecter"),l=t("./lib/segment-chainer"),s=t("./lib/segment-selector"),c=t("./lib/geojson"),u=!1,f=i();function d(t,e,r){var a=n.segments(t),i=n.segments(e),o=r(n.combine(a,i));return n.polygon(o)}n={buildLog:function(t){return!0===t?u=a():!1===t&&(u=!1),!1!==u&&u.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,u);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,u).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:s.union(t.combined,u),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:s.intersect(t.combined,u),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:s.difference(t.combined,u),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:s.differenceRev(t.combined,u),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:s.xor(t.combined,u),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:l(t.segments,f,u),inverted:t.inverted}},polygonFromGeoJSON:function(t){return c.toPolygon(n,t)},polygonToGeoJSON:function(t){return c.fromPolygon(n,f,t)},union:function(t,e){return d(t,e,n.selectUnion)},intersect:function(t,e){return d(t,e,n.selectIntersect)},difference:function(t,e){return d(t,e,n.selectDifference)},differenceRev:function(t,e){return d(t,e,n.selectDifferenceRev)},xor:function(t,e){return d(t,e,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),e.exports=n},{"./lib/build-log":26,"./lib/epsilon":27,"./lib/geojson":28,"./lib/intersecter":29,"./lib/segment-chainer":31,"./lib/segment-selector":32}],26:[function(t,e,r){e.exports=function(){var t,e=0,r=!1;function n(e,r){return t.list.push({type:e,data:r?JSON.parse(JSON.stringify(r)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return n("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return n("div_seg",{seg:t,pt:e}),n("chop",{seg:t,pt:e})},statusRemove:function(t){return n("pop_seg",{seg:t})},segmentUpdate:function(t){return n("seg_update",{seg:t})},segmentNew:function(t,e){return n("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return n("rem_seg",{seg:t})},tempStatus:function(t,e,r){return n("temp_status",{seg:t,above:e,below:r})},rewind:function(t){return n("rewind",{seg:t})},status:function(t,e,r){return n("status",{seg:t,above:e,below:r})},vert:function(e){return e===r?t:(r=e,n("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),n("log",{txt:t})},reset:function(){return n("reset")},selected:function(t){return n("selected",{segs:t})},chainStart:function(t){return n("chain_start",{seg:t})},chainRemoveHead:function(t,e){return n("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return n("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return n("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return n("chain_match",{index:t})},chainClose:function(t){return n("chain_close",{index:t})},chainAddHead:function(t,e){return n("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return n("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return n("chain_con",{index1:t,index2:e})},chainReverse:function(t){return n("chain_rev",{index:t})},chainJoin:function(t,e){return n("chain_join",{index1:t,index2:e})},done:function(){return n("done")}}}},{}],27:[function(t,e,r){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,r,n){var a=r[0],i=r[1],o=n[0],l=n[1],s=e[0];return(o-a)*(e[1]-i)-(l-i)*(s-a)>=-t},pointBetween:function(e,r,n){var a=e[1]-r[1],i=n[0]-r[0],o=e[0]-r[0],l=n[1]-r[1],s=o*i+a*l;return!(s-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-a>t&&(i-c)*(a-u)/(o-u)+c-n>t&&(l=!l),i=c,o=u}return l}};return e}},{}],28:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),a=1;a0})}function u(t,n){var a=t.seg,i=n.seg,o=a.start,l=a.end,c=i.start,u=i.end;r&&r.checkIntersection(a,i);var f=e.linesIntersect(o,l,c,u);if(!1===f){if(!e.pointsCollinear(o,l,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(l,c))return!1;var d=e.pointsSame(o,c),p=e.pointsSame(l,u);if(d&&p)return n;var h=!d&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(l,c,u);if(d)return g?s(n,l):s(t,u),n;h&&(p||(g?s(n,l):s(t,u)),s(n,o))}else 0===f.alongA&&(-1===f.alongB?s(t,c):0===f.alongB?s(t,f.pt):1===f.alongB&&s(t,u)),0===f.alongB&&(-1===f.alongA?s(n,o):0===f.alongA?s(n,f.pt):1===f.alongA&&s(n,l));return!1}for(var f=[];!i.isEmpty();){var d=i.getHead();if(r&&r.vert(d.pt[0]),d.isStart){r&&r.segmentNew(d.seg,d.primary);var p=c(d),h=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(h){var t=u(d,h);if(t)return t}return!!g&&u(d,g)}r&&r.tempStatus(d.seg,!!h&&h.seg,!!g&&g.seg);var y,m,x=v();if(x)t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=d.seg.myFill,r&&r.segmentUpdate(x.seg),d.other.remove(),d.remove();if(i.getHead()!==d){r&&r.rewind(d.seg);continue}t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=g?g.seg.myFill.above:a,d.seg.myFill.above=m?!d.seg.myFill.below:d.seg.myFill.below):null===d.seg.otherFill&&(y=g?d.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:d.primary?o:a,d.seg.otherFill={above:y,below:y}),r&&r.status(d.seg,!!h&&h.seg,!!g&&g.seg),d.other.status=p.insert(n.node({ev:d}))}else{var b=d.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(l.exists(b.prev)&&l.exists(b.next)&&u(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!d.primary){var _=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=_}f.push(d.seg)}i.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,a,i,o=t[t.length-1],s=0;s1)for(var r=1;r1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=O(t,360),e=O(e,100),r=O(r,100),0===e)n=a=i=r;else{var l=r<.5?r*(1+e):r+e-r*e,s=2*r-l;n=o(s,l,t+1/3),a=o(s,l,t),i=o(s,l,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(e.h,s,u),f=!0,d="hsl"),e.hasOwnProperty("a")&&(i=e.a));var p,h,g;return i=C(i),{ok:f,format:e.format||d,r:o(255,l(a.r,0)),g:o(255,l(a.g,0)),b:o(255,l(a.b,0)),a:i}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=i(100*this._a)/100,this._format=s.format||u.format,this._gradientType=s.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=u.ok,this._tc_id=a++}function u(t,e,r){t=O(t,255),e=O(e,255),r=O(r,255);var n,a,i=l(t,e,r),s=o(t,e,r),c=(i+s)/2;if(i==s)n=a=0;else{var u=i-s;switch(a=c>.5?u/(2-i-s):u/(i+s),i){case t:n=(e-r)/u+(e>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(c(n));return i}function A(t,e){e=e||6;for(var r=c(t).toHsv(),n=r.h,a=r.s,i=r.v,o=[],l=1/e;e--;)o.push(c({h:n,s:a,v:i})),i=(i+l)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,a=this.toRgb();return e=a.r/255,r=a.g/255,n=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=C(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return d(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,a){var o=[D(i(t).toString(16)),D(i(e).toString(16)),D(i(r).toString(16)),D(I(n))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*O(this._r,255))+"%",g:i(100*O(this._g,255))+"%",b:i(100*O(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%)":"rgba("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[d(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=c(t);r="#"+p(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(T,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:E(t[n]));t=r}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:s(),g:s(),b:s()})},c.mix=function(t,e,r){r=0===r?0:r||50;var n=c(t).toRgb(),a=c(e).toRgb(),i=r/100;return c({r:(a.r-n.r)*i+n.r,g:(a.g-n.g)*i+n.g,b:(a.b-n.b)*i+n.b,a:(a.a-n.a)*i+n.a})},c.readability=function(e,r){var n=c(e),a=c(r);return(t.max(n.getLuminance(),a.getLuminance())+.05)/(t.min(n.getLuminance(),a.getLuminance())+.05)},c.isReadable=function(t,e,r){var n,a,i=c.readability(t,e);switch(a=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},c.mostReadable=function(t,e,r){var n,a,i,o,l=null,s=0;a=(r=r||{}).includeFallbackColors,i=r.level,o=r.size;for(var u=0;us&&(s=n,l=c(e[u]));return c.isReadable(t,l,{level:i,size:o})||!a?l:(r.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],r))};var L=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=c.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(L);function C(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function O(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,l(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function z(t){return o(1,l(0,t))}function P(t){return parseInt(t,16)}function D(t){return 1==t.length?"0"+t:""+t}function E(t){return t<=1&&(t=100*t+"%"),t}function I(e){return t.round(255*parseFloat(e)).toString(16)}function N(t){return P(t)/255}var R,F,B,j=(F="[\\s|\\(]+("+(R="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+R+")[,|\\s]+("+R+")\\s*\\)?",B="[\\s|\\(]+("+R+")[,|\\s]+("+R+")[,|\\s]+("+R+")[,|\\s]+("+R+")\\s*\\)?",{CSS_UNIT:new RegExp(R),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+B),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+B),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+B),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function H(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],35:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],36:[function(t,e,r){"use strict";var n=t("./arrow_paths"),a=t("../../plots/font_attributes"),i=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:a({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",i.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",i.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:a({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":204,"../../plots/cartesian/constants":220,"../../plots/font_attributes":241,"./arrow_paths":35}],37:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=a.getFromId(t,e.xref),n=a.getFromId(t,e.yref);e._extremes={},r&&l(e,r),n&&l(e,n)})}function l(t,e){var r,n=e._id,i=n.charAt(0),o=t[i],l=t["a"+i],s=t[i+"ref"],c=t["a"+i+"ref"],u=t["_"+i+"padplus"],f=t["_"+i+"padminus"],d={x:1,y:-1}[i]*t[i+"shift"],p=3*t.arrowsize*t.arrowwidth||0,h=p+d,g=p-d,v=3*t.startarrowsize*t.arrowwidth||0,y=v+d,m=v-d;if(c===s){var x=a.findExtremes(e,[e.r2c(o)],{ppadplus:h,ppadminus:g}),b=a.findExtremes(e,[e.r2c(l)],{ppadplus:Math.max(u,y),ppadminus:Math.max(f,m)});r={min:[x.min[0],b.min[0]],max:[x.max[0],b.max[0]]}}else y=l?y+l:y,m=l?m-l:m,r=a.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(u,h,y),ppadminus:Math.max(f,g,m)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([i,o],t)}},{"../../lib":170,"../../plots/cartesian/axes":214,"./draw":42}],38:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,a,i,o,s,c,u=t._fullLayout.annotations,f=[],d=[],p=[],h=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,l,s=o(t,e),c=s.on,u=s.off.concat(s.explicitOff),f={},d=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var V=!1,U=["x","y"],G=0;G1)&&(K===$?((st=tt.r2fraction(e["a"+Q]))<0||st>1)&&(V=!0):V=!0),Z=tt._offset+tt.r2p(e[Q]),W=.5}else"x"===Q?(Y=e[Q],Z=b.l+b.w*Y):(Y=1-e[Q],Z=b.t+b.h*Y),W=e.showarrow?.5:Y;if(e.showarrow){lt.head=Z;var ct=e["a"+Q];J=rt*q(.5,e.xanchor)-nt*q(.5,e.yanchor),K===$?(lt.tail=tt._offset+tt.r2p(ct),X=J):(lt.tail=Z+ct,X=J+ct),lt.text=lt.tail+J;var ut=x["x"===Q?"width":"height"];if("paper"===$&&(lt.head=o.constrain(lt.head,1,ut-1)),"pixel"===K){var ft=-Math.max(lt.tail-3,lt.text),dt=Math.min(lt.tail+3,lt.text)-ut;ft>0?(lt.tail+=ft,lt.text+=ft):dt>0&&(lt.tail-=dt,lt.text-=dt)}lt.tail+=ot,lt.head+=ot}else X=J=at*q(W,it),lt.text=Z+J;lt.text+=ot,J+=ot,X+=ot,e["_"+Q+"padplus"]=at/2+X,e["_"+Q+"padminus"]=at/2-X,e["_"+Q+"size"]=at,e["_"+Q+"shift"]=J}if(t._dragging||!V){var pt=0,ht=0;if("left"!==e.align&&(pt=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(ht=(P-m)*("middle"===e.valign?.5:1)),u)n.select("svg").attr({x:N+pt-1,y:N+ht}).call(c.setClipUrl,F?A:null);else{var gt=N+ht-h.top,vt=N+pt-h.left;H.call(f.positionText,vt,gt).call(c.setClipUrl,F?A:null)}B.select("rect").call(c.setRect,N,N,w,P),R.call(c.setRect,E/2,E/2,I-E,j-E),D.call(c.setTranslate,Math.round(L.x.text-I/2),Math.round(L.y.text-j/2)),O.attr({transform:"rotate("+S+","+L.x.text+","+L.y.text+")"});var yt,mt=function(r,n){C.selectAll(".annotation-arrow-g").remove();var u=L.x.head,f=L.y.head,d=L.x.tail+r,h=L.y.tail+n,y=L.x.text+r,m=L.y.text+n,x=o.rotationXYMatrix(S,y,m),w=o.apply2DTransform(x),A=o.apply2DTransform2(x),z=+R.attr("width"),P=+R.attr("height"),E=y-.5*z,I=E+z,N=m-.5*P,F=N+P,B=[[E,N,E,F],[E,F,I,F],[I,F,I,N],[I,N,E,N]].map(A);if(!B.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){B.forEach(function(t){var e=o.segmentsIntersect(d,h,u,f,t[0],t[1],t[2],t[3]);e&&(d=e.x,h=e.y)});var j=e.arrowwidth,H=e.arrowcolor,q=e.arrowside,V=C.append("g").style({opacity:s.opacity(H)}).classed("annotation-arrow-g",!0),U=V.append("path").attr("d","M"+d+","+h+"L"+u+","+f).style("stroke-width",j+"px").call(s.stroke,s.rgb(H));if(g(U,q,e),_.annotationPosition&&U.node().parentNode&&!i){var G=u,Z=f;if(e.standoff){var X=Math.sqrt(Math.pow(u-d,2)+Math.pow(f-h,2));G+=e.standoff*(d-u)/X,Z+=e.standoff*(h-f)/X}var Y,W,J=V.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(d-G)+","+(h-Z),transform:"translate("+G+","+Z+")"}).style("stroke-width",j+6+"px").call(s.stroke,"rgba(0,0,0,0)").call(s.fill,"rgba(0,0,0,0)");p.init({element:J.node(),gd:t,prepFn:function(){var t=c.getTranslate(D);Y=t.x,W=t.y,l&&l.autorange&&k(l._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(Y,W),a=n[0]+t,i=n[1]+r;D.call(c.setTranslate,a,i),T("x",l?l.p2r(l.r2p(e.x)+t):e.x+t/b.w),T("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/b.h),e.axref===e.xref&&T("ax",l.p2r(l.r2p(e.ax)+t)),e.ayref===e.yref&&T("ay",v.p2r(v.r2p(e.ay)+r)),V.attr("transform","translate("+t+","+r+")"),O.attr({transform:"rotate("+S+","+a+","+i+")"})},doneFn:function(){a.call("relayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&mt(0,0),z)p.init({element:D.node(),gd:t,prepFn:function(){yt=O.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?T("ax",l.p2r(l.r2p(e.ax)+t)):T("ax",e.ax+t),e.ayref===e.yref?T("ay",v.p2r(v.r2p(e.ay)+r)):T("ay",e.ay+r),mt(t,r);else{if(i)return;var a,o;if(l)a=l.p2r(l.r2p(e.x)+t);else{var s=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-s/2;a=p.align(c+t/b.w,s,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-r/b.h,u,0,1,e.yanchor)}T("x",a),T("y",o),l&&v||(n=p.getCursor(l?.5:a,v?.5:o,e.xanchor,e.yanchor))}O.attr({transform:"translate("+t+","+r+")"+yt}),d(D,n)},doneFn:function(){d(D),a.call("relayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else D.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,y=f.backoff*p+r.standoff,m=d.backoff*h+r.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},l={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-l.x,b=o.y-l.y;if(c=(s=Math.atan2(b,x))+Math.PI,y&&m&&y+m>Math.sqrt(x*x+b*b))return void z();if(y){if(y*y>x*x+b*b)return void z();var _=y*Math.cos(s),w=y*Math.sin(s);l.x+=_,l.y+=w,t.attr({x2:l.x,y2:l.y})}if(m){if(m*m>x*x+b*b)return void z();var k=m*Math.cos(s),T=m*Math.sin(s);o.x-=k,o.y-=T,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var M=u.getTotalLength(),A="";if(M1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+l+'"]').remove():(s._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(s.x)*r[0],e.yaxis.r2l(s.y)*r[1],e.zaxis.r2l(s.z)*r[2]]),n(t.graphDiv,s,l,t.id,s._xa,s._ya))}}},{"../../plots/gl3d/project":244,"../annotations/draw":42}],49:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var i=r.attrRegex,o=Object.keys(t),l=0;l=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var l=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+l+", "+n[3]+")":"rgb("+l+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(n(t))},i.opacity=function(t){return t?n(t).getAlpha():0},i.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},i.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var a=n(e||s).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-r.a)+r.r*r.a,g:i.g*(1-r.a)+r.g*r.a,b:i.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},i.contrast=function(t,e,r){var a=n(t);return 1!==a.getAlpha()&&(a=n(i.combine(t,s))),(a.isDark()?e?a.lighten(e):s:r?a.darken(r):l).toString()},i.stroke=function(t,e){var r=n(e);t.style({stroke:i.tinyRGB(r),"stroke-opacity":r.getAlpha()})},i.fill=function(t,e){var r=n(e);t.style({fill:i.tinyRGB(r),"fill-opacity":r.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,r,n,a,o=Object.keys(t);for(e=0;e0?L>=E:L<=E));S++)L>N&&L0?L>=E:L<=E));S++)L>C[0]&&L1){var it=Math.pow(10,Math.floor(Math.log(at)/Math.LN10));rt*=it*c.roundUp(at/it,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(tt.tick0=0)}tt.dtick=rt}tt.domain=[J+X,J+U-X],tt.setScale();var ot=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(T.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(T.cbbg,!0),t.append("g").classed(T.cbfills,!0),t.append("g").classed(T.cblines,!0),t.append("g").classed(T.cbaxis,!0).classed(T.crisp,!0),t.append("g").classed(T.cbtitleunshift,!0).append("g").classed(T.cbtitle,!0),t.append("rect").classed(T.cboutline,!0),t.select(".cbtitle").datum(0)})});ot.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var lt=ot.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")");tt._axislayer=ot.select(".cbaxis");var st=0;if(-1!==["top","bottom"].indexOf(r.titleside)){var ct,ut=k.l+(r.x+G)*k.w,ft=tt.titlefont.size;ct="top"===r.titleside?(1-(J+U-X))*k.h+k.t+3+.75*ft:(1-(J+X))*k.h+k.t-3-.25*ft,yt(tt._id+"title",{attributes:{x:ut,y:ct,"text-anchor":"start"}})}var dt,pt,ht,gt=c.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.titleside)){var i=ot.select(".cbtitle"),o=i.select("text"),s=[-r.outlinewidth/2,r.outlinewidth/2],u=i.select(".h"+tt._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),u?(st=d.bBox(u).height)>f&&(s[1]-=(st-f)/2):o.node()&&!o.classed(T.jsPlaceholder)&&(st=d.bBox(o.node()).height),st){if(st+=5,"top"===r.titleside)tt.domain[1]-=st/k.h,s[1]*=-1;else{tt.domain[0]+=st/k.h;var p=g.lineCount(o);s[1]+=(1-p)*f}i.attr("transform","translate("+s+")"),tt.setScale()}}ot.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-tt.domain[1]))+")"),tt._axislayer.attr("transform","translate(0,"+Math.round(-k.t)+")");var h=ot.select(".cbfills").selectAll("rect.cbfill").data(z);h.enter().append("rect").classed(T.cbfill,!0).style("stroke","none"),h.exit().remove();var m=C.map(tt.c2p).map(Math.round).sort(function(t,e){return t-e});h.each(function(i,o){var l=[0===o?C[0]:(z[o]+z[o-1])/2,o===z.length-1?C[1]:(z[o]+z[o+1])/2].map(tt.c2p).map(Math.round);l[1]=c.constrain(l[1]+(l[1]>l[0])?1:-1,m[0],m[1]);var s=n.select(this).attr({x:Y,width:Math.max(H,2),y:n.min(l),height:Math.max(n.max(l)-n.min(l),2)});if(r.fillgradient)d.gradient(s,t,e,"vertical",r.fillgradient,"fill");else{var u=D(i).replace("e-","");s.attr("fill",a(u).toHexString())}});var x=ot.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?O:[]);return x.enter().append("path").classed(T.cbline,!0),x.exit().remove(),x.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round(tt.c2p(t))+r.line.width/2%1)+"h"+H).call(d.lineGroupStyle,r.line.width,P(t),r.line.dash)}),tt._axislayer.selectAll("g."+tt._id+"tick,path").remove(),tt._pos=Y+H+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),tt.side="right",c.syncOrAsync([function(){return l.doTicksSingle(t,tt,!0)},function(){if(-1===["top","bottom"].indexOf(r.titleside)){var e=tt.titlefont.size,a=tt._offset+tt._length/2,i=k.l+(tt.position||0)*k.w+("right"===tt.side?10+e*(tt.showticklabels?1:.5):-10-e*(tt.showticklabels?.5:0));yt("h"+tt._id+"title",{avoid:{selection:n.select(t).selectAll("g."+tt._id+"tick"),side:r.titleside,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var n=H+r.outlinewidth/2+d.bBox(tt._axislayer.node()).width;if((F=lt.select("text")).node()&&!F.classed(T.jsPlaceholder)){var a,o=lt.select(".h"+tt._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(r.titleside)?d.bBox(o).width:d.bBox(lt.node()).right-Y-k.l,n=Math.max(n,a)}var l=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,s=Q-$;ot.select(".cbbg").attr({x:Y-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:$-Z,width:Math.max(l,2),height:Math.max(s+2*Z,2)}).call(p.fill,r.bgcolor).call(p.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),ot.selectAll(".cboutline").attr({x:Y,y:$+r.ypad+("top"===r.titleside?st:0),width:Math.max(H,2),height:Math.max(s-2*r.ypad-st,2)}).call(p.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var c=({center:.5,right:1}[r.xanchor]||0)*l;ot.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=m[r.yanchor],h=x[r.yanchor];"pixels"===r.lenmode?(u.y=r.y,u.t=s*f,u.b=s*h):(u.t=u.b=0,u.yt=r.y+r.len*f,u.yb=r.y-r.len*h);var g=m[r.xanchor],v=x[r.xanchor];if("pixels"===r.thicknessmode)u.x=r.x,u.l=l*g,u.r=l*v;else{var y=l-H;u.l=y*g,u.r=y*v,u.xl=r.x-r.thickness*g,u.xr=r.x+r.thickness*v}i.autoMargin(t,e,u)}],t);if(gt&>.then&&(t._promises||[]).push(gt),t._context.edits.colorbarPosition)s.init({element:ot.node(),gd:t,prepFn:function(){dt=ot.attr("transform"),f(ot)},moveFn:function(t,e){ot.attr("transform",dt+" translate("+t+","+e+")"),pt=s.align(W+t/k.w,q,0,1,r.xanchor),ht=s.align(J-e/k.h,U,0,1,r.yanchor);var n=s.getCursor(pt,ht,r.xanchor,r.yanchor);f(ot,n)},doneFn:function(){f(ot),void 0!==pt&&void 0!==ht&&o.call("restyle",t,{"colorbar.x":pt,"colorbar.y":ht},A().index)}});return gt}function vt(t,e){return c.coerce(K,tt,w,t,e)}function yt(e,r){var n=A(),a="colorbar.title",i=n._module.colorbar.container;i&&(a=i+"."+a);var o={propContainer:tt,propName:a,traceIndex:n.index,placeholder:v._dfltTitle.colorbar,containerGroup:ot.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;ot.selectAll("."+l+",."+l+"-math-group").remove(),h.draw(t,e,u(o,r||{}))}v._infolayer.selectAll("g."+e).remove()}function A(){var r,n,a=e.substr(2);for(r=0;r=0?a.Reds:a.Blues,l.reversescale?i(m):m),s.autocolorscale||f("autocolorscale",!1))}},{"../../lib":170,"./flip_scale":63,"./scales":70}],60:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":70}],61:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,r,c,u){var f,d=u.prefix,p=u.cLetter,h=d.slice(0,d.length-1),g=d?a.nestedProperty(t,h).get()||{}:t,v=d?a.nestedProperty(e,h).get()||{}:e,y=g[p+"min"],m=g[p+"max"],x=g.colorscale;c(d+p+"auto",!(n(y)&&n(m)&&y=0;a--,i++)e=t[a],n[i]=[1-e[0],e[1]];return n}},{}],64:[function(t,e,r){"use strict";var n=t("./scales"),a=t("./default_scale"),i=t("./is_valid_scale_array");e.exports=function(t,e){if(e||(e=a),!t)return e;function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return"string"==typeof t&&(r(),"string"==typeof t&&r()),i(t)?t:e}},{"./default_scale":60,"./is_valid_scale_array":68,"./scales":70}],65:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=t("./is_valid_scale");e.exports=function(t,e){var r=e?a.nestedProperty(t,e).get()||{}:t,o=r.color,l=!1;if(a.isArrayOrTypedArray(o))for(var s=0;s4/3-l?o:l}},{}],72:[function(t,e,r){"use strict";var n=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,i){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:n.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":170}],73:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),l=t("../../lib"),s=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function d(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,r,n,f,h,g,v,y,m=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;m._mouseDownTime||(m._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,r){return Math.abs(t)b&&(x=Math.max(x-1,1)),m._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!y){var r;try{r=new MouseEvent("click",e)}catch(t){var n=p(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(m),m._dragged=!1}else m._dragged=!1}},u.coverSlip=d},{"../../constants/interactions":151,"../../lib":170,"../../plots/cartesian/constants":220,"../../registry":259,"./align":71,"./cursor":72,"./unhover":74,"has-hover":20,"has-passive-events":21,"mouse-event-offset":24}],74:[function(t,e,r){"use strict";var n=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),l=e.exports={};l.wrapped=function(t,e,r){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),l.raw(t,e,r)},l.raw=function(t,e){var r=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":163,"../../lib/get_graph_div":168,"../../lib/throttle":192,"../fx/constants":88}],75:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],76:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,h=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){c.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(l.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,a){t.call(v.setPosition,e,r).call(v.setSize,n,a)},v.translatePoint=function(t,e,r,n){var i=r.c2p(t.x),o=n.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var a=n.select(this);v.translatePoint(t,a,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,a,i){e.attr("display",r.isPtWithinRange(t,a)&&n.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,l=i.ycalendar,s="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(s).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,a,o,l)})})}},v.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=r||i.width||0,s=a||i.dash||"";l.stroke(e,n||i.color),v.dashLine(e,s,o)},v.lineGroupStyle=function(t,e,r,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,s=a||i.dash||"";n.select(this).call(l.stroke,r||i.color).call(v.dashLine,s,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(l.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){n.select(this).call(l.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var m=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=n.format("~.1f"),T={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,a,o,s){for(var u=o.length,f=T[a],d=new Array(u),p=0;p=100,e.attr("d",b(u,s))}var f,d,p,h=!1;if(t.so)p=o.outlierwidth,d=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,d="mlc"in t?t.mlcc=n.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?l.defaultLine:o.color,c.isArrayOrTypedArray(i.color)&&(f=l.defaultLine,h=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):i.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(l.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var y=i.gradient,m=t.mgt;if(m?h=!0:m=y&&y.type,Array.isArray(m)&&(m=m[0],T[m]||(m=0)),m&&"none"!==m){var x=t.mgc;x?h=!0:x=y.color;var _=r.uid;h&&(_+="-"+t.i),v.gradient(e,a,_,m,[[0,x],[1,f]],"fill")}else l.fill(e,f);p&&l.stroke(e,d)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=h.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.marker||{},i=r.marker||{},l=n.marker||{},s=a.opacity,u=i.opacity,f=l.opacity,d=void 0!==u,h=void 0!==f;(c.isArrayOrTypedArray(s)||d||h)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?d?u:e:h?f:p*e});var g=a.color,v=i.color,y=l.color;(v||y)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:y||e});var m=a.size,x=i.size,b=l.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||m/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.textfont||{},i=r.textfont||{},o=n.textfont||{},s=a.color,c=i.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||s;return t.selected?c||e:u||(c?e:l.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];r.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&i.push(function(t,e){l.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&i.push(function(t,e){var n=e.mx||a.symbol||0,i=r.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(n),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=n.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var l=t.tp||e.textposition,s=L(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,s,f).text(o).call(u.convertToTspans,r).call(A,l,s,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=n.select(this),i=r.selectedTextColorFn(t),o=t.tp||e.textposition,s=L(t,e);l.fill(a,i),A(a,o,s,t.mrc2||t.mrc)})}};var S=.5;function C(t,e,r,a){var i=t[0]-e[0],o=t[1]-e[1],l=r[0]-e[0],s=r[1]-e[1],c=Math.pow(i*i+o*o,S/2),u=Math.pow(l*l+s*s,S/2),f=(u*u*i-c*c*l)*a,d=(u*u*o-c*c*s)*a,p=3*u*(c+u),h=3*c*(c+u);return[[n.round(e[0]+(p&&f/p),2),n.round(e[1]+(p&&d/p),2)],[n.round(e[0]-(h&&f/h),2),n.round(e[1]-(h&&d/h),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],a=[];for(r=1;r=1e4&&(v.savedBBoxes={},P=0),r&&(v.savedBBoxes[r]=y),P++,c.extendFlat({},y)},v.setClipUrl=function(t,e){if(e){if(void 0===v.baseUrl){var r=n.select("base");r.size()&&r.attr("href")?v.baseUrl=window.location.href.split("#")[0]:v.baseUrl=""}t.attr("clip-path","url("+v.baseUrl+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||0,r=r||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+r+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||1,r=r||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+r+")").trim(),t[a]("transform",i),i};var E=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(E,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var I=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,a=n.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),l=parseFloat(i.attr("y")||0),s=(a.attr("transform")||"").match(I);t=1===e&&1===r?[]:["translate("+o+","+l+")","scale("+e+","+r+")","translate("+-o+","+-l+")"],s&&t.push(s),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":149,"../../constants/interactions":151,"../../constants/xmlns_namespaces":153,"../../lib":170,"../../lib/svg_text_utils":191,"../../registry":259,"../../traces/scatter/make_bubble_size_func":385,"../../traces/scatter/subtypes":392,"../color":51,"../colorscale":66,"./symbol_defs":77,d3:16,"fast-isnumeric":18,tinycolor2:34}],77:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+a+i+a+i+o+i+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),a=n.round(-t,2),i=n.round(-.309*t,2);return"M"+e+","+i+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+r+"V"+r+"L0,"+e+"L-"+a+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+a+"H"+r+"L"+e+",0L"+r+",-"+a+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),a=n.round(.951*e,2),i=n.round(.363*e,2),o=n.round(.588*e,2),l=n.round(-e,2),s=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+s+"H"+a+"L"+i+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+i+","+c+"L-"+a+","+s+"H-"+r+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),a=n.round(.76*t,2);return"M-"+a+",0l-"+r+",-"+e+"h"+a+"l"+r+",-"+e+"l"+r+","+e+"h"+a+"l-"+r+","+e+"l"+r+","+e+"h-"+a+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+a+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+a+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:16}],78:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],79:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function l(t,e,r,a){var l=e["error_"+a]||{},s=[];if(l.visible&&-1!==["linear","log"].indexOf(r.type)){for(var c=o(l),u=0;u0;t.each(function(t){var u,f=t[0].trace,d=f.error_x||{},p=f.error_y||{};f.ids&&(u=function(t){return t.id});var h=o.hasMarkers(f)&&f.marker.maxdisplayed>0;p.visible||d.visible||(t=[]);var g=n.select(this).selectAll("g.errorbar").data(t,u);if(g.exit().remove(),t.length){d.visible||g.selectAll("path.xerror").remove(),p.visible||g.selectAll("path.yerror").remove(),g.style("opacity",1);var v=g.enter().append("g").classed("errorbar",!0);c&&v.style("opacity",0).transition().duration(r.duration).style("opacity",1),i.setClipUrl(g,e.layerClipId),g.each(function(t){var e=n.select(this),i=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,l,s);if(!h||t.vis){var o,u=e.select("path.yerror");if(p.visible&&a(i.x)&&a(i.yh)&&a(i.ys)){var f=p.width;o="M"+(i.x-f)+","+i.yh+"h"+2*f+"m-"+f+",0V"+i.ys,i.noYS||(o+="m-"+f+",0h"+2*f),!u.size()?u=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):c&&(u=u.transition().duration(r.duration).ease(r.easing)),u.attr("d",o)}else u.remove();var g=e.select("path.xerror");if(d.visible&&a(i.y)&&a(i.xh)&&a(i.xs)){var v=(d.copy_ystyle?p:d).width;o="M"+i.xh+","+(i.y-v)+"v"+2*v+"m0,-"+v+"H"+i.xs,i.noXS||(o+="m0,-"+v+"v"+2*v),!g.size()?g=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):c&&(g=g.transition().duration(r.duration).ease(r.easing)),g.attr("d",o)}else g.remove()}})}})}},{"../../traces/scatter/subtypes":392,"../drawing":76,d3:16,"fast-isnumeric":18}],84:[function(t,e,r){"use strict";var n=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},i=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(a.stroke,r.color),i.copy_ystyle&&(i=r),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":51,d3:16}],85:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":241}],86:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry");function i(t,e,r,a){a=a||n.identity,Array.isArray(t)&&(e[0][r]=a(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var l=0;l=0&&r.index-1&&o.length>x&&(o=x>3?o.substr(0,x-3)+"...":o.substr(0,x))}void 0!==t.zLabel?(void 0!==t.xLabel&&(c+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(c+="y: "+t.yLabel+"
"),c+=(c?"z: ":"")+t.zLabel):O&&t[a+"Label"]===T?c=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(c=t.yLabel):c=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(c+=(c?"
":"")+t.text),void 0!==t.extraText&&(c+=(c?"
":"")+t.extraText),""===c&&(""===o&&e.remove(),c=o);var b=e.select("text.nums").call(u.font,t.fontFamily||h,t.fontSize||g,t.fontColor||m).text(c).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),_=e.select("text.name"),M=0;o&&o!==c?(_.call(u.font,t.fontFamily||h,t.fontSize||g,v).text(o).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),M=_.node().getBoundingClientRect().width+2*k):(_.remove(),e.select("rect").remove()),e.select("path").style({fill:p,stroke:m});var A,z,P=b.node().getBoundingClientRect(),D=t.xa._offset+(t.x0+t.x1)/2,E=t.ya._offset+(t.y0+t.y1)/2,I=Math.abs(t.x1-t.x0),N=Math.abs(t.y1-t.y0),R=P.width+w+k+M;t.ty0=L-P.top,t.bx=P.width+2*k,t.by=P.height+2*k,t.anchor="start",t.txwidth=P.width,t.tx2width=M,t.offset=0,i?(t.pos=D,A=E+N/2+R<=C,z=E-N/2-R>=0,"top"!==t.idealAlign&&A||!z?A?(E+=N/2,t.anchor="start"):t.anchor="middle":(E-=N/2,t.anchor="end")):(t.pos=E,A=D+I/2+R<=S,z=D-I/2-R>=0,"left"!==t.idealAlign&&A||!z?A?(D+=I/2,t.anchor="start"):t.anchor="middle":(D-=I/2,t.anchor="end")),b.attr("text-anchor",t.anchor),M&&_.attr("text-anchor",t.anchor),e.attr("transform","translate("+D+","+E+")"+(i?"rotate("+y+")":""))}),N}function M(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var a="end"===t.anchor?-1:1,i=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],l=o*(w+k),c=l+o*(t.txwidth+k),f=0,d=t.offset;"middle"===t.anchor&&(l-=t.tx2width/2,c+=t.txwidth/2+k),e&&(d*=-_,f=t.offset*b),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(d-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+d)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(d-w)+"Z"),i.call(s.positionText,l+f,d+t.ty0-t.by/2+k),t.tx2width&&(r.select("text.name").call(s.positionText,c+o*k+f,d+t.ty0-t.by/2+k),r.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,d-t.by/2-1,t.tx2width,t.by+2))}})}function A(t,e){var r=t.index,n=t.trace||{},a=t.cd[0],i=t.cd[r]||{},l=Array.isArray(r)?function(t,e){return o.castOption(a,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(i,n,t,e)};function s(e,r,n){var a=l(r,n);a&&(t[e]=a)}if(s("hoverinfo","hi","hoverinfo"),s("bgcolor","hbg","hoverlabel.bgcolor"),s("borderColor","hbc","hoverlabel.bordercolor"),s("fontFamily","htf","hoverlabel.font.family"),s("fontSize","hts","hoverlabel.font.size"),s("fontColor","htc","hoverlabel.font.color"),s("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function L(t,e){var r,n,a=e.container,o=e.fullLayout,l=e.event,s=!!t.hLinePoint,c=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),c||s){var d=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(s){var p,h,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(p=l.pointerX,h=l.pointerY):(p=r._offset+g.x,h=n._offset+g.y);var v,y,m=i.readability(g.color,d)<1.5?f.contrast(d):g.color,x=n.spikemode,b=n.spikethickness,_=n.spikecolor||m,w=n._boundingBox,k=(w.left+w.right)/2w[0]._length||et<0||et>k[0]._length)return d.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,I="xval"in e?g.flat(s,e.xval):g.p2c(w,tt),N="yval"in e?g.flat(s,e.yval):g.p2c(k,et),!a(I[0])||!a(N[0]))return o.warn("Fx.hover failed",e,t),d.unhoverRaw(t,e)}var at=1/0;for(F=0;FX&&(J.splice(0,X),at=J[0].distance),m&&0!==W&&0===J.length){Z.distance=W,Z.index=!1;var ct=j._module.hoverPoints(Z,U,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=W})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var dt=ft[0];a(dt.x0)&&a(dt.y0)&&(ut=vt(dt),(!$.vLinePoint||$.vLinePoint.spikeDistance>ut.spikeDistance)&&($.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var ht=pt[0];a(ht.x0)&&a(ht.y0)&&(ut=vt(ht),(!$.hLinePoint||$.hLinePoint.spikeDistance>ut.spikeDistance)&&($.hLinePoint=ut))}}}}function gt(t,e){for(var r,n=null,a=1/0,i=0;i1||J.length>1)||"closest"===E&&K&&J.length>1,Ct=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),Ot={hovermode:E,rotateLabels:St,bgColor:Ct,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},zt=T(J,Ot,t);if(function(t,e,r){var n,a,i,o,l,s,c,u=0,f=1,d=t.map(function(t,n){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!n&&o&&o[0]>o[1]!==i&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?x:1)/2,pmin:0,pmax:i?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],r=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=r.pos+r.dp+r.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;n=!1}if(!(i<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=i;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos>e.pmax-1&&(s.del=!0,c--);for(o=0;o=0;l--)t[l].dp-=i;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(;!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&v.pmin===y.pmin&&v.pmax===y.pmax){for(l=g.length-1;l>=0;l--)g[l].dp+=a;for(h.push.apply(h,g),d.splice(o+1,1),c=0,l=h.length-1;l>=0;l--)c+=h[l].dp;for(i=c/h.length,l=h.length-1;l>=0;l--)h[l].dp-=i;n=!1}else o++}d.forEach(p)}for(o=d.length-1;o>=0;o--){var m=d[o];for(l=m.length-1;l>=0;l--){var b=m[l],_=t[b.i];_.offset=b.dp,_.del=b.del}}}(J,St?"xa":"ya",u),M(zt,St),e.target&&e.target.tagName){var Pt=h.getComponentMethod("annotations","hasClickToShow")(t,At);c(n.select(e.target),Pt?"pointer":"")}if(!e.target||i||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var a=r[n],i=t._hoverdata[n];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber))return!0}return!1}(t,0,Mt))return;Mt&&t.emit("plotly_unhover",{event:e,points:Mt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:I,yvals:N})}(t,e,r,i)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0},a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=T([r],o,e.gd);return M(l,o.rotateLabels),l.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0}}),a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=T(r,o,e.gd),s=0;return l.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){d||p||h||"independent"===T("pattern")&&(d=!0),v._hasSubplotGrid=d;var x,b,_="top to bottom"===T("roworder"),w=d?.2:.1,k=d?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",T,w,x,m),y:u("y",T,k,b,y,_)}}else delete e.grid}function T(t,e){return n.coerce(r,v,s,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,a,i,o,l,s,u,d=t.grid||{},p=e._subplots,h=r._hasSubplotGrid,g=r.rows,v=r.columns,y="independent"===r.pattern,m=r._axisMap={};if(h){var x=d.subplots||[];s=r.subplots=new Array(g);var b=1;for(n=0;n=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],104:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes");e.exports={bgcolor:{valType:"color",editType:"legend"},bordercolor:{valType:"color",dflt:a.defaultLine,editType:"legend"},borderwidth:{valType:"number",min:0,dflt:0,editType:"legend"},font:n({editType:"legend"}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v",editType:"legend"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"],editType:"legend"},tracegroupgap:{valType:"number",min:0,dflt:10,editType:"legend"},x:{valType:"number",min:-2,max:3,dflt:1.02,editType:"legend"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left",editType:"legend"},y:{valType:"number",min:-2,max:3,dflt:1,editType:"legend"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"legend"},editType:"legend"}},{"../../plots/font_attributes":241,"../color/attributes":50}],105:[function(t,e,r){"use strict";e.exports={scrollBarWidth:6,scrollBarMinHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4,textOffsetX:40}},{}],106:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib"),i=t("../../plot_api/plot_template"),o=t("./attributes"),l=t("../../plots/layout_attributes"),s=t("./helpers");e.exports=function(t,e,r){for(var c,u,f,d,p=t.legend||{},h=0,g=!1,v="normal",y=0;y1)){var x=i.newContainer(e,"legend");if(_("bgcolor",e.paper_bgcolor),_("bordercolor"),_("borderwidth"),a.coerceFont(_,"font",e.font),_("orientation"),"h"===x.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(c=0,f="left",u=1.1,d="bottom"):(c=0,f="left",u=-.1,d="top")}_("traceorder",v),s.isGrouped(e.legend)&&_("tracegroupgap"),_("x",c),_("xanchor",f),_("y",u),_("yanchor",d),a.noneOrAll(p,x,["x","y"])}function _(t,e){return a.coerce(p,x,o,t,e)}}},{"../../lib":170,"../../plot_api/plot_template":204,"../../plots/layout_attributes":245,"../../registry":259,"./attributes":104,"./helpers":110}],107:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib/events"),s=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),d=t("./handle_click"),p=t("./constants"),h=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,y=g.FROM_TL,m=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=t("./anchor_utils"),k=h.DBLCLICKDELAY;function T(t,e,r,n,a){var i=r.data()[0][0].trace,o={event:a,node:r.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=r.datum()[0].label),!1!==l.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){d(r,t,n)},k);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==l.triggerHandler(t,"plotly_legenddoubleclick",o)&&d(r,t,n)}}function M(t,e,r){var n=t.data()[0][0],i=e._fullLayout,l=n.trace,s=o.traceIs(l,"pie"),u=l.index,d=s?n.label:l.name,h=e._context.edits.legendText&&!s,g=a.ensureSingle(t,"text","legendtext");function y(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,a,i=t.select("g[class*=math-group]"),o=i.node(),l=e._fullLayout.legend.font.size*v;if(o){var s=c.bBox(o);n=s.height,a=s.width,c.setTranslate(i,0,n/4)}else{var u=t.select(".legendtext"),d=f.lineCount(u),h=u.node();n=l*d,a=h?c.bBox(h).width:0;var g=l*(.3+(1-d)/2);f.positionText(u,p.textOffsetX,g)}n=Math.max(n,16)+3,r.height=n,r.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,i.legend.font).text(h?A(d,r):d),f.positionText(g,p.textOffsetX,0),h?g.call(f.makeEditable,{gd:e,text:d}).call(y).on("edit",function(t){this.text(A(t,r)).call(y);var i=n.trace._fullInput||{},l={};if(o.hasTransform(i,"groupby")){var s=o.getTransformIndices(i,"groupby"),c=s[s.length-1],f=a.keyedContainer(i,"transforms["+c+"].styles","target","value.name");f.set(n.trace._group,t),l=f.constructUpdate()}else l.name=t;return o.call("restyle",e,l,u)}):y(g)}function A(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function L(t,e){var r,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimek&&(i=Math.max(i-1,1)),T(e,r,t,i,n.event)}})}function S(t,e,r){var a=t._fullLayout,i=a.legend,o=i.borderwidth,l=_.isGrouped(i),s=0;if(i._width=0,i._height=0,_.isVertical(i))l&&e.each(function(t,e){c.setTranslate(this,0,e*i.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;c.setTranslate(this,o,5+o+i._height+r/2),i._height+=r,i._width=Math.max(i._width,n)}),i._width+=45+2*o,i._height+=10+2*o,l&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),s=40;else if(l){for(var u=[i._width],f=e.data(),d=0,p=f.length;do+w-k,r.each(function(t){var e=t[0],r=v?40+t[0].width:x;o+b+k+r>a._size.w&&(b=0,y+=m,i._height=i._height+m,m=0),c.setTranslate(this,o+b,5+o+e.height/2+y),i._width+=k+r,i._height=Math.max(i._height,e.height),b+=k+r,m=Math.max(e.height,m)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var T=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");c.setRect(r,0,-e.height/2,(T?0:i._width)+s,e.height)})}function C(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");var n="top";w.isBottomAnchor(e)?n="bottom":w.isMiddleAnchor(e)&&(n="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[r],r:e._width*m[r],b:e._height*m[n],t:e._height*y[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var l=e.legend,f=e.showlegend&&x(t.calcdata,l),d=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void i.autoMargin(t,"legend");for(var h=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[r],r:e._width*m[r],b:0,t:0})}(t):C(t);var d=e._size,h=d.l+d.w*l.x,g=d.t+d.h*(1-l.y);w.isRightAnchor(l)?h-=l._width:w.isCenterAnchor(l)&&(h-=l._width/2),w.isBottomAnchor(l)?g-=l._height:w.isMiddleAnchor(l)&&(g-=l._height/2);var v=l._width,x=d.w;v>x?(h=d.l,v=x):(h+v>u&&(h=u-v),h<0&&(h=0),v=Math.min(u-h,l._width));var b,_,k,M,A=l._height,L=d.h;if(A>L?(g=d.t,A=L):(g+A>f&&(g=f-A),g<0&&(g=0),A=Math.min(f-g,l._height)),c.setTranslate(z,h,g),I.on(".drag",null),z.on("wheel",null),l._height<=A||t._context.staticPlot)D.attr({width:v-l.borderwidth,height:A-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),c.setTranslate(E,0,0),P.select("rect").attr({width:v-2*l.borderwidth,height:A-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth}),c.setClipUrl(E,r),c.setRect(I,0,0,0,0),delete l._scrollY;else{var F,B,j=Math.max(p.scrollBarMinHeight,A*A/l._height),H=A-j-2*p.scrollBarMargin,q=l._height-A,V=H/q,U=Math.min(l._scrollY||0,q);D.attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),P.select("rect").attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth+U}),c.setClipUrl(E,r),Z(U,j,V),z.on("wheel",function(){Z(U=a.constrain(l._scrollY+n.event.deltaY/H*q,0,q),j,V),0!==U&&U!==q&&n.event.preventDefault()});var G=n.behavior.drag().on("dragstart",function(){F=n.event.sourceEvent.clientY,B=U}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||Z(U=a.constrain((t.clientY-F)/V+B,0,q),j,V)});I.call(G)}function Z(e,r,n){l._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(E,0,-e),c.setRect(I,v,p.scrollBarMargin+e*n,p.scrollBarWidth,r),P.select("rect").attr({y:l.borderwidth+e})}t._context.edits.legendPosition&&(z.classed("cursor-move",!0),s.init({element:z.node(),gd:t,prepFn:function(){var t=c.getTranslate(z);k=t.x,M=t.y},moveFn:function(t,e){var r=k+t,n=M+e;c.setTranslate(z,r,n),b=s.align(r,0,d.l,d.l+d.w,l.xanchor),_=s.align(n,0,d.t+d.h,d.t,l.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("relayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(r,n){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});a.size()>0&&T(t,z,a,r,n)}}))}],t)}}},{"../../constants/alignment":149,"../../constants/interactions":151,"../../lib":170,"../../lib/events":163,"../../lib/svg_text_utils":191,"../../plots/plots":247,"../../registry":259,"../color":51,"../dragelement":73,"../drawing":76,"./anchor_utils":103,"./constants":105,"./get_legend_data":108,"./handle_click":109,"./helpers":110,"./style":112,d3:16}],108:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var r,i,o={},l=[],s=!1,c={},u=0;function f(t,r){if(""!==t&&a.isGrouped(e))-1===l.indexOf(t)?(l.push(t),s=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+u;l.push(n),o[n]=[[r]],u++}}for(r=0;rr[1])return r[1]}return a}function h(t){return t[0]}if(u||f||d){var g={},v={};if(u){g.mc=p("marker.color",h),g.mx=p("marker.symbol",h),g.mo=p("marker.opacity",i.mean,[.2,1]),g.mlc=p("marker.line.color",h),g.mlw=p("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=p("marker.size",i.mean,[2,16]);g.ms=y,v.marker.size=y}d&&(v.line={width:p("line.width",h,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",h),g.ts=10,g.tc=p("textfont.color",h),g.tf=p("textfont.family",h)),r=[i.minExtend(l,g)],(a=i.minExtend(c,v)).selectedpoints=null}var m=n.select(this).select("g.legendpoints"),x=m.selectAll("path.scatterpts").data(u?r:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,a,e),u&&(r[0].mrc=3);var b=m.selectAll("g.pointtext").data(f?r:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,o=n.select(this);o.style("stroke-width",i+"px").call(l.fill,a.fillcolor),i&&l.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,s=n.select(this);s.style("fill","none").call(o.dashLine,a.line.dash,i),i&&l.stroke(s,a.line.color)})})}},{"../../lib":170,"../../registry":259,"../../traces/pie/style_one":366,"../../traces/scatter/subtypes":392,"../color":51,"../drawing":76,d3:16}],113:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),l=t("../../../build/ploticon"),s=o._,c=e.exports={};function u(t,e){var r,a,o=e.currentTarget,l=o.getAttribute("data-attr"),s=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=i.list(t,null,!0),d="on";if("zoom"===l){var p,h="in"===s?.5:2,g=(1+h)/2,v=(1-h)/2;for(a=0;a1?(_=["toggleHover"],w=["resetViews"]):f?(b=["zoomInGeo","zoomOutGeo"],_=["hoverClosestGeo"],w=["resetGeo"]):u?(_=["hoverClosest3d"],w=["resetCameraDefault3d","resetCameraLastSave3d"]):g?(_=["toggleHover"],w=["resetViewMapbox"]):_=p?["hoverClosestGl2d"]:d?["hoverClosestPie"]:["toggleHover"];c&&(_=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!c&&!p||y||(b=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==w[0]&&(w=["resetScale2d"]));u?k=["zoom3d","pan3d","orbitRotation","tableRotation"]:(c||p)&&!y||h?k=["zoom2d","pan2d"]:g||f?k=["pan2d"]:v&&(k=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),a=0,i=0;i0?d+c:c;return{ppad:c,ppadplus:u?h:g,ppadminus:u?g:h}}return{ppad:c}}function u(t,e,r,n,a){var l="category"===t.type?t.r2c:t.d2c;if(void 0!==e)return[l(e),l(r)];if(n){var s,c,u,f,d=1/0,p=-1/0,h=n.match(i.segmentRE);for("date"===t.type&&(l=o.decodeDate(l)),s=0;sp&&(p=f)));return p>=d?[d,p]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:I?V(r.xanchor)+r.x0:V(r.x0),cy:N?U(r.yanchor)-r.y0:U(r.y0),r:i}).style(a).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:I?V(r.xanchor)+r.x1:V(r.x1),cy:N?U(r.yanchor)-r.y1:U(r.y1),r:i}).style(a).classed("cursor-grab",!0),n}():e,Y={element:X.node(),gd:t,prepFn:function(n){I&&(_=V(r.xanchor));N&&(w=U(r.yanchor));"path"===r.type?z=r.path:(y=I?r.x0:V(r.x0),m=N?r.y0:U(r.y0),x=I?r.x1:V(r.x1),b=N?r.y1:U(r.y1));yb?(k=m,L="y0",T=b,S="y1"):(k=b,L="y1",T=m,S="y0");W(n),$(p,r),function(t,e,r){var n=e.xref,a=e.yref,o=i.getFromId(r,n),s=i.getFromId(r,a),c="";"paper"===n||o.autorange||(c+=n);"paper"===a||s.autorange||(c+=a);t.call(l.setClipUrl,c?"clip"+r._fullLayout._uid+c:null)}(e,r,t),Y.moveFn="move"===P?J:Q},doneFn:function(){u(e),K(p),h(e,t,r),n.call("relayout",t,B.getUpdateObj())},clickFn:function(){K(p)}};function W(t){if(R)P="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Y.element.getBoundingClientRect(),n=r.right-r.left,a=r.bottom-r.top,i=t.clientX-r.left,o=t.clientY-r.top,l=!F&&n>D&&a>E&&!t.shiftKey?c.getCursor(i/n,1-o/a):"move";u(e,l),P=l.split("-")[0]}}function J(n,a){if("path"===r.type){var i=function(t){return t},o=i,l=i;I?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?j("yanchor",r.yanchor=Z(w+a)):(l=function(t){return Z(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(z,o,l))}else I?j("xanchor",r.xanchor=G(_+n)):(j("x0",r.x0=G(y+n)),j("x1",r.x1=G(x+n))),N?j("yanchor",r.yanchor=Z(w+a)):(j("y0",r.y0=Z(m+a)),j("y1",r.y1=Z(b+a)));e.attr("d",g(t,r)),$(p,r)}function Q(n,a){if(F){var i=function(t){return t},o=i,l=i;I?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?j("yanchor",r.yanchor=Z(w+a)):(l=function(t){return Z(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(z,o,l))}else if(R){if("resize-over-start-point"===P){var s=y+n,c=N?m-a:m+a;j("x0",r.x0=I?s:G(s)),j("y0",r.y0=N?c:Z(c))}else if("resize-over-end-point"===P){var u=x+n,f=N?b-a:b+a;j("x1",r.x1=I?u:G(u)),j("y1",r.y1=N?f:Z(f))}}else{var h=~P.indexOf("n")?k+a:k,B=~P.indexOf("s")?T+a:T,X=~P.indexOf("w")?M+n:M,Y=~P.indexOf("e")?A+n:A;~P.indexOf("n")&&N&&(h=k-a),~P.indexOf("s")&&N&&(B=T-a),(!N&&B-h>E||N&&h-B>E)&&(j(L,r[L]=N?h:Z(h)),j(S,r[S]=N?B:Z(B))),Y-X>D&&(j(C,r[C]=I?X:G(X)),j(O,r[O]=I?Y:G(Y)))}e.attr("d",g(t,r)),$(p,r)}function $(t,e){(I||N)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=V(I?e.xanchor:a.midRange(r?[e.x0,e.x1]:d.extractPathCoords(e.path,f.paramIsX))),o=U(N?e.yanchor:a.midRange(r?[e.y0,e.y1]:d.extractPathCoords(e.path,f.paramIsY)));if(i=d.roundPositionForSharpStrokeRendering(i,1),o=d.roundPositionForSharpStrokeRendering(o,1),I&&N){var l="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",l)}else if(I){var s="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",s)}else{var c="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",c)}}()}function K(t){t.selectAll(".visual-cue").remove()}c.init(Y),X.node().onmousemove=W}(t,x,r,e,p)}}function h(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");t.call(l.setClipUrl,n?"clip"+e._fullLayout._uid+n:null)}function g(t,e){var r,n,o,l,s,c,u,p,h=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),y=t._fullLayout._size;if(g?(r=d.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return y.l+y.w*t},v?(o=d.shapePositionToRange(v),l=function(t){return v._offset+v.r2p(o(t,!0))}):l=function(t){return y.t+y.h*(1-t)},"path"===h)return g&&"date"===g.type&&(n=d.decodeDate(n)),v&&"date"===v.type&&(l=d.decodeDate(l)),function(t,e,r){var n=t.path,i=t.xsizemode,o=t.ysizemode,l=t.xanchor,s=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,c=t.charAt(0),u=f.paramIsX[c],d=f.paramIsY[c],p=f.numParams[c],h=t.substr(1).replace(f.paramRE,function(t){return u[n]?t="pixel"===i?e(l)+Number(t):e(t):d[n]&&(t="pixel"===o?r(s)-Number(t):r(t)),++n>p&&(t="X"),t});return n>p&&(h=h.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),c+h})}(e,n,l);if("pixel"===e.xsizemode){var m=n(e.xanchor);s=m+e.x0,c=m+e.x1}else s=n(e.x0),c=n(e.x1);if("pixel"===e.ysizemode){var x=l(e.yanchor);u=x-e.y0,p=x-e.y1}else u=l(e.y0),p=l(e.y1);if("line"===h)return"M"+s+","+u+"L"+c+","+p;if("rect"===h)return"M"+s+","+u+"H"+c+"V"+p+"H"+s+"Z";var b=(s+c)/2,_=(u+p)/2,w=Math.abs(b-s),k=Math.abs(_-u),T="A"+w+","+k,M=b+w+","+_;return"M"+M+T+" 0 1,1 "+(b+","+(_-k))+T+" 0 0,1 "+M+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],l=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return n>=l?t:(i[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var a=0;a0&&(l=l.transition().duration(e.transition.duration).ease(e.transition.easing)),l.attr("transform","translate("+(o-.5*f.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function S(t,e){var r=t._dims;return r.inputAreaStart+f.stepInset+(r.inputAreaLength-2*f.stepInset)*Math.min(1,Math.max(0,e))}function C(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-f.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*f.stepInset-2*r.inputAreaStart)))}function O(t,e,r){var n=r._dims,a=l.ensureSingle(t,"rect",f.railTouchRectClass,function(n){n.call(M,e,t,r).style("pointer-events","all")});a.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,f.tickOffset+r.ticklen+n.labelHeight)}).call(i.fill,r.bgcolor).attr("opacity",0),o.setTranslate(a,0,n.currentValueTotalHeight)}function z(t,e){var r=e._dims,n=r.inputAreaLength-2*f.railInset,a=l.ensureSingle(t,"rect",f.railRectClass);a.attr({width:n,height:f.railWidth,rx:f.railRadius,ry:f.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,f.railInset,.5*(r.inputAreaWidth-f.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[f.name],n=[],a=0;a0?[0]:[]);function l(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,v(e))}if(i.enter().append("g").classed(f.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){n.select(this).selectAll("g."+f.groupClassName).each(l)}).remove(),0!==r.length){var s=i.selectAll("g."+f.groupClassName).data(r,y);s.enter().append("g").classed(f.groupClassName,!0),s.exit().each(l).remove();for(var c=0;c0||d<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[m.side];e.attr("transform","translate("+g+")")}}}P.call(D),O&&(C?P.on(".opacity",null):(L=0,S=!0,P.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),P.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("restyle",t,g,e,y):o.call("relayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(D)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return P.classed("js-placeholder",S),_}};var d=/ [XY][0-9]* /},{"../../constants/interactions":151,"../../lib":170,"../../lib/svg_text_utils":191,"../../plots/plots":247,"../../registry":259,"../color":51,"../drawing":76,d3:16,"fast-isnumeric":18}],143:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,l=t("../../plots/pad_attributes"),s=t("../../plot_api/plot_template").templatedArray,c=s("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(s("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i({},l,{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":164,"../../plot_api/edit_types":197,"../../plot_api/plot_template":204,"../../plots/font_attributes":241,"../../plots/pad_attributes":246,"../color/attributes":50}],144:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],145:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,l=i.buttons;function s(t,e,r){function o(r,a){return n.coerce(t,e,i,r,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function r(r,a){return n.coerce(t,e,l,r,a)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:s})}},{"../../lib":170,"../../plots/array_container_defaults":210,"./attributes":143,"./constants":144}],146:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../legend/anchor_utils"),u=t("../../plot_api/plot_template").arrayEditor,f=t("../../constants/alignment").LINE_SPACING,d=t("./constants"),p=t("./scrollbox");function h(t){return t._index}function g(t,e){return+t.attr(d.menuIndexAttrName)===e._index}function v(t,e,r,n,a,i,o,l){e.active=o,u(t.layout,d.name,e).applyUpdate("active",o),"buttons"===e.type?m(t,n,null,null,e):"dropdown"===e.type&&(a.attr(d.menuIndexAttrName,"-1"),y(t,n,a,i,e),l||m(t,n,a,i,e))}function y(t,e,r,n,a){var i=l.ensureSingle(e,"g",d.headerClassName,function(t){t.style("pointer-events","all")}),s=a._dims,c=a.active,u=a.buttons[c]||d.blankHeaderOpts,f={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},p={width:s.headerWidth,height:s.headerHeight};i.call(x,a,u,t).call(L,a,f,p),l.ensureSingle(e,"text",d.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(d.arrowSymbol[a.direction])}).attr({x:s.headerWidth-d.arrowOffsetX+a.pad.l,y:s.headerHeight/2+d.textOffsetY+a.pad.t}),i.on("click",function(){r.call(S,String(g(r,a)?-1:a._index)),m(t,e,r,n,a)}),i.on("mouseover",function(){i.call(k)}),i.on("mouseout",function(){i.call(T,a)}),o.setTranslate(e,s.lx,s.ly)}function m(t,e,r,i,o){r||(r=e).attr("pointer-events","all");var s=function(t){return-1==+t.attr(d.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?d.dropdownButtonClassName:d.buttonClassName,u=r.selectAll("g."+c).data(l.filterVisible(s)),f=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(f.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var h=0,g=0,y=o._dims,m=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(m?g=y.headerHeight+d.gapButtonHeader:h=y.headerWidth+d.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(g=-d.gapButtonHeader+d.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(h=-d.gapButtonHeader+d.gapButton-y.openWidth);var b={x:y.lx+h+o.pad.l,y:y.ly+g+o.pad.t,yPad:d.gapButton,xPad:d.gapButton,index:0},_={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(l,s){var c=n.select(this);c.call(x,o,l,t).call(L,o,b),c.on("click",function(){n.event.defaultPrevented||(v(t,o,0,e,r,i,s),l.execute&&a.executeAPICommand(t,l.method,l.args),t.emit("plotly_buttonclicked",{menu:o,button:l,active:o.active}))}),c.on("mouseover",function(){c.call(k)}),c.on("mouseout",function(){c.call(T,o),u.call(w,o)})}),u.call(w,o),m?(_.w=Math.max(y.openWidth,y.headerWidth),_.h=b.y-_.t):(_.w=b.x-_.l,_.h=Math.max(y.openHeight,y.headerHeight)),_.direction=o.direction,i&&(u.size()?function(t,e,r,n,a,i){var o,l,s,c=a.direction,u="up"===c||"down"===c,f=a._dims,p=a.active;if(u)for(l=0,s=0;s0?[0]:[]);if(o.enter().append("g").classed(d.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+d.headerGroupClassName).each(i)}).remove(),0!==r.length){var s=o.selectAll("g."+d.headerGroupClassName).data(r,h);s.enter().append("g").classed(d.headerGroupClassName,!0);for(var c=l.ensureSingle(o,"g",d.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,M=l.barLength+2*l.barPad,A=l.barWidth+2*l.barPad,L=h,S=v+y;S+A>c&&(S=c-A);var C=this.container.selectAll("rect.scrollbar-horizontal").data(T?[0]:[]);C.exit().on(".drag",null).remove(),C.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,l.barColor),T?(this.hbar=C.attr({rx:l.barRadius,ry:l.barRadius,x:L,y:S,width:M,height:A}),this._hbarXMin=L+M/2,this._hbarTranslateMax=w-M):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var O=y>k,z=l.barWidth+2*l.barPad,P=l.barLength+2*l.barPad,D=h+g,E=v;D+z>s&&(D=s-z);var I=this.container.selectAll("rect.scrollbar-vertical").data(O?[0]:[]);I.exit().on(".drag",null).remove(),I.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,l.barColor),O?(this.vbar=I.attr({rx:l.barRadius,ry:l.barRadius,x:D,y:E,width:z,height:P}),this._vbarYMin=E+P/2,this._vbarTranslateMax=k-P):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var N=this.id,R=u-.5,F=O?f+z+.5:f+.5,B=d-.5,j=T?p+A+.5:p+.5,H=o._topdefs.selectAll("#"+N).data(T||O?[0]:[]);if(H.exit().remove(),H.enter().append("clipPath").attr("id",N).append("rect"),T||O?(this._clipRect=H.select("rect").attr({x:Math.floor(R),y:Math.floor(B),width:Math.ceil(F)-Math.floor(R),height:Math.ceil(j)-Math.floor(B)}),this.container.call(i.setClipUrl,N),this.bg.attr({x:h,y:v,width:g,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),T||O){var q=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));T&&this.hbar.on(".drag",null).call(V),O&&this.vbar.on(".drag",null).call(V)}this.setTranslate(e,r)},l.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},l.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},l.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},l.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,a=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,a)-r)/(a-r)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,l=i+this._vbarTranslateMax;e=(o.constrain(n.event.y,i,l)-i)/(l-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},l.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/r;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var l=e/n;this.vbar.call(i.setTranslate,t,e+l*this._vbarTranslateMax)}}},{"../../lib":170,"../color":51,"../drawing":76,d3:16}],149:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],150:[function(t,e,r){"use strict";e.exports={COMPARISON_OPS:["=","!=","<",">=",">","<="],COMPARISON_OPS2:["=","<",">=",">","<="],INTERVAL_OPS:["[]","()","[)","(]","][",")(","](",")["],SET_OPS:["{}","}{"],CONSTRAINT_REDUCTION:{"=":"=","<":"<","<=":"<",">":">",">=":">","[]":"[]","()":"[]","[)":"[]","(]":"[]","][":"][",")(":"][","](":"][",")[":"]["}}},{}],151:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],152:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],153:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],154:[function(t,e,r){"use strict";r.version="1.42.5",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config");for(var n=t("./registry"),a=r.register=n.register,i=t("./plot_api"),o=Object.keys(i),l=0;ll-1e-15}function c(t,e){return i(e-t,l)}function u(t,e){if(s(e))return!0;var r,n;e[0](n=a(n,l))&&(n+=l);var i=a(t,l),o=i+l;return i>=r&&i<=n||o>=r&&o<=n}function f(t,e,r,n,a,i,c){a=a||0,i=i||0;var u,f,d,p,h,g=s([r,n]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(u=0,f=o,d=l):r=a&&t<=i);var a,i},pathArc:function(t,e,r,n,a){return f(null,t,e,r,n,a,0)},pathSector:function(t,e,r,n,a){return f(null,t,e,r,n,a,1)},pathAnnulus:function(t,e,r,n,a,i){return f(t,e,r,n,a,i,1)}}},{"./mod":177}],157:[function(t,e,r){"use strict";var n=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function l(t){return n(t)||o(t)}r.isTypedArray=o,r.isArrayOrTypedArray=l,r.isArray1D=function(t){return!l(t[0])},r.ensureArray=function(t,e){return n(t)||(t=[]),t.length=e,t},r.concat=function(){var t,e,r,a,i,o,l,s,c=[],u=!0,f=0;for(r=0;ra.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,a){t%1||!n(t)||void 0!==a.min&&ta.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var a="number"==typeof t;!0!==n.strict&&a?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){a(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(u(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var a=n.regex||s(r);"string"==typeof t&&a.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!s(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=n&&t<=a?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),y=t.charAt(0);!c||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:m);if(!k)return u;var T=k[1],M=k[3]||"1",A=Number(k[5]||1),L=Number(k[7]||0),S=Number(k[9]||0),C=Number(k[11]||0);if(c){if(2===T.length)return u;var O;T=Number(T);try{var z=v.getComponentMethod("calendars","getCal")(e);if(w){var P="i"===M.charAt(M.length-1);M=parseInt(M,10),O=z.newDate(T,z.toMonthIndex(T,M,P),A)}else O=z.newDate(T,Number(M),A)}catch(t){return u}return O?(O.toJD()-g)*f+L*d+S*p+C*h:u}T=2===T.length?(Number(T)+2e3-b)%100+b:Number(T),M-=1;var D=new Date(Date.UTC(2e3,M,A,L,S));return D.setUTCFullYear(T),D.getUTCMonth()!==M?u:D.getUTCDate()!==A?u:D.getTime()+C*h},n=r.MIN_MS=r.dateTime2ms("-9999"),a=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==u};var k=90*f,T=3*d,M=5*p;function A(t,e,r,n,a){if((e||r||n||a)&&(t+=" "+w(e,2)+":"+w(r,2),(n||a)&&(t+=":"+w(n,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=a))return u;e||(e=0);var i,o,l,c,m,x,b=Math.floor(10*s(t+.05,1)),w=Math.round(t-b/10);if(_(r)){var L=Math.floor(w/f)+g,S=Math.floor(s(t,f));try{i=v.getComponentMethod("calendars","getCal")(r).fromJD(L).formatDate("yyyy-mm-dd")}catch(t){i=y("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=n+f&&t<=a-f))return u;var e=Math.floor(10*s(t+.05,1)),r=new Date(Math.round(t-e/10));return A(i.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===u)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return l.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return l.error("unrecognized date",t),e;return t};var L=/%\d?f/g;function S(t,e,r,n){t=t.replace(L,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(a)}var C=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,a,i){if(a=_(a)&&a,!e)if("y"===r)e=i.year;else if("m"===r)e=i.month;else{if("d"!==r)return function(t,e){var r=s(t+.05,f),n=w(Math.floor(r/d),2)+":"+w(s(Math.floor(r/p),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(s(t/h,60),C[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+a}return n}(t,r)+"\n"+S(i.dayMonthYear,t,n,a);e=i.dayMonth+"\n"+i.year}return S(e,t,n,a)};var O=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=s(t,f);if(t=Math.round(t-n),r)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(r),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){l.error("invalid ms "+t+" in calendar "+r)}var c=new Date(t+O);return c.setUTCMonth(c.getUTCMonth()+e)+n-O},r.findExactDates=function(t,e){for(var r,n,a=0,i=0,l=0,s=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}function s(t,e,r,n,a){var i=n*t+a*e;if(i<0)return n*n+a*a;if(i>r){var o=n-t,l=a-e;return o*o+l*l}var s=n*e-a*t;return s*s/r}r.segmentsIntersect=l,r.segmentDistance=function(t,e,r,n,a,i,o,c){if(l(t,e,r,n,a,i,o,c))return 0;var u=r-t,f=n-e,d=o-a,p=c-i,h=u*u+f*f,g=d*d+p*p,v=Math.min(s(u,f,h,a-t,i-e),s(u,f,h,o-t,c-e),s(d,p,g,t-a,e-i),s(d,p,g,r-a,n-i));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,l){if(t===a&&l===i||(n={},a=t,i=l),n[r])return n[r];var s=t.getPointAtLength(o(r-l/2,e)),c=t.getPointAtLength(o(r+l/2,e)),u=Math.atan((c.y-s.y)/(c.x-s.x)),f=t.getPointAtLength(o(r,e)),d={x:(4*f.x+s.x+c.x)/6,y:(4*f.y+s.y+c.y)/6,theta:u};return n[r]=d,d},r.clearLocationCache=function(){a=null},r.getVisibleSegment=function(t,e,r){var n,a,i=e.left,o=e.right,l=e.top,s=e.bottom,c=0,u=t.getTotalLength(),f=u;function d(e){var r=t.getPointAtLength(e);0===e?n=r:e===u&&(a=r);var c=r.xo?r.x-o:0,f=r.ys?r.y-s:0;return Math.sqrt(c*c+f*f)}for(var p=d(c);p;){if((c+=p+r)>f)return;p=d(c)}for(p=d(f);p;){if(c>(f-=p+r))return;p=d(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(n.x-a.x)<.1&&Math.abs(n.y-a.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var a,i,o,l=(n=n||{}).pathLength||t.getTotalLength(),s=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(l)[r]?-1:1,f=0,d=0,p=l;f0?p=a:d=a,f++}return i}},{"./mod":177}],168:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],169:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],170:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../constants/numerical"),o=i.FP_SAFE,l=i.BADNUM,s=e.exports={};s.nestedProperty=t("./nested_property"),s.keyedContainer=t("./keyed_container"),s.relativeAttr=t("./relative_attr"),s.isPlainObject=t("./is_plain_object"),s.toLogRange=t("./to_log_range"),s.relinkPrivateKeys=t("./relink_private");var c=t("./array");s.isTypedArray=c.isTypedArray,s.isArrayOrTypedArray=c.isArrayOrTypedArray,s.isArray1D=c.isArray1D,s.ensureArray=c.ensureArray,s.concat=c.concat;var u=t("./mod");s.mod=u.mod,s.modHalf=u.modHalf;var f=t("./coerce");s.valObjectMeta=f.valObjectMeta,s.coerce=f.coerce,s.coerce2=f.coerce2,s.coerceFont=f.coerceFont,s.coerceHoverinfo=f.coerceHoverinfo,s.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,s.validate=f.validate;var d=t("./dates");s.dateTime2ms=d.dateTime2ms,s.isDateTime=d.isDateTime,s.ms2DateTime=d.ms2DateTime,s.ms2DateTimeLocal=d.ms2DateTimeLocal,s.cleanDate=d.cleanDate,s.isJSDate=d.isJSDate,s.formatDate=d.formatDate,s.incrementMonth=d.incrementMonth,s.dateTick0=d.dateTick0,s.dfltRange=d.dfltRange,s.findExactDates=d.findExactDates,s.MIN_MS=d.MIN_MS,s.MAX_MS=d.MAX_MS;var p=t("./search");s.findBin=p.findBin,s.sorterAsc=p.sorterAsc,s.sorterDes=p.sorterDes,s.distinctVals=p.distinctVals,s.roundUp=p.roundUp,s.sort=p.sort,s.findIndexOfMin=p.findIndexOfMin;var h=t("./stats");s.aggNums=h.aggNums,s.len=h.len,s.mean=h.mean,s.midRange=h.midRange,s.variance=h.variance,s.stdev=h.stdev,s.interp=h.interp;var g=t("./matrix");s.init2dArray=g.init2dArray,s.transposeRagged=g.transposeRagged,s.dot=g.dot,s.translationMatrix=g.translationMatrix,s.rotationMatrix=g.rotationMatrix,s.rotationXYMatrix=g.rotationXYMatrix,s.apply2DTransform=g.apply2DTransform,s.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");s.deg2rad=v.deg2rad,s.rad2deg=v.rad2deg,s.angleDelta=v.angleDelta,s.angleDist=v.angleDist,s.isFullCircle=v.isFullCircle,s.isAngleInsideSector=v.isAngleInsideSector,s.isPtInsideSector=v.isPtInsideSector,s.pathArc=v.pathArc,s.pathSector=v.pathSector,s.pathAnnulus=v.pathAnnulus;var y=t("./geometry2d");s.segmentsIntersect=y.segmentsIntersect,s.segmentDistance=y.segmentDistance,s.getTextLocation=y.getTextLocation,s.clearLocationCache=y.clearLocationCache,s.getVisibleSegment=y.getVisibleSegment,s.findPointOnPath=y.findPointOnPath;var m=t("./extend");s.extendFlat=m.extendFlat,s.extendDeep=m.extendDeep,s.extendDeepAll=m.extendDeepAll,s.extendDeepNoArrays=m.extendDeepNoArrays;var x=t("./loggers");s.log=x.log,s.warn=x.warn,s.error=x.error;var b=t("./regex");s.counterRegex=b.counter;var _=t("./throttle");function w(t){var e={};for(var r in t)for(var n=t[r],a=0;ao?l:a(t)?Number(t):l:l},s.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},s.noop=t("./noop"),s.identity=t("./identity"),s.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},s.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},s.simpleMap=function(t,e,r,n){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,r)?a>10?(s.warn("randstr failed uniqueness"),c):t(e,r,n,(a||0)+1):c},s.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},s.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,a,i,o=t.length,l=2*o,s=2*e-1,c=new Array(s),u=new Array(o);for(r=0;r=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=o&&(a=l-1-a),i+=t[a]*c[n];u[r]=i}return u},s.syncOrAsync=function(t,e,r){var n;function a(){return s.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(a).then(void 0,s.promiseError);return r&&r(e)},s.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},s.noneOrAll=function(t,e,r){if(t){var n,a=!1,i=!0;for(n=0;n1?a+o[1]:"";if(i&&(o.length>1||l.length>4||r))for(;n.test(l);)l=l.replace(n,"$1"+i+"$2");return l+s};var M=/%{([^\s%{}]*)}/g,A=/^\w*$/;s.templateString=function(t,e){var r={};return t.replace(M,function(t,n){return A.test(n)?e[n]||"":(r[n]=r[n]||s.nestedProperty(e,n).get,r[n]()||"")})};s.subplotSort=function(t,e){for(var r=Math.min(t.length,e.length)+1,n=0,a=0,i=0;i=48&&o<=57,c=l>=48&&l<=57;if(s&&(n=10*n+o-48),c&&(a=10*a+l-48),!s||!c){if(n!==a)return n-a;if(o!==l)return o-l}}return a-n};var L=2e9;s.seedPseudoRandom=function(){L=2e9},s.pseudoRandom=function(){var t=L;return L=(69069*L+1)%4294967296,Math.abs(L-t)<429496729?s.pseudoRandom():L/4294967296}},{"../constants/numerical":152,"./angles":156,"./array":157,"./clean_number":158,"./clear_responsive":160,"./coerce":161,"./dates":162,"./extend":164,"./filter_unique":165,"./filter_visible":166,"./geometry2d":167,"./get_graph_div":168,"./identity":169,"./is_plain_object":171,"./keyed_container":172,"./localize":173,"./loggers":174,"./make_trace_groups":175,"./matrix":176,"./mod":177,"./nested_property":178,"./noop":179,"./notifier":180,"./push_unique":183,"./regex":185,"./relative_attr":186,"./relink_private":187,"./search":188,"./stats":190,"./throttle":192,"./to_log_range":193,d3:16,"fast-isnumeric":18}],171:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],172:[function(t,e,r){"use strict";var n=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,r,i){var o,l,s;r=r||"name",i=i||"value";var c={};e&&e.length?(s=n(t,e),l=s.get()):l=t,e=e||"";var u={};if(l)for(o=0;o2)return c[e]=2|c[e],d.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],178:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,c=e.split(".");s/g),o=0;oi||c===a||cl||e&&s(t))}:function(t,e){var s=t[0],c=t[1];if(s===a||si||c===a||cl)return!1;var u,f,d,p,h,g=r.length,v=r[0][0],y=r[0][1],m=0;for(u=1;uMath.max(f,v)||c>Math.max(d,y)))if(cu||Math.abs(n(o,d))>a)return!0;return!1};i.filter=function(t,e){var r=[t[0]],n=0,a=0;function i(i){t.push(i);var l=r.length,s=n;r.splice(a+1);for(var c=s+1;c1&&i(t.pop());return{addPt:i,raw:t,filtered:r}}},{"../constants/numerical":152,"./matrix":176}],183:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ra.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function c(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,u,f=0,d=e.length,p=0,h=d>1?(e[d-1]-e[0])/(d-1):1;for(u=h>=0?r?o:l:r?c:s,t+=1e-9*h*(r?-1:1)*(h>=0?1:-1);f90&&a.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,a=e[n]-e[0]||1,i=a/(n||1)/1e4,o=[e[0]],l=0;le[l]+i&&(a=Math.min(a,e[l+1]-e[l]),o.push(e[l+1]));return{vals:o,minDiff:a}},r.roundUp=function(t,e,r){for(var n,a=0,i=e.length-1,o=0,l=r?0:1,s=r?1:0,c=r?Math.ceil:Math.floor;a0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||i;for(var r,n=1/0,a=0;ai.length)&&(o=i.length),n(e)||(e=!1),a(i[0])){for(s=new Array(o),l=0;lt.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":157,"fast-isnumeric":18}],191:[function(t,e,r){"use strict";var n=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function l(t,e){return t.node().getBoundingClientRect()[e]}var s=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var L=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&L.match(s),O=n.select(t.node().parentNode);if(!O.empty()){var z=t.attr("class")?t.attr("class").split(" ")[0]:"text";return z+="-math",O.selectAll("svg."+z).remove(),O.selectAll("g."+z+"-group").remove(),t.style("display",null).attr({"data-unformatted":L,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),i={fontSize:r};!function(t,e,r){var i,o,l,s;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),l=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+a.randstr({},64);return s=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(s.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(s.select(".MathJax_SVG").empty()||!s.select("svg").node())a.log("There was an error in the tex syntax.",t),r();else{var o=s.select("svg").node().getBoundingClientRect();r(s.select(".MathJax_SVG"),e,o)}if(s.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==l&&(MathJax.Hub.processSectionDelay=l),MathJax.Hub.Config(o)})}(S[2],i,function(n,a,i){O.selectAll("svg."+z).remove(),O.selectAll("g."+z+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return P(),void e();var s=O.append("g").classed(z+"-group",!0).attr({"pointer-events":"none","data-unformatted":L,"data-math":"Y"});s.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:z,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=l(o,"width"),f=l(o,"height"),d=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(r||l(t,"height"))/4;"y"===z[0]?(s.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===z[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===z[0]?o.attr({x:0,y:p}):o.attr({x:d,y:+t.attr("y")+p-f/2}),v&&v.call(t,s),e(s)})})):P(),t}function P(){O.empty()||(z=t.attr("class")+"-math",O.select("svg."+z).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var r,l=!1,s=[],c=-1;function u(){c++;var e=document.createElementNS(i.svg,"tspan");n.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),r=e;var a=s;if(s=[{node:e}],a.length>1)for(var l=1;l doesnt match end tag <"+t+">. Pretending it did match.",e),r=s[s.length-1].node}else a.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(r=t,s=[{node:t}]);for(var O=e.split(m),z=0;z|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},d={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},h="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,m=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,T=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function M(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&C(n)}var A=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var L={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function C(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):L[e])||t})}function O(t,e,r){var n,a,i,o=r.horizontalAlign,l=r.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-n.height}:"middle"===l?function(){return s.top+(s.height-n.height)/2}:function(){return s.top},i="right"===o?function(){return s.right-n.width}:"center"===o?function(){return s.left+(s.width-n.width)/2}:function(){return s.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:i()-c.left+"px","z-index":1e3}),this}}r.convertEntities=C,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function a(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var i=a("x",e),o=a("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},r.makeEditable=function(t,e){var r=e.gd,a=e.delegate,i=n.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function l(){!function(){var a=n.select(r).select(".svg-container"),o=a.append("div"),l=t.node().style,c=parseFloat(l.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":l.fontFamily||"Arial","font-size":c,color:e.fill||l.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(O(t,a,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=n.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),n.select(this).call(O(t,a,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(s)}(),t.style({opacity:0});var a,l=o.attr("class");(a=l?"."+l.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(a).style({opacity:0})}function s(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?l():o.on("click",l),n.rebind(t,i,"on")}},{"../constants/alignment":149,"../constants/xmlns_namespaces":153,"../lib":170,d3:16}],192:[function(t,e,r){"use strict";var n={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var i=n[t],o=Date.now();if(!i){for(var l in n)n[l].tsi.ts+e?s():i.timer=setTimeout(function(){s(),i.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)a(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],193:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":18}],194:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],195:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],196:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,a=n.layoutArrayContainers,i=n.layoutArrayRegexes,o=t.split("[")[0],l=0;l0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var n=(l.subplotsRegistry.cartesian||{}).attrRegex,i=(l.subplotsRegistry.gl3d||{}).attrRegex,s=Object.keys(t);for(e=0;e3?(A.x=1.02,A.xanchor="left"):A.x<-2&&(A.x=-.02,A.xanchor="right"),A.y>3?(A.y=1.02,A.yanchor="bottom"):A.y<-2&&(A.y=-.02,A.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=m(e);r;){if(r in t)return!0;r=m(r)}return!1};var x=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&o.warn("Full array edits are incompatible with other edits",f);var m=r[""][""];if(u(m))e.set(null);else{if(!Array.isArray(m))return o.warn("Unrecognized full array edit value",f,m),!0;e.set(m)}return!g&&(d(v,y),p(t),!0)}var x,b,_,w,k,T,M,A=Object.keys(r).map(Number).sort(l),L=e.get(),S=L||[],C=n(y,f).get(),O=[],z=-1,P=S.length;for(x=0;xS.length-(M?0:1))o.warn("index out of range",f,_);else if(void 0!==T)k.length>1&&o.warn("Insertion & removal are incompatible with edits to the same index.",f,_),u(T)?O.push(_):M?("add"===T&&(T={}),S.splice(_,0,T),C&&C.splice(_,0,{})):o.warn("Unrecognized full object edit value",f,_,T),-1===z&&(z=_);else for(b=0;b=0;x--)S.splice(O[x],1),C&&C.splice(O[x],1);if(S.length?L||e.set(S):e.set(null),g)return!1;if(d(v,y),h!==i){var D;if(-1===z)D=A;else{for(P=Math.max(S.length,P),D=[],x=0;x=z);x++)D.push(_);for(x=z;x=t.data.length||a<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(a,n+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+r+" must be unique.")}}function D(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),P(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&P(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function E(t,e,r,n,i){!function(t,e,r,n){var a=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var i in P(t,r,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==r.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in n)||!Array.isArray(n[i])||n[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var l=function(t,e,r,n){var i,l,s,c,u,f=o.isPlainObject(n),d=[];for(var p in Array.isArray(r)||(r=[r]),r=z(r,t.data.length-1),e)for(var h=0;h=0&&r=0&&r0&&"string"!=typeof C.parts[z];)z--;var P=C.parts[z],D=C.parts[z-1]+"."+P,E=C.parts.slice(0,z).join("."),I=o.nestedProperty(t.layout,E).get(),R=o.nestedProperty(l,E).get(),F=C.get();if(void 0!==O){m[S]=O,x[S]="reverse"===P?O:N(F);var B=u.getLayoutValObject(l,C.parts);if(B&&B.impliedEdits&&null!==O)for(var V in B.impliedEdits)b(o.relativeAttr(S,V),B.impliedEdits[V]);if(-1!==["width","height"].indexOf(S))if(O){b("autosize",null);var G="height"===S?"width":"height";b(G,l[G])}else l[S]=t._initialAutoSize[S];else if("autosize"===S)b("width",O?null:l.width),b("height",O?null:l.height);else if(D.match(j))L(D),o.nestedProperty(l,E+"._inputRange").set(null);else if(D.match(H)){L(D),o.nestedProperty(l,E+"._inputRange").set(null);var Z=o.nestedProperty(l,E).get();Z._inputDomain&&(Z._input.domain=Z._inputDomain.slice())}else D.match(q)&&o.nestedProperty(l,E+"._inputDomain").set(null);if("type"===P){var X=I,Y="linear"===R.type&&"log"===O,W="log"===R.type&&"linear"===O;if(Y||W){if(X&&X.range)if(R.autorange)Y&&(X.range=X.range[1]>X.range[0]?[1,2]:[2,1]);else{var J=X.range[0],Q=X.range[1];Y?(J<=0&&Q<=0&&b(E+".autorange",!0),J<=0?J=Q/1e6:Q<=0&&(Q=J/1e6),b(E+".range[0]",Math.log(J)/Math.LN10),b(E+".range[1]",Math.log(Q)/Math.LN10)):(b(E+".range[0]",Math.pow(10,J)),b(E+".range[1]",Math.pow(10,Q)))}else b(E+".autorange",!0);Array.isArray(l._subplots.polar)&&l._subplots.polar.length&&l[C.parts[0]]&&"radialaxis"===C.parts[1]&&delete l[C.parts[0]]._subplot.viewInitial["radialaxis.range"],c.getComponentMethod("annotations","convertCoords")(t,R,O,b),c.getComponentMethod("images","convertCoords")(t,R,O,b)}else b(E+".autorange",!0),b(E+".range",null);o.nestedProperty(l,E+"._inputRange").set(null)}else if(P.match(M)){var $=o.nestedProperty(l,S).get(),K=(O||{}).type;K&&"-"!==K||(K="linear"),c.getComponentMethod("annotations","convertCoords")(t,$,K,b),c.getComponentMethod("images","convertCoords")(t,$,K,b)}var tt=_.containerArrayMatch(S);if(tt){r=tt.array,n=tt.index;var et=tt.property,rt=(o.nestedProperty(i,r)||[])[n]||{},nt=B||{editType:"calc"};""!==n&&""===et&&(_.isAddVal(O)?x[S]=null:_.isRemoveVal(O)?x[S]=rt:o.warn("unrecognized full object value",e)),T.update(y,nt),d[r]||(d[r]={});var at=d[r][n];at||(at=d[r][n]={}),at[et]=O,delete e[S]}else"reverse"===P?(I.range?I.range.reverse():(b(E+".autorange",!0),I.range=[1,0]),R.autorange?y.calc=!0:y.plot=!0):(l._has("scatter-like")&&l._has("regl")&&"dragmode"===S&&("lasso"===O||"select"===O)&&"lasso"!==F&&"select"!==F?y.plot=!0:B?T.update(y,B):y.calc=!0,C.set(O))}}for(r in d){_.applyContainerArrayChanges(t,o.nestedProperty(i,r),d[r],y)||(y.plot=!0)}var it=l._axisConstraintGroups||[];for(k in A)for(n=0;n=a.length?a[0]:a[t]:a}function s(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function c(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(i,u){function d(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,f.transition(t,e.frame.data,e.frame.layout,w.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function p(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&d()};e()}var h,g,v=0;function y(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var m=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))m.push({type:"object",data:y(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(h=0;h0&&TT)&&M.push(g);m=M}}m.length>0?function(e){if(0!==e.length){for(var a=0;a=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(u[g]||h[g]||{}).name,y=e[n].name,m=u[v]||h[v];v&&y&&"number"==typeof y&&m&&A<5&&(A++,o.warn('addFrames: overwriting frame "'+(u[v]||h[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===A&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),h[g]={name:g},p.push({frame:f.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:d+n})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(a=p[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;u[a.name="frame "+t._transitionData._counter++];);if(u[a.name]){for(i=0;i=0;r--)n=e[r],i.push({type:"delete",index:n}),l.unshift({type:"insert",index:n,value:a[n]});var c=f.modifyFrames,u=f.modifyFrames,d=[t,l],p=[t,i];return s&&s.add(t,c,d,u,p),f.modifyFrames(t,i)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return f.cleanPlot([],{},r,e),f.purge(t),l.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":51,"../components/colorbar/connect":53,"../components/drawing":76,"../constants/xmlns_namespaces":153,"../lib":170,"../lib/events":163,"../lib/queue":184,"../lib/svg_text_utils":191,"../plots/cartesian/axes":214,"../plots/cartesian/constants":220,"../plots/cartesian/graph_interact":224,"../plots/plots":247,"../plots/polar/legacy":250,"../registry":259,"./edit_types":197,"./helpers":198,"./manage_arrays":200,"./plot_config":202,"./plot_schema":203,"./subroutines":205,d3:16,"fast-isnumeric":18,"has-hover":20}],202:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],203:[function(t,e,r){"use strict";var n=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),l=t("../plots/frame_attributes"),s=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),d=a.extendFlat,p=a.extendDeepAll,h=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",y=[g,v,"_arrayAttrRegexps","_deprecated"];function m(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(x(e[r]))r++;else if(r=i.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!x(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):h(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(h(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=s.length)return!1;a=(r=(n.transformsRegistry[s[u].type]||{}).attributes)&&r[e[2]],l=3}else if("area"===t.type)a=c[o];else{var f=t._module;if(f||(f=(n.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(r=f.attributes)&&r[o])){var d=f.basePlotModule;d&&d.attributes&&(a=d.attributes[o])}a||(a=i[o])}return m(a,e,l)},r.getLayoutValObject=function(t,e){return m(function(t,e){var r,a,i,l,s=t._basePlotModules;if(s){var c;for(r=0;r=a&&(r._input||{})._templateitemname;l&&(o=a);var s,c=e+"["+o+"]";function u(){s={},l&&(s[c]={},s[c][i]=l)}function f(t,e){l?n.nestedProperty(s[c],t).set(e):s[c+"."+t]=e}function d(){var t=s;return u(),t}return u(),{modifyBase:function(t,e){s[t]=e},modifyItem:f,getUpdateObj:d,applyUpdate:function(e,r){e&&f(e,r);var a=d();for(var i in a)n.nestedProperty(t,i).set(a[i])}}}},{"../lib":170,"../plots/attributes":211}],205:[function(t,e,r){"use strict";var n=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),l=t("../lib/clear_gl_canvases"),s=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),d=t("../plots/cartesian/axes"),p=t("../constants/alignment"),h=t("../plots/cartesian/constraints"),g=h.enforce,v=h.clean,y=t("../plots/cartesian/autorange").doAutoRange;function m(t,e,r){for(var n=0;n=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function x(t){var e,a,i,l,u,h=t._fullLayout,g=h._size,v=g.p,y=d.list(t,"",!0);if(h._paperdiv.style({width:t._context.responsive&&h.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":h.width+"px",height:t._context.responsive&&h.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":h.height+"px"}).selectAll(".main-svg").call(c.setSize,h.width,h.height),t._context.setBackground(t,h.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!h._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-v-n:e._offset+e._length+v+n:g.t+g.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+v+n:e._offset-v-n:g.l+g.w*(t.position||0)+n%1}for(e=0;ek?u.push({code:"unused",traceType:m,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:m,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var i=e[n],o=p(e,n,r);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&u.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&h(i)&&t(i,o)}}({data:v,layout:d},""),u.length)return u.map(g)}},{"../lib":170,"../plots/attributes":211,"../plots/plots":247,"./plot_config":202,"./plot_schema":203,"./plot_template":204}],207:[function(t,e,r){"use strict";var n=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),l=t("../snapshot/svgtoimg"),s={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,u,f;function d(t){return!(t in e)||a.validate(e[t],s[t])}if(e=e||{},a.isPlainObject(t)?(r=t.data||[],u=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),r=a.extendDeep([],t.data),u=a.extendDeep({},t.layout),f=t._context),!d("width")||!d("height"))throw new Error("Height and width should be pixel values.");if(!d("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function h(t,r){return a.coerce(e,p,s,t,r)}var g=h("format"),v=h("width"),y=h("height"),m=h("scale"),x=h("setBackground"),b=h("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},u);v&&(w.width=v),y&&(w.height=y);var k=a.extendFlat({},f,{staticPlot:!0,setBackground:x}),T=i.getRedrawFunc(_);function M(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function A(){return new Promise(function(t,e){var r=o(_,g,m),i=_._fullLayout.width,s=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(b?r:"data:image/svg+xml,"+encodeURIComponent(r));var c=document.createElement("canvas");c.id=a.randstr(),l({format:g,width:i,height:s,scale:m,canvas:c,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,k).then(T).then(M).then(A).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":170,"../snapshot/helpers":263,"../snapshot/svgtoimg":265,"../snapshot/tosvg":267,"./plot_api":201}],208:[function(t,e,r){"use strict";var n=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),l=n.isPlainObject,s=Array.isArray,c=n.isArrayOrTypedArray;function u(t,e,r,a,i,o){o=o||[];for(var f=Object.keys(t),d=0;dx.length&&a.push(p("unused",i,y.concat(x.length)));var T,M,A,L,S,C=x.length,O=Array.isArray(k);if(O&&(C=Math.min(C,k.length)),2===b.dimensions)for(M=0;Mx[M].length&&a.push(p("unused",i,y.concat(M,x[M].length)));var z=x[M].length;for(T=0;T<(O?Math.min(z,k[M].length):z);T++)A=O?k[M][T]:k,L=m[M][T],S=x[M][T],n.validate(L,A)?S!==L&&S!==+L&&a.push(p("dynamic",i,y.concat(M,T),L,S)):a.push(p("value",i,y.concat(M,T),L))}else a.push(p("array",i,y.concat(M),m[M]));else for(M=0;M1&&d.push(p("object","layout"))),a.supplyDefaults(h);for(var g=h._fullData,v=r.length,y=0;y0&&((b=M-o(v)-o(y))>A?_/b>L&&(m=v,x=y,L=_/b):_/M>L&&(m={val:v.val,pad:0},x={val:y.val,pad:0},L=_/M));if(d===p){var S=d-1,C=d+1;if(k)if(0===d)i=[0,1];else{var O=(d>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),z=d/(1-Math.min(.5,O/M));i=d>0?[0,z]:[z,0]}else i=T?[Math.max(0,S),Math.max(1,C)]:[S,C]}else k?(m.val>=0&&(m={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):T&&(m.val-L*o(m)<0&&(m={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),L=(x.val-m.val)/(M-o(m)-o(x)),i=[m.val-L*o(m),x.val+L*o(x)];return h&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function l(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function s(t,e){var r,n,a,i=e._id,o=t._fullData,l=t._fullLayout,s=[],f=[];function d(t,e){for(r=0;r=r&&(c.extrapad||!o)){l=!1;break}a(e,c.val)&&c.pad<=r&&(o||!c.extrapad)&&(t.splice(s,1),s--)}if(l){var u=i&&0===e;t.push({val:e,pad:u?0:r,extrapad:!u&&o})}}function d(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:o,makePadFn:l,doAutoRange:function(t,e){e._length||e.setScale();var r;e.autorange&&(e.range=o(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l),(r=e._input).range=e.range.slice(),r.autorange=e.autorange);if(e._anchorAxis&&e._anchorAxis.rangeslider){var n=e._anchorAxis.rangeslider[e._name];n&&"auto"===n.rangemode&&(n.range=o(t,e)),(r=e._anchorAxis._input).rangeslider[e._name]=a.extendFlat({},n)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var a,o,l,s,f,p,h,g,v,y=[],m=[],x=e.length,b=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function T(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var M=T((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),A=T((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),L=T(r.vpadplus||r.vpad),S=T(r.vpadminus||r.vpad);if(!k){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=z;a--)O(a);return{min:y,max:m}},concatExtremes:s}},{"../../constants/numerical":152,"../../lib":170,"fast-isnumeric":18}],214:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),d=t("./layout_attributes"),p=t("./clean_ticks"),h=t("../../constants/numerical"),g=h.ONEAVGYEAR,v=h.ONEAVGMONTH,y=h.ONEDAY,m=h.ONEHOUR,x=h.ONEMIN,b=h.ONESEC,_=h.MINUS_SIGN,w=h.BADNUM,k=t("../../constants/alignment").MID_SHIFT,T=t("../../constants/alignment").LINE_SPACING,M=e.exports={};M.setConvert=t("./set_convert");var A=t("./axis_autotype"),L=t("./axis_ids");M.id2name=L.id2name,M.name2id=L.name2id,M.cleanId=L.cleanId,M.list=L.list,M.listIds=L.listIds,M.getFromId=L.getFromId,M.getFromTrace=L.getFromTrace;var S=t("./autorange");M.getAutoRange=S.getAutoRange,M.findExtremes=S.findExtremes,M.coerceRef=function(t,e,r,n,a,i){var o=n.charAt(n.length-1),s=r._fullLayout._subplots[o+"axis"],c=n+"ref",u={};return a||(a=s[0]||i),i||(i=a),u[c]={valType:"enumerated",values:s.concat(i?[i]:[]),dflt:a},l.coerce(t,e,u,c)},M.coercePosition=function(t,e,r,n,a,i){var o,s;if("paper"===n||"pixel"===n)o=l.ensureNumber,s=r(a,i);else{var c=M.getFromId(e,n);s=r(a,i=c.fraction2r(i)),o=c.cleanPos}t[a]=o(s)},M.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?l.ensureNumber:M.getFromId(e,r).cleanPos)(t)};var C=M.getDataConversions=function(t,e,r,n){var a,i="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(i)){if(a={type:A(n),_categories:[]},M.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},M.saveRangeInitial=function(t,e){for(var r=M.list(t,"",!0),n=!1,a=0;a.3*d||u(n)||u(i))){var p=r.dtick/2;t+=t+p.8){var o=Number(r.substr(1));i.exactYears>.8&&o%12==0?t=M.tickIncrement(t,"M6","reverse")+1.5*y:i.exactMonths>.8?t=M.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var s=M.tickIncrement(t,r);if(s<=n)return s}return t}(x,t,m,c,i)),v=x,0;v<=u;)v=M.tickIncrement(v,m,!1,i),0;return{start:e.c2r(x,0,i),end:e.c2r(v,0,i),size:m,_dataSpan:u-c}},M.prepTicks=function(t){var e=l.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=l.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),M.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},M.calcTicks=function(t){M.prepTicks(t);var e=l.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e,r,n=t.tickvals,a=t.ticktext,i=new Array(n.length),o=l.simpleMap(t.range,t.r2l),s=1.0001*o[0]-1e-4*o[1],c=1.0001*o[1]-1e-4*o[0],u=Math.min(s,c),f=Math.max(s,c),d=0;Array.isArray(a)||(a=[]);var p="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(r=0;ru&&e=n:c<=n)&&!(i.length>s||c===o);c=M.tickIncrement(c,t.dtick,a,t.calendar))o=c,i.push(c);J(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(i.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&i<=10||e>=15*y)t._tickround="d";else if(e>=x&&i<=16||e>=m)t._tickround="M";else if(e>=b&&i<=19||e>=x)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var l=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var s=Math.max(Math.abs(l[0]),Math.abs(l[1])),c=Math.floor(Math.log(s)/Math.LN10+.01);Math.abs(c)>3&&(V(t.exponentformat)&&!U(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function H(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}M.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=l.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,r=n(10),t.dtick="M"+12*B(e,r,P)):i>v?(e/=v,t.dtick="M"+B(e,1,D)):i>y?(t.dtick=B(e,y,I),t.tick0=l.dateTick0(t.calendar,!0)):i>m?t.dtick=B(e,m,D):i>x?t.dtick=B(e,x,E):i>b?t.dtick=B(e,b,E):(r=n(10),t.dtick=B(e,r,P))}else if("log"===t.type){t.tick0=0;var o=l.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var s=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/s,r=n(10),t.dtick="L"+B(e,r,P)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):J(t)?(t.tick0=0,r=1,t.dtick=B(e,r,F)):(t.tick0=0,r=n(10),t.dtick=B(e,r,P));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},M.tickIncrement=function(t,e,r,i){var o=r?-1:1;if(a(e))return t+o*e;var s=e.charAt(0),c=o*Number(e.substr(1));if("M"===s)return l.incrementMonth(t,c,i);if("L"===s)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===s){var u="D2"===e?R:N,f=t+.01*o,d=l.roundUp(l.mod(f,1),u,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(e)},M.tickFirst=function(t){var e=t.r2l||Number,r=l.simpleMap(t.range,e),i=r[1]"+s,t._prevDateHead=s));e.text=c}(t,o,r,c):"log"===t.type?function(t,e,r,n,i){var o=t.dtick,s=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===i&&(i="");n&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,s),t,i,n);else if(a(o)||"D"===u&&l.mod(s+.01,1)<.1){var f=Math.round(s),d=Math.abs(f),p=t.exponentformat;"power"===p||V(p)&&U(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+d+"",e.fontSize*=1.25):("e"===p||"E"===p)&&d>2?e.text="1"+p+(f>0?"+":_)+d:(e.text=G(Math.pow(10,s),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,l.mod(s,1)))),e.fontSize*=.75}if("D1"===t.dtick){var h=String(e.text).charAt(0);"0"!==h&&"1"!==h||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(s<0?.5:.25)))}}(t,o,0,c,n):"category"===t.type?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,o):J(t)?function(t,e,r,n,a){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,a,n);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,a=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/a),Math.round(r/a)]}(i);if(o[1]>=100)e.text=G(l.deg2rad(e.x),t,a,n);else{var s=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),s&&(e.text=_+e.text)}}}}(t,o,r,c,n):function(t,e,r,n,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,n)}(t,o,0,c,n),t.tickprefix&&!p(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!p(t.showticksuffix)&&(o.text+=t.ticksuffix),o},M.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return M.hoverLabelText(t,e)+" - "+M.hoverLabelText(t,r);var n="log"===t.type&&e<=0,a=M.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+a:a};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function V(t){return"SI"===t||"B"===t}function U(t){return t>14||t<-15}function G(t,e,r,n){var i=t<0,o=e._tickround,s=r||e.exponentformat||"B",c=e._tickexponent,u=M.getTickFormat(e),f=e.separatethousands;if(n){var d={exponentformat:s,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(d),o=(Number(d._tickround)||0)+4,c=d._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,h=Math.pow(10,-o)/2;if("none"===s&&(c=0),(t=Math.abs(t))"+p+"":"B"===s&&9===c?t+="B":V(s)&&(t+=q[c/3+5]));return i?_+t:t}function Z(t,e){var r=t.l2p(e);return r>1&&r=0,i=u(t,e[1])<=0;return(r||a)&&(n||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},l=0;l2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":259,"./constants":220}],218:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var l,s=r("categoryorder",a);"array"===s&&(l=r("categoryarray")),o||"array"!==s||(s=e.categoryorder="trace"),"trace"===s?e._initialCategories=[]:"array"===s?e._initialCategories=l.slice():(l=function(t,e){var r,n,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;nl*x)||k)for(r=0;rD&&Nz&&(z=N);p/=(z-O)/(2*P),O=u.l2r(O),z=u.l2r(z),u.range=u._input.range=L=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function E(t,e,r,n,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",a+"Z")}function I(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function N(t,e,r,n,a,i){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),R(t,e,a,i)}function R(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function B(t){L&&t.data&&t._context.showTips&&(l.notifier(l._(t,"Double-click to zoom back out"),"long"),L=!1)}function j(t){return"lasso"===t||"select"===t}function H(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,A)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(i){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function V(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,i,c,d,L,S){var R,U,G,Z,X,Y,W,J,Q,$,K,tt,et,rt,nt,at,it,ot,lt,st,ct,ut=t._fullLayout._zoomlayer,ft=L+S==="nsew",dt=1===(L+S).length;function pt(){if(R=e.xaxis,U=e.yaxis,Q=R._length,$=U._length,W=R._offset,J=U._offset,(G={})[R._id]=R,(Z={})[U._id]=U,L&&S)for(var r=e.overlays,n=0;n-1&&w(a,t,X,Y,e.id,At),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===r&&dt){var l=L?U:R,c="s"===L||"w"===S?0:1,u=l._name+".range["+c+"]",d=function(t,e){var r,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,a))):(r=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,n.format("."+String(r)+"g")(a))}(l,c),p="left",h="middle";if(l.fixedrange)return;L?(h="n"===L?"top":"bottom","right"===l.side&&(p="right")):"e"===S&&(p="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(s.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(d),fill:l.tickfont?l.tickfont.color:"#444",horizontalAlign:p,verticalAlign:h}).on("edit",function(e){var r=l.d2r(e);void 0!==r&&o.call("relayout",t,u,r)})}}function Ct(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min(Q,e+vt)),a=Math.max(0,Math.min($,r+yt)),i=Math.abs(n-vt),o=Math.abs(a-yt);function l(){wt="",mt.r=mt.l,mt.t=mt.b,Tt.attr("d","M0,0Z")}mt.l=Math.min(vt,n),mt.r=Math.max(vt,n),mt.t=Math.min(yt,a),mt.b=Math.max(yt,a),nt?i>A||o>A?(wt="xy",i/Q>o/$?(o=i*$/Q,yt>a?mt.t=yt-o:mt.b=yt+o):(i=o*Q/$,vt>n?mt.l=vt-i:mt.r=vt+i),Tt.attr("d",H(mt))):l():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Et);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var a,i=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=Nt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(at){for(S||(s=.5),a=0;ag[1]-.01&&(e.domain=l),a.noneOrAll(t.domain,e.domain,l)}return r("layer"),e}},{"../../lib":170,"fast-isnumeric":18}],231:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*r;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":149}],232:[function(t,e,r){"use strict";var n=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),l=t("../../lib/polygon"),s=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),d=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),h=p.MINSELECT,g=l.filter,v=l.tester;function y(t){return t._id}function m(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h,g,v=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,m=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var x=function(t,e){var r,n,a=t[0],i=-1,o=[];for(n=0;n0?function(t,e){var r,n,a,i=[];for(a=0;a0&&i.push(r);if(1===i.length&&i[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=r.selectedpoints.length)>1)return!1}return 1===a}(l)&&(d=A(x))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",n)}function A(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,a=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function L(t,e,r){var n,i,o,l;if(r){var s=r.points||[];for(n=0;n-1&&m(e,A,a.xaxes,a.yaxes,a.subplot,a,U),"event"===r&&A.emit("plotly_selected",void 0);o.click(A,e)})},a.doneFn=function(){Z.remove(),s.done(X).then(function(){s.clear(X),a.gd.emit("plotly_selected",b),d&&a.selectionDefs&&(d.subtract=V,a.selectionDefs.push(d),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:C,selectOnClick:m}},{"../../components/color":51,"../../components/fx":93,"../../components/fx/helpers":90,"../../lib/clear_gl_canvases":159,"../../lib/polygon":182,"../../lib/throttle":192,"../../plot_api/subroutines":205,"../../registry":259,"./axis_ids":217,"./constants":220,polybooljs:25}],233:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,l=i.ms2DateTime,s=i.dateTime2ms,c=i.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,d=u.BADNUM,p=u.LOG_CLIP,h=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function u(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],a=t.range[1];return.5*(n+a-2*p*Math.abs(n-a))}return d}function y(e,r,n){var o=s(e,n||t.calendar);if(o===d){if(!a(e))return d;e=+e;var l=Math.floor(10*i.mod(e+.05,1)),c=Math.round(e-l/10);o=s(new Date(c))+l/10}return o}function m(e,r,n){return l(e,r,n||t.calendar)}function x(e){return t._categories[Math.round(e)]}function b(e){if(t._categoriesMap){var r=t._categoriesMap[e];if(void 0!==r)return r}if(a(e))return+e}function _(e){return a(e)?n.round(t._b+t._m*e,2):d}function w(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=_,t.p2l=w,t.c2p="log"===t.type?function(t,e){return _(u(t,e))}:_,t.p2c="log"===t.type?function(t){return v(w(t))}:w,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=w,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(w(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=w,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=y,t.c2d=t.c2r=t.l2d=t.l2r=m,t.d2p=t.r2p=function(e,r,n){return t.l2p(y(e,0,n))},t.p2d=t.p2r=function(t,e,r){return m(w(t),e,r)},t.cleanPos=function(e){return i.cleanDate(e,d,t.calendar)}):"category"===t.type&&(t.d2c=t.d2l=function(e){if(null!=e){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return d},t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=b,t.r2c=function(e){var r=b(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=b,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(w(t))},t.r2p=t.d2p,t.p2r=w,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,l,s=i.nestedProperty(t,e).get();if(l=(l="date"===t.type?i.dfltRange(t.calendar):"y"===r?h.DFLTRANGEY:n.dfltRange||h.DFLTRANGEX).slice(),s&&2===s.length)for("date"===t.type&&(s[0]=i.cleanDate(s[0],d,t.calendar),s[1]=i.cleanDate(s[1],d,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(s[o],t.calendar)){t[e]=l;break}if(t.r2l(s[0])===t.r2l(s[1])){var c=i.constrain(t.r2l(s[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);s[0]=t.l2r(c-1e3),s[1]=t.l2r(c+1e3);break}}else{if(!a(s[o])){if(!a(s[1-o])){t[e]=l;break}s[o]=s[1-o]*(o?10:.1)}if(s[o]<-f?s[o]=-f:s[o]>f&&(s[o]=f),s[0]===s[1]){var u=Math.max(1,Math.abs(1e-6*s[0]));s[0]-=u,s[1]+=u}}else i.nestedProperty(t,e).set(l)},t.setScale=function(n){var a=e._size;if(t._categories||(t._categories=[]),t._categoriesMap||(t._categoriesMap={}),t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=n&&t._r?"_r":"range",l=t.calendar;t.cleanRange(o);var s=t.r2l(t[o][0],l),c=t.r2l(t[o][1],l);if("y"===r?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-c),t._b=-t._m*c):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,a,o,l,s=t.type,c="date"===s&&e[r+"calendar"];if(r in e){if(n=e[r],l=e._length||n.length,i.isTypedArray(n)&&("linear"===s||"log"===s)){if(l===n.length)return n;if(n.subarray)return n.subarray(0,l)}for(a=new Array(l),o=0;o rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,r._offset).call(i.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(i.setPointGroupScale,1,1),n.selectAll(".textpoint").call(i.setTextPointsScale,1,1),n.call(i.hideOutsideRangePoints,t)}function x(e,r){var n,l,s,u=g[e.xaxis._id],f=g[e.yaxis._id],d=[];if(u){l=(n=t._fullLayout[u.axisName])._r,s=u.to,d[0]=(l[0]*(1-r)+r*s[0]-l[0])/(l[1]-l[0])*e.xaxis._length;var p=l[1]-l[0],h=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[2]=e.xaxis._length*(1-r+r*h/p)}else d[0]=0,d[2]=e.xaxis._length;if(f){l=(n=t._fullLayout[f.axisName])._r,s=f.to,d[1]=(l[1]*(1-r)+r*s[1]-l[1])/(l[0]-l[1])*e.yaxis._length;var v=l[1]-l[0],y=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[3]=e.yaxis._length*(1-r+r*y/v)}else d[1]=0,d[3]=e.yaxis._length;!function(e,r){var n,i=[];for(i=[e._id,r._id],n=0;nr.duration?(function(){for(var e={},r=0;r0&&(a["_"+r+"axes"]||{})[e])return a;if((a[r+"axis"]||r)===e){if(o(a,r))return a;if((a[r]||[]).length||a[r+"0"])return a}}}(e,r,l);if(!s)return;if("histogram"===s.type&&l==={v:"y",h:"x"}[s.orientation||"v"])return void(t.type="linear");var c,u=l+"calendar",f=s[u];if(o(s,l)){var d=i(s),p=[];for(c=0;c0?".":"")+i;a.isPlainObject(o)?s(o,e,l,n+1):e(l,i,o)}})}r.manageCommandObserver=function(t,e,n,o){var l={},s=!0;e&&e._commandObserver&&(l=e._commandObserver),l.cache||(l.cache={}),l.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,n,l.lookupTable);if(e&&e._commandObserver){if(c)return l;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,l}if(c){i(t,c,l.cache),l.check=function(){if(s){var e=i(t,c,l.cache);return e.changed&&o&&void 0!==l.lookupTable[e.value]&&(l.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:l.lookupTable[e.value]})).then(l.enable,l.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;f=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),r.attr(i);var o=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),a=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+a})}}(t,o),l.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),a=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,a={};function o(t){for(var r=!0,i=0;i1&&D.length>1){for(i.getComponentMethod("grid","sizeDefaults")(c,l),o=0;o15&&D.length>15&&0===l.shapes.length&&0===l.images.length,l._hasCartesian=l._has("cartesian"),l._hasGeo=l._has("geo"),l._hasGL3D=l._has("gl3d"),l._hasGL2D=l._has("gl2d"),l._hasTernary=l._has("ternary"),l._hasPie=l._has("pie"),v.linkSubplots(d,l,u,a),v.cleanPlot(d,l,u,a),h(l,a),v.doAutoMargin(t);var F=f.list(t);for(o=0;o0){var f=1-2*l;n=Math.round(f*n),i=Math.round(f*i)}}var d=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-i)>1;(g||h)&&(h&&(r.width=n),g&&(r.height=i)),t._initialAutoSize||(t._initialAutoSize={width:n,height:i}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var a,o,l,c=i.componentsRegistry,u=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in c)(l=c[a]).includeBasePlot&&l.includeBasePlot(t,e);for(var d in u.length||u.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[d].sort(s.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var s=void 0!==r.xl?r.xl:r.x,c=void 0!==r.xr?r.xr:r.x,u=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;a[e]={l:{val:s,size:r.l+o},r:{val:c,size:r.r+o},b:{val:f,size:r.b+o},t:{val:u,size:r.t+o}},i[e]=1}else delete a[e],delete i[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),M(e);var r=e._size,n=JSON.stringify(r),o=Math.max(e.margin.l||0,0),l=Math.max(e.margin.r||0,0),s=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin,f=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var d in u)f[d]||delete u[d];for(var p in u.base={l:{val:0,size:o},r:{val:1,size:l},t:{val:1,size:s},b:{val:0,size:c}},u){var h=u[p].l||{},g=u[p].b||{},v=h.val,y=h.size,m=g.val,x=g.size;for(var b in u){if(a(y)&&u[b].r){var _=u[b].r.val,w=u[b].r.size;if(_>v){var k=(y*_+(w-e.width)*v)/(_-v),T=(w*(1-v)+(y-e.width)*(1-_))/(_-v);k>=0&&T>=0&&k+T>o+l&&(o=k,l=T)}}if(a(x)&&u[b].t){var A=u[b].t.val,L=u[b].t.size;if(A>m){var S=(x*A+(L-e.height)*m)/(A-m),C=(L*(1-m)+(x-e.height)*(1-A))/(A-m);S>=0&&C>=0&&S+C>c+s&&(c=S,s=C)}}}}}if(r.l=Math.round(o),r.r=Math.round(l),r.t=Math.round(s),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,r,n,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,l=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(s.isPlainObject(t)){var e,n,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!s.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;a[e]=c(t[e])}return a}return Array.isArray(t)?t.map(c):s.isTypedArray(t)?s.simpleMap(t,s.identity):s.isJSDate(t)?s.ms2DateTimeLocal(+t):t}var u={data:(i||[]).map(function(t){var r=c(t);return e&&delete r.fit,r})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),l&&(u.frames=c(l)),"object"===n?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var r,n,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,l,c=0,u=0;function f(){return c++,function(){var r;u++,p||u!==c||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var h=t._fullLayout._basePlotModules,g=!1;if(r)for(l=0;l=0;l--)if(o[l].enabled){r._indexToPoints=o[l]._indexToPoints;break}n&&n.calc&&(i=n.calc(t,r))}Array.isArray(i)&&i[0]||(i=[{x:u,y:u}]),i[0].t||(i[0].t={}),i[0].trace=r,h[e]=i}}for(m&&A(c),a=0;a=0?d.angularAxis.domain:n.extent(k),S=Math.abs(k[1]-k[0]);M&&!T&&(S=0);var C=L.slice();A&&T&&(C[1]+=S);var O=d.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),d.angularAxis.ticksStep&&(O=(C[1]-C[0])/O);var z=d.angularAxis.ticksStep||(C[1]-C[0])/(O*(d.minorTicks+1));w&&(z=Math.max(Math.round(z),1)),C[2]||(C[2]=z);var P=n.range.apply(this,C);if(P=P.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=n.scale.linear().domain(C.slice(0,2)).range("clockwise"===d.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=A?S:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var D=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),E=this.appendChild(this.ownerDocument.importNode(D.documentElement,!0));t=n.select(E)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var I,N=t.select(".chart-group"),R={fill:"none",stroke:d.tickColor},F={"font-size":d.font.size,"font-family":d.font.family,fill:d.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+d.font.outlineColor}).join(",")};if(d.showLegend){I=t.select(".legend-group").attr({transform:"translate("+[x,d.margin.top]+")"}).style({display:"block"});var B=p.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:I,elements:B,reverseOrder:d.legend.reverseOrder})})();var j=I.node().getBBox();x=Math.min(d.width-j.width-d.margin.left-d.margin.right,d.height-d.margin.top-d.margin.bottom)/2,x=Math.max(10,x),_=[d.margin.left+x,d.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),I.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else I=t.select(".legend-group").style({display:"none"});t.attr({width:d.width,height:d.height}).style({opacity:d.opacity}),N.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(d.width-(d.margin.left+d.margin.right+2*x+(j?j.width:0)))/2,(d.height-(d.margin.top+d.margin.bottom+2*x))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),t.select(".outer-group").attr("transform","translate("+H+")"),d.title){var q=t.select("g.title-group text").style(F).text(d.title),V=q.node().getBBox();q.attr({x:_[0]-V.width/2,y:_[1]-x-20})}var U=t.select(".radial.axis-group");if(d.radialAxis.gridLinesVisible){var G=U.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(R),G.attr("r",r),G.exit().remove()}U.select("circle.outside-circle").attr({r:x}).style(R);var Z=t.select("circle.background-circle").attr({r:x}).style({fill:d.backgroundColor,stroke:d.stroke});function X(t,e){return l(t)%360+d.orientation}if(d.radialAxis.visible){var Y=n.svg.axis().scale(r).ticks(5).tickSize(5);U.call(Y).attr({transform:"rotate("+d.radialAxis.orientation+")"}),U.selectAll(".domain").style(R),U.selectAll("g>text").text(function(t,e){return this.textContent+d.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===d.radialAxis.tickOrientation?"rotate("+-d.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),U.selectAll("g>line").style({stroke:"black"})}var W=t.select(".angular.axis-group").selectAll("g.angular-tick").data(P),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+X(t)+")"}}).style({display:d.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(d.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(d.minorTicks+1)==0)}).style(R),J.selectAll(".minor").style({stroke:d.minorTickColor}),W.select("line.grid-line").attr({x1:d.tickLength?x-d.tickLength:0,x2:x}).style({display:d.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(F);var Q=W.select("text.axis-text").attr({x:x+d.labelOffset,dy:i+"em",transform:function(t,e){var r=X(t),n=x+d.labelOffset,a=d.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-r+" "+n+" 0)":"radial"==a?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:d.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(d.minorTicks+1)!=0?"":w?w[t]+d.angularAxis.ticksSuffix:t+d.angularAxis.ticksSuffix}).style(F);d.angularAxis.rewriteTicks&&Q.text(function(t,e){return e%(d.minorTicks+1)!=0?"":d.angularAxis.rewriteTicks(this.textContent,e)});var $=n.max(N.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));I.attr({transform:"translate("+[x+$,d.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||K){var et=[];p.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=d.orientation,n.direction=d.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return a(o[r].defaultConfig(),t)});o[r]().config(n)()})}var at,it,ot=t.select(".guides-group"),lt=t.select(".tooltips-group"),st=o.tooltipPanel().config({container:lt,fontSize:8})(),ct=o.tooltipPanel().config({container:lt,fontSize:8})(),ut=o.tooltipPanel().config({container:lt,hasTick:!0})();if(!T){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});N.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(Z).angle;ft.attr({x2:-x,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-d.orientation)%360;at=l.invert(n);var a=o.util.convertToCartesian(x+12,r+180);st.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var dt=ot.select("circle").style({stroke:"grey",fill:"none"});N.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(Z).radius;dt.attr({r:n}).style({opacity:.5}),it=r.invert(o.util.getMousePos(Z).radius);var a=o.util.convertToCartesian(n,d.radialAxis.orientation);ct.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){dt.style({opacity:0}),ut.hide(),st.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var a=n.select(this),i=this.style.fill,l="black",s=this.style.opacity||1;if(a.attr({"data-opacity":s}),i&&"none"!==i){a.attr({"data-fill":i}),l=n.hsl(i).darker().toString(),a.style({fill:l,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};T&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=t.node().getBoundingClientRect(),p=[f.left+f.width/2-H[0]-d.left,f.top+f.height/2-H[1]-d.top];ut.config({color:l}).text(u),ut.move(p)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),l=n.hsl(i).darker().toString(),a.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var r=n.select(this),a=r.attr("data-fill");a?r.style({fill:a,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(c),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),a(s.data[e],o.Axis.defaultConfig().data[0]),a(s.data[e],t)}),a(s.layout,o.Axis.defaultConfig().layout),a(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return t},n.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var a=e||6,i=[],o=[];n.range(0,360+a,a).forEach(function(e,r){var n=e*Math.PI/180,a=t(n);i.push(e),o.push(a)});var l={t:i,r:o};return r&&(l.name=r),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],a=e[1],i={};return i.x=r,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,r)+Math.PI)/Math.PI,i.radius=Math.sqrt(r*r+a*a),i},o.util.duplicatesCount=function(t){for(var e,r={},n={},a=0,i=t.length;a0)){var s=n.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({class:"line",d:u(l),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return h.fill(r,a,i)},"fill-opacity":0,stroke:function(t,e){return h.stroke(r,a,i)},"stroke-width":function(t,e){return h["stroke-width"](r,a,i)},"stroke-dasharray":function(t,e){return h["stroke-dasharray"](r,a,i)},opacity:function(t,e){return h.opacity(r,a,i)},display:function(t,e){return h.display(r,a,i)}})}};var f=e.angularScale.range(),d=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=n.svg.arc().startAngle(function(t){return-d/2}).endAngle(function(t){return d/2}).innerRadius(function(t){return e.radialScale(s+(t[2]||0))}).outerRadius(function(t){return e.radialScale(s+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,r,a){n.select(this).attr({class:"mark arc",d:p,transform:function(t,r){return"rotate("+(e.orientation+l(t[0])+90)+")"}})};var h={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,a){return r[t[a].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(h).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),a(t[r],o.PolyChart.defaultConfig()),a(t[r],e)}),this):t},i.getColorScale=function(){},n.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,i=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var i=a({},e.elements[r]);return i.name=t,i.color=[].concat(e.elements[r].color)[n],i})}),o=n.merge(i);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var l=e.container;("string"==typeof l||l.nodeName)&&(l=n.select(l));var s=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,d=l.classed("legend-group",!0).selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var h=n.range(o.length),g=n.scale[u?"linear":"ordinal"]().domain(h).range(s),v=n.scale[u?"linear":"ordinal"]().domain(h)[u?"range":"rangePoints"]([0,f]);if(u){var y=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var m=d.select(".legend-marks").selectAll("path.legend-mark").data(o);m.enter().append("path").classed("legend-mark",!0),m.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var r,a,i,o=t.symbol;return i=3*(a=c),"line"===(r=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(i)():n.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),m.exit().remove()}var x=n.svg.axis().scale(v).orient("right"),b=d.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(a(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){var n=(t=i.container.selectAll("g."+l).data([0])).enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:i.padding+s,dy:.3*+i.fontSize}),c};return c.text=function(a){var o=n.hsl(i.color).l,l=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":i.fontSize+"px"}).text(f);var d=i.padding,p=e.node().getBBox(),h={fill:i.color,stroke:l,"stroke-width":"2px"},g=p.width+2*d+s,v=p.height+2*d;return r.attr({d:"M"+[[s,-v/2],[s,-v/4],[i.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(h),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return a(i,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=a({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=i.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var l=a({},t.layout);if([[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var s=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(l.margin).forEach(function(t,e){u[c[s.indexOf(t.key)]]=t.value}),l.margin=u}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),r.layout=l}return r}};return t}},{"../../../constants/alignment":149,"../../../lib":170,d3:16}],252:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),l=t("./undo_manager"),s=a.extendDeepAll,c=e.exports={};c.framework=function(t){var e,r,a,i,u,f=new l;function d(r,l){return l&&(u=l),n.select(n.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?s(e,r):r,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return d.isPolar=!0,d.svg=function(){return a.svg()},d.getConfig=function(){return e},d.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},d.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},d.setUndoPoint=function(){var t,n,a=this,i=o.util.cloneJson(e);t=i,n=r,f.add({undo:function(){n&&a(n)},redo:function(){a(t)}}),r=o.util.cloneJson(i)},d.undo=function(){f.undo()},d.redo=function(){f.redo()},d},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../../components/color":51,"../../../lib":170,"./micropolar":251,"./undo_manager":253,d3:16}],253:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function a(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(a(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(a(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r=u&&(p.min=0,g.min=0,v.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}function h(t,e,r){var n=f[e._name];function a(r,a){return i.coerce(t,e,n,r,a)}e.type="linear";var o=a("color"),d=o!==n.color.dflt?o:r.font.color,p=e._name.charAt(0).toUpperCase(),h="Component "+p,g=a("title",h);e._hovertitle=g===h?g:p,i.coerceFont(a,"titlefont",{family:r.font.family,size:Math.round(1.2*r.font.size),color:d}),a("min"),c(t,e,a,"linear"),l(t,e,a,"linear",{}),s(t,e,a,{outerTicks:!0}),a("showticklabels")&&(i.coerceFont(a,"tickfont",{family:r.font.family,size:r.font.size,color:d}),a("tickangle"),a("tickformat")),u(t,e,a,{dfltColor:o,bgColor:r.bgColor,blend:60,showLine:!0,showGrid:!0,noZeroLine:!0,attributes:n}),a("hoverformat"),a("layer")}e.exports=function(t,e,r){o(t,e,r,{type:"ternary",attributes:f,handleDefaults:p,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../components/color":51,"../../lib":170,"../../plot_api/plot_template":204,"../cartesian/line_grid_defaults":229,"../cartesian/tick_label_defaults":234,"../cartesian/tick_mark_defaults":235,"../cartesian/tick_value_defaults":236,"../subplot_defaults":254,"./layout_attributes":256}],258:[function(t,e,r){"use strict";var n=t("d3"),a=t("tinycolor2"),i=t("../../registry"),o=t("../../lib"),l=o._,s=t("../../components/color"),c=t("../../components/drawing"),u=t("../cartesian/set_convert"),f=t("../../lib/extend").extendFlat,d=t("../plots"),p=t("../cartesian/axes"),h=t("../../components/dragelement"),g=t("../../components/fx"),v=t("../../components/titles"),y=t("../cartesian/select").prepSelect,m=t("../cartesian/select").selectOnClick,x=t("../cartesian/select").clearSelect,b=t("../cartesian/constants");function _(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework(e),this.aTickLayout=null,this.bTickLayout=null,this.cTickLayout=null}e.exports=_;var w=_.prototype;w.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={},this.layers={}},w.plot=function(t,e){var r=e[this.id],n=e._size;this._hasClipOnAxisFalse=!1;for(var a=0;ak*x?a=(i=x)*k:i=(a=m)/k,o=v*a/m,l=y*i/x,r=e.l+e.w*h-a/2,n=e.t+e.h*(1-g)-i/2,d.x0=r,d.y0=n,d.w=a,d.h=i,d.sum=b,d.xaxis={type:"linear",range:[_+2*T-b,b-_-2*w],domain:[h-o/2,h+o/2],_id:"x"},u(d.xaxis,d.graphDiv._fullLayout),d.xaxis.setScale(),d.xaxis.isPtWithinRange=function(t){return t.a>=d.aaxis.range[0]&&t.a<=d.aaxis.range[1]&&t.b>=d.baxis.range[1]&&t.b<=d.baxis.range[0]&&t.c>=d.caxis.range[1]&&t.c<=d.caxis.range[0]},d.yaxis={type:"linear",range:[_,b-w-T],domain:[g-l/2,g+l/2],_id:"y"},u(d.yaxis,d.graphDiv._fullLayout),d.yaxis.setScale(),d.yaxis.isPtWithinRange=function(){return!0};var M=d.yaxis.domain[0],A=d.aaxis=f({},t.aaxis,{visible:!0,range:[_,b-w-T],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[M,M+l*k],_axislayer:d.layers.aaxis,_gridlayer:d.layers.agrid,anchor:"free",position:0,_pos:0,_id:"y",_length:a,_gridpath:"M0,0l"+i+",-"+a/2,automargin:!1});u(A,d.graphDiv._fullLayout),A.setScale();var L=d.baxis=f({},t.baxis,{visible:!0,range:[b-_-T,w],side:"bottom",_counterangle:30,domain:d.xaxis.domain,_axislayer:d.layers.baxis,_gridlayer:d.layers.bgrid,_counteraxis:d.aaxis,anchor:"free",position:0,_pos:0,_id:"x",_length:a,_gridpath:"M0,0l-"+a/2+",-"+i,automargin:!1});u(L,d.graphDiv._fullLayout),L.setScale(),A._counteraxis=L;var S=d.caxis=f({},t.caxis,{visible:!0,range:[b-_-w,T],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[M,M+l*k],_axislayer:d.layers.caxis,_gridlayer:d.layers.cgrid,_counteraxis:d.baxis,anchor:"free",position:0,_pos:0,_id:"y",_length:a,_gridpath:"M0,0l-"+i+","+a/2,automargin:!1});u(S,d.graphDiv._fullLayout),S.setScale();var C="M"+r+","+(n+i)+"h"+a+"l-"+a/2+",-"+i+"Z";d.clipDef.select("path").attr("d",C),d.layers.plotbg.select("path").attr("d",C);var O="M0,"+i+"h"+a+"l-"+a/2+",-"+i+"Z";d.clipDefRelative.select("path").attr("d",O);var z="translate("+r+","+n+")";d.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",z),d.clipDefRelative.select("path").attr("transform",null);var P="translate("+(r-L._offset)+","+(n+i)+")";d.layers.baxis.attr("transform",P),d.layers.bgrid.attr("transform",P);var D="translate("+(r+a/2)+","+n+")rotate(30)translate(0,"+-A._offset+")";d.layers.aaxis.attr("transform",D),d.layers.agrid.attr("transform",D);var E="translate("+(r+a/2)+","+n+")rotate(-30)translate(0,"+-S._offset+")";d.layers.caxis.attr("transform",E),d.layers.cgrid.attr("transform",E),d.drawAxes(!0),d.plotContainer.selectAll(".crisp").classed("crisp",!1),d.layers.aline.select("path").attr("d",A.showline?"M"+r+","+(n+i)+"l"+a/2+",-"+i:"M0,0").call(s.stroke,A.linecolor||"#000").style("stroke-width",(A.linewidth||0)+"px"),d.layers.bline.select("path").attr("d",L.showline?"M"+r+","+(n+i)+"h"+a:"M0,0").call(s.stroke,L.linecolor||"#000").style("stroke-width",(L.linewidth||0)+"px"),d.layers.cline.select("path").attr("d",S.showline?"M"+(r+a/2)+","+n+"l"+a/2+","+i:"M0,0").call(s.stroke,S.linecolor||"#000").style("stroke-width",(S.linewidth||0)+"px"),d.graphDiv._context.staticPlot||d.initInteractions(),c.setClipUrl(d.layers.frontplot,d._hasClipOnAxisFalse?null:d.clipId)},w.drawAxes=function(t){var e,r=this.graphDiv,n=this.id.substr(7)+"title",a=this.layers,i=this.aaxis,o=this.baxis,s=this.caxis;if(e=T(i),this.aTickLayout!==e&&(a.aaxis.selectAll(".ytick").remove(),this.aTickLayout=e),e=T(o),this.bTickLayout!==e&&(a.baxis.selectAll(".xtick").remove(),this.bTickLayout=e),e=T(s),this.cTickLayout!==e&&(a.caxis.selectAll(".ytick").remove(),this.cTickLayout=e),p.doTicksSingle(r,i,!0),p.doTicksSingle(r,o,!0),p.doTicksSingle(r,s,!0),t){var c=Math.max(i.showticklabels?i.tickfont.size/2:0,(s.showticklabels?.75*s.tickfont.size:0)+("outside"===s.ticks?.87*s.ticklen:0));this.layers["a-title"]=v.draw(r,"a"+n,{propContainer:i,propName:this.id+".aaxis.title",placeholder:l(r,"Click to enter Component A title"),attributes:{x:this.x0+this.w/2,y:this.y0-i.titlefont.size/3-c,"text-anchor":"middle"}});var u=(o.showticklabels?o.tickfont.size:0)+("outside"===o.ticks?o.ticklen:0)+3;this.layers["b-title"]=v.draw(r,"b"+n,{propContainer:o,propName:this.id+".baxis.title",placeholder:l(r,"Click to enter Component B title"),attributes:{x:this.x0-u,y:this.y0+this.h+.83*o.titlefont.size+u,"text-anchor":"middle"}}),this.layers["c-title"]=v.draw(r,"c"+n,{propContainer:s,propName:this.id+".caxis.title",placeholder:l(r,"Click to enter Component C title"),attributes:{x:this.x0+this.w+u,y:this.y0+this.h+.83*s.titlefont.size+u,"text-anchor":"middle"}})}};var M=b.MINZOOM/2+.87,A="m-0.87,.5h"+M+"v3h-"+(M+5.2)+"l"+(M/2+2.6)+",-"+(.87*M+4.5)+"l2.6,1.5l-"+M/2+","+.87*M+"Z",L="m0.87,.5h-"+M+"v3h"+(M+5.2)+"l-"+(M/2+2.6)+",-"+(.87*M+4.5)+"l-2.6,1.5l"+M/2+","+.87*M+"Z",S="m0,1l"+M/2+","+.87*M+"l2.6,-1.5l-"+(M/2+2.6)+",-"+(.87*M+4.5)+"l-"+(M/2+2.6)+","+(.87*M+4.5)+"l2.6,1.5l"+M/2+",-"+.87*M+"Z",C="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",O=!0;function z(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}w.initInteractions=function(){var t,e,r,n,u,f,d,p,v,_,w=this,T=w.layers.plotbg.select("path").node(),M=w.graphDiv,P=M._fullLayout._zoomlayer,D={element:T,gd:M,plotinfo:{id:w.id,xaxis:w.xaxis,yaxis:w.yaxis},subplot:w.id,prepFn:function(i,o,l){D.xaxes=[w.xaxis],D.yaxes=[w.yaxis];var c=M._fullLayout.dragmode;D.minDrag="lasso"===c?1:void 0,"zoom"===c?(D.moveFn=F,D.clickFn=E,D.doneFn=B,function(i,o,l){var c=T.getBoundingClientRect();t=o-c.left,e=l-c.top,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,n=w.aaxis.range[1]-r.a,f=a(w.graphDiv._fullLayout[w.id].bgcolor).getLuminance(),d="M0,"+w.h+"L"+w.w/2+", 0L"+w.w+","+w.h+"Z",p=!1,v=P.append("path").attr("class","zoombox").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:f>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",d),_=P.append("path").attr("class","zoombox-corners").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:s.background,stroke:s.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),x(P)}(0,o,l)):"pan"===c?(D.moveFn=j,D.clickFn=E,D.doneFn=H,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,x(P)):"select"!==c&&"lasso"!==c||y(i,o,l,D,c)}};function E(t,e){var r=M._fullLayout.clickmode;if(z(M),2===t){var n={};n[w.id+".aaxis.min"]=0,n[w.id+".baxis.min"]=0,n[w.id+".caxis.min"]=0,M.emit("plotly_doubleclick",null),i.call("relayout",M,n)}r.indexOf("select")>-1&&1===t&&m(e,M,[w.xaxis],[w.yaxis],w.id,D),r.indexOf("event")>-1&&g.click(M,e,w.id)}function I(t,e){return 1-e/w.h}function N(t,e){return 1-(t+(w.h-e)/Math.sqrt(3))/w.w}function R(t,e){return(t-(w.h-e)/Math.sqrt(3))/w.w}function F(a,i){var o=t+a,l=e+i,s=Math.max(0,Math.min(1,I(0,e),I(0,l))),c=Math.max(0,Math.min(1,N(t,e),N(o,l))),h=Math.max(0,Math.min(1,R(t,e),R(o,l))),g=(s/2+h)*w.w,y=(1-s/2-c)*w.w,m=(g+y)/2,x=y-g,T=(1-s)*w.h,M=T-x/k;x.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),_.transition().style("opacity",1).duration(200),p=!0)}function B(){if(z(M),u!==r){var t={};t[w.id+".aaxis.min"]=u.a,t[w.id+".baxis.min"]=u.b,t[w.id+".caxis.min"]=u.c,i.call("relayout",M,t),O&&M.data&&M._context.showTips&&(o.notifier(l(M,"Double-click to zoom back out"),"long"),O=!1)}}function j(t,e){var n=t/w.xaxis._m,a=e/w.yaxis._m,i=[(u={a:r.a-a,b:r.b+(n+a)/2,c:r.c-(n-a)/2}).a,u.b,u.c].sort(),o=i.indexOf(u.a),l=i.indexOf(u.b),s=i.indexOf(u.c);i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),u={a:i[o],b:i[l],c:i[s]},e=(r.a-u.a)*w.yaxis._m,t=(r.c-u.c-r.b+u.b)*w.xaxis._m);var f="translate("+(w.x0+t)+","+(w.y0+e)+")";w.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",f);var d="translate("+-t+","+-e+")";w.clipDefRelative.select("path").attr("transform",d),w.aaxis.range=[u.a,w.sum-u.b-u.c],w.baxis.range=[w.sum-u.a-u.c,u.b],w.caxis.range=[w.sum-u.a-u.b,u.c],w.drawAxes(!1),w.plotContainer.selectAll(".crisp").classed("crisp",!1),w._hasClipOnAxisFalse&&w.plotContainer.select(".scatterlayer").selectAll(".trace").call(c.hideOutsideRangePoints,w)}function H(){var t={};t[w.id+".aaxis.min"]=u.a,t[w.id+".baxis.min"]=u.b,t[w.id+".caxis.min"]=u.c,i.call("relayout",M,t)}T.onmousemove=function(t){g.hover(M,t,w.id),M._fullLayout._lasthover=T,M._fullLayout._hoversubplot=w.id},T.onmouseout=function(t){M._dragging||h.unhover(M,t)},h.init(D)}},{"../../components/color":51,"../../components/dragelement":73,"../../components/drawing":76,"../../components/fx":93,"../../components/titles":142,"../../lib":170,"../../lib/extend":164,"../../registry":259,"../cartesian/axes":214,"../cartesian/constants":220,"../cartesian/select":232,"../cartesian/set_convert":233,"../plots":247,d3:16,tinycolor2:34}],259:[function(t,e,r){"use strict";var n=t("./lib/loggers"),a=t("./lib/noop"),i=t("./lib/push_unique"),o=t("./lib/is_plain_object"),l=t("./lib/extend"),s=t("./plots/attributes"),c=t("./plots/layout_attributes"),u=l.extendFlat,f=l.extendDeepAll;function d(t){var e=t.name,a=t.categories,i=t.meta;if(r.modules[e])n.log("Type "+e+" already registered");else{r.subplotsRegistry[t.basePlotModule.name]||function(t){var e=t.name;if(r.subplotsRegistry[e])return void n.log("Plot type "+e+" already registered.");for(var a in v(t),r.subplotsRegistry[e]=t,r.componentsRegistry)x(a,t.name)}(t.basePlotModule);for(var o={},l=0;l-1&&(u[d[r]].title="");for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(s,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(s,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||d.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),d.node().setAttributeNS(l.xmlns,"xmlns",l.svg),d.node().setAttributeNS(l.xmlns,"xmlns:xlink",l.xlink),"svg"===e&&r&&(d.attr("width",r*h),d.attr("height",r*g),d.attr("viewBox","0 0 "+h+" "+g));var _=(new window.XMLSerializer).serializeToString(d.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":51,"../components/drawing":76,"../constants/xmlns_namespaces":153,"../lib":170,d3:16}],268:[function(t,e,r){"use strict";var n=t("../../lib").mergeArray;e.exports=function(t,e){for(var r=0;rf+c||!n(u))&&(p=!0,g(d,t))}for(var v=0;vi))return e}return void 0!==r?r:t.dflt},r.coerceColor=function(t,e,r){return a(e).isValid()?e:void 0!==r?r:t.dflt},r.coerceEnumerated=function(t,e,r){return t.coerceNumber&&(e=+e),-1!==t.values.indexOf(e)?e:void 0!==r?r:t.dflt},r.getValue=function(t,e){var r;return Array.isArray(t)?e.01?C:function(t,e){return Math.abs(t-e)>=2?C(t):t>e?Math.ceil(t):Math.floor(t)};_=S(_,w),w=S(w,_),k=S(k,T),T=S(T,k)}i.ensureSingle(M,"path").style("vector-effect","non-scaling-stroke").attr("d","M"+_+","+k+"V"+T+"H"+w+"V"+k+"Z").call(s.setClipUrl,e.layerClipId),function(t,e,r,n,a,l,c,u){var y;function m(e,r,n){var a=i.ensureSingle(e,"text").text(r).attr({class:"bartext bartext-"+y,transform:"","text-anchor":"middle","data-notex":1}).call(s.font,n).call(o.convertToTspans,t);return a}var x=r[0].trace,b=x.orientation,_=function(t,e){var r=p.getValue(t.text,e);return p.coerceString(f,r)}(x,n);if(y=function(t,e){var r=p.getValue(t.textposition,e);return p.coerceEnumerated(d,r)}(x,n),!_||"none"===y)return void e.select("text").remove();var w,k,T,M,A,L,S=t._fullLayout.font,C=h.getBarColor(r[n],x),O=h.getInsideTextFont(x,n,S,C),z=h.getOutsideTextFont(x,n,S),P=t._fullLayout.barmode,D="relative"===P,E="stack"===P||D,I=r[n],N=!E||I._outmost,R=Math.abs(l-a)-2*g,F=Math.abs(u-c)-2*g;"outside"===y&&(N||I.hasB||(y="inside"));if("auto"===y)if(N){y="inside",w=m(e,_,O),k=s.bBox(w.node()),T=k.width,M=k.height;var B=T>0&&M>0,j=T<=R&&M<=F,H=T<=F&&M<=R,q="h"===b?R>=T*(F/M):F>=M*(R/T);B&&(j||H||q)?y="inside":(y="outside",w.remove(),w=null)}else y="inside";if(!w&&(w=m(e,_,"outside"===y?z:O),k=s.bBox(w.node()),T=k.width,M=k.height,T<=0||M<=0))return void w.remove();"outside"===y?(L="both"===x.constraintext||"outside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s="h"===i?Math.abs(n-r):Math.abs(e-t);s>2*g&&(l=g);var c=1;o&&(c="h"===i?Math.min(1,s/a.height):Math.min(1,s/a.width));var u,f,d,p,h=(a.left+a.right)/2,y=(a.top+a.bottom)/2;u=c*a.width,f=c*a.height,"h"===i?er?(d=(t+e)/2,p=n+l+f/2):(d=(t+e)/2,p=n-l-f/2);return v(h,y,d,p,c,!1)}(a,l,c,u,k,b,L)):(L="both"===x.constraintext||"inside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h=a.width,y=a.height,m=(a.left+a.right)/2,x=(a.top+a.bottom)/2,b=Math.abs(e-t),_=Math.abs(n-r);b>2*g&&_>2*g?(b-=2*(f=g),_-=2*f):f=0;h<=b&&y<=_?(d=!1,p=1):h<=_&&y<=b?(d=!0,p=1):hr?(c=(t+e)/2,u=n-f-s/2):(c=(t+e)/2,u=n+f+s/2);return v(m,x,c,u,p,d)}(a,l,c,u,k,b,L));w.attr("transform",A)}(t,M,r,u,_,w,k,T),e.layerClipId&&s.hideOutsideRangePoint(c,M.select("text"),y,m,b.xcalendar,b.ycalendar)}else M.remove();function C(t){return 0===x.bargap&&0===x.bargroupgap?n.round(Math.round(t)-L,2):t}});var w=!1===u.trace.cliponaxis;s.setClipUrl(c,w?null:e.layerClipId)});c.getComponentMethod("errorbars","plot")(b,e)}},{"../../components/color":51,"../../components/drawing":76,"../../lib":170,"../../lib/svg_text_utils":191,"../../registry":259,"./attributes":269,"./helpers":273,"./style":281,d3:16,"fast-isnumeric":18}],279:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,a=t.xaxis,i=t.yaxis,o=[];if(!1===e)for(r=0;r1||0===i.bargap&&0===i.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),r.selectAll("g.points").each(function(e){p(n.select(this),e[0].trace,t)}),l.getComponentMethod("errorbars","style")(r)},styleOnSelect:function(t,e){var r=e[0].node3,a=e[0].trace;a.selectedpoints?function(t,e,r){i.selectedPointStyle(t.selectAll("path"),e),function(t,e,r){t.each(function(t){var a,l=n.select(this);if(t.selected){a=o.extendFlat({},h(l,t,e,r));var s=e.selected.textfont&&e.selected.textfont.color;s&&(a.color=s),i.font(l,a)}else i.selectedTextStyle(l,e)})}(t.selectAll("text"),e,r)}(r,a,t):p(r,a,t)},getInsideTextFont:v,getOutsideTextFont:y,getBarColor:x}},{"../../components/color":51,"../../components/drawing":76,"../../lib":170,"../../registry":259,"./attributes":269,"./helpers":273,d3:16}],282:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l){r("marker.color",o),a(t,"marker")&&i(t,e,l,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),a(t,"marker.line")&&i(t,e,l,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":51,"../../components/colorscale/defaults":61,"../../components/colorscale/has_colorscale":65}],283:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),a=t("../../components/color/attributes"),i=t("../../lib/extend").extendFlat,o=n.marker,l=o.line;e.exports={y:{valType:"data_array",editType:"calc+clearAxisTypes"},x:{valType:"data_array",editType:"calc+clearAxisTypes"},x0:{valType:"any",editType:"calc+clearAxisTypes"},y0:{valType:"any",editType:"calc+clearAxisTypes"},name:{valType:"string",editType:"calc+clearAxisTypes"},text:i({},n.text,{}),whiskerwidth:{valType:"number",min:0,max:1,dflt:.5,editType:"calc"},notched:{valType:"boolean",editType:"calc"},notchwidth:{valType:"number",min:0,max:.5,dflt:.25,editType:"calc"},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers",editType:"calc"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1,editType:"calc"},jitter:{valType:"number",min:0,max:1,editType:"calc"},pointpos:{valType:"number",min:-2,max:2,editType:"calc"},orientation:{valType:"enumerated",values:["v","h"],editType:"calc+clearAxisTypes"},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)",editType:"style"},symbol:i({},o.symbol,{arrayOk:!1,editType:"plot"}),opacity:i({},o.opacity,{arrayOk:!1,dflt:1,editType:"style"}),size:i({},o.size,{arrayOk:!1,editType:"calc"}),color:i({},o.color,{arrayOk:!1,editType:"style"}),line:{color:i({},l.color,{arrayOk:!1,dflt:a.defaultLine,editType:"style"}),width:i({},l.width,{arrayOk:!1,dflt:0,editType:"style"}),outliercolor:{valType:"color",editType:"style"},outlierwidth:{valType:"number",min:0,dflt:1,editType:"style"},editType:"style"},editType:"plot"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,selected:{marker:n.selected.marker,editType:"style"},unselected:{marker:n.unselected.marker,editType:"style"},hoveron:{valType:"flaglist",flags:["boxes","points"],dflt:"boxes+points",editType:"style"}}},{"../../components/color/attributes":50,"../../lib/extend":164,"../scatter/attributes":368}],284:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=a._,o=t("../../plots/cartesian/axes");function l(t,e,r){var n={text:"tx"};for(var a in n)Array.isArray(e[a])&&(t[n[a]]=e[a][r])}function s(t,e){return t.v-e.v}function c(t){return t.v}e.exports=function(t,e){var r,u,f,d,p,h=t._fullLayout,g=o.getFromId(t,e.xaxis||"x"),v=o.getFromId(t,e.yaxis||"y"),y=[],m="violin"===e.type?"_numViolins":"_numBoxes";"h"===e.orientation?(u=g,f="x",d=v,p="y"):(u=v,f="y",d=g,p="x");var x=u.makeCalcdata(e,f),b=function(t,e,r,i,o){if(e in t)return r.makeCalcdata(t,e);var l;l=e+"0"in t?t[e+"0"]:"name"in t&&("category"===r.type||n(t.name)&&-1!==["linear","log"].indexOf(r.type)||a.isDateTime(t.name)&&"date"===r.type)?t.name:o;var s=r.d2c(l,0,t[e+"calendar"]);return i.map(function(){return s})}(e,p,d,x,h[m]),_=a.distinctVals(b),w=_.vals,k=_.minDiff/2,T=function(t,e){for(var r=t.length,n=new Array(r+1),a=0;a=0&&S0){var O=A[r].sort(s),z=O.map(c),P=z.length,D={pos:w[r],pts:O};D.min=z[0],D.max=z[P-1],D.mean=a.mean(z,P),D.sd=a.stdev(z,P,D.mean),D.q1=a.interp(z,.25),D.med=a.interp(z,.5),D.q3=a.interp(z,.75),D.lf=Math.min(D.q1,z[Math.min(a.findBin(2.5*D.q1-1.5*D.q3,z,!0)+1,P-1)]),D.uf=Math.max(D.q3,z[Math.max(a.findBin(2.5*D.q3-1.5*D.q1,z),0)]),D.lo=4*D.q1-3*D.q3,D.uo=4*D.q3-3*D.q1;var E=1.57*(D.q3-D.q1)/Math.sqrt(P);D.ln=D.med-E,D.un=D.med+E,y.push(D)}!function(t,e){if(a.isArrayOrTypedArray(e.selectedpoints))for(var r=0;r0?(y[0].t={num:h[m],dPos:k,posLetter:p,valLetter:f,labels:{med:i(t,"median:"),min:i(t,"min:"),q1:i(t,"q1:"),q3:i(t,"q3:"),max:i(t,"max:"),mean:"sd"===e.boxmean?i(t,"mean \xb1 \u03c3:"):i(t,"mean:"),lf:i(t,"lower fence:"),uf:i(t,"upper fence:")}},h[m]++,y):[{t:{empty:!0}}]}},{"../../lib":170,"../../plots/cartesian/axes":214,"fast-isnumeric":18}],285:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),a=t("../../lib"),i=["v","h"];function o(t,e,r,i,o){var l,s,c,u=e.calcdata,f=e._fullLayout,d=[],p="violin"===t?"_numViolins":"_numBoxes";for(l=0;lt.uf}),s=Math.max((t.max-t.min)/10,t.q3-t.q1),c=1e-9*s,p=s*l,h=[],g=0;if(r.jitter){if(0===s)for(g=1,h=new Array(i.length),e=0;et.lo&&(_.so=!0)}return i});h.enter().append("path").classed("point",!0),h.exit().remove(),h.call(i.translatePoints,s,c)}function u(t,e,r,i){var o,l,s=e.pos,c=e.val,u=i.bPos,f=i.bPosPxOffset||0,d=r.boxmean||(r.meanline||{}).visible;Array.isArray(i.bdPos)?(o=i.bdPos[0],l=i.bdPos[1]):(o=i.bdPos,l=i.bdPos);var p=t.selectAll("path.mean").data("box"===r.type&&r.boxmean||"violin"===r.type&&r.box.visible&&r.meanline.visible?a.identity:[]);p.enter().append("path").attr("class","mean").style({fill:"none","vector-effect":"non-scaling-stroke"}),p.exit().remove(),p.each(function(t){var e=s.c2p(t.pos+u,!0)+f,a=s.c2p(t.pos+u-o,!0)+f,i=s.c2p(t.pos+u+l,!0)+f,p=c.c2p(t.mean,!0),h=c.c2p(t.mean-t.sd,!0),g=c.c2p(t.mean+t.sd,!0);"h"===r.orientation?n.select(this).attr("d","M"+p+","+a+"V"+i+("sd"===d?"m0,0L"+h+","+e+"L"+p+","+a+"L"+g+","+e+"Z":"")):n.select(this).attr("d","M"+a+","+p+"H"+i+("sd"===d?"m0,0L"+e+","+h+"L"+a+","+p+"L"+e+","+g+"Z":""))})}e.exports={plot:function(t,e,r,i){var o=t._fullLayout,l=e.xaxis,f=e.yaxis,d=o._numBoxes,p=1-o.boxgap,h="group"===o.boxmode&&d>1;a.makeTraceGroups(i,r,"trace boxes").each(function(t){var r=n.select(this),a=t[0],i=a.t,g=a.trace;e.isRangePlot||(a.node3=r);var v,y,m=i.dPos*p*(1-o.boxgroupgap)/(h?d:1),x=h?2*i.dPos*((i.num+.5)/d-.5)*p:0,b=m*g.whiskerwidth;!0!==g.visible||i.empty?r.remove():("h"===g.orientation?(v=f,y=l):(v=l,y=f),i.bPos=x,i.bdPos=m,i.wdPos=b,i.wHover=i.dPos*(h?p/d:1),s(r,{pos:v,val:y},g,i),c(r,{x:l,y:f},g,i),u(r,{pos:v,val:y},g,i))})},plotBoxAndWhiskers:s,plotPoints:c,plotBoxMean:u}},{"../../components/drawing":76,"../../lib":170,d3:16}],293:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n,a=t.cd,i=t.xaxis,o=t.yaxis,l=[];if(!1===e)for(r=0;r":f.value>d&&(l.prefixBoundary=!0);break;case"<":f.valued)&&(l.prefixBoundary=!0);break;case"][":i=Math.min.apply(null,f.value),o=Math.max.apply(null,f.value),id&&(l.prefixBoundary=!0)}}},{}],298:[function(t,e,r){"use strict";var n=t("../../components/colorbar/draw"),a=t("./make_color_map"),i=t("./end_plus");e.exports=function(t,e){var r=e[0].trace,o="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+o).remove(),r.showscale){var l=e[0].t.cb=n(t,o),s=r.contours,c=r.line,u=s.size||1,f=s.coloring,d=a(r,{isColorbar:!0});l.fillgradient("heatmap"===f?r.colorscale:"").zrange("heatmap"===f?[r.zmin,r.zmax]:"").fillcolor("fill"===f?d:"").line({color:"lines"===f?d:c.color,width:!1!==s.showlines?c.width:0,dash:c.dash}).levels({start:s.start,end:i(s),size:u}).options(r.colorbar)()}}},{"../../components/colorbar/draw":56,"./end_plus":306,"./make_color_map":311}],299:[function(t,e,r){"use strict";e.exports={BOTTOMSTART:[1,9,13,104,713],TOPSTART:[4,6,7,104,713],LEFTSTART:[8,12,14,208,1114],RIGHTSTART:[2,3,11,208,1114],NEWDELTA:[null,[-1,0],[0,-1],[-1,0],[1,0],null,[0,-1],[-1,0],[0,1],[0,1],null,[0,1],[1,0],[1,0],[0,-1]],CHOOSESADDLE:{104:[4,1],208:[2,8],713:[7,13],1114:[11,14]},SADDLEREMAINDER:{1:4,2:8,4:1,7:13,8:2,11:14,13:7,14:11},LABELDISTANCE:2,LABELINCREASE:10,LABELMIN:3,LABELMAX:10,LABELOPTIMIZER:{EDGECOST:1,ANGLECOST:1,NEIGHBORCOST:5,SAMELEVELFACTOR:10,SAMELEVELDISTANCE:5,MAXCOST:100,INITIALSEARCHPOINTS:10,ITERATIONS:5}}},{}],300:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./label_defaults"),i=t("../../components/color"),o=i.addOpacity,l=i.opacity,s=t("../../constants/filter_ops"),c=s.CONSTRAINT_REDUCTION,u=s.COMPARISON_OPS2;e.exports=function(t,e,r,i,s,f){var d,p,h,g=e.contours,v=r("contours.operation");(g._operation=c[v],function(t,e){var r;-1===u.indexOf(e.operation)?(t("contours.value",[0,1]),Array.isArray(e.value)?e.value.length>2?e.value=e.value.slice(2):0===e.length?e.value=[0,1]:e.length<2?(r=parseFloat(e.value[0]),e.value=[r,r+1]):e.value=[parseFloat(e.value[0]),parseFloat(e.value[1])]:n(e.value)&&(r=parseFloat(e.value),e.value=[r,r+1])):(t("contours.value",0),n(e.value)||(Array.isArray(e.value)?e.value=parseFloat(e.value[0]):e.value=0))}(r,g),"="===v?d=g.showlines=!0:(d=r("contours.showlines"),h=r("fillcolor",o((t.line||{}).color||s,.5))),d)&&(p=r("line.color",h&&l(h)?o(e.fillcolor,1):s),r("line.width",2),r("line.dash"));r("line.smoothing"),a(r,i,p,f)}},{"../../components/color":51,"../../constants/filter_ops":150,"./label_defaults":310,"fast-isnumeric":18}],301:[function(t,e,r){"use strict";var n=t("../../constants/filter_ops"),a=t("fast-isnumeric");function i(t,e){var r,i=Array.isArray(e);function o(t){return a(t)?+t:null}return-1!==n.COMPARISON_OPS2.indexOf(t)?r=o(i?e[0]:e):-1!==n.INTERVAL_OPS.indexOf(t)?r=i?[o(e[0]),o(e[1])]:[o(e),o(e)]:-1!==n.SET_OPS.indexOf(t)&&(r=i?e.map(o):[o(e)]),r}function o(t){return function(e){e=i(t,e);var r=Math.min(e[0],e[1]),n=Math.max(e[0],e[1]);return{start:r,end:n,size:n-r}}}function l(t){return function(e){return{start:e=i(t,e),end:1/0,size:1/0}}}e.exports={"[]":o("[]"),"][":o("]["),">":l(">"),"<":l("<"),"=":l("=")}},{"../../constants/filter_ops":150,"fast-isnumeric":18}],302:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var a=n("contours.start"),i=n("contours.end"),o=!1===a||!1===i,l=r("contours.size");!(o?e.autocontour=!0:r("autocontour",!1))&&l||r("ncontours")}},{}],303:[function(t,e,r){"use strict";var n=t("../../lib");function a(t){return n.extendFlat({},t,{edgepaths:n.extendDeep([],t.edgepaths),paths:n.extendDeep([],t.paths)})}e.exports=function(t,e){var r,i,o,l=function(t){return t.reverse()},s=function(t){return t};switch(e){case"=":case"<":return t;case">":for(1!==t.length&&n.warn("Contour data invalid for the specified inequality operation."),i=t[0],r=0;r1e3){n.warn("Too many contours, clipping at 1000",t);break}return s}},{"../../lib":170,"./constraint_mapping":301,"./end_plus":306}],306:[function(t,e,r){"use strict";e.exports=function(t){return t.end+t.size/1e6}},{}],307:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./constants");function i(t,e,r,n){return Math.abs(t[0]-e[0])20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==a.BOTTOMSTART.indexOf(t)?i=1:-1!==a.LEFTSTART.indexOf(t)?n=1:-1!==a.TOPSTART.indexOf(t)?i=-1:n=-1;return[n,i]}(d,r,e),h=[l(t,e,[-p[0],-p[1]])],g=p.join(","),v=t.z.length,y=t.z[0].length;for(c=0;c<1e4;c++){if(d>20?(d=a.CHOOSESADDLE[d][(p[0]||p[1])<0?0:1],t.crossings[f]=a.SADDLEREMAINDER[d]):delete t.crossings[f],!(p=a.NEWDELTA[d])){n.log("Found bad marching index:",d,e,t.level);break}h.push(l(t,e,p)),e[0]+=p[0],e[1]+=p[1],i(h[h.length-1],h[h.length-2],o,s)&&h.pop(),f=e.join(",");var m=p[0]&&(e[0]<0||e[0]>y-2)||p[1]&&(e[1]<0||e[1]>v-2);if(f===u&&p.join(",")===g||r&&m)break;d=t.crossings[f]}1e4===c&&n.log("Infinite loop in contour?");var x,b,_,w,k,T,M,A,L,S,C,O,z,P,D,E=i(h[0],h[h.length-1],o,s),I=0,N=.2*t.smoothing,R=[],F=0;for(c=1;c=F;c--)if((x=R[c])=F&&x+R[b]A&&L--,t.edgepaths[L]=C.concat(h,S));break}q||(t.edgepaths[A]=h.concat(S))}for(A=0;At?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);return 5===r||10===r?t>(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4?5===r?713:1114:5===r?104:208:15===r?0:r}e.exports=function(t){var e,r,i,o,l,s,c,u,f,d=t[0].z,p=d.length,h=d[0].length,g=2===p||2===h;for(r=0;rt.level}return r?"M"+e.join("L")+"Z":""}(t,e),d=0,p=t.edgepaths.map(function(t,e){return e}),h=!0;function g(t){return Math.abs(t[1]-e[2][1])<.01}function v(t){return Math.abs(t[0]-e[0][0])<.01}function y(t){return Math.abs(t[0]-e[2][0])<.01}for(;p.length;){for(c=i.smoothopen(t.edgepaths[d],t.smoothing),f+=h?c:c.replace(/^M/,"L"),p.splice(p.indexOf(d),1),r=t.edgepaths[d][t.edgepaths[d].length-1],l=-1,o=0;o<4;o++){if(!r){a.log("Missing end?",d,t);break}for(u=r,Math.abs(u[1]-e[0][1])<.01&&!y(r)?n=e[1]:v(r)?n=e[0]:g(r)?n=e[3]:y(r)&&(n=e[2]),s=0;s=0&&(n=m,l=s):Math.abs(r[1]-n[1])<.01?Math.abs(r[1]-m[1])<.01&&(m[0]-r[0])*(n[0]-m[0])>=0&&(n=m,l=s):a.log("endpt to newendpt is not vert. or horz.",r,n,m)}if(r=n,l>=0)break;f+="L"+n}if(l===t.edgepaths.length){a.log("unclosed perimeter path");break}d=l,(h=-1===p.indexOf(d))&&(d=p[0],f+="Z")}for(d=0;dn.center?n.right-l:l-n.left)/(u+Math.abs(Math.sin(c)*o)),p=(s>n.middle?n.bottom-s:s-n.top)/(Math.abs(f)+Math.cos(c)*o);if(d<1||p<1)return 1/0;var h=v.EDGECOST*(1/(d-1)+1/(p-1));h+=v.ANGLECOST*c*c;for(var g=l-u,y=s-f,m=l+u,x=s+f,b=0;b2*v.MAXCOST)break;p&&(l/=2),s=(o=c-l/2)+1.5*l}if(d<=v.MAXCOST)return u},r.addLabelData=function(t,e,r,n){var a=e.width/2,i=e.height/2,o=t.x,l=t.y,s=t.theta,c=Math.sin(s),u=Math.cos(s),f=a*u,d=i*c,p=a*c,h=-i*u,g=[[o-f-d,l-p-h],[o+f-d,l+p-h],[o+f+d,l+p+h],[o-f+d,l-p+h]];r.push({text:e.text,x:o,y:l,dy:e.dy,theta:s,level:e.level,width:e.width,height:e.height}),n.push(g)},r.drawLabels=function(t,e,r,i,l){var s=t.selectAll("text").data(e,function(t){return t.text+","+t.x+","+t.y+","+t.theta});if(s.exit().remove(),s.enter().append("text").attr({"data-notex":1,"text-anchor":"middle"}).each(function(t){var e=t.x+Math.sin(t.theta)*t.dy,a=t.y-Math.cos(t.theta)*t.dy;n.select(this).text(t.text).attr({x:e,y:a,transform:"rotate("+180*t.theta/Math.PI+" "+e+" "+a+")"}).call(o.convertToTspans,r)}),l){for(var c="",u=0;ue.end&&(e.start=e.end=(e.start+e.end)/2),t._input.contours||(t._input.contours={}),a.extendFlat(t._input.contours,{start:e.start,end:e.end,size:e.size}),t._input.autocontour=!0}else if("constraint"!==e.type){var s,c=e.start,u=e.end,f=t._input.contours;if(c>u&&(e.start=f.start=u,u=e.end=f.end=c,c=e.start),!(e.size>0))s=c===u?1:i(c,u,t.ncontours).dtick,f.size=e.size=s}}},{"../../lib":170,"../../plots/cartesian/axes":214}],315:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../components/drawing"),i=t("../heatmap/style"),o=t("./make_color_map");e.exports=function(t){var e=n.select(t).selectAll("g.contour");e.style("opacity",function(t){return t[0].trace.opacity}),e.each(function(t){var e=n.select(this),r=t[0].trace,i=r.contours,l=r.line,s=i.size||1,c=i.start,u="constraint"===i.type,f=!u&&"lines"===i.coloring,d=!u&&"fill"===i.coloring,p=f||d?o(r):null;e.selectAll("g.contourlevel").each(function(t){n.select(this).selectAll("path").call(a.lineGroupStyle,l.width,f?p(t.level):l.color,l.dash)});var h=i.labelfont;if(e.selectAll("g.contourlabels text").each(function(t){a.font(n.select(this),{family:h.family,size:h.size,color:h.color||(f?p(t.level):l.color)})}),u)e.selectAll("g.contourfill path").style("fill",r.fillcolor);else if(d){var g;e.selectAll("g.contourfill path").style("fill",function(t){return void 0===g&&(g=t.level),p(t.level+.5*s)}),void 0===g&&(g=c),e.selectAll("g.contourbg path").style("fill",p(g-.5*s))}}),i(t)}},{"../../components/drawing":76,"../heatmap/style":330,"./make_color_map":311,d3:16}],316:[function(t,e,r){"use strict";var n=t("../../components/colorscale/defaults"),a=t("./label_defaults");e.exports=function(t,e,r,i,o){var l,s=r("contours.coloring"),c="";"fill"===s&&(l=r("contours.showlines")),!1!==l&&("lines"!==s&&(c=r("line.color","#000")),r("line.width",.5),r("line.dash")),"none"!==s&&(!0!==t.showlegend&&(e.showlegend=!1),e._dfltShowLegend=!1,n(t,e,i,r,{prefix:"",cLetter:"z"})),r("line.smoothing"),a(r,i,c,o)}},{"../../components/colorscale/defaults":61,"./label_defaults":310}],317:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),a=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),o=t("../../lib/extend").extendFlat;e.exports=o({z:{valType:"data_array",editType:"calc"},x:o({},n.x,{impliedEdits:{xtype:"array"}}),x0:o({},n.x0,{impliedEdits:{xtype:"scaled"}}),dx:o({},n.dx,{impliedEdits:{xtype:"scaled"}}),y:o({},n.y,{impliedEdits:{ytype:"array"}}),y0:o({},n.y0,{impliedEdits:{ytype:"scaled"}}),dy:o({},n.dy,{impliedEdits:{ytype:"scaled"}}),text:{valType:"data_array",editType:"calc"},transpose:{valType:"boolean",dflt:!1,editType:"calc"},xtype:{valType:"enumerated",values:["array","scaled"],editType:"calc+clearAxisTypes"},ytype:{valType:"enumerated",values:["array","scaled"],editType:"calc+clearAxisTypes"},zsmooth:{valType:"enumerated",values:["fast","best",!1],dflt:!1,editType:"calc"},connectgaps:{valType:"boolean",dflt:!1,editType:"calc"},xgap:{valType:"number",dflt:0,min:0,editType:"plot"},ygap:{valType:"number",dflt:0,min:0,editType:"plot"},zhoverformat:{valType:"string",dflt:"",editType:"none"},transforms:void 0},a("",{cLetter:"z",autoColorDflt:!1}),{colorbar:i})},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../lib/extend":164,"../scatter/attributes":368}],318:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib"),i=t("../../plots/cartesian/axes"),o=t("../histogram2d/calc"),l=t("../../components/colorscale/calc"),s=t("./convert_column_xyz"),c=t("./max_row_length"),u=t("./clean_2d_array"),f=t("./interp2d"),d=t("./find_empties"),p=t("./make_bound_array");e.exports=function(t,e){var r,h,g,v,y,m,x,b,_,w=i.getFromId(t,e.xaxis||"x"),k=i.getFromId(t,e.yaxis||"y"),T=n.traceIs(e,"contour"),M=n.traceIs(e,"histogram"),A=n.traceIs(e,"gl2d"),L=T?"best":e.zsmooth;if(w._minDtick=0,k._minDtick=0,M)r=(_=o(t,e)).x,h=_.x0,g=_.dx,v=_.y,y=_.y0,m=_.dy,x=_.z;else{var S=e.z;a.isArray1D(S)?(s(e,w,k,"x","y",["z"]),r=e._x,v=e._y,S=e._z):(r=e.x?w.makeCalcdata(e,"x"):[],v=e.y?k.makeCalcdata(e,"y"):[]),h=e.x0||0,g=e.dx||1,y=e.y0||0,m=e.dy||1,x=u(S,e.transpose),(T||e.connectgaps)&&(e._emptypoints=d(x),f(x,e._emptypoints))}function C(t){L=e._input.zsmooth=e.zsmooth=!1,a.warn('cannot use zsmooth: "fast": '+t)}if("fast"===L)if("log"===w.type||"log"===k.type)C("log axis found");else if(!M){if(r.length){var O=(r[r.length-1]-r[0])/(r.length-1),z=Math.abs(O/100);for(b=0;bz){C("x scale is not linear");break}}if(v.length&&"fast"===L){var P=(v[v.length-1]-v[0])/(v.length-1),D=Math.abs(P/100);for(b=0;bD){C("y scale is not linear");break}}}var E=c(x),I="scaled"===e.xtype?"":r,N=p(e,I,h,g,E,w),R="scaled"===e.ytype?"":v,F=p(e,R,y,m,x.length,k);A||(e._extremes[w._id]=i.findExtremes(w,N),e._extremes[k._id]=i.findExtremes(k,F));var B={x:N,y:F,z:x,text:e._text||e.text};if(I&&I.length===N.length-1&&(B.xCenter=I),R&&R.length===F.length-1&&(B.yCenter=R),M&&(B.xRanges=_.xRanges,B.yRanges=_.yRanges,B.pts=_.pts),T&&"constraint"===e.contours.type||l(e,x,"","z"),T&&e.contours&&"heatmap"===e.contours.coloring){var j={type:"contour"===e.type?"heatmap":"histogram2d",xcalendar:e.xcalendar,ycalendar:e.ycalendar};B.xfill=p(j,I,h,g,E,w),B.yfill=p(j,R,y,m,x.length,k)}return[B]}},{"../../components/colorscale/calc":59,"../../lib":170,"../../plots/cartesian/axes":214,"../../registry":259,"../histogram2d/calc":346,"./clean_2d_array":319,"./convert_column_xyz":321,"./find_empties":323,"./interp2d":326,"./make_bound_array":327,"./max_row_length":328}],319:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){var r,a,i,o,l,s;function c(t){if(n(t))return+t}if(e){for(r=0,l=0;l=0;o--)(l=((f[[(r=(i=d[o])[0])-1,a=i[1]]]||g)[2]+(f[[r+1,a]]||g)[2]+(f[[r,a-1]]||g)[2]+(f[[r,a+1]]||g)[2])/20)&&(s[i]=[r,a,l],d.splice(o,1),c=!0);if(!c)throw"findEmpties iterated with no new neighbors";for(i in s)f[i]=s[i],u.push(s[i])}return u.sort(function(t,e){return e[2]-t[2]})}},{"./max_row_length":328}],324:[function(t,e,r){"use strict";var n=t("../../components/fx"),a=t("../../lib"),i=t("../../plots/cartesian/axes");e.exports=function(t,e,r,o,l,s){var c,u,f,d,p=t.cd[0],h=p.trace,g=t.xa,v=t.ya,y=p.x,m=p.y,x=p.z,b=p.xCenter,_=p.yCenter,w=p.zmask,k=[h.zmin,h.zmax],T=h.zhoverformat,M=y,A=m;if(!1!==t.index){try{f=Math.round(t.index[1]),d=Math.round(t.index[0])}catch(e){return void a.error("Error hovering on heatmap, pointNumber must be [row,col], found:",t.index)}if(f<0||f>=x[0].length||d<0||d>x.length)return}else{if(n.inbox(e-y[0],e-y[y.length-1],0)>0||n.inbox(r-m[0],r-m[m.length-1],0)>0)return;if(s){var L;for(M=[2*y[0]-y[1]],L=1;Lg&&(y=Math.max(y,Math.abs(t[i][o]-h)/(v-g))))}return y}e.exports=function(t,e){var r,a=1;for(o(t,e),r=0;r.01;r++)a=o(t,e,i(a));return a>.01&&n.log("interp2d didn't converge quickly",a),t}},{"../../lib":170}],327:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib").isArrayOrTypedArray;e.exports=function(t,e,r,i,o,l){var s,c,u,f=[],d=n.traceIs(t,"contour"),p=n.traceIs(t,"histogram"),h=n.traceIs(t,"gl2d");if(a(e)&&e.length>1&&!p&&"category"!==l.type){var g=e.length;if(!(g<=o))return d?e.slice(0,o):e.slice(0,o+1);if(d||h)f=e.slice(0,o);else if(1===o)f=[e[0]-.5,e[0]+.5];else{for(f=[1.5*e[0]-.5*e[1]],u=1;u0;)p=h.c2p(T[x]),x--;for(p0;)m=g.c2p(M[x]),x--;if(m0&&(i=!0);for(var s=0;si){var o=i-r[t];return r[t]=i,o}}return 0},max:function(t,e,r,a){var i=a[e];if(n(i)){if(i=Number(i),!n(r[t]))return r[t]=i,i;if(r[t]c?t>o?t>1.1*a?a:t>1.1*i?i:o:t>l?l:t>s?s:c:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function p(t,e,r,n,i,l){if(n&&t>o){var s=h(e,i,l),c=h(r,i,l),u=t===a?0:1;return s[u]!==c[u]}return Math.floor(r/t)-Math.floor(e/t)>.1}function h(t,e,r){var n=e.c2d(t,a,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}e.exports=function(t,e,r,n,i){var l,s,c=-1.1*e,d=-.1*e,p=t-d,h=r[0],g=r[1],v=Math.min(f(h+d,h+p,n,i),f(g+d,g+p,n,i)),y=Math.min(f(h+c,h+d,n,i),f(g+c,g+d,n,i));if(v>y&&yo){var m=l===a?1:6,x=l===a?"M12":"M1";return function(e,r){var o=n.c2d(e,a,i),l=o.indexOf("-",m);l>0&&(o=o.substr(0,l));var c=n.d2c(o,0,i);if(cr.r2l(z)&&(D=i.tickIncrement(D,_.size,!0,d)),L.start=r.l2r(D),O||a.nestedProperty(e,v+".start").set(L.start)}var E=_.end,I=r.r2l(A.end),N=void 0!==I;if((_.endFound||N)&&I!==r.r2l(E)){var R=N?I:a.aggNums(Math.max,null,p);L.end=r.l2r(R),N||a.nestedProperty(e,v+".start").set(L.end)}var F="autobin"+o;return!1===e._input[F]&&(e._input[v]=a.extendFlat({},e[v]||{}),delete e._input[F],delete e[F]),[L,p]}e.exports=function(t,e){if(!0===e.visible){var r,d,p,h,g=[],v=[],y=i.getFromId(t,"h"===e.orientation?e.yaxis||"y":e.xaxis||"x"),m="h"===e.orientation?"y":"x",x={x:"y",y:"x"}[m],b=e[m+"calendar"],_=e.cumulative,w=f(t,e,y,m),k=w[0],T=w[1],M="string"==typeof k.size,A=[],L=M?A:k,S=[],C=[],O=[],z=0,P=e.histnorm,D=e.histfunc,E=-1!==P.indexOf("density");_.enabled&&E&&(P=P.replace(/ ?density$/,""),E=!1);var I,N="max"===D||"min"===D?null:0,R=l.count,F=s[P],B=!1,j=function(t){return y.r2c(t,0,b)};for(a.isArrayOrTypedArray(e[x])&&"count"!==D&&(I=e[x],B="avg"===D,R=l[D]),r=j(k.start),p=j(k.end)+(r-i.tickIncrement(r,k.size,!1,b))/1e6;r=0&&h=0;n--)l(n);else if("increasing"===e){for(n=1;n=0;n--)t[n]+=t[n+1];"exclude"===r&&(t.push(0),t.shift())}}(v,_.direction,_.currentbin);var Y=Math.min(g.length,v.length),W=[],J=0,Q=Y-1;for(r=0;r=J;r--)if(v[r]){Q=r;break}for(r=J;r<=Q;r++)if(n(g[r])&&n(v[r])){var $={p:g[r],s:v[r],b:0};_.enabled||($.pts=O[r],V?$.ph0=$.ph1=O[r].length?T[O[r][0]]:g[r]:($.ph0=H(A[r]),$.ph1=H(A[r+1],!0))),W.push($)}return 1===W.length&&(W[0].width1=i.tickIncrement(W[0].p,k.size,!1,b)-W[0].p),o(W,e),a.isArrayOrTypedArray(e.selectedpoints)&&a.tagSelected(W,e,Z),W}}},{"../../lib":170,"../../plots/cartesian/axes":214,"../bar/arrays_to_calcdata":268,"./average":334,"./bin_functions":336,"./bin_label_vals":337,"./norm_functions":344,"fast-isnumeric":18}],339:[function(t,e,r){"use strict";var n=t("../../lib"),a=n.nestedProperty,i=t("./attributes"),o={x:[{aStr:"xbins.start",name:"start"},{aStr:"xbins.end",name:"end"},{aStr:"xbins.size",name:"size"},{aStr:"nbinsx",name:"nbins"}],y:[{aStr:"ybins.start",name:"start"},{aStr:"ybins.end",name:"end"},{aStr:"ybins.size",name:"size"},{aStr:"nbinsy",name:"nbins"}]};e.exports=function(t,e){var r,l,s,c,u,f,d,p=e._histogramBinOpts={},h="overlay"===e.barmode;function g(t){return n.coerce(s._input,s,i,t)}for(r=0;rM&&v.splice(M,v.length-M),m.length>M&&m.splice(M,m.length-M),c(e,"x",v,g,_,k,x),c(e,"y",m,y,w,T,b);var A=[],L=[],S=[],C="string"==typeof e.xbins.size,O="string"==typeof e.ybins.size,z=[],P=[],D=C?z:e.xbins,E=O?P:e.ybins,I=0,N=[],R=[],F=e.histnorm,B=e.histfunc,j=-1!==F.indexOf("density"),H="max"===B||"min"===B?null:0,q=i.count,V=o[F],U=!1,G=[],Z=[],X="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";X&&"count"!==B&&(U="avg"===B,q=i[B]);var Y=e.xbins,W=_(Y.start),J=_(Y.end)+(W-a.tickIncrement(W,Y.size,!1,x))/1e6;for(r=W;r=0&&p=0&&h0?Number(h):p;else if("string"!=typeof h)u.size=p;else{var g=h.charAt(0),v=h.substr(1);((v=n(v)?Number(v):0)<=0||"date"!==s||"M"!==g||v!==Math.round(v))&&(u.size=p)}}e.exports=function(t,e){var r,n,a,i;function u(t){return o.coerce(a._input,a,l,t)}for(r=0;r")}}return v},r.crossTraceCalc=function(t){var e=t._fullLayout,r=t.calcdata,n=e.piecolorway,a=e._piecolormap;e.extendpiecolors&&(n=function(t){var e,r=JSON.stringify(t),n=s[r];if(!n){for(n=t.slice(),e=0;e0?1:-1)/2,y:i/(1+r*r/(n*n)),outside:!0}}function p(t,e){var r=t.trace,n=e.h*(r.domain.y[1]-r.domain.y[0]);return Math.min(t.titleBox.height,n/2)}function h(t){var e,r=t.pull;if(Array.isArray(r))for(r=0,e=0;er&&(r=t.pull[e]);return r}e.exports=function(t,e){var r=t._fullLayout;!function(t,e){for(var r,n,a=0;aa.vTotal/2?1:0)}(e),g.attr("stroke-linejoin","round"),g.each(function(){var g=n.select(this).selectAll("g.slice").data(e);g.enter().append("g").classed("slice",!0),g.exit().remove();var m=[[[],[]],[[],[]]],x=!1;g.each(function(e){if(e.hidden)n.select(this).selectAll("path,g").remove();else{e.pointNumber=e.i,e.curveNumber=y.index,m[e.pxmid[1]<0?0:1][e.pxmid[0]<0?0:1].push(e);var p=v.cx,h=v.cy,g=n.select(this),b=g.selectAll("path.surface").data([e]),_=!1,w=!1;if(b.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),g.select("path.textline").remove(),g.on("mouseover",function(){var i=t._fullLayout,o=t._fullData[y.index];if(!t._dragging&&!1!==i.hovermode){var l=o.hoverinfo;if(Array.isArray(l)&&(l=a.castHoverinfo({hoverinfo:[c.castOption(l,e.pts)],_module:y._module},i,0)),"all"===l&&(l="label+text+value+percent+name"),"none"!==l&&"skip"!==l&&l){var s=f(e,v),d=p+e.pxmid[0]*(1-s),g=h+e.pxmid[1]*(1-s),m=r.separators,x=[];if(-1!==l.indexOf("label")&&x.push(e.label),-1!==l.indexOf("text")){var b=c.castOption(o.hovertext||o.text,e.pts);b&&x.push(b)}-1!==l.indexOf("value")&&x.push(c.formatPieValue(e.v,m)),-1!==l.indexOf("percent")&&x.push(c.formatPiePercent(e.v/v.vTotal,m));var k=y.hoverlabel,T=k.font;a.loneHover({x0:d-s*v.r,x1:d+s*v.r,y:g,text:x.join("
"),name:-1!==l.indexOf("name")?o.name:void 0,idealAlign:e.pxmid[0]<0?"left":"right",color:c.castOption(k.bgcolor,e.pts)||e.color,borderColor:c.castOption(k.bordercolor,e.pts),fontFamily:c.castOption(T.family,e.pts),fontSize:c.castOption(T.size,e.pts),fontColor:c.castOption(T.color,e.pts)},{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:t}),_=!0}t.emit("plotly_hover",{points:[u(e,o)],event:n.event}),w=!0}}).on("mouseout",function(r){var i=t._fullLayout,o=t._fullData[y.index];w&&(r.originalEvent=n.event,t.emit("plotly_unhover",{points:[u(e,o)],event:n.event}),w=!1),_&&(a.loneUnhover(i._hoverlayer.node()),_=!1)}).on("click",function(){var r=t._fullLayout,i=t._fullData[y.index];t._dragging||!1===r.hovermode||(t._hoverdata=[u(e,i)],a.click(t,n.event))}),y.pull){var k=+c.castOption(y.pull,e.pts)||0;k>0&&(p+=k*e.pxmid[0],h+=k*e.pxmid[1])}e.cxFinal=p,e.cyFinal=h;var T=y.hole;if(e.v===v.vTotal){var M="M"+(p+e.px0[0])+","+(h+e.px0[1])+O(e.px0,e.pxmid,!0,1)+O(e.pxmid,e.px0,!0,1)+"Z";T?b.attr("d","M"+(p+T*e.px0[0])+","+(h+T*e.px0[1])+O(e.px0,e.pxmid,!1,T)+O(e.pxmid,e.px0,!1,T)+"Z"+M):b.attr("d",M)}else{var A=O(e.px0,e.px1,!0,1);if(T){var L=1-T;b.attr("d","M"+(p+T*e.px1[0])+","+(h+T*e.px1[1])+O(e.px1,e.px0,!1,T)+"l"+L*e.px0[0]+","+L*e.px0[1]+A+"Z")}else b.attr("d","M"+p+","+h+"l"+e.px0[0]+","+e.px0[1]+A+"Z")}var S=c.castOption(y.textposition,e.pts),C=g.selectAll("g.slicetext").data(e.text&&"none"!==S?[0]:[]);C.enter().append("g").classed("slicetext",!0),C.exit().remove(),C.each(function(){var r=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});r.text(e.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(o.font,"outside"===S?function(t,e,r){var n=c.castOption(t.outsidetextfont.color,e.pts)||c.castOption(t.textfont.color,e.pts)||r.color,a=c.castOption(t.outsidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,i=c.castOption(t.outsidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n,family:a,size:i}}(y,e,t._fullLayout.font):function(t,e,r){var n=c.castOption(t.insidetextfont.color,e.pts);!n&&t._input.textfont&&(n=c.castOption(t._input.textfont.color,e.pts));var a=c.castOption(t.insidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,o=c.castOption(t.insidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n||i.contrast(e.color),family:a,size:o}}(y,e,t._fullLayout.font)).call(s.convertToTspans,t);var a,u=o.bBox(r.node());"outside"===S?a=d(u,e):(a=function(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,i=Math.PI*Math.min(e.v/r.vTotal,.5),o=1-r.trace.hole,l=f(e,r),s={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(s.scale>=1)return s;var c=a+1/(2*Math.tan(i)),u=r.r*Math.min(1/(Math.sqrt(c*c+.5)+c),o/(Math.sqrt(a*a+o/2)+a)),d={scale:2*u/t.height,rCenter:Math.cos(u/r.r)-u*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},p=1/a,h=p+1/(2*Math.tan(i)),g=r.r*Math.min(1/(Math.sqrt(h*h+.5)+h),o/(Math.sqrt(p*p+o/2)+p)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},y=v.scale>d.scale?v:d;return s.scale<1&&y.scale>s.scale?y:s}(u,e,v),"auto"===S&&a.scale<1&&(r.call(o.font,y.outsidetextfont),y.outsidetextfont.family===y.insidetextfont.family&&y.outsidetextfont.size===y.insidetextfont.size||(u=o.bBox(r.node())),a=d(u,e)));var g=p+e.pxmid[0]*a.rCenter+(a.x||0),m=h+e.pxmid[1]*a.rCenter+(a.y||0);a.outside&&(e.yLabelMin=m-u.height/2,e.yLabelMid=m,e.yLabelMax=m+u.height/2,e.labelExtraX=0,e.labelExtraY=0,x=!0),r.attr("transform","translate("+g+","+m+")"+(a.scale<1?"scale("+a.scale+")":"")+(a.rotate?"rotate("+a.rotate+")":"")+"translate("+-(u.left+u.right)/2+","+-(u.top+u.bottom)/2+")")})}function O(t,r,n,a){return"a"+a*v.r+","+a*v.r+" 0 "+e.largeArc+(n?" 1 ":" 0 ")+a*(r[0]-t[0])+","+a*(r[1]-t[1])}});var b=n.select(this).selectAll("g.titletext").data(y.title?[0]:[]);b.enter().append("g").classed("titletext",!0),b.exit().remove(),b.each(function(){var e,a=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});a.text(y.title).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(o.font,y.titlefont).call(s.convertToTspans,t),e="middle center"===y.titleposition?function(t){var e=Math.sqrt(t.titleBox.width*t.titleBox.width+t.titleBox.height*t.titleBox.height);return{x:t.cx,y:t.cy,scale:t.trace.hole*t.r*2/e,tx:0,ty:-t.titleBox.height/2+t.trace.titlefont.size}}(v):function(t,e){var r,n,a=1,i=1,o=t.trace,l={x:t.cx,y:t.cy},s={tx:0,ty:0};s.ty+=o.titlefont.size,n=h(o),-1!==o.titleposition.indexOf("top")?(l.y-=(1+n)*t.r,s.ty-=t.titleBox.height):-1!==o.titleposition.indexOf("bottom")&&(l.y+=(1+n)*t.r);-1!==o.titleposition.indexOf("left")?(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x-=(1+n)*t.r,s.tx+=t.titleBox.width/2):-1!==o.titleposition.indexOf("center")?r=e.w*(o.domain.x[1]-o.domain.x[0]):-1!==o.titleposition.indexOf("right")&&(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x+=(1+n)*t.r,s.tx-=t.titleBox.width/2);return a=r/t.titleBox.width,i=p(t,e)/t.titleBox.height,{x:l.x,y:l.y,scale:Math.min(a,i),tx:s.tx,ty:s.ty}}(v,r._size),a.attr("transform","translate("+e.x+","+e.y+")"+(e.scale<1?"scale("+e.scale+")":"")+"translate("+e.tx+","+e.ty+")")}),x&&function(t,e){var r,n,a,i,o,l,s,u,f,d,p,h,g;function v(t,e){return t.pxmid[1]-e.pxmid[1]}function y(t,e){return e.pxmid[1]-t.pxmid[1]}function m(t,r){r||(r={});var a,u,f,p,h,g,v=r.labelExtraY+(n?r.yLabelMax:r.yLabelMin),y=n?t.yLabelMin:t.yLabelMax,m=n?t.yLabelMax:t.yLabelMin,x=t.cyFinal+o(t.px0[1],t.px1[1]),b=v-y;if(b*s>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(u=0;u=(c.castOption(e.pull,f.pts)||0)||((t.pxmid[1]-f.pxmid[1])*s>0?(p=f.cyFinal+o(f.px0[1],f.px1[1]),(b=p-y-t.labelExtraY)*s>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-x)*s>0&&(a=3*l*Math.abs(u-d.indexOf(t)),h=f.cxFinal+i(f.px0[0],f.px1[0]),(g=h+a-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*l>0&&(t.labelExtraX+=g)))}for(n=0;n<2;n++)for(a=n?v:y,o=n?Math.max:Math.min,s=n?1:-1,r=0;r<2;r++){for(i=r?Math.max:Math.min,l=r?1:-1,(u=t[n][r]).sort(a),f=t[1-n][r],d=f.concat(u),h=[],p=0;pMath.abs(c)?o+="l"+c*t.pxmid[0]/t.pxmid[1]+","+c+"H"+(a+t.labelExtraX+l):o+="l"+t.labelExtraX+","+s+"v"+(c-s)+"h"+l}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+l;e.append("path").classed("textline",!0).call(i.stroke,y.outsidetextfont.color).attr({"stroke-width":Math.min(2,y.outsidetextfont.size/8),d:o,fill:"none"})}})})});setTimeout(function(){g.selectAll("tspan").each(function(){var t=n.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":51,"../../components/drawing":76,"../../components/fx":93,"../../lib":170,"../../lib/svg_text_utils":191,"./event_data":359,"./helpers":360,d3:16}],365:[function(t,e,r){"use strict";var n=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each(function(t){n.select(this).call(a,t,e)})})}},{"./style_one":366,d3:16}],366:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("./helpers").castOption;e.exports=function(t,e,r){var i=r.marker.line,o=a(i.color,e.pts)||n.defaultLine,l=a(i.width,e.pts)||0;t.style({"stroke-width":l}).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":51,"./helpers":360}],367:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rl&&M[v].gap;)v--;for(m=M[v].s,h=M.length-1;h>v;h--)M[h].s=m;for(;lA[u]&&u=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===r.xaxis&&i.yaxis===r.yaxis){i.opacity=void 0;break}}}}}},{}],375:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),l=t("./subtypes"),s=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),d=t("./line_shape_defaults"),p=t("./text_defaults"),h=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,a){return n.coerce(t,e,i,r,a)}var y=s(t,e,g,v);if(y||(e.visible=!1),e.visible){var m=c(t,e,g,v),x=!m&&yG!=(R=P[O][1])>=G&&(E=P[O-1][0],I=P[O][0],R-N&&(D=E+(I-E)*(G-N)/(R-N),H=Math.min(H,D),q=Math.max(q,D)));H=Math.max(H,0),q=Math.min(q,d._length);var Z=l.defaultLine;return l.opacity(f.fillcolor)?Z=f.fillcolor:l.opacity((f.line||{}).color)&&(Z=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:H,x1:q,y0:G,y1:G,color:Z}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":51,"../../components/fx":93,"../../lib":170,"../../registry":259,"./fill_hover_text":376,"./get_trace_color":378}],380:[function(t,e,r){"use strict";var n={},a=t("./subtypes");n.hasLines=a.hasLines,n.hasMarkers=a.hasMarkers,n.hasText=a.hasText,n.isBubble=a.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":226,"./arrays_to_calcdata":367,"./attributes":368,"./calc":369,"./cross_trace_calc":373,"./cross_trace_defaults":374,"./defaults":375,"./hover":379,"./marker_colorbar":386,"./plot":388,"./select":389,"./style":391,"./subtypes":392}],381:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l,s){var c=(t.marker||{}).color;(l("line.color",r),a(t,"line"))?i(t,e,o,l,{prefix:"line.",cLetter:"c",noScale:!0}):l("line.color",!n(c)&&c||r);l("line.width"),(s||{}).noDash||l("line.dash")}},{"../../components/colorscale/defaults":61,"../../components/colorscale/has_colorscale":65,"../../lib":170}],382:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),a=n.BADNUM,i=n.LOG_CLIP,o=i+.5,l=i-.5,s=t("../../lib"),c=s.segmentsIntersect,u=s.constrain,f=t("./constants");e.exports=function(t,e){var r,n,i,d,p,h,g,v,y,m,x,b,_,w,k,T,M,A,L=e.xaxis,S=e.yaxis,C="log"===L.type,O="log"===S.type,z=L._length,P=S._length,D=e.connectGaps,E=e.baseTolerance,I=e.shape,N="linear"===I,R=[],F=f.minTolerance,B=new Array(t.length),j=0;function H(e){var r=t[e];if(!r)return!1;var n=L.c2p(r.x),i=S.c2p(r.y);if(n===a){if(C&&(n=L.c2p(r.x,!0)),n===a)return!1;O&&i===a&&(n*=Math.abs(L._m*P*(L._m>0?o:l)/(S._m*z*(S._m>0?o:l)))),n*=1e3}if(i===a){if(O&&(i=S.c2p(r.y,!0)),i===a)return!1;i*=1e3}return[n,i]}function q(t,e,r,n){var a=r-t,i=n-e,o=.5-t,l=.5-e,s=a*a+i*i,c=a*o+i*l;if(c>0&&ctt||t[1]rt)return[u(t[0],K,tt),u(t[1],et,rt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,a){var i=at(n),o=at(a),l=[];if(i&&o&&it(i,o))return l;i&&l.push(i),o&&l.push(o);var c=2*s.constrain((n[t]+a[t])/2,e,r)-((i||n)[t]+(o||a)[t]);c&&((i&&o?c>0==i[t]>o[t]?i:o:i||o)[t]+=c);return l}}function lt(t){var e=t[0],r=t[1],n=e===B[j-1][0],a=r===B[j-1][1];if(!n||!a)if(j>1){var i=e===B[j-2][0],o=r===B[j-2][1];n&&(e===K||e===tt)&&i?o?j--:B[j-1]=t:a&&(r===et||r===rt)&&o?i?j--:B[j-1]=t:B[j++]=t}else B[j++]=t}function st(t){B[j-1][0]!==t[0]&&B[j-1][1]!==t[1]&<([X,Y]),lt(t),W=null,X=Y=0}function ct(t){if(M=t[0]/z,A=t[1]/P,G=t[0]tt?tt:0,Z=t[1]rt?rt:0,G||Z){if(j)if(W){var e=Q(W,t);e.length>1&&(st(e[0]),B[j++]=e[1])}else J=Q(B[j-1],t)[0],B[j++]=J;else B[j++]=[G||t[0],Z||t[1]];var r=B[j-1];G&&Z&&(r[0]!==G||r[1]!==Z)?(W&&(X!==G&&Y!==Z?lt(X&&Y?(n=W,i=(a=t)[0]-n[0],o=(a[1]-n[1])/i,(n[1]*a[0]-a[1]*n[0])/i>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[X||G,Y||Z]):X&&Y&<([X,Y])),lt([G,Z])):X-G&&Y-Z&<([G||X,Z||Y]),W=t,X=G,Y=Z}else W&&st(Q(W,t)[0]),B[j++]=t;var n,a,i,o}for("linear"===I||"spline"===I?Q=function(t,e){for(var r=[],n=0,a=0;a<4;a++){var i=nt[a],o=c(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&U(o,t)V(h,ut))break;i=h,(_=y[0]*v[0]+y[1]*v[1])>x?(x=_,d=h,g=!1):_=t.length||!h)break;ct(h),n=h}}else ct(d)}W&<([X||W[0],Y||W[1]]),R.push(B.slice(0,j))}return R}},{"../../constants/numerical":152,"../../lib":170,"./constants":372}],383:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],384:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var a,i,o,l,s,c={},u=!1,f=-1,d=0,p=-1;for(i=0;i=0?s=p:(s=p=d,d++),s0?Math.max(e,a):0}}},{"fast-isnumeric":18}],386:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],387:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,l,s,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(r=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",r),a(t,"marker")&&i(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c.noSelect||(s("selected.marker.color"),s("unselected.marker.color"),s("selected.marker.size"),s("unselected.marker.size")),c.noLine||(s("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?n.background:n.defaultLine),a(t,"marker.line")&&i(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0)),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode")),c.gradient)&&("none"!==s("marker.gradient.type")&&s("marker.gradient.color"))}},{"../../components/color":51,"../../components/colorscale/defaults":61,"../../components/colorscale/has_colorscale":65,"./subtypes":392}],388:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,l=i.identity,s=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),d=t("../../lib/polygon").tester;function p(t,e,r,f,p,h,g){var v;!function(t,e,r,a,o){var l=r.xaxis,s=r.yaxis,u=n.extent(i.simpleMap(l.range,l.r2c)),f=n.extent(i.simpleMap(s.range,s.r2c)),d=a[0].trace;if(!c.hasMarkers(d))return;var p=d.marker.maxdisplayed;if(0===p)return;var h=a.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(h.length/p),v=0;o.forEach(function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function m(t){return y?t.transition():t}var x=r.xaxis,b=r.yaxis,_=f[0].trace,w=_.line,k=n.select(h),T=o(k,"g","errorbars"),M=o(k,"g","lines"),A=o(k,"g","points"),L=o(k,"g","text");if(a.getComponentMethod("errorbars","plot")(T,r,g),!0===_.visible){var S,C;m(k).style("opacity",_.opacity);var O=_.fill.charAt(_.fill.length-1);"x"!==O&&"y"!==O&&(O=""),r.isRangePlot||(f[0].node3=k);var z="",P=[],D=_._prevtrace;D&&(z=D._prevRevpath||"",C=D._nextFill,P=D._polygons);var E,I,N,R,F,B,j,H,q,V="",U="",G=[],Z=i.noop;if(S=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(C&&C.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(N=s.steps(w.shape),R=s.steps(w.shape.split("").reverse().join(""))):N=R="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?s.smoothclosed(t.slice(1),w.smoothing):s.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return R(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)m(r.style("opacity",0).attr("d",E).call(s.lineGroupStyle)).style("opacity",1);else{var a=m(r);a.attr("d",E),s.singleLineStyle(f,a)}}}}}var X=M.selectAll(".js-line").data(G);m(X.exit()).style("opacity",0).remove(),X.each(Z(!1)),X.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(s.lineGroupStyle).each(Z(!0)),s.setClipUrl(X,r.layerClipId),G.length?(S?(S.datum(f),B&&H&&(O?("y"===O?B[1]=H[1]=b.c2p(0,!0):"x"===O&&(B[0]=H[0]=x.c2p(0,!0)),m(S).attr("d","M"+H+"L"+B+"L"+V.substr(1)).call(s.singleFillStyle)):m(S).attr("d",V+"Z").call(s.singleFillStyle))):C&&("tonext"===_.fill.substr(0,6)&&V&&z?("tonext"===_.fill?m(C).attr("d",V+"Z"+z+"Z").call(s.singleFillStyle):m(C).attr("d",V+"L"+z.substr(1)+"Z").call(s.singleFillStyle),_._polygons=_._polygons.concat(P)):(W(C),_._polygons=null)),_._prevRevpath=U,_._prevPolygons=q):(S?W(S):C&&W(C),_._polygons=_._prevRevpath=_._prevPolygons=null),A.datum(f),L.datum(f),function(e,a,i){var o,u=i[0].trace,f=c.hasMarkers(u),d=c.hasText(u),p=tt(u),h=et,g=et;if(f||d){var v=l,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?Q:J:_&&!w&&(v=$),f&&(h=v),d&&(g=v)}var k,T=(o=e.selectAll("path.point").data(h,p)).enter().append("path").classed("point",!0);y&&T.call(s.pointStyle,u,t).call(s.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=s.makePointStyleFns(u)),o.each(function(e){var a=n.select(this),i=m(a);s.translatePoint(e,i,x,b)?(s.singlePointStyle(e,i,u,k,t),r.layerClipId&&s.hideOutsideRangePoint(e,i,x,b,u.xcalendar,u.ycalendar),u.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),a=m(e.select("text"));s.translatePoint(t,a,x,b)?r.layerClipId&&s.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(s.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),r=b.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){m(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(A,L,f);var Y=!1===_.cliponaxis?null:r.layerClipId;s.setClipUrl(A,Y),s.setClipUrl(L,Y)}function W(t){m(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function Q(t){return t.filter(function(t){return t.vis})}function $(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,a,i,c){var u,d,h=!i,g=!!i&&i.duration>0,v=f(t,e,r);((u=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,r){e.each(function(t){var e=o(n.select(this),"g","fills");s.setClipUrl(e,r.layerClipId);var a=t[0].trace,i=[];a._ownfill&&i.push("_ownFill"),a._nexttrace&&i.push("_nextFill");var c=e.selectAll("g").data(i,l);c.enter().append("g"),c.exit().each(function(t){a[t]=null}).remove(),c.order().each(function(t){a[t]=o(n.select(this),"path","js-fill")})})}(0,u,e),g)?(c&&(d=c()),n.transition().duration(i.duration).ease(i.easing).each("end",function(){d&&d()}).each("interrupt",function(){d&&d()}).each(function(){a.selectAll("g.trace").each(function(r,n){p(t,n,e,r,v,this,i)})})):u.each(function(r,n){p(t,n,e,r,v,this,i)});h&&u.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":76,"../../lib":170,"../../lib/polygon":182,"../../registry":259,"./line_points":382,"./link_traces":384,"./subtypes":392,d3:16}],389:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,a,i,o,l=t.cd,s=t.xaxis,c=t.yaxis,u=[],f=l[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r"),o}function y(t,e){v.push(t._hovertitle+": "+a.tickText(t,e,"hover").text)}}},{"../../plots/cartesian/axes":214,"../scatter/hover":379}],400:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("../scatter/style").style,n.styleOnSelect=t("../scatter/style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("../scatter/select"),n.eventData=t("./event_data"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","showLegend","scatter-like"],n.meta={},e.exports=n},{"../../plots/ternary":255,"../scatter/marker_colorbar":386,"../scatter/select":389,"../scatter/style":391,"./attributes":395,"./calc":396,"./defaults":397,"./event_data":398,"./hover":399,"./plot":401}],401:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e,r){var a=e.plotContainer;a.select(".scatterlayer").selectAll("*").remove();var i={xaxis:e.xaxis,yaxis:e.yaxis,plot:a,layerClipId:e._hasClipOnAxisFalse?e.clipIdRelative:null},o=e.layers.frontplot.select("g.scatterlayer");n(t,i,r,o)}},{"../scatter/plot":388}],402:[function(t,e,r){"use strict";var n=t("../box/attributes"),a=t("../../lib/extend").extendFlat;e.exports={y:n.y,x:n.x,x0:n.x0,y0:n.y0,name:n.name,orientation:a({},n.orientation,{}),bandwidth:{valType:"number",min:0,editType:"calc"},scalegroup:{valType:"string",dflt:"",editType:"calc"},scalemode:{valType:"enumerated",values:["width","count"],dflt:"width",editType:"calc"},spanmode:{valType:"enumerated",values:["soft","hard","manual"],dflt:"soft",editType:"calc"},span:{valType:"info_array",items:[{valType:"any",editType:"calc"},{valType:"any",editType:"calc"}],editType:"calc"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,points:a({},n.boxpoints,{}),jitter:a({},n.jitter,{}),pointpos:a({},n.pointpos,{}),marker:n.marker,text:n.text,box:{visible:{valType:"boolean",dflt:!1,editType:"plot"},width:{valType:"number",min:0,max:1,dflt:.25,editType:"plot"},fillcolor:{valType:"color",editType:"style"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,editType:"style"},editType:"style"},editType:"plot"},meanline:{visible:{valType:"boolean",dflt:!1,editType:"plot"},color:{valType:"color",editType:"style"},width:{valType:"number",min:0,editType:"style"},editType:"plot"},side:{valType:"enumerated",values:["both","positive","negative"],dflt:"both",editType:"plot"},selected:n.selected,unselected:n.unselected,hoveron:{valType:"flaglist",flags:["violins","points","kde"],dflt:"violins+points+kde",extras:["all"],editType:"style"}}},{"../../lib/extend":164,"../box/attributes":283}],403:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("../box/calc"),o=t("./helpers"),l=t("../../constants/numerical").BADNUM;function s(t,e,r){var a=e.max-e.min;if(!a)return 1;if(t.bandwidth)return Math.max(t.bandwidth,a/1e4);var i=r.length,o=n.stdev(r,i-1,e.mean);return Math.max(function(t,e,r){return 1.059*Math.min(e,r/1.349)*Math.pow(t,-.2)}(i,o,e.q3-e.q1),a/100)}function c(t,e,r,n){var i,o=t.spanmode,s=t.span||[],c=[e.min,e.max],u=[e.min-2*n,e.max+2*n];function f(n){var a=s[n],i=r.d2c(a,0,t[e.valLetter+"calendar"]);return i===l?u[n]:i}var d={type:"linear",range:i="soft"===o?u:"hard"===o?c:[f(0),f(1)]};return a.setConvert(d),d.cleanRange(),i}e.exports=function(t,e){var r=i(t,e);if(r[0].t.empty)return r;var l=t._fullLayout,u=a.getFromId(t,e["h"===e.orientation?"xaxis":"yaxis"]),f=l._violinScaleGroupStats,d=e.scalegroup,p=f[d];p||(p=f[d]={maxWidth:0,maxCount:0});for(var h=1/0,g=-1/0,v=0;v0){var m,x,b,_,w,k=t.xa,T=t.ya;"h"===d.orientation?(w=e,m="y",b=T,x="x",_=k):(w=r,m="x",b=k,x="y",_=T);var M=f[t.index];if(w>=M.span[0]&&w<=M.span[1]){var A=n.extendFlat({},t),L=_.c2p(w,!0),S=o.getKdeValue(M,d,w),C=o.getPositionOnKdePath(M,d,L),O=b._offset,z=b._length;A[m+"0"]=C[0],A[m+"1"]=C[1],A[x+"0"]=A[x+"1"]=L,A[x+"Label"]=x+": "+a.hoverLabelText(_,w)+", "+f[0].t.labels.kde+" "+S.toFixed(3),A.spikeDistance=y[0].spikeDistance;var P=m+"Spike";A[P]=y[0][P],y[0].spikeDistance=void 0,y[0][P]=void 0,v.push(A),(u={stroke:t.color})[m+"1"]=n.constrain(O+C[0],O,O+z),u[m+"2"]=n.constrain(O+C[1],O,O+z),u[x+"1"]=u[x+"2"]=_._offset+L}}}-1!==p.indexOf("points")&&(c=i.hoverOnPoints(t,e,r));var D=s.selectAll(".violinline-"+d.uid).data(u?[0]:[]);return D.enter().append("line").classed("violinline-"+d.uid,!0).attr("stroke-width",1.5),D.exit().remove(),D.attr(u),"closest"===l?c?[c]:v:c?(v.push(c),v):v}},{"../../lib":170,"../../plots/cartesian/axes":214,"../box/hover":288,"./helpers":406}],408:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),crossTraceCalc:t("./cross_trace_calc"),plot:t("./plot"),style:t("./style"),styleOnSelect:t("../scatter/style").styleOnSelect,hoverPoints:t("./hover"),selectPoints:t("../box/select"),moduleType:"trace",name:"violin",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","symbols","oriented","box-violin","showLegend","violinLayout","zoomScale"],meta:{}}},{"../../plots/cartesian":226,"../box/select":293,"../scatter/style":391,"./attributes":402,"./calc":403,"./cross_trace_calc":404,"./defaults":405,"./hover":407,"./layout_attributes":409,"./layout_defaults":410,"./plot":411,"./style":412}],409:[function(t,e,r){"use strict";var n=t("../box/layout_attributes"),a=t("../../lib").extendFlat;e.exports={violinmode:a({},n.boxmode,{}),violingap:a({},n.boxgap,{}),violingroupgap:a({},n.boxgroupgap,{})}},{"../../lib":170,"../box/layout_attributes":290}],410:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./layout_attributes"),i=t("../box/layout_defaults");e.exports=function(t,e,r){i._supply(t,e,r,function(r,i){return n.coerce(t,e,a,r,i)},"violin")}},{"../../lib":170,"../box/layout_defaults":291,"./layout_attributes":409}],411:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../components/drawing"),o=t("../box/plot"),l=t("../scatter/line_points"),s=t("./helpers");e.exports=function(t,e,r,c){var u=t._fullLayout,f=e.xaxis,d=e.yaxis;function p(t){var e=l(t,{xaxis:f,yaxis:d,connectGaps:!0,baseTolerance:.75,shape:"spline",simplify:!0});return i.smoothopen(e[0],1)}a.makeTraceGroups(c,r,"trace violins").each(function(t){var r=n.select(this),i=t[0],l=i.t,c=i.trace;e.isRangePlot||(i.node3=r);var h=u._numViolins,g="group"===u.violinmode&&h>1,v=1-u.violingap,y=l.bdPos=l.dPos*v*(1-u.violingroupgap)/(g?h:1),m=l.bPos=g?2*l.dPos*((l.num+.5)/h-.5)*v:0;if(l.wHover=l.dPos*(g?v/h:1),!0!==c.visible||l.empty)r.remove();else{var x=e[l.valLetter+"axis"],b=e[l.posLetter+"axis"],_="both"===c.side,w=_||"positive"===c.side,k=_||"negative"===c.side,T=u._violinScaleGroupStats[c.scalegroup],M=r.selectAll("path.violin").data(a.identity);M.enter().append("path").style("vector-effect","non-scaling-stroke").attr("class","violin"),M.exit().remove(),M.each(function(t){var e,r,a,i,o,s,u,f,d=n.select(this),h=t.density,g=h.length,v=t.pos+m,M=b.c2p(v);switch(c.scalemode){case"width":e=T.maxWidth/y;break;case"count":e=T.maxWidth/y*(T.maxCount/t.pts.length)}if(w){for(u=new Array(g),o=0;o:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;margin-left:0px;margin-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var i in a){var o=i.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");n.addStyleRule(o,a[i])}},{"../src/lib":168}],2:[function(t,e,r){"use strict";e.exports={undo:{width:857.1,height:1e3,path:"m857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z",transform:"matrix(1 0 0 -1 0 850)"},home:{width:928.6,height:1e3,path:"m786 296v-267q0-15-11-26t-25-10h-214v214h-143v-214h-214q-15 0-25 10t-11 26v267q0 1 0 2t0 2l321 264 321-264q1-1 1-4z m124 39l-34-41q-5-5-12-6h-2q-7 0-12 3l-386 322-386-322q-7-4-13-4-7 2-12 7l-35 41q-4 5-3 13t6 12l401 334q18 15 42 15t43-15l136-114v109q0 8 5 13t13 5h107q8 0 13-5t5-13v-227l122-102q5-5 6-12t-4-13z",transform:"matrix(1 0 0 -1 0 850)"},"camera-retro":{width:1e3,height:1e3,path:"m518 386q0 8-5 13t-13 5q-37 0-63-27t-26-63q0-8 5-13t13-5 12 5 5 13q0 23 16 38t38 16q8 0 13 5t5 13z m125-73q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101z m-572-320h858v71h-858v-71z m643 320q0 89-62 152t-152 62-151-62-63-152 63-151 151-63 152 63 62 151z m-571 358h214v72h-214v-72z m-72-107h858v143h-462l-36-71h-360v-72z m929 143v-714q0-30-21-51t-50-21h-858q-29 0-50 21t-21 51v714q0 30 21 51t50 21h858q29 0 50-21t21-51z",transform:"matrix(1 0 0 -1 0 850)"},zoombox:{width:1e3,height:1e3,path:"m1000-25l-250 251c40 63 63 138 63 218 0 224-182 406-407 406-224 0-406-182-406-406s183-406 407-406c80 0 155 22 218 62l250-250 125 125z m-812 250l0 438 437 0 0-438-437 0z m62 375l313 0 0-312-313 0 0 312z",transform:"matrix(1 0 0 -1 0 850)"},pan:{width:1e3,height:1e3,path:"m1000 350l-187 188 0-125-250 0 0 250 125 0-188 187-187-187 125 0 0-250-250 0 0 125-188-188 186-187 0 125 252 0 0-250-125 0 187-188 188 188-125 0 0 250 250 0 0-126 187 188z",transform:"matrix(1 0 0 -1 0 850)"},zoom_plus:{width:875,height:1e3,path:"m1 787l0-875 875 0 0 875-875 0z m687-500l-187 0 0-187-125 0 0 187-188 0 0 125 188 0 0 187 125 0 0-187 187 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},zoom_minus:{width:875,height:1e3,path:"m0 788l0-876 875 0 0 876-875 0z m688-500l-500 0 0 125 500 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},autoscale:{width:1e3,height:1e3,path:"m250 850l-187 0-63 0 0-62 0-188 63 0 0 188 187 0 0 62z m688 0l-188 0 0-62 188 0 0-188 62 0 0 188 0 62-62 0z m-875-938l0 188-63 0 0-188 0-62 63 0 187 0 0 62-187 0z m875 188l0-188-188 0 0-62 188 0 62 0 0 62 0 188-62 0z m-125 188l-1 0-93-94-156 156 156 156 92-93 2 0 0 250-250 0 0-2 93-92-156-156-156 156 94 92 0 2-250 0 0-250 0 0 93 93 157-156-157-156-93 94 0 0 0-250 250 0 0 0-94 93 156 157 156-157-93-93 0 0 250 0 0 250z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_basic:{width:1500,height:1e3,path:"m375 725l0 0-375-375 375-374 0-1 1125 0 0 750-1125 0z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_compare:{width:1125,height:1e3,path:"m187 786l0 2-187-188 188-187 0 0 937 0 0 373-938 0z m0-499l0 1-187-188 188-188 0 0 937 0 0 376-938-1z",transform:"matrix(1 0 0 -1 0 850)"},plotlylogo:{width:1542,height:1e3,path:"m0-10h182v-140h-182v140z m228 146h183v-286h-183v286z m225 714h182v-1000h-182v1000z m225-285h182v-715h-182v715z m225 142h183v-857h-183v857z m231-428h182v-429h-182v429z m225-291h183v-138h-183v138z",transform:"matrix(1 0 0 -1 0 850)"},"z-axis":{width:1e3,height:1e3,path:"m833 5l-17 108v41l-130-65 130-66c0 0 0 38 0 39 0-1 36-14 39-25 4-15-6-22-16-30-15-12-39-16-56-20-90-22-187-23-279-23-261 0-341 34-353 59 3 60 228 110 228 110-140-8-351-35-351-116 0-120 293-142 474-142 155 0 477 22 477 142 0 50-74 79-163 96z m-374 94c-58-5-99-21-99-40 0-24 65-43 144-43 79 0 143 19 143 43 0 19-42 34-98 40v216h87l-132 135-133-135h88v-216z m167 515h-136v1c16 16 31 34 46 52l84 109v54h-230v-71h124v-1c-16-17-28-32-44-51l-89-114v-51h245v72z",transform:"matrix(1 0 0 -1 0 850)"},"3d_rotate":{width:1e3,height:1e3,path:"m922 660c-5 4-9 7-14 11-359 263-580-31-580-31l-102 28 58-400c0 1 1 1 2 2 118 108 351 249 351 249s-62 27-100 42c88 83 222 183 347 122 16-8 30-17 44-27-2 1-4 2-6 4z m36-329c0 0 64 229-88 296-62 27-124 14-175-11 157-78 225-208 249-266 8-19 11-31 11-31 2 5 6 15 11 32-5-13-8-20-8-20z m-775-239c70-31 117-50 198-32-121 80-199 346-199 346l-96-15-58-12c0 0 55-226 155-287z m603 133l-317-139c0 0 4-4 19-14 7-5 24-15 24-15s-177-147-389 4c235-287 536-112 536-112l31-22 100 299-4-1z m-298-153c6-4 14-9 24-15 0 0-17 10-24 15z",transform:"matrix(1 0 0 -1 0 850)"},camera:{width:1e3,height:1e3,path:"m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z m400 150h-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28l-31-94c-6-15-23-28-40-28h-120c-55 0-100-45-100-100v-450c0-55 45-100 100-100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250-250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35-35z",transform:"matrix(1 0 0 -1 0 850)"},movie:{width:1e3,height:1e3,path:"m938 413l-188-125c0 37-17 71-44 94 64 38 107 107 107 187 0 121-98 219-219 219-121 0-219-98-219-219 0-61 25-117 66-156h-115c30 33 49 76 49 125 0 103-84 187-187 187s-188-84-188-187c0-57 26-107 65-141-38-22-65-62-65-109v-250c0-70 56-126 125-126h500c69 0 125 56 125 126l188-126c34 0 62 28 62 63v375c0 35-28 63-62 63z m-750 0c-69 0-125 56-125 125s56 125 125 125 125-56 125-125-56-125-125-125z m406-1c-87 0-157 70-157 157 0 86 70 156 157 156s156-70 156-156-70-157-156-157z",transform:"matrix(1 0 0 -1 0 850)"},question:{width:857.1,height:1e3,path:"m500 82v107q0 8-5 13t-13 5h-107q-8 0-13-5t-5-13v-107q0-8 5-13t13-5h107q8 0 13 5t5 13z m143 375q0 49-31 91t-77 65-95 23q-136 0-207-119-9-14 4-24l74-55q4-4 10-4 9 0 14 7 30 38 48 51 19 14 48 14 27 0 48-15t21-33q0-21-11-34t-38-25q-35-16-65-48t-29-70v-20q0-8 5-13t13-5h107q8 0 13 5t5 13q0 10 12 27t30 28q18 10 28 16t25 19 25 27 16 34 7 45z m214-107q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z",transform:"matrix(1 0 0 -1 0 850)"},disk:{width:857.1,height:1e3,path:"m214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z",transform:"matrix(1 0 0 -1 0 850)"},lasso:{width:1031,height:1e3,path:"m1018 538c-36 207-290 336-568 286-277-48-473-256-436-463 10-57 36-108 76-151-13-66 11-137 68-183 34-28 75-41 114-42l-55-70 0 0c-2-1-3-2-4-3-10-14-8-34 5-45 14-11 34-8 45 4 1 1 2 3 2 5l0 0 113 140c16 11 31 24 45 40 4 3 6 7 8 11 48-3 100 0 151 9 278 48 473 255 436 462z m-624-379c-80 14-149 48-197 96 42 42 109 47 156 9 33-26 47-66 41-105z m-187-74c-19 16-33 37-39 60 50-32 109-55 174-68-42-25-95-24-135 8z m360 75c-34-7-69-9-102-8 8 62-16 128-68 170-73 59-175 54-244-5-9 20-16 40-20 61-28 159 121 317 333 354s407-60 434-217c28-159-121-318-333-355z",transform:"matrix(1 0 0 -1 0 850)"},selectbox:{width:1e3,height:1e3,path:"m0 850l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-285l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z",transform:"matrix(1 0 0 -1 0 850)"},spikeline:{width:1e3,height:1e3,path:"M512 409c0-57-46-104-103-104-57 0-104 47-104 104 0 57 47 103 104 103 57 0 103-46 103-103z m-327-39l92 0 0 92-92 0z m-185 0l92 0 0 92-92 0z m370-186l92 0 0 93-92 0z m0-184l92 0 0 92-92 0z",transform:"matrix(1.5 0 0 -1.5 0 850)"},newplotlylogo:{name:"newplotlylogo",svg:"plotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":274}],4:[function(t,e,r){"use strict";e.exports=t("../src/traces/box")},{"../src/traces/box":288}],5:[function(t,e,r){"use strict";e.exports=t("../src/traces/contour")},{"../src/traces/contour":308}],6:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":151}],7:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmap")},{"../src/traces/heatmap":324}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram")},{"../src/traces/histogram":342}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2d")},{"../src/traces/histogram2d":349}],10:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2dcontour")},{"../src/traces/histogram2dcontour":353}],11:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./box"),t("./heatmap"),t("./histogram"),t("./histogram2d"),t("./histogram2dcontour"),t("./pie"),t("./contour"),t("./scatterternary"),t("./violin")]),e.exports=n},{"./bar":3,"./box":4,"./contour":5,"./core":6,"./heatmap":7,"./histogram":8,"./histogram2d":9,"./histogram2dcontour":10,"./pie":12,"./scatterternary":13,"./violin":14}],12:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":360}],13:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterternary")},{"../src/traces/scatterternary":399}],14:[function(t,e,r){"use strict";e.exports=t("../src/traces/violin")},{"../src/traces/violin":407}],15:[function(t,e,r){var n=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},i=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var l,s=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),l=0===c.x}catch(t){l=!1}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,a){var i,o,l;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),l=o[e]):(o=t._events=n(null),t._eventsCount=0),l){if("function"==typeof l?l=o[e]=a?[r,l]:[l,r]:a?l.unshift(r):l.push(r),!l.warned&&(i=u(t))&&i>0&&l.length>i){l.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+l.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=l.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else l=o[e]=r,++t._eventsCount;return t}function d(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var s=new Error('Unhandled "error" event. ('+e+")");throw s.context=e,s}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,a=v(t,n),i=0;i=0;o--)if(r[o]===e||r[o].listener===e){l=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(var r=e,n=r+1,a=t.length;n=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],16:[function(t,e,r){!function(){var t={version:"3.5.17"},r=[].slice,n=function(t){return r.call(t)},a=this.document;function i(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(a)try{n(a.documentElement.childNodes)[0].nodeType}catch(t){n=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),a)try{a.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var l=this.Element.prototype,s=l.setAttribute,c=l.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;l.setAttribute=function(t,e){s.call(this,t,e+"")},l.setAttributeNS=function(t,e,r){c.call(this,t,e,r+"")},u.setProperty=function(t,e,r){f.call(this,t,e+"",r)}}function d(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function h(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)<0?n=i+1:a=i}return n},right:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)>0?a=i:n=i+1}return n}}}t.ascending=d,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++an&&(r=n)}else{for(;++a=n){r=n;break}for(;++an&&(r=n)}return r},t.max=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++ar&&(r=n)}else{for(;++a=n){r=n;break}for(;++ar&&(r=n)}return r},t.extent=function(t,e){var r,n,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=n){r=a=n;break}for(;++in&&(r=n),a=n){r=a=n;break}for(;++in&&(r=n),a1)return o/(s-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(d);function y(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return d(t(e),r)}:t)},t.shuffle=function(t,e,r){(i=arguments.length)<3&&(r=t.length,i<2&&(e=0));for(var n,a,i=r-e;i;)a=Math.random()*i--|0,n=t[i+e],t[i+e]=t[a+e],t[a+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],a=new Array(r<0?0:r);e=0;)for(e=(n=t[a]).length;--e>=0;)r[--o]=n[e];return r};var m=Math.abs;function x(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(m(r)),o=-1;if(t*=i,e*=i,(r*=i)<0)for(;(n=t+r*++o)>e;)a.push(n/i);else for(;(n=t+r*++o)=a.length)return r?r.call(n,i):e?i.sort(e):i;for(var s,c,u,f,d=-1,p=i.length,h=a[l++],g=new b;++d=a.length)return e;var n=[],o=i[r++];return e.forEach(function(e,a){n.push({key:e,values:t(a,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return a.push(t),n},n.sortKeys=function(t){return i[a.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new O;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function V(t){return q(t,X),t}var U=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},Z=function(t,e){var r=t.matches||t[P(t,"matchesSelector")];return(Z=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(U=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,Z=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var X=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return U(t,this)}}function W(t){return"function"==typeof t?t:function(){return G(t,this)}}X.select=function(t){var e,r,n,a,i=[];t=Y(t);for(var o=-1,l=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),$.hasOwnProperty(r)?{space:$[r],local:t}:t}},X.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each(Q(r,e[r]));return this}return this.each(Q(e,r))},X.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,a=-1;if(e=r.classList){for(;++a=0;)(r=n[a])&&(i&&i!==r.nextSibling&&i.parentNode.insertBefore(r,i),i=r);return this},X.sort=function(t){t=function(t){arguments.length||(t=d);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var s=ht.get(e);function c(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return s&&(e=s,l=vt),o?r?function(){var t=l(r,n(arguments));c.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=r}:c:r?R:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(r=a.match(n)){var i=this[a];this.removeEventListener(r[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=dt,dt.append=X.append,dt.empty=X.empty,dt.node=X.node,dt.call=X.call,dt.size=X.size,dt.select=function(t){for(var e,r,n,a,i,o=[],l=-1,s=this.length;++l=n&&(n=e+1);!(o=l[n])&&++n0?1:t<0?-1:0}function Dt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function Pt(t){return t>1?0:t<-1?Mt:Math.acos(t)}function Et(t){return t>1?St:t<-1?-St:Math.asin(t)}function Rt(t){return((t=Math.exp(t))+1/t)/2}function It(t){return(t=Math.sin(t/2))*t}var Nt=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,a=t[0],i=t[1],o=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-i,d=u*u+f*f;if(d0&&(e=e.transition().duration(g)),e.call(w.event)}function L(){c&&c.domain(s.range().map(function(t){return(t-d.x)/d.k}).map(s.invert)),f&&f.domain(u.range().map(function(t){return(t-d.y)/d.k}).map(u.invert))}function S(t){v++||t({type:"zoomstart"})}function C(t){L(),t({type:"zoom",scale:d.k,translate:[d.x,d.y]})}function O(t){--v||(t({type:"zoomend"}),r=null)}function z(){var e=this,r=_.of(e,arguments),n=0,a=t.select(o(e)).on(m,function(){n=1,M(t.mouse(e),i),C(r)}).on(x,function(){a.on(m,null).on(x,null),l(n),O(r)}),i=k(t.mouse(e)),l=xt(e);fl.call(e),S(r)}function D(){var e,r=this,n=_.of(r,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+o,c="touchend"+o,u=[],f=t.select(r),p=xt(r);function h(){var n=t.touches(r);return e=d.k,n.forEach(function(t){t.identifier in a&&(a[t.identifier]=k(t))}),n}function g(){var e=t.event.target;t.select(e).on(s,v).on(c,m),u.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){y=p[0];var x=p[1],b=y[0]-x[0],_=y[1]-x[1];i=b*b+_*_}}function v(){var o,s,c,u,f=t.touches(r);fl.call(r);for(var d=0,p=f.length;d360?t-=360:t<0&&(t+=360),t<60?n+(a-n)*t/60:t<180?a:t<240?n+(a-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(a=r<=.5?r*(1+e):r+e-r*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Yt?e.l:(e=de((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Ut(this.h,this.s,this.l)},t.hcl=Gt;var Zt=Gt.prototype=new Ht;function Xt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Yt(r,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Yt(t,e,r){return this instanceof Yt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Yt?new Yt(t.l,t.a,t.b):t instanceof Gt?Xt(t.h,t.c,t.l):de((t=ie(t)).r,t.g,t.b):new Yt(t,e,r)}Zt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Wt*(arguments.length?t:1)))},Zt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Wt*(arguments.length?t:1)))},Zt.rgb=function(){return Xt(this.h,this.c,this.l).rgb()},t.lab=Yt;var Wt=18,Jt=.95047,$t=1,Qt=1.08883,Kt=Yt.prototype=new Ht;function te(t,e,r){var n=(t+16)/116,a=n+e/500,i=n-r/200;return new ie(ae(3.2404542*(a=re(a)*Jt)-1.5371385*(n=re(n)*$t)-.4985314*(i=re(i)*Qt)),ae(-.969266*a+1.8760108*n+.041556*i),ae(.0556434*a-.2040259*n+1.0572252*i))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Ot,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,r){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ue(""+t,ie,Ut):new ie(t,e,r)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function le(t){return oe(t)+""}Kt.brighter=function(t){return new Yt(Math.min(100,this.l+Wt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Yt(Math.max(0,this.l-Wt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var se=ie.prototype=new Ht;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,r){var n,a,i,o=0,l=0,s=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=n[2].split(","),n[1]){case"hsl":return r(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(he(a[0]),he(a[1]),he(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,l=240&i,l|=l>>4,s=15&i,s|=s<<4):7===t.length&&(o=(16711680&i)>>16,l=(65280&i)>>8,s=255&i)),e(o,l,s))}function fe(t,e,r){var n,a,i=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),l=o-i,s=(o+i)/2;return l?(a=s<.5?l/(o+i):l/(2-o-i),n=t==o?(e-r)/l+(e0&&s<1?0:n),new qt(n,a,s)}function de(t,e,r){var n=ne((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(r=pe(r)))/Jt),a=ne((.2126729*t+.7151522*e+.072175*r)/$t);return Yt(116*a-16,500*(n-a),200*(a-ne((.0193339*t+.119192*e+.9503041*r)/Qt)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function he(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}se.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,a=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=a.call(o,c)}catch(t){return void l.error.call(o,t)}l.load.call(o,t)}else l.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var r=t.event;t.event=e;try{l.progress.call(o,c)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,a){if(2===arguments.length&&"function"==typeof n&&(a=n,n=null),c.open(t,e,!0),null==r||"accept"in s||(s.accept=r+",*/*"),c.setRequestHeader)for(var i in s)c.setRequestHeader(i,s[i]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=u&&(c.responseType=u),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),l.beforesend.call(o,c),c.send(null==n?null:n),o},o.abort=function(){return c.abort(),o},t.rebind(o,l,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=ye(z),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function a(t,r,n){arguments.length<3&&(n=r,r=null);var a=me(t,e,null==r?i:o(r),n);return a.row=function(t){return arguments.length?a.response(null==(r=t)?i:o(t)):r},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function l(e){return e.map(s).join(t)}function s(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var r;return a.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(a(t),r)}:a})},a.parseRows=function(t,e){var r,a,i={},o={},l=[],s=t.length,c=0,u=0;function f(){if(c>=s)return o;if(a)return a=!1,i;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Me,e)),_e=0):(_e=1,ke(Me))}function Ae(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Le(){for(var t,e=xe,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Se(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Ce[8+n/3]};var Oe=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ze=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Se(e,r))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),r))))}});function De(t){return t+""}var Pe=t.time={},Ee=Date;function Re(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Re.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ie.setUTCDate.apply(this._,arguments)},setDay:function(){Ie.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ie.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ie.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ie.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ie.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ie.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ie.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ie.setTime.apply(this._,arguments)}};var Ie=Date.prototype;function Ne(t,e,r){function n(e){var r=t(e),n=i(r,1);return e-r1)for(;o68?1900:2e3),r+a[0].length):-1}function Je(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function $e(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function Qe(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ar(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=m(e)/60|0,a=m(e)%60;return r+qe(n,"0",2)+qe(a,"0",2)}function ir(t,e,r){He.lastIndex=0;var n=He.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),i.push(t.substring(r-=l,r+l)),!((s+=l+1)>e));)l=a[o=(o+1)%a.length];return i.reverse().join(n)}:z;return function(e){var n=Oe.exec(e),a=n[1]||" ",l=n[2]||">",s=n[3]||"-",c=n[4]||"",u=n[5],f=+n[6],d=n[7],p=n[8],h=n[9],g=1,v="",y="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===a&&"="===l)&&(u=a="0",l="="),h){case"n":d=!0,h="g";break;case"%":g=100,y="%",h="f";break;case"p":g=100,y="%",h="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+h.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":g=-1,h="r"}"$"===c&&(v=i[0],y=i[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):"e"!=h&&"f"!=h||(p=Math.max(0,Math.min(20,p)))),h=ze.get(h)||De;var b=u&&d;return function(e){var n=y;if(m&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===s?"":s;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),n=c.symbol+y}else e*=g;var _,w,k=(e=h(e,p)).lastIndexOf(".");if(k<0){var T=x?e.lastIndexOf("e"):-1;T<0?(_=e,w=""):(_=e.substring(0,T),w=e.substring(T))}else _=e.substring(0,k),w=r+e.substring(k+1);!u&&d&&(_=o(_,1/0));var M=v.length+_.length+w.length+(b?0:i.length),A=M"===l?A+i+e:"^"===l?A.substring(0,M>>=1)+i+e+A.substring(M):i+(b?e:A+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,a=e.time,i=e.periods,o=e.days,l=e.shortDays,s=e.months,c=e.shortMonths;function u(t){var e=t.length;function r(r){for(var n,a,i,o=[],l=-1,s=0;++l=c)return-1;if(37===(a=e.charCodeAt(l++))){if(o=e.charAt(l++),!(i=w[o in Be?e.charAt(l++):o])||(n=i(t,r,n))<0)return-1}else if(a!=r.charCodeAt(n++))return-1}return n}u.utc=function(t){var e=u(t);function r(t){try{var r=new(Ee=Re);return r._=t,e(r)}finally{Ee=Date}}return r.parse=function(t){try{Ee=Re;var r=e.parse(t);return r&&r._}finally{Ee=Date}},r.toString=e.toString,r},u.multi=u.utc.multi=or;var d=t.map(),p=Ve(o),h=Ue(o),g=Ve(l),v=Ue(l),y=Ve(s),m=Ue(s),x=Ve(c),b=Ue(c);i.forEach(function(t,e){d.set(t.toLowerCase(),e)});var _={a:function(t){return l[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:u(r),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+Pe.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(Pe.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(Pe.mondayOfYear(t),e,2)},x:u(n),X:u(a),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:ar,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=h.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){y.lastIndex=0;var n=y.exec(e.slice(r));return n?(t.m=m.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:Qe,e:Qe,H:tr,I:tr,j:Ke,L:nr,m:$e,M:er,p:function(t,e,r){var n=d.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:Ze,w:Ge,W:Xe,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:We,Y:Ye,Z:Je,"%":ir};return u}(e)}};var lr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function sr(){}t.format=lr.numberFormat,t.geo={},sr.prototype={s:0,t:0,add:function(t){ur(t,this.t,cr),ur(cr.s,this.s,this),this.s?this.t+=cr.t:this.s=cr.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cr=new sr;function ur(t,e,r){var n=r.s=t+e,a=n-t,i=n-a;r.t=t-i+(e-a)}function fr(t,e){t&&pr.hasOwnProperty(t.type)&&pr[t.type](t,e)}t.geo.stream=function(t,e){t&&dr.hasOwnProperty(t.type)?dr[t.type](t,e):fr(t,e)};var dr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,a=r.length;++n=0?1:-1,l=o*i,s=Math.cos(e),c=Math.sin(e),u=a*c,f=n*s+u*Math.cos(l),d=u*o*Math.sin(l);Sr.add(Math.atan2(d,f)),r=t,n=s,a=c}Cr.point=function(o,l){Cr.point=i,r=(t=o)*Ct,n=Math.cos(l=(e=l)*Ct/2+Mt/4),a=Math.sin(l)},Cr.lineEnd=function(){i(t,e)}}function zr(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Dr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Pr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Er(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Rr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Ir(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Nr(t){return[Math.atan2(t[1],t[0]),Et(t[2])]}function Fr(t,e){return m(t[0]-e[0])kt?a=90:c<-kt&&(r=-90),f[0]=e,f[1]=n}};function p(t,i){u.push(f=[e=t,n=t]),ia&&(a=i)}function h(t,o){var l=zr([t*Ct,o*Ct]);if(s){var c=Pr(s,l),u=Pr([c[1],-c[0],0],c);Ir(u),u=Nr(u);var f=t-i,d=f>0?1:-1,h=u[0]*Ot*d,g=m(f)>180;if(g^(d*ia&&(a=v);else if(g^(d*i<(h=(h+360)%360-180)&&ha&&(a=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>i?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else p(t,o);s=l,i=t}function g(){d.point=h}function v(){f[0]=e,f[1]=n,d.point=p,s=null}function y(t,e){if(s){var r=t-i;c+=m(r)>180?r+(r>0?360:-360):r}else o=t,l=e;Cr.point(t,e),h(t,e)}function x(){Cr.lineStart()}function b(){y(o,l),Cr.lineEnd(),m(c)>kt&&(e=-(n=180)),f[0]=e,f[1]=n,s=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):l.push(g=p);for(var s,c,p,h=-1/0,g=(o=0,l[c=l.length-1]);o<=c;g=p,++o)p=l[o],(s=_(g[1],p[0]))>h&&(h=s,e=p[0],n=g[1])}return u=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,a]]}}(),t.geo.centroid=function(e){yr=mr=xr=br=_r=wr=kr=Tr=Mr=Ar=Lr=0,t.geo.stream(e,Br);var r=Mr,n=Ar,a=Lr,i=r*r+n*n+a*a;return i=0;--l)a.point((f=u[l])[0],f[1]);else n(p.x,p.p.x,-1,a);p=p.p}u=(p=p.o).z,h=!h}while(!p.v);a.lineEnd()}}}function Yr(t){if(e=t.length){for(var e,r,n=0,a=t[0];++n=0?1:-1,k=w*_,T=k>Mt,M=h*x;if(Sr.add(Math.atan2(M*w*Math.sin(k),g*b+M*Math.cos(k))),i+=T?_+w*At:_,T^d>=r^y>=r){var A=Pr(zr(f),zr(t));Ir(A);var L=Pr(a,A);Ir(L);var S=(T^_>=0?-1:1)*Et(L[2]);(n>S||n===S&&(A[0]||A[1]))&&(o+=T^_>=0?1:-1)}if(!v++)break;d=y,h=x,g=b,f=t}}return(i<-kt||i0){for(x||(o.polygonStart(),x=!0),o.lineStart();++i1&&2&e&&r.push(r.pop().concat(r.shift())),l.push(r.filter($r))}return u}}function $r(t){return t.length>1}function Qr(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:R,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-St-kt:St-t[1])-((e=e.x)[0]<0?e[1]-St-kt:St-e[1])}var tn=Jr(Zr,function(t){var e,r=NaN,n=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var l=i>0?Mt:-Mt,s=m(i-r);m(s-Mt)0?St:-St),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),t.point(i,n),e=0):a!==l&&s>=Mt&&(m(r-a)kt?Math.atan((Math.sin(e)*(i=Math.cos(n))*Math.sin(r)-Math.sin(n)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+n)/2}(r,n,i,o),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),e=0),t.point(r=i,n=o),a=l},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var a;if(null==t)a=r*St,n.point(-Mt,a),n.point(0,a),n.point(Mt,a),n.point(Mt,0),n.point(Mt,-a),n.point(0,-a),n.point(-Mt,-a),n.point(-Mt,0),n.point(-Mt,a);else if(m(t[0]-e[0])>kt){var i=t[0]0)){if(i/=d,d<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=r-s,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>u&&(u=i)}else if(d>0){if(i0)){if(i/=p,p<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=n-c,p||!(i<0)){if(i/=p,p<0){if(i>f)return;i>u&&(u=i)}else if(p>0){if(i0&&(a.a={x:s+u*d,y:c+u*p}),f<1&&(a.b={x:s+f*d,y:c+f*p}),a}}}}}}var rn=1e9;function nn(e,r,n,a){return function(s){var c,u,f,d,p,h,g,v,y,m,x,b=s,_=Qr(),w=en(e,r,n,a),k={point:A,lineStart:function(){k.point=L,u&&u.push(f=[]);m=!0,y=!1,g=v=NaN},lineEnd:function(){c&&(L(d,p),h&&y&&_.rejoin(),c.push(_.buffer()));k.point=A,y&&s.lineEnd()},polygonStart:function(){s=_,c=[],u=[],x=!0},polygonEnd:function(){s=b,c=t.merge(c);var r=function(t){for(var e=0,r=u.length,n=t[1],a=0;an&&Dt(c,i,t)>0&&++e:i[1]<=n&&Dt(c,i,t)<0&&--e,c=i;return 0!==e}([e,a]),n=x&&r,i=c.length;(n||i)&&(s.polygonStart(),n&&(s.lineStart(),T(null,null,1,s),s.lineEnd()),i&&Xr(c,o,r,T,s),s.polygonEnd()),c=u=f=null}};function T(t,o,s,c){var u=0,f=0;if(null==t||(u=i(t,s))!==(f=i(o,s))||l(t,o)<0^s>0)do{c.point(0===u||3===u?e:n,u>1?a:r)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function M(t,i){return e<=t&&t<=n&&r<=i&&i<=a}function A(t,e){M(t,e)&&s.point(t,e)}function L(t,e){var r=M(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(u&&f.push([t,e]),m)d=t,p=e,h=r,m=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&y)s.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(y||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),x=!1):r&&(s.lineStart(),s.point(t,e),x=!1)}g=t,v=e,y=r}return k};function i(t,a){return m(t[0]-e)0?0:3:m(t[0]-n)0?2:1:m(t[1]-r)0?1:0:a>0?3:2}function o(t,e){return l(t.x,e.x)}function l(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Mt/3,n=Cn(t),a=n(e,r);return a.parallels=function(t){return arguments.length?n(e=t[0]*Mt/180,r=t[1]*Mt/180):[e/Mt*180,r/Mt*180]},a}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,a=1+r*(2*n-r),i=Math.sqrt(a)/n;function o(t,e){var r=Math.sqrt(a-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),i-r*Math.cos(t)]}return o.invert=function(t,e){var r=i-e;return[Math.atan2(t,r)/n,Et((a-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(l){return arguments.length?(i=nn(t=+l[0][0],e=+l[0][1],r=+l[1][0],n=+l[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,r){e=[t,r]}};function c(t){var i=t[0],o=t[1];return e=null,r(i,o),e||(n(i,o),e)||a(i,o),e}return c.invert=function(t){var e=i.scale(),r=i.translate(),n=(t[0]-r[0])/e,a=(t[1]-r[1])/e;return(a>=.12&&a<.234&&n>=-.425&&n<-.214?o:a>=.166&&a<.234&&n>=-.214&&n<-.115?l:i).invert(t)},c.stream=function(t){var e=i.stream(t),r=o.stream(t),n=l.stream(t);return{point:function(t,a){e.point(t,a),r.point(t,a),n.point(t,a)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),l.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),l.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),u=+t[0],f=+t[1];return r=i.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(s).point,n=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(s).point,a=l.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(s).point,c},c.scale(1070)};var ln,sn,cn,un,fn,dn,pn={point:R,lineStart:R,lineEnd:R,polygonStart:function(){sn=0,pn.lineStart=hn},polygonEnd:function(){pn.lineStart=pn.lineEnd=pn.point=R,ln+=m(sn/2)}};function hn(){var t,e,r,n;function a(t,e){sn+=n*t-r*e,r=t,n=e}pn.point=function(i,o){pn.point=a,t=r=i,e=n=o},pn.lineEnd=function(){a(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);edn&&(dn=e)},lineStart:R,lineEnd:R,polygonStart:R,polygonEnd:R};function vn(){var t=yn(4.5),e=[],r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=yn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function a(t,n){e.push("M",t,",",n),r.point=i}function i(t,r){e.push("L",t,",",r)}function o(){r.point=n}function l(){e.push("Z")}return r}function yn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var mn,xn={point:bn,lineStart:_n,lineEnd:wn,polygonStart:function(){xn.lineStart=kn},polygonEnd:function(){xn.point=bn,xn.lineStart=_n,xn.lineEnd=wn}};function bn(t,e){xr+=t,br+=e,++_r}function _n(){var t,e;function r(r,n){var a=r-t,i=n-e,o=Math.sqrt(a*a+i*i);wr+=o*(t+r)/2,kr+=o*(e+n)/2,Tr+=o,bn(t=r,e=n)}xn.point=function(n,a){xn.point=r,bn(t=n,e=a)}}function wn(){xn.point=bn}function kn(){var t,e,r,n;function a(t,e){var a=t-r,i=e-n,o=Math.sqrt(a*a+i*i);wr+=o*(r+t)/2,kr+=o*(n+e)/2,Tr+=o,Mr+=(o=n*t-r*e)*(r+t),Ar+=o*(n+e),Lr+=3*o,bn(r=t,n=e)}xn.point=function(i,o){xn.point=a,bn(t=r=i,e=n=o)},xn.lineEnd=function(){a(t,e)}}function Tn(t){var e=4.5,r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:R};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,At)}function a(e,n){t.moveTo(e,n),r.point=i}function i(e,r){t.lineTo(e,r)}function o(){r.point=n}function l(){t.closePath()}return r}function Mn(t){var e=.5,r=Math.cos(30*Ct),n=16;function a(e){return(n?function(e){var r,a,o,l,s,c,u,f,d,p,h,g,v={point:y,lineStart:m,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=m}};function y(r,n){r=t(r,n),e.point(r[0],r[1])}function m(){f=NaN,v.point=x,e.lineStart()}function x(r,a){var o=zr([r,a]),l=t(r,a);i(f,d,u,p,h,g,f=l[0],d=l[1],u=r,p=o[0],h=o[1],g=o[2],n,e),e.point(f,d)}function b(){v.point=y,e.lineEnd()}function _(){m(),v.point=w,v.lineEnd=k}function w(t,e){x(r=t,e),a=f,o=d,l=p,s=h,c=g,v.point=x}function k(){i(f,d,u,p,h,g,a,o,r,l,s,c,n,e),v.lineEnd=b,b()}return v}:function(e){return Ln(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function i(n,a,o,l,s,c,u,f,d,p,h,g,v,y){var x=u-n,b=f-a,_=x*x+b*b;if(_>4*e&&v--){var w=l+p,k=s+h,T=c+g,M=Math.sqrt(w*w+k*k+T*T),A=Math.asin(T/=M),L=m(m(T)-1)e||m((x*z+b*D)/_-.5)>.3||l*p+s*h+c*g0&&16,a):Math.sqrt(e)},a}function An(t){this.stream=t}function Ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sn(t){return Cn(function(){return t})()}function Cn(e){var r,n,a,i,o,l,s=Mn(function(t,e){return[(t=r(t,e))[0]*c+i,o-t[1]*c]}),c=150,u=480,f=250,d=0,p=0,h=0,g=0,v=0,y=tn,x=z,b=null,_=null;function w(t){return[(t=a(t[0]*Ct,t[1]*Ct))[0]*c+i,o-t[1]*c]}function k(t){return(t=a.invert((t[0]-i)/c,(o-t[1])/c))&&[t[0]*Ot,t[1]*Ot]}function T(){a=Gr(n=Pn(h,g,v),r);var t=r(d,p);return i=u-t[0]*c,o=f+t[1]*c,M()}function M(){return l&&(l.valid=!1,l=null),w}return w.stream=function(t){return l&&(l.valid=!1),(l=On(y(n,s(x(t))))).valid=!0,l},w.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,tn):function(t){var e=Math.cos(t),r=e>0,n=m(e)>kt;return Jr(a,function(t){var e,l,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var p,h=[f,d],g=a(f,d),v=r?g?0:o(f,d):g?o(f+(f<0?Mt:-Mt),d):0;if(!e&&(c=s=g)&&t.lineStart(),g!==s&&(p=i(e,h),(Fr(e,p)||Fr(h,p))&&(h[0]+=kt,h[1]+=kt,g=a(h[0],h[1]))),g!==s)u=0,g?(t.lineStart(),p=i(h,e),t.point(p[0],p[1])):(p=i(e,h),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(n&&e&&r^g){var y;v&l||!(y=i(h,e,!0))||(u=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!g||e&&Fr(e,h)||t.point(h[0],h[1]),e=h,s=g,l=v},lineEnd:function(){s&&t.lineEnd(),e=null},clean:function(){return u|(c&&s)<<1}}},Nn(t,6*Ct),r?[0,-t]:[-Mt,t-Mt]);function a(t,r){return Math.cos(t)*Math.cos(r)>e}function i(t,r,n){var a=[1,0,0],i=Pr(zr(t),zr(r)),o=Dr(i,i),l=i[0],s=o-l*l;if(!s)return!n&&t;var c=e*o/s,u=-e*l/s,f=Pr(a,i),d=Rr(a,c);Er(d,Rr(i,u));var p=f,h=Dr(d,p),g=Dr(p,p),v=h*h-g*(Dr(d,d)-1);if(!(v<0)){var y=Math.sqrt(v),x=Rr(p,(-h-y)/g);if(Er(x,d),x=Nr(x),!n)return x;var b,_=t[0],w=r[0],k=t[1],T=r[1];w<_&&(b=_,_=w,w=b);var M=w-_,A=m(M-Mt)0^x[1]<(m(x[0]-_)Mt^(_<=x[0]&&x[0]<=w)){var L=Rr(p,(-h+y)/g);return Er(L,d),[x,Nr(L)]}}}function o(e,n){var a=r?t:Mt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),n<-a?i|=4:n>a&&(i|=8),i}}((b=+t)*Ct),M()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):z,M()):_},w.scale=function(t){return arguments.length?(c=+t,T()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],T()):[u,f]},w.center=function(t){return arguments.length?(d=t[0]%360*Ct,p=t[1]%360*Ct,T()):[d*Ot,p*Ot]},w.rotate=function(t){return arguments.length?(h=t[0]%360*Ct,g=t[1]%360*Ct,v=t.length>2?t[2]%360*Ct:0,T()):[h*Ot,g*Ot,v*Ot]},t.rebind(w,s,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&k,T()}}function On(t){return Ln(t,function(e,r){t.point(e*Ct,r*Ct)})}function zn(t,e){return[t,e]}function Dn(t,e){return[t>Mt?t-At:t<-Mt?t+At:t,e]}function Pn(t,e,r){return t?e||r?Gr(Rn(t),In(e,r)):Rn(t):e||r?In(e,r):Dn}function En(t){return function(e,r){return[(e+=t)>Mt?e-At:e<-Mt?e+At:e,r]}}function Rn(t){var e=En(t);return e.invert=En(-t),e}function In(t,e){var r=Math.cos(t),n=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*r+l*n;return[Math.atan2(s*a-u*i,l*r-c*n),Et(u*a+s*i)]}return o.invert=function(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*a-s*i;return[Math.atan2(s*a+c*i,l*r+u*n),Et(u*r-l*n)]},o}function Nn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(a,i,o,l){var s=o*e;null!=a?(a=Fn(r,a),i=Fn(r,i),(o>0?ai)&&(a+=o*At)):(a=t+o*At,i=t-.5*s);for(var c,u=a;o>0?u>i:u2?t[2]*Ct:0),e.invert=function(e){return(e=t.invert(e[0]*Ct,e[1]*Ct))[0]*=Ot,e[1]*=Ot,e},e},Dn.invert=zn,t.geo.circle=function(){var t,e,r=[0,0],n=6;function a(){var t="function"==typeof r?r.apply(this,arguments):r,n=Pn(-t[0]*Ct,-t[1]*Ct,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=n(t,e)),t[0]*=Ot,t[1]*=Ot}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(r=t,a):r},a.angle=function(r){return arguments.length?(e=Nn((t=+r)*Ct,n*Ct),a):t},a.precision=function(r){return arguments.length?(e=Nn(t*Ct,(n=+r)*Ct),a):n},a.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Ct,a=t[1]*Ct,i=e[1]*Ct,o=Math.sin(n),l=Math.cos(n),s=Math.sin(a),c=Math.cos(a),u=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-s*f*l)*r),s*u+c*f*l)},t.geo.graticule=function(){var e,r,n,a,i,o,l,s,c,u,f,d,p=10,h=p,g=90,v=360,y=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(a/g)*g,n,g).map(f).concat(t.range(Math.ceil(s/v)*v,l,v).map(d)).concat(t.range(Math.ceil(r/p)*p,e,p).filter(function(t){return m(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/h)*h,i,h).filter(function(t){return m(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(d(l).slice(1),f(n).reverse().slice(1),d(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(a=+t[0][0],n=+t[1][0],s=+t[0][1],l=+t[1][1],a>n&&(t=a,a=n,n=t),s>l&&(t=s,s=l,l=t),x.precision(y)):[[a,s],[n,l]]},x.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),o>i&&(t=o,o=i,i=t),x.precision(y)):[[r,o],[e,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],h=+t[1],x):[p,h]},x.precision=function(t){return arguments.length?(y=+t,c=Bn(o,i,90),u=jn(r,e,y),f=Bn(s,l,90),d=jn(a,n,y),x):y},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,r,n=Hn,a=qn;function i(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||a.apply(this,arguments))},i.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,i):n},i.target=function(t){return arguments.length?(a=t,r="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return r=t[0]*Ct,n=t[1]*Ct,a=e[0]*Ct,i=e[1]*Ct,o=Math.cos(n),l=Math.sin(n),s=Math.cos(i),c=Math.sin(i),u=o*Math.cos(r),f=o*Math.sin(r),d=s*Math.cos(a),p=s*Math.sin(a),h=2*Math.asin(Math.sqrt(It(i-n)+o*s*It(a-r))),g=1/Math.sin(h),(v=h?function(t){var e=Math.sin(t*=h)*g,r=Math.sin(h-t)*g,n=r*u+e*d,a=r*f+e*p,i=r*l+e*c;return[Math.atan2(a,n)*Ot,Math.atan2(i,Math.sqrt(n*n+a*a))*Ot]}:function(){return[r*Ot,n*Ot]}).distance=h,v;var r,n,a,i,o,l,s,c,u,f,d,p,h,g,v},t.geo.length=function(e){return mn=0,t.geo.stream(e,Vn),mn};var Vn={sphere:R,point:R,lineStart:function(){var t,e,r;function n(n,a){var i=Math.sin(a*=Ct),o=Math.cos(a),l=m((n*=Ct)-t),s=Math.cos(l);mn+=Math.atan2(Math.sqrt((l=o*Math.sin(l))*l+(l=r*i-e*o*s)*l),e*i+r*o*s),t=n,e=i,r=o}Vn.point=function(a,i){t=a*Ct,e=Math.sin(i*=Ct),r=Math.cos(i),Vn.point=n},Vn.lineEnd=function(){Vn.point=Vn.lineEnd=R}},lineEnd:R,polygonStart:R,polygonEnd:R};function Un(t,e){function r(e,r){var n=Math.cos(e),a=Math.cos(r),i=t(n*a);return[i*a*Math.sin(e),i*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),a=e(n),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,n*o),Math.asin(n&&r*i/n)]},r}var Gn=Un(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sn(Gn)}).raw=Gn;var Zn=Un(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},z);function Xn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Mt/4+t/2)},a=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),i=r*Math.pow(n(t),a)/a;if(!a)return Jn;function o(t,e){i>0?e<-St+kt&&(e=-St+kt):e>St-kt&&(e=St-kt);var r=i/Math.pow(n(e),a);return[r*Math.sin(a*t),i-r*Math.cos(a*t)]}return o.invert=function(t,e){var r=i-e,n=zt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(i/n,1/a))-St]},o}function Yn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),a=r/n+t;if(m(n)1&&Dt(t[r[n-2]],t[r[n-1]],t[a])<=0;)--n;r[n++]=a}return r.slice(0,n)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sn(Kn)}).raw=Kn,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=$n(ta),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,r=ra;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,a=ve(e),i=ve(r),o=t.length,l=[],s=[];for(n=0;n=0;--n)p.push(t[l[c[n]][2]]);for(n=+f;nkt)l=l.L;else{if(!((a=i-wa(l,o))>kt)){n>-kt?(e=l.P,r=l):a>-kt?(e=l,r=l.N):e=r=l;break}if(!l.R){e=l;break}l=l.R}var s=ya(t);if(fa.insert(e,s),e||r){if(e===r)return La(e),r=ya(e.site),fa.insert(s,r),s.edge=r.edge=Oa(e.site,s.site),Aa(e),void Aa(r);if(r){La(e),La(r);var c=e.site,u=c.x,f=c.y,d=t.x-u,p=t.y-f,h=r.site,g=h.x-u,v=h.y-f,y=2*(d*v-p*g),m=d*d+p*p,x=g*g+v*v,b={x:(v*m-p*x)/y+u,y:(d*x-g*m)/y+f};za(r.edge,c,h,b),s.edge=Oa(c,t,null,b),r.edge=Oa(t,h,null,b),Aa(e),Aa(r)}else s.edge=Oa(e.site,s.site)}}function _a(t,e){var r=t.site,n=r.x,a=r.y,i=a-e;if(!i)return n;var o=t.P;if(!o)return-1/0;var l=(r=o.site).x,s=r.y,c=s-e;if(!c)return l;var u=l-n,f=1/i-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-i/2)))/f+n:(n+l)/2}function wa(t,e){var r=t.N;if(r)return _a(r,e);var n=t.site;return n.y===e?n.x:1/0}function ka(t){this.site=t,this.edges=[]}function Ta(t,e){return e.angle-t.angle}function Ma(){Ea(this),this.x=this.y=this.arc=this.site=this.cy=null}function Aa(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,a=t.site,i=r.site;if(n!==i){var o=a.x,l=a.y,s=n.x-o,c=n.y-l,u=i.x-o,f=2*(s*(v=i.y-l)-c*u);if(!(f>=-Tt)){var d=s*s+c*c,p=u*u+v*v,h=(v*d-c*p)/f,g=(s*p-u*d)/f,v=g+l,y=ga.pop()||new Ma;y.arc=t,y.site=a,y.x=h+o,y.y=v+Math.sqrt(h*h+g*g),y.cy=v,t.circle=y;for(var m=null,x=pa._;x;)if(y.y=l)return;if(d>h){if(i){if(i.y>=c)return}else i={x:v,y:s};r={x:v,y:c}}else{if(i){if(i.y1)if(d>h){if(i){if(i.y>=c)return}else i={x:(s-a)/n,y:s};r={x:(c-a)/n,y:c}}else{if(i){if(i.y=l)return}else i={x:o,y:n*o+a};r={x:l,y:n*l+a}}else{if(i){if(i.xkt||m(a-r)>kt)&&(l.splice(o,0,new Da((y=i.site,x=u,b=m(n-f)kt?{x:f,y:m(e-f)kt?{x:m(r-h)kt?{x:d,y:m(e-d)kt?{x:m(r-p)=r&&c.x<=a&&c.y>=n&&c.y<=o?[[r,o],[a,o],[a,n],[r,n]]:[]).point=t[l]}),e}function l(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/kt)*kt,y:Math.round(a(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Fa(l(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fa(l(t)).cells.forEach(function(r,n){for(var a,i,o,l,s=r.site,c=r.edges.sort(Ta),u=-1,f=c.length,d=c[f-1].edge,p=d.l===s?d.r:d.l;++ui&&(a=e.slice(i,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(n=n[0])?l[o]?l[o]+=n:l[++o]=n:(l[++o]=null,s.push({i:o,x:Ga(r,n)})),i=Ya.lastIndex;return ig&&(g=s.x),s.y>v&&(v=s.y),c.push(s.x),u.push(s.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-h;function T(t,e,r,n,a,i,o,l){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var s=t.x,c=t.y;if(null!=s)if(m(s-r)+m(c-n)<.01)M(t,e,r,n,a,i,o,l);else{var u=t.point;t.x=t.y=t.point=null,M(t,u,s,c,a,i,o,l),M(t,e,r,n,a,i,o,l)}else t.x=r,t.y=n,t.point=e}else M(t,e,r,n,a,i,o,l)}function M(t,e,r,n,a,i,o,l){var s=.5*(a+o),c=.5*(i+l),u=r>=s,f=n>=c,d=f<<1|u;t.leaf=!1,u?a=s:o=s,f?i=c:l=c,T(t=t.nodes[d]||(t.nodes[d]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}}),e,r,n,a,i,o,l)}w>k?v=h+w:g=p+k;var A={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}};if(A.visit=function(t){!function t(e,r,n,a,i,o){if(!e(r,n,a,i,o)){var l=.5*(n+i),s=.5*(a+o),c=r.nodes;c[0]&&t(e,c[0],n,a,l,s),c[1]&&t(e,c[1],l,a,i,s),c[2]&&t(e,c[2],n,s,l,o),c[3]&&t(e,c[3],l,s,i,o)}}(t,A,p,h,g,v)},A.find=function(t){return function(t,e,r,n,a,i,o){var l,s=1/0;return function t(c,u,f,d,p){if(!(u>i||f>o||d=_)<<1|e>=b,k=w+4;w=0&&!(n=t.interpolators[a](e,r)););return n}function Ja(t,e){var r,n=[],a=[],i=t.length,o=e.length,l=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function ii(t){return 1-Math.cos(t*St)}function oi(t){return Math.pow(2,10*(t-1))}function li(t){return 1-Math.sqrt(1-t*t)}function si(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ci(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ui(t){var e,r,n,a=[t.a,t.b],i=[t.c,t.d],o=di(a),l=fi(a,i),s=di(((e=i)[0]+=(n=-l)*(r=a)[0],e[1]+=n*r[1],e))||0;a[0]*i[1]=0?t.slice(0,n):t,i=n>=0?t.slice(n+1):"in";return a=Qa.get(a)||$a,i=Ka.get(i)||z,e=i(a.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,a=e.c,i=e.l,o=r.h-n,l=r.c-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.c:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Xt(n+o*t,a+l*t,i+s*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,a=e.s,i=e.l,o=r.h-n,l=r.s-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.s:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ut(n+o*t,a+l*t,i+s*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,a=e.a,i=e.b,o=r.l-n,l=r.a-a,s=r.b-i;return function(t){return te(n+o*t,a+l*t,i+s*t)+""}},t.interpolateRound=ci,t.transform=function(e){var r=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ui(e?e.matrix:pi)})(e)},ui.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pi={a:1,b:0,c:0,d:1,e:0,f:0};function hi(t){return t.length?t.pop()+",":""}function gi(e,r){var n=[],a=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push("translate(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,a),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(hi(r)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&r.push(hi(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,a),function(t,e,r,n){t!==e?n.push({i:r.push(hi(r)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&r.push(hi(r)+"skewX("+e+")")}(e.skew,r.skew,n,a),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push(hi(r)+"scale(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(hi(r)+"scale("+e+")")}(e.scale,r.scale,n,a),e=r=null,function(t){for(var e,r=-1,i=a.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,s.end({type:"end",alpha:n=0})):t>0&&(s.start({type:"start",alpha:n=t}),e=Te(l.tick)),l):n},l.start=function(){var t,e,r,n=y.length,s=m.length,u=c[0],h=c[1];for(t=0;t=0;)r.push(a[n])}function Ci(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(u=c[s]),u.parent=i,u.depth=i.depth+1;r&&(i.value=0),i.children=c}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Ci(a,function(e){var n,a;t&&(n=e.children)&&n.sort(t),r&&(a=e.parent)&&(a.value+=e.value)}),l}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Si(t,function(t){t.children&&(t.value=0)}),Ci(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var a=e.call(this,t,n);return function t(e,r,n,a){var i=e.children;if(e.x=r,e.y=e.depth*a,e.dx=n,e.dy=a,i&&(o=i.length)){var o,l,s,c=-1;for(n=e.value?n/e.value:0;++cl&&(l=n),o.push(n)}for(r=0;ra&&(n=r,a=e);return n}function Vi(t){return t.reduce(Ui,0)}function Ui(t,e){return t+e[1]}function Gi(t,e){return Zi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Zi(t,e){for(var r=-1,n=+t[0],a=(t[1]-n)/e,i=[];++r<=e;)i[r]=a*r+n;return i}function Xi(e){return[t.min(e),t.max(e)]}function Yi(t,e){return t.value-e.value}function Wi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function $i(t,e){var r=e.x-t.x,n=e.y-t.y,a=t.r+e.r;return.999*a*a>r*r+n*n}function Qi(t){if((e=t.children)&&(s=e.length)){var e,r,n,a,i,o,l,s,c=1/0,u=-1/0,f=1/0,d=-1/0;if(e.forEach(Ki),(r=e[0]).x=-r.r,r.y=0,x(r),s>1&&((n=e[1]).x=n.r,n.y=0,x(n),s>2))for(eo(r,n,a=e[2]),x(a),Wi(r,a),r._pack_prev=a,Wi(a,n),n=r._pack_next,i=3;i0)for(o=-1;++o=f[0]&&s<=f[1]&&((l=c[t.bisect(d,s,1,h)-1]).y+=g,l.push(i[o]));return c}return i.value=function(t){return arguments.length?(r=t,i):r},i.range=function(t){return arguments.length?(n=ve(t),i):n},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Zi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Yi),n=0,a=[1,1];function i(t,i){var o=r.call(this,t,i),l=o[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,Ci(l,function(t){t.r=+u(t.value)}),Ci(l,Qi),n){var f=n*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;Ci(l,function(t){t.r+=f}),Ci(l,Qi),Ci(l,function(t){t.r-=f})}return function t(e,r,n,a){var i=e.children;e.x=r+=a*e.x;e.y=n+=a*e.y;e.r*=a;if(i)for(var o=-1,l=i.length;++op.x&&(p=t),t.depth>h.depth&&(h=t)});var g=r(d,p)/2-d.x,v=n[0]/(p.x+r(p,d)/2+g),y=n[1]/(h.depth||1);Si(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*y})}return c}function o(t){var e=t.children,n=t.parent.children,a=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+r(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+r(t._,a._));t.parent.A=function(t,e,n){if(e){for(var a,i=t,o=t,l=e,s=i.parent.children[0],c=i.m,u=o.m,f=l.m,d=s.m;l=ao(l),i=no(i),l&&i;)s=no(s),(o=ao(o)).a=t,(a=l.z+f-i.z-c+r(l._,i._))>0&&(io(oo(l,t,n),t,a),c+=a,u+=a),f+=l.m,c+=i.m,d+=s.m,u+=o.m;l&&!ao(o)&&(o.t=l,o.m+=f-u),i&&!no(s)&&(s.t=i,s.m+=c-d,n=t)}return n}(t,a,t.parent.A||n[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=n[0],t.y=t.depth*n[1]}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t)?s:null,i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null==(n=t)?null:s,i):a?n:null},Li(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],a=!1;function i(i,o){var l,s=e.call(this,i,o),c=s[0],u=0;Ci(c,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=l?u+=r(e,l):0,e.y=0,l=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(c),d=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(c),p=f.x-r(f,d)/2,h=d.x+r(d,f)/2;return Ci(c,a?function(t){t.x=(t.x-c.x)*n[0],t.y=(c.y-t.y)*n[1]}:function(t){t.x=(t.x-p)/(h-p)*n[0],t.y=(1-(c.y?t.y/c.y:1))*n[1]}),s}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t),i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null!=(n=t),i):a?n:null},Li(i,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,a=[1,1],i=null,o=lo,l=!1,s="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var r,n,a=-1,i=t.length;++a0;)l.push(r=c[a-1]),l.area+=r.area,"squarify"!==s||(n=p(l,g))<=d?(c.pop(),d=n):(l.area-=l.pop().area,h(l,g,i,!1),g=Math.min(i.dx,i.dy),l.length=l.area=0,d=1/0);l.length&&(h(l,g,i,!0),l.length=l.area=0),e.forEach(f)}}function d(t){var e=t.children;if(e&&e.length){var r,n=o(t),a=e.slice(),i=[];for(u(a,n.dx*n.dy/t.value),i.area=0;r=a.pop();)i.push(r),i.area+=r.area,null!=r.z&&(h(i,r.z?n.dx:n.dy,n,!a.length),i.length=i.area=0);e.forEach(d)}}function p(t,e){for(var r,n=t.area,a=0,i=1/0,o=-1,l=t.length;++oa&&(a=r));return e*=e,(n*=n)?Math.max(e*a*c/n,n/(e*i*c)):1/0}function h(t,e,r,a){var i,o=-1,l=t.length,s=r.x,c=r.y,u=e?n(t.area/e):0;if(e==r.dx){for((a||u>r.dy)&&(u=r.dy);++or.dx)&&(u=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,l=a?yi:vi;return i=t(e,r,l,n),o=t(r,e,l,Wa),s}function s(t){return i(t)}s.invert=function(t){return o(t)};s.domain=function(t){return arguments.length?(e=t.map(Number),l()):e};s.range=function(t){return arguments.length?(r=t,l()):r};s.rangeRound=function(t){return s.range(t).interpolate(ci)};s.clamp=function(t){return arguments.length?(a=t,l()):a};s.interpolate=function(t){return arguments.length?(n=t,l()):n};s.ticks=function(t){return bo(e,t)};s.tickFormat=function(t,r){return _o(e,t,r)};s.nice=function(t){return mo(e,t),l()};s.copy=function(){return t(e,r,n,a)};return l()}([0,1],[0,1],Wa,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function l(t){return a?Math.pow(n,t):-Math.pow(n,-t)}function s(t){return r(o(t))}s.invert=function(t){return l(r.invert(t))};s.domain=function(t){return arguments.length?(a=t[0]>=0,r.domain((i=t.map(Number)).map(o)),s):i};s.base=function(t){return arguments.length?(n=+t,r.domain(i.map(o)),s):n};s.nice=function(){var t=po(i.map(o),a?Math:Mo);return r.domain(t),i=t.map(l),s};s.ticks=function(){var t=co(i),e=[],r=t[0],s=t[1],c=Math.floor(o(r)),u=Math.ceil(o(s)),f=n%1?2:n;if(isFinite(u-c)){if(a){for(;c0;d--)e.push(l(c)*d);for(c=0;e[c]s;u--);e=e.slice(c,u)}return e};s.tickFormat=function(e,r){if(!arguments.length)return To;arguments.length<2?r=To:"function"!=typeof r&&(r=t.format(r));var a=Math.max(1,n*e/s.ticks().length);return function(t){var e=t/l(Math.round(o(t)));return e*n0?a[t-1]:r[0],tf?0:1;if(c=Lt)return s(c,p)+(l?s(l,1-p):"")+"Z";var h,g,v,y,m,x,b,_,w,k,T,M,A=0,L=0,S=[];if((y=(+o.apply(this,arguments)||0)/2)&&(v=n===Do?Math.sqrt(l*l+c*c):+n.apply(this,arguments),p||(L*=-1),c&&(L=Et(v/c*Math.sin(y))),l&&(A=Et(v/l*Math.sin(y)))),c){m=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var C=Math.abs(f-u-2*L)<=Mt?0:1;if(L&&Fo(m,x,b,_)===p^C){var O=(u+f)/2;m=c*Math.cos(O),x=c*Math.sin(O),b=_=null}}else m=x=0;if(l){w=l*Math.cos(f-A),k=l*Math.sin(f-A),T=l*Math.cos(u+A),M=l*Math.sin(u+A);var z=Math.abs(u-f+2*A)<=Mt?0:1;if(A&&Fo(w,k,T,M)===1-p^z){var D=(u+f)/2;w=l*Math.cos(D),k=l*Math.sin(D),T=M=null}}else w=k=0;if(d>kt&&(h=Math.min(Math.abs(c-l)/2,+r.apply(this,arguments)))>.001){g=l0?0:1}function Bo(t,e,r,n,a){var i=t[0]-e[0],o=t[1]-e[1],l=(a?n:-n)/Math.sqrt(i*i+o*o),s=l*o,c=-l*i,u=t[0]+s,f=t[1]+c,d=e[0]+s,p=e[1]+c,h=(u+d)/2,g=(f+p)/2,v=d-u,y=p-f,m=v*v+y*y,x=r-n,b=u*p-d*f,_=(y<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-b*b)),w=(b*y-v*_)/m,k=(-b*v-y*_)/m,T=(b*y+v*_)/m,M=(-b*v+y*_)/m,A=w-h,L=k-g,S=T-h,C=M-g;return A*A+L*L>S*S+C*C&&(w=T,k=M),[[w-s,k-c],[w*r/x,k*r/x]]}function jo(t){var e=ea,r=ra,n=Zr,a=qo,i=a.key,o=.7;function l(i){var l,s=[],c=[],u=-1,f=i.length,d=ve(e),p=ve(r);function h(){s.push("M",a(t(c),o))}for(;++u1&&a.push("H",n[0]);return a.join("")},"step-before":Uo,"step-after":Go,basis:Yo,"basis-open":function(t){if(t.length<4)return qo(t);var e,r=[],n=-1,a=t.length,i=[0],o=[0];for(;++n<3;)e=t[n],i.push(e[0]),o.push(e[1]);r.push(Wo(Qo,i)+","+Wo(Qo,o)),--n;for(;++n9&&(a=3*e/Math.sqrt(a),o[l]=a*r,o[l+1]=a*n));l=-1;for(;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+o[l]*o[l])),i.push([a||0,o[l]*a||0]);return i}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Vo(t){return t.join("L")+"Z"}function Uo(t){for(var e=0,r=t.length,n=t[0],a=[n[0],",",n[1]];++e1){l=e[1],i=t[s],s++,n+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-l[0])+","+(i[1]-l[1])+","+i[0]+","+i[1];for(var c=2;cMt)+",1 "+e}function s(t,e,r,n){return"Q 0,0 "+n}return i.radius=function(t){return arguments.length?(r=ve(t),i):r},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(n=ve(t),i):n},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Hn,e=qn,r=al;function n(n,a){var i=t.call(this,n,a),o=e.call(this,n,a),l=(i.y+o.y)/2,s=[i,{x:i.x,y:l},{x:o.x,y:l},o];return"M"+(s=s.map(r))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=al,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-St;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=ol,e=il;function r(r,n){return(sl.get(t.call(this,r,n))||ll)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var sl=t.map({circle:ll,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*ul)),r=e*ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=sl.keys();var cl=Math.sqrt(3),ul=Math.tan(30*Ct);X.transition=function(t){for(var e,r,n=hl||++yl,a=bl(t),i=[],o=gl||{time:Date.now(),ease:ai,delay:0,duration:250},l=-1,s=this.length;++l0;)c[--d].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[n]:delete t[r],1}f||(i=a.time,o=Te(function(t){var e=f.delay;if(o.t=e+i,e<=t)return d(t-e);o.c=d},0,i),f=u[n]={tween:new b,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++u.count)}vl.call=X.call,vl.empty=X.empty,vl.node=X.node,vl.size=X.size,t.transition=function(e,r){return e&&e.transition?hl?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vl,vl.select=function(t){var e,r,n,a=this.id,i=this.namespace,o=[];t=Y(t);for(var l=-1,s=this.length;++lrect,.s>rect").attr("width",l[1]-l[0])}function g(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function v(){var f,v,y=this,m=t.select(t.event.target),x=n.of(y,arguments),b=t.select(y),_=m.datum(),w=!/^(n|s)$/.test(_)&&a,k=!/^(e|w)$/.test(_)&&i,T=m.classed("extent"),M=xt(y),A=t.mouse(y),L=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(T||(f=null,A[0]-=l[1],A[1]-=s[1],T=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==T&&(A[0]+=l[1],A[1]+=s[1],T=0,F())});if(t.event.changedTouches?L.on("touchmove.brush",O).on("touchend.brush",D):L.on("mousemove.brush",O).on("mouseup.brush",D),b.interrupt().selectAll("*").interrupt(),T)A[0]=l[0]-A[0],A[1]=s[0]-A[1];else if(_){var S=+/w$/.test(_),C=+/^n/.test(_);v=[l[1-S]-A[0],s[1-C]-A[1]],A[0]=l[S],A[1]=s[C]}else t.event.altKey&&(f=A.slice());function O(){var e=t.mouse(y),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),T||(t.event.altKey?(f||(f=[(l[0]+l[1])/2,(s[0]+s[1])/2]),A[0]=l[+(e[0]1?{floor:function(e){for(;l(e=t.floor(e));)e=Pl(e-1);return e},ceil:function(e){for(;l(e=t.ceil(e));)e=Pl(+e+1);return e}}:t))},a.ticks=function(t,e){var r=co(a.domain()),n=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],Pl(+r[1]+1),e<1?1:e)},a.tickFormat=function(){return n},a.copy=function(){return Dl(e.copy(),r,n)},yo(a,e)}function Pl(t){return new Date(t)}Sl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?zl:Ol,zl.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},zl.toString=Ol.toString,Pe.second=Ne(function(t){return new Ee(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),Pe.seconds=Pe.second.range,Pe.seconds.utc=Pe.second.utc.range,Pe.minute=Ne(function(t){return new Ee(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),Pe.minutes=Pe.minute.range,Pe.minutes.utc=Pe.minute.utc.range,Pe.hour=Ne(function(t){var e=t.getTimezoneOffset()/60;return new Ee(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),Pe.hours=Pe.hour.range,Pe.hours.utc=Pe.hour.utc.range,Pe.month=Ne(function(t){return(t=Pe.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),Pe.months=Pe.month.range,Pe.months.utc=Pe.month.utc.range;var El=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Rl=[[Pe.second,1],[Pe.second,5],[Pe.second,15],[Pe.second,30],[Pe.minute,1],[Pe.minute,5],[Pe.minute,15],[Pe.minute,30],[Pe.hour,1],[Pe.hour,3],[Pe.hour,6],[Pe.hour,12],[Pe.day,1],[Pe.day,2],[Pe.week,1],[Pe.month,1],[Pe.month,3],[Pe.year,1]],Il=Sl.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Zr]]),Nl={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(Pl)},floor:z,ceil:z};Rl.year=Pe.year,Pe.scale=function(){return Dl(t.scale.linear(),Rl,Il)};var Fl=Rl.map(function(t){return[t[0].utc,t[1]]}),Bl=Cl.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Zr]]);function jl(t){return JSON.parse(t.responseText)}function Hl(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Fl.year=Pe.year.utc,Pe.scale.utc=function(){return Dl(t.scale.linear(),Fl,Bl)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return me(t,"application/json",jl,e)},t.html=function(t,e){return me(t,"text/html",Hl,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],17:[function(t,e,r){(function(n,a){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,l=void 0,s=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(l?l(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,d="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],24:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(l=e,l===window||l===document||l===document.body?n:l.getBoundingClientRect());var l;return r[0]=a-o.left,r[1]=i-o.top,r}},{}],25:[function(t,e,r){var n,a=t("./lib/build-log"),i=t("./lib/epsilon"),o=t("./lib/intersecter"),l=t("./lib/segment-chainer"),s=t("./lib/segment-selector"),c=t("./lib/geojson"),u=!1,f=i();function d(t,e,r){var a=n.segments(t),i=n.segments(e),o=r(n.combine(a,i));return n.polygon(o)}n={buildLog:function(t){return!0===t?u=a():!1===t&&(u=!1),!1!==u&&u.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,u);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,u).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:s.union(t.combined,u),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:s.intersect(t.combined,u),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:s.difference(t.combined,u),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:s.differenceRev(t.combined,u),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:s.xor(t.combined,u),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:l(t.segments,f,u),inverted:t.inverted}},polygonFromGeoJSON:function(t){return c.toPolygon(n,t)},polygonToGeoJSON:function(t){return c.fromPolygon(n,f,t)},union:function(t,e){return d(t,e,n.selectUnion)},intersect:function(t,e){return d(t,e,n.selectIntersect)},difference:function(t,e){return d(t,e,n.selectDifference)},differenceRev:function(t,e){return d(t,e,n.selectDifferenceRev)},xor:function(t,e){return d(t,e,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),e.exports=n},{"./lib/build-log":26,"./lib/epsilon":27,"./lib/geojson":28,"./lib/intersecter":29,"./lib/segment-chainer":31,"./lib/segment-selector":32}],26:[function(t,e,r){e.exports=function(){var t,e=0,r=!1;function n(e,r){return t.list.push({type:e,data:r?JSON.parse(JSON.stringify(r)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return n("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return n("div_seg",{seg:t,pt:e}),n("chop",{seg:t,pt:e})},statusRemove:function(t){return n("pop_seg",{seg:t})},segmentUpdate:function(t){return n("seg_update",{seg:t})},segmentNew:function(t,e){return n("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return n("rem_seg",{seg:t})},tempStatus:function(t,e,r){return n("temp_status",{seg:t,above:e,below:r})},rewind:function(t){return n("rewind",{seg:t})},status:function(t,e,r){return n("status",{seg:t,above:e,below:r})},vert:function(e){return e===r?t:(r=e,n("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),n("log",{txt:t})},reset:function(){return n("reset")},selected:function(t){return n("selected",{segs:t})},chainStart:function(t){return n("chain_start",{seg:t})},chainRemoveHead:function(t,e){return n("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return n("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return n("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return n("chain_match",{index:t})},chainClose:function(t){return n("chain_close",{index:t})},chainAddHead:function(t,e){return n("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return n("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return n("chain_con",{index1:t,index2:e})},chainReverse:function(t){return n("chain_rev",{index:t})},chainJoin:function(t,e){return n("chain_join",{index1:t,index2:e})},done:function(){return n("done")}}}},{}],27:[function(t,e,r){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,r,n){var a=r[0],i=r[1],o=n[0],l=n[1],s=e[0];return(o-a)*(e[1]-i)-(l-i)*(s-a)>=-t},pointBetween:function(e,r,n){var a=e[1]-r[1],i=n[0]-r[0],o=e[0]-r[0],l=n[1]-r[1],s=o*i+a*l;return!(s-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-a>t&&(i-c)*(a-u)/(o-u)+c-n>t&&(l=!l),i=c,o=u}return l}};return e}},{}],28:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),a=1;a0})}function u(t,n){var a=t.seg,i=n.seg,o=a.start,l=a.end,c=i.start,u=i.end;r&&r.checkIntersection(a,i);var f=e.linesIntersect(o,l,c,u);if(!1===f){if(!e.pointsCollinear(o,l,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(l,c))return!1;var d=e.pointsSame(o,c),p=e.pointsSame(l,u);if(d&&p)return n;var h=!d&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(l,c,u);if(d)return g?s(n,l):s(t,u),n;h&&(p||(g?s(n,l):s(t,u)),s(n,o))}else 0===f.alongA&&(-1===f.alongB?s(t,c):0===f.alongB?s(t,f.pt):1===f.alongB&&s(t,u)),0===f.alongB&&(-1===f.alongA?s(n,o):0===f.alongA?s(n,f.pt):1===f.alongA&&s(n,l));return!1}for(var f=[];!i.isEmpty();){var d=i.getHead();if(r&&r.vert(d.pt[0]),d.isStart){r&&r.segmentNew(d.seg,d.primary);var p=c(d),h=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(h){var t=u(d,h);if(t)return t}return!!g&&u(d,g)}r&&r.tempStatus(d.seg,!!h&&h.seg,!!g&&g.seg);var y,m,x=v();if(x)t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=d.seg.myFill,r&&r.segmentUpdate(x.seg),d.other.remove(),d.remove();if(i.getHead()!==d){r&&r.rewind(d.seg);continue}t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=g?g.seg.myFill.above:a,d.seg.myFill.above=m?!d.seg.myFill.below:d.seg.myFill.below):null===d.seg.otherFill&&(y=g?d.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:d.primary?o:a,d.seg.otherFill={above:y,below:y}),r&&r.status(d.seg,!!h&&h.seg,!!g&&g.seg),d.other.status=p.insert(n.node({ev:d}))}else{var b=d.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(l.exists(b.prev)&&l.exists(b.next)&&u(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!d.primary){var _=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=_}f.push(d.seg)}i.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,a,i,o=t[t.length-1],s=0;s1)for(var r=1;r1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=O(t,360),e=O(e,100),r=O(r,100),0===e)n=a=i=r;else{var l=r<.5?r*(1+e):r+e-r*e,s=2*r-l;n=o(s,l,t+1/3),a=o(s,l,t),i=o(s,l,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(e.h,s,u),f=!0,d="hsl"),e.hasOwnProperty("a")&&(i=e.a));var p,h,g;return i=C(i),{ok:f,format:e.format||d,r:o(255,l(a.r,0)),g:o(255,l(a.g,0)),b:o(255,l(a.b,0)),a:i}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=i(100*this._a)/100,this._format=s.format||u.format,this._gradientType=s.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=u.ok,this._tc_id=a++}function u(t,e,r){t=O(t,255),e=O(e,255),r=O(r,255);var n,a,i=l(t,e,r),s=o(t,e,r),c=(i+s)/2;if(i==s)n=a=0;else{var u=i-s;switch(a=c>.5?u/(2-i-s):u/(i+s),i){case t:n=(e-r)/u+(e>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(c(n));return i}function A(t,e){e=e||6;for(var r=c(t).toHsv(),n=r.h,a=r.s,i=r.v,o=[],l=1/e;e--;)o.push(c({h:n,s:a,v:i})),i=(i+l)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,a=this.toRgb();return e=a.r/255,r=a.g/255,n=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=C(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return d(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,a){var o=[P(i(t).toString(16)),P(i(e).toString(16)),P(i(r).toString(16)),P(R(n))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*O(this._r,255))+"%",g:i(100*O(this._g,255))+"%",b:i(100*O(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%)":"rgba("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[d(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=c(t);r="#"+p(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(T,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:E(t[n]));t=r}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:s(),g:s(),b:s()})},c.mix=function(t,e,r){r=0===r?0:r||50;var n=c(t).toRgb(),a=c(e).toRgb(),i=r/100;return c({r:(a.r-n.r)*i+n.r,g:(a.g-n.g)*i+n.g,b:(a.b-n.b)*i+n.b,a:(a.a-n.a)*i+n.a})},c.readability=function(e,r){var n=c(e),a=c(r);return(t.max(n.getLuminance(),a.getLuminance())+.05)/(t.min(n.getLuminance(),a.getLuminance())+.05)},c.isReadable=function(t,e,r){var n,a,i=c.readability(t,e);switch(a=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},c.mostReadable=function(t,e,r){var n,a,i,o,l=null,s=0;a=(r=r||{}).includeFallbackColors,i=r.level,o=r.size;for(var u=0;us&&(s=n,l=c(e[u]));return c.isReadable(t,l,{level:i,size:o})||!a?l:(r.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],r))};var L=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=c.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(L);function C(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function O(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,l(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function z(t){return o(1,l(0,t))}function D(t){return parseInt(t,16)}function P(t){return 1==t.length?"0"+t:""+t}function E(t){return t<=1&&(t=100*t+"%"),t}function R(e){return t.round(255*parseFloat(e)).toString(16)}function I(t){return D(t)/255}var N,F,B,j=(F="[\\s|\\(]+("+(N="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+N+")[,|\\s]+("+N+")\\s*\\)?",B="[\\s|\\(]+("+N+")[,|\\s]+("+N+")[,|\\s]+("+N+")[,|\\s]+("+N+")\\s*\\)?",{CSS_UNIT:new RegExp(N),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+B),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+B),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+B),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function H(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],35:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],36:[function(t,e,r){"use strict";var n=t("./arrow_paths"),a=t("../../plots/font_attributes"),i=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:a({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",i.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",i.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:a({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":202,"../../plots/cartesian/constants":218,"../../plots/font_attributes":239,"./arrow_paths":35}],37:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=a.getFromId(t,e.xref),n=a.getFromId(t,e.yref);e._extremes={},r&&l(e,r),n&&l(e,n)})}function l(t,e){var r,n=e._id,i=n.charAt(0),o=t[i],l=t["a"+i],s=t[i+"ref"],c=t["a"+i+"ref"],u=t["_"+i+"padplus"],f=t["_"+i+"padminus"],d={x:1,y:-1}[i]*t[i+"shift"],p=3*t.arrowsize*t.arrowwidth||0,h=p+d,g=p-d,v=3*t.startarrowsize*t.arrowwidth||0,y=v+d,m=v-d;if(c===s){var x=a.findExtremes(e,[e.r2c(o)],{ppadplus:h,ppadminus:g}),b=a.findExtremes(e,[e.r2c(l)],{ppadplus:Math.max(u,y),ppadminus:Math.max(f,m)});r={min:[x.min[0],b.min[0]],max:[x.max[0],b.max[0]]}}else y=l?y+l:y,m=l?m-l:m,r=a.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(u,h,y),ppadminus:Math.max(f,g,m)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([i,o],t)}},{"../../lib":168,"../../plots/cartesian/axes":212,"./draw":42}],38:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,a,i,o,s,c,u=t._fullLayout.annotations,f=[],d=[],p=[],h=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,l,s=o(t,e),c=s.on,u=s.off.concat(s.explicitOff),f={},d=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var V=!1,U=["x","y"],G=0;G1)&&(K===Q?((st=tt.r2fraction(e["a"+$]))<0||st>1)&&(V=!0):V=!0),Z=tt._offset+tt.r2p(e[$]),W=.5}else"x"===$?(Y=e[$],Z=b.l+b.w*Y):(Y=1-e[$],Z=b.t+b.h*Y),W=e.showarrow?.5:Y;if(e.showarrow){lt.head=Z;var ct=e["a"+$];J=rt*q(.5,e.xanchor)-nt*q(.5,e.yanchor),K===Q?(lt.tail=tt._offset+tt.r2p(ct),X=J):(lt.tail=Z+ct,X=J+ct),lt.text=lt.tail+J;var ut=x["x"===$?"width":"height"];if("paper"===Q&&(lt.head=o.constrain(lt.head,1,ut-1)),"pixel"===K){var ft=-Math.max(lt.tail-3,lt.text),dt=Math.min(lt.tail+3,lt.text)-ut;ft>0?(lt.tail+=ft,lt.text+=ft):dt>0&&(lt.tail-=dt,lt.text-=dt)}lt.tail+=ot,lt.head+=ot}else X=J=at*q(W,it),lt.text=Z+J;lt.text+=ot,J+=ot,X+=ot,e["_"+$+"padplus"]=at/2+X,e["_"+$+"padminus"]=at/2-X,e["_"+$+"size"]=at,e["_"+$+"shift"]=J}if(t._dragging||!V){var pt=0,ht=0;if("left"!==e.align&&(pt=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(ht=(D-m)*("middle"===e.valign?.5:1)),u)n.select("svg").attr({x:I+pt-1,y:I+ht}).call(c.setClipUrl,F?A:null,t);else{var gt=I+ht-h.top,vt=I+pt-h.left;H.call(f.positionText,vt,gt).call(c.setClipUrl,F?A:null,t)}B.select("rect").call(c.setRect,I,I,w,D),N.call(c.setRect,E/2,E/2,R-E,j-E),P.call(c.setTranslate,Math.round(L.x.text-R/2),Math.round(L.y.text-j/2)),O.attr({transform:"rotate("+S+","+L.x.text+","+L.y.text+")"});var yt,mt=function(r,n){C.selectAll(".annotation-arrow-g").remove();var u=L.x.head,f=L.y.head,d=L.x.tail+r,h=L.y.tail+n,y=L.x.text+r,m=L.y.text+n,x=o.rotationXYMatrix(S,y,m),w=o.apply2DTransform(x),A=o.apply2DTransform2(x),z=+N.attr("width"),D=+N.attr("height"),E=y-.5*z,R=E+z,I=m-.5*D,F=I+D,B=[[E,I,E,F],[E,F,R,F],[R,F,R,I],[R,I,E,I]].map(A);if(!B.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){B.forEach(function(t){var e=o.segmentsIntersect(d,h,u,f,t[0],t[1],t[2],t[3]);e&&(d=e.x,h=e.y)});var j=e.arrowwidth,H=e.arrowcolor,q=e.arrowside,V=C.append("g").style({opacity:s.opacity(H)}).classed("annotation-arrow-g",!0),U=V.append("path").attr("d","M"+d+","+h+"L"+u+","+f).style("stroke-width",j+"px").call(s.stroke,s.rgb(H));if(g(U,q,e),_.annotationPosition&&U.node().parentNode&&!i){var G=u,Z=f;if(e.standoff){var X=Math.sqrt(Math.pow(u-d,2)+Math.pow(f-h,2));G+=e.standoff*(d-u)/X,Z+=e.standoff*(h-f)/X}var Y,W,J=V.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(d-G)+","+(h-Z),transform:"translate("+G+","+Z+")"}).style("stroke-width",j+6+"px").call(s.stroke,"rgba(0,0,0,0)").call(s.fill,"rgba(0,0,0,0)");p.init({element:J.node(),gd:t,prepFn:function(){var t=c.getTranslate(P);Y=t.x,W=t.y,l&&l.autorange&&k(l._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(Y,W),a=n[0]+t,i=n[1]+r;P.call(c.setTranslate,a,i),T("x",l?l.p2r(l.r2p(e.x)+t):e.x+t/b.w),T("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/b.h),e.axref===e.xref&&T("ax",l.p2r(l.r2p(e.ax)+t)),e.ayref===e.yref&&T("ay",v.p2r(v.r2p(e.ay)+r)),V.attr("transform","translate("+t+","+r+")"),O.attr({transform:"rotate("+S+","+a+","+i+")"})},doneFn:function(){a.call("_guiRelayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&mt(0,0),z)p.init({element:P.node(),gd:t,prepFn:function(){yt=O.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?T("ax",l.p2r(l.r2p(e.ax)+t)):T("ax",e.ax+t),e.ayref===e.yref?T("ay",v.p2r(v.r2p(e.ay)+r)):T("ay",e.ay+r),mt(t,r);else{if(i)return;var a,o;if(l)a=l.p2r(l.r2p(e.x)+t);else{var s=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-s/2;a=p.align(c+t/b.w,s,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-r/b.h,u,0,1,e.yanchor)}T("x",a),T("y",o),l&&v||(n=p.getCursor(l?.5:a,v?.5:o,e.xanchor,e.yanchor))}O.attr({transform:"translate("+t+","+r+")"+yt}),d(P,n)},doneFn:function(){d(P),a.call("_guiRelayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else P.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,y=f.backoff*p+r.standoff,m=d.backoff*h+r.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},l={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-l.x,b=o.y-l.y;if(c=(s=Math.atan2(b,x))+Math.PI,y&&m&&y+m>Math.sqrt(x*x+b*b))return void z();if(y){if(y*y>x*x+b*b)return void z();var _=y*Math.cos(s),w=y*Math.sin(s);l.x+=_,l.y+=w,t.attr({x2:l.x,y2:l.y})}if(m){if(m*m>x*x+b*b)return void z();var k=m*Math.cos(s),T=m*Math.sin(s);o.x-=k,o.y-=T,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var M=u.getTotalLength(),A="";if(M1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+l+'"]').remove():(s._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(s.x)*r[0],e.yaxis.r2l(s.y)*r[1],e.zaxis.r2l(s.z)*r[2]]),n(t.graphDiv,s,l,t.id,s._xa,s._ya))}}},{"../../plots/gl3d/project":242,"../annotations/draw":42}],49:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var i=r.attrRegex,o=Object.keys(t),l=0;l=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var l=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+l+", "+n[3]+")":"rgb("+l+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(n(t))},i.opacity=function(t){return t?n(t).getAlpha():0},i.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},i.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var a=n(e||s).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-r.a)+r.r*r.a,g:i.g*(1-r.a)+r.g*r.a,b:i.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},i.contrast=function(t,e,r){var a=n(t);return 1!==a.getAlpha()&&(a=n(i.combine(t,s))),(a.isDark()?e?a.lighten(e):s:r?a.darken(r):l).toString()},i.stroke=function(t,e){var r=n(e);t.style({stroke:i.tinyRGB(r),"stroke-opacity":r.getAlpha()})},i.fill=function(t,e){var r=n(e);t.style({fill:i.tinyRGB(r),"fill-opacity":r.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,r,n,a,o=Object.keys(t);for(e=0;e0?S>=R:S<=R));C++)S>N&&S0?S>=R:S<=R));C++)S>O[0]&&S1){var ot=Math.pow(10,Math.floor(Math.log(it)/Math.LN10));nt*=ot*c.roundUp(it/ot,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(et.tick0=0)}et.dtick=nt}et.domain=[$+Y,$+G-Y],et.setScale();var lt=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(T.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(T.cbbg,!0),t.append("g").classed(T.cbfills,!0),t.append("g").classed(T.cblines,!0),t.append("g").classed(T.cbaxis,!0).classed(T.crisp,!0),t.append("g").classed(T.cbtitleunshift,!0).append("g").classed(T.cbtitle,!0),t.append("rect").classed(T.cboutline,!0),t.select(".cbtitle").datum(0)})});lt.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var st=lt.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")"),ct=lt.select(".cbaxis"),ut=0;if(-1!==["top","bottom"].indexOf(r.title.side)){var ft,dt=k.l+(r.x+Z)*k.w,pt=et.title.font.size;ft="top"===r.title.side?(1-($+G-Y))*k.h+k.t+3+.75*pt:(1-($+Y))*k.h+k.t-3-.25*pt,xt(et._id+"title",{attributes:{x:dt,y:ft,"text-anchor":"start"}})}var ht,gt,vt,yt=c.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.title.side)){var i=lt.select(".cbtitle"),o=i.select("text"),s=[-r.outlinewidth/2,r.outlinewidth/2],u=i.select(".h"+et._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),u?(ut=d.bBox(u).height)>f&&(s[1]-=(ut-f)/2):o.node()&&!o.classed(T.jsPlaceholder)&&(ut=d.bBox(o.node()).height),ut){if(ut+=5,"top"===r.title.side)et.domain[1]-=ut/k.h,s[1]*=-1;else{et.domain[0]+=ut/k.h;var p=g.lineCount(o);s[1]+=(1-p)*f}i.attr("transform","translate("+s+")"),et.setScale()}}lt.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-et.domain[1]))+")"),ct.attr("transform","translate(0,"+Math.round(-k.t)+")");var h=lt.select(".cbfills").selectAll("rect.cbfill").data(D);h.enter().append("rect").classed(T.cbfill,!0).style("stroke","none"),h.exit().remove();var m=O.map(et.c2p).map(Math.round).sort(function(t,e){return t-e});h.each(function(i,o){var l=[0===o?O[0]:(D[o]+D[o-1])/2,o===D.length-1?O[1]:(D[o]+D[o+1])/2].map(et.c2p).map(Math.round);l[1]=c.constrain(l[1]+(l[1]>l[0])?1:-1,m[0],m[1]);var s=n.select(this).attr({x:W,width:Math.max(q,2),y:n.min(l),height:Math.max(n.max(l)-n.min(l),2)});if(r.fillgradient)d.gradient(s,t,e,"vertical",r.fillgradient,"fill");else{var u=E(i).replace("e-","");s.attr("fill",a(u).toHexString())}});var x=lt.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?z:[]);return x.enter().append("path").classed(T.cbline,!0),x.exit().remove(),x.each(function(t){n.select(this).attr("d","M"+W+","+(Math.round(et.c2p(t))+r.line.width/2%1)+"h"+q).call(d.lineGroupStyle,r.line.width,P(t),r.line.dash)}),ct.selectAll("g."+et._id+"tick,path").remove(),c.syncOrAsync([function(){var e=W+q+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),n=l.calcTicks(et),a=l.makeTransFn(et),i=l.makeLabelFns(et,e),o=l.getTickSigns(et)[2];return l.drawTicks(t,et,{vals:"inside"===et.ticks?l.clipEnds(et,n):n,layer:ct,path:l.makeTickPath(et,e,o),transFn:a}),l.drawLabels(t,et,{vals:n,layer:ct,transFn:a,labelXFn:i.labelXFn,labelYFn:i.labelYFn,labelAnchorFn:i.labelAnchorFn})},function(){if(-1===["top","bottom"].indexOf(r.title.side)){var e=et.title.font.size,a=et._offset+et._length/2,i=k.l+(et.position||0)*k.w+("right"===et.side?10+e*(et.showticklabels?1:.5):-10-e*(et.showticklabels?.5:0));xt("h"+et._id+"title",{avoid:{selection:n.select(t).selectAll("g."+et._id+"tick"),side:r.title.side,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var n=q+r.outlinewidth/2+d.bBox(ct.node()).width;if((B=st.select("text")).node()&&!B.classed(T.jsPlaceholder)){var a,o=st.select(".h"+et._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(r.title.side)?d.bBox(o).width:d.bBox(st.node()).right-W-k.l,n=Math.max(n,a)}var l=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,s=Q-K;lt.select(".cbbg").attr({x:W-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:K-X,width:Math.max(l,2),height:Math.max(s+2*X,2)}).call(p.fill,r.bgcolor).call(p.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),lt.selectAll(".cboutline").attr({x:W,y:K+r.ypad+("top"===r.title.side?ut:0),width:Math.max(q,2),height:Math.max(s-2*r.ypad-ut,2)}).call(p.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var c=({center:.5,right:1}[r.xanchor]||0)*l;lt.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=m[r.yanchor],h=x[r.yanchor];"pixels"===r.lenmode?(u.y=r.y,u.t=s*f,u.b=s*h):(u.t=u.b=0,u.yt=r.y+r.len*f,u.yb=r.y-r.len*h);var g=m[r.xanchor],v=x[r.xanchor];if("pixels"===r.thicknessmode)u.x=r.x,u.l=l*g,u.r=l*v;else{var y=l-q;u.l=y*g,u.r=y*v,u.xl=r.x-r.thickness*g,u.xr=r.x+r.thickness*v}i.autoMargin(t,e,u)}],t);if(yt&&yt.then&&(t._promises||[]).push(yt),t._context.edits.colorbarPosition)s.init({element:lt.node(),gd:t,prepFn:function(){ht=lt.attr("transform"),f(lt)},moveFn:function(t,e){lt.attr("transform",ht+" translate("+t+","+e+")"),gt=s.align(J+t/k.w,V,0,1,r.xanchor),vt=s.align($-e/k.h,G,0,1,r.yanchor);var n=s.getCursor(gt,vt,r.xanchor,r.yanchor);f(lt,n)},doneFn:function(){if(f(lt),void 0!==gt&&void 0!==vt){var e={};e[L("x")]=gt,e[L("y")]=vt,o.call("_guiRestyle",t,e,A().index)}}});return yt}function mt(t,e){return c.coerce(tt,et,w,t,e)}function xt(e,r){var n={propContainer:et,propName:L("title"),traceIndex:A().index,placeholder:v._dfltTitle.colorbar,containerGroup:lt.select(".cbtitle")},a="h"===e.charAt(0)?e.substr(1):"h"+e;lt.selectAll("."+a+",."+a+"-math-group").remove(),h.draw(t,e,u(n,r||{}))}v._infolayer.selectAll("g."+e).remove()}function A(){var r,n,a=e.substr(2);for(r=0;r=0?a.colorscale.sequential:a.colorscale.sequentialminus,s._colorscale=s.colorscale=h)}},{"../../lib":168}],60:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./helpers").hasColorscale;e.exports=function(t){function e(t,e){var r=t["_"+e];void 0!==r&&(t[e]=r)}function r(t,r){var a=r.container?n.nestedProperty(t,r.container).get():t;if(a){var i=a.zauto||a.cauto,o=r.min,l=r.max;(i||void 0===a[o])&&e(a,o),(i||void 0===a[l])&&e(a,l),a.autocolorscale&&e(a,"colorscale")}}for(var i=0;i=0;n--,a++){var i=t[n];r[a]=[1-i[0],i[1]]}return r}function u(t){var e={r:t[0],g:t[1],b:t[2],a:t[3]};return a(e).toRgbString()}e.exports={hasColorscale:function(t,e){var r=e?o.nestedProperty(t,e).get()||{}:t,n=r.color,a=!1;if(o.isArrayOrTypedArray(n))for(var l=0;l4/3-l?o:l}},{}],68:[function(t,e,r){"use strict";var n=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,i){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:n.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":168}],69:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),l=t("../../lib"),s=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function d(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,r,n,f,h,g,v,y,m=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;m._mouseDownTime||(m._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,r){return Math.abs(t)b&&(x=Math.max(x-1,1)),m._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!y){var r;try{r=new MouseEvent("click",e)}catch(t){var n=p(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(m),m._dragged=!1}else m._dragged=!1}},u.coverSlip=d},{"../../constants/interactions":148,"../../lib":168,"../../plots/cartesian/constants":218,"../../registry":257,"./align":67,"./cursor":68,"./unhover":70,"has-hover":20,"has-passive-events":21,"mouse-event-offset":24}],70:[function(t,e,r){"use strict";var n=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),l=e.exports={};l.wrapped=function(t,e,r){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),l.raw(t,e,r)},l.raw=function(t,e){var r=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":161,"../../lib/get_graph_div":166,"../../lib/throttle":190,"../fx/constants":84}],71:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],72:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,h=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){c.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(l.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,a){t.call(v.setPosition,e,r).call(v.setSize,n,a)},v.translatePoint=function(t,e,r,n){var i=r.c2p(t.x),o=n.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var a=n.select(this);v.translatePoint(t,a,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,a,i){e.attr("display",r.isPtWithinRange(t,a)&&n.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,l=i.ycalendar,s="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(s).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,a,o,l)})})}},v.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=r||i.width||0,s=a||i.dash||"";l.stroke(e,n||i.color),v.dashLine(e,s,o)},v.lineGroupStyle=function(t,e,r,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,s=a||i.dash||"";n.select(this).call(l.stroke,r||i.color).call(v.dashLine,s,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(l.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){var e=n.select(this);t[0].trace&&e.call(l.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var m=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=n.format("~.1f"),T={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,a,o,s){for(var u=o.length,f=T[a],d=new Array(u),p=0;p=100,e.attr("d",b(u,s))}var f,d,p,h=!1;if(t.so)p=o.outlierwidth,d=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,d="mlc"in t?t.mlcc=n.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?l.defaultLine:o.color,c.isArrayOrTypedArray(i.color)&&(f=l.defaultLine,h=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):i.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(l.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var y=i.gradient,m=t.mgt;if(m?h=!0:m=y&&y.type,Array.isArray(m)&&(m=m[0],T[m]||(m=0)),m&&"none"!==m){var x=t.mgc;x?h=!0:x=y.color;var _=r.uid;h&&(_+="-"+t.i),v.gradient(e,a,_,m,[[0,x],[1,f]],"fill")}else l.fill(e,f);p&&l.stroke(e,d)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=h.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.marker||{},i=r.marker||{},l=n.marker||{},s=a.opacity,u=i.opacity,f=l.opacity,d=void 0!==u,h=void 0!==f;(c.isArrayOrTypedArray(s)||d||h)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?d?u:e:h?f:p*e});var g=a.color,v=i.color,y=l.color;(v||y)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:y||e});var m=a.size,x=i.size,b=l.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||m/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.textfont||{},i=r.textfont||{},o=n.textfont||{},s=a.color,c=i.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||s;return t.selected?c||e:u||(c?e:l.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];r.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&i.push(function(t,e){l.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&i.push(function(t,e){var n=e.mx||a.symbol||0,i=r.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(n),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=n.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var l=t.tp||e.textposition,s=L(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,s,f).text(o).call(u.convertToTspans,r).call(A,l,s,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=n.select(this),i=r.selectedTextColorFn(t),o=t.tp||e.textposition,s=L(t,e);l.fill(a,i),A(a,o,s,t.mrc2||t.mrc)})}};var S=.5;function C(t,e,r,a){var i=t[0]-e[0],o=t[1]-e[1],l=r[0]-e[0],s=r[1]-e[1],c=Math.pow(i*i+o*o,S/2),u=Math.pow(l*l+s*s,S/2),f=(u*u*i-c*c*l)*a,d=(u*u*o-c*c*s)*a,p=3*u*(c+u),h=3*c*(c+u);return[[n.round(e[0]+(p&&f/p),2),n.round(e[1]+(p&&d/p),2)],[n.round(e[0]-(h&&f/h),2),n.round(e[1]-(h&&d/h),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],a=[];for(r=1;r=1e4&&(v.savedBBoxes={},D=0),r&&(v.savedBBoxes[r]=y),D++,c.extendFlat({},y)},v.setClipUrl=function(t,e,r){if(e){var n=r._context,a=n._exportedPlot?"":n._baseUrl||"";t.attr("clip-path","url("+a+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||0,r=r||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+r+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||1,r=r||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+r+")").trim(),t[a]("transform",i),i};var E=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(E,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var R=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,a=n.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),l=parseFloat(i.attr("y")||0),s=(a.attr("transform")||"").match(R);t=1===e&&1===r?[]:["translate("+o+","+l+")","scale("+e+","+r+")","translate("+-o+","+-l+")"],s&&t.push(s),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":146,"../../constants/interactions":148,"../../constants/xmlns_namespaces":150,"../../lib":168,"../../lib/svg_text_utils":189,"../../registry":257,"../../traces/scatter/make_bubble_size_func":384,"../../traces/scatter/subtypes":391,"../color":51,"../colorscale":63,"./symbol_defs":73,d3:16,"fast-isnumeric":18,tinycolor2:34}],73:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+a+i+a+i+o+i+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),a=n.round(-t,2),i=n.round(-.309*t,2);return"M"+e+","+i+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+r+"V"+r+"L0,"+e+"L-"+a+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+a+"H"+r+"L"+e+",0L"+r+",-"+a+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),a=n.round(.951*e,2),i=n.round(.363*e,2),o=n.round(.588*e,2),l=n.round(-e,2),s=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+s+"H"+a+"L"+i+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+i+","+c+"L-"+a+","+s+"H-"+r+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),a=n.round(.76*t,2);return"M-"+a+",0l-"+r+",-"+e+"h"+a+"l"+r+",-"+e+"l"+r+","+e+"h"+a+"l-"+r+","+e+"l"+r+","+e+"h-"+a+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+a+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+a+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:16}],74:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],75:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function l(t,e,r,a){var l=e["error_"+a]||{},s=[];if(l.visible&&-1!==["linear","log"].indexOf(r.type)){for(var c=o(l),u=0;u0;e.each(function(e){var f,d=e[0].trace,p=d.error_x||{},h=d.error_y||{};d.ids&&(f=function(t){return t.id});var g=o.hasMarkers(d)&&d.marker.maxdisplayed>0;h.visible||p.visible||(e=[]);var v=n.select(this).selectAll("g.errorbar").data(e,f);if(v.exit().remove(),e.length){p.visible||v.selectAll("path.xerror").remove(),h.visible||v.selectAll("path.yerror").remove(),v.style("opacity",1);var y=v.enter().append("g").classed("errorbar",!0);u&&y.style("opacity",0).transition().duration(l.duration).style("opacity",1),i.setClipUrl(v,r.layerClipId,t),v.each(function(t){var e=n.select(this),r=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,s,c);if(!g||t.vis){var i,o=e.select("path.yerror");if(h.visible&&a(r.x)&&a(r.yh)&&a(r.ys)){var f=h.width;i="M"+(r.x-f)+","+r.yh+"h"+2*f+"m-"+f+",0V"+r.ys,r.noYS||(i+="m-"+f+",0h"+2*f),!o.size()?o=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):u&&(o=o.transition().duration(l.duration).ease(l.easing)),o.attr("d",i)}else o.remove();var d=e.select("path.xerror");if(p.visible&&a(r.y)&&a(r.xh)&&a(r.xs)){var v=(p.copy_ystyle?h:p).width;i="M"+r.xh+","+(r.y-v)+"v"+2*v+"m0,-"+v+"H"+r.xs,r.noXS||(i+="m0,-"+v+"v"+2*v),!d.size()?d=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):u&&(d=d.transition().duration(l.duration).ease(l.easing)),d.attr("d",i)}else d.remove()}})}})}},{"../../traces/scatter/subtypes":391,"../drawing":72,d3:16,"fast-isnumeric":18}],80:[function(t,e,r){"use strict";var n=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},i=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(a.stroke,r.color),i.copy_ystyle&&(i=r),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":51,d3:16}],81:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":239}],82:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry");function i(t,e,r,a){a=a||n.identity,Array.isArray(t)&&(e[0][r]=a(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var l=0;l=0&&r.indexw[0]._length||et<0||et>k[0]._length)return d.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,R="xval"in e?g.flat(s,e.xval):g.p2c(w,tt),I="yval"in e?g.flat(s,e.yval):g.p2c(k,et),!a(R[0])||!a(I[0]))return o.warn("Fx.hover failed",e,t),d.unhoverRaw(t,e)}var at=1/0;for(F=0;F<$.length;F++)if((B=$[F])&&B[0]&&B[0].trace&&!0===B[0].trace.visible&&(j=B[0].trace,-1===["carpet","contourcarpet"].indexOf(j._module.name))){if("splom"===j.type?H=s[q=0]:(H=g.getSubplot(j),q=s.indexOf(H)),V=E,Z={cd:B,trace:j,xa:w[q],ya:k[q],maxHoverDistance:Y,maxSpikeDistance:W,index:!1,distance:Math.min(at,Y),spikeDistance:1/0,xSpike:void 0,ySpike:void 0,color:f.defaultLine,name:j.name,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},u[H]&&(Z.subplot=u[H]._subplot),u._splomScenes&&u._splomScenes[j.uid]&&(Z.scene=u._splomScenes[j.uid]),X=J.length,"array"===V){var it=e[F];"pointNumber"in it?(Z.index=it.pointNumber,V="closest"):(V="","xval"in it&&(U=it.xval,V="x"),"yval"in it&&(G=it.yval,V=V?"closest":"y"))}else U=R[q],G=I[q];if(0!==Y)if(j._module&&j._module.hoverPoints){var ot=j._module.hoverPoints(Z,U,G,V,u._hoverlayer);if(ot)for(var lt,st=0;stX&&(J.splice(0,X),at=J[0].distance),m&&0!==W&&0===J.length){Z.distance=W,Z.index=!1;var ct=j._module.hoverPoints(Z,U,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=W})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var dt=ft[0];a(dt.x0)&&a(dt.y0)&&(ut=vt(dt),(!Q.vLinePoint||Q.vLinePoint.spikeDistance>ut.spikeDistance)&&(Q.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var ht=pt[0];a(ht.x0)&&a(ht.y0)&&(ut=vt(ht),(!Q.hLinePoint||Q.hLinePoint.spikeDistance>ut.spikeDistance)&&(Q.hLinePoint=ut))}}}}function gt(t,e){for(var r,n=null,a=1/0,i=0;i1||J.length>1)||"closest"===E&&K&&J.length>1,zt=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),Dt={hovermode:E,rotateLabels:Ot,bgColor:zt,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},Pt=M(J,Dt,t);if(function(t,e,r){var n,a,i,o,l,s,c,u=0,f=1,d=t.map(function(t,n){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!n&&o&&o[0]>o[1]!==i&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?x:1)/2,pmin:0,pmax:i?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],r=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=r.pos+r.dp+r.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;n=!1}if(!(i<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=i;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos>e.pmax-1&&(s.del=!0,c--);for(o=0;o=0;l--)t[l].dp-=i;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(;!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&v.pmin===y.pmin&&v.pmax===y.pmax){for(l=g.length-1;l>=0;l--)g[l].dp+=a;for(h.push.apply(h,g),d.splice(o+1,1),c=0,l=h.length-1;l>=0;l--)c+=h[l].dp;for(i=c/h.length,l=h.length-1;l>=0;l--)h[l].dp-=i;n=!1}else o++}d.forEach(p)}for(o=d.length-1;o>=0;o--){var m=d[o];for(l=m.length-1;l>=0;l--){var b=m[l],_=t[b.i];_.offset=b.dp,_.del=b.del}}}(J,Ot?"xa":"ya",u),A(Pt,Ot),e.target&&e.target.tagName){var Et=h.getComponentMethod("annotations","hasClickToShow")(t,At);c(n.select(e.target),Et?"pointer":"")}if(!e.target||i||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var a=r[n],i=t._hoverdata[n];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber)||String(a.pointNumbers)!==String(i.pointNumbers))return!0}return!1}(t,0,Mt))return;Mt&&t.emit("plotly_unhover",{event:e,points:Mt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:R,yvals:I})}(t,e,r,i)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1},a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M([r],o,e.gd);return A(l,o.rotateLabels),l.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1}}),a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M(r,o,e.gd),s=0;return l.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5([\s\S]*)<\/extra>/;function M(t,e,r){var a=e.hovermode,i=e.rotateLabels,l=e.bgColor,c=e.container,d=e.outerContainer,p=e.commonLabelOpts||{},h=e.fontFamily||v.HOVERFONT,g=e.fontSize||v.HOVERFONTSIZE,m=t[0],x=m.xa,b=m.ya,_="y"===a?"yLabel":"xLabel",M=m[_],A=(String(M)||"").split(" ")[0],L=d.node().getBoundingClientRect(),S=L.top,C=L.width,O=L.height,z=void 0!==M&&m.distance<=e.hoverdistance&&("x"===a||"y"===a);if(z){var D,P,E=!0;for(D=0;D-1&&c.length>b&&(c=b>3?c.substr(0,b-3)+"...":c.substr(0,b))}void 0!==t.zLabel?(void 0!==t.xLabel&&(d+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(d+="y: "+t.yLabel+"
"),d+=(d?"z: ":"")+t.zLabel):z&&t[a+"Label"]===M?d=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(d=t.yLabel):d=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(d+=(d?"
":"")+t.text),void 0!==t.extraText&&(d+=(d?"
":"")+t.extraText),""===d&&(""===c&&e.remove(),d=c);var _=t.hovertemplate||!1,A=t.hovertemplateLabels||t,L=t.eventData[0]||{};_&&(d=(d=o.hovertemplateString(_,A,L)).replace(T,function(t,e){return c=e,""}));var D=e.select("text.nums").call(u.font,t.fontFamily||h,t.fontSize||g,t.fontColor||x).text(d).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),P=e.select("text.name"),E=0;c&&c!==d?(P.call(u.font,t.fontFamily||h,t.fontSize||g,m).text(c).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),E=P.node().getBoundingClientRect().width+2*k):(P.remove(),e.select("rect").remove()),e.select("path").style({fill:v,stroke:x});var R,I,N=D.node().getBoundingClientRect(),F=t.xa._offset+(t.x0+t.x1)/2,B=t.ya._offset+(t.y0+t.y1)/2,j=Math.abs(t.x1-t.x0),H=Math.abs(t.y1-t.y0),q=N.width+w+k+E;t.ty0=S-N.top,t.bx=N.width+2*k,t.by=N.height+2*k,t.anchor="start",t.txwidth=N.width,t.tx2width=E,t.offset=0,i?(t.pos=F,R=B+H/2+q<=O,I=B-H/2-q>=0,"top"!==t.idealAlign&&R||!I?R?(B+=H/2,t.anchor="start"):t.anchor="middle":(B-=H/2,t.anchor="end")):(t.pos=B,R=F+j/2+q<=C,I=F-j/2-q>=0,"left"!==t.idealAlign&&R||!I?R?(F+=j/2,t.anchor="start"):t.anchor="middle":(F-=j/2,t.anchor="end")),D.attr("text-anchor",t.anchor),E&&P.attr("text-anchor",t.anchor),e.attr("transform","translate("+F+","+B+")"+(i?"rotate("+y+")":""))}),N}function A(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var a="end"===t.anchor?-1:1,i=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],l=o*(w+k),c=l+o*(t.txwidth+k),f=0,d=t.offset;"middle"===t.anchor&&(l-=t.tx2width/2,c+=t.txwidth/2+k),e&&(d*=-_,f=t.offset*b),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(d-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+d)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(d-w)+"Z"),i.call(s.positionText,l+f,d+t.ty0-t.by/2+k),t.tx2width&&(r.select("text.name").call(s.positionText,c+o*k+f,d+t.ty0-t.by/2+k),r.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,d-t.by/2-1,t.tx2width,t.by+2))}})}function L(t,e){var r=t.index,n=t.trace||{},a=t.cd[0],i=t.cd[r]||{},l=Array.isArray(r)?function(t,e){return o.castOption(a,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(i,n,t,e)};function s(e,r,n){var a=l(r,n);a&&(t[e]=a)}if(s("hoverinfo","hi","hoverinfo"),s("bgcolor","hbg","hoverlabel.bgcolor"),s("borderColor","hbc","hoverlabel.bordercolor"),s("fontFamily","htf","hoverlabel.font.family"),s("fontSize","hts","hoverlabel.font.size"),s("fontColor","htc","hoverlabel.font.color"),s("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return f&&"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function S(t,e){var r,n,a=e.container,o=e.fullLayout,l=e.event,s=!!t.hLinePoint,c=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),c||s){var d=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(s){var p,h,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(p=l.pointerX,h=l.pointerY):(p=r._offset+g.x,h=n._offset+g.y);var v,y,m=i.readability(g.color,d)<1.5?f.contrast(d):g.color,x=n.spikemode,b=n.spikethickness,_=n.spikecolor||m,w=n._boundingBox,k=(w.left+w.right)/20){for(var n=[],a=0;a-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){d||p||h||"independent"===T("pattern")&&(d=!0),v._hasSubplotGrid=d;var x,b,_="top to bottom"===T("roworder"),w=d?.2:.1,k=d?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",T,w,x,m),y:u("y",T,k,b,y,_)}}else delete e.grid}function T(t,e){return n.coerce(r,v,s,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,a,i,o,l,s,u,d=t.grid||{},p=e._subplots,h=r._hasSubplotGrid,g=r.rows,v=r.columns,y="independent"===r.pattern,m=r._axisMap={};if(h){var x=d.subplots||[];s=r.subplots=new Array(g);var b=1;for(n=0;n1);if(!1!==x||p.uirevision){var b=i.newContainer(e,"legend");if(w("uirevision",e.uirevision),!1!==x){if(w("bgcolor",e.paper_bgcolor),w("bordercolor"),w("borderwidth"),a.coerceFont(w,"font",e.font),w("orientation"),"h"===b.orientation){var _=t.xaxis;n.getComponentMethod("rangeslider","isVisible")(_)?(c=0,f="left",u=1.1,d="bottom"):(c=0,f="left",u=-.1,d="top")}w("traceorder",v),s.isGrouped(e.legend)&&w("tracegroupgap"),w("x",c),w("xanchor",f),w("y",u),w("yanchor",d),w("valign"),a.noneOrAll(p,b,["x","y"])}}function w(t,e){return a.coerce(p,b,o,t,e)}}},{"../../lib":168,"../../plot_api/plot_template":202,"../../plots/layout_attributes":243,"../../registry":257,"./attributes":100,"./helpers":106}],103:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib/events"),s=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),d=t("./handle_click"),p=t("./constants"),h=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,y=g.FROM_TL,m=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=h.DBLCLICKDELAY;function k(t,e,r,n,a){var i=r.data()[0][0].trace,o={event:a,node:r.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=r.datum()[0].label),!1!==l.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){d(r,t,n)},w);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==l.triggerHandler(t,"plotly_legenddoubleclick",o)&&d(r,t,n)}}function T(t,e,r){var n=t.data()[0][0],i=e._fullLayout,l=n.trace,s=o.traceIs(l,"pie"),u=l.index,d=s?n.label:l.name,h=e._context.edits.legendText&&!s,g=a.ensureSingle(t,"text","legendtext");function y(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,a,i=t.select("g[class*=math-group]"),o=i.node(),l=e._fullLayout.legend.font.size*v;if(o){var s=c.bBox(o);n=s.height,a=s.width,c.setTranslate(i,0,n/4)}else{var u=t.select(".legendtext"),d=f.lineCount(u),h=u.node();n=l*d,a=h?c.bBox(h).width:0;var g=l*(.3+(1-d)/2);f.positionText(u,p.textOffsetX,g),r.lineHeight=l}n=Math.max(n,16)+3,r.height=n,r.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,i.legend.font).text(h?M(d,r):d),f.positionText(g,p.textOffsetX,0),h?g.call(f.makeEditable,{gd:e,text:d}).call(y).on("edit",function(t){this.text(M(t,r)).call(y);var i=n.trace._fullInput||{},l={};if(o.hasTransform(i,"groupby")){var s=o.getTransformIndices(i,"groupby"),c=s[s.length-1],f=a.keyedContainer(i,"transforms["+c+"].styles","target","value.name");f.set(n.trace._group,t),l=f.constructUpdate()}else l.name=t;return o.call("_guiRestyle",e,l,u)}):y(g)}function M(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function A(t,e){var r,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimew&&(i=Math.max(i-1,1)),k(e,r,t,i,n.event)}})}function L(t,e,r){var a=t._fullLayout,i=a.legend,o=i.borderwidth,l=_.isGrouped(i),s=0;if(i._width=0,i._height=0,_.isVertical(i))l&&e.each(function(t,e){c.setTranslate(this,0,e*i.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;c.setTranslate(this,o,5+o+i._height+r/2),i._height+=r,i._width=Math.max(i._width,n)}),i._width+=45+2*o,i._height+=10+2*o,l&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),s=40;else if(l){for(var u=[i._width],f=e.data(),d=0,p=f.length;do+w-k,r.each(function(t){var e=t[0],r=v?40+t[0].width:x;o+b+k+r>a._size.w&&(b=0,y+=m,i._height=i._height+m,m=0),c.setTranslate(this,o+b,5+o+e.height/2+y),i._width+=k+r,i._height=Math.max(i._height,e.height),b+=k+r,m=Math.max(e.height,m)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var T=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");c.setRect(r,0,-e.height/2,(T?0:i._width)+s,e.height)})}function S(t){var e=t._fullLayout.legend,r="left";a.isRightAnchor(e)?r="right":a.isCenterAnchor(e)&&(r="center");var n="top";a.isBottomAnchor(e)?n="bottom":a.isMiddleAnchor(e)&&(n="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[r],r:e._width*m[r],b:e._height*m[n],t:e._height*y[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var l=e.legend,f=e.showlegend&&x(t.calcdata,l),d=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void i.autoMargin(t,"legend");for(var h=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";a.isRightAnchor(e)?r="right":a.isCenterAnchor(e)&&(r="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[r],r:e._width*m[r],b:0,t:0})}(t):S(t);var d=e._size,h=d.l+d.w*l.x,g=d.t+d.h*(1-l.y);a.isRightAnchor(l)?h-=l._width:a.isCenterAnchor(l)&&(h-=l._width/2),a.isBottomAnchor(l)?g-=l._height:a.isMiddleAnchor(l)&&(g-=l._height/2);var v=l._width,x=d.w;v>x?(h=d.l,v=x):(h+v>u&&(h=u-v),h<0&&(h=0),v=Math.min(u-h,l._width));var b,_,w,T,M=l._height,A=d.h;if(M>A?(g=d.t,M=A):(g+M>f&&(g=f-M),g<0&&(g=0),M=Math.min(f-g,l._height)),c.setTranslate(O,h,g),E.on(".drag",null),O.on("wheel",null),l._height<=M||t._context.staticPlot)D.attr({width:v-l.borderwidth,height:M-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),c.setTranslate(P,0,0),z.select("rect").attr({width:v-2*l.borderwidth,height:M-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth}),c.setClipUrl(P,r,t),c.setRect(E,0,0,0,0),delete l._scrollY;else{var N,F,B=Math.max(p.scrollBarMinHeight,M*M/l._height),j=M-B-2*p.scrollBarMargin,H=l._height-M,q=j/H,V=Math.min(l._scrollY||0,H);D.attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:M-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),z.select("rect").attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:M-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth+V}),c.setClipUrl(P,r,t),G(V,B,q),O.on("wheel",function(){G(V=a.constrain(l._scrollY+n.event.deltaY/j*H,0,H),B,q),0!==V&&V!==H&&n.event.preventDefault()});var U=n.behavior.drag().on("dragstart",function(){N=n.event.sourceEvent.clientY,F=V}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||G(V=a.constrain((t.clientY-N)/q+F,0,H),B,q)});E.call(U)}function G(e,r,n){l._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(P,0,-e),c.setRect(E,v,p.scrollBarMargin+e*n,p.scrollBarWidth,r),z.select("rect").attr({y:l.borderwidth+e})}t._context.edits.legendPosition&&(O.classed("cursor-move",!0),s.init({element:O.node(),gd:t,prepFn:function(){var t=c.getTranslate(O);w=t.x,T=t.y},moveFn:function(t,e){var r=w+t,n=T+e;c.setTranslate(O,r,n),b=s.align(r,0,d.l,d.l+d.w,l.xanchor),_=s.align(n,0,d.t+d.h,d.t,l.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("_guiRelayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(r,n){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});a.size()>0&&k(t,O,a,r,n)}}))}],t)}}},{"../../constants/alignment":146,"../../constants/interactions":148,"../../lib":168,"../../lib/events":161,"../../lib/svg_text_utils":189,"../../plots/plots":245,"../../registry":257,"../color":51,"../dragelement":69,"../drawing":72,"./constants":101,"./get_legend_data":104,"./handle_click":105,"./helpers":106,"./style":108,d3:16}],104:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var r,i,o={},l=[],s=!1,c={},u=0;function f(t,r){if(""!==t&&a.isGrouped(e))-1===l.indexOf(t)?(l.push(t),s=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+u;l.push(n),o[n]=[[r]],u++}}for(r=0;rr[1])return r[1]}return a}function h(t){return t[0]}if(u||f||d){var g={},v={};if(u){g.mc=p("marker.color",h),g.mx=p("marker.symbol",h),g.mo=p("marker.opacity",i.mean,[.2,1]),g.mlc=p("marker.line.color",h),g.mlw=p("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=p("marker.size",i.mean,[2,16]);g.ms=y,v.marker.size=y}d&&(v.line={width:p("line.width",h,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",h),g.ts=10,g.tc=p("textfont.color",h),g.tf=p("textfont.family",h)),r=[i.minExtend(l,g)],(a=i.minExtend(c,v)).selectedpoints=null}var m=n.select(this).select("g.legendpoints"),x=m.selectAll("path.scatterpts").data(u?r:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,a,e),u&&(r[0].mrc=3);var b=m.selectAll("g.pointtext").data(f?r:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,o=n.select(this);o.style("stroke-width",i+"px").call(l.fill,a.fillcolor),i&&l.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,s=n.select(this);s.style("fill","none").call(o.dashLine,a.line.dash,i),i&&l.stroke(s,a.line.color)})})}},{"../../lib":168,"../../registry":257,"../../traces/pie/style_one":365,"../../traces/scatter/subtypes":391,"../color":51,"../drawing":72,d3:16}],109:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),l=t("../../../build/ploticon"),s=o._,c=e.exports={};function u(t,e){var r,a,o=e.currentTarget,l=o.getAttribute("data-attr"),s=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=i.list(t,null,!0),d="on";if("zoom"===l){var p,h="in"===s?.5:2,g=(1+h)/2,v=(1-h)/2;for(a=0;a1?(k=["toggleHover"],T=["resetViews"]):d?(w=["zoomInGeo","zoomOutGeo"],k=["hoverClosestGeo"],T=["resetGeo"]):f?(k=["hoverClosest3d"],T=["resetCameraDefault3d","resetCameraLastSave3d"]):v?(k=["toggleHover"],T=["resetViewMapbox"]):k=h?["hoverClosestGl2d"]:p?["hoverClosestPie"]:["toggleHover"];u&&(k=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!u&&!h||m||(w=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==T[0]&&(T=["resetScale2d"]));f?M=["zoom3d","pan3d","orbitRotation","tableRotation"]:(u||h)&&!m||g?M=["zoom2d","pan2d"]:v||d?M=["pan2d"]:y&&(M=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),a=0,i=0;i0?d+c:c;return{ppad:c,ppadplus:u?h:g,ppadminus:u?g:h}}return{ppad:c}}function u(t,e,r,n,a){var l="category"===t.type||"multicategory"===t.type?t.r2c:t.d2c;if(void 0!==e)return[l(e),l(r)];if(n){var s,c,u,f,d=1/0,p=-1/0,h=n.match(i.segmentRE);for("date"===t.type&&(l=o.decodeDate(l)),s=0;sp&&(p=f)));return p>=d?[d,p]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:R?V(r.xanchor)+r.x0:V(r.x0),cy:I?U(r.yanchor)-r.y0:U(r.y0),r:i}).style(a).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:R?V(r.xanchor)+r.x1:V(r.x1),cy:I?U(r.yanchor)-r.y1:U(r.y1),r:i}).style(a).classed("cursor-grab",!0),n}():e,Y={element:X.node(),gd:t,prepFn:function(n){R&&(_=V(r.xanchor));I&&(w=U(r.yanchor));"path"===r.type?z=r.path:(y=R?r.x0:V(r.x0),m=I?r.y0:U(r.y0),x=R?r.x1:V(r.x1),b=I?r.y1:U(r.y1));yb?(k=m,L="y0",T=b,S="y1"):(k=b,L="y1",T=m,S="y0");W(n),Q(p,r),function(t,e,r){var n=e.xref,a=e.yref,o=i.getFromId(r,n),s=i.getFromId(r,a),c="";"paper"===n||o.autorange||(c+=n);"paper"===a||s.autorange||(c+=a);l.setClipUrl(t,c?"clip"+r._fullLayout._uid+c:null,r)}(e,r,t),Y.moveFn="move"===D?J:$},doneFn:function(){u(e),K(p),h(e,t,r),n.call("_guiRelayout",t,B.getUpdateObj())},clickFn:function(){K(p)}};function W(t){if(N)D="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Y.element.getBoundingClientRect(),n=r.right-r.left,a=r.bottom-r.top,i=t.clientX-r.left,o=t.clientY-r.top,l=!F&&n>P&&a>E&&!t.shiftKey?c.getCursor(i/n,1-o/a):"move";u(e,l),D=l.split("-")[0]}}function J(n,a){if("path"===r.type){var i=function(t){return t},o=i,l=i;R?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),I?j("yanchor",r.yanchor=Z(w+a)):(l=function(t){return Z(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(z,o,l))}else R?j("xanchor",r.xanchor=G(_+n)):(j("x0",r.x0=G(y+n)),j("x1",r.x1=G(x+n))),I?j("yanchor",r.yanchor=Z(w+a)):(j("y0",r.y0=Z(m+a)),j("y1",r.y1=Z(b+a)));e.attr("d",g(t,r)),Q(p,r)}function $(n,a){if(F){var i=function(t){return t},o=i,l=i;R?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),I?j("yanchor",r.yanchor=Z(w+a)):(l=function(t){return Z(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(z,o,l))}else if(N){if("resize-over-start-point"===D){var s=y+n,c=I?m-a:m+a;j("x0",r.x0=R?s:G(s)),j("y0",r.y0=I?c:Z(c))}else if("resize-over-end-point"===D){var u=x+n,f=I?b-a:b+a;j("x1",r.x1=R?u:G(u)),j("y1",r.y1=I?f:Z(f))}}else{var h=~D.indexOf("n")?k+a:k,B=~D.indexOf("s")?T+a:T,X=~D.indexOf("w")?M+n:M,Y=~D.indexOf("e")?A+n:A;~D.indexOf("n")&&I&&(h=k-a),~D.indexOf("s")&&I&&(B=T-a),(!I&&B-h>E||I&&h-B>E)&&(j(L,r[L]=I?h:Z(h)),j(S,r[S]=I?B:Z(B))),Y-X>P&&(j(C,r[C]=R?X:G(X)),j(O,r[O]=R?Y:G(Y)))}e.attr("d",g(t,r)),Q(p,r)}function Q(t,e){(R||I)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=V(R?e.xanchor:a.midRange(r?[e.x0,e.x1]:d.extractPathCoords(e.path,f.paramIsX))),o=U(I?e.yanchor:a.midRange(r?[e.y0,e.y1]:d.extractPathCoords(e.path,f.paramIsY)));if(i=d.roundPositionForSharpStrokeRendering(i,1),o=d.roundPositionForSharpStrokeRendering(o,1),R&&I){var l="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",l)}else if(R){var s="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",s)}else{var c="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",c)}}()}function K(t){t.selectAll(".visual-cue").remove()}c.init(Y),X.node().onmousemove=W}(t,x,r,e,p)}}function h(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");l.setClipUrl(t,n?"clip"+e._fullLayout._uid+n:null,e)}function g(t,e){var r,n,o,l,s,c,u,p,h=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),y=t._fullLayout._size;if(g?(r=d.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return y.l+y.w*t},v?(o=d.shapePositionToRange(v),l=function(t){return v._offset+v.r2p(o(t,!0))}):l=function(t){return y.t+y.h*(1-t)},"path"===h)return g&&"date"===g.type&&(n=d.decodeDate(n)),v&&"date"===v.type&&(l=d.decodeDate(l)),function(t,e,r){var n=t.path,i=t.xsizemode,o=t.ysizemode,l=t.xanchor,s=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,c=t.charAt(0),u=f.paramIsX[c],d=f.paramIsY[c],p=f.numParams[c],h=t.substr(1).replace(f.paramRE,function(t){return u[n]?t="pixel"===i?e(l)+Number(t):e(t):d[n]&&(t="pixel"===o?r(s)-Number(t):r(t)),++n>p&&(t="X"),t});return n>p&&(h=h.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),c+h})}(e,n,l);if("pixel"===e.xsizemode){var m=n(e.xanchor);s=m+e.x0,c=m+e.x1}else s=n(e.x0),c=n(e.x1);if("pixel"===e.ysizemode){var x=l(e.yanchor);u=x-e.y0,p=x-e.y1}else u=l(e.y0),p=l(e.y1);if("line"===h)return"M"+s+","+u+"L"+c+","+p;if("rect"===h)return"M"+s+","+u+"H"+c+"V"+p+"H"+s+"Z";var b=(s+c)/2,_=(u+p)/2,w=Math.abs(b-s),k=Math.abs(_-u),T="A"+w+","+k,M=b+w+","+_;return"M"+M+T+" 0 1,1 "+(b+","+(_-k))+T+" 0 0,1 "+M+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],l=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return n>=l?t:(i[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var a=0;a0&&(l=l.transition().duration(e.transition.duration).ease(e.transition.easing)),l.attr("transform","translate("+(o-.5*u.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function L(t,e){var r=t._dims;return r.inputAreaStart+u.stepInset+(r.inputAreaLength-2*u.stepInset)*Math.min(1,Math.max(0,e))}function S(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-u.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*u.stepInset-2*r.inputAreaStart)))}function C(t,e,r){var n=r._dims,a=l.ensureSingle(t,"rect",u.railTouchRectClass,function(n){n.call(T,e,t,r).style("pointer-events","all")});a.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,u.tickOffset+r.ticklen+n.labelHeight)}).call(i.fill,r.bgcolor).attr("opacity",0),o.setTranslate(a,0,n.currentValueTotalHeight)}function O(t,e){var r=e._dims,n=r.inputAreaLength-2*u.railInset,a=l.ensureSingle(t,"rect",u.railRectClass);a.attr({width:n,height:u.railWidth,rx:u.railRadius,ry:u.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,u.railInset,.5*(r.inputAreaWidth-u.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[u.name],n=[],a=0;a0?[0]:[]);function l(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,g(e))}if(i.enter().append("g").classed(u.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){n.select(this).selectAll("g."+u.groupClassName).each(l)}).remove(),0!==r.length){var s=i.selectAll("g."+u.groupClassName).data(r,v);s.enter().append("g").classed(u.groupClassName,!0),s.exit().each(l).remove();for(var c=0;c0||d<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[m.side];e.attr("transform","translate("+g+")")}}}P.call(E),z&&(A?P.on(".opacity",null):(k=0,T=!0,P.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),P.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("_guiRestyle",t,g,e,y):o.call("_guiRelayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(E)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return P.classed("js-placeholder",T),_}};var d=/ [XY][0-9]* /},{"../../constants/interactions":148,"../../lib":168,"../../lib/svg_text_utils":189,"../../plots/plots":245,"../../registry":257,"../color":51,"../drawing":72,d3:16,"fast-isnumeric":18}],140:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,l=t("../../plots/pad_attributes"),s=t("../../plot_api/plot_template").templatedArray,c=s("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(s("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i(l({editType:"arraydraw"}),{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":162,"../../plot_api/edit_types":195,"../../plot_api/plot_template":202,"../../plots/font_attributes":239,"../../plots/pad_attributes":244,"../color/attributes":50}],141:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],142:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,l=i.buttons;function s(t,e,r){function o(r,a){return n.coerce(t,e,i,r,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function r(r,a){return n.coerce(t,e,l,r,a)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:s})}},{"../../lib":168,"../../plots/array_container_defaults":208,"./attributes":140,"./constants":141}],143:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../plot_api/plot_template").arrayEditor,u=t("../../constants/alignment").LINE_SPACING,f=t("./constants"),d=t("./scrollbox");function p(t){return t._index}function h(t,e){return+t.attr(f.menuIndexAttrName)===e._index}function g(t,e,r,n,a,i,o,l){e.active=o,c(t.layout,f.name,e).applyUpdate("active",o),"buttons"===e.type?y(t,n,null,null,e):"dropdown"===e.type&&(a.attr(f.menuIndexAttrName,"-1"),v(t,n,a,i,e),l||y(t,n,a,i,e))}function v(t,e,r,n,a){var i=l.ensureSingle(e,"g",f.headerClassName,function(t){t.style("pointer-events","all")}),s=a._dims,c=a.active,u=a.buttons[c]||f.blankHeaderOpts,d={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},p={width:s.headerWidth,height:s.headerHeight};i.call(m,a,u,t).call(A,a,d,p),l.ensureSingle(e,"text",f.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(f.arrowSymbol[a.direction])}).attr({x:s.headerWidth-f.arrowOffsetX+a.pad.l,y:s.headerHeight/2+f.textOffsetY+a.pad.t}),i.on("click",function(){r.call(L,String(h(r,a)?-1:a._index)),y(t,e,r,n,a)}),i.on("mouseover",function(){i.call(w)}),i.on("mouseout",function(){i.call(k,a)}),o.setTranslate(e,s.lx,s.ly)}function y(t,e,r,i,o){r||(r=e).attr("pointer-events","all");var s=function(t){return-1==+t.attr(f.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?f.dropdownButtonClassName:f.buttonClassName,u=r.selectAll("g."+c).data(l.filterVisible(s)),d=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(d.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var h=0,v=0,y=o._dims,x=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(x?v=y.headerHeight+f.gapButtonHeader:h=y.headerWidth+f.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(v=-f.gapButtonHeader+f.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(h=-f.gapButtonHeader+f.gapButton-y.openWidth);var b={x:y.lx+h+o.pad.l,y:y.ly+v+o.pad.t,yPad:f.gapButton,xPad:f.gapButton,index:0},T={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(l,s){var c=n.select(this);c.call(m,o,l,t).call(A,o,b),c.on("click",function(){n.event.defaultPrevented||(g(t,o,0,e,r,i,s),l.execute&&a.executeAPICommand(t,l.method,l.args),t.emit("plotly_buttonclicked",{menu:o,button:l,active:o.active}))}),c.on("mouseover",function(){c.call(w)}),c.on("mouseout",function(){c.call(k,o),u.call(_,o)})}),u.call(_,o),x?(T.w=Math.max(y.openWidth,y.headerWidth),T.h=b.y-T.t):(T.w=b.x-T.l,T.h=Math.max(y.openHeight,y.headerHeight)),T.direction=o.direction,i&&(u.size()?function(t,e,r,n,a,i){var o,l,s,c=a.direction,u="up"===c||"down"===c,d=a._dims,p=a.active;if(u)for(l=0,s=0;s0?[0]:[]);if(o.enter().append("g").classed(f.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+f.headerGroupClassName).each(i)}).remove(),0!==r.length){var s=o.selectAll("g."+f.headerGroupClassName).data(r,p);s.enter().append("g").classed(f.headerGroupClassName,!0);for(var c=l.ensureSingle(o,"g",f.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,M=l.barLength+2*l.barPad,A=l.barWidth+2*l.barPad,L=h,S=v+y;S+A>c&&(S=c-A);var C=this.container.selectAll("rect.scrollbar-horizontal").data(T?[0]:[]);C.exit().on(".drag",null).remove(),C.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,l.barColor),T?(this.hbar=C.attr({rx:l.barRadius,ry:l.barRadius,x:L,y:S,width:M,height:A}),this._hbarXMin=L+M/2,this._hbarTranslateMax=w-M):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var O=y>k,z=l.barWidth+2*l.barPad,D=l.barLength+2*l.barPad,P=h+g,E=v;P+z>s&&(P=s-z);var R=this.container.selectAll("rect.scrollbar-vertical").data(O?[0]:[]);R.exit().on(".drag",null).remove(),R.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,l.barColor),O?(this.vbar=R.attr({rx:l.barRadius,ry:l.barRadius,x:P,y:E,width:z,height:D}),this._vbarYMin=E+D/2,this._vbarTranslateMax=k-D):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var I=this.id,N=u-.5,F=O?f+z+.5:f+.5,B=d-.5,j=T?p+A+.5:p+.5,H=o._topdefs.selectAll("#"+I).data(T||O?[0]:[]);if(H.exit().remove(),H.enter().append("clipPath").attr("id",I).append("rect"),T||O?(this._clipRect=H.select("rect").attr({x:Math.floor(N),y:Math.floor(B),width:Math.ceil(F)-Math.floor(N),height:Math.ceil(j)-Math.floor(B)}),this.container.call(i.setClipUrl,I,this.gd),this.bg.attr({x:h,y:v,width:g,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),T||O){var q=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));T&&this.hbar.on(".drag",null).call(V),O&&this.vbar.on(".drag",null).call(V)}this.setTranslate(e,r)},l.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},l.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},l.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},l.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,a=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,a)-r)/(a-r)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,l=i+this._vbarTranslateMax;e=(o.constrain(n.event.y,i,l)-i)/(l-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},l.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/r;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var l=e/n;this.vbar.call(i.setTranslate,t,e+l*this._vbarTranslateMax)}}},{"../../lib":168,"../color":51,"../drawing":72,d3:16}],146:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,CAP_SHIFT:.7,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],147:[function(t,e,r){"use strict";e.exports={COMPARISON_OPS:["=","!=","<",">=",">","<="],COMPARISON_OPS2:["=","<",">=",">","<="],INTERVAL_OPS:["[]","()","[)","(]","][",")(","](",")["],SET_OPS:["{}","}{"],CONSTRAINT_REDUCTION:{"=":"=","<":"<","<=":"<",">":">",">=":">","[]":"[]","()":"[]","[)":"[]","(]":"[]","][":"][",")(":"][","](":"][",")[":"]["}}},{}],148:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],149:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],150:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],151:[function(t,e,r){"use strict";r.version="1.43.0",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config")();for(var n=t("./registry"),a=r.register=n.register,i=t("./plot_api"),o=Object.keys(i),l=0;l1/3&&t.x<2/3},r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isTopAnchor=function(t){return"top"===t.yanchor||"auto"===t.yanchor&&t.y>=2/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3}},{}],154:[function(t,e,r){"use strict";var n=t("./mod"),a=n.mod,i=n.modHalf,o=Math.PI,l=2*o;function s(t){return Math.abs(t[1]-t[0])>l-1e-15}function c(t,e){return i(e-t,l)}function u(t,e){if(s(e))return!0;var r,n;e[0](n=a(n,l))&&(n+=l);var i=a(t,l),o=i+l;return i>=r&&i<=n||o>=r&&o<=n}function f(t,e,r,n,a,i,c){a=a||0,i=i||0;var u,f,d,p,h,g=s([r,n]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(u=0,f=o,d=l):r=a&&t<=i);var a,i},pathArc:function(t,e,r,n,a){return f(null,t,e,r,n,a,0)},pathSector:function(t,e,r,n,a){return f(null,t,e,r,n,a,1)},pathAnnulus:function(t,e,r,n,a,i){return f(t,e,r,n,a,i,1)}}},{"./mod":175}],155:[function(t,e,r){"use strict";var n=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function l(t){return n(t)||o(t)}function s(t,e,r){if(l(t)){if(l(t[0])){for(var n=r,a=0;aa.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,a){t%1||!n(t)||void 0!==a.min&&ta.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var a="number"==typeof t;!0!==n.strict&&a?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){a(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o.get(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(u(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var a=n.regex||c(r);"string"==typeof t&&a.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!c(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=n&&t<=a?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),y=t.charAt(0);!c||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:m);if(!k)return u;var T=k[1],M=k[3]||"1",A=Number(k[5]||1),L=Number(k[7]||0),S=Number(k[9]||0),C=Number(k[11]||0);if(c){if(2===T.length)return u;var O;T=Number(T);try{var z=v.getComponentMethod("calendars","getCal")(e);if(w){var D="i"===M.charAt(M.length-1);M=parseInt(M,10),O=z.newDate(T,z.toMonthIndex(T,M,D),A)}else O=z.newDate(T,Number(M),A)}catch(t){return u}return O?(O.toJD()-g)*f+L*d+S*p+C*h:u}T=2===T.length?(Number(T)+2e3-b)%100+b:Number(T),M-=1;var P=new Date(Date.UTC(2e3,M,A,L,S));return P.setUTCFullYear(T),P.getUTCMonth()!==M?u:P.getUTCDate()!==A?u:P.getTime()+C*h},n=r.MIN_MS=r.dateTime2ms("-9999"),a=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==u};var k=90*f,T=3*d,M=5*p;function A(t,e,r,n,a){if((e||r||n||a)&&(t+=" "+w(e,2)+":"+w(r,2),(n||a)&&(t+=":"+w(n,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=a))return u;e||(e=0);var i,o,l,c,m,x,b=Math.floor(10*s(t+.05,1)),w=Math.round(t-b/10);if(_(r)){var L=Math.floor(w/f)+g,S=Math.floor(s(t,f));try{i=v.getComponentMethod("calendars","getCal")(r).fromJD(L).formatDate("yyyy-mm-dd")}catch(t){i=y("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=n+f&&t<=a-f))return u;var e=Math.floor(10*s(t+.05,1)),r=new Date(Math.round(t-e/10));return A(i.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===u)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return l.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return l.error("unrecognized date",t),e;return t};var L=/%\d?f/g;function S(t,e,r,n){t=t.replace(L,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(a)}var C=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,a,i){if(a=_(a)&&a,!e)if("y"===r)e=i.year;else if("m"===r)e=i.month;else{if("d"!==r)return function(t,e){var r=s(t+.05,f),n=w(Math.floor(r/d),2)+":"+w(s(Math.floor(r/p),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(s(t/h,60),C[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+a}return n}(t,r)+"\n"+S(i.dayMonthYear,t,n,a);e=i.dayMonth+"\n"+i.year}return S(e,t,n,a)};var O=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=s(t,f);if(t=Math.round(t-n),r)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(r),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){l.error("invalid ms "+t+" in calendar "+r)}var c=new Date(t+O);return c.setUTCMonth(c.getUTCMonth()+e)+n-O},r.findExactDates=function(t,e){for(var r,n,a=0,i=0,l=0,s=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}function s(t,e,r,n,a){var i=n*t+a*e;if(i<0)return n*n+a*a;if(i>r){var o=n-t,l=a-e;return o*o+l*l}var s=n*e-a*t;return s*s/r}r.segmentsIntersect=l,r.segmentDistance=function(t,e,r,n,a,i,o,c){if(l(t,e,r,n,a,i,o,c))return 0;var u=r-t,f=n-e,d=o-a,p=c-i,h=u*u+f*f,g=d*d+p*p,v=Math.min(s(u,f,h,a-t,i-e),s(u,f,h,o-t,c-e),s(d,p,g,t-a,e-i),s(d,p,g,r-a,n-i));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,l){if(t===a&&l===i||(n={},a=t,i=l),n[r])return n[r];var s=t.getPointAtLength(o(r-l/2,e)),c=t.getPointAtLength(o(r+l/2,e)),u=Math.atan((c.y-s.y)/(c.x-s.x)),f=t.getPointAtLength(o(r,e)),d={x:(4*f.x+s.x+c.x)/6,y:(4*f.y+s.y+c.y)/6,theta:u};return n[r]=d,d},r.clearLocationCache=function(){a=null},r.getVisibleSegment=function(t,e,r){var n,a,i=e.left,o=e.right,l=e.top,s=e.bottom,c=0,u=t.getTotalLength(),f=u;function d(e){var r=t.getPointAtLength(e);0===e?n=r:e===u&&(a=r);var c=r.xo?r.x-o:0,f=r.ys?r.y-s:0;return Math.sqrt(c*c+f*f)}for(var p=d(c);p;){if((c+=p+r)>f)return;p=d(c)}for(p=d(f);p;){if(c>(f-=p+r))return;p=d(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(n.x-a.x)<.1&&Math.abs(n.y-a.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var a,i,o,l=(n=n||{}).pathLength||t.getTotalLength(),s=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(l)[r]?-1:1,f=0,d=0,p=l;f0?p=a:d=a,f++}return i}},{"./mod":175}],166:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],167:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],168:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../constants/numerical"),o=i.FP_SAFE,l=i.BADNUM,s=e.exports={};s.nestedProperty=t("./nested_property"),s.keyedContainer=t("./keyed_container"),s.relativeAttr=t("./relative_attr"),s.isPlainObject=t("./is_plain_object"),s.toLogRange=t("./to_log_range"),s.relinkPrivateKeys=t("./relink_private");var c=t("./array");s.isTypedArray=c.isTypedArray,s.isArrayOrTypedArray=c.isArrayOrTypedArray,s.isArray1D=c.isArray1D,s.ensureArray=c.ensureArray,s.concat=c.concat,s.maxRowLength=c.maxRowLength,s.minRowLength=c.minRowLength;var u=t("./mod");s.mod=u.mod,s.modHalf=u.modHalf;var f=t("./coerce");s.valObjectMeta=f.valObjectMeta,s.coerce=f.coerce,s.coerce2=f.coerce2,s.coerceFont=f.coerceFont,s.coerceHoverinfo=f.coerceHoverinfo,s.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,s.validate=f.validate;var d=t("./dates");s.dateTime2ms=d.dateTime2ms,s.isDateTime=d.isDateTime,s.ms2DateTime=d.ms2DateTime,s.ms2DateTimeLocal=d.ms2DateTimeLocal,s.cleanDate=d.cleanDate,s.isJSDate=d.isJSDate,s.formatDate=d.formatDate,s.incrementMonth=d.incrementMonth,s.dateTick0=d.dateTick0,s.dfltRange=d.dfltRange,s.findExactDates=d.findExactDates,s.MIN_MS=d.MIN_MS,s.MAX_MS=d.MAX_MS;var p=t("./search");s.findBin=p.findBin,s.sorterAsc=p.sorterAsc,s.sorterDes=p.sorterDes,s.distinctVals=p.distinctVals,s.roundUp=p.roundUp,s.sort=p.sort,s.findIndexOfMin=p.findIndexOfMin;var h=t("./stats");s.aggNums=h.aggNums,s.len=h.len,s.mean=h.mean,s.midRange=h.midRange,s.variance=h.variance,s.stdev=h.stdev,s.interp=h.interp;var g=t("./matrix");s.init2dArray=g.init2dArray,s.transposeRagged=g.transposeRagged,s.dot=g.dot,s.translationMatrix=g.translationMatrix,s.rotationMatrix=g.rotationMatrix,s.rotationXYMatrix=g.rotationXYMatrix,s.apply2DTransform=g.apply2DTransform,s.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");s.deg2rad=v.deg2rad,s.rad2deg=v.rad2deg,s.angleDelta=v.angleDelta,s.angleDist=v.angleDist,s.isFullCircle=v.isFullCircle,s.isAngleInsideSector=v.isAngleInsideSector,s.isPtInsideSector=v.isPtInsideSector,s.pathArc=v.pathArc,s.pathSector=v.pathSector,s.pathAnnulus=v.pathAnnulus;var y=t("./anchor_utils");s.isLeftAnchor=y.isLeftAnchor,s.isCenterAnchor=y.isCenterAnchor,s.isRightAnchor=y.isRightAnchor,s.isTopAnchor=y.isTopAnchor,s.isMiddleAnchor=y.isMiddleAnchor,s.isBottomAnchor=y.isBottomAnchor;var m=t("./geometry2d");s.segmentsIntersect=m.segmentsIntersect,s.segmentDistance=m.segmentDistance,s.getTextLocation=m.getTextLocation,s.clearLocationCache=m.clearLocationCache,s.getVisibleSegment=m.getVisibleSegment,s.findPointOnPath=m.findPointOnPath;var x=t("./extend");s.extendFlat=x.extendFlat,s.extendDeep=x.extendDeep,s.extendDeepAll=x.extendDeepAll,s.extendDeepNoArrays=x.extendDeepNoArrays;var b=t("./loggers");s.log=b.log,s.warn=b.warn,s.error=b.error;var _=t("./regex");s.counterRegex=_.counter;var w=t("./throttle");function k(t){var e={};for(var r in t)for(var n=t[r],a=0;ao?l:a(t)?Number(t):l:l},s.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},s.noop=t("./noop"),s.identity=t("./identity"),s.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},s.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},s.simpleMap=function(t,e,r,n){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,r)?a>10?(s.warn("randstr failed uniqueness"),c):t(e,r,n,(a||0)+1):c},s.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},s.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,a,i,o=t.length,l=2*o,s=2*e-1,c=new Array(s),u=new Array(o);for(r=0;r=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=o&&(a=l-1-a),i+=t[a]*c[n];u[r]=i}return u},s.syncOrAsync=function(t,e,r){var n;function a(){return s.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(a).then(void 0,s.promiseError);return r&&r(e)},s.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},s.noneOrAll=function(t,e,r){if(t){var n,a=!1,i=!0;for(n=0;n1?a+o[1]:"";if(i&&(o.length>1||l.length>4||r))for(;n.test(l);)l=l.replace(n,"$1"+i+"$2");return l+s};var A=/%{([^\s%{}:]*)(:[^}]*)?}/g,L=/^\w*$/;s.templateString=function(t,e){var r={};return t.replace(A,function(t,n){return L.test(n)?e[n]||"":(r[n]=r[n]||s.nestedProperty(e,n).get,r[n]()||"")})};var S=/^:/,C=0;s.hovertemplateString=function(t,e){var r=arguments,a={};return t.replace(A,function(t,i,o){var l,c,u;for(u=2;u=48&&o<=57,c=l>=48&&l<=57;if(s&&(n=10*n+o-48),c&&(a=10*a+l-48),!s||!c){if(n!==a)return n-a;if(o!==l)return o-l}}return a-n};var O=2e9;s.seedPseudoRandom=function(){O=2e9},s.pseudoRandom=function(){var t=O;return O=(69069*O+1)%4294967296,Math.abs(O-t)<429496729?s.pseudoRandom():O/4294967296}},{"../constants/numerical":149,"./anchor_utils":153,"./angles":154,"./array":155,"./clean_number":156,"./clear_responsive":158,"./coerce":159,"./dates":160,"./extend":162,"./filter_unique":163,"./filter_visible":164,"./geometry2d":165,"./get_graph_div":166,"./identity":167,"./is_plain_object":169,"./keyed_container":170,"./localize":171,"./loggers":172,"./make_trace_groups":173,"./matrix":174,"./mod":175,"./nested_property":176,"./noop":177,"./notifier":178,"./push_unique":181,"./regex":183,"./relative_attr":184,"./relink_private":185,"./search":186,"./stats":188,"./throttle":190,"./to_log_range":191,d3:16,"fast-isnumeric":18}],169:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],170:[function(t,e,r){"use strict";var n=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,r,i){var o,l,s;r=r||"name",i=i||"value";var c={};e&&e.length?(s=n(t,e),l=s.get()):l=t,e=e||"";var u={};if(l)for(o=0;o2)return c[e]=2|c[e],d.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],176:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,c=e.split(".");s/g),o=0;oi||c===a||cl||e&&s(t))}:function(t,e){var s=t[0],c=t[1];if(s===a||si||c===a||cl)return!1;var u,f,d,p,h,g=r.length,v=r[0][0],y=r[0][1],m=0;for(u=1;uMath.max(f,v)||c>Math.max(d,y)))if(cu||Math.abs(n(o,d))>a)return!0;return!1};i.filter=function(t,e){var r=[t[0]],n=0,a=0;function i(i){t.push(i);var l=r.length,s=n;r.splice(a+1);for(var c=s+1;c1&&i(t.pop());return{addPt:i,raw:t,filtered:r}}},{"../constants/numerical":149,"./matrix":174}],181:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ra.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function c(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,u,f=0,d=e.length,p=0,h=d>1?(e[d-1]-e[0])/(d-1):1;for(u=h>=0?r?o:l:r?c:s,t+=1e-9*h*(r?-1:1)*(h>=0?1:-1);f90&&a.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,a=e[n]-e[0]||1,i=a/(n||1)/1e4,o=[e[0]],l=0;le[l]+i&&(a=Math.min(a,e[l+1]-e[l]),o.push(e[l+1]));return{vals:o,minDiff:a}},r.roundUp=function(t,e,r){for(var n,a=0,i=e.length-1,o=0,l=r?0:1,s=r?1:0,c=r?Math.ceil:Math.floor;a0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||i;for(var r,n=1/0,a=0;ai.length)&&(o=i.length),n(e)||(e=!1),a(i[0])){for(s=new Array(o),l=0;lt.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":155,"fast-isnumeric":18}],189:[function(t,e,r){"use strict";var n=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function l(t,e){return t.node().getBoundingClientRect()[e]}var s=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var L=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&L.match(s),O=n.select(t.node().parentNode);if(!O.empty()){var z=t.attr("class")?t.attr("class").split(" ")[0]:"text";return z+="-math",O.selectAll("svg."+z).remove(),O.selectAll("g."+z+"-group").remove(),t.style("display",null).attr({"data-unformatted":L,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),i={fontSize:r};!function(t,e,r){var i,o,l,s;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),l=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+a.randstr({},64);return s=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(s.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(s.select(".MathJax_SVG").empty()||!s.select("svg").node())a.log("There was an error in the tex syntax.",t),r();else{var o=s.select("svg").node().getBoundingClientRect();r(s.select(".MathJax_SVG"),e,o)}if(s.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==l&&(MathJax.Hub.processSectionDelay=l),MathJax.Hub.Config(o)})}(S[2],i,function(n,a,i){O.selectAll("svg."+z).remove(),O.selectAll("g."+z+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return D(),void e();var s=O.append("g").classed(z+"-group",!0).attr({"pointer-events":"none","data-unformatted":L,"data-math":"Y"});s.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:z,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=l(o,"width"),f=l(o,"height"),d=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(r||l(t,"height"))/4;"y"===z[0]?(s.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===z[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===z[0]?o.attr({x:0,y:p}):o.attr({x:d,y:+t.attr("y")+p-f/2}),v&&v.call(t,s),e(s)})})):D(),t}function D(){O.empty()||(z=t.attr("class")+"-math",O.select("svg."+z).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var r,l=!1,s=[],c=-1;function u(){c++;var e=document.createElementNS(i.svg,"tspan");n.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),r=e;var a=s;if(s=[{node:e}],a.length>1)for(var l=1;l doesnt match end tag <"+t+">. Pretending it did match.",e),r=s[s.length-1].node}else a.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(r=t,s=[{node:t}]);for(var O=e.split(m),z=0;z|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},d={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},h="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,m=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,T=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function M(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&C(n)}var A=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var L={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function C(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):L[e])||t})}function O(t,e,r){var n,a,i,o=r.horizontalAlign,l=r.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-n.height}:"middle"===l?function(){return s.top+(s.height-n.height)/2}:function(){return s.top},i="right"===o?function(){return s.right-n.width}:"center"===o?function(){return s.left+(s.width-n.width)/2}:function(){return s.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:i()-c.left+"px","z-index":1e3}),this}}r.convertEntities=C,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function a(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var i=a("x",e),o=a("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},r.makeEditable=function(t,e){var r=e.gd,a=e.delegate,i=n.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function l(){!function(){var a=n.select(r).select(".svg-container"),o=a.append("div"),l=t.node().style,c=parseFloat(l.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":l.fontFamily||"Arial","font-size":c,color:e.fill||l.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(O(t,a,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=n.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),n.select(this).call(O(t,a,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(s)}(),t.style({opacity:0});var a,l=o.attr("class");(a=l?"."+l.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(a).style({opacity:0})}function s(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?l():o.on("click",l),n.rebind(t,i,"on")}},{"../constants/alignment":146,"../constants/xmlns_namespaces":150,"../lib":168,d3:16}],190:[function(t,e,r){"use strict";var n={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var i=n[t],o=Date.now();if(!i){for(var l in n)n[l].tsi.ts+e?s():i.timer=setTimeout(function(){s(),i.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)a(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],191:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":18}],192:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],193:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],194:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,a=n.layoutArrayContainers,i=n.layoutArrayRegexes,o=t.split("[")[0],l=0;l0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var i=(l.subplotsRegistry.cartesian||{}).attrRegex,s=(l.subplotsRegistry.polar||{}).attrRegex,u=(l.subplotsRegistry.ternary||{}).attrRegex,h=(l.subplotsRegistry.gl3d||{}).attrRegex,g=Object.keys(t);for(e=0;e3?(z.x=1.02,z.xanchor="left"):z.x<-2&&(z.x=-.02,z.xanchor="right"),z.y>3?(z.y=1.02,z.yanchor="bottom"):z.y<-2&&(z.y=-.02,z.yanchor="top")),p(t),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t.template&&t.template.layout&&r.cleanLayout(t.template.layout),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=x(e);r;){if(r in t)return!0;r=x(r)}return!1};var b=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&i.warn("Full array edits are incompatible with other edits",f);var m=r[""][""];if(c(m))e.set(null);else{if(!Array.isArray(m))return i.warn("Unrecognized full array edit value",f,m),!0;e.set(m)}return!g&&(d(v,y),p(t),!0)}var x,b,_,w,k,T,M,A,L=Object.keys(r).map(Number).sort(o),S=e.get(),C=S||[],O=u(y,f).get(),z=[],D=-1,P=C.length;for(x=0;xC.length-(M?0:1))i.warn("index out of range",f,_);else if(void 0!==T)k.length>1&&i.warn("Insertion & removal are incompatible with edits to the same index.",f,_),c(T)?z.push(_):M?("add"===T&&(T={}),C.splice(_,0,T),O&&O.splice(_,0,{})):i.warn("Unrecognized full object edit value",f,_,T),-1===D&&(D=_);else for(b=0;b=0;x--)C.splice(z[x],1),O&&O.splice(z[x],1);if(C.length?S||e.set(C):e.set(null),g)return!1;if(d(v,y),h!==a){var E;if(-1===D)E=L;else{for(P=Math.max(C.length,P),E=[],x=0;x=D);x++)E.push(_);for(x=D;x=t.data.length||a<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(a,n+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+r+" must be unique.")}}function E(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),P(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&P(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function R(t,e,r,n,i){!function(t,e,r,n){var a=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var i in P(t,r,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==r.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in n)||!Array.isArray(n[i])||n[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var s=function(t,e,r,n){var i,s,c,u,f,d=o.isPlainObject(n),p=[];for(var h in Array.isArray(r)||(r=[r]),r=D(r,t.data.length-1),e)for(var g=0;g-1?s(r,r.replace("titlefont","title.font")):r.indexOf("titleposition")>-1?s(r,r.replace("titleposition","title.position")):r.indexOf("titleside")>-1?s(r,r.replace("titleside","title.side")):r.indexOf("titleoffset")>-1&&s(r,r.replace("titleoffset","title.offset")):s(r,r.replace("title","title.text"));function s(e,r){t[r]=t[e],delete t[e]}}function V(t,e,r){if(t=o.getGraphDiv(t),k.clearPromiseQueue(t),t.framework&&t.framework.isPolar)return Promise.resolve(t);var n={};if("string"==typeof e)n[e]=r;else{if(!o.isPlainObject(e))return o.warn("Relayout fail.",e,r),Promise.reject();n=o.extendFlat({},e)}Object.keys(n).length&&(t.changed=!0);var a=W(t,n),i=a.flags;i.calc&&(t.calcdata=void 0);var l=[d.previousPromises];i.layoutReplot?l.push(T.layoutReplot):Object.keys(n).length&&(U(t,i,a)||d.supplyDefaults(t),i.legend&&l.push(T.doLegend),i.layoutstyle&&l.push(T.layoutStyles),i.axrange&&G(l,a.rangesAltered),i.ticks&&l.push(T.doTicksRelayout),i.modebar&&l.push(T.doModeBar),i.camera&&l.push(T.doCamera),l.push(S)),l.push(d.rehover),c.add(t,V,[t,a.undoit],V,[t,a.redoit]);var s=o.syncOrAsync(l,t);return s&&s.then||(s=Promise.resolve(t)),s.then(function(){return t.emit("plotly_relayout",a.eventData),t})}function U(t,e,r){var n;if(!e.axrange)return!1;for(n in e)if("axrange"!==n&&e[n])return!1;for(n in r.rangesAltered){var a=h.id2name(n),i=t.layout[a],o=t._fullLayout[a];o.autorange=i.autorange,o.range=i.range.slice(),o.cleanRange()}return!0}function G(t,e){var r=e?function(t){var r={skipTitle:!0};for(var n in e)if(h.getFromId(t,n).automargin){r={};break}return h.draw(t,Object.keys(e),r)}:function(t){return h.draw(t,"redraw")};t.push(T.doAutoRangeAndConstraints,r,T.drawData,T.finalDraw)}r.plot=function(t,e,a,i){var l;if(t=o.getGraphDiv(t),s.init(t),o.isPlainObject(e)){var c=e;e=c.data,a=c.layout,i=c.config,l=c.frames}if(!1===s.triggerHandler(t,"plotly_beforeplot",[e,a,i]))return Promise.reject();e||a||o.isPlotDiv(t)||o.warn("Calling Plotly.plot as if redrawing but this container doesn't yet have a plot.",t),z(t,i),a||(a={}),n.select(t).classed("js-plotly-plot",!0),g.makeTester(),Array.isArray(t._promises)||(t._promises=[]);var f=0===(t.data||[]).length&&Array.isArray(e);if(Array.isArray(e)&&(k.cleanData(e),f?t.data=e:t.data.push.apply(t.data,e),t.empty=!1),t.layout&&!f||(t.layout=k.cleanLayout(a)),t._dragging&&!t._transitioning)return t._replotPending=!0,Promise.reject();t._replotPending=!1,d.supplyDefaults(t);var v=t._fullLayout,x=v._has("cartesian");if(!v._has("polar")&&e&&e[0]&&e[0].r)return o.log("Legacy polar charts are deprecated!"),function(t,e,r){var a=n.select(t).selectAll(".plot-container").data([0]);a.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=a.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e);r&&(t.layout=r);p.manager.fillLayout(t),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=p.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var l=t.framework.svg(),s=1,c=t._fullLayout.title?t._fullLayout.title.text:"";""!==c&&c||(s=0);var u=function(){this.call(b.convertToTspans,t)},f=l.select(".title-group text").call(u);if(t._context.edits.titleText){var h=o._(t,"Click to enter Plot title");c&&c!==h||(s=.2,f.attr({"data-unformatted":h}).text(h).style({opacity:s}).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)}));var g=function(){this.call(b.makeEditable,{gd:t}).on("edit",function(e){t.framework({layout:{title:{text:e}}}),this.text(e).call(u),this.call(g)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(u)})};f.call(g)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),d.addLinks(t),Promise.resolve()}(t,e,a);v._replotting=!0,f&<(t),t.framework!==lt&&(t.framework=lt,lt(t)),g.initGradients(t),f&&h.saveShowSpikeInitial(t);var _=!t.calcdata||t.calcdata.length!==(t._fullData||[]).length;_&&d.doCalcdata(t);for(var w=0;w=0&&r=0&&r0&&"string"!=typeof P.parts[R];)R--;var I=P.parts[R],N=P.parts[R-1]+"."+I,j=P.parts.slice(0,R).join("."),H=l(t.layout,j).get(),V=l(s,j).get(),U=P.get();if(void 0!==E){T[D]=E,L[D]="reverse"===I?E:F(U);var G=f.getLayoutValObject(s,P.parts);if(G&&G.impliedEdits&&null!==E)for(var W in G.impliedEdits)S(o.relativeAttr(D,W),G.impliedEdits[W]);if(-1!==["width","height"].indexOf(D))if(E){S("autosize",null);var $="height"===D?"width":"height";S($,s[$])}else s[D]=t._initialAutoSize[D];else if("autosize"===D)S("width",E?null:s.width),S("height",E?null:s.height);else if(N.match(Z))z(N),l(s,j+"._inputRange").set(null);else if(N.match(X)){z(N),l(s,j+"._inputRange").set(null);var Q=l(s,j).get();Q._inputDomain&&(Q._input.domain=Q._inputDomain.slice())}else N.match(Y)&&l(s,j+"._inputDomain").set(null);if("type"===I){var K=H,tt="linear"===V.type&&"log"===E,et="log"===V.type&&"linear"===E;if(tt||et){if(K&&K.range)if(V.autorange)tt&&(K.range=K.range[1]>K.range[0]?[1,2]:[2,1]);else{var rt=K.range[0],nt=K.range[1];tt?(rt<=0&&nt<=0&&S(j+".autorange",!0),rt<=0?rt=nt/1e6:nt<=0&&(nt=rt/1e6),S(j+".range[0]",Math.log(rt)/Math.LN10),S(j+".range[1]",Math.log(nt)/Math.LN10)):(S(j+".range[0]",Math.pow(10,rt)),S(j+".range[1]",Math.pow(10,nt)))}else S(j+".autorange",!0);Array.isArray(s._subplots.polar)&&s._subplots.polar.length&&s[P.parts[0]]&&"radialaxis"===P.parts[1]&&delete s[P.parts[0]]._subplot.viewInitial["radialaxis.range"],u.getComponentMethod("annotations","convertCoords")(t,V,E,S),u.getComponentMethod("images","convertCoords")(t,V,E,S)}else S(j+".autorange",!0),S(j+".range",null);l(s,j+"._inputRange").set(null)}else if(I.match(A)){var at=l(s,D).get(),it=(E||{}).type;it&&"-"!==it||(it="linear"),u.getComponentMethod("annotations","convertCoords")(t,at,it,S),u.getComponentMethod("images","convertCoords")(t,at,it,S)}var ot=w.containerArrayMatch(D);if(ot){r=ot.array,n=ot.index;var lt=ot.property,st=G||{editType:"calc"};""!==n&&""===lt&&(w.isAddVal(E)?L[D]=null:w.isRemoveVal(E)?L[D]=(l(i,r).get()||[])[n]:o.warn("unrecognized full object value",e)),M.update(_,st),y[r]||(y[r]={});var ct=y[r][n];ct||(ct=y[r][n]={}),ct[lt]=E,delete e[D]}else"reverse"===I?(H.range?H.range.reverse():(S(j+".autorange",!0),H.range=[1,0]),V.autorange?_.calc=!0:_.plot=!0):(s._has("scatter-like")&&s._has("regl")&&"dragmode"===D&&("lasso"===E||"select"===E)&&"lasso"!==U&&"select"!==U?_.plot=!0:G?M.update(_,G):_.calc=!0,P.set(E))}}for(r in y){w.applyContainerArrayChanges(t,d(i,r),y[r],_,d)||(_.plot=!0)}var ut=s._axisConstraintGroups||[];for(C in O)for(n=0;n1;)if(n.pop(),void 0!==(r=l(e,n.join(".")+".uirevision").get()))return r;return e.uirevision}function nt(t,e){for(var r=0;r=a.length?a[0]:a[t]:a}function s(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function c(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(i,u){function f(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,d.transition(t,e.frame.data,e.frame.layout,k.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function p(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&f()};e()}var h,g,v=0;function y(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var m=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))m.push({type:"object",data:y(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(h=0;h0&&TT)&&M.push(g);m=M}}m.length>0?function(e){if(0!==e.length){for(var a=0;a=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(u[g]||h[g]||{}).name,y=e[n].name,m=u[v]||h[v];v&&y&&"number"==typeof y&&m&&L<5&&(L++,o.warn('addFrames: overwriting frame "'+(u[v]||h[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===L&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),h[g]={name:g},p.push({frame:d.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:f+n})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(a=p[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;u[a.name="frame "+t._transitionData._counter++];);if(u[a.name]){for(i=0;i=0;r--)n=e[r],i.push({type:"delete",index:n}),l.unshift({type:"insert",index:n,value:a[n]});var s=d.modifyFrames,u=d.modifyFrames,f=[t,l],p=[t,i];return c&&c.add(t,s,f,u,p),d.modifyFrames(t,i)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return d.cleanPlot([],{},r,e),d.purge(t),s.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":51,"../components/colorbar/connect":53,"../components/drawing":72,"../constants/xmlns_namespaces":150,"../lib":168,"../lib/events":161,"../lib/queue":182,"../lib/svg_text_utils":189,"../plots/cartesian/axes":212,"../plots/cartesian/constants":218,"../plots/cartesian/graph_interact":222,"../plots/plots":245,"../plots/polar/legacy":248,"../registry":257,"./edit_types":195,"./helpers":196,"./manage_arrays":198,"./plot_config":200,"./plot_schema":201,"./subroutines":203,d3:16,"fast-isnumeric":18,"has-hover":20}],200:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,showSendToCloud:!1,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,watermark:!1,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],201:[function(t,e,r){"use strict";var n=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),l=t("../plots/frame_attributes"),s=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),d=a.extendFlat,p=a.extendDeepAll,h=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",y=[g,v,"_arrayAttrRegexps","_deprecated"];function m(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(x(e[r]))r++;else if(r=i.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!x(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):h(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(h(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=s.length)return!1;a=(r=(n.transformsRegistry[s[u].type]||{}).attributes)&&r[e[2]],l=3}else if("area"===t.type)a=c[o];else{var f=t._module;if(f||(f=(n.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(r=f.attributes)&&r[o])){var d=f.basePlotModule;d&&d.attributes&&(a=d.attributes[o])}a||(a=i[o])}return m(a,e,l)},r.getLayoutValObject=function(t,e){return m(function(t,e){var r,a,i,l,s=t._basePlotModules;if(s){var c;for(r=0;r=a&&(r._input||{})._templateitemname;l&&(o=a);var s,c=e+"["+o+"]";function u(){s={},l&&(s[c]={},s[c][i]=l)}function f(t,e){l?n.nestedProperty(s[c],t).set(e):s[c+"."+t]=e}function d(){var t=s;return u(),t}return u(),{modifyBase:function(t,e){s[t]=e},modifyItem:f,getUpdateObj:d,applyUpdate:function(e,r){e&&f(e,r);var a=d();for(var i in a)n.nestedProperty(t,i).set(a[i])}}}},{"../lib":168,"../plots/attributes":209}],203:[function(t,e,r){"use strict";var n=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),l=t("../lib/clear_gl_canvases"),s=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),d=t("../plots/cartesian/axes"),p=t("../constants/alignment"),h=t("../plots/cartesian/constraints"),g=h.enforce,v=h.clean,y=t("../plots/cartesian/autorange").doAutoRange,m="start",x="middle",b="end";function _(t,e,r){for(var n=0;n=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function w(t){var e,a,i,l,u,h,g=t._fullLayout,v=g._size,y=v.p,m=d.list(t,"",!0);if(g._paperdiv.style({width:t._context.responsive&&g.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":g.width+"px",height:t._context.responsive&&g.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":g.height+"px"}).selectAll(".main-svg").call(c.setSize,g.width,g.height),t._context.setBackground(t,g.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!g._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-y-n:e._offset+e._length+y+n:v.t+v.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+y+n:e._offset-y-n:v.l+v.w*(t.position||0)+n%1}for(e=0;ek?u.push({code:"unused",traceType:m,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:m,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var i=e[n],o=p(e,n,r);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&u.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&h(i)&&t(i,o)}}({data:v,layout:d},""),u.length)return u.map(g)}},{"../lib":168,"../plots/attributes":209,"../plots/plots":245,"./plot_config":200,"./plot_schema":201,"./plot_template":202}],205:[function(t,e,r){"use strict";var n=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),l=t("../snapshot/svgtoimg"),s={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,u,f;function d(t){return!(t in e)||a.validate(e[t],s[t])}if(e=e||{},a.isPlainObject(t)?(r=t.data||[],u=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),r=a.extendDeep([],t.data),u=a.extendDeep({},t.layout),f=t._context),!d("width")||!d("height"))throw new Error("Height and width should be pixel values.");if(!d("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function h(t,r){return a.coerce(e,p,s,t,r)}var g=h("format"),v=h("width"),y=h("height"),m=h("scale"),x=h("setBackground"),b=h("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},u);v&&(w.width=v),y&&(w.height=y);var k=a.extendFlat({},f,{_exportedPlot:!0,staticPlot:!0,setBackground:x}),T=i.getRedrawFunc(_);function M(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function A(){return new Promise(function(t,e){var r=o(_,g,m),i=_._fullLayout.width,s=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(b?r:"data:image/svg+xml,"+encodeURIComponent(r));var c=document.createElement("canvas");c.id=a.randstr(),l({format:g,width:i,height:s,scale:m,canvas:c,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,k).then(T).then(M).then(A).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":168,"../snapshot/helpers":261,"../snapshot/svgtoimg":263,"../snapshot/tosvg":265,"./plot_api":199}],206:[function(t,e,r){"use strict";var n=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),l=n.isPlainObject,s=Array.isArray,c=n.isArrayOrTypedArray;function u(t,e,r,a,i,o){o=o||[];for(var f=Object.keys(t),d=0;dx.length&&a.push(p("unused",i,y.concat(x.length)));var T,M,A,L,S,C=x.length,O=Array.isArray(k);if(O&&(C=Math.min(C,k.length)),2===b.dimensions)for(M=0;Mx[M].length&&a.push(p("unused",i,y.concat(M,x[M].length)));var z=x[M].length;for(T=0;T<(O?Math.min(z,k[M].length):z);T++)A=O?k[M][T]:k,L=m[M][T],S=x[M][T],n.validate(L,A)?S!==L&&S!==+L&&a.push(p("dynamic",i,y.concat(M,T),L,S)):a.push(p("value",i,y.concat(M,T),L))}else a.push(p("array",i,y.concat(M),m[M]));else for(M=0;M1&&d.push(p("object","layout"))),a.supplyDefaults(h);for(var g=h._fullData,v=r.length,y=0;y0&&((b=M-o(v)-o(y))>A?_/b>L&&(m=v,x=y,L=_/b):_/M>L&&(m={val:v.val,pad:0},x={val:y.val,pad:0},L=_/M));if(d===p){var S=d-1,C=d+1;if(k)if(0===d)i=[0,1];else{var O=(d>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),z=d/(1-Math.min(.5,O/M));i=d>0?[0,z]:[z,0]}else i=T?[Math.max(0,S),Math.max(1,C)]:[S,C]}else k?(m.val>=0&&(m={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):T&&(m.val-L*o(m)<0&&(m={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),L=(x.val-m.val)/(M-o(m)-o(x)),i=[m.val-L*o(m),x.val+L*o(x)];return h&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function s(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function c(t,e){var r,n,a,i=e._id,o=t._fullData,l=t._fullLayout,s=[],c=[];function d(t,e){for(r=0;r=r&&(c.extrapad||!o)){l=!1;break}a(e,c.val)&&c.pad<=r&&(o||!c.extrapad)&&(t.splice(s,1),s--)}if(l){var u=i&&0===e;t.push({val:e,pad:u?0:r,extrapad:!u&&o})}}function p(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:l,makePadFn:s,doAutoRange:function(t,e){if(e.autorange){e.range=l(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l);var r=e._input,n={};n[e._attr+".range"]=e.range,n[e._attr+".autorange"]=e.autorange,o.call("_storeDirectGUIEdit",t.layout,t._fullLayout._preGUI,n),r.range=e.range.slice(),r.autorange=e.autorange}var i=e._anchorAxis;if(i&&i.rangeslider){var s=i.rangeslider[e._name];s&&"auto"===s.rangemode&&(s.range=l(t,e)),i._input.rangeslider[e._name]=a.extendFlat({},s)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var a,o,l,s,c,d,h,g,v,y=[],m=[],x=e.length,b=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function T(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var M=T((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),A=T((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),L=T(r.vpadplus||r.vpad),S=T(r.vpadminus||r.vpad);if(!k){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=z;a--)O(a);return{min:y,max:m}},concatExtremes:c}},{"../../constants/numerical":149,"../../lib":168,"../../registry":257,"fast-isnumeric":18}],212:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),d=t("./layout_attributes"),p=t("./clean_ticks"),h=t("../../constants/numerical"),g=h.ONEAVGYEAR,v=h.ONEAVGMONTH,y=h.ONEDAY,m=h.ONEHOUR,x=h.ONEMIN,b=h.ONESEC,_=h.MINUS_SIGN,w=h.BADNUM,k=t("../../constants/alignment").MID_SHIFT,T=t("../../constants/alignment").LINE_SPACING,M=e.exports={};M.setConvert=t("./set_convert");var A=t("./axis_autotype"),L=t("./axis_ids");M.id2name=L.id2name,M.name2id=L.name2id,M.cleanId=L.cleanId,M.list=L.list,M.listIds=L.listIds,M.getFromId=L.getFromId,M.getFromTrace=L.getFromTrace;var S=t("./autorange");M.getAutoRange=S.getAutoRange,M.findExtremes=S.findExtremes,M.coerceRef=function(t,e,r,n,a,i){var o=n.charAt(n.length-1),s=r._fullLayout._subplots[o+"axis"],c=n+"ref",u={};return a||(a=s[0]||i),i||(i=a),u[c]={valType:"enumerated",values:s.concat(i?[i]:[]),dflt:a},l.coerce(t,e,u,c)},M.coercePosition=function(t,e,r,n,a,i){var o,s;if("paper"===n||"pixel"===n)o=l.ensureNumber,s=r(a,i);else{var c=M.getFromId(e,n);s=r(a,i=c.fraction2r(i)),o=c.cleanPos}t[a]=o(s)},M.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?l.ensureNumber:M.getFromId(e,r).cleanPos)(t)};var C=M.getDataConversions=function(t,e,r,n){var a,i="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(i)){if(a={type:A(n),_categories:[]},M.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},M.saveRangeInitial=function(t,e){for(var r=M.list(t,"",!0),n=!1,a=0;a.3*d||u(n)||u(i))){var p=r.dtick/2;t+=t+p.8){var o=Number(r.substr(1));i.exactYears>.8&&o%12==0?t=M.tickIncrement(t,"M6","reverse")+1.5*y:i.exactMonths>.8?t=M.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var s=M.tickIncrement(t,r);if(s<=n)return s}return t}(x,t,m,c,i)),v=x,0;v<=u;)v=M.tickIncrement(v,m,!1,i),0;return{start:e.c2r(x,0,i),end:e.c2r(v,0,i),size:m,_dataSpan:u-c}},M.prepTicks=function(t){var e=l.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type||"multicategory"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=l.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),M.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},M.calcTicks=function(t){M.prepTicks(t);var e=l.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e=t.tickvals,r=t.ticktext,n=new Array(e.length),a=l.simpleMap(t.range,t.r2l),i=1.0001*a[0]-1e-4*a[1],o=1.0001*a[1]-1e-4*a[0],s=Math.min(i,o),c=Math.max(i,o),u=0;Array.isArray(r)||(r=[]);var f="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(var d=0;ds&&p=n:c<=n)&&!(i.length>s||c===o);c=M.tickIncrement(c,t.dtick,a,t.calendar))o=c,i.push(c);et(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(i.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&i<=10||e>=15*y)t._tickround="d";else if(e>=x&&i<=16||e>=m)t._tickround="M";else if(e>=b&&i<=19||e>=x)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var l=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var s=Math.max(Math.abs(l[0]),Math.abs(l[1])),c=Math.floor(Math.log(s)/Math.LN10+.01);Math.abs(c)>3&&(V(t.exponentformat)&&!U(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function H(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}M.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=l.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,r=n(10),t.dtick="M"+12*B(e,r,D)):i>v?(e/=v,t.dtick="M"+B(e,1,P)):i>y?(t.dtick=B(e,y,R),t.tick0=l.dateTick0(t.calendar,!0)):i>m?t.dtick=B(e,m,P):i>x?t.dtick=B(e,x,E):i>b?t.dtick=B(e,b,E):(r=n(10),t.dtick=B(e,r,D))}else if("log"===t.type){t.tick0=0;var o=l.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var s=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/s,r=n(10),t.dtick="L"+B(e,r,D)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type||"multicategory"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):et(t)?(t.tick0=0,r=1,t.dtick=B(e,r,F)):(t.tick0=0,r=n(10),t.dtick=B(e,r,D));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},M.tickIncrement=function(t,e,r,i){var o=r?-1:1;if(a(e))return t+o*e;var s=e.charAt(0),c=o*Number(e.substr(1));if("M"===s)return l.incrementMonth(t,c,i);if("L"===s)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===s){var u="D2"===e?N:I,f=t+.01*o,d=l.roundUp(l.mod(f,1),u,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(e)},M.tickFirst=function(t){var e=t.r2l||Number,r=l.simpleMap(t.range,e),i=r[1]"+s,t._prevDateHead=s));e.text=c}(t,i,r,s):"log"===c?function(t,e,r,n,i){var o=t.dtick,s=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===i&&(i="");n&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,s),t,i,n);else if(a(o)||"D"===u&&l.mod(s+.01,1)<.1){var f=Math.round(s),d=Math.abs(f),p=t.exponentformat;"power"===p||V(p)&&U(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+d+"",e.fontSize*=1.25):("e"===p||"E"===p)&&d>2?e.text="1"+p+(f>0?"+":_)+d:(e.text=G(Math.pow(10,s),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,l.mod(s,1)))),e.fontSize*=.75}if("D1"===t.dtick){var h=String(e.text).charAt(0);"0"!==h&&"1"!==h||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(s<0?.5:.25)))}}(t,i,0,s,h):"category"===c?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,i):"multicategory"===c?function(t,e,r){var n=Math.round(e.x),a=t._categories[n]||[],i=void 0===a[1]?"":String(a[1]),o=void 0===a[0]?"":String(a[0]);r?e.text=o+" - "+i:(e.text=i,e.text2=o)}(t,i,r):et(t)?function(t,e,r,n,a){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,a,n);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,a=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/a),Math.round(r/a)]}(i);if(o[1]>=100)e.text=G(l.deg2rad(e.x),t,a,n);else{var s=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),s&&(e.text=_+e.text)}}}}(t,i,r,s,h):function(t,e,r,n,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,n)}(t,i,0,s,h),t.tickprefix&&!p(t.showtickprefix)&&(i.text=t.tickprefix+i.text),t.ticksuffix&&!p(t.showticksuffix)&&(i.text+=t.ticksuffix),"boundaries"===t.tickson||t.showdividers){var g=function(e){var r=t.l2p(e);return r>=0&&r<=t._length?e:null};i.xbnd=[g(i.x-.5),g(i.x+t.dtick-.5)]}return i},M.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return M.hoverLabelText(t,e)+" - "+M.hoverLabelText(t,r);var n="log"===t.type&&e<=0,a=M.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+a:a};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function V(t){return"SI"===t||"B"===t}function U(t){return t>14||t<-15}function G(t,e,r,n){var i=t<0,o=e._tickround,s=r||e.exponentformat||"B",c=e._tickexponent,u=M.getTickFormat(e),f=e.separatethousands;if(n){var d={exponentformat:s,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(d),o=(Number(d._tickround)||0)+4,c=d._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,h=Math.pow(10,-o)/2;if("none"===s&&(c=0),(t=Math.abs(t))"+p+"":"B"===s&&9===c?t+="B":V(s)&&(t+=q[c/3+5]));return i?_+t:t}function Z(t,e){var r=t._id.charAt(0),n=t._tickAngles[e]||0,a=l.deg2rad(n),i=Math.sin(a),o=Math.cos(a),s=0,c=0;return t._selections[e].each(function(){var t=W(this),e=f.bBox(t.node()),r=e.width,n=e.height;s=Math.max(s,o*r,i*n),c=Math.max(c,i*r,o*n)}),{x:c,y:s}[r]}function X(t){return[t.text,t.x,t.axInfo,t.font,t.fontSize,t.fontColor].join("_")}function Y(t,e){var r=t.l2p(e);return r>1&&r=0,i=u(t,e[1])<=0;return(r||a)&&(n||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},l=0;l2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":257,"./constants":218}],216:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var l,s=r("categoryorder",a);"array"===s&&(l=r("categoryarray")),o||"array"!==s||(s=e.categoryorder="trace"),"trace"===s?e._initialCategories=[]:"array"===s?e._initialCategories=l.slice():(l=function(t,e){var r,n,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;nl*x)||k)for(r=0;rP&&Iz&&(z=I);p/=(z-O)/(2*D),O=u.l2r(O),z=u.l2r(z),u.range=u._input.range=L=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function E(t,e,r,n,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",a+"Z")}function R(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function I(t,e,r,n,a,i){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),N(t,e,a,i)}function N(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function B(t){L&&t.data&&t._context.showTips&&(l.notifier(l._(t,"Double-click to zoom back out"),"long"),L=!1)}function j(t){return"lasso"===t||"select"===t}function H(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,A)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(i){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function V(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,i,c,p,L,S){var N,U,G,Z,X,Y,W,J,$,Q,K,tt,et,rt,nt,at,it,ot,lt,st,ct,ut=t._fullLayout._zoomlayer,ft=L+S==="nsew",dt=1===(L+S).length;function pt(){if(N=e.xaxis,U=e.yaxis,$=N._length,Q=U._length,W=N._offset,J=U._offset,(G={})[N._id]=N,(Z={})[U._id]=U,L&&S)for(var r=e.overlays,n=0;n-1&&w(a,t,X,Y,e.id,At),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===r&&dt){var l=L?U:N,c="s"===L||"w"===S?0:1,u=l._name+".range["+c+"]",d=function(t,e){var r,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,a))):(r=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,n.format("."+String(r)+"g")(a))}(l,c),p="left",h="middle";if(l.fixedrange)return;L?(h="n"===L?"top":"bottom","right"===l.side&&(p="right")):"e"===S&&(p="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(s.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(d),fill:l.tickfont?l.tickfont.color:"#444",horizontalAlign:p,verticalAlign:h}).on("edit",function(e){var r=l.d2r(e);void 0!==r&&o.call("_guiRelayout",t,u,r)})}}function Ct(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min($,e+vt)),a=Math.max(0,Math.min(Q,r+yt)),i=Math.abs(n-vt),o=Math.abs(a-yt);function l(){wt="",mt.r=mt.l,mt.t=mt.b,Tt.attr("d","M0,0Z")}mt.l=Math.min(vt,n),mt.r=Math.max(vt,n),mt.t=Math.min(yt,a),mt.b=Math.max(yt,a),nt?i>A||o>A?(wt="xy",i/$>o/Q?(o=i*Q/$,yt>a?mt.t=yt-o:mt.b=yt+o):(i=o*$/Q,vt>n?mt.l=vt-i:mt.r=vt+i),Tt.attr("d",H(mt))):l():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Et);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var a,i=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=It.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(at){for(S||(s=.5),a=0;ag[1]-.01&&(e.domain=l),a.noneOrAll(t.domain,e.domain,l)}return r("layer"),e}},{"../../lib":168,"fast-isnumeric":18}],229:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*r;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":146}],230:[function(t,e,r){"use strict";var n=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),l=t("../../lib/polygon"),s=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),d=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),h=p.MINSELECT,g=l.filter,v=l.tester;function y(t){return t._id}function m(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h,g,v=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,m=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var x=function(t,e){var r,n,a=t[0],i=-1,o=[];for(n=0;n0?function(t,e){var r,n,a,i=[];for(a=0;a0&&i.push(r);if(1===i.length&&i[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=r.selectedpoints.length)>1)return!1}return 1===a}(l)&&(d=A(x))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",n)}function A(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,a=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function L(t,e,r){var n,i,o,l;for(n=0;n-1&&m(e,A,a.xaxes,a.yaxes,a.subplot,a,U),"event"===r&&A.emit("plotly_selected",void 0);o.click(A,e)})},a.doneFn=function(){Z.remove(),s.done(X).then(function(){s.clear(X),a.gd.emit("plotly_selected",b),d&&a.selectionDefs&&(d.subtract=V,a.selectionDefs.push(d),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:C,selectOnClick:m}},{"../../components/color":51,"../../components/fx":90,"../../components/fx/helpers":86,"../../lib/clear_gl_canvases":157,"../../lib/polygon":180,"../../lib/throttle":190,"../../plot_api/subroutines":203,"../../registry":257,"./axis_ids":215,"./constants":218,polybooljs:25}],231:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,l=i.ms2DateTime,s=i.dateTime2ms,c=i.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,d=u.BADNUM,p=u.LOG_CLIP,h=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}function y(t){return null!=t}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function u(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],a=t.range[1];return.5*(n+a-2*p*Math.abs(n-a))}return d}function m(e,r,n){var o=s(e,n||t.calendar);if(o===d){if(!a(e))return d;e=+e;var l=Math.floor(10*i.mod(e+.05,1)),c=Math.round(e-l/10);o=s(new Date(c))+l/10}return o}function x(e,r,n){return l(e,r,n||t.calendar)}function b(e){return t._categories[Math.round(e)]}function _(e){if(y(e)){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return d}function w(e){if(t._categoriesMap)return t._categoriesMap[e]}function k(t){var e=w(t);return void 0!==e?e:a(t)?+t:void 0}function T(e){return a(e)?n.round(t._b+t._m*e,2):d}function M(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=T,t.p2l=M,t.c2p="log"===t.type?function(t,e){return T(u(t,e))}:T,t.p2c="log"===t.type?function(t){return v(M(t))}:M,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=M,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(M(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=M,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=m,t.c2d=t.c2r=t.l2d=t.l2r=x,t.d2p=t.r2p=function(e,r,n){return t.l2p(m(e,0,n))},t.p2d=t.p2r=function(t,e,r){return x(M(t),e,r)},t.cleanPos=function(e){return i.cleanDate(e,d,t.calendar)}):"category"===t.type?(t.d2c=t.d2l=_,t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var r=k(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(M(t))},t.r2p=t.d2p,t.p2r=M,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}):"multicategory"===t.type&&(t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var r=k(e);return void 0!==r?r:t.fraction2r(.5)},t.r2c_just_indices=w,t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(M(t))},t.r2p=t.d2p,t.p2r=M,t.cleanPos=function(t){return Array.isArray(t)||"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,l,s=i.nestedProperty(t,e).get();if(l=(l="date"===t.type?i.dfltRange(t.calendar):"y"===r?h.DFLTRANGEY:n.dfltRange||h.DFLTRANGEX).slice(),s&&2===s.length)for("date"===t.type&&(s[0]=i.cleanDate(s[0],d,t.calendar),s[1]=i.cleanDate(s[1],d,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(s[o],t.calendar)){t[e]=l;break}if(t.r2l(s[0])===t.r2l(s[1])){var c=i.constrain(t.r2l(s[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);s[0]=t.l2r(c-1e3),s[1]=t.l2r(c+1e3);break}}else{if(!a(s[o])){if(!a(s[1-o])){t[e]=l;break}s[o]=s[1-o]*(o?10:.1)}if(s[o]<-f?s[o]=-f:s[o]>f&&(s[o]=f),s[0]===s[1]){var u=Math.max(1,Math.abs(1e-6*s[0]));s[0]-=u,s[1]+=u}}else i.nestedProperty(t,e).set(l)},t.setScale=function(n){var a=e._size;if(t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=n&&t._r?"_r":"range",l=t.calendar;t.cleanRange(o);var s=t.r2l(t[o][0],l),c=t.r2l(t[o][1],l);if("y"===r?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-c),t._b=-t._m*c):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,a,o,l,s=t.type,c="date"===s&&e[r+"calendar"];if(r in e){if(n=e[r],l=e._length||i.minRowLength(n),i.isTypedArray(n)&&("linear"===s||"log"===s)){if(l===n.length)return n;if(n.subarray)return n.subarray(0,l)}if("multicategory"===s)return function(t,e){var r,n=new Array(e),a=new Array(e),o=[[0,{}],[0,{}]];if(i.isArrayOrTypedArray(t[0])&&i.isArrayOrTypedArray(t[1])){for(r=0;r rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,r._offset).call(i.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(i.setPointGroupScale,1,1),n.selectAll(".textpoint").call(i.setTextPointsScale,1,1),n.call(i.hideOutsideRangePoints,t)}function x(e,r){var n,l,s,u=g[e.xaxis._id],f=g[e.yaxis._id],d=[];if(u){l=(n=t._fullLayout[u.axisName])._r,s=u.to,d[0]=(l[0]*(1-r)+r*s[0]-l[0])/(l[1]-l[0])*e.xaxis._length;var p=l[1]-l[0],h=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[2]=e.xaxis._length*(1-r+r*h/p)}else d[0]=0,d[2]=e.xaxis._length;if(f){l=(n=t._fullLayout[f.axisName])._r,s=f.to,d[1]=(l[1]*(1-r)+r*s[1]-l[1])/(l[0]-l[1])*e.yaxis._length;var v=l[1]-l[0],y=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[3]=e.yaxis._length*(1-r+r*y/v)}else d[1]=0,d[3]=e.yaxis._length;!function(e,r){var n,i=[e._id,r._id];function l(e,r,a){for(n=0;nr.duration?(function(){for(var e={},r=0;r0&&(a["_"+r+"axes"]||{})[e])return a;if((a[r+"axis"]||r)===e){if(o(a,r))return a;if((a[r]||[]).length||a[r+"0"])return a}}}(e,r,l);if(!s)return;if("histogram"===s.type&&l==={v:"y",h:"x"}[s.orientation||"v"])return void(t.type="linear");var c,u=l+"calendar",f=s[u],d={noMultiCategory:!n(s,"cartesian")||n(s,"noMultiCategory")};if(o(s,l)){var p=i(s),h=[];for(c=0;c0?".":"")+i;a.isPlainObject(o)?s(o,e,l,n+1):e(l,i,o)}})}r.manageCommandObserver=function(t,e,n,o){var l={},s=!0;e&&e._commandObserver&&(l=e._commandObserver),l.cache||(l.cache={}),l.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,n,l.lookupTable);if(e&&e._commandObserver){if(c)return l;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,l}if(c){i(t,c,l.cache),l.check=function(){if(s){var e=i(t,c,l.cache);return e.changed&&o&&void 0!==l.lookupTable[e.value]&&(l.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:l.lookupTable[e.value]})).then(l.enable,l.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;f=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),r.attr(i);var o=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),a=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+a})}}(t,o),l.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),a=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,a={};function o(t){for(var r=!0,i=0;i1&&P.length>1){for(i.getComponentMethod("grid","sizeDefaults")(c,l),o=0;o15&&P.length>15&&0===l.shapes.length&&0===l.images.length,l._hasCartesian=l._has("cartesian"),l._hasGeo=l._has("geo"),l._hasGL3D=l._has("gl3d"),l._hasGL2D=l._has("gl2d"),l._hasTernary=l._has("ternary"),l._hasPie=l._has("pie"),v.linkSubplots(f,l,u,a),v.cleanPlot(f,l,u,a),h(l,a),l._preGUI||(l._preGUI={}),l._tracePreGUI||(l._tracePreGUI={});var F,B=l._tracePreGUI,j={};for(F in B)j[F]="old";for(o=0;o0){var f=1-2*l;n=Math.round(f*n),i=Math.round(f*i)}}var d=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-i)>1;(g||h)&&(h&&(r.width=n),g&&(r.height=i)),t._initialAutoSize||(t._initialAutoSize={width:n,height:i}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var a,o,l,c=i.componentsRegistry,u=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in c)(l=c[a]).includeBasePlot&&l.includeBasePlot(t,e);for(var d in u.length||u.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[d].sort(s.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var s=void 0!==r.xl?r.xl:r.x,c=void 0!==r.xr?r.xr:r.x,u=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;a[e]={l:{val:s,size:r.l+o},r:{val:c,size:r.r+o},b:{val:f,size:r.b+o},t:{val:u,size:r.t+o}},i[e]=1}else delete a[e],delete i[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),A(e);var r=e._size,n=JSON.stringify(r),o=e.margin,l=o.l,s=o.r,c=o.t,u=o.b,f=e._pushmargin,d=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var p in f)d[p]||delete f[p];for(var h in f.base={l:{val:0,size:l},r:{val:1,size:s},t:{val:1,size:c},b:{val:0,size:u}},f){var g=f[h].l||{},v=f[h].b||{},y=g.val,m=g.size,x=v.val,b=v.size;for(var _ in f){if(a(m)&&f[_].r){var w=f[_].r.val,k=f[_].r.size;if(w>y){var T=(m*w+(k-e.width)*y)/(w-y),M=(k*(1-y)+(m-e.width)*(1-w))/(w-y);T>=0&&M>=0&&T+M>l+s&&(l=T,s=M)}}if(a(b)&&f[_].t){var L=f[_].t.val,S=f[_].t.size;if(L>x){var C=(b*L+(S-e.height)*x)/(L-x),O=(S*(1-x)+(b-e.height)*(1-L))/(L-x);C>=0&&O>=0&&C+O>u+c&&(u=C,c=O)}}}}}if(r.l=Math.round(l),r.r=Math.round(s),r.t=Math.round(c),r.b=Math.round(u),r.p=Math.round(o.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,r,n,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,l=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(s.isPlainObject(t)){var e,n,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!s.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;a[e]=c(t[e])}return a}return Array.isArray(t)?t.map(c):s.isTypedArray(t)?s.simpleMap(t,s.identity):s.isJSDate(t)?s.ms2DateTimeLocal(+t):t}var u={data:(i||[]).map(function(t){var r=c(t);return e&&delete r.fit,r})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),l&&(u.frames=c(l)),"object"===n?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var r,n,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,l,c=0,u=0;function f(){return c++,function(){var r;u++,p||u!==c||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var h=t._fullLayout._basePlotModules,g=!1;if(r)for(l=0;l=0;l--)if(o[l].enabled){r._indexToPoints=o[l]._indexToPoints;break}n&&n.calc&&(i=n.calc(t,r))}Array.isArray(i)&&i[0]||(i=[{x:u,y:u}]),i[0].t||(i[0].t={}),i[0].trace=r,h[e]=i}}for(m&&L(c),a=0;a=0?d.angularAxis.domain:n.extent(k),S=Math.abs(k[1]-k[0]);M&&!T&&(S=0);var C=L.slice();A&&T&&(C[1]+=S);var O=d.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),d.angularAxis.ticksStep&&(O=(C[1]-C[0])/O);var z=d.angularAxis.ticksStep||(C[1]-C[0])/(O*(d.minorTicks+1));w&&(z=Math.max(Math.round(z),1)),C[2]||(C[2]=z);var D=n.range.apply(this,C);if(D=D.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=n.scale.linear().domain(C.slice(0,2)).range("clockwise"===d.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=A?S:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var P=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),E=this.appendChild(this.ownerDocument.importNode(P.documentElement,!0));t=n.select(E)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var R,I=t.select(".chart-group"),N={fill:"none",stroke:d.tickColor},F={"font-size":d.font.size,"font-family":d.font.family,fill:d.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+d.font.outlineColor}).join(",")};if(d.showLegend){R=t.select(".legend-group").attr({transform:"translate("+[x,d.margin.top]+")"}).style({display:"block"});var B=p.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:R,elements:B,reverseOrder:d.legend.reverseOrder})})();var j=R.node().getBBox();x=Math.min(d.width-j.width-d.margin.left-d.margin.right,d.height-d.margin.top-d.margin.bottom)/2,x=Math.max(10,x),_=[d.margin.left+x,d.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),R.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else R=t.select(".legend-group").style({display:"none"});t.attr({width:d.width,height:d.height}).style({opacity:d.opacity}),I.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(d.width-(d.margin.left+d.margin.right+2*x+(j?j.width:0)))/2,(d.height-(d.margin.top+d.margin.bottom+2*x))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),t.select(".outer-group").attr("transform","translate("+H+")"),d.title&&d.title.text){var q=t.select("g.title-group text").style(F).text(d.title.text),V=q.node().getBBox();q.attr({x:_[0]-V.width/2,y:_[1]-x-20})}var U=t.select(".radial.axis-group");if(d.radialAxis.gridLinesVisible){var G=U.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(N),G.attr("r",r),G.exit().remove()}U.select("circle.outside-circle").attr({r:x}).style(N);var Z=t.select("circle.background-circle").attr({r:x}).style({fill:d.backgroundColor,stroke:d.stroke});function X(t,e){return l(t)%360+d.orientation}if(d.radialAxis.visible){var Y=n.svg.axis().scale(r).ticks(5).tickSize(5);U.call(Y).attr({transform:"rotate("+d.radialAxis.orientation+")"}),U.selectAll(".domain").style(N),U.selectAll("g>text").text(function(t,e){return this.textContent+d.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===d.radialAxis.tickOrientation?"rotate("+-d.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),U.selectAll("g>line").style({stroke:"black"})}var W=t.select(".angular.axis-group").selectAll("g.angular-tick").data(D),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+X(t)+")"}}).style({display:d.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(d.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(d.minorTicks+1)==0)}).style(N),J.selectAll(".minor").style({stroke:d.minorTickColor}),W.select("line.grid-line").attr({x1:d.tickLength?x-d.tickLength:0,x2:x}).style({display:d.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(F);var $=W.select("text.axis-text").attr({x:x+d.labelOffset,dy:i+"em",transform:function(t,e){var r=X(t),n=x+d.labelOffset,a=d.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-r+" "+n+" 0)":"radial"==a?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:d.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(d.minorTicks+1)!=0?"":w?w[t]+d.angularAxis.ticksSuffix:t+d.angularAxis.ticksSuffix}).style(F);d.angularAxis.rewriteTicks&&$.text(function(t,e){return e%(d.minorTicks+1)!=0?"":d.angularAxis.rewriteTicks(this.textContent,e)});var Q=n.max(I.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));R.attr({transform:"translate("+[x+Q,d.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||K){var et=[];p.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=d.orientation,n.direction=d.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return a(o[r].defaultConfig(),t)});o[r]().config(n)()})}var at,it,ot=t.select(".guides-group"),lt=t.select(".tooltips-group"),st=o.tooltipPanel().config({container:lt,fontSize:8})(),ct=o.tooltipPanel().config({container:lt,fontSize:8})(),ut=o.tooltipPanel().config({container:lt,hasTick:!0})();if(!T){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});I.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(Z).angle;ft.attr({x2:-x,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-d.orientation)%360;at=l.invert(n);var a=o.util.convertToCartesian(x+12,r+180);st.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var dt=ot.select("circle").style({stroke:"grey",fill:"none"});I.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(Z).radius;dt.attr({r:n}).style({opacity:.5}),it=r.invert(o.util.getMousePos(Z).radius);var a=o.util.convertToCartesian(n,d.radialAxis.orientation);ct.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){dt.style({opacity:0}),ut.hide(),st.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var a=n.select(this),i=this.style.fill,l="black",s=this.style.opacity||1;if(a.attr({"data-opacity":s}),i&&"none"!==i){a.attr({"data-fill":i}),l=n.hsl(i).darker().toString(),a.style({fill:l,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};T&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=t.node().getBoundingClientRect(),p=[f.left+f.width/2-H[0]-d.left,f.top+f.height/2-H[1]-d.top];ut.config({color:l}).text(u),ut.move(p)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),l=n.hsl(i).darker().toString(),a.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var r=n.select(this),a=r.attr("data-fill");a?r.style({fill:a,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(c),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),a(s.data[e],o.Axis.defaultConfig().data[0]),a(s.data[e],t)}),a(s.layout,o.Axis.defaultConfig().layout),a(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return t},n.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var a=e||6,i=[],o=[];n.range(0,360+a,a).forEach(function(e,r){var n=e*Math.PI/180,a=t(n);i.push(e),o.push(a)});var l={t:i,r:o};return r&&(l.name=r),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],a=e[1],i={};return i.x=r,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,r)+Math.PI)/Math.PI,i.radius=Math.sqrt(r*r+a*a),i},o.util.duplicatesCount=function(t){for(var e,r={},n={},a=0,i=t.length;a0)){var s=n.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({class:"line",d:u(l),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return h.fill(r,a,i)},"fill-opacity":0,stroke:function(t,e){return h.stroke(r,a,i)},"stroke-width":function(t,e){return h["stroke-width"](r,a,i)},"stroke-dasharray":function(t,e){return h["stroke-dasharray"](r,a,i)},opacity:function(t,e){return h.opacity(r,a,i)},display:function(t,e){return h.display(r,a,i)}})}};var f=e.angularScale.range(),d=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=n.svg.arc().startAngle(function(t){return-d/2}).endAngle(function(t){return d/2}).innerRadius(function(t){return e.radialScale(s+(t[2]||0))}).outerRadius(function(t){return e.radialScale(s+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,r,a){n.select(this).attr({class:"mark arc",d:p,transform:function(t,r){return"rotate("+(e.orientation+l(t[0])+90)+")"}})};var h={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,a){return r[t[a].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(h).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),a(t[r],o.PolyChart.defaultConfig()),a(t[r],e)}),this):t},i.getColorScale=function(){},n.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,i=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var i=a({},e.elements[r]);return i.name=t,i.color=[].concat(e.elements[r].color)[n],i})}),o=n.merge(i);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var l=e.container;("string"==typeof l||l.nodeName)&&(l=n.select(l));var s=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,d=l.classed("legend-group",!0).selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var h=n.range(o.length),g=n.scale[u?"linear":"ordinal"]().domain(h).range(s),v=n.scale[u?"linear":"ordinal"]().domain(h)[u?"range":"rangePoints"]([0,f]);if(u){var y=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var m=d.select(".legend-marks").selectAll("path.legend-mark").data(o);m.enter().append("path").classed("legend-mark",!0),m.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var r,a,i,o=t.symbol;return i=3*(a=c),"line"===(r=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(i)():n.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),m.exit().remove()}var x=n.svg.axis().scale(v).orient("right"),b=d.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(a(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){var n=(t=i.container.selectAll("g."+l).data([0])).enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:i.padding+s,dy:.3*+i.fontSize}),c};return c.text=function(a){var o=n.hsl(i.color).l,l=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":i.fontSize+"px"}).text(f);var d=i.padding,p=e.node().getBBox(),h={fill:i.color,stroke:l,"stroke-width":"2px"},g=p.width+2*d+s,v=p.height+2*d;return r.attr({d:"M"+[[s,-v/2],[s,-v/4],[i.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(h),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return a(i,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=a({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=i.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var l=a({},t.layout);if([[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var s=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(l.margin).forEach(function(t,e){u[c[s.indexOf(t.key)]]=t.value}),l.margin=u}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),r.layout=l}return r}};return t}},{"../../../constants/alignment":146,"../../../lib":168,d3:16}],250:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),l=t("./undo_manager"),s=a.extendDeepAll,c=e.exports={};c.framework=function(t){var e,r,a,i,u,f=new l;function d(r,l){return l&&(u=l),n.select(n.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?s(e,r):r,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return d.isPolar=!0,d.svg=function(){return a.svg()},d.getConfig=function(){return e},d.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},d.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},d.setUndoPoint=function(){var t,n,a=this,i=o.util.cloneJson(e);t=i,n=r,f.add({undo:function(){n&&a(n)},redo:function(){a(t)}}),r=o.util.cloneJson(i)},d.undo=function(){f.undo()},d.redo=function(){f.redo()},d},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../../components/color":51,"../../../lib":168,"./micropolar":249,"./undo_manager":251,d3:16}],251:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function a(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(a(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(a(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r=u&&(p.min=0,g.min=0,v.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}function h(t,e,r,n){var a=f[e._name];function o(r,n){return i.coerce(t,e,a,r,n)}o("uirevision",n.uirevision),e.type="linear";var d=o("color"),p=d!==a.color.dflt?d:r.font.color,h=e._name.charAt(0).toUpperCase(),g="Component "+h,v=o("title.text",g);e._hovertitle=v===g?v:h,i.coerceFont(o,"title.font",{family:r.font.family,size:Math.round(1.2*r.font.size),color:p}),o("min"),c(t,e,o,"linear"),l(t,e,o,"linear",{}),s(t,e,o,{outerTicks:!0}),o("showticklabels")&&(i.coerceFont(o,"tickfont",{family:r.font.family,size:r.font.size,color:p}),o("tickangle"),o("tickformat")),u(t,e,o,{dfltColor:d,bgColor:r.bgColor,blend:60,showLine:!0,showGrid:!0,noZeroLine:!0,attributes:a}),o("hoverformat"),o("layer")}e.exports=function(t,e,r){o(t,e,r,{type:"ternary",attributes:f,handleDefaults:p,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../components/color":51,"../../lib":168,"../../plot_api/plot_template":202,"../cartesian/line_grid_defaults":227,"../cartesian/tick_label_defaults":232,"../cartesian/tick_mark_defaults":233,"../cartesian/tick_value_defaults":234,"../subplot_defaults":252,"./layout_attributes":254}],256:[function(t,e,r){"use strict";var n=t("d3"),a=t("tinycolor2"),i=t("../../registry"),o=t("../../lib"),l=o._,s=t("../../components/color"),c=t("../../components/drawing"),u=t("../cartesian/set_convert"),f=t("../../lib/extend").extendFlat,d=t("../plots"),p=t("../cartesian/axes"),h=t("../../components/dragelement"),g=t("../../components/fx"),v=t("../../components/titles"),y=t("../cartesian/select").prepSelect,m=t("../cartesian/select").selectOnClick,x=t("../cartesian/select").clearSelect,b=t("../cartesian/constants");function _(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework(e),this.aTickLayout=null,this.bTickLayout=null,this.cTickLayout=null}e.exports=_;var w=_.prototype;w.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={},this.layers={}},w.plot=function(t,e){var r=e[this.id],n=e._size;this._hasClipOnAxisFalse=!1;for(var a=0;ak*x?a=(i=x)*k:i=(a=m)/k,o=v*a/m,l=y*i/x,r=e.l+e.w*h-a/2,n=e.t+e.h*(1-g)-i/2,d.x0=r,d.y0=n,d.w=a,d.h=i,d.sum=b,d.xaxis={type:"linear",range:[_+2*T-b,b-_-2*w],domain:[h-o/2,h+o/2],_id:"x"},u(d.xaxis,d.graphDiv._fullLayout),d.xaxis.setScale(),d.xaxis.isPtWithinRange=function(t){return t.a>=d.aaxis.range[0]&&t.a<=d.aaxis.range[1]&&t.b>=d.baxis.range[1]&&t.b<=d.baxis.range[0]&&t.c>=d.caxis.range[1]&&t.c<=d.caxis.range[0]},d.yaxis={type:"linear",range:[_,b-w-T],domain:[g-l/2,g+l/2],_id:"y"},u(d.yaxis,d.graphDiv._fullLayout),d.yaxis.setScale(),d.yaxis.isPtWithinRange=function(){return!0};var M=d.yaxis.domain[0],A=d.aaxis=f({},t.aaxis,{range:[_,b-w-T],side:"left",tickangle:(+t.aaxis.tickangle||0)-30,domain:[M,M+l*k],anchor:"free",position:0,_id:"y",_length:a});u(A,d.graphDiv._fullLayout),A.setScale();var L=d.baxis=f({},t.baxis,{range:[b-_-T,w],side:"bottom",domain:d.xaxis.domain,anchor:"free",position:0,_id:"x",_length:a});u(L,d.graphDiv._fullLayout),L.setScale();var S=d.caxis=f({},t.caxis,{range:[b-_-w,T],side:"right",tickangle:(+t.caxis.tickangle||0)+30,domain:[M,M+l*k],anchor:"free",position:0,_id:"y",_length:a});u(S,d.graphDiv._fullLayout),S.setScale();var C="M"+r+","+(n+i)+"h"+a+"l-"+a/2+",-"+i+"Z";d.clipDef.select("path").attr("d",C),d.layers.plotbg.select("path").attr("d",C);var O="M0,"+i+"h"+a+"l-"+a/2+",-"+i+"Z";d.clipDefRelative.select("path").attr("d",O);var z="translate("+r+","+n+")";d.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",z),d.clipDefRelative.select("path").attr("transform",null);var D="translate("+(r-L._offset)+","+(n+i)+")";d.layers.baxis.attr("transform",D),d.layers.bgrid.attr("transform",D);var P="translate("+(r+a/2)+","+n+")rotate(30)translate(0,"+-A._offset+")";d.layers.aaxis.attr("transform",P),d.layers.agrid.attr("transform",P);var E="translate("+(r+a/2)+","+n+")rotate(-30)translate(0,"+-S._offset+")";d.layers.caxis.attr("transform",E),d.layers.cgrid.attr("transform",E),d.drawAxes(!0),d.layers.aline.select("path").attr("d",A.showline?"M"+r+","+(n+i)+"l"+a/2+",-"+i:"M0,0").call(s.stroke,A.linecolor||"#000").style("stroke-width",(A.linewidth||0)+"px"),d.layers.bline.select("path").attr("d",L.showline?"M"+r+","+(n+i)+"h"+a:"M0,0").call(s.stroke,L.linecolor||"#000").style("stroke-width",(L.linewidth||0)+"px"),d.layers.cline.select("path").attr("d",S.showline?"M"+(r+a/2)+","+n+"l"+a/2+","+i:"M0,0").call(s.stroke,S.linecolor||"#000").style("stroke-width",(S.linewidth||0)+"px"),d.graphDiv._context.staticPlot||d.initInteractions(),c.setClipUrl(d.layers.frontplot,d._hasClipOnAxisFalse?null:d.clipId,d.graphDiv)},w.drawAxes=function(t){var e=this.graphDiv,r=this.id.substr(7)+"title",n=this.layers,a=this.aaxis,i=this.baxis,o=this.caxis;if(this.drawAx(a),this.drawAx(i),this.drawAx(o),t){var s=Math.max(a.showticklabels?a.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0)),c=(i.showticklabels?i.tickfont.size:0)+("outside"===i.ticks?i.ticklen:0)+3;n["a-title"]=v.draw(e,"a"+r,{propContainer:a,propName:this.id+".aaxis.title",placeholder:l(e,"Click to enter Component A title"),attributes:{x:this.x0+this.w/2,y:this.y0-a.title.font.size/3-s,"text-anchor":"middle"}}),n["b-title"]=v.draw(e,"b"+r,{propContainer:i,propName:this.id+".baxis.title",placeholder:l(e,"Click to enter Component B title"),attributes:{x:this.x0-c,y:this.y0+this.h+.83*i.title.font.size+c,"text-anchor":"middle"}}),n["c-title"]=v.draw(e,"c"+r,{propContainer:o,propName:this.id+".caxis.title",placeholder:l(e,"Click to enter Component C title"),attributes:{x:this.x0+this.w+c,y:this.y0+this.h+.83*o.title.font.size+c,"text-anchor":"middle"}})}},w.drawAx=function(t){var e,r=this.graphDiv,n=t._name,a=n.charAt(0),i=t._id,l=this.layers[n],s=a+"tickLayout",c=(e=t).ticks+String(e.ticklen)+String(e.showticklabels);this[s]!==c&&(l.selectAll("."+i+"tick").remove(),this[s]=c),t.setScale();var u=p.calcTicks(t),f=p.clipEnds(t,u),d=p.makeTransFn(t),h=p.getTickSigns(t)[2],g=o.deg2rad(30),v=h*(t.linewidth||1)/2,y=h*t.ticklen,m=this.w,x=this.h,b="b"===a?"M0,"+v+"l"+Math.sin(g)*y+","+Math.cos(g)*y:"M"+v+",0l"+Math.cos(g)*y+","+-Math.sin(g)*y,_={a:"M0,0l"+x+",-"+m/2,b:"M0,0l-"+m/2+",-"+x,c:"M0,0l-"+x+","+m/2}[a];p.drawTicks(r,t,{vals:"inside"===t.ticks?f:u,layer:l,path:b,transFn:d,crisp:!1}),p.drawGrid(r,t,{vals:f,layer:this.layers[a+"grid"],path:_,transFn:d,crisp:!1});var w=p.makeLabelFns(t,0,30);p.drawLabels(r,t,{vals:u,layer:l,transFn:d,labelXFn:w.labelXFn,labelYFn:w.labelYFn,labelAnchorFn:w.labelAnchorFn})};var T=b.MINZOOM/2+.87,M="m-0.87,.5h"+T+"v3h-"+(T+5.2)+"l"+(T/2+2.6)+",-"+(.87*T+4.5)+"l2.6,1.5l-"+T/2+","+.87*T+"Z",A="m0.87,.5h-"+T+"v3h"+(T+5.2)+"l-"+(T/2+2.6)+",-"+(.87*T+4.5)+"l-2.6,1.5l"+T/2+","+.87*T+"Z",L="m0,1l"+T/2+","+.87*T+"l2.6,-1.5l-"+(T/2+2.6)+",-"+(.87*T+4.5)+"l-"+(T/2+2.6)+","+(.87*T+4.5)+"l2.6,1.5l"+T/2+",-"+.87*T+"Z",S="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",C=!0;function O(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}w.initInteractions=function(){var t,e,r,n,u,f,d,p,v,_,w=this,T=w.layers.plotbg.select("path").node(),z=w.graphDiv,D=z._fullLayout._zoomlayer,P={element:T,gd:z,plotinfo:{id:w.id,xaxis:w.xaxis,yaxis:w.yaxis},subplot:w.id,prepFn:function(i,o,l){P.xaxes=[w.xaxis],P.yaxes=[w.yaxis];var c=z._fullLayout.dragmode;P.minDrag="lasso"===c?1:void 0,"zoom"===c?(P.moveFn=B,P.clickFn=R,P.doneFn=j,function(i,o,l){var c=T.getBoundingClientRect();t=o-c.left,e=l-c.top,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,n=w.aaxis.range[1]-r.a,f=a(w.graphDiv._fullLayout[w.id].bgcolor).getLuminance(),d="M0,"+w.h+"L"+w.w/2+", 0L"+w.w+","+w.h+"Z",p=!1,v=D.append("path").attr("class","zoombox").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:f>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",d),_=D.append("path").attr("class","zoombox-corners").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:s.background,stroke:s.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),x(D)}(0,o,l)):"pan"===c?(P.moveFn=H,P.clickFn=R,P.doneFn=q,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,x(D)):"select"!==c&&"lasso"!==c||y(i,o,l,P,c)}};function E(t){var e={};return e[w.id+".aaxis.min"]=t.a,e[w.id+".baxis.min"]=t.b,e[w.id+".caxis.min"]=t.c,e}function R(t,e){var r=z._fullLayout.clickmode;O(z),2===t&&(z.emit("plotly_doubleclick",null),i.call("_guiRelayout",z,E({a:0,b:0,c:0}))),r.indexOf("select")>-1&&1===t&&m(e,z,[w.xaxis],[w.yaxis],w.id,P),r.indexOf("event")>-1&&g.click(z,e,w.id)}function I(t,e){return 1-e/w.h}function N(t,e){return 1-(t+(w.h-e)/Math.sqrt(3))/w.w}function F(t,e){return(t-(w.h-e)/Math.sqrt(3))/w.w}function B(a,i){var o=t+a,l=e+i,s=Math.max(0,Math.min(1,I(0,e),I(0,l))),c=Math.max(0,Math.min(1,N(t,e),N(o,l))),h=Math.max(0,Math.min(1,F(t,e),F(o,l))),g=(s/2+h)*w.w,y=(1-s/2-c)*w.w,m=(g+y)/2,x=y-g,T=(1-s)*w.h,C=T-x/k;x.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),_.transition().style("opacity",1).duration(200),p=!0)}function j(){O(z),u!==r&&(i.call("_guiRelayout",z,E(u)),C&&z.data&&z._context.showTips&&(o.notifier(l(z,"Double-click to zoom back out"),"long"),C=!1))}function H(t,e){var n=t/w.xaxis._m,a=e/w.yaxis._m,i=[(u={a:r.a-a,b:r.b+(n+a)/2,c:r.c-(n-a)/2}).a,u.b,u.c].sort(),o=i.indexOf(u.a),l=i.indexOf(u.b),s=i.indexOf(u.c);i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),u={a:i[o],b:i[l],c:i[s]},e=(r.a-u.a)*w.yaxis._m,t=(r.c-u.c-r.b+u.b)*w.xaxis._m);var f="translate("+(w.x0+t)+","+(w.y0+e)+")";w.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",f);var d="translate("+-t+","+-e+")";w.clipDefRelative.select("path").attr("transform",d),w.aaxis.range=[u.a,w.sum-u.b-u.c],w.baxis.range=[w.sum-u.a-u.c,u.b],w.caxis.range=[w.sum-u.a-u.b,u.c],w.drawAxes(!1),w._hasClipOnAxisFalse&&w.plotContainer.select(".scatterlayer").selectAll(".trace").call(c.hideOutsideRangePoints,w)}function q(){i.call("_guiRelayout",z,E(u))}T.onmousemove=function(t){g.hover(z,t,w.id),z._fullLayout._lasthover=T,z._fullLayout._hoversubplot=w.id},T.onmouseout=function(t){z._dragging||h.unhover(z,t)},h.init(P)}},{"../../components/color":51,"../../components/dragelement":69,"../../components/drawing":72,"../../components/fx":90,"../../components/titles":139,"../../lib":168,"../../lib/extend":162,"../../registry":257,"../cartesian/axes":212,"../cartesian/constants":218,"../cartesian/select":230,"../cartesian/set_convert":231,"../plots":245,d3:16,tinycolor2:34}],257:[function(t,e,r){"use strict";var n=t("./lib/loggers"),a=t("./lib/noop"),i=t("./lib/push_unique"),o=t("./lib/is_plain_object"),l=t("./lib/extend"),s=t("./plots/attributes"),c=t("./plots/layout_attributes"),u=l.extendFlat,f=l.extendDeepAll;function d(t){var e=t.name,a=t.categories,i=t.meta;if(r.modules[e])n.log("Type "+e+" already registered");else{r.subplotsRegistry[t.basePlotModule.name]||function(t){var e=t.name;if(r.subplotsRegistry[e])return void n.log("Plot type "+e+" already registered.");for(var a in v(t),r.subplotsRegistry[e]=t,r.componentsRegistry)x(a,t.name)}(t.basePlotModule);for(var o={},l=0;l-1&&(u[d[r]].title={text:""});for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(s,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(s,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||d.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),d.node().setAttributeNS(l.xmlns,"xmlns",l.svg),d.node().setAttributeNS(l.xmlns,"xmlns:xlink",l.xlink),"svg"===e&&r&&(d.attr("width",r*h),d.attr("height",r*g),d.attr("viewBox","0 0 "+h+" "+g));var _=(new window.XMLSerializer).serializeToString(d.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":51,"../components/drawing":72,"../constants/xmlns_namespaces":150,"../lib":168,d3:16}],266:[function(t,e,r){"use strict";var n=t("../../lib").mergeArray;e.exports=function(t,e){for(var r=0;rf+c||!n(u))&&(p=!0,g(d,t))}for(var v=0;vi))return e}return void 0!==r?r:t.dflt},r.coerceColor=function(t,e,r){return a(e).isValid()?e:void 0!==r?r:t.dflt},r.coerceEnumerated=function(t,e,r){return t.coerceNumber&&(e=+e),-1!==t.values.indexOf(e)?e:void 0!==r?r:t.dflt},r.getValue=function(t,e){var r;return Array.isArray(t)?e.01?C:function(t,e){return Math.abs(t-e)>=2?C(t):t>e?Math.ceil(t):Math.floor(t)};_=S(_,w),w=S(w,_),k=S(k,T),T=S(T,k)}i.ensureSingle(M,"path").style("vector-effect","non-scaling-stroke").attr("d","M"+_+","+k+"V"+T+"H"+w+"V"+k+"Z").call(s.setClipUrl,e.layerClipId,t),function(t,e,r,n,a,l,c,u){var y;function m(e,r,n){var a=i.ensureSingle(e,"text").text(r).attr({class:"bartext bartext-"+y,transform:"","text-anchor":"middle","data-notex":1}).call(s.font,n).call(o.convertToTspans,t);return a}var x=r[0].trace,b=x.orientation,_=function(t,e){var r=p.getValue(t.text,e);return p.coerceString(f,r)}(x,n);if(y=function(t,e){var r=p.getValue(t.textposition,e);return p.coerceEnumerated(d,r)}(x,n),!_||"none"===y)return void e.select("text").remove();var w,k,T,M,A,L,S=t._fullLayout.font,C=h.getBarColor(r[n],x),O=h.getInsideTextFont(x,n,S,C),z=h.getOutsideTextFont(x,n,S),D=t._fullLayout.barmode,P="relative"===D,E="stack"===D||P,R=r[n],I=!E||R._outmost,N=Math.abs(l-a)-2*g,F=Math.abs(u-c)-2*g;"outside"===y&&(I||R.hasB||(y="inside"));if("auto"===y)if(I){y="inside",w=m(e,_,O),k=s.bBox(w.node()),T=k.width,M=k.height;var B=T>0&&M>0,j=T<=N&&M<=F,H=T<=F&&M<=N,q="h"===b?N>=T*(F/M):F>=M*(N/T);B&&(j||H||q)?y="inside":(y="outside",w.remove(),w=null)}else y="inside";if(!w&&(w=m(e,_,"outside"===y?z:O),k=s.bBox(w.node()),T=k.width,M=k.height,T<=0||M<=0))return void w.remove();"outside"===y?(L="both"===x.constraintext||"outside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s="h"===i?Math.abs(n-r):Math.abs(e-t);s>2*g&&(l=g);var c=1;o&&(c="h"===i?Math.min(1,s/a.height):Math.min(1,s/a.width));var u,f,d,p,h=(a.left+a.right)/2,y=(a.top+a.bottom)/2;u=c*a.width,f=c*a.height,"h"===i?er?(d=(t+e)/2,p=n+l+f/2):(d=(t+e)/2,p=n-l-f/2);return v(h,y,d,p,c,!1)}(a,l,c,u,k,b,L)):(L="both"===x.constraintext||"inside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h=a.width,y=a.height,m=(a.left+a.right)/2,x=(a.top+a.bottom)/2,b=Math.abs(e-t),_=Math.abs(n-r);b>2*g&&_>2*g?(b-=2*(f=g),_-=2*f):f=0;h<=b&&y<=_?(d=!1,p=1):h<=_&&y<=b?(d=!0,p=1):hr?(c=(t+e)/2,u=n-f-s/2):(c=(t+e)/2,u=n+f+s/2);return v(m,x,c,u,p,d)}(a,l,c,u,k,b,L));w.attr("transform",A)}(t,M,r,u,_,w,k,T),e.layerClipId&&s.hideOutsideRangePoint(c,M.select("text"),y,m,b.xcalendar,b.ycalendar)}else M.remove();function C(t){return 0===x.bargap&&0===x.bargroupgap?n.round(Math.round(t)-L,2):t}});var w=!1===u.trace.cliponaxis;s.setClipUrl(c,w?null:e.layerClipId,t)});c.getComponentMethod("errorbars","plot")(t,b,e)}},{"../../components/color":51,"../../components/drawing":72,"../../lib":168,"../../lib/svg_text_utils":189,"../../registry":257,"./attributes":267,"./helpers":272,"./style":280,d3:16,"fast-isnumeric":18}],278:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,a=t.xaxis,i=t.yaxis,o=[];if(!1===e)for(r=0;r1||0===i.bargap&&0===i.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),r.selectAll("g.points").each(function(e){p(n.select(this),e[0].trace,t)}),l.getComponentMethod("errorbars","style")(r)},styleOnSelect:function(t,e){var r=e[0].node3,a=e[0].trace;a.selectedpoints?function(t,e,r){i.selectedPointStyle(t.selectAll("path"),e),function(t,e,r){t.each(function(t){var a,l=n.select(this);if(t.selected){a=o.extendFlat({},h(l,t,e,r));var s=e.selected.textfont&&e.selected.textfont.color;s&&(a.color=s),i.font(l,a)}else i.selectedTextStyle(l,e)})}(t.selectAll("text"),e,r)}(r,a,t):p(r,a,t)},getInsideTextFont:v,getOutsideTextFont:y,getBarColor:x}},{"../../components/color":51,"../../components/drawing":72,"../../lib":168,"../../registry":257,"./attributes":267,"./helpers":272,d3:16}],281:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l){r("marker.color",o),a(t,"marker")&&i(t,e,l,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),a(t,"marker.line")&&i(t,e,l,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":51,"../../components/colorscale/defaults":61,"../../components/colorscale/helpers":62}],282:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),a=t("../../components/color/attributes"),i=t("../../lib/extend").extendFlat,o=n.marker,l=o.line;e.exports={y:{valType:"data_array",editType:"calc+clearAxisTypes"},x:{valType:"data_array",editType:"calc+clearAxisTypes"},x0:{valType:"any",editType:"calc+clearAxisTypes"},y0:{valType:"any",editType:"calc+clearAxisTypes"},name:{valType:"string",editType:"calc+clearAxisTypes"},text:i({},n.text,{}),whiskerwidth:{valType:"number",min:0,max:1,dflt:.5,editType:"calc"},notched:{valType:"boolean",editType:"calc"},notchwidth:{valType:"number",min:0,max:.5,dflt:.25,editType:"calc"},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers",editType:"calc"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1,editType:"calc"},jitter:{valType:"number",min:0,max:1,editType:"calc"},pointpos:{valType:"number",min:-2,max:2,editType:"calc"},orientation:{valType:"enumerated",values:["v","h"],editType:"calc+clearAxisTypes"},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)",editType:"style"},symbol:i({},o.symbol,{arrayOk:!1,editType:"plot"}),opacity:i({},o.opacity,{arrayOk:!1,dflt:1,editType:"style"}),size:i({},o.size,{arrayOk:!1,editType:"calc"}),color:i({},o.color,{arrayOk:!1,editType:"style"}),line:{color:i({},l.color,{arrayOk:!1,dflt:a.defaultLine,editType:"style"}),width:i({},l.width,{arrayOk:!1,dflt:0,editType:"style"}),outliercolor:{valType:"color",editType:"style"},outlierwidth:{valType:"number",min:0,dflt:1,editType:"style"},editType:"style"},editType:"plot"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,selected:{marker:n.selected.marker,editType:"style"},unselected:{marker:n.unselected.marker,editType:"style"},hoveron:{valType:"flaglist",flags:["boxes","points"],dflt:"boxes+points",editType:"style"}}},{"../../components/color/attributes":50,"../../lib/extend":162,"../scatter/attributes":367}],283:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=a._,o=t("../../plots/cartesian/axes");function l(t,e,r){var n={text:"tx"};for(var a in n)Array.isArray(e[a])&&(t[n[a]]=e[a][r])}function s(t,e){return t.v-e.v}function c(t){return t.v}e.exports=function(t,e){var r,u,f,d,p,h=t._fullLayout,g=o.getFromId(t,e.xaxis||"x"),v=o.getFromId(t,e.yaxis||"y"),y=[],m="violin"===e.type?"_numViolins":"_numBoxes";"h"===e.orientation?(u=g,f="x",d=v,p="y"):(u=v,f="y",d=g,p="x");var x=u.makeCalcdata(e,f),b=function(t,e,r,i,o){if(e in t)return r.makeCalcdata(t,e);var l;l=e+"0"in t?t[e+"0"]:"name"in t&&("category"===r.type||n(t.name)&&-1!==["linear","log"].indexOf(r.type)||a.isDateTime(t.name)&&"date"===r.type)?t.name:o;var s="multicategory"===r.type?r.r2c_just_indices(l):r.d2c(l,0,t[e+"calendar"]);return i.map(function(){return s})}(e,p,d,x,h[m]),_=a.distinctVals(b),w=_.vals,k=_.minDiff/2,T=function(t,e){for(var r=t.length,n=new Array(r+1),a=0;a=0&&S0){var O=A[r].sort(s),z=O.map(c),D=z.length,P={pos:w[r],pts:O};P.min=z[0],P.max=z[D-1],P.mean=a.mean(z,D),P.sd=a.stdev(z,D,P.mean),P.q1=a.interp(z,.25),P.med=a.interp(z,.5),P.q3=a.interp(z,.75),P.lf=Math.min(P.q1,z[Math.min(a.findBin(2.5*P.q1-1.5*P.q3,z,!0)+1,D-1)]),P.uf=Math.max(P.q3,z[Math.max(a.findBin(2.5*P.q3-1.5*P.q1,z),0)]),P.lo=4*P.q1-3*P.q3,P.uo=4*P.q3-3*P.q1;var E=1.57*(P.q3-P.q1)/Math.sqrt(D);P.ln=P.med-E,P.un=P.med+E,y.push(P)}!function(t,e){if(a.isArrayOrTypedArray(e.selectedpoints))for(var r=0;r0?(y[0].t={num:h[m],dPos:k,posLetter:p,valLetter:f,labels:{med:i(t,"median:"),min:i(t,"min:"),q1:i(t,"q1:"),q3:i(t,"q3:"),max:i(t,"max:"),mean:"sd"===e.boxmean?i(t,"mean \xb1 \u03c3:"):i(t,"mean:"),lf:i(t,"lower fence:"),uf:i(t,"upper fence:")}},h[m]++,y):[{t:{empty:!0}}]}},{"../../lib":168,"../../plots/cartesian/axes":212,"fast-isnumeric":18}],284:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),a=t("../../lib"),i=["v","h"];function o(t,e,r,i,o){var l,s,c,u=e.calcdata,f=e._fullLayout,d=[],p="violin"===t?"_numViolins":"_numBoxes";for(l=0;lt.uf}),s=Math.max((t.max-t.min)/10,t.q3-t.q1),c=1e-9*s,p=s*l,h=[],g=0;if(r.jitter){if(0===s)for(g=1,h=new Array(i.length),e=0;et.lo&&(_.so=!0)}return i});h.enter().append("path").classed("point",!0),h.exit().remove(),h.call(i.translatePoints,s,c)}function u(t,e,r,i){var o,l,s=e.pos,c=e.val,u=i.bPos,f=i.bPosPxOffset||0,d=r.boxmean||(r.meanline||{}).visible;Array.isArray(i.bdPos)?(o=i.bdPos[0],l=i.bdPos[1]):(o=i.bdPos,l=i.bdPos);var p=t.selectAll("path.mean").data("box"===r.type&&r.boxmean||"violin"===r.type&&r.box.visible&&r.meanline.visible?a.identity:[]);p.enter().append("path").attr("class","mean").style({fill:"none","vector-effect":"non-scaling-stroke"}),p.exit().remove(),p.each(function(t){var e=s.c2p(t.pos+u,!0)+f,a=s.c2p(t.pos+u-o,!0)+f,i=s.c2p(t.pos+u+l,!0)+f,p=c.c2p(t.mean,!0),h=c.c2p(t.mean-t.sd,!0),g=c.c2p(t.mean+t.sd,!0);"h"===r.orientation?n.select(this).attr("d","M"+p+","+a+"V"+i+("sd"===d?"m0,0L"+h+","+e+"L"+p+","+a+"L"+g+","+e+"Z":"")):n.select(this).attr("d","M"+a+","+p+"H"+i+("sd"===d?"m0,0L"+e+","+h+"L"+a+","+p+"L"+e+","+g+"Z":""))})}e.exports={plot:function(t,e,r,i){var o=t._fullLayout,l=e.xaxis,f=e.yaxis,d=o._numBoxes,p=1-o.boxgap,h="group"===o.boxmode&&d>1;a.makeTraceGroups(i,r,"trace boxes").each(function(t){var r=n.select(this),a=t[0],i=a.t,g=a.trace;e.isRangePlot||(a.node3=r);var v,y,m=i.dPos*p*(1-o.boxgroupgap)/(h?d:1),x=h?2*i.dPos*((i.num+.5)/d-.5)*p:0,b=m*g.whiskerwidth;!0!==g.visible||i.empty?r.remove():("h"===g.orientation?(v=f,y=l):(v=l,y=f),i.bPos=x,i.bdPos=m,i.wdPos=b,i.wHover=i.dPos*(h?p/d:1),s(r,{pos:v,val:y},g,i),c(r,{x:l,y:f},g,i),u(r,{pos:v,val:y},g,i))})},plotBoxAndWhiskers:s,plotPoints:c,plotBoxMean:u}},{"../../components/drawing":72,"../../lib":168,d3:16}],292:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n,a=t.cd,i=t.xaxis,o=t.yaxis,l=[];if(!1===e)for(r=0;r":f.value>d&&(l.prefixBoundary=!0);break;case"<":f.valued)&&(l.prefixBoundary=!0);break;case"][":i=Math.min.apply(null,f.value),o=Math.max.apply(null,f.value),id&&(l.prefixBoundary=!0)}}},{}],297:[function(t,e,r){"use strict";var n=t("../../components/colorbar/draw"),a=t("./make_color_map"),i=t("./end_plus");e.exports=function(t,e){var r=e[0].trace,o="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+o).remove(),r.showscale){var l=e[0].t.cb=n(t,o),s=r.contours,c=r.line,u=s.size||1,f=s.coloring,d=a(r,{isColorbar:!0});l.fillgradient("heatmap"===f?r.colorscale:"").zrange("heatmap"===f?[r.zmin,r.zmax]:"").fillcolor("fill"===f?d:"").line({color:"lines"===f?d:c.color,width:!1!==s.showlines?c.width:0,dash:c.dash}).levels({start:s.start,end:i(s),size:u}).options(r.colorbar)()}}},{"../../components/colorbar/draw":56,"./end_plus":305,"./make_color_map":310}],298:[function(t,e,r){"use strict";e.exports={BOTTOMSTART:[1,9,13,104,713],TOPSTART:[4,6,7,104,713],LEFTSTART:[8,12,14,208,1114],RIGHTSTART:[2,3,11,208,1114],NEWDELTA:[null,[-1,0],[0,-1],[-1,0],[1,0],null,[0,-1],[-1,0],[0,1],[0,1],null,[0,1],[1,0],[1,0],[0,-1]],CHOOSESADDLE:{104:[4,1],208:[2,8],713:[7,13],1114:[11,14]},SADDLEREMAINDER:{1:4,2:8,4:1,7:13,8:2,11:14,13:7,14:11},LABELDISTANCE:2,LABELINCREASE:10,LABELMIN:3,LABELMAX:10,LABELOPTIMIZER:{EDGECOST:1,ANGLECOST:1,NEIGHBORCOST:5,SAMELEVELFACTOR:10,SAMELEVELDISTANCE:5,MAXCOST:100,INITIALSEARCHPOINTS:10,ITERATIONS:5}}},{}],299:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./label_defaults"),i=t("../../components/color"),o=i.addOpacity,l=i.opacity,s=t("../../constants/filter_ops"),c=s.CONSTRAINT_REDUCTION,u=s.COMPARISON_OPS2;e.exports=function(t,e,r,i,s,f){var d,p,h,g=e.contours,v=r("contours.operation");(g._operation=c[v],function(t,e){var r;-1===u.indexOf(e.operation)?(t("contours.value",[0,1]),Array.isArray(e.value)?e.value.length>2?e.value=e.value.slice(2):0===e.length?e.value=[0,1]:e.length<2?(r=parseFloat(e.value[0]),e.value=[r,r+1]):e.value=[parseFloat(e.value[0]),parseFloat(e.value[1])]:n(e.value)&&(r=parseFloat(e.value),e.value=[r,r+1])):(t("contours.value",0),n(e.value)||(Array.isArray(e.value)?e.value=parseFloat(e.value[0]):e.value=0))}(r,g),"="===v?d=g.showlines=!0:(d=r("contours.showlines"),h=r("fillcolor",o((t.line||{}).color||s,.5))),d)&&(p=r("line.color",h&&l(h)?o(e.fillcolor,1):s),r("line.width",2),r("line.dash"));r("line.smoothing"),a(r,i,p,f)}},{"../../components/color":51,"../../constants/filter_ops":147,"./label_defaults":309,"fast-isnumeric":18}],300:[function(t,e,r){"use strict";var n=t("../../constants/filter_ops"),a=t("fast-isnumeric");function i(t,e){var r,i=Array.isArray(e);function o(t){return a(t)?+t:null}return-1!==n.COMPARISON_OPS2.indexOf(t)?r=o(i?e[0]:e):-1!==n.INTERVAL_OPS.indexOf(t)?r=i?[o(e[0]),o(e[1])]:[o(e),o(e)]:-1!==n.SET_OPS.indexOf(t)&&(r=i?e.map(o):[o(e)]),r}function o(t){return function(e){e=i(t,e);var r=Math.min(e[0],e[1]),n=Math.max(e[0],e[1]);return{start:r,end:n,size:n-r}}}function l(t){return function(e){return{start:e=i(t,e),end:1/0,size:1/0}}}e.exports={"[]":o("[]"),"][":o("]["),">":l(">"),"<":l("<"),"=":l("=")}},{"../../constants/filter_ops":147,"fast-isnumeric":18}],301:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var a=n("contours.start"),i=n("contours.end"),o=!1===a||!1===i,l=r("contours.size");!(o?e.autocontour=!0:r("autocontour",!1))&&l||r("ncontours")}},{}],302:[function(t,e,r){"use strict";var n=t("../../lib");function a(t){return n.extendFlat({},t,{edgepaths:n.extendDeep([],t.edgepaths),paths:n.extendDeep([],t.paths)})}e.exports=function(t,e){var r,i,o,l=function(t){return t.reverse()},s=function(t){return t};switch(e){case"=":case"<":return t;case">":for(1!==t.length&&n.warn("Contour data invalid for the specified inequality operation."),i=t[0],r=0;r1e3){n.warn("Too many contours, clipping at 1000",t);break}return s}},{"../../lib":168,"./constraint_mapping":300,"./end_plus":305}],305:[function(t,e,r){"use strict";e.exports=function(t){return t.end+t.size/1e6}},{}],306:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./constants");function i(t,e,r,n){return Math.abs(t[0]-e[0])20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==a.BOTTOMSTART.indexOf(t)?i=1:-1!==a.LEFTSTART.indexOf(t)?n=1:-1!==a.TOPSTART.indexOf(t)?i=-1:n=-1;return[n,i]}(d,r,e),h=[l(t,e,[-p[0],-p[1]])],g=p.join(","),v=t.z.length,y=t.z[0].length;for(c=0;c<1e4;c++){if(d>20?(d=a.CHOOSESADDLE[d][(p[0]||p[1])<0?0:1],t.crossings[f]=a.SADDLEREMAINDER[d]):delete t.crossings[f],!(p=a.NEWDELTA[d])){n.log("Found bad marching index:",d,e,t.level);break}h.push(l(t,e,p)),e[0]+=p[0],e[1]+=p[1],i(h[h.length-1],h[h.length-2],o,s)&&h.pop(),f=e.join(",");var m=p[0]&&(e[0]<0||e[0]>y-2)||p[1]&&(e[1]<0||e[1]>v-2);if(f===u&&p.join(",")===g||r&&m)break;d=t.crossings[f]}1e4===c&&n.log("Infinite loop in contour?");var x,b,_,w,k,T,M,A,L,S,C,O,z,D,P,E=i(h[0],h[h.length-1],o,s),R=0,I=.2*t.smoothing,N=[],F=0;for(c=1;c=F;c--)if((x=N[c])=F&&x+N[b]A&&L--,t.edgepaths[L]=C.concat(h,S));break}q||(t.edgepaths[A]=h.concat(S))}for(A=0;At?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);return 5===r||10===r?t>(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4?5===r?713:1114:5===r?104:208:15===r?0:r}e.exports=function(t){var e,r,i,o,l,s,c,u,f,d=t[0].z,p=d.length,h=d[0].length,g=2===p||2===h;for(r=0;rt.level}return r?"M"+e.join("L")+"Z":""}(t,e),d=0,p=t.edgepaths.map(function(t,e){return e}),h=!0;function g(t){return Math.abs(t[1]-e[2][1])<.01}function v(t){return Math.abs(t[0]-e[0][0])<.01}function y(t){return Math.abs(t[0]-e[2][0])<.01}for(;p.length;){for(c=i.smoothopen(t.edgepaths[d],t.smoothing),f+=h?c:c.replace(/^M/,"L"),p.splice(p.indexOf(d),1),r=t.edgepaths[d][t.edgepaths[d].length-1],l=-1,o=0;o<4;o++){if(!r){a.log("Missing end?",d,t);break}for(u=r,Math.abs(u[1]-e[0][1])<.01&&!y(r)?n=e[1]:v(r)?n=e[0]:g(r)?n=e[3]:y(r)&&(n=e[2]),s=0;s=0&&(n=m,l=s):Math.abs(r[1]-n[1])<.01?Math.abs(r[1]-m[1])<.01&&(m[0]-r[0])*(n[0]-m[0])>=0&&(n=m,l=s):a.log("endpt to newendpt is not vert. or horz.",r,n,m)}if(r=n,l>=0)break;f+="L"+n}if(l===t.edgepaths.length){a.log("unclosed perimeter path");break}d=l,(h=-1===p.indexOf(d))&&(d=p[0],f+="Z")}for(d=0;dn.center?n.right-l:l-n.left)/(u+Math.abs(Math.sin(c)*o)),p=(s>n.middle?n.bottom-s:s-n.top)/(Math.abs(f)+Math.cos(c)*o);if(d<1||p<1)return 1/0;var h=v.EDGECOST*(1/(d-1)+1/(p-1));h+=v.ANGLECOST*c*c;for(var g=l-u,y=s-f,m=l+u,x=s+f,b=0;b2*v.MAXCOST)break;p&&(l/=2),s=(o=c-l/2)+1.5*l}if(d<=v.MAXCOST)return u},r.addLabelData=function(t,e,r,n){var a=e.width/2,i=e.height/2,o=t.x,l=t.y,s=t.theta,c=Math.sin(s),u=Math.cos(s),f=a*u,d=i*c,p=a*c,h=-i*u,g=[[o-f-d,l-p-h],[o+f-d,l+p-h],[o+f+d,l+p+h],[o-f+d,l-p+h]];r.push({text:e.text,x:o,y:l,dy:e.dy,theta:s,level:e.level,width:e.width,height:e.height}),n.push(g)},r.drawLabels=function(t,e,r,i,l){var s=t.selectAll("text").data(e,function(t){return t.text+","+t.x+","+t.y+","+t.theta});if(s.exit().remove(),s.enter().append("text").attr({"data-notex":1,"text-anchor":"middle"}).each(function(t){var e=t.x+Math.sin(t.theta)*t.dy,a=t.y-Math.cos(t.theta)*t.dy;n.select(this).text(t.text).attr({x:e,y:a,transform:"rotate("+180*t.theta/Math.PI+" "+e+" "+a+")"}).call(o.convertToTspans,r)}),l){for(var c="",u=0;ue.end&&(e.start=e.end=(e.start+e.end)/2),t._input.contours||(t._input.contours={}),a.extendFlat(t._input.contours,{start:e.start,end:e.end,size:e.size}),t._input.autocontour=!0}else if("constraint"!==e.type){var s,c=e.start,u=e.end,f=t._input.contours;if(c>u&&(e.start=f.start=u,u=e.end=f.end=c,c=e.start),!(e.size>0))s=c===u?1:i(c,u,t.ncontours).dtick,f.size=e.size=s}}},{"../../lib":168,"../../plots/cartesian/axes":212}],314:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../components/drawing"),i=t("../heatmap/style"),o=t("./make_color_map");e.exports=function(t){var e=n.select(t).selectAll("g.contour");e.style("opacity",function(t){return t[0].trace.opacity}),e.each(function(t){var e=n.select(this),r=t[0].trace,i=r.contours,l=r.line,s=i.size||1,c=i.start,u="constraint"===i.type,f=!u&&"lines"===i.coloring,d=!u&&"fill"===i.coloring,p=f||d?o(r):null;e.selectAll("g.contourlevel").each(function(t){n.select(this).selectAll("path").call(a.lineGroupStyle,l.width,f?p(t.level):l.color,l.dash)});var h=i.labelfont;if(e.selectAll("g.contourlabels text").each(function(t){a.font(n.select(this),{family:h.family,size:h.size,color:h.color||(f?p(t.level):l.color)})}),u)e.selectAll("g.contourfill path").style("fill",r.fillcolor);else if(d){var g;e.selectAll("g.contourfill path").style("fill",function(t){return void 0===g&&(g=t.level),p(t.level+.5*s)}),void 0===g&&(g=c),e.selectAll("g.contourbg path").style("fill",p(g-.5*s))}}),i(t)}},{"../../components/drawing":72,"../heatmap/style":328,"./make_color_map":310,d3:16}],315:[function(t,e,r){"use strict";var n=t("../../components/colorscale/defaults"),a=t("./label_defaults");e.exports=function(t,e,r,i,o){var l,s=r("contours.coloring"),c="";"fill"===s&&(l=r("contours.showlines")),!1!==l&&("lines"!==s&&(c=r("line.color","#000")),r("line.width",.5),r("line.dash")),"none"!==s&&(!0!==t.showlegend&&(e.showlegend=!1),e._dfltShowLegend=!1,n(t,e,i,r,{prefix:"",cLetter:"z"})),r("line.smoothing"),a(r,i,c,o)}},{"../../components/colorscale/defaults":61,"./label_defaults":309}],316:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),a=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),o=t("../../lib/extend").extendFlat;e.exports=o({z:{valType:"data_array",editType:"calc"},x:o({},n.x,{impliedEdits:{xtype:"array"}}),x0:o({},n.x0,{impliedEdits:{xtype:"scaled"}}),dx:o({},n.dx,{impliedEdits:{xtype:"scaled"}}),y:o({},n.y,{impliedEdits:{ytype:"array"}}),y0:o({},n.y0,{impliedEdits:{ytype:"scaled"}}),dy:o({},n.dy,{impliedEdits:{ytype:"scaled"}}),text:{valType:"data_array",editType:"calc"},transpose:{valType:"boolean",dflt:!1,editType:"calc"},xtype:{valType:"enumerated",values:["array","scaled"],editType:"calc+clearAxisTypes"},ytype:{valType:"enumerated",values:["array","scaled"],editType:"calc+clearAxisTypes"},zsmooth:{valType:"enumerated",values:["fast","best",!1],dflt:!1,editType:"calc"},connectgaps:{valType:"boolean",dflt:!1,editType:"calc"},xgap:{valType:"number",dflt:0,min:0,editType:"plot"},ygap:{valType:"number",dflt:0,min:0,editType:"plot"},zhoverformat:{valType:"string",dflt:"",editType:"none"},transforms:void 0},a("",{cLetter:"z",autoColorDflt:!1}),{colorbar:i})},{"../../components/colorbar/attributes":52,"../../components/colorscale/attributes":58,"../../lib/extend":162,"../scatter/attributes":367}],317:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib"),i=t("../../plots/cartesian/axes"),o=t("../histogram2d/calc"),l=t("../../components/colorscale/calc"),s=t("./convert_column_xyz"),c=t("./clean_2d_array"),u=t("./interp2d"),f=t("./find_empties"),d=t("./make_bound_array");e.exports=function(t,e){var r,p,h,g,v,y,m,x,b,_=i.getFromId(t,e.xaxis||"x"),w=i.getFromId(t,e.yaxis||"y"),k=n.traceIs(e,"contour"),T=n.traceIs(e,"histogram"),M=n.traceIs(e,"gl2d"),A=k?"best":e.zsmooth;if(_._minDtick=0,w._minDtick=0,T)r=(b=o(t,e)).x,p=b.x0,h=b.dx,g=b.y,v=b.y0,y=b.dy,m=b.z;else{var L=e.z;a.isArray1D(L)?(s(e,_,w,"x","y",["z"]),r=e._x,g=e._y,L=e._z):(r=e.x?_.makeCalcdata(e,"x"):[],g=e.y?w.makeCalcdata(e,"y"):[]),p=e.x0||0,h=e.dx||1,v=e.y0||0,y=e.dy||1,m=c(L,e.transpose),(k||e.connectgaps)&&(e._emptypoints=f(m),u(m,e._emptypoints))}function S(t){A=e._input.zsmooth=e.zsmooth=!1,a.warn('cannot use zsmooth: "fast": '+t)}if("fast"===A)if("log"===_.type||"log"===w.type)S("log axis found");else if(!T){if(r.length){var C=(r[r.length-1]-r[0])/(r.length-1),O=Math.abs(C/100);for(x=0;xO){S("x scale is not linear");break}}if(g.length&&"fast"===A){var z=(g[g.length-1]-g[0])/(g.length-1),D=Math.abs(z/100);for(x=0;xD){S("y scale is not linear");break}}}var P=a.maxRowLength(m),E="scaled"===e.xtype?"":r,R=d(e,E,p,h,P,_),I="scaled"===e.ytype?"":g,N=d(e,I,v,y,m.length,w);M||(e._extremes[_._id]=i.findExtremes(_,R),e._extremes[w._id]=i.findExtremes(w,N));var F={x:R,y:N,z:m,text:e._text||e.text};if(E&&E.length===R.length-1&&(F.xCenter=E),I&&I.length===N.length-1&&(F.yCenter=I),T&&(F.xRanges=b.xRanges,F.yRanges=b.yRanges,F.pts=b.pts),k&&"constraint"===e.contours.type||l(t,e,{vals:m,containerStr:"",cLetter:"z"}),k&&e.contours&&"heatmap"===e.contours.coloring){var B={type:"contour"===e.type?"heatmap":"histogram2d",xcalendar:e.xcalendar,ycalendar:e.ycalendar};F.xfill=d(B,E,p,h,P,_),F.yfill=d(B,I,v,y,m.length,w)}return[F]}},{"../../components/colorscale/calc":59,"../../lib":168,"../../plots/cartesian/axes":212,"../../registry":257,"../histogram2d/calc":345,"./clean_2d_array":318,"./convert_column_xyz":320,"./find_empties":322,"./interp2d":325,"./make_bound_array":326}],318:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){var r,a,i,o,l,s;function c(t){if(n(t))return+t}if(e){for(r=0,l=0;l=0;o--)(l=((f[[(r=(i=d[o])[0])-1,a=i[1]]]||g)[2]+(f[[r+1,a]]||g)[2]+(f[[r,a-1]]||g)[2]+(f[[r,a+1]]||g)[2])/20)&&(s[i]=[r,a,l],d.splice(o,1),c=!0);if(!c)throw"findEmpties iterated with no new neighbors";for(i in s)f[i]=s[i],u.push(s[i])}return u.sort(function(t,e){return e[2]-t[2]})}},{"../../lib":168}],323:[function(t,e,r){"use strict";var n=t("../../components/fx"),a=t("../../lib"),i=t("../../plots/cartesian/axes");e.exports=function(t,e,r,o,l,s){var c,u,f,d,p=t.cd[0],h=p.trace,g=t.xa,v=t.ya,y=p.x,m=p.y,x=p.z,b=p.xCenter,_=p.yCenter,w=p.zmask,k=[h.zmin,h.zmax],T=h.zhoverformat,M=y,A=m;if(!1!==t.index){try{f=Math.round(t.index[1]),d=Math.round(t.index[0])}catch(e){return void a.error("Error hovering on heatmap, pointNumber must be [row,col], found:",t.index)}if(f<0||f>=x[0].length||d<0||d>x.length)return}else{if(n.inbox(e-y[0],e-y[y.length-1],0)>0||n.inbox(r-m[0],r-m[m.length-1],0)>0)return;if(s){var L;for(M=[2*y[0]-y[1]],L=1;Lg&&(y=Math.max(y,Math.abs(t[i][o]-h)/(v-g))))}return y}e.exports=function(t,e){var r,a=1;for(o(t,e),r=0;r.01;r++)a=o(t,e,i(a));return a>.01&&n.log("interp2d didn't converge quickly",a),t}},{"../../lib":168}],326:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib").isArrayOrTypedArray;e.exports=function(t,e,r,i,o,l){var s,c,u,f=[],d=n.traceIs(t,"contour"),p=n.traceIs(t,"histogram"),h=n.traceIs(t,"gl2d");if(a(e)&&e.length>1&&!p&&"category"!==l.type){var g=e.length;if(!(g<=o))return d?e.slice(0,o):e.slice(0,o+1);if(d||h)f=e.slice(0,o);else if(1===o)f=[e[0]-.5,e[0]+.5];else{for(f=[1.5*e[0]-.5*e[1]],u=1;u0;)d=p.c2p(k[m]),m--;for(d0;)y=h.c2p(T[m]),m--;if(y0&&(i=!0);for(var s=0;si){var o=i-r[t];return r[t]=i,o}}return 0},max:function(t,e,r,a){var i=a[e];if(n(i)){if(i=Number(i),!n(r[t]))return r[t]=i,i;if(r[t]c?t>o?t>1.1*a?a:t>1.1*i?i:o:t>l?l:t>s?s:c:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function p(t,e,r,n,i,l){if(n&&t>o){var s=h(e,i,l),c=h(r,i,l),u=t===a?0:1;return s[u]!==c[u]}return Math.floor(r/t)-Math.floor(e/t)>.1}function h(t,e,r){var n=e.c2d(t,a,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}e.exports=function(t,e,r,n,i){var l,s,c=-1.1*e,d=-.1*e,p=t-d,h=r[0],g=r[1],v=Math.min(f(h+d,h+p,n,i),f(g+d,g+p,n,i)),y=Math.min(f(h+c,h+d,n,i),f(g+c,g+d,n,i));if(v>y&&yo){var m=l===a?1:6,x=l===a?"M12":"M1";return function(e,r){var o=n.c2d(e,a,i),l=o.indexOf("-",m);l>0&&(o=o.substr(0,l));var c=n.d2c(o,0,i);if(cr.r2l(z)&&(P=i.tickIncrement(P,_.size,!0,d)),L.start=r.l2r(P),O||a.nestedProperty(e,v+".start").set(L.start)}var E=_.end,R=r.r2l(A.end),I=void 0!==R;if((_.endFound||I)&&R!==r.r2l(E)){var N=I?R:a.aggNums(Math.max,null,p);L.end=r.l2r(N),I||a.nestedProperty(e,v+".start").set(L.end)}var F="autobin"+o;return!1===e._input[F]&&(e._input[v]=a.extendFlat({},e[v]||{}),delete e._input[F],delete e[F]),[L,p]}e.exports=function(t,e){if(!0===e.visible){var r,d,p,h,g=[],v=[],y=i.getFromId(t,"h"===e.orientation?e.yaxis||"y":e.xaxis||"x"),m="h"===e.orientation?"y":"x",x={x:"y",y:"x"}[m],b=e[m+"calendar"],_=e.cumulative,w=f(t,e,y,m),k=w[0],T=w[1],M="string"==typeof k.size,A=[],L=M?A:k,S=[],C=[],O=[],z=0,D=e.histnorm,P=e.histfunc,E=-1!==D.indexOf("density");_.enabled&&E&&(D=D.replace(/ ?density$/,""),E=!1);var R,I="max"===P||"min"===P?null:0,N=l.count,F=s[D],B=!1,j=function(t){return y.r2c(t,0,b)};for(a.isArrayOrTypedArray(e[x])&&"count"!==P&&(R=e[x],B="avg"===P,N=l[P]),r=j(k.start),p=j(k.end)+(r-i.tickIncrement(r,k.size,!1,b))/1e6;r=0&&h=0;n--)l(n);else if("increasing"===e){for(n=1;n=0;n--)t[n]+=t[n+1];"exclude"===r&&(t.push(0),t.shift())}}(v,_.direction,_.currentbin);var Y=Math.min(g.length,v.length),W=[],J=0,$=Y-1;for(r=0;r=J;r--)if(v[r]){$=r;break}for(r=J;r<=$;r++)if(n(g[r])&&n(v[r])){var Q={p:g[r],s:v[r],b:0};_.enabled||(Q.pts=O[r],V?Q.ph0=Q.ph1=O[r].length?T[O[r][0]]:g[r]:(Q.ph0=H(A[r]),Q.ph1=H(A[r+1],!0))),W.push(Q)}return 1===W.length&&(W[0].width1=i.tickIncrement(W[0].p,k.size,!1,b)-W[0].p),o(W,e),a.isArrayOrTypedArray(e.selectedpoints)&&a.tagSelected(W,e,Z),W}}},{"../../lib":168,"../../plots/cartesian/axes":212,"../bar/arrays_to_calcdata":266,"./average":332,"./bin_functions":334,"./bin_label_vals":335,"./norm_functions":343,"fast-isnumeric":18}],337:[function(t,e,r){"use strict";e.exports={eventDataKeys:["binNumber"]}},{}],338:[function(t,e,r){"use strict";var n=t("../../lib"),a=n.nestedProperty,i=t("./attributes"),o={x:[{aStr:"xbins.start",name:"start"},{aStr:"xbins.end",name:"end"},{aStr:"xbins.size",name:"size"},{aStr:"nbinsx",name:"nbins"}],y:[{aStr:"ybins.start",name:"start"},{aStr:"ybins.end",name:"end"},{aStr:"ybins.size",name:"size"},{aStr:"nbinsy",name:"nbins"}]};e.exports=function(t,e){var r,l,s,c,u,f,d,p=e._histogramBinOpts={},h="overlay"===e.barmode;function g(t){return n.coerce(s._input,s,i,t)}for(r=0;rM&&v.splice(M,v.length-M),m.length>M&&m.splice(M,m.length-M),c(e,"x",v,g,_,k,x),c(e,"y",m,y,w,T,b);var A=[],L=[],S=[],C="string"==typeof e.xbins.size,O="string"==typeof e.ybins.size,z=[],D=[],P=C?z:e.xbins,E=O?D:e.ybins,R=0,I=[],N=[],F=e.histnorm,B=e.histfunc,j=-1!==F.indexOf("density"),H="max"===B||"min"===B?null:0,q=i.count,V=o[F],U=!1,G=[],Z=[],X="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";X&&"count"!==B&&(U="avg"===B,q=i[B]);var Y=e.xbins,W=_(Y.start),J=_(Y.end)+(W-a.tickIncrement(W,Y.size,!1,x))/1e6;for(r=W;r=0&&p<$&&h>=0&&h0?Number(h):p;else if("string"!=typeof h)u.size=p;else{var g=h.charAt(0),v=h.substr(1);((v=n(v)?Number(v):0)<=0||"date"!==s||"M"!==g||v!==Math.round(v))&&(u.size=p)}}e.exports=function(t,e){var r,n,a,i;function u(t){return o.coerce(a._input,a,l,t)}for(r=0;r")}}return v},r.crossTraceCalc=function(t){var e=t._fullLayout,r=t.calcdata,n=e.piecolorway,a=e._piecolormap;e.extendpiecolors&&(n=function(t){var e,r=JSON.stringify(t),n=s[r];if(!n){for(n=t.slice(),e=0;e0?1:-1)/2,y:i/(1+r*r/(n*n)),outside:!0}}function p(t,e){var r=t.trace,n=e.h*(r.domain.y[1]-r.domain.y[0]);return Math.min(t.titleBox.height,n/2)}function h(t){var e,r=t.pull;if(Array.isArray(r))for(r=0,e=0;er&&(r=t.pull[e]);return r}e.exports=function(t,e){var r=t._fullLayout;!function(t,e){for(var r,n,a=0;aa.vTotal/2?1:0)}(e),g.attr("stroke-linejoin","round"),g.each(function(){var g=n.select(this).selectAll("g.slice").data(e);g.enter().append("g").classed("slice",!0),g.exit().remove();var m=[[[],[]],[[],[]]],x=!1;g.each(function(e){if(e.hidden)n.select(this).selectAll("path,g").remove();else{e.pointNumber=e.i,e.curveNumber=y.index,m[e.pxmid[1]<0?0:1][e.pxmid[0]<0?0:1].push(e);var p=v.cx,h=v.cy,g=n.select(this),b=g.selectAll("path.surface").data([e]),_=!1,w=!1;if(b.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),g.select("path.textline").remove(),g.on("mouseover",function(){var i=t._fullLayout,o=t._fullData[y.index];if(!t._dragging&&!1!==i.hovermode){var l=o.hoverinfo;if(Array.isArray(l)&&(l=a.castHoverinfo({hoverinfo:[c.castOption(l,e.pts)],_module:y._module},i,0)),"all"===l&&(l="label+text+value+percent+name"),o.hovertemplate||"none"!==l&&"skip"!==l&&l){var s=f(e,v),d=p+e.pxmid[0]*(1-s),g=h+e.pxmid[1]*(1-s),m=r.separators,x=[];if(l&&-1!==l.indexOf("label")&&x.push(e.label),e.text=c.castOption(o.hovertext||o.text,e.pts),l&&-1!==l.indexOf("text")){var b=e.text;b&&x.push(b)}e.value=e.v,e.valueLabel=c.formatPieValue(e.v,m),l&&-1!==l.indexOf("value")&&x.push(e.valueLabel),e.percent=e.v/v.vTotal,e.percentLabel=c.formatPiePercent(e.percent,m),l&&-1!==l.indexOf("percent")&&x.push(e.percentLabel);var k=y.hoverlabel,T=k.font;a.loneHover({x0:d-s*v.r,x1:d+s*v.r,y:g,text:x.join("
"),name:o.hovertemplate||-1!==l.indexOf("name")?o.name:void 0,idealAlign:e.pxmid[0]<0?"left":"right",color:c.castOption(k.bgcolor,e.pts)||e.color,borderColor:c.castOption(k.bordercolor,e.pts),fontFamily:c.castOption(T.family,e.pts),fontSize:c.castOption(T.size,e.pts),fontColor:c.castOption(T.color,e.pts),trace:o,hovertemplate:c.castOption(o.hovertemplate,e.pts),hovertemplateLabels:e,eventData:[u(e,o)]},{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:t}),_=!0}t.emit("plotly_hover",{points:[u(e,o)],event:n.event}),w=!0}}).on("mouseout",function(r){var i=t._fullLayout,o=t._fullData[y.index];w&&(r.originalEvent=n.event,t.emit("plotly_unhover",{points:[u(e,o)],event:n.event}),w=!1),_&&(a.loneUnhover(i._hoverlayer.node()),_=!1)}).on("click",function(){var r=t._fullLayout,i=t._fullData[y.index];t._dragging||!1===r.hovermode||(t._hoverdata=[u(e,i)],a.click(t,n.event))}),y.pull){var k=+c.castOption(y.pull,e.pts)||0;k>0&&(p+=k*e.pxmid[0],h+=k*e.pxmid[1])}e.cxFinal=p,e.cyFinal=h;var T=y.hole;if(e.v===v.vTotal){var M="M"+(p+e.px0[0])+","+(h+e.px0[1])+O(e.px0,e.pxmid,!0,1)+O(e.pxmid,e.px0,!0,1)+"Z";T?b.attr("d","M"+(p+T*e.px0[0])+","+(h+T*e.px0[1])+O(e.px0,e.pxmid,!1,T)+O(e.pxmid,e.px0,!1,T)+"Z"+M):b.attr("d",M)}else{var A=O(e.px0,e.px1,!0,1);if(T){var L=1-T;b.attr("d","M"+(p+T*e.px1[0])+","+(h+T*e.px1[1])+O(e.px1,e.px0,!1,T)+"l"+L*e.px0[0]+","+L*e.px0[1]+A+"Z")}else b.attr("d","M"+p+","+h+"l"+e.px0[0]+","+e.px0[1]+A+"Z")}var S=c.castOption(y.textposition,e.pts),C=g.selectAll("g.slicetext").data(e.text&&"none"!==S?[0]:[]);C.enter().append("g").classed("slicetext",!0),C.exit().remove(),C.each(function(){var r=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});r.text(e.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(o.font,"outside"===S?function(t,e,r){var n=c.castOption(t.outsidetextfont.color,e.pts)||c.castOption(t.textfont.color,e.pts)||r.color,a=c.castOption(t.outsidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,i=c.castOption(t.outsidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n,family:a,size:i}}(y,e,t._fullLayout.font):function(t,e,r){var n=c.castOption(t.insidetextfont.color,e.pts);!n&&t._input.textfont&&(n=c.castOption(t._input.textfont.color,e.pts));var a=c.castOption(t.insidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,o=c.castOption(t.insidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n||i.contrast(e.color),family:a,size:o}}(y,e,t._fullLayout.font)).call(s.convertToTspans,t);var a,u=o.bBox(r.node());"outside"===S?a=d(u,e):(a=function(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,i=Math.PI*Math.min(e.v/r.vTotal,.5),o=1-r.trace.hole,l=f(e,r),s={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(s.scale>=1)return s;var c=a+1/(2*Math.tan(i)),u=r.r*Math.min(1/(Math.sqrt(c*c+.5)+c),o/(Math.sqrt(a*a+o/2)+a)),d={scale:2*u/t.height,rCenter:Math.cos(u/r.r)-u*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},p=1/a,h=p+1/(2*Math.tan(i)),g=r.r*Math.min(1/(Math.sqrt(h*h+.5)+h),o/(Math.sqrt(p*p+o/2)+p)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},y=v.scale>d.scale?v:d;return s.scale<1&&y.scale>s.scale?y:s}(u,e,v),"auto"===S&&a.scale<1&&(r.call(o.font,y.outsidetextfont),y.outsidetextfont.family===y.insidetextfont.family&&y.outsidetextfont.size===y.insidetextfont.size||(u=o.bBox(r.node())),a=d(u,e)));var g=p+e.pxmid[0]*a.rCenter+(a.x||0),m=h+e.pxmid[1]*a.rCenter+(a.y||0);a.outside&&(e.yLabelMin=m-u.height/2,e.yLabelMid=m,e.yLabelMax=m+u.height/2,e.labelExtraX=0,e.labelExtraY=0,x=!0),r.attr("transform","translate("+g+","+m+")"+(a.scale<1?"scale("+a.scale+")":"")+(a.rotate?"rotate("+a.rotate+")":"")+"translate("+-(u.left+u.right)/2+","+-(u.top+u.bottom)/2+")")})}function O(t,r,n,a){return"a"+a*v.r+","+a*v.r+" 0 "+e.largeArc+(n?" 1 ":" 0 ")+a*(r[0]-t[0])+","+a*(r[1]-t[1])}});var b=n.select(this).selectAll("g.titletext").data(y.title.text?[0]:[]);b.enter().append("g").classed("titletext",!0),b.exit().remove(),b.each(function(){var e,a=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});a.text(y.title.text).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(o.font,y.title.font).call(s.convertToTspans,t),e="middle center"===y.title.position?function(t){var e=Math.sqrt(t.titleBox.width*t.titleBox.width+t.titleBox.height*t.titleBox.height);return{x:t.cx,y:t.cy,scale:t.trace.hole*t.r*2/e,tx:0,ty:-t.titleBox.height/2+t.trace.title.font.size}}(v):function(t,e){var r,n,a=1,i=1,o=t.trace,l={x:t.cx,y:t.cy},s={tx:0,ty:0};s.ty+=o.title.font.size,n=h(o),-1!==o.title.position.indexOf("top")?(l.y-=(1+n)*t.r,s.ty-=t.titleBox.height):-1!==o.title.position.indexOf("bottom")&&(l.y+=(1+n)*t.r);-1!==o.title.position.indexOf("left")?(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x-=(1+n)*t.r,s.tx+=t.titleBox.width/2):-1!==o.title.position.indexOf("center")?r=e.w*(o.domain.x[1]-o.domain.x[0]):-1!==o.title.position.indexOf("right")&&(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x+=(1+n)*t.r,s.tx-=t.titleBox.width/2);return a=r/t.titleBox.width,i=p(t,e)/t.titleBox.height,{x:l.x,y:l.y,scale:Math.min(a,i),tx:s.tx,ty:s.ty}}(v,r._size),a.attr("transform","translate("+e.x+","+e.y+")"+(e.scale<1?"scale("+e.scale+")":"")+"translate("+e.tx+","+e.ty+")")}),x&&function(t,e){var r,n,a,i,o,l,s,u,f,d,p,h,g;function v(t,e){return t.pxmid[1]-e.pxmid[1]}function y(t,e){return e.pxmid[1]-t.pxmid[1]}function m(t,r){r||(r={});var a,u,f,p,h,g,v=r.labelExtraY+(n?r.yLabelMax:r.yLabelMin),y=n?t.yLabelMin:t.yLabelMax,m=n?t.yLabelMax:t.yLabelMin,x=t.cyFinal+o(t.px0[1],t.px1[1]),b=v-y;if(b*s>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(u=0;u=(c.castOption(e.pull,f.pts)||0)||((t.pxmid[1]-f.pxmid[1])*s>0?(p=f.cyFinal+o(f.px0[1],f.px1[1]),(b=p-y-t.labelExtraY)*s>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-x)*s>0&&(a=3*l*Math.abs(u-d.indexOf(t)),h=f.cxFinal+i(f.px0[0],f.px1[0]),(g=h+a-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*l>0&&(t.labelExtraX+=g)))}for(n=0;n<2;n++)for(a=n?v:y,o=n?Math.max:Math.min,s=n?1:-1,r=0;r<2;r++){for(i=r?Math.max:Math.min,l=r?1:-1,(u=t[n][r]).sort(a),f=t[1-n][r],d=f.concat(u),h=[],p=0;pMath.abs(c)?o+="l"+c*t.pxmid[0]/t.pxmid[1]+","+c+"H"+(a+t.labelExtraX+l):o+="l"+t.labelExtraX+","+s+"v"+(c-s)+"h"+l}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+l;e.append("path").classed("textline",!0).call(i.stroke,y.outsidetextfont.color).attr({"stroke-width":Math.min(2,y.outsidetextfont.size/8),d:o,fill:"none"})}})})});setTimeout(function(){g.selectAll("tspan").each(function(){var t=n.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":51,"../../components/drawing":72,"../../components/fx":90,"../../lib":168,"../../lib/svg_text_utils":189,"./event_data":358,"./helpers":359,d3:16}],364:[function(t,e,r){"use strict";var n=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each(function(t){n.select(this).call(a,t,e)})})}},{"./style_one":365,d3:16}],365:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("./helpers").castOption;e.exports=function(t,e,r){var i=r.marker.line,o=a(i.color,e.pts)||n.defaultLine,l=a(i.width,e.pts)||0;t.style({"stroke-width":l}).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":51,"./helpers":359}],366:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rl&&M[v].gap;)v--;for(m=M[v].s,h=M.length-1;h>v;h--)M[h].s=m;for(;lA[u]&&u=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===r.xaxis&&i.yaxis===r.yaxis){i.opacity=void 0;break}}}}}},{}],374:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),l=t("./subtypes"),s=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),d=t("./line_shape_defaults"),p=t("./text_defaults"),h=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,a){return n.coerce(t,e,i,r,a)}var y=s(t,e,g,v);if(y||(e.visible=!1),e.visible){var m=c(t,e,g,v),x=!m&&yG!=(N=D[O][1])>=G&&(E=D[O-1][0],R=D[O][0],N-I&&(P=E+(R-E)*(G-I)/(N-I),H=Math.min(H,P),q=Math.max(q,P)));H=Math.max(H,0),q=Math.min(q,d._length);var Z=l.defaultLine;return l.opacity(f.fillcolor)?Z=f.fillcolor:l.opacity((f.line||{}).color)&&(Z=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:H,x1:q,y0:G,y1:G,color:Z,hovertemplate:"%{name}"}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":51,"../../components/fx":90,"../../lib":168,"../../registry":257,"./fill_hover_text":375,"./get_trace_color":377}],379:[function(t,e,r){"use strict";var n={},a=t("./subtypes");n.hasLines=a.hasLines,n.hasMarkers=a.hasMarkers,n.hasText=a.hasText,n.isBubble=a.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":224,"./arrays_to_calcdata":366,"./attributes":367,"./calc":368,"./cross_trace_calc":372,"./cross_trace_defaults":373,"./defaults":374,"./hover":378,"./marker_colorbar":385,"./plot":387,"./select":388,"./style":390,"./subtypes":391}],380:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l,s){var c=(t.marker||{}).color;(l("line.color",r),a(t,"line"))?i(t,e,o,l,{prefix:"line.",cLetter:"c",noScale:!0}):l("line.color",!n(c)&&c||r);l("line.width"),(s||{}).noDash||l("line.dash")}},{"../../components/colorscale/defaults":61,"../../components/colorscale/helpers":62,"../../lib":168}],381:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),a=n.BADNUM,i=n.LOG_CLIP,o=i+.5,l=i-.5,s=t("../../lib"),c=s.segmentsIntersect,u=s.constrain,f=t("./constants");e.exports=function(t,e){var r,n,i,d,p,h,g,v,y,m,x,b,_,w,k,T,M,A,L=e.xaxis,S=e.yaxis,C="log"===L.type,O="log"===S.type,z=L._length,D=S._length,P=e.connectGaps,E=e.baseTolerance,R=e.shape,I="linear"===R,N=[],F=f.minTolerance,B=new Array(t.length),j=0;function H(e){var r=t[e];if(!r)return!1;var n=L.c2p(r.x),i=S.c2p(r.y);if(n===a){if(C&&(n=L.c2p(r.x,!0)),n===a)return!1;O&&i===a&&(n*=Math.abs(L._m*D*(L._m>0?o:l)/(S._m*z*(S._m>0?o:l)))),n*=1e3}if(i===a){if(O&&(i=S.c2p(r.y,!0)),i===a)return!1;i*=1e3}return[n,i]}function q(t,e,r,n){var a=r-t,i=n-e,o=.5-t,l=.5-e,s=a*a+i*i,c=a*o+i*l;if(c>0&&ctt||t[1]rt)return[u(t[0],K,tt),u(t[1],et,rt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,a){var i=at(n),o=at(a),l=[];if(i&&o&&it(i,o))return l;i&&l.push(i),o&&l.push(o);var c=2*s.constrain((n[t]+a[t])/2,e,r)-((i||n)[t]+(o||a)[t]);c&&((i&&o?c>0==i[t]>o[t]?i:o:i||o)[t]+=c);return l}}function lt(t){var e=t[0],r=t[1],n=e===B[j-1][0],a=r===B[j-1][1];if(!n||!a)if(j>1){var i=e===B[j-2][0],o=r===B[j-2][1];n&&(e===K||e===tt)&&i?o?j--:B[j-1]=t:a&&(r===et||r===rt)&&o?i?j--:B[j-1]=t:B[j++]=t}else B[j++]=t}function st(t){B[j-1][0]!==t[0]&&B[j-1][1]!==t[1]&<([X,Y]),lt(t),W=null,X=Y=0}function ct(t){if(M=t[0]/z,A=t[1]/D,G=t[0]tt?tt:0,Z=t[1]rt?rt:0,G||Z){if(j)if(W){var e=$(W,t);e.length>1&&(st(e[0]),B[j++]=e[1])}else J=$(B[j-1],t)[0],B[j++]=J;else B[j++]=[G||t[0],Z||t[1]];var r=B[j-1];G&&Z&&(r[0]!==G||r[1]!==Z)?(W&&(X!==G&&Y!==Z?lt(X&&Y?(n=W,i=(a=t)[0]-n[0],o=(a[1]-n[1])/i,(n[1]*a[0]-a[1]*n[0])/i>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[X||G,Y||Z]):X&&Y&<([X,Y])),lt([G,Z])):X-G&&Y-Z&<([G||X,Z||Y]),W=t,X=G,Y=Z}else W&&st($(W,t)[0]),B[j++]=t;var n,a,i,o}for("linear"===R||"spline"===R?$=function(t,e){for(var r=[],n=0,a=0;a<4;a++){var i=nt[a],o=c(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&U(o,t)V(h,ut))break;i=h,(_=y[0]*v[0]+y[1]*v[1])>x?(x=_,d=h,g=!1):_=t.length||!h)break;ct(h),n=h}}else ct(d)}W&<([X||W[0],Y||W[1]]),N.push(B.slice(0,j))}return N}},{"../../constants/numerical":149,"../../lib":168,"./constants":371}],382:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],383:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var a,i,o,l,s,c={},u=!1,f=-1,d=0,p=-1;for(i=0;i=0?s=p:(s=p=d,d++),s0?Math.max(e,a):0}}},{"fast-isnumeric":18}],385:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],386:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,l,s,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(r=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",r),a(t,"marker")&&i(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c.noSelect||(s("selected.marker.color"),s("unselected.marker.color"),s("selected.marker.size"),s("unselected.marker.size")),c.noLine||(s("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?n.background:n.defaultLine),a(t,"marker.line")&&i(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0)),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode")),c.gradient)&&("none"!==s("marker.gradient.type")&&s("marker.gradient.color"))}},{"../../components/color":51,"../../components/colorscale/defaults":61,"../../components/colorscale/helpers":62,"./subtypes":391}],387:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,l=i.identity,s=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),d=t("../../lib/polygon").tester;function p(t,e,r,f,p,h,g){var v;!function(t,e,r,a,o){var l=r.xaxis,s=r.yaxis,u=n.extent(i.simpleMap(l.range,l.r2c)),f=n.extent(i.simpleMap(s.range,s.r2c)),d=a[0].trace;if(!c.hasMarkers(d))return;var p=d.marker.maxdisplayed;if(0===p)return;var h=a.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(h.length/p),v=0;o.forEach(function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function m(t){return y?t.transition():t}var x=r.xaxis,b=r.yaxis,_=f[0].trace,w=_.line,k=n.select(h),T=o(k,"g","errorbars"),M=o(k,"g","lines"),A=o(k,"g","points"),L=o(k,"g","text");if(a.getComponentMethod("errorbars","plot")(t,T,r,g),!0===_.visible){var S,C;m(k).style("opacity",_.opacity);var O=_.fill.charAt(_.fill.length-1);"x"!==O&&"y"!==O&&(O=""),r.isRangePlot||(f[0].node3=k);var z="",D=[],P=_._prevtrace;P&&(z=P._prevRevpath||"",C=P._nextFill,D=P._polygons);var E,R,I,N,F,B,j,H,q,V="",U="",G=[],Z=i.noop;if(S=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(C&&C.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(I=s.steps(w.shape),N=s.steps(w.shape.split("").reverse().join(""))):I=N="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?s.smoothclosed(t.slice(1),w.smoothing):s.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return N(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)m(r.style("opacity",0).attr("d",E).call(s.lineGroupStyle)).style("opacity",1);else{var a=m(r);a.attr("d",E),s.singleLineStyle(f,a)}}}}}var X=M.selectAll(".js-line").data(G);m(X.exit()).style("opacity",0).remove(),X.each(Z(!1)),X.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(s.lineGroupStyle).each(Z(!0)),s.setClipUrl(X,r.layerClipId,t),G.length?(S?(S.datum(f),B&&H&&(O?("y"===O?B[1]=H[1]=b.c2p(0,!0):"x"===O&&(B[0]=H[0]=x.c2p(0,!0)),m(S).attr("d","M"+H+"L"+B+"L"+V.substr(1)).call(s.singleFillStyle)):m(S).attr("d",V+"Z").call(s.singleFillStyle))):C&&("tonext"===_.fill.substr(0,6)&&V&&z?("tonext"===_.fill?m(C).attr("d",V+"Z"+z+"Z").call(s.singleFillStyle):m(C).attr("d",V+"L"+z.substr(1)+"Z").call(s.singleFillStyle),_._polygons=_._polygons.concat(D)):(W(C),_._polygons=null)),_._prevRevpath=U,_._prevPolygons=q):(S?W(S):C&&W(C),_._polygons=_._prevRevpath=_._prevPolygons=null),A.datum(f),L.datum(f),function(e,a,i){var o,u=i[0].trace,f=c.hasMarkers(u),d=c.hasText(u),p=tt(u),h=et,g=et;if(f||d){var v=l,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?$:J:_&&!w&&(v=Q),f&&(h=v),d&&(g=v)}var k,T=(o=e.selectAll("path.point").data(h,p)).enter().append("path").classed("point",!0);y&&T.call(s.pointStyle,u,t).call(s.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=s.makePointStyleFns(u)),o.each(function(e){var a=n.select(this),i=m(a);s.translatePoint(e,i,x,b)?(s.singlePointStyle(e,i,u,k,t),r.layerClipId&&s.hideOutsideRangePoint(e,i,x,b,u.xcalendar,u.ycalendar),u.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),a=m(e.select("text"));s.translatePoint(t,a,x,b)?r.layerClipId&&s.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(s.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),r=b.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){m(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(A,L,f);var Y=!1===_.cliponaxis?null:r.layerClipId;s.setClipUrl(A,Y,t),s.setClipUrl(L,Y,t)}function W(t){m(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function $(t){return t.filter(function(t){return t.vis})}function Q(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,a,i,c){var u,d,h=!i,g=!!i&&i.duration>0,v=f(t,e,r);((u=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,r){e.each(function(e){var a=o(n.select(this),"g","fills");s.setClipUrl(a,r.layerClipId,t);var i=e[0].trace,c=[];i._ownfill&&c.push("_ownFill"),i._nexttrace&&c.push("_nextFill");var u=a.selectAll("g").data(c,l);u.enter().append("g"),u.exit().each(function(t){i[t]=null}).remove(),u.order().each(function(t){i[t]=o(n.select(this),"path","js-fill")})})}(t,u,e),g)?(c&&(d=c()),n.transition().duration(i.duration).ease(i.easing).each("end",function(){d&&d()}).each("interrupt",function(){d&&d()}).each(function(){a.selectAll("g.trace").each(function(r,n){p(t,n,e,r,v,this,i)})})):u.each(function(r,n){p(t,n,e,r,v,this,i)});h&&u.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":72,"../../lib":168,"../../lib/polygon":180,"../../registry":257,"./line_points":381,"./link_traces":383,"./subtypes":391,d3:16}],388:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,a,i,o,l=t.cd,s=t.xaxis,c=t.yaxis,u=[],f=l[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r"),o}function y(t,e){v.push(t._hovertitle+": "+a.tickText(t,e,"hover").text)}}},{"../../plots/cartesian/axes":212,"../scatter/hover":378}],399:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("../scatter/style").style,n.styleOnSelect=t("../scatter/style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("../scatter/select"),n.eventData=t("./event_data"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","showLegend","scatter-like"],n.meta={},e.exports=n},{"../../plots/ternary":253,"../scatter/marker_colorbar":385,"../scatter/select":388,"../scatter/style":390,"./attributes":394,"./calc":395,"./defaults":396,"./event_data":397,"./hover":398,"./plot":400}],400:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e,r){var a=e.plotContainer;a.select(".scatterlayer").selectAll("*").remove();var i={xaxis:e.xaxis,yaxis:e.yaxis,plot:a,layerClipId:e._hasClipOnAxisFalse?e.clipIdRelative:null},o=e.layers.frontplot.select("g.scatterlayer");n(t,i,r,o)}},{"../scatter/plot":387}],401:[function(t,e,r){"use strict";var n=t("../box/attributes"),a=t("../../lib/extend").extendFlat;e.exports={y:n.y,x:n.x,x0:n.x0,y0:n.y0,name:n.name,orientation:a({},n.orientation,{}),bandwidth:{valType:"number",min:0,editType:"calc"},scalegroup:{valType:"string",dflt:"",editType:"calc"},scalemode:{valType:"enumerated",values:["width","count"],dflt:"width",editType:"calc"},spanmode:{valType:"enumerated",values:["soft","hard","manual"],dflt:"soft",editType:"calc"},span:{valType:"info_array",items:[{valType:"any",editType:"calc"},{valType:"any",editType:"calc"}],editType:"calc"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,points:a({},n.boxpoints,{}),jitter:a({},n.jitter,{}),pointpos:a({},n.pointpos,{}),marker:n.marker,text:n.text,box:{visible:{valType:"boolean",dflt:!1,editType:"plot"},width:{valType:"number",min:0,max:1,dflt:.25,editType:"plot"},fillcolor:{valType:"color",editType:"style"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,editType:"style"},editType:"style"},editType:"plot"},meanline:{visible:{valType:"boolean",dflt:!1,editType:"plot"},color:{valType:"color",editType:"style"},width:{valType:"number",min:0,editType:"style"},editType:"plot"},side:{valType:"enumerated",values:["both","positive","negative"],dflt:"both",editType:"plot"},selected:n.selected,unselected:n.unselected,hoveron:{valType:"flaglist",flags:["violins","points","kde"],dflt:"violins+points+kde",extras:["all"],editType:"style"}}},{"../../lib/extend":162,"../box/attributes":282}],402:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("../box/calc"),o=t("./helpers"),l=t("../../constants/numerical").BADNUM;function s(t,e,r){var a=e.max-e.min;if(!a)return 1;if(t.bandwidth)return Math.max(t.bandwidth,a/1e4);var i=r.length,o=n.stdev(r,i-1,e.mean);return Math.max(function(t,e,r){return 1.059*Math.min(e,r/1.349)*Math.pow(t,-.2)}(i,o,e.q3-e.q1),a/100)}function c(t,e,r,n){var i,o=t.spanmode,s=t.span||[],c=[e.min,e.max],u=[e.min-2*n,e.max+2*n];function f(n){var a=s[n],i="multicategory"===r.type?r.r2c(a):r.d2c(a,0,t[e.valLetter+"calendar"]);return i===l?u[n]:i}var d={type:"linear",range:i="soft"===o?u:"hard"===o?c:[f(0),f(1)]};return a.setConvert(d),d.cleanRange(),i}e.exports=function(t,e){var r=i(t,e);if(r[0].t.empty)return r;var l=t._fullLayout,u=a.getFromId(t,e["h"===e.orientation?"xaxis":"yaxis"]),f=l._violinScaleGroupStats,d=e.scalegroup,p=f[d];p||(p=f[d]={maxWidth:0,maxCount:0});for(var h=1/0,g=-1/0,v=0;v0){var m,x,b,_,w,k=t.xa,T=t.ya;"h"===d.orientation?(w=e,m="y",b=T,x="x",_=k):(w=r,m="x",b=k,x="y",_=T);var M=f[t.index];if(w>=M.span[0]&&w<=M.span[1]){var A=n.extendFlat({},t),L=_.c2p(w,!0),S=o.getKdeValue(M,d,w),C=o.getPositionOnKdePath(M,d,L),O=b._offset,z=b._length;A[m+"0"]=C[0],A[m+"1"]=C[1],A[x+"0"]=A[x+"1"]=L,A[x+"Label"]=x+": "+a.hoverLabelText(_,w)+", "+f[0].t.labels.kde+" "+S.toFixed(3),A.spikeDistance=y[0].spikeDistance;var D=m+"Spike";A[D]=y[0][D],y[0].spikeDistance=void 0,y[0][D]=void 0,v.push(A),(u={stroke:t.color})[m+"1"]=n.constrain(O+C[0],O,O+z),u[m+"2"]=n.constrain(O+C[1],O,O+z),u[x+"1"]=u[x+"2"]=_._offset+L}}}-1!==p.indexOf("points")&&(c=i.hoverOnPoints(t,e,r));var P=s.selectAll(".violinline-"+d.uid).data(u?[0]:[]);return P.enter().append("line").classed("violinline-"+d.uid,!0).attr("stroke-width",1.5),P.exit().remove(),P.attr(u),"closest"===l?c?[c]:v:c?(v.push(c),v):v}},{"../../lib":168,"../../plots/cartesian/axes":212,"../box/hover":287,"./helpers":405}],407:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),crossTraceCalc:t("./cross_trace_calc"),plot:t("./plot"),style:t("./style"),styleOnSelect:t("../scatter/style").styleOnSelect,hoverPoints:t("./hover"),selectPoints:t("../box/select"),moduleType:"trace",name:"violin",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","symbols","oriented","box-violin","showLegend","violinLayout","zoomScale"],meta:{}}},{"../../plots/cartesian":224,"../box/select":292,"../scatter/style":390,"./attributes":401,"./calc":402,"./cross_trace_calc":403,"./defaults":404,"./hover":406,"./layout_attributes":408,"./layout_defaults":409,"./plot":410,"./style":411}],408:[function(t,e,r){"use strict";var n=t("../box/layout_attributes"),a=t("../../lib").extendFlat;e.exports={violinmode:a({},n.boxmode,{}),violingap:a({},n.boxgap,{}),violingroupgap:a({},n.boxgroupgap,{})}},{"../../lib":168,"../box/layout_attributes":289}],409:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./layout_attributes"),i=t("../box/layout_defaults");e.exports=function(t,e,r){i._supply(t,e,r,function(r,i){return n.coerce(t,e,a,r,i)},"violin")}},{"../../lib":168,"../box/layout_defaults":290,"./layout_attributes":408}],410:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../components/drawing"),o=t("../box/plot"),l=t("../scatter/line_points"),s=t("./helpers");e.exports=function(t,e,r,c){var u=t._fullLayout,f=e.xaxis,d=e.yaxis;function p(t){var e=l(t,{xaxis:f,yaxis:d,connectGaps:!0,baseTolerance:.75,shape:"spline",simplify:!0});return i.smoothopen(e[0],1)}a.makeTraceGroups(c,r,"trace violins").each(function(t){var r=n.select(this),i=t[0],l=i.t,c=i.trace;e.isRangePlot||(i.node3=r);var h=u._numViolins,g="group"===u.violinmode&&h>1,v=1-u.violingap,y=l.bdPos=l.dPos*v*(1-u.violingroupgap)/(g?h:1),m=l.bPos=g?2*l.dPos*((l.num+.5)/h-.5)*v:0;if(l.wHover=l.dPos*(g?v/h:1),!0!==c.visible||l.empty)r.remove();else{var x=e[l.valLetter+"axis"],b=e[l.posLetter+"axis"],_="both"===c.side,w=_||"positive"===c.side,k=_||"negative"===c.side,T=u._violinScaleGroupStats[c.scalegroup],M=r.selectAll("path.violin").data(a.identity);M.enter().append("path").style("vector-effect","non-scaling-stroke").attr("class","violin"),M.exit().remove(),M.each(function(t){var e,r,a,i,o,s,u,f,d=n.select(this),h=t.density,g=h.length,v=t.pos+m,M=b.c2p(v);switch(c.scalemode){case"width":e=T.maxWidth/y;break;case"count":e=T.maxWidth/y*(T.maxCount/t.pts.length)}if(w){for(u=new Array(g),o=0;o:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", + "X:hover .modebar--hover .modebar-group": "opacity:1;", "X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;", "X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;", "X .modebar-btn svg": "position:relative;top:2px;", @@ -71,7 +71,7 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":164}],2:[function(_dereq_,module,exports){ +},{"../src/lib":162}],2:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -214,7 +214,7 @@ module.exports = { module.exports = _dereq_('../src/traces/bar'); -},{"../src/traces/bar":264}],4:[function(_dereq_,module,exports){ +},{"../src/traces/bar":263}],4:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -227,7 +227,7 @@ module.exports = _dereq_('../src/traces/bar'); module.exports = _dereq_('../src/traces/candlestick'); -},{"../src/traces/candlestick":281}],5:[function(_dereq_,module,exports){ +},{"../src/traces/candlestick":280}],5:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -240,7 +240,7 @@ module.exports = _dereq_('../src/traces/candlestick'); module.exports = _dereq_('../src/core'); -},{"../src/core":148}],6:[function(_dereq_,module,exports){ +},{"../src/core":145}],6:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15148,7 +15148,7 @@ module.exports = templatedArray('annotation', { } }); -},{"../../plot_api/plot_template":198,"../../plots/cartesian/constants":214,"../../plots/font_attributes":235,"./arrow_paths":30}],32:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":196,"../../plots/cartesian/constants":212,"../../plots/font_attributes":233,"./arrow_paths":30}],32:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15237,7 +15237,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":164,"../../plots/cartesian/axes":208,"./draw":37}],33:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/cartesian/axes":206,"./draw":37}],33:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15376,7 +15376,7 @@ function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":164,"../../plot_api/plot_template":198,"../../registry":248}],34:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plot_api/plot_template":196,"../../registry":246}],34:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15456,7 +15456,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":164,"../color":46}],35:[function(_dereq_,module,exports){ +},{"../../lib":162,"../color":46}],35:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15519,7 +15519,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":187,"fast-isnumeric":13}],36:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":185,"fast-isnumeric":13}],36:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15625,7 +15625,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":164,"../../plots/array_container_defaults":204,"../../plots/cartesian/axes":208,"./attributes":31,"./common_defaults":34}],37:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/array_container_defaults":202,"../../plots/cartesian/axes":206,"./attributes":31,"./common_defaults":34}],37:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16039,14 +16039,14 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { x: borderfull + xShift - 1, y: borderfull + yShift }) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; annText.call(svgTextUtils.positionText, textx, texty) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } annTextClip.select('rect').call(Drawing.setRect, borderfull, borderfull, @@ -16212,7 +16212,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }); }, doneFn: function() { - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -16295,7 +16295,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }, doneFn: function() { setCursor(annTextGroupInner); - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -16319,13 +16319,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { modifyBase(ya._name + '.autorange', true); } - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); }); } else annText.call(textLayout); } -},{"../../lib":164,"../../lib/setcursor":183,"../../lib/svg_text_utils":185,"../../plot_api/plot_template":198,"../../plots/cartesian/axes":208,"../../plots/plots":241,"../../registry":248,"../color":46,"../dragelement":68,"../drawing":71,"../fx":88,"./draw_arrow_head":38,"d3":11}],38:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../lib/setcursor":181,"../../lib/svg_text_utils":183,"../../plot_api/plot_template":196,"../../plots/cartesian/axes":206,"../../plots/plots":239,"../../registry":246,"../color":46,"../dragelement":64,"../drawing":67,"../fx":85,"./draw_arrow_head":38,"d3":11}],38:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16513,7 +16513,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":219,"./attributes":31,"./calc_autorange":32,"./click":33,"./convert_coords":35,"./defaults":36,"./draw":37}],40:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":217,"./attributes":31,"./calc_autorange":32,"./click":33,"./convert_coords":35,"./defaults":36,"./draw":37}],40:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16601,7 +16601,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":191,"../../plot_api/plot_template":198,"../annotations/attributes":31}],41:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../annotations/attributes":31}],41:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16666,7 +16666,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":164,"../../plots/cartesian/axes":208}],42:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/cartesian/axes":206}],42:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16742,7 +16742,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":164,"../../plots/array_container_defaults":204,"../../plots/cartesian/axes":208,"../annotations/common_defaults":34,"./attributes":40}],43:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/array_container_defaults":202,"../../plots/cartesian/axes":206,"../annotations/common_defaults":34,"./attributes":40}],43:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16794,7 +16794,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":238,"../annotations/draw":37}],44:[function(_dereq_,module,exports){ +},{"../../plots/gl3d/project":236,"../annotations/draw":37}],44:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16842,7 +16842,7 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":164,"../../registry":248,"./attributes":40,"./convert":41,"./defaults":42,"./draw":43}],45:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../registry":246,"./attributes":40,"./convert":41,"./defaults":42,"./draw":43}],45:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17196,23 +17196,43 @@ module.exports = overrideAll({ exponentformat: axesAttrs.exponentformat, showexponent: axesAttrs.showexponent, title: { - valType: 'string', - - + text: { + valType: 'string', + + + }, + font: fontAttrs({ + + }), + side: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } }, - titlefont: fontAttrs({ - - }), - titleside: { - valType: 'enumerated', - values: ['right', 'top', 'bottom'], - - dflt: 'top', - + + _deprecated: { + title: { + valType: 'string', + + + }, + titlefont: fontAttrs({ + + }), + titleside: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":158,"../../plot_api/edit_types":191,"../../plots/cartesian/layout_attributes":221,"../../plots/font_attributes":235}],48:[function(_dereq_,module,exports){ +},{"../../lib/extend":156,"../../plot_api/edit_types":189,"../../plots/cartesian/layout_attributes":219,"../../plots/font_attributes":233}],48:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17221,10 +17241,10 @@ module.exports = overrideAll({ * LICENSE file in the root directory of this source tree. */ - 'use strict'; var drawColorbar = _dereq_('./draw'); +var flipScale = _dereq_('../colorscale/helpers').flipScale; /** * connectColorbar: create a colorbar from a trace, using its module to @@ -17264,12 +17284,16 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) { var cb = cd[0].t.cb = drawColorbar(gd, cbId); - cb.fillgradient(container.colorscale) + var scl = container.reversescale ? + flipScale(container.colorscale) : + container.colorscale; + + cb.fillgradient(scl) .zrange([container[moduleOpts.min], container[moduleOpts.max]]) .options(container.colorbar)(); }; -},{"./draw":51}],49:[function(_dereq_,module,exports){ +},{"../colorscale/helpers":57,"./draw":51}],49:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17359,12 +17383,12 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); - coerce('title', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'titlefont', layout.font); - coerce('titleside'); + coerce('title.text', layout._dfltTitle.colorbar); + Lib.coerceFont(coerce, 'title.font', layout.font); + coerce('title.side'); }; -},{"../../lib":164,"../../plot_api/plot_template":198,"../../plots/cartesian/tick_label_defaults":228,"../../plots/cartesian/tick_mark_defaults":229,"../../plots/cartesian/tick_value_defaults":230,"./attributes":47}],51:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/cartesian/tick_label_defaults":226,"../../plots/cartesian/tick_mark_defaults":227,"../../plots/cartesian/tick_value_defaults":228,"./attributes":47}],51:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17551,9 +17575,9 @@ module.exports = function draw(gd, id) { showticksuffix: opts.showticksuffix, ticksuffix: opts.ticksuffix, title: opts.title, - titlefont: opts.titlefont, showline: true, anchor: 'free', + side: 'right', position: 1 }, cbAxisOut = { @@ -17564,6 +17588,7 @@ module.exports = function draw(gd, id) { letter: 'y', font: fullLayout.font, noHover: true, + noTickson: true, calendar: fullLayout.calendar // not really necessary (yet?) }; @@ -17584,11 +17609,11 @@ module.exports = function draw(gd, id) { // save for other callers to access this axis component.axis = cbAxisOut; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { - cbAxisOut.titleside = opts.titleside; + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { + cbAxisOut.title.side = opts.title.side; cbAxisOut.titlex = opts.x + xpadFrac; cbAxisOut.titley = yBottomFrac + - (opts.titleside === 'top' ? lenFrac - ypadFrac : ypadFrac); + (opts.title.side === 'top' ? lenFrac - ypadFrac : ypadFrac); } if(opts.line.color && opts.tickmode === 'auto') { @@ -17648,17 +17673,18 @@ module.exports = function draw(gd, id) { Math.round(gs.l) + ',-' + Math.round(gs.t) + ')'); - cbAxisOut._axislayer = container.select('.cbaxis'); + var axisLayer = container.select('.cbaxis'); + var titleHeight = 0; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // draw the title so we know how much room it needs // when we squish the axis. This one only applies to // top or bottom titles, not right side. var x = gs.l + (opts.x + xpadFrac) * gs.w, - fontSize = cbAxisOut.titlefont.size, + fontSize = cbAxisOut.title.font.size, y; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; } @@ -17672,7 +17698,7 @@ module.exports = function draw(gd, id) { } function drawAxis() { - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // squish the axis top to make room for the title var titleGroup = container.select('.cbtitle'), titleText = titleGroup.select('text'), @@ -17703,7 +17729,7 @@ module.exports = function draw(gd, id) { // TODO: configurable titleHeight += 5; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; } @@ -17724,8 +17750,7 @@ module.exports = function draw(gd, id) { .attr('transform', 'translate(0,' + Math.round(gs.h * (1 - cbAxisOut.domain[1])) + ')'); - cbAxisOut._axislayer.attr('transform', 'translate(0,' + - Math.round(-gs.t) + ')'); + axisLayer.attr('transform', 'translate(0,' + Math.round(-gs.t) + ')'); var fills = container.select('.cbfills') .selectAll('rect.cbfill') @@ -17792,12 +17817,7 @@ module.exports = function draw(gd, id) { }); // force full redraw of labels and ticks - cbAxisOut._axislayer.selectAll('g.' + cbAxisOut._id + 'tick,path') - .remove(); - - cbAxisOut._pos = xLeft + thickPx + - (opts.outlinewidth||0) / 2 - (opts.ticks === 'outside' ? 1 : 0); - cbAxisOut.side = 'right'; + axisLayer.selectAll('g.' + cbAxisOut._id + 'tick,path').remove(); // separate out axis and title drawing, // so we don't need such complicated logic in Titles.draw @@ -17805,11 +17825,33 @@ module.exports = function draw(gd, id) { // this title call only handles side=right return Lib.syncOrAsync([ function() { - return Axes.doTicksSingle(gd, cbAxisOut, true); + var shift = xLeft + thickPx + + (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0); + + var vals = Axes.calcTicks(cbAxisOut); + var transFn = Axes.makeTransFn(cbAxisOut); + var labelFns = Axes.makeLabelFns(cbAxisOut, shift); + var tickSign = Axes.getTickSigns(cbAxisOut)[2]; + + Axes.drawTicks(gd, cbAxisOut, { + vals: cbAxisOut.ticks === 'inside' ? Axes.clipEnds(cbAxisOut, vals) : vals, + layer: axisLayer, + path: Axes.makeTickPath(cbAxisOut, shift, tickSign), + transFn: transFn + }); + + return Axes.drawLabels(gd, cbAxisOut, { + vals: vals, + layer: axisLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); }, function() { - if(['top', 'bottom'].indexOf(opts.titleside) === -1) { - var fontSize = cbAxisOut.titlefont.size, + if(['top', 'bottom'].indexOf(opts.title.side) === -1) { + var fontSize = cbAxisOut.title.font.size, y = cbAxisOut._offset + cbAxisOut._length / 2, x = gs.l + (cbAxisOut.position || 0) * gs.w + ((cbAxisOut.side === 'right') ? 10 + fontSize * ((cbAxisOut.showticklabels ? 1 : 0.5)) : @@ -17821,7 +17863,7 @@ module.exports = function draw(gd, id) { drawTitle('h' + cbAxisOut._id + 'title', { avoid: { selection: d3.select(gd).selectAll('g.' + cbAxisOut._id + 'tick'), - side: opts.titleside, + side: opts.title.side, offsetLeft: gs.l, offsetTop: 0, maxShift: fullLayout.width @@ -17834,15 +17876,10 @@ module.exports = function draw(gd, id) { } function drawTitle(titleClass, titleOpts) { - var trace = getTrace(); - var propName = 'colorbar.title'; - var containerName = trace._module.colorbar.container; - if(containerName) propName = containerName + '.' + propName; - var dfltTitleOpts = { propContainer: cbAxisOut, - propName: propName, - traceIndex: trace.index, + propName: getPropName('title'), + traceIndex: getTrace().index, placeholder: fullLayout._dfltTitle.colorbar, containerGroup: container.select('.cbtitle') }; @@ -17866,7 +17903,7 @@ module.exports = function draw(gd, id) { // TODO: why are we redrawing multiple times now with this? // I guess autoMargin doesn't like being post-promise? var innerWidth = thickPx + opts.outlinewidth / 2 + - Drawing.bBox(cbAxisOut._axislayer.node()).width; + Drawing.bBox(axisLayer.node()).width; titleEl = titleCont.select('text'); if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) { var mathJaxNode = titleCont @@ -17874,11 +17911,11 @@ module.exports = function draw(gd, id) { .node(), titleWidth; if(mathJaxNode && - ['top', 'bottom'].indexOf(opts.titleside) !== -1) { + ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; } else { - // note: the formula below works for all titlesides, + // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift // transform gets removed by Drawing.bBox @@ -17907,7 +17944,7 @@ module.exports = function draw(gd, id) { container.selectAll('.cboutline').attr({ x: xLeft, y: yTopPx + opts.ypad + - (opts.titleside === 'top' ? titleHeight : 0), + (opts.title.side === 'top' ? titleHeight : 0), width: Math.max(thickPx, 2), height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2) }) @@ -17994,11 +18031,10 @@ module.exports = function draw(gd, id) { setCursor(container); if(xf !== undefined && yf !== undefined) { - Registry.call('restyle', - gd, - {'colorbar.x': xf, 'colorbar.y': yf}, - getTrace().index - ); + var update = {}; + update[getPropName('x')] = xf; + update[getPropName('y')] = yf; + Registry.call('_guiRestyle', gd, update, getTrace().index); } } }); @@ -18016,6 +18052,14 @@ module.exports = function draw(gd, id) { } } + function getPropName(suffix) { + var trace = getTrace(); + var propName = 'colorbar.'; + var containerName = trace._module.colorbar.container; + if(containerName) propName = containerName + '.' + propName; + return propName + suffix; + } + // setter/getters for every item defined in opts Object.keys(opts).forEach(function(name) { component[name] = function(v) { @@ -18049,7 +18093,7 @@ module.exports = function draw(gd, id) { return component; }; -},{"../../constants/alignment":144,"../../lib":164,"../../lib/extend":158,"../../lib/setcursor":183,"../../lib/svg_text_utils":185,"../../plots/cartesian/axes":208,"../../plots/cartesian/axis_defaults":210,"../../plots/cartesian/layout_attributes":221,"../../plots/cartesian/position_defaults":224,"../../plots/plots":241,"../../registry":248,"../color":46,"../dragelement":68,"../drawing":71,"../titles":137,"./attributes":47,"./constants":49,"d3":11,"tinycolor2":29}],52:[function(_dereq_,module,exports){ +},{"../../constants/alignment":141,"../../lib":162,"../../lib/extend":156,"../../lib/setcursor":181,"../../lib/svg_text_utils":183,"../../plots/cartesian/axes":206,"../../plots/cartesian/axis_defaults":208,"../../plots/cartesian/layout_attributes":219,"../../plots/cartesian/position_defaults":222,"../../plots/plots":239,"../../registry":246,"../color":46,"../dragelement":64,"../drawing":67,"../titles":134,"./attributes":47,"./constants":49,"d3":11,"tinycolor2":29}],52:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18068,7 +18112,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":164}],53:[function(_dereq_,module,exports){ +},{"../../lib":162}],53:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18079,7 +18123,7 @@ module.exports = function hasColorbar(container) { 'use strict'; -var palettes = _dereq_('./scales.js'); +var palettes = _dereq_('./scales.js').scales; var paletteStr = Object.keys(palettes); function code(s) { @@ -18226,7 +18270,7 @@ module.exports = function colorScaleAttrs(context, opts) { valType: 'boolean', dflt: false, - editType: 'calc', + editType: 'plot', }; @@ -18243,7 +18287,7 @@ module.exports = function colorScaleAttrs(context, opts) { return attrs; }; -},{"./scales.js":65}],54:[function(_dereq_,module,exports){ +},{"./scales.js":61}],54:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18252,49 +18296,19 @@ module.exports = function colorScaleAttrs(context, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); -var scales = _dereq_('./scales'); -var flipScale = _dereq_('./flip_scale'); - - -module.exports = function calc(trace, vals, containerStr, cLetter) { - var container = trace; - var inputContainer = trace._input; - var fullInputContainer = trace._fullInput; - - // set by traces with groupby transforms - var updateStyle = trace.updateStyle; - - function doUpdate(attr, inputVal, fullVal) { - if(fullVal === undefined) fullVal = inputVal; - - if(updateStyle) { - updateStyle(trace._input, containerStr ? (containerStr + '.' + attr) : attr, inputVal); - } - else { - inputContainer[attr] = inputVal; - } - - container[attr] = fullVal; - if(fullInputContainer && (trace !== trace._fullInput)) { - if(updateStyle) { - updateStyle(trace._fullInput, containerStr ? (containerStr + '.' + attr) : attr, fullVal); - } - else { - fullInputContainer[attr] = fullVal; - } - } - } +module.exports = function calc(gd, trace, opts) { + var fullLayout = gd._fullLayout; + var vals = opts.vals; + var containerStr = opts.containerStr; + var cLetter = opts.cLetter; - if(containerStr) { - container = Lib.nestedProperty(container, containerStr).get(); - inputContainer = Lib.nestedProperty(inputContainer, containerStr).get(); - fullInputContainer = Lib.nestedProperty(fullInputContainer, containerStr).get() || {}; - } + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() : + trace; var autoAttr = cLetter + 'auto'; var minAttr = cLetter + 'min'; @@ -18317,37 +18331,19 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { max += 0.5; } - doUpdate(minAttr, min); - doUpdate(maxAttr, max); - - /* - * If auto was explicitly false but min or max was missing, - * we filled in the missing piece here but later the trace does - * not look auto. - * Otherwise make sure the trace still looks auto as far as later - * changes are concerned. - */ - doUpdate(autoAttr, (auto !== false || (min === undefined && max === undefined))); + container['_' + minAttr] = container[minAttr] = min; + container['_' + maxAttr] = container[maxAttr] = max; if(container.autocolorscale) { - if(min * max < 0) scl = scales.RdBu; - else if(min >= 0) scl = scales.Reds; - else scl = scales.Blues; - - // reversescale is handled at the containerOut level - doUpdate('colorscale', scl, container.reversescale ? flipScale(scl) : scl); + if(min * max < 0) scl = fullLayout.colorscale.diverging; + else if(min >= 0) scl = fullLayout.colorscale.sequential; + else scl = fullLayout.colorscale.sequentialminus; - // We pushed a colorscale back to input, which will change the default autocolorscale next time - // to avoid spurious redraws from Plotly.react, update resulting autocolorscale now - // This is a conscious decision so that changing the data later does not unexpectedly - // give you a new colorscale - if(!inputContainer.autocolorscale) { - doUpdate('autocolorscale', false); - } + container._colorscale = container.colorscale = scl; } }; -},{"../../lib":164,"./flip_scale":58,"./scales":65}],55:[function(_dereq_,module,exports){ +},{"../../lib":162}],55:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18358,12 +18354,68 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { 'use strict'; -var scales = _dereq_('./scales'); +var Lib = _dereq_('../../lib'); +var hasColorscale = _dereq_('./helpers').hasColorscale; +module.exports = function crossTraceDefaults(fullData) { + function replace(cont, k) { + var val = cont['_' + k]; + if(val !== undefined) { + cont[k] = val; + } + } + + function relinkColorAtts(trace, cAttrs) { + var cont = cAttrs.container ? + Lib.nestedProperty(trace, cAttrs.container).get() : + trace; + + if(cont) { + var isAuto = cont.zauto || cont.cauto; + var minAttr = cAttrs.min; + var maxAttr = cAttrs.max; + + if(isAuto || cont[minAttr] === undefined) { + replace(cont, minAttr); + } + if(isAuto || cont[maxAttr] === undefined) { + replace(cont, maxAttr); + } + if(cont.autocolorscale) { + replace(cont, 'colorscale'); + } + } + } + + for(var i = 0; i < fullData.length; i++) { + var trace = fullData[i]; + var _module = trace._module; + + if(_module.colorbar) { + relinkColorAtts(trace, _module.colorbar); + } + + // TODO could generalize _module.colorscale and use it here? + + if(hasColorscale(trace, 'marker.line')) { + relinkColorAtts(trace, { + container: 'marker.line', + min: 'cmin', + max: 'cmax' + }); + } -module.exports = scales.RdBu; + if(hasColorscale(trace, 'line')) { + relinkColorAtts(trace, { + container: 'line', + min: 'cmin', + max: 'cmax' + }); + } + } +}; -},{"./scales":65}],56:[function(_dereq_,module,exports){ +},{"../../lib":162,"./helpers":57}],56:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18372,33 +18424,32 @@ module.exports = scales.RdBu; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); - var hasColorbar = _dereq_('../colorbar/has_colorbar'); var colorbarDefaults = _dereq_('../colorbar/defaults'); -var isValidScale = _dereq_('./is_valid_scale'); -var flipScale = _dereq_('./flip_scale'); +var isValidScale = _dereq_('./scales').isValid; -module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { - var prefix = opts.prefix, - cLetter = opts.cLetter, - containerStr = prefix.slice(0, prefix.length - 1), - containerIn = prefix ? - Lib.nestedProperty(traceIn, containerStr).get() || {} : - traceIn, - containerOut = prefix ? - Lib.nestedProperty(traceOut, containerStr).get() || {} : - traceOut, - minIn = containerIn[cLetter + 'min'], - maxIn = containerIn[cLetter + 'max'], - sclIn = containerIn.colorscale; +function npMaybe(cont, prefix) { + var containerStr = prefix.slice(0, prefix.length - 1); + return prefix ? + Lib.nestedProperty(cont, containerStr).get() || {} : + cont; +} +module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { + var prefix = opts.prefix; + var cLetter = opts.cLetter; + var containerIn = npMaybe(traceIn, prefix); + var containerOut = npMaybe(traceOut, prefix); + var template = npMaybe(traceOut._template || {}, prefix) || {}; + + var minIn = containerIn[cLetter + 'min']; + var maxIn = containerIn[cLetter + 'max']; var validMinMax = isNumeric(minIn) && isNumeric(maxIn) && (minIn < maxIn); coerce(prefix + cLetter + 'auto', !validMinMax); coerce(prefix + cLetter + 'min'); @@ -18406,19 +18457,17 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, // handles both the trace case (autocolorscale is false by default) and // the marker and marker.line case (autocolorscale is true by default) + var sclIn = containerIn.colorscale; + var sclTemplate = template.colorscale; var autoColorscaleDflt; if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn); + if(sclTemplate !== undefined) autoColorscaleDflt = !isValidScale(sclTemplate); coerce(prefix + 'autocolorscale', autoColorscaleDflt); - var sclOut = coerce(prefix + 'colorscale'); - - // reversescale is handled at the containerOut level - var reverseScale = coerce(prefix + 'reversescale'); - if(reverseScale) containerOut.colorscale = flipScale(sclOut); - // ... until Scatter.colorbar can handle marker line colorbars - if(prefix === 'marker.line.') return; + coerce(prefix + 'colorscale'); + coerce(prefix + 'reversescale'); - if(!opts.noScale) { + if(!opts.noScale && prefix !== 'marker.line.') { // handles both the trace case where the dflt is listed in attributes and // the marker case where the dflt is determined by hasColorbar var showScaleDflt; @@ -18429,109 +18478,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, } }; -},{"../../lib":164,"../colorbar/defaults":50,"../colorbar/has_colorbar":52,"./flip_scale":58,"./is_valid_scale":62,"fast-isnumeric":13}],57:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -/** - * Extract colorscale into numeric domain and color range. - * - * @param {array} scl colorscale array of arrays - * @param {number} cmin minimum color value (used to clamp scale) - * @param {number} cmax maximum color value (used to clamp scale) - */ -module.exports = function extractScale(scl, cmin, cmax) { - var N = scl.length, - domain = new Array(N), - range = new Array(N); - - for(var i = 0; i < N; i++) { - var si = scl[i]; - - domain[i] = cmin + si[0] * (cmax - cmin); - range[i] = si[1]; - } - - return { - domain: domain, - range: range - }; -}; - -},{}],58:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function flipScale(scl) { - var N = scl.length, - sclNew = new Array(N), - si; - - for(var i = N - 1, j = 0; i >= 0; i--, j++) { - si = scl[i]; - sclNew[j] = [1 - si[0], si[1]]; - } - - return sclNew; -}; - -},{}],59:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var defaultScale = _dereq_('./default_scale'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function getScale(scl, dflt) { - if(!dflt) dflt = defaultScale; - if(!scl) return dflt; - - function parseScale() { - try { - scl = scales[scl] || JSON.parse(scl); - } - catch(e) { - scl = dflt; - } - } - - if(typeof scl === 'string') { - parseScale(); - // occasionally scl is double-JSON encoded... - if(typeof scl === 'string') parseScale(); - } - - if(!isValidScaleArray(scl)) return dflt; - return scl; -}; - -},{"./default_scale":55,"./is_valid_scale_array":63,"./scales":65}],60:[function(_dereq_,module,exports){ +},{"../../lib":162,"../colorbar/defaults":50,"../colorbar/has_colorbar":52,"./scales":61,"fast-isnumeric":13}],57:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18542,11 +18489,16 @@ module.exports = function getScale(scl, dflt) { 'use strict'; +var d3 = _dereq_('d3'); +var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); + var Lib = _dereq_('../../lib'); -var isValidScale = _dereq_('./is_valid_scale'); +var Color = _dereq_('../color'); + +var isValidScale = _dereq_('./scales').isValid; -module.exports = function hasColorscale(trace, containerStr) { +function hasColorscale(trace, containerStr) { var container = containerStr ? Lib.nestedProperty(trace, containerStr).get() || {} : trace; @@ -18571,117 +18523,61 @@ module.exports = function hasColorscale(trace, containerStr) { Lib.isPlainObject(container.colorbar) ) ); -}; - -},{"../../lib":164,"./is_valid_scale":62,"fast-isnumeric":13}],61:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -exports.scales = _dereq_('./scales'); - -exports.defaultScale = _dereq_('./default_scale'); - -exports.attributes = _dereq_('./attributes'); - -exports.handleDefaults = _dereq_('./defaults'); - -exports.calc = _dereq_('./calc'); - -exports.hasColorscale = _dereq_('./has_colorscale'); - -exports.isValidScale = _dereq_('./is_valid_scale'); - -exports.getScale = _dereq_('./get_scale'); - -exports.flipScale = _dereq_('./flip_scale'); - -exports.extractScale = _dereq_('./extract_scale'); - -exports.makeColorScaleFunc = _dereq_('./make_color_scale_func'); - -},{"./attributes":53,"./calc":54,"./default_scale":55,"./defaults":56,"./extract_scale":57,"./flip_scale":58,"./get_scale":59,"./has_colorscale":60,"./is_valid_scale":62,"./make_color_scale_func":64,"./scales":65}],62:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function isValidScale(scl) { - if(scales[scl] !== undefined) return true; - else return isValidScaleArray(scl); -}; +} -},{"./is_valid_scale_array":63,"./scales":65}],63:[function(_dereq_,module,exports){ /** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var tinycolor = _dereq_('tinycolor2'); - - -module.exports = function isValidScaleArray(scl) { - var highestVal = 0; + * Extract colorscale into numeric domain and color range. + * + * @param {object} cont colorscale container (e.g. trace, marker) + * - colorscale {array of arrays} + * - cmin/zmin {number} + * - cmax/zmax {number} + * - reversescale {boolean} + * @param {object} opts + * - cLetter {string} 'c' (for cmin/cmax) or 'z' (for zmin/zmax) + * + * @return {object} + * - domain {array} + * - range {array} + */ +function extractScale(cont, opts) { + var cLetter = opts.cLetter; - if(!Array.isArray(scl) || scl.length < 2) return false; + var scl = cont.reversescale ? + flipScale(cont.colorscale) : + cont.colorscale; - if(!scl[0] || !scl[scl.length - 1]) return false; + // minimum color value (used to clamp scale) + var cmin = cont[cLetter + 'min']; + // maximum color value (used to clamp scale) + var cmax = cont[cLetter + 'max']; - if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + var N = scl.length; + var domain = new Array(N); + var range = new Array(N); - for(var i = 0; i < scl.length; i++) { + for(var i = 0; i < N; i++) { var si = scl[i]; - - if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { - return false; - } - - highestVal = +si[0]; + domain[i] = cmin + si[0] * (cmax - cmin); + range[i] = si[1]; } - return true; -}; - -},{"tinycolor2":29}],64:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; + return { + domain: domain, + range: range + }; +} -var d3 = _dereq_('d3'); -var tinycolor = _dereq_('tinycolor2'); -var isNumeric = _dereq_('fast-isnumeric'); +function flipScale(scl) { + var N = scl.length; + var sclNew = new Array(N); -var Color = _dereq_('../color'); + for(var i = N - 1, j = 0; i >= 0; i--, j++) { + var si = scl[i]; + sclNew[j] = [1 - si[0], si[1]]; + } + return sclNew; +} /** * General colorscale function generator. @@ -18696,7 +18592,7 @@ var Color = _dereq_('../color'); * * @return {function} */ -module.exports = function makeColorScaleFunc(specs, opts) { +function makeColorScaleFunc(specs, opts) { opts = opts || {}; var domain = specs.domain, @@ -18748,7 +18644,7 @@ module.exports = function makeColorScaleFunc(specs, opts) { sclFunc.range = function() { return range; }; return sclFunc; -}; +} function colorArray2rbga(colorArray) { var colorObj = { @@ -18761,7 +18657,14 @@ function colorArray2rbga(colorArray) { return tinycolor(colorObj).toRgbString(); } -},{"../color":46,"d3":11,"fast-isnumeric":13,"tinycolor2":29}],65:[function(_dereq_,module,exports){ +module.exports = { + hasColorscale: hasColorscale, + extractScale: extractScale, + flipScale: flipScale, + makeColorScaleFunc: makeColorScaleFunc +}; + +},{"../../lib":162,"../color":46,"./scales":61,"d3":11,"fast-isnumeric":13,"tinycolor2":29}],58:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18772,8 +18675,116 @@ function colorArray2rbga(colorArray) { 'use strict'; +var scales = _dereq_('./scales'); +var helpers = _dereq_('./helpers'); module.exports = { + moduleType: 'component', + name: 'colorscale', + + attributes: _dereq_('./attributes'), + layoutAttributes: _dereq_('./layout_attributes'), + + supplyLayoutDefaults: _dereq_('./layout_defaults'), + handleDefaults: _dereq_('./defaults'), + crossTraceDefaults: _dereq_('./cross_trace_defaults'), + + calc: _dereq_('./calc'), + + // ./scales.js is required in lib/coerce.js ; + // it needs to be a seperate module to avoid circular a dependency + scales: scales.scales, + defaultScale: scales.defaultScale, + getScale: scales.get, + isValidScale: scales.isValid, + + hasColorscale: helpers.hasColorscale, + flipScale: helpers.flipScale, + extractScale: helpers.extractScale, + makeColorScaleFunc: helpers.makeColorScaleFunc +}; + +},{"./attributes":53,"./calc":54,"./cross_trace_defaults":55,"./defaults":56,"./helpers":57,"./layout_attributes":59,"./layout_defaults":60,"./scales":61}],59:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var scales = _dereq_('./scales').scales; + +var msg = 'Note that `autocolorscale` must be true for this attribute to work.'; + +module.exports = { + editType: 'calc', + sequential: { + valType: 'colorscale', + dflt: scales.Reds, + + editType: 'calc', + + }, + sequentialminus: { + valType: 'colorscale', + dflt: scales.Blues, + + editType: 'calc', + + }, + diverging: { + valType: 'colorscale', + dflt: scales.RdBu, + + editType: 'calc', + + } +}; + +},{"./scales":61}],60:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var Lib = _dereq_('../../lib'); +var colorscaleAttrs = _dereq_('./layout_attributes'); +var Template = _dereq_('../../plot_api/plot_template'); + +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var colorscaleIn = layoutIn.colorscale; + var colorscaleOut = Template.newContainer(layoutOut, 'colorscale'); + function coerce(attr, dflt) { + return Lib.coerce(colorscaleIn, colorscaleOut, colorscaleAttrs, attr, dflt); + } + + coerce('sequential'); + coerce('sequentialminus'); + coerce('diverging'); +}; + +},{"../../lib":162,"../../plot_api/plot_template":196,"./layout_attributes":59}],61:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var tinycolor = _dereq_('tinycolor2'); + +var scales = { 'Greys': [ [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] ], @@ -18904,7 +18915,67 @@ module.exports = { ] }; -},{}],66:[function(_dereq_,module,exports){ +var defaultScale = scales.RdBu; + +function getScale(scl, dflt) { + if(!dflt) dflt = defaultScale; + if(!scl) return dflt; + + function parseScale() { + try { + scl = scales[scl] || JSON.parse(scl); + } catch(e) { + scl = dflt; + } + } + + if(typeof scl === 'string') { + parseScale(); + // occasionally scl is double-JSON encoded... + if(typeof scl === 'string') parseScale(); + } + + if(!isValidScaleArray(scl)) return dflt; + return scl; +} + + +function isValidScaleArray(scl) { + var highestVal = 0; + + if(!Array.isArray(scl) || scl.length < 2) return false; + + if(!scl[0] || !scl[scl.length - 1]) return false; + + if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + + for(var i = 0; i < scl.length; i++) { + var si = scl[i]; + + if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { + return false; + } + + highestVal = +si[0]; + } + + return true; +} + +function isValidScale(scl) { + if(scales[scl] !== undefined) return true; + else return isValidScaleArray(scl); +} + +module.exports = { + scales: scales, + defaultScale: defaultScale, + + get: getScale, + isValid: isValidScale +}; + +},{"tinycolor2":29}],62:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18937,7 +19008,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],67:[function(_dereq_,module,exports){ +},{}],63:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18975,7 +19046,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":164}],68:[function(_dereq_,module,exports){ +},{"../../lib":162}],64:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19102,8 +19173,6 @@ dragElement.init = function init(options) { var clampFn = options.clampFn || _clampFn; function onStart(e) { - e.preventDefault(); - // make dragging and dragged into properties of gd // so that others can look at and modify them gd._dragged = false; @@ -19145,11 +19214,15 @@ dragElement.init = function init(options) { document.documentElement.style.cursor = window.getComputedStyle(element).cursor; } - document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onDone); - document.addEventListener('touchmove', onMove); document.addEventListener('touchend', onDone); + if(options.dragmode !== false) { + e.preventDefault(); + document.addEventListener('mousemove', onMove); + document.addEventListener('touchmove', onMove); + } + return; } @@ -19173,13 +19246,15 @@ dragElement.init = function init(options) { } function onDone(e) { - document.removeEventListener('mousemove', onMove); + if(options.dragmode !== false) { + e.preventDefault(); + document.removeEventListener('mousemove', onMove); + document.removeEventListener('touchmove', onMove); + } + document.removeEventListener('mouseup', onDone); - document.removeEventListener('touchmove', onMove); document.removeEventListener('touchend', onDone); - e.preventDefault(); - if(hasHover) { Lib.removeElement(dragCover); } @@ -19272,7 +19347,7 @@ function pointerOffset(e) { ); } -},{"../../constants/interactions":145,"../../lib":164,"../../plots/cartesian/constants":214,"../../registry":248,"./align":66,"./cursor":67,"./unhover":69,"has-hover":15,"has-passive-events":16,"mouse-event-offset":19}],69:[function(_dereq_,module,exports){ +},{"../../constants/interactions":142,"../../lib":162,"../../plots/cartesian/constants":212,"../../registry":246,"./align":62,"./cursor":63,"./unhover":65,"has-hover":15,"has-passive-events":16,"mouse-event-offset":19}],65:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19330,7 +19405,7 @@ unhover.raw = function unhoverRaw(gd, evt) { } }; -},{"../../lib/events":157,"../../lib/get_graph_div":162,"../../lib/throttle":186,"../fx/constants":83}],70:[function(_dereq_,module,exports){ +},{"../../lib/events":155,"../../lib/get_graph_div":160,"../../lib/throttle":184,"../fx/constants":79}],66:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19355,7 +19430,7 @@ exports.dash = { }; -},{}],71:[function(_dereq_,module,exports){ +},{}],67:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19556,7 +19631,11 @@ drawing.fillGroupStyle = function(s) { s.style('stroke-width', 0) .each(function(d) { var shape = d3.select(this); - shape.call(Color.fill, d[0].trace.fillcolor); + // N.B. 'd' won't be a calcdata item when + // fill !== 'none' on a segment-less and marker-less trace + if(d[0].trace) { + shape.call(Color.fill, d[0].trace.fillcolor); + } }); }; @@ -19997,7 +20076,7 @@ drawing.tryColorscale = function(marker, prefix) { if(scl && Lib.isArrayOrTypedArray(colorArray)) { return Colorscale.makeColorScaleFunc( - Colorscale.extractScale(scl, cont.cmin, cont.cmax) + Colorscale.extractScale(cont, {cLetter: 'c'}) ); } } @@ -20358,32 +20437,28 @@ function nodeHash(node) { node.getAttribute('style'); } -/* - * make a robust clipPath url from a local id - * note! We'd better not be exporting from a page - * with a or the svg will not be portable! +/** + * Set clipPath URL in a way that work for all situations. + * + * In details, graphs on pages with HTML tags need to prepend + * the clip path ids with the page's base url EXCEPT during toImage exports. + * + * @param {d3 selection} s : node to add clip-path attribute + * @param {string} localId : local clip-path (w/o base url) id + * @param {DOM element || object} gd + * - context._baseUrl {string} + * - context._exportedPlot {boolean} */ -drawing.setClipUrl = function(s, localId) { +drawing.setClipUrl = function(s, localId, gd) { if(!localId) { s.attr('clip-path', null); return; } - if(drawing.baseUrl === undefined) { - var base = d3.select('base'); - - // Stash base url once and for all! - // We may have to stash this elsewhere when - // we'll try to support for child windows - // more info -> https://github.com/plotly/plotly.js/issues/702 - if(base.size() && base.attr('href')) { - drawing.baseUrl = window.location.href.split('#')[0]; - } else { - drawing.baseUrl = ''; - } - } + var context = gd._context; + var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - s.attr('clip-path', 'url(' + drawing.baseUrl + '#' + localId + ')'); + s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')'); }; drawing.getTranslate = function(element) { @@ -20515,7 +20590,7 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../constants/alignment":144,"../../constants/interactions":145,"../../constants/xmlns_namespaces":147,"../../lib":164,"../../lib/svg_text_utils":185,"../../registry":248,"../../traces/scatter/make_bubble_size_func":333,"../../traces/scatter/subtypes":340,"../color":46,"../colorscale":61,"./symbol_defs":72,"d3":11,"fast-isnumeric":13,"tinycolor2":29}],72:[function(_dereq_,module,exports){ +},{"../../constants/alignment":141,"../../constants/interactions":142,"../../constants/xmlns_namespaces":144,"../../lib":162,"../../lib/svg_text_utils":183,"../../registry":246,"../../traces/scatter/make_bubble_size_func":333,"../../traces/scatter/subtypes":340,"../color":46,"../colorscale":58,"./symbol_defs":68,"d3":11,"fast-isnumeric":13,"tinycolor2":29}],68:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21003,7 +21078,7 @@ module.exports = { } }; -},{"d3":11}],73:[function(_dereq_,module,exports){ +},{"d3":11}],69:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21118,7 +21193,7 @@ module.exports = { } }; -},{}],74:[function(_dereq_,module,exports){ +},{}],70:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21200,7 +21275,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max); } -},{"../../plots/cartesian/axes":208,"../../registry":248,"./compute_error":75,"fast-isnumeric":13}],75:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":206,"../../registry":246,"./compute_error":71,"fast-isnumeric":13}],71:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21304,7 +21379,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],76:[function(_dereq_,module,exports){ +},{}],72:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21380,7 +21455,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":164,"../../plot_api/plot_template":198,"../../registry":248,"./attributes":73,"fast-isnumeric":13}],77:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plot_api/plot_template":196,"../../registry":246,"./attributes":69,"fast-isnumeric":13}],73:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21449,7 +21524,7 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":164,"../../plot_api/edit_types":191,"./attributes":73,"./calc":74,"./compute_error":75,"./defaults":76,"./plot":78,"./style":79}],78:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plot_api/edit_types":189,"./attributes":69,"./calc":70,"./compute_error":71,"./defaults":72,"./plot":74,"./style":75}],74:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21467,7 +21542,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); var subTypes = _dereq_('../../traces/scatter/subtypes'); -module.exports = function plot(traces, plotinfo, transitionOpts) { +module.exports = function plot(gd, traces, plotinfo, transitionOpts) { var isNew; var xa = plotinfo.xaxis; @@ -21518,7 +21593,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { .style('opacity', 1); } - Drawing.setClipUrl(errorbars, plotinfo.layerClipId); + Drawing.setClipUrl(errorbars, plotinfo.layerClipId, gd); errorbars.each(function(d) { var errorbar = d3.select(this); @@ -21623,7 +21698,7 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":340,"../drawing":71,"d3":11,"fast-isnumeric":13}],79:[function(_dereq_,module,exports){ +},{"../../traces/scatter/subtypes":340,"../drawing":67,"d3":11,"fast-isnumeric":13}],75:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21660,7 +21735,7 @@ module.exports = function style(traces) { }); }; -},{"../color":46,"d3":11}],80:[function(_dereq_,module,exports){ +},{"../color":46,"d3":11}],76:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21706,7 +21781,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":235}],81:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":233}],77:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21743,6 +21818,8 @@ module.exports = function calc(gd) { fillFn(trace.hoverinfo, cd, 'hi', makeCoerceHoverInfo(trace)); + if(trace.hovertemplate) fillFn(trace.hovertemplate, cd, 'ht'); + if(!trace.hoverlabel) continue; fillFn(trace.hoverlabel.bgcolor, cd, 'hbg'); @@ -21762,7 +21839,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":164,"../../registry":248}],82:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../registry":246}],78:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21800,7 +21877,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":248,"./hover":86}],83:[function(_dereq_,module,exports){ +},{"../../registry":246,"./hover":82}],79:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21832,7 +21909,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],84:[function(_dereq_,module,exports){ +},{}],80:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21855,7 +21932,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, layout.hoverlabel); }; -},{"../../lib":164,"./attributes":80,"./hoverlabel_defaults":87}],85:[function(_dereq_,module,exports){ +},{"../../lib":162,"./attributes":76,"./hoverlabel_defaults":83}],81:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22098,7 +22175,7 @@ function getPointData(val, pointNumber) { } } -},{"../../lib":164}],86:[function(_dereq_,module,exports){ +},{"../../lib":162}],82:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22227,13 +22304,17 @@ exports.loneHover = function loneHover(hoverItem, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; var container3 = d3.select(opts.container); @@ -22247,7 +22328,6 @@ exports.loneHover = function loneHover(hoverItem, opts) { container: container3, outerContainer: outerContainer3 }; - var hoverLabel = createHoverText([pointData], fullOpts, opts.gd); alignHoverText(hoverLabel, fullOpts.rotateLabels); @@ -22281,13 +22361,17 @@ exports.multiHovers = function multiHovers(hoverItems, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; }); @@ -22763,7 +22847,14 @@ function _hover(gd, evt, subplot, noHoverEvent) { // other people and send it to the event for(itemnum = 0; itemnum < hoverData.length; itemnum++) { var pt = hoverData[itemnum]; - newhoverdata.push(helpers.makeEventData(pt, pt.trace, pt.cd)); + var eventData = helpers.makeEventData(pt, pt.trace, pt.cd); + + var ht = false; + if(pt.cd[pt.index] && pt.cd[pt.index].ht) ht = pt.cd[pt.index].ht; + hoverData[itemnum].hovertemplate = ht || pt.trace.hovertemplate || false; + hoverData[itemnum].eventData = [eventData]; + + newhoverdata.push(eventData); } gd._hoverdata = newhoverdata; @@ -22821,6 +22912,8 @@ function _hover(gd, evt, subplot, noHoverEvent) { }); } +var EXTRA_STRING_REGEX = /([\s\S]*)<\/extra>/; + function createHoverText(hoverData, opts, gd) { var hovermode = opts.hovermode; var rotateLabels = opts.rotateLabels; @@ -22864,11 +22957,13 @@ function createHoverText(hoverData, opts, gd) { if(allHaveZ && hoverData[i].zLabel === undefined) allHaveZ = false; traceHoverinfo = hoverData[i].hoverinfo || hoverData[i].trace.hoverinfo; - var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); - if(parts.indexOf('all') === -1 && - parts.indexOf(hovermode) === -1) { - showCommonLabel = false; - break; + if(traceHoverinfo) { + var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); + if(parts.indexOf('all') === -1 && + parts.indexOf(hovermode) === -1) { + showCommonLabel = false; + break; + } } } @@ -23051,6 +23146,19 @@ function createHoverText(hoverData, opts, gd) { text = name; } + // hovertemplate + var hovertemplate = d.hovertemplate || false; + var hovertemplateLabels = d.hovertemplateLabels || d; + var eventData = d.eventData[0] || {}; + if(hovertemplate) { + text = Lib.hovertemplateString(hovertemplate, hovertemplateLabels, eventData); + + text = text.replace(EXTRA_STRING_REGEX, function(match, extra) { + name = extra; // Assign name for secondary text label + return ''; // Remove from main text label + }); + } + // main label var tx = g.select('text.nums') .call(Drawing.font, @@ -23449,7 +23557,7 @@ function cleanPoint(d, hovermode) { var infomode = d.hoverinfo || d.trace.hoverinfo; - if(infomode !== 'all') { + if(infomode && infomode !== 'all') { infomode = Array.isArray(infomode) ? infomode : infomode.split('+'); if(infomode.indexOf('x') === -1) d.xLabel = undefined; if(infomode.indexOf('y') === -1) d.yLabel = undefined; @@ -23635,8 +23743,11 @@ function hoverChanged(gd, evt, oldhoverdata) { for(var i = oldhoverdata.length - 1; i >= 0; i--) { var oldPt = oldhoverdata[i]; var newPt = gd._hoverdata[i]; + if(oldPt.curveNumber !== newPt.curveNumber || - String(oldPt.pointNumber) !== String(newPt.pointNumber)) { + String(oldPt.pointNumber) !== String(newPt.pointNumber) || + String(oldPt.pointNumbers) !== String(newPt.pointNumbers) + ) { return true; } } @@ -23652,7 +23763,7 @@ function spikesChanged(gd, oldspikepoints) { return false; } -},{"../../lib":164,"../../lib/events":157,"../../lib/override_cursor":175,"../../lib/svg_text_utils":185,"../../plots/cartesian/axes":208,"../../registry":248,"../color":46,"../dragelement":68,"../drawing":71,"./constants":83,"./helpers":85,"d3":11,"fast-isnumeric":13,"tinycolor2":29}],87:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../lib/events":155,"../../lib/override_cursor":173,"../../lib/svg_text_utils":183,"../../plots/cartesian/axes":206,"../../registry":246,"../color":46,"../dragelement":64,"../drawing":67,"./constants":79,"./helpers":81,"d3":11,"fast-isnumeric":13,"tinycolor2":29}],83:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23674,7 +23785,49 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts Lib.coerceFont(coerce, 'hoverlabel.font', opts.font); }; -},{"../../lib":164}],88:[function(_dereq_,module,exports){ +},{"../../lib":162}],84:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function(opts, extra) { + opts = opts || {}; + extra = extra || {}; + + var descPart = extra.description ? ' ' + extra.description : ''; + var keys = extra.keys || []; + if(keys.length > 0) { + var quotedKeys = []; + for(var i = 0; i < keys.length; i++) { + quotedKeys[i] = '`' + keys[i] + '`'; + } + descPart = descPart + 'Finally, the template string has access to '; + if(keys.length === 1) { + descPart = 'variable ' + quotedKeys[0]; + } else { + descPart = 'variables ' + quotedKeys.slice(0, -1).join(', ') + ' and ' + quotedKeys.slice(-1) + '.'; + } + } + + var hovertemplate = { + valType: 'string', + + dflt: '', + arrayOk: true, + editType: 'none', + + }; + + return hovertemplate; +}; + +},{}],85:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23754,7 +23907,7 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":164,"../dragelement":68,"./attributes":80,"./calc":81,"./click":82,"./constants":83,"./defaults":84,"./helpers":85,"./hover":86,"./layout_attributes":89,"./layout_defaults":90,"./layout_global_defaults":91,"d3":11}],89:[function(_dereq_,module,exports){ +},{"../../lib":162,"../dragelement":64,"./attributes":76,"./calc":77,"./click":78,"./constants":79,"./defaults":80,"./helpers":81,"./hover":82,"./layout_attributes":86,"./layout_defaults":87,"./layout_global_defaults":88,"d3":11}],86:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23787,7 +23940,7 @@ module.exports = { dragmode: { valType: 'enumerated', - values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'], + values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable', false], dflt: 'zoom', editType: 'modebar', @@ -23849,7 +24002,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":235,"./constants":83}],90:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":233,"./constants":79}],87:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23922,7 +24075,7 @@ function isHoriz(fullData) { return out; } -},{"../../lib":164,"./layout_attributes":89}],91:[function(_dereq_,module,exports){ +},{"../../lib":162,"./layout_attributes":86}],88:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23945,7 +24098,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":164,"./hoverlabel_defaults":87,"./layout_attributes":89}],92:[function(_dereq_,module,exports){ +},{"../../lib":162,"./hoverlabel_defaults":83,"./layout_attributes":86}],89:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24330,7 +24483,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":164,"../../lib/regex":179,"../../plot_api/plot_template":198,"../../plots/cartesian/constants":214,"../../plots/domain":234}],93:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../lib/regex":177,"../../plot_api/plot_template":196,"../../plots/cartesian/constants":212,"../../plots/domain":232}],90:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24465,7 +24618,7 @@ module.exports = templatedArray('image', { editType: 'arraydraw' }); -},{"../../plot_api/plot_template":198,"../../plots/cartesian/constants":214}],94:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":196,"../../plots/cartesian/constants":212}],91:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24548,7 +24701,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":187,"fast-isnumeric":13}],95:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":185,"fast-isnumeric":13}],92:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24609,7 +24762,7 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":164,"../../plots/array_container_defaults":204,"../../plots/cartesian/axes":208,"./attributes":93}],96:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/array_container_defaults":202,"../../plots/cartesian/axes":206,"./attributes":90}],93:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24780,9 +24933,10 @@ module.exports = function draw(gd) { yId = ya ? ya._id : '', clipAxes = xId + yId; - thisImage.call(Drawing.setClipUrl, clipAxes ? - ('clip' + fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + thisImage, + clipAxes ? ('clip' + fullLayout._uid + clipAxes) : null, + gd ); } @@ -24830,7 +24984,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":147,"../../plots/cartesian/axes":208,"../drawing":71,"d3":11}],97:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":144,"../../plots/cartesian/axes":206,"../drawing":67,"d3":11}],94:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24854,56 +25008,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":219,"./attributes":93,"./convert_coords":94,"./defaults":95,"./draw":96}],98:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - - -/** - * Determine the position anchor property of x/y xanchor/yanchor components. - * - * - values < 1/3 align the low side at that fraction, - * - values [1/3, 2/3] align the center at that fraction, - * - values > 2/3 align the right at that fraction. - */ - -exports.isRightAnchor = function isRightAnchor(opts) { - return ( - opts.xanchor === 'right' || - (opts.xanchor === 'auto' && opts.x >= 2 / 3) - ); -}; - -exports.isCenterAnchor = function isCenterAnchor(opts) { - return ( - opts.xanchor === 'center' || - (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) - ); -}; - -exports.isBottomAnchor = function isBottomAnchor(opts) { - return ( - opts.yanchor === 'bottom' || - (opts.yanchor === 'auto' && opts.y <= 1 / 3) - ); -}; - -exports.isMiddleAnchor = function isMiddleAnchor(opts) { - return ( - opts.yanchor === 'middle' || - (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) - ); -}; - -},{}],99:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":217,"./attributes":90,"./convert_coords":91,"./defaults":92,"./draw":93}],95:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25001,11 +25106,25 @@ module.exports = { editType: 'legend', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + valign: { + valType: 'enumerated', + values: ['top', 'middle', 'bottom'], + dflt: 'middle', + + editType: 'legend', + }, editType: 'legend' }; -},{"../../plots/font_attributes":235,"../color/attributes":45}],100:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":233,"../color/attributes":45}],96:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25024,7 +25143,7 @@ module.exports = { textOffsetX: 40 }; -},{}],101:[function(_dereq_,module,exports){ +},{}],97:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25093,7 +25212,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { basePlotLayoutAttributes, 'showlegend', legendReallyHasATrace && legendTraceCount > 1); - if(showLegend === false) return; + if(showLegend === false && !containerIn.uirevision) return; var containerOut = Template.newContainer(layoutOut, 'legend'); @@ -25101,6 +25220,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); } + coerce('uirevision', layoutOut.uirevision); + + if(showLegend === false) return; + coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); @@ -25109,7 +25232,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('orientation'); if(containerOut.orientation === 'h') { var xaxis = layoutIn.xaxis; - if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { + if(Registry.getComponentMethod('rangeslider', 'isVisible')(xaxis)) { defaultX = 0; defaultXAnchor = 'left'; defaultY = 1.1; @@ -25130,10 +25253,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('xanchor', defaultXAnchor); coerce('y', defaultY); coerce('yanchor', defaultYAnchor); + coerce('valign'); Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); }; -},{"../../lib":164,"../../plot_api/plot_template":198,"../../plots/layout_attributes":239,"../../registry":248,"./attributes":99,"./helpers":105}],102:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/layout_attributes":237,"../../registry":246,"./attributes":95,"./helpers":101}],98:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25166,7 +25290,6 @@ var FROM_BR = alignmentConstants.FROM_BR; var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); -var anchorUtils = _dereq_('./anchor_utils'); var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; @@ -25290,17 +25413,17 @@ module.exports = function draw(gd) { lx = gs.l + gs.w * opts.x, ly = gs.t + gs.h * (1 - opts.y); - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= opts._width; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= opts._height; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -25360,7 +25483,7 @@ module.exports = function draw(gd) { y: opts.borderwidth }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; @@ -25398,7 +25521,7 @@ module.exports = function draw(gd) { y: opts.borderwidth + scrollBoxY }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -25475,7 +25598,7 @@ module.exports = function draw(gd) { }, doneFn: function() { if(xf !== undefined && yf !== undefined) { - Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf}); + Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf}); } }, clickFn: function(numClicks, e) { @@ -25582,7 +25705,7 @@ function drawTexts(g, gd, maxLength) { update.name = newName; } - return Registry.call('restyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, traceIndex); }); } else { textLayout(textEl); @@ -25672,6 +25795,7 @@ function computeTextDimensions(g, gd) { // to avoid getBoundingClientRect var textY = lineHeight * (0.3 + (1 - textLines) / 2); svgTextUtils.positionText(text, constants.textOffsetX, textY); + legendItem.lineHeight = lineHeight; } height = Math.max(height, 16) + 3; @@ -25835,18 +25959,18 @@ function expandMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -25866,10 +25990,10 @@ function expandHorizontalMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } @@ -25884,7 +26008,7 @@ function expandHorizontalMargin(gd) { }); } -},{"../../constants/alignment":144,"../../constants/interactions":145,"../../lib":164,"../../lib/events":157,"../../lib/svg_text_utils":185,"../../plots/plots":241,"../../registry":248,"../color":46,"../dragelement":68,"../drawing":71,"./anchor_utils":98,"./constants":100,"./get_legend_data":103,"./handle_click":104,"./helpers":105,"./style":107,"d3":11}],103:[function(_dereq_,module,exports){ +},{"../../constants/alignment":141,"../../constants/interactions":142,"../../lib":162,"../../lib/events":155,"../../lib/svg_text_utils":183,"../../plots/plots":239,"../../registry":246,"../color":46,"../dragelement":64,"../drawing":67,"./constants":96,"./get_legend_data":99,"./handle_click":100,"./helpers":101,"./style":103,"d3":11}],99:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25990,7 +26114,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":248,"./helpers":105}],104:[function(_dereq_,module,exports){ +},{"../../registry":246,"./helpers":101}],100:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26104,7 +26228,7 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices); + Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices); } else { var hasLegendgroup = legendgroup && legendgroup.length; var traceIndicesInGroup = []; @@ -26210,11 +26334,11 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', gd, attrUpdate, attrIndices); + Registry.call('_guiRestyle', gd, attrUpdate, attrIndices); } }; -},{"../../lib":164,"../../registry":248}],105:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../registry":246}],101:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26238,7 +26362,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],106:[function(_dereq_,module,exports){ +},{}],102:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26262,7 +26386,7 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":99,"./defaults":101,"./draw":102,"./style":107}],107:[function(_dereq_,module,exports){ +},{"./attributes":95,"./defaults":97,"./draw":98,"./style":103}],103:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26290,6 +26414,19 @@ module.exports = function style(s, gd) { var layers = Lib.ensureSingle(traceGroup, 'g', 'layers'); layers.style('opacity', d[0].trace.opacity); + // Marker vertical alignment + var valign = gd._fullLayout.legend.valign; + var lineHeight = d[0].lineHeight; + var height = d[0].height; + + if(valign === 'middle' || !lineHeight || !height) { + layers.attr('transform', null); // this here is a fun d3 trick to unset DOM attributes + } else { + var factor = {top: 1, bottom: -1}[valign]; + var markerOffsetY = factor * (0.5 * (lineHeight - height + 3)); + layers.attr('transform', 'translate(0,' + markerOffsetY + ')'); + } + var fill = layers .selectAll('g.legendfill') .data([d]); @@ -26609,7 +26746,7 @@ module.exports = function style(s, gd) { } }; -},{"../../lib":164,"../../registry":248,"../../traces/pie/style_one":314,"../../traces/scatter/subtypes":340,"../color":46,"../drawing":71,"d3":11}],108:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../registry":246,"../../traces/pie/style_one":314,"../../traces/scatter/subtypes":340,"../color":46,"../drawing":67,"d3":11}],104:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26873,7 +27010,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -26929,7 +27066,7 @@ function handleDrag3d(gd, ev) { var val2d = (val === 'pan') ? val : 'zoom'; layoutUpdate.dragmode = val2d; - Registry.call('relayout', gd, layoutUpdate); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.resetCameraDefault3d = { @@ -26968,7 +27105,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -26982,54 +27119,48 @@ modeBarButtons.hoverClosest3d = { click: handleHover3d }; -function handleHover3d(gd, ev) { +function getNextHover3d(gd, ev) { var button = ev.currentTarget; - var val = button._previousVal || false; - var layout = gd.layout; + var val = button._previousVal; var fullLayout = gd._fullLayout; var sceneIds = fullLayout._subplots.gl3d; var axes = ['xaxis', 'yaxis', 'zaxis']; - var spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor']; // initialize 'current spike' object to be stored in the DOM var currentSpikes = {}; - var axisSpikes = {}; var layoutUpdate = {}; if(val) { - layoutUpdate = Lib.extendDeep(layout, val); + layoutUpdate = val; button._previousVal = null; } else { - layoutUpdate = { - 'allaxes.showspikes': false - }; - for(var i = 0; i < sceneIds.length; i++) { - var sceneId = sceneIds[i], - sceneLayout = fullLayout[sceneId], - sceneSpikes = currentSpikes[sceneId] = {}; + var sceneId = sceneIds[i]; + var sceneLayout = fullLayout[sceneId]; - sceneSpikes.hovermode = sceneLayout.hovermode; - layoutUpdate[sceneId + '.hovermode'] = false; + var hovermodeAStr = sceneId + '.hovermode'; + currentSpikes[hovermodeAStr] = sceneLayout.hovermode; + layoutUpdate[hovermodeAStr] = false; // copy all the current spike attrs for(var j = 0; j < 3; j++) { var axis = axes[j]; - axisSpikes = sceneSpikes[axis] = {}; - - for(var k = 0; k < spikeAttrs.length; k++) { - var spikeAttr = spikeAttrs[k]; - axisSpikes[spikeAttr] = sceneLayout[axis][spikeAttr]; - } + var spikeAStr = sceneId + '.' + axis + '.showspikes'; + layoutUpdate[spikeAStr] = false; + currentSpikes[spikeAStr] = sceneLayout[axis].showspikes; } } - button._previousVal = Lib.extendDeep({}, currentSpikes); + button._previousVal = currentSpikes; } + return layoutUpdate; +} - Registry.call('relayout', gd, layoutUpdate); +function handleHover3d(gd, ev) { + var layoutUpdate = getNextHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.zoomInGeo = { @@ -27085,7 +27216,7 @@ function handleGeo(gd, ev) { var scale = geoLayout.projection.scale; var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; - Registry.call('relayout', gd, id + '.projection.scale', newScale); + Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); } else if(attr === 'reset') { resetView(gd, 'geo'); } @@ -27113,18 +27244,20 @@ modeBarButtons.hoverClosestPie = { click: toggleHover }; -function toggleHover(gd) { +function getNextHover(gd) { var fullLayout = gd._fullLayout; - var onHoverVal; + if(fullLayout.hovermode) return false; + if(fullLayout._has('cartesian')) { - onHoverVal = fullLayout._isHoriz ? 'y' : 'x'; + return fullLayout._isHoriz ? 'y' : 'x'; } - else onHoverVal = 'closest'; - - var newHover = gd._fullLayout.hovermode ? false : onHoverVal; + return 'closest'; +} - Registry.call('relayout', gd, 'hovermode', newHover); +function toggleHover(gd) { + var newHover = getNextHover(gd); + Registry.call('_guiRelayout', gd, 'hovermode', newHover); } // buttons when more then one plot types are present @@ -27138,12 +27271,10 @@ modeBarButtons.toggleHover = { icon: Icons.tooltip_basic, gravity: 'ne', click: function(gd, ev) { - toggleHover(gd); + var layoutUpdate = getNextHover3d(gd, ev); + layoutUpdate.hovermode = getNextHover(gd); - // the 3d hovermode update must come - // last so that layout.hovermode update does not - // override scene?.hovermode?.layout. - handleHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } }; @@ -27179,7 +27310,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } }; @@ -27226,10 +27357,10 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', gd, aObj); + Registry.call('_guiRelayout', gd, aObj); } -},{"../../../build/ploticon":2,"../../lib":164,"../../plots/cartesian/axis_ids":211,"../../plots/plots":241,"../../registry":248}],109:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":162,"../../plots/cartesian/axis_ids":209,"../../plots/plots":239,"../../registry":246}],105:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27243,7 +27374,7 @@ function resetView(gd, subplotType) { exports.manage = _dereq_('./manage'); -},{"./manage":110}],110:[function(_dereq_,module,exports){ +},{"./manage":106}],106:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27275,7 +27406,7 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar) { + if(!context.displayModeBar && !context.watermark) { if(modeBar) { modeBar.destroy(); delete fullLayout._modeBar; @@ -27303,11 +27434,15 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); } + else if(!context.displayModeBar && context.watermark) { + buttonGroups = []; + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, - context.modeBarButtonsToAdd + context.modeBarButtonsToAdd, + context.showSendToCloud ); } @@ -27316,7 +27451,7 @@ module.exports = function manageModeBar(gd) { }; // logic behind which buttons are displayed by default -function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { +function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; @@ -27347,7 +27482,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { } // buttons common to all plot types - addGroup(['toImage', 'sendDataToCloud']); + var commonGroup = ['toImage']; + if(showSendToCloud) commonGroup.push('sendDataToCloud'); + addGroup(commonGroup); var zoomGroup = []; var hoverGroup = []; @@ -27498,7 +27635,7 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":211,"../../registry":248,"../../traces/scatter/subtypes":340,"./buttons":108,"./modebar":111}],111:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axis_ids":209,"../../registry":246,"../../traces/scatter/subtypes":340,"./buttons":104,"./modebar":107}],107:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27581,11 +27718,16 @@ proto.update = function(graphInfo, buttons) { this.updateButtons(buttons); - if(context.displaylogo) { + if(context.watermark || context.displaylogo) { + var logoGroup = this.getLogo(); + if(context.watermark) { + logoGroup.className = logoGroup.className + ' watermark'; + } + if(fullLayout.modebar.orientation === 'v') { - this.element.prepend(this.getLogo()); + this.element.prepend(logoGroup); } else { - this.element.appendChild(this.getLogo()); + this.element.appendChild(logoGroup); } this.hasLogo = true; @@ -27844,7 +27986,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../../build/ploticon":2,"../../lib":164,"d3":11,"fast-isnumeric":13}],112:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":162,"d3":11,"fast-isnumeric":13}],108:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27980,7 +28122,7 @@ module.exports = { editType: 'plot' }; -},{"../../plot_api/plot_template":198,"../../plots/font_attributes":235,"../color/attributes":45}],113:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":196,"../../plots/font_attributes":233,"../color/attributes":45}],109:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28009,7 +28151,7 @@ module.exports = { darkAmount: 10 }; -},{}],114:[function(_dereq_,module,exports){ +},{}],110:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28102,7 +28244,7 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":164,"../../plot_api/plot_template":198,"../../plots/array_container_defaults":204,"../color":46,"./attributes":112,"./constants":113}],115:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/array_container_defaults":202,"../color":46,"./attributes":108,"./constants":109}],111:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28122,7 +28264,6 @@ var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var alignmentConstants = _dereq_('../../constants/alignment'); var LINE_SPACING = alignmentConstants.LINE_SPACING; @@ -28174,7 +28315,7 @@ module.exports = function draw(gd) { button.on('click', function() { if(gd._dragged) return; - Registry.call('relayout', gd, update); + Registry.call('_guiRelayout', gd, update); }); button.on('mouseover', function() { @@ -28323,21 +28464,21 @@ function reposition(gd, buttons, opts, axName, selector) { var ly = graphSize.t + graphSize.h * (1 - opts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= width; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(opts)) { + if(Lib.isCenterAnchor(opts)) { lx -= width / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(opts)) { + if(Lib.isMiddleAnchor(opts)) { ly -= height / 2; yanchor = 'middle'; } @@ -28359,7 +28500,7 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', 'translate(' + lx + ',' + ly + ')'); } -},{"../../constants/alignment":144,"../../lib":164,"../../lib/svg_text_utils":185,"../../plots/cartesian/axis_ids":211,"../../plots/plots":241,"../../registry":248,"../color":46,"../drawing":71,"../legend/anchor_utils":98,"./constants":113,"./get_update_object":116,"d3":11}],116:[function(_dereq_,module,exports){ +},{"../../constants/alignment":141,"../../lib":162,"../../lib/svg_text_utils":183,"../../plots/cartesian/axis_ids":209,"../../plots/plots":239,"../../registry":246,"../color":46,"../drawing":67,"./constants":109,"./get_update_object":112,"d3":11}],112:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28416,7 +28557,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":11}],117:[function(_dereq_,module,exports){ +},{"d3":11}],113:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28443,7 +28584,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":112,"./defaults":114,"./draw":115}],118:[function(_dereq_,module,exports){ +},{"./attributes":108,"./defaults":110,"./draw":111}],114:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28517,7 +28658,7 @@ module.exports = { editType: 'calc' }; -},{"../color/attributes":45}],119:[function(_dereq_,module,exports){ +},{"../color/attributes":45}],115:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28551,7 +28692,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":207,"../../plots/cartesian/axis_ids":211,"./constants":120}],120:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/autorange":205,"../../plots/cartesian/axis_ids":209,"./constants":116}],116:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28607,7 +28748,7 @@ module.exports = { extraPad: 15 }; -},{}],121:[function(_dereq_,module,exports){ +},{}],117:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28693,7 +28834,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":164,"../../plot_api/plot_template":198,"../../plots/cartesian/axis_ids":211,"./attributes":118,"./oppaxis_attributes":124}],122:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/cartesian/axis_ids":209,"./attributes":114,"./oppaxis_attributes":121}],118:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28715,7 +28856,7 @@ var Color = _dereq_('../color'); var Titles = _dereq_('../titles'); var Cartesian = _dereq_('../../plots/cartesian'); -var Axes = _dereq_('../../plots/cartesian/axes'); +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); var dragElement = _dereq_('../dragelement'); var setCursor = _dereq_('../../lib/setcursor'); @@ -28723,8 +28864,13 @@ var setCursor = _dereq_('../../lib/setcursor'); var constants = _dereq_('./constants'); module.exports = function(gd) { - var fullLayout = gd._fullLayout, - rangeSliderData = makeRangeSliderData(fullLayout); + var fullLayout = gd._fullLayout; + var rangeSliderData = fullLayout._rangeSliderData; + for(var i = 0; i < rangeSliderData.length; i++) { + var opts = rangeSliderData[i][constants.name]; + // fullLayout._uid may not exist when we call makeData + opts._clipId = opts._id + '-' + fullLayout._uid; + } /* * @@ -28751,10 +28897,6 @@ module.exports = function(gd) { .selectAll('g.' + constants.containerClassName) .data(rangeSliderData, keyFunction); - rangeSliders.enter().append('g') - .classed(constants.containerClassName, true) - .attr('pointer-events', 'all'); - // remove exiting sliders and their corresponding clip paths rangeSliders.exit().each(function(axisOpts) { var opts = axisOpts[constants.name]; @@ -28764,48 +28906,51 @@ module.exports = function(gd) { // return early if no range slider is visible if(rangeSliderData.length === 0) return; + rangeSliders.enter().append('g') + .classed(constants.containerClassName, true) + .attr('pointer-events', 'all'); + // for all present range sliders rangeSliders.each(function(axisOpts) { - var rangeSlider = d3.select(this), - opts = axisOpts[constants.name], - oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)], - oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)]; + var rangeSlider = d3.select(this); + var opts = axisOpts[constants.name]; + var oppAxisOpts = fullLayout[axisIDs.id2name(axisOpts.anchor)]; + var oppAxisRangeOpts = opts[axisIDs.id2name(axisOpts.anchor)]; // update range // Expand slider range to the axis range - // TODO: what if the ranges are reversed? if(opts.range) { - var outRange = opts.range; - var axRange = axisOpts.range; + var rng = Lib.simpleMap(opts.range, axisOpts.r2l); + var axRng = Lib.simpleMap(axisOpts.range, axisOpts.r2l); + var newRng; + + if(axRng[0] < axRng[1]) { + newRng = [ + Math.min(rng[0], axRng[0]), + Math.max(rng[1], axRng[1]) + ]; + } else { + newRng = [ + Math.max(rng[0], axRng[0]), + Math.min(rng[1], axRng[1]) + ]; + } - outRange[0] = axisOpts.l2r(Math.min(axisOpts.r2l(outRange[0]), axisOpts.r2l(axRange[0]))); - outRange[1] = axisOpts.l2r(Math.max(axisOpts.r2l(outRange[1]), axisOpts.r2l(axRange[1]))); - opts._input.range = outRange.slice(); + opts.range = opts._input.range = Lib.simpleMap(newRng, axisOpts.l2r); } axisOpts.cleanRange('rangeslider.range'); - // update range slider dimensions var margin = fullLayout.margin; var graphSize = fullLayout._size; var domain = axisOpts.domain; - var tickHeight = (axisOpts._boundingBox || {}).height || 0; - - var oppBottom = Infinity; - var subplotData = Axes.getSubplots(gd, axisOpts); - for(var i = 0; i < subplotData.length; i++) { - var oppAxis = Axes.getFromId(gd, subplotData[i].substr(subplotData[i].indexOf('y'))); - oppBottom = Math.min(oppBottom, oppAxis.domain[0]); - } + var tickHeight = opts._tickHeight; - opts._id = constants.name + axisOpts._id; - opts._clipId = opts._id + '-' + fullLayout._uid; + var oppBottom = opts._oppBottom; opts._width = graphSize.w * (domain[1] - domain[0]); - opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; - opts._offsetShift = Math.floor(opts.borderwidth / 2); var x = Math.round(margin.l + (graphSize.w * domain[0])); @@ -28868,41 +29013,14 @@ module.exports = function(gd) { placeholder: fullLayout._dfltTitle.x, attributes: { x: axisOpts._offset + axisOpts._length / 2, - y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size, + y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.title.font.size, 'text-anchor': 'middle' } }); } - - // update margins - Plots.autoMargin(gd, opts._id, { - x: domain[0], - y: oppBottom, - l: 0, - r: 0, - t: 0, - b: opts._height + margin.b + tickHeight, - pad: constants.extraPad + opts._offsetShift * 2 - }); }); }; -function makeRangeSliderData(fullLayout) { - var axes = Axes.list({ _fullLayout: fullLayout }, 'x', true), - name = constants.name, - out = []; - - if(fullLayout._has('gl2d')) return out; - - for(var i = 0; i < axes.length; i++) { - var ax = axes[i]; - - if(ax[name] && ax[name].visible) out.push(ax); - } - - return out; -} - function setupDragElement(rangeSlider, gd, axisOpts, opts) { var slideBox = rangeSlider.select('rect.' + constants.slideBoxClassName).node(), grabAreaMin = rangeSlider.select('rect.' + constants.grabAreaMinClassName).node(), @@ -28982,7 +29100,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) { dataMax = clamp(opts.p2d(opts._pixelMax)); window.requestAnimationFrame(function() { - Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); + Registry.call('_guiRelayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); }); } @@ -29089,15 +29207,14 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) { } function drawRangePlot(rangeSlider, gd, axisOpts, opts) { - var subplotData = Axes.getSubplots(gd, axisOpts), - calcData = gd.calcdata; + var calcData = gd.calcdata; var rangePlots = rangeSlider.selectAll('g.' + constants.rangePlotClassName) - .data(subplotData, Lib.identity); + .data(axisOpts._subplotsWith, Lib.identity); rangePlots.enter().append('g') .attr('class', function(id) { return constants.rangePlotClassName + ' ' + id; }) - .call(Drawing.setClipUrl, opts._clipId); + .call(Drawing.setClipUrl, opts._clipId, gd); rangePlots.order(); @@ -29109,7 +29226,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var plotgroup = d3.select(this), isMainPlot = (i === 0); - var oppAxisOpts = Axes.getFromId(gd, id, 'y'), + var oppAxisOpts = axisIDs.getFromId(gd, id, 'y'), oppAxisName = oppAxisOpts._name, oppAxisRangeOpts = opts[oppAxisName]; @@ -29141,6 +29258,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var xa = mockFigure._fullLayout.xaxis; var ya = mockFigure._fullLayout[oppAxisName]; + xa.clearCalc(); + xa.setScale(); + ya.clearCalc(); + ya.setScale(); + var plotinfo = { id: id, plotgroup: plotgroup, @@ -29293,7 +29415,77 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":164,"../../lib/setcursor":183,"../../plots/cartesian":220,"../../plots/cartesian/axes":208,"../../plots/plots":241,"../../registry":248,"../color":46,"../dragelement":68,"../drawing":71,"../titles":137,"./constants":120,"d3":11}],123:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../lib/setcursor":181,"../../plots/cartesian":218,"../../plots/cartesian/axis_ids":209,"../../plots/plots":239,"../../registry":246,"../color":46,"../dragelement":64,"../drawing":67,"../titles":134,"./constants":116,"d3":11}],119:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); +var constants = _dereq_('./constants'); +var name = constants.name; + +function isVisible(ax) { + var rangeSlider = ax && ax[name]; + return rangeSlider && rangeSlider.visible; +} +exports.isVisible = isVisible; + +exports.makeData = function(fullLayout) { + var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true); + var margin = fullLayout.margin; + var rangeSliderData = []; + + if(!fullLayout._has('gl2d')) { + for(var i = 0; i < axes.length; i++) { + var ax = axes[i]; + + if(isVisible(ax)) { + rangeSliderData.push(ax); + + var opts = ax[name]; + opts._id = name + ax._id; + opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; + opts._offsetShift = Math.floor(opts.borderwidth / 2); + } + } + } + + fullLayout._rangeSliderData = rangeSliderData; +}; + +exports.autoMarginOpts = function(gd, ax) { + var opts = ax[name]; + + var oppBottom = Infinity; + var counterAxes = ax._counterAxes; + for(var j = 0; j < counterAxes.length; j++) { + var counterId = counterAxes[j]; + var oppAxis = axisIDs.getFromId(gd, counterId); + oppBottom = Math.min(oppBottom, oppAxis.domain[0]); + } + opts._oppBottom = oppBottom; + + var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0; + opts._tickHeight = tickHeight; + + return { + x: 0, + y: oppBottom, + l: 0, + r: 0, + t: 0, + b: opts._height + gd._fullLayout.margin.b + tickHeight, + pad: constants.extraPad + opts._offsetShift * 2 + }; +}; + +},{"../../plots/cartesian/axis_ids":209,"./constants":116}],120:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29307,6 +29499,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { var Lib = _dereq_('../../lib'); var attrs = _dereq_('./attributes'); var oppAxisAttrs = _dereq_('./oppaxis_attributes'); +var helpers = _dereq_('./helpers'); module.exports = { moduleType: 'component', @@ -29325,10 +29518,13 @@ module.exports = { layoutAttributes: _dereq_('./attributes'), handleDefaults: _dereq_('./defaults'), calcAutorange: _dereq_('./calc_autorange'), - draw: _dereq_('./draw') + draw: _dereq_('./draw'), + isVisible: helpers.isVisible, + makeData: helpers.makeData, + autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":164,"./attributes":118,"./calc_autorange":119,"./defaults":121,"./draw":122,"./oppaxis_attributes":124}],124:[function(_dereq_,module,exports){ +},{"../../lib":162,"./attributes":114,"./calc_autorange":115,"./defaults":117,"./draw":118,"./helpers":119,"./oppaxis_attributes":121}],121:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29366,7 +29562,7 @@ module.exports = { editType: 'calc' }; -},{}],125:[function(_dereq_,module,exports){ +},{}],122:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29502,7 +29698,7 @@ module.exports = templatedArray('shape', { editType: 'arraydraw' }); -},{"../../lib/extend":158,"../../plot_api/plot_template":198,"../../traces/scatter/attributes":316,"../annotations/attributes":31,"../drawing/attributes":70}],126:[function(_dereq_,module,exports){ +},{"../../lib/extend":156,"../../plot_api/plot_template":196,"../../traces/scatter/attributes":316,"../annotations/attributes":31,"../drawing/attributes":66}],123:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29511,7 +29707,6 @@ module.exports = templatedArray('shape', { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); @@ -29589,7 +29784,7 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { } function shapeBounds(ax, v0, v1, path, paramsToUse) { - var convertVal = (ax.type === 'category') ? ax.r2c : ax.d2c; + var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; if(!path) return; @@ -29620,7 +29815,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":164,"../../plots/cartesian/axes":208,"./constants":127,"./helpers":130}],127:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/cartesian/axes":206,"./constants":124,"./helpers":127}],124:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29684,7 +29879,7 @@ module.exports = { } }; -},{}],128:[function(_dereq_,module,exports){ +},{}],125:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29809,7 +30004,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":164,"../../plots/array_container_defaults":204,"../../plots/cartesian/axes":208,"./attributes":125,"./helpers":130}],129:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/array_container_defaults":202,"../../plots/cartesian/axes":206,"./attributes":122,"./helpers":127}],126:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29932,9 +30127,10 @@ function setClipPath(shapePath, gd, shapeOptions) { // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 var clipAxes = (shapeOptions.xref + shapeOptions.yref).replace(/paper/g, ''); - shapePath.call(Drawing.setClipUrl, clipAxes ? - ('clip' + gd._fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } @@ -30118,7 +30314,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { // Don't rely on clipPath being activated during re-layout setClipPath(shapePath, gd, shapeOptions); - Registry.call('relayout', gd, editHelpers.getUpdateObj()); + Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj()); } function abortDrag() { @@ -30305,9 +30501,10 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(xref !== 'paper' && !xa.autorange) clipAxes += xref; if(yref !== 'paper' && !ya.autorange) clipAxes += yref; - shapePath.call(Drawing.setClipUrl, clipAxes ? - 'clip' + gd._fullLayout._uid + clipAxes : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } } @@ -30439,7 +30636,7 @@ function movePath(pathIn, moveX, moveY) { }); } -},{"../../lib":164,"../../lib/setcursor":183,"../../plot_api/plot_template":198,"../../plots/cartesian/axes":208,"../../registry":248,"../color":46,"../dragelement":68,"../drawing":71,"./constants":127,"./helpers":130}],130:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../lib/setcursor":181,"../../plot_api/plot_template":196,"../../plots/cartesian/axes":206,"../../registry":246,"../color":46,"../dragelement":64,"../drawing":67,"./constants":124,"./helpers":127}],127:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30564,7 +30761,7 @@ exports.roundPositionForSharpStrokeRendering = function(pos, strokeWidth) { return strokeWidthIsOdd ? posValAsInt + 0.5 : posValAsInt; }; -},{"../../lib":164,"./constants":127}],131:[function(_dereq_,module,exports){ +},{"../../lib":162,"./constants":124}],128:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30591,7 +30788,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":219,"./attributes":125,"./calc_autorange":126,"./defaults":128,"./draw":129}],132:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":217,"./attributes":122,"./calc_autorange":123,"./defaults":125,"./draw":126}],129:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30693,7 +30890,7 @@ module.exports = overrideAll(templatedArray('slider', { }, - pad: extendDeepAll({}, padAttrs, { + pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { }, {t: {dflt: 20}}), xanchor: { @@ -30834,7 +31031,7 @@ module.exports = overrideAll(templatedArray('slider', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":158,"../../plot_api/edit_types":191,"../../plot_api/plot_template":198,"../../plots/animation_attributes":203,"../../plots/font_attributes":235,"../../plots/pad_attributes":240,"./constants":133}],133:[function(_dereq_,module,exports){ +},{"../../lib/extend":156,"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../../plots/animation_attributes":201,"../../plots/font_attributes":233,"../../plots/pad_attributes":238,"./constants":130}],130:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30928,7 +31125,7 @@ module.exports = { currentValueInset: 0, }; -},{}],134:[function(_dereq_,module,exports){ +},{}],131:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31045,7 +31242,7 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":164,"../../plots/array_container_defaults":204,"./attributes":132,"./constants":133}],135:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/array_container_defaults":202,"./attributes":129,"./constants":130}],132:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31063,7 +31260,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var constants = _dereq_('./constants'); @@ -31255,21 +31451,21 @@ function findDimensions(gd, sliderOpts) { dims.height = dims.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + dims.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(sliderOpts)) { + if(Lib.isRightAnchor(sliderOpts)) { dims.lx -= dims.outerLength; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(sliderOpts)) { + if(Lib.isCenterAnchor(sliderOpts)) { dims.lx -= dims.outerLength / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(sliderOpts)) { + if(Lib.isBottomAnchor(sliderOpts)) { dims.ly -= dims.height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(sliderOpts)) { + if(Lib.isMiddleAnchor(sliderOpts)) { dims.ly -= dims.height / 2; yanchor = 'middle'; } @@ -31676,7 +31872,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":144,"../../lib":164,"../../lib/svg_text_utils":185,"../../plot_api/plot_template":198,"../../plots/plots":241,"../color":46,"../drawing":71,"../legend/anchor_utils":98,"./constants":133,"d3":11}],136:[function(_dereq_,module,exports){ +},{"../../constants/alignment":141,"../../lib":162,"../../lib/svg_text_utils":183,"../../plot_api/plot_template":196,"../../plots/plots":239,"../color":46,"../drawing":67,"./constants":130,"d3":11}],133:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31699,7 +31895,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":132,"./constants":133,"./defaults":134,"./draw":135}],137:[function(_dereq_,module,exports){ +},{"./attributes":129,"./constants":130,"./defaults":131,"./draw":132}],134:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31769,19 +31965,21 @@ function draw(gd, titleClass, options) { var group = options.containerGroup; var fullLayout = gd._fullLayout; - var titlefont = cont.titlefont || {}; - var font = titlefont.family; - var fontSize = titlefont.size; - var fontColor = titlefont.color; var opacity = 1; var isplaceholder = false; - var txt = (cont.title || '').trim(); + var title = cont.title; + var txt = (title && title.text ? title.text : '').trim(); + + var font = title && title.font ? title.font : {}; + var fontFamily = font.family; + var fontSize = font.size; + var fontColor = font.color; // only make this title editable if we positively identify its property // as one that has editing enabled. var editAttr; - if(prop === 'title') editAttr = 'titleText'; + if(prop === 'title.text') editAttr = 'titleText'; else if(prop.indexOf('axis') !== -1) editAttr = 'axisTitleText'; else if(prop.indexOf('colorbar' !== -1)) editAttr = 'colorbarTitleText'; var editable = gd._context.edits[editAttr]; @@ -31839,7 +32037,7 @@ function draw(gd, titleClass, options) { titleEl.attr('transform', transformVal); titleEl.style({ - 'font-family': font, + 'font-family': fontFamily, 'font-size': d3.round(fontSize, 2) + 'px', fill: Color.rgb(fontColor), opacity: opacity * Color.opacity(fontColor), @@ -31939,9 +32137,9 @@ function draw(gd, titleClass, options) { el.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { if(traceIndex !== undefined) { - Registry.call('restyle', gd, prop, text, traceIndex); + Registry.call('_guiRestyle', gd, prop, text, traceIndex); } else { - Registry.call('relayout', gd, prop, text); + Registry.call('_guiRelayout', gd, prop, text); } }) .on('cancel', function() { @@ -31958,7 +32156,7 @@ function draw(gd, titleClass, options) { return group; } -},{"../../constants/interactions":145,"../../lib":164,"../../lib/svg_text_utils":185,"../../plots/plots":241,"../../registry":248,"../color":46,"../drawing":71,"d3":11,"fast-isnumeric":13}],138:[function(_dereq_,module,exports){ +},{"../../constants/interactions":142,"../../lib":162,"../../lib/svg_text_utils":183,"../../plots/plots":239,"../../registry":246,"../color":46,"../drawing":67,"d3":11,"fast-isnumeric":13}],135:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32087,7 +32285,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { }, - pad: extendFlat({}, padAttrs, { + pad: extendFlat(padAttrs({editType: 'arraydraw'}), { }), @@ -32116,7 +32314,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":158,"../../plot_api/edit_types":191,"../../plot_api/plot_template":198,"../../plots/font_attributes":235,"../../plots/pad_attributes":240,"../color/attributes":45}],139:[function(_dereq_,module,exports){ +},{"../../lib/extend":156,"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../../plots/font_attributes":233,"../../plots/pad_attributes":238,"../color/attributes":45}],136:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32197,7 +32395,7 @@ module.exports = { } }; -},{}],140:[function(_dereq_,module,exports){ +},{}],137:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32280,7 +32478,7 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":164,"../../plots/array_container_defaults":204,"./attributes":138,"./constants":139}],141:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/array_container_defaults":202,"./attributes":135,"./constants":136}],138:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32299,7 +32497,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var LINE_SPACING = _dereq_('../../constants/alignment').LINE_SPACING; @@ -32849,21 +33046,21 @@ function findDimensions(gd, menuOpts) { dims.ly = graphSize.t + graphSize.h * (1 - menuOpts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(menuOpts)) { + if(Lib.isRightAnchor(menuOpts)) { dims.lx -= paddedWidth; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(menuOpts)) { + if(Lib.isCenterAnchor(menuOpts)) { dims.lx -= paddedWidth / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(menuOpts)) { + if(Lib.isBottomAnchor(menuOpts)) { dims.ly -= paddedHeight; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(menuOpts)) { + if(Lib.isMiddleAnchor(menuOpts)) { dims.ly -= paddedHeight / 2; yanchor = 'middle'; } @@ -32930,9 +33127,9 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":144,"../../lib":164,"../../lib/svg_text_utils":185,"../../plot_api/plot_template":198,"../../plots/plots":241,"../color":46,"../drawing":71,"../legend/anchor_utils":98,"./constants":139,"./scrollbox":143,"d3":11}],142:[function(_dereq_,module,exports){ -arguments[4][136][0].apply(exports,arguments) -},{"./attributes":138,"./constants":139,"./defaults":140,"./draw":141,"dup":136}],143:[function(_dereq_,module,exports){ +},{"../../constants/alignment":141,"../../lib":162,"../../lib/svg_text_utils":183,"../../plot_api/plot_template":196,"../../plots/plots":239,"../color":46,"../drawing":67,"./constants":136,"./scrollbox":140,"d3":11}],139:[function(_dereq_,module,exports){ +arguments[4][133][0].apply(exports,arguments) +},{"./attributes":135,"./constants":136,"./defaults":137,"./draw":138,"dup":133}],140:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33189,7 +33386,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { height: Math.ceil(clipB) - Math.floor(clipT) }); - this.container.call(Drawing.setClipUrl, clipId); + this.container.call(Drawing.setClipUrl, clipId, this.gd); this.bg.attr({ x: l, @@ -33403,7 +33600,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":164,"../color":46,"../drawing":71,"d3":11}],144:[function(_dereq_,module,exports){ +},{"../../lib":162,"../color":46,"../drawing":67,"d3":11}],141:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33447,12 +33644,17 @@ module.exports = { // multiple of fontSize to get the vertical offset between lines LINE_SPACING: 1.3, - // multiple of fontSize to shift from the baseline to the midline + // multiple of fontSize to shift from the baseline + // to the cap (captical letter) line // (to use when we don't calculate this shift from Drawing.bBox) - // To be precise this should be half the cap height (capital letter) - // of the font, and according to wikipedia: + // This is an approximation since in reality cap height can differ + // from font to font. However, according to Wikipedia // an "average" font might have a cap height of 70% of the em // https://en.wikipedia.org/wiki/Em_(typography)#History + CAP_SHIFT: 0.70, + + // half the cap height (distance between baseline and cap line) + // of an "average" font (for more info see above). MID_SHIFT: 0.35, OPPOSITE_SIDE: { @@ -33463,7 +33665,7 @@ module.exports = { } }; -},{}],145:[function(_dereq_,module,exports){ +},{}],142:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33490,7 +33692,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],146:[function(_dereq_,module,exports){ +},{}],143:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33555,7 +33757,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],147:[function(_dereq_,module,exports){ +},{}],144:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33579,7 +33781,7 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],148:[function(_dereq_,module,exports){ +},{}],145:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33591,7 +33793,7 @@ exports.svgAttrs = { 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.42.5'; +exports.version = '1.43.0'; // inject promise polyfill _dereq_('es6-promise').polyfill(); @@ -33600,7 +33802,7 @@ _dereq_('es6-promise').polyfill(); _dereq_('../build/plotcss'); // inject default MathJax config -_dereq_('./fonts/mathjax_config'); +_dereq_('./fonts/mathjax_config')(); // include registry module and expose register method var Registry = _dereq_('./registry'); @@ -33611,7 +33813,8 @@ var plotApi = _dereq_('./plot_api'); var methodNames = Object.keys(plotApi); for(var i = 0; i < methodNames.length; i++) { var name = methodNames[i]; - exports[name] = plotApi[name]; + // _ -> private API methods, but still registered for internal use + if(name.charAt(0) !== '_') exports[name] = plotApi[name]; register({ moduleType: 'apiMethod', name: name, @@ -33635,7 +33838,8 @@ register([ _dereq_('./components/rangeslider'), _dereq_('./components/rangeselector'), _dereq_('./components/grid'), - _dereq_('./components/errorbars') + _dereq_('./components/errorbars'), + _dereq_('./components/colorscale') ]); // locales en and en-US are required for default behavior @@ -33657,7 +33861,7 @@ exports.Queue = _dereq_('./lib/queue'); // export d3 used in the bundle exports.d3 = _dereq_('d3'); -},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":39,"./components/annotations3d":44,"./components/errorbars":77,"./components/fx":88,"./components/grid":92,"./components/images":97,"./components/legend":106,"./components/rangeselector":117,"./components/rangeslider":123,"./components/shapes":131,"./components/sliders":136,"./components/updatemenus":142,"./fonts/mathjax_config":149,"./lib/queue":178,"./locale-en":189,"./locale-en-us":188,"./plot_api":193,"./plot_api/plot_schema":197,"./plots/plots":241,"./registry":248,"./snapshot":253,"./traces/scatter":328,"d3":11,"es6-promise":12}],149:[function(_dereq_,module,exports){ +},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":39,"./components/annotations3d":44,"./components/colorscale":58,"./components/errorbars":73,"./components/fx":85,"./components/grid":89,"./components/images":94,"./components/legend":102,"./components/rangeselector":113,"./components/rangeslider":120,"./components/shapes":128,"./components/sliders":133,"./components/updatemenus":139,"./fonts/mathjax_config":146,"./lib/queue":176,"./locale-en":187,"./locale-en-us":186,"./plot_api":191,"./plot_api/plot_schema":195,"./plots/plots":239,"./registry":246,"./snapshot":251,"./traces/scatter":328,"d3":11,"es6-promise":12}],146:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33670,31 +33874,89 @@ exports.d3 = _dereq_('d3'); /* global MathJax:false */ +module.exports = function() { + if(typeof MathJax !== 'undefined') { + var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; + + if(globalConfig) { + MathJax.Hub.Config({ + messageStyle: 'none', + skipStartupTypeset: true, + displayAlign: 'left', + tex2jax: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + } + }); + MathJax.Hub.Configured(); + } + } +}; + +},{}],147:[function(_dereq_,module,exports){ /** - * Check and configure MathJax +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + + +/** + * Determine the position anchor property of x/y xanchor/yanchor components. + * + * - values < 1/3 align the low side at that fraction, + * - values [1/3, 2/3] align the center at that fraction, + * - values > 2/3 align the right at that fraction. */ -if(typeof MathJax !== 'undefined') { - exports.MathJax = true; - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } +exports.isLeftAnchor = function isLeftAnchor(opts) { + return ( + opts.xanchor === 'left' || + (opts.xanchor === 'auto' && opts.x <= 1 / 3) + ); +}; -} else { - exports.MathJax = false; -} +exports.isCenterAnchor = function isCenterAnchor(opts) { + return ( + opts.xanchor === 'center' || + (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) + ); +}; -},{}],150:[function(_dereq_,module,exports){ +exports.isRightAnchor = function isRightAnchor(opts) { + return ( + opts.xanchor === 'right' || + (opts.xanchor === 'auto' && opts.x >= 2 / 3) + ); +}; + +exports.isTopAnchor = function isTopAnchor(opts) { + return ( + opts.yanchor === 'top' || + (opts.yanchor === 'auto' && opts.y >= 2 / 3) + ); +}; + +exports.isMiddleAnchor = function isMiddleAnchor(opts) { + return ( + opts.yanchor === 'middle' || + (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) + ); +}; + +exports.isBottomAnchor = function isBottomAnchor(opts) { + return ( + opts.yanchor === 'bottom' || + (opts.yanchor === 'auto' && opts.y <= 1 / 3) + ); +}; + +},{}],148:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33935,7 +34197,7 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":171}],151:[function(_dereq_,module,exports){ +},{"./mod":169}],149:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34071,7 +34333,30 @@ exports.concat = function() { return out; }; -},{}],152:[function(_dereq_,module,exports){ +exports.maxRowLength = function(z) { + return _rowLength(z, Math.max, 0); +}; + +exports.minRowLength = function(z) { + return _rowLength(z, Math.min, Infinity); +}; + +function _rowLength(z, fn, len0) { + if(isArrayOrTypedArray(z)) { + if(isArrayOrTypedArray(z[0])) { + var len = len0; + for(var i = 0; i < z.length; i++) { + len = fn(len, z[i].length); + } + return len; + } else { + return z.length; + } + } + return 0; +} + +},{}],150:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34104,7 +34389,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":146,"fast-isnumeric":13}],153:[function(_dereq_,module,exports){ +},{"../constants/numerical":143,"fast-isnumeric":13}],151:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34132,7 +34417,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],154:[function(_dereq_,module,exports){ +},{}],152:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34155,7 +34440,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],155:[function(_dereq_,module,exports){ +},{}],153:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34164,18 +34449,17 @@ module.exports = function clearResponsive(gd) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); var baseTraceAttrs = _dereq_('../plots/attributes'); -var getColorscale = _dereq_('../components/colorscale/get_scale'); -var colorscaleNames = Object.keys(_dereq_('../components/colorscale/scales')); +var scales = _dereq_('../components/colorscale/scales'); +var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; + var nestedProperty = _dereq_('./nested_property'); var counterRegex = _dereq_('./regex').counter; -var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; var modHalf = _dereq_('./mod').modHalf; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -34293,7 +34577,7 @@ exports.valObjectMeta = { coerceFunction: function(v, propOut, dflt) { - propOut.set(getColorscale(v, dflt)); + propOut.set(scales.get(v, dflt)); } }, angle: { @@ -34627,7 +34911,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/get_scale":59,"../components/colorscale/scales":65,"../constants/interactions":145,"../plots/attributes":205,"./array":151,"./mod":171,"./nested_property":172,"./regex":179,"fast-isnumeric":13,"tinycolor2":29}],156:[function(_dereq_,module,exports){ +},{"../components/colorscale/scales":61,"../constants/interactions":142,"../plots/attributes":203,"./array":149,"./mod":169,"./nested_property":170,"./regex":177,"fast-isnumeric":13,"tinycolor2":29}],154:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35230,7 +35514,7 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":146,"../registry":248,"./loggers":168,"./mod":171,"d3":11,"fast-isnumeric":13}],157:[function(_dereq_,module,exports){ +},{"../constants/numerical":143,"../registry":246,"./loggers":166,"./mod":169,"d3":11,"fast-isnumeric":13}],155:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35404,7 +35688,7 @@ var Events = { module.exports = Events; -},{"events":10}],158:[function(_dereq_,module,exports){ +},{"events":10}],156:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35520,7 +35804,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":165}],159:[function(_dereq_,module,exports){ +},{"./is_plain_object.js":163}],157:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35571,7 +35855,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],160:[function(_dereq_,module,exports){ +},{}],158:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35618,7 +35902,7 @@ function isCalcData(cont) { ); } -},{}],161:[function(_dereq_,module,exports){ +},{}],159:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35864,7 +36148,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":171}],162:[function(_dereq_,module,exports){ +},{"./mod":169}],160:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35902,7 +36186,7 @@ module.exports = function(gd) { return gd; // otherwise assume that gd is a DOM element }; -},{}],163:[function(_dereq_,module,exports){ +},{}],161:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35918,7 +36202,7 @@ module.exports = function(gd) { module.exports = function identity(d) { return d; }; -},{}],164:[function(_dereq_,module,exports){ +},{}],162:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35952,6 +36236,8 @@ lib.isArrayOrTypedArray = arrayModule.isArrayOrTypedArray; lib.isArray1D = arrayModule.isArray1D; lib.ensureArray = arrayModule.ensureArray; lib.concat = arrayModule.concat; +lib.maxRowLength = arrayModule.maxRowLength; +lib.minRowLength = arrayModule.minRowLength; var modModule = _dereq_('./mod'); lib.mod = modModule.mod; @@ -36021,6 +36307,14 @@ lib.pathArc = anglesModule.pathArc; lib.pathSector = anglesModule.pathSector; lib.pathAnnulus = anglesModule.pathAnnulus; +var anchorUtils = _dereq_('./anchor_utils'); +lib.isLeftAnchor = anchorUtils.isLeftAnchor; +lib.isCenterAnchor = anchorUtils.isCenterAnchor; +lib.isRightAnchor = anchorUtils.isRightAnchor; +lib.isTopAnchor = anchorUtils.isTopAnchor; +lib.isMiddleAnchor = anchorUtils.isMiddleAnchor; +lib.isBottomAnchor = anchorUtils.isBottomAnchor; + var geom2dModule = _dereq_('./geometry2d'); lib.segmentsIntersect = geom2dModule.segmentsIntersect; lib.segmentDistance = geom2dModule.segmentDistance; @@ -36555,7 +36849,13 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) objOut[k] = v.slice(0, arrayLen); + else if(Array.isArray(v)) { + if(k === 'colorscale') { + objOut[k] = v.slice(); + } else { + objOut[k] = v.slice(0, arrayLen); + } + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -36900,10 +37200,10 @@ lib.numSeparate = function(value, separators, separatethousands) { return x1 + x2; }; -var TEMPLATE_STRING_REGEX = /%{([^\s%{}]*)}/g; +var TEMPLATE_STRING_REGEX = /%{([^\s%{}:]*)(:[^}]*)?}/g; var SIMPLE_PROPERTY_REGEX = /^\w*$/; -/* +/** * Substitute values from an object into a string * * Examples: @@ -36915,7 +37215,6 @@ var SIMPLE_PROPERTY_REGEX = /^\w*$/; * * @return {string} templated string */ - lib.templateString = function(string, obj) { // Not all that useful, but cache nestedProperty instantiation // just in case it speeds things up *slightly*: @@ -36930,6 +37229,67 @@ lib.templateString = function(string, obj) { }); }; +var TEMPLATE_STRING_FORMAT_SEPARATOR = /^:/; +var numberOfHoverTemplateWarnings = 0; +var maximumNumberOfHoverTemplateWarnings = 10; +/** + * Substitute values from an object into a string and optionally formats them using d3-format, + * or fallback to associated labels. + * + * Examples: + * Lib.templateString('name: %{trace}', {trace: 'asdf'}) --> 'name: asdf' + * Lib.templateString('name: %{trace[0].name}', {trace: [{name: 'asdf'}]}) --> 'name: asdf' + * Lib.templateString('price: %{y:$.2f}', {y: 1}) --> 'price: $1.00' + * + * @param {string} input string containing %{...:...} template strings + * @param {obj} data object containing fallback text when no formatting is specified, ex.: {yLabel: 'formattedYValue'} + * @param {obj} data objects containing substitution values + * + * @return {string} templated string + */ +lib.hovertemplateString = function(string, labels) { + var args = arguments; + // Not all that useful, but cache nestedProperty instantiation + // just in case it speeds things up *slightly*: + var getterCache = {}; + + return string.replace(TEMPLATE_STRING_REGEX, function(match, key, format) { + var obj, value, i; + for(i = 2; i < args.length; i++) { + obj = args[i]; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; + } + + if(value === undefined) { + if(numberOfHoverTemplateWarnings < maximumNumberOfHoverTemplateWarnings) { + lib.warn('Variable \'' + key + '\' in hovertemplate could not be found!'); + value = match; + } + + if(numberOfHoverTemplateWarnings === maximumNumberOfHoverTemplateWarnings) { + lib.warn('Too many hovertemplate warnings - additional warnings will be suppressed'); + } + numberOfHoverTemplateWarnings++; + } + + if(format) { + value = d3.format(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value); + } else { + if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + } + return value; + }); +}; + /* * alphanumeric string sort, tailored for subplot IDs like scene2, scene10, x10y13 etc */ @@ -36972,7 +37332,7 @@ lib.pseudoRandom = function() { return randSeed / 4294967296; }; -},{"../constants/numerical":146,"./angles":150,"./array":151,"./clean_number":152,"./clear_responsive":154,"./coerce":155,"./dates":156,"./extend":158,"./filter_unique":159,"./filter_visible":160,"./geometry2d":161,"./get_graph_div":162,"./identity":163,"./is_plain_object":165,"./keyed_container":166,"./localize":167,"./loggers":168,"./make_trace_groups":169,"./matrix":170,"./mod":171,"./nested_property":172,"./noop":173,"./notifier":174,"./push_unique":177,"./regex":179,"./relative_attr":180,"./relink_private":181,"./search":182,"./stats":184,"./throttle":186,"./to_log_range":187,"d3":11,"fast-isnumeric":13}],165:[function(_dereq_,module,exports){ +},{"../constants/numerical":143,"./anchor_utils":147,"./angles":148,"./array":149,"./clean_number":150,"./clear_responsive":152,"./coerce":153,"./dates":154,"./extend":156,"./filter_unique":157,"./filter_visible":158,"./geometry2d":159,"./get_graph_div":160,"./identity":161,"./is_plain_object":163,"./keyed_container":164,"./localize":165,"./loggers":166,"./make_trace_groups":167,"./matrix":168,"./mod":169,"./nested_property":170,"./noop":171,"./notifier":172,"./push_unique":175,"./regex":177,"./relative_attr":178,"./relink_private":179,"./search":180,"./stats":182,"./throttle":184,"./to_log_range":185,"d3":11,"fast-isnumeric":13}],163:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37001,7 +37361,7 @@ module.exports = function isPlainObject(obj) { ); }; -},{}],166:[function(_dereq_,module,exports){ +},{}],164:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37194,7 +37554,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":172}],167:[function(_dereq_,module,exports){ +},{"./nested_property":170}],165:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37250,7 +37610,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":248}],168:[function(_dereq_,module,exports){ +},{"../registry":246}],166:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37336,7 +37696,7 @@ function apply(f, args) { } } -},{"../plot_api/plot_config":196}],169:[function(_dereq_,module,exports){ +},{"../plot_api/plot_config":194}],167:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37373,7 +37733,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{}],170:[function(_dereq_,module,exports){ +},{}],168:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37483,7 +37843,7 @@ exports.apply2DTransform2 = function(transform) { }; }; -},{}],171:[function(_dereq_,module,exports){ +},{}],169:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37518,7 +37878,7 @@ module.exports = { modHalf: modHalf }; -},{}],172:[function(_dereq_,module,exports){ +},{}],170:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37765,7 +38125,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":151,"fast-isnumeric":13}],173:[function(_dereq_,module,exports){ +},{"./array":149,"fast-isnumeric":13}],171:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37781,7 +38141,7 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],174:[function(_dereq_,module,exports){ +},{}],172:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37863,7 +38223,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":11,"fast-isnumeric":13}],175:[function(_dereq_,module,exports){ +},{"d3":11,"fast-isnumeric":13}],173:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37912,7 +38272,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":183}],176:[function(_dereq_,module,exports){ +},{"./setcursor":181}],174:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38165,7 +38525,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":146,"./matrix":170}],177:[function(_dereq_,module,exports){ +},{"../constants/numerical":143,"./matrix":168}],175:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38205,7 +38565,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],178:[function(_dereq_,module,exports){ +},{}],176:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38416,7 +38776,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":164,"../plot_api/plot_config":196}],179:[function(_dereq_,module,exports){ +},{"../lib":162,"../plot_api/plot_config":194}],177:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38435,16 +38795,18 @@ module.exports = queue; * @param {Optional(string)} tail: a fixed piece after the id * eg counterRegex('scene', '.annotations') for scene2.annotations etc. * @param {boolean} openEnded: if true, the string may continue past the match. + * @param {boolean} matchBeginning: if false, the string may start before the match. */ -exports.counter = function(head, tail, openEnded) { +exports.counter = function(head, tail, openEnded, matchBeginning) { var fullTail = (tail || '') + (openEnded ? '' : '$'); + var startWithPrefix = matchBeginning === false ? '' : '^'; if(head === 'xy') { - return new RegExp('^x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + 'x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); } - return new RegExp('^' + head + '([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],180:[function(_dereq_,module,exports){ +},{}],178:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38497,7 +38859,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],181:[function(_dereq_,module,exports){ +},{}],179:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38560,7 +38922,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":151,"./is_plain_object":165}],182:[function(_dereq_,module,exports){ +},{"./array":149,"./is_plain_object":163}],180:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38748,7 +39110,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"./identity":163,"./loggers":168,"fast-isnumeric":13}],183:[function(_dereq_,module,exports){ +},{"./identity":161,"./loggers":166,"fast-isnumeric":13}],181:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38771,7 +39133,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],184:[function(_dereq_,module,exports){ +},{}],182:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38872,7 +39234,7 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":151,"fast-isnumeric":13}],185:[function(_dereq_,module,exports){ +},{"./array":149,"fast-isnumeric":13}],183:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39647,7 +40009,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":144,"../constants/xmlns_namespaces":147,"../lib":164,"d3":11}],186:[function(_dereq_,module,exports){ +},{"../constants/alignment":141,"../constants/xmlns_namespaces":144,"../lib":162,"d3":11}],184:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39751,7 +40113,7 @@ function _clearTimeout(cache) { } } -},{}],187:[function(_dereq_,module,exports){ +},{}],185:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39779,7 +40141,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":13}],188:[function(_dereq_,module,exports){ +},{"fast-isnumeric":13}],186:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39801,7 +40163,7 @@ module.exports = { } }; -},{}],189:[function(_dereq_,module,exports){ +},{}],187:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39844,7 +40206,7 @@ module.exports = { } }; -},{}],190:[function(_dereq_,module,exports){ +},{}],188:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39902,7 +40264,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":248}],191:[function(_dereq_,module,exports){ +},{"../registry":246}],189:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40028,7 +40390,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":164}],192:[function(_dereq_,module,exports){ +},{"../lib":162}],190:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40084,6 +40446,8 @@ exports.cleanLayout = function(layout) { } var axisAttrRegex = (Plots.subplotsRegistry.cartesian || {}).attrRegex; + var polarAttrRegex = (Plots.subplotsRegistry.polar || {}).attrRegex; + var ternaryAttrRegex = (Plots.subplotsRegistry.ternary || {}).attrRegex; var sceneAttrRegex = (Plots.subplotsRegistry.gl3d || {}).attrRegex; var keys = Object.keys(layout); @@ -40122,6 +40486,24 @@ exports.cleanLayout = function(layout) { } delete ax.autotick; } + + cleanTitle(ax); + } + + // modifications for polar + else if(polarAttrRegex && polarAttrRegex.test(key)) { + var polar = layout[key]; + + cleanTitle(polar.radialaxis); + } + + // modifications for ternary + else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + var ternary = layout[key]; + + cleanTitle(ternary.aaxis); + cleanTitle(ternary.baxis); + cleanTitle(ternary.caxis); } // modifications for 3D scenes @@ -40145,11 +40527,16 @@ exports.cleanLayout = function(layout) { scene.camera = { eye: {x: eye[0], y: eye[1], z: eye[2]}, center: {x: center[0], y: center[1], z: center[2]}, - up: {x: mat[1], y: mat[5], z: mat[9]} + up: {x: 0, y: 0, z: 1} // we just ignore calculating camera z up in this case }; delete scene.cameraposition; } + + // clean axis titles + cleanTitle(scene.xaxis); + cleanTitle(scene.yaxis); + cleanTitle(scene.zaxis); } } @@ -40207,6 +40594,9 @@ exports.cleanLayout = function(layout) { } } + // clean plot title + cleanTitle(layout); + /* * Moved from rotate -> orbit for dragmode */ @@ -40216,6 +40606,11 @@ exports.cleanLayout = function(layout) { // supported, but new tinycolor does not because they're not valid css Color.clean(layout); + // clean the layout container in layout.template + if(layout.template && layout.template.layout) { + exports.cleanLayout(layout.template.layout); + } + return layout; }; @@ -40227,6 +40622,46 @@ function cleanAxRef(container, attr) { } } +/** + * Cleans up old title attribute structure (flat) in favor of the new one (nested). + * + * @param {Object} titleContainer - an object potentially including deprecated title attributes + */ +function cleanTitle(titleContainer) { + if(titleContainer) { + + // title -> title.text + // (although title used to be a string attribute, + // numbers are accepted as well) + if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') { + titleContainer.title = { + text: titleContainer.title + }; + } + + rewireAttr('titlefont', 'font'); + rewireAttr('titleposition', 'position'); + rewireAttr('titleside', 'side'); + rewireAttr('titleoffset', 'offset'); + } + + function rewireAttr(oldAttrName, newAttrName) { + var oldAttrSet = titleContainer[oldAttrName]; + var newAttrSet = titleContainer.title && titleContainer.title[newAttrName]; + + if(oldAttrSet && !newAttrSet) { + + // Ensure title object exists + if(!titleContainer.title) { + titleContainer.title = {}; + } + + titleContainer.title[newAttrName] = titleContainer[oldAttrName]; + delete titleContainer[oldAttrName]; + } + } +} + /* * cleanData: Make a few changes to the data for backward compatibility * before it gets used for anything. Modifies the data traces users provide. @@ -40430,6 +40865,13 @@ exports.cleanData = function(data) { delete trace.autobiny; delete trace.ybins; } + + cleanTitle(trace); + if(trace.colorbar) cleanTitle(trace.colorbar); + if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar); + if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar); + if(trace.aaxis) cleanTitle(trace.aaxis); + if(trace.baxis) cleanTitle(trace.baxis); } }; @@ -40470,11 +40912,14 @@ function commonPrefix(name1, name2, show1, show2) { function cleanTextPosition(textposition) { var posY = 'middle', posX = 'center'; - if(textposition.indexOf('top') !== -1) posY = 'top'; - else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; - if(textposition.indexOf('left') !== -1) posX = 'left'; - else if(textposition.indexOf('right') !== -1) posX = 'right'; + if(typeof textposition === 'string') { + if(textposition.indexOf('top') !== -1) posY = 'top'; + else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; + + if(textposition.indexOf('left') !== -1) posX = 'left'; + else if(textposition.indexOf('right') !== -1) posX = 'right'; + } return posY + ' ' + posX; } @@ -40650,7 +41095,7 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":46,"../lib":164,"../plots/cartesian/axis_ids":211,"../plots/plots":241,"../registry":248,"fast-isnumeric":13,"gl-mat4/fromQuat":14}],193:[function(_dereq_,module,exports){ +},{"../components/color":46,"../lib":162,"../plots/cartesian/axis_ids":209,"../plots/plots":239,"../registry":246,"fast-isnumeric":13,"gl-mat4/fromQuat":14}],191:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40669,6 +41114,10 @@ exports.restyle = main.restyle; exports.relayout = main.relayout; exports.redraw = main.redraw; exports.update = main.update; +exports._guiRestyle = main._guiRestyle; +exports._guiRelayout = main._guiRelayout; +exports._guiUpdate = main._guiUpdate; +exports._storeDirectGUIEdit = main._storeDirectGUIEdit; exports.react = main.react; exports.extendTraces = main.extendTraces; exports.prependTraces = main.prependTraces; @@ -40689,7 +41138,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":250,"./plot_api":195,"./template_api":200,"./to_image":201,"./validate":202}],194:[function(_dereq_,module,exports){ +},{"../snapshot/download":248,"./plot_api":193,"./template_api":198,"./to_image":199,"./validate":200}],192:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40701,7 +41150,6 @@ exports.validateTemplate = templateApi.validateTemplate; 'use strict'; -var nestedProperty = _dereq_('../lib/nested_property'); var isPlainObject = _dereq_('../lib/is_plain_object'); var noop = _dereq_('../lib/noop'); var Loggers = _dereq_('../lib/loggers'); @@ -40758,11 +41206,15 @@ var isRemoveVal = exports.isRemoveVal = function isRemoveVal(val) { * the flags for which actions we're going to perform to display these (and * any other) changes. If we're already `recalc`ing, we don't need to redraw * individual items + * @param {function} _nestedProperty + * a (possibly modified for gui edits) nestedProperty constructor + * The modified version takes a 3rd argument, for a prefix to the attribute + * string necessary for storing GUI edits * * @returns {bool} `true` if it managed to complete drawing of the changes * `false` would mean the parent should replot. */ -exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags) { +exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags, _nestedProperty) { var componentType = np.astr, supplyComponentDefaults = Registry.getComponentMethod(componentType, 'supplyLayoutDefaults'), draw = Registry.getComponentMethod(componentType, 'draw'), @@ -40802,7 +41254,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, // redoing supplyDefaults // TODO: this assumes componentArray is in gd.layout - which will not be // true after we extend this to restyle - componentArrayFull = nestedProperty(fullLayout, componentType).get(); + componentArrayFull = _nestedProperty(fullLayout, componentType).get(); var deletes = [], firstIndexChange = -1, @@ -40813,7 +41265,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, objEdits, objKeys, objVal, - adding; + adding, prefix; // first make the add and edit changes for(i = 0; i < componentNums.length; i++) { @@ -40852,7 +41304,9 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, } else { for(j = 0; j < objKeys.length; j++) { - nestedProperty(componentArray[componentNum], objKeys[j]).set(objEdits[objKeys[j]]); + prefix = componentType + '[' + componentNum + '].'; + _nestedProperty(componentArray[componentNum], objKeys[j], prefix) + .set(objEdits[objKeys[j]]); } } } @@ -40903,7 +41357,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":165,"../lib/loggers":168,"../lib/nested_property":172,"../lib/noop":173,"../lib/search":182,"../registry":248,"./container_array_match":190}],195:[function(_dereq_,module,exports){ +},{"../lib/is_plain_object":163,"../lib/loggers":166,"../lib/noop":171,"../lib/search":180,"../registry":246,"./container_array_match":188}],193:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40921,6 +41375,8 @@ var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); var Lib = _dereq_('../lib'); +var nestedProperty = Lib.nestedProperty; + var Events = _dereq_('../lib/events'); var Queue = _dereq_('../lib/queue'); @@ -41016,9 +41472,6 @@ exports.plot = function(gd, data, layout, config) { // so we can share cached text across tabs Drawing.makeTester(); - // clear stashed base url - delete Drawing.baseUrl; - // collect promises for any async actions during plotting // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all @@ -41063,7 +41516,7 @@ exports.plot = function(gd, data, layout, config) { // Legacy polar plots if(!fullLayout._has('polar') && data && data[0] && data[0].r) { Lib.log('Legacy polar charts are deprecated!'); - return plotPolar(gd, data, layout); + return plotLegacyPolar(gd, data, layout); } // so we don't try to re-call Plotly.plot from inside @@ -41239,8 +41692,7 @@ exports.plot = function(gd, data, layout, config) { return Lib.syncOrAsync([ Registry.getComponentMethod('shapes', 'calcAutorange'), Registry.getComponentMethod('annotations', 'calcAutorange'), - doAutoRangeAndConstraints, - Registry.getComponentMethod('rangeslider', 'calcAutorange') + doAutoRangeAndConstraints ], gd); } @@ -41252,11 +41704,16 @@ exports.plot = function(gd, data, layout, config) { // store initial ranges *after* enforcing constraints, otherwise // we will never look like we're at the initial ranges if(graphWasEmpty) Axes.saveRangeInitial(gd); + + // this one is different from shapes/annotations calcAutorange + // the others incorporate those components into ax._extremes, + // this one actually sets the ranges in rangesliders. + Registry.getComponentMethod('rangeslider', 'calcAutorange')(gd); } // draw ticks, titles, and calculate axis scaling (._b, ._m) function drawAxes() { - return Axes.doTicks(gd, graphWasEmpty ? '' : 'redraw'); + return Axes.draw(gd, graphWasEmpty ? '' : 'redraw'); } var seq = [ @@ -41325,7 +41782,16 @@ function opaqueSetBackground(gd, bgColor) { } function setPlotContext(gd, config) { - if(!gd._context) gd._context = Lib.extendDeep({}, defaultConfig); + if(!gd._context) { + gd._context = Lib.extendDeep({}, defaultConfig); + + // stash href, used to make robust clipPath URLs + var base = d3.select('base'); + gd._context._baseUrl = base.size() && base.attr('href') ? + window.location.href.split('#')[0] : + ''; + } + var context = gd._context; var i, keys, key; @@ -41371,6 +41837,9 @@ function setPlotContext(gd, config) { } } } + + // not part of the user-facing config options + context._exportedPlot = config._exportedPlot; } // staticPlot forces a bunch of others: @@ -41400,7 +41869,7 @@ function setPlotContext(gd, config) { context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0; } -function plotPolar(gd, data, layout) { +function plotLegacyPolar(gd, data, layout) { // build or reuse the container skeleton var plotContainer = d3.select(gd).selectAll('.plot-container') .data([0]); @@ -41441,7 +41910,7 @@ function plotPolar(gd, data, layout) { // editable title var opacity = 1; - var txt = gd._fullLayout.title; + var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; if(txt === '' || !txt) opacity = 0; var titleLayout = function() { @@ -41475,7 +41944,7 @@ function plotPolar(gd, data, layout) { var setContenteditable = function() { this.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { - gd.framework({layout: {title: text}}); + gd.framework({layout: {title: {text: text}}}); this.text(text) .call(titleLayout); this.call(setContenteditable); @@ -41748,7 +42217,7 @@ function getExtendProperties(gd, update, indices, maxPoints) { * instance that references the key and value for this particular trace. */ trace = gd.data[indices[j]]; - prop = Lib.nestedProperty(trace, key); + prop = nestedProperty(trace, key); /* * Target is the existing gd.data.trace.dataArray value like "x" or "marker.size" @@ -42219,7 +42688,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) { * If the array is too short, it will wrap around (useful for * style files that want to specify cyclical default values). */ -exports.restyle = function restyle(gd, astr, val, _traces) { +function restyle(gd, astr, val, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -42289,7 +42758,8 @@ exports.restyle = function restyle(gd, astr, val, _traces) { gd.emit('plotly_restyle', specs.eventData); return gd; }); -}; +} +exports.restyle = restyle; // for undo: undefined initial vals must be turned into nulls // so that we unset rather than ignore them @@ -42298,11 +42768,77 @@ function undefinedToNull(val) { return val; } +/** + * Factory function to wrap nestedProperty with GUI edits if necessary + * with GUI edits we add an optional prefix to the nestedProperty constructor + * to prepend to the attribute string in the preGUI store. + */ +function makeNP(preGUI, guiEditFlag) { + if(!guiEditFlag) return nestedProperty; + + return function(container, attr, prefix) { + var np = nestedProperty(container, attr); + var npSet = np.set; + np.set = function(val) { + var fullAttr = (prefix || '') + attr; + storeCurrent(fullAttr, np.get(), val, preGUI); + npSet(val); + }; + return np; + }; +} + +function storeCurrent(attr, val, newVal, preGUI) { + if(Array.isArray(val) || Array.isArray(newVal)) { + var arrayVal = Array.isArray(val) ? val : []; + var arrayNew = Array.isArray(newVal) ? newVal : []; + var maxLen = Math.max(arrayVal.length, arrayNew.length); + for(var i = 0; i < maxLen; i++) { + storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); + } + } + else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + var objVal = Lib.isPlainObject(val) ? val : {}; + var objNew = Lib.isPlainObject(newVal) ? newVal : {}; + var objBoth = Lib.extendFlat({}, objVal, objNew); + for(var key in objBoth) { + storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); + } + } + else if(preGUI[attr] === undefined) { + preGUI[attr] = undefinedToNull(val); + } +} + +/** + * storeDirectGUIEdit: for routines that skip restyle/relayout and mock it + * by emitting a plotly_restyle or plotly_relayout event, this routine + * keeps track of the initial state in _preGUI for use by uirevision + * Does *not* apply these changes to data/layout - that's the responsibility + * of the calling routine. + * + * @param {object} container: the input attributes container (eg `layout` or a `trace`) + * @param {object} preGUI: where original values should be stored, either + * `layout._preGUI` or `layout._tracePreGUI[uid]` + * @param {object} edits: the {attr: val} object as normally passed to `relayout` etc + */ +exports._storeDirectGUIEdit = function(container, preGUI, edits) { + for(var attr in edits) { + var np = nestedProperty(container, attr); + storeCurrent(attr, np.get(), edits[attr], preGUI); + } +}; + function _restyle(gd, aobj, traces) { - var fullLayout = gd._fullLayout, - fullData = gd._fullData, - data = gd.data, - i; + var fullLayout = gd._fullLayout; + var fullData = gd._fullData; + var data = gd.data; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var eventData = Lib.extendDeepAll({}, aobj); + var i; + + cleanDeprecatedAttributeKeys(aobj); // initialize flags var flags = editTypes.traceFlags(); @@ -42326,6 +42862,16 @@ function _restyle(gd, aobj, traces) { function rangeAttr(axName) { return 'LAYOUT' + axName + '.range'; } + function getFullTrace(traceIndex) { + // usually fullData maps 1:1 onto data, but with groupby transforms + // the fullData index can be greater. Take the *first* matching trace. + for(var j = traceIndex; j < fullData.length; j++) { + if(fullData[j]._input === data[traceIndex]) return fullData[j]; + } + // should never get here - and if we *do* it should cause an error + // later on undefined fullTrace is passed to nestedProperty. + } + // for attrs that interact (like scales & autoscales), save the // old vals before making the change // val=undefined will not set a value, just record what the value was. @@ -42341,9 +42887,11 @@ function _restyle(gd, aobj, traces) { var extraparam; if(attr.substr(0, 6) === 'LAYOUT') { - extraparam = Lib.nestedProperty(gd.layout, attr.replace('LAYOUT', '')); + extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', '')); } else { - extraparam = Lib.nestedProperty(data[traces[i]], attr); + var tracei = traces[i]; + var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid]; + extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr); } if(!(attr in undoit)) { @@ -42398,7 +42946,7 @@ function _restyle(gd, aobj, traces) { redoit[ai] = vi; if(ai.substr(0, 6) === 'LAYOUT') { - param = Lib.nestedProperty(gd.layout, ai.replace('LAYOUT', '')); + param = layoutNP(gd.layout, ai.replace('LAYOUT', '')); undoit[ai] = [undefinedToNull(param.get())]; // since we're allowing val to be an array, allow it here too, // even though that's meaningless @@ -42413,8 +42961,9 @@ function _restyle(gd, aobj, traces) { undoit[ai] = a0(); for(i = 0; i < traces.length; i++) { cont = data[traces[i]]; - contFull = fullData[traces[i]]; - param = Lib.nestedProperty(cont, ai); + contFull = getFullTrace(traces[i]); + var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid]; + param = makeNP(preGUI, guiEditFlag)(cont, ai); oldVal = param.get(); newVal = Array.isArray(vi) ? vi[i % vi.length] : vi; @@ -42424,7 +42973,7 @@ function _restyle(gd, aobj, traces) { var prefix = ai.substr(0, ai.length - finalPart.length - 1); var prefixDot = prefix ? prefix + '.' : ''; var innerContFull = prefix ? - Lib.nestedProperty(contFull, prefix).get() : contFull; + nestedProperty(contFull, prefix).get() : contFull; valObject = PlotSchema.getTraceValObject(contFull, param.parts); @@ -42471,14 +43020,14 @@ function _restyle(gd, aobj, traces) { Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo); if(oldVal === 'pie') { - Lib.nestedProperty(cont, 'marker.color') - .set(Lib.nestedProperty(cont, 'marker.colors').get()); + nestedProperty(cont, 'marker.color') + .set(nestedProperty(cont, 'marker.colors').get()); // super kludgy - but if all pies are gone we won't remove them otherwise fullLayout._pielayer.selectAll('g.trace').remove(); } else if(Registry.traceIs(cont, 'cartesian')) { - Lib.nestedProperty(cont, 'marker.colors') - .set(Lib.nestedProperty(cont, 'marker.color').get()); + nestedProperty(cont, 'marker.colors') + .set(nestedProperty(cont, 'marker.color').get()); } } @@ -42549,7 +43098,7 @@ function _restyle(gd, aobj, traces) { // swap hovermode if set to "compare x/y data" if(ai === 'orientationaxes') { - var hovermode = Lib.nestedProperty(gd.layout, 'hovermode'); + var hovermode = nestedProperty(gd.layout, 'hovermode'); if(hovermode.get() === 'x') { hovermode.set('y'); } else if(hovermode.get() === 'y') { @@ -42588,10 +43137,53 @@ function _restyle(gd, aobj, traces) { undoit: undoit, redoit: redoit, traces: traces, - eventData: Lib.extendDeepNoArrays([], [redoit, traces]) + eventData: Lib.extendDeepNoArrays([], [eventData, traces]) }; } +/** + * Converts deprecated attribute keys to + * the current API to ensure backwards compatibility. + * + * This is needed for the update mechanism to determine which + * subroutines to run based on the actual attribute + * definitions (that don't include the deprecated ones). + * + * E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'} + * and {titlefont: {...}} to {'title.font': {...}}. + * + * @param aobj + */ +function cleanDeprecatedAttributeKeys(aobj) { + var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false); + var colorbarRegex = /colorbar\.title$/; + var keys = Object.keys(aobj); + var i, key, value; + + for(i = 0; i < keys.length; i++) { + key = keys[i]; + value = aobj[key]; + + if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) && + (typeof value === 'string' || typeof value === 'number')) { + replace(key, key.replace('title', 'title.text')); + } else if(key.indexOf('titlefont') > -1) { + replace(key, key.replace('titlefont', 'title.font')); + } else if(key.indexOf('titleposition') > -1) { + replace(key, key.replace('titleposition', 'title.position')); + } else if(key.indexOf('titleside') > -1) { + replace(key, key.replace('titleside', 'title.side')); + } else if(key.indexOf('titleoffset') > -1) { + replace(key, key.replace('titleoffset', 'title.offset')); + } + } + + function replace(oldAttrStr, newAttrStr) { + aobj[newAttrStr] = aobj[oldAttrStr]; + delete aobj[oldAttrStr]; + } +} + /** * relayout: update layout attributes of an existing plot * @@ -42612,7 +43204,7 @@ function _restyle(gd, aobj, traces) { * attribute object `{astr1: val1, astr2: val2 ...}` * allows setting multiple attributes simultaneously */ -exports.relayout = function relayout(gd, astr, val) { +function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -42675,7 +43267,8 @@ exports.relayout = function relayout(gd, astr, val) { gd.emit('plotly_relayout', specs.eventData); return gd; }); -}; +} +exports.relayout = relayout; // Optimization mostly for large splom traces where // Plots.supplyDefaults can take > 100ms @@ -42703,13 +43296,24 @@ function addAxRangeSequence(seq, rangesAltered) { // N.B. leave as sequence of subroutines (for now) instead of // subroutine of its own so that finalDraw always gets // executed after drawData - var doTicks = rangesAltered ? - function(gd) { return Axes.doTicks(gd, Object.keys(rangesAltered), true); } : - function(gd) { return Axes.doTicks(gd, 'redraw'); }; + var drawAxes = rangesAltered ? + function(gd) { + var opts = {skipTitle: true}; + for(var id in rangesAltered) { + if(Axes.getFromId(gd, id).automargin) { + opts = {}; + break; + } + } + return Axes.draw(gd, Object.keys(rangesAltered), opts); + } : + function(gd) { + return Axes.draw(gd, 'redraw'); + }; seq.push( subroutines.doAutoRangeAndConstraints, - doTicks, + drawAxes, subroutines.drawData, subroutines.finalDraw ); @@ -42720,14 +43324,19 @@ var AX_AUTORANGE_RE = /^[xyz]axis[0-9]*\.autorange$/; var AX_DOMAIN_RE = /^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/; function _relayout(gd, aobj) { - var layout = gd.layout, - fullLayout = gd._fullLayout, - keys = Object.keys(aobj), - axes = Axes.list(gd), - arrayEdits = {}, - arrayStr, - i, - j; + var layout = gd.layout; + var fullLayout = gd._fullLayout; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var keys = Object.keys(aobj); + var axes = Axes.list(gd); + var eventData = Lib.extendDeepAll({}, aobj); + var arrayEdits = {}; + + var arrayStr, i, j; + + cleanDeprecatedAttributeKeys(aobj); + keys = Object.keys(aobj); // look for 'allaxes', split out into all axes // in case of 3D the axis are nested within a scene which is held in _id @@ -42767,7 +43376,7 @@ function _relayout(gd, aobj) { // via a parent) do not override with this auto-generated extra if(attr in aobj || helpers.hasParent(aobj, attr)) return; - var p = Lib.nestedProperty(layout, attr); + var p = layoutNP(layout, attr); if(!(attr in undoit)) { undoit[attr] = undefinedToNull(p.get()); } @@ -42792,7 +43401,7 @@ function _relayout(gd, aobj) { throw new Error('cannot set ' + ai + 'and a parent attribute simultaneously'); } - var p = Lib.nestedProperty(layout, ai); + var p = layoutNP(layout, ai); var vi = aobj[ai]; var plen = p.parts.length; // p.parts may end with an index integer if the property is an array @@ -42804,8 +43413,8 @@ function _relayout(gd, aobj) { var pleafPlus = p.parts[pend - 1] + '.' + pleaf; // trunk nodes (everything except the leaf) var ptrunk = p.parts.slice(0, pend).join('.'); - var parentIn = Lib.nestedProperty(gd.layout, ptrunk).get(); - var parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + var parentIn = nestedProperty(gd.layout, ptrunk).get(); + var parentFull = nestedProperty(fullLayout, ptrunk).get(); var vOld = p.get(); if(vi === undefined) continue; @@ -42850,12 +43459,12 @@ function _relayout(gd, aobj) { // check autorange vs range else if(pleafPlus.match(AX_RANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - var axFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + var axFull = nestedProperty(fullLayout, ptrunk).get(); if(axFull._inputDomain) { // if we're autoranging and this axis has a constrained domain, // reset it so we don't get locked into a shrunken size @@ -42863,7 +43472,7 @@ function _relayout(gd, aobj) { } } else if(pleafPlus.match(AX_DOMAIN_RE)) { - Lib.nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); + nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } // toggling axis type between log and linear: we need to convert @@ -42932,10 +43541,10 @@ function _relayout(gd, aobj) { doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleaf.match(AX_NAME_PATTERN)) { - var fullProp = Lib.nestedProperty(fullLayout, ai).get(), + var fullProp = nestedProperty(fullLayout, ai).get(), newType = (vi || {}).type; // This can potentially cause strange behavior if the autotype is not @@ -42957,8 +43566,6 @@ function _relayout(gd, aobj) { arrayStr = containerArrayMatch.array; i = containerArrayMatch.index; var propStr = containerArrayMatch.property; - var componentArray = Lib.nestedProperty(layout, arrayStr); - var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; if(i !== '' && propStr === '') { @@ -42968,7 +43575,7 @@ function _relayout(gd, aobj) { if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { - undoit[ai] = obji; + undoit[ai] = (nestedProperty(layout, arrayStr).get() || [])[i]; } else { Lib.warn('unrecognized full object value', aobj); } @@ -43012,7 +43619,7 @@ function _relayout(gd, aobj) { // now we've collected component edits - execute them all together for(arrayStr in arrayEdits) { var finished = manageArrays.applyContainerArrayChanges(gd, - Lib.nestedProperty(layout, arrayStr), arrayEdits[arrayStr], flags); + layoutNP(layout, arrayStr), arrayEdits[arrayStr], flags, layoutNP); if(!finished) flags.plot = true; } @@ -43055,7 +43662,7 @@ function _relayout(gd, aobj) { rangesAltered: rangesAltered, undoit: undoit, redoit: redoit, - eventData: Lib.extendDeep({}, redoit) + eventData: eventData }; } @@ -43090,7 +43697,7 @@ function updateAutosize(gd) { * integer or array of integers for the traces to alter (all if omitted) * */ -exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { +function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -43170,7 +43777,235 @@ exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { return gd; }); -}; +} +exports.update = update; + +/* + * internal-use-only restyle/relayout/update variants that record the initial + * values in (fullLayout|fullTrace)._preGUI so changes can be persisted across + * Plotly.react data updates, dependent on uirevision attributes + */ +function guiEdit(func) { + return function wrappedEdit(gd) { + gd._fullLayout._guiEditing = true; + var p = func.apply(null, arguments); + gd._fullLayout._guiEditing = false; + return p; + }; +} +exports._guiRestyle = guiEdit(restyle); +exports._guiRelayout = guiEdit(relayout); +exports._guiUpdate = guiEdit(update); + +// For connecting edited layout attributes to uirevision attrs +// If no `attr` we use `match[1] + '.uirevision'` +// Ordered by most common edits first, to minimize our search time +var layoutUIControlPatterns = [ + {pattern: /^hiddenlabels/, attr: 'legend.uirevision'}, + {pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/}, + + // showspikes and modes include those nested inside scenes + {pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'}, + {pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'}, + + {pattern: /^(scene\d*)\.camera/}, + {pattern: /^(geo\d*)\.(projection|center)/}, + {pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/}, + {pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/}, + {pattern: /^(polar\d*\.angularaxis)\.rotation/}, + {pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/}, + + {pattern: /^legend\.(x|y)$/, attr: 'editrevision'}, + {pattern: /^(shapes|annotations)/, attr: 'editrevision'}, + {pattern: /^title\.text$/, attr: 'editrevision'} +]; + +// same for trace attributes: if `attr` is given it's in layout, +// or with no `attr` we use `trace.uirevision` +var traceUIControlPatterns = [ + {pattern: /^selectedpoints$/, attr: 'selectionrevision'}, + // "visible" includes trace.transforms[i].styles[j].value.visible + {pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'}, + {pattern: /^dimensions\[\d+\]\.constraintrange/}, + + // below this you must be in editable: true mode + // TODO: I still put name and title with `trace.uirevision` + // reasonable or should these be `editrevision`? + // Also applies to axis titles up in the layout section + + // "name" also includes transform.styles + {pattern: /(^|value\.)name$/}, + // including nested colorbar attributes (ie marker.colorbar) + {pattern: /colorbar\.title\.text$/}, + {pattern: /colorbar\.(x|y)$/, attr: 'editrevision'} +]; + +function findUIPattern(key, patternSpecs) { + for(var i = 0; i < patternSpecs.length; i++) { + var spec = patternSpecs[i]; + var match = key.match(spec.pattern); + if(match) { + return {head: match[1], attr: spec.attr}; + } + } +} + +// We're finding the new uirevision before supplyDefaults, so do the +// inheritance manually. Note that only `undefined` inherits - other +// falsy values are returned. +function getNewRev(revAttr, container) { + var newRev = nestedProperty(container, revAttr).get(); + if(newRev !== undefined) return newRev; + + var parts = revAttr.split('.'); + parts.pop(); + while(parts.length > 1) { + parts.pop(); + newRev = nestedProperty(container, parts.join('.') + '.uirevision').get(); + if(newRev !== undefined) return newRev; + } + + return container.uirevision; +} + +function getFullTraceIndexFromUid(uid, fullData) { + for(var i = 0; i < fullData.length; i++) { + if(fullData[i]._fullInput.uid === uid) return i; + } + return -1; +} + +function getTraceIndexFromUid(uid, data, tracei) { + for(var i = 0; i < data.length; i++) { + if(data[i].uid === uid) return i; + } + // fall back on trace order, but only if user didn't provide a uid for that trace + return data[tracei].uid ? -1 : tracei; +} + +function valsMatch(v1, v2) { + var v1IsObj = Lib.isPlainObject(v1); + var v1IsArray = Array.isArray(v1); + if(v1IsObj || v1IsArray) { + return ( + (v1IsObj && Lib.isPlainObject(v2)) || + (v1IsArray && Array.isArray(v2)) + ) && JSON.stringify(v1) === JSON.stringify(v2); + } + return v1 === v2; +} + +function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { + var layoutPreGUI = oldFullLayout._preGUI; + var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal; + var bothInheritAutorange = []; + var newRangeAccepted = {}; + for(key in layoutPreGUI) { + match = findUIPattern(key, layoutUIControlPatterns); + if(match) { + revAttr = match.attr || (match.head + '.uirevision'); + oldRev = nestedProperty(oldFullLayout, revAttr).get(); + newRev = oldRev && getNewRev(revAttr, layout); + if(newRev && (newRev === oldRev)) { + preGUIVal = layoutPreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(layout, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + if(newVal === undefined && key.substr(key.length - 9) === 'autorange') { + bothInheritAutorange.push(key.substr(0, key.length - 10)); + } + newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key); + } + // if we got this far, the new value was accepted as the new starting + // point (either because it changed or revision changed) + // so remove it from _preGUI for next time. + delete layoutPreGUI[key]; + + if(key.substr(key.length - 8, 6) === 'range[') { + newRangeAccepted[key.substr(0, key.length - 9)] = 1; + } + } + + // Special logic for `autorange`, since it interacts with `range`: + // If the new figure's matching `range` was kept, and `autorange` + // wasn't supplied explicitly in either the original or the new figure, + // we shouldn't alter that - but we may just have done that, so fix it. + for(var i = 0; i < bothInheritAutorange.length; i++) { + var axAttr = bothInheritAutorange[i]; + if(newRangeAccepted[axAttr]) { + var newAx = nestedProperty(layout, axAttr).get(); + if(newAx) delete newAx.autorange; + } + } + + // Now traces - try to match them up by uid (in case we added/deleted in + // the middle), then fall back on index. + var allTracePreGUI = oldFullLayout._tracePreGUI; + for(var uid in allTracePreGUI) { + var tracePreGUI = allTracePreGUI[uid]; + var newTrace = null; + var fullInput; + for(key in tracePreGUI) { + // wait until we know we have preGUI values to look for traces + // but if we don't find both, stop looking at this uid + if(!newTrace) { + var fulli = getFullTraceIndexFromUid(uid, oldFullData); + if(fulli < 0) { + // Somehow we didn't even have this trace in oldFullData... + // I guess this could happen with `deleteTraces` or something + delete allTracePreGUI[uid]; + break; + } + var fullTrace = oldFullData[fulli]; + fullInput = fullTrace._fullInput; + + var newTracei = getTraceIndexFromUid(uid, data, fullInput.index); + if(newTracei < 0) { + // No match in new data + delete allTracePreGUI[uid]; + break; + } + newTrace = data[newTracei]; + } + + match = findUIPattern(key, traceUIControlPatterns); + if(match) { + if(match.attr) { + oldRev = nestedProperty(oldFullLayout, match.attr).get(); + newRev = oldRev && getNewRev(match.attr, layout); + } + else { + oldRev = fullInput.uirevision; + // inheritance for trace.uirevision is simple, just layout.uirevision + newRev = newTrace.uirevision; + if(newRev === undefined) newRev = layout.uirevision; + } + + if(newRev && newRev === oldRev) { + preGUIVal = tracePreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(newTrace, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + newNP.set(undefinedToNull(nestedProperty(fullInput, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); + } + delete tracePreGUI[key]; + } + } +} /** * Plotly.react: @@ -43234,6 +44069,8 @@ exports.react = function(gd, data, layout, config) { gd.layout = layout || {}; helpers.cleanLayout(gd.layout); + applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout); + // "true" skips updating calcdata and remapping arrays from calcTransforms, // which supplyDefaults usually does at the end, but we may need to NOT do // if the diff (which we haven't determined yet) says we'll recalc @@ -44288,7 +45125,7 @@ function makePlotFramework(gd) { gd.emit('plotly_framework'); } -},{"../components/color":46,"../components/colorbar/connect":48,"../components/drawing":71,"../constants/xmlns_namespaces":147,"../lib":164,"../lib/events":157,"../lib/queue":178,"../lib/svg_text_utils":185,"../plots/cartesian/axes":208,"../plots/cartesian/constants":214,"../plots/cartesian/graph_interact":218,"../plots/plots":241,"../plots/polar/legacy":244,"../registry":248,"./edit_types":191,"./helpers":192,"./manage_arrays":194,"./plot_config":196,"./plot_schema":197,"./subroutines":199,"d3":11,"fast-isnumeric":13,"has-hover":15}],196:[function(_dereq_,module,exports){ +},{"../components/color":46,"../components/colorbar/connect":48,"../components/drawing":67,"../constants/xmlns_namespaces":144,"../lib":162,"../lib/events":155,"../lib/queue":176,"../lib/svg_text_utils":183,"../plots/cartesian/axes":206,"../plots/cartesian/constants":212,"../plots/cartesian/graph_interact":216,"../plots/plots":239,"../plots/polar/legacy":242,"../registry":246,"./edit_types":189,"./helpers":190,"./manage_arrays":192,"./plot_config":194,"./plot_schema":195,"./subroutines":197,"d3":11,"fast-isnumeric":13,"has-hover":15}],194:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -44381,12 +45218,34 @@ module.exports = { */ showAxisRangeEntryBoxes: true, - // link to open this plot in plotly + /* + * Add a text link to open this plot in plotly? + * This link shows up in the bottom right corner of the plot, and works + * identically to the newer ModeBar button controlled by `showSendToCloud` + * unless `sendData: false` is used. + */ showLink: false, - // if we show a link, does it contain data or just link to a plotly file? + /* + * If we show a text link (`showLink: true`), does it contain data or just + * a reference to a plotly cloud file? This option should only be used on + * plot.ly or another plotly server, and is not supported by the newer + * ModeBar button `showSendToCloud`. + */ sendData: true, + /* + * Should we include a ModeBar button, labeled "Edit in Chart Studio", + * that sends this chart to plot.ly or another plotly server as specified + * by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0 + * this button was included by default, now it is opt-in using this flag. + * + * Note that this button can (depending on `plotlyServerURL`) send your data + * to an external server. However that server doesn't persist your data + * until you arrive at the Chart Studio and explicitly click "Save". + */ + showSendToCloud: false, + // text appearing in the sendData link linkText: 'Edit chart', @@ -44424,6 +45283,9 @@ module.exports = { // add the plotly logo on the end of the mode bar displaylogo: true, + // watermark the images with the company's logo + watermark: false, + // increase the pixel ratio for Gl plot images plotGlPixelRatio: 2, @@ -44490,7 +45352,7 @@ module.exports = { locales: {} }; -},{}],197:[function(_dereq_,module,exports){ +},{}],195:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45176,7 +46038,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":164,"../plots/animation_attributes":203,"../plots/attributes":205,"../plots/frame_attributes":236,"../plots/layout_attributes":239,"../plots/polar/legacy/area_attributes":242,"../plots/polar/legacy/axis_attributes":243,"../registry":248,"./edit_types":191}],198:[function(_dereq_,module,exports){ +},{"../lib":162,"../plots/animation_attributes":201,"../plots/attributes":203,"../plots/frame_attributes":234,"../plots/layout_attributes":237,"../plots/polar/legacy/area_attributes":240,"../plots/polar/legacy/axis_attributes":241,"../registry":246,"./edit_types":189}],196:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45490,7 +46352,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":164,"../plots/attributes":205}],199:[function(_dereq_,module,exports){ +},{"../lib":162,"../plots/attributes":203}],197:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45520,6 +46382,10 @@ var enforceAxisConstraints = axisConstraints.enforce; var cleanAxisConstraints = axisConstraints.clean; var doAutoRange = _dereq_('../plots/cartesian/autorange').doAutoRange; +var SVG_TEXT_ANCHOR_START = 'start'; +var SVG_TEXT_ANCHOR_MIDDLE = 'middle'; +var SVG_TEXT_ANCHOR_END = 'end'; + exports.layoutStyles = function(gd) { return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd); }; @@ -45544,7 +46410,7 @@ function lsInner(gd) { var gs = fullLayout._size; var pad = gs.p; var axList = Axes.list(gd, '', true); - var i, subplot, plotinfo, xa, ya; + var i, subplot, plotinfo, ax, xa, ya; fullLayout._paperdiv.style({ width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px', @@ -45580,10 +46446,7 @@ function lsInner(gd) { // some preparation of axis position info for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - - // reset scale in case the margins have changed - ax.setScale(); + ax = axList[i]; var counterAx = ax._anchorAxis; @@ -45602,11 +46465,6 @@ function lsInner(gd) { ax._mainMirrorPosition = (ax.mirror && counterAx) ? getLinePosition(ax, counterAx, alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; - - // Figure out which subplot to draw ticks, labels, & axis lines on - // do this as a separate loop so we already have all the - // _mainAxis and _anchorAxis links set - ax._mainSubplot = findMainSubplot(ax, fullLayout); } // figure out which backgrounds we need to draw, @@ -45717,7 +46575,7 @@ function lsInner(gd) { layerClipId = null; } - Drawing.setClipUrl(plotinfo.plot, plotClipId); + Drawing.setClipUrl(plotinfo.plot, plotClipId, gd); // stash layer clipId value (null or same as clipId) // to DRY up Drawing.setClipUrl calls on trace-module and trace layers @@ -45847,48 +46705,6 @@ function lsInner(gd) { return gd._promises.length && Promise.all(gd._promises); } -function findMainSubplot(ax, fullLayout) { - var subplotList = fullLayout._subplots; - var ids = subplotList.cartesian.concat(subplotList.gl2d || []); - var mockGd = {_fullLayout: fullLayout}; - - var isX = ax._id.charAt(0) === 'x'; - var anchorAx = ax._mainAxis._anchorAxis; - var mainSubplotID = ''; - var nextBestMainSubplotID = ''; - var anchorID = ''; - - // First try the main ID with the anchor - if(anchorAx) { - anchorID = anchorAx._mainAxis._id; - mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); - } - - // Then look for a subplot with the counteraxis overlaying the anchor - // If that fails just use the first subplot including this axis - if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { - mainSubplotID = ''; - - for(var j = 0; j < ids.length; j++) { - var id = ids[j]; - var yIndex = id.indexOf('y'); - var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); - var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); - - if(idPart === ax._id) { - if(!nextBestMainSubplotID) nextBestMainSubplotID = id; - var counterAx = Axes.getFromId(mockGd, counterPart); - if(anchorID && counterAx.overlaying === anchorID) { - mainSubplotID = id; - break; - } - } - } - } - - return mainSubplotID || nextBestMainSubplotID; -} - function shouldShowLinesOrTicks(ax, subplot) { return (ax.ticks || ax.showline) && (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); @@ -45943,18 +46759,92 @@ function findCounterAxisLineWidth(ax, side, counterAx, axList) { exports.drawMainTitle = function(gd) { var fullLayout = gd._fullLayout; + var textAnchor = getMainTitleTextAnchor(fullLayout); + var dy = getMainTitleDy(fullLayout); + Titles.draw(gd, 'gtitle', { propContainer: fullLayout, - propName: 'title', + propName: 'title.text', placeholder: fullLayout._dfltTitle.plot, attributes: { - x: fullLayout.width / 2, - y: fullLayout._size.t / 2, - 'text-anchor': 'middle' + x: getMainTitleX(fullLayout, textAnchor), + y: getMainTitleY(fullLayout, dy), + 'text-anchor': textAnchor, + dy: dy } }); }; +function getMainTitleX(fullLayout, textAnchor) { + var title = fullLayout.title; + var gs = fullLayout._size; + var hPadShift = 0; + + if(textAnchor === SVG_TEXT_ANCHOR_START) { + hPadShift = title.pad.l; + } else if(textAnchor === SVG_TEXT_ANCHOR_END) { + hPadShift = -title.pad.r; + } + + switch(title.xref) { + case 'paper': + return gs.l + gs.w * title.x + hPadShift; + case 'container': + default: + return fullLayout.width * title.x + hPadShift; + } +} + +function getMainTitleY(fullLayout, dy) { + var title = fullLayout.title; + var gs = fullLayout._size; + var vPadShift = 0; + + if(dy === '0em' || !dy) { + vPadShift = -title.pad.b; + } else if(dy === alignmentConstants.CAP_SHIFT + 'em') { + vPadShift = title.pad.t; + } + + if(title.y === 'auto') { + return gs.t / 2; + } else { + switch(title.yref) { + case 'paper': + return gs.t + gs.h - gs.h * title.y + vPadShift; + case 'container': + default: + return fullLayout.height - fullLayout.height * title.y + vPadShift; + } + } +} + +function getMainTitleTextAnchor(fullLayout) { + var title = fullLayout.title; + + var textAnchor = SVG_TEXT_ANCHOR_MIDDLE; + if(Lib.isRightAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_END; + } else if(Lib.isLeftAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_START; + } + + return textAnchor; +} + +function getMainTitleDy(fullLayout) { + var title = fullLayout.title; + + var dy = '0em'; + if(Lib.isTopAnchor(title)) { + dy = alignmentConstants.CAP_SHIFT + 'em'; + } else if(Lib.isMiddleAnchor(title)) { + dy = alignmentConstants.MID_SHIFT + 'em'; + } + + return dy; +} + exports.doTraceStyle = function(gd) { var calcdata = gd.calcdata; var editStyleCalls = []; @@ -46032,7 +46922,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.doTicks(gd, 'redraw'); + Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -46167,6 +47057,8 @@ exports.doAutoRangeAndConstraints = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; cleanAxisConstraints(gd, ax); + // in case margins changed, update scale + ax.setScale(); doAutoRange(gd, ax); } @@ -46198,7 +47090,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('updatemenus', 'draw')(gd); }; -},{"../components/color":46,"../components/drawing":71,"../components/modebar":109,"../components/titles":137,"../constants/alignment":144,"../lib":164,"../lib/clear_gl_canvases":153,"../plots/cartesian/autorange":207,"../plots/cartesian/axes":208,"../plots/cartesian/constraints":216,"../plots/plots":241,"../registry":248,"d3":11}],200:[function(_dereq_,module,exports){ +},{"../components/color":46,"../components/drawing":67,"../components/modebar":105,"../components/titles":134,"../constants/alignment":141,"../lib":162,"../lib/clear_gl_canvases":151,"../plots/cartesian/autorange":205,"../plots/cartesian/axes":206,"../plots/cartesian/constraints":214,"../plots/plots":239,"../registry":246,"d3":11}],198:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46672,7 +47564,7 @@ function format(opts) { return opts; } -},{"../lib":164,"../plots/attributes":205,"../plots/plots":241,"./plot_config":196,"./plot_schema":197,"./plot_template":198}],201:[function(_dereq_,module,exports){ +},{"../lib":162,"../plots/attributes":203,"../plots/plots":239,"./plot_config":194,"./plot_schema":195,"./plot_template":196}],199:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46792,6 +47684,7 @@ function toImage(gd, opts) { // extend config for static plot var configImage = Lib.extendFlat({}, config, { + _exportedPlot: true, staticPlot: true, setBackground: setBackground }); @@ -46862,7 +47755,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":164,"../snapshot/helpers":252,"../snapshot/svgtoimg":254,"../snapshot/tosvg":256,"./plot_api":195}],202:[function(_dereq_,module,exports){ +},{"../lib":162,"../snapshot/helpers":250,"../snapshot/svgtoimg":252,"../snapshot/tosvg":254,"./plot_api":193}],200:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47308,7 +48201,7 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":164,"../plots/plots":241,"./plot_config":196,"./plot_schema":197}],203:[function(_dereq_,module,exports){ +},{"../lib":162,"../plots/plots":239,"./plot_config":194,"./plot_schema":195}],201:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47410,7 +48303,7 @@ module.exports = { } }; -},{}],204:[function(_dereq_,module,exports){ +},{}],202:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47506,7 +48399,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":164,"../plot_api/plot_template":198}],205:[function(_dereq_,module,exports){ +},{"../lib":162,"../plot_api/plot_template":196}],203:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47628,10 +48521,16 @@ module.exports = { _isLinkedToArray: 'transform', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + } }; -},{"../components/fx/attributes":80}],206:[function(_dereq_,module,exports){ +},{"../components/fx/attributes":76}],204:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47660,7 +48559,7 @@ module.exports = { } }; -},{}],207:[function(_dereq_,module,exports){ +},{}],205:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47675,6 +48574,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; +var Registry = _dereq_('../../registry'); module.exports = { getAutoRange: getAutoRange, @@ -47899,10 +48799,6 @@ function concatExtremes(gd, ax) { } function doAutoRange(gd, ax) { - if(!ax._length) ax.setScale(); - - var axIn; - if(ax.autorange) { ax.range = getAutoRange(gd, ax); @@ -47912,20 +48808,28 @@ function doAutoRange(gd, ax) { // doAutoRange will get called on fullLayout, // but we want to report its results back to layout - axIn = ax._input; + var axIn = ax._input; + + // before we edit _input, store preGUI values + var edits = {}; + edits[ax._attr + '.range'] = ax.range; + edits[ax._attr + '.autorange'] = ax.autorange; + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, edits); + axIn.range = ax.range.slice(); axIn.autorange = ax.autorange; } - if(ax._anchorAxis && ax._anchorAxis.rangeslider) { - var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name]; + var anchorAx = ax._anchorAxis; + + if(anchorAx && anchorAx.rangeslider) { + var axeRangeOpts = anchorAx.rangeslider[ax._name]; if(axeRangeOpts) { if(axeRangeOpts.rangemode === 'auto') { axeRangeOpts.range = getAutoRange(gd, ax); } } - axIn = ax._anchorAxis._input; - axIn.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); } } @@ -48143,7 +49047,7 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":146,"../../lib":164,"fast-isnumeric":13}],208:[function(_dereq_,module,exports){ +},{"../../constants/numerical":143,"../../lib":162,"../../registry":246,"fast-isnumeric":13}],206:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48303,6 +49207,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t ax.d2c(targetArray[i]); } } + // TODO what to do for transforms? } else { ax = axes.getFromTrace(gd, trace, d2cTarget); } @@ -48343,7 +49248,7 @@ axes.counterLetter = function(id) { axes.minDtick = function(ax, newDiff, newFirst, allow) { // doesn't make sense to do forced min dTick on log or category axes, // and the plot itself may decide to cancel (ie non-grouped bars) - if(['log', 'category'].indexOf(ax.type) !== -1 || !allow) { + if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; } // undefined means there's nothing there yet @@ -48375,18 +49280,15 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // save a copy of the initial axis ranges in fullLayout // use them in mode bar and dblclick events axes.saveRangeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._rangeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.range[0] === ax._rangeInitial[0] && - ax.range[1] === ax._rangeInitial[1] - ) + var hasChanged = isNew || !( + ax.range[0] === ax._rangeInitial[0] && + ax.range[1] === ax._rangeInitial[1] ); if((isNew && ax.autorange === false) || (overwrite && hasChanged)) { @@ -48400,21 +49302,16 @@ axes.saveRangeInitial = function(gd, overwrite) { // save a copy of the initial spike visibility axes.saveShowSpikeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false, - allSpikesEnabled = 'on'; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; + var allSpikesEnabled = 'on'; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._showSpikeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.showspikes === ax._showspikes - ) - ); + var hasChanged = isNew || !(ax.showspikes === ax._showspikes); - if((isNew) || (overwrite && hasChanged)) { + if(isNew || (overwrite && hasChanged)) { ax._showSpikeInitial = ax.showspikes; hasOneAxisChanged = true; } @@ -48431,7 +49328,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { var dataMin = Lib.aggNums(Math.min, null, data); var dataMax = Lib.aggNums(Math.max, null, data); - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { return { start: dataMin - 0.5, end: dataMax + 0.5, @@ -48449,8 +49346,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { type: 'linear', range: [dataMin, dataMax] }; - } - else { + } else { dummyAx = { type: ax.type, range: Lib.simpleMap([dataMin, dataMax], ax.c2r, 0, calendar), @@ -48535,10 +49431,10 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { - var edgecount = 0, - midcount = 0, - intcount = 0, - blankCount = 0; + var edgecount = 0; + var midcount = 0; + var intcount = 0; + var blankCount = 0; function nearEdge(v) { // is a value within 1% of a bin edge? @@ -48629,14 +49525,14 @@ axes.prepTicks = function(ax) { // calculate max number of (auto) ticks to display based on plot size if(ax.tickmode === 'auto' || !ax.dtick) { - var nt = ax.nticks, - minPx; + var nt = ax.nticks; + var minPx; + if(!nt) { - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; nt = ax._length / minPx; - } - else { + } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; nt = Lib.constrain(ax._length / minPx, 4, 9) + 1; } @@ -48698,7 +49594,7 @@ axes.calcTicks = function calcTicks(ax) { // return the full set of tick vals var vals = []; - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { endTick = (axrev) ? Math.max(-0.5, endTick) : Math.min(ax._categories.length - 0.5, endTick); } @@ -48742,23 +49638,22 @@ axes.calcTicks = function calcTicks(ax) { }; function arrayTicks(ax) { - var vals = ax.tickvals, - text = ax.ticktext, - ticksOut = new Array(vals.length), - rng = Lib.simpleMap(ax.range, ax.r2l), - r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001, - r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001, - tickMin = Math.min(r0expanded, r1expanded), - tickMax = Math.max(r0expanded, r1expanded), - vali, - i, - j = 0; + var vals = ax.tickvals; + var text = ax.ticktext; + var ticksOut = new Array(vals.length); + var rng = Lib.simpleMap(ax.range, ax.r2l); + var r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001; + var r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001; + var tickMin = Math.min(r0expanded, r1expanded); + var tickMax = Math.max(r0expanded, r1expanded); + var j = 0; // without a text array, just format the given values as any other ticks // except with more precision to the numbers if(!Array.isArray(text)) text = []; // make sure showing ticks doesn't accidentally add new categories + // TODO multicategory, if we allow ticktext / tickvals var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; // array ticks on log axes always show the full number @@ -48767,8 +49662,8 @@ function arrayTicks(ax) { ax.dtick = 'L' + Math.pow(10, Math.floor(Math.min(ax.range[0], ax.range[1])) - 1); } - for(i = 0; i < vals.length; i++) { - vali = tickVal2l(vals[i]); + for(var i = 0; i < vals.length; i++) { + var vali = tickVal2l(vals[i]); if(vali > tickMin && vali < tickMax) { if(text[i] === undefined) ticksOut[j] = axes.tickText(ax, vali); else ticksOut[j] = tickTextObj(ax, vali, String(text[i])); @@ -48781,17 +49676,17 @@ function arrayTicks(ax) { return ticksOut; } -var roundBase10 = [2, 5, 10], - roundBase24 = [1, 2, 3, 6, 12], - roundBase60 = [1, 2, 5, 10, 15, 30], - // 2&3 day ticks are weird, but need something btwn 1&7 - roundDays = [1, 2, 3, 7, 14], - // approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) - // these don't have to be exact, just close enough to round to the right value - roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1], - roundLog2 = [-0.301, 0, 0.301, 0.699, 1], - // N.B. `thetaunit; 'radians' angular axes must be converted to degrees - roundAngles = [15, 30, 45, 90, 180]; +var roundBase10 = [2, 5, 10]; +var roundBase24 = [1, 2, 3, 6, 12]; +var roundBase60 = [1, 2, 5, 10, 15, 30]; +// 2&3 day ticks are weird, but need something btwn 1&7 +var roundDays = [1, 2, 3, 7, 14]; +// approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) +// these don't have to be exact, just close enough to round to the right value +var roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1]; +var roundLog2 = [-0.301, 0, 0.301, 0.699, 1]; +// N.B. `thetaunit; 'radians' angular axes must be converted to degrees +var roundAngles = [15, 30, 45, 90, 180]; function roundDTick(roughDTick, base, roundingSet) { return base * Lib.roundUp(roughDTick / base, roundingSet); @@ -48882,7 +49777,7 @@ axes.autoTicks = function(ax, roughDTick) { ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } } - else if(ax.type === 'category') { + else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); } @@ -48922,7 +49817,7 @@ function autoTickRound(ax) { dtick = 1; } - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { ax._tickround = null; } if(ax.type === 'date') { @@ -49014,36 +49909,34 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { // calculate the first tick on an axis axes.tickFirst = function(ax) { - var r2l = ax.r2l || Number, - rng = Lib.simpleMap(ax.range, r2l), - axrev = rng[1] < rng[0], - sRound = axrev ? Math.floor : Math.ceil, - // add a tiny extra bit to make sure we get ticks - // that may have been rounded out - r0 = rng[0] * 1.0001 - rng[1] * 0.0001, - dtick = ax.dtick, - tick0 = r2l(ax.tick0); + var r2l = ax.r2l || Number; + var rng = Lib.simpleMap(ax.range, r2l); + var axrev = rng[1] < rng[0]; + var sRound = axrev ? Math.floor : Math.ceil; + // add a tiny extra bit to make sure we get ticks + // that may have been rounded out + var r0 = rng[0] * 1.0001 - rng[1] * 0.0001; + var dtick = ax.dtick; + var tick0 = r2l(ax.tick0); if(isNumeric(dtick)) { var tmin = sRound((r0 - tick0) / dtick) * dtick + tick0; // make sure no ticks outside the category list - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { tmin = Lib.constrain(tmin, 0, ax._categories.length - 1); } return tmin; } - var tType = dtick.charAt(0), - dtNum = Number(dtick.substr(1)); + var tType = dtick.charAt(0); + var dtNum = Number(dtick.substr(1)); // Dates: months (or years) if(tType === 'M') { - var cnt = 0, - t0 = tick0, - t1, - mult, - newDTick; + var cnt = 0; + var t0 = tick0; + var t1, mult, newDTick; // This algorithm should work for *any* nonlinear (but close to linear!) // tick spacing. Limit to 10 iterations, for gregorian months it's normally <=3. @@ -49085,16 +49978,18 @@ axes.tickFirst = function(ax) { // hover is a (truthy) flag for whether to show numbers with a bit // more precision for hovertext axes.tickText = function(ax, x, hover) { - var out = tickTextObj(ax, x), - hideexp, - arrayMode = ax.tickmode === 'array', - extraPrecision = hover || arrayMode, - i, - tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; + var out = tickTextObj(ax, x); + var arrayMode = ax.tickmode === 'array'; + var extraPrecision = hover || arrayMode; + var axType = ax.type; + // TODO multicategory, if we allow ticktext / tickvals + var tickVal2l = axType === 'category' ? ax.d2l_noadd : ax.d2l; + var i; if(arrayMode && Array.isArray(ax.ticktext)) { - var rng = Lib.simpleMap(ax.range, ax.r2l), - minDiff = Math.abs(rng[1] - rng[0]) / 10000; + var rng = Lib.simpleMap(ax.range, ax.r2l); + var minDiff = Math.abs(rng[1] - rng[0]) / 10000; + for(i = 0; i < ax.ticktext.length; i++) { if(Math.abs(x - tickVal2l(ax.tickvals[i])) < minDiff) break; } @@ -49105,28 +50000,25 @@ axes.tickText = function(ax, x, hover) { } function isHidden(showAttr) { - var first_or_last; - if(showAttr === undefined) return true; if(hover) return showAttr === 'none'; - first_or_last = { + var firstOrLast = { first: ax._tmin, last: ax._tmax }[showAttr]; - return showAttr !== 'all' && x !== first_or_last; + return showAttr !== 'all' && x !== firstOrLast; } - if(hover) { - hideexp = 'never'; - } else { - hideexp = ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - } + var hideexp = hover ? + 'never' : + ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - if(ax.type === 'date') formatDate(ax, out, hover, extraPrecision); - else if(ax.type === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); - else if(ax.type === 'category') formatCategory(ax, out); + if(axType === 'date') formatDate(ax, out, hover, extraPrecision); + else if(axType === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); + else if(axType === 'category') formatCategory(ax, out); + else if(axType === 'multicategory') formatMultiCategory(ax, out, hover); else if(isAngular(ax)) formatAngle(ax, out, hover, extraPrecision, hideexp); else formatLinear(ax, out, hover, extraPrecision, hideexp); @@ -49134,6 +50026,20 @@ axes.tickText = function(ax, x, hover) { if(ax.tickprefix && !isHidden(ax.showtickprefix)) out.text = ax.tickprefix + out.text; if(ax.ticksuffix && !isHidden(ax.showticksuffix)) out.text += ax.ticksuffix; + // Setup ticks and grid lines boundaries + // at 1/2 a 'category' to the left/bottom + if(ax.tickson === 'boundaries' || ax.showdividers) { + var inbounds = function(v) { + var p = ax.l2p(v); + return p >= 0 && p <= ax._length ? v : null; + }; + + out.xbnd = [ + inbounds(out.x - 0.5), + inbounds(out.x + ax.dtick - 0.5) + ]; + } + return out; }; @@ -49183,8 +50089,8 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround, - fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); + var tr = ax._tickround; + var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); if(extraPrecision) { // second or sub-second precision: extra always shows max digits. @@ -49193,8 +50099,8 @@ function formatDate(ax, out, hover, extraPrecision) { else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr]; } - var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat), - headStr; + var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat); + var headStr; var splitIndex = dateStr.indexOf('\n'); if(splitIndex !== -1) { @@ -49311,6 +50217,22 @@ function formatCategory(ax, out) { out.text = String(tt); } +function formatMultiCategory(ax, out, hover) { + var v = Math.round(out.x); + var cats = ax._categories[v] || []; + var tt = cats[1] === undefined ? '' : String(cats[1]); + var tt2 = cats[0] === undefined ? '' : String(cats[0]); + + if(hover) { + // TODO is this what we want? + out.text = tt2 + ' - ' + tt; + } else { + // setup for secondary labels + out.text = tt; + out.text2 = tt2; + } +} + function formatLinear(ax, out, hover, extraPrecision, hideexp) { if(hideexp === 'never') { // If this is a hover label, then we must *never* hide the exponent @@ -49416,14 +50338,13 @@ function beyondSI(exponent) { } function numFormat(v, ax, fmtoverride, hover) { - // negative? - var isNeg = v < 0, - // max number of digits past decimal point to show - tickRound = ax._tickround, - exponentFormat = fmtoverride || ax.exponentformat || 'B', - exponent = ax._tickexponent, - tickformat = axes.getTickFormat(ax), - separatethousands = ax.separatethousands; + var isNeg = v < 0; + // max number of digits past decimal point to show + var tickRound = ax._tickround; + var exponentFormat = fmtoverride || ax.exponentformat || 'B'; + var exponent = ax._tickexponent; + var tickformat = axes.getTickFormat(ax); + var separatethousands = ax.separatethousands; // special case for hover: set exponent just for this value, and // add a couple more digits of precision over tick labels @@ -49596,6 +50517,9 @@ axes.getTickFormat = function(ax) { // as an array of items like 'xy', 'x2y', 'x2y2'... // sorted by x (x,x2,x3...) then y // optionally restrict to only subplots containing axis object ax +// +// NOTE: this is currently only used OUTSIDE plotly.js (toolpanel, webapp) +// ideally we get rid of it there (or just copy this there) and remove it here axes.getSubplots = function(gd, ax) { var subplotObj = gd._fullLayout._subplots; var allSubplots = subplotObj.cartesian.concat(subplotObj.gl2d || []); @@ -49614,18 +50538,20 @@ axes.getSubplots = function(gd, ax) { }; // find all subplots with axis 'ax' +// NOTE: this is only used in axes.getSubplots (only used outside plotly.js) and +// gl2d/convert (where it restricts axis subplots to only those with gl2d) axes.findSubplotsWithAxis = function(subplots, ax) { var axMatch = new RegExp( (ax._id.charAt(0) === 'x') ? ('^' + ax._id + 'y') : (ax._id + '$') ); - var subplotsWithAxis = []; + var subplotsWithAx = []; for(var i = 0; i < subplots.length; i++) { var sp = subplots[i]; - if(axMatch.test(sp)) subplotsWithAxis.push(sp); + if(axMatch.test(sp)) subplotsWithAx.push(sp); } - return subplotsWithAxis; + return subplotsWithAx; }; // makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings @@ -49678,24 +50604,25 @@ axes.makeClipPaths = function(gd) { * * @param {DOM element} gd : graph div * @param {string or array of strings} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update + * @param {object} opts: + * - @param {boolean} skipTitle : optional flag to skip axis title draw/update * - * Signature 1: Axes.doTicks(gd, 'redraw') + * Signature 1: Axes.draw(gd, 'redraw') * use this to clear and redraw all axes on graph * - * Signature 2: Axes.doTicks(gd, '') + * Signature 2: Axes.draw(gd, '') * use this to draw all axes on graph w/o the selectAll().remove() * of the 'redraw' signature * - * Signature 3: Axes.doTicks(gd, [axId, axId2, ...]) + * Signature 3: Axes.draw(gd, [axId, axId2, ...]) * where the items are axis id string, * use this to update multiple axes in one call * - * N.B doTicks updates: + * N.B draw updates: * - ax._r (stored range for use by zoom/pan) * - ax._rl (stored linearized range for use by zoom/pan) */ -axes.doTicks = function(gd, arg, skipTitle) { +axes.draw = function(gd, arg, opts) { var fullLayout = gd._fullLayout; if(arg === 'redraw') { @@ -49707,6 +50634,8 @@ axes.doTicks = function(gd, arg, skipTitle) { plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove(); if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); @@ -49716,13 +50645,13 @@ axes.doTicks = function(gd, arg, skipTitle) { var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; - Lib.syncOrAsync(axList.map(function(axid) { + return Lib.syncOrAsync(axList.map(function(axId) { return function() { - if(!axid) return; + if(!axId) return; - var axDone = axes.doTicksSingle(gd, axid, skipTitle); + var ax = axes.getFromId(gd, axId); + var axDone = axes.drawOne(gd, ax, opts); - var ax = axes.getFromId(gd, axid); ax._r = ax.range.slice(); ax._rl = Lib.simpleMap(ax._r, ax.r2l); @@ -49732,692 +50661,1077 @@ axes.doTicks = function(gd, arg, skipTitle) { }; /** - * Per-axis drawing routine! - * - * This routine draws axis ticks and much more (... grids, labels, title etc.) - * Supports multiple argument signatures. - * N.B. this thing is async in general (because of MathJax rendering) - * - * @param {DOM element} gd : graph div - * @param {string or object} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * @return {promise} - * - * Signature 1: Axes.doTicks(gd, ax) - * where ax is an axis object as in fullLayout + * Draw one cartesian axis * - * Signature 2: Axes.doTicks(gd, axId) - * where axId is a axis id string + * @param {DOM element} gd + * @param {object} ax (full) axis object + * @param {object} opts + * - @param {boolean} skipTitle (set to true to skip axis title draw call) */ -axes.doTicksSingle = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; - var independent = false; - var ax; +axes.drawOne = function(gd, ax, opts) { + opts = opts || {}; - if(Lib.isPlainObject(arg)) { - ax = arg; - independent = true; - } else { - ax = axes.getFromId(gd, arg); - } + var i, sp, plotinfo; - // set scaling to pixels ax.setScale(); - var axid = ax._id; - var axLetter = axid.charAt(0); - var counterLetter = axes.counterLetter(axid); + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var counterLetter = axes.counterLetter(axId); + var mainSubplot = ax._mainSubplot; + var mainLinePosition = ax._mainLinePosition; + var mainMirrorPosition = ax._mainMirrorPosition; + var mainPlotinfo = fullLayout._plots[mainSubplot]; + var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; + var subplotsWithAx = ax._subplotsWith; + var vals = ax._vals = axes.calcTicks(ax); - var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; - var tcls = axid + 'tick'; - var gcls = axid + 'grid'; - var zcls = axid + 'zl'; - var pad = (ax.linewidth || 1) / 2; - var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); - var labelShift = 0; - var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); - var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); - var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); - var sides, transfn, tickpathfn, subplots; - var tickLabels; - var i; - if(ax._counterangle && ax.ticks === 'outside') { - var caRad = ax._counterangle * Math.PI / 180; - labelStandoff = ax.ticklen * Math.cos(caRad) + 1; - labelShift = ax.ticklen * Math.sin(caRad); + // Add a couple of axis properties that should cause us to recreate + // elements. Used in d3 data function. + var axInfo = [ax.mirror, mainLinePosition, mainMirrorPosition].join('_'); + for(i = 0; i < vals.length; i++) { + vals[i].axInfo = axInfo; } - if(ax.showticklabels && (ax.ticks === 'outside' || ax.showline)) { - labelStandoff += 0.2 * ax.tickfont.size; - } + if(!ax.visible) return; - // positioning arguments for x vs y axes - if(axLetter === 'x') { - sides = ['bottom', 'top']; - transfn = ax._transfn || function(d) { - return 'translate(' + (ax._offset + ax.l2p(d.x)) + ',0)'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M0,' + shift + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len); - } - else return 'M0,' + shift + 'v' + len; - }; - } - else if(axLetter === 'y') { - sides = ['left', 'right']; - transfn = ax._transfn || function(d) { - return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M' + shift + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); - } - else return 'M' + shift + ',0h' + len; - }; - } - else if(isAngular(ax)) { - sides = ['left', 'right']; - transfn = ax._transfn; - tickpathfn = function(shift, len) { - return 'M' + shift + ',0h' + len; - }; - } - else { - Lib.warn('Unrecognized doTicks axis:', axid); - return; + // stash selections to avoid DOM queries e.g. + // - stash tickLabels selection, so that drawTitle can use it to scoot title + ax._selections = {}; + // stash tick angle (including the computed 'auto' values) per tick-label class + ax._tickAngles = {}; + + var transFn = axes.makeTransFn(ax); + var tickVals; + // We remove zero lines, grid lines, and inside ticks if they're within 1px of the end + // The key case here is removing zero lines when the axis bound is zero + var valsClipped; + + if(ax.tickson === 'boundaries') { + var boundaryVals = getBoundaryVals(ax, vals); + valsClipped = axes.clipEnds(ax, boundaryVals); + tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals; + } else { + valsClipped = axes.clipEnds(ax, vals); + tickVals = ax.ticks === 'inside' ? valsClipped : vals; } - var axside = ax.side || sides[0]; - // which direction do the side[0], side[1], and free ticks go? - // then we flip if outside XOR y axis - var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; - if((ax.ticks !== 'inside') === (axLetter === 'x')) { - ticksign = ticksign.map(function(v) { return -v; }); - } + var gridVals = ax._gridVals = valsClipped; + var dividerVals = getDividerVals(ax, vals); - if(!ax.visible) return; + if(!fullLayout._hasOnlyLargeSploms) { + // keep track of which subplots (by main conteraxis) we've already + // drawn grids for, so we don't overdraw overlaying subplots + var finishedGrids = {}; - if(ax._tickFilter) { - vals = vals.filter(ax._tickFilter); - } + for(i = 0; i < subplotsWithAx.length; i++) { + sp = subplotsWithAx[i]; + plotinfo = fullLayout._plots[sp]; - // Remove zero lines, grid lines, and inside ticks if they're within - // 1 pixel of the end. - // The key case here is removing zero lines when the axis bound is zero. - // Don't clip angular values. - var valsClipped = ax._valsClipped = isAngular(ax) ? - vals : - vals.filter(function(d) { return clipEnds(ax, d.x); }); + var counterAxis = plotinfo[counterLetter + 'axis']; + var mainCounterID = counterAxis._mainAxis._id; + if(finishedGrids[mainCounterID]) continue; + finishedGrids[mainCounterID] = 1; - function drawTicks(container, tickpath) { - var ticks = container.selectAll('path.' + tcls) - .data(ax.ticks === 'inside' ? valsClipped : vals, datafn); + var gridPath = axLetter === 'x' ? + 'M0,' + counterAxis._offset + 'v' + counterAxis._length : + 'M' + counterAxis._offset + ',0h' + counterAxis._length; - if(tickpath && ax.ticks) { - ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) - .classed('crisp', 1) - .call(Color.stroke, ax.tickcolor) - .style('stroke-width', tickWidth + 'px') - .attr('d', tickpath); - ticks.attr('transform', transfn); - ticks.exit().remove(); + axes.drawGrid(gd, ax, { + vals: gridVals, + counterAxis: counterAxis, + layer: plotinfo.gridlayer.select('.' + axId), + path: gridPath, + transFn: transFn + }); + axes.drawZeroLine(gd, ax, { + counterAxis: counterAxis, + layer: plotinfo.zerolinelayer, + path: gridPath, + transFn: transFn + }); } - else ticks.remove(); } - function drawLabels(container, position) { - // tick labels - for now just the main labels. - // TODO: mirror labels, esp for subplots - tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); + var tickSigns = axes.getTickSigns(ax); + var tickSubplots = []; - if(!isNumeric(position)) { - tickLabels.remove(); - drawAxTitle(); - return; - } - if(!ax.showticklabels) { - tickLabels.remove(); - drawAxTitle(); - calcBoundingBox(); - return; + if(ax.ticks) { + var mainTickPath = axes.makeTickPath(ax, mainLinePosition, tickSigns[2]); + var mirrorTickPath; + var fullTickPath; + if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { + mirrorTickPath = axes.makeTickPath(ax, mainMirrorPosition, tickSigns[3]); + fullTickPath = mainTickPath + mirrorTickPath; + } else { + mirrorTickPath = ''; + fullTickPath = mainTickPath; } - var labelx, labely, labelanchor, labelpos0, flipit; - if(axLetter === 'x') { - flipit = (axside === 'bottom') ? 1 : -1; - labelx = function(d) { return d.dx + labelShift * flipit; }; - labelpos0 = position + (labelStandoff + pad) * flipit; - labely = function(d) { - return d.dy + labelpos0 + d.fontSize * - ((axside === 'bottom') ? 1 : -0.2); - }; - labelanchor = function(angle) { - if(!isNumeric(angle) || angle === 0 || angle === 180) { - return 'middle'; - } - return (angle * flipit < 0) ? 'end' : 'start'; - }; - } - else if(axLetter === 'y') { - flipit = (axside === 'right') ? 1 : -1; - labely = function(d) { - return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit; - }; - labelx = function(d) { - return d.dx + position + (labelStandoff + pad + - ((Math.abs(ax.tickangle) === 90) ? d.fontSize / 2 : 0)) * flipit; - }; - labelanchor = function(angle) { - if(isNumeric(angle) && Math.abs(angle) === 90) { - return 'middle'; - } - return axside === 'right' ? 'start' : 'end'; + var tickPath; + if(ax.showdividers && ax.ticks === 'outside' && ax.tickson === 'boundaries') { + var dividerLookup = {}; + for(i = 0; i < dividerVals.length; i++) { + dividerLookup[dividerVals[i].x] = 1; + } + tickPath = function(d) { + return dividerLookup[d.x] ? mirrorTickPath : fullTickPath; }; + } else { + tickPath = fullTickPath; } - else if(isAngular(ax)) { - ax._labelShift = labelShift; - ax._labelStandoff = labelStandoff; - ax._pad = pad; - - labelx = ax._labelx; - labely = ax._labely; - labelanchor = ax._labelanchor; - } - - var maxFontSize = 0, - autoangle = 0, - labelsReady = []; - tickLabels.enter().append('g').classed(tcls, 1) - .append('text') - // only so tex has predictable alignment that we can - // alter later - .attr('text-anchor', 'middle') - .each(function(d) { - var thisLabel = d3.select(this), - newPromise = gd._promises.length; - thisLabel - .call(svgTextUtils.positionText, labelx(d), labely(d)) - .call(Drawing.font, d.font, d.fontSize, d.fontColor) - .text(d.text) - .call(svgTextUtils.convertToTspans, gd); - newPromise = gd._promises[newPromise]; - if(newPromise) { - // if we have an async label, we'll deal with that - // all here so take it out of gd._promises and - // instead position the label and promise this in - // labelsReady - labelsReady.push(gd._promises.pop().then(function() { - positionLabels(thisLabel, ax.tickangle); - })); - } - else { - // sync label: just position it now. - positionLabels(thisLabel, ax.tickangle); - } - }); - tickLabels.exit().remove(); - tickLabels.each(function(d) { - maxFontSize = Math.max(maxFontSize, d.fontSize); + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: mainAxLayer, + path: tickPath, + transFn: transFn }); - if(isAngular(ax)) { - tickLabels.each(function(d) { - d3.select(this).select('text') - .call(svgTextUtils.positionText, labelx(d), labely(d)); + tickSubplots = Object.keys(ax._linepositions || {}); + } + + for(i = 0; i < tickSubplots.length; i++) { + sp = tickSubplots[i]; + plotinfo = fullLayout._plots[sp]; + // [bottom or left, top or right], free and main are handled above + var linepositions = ax._linepositions[sp] || []; + var spTickPath = axes.makeTickPath(ax, linepositions[0], tickSigns[0]) + + axes.makeTickPath(ax, linepositions[1], tickSigns[1]); + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: plotinfo[axLetter + 'axislayer'], + path: spTickPath, + transFn: transFn + }); + } + + var seq = []; + + // tick labels - for now just the main labels. + // TODO: mirror labels, esp for subplots + + seq.push(function() { + var labelFns = axes.makeLabelFns(ax, mainLinePosition); + return axes.drawLabels(gd, ax, { + vals: vals, + layer: mainAxLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn, + }); + }); + + if(ax.type === 'multicategory') { + var labelLength = 0; + var pad = {x: 2, y: 10}[axLetter]; + var sgn = tickSigns[2] * (ax.ticks === 'inside' ? -1 : 1); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick') + pad; + labelLength += ax._tickAngles[axId + 'tick'] ? ax.tickfont.size * LINE_SPACING : 0; + var secondaryPosition = mainLinePosition + labelLength * sgn; + var secondaryLabelFns = axes.makeLabelFns(ax, secondaryPosition); + + return axes.drawLabels(gd, ax, { + vals: getSecondaryLabelVals(ax, vals), + layer: mainAxLayer, + cls: axId + 'tick2', + repositionOnUpdate: true, + secondary: true, + transFn: transFn, + labelXFn: secondaryLabelFns.labelXFn, + labelYFn: secondaryLabelFns.labelYFn, + labelAnchorFn: secondaryLabelFns.labelAnchorFn, }); - } + }); - // How much to shift a multi-line label to center it vertically. - function getAnchorHeight(lineCount, lineHeight, angle) { - var h = (lineCount - 1) * lineHeight; - if(axLetter === 'x') { - if(angle < -60 || 60 < angle) { - return -0.5 * h; - } else if(axside === 'top') { - return -h; - } - } else { - angle *= axside === 'left' ? 1 : -1; - if(angle < -30) { - return -h; - } else if(angle < 30) { - return -0.5 * h; - } - } - return 0; - } - - function positionLabels(s, angle) { - s.each(function(d) { - var anchor = labelanchor(angle, d); - var thisLabel = d3.select(this), - mathjaxGroup = thisLabel.select('.text-math-group'), - transform = transfn.call(thisLabel.node(), d) + - ((isNumeric(angle) && +angle !== 0) ? - (' rotate(' + angle + ',' + labelx(d) + ',' + - (labely(d) - d.fontSize / 2) + ')') : - ''); - var anchorHeight = getAnchorHeight( - svgTextUtils.lineCount(thisLabel), - LINE_SPACING * d.fontSize, - isNumeric(angle) ? +angle : 0); - if(anchorHeight) { - transform += ' translate(0, ' + anchorHeight + ')'; - } - if(mathjaxGroup.empty()) { - thisLabel.select('text').attr({ - transform: transform, - 'text-anchor': anchor - }); - } - else { - var mjShift = - Drawing.bBox(mathjaxGroup.node()).width * - {end: -0.5, start: 0.5}[anchor]; - mathjaxGroup.attr('transform', transform + - (mjShift ? 'translate(' + mjShift + ',0)' : '')); - } + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick2'); + ax._labelLength = labelLength; + + return drawDividers(gd, ax, { + vals: dividerVals, + layer: mainAxLayer, + path: axes.makeTickPath(ax, mainLinePosition, sgn, labelLength), + transFn: transFn }); - } + }); + } - // make sure all labels are correctly positioned at their base angle - // the positionLabels call above is only for newly drawn labels. - // do this without waiting, using the last calculated angle to - // minimize flicker, then do it again when we know all labels are - // there, putting back the prescribed angle to check for overlaps. - positionLabels(tickLabels, ax._lastangle || ax.tickangle); - - function allLabelsReady() { - return labelsReady.length && Promise.all(labelsReady); - } - - function fixLabelOverlaps() { - positionLabels(tickLabels, ax.tickangle); - - // check for auto-angling if x labels overlap - // don't auto-angle at all for log axes with - // base and digit format - if(axLetter === 'x' && !isNumeric(ax.tickangle) && - (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')) { - var lbbArray = []; - tickLabels.each(function(d) { - var s = d3.select(this), - thisLabel = s.select('.text-math-group'), - x = ax.l2p(d.x); - if(thisLabel.empty()) thisLabel = s.select('text'); - - var bb = Drawing.bBox(thisLabel.node()); - - lbbArray.push({ - // ignore about y, just deal with x overlaps - top: 0, - bottom: 10, - height: 10, - left: x - bb.width / 2, - // impose a 2px gap - right: x + bb.width / 2 + 2, - width: bb.width + 2 - }); - }); - for(i = 0; i < lbbArray.length - 1; i++) { - if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { - // any overlap at all - set 30 degrees - autoangle = 30; - break; - } - } - if(autoangle) { - var tickspacing = Math.abs( - (vals[vals.length - 1].x - vals[0].x) * ax._m - ) / (vals.length - 1); - if(tickspacing < maxFontSize * 2.5) { - autoangle = 90; - } - positionLabels(tickLabels, autoangle); - } - ax._lastangle = autoangle; - } + function extendRange(range, newRange) { + range[0] = Math.min(range[0], newRange[0]); + range[1] = Math.max(range[1], newRange[1]); + } - // update the axis title - // (so it can move out of the way if needed) - // TODO: separate out scoot so we don't need to do - // a full redraw of the title (mostly relevant for MathJax) - drawAxTitle(); - return axid + ' done'; - } + function calcBoundingBox() { + if(ax.showticklabels) { + var gdBB = gd.getBoundingClientRect(); + var bBox = mainAxLayer.node().getBoundingClientRect(); + + /* + * the way we're going to use this, the positioning that matters + * is relative to the origin of gd. This is important particularly + * if gd is scrollable, and may have been scrolled between the time + * we calculate this and the time we use it + */ + + ax._boundingBox = { + width: bBox.width, + height: bBox.height, + left: bBox.left - gdBB.left, + right: bBox.right - gdBB.left, + top: bBox.top - gdBB.top, + bottom: bBox.bottom - gdBB.top + }; + } else { + var gs = fullLayout._size; + var pos; - function calcBoundingBox() { - if(ax.showticklabels) { - var gdBB = gd.getBoundingClientRect(); - var bBox = container.node().getBoundingClientRect(); + // set dummy bbox for ticklabel-less axes - /* - * the way we're going to use this, the positioning that matters - * is relative to the origin of gd. This is important particularly - * if gd is scrollable, and may have been scrolled between the time - * we calculate this and the time we use it - */ + if(axLetter === 'x') { + pos = ax.anchor === 'free' ? + gs.t + gs.h * (1 - ax.position) : + gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); ax._boundingBox = { - width: bBox.width, - height: bBox.height, - left: bBox.left - gdBB.left, - right: bBox.right - gdBB.left, - top: bBox.top - gdBB.top, - bottom: bBox.bottom - gdBB.top + top: pos, + bottom: pos, + left: ax._offset, + right: ax._offset + ax._length, + width: ax._length, + height: 0 }; } else { - var gs = fullLayout._size; - var pos; + pos = ax.anchor === 'free' ? + gs.l + gs.w * ax.position : + gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - // set dummy bbox for ticklabel-less axes - - if(axLetter === 'x') { - pos = ax.anchor === 'free' ? - gs.t + gs.h * (1 - ax.position) : - gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); - - ax._boundingBox = { - top: pos, - bottom: pos, - left: ax._offset, - right: ax._offset + ax._length, - width: ax._length, - height: 0 - }; - } else { - pos = ax.anchor === 'free' ? - gs.l + gs.w * ax.position : - gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - - ax._boundingBox = { - left: pos, - right: pos, - bottom: ax._offset + ax._length, - top: ax._offset, - height: ax._length, - width: 0 - }; - } + ax._boundingBox = { + left: pos, + right: pos, + bottom: ax._offset + ax._length, + top: ax._offset, + height: ax._length, + width: 0 + }; } + } - /* - * for spikelines: what's the full domain of positions in the - * opposite direction that are associated with this axis? - * This means any axes that we make a subplot with, plus the - * position of the axis itself if it's free. - */ - if(subplots) { - var fullRange = ax._counterSpan = [Infinity, -Infinity]; - - for(i = 0; i < subplots.length; i++) { - var subplot = fullLayout._plots[subplots[i]]; - var counterAxis = subplot[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + /* + * for spikelines: what's the full domain of positions in the + * opposite direction that are associated with this axis? + * This means any axes that we make a subplot with, plus the + * position of the axis itself if it's free. + */ + if(subplotsWithAx) { + var fullRange = ax._counterSpan = [Infinity, -Infinity]; - extendRange(fullRange, [ - counterAxis._offset, - counterAxis._offset + counterAxis._length - ]); - } + for(var i = 0; i < subplotsWithAx.length; i++) { + var plotinfo = fullLayout._plots[subplotsWithAx[i]]; + var counterAxis = plotinfo[(axLetter === 'x') ? 'yaxis' : 'xaxis']; - if(ax.anchor === 'free') { - extendRange(fullRange, (axLetter === 'x') ? - [ax._boundingBox.bottom, ax._boundingBox.top] : - [ax._boundingBox.right, ax._boundingBox.left]); - } + extendRange(fullRange, [ + counterAxis._offset, + counterAxis._offset + counterAxis._length + ]); } - function extendRange(range, newRange) { - range[0] = Math.min(range[0], newRange[0]); - range[1] = Math.max(range[1], newRange[1]); + if(ax.anchor === 'free') { + extendRange(fullRange, (axLetter === 'x') ? + [ax._boundingBox.bottom, ax._boundingBox.top] : + [ax._boundingBox.right, ax._boundingBox.left]); } } + } - function doAutoMargins() { - var pushKey = ax._name + '.automargin'; - if(axLetter !== 'x' && axLetter !== 'y') { return; } - if(!ax.automargin) { - Plots.autoMargin(gd, pushKey); - return; - } + var hasRangeSlider = Registry.getComponentMethod('rangeslider', 'isVisible')(ax); - var s = ax.side[0]; - var push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + function doAutoMargins() { + var push, rangeSliderPush; + + if(hasRangeSlider) { + rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); + } + Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); + + var s = ax.side.charAt(0); + if(ax.automargin && (!hasRangeSlider || s !== 'b')) { + push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; if(axLetter === 'x') { push.y = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 't' ? 1 : 0]); + ax._anchorAxis.domain[s === 't' ? 1 : 0]); push[s] += ax._boundingBox.height; - } - else { + } else { push.x = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 'r' ? 1 : 0]); + ax._anchorAxis.domain[s === 'r' ? 1 : 0]); push[s] += ax._boundingBox.width; } - if(ax.title !== fullLayout._dfltTitle[axLetter]) { - push[s] += ax.titlefont.size; + if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { + push[s] += ax.title.font.size; } - - Plots.autoMargin(gd, pushKey, push); } - var done = Lib.syncOrAsync([ - allLabelsReady, - fixLabelOverlaps, - calcBoundingBox, - doAutoMargins - ]); - if(done && done.then) gd._promises.push(done); - return done; + Plots.autoMargin(gd, axAutoMarginID(ax), push); } - function drawAxTitle() { - if(skipTitle) return; + seq.push(calcBoundingBox, doAutoMargins); - // now this only applies to regular cartesian axes; colorbars and - // others ALWAYS call doTicks with skipTitle=true so they can - // configure their own titles. + if(!opts.skipTitle && + !(hasRangeSlider && ax._boundingBox && ax.side === 'bottom') + ) { + seq.push(function() { return drawTitle(gd, ax); }); + } - // rangeslider takes over a bottom title so drop it here - if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; + return Lib.syncOrAsync(seq); +}; - var avoid = { - selection: tickLabels, - side: ax.side - }; - var axLetter = axid.charAt(0); - var gs = gd._fullLayout._size; - var offsetBase = 1.5; - var fontSize = ax.titlefont.size; +function getBoundaryVals(ax, vals) { + var out = []; + var i; - var transform, counterAxis, x, y; + // boundaryVals are never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; - if(tickLabels.size()) { - var translation = Drawing.getTranslate(tickLabels.node().parentNode); - avoid.offsetLeft = translation.x; - avoid.offsetTop = translation.y; + if(vals.length) { + for(i = 0; i < vals.length; i++) { + _push(vals[i], 0); } + _push(vals[i - 1], 1); + } - var titleStandoff = 10 + fontSize * offsetBase + - (ax.linewidth ? ax.linewidth - 1 : 0); + return out; +} - if(axLetter === 'x') { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : - axisIds.getFromId(gd, ax.anchor); +function getSecondaryLabelVals(ax, vals) { + var out = []; + var lookup = {}; - x = ax._offset + ax._length / 2; + for(var i = 0; i < vals.length; i++) { + var d = vals[i]; + if(lookup[d.text2]) { + lookup[d.text2].push(d.x); + } else { + lookup[d.text2] = [d.x]; + } + } - if(ax.side === 'top') { - y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); - } - else { - y = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1.5 : 0.5); - } - y += counterAxis._offset; + for(var k in lookup) { + out.push(tickTextObj(ax, Lib.interp(lookup[k], 0.5), k)); + } + + return out; +} + +function getDividerVals(ax, vals) { + var out = []; + var i, current; - if(!avoid.side) avoid.side = 'bottom'; + // never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); } - else { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + }; - y = ax._offset + ax._length / 2; - if(ax.side === 'right') { - x = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1 : 0.5); - } - else { - x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + if(ax.showdividers && vals.length) { + for(i = 0; i < vals.length; i++) { + var d = vals[i]; + if(d.text2 !== current) { + _push(d, 0); } - x += counterAxis._offset; + current = d.text2; + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getLabelLevelSpan(ax, cls) { + var axLetter = ax._id.charAt(0); + var angle = ax._tickAngles[cls] || 0; + var rad = Lib.deg2rad(angle); + var sinA = Math.sin(rad); + var cosA = Math.cos(rad); + var maxX = 0; + var maxY = 0; + + // N.B. Drawing.bBox does not take into account rotate transforms + + ax._selections[cls].each(function() { + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + var w = bb.width; + var h = bb.height; + maxX = Math.max(maxX, cosA * w, sinA * h); + maxY = Math.max(maxY, sinA * w, cosA * h); + }); + + return {x: maxY, y: maxX}[axLetter]; +} + +/** + * Which direction do the 'ax.side' values, and free ticks go? + * + * @param {object} ax (full) axis object + * - {string} _id (starting with 'x' or 'y') + * - {string} side + * - {string} ticks + * @return {array} all entries are either -1 or 1 + * - [0]: sign for top/right ticks (i.e. negative SVG direction) + * - [1]: sign for bottom/left ticks (i.e. positive SVG direction) + * - [2]: sign for ticks corresponding to 'ax.side' + * - [3]: sign for ticks mirroring 'ax.side' + */ +axes.getTickSigns = function(ax) { + var axLetter = ax._id.charAt(0); + var sideOpposite = {x: 'top', y: 'right'}[axLetter]; + var main = ax.side === sideOpposite ? 1 : -1; + var out = [-1, 1, main, -main]; + // then we flip if outside XOR y axis + if((ax.ticks !== 'inside') === (axLetter === 'x')) { + out = out.map(function(v) { return -v; }); + } + return out; +}; - transform = {rotate: '-90', offset: 0}; - if(!avoid.side) avoid.side = 'left'; +/** + * Make axis translate transform function + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} _offset + * - {fn} l2p + * @return {fn} function of calcTicks items + */ +axes.makeTransFn = function(ax) { + var axLetter = ax._id.charAt(0); + var offset = ax._offset; + return axLetter === 'x' ? + function(d) { return 'translate(' + (offset + ax.l2p(d.x)) + ',0)'; } : + function(d) { return 'translate(0,' + (offset + ax.l2p(d.x)) + ')'; }; +}; + +/** + * Make axis tick path string + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} ticklen + * - {number} linewidth + * @param {number} shift along direction of ticklen + * @param {1 or -1} sng tick sign + * @param {number (optional)} len tick length + * @return {string} + */ +axes.makeTickPath = function(ax, shift, sgn, len) { + len = len !== undefined ? len : ax.ticklen; + + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + + return axLetter === 'x' ? + 'M0,' + (shift + pad * sgn) + 'v' + (len * sgn) : + 'M' + (shift + pad * sgn) + ',0h' + (len * sgn); +}; + +/** + * Make axis tick label x, y and anchor functions + * + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} ticklen + * - {string} side + * - {number} linewidth + * - {number} tickfont.size + * - {boolean} showline + * @param {number} shift + * @param {number} angle [in degrees] ... + * @return {object} + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + * - {number} labelStandoff + * - {number} labelShift + */ +axes.makeLabelFns = function(ax, shift, angle) { + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside'; + + var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0; + var labelShift = 0; + + if(angle && ax.ticks === 'outside') { + var rad = Lib.deg2rad(angle); + labelStandoff = ax.ticklen * Math.cos(rad) + 1; + labelShift = ax.ticklen * Math.sin(rad); + } + + if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) { + labelStandoff += 0.2 * ax.tickfont.size; + } + + // Used in polar angular label x/y functions + // TODO generalize makeLabelFns so that it just work for angular axes + var out = { + labelStandoff: labelStandoff, + labelShift: labelShift + }; + + var x0, y0, ff, flipIt; + if(axLetter === 'x') { + flipIt = ax.side === 'bottom' ? 1 : -1; + x0 = labelShift * flipIt; + y0 = shift + (labelStandoff + pad) * flipIt; + ff = ax.side === 'bottom' ? 1 : -0.2; + + out.labelXFn = function(d) { return d.dx + x0; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * ff; }; + out.labelAnchorFn = function(a) { + if(!isNumeric(a) || a === 0 || a === 180) { + return 'middle'; + } + return (a * flipIt < 0) ? 'end' : 'start'; + }; + } else if(axLetter === 'y') { + flipIt = ax.side === 'right' ? 1 : -1; + x0 = labelStandoff + pad; + y0 = -labelShift * flipIt; + ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0; + + out.labelXFn = function(d) { return d.dx + shift + (x0 + d.fontSize * ff) * flipIt; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; }; + out.labelAnchorFn = function(a) { + if(isNumeric(a) && Math.abs(a) === 90) { + return 'middle'; + } + return ax.side === 'right' ? 'start' : 'end'; + }; + } + + return out; +}; + +function tickDataFn(d) { + return [d.text, d.x, d.axInfo, d.font, d.fontSize, d.fontColor].join('_'); +} + +/** + * Draw axis ticks + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} linewidth + * - {string} tickcolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawTicks = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'tick'; + + var ticks = opts.layer.selectAll('path.' + cls) + .data(ax.ticks ? opts.vals : [], tickDataFn); + + ticks.exit().remove(); + + ticks.enter().append('path') + .classed(cls, 1) + .classed('ticks', 1) + .classed('crisp', opts.crisp !== false) + .call(Color.stroke, ax.tickcolor) + .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') + .attr('d', opts.path); + + ticks.attr('transform', opts.transFn); +}; + +/** + * Draw axis grid + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showgrid + * - {string} gridcolor + * - {string} gridwidth + * - {boolean} zeroline + * - {string} type + * - {string} dtick + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * optional - only required if this axis supports zero lines + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawGrid = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'grid'; + var vals = opts.vals; + var counterAx = opts.counterAxis; + if(ax.showgrid === false) { + vals = []; + } + else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + var isArrayMode = ax.tickmode === 'array'; + for(var i = 0; i < vals.length; i++) { + var xi = vals[i].x; + if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) { + vals = vals.slice(0, i).concat(vals.slice(i + 1)); + // In array mode you can in principle have multiple + // ticks at 0, so test them all. Otherwise once we found + // one we can stop. + if(isArrayMode) i--; + else break; + } } + } + + var grid = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + grid.exit().remove(); + + grid.enter().append('path') + .classed(cls, 1) + .classed('crisp', opts.crisp !== false); + + ax._gw = Drawing.crispRound(gd, ax.gridwidth, 1); + + grid.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.gridcolor || '#ddd') + .style('stroke-width', ax._gw + 'px'); + + if(typeof opts.path === 'function') grid.attr('d', opts.path); +}; + +/** + * Draw axis zero-line + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} zeroline + * - {number} zerolinewidth + * - {string} zerolinecolor + * - {number (optional)} _gridWidthCrispRound + * @param {object} opts + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawZeroLine = function(gd, ax, opts) { + opts = opts || opts; + + var cls = ax._id + 'zl'; + var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis); - Titles.draw(gd, axid + 'title', { - propContainer: ax, - propName: ax._name + '.title', - placeholder: fullLayout._dfltTitle[axLetter], - avoid: avoid, - transform: transform, - attributes: {x: x, y: y, 'text-anchor': 'middle'} + var zl = opts.layer.selectAll('path.' + cls) + .data(show ? [{x: 0, id: ax._id}] : []); + + zl.exit().remove(); + + zl.enter().append('path') + .classed(cls, 1) + .classed('zl', 1) + .classed('crisp', opts.crisp !== false) + .each(function() { + // use the fact that only one element can enter to trigger a sort. + // If several zerolines enter at the same time we will sort once per, + // but generally this should be a minimal overhead. + opts.layer.selectAll('path').sort(function(da, db) { + return axisIds.idSort(da.id, db.id); + }); }); - } - function drawGrid(plotinfo, counteraxis) { - if(fullLayout._hasOnlyLargeSploms) return; - - var gridcontainer = plotinfo.gridlayer.selectAll('.' + axid); - var zlcontainer = plotinfo.zerolinelayer; - var gridpath = ax._gridpath || ((axLetter === 'x' ? - ('M0,' + counteraxis._offset + 'v') : - ('M' + counteraxis._offset + ',0h') - ) + counteraxis._length); - var grid = gridcontainer.selectAll('path.' + gcls) - .data((ax.showgrid === false) ? [] : valsClipped, datafn); - grid.enter().append('path').classed(gcls, 1) - .classed('crisp', 1) - .attr('d', gridpath) + zl.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); +}; + +/** + * Draw axis tick labels + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showticklabels + * - {number} tickangle + * - {object (optional)} _selections + * - {object} (optional)} _tickAngles + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string (optional)} cls (node className) + * - {boolean} repositionOnUpdate (set to true to reposition update selection) + * - {boolean} secondary + * - {fn} transFn + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + */ +axes.drawLabels = function(gd, ax, opts) { + opts = opts || {}; + + var axId = ax._id; + var axLetter = axId.charAt(0); + var cls = opts.cls || axId + 'tick'; + var vals = opts.vals; + var labelXFn = opts.labelXFn; + var labelYFn = opts.labelYFn; + var labelAnchorFn = opts.labelAnchorFn; + var tickAngle = opts.secondary ? 0 : ax.tickangle; + var lastAngle = (ax._tickAngles || {})[cls]; + + var tickLabels = opts.layer.selectAll('g.' + cls) + .data(ax.showticklabels ? vals : [], tickDataFn); + + var labelsReady = []; + + tickLabels.enter().append('g') + .classed(cls, 1) + .append('text') + // only so tex has predictable alignment that we can + // alter later + .attr('text-anchor', 'middle') .each(function(d) { - if(ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - Math.abs(d.x) < ax.dtick / 100) { - d3.select(this).remove(); + var thisLabel = d3.select(this); + var newPromise = gd._promises.length; + + thisLabel + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)) + .call(Drawing.font, d.font, d.fontSize, d.fontColor) + .text(d.text) + .call(svgTextUtils.convertToTspans, gd); + + if(gd._promises[newPromise]) { + // if we have an async label, we'll deal with that + // all here so take it out of gd._promises and + // instead position the label and promise this in + // labelsReady + labelsReady.push(gd._promises.pop().then(function() { + positionLabels(thisLabel, tickAngle); + })); + } else { + // sync label: just position it now. + positionLabels(thisLabel, tickAngle); } }); - grid.attr('transform', transfn) - .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', gridWidth + 'px'); - if(typeof gridpath === 'function') grid.attr('d', gridpath); - grid.exit().remove(); - - // zero line - if(zlcontainer) { - var zlData = {x: 0, id: axid}; - var showZl = axes.shouldShowZeroLine(gd, ax, counteraxis); - var zl = zlcontainer.selectAll('path.' + zcls) - .data(showZl ? [zlData] : []); - zl.enter().append('path').classed(zcls, 1).classed('zl', 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function() { - // use the fact that only one element can enter to trigger a sort. - // If several zerolines enter at the same time we will sort once per, - // but generally this should be a minimal overhead. - zlcontainer.selectAll('path').sort(function(da, db) { - return axisIds.idSort(da.id, db.id); - }); - }); - zl.attr('transform', transfn) - .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', zeroLineWidth + 'px'); - zl.exit().remove(); - } + + tickLabels.exit().remove(); + + if(opts.repositionOnUpdate) { + tickLabels.each(function(d) { + d3.select(this).select('text') + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)); + }); } - if(independent) { - drawTicks(ax._axislayer, tickpathfn(ax._pos + pad * ticksign[2], ticksign[2] * ax.ticklen)); - if(ax._counteraxis) { - var fictionalPlotinfo = { - gridlayer: ax._gridlayer, - zerolinelayer: ax._zerolinelayer - }; - drawGrid(fictionalPlotinfo, ax._counteraxis); + // How much to shift a multi-line label to center it vertically. + function getAnchorHeight(lineCount, lineHeight, angle) { + var h = (lineCount - 1) * lineHeight; + if(axLetter === 'x') { + if(angle < -60 || 60 < angle) { + return -0.5 * h; + } else if(ax.side === 'top') { + return -h; + } + } else { + angle *= ax.side === 'left' ? 1 : -1; + if(angle < -30) { + return -h; + } else if(angle < 30) { + return -0.5 * h; + } } - return drawLabels(ax._axislayer, ax._pos); + return 0; } - else if(fullLayout._has('cartesian')) { - subplots = axes.getSubplots(gd, ax); - - // keep track of which subplots (by main conteraxis) we've already - // drawn grids for, so we don't overdraw overlaying subplots - var finishedGrids = {}; - subplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; - var counterAxis = plotinfo[counterLetter + 'axis']; + function positionLabels(s, angle) { + s.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + var anchor = labelAnchorFn(angle, d); + + var transform = opts.transFn.call(thisLabel.node(), d) + + ((isNumeric(angle) && +angle !== 0) ? + (' rotate(' + angle + ',' + labelXFn(d) + ',' + + (labelYFn(d) - d.fontSize / 2) + ')') : + ''); + + var anchorHeight = getAnchorHeight( + svgTextUtils.lineCount(thisLabel), + LINE_SPACING * d.fontSize, + isNumeric(angle) ? +angle : 0 + ); - var mainCounterID = counterAxis._mainAxis._id; - if(finishedGrids[mainCounterID]) return; - finishedGrids[mainCounterID] = 1; + if(anchorHeight) { + transform += ' translate(0, ' + anchorHeight + ')'; + } - drawGrid(plotinfo, counterAxis, subplot); + if(mathjaxGroup.empty()) { + thisLabel.select('text').attr({ + transform: transform, + 'text-anchor': anchor + }); + } else { + var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; + var mjShift = mjWidth * {end: -0.5, start: 0.5}[anchor]; + mathjaxGroup.attr('transform', transform + (mjShift ? 'translate(' + mjShift + ',0)' : '')); + } }); + } - var mainSubplot = ax._mainSubplot; - var mainPlotinfo = fullLayout._plots[mainSubplot]; - var tickSubplots = []; + // make sure all labels are correctly positioned at their base angle + // the positionLabels call above is only for newly drawn labels. + // do this without waiting, using the last calculated angle to + // minimize flicker, then do it again when we know all labels are + // there, putting back the prescribed angle to check for overlaps. + positionLabels(tickLabels, lastAngle || tickAngle); - if(ax.ticks) { - var mainSign = ticksign[2]; - var tickpath = tickpathfn(ax._mainLinePosition + pad * mainSign, mainSign * ax.ticklen); - if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { - tickpath += tickpathfn(ax._mainMirrorPosition - pad * mainSign, -mainSign * ax.ticklen); - } - drawTicks(mainPlotinfo[axLetter + 'axislayer'], tickpath); + function allLabelsReady() { + return labelsReady.length && Promise.all(labelsReady); + } - tickSubplots = Object.keys(ax._linepositions || {}); - } + function fixLabelOverlaps() { + positionLabels(tickLabels, tickAngle); - tickSubplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; + var autoangle = null; - var container = plotinfo[axLetter + 'axislayer']; + // check for auto-angling if x labels overlap + // don't auto-angle at all for log axes with + // base and digit format + if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) && + (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D') + ) { + autoangle = 0; - // [bottom or left, top or right] - // free and main are handled above - var linepositions = ax._linepositions[subplot] || []; + var maxFontSize = 0; + var lbbArray = []; + var i; + + tickLabels.each(function(d) { + maxFontSize = Math.max(maxFontSize, d.fontSize); + + var x = ax.l2p(d.x); + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + + lbbArray.push({ + // ignore about y, just deal with x overlaps + top: 0, + bottom: 10, + height: 10, + left: x - bb.width / 2, + // impose a 2px gap + right: x + bb.width / 2 + 2, + width: bb.width + 2 + }); + }); + + if((ax.tickson === 'boundaries' || ax.showdividers) && !opts.secondary) { + var gap = 2; + if(ax.ticks) gap += ax.tickwidth / 2; + + // TODO should secondary labels also fall into this fix-overlap regime? + + for(i = 0; i < lbbArray.length; i++) { + var xbnd = vals[i].xbnd; + var lbb = lbbArray[i]; + if( + (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || + (xbnd[1] !== null && (ax.l2p(xbnd[1]) - lbb.right) < gap) + ) { + autoangle = 90; + break; + } + } + } else { + var vLen = vals.length; + var tickSpacing = Math.abs((vals[vLen - 1].x - vals[0].x) * ax._m) / (vLen - 1); + var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory'; - function tickPathSide(sidei) { - var tsign = ticksign[sidei]; - return tickpathfn(linepositions[sidei] + pad * tsign, tsign * ax.ticklen); + // any overlap at all - set 30 degrees or 90 degrees + for(i = 0; i < lbbArray.length - 1; i++) { + if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { + autoangle = rotate90 ? 90 : 30; + break; + } + } } - drawTicks(container, tickPathSide(0) + tickPathSide(1)); - }); + if(autoangle) { + positionLabels(tickLabels, autoangle); + } + } - var mainContainer = mainPlotinfo[axLetter + 'axislayer']; + if(ax._tickAngles) { + ax._tickAngles[cls] = autoangle === null ? + (isNumeric(tickAngle) ? tickAngle : 0) : + autoangle; + } + } - return drawLabels(mainContainer, ax._mainLinePosition); + if(ax._selections) { + ax._selections[cls] = tickLabels; } + + var done = Lib.syncOrAsync([allLabelsReady, fixLabelOverlaps]); + if(done && done.then) gd._promises.push(done); + return done; }; +/** + * Draw axis dividers + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} showdividers + * - {number} dividerwidth + * - {string} dividercolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {fn} path + * - {fn} transFn + */ +function drawDividers(gd, ax, opts) { + var cls = ax._id + 'divider'; + var vals = opts.vals; + + var dividers = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + dividers.exit().remove(); + + dividers.enter().insert('path', ':first-child') + .classed(cls, 1) + .classed('crisp', 1) + .call(Color.stroke, ax.dividercolor) + .style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px'); + + dividers + .attr('transform', opts.transFn) + .attr('d', opts.path); +} + +function drawTitle(gd, ax) { + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var gs = fullLayout._size; + var fontSize = ax.title.font.size; + + var titleStandoff; + if(ax.type === 'multicategory') { + titleStandoff = ax._labelLength; + } else { + var offsetBase = 1.5; + titleStandoff = 10 + fontSize * offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); + } + + var transform, counterAxis, x, y; + + if(axLetter === 'x') { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + x = ax._offset + ax._length / 2; + + if(ax.side === 'top') { + y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); + } else { + y = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1.5 : 0.5); + } + y += counterAxis._offset; + } else { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + y = ax._offset + ax._length / 2; + + if(ax.side === 'right') { + x = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1 : 0.5); + } else { + x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + } + x += counterAxis._offset; + + transform = {rotate: '-90', offset: 0}; + } + + var avoid; + + if(ax.type !== 'multicategory') { + var tickLabels = ax._selections[ax._id + 'tick']; + + avoid = { + selection: tickLabels, + side: ax.side + }; + + if(tickLabels && tickLabels.node() && tickLabels.node().parentNode) { + var translation = Drawing.getTranslate(tickLabels.node().parentNode); + avoid.offsetLeft = translation.x; + avoid.offsetTop = translation.y; + } + } + + return Titles.draw(gd, axId + 'title', { + propContainer: ax, + propName: ax._name + '.title.text', + placeholder: fullLayout._dfltTitle[axLetter], + avoid: avoid, + transform: transform, + attributes: {x: x, y: y, 'text-anchor': 'middle'} + }); +} + axes.shouldShowZeroLine = function(gd, ax, counterAxis) { var rng = Lib.simpleMap(ax.range, ax.r2l); return ( (rng[0] * rng[1] <= 0) && ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - ax._valsClipped.length && + ax._gridVals.length && ( clipEnds(ax, 0) || !anyCounterAxLineAtZero(gd, ax, counterAxis, rng) || @@ -50426,6 +51740,10 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { ); }; +axes.clipEnds = function(ax, vals) { + return vals.filter(function(d) { return clipEnds(ax, d.x); }); +}; + function clipEnds(ax, l) { var p = ax.l2p(l); return (p > 1 && p < ax._length - 1); @@ -50501,6 +51819,12 @@ function hasBarsOrFill(gd, ax) { return false; } +function selectTickLabel(gTick) { + var s = d3.select(gTick); + var mj = s.select('.text-math-group'); + return mj.empty() ? s.select('text') : mj; +} + /** * Find all margin pushers for 2D axes and reserve them for later use * Both label and rangeslider automargin calculations happen later so @@ -50515,14 +51839,17 @@ axes.allowAutoMargin = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; if(ax.automargin) { - Plots.allowAutoMargin(gd, ax._name + '.automargin'); + Plots.allowAutoMargin(gd, axAutoMarginID(ax)); } - if(ax.rangeslider && ax.rangeslider.visible) { - Plots.allowAutoMargin(gd, 'rangeslider' + ax._id); + if(Registry.getComponentMethod('rangeslider', 'isVisible')(ax)) { + Plots.allowAutoMargin(gd, rangeSliderAutoMarginID(ax)); } } }; +function axAutoMarginID(ax) { return ax._id + '.automargin'; } +function rangeSliderAutoMarginID(ax) { return ax._id + '.rangeslider'; } + // swap all the presentation attributes of the axes showing these traces axes.swap = function(gd, traces) { var axGroups = makeAxisGroups(gd, traces); @@ -50578,11 +51905,10 @@ function mergeAxisGroups(intoSet, fromSet) { } function swapAxisGroup(gd, xIds, yIds) { - var i, - j, - xFullAxes = [], - yFullAxes = [], - layout = gd.layout; + var xFullAxes = []; + var yFullAxes = []; + var layout = gd.layout; + var i, j; for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i])); for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i])); @@ -50595,12 +51921,12 @@ function swapAxisGroup(gd, xIds, yIds) { var numericTypes = ['linear', 'log']; for(i = 0; i < allAxKeys.length; i++) { - var keyi = allAxKeys[i], - xVal = xFullAxes[0][keyi], - yVal = yFullAxes[0][keyi], - allEqual = true, - coerceLinearX = false, - coerceLinearY = false; + var keyi = allAxKeys[i]; + var xVal = xFullAxes[0][keyi]; + var yVal = yFullAxes[0][keyi]; + var allEqual = true; + var coerceLinearX = false; + var coerceLinearY = false; if(keyi.charAt(0) === '_' || typeof xVal === 'function' || noSwapAttrs.indexOf(keyi) !== -1) { continue; @@ -50646,17 +51972,18 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes, dfltTitle) { // in case the value is the default for either axis, // look at the first axis in each list and see if // this key's value is undefined - var np = Lib.nestedProperty, - xVal = np(layout[xFullAxes[0]._name], key).get(), - yVal = np(layout[yFullAxes[0]._name], key).get(), - i; + var np = Lib.nestedProperty; + var xVal = np(layout[xFullAxes[0]._name], key).get(); + var yVal = np(layout[yFullAxes[0]._name], key).get(); + var i; + if(key === 'title') { // special handling of placeholder titles - if(xVal === dfltTitle.x) { - xVal = dfltTitle.y; + if(xVal && xVal.text === dfltTitle.x) { + xVal.text = dfltTitle.y; } - if(yVal === dfltTitle.y) { - yVal = dfltTitle.x; + if(yVal && yVal.text === dfltTitle.y) { + yVal.text = dfltTitle.x; } } @@ -50672,7 +51999,7 @@ function isAngular(ax) { return ax._id === 'angularaxis'; } -},{"../../components/color":46,"../../components/drawing":71,"../../components/titles":137,"../../constants/alignment":144,"../../constants/numerical":146,"../../lib":164,"../../lib/svg_text_utils":185,"../../plots/plots":241,"../../registry":248,"./autorange":207,"./axis_autotype":209,"./axis_ids":211,"./clean_ticks":213,"./layout_attributes":221,"./set_convert":227,"d3":11,"fast-isnumeric":13}],209:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/drawing":67,"../../components/titles":134,"../../constants/alignment":141,"../../constants/numerical":143,"../../lib":162,"../../lib/svg_text_utils":183,"../../plots/plots":239,"../../registry":246,"./autorange":205,"./axis_autotype":207,"./axis_ids":209,"./clean_ticks":211,"./layout_attributes":219,"./set_convert":225,"d3":11,"fast-isnumeric":13}],207:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50689,7 +52016,10 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var BADNUM = _dereq_('../../constants/numerical').BADNUM; -module.exports = function autoType(array, calendar) { +module.exports = function autoType(array, calendar, opts) { + opts = opts || {}; + + if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory'; if(moreDates(array, calendar)) return 'date'; if(category(array)) return 'category'; if(linearOK(array)) return 'linear'; @@ -50757,7 +52087,14 @@ function category(a) { return curvecats > curvenums * 2; } -},{"../../constants/numerical":146,"../../lib":164,"fast-isnumeric":13}],210:[function(_dereq_,module,exports){ +// very-loose requirements for multicategory, +// trace modules that should never auto-type to multicategory +// should be declared with 'noMultiCategory' +function multiCategory(a) { + return Lib.isArrayOrTypedArray(a[0]) && Lib.isArrayOrTypedArray(a[1]); +} + +},{"../../constants/numerical":143,"../../lib":162,"fast-isnumeric":13}],208:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50788,6 +52125,7 @@ var setConvert = _dereq_('./set_convert'); * outerTicks: boolean, should ticks default to outside? * showGrid: boolean, should gridlines be shown by default? * noHover: boolean, this axis doesn't support hover effects? + * noTickson: boolean, this axis doesn't support 'tickson' * data: the plot data, used to manage categories * bgColor: the plot background color, to calculate default gridline colors */ @@ -50828,8 +52166,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, // try to get default title from splom trace, fallback to graph-wide value var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter]; - coerce('title', dfltTitle); - Lib.coerceFont(coerce, 'titlefont', { + coerce('title.text', dfltTitle); + Lib.coerceFont(coerce, 'title.font', { family: font.family, size: Math.round(font.size * 1.2), color: dfltFontColor @@ -50849,10 +52187,29 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, if(options.automargin) coerce('automargin'); + var isMultiCategory = containerOut.type === 'multicategory'; + + if(!options.noTickson && + (containerOut.type === 'category' || isMultiCategory) && + (containerOut.ticks || containerOut.showgrid) + ) { + var ticksonDflt; + if(isMultiCategory) ticksonDflt = 'boundaries'; + coerce('tickson', ticksonDflt); + } + + if(isMultiCategory) { + var showDividers = coerce('showdividers'); + if(showDividers) { + coerce('dividercolor'); + coerce('dividerwidth'); + } + } + return containerOut; }; -},{"../../lib":164,"../../registry":248,"./category_order_defaults":212,"./layout_attributes":221,"./line_grid_defaults":223,"./set_convert":227,"./tick_label_defaults":228,"./tick_mark_defaults":229,"./tick_value_defaults":230}],211:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../registry":246,"./category_order_defaults":210,"./layout_attributes":219,"./line_grid_defaults":221,"./set_convert":225,"./tick_label_defaults":226,"./tick_mark_defaults":227,"./tick_value_defaults":228}],209:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50970,7 +52327,7 @@ exports.idSort = function(id1, id2) { return +(id1.substr(1) || 1) - +(id2.substr(1) || 1); }; -},{"../../registry":248,"./constants":214}],212:[function(_dereq_,module,exports){ +},{"../../registry":246,"./constants":212}],210:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51064,7 +52421,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],213:[function(_dereq_,module,exports){ +},{}],211:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51153,7 +52510,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":146,"../../lib":164,"fast-isnumeric":13}],214:[function(_dereq_,module,exports){ +},{"../../constants/numerical":143,"../../lib":162,"fast-isnumeric":13}],212:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51235,7 +52592,7 @@ module.exports = { } }; -},{"../../lib/regex":179}],215:[function(_dereq_,module,exports){ +},{"../../lib/regex":177}],213:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51389,7 +52746,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[scaleanchor] = 1; } -},{"../../lib":164,"./axis_ids":211}],216:[function(_dereq_,module,exports){ +},{"../../lib":162,"./axis_ids":209}],214:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51531,7 +52888,6 @@ exports.enforce = function enforceAxisConstraints(gd) { var getPad = makePadFn(ax); updateDomain(ax, factor); - ax.setScale(); var m = Math.abs(ax._m); var extremes = concatExtremes(gd, ax); var minArray = extremes.min; @@ -51598,9 +52954,10 @@ function updateDomain(ax, factor) { center + (inputDomain[0] - center) / factor, center + (inputDomain[1] - center) / factor ]; + ax.setScale(); } -},{"../../constants/alignment":144,"../../constants/numerical":146,"./autorange":207,"./axis_ids":211,"./scale_zoom":225}],217:[function(_dereq_,module,exports){ +},{"../../constants/alignment":141,"../../constants/numerical":143,"./autorange":205,"./axis_ids":209,"./scale_zoom":223}],215:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51622,6 +52979,7 @@ var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Fx = _dereq_('../../components/fx'); +var Axes = _dereq_('./axes'); var setCursor = _dereq_('../../lib/setcursor'); var dragElement = _dereq_('../../components/dragelement'); var FROM_TL = _dereq_('../../constants/alignment').FROM_TL; @@ -51630,7 +52988,6 @@ var redrawReglTraces = _dereq_('../../plot_api/subroutines').redrawReglTraces; var Plots = _dereq_('../plots'); -var doTicksSingle = _dereq_('./axes').doTicksSingle; var getFromId = _dereq_('./axis_ids').getFromId; var prepSelect = _dereq_('./select').prepSelect; var clearSelect = _dereq_('./select').clearSelect; @@ -51874,7 +53231,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { .on('edit', function(text) { var v = ax.d2r(text); if(v !== undefined) { - Registry.call('relayout', gd, attrStr, v); + Registry.call('_guiRelayout', gd, attrStr, v); } }); } @@ -52119,6 +53476,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { return; } + // prevent axis drawing from monkeying with margins until we're done + gd._fullLayout._replotting = true; + if(xActive === 'ew' || yActive === 'ns') { if(xActive) dragAxList(xaxes, dx); if(yActive) dragAxList(yaxes, dy); @@ -52222,8 +53582,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { updates = {}; for(i = 0; i < activeAxIds.length; i++) { var axId = activeAxIds[i]; - doTicksSingle(gd, axId, true); var ax = getFromId(gd, axId); + Axes.drawOne(gd, ax, {skipTitle: true}); updates[ax._name + '.range[0]'] = ax.range[0]; updates[ax._name + '.range[1]'] = ax.range[1]; } @@ -52315,7 +53675,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, attrs); } // dragTail - finish a drag event with a redraw @@ -52329,7 +53689,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // accumulated MathJax promises - wait for them before we relayout. Lib.syncOrAsync([ Plots.previousPromises, - function() { Registry.call('relayout', gd, updates); } + function() { + gd._fullLayout._replotting = false; + Registry.call('_guiRelayout', gd, updates); + } ], gd); } @@ -52787,7 +54150,7 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":46,"../../components/dragelement":68,"../../components/drawing":71,"../../components/fx":88,"../../constants/alignment":144,"../../lib":164,"../../lib/clear_gl_canvases":153,"../../lib/setcursor":183,"../../lib/svg_text_utils":185,"../../plot_api/subroutines":199,"../../registry":248,"../plots":241,"./axes":208,"./axis_ids":211,"./constants":214,"./scale_zoom":225,"./select":226,"d3":11,"has-passive-events":16,"tinycolor2":29}],218:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/dragelement":64,"../../components/drawing":67,"../../components/fx":85,"../../constants/alignment":141,"../../lib":162,"../../lib/clear_gl_canvases":151,"../../lib/setcursor":181,"../../lib/svg_text_utils":183,"../../plot_api/subroutines":197,"../../registry":246,"../plots":239,"./axes":206,"./axis_ids":209,"./constants":212,"./scale_zoom":223,"./select":224,"d3":11,"has-passive-events":16,"tinycolor2":29}],216:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52955,7 +54318,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":68,"../../components/fx":88,"../../lib/setcursor":183,"./constants":214,"./dragbox":217,"d3":11}],219:[function(_dereq_,module,exports){ +},{"../../components/dragelement":64,"../../components/fx":85,"../../lib/setcursor":181,"./constants":212,"./dragbox":215,"d3":11}],217:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53030,7 +54393,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":164,"../../registry":248}],220:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../registry":246}],218:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53295,7 +54658,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback // layers that allow `cliponaxis: false` if(className !== 'scatterlayer' && className !== 'barlayer') { - Drawing.setClipUrl(sel, plotinfo.layerClipId); + Drawing.setClipUrl(sel, plotinfo.layerClipId, gd); } }); @@ -53653,7 +55016,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":71,"../../constants/xmlns_namespaces":147,"../../lib":164,"../../registry":248,"../get_data":237,"../plots":241,"./attributes":206,"./axis_ids":211,"./constants":214,"./graph_interact":218,"./layout_attributes":221,"./layout_defaults":222,"./transition_axes":231,"d3":11}],221:[function(_dereq_,module,exports){ +},{"../../components/drawing":67,"../../constants/xmlns_namespaces":144,"../../lib":162,"../../registry":246,"../get_data":235,"../plots":239,"./attributes":204,"./axis_ids":209,"./constants":212,"./graph_interact":216,"./layout_attributes":219,"./layout_defaults":220,"./transition_axes":229,"d3":11}],219:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53688,21 +55051,24 @@ module.exports = { }, title: { - valType: 'string', - - editType: 'ticks', - + text: { + valType: 'string', + + editType: 'ticks', + + }, + font: fontAttrs({ + editType: 'ticks', + + }), + editType: 'ticks' }, - titlefont: fontAttrs({ - editType: 'ticks', - - }), type: { valType: 'enumerated', // '-' means we haven't yet run autotype or couldn't find any data // it gets turned into linear in gd._fullLayout but not copied back // to gd.data like the others are. - values: ['-', 'linear', 'log', 'date', 'category'], + values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', editType: 'calc', @@ -53831,6 +55197,14 @@ module.exports = { editType: 'ticks', + }, + tickson: { + valType: 'enumerated', + values: ['labels', 'boundaries'], + + dflt: 'labels', + editType: 'ticks', + }, mirror: { valType: 'enumerated', @@ -54084,6 +55458,30 @@ module.exports = { editType: 'ticks', }, + + showdividers: { + valType: 'boolean', + dflt: true, + + editType: 'ticks', + + }, + dividercolor: { + valType: 'color', + dflt: colorAttrs.defaultLine, + + editType: 'ticks', + + }, + dividerwidth: { + valType: 'number', + dflt: 1, + + editType: 'ticks', + + }, + // TODO dividerlen: that would override "to label base" length? + // positioning attributes // anchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -54165,6 +55563,12 @@ module.exports = { editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'calc', @@ -54174,11 +55578,21 @@ module.exports = { editType: 'ticks', - } + }, + title: { + valType: 'string', + + editType: 'ticks', + + }, + titlefont: fontAttrs({ + editType: 'ticks', + + }) } }; -},{"../../components/color/attributes":45,"../../components/drawing/attributes":70,"../../lib/extend":158,"../../plot_api/plot_template":198,"../font_attributes":235,"./constants":214}],222:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":45,"../../components/drawing/attributes":66,"../../lib/extend":156,"../../plot_api/plot_template":196,"../font_attributes":233,"./constants":212}],220:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54337,9 +55751,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; }); axLayoutOut._annIndices = []; axLayoutOut._shapeIndices = []; + axLayoutOut._subplotsWith = []; + axLayoutOut._counterAxes = []; // set up some private properties - axLayoutOut._name = axName; + axLayoutOut._name = axLayoutOut._attr = axName; var id = axLayoutOut._id = name2id(axName); var overlayableAxes = getOverlayableAxes(axLetter, axName); @@ -54357,6 +55773,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id] }; + coerce('uirevision', layoutOut.uirevision); + handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions); handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut); @@ -54418,11 +55836,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var anchoredAxis = layoutOut[id2name(axLayoutOut.anchor)]; - var fixedRangeDflt = ( - anchoredAxis && - anchoredAxis.rangeslider && - anchoredAxis.rangeslider.visible - ); + var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis); coerce('fixedrange', fixedRangeDflt); } @@ -54447,7 +55861,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } }; -},{"../../components/color":46,"../../lib":164,"../../plot_api/plot_template":198,"../../registry":248,"../layout_attributes":239,"./axis_defaults":210,"./axis_ids":211,"./constraint_defaults":215,"./layout_attributes":221,"./position_defaults":224,"./type_defaults":232}],223:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../lib":162,"../../plot_api/plot_template":196,"../../registry":246,"../layout_attributes":237,"./axis_defaults":208,"./axis_ids":209,"./constraint_defaults":213,"./layout_attributes":219,"./position_defaults":222,"./type_defaults":230}],221:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54512,7 +55926,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":45,"../../lib":164,"tinycolor2":29}],224:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":45,"../../lib":162,"tinycolor2":29}],222:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54596,7 +56010,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":164,"fast-isnumeric":13}],225:[function(_dereq_,module,exports){ +},{"../../lib":162,"fast-isnumeric":13}],223:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54624,7 +56038,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ]; }; -},{"../../constants/alignment":144}],226:[function(_dereq_,module,exports){ +},{"../../constants/alignment":141}],224:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55293,13 +56707,22 @@ function isOnlyOnePointSelected(searchTraces) { function updateSelectedState(gd, searchTraces, eventData) { var i, searchInfo, cd, trace; + // before anything else, update preGUI if necessary + for(i = 0; i < searchTraces.length; i++) { + var fullInputTrace = searchTraces[i].cd[0].trace._fullInput; + var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid]; + if(tracePreGUI.selectedpoints === undefined) { + tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null; + } + } + if(eventData) { var pts = eventData.points || []; for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; - trace.selectedpoints = []; - trace._input.selectedpoints = []; + trace._input.selectedpoints = trace._fullInput.selectedpoints = []; + if(trace._fullInput !== trace) trace.selectedpoints = []; } for(i = 0; i < pts.length; i++) { @@ -55309,10 +56732,14 @@ function updateSelectedState(gd, searchTraces, eventData) { if(pt.pointIndices) { [].push.apply(data.selectedpoints, pt.pointIndices); - [].push.apply(fullData.selectedpoints, pt.pointIndices); + if(trace._fullInput !== trace) { + [].push.apply(fullData.selectedpoints, pt.pointIndices); + } } else { data.selectedpoints.push(pt.pointIndex); - fullData.selectedpoints.push(pt.pointIndex); + if(trace._fullInput !== trace) { + fullData.selectedpoints.push(pt.pointIndex); + } } } } @@ -55321,6 +56748,9 @@ function updateSelectedState(gd, searchTraces, eventData) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; delete trace._input.selectedpoints; + if(trace._fullInput !== trace) { + delete trace._fullInput.selectedpoints; + } } } @@ -55398,7 +56828,7 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":46,"../../components/fx":88,"../../components/fx/helpers":85,"../../lib/clear_gl_canvases":153,"../../lib/polygon":176,"../../lib/throttle":186,"../../plot_api/subroutines":199,"../../registry":248,"./axis_ids":211,"./constants":214,"polybooljs":20}],227:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/fx":85,"../../components/fx/helpers":81,"../../lib/clear_gl_canvases":151,"../../lib/polygon":174,"../../lib/throttle":184,"../../plot_api/subroutines":197,"../../registry":246,"./axis_ids":209,"./constants":212,"polybooljs":20}],225:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55431,6 +56861,10 @@ function fromLog(v) { return Math.pow(10, v); } +function isValidCategory(v) { + return v !== null && v !== undefined; +} + /** * Define the conversion functions for an axis data is used in 5 ways: * @@ -55524,7 +56958,7 @@ module.exports = function setConvert(ax, fullLayout) { * a disconnect between the array and the index returned */ function setCategoryIndex(v) { - if(v !== null && v !== undefined) { + if(isValidCategory(v)) { if(ax._categoriesMap === undefined) { ax._categoriesMap = {}; } @@ -55543,14 +56977,58 @@ module.exports = function setConvert(ax, fullLayout) { return BADNUM; } + function setMultiCategoryIndex(arrayIn, len) { + var arrayOut = new Array(len); + var i; + + // [ [arrayIn[0][i], arrayIn[1][i]], for i .. len ] + var tmp = new Array(len); + // [ [cnt, {$cat: index}], for j .. arrayIn.length ] + var seen = [[0, {}], [0, {}]]; + + if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) { + for(i = 0; i < len; i++) { + var v0 = arrayIn[0][i]; + var v1 = arrayIn[1][i]; + if(isValidCategory(v0) && isValidCategory(v1)) { + tmp[i] = [v0, v1]; + if(!(v0 in seen[0][1])) { + seen[0][1][v0] = seen[0][0]++; + } + if(!(v1 in seen[1][1])) { + seen[1][1][v1] = seen[1][0]++; + } + } + } + + tmp.sort(function(a, b) { + var ind0 = seen[0][1]; + var d = ind0[a[0]] - ind0[b[0]]; + if(d) return d; + + var ind1 = seen[1][1]; + return ind1[a[1]] - ind1[b[1]]; + }); + } + + for(i = 0; i < len; i++) { + arrayOut[i] = setCategoryIndex(tmp[i]); + } + + return arrayOut; + } + function getCategoryIndex(v) { - // d2l/d2c variant that that won't add categories but will also - // allow numbers to be mapped to the linearized axis positions if(ax._categoriesMap) { - var index = ax._categoriesMap[v]; - if(index !== undefined) return index; + return ax._categoriesMap[v]; } + } + function getCategoryPosition(v) { + // d2l/d2c variant that that won't add categories but will also + // allow numbers to be mapped to the linearized axis positions + var index = getCategoryIndex(v); + if(index !== undefined) return index; if(isNumeric(v)) return +v; } @@ -55636,15 +57114,15 @@ module.exports = function setConvert(ax, fullLayout) { ax.d2c = ax.d2l = setCategoryIndex; ax.r2d = ax.c2d = ax.l2d = getCategoryName; - ax.d2r = ax.d2l_noadd = getCategoryIndex; + ax.d2r = ax.d2l_noadd = getCategoryPosition; ax.r2c = function(v) { - var index = getCategoryIndex(v); + var index = getCategoryPosition(v); return index !== undefined ? index : ax.fraction2r(0.5); }; ax.l2r = ax.c2r = ensureNumber; - ax.r2l = getCategoryIndex; + ax.r2l = getCategoryPosition; ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; ax.p2d = function(px) { return getCategoryName(p2l(px)); }; @@ -55656,6 +57134,34 @@ module.exports = function setConvert(ax, fullLayout) { return ensureNumber(v); }; } + else if(ax.type === 'multicategory') { + // N.B. multicategory axes don't define d2c and d2l, + // as 'data-to-calcdata' conversion needs to take into + // account all data array items as in ax.makeCalcdata. + + ax.r2d = ax.c2d = ax.l2d = getCategoryName; + ax.d2r = ax.d2l_noadd = getCategoryPosition; + + ax.r2c = function(v) { + var index = getCategoryPosition(v); + return index !== undefined ? index : ax.fraction2r(0.5); + }; + + ax.r2c_just_indices = getCategoryIndex; + + ax.l2r = ax.c2r = ensureNumber; + ax.r2l = getCategoryPosition; + + ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; + ax.p2d = function(px) { return getCategoryName(p2l(px)); }; + ax.r2p = ax.d2p; + ax.p2r = p2l; + + ax.cleanPos = function(v) { + if(Array.isArray(v) || (typeof v === 'string' && v !== '')) return v; + return ensureNumber(v); + }; + } // find the range value at the specified (linear) fraction of the axis ax.fraction2r = function(v) { @@ -55749,11 +57255,6 @@ module.exports = function setConvert(ax, fullLayout) { ax.setScale = function(usePrivateRange) { var gs = fullLayout._size; - // TODO cleaner way to handle this case - if(!ax._categories) ax._categories = []; - // Add a map to optimize the performance of category collection - if(!ax._categoriesMap) ax._categoriesMap = {}; - // make sure we have a domain (pull it in from the axis // this one is overlaying if necessary) if(ax.overlaying) { @@ -55808,7 +57309,7 @@ module.exports = function setConvert(ax, fullLayout) { if(axLetter in trace) { arrayIn = trace[axLetter]; - len = trace._length || arrayIn.length; + len = trace._length || Lib.minRowLength(arrayIn); if(Lib.isTypedArray(arrayIn) && (axType === 'linear' || axType === 'log')) { if(len === arrayIn.length) { @@ -55818,6 +57319,10 @@ module.exports = function setConvert(ax, fullLayout) { } } + if(axType === 'multicategory') { + return setMultiCategoryIndex(arrayIn, len); + } + arrayOut = new Array(len); for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); @@ -55894,7 +57399,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":146,"../../lib":164,"./axis_ids":211,"./constants":214,"d3":11,"fast-isnumeric":13}],228:[function(_dereq_,module,exports){ +},{"../../constants/numerical":143,"../../lib":162,"./axis_ids":209,"./constants":212,"d3":11,"fast-isnumeric":13}],226:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55995,7 +57500,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../lib":164,"../array_container_defaults":204,"./layout_attributes":221}],229:[function(_dereq_,module,exports){ +},{"../../lib":162,"../array_container_defaults":202,"./layout_attributes":219}],227:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56028,7 +57533,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":164,"./layout_attributes":221}],230:[function(_dereq_,module,exports){ +},{"../../lib":162,"./layout_attributes":219}],228:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56037,22 +57542,18 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); - module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { var tickmode; if(containerIn.tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; - } - else { - var tickmodeDefault = - Array.isArray(containerIn.tickvals) ? 'array' : + } else { + var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : containerIn.dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); @@ -56067,15 +57568,14 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe containerIn.dtick, axType); containerOut.tick0 = cleanTicks.tick0( containerIn.tick0, axType, containerOut.calendar, dtick); - } - else { + } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto'; else coerce('ticktext'); } }; -},{"./clean_ticks":213}],231:[function(_dereq_,module,exports){ +},{"./clean_ticks":211}],229:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56197,14 +57697,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo } function ticksAndAnnotations(xa, ya) { - var activeAxIds = [], - i; - - activeAxIds = [xa._id, ya._id]; + var activeAxIds = [xa._id, ya._id]; + var i; - for(i = 0; i < activeAxIds.length; i++) { - Axes.doTicksSingle(gd, activeAxIds[i], true); - } + Axes.drawOne(gd, xa, {skipTitle: true}); + Axes.drawOne(gd, ya, {skipTitle: true}); function redrawObjs(objArray, method, shortCircuit) { for(i = 0; i < objArray.length; i++) { @@ -56403,7 +57900,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo return Promise.resolve(); }; -},{"../../components/drawing":71,"../../registry":248,"./axes":208,"./constants":214,"d3":11}],232:[function(_dereq_,module,exports){ +},{"../../components/drawing":67,"../../registry":246,"./axes":206,"./constants":212,"d3":11}],230:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56414,7 +57911,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo 'use strict'; -var Registry = _dereq_('../../registry'); +var traceIs = _dereq_('../../registry').traceIs; var autoType = _dereq_('./axis_autotype'); /* @@ -56463,6 +57960,7 @@ function setAutoType(ax, data) { var calAttr = axLetter + 'calendar'; var calendar = d0[calAttr]; + var opts = {noMultiCategory: !traceIs(d0, 'cartesian') || traceIs(d0, 'noMultiCategory')}; var i; // check all boxes on this x axis to see @@ -56473,8 +57971,7 @@ function setAutoType(ax, data) { for(i = 0; i < data.length; i++) { var trace = data[i]; - if(!Registry.traceIs(trace, 'box-violin') || - (trace[axLetter + 'axis'] || axLetter) !== id) continue; + if(!traceIs(trace, 'box-violin') || (trace[axLetter + 'axis'] || axLetter) !== id) continue; if(trace[posLetter] !== undefined) boxPositions.push(trace[posLetter][0]); else if(trace.name !== undefined) boxPositions.push(trace.name); @@ -56483,7 +57980,7 @@ function setAutoType(ax, data) { if(trace[calAttr] !== calendar) calendar = undefined; } - ax.type = autoType(boxPositions, calendar); + ax.type = autoType(boxPositions, calendar, opts); } else if(d0.type === 'splom') { var dimensions = d0.dimensions; @@ -56491,13 +57988,13 @@ function setAutoType(ax, data) { for(i = 0; i < dimensions.length; i++) { var dim = dimensions[i]; if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) { - ax.type = autoType(dim.values, calendar); + ax.type = autoType(dim.values, calendar, opts); break; } } } else { - ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar); + ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -56528,9 +58025,9 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace), - isBox = Registry.traceIs(trace, 'box-violin'), - isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); + var posLetter = getBoxPosLetter(trace); + var isBox = traceIs(trace, 'box-violin'); + var isCandlestick = traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox && @@ -56541,7 +58038,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":248,"./axis_autotype":209}],233:[function(_dereq_,module,exports){ +},{"../../registry":246,"./axis_autotype":207}],231:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56965,7 +58462,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":164,"../registry":248}],234:[function(_dereq_,module,exports){ +},{"../lib":162,"../registry":246}],232:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57073,7 +58570,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { coerce('domain.y', dfltY); }; -},{"../lib/extend":158}],235:[function(_dereq_,module,exports){ +},{"../lib/extend":156}],233:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57138,7 +58635,7 @@ module.exports = function(opts) { return attrs; }; -},{}],236:[function(_dereq_,module,exports){ +},{}],234:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57184,7 +58681,7 @@ module.exports = { } }; -},{}],237:[function(_dereq_,module,exports){ +},{}],235:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57312,7 +58809,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":248,"./cartesian/constants":214}],238:[function(_dereq_,module,exports){ +},{"../registry":246,"./cartesian/constants":212}],236:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57346,7 +58843,7 @@ function project(camera, v) { module.exports = project; -},{}],239:[function(_dereq_,module,exports){ +},{}],237:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57359,6 +58856,9 @@ module.exports = project; var fontAttrs = _dereq_('./font_attributes'); var colorAttrs = _dereq_('../components/color/attributes'); +var colorscaleAttrs = _dereq_('../components/colorscale/layout_attributes'); +var padAttrs = _dereq_('./pad_attributes'); +var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', @@ -57371,15 +58871,71 @@ globalFont.color.dflt = colorAttrs.defaultLine; module.exports = { font: globalFont, title: { - valType: 'string', - - editType: 'layoutstyle', - + text: { + valType: 'string', + + editType: 'layoutstyle', + + }, + font: fontAttrs({ + editType: 'layoutstyle', + + }), + xref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + yref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + x: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.5, + + editType: 'layoutstyle', + + }, + y: { + valType: 'number', + min: 0, + max: 1, + dflt: 'auto', + + editType: 'layoutstyle', + + }, + xanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'left', 'center', 'right'], + + editType: 'layoutstyle', + + }, + yanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'top', 'middle', 'bottom'], + + editType: 'layoutstyle', + + }, + pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { + + }), + editType: 'layoutstyle' }, - titlefont: fontAttrs({ - editType: 'layoutstyle', - - }), autosize: { valType: 'boolean', @@ -57498,11 +59054,30 @@ module.exports = { editType: 'calc', }, + colorscale: colorscaleAttrs, datarevision: { valType: 'any', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editrevision: { + valType: 'any', + + editType: 'none', + + }, + selectionrevision: { + valType: 'any', + + editType: 'none', + }, template: { valType: 'any', @@ -57536,12 +59111,30 @@ module.exports = { editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'modebar' + }, + _deprecated: { + title: { + valType: 'string', + + editType: 'layoutstyle', + + }, + titlefont: fontAttrs({ + editType: 'layoutstyle', + + }) } }; -},{"../components/color/attributes":45,"./font_attributes":235}],240:[function(_dereq_,module,exports){ +},{"../components/color/attributes":45,"../components/colorscale/layout_attributes":59,"../lib/extend":156,"./font_attributes":233,"./pad_attributes":238}],238:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57552,42 +59145,51 @@ module.exports = { 'use strict'; -// This is used exclusively by components inside component arrays, -// hence the 'arraydraw' editType. If this ever gets used elsewhere -// we could generalize it as a function ala font_attributes -module.exports = { - t: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - r: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - b: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - l: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - editType: 'arraydraw' +/** + * Creates a set of padding attributes. + * + * @param {object} opts + * @param {string} editType: + * the editType for all pieces of this padding definition + * + * @return {object} attributes object containing {t, r, b, l} as specified + */ +module.exports = function(opts) { + var editType = opts.editType; + return { + t: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + r: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + b: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + l: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + editType: editType + }; }; -},{}],241:[function(_dereq_,module,exports){ +},{}],239:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58039,6 +59641,7 @@ plots.supplyDefaults = function(gd, opts) { for(i = 0; i < crossTraceDefaultsFuncs.length; i++) { crossTraceDefaultsFuncs[i](newFullData, newFullLayout); } + Registry.getComponentMethod('colorscale', 'crossTraceDefaults')(newFullData, newFullLayout); // turn on flag to optimize large splom-only graphs // mostly by omitting SVG layers during Cartesian.drawFramework @@ -58069,15 +59672,29 @@ plots.supplyDefaults = function(gd, opts) { // relink functions and _ attributes to promote consistency between plots relinkPrivateKeys(newFullLayout, oldFullLayout); - // TODO may return a promise - plots.doAutoMargin(gd); - - // set scale after auto margin routine - var axList = axisIDs.list(gd); - for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - ax.setScale(); + // For persisting GUI-driven changes in layout + // _preGUI and _tracePreGUI were already copied over in relinkPrivateKeys + if(!newFullLayout._preGUI) newFullLayout._preGUI = {}; + // track trace GUI changes by uid rather than by trace index + if(!newFullLayout._tracePreGUI) newFullLayout._tracePreGUI = {}; + var tracePreGUI = newFullLayout._tracePreGUI; + var uids = {}; + var uid; + for(uid in tracePreGUI) uids[uid] = 'old'; + for(i = 0; i < newFullData.length; i++) { + uid = newFullData[i]._fullInput.uid; + if(!uids[uid]) tracePreGUI[uid] = {}; + uids[uid] = 'new'; } + for(uid in uids) { + if(uids[uid] === 'old') delete tracePreGUI[uid]; + } + + // set up containers for margin calculations + initMargins(newFullLayout); + + // collect and do some initial calculations for rangesliders + Registry.getComponentMethod('rangeslider', 'makeData')(newFullLayout); // update object references in calcdata if(!skipUpdateCalc && oldCalcdata.length === newFullData.length) { @@ -58387,6 +60004,12 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa plotinfo.id = id; } + // add these axis ids to each others' subplot lists + xaxis._counterAxes.push(yaxis._id); + yaxis._counterAxes.push(xaxis._id); + xaxis._subplotsWith.push(id); + yaxis._subplotsWith.push(id); + // update x and y axis layout object refs plotinfo.xaxis = xaxis; plotinfo.yaxis = yaxis; @@ -58414,8 +60037,9 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // while we're at it, link overlaying axes to their main axes and // anchored axes to the axes they're anchored to var axList = axisIDs.list(mockGd, null, true); + var ax; for(i = 0; i < axList.length; i++) { - var ax = axList[i]; + ax = axList[i]; var mainAx = null; if(ax.overlaying) { @@ -58443,8 +60067,53 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa null : axisIDs.getFromId(mockGd, ax.anchor); } + + // finally, we can find the main subplot for each axis + // (on which the ticks & labels are drawn) + for(i = 0; i < axList.length; i++) { + ax = axList[i]; + ax._counterAxes.sort(axisIDs.idSort); + ax._subplotsWith.sort(Lib.subplotSort); + ax._mainSubplot = findMainSubplot(ax, newFullLayout); + } }; +function findMainSubplot(ax, fullLayout) { + var mockGd = {_fullLayout: fullLayout}; + + var isX = ax._id.charAt(0) === 'x'; + var anchorAx = ax._mainAxis._anchorAxis; + var mainSubplotID = ''; + var nextBestMainSubplotID = ''; + var anchorID = ''; + + // First try the main ID with the anchor + if(anchorAx) { + anchorID = anchorAx._mainAxis._id; + mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); + } + + // Then look for a subplot with the counteraxis overlaying the anchor + // If that fails just use the first subplot including this axis + if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { + mainSubplotID = ''; + + var counterIDs = ax._counterAxes; + for(var j = 0; j < counterIDs.length; j++) { + var counterPart = counterIDs[j]; + var id = isX ? (ax._id + counterPart) : (counterPart + ax._id); + if(!nextBestMainSubplotID) nextBestMainSubplotID = id; + var counterAx = axisIDs.getFromId(mockGd, counterPart); + if(anchorID && counterAx.overlaying === anchorID) { + mainSubplotID = id; + break; + } + } + } + + return mainSubplotID || nextBestMainSubplotID; +} + // This function clears any trace attributes with valType: color and // no set dflt filed in the plot schema. This is needed because groupby (which // is the only transform for which this currently applies) supplies parent @@ -58712,6 +60381,8 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac coerce('type'); coerce('name', layout._traceWord + ' ' + traceInIndex); + coerce('uirevision', layout.uirevision); + // we want even invisible traces to make their would-be subplots visible // so coerce the subplot id(s) now no matter what var _module = plots.getModule(traceOut); @@ -58785,7 +60456,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac if(_module) { _module.supplyDefaults(traceIn, traceOut, defaultColor, layout); - Lib.coerceHoverinfo(traceIn, traceOut, layout); + if(!traceOut.hovertemplate) Lib.coerceHoverinfo(traceIn, traceOut, layout); } if(!Registry.traceIs(traceOut, 'noOpacity')) coerce('opacity'); @@ -58914,14 +60585,25 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { var globalFont = Lib.coerceFont(coerce, 'font'); - coerce('title', layoutOut._dfltTitle.plot); + coerce('title.text', layoutOut._dfltTitle.plot); - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: globalFont.family, size: Math.round(globalFont.size * 1.4), color: globalFont.color }); + coerce('title.xref'); + coerce('title.yref'); + coerce('title.x'); + coerce('title.y'); + coerce('title.xanchor'); + coerce('title.yanchor'); + coerce('title.pad.t'); + coerce('title.pad.r'); + coerce('title.pad.b'); + coerce('title.pad.l'); + // Make sure that autosize is defaulted to *true* // on layouts with no set width and height for backward compatibly, // in particular https://plot.ly/javascript/responsive-fluid-layout/ @@ -58954,12 +60636,16 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('colorway'); coerce('datarevision'); + var uirevision = coerce('uirevision'); + coerce('editrevision', uirevision); + coerce('selectionrevision', uirevision); coerce('modebar.orientation'); coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); + coerce('modebar.uirevision', uirevision); Registry.getComponentMethod( 'calendars', @@ -59241,7 +60927,20 @@ plots.allowAutoMargin = function(gd, id) { gd._fullLayout._pushmarginIds[id] = 1; }; -function setupAutoMargin(fullLayout) { +function initMargins(fullLayout) { + var margin = fullLayout.margin; + + if(!fullLayout._size) { + var gs = fullLayout._size = { + l: Math.round(margin.l), + r: Math.round(margin.r), + t: Math.round(margin.t), + b: Math.round(margin.b), + p: Math.round(margin.pad) + }; + gs.w = Math.round(fullLayout.width) - gs.l - gs.r; + gs.h = Math.round(fullLayout.height) - gs.t - gs.b; + } if(!fullLayout._pushmargin) fullLayout._pushmargin = {}; if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {}; } @@ -59264,8 +60963,6 @@ function setupAutoMargin(fullLayout) { plots.autoMargin = function(gd, id, o) { var fullLayout = gd._fullLayout; - setupAutoMargin(fullLayout); - var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -59309,18 +61006,19 @@ plots.autoMargin = function(gd, id, o) { plots.doAutoMargin = function(gd) { var fullLayout = gd._fullLayout; if(!fullLayout._size) fullLayout._size = {}; - setupAutoMargin(fullLayout); + initMargins(fullLayout); - var gs = fullLayout._size, - oldmargins = JSON.stringify(gs); + var gs = fullLayout._size; + var oldmargins = JSON.stringify(gs); + var margin = fullLayout.margin; // adjust margins for outside components // fullLayout.margin is the requested margin, // fullLayout._size has margins and plotsize after adjustment - var ml = Math.max(fullLayout.margin.l || 0, 0); - var mr = Math.max(fullLayout.margin.r || 0, 0); - var mt = Math.max(fullLayout.margin.t || 0, 0); - var mb = Math.max(fullLayout.margin.b || 0, 0); + var ml = margin.l; + var mr = margin.r; + var mt = margin.t; + var mb = margin.b; var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -59390,7 +61088,7 @@ plots.doAutoMargin = function(gd) { gs.r = Math.round(mr); gs.t = Math.round(mt); gs.b = Math.round(mb); - gs.p = Math.round(fullLayout.margin.pad); + gs.p = Math.round(margin.pad); gs.w = Math.round(fullLayout.width) - gs.l - gs.r; gs.h = Math.round(fullLayout.height) - gs.t - gs.b; @@ -60271,7 +61969,7 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl subplot.traceHash = traceHash; }; -},{"../components/color":46,"../constants/numerical":146,"../lib":164,"../plot_api/plot_schema":197,"../plot_api/plot_template":198,"../plots/cartesian/axis_ids":211,"../registry":248,"./animation_attributes":203,"./attributes":205,"./command":233,"./font_attributes":235,"./frame_attributes":236,"./layout_attributes":239,"d3":11,"fast-isnumeric":13}],242:[function(_dereq_,module,exports){ +},{"../components/color":46,"../constants/numerical":143,"../lib":162,"../plot_api/plot_schema":195,"../plot_api/plot_template":196,"../plots/cartesian/axis_ids":209,"../registry":246,"./animation_attributes":201,"./attributes":203,"./command":231,"./font_attributes":233,"./frame_attributes":234,"./layout_attributes":237,"d3":11,"fast-isnumeric":13}],240:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60315,7 +62013,7 @@ module.exports = { } }; -},{"../../../lib/extend":158,"../../../traces/scatter/attributes":316}],243:[function(_dereq_,module,exports){ +},{"../../../lib/extend":156,"../../../traces/scatter/attributes":316}],241:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60437,7 +62135,7 @@ module.exports = overrideAll({ } }, 'plot', 'nested'); -},{"../../../lib/extend":158,"../../../plot_api/edit_types":191,"../../cartesian/layout_attributes":221}],244:[function(_dereq_,module,exports){ +},{"../../../lib/extend":156,"../../../plot_api/edit_types":189,"../../cartesian/layout_attributes":219}],242:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60452,7 +62150,7 @@ var Polar = module.exports = _dereq_('./micropolar'); Polar.manager = _dereq_('./micropolar_manager'); -},{"./micropolar":245,"./micropolar_manager":246}],245:[function(_dereq_,module,exports){ +},{"./micropolar":243,"./micropolar_manager":244}],243:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60670,8 +62368,8 @@ var µ = module.exports = { version: '0.2.2' }; centeringOffset[0] = Math.max(0, centeringOffset[0]); centeringOffset[1] = Math.max(0, centeringOffset[1]); svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title); + if (axisConfig.title && axisConfig.title.text) { + var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); var titleBBox = title.node().getBBox(); title.attr({ x: chartCenter[0] - titleBBox.width / 2, @@ -61872,7 +63570,7 @@ var µ = module.exports = { version: '0.2.2' }; return exports; }; -},{"../../../constants/alignment":144,"../../../lib":164,"d3":11}],246:[function(_dereq_,module,exports){ +},{"../../../constants/alignment":141,"../../../lib":162,"d3":11}],244:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61958,7 +63656,7 @@ manager.fillLayout = function(_gd) { _gd._fullLayout = extendDeepAll(dflts, _gd.layout); }; -},{"../../../components/color":46,"../../../lib":164,"./micropolar":245,"./undo_manager":247,"d3":11}],247:[function(_dereq_,module,exports){ +},{"../../../components/color":46,"../../../lib":162,"./micropolar":243,"./undo_manager":245,"d3":11}],245:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62024,7 +63722,7 @@ module.exports = function UndoManager() { }; }; -},{}],248:[function(_dereq_,module,exports){ +},{}],246:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62466,7 +64164,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/extend":158,"./lib/is_plain_object":165,"./lib/loggers":168,"./lib/noop":173,"./lib/push_unique":177,"./plots/attributes":205,"./plots/layout_attributes":239}],249:[function(_dereq_,module,exports){ +},{"./lib/extend":156,"./lib/is_plain_object":163,"./lib/loggers":166,"./lib/noop":171,"./lib/push_unique":175,"./plots/attributes":203,"./plots/layout_attributes":237}],247:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62493,7 +64191,7 @@ function cloneLayoutOverride(tileClass) { autosize: true, width: 150, height: 150, - title: '', + title: {text: ''}, showlegend: false, margin: {l: 5, r: 5, t: 5, b: 5, pad: 0}, annotations: [] @@ -62502,7 +64200,7 @@ function cloneLayoutOverride(tileClass) { case 'thumbnail': override = { - title: '', + title: {text: ''}, hidesources: true, showlegend: false, borderwidth: 0, @@ -62550,7 +64248,7 @@ module.exports = function clonePlot(graphObj, options) { for(i = 0; i < keys.length; i++) { if(keyIsAxis(keys[i])) { - newLayout[keys[i]].title = ''; + newLayout[keys[i]].title = {text: ''}; } } @@ -62578,7 +64276,7 @@ module.exports = function clonePlot(graphObj, options) { var axesImageOverride = {}; if(options.tileClass === 'thumbnail') { axesImageOverride = { - title: '', + title: {text: ''}, showaxeslabels: false, showticklabels: false, linetickenable: false @@ -62640,7 +64338,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":164}],250:[function(_dereq_,module,exports){ +},{"../lib":162}],248:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62708,7 +64406,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":164,"../plot_api/to_image":201,"./filesaver":251}],251:[function(_dereq_,module,exports){ +},{"../lib":162,"../plot_api/to_image":199,"./filesaver":249}],249:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62780,7 +64478,7 @@ var fileSaver = function(url, name) { module.exports = fileSaver; -},{}],252:[function(_dereq_,module,exports){ +},{}],250:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62817,7 +64515,7 @@ exports.getRedrawFunc = function(gd) { }; }; -},{}],253:[function(_dereq_,module,exports){ +},{}],251:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62843,7 +64541,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":249,"./download":250,"./helpers":252,"./svgtoimg":254,"./toimage":255,"./tosvg":256}],254:[function(_dereq_,module,exports){ +},{"./cloneplot":247,"./download":248,"./helpers":250,"./svgtoimg":252,"./toimage":253,"./tosvg":254}],252:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62959,7 +64657,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":164,"events":10}],255:[function(_dereq_,module,exports){ +},{"../lib":162,"events":10}],253:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63038,7 +64736,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":164,"../registry":248,"./cloneplot":249,"./helpers":252,"./svgtoimg":254,"./tosvg":256,"events":10}],256:[function(_dereq_,module,exports){ +},{"../lib":162,"../registry":246,"./cloneplot":247,"./helpers":250,"./svgtoimg":252,"./tosvg":254,"events":10}],254:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63220,7 +64918,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":46,"../components/drawing":71,"../constants/xmlns_namespaces":147,"../lib":164,"d3":11}],257:[function(_dereq_,module,exports){ +},{"../components/color":46,"../components/drawing":67,"../constants/xmlns_namespaces":144,"../lib":162,"d3":11}],255:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63255,7 +64953,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":164}],258:[function(_dereq_,module,exports){ +},{"../../lib":162}],256:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63267,9 +64965,11 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); +var constants = _dereq_('./constants.js'); var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -63318,6 +65018,9 @@ module.exports = { text: scatterAttrs.text, hovertext: scatterAttrs.hovertext, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), textposition: { valType: 'enumerated', @@ -63425,7 +65128,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":47,"../../components/colorscale/attributes":53,"../../lib/extend":158,"../../plots/font_attributes":235,"../scatter/attributes":316}],259:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":47,"../../components/colorscale/attributes":53,"../../components/fx/hovertemplate_attributes":84,"../../lib/extend":156,"../../plots/font_attributes":233,"../scatter/attributes":316,"./constants.js":258}],257:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63437,7 +65140,7 @@ module.exports = { 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var arraysToCalcdata = _dereq_('./arrays_to_calcdata'); var calcSelection = _dereq_('../scatter/calc_selection'); @@ -63470,10 +65173,18 @@ module.exports = function calc(gd, trace) { // auto-z and autocolorscale if applicable if(hasColorscale(trace, 'marker')) { - colorscaleCalc(trace, trace.marker.color, 'marker', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - colorscaleCalc(trace, trace.marker.line.color, 'marker.line', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } arraysToCalcdata(cd, trace); @@ -63482,7 +65193,23 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../../components/colorscale/calc":54,"../../components/colorscale/has_colorscale":60,"../../plots/cartesian/axes":208,"../scatter/calc_selection":318,"./arrays_to_calcdata":257}],260:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":54,"../../components/colorscale/helpers":57,"../../plots/cartesian/axes":206,"../scatter/calc_selection":318,"./arrays_to_calcdata":255}],258:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + eventDataKeys: [] +}; + +},{}],259:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63611,9 +65338,14 @@ function initBase(gd, pa, sa, calcTraces) { // time. But included here for completeness. var scalendar = trace.orientation === 'h' ? trace.xcalendar : trace.ycalendar; + // 'base' on categorical axes makes no sense + var d2c = sa.type === 'category' || sa.type === 'multicategory' ? + function() { return null; } : + sa.d2c; + if(isArrayOrTypedArray(base)) { for(j = 0; j < Math.min(base.length, cd.length); j++) { - b = sa.d2c(base[j], 0, scalendar); + b = d2c(base[j], 0, scalendar); if(isNumeric(b)) { cd[j].b = +b; cd[j].hasB = 1; @@ -63624,7 +65356,7 @@ function initBase(gd, pa, sa, calcTraces) { cd[j].b = 0; } } else { - b = sa.d2c(base, 0, scalendar); + b = d2c(base, 0, scalendar); var hasBase = isNumeric(b); b = hasBase ? b : 0; for(j = 0; j < cd.length; j++) { @@ -64203,7 +65935,7 @@ module.exports = { setGroupPositions: setGroupPositions }; -},{"../../constants/numerical":146,"../../lib":164,"../../plots/cartesian/axes":208,"../../registry":248,"./sieve.js":269,"fast-isnumeric":13}],261:[function(_dereq_,module,exports){ +},{"../../constants/numerical":143,"../../lib":162,"../../plots/cartesian/axes":206,"../../registry":246,"./sieve.js":268,"fast-isnumeric":13}],260:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64243,6 +65975,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); + coerce('hovertemplate'); var textPosition = coerce('textposition'); @@ -64283,7 +66016,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/color":46,"../../lib":164,"../../registry":248,"../bar/style_defaults":271,"../scatter/xy_defaults":342,"./attributes":258}],262:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../lib":162,"../../registry":246,"../bar/style_defaults":270,"../scatter/xy_defaults":342,"./attributes":256}],261:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64352,7 +66085,7 @@ exports.getValue = function(arrayOrScalar, index) { return value; }; -},{"fast-isnumeric":13,"tinycolor2":29}],263:[function(_dereq_,module,exports){ +},{"fast-isnumeric":13,"tinycolor2":29}],262:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64492,6 +66225,7 @@ function hoverPoints(pointData, xval, yval, hovermode) { fillHoverText(di, trace, pointData); Registry.getComponentMethod('errorbars', 'hoverInfo')(di, trace, pointData); + pointData.hovertemplate = trace.hovertemplate; return [pointData]; } @@ -64509,7 +66243,7 @@ module.exports = { getTraceColor: getTraceColor }; -},{"../../components/color":46,"../../components/fx":88,"../../registry":248,"../scatter/fill_hover_text":324}],264:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/fx":85,"../../registry":246,"../scatter/fill_hover_text":324}],263:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64547,7 +66281,7 @@ Bar.meta = { module.exports = Bar; -},{"../../plots/cartesian":220,"../scatter/marker_colorbar":334,"./arrays_to_calcdata":257,"./attributes":258,"./calc":259,"./cross_trace_calc":260,"./defaults":261,"./hover":263,"./layout_attributes":265,"./layout_defaults":266,"./plot":267,"./select":268,"./style":270}],265:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":218,"../scatter/marker_colorbar":334,"./arrays_to_calcdata":255,"./attributes":256,"./calc":257,"./cross_trace_calc":259,"./defaults":260,"./hover":262,"./layout_attributes":264,"./layout_defaults":265,"./plot":266,"./select":267,"./style":269}],264:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64595,7 +66329,7 @@ module.exports = { } }; -},{}],266:[function(_dereq_,module,exports){ +},{}],265:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64653,7 +66387,7 @@ module.exports = function(layoutIn, layoutOut, fullData) { coerce('bargroupgap'); }; -},{"../../lib":164,"../../plots/cartesian/axes":208,"../../registry":248,"./layout_attributes":265}],267:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/cartesian/axes":206,"../../registry":246,"./layout_attributes":264}],266:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64780,7 +66514,7 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { .style('vector-effect', 'non-scaling-stroke') .attr('d', 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z') - .call(Drawing.setClipUrl, plotinfo.layerClipId); + .call(Drawing.setClipUrl, plotinfo.layerClipId, gd); appendBarText(gd, bar, cd, i, x0, x1, y0, y1); @@ -64792,11 +66526,11 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { // lastly, clip points groups of `cliponaxis !== false` traces // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = cd0.trace.cliponaxis === false; - Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId); + Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId, gd); }); // error bars are on the top - Registry.getComponentMethod('errorbars', 'plot')(bartraces, plotinfo); + Registry.getComponentMethod('errorbars', 'plot')(gd, bartraces, plotinfo); }; function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) { @@ -65093,7 +66827,7 @@ function getTextPosition(trace, index) { return helpers.coerceEnumerated(attributeTextPosition, value); } -},{"../../components/color":46,"../../components/drawing":71,"../../lib":164,"../../lib/svg_text_utils":185,"../../registry":248,"./attributes":258,"./helpers":262,"./style":270,"d3":11,"fast-isnumeric":13}],268:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/drawing":67,"../../lib":162,"../../lib/svg_text_utils":183,"../../registry":246,"./attributes":256,"./helpers":261,"./style":269,"d3":11,"fast-isnumeric":13}],267:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65136,7 +66870,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],269:[function(_dereq_,module,exports){ +},{}],268:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65245,7 +66979,7 @@ Sieve.prototype.getLabel = function getLabel(position, value) { return prefix + label; }; -},{"../../constants/numerical":146,"../../lib":164}],270:[function(_dereq_,module,exports){ +},{"../../constants/numerical":143,"../../lib":162}],269:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65419,7 +67153,7 @@ module.exports = { getBarColor: getBarColor }; -},{"../../components/color":46,"../../components/drawing":71,"../../lib":164,"../../registry":248,"./attributes":258,"./helpers":262,"d3":11}],271:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/drawing":67,"../../lib":162,"../../registry":246,"./attributes":256,"./helpers":261,"d3":11}],270:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65428,11 +67162,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout) { @@ -65458,7 +67191,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, default coerce('unselected.marker.color'); }; -},{"../../components/color":46,"../../components/colorscale/defaults":56,"../../components/colorscale/has_colorscale":60}],272:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/colorscale/defaults":56,"../../components/colorscale/helpers":57}],271:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65650,7 +67383,7 @@ module.exports = { } }; -},{"../../components/color/attributes":45,"../../lib/extend":158,"../scatter/attributes":316}],273:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":45,"../../lib/extend":156,"../scatter/attributes":316}],272:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65766,7 +67499,7 @@ module.exports = { setPositionOffset: setPositionOffset }; -},{"../../lib":164,"../../plots/cartesian/axes":208}],274:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/cartesian/axes":206}],273:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65807,7 +67540,7 @@ module.exports = { } }; -},{}],275:[function(_dereq_,module,exports){ +},{}],274:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65850,7 +67583,7 @@ module.exports = { _supply: _supply }; -},{"../../lib":164,"../../registry":248,"./layout_attributes":274}],276:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../registry":246,"./layout_attributes":273}],275:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66190,7 +67923,7 @@ module.exports = { plotBoxMean: plotBoxMean }; -},{"../../components/drawing":71,"../../lib":164,"d3":11}],277:[function(_dereq_,module,exports){ +},{"../../components/drawing":67,"../../lib":162,"d3":11}],276:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66264,7 +67997,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/color":46,"../../components/drawing":71,"d3":11}],278:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/drawing":67,"d3":11}],277:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66317,7 +68050,7 @@ module.exports = { hoverlabel: OHLCattrs.hoverlabel, }; -},{"../../lib":164,"../box/attributes":272,"../ohlc/attributes":294}],279:[function(_dereq_,module,exports){ +},{"../../lib":162,"../box/attributes":271,"../ohlc/attributes":294}],278:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66367,7 +68100,7 @@ function ptFunc(o, h, l, c) { }; } -},{"../../lib":164,"../../plots/cartesian/axes":208,"../ohlc/calc":295}],280:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/cartesian/axes":206,"../ohlc/calc":295}],279:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66412,7 +68145,7 @@ function handleDirection(traceIn, traceOut, coerce, direction) { coerce(direction + '.fillcolor', Color.addOpacity(lineColor, 0.5)); } -},{"../../components/color":46,"../../lib":164,"../ohlc/ohlc_defaults":299,"./attributes":278}],281:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../lib":162,"../ohlc/ohlc_defaults":299,"./attributes":277}],280:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66445,7 +68178,7 @@ module.exports = { selectPoints: _dereq_('../ohlc/select') }; -},{"../../plots/cartesian":220,"../box/cross_trace_calc":273,"../box/layout_attributes":274,"../box/layout_defaults":275,"../box/plot":276,"../box/style":277,"../ohlc/hover":297,"../ohlc/select":301,"./attributes":278,"./calc":279,"./defaults":280}],282:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":218,"../box/cross_trace_calc":272,"../box/layout_attributes":273,"../box/layout_defaults":274,"../box/plot":275,"../box/style":276,"../ohlc/hover":297,"../ohlc/select":301,"./attributes":277,"./calc":278,"./defaults":279}],281:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66457,7 +68190,9 @@ module.exports = { 'use strict'; var barAttrs = _dereq_('../bar/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var makeBinAttrs = _dereq_('./bin_attributes'); +var constants = _dereq_('./constants'); module.exports = { x: { @@ -66550,14 +68285,13 @@ module.exports = { dflt: null, editType: 'calc', - impliedEdits: { - 'ybins.start': undefined, - 'ybins.end': undefined, - 'ybins.size': undefined - }, }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), + marker: barAttrs.marker, selected: barAttrs.selected, @@ -66568,7 +68302,7 @@ module.exports = { } }; -},{"../bar/attributes":258,"./bin_attributes":284}],283:[function(_dereq_,module,exports){ +},{"../../components/fx/hovertemplate_attributes":84,"../bar/attributes":256,"./bin_attributes":283,"./constants":287}],282:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66594,7 +68328,7 @@ module.exports = function doAvg(size, counts) { return total; }; -},{}],284:[function(_dereq_,module,exports){ +},{}],283:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66629,7 +68363,7 @@ module.exports = function makeBinAttrs(axLetter, match) { }; }; -},{}],285:[function(_dereq_,module,exports){ +},{}],284:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66705,7 +68439,7 @@ module.exports = { } }; -},{"fast-isnumeric":13}],286:[function(_dereq_,module,exports){ +},{"fast-isnumeric":13}],285:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66883,7 +68617,7 @@ function dateParts(v, pa, calendar) { return parts; } -},{"../../constants/numerical":146,"../../plots/cartesian/axes":208}],287:[function(_dereq_,module,exports){ +},{"../../constants/numerical":143,"../../plots/cartesian/axes":206}],286:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67137,16 +68871,18 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { var isFirstVisible = true; for(i = 0; i < traces.length; i++) { tracei = traces[i]; - pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData); - allPos = Lib.concat(allPos, pos0); - delete tracei._autoBinFinished; - if(trace.visible === true) { - if(isFirstVisible) { - isFirstVisible = false; - } - else { - delete tracei._autoBin; - tracei._autoBinFinished = 1; + if(tracei.visible) { + pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData); + allPos = Lib.concat(allPos, pos0); + delete tracei._autoBinFinished; + if(trace.visible === true) { + if(isFirstVisible) { + isFirstVisible = false; + } + else { + delete tracei._autoBin; + tracei._autoBinFinished = 1; + } } } } @@ -67156,7 +68892,8 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { // Edge case: single-valued histogram overlaying others // Use them all together to calculate the bin size for the single-valued one - if(isOverlay && newBinSpec._dataSpan === 0 && pa.type !== 'category') { + if(isOverlay && newBinSpec._dataSpan === 0 && + pa.type !== 'category' && pa.type !== 'multicategory') { // Several single-valued histograms! Stop infinite recursion, // just return an extra flag that tells handleSingleValueOverlays // to sort out this trace too @@ -67213,7 +68950,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { Lib.aggNums(Math.min, null, pos0); var dummyAx = { - type: pa.type === 'category' ? 'linear' : pa.type, + type: (pa.type === 'category' || pa.type === 'multicategory') ? 'linear' : pa.type, r2l: pa.r2l, dtick: binOpts.size, tick0: mainStart, @@ -67413,7 +69150,23 @@ function cdf(size, direction, currentBin) { } } -},{"../../lib":164,"../../plots/cartesian/axes":208,"../bar/arrays_to_calcdata":257,"./average":283,"./bin_functions":285,"./bin_label_vals":286,"./norm_functions":293,"fast-isnumeric":13}],288:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/cartesian/axes":206,"../bar/arrays_to_calcdata":255,"./average":282,"./bin_functions":284,"./bin_label_vals":285,"./norm_functions":293,"fast-isnumeric":13}],287:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + eventDataKeys: ['binNumber'] +}; + +},{}],288:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67527,7 +69280,7 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) { } }; -},{"../../lib":164,"./attributes":282}],289:[function(_dereq_,module,exports){ +},{"../../lib":162,"./attributes":281}],289:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67566,7 +69319,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var sampleLetter = orientation === 'v' ? 'x' : 'y'; var aggLetter = orientation === 'v' ? 'y' : 'x'; - var len = (x && y) ? Math.min(x.length && y.length) : (traceOut[sampleLetter] || []).length; + var len = (x && y) ? + Math.min(Lib.minRowLength(x) && Lib.minRowLength(y)) : + Lib.minRowLength(traceOut[sampleLetter] || []); if(!len) { traceOut.visible = false; @@ -67586,6 +69341,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout // autobin(x|y) are only included here to appease Plotly.validate coerce('autobin' + sampleLetter); + coerce('hovertemplate'); + handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout); // override defaultColor for error bars with defaultLine @@ -67596,7 +69353,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/color":46,"../../lib":164,"../../registry":248,"../bar/style_defaults":271,"./attributes":282}],290:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../lib":162,"../../registry":246,"../bar/style_defaults":270,"./attributes":281}],290:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67672,10 +69429,12 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { pointData[posLetter + 'Label'] = hoverLabelText(pointData[posLetter + 'a'], di.ph0, di.ph1); } + if(trace.hovermplate) pointData.hovertemplate = trace.hovertemplate; + return pts; }; -},{"../../plots/cartesian/axes":208,"../bar/hover":263}],292:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":206,"../bar/hover":262}],292:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67729,7 +69488,7 @@ Histogram.meta = { module.exports = Histogram; -},{"../../plots/cartesian":220,"../bar/cross_trace_calc":260,"../bar/layout_attributes":265,"../bar/layout_defaults":266,"../bar/plot":267,"../bar/select":268,"../bar/style":270,"../scatter/marker_colorbar":334,"./attributes":282,"./calc":287,"./cross_trace_defaults":288,"./defaults":289,"./event_data":290,"./hover":291}],293:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":218,"../bar/cross_trace_calc":259,"../bar/layout_attributes":264,"../bar/layout_defaults":265,"../bar/plot":266,"../bar/select":267,"../bar/style":269,"../scatter/marker_colorbar":334,"./attributes":281,"./calc":286,"./cross_trace_defaults":288,"./defaults":289,"./event_data":290,"./hover":291}],293:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67874,7 +69633,7 @@ module.exports = { }), }; -},{"../../components/drawing/attributes":70,"../../components/fx/attributes":80,"../../lib":164,"../scatter/attributes":316}],295:[function(_dereq_,module,exports){ +},{"../../components/drawing/attributes":66,"../../components/fx/attributes":76,"../../lib":162,"../scatter/attributes":316}],295:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67969,7 +69728,7 @@ function calcCommon(gd, trace, x, ya, ptFunc) { } } - trace._extremes[ya._id] = Axes.findExtremes(ya, l.concat(h), {padded: true}); + trace._extremes[ya._id] = Axes.findExtremes(ya, Lib.concat(l, h), {padded: true}); if(cd.length) { cd[0].t = { @@ -68039,7 +69798,7 @@ module.exports = { calcCommon: calcCommon }; -},{"../../constants/numerical":146,"../../lib":164,"../../plots/cartesian/axes":208}],296:[function(_dereq_,module,exports){ +},{"../../constants/numerical":143,"../../lib":162,"../../plots/cartesian/axes":206}],296:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68084,7 +69843,7 @@ function handleDirection(traceIn, traceOut, coerce, direction) { coerce(direction + '.line.dash', traceOut.line.dash); } -},{"../../lib":164,"./attributes":294,"./ohlc_defaults":299}],297:[function(_dereq_,module,exports){ +},{"../../lib":162,"./attributes":294,"./ohlc_defaults":299}],297:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68286,7 +70045,7 @@ module.exports = { hoverOnPoints: hoverOnPoints }; -},{"../../components/color":46,"../../components/fx":88,"../../lib":164,"../../plots/cartesian/axes":208,"../scatter/fill_hover_text":324}],298:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/fx":85,"../../lib":162,"../../plots/cartesian/axes":206,"../scatter/fill_hover_text":324}],298:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68315,7 +70074,7 @@ module.exports = { selectPoints: _dereq_('./select') }; -},{"../../plots/cartesian":220,"./attributes":294,"./calc":295,"./defaults":296,"./hover":297,"./plot":300,"./select":301,"./style":302}],299:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":218,"./attributes":294,"./calc":295,"./defaults":296,"./hover":297,"./plot":300,"./select":301,"./style":302}],299:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68324,11 +70083,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Registry = _dereq_('../../registry'); - +var Lib = _dereq_('../../lib'); module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) { var x = coerce('x'); @@ -68345,15 +70103,13 @@ module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) { if(!(open && high && low && close)) return; var len = Math.min(open.length, high.length, low.length, close.length); - - if(x) len = Math.min(len, x.length); - + if(x) len = Math.min(len, Lib.minRowLength(x)); traceOut._length = len; return len; }; -},{"../../registry":248}],300:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../registry":246}],300:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68409,7 +70165,7 @@ module.exports = function plot(gd, plotinfo, cdOHLC, ohlcLayer) { }); }; -},{"../../lib":164,"d3":11}],301:[function(_dereq_,module,exports){ +},{"../../lib":162,"d3":11}],301:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68491,7 +70247,7 @@ module.exports = function style(gd, cd) { }); }; -},{"../../components/color":46,"../../components/drawing":71,"d3":11}],303:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/drawing":67,"d3":11}],303:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68505,6 +70261,7 @@ module.exports = function style(gd, cd) { var colorAttrs = _dereq_('../../components/color/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); var plotAttrs = _dereq_('../../plots/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var domainAttrs = _dereq_('../../plots/domain').attributes; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -68612,6 +70369,9 @@ module.exports = { hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { flags: ['label', 'text', 'value', 'percent', 'name'] }), + hovertemplate: hovertemplateAttrs({}, { + keys: ['label', 'color', 'value', 'percent', 'text'] + }), textposition: { valType: 'enumerated', @@ -68632,26 +70392,30 @@ module.exports = { }), title: { - valType: 'string', - dflt: '', - - editType: 'calc', - - }, - titleposition: { - valType: 'enumerated', - values: [ - 'top left', 'top center', 'top right', - 'middle center', - 'bottom left', 'bottom center', 'bottom right' - ], - - editType: 'calc', - + text: { + valType: 'string', + dflt: '', + + editType: 'calc', + + }, + font: extendFlat({}, textFontAttrs, { + + }), + position: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + + editType: 'calc', + + }, + + editType: 'calc' }, - titlefont: extendFlat({}, textFontAttrs, { - - }), // position and shape domain: domainAttrs({name: 'pie', trace: true, editType: 'calc'}), @@ -68708,10 +70472,34 @@ module.exports = { arrayOk: true, editType: 'calc', + }, + + _deprecated: { + title: { + valType: 'string', + dflt: '', + + editType: 'calc', + + }, + titlefont: extendFlat({}, textFontAttrs, { + + }), + titleposition: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + + editType: 'calc', + + } } }; -},{"../../components/color/attributes":45,"../../lib/extend":158,"../../plots/attributes":205,"../../plots/domain":234,"../../plots/font_attributes":235}],304:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":45,"../../components/fx/hovertemplate_attributes":84,"../../lib/extend":156,"../../plots/attributes":203,"../../plots/domain":232,"../../plots/font_attributes":233}],304:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68743,7 +70531,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../plots/get_data":237,"../../registry":248}],305:[function(_dereq_,module,exports){ +},{"../../plots/get_data":235,"../../registry":246}],305:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68934,7 +70722,7 @@ function generateExtendedColors(colorList) { return pieColors; } -},{"../../components/color":46,"../../lib":164,"./helpers":308,"fast-isnumeric":13,"tinycolor2":29}],306:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../lib":162,"./helpers":308,"fast-isnumeric":13,"tinycolor2":29}],306:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68988,6 +70776,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var textData = coerce('text'); var textInfo = coerce('textinfo', Array.isArray(textData) ? 'text+percent' : 'percent'); coerce('hovertext'); + coerce('hovertemplate'); if(textInfo && textInfo !== 'none') { var textPosition = coerce('textposition'), @@ -69013,11 +70802,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleDomainDefaults(traceOut, layout, coerce); var hole = coerce('hole'); - var title = coerce('title'); + var title = coerce('title.text'); if(title) { - var titlePosition = coerce('titleposition', hole ? 'middle center' : 'top center'); - if(!hole && titlePosition === 'middle center') traceOut.titleposition = 'top center'; - coerceFont(coerce, 'titlefont', layout.font); + var titlePosition = coerce('title.position', hole ? 'middle center' : 'top center'); + if(!hole && titlePosition === 'middle center') traceOut.title.position = 'top center'; + coerceFont(coerce, 'title.font', layout.font); } coerce('sort'); @@ -69027,7 +70816,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('pull'); }; -},{"../../lib":164,"../../plots/domain":234,"./attributes":303}],307:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../plots/domain":232,"./attributes":303}],307:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69054,6 +70843,8 @@ module.exports = function eventData(pt, trace) { label: pt.label, color: pt.color, value: pt.v, + percent: pt.percent, + text: pt.text, // pt.v (and pt.i below) for backward compatibility v: pt.v @@ -69070,7 +70861,7 @@ module.exports = function eventData(pt, trace) { return out; }; -},{"../../components/fx/helpers":85}],308:[function(_dereq_,module,exports){ +},{"../../components/fx/helpers":81}],308:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69112,7 +70903,7 @@ exports.castOption = function castOption(item, indices) { else if(item) return item; }; -},{"../../lib":164}],309:[function(_dereq_,module,exports){ +},{"../../lib":162}],309:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69208,7 +70999,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { coerce('extendpiecolors'); }; -},{"../../lib":164,"./layout_attributes":310}],312:[function(_dereq_,module,exports){ +},{"../../lib":162,"./layout_attributes":310}],312:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69310,20 +71101,25 @@ module.exports = function plot(gd, cdpie) { // in case we dragged over the pie from another subplot, // or if hover is turned off - if(hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo) { + if(trace2.hovertemplate || (hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo)) { var rInscribed = getInscribedRadiusFraction(pt, cd0); var hoverCenterX = cx + pt.pxmid[0] * (1 - rInscribed); var hoverCenterY = cy + pt.pxmid[1] * (1 - rInscribed); var separators = fullLayout.separators; var thisText = []; - if(hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); - if(hoverinfo.indexOf('text') !== -1) { - var texti = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); + pt.text = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('text') !== -1) { + var texti = pt.text; if(texti) thisText.push(texti); } - if(hoverinfo.indexOf('value') !== -1) thisText.push(helpers.formatPieValue(pt.v, separators)); - if(hoverinfo.indexOf('percent') !== -1) thisText.push(helpers.formatPiePercent(pt.v / cd0.vTotal, separators)); + pt.value = pt.v; + pt.valueLabel = helpers.formatPieValue(pt.v, separators); + if(hoverinfo && hoverinfo.indexOf('value') !== -1) thisText.push(pt.valueLabel); + pt.percent = pt.v / cd0.vTotal; + pt.percentLabel = helpers.formatPiePercent(pt.percent, separators); + if(hoverinfo && hoverinfo.indexOf('percent') !== -1) thisText.push(pt.percentLabel); var hoverLabel = trace.hoverlabel; var hoverFont = hoverLabel.font; @@ -69333,13 +71129,18 @@ module.exports = function plot(gd, cdpie) { x1: hoverCenterX + rInscribed * cd0.r, y: hoverCenterY, text: thisText.join('
'), - name: hoverinfo.indexOf('name') !== -1 ? trace2.name : undefined, + name: (trace2.hovertemplate || hoverinfo.indexOf('name') !== -1) ? trace2.name : undefined, idealAlign: pt.pxmid[0] < 0 ? 'left' : 'right', color: helpers.castOption(hoverLabel.bgcolor, pt.pts) || pt.color, borderColor: helpers.castOption(hoverLabel.bordercolor, pt.pts), fontFamily: helpers.castOption(hoverFont.family, pt.pts), fontSize: helpers.castOption(hoverFont.size, pt.pts), - fontColor: helpers.castOption(hoverFont.color, pt.pts) + fontColor: helpers.castOption(hoverFont.color, pt.pts), + + trace: trace2, + hovertemplate: helpers.castOption(trace2.hovertemplate, pt.pts), + hovertemplateLabels: pt, + eventData: [eventData(pt, trace2)] }, { container: fullLayout2._hoverlayer.node(), outerContainer: fullLayout2._paper.node(), @@ -69523,7 +71324,7 @@ module.exports = function plot(gd, cdpie) { // add the title var titleTextGroup = d3.select(this).selectAll('g.titletext') - .data(trace.title ? [0] : []); + .data(trace.title.text ? [0] : []); titleTextGroup.enter().append('g') .classed('titletext', true); @@ -69535,18 +71336,18 @@ module.exports = function plot(gd, cdpie) { s.attr('data-notex', 1); }); - titleText.text(trace.title) + titleText.text(trace.title.text) .attr({ 'class': 'titletext', transform: '', 'text-anchor': 'middle', }) - .call(Drawing.font, trace.titlefont) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var transform; - if(trace.titleposition === 'middle center') { + if(trace.title.position === 'middle center') { transform = positionTitleInside(cd0); } else { transform = positionTitleOutside(cd0, fullLayout._size); @@ -69674,11 +71475,11 @@ function prerenderTitles(cdpie, gd) { cd0 = cdpie[i][0]; trace = cd0.trace; - if(trace.title) { + if(trace.title.text) { var dummyTitle = Drawing.tester.append('text') .attr('data-notex', 1) - .text(trace.title) - .call(Drawing.font, trace.titlefont) + .text(trace.title.text) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var bBox = Drawing.bBox(dummyTitle.node(), true); cd0.titleBox = { @@ -69780,7 +71581,7 @@ function positionTitleInside(cd0) { y: cd0.cy, scale: cd0.trace.hole * cd0.r * 2 / textDiameter, tx: 0, - ty: - cd0.titleBox.height / 2 + cd0.trace.titlefont.size + ty: - cd0.titleBox.height / 2 + cd0.trace.title.font.size }; } @@ -69803,25 +71604,25 @@ function positionTitleOutside(cd0, plotSize) { // we reason below as if the baseline is the top middle point of the text box. // so we must add the font size to approximate the y-coord. of the top. // note that this correction must happen after scaling. - translate.ty += trace.titlefont.size; + translate.ty += trace.title.font.size; maxPull = getMaxPull(trace); - if(trace.titleposition.indexOf('top') !== -1) { + if(trace.title.position.indexOf('top') !== -1) { topMiddle.y -= (1 + maxPull) * cd0.r; translate.ty -= cd0.titleBox.height; } - else if(trace.titleposition.indexOf('bottom') !== -1) { + else if(trace.title.position.indexOf('bottom') !== -1) { topMiddle.y += (1 + maxPull) * cd0.r; } - if(trace.titleposition.indexOf('left') !== -1) { + if(trace.title.position.indexOf('left') !== -1) { // we start the text at the left edge of the pie maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x -= (1 + maxPull) * cd0.r; translate.tx += cd0.titleBox.width / 2; - } else if(trace.titleposition.indexOf('center') !== -1) { + } else if(trace.title.position.indexOf('center') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); - } else if(trace.titleposition.indexOf('right') !== -1) { + } else if(trace.title.position.indexOf('right') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x += (1 + maxPull) * cd0.r; translate.tx -= cd0.titleBox.width / 2; @@ -69975,7 +71776,7 @@ function scalePies(cdpie, plotSize) { pieBoxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); pieBoxHeight = plotSize.h * (trace.domain.y[1] - trace.domain.y[0]); // leave some space for the title, if it will be displayed outside - if(trace.title && trace.titleposition !== 'middle center') { + if(trace.title.text && trace.title.position !== 'middle center') { pieBoxHeight -= getTitleSpace(cd0, plotSize); } @@ -69985,7 +71786,7 @@ function scalePies(cdpie, plotSize) { cd0.cx = plotSize.l + plotSize.w * (trace.domain.x[1] + trace.domain.x[0]) / 2; cd0.cy = plotSize.t + plotSize.h * (1 - trace.domain.y[0]) - pieBoxHeight / 2; - if(trace.title && trace.titleposition.indexOf('bottom') !== -1) { + if(trace.title.text && trace.title.position.indexOf('bottom') !== -1) { cd0.cy -= getTitleSpace(cd0, plotSize); } @@ -70064,7 +71865,7 @@ function setCoords(cd) { } } -},{"../../components/color":46,"../../components/drawing":71,"../../components/fx":88,"../../lib":164,"../../lib/svg_text_utils":185,"./event_data":307,"./helpers":308,"d3":11}],313:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/drawing":67,"../../components/fx":85,"../../lib":162,"../../lib/svg_text_utils":183,"./event_data":307,"./helpers":308,"d3":11}],313:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70169,7 +71970,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":164}],316:[function(_dereq_,module,exports){ +},{"../../lib":162}],316:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70180,6 +71981,7 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -70291,6 +72093,9 @@ module.exports = { editType: 'style', }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), line: { color: { valType: 'color', @@ -70565,7 +72370,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":47,"../../components/colorscale/attributes":53,"../../components/drawing":71,"../../components/drawing/attributes":70,"../../lib/extend":158,"../../plots/font_attributes":235,"./constants":320}],317:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":47,"../../components/colorscale/attributes":53,"../../components/drawing":67,"../../components/drawing/attributes":66,"../../components/fx/hovertemplate_attributes":84,"../../lib/extend":156,"../../plots/font_attributes":233,"./constants":320}],317:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70655,7 +72460,7 @@ function calc(gd, trace) { } arraysToCalcdata(cd, trace); - calcColorscale(trace); + calcColorscale(gd, trace); calcSelection(cd, trace); if(stackGroupOpts) { @@ -70855,7 +72660,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":146,"../../lib":164,"../../plots/cartesian/axes":208,"./arrays_to_calcdata":315,"./calc_selection":318,"./colorscale_calc":319,"./subtypes":340,"fast-isnumeric":13}],318:[function(_dereq_,module,exports){ +},{"../../constants/numerical":143,"../../lib":162,"../../plots/cartesian/axes":206,"./arrays_to_calcdata":315,"./calc_selection":318,"./colorscale_calc":319,"./subtypes":340,"fast-isnumeric":13}],318:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70874,7 +72679,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":164}],319:[function(_dereq_,module,exports){ +},{"../../lib":162}],319:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70883,31 +72688,41 @@ module.exports = function calcSelection(cd, trace) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var subTypes = _dereq_('./subtypes'); - -module.exports = function calcMarkerColorscale(trace) { +module.exports = function calcMarkerColorscale(gd, trace) { if(subTypes.hasLines(trace) && hasColorscale(trace, 'line')) { - calcColorscale(trace, trace.line.color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } if(subTypes.hasMarkers(trace)) { if(hasColorscale(trace, 'marker')) { - calcColorscale(trace, trace.marker.color, 'marker', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - calcColorscale(trace, trace.marker.line.color, 'marker.line', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } } }; -},{"../../components/colorscale/calc":54,"../../components/colorscale/has_colorscale":60,"./subtypes":340}],320:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":54,"../../components/colorscale/helpers":57,"./subtypes":340}],320:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70931,7 +72746,9 @@ module.exports = { // number of viewport sizes away from the visible region // at which we clip all lines to the perimeter - maxScreensAway: 20 + maxScreensAway: 20, + + eventDataKeys: [] }; },{}],321:[function(_dereq_,module,exports){ @@ -71234,7 +73051,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout dfltHoverOn.push('fills'); } coerce('hoveron', dfltHoverOn.join('+') || 'points'); - + if(traceOut.hoveron !== 'fills') coerce('hovertemplate'); var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults'); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'}); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'}); @@ -71242,7 +73059,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":164,"../../registry":248,"./attributes":316,"./constants":320,"./fillcolor_defaults":325,"./line_defaults":329,"./line_shape_defaults":331,"./marker_defaults":335,"./stack_defaults":338,"./subtypes":340,"./text_defaults":341,"./xy_defaults":342}],324:[function(_dereq_,module,exports){ +},{"../../lib":162,"../../registry":246,"./attributes":316,"./constants":320,"./fillcolor_defaults":325,"./line_defaults":329,"./line_shape_defaults":331,"./marker_defaults":335,"./stack_defaults":338,"./subtypes":340,"./text_defaults":341,"./xy_defaults":342}],324:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71285,7 +73102,7 @@ function isValid(v) { return v || v === 0; } -},{"../../lib":164}],325:[function(_dereq_,module,exports){ +},{"../../lib":162}],325:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71323,7 +73140,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":46,"../../lib":164}],326:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../lib":162}],326:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71472,7 +73289,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { y1: yc + rad, yLabelVal: yLabelVal, - spikeDistance: dxy(di) + spikeDistance: dxy(di), + hovertemplate: trace.hovertemplate }); fillHoverText(di, trace, pointData); @@ -71556,7 +73374,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { x1: xmax, y0: yAvg, y1: yAvg, - color: color + color: color, + hovertemplate: '%{name}' }); delete pointData.index; @@ -71571,7 +73390,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":46,"../../components/fx":88,"../../lib":164,"../../registry":248,"./fill_hover_text":324,"./get_trace_color":326}],328:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/fx":85,"../../lib":162,"../../registry":246,"./fill_hover_text":324,"./get_trace_color":326}],328:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71618,7 +73437,7 @@ Scatter.meta = { module.exports = Scatter; -},{"../../plots/cartesian":220,"./arrays_to_calcdata":315,"./attributes":316,"./calc":317,"./cross_trace_calc":321,"./cross_trace_defaults":322,"./defaults":323,"./hover":327,"./marker_colorbar":334,"./plot":336,"./select":337,"./style":339,"./subtypes":340}],329:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":218,"./arrays_to_calcdata":315,"./attributes":316,"./calc":317,"./cross_trace_calc":321,"./cross_trace_defaults":322,"./defaults":323,"./hover":327,"./marker_colorbar":334,"./plot":336,"./select":337,"./style":339,"./subtypes":340}],329:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71630,7 +73449,7 @@ module.exports = Scatter; 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) { @@ -71649,7 +73468,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":56,"../../components/colorscale/has_colorscale":60,"../../lib":164}],330:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":56,"../../components/colorscale/helpers":57,"../../lib":162}],330:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72114,7 +73933,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":146,"../../lib":164,"./constants":320}],331:[function(_dereq_,module,exports){ +},{"../../constants/numerical":143,"../../lib":162,"./constants":320}],331:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72295,11 +74114,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var subTypes = _dereq_('./subtypes'); @@ -72369,7 +74187,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":46,"../../components/colorscale/defaults":56,"../../components/colorscale/has_colorscale":60,"./subtypes":340}],336:[function(_dereq_,module,exports){ +},{"../../components/color":46,"../../components/colorscale/defaults":56,"../../components/colorscale/helpers":57,"./subtypes":340}],336:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72460,7 +74278,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition function createFills(gd, traceJoin, plotinfo) { traceJoin.each(function(d) { var fills = ensureSingle(d3.select(this), 'g', 'fills'); - Drawing.setClipUrl(fills, plotinfo.layerClipId); + Drawing.setClipUrl(fills, plotinfo.layerClipId, gd); var trace = d[0].trace; @@ -72512,7 +74330,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition var text = ensureSingle(tr, 'g', 'text'); // error bars are at the bottom - Registry.getComponentMethod('errorbars', 'plot')(errorBarGroup, plotinfo, transitionOpts); + Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts); if(trace.visible !== true) return; @@ -72667,7 +74485,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.lineGroupStyle) .each(makeUpdate(true)); - Drawing.setClipUrl(lineJoin, plotinfo.layerClipId); + Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd); function clearFill(selection) { transition(selection).attr('d', 'M0,0Z'); @@ -72895,8 +74713,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = trace.cliponaxis === false; var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId; - Drawing.setClipUrl(points, clipUrl); - Drawing.setClipUrl(text, clipUrl); + Drawing.setClipUrl(points, clipUrl, gd); + Drawing.setClipUrl(text, clipUrl, gd); } function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { @@ -72941,7 +74759,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":71,"../../lib":164,"../../lib/polygon":176,"../../registry":248,"./line_points":330,"./link_traces":332,"./subtypes":340,"d3":11}],337:[function(_dereq_,module,exports){ +},{"../../components/drawing":67,"../../lib":162,"../../lib/polygon":174,"../../registry":246,"./line_points":330,"./link_traces":332,"./subtypes":340,"d3":11}],337:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73174,7 +74992,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":71,"../../registry":248,"d3":11}],340:[function(_dereq_,module,exports){ +},{"../../components/drawing":67,"../../registry":246,"d3":11}],340:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73213,7 +75031,7 @@ module.exports = { } }; -},{"../../lib":164}],341:[function(_dereq_,module,exports){ +},{"../../lib":162}],341:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73243,7 +75061,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":164}],342:[function(_dereq_,module,exports){ +},{"../../lib":162}],342:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73252,34 +75070,32 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var Lib = _dereq_('../../lib'); var Registry = _dereq_('../../registry'); - module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { - var len, - x = coerce('x'), - y = coerce('y'); + var x = coerce('x'); + var y = coerce('y'); + var len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); if(x) { + var xlen = Lib.minRowLength(x); if(y) { - len = Math.min(x.length, y.length); - } - else { - len = x.length; + len = Math.min(xlen, Lib.minRowLength(y)); + } else { + len = xlen; coerce('y0'); coerce('dy'); } - } - else { + } else { if(!y) return 0; - len = traceOut.y.length; + len = Lib.minRowLength(y); coerce('x0'); coerce('dx'); } @@ -73289,5 +75105,5 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../registry":248}]},{},[7])(7) +},{"../../lib":162,"../../registry":246}]},{},[7])(7) }); diff --git a/dist/plotly-finance.min.js b/dist/plotly-finance.min.js index d5a80c64d01..e1fd7cd8c54 100644 --- a/dist/plotly-finance.min.js +++ b/dist/plotly-finance.min.js @@ -1,7 +1,7 @@ /** -* plotly.js (finance - minified) v1.42.5 +* plotly.js (finance - minified) v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,r,n){function a(o,l){if(!r[o]){if(!e[o]){var s="function"==typeof require&&require;if(!l&&s)return s(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};e[o][0].call(u.exports,function(t){return a(e[o][1][t]||t)},u,u.exports,t,e,r,n)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;oplotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":264}],4:[function(t,e,r){"use strict";e.exports=t("../src/traces/candlestick")},{"../src/traces/candlestick":281}],5:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":148}],6:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram")},{"../src/traces/histogram":292}],7:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./histogram"),t("./pie"),t("./ohlc"),t("./candlestick")]),e.exports=n},{"./bar":3,"./candlestick":4,"./core":5,"./histogram":6,"./ohlc":8,"./pie":9}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/ohlc")},{"../src/traces/ohlc":298}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":309}],10:[function(t,e,r){var n=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},i=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var l,s=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),l=0===c.x}catch(t){l=!1}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,a){var i,o,l;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),l=o[e]):(o=t._events=n(null),t._eventsCount=0),l){if("function"==typeof l?l=o[e]=a?[r,l]:[l,r]:a?l.unshift(r):l.push(r),!l.warned&&(i=u(t))&&i>0&&l.length>i){l.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+l.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=l.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else l=o[e]=r,++t._eventsCount;return t}function d(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var s=new Error('Unhandled "error" event. ('+e+")");throw s.context=e,s}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,a=v(t,n),i=0;i=0;o--)if(r[o]===e||r[o].listener===e){l=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(var r=e,n=r+1,a=t.length;n=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],11:[function(t,e,r){!function(){var t={version:"3.5.17"},r=[].slice,n=function(t){return r.call(t)},a=this.document;function i(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(a)try{n(a.documentElement.childNodes)[0].nodeType}catch(t){n=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),a)try{a.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var l=this.Element.prototype,s=l.setAttribute,c=l.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;l.setAttribute=function(t,e){s.call(this,t,e+"")},l.setAttributeNS=function(t,e,r){c.call(this,t,e,r+"")},u.setProperty=function(t,e,r){f.call(this,t,e+"",r)}}function d(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function h(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)<0?n=i+1:a=i}return n},right:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)>0?a=i:n=i+1}return n}}}t.ascending=d,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++an&&(r=n)}else{for(;++a=n){r=n;break}for(;++an&&(r=n)}return r},t.max=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++ar&&(r=n)}else{for(;++a=n){r=n;break}for(;++ar&&(r=n)}return r},t.extent=function(t,e){var r,n,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=n){r=a=n;break}for(;++in&&(r=n),a=n){r=a=n;break}for(;++in&&(r=n),a1)return o/(s-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(d);function y(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return d(t(e),r)}:t)},t.shuffle=function(t,e,r){(i=arguments.length)<3&&(r=t.length,i<2&&(e=0));for(var n,a,i=r-e;i;)a=Math.random()*i--|0,n=t[i+e],t[i+e]=t[a+e],t[a+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],a=new Array(r<0?0:r);e=0;)for(e=(n=t[a]).length;--e>=0;)r[--o]=n[e];return r};var m=Math.abs;function x(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(m(r)),o=-1;if(t*=i,e*=i,(r*=i)<0)for(;(n=t+r*++o)>e;)a.push(n/i);else for(;(n=t+r*++o)=a.length)return r?r.call(n,i):e?i.sort(e):i;for(var s,c,u,f,d=-1,p=i.length,h=a[l++],g=new b;++d=a.length)return e;var n=[],o=i[r++];return e.forEach(function(e,a){n.push({key:e,values:t(a,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return a.push(t),n},n.sortKeys=function(t){return i[a.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new O;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function V(t){return q(t,Y),t}var U=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},Z=function(t,e){var r=t.matches||t[z(t,"matchesSelector")];return(Z=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(U=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,Z=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var Y=t.selection.prototype=[];function X(t){return"function"==typeof t?t:function(){return U(t,this)}}function W(t){return"function"==typeof t?t:function(){return G(t,this)}}Y.select=function(t){var e,r,n,a,i=[];t=X(t);for(var o=-1,l=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Q.hasOwnProperty(r)?{space:Q[r],local:t}:t}},Y.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each($(r,e[r]));return this}return this.each($(e,r))},Y.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,a=-1;if(e=r.classList){for(;++a=0;)(r=n[a])&&(i&&i!==r.nextSibling&&i.parentNode.insertBefore(r,i),i=r);return this},Y.sort=function(t){t=function(t){arguments.length||(t=d);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var s=ht.get(e);function c(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return s&&(e=s,l=vt),o?r?function(){var t=l(r,n(arguments));c.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=r}:c:r?N:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(r=a.match(n)){var i=this[a];this.removeEventListener(r[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=dt,dt.append=Y.append,dt.empty=Y.empty,dt.node=Y.node,dt.call=Y.call,dt.size=Y.size,dt.select=function(t){for(var e,r,n,a,i,o=[],l=-1,s=this.length;++l=n&&(n=e+1);!(o=l[n])&&++n0?1:t<0?-1:0}function Dt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function zt(t){return t>1?0:t<-1?Mt:Math.acos(t)}function Et(t){return t>1?St:t<-1?-St:Math.asin(t)}function Nt(t){return((t=Math.exp(t))+1/t)/2}function Rt(t){return(t=Math.sin(t/2))*t}var It=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,a=t[0],i=t[1],o=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-i,d=u*u+f*f;if(d0&&(e=e.transition().duration(g)),e.call(w.event)}function L(){c&&c.domain(s.range().map(function(t){return(t-d.x)/d.k}).map(s.invert)),f&&f.domain(u.range().map(function(t){return(t-d.y)/d.k}).map(u.invert))}function S(t){v++||t({type:"zoomstart"})}function C(t){L(),t({type:"zoom",scale:d.k,translate:[d.x,d.y]})}function O(t){--v||(t({type:"zoomend"}),r=null)}function P(){var e=this,r=_.of(e,arguments),n=0,a=t.select(o(e)).on(m,function(){n=1,M(t.mouse(e),i),C(r)}).on(x,function(){a.on(m,null).on(x,null),l(n),O(r)}),i=k(t.mouse(e)),l=xt(e);fl.call(e),S(r)}function D(){var e,r=this,n=_.of(r,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+o,c="touchend"+o,u=[],f=t.select(r),p=xt(r);function h(){var n=t.touches(r);return e=d.k,n.forEach(function(t){t.identifier in a&&(a[t.identifier]=k(t))}),n}function g(){var e=t.event.target;t.select(e).on(s,v).on(c,m),u.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){y=p[0];var x=p[1],b=y[0]-x[0],_=y[1]-x[1];i=b*b+_*_}}function v(){var o,s,c,u,f=t.touches(r);fl.call(r);for(var d=0,p=f.length;d360?t-=360:t<0&&(t+=360),t<60?n+(a-n)*t/60:t<180?a:t<240?n+(a-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(a=r<=.5?r*(1+e):r+e-r*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Xt?e.l:(e=de((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Ut(this.h,this.s,this.l)},t.hcl=Gt;var Zt=Gt.prototype=new Ht;function Yt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Xt(r,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Xt(t,e,r){return this instanceof Xt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Xt?new Xt(t.l,t.a,t.b):t instanceof Gt?Yt(t.h,t.c,t.l):de((t=ie(t)).r,t.g,t.b):new Xt(t,e,r)}Zt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Wt*(arguments.length?t:1)))},Zt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Wt*(arguments.length?t:1)))},Zt.rgb=function(){return Yt(this.h,this.c,this.l).rgb()},t.lab=Xt;var Wt=18,Jt=.95047,Qt=1,$t=1.08883,Kt=Xt.prototype=new Ht;function te(t,e,r){var n=(t+16)/116,a=n+e/500,i=n-r/200;return new ie(ae(3.2404542*(a=re(a)*Jt)-1.5371385*(n=re(n)*Qt)-.4985314*(i=re(i)*$t)),ae(-.969266*a+1.8760108*n+.041556*i),ae(.0556434*a-.2040259*n+1.0572252*i))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Ot,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,r){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ue(""+t,ie,Ut):new ie(t,e,r)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function le(t){return oe(t)+""}Kt.brighter=function(t){return new Xt(Math.min(100,this.l+Wt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Xt(Math.max(0,this.l-Wt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var se=ie.prototype=new Ht;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,r){var n,a,i,o=0,l=0,s=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=n[2].split(","),n[1]){case"hsl":return r(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(he(a[0]),he(a[1]),he(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,l=240&i,l|=l>>4,s=15&i,s|=s<<4):7===t.length&&(o=(16711680&i)>>16,l=(65280&i)>>8,s=255&i)),e(o,l,s))}function fe(t,e,r){var n,a,i=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),l=o-i,s=(o+i)/2;return l?(a=s<.5?l/(o+i):l/(2-o-i),n=t==o?(e-r)/l+(e0&&s<1?0:n),new qt(n,a,s)}function de(t,e,r){var n=ne((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(r=pe(r)))/Jt),a=ne((.2126729*t+.7151522*e+.072175*r)/Qt);return Xt(116*a-16,500*(n-a),200*(a-ne((.0193339*t+.119192*e+.9503041*r)/$t)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function he(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}se.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,a=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=a.call(o,c)}catch(t){return void l.error.call(o,t)}l.load.call(o,t)}else l.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var r=t.event;t.event=e;try{l.progress.call(o,c)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,a){if(2===arguments.length&&"function"==typeof n&&(a=n,n=null),c.open(t,e,!0),null==r||"accept"in s||(s.accept=r+",*/*"),c.setRequestHeader)for(var i in s)c.setRequestHeader(i,s[i]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=u&&(c.responseType=u),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),l.beforesend.call(o,c),c.send(null==n?null:n),o},o.abort=function(){return c.abort(),o},t.rebind(o,l,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=ye(P),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function a(t,r,n){arguments.length<3&&(n=r,r=null);var a=me(t,e,null==r?i:o(r),n);return a.row=function(t){return arguments.length?a.response(null==(r=t)?i:o(t)):r},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function l(e){return e.map(s).join(t)}function s(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var r;return a.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(a(t),r)}:a})},a.parseRows=function(t,e){var r,a,i={},o={},l=[],s=t.length,c=0,u=0;function f(){if(c>=s)return o;if(a)return a=!1,i;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Me,e)),_e=0):(_e=1,ke(Me))}function Ae(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Le(){for(var t,e=xe,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Se(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Ce[8+n/3]};var Oe=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Pe=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Se(e,r))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),r))))}});function De(t){return t+""}var ze=t.time={},Ee=Date;function Ne(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Ne.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Re.setUTCDate.apply(this._,arguments)},setDay:function(){Re.setUTCDay.apply(this._,arguments)},setFullYear:function(){Re.setUTCFullYear.apply(this._,arguments)},setHours:function(){Re.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Re.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Re.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Re.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Re.setUTCSeconds.apply(this._,arguments)},setTime:function(){Re.setTime.apply(this._,arguments)}};var Re=Date.prototype;function Ie(t,e,r){function n(e){var r=t(e),n=i(r,1);return e-r1)for(;o68?1900:2e3),r+a[0].length):-1}function Je(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function Qe(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function $e(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ar(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=m(e)/60|0,a=m(e)%60;return r+qe(n,"0",2)+qe(a,"0",2)}function ir(t,e,r){He.lastIndex=0;var n=He.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),i.push(t.substring(r-=l,r+l)),!((s+=l+1)>e));)l=a[o=(o+1)%a.length];return i.reverse().join(n)}:P;return function(e){var n=Oe.exec(e),a=n[1]||" ",l=n[2]||">",s=n[3]||"-",c=n[4]||"",u=n[5],f=+n[6],d=n[7],p=n[8],h=n[9],g=1,v="",y="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===a&&"="===l)&&(u=a="0",l="="),h){case"n":d=!0,h="g";break;case"%":g=100,y="%",h="f";break;case"p":g=100,y="%",h="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+h.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":g=-1,h="r"}"$"===c&&(v=i[0],y=i[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):"e"!=h&&"f"!=h||(p=Math.max(0,Math.min(20,p)))),h=Pe.get(h)||De;var b=u&&d;return function(e){var n=y;if(m&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===s?"":s;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),n=c.symbol+y}else e*=g;var _,w,k=(e=h(e,p)).lastIndexOf(".");if(k<0){var T=x?e.lastIndexOf("e"):-1;T<0?(_=e,w=""):(_=e.substring(0,T),w=e.substring(T))}else _=e.substring(0,k),w=r+e.substring(k+1);!u&&d&&(_=o(_,1/0));var M=v.length+_.length+w.length+(b?0:i.length),A=M"===l?A+i+e:"^"===l?A.substring(0,M>>=1)+i+e+A.substring(M):i+(b?e:A+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,a=e.time,i=e.periods,o=e.days,l=e.shortDays,s=e.months,c=e.shortMonths;function u(t){var e=t.length;function r(r){for(var n,a,i,o=[],l=-1,s=0;++l=c)return-1;if(37===(a=e.charCodeAt(l++))){if(o=e.charAt(l++),!(i=w[o in Be?e.charAt(l++):o])||(n=i(t,r,n))<0)return-1}else if(a!=r.charCodeAt(n++))return-1}return n}u.utc=function(t){var e=u(t);function r(t){try{var r=new(Ee=Ne);return r._=t,e(r)}finally{Ee=Date}}return r.parse=function(t){try{Ee=Ne;var r=e.parse(t);return r&&r._}finally{Ee=Date}},r.toString=e.toString,r},u.multi=u.utc.multi=or;var d=t.map(),p=Ve(o),h=Ue(o),g=Ve(l),v=Ue(l),y=Ve(s),m=Ue(s),x=Ve(c),b=Ue(c);i.forEach(function(t,e){d.set(t.toLowerCase(),e)});var _={a:function(t){return l[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:u(r),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+ze.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(ze.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(ze.mondayOfYear(t),e,2)},x:u(n),X:u(a),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:ar,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=h.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){y.lastIndex=0;var n=y.exec(e.slice(r));return n?(t.m=m.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:$e,e:$e,H:tr,I:tr,j:Ke,L:nr,m:Qe,M:er,p:function(t,e,r){var n=d.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:Ze,w:Ge,W:Ye,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:We,Y:Xe,Z:Je,"%":ir};return u}(e)}};var lr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function sr(){}t.format=lr.numberFormat,t.geo={},sr.prototype={s:0,t:0,add:function(t){ur(t,this.t,cr),ur(cr.s,this.s,this),this.s?this.t+=cr.t:this.s=cr.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cr=new sr;function ur(t,e,r){var n=r.s=t+e,a=n-t,i=n-a;r.t=t-i+(e-a)}function fr(t,e){t&&pr.hasOwnProperty(t.type)&&pr[t.type](t,e)}t.geo.stream=function(t,e){t&&dr.hasOwnProperty(t.type)?dr[t.type](t,e):fr(t,e)};var dr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,a=r.length;++n=0?1:-1,l=o*i,s=Math.cos(e),c=Math.sin(e),u=a*c,f=n*s+u*Math.cos(l),d=u*o*Math.sin(l);Sr.add(Math.atan2(d,f)),r=t,n=s,a=c}Cr.point=function(o,l){Cr.point=i,r=(t=o)*Ct,n=Math.cos(l=(e=l)*Ct/2+Mt/4),a=Math.sin(l)},Cr.lineEnd=function(){i(t,e)}}function Pr(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Dr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function zr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Er(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Nr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Rr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Ir(t){return[Math.atan2(t[1],t[0]),Et(t[2])]}function Fr(t,e){return m(t[0]-e[0])kt?a=90:c<-kt&&(r=-90),f[0]=e,f[1]=n}};function p(t,i){u.push(f=[e=t,n=t]),ia&&(a=i)}function h(t,o){var l=Pr([t*Ct,o*Ct]);if(s){var c=zr(s,l),u=zr([c[1],-c[0],0],c);Rr(u),u=Ir(u);var f=t-i,d=f>0?1:-1,h=u[0]*Ot*d,g=m(f)>180;if(g^(d*ia&&(a=v);else if(g^(d*i<(h=(h+360)%360-180)&&ha&&(a=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>i?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else p(t,o);s=l,i=t}function g(){d.point=h}function v(){f[0]=e,f[1]=n,d.point=p,s=null}function y(t,e){if(s){var r=t-i;c+=m(r)>180?r+(r>0?360:-360):r}else o=t,l=e;Cr.point(t,e),h(t,e)}function x(){Cr.lineStart()}function b(){y(o,l),Cr.lineEnd(),m(c)>kt&&(e=-(n=180)),f[0]=e,f[1]=n,s=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):l.push(g=p);for(var s,c,p,h=-1/0,g=(o=0,l[c=l.length-1]);o<=c;g=p,++o)p=l[o],(s=_(g[1],p[0]))>h&&(h=s,e=p[0],n=g[1])}return u=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,a]]}}(),t.geo.centroid=function(e){yr=mr=xr=br=_r=wr=kr=Tr=Mr=Ar=Lr=0,t.geo.stream(e,Br);var r=Mr,n=Ar,a=Lr,i=r*r+n*n+a*a;return i=0;--l)a.point((f=u[l])[0],f[1]);else n(p.x,p.p.x,-1,a);p=p.p}u=(p=p.o).z,h=!h}while(!p.v);a.lineEnd()}}}function Xr(t){if(e=t.length){for(var e,r,n=0,a=t[0];++n=0?1:-1,k=w*_,T=k>Mt,M=h*x;if(Sr.add(Math.atan2(M*w*Math.sin(k),g*b+M*Math.cos(k))),i+=T?_+w*At:_,T^d>=r^y>=r){var A=zr(Pr(f),Pr(t));Rr(A);var L=zr(a,A);Rr(L);var S=(T^_>=0?-1:1)*Et(L[2]);(n>S||n===S&&(A[0]||A[1]))&&(o+=T^_>=0?1:-1)}if(!v++)break;d=y,h=x,g=b,f=t}}return(i<-kt||i0){for(x||(o.polygonStart(),x=!0),o.lineStart();++i1&&2&e&&r.push(r.pop().concat(r.shift())),l.push(r.filter(Qr))}return u}}function Qr(t){return t.length>1}function $r(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:N,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-St-kt:St-t[1])-((e=e.x)[0]<0?e[1]-St-kt:St-e[1])}var tn=Jr(Zr,function(t){var e,r=NaN,n=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var l=i>0?Mt:-Mt,s=m(i-r);m(s-Mt)0?St:-St),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),t.point(i,n),e=0):a!==l&&s>=Mt&&(m(r-a)kt?Math.atan((Math.sin(e)*(i=Math.cos(n))*Math.sin(r)-Math.sin(n)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+n)/2}(r,n,i,o),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),e=0),t.point(r=i,n=o),a=l},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var a;if(null==t)a=r*St,n.point(-Mt,a),n.point(0,a),n.point(Mt,a),n.point(Mt,0),n.point(Mt,-a),n.point(0,-a),n.point(-Mt,-a),n.point(-Mt,0),n.point(-Mt,a);else if(m(t[0]-e[0])>kt){var i=t[0]0)){if(i/=d,d<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=r-s,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>u&&(u=i)}else if(d>0){if(i0)){if(i/=p,p<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=n-c,p||!(i<0)){if(i/=p,p<0){if(i>f)return;i>u&&(u=i)}else if(p>0){if(i0&&(a.a={x:s+u*d,y:c+u*p}),f<1&&(a.b={x:s+f*d,y:c+f*p}),a}}}}}}var rn=1e9;function nn(e,r,n,a){return function(s){var c,u,f,d,p,h,g,v,y,m,x,b=s,_=$r(),w=en(e,r,n,a),k={point:A,lineStart:function(){k.point=L,u&&u.push(f=[]);m=!0,y=!1,g=v=NaN},lineEnd:function(){c&&(L(d,p),h&&y&&_.rejoin(),c.push(_.buffer()));k.point=A,y&&s.lineEnd()},polygonStart:function(){s=_,c=[],u=[],x=!0},polygonEnd:function(){s=b,c=t.merge(c);var r=function(t){for(var e=0,r=u.length,n=t[1],a=0;an&&Dt(c,i,t)>0&&++e:i[1]<=n&&Dt(c,i,t)<0&&--e,c=i;return 0!==e}([e,a]),n=x&&r,i=c.length;(n||i)&&(s.polygonStart(),n&&(s.lineStart(),T(null,null,1,s),s.lineEnd()),i&&Yr(c,o,r,T,s),s.polygonEnd()),c=u=f=null}};function T(t,o,s,c){var u=0,f=0;if(null==t||(u=i(t,s))!==(f=i(o,s))||l(t,o)<0^s>0)do{c.point(0===u||3===u?e:n,u>1?a:r)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function M(t,i){return e<=t&&t<=n&&r<=i&&i<=a}function A(t,e){M(t,e)&&s.point(t,e)}function L(t,e){var r=M(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(u&&f.push([t,e]),m)d=t,p=e,h=r,m=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&y)s.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(y||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),x=!1):r&&(s.lineStart(),s.point(t,e),x=!1)}g=t,v=e,y=r}return k};function i(t,a){return m(t[0]-e)0?0:3:m(t[0]-n)0?2:1:m(t[1]-r)0?1:0:a>0?3:2}function o(t,e){return l(t.x,e.x)}function l(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Mt/3,n=Cn(t),a=n(e,r);return a.parallels=function(t){return arguments.length?n(e=t[0]*Mt/180,r=t[1]*Mt/180):[e/Mt*180,r/Mt*180]},a}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,a=1+r*(2*n-r),i=Math.sqrt(a)/n;function o(t,e){var r=Math.sqrt(a-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),i-r*Math.cos(t)]}return o.invert=function(t,e){var r=i-e;return[Math.atan2(t,r)/n,Et((a-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(l){return arguments.length?(i=nn(t=+l[0][0],e=+l[0][1],r=+l[1][0],n=+l[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,r){e=[t,r]}};function c(t){var i=t[0],o=t[1];return e=null,r(i,o),e||(n(i,o),e)||a(i,o),e}return c.invert=function(t){var e=i.scale(),r=i.translate(),n=(t[0]-r[0])/e,a=(t[1]-r[1])/e;return(a>=.12&&a<.234&&n>=-.425&&n<-.214?o:a>=.166&&a<.234&&n>=-.214&&n<-.115?l:i).invert(t)},c.stream=function(t){var e=i.stream(t),r=o.stream(t),n=l.stream(t);return{point:function(t,a){e.point(t,a),r.point(t,a),n.point(t,a)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),l.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),l.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),u=+t[0],f=+t[1];return r=i.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(s).point,n=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(s).point,a=l.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(s).point,c},c.scale(1070)};var ln,sn,cn,un,fn,dn,pn={point:N,lineStart:N,lineEnd:N,polygonStart:function(){sn=0,pn.lineStart=hn},polygonEnd:function(){pn.lineStart=pn.lineEnd=pn.point=N,ln+=m(sn/2)}};function hn(){var t,e,r,n;function a(t,e){sn+=n*t-r*e,r=t,n=e}pn.point=function(i,o){pn.point=a,t=r=i,e=n=o},pn.lineEnd=function(){a(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);edn&&(dn=e)},lineStart:N,lineEnd:N,polygonStart:N,polygonEnd:N};function vn(){var t=yn(4.5),e=[],r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=yn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function a(t,n){e.push("M",t,",",n),r.point=i}function i(t,r){e.push("L",t,",",r)}function o(){r.point=n}function l(){e.push("Z")}return r}function yn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var mn,xn={point:bn,lineStart:_n,lineEnd:wn,polygonStart:function(){xn.lineStart=kn},polygonEnd:function(){xn.point=bn,xn.lineStart=_n,xn.lineEnd=wn}};function bn(t,e){xr+=t,br+=e,++_r}function _n(){var t,e;function r(r,n){var a=r-t,i=n-e,o=Math.sqrt(a*a+i*i);wr+=o*(t+r)/2,kr+=o*(e+n)/2,Tr+=o,bn(t=r,e=n)}xn.point=function(n,a){xn.point=r,bn(t=n,e=a)}}function wn(){xn.point=bn}function kn(){var t,e,r,n;function a(t,e){var a=t-r,i=e-n,o=Math.sqrt(a*a+i*i);wr+=o*(r+t)/2,kr+=o*(n+e)/2,Tr+=o,Mr+=(o=n*t-r*e)*(r+t),Ar+=o*(n+e),Lr+=3*o,bn(r=t,n=e)}xn.point=function(i,o){xn.point=a,bn(t=r=i,e=n=o)},xn.lineEnd=function(){a(t,e)}}function Tn(t){var e=4.5,r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:N};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,At)}function a(e,n){t.moveTo(e,n),r.point=i}function i(e,r){t.lineTo(e,r)}function o(){r.point=n}function l(){t.closePath()}return r}function Mn(t){var e=.5,r=Math.cos(30*Ct),n=16;function a(e){return(n?function(e){var r,a,o,l,s,c,u,f,d,p,h,g,v={point:y,lineStart:m,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=m}};function y(r,n){r=t(r,n),e.point(r[0],r[1])}function m(){f=NaN,v.point=x,e.lineStart()}function x(r,a){var o=Pr([r,a]),l=t(r,a);i(f,d,u,p,h,g,f=l[0],d=l[1],u=r,p=o[0],h=o[1],g=o[2],n,e),e.point(f,d)}function b(){v.point=y,e.lineEnd()}function _(){m(),v.point=w,v.lineEnd=k}function w(t,e){x(r=t,e),a=f,o=d,l=p,s=h,c=g,v.point=x}function k(){i(f,d,u,p,h,g,a,o,r,l,s,c,n,e),v.lineEnd=b,b()}return v}:function(e){return Ln(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function i(n,a,o,l,s,c,u,f,d,p,h,g,v,y){var x=u-n,b=f-a,_=x*x+b*b;if(_>4*e&&v--){var w=l+p,k=s+h,T=c+g,M=Math.sqrt(w*w+k*k+T*T),A=Math.asin(T/=M),L=m(m(T)-1)e||m((x*P+b*D)/_-.5)>.3||l*p+s*h+c*g0&&16,a):Math.sqrt(e)},a}function An(t){this.stream=t}function Ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sn(t){return Cn(function(){return t})()}function Cn(e){var r,n,a,i,o,l,s=Mn(function(t,e){return[(t=r(t,e))[0]*c+i,o-t[1]*c]}),c=150,u=480,f=250,d=0,p=0,h=0,g=0,v=0,y=tn,x=P,b=null,_=null;function w(t){return[(t=a(t[0]*Ct,t[1]*Ct))[0]*c+i,o-t[1]*c]}function k(t){return(t=a.invert((t[0]-i)/c,(o-t[1])/c))&&[t[0]*Ot,t[1]*Ot]}function T(){a=Gr(n=zn(h,g,v),r);var t=r(d,p);return i=u-t[0]*c,o=f+t[1]*c,M()}function M(){return l&&(l.valid=!1,l=null),w}return w.stream=function(t){return l&&(l.valid=!1),(l=On(y(n,s(x(t))))).valid=!0,l},w.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,tn):function(t){var e=Math.cos(t),r=e>0,n=m(e)>kt;return Jr(a,function(t){var e,l,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var p,h=[f,d],g=a(f,d),v=r?g?0:o(f,d):g?o(f+(f<0?Mt:-Mt),d):0;if(!e&&(c=s=g)&&t.lineStart(),g!==s&&(p=i(e,h),(Fr(e,p)||Fr(h,p))&&(h[0]+=kt,h[1]+=kt,g=a(h[0],h[1]))),g!==s)u=0,g?(t.lineStart(),p=i(h,e),t.point(p[0],p[1])):(p=i(e,h),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(n&&e&&r^g){var y;v&l||!(y=i(h,e,!0))||(u=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!g||e&&Fr(e,h)||t.point(h[0],h[1]),e=h,s=g,l=v},lineEnd:function(){s&&t.lineEnd(),e=null},clean:function(){return u|(c&&s)<<1}}},In(t,6*Ct),r?[0,-t]:[-Mt,t-Mt]);function a(t,r){return Math.cos(t)*Math.cos(r)>e}function i(t,r,n){var a=[1,0,0],i=zr(Pr(t),Pr(r)),o=Dr(i,i),l=i[0],s=o-l*l;if(!s)return!n&&t;var c=e*o/s,u=-e*l/s,f=zr(a,i),d=Nr(a,c);Er(d,Nr(i,u));var p=f,h=Dr(d,p),g=Dr(p,p),v=h*h-g*(Dr(d,d)-1);if(!(v<0)){var y=Math.sqrt(v),x=Nr(p,(-h-y)/g);if(Er(x,d),x=Ir(x),!n)return x;var b,_=t[0],w=r[0],k=t[1],T=r[1];w<_&&(b=_,_=w,w=b);var M=w-_,A=m(M-Mt)0^x[1]<(m(x[0]-_)Mt^(_<=x[0]&&x[0]<=w)){var L=Nr(p,(-h+y)/g);return Er(L,d),[x,Ir(L)]}}}function o(e,n){var a=r?t:Mt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),n<-a?i|=4:n>a&&(i|=8),i}}((b=+t)*Ct),M()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):P,M()):_},w.scale=function(t){return arguments.length?(c=+t,T()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],T()):[u,f]},w.center=function(t){return arguments.length?(d=t[0]%360*Ct,p=t[1]%360*Ct,T()):[d*Ot,p*Ot]},w.rotate=function(t){return arguments.length?(h=t[0]%360*Ct,g=t[1]%360*Ct,v=t.length>2?t[2]%360*Ct:0,T()):[h*Ot,g*Ot,v*Ot]},t.rebind(w,s,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&k,T()}}function On(t){return Ln(t,function(e,r){t.point(e*Ct,r*Ct)})}function Pn(t,e){return[t,e]}function Dn(t,e){return[t>Mt?t-At:t<-Mt?t+At:t,e]}function zn(t,e,r){return t?e||r?Gr(Nn(t),Rn(e,r)):Nn(t):e||r?Rn(e,r):Dn}function En(t){return function(e,r){return[(e+=t)>Mt?e-At:e<-Mt?e+At:e,r]}}function Nn(t){var e=En(t);return e.invert=En(-t),e}function Rn(t,e){var r=Math.cos(t),n=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*r+l*n;return[Math.atan2(s*a-u*i,l*r-c*n),Et(u*a+s*i)]}return o.invert=function(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*a-s*i;return[Math.atan2(s*a+c*i,l*r+u*n),Et(u*r-l*n)]},o}function In(t,e){var r=Math.cos(t),n=Math.sin(t);return function(a,i,o,l){var s=o*e;null!=a?(a=Fn(r,a),i=Fn(r,i),(o>0?ai)&&(a+=o*At)):(a=t+o*At,i=t-.5*s);for(var c,u=a;o>0?u>i:u2?t[2]*Ct:0),e.invert=function(e){return(e=t.invert(e[0]*Ct,e[1]*Ct))[0]*=Ot,e[1]*=Ot,e},e},Dn.invert=Pn,t.geo.circle=function(){var t,e,r=[0,0],n=6;function a(){var t="function"==typeof r?r.apply(this,arguments):r,n=zn(-t[0]*Ct,-t[1]*Ct,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=n(t,e)),t[0]*=Ot,t[1]*=Ot}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(r=t,a):r},a.angle=function(r){return arguments.length?(e=In((t=+r)*Ct,n*Ct),a):t},a.precision=function(r){return arguments.length?(e=In(t*Ct,(n=+r)*Ct),a):n},a.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Ct,a=t[1]*Ct,i=e[1]*Ct,o=Math.sin(n),l=Math.cos(n),s=Math.sin(a),c=Math.cos(a),u=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-s*f*l)*r),s*u+c*f*l)},t.geo.graticule=function(){var e,r,n,a,i,o,l,s,c,u,f,d,p=10,h=p,g=90,v=360,y=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(a/g)*g,n,g).map(f).concat(t.range(Math.ceil(s/v)*v,l,v).map(d)).concat(t.range(Math.ceil(r/p)*p,e,p).filter(function(t){return m(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/h)*h,i,h).filter(function(t){return m(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(d(l).slice(1),f(n).reverse().slice(1),d(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(a=+t[0][0],n=+t[1][0],s=+t[0][1],l=+t[1][1],a>n&&(t=a,a=n,n=t),s>l&&(t=s,s=l,l=t),x.precision(y)):[[a,s],[n,l]]},x.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),o>i&&(t=o,o=i,i=t),x.precision(y)):[[r,o],[e,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],h=+t[1],x):[p,h]},x.precision=function(t){return arguments.length?(y=+t,c=Bn(o,i,90),u=jn(r,e,y),f=Bn(s,l,90),d=jn(a,n,y),x):y},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,r,n=Hn,a=qn;function i(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||a.apply(this,arguments))},i.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,i):n},i.target=function(t){return arguments.length?(a=t,r="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return r=t[0]*Ct,n=t[1]*Ct,a=e[0]*Ct,i=e[1]*Ct,o=Math.cos(n),l=Math.sin(n),s=Math.cos(i),c=Math.sin(i),u=o*Math.cos(r),f=o*Math.sin(r),d=s*Math.cos(a),p=s*Math.sin(a),h=2*Math.asin(Math.sqrt(Rt(i-n)+o*s*Rt(a-r))),g=1/Math.sin(h),(v=h?function(t){var e=Math.sin(t*=h)*g,r=Math.sin(h-t)*g,n=r*u+e*d,a=r*f+e*p,i=r*l+e*c;return[Math.atan2(a,n)*Ot,Math.atan2(i,Math.sqrt(n*n+a*a))*Ot]}:function(){return[r*Ot,n*Ot]}).distance=h,v;var r,n,a,i,o,l,s,c,u,f,d,p,h,g,v},t.geo.length=function(e){return mn=0,t.geo.stream(e,Vn),mn};var Vn={sphere:N,point:N,lineStart:function(){var t,e,r;function n(n,a){var i=Math.sin(a*=Ct),o=Math.cos(a),l=m((n*=Ct)-t),s=Math.cos(l);mn+=Math.atan2(Math.sqrt((l=o*Math.sin(l))*l+(l=r*i-e*o*s)*l),e*i+r*o*s),t=n,e=i,r=o}Vn.point=function(a,i){t=a*Ct,e=Math.sin(i*=Ct),r=Math.cos(i),Vn.point=n},Vn.lineEnd=function(){Vn.point=Vn.lineEnd=N}},lineEnd:N,polygonStart:N,polygonEnd:N};function Un(t,e){function r(e,r){var n=Math.cos(e),a=Math.cos(r),i=t(n*a);return[i*a*Math.sin(e),i*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),a=e(n),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,n*o),Math.asin(n&&r*i/n)]},r}var Gn=Un(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sn(Gn)}).raw=Gn;var Zn=Un(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},P);function Yn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Mt/4+t/2)},a=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),i=r*Math.pow(n(t),a)/a;if(!a)return Jn;function o(t,e){i>0?e<-St+kt&&(e=-St+kt):e>St-kt&&(e=St-kt);var r=i/Math.pow(n(e),a);return[r*Math.sin(a*t),i-r*Math.cos(a*t)]}return o.invert=function(t,e){var r=i-e,n=Pt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(i/n,1/a))-St]},o}function Xn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),a=r/n+t;if(m(n)1&&Dt(t[r[n-2]],t[r[n-1]],t[a])<=0;)--n;r[n++]=a}return r.slice(0,n)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sn(Kn)}).raw=Kn,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=Qn(ta),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,r=ra;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,a=ve(e),i=ve(r),o=t.length,l=[],s=[];for(n=0;n=0;--n)p.push(t[l[c[n]][2]]);for(n=+f;nkt)l=l.L;else{if(!((a=i-wa(l,o))>kt)){n>-kt?(e=l.P,r=l):a>-kt?(e=l,r=l.N):e=r=l;break}if(!l.R){e=l;break}l=l.R}var s=ya(t);if(fa.insert(e,s),e||r){if(e===r)return La(e),r=ya(e.site),fa.insert(s,r),s.edge=r.edge=Oa(e.site,s.site),Aa(e),void Aa(r);if(r){La(e),La(r);var c=e.site,u=c.x,f=c.y,d=t.x-u,p=t.y-f,h=r.site,g=h.x-u,v=h.y-f,y=2*(d*v-p*g),m=d*d+p*p,x=g*g+v*v,b={x:(v*m-p*x)/y+u,y:(d*x-g*m)/y+f};Pa(r.edge,c,h,b),s.edge=Oa(c,t,null,b),r.edge=Oa(t,h,null,b),Aa(e),Aa(r)}else s.edge=Oa(e.site,s.site)}}function _a(t,e){var r=t.site,n=r.x,a=r.y,i=a-e;if(!i)return n;var o=t.P;if(!o)return-1/0;var l=(r=o.site).x,s=r.y,c=s-e;if(!c)return l;var u=l-n,f=1/i-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-i/2)))/f+n:(n+l)/2}function wa(t,e){var r=t.N;if(r)return _a(r,e);var n=t.site;return n.y===e?n.x:1/0}function ka(t){this.site=t,this.edges=[]}function Ta(t,e){return e.angle-t.angle}function Ma(){Ea(this),this.x=this.y=this.arc=this.site=this.cy=null}function Aa(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,a=t.site,i=r.site;if(n!==i){var o=a.x,l=a.y,s=n.x-o,c=n.y-l,u=i.x-o,f=2*(s*(v=i.y-l)-c*u);if(!(f>=-Tt)){var d=s*s+c*c,p=u*u+v*v,h=(v*d-c*p)/f,g=(s*p-u*d)/f,v=g+l,y=ga.pop()||new Ma;y.arc=t,y.site=a,y.x=h+o,y.y=v+Math.sqrt(h*h+g*g),y.cy=v,t.circle=y;for(var m=null,x=pa._;x;)if(y.y=l)return;if(d>h){if(i){if(i.y>=c)return}else i={x:v,y:s};r={x:v,y:c}}else{if(i){if(i.y1)if(d>h){if(i){if(i.y>=c)return}else i={x:(s-a)/n,y:s};r={x:(c-a)/n,y:c}}else{if(i){if(i.y=l)return}else i={x:o,y:n*o+a};r={x:l,y:n*l+a}}else{if(i){if(i.xkt||m(a-r)>kt)&&(l.splice(o,0,new Da((y=i.site,x=u,b=m(n-f)kt?{x:f,y:m(e-f)kt?{x:m(r-h)kt?{x:d,y:m(e-d)kt?{x:m(r-p)=r&&c.x<=a&&c.y>=n&&c.y<=o?[[r,o],[a,o],[a,n],[r,n]]:[]).point=t[l]}),e}function l(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/kt)*kt,y:Math.round(a(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Fa(l(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fa(l(t)).cells.forEach(function(r,n){for(var a,i,o,l,s=r.site,c=r.edges.sort(Ta),u=-1,f=c.length,d=c[f-1].edge,p=d.l===s?d.r:d.l;++ui&&(a=e.slice(i,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(n=n[0])?l[o]?l[o]+=n:l[++o]=n:(l[++o]=null,s.push({i:o,x:Ga(r,n)})),i=Xa.lastIndex;return ig&&(g=s.x),s.y>v&&(v=s.y),c.push(s.x),u.push(s.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-h;function T(t,e,r,n,a,i,o,l){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var s=t.x,c=t.y;if(null!=s)if(m(s-r)+m(c-n)<.01)M(t,e,r,n,a,i,o,l);else{var u=t.point;t.x=t.y=t.point=null,M(t,u,s,c,a,i,o,l),M(t,e,r,n,a,i,o,l)}else t.x=r,t.y=n,t.point=e}else M(t,e,r,n,a,i,o,l)}function M(t,e,r,n,a,i,o,l){var s=.5*(a+o),c=.5*(i+l),u=r>=s,f=n>=c,d=f<<1|u;t.leaf=!1,u?a=s:o=s,f?i=c:l=c,T(t=t.nodes[d]||(t.nodes[d]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}}),e,r,n,a,i,o,l)}w>k?v=h+w:g=p+k;var A={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}};if(A.visit=function(t){!function t(e,r,n,a,i,o){if(!e(r,n,a,i,o)){var l=.5*(n+i),s=.5*(a+o),c=r.nodes;c[0]&&t(e,c[0],n,a,l,s),c[1]&&t(e,c[1],l,a,i,s),c[2]&&t(e,c[2],n,s,l,o),c[3]&&t(e,c[3],l,s,i,o)}}(t,A,p,h,g,v)},A.find=function(t){return function(t,e,r,n,a,i,o){var l,s=1/0;return function t(c,u,f,d,p){if(!(u>i||f>o||d=_)<<1|e>=b,k=w+4;w=0&&!(n=t.interpolators[a](e,r)););return n}function Ja(t,e){var r,n=[],a=[],i=t.length,o=e.length,l=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function ii(t){return 1-Math.cos(t*St)}function oi(t){return Math.pow(2,10*(t-1))}function li(t){return 1-Math.sqrt(1-t*t)}function si(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ci(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ui(t){var e,r,n,a=[t.a,t.b],i=[t.c,t.d],o=di(a),l=fi(a,i),s=di(((e=i)[0]+=(n=-l)*(r=a)[0],e[1]+=n*r[1],e))||0;a[0]*i[1]=0?t.slice(0,n):t,i=n>=0?t.slice(n+1):"in";return a=$a.get(a)||Qa,i=Ka.get(i)||P,e=i(a.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,a=e.c,i=e.l,o=r.h-n,l=r.c-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.c:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Yt(n+o*t,a+l*t,i+s*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,a=e.s,i=e.l,o=r.h-n,l=r.s-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.s:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ut(n+o*t,a+l*t,i+s*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,a=e.a,i=e.b,o=r.l-n,l=r.a-a,s=r.b-i;return function(t){return te(n+o*t,a+l*t,i+s*t)+""}},t.interpolateRound=ci,t.transform=function(e){var r=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ui(e?e.matrix:pi)})(e)},ui.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pi={a:1,b:0,c:0,d:1,e:0,f:0};function hi(t){return t.length?t.pop()+",":""}function gi(e,r){var n=[],a=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push("translate(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,a),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(hi(r)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&r.push(hi(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,a),function(t,e,r,n){t!==e?n.push({i:r.push(hi(r)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&r.push(hi(r)+"skewX("+e+")")}(e.skew,r.skew,n,a),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push(hi(r)+"scale(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(hi(r)+"scale("+e+")")}(e.scale,r.scale,n,a),e=r=null,function(t){for(var e,r=-1,i=a.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,s.end({type:"end",alpha:n=0})):t>0&&(s.start({type:"start",alpha:n=t}),e=Te(l.tick)),l):n},l.start=function(){var t,e,r,n=y.length,s=m.length,u=c[0],h=c[1];for(t=0;t=0;)r.push(a[n])}function Ci(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(u=c[s]),u.parent=i,u.depth=i.depth+1;r&&(i.value=0),i.children=c}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Ci(a,function(e){var n,a;t&&(n=e.children)&&n.sort(t),r&&(a=e.parent)&&(a.value+=e.value)}),l}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Si(t,function(t){t.children&&(t.value=0)}),Ci(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var a=e.call(this,t,n);return function t(e,r,n,a){var i=e.children;if(e.x=r,e.y=e.depth*a,e.dx=n,e.dy=a,i&&(o=i.length)){var o,l,s,c=-1;for(n=e.value?n/e.value:0;++cl&&(l=n),o.push(n)}for(r=0;ra&&(n=r,a=e);return n}function Vi(t){return t.reduce(Ui,0)}function Ui(t,e){return t+e[1]}function Gi(t,e){return Zi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Zi(t,e){for(var r=-1,n=+t[0],a=(t[1]-n)/e,i=[];++r<=e;)i[r]=a*r+n;return i}function Yi(e){return[t.min(e),t.max(e)]}function Xi(t,e){return t.value-e.value}function Wi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function Qi(t,e){var r=e.x-t.x,n=e.y-t.y,a=t.r+e.r;return.999*a*a>r*r+n*n}function $i(t){if((e=t.children)&&(s=e.length)){var e,r,n,a,i,o,l,s,c=1/0,u=-1/0,f=1/0,d=-1/0;if(e.forEach(Ki),(r=e[0]).x=-r.r,r.y=0,x(r),s>1&&((n=e[1]).x=n.r,n.y=0,x(n),s>2))for(eo(r,n,a=e[2]),x(a),Wi(r,a),r._pack_prev=a,Wi(a,n),n=r._pack_next,i=3;i0)for(o=-1;++o=f[0]&&s<=f[1]&&((l=c[t.bisect(d,s,1,h)-1]).y+=g,l.push(i[o]));return c}return i.value=function(t){return arguments.length?(r=t,i):r},i.range=function(t){return arguments.length?(n=ve(t),i):n},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Zi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Xi),n=0,a=[1,1];function i(t,i){var o=r.call(this,t,i),l=o[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,Ci(l,function(t){t.r=+u(t.value)}),Ci(l,$i),n){var f=n*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;Ci(l,function(t){t.r+=f}),Ci(l,$i),Ci(l,function(t){t.r-=f})}return function t(e,r,n,a){var i=e.children;e.x=r+=a*e.x;e.y=n+=a*e.y;e.r*=a;if(i)for(var o=-1,l=i.length;++op.x&&(p=t),t.depth>h.depth&&(h=t)});var g=r(d,p)/2-d.x,v=n[0]/(p.x+r(p,d)/2+g),y=n[1]/(h.depth||1);Si(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*y})}return c}function o(t){var e=t.children,n=t.parent.children,a=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+r(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+r(t._,a._));t.parent.A=function(t,e,n){if(e){for(var a,i=t,o=t,l=e,s=i.parent.children[0],c=i.m,u=o.m,f=l.m,d=s.m;l=ao(l),i=no(i),l&&i;)s=no(s),(o=ao(o)).a=t,(a=l.z+f-i.z-c+r(l._,i._))>0&&(io(oo(l,t,n),t,a),c+=a,u+=a),f+=l.m,c+=i.m,d+=s.m,u+=o.m;l&&!ao(o)&&(o.t=l,o.m+=f-u),i&&!no(s)&&(s.t=i,s.m+=c-d,n=t)}return n}(t,a,t.parent.A||n[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=n[0],t.y=t.depth*n[1]}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t)?s:null,i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null==(n=t)?null:s,i):a?n:null},Li(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],a=!1;function i(i,o){var l,s=e.call(this,i,o),c=s[0],u=0;Ci(c,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=l?u+=r(e,l):0,e.y=0,l=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(c),d=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(c),p=f.x-r(f,d)/2,h=d.x+r(d,f)/2;return Ci(c,a?function(t){t.x=(t.x-c.x)*n[0],t.y=(c.y-t.y)*n[1]}:function(t){t.x=(t.x-p)/(h-p)*n[0],t.y=(1-(c.y?t.y/c.y:1))*n[1]}),s}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t),i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null!=(n=t),i):a?n:null},Li(i,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,a=[1,1],i=null,o=lo,l=!1,s="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var r,n,a=-1,i=t.length;++a0;)l.push(r=c[a-1]),l.area+=r.area,"squarify"!==s||(n=p(l,g))<=d?(c.pop(),d=n):(l.area-=l.pop().area,h(l,g,i,!1),g=Math.min(i.dx,i.dy),l.length=l.area=0,d=1/0);l.length&&(h(l,g,i,!0),l.length=l.area=0),e.forEach(f)}}function d(t){var e=t.children;if(e&&e.length){var r,n=o(t),a=e.slice(),i=[];for(u(a,n.dx*n.dy/t.value),i.area=0;r=a.pop();)i.push(r),i.area+=r.area,null!=r.z&&(h(i,r.z?n.dx:n.dy,n,!a.length),i.length=i.area=0);e.forEach(d)}}function p(t,e){for(var r,n=t.area,a=0,i=1/0,o=-1,l=t.length;++oa&&(a=r));return e*=e,(n*=n)?Math.max(e*a*c/n,n/(e*i*c)):1/0}function h(t,e,r,a){var i,o=-1,l=t.length,s=r.x,c=r.y,u=e?n(t.area/e):0;if(e==r.dx){for((a||u>r.dy)&&(u=r.dy);++or.dx)&&(u=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,l=a?yi:vi;return i=t(e,r,l,n),o=t(r,e,l,Wa),s}function s(t){return i(t)}s.invert=function(t){return o(t)};s.domain=function(t){return arguments.length?(e=t.map(Number),l()):e};s.range=function(t){return arguments.length?(r=t,l()):r};s.rangeRound=function(t){return s.range(t).interpolate(ci)};s.clamp=function(t){return arguments.length?(a=t,l()):a};s.interpolate=function(t){return arguments.length?(n=t,l()):n};s.ticks=function(t){return bo(e,t)};s.tickFormat=function(t,r){return _o(e,t,r)};s.nice=function(t){return mo(e,t),l()};s.copy=function(){return t(e,r,n,a)};return l()}([0,1],[0,1],Wa,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function l(t){return a?Math.pow(n,t):-Math.pow(n,-t)}function s(t){return r(o(t))}s.invert=function(t){return l(r.invert(t))};s.domain=function(t){return arguments.length?(a=t[0]>=0,r.domain((i=t.map(Number)).map(o)),s):i};s.base=function(t){return arguments.length?(n=+t,r.domain(i.map(o)),s):n};s.nice=function(){var t=po(i.map(o),a?Math:Mo);return r.domain(t),i=t.map(l),s};s.ticks=function(){var t=co(i),e=[],r=t[0],s=t[1],c=Math.floor(o(r)),u=Math.ceil(o(s)),f=n%1?2:n;if(isFinite(u-c)){if(a){for(;c0;d--)e.push(l(c)*d);for(c=0;e[c]s;u--);e=e.slice(c,u)}return e};s.tickFormat=function(e,r){if(!arguments.length)return To;arguments.length<2?r=To:"function"!=typeof r&&(r=t.format(r));var a=Math.max(1,n*e/s.ticks().length);return function(t){var e=t/l(Math.round(o(t)));return e*n0?a[t-1]:r[0],tf?0:1;if(c=Lt)return s(c,p)+(l?s(l,1-p):"")+"Z";var h,g,v,y,m,x,b,_,w,k,T,M,A=0,L=0,S=[];if((y=(+o.apply(this,arguments)||0)/2)&&(v=n===Do?Math.sqrt(l*l+c*c):+n.apply(this,arguments),p||(L*=-1),c&&(L=Et(v/c*Math.sin(y))),l&&(A=Et(v/l*Math.sin(y)))),c){m=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var C=Math.abs(f-u-2*L)<=Mt?0:1;if(L&&Fo(m,x,b,_)===p^C){var O=(u+f)/2;m=c*Math.cos(O),x=c*Math.sin(O),b=_=null}}else m=x=0;if(l){w=l*Math.cos(f-A),k=l*Math.sin(f-A),T=l*Math.cos(u+A),M=l*Math.sin(u+A);var P=Math.abs(u-f+2*A)<=Mt?0:1;if(A&&Fo(w,k,T,M)===1-p^P){var D=(u+f)/2;w=l*Math.cos(D),k=l*Math.sin(D),T=M=null}}else w=k=0;if(d>kt&&(h=Math.min(Math.abs(c-l)/2,+r.apply(this,arguments)))>.001){g=l0?0:1}function Bo(t,e,r,n,a){var i=t[0]-e[0],o=t[1]-e[1],l=(a?n:-n)/Math.sqrt(i*i+o*o),s=l*o,c=-l*i,u=t[0]+s,f=t[1]+c,d=e[0]+s,p=e[1]+c,h=(u+d)/2,g=(f+p)/2,v=d-u,y=p-f,m=v*v+y*y,x=r-n,b=u*p-d*f,_=(y<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-b*b)),w=(b*y-v*_)/m,k=(-b*v-y*_)/m,T=(b*y+v*_)/m,M=(-b*v+y*_)/m,A=w-h,L=k-g,S=T-h,C=M-g;return A*A+L*L>S*S+C*C&&(w=T,k=M),[[w-s,k-c],[w*r/x,k*r/x]]}function jo(t){var e=ea,r=ra,n=Zr,a=qo,i=a.key,o=.7;function l(i){var l,s=[],c=[],u=-1,f=i.length,d=ve(e),p=ve(r);function h(){s.push("M",a(t(c),o))}for(;++u1&&a.push("H",n[0]);return a.join("")},"step-before":Uo,"step-after":Go,basis:Xo,"basis-open":function(t){if(t.length<4)return qo(t);var e,r=[],n=-1,a=t.length,i=[0],o=[0];for(;++n<3;)e=t[n],i.push(e[0]),o.push(e[1]);r.push(Wo($o,i)+","+Wo($o,o)),--n;for(;++n9&&(a=3*e/Math.sqrt(a),o[l]=a*r,o[l+1]=a*n));l=-1;for(;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+o[l]*o[l])),i.push([a||0,o[l]*a||0]);return i}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Vo(t){return t.join("L")+"Z"}function Uo(t){for(var e=0,r=t.length,n=t[0],a=[n[0],",",n[1]];++e1){l=e[1],i=t[s],s++,n+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-l[0])+","+(i[1]-l[1])+","+i[0]+","+i[1];for(var c=2;cMt)+",1 "+e}function s(t,e,r,n){return"Q 0,0 "+n}return i.radius=function(t){return arguments.length?(r=ve(t),i):r},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(n=ve(t),i):n},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Hn,e=qn,r=al;function n(n,a){var i=t.call(this,n,a),o=e.call(this,n,a),l=(i.y+o.y)/2,s=[i,{x:i.x,y:l},{x:o.x,y:l},o];return"M"+(s=s.map(r))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=al,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-St;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=ol,e=il;function r(r,n){return(sl.get(t.call(this,r,n))||ll)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var sl=t.map({circle:ll,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*ul)),r=e*ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=sl.keys();var cl=Math.sqrt(3),ul=Math.tan(30*Ct);Y.transition=function(t){for(var e,r,n=hl||++yl,a=bl(t),i=[],o=gl||{time:Date.now(),ease:ai,delay:0,duration:250},l=-1,s=this.length;++l0;)c[--d].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[n]:delete t[r],1}f||(i=a.time,o=Te(function(t){var e=f.delay;if(o.t=e+i,e<=t)return d(t-e);o.c=d},0,i),f=u[n]={tween:new b,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++u.count)}vl.call=Y.call,vl.empty=Y.empty,vl.node=Y.node,vl.size=Y.size,t.transition=function(e,r){return e&&e.transition?hl?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vl,vl.select=function(t){var e,r,n,a=this.id,i=this.namespace,o=[];t=X(t);for(var l=-1,s=this.length;++lrect,.s>rect").attr("width",l[1]-l[0])}function g(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function v(){var f,v,y=this,m=t.select(t.event.target),x=n.of(y,arguments),b=t.select(y),_=m.datum(),w=!/^(n|s)$/.test(_)&&a,k=!/^(e|w)$/.test(_)&&i,T=m.classed("extent"),M=xt(y),A=t.mouse(y),L=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(T||(f=null,A[0]-=l[1],A[1]-=s[1],T=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==T&&(A[0]+=l[1],A[1]+=s[1],T=0,F())});if(t.event.changedTouches?L.on("touchmove.brush",O).on("touchend.brush",D):L.on("mousemove.brush",O).on("mouseup.brush",D),b.interrupt().selectAll("*").interrupt(),T)A[0]=l[0]-A[0],A[1]=s[0]-A[1];else if(_){var S=+/w$/.test(_),C=+/^n/.test(_);v=[l[1-S]-A[0],s[1-C]-A[1]],A[0]=l[S],A[1]=s[C]}else t.event.altKey&&(f=A.slice());function O(){var e=t.mouse(y),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),T||(t.event.altKey?(f||(f=[(l[0]+l[1])/2,(s[0]+s[1])/2]),A[0]=l[+(e[0]1?{floor:function(e){for(;l(e=t.floor(e));)e=zl(e-1);return e},ceil:function(e){for(;l(e=t.ceil(e));)e=zl(+e+1);return e}}:t))},a.ticks=function(t,e){var r=co(a.domain()),n=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],zl(+r[1]+1),e<1?1:e)},a.tickFormat=function(){return n},a.copy=function(){return Dl(e.copy(),r,n)},yo(a,e)}function zl(t){return new Date(t)}Sl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Pl:Ol,Pl.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Pl.toString=Ol.toString,ze.second=Ie(function(t){return new Ee(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),ze.seconds=ze.second.range,ze.seconds.utc=ze.second.utc.range,ze.minute=Ie(function(t){return new Ee(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),ze.minutes=ze.minute.range,ze.minutes.utc=ze.minute.utc.range,ze.hour=Ie(function(t){var e=t.getTimezoneOffset()/60;return new Ee(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),ze.hours=ze.hour.range,ze.hours.utc=ze.hour.utc.range,ze.month=Ie(function(t){return(t=ze.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),ze.months=ze.month.range,ze.months.utc=ze.month.utc.range;var El=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Nl=[[ze.second,1],[ze.second,5],[ze.second,15],[ze.second,30],[ze.minute,1],[ze.minute,5],[ze.minute,15],[ze.minute,30],[ze.hour,1],[ze.hour,3],[ze.hour,6],[ze.hour,12],[ze.day,1],[ze.day,2],[ze.week,1],[ze.month,1],[ze.month,3],[ze.year,1]],Rl=Sl.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Zr]]),Il={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(zl)},floor:P,ceil:P};Nl.year=ze.year,ze.scale=function(){return Dl(t.scale.linear(),Nl,Rl)};var Fl=Nl.map(function(t){return[t[0].utc,t[1]]}),Bl=Cl.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Zr]]);function jl(t){return JSON.parse(t.responseText)}function Hl(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Fl.year=ze.year.utc,ze.scale.utc=function(){return Dl(t.scale.linear(),Fl,Bl)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return me(t,"application/json",jl,e)},t.html=function(t,e){return me(t,"text/html",Hl,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],12:[function(t,e,r){(function(n,a){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,l=void 0,s=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(l?l(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,d="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],19:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(l=e,l===window||l===document||l===document.body?n:l.getBoundingClientRect());var l;return r[0]=a-o.left,r[1]=i-o.top,r}},{}],20:[function(t,e,r){var n,a=t("./lib/build-log"),i=t("./lib/epsilon"),o=t("./lib/intersecter"),l=t("./lib/segment-chainer"),s=t("./lib/segment-selector"),c=t("./lib/geojson"),u=!1,f=i();function d(t,e,r){var a=n.segments(t),i=n.segments(e),o=r(n.combine(a,i));return n.polygon(o)}n={buildLog:function(t){return!0===t?u=a():!1===t&&(u=!1),!1!==u&&u.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,u);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,u).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:s.union(t.combined,u),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:s.intersect(t.combined,u),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:s.difference(t.combined,u),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:s.differenceRev(t.combined,u),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:s.xor(t.combined,u),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:l(t.segments,f,u),inverted:t.inverted}},polygonFromGeoJSON:function(t){return c.toPolygon(n,t)},polygonToGeoJSON:function(t){return c.fromPolygon(n,f,t)},union:function(t,e){return d(t,e,n.selectUnion)},intersect:function(t,e){return d(t,e,n.selectIntersect)},difference:function(t,e){return d(t,e,n.selectDifference)},differenceRev:function(t,e){return d(t,e,n.selectDifferenceRev)},xor:function(t,e){return d(t,e,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),e.exports=n},{"./lib/build-log":21,"./lib/epsilon":22,"./lib/geojson":23,"./lib/intersecter":24,"./lib/segment-chainer":26,"./lib/segment-selector":27}],21:[function(t,e,r){e.exports=function(){var t,e=0,r=!1;function n(e,r){return t.list.push({type:e,data:r?JSON.parse(JSON.stringify(r)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return n("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return n("div_seg",{seg:t,pt:e}),n("chop",{seg:t,pt:e})},statusRemove:function(t){return n("pop_seg",{seg:t})},segmentUpdate:function(t){return n("seg_update",{seg:t})},segmentNew:function(t,e){return n("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return n("rem_seg",{seg:t})},tempStatus:function(t,e,r){return n("temp_status",{seg:t,above:e,below:r})},rewind:function(t){return n("rewind",{seg:t})},status:function(t,e,r){return n("status",{seg:t,above:e,below:r})},vert:function(e){return e===r?t:(r=e,n("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),n("log",{txt:t})},reset:function(){return n("reset")},selected:function(t){return n("selected",{segs:t})},chainStart:function(t){return n("chain_start",{seg:t})},chainRemoveHead:function(t,e){return n("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return n("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return n("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return n("chain_match",{index:t})},chainClose:function(t){return n("chain_close",{index:t})},chainAddHead:function(t,e){return n("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return n("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return n("chain_con",{index1:t,index2:e})},chainReverse:function(t){return n("chain_rev",{index:t})},chainJoin:function(t,e){return n("chain_join",{index1:t,index2:e})},done:function(){return n("done")}}}},{}],22:[function(t,e,r){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,r,n){var a=r[0],i=r[1],o=n[0],l=n[1],s=e[0];return(o-a)*(e[1]-i)-(l-i)*(s-a)>=-t},pointBetween:function(e,r,n){var a=e[1]-r[1],i=n[0]-r[0],o=e[0]-r[0],l=n[1]-r[1],s=o*i+a*l;return!(s-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-a>t&&(i-c)*(a-u)/(o-u)+c-n>t&&(l=!l),i=c,o=u}return l}};return e}},{}],23:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),a=1;a0})}function u(t,n){var a=t.seg,i=n.seg,o=a.start,l=a.end,c=i.start,u=i.end;r&&r.checkIntersection(a,i);var f=e.linesIntersect(o,l,c,u);if(!1===f){if(!e.pointsCollinear(o,l,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(l,c))return!1;var d=e.pointsSame(o,c),p=e.pointsSame(l,u);if(d&&p)return n;var h=!d&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(l,c,u);if(d)return g?s(n,l):s(t,u),n;h&&(p||(g?s(n,l):s(t,u)),s(n,o))}else 0===f.alongA&&(-1===f.alongB?s(t,c):0===f.alongB?s(t,f.pt):1===f.alongB&&s(t,u)),0===f.alongB&&(-1===f.alongA?s(n,o):0===f.alongA?s(n,f.pt):1===f.alongA&&s(n,l));return!1}for(var f=[];!i.isEmpty();){var d=i.getHead();if(r&&r.vert(d.pt[0]),d.isStart){r&&r.segmentNew(d.seg,d.primary);var p=c(d),h=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(h){var t=u(d,h);if(t)return t}return!!g&&u(d,g)}r&&r.tempStatus(d.seg,!!h&&h.seg,!!g&&g.seg);var y,m,x=v();if(x)t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=d.seg.myFill,r&&r.segmentUpdate(x.seg),d.other.remove(),d.remove();if(i.getHead()!==d){r&&r.rewind(d.seg);continue}t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=g?g.seg.myFill.above:a,d.seg.myFill.above=m?!d.seg.myFill.below:d.seg.myFill.below):null===d.seg.otherFill&&(y=g?d.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:d.primary?o:a,d.seg.otherFill={above:y,below:y}),r&&r.status(d.seg,!!h&&h.seg,!!g&&g.seg),d.other.status=p.insert(n.node({ev:d}))}else{var b=d.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(l.exists(b.prev)&&l.exists(b.next)&&u(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!d.primary){var _=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=_}f.push(d.seg)}i.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,a,i,o=t[t.length-1],s=0;s1)for(var r=1;r1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=O(t,360),e=O(e,100),r=O(r,100),0===e)n=a=i=r;else{var l=r<.5?r*(1+e):r+e-r*e,s=2*r-l;n=o(s,l,t+1/3),a=o(s,l,t),i=o(s,l,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(e.h,s,u),f=!0,d="hsl"),e.hasOwnProperty("a")&&(i=e.a));var p,h,g;return i=C(i),{ok:f,format:e.format||d,r:o(255,l(a.r,0)),g:o(255,l(a.g,0)),b:o(255,l(a.b,0)),a:i}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=i(100*this._a)/100,this._format=s.format||u.format,this._gradientType=s.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=u.ok,this._tc_id=a++}function u(t,e,r){t=O(t,255),e=O(e,255),r=O(r,255);var n,a,i=l(t,e,r),s=o(t,e,r),c=(i+s)/2;if(i==s)n=a=0;else{var u=i-s;switch(a=c>.5?u/(2-i-s):u/(i+s),i){case t:n=(e-r)/u+(e>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(c(n));return i}function A(t,e){e=e||6;for(var r=c(t).toHsv(),n=r.h,a=r.s,i=r.v,o=[],l=1/e;e--;)o.push(c({h:n,s:a,v:i})),i=(i+l)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,a=this.toRgb();return e=a.r/255,r=a.g/255,n=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=C(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return d(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,a){var o=[z(i(t).toString(16)),z(i(e).toString(16)),z(i(r).toString(16)),z(N(n))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*O(this._r,255))+"%",g:i(100*O(this._g,255))+"%",b:i(100*O(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%)":"rgba("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[d(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=c(t);r="#"+p(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(T,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:E(t[n]));t=r}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:s(),g:s(),b:s()})},c.mix=function(t,e,r){r=0===r?0:r||50;var n=c(t).toRgb(),a=c(e).toRgb(),i=r/100;return c({r:(a.r-n.r)*i+n.r,g:(a.g-n.g)*i+n.g,b:(a.b-n.b)*i+n.b,a:(a.a-n.a)*i+n.a})},c.readability=function(e,r){var n=c(e),a=c(r);return(t.max(n.getLuminance(),a.getLuminance())+.05)/(t.min(n.getLuminance(),a.getLuminance())+.05)},c.isReadable=function(t,e,r){var n,a,i=c.readability(t,e);switch(a=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},c.mostReadable=function(t,e,r){var n,a,i,o,l=null,s=0;a=(r=r||{}).includeFallbackColors,i=r.level,o=r.size;for(var u=0;us&&(s=n,l=c(e[u]));return c.isReadable(t,l,{level:i,size:o})||!a?l:(r.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],r))};var L=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=c.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(L);function C(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function O(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,l(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function P(t){return o(1,l(0,t))}function D(t){return parseInt(t,16)}function z(t){return 1==t.length?"0"+t:""+t}function E(t){return t<=1&&(t=100*t+"%"),t}function N(e){return t.round(255*parseFloat(e)).toString(16)}function R(t){return D(t)/255}var I,F,B,j=(F="[\\s|\\(]+("+(I="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",B="[\\s|\\(]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",{CSS_UNIT:new RegExp(I),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+B),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+B),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+B),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function H(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],30:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],31:[function(t,e,r){"use strict";var n=t("./arrow_paths"),a=t("../../plots/font_attributes"),i=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:a({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",i.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",i.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:a({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":198,"../../plots/cartesian/constants":214,"../../plots/font_attributes":235,"./arrow_paths":30}],32:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=a.getFromId(t,e.xref),n=a.getFromId(t,e.yref);e._extremes={},r&&l(e,r),n&&l(e,n)})}function l(t,e){var r,n=e._id,i=n.charAt(0),o=t[i],l=t["a"+i],s=t[i+"ref"],c=t["a"+i+"ref"],u=t["_"+i+"padplus"],f=t["_"+i+"padminus"],d={x:1,y:-1}[i]*t[i+"shift"],p=3*t.arrowsize*t.arrowwidth||0,h=p+d,g=p-d,v=3*t.startarrowsize*t.arrowwidth||0,y=v+d,m=v-d;if(c===s){var x=a.findExtremes(e,[e.r2c(o)],{ppadplus:h,ppadminus:g}),b=a.findExtremes(e,[e.r2c(l)],{ppadplus:Math.max(u,y),ppadminus:Math.max(f,m)});r={min:[x.min[0],b.min[0]],max:[x.max[0],b.max[0]]}}else y=l?y+l:y,m=l?m-l:m,r=a.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(u,h,y),ppadminus:Math.max(f,g,m)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([i,o],t)}},{"../../lib":164,"../../plots/cartesian/axes":208,"./draw":37}],33:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,a,i,o,s,c,u=t._fullLayout.annotations,f=[],d=[],p=[],h=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,l,s=o(t,e),c=s.on,u=s.off.concat(s.explicitOff),f={},d=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var V=!1,U=["x","y"],G=0;G1)&&(K===$?((st=tt.r2fraction(e["a"+Q]))<0||st>1)&&(V=!0):V=!0),Z=tt._offset+tt.r2p(e[Q]),W=.5}else"x"===Q?(X=e[Q],Z=b.l+b.w*X):(X=1-e[Q],Z=b.t+b.h*X),W=e.showarrow?.5:X;if(e.showarrow){lt.head=Z;var ct=e["a"+Q];J=rt*q(.5,e.xanchor)-nt*q(.5,e.yanchor),K===$?(lt.tail=tt._offset+tt.r2p(ct),Y=J):(lt.tail=Z+ct,Y=J+ct),lt.text=lt.tail+J;var ut=x["x"===Q?"width":"height"];if("paper"===$&&(lt.head=o.constrain(lt.head,1,ut-1)),"pixel"===K){var ft=-Math.max(lt.tail-3,lt.text),dt=Math.min(lt.tail+3,lt.text)-ut;ft>0?(lt.tail+=ft,lt.text+=ft):dt>0&&(lt.tail-=dt,lt.text-=dt)}lt.tail+=ot,lt.head+=ot}else Y=J=at*q(W,it),lt.text=Z+J;lt.text+=ot,J+=ot,Y+=ot,e["_"+Q+"padplus"]=at/2+Y,e["_"+Q+"padminus"]=at/2-Y,e["_"+Q+"size"]=at,e["_"+Q+"shift"]=J}if(t._dragging||!V){var pt=0,ht=0;if("left"!==e.align&&(pt=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(ht=(D-m)*("middle"===e.valign?.5:1)),u)n.select("svg").attr({x:R+pt-1,y:R+ht}).call(c.setClipUrl,F?A:null);else{var gt=R+ht-h.top,vt=R+pt-h.left;H.call(f.positionText,vt,gt).call(c.setClipUrl,F?A:null)}B.select("rect").call(c.setRect,R,R,w,D),I.call(c.setRect,E/2,E/2,N-E,j-E),z.call(c.setTranslate,Math.round(L.x.text-N/2),Math.round(L.y.text-j/2)),O.attr({transform:"rotate("+S+","+L.x.text+","+L.y.text+")"});var yt,mt=function(r,n){C.selectAll(".annotation-arrow-g").remove();var u=L.x.head,f=L.y.head,d=L.x.tail+r,h=L.y.tail+n,y=L.x.text+r,m=L.y.text+n,x=o.rotationXYMatrix(S,y,m),w=o.apply2DTransform(x),A=o.apply2DTransform2(x),P=+I.attr("width"),D=+I.attr("height"),E=y-.5*P,N=E+P,R=m-.5*D,F=R+D,B=[[E,R,E,F],[E,F,N,F],[N,F,N,R],[N,R,E,R]].map(A);if(!B.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){B.forEach(function(t){var e=o.segmentsIntersect(d,h,u,f,t[0],t[1],t[2],t[3]);e&&(d=e.x,h=e.y)});var j=e.arrowwidth,H=e.arrowcolor,q=e.arrowside,V=C.append("g").style({opacity:s.opacity(H)}).classed("annotation-arrow-g",!0),U=V.append("path").attr("d","M"+d+","+h+"L"+u+","+f).style("stroke-width",j+"px").call(s.stroke,s.rgb(H));if(g(U,q,e),_.annotationPosition&&U.node().parentNode&&!i){var G=u,Z=f;if(e.standoff){var Y=Math.sqrt(Math.pow(u-d,2)+Math.pow(f-h,2));G+=e.standoff*(d-u)/Y,Z+=e.standoff*(h-f)/Y}var X,W,J=V.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(d-G)+","+(h-Z),transform:"translate("+G+","+Z+")"}).style("stroke-width",j+6+"px").call(s.stroke,"rgba(0,0,0,0)").call(s.fill,"rgba(0,0,0,0)");p.init({element:J.node(),gd:t,prepFn:function(){var t=c.getTranslate(z);X=t.x,W=t.y,l&&l.autorange&&k(l._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(X,W),a=n[0]+t,i=n[1]+r;z.call(c.setTranslate,a,i),T("x",l?l.p2r(l.r2p(e.x)+t):e.x+t/b.w),T("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/b.h),e.axref===e.xref&&T("ax",l.p2r(l.r2p(e.ax)+t)),e.ayref===e.yref&&T("ay",v.p2r(v.r2p(e.ay)+r)),V.attr("transform","translate("+t+","+r+")"),O.attr({transform:"rotate("+S+","+a+","+i+")"})},doneFn:function(){a.call("relayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&mt(0,0),P)p.init({element:z.node(),gd:t,prepFn:function(){yt=O.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?T("ax",l.p2r(l.r2p(e.ax)+t)):T("ax",e.ax+t),e.ayref===e.yref?T("ay",v.p2r(v.r2p(e.ay)+r)):T("ay",e.ay+r),mt(t,r);else{if(i)return;var a,o;if(l)a=l.p2r(l.r2p(e.x)+t);else{var s=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-s/2;a=p.align(c+t/b.w,s,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-r/b.h,u,0,1,e.yanchor)}T("x",a),T("y",o),l&&v||(n=p.getCursor(l?.5:a,v?.5:o,e.xanchor,e.yanchor))}O.attr({transform:"translate("+t+","+r+")"+yt}),d(z,n)},doneFn:function(){d(z),a.call("relayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else z.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,y=f.backoff*p+r.standoff,m=d.backoff*h+r.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},l={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-l.x,b=o.y-l.y;if(c=(s=Math.atan2(b,x))+Math.PI,y&&m&&y+m>Math.sqrt(x*x+b*b))return void P();if(y){if(y*y>x*x+b*b)return void P();var _=y*Math.cos(s),w=y*Math.sin(s);l.x+=_,l.y+=w,t.attr({x2:l.x,y2:l.y})}if(m){if(m*m>x*x+b*b)return void P();var k=m*Math.cos(s),T=m*Math.sin(s);o.x-=k,o.y-=T,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var M=u.getTotalLength(),A="";if(M1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+l+'"]').remove():(s._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(s.x)*r[0],e.yaxis.r2l(s.y)*r[1],e.zaxis.r2l(s.z)*r[2]]),n(t.graphDiv,s,l,t.id,s._xa,s._ya))}}},{"../../plots/gl3d/project":238,"../annotations/draw":37}],44:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var i=r.attrRegex,o=Object.keys(t),l=0;l=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var l=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+l+", "+n[3]+")":"rgb("+l+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(n(t))},i.opacity=function(t){return t?n(t).getAlpha():0},i.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},i.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var a=n(e||s).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-r.a)+r.r*r.a,g:i.g*(1-r.a)+r.g*r.a,b:i.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},i.contrast=function(t,e,r){var a=n(t);return 1!==a.getAlpha()&&(a=n(i.combine(t,s))),(a.isDark()?e?a.lighten(e):s:r?a.darken(r):l).toString()},i.stroke=function(t,e){var r=n(e);t.style({stroke:i.tinyRGB(r),"stroke-opacity":r.getAlpha()})},i.fill=function(t,e){var r=n(e);t.style({fill:i.tinyRGB(r),"fill-opacity":r.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,r,n,a,o=Object.keys(t);for(e=0;e0?L>=E:L<=E));S++)L>R&&L0?L>=E:L<=E));S++)L>C[0]&&L1){var it=Math.pow(10,Math.floor(Math.log(at)/Math.LN10));rt*=it*c.roundUp(at/it,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(tt.tick0=0)}tt.dtick=rt}tt.domain=[J+Y,J+U-Y],tt.setScale();var ot=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(T.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(T.cbbg,!0),t.append("g").classed(T.cbfills,!0),t.append("g").classed(T.cblines,!0),t.append("g").classed(T.cbaxis,!0).classed(T.crisp,!0),t.append("g").classed(T.cbtitleunshift,!0).append("g").classed(T.cbtitle,!0),t.append("rect").classed(T.cboutline,!0),t.select(".cbtitle").datum(0)})});ot.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var lt=ot.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")");tt._axislayer=ot.select(".cbaxis");var st=0;if(-1!==["top","bottom"].indexOf(r.titleside)){var ct,ut=k.l+(r.x+G)*k.w,ft=tt.titlefont.size;ct="top"===r.titleside?(1-(J+U-Y))*k.h+k.t+3+.75*ft:(1-(J+Y))*k.h+k.t-3-.25*ft,yt(tt._id+"title",{attributes:{x:ut,y:ct,"text-anchor":"start"}})}var dt,pt,ht,gt=c.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.titleside)){var i=ot.select(".cbtitle"),o=i.select("text"),s=[-r.outlinewidth/2,r.outlinewidth/2],u=i.select(".h"+tt._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),u?(st=d.bBox(u).height)>f&&(s[1]-=(st-f)/2):o.node()&&!o.classed(T.jsPlaceholder)&&(st=d.bBox(o.node()).height),st){if(st+=5,"top"===r.titleside)tt.domain[1]-=st/k.h,s[1]*=-1;else{tt.domain[0]+=st/k.h;var p=g.lineCount(o);s[1]+=(1-p)*f}i.attr("transform","translate("+s+")"),tt.setScale()}}ot.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-tt.domain[1]))+")"),tt._axislayer.attr("transform","translate(0,"+Math.round(-k.t)+")");var h=ot.select(".cbfills").selectAll("rect.cbfill").data(P);h.enter().append("rect").classed(T.cbfill,!0).style("stroke","none"),h.exit().remove();var m=C.map(tt.c2p).map(Math.round).sort(function(t,e){return t-e});h.each(function(i,o){var l=[0===o?C[0]:(P[o]+P[o-1])/2,o===P.length-1?C[1]:(P[o]+P[o+1])/2].map(tt.c2p).map(Math.round);l[1]=c.constrain(l[1]+(l[1]>l[0])?1:-1,m[0],m[1]);var s=n.select(this).attr({x:X,width:Math.max(H,2),y:n.min(l),height:Math.max(n.max(l)-n.min(l),2)});if(r.fillgradient)d.gradient(s,t,e,"vertical",r.fillgradient,"fill");else{var u=z(i).replace("e-","");s.attr("fill",a(u).toHexString())}});var x=ot.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?O:[]);return x.enter().append("path").classed(T.cbline,!0),x.exit().remove(),x.each(function(t){n.select(this).attr("d","M"+X+","+(Math.round(tt.c2p(t))+r.line.width/2%1)+"h"+H).call(d.lineGroupStyle,r.line.width,D(t),r.line.dash)}),tt._axislayer.selectAll("g."+tt._id+"tick,path").remove(),tt._pos=X+H+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),tt.side="right",c.syncOrAsync([function(){return l.doTicksSingle(t,tt,!0)},function(){if(-1===["top","bottom"].indexOf(r.titleside)){var e=tt.titlefont.size,a=tt._offset+tt._length/2,i=k.l+(tt.position||0)*k.w+("right"===tt.side?10+e*(tt.showticklabels?1:.5):-10-e*(tt.showticklabels?.5:0));yt("h"+tt._id+"title",{avoid:{selection:n.select(t).selectAll("g."+tt._id+"tick"),side:r.titleside,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var n=H+r.outlinewidth/2+d.bBox(tt._axislayer.node()).width;if((F=lt.select("text")).node()&&!F.classed(T.jsPlaceholder)){var a,o=lt.select(".h"+tt._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(r.titleside)?d.bBox(o).width:d.bBox(lt.node()).right-X-k.l,n=Math.max(n,a)}var l=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,s=Q-$;ot.select(".cbbg").attr({x:X-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:$-Z,width:Math.max(l,2),height:Math.max(s+2*Z,2)}).call(p.fill,r.bgcolor).call(p.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),ot.selectAll(".cboutline").attr({x:X,y:$+r.ypad+("top"===r.titleside?st:0),width:Math.max(H,2),height:Math.max(s-2*r.ypad-st,2)}).call(p.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var c=({center:.5,right:1}[r.xanchor]||0)*l;ot.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=m[r.yanchor],h=x[r.yanchor];"pixels"===r.lenmode?(u.y=r.y,u.t=s*f,u.b=s*h):(u.t=u.b=0,u.yt=r.y+r.len*f,u.yb=r.y-r.len*h);var g=m[r.xanchor],v=x[r.xanchor];if("pixels"===r.thicknessmode)u.x=r.x,u.l=l*g,u.r=l*v;else{var y=l-H;u.l=y*g,u.r=y*v,u.xl=r.x-r.thickness*g,u.xr=r.x+r.thickness*v}i.autoMargin(t,e,u)}],t);if(gt&>.then&&(t._promises||[]).push(gt),t._context.edits.colorbarPosition)s.init({element:ot.node(),gd:t,prepFn:function(){dt=ot.attr("transform"),f(ot)},moveFn:function(t,e){ot.attr("transform",dt+" translate("+t+","+e+")"),pt=s.align(W+t/k.w,q,0,1,r.xanchor),ht=s.align(J-e/k.h,U,0,1,r.yanchor);var n=s.getCursor(pt,ht,r.xanchor,r.yanchor);f(ot,n)},doneFn:function(){f(ot),void 0!==pt&&void 0!==ht&&o.call("restyle",t,{"colorbar.x":pt,"colorbar.y":ht},A().index)}});return gt}function vt(t,e){return c.coerce(K,tt,w,t,e)}function yt(e,r){var n=A(),a="colorbar.title",i=n._module.colorbar.container;i&&(a=i+"."+a);var o={propContainer:tt,propName:a,traceIndex:n.index,placeholder:v._dfltTitle.colorbar,containerGroup:ot.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;ot.selectAll("."+l+",."+l+"-math-group").remove(),h.draw(t,e,u(o,r||{}))}v._infolayer.selectAll("g."+e).remove()}function A(){var r,n,a=e.substr(2);for(r=0;r=0?a.Reds:a.Blues,l.reversescale?i(m):m),s.autocolorscale||f("autocolorscale",!1))}},{"../../lib":164,"./flip_scale":58,"./scales":65}],55:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":65}],56:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,r,c,u){var f,d=u.prefix,p=u.cLetter,h=d.slice(0,d.length-1),g=d?a.nestedProperty(t,h).get()||{}:t,v=d?a.nestedProperty(e,h).get()||{}:e,y=g[p+"min"],m=g[p+"max"],x=g.colorscale;c(d+p+"auto",!(n(y)&&n(m)&&y=0;a--,i++)e=t[a],n[i]=[1-e[0],e[1]];return n}},{}],59:[function(t,e,r){"use strict";var n=t("./scales"),a=t("./default_scale"),i=t("./is_valid_scale_array");e.exports=function(t,e){if(e||(e=a),!t)return e;function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return"string"==typeof t&&(r(),"string"==typeof t&&r()),i(t)?t:e}},{"./default_scale":55,"./is_valid_scale_array":63,"./scales":65}],60:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=t("./is_valid_scale");e.exports=function(t,e){var r=e?a.nestedProperty(t,e).get()||{}:t,o=r.color,l=!1;if(a.isArrayOrTypedArray(o))for(var s=0;s4/3-l?o:l}},{}],67:[function(t,e,r){"use strict";var n=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,i){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:n.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":164}],68:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),l=t("../../lib"),s=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function d(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,r,n,f,h,g,v,y,m=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;m._mouseDownTime||(m._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,r){return Math.abs(t)b&&(x=Math.max(x-1,1)),m._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!y){var r;try{r=new MouseEvent("click",e)}catch(t){var n=p(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(m),m._dragged=!1}else m._dragged=!1}},u.coverSlip=d},{"../../constants/interactions":145,"../../lib":164,"../../plots/cartesian/constants":214,"../../registry":248,"./align":66,"./cursor":67,"./unhover":69,"has-hover":15,"has-passive-events":16,"mouse-event-offset":19}],69:[function(t,e,r){"use strict";var n=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),l=e.exports={};l.wrapped=function(t,e,r){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),l.raw(t,e,r)},l.raw=function(t,e){var r=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":157,"../../lib/get_graph_div":162,"../../lib/throttle":186,"../fx/constants":83}],70:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],71:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,h=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){c.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(l.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,a){t.call(v.setPosition,e,r).call(v.setSize,n,a)},v.translatePoint=function(t,e,r,n){var i=r.c2p(t.x),o=n.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var a=n.select(this);v.translatePoint(t,a,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,a,i){e.attr("display",r.isPtWithinRange(t,a)&&n.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,l=i.ycalendar,s="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(s).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,a,o,l)})})}},v.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=r||i.width||0,s=a||i.dash||"";l.stroke(e,n||i.color),v.dashLine(e,s,o)},v.lineGroupStyle=function(t,e,r,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,s=a||i.dash||"";n.select(this).call(l.stroke,r||i.color).call(v.dashLine,s,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(l.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){n.select(this).call(l.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var m=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=n.format("~.1f"),T={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,a,o,s){for(var u=o.length,f=T[a],d=new Array(u),p=0;p=100,e.attr("d",b(u,s))}var f,d,p,h=!1;if(t.so)p=o.outlierwidth,d=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,d="mlc"in t?t.mlcc=n.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?l.defaultLine:o.color,c.isArrayOrTypedArray(i.color)&&(f=l.defaultLine,h=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):i.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(l.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var y=i.gradient,m=t.mgt;if(m?h=!0:m=y&&y.type,Array.isArray(m)&&(m=m[0],T[m]||(m=0)),m&&"none"!==m){var x=t.mgc;x?h=!0:x=y.color;var _=r.uid;h&&(_+="-"+t.i),v.gradient(e,a,_,m,[[0,x],[1,f]],"fill")}else l.fill(e,f);p&&l.stroke(e,d)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=h.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.marker||{},i=r.marker||{},l=n.marker||{},s=a.opacity,u=i.opacity,f=l.opacity,d=void 0!==u,h=void 0!==f;(c.isArrayOrTypedArray(s)||d||h)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?d?u:e:h?f:p*e});var g=a.color,v=i.color,y=l.color;(v||y)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:y||e});var m=a.size,x=i.size,b=l.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||m/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.textfont||{},i=r.textfont||{},o=n.textfont||{},s=a.color,c=i.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||s;return t.selected?c||e:u||(c?e:l.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];r.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&i.push(function(t,e){l.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&i.push(function(t,e){var n=e.mx||a.symbol||0,i=r.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(n),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=n.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var l=t.tp||e.textposition,s=L(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,s,f).text(o).call(u.convertToTspans,r).call(A,l,s,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=n.select(this),i=r.selectedTextColorFn(t),o=t.tp||e.textposition,s=L(t,e);l.fill(a,i),A(a,o,s,t.mrc2||t.mrc)})}};var S=.5;function C(t,e,r,a){var i=t[0]-e[0],o=t[1]-e[1],l=r[0]-e[0],s=r[1]-e[1],c=Math.pow(i*i+o*o,S/2),u=Math.pow(l*l+s*s,S/2),f=(u*u*i-c*c*l)*a,d=(u*u*o-c*c*s)*a,p=3*u*(c+u),h=3*c*(c+u);return[[n.round(e[0]+(p&&f/p),2),n.round(e[1]+(p&&d/p),2)],[n.round(e[0]-(h&&f/h),2),n.round(e[1]-(h&&d/h),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],a=[];for(r=1;r=1e4&&(v.savedBBoxes={},D=0),r&&(v.savedBBoxes[r]=y),D++,c.extendFlat({},y)},v.setClipUrl=function(t,e){if(e){if(void 0===v.baseUrl){var r=n.select("base");r.size()&&r.attr("href")?v.baseUrl=window.location.href.split("#")[0]:v.baseUrl=""}t.attr("clip-path","url("+v.baseUrl+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||0,r=r||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+r+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||1,r=r||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+r+")").trim(),t[a]("transform",i),i};var E=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(E,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var N=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,a=n.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),l=parseFloat(i.attr("y")||0),s=(a.attr("transform")||"").match(N);t=1===e&&1===r?[]:["translate("+o+","+l+")","scale("+e+","+r+")","translate("+-o+","+-l+")"],s&&t.push(s),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":144,"../../constants/interactions":145,"../../constants/xmlns_namespaces":147,"../../lib":164,"../../lib/svg_text_utils":185,"../../registry":248,"../../traces/scatter/make_bubble_size_func":333,"../../traces/scatter/subtypes":340,"../color":46,"../colorscale":61,"./symbol_defs":72,d3:11,"fast-isnumeric":13,tinycolor2:29}],72:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+a+i+a+i+o+i+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),a=n.round(-t,2),i=n.round(-.309*t,2);return"M"+e+","+i+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+r+"V"+r+"L0,"+e+"L-"+a+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+a+"H"+r+"L"+e+",0L"+r+",-"+a+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),a=n.round(.951*e,2),i=n.round(.363*e,2),o=n.round(.588*e,2),l=n.round(-e,2),s=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+s+"H"+a+"L"+i+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+i+","+c+"L-"+a+","+s+"H-"+r+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),a=n.round(.76*t,2);return"M-"+a+",0l-"+r+",-"+e+"h"+a+"l"+r+",-"+e+"l"+r+","+e+"h"+a+"l-"+r+","+e+"l"+r+","+e+"h-"+a+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+a+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+a+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:11}],73:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],74:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function l(t,e,r,a){var l=e["error_"+a]||{},s=[];if(l.visible&&-1!==["linear","log"].indexOf(r.type)){for(var c=o(l),u=0;u0;t.each(function(t){var u,f=t[0].trace,d=f.error_x||{},p=f.error_y||{};f.ids&&(u=function(t){return t.id});var h=o.hasMarkers(f)&&f.marker.maxdisplayed>0;p.visible||d.visible||(t=[]);var g=n.select(this).selectAll("g.errorbar").data(t,u);if(g.exit().remove(),t.length){d.visible||g.selectAll("path.xerror").remove(),p.visible||g.selectAll("path.yerror").remove(),g.style("opacity",1);var v=g.enter().append("g").classed("errorbar",!0);c&&v.style("opacity",0).transition().duration(r.duration).style("opacity",1),i.setClipUrl(g,e.layerClipId),g.each(function(t){var e=n.select(this),i=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,l,s);if(!h||t.vis){var o,u=e.select("path.yerror");if(p.visible&&a(i.x)&&a(i.yh)&&a(i.ys)){var f=p.width;o="M"+(i.x-f)+","+i.yh+"h"+2*f+"m-"+f+",0V"+i.ys,i.noYS||(o+="m-"+f+",0h"+2*f),!u.size()?u=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):c&&(u=u.transition().duration(r.duration).ease(r.easing)),u.attr("d",o)}else u.remove();var g=e.select("path.xerror");if(d.visible&&a(i.y)&&a(i.xh)&&a(i.xs)){var v=(d.copy_ystyle?p:d).width;o="M"+i.xh+","+(i.y-v)+"v"+2*v+"m0,-"+v+"H"+i.xs,i.noXS||(o+="m0,-"+v+"v"+2*v),!g.size()?g=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):c&&(g=g.transition().duration(r.duration).ease(r.easing)),g.attr("d",o)}else g.remove()}})}})}},{"../../traces/scatter/subtypes":340,"../drawing":71,d3:11,"fast-isnumeric":13}],79:[function(t,e,r){"use strict";var n=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},i=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(a.stroke,r.color),i.copy_ystyle&&(i=r),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":46,d3:11}],80:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":235}],81:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry");function i(t,e,r,a){a=a||n.identity,Array.isArray(t)&&(e[0][r]=a(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var l=0;l=0&&r.index-1&&o.length>x&&(o=x>3?o.substr(0,x-3)+"...":o.substr(0,x))}void 0!==t.zLabel?(void 0!==t.xLabel&&(c+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(c+="y: "+t.yLabel+"
"),c+=(c?"z: ":"")+t.zLabel):O&&t[a+"Label"]===T?c=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(c=t.yLabel):c=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(c+=(c?"
":"")+t.text),void 0!==t.extraText&&(c+=(c?"
":"")+t.extraText),""===c&&(""===o&&e.remove(),c=o);var b=e.select("text.nums").call(u.font,t.fontFamily||h,t.fontSize||g,t.fontColor||m).text(c).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),_=e.select("text.name"),M=0;o&&o!==c?(_.call(u.font,t.fontFamily||h,t.fontSize||g,v).text(o).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),M=_.node().getBoundingClientRect().width+2*k):(_.remove(),e.select("rect").remove()),e.select("path").style({fill:p,stroke:m});var A,P,D=b.node().getBoundingClientRect(),z=t.xa._offset+(t.x0+t.x1)/2,E=t.ya._offset+(t.y0+t.y1)/2,N=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),I=D.width+w+k+M;t.ty0=L-D.top,t.bx=D.width+2*k,t.by=D.height+2*k,t.anchor="start",t.txwidth=D.width,t.tx2width=M,t.offset=0,i?(t.pos=z,A=E+R/2+I<=C,P=E-R/2-I>=0,"top"!==t.idealAlign&&A||!P?A?(E+=R/2,t.anchor="start"):t.anchor="middle":(E-=R/2,t.anchor="end")):(t.pos=E,A=z+N/2+I<=S,P=z-N/2-I>=0,"left"!==t.idealAlign&&A||!P?A?(z+=N/2,t.anchor="start"):t.anchor="middle":(z-=N/2,t.anchor="end")),b.attr("text-anchor",t.anchor),M&&_.attr("text-anchor",t.anchor),e.attr("transform","translate("+z+","+E+")"+(i?"rotate("+y+")":""))}),R}function M(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var a="end"===t.anchor?-1:1,i=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],l=o*(w+k),c=l+o*(t.txwidth+k),f=0,d=t.offset;"middle"===t.anchor&&(l-=t.tx2width/2,c+=t.txwidth/2+k),e&&(d*=-_,f=t.offset*b),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(d-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+d)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(d-w)+"Z"),i.call(s.positionText,l+f,d+t.ty0-t.by/2+k),t.tx2width&&(r.select("text.name").call(s.positionText,c+o*k+f,d+t.ty0-t.by/2+k),r.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,d-t.by/2-1,t.tx2width,t.by+2))}})}function A(t,e){var r=t.index,n=t.trace||{},a=t.cd[0],i=t.cd[r]||{},l=Array.isArray(r)?function(t,e){return o.castOption(a,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(i,n,t,e)};function s(e,r,n){var a=l(r,n);a&&(t[e]=a)}if(s("hoverinfo","hi","hoverinfo"),s("bgcolor","hbg","hoverlabel.bgcolor"),s("borderColor","hbc","hoverlabel.bordercolor"),s("fontFamily","htf","hoverlabel.font.family"),s("fontSize","hts","hoverlabel.font.size"),s("fontColor","htc","hoverlabel.font.color"),s("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function L(t,e){var r,n,a=e.container,o=e.fullLayout,l=e.event,s=!!t.hLinePoint,c=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),c||s){var d=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(s){var p,h,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(p=l.pointerX,h=l.pointerY):(p=r._offset+g.x,h=n._offset+g.y);var v,y,m=i.readability(g.color,d)<1.5?f.contrast(d):g.color,x=n.spikemode,b=n.spikethickness,_=n.spikecolor||m,w=n._boundingBox,k=(w.left+w.right)/2w[0]._length||et<0||et>k[0]._length)return d.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,N="xval"in e?g.flat(s,e.xval):g.p2c(w,tt),R="yval"in e?g.flat(s,e.yval):g.p2c(k,et),!a(N[0])||!a(R[0]))return o.warn("Fx.hover failed",e,t),d.unhoverRaw(t,e)}var at=1/0;for(F=0;FY&&(J.splice(0,Y),at=J[0].distance),m&&0!==W&&0===J.length){Z.distance=W,Z.index=!1;var ct=j._module.hoverPoints(Z,U,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=W})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var dt=ft[0];a(dt.x0)&&a(dt.y0)&&(ut=vt(dt),(!$.vLinePoint||$.vLinePoint.spikeDistance>ut.spikeDistance)&&($.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var ht=pt[0];a(ht.x0)&&a(ht.y0)&&(ut=vt(ht),(!$.hLinePoint||$.hLinePoint.spikeDistance>ut.spikeDistance)&&($.hLinePoint=ut))}}}}function gt(t,e){for(var r,n=null,a=1/0,i=0;i1||J.length>1)||"closest"===E&&K&&J.length>1,Ct=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),Ot={hovermode:E,rotateLabels:St,bgColor:Ct,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},Pt=T(J,Ot,t);if(function(t,e,r){var n,a,i,o,l,s,c,u=0,f=1,d=t.map(function(t,n){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!n&&o&&o[0]>o[1]!==i&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?x:1)/2,pmin:0,pmax:i?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],r=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=r.pos+r.dp+r.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;n=!1}if(!(i<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=i;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos>e.pmax-1&&(s.del=!0,c--);for(o=0;o=0;l--)t[l].dp-=i;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(;!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&v.pmin===y.pmin&&v.pmax===y.pmax){for(l=g.length-1;l>=0;l--)g[l].dp+=a;for(h.push.apply(h,g),d.splice(o+1,1),c=0,l=h.length-1;l>=0;l--)c+=h[l].dp;for(i=c/h.length,l=h.length-1;l>=0;l--)h[l].dp-=i;n=!1}else o++}d.forEach(p)}for(o=d.length-1;o>=0;o--){var m=d[o];for(l=m.length-1;l>=0;l--){var b=m[l],_=t[b.i];_.offset=b.dp,_.del=b.del}}}(J,St?"xa":"ya",u),M(Pt,St),e.target&&e.target.tagName){var Dt=h.getComponentMethod("annotations","hasClickToShow")(t,At);c(n.select(e.target),Dt?"pointer":"")}if(!e.target||i||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var a=r[n],i=t._hoverdata[n];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber))return!0}return!1}(t,0,Mt))return;Mt&&t.emit("plotly_unhover",{event:e,points:Mt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:N,yvals:R})}(t,e,r,i)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0},a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=T([r],o,e.gd);return M(l,o.rotateLabels),l.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0}}),a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=T(r,o,e.gd),s=0;return l.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){d||p||h||"independent"===T("pattern")&&(d=!0),v._hasSubplotGrid=d;var x,b,_="top to bottom"===T("roworder"),w=d?.2:.1,k=d?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",T,w,x,m),y:u("y",T,k,b,y,_)}}else delete e.grid}function T(t,e){return n.coerce(r,v,s,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,a,i,o,l,s,u,d=t.grid||{},p=e._subplots,h=r._hasSubplotGrid,g=r.rows,v=r.columns,y="independent"===r.pattern,m=r._axisMap={};if(h){var x=d.subplots||[];s=r.subplots=new Array(g);var b=1;for(n=0;n=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],99:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes");e.exports={bgcolor:{valType:"color",editType:"legend"},bordercolor:{valType:"color",dflt:a.defaultLine,editType:"legend"},borderwidth:{valType:"number",min:0,dflt:0,editType:"legend"},font:n({editType:"legend"}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v",editType:"legend"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"],editType:"legend"},tracegroupgap:{valType:"number",min:0,dflt:10,editType:"legend"},x:{valType:"number",min:-2,max:3,dflt:1.02,editType:"legend"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left",editType:"legend"},y:{valType:"number",min:-2,max:3,dflt:1,editType:"legend"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"legend"},editType:"legend"}},{"../../plots/font_attributes":235,"../color/attributes":45}],100:[function(t,e,r){"use strict";e.exports={scrollBarWidth:6,scrollBarMinHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4,textOffsetX:40}},{}],101:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib"),i=t("../../plot_api/plot_template"),o=t("./attributes"),l=t("../../plots/layout_attributes"),s=t("./helpers");e.exports=function(t,e,r){for(var c,u,f,d,p=t.legend||{},h=0,g=!1,v="normal",y=0;y1)){var x=i.newContainer(e,"legend");if(_("bgcolor",e.paper_bgcolor),_("bordercolor"),_("borderwidth"),a.coerceFont(_,"font",e.font),_("orientation"),"h"===x.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(c=0,f="left",u=1.1,d="bottom"):(c=0,f="left",u=-.1,d="top")}_("traceorder",v),s.isGrouped(e.legend)&&_("tracegroupgap"),_("x",c),_("xanchor",f),_("y",u),_("yanchor",d),a.noneOrAll(p,x,["x","y"])}function _(t,e){return a.coerce(p,x,o,t,e)}}},{"../../lib":164,"../../plot_api/plot_template":198,"../../plots/layout_attributes":239,"../../registry":248,"./attributes":99,"./helpers":105}],102:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib/events"),s=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),d=t("./handle_click"),p=t("./constants"),h=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,y=g.FROM_TL,m=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=t("./anchor_utils"),k=h.DBLCLICKDELAY;function T(t,e,r,n,a){var i=r.data()[0][0].trace,o={event:a,node:r.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=r.datum()[0].label),!1!==l.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){d(r,t,n)},k);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==l.triggerHandler(t,"plotly_legenddoubleclick",o)&&d(r,t,n)}}function M(t,e,r){var n=t.data()[0][0],i=e._fullLayout,l=n.trace,s=o.traceIs(l,"pie"),u=l.index,d=s?n.label:l.name,h=e._context.edits.legendText&&!s,g=a.ensureSingle(t,"text","legendtext");function y(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,a,i=t.select("g[class*=math-group]"),o=i.node(),l=e._fullLayout.legend.font.size*v;if(o){var s=c.bBox(o);n=s.height,a=s.width,c.setTranslate(i,0,n/4)}else{var u=t.select(".legendtext"),d=f.lineCount(u),h=u.node();n=l*d,a=h?c.bBox(h).width:0;var g=l*(.3+(1-d)/2);f.positionText(u,p.textOffsetX,g)}n=Math.max(n,16)+3,r.height=n,r.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,i.legend.font).text(h?A(d,r):d),f.positionText(g,p.textOffsetX,0),h?g.call(f.makeEditable,{gd:e,text:d}).call(y).on("edit",function(t){this.text(A(t,r)).call(y);var i=n.trace._fullInput||{},l={};if(o.hasTransform(i,"groupby")){var s=o.getTransformIndices(i,"groupby"),c=s[s.length-1],f=a.keyedContainer(i,"transforms["+c+"].styles","target","value.name");f.set(n.trace._group,t),l=f.constructUpdate()}else l.name=t;return o.call("restyle",e,l,u)}):y(g)}function A(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function L(t,e){var r,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimek&&(i=Math.max(i-1,1)),T(e,r,t,i,n.event)}})}function S(t,e,r){var a=t._fullLayout,i=a.legend,o=i.borderwidth,l=_.isGrouped(i),s=0;if(i._width=0,i._height=0,_.isVertical(i))l&&e.each(function(t,e){c.setTranslate(this,0,e*i.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;c.setTranslate(this,o,5+o+i._height+r/2),i._height+=r,i._width=Math.max(i._width,n)}),i._width+=45+2*o,i._height+=10+2*o,l&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),s=40;else if(l){for(var u=[i._width],f=e.data(),d=0,p=f.length;do+w-k,r.each(function(t){var e=t[0],r=v?40+t[0].width:x;o+b+k+r>a._size.w&&(b=0,y+=m,i._height=i._height+m,m=0),c.setTranslate(this,o+b,5+o+e.height/2+y),i._width+=k+r,i._height=Math.max(i._height,e.height),b+=k+r,m=Math.max(e.height,m)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var T=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");c.setRect(r,0,-e.height/2,(T?0:i._width)+s,e.height)})}function C(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");var n="top";w.isBottomAnchor(e)?n="bottom":w.isMiddleAnchor(e)&&(n="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[r],r:e._width*m[r],b:e._height*m[n],t:e._height*y[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var l=e.legend,f=e.showlegend&&x(t.calcdata,l),d=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void i.autoMargin(t,"legend");for(var h=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[r],r:e._width*m[r],b:0,t:0})}(t):C(t);var d=e._size,h=d.l+d.w*l.x,g=d.t+d.h*(1-l.y);w.isRightAnchor(l)?h-=l._width:w.isCenterAnchor(l)&&(h-=l._width/2),w.isBottomAnchor(l)?g-=l._height:w.isMiddleAnchor(l)&&(g-=l._height/2);var v=l._width,x=d.w;v>x?(h=d.l,v=x):(h+v>u&&(h=u-v),h<0&&(h=0),v=Math.min(u-h,l._width));var b,_,k,M,A=l._height,L=d.h;if(A>L?(g=d.t,A=L):(g+A>f&&(g=f-A),g<0&&(g=0),A=Math.min(f-g,l._height)),c.setTranslate(P,h,g),N.on(".drag",null),P.on("wheel",null),l._height<=A||t._context.staticPlot)z.attr({width:v-l.borderwidth,height:A-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),c.setTranslate(E,0,0),D.select("rect").attr({width:v-2*l.borderwidth,height:A-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth}),c.setClipUrl(E,r),c.setRect(N,0,0,0,0),delete l._scrollY;else{var F,B,j=Math.max(p.scrollBarMinHeight,A*A/l._height),H=A-j-2*p.scrollBarMargin,q=l._height-A,V=H/q,U=Math.min(l._scrollY||0,q);z.attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),D.select("rect").attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth+U}),c.setClipUrl(E,r),Z(U,j,V),P.on("wheel",function(){Z(U=a.constrain(l._scrollY+n.event.deltaY/H*q,0,q),j,V),0!==U&&U!==q&&n.event.preventDefault()});var G=n.behavior.drag().on("dragstart",function(){F=n.event.sourceEvent.clientY,B=U}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||Z(U=a.constrain((t.clientY-F)/V+B,0,q),j,V)});N.call(G)}function Z(e,r,n){l._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(E,0,-e),c.setRect(N,v,p.scrollBarMargin+e*n,p.scrollBarWidth,r),D.select("rect").attr({y:l.borderwidth+e})}t._context.edits.legendPosition&&(P.classed("cursor-move",!0),s.init({element:P.node(),gd:t,prepFn:function(){var t=c.getTranslate(P);k=t.x,M=t.y},moveFn:function(t,e){var r=k+t,n=M+e;c.setTranslate(P,r,n),b=s.align(r,0,d.l,d.l+d.w,l.xanchor),_=s.align(n,0,d.t+d.h,d.t,l.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("relayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(r,n){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});a.size()>0&&T(t,P,a,r,n)}}))}],t)}}},{"../../constants/alignment":144,"../../constants/interactions":145,"../../lib":164,"../../lib/events":157,"../../lib/svg_text_utils":185,"../../plots/plots":241,"../../registry":248,"../color":46,"../dragelement":68,"../drawing":71,"./anchor_utils":98,"./constants":100,"./get_legend_data":103,"./handle_click":104,"./helpers":105,"./style":107,d3:11}],103:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var r,i,o={},l=[],s=!1,c={},u=0;function f(t,r){if(""!==t&&a.isGrouped(e))-1===l.indexOf(t)?(l.push(t),s=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+u;l.push(n),o[n]=[[r]],u++}}for(r=0;rr[1])return r[1]}return a}function h(t){return t[0]}if(u||f||d){var g={},v={};if(u){g.mc=p("marker.color",h),g.mx=p("marker.symbol",h),g.mo=p("marker.opacity",i.mean,[.2,1]),g.mlc=p("marker.line.color",h),g.mlw=p("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=p("marker.size",i.mean,[2,16]);g.ms=y,v.marker.size=y}d&&(v.line={width:p("line.width",h,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",h),g.ts=10,g.tc=p("textfont.color",h),g.tf=p("textfont.family",h)),r=[i.minExtend(l,g)],(a=i.minExtend(c,v)).selectedpoints=null}var m=n.select(this).select("g.legendpoints"),x=m.selectAll("path.scatterpts").data(u?r:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,a,e),u&&(r[0].mrc=3);var b=m.selectAll("g.pointtext").data(f?r:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,o=n.select(this);o.style("stroke-width",i+"px").call(l.fill,a.fillcolor),i&&l.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,s=n.select(this);s.style("fill","none").call(o.dashLine,a.line.dash,i),i&&l.stroke(s,a.line.color)})})}},{"../../lib":164,"../../registry":248,"../../traces/pie/style_one":314,"../../traces/scatter/subtypes":340,"../color":46,"../drawing":71,d3:11}],108:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),l=t("../../../build/ploticon"),s=o._,c=e.exports={};function u(t,e){var r,a,o=e.currentTarget,l=o.getAttribute("data-attr"),s=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=i.list(t,null,!0),d="on";if("zoom"===l){var p,h="in"===s?.5:2,g=(1+h)/2,v=(1-h)/2;for(a=0;a1?(_=["toggleHover"],w=["resetViews"]):f?(b=["zoomInGeo","zoomOutGeo"],_=["hoverClosestGeo"],w=["resetGeo"]):u?(_=["hoverClosest3d"],w=["resetCameraDefault3d","resetCameraLastSave3d"]):g?(_=["toggleHover"],w=["resetViewMapbox"]):_=p?["hoverClosestGl2d"]:d?["hoverClosestPie"]:["toggleHover"];c&&(_=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!c&&!p||y||(b=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==w[0]&&(w=["resetScale2d"]));u?k=["zoom3d","pan3d","orbitRotation","tableRotation"]:(c||p)&&!y||h?k=["zoom2d","pan2d"]:g||f?k=["pan2d"]:v&&(k=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),a=0,i=0;i0?d+c:c;return{ppad:c,ppadplus:u?h:g,ppadminus:u?g:h}}return{ppad:c}}function u(t,e,r,n,a){var l="category"===t.type?t.r2c:t.d2c;if(void 0!==e)return[l(e),l(r)];if(n){var s,c,u,f,d=1/0,p=-1/0,h=n.match(i.segmentRE);for("date"===t.type&&(l=o.decodeDate(l)),s=0;sp&&(p=f)));return p>=d?[d,p]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:N?V(r.xanchor)+r.x0:V(r.x0),cy:R?U(r.yanchor)-r.y0:U(r.y0),r:i}).style(a).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:N?V(r.xanchor)+r.x1:V(r.x1),cy:R?U(r.yanchor)-r.y1:U(r.y1),r:i}).style(a).classed("cursor-grab",!0),n}():e,X={element:Y.node(),gd:t,prepFn:function(n){N&&(_=V(r.xanchor));R&&(w=U(r.yanchor));"path"===r.type?P=r.path:(y=N?r.x0:V(r.x0),m=R?r.y0:U(r.y0),x=N?r.x1:V(r.x1),b=R?r.y1:U(r.y1));yb?(k=m,L="y0",T=b,S="y1"):(k=b,L="y1",T=m,S="y0");W(n),$(p,r),function(t,e,r){var n=e.xref,a=e.yref,o=i.getFromId(r,n),s=i.getFromId(r,a),c="";"paper"===n||o.autorange||(c+=n);"paper"===a||s.autorange||(c+=a);t.call(l.setClipUrl,c?"clip"+r._fullLayout._uid+c:null)}(e,r,t),X.moveFn="move"===D?J:Q},doneFn:function(){u(e),K(p),h(e,t,r),n.call("relayout",t,B.getUpdateObj())},clickFn:function(){K(p)}};function W(t){if(I)D="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=X.element.getBoundingClientRect(),n=r.right-r.left,a=r.bottom-r.top,i=t.clientX-r.left,o=t.clientY-r.top,l=!F&&n>z&&a>E&&!t.shiftKey?c.getCursor(i/n,1-o/a):"move";u(e,l),D=l.split("-")[0]}}function J(n,a){if("path"===r.type){var i=function(t){return t},o=i,l=i;N?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),R?j("yanchor",r.yanchor=Z(w+a)):(l=function(t){return Z(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(P,o,l))}else N?j("xanchor",r.xanchor=G(_+n)):(j("x0",r.x0=G(y+n)),j("x1",r.x1=G(x+n))),R?j("yanchor",r.yanchor=Z(w+a)):(j("y0",r.y0=Z(m+a)),j("y1",r.y1=Z(b+a)));e.attr("d",g(t,r)),$(p,r)}function Q(n,a){if(F){var i=function(t){return t},o=i,l=i;N?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),R?j("yanchor",r.yanchor=Z(w+a)):(l=function(t){return Z(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(P,o,l))}else if(I){if("resize-over-start-point"===D){var s=y+n,c=R?m-a:m+a;j("x0",r.x0=N?s:G(s)),j("y0",r.y0=R?c:Z(c))}else if("resize-over-end-point"===D){var u=x+n,f=R?b-a:b+a;j("x1",r.x1=N?u:G(u)),j("y1",r.y1=R?f:Z(f))}}else{var h=~D.indexOf("n")?k+a:k,B=~D.indexOf("s")?T+a:T,Y=~D.indexOf("w")?M+n:M,X=~D.indexOf("e")?A+n:A;~D.indexOf("n")&&R&&(h=k-a),~D.indexOf("s")&&R&&(B=T-a),(!R&&B-h>E||R&&h-B>E)&&(j(L,r[L]=R?h:Z(h)),j(S,r[S]=R?B:Z(B))),X-Y>z&&(j(C,r[C]=N?Y:G(Y)),j(O,r[O]=N?X:G(X)))}e.attr("d",g(t,r)),$(p,r)}function $(t,e){(N||R)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=V(N?e.xanchor:a.midRange(r?[e.x0,e.x1]:d.extractPathCoords(e.path,f.paramIsX))),o=U(R?e.yanchor:a.midRange(r?[e.y0,e.y1]:d.extractPathCoords(e.path,f.paramIsY)));if(i=d.roundPositionForSharpStrokeRendering(i,1),o=d.roundPositionForSharpStrokeRendering(o,1),N&&R){var l="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",l)}else if(N){var s="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",s)}else{var c="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",c)}}()}function K(t){t.selectAll(".visual-cue").remove()}c.init(X),Y.node().onmousemove=W}(t,x,r,e,p)}}function h(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");t.call(l.setClipUrl,n?"clip"+e._fullLayout._uid+n:null)}function g(t,e){var r,n,o,l,s,c,u,p,h=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),y=t._fullLayout._size;if(g?(r=d.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return y.l+y.w*t},v?(o=d.shapePositionToRange(v),l=function(t){return v._offset+v.r2p(o(t,!0))}):l=function(t){return y.t+y.h*(1-t)},"path"===h)return g&&"date"===g.type&&(n=d.decodeDate(n)),v&&"date"===v.type&&(l=d.decodeDate(l)),function(t,e,r){var n=t.path,i=t.xsizemode,o=t.ysizemode,l=t.xanchor,s=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,c=t.charAt(0),u=f.paramIsX[c],d=f.paramIsY[c],p=f.numParams[c],h=t.substr(1).replace(f.paramRE,function(t){return u[n]?t="pixel"===i?e(l)+Number(t):e(t):d[n]&&(t="pixel"===o?r(s)-Number(t):r(t)),++n>p&&(t="X"),t});return n>p&&(h=h.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),c+h})}(e,n,l);if("pixel"===e.xsizemode){var m=n(e.xanchor);s=m+e.x0,c=m+e.x1}else s=n(e.x0),c=n(e.x1);if("pixel"===e.ysizemode){var x=l(e.yanchor);u=x-e.y0,p=x-e.y1}else u=l(e.y0),p=l(e.y1);if("line"===h)return"M"+s+","+u+"L"+c+","+p;if("rect"===h)return"M"+s+","+u+"H"+c+"V"+p+"H"+s+"Z";var b=(s+c)/2,_=(u+p)/2,w=Math.abs(b-s),k=Math.abs(_-u),T="A"+w+","+k,M=b+w+","+_;return"M"+M+T+" 0 1,1 "+(b+","+(_-k))+T+" 0 0,1 "+M+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],l=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return n>=l?t:(i[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var a=0;a0&&(l=l.transition().duration(e.transition.duration).ease(e.transition.easing)),l.attr("transform","translate("+(o-.5*f.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function S(t,e){var r=t._dims;return r.inputAreaStart+f.stepInset+(r.inputAreaLength-2*f.stepInset)*Math.min(1,Math.max(0,e))}function C(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-f.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*f.stepInset-2*r.inputAreaStart)))}function O(t,e,r){var n=r._dims,a=l.ensureSingle(t,"rect",f.railTouchRectClass,function(n){n.call(M,e,t,r).style("pointer-events","all")});a.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,f.tickOffset+r.ticklen+n.labelHeight)}).call(i.fill,r.bgcolor).attr("opacity",0),o.setTranslate(a,0,n.currentValueTotalHeight)}function P(t,e){var r=e._dims,n=r.inputAreaLength-2*f.railInset,a=l.ensureSingle(t,"rect",f.railRectClass);a.attr({width:n,height:f.railWidth,rx:f.railRadius,ry:f.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,f.railInset,.5*(r.inputAreaWidth-f.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[f.name],n=[],a=0;a0?[0]:[]);function l(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,v(e))}if(i.enter().append("g").classed(f.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){n.select(this).selectAll("g."+f.groupClassName).each(l)}).remove(),0!==r.length){var s=i.selectAll("g."+f.groupClassName).data(r,y);s.enter().append("g").classed(f.groupClassName,!0),s.exit().each(l).remove();for(var c=0;c0||d<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[m.side];e.attr("transform","translate("+g+")")}}}D.call(z),O&&(C?D.on(".opacity",null):(L=0,S=!0,D.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),D.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("restyle",t,g,e,y):o.call("relayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(z)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return D.classed("js-placeholder",S),_}};var d=/ [XY][0-9]* /},{"../../constants/interactions":145,"../../lib":164,"../../lib/svg_text_utils":185,"../../plots/plots":241,"../../registry":248,"../color":46,"../drawing":71,d3:11,"fast-isnumeric":13}],138:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,l=t("../../plots/pad_attributes"),s=t("../../plot_api/plot_template").templatedArray,c=s("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(s("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i({},l,{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":158,"../../plot_api/edit_types":191,"../../plot_api/plot_template":198,"../../plots/font_attributes":235,"../../plots/pad_attributes":240,"../color/attributes":45}],139:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],140:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,l=i.buttons;function s(t,e,r){function o(r,a){return n.coerce(t,e,i,r,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function r(r,a){return n.coerce(t,e,l,r,a)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:s})}},{"../../lib":164,"../../plots/array_container_defaults":204,"./attributes":138,"./constants":139}],141:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../legend/anchor_utils"),u=t("../../plot_api/plot_template").arrayEditor,f=t("../../constants/alignment").LINE_SPACING,d=t("./constants"),p=t("./scrollbox");function h(t){return t._index}function g(t,e){return+t.attr(d.menuIndexAttrName)===e._index}function v(t,e,r,n,a,i,o,l){e.active=o,u(t.layout,d.name,e).applyUpdate("active",o),"buttons"===e.type?m(t,n,null,null,e):"dropdown"===e.type&&(a.attr(d.menuIndexAttrName,"-1"),y(t,n,a,i,e),l||m(t,n,a,i,e))}function y(t,e,r,n,a){var i=l.ensureSingle(e,"g",d.headerClassName,function(t){t.style("pointer-events","all")}),s=a._dims,c=a.active,u=a.buttons[c]||d.blankHeaderOpts,f={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},p={width:s.headerWidth,height:s.headerHeight};i.call(x,a,u,t).call(L,a,f,p),l.ensureSingle(e,"text",d.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(d.arrowSymbol[a.direction])}).attr({x:s.headerWidth-d.arrowOffsetX+a.pad.l,y:s.headerHeight/2+d.textOffsetY+a.pad.t}),i.on("click",function(){r.call(S,String(g(r,a)?-1:a._index)),m(t,e,r,n,a)}),i.on("mouseover",function(){i.call(k)}),i.on("mouseout",function(){i.call(T,a)}),o.setTranslate(e,s.lx,s.ly)}function m(t,e,r,i,o){r||(r=e).attr("pointer-events","all");var s=function(t){return-1==+t.attr(d.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?d.dropdownButtonClassName:d.buttonClassName,u=r.selectAll("g."+c).data(l.filterVisible(s)),f=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(f.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var h=0,g=0,y=o._dims,m=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(m?g=y.headerHeight+d.gapButtonHeader:h=y.headerWidth+d.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(g=-d.gapButtonHeader+d.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(h=-d.gapButtonHeader+d.gapButton-y.openWidth);var b={x:y.lx+h+o.pad.l,y:y.ly+g+o.pad.t,yPad:d.gapButton,xPad:d.gapButton,index:0},_={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(l,s){var c=n.select(this);c.call(x,o,l,t).call(L,o,b),c.on("click",function(){n.event.defaultPrevented||(v(t,o,0,e,r,i,s),l.execute&&a.executeAPICommand(t,l.method,l.args),t.emit("plotly_buttonclicked",{menu:o,button:l,active:o.active}))}),c.on("mouseover",function(){c.call(k)}),c.on("mouseout",function(){c.call(T,o),u.call(w,o)})}),u.call(w,o),m?(_.w=Math.max(y.openWidth,y.headerWidth),_.h=b.y-_.t):(_.w=b.x-_.l,_.h=Math.max(y.openHeight,y.headerHeight)),_.direction=o.direction,i&&(u.size()?function(t,e,r,n,a,i){var o,l,s,c=a.direction,u="up"===c||"down"===c,f=a._dims,p=a.active;if(u)for(l=0,s=0;s0?[0]:[]);if(o.enter().append("g").classed(d.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+d.headerGroupClassName).each(i)}).remove(),0!==r.length){var s=o.selectAll("g."+d.headerGroupClassName).data(r,h);s.enter().append("g").classed(d.headerGroupClassName,!0);for(var c=l.ensureSingle(o,"g",d.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,M=l.barLength+2*l.barPad,A=l.barWidth+2*l.barPad,L=h,S=v+y;S+A>c&&(S=c-A);var C=this.container.selectAll("rect.scrollbar-horizontal").data(T?[0]:[]);C.exit().on(".drag",null).remove(),C.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,l.barColor),T?(this.hbar=C.attr({rx:l.barRadius,ry:l.barRadius,x:L,y:S,width:M,height:A}),this._hbarXMin=L+M/2,this._hbarTranslateMax=w-M):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var O=y>k,P=l.barWidth+2*l.barPad,D=l.barLength+2*l.barPad,z=h+g,E=v;z+P>s&&(z=s-P);var N=this.container.selectAll("rect.scrollbar-vertical").data(O?[0]:[]);N.exit().on(".drag",null).remove(),N.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,l.barColor),O?(this.vbar=N.attr({rx:l.barRadius,ry:l.barRadius,x:z,y:E,width:P,height:D}),this._vbarYMin=E+D/2,this._vbarTranslateMax=k-D):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var R=this.id,I=u-.5,F=O?f+P+.5:f+.5,B=d-.5,j=T?p+A+.5:p+.5,H=o._topdefs.selectAll("#"+R).data(T||O?[0]:[]);if(H.exit().remove(),H.enter().append("clipPath").attr("id",R).append("rect"),T||O?(this._clipRect=H.select("rect").attr({x:Math.floor(I),y:Math.floor(B),width:Math.ceil(F)-Math.floor(I),height:Math.ceil(j)-Math.floor(B)}),this.container.call(i.setClipUrl,R),this.bg.attr({x:h,y:v,width:g,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),T||O){var q=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));T&&this.hbar.on(".drag",null).call(V),O&&this.vbar.on(".drag",null).call(V)}this.setTranslate(e,r)},l.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},l.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},l.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},l.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,a=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,a)-r)/(a-r)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,l=i+this._vbarTranslateMax;e=(o.constrain(n.event.y,i,l)-i)/(l-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},l.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/r;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var l=e/n;this.vbar.call(i.setTranslate,t,e+l*this._vbarTranslateMax)}}},{"../../lib":164,"../color":46,"../drawing":71,d3:11}],144:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],145:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],146:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],147:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],148:[function(t,e,r){"use strict";r.version="1.42.5",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config");for(var n=t("./registry"),a=r.register=n.register,i=t("./plot_api"),o=Object.keys(i),l=0;ll-1e-15}function c(t,e){return i(e-t,l)}function u(t,e){if(s(e))return!0;var r,n;e[0](n=a(n,l))&&(n+=l);var i=a(t,l),o=i+l;return i>=r&&i<=n||o>=r&&o<=n}function f(t,e,r,n,a,i,c){a=a||0,i=i||0;var u,f,d,p,h,g=s([r,n]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(u=0,f=o,d=l):r=a&&t<=i);var a,i},pathArc:function(t,e,r,n,a){return f(null,t,e,r,n,a,0)},pathSector:function(t,e,r,n,a){return f(null,t,e,r,n,a,1)},pathAnnulus:function(t,e,r,n,a,i){return f(t,e,r,n,a,i,1)}}},{"./mod":171}],151:[function(t,e,r){"use strict";var n=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function l(t){return n(t)||o(t)}r.isTypedArray=o,r.isArrayOrTypedArray=l,r.isArray1D=function(t){return!l(t[0])},r.ensureArray=function(t,e){return n(t)||(t=[]),t.length=e,t},r.concat=function(){var t,e,r,a,i,o,l,s,c=[],u=!0,f=0;for(r=0;ra.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,a){t%1||!n(t)||void 0!==a.min&&ta.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var a="number"==typeof t;!0!==n.strict&&a?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){a(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(u(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var a=n.regex||s(r);"string"==typeof t&&a.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!s(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=n&&t<=a?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),y=t.charAt(0);!c||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:m);if(!k)return u;var T=k[1],M=k[3]||"1",A=Number(k[5]||1),L=Number(k[7]||0),S=Number(k[9]||0),C=Number(k[11]||0);if(c){if(2===T.length)return u;var O;T=Number(T);try{var P=v.getComponentMethod("calendars","getCal")(e);if(w){var D="i"===M.charAt(M.length-1);M=parseInt(M,10),O=P.newDate(T,P.toMonthIndex(T,M,D),A)}else O=P.newDate(T,Number(M),A)}catch(t){return u}return O?(O.toJD()-g)*f+L*d+S*p+C*h:u}T=2===T.length?(Number(T)+2e3-b)%100+b:Number(T),M-=1;var z=new Date(Date.UTC(2e3,M,A,L,S));return z.setUTCFullYear(T),z.getUTCMonth()!==M?u:z.getUTCDate()!==A?u:z.getTime()+C*h},n=r.MIN_MS=r.dateTime2ms("-9999"),a=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==u};var k=90*f,T=3*d,M=5*p;function A(t,e,r,n,a){if((e||r||n||a)&&(t+=" "+w(e,2)+":"+w(r,2),(n||a)&&(t+=":"+w(n,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=a))return u;e||(e=0);var i,o,l,c,m,x,b=Math.floor(10*s(t+.05,1)),w=Math.round(t-b/10);if(_(r)){var L=Math.floor(w/f)+g,S=Math.floor(s(t,f));try{i=v.getComponentMethod("calendars","getCal")(r).fromJD(L).formatDate("yyyy-mm-dd")}catch(t){i=y("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=n+f&&t<=a-f))return u;var e=Math.floor(10*s(t+.05,1)),r=new Date(Math.round(t-e/10));return A(i.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===u)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return l.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return l.error("unrecognized date",t),e;return t};var L=/%\d?f/g;function S(t,e,r,n){t=t.replace(L,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(a)}var C=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,a,i){if(a=_(a)&&a,!e)if("y"===r)e=i.year;else if("m"===r)e=i.month;else{if("d"!==r)return function(t,e){var r=s(t+.05,f),n=w(Math.floor(r/d),2)+":"+w(s(Math.floor(r/p),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(s(t/h,60),C[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+a}return n}(t,r)+"\n"+S(i.dayMonthYear,t,n,a);e=i.dayMonth+"\n"+i.year}return S(e,t,n,a)};var O=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=s(t,f);if(t=Math.round(t-n),r)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(r),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){l.error("invalid ms "+t+" in calendar "+r)}var c=new Date(t+O);return c.setUTCMonth(c.getUTCMonth()+e)+n-O},r.findExactDates=function(t,e){for(var r,n,a=0,i=0,l=0,s=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}function s(t,e,r,n,a){var i=n*t+a*e;if(i<0)return n*n+a*a;if(i>r){var o=n-t,l=a-e;return o*o+l*l}var s=n*e-a*t;return s*s/r}r.segmentsIntersect=l,r.segmentDistance=function(t,e,r,n,a,i,o,c){if(l(t,e,r,n,a,i,o,c))return 0;var u=r-t,f=n-e,d=o-a,p=c-i,h=u*u+f*f,g=d*d+p*p,v=Math.min(s(u,f,h,a-t,i-e),s(u,f,h,o-t,c-e),s(d,p,g,t-a,e-i),s(d,p,g,r-a,n-i));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,l){if(t===a&&l===i||(n={},a=t,i=l),n[r])return n[r];var s=t.getPointAtLength(o(r-l/2,e)),c=t.getPointAtLength(o(r+l/2,e)),u=Math.atan((c.y-s.y)/(c.x-s.x)),f=t.getPointAtLength(o(r,e)),d={x:(4*f.x+s.x+c.x)/6,y:(4*f.y+s.y+c.y)/6,theta:u};return n[r]=d,d},r.clearLocationCache=function(){a=null},r.getVisibleSegment=function(t,e,r){var n,a,i=e.left,o=e.right,l=e.top,s=e.bottom,c=0,u=t.getTotalLength(),f=u;function d(e){var r=t.getPointAtLength(e);0===e?n=r:e===u&&(a=r);var c=r.xo?r.x-o:0,f=r.ys?r.y-s:0;return Math.sqrt(c*c+f*f)}for(var p=d(c);p;){if((c+=p+r)>f)return;p=d(c)}for(p=d(f);p;){if(c>(f-=p+r))return;p=d(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(n.x-a.x)<.1&&Math.abs(n.y-a.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var a,i,o,l=(n=n||{}).pathLength||t.getTotalLength(),s=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(l)[r]?-1:1,f=0,d=0,p=l;f0?p=a:d=a,f++}return i}},{"./mod":171}],162:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],163:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],164:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../constants/numerical"),o=i.FP_SAFE,l=i.BADNUM,s=e.exports={};s.nestedProperty=t("./nested_property"),s.keyedContainer=t("./keyed_container"),s.relativeAttr=t("./relative_attr"),s.isPlainObject=t("./is_plain_object"),s.toLogRange=t("./to_log_range"),s.relinkPrivateKeys=t("./relink_private");var c=t("./array");s.isTypedArray=c.isTypedArray,s.isArrayOrTypedArray=c.isArrayOrTypedArray,s.isArray1D=c.isArray1D,s.ensureArray=c.ensureArray,s.concat=c.concat;var u=t("./mod");s.mod=u.mod,s.modHalf=u.modHalf;var f=t("./coerce");s.valObjectMeta=f.valObjectMeta,s.coerce=f.coerce,s.coerce2=f.coerce2,s.coerceFont=f.coerceFont,s.coerceHoverinfo=f.coerceHoverinfo,s.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,s.validate=f.validate;var d=t("./dates");s.dateTime2ms=d.dateTime2ms,s.isDateTime=d.isDateTime,s.ms2DateTime=d.ms2DateTime,s.ms2DateTimeLocal=d.ms2DateTimeLocal,s.cleanDate=d.cleanDate,s.isJSDate=d.isJSDate,s.formatDate=d.formatDate,s.incrementMonth=d.incrementMonth,s.dateTick0=d.dateTick0,s.dfltRange=d.dfltRange,s.findExactDates=d.findExactDates,s.MIN_MS=d.MIN_MS,s.MAX_MS=d.MAX_MS;var p=t("./search");s.findBin=p.findBin,s.sorterAsc=p.sorterAsc,s.sorterDes=p.sorterDes,s.distinctVals=p.distinctVals,s.roundUp=p.roundUp,s.sort=p.sort,s.findIndexOfMin=p.findIndexOfMin;var h=t("./stats");s.aggNums=h.aggNums,s.len=h.len,s.mean=h.mean,s.midRange=h.midRange,s.variance=h.variance,s.stdev=h.stdev,s.interp=h.interp;var g=t("./matrix");s.init2dArray=g.init2dArray,s.transposeRagged=g.transposeRagged,s.dot=g.dot,s.translationMatrix=g.translationMatrix,s.rotationMatrix=g.rotationMatrix,s.rotationXYMatrix=g.rotationXYMatrix,s.apply2DTransform=g.apply2DTransform,s.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");s.deg2rad=v.deg2rad,s.rad2deg=v.rad2deg,s.angleDelta=v.angleDelta,s.angleDist=v.angleDist,s.isFullCircle=v.isFullCircle,s.isAngleInsideSector=v.isAngleInsideSector,s.isPtInsideSector=v.isPtInsideSector,s.pathArc=v.pathArc,s.pathSector=v.pathSector,s.pathAnnulus=v.pathAnnulus;var y=t("./geometry2d");s.segmentsIntersect=y.segmentsIntersect,s.segmentDistance=y.segmentDistance,s.getTextLocation=y.getTextLocation,s.clearLocationCache=y.clearLocationCache,s.getVisibleSegment=y.getVisibleSegment,s.findPointOnPath=y.findPointOnPath;var m=t("./extend");s.extendFlat=m.extendFlat,s.extendDeep=m.extendDeep,s.extendDeepAll=m.extendDeepAll,s.extendDeepNoArrays=m.extendDeepNoArrays;var x=t("./loggers");s.log=x.log,s.warn=x.warn,s.error=x.error;var b=t("./regex");s.counterRegex=b.counter;var _=t("./throttle");function w(t){var e={};for(var r in t)for(var n=t[r],a=0;ao?l:a(t)?Number(t):l:l},s.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},s.noop=t("./noop"),s.identity=t("./identity"),s.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},s.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},s.simpleMap=function(t,e,r,n){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,r)?a>10?(s.warn("randstr failed uniqueness"),c):t(e,r,n,(a||0)+1):c},s.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},s.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,a,i,o=t.length,l=2*o,s=2*e-1,c=new Array(s),u=new Array(o);for(r=0;r=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=o&&(a=l-1-a),i+=t[a]*c[n];u[r]=i}return u},s.syncOrAsync=function(t,e,r){var n;function a(){return s.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(a).then(void 0,s.promiseError);return r&&r(e)},s.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},s.noneOrAll=function(t,e,r){if(t){var n,a=!1,i=!0;for(n=0;n1?a+o[1]:"";if(i&&(o.length>1||l.length>4||r))for(;n.test(l);)l=l.replace(n,"$1"+i+"$2");return l+s};var M=/%{([^\s%{}]*)}/g,A=/^\w*$/;s.templateString=function(t,e){var r={};return t.replace(M,function(t,n){return A.test(n)?e[n]||"":(r[n]=r[n]||s.nestedProperty(e,n).get,r[n]()||"")})};s.subplotSort=function(t,e){for(var r=Math.min(t.length,e.length)+1,n=0,a=0,i=0;i=48&&o<=57,c=l>=48&&l<=57;if(s&&(n=10*n+o-48),c&&(a=10*a+l-48),!s||!c){if(n!==a)return n-a;if(o!==l)return o-l}}return a-n};var L=2e9;s.seedPseudoRandom=function(){L=2e9},s.pseudoRandom=function(){var t=L;return L=(69069*L+1)%4294967296,Math.abs(L-t)<429496729?s.pseudoRandom():L/4294967296}},{"../constants/numerical":146,"./angles":150,"./array":151,"./clean_number":152,"./clear_responsive":154,"./coerce":155,"./dates":156,"./extend":158,"./filter_unique":159,"./filter_visible":160,"./geometry2d":161,"./get_graph_div":162,"./identity":163,"./is_plain_object":165,"./keyed_container":166,"./localize":167,"./loggers":168,"./make_trace_groups":169,"./matrix":170,"./mod":171,"./nested_property":172,"./noop":173,"./notifier":174,"./push_unique":177,"./regex":179,"./relative_attr":180,"./relink_private":181,"./search":182,"./stats":184,"./throttle":186,"./to_log_range":187,d3:11,"fast-isnumeric":13}],165:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],166:[function(t,e,r){"use strict";var n=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,r,i){var o,l,s;r=r||"name",i=i||"value";var c={};e&&e.length?(s=n(t,e),l=s.get()):l=t,e=e||"";var u={};if(l)for(o=0;o2)return c[e]=2|c[e],d.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],172:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,c=e.split(".");s/g),o=0;oi||c===a||cl||e&&s(t))}:function(t,e){var s=t[0],c=t[1];if(s===a||si||c===a||cl)return!1;var u,f,d,p,h,g=r.length,v=r[0][0],y=r[0][1],m=0;for(u=1;uMath.max(f,v)||c>Math.max(d,y)))if(cu||Math.abs(n(o,d))>a)return!0;return!1};i.filter=function(t,e){var r=[t[0]],n=0,a=0;function i(i){t.push(i);var l=r.length,s=n;r.splice(a+1);for(var c=s+1;c1&&i(t.pop());return{addPt:i,raw:t,filtered:r}}},{"../constants/numerical":146,"./matrix":170}],177:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ra.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function c(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,u,f=0,d=e.length,p=0,h=d>1?(e[d-1]-e[0])/(d-1):1;for(u=h>=0?r?o:l:r?c:s,t+=1e-9*h*(r?-1:1)*(h>=0?1:-1);f90&&a.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,a=e[n]-e[0]||1,i=a/(n||1)/1e4,o=[e[0]],l=0;le[l]+i&&(a=Math.min(a,e[l+1]-e[l]),o.push(e[l+1]));return{vals:o,minDiff:a}},r.roundUp=function(t,e,r){for(var n,a=0,i=e.length-1,o=0,l=r?0:1,s=r?1:0,c=r?Math.ceil:Math.floor;a0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||i;for(var r,n=1/0,a=0;ai.length)&&(o=i.length),n(e)||(e=!1),a(i[0])){for(s=new Array(o),l=0;lt.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":151,"fast-isnumeric":13}],185:[function(t,e,r){"use strict";var n=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function l(t,e){return t.node().getBoundingClientRect()[e]}var s=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var L=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&L.match(s),O=n.select(t.node().parentNode);if(!O.empty()){var P=t.attr("class")?t.attr("class").split(" ")[0]:"text";return P+="-math",O.selectAll("svg."+P).remove(),O.selectAll("g."+P+"-group").remove(),t.style("display",null).attr({"data-unformatted":L,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),i={fontSize:r};!function(t,e,r){var i,o,l,s;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),l=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+a.randstr({},64);return s=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(s.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(s.select(".MathJax_SVG").empty()||!s.select("svg").node())a.log("There was an error in the tex syntax.",t),r();else{var o=s.select("svg").node().getBoundingClientRect();r(s.select(".MathJax_SVG"),e,o)}if(s.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==l&&(MathJax.Hub.processSectionDelay=l),MathJax.Hub.Config(o)})}(S[2],i,function(n,a,i){O.selectAll("svg."+P).remove(),O.selectAll("g."+P+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return D(),void e();var s=O.append("g").classed(P+"-group",!0).attr({"pointer-events":"none","data-unformatted":L,"data-math":"Y"});s.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:P,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=l(o,"width"),f=l(o,"height"),d=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(r||l(t,"height"))/4;"y"===P[0]?(s.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===P[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===P[0]?o.attr({x:0,y:p}):o.attr({x:d,y:+t.attr("y")+p-f/2}),v&&v.call(t,s),e(s)})})):D(),t}function D(){O.empty()||(P=t.attr("class")+"-math",O.select("svg."+P).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var r,l=!1,s=[],c=-1;function u(){c++;var e=document.createElementNS(i.svg,"tspan");n.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),r=e;var a=s;if(s=[{node:e}],a.length>1)for(var l=1;l doesnt match end tag <"+t+">. Pretending it did match.",e),r=s[s.length-1].node}else a.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(r=t,s=[{node:t}]);for(var O=e.split(m),P=0;P|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},d={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},h="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,m=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,T=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function M(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&C(n)}var A=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var L={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function C(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):L[e])||t})}function O(t,e,r){var n,a,i,o=r.horizontalAlign,l=r.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-n.height}:"middle"===l?function(){return s.top+(s.height-n.height)/2}:function(){return s.top},i="right"===o?function(){return s.right-n.width}:"center"===o?function(){return s.left+(s.width-n.width)/2}:function(){return s.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:i()-c.left+"px","z-index":1e3}),this}}r.convertEntities=C,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function a(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var i=a("x",e),o=a("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},r.makeEditable=function(t,e){var r=e.gd,a=e.delegate,i=n.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function l(){!function(){var a=n.select(r).select(".svg-container"),o=a.append("div"),l=t.node().style,c=parseFloat(l.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":l.fontFamily||"Arial","font-size":c,color:e.fill||l.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(O(t,a,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=n.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),n.select(this).call(O(t,a,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(s)}(),t.style({opacity:0});var a,l=o.attr("class");(a=l?"."+l.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(a).style({opacity:0})}function s(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?l():o.on("click",l),n.rebind(t,i,"on")}},{"../constants/alignment":144,"../constants/xmlns_namespaces":147,"../lib":164,d3:11}],186:[function(t,e,r){"use strict";var n={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var i=n[t],o=Date.now();if(!i){for(var l in n)n[l].tsi.ts+e?s():i.timer=setTimeout(function(){s(),i.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)a(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],187:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":13}],188:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],189:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],190:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,a=n.layoutArrayContainers,i=n.layoutArrayRegexes,o=t.split("[")[0],l=0;l0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var n=(l.subplotsRegistry.cartesian||{}).attrRegex,i=(l.subplotsRegistry.gl3d||{}).attrRegex,s=Object.keys(t);for(e=0;e3?(A.x=1.02,A.xanchor="left"):A.x<-2&&(A.x=-.02,A.xanchor="right"),A.y>3?(A.y=1.02,A.yanchor="bottom"):A.y<-2&&(A.y=-.02,A.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=m(e);r;){if(r in t)return!0;r=m(r)}return!1};var x=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&o.warn("Full array edits are incompatible with other edits",f);var m=r[""][""];if(u(m))e.set(null);else{if(!Array.isArray(m))return o.warn("Unrecognized full array edit value",f,m),!0;e.set(m)}return!g&&(d(v,y),p(t),!0)}var x,b,_,w,k,T,M,A=Object.keys(r).map(Number).sort(l),L=e.get(),S=L||[],C=n(y,f).get(),O=[],P=-1,D=S.length;for(x=0;xS.length-(M?0:1))o.warn("index out of range",f,_);else if(void 0!==T)k.length>1&&o.warn("Insertion & removal are incompatible with edits to the same index.",f,_),u(T)?O.push(_):M?("add"===T&&(T={}),S.splice(_,0,T),C&&C.splice(_,0,{})):o.warn("Unrecognized full object edit value",f,_,T),-1===P&&(P=_);else for(b=0;b=0;x--)S.splice(O[x],1),C&&C.splice(O[x],1);if(S.length?L||e.set(S):e.set(null),g)return!1;if(d(v,y),h!==i){var z;if(-1===P)z=A;else{for(D=Math.max(S.length,D),z=[],x=0;x=P);x++)z.push(_);for(x=P;x=t.data.length||a<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(a,n+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+r+" must be unique.")}}function z(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),D(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&D(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function E(t,e,r,n,i){!function(t,e,r,n){var a=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var i in D(t,r,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==r.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in n)||!Array.isArray(n[i])||n[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var l=function(t,e,r,n){var i,l,s,c,u,f=o.isPlainObject(n),d=[];for(var p in Array.isArray(r)||(r=[r]),r=P(r,t.data.length-1),e)for(var h=0;h=0&&r=0&&r0&&"string"!=typeof C.parts[P];)P--;var D=C.parts[P],z=C.parts[P-1]+"."+D,E=C.parts.slice(0,P).join("."),N=o.nestedProperty(t.layout,E).get(),I=o.nestedProperty(l,E).get(),F=C.get();if(void 0!==O){m[S]=O,x[S]="reverse"===D?O:R(F);var B=u.getLayoutValObject(l,C.parts);if(B&&B.impliedEdits&&null!==O)for(var V in B.impliedEdits)b(o.relativeAttr(S,V),B.impliedEdits[V]);if(-1!==["width","height"].indexOf(S))if(O){b("autosize",null);var G="height"===S?"width":"height";b(G,l[G])}else l[S]=t._initialAutoSize[S];else if("autosize"===S)b("width",O?null:l.width),b("height",O?null:l.height);else if(z.match(j))L(z),o.nestedProperty(l,E+"._inputRange").set(null);else if(z.match(H)){L(z),o.nestedProperty(l,E+"._inputRange").set(null);var Z=o.nestedProperty(l,E).get();Z._inputDomain&&(Z._input.domain=Z._inputDomain.slice())}else z.match(q)&&o.nestedProperty(l,E+"._inputDomain").set(null);if("type"===D){var Y=N,X="linear"===I.type&&"log"===O,W="log"===I.type&&"linear"===O;if(X||W){if(Y&&Y.range)if(I.autorange)X&&(Y.range=Y.range[1]>Y.range[0]?[1,2]:[2,1]);else{var J=Y.range[0],Q=Y.range[1];X?(J<=0&&Q<=0&&b(E+".autorange",!0),J<=0?J=Q/1e6:Q<=0&&(Q=J/1e6),b(E+".range[0]",Math.log(J)/Math.LN10),b(E+".range[1]",Math.log(Q)/Math.LN10)):(b(E+".range[0]",Math.pow(10,J)),b(E+".range[1]",Math.pow(10,Q)))}else b(E+".autorange",!0);Array.isArray(l._subplots.polar)&&l._subplots.polar.length&&l[C.parts[0]]&&"radialaxis"===C.parts[1]&&delete l[C.parts[0]]._subplot.viewInitial["radialaxis.range"],c.getComponentMethod("annotations","convertCoords")(t,I,O,b),c.getComponentMethod("images","convertCoords")(t,I,O,b)}else b(E+".autorange",!0),b(E+".range",null);o.nestedProperty(l,E+"._inputRange").set(null)}else if(D.match(M)){var $=o.nestedProperty(l,S).get(),K=(O||{}).type;K&&"-"!==K||(K="linear"),c.getComponentMethod("annotations","convertCoords")(t,$,K,b),c.getComponentMethod("images","convertCoords")(t,$,K,b)}var tt=_.containerArrayMatch(S);if(tt){r=tt.array,n=tt.index;var et=tt.property,rt=(o.nestedProperty(i,r)||[])[n]||{},nt=B||{editType:"calc"};""!==n&&""===et&&(_.isAddVal(O)?x[S]=null:_.isRemoveVal(O)?x[S]=rt:o.warn("unrecognized full object value",e)),T.update(y,nt),d[r]||(d[r]={});var at=d[r][n];at||(at=d[r][n]={}),at[et]=O,delete e[S]}else"reverse"===D?(N.range?N.range.reverse():(b(E+".autorange",!0),N.range=[1,0]),I.autorange?y.calc=!0:y.plot=!0):(l._has("scatter-like")&&l._has("regl")&&"dragmode"===S&&("lasso"===O||"select"===O)&&"lasso"!==F&&"select"!==F?y.plot=!0:B?T.update(y,B):y.calc=!0,C.set(O))}}for(r in d){_.applyContainerArrayChanges(t,o.nestedProperty(i,r),d[r],y)||(y.plot=!0)}var it=l._axisConstraintGroups||[];for(k in A)for(n=0;n=a.length?a[0]:a[t]:a}function s(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function c(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(i,u){function d(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,f.transition(t,e.frame.data,e.frame.layout,w.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function p(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&d()};e()}var h,g,v=0;function y(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var m=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))m.push({type:"object",data:y(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(h=0;h0&&TT)&&M.push(g);m=M}}m.length>0?function(e){if(0!==e.length){for(var a=0;a=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(u[g]||h[g]||{}).name,y=e[n].name,m=u[v]||h[v];v&&y&&"number"==typeof y&&m&&A<5&&(A++,o.warn('addFrames: overwriting frame "'+(u[v]||h[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===A&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),h[g]={name:g},p.push({frame:f.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:d+n})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(a=p[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;u[a.name="frame "+t._transitionData._counter++];);if(u[a.name]){for(i=0;i=0;r--)n=e[r],i.push({type:"delete",index:n}),l.unshift({type:"insert",index:n,value:a[n]});var c=f.modifyFrames,u=f.modifyFrames,d=[t,l],p=[t,i];return s&&s.add(t,c,d,u,p),f.modifyFrames(t,i)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return f.cleanPlot([],{},r,e),f.purge(t),l.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":46,"../components/colorbar/connect":48,"../components/drawing":71,"../constants/xmlns_namespaces":147,"../lib":164,"../lib/events":157,"../lib/queue":178,"../lib/svg_text_utils":185,"../plots/cartesian/axes":208,"../plots/cartesian/constants":214,"../plots/cartesian/graph_interact":218,"../plots/plots":241,"../plots/polar/legacy":244,"../registry":248,"./edit_types":191,"./helpers":192,"./manage_arrays":194,"./plot_config":196,"./plot_schema":197,"./subroutines":199,d3:11,"fast-isnumeric":13,"has-hover":15}],196:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],197:[function(t,e,r){"use strict";var n=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),l=t("../plots/frame_attributes"),s=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),d=a.extendFlat,p=a.extendDeepAll,h=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",y=[g,v,"_arrayAttrRegexps","_deprecated"];function m(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(x(e[r]))r++;else if(r=i.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!x(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):h(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(h(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=s.length)return!1;a=(r=(n.transformsRegistry[s[u].type]||{}).attributes)&&r[e[2]],l=3}else if("area"===t.type)a=c[o];else{var f=t._module;if(f||(f=(n.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(r=f.attributes)&&r[o])){var d=f.basePlotModule;d&&d.attributes&&(a=d.attributes[o])}a||(a=i[o])}return m(a,e,l)},r.getLayoutValObject=function(t,e){return m(function(t,e){var r,a,i,l,s=t._basePlotModules;if(s){var c;for(r=0;r=a&&(r._input||{})._templateitemname;l&&(o=a);var s,c=e+"["+o+"]";function u(){s={},l&&(s[c]={},s[c][i]=l)}function f(t,e){l?n.nestedProperty(s[c],t).set(e):s[c+"."+t]=e}function d(){var t=s;return u(),t}return u(),{modifyBase:function(t,e){s[t]=e},modifyItem:f,getUpdateObj:d,applyUpdate:function(e,r){e&&f(e,r);var a=d();for(var i in a)n.nestedProperty(t,i).set(a[i])}}}},{"../lib":164,"../plots/attributes":205}],199:[function(t,e,r){"use strict";var n=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),l=t("../lib/clear_gl_canvases"),s=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),d=t("../plots/cartesian/axes"),p=t("../constants/alignment"),h=t("../plots/cartesian/constraints"),g=h.enforce,v=h.clean,y=t("../plots/cartesian/autorange").doAutoRange;function m(t,e,r){for(var n=0;n=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function x(t){var e,a,i,l,u,h=t._fullLayout,g=h._size,v=g.p,y=d.list(t,"",!0);if(h._paperdiv.style({width:t._context.responsive&&h.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":h.width+"px",height:t._context.responsive&&h.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":h.height+"px"}).selectAll(".main-svg").call(c.setSize,h.width,h.height),t._context.setBackground(t,h.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!h._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-v-n:e._offset+e._length+v+n:g.t+g.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+v+n:e._offset-v-n:g.l+g.w*(t.position||0)+n%1}for(e=0;ek?u.push({code:"unused",traceType:m,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:m,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var i=e[n],o=p(e,n,r);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&u.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&h(i)&&t(i,o)}}({data:v,layout:d},""),u.length)return u.map(g)}},{"../lib":164,"../plots/attributes":205,"../plots/plots":241,"./plot_config":196,"./plot_schema":197,"./plot_template":198}],201:[function(t,e,r){"use strict";var n=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),l=t("../snapshot/svgtoimg"),s={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,u,f;function d(t){return!(t in e)||a.validate(e[t],s[t])}if(e=e||{},a.isPlainObject(t)?(r=t.data||[],u=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),r=a.extendDeep([],t.data),u=a.extendDeep({},t.layout),f=t._context),!d("width")||!d("height"))throw new Error("Height and width should be pixel values.");if(!d("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function h(t,r){return a.coerce(e,p,s,t,r)}var g=h("format"),v=h("width"),y=h("height"),m=h("scale"),x=h("setBackground"),b=h("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},u);v&&(w.width=v),y&&(w.height=y);var k=a.extendFlat({},f,{staticPlot:!0,setBackground:x}),T=i.getRedrawFunc(_);function M(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function A(){return new Promise(function(t,e){var r=o(_,g,m),i=_._fullLayout.width,s=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(b?r:"data:image/svg+xml,"+encodeURIComponent(r));var c=document.createElement("canvas");c.id=a.randstr(),l({format:g,width:i,height:s,scale:m,canvas:c,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,k).then(T).then(M).then(A).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":164,"../snapshot/helpers":252,"../snapshot/svgtoimg":254,"../snapshot/tosvg":256,"./plot_api":195}],202:[function(t,e,r){"use strict";var n=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),l=n.isPlainObject,s=Array.isArray,c=n.isArrayOrTypedArray;function u(t,e,r,a,i,o){o=o||[];for(var f=Object.keys(t),d=0;dx.length&&a.push(p("unused",i,y.concat(x.length)));var T,M,A,L,S,C=x.length,O=Array.isArray(k);if(O&&(C=Math.min(C,k.length)),2===b.dimensions)for(M=0;Mx[M].length&&a.push(p("unused",i,y.concat(M,x[M].length)));var P=x[M].length;for(T=0;T<(O?Math.min(P,k[M].length):P);T++)A=O?k[M][T]:k,L=m[M][T],S=x[M][T],n.validate(L,A)?S!==L&&S!==+L&&a.push(p("dynamic",i,y.concat(M,T),L,S)):a.push(p("value",i,y.concat(M,T),L))}else a.push(p("array",i,y.concat(M),m[M]));else for(M=0;M1&&d.push(p("object","layout"))),a.supplyDefaults(h);for(var g=h._fullData,v=r.length,y=0;y0&&((b=M-o(v)-o(y))>A?_/b>L&&(m=v,x=y,L=_/b):_/M>L&&(m={val:v.val,pad:0},x={val:y.val,pad:0},L=_/M));if(d===p){var S=d-1,C=d+1;if(k)if(0===d)i=[0,1];else{var O=(d>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),P=d/(1-Math.min(.5,O/M));i=d>0?[0,P]:[P,0]}else i=T?[Math.max(0,S),Math.max(1,C)]:[S,C]}else k?(m.val>=0&&(m={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):T&&(m.val-L*o(m)<0&&(m={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),L=(x.val-m.val)/(M-o(m)-o(x)),i=[m.val-L*o(m),x.val+L*o(x)];return h&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function l(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function s(t,e){var r,n,a,i=e._id,o=t._fullData,l=t._fullLayout,s=[],f=[];function d(t,e){for(r=0;r=r&&(c.extrapad||!o)){l=!1;break}a(e,c.val)&&c.pad<=r&&(o||!c.extrapad)&&(t.splice(s,1),s--)}if(l){var u=i&&0===e;t.push({val:e,pad:u?0:r,extrapad:!u&&o})}}function d(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:o,makePadFn:l,doAutoRange:function(t,e){e._length||e.setScale();var r;e.autorange&&(e.range=o(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l),(r=e._input).range=e.range.slice(),r.autorange=e.autorange);if(e._anchorAxis&&e._anchorAxis.rangeslider){var n=e._anchorAxis.rangeslider[e._name];n&&"auto"===n.rangemode&&(n.range=o(t,e)),(r=e._anchorAxis._input).rangeslider[e._name]=a.extendFlat({},n)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var a,o,l,s,f,p,h,g,v,y=[],m=[],x=e.length,b=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function T(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var M=T((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),A=T((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),L=T(r.vpadplus||r.vpad),S=T(r.vpadminus||r.vpad);if(!k){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=P;a--)O(a);return{min:y,max:m}},concatExtremes:s}},{"../../constants/numerical":146,"../../lib":164,"fast-isnumeric":13}],208:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),d=t("./layout_attributes"),p=t("./clean_ticks"),h=t("../../constants/numerical"),g=h.ONEAVGYEAR,v=h.ONEAVGMONTH,y=h.ONEDAY,m=h.ONEHOUR,x=h.ONEMIN,b=h.ONESEC,_=h.MINUS_SIGN,w=h.BADNUM,k=t("../../constants/alignment").MID_SHIFT,T=t("../../constants/alignment").LINE_SPACING,M=e.exports={};M.setConvert=t("./set_convert");var A=t("./axis_autotype"),L=t("./axis_ids");M.id2name=L.id2name,M.name2id=L.name2id,M.cleanId=L.cleanId,M.list=L.list,M.listIds=L.listIds,M.getFromId=L.getFromId,M.getFromTrace=L.getFromTrace;var S=t("./autorange");M.getAutoRange=S.getAutoRange,M.findExtremes=S.findExtremes,M.coerceRef=function(t,e,r,n,a,i){var o=n.charAt(n.length-1),s=r._fullLayout._subplots[o+"axis"],c=n+"ref",u={};return a||(a=s[0]||i),i||(i=a),u[c]={valType:"enumerated",values:s.concat(i?[i]:[]),dflt:a},l.coerce(t,e,u,c)},M.coercePosition=function(t,e,r,n,a,i){var o,s;if("paper"===n||"pixel"===n)o=l.ensureNumber,s=r(a,i);else{var c=M.getFromId(e,n);s=r(a,i=c.fraction2r(i)),o=c.cleanPos}t[a]=o(s)},M.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?l.ensureNumber:M.getFromId(e,r).cleanPos)(t)};var C=M.getDataConversions=function(t,e,r,n){var a,i="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(i)){if(a={type:A(n),_categories:[]},M.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},M.saveRangeInitial=function(t,e){for(var r=M.list(t,"",!0),n=!1,a=0;a.3*d||u(n)||u(i))){var p=r.dtick/2;t+=t+p.8){var o=Number(r.substr(1));i.exactYears>.8&&o%12==0?t=M.tickIncrement(t,"M6","reverse")+1.5*y:i.exactMonths>.8?t=M.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var s=M.tickIncrement(t,r);if(s<=n)return s}return t}(x,t,m,c,i)),v=x,0;v<=u;)v=M.tickIncrement(v,m,!1,i),0;return{start:e.c2r(x,0,i),end:e.c2r(v,0,i),size:m,_dataSpan:u-c}},M.prepTicks=function(t){var e=l.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=l.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),M.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},M.calcTicks=function(t){M.prepTicks(t);var e=l.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e,r,n=t.tickvals,a=t.ticktext,i=new Array(n.length),o=l.simpleMap(t.range,t.r2l),s=1.0001*o[0]-1e-4*o[1],c=1.0001*o[1]-1e-4*o[0],u=Math.min(s,c),f=Math.max(s,c),d=0;Array.isArray(a)||(a=[]);var p="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(r=0;ru&&e=n:c<=n)&&!(i.length>s||c===o);c=M.tickIncrement(c,t.dtick,a,t.calendar))o=c,i.push(c);J(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(i.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&i<=10||e>=15*y)t._tickround="d";else if(e>=x&&i<=16||e>=m)t._tickround="M";else if(e>=b&&i<=19||e>=x)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var l=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var s=Math.max(Math.abs(l[0]),Math.abs(l[1])),c=Math.floor(Math.log(s)/Math.LN10+.01);Math.abs(c)>3&&(V(t.exponentformat)&&!U(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function H(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}M.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=l.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,r=n(10),t.dtick="M"+12*B(e,r,D)):i>v?(e/=v,t.dtick="M"+B(e,1,z)):i>y?(t.dtick=B(e,y,N),t.tick0=l.dateTick0(t.calendar,!0)):i>m?t.dtick=B(e,m,z):i>x?t.dtick=B(e,x,E):i>b?t.dtick=B(e,b,E):(r=n(10),t.dtick=B(e,r,D))}else if("log"===t.type){t.tick0=0;var o=l.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var s=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/s,r=n(10),t.dtick="L"+B(e,r,D)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):J(t)?(t.tick0=0,r=1,t.dtick=B(e,r,F)):(t.tick0=0,r=n(10),t.dtick=B(e,r,D));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},M.tickIncrement=function(t,e,r,i){var o=r?-1:1;if(a(e))return t+o*e;var s=e.charAt(0),c=o*Number(e.substr(1));if("M"===s)return l.incrementMonth(t,c,i);if("L"===s)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===s){var u="D2"===e?I:R,f=t+.01*o,d=l.roundUp(l.mod(f,1),u,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(e)},M.tickFirst=function(t){var e=t.r2l||Number,r=l.simpleMap(t.range,e),i=r[1]"+s,t._prevDateHead=s));e.text=c}(t,o,r,c):"log"===t.type?function(t,e,r,n,i){var o=t.dtick,s=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===i&&(i="");n&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,s),t,i,n);else if(a(o)||"D"===u&&l.mod(s+.01,1)<.1){var f=Math.round(s),d=Math.abs(f),p=t.exponentformat;"power"===p||V(p)&&U(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+d+"",e.fontSize*=1.25):("e"===p||"E"===p)&&d>2?e.text="1"+p+(f>0?"+":_)+d:(e.text=G(Math.pow(10,s),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,l.mod(s,1)))),e.fontSize*=.75}if("D1"===t.dtick){var h=String(e.text).charAt(0);"0"!==h&&"1"!==h||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(s<0?.5:.25)))}}(t,o,0,c,n):"category"===t.type?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,o):J(t)?function(t,e,r,n,a){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,a,n);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,a=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/a),Math.round(r/a)]}(i);if(o[1]>=100)e.text=G(l.deg2rad(e.x),t,a,n);else{var s=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),s&&(e.text=_+e.text)}}}}(t,o,r,c,n):function(t,e,r,n,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,n)}(t,o,0,c,n),t.tickprefix&&!p(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!p(t.showticksuffix)&&(o.text+=t.ticksuffix),o},M.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return M.hoverLabelText(t,e)+" - "+M.hoverLabelText(t,r);var n="log"===t.type&&e<=0,a=M.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+a:a};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function V(t){return"SI"===t||"B"===t}function U(t){return t>14||t<-15}function G(t,e,r,n){var i=t<0,o=e._tickround,s=r||e.exponentformat||"B",c=e._tickexponent,u=M.getTickFormat(e),f=e.separatethousands;if(n){var d={exponentformat:s,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(d),o=(Number(d._tickround)||0)+4,c=d._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,h=Math.pow(10,-o)/2;if("none"===s&&(c=0),(t=Math.abs(t))"+p+"":"B"===s&&9===c?t+="B":V(s)&&(t+=q[c/3+5]));return i?_+t:t}function Z(t,e){var r=t.l2p(e);return r>1&&r=0,i=u(t,e[1])<=0;return(r||a)&&(n||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},l=0;l2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":248,"./constants":214}],212:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var l,s=r("categoryorder",a);"array"===s&&(l=r("categoryarray")),o||"array"!==s||(s=e.categoryorder="trace"),"trace"===s?e._initialCategories=[]:"array"===s?e._initialCategories=l.slice():(l=function(t,e){var r,n,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;nl*x)||k)for(r=0;rz&&RP&&(P=R);p/=(P-O)/(2*D),O=u.l2r(O),P=u.l2r(P),u.range=u._input.range=L=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function E(t,e,r,n,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",a+"Z")}function N(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function R(t,e,r,n,a,i){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),I(t,e,a,i)}function I(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function B(t){L&&t.data&&t._context.showTips&&(l.notifier(l._(t,"Double-click to zoom back out"),"long"),L=!1)}function j(t){return"lasso"===t||"select"===t}function H(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,A)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(i){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function V(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,i,c,d,L,S){var I,U,G,Z,Y,X,W,J,Q,$,K,tt,et,rt,nt,at,it,ot,lt,st,ct,ut=t._fullLayout._zoomlayer,ft=L+S==="nsew",dt=1===(L+S).length;function pt(){if(I=e.xaxis,U=e.yaxis,Q=I._length,$=U._length,W=I._offset,J=U._offset,(G={})[I._id]=I,(Z={})[U._id]=U,L&&S)for(var r=e.overlays,n=0;n-1&&w(a,t,Y,X,e.id,At),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===r&&dt){var l=L?U:I,c="s"===L||"w"===S?0:1,u=l._name+".range["+c+"]",d=function(t,e){var r,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,a))):(r=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,n.format("."+String(r)+"g")(a))}(l,c),p="left",h="middle";if(l.fixedrange)return;L?(h="n"===L?"top":"bottom","right"===l.side&&(p="right")):"e"===S&&(p="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(s.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(d),fill:l.tickfont?l.tickfont.color:"#444",horizontalAlign:p,verticalAlign:h}).on("edit",function(e){var r=l.d2r(e);void 0!==r&&o.call("relayout",t,u,r)})}}function Ct(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min(Q,e+vt)),a=Math.max(0,Math.min($,r+yt)),i=Math.abs(n-vt),o=Math.abs(a-yt);function l(){wt="",mt.r=mt.l,mt.t=mt.b,Tt.attr("d","M0,0Z")}mt.l=Math.min(vt,n),mt.r=Math.max(vt,n),mt.t=Math.min(yt,a),mt.b=Math.max(yt,a),nt?i>A||o>A?(wt="xy",i/Q>o/$?(o=i*$/Q,yt>a?mt.t=yt-o:mt.b=yt+o):(i=o*Q/$,vt>n?mt.l=vt-i:mt.r=vt+i),Tt.attr("d",H(mt))):l():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Et);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var a,i=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=Rt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(at){for(S||(s=.5),a=0;ag[1]-.01&&(e.domain=l),a.noneOrAll(t.domain,e.domain,l)}return r("layer"),e}},{"../../lib":164,"fast-isnumeric":13}],225:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*r;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":144}],226:[function(t,e,r){"use strict";var n=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),l=t("../../lib/polygon"),s=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),d=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),h=p.MINSELECT,g=l.filter,v=l.tester;function y(t){return t._id}function m(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h,g,v=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,m=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var x=function(t,e){var r,n,a=t[0],i=-1,o=[];for(n=0;n0?function(t,e){var r,n,a,i=[];for(a=0;a0&&i.push(r);if(1===i.length&&i[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=r.selectedpoints.length)>1)return!1}return 1===a}(l)&&(d=A(x))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",n)}function A(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,a=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function L(t,e,r){var n,i,o,l;if(r){var s=r.points||[];for(n=0;n-1&&m(e,A,a.xaxes,a.yaxes,a.subplot,a,U),"event"===r&&A.emit("plotly_selected",void 0);o.click(A,e)})},a.doneFn=function(){Z.remove(),s.done(Y).then(function(){s.clear(Y),a.gd.emit("plotly_selected",b),d&&a.selectionDefs&&(d.subtract=V,a.selectionDefs.push(d),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:C,selectOnClick:m}},{"../../components/color":46,"../../components/fx":88,"../../components/fx/helpers":85,"../../lib/clear_gl_canvases":153,"../../lib/polygon":176,"../../lib/throttle":186,"../../plot_api/subroutines":199,"../../registry":248,"./axis_ids":211,"./constants":214,polybooljs:20}],227:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,l=i.ms2DateTime,s=i.dateTime2ms,c=i.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,d=u.BADNUM,p=u.LOG_CLIP,h=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function u(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],a=t.range[1];return.5*(n+a-2*p*Math.abs(n-a))}return d}function y(e,r,n){var o=s(e,n||t.calendar);if(o===d){if(!a(e))return d;e=+e;var l=Math.floor(10*i.mod(e+.05,1)),c=Math.round(e-l/10);o=s(new Date(c))+l/10}return o}function m(e,r,n){return l(e,r,n||t.calendar)}function x(e){return t._categories[Math.round(e)]}function b(e){if(t._categoriesMap){var r=t._categoriesMap[e];if(void 0!==r)return r}if(a(e))return+e}function _(e){return a(e)?n.round(t._b+t._m*e,2):d}function w(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=_,t.p2l=w,t.c2p="log"===t.type?function(t,e){return _(u(t,e))}:_,t.p2c="log"===t.type?function(t){return v(w(t))}:w,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=w,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(w(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=w,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=y,t.c2d=t.c2r=t.l2d=t.l2r=m,t.d2p=t.r2p=function(e,r,n){return t.l2p(y(e,0,n))},t.p2d=t.p2r=function(t,e,r){return m(w(t),e,r)},t.cleanPos=function(e){return i.cleanDate(e,d,t.calendar)}):"category"===t.type&&(t.d2c=t.d2l=function(e){if(null!=e){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return d},t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=b,t.r2c=function(e){var r=b(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=b,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(w(t))},t.r2p=t.d2p,t.p2r=w,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,l,s=i.nestedProperty(t,e).get();if(l=(l="date"===t.type?i.dfltRange(t.calendar):"y"===r?h.DFLTRANGEY:n.dfltRange||h.DFLTRANGEX).slice(),s&&2===s.length)for("date"===t.type&&(s[0]=i.cleanDate(s[0],d,t.calendar),s[1]=i.cleanDate(s[1],d,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(s[o],t.calendar)){t[e]=l;break}if(t.r2l(s[0])===t.r2l(s[1])){var c=i.constrain(t.r2l(s[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);s[0]=t.l2r(c-1e3),s[1]=t.l2r(c+1e3);break}}else{if(!a(s[o])){if(!a(s[1-o])){t[e]=l;break}s[o]=s[1-o]*(o?10:.1)}if(s[o]<-f?s[o]=-f:s[o]>f&&(s[o]=f),s[0]===s[1]){var u=Math.max(1,Math.abs(1e-6*s[0]));s[0]-=u,s[1]+=u}}else i.nestedProperty(t,e).set(l)},t.setScale=function(n){var a=e._size;if(t._categories||(t._categories=[]),t._categoriesMap||(t._categoriesMap={}),t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=n&&t._r?"_r":"range",l=t.calendar;t.cleanRange(o);var s=t.r2l(t[o][0],l),c=t.r2l(t[o][1],l);if("y"===r?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-c),t._b=-t._m*c):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,a,o,l,s=t.type,c="date"===s&&e[r+"calendar"];if(r in e){if(n=e[r],l=e._length||n.length,i.isTypedArray(n)&&("linear"===s||"log"===s)){if(l===n.length)return n;if(n.subarray)return n.subarray(0,l)}for(a=new Array(l),o=0;o rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,r._offset).call(i.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(i.setPointGroupScale,1,1),n.selectAll(".textpoint").call(i.setTextPointsScale,1,1),n.call(i.hideOutsideRangePoints,t)}function x(e,r){var n,l,s,u=g[e.xaxis._id],f=g[e.yaxis._id],d=[];if(u){l=(n=t._fullLayout[u.axisName])._r,s=u.to,d[0]=(l[0]*(1-r)+r*s[0]-l[0])/(l[1]-l[0])*e.xaxis._length;var p=l[1]-l[0],h=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[2]=e.xaxis._length*(1-r+r*h/p)}else d[0]=0,d[2]=e.xaxis._length;if(f){l=(n=t._fullLayout[f.axisName])._r,s=f.to,d[1]=(l[1]*(1-r)+r*s[1]-l[1])/(l[0]-l[1])*e.yaxis._length;var v=l[1]-l[0],y=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[3]=e.yaxis._length*(1-r+r*y/v)}else d[1]=0,d[3]=e.yaxis._length;!function(e,r){var n,i=[];for(i=[e._id,r._id],n=0;nr.duration?(function(){for(var e={},r=0;r0&&(a["_"+r+"axes"]||{})[e])return a;if((a[r+"axis"]||r)===e){if(o(a,r))return a;if((a[r]||[]).length||a[r+"0"])return a}}}(e,r,l);if(!s)return;if("histogram"===s.type&&l==={v:"y",h:"x"}[s.orientation||"v"])return void(t.type="linear");var c,u=l+"calendar",f=s[u];if(o(s,l)){var d=i(s),p=[];for(c=0;c0?".":"")+i;a.isPlainObject(o)?s(o,e,l,n+1):e(l,i,o)}})}r.manageCommandObserver=function(t,e,n,o){var l={},s=!0;e&&e._commandObserver&&(l=e._commandObserver),l.cache||(l.cache={}),l.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,n,l.lookupTable);if(e&&e._commandObserver){if(c)return l;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,l}if(c){i(t,c,l.cache),l.check=function(){if(s){var e=i(t,c,l.cache);return e.changed&&o&&void 0!==l.lookupTable[e.value]&&(l.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:l.lookupTable[e.value]})).then(l.enable,l.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;f=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),r.attr(i);var o=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),a=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+a})}}(t,o),l.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),a=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,a={};function o(t){for(var r=!0,i=0;i1&&z.length>1){for(i.getComponentMethod("grid","sizeDefaults")(c,l),o=0;o15&&z.length>15&&0===l.shapes.length&&0===l.images.length,l._hasCartesian=l._has("cartesian"),l._hasGeo=l._has("geo"),l._hasGL3D=l._has("gl3d"),l._hasGL2D=l._has("gl2d"),l._hasTernary=l._has("ternary"),l._hasPie=l._has("pie"),v.linkSubplots(d,l,u,a),v.cleanPlot(d,l,u,a),h(l,a),v.doAutoMargin(t);var F=f.list(t);for(o=0;o0){var f=1-2*l;n=Math.round(f*n),i=Math.round(f*i)}}var d=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-i)>1;(g||h)&&(h&&(r.width=n),g&&(r.height=i)),t._initialAutoSize||(t._initialAutoSize={width:n,height:i}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var a,o,l,c=i.componentsRegistry,u=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in c)(l=c[a]).includeBasePlot&&l.includeBasePlot(t,e);for(var d in u.length||u.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[d].sort(s.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var s=void 0!==r.xl?r.xl:r.x,c=void 0!==r.xr?r.xr:r.x,u=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;a[e]={l:{val:s,size:r.l+o},r:{val:c,size:r.r+o},b:{val:f,size:r.b+o},t:{val:u,size:r.t+o}},i[e]=1}else delete a[e],delete i[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),M(e);var r=e._size,n=JSON.stringify(r),o=Math.max(e.margin.l||0,0),l=Math.max(e.margin.r||0,0),s=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin,f=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var d in u)f[d]||delete u[d];for(var p in u.base={l:{val:0,size:o},r:{val:1,size:l},t:{val:1,size:s},b:{val:0,size:c}},u){var h=u[p].l||{},g=u[p].b||{},v=h.val,y=h.size,m=g.val,x=g.size;for(var b in u){if(a(y)&&u[b].r){var _=u[b].r.val,w=u[b].r.size;if(_>v){var k=(y*_+(w-e.width)*v)/(_-v),T=(w*(1-v)+(y-e.width)*(1-_))/(_-v);k>=0&&T>=0&&k+T>o+l&&(o=k,l=T)}}if(a(x)&&u[b].t){var A=u[b].t.val,L=u[b].t.size;if(A>m){var S=(x*A+(L-e.height)*m)/(A-m),C=(L*(1-m)+(x-e.height)*(1-A))/(A-m);S>=0&&C>=0&&S+C>c+s&&(c=S,s=C)}}}}}if(r.l=Math.round(o),r.r=Math.round(l),r.t=Math.round(s),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,r,n,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,l=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(s.isPlainObject(t)){var e,n,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!s.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;a[e]=c(t[e])}return a}return Array.isArray(t)?t.map(c):s.isTypedArray(t)?s.simpleMap(t,s.identity):s.isJSDate(t)?s.ms2DateTimeLocal(+t):t}var u={data:(i||[]).map(function(t){var r=c(t);return e&&delete r.fit,r})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),l&&(u.frames=c(l)),"object"===n?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var r,n,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,l,c=0,u=0;function f(){return c++,function(){var r;u++,p||u!==c||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var h=t._fullLayout._basePlotModules,g=!1;if(r)for(l=0;l=0;l--)if(o[l].enabled){r._indexToPoints=o[l]._indexToPoints;break}n&&n.calc&&(i=n.calc(t,r))}Array.isArray(i)&&i[0]||(i=[{x:u,y:u}]),i[0].t||(i[0].t={}),i[0].trace=r,h[e]=i}}for(m&&A(c),a=0;a=0?d.angularAxis.domain:n.extent(k),S=Math.abs(k[1]-k[0]);M&&!T&&(S=0);var C=L.slice();A&&T&&(C[1]+=S);var O=d.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),d.angularAxis.ticksStep&&(O=(C[1]-C[0])/O);var P=d.angularAxis.ticksStep||(C[1]-C[0])/(O*(d.minorTicks+1));w&&(P=Math.max(Math.round(P),1)),C[2]||(C[2]=P);var D=n.range.apply(this,C);if(D=D.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=n.scale.linear().domain(C.slice(0,2)).range("clockwise"===d.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=A?S:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var z=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),E=this.appendChild(this.ownerDocument.importNode(z.documentElement,!0));t=n.select(E)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var N,R=t.select(".chart-group"),I={fill:"none",stroke:d.tickColor},F={"font-size":d.font.size,"font-family":d.font.family,fill:d.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+d.font.outlineColor}).join(",")};if(d.showLegend){N=t.select(".legend-group").attr({transform:"translate("+[x,d.margin.top]+")"}).style({display:"block"});var B=p.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:N,elements:B,reverseOrder:d.legend.reverseOrder})})();var j=N.node().getBBox();x=Math.min(d.width-j.width-d.margin.left-d.margin.right,d.height-d.margin.top-d.margin.bottom)/2,x=Math.max(10,x),_=[d.margin.left+x,d.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),N.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else N=t.select(".legend-group").style({display:"none"});t.attr({width:d.width,height:d.height}).style({opacity:d.opacity}),R.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(d.width-(d.margin.left+d.margin.right+2*x+(j?j.width:0)))/2,(d.height-(d.margin.top+d.margin.bottom+2*x))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),t.select(".outer-group").attr("transform","translate("+H+")"),d.title){var q=t.select("g.title-group text").style(F).text(d.title),V=q.node().getBBox();q.attr({x:_[0]-V.width/2,y:_[1]-x-20})}var U=t.select(".radial.axis-group");if(d.radialAxis.gridLinesVisible){var G=U.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(I),G.attr("r",r),G.exit().remove()}U.select("circle.outside-circle").attr({r:x}).style(I);var Z=t.select("circle.background-circle").attr({r:x}).style({fill:d.backgroundColor,stroke:d.stroke});function Y(t,e){return l(t)%360+d.orientation}if(d.radialAxis.visible){var X=n.svg.axis().scale(r).ticks(5).tickSize(5);U.call(X).attr({transform:"rotate("+d.radialAxis.orientation+")"}),U.selectAll(".domain").style(I),U.selectAll("g>text").text(function(t,e){return this.textContent+d.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===d.radialAxis.tickOrientation?"rotate("+-d.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),U.selectAll("g>line").style({stroke:"black"})}var W=t.select(".angular.axis-group").selectAll("g.angular-tick").data(D),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+Y(t)+")"}}).style({display:d.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(d.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(d.minorTicks+1)==0)}).style(I),J.selectAll(".minor").style({stroke:d.minorTickColor}),W.select("line.grid-line").attr({x1:d.tickLength?x-d.tickLength:0,x2:x}).style({display:d.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(F);var Q=W.select("text.axis-text").attr({x:x+d.labelOffset,dy:i+"em",transform:function(t,e){var r=Y(t),n=x+d.labelOffset,a=d.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-r+" "+n+" 0)":"radial"==a?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:d.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(d.minorTicks+1)!=0?"":w?w[t]+d.angularAxis.ticksSuffix:t+d.angularAxis.ticksSuffix}).style(F);d.angularAxis.rewriteTicks&&Q.text(function(t,e){return e%(d.minorTicks+1)!=0?"":d.angularAxis.rewriteTicks(this.textContent,e)});var $=n.max(R.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));N.attr({transform:"translate("+[x+$,d.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||K){var et=[];p.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=d.orientation,n.direction=d.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return a(o[r].defaultConfig(),t)});o[r]().config(n)()})}var at,it,ot=t.select(".guides-group"),lt=t.select(".tooltips-group"),st=o.tooltipPanel().config({container:lt,fontSize:8})(),ct=o.tooltipPanel().config({container:lt,fontSize:8})(),ut=o.tooltipPanel().config({container:lt,hasTick:!0})();if(!T){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});R.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(Z).angle;ft.attr({x2:-x,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-d.orientation)%360;at=l.invert(n);var a=o.util.convertToCartesian(x+12,r+180);st.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var dt=ot.select("circle").style({stroke:"grey",fill:"none"});R.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(Z).radius;dt.attr({r:n}).style({opacity:.5}),it=r.invert(o.util.getMousePos(Z).radius);var a=o.util.convertToCartesian(n,d.radialAxis.orientation);ct.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){dt.style({opacity:0}),ut.hide(),st.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var a=n.select(this),i=this.style.fill,l="black",s=this.style.opacity||1;if(a.attr({"data-opacity":s}),i&&"none"!==i){a.attr({"data-fill":i}),l=n.hsl(i).darker().toString(),a.style({fill:l,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};T&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=t.node().getBoundingClientRect(),p=[f.left+f.width/2-H[0]-d.left,f.top+f.height/2-H[1]-d.top];ut.config({color:l}).text(u),ut.move(p)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),l=n.hsl(i).darker().toString(),a.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var r=n.select(this),a=r.attr("data-fill");a?r.style({fill:a,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(c),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),a(s.data[e],o.Axis.defaultConfig().data[0]),a(s.data[e],t)}),a(s.layout,o.Axis.defaultConfig().layout),a(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return t},n.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var a=e||6,i=[],o=[];n.range(0,360+a,a).forEach(function(e,r){var n=e*Math.PI/180,a=t(n);i.push(e),o.push(a)});var l={t:i,r:o};return r&&(l.name=r),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],a=e[1],i={};return i.x=r,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,r)+Math.PI)/Math.PI,i.radius=Math.sqrt(r*r+a*a),i},o.util.duplicatesCount=function(t){for(var e,r={},n={},a=0,i=t.length;a0)){var s=n.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({class:"line",d:u(l),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return h.fill(r,a,i)},"fill-opacity":0,stroke:function(t,e){return h.stroke(r,a,i)},"stroke-width":function(t,e){return h["stroke-width"](r,a,i)},"stroke-dasharray":function(t,e){return h["stroke-dasharray"](r,a,i)},opacity:function(t,e){return h.opacity(r,a,i)},display:function(t,e){return h.display(r,a,i)}})}};var f=e.angularScale.range(),d=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=n.svg.arc().startAngle(function(t){return-d/2}).endAngle(function(t){return d/2}).innerRadius(function(t){return e.radialScale(s+(t[2]||0))}).outerRadius(function(t){return e.radialScale(s+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,r,a){n.select(this).attr({class:"mark arc",d:p,transform:function(t,r){return"rotate("+(e.orientation+l(t[0])+90)+")"}})};var h={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,a){return r[t[a].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(h).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),a(t[r],o.PolyChart.defaultConfig()),a(t[r],e)}),this):t},i.getColorScale=function(){},n.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,i=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var i=a({},e.elements[r]);return i.name=t,i.color=[].concat(e.elements[r].color)[n],i})}),o=n.merge(i);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var l=e.container;("string"==typeof l||l.nodeName)&&(l=n.select(l));var s=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,d=l.classed("legend-group",!0).selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var h=n.range(o.length),g=n.scale[u?"linear":"ordinal"]().domain(h).range(s),v=n.scale[u?"linear":"ordinal"]().domain(h)[u?"range":"rangePoints"]([0,f]);if(u){var y=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var m=d.select(".legend-marks").selectAll("path.legend-mark").data(o);m.enter().append("path").classed("legend-mark",!0),m.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var r,a,i,o=t.symbol;return i=3*(a=c),"line"===(r=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(i)():n.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),m.exit().remove()}var x=n.svg.axis().scale(v).orient("right"),b=d.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(a(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){var n=(t=i.container.selectAll("g."+l).data([0])).enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:i.padding+s,dy:.3*+i.fontSize}),c};return c.text=function(a){var o=n.hsl(i.color).l,l=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":i.fontSize+"px"}).text(f);var d=i.padding,p=e.node().getBBox(),h={fill:i.color,stroke:l,"stroke-width":"2px"},g=p.width+2*d+s,v=p.height+2*d;return r.attr({d:"M"+[[s,-v/2],[s,-v/4],[i.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(h),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return a(i,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=a({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=i.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var l=a({},t.layout);if([[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var s=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(l.margin).forEach(function(t,e){u[c[s.indexOf(t.key)]]=t.value}),l.margin=u}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),r.layout=l}return r}};return t}},{"../../../constants/alignment":144,"../../../lib":164,d3:11}],246:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),l=t("./undo_manager"),s=a.extendDeepAll,c=e.exports={};c.framework=function(t){var e,r,a,i,u,f=new l;function d(r,l){return l&&(u=l),n.select(n.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?s(e,r):r,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return d.isPolar=!0,d.svg=function(){return a.svg()},d.getConfig=function(){return e},d.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},d.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},d.setUndoPoint=function(){var t,n,a=this,i=o.util.cloneJson(e);t=i,n=r,f.add({undo:function(){n&&a(n)},redo:function(){a(t)}}),r=o.util.cloneJson(i)},d.undo=function(){f.undo()},d.redo=function(){f.redo()},d},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../../components/color":46,"../../../lib":164,"./micropolar":245,"./undo_manager":247,d3:11}],247:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function a(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(a(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(a(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r-1&&(u[d[r]].title="");for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(s,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(s,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||d.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),d.node().setAttributeNS(l.xmlns,"xmlns",l.svg),d.node().setAttributeNS(l.xmlns,"xmlns:xlink",l.xlink),"svg"===e&&r&&(d.attr("width",r*h),d.attr("height",r*g),d.attr("viewBox","0 0 "+h+" "+g));var _=(new window.XMLSerializer).serializeToString(d.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":46,"../components/drawing":71,"../constants/xmlns_namespaces":147,"../lib":164,d3:11}],257:[function(t,e,r){"use strict";var n=t("../../lib").mergeArray;e.exports=function(t,e){for(var r=0;rf+c||!n(u))&&(p=!0,g(d,t))}for(var v=0;vi))return e}return void 0!==r?r:t.dflt},r.coerceColor=function(t,e,r){return a(e).isValid()?e:void 0!==r?r:t.dflt},r.coerceEnumerated=function(t,e,r){return t.coerceNumber&&(e=+e),-1!==t.values.indexOf(e)?e:void 0!==r?r:t.dflt},r.getValue=function(t,e){var r;return Array.isArray(t)?e.01?C:function(t,e){return Math.abs(t-e)>=2?C(t):t>e?Math.ceil(t):Math.floor(t)};_=S(_,w),w=S(w,_),k=S(k,T),T=S(T,k)}i.ensureSingle(M,"path").style("vector-effect","non-scaling-stroke").attr("d","M"+_+","+k+"V"+T+"H"+w+"V"+k+"Z").call(s.setClipUrl,e.layerClipId),function(t,e,r,n,a,l,c,u){var y;function m(e,r,n){var a=i.ensureSingle(e,"text").text(r).attr({class:"bartext bartext-"+y,transform:"","text-anchor":"middle","data-notex":1}).call(s.font,n).call(o.convertToTspans,t);return a}var x=r[0].trace,b=x.orientation,_=function(t,e){var r=p.getValue(t.text,e);return p.coerceString(f,r)}(x,n);if(y=function(t,e){var r=p.getValue(t.textposition,e);return p.coerceEnumerated(d,r)}(x,n),!_||"none"===y)return void e.select("text").remove();var w,k,T,M,A,L,S=t._fullLayout.font,C=h.getBarColor(r[n],x),O=h.getInsideTextFont(x,n,S,C),P=h.getOutsideTextFont(x,n,S),D=t._fullLayout.barmode,z="relative"===D,E="stack"===D||z,N=r[n],R=!E||N._outmost,I=Math.abs(l-a)-2*g,F=Math.abs(u-c)-2*g;"outside"===y&&(R||N.hasB||(y="inside"));if("auto"===y)if(R){y="inside",w=m(e,_,O),k=s.bBox(w.node()),T=k.width,M=k.height;var B=T>0&&M>0,j=T<=I&&M<=F,H=T<=F&&M<=I,q="h"===b?I>=T*(F/M):F>=M*(I/T);B&&(j||H||q)?y="inside":(y="outside",w.remove(),w=null)}else y="inside";if(!w&&(w=m(e,_,"outside"===y?P:O),k=s.bBox(w.node()),T=k.width,M=k.height,T<=0||M<=0))return void w.remove();"outside"===y?(L="both"===x.constraintext||"outside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s="h"===i?Math.abs(n-r):Math.abs(e-t);s>2*g&&(l=g);var c=1;o&&(c="h"===i?Math.min(1,s/a.height):Math.min(1,s/a.width));var u,f,d,p,h=(a.left+a.right)/2,y=(a.top+a.bottom)/2;u=c*a.width,f=c*a.height,"h"===i?er?(d=(t+e)/2,p=n+l+f/2):(d=(t+e)/2,p=n-l-f/2);return v(h,y,d,p,c,!1)}(a,l,c,u,k,b,L)):(L="both"===x.constraintext||"inside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h=a.width,y=a.height,m=(a.left+a.right)/2,x=(a.top+a.bottom)/2,b=Math.abs(e-t),_=Math.abs(n-r);b>2*g&&_>2*g?(b-=2*(f=g),_-=2*f):f=0;h<=b&&y<=_?(d=!1,p=1):h<=_&&y<=b?(d=!0,p=1):hr?(c=(t+e)/2,u=n-f-s/2):(c=(t+e)/2,u=n+f+s/2);return v(m,x,c,u,p,d)}(a,l,c,u,k,b,L));w.attr("transform",A)}(t,M,r,u,_,w,k,T),e.layerClipId&&s.hideOutsideRangePoint(c,M.select("text"),y,m,b.xcalendar,b.ycalendar)}else M.remove();function C(t){return 0===x.bargap&&0===x.bargroupgap?n.round(Math.round(t)-L,2):t}});var w=!1===u.trace.cliponaxis;s.setClipUrl(c,w?null:e.layerClipId)});c.getComponentMethod("errorbars","plot")(b,e)}},{"../../components/color":46,"../../components/drawing":71,"../../lib":164,"../../lib/svg_text_utils":185,"../../registry":248,"./attributes":258,"./helpers":262,"./style":270,d3:11,"fast-isnumeric":13}],268:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,a=t.xaxis,i=t.yaxis,o=[];if(!1===e)for(r=0;r1||0===i.bargap&&0===i.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),r.selectAll("g.points").each(function(e){p(n.select(this),e[0].trace,t)}),l.getComponentMethod("errorbars","style")(r)},styleOnSelect:function(t,e){var r=e[0].node3,a=e[0].trace;a.selectedpoints?function(t,e,r){i.selectedPointStyle(t.selectAll("path"),e),function(t,e,r){t.each(function(t){var a,l=n.select(this);if(t.selected){a=o.extendFlat({},h(l,t,e,r));var s=e.selected.textfont&&e.selected.textfont.color;s&&(a.color=s),i.font(l,a)}else i.selectedTextStyle(l,e)})}(t.selectAll("text"),e,r)}(r,a,t):p(r,a,t)},getInsideTextFont:v,getOutsideTextFont:y,getBarColor:x}},{"../../components/color":46,"../../components/drawing":71,"../../lib":164,"../../registry":248,"./attributes":258,"./helpers":262,d3:11}],271:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l){r("marker.color",o),a(t,"marker")&&i(t,e,l,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),a(t,"marker.line")&&i(t,e,l,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":46,"../../components/colorscale/defaults":56,"../../components/colorscale/has_colorscale":60}],272:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),a=t("../../components/color/attributes"),i=t("../../lib/extend").extendFlat,o=n.marker,l=o.line;e.exports={y:{valType:"data_array",editType:"calc+clearAxisTypes"},x:{valType:"data_array",editType:"calc+clearAxisTypes"},x0:{valType:"any",editType:"calc+clearAxisTypes"},y0:{valType:"any",editType:"calc+clearAxisTypes"},name:{valType:"string",editType:"calc+clearAxisTypes"},text:i({},n.text,{}),whiskerwidth:{valType:"number",min:0,max:1,dflt:.5,editType:"calc"},notched:{valType:"boolean",editType:"calc"},notchwidth:{valType:"number",min:0,max:.5,dflt:.25,editType:"calc"},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers",editType:"calc"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1,editType:"calc"},jitter:{valType:"number",min:0,max:1,editType:"calc"},pointpos:{valType:"number",min:-2,max:2,editType:"calc"},orientation:{valType:"enumerated",values:["v","h"],editType:"calc+clearAxisTypes"},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)",editType:"style"},symbol:i({},o.symbol,{arrayOk:!1,editType:"plot"}),opacity:i({},o.opacity,{arrayOk:!1,dflt:1,editType:"style"}),size:i({},o.size,{arrayOk:!1,editType:"calc"}),color:i({},o.color,{arrayOk:!1,editType:"style"}),line:{color:i({},l.color,{arrayOk:!1,dflt:a.defaultLine,editType:"style"}),width:i({},l.width,{arrayOk:!1,dflt:0,editType:"style"}),outliercolor:{valType:"color",editType:"style"},outlierwidth:{valType:"number",min:0,dflt:1,editType:"style"},editType:"style"},editType:"plot"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,selected:{marker:n.selected.marker,editType:"style"},unselected:{marker:n.unselected.marker,editType:"style"},hoveron:{valType:"flaglist",flags:["boxes","points"],dflt:"boxes+points",editType:"style"}}},{"../../components/color/attributes":45,"../../lib/extend":158,"../scatter/attributes":316}],273:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),a=t("../../lib"),i=["v","h"];function o(t,e,r,i,o){var l,s,c,u=e.calcdata,f=e._fullLayout,d=[],p="violin"===t?"_numViolins":"_numBoxes";for(l=0;lt.uf}),s=Math.max((t.max-t.min)/10,t.q3-t.q1),c=1e-9*s,p=s*l,h=[],g=0;if(r.jitter){if(0===s)for(g=1,h=new Array(i.length),e=0;et.lo&&(_.so=!0)}return i});h.enter().append("path").classed("point",!0),h.exit().remove(),h.call(i.translatePoints,s,c)}function u(t,e,r,i){var o,l,s=e.pos,c=e.val,u=i.bPos,f=i.bPosPxOffset||0,d=r.boxmean||(r.meanline||{}).visible;Array.isArray(i.bdPos)?(o=i.bdPos[0],l=i.bdPos[1]):(o=i.bdPos,l=i.bdPos);var p=t.selectAll("path.mean").data("box"===r.type&&r.boxmean||"violin"===r.type&&r.box.visible&&r.meanline.visible?a.identity:[]);p.enter().append("path").attr("class","mean").style({fill:"none","vector-effect":"non-scaling-stroke"}),p.exit().remove(),p.each(function(t){var e=s.c2p(t.pos+u,!0)+f,a=s.c2p(t.pos+u-o,!0)+f,i=s.c2p(t.pos+u+l,!0)+f,p=c.c2p(t.mean,!0),h=c.c2p(t.mean-t.sd,!0),g=c.c2p(t.mean+t.sd,!0);"h"===r.orientation?n.select(this).attr("d","M"+p+","+a+"V"+i+("sd"===d?"m0,0L"+h+","+e+"L"+p+","+a+"L"+g+","+e+"Z":"")):n.select(this).attr("d","M"+a+","+p+"H"+i+("sd"===d?"m0,0L"+e+","+h+"L"+a+","+p+"L"+e+","+g+"Z":""))})}e.exports={plot:function(t,e,r,i){var o=t._fullLayout,l=e.xaxis,f=e.yaxis,d=o._numBoxes,p=1-o.boxgap,h="group"===o.boxmode&&d>1;a.makeTraceGroups(i,r,"trace boxes").each(function(t){var r=n.select(this),a=t[0],i=a.t,g=a.trace;e.isRangePlot||(a.node3=r);var v,y,m=i.dPos*p*(1-o.boxgroupgap)/(h?d:1),x=h?2*i.dPos*((i.num+.5)/d-.5)*p:0,b=m*g.whiskerwidth;!0!==g.visible||i.empty?r.remove():("h"===g.orientation?(v=f,y=l):(v=l,y=f),i.bPos=x,i.bdPos=m,i.wdPos=b,i.wHover=i.dPos*(h?p/d:1),s(r,{pos:v,val:y},g,i),c(r,{x:l,y:f},g,i),u(r,{pos:v,val:y},g,i))})},plotBoxAndWhiskers:s,plotPoints:c,plotBoxMean:u}},{"../../components/drawing":71,"../../lib":164,d3:11}],277:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../components/color"),i=t("../../components/drawing");e.exports={style:function(t,e){var r=e?e[0].node3:n.select(t).selectAll("g.trace.boxes");r.style("opacity",function(t){return t[0].trace.opacity}),r.each(function(e){var r=n.select(this),o=e[0].trace,l=o.line.width;function s(t,e,r,n){t.style("stroke-width",e+"px").call(a.stroke,r).call(a.fill,n)}var c=r.selectAll("path.box");if("candlestick"===o.type)c.each(function(t){var e=n.select(this),r=o[t.dir];s(e,r.line.width,r.line.color,r.fillcolor),e.style("opacity",o.selectedpoints&&!t.selected?.3:1)});else{s(c,l,o.line.color,o.fillcolor),r.selectAll("path.mean").style({"stroke-width":l,"stroke-dasharray":2*l+"px,"+l+"px"}).call(a.stroke,o.line.color);var u=r.selectAll("path.point");i.pointStyle(u,o,t)}})},styleOnSelect:function(t,e){var r=e[0].node3,n=e[0].trace,a=r.selectAll("path.point");n.selectedpoints?i.selectedPointStyle(a,n):i.pointStyle(a,n,t)}}},{"../../components/color":46,"../../components/drawing":71,d3:11}],278:[function(t,e,r){"use strict";var n=t("../../lib").extendFlat,a=t("../ohlc/attributes"),i=t("../box/attributes");function o(t){return{line:{color:n({},i.line.color,{dflt:t}),width:i.line.width,editType:"style"},fillcolor:i.fillcolor,editType:"style"}}e.exports={x:a.x,open:a.open,high:a.high,low:a.low,close:a.close,line:{width:n({},i.line.width,{}),editType:"style"},increasing:o(a.increasing.line.color.dflt),decreasing:o(a.decreasing.line.color.dflt),text:a.text,whiskerwidth:n({},i.whiskerwidth,{dflt:0}),hoverlabel:a.hoverlabel}},{"../../lib":164,"../box/attributes":272,"../ohlc/attributes":294}],279:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("../ohlc/calc").calcCommon;function o(t,e,r,n){return{min:r,q1:Math.min(t,n),med:n,q3:Math.max(t,n),max:e}}e.exports=function(t,e){var r=t._fullLayout,l=a.getFromId(t,e.xaxis),s=a.getFromId(t,e.yaxis),c=l.makeCalcdata(e,"x"),u=i(t,e,c,s,o);return u.length?(n.extendFlat(u[0].t,{num:r._numBoxes,dPos:n.distinctVals(c).minDiff/2,posLetter:"x",valLetter:"y"}),r._numBoxes++,u):[{t:{empty:!0}}]}},{"../../lib":164,"../../plots/cartesian/axes":208,"../ohlc/calc":295}],280:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../components/color"),i=t("../ohlc/ohlc_defaults"),o=t("./attributes");function l(t,e,r,n){var i=r(n+".line.color");r(n+".line.width",e.line.width),r(n+".fillcolor",a.addOpacity(i,.5))}e.exports=function(t,e,r,a){function s(r,a){return n.coerce(t,e,o,r,a)}i(t,e,s,a)?(s("line.width"),l(t,e,s,"increasing"),l(t,e,s,"decreasing"),s("text"),s("whiskerwidth"),a._requestRangeslider[e.xaxis]=!0):e.visible=!1}},{"../../components/color":46,"../../lib":164,"../ohlc/ohlc_defaults":299,"./attributes":278}],281:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"candlestick",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","showLegend","candlestick","boxLayout"],meta:{},attributes:t("./attributes"),layoutAttributes:t("../box/layout_attributes"),supplyLayoutDefaults:t("../box/layout_defaults").supplyLayoutDefaults,crossTraceCalc:t("../box/cross_trace_calc").crossTraceCalc,supplyDefaults:t("./defaults"),calc:t("./calc"),plot:t("../box/plot").plot,layerName:"boxlayer",style:t("../box/style").style,hoverPoints:t("../ohlc/hover").hoverPoints,selectPoints:t("../ohlc/select")}},{"../../plots/cartesian":220,"../box/cross_trace_calc":273,"../box/layout_attributes":274,"../box/layout_defaults":275,"../box/plot":276,"../box/style":277,"../ohlc/hover":297,"../ohlc/select":301,"./attributes":278,"./calc":279,"./defaults":280}],282:[function(t,e,r){"use strict";var n=t("../bar/attributes"),a=t("./bin_attributes");e.exports={x:{valType:"data_array",editType:"calc+clearAxisTypes"},y:{valType:"data_array",editType:"calc+clearAxisTypes"},text:n.text,orientation:n.orientation,histfunc:{valType:"enumerated",values:["count","sum","avg","min","max"],dflt:"count",editType:"calc"},histnorm:{valType:"enumerated",values:["","percent","probability","density","probability density"],dflt:"",editType:"calc"},cumulative:{enabled:{valType:"boolean",dflt:!1,editType:"calc"},direction:{valType:"enumerated",values:["increasing","decreasing"],dflt:"increasing",editType:"calc"},currentbin:{valType:"enumerated",values:["include","exclude","half"],dflt:"include",editType:"calc"},editType:"calc"},nbinsx:{valType:"integer",min:0,dflt:0,editType:"calc"},xbins:a("x",!0),nbinsy:{valType:"integer",min:0,dflt:0,editType:"calc"},ybins:a("y",!0),autobinx:{valType:"boolean",dflt:null,editType:"calc"},autobiny:{valType:"boolean",dflt:null,editType:"calc",impliedEdits:{"ybins.start":void 0,"ybins.end":void 0,"ybins.size":void 0}},marker:n.marker,selected:n.selected,unselected:n.unselected,_deprecated:{bardir:n._deprecated.bardir}}},{"../bar/attributes":258,"./bin_attributes":284}],283:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=t.length,n=0,a=0;ai){var o=i-r[t];return r[t]=i,o}}return 0},max:function(t,e,r,a){var i=a[e];if(n(i)){if(i=Number(i),!n(r[t]))return r[t]=i,i;if(r[t]c?t>o?t>1.1*a?a:t>1.1*i?i:o:t>l?l:t>s?s:c:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function p(t,e,r,n,i,l){if(n&&t>o){var s=h(e,i,l),c=h(r,i,l),u=t===a?0:1;return s[u]!==c[u]}return Math.floor(r/t)-Math.floor(e/t)>.1}function h(t,e,r){var n=e.c2d(t,a,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}e.exports=function(t,e,r,n,i){var l,s,c=-1.1*e,d=-.1*e,p=t-d,h=r[0],g=r[1],v=Math.min(f(h+d,h+p,n,i),f(g+d,g+p,n,i)),y=Math.min(f(h+c,h+d,n,i),f(g+c,g+d,n,i));if(v>y&&yo){var m=l===a?1:6,x=l===a?"M12":"M1";return function(e,r){var o=n.c2d(e,a,i),l=o.indexOf("-",m);l>0&&(o=o.substr(0,l));var c=n.d2c(o,0,i);if(cr.r2l(P)&&(z=i.tickIncrement(z,_.size,!0,d)),L.start=r.l2r(z),O||a.nestedProperty(e,v+".start").set(L.start)}var E=_.end,N=r.r2l(A.end),R=void 0!==N;if((_.endFound||R)&&N!==r.r2l(E)){var I=R?N:a.aggNums(Math.max,null,p);L.end=r.l2r(I),R||a.nestedProperty(e,v+".start").set(L.end)}var F="autobin"+o;return!1===e._input[F]&&(e._input[v]=a.extendFlat({},e[v]||{}),delete e._input[F],delete e[F]),[L,p]}e.exports=function(t,e){if(!0===e.visible){var r,d,p,h,g=[],v=[],y=i.getFromId(t,"h"===e.orientation?e.yaxis||"y":e.xaxis||"x"),m="h"===e.orientation?"y":"x",x={x:"y",y:"x"}[m],b=e[m+"calendar"],_=e.cumulative,w=f(t,e,y,m),k=w[0],T=w[1],M="string"==typeof k.size,A=[],L=M?A:k,S=[],C=[],O=[],P=0,D=e.histnorm,z=e.histfunc,E=-1!==D.indexOf("density");_.enabled&&E&&(D=D.replace(/ ?density$/,""),E=!1);var N,R="max"===z||"min"===z?null:0,I=l.count,F=s[D],B=!1,j=function(t){return y.r2c(t,0,b)};for(a.isArrayOrTypedArray(e[x])&&"count"!==z&&(N=e[x],B="avg"===z,I=l[z]),r=j(k.start),p=j(k.end)+(r-i.tickIncrement(r,k.size,!1,b))/1e6;r=0&&h=0;n--)l(n);else if("increasing"===e){for(n=1;n=0;n--)t[n]+=t[n+1];"exclude"===r&&(t.push(0),t.shift())}}(v,_.direction,_.currentbin);var X=Math.min(g.length,v.length),W=[],J=0,Q=X-1;for(r=0;r=J;r--)if(v[r]){Q=r;break}for(r=J;r<=Q;r++)if(n(g[r])&&n(v[r])){var $={p:g[r],s:v[r],b:0};_.enabled||($.pts=O[r],V?$.ph0=$.ph1=O[r].length?T[O[r][0]]:g[r]:($.ph0=H(A[r]),$.ph1=H(A[r+1],!0))),W.push($)}return 1===W.length&&(W[0].width1=i.tickIncrement(W[0].p,k.size,!1,b)-W[0].p),o(W,e),a.isArrayOrTypedArray(e.selectedpoints)&&a.tagSelected(W,e,Z),W}}},{"../../lib":164,"../../plots/cartesian/axes":208,"../bar/arrays_to_calcdata":257,"./average":283,"./bin_functions":285,"./bin_label_vals":286,"./norm_functions":293,"fast-isnumeric":13}],288:[function(t,e,r){"use strict";var n=t("../../lib"),a=n.nestedProperty,i=t("./attributes"),o={x:[{aStr:"xbins.start",name:"start"},{aStr:"xbins.end",name:"end"},{aStr:"xbins.size",name:"size"},{aStr:"nbinsx",name:"nbins"}],y:[{aStr:"ybins.start",name:"start"},{aStr:"ybins.end",name:"end"},{aStr:"ybins.size",name:"size"},{aStr:"nbinsy",name:"nbins"}]};e.exports=function(t,e){var r,l,s,c,u,f,d,p=e._histogramBinOpts={},h="overlay"===e.barmode;function g(t){return n.coerce(s._input,s,i,t)}for(r=0;rh):p=_>m,h=_;var w=l(m,x,b,_);w.pos=y,w.yc=(m+_)/2,w.i=v,w.dir=p?"increasing":"decreasing",d&&(w.tx=e.text[v]),g.push(w)}}return e._extremes[n._id]=i.findExtremes(n,u.concat(c),{padded:!0}),g.length&&(g[0].t={labels:{open:a(t,"open:")+" ",high:a(t,"high:")+" ",low:a(t,"low:")+" ",close:a(t,"close:")+" "}}),g}e.exports={calc:function(t,e){var r=i.getFromId(t,e.xaxis),a=i.getFromId(t,e.yaxis),o=function(t,e,r){var a=r._minDiff;if(!a){var i,o=t._fullData,l=[];for(a=1/0,i=0;i"+u.labels[x]+n.hoverLabelText(l,b):((m=a.extendFlat({},d)).y0=m.y1=_,m.yLabelVal=b,m.yLabel=u.labels[x]+n.hoverLabelText(l,b),m.name="",f.push(m),v[b]=m)}return f}function f(t,e,r,a){var i=t.cd,o=t.ya,u=i[0].trace,f=i[0].t,d=c(t,e,r,a);if(!d)return[];var p=i[d.index],h=d.index=p.i,g=p.dir;function v(t){return f.labels[t]+n.hoverLabelText(o,u[t][h])}var y=p.hi||u.hoverinfo,m=y.split("+"),x="all"===y,b=x||-1!==m.indexOf("y"),_=x||-1!==m.indexOf("text"),w=b?[v("open"),v("high"),v("low"),v("close")+" "+s[g]]:[];return _&&l(p,u,w),d.extraText=w.join("
"),d.y0=d.y1=o.c2p(p.yc,!0),[d]}e.exports={hoverPoints:function(t,e,r,n){return t.cd[0].trace.hoverlabel.split?u(t,e,r,n):f(t,e,r,n)},hoverSplit:u,hoverOnPoints:f}},{"../../components/color":46,"../../components/fx":88,"../../lib":164,"../../plots/cartesian/axes":208,"../scatter/fill_hover_text":324}],298:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"ohlc",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","showLegend"],meta:{},attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("./calc").calc,plot:t("./plot"),style:t("./style"),hoverPoints:t("./hover").hoverPoints,selectPoints:t("./select")}},{"../../plots/cartesian":220,"./attributes":294,"./calc":295,"./defaults":296,"./hover":297,"./plot":300,"./select":301,"./style":302}],299:[function(t,e,r){"use strict";var n=t("../../registry");e.exports=function(t,e,r,a){var i=r("x"),o=r("open"),l=r("high"),s=r("low"),c=r("close");if(r("hoverlabel.split"),n.getComponentMethod("calendars","handleTraceDefaults")(t,e,["x"],a),o&&l&&s&&c){var u=Math.min(o.length,l.length,s.length,c.length);return i&&(u=Math.min(u,i.length)),e._length=u,u}}},{"../../registry":248}],300:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib");e.exports=function(t,e,r,i){var o=e.xaxis,l=e.yaxis;a.makeTraceGroups(i,r,"trace ohlc").each(function(t){var r=n.select(this),i=t[0],s=i.t,c=i.trace;if(e.isRangePlot||(i.node3=r),!0!==c.visible||s.empty)r.remove();else{var u=s.tickLen,f=r.selectAll("path").data(a.identity);f.enter().append("path"),f.exit().remove(),f.attr("d",function(t){var e=o.c2p(t.pos,!0),r=o.c2p(t.pos-u,!0),n=o.c2p(t.pos+u,!0);return"M"+r+","+l.c2p(t.o,!0)+"H"+e+"M"+e+","+l.c2p(t.h,!0)+"V"+l.c2p(t.l,!0)+"M"+n+","+l.c2p(t.c,!0)+"H"+e})}})}},{"../../lib":164,d3:11}],301:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,a=t.xaxis,i=t.yaxis,o=[],l=n[0].t.bPos||0;if(!1===e)for(r=0;r")}}return v},r.crossTraceCalc=function(t){var e=t._fullLayout,r=t.calcdata,n=e.piecolorway,a=e._piecolormap;e.extendpiecolors&&(n=function(t){var e,r=JSON.stringify(t),n=s[r];if(!n){for(n=t.slice(),e=0;e0?1:-1)/2,y:i/(1+r*r/(n*n)),outside:!0}}function p(t,e){var r=t.trace,n=e.h*(r.domain.y[1]-r.domain.y[0]);return Math.min(t.titleBox.height,n/2)}function h(t){var e,r=t.pull;if(Array.isArray(r))for(r=0,e=0;er&&(r=t.pull[e]);return r}e.exports=function(t,e){var r=t._fullLayout;!function(t,e){for(var r,n,a=0;aa.vTotal/2?1:0)}(e),g.attr("stroke-linejoin","round"),g.each(function(){var g=n.select(this).selectAll("g.slice").data(e);g.enter().append("g").classed("slice",!0),g.exit().remove();var m=[[[],[]],[[],[]]],x=!1;g.each(function(e){if(e.hidden)n.select(this).selectAll("path,g").remove();else{e.pointNumber=e.i,e.curveNumber=y.index,m[e.pxmid[1]<0?0:1][e.pxmid[0]<0?0:1].push(e);var p=v.cx,h=v.cy,g=n.select(this),b=g.selectAll("path.surface").data([e]),_=!1,w=!1;if(b.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),g.select("path.textline").remove(),g.on("mouseover",function(){var i=t._fullLayout,o=t._fullData[y.index];if(!t._dragging&&!1!==i.hovermode){var l=o.hoverinfo;if(Array.isArray(l)&&(l=a.castHoverinfo({hoverinfo:[c.castOption(l,e.pts)],_module:y._module},i,0)),"all"===l&&(l="label+text+value+percent+name"),"none"!==l&&"skip"!==l&&l){var s=f(e,v),d=p+e.pxmid[0]*(1-s),g=h+e.pxmid[1]*(1-s),m=r.separators,x=[];if(-1!==l.indexOf("label")&&x.push(e.label),-1!==l.indexOf("text")){var b=c.castOption(o.hovertext||o.text,e.pts);b&&x.push(b)}-1!==l.indexOf("value")&&x.push(c.formatPieValue(e.v,m)),-1!==l.indexOf("percent")&&x.push(c.formatPiePercent(e.v/v.vTotal,m));var k=y.hoverlabel,T=k.font;a.loneHover({x0:d-s*v.r,x1:d+s*v.r,y:g,text:x.join("
"),name:-1!==l.indexOf("name")?o.name:void 0,idealAlign:e.pxmid[0]<0?"left":"right",color:c.castOption(k.bgcolor,e.pts)||e.color,borderColor:c.castOption(k.bordercolor,e.pts),fontFamily:c.castOption(T.family,e.pts),fontSize:c.castOption(T.size,e.pts),fontColor:c.castOption(T.color,e.pts)},{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:t}),_=!0}t.emit("plotly_hover",{points:[u(e,o)],event:n.event}),w=!0}}).on("mouseout",function(r){var i=t._fullLayout,o=t._fullData[y.index];w&&(r.originalEvent=n.event,t.emit("plotly_unhover",{points:[u(e,o)],event:n.event}),w=!1),_&&(a.loneUnhover(i._hoverlayer.node()),_=!1)}).on("click",function(){var r=t._fullLayout,i=t._fullData[y.index];t._dragging||!1===r.hovermode||(t._hoverdata=[u(e,i)],a.click(t,n.event))}),y.pull){var k=+c.castOption(y.pull,e.pts)||0;k>0&&(p+=k*e.pxmid[0],h+=k*e.pxmid[1])}e.cxFinal=p,e.cyFinal=h;var T=y.hole;if(e.v===v.vTotal){var M="M"+(p+e.px0[0])+","+(h+e.px0[1])+O(e.px0,e.pxmid,!0,1)+O(e.pxmid,e.px0,!0,1)+"Z";T?b.attr("d","M"+(p+T*e.px0[0])+","+(h+T*e.px0[1])+O(e.px0,e.pxmid,!1,T)+O(e.pxmid,e.px0,!1,T)+"Z"+M):b.attr("d",M)}else{var A=O(e.px0,e.px1,!0,1);if(T){var L=1-T;b.attr("d","M"+(p+T*e.px1[0])+","+(h+T*e.px1[1])+O(e.px1,e.px0,!1,T)+"l"+L*e.px0[0]+","+L*e.px0[1]+A+"Z")}else b.attr("d","M"+p+","+h+"l"+e.px0[0]+","+e.px0[1]+A+"Z")}var S=c.castOption(y.textposition,e.pts),C=g.selectAll("g.slicetext").data(e.text&&"none"!==S?[0]:[]);C.enter().append("g").classed("slicetext",!0),C.exit().remove(),C.each(function(){var r=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});r.text(e.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(o.font,"outside"===S?function(t,e,r){var n=c.castOption(t.outsidetextfont.color,e.pts)||c.castOption(t.textfont.color,e.pts)||r.color,a=c.castOption(t.outsidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,i=c.castOption(t.outsidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n,family:a,size:i}}(y,e,t._fullLayout.font):function(t,e,r){var n=c.castOption(t.insidetextfont.color,e.pts);!n&&t._input.textfont&&(n=c.castOption(t._input.textfont.color,e.pts));var a=c.castOption(t.insidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,o=c.castOption(t.insidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n||i.contrast(e.color),family:a,size:o}}(y,e,t._fullLayout.font)).call(s.convertToTspans,t);var a,u=o.bBox(r.node());"outside"===S?a=d(u,e):(a=function(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,i=Math.PI*Math.min(e.v/r.vTotal,.5),o=1-r.trace.hole,l=f(e,r),s={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(s.scale>=1)return s;var c=a+1/(2*Math.tan(i)),u=r.r*Math.min(1/(Math.sqrt(c*c+.5)+c),o/(Math.sqrt(a*a+o/2)+a)),d={scale:2*u/t.height,rCenter:Math.cos(u/r.r)-u*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},p=1/a,h=p+1/(2*Math.tan(i)),g=r.r*Math.min(1/(Math.sqrt(h*h+.5)+h),o/(Math.sqrt(p*p+o/2)+p)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},y=v.scale>d.scale?v:d;return s.scale<1&&y.scale>s.scale?y:s}(u,e,v),"auto"===S&&a.scale<1&&(r.call(o.font,y.outsidetextfont),y.outsidetextfont.family===y.insidetextfont.family&&y.outsidetextfont.size===y.insidetextfont.size||(u=o.bBox(r.node())),a=d(u,e)));var g=p+e.pxmid[0]*a.rCenter+(a.x||0),m=h+e.pxmid[1]*a.rCenter+(a.y||0);a.outside&&(e.yLabelMin=m-u.height/2,e.yLabelMid=m,e.yLabelMax=m+u.height/2,e.labelExtraX=0,e.labelExtraY=0,x=!0),r.attr("transform","translate("+g+","+m+")"+(a.scale<1?"scale("+a.scale+")":"")+(a.rotate?"rotate("+a.rotate+")":"")+"translate("+-(u.left+u.right)/2+","+-(u.top+u.bottom)/2+")")})}function O(t,r,n,a){return"a"+a*v.r+","+a*v.r+" 0 "+e.largeArc+(n?" 1 ":" 0 ")+a*(r[0]-t[0])+","+a*(r[1]-t[1])}});var b=n.select(this).selectAll("g.titletext").data(y.title?[0]:[]);b.enter().append("g").classed("titletext",!0),b.exit().remove(),b.each(function(){var e,a=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});a.text(y.title).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(o.font,y.titlefont).call(s.convertToTspans,t),e="middle center"===y.titleposition?function(t){var e=Math.sqrt(t.titleBox.width*t.titleBox.width+t.titleBox.height*t.titleBox.height);return{x:t.cx,y:t.cy,scale:t.trace.hole*t.r*2/e,tx:0,ty:-t.titleBox.height/2+t.trace.titlefont.size}}(v):function(t,e){var r,n,a=1,i=1,o=t.trace,l={x:t.cx,y:t.cy},s={tx:0,ty:0};s.ty+=o.titlefont.size,n=h(o),-1!==o.titleposition.indexOf("top")?(l.y-=(1+n)*t.r,s.ty-=t.titleBox.height):-1!==o.titleposition.indexOf("bottom")&&(l.y+=(1+n)*t.r);-1!==o.titleposition.indexOf("left")?(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x-=(1+n)*t.r,s.tx+=t.titleBox.width/2):-1!==o.titleposition.indexOf("center")?r=e.w*(o.domain.x[1]-o.domain.x[0]):-1!==o.titleposition.indexOf("right")&&(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x+=(1+n)*t.r,s.tx-=t.titleBox.width/2);return a=r/t.titleBox.width,i=p(t,e)/t.titleBox.height,{x:l.x,y:l.y,scale:Math.min(a,i),tx:s.tx,ty:s.ty}}(v,r._size),a.attr("transform","translate("+e.x+","+e.y+")"+(e.scale<1?"scale("+e.scale+")":"")+"translate("+e.tx+","+e.ty+")")}),x&&function(t,e){var r,n,a,i,o,l,s,u,f,d,p,h,g;function v(t,e){return t.pxmid[1]-e.pxmid[1]}function y(t,e){return e.pxmid[1]-t.pxmid[1]}function m(t,r){r||(r={});var a,u,f,p,h,g,v=r.labelExtraY+(n?r.yLabelMax:r.yLabelMin),y=n?t.yLabelMin:t.yLabelMax,m=n?t.yLabelMax:t.yLabelMin,x=t.cyFinal+o(t.px0[1],t.px1[1]),b=v-y;if(b*s>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(u=0;u=(c.castOption(e.pull,f.pts)||0)||((t.pxmid[1]-f.pxmid[1])*s>0?(p=f.cyFinal+o(f.px0[1],f.px1[1]),(b=p-y-t.labelExtraY)*s>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-x)*s>0&&(a=3*l*Math.abs(u-d.indexOf(t)),h=f.cxFinal+i(f.px0[0],f.px1[0]),(g=h+a-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*l>0&&(t.labelExtraX+=g)))}for(n=0;n<2;n++)for(a=n?v:y,o=n?Math.max:Math.min,s=n?1:-1,r=0;r<2;r++){for(i=r?Math.max:Math.min,l=r?1:-1,(u=t[n][r]).sort(a),f=t[1-n][r],d=f.concat(u),h=[],p=0;pMath.abs(c)?o+="l"+c*t.pxmid[0]/t.pxmid[1]+","+c+"H"+(a+t.labelExtraX+l):o+="l"+t.labelExtraX+","+s+"v"+(c-s)+"h"+l}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+l;e.append("path").classed("textline",!0).call(i.stroke,y.outsidetextfont.color).attr({"stroke-width":Math.min(2,y.outsidetextfont.size/8),d:o,fill:"none"})}})})});setTimeout(function(){g.selectAll("tspan").each(function(){var t=n.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":46,"../../components/drawing":71,"../../components/fx":88,"../../lib":164,"../../lib/svg_text_utils":185,"./event_data":307,"./helpers":308,d3:11}],313:[function(t,e,r){"use strict";var n=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each(function(t){n.select(this).call(a,t,e)})})}},{"./style_one":314,d3:11}],314:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("./helpers").castOption;e.exports=function(t,e,r){var i=r.marker.line,o=a(i.color,e.pts)||n.defaultLine,l=a(i.width,e.pts)||0;t.style({"stroke-width":l}).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":46,"./helpers":308}],315:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rl&&M[v].gap;)v--;for(m=M[v].s,h=M.length-1;h>v;h--)M[h].s=m;for(;lA[u]&&u=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===r.xaxis&&i.yaxis===r.yaxis){i.opacity=void 0;break}}}}}},{}],323:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),l=t("./subtypes"),s=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),d=t("./line_shape_defaults"),p=t("./text_defaults"),h=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,a){return n.coerce(t,e,i,r,a)}var y=s(t,e,g,v);if(y||(e.visible=!1),e.visible){var m=c(t,e,g,v),x=!m&&yG!=(I=D[O][1])>=G&&(E=D[O-1][0],N=D[O][0],I-R&&(z=E+(N-E)*(G-R)/(I-R),H=Math.min(H,z),q=Math.max(q,z)));H=Math.max(H,0),q=Math.min(q,d._length);var Z=l.defaultLine;return l.opacity(f.fillcolor)?Z=f.fillcolor:l.opacity((f.line||{}).color)&&(Z=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:H,x1:q,y0:G,y1:G,color:Z}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":46,"../../components/fx":88,"../../lib":164,"../../registry":248,"./fill_hover_text":324,"./get_trace_color":326}],328:[function(t,e,r){"use strict";var n={},a=t("./subtypes");n.hasLines=a.hasLines,n.hasMarkers=a.hasMarkers,n.hasText=a.hasText,n.isBubble=a.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":220,"./arrays_to_calcdata":315,"./attributes":316,"./calc":317,"./cross_trace_calc":321,"./cross_trace_defaults":322,"./defaults":323,"./hover":327,"./marker_colorbar":334,"./plot":336,"./select":337,"./style":339,"./subtypes":340}],329:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l,s){var c=(t.marker||{}).color;(l("line.color",r),a(t,"line"))?i(t,e,o,l,{prefix:"line.",cLetter:"c",noScale:!0}):l("line.color",!n(c)&&c||r);l("line.width"),(s||{}).noDash||l("line.dash")}},{"../../components/colorscale/defaults":56,"../../components/colorscale/has_colorscale":60,"../../lib":164}],330:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),a=n.BADNUM,i=n.LOG_CLIP,o=i+.5,l=i-.5,s=t("../../lib"),c=s.segmentsIntersect,u=s.constrain,f=t("./constants");e.exports=function(t,e){var r,n,i,d,p,h,g,v,y,m,x,b,_,w,k,T,M,A,L=e.xaxis,S=e.yaxis,C="log"===L.type,O="log"===S.type,P=L._length,D=S._length,z=e.connectGaps,E=e.baseTolerance,N=e.shape,R="linear"===N,I=[],F=f.minTolerance,B=new Array(t.length),j=0;function H(e){var r=t[e];if(!r)return!1;var n=L.c2p(r.x),i=S.c2p(r.y);if(n===a){if(C&&(n=L.c2p(r.x,!0)),n===a)return!1;O&&i===a&&(n*=Math.abs(L._m*D*(L._m>0?o:l)/(S._m*P*(S._m>0?o:l)))),n*=1e3}if(i===a){if(O&&(i=S.c2p(r.y,!0)),i===a)return!1;i*=1e3}return[n,i]}function q(t,e,r,n){var a=r-t,i=n-e,o=.5-t,l=.5-e,s=a*a+i*i,c=a*o+i*l;if(c>0&&ctt||t[1]rt)return[u(t[0],K,tt),u(t[1],et,rt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,a){var i=at(n),o=at(a),l=[];if(i&&o&&it(i,o))return l;i&&l.push(i),o&&l.push(o);var c=2*s.constrain((n[t]+a[t])/2,e,r)-((i||n)[t]+(o||a)[t]);c&&((i&&o?c>0==i[t]>o[t]?i:o:i||o)[t]+=c);return l}}function lt(t){var e=t[0],r=t[1],n=e===B[j-1][0],a=r===B[j-1][1];if(!n||!a)if(j>1){var i=e===B[j-2][0],o=r===B[j-2][1];n&&(e===K||e===tt)&&i?o?j--:B[j-1]=t:a&&(r===et||r===rt)&&o?i?j--:B[j-1]=t:B[j++]=t}else B[j++]=t}function st(t){B[j-1][0]!==t[0]&&B[j-1][1]!==t[1]&<([Y,X]),lt(t),W=null,Y=X=0}function ct(t){if(M=t[0]/P,A=t[1]/D,G=t[0]tt?tt:0,Z=t[1]rt?rt:0,G||Z){if(j)if(W){var e=Q(W,t);e.length>1&&(st(e[0]),B[j++]=e[1])}else J=Q(B[j-1],t)[0],B[j++]=J;else B[j++]=[G||t[0],Z||t[1]];var r=B[j-1];G&&Z&&(r[0]!==G||r[1]!==Z)?(W&&(Y!==G&&X!==Z?lt(Y&&X?(n=W,i=(a=t)[0]-n[0],o=(a[1]-n[1])/i,(n[1]*a[0]-a[1]*n[0])/i>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[Y||G,X||Z]):Y&&X&<([Y,X])),lt([G,Z])):Y-G&&X-Z&<([G||Y,Z||X]),W=t,Y=G,X=Z}else W&&st(Q(W,t)[0]),B[j++]=t;var n,a,i,o}for("linear"===N||"spline"===N?Q=function(t,e){for(var r=[],n=0,a=0;a<4;a++){var i=nt[a],o=c(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&U(o,t)V(h,ut))break;i=h,(_=y[0]*v[0]+y[1]*v[1])>x?(x=_,d=h,g=!1):_=t.length||!h)break;ct(h),n=h}}else ct(d)}W&<([Y||W[0],X||W[1]]),I.push(B.slice(0,j))}return I}},{"../../constants/numerical":146,"../../lib":164,"./constants":320}],331:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],332:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var a,i,o,l,s,c={},u=!1,f=-1,d=0,p=-1;for(i=0;i=0?s=p:(s=p=d,d++),s0?Math.max(e,a):0}}},{"fast-isnumeric":13}],334:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],335:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,l,s,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(r=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",r),a(t,"marker")&&i(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c.noSelect||(s("selected.marker.color"),s("unselected.marker.color"),s("selected.marker.size"),s("unselected.marker.size")),c.noLine||(s("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?n.background:n.defaultLine),a(t,"marker.line")&&i(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0)),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode")),c.gradient)&&("none"!==s("marker.gradient.type")&&s("marker.gradient.color"))}},{"../../components/color":46,"../../components/colorscale/defaults":56,"../../components/colorscale/has_colorscale":60,"./subtypes":340}],336:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,l=i.identity,s=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),d=t("../../lib/polygon").tester;function p(t,e,r,f,p,h,g){var v;!function(t,e,r,a,o){var l=r.xaxis,s=r.yaxis,u=n.extent(i.simpleMap(l.range,l.r2c)),f=n.extent(i.simpleMap(s.range,s.r2c)),d=a[0].trace;if(!c.hasMarkers(d))return;var p=d.marker.maxdisplayed;if(0===p)return;var h=a.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(h.length/p),v=0;o.forEach(function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function m(t){return y?t.transition():t}var x=r.xaxis,b=r.yaxis,_=f[0].trace,w=_.line,k=n.select(h),T=o(k,"g","errorbars"),M=o(k,"g","lines"),A=o(k,"g","points"),L=o(k,"g","text");if(a.getComponentMethod("errorbars","plot")(T,r,g),!0===_.visible){var S,C;m(k).style("opacity",_.opacity);var O=_.fill.charAt(_.fill.length-1);"x"!==O&&"y"!==O&&(O=""),r.isRangePlot||(f[0].node3=k);var P="",D=[],z=_._prevtrace;z&&(P=z._prevRevpath||"",C=z._nextFill,D=z._polygons);var E,N,R,I,F,B,j,H,q,V="",U="",G=[],Z=i.noop;if(S=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(C&&C.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(R=s.steps(w.shape),I=s.steps(w.shape.split("").reverse().join(""))):R=I="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?s.smoothclosed(t.slice(1),w.smoothing):s.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return I(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)m(r.style("opacity",0).attr("d",E).call(s.lineGroupStyle)).style("opacity",1);else{var a=m(r);a.attr("d",E),s.singleLineStyle(f,a)}}}}}var Y=M.selectAll(".js-line").data(G);m(Y.exit()).style("opacity",0).remove(),Y.each(Z(!1)),Y.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(s.lineGroupStyle).each(Z(!0)),s.setClipUrl(Y,r.layerClipId),G.length?(S?(S.datum(f),B&&H&&(O?("y"===O?B[1]=H[1]=b.c2p(0,!0):"x"===O&&(B[0]=H[0]=x.c2p(0,!0)),m(S).attr("d","M"+H+"L"+B+"L"+V.substr(1)).call(s.singleFillStyle)):m(S).attr("d",V+"Z").call(s.singleFillStyle))):C&&("tonext"===_.fill.substr(0,6)&&V&&P?("tonext"===_.fill?m(C).attr("d",V+"Z"+P+"Z").call(s.singleFillStyle):m(C).attr("d",V+"L"+P.substr(1)+"Z").call(s.singleFillStyle),_._polygons=_._polygons.concat(D)):(W(C),_._polygons=null)),_._prevRevpath=U,_._prevPolygons=q):(S?W(S):C&&W(C),_._polygons=_._prevRevpath=_._prevPolygons=null),A.datum(f),L.datum(f),function(e,a,i){var o,u=i[0].trace,f=c.hasMarkers(u),d=c.hasText(u),p=tt(u),h=et,g=et;if(f||d){var v=l,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?Q:J:_&&!w&&(v=$),f&&(h=v),d&&(g=v)}var k,T=(o=e.selectAll("path.point").data(h,p)).enter().append("path").classed("point",!0);y&&T.call(s.pointStyle,u,t).call(s.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=s.makePointStyleFns(u)),o.each(function(e){var a=n.select(this),i=m(a);s.translatePoint(e,i,x,b)?(s.singlePointStyle(e,i,u,k,t),r.layerClipId&&s.hideOutsideRangePoint(e,i,x,b,u.xcalendar,u.ycalendar),u.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),a=m(e.select("text"));s.translatePoint(t,a,x,b)?r.layerClipId&&s.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(s.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),r=b.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){m(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(A,L,f);var X=!1===_.cliponaxis?null:r.layerClipId;s.setClipUrl(A,X),s.setClipUrl(L,X)}function W(t){m(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function Q(t){return t.filter(function(t){return t.vis})}function $(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,a,i,c){var u,d,h=!i,g=!!i&&i.duration>0,v=f(t,e,r);((u=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,r){e.each(function(t){var e=o(n.select(this),"g","fills");s.setClipUrl(e,r.layerClipId);var a=t[0].trace,i=[];a._ownfill&&i.push("_ownFill"),a._nexttrace&&i.push("_nextFill");var c=e.selectAll("g").data(i,l);c.enter().append("g"),c.exit().each(function(t){a[t]=null}).remove(),c.order().each(function(t){a[t]=o(n.select(this),"path","js-fill")})})}(0,u,e),g)?(c&&(d=c()),n.transition().duration(i.duration).ease(i.easing).each("end",function(){d&&d()}).each("interrupt",function(){d&&d()}).each(function(){a.selectAll("g.trace").each(function(r,n){p(t,n,e,r,v,this,i)})})):u.each(function(r,n){p(t,n,e,r,v,this,i)});h&&u.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":71,"../../lib":164,"../../lib/polygon":176,"../../registry":248,"./line_points":330,"./link_traces":332,"./subtypes":340,d3:11}],337:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,a,i,o,l=t.cd,s=t.xaxis,c=t.yaxis,u=[],f=l[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;margin-left:0px;margin-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var i in a){var o=i.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");n.addStyleRule(o,a[i])}},{"../src/lib":162}],2:[function(t,e,r){"use strict";e.exports={undo:{width:857.1,height:1e3,path:"m857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z",transform:"matrix(1 0 0 -1 0 850)"},home:{width:928.6,height:1e3,path:"m786 296v-267q0-15-11-26t-25-10h-214v214h-143v-214h-214q-15 0-25 10t-11 26v267q0 1 0 2t0 2l321 264 321-264q1-1 1-4z m124 39l-34-41q-5-5-12-6h-2q-7 0-12 3l-386 322-386-322q-7-4-13-4-7 2-12 7l-35 41q-4 5-3 13t6 12l401 334q18 15 42 15t43-15l136-114v109q0 8 5 13t13 5h107q8 0 13-5t5-13v-227l122-102q5-5 6-12t-4-13z",transform:"matrix(1 0 0 -1 0 850)"},"camera-retro":{width:1e3,height:1e3,path:"m518 386q0 8-5 13t-13 5q-37 0-63-27t-26-63q0-8 5-13t13-5 12 5 5 13q0 23 16 38t38 16q8 0 13 5t5 13z m125-73q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101z m-572-320h858v71h-858v-71z m643 320q0 89-62 152t-152 62-151-62-63-152 63-151 151-63 152 63 62 151z m-571 358h214v72h-214v-72z m-72-107h858v143h-462l-36-71h-360v-72z m929 143v-714q0-30-21-51t-50-21h-858q-29 0-50 21t-21 51v714q0 30 21 51t50 21h858q29 0 50-21t21-51z",transform:"matrix(1 0 0 -1 0 850)"},zoombox:{width:1e3,height:1e3,path:"m1000-25l-250 251c40 63 63 138 63 218 0 224-182 406-407 406-224 0-406-182-406-406s183-406 407-406c80 0 155 22 218 62l250-250 125 125z m-812 250l0 438 437 0 0-438-437 0z m62 375l313 0 0-312-313 0 0 312z",transform:"matrix(1 0 0 -1 0 850)"},pan:{width:1e3,height:1e3,path:"m1000 350l-187 188 0-125-250 0 0 250 125 0-188 187-187-187 125 0 0-250-250 0 0 125-188-188 186-187 0 125 252 0 0-250-125 0 187-188 188 188-125 0 0 250 250 0 0-126 187 188z",transform:"matrix(1 0 0 -1 0 850)"},zoom_plus:{width:875,height:1e3,path:"m1 787l0-875 875 0 0 875-875 0z m687-500l-187 0 0-187-125 0 0 187-188 0 0 125 188 0 0 187 125 0 0-187 187 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},zoom_minus:{width:875,height:1e3,path:"m0 788l0-876 875 0 0 876-875 0z m688-500l-500 0 0 125 500 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},autoscale:{width:1e3,height:1e3,path:"m250 850l-187 0-63 0 0-62 0-188 63 0 0 188 187 0 0 62z m688 0l-188 0 0-62 188 0 0-188 62 0 0 188 0 62-62 0z m-875-938l0 188-63 0 0-188 0-62 63 0 187 0 0 62-187 0z m875 188l0-188-188 0 0-62 188 0 62 0 0 62 0 188-62 0z m-125 188l-1 0-93-94-156 156 156 156 92-93 2 0 0 250-250 0 0-2 93-92-156-156-156 156 94 92 0 2-250 0 0-250 0 0 93 93 157-156-157-156-93 94 0 0 0-250 250 0 0 0-94 93 156 157 156-157-93-93 0 0 250 0 0 250z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_basic:{width:1500,height:1e3,path:"m375 725l0 0-375-375 375-374 0-1 1125 0 0 750-1125 0z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_compare:{width:1125,height:1e3,path:"m187 786l0 2-187-188 188-187 0 0 937 0 0 373-938 0z m0-499l0 1-187-188 188-188 0 0 937 0 0 376-938-1z",transform:"matrix(1 0 0 -1 0 850)"},plotlylogo:{width:1542,height:1e3,path:"m0-10h182v-140h-182v140z m228 146h183v-286h-183v286z m225 714h182v-1000h-182v1000z m225-285h182v-715h-182v715z m225 142h183v-857h-183v857z m231-428h182v-429h-182v429z m225-291h183v-138h-183v138z",transform:"matrix(1 0 0 -1 0 850)"},"z-axis":{width:1e3,height:1e3,path:"m833 5l-17 108v41l-130-65 130-66c0 0 0 38 0 39 0-1 36-14 39-25 4-15-6-22-16-30-15-12-39-16-56-20-90-22-187-23-279-23-261 0-341 34-353 59 3 60 228 110 228 110-140-8-351-35-351-116 0-120 293-142 474-142 155 0 477 22 477 142 0 50-74 79-163 96z m-374 94c-58-5-99-21-99-40 0-24 65-43 144-43 79 0 143 19 143 43 0 19-42 34-98 40v216h87l-132 135-133-135h88v-216z m167 515h-136v1c16 16 31 34 46 52l84 109v54h-230v-71h124v-1c-16-17-28-32-44-51l-89-114v-51h245v72z",transform:"matrix(1 0 0 -1 0 850)"},"3d_rotate":{width:1e3,height:1e3,path:"m922 660c-5 4-9 7-14 11-359 263-580-31-580-31l-102 28 58-400c0 1 1 1 2 2 118 108 351 249 351 249s-62 27-100 42c88 83 222 183 347 122 16-8 30-17 44-27-2 1-4 2-6 4z m36-329c0 0 64 229-88 296-62 27-124 14-175-11 157-78 225-208 249-266 8-19 11-31 11-31 2 5 6 15 11 32-5-13-8-20-8-20z m-775-239c70-31 117-50 198-32-121 80-199 346-199 346l-96-15-58-12c0 0 55-226 155-287z m603 133l-317-139c0 0 4-4 19-14 7-5 24-15 24-15s-177-147-389 4c235-287 536-112 536-112l31-22 100 299-4-1z m-298-153c6-4 14-9 24-15 0 0-17 10-24 15z",transform:"matrix(1 0 0 -1 0 850)"},camera:{width:1e3,height:1e3,path:"m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z m400 150h-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28l-31-94c-6-15-23-28-40-28h-120c-55 0-100-45-100-100v-450c0-55 45-100 100-100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250-250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35-35z",transform:"matrix(1 0 0 -1 0 850)"},movie:{width:1e3,height:1e3,path:"m938 413l-188-125c0 37-17 71-44 94 64 38 107 107 107 187 0 121-98 219-219 219-121 0-219-98-219-219 0-61 25-117 66-156h-115c30 33 49 76 49 125 0 103-84 187-187 187s-188-84-188-187c0-57 26-107 65-141-38-22-65-62-65-109v-250c0-70 56-126 125-126h500c69 0 125 56 125 126l188-126c34 0 62 28 62 63v375c0 35-28 63-62 63z m-750 0c-69 0-125 56-125 125s56 125 125 125 125-56 125-125-56-125-125-125z m406-1c-87 0-157 70-157 157 0 86 70 156 157 156s156-70 156-156-70-157-156-157z",transform:"matrix(1 0 0 -1 0 850)"},question:{width:857.1,height:1e3,path:"m500 82v107q0 8-5 13t-13 5h-107q-8 0-13-5t-5-13v-107q0-8 5-13t13-5h107q8 0 13 5t5 13z m143 375q0 49-31 91t-77 65-95 23q-136 0-207-119-9-14 4-24l74-55q4-4 10-4 9 0 14 7 30 38 48 51 19 14 48 14 27 0 48-15t21-33q0-21-11-34t-38-25q-35-16-65-48t-29-70v-20q0-8 5-13t13-5h107q8 0 13 5t5 13q0 10 12 27t30 28q18 10 28 16t25 19 25 27 16 34 7 45z m214-107q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z",transform:"matrix(1 0 0 -1 0 850)"},disk:{width:857.1,height:1e3,path:"m214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z",transform:"matrix(1 0 0 -1 0 850)"},lasso:{width:1031,height:1e3,path:"m1018 538c-36 207-290 336-568 286-277-48-473-256-436-463 10-57 36-108 76-151-13-66 11-137 68-183 34-28 75-41 114-42l-55-70 0 0c-2-1-3-2-4-3-10-14-8-34 5-45 14-11 34-8 45 4 1 1 2 3 2 5l0 0 113 140c16 11 31 24 45 40 4 3 6 7 8 11 48-3 100 0 151 9 278 48 473 255 436 462z m-624-379c-80 14-149 48-197 96 42 42 109 47 156 9 33-26 47-66 41-105z m-187-74c-19 16-33 37-39 60 50-32 109-55 174-68-42-25-95-24-135 8z m360 75c-34-7-69-9-102-8 8 62-16 128-68 170-73 59-175 54-244-5-9 20-16 40-20 61-28 159 121 317 333 354s407-60 434-217c28-159-121-318-333-355z",transform:"matrix(1 0 0 -1 0 850)"},selectbox:{width:1e3,height:1e3,path:"m0 850l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-285l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z",transform:"matrix(1 0 0 -1 0 850)"},spikeline:{width:1e3,height:1e3,path:"M512 409c0-57-46-104-103-104-57 0-104 47-104 104 0 57 47 103 104 103 57 0 103-46 103-103z m-327-39l92 0 0 92-92 0z m-185 0l92 0 0 92-92 0z m370-186l92 0 0 93-92 0z m0-184l92 0 0 92-92 0z",transform:"matrix(1.5 0 0 -1.5 0 850)"},newplotlylogo:{name:"newplotlylogo",svg:"plotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":263}],4:[function(t,e,r){"use strict";e.exports=t("../src/traces/candlestick")},{"../src/traces/candlestick":280}],5:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":145}],6:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram")},{"../src/traces/histogram":292}],7:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./histogram"),t("./pie"),t("./ohlc"),t("./candlestick")]),e.exports=n},{"./bar":3,"./candlestick":4,"./core":5,"./histogram":6,"./ohlc":8,"./pie":9}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/ohlc")},{"../src/traces/ohlc":298}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":309}],10:[function(t,e,r){var n=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},i=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var l,s=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),l=0===c.x}catch(t){l=!1}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,a){var i,o,l;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),l=o[e]):(o=t._events=n(null),t._eventsCount=0),l){if("function"==typeof l?l=o[e]=a?[r,l]:[l,r]:a?l.unshift(r):l.push(r),!l.warned&&(i=u(t))&&i>0&&l.length>i){l.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+l.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=l.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else l=o[e]=r,++t._eventsCount;return t}function d(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var s=new Error('Unhandled "error" event. ('+e+")");throw s.context=e,s}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,a=v(t,n),i=0;i=0;o--)if(r[o]===e||r[o].listener===e){l=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(var r=e,n=r+1,a=t.length;n=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],11:[function(t,e,r){!function(){var t={version:"3.5.17"},r=[].slice,n=function(t){return r.call(t)},a=this.document;function i(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(a)try{n(a.documentElement.childNodes)[0].nodeType}catch(t){n=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),a)try{a.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var l=this.Element.prototype,s=l.setAttribute,c=l.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;l.setAttribute=function(t,e){s.call(this,t,e+"")},l.setAttributeNS=function(t,e,r){c.call(this,t,e,r+"")},u.setProperty=function(t,e,r){f.call(this,t,e+"",r)}}function d(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function h(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)<0?n=i+1:a=i}return n},right:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)>0?a=i:n=i+1}return n}}}t.ascending=d,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++an&&(r=n)}else{for(;++a=n){r=n;break}for(;++an&&(r=n)}return r},t.max=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++ar&&(r=n)}else{for(;++a=n){r=n;break}for(;++ar&&(r=n)}return r},t.extent=function(t,e){var r,n,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=n){r=a=n;break}for(;++in&&(r=n),a=n){r=a=n;break}for(;++in&&(r=n),a1)return o/(s-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(d);function y(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return d(t(e),r)}:t)},t.shuffle=function(t,e,r){(i=arguments.length)<3&&(r=t.length,i<2&&(e=0));for(var n,a,i=r-e;i;)a=Math.random()*i--|0,n=t[i+e],t[i+e]=t[a+e],t[a+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],a=new Array(r<0?0:r);e=0;)for(e=(n=t[a]).length;--e>=0;)r[--o]=n[e];return r};var m=Math.abs;function x(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(m(r)),o=-1;if(t*=i,e*=i,(r*=i)<0)for(;(n=t+r*++o)>e;)a.push(n/i);else for(;(n=t+r*++o)=a.length)return r?r.call(n,i):e?i.sort(e):i;for(var s,c,u,f,d=-1,p=i.length,h=a[l++],g=new b;++d=a.length)return e;var n=[],o=i[r++];return e.forEach(function(e,a){n.push({key:e,values:t(a,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return a.push(t),n},n.sortKeys=function(t){return i[a.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new O;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function V(t){return q(t,X),t}var U=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},Y=function(t,e){var r=t.matches||t[z(t,"matchesSelector")];return(Y=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(U=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,Y=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var X=t.selection.prototype=[];function Z(t){return"function"==typeof t?t:function(){return U(t,this)}}function W(t){return"function"==typeof t?t:function(){return G(t,this)}}X.select=function(t){var e,r,n,a,i=[];t=Z(t);for(var o=-1,l=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),$.hasOwnProperty(r)?{space:$[r],local:t}:t}},X.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each(Q(r,e[r]));return this}return this.each(Q(e,r))},X.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,a=-1;if(e=r.classList){for(;++a=0;)(r=n[a])&&(i&&i!==r.nextSibling&&i.parentNode.insertBefore(r,i),i=r);return this},X.sort=function(t){t=function(t){arguments.length||(t=d);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var s=ht.get(e);function c(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return s&&(e=s,l=vt),o?r?function(){var t=l(r,n(arguments));c.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=r}:c:r?R:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(r=a.match(n)){var i=this[a];this.removeEventListener(r[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=dt,dt.append=X.append,dt.empty=X.empty,dt.node=X.node,dt.call=X.call,dt.size=X.size,dt.select=function(t){for(var e,r,n,a,i,o=[],l=-1,s=this.length;++l=n&&(n=e+1);!(o=l[n])&&++n0?1:t<0?-1:0}function Dt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function zt(t){return t>1?0:t<-1?Mt:Math.acos(t)}function Et(t){return t>1?St:t<-1?-St:Math.asin(t)}function Rt(t){return((t=Math.exp(t))+1/t)/2}function Nt(t){return(t=Math.sin(t/2))*t}var It=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,a=t[0],i=t[1],o=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-i,d=u*u+f*f;if(d0&&(e=e.transition().duration(g)),e.call(w.event)}function L(){c&&c.domain(s.range().map(function(t){return(t-d.x)/d.k}).map(s.invert)),f&&f.domain(u.range().map(function(t){return(t-d.y)/d.k}).map(u.invert))}function S(t){v++||t({type:"zoomstart"})}function C(t){L(),t({type:"zoom",scale:d.k,translate:[d.x,d.y]})}function O(t){--v||(t({type:"zoomend"}),r=null)}function P(){var e=this,r=_.of(e,arguments),n=0,a=t.select(o(e)).on(m,function(){n=1,M(t.mouse(e),i),C(r)}).on(x,function(){a.on(m,null).on(x,null),l(n),O(r)}),i=k(t.mouse(e)),l=xt(e);fl.call(e),S(r)}function D(){var e,r=this,n=_.of(r,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+o,c="touchend"+o,u=[],f=t.select(r),p=xt(r);function h(){var n=t.touches(r);return e=d.k,n.forEach(function(t){t.identifier in a&&(a[t.identifier]=k(t))}),n}function g(){var e=t.event.target;t.select(e).on(s,v).on(c,m),u.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){y=p[0];var x=p[1],b=y[0]-x[0],_=y[1]-x[1];i=b*b+_*_}}function v(){var o,s,c,u,f=t.touches(r);fl.call(r);for(var d=0,p=f.length;d360?t-=360:t<0&&(t+=360),t<60?n+(a-n)*t/60:t<180?a:t<240?n+(a-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(a=r<=.5?r*(1+e):r+e-r*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Zt?e.l:(e=de((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Ut(this.h,this.s,this.l)},t.hcl=Gt;var Yt=Gt.prototype=new Ht;function Xt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Zt(r,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Zt(t,e,r){return this instanceof Zt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Zt?new Zt(t.l,t.a,t.b):t instanceof Gt?Xt(t.h,t.c,t.l):de((t=ie(t)).r,t.g,t.b):new Zt(t,e,r)}Yt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Wt*(arguments.length?t:1)))},Yt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Wt*(arguments.length?t:1)))},Yt.rgb=function(){return Xt(this.h,this.c,this.l).rgb()},t.lab=Zt;var Wt=18,Jt=.95047,$t=1,Qt=1.08883,Kt=Zt.prototype=new Ht;function te(t,e,r){var n=(t+16)/116,a=n+e/500,i=n-r/200;return new ie(ae(3.2404542*(a=re(a)*Jt)-1.5371385*(n=re(n)*$t)-.4985314*(i=re(i)*Qt)),ae(-.969266*a+1.8760108*n+.041556*i),ae(.0556434*a-.2040259*n+1.0572252*i))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Ot,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,r){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ue(""+t,ie,Ut):new ie(t,e,r)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function le(t){return oe(t)+""}Kt.brighter=function(t){return new Zt(Math.min(100,this.l+Wt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Zt(Math.max(0,this.l-Wt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var se=ie.prototype=new Ht;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,r){var n,a,i,o=0,l=0,s=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=n[2].split(","),n[1]){case"hsl":return r(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(he(a[0]),he(a[1]),he(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,l=240&i,l|=l>>4,s=15&i,s|=s<<4):7===t.length&&(o=(16711680&i)>>16,l=(65280&i)>>8,s=255&i)),e(o,l,s))}function fe(t,e,r){var n,a,i=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),l=o-i,s=(o+i)/2;return l?(a=s<.5?l/(o+i):l/(2-o-i),n=t==o?(e-r)/l+(e0&&s<1?0:n),new qt(n,a,s)}function de(t,e,r){var n=ne((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(r=pe(r)))/Jt),a=ne((.2126729*t+.7151522*e+.072175*r)/$t);return Zt(116*a-16,500*(n-a),200*(a-ne((.0193339*t+.119192*e+.9503041*r)/Qt)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function he(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}se.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,a=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=a.call(o,c)}catch(t){return void l.error.call(o,t)}l.load.call(o,t)}else l.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var r=t.event;t.event=e;try{l.progress.call(o,c)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,a){if(2===arguments.length&&"function"==typeof n&&(a=n,n=null),c.open(t,e,!0),null==r||"accept"in s||(s.accept=r+",*/*"),c.setRequestHeader)for(var i in s)c.setRequestHeader(i,s[i]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=u&&(c.responseType=u),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),l.beforesend.call(o,c),c.send(null==n?null:n),o},o.abort=function(){return c.abort(),o},t.rebind(o,l,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=ye(P),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function a(t,r,n){arguments.length<3&&(n=r,r=null);var a=me(t,e,null==r?i:o(r),n);return a.row=function(t){return arguments.length?a.response(null==(r=t)?i:o(t)):r},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function l(e){return e.map(s).join(t)}function s(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var r;return a.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(a(t),r)}:a})},a.parseRows=function(t,e){var r,a,i={},o={},l=[],s=t.length,c=0,u=0;function f(){if(c>=s)return o;if(a)return a=!1,i;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Me,e)),_e=0):(_e=1,ke(Me))}function Ae(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Le(){for(var t,e=xe,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Se(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Ce[8+n/3]};var Oe=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Pe=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Se(e,r))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),r))))}});function De(t){return t+""}var ze=t.time={},Ee=Date;function Re(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Re.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ne.setUTCDate.apply(this._,arguments)},setDay:function(){Ne.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ne.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ne.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ne.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ne.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ne.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ne.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ne.setTime.apply(this._,arguments)}};var Ne=Date.prototype;function Ie(t,e,r){function n(e){var r=t(e),n=i(r,1);return e-r1)for(;o68?1900:2e3),r+a[0].length):-1}function Je(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function $e(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function Qe(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ar(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=m(e)/60|0,a=m(e)%60;return r+qe(n,"0",2)+qe(a,"0",2)}function ir(t,e,r){He.lastIndex=0;var n=He.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),i.push(t.substring(r-=l,r+l)),!((s+=l+1)>e));)l=a[o=(o+1)%a.length];return i.reverse().join(n)}:P;return function(e){var n=Oe.exec(e),a=n[1]||" ",l=n[2]||">",s=n[3]||"-",c=n[4]||"",u=n[5],f=+n[6],d=n[7],p=n[8],h=n[9],g=1,v="",y="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===a&&"="===l)&&(u=a="0",l="="),h){case"n":d=!0,h="g";break;case"%":g=100,y="%",h="f";break;case"p":g=100,y="%",h="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+h.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":g=-1,h="r"}"$"===c&&(v=i[0],y=i[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):"e"!=h&&"f"!=h||(p=Math.max(0,Math.min(20,p)))),h=Pe.get(h)||De;var b=u&&d;return function(e){var n=y;if(m&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===s?"":s;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),n=c.symbol+y}else e*=g;var _,w,k=(e=h(e,p)).lastIndexOf(".");if(k<0){var T=x?e.lastIndexOf("e"):-1;T<0?(_=e,w=""):(_=e.substring(0,T),w=e.substring(T))}else _=e.substring(0,k),w=r+e.substring(k+1);!u&&d&&(_=o(_,1/0));var M=v.length+_.length+w.length+(b?0:i.length),A=M"===l?A+i+e:"^"===l?A.substring(0,M>>=1)+i+e+A.substring(M):i+(b?e:A+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,a=e.time,i=e.periods,o=e.days,l=e.shortDays,s=e.months,c=e.shortMonths;function u(t){var e=t.length;function r(r){for(var n,a,i,o=[],l=-1,s=0;++l=c)return-1;if(37===(a=e.charCodeAt(l++))){if(o=e.charAt(l++),!(i=w[o in Be?e.charAt(l++):o])||(n=i(t,r,n))<0)return-1}else if(a!=r.charCodeAt(n++))return-1}return n}u.utc=function(t){var e=u(t);function r(t){try{var r=new(Ee=Re);return r._=t,e(r)}finally{Ee=Date}}return r.parse=function(t){try{Ee=Re;var r=e.parse(t);return r&&r._}finally{Ee=Date}},r.toString=e.toString,r},u.multi=u.utc.multi=or;var d=t.map(),p=Ve(o),h=Ue(o),g=Ve(l),v=Ue(l),y=Ve(s),m=Ue(s),x=Ve(c),b=Ue(c);i.forEach(function(t,e){d.set(t.toLowerCase(),e)});var _={a:function(t){return l[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:u(r),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+ze.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(ze.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(ze.mondayOfYear(t),e,2)},x:u(n),X:u(a),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:ar,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=h.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){y.lastIndex=0;var n=y.exec(e.slice(r));return n?(t.m=m.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:Qe,e:Qe,H:tr,I:tr,j:Ke,L:nr,m:$e,M:er,p:function(t,e,r){var n=d.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:Ye,w:Ge,W:Xe,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:We,Y:Ze,Z:Je,"%":ir};return u}(e)}};var lr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function sr(){}t.format=lr.numberFormat,t.geo={},sr.prototype={s:0,t:0,add:function(t){ur(t,this.t,cr),ur(cr.s,this.s,this),this.s?this.t+=cr.t:this.s=cr.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cr=new sr;function ur(t,e,r){var n=r.s=t+e,a=n-t,i=n-a;r.t=t-i+(e-a)}function fr(t,e){t&&pr.hasOwnProperty(t.type)&&pr[t.type](t,e)}t.geo.stream=function(t,e){t&&dr.hasOwnProperty(t.type)?dr[t.type](t,e):fr(t,e)};var dr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,a=r.length;++n=0?1:-1,l=o*i,s=Math.cos(e),c=Math.sin(e),u=a*c,f=n*s+u*Math.cos(l),d=u*o*Math.sin(l);Sr.add(Math.atan2(d,f)),r=t,n=s,a=c}Cr.point=function(o,l){Cr.point=i,r=(t=o)*Ct,n=Math.cos(l=(e=l)*Ct/2+Mt/4),a=Math.sin(l)},Cr.lineEnd=function(){i(t,e)}}function Pr(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Dr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function zr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Er(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Rr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Nr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Ir(t){return[Math.atan2(t[1],t[0]),Et(t[2])]}function Fr(t,e){return m(t[0]-e[0])kt?a=90:c<-kt&&(r=-90),f[0]=e,f[1]=n}};function p(t,i){u.push(f=[e=t,n=t]),ia&&(a=i)}function h(t,o){var l=Pr([t*Ct,o*Ct]);if(s){var c=zr(s,l),u=zr([c[1],-c[0],0],c);Nr(u),u=Ir(u);var f=t-i,d=f>0?1:-1,h=u[0]*Ot*d,g=m(f)>180;if(g^(d*ia&&(a=v);else if(g^(d*i<(h=(h+360)%360-180)&&ha&&(a=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>i?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else p(t,o);s=l,i=t}function g(){d.point=h}function v(){f[0]=e,f[1]=n,d.point=p,s=null}function y(t,e){if(s){var r=t-i;c+=m(r)>180?r+(r>0?360:-360):r}else o=t,l=e;Cr.point(t,e),h(t,e)}function x(){Cr.lineStart()}function b(){y(o,l),Cr.lineEnd(),m(c)>kt&&(e=-(n=180)),f[0]=e,f[1]=n,s=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):l.push(g=p);for(var s,c,p,h=-1/0,g=(o=0,l[c=l.length-1]);o<=c;g=p,++o)p=l[o],(s=_(g[1],p[0]))>h&&(h=s,e=p[0],n=g[1])}return u=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,a]]}}(),t.geo.centroid=function(e){yr=mr=xr=br=_r=wr=kr=Tr=Mr=Ar=Lr=0,t.geo.stream(e,Br);var r=Mr,n=Ar,a=Lr,i=r*r+n*n+a*a;return i=0;--l)a.point((f=u[l])[0],f[1]);else n(p.x,p.p.x,-1,a);p=p.p}u=(p=p.o).z,h=!h}while(!p.v);a.lineEnd()}}}function Zr(t){if(e=t.length){for(var e,r,n=0,a=t[0];++n=0?1:-1,k=w*_,T=k>Mt,M=h*x;if(Sr.add(Math.atan2(M*w*Math.sin(k),g*b+M*Math.cos(k))),i+=T?_+w*At:_,T^d>=r^y>=r){var A=zr(Pr(f),Pr(t));Nr(A);var L=zr(a,A);Nr(L);var S=(T^_>=0?-1:1)*Et(L[2]);(n>S||n===S&&(A[0]||A[1]))&&(o+=T^_>=0?1:-1)}if(!v++)break;d=y,h=x,g=b,f=t}}return(i<-kt||i0){for(x||(o.polygonStart(),x=!0),o.lineStart();++i1&&2&e&&r.push(r.pop().concat(r.shift())),l.push(r.filter($r))}return u}}function $r(t){return t.length>1}function Qr(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:R,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-St-kt:St-t[1])-((e=e.x)[0]<0?e[1]-St-kt:St-e[1])}var tn=Jr(Yr,function(t){var e,r=NaN,n=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var l=i>0?Mt:-Mt,s=m(i-r);m(s-Mt)0?St:-St),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),t.point(i,n),e=0):a!==l&&s>=Mt&&(m(r-a)kt?Math.atan((Math.sin(e)*(i=Math.cos(n))*Math.sin(r)-Math.sin(n)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+n)/2}(r,n,i,o),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(l,n),e=0),t.point(r=i,n=o),a=l},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var a;if(null==t)a=r*St,n.point(-Mt,a),n.point(0,a),n.point(Mt,a),n.point(Mt,0),n.point(Mt,-a),n.point(0,-a),n.point(-Mt,-a),n.point(-Mt,0),n.point(-Mt,a);else if(m(t[0]-e[0])>kt){var i=t[0]0)){if(i/=d,d<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=r-s,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>u&&(u=i)}else if(d>0){if(i0)){if(i/=p,p<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=n-c,p||!(i<0)){if(i/=p,p<0){if(i>f)return;i>u&&(u=i)}else if(p>0){if(i0&&(a.a={x:s+u*d,y:c+u*p}),f<1&&(a.b={x:s+f*d,y:c+f*p}),a}}}}}}var rn=1e9;function nn(e,r,n,a){return function(s){var c,u,f,d,p,h,g,v,y,m,x,b=s,_=Qr(),w=en(e,r,n,a),k={point:A,lineStart:function(){k.point=L,u&&u.push(f=[]);m=!0,y=!1,g=v=NaN},lineEnd:function(){c&&(L(d,p),h&&y&&_.rejoin(),c.push(_.buffer()));k.point=A,y&&s.lineEnd()},polygonStart:function(){s=_,c=[],u=[],x=!0},polygonEnd:function(){s=b,c=t.merge(c);var r=function(t){for(var e=0,r=u.length,n=t[1],a=0;an&&Dt(c,i,t)>0&&++e:i[1]<=n&&Dt(c,i,t)<0&&--e,c=i;return 0!==e}([e,a]),n=x&&r,i=c.length;(n||i)&&(s.polygonStart(),n&&(s.lineStart(),T(null,null,1,s),s.lineEnd()),i&&Xr(c,o,r,T,s),s.polygonEnd()),c=u=f=null}};function T(t,o,s,c){var u=0,f=0;if(null==t||(u=i(t,s))!==(f=i(o,s))||l(t,o)<0^s>0)do{c.point(0===u||3===u?e:n,u>1?a:r)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function M(t,i){return e<=t&&t<=n&&r<=i&&i<=a}function A(t,e){M(t,e)&&s.point(t,e)}function L(t,e){var r=M(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(u&&f.push([t,e]),m)d=t,p=e,h=r,m=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&y)s.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(y||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),x=!1):r&&(s.lineStart(),s.point(t,e),x=!1)}g=t,v=e,y=r}return k};function i(t,a){return m(t[0]-e)0?0:3:m(t[0]-n)0?2:1:m(t[1]-r)0?1:0:a>0?3:2}function o(t,e){return l(t.x,e.x)}function l(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Mt/3,n=Cn(t),a=n(e,r);return a.parallels=function(t){return arguments.length?n(e=t[0]*Mt/180,r=t[1]*Mt/180):[e/Mt*180,r/Mt*180]},a}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,a=1+r*(2*n-r),i=Math.sqrt(a)/n;function o(t,e){var r=Math.sqrt(a-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),i-r*Math.cos(t)]}return o.invert=function(t,e){var r=i-e;return[Math.atan2(t,r)/n,Et((a-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(l){return arguments.length?(i=nn(t=+l[0][0],e=+l[0][1],r=+l[1][0],n=+l[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,r){e=[t,r]}};function c(t){var i=t[0],o=t[1];return e=null,r(i,o),e||(n(i,o),e)||a(i,o),e}return c.invert=function(t){var e=i.scale(),r=i.translate(),n=(t[0]-r[0])/e,a=(t[1]-r[1])/e;return(a>=.12&&a<.234&&n>=-.425&&n<-.214?o:a>=.166&&a<.234&&n>=-.214&&n<-.115?l:i).invert(t)},c.stream=function(t){var e=i.stream(t),r=o.stream(t),n=l.stream(t);return{point:function(t,a){e.point(t,a),r.point(t,a),n.point(t,a)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),l.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),l.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),u=+t[0],f=+t[1];return r=i.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(s).point,n=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(s).point,a=l.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(s).point,c},c.scale(1070)};var ln,sn,cn,un,fn,dn,pn={point:R,lineStart:R,lineEnd:R,polygonStart:function(){sn=0,pn.lineStart=hn},polygonEnd:function(){pn.lineStart=pn.lineEnd=pn.point=R,ln+=m(sn/2)}};function hn(){var t,e,r,n;function a(t,e){sn+=n*t-r*e,r=t,n=e}pn.point=function(i,o){pn.point=a,t=r=i,e=n=o},pn.lineEnd=function(){a(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);edn&&(dn=e)},lineStart:R,lineEnd:R,polygonStart:R,polygonEnd:R};function vn(){var t=yn(4.5),e=[],r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=yn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function a(t,n){e.push("M",t,",",n),r.point=i}function i(t,r){e.push("L",t,",",r)}function o(){r.point=n}function l(){e.push("Z")}return r}function yn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var mn,xn={point:bn,lineStart:_n,lineEnd:wn,polygonStart:function(){xn.lineStart=kn},polygonEnd:function(){xn.point=bn,xn.lineStart=_n,xn.lineEnd=wn}};function bn(t,e){xr+=t,br+=e,++_r}function _n(){var t,e;function r(r,n){var a=r-t,i=n-e,o=Math.sqrt(a*a+i*i);wr+=o*(t+r)/2,kr+=o*(e+n)/2,Tr+=o,bn(t=r,e=n)}xn.point=function(n,a){xn.point=r,bn(t=n,e=a)}}function wn(){xn.point=bn}function kn(){var t,e,r,n;function a(t,e){var a=t-r,i=e-n,o=Math.sqrt(a*a+i*i);wr+=o*(r+t)/2,kr+=o*(n+e)/2,Tr+=o,Mr+=(o=n*t-r*e)*(r+t),Ar+=o*(n+e),Lr+=3*o,bn(r=t,n=e)}xn.point=function(i,o){xn.point=a,bn(t=r=i,e=n=o)},xn.lineEnd=function(){a(t,e)}}function Tn(t){var e=4.5,r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=l},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:R};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,At)}function a(e,n){t.moveTo(e,n),r.point=i}function i(e,r){t.lineTo(e,r)}function o(){r.point=n}function l(){t.closePath()}return r}function Mn(t){var e=.5,r=Math.cos(30*Ct),n=16;function a(e){return(n?function(e){var r,a,o,l,s,c,u,f,d,p,h,g,v={point:y,lineStart:m,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=m}};function y(r,n){r=t(r,n),e.point(r[0],r[1])}function m(){f=NaN,v.point=x,e.lineStart()}function x(r,a){var o=Pr([r,a]),l=t(r,a);i(f,d,u,p,h,g,f=l[0],d=l[1],u=r,p=o[0],h=o[1],g=o[2],n,e),e.point(f,d)}function b(){v.point=y,e.lineEnd()}function _(){m(),v.point=w,v.lineEnd=k}function w(t,e){x(r=t,e),a=f,o=d,l=p,s=h,c=g,v.point=x}function k(){i(f,d,u,p,h,g,a,o,r,l,s,c,n,e),v.lineEnd=b,b()}return v}:function(e){return Ln(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function i(n,a,o,l,s,c,u,f,d,p,h,g,v,y){var x=u-n,b=f-a,_=x*x+b*b;if(_>4*e&&v--){var w=l+p,k=s+h,T=c+g,M=Math.sqrt(w*w+k*k+T*T),A=Math.asin(T/=M),L=m(m(T)-1)e||m((x*P+b*D)/_-.5)>.3||l*p+s*h+c*g0&&16,a):Math.sqrt(e)},a}function An(t){this.stream=t}function Ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sn(t){return Cn(function(){return t})()}function Cn(e){var r,n,a,i,o,l,s=Mn(function(t,e){return[(t=r(t,e))[0]*c+i,o-t[1]*c]}),c=150,u=480,f=250,d=0,p=0,h=0,g=0,v=0,y=tn,x=P,b=null,_=null;function w(t){return[(t=a(t[0]*Ct,t[1]*Ct))[0]*c+i,o-t[1]*c]}function k(t){return(t=a.invert((t[0]-i)/c,(o-t[1])/c))&&[t[0]*Ot,t[1]*Ot]}function T(){a=Gr(n=zn(h,g,v),r);var t=r(d,p);return i=u-t[0]*c,o=f+t[1]*c,M()}function M(){return l&&(l.valid=!1,l=null),w}return w.stream=function(t){return l&&(l.valid=!1),(l=On(y(n,s(x(t))))).valid=!0,l},w.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,tn):function(t){var e=Math.cos(t),r=e>0,n=m(e)>kt;return Jr(a,function(t){var e,l,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var p,h=[f,d],g=a(f,d),v=r?g?0:o(f,d):g?o(f+(f<0?Mt:-Mt),d):0;if(!e&&(c=s=g)&&t.lineStart(),g!==s&&(p=i(e,h),(Fr(e,p)||Fr(h,p))&&(h[0]+=kt,h[1]+=kt,g=a(h[0],h[1]))),g!==s)u=0,g?(t.lineStart(),p=i(h,e),t.point(p[0],p[1])):(p=i(e,h),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(n&&e&&r^g){var y;v&l||!(y=i(h,e,!0))||(u=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!g||e&&Fr(e,h)||t.point(h[0],h[1]),e=h,s=g,l=v},lineEnd:function(){s&&t.lineEnd(),e=null},clean:function(){return u|(c&&s)<<1}}},In(t,6*Ct),r?[0,-t]:[-Mt,t-Mt]);function a(t,r){return Math.cos(t)*Math.cos(r)>e}function i(t,r,n){var a=[1,0,0],i=zr(Pr(t),Pr(r)),o=Dr(i,i),l=i[0],s=o-l*l;if(!s)return!n&&t;var c=e*o/s,u=-e*l/s,f=zr(a,i),d=Rr(a,c);Er(d,Rr(i,u));var p=f,h=Dr(d,p),g=Dr(p,p),v=h*h-g*(Dr(d,d)-1);if(!(v<0)){var y=Math.sqrt(v),x=Rr(p,(-h-y)/g);if(Er(x,d),x=Ir(x),!n)return x;var b,_=t[0],w=r[0],k=t[1],T=r[1];w<_&&(b=_,_=w,w=b);var M=w-_,A=m(M-Mt)0^x[1]<(m(x[0]-_)Mt^(_<=x[0]&&x[0]<=w)){var L=Rr(p,(-h+y)/g);return Er(L,d),[x,Ir(L)]}}}function o(e,n){var a=r?t:Mt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),n<-a?i|=4:n>a&&(i|=8),i}}((b=+t)*Ct),M()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):P,M()):_},w.scale=function(t){return arguments.length?(c=+t,T()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],T()):[u,f]},w.center=function(t){return arguments.length?(d=t[0]%360*Ct,p=t[1]%360*Ct,T()):[d*Ot,p*Ot]},w.rotate=function(t){return arguments.length?(h=t[0]%360*Ct,g=t[1]%360*Ct,v=t.length>2?t[2]%360*Ct:0,T()):[h*Ot,g*Ot,v*Ot]},t.rebind(w,s,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&k,T()}}function On(t){return Ln(t,function(e,r){t.point(e*Ct,r*Ct)})}function Pn(t,e){return[t,e]}function Dn(t,e){return[t>Mt?t-At:t<-Mt?t+At:t,e]}function zn(t,e,r){return t?e||r?Gr(Rn(t),Nn(e,r)):Rn(t):e||r?Nn(e,r):Dn}function En(t){return function(e,r){return[(e+=t)>Mt?e-At:e<-Mt?e+At:e,r]}}function Rn(t){var e=En(t);return e.invert=En(-t),e}function Nn(t,e){var r=Math.cos(t),n=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*r+l*n;return[Math.atan2(s*a-u*i,l*r-c*n),Et(u*a+s*i)]}return o.invert=function(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*a-s*i;return[Math.atan2(s*a+c*i,l*r+u*n),Et(u*r-l*n)]},o}function In(t,e){var r=Math.cos(t),n=Math.sin(t);return function(a,i,o,l){var s=o*e;null!=a?(a=Fn(r,a),i=Fn(r,i),(o>0?ai)&&(a+=o*At)):(a=t+o*At,i=t-.5*s);for(var c,u=a;o>0?u>i:u2?t[2]*Ct:0),e.invert=function(e){return(e=t.invert(e[0]*Ct,e[1]*Ct))[0]*=Ot,e[1]*=Ot,e},e},Dn.invert=Pn,t.geo.circle=function(){var t,e,r=[0,0],n=6;function a(){var t="function"==typeof r?r.apply(this,arguments):r,n=zn(-t[0]*Ct,-t[1]*Ct,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=n(t,e)),t[0]*=Ot,t[1]*=Ot}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(r=t,a):r},a.angle=function(r){return arguments.length?(e=In((t=+r)*Ct,n*Ct),a):t},a.precision=function(r){return arguments.length?(e=In(t*Ct,(n=+r)*Ct),a):n},a.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Ct,a=t[1]*Ct,i=e[1]*Ct,o=Math.sin(n),l=Math.cos(n),s=Math.sin(a),c=Math.cos(a),u=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-s*f*l)*r),s*u+c*f*l)},t.geo.graticule=function(){var e,r,n,a,i,o,l,s,c,u,f,d,p=10,h=p,g=90,v=360,y=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(a/g)*g,n,g).map(f).concat(t.range(Math.ceil(s/v)*v,l,v).map(d)).concat(t.range(Math.ceil(r/p)*p,e,p).filter(function(t){return m(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/h)*h,i,h).filter(function(t){return m(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(d(l).slice(1),f(n).reverse().slice(1),d(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(a=+t[0][0],n=+t[1][0],s=+t[0][1],l=+t[1][1],a>n&&(t=a,a=n,n=t),s>l&&(t=s,s=l,l=t),x.precision(y)):[[a,s],[n,l]]},x.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),o>i&&(t=o,o=i,i=t),x.precision(y)):[[r,o],[e,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],h=+t[1],x):[p,h]},x.precision=function(t){return arguments.length?(y=+t,c=Bn(o,i,90),u=jn(r,e,y),f=Bn(s,l,90),d=jn(a,n,y),x):y},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,r,n=Hn,a=qn;function i(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||a.apply(this,arguments))},i.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,i):n},i.target=function(t){return arguments.length?(a=t,r="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return r=t[0]*Ct,n=t[1]*Ct,a=e[0]*Ct,i=e[1]*Ct,o=Math.cos(n),l=Math.sin(n),s=Math.cos(i),c=Math.sin(i),u=o*Math.cos(r),f=o*Math.sin(r),d=s*Math.cos(a),p=s*Math.sin(a),h=2*Math.asin(Math.sqrt(Nt(i-n)+o*s*Nt(a-r))),g=1/Math.sin(h),(v=h?function(t){var e=Math.sin(t*=h)*g,r=Math.sin(h-t)*g,n=r*u+e*d,a=r*f+e*p,i=r*l+e*c;return[Math.atan2(a,n)*Ot,Math.atan2(i,Math.sqrt(n*n+a*a))*Ot]}:function(){return[r*Ot,n*Ot]}).distance=h,v;var r,n,a,i,o,l,s,c,u,f,d,p,h,g,v},t.geo.length=function(e){return mn=0,t.geo.stream(e,Vn),mn};var Vn={sphere:R,point:R,lineStart:function(){var t,e,r;function n(n,a){var i=Math.sin(a*=Ct),o=Math.cos(a),l=m((n*=Ct)-t),s=Math.cos(l);mn+=Math.atan2(Math.sqrt((l=o*Math.sin(l))*l+(l=r*i-e*o*s)*l),e*i+r*o*s),t=n,e=i,r=o}Vn.point=function(a,i){t=a*Ct,e=Math.sin(i*=Ct),r=Math.cos(i),Vn.point=n},Vn.lineEnd=function(){Vn.point=Vn.lineEnd=R}},lineEnd:R,polygonStart:R,polygonEnd:R};function Un(t,e){function r(e,r){var n=Math.cos(e),a=Math.cos(r),i=t(n*a);return[i*a*Math.sin(e),i*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),a=e(n),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,n*o),Math.asin(n&&r*i/n)]},r}var Gn=Un(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sn(Gn)}).raw=Gn;var Yn=Un(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},P);function Xn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Mt/4+t/2)},a=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),i=r*Math.pow(n(t),a)/a;if(!a)return Jn;function o(t,e){i>0?e<-St+kt&&(e=-St+kt):e>St-kt&&(e=St-kt);var r=i/Math.pow(n(e),a);return[r*Math.sin(a*t),i-r*Math.cos(a*t)]}return o.invert=function(t,e){var r=i-e,n=Pt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(i/n,1/a))-St]},o}function Zn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),a=r/n+t;if(m(n)1&&Dt(t[r[n-2]],t[r[n-1]],t[a])<=0;)--n;r[n++]=a}return r.slice(0,n)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sn(Kn)}).raw=Kn,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=$n(ta),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,r=ra;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,a=ve(e),i=ve(r),o=t.length,l=[],s=[];for(n=0;n=0;--n)p.push(t[l[c[n]][2]]);for(n=+f;nkt)l=l.L;else{if(!((a=i-wa(l,o))>kt)){n>-kt?(e=l.P,r=l):a>-kt?(e=l,r=l.N):e=r=l;break}if(!l.R){e=l;break}l=l.R}var s=ya(t);if(fa.insert(e,s),e||r){if(e===r)return La(e),r=ya(e.site),fa.insert(s,r),s.edge=r.edge=Oa(e.site,s.site),Aa(e),void Aa(r);if(r){La(e),La(r);var c=e.site,u=c.x,f=c.y,d=t.x-u,p=t.y-f,h=r.site,g=h.x-u,v=h.y-f,y=2*(d*v-p*g),m=d*d+p*p,x=g*g+v*v,b={x:(v*m-p*x)/y+u,y:(d*x-g*m)/y+f};Pa(r.edge,c,h,b),s.edge=Oa(c,t,null,b),r.edge=Oa(t,h,null,b),Aa(e),Aa(r)}else s.edge=Oa(e.site,s.site)}}function _a(t,e){var r=t.site,n=r.x,a=r.y,i=a-e;if(!i)return n;var o=t.P;if(!o)return-1/0;var l=(r=o.site).x,s=r.y,c=s-e;if(!c)return l;var u=l-n,f=1/i-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-i/2)))/f+n:(n+l)/2}function wa(t,e){var r=t.N;if(r)return _a(r,e);var n=t.site;return n.y===e?n.x:1/0}function ka(t){this.site=t,this.edges=[]}function Ta(t,e){return e.angle-t.angle}function Ma(){Ea(this),this.x=this.y=this.arc=this.site=this.cy=null}function Aa(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,a=t.site,i=r.site;if(n!==i){var o=a.x,l=a.y,s=n.x-o,c=n.y-l,u=i.x-o,f=2*(s*(v=i.y-l)-c*u);if(!(f>=-Tt)){var d=s*s+c*c,p=u*u+v*v,h=(v*d-c*p)/f,g=(s*p-u*d)/f,v=g+l,y=ga.pop()||new Ma;y.arc=t,y.site=a,y.x=h+o,y.y=v+Math.sqrt(h*h+g*g),y.cy=v,t.circle=y;for(var m=null,x=pa._;x;)if(y.y=l)return;if(d>h){if(i){if(i.y>=c)return}else i={x:v,y:s};r={x:v,y:c}}else{if(i){if(i.y1)if(d>h){if(i){if(i.y>=c)return}else i={x:(s-a)/n,y:s};r={x:(c-a)/n,y:c}}else{if(i){if(i.y=l)return}else i={x:o,y:n*o+a};r={x:l,y:n*l+a}}else{if(i){if(i.xkt||m(a-r)>kt)&&(l.splice(o,0,new Da((y=i.site,x=u,b=m(n-f)kt?{x:f,y:m(e-f)kt?{x:m(r-h)kt?{x:d,y:m(e-d)kt?{x:m(r-p)=r&&c.x<=a&&c.y>=n&&c.y<=o?[[r,o],[a,o],[a,n],[r,n]]:[]).point=t[l]}),e}function l(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/kt)*kt,y:Math.round(a(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Fa(l(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fa(l(t)).cells.forEach(function(r,n){for(var a,i,o,l,s=r.site,c=r.edges.sort(Ta),u=-1,f=c.length,d=c[f-1].edge,p=d.l===s?d.r:d.l;++ui&&(a=e.slice(i,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(n=n[0])?l[o]?l[o]+=n:l[++o]=n:(l[++o]=null,s.push({i:o,x:Ga(r,n)})),i=Za.lastIndex;return ig&&(g=s.x),s.y>v&&(v=s.y),c.push(s.x),u.push(s.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-h;function T(t,e,r,n,a,i,o,l){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var s=t.x,c=t.y;if(null!=s)if(m(s-r)+m(c-n)<.01)M(t,e,r,n,a,i,o,l);else{var u=t.point;t.x=t.y=t.point=null,M(t,u,s,c,a,i,o,l),M(t,e,r,n,a,i,o,l)}else t.x=r,t.y=n,t.point=e}else M(t,e,r,n,a,i,o,l)}function M(t,e,r,n,a,i,o,l){var s=.5*(a+o),c=.5*(i+l),u=r>=s,f=n>=c,d=f<<1|u;t.leaf=!1,u?a=s:o=s,f?i=c:l=c,T(t=t.nodes[d]||(t.nodes[d]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}}),e,r,n,a,i,o,l)}w>k?v=h+w:g=p+k;var A={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(A,t,+y(t,++f),+x(t,f),p,h,g,v)}};if(A.visit=function(t){!function t(e,r,n,a,i,o){if(!e(r,n,a,i,o)){var l=.5*(n+i),s=.5*(a+o),c=r.nodes;c[0]&&t(e,c[0],n,a,l,s),c[1]&&t(e,c[1],l,a,i,s),c[2]&&t(e,c[2],n,s,l,o),c[3]&&t(e,c[3],l,s,i,o)}}(t,A,p,h,g,v)},A.find=function(t){return function(t,e,r,n,a,i,o){var l,s=1/0;return function t(c,u,f,d,p){if(!(u>i||f>o||d=_)<<1|e>=b,k=w+4;w=0&&!(n=t.interpolators[a](e,r)););return n}function Ja(t,e){var r,n=[],a=[],i=t.length,o=e.length,l=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function ii(t){return 1-Math.cos(t*St)}function oi(t){return Math.pow(2,10*(t-1))}function li(t){return 1-Math.sqrt(1-t*t)}function si(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ci(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ui(t){var e,r,n,a=[t.a,t.b],i=[t.c,t.d],o=di(a),l=fi(a,i),s=di(((e=i)[0]+=(n=-l)*(r=a)[0],e[1]+=n*r[1],e))||0;a[0]*i[1]=0?t.slice(0,n):t,i=n>=0?t.slice(n+1):"in";return a=Qa.get(a)||$a,i=Ka.get(i)||P,e=i(a.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,a=e.c,i=e.l,o=r.h-n,l=r.c-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.c:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Xt(n+o*t,a+l*t,i+s*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,a=e.s,i=e.l,o=r.h-n,l=r.s-a,s=r.l-i;isNaN(l)&&(l=0,a=isNaN(a)?r.s:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ut(n+o*t,a+l*t,i+s*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,a=e.a,i=e.b,o=r.l-n,l=r.a-a,s=r.b-i;return function(t){return te(n+o*t,a+l*t,i+s*t)+""}},t.interpolateRound=ci,t.transform=function(e){var r=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ui(e?e.matrix:pi)})(e)},ui.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pi={a:1,b:0,c:0,d:1,e:0,f:0};function hi(t){return t.length?t.pop()+",":""}function gi(e,r){var n=[],a=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push("translate(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,a),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(hi(r)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&r.push(hi(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,a),function(t,e,r,n){t!==e?n.push({i:r.push(hi(r)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&r.push(hi(r)+"skewX("+e+")")}(e.skew,r.skew,n,a),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push(hi(r)+"scale(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(hi(r)+"scale("+e+")")}(e.scale,r.scale,n,a),e=r=null,function(t){for(var e,r=-1,i=a.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,s.end({type:"end",alpha:n=0})):t>0&&(s.start({type:"start",alpha:n=t}),e=Te(l.tick)),l):n},l.start=function(){var t,e,r,n=y.length,s=m.length,u=c[0],h=c[1];for(t=0;t=0;)r.push(a[n])}function Ci(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(u=c[s]),u.parent=i,u.depth=i.depth+1;r&&(i.value=0),i.children=c}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Ci(a,function(e){var n,a;t&&(n=e.children)&&n.sort(t),r&&(a=e.parent)&&(a.value+=e.value)}),l}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Si(t,function(t){t.children&&(t.value=0)}),Ci(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var a=e.call(this,t,n);return function t(e,r,n,a){var i=e.children;if(e.x=r,e.y=e.depth*a,e.dx=n,e.dy=a,i&&(o=i.length)){var o,l,s,c=-1;for(n=e.value?n/e.value:0;++cl&&(l=n),o.push(n)}for(r=0;ra&&(n=r,a=e);return n}function Vi(t){return t.reduce(Ui,0)}function Ui(t,e){return t+e[1]}function Gi(t,e){return Yi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Yi(t,e){for(var r=-1,n=+t[0],a=(t[1]-n)/e,i=[];++r<=e;)i[r]=a*r+n;return i}function Xi(e){return[t.min(e),t.max(e)]}function Zi(t,e){return t.value-e.value}function Wi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function $i(t,e){var r=e.x-t.x,n=e.y-t.y,a=t.r+e.r;return.999*a*a>r*r+n*n}function Qi(t){if((e=t.children)&&(s=e.length)){var e,r,n,a,i,o,l,s,c=1/0,u=-1/0,f=1/0,d=-1/0;if(e.forEach(Ki),(r=e[0]).x=-r.r,r.y=0,x(r),s>1&&((n=e[1]).x=n.r,n.y=0,x(n),s>2))for(eo(r,n,a=e[2]),x(a),Wi(r,a),r._pack_prev=a,Wi(a,n),n=r._pack_next,i=3;i0)for(o=-1;++o=f[0]&&s<=f[1]&&((l=c[t.bisect(d,s,1,h)-1]).y+=g,l.push(i[o]));return c}return i.value=function(t){return arguments.length?(r=t,i):r},i.range=function(t){return arguments.length?(n=ve(t),i):n},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Yi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Zi),n=0,a=[1,1];function i(t,i){var o=r.call(this,t,i),l=o[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,Ci(l,function(t){t.r=+u(t.value)}),Ci(l,Qi),n){var f=n*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;Ci(l,function(t){t.r+=f}),Ci(l,Qi),Ci(l,function(t){t.r-=f})}return function t(e,r,n,a){var i=e.children;e.x=r+=a*e.x;e.y=n+=a*e.y;e.r*=a;if(i)for(var o=-1,l=i.length;++op.x&&(p=t),t.depth>h.depth&&(h=t)});var g=r(d,p)/2-d.x,v=n[0]/(p.x+r(p,d)/2+g),y=n[1]/(h.depth||1);Si(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*y})}return c}function o(t){var e=t.children,n=t.parent.children,a=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+r(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+r(t._,a._));t.parent.A=function(t,e,n){if(e){for(var a,i=t,o=t,l=e,s=i.parent.children[0],c=i.m,u=o.m,f=l.m,d=s.m;l=ao(l),i=no(i),l&&i;)s=no(s),(o=ao(o)).a=t,(a=l.z+f-i.z-c+r(l._,i._))>0&&(io(oo(l,t,n),t,a),c+=a,u+=a),f+=l.m,c+=i.m,d+=s.m,u+=o.m;l&&!ao(o)&&(o.t=l,o.m+=f-u),i&&!no(s)&&(s.t=i,s.m+=c-d,n=t)}return n}(t,a,t.parent.A||n[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=n[0],t.y=t.depth*n[1]}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t)?s:null,i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null==(n=t)?null:s,i):a?n:null},Li(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],a=!1;function i(i,o){var l,s=e.call(this,i,o),c=s[0],u=0;Ci(c,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=l?u+=r(e,l):0,e.y=0,l=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(c),d=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(c),p=f.x-r(f,d)/2,h=d.x+r(d,f)/2;return Ci(c,a?function(t){t.x=(t.x-c.x)*n[0],t.y=(c.y-t.y)*n[1]}:function(t){t.x=(t.x-p)/(h-p)*n[0],t.y=(1-(c.y?t.y/c.y:1))*n[1]}),s}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t),i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null!=(n=t),i):a?n:null},Li(i,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,a=[1,1],i=null,o=lo,l=!1,s="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var r,n,a=-1,i=t.length;++a0;)l.push(r=c[a-1]),l.area+=r.area,"squarify"!==s||(n=p(l,g))<=d?(c.pop(),d=n):(l.area-=l.pop().area,h(l,g,i,!1),g=Math.min(i.dx,i.dy),l.length=l.area=0,d=1/0);l.length&&(h(l,g,i,!0),l.length=l.area=0),e.forEach(f)}}function d(t){var e=t.children;if(e&&e.length){var r,n=o(t),a=e.slice(),i=[];for(u(a,n.dx*n.dy/t.value),i.area=0;r=a.pop();)i.push(r),i.area+=r.area,null!=r.z&&(h(i,r.z?n.dx:n.dy,n,!a.length),i.length=i.area=0);e.forEach(d)}}function p(t,e){for(var r,n=t.area,a=0,i=1/0,o=-1,l=t.length;++oa&&(a=r));return e*=e,(n*=n)?Math.max(e*a*c/n,n/(e*i*c)):1/0}function h(t,e,r,a){var i,o=-1,l=t.length,s=r.x,c=r.y,u=e?n(t.area/e):0;if(e==r.dx){for((a||u>r.dy)&&(u=r.dy);++or.dx)&&(u=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,l=a?yi:vi;return i=t(e,r,l,n),o=t(r,e,l,Wa),s}function s(t){return i(t)}s.invert=function(t){return o(t)};s.domain=function(t){return arguments.length?(e=t.map(Number),l()):e};s.range=function(t){return arguments.length?(r=t,l()):r};s.rangeRound=function(t){return s.range(t).interpolate(ci)};s.clamp=function(t){return arguments.length?(a=t,l()):a};s.interpolate=function(t){return arguments.length?(n=t,l()):n};s.ticks=function(t){return bo(e,t)};s.tickFormat=function(t,r){return _o(e,t,r)};s.nice=function(t){return mo(e,t),l()};s.copy=function(){return t(e,r,n,a)};return l()}([0,1],[0,1],Wa,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function l(t){return a?Math.pow(n,t):-Math.pow(n,-t)}function s(t){return r(o(t))}s.invert=function(t){return l(r.invert(t))};s.domain=function(t){return arguments.length?(a=t[0]>=0,r.domain((i=t.map(Number)).map(o)),s):i};s.base=function(t){return arguments.length?(n=+t,r.domain(i.map(o)),s):n};s.nice=function(){var t=po(i.map(o),a?Math:Mo);return r.domain(t),i=t.map(l),s};s.ticks=function(){var t=co(i),e=[],r=t[0],s=t[1],c=Math.floor(o(r)),u=Math.ceil(o(s)),f=n%1?2:n;if(isFinite(u-c)){if(a){for(;c0;d--)e.push(l(c)*d);for(c=0;e[c]s;u--);e=e.slice(c,u)}return e};s.tickFormat=function(e,r){if(!arguments.length)return To;arguments.length<2?r=To:"function"!=typeof r&&(r=t.format(r));var a=Math.max(1,n*e/s.ticks().length);return function(t){var e=t/l(Math.round(o(t)));return e*n0?a[t-1]:r[0],tf?0:1;if(c=Lt)return s(c,p)+(l?s(l,1-p):"")+"Z";var h,g,v,y,m,x,b,_,w,k,T,M,A=0,L=0,S=[];if((y=(+o.apply(this,arguments)||0)/2)&&(v=n===Do?Math.sqrt(l*l+c*c):+n.apply(this,arguments),p||(L*=-1),c&&(L=Et(v/c*Math.sin(y))),l&&(A=Et(v/l*Math.sin(y)))),c){m=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var C=Math.abs(f-u-2*L)<=Mt?0:1;if(L&&Fo(m,x,b,_)===p^C){var O=(u+f)/2;m=c*Math.cos(O),x=c*Math.sin(O),b=_=null}}else m=x=0;if(l){w=l*Math.cos(f-A),k=l*Math.sin(f-A),T=l*Math.cos(u+A),M=l*Math.sin(u+A);var P=Math.abs(u-f+2*A)<=Mt?0:1;if(A&&Fo(w,k,T,M)===1-p^P){var D=(u+f)/2;w=l*Math.cos(D),k=l*Math.sin(D),T=M=null}}else w=k=0;if(d>kt&&(h=Math.min(Math.abs(c-l)/2,+r.apply(this,arguments)))>.001){g=l0?0:1}function Bo(t,e,r,n,a){var i=t[0]-e[0],o=t[1]-e[1],l=(a?n:-n)/Math.sqrt(i*i+o*o),s=l*o,c=-l*i,u=t[0]+s,f=t[1]+c,d=e[0]+s,p=e[1]+c,h=(u+d)/2,g=(f+p)/2,v=d-u,y=p-f,m=v*v+y*y,x=r-n,b=u*p-d*f,_=(y<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-b*b)),w=(b*y-v*_)/m,k=(-b*v-y*_)/m,T=(b*y+v*_)/m,M=(-b*v+y*_)/m,A=w-h,L=k-g,S=T-h,C=M-g;return A*A+L*L>S*S+C*C&&(w=T,k=M),[[w-s,k-c],[w*r/x,k*r/x]]}function jo(t){var e=ea,r=ra,n=Yr,a=qo,i=a.key,o=.7;function l(i){var l,s=[],c=[],u=-1,f=i.length,d=ve(e),p=ve(r);function h(){s.push("M",a(t(c),o))}for(;++u1&&a.push("H",n[0]);return a.join("")},"step-before":Uo,"step-after":Go,basis:Zo,"basis-open":function(t){if(t.length<4)return qo(t);var e,r=[],n=-1,a=t.length,i=[0],o=[0];for(;++n<3;)e=t[n],i.push(e[0]),o.push(e[1]);r.push(Wo(Qo,i)+","+Wo(Qo,o)),--n;for(;++n9&&(a=3*e/Math.sqrt(a),o[l]=a*r,o[l+1]=a*n));l=-1;for(;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+o[l]*o[l])),i.push([a||0,o[l]*a||0]);return i}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Vo(t){return t.join("L")+"Z"}function Uo(t){for(var e=0,r=t.length,n=t[0],a=[n[0],",",n[1]];++e1){l=e[1],i=t[s],s++,n+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-l[0])+","+(i[1]-l[1])+","+i[0]+","+i[1];for(var c=2;cMt)+",1 "+e}function s(t,e,r,n){return"Q 0,0 "+n}return i.radius=function(t){return arguments.length?(r=ve(t),i):r},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(n=ve(t),i):n},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Hn,e=qn,r=al;function n(n,a){var i=t.call(this,n,a),o=e.call(this,n,a),l=(i.y+o.y)/2,s=[i,{x:i.x,y:l},{x:o.x,y:l},o];return"M"+(s=s.map(r))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=al,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-St;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=ol,e=il;function r(r,n){return(sl.get(t.call(this,r,n))||ll)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var sl=t.map({circle:ll,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*ul)),r=e*ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cl),r=e*cl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=sl.keys();var cl=Math.sqrt(3),ul=Math.tan(30*Ct);X.transition=function(t){for(var e,r,n=hl||++yl,a=bl(t),i=[],o=gl||{time:Date.now(),ease:ai,delay:0,duration:250},l=-1,s=this.length;++l0;)c[--d].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[n]:delete t[r],1}f||(i=a.time,o=Te(function(t){var e=f.delay;if(o.t=e+i,e<=t)return d(t-e);o.c=d},0,i),f=u[n]={tween:new b,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++u.count)}vl.call=X.call,vl.empty=X.empty,vl.node=X.node,vl.size=X.size,t.transition=function(e,r){return e&&e.transition?hl?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vl,vl.select=function(t){var e,r,n,a=this.id,i=this.namespace,o=[];t=Z(t);for(var l=-1,s=this.length;++lrect,.s>rect").attr("width",l[1]-l[0])}function g(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function v(){var f,v,y=this,m=t.select(t.event.target),x=n.of(y,arguments),b=t.select(y),_=m.datum(),w=!/^(n|s)$/.test(_)&&a,k=!/^(e|w)$/.test(_)&&i,T=m.classed("extent"),M=xt(y),A=t.mouse(y),L=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(T||(f=null,A[0]-=l[1],A[1]-=s[1],T=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==T&&(A[0]+=l[1],A[1]+=s[1],T=0,F())});if(t.event.changedTouches?L.on("touchmove.brush",O).on("touchend.brush",D):L.on("mousemove.brush",O).on("mouseup.brush",D),b.interrupt().selectAll("*").interrupt(),T)A[0]=l[0]-A[0],A[1]=s[0]-A[1];else if(_){var S=+/w$/.test(_),C=+/^n/.test(_);v=[l[1-S]-A[0],s[1-C]-A[1]],A[0]=l[S],A[1]=s[C]}else t.event.altKey&&(f=A.slice());function O(){var e=t.mouse(y),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),T||(t.event.altKey?(f||(f=[(l[0]+l[1])/2,(s[0]+s[1])/2]),A[0]=l[+(e[0]1?{floor:function(e){for(;l(e=t.floor(e));)e=zl(e-1);return e},ceil:function(e){for(;l(e=t.ceil(e));)e=zl(+e+1);return e}}:t))},a.ticks=function(t,e){var r=co(a.domain()),n=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],zl(+r[1]+1),e<1?1:e)},a.tickFormat=function(){return n},a.copy=function(){return Dl(e.copy(),r,n)},yo(a,e)}function zl(t){return new Date(t)}Sl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Pl:Ol,Pl.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Pl.toString=Ol.toString,ze.second=Ie(function(t){return new Ee(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),ze.seconds=ze.second.range,ze.seconds.utc=ze.second.utc.range,ze.minute=Ie(function(t){return new Ee(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),ze.minutes=ze.minute.range,ze.minutes.utc=ze.minute.utc.range,ze.hour=Ie(function(t){var e=t.getTimezoneOffset()/60;return new Ee(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),ze.hours=ze.hour.range,ze.hours.utc=ze.hour.utc.range,ze.month=Ie(function(t){return(t=ze.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),ze.months=ze.month.range,ze.months.utc=ze.month.utc.range;var El=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Rl=[[ze.second,1],[ze.second,5],[ze.second,15],[ze.second,30],[ze.minute,1],[ze.minute,5],[ze.minute,15],[ze.minute,30],[ze.hour,1],[ze.hour,3],[ze.hour,6],[ze.hour,12],[ze.day,1],[ze.day,2],[ze.week,1],[ze.month,1],[ze.month,3],[ze.year,1]],Nl=Sl.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Yr]]),Il={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(zl)},floor:P,ceil:P};Rl.year=ze.year,ze.scale=function(){return Dl(t.scale.linear(),Rl,Nl)};var Fl=Rl.map(function(t){return[t[0].utc,t[1]]}),Bl=Cl.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Yr]]);function jl(t){return JSON.parse(t.responseText)}function Hl(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Fl.year=ze.year.utc,ze.scale.utc=function(){return Dl(t.scale.linear(),Fl,Bl)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return me(t,"application/json",jl,e)},t.html=function(t,e){return me(t,"text/html",Hl,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],12:[function(t,e,r){(function(n,a){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,l=void 0,s=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(l?l(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,d="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],19:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(l=e,l===window||l===document||l===document.body?n:l.getBoundingClientRect());var l;return r[0]=a-o.left,r[1]=i-o.top,r}},{}],20:[function(t,e,r){var n,a=t("./lib/build-log"),i=t("./lib/epsilon"),o=t("./lib/intersecter"),l=t("./lib/segment-chainer"),s=t("./lib/segment-selector"),c=t("./lib/geojson"),u=!1,f=i();function d(t,e,r){var a=n.segments(t),i=n.segments(e),o=r(n.combine(a,i));return n.polygon(o)}n={buildLog:function(t){return!0===t?u=a():!1===t&&(u=!1),!1!==u&&u.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,u);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,u).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:s.union(t.combined,u),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:s.intersect(t.combined,u),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:s.difference(t.combined,u),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:s.differenceRev(t.combined,u),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:s.xor(t.combined,u),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:l(t.segments,f,u),inverted:t.inverted}},polygonFromGeoJSON:function(t){return c.toPolygon(n,t)},polygonToGeoJSON:function(t){return c.fromPolygon(n,f,t)},union:function(t,e){return d(t,e,n.selectUnion)},intersect:function(t,e){return d(t,e,n.selectIntersect)},difference:function(t,e){return d(t,e,n.selectDifference)},differenceRev:function(t,e){return d(t,e,n.selectDifferenceRev)},xor:function(t,e){return d(t,e,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),e.exports=n},{"./lib/build-log":21,"./lib/epsilon":22,"./lib/geojson":23,"./lib/intersecter":24,"./lib/segment-chainer":26,"./lib/segment-selector":27}],21:[function(t,e,r){e.exports=function(){var t,e=0,r=!1;function n(e,r){return t.list.push({type:e,data:r?JSON.parse(JSON.stringify(r)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return n("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return n("div_seg",{seg:t,pt:e}),n("chop",{seg:t,pt:e})},statusRemove:function(t){return n("pop_seg",{seg:t})},segmentUpdate:function(t){return n("seg_update",{seg:t})},segmentNew:function(t,e){return n("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return n("rem_seg",{seg:t})},tempStatus:function(t,e,r){return n("temp_status",{seg:t,above:e,below:r})},rewind:function(t){return n("rewind",{seg:t})},status:function(t,e,r){return n("status",{seg:t,above:e,below:r})},vert:function(e){return e===r?t:(r=e,n("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),n("log",{txt:t})},reset:function(){return n("reset")},selected:function(t){return n("selected",{segs:t})},chainStart:function(t){return n("chain_start",{seg:t})},chainRemoveHead:function(t,e){return n("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return n("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return n("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return n("chain_match",{index:t})},chainClose:function(t){return n("chain_close",{index:t})},chainAddHead:function(t,e){return n("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return n("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return n("chain_con",{index1:t,index2:e})},chainReverse:function(t){return n("chain_rev",{index:t})},chainJoin:function(t,e){return n("chain_join",{index1:t,index2:e})},done:function(){return n("done")}}}},{}],22:[function(t,e,r){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,r,n){var a=r[0],i=r[1],o=n[0],l=n[1],s=e[0];return(o-a)*(e[1]-i)-(l-i)*(s-a)>=-t},pointBetween:function(e,r,n){var a=e[1]-r[1],i=n[0]-r[0],o=e[0]-r[0],l=n[1]-r[1],s=o*i+a*l;return!(s-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-a>t&&(i-c)*(a-u)/(o-u)+c-n>t&&(l=!l),i=c,o=u}return l}};return e}},{}],23:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),a=1;a0})}function u(t,n){var a=t.seg,i=n.seg,o=a.start,l=a.end,c=i.start,u=i.end;r&&r.checkIntersection(a,i);var f=e.linesIntersect(o,l,c,u);if(!1===f){if(!e.pointsCollinear(o,l,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(l,c))return!1;var d=e.pointsSame(o,c),p=e.pointsSame(l,u);if(d&&p)return n;var h=!d&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(l,c,u);if(d)return g?s(n,l):s(t,u),n;h&&(p||(g?s(n,l):s(t,u)),s(n,o))}else 0===f.alongA&&(-1===f.alongB?s(t,c):0===f.alongB?s(t,f.pt):1===f.alongB&&s(t,u)),0===f.alongB&&(-1===f.alongA?s(n,o):0===f.alongA?s(n,f.pt):1===f.alongA&&s(n,l));return!1}for(var f=[];!i.isEmpty();){var d=i.getHead();if(r&&r.vert(d.pt[0]),d.isStart){r&&r.segmentNew(d.seg,d.primary);var p=c(d),h=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(h){var t=u(d,h);if(t)return t}return!!g&&u(d,g)}r&&r.tempStatus(d.seg,!!h&&h.seg,!!g&&g.seg);var y,m,x=v();if(x)t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=d.seg.myFill,r&&r.segmentUpdate(x.seg),d.other.remove(),d.remove();if(i.getHead()!==d){r&&r.rewind(d.seg);continue}t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=g?g.seg.myFill.above:a,d.seg.myFill.above=m?!d.seg.myFill.below:d.seg.myFill.below):null===d.seg.otherFill&&(y=g?d.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:d.primary?o:a,d.seg.otherFill={above:y,below:y}),r&&r.status(d.seg,!!h&&h.seg,!!g&&g.seg),d.other.status=p.insert(n.node({ev:d}))}else{var b=d.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(l.exists(b.prev)&&l.exists(b.next)&&u(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!d.primary){var _=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=_}f.push(d.seg)}i.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,a,i,o=t[t.length-1],s=0;s1)for(var r=1;r1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=O(t,360),e=O(e,100),r=O(r,100),0===e)n=a=i=r;else{var l=r<.5?r*(1+e):r+e-r*e,s=2*r-l;n=o(s,l,t+1/3),a=o(s,l,t),i=o(s,l,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(e.h,s,u),f=!0,d="hsl"),e.hasOwnProperty("a")&&(i=e.a));var p,h,g;return i=C(i),{ok:f,format:e.format||d,r:o(255,l(a.r,0)),g:o(255,l(a.g,0)),b:o(255,l(a.b,0)),a:i}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=i(100*this._a)/100,this._format=s.format||u.format,this._gradientType=s.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=u.ok,this._tc_id=a++}function u(t,e,r){t=O(t,255),e=O(e,255),r=O(r,255);var n,a,i=l(t,e,r),s=o(t,e,r),c=(i+s)/2;if(i==s)n=a=0;else{var u=i-s;switch(a=c>.5?u/(2-i-s):u/(i+s),i){case t:n=(e-r)/u+(e>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(c(n));return i}function A(t,e){e=e||6;for(var r=c(t).toHsv(),n=r.h,a=r.s,i=r.v,o=[],l=1/e;e--;)o.push(c({h:n,s:a,v:i})),i=(i+l)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,a=this.toRgb();return e=a.r/255,r=a.g/255,n=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=C(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return d(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,a){var o=[z(i(t).toString(16)),z(i(e).toString(16)),z(i(r).toString(16)),z(R(n))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*O(this._r,255))+"%",g:i(100*O(this._g,255))+"%",b:i(100*O(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%)":"rgba("+i(100*O(this._r,255))+"%, "+i(100*O(this._g,255))+"%, "+i(100*O(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[d(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=c(t);r="#"+p(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(T,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:E(t[n]));t=r}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:s(),g:s(),b:s()})},c.mix=function(t,e,r){r=0===r?0:r||50;var n=c(t).toRgb(),a=c(e).toRgb(),i=r/100;return c({r:(a.r-n.r)*i+n.r,g:(a.g-n.g)*i+n.g,b:(a.b-n.b)*i+n.b,a:(a.a-n.a)*i+n.a})},c.readability=function(e,r){var n=c(e),a=c(r);return(t.max(n.getLuminance(),a.getLuminance())+.05)/(t.min(n.getLuminance(),a.getLuminance())+.05)},c.isReadable=function(t,e,r){var n,a,i=c.readability(t,e);switch(a=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},c.mostReadable=function(t,e,r){var n,a,i,o,l=null,s=0;a=(r=r||{}).includeFallbackColors,i=r.level,o=r.size;for(var u=0;us&&(s=n,l=c(e[u]));return c.isReadable(t,l,{level:i,size:o})||!a?l:(r.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],r))};var L=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=c.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(L);function C(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function O(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,l(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function P(t){return o(1,l(0,t))}function D(t){return parseInt(t,16)}function z(t){return 1==t.length?"0"+t:""+t}function E(t){return t<=1&&(t=100*t+"%"),t}function R(e){return t.round(255*parseFloat(e)).toString(16)}function N(t){return D(t)/255}var I,F,B,j=(F="[\\s|\\(]+("+(I="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",B="[\\s|\\(]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",{CSS_UNIT:new RegExp(I),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+B),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+B),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+B),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function H(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],30:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],31:[function(t,e,r){"use strict";var n=t("./arrow_paths"),a=t("../../plots/font_attributes"),i=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:a({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",i.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",i.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:a({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":196,"../../plots/cartesian/constants":212,"../../plots/font_attributes":233,"./arrow_paths":30}],32:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=a.getFromId(t,e.xref),n=a.getFromId(t,e.yref);e._extremes={},r&&l(e,r),n&&l(e,n)})}function l(t,e){var r,n=e._id,i=n.charAt(0),o=t[i],l=t["a"+i],s=t[i+"ref"],c=t["a"+i+"ref"],u=t["_"+i+"padplus"],f=t["_"+i+"padminus"],d={x:1,y:-1}[i]*t[i+"shift"],p=3*t.arrowsize*t.arrowwidth||0,h=p+d,g=p-d,v=3*t.startarrowsize*t.arrowwidth||0,y=v+d,m=v-d;if(c===s){var x=a.findExtremes(e,[e.r2c(o)],{ppadplus:h,ppadminus:g}),b=a.findExtremes(e,[e.r2c(l)],{ppadplus:Math.max(u,y),ppadminus:Math.max(f,m)});r={min:[x.min[0],b.min[0]],max:[x.max[0],b.max[0]]}}else y=l?y+l:y,m=l?m-l:m,r=a.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(u,h,y),ppadminus:Math.max(f,g,m)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([i,o],t)}},{"../../lib":162,"../../plots/cartesian/axes":206,"./draw":37}],33:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,a,i,o,s,c,u=t._fullLayout.annotations,f=[],d=[],p=[],h=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,l,s=o(t,e),c=s.on,u=s.off.concat(s.explicitOff),f={},d=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var V=!1,U=["x","y"],G=0;G1)&&(K===Q?((st=tt.r2fraction(e["a"+$]))<0||st>1)&&(V=!0):V=!0),Y=tt._offset+tt.r2p(e[$]),W=.5}else"x"===$?(Z=e[$],Y=b.l+b.w*Z):(Z=1-e[$],Y=b.t+b.h*Z),W=e.showarrow?.5:Z;if(e.showarrow){lt.head=Y;var ct=e["a"+$];J=rt*q(.5,e.xanchor)-nt*q(.5,e.yanchor),K===Q?(lt.tail=tt._offset+tt.r2p(ct),X=J):(lt.tail=Y+ct,X=J+ct),lt.text=lt.tail+J;var ut=x["x"===$?"width":"height"];if("paper"===Q&&(lt.head=o.constrain(lt.head,1,ut-1)),"pixel"===K){var ft=-Math.max(lt.tail-3,lt.text),dt=Math.min(lt.tail+3,lt.text)-ut;ft>0?(lt.tail+=ft,lt.text+=ft):dt>0&&(lt.tail-=dt,lt.text-=dt)}lt.tail+=ot,lt.head+=ot}else X=J=at*q(W,it),lt.text=Y+J;lt.text+=ot,J+=ot,X+=ot,e["_"+$+"padplus"]=at/2+X,e["_"+$+"padminus"]=at/2-X,e["_"+$+"size"]=at,e["_"+$+"shift"]=J}if(t._dragging||!V){var pt=0,ht=0;if("left"!==e.align&&(pt=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(ht=(D-m)*("middle"===e.valign?.5:1)),u)n.select("svg").attr({x:N+pt-1,y:N+ht}).call(c.setClipUrl,F?A:null,t);else{var gt=N+ht-h.top,vt=N+pt-h.left;H.call(f.positionText,vt,gt).call(c.setClipUrl,F?A:null,t)}B.select("rect").call(c.setRect,N,N,w,D),I.call(c.setRect,E/2,E/2,R-E,j-E),z.call(c.setTranslate,Math.round(L.x.text-R/2),Math.round(L.y.text-j/2)),O.attr({transform:"rotate("+S+","+L.x.text+","+L.y.text+")"});var yt,mt=function(r,n){C.selectAll(".annotation-arrow-g").remove();var u=L.x.head,f=L.y.head,d=L.x.tail+r,h=L.y.tail+n,y=L.x.text+r,m=L.y.text+n,x=o.rotationXYMatrix(S,y,m),w=o.apply2DTransform(x),A=o.apply2DTransform2(x),P=+I.attr("width"),D=+I.attr("height"),E=y-.5*P,R=E+P,N=m-.5*D,F=N+D,B=[[E,N,E,F],[E,F,R,F],[R,F,R,N],[R,N,E,N]].map(A);if(!B.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){B.forEach(function(t){var e=o.segmentsIntersect(d,h,u,f,t[0],t[1],t[2],t[3]);e&&(d=e.x,h=e.y)});var j=e.arrowwidth,H=e.arrowcolor,q=e.arrowside,V=C.append("g").style({opacity:s.opacity(H)}).classed("annotation-arrow-g",!0),U=V.append("path").attr("d","M"+d+","+h+"L"+u+","+f).style("stroke-width",j+"px").call(s.stroke,s.rgb(H));if(g(U,q,e),_.annotationPosition&&U.node().parentNode&&!i){var G=u,Y=f;if(e.standoff){var X=Math.sqrt(Math.pow(u-d,2)+Math.pow(f-h,2));G+=e.standoff*(d-u)/X,Y+=e.standoff*(h-f)/X}var Z,W,J=V.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(d-G)+","+(h-Y),transform:"translate("+G+","+Y+")"}).style("stroke-width",j+6+"px").call(s.stroke,"rgba(0,0,0,0)").call(s.fill,"rgba(0,0,0,0)");p.init({element:J.node(),gd:t,prepFn:function(){var t=c.getTranslate(z);Z=t.x,W=t.y,l&&l.autorange&&k(l._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(Z,W),a=n[0]+t,i=n[1]+r;z.call(c.setTranslate,a,i),T("x",l?l.p2r(l.r2p(e.x)+t):e.x+t/b.w),T("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/b.h),e.axref===e.xref&&T("ax",l.p2r(l.r2p(e.ax)+t)),e.ayref===e.yref&&T("ay",v.p2r(v.r2p(e.ay)+r)),V.attr("transform","translate("+t+","+r+")"),O.attr({transform:"rotate("+S+","+a+","+i+")"})},doneFn:function(){a.call("_guiRelayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&mt(0,0),P)p.init({element:z.node(),gd:t,prepFn:function(){yt=O.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?T("ax",l.p2r(l.r2p(e.ax)+t)):T("ax",e.ax+t),e.ayref===e.yref?T("ay",v.p2r(v.r2p(e.ay)+r)):T("ay",e.ay+r),mt(t,r);else{if(i)return;var a,o;if(l)a=l.p2r(l.r2p(e.x)+t);else{var s=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-s/2;a=p.align(c+t/b.w,s,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-r/b.h,u,0,1,e.yanchor)}T("x",a),T("y",o),l&&v||(n=p.getCursor(l?.5:a,v?.5:o,e.xanchor,e.yanchor))}O.attr({transform:"translate("+t+","+r+")"+yt}),d(z,n)},doneFn:function(){d(z),a.call("_guiRelayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else z.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,y=f.backoff*p+r.standoff,m=d.backoff*h+r.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},l={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-l.x,b=o.y-l.y;if(c=(s=Math.atan2(b,x))+Math.PI,y&&m&&y+m>Math.sqrt(x*x+b*b))return void P();if(y){if(y*y>x*x+b*b)return void P();var _=y*Math.cos(s),w=y*Math.sin(s);l.x+=_,l.y+=w,t.attr({x2:l.x,y2:l.y})}if(m){if(m*m>x*x+b*b)return void P();var k=m*Math.cos(s),T=m*Math.sin(s);o.x-=k,o.y-=T,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var M=u.getTotalLength(),A="";if(M1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+l+'"]').remove():(s._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(s.x)*r[0],e.yaxis.r2l(s.y)*r[1],e.zaxis.r2l(s.z)*r[2]]),n(t.graphDiv,s,l,t.id,s._xa,s._ya))}}},{"../../plots/gl3d/project":236,"../annotations/draw":37}],44:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var i=r.attrRegex,o=Object.keys(t),l=0;l=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var l=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+l+", "+n[3]+")":"rgb("+l+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(n(t))},i.opacity=function(t){return t?n(t).getAlpha():0},i.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},i.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var a=n(e||s).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-r.a)+r.r*r.a,g:i.g*(1-r.a)+r.g*r.a,b:i.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},i.contrast=function(t,e,r){var a=n(t);return 1!==a.getAlpha()&&(a=n(i.combine(t,s))),(a.isDark()?e?a.lighten(e):s:r?a.darken(r):l).toString()},i.stroke=function(t,e){var r=n(e);t.style({stroke:i.tinyRGB(r),"stroke-opacity":r.getAlpha()})},i.fill=function(t,e){var r=n(e);t.style({fill:i.tinyRGB(r),"fill-opacity":r.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,r,n,a,o=Object.keys(t);for(e=0;e0?S>=R:S<=R));C++)S>I&&S0?S>=R:S<=R));C++)S>O[0]&&S1){var ot=Math.pow(10,Math.floor(Math.log(it)/Math.LN10));nt*=ot*c.roundUp(it/ot,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(et.tick0=0)}et.dtick=nt}et.domain=[$+Z,$+G-Z],et.setScale();var lt=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(T.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(T.cbbg,!0),t.append("g").classed(T.cbfills,!0),t.append("g").classed(T.cblines,!0),t.append("g").classed(T.cbaxis,!0).classed(T.crisp,!0),t.append("g").classed(T.cbtitleunshift,!0).append("g").classed(T.cbtitle,!0),t.append("rect").classed(T.cboutline,!0),t.select(".cbtitle").datum(0)})});lt.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var st=lt.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")"),ct=lt.select(".cbaxis"),ut=0;if(-1!==["top","bottom"].indexOf(r.title.side)){var ft,dt=k.l+(r.x+Y)*k.w,pt=et.title.font.size;ft="top"===r.title.side?(1-($+G-Z))*k.h+k.t+3+.75*pt:(1-($+Z))*k.h+k.t-3-.25*pt,xt(et._id+"title",{attributes:{x:dt,y:ft,"text-anchor":"start"}})}var ht,gt,vt,yt=c.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.title.side)){var i=lt.select(".cbtitle"),o=i.select("text"),s=[-r.outlinewidth/2,r.outlinewidth/2],u=i.select(".h"+et._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),u?(ut=d.bBox(u).height)>f&&(s[1]-=(ut-f)/2):o.node()&&!o.classed(T.jsPlaceholder)&&(ut=d.bBox(o.node()).height),ut){if(ut+=5,"top"===r.title.side)et.domain[1]-=ut/k.h,s[1]*=-1;else{et.domain[0]+=ut/k.h;var p=g.lineCount(o);s[1]+=(1-p)*f}i.attr("transform","translate("+s+")"),et.setScale()}}lt.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-et.domain[1]))+")"),ct.attr("transform","translate(0,"+Math.round(-k.t)+")");var h=lt.select(".cbfills").selectAll("rect.cbfill").data(D);h.enter().append("rect").classed(T.cbfill,!0).style("stroke","none"),h.exit().remove();var m=O.map(et.c2p).map(Math.round).sort(function(t,e){return t-e});h.each(function(i,o){var l=[0===o?O[0]:(D[o]+D[o-1])/2,o===D.length-1?O[1]:(D[o]+D[o+1])/2].map(et.c2p).map(Math.round);l[1]=c.constrain(l[1]+(l[1]>l[0])?1:-1,m[0],m[1]);var s=n.select(this).attr({x:W,width:Math.max(q,2),y:n.min(l),height:Math.max(n.max(l)-n.min(l),2)});if(r.fillgradient)d.gradient(s,t,e,"vertical",r.fillgradient,"fill");else{var u=E(i).replace("e-","");s.attr("fill",a(u).toHexString())}});var x=lt.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?P:[]);return x.enter().append("path").classed(T.cbline,!0),x.exit().remove(),x.each(function(t){n.select(this).attr("d","M"+W+","+(Math.round(et.c2p(t))+r.line.width/2%1)+"h"+q).call(d.lineGroupStyle,r.line.width,z(t),r.line.dash)}),ct.selectAll("g."+et._id+"tick,path").remove(),c.syncOrAsync([function(){var e=W+q+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),n=l.calcTicks(et),a=l.makeTransFn(et),i=l.makeLabelFns(et,e),o=l.getTickSigns(et)[2];return l.drawTicks(t,et,{vals:"inside"===et.ticks?l.clipEnds(et,n):n,layer:ct,path:l.makeTickPath(et,e,o),transFn:a}),l.drawLabels(t,et,{vals:n,layer:ct,transFn:a,labelXFn:i.labelXFn,labelYFn:i.labelYFn,labelAnchorFn:i.labelAnchorFn})},function(){if(-1===["top","bottom"].indexOf(r.title.side)){var e=et.title.font.size,a=et._offset+et._length/2,i=k.l+(et.position||0)*k.w+("right"===et.side?10+e*(et.showticklabels?1:.5):-10-e*(et.showticklabels?.5:0));xt("h"+et._id+"title",{avoid:{selection:n.select(t).selectAll("g."+et._id+"tick"),side:r.title.side,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var n=q+r.outlinewidth/2+d.bBox(ct.node()).width;if((B=st.select("text")).node()&&!B.classed(T.jsPlaceholder)){var a,o=st.select(".h"+et._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(r.title.side)?d.bBox(o).width:d.bBox(st.node()).right-W-k.l,n=Math.max(n,a)}var l=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,s=Q-K;lt.select(".cbbg").attr({x:W-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:K-X,width:Math.max(l,2),height:Math.max(s+2*X,2)}).call(p.fill,r.bgcolor).call(p.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),lt.selectAll(".cboutline").attr({x:W,y:K+r.ypad+("top"===r.title.side?ut:0),width:Math.max(q,2),height:Math.max(s-2*r.ypad-ut,2)}).call(p.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var c=({center:.5,right:1}[r.xanchor]||0)*l;lt.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=m[r.yanchor],h=x[r.yanchor];"pixels"===r.lenmode?(u.y=r.y,u.t=s*f,u.b=s*h):(u.t=u.b=0,u.yt=r.y+r.len*f,u.yb=r.y-r.len*h);var g=m[r.xanchor],v=x[r.xanchor];if("pixels"===r.thicknessmode)u.x=r.x,u.l=l*g,u.r=l*v;else{var y=l-q;u.l=y*g,u.r=y*v,u.xl=r.x-r.thickness*g,u.xr=r.x+r.thickness*v}i.autoMargin(t,e,u)}],t);if(yt&&yt.then&&(t._promises||[]).push(yt),t._context.edits.colorbarPosition)s.init({element:lt.node(),gd:t,prepFn:function(){ht=lt.attr("transform"),f(lt)},moveFn:function(t,e){lt.attr("transform",ht+" translate("+t+","+e+")"),gt=s.align(J+t/k.w,V,0,1,r.xanchor),vt=s.align($-e/k.h,G,0,1,r.yanchor);var n=s.getCursor(gt,vt,r.xanchor,r.yanchor);f(lt,n)},doneFn:function(){if(f(lt),void 0!==gt&&void 0!==vt){var e={};e[L("x")]=gt,e[L("y")]=vt,o.call("_guiRestyle",t,e,A().index)}}});return yt}function mt(t,e){return c.coerce(tt,et,w,t,e)}function xt(e,r){var n={propContainer:et,propName:L("title"),traceIndex:A().index,placeholder:v._dfltTitle.colorbar,containerGroup:lt.select(".cbtitle")},a="h"===e.charAt(0)?e.substr(1):"h"+e;lt.selectAll("."+a+",."+a+"-math-group").remove(),h.draw(t,e,u(n,r||{}))}v._infolayer.selectAll("g."+e).remove()}function A(){var r,n,a=e.substr(2);for(r=0;r=0?a.colorscale.sequential:a.colorscale.sequentialminus,s._colorscale=s.colorscale=h)}},{"../../lib":162}],55:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./helpers").hasColorscale;e.exports=function(t){function e(t,e){var r=t["_"+e];void 0!==r&&(t[e]=r)}function r(t,r){var a=r.container?n.nestedProperty(t,r.container).get():t;if(a){var i=a.zauto||a.cauto,o=r.min,l=r.max;(i||void 0===a[o])&&e(a,o),(i||void 0===a[l])&&e(a,l),a.autocolorscale&&e(a,"colorscale")}}for(var i=0;i=0;n--,a++){var i=t[n];r[a]=[1-i[0],i[1]]}return r}function u(t){var e={r:t[0],g:t[1],b:t[2],a:t[3]};return a(e).toRgbString()}e.exports={hasColorscale:function(t,e){var r=e?o.nestedProperty(t,e).get()||{}:t,n=r.color,a=!1;if(o.isArrayOrTypedArray(n))for(var l=0;l4/3-l?o:l}},{}],63:[function(t,e,r){"use strict";var n=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,i){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:n.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":162}],64:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),l=t("../../lib"),s=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function d(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,r,n,f,h,g,v,y,m=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;m._mouseDownTime||(m._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,r){return Math.abs(t)b&&(x=Math.max(x-1,1)),m._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!y){var r;try{r=new MouseEvent("click",e)}catch(t){var n=p(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(m),m._dragged=!1}else m._dragged=!1}},u.coverSlip=d},{"../../constants/interactions":142,"../../lib":162,"../../plots/cartesian/constants":212,"../../registry":246,"./align":62,"./cursor":63,"./unhover":65,"has-hover":15,"has-passive-events":16,"mouse-event-offset":19}],65:[function(t,e,r){"use strict";var n=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),l=e.exports={};l.wrapped=function(t,e,r){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),l.raw(t,e,r)},l.raw=function(t,e){var r=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":155,"../../lib/get_graph_div":160,"../../lib/throttle":184,"../fx/constants":79}],66:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],67:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,h=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){c.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(l.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,a){t.call(v.setPosition,e,r).call(v.setSize,n,a)},v.translatePoint=function(t,e,r,n){var i=r.c2p(t.x),o=n.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var a=n.select(this);v.translatePoint(t,a,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,a,i){e.attr("display",r.isPtWithinRange(t,a)&&n.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,l=i.ycalendar,s="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(s).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,a,o,l)})})}},v.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=r||i.width||0,s=a||i.dash||"";l.stroke(e,n||i.color),v.dashLine(e,s,o)},v.lineGroupStyle=function(t,e,r,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,s=a||i.dash||"";n.select(this).call(l.stroke,r||i.color).call(v.dashLine,s,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(l.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){var e=n.select(this);t[0].trace&&e.call(l.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var m=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=n.format("~.1f"),T={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,a,o,s){for(var u=o.length,f=T[a],d=new Array(u),p=0;p=100,e.attr("d",b(u,s))}var f,d,p,h=!1;if(t.so)p=o.outlierwidth,d=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,d="mlc"in t?t.mlcc=n.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?l.defaultLine:o.color,c.isArrayOrTypedArray(i.color)&&(f=l.defaultLine,h=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):i.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(l.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var y=i.gradient,m=t.mgt;if(m?h=!0:m=y&&y.type,Array.isArray(m)&&(m=m[0],T[m]||(m=0)),m&&"none"!==m){var x=t.mgc;x?h=!0:x=y.color;var _=r.uid;h&&(_+="-"+t.i),v.gradient(e,a,_,m,[[0,x],[1,f]],"fill")}else l.fill(e,f);p&&l.stroke(e,d)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=h.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.marker||{},i=r.marker||{},l=n.marker||{},s=a.opacity,u=i.opacity,f=l.opacity,d=void 0!==u,h=void 0!==f;(c.isArrayOrTypedArray(s)||d||h)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?d?u:e:h?f:p*e});var g=a.color,v=i.color,y=l.color;(v||y)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:y||e});var m=a.size,x=i.size,b=l.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||m/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.textfont||{},i=r.textfont||{},o=n.textfont||{},s=a.color,c=i.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||s;return t.selected?c||e:u||(c?e:l.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];r.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&i.push(function(t,e){l.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&i.push(function(t,e){var n=e.mx||a.symbol||0,i=r.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(n),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=n.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var l=t.tp||e.textposition,s=L(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,s,f).text(o).call(u.convertToTspans,r).call(A,l,s,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=n.select(this),i=r.selectedTextColorFn(t),o=t.tp||e.textposition,s=L(t,e);l.fill(a,i),A(a,o,s,t.mrc2||t.mrc)})}};var S=.5;function C(t,e,r,a){var i=t[0]-e[0],o=t[1]-e[1],l=r[0]-e[0],s=r[1]-e[1],c=Math.pow(i*i+o*o,S/2),u=Math.pow(l*l+s*s,S/2),f=(u*u*i-c*c*l)*a,d=(u*u*o-c*c*s)*a,p=3*u*(c+u),h=3*c*(c+u);return[[n.round(e[0]+(p&&f/p),2),n.round(e[1]+(p&&d/p),2)],[n.round(e[0]-(h&&f/h),2),n.round(e[1]-(h&&d/h),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],a=[];for(r=1;r=1e4&&(v.savedBBoxes={},D=0),r&&(v.savedBBoxes[r]=y),D++,c.extendFlat({},y)},v.setClipUrl=function(t,e,r){if(e){var n=r._context,a=n._exportedPlot?"":n._baseUrl||"";t.attr("clip-path","url("+a+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||0,r=r||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+r+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||1,r=r||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+r+")").trim(),t[a]("transform",i),i};var E=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(E,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var R=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,a=n.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),l=parseFloat(i.attr("y")||0),s=(a.attr("transform")||"").match(R);t=1===e&&1===r?[]:["translate("+o+","+l+")","scale("+e+","+r+")","translate("+-o+","+-l+")"],s&&t.push(s),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":141,"../../constants/interactions":142,"../../constants/xmlns_namespaces":144,"../../lib":162,"../../lib/svg_text_utils":183,"../../registry":246,"../../traces/scatter/make_bubble_size_func":333,"../../traces/scatter/subtypes":340,"../color":46,"../colorscale":58,"./symbol_defs":68,d3:11,"fast-isnumeric":13,tinycolor2:29}],68:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+a+i+a+i+o+i+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),a=n.round(-t,2),i=n.round(-.309*t,2);return"M"+e+","+i+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+r+"V"+r+"L0,"+e+"L-"+a+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+a+"H"+r+"L"+e+",0L"+r+",-"+a+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),a=n.round(.951*e,2),i=n.round(.363*e,2),o=n.round(.588*e,2),l=n.round(-e,2),s=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+s+"H"+a+"L"+i+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+i+","+c+"L-"+a+","+s+"H-"+r+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),a=n.round(.76*t,2);return"M-"+a+",0l-"+r+",-"+e+"h"+a+"l"+r+",-"+e+"l"+r+","+e+"h"+a+"l-"+r+","+e+"l"+r+","+e+"h-"+a+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+a+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+a+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:11}],69:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],70:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function l(t,e,r,a){var l=e["error_"+a]||{},s=[];if(l.visible&&-1!==["linear","log"].indexOf(r.type)){for(var c=o(l),u=0;u0;e.each(function(e){var f,d=e[0].trace,p=d.error_x||{},h=d.error_y||{};d.ids&&(f=function(t){return t.id});var g=o.hasMarkers(d)&&d.marker.maxdisplayed>0;h.visible||p.visible||(e=[]);var v=n.select(this).selectAll("g.errorbar").data(e,f);if(v.exit().remove(),e.length){p.visible||v.selectAll("path.xerror").remove(),h.visible||v.selectAll("path.yerror").remove(),v.style("opacity",1);var y=v.enter().append("g").classed("errorbar",!0);u&&y.style("opacity",0).transition().duration(l.duration).style("opacity",1),i.setClipUrl(v,r.layerClipId,t),v.each(function(t){var e=n.select(this),r=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,s,c);if(!g||t.vis){var i,o=e.select("path.yerror");if(h.visible&&a(r.x)&&a(r.yh)&&a(r.ys)){var f=h.width;i="M"+(r.x-f)+","+r.yh+"h"+2*f+"m-"+f+",0V"+r.ys,r.noYS||(i+="m-"+f+",0h"+2*f),!o.size()?o=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):u&&(o=o.transition().duration(l.duration).ease(l.easing)),o.attr("d",i)}else o.remove();var d=e.select("path.xerror");if(p.visible&&a(r.y)&&a(r.xh)&&a(r.xs)){var v=(p.copy_ystyle?h:p).width;i="M"+r.xh+","+(r.y-v)+"v"+2*v+"m0,-"+v+"H"+r.xs,r.noXS||(i+="m0,-"+v+"v"+2*v),!d.size()?d=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):u&&(d=d.transition().duration(l.duration).ease(l.easing)),d.attr("d",i)}else d.remove()}})}})}},{"../../traces/scatter/subtypes":340,"../drawing":67,d3:11,"fast-isnumeric":13}],75:[function(t,e,r){"use strict";var n=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},i=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(a.stroke,r.color),i.copy_ystyle&&(i=r),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":46,d3:11}],76:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":233}],77:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry");function i(t,e,r,a){a=a||n.identity,Array.isArray(t)&&(e[0][r]=a(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var l=0;l=0&&r.indexw[0]._length||et<0||et>k[0]._length)return d.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,R="xval"in e?g.flat(s,e.xval):g.p2c(w,tt),N="yval"in e?g.flat(s,e.yval):g.p2c(k,et),!a(R[0])||!a(N[0]))return o.warn("Fx.hover failed",e,t),d.unhoverRaw(t,e)}var at=1/0;for(F=0;F<$.length;F++)if((B=$[F])&&B[0]&&B[0].trace&&!0===B[0].trace.visible&&(j=B[0].trace,-1===["carpet","contourcarpet"].indexOf(j._module.name))){if("splom"===j.type?H=s[q=0]:(H=g.getSubplot(j),q=s.indexOf(H)),V=E,Y={cd:B,trace:j,xa:w[q],ya:k[q],maxHoverDistance:Z,maxSpikeDistance:W,index:!1,distance:Math.min(at,Z),spikeDistance:1/0,xSpike:void 0,ySpike:void 0,color:f.defaultLine,name:j.name,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},u[H]&&(Y.subplot=u[H]._subplot),u._splomScenes&&u._splomScenes[j.uid]&&(Y.scene=u._splomScenes[j.uid]),X=J.length,"array"===V){var it=e[F];"pointNumber"in it?(Y.index=it.pointNumber,V="closest"):(V="","xval"in it&&(U=it.xval,V="x"),"yval"in it&&(G=it.yval,V=V?"closest":"y"))}else U=R[q],G=N[q];if(0!==Z)if(j._module&&j._module.hoverPoints){var ot=j._module.hoverPoints(Y,U,G,V,u._hoverlayer);if(ot)for(var lt,st=0;stX&&(J.splice(0,X),at=J[0].distance),m&&0!==W&&0===J.length){Y.distance=W,Y.index=!1;var ct=j._module.hoverPoints(Y,U,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=W})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var dt=ft[0];a(dt.x0)&&a(dt.y0)&&(ut=vt(dt),(!Q.vLinePoint||Q.vLinePoint.spikeDistance>ut.spikeDistance)&&(Q.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var ht=pt[0];a(ht.x0)&&a(ht.y0)&&(ut=vt(ht),(!Q.hLinePoint||Q.hLinePoint.spikeDistance>ut.spikeDistance)&&(Q.hLinePoint=ut))}}}}function gt(t,e){for(var r,n=null,a=1/0,i=0;i1||J.length>1)||"closest"===E&&K&&J.length>1,Pt=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),Dt={hovermode:E,rotateLabels:Ot,bgColor:Pt,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},zt=M(J,Dt,t);if(function(t,e,r){var n,a,i,o,l,s,c,u=0,f=1,d=t.map(function(t,n){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!n&&o&&o[0]>o[1]!==i&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?x:1)/2,pmin:0,pmax:i?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],r=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=r.pos+r.dp+r.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;n=!1}if(!(i<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=i;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos>e.pmax-1&&(s.del=!0,c--);for(o=0;o=0;l--)t[l].dp-=i;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(;!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&v.pmin===y.pmin&&v.pmax===y.pmax){for(l=g.length-1;l>=0;l--)g[l].dp+=a;for(h.push.apply(h,g),d.splice(o+1,1),c=0,l=h.length-1;l>=0;l--)c+=h[l].dp;for(i=c/h.length,l=h.length-1;l>=0;l--)h[l].dp-=i;n=!1}else o++}d.forEach(p)}for(o=d.length-1;o>=0;o--){var m=d[o];for(l=m.length-1;l>=0;l--){var b=m[l],_=t[b.i];_.offset=b.dp,_.del=b.del}}}(J,Ot?"xa":"ya",u),A(zt,Ot),e.target&&e.target.tagName){var Et=h.getComponentMethod("annotations","hasClickToShow")(t,At);c(n.select(e.target),Et?"pointer":"")}if(!e.target||i||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var a=r[n],i=t._hoverdata[n];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber)||String(a.pointNumbers)!==String(i.pointNumbers))return!0}return!1}(t,0,Mt))return;Mt&&t.emit("plotly_unhover",{event:e,points:Mt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:R,yvals:N})}(t,e,r,i)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1},a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M([r],o,e.gd);return A(l,o.rotateLabels),l.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1}}),a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M(r,o,e.gd),s=0;return l.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5([\s\S]*)<\/extra>/;function M(t,e,r){var a=e.hovermode,i=e.rotateLabels,l=e.bgColor,c=e.container,d=e.outerContainer,p=e.commonLabelOpts||{},h=e.fontFamily||v.HOVERFONT,g=e.fontSize||v.HOVERFONTSIZE,m=t[0],x=m.xa,b=m.ya,_="y"===a?"yLabel":"xLabel",M=m[_],A=(String(M)||"").split(" ")[0],L=d.node().getBoundingClientRect(),S=L.top,C=L.width,O=L.height,P=void 0!==M&&m.distance<=e.hoverdistance&&("x"===a||"y"===a);if(P){var D,z,E=!0;for(D=0;D-1&&c.length>b&&(c=b>3?c.substr(0,b-3)+"...":c.substr(0,b))}void 0!==t.zLabel?(void 0!==t.xLabel&&(d+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(d+="y: "+t.yLabel+"
"),d+=(d?"z: ":"")+t.zLabel):P&&t[a+"Label"]===M?d=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(d=t.yLabel):d=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(d+=(d?"
":"")+t.text),void 0!==t.extraText&&(d+=(d?"
":"")+t.extraText),""===d&&(""===c&&e.remove(),d=c);var _=t.hovertemplate||!1,A=t.hovertemplateLabels||t,L=t.eventData[0]||{};_&&(d=(d=o.hovertemplateString(_,A,L)).replace(T,function(t,e){return c=e,""}));var D=e.select("text.nums").call(u.font,t.fontFamily||h,t.fontSize||g,t.fontColor||x).text(d).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),z=e.select("text.name"),E=0;c&&c!==d?(z.call(u.font,t.fontFamily||h,t.fontSize||g,m).text(c).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,r),E=z.node().getBoundingClientRect().width+2*k):(z.remove(),e.select("rect").remove()),e.select("path").style({fill:v,stroke:x});var R,N,I=D.node().getBoundingClientRect(),F=t.xa._offset+(t.x0+t.x1)/2,B=t.ya._offset+(t.y0+t.y1)/2,j=Math.abs(t.x1-t.x0),H=Math.abs(t.y1-t.y0),q=I.width+w+k+E;t.ty0=S-I.top,t.bx=I.width+2*k,t.by=I.height+2*k,t.anchor="start",t.txwidth=I.width,t.tx2width=E,t.offset=0,i?(t.pos=F,R=B+H/2+q<=O,N=B-H/2-q>=0,"top"!==t.idealAlign&&R||!N?R?(B+=H/2,t.anchor="start"):t.anchor="middle":(B-=H/2,t.anchor="end")):(t.pos=B,R=F+j/2+q<=C,N=F-j/2-q>=0,"left"!==t.idealAlign&&R||!N?R?(F+=j/2,t.anchor="start"):t.anchor="middle":(F-=j/2,t.anchor="end")),D.attr("text-anchor",t.anchor),E&&z.attr("text-anchor",t.anchor),e.attr("transform","translate("+F+","+B+")"+(i?"rotate("+y+")":""))}),I}function A(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var a="end"===t.anchor?-1:1,i=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],l=o*(w+k),c=l+o*(t.txwidth+k),f=0,d=t.offset;"middle"===t.anchor&&(l-=t.tx2width/2,c+=t.txwidth/2+k),e&&(d*=-_,f=t.offset*b),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(d-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+d)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(d-w)+"Z"),i.call(s.positionText,l+f,d+t.ty0-t.by/2+k),t.tx2width&&(r.select("text.name").call(s.positionText,c+o*k+f,d+t.ty0-t.by/2+k),r.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,d-t.by/2-1,t.tx2width,t.by+2))}})}function L(t,e){var r=t.index,n=t.trace||{},a=t.cd[0],i=t.cd[r]||{},l=Array.isArray(r)?function(t,e){return o.castOption(a,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(i,n,t,e)};function s(e,r,n){var a=l(r,n);a&&(t[e]=a)}if(s("hoverinfo","hi","hoverinfo"),s("bgcolor","hbg","hoverlabel.bgcolor"),s("borderColor","hbc","hoverlabel.bordercolor"),s("fontFamily","htf","hoverlabel.font.family"),s("fontSize","hts","hoverlabel.font.size"),s("fontColor","htc","hoverlabel.font.color"),s("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return f&&"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function S(t,e){var r,n,a=e.container,o=e.fullLayout,l=e.event,s=!!t.hLinePoint,c=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),c||s){var d=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(s){var p,h,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(p=l.pointerX,h=l.pointerY):(p=r._offset+g.x,h=n._offset+g.y);var v,y,m=i.readability(g.color,d)<1.5?f.contrast(d):g.color,x=n.spikemode,b=n.spikethickness,_=n.spikecolor||m,w=n._boundingBox,k=(w.left+w.right)/20){for(var n=[],a=0;a-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){d||p||h||"independent"===T("pattern")&&(d=!0),v._hasSubplotGrid=d;var x,b,_="top to bottom"===T("roworder"),w=d?.2:.1,k=d?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",T,w,x,m),y:u("y",T,k,b,y,_)}}else delete e.grid}function T(t,e){return n.coerce(r,v,s,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,a,i,o,l,s,u,d=t.grid||{},p=e._subplots,h=r._hasSubplotGrid,g=r.rows,v=r.columns,y="independent"===r.pattern,m=r._axisMap={};if(h){var x=d.subplots||[];s=r.subplots=new Array(g);var b=1;for(n=0;n1);if(!1!==x||p.uirevision){var b=i.newContainer(e,"legend");if(w("uirevision",e.uirevision),!1!==x){if(w("bgcolor",e.paper_bgcolor),w("bordercolor"),w("borderwidth"),a.coerceFont(w,"font",e.font),w("orientation"),"h"===b.orientation){var _=t.xaxis;n.getComponentMethod("rangeslider","isVisible")(_)?(c=0,f="left",u=1.1,d="bottom"):(c=0,f="left",u=-.1,d="top")}w("traceorder",v),s.isGrouped(e.legend)&&w("tracegroupgap"),w("x",c),w("xanchor",f),w("y",u),w("yanchor",d),w("valign"),a.noneOrAll(p,b,["x","y"])}}function w(t,e){return a.coerce(p,b,o,t,e)}}},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/layout_attributes":237,"../../registry":246,"./attributes":95,"./helpers":101}],98:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib/events"),s=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),d=t("./handle_click"),p=t("./constants"),h=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,y=g.FROM_TL,m=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=h.DBLCLICKDELAY;function k(t,e,r,n,a){var i=r.data()[0][0].trace,o={event:a,node:r.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=r.datum()[0].label),!1!==l.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){d(r,t,n)},w);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==l.triggerHandler(t,"plotly_legenddoubleclick",o)&&d(r,t,n)}}function T(t,e,r){var n=t.data()[0][0],i=e._fullLayout,l=n.trace,s=o.traceIs(l,"pie"),u=l.index,d=s?n.label:l.name,h=e._context.edits.legendText&&!s,g=a.ensureSingle(t,"text","legendtext");function y(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,a,i=t.select("g[class*=math-group]"),o=i.node(),l=e._fullLayout.legend.font.size*v;if(o){var s=c.bBox(o);n=s.height,a=s.width,c.setTranslate(i,0,n/4)}else{var u=t.select(".legendtext"),d=f.lineCount(u),h=u.node();n=l*d,a=h?c.bBox(h).width:0;var g=l*(.3+(1-d)/2);f.positionText(u,p.textOffsetX,g),r.lineHeight=l}n=Math.max(n,16)+3,r.height=n,r.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,i.legend.font).text(h?M(d,r):d),f.positionText(g,p.textOffsetX,0),h?g.call(f.makeEditable,{gd:e,text:d}).call(y).on("edit",function(t){this.text(M(t,r)).call(y);var i=n.trace._fullInput||{},l={};if(o.hasTransform(i,"groupby")){var s=o.getTransformIndices(i,"groupby"),c=s[s.length-1],f=a.keyedContainer(i,"transforms["+c+"].styles","target","value.name");f.set(n.trace._group,t),l=f.constructUpdate()}else l.name=t;return o.call("_guiRestyle",e,l,u)}):y(g)}function M(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function A(t,e){var r,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimew&&(i=Math.max(i-1,1)),k(e,r,t,i,n.event)}})}function L(t,e,r){var a=t._fullLayout,i=a.legend,o=i.borderwidth,l=_.isGrouped(i),s=0;if(i._width=0,i._height=0,_.isVertical(i))l&&e.each(function(t,e){c.setTranslate(this,0,e*i.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;c.setTranslate(this,o,5+o+i._height+r/2),i._height+=r,i._width=Math.max(i._width,n)}),i._width+=45+2*o,i._height+=10+2*o,l&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),s=40;else if(l){for(var u=[i._width],f=e.data(),d=0,p=f.length;do+w-k,r.each(function(t){var e=t[0],r=v?40+t[0].width:x;o+b+k+r>a._size.w&&(b=0,y+=m,i._height=i._height+m,m=0),c.setTranslate(this,o+b,5+o+e.height/2+y),i._width+=k+r,i._height=Math.max(i._height,e.height),b+=k+r,m=Math.max(e.height,m)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var T=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");c.setRect(r,0,-e.height/2,(T?0:i._width)+s,e.height)})}function S(t){var e=t._fullLayout.legend,r="left";a.isRightAnchor(e)?r="right":a.isCenterAnchor(e)&&(r="center");var n="top";a.isBottomAnchor(e)?n="bottom":a.isMiddleAnchor(e)&&(n="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[r],r:e._width*m[r],b:e._height*m[n],t:e._height*y[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var l=e.legend,f=e.showlegend&&x(t.calcdata,l),d=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void i.autoMargin(t,"legend");for(var h=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";a.isRightAnchor(e)?r="right":a.isCenterAnchor(e)&&(r="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[r],r:e._width*m[r],b:0,t:0})}(t):S(t);var d=e._size,h=d.l+d.w*l.x,g=d.t+d.h*(1-l.y);a.isRightAnchor(l)?h-=l._width:a.isCenterAnchor(l)&&(h-=l._width/2),a.isBottomAnchor(l)?g-=l._height:a.isMiddleAnchor(l)&&(g-=l._height/2);var v=l._width,x=d.w;v>x?(h=d.l,v=x):(h+v>u&&(h=u-v),h<0&&(h=0),v=Math.min(u-h,l._width));var b,_,w,T,M=l._height,A=d.h;if(M>A?(g=d.t,M=A):(g+M>f&&(g=f-M),g<0&&(g=0),M=Math.min(f-g,l._height)),c.setTranslate(O,h,g),E.on(".drag",null),O.on("wheel",null),l._height<=M||t._context.staticPlot)D.attr({width:v-l.borderwidth,height:M-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),c.setTranslate(z,0,0),P.select("rect").attr({width:v-2*l.borderwidth,height:M-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth}),c.setClipUrl(z,r,t),c.setRect(E,0,0,0,0),delete l._scrollY;else{var I,F,B=Math.max(p.scrollBarMinHeight,M*M/l._height),j=M-B-2*p.scrollBarMargin,H=l._height-M,q=j/H,V=Math.min(l._scrollY||0,H);D.attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:M-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),P.select("rect").attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:M-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth+V}),c.setClipUrl(z,r,t),G(V,B,q),O.on("wheel",function(){G(V=a.constrain(l._scrollY+n.event.deltaY/j*H,0,H),B,q),0!==V&&V!==H&&n.event.preventDefault()});var U=n.behavior.drag().on("dragstart",function(){I=n.event.sourceEvent.clientY,F=V}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||G(V=a.constrain((t.clientY-I)/q+F,0,H),B,q)});E.call(U)}function G(e,r,n){l._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(z,0,-e),c.setRect(E,v,p.scrollBarMargin+e*n,p.scrollBarWidth,r),P.select("rect").attr({y:l.borderwidth+e})}t._context.edits.legendPosition&&(O.classed("cursor-move",!0),s.init({element:O.node(),gd:t,prepFn:function(){var t=c.getTranslate(O);w=t.x,T=t.y},moveFn:function(t,e){var r=w+t,n=T+e;c.setTranslate(O,r,n),b=s.align(r,0,d.l,d.l+d.w,l.xanchor),_=s.align(n,0,d.t+d.h,d.t,l.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("_guiRelayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(r,n){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});a.size()>0&&k(t,O,a,r,n)}}))}],t)}}},{"../../constants/alignment":141,"../../constants/interactions":142,"../../lib":162,"../../lib/events":155,"../../lib/svg_text_utils":183,"../../plots/plots":239,"../../registry":246,"../color":46,"../dragelement":64,"../drawing":67,"./constants":96,"./get_legend_data":99,"./handle_click":100,"./helpers":101,"./style":103,d3:11}],99:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var r,i,o={},l=[],s=!1,c={},u=0;function f(t,r){if(""!==t&&a.isGrouped(e))-1===l.indexOf(t)?(l.push(t),s=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+u;l.push(n),o[n]=[[r]],u++}}for(r=0;rr[1])return r[1]}return a}function h(t){return t[0]}if(u||f||d){var g={},v={};if(u){g.mc=p("marker.color",h),g.mx=p("marker.symbol",h),g.mo=p("marker.opacity",i.mean,[.2,1]),g.mlc=p("marker.line.color",h),g.mlw=p("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=p("marker.size",i.mean,[2,16]);g.ms=y,v.marker.size=y}d&&(v.line={width:p("line.width",h,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",h),g.ts=10,g.tc=p("textfont.color",h),g.tf=p("textfont.family",h)),r=[i.minExtend(l,g)],(a=i.minExtend(c,v)).selectedpoints=null}var m=n.select(this).select("g.legendpoints"),x=m.selectAll("path.scatterpts").data(u?r:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,a,e),u&&(r[0].mrc=3);var b=m.selectAll("g.pointtext").data(f?r:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,o=n.select(this);o.style("stroke-width",i+"px").call(l.fill,a.fillcolor),i&&l.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,s=n.select(this);s.style("fill","none").call(o.dashLine,a.line.dash,i),i&&l.stroke(s,a.line.color)})})}},{"../../lib":162,"../../registry":246,"../../traces/pie/style_one":314,"../../traces/scatter/subtypes":340,"../color":46,"../drawing":67,d3:11}],104:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),l=t("../../../build/ploticon"),s=o._,c=e.exports={};function u(t,e){var r,a,o=e.currentTarget,l=o.getAttribute("data-attr"),s=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=i.list(t,null,!0),d="on";if("zoom"===l){var p,h="in"===s?.5:2,g=(1+h)/2,v=(1-h)/2;for(a=0;a1?(k=["toggleHover"],T=["resetViews"]):d?(w=["zoomInGeo","zoomOutGeo"],k=["hoverClosestGeo"],T=["resetGeo"]):f?(k=["hoverClosest3d"],T=["resetCameraDefault3d","resetCameraLastSave3d"]):v?(k=["toggleHover"],T=["resetViewMapbox"]):k=h?["hoverClosestGl2d"]:p?["hoverClosestPie"]:["toggleHover"];u&&(k=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!u&&!h||m||(w=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==T[0]&&(T=["resetScale2d"]));f?M=["zoom3d","pan3d","orbitRotation","tableRotation"]:(u||h)&&!m||g?M=["zoom2d","pan2d"]:v||d?M=["pan2d"]:y&&(M=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),a=0,i=0;i0?d+c:c;return{ppad:c,ppadplus:u?h:g,ppadminus:u?g:h}}return{ppad:c}}function u(t,e,r,n,a){var l="category"===t.type||"multicategory"===t.type?t.r2c:t.d2c;if(void 0!==e)return[l(e),l(r)];if(n){var s,c,u,f,d=1/0,p=-1/0,h=n.match(i.segmentRE);for("date"===t.type&&(l=o.decodeDate(l)),s=0;sp&&(p=f)));return p>=d?[d,p]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:R?V(r.xanchor)+r.x0:V(r.x0),cy:N?U(r.yanchor)-r.y0:U(r.y0),r:i}).style(a).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:R?V(r.xanchor)+r.x1:V(r.x1),cy:N?U(r.yanchor)-r.y1:U(r.y1),r:i}).style(a).classed("cursor-grab",!0),n}():e,Z={element:X.node(),gd:t,prepFn:function(n){R&&(_=V(r.xanchor));N&&(w=U(r.yanchor));"path"===r.type?P=r.path:(y=R?r.x0:V(r.x0),m=N?r.y0:U(r.y0),x=R?r.x1:V(r.x1),b=N?r.y1:U(r.y1));yb?(k=m,L="y0",T=b,S="y1"):(k=b,L="y1",T=m,S="y0");W(n),Q(p,r),function(t,e,r){var n=e.xref,a=e.yref,o=i.getFromId(r,n),s=i.getFromId(r,a),c="";"paper"===n||o.autorange||(c+=n);"paper"===a||s.autorange||(c+=a);l.setClipUrl(t,c?"clip"+r._fullLayout._uid+c:null,r)}(e,r,t),Z.moveFn="move"===D?J:$},doneFn:function(){u(e),K(p),h(e,t,r),n.call("_guiRelayout",t,B.getUpdateObj())},clickFn:function(){K(p)}};function W(t){if(I)D="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Z.element.getBoundingClientRect(),n=r.right-r.left,a=r.bottom-r.top,i=t.clientX-r.left,o=t.clientY-r.top,l=!F&&n>z&&a>E&&!t.shiftKey?c.getCursor(i/n,1-o/a):"move";u(e,l),D=l.split("-")[0]}}function J(n,a){if("path"===r.type){var i=function(t){return t},o=i,l=i;R?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?j("yanchor",r.yanchor=Y(w+a)):(l=function(t){return Y(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(P,o,l))}else R?j("xanchor",r.xanchor=G(_+n)):(j("x0",r.x0=G(y+n)),j("x1",r.x1=G(x+n))),N?j("yanchor",r.yanchor=Y(w+a)):(j("y0",r.y0=Y(m+a)),j("y1",r.y1=Y(b+a)));e.attr("d",g(t,r)),Q(p,r)}function $(n,a){if(F){var i=function(t){return t},o=i,l=i;R?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?j("yanchor",r.yanchor=Y(w+a)):(l=function(t){return Y(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),j("path",r.path=v(P,o,l))}else if(I){if("resize-over-start-point"===D){var s=y+n,c=N?m-a:m+a;j("x0",r.x0=R?s:G(s)),j("y0",r.y0=N?c:Y(c))}else if("resize-over-end-point"===D){var u=x+n,f=N?b-a:b+a;j("x1",r.x1=R?u:G(u)),j("y1",r.y1=N?f:Y(f))}}else{var h=~D.indexOf("n")?k+a:k,B=~D.indexOf("s")?T+a:T,X=~D.indexOf("w")?M+n:M,Z=~D.indexOf("e")?A+n:A;~D.indexOf("n")&&N&&(h=k-a),~D.indexOf("s")&&N&&(B=T-a),(!N&&B-h>E||N&&h-B>E)&&(j(L,r[L]=N?h:Y(h)),j(S,r[S]=N?B:Y(B))),Z-X>z&&(j(C,r[C]=R?X:G(X)),j(O,r[O]=R?Z:G(Z)))}e.attr("d",g(t,r)),Q(p,r)}function Q(t,e){(R||N)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=V(R?e.xanchor:a.midRange(r?[e.x0,e.x1]:d.extractPathCoords(e.path,f.paramIsX))),o=U(N?e.yanchor:a.midRange(r?[e.y0,e.y1]:d.extractPathCoords(e.path,f.paramIsY)));if(i=d.roundPositionForSharpStrokeRendering(i,1),o=d.roundPositionForSharpStrokeRendering(o,1),R&&N){var l="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",l)}else if(R){var s="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",s)}else{var c="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",c)}}()}function K(t){t.selectAll(".visual-cue").remove()}c.init(Z),X.node().onmousemove=W}(t,x,r,e,p)}}function h(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");l.setClipUrl(t,n?"clip"+e._fullLayout._uid+n:null,e)}function g(t,e){var r,n,o,l,s,c,u,p,h=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),y=t._fullLayout._size;if(g?(r=d.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return y.l+y.w*t},v?(o=d.shapePositionToRange(v),l=function(t){return v._offset+v.r2p(o(t,!0))}):l=function(t){return y.t+y.h*(1-t)},"path"===h)return g&&"date"===g.type&&(n=d.decodeDate(n)),v&&"date"===v.type&&(l=d.decodeDate(l)),function(t,e,r){var n=t.path,i=t.xsizemode,o=t.ysizemode,l=t.xanchor,s=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,c=t.charAt(0),u=f.paramIsX[c],d=f.paramIsY[c],p=f.numParams[c],h=t.substr(1).replace(f.paramRE,function(t){return u[n]?t="pixel"===i?e(l)+Number(t):e(t):d[n]&&(t="pixel"===o?r(s)-Number(t):r(t)),++n>p&&(t="X"),t});return n>p&&(h=h.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),c+h})}(e,n,l);if("pixel"===e.xsizemode){var m=n(e.xanchor);s=m+e.x0,c=m+e.x1}else s=n(e.x0),c=n(e.x1);if("pixel"===e.ysizemode){var x=l(e.yanchor);u=x-e.y0,p=x-e.y1}else u=l(e.y0),p=l(e.y1);if("line"===h)return"M"+s+","+u+"L"+c+","+p;if("rect"===h)return"M"+s+","+u+"H"+c+"V"+p+"H"+s+"Z";var b=(s+c)/2,_=(u+p)/2,w=Math.abs(b-s),k=Math.abs(_-u),T="A"+w+","+k,M=b+w+","+_;return"M"+M+T+" 0 1,1 "+(b+","+(_-k))+T+" 0 0,1 "+M+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],l=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return n>=l?t:(i[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var a=0;a0&&(l=l.transition().duration(e.transition.duration).ease(e.transition.easing)),l.attr("transform","translate("+(o-.5*u.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function L(t,e){var r=t._dims;return r.inputAreaStart+u.stepInset+(r.inputAreaLength-2*u.stepInset)*Math.min(1,Math.max(0,e))}function S(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-u.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*u.stepInset-2*r.inputAreaStart)))}function C(t,e,r){var n=r._dims,a=l.ensureSingle(t,"rect",u.railTouchRectClass,function(n){n.call(T,e,t,r).style("pointer-events","all")});a.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,u.tickOffset+r.ticklen+n.labelHeight)}).call(i.fill,r.bgcolor).attr("opacity",0),o.setTranslate(a,0,n.currentValueTotalHeight)}function O(t,e){var r=e._dims,n=r.inputAreaLength-2*u.railInset,a=l.ensureSingle(t,"rect",u.railRectClass);a.attr({width:n,height:u.railWidth,rx:u.railRadius,ry:u.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,u.railInset,.5*(r.inputAreaWidth-u.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[u.name],n=[],a=0;a0?[0]:[]);function l(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,g(e))}if(i.enter().append("g").classed(u.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){n.select(this).selectAll("g."+u.groupClassName).each(l)}).remove(),0!==r.length){var s=i.selectAll("g."+u.groupClassName).data(r,v);s.enter().append("g").classed(u.groupClassName,!0),s.exit().each(l).remove();for(var c=0;c0||d<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[m.side];e.attr("transform","translate("+g+")")}}}z.call(E),P&&(A?z.on(".opacity",null):(k=0,T=!0,z.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),z.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("_guiRestyle",t,g,e,y):o.call("_guiRelayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(E)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return z.classed("js-placeholder",T),_}};var d=/ [XY][0-9]* /},{"../../constants/interactions":142,"../../lib":162,"../../lib/svg_text_utils":183,"../../plots/plots":239,"../../registry":246,"../color":46,"../drawing":67,d3:11,"fast-isnumeric":13}],135:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,l=t("../../plots/pad_attributes"),s=t("../../plot_api/plot_template").templatedArray,c=s("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(s("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i(l({editType:"arraydraw"}),{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":156,"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../../plots/font_attributes":233,"../../plots/pad_attributes":238,"../color/attributes":45}],136:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],137:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,l=i.buttons;function s(t,e,r){function o(r,a){return n.coerce(t,e,i,r,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function r(r,a){return n.coerce(t,e,l,r,a)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:s})}},{"../../lib":162,"../../plots/array_container_defaults":202,"./attributes":135,"./constants":136}],138:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../plot_api/plot_template").arrayEditor,u=t("../../constants/alignment").LINE_SPACING,f=t("./constants"),d=t("./scrollbox");function p(t){return t._index}function h(t,e){return+t.attr(f.menuIndexAttrName)===e._index}function g(t,e,r,n,a,i,o,l){e.active=o,c(t.layout,f.name,e).applyUpdate("active",o),"buttons"===e.type?y(t,n,null,null,e):"dropdown"===e.type&&(a.attr(f.menuIndexAttrName,"-1"),v(t,n,a,i,e),l||y(t,n,a,i,e))}function v(t,e,r,n,a){var i=l.ensureSingle(e,"g",f.headerClassName,function(t){t.style("pointer-events","all")}),s=a._dims,c=a.active,u=a.buttons[c]||f.blankHeaderOpts,d={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},p={width:s.headerWidth,height:s.headerHeight};i.call(m,a,u,t).call(A,a,d,p),l.ensureSingle(e,"text",f.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(f.arrowSymbol[a.direction])}).attr({x:s.headerWidth-f.arrowOffsetX+a.pad.l,y:s.headerHeight/2+f.textOffsetY+a.pad.t}),i.on("click",function(){r.call(L,String(h(r,a)?-1:a._index)),y(t,e,r,n,a)}),i.on("mouseover",function(){i.call(w)}),i.on("mouseout",function(){i.call(k,a)}),o.setTranslate(e,s.lx,s.ly)}function y(t,e,r,i,o){r||(r=e).attr("pointer-events","all");var s=function(t){return-1==+t.attr(f.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?f.dropdownButtonClassName:f.buttonClassName,u=r.selectAll("g."+c).data(l.filterVisible(s)),d=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(d.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var h=0,v=0,y=o._dims,x=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(x?v=y.headerHeight+f.gapButtonHeader:h=y.headerWidth+f.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(v=-f.gapButtonHeader+f.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(h=-f.gapButtonHeader+f.gapButton-y.openWidth);var b={x:y.lx+h+o.pad.l,y:y.ly+v+o.pad.t,yPad:f.gapButton,xPad:f.gapButton,index:0},T={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(l,s){var c=n.select(this);c.call(m,o,l,t).call(A,o,b),c.on("click",function(){n.event.defaultPrevented||(g(t,o,0,e,r,i,s),l.execute&&a.executeAPICommand(t,l.method,l.args),t.emit("plotly_buttonclicked",{menu:o,button:l,active:o.active}))}),c.on("mouseover",function(){c.call(w)}),c.on("mouseout",function(){c.call(k,o),u.call(_,o)})}),u.call(_,o),x?(T.w=Math.max(y.openWidth,y.headerWidth),T.h=b.y-T.t):(T.w=b.x-T.l,T.h=Math.max(y.openHeight,y.headerHeight)),T.direction=o.direction,i&&(u.size()?function(t,e,r,n,a,i){var o,l,s,c=a.direction,u="up"===c||"down"===c,d=a._dims,p=a.active;if(u)for(l=0,s=0;s0?[0]:[]);if(o.enter().append("g").classed(f.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+f.headerGroupClassName).each(i)}).remove(),0!==r.length){var s=o.selectAll("g."+f.headerGroupClassName).data(r,p);s.enter().append("g").classed(f.headerGroupClassName,!0);for(var c=l.ensureSingle(o,"g",f.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,M=l.barLength+2*l.barPad,A=l.barWidth+2*l.barPad,L=h,S=v+y;S+A>c&&(S=c-A);var C=this.container.selectAll("rect.scrollbar-horizontal").data(T?[0]:[]);C.exit().on(".drag",null).remove(),C.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,l.barColor),T?(this.hbar=C.attr({rx:l.barRadius,ry:l.barRadius,x:L,y:S,width:M,height:A}),this._hbarXMin=L+M/2,this._hbarTranslateMax=w-M):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var O=y>k,P=l.barWidth+2*l.barPad,D=l.barLength+2*l.barPad,z=h+g,E=v;z+P>s&&(z=s-P);var R=this.container.selectAll("rect.scrollbar-vertical").data(O?[0]:[]);R.exit().on(".drag",null).remove(),R.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,l.barColor),O?(this.vbar=R.attr({rx:l.barRadius,ry:l.barRadius,x:z,y:E,width:P,height:D}),this._vbarYMin=E+D/2,this._vbarTranslateMax=k-D):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var N=this.id,I=u-.5,F=O?f+P+.5:f+.5,B=d-.5,j=T?p+A+.5:p+.5,H=o._topdefs.selectAll("#"+N).data(T||O?[0]:[]);if(H.exit().remove(),H.enter().append("clipPath").attr("id",N).append("rect"),T||O?(this._clipRect=H.select("rect").attr({x:Math.floor(I),y:Math.floor(B),width:Math.ceil(F)-Math.floor(I),height:Math.ceil(j)-Math.floor(B)}),this.container.call(i.setClipUrl,N,this.gd),this.bg.attr({x:h,y:v,width:g,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),T||O){var q=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));T&&this.hbar.on(".drag",null).call(V),O&&this.vbar.on(".drag",null).call(V)}this.setTranslate(e,r)},l.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},l.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},l.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},l.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,a=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,a)-r)/(a-r)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,l=i+this._vbarTranslateMax;e=(o.constrain(n.event.y,i,l)-i)/(l-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},l.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/r;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var l=e/n;this.vbar.call(i.setTranslate,t,e+l*this._vbarTranslateMax)}}},{"../../lib":162,"../color":46,"../drawing":67,d3:11}],141:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,CAP_SHIFT:.7,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],142:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],143:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],144:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],145:[function(t,e,r){"use strict";r.version="1.43.0",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config")();for(var n=t("./registry"),a=r.register=n.register,i=t("./plot_api"),o=Object.keys(i),l=0;l1/3&&t.x<2/3},r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isTopAnchor=function(t){return"top"===t.yanchor||"auto"===t.yanchor&&t.y>=2/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3}},{}],148:[function(t,e,r){"use strict";var n=t("./mod"),a=n.mod,i=n.modHalf,o=Math.PI,l=2*o;function s(t){return Math.abs(t[1]-t[0])>l-1e-15}function c(t,e){return i(e-t,l)}function u(t,e){if(s(e))return!0;var r,n;e[0](n=a(n,l))&&(n+=l);var i=a(t,l),o=i+l;return i>=r&&i<=n||o>=r&&o<=n}function f(t,e,r,n,a,i,c){a=a||0,i=i||0;var u,f,d,p,h,g=s([r,n]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(u=0,f=o,d=l):r=a&&t<=i);var a,i},pathArc:function(t,e,r,n,a){return f(null,t,e,r,n,a,0)},pathSector:function(t,e,r,n,a){return f(null,t,e,r,n,a,1)},pathAnnulus:function(t,e,r,n,a,i){return f(t,e,r,n,a,i,1)}}},{"./mod":169}],149:[function(t,e,r){"use strict";var n=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function l(t){return n(t)||o(t)}function s(t,e,r){if(l(t)){if(l(t[0])){for(var n=r,a=0;aa.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,a){t%1||!n(t)||void 0!==a.min&&ta.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var a="number"==typeof t;!0!==n.strict&&a?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){a(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o.get(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(u(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var a=n.regex||c(r);"string"==typeof t&&a.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!c(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=n&&t<=a?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),y=t.charAt(0);!c||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:m);if(!k)return u;var T=k[1],M=k[3]||"1",A=Number(k[5]||1),L=Number(k[7]||0),S=Number(k[9]||0),C=Number(k[11]||0);if(c){if(2===T.length)return u;var O;T=Number(T);try{var P=v.getComponentMethod("calendars","getCal")(e);if(w){var D="i"===M.charAt(M.length-1);M=parseInt(M,10),O=P.newDate(T,P.toMonthIndex(T,M,D),A)}else O=P.newDate(T,Number(M),A)}catch(t){return u}return O?(O.toJD()-g)*f+L*d+S*p+C*h:u}T=2===T.length?(Number(T)+2e3-b)%100+b:Number(T),M-=1;var z=new Date(Date.UTC(2e3,M,A,L,S));return z.setUTCFullYear(T),z.getUTCMonth()!==M?u:z.getUTCDate()!==A?u:z.getTime()+C*h},n=r.MIN_MS=r.dateTime2ms("-9999"),a=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==u};var k=90*f,T=3*d,M=5*p;function A(t,e,r,n,a){if((e||r||n||a)&&(t+=" "+w(e,2)+":"+w(r,2),(n||a)&&(t+=":"+w(n,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=a))return u;e||(e=0);var i,o,l,c,m,x,b=Math.floor(10*s(t+.05,1)),w=Math.round(t-b/10);if(_(r)){var L=Math.floor(w/f)+g,S=Math.floor(s(t,f));try{i=v.getComponentMethod("calendars","getCal")(r).fromJD(L).formatDate("yyyy-mm-dd")}catch(t){i=y("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=n+f&&t<=a-f))return u;var e=Math.floor(10*s(t+.05,1)),r=new Date(Math.round(t-e/10));return A(i.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===u)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return l.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return l.error("unrecognized date",t),e;return t};var L=/%\d?f/g;function S(t,e,r,n){t=t.replace(L,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(a)}var C=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,a,i){if(a=_(a)&&a,!e)if("y"===r)e=i.year;else if("m"===r)e=i.month;else{if("d"!==r)return function(t,e){var r=s(t+.05,f),n=w(Math.floor(r/d),2)+":"+w(s(Math.floor(r/p),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(s(t/h,60),C[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+a}return n}(t,r)+"\n"+S(i.dayMonthYear,t,n,a);e=i.dayMonth+"\n"+i.year}return S(e,t,n,a)};var O=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=s(t,f);if(t=Math.round(t-n),r)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(r),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){l.error("invalid ms "+t+" in calendar "+r)}var c=new Date(t+O);return c.setUTCMonth(c.getUTCMonth()+e)+n-O},r.findExactDates=function(t,e){for(var r,n,a=0,i=0,l=0,s=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}function s(t,e,r,n,a){var i=n*t+a*e;if(i<0)return n*n+a*a;if(i>r){var o=n-t,l=a-e;return o*o+l*l}var s=n*e-a*t;return s*s/r}r.segmentsIntersect=l,r.segmentDistance=function(t,e,r,n,a,i,o,c){if(l(t,e,r,n,a,i,o,c))return 0;var u=r-t,f=n-e,d=o-a,p=c-i,h=u*u+f*f,g=d*d+p*p,v=Math.min(s(u,f,h,a-t,i-e),s(u,f,h,o-t,c-e),s(d,p,g,t-a,e-i),s(d,p,g,r-a,n-i));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,l){if(t===a&&l===i||(n={},a=t,i=l),n[r])return n[r];var s=t.getPointAtLength(o(r-l/2,e)),c=t.getPointAtLength(o(r+l/2,e)),u=Math.atan((c.y-s.y)/(c.x-s.x)),f=t.getPointAtLength(o(r,e)),d={x:(4*f.x+s.x+c.x)/6,y:(4*f.y+s.y+c.y)/6,theta:u};return n[r]=d,d},r.clearLocationCache=function(){a=null},r.getVisibleSegment=function(t,e,r){var n,a,i=e.left,o=e.right,l=e.top,s=e.bottom,c=0,u=t.getTotalLength(),f=u;function d(e){var r=t.getPointAtLength(e);0===e?n=r:e===u&&(a=r);var c=r.xo?r.x-o:0,f=r.ys?r.y-s:0;return Math.sqrt(c*c+f*f)}for(var p=d(c);p;){if((c+=p+r)>f)return;p=d(c)}for(p=d(f);p;){if(c>(f-=p+r))return;p=d(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(n.x-a.x)<.1&&Math.abs(n.y-a.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var a,i,o,l=(n=n||{}).pathLength||t.getTotalLength(),s=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(l)[r]?-1:1,f=0,d=0,p=l;f0?p=a:d=a,f++}return i}},{"./mod":169}],160:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],161:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],162:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../constants/numerical"),o=i.FP_SAFE,l=i.BADNUM,s=e.exports={};s.nestedProperty=t("./nested_property"),s.keyedContainer=t("./keyed_container"),s.relativeAttr=t("./relative_attr"),s.isPlainObject=t("./is_plain_object"),s.toLogRange=t("./to_log_range"),s.relinkPrivateKeys=t("./relink_private");var c=t("./array");s.isTypedArray=c.isTypedArray,s.isArrayOrTypedArray=c.isArrayOrTypedArray,s.isArray1D=c.isArray1D,s.ensureArray=c.ensureArray,s.concat=c.concat,s.maxRowLength=c.maxRowLength,s.minRowLength=c.minRowLength;var u=t("./mod");s.mod=u.mod,s.modHalf=u.modHalf;var f=t("./coerce");s.valObjectMeta=f.valObjectMeta,s.coerce=f.coerce,s.coerce2=f.coerce2,s.coerceFont=f.coerceFont,s.coerceHoverinfo=f.coerceHoverinfo,s.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,s.validate=f.validate;var d=t("./dates");s.dateTime2ms=d.dateTime2ms,s.isDateTime=d.isDateTime,s.ms2DateTime=d.ms2DateTime,s.ms2DateTimeLocal=d.ms2DateTimeLocal,s.cleanDate=d.cleanDate,s.isJSDate=d.isJSDate,s.formatDate=d.formatDate,s.incrementMonth=d.incrementMonth,s.dateTick0=d.dateTick0,s.dfltRange=d.dfltRange,s.findExactDates=d.findExactDates,s.MIN_MS=d.MIN_MS,s.MAX_MS=d.MAX_MS;var p=t("./search");s.findBin=p.findBin,s.sorterAsc=p.sorterAsc,s.sorterDes=p.sorterDes,s.distinctVals=p.distinctVals,s.roundUp=p.roundUp,s.sort=p.sort,s.findIndexOfMin=p.findIndexOfMin;var h=t("./stats");s.aggNums=h.aggNums,s.len=h.len,s.mean=h.mean,s.midRange=h.midRange,s.variance=h.variance,s.stdev=h.stdev,s.interp=h.interp;var g=t("./matrix");s.init2dArray=g.init2dArray,s.transposeRagged=g.transposeRagged,s.dot=g.dot,s.translationMatrix=g.translationMatrix,s.rotationMatrix=g.rotationMatrix,s.rotationXYMatrix=g.rotationXYMatrix,s.apply2DTransform=g.apply2DTransform,s.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");s.deg2rad=v.deg2rad,s.rad2deg=v.rad2deg,s.angleDelta=v.angleDelta,s.angleDist=v.angleDist,s.isFullCircle=v.isFullCircle,s.isAngleInsideSector=v.isAngleInsideSector,s.isPtInsideSector=v.isPtInsideSector,s.pathArc=v.pathArc,s.pathSector=v.pathSector,s.pathAnnulus=v.pathAnnulus;var y=t("./anchor_utils");s.isLeftAnchor=y.isLeftAnchor,s.isCenterAnchor=y.isCenterAnchor,s.isRightAnchor=y.isRightAnchor,s.isTopAnchor=y.isTopAnchor,s.isMiddleAnchor=y.isMiddleAnchor,s.isBottomAnchor=y.isBottomAnchor;var m=t("./geometry2d");s.segmentsIntersect=m.segmentsIntersect,s.segmentDistance=m.segmentDistance,s.getTextLocation=m.getTextLocation,s.clearLocationCache=m.clearLocationCache,s.getVisibleSegment=m.getVisibleSegment,s.findPointOnPath=m.findPointOnPath;var x=t("./extend");s.extendFlat=x.extendFlat,s.extendDeep=x.extendDeep,s.extendDeepAll=x.extendDeepAll,s.extendDeepNoArrays=x.extendDeepNoArrays;var b=t("./loggers");s.log=b.log,s.warn=b.warn,s.error=b.error;var _=t("./regex");s.counterRegex=_.counter;var w=t("./throttle");function k(t){var e={};for(var r in t)for(var n=t[r],a=0;ao?l:a(t)?Number(t):l:l},s.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},s.noop=t("./noop"),s.identity=t("./identity"),s.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},s.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},s.simpleMap=function(t,e,r,n){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,r)?a>10?(s.warn("randstr failed uniqueness"),c):t(e,r,n,(a||0)+1):c},s.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},s.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,a,i,o=t.length,l=2*o,s=2*e-1,c=new Array(s),u=new Array(o);for(r=0;r=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=o&&(a=l-1-a),i+=t[a]*c[n];u[r]=i}return u},s.syncOrAsync=function(t,e,r){var n;function a(){return s.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(a).then(void 0,s.promiseError);return r&&r(e)},s.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},s.noneOrAll=function(t,e,r){if(t){var n,a=!1,i=!0;for(n=0;n1?a+o[1]:"";if(i&&(o.length>1||l.length>4||r))for(;n.test(l);)l=l.replace(n,"$1"+i+"$2");return l+s};var A=/%{([^\s%{}:]*)(:[^}]*)?}/g,L=/^\w*$/;s.templateString=function(t,e){var r={};return t.replace(A,function(t,n){return L.test(n)?e[n]||"":(r[n]=r[n]||s.nestedProperty(e,n).get,r[n]()||"")})};var S=/^:/,C=0;s.hovertemplateString=function(t,e){var r=arguments,a={};return t.replace(A,function(t,i,o){var l,c,u;for(u=2;u=48&&o<=57,c=l>=48&&l<=57;if(s&&(n=10*n+o-48),c&&(a=10*a+l-48),!s||!c){if(n!==a)return n-a;if(o!==l)return o-l}}return a-n};var O=2e9;s.seedPseudoRandom=function(){O=2e9},s.pseudoRandom=function(){var t=O;return O=(69069*O+1)%4294967296,Math.abs(O-t)<429496729?s.pseudoRandom():O/4294967296}},{"../constants/numerical":143,"./anchor_utils":147,"./angles":148,"./array":149,"./clean_number":150,"./clear_responsive":152,"./coerce":153,"./dates":154,"./extend":156,"./filter_unique":157,"./filter_visible":158,"./geometry2d":159,"./get_graph_div":160,"./identity":161,"./is_plain_object":163,"./keyed_container":164,"./localize":165,"./loggers":166,"./make_trace_groups":167,"./matrix":168,"./mod":169,"./nested_property":170,"./noop":171,"./notifier":172,"./push_unique":175,"./regex":177,"./relative_attr":178,"./relink_private":179,"./search":180,"./stats":182,"./throttle":184,"./to_log_range":185,d3:11,"fast-isnumeric":13}],163:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],164:[function(t,e,r){"use strict";var n=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,r,i){var o,l,s;r=r||"name",i=i||"value";var c={};e&&e.length?(s=n(t,e),l=s.get()):l=t,e=e||"";var u={};if(l)for(o=0;o2)return c[e]=2|c[e],d.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],170:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,c=e.split(".");s/g),o=0;oi||c===a||cl||e&&s(t))}:function(t,e){var s=t[0],c=t[1];if(s===a||si||c===a||cl)return!1;var u,f,d,p,h,g=r.length,v=r[0][0],y=r[0][1],m=0;for(u=1;uMath.max(f,v)||c>Math.max(d,y)))if(cu||Math.abs(n(o,d))>a)return!0;return!1};i.filter=function(t,e){var r=[t[0]],n=0,a=0;function i(i){t.push(i);var l=r.length,s=n;r.splice(a+1);for(var c=s+1;c1&&i(t.pop());return{addPt:i,raw:t,filtered:r}}},{"../constants/numerical":143,"./matrix":168}],175:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ra.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function c(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,u,f=0,d=e.length,p=0,h=d>1?(e[d-1]-e[0])/(d-1):1;for(u=h>=0?r?o:l:r?c:s,t+=1e-9*h*(r?-1:1)*(h>=0?1:-1);f90&&a.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,a=e[n]-e[0]||1,i=a/(n||1)/1e4,o=[e[0]],l=0;le[l]+i&&(a=Math.min(a,e[l+1]-e[l]),o.push(e[l+1]));return{vals:o,minDiff:a}},r.roundUp=function(t,e,r){for(var n,a=0,i=e.length-1,o=0,l=r?0:1,s=r?1:0,c=r?Math.ceil:Math.floor;a0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||i;for(var r,n=1/0,a=0;ai.length)&&(o=i.length),n(e)||(e=!1),a(i[0])){for(s=new Array(o),l=0;lt.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":149,"fast-isnumeric":13}],183:[function(t,e,r){"use strict";var n=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function l(t,e){return t.node().getBoundingClientRect()[e]}var s=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var L=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&L.match(s),O=n.select(t.node().parentNode);if(!O.empty()){var P=t.attr("class")?t.attr("class").split(" ")[0]:"text";return P+="-math",O.selectAll("svg."+P).remove(),O.selectAll("g."+P+"-group").remove(),t.style("display",null).attr({"data-unformatted":L,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),i={fontSize:r};!function(t,e,r){var i,o,l,s;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),l=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+a.randstr({},64);return s=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(s.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(s.select(".MathJax_SVG").empty()||!s.select("svg").node())a.log("There was an error in the tex syntax.",t),r();else{var o=s.select("svg").node().getBoundingClientRect();r(s.select(".MathJax_SVG"),e,o)}if(s.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==l&&(MathJax.Hub.processSectionDelay=l),MathJax.Hub.Config(o)})}(S[2],i,function(n,a,i){O.selectAll("svg."+P).remove(),O.selectAll("g."+P+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return D(),void e();var s=O.append("g").classed(P+"-group",!0).attr({"pointer-events":"none","data-unformatted":L,"data-math":"Y"});s.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:P,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=l(o,"width"),f=l(o,"height"),d=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(r||l(t,"height"))/4;"y"===P[0]?(s.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===P[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===P[0]?o.attr({x:0,y:p}):o.attr({x:d,y:+t.attr("y")+p-f/2}),v&&v.call(t,s),e(s)})})):D(),t}function D(){O.empty()||(P=t.attr("class")+"-math",O.select("svg."+P).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var r,l=!1,s=[],c=-1;function u(){c++;var e=document.createElementNS(i.svg,"tspan");n.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),r=e;var a=s;if(s=[{node:e}],a.length>1)for(var l=1;l doesnt match end tag <"+t+">. Pretending it did match.",e),r=s[s.length-1].node}else a.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(r=t,s=[{node:t}]);for(var O=e.split(m),P=0;P|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},d={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},h="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,m=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,T=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function M(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&C(n)}var A=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var L={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function C(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):L[e])||t})}function O(t,e,r){var n,a,i,o=r.horizontalAlign,l=r.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-n.height}:"middle"===l?function(){return s.top+(s.height-n.height)/2}:function(){return s.top},i="right"===o?function(){return s.right-n.width}:"center"===o?function(){return s.left+(s.width-n.width)/2}:function(){return s.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:i()-c.left+"px","z-index":1e3}),this}}r.convertEntities=C,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function a(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var i=a("x",e),o=a("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},r.makeEditable=function(t,e){var r=e.gd,a=e.delegate,i=n.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function l(){!function(){var a=n.select(r).select(".svg-container"),o=a.append("div"),l=t.node().style,c=parseFloat(l.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":l.fontFamily||"Arial","font-size":c,color:e.fill||l.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(O(t,a,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=n.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),n.select(this).call(O(t,a,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(s)}(),t.style({opacity:0});var a,l=o.attr("class");(a=l?"."+l.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(a).style({opacity:0})}function s(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?l():o.on("click",l),n.rebind(t,i,"on")}},{"../constants/alignment":141,"../constants/xmlns_namespaces":144,"../lib":162,d3:11}],184:[function(t,e,r){"use strict";var n={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var i=n[t],o=Date.now();if(!i){for(var l in n)n[l].tsi.ts+e?s():i.timer=setTimeout(function(){s(),i.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)a(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],185:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":13}],186:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],187:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],188:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,a=n.layoutArrayContainers,i=n.layoutArrayRegexes,o=t.split("[")[0],l=0;l0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var i=(l.subplotsRegistry.cartesian||{}).attrRegex,s=(l.subplotsRegistry.polar||{}).attrRegex,u=(l.subplotsRegistry.ternary||{}).attrRegex,h=(l.subplotsRegistry.gl3d||{}).attrRegex,g=Object.keys(t);for(e=0;e3?(P.x=1.02,P.xanchor="left"):P.x<-2&&(P.x=-.02,P.xanchor="right"),P.y>3?(P.y=1.02,P.yanchor="bottom"):P.y<-2&&(P.y=-.02,P.yanchor="top")),p(t),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t.template&&t.template.layout&&r.cleanLayout(t.template.layout),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=x(e);r;){if(r in t)return!0;r=x(r)}return!1};var b=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&i.warn("Full array edits are incompatible with other edits",f);var m=r[""][""];if(c(m))e.set(null);else{if(!Array.isArray(m))return i.warn("Unrecognized full array edit value",f,m),!0;e.set(m)}return!g&&(d(v,y),p(t),!0)}var x,b,_,w,k,T,M,A,L=Object.keys(r).map(Number).sort(o),S=e.get(),C=S||[],O=u(y,f).get(),P=[],D=-1,z=C.length;for(x=0;xC.length-(M?0:1))i.warn("index out of range",f,_);else if(void 0!==T)k.length>1&&i.warn("Insertion & removal are incompatible with edits to the same index.",f,_),c(T)?P.push(_):M?("add"===T&&(T={}),C.splice(_,0,T),O&&O.splice(_,0,{})):i.warn("Unrecognized full object edit value",f,_,T),-1===D&&(D=_);else for(b=0;b=0;x--)C.splice(P[x],1),O&&O.splice(P[x],1);if(C.length?S||e.set(C):e.set(null),g)return!1;if(d(v,y),h!==a){var E;if(-1===D)E=L;else{for(z=Math.max(C.length,z),E=[],x=0;x=D);x++)E.push(_);for(x=D;x=t.data.length||a<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(a,n+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+r+" must be unique.")}}function E(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),z(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&z(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function R(t,e,r,n,i){!function(t,e,r,n){var a=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var i in z(t,r,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==r.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in n)||!Array.isArray(n[i])||n[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var s=function(t,e,r,n){var i,s,c,u,f,d=o.isPlainObject(n),p=[];for(var h in Array.isArray(r)||(r=[r]),r=D(r,t.data.length-1),e)for(var g=0;g-1?s(r,r.replace("titlefont","title.font")):r.indexOf("titleposition")>-1?s(r,r.replace("titleposition","title.position")):r.indexOf("titleside")>-1?s(r,r.replace("titleside","title.side")):r.indexOf("titleoffset")>-1&&s(r,r.replace("titleoffset","title.offset")):s(r,r.replace("title","title.text"));function s(e,r){t[r]=t[e],delete t[e]}}function V(t,e,r){if(t=o.getGraphDiv(t),k.clearPromiseQueue(t),t.framework&&t.framework.isPolar)return Promise.resolve(t);var n={};if("string"==typeof e)n[e]=r;else{if(!o.isPlainObject(e))return o.warn("Relayout fail.",e,r),Promise.reject();n=o.extendFlat({},e)}Object.keys(n).length&&(t.changed=!0);var a=W(t,n),i=a.flags;i.calc&&(t.calcdata=void 0);var l=[d.previousPromises];i.layoutReplot?l.push(T.layoutReplot):Object.keys(n).length&&(U(t,i,a)||d.supplyDefaults(t),i.legend&&l.push(T.doLegend),i.layoutstyle&&l.push(T.layoutStyles),i.axrange&&G(l,a.rangesAltered),i.ticks&&l.push(T.doTicksRelayout),i.modebar&&l.push(T.doModeBar),i.camera&&l.push(T.doCamera),l.push(S)),l.push(d.rehover),c.add(t,V,[t,a.undoit],V,[t,a.redoit]);var s=o.syncOrAsync(l,t);return s&&s.then||(s=Promise.resolve(t)),s.then(function(){return t.emit("plotly_relayout",a.eventData),t})}function U(t,e,r){var n;if(!e.axrange)return!1;for(n in e)if("axrange"!==n&&e[n])return!1;for(n in r.rangesAltered){var a=h.id2name(n),i=t.layout[a],o=t._fullLayout[a];o.autorange=i.autorange,o.range=i.range.slice(),o.cleanRange()}return!0}function G(t,e){var r=e?function(t){var r={skipTitle:!0};for(var n in e)if(h.getFromId(t,n).automargin){r={};break}return h.draw(t,Object.keys(e),r)}:function(t){return h.draw(t,"redraw")};t.push(T.doAutoRangeAndConstraints,r,T.drawData,T.finalDraw)}r.plot=function(t,e,a,i){var l;if(t=o.getGraphDiv(t),s.init(t),o.isPlainObject(e)){var c=e;e=c.data,a=c.layout,i=c.config,l=c.frames}if(!1===s.triggerHandler(t,"plotly_beforeplot",[e,a,i]))return Promise.reject();e||a||o.isPlotDiv(t)||o.warn("Calling Plotly.plot as if redrawing but this container doesn't yet have a plot.",t),P(t,i),a||(a={}),n.select(t).classed("js-plotly-plot",!0),g.makeTester(),Array.isArray(t._promises)||(t._promises=[]);var f=0===(t.data||[]).length&&Array.isArray(e);if(Array.isArray(e)&&(k.cleanData(e),f?t.data=e:t.data.push.apply(t.data,e),t.empty=!1),t.layout&&!f||(t.layout=k.cleanLayout(a)),t._dragging&&!t._transitioning)return t._replotPending=!0,Promise.reject();t._replotPending=!1,d.supplyDefaults(t);var v=t._fullLayout,x=v._has("cartesian");if(!v._has("polar")&&e&&e[0]&&e[0].r)return o.log("Legacy polar charts are deprecated!"),function(t,e,r){var a=n.select(t).selectAll(".plot-container").data([0]);a.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=a.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e);r&&(t.layout=r);p.manager.fillLayout(t),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=p.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var l=t.framework.svg(),s=1,c=t._fullLayout.title?t._fullLayout.title.text:"";""!==c&&c||(s=0);var u=function(){this.call(b.convertToTspans,t)},f=l.select(".title-group text").call(u);if(t._context.edits.titleText){var h=o._(t,"Click to enter Plot title");c&&c!==h||(s=.2,f.attr({"data-unformatted":h}).text(h).style({opacity:s}).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)}));var g=function(){this.call(b.makeEditable,{gd:t}).on("edit",function(e){t.framework({layout:{title:{text:e}}}),this.text(e).call(u),this.call(g)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(u)})};f.call(g)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),d.addLinks(t),Promise.resolve()}(t,e,a);v._replotting=!0,f&<(t),t.framework!==lt&&(t.framework=lt,lt(t)),g.initGradients(t),f&&h.saveShowSpikeInitial(t);var _=!t.calcdata||t.calcdata.length!==(t._fullData||[]).length;_&&d.doCalcdata(t);for(var w=0;w=0&&r=0&&r0&&"string"!=typeof z.parts[R];)R--;var N=z.parts[R],I=z.parts[R-1]+"."+N,j=z.parts.slice(0,R).join("."),H=l(t.layout,j).get(),V=l(s,j).get(),U=z.get();if(void 0!==E){T[D]=E,L[D]="reverse"===N?E:F(U);var G=f.getLayoutValObject(s,z.parts);if(G&&G.impliedEdits&&null!==E)for(var W in G.impliedEdits)S(o.relativeAttr(D,W),G.impliedEdits[W]);if(-1!==["width","height"].indexOf(D))if(E){S("autosize",null);var $="height"===D?"width":"height";S($,s[$])}else s[D]=t._initialAutoSize[D];else if("autosize"===D)S("width",E?null:s.width),S("height",E?null:s.height);else if(I.match(Y))P(I),l(s,j+"._inputRange").set(null);else if(I.match(X)){P(I),l(s,j+"._inputRange").set(null);var Q=l(s,j).get();Q._inputDomain&&(Q._input.domain=Q._inputDomain.slice())}else I.match(Z)&&l(s,j+"._inputDomain").set(null);if("type"===N){var K=H,tt="linear"===V.type&&"log"===E,et="log"===V.type&&"linear"===E;if(tt||et){if(K&&K.range)if(V.autorange)tt&&(K.range=K.range[1]>K.range[0]?[1,2]:[2,1]);else{var rt=K.range[0],nt=K.range[1];tt?(rt<=0&&nt<=0&&S(j+".autorange",!0),rt<=0?rt=nt/1e6:nt<=0&&(nt=rt/1e6),S(j+".range[0]",Math.log(rt)/Math.LN10),S(j+".range[1]",Math.log(nt)/Math.LN10)):(S(j+".range[0]",Math.pow(10,rt)),S(j+".range[1]",Math.pow(10,nt)))}else S(j+".autorange",!0);Array.isArray(s._subplots.polar)&&s._subplots.polar.length&&s[z.parts[0]]&&"radialaxis"===z.parts[1]&&delete s[z.parts[0]]._subplot.viewInitial["radialaxis.range"],u.getComponentMethod("annotations","convertCoords")(t,V,E,S),u.getComponentMethod("images","convertCoords")(t,V,E,S)}else S(j+".autorange",!0),S(j+".range",null);l(s,j+"._inputRange").set(null)}else if(N.match(A)){var at=l(s,D).get(),it=(E||{}).type;it&&"-"!==it||(it="linear"),u.getComponentMethod("annotations","convertCoords")(t,at,it,S),u.getComponentMethod("images","convertCoords")(t,at,it,S)}var ot=w.containerArrayMatch(D);if(ot){r=ot.array,n=ot.index;var lt=ot.property,st=G||{editType:"calc"};""!==n&&""===lt&&(w.isAddVal(E)?L[D]=null:w.isRemoveVal(E)?L[D]=(l(i,r).get()||[])[n]:o.warn("unrecognized full object value",e)),M.update(_,st),y[r]||(y[r]={});var ct=y[r][n];ct||(ct=y[r][n]={}),ct[lt]=E,delete e[D]}else"reverse"===N?(H.range?H.range.reverse():(S(j+".autorange",!0),H.range=[1,0]),V.autorange?_.calc=!0:_.plot=!0):(s._has("scatter-like")&&s._has("regl")&&"dragmode"===D&&("lasso"===E||"select"===E)&&"lasso"!==U&&"select"!==U?_.plot=!0:G?M.update(_,G):_.calc=!0,z.set(E))}}for(r in y){w.applyContainerArrayChanges(t,d(i,r),y[r],_,d)||(_.plot=!0)}var ut=s._axisConstraintGroups||[];for(C in O)for(n=0;n1;)if(n.pop(),void 0!==(r=l(e,n.join(".")+".uirevision").get()))return r;return e.uirevision}function nt(t,e){for(var r=0;r=a.length?a[0]:a[t]:a}function s(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function c(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(i,u){function f(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,d.transition(t,e.frame.data,e.frame.layout,k.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function p(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&f()};e()}var h,g,v=0;function y(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var m=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))m.push({type:"object",data:y(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(h=0;h0&&TT)&&M.push(g);m=M}}m.length>0?function(e){if(0!==e.length){for(var a=0;a=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(u[g]||h[g]||{}).name,y=e[n].name,m=u[v]||h[v];v&&y&&"number"==typeof y&&m&&L<5&&(L++,o.warn('addFrames: overwriting frame "'+(u[v]||h[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===L&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),h[g]={name:g},p.push({frame:d.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:f+n})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(a=p[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;u[a.name="frame "+t._transitionData._counter++];);if(u[a.name]){for(i=0;i=0;r--)n=e[r],i.push({type:"delete",index:n}),l.unshift({type:"insert",index:n,value:a[n]});var s=d.modifyFrames,u=d.modifyFrames,f=[t,l],p=[t,i];return c&&c.add(t,s,f,u,p),d.modifyFrames(t,i)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return d.cleanPlot([],{},r,e),d.purge(t),s.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":46,"../components/colorbar/connect":48,"../components/drawing":67,"../constants/xmlns_namespaces":144,"../lib":162,"../lib/events":155,"../lib/queue":176,"../lib/svg_text_utils":183,"../plots/cartesian/axes":206,"../plots/cartesian/constants":212,"../plots/cartesian/graph_interact":216,"../plots/plots":239,"../plots/polar/legacy":242,"../registry":246,"./edit_types":189,"./helpers":190,"./manage_arrays":192,"./plot_config":194,"./plot_schema":195,"./subroutines":197,d3:11,"fast-isnumeric":13,"has-hover":15}],194:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,showSendToCloud:!1,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,watermark:!1,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],195:[function(t,e,r){"use strict";var n=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),l=t("../plots/frame_attributes"),s=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),d=a.extendFlat,p=a.extendDeepAll,h=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",y=[g,v,"_arrayAttrRegexps","_deprecated"];function m(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(x(e[r]))r++;else if(r=i.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!x(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):h(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(h(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=s.length)return!1;a=(r=(n.transformsRegistry[s[u].type]||{}).attributes)&&r[e[2]],l=3}else if("area"===t.type)a=c[o];else{var f=t._module;if(f||(f=(n.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(r=f.attributes)&&r[o])){var d=f.basePlotModule;d&&d.attributes&&(a=d.attributes[o])}a||(a=i[o])}return m(a,e,l)},r.getLayoutValObject=function(t,e){return m(function(t,e){var r,a,i,l,s=t._basePlotModules;if(s){var c;for(r=0;r=a&&(r._input||{})._templateitemname;l&&(o=a);var s,c=e+"["+o+"]";function u(){s={},l&&(s[c]={},s[c][i]=l)}function f(t,e){l?n.nestedProperty(s[c],t).set(e):s[c+"."+t]=e}function d(){var t=s;return u(),t}return u(),{modifyBase:function(t,e){s[t]=e},modifyItem:f,getUpdateObj:d,applyUpdate:function(e,r){e&&f(e,r);var a=d();for(var i in a)n.nestedProperty(t,i).set(a[i])}}}},{"../lib":162,"../plots/attributes":203}],197:[function(t,e,r){"use strict";var n=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),l=t("../lib/clear_gl_canvases"),s=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),d=t("../plots/cartesian/axes"),p=t("../constants/alignment"),h=t("../plots/cartesian/constraints"),g=h.enforce,v=h.clean,y=t("../plots/cartesian/autorange").doAutoRange,m="start",x="middle",b="end";function _(t,e,r){for(var n=0;n=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function w(t){var e,a,i,l,u,h,g=t._fullLayout,v=g._size,y=v.p,m=d.list(t,"",!0);if(g._paperdiv.style({width:t._context.responsive&&g.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":g.width+"px",height:t._context.responsive&&g.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":g.height+"px"}).selectAll(".main-svg").call(c.setSize,g.width,g.height),t._context.setBackground(t,g.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!g._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-y-n:e._offset+e._length+y+n:v.t+v.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+y+n:e._offset-y-n:v.l+v.w*(t.position||0)+n%1}for(e=0;ek?u.push({code:"unused",traceType:m,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:m,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var i=e[n],o=p(e,n,r);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&u.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&h(i)&&t(i,o)}}({data:v,layout:d},""),u.length)return u.map(g)}},{"../lib":162,"../plots/attributes":203,"../plots/plots":239,"./plot_config":194,"./plot_schema":195,"./plot_template":196}],199:[function(t,e,r){"use strict";var n=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),l=t("../snapshot/svgtoimg"),s={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,u,f;function d(t){return!(t in e)||a.validate(e[t],s[t])}if(e=e||{},a.isPlainObject(t)?(r=t.data||[],u=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),r=a.extendDeep([],t.data),u=a.extendDeep({},t.layout),f=t._context),!d("width")||!d("height"))throw new Error("Height and width should be pixel values.");if(!d("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function h(t,r){return a.coerce(e,p,s,t,r)}var g=h("format"),v=h("width"),y=h("height"),m=h("scale"),x=h("setBackground"),b=h("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},u);v&&(w.width=v),y&&(w.height=y);var k=a.extendFlat({},f,{_exportedPlot:!0,staticPlot:!0,setBackground:x}),T=i.getRedrawFunc(_);function M(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function A(){return new Promise(function(t,e){var r=o(_,g,m),i=_._fullLayout.width,s=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(b?r:"data:image/svg+xml,"+encodeURIComponent(r));var c=document.createElement("canvas");c.id=a.randstr(),l({format:g,width:i,height:s,scale:m,canvas:c,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,k).then(T).then(M).then(A).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":162,"../snapshot/helpers":250,"../snapshot/svgtoimg":252,"../snapshot/tosvg":254,"./plot_api":193}],200:[function(t,e,r){"use strict";var n=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),l=n.isPlainObject,s=Array.isArray,c=n.isArrayOrTypedArray;function u(t,e,r,a,i,o){o=o||[];for(var f=Object.keys(t),d=0;dx.length&&a.push(p("unused",i,y.concat(x.length)));var T,M,A,L,S,C=x.length,O=Array.isArray(k);if(O&&(C=Math.min(C,k.length)),2===b.dimensions)for(M=0;Mx[M].length&&a.push(p("unused",i,y.concat(M,x[M].length)));var P=x[M].length;for(T=0;T<(O?Math.min(P,k[M].length):P);T++)A=O?k[M][T]:k,L=m[M][T],S=x[M][T],n.validate(L,A)?S!==L&&S!==+L&&a.push(p("dynamic",i,y.concat(M,T),L,S)):a.push(p("value",i,y.concat(M,T),L))}else a.push(p("array",i,y.concat(M),m[M]));else for(M=0;M1&&d.push(p("object","layout"))),a.supplyDefaults(h);for(var g=h._fullData,v=r.length,y=0;y0&&((b=M-o(v)-o(y))>A?_/b>L&&(m=v,x=y,L=_/b):_/M>L&&(m={val:v.val,pad:0},x={val:y.val,pad:0},L=_/M));if(d===p){var S=d-1,C=d+1;if(k)if(0===d)i=[0,1];else{var O=(d>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),P=d/(1-Math.min(.5,O/M));i=d>0?[0,P]:[P,0]}else i=T?[Math.max(0,S),Math.max(1,C)]:[S,C]}else k?(m.val>=0&&(m={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):T&&(m.val-L*o(m)<0&&(m={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),L=(x.val-m.val)/(M-o(m)-o(x)),i=[m.val-L*o(m),x.val+L*o(x)];return h&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function s(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function c(t,e){var r,n,a,i=e._id,o=t._fullData,l=t._fullLayout,s=[],c=[];function d(t,e){for(r=0;r=r&&(c.extrapad||!o)){l=!1;break}a(e,c.val)&&c.pad<=r&&(o||!c.extrapad)&&(t.splice(s,1),s--)}if(l){var u=i&&0===e;t.push({val:e,pad:u?0:r,extrapad:!u&&o})}}function p(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:l,makePadFn:s,doAutoRange:function(t,e){if(e.autorange){e.range=l(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l);var r=e._input,n={};n[e._attr+".range"]=e.range,n[e._attr+".autorange"]=e.autorange,o.call("_storeDirectGUIEdit",t.layout,t._fullLayout._preGUI,n),r.range=e.range.slice(),r.autorange=e.autorange}var i=e._anchorAxis;if(i&&i.rangeslider){var s=i.rangeslider[e._name];s&&"auto"===s.rangemode&&(s.range=l(t,e)),i._input.rangeslider[e._name]=a.extendFlat({},s)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var a,o,l,s,c,d,h,g,v,y=[],m=[],x=e.length,b=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function T(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var M=T((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),A=T((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),L=T(r.vpadplus||r.vpad),S=T(r.vpadminus||r.vpad);if(!k){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=P;a--)O(a);return{min:y,max:m}},concatExtremes:c}},{"../../constants/numerical":143,"../../lib":162,"../../registry":246,"fast-isnumeric":13}],206:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),d=t("./layout_attributes"),p=t("./clean_ticks"),h=t("../../constants/numerical"),g=h.ONEAVGYEAR,v=h.ONEAVGMONTH,y=h.ONEDAY,m=h.ONEHOUR,x=h.ONEMIN,b=h.ONESEC,_=h.MINUS_SIGN,w=h.BADNUM,k=t("../../constants/alignment").MID_SHIFT,T=t("../../constants/alignment").LINE_SPACING,M=e.exports={};M.setConvert=t("./set_convert");var A=t("./axis_autotype"),L=t("./axis_ids");M.id2name=L.id2name,M.name2id=L.name2id,M.cleanId=L.cleanId,M.list=L.list,M.listIds=L.listIds,M.getFromId=L.getFromId,M.getFromTrace=L.getFromTrace;var S=t("./autorange");M.getAutoRange=S.getAutoRange,M.findExtremes=S.findExtremes,M.coerceRef=function(t,e,r,n,a,i){var o=n.charAt(n.length-1),s=r._fullLayout._subplots[o+"axis"],c=n+"ref",u={};return a||(a=s[0]||i),i||(i=a),u[c]={valType:"enumerated",values:s.concat(i?[i]:[]),dflt:a},l.coerce(t,e,u,c)},M.coercePosition=function(t,e,r,n,a,i){var o,s;if("paper"===n||"pixel"===n)o=l.ensureNumber,s=r(a,i);else{var c=M.getFromId(e,n);s=r(a,i=c.fraction2r(i)),o=c.cleanPos}t[a]=o(s)},M.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?l.ensureNumber:M.getFromId(e,r).cleanPos)(t)};var C=M.getDataConversions=function(t,e,r,n){var a,i="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(i)){if(a={type:A(n),_categories:[]},M.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},M.saveRangeInitial=function(t,e){for(var r=M.list(t,"",!0),n=!1,a=0;a.3*d||u(n)||u(i))){var p=r.dtick/2;t+=t+p.8){var o=Number(r.substr(1));i.exactYears>.8&&o%12==0?t=M.tickIncrement(t,"M6","reverse")+1.5*y:i.exactMonths>.8?t=M.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var s=M.tickIncrement(t,r);if(s<=n)return s}return t}(x,t,m,c,i)),v=x,0;v<=u;)v=M.tickIncrement(v,m,!1,i),0;return{start:e.c2r(x,0,i),end:e.c2r(v,0,i),size:m,_dataSpan:u-c}},M.prepTicks=function(t){var e=l.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type||"multicategory"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=l.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),M.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},M.calcTicks=function(t){M.prepTicks(t);var e=l.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e=t.tickvals,r=t.ticktext,n=new Array(e.length),a=l.simpleMap(t.range,t.r2l),i=1.0001*a[0]-1e-4*a[1],o=1.0001*a[1]-1e-4*a[0],s=Math.min(i,o),c=Math.max(i,o),u=0;Array.isArray(r)||(r=[]);var f="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(var d=0;ds&&p=n:c<=n)&&!(i.length>s||c===o);c=M.tickIncrement(c,t.dtick,a,t.calendar))o=c,i.push(c);et(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(i.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&i<=10||e>=15*y)t._tickround="d";else if(e>=x&&i<=16||e>=m)t._tickround="M";else if(e>=b&&i<=19||e>=x)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var l=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var s=Math.max(Math.abs(l[0]),Math.abs(l[1])),c=Math.floor(Math.log(s)/Math.LN10+.01);Math.abs(c)>3&&(V(t.exponentformat)&&!U(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function H(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}M.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=l.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,r=n(10),t.dtick="M"+12*B(e,r,D)):i>v?(e/=v,t.dtick="M"+B(e,1,z)):i>y?(t.dtick=B(e,y,R),t.tick0=l.dateTick0(t.calendar,!0)):i>m?t.dtick=B(e,m,z):i>x?t.dtick=B(e,x,E):i>b?t.dtick=B(e,b,E):(r=n(10),t.dtick=B(e,r,D))}else if("log"===t.type){t.tick0=0;var o=l.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var s=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/s,r=n(10),t.dtick="L"+B(e,r,D)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type||"multicategory"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):et(t)?(t.tick0=0,r=1,t.dtick=B(e,r,F)):(t.tick0=0,r=n(10),t.dtick=B(e,r,D));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},M.tickIncrement=function(t,e,r,i){var o=r?-1:1;if(a(e))return t+o*e;var s=e.charAt(0),c=o*Number(e.substr(1));if("M"===s)return l.incrementMonth(t,c,i);if("L"===s)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===s){var u="D2"===e?I:N,f=t+.01*o,d=l.roundUp(l.mod(f,1),u,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(e)},M.tickFirst=function(t){var e=t.r2l||Number,r=l.simpleMap(t.range,e),i=r[1]"+s,t._prevDateHead=s));e.text=c}(t,i,r,s):"log"===c?function(t,e,r,n,i){var o=t.dtick,s=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===i&&(i="");n&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,s),t,i,n);else if(a(o)||"D"===u&&l.mod(s+.01,1)<.1){var f=Math.round(s),d=Math.abs(f),p=t.exponentformat;"power"===p||V(p)&&U(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+d+"",e.fontSize*=1.25):("e"===p||"E"===p)&&d>2?e.text="1"+p+(f>0?"+":_)+d:(e.text=G(Math.pow(10,s),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,l.mod(s,1)))),e.fontSize*=.75}if("D1"===t.dtick){var h=String(e.text).charAt(0);"0"!==h&&"1"!==h||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(s<0?.5:.25)))}}(t,i,0,s,h):"category"===c?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,i):"multicategory"===c?function(t,e,r){var n=Math.round(e.x),a=t._categories[n]||[],i=void 0===a[1]?"":String(a[1]),o=void 0===a[0]?"":String(a[0]);r?e.text=o+" - "+i:(e.text=i,e.text2=o)}(t,i,r):et(t)?function(t,e,r,n,a){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,a,n);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,a=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/a),Math.round(r/a)]}(i);if(o[1]>=100)e.text=G(l.deg2rad(e.x),t,a,n);else{var s=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),s&&(e.text=_+e.text)}}}}(t,i,r,s,h):function(t,e,r,n,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,n)}(t,i,0,s,h),t.tickprefix&&!p(t.showtickprefix)&&(i.text=t.tickprefix+i.text),t.ticksuffix&&!p(t.showticksuffix)&&(i.text+=t.ticksuffix),"boundaries"===t.tickson||t.showdividers){var g=function(e){var r=t.l2p(e);return r>=0&&r<=t._length?e:null};i.xbnd=[g(i.x-.5),g(i.x+t.dtick-.5)]}return i},M.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return M.hoverLabelText(t,e)+" - "+M.hoverLabelText(t,r);var n="log"===t.type&&e<=0,a=M.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+a:a};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function V(t){return"SI"===t||"B"===t}function U(t){return t>14||t<-15}function G(t,e,r,n){var i=t<0,o=e._tickround,s=r||e.exponentformat||"B",c=e._tickexponent,u=M.getTickFormat(e),f=e.separatethousands;if(n){var d={exponentformat:s,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(d),o=(Number(d._tickround)||0)+4,c=d._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,h=Math.pow(10,-o)/2;if("none"===s&&(c=0),(t=Math.abs(t))"+p+"":"B"===s&&9===c?t+="B":V(s)&&(t+=q[c/3+5]));return i?_+t:t}function Y(t,e){var r=t._id.charAt(0),n=t._tickAngles[e]||0,a=l.deg2rad(n),i=Math.sin(a),o=Math.cos(a),s=0,c=0;return t._selections[e].each(function(){var t=W(this),e=f.bBox(t.node()),r=e.width,n=e.height;s=Math.max(s,o*r,i*n),c=Math.max(c,i*r,o*n)}),{x:c,y:s}[r]}function X(t){return[t.text,t.x,t.axInfo,t.font,t.fontSize,t.fontColor].join("_")}function Z(t,e){var r=t.l2p(e);return r>1&&r=0,i=u(t,e[1])<=0;return(r||a)&&(n||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},l=0;l2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":246,"./constants":212}],210:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var l,s=r("categoryorder",a);"array"===s&&(l=r("categoryarray")),o||"array"!==s||(s=e.categoryorder="trace"),"trace"===s?e._initialCategories=[]:"array"===s?e._initialCategories=l.slice():(l=function(t,e){var r,n,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;nl*x)||k)for(r=0;rz&&NP&&(P=N);p/=(P-O)/(2*D),O=u.l2r(O),P=u.l2r(P),u.range=u._input.range=L=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function E(t,e,r,n,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",a+"Z")}function R(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function N(t,e,r,n,a,i){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),I(t,e,a,i)}function I(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function B(t){L&&t.data&&t._context.showTips&&(l.notifier(l._(t,"Double-click to zoom back out"),"long"),L=!1)}function j(t){return"lasso"===t||"select"===t}function H(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,A)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(i){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function V(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,i,c,p,L,S){var I,U,G,Y,X,Z,W,J,$,Q,K,tt,et,rt,nt,at,it,ot,lt,st,ct,ut=t._fullLayout._zoomlayer,ft=L+S==="nsew",dt=1===(L+S).length;function pt(){if(I=e.xaxis,U=e.yaxis,$=I._length,Q=U._length,W=I._offset,J=U._offset,(G={})[I._id]=I,(Y={})[U._id]=U,L&&S)for(var r=e.overlays,n=0;n-1&&w(a,t,X,Z,e.id,At),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===r&&dt){var l=L?U:I,c="s"===L||"w"===S?0:1,u=l._name+".range["+c+"]",d=function(t,e){var r,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,a))):(r=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,n.format("."+String(r)+"g")(a))}(l,c),p="left",h="middle";if(l.fixedrange)return;L?(h="n"===L?"top":"bottom","right"===l.side&&(p="right")):"e"===S&&(p="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(s.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(d),fill:l.tickfont?l.tickfont.color:"#444",horizontalAlign:p,verticalAlign:h}).on("edit",function(e){var r=l.d2r(e);void 0!==r&&o.call("_guiRelayout",t,u,r)})}}function Ct(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min($,e+vt)),a=Math.max(0,Math.min(Q,r+yt)),i=Math.abs(n-vt),o=Math.abs(a-yt);function l(){wt="",mt.r=mt.l,mt.t=mt.b,Tt.attr("d","M0,0Z")}mt.l=Math.min(vt,n),mt.r=Math.max(vt,n),mt.t=Math.min(yt,a),mt.b=Math.max(yt,a),nt?i>A||o>A?(wt="xy",i/$>o/Q?(o=i*Q/$,yt>a?mt.t=yt-o:mt.b=yt+o):(i=o*$/Q,vt>n?mt.l=vt-i:mt.r=vt+i),Tt.attr("d",H(mt))):l():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Et);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var a,i=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=Nt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(at){for(S||(s=.5),a=0;ag[1]-.01&&(e.domain=l),a.noneOrAll(t.domain,e.domain,l)}return r("layer"),e}},{"../../lib":162,"fast-isnumeric":13}],223:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*r;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":141}],224:[function(t,e,r){"use strict";var n=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),l=t("../../lib/polygon"),s=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),d=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),h=p.MINSELECT,g=l.filter,v=l.tester;function y(t){return t._id}function m(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h,g,v=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,m=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var x=function(t,e){var r,n,a=t[0],i=-1,o=[];for(n=0;n0?function(t,e){var r,n,a,i=[];for(a=0;a0&&i.push(r);if(1===i.length&&i[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=r.selectedpoints.length)>1)return!1}return 1===a}(l)&&(d=A(x))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",n)}function A(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,a=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function L(t,e,r){var n,i,o,l;for(n=0;n-1&&m(e,A,a.xaxes,a.yaxes,a.subplot,a,U),"event"===r&&A.emit("plotly_selected",void 0);o.click(A,e)})},a.doneFn=function(){Y.remove(),s.done(X).then(function(){s.clear(X),a.gd.emit("plotly_selected",b),d&&a.selectionDefs&&(d.subtract=V,a.selectionDefs.push(d),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:C,selectOnClick:m}},{"../../components/color":46,"../../components/fx":85,"../../components/fx/helpers":81,"../../lib/clear_gl_canvases":151,"../../lib/polygon":174,"../../lib/throttle":184,"../../plot_api/subroutines":197,"../../registry":246,"./axis_ids":209,"./constants":212,polybooljs:20}],225:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,l=i.ms2DateTime,s=i.dateTime2ms,c=i.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,d=u.BADNUM,p=u.LOG_CLIP,h=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}function y(t){return null!=t}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function u(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],a=t.range[1];return.5*(n+a-2*p*Math.abs(n-a))}return d}function m(e,r,n){var o=s(e,n||t.calendar);if(o===d){if(!a(e))return d;e=+e;var l=Math.floor(10*i.mod(e+.05,1)),c=Math.round(e-l/10);o=s(new Date(c))+l/10}return o}function x(e,r,n){return l(e,r,n||t.calendar)}function b(e){return t._categories[Math.round(e)]}function _(e){if(y(e)){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return d}function w(e){if(t._categoriesMap)return t._categoriesMap[e]}function k(t){var e=w(t);return void 0!==e?e:a(t)?+t:void 0}function T(e){return a(e)?n.round(t._b+t._m*e,2):d}function M(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=T,t.p2l=M,t.c2p="log"===t.type?function(t,e){return T(u(t,e))}:T,t.p2c="log"===t.type?function(t){return v(M(t))}:M,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=M,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(M(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=M,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=m,t.c2d=t.c2r=t.l2d=t.l2r=x,t.d2p=t.r2p=function(e,r,n){return t.l2p(m(e,0,n))},t.p2d=t.p2r=function(t,e,r){return x(M(t),e,r)},t.cleanPos=function(e){return i.cleanDate(e,d,t.calendar)}):"category"===t.type?(t.d2c=t.d2l=_,t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var r=k(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(M(t))},t.r2p=t.d2p,t.p2r=M,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}):"multicategory"===t.type&&(t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var r=k(e);return void 0!==r?r:t.fraction2r(.5)},t.r2c_just_indices=w,t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(M(t))},t.r2p=t.d2p,t.p2r=M,t.cleanPos=function(t){return Array.isArray(t)||"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,l,s=i.nestedProperty(t,e).get();if(l=(l="date"===t.type?i.dfltRange(t.calendar):"y"===r?h.DFLTRANGEY:n.dfltRange||h.DFLTRANGEX).slice(),s&&2===s.length)for("date"===t.type&&(s[0]=i.cleanDate(s[0],d,t.calendar),s[1]=i.cleanDate(s[1],d,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(s[o],t.calendar)){t[e]=l;break}if(t.r2l(s[0])===t.r2l(s[1])){var c=i.constrain(t.r2l(s[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);s[0]=t.l2r(c-1e3),s[1]=t.l2r(c+1e3);break}}else{if(!a(s[o])){if(!a(s[1-o])){t[e]=l;break}s[o]=s[1-o]*(o?10:.1)}if(s[o]<-f?s[o]=-f:s[o]>f&&(s[o]=f),s[0]===s[1]){var u=Math.max(1,Math.abs(1e-6*s[0]));s[0]-=u,s[1]+=u}}else i.nestedProperty(t,e).set(l)},t.setScale=function(n){var a=e._size;if(t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=n&&t._r?"_r":"range",l=t.calendar;t.cleanRange(o);var s=t.r2l(t[o][0],l),c=t.r2l(t[o][1],l);if("y"===r?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-c),t._b=-t._m*c):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,a,o,l,s=t.type,c="date"===s&&e[r+"calendar"];if(r in e){if(n=e[r],l=e._length||i.minRowLength(n),i.isTypedArray(n)&&("linear"===s||"log"===s)){if(l===n.length)return n;if(n.subarray)return n.subarray(0,l)}if("multicategory"===s)return function(t,e){var r,n=new Array(e),a=new Array(e),o=[[0,{}],[0,{}]];if(i.isArrayOrTypedArray(t[0])&&i.isArrayOrTypedArray(t[1])){for(r=0;r rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,r._offset).call(i.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(i.setPointGroupScale,1,1),n.selectAll(".textpoint").call(i.setTextPointsScale,1,1),n.call(i.hideOutsideRangePoints,t)}function x(e,r){var n,l,s,u=g[e.xaxis._id],f=g[e.yaxis._id],d=[];if(u){l=(n=t._fullLayout[u.axisName])._r,s=u.to,d[0]=(l[0]*(1-r)+r*s[0]-l[0])/(l[1]-l[0])*e.xaxis._length;var p=l[1]-l[0],h=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[2]=e.xaxis._length*(1-r+r*h/p)}else d[0]=0,d[2]=e.xaxis._length;if(f){l=(n=t._fullLayout[f.axisName])._r,s=f.to,d[1]=(l[1]*(1-r)+r*s[1]-l[1])/(l[0]-l[1])*e.yaxis._length;var v=l[1]-l[0],y=s[1]-s[0];n.range[0]=l[0]*(1-r)+r*s[0],n.range[1]=l[1]*(1-r)+r*s[1],d[3]=e.yaxis._length*(1-r+r*y/v)}else d[1]=0,d[3]=e.yaxis._length;!function(e,r){var n,i=[e._id,r._id];function l(e,r,a){for(n=0;nr.duration?(function(){for(var e={},r=0;r0&&(a["_"+r+"axes"]||{})[e])return a;if((a[r+"axis"]||r)===e){if(o(a,r))return a;if((a[r]||[]).length||a[r+"0"])return a}}}(e,r,l);if(!s)return;if("histogram"===s.type&&l==={v:"y",h:"x"}[s.orientation||"v"])return void(t.type="linear");var c,u=l+"calendar",f=s[u],d={noMultiCategory:!n(s,"cartesian")||n(s,"noMultiCategory")};if(o(s,l)){var p=i(s),h=[];for(c=0;c0?".":"")+i;a.isPlainObject(o)?s(o,e,l,n+1):e(l,i,o)}})}r.manageCommandObserver=function(t,e,n,o){var l={},s=!0;e&&e._commandObserver&&(l=e._commandObserver),l.cache||(l.cache={}),l.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,n,l.lookupTable);if(e&&e._commandObserver){if(c)return l;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,l}if(c){i(t,c,l.cache),l.check=function(){if(s){var e=i(t,c,l.cache);return e.changed&&o&&void 0!==l.lookupTable[e.value]&&(l.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:l.lookupTable[e.value]})).then(l.enable,l.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;f=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),r.attr(i);var o=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),a=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+a})}}(t,o),l.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),a=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,a={};function o(t){for(var r=!0,i=0;i1&&z.length>1){for(i.getComponentMethod("grid","sizeDefaults")(c,l),o=0;o15&&z.length>15&&0===l.shapes.length&&0===l.images.length,l._hasCartesian=l._has("cartesian"),l._hasGeo=l._has("geo"),l._hasGL3D=l._has("gl3d"),l._hasGL2D=l._has("gl2d"),l._hasTernary=l._has("ternary"),l._hasPie=l._has("pie"),v.linkSubplots(f,l,u,a),v.cleanPlot(f,l,u,a),h(l,a),l._preGUI||(l._preGUI={}),l._tracePreGUI||(l._tracePreGUI={});var F,B=l._tracePreGUI,j={};for(F in B)j[F]="old";for(o=0;o0){var f=1-2*l;n=Math.round(f*n),i=Math.round(f*i)}}var d=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-i)>1;(g||h)&&(h&&(r.width=n),g&&(r.height=i)),t._initialAutoSize||(t._initialAutoSize={width:n,height:i}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var a,o,l,c=i.componentsRegistry,u=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in c)(l=c[a]).includeBasePlot&&l.includeBasePlot(t,e);for(var d in u.length||u.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[d].sort(s.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var s=void 0!==r.xl?r.xl:r.x,c=void 0!==r.xr?r.xr:r.x,u=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;a[e]={l:{val:s,size:r.l+o},r:{val:c,size:r.r+o},b:{val:f,size:r.b+o},t:{val:u,size:r.t+o}},i[e]=1}else delete a[e],delete i[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),A(e);var r=e._size,n=JSON.stringify(r),o=e.margin,l=o.l,s=o.r,c=o.t,u=o.b,f=e._pushmargin,d=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var p in f)d[p]||delete f[p];for(var h in f.base={l:{val:0,size:l},r:{val:1,size:s},t:{val:1,size:c},b:{val:0,size:u}},f){var g=f[h].l||{},v=f[h].b||{},y=g.val,m=g.size,x=v.val,b=v.size;for(var _ in f){if(a(m)&&f[_].r){var w=f[_].r.val,k=f[_].r.size;if(w>y){var T=(m*w+(k-e.width)*y)/(w-y),M=(k*(1-y)+(m-e.width)*(1-w))/(w-y);T>=0&&M>=0&&T+M>l+s&&(l=T,s=M)}}if(a(b)&&f[_].t){var L=f[_].t.val,S=f[_].t.size;if(L>x){var C=(b*L+(S-e.height)*x)/(L-x),O=(S*(1-x)+(b-e.height)*(1-L))/(L-x);C>=0&&O>=0&&C+O>u+c&&(u=C,c=O)}}}}}if(r.l=Math.round(l),r.r=Math.round(s),r.t=Math.round(c),r.b=Math.round(u),r.p=Math.round(o.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,r,n,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,l=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(s.isPlainObject(t)){var e,n,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!s.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;a[e]=c(t[e])}return a}return Array.isArray(t)?t.map(c):s.isTypedArray(t)?s.simpleMap(t,s.identity):s.isJSDate(t)?s.ms2DateTimeLocal(+t):t}var u={data:(i||[]).map(function(t){var r=c(t);return e&&delete r.fit,r})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),l&&(u.frames=c(l)),"object"===n?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var r,n,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,l,c=0,u=0;function f(){return c++,function(){var r;u++,p||u!==c||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var h=t._fullLayout._basePlotModules,g=!1;if(r)for(l=0;l=0;l--)if(o[l].enabled){r._indexToPoints=o[l]._indexToPoints;break}n&&n.calc&&(i=n.calc(t,r))}Array.isArray(i)&&i[0]||(i=[{x:u,y:u}]),i[0].t||(i[0].t={}),i[0].trace=r,h[e]=i}}for(m&&L(c),a=0;a=0?d.angularAxis.domain:n.extent(k),S=Math.abs(k[1]-k[0]);M&&!T&&(S=0);var C=L.slice();A&&T&&(C[1]+=S);var O=d.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),d.angularAxis.ticksStep&&(O=(C[1]-C[0])/O);var P=d.angularAxis.ticksStep||(C[1]-C[0])/(O*(d.minorTicks+1));w&&(P=Math.max(Math.round(P),1)),C[2]||(C[2]=P);var D=n.range.apply(this,C);if(D=D.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=n.scale.linear().domain(C.slice(0,2)).range("clockwise"===d.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=A?S:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var z=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),E=this.appendChild(this.ownerDocument.importNode(z.documentElement,!0));t=n.select(E)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var R,N=t.select(".chart-group"),I={fill:"none",stroke:d.tickColor},F={"font-size":d.font.size,"font-family":d.font.family,fill:d.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+d.font.outlineColor}).join(",")};if(d.showLegend){R=t.select(".legend-group").attr({transform:"translate("+[x,d.margin.top]+")"}).style({display:"block"});var B=p.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:R,elements:B,reverseOrder:d.legend.reverseOrder})})();var j=R.node().getBBox();x=Math.min(d.width-j.width-d.margin.left-d.margin.right,d.height-d.margin.top-d.margin.bottom)/2,x=Math.max(10,x),_=[d.margin.left+x,d.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),R.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else R=t.select(".legend-group").style({display:"none"});t.attr({width:d.width,height:d.height}).style({opacity:d.opacity}),N.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(d.width-(d.margin.left+d.margin.right+2*x+(j?j.width:0)))/2,(d.height-(d.margin.top+d.margin.bottom+2*x))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),t.select(".outer-group").attr("transform","translate("+H+")"),d.title&&d.title.text){var q=t.select("g.title-group text").style(F).text(d.title.text),V=q.node().getBBox();q.attr({x:_[0]-V.width/2,y:_[1]-x-20})}var U=t.select(".radial.axis-group");if(d.radialAxis.gridLinesVisible){var G=U.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(I),G.attr("r",r),G.exit().remove()}U.select("circle.outside-circle").attr({r:x}).style(I);var Y=t.select("circle.background-circle").attr({r:x}).style({fill:d.backgroundColor,stroke:d.stroke});function X(t,e){return l(t)%360+d.orientation}if(d.radialAxis.visible){var Z=n.svg.axis().scale(r).ticks(5).tickSize(5);U.call(Z).attr({transform:"rotate("+d.radialAxis.orientation+")"}),U.selectAll(".domain").style(I),U.selectAll("g>text").text(function(t,e){return this.textContent+d.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===d.radialAxis.tickOrientation?"rotate("+-d.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),U.selectAll("g>line").style({stroke:"black"})}var W=t.select(".angular.axis-group").selectAll("g.angular-tick").data(D),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+X(t)+")"}}).style({display:d.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(d.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(d.minorTicks+1)==0)}).style(I),J.selectAll(".minor").style({stroke:d.minorTickColor}),W.select("line.grid-line").attr({x1:d.tickLength?x-d.tickLength:0,x2:x}).style({display:d.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(F);var $=W.select("text.axis-text").attr({x:x+d.labelOffset,dy:i+"em",transform:function(t,e){var r=X(t),n=x+d.labelOffset,a=d.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-r+" "+n+" 0)":"radial"==a?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:d.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(d.minorTicks+1)!=0?"":w?w[t]+d.angularAxis.ticksSuffix:t+d.angularAxis.ticksSuffix}).style(F);d.angularAxis.rewriteTicks&&$.text(function(t,e){return e%(d.minorTicks+1)!=0?"":d.angularAxis.rewriteTicks(this.textContent,e)});var Q=n.max(N.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));R.attr({transform:"translate("+[x+Q,d.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||K){var et=[];p.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=d.orientation,n.direction=d.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return a(o[r].defaultConfig(),t)});o[r]().config(n)()})}var at,it,ot=t.select(".guides-group"),lt=t.select(".tooltips-group"),st=o.tooltipPanel().config({container:lt,fontSize:8})(),ct=o.tooltipPanel().config({container:lt,fontSize:8})(),ut=o.tooltipPanel().config({container:lt,hasTick:!0})();if(!T){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});N.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(Y).angle;ft.attr({x2:-x,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-d.orientation)%360;at=l.invert(n);var a=o.util.convertToCartesian(x+12,r+180);st.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var dt=ot.select("circle").style({stroke:"grey",fill:"none"});N.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(Y).radius;dt.attr({r:n}).style({opacity:.5}),it=r.invert(o.util.getMousePos(Y).radius);var a=o.util.convertToCartesian(n,d.radialAxis.orientation);ct.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){dt.style({opacity:0}),ut.hide(),st.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var a=n.select(this),i=this.style.fill,l="black",s=this.style.opacity||1;if(a.attr({"data-opacity":s}),i&&"none"!==i){a.attr({"data-fill":i}),l=n.hsl(i).darker().toString(),a.style({fill:l,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};T&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=t.node().getBoundingClientRect(),p=[f.left+f.width/2-H[0]-d.left,f.top+f.height/2-H[1]-d.top];ut.config({color:l}).text(u),ut.move(p)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),l=n.hsl(i).darker().toString(),a.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var r=n.select(this),a=r.attr("data-fill");a?r.style({fill:a,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(c),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),a(s.data[e],o.Axis.defaultConfig().data[0]),a(s.data[e],t)}),a(s.layout,o.Axis.defaultConfig().layout),a(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return t},n.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var a=e||6,i=[],o=[];n.range(0,360+a,a).forEach(function(e,r){var n=e*Math.PI/180,a=t(n);i.push(e),o.push(a)});var l={t:i,r:o};return r&&(l.name=r),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],a=e[1],i={};return i.x=r,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,r)+Math.PI)/Math.PI,i.radius=Math.sqrt(r*r+a*a),i},o.util.duplicatesCount=function(t){for(var e,r={},n={},a=0,i=t.length;a0)){var s=n.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({class:"line",d:u(l),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return h.fill(r,a,i)},"fill-opacity":0,stroke:function(t,e){return h.stroke(r,a,i)},"stroke-width":function(t,e){return h["stroke-width"](r,a,i)},"stroke-dasharray":function(t,e){return h["stroke-dasharray"](r,a,i)},opacity:function(t,e){return h.opacity(r,a,i)},display:function(t,e){return h.display(r,a,i)}})}};var f=e.angularScale.range(),d=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=n.svg.arc().startAngle(function(t){return-d/2}).endAngle(function(t){return d/2}).innerRadius(function(t){return e.radialScale(s+(t[2]||0))}).outerRadius(function(t){return e.radialScale(s+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,r,a){n.select(this).attr({class:"mark arc",d:p,transform:function(t,r){return"rotate("+(e.orientation+l(t[0])+90)+")"}})};var h={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,a){return r[t[a].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(h).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),a(t[r],o.PolyChart.defaultConfig()),a(t[r],e)}),this):t},i.getColorScale=function(){},n.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,i=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var i=a({},e.elements[r]);return i.name=t,i.color=[].concat(e.elements[r].color)[n],i})}),o=n.merge(i);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var l=e.container;("string"==typeof l||l.nodeName)&&(l=n.select(l));var s=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,d=l.classed("legend-group",!0).selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var h=n.range(o.length),g=n.scale[u?"linear":"ordinal"]().domain(h).range(s),v=n.scale[u?"linear":"ordinal"]().domain(h)[u?"range":"rangePoints"]([0,f]);if(u){var y=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var m=d.select(".legend-marks").selectAll("path.legend-mark").data(o);m.enter().append("path").classed("legend-mark",!0),m.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var r,a,i,o=t.symbol;return i=3*(a=c),"line"===(r=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(i)():n.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),m.exit().remove()}var x=n.svg.axis().scale(v).orient("right"),b=d.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(a(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){var n=(t=i.container.selectAll("g."+l).data([0])).enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:i.padding+s,dy:.3*+i.fontSize}),c};return c.text=function(a){var o=n.hsl(i.color).l,l=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":i.fontSize+"px"}).text(f);var d=i.padding,p=e.node().getBBox(),h={fill:i.color,stroke:l,"stroke-width":"2px"},g=p.width+2*d+s,v=p.height+2*d;return r.attr({d:"M"+[[s,-v/2],[s,-v/4],[i.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(h),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return a(i,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=a({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=i.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var l=a({},t.layout);if([[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var s=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(l.margin).forEach(function(t,e){u[c[s.indexOf(t.key)]]=t.value}),l.margin=u}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),r.layout=l}return r}};return t}},{"../../../constants/alignment":141,"../../../lib":162,d3:11}],244:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),l=t("./undo_manager"),s=a.extendDeepAll,c=e.exports={};c.framework=function(t){var e,r,a,i,u,f=new l;function d(r,l){return l&&(u=l),n.select(n.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?s(e,r):r,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return d.isPolar=!0,d.svg=function(){return a.svg()},d.getConfig=function(){return e},d.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},d.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},d.setUndoPoint=function(){var t,n,a=this,i=o.util.cloneJson(e);t=i,n=r,f.add({undo:function(){n&&a(n)},redo:function(){a(t)}}),r=o.util.cloneJson(i)},d.undo=function(){f.undo()},d.redo=function(){f.redo()},d},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../../components/color":46,"../../../lib":162,"./micropolar":243,"./undo_manager":245,d3:11}],245:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function a(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(a(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(a(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r-1&&(u[d[r]].title={text:""});for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(s,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(s,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||d.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),d.node().setAttributeNS(l.xmlns,"xmlns",l.svg),d.node().setAttributeNS(l.xmlns,"xmlns:xlink",l.xlink),"svg"===e&&r&&(d.attr("width",r*h),d.attr("height",r*g),d.attr("viewBox","0 0 "+h+" "+g));var _=(new window.XMLSerializer).serializeToString(d.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":46,"../components/drawing":67,"../constants/xmlns_namespaces":144,"../lib":162,d3:11}],255:[function(t,e,r){"use strict";var n=t("../../lib").mergeArray;e.exports=function(t,e){for(var r=0;rf+c||!n(u))&&(p=!0,g(d,t))}for(var v=0;vi))return e}return void 0!==r?r:t.dflt},r.coerceColor=function(t,e,r){return a(e).isValid()?e:void 0!==r?r:t.dflt},r.coerceEnumerated=function(t,e,r){return t.coerceNumber&&(e=+e),-1!==t.values.indexOf(e)?e:void 0!==r?r:t.dflt},r.getValue=function(t,e){var r;return Array.isArray(t)?e.01?C:function(t,e){return Math.abs(t-e)>=2?C(t):t>e?Math.ceil(t):Math.floor(t)};_=S(_,w),w=S(w,_),k=S(k,T),T=S(T,k)}i.ensureSingle(M,"path").style("vector-effect","non-scaling-stroke").attr("d","M"+_+","+k+"V"+T+"H"+w+"V"+k+"Z").call(s.setClipUrl,e.layerClipId,t),function(t,e,r,n,a,l,c,u){var y;function m(e,r,n){var a=i.ensureSingle(e,"text").text(r).attr({class:"bartext bartext-"+y,transform:"","text-anchor":"middle","data-notex":1}).call(s.font,n).call(o.convertToTspans,t);return a}var x=r[0].trace,b=x.orientation,_=function(t,e){var r=p.getValue(t.text,e);return p.coerceString(f,r)}(x,n);if(y=function(t,e){var r=p.getValue(t.textposition,e);return p.coerceEnumerated(d,r)}(x,n),!_||"none"===y)return void e.select("text").remove();var w,k,T,M,A,L,S=t._fullLayout.font,C=h.getBarColor(r[n],x),O=h.getInsideTextFont(x,n,S,C),P=h.getOutsideTextFont(x,n,S),D=t._fullLayout.barmode,z="relative"===D,E="stack"===D||z,R=r[n],N=!E||R._outmost,I=Math.abs(l-a)-2*g,F=Math.abs(u-c)-2*g;"outside"===y&&(N||R.hasB||(y="inside"));if("auto"===y)if(N){y="inside",w=m(e,_,O),k=s.bBox(w.node()),T=k.width,M=k.height;var B=T>0&&M>0,j=T<=I&&M<=F,H=T<=F&&M<=I,q="h"===b?I>=T*(F/M):F>=M*(I/T);B&&(j||H||q)?y="inside":(y="outside",w.remove(),w=null)}else y="inside";if(!w&&(w=m(e,_,"outside"===y?P:O),k=s.bBox(w.node()),T=k.width,M=k.height,T<=0||M<=0))return void w.remove();"outside"===y?(L="both"===x.constraintext||"outside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s="h"===i?Math.abs(n-r):Math.abs(e-t);s>2*g&&(l=g);var c=1;o&&(c="h"===i?Math.min(1,s/a.height):Math.min(1,s/a.width));var u,f,d,p,h=(a.left+a.right)/2,y=(a.top+a.bottom)/2;u=c*a.width,f=c*a.height,"h"===i?er?(d=(t+e)/2,p=n+l+f/2):(d=(t+e)/2,p=n-l-f/2);return v(h,y,d,p,c,!1)}(a,l,c,u,k,b,L)):(L="both"===x.constraintext||"inside"===x.constraintext,A=function(t,e,r,n,a,i,o){var l,s,c,u,f,d,p,h=a.width,y=a.height,m=(a.left+a.right)/2,x=(a.top+a.bottom)/2,b=Math.abs(e-t),_=Math.abs(n-r);b>2*g&&_>2*g?(b-=2*(f=g),_-=2*f):f=0;h<=b&&y<=_?(d=!1,p=1):h<=_&&y<=b?(d=!0,p=1):hr?(c=(t+e)/2,u=n-f-s/2):(c=(t+e)/2,u=n+f+s/2);return v(m,x,c,u,p,d)}(a,l,c,u,k,b,L));w.attr("transform",A)}(t,M,r,u,_,w,k,T),e.layerClipId&&s.hideOutsideRangePoint(c,M.select("text"),y,m,b.xcalendar,b.ycalendar)}else M.remove();function C(t){return 0===x.bargap&&0===x.bargroupgap?n.round(Math.round(t)-L,2):t}});var w=!1===u.trace.cliponaxis;s.setClipUrl(c,w?null:e.layerClipId,t)});c.getComponentMethod("errorbars","plot")(t,b,e)}},{"../../components/color":46,"../../components/drawing":67,"../../lib":162,"../../lib/svg_text_utils":183,"../../registry":246,"./attributes":256,"./helpers":261,"./style":269,d3:11,"fast-isnumeric":13}],267:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,a=t.xaxis,i=t.yaxis,o=[];if(!1===e)for(r=0;r1||0===i.bargap&&0===i.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),r.selectAll("g.points").each(function(e){p(n.select(this),e[0].trace,t)}),l.getComponentMethod("errorbars","style")(r)},styleOnSelect:function(t,e){var r=e[0].node3,a=e[0].trace;a.selectedpoints?function(t,e,r){i.selectedPointStyle(t.selectAll("path"),e),function(t,e,r){t.each(function(t){var a,l=n.select(this);if(t.selected){a=o.extendFlat({},h(l,t,e,r));var s=e.selected.textfont&&e.selected.textfont.color;s&&(a.color=s),i.font(l,a)}else i.selectedTextStyle(l,e)})}(t.selectAll("text"),e,r)}(r,a,t):p(r,a,t)},getInsideTextFont:v,getOutsideTextFont:y,getBarColor:x}},{"../../components/color":46,"../../components/drawing":67,"../../lib":162,"../../registry":246,"./attributes":256,"./helpers":261,d3:11}],270:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l){r("marker.color",o),a(t,"marker")&&i(t,e,l,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),a(t,"marker.line")&&i(t,e,l,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":46,"../../components/colorscale/defaults":56,"../../components/colorscale/helpers":57}],271:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),a=t("../../components/color/attributes"),i=t("../../lib/extend").extendFlat,o=n.marker,l=o.line;e.exports={y:{valType:"data_array",editType:"calc+clearAxisTypes"},x:{valType:"data_array",editType:"calc+clearAxisTypes"},x0:{valType:"any",editType:"calc+clearAxisTypes"},y0:{valType:"any",editType:"calc+clearAxisTypes"},name:{valType:"string",editType:"calc+clearAxisTypes"},text:i({},n.text,{}),whiskerwidth:{valType:"number",min:0,max:1,dflt:.5,editType:"calc"},notched:{valType:"boolean",editType:"calc"},notchwidth:{valType:"number",min:0,max:.5,dflt:.25,editType:"calc"},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers",editType:"calc"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1,editType:"calc"},jitter:{valType:"number",min:0,max:1,editType:"calc"},pointpos:{valType:"number",min:-2,max:2,editType:"calc"},orientation:{valType:"enumerated",values:["v","h"],editType:"calc+clearAxisTypes"},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)",editType:"style"},symbol:i({},o.symbol,{arrayOk:!1,editType:"plot"}),opacity:i({},o.opacity,{arrayOk:!1,dflt:1,editType:"style"}),size:i({},o.size,{arrayOk:!1,editType:"calc"}),color:i({},o.color,{arrayOk:!1,editType:"style"}),line:{color:i({},l.color,{arrayOk:!1,dflt:a.defaultLine,editType:"style"}),width:i({},l.width,{arrayOk:!1,dflt:0,editType:"style"}),outliercolor:{valType:"color",editType:"style"},outlierwidth:{valType:"number",min:0,dflt:1,editType:"style"},editType:"style"},editType:"plot"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,selected:{marker:n.selected.marker,editType:"style"},unselected:{marker:n.unselected.marker,editType:"style"},hoveron:{valType:"flaglist",flags:["boxes","points"],dflt:"boxes+points",editType:"style"}}},{"../../components/color/attributes":45,"../../lib/extend":156,"../scatter/attributes":316}],272:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),a=t("../../lib"),i=["v","h"];function o(t,e,r,i,o){var l,s,c,u=e.calcdata,f=e._fullLayout,d=[],p="violin"===t?"_numViolins":"_numBoxes";for(l=0;lt.uf}),s=Math.max((t.max-t.min)/10,t.q3-t.q1),c=1e-9*s,p=s*l,h=[],g=0;if(r.jitter){if(0===s)for(g=1,h=new Array(i.length),e=0;et.lo&&(_.so=!0)}return i});h.enter().append("path").classed("point",!0),h.exit().remove(),h.call(i.translatePoints,s,c)}function u(t,e,r,i){var o,l,s=e.pos,c=e.val,u=i.bPos,f=i.bPosPxOffset||0,d=r.boxmean||(r.meanline||{}).visible;Array.isArray(i.bdPos)?(o=i.bdPos[0],l=i.bdPos[1]):(o=i.bdPos,l=i.bdPos);var p=t.selectAll("path.mean").data("box"===r.type&&r.boxmean||"violin"===r.type&&r.box.visible&&r.meanline.visible?a.identity:[]);p.enter().append("path").attr("class","mean").style({fill:"none","vector-effect":"non-scaling-stroke"}),p.exit().remove(),p.each(function(t){var e=s.c2p(t.pos+u,!0)+f,a=s.c2p(t.pos+u-o,!0)+f,i=s.c2p(t.pos+u+l,!0)+f,p=c.c2p(t.mean,!0),h=c.c2p(t.mean-t.sd,!0),g=c.c2p(t.mean+t.sd,!0);"h"===r.orientation?n.select(this).attr("d","M"+p+","+a+"V"+i+("sd"===d?"m0,0L"+h+","+e+"L"+p+","+a+"L"+g+","+e+"Z":"")):n.select(this).attr("d","M"+a+","+p+"H"+i+("sd"===d?"m0,0L"+e+","+h+"L"+a+","+p+"L"+e+","+g+"Z":""))})}e.exports={plot:function(t,e,r,i){var o=t._fullLayout,l=e.xaxis,f=e.yaxis,d=o._numBoxes,p=1-o.boxgap,h="group"===o.boxmode&&d>1;a.makeTraceGroups(i,r,"trace boxes").each(function(t){var r=n.select(this),a=t[0],i=a.t,g=a.trace;e.isRangePlot||(a.node3=r);var v,y,m=i.dPos*p*(1-o.boxgroupgap)/(h?d:1),x=h?2*i.dPos*((i.num+.5)/d-.5)*p:0,b=m*g.whiskerwidth;!0!==g.visible||i.empty?r.remove():("h"===g.orientation?(v=f,y=l):(v=l,y=f),i.bPos=x,i.bdPos=m,i.wdPos=b,i.wHover=i.dPos*(h?p/d:1),s(r,{pos:v,val:y},g,i),c(r,{x:l,y:f},g,i),u(r,{pos:v,val:y},g,i))})},plotBoxAndWhiskers:s,plotPoints:c,plotBoxMean:u}},{"../../components/drawing":67,"../../lib":162,d3:11}],276:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../components/color"),i=t("../../components/drawing");e.exports={style:function(t,e){var r=e?e[0].node3:n.select(t).selectAll("g.trace.boxes");r.style("opacity",function(t){return t[0].trace.opacity}),r.each(function(e){var r=n.select(this),o=e[0].trace,l=o.line.width;function s(t,e,r,n){t.style("stroke-width",e+"px").call(a.stroke,r).call(a.fill,n)}var c=r.selectAll("path.box");if("candlestick"===o.type)c.each(function(t){var e=n.select(this),r=o[t.dir];s(e,r.line.width,r.line.color,r.fillcolor),e.style("opacity",o.selectedpoints&&!t.selected?.3:1)});else{s(c,l,o.line.color,o.fillcolor),r.selectAll("path.mean").style({"stroke-width":l,"stroke-dasharray":2*l+"px,"+l+"px"}).call(a.stroke,o.line.color);var u=r.selectAll("path.point");i.pointStyle(u,o,t)}})},styleOnSelect:function(t,e){var r=e[0].node3,n=e[0].trace,a=r.selectAll("path.point");n.selectedpoints?i.selectedPointStyle(a,n):i.pointStyle(a,n,t)}}},{"../../components/color":46,"../../components/drawing":67,d3:11}],277:[function(t,e,r){"use strict";var n=t("../../lib").extendFlat,a=t("../ohlc/attributes"),i=t("../box/attributes");function o(t){return{line:{color:n({},i.line.color,{dflt:t}),width:i.line.width,editType:"style"},fillcolor:i.fillcolor,editType:"style"}}e.exports={x:a.x,open:a.open,high:a.high,low:a.low,close:a.close,line:{width:n({},i.line.width,{}),editType:"style"},increasing:o(a.increasing.line.color.dflt),decreasing:o(a.decreasing.line.color.dflt),text:a.text,whiskerwidth:n({},i.whiskerwidth,{dflt:0}),hoverlabel:a.hoverlabel}},{"../../lib":162,"../box/attributes":271,"../ohlc/attributes":294}],278:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("../ohlc/calc").calcCommon;function o(t,e,r,n){return{min:r,q1:Math.min(t,n),med:n,q3:Math.max(t,n),max:e}}e.exports=function(t,e){var r=t._fullLayout,l=a.getFromId(t,e.xaxis),s=a.getFromId(t,e.yaxis),c=l.makeCalcdata(e,"x"),u=i(t,e,c,s,o);return u.length?(n.extendFlat(u[0].t,{num:r._numBoxes,dPos:n.distinctVals(c).minDiff/2,posLetter:"x",valLetter:"y"}),r._numBoxes++,u):[{t:{empty:!0}}]}},{"../../lib":162,"../../plots/cartesian/axes":206,"../ohlc/calc":295}],279:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../components/color"),i=t("../ohlc/ohlc_defaults"),o=t("./attributes");function l(t,e,r,n){var i=r(n+".line.color");r(n+".line.width",e.line.width),r(n+".fillcolor",a.addOpacity(i,.5))}e.exports=function(t,e,r,a){function s(r,a){return n.coerce(t,e,o,r,a)}i(t,e,s,a)?(s("line.width"),l(t,e,s,"increasing"),l(t,e,s,"decreasing"),s("text"),s("whiskerwidth"),a._requestRangeslider[e.xaxis]=!0):e.visible=!1}},{"../../components/color":46,"../../lib":162,"../ohlc/ohlc_defaults":299,"./attributes":277}],280:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"candlestick",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","showLegend","candlestick","boxLayout"],meta:{},attributes:t("./attributes"),layoutAttributes:t("../box/layout_attributes"),supplyLayoutDefaults:t("../box/layout_defaults").supplyLayoutDefaults,crossTraceCalc:t("../box/cross_trace_calc").crossTraceCalc,supplyDefaults:t("./defaults"),calc:t("./calc"),plot:t("../box/plot").plot,layerName:"boxlayer",style:t("../box/style").style,hoverPoints:t("../ohlc/hover").hoverPoints,selectPoints:t("../ohlc/select")}},{"../../plots/cartesian":218,"../box/cross_trace_calc":272,"../box/layout_attributes":273,"../box/layout_defaults":274,"../box/plot":275,"../box/style":276,"../ohlc/hover":297,"../ohlc/select":301,"./attributes":277,"./calc":278,"./defaults":279}],281:[function(t,e,r){"use strict";var n=t("../bar/attributes"),a=t("../../components/fx/hovertemplate_attributes"),i=t("./bin_attributes"),o=t("./constants");e.exports={x:{valType:"data_array",editType:"calc+clearAxisTypes"},y:{valType:"data_array",editType:"calc+clearAxisTypes"},text:n.text,orientation:n.orientation,histfunc:{valType:"enumerated",values:["count","sum","avg","min","max"],dflt:"count",editType:"calc"},histnorm:{valType:"enumerated",values:["","percent","probability","density","probability density"],dflt:"",editType:"calc"},cumulative:{enabled:{valType:"boolean",dflt:!1,editType:"calc"},direction:{valType:"enumerated",values:["increasing","decreasing"],dflt:"increasing",editType:"calc"},currentbin:{valType:"enumerated",values:["include","exclude","half"],dflt:"include",editType:"calc"},editType:"calc"},nbinsx:{valType:"integer",min:0,dflt:0,editType:"calc"},xbins:i("x",!0),nbinsy:{valType:"integer",min:0,dflt:0,editType:"calc"},ybins:i("y",!0),autobinx:{valType:"boolean",dflt:null,editType:"calc"},autobiny:{valType:"boolean",dflt:null,editType:"calc"},hovertemplate:a({},{keys:o.eventDataKeys}),marker:n.marker,selected:n.selected,unselected:n.unselected,_deprecated:{bardir:n._deprecated.bardir}}},{"../../components/fx/hovertemplate_attributes":84,"../bar/attributes":256,"./bin_attributes":283,"./constants":287}],282:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=t.length,n=0,a=0;ai){var o=i-r[t];return r[t]=i,o}}return 0},max:function(t,e,r,a){var i=a[e];if(n(i)){if(i=Number(i),!n(r[t]))return r[t]=i,i;if(r[t]c?t>o?t>1.1*a?a:t>1.1*i?i:o:t>l?l:t>s?s:c:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function p(t,e,r,n,i,l){if(n&&t>o){var s=h(e,i,l),c=h(r,i,l),u=t===a?0:1;return s[u]!==c[u]}return Math.floor(r/t)-Math.floor(e/t)>.1}function h(t,e,r){var n=e.c2d(t,a,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}e.exports=function(t,e,r,n,i){var l,s,c=-1.1*e,d=-.1*e,p=t-d,h=r[0],g=r[1],v=Math.min(f(h+d,h+p,n,i),f(g+d,g+p,n,i)),y=Math.min(f(h+c,h+d,n,i),f(g+c,g+d,n,i));if(v>y&&yo){var m=l===a?1:6,x=l===a?"M12":"M1";return function(e,r){var o=n.c2d(e,a,i),l=o.indexOf("-",m);l>0&&(o=o.substr(0,l));var c=n.d2c(o,0,i);if(cr.r2l(P)&&(z=i.tickIncrement(z,_.size,!0,d)),L.start=r.l2r(z),O||a.nestedProperty(e,v+".start").set(L.start)}var E=_.end,R=r.r2l(A.end),N=void 0!==R;if((_.endFound||N)&&R!==r.r2l(E)){var I=N?R:a.aggNums(Math.max,null,p);L.end=r.l2r(I),N||a.nestedProperty(e,v+".start").set(L.end)}var F="autobin"+o;return!1===e._input[F]&&(e._input[v]=a.extendFlat({},e[v]||{}),delete e._input[F],delete e[F]),[L,p]}e.exports=function(t,e){if(!0===e.visible){var r,d,p,h,g=[],v=[],y=i.getFromId(t,"h"===e.orientation?e.yaxis||"y":e.xaxis||"x"),m="h"===e.orientation?"y":"x",x={x:"y",y:"x"}[m],b=e[m+"calendar"],_=e.cumulative,w=f(t,e,y,m),k=w[0],T=w[1],M="string"==typeof k.size,A=[],L=M?A:k,S=[],C=[],O=[],P=0,D=e.histnorm,z=e.histfunc,E=-1!==D.indexOf("density");_.enabled&&E&&(D=D.replace(/ ?density$/,""),E=!1);var R,N="max"===z||"min"===z?null:0,I=l.count,F=s[D],B=!1,j=function(t){return y.r2c(t,0,b)};for(a.isArrayOrTypedArray(e[x])&&"count"!==z&&(R=e[x],B="avg"===z,I=l[z]),r=j(k.start),p=j(k.end)+(r-i.tickIncrement(r,k.size,!1,b))/1e6;r=0&&h=0;n--)l(n);else if("increasing"===e){for(n=1;n=0;n--)t[n]+=t[n+1];"exclude"===r&&(t.push(0),t.shift())}}(v,_.direction,_.currentbin);var Z=Math.min(g.length,v.length),W=[],J=0,$=Z-1;for(r=0;r=J;r--)if(v[r]){$=r;break}for(r=J;r<=$;r++)if(n(g[r])&&n(v[r])){var Q={p:g[r],s:v[r],b:0};_.enabled||(Q.pts=O[r],V?Q.ph0=Q.ph1=O[r].length?T[O[r][0]]:g[r]:(Q.ph0=H(A[r]),Q.ph1=H(A[r+1],!0))),W.push(Q)}return 1===W.length&&(W[0].width1=i.tickIncrement(W[0].p,k.size,!1,b)-W[0].p),o(W,e),a.isArrayOrTypedArray(e.selectedpoints)&&a.tagSelected(W,e,Y),W}}},{"../../lib":162,"../../plots/cartesian/axes":206,"../bar/arrays_to_calcdata":255,"./average":282,"./bin_functions":284,"./bin_label_vals":285,"./norm_functions":293,"fast-isnumeric":13}],287:[function(t,e,r){"use strict";e.exports={eventDataKeys:["binNumber"]}},{}],288:[function(t,e,r){"use strict";var n=t("../../lib"),a=n.nestedProperty,i=t("./attributes"),o={x:[{aStr:"xbins.start",name:"start"},{aStr:"xbins.end",name:"end"},{aStr:"xbins.size",name:"size"},{aStr:"nbinsx",name:"nbins"}],y:[{aStr:"ybins.start",name:"start"},{aStr:"ybins.end",name:"end"},{aStr:"ybins.size",name:"size"},{aStr:"nbinsy",name:"nbins"}]};e.exports=function(t,e){var r,l,s,c,u,f,d,p=e._histogramBinOpts={},h="overlay"===e.barmode;function g(t){return n.coerce(s._input,s,i,t)}for(r=0;rg):h=w>x,g=w;var k=s(x,b,_,w);k.pos=m,k.yc=(x+w)/2,k.i=y,k.dir=h?"increasing":"decreasing",p&&(k.tx=e.text[y]),v.push(k)}}return e._extremes[l._id]=i.findExtremes(l,n.concat(f,u),{padded:!0}),v.length&&(v[0].t={labels:{open:a(t,"open:")+" ",high:a(t,"high:")+" ",low:a(t,"low:")+" ",close:a(t,"close:")+" "}}),v}e.exports={calc:function(t,e){var r=i.getFromId(t,e.xaxis),a=i.getFromId(t,e.yaxis),o=function(t,e,r){var a=r._minDiff;if(!a){var i,o=t._fullData,l=[];for(a=1/0,i=0;i"+u.labels[x]+n.hoverLabelText(l,b):((m=a.extendFlat({},d)).y0=m.y1=_,m.yLabelVal=b,m.yLabel=u.labels[x]+n.hoverLabelText(l,b),m.name="",f.push(m),v[b]=m)}return f}function f(t,e,r,a){var i=t.cd,o=t.ya,u=i[0].trace,f=i[0].t,d=c(t,e,r,a);if(!d)return[];var p=i[d.index],h=d.index=p.i,g=p.dir;function v(t){return f.labels[t]+n.hoverLabelText(o,u[t][h])}var y=p.hi||u.hoverinfo,m=y.split("+"),x="all"===y,b=x||-1!==m.indexOf("y"),_=x||-1!==m.indexOf("text"),w=b?[v("open"),v("high"),v("low"),v("close")+" "+s[g]]:[];return _&&l(p,u,w),d.extraText=w.join("
"),d.y0=d.y1=o.c2p(p.yc,!0),[d]}e.exports={hoverPoints:function(t,e,r,n){return t.cd[0].trace.hoverlabel.split?u(t,e,r,n):f(t,e,r,n)},hoverSplit:u,hoverOnPoints:f}},{"../../components/color":46,"../../components/fx":85,"../../lib":162,"../../plots/cartesian/axes":206,"../scatter/fill_hover_text":324}],298:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"ohlc",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","showLegend"],meta:{},attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("./calc").calc,plot:t("./plot"),style:t("./style"),hoverPoints:t("./hover").hoverPoints,selectPoints:t("./select")}},{"../../plots/cartesian":218,"./attributes":294,"./calc":295,"./defaults":296,"./hover":297,"./plot":300,"./select":301,"./style":302}],299:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib");e.exports=function(t,e,r,i){var o=r("x"),l=r("open"),s=r("high"),c=r("low"),u=r("close");if(r("hoverlabel.split"),n.getComponentMethod("calendars","handleTraceDefaults")(t,e,["x"],i),l&&s&&c&&u){var f=Math.min(l.length,s.length,c.length,u.length);return o&&(f=Math.min(f,a.minRowLength(o))),e._length=f,f}}},{"../../lib":162,"../../registry":246}],300:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib");e.exports=function(t,e,r,i){var o=e.xaxis,l=e.yaxis;a.makeTraceGroups(i,r,"trace ohlc").each(function(t){var r=n.select(this),i=t[0],s=i.t,c=i.trace;if(e.isRangePlot||(i.node3=r),!0!==c.visible||s.empty)r.remove();else{var u=s.tickLen,f=r.selectAll("path").data(a.identity);f.enter().append("path"),f.exit().remove(),f.attr("d",function(t){var e=o.c2p(t.pos,!0),r=o.c2p(t.pos-u,!0),n=o.c2p(t.pos+u,!0);return"M"+r+","+l.c2p(t.o,!0)+"H"+e+"M"+e+","+l.c2p(t.h,!0)+"V"+l.c2p(t.l,!0)+"M"+n+","+l.c2p(t.c,!0)+"H"+e})}})}},{"../../lib":162,d3:11}],301:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,a=t.xaxis,i=t.yaxis,o=[],l=n[0].t.bPos||0;if(!1===e)for(r=0;r")}}return v},r.crossTraceCalc=function(t){var e=t._fullLayout,r=t.calcdata,n=e.piecolorway,a=e._piecolormap;e.extendpiecolors&&(n=function(t){var e,r=JSON.stringify(t),n=s[r];if(!n){for(n=t.slice(),e=0;e0?1:-1)/2,y:i/(1+r*r/(n*n)),outside:!0}}function p(t,e){var r=t.trace,n=e.h*(r.domain.y[1]-r.domain.y[0]);return Math.min(t.titleBox.height,n/2)}function h(t){var e,r=t.pull;if(Array.isArray(r))for(r=0,e=0;er&&(r=t.pull[e]);return r}e.exports=function(t,e){var r=t._fullLayout;!function(t,e){for(var r,n,a=0;aa.vTotal/2?1:0)}(e),g.attr("stroke-linejoin","round"),g.each(function(){var g=n.select(this).selectAll("g.slice").data(e);g.enter().append("g").classed("slice",!0),g.exit().remove();var m=[[[],[]],[[],[]]],x=!1;g.each(function(e){if(e.hidden)n.select(this).selectAll("path,g").remove();else{e.pointNumber=e.i,e.curveNumber=y.index,m[e.pxmid[1]<0?0:1][e.pxmid[0]<0?0:1].push(e);var p=v.cx,h=v.cy,g=n.select(this),b=g.selectAll("path.surface").data([e]),_=!1,w=!1;if(b.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),g.select("path.textline").remove(),g.on("mouseover",function(){var i=t._fullLayout,o=t._fullData[y.index];if(!t._dragging&&!1!==i.hovermode){var l=o.hoverinfo;if(Array.isArray(l)&&(l=a.castHoverinfo({hoverinfo:[c.castOption(l,e.pts)],_module:y._module},i,0)),"all"===l&&(l="label+text+value+percent+name"),o.hovertemplate||"none"!==l&&"skip"!==l&&l){var s=f(e,v),d=p+e.pxmid[0]*(1-s),g=h+e.pxmid[1]*(1-s),m=r.separators,x=[];if(l&&-1!==l.indexOf("label")&&x.push(e.label),e.text=c.castOption(o.hovertext||o.text,e.pts),l&&-1!==l.indexOf("text")){var b=e.text;b&&x.push(b)}e.value=e.v,e.valueLabel=c.formatPieValue(e.v,m),l&&-1!==l.indexOf("value")&&x.push(e.valueLabel),e.percent=e.v/v.vTotal,e.percentLabel=c.formatPiePercent(e.percent,m),l&&-1!==l.indexOf("percent")&&x.push(e.percentLabel);var k=y.hoverlabel,T=k.font;a.loneHover({x0:d-s*v.r,x1:d+s*v.r,y:g,text:x.join("
"),name:o.hovertemplate||-1!==l.indexOf("name")?o.name:void 0,idealAlign:e.pxmid[0]<0?"left":"right",color:c.castOption(k.bgcolor,e.pts)||e.color,borderColor:c.castOption(k.bordercolor,e.pts),fontFamily:c.castOption(T.family,e.pts),fontSize:c.castOption(T.size,e.pts),fontColor:c.castOption(T.color,e.pts),trace:o,hovertemplate:c.castOption(o.hovertemplate,e.pts),hovertemplateLabels:e,eventData:[u(e,o)]},{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:t}),_=!0}t.emit("plotly_hover",{points:[u(e,o)],event:n.event}),w=!0}}).on("mouseout",function(r){var i=t._fullLayout,o=t._fullData[y.index];w&&(r.originalEvent=n.event,t.emit("plotly_unhover",{points:[u(e,o)],event:n.event}),w=!1),_&&(a.loneUnhover(i._hoverlayer.node()),_=!1)}).on("click",function(){var r=t._fullLayout,i=t._fullData[y.index];t._dragging||!1===r.hovermode||(t._hoverdata=[u(e,i)],a.click(t,n.event))}),y.pull){var k=+c.castOption(y.pull,e.pts)||0;k>0&&(p+=k*e.pxmid[0],h+=k*e.pxmid[1])}e.cxFinal=p,e.cyFinal=h;var T=y.hole;if(e.v===v.vTotal){var M="M"+(p+e.px0[0])+","+(h+e.px0[1])+O(e.px0,e.pxmid,!0,1)+O(e.pxmid,e.px0,!0,1)+"Z";T?b.attr("d","M"+(p+T*e.px0[0])+","+(h+T*e.px0[1])+O(e.px0,e.pxmid,!1,T)+O(e.pxmid,e.px0,!1,T)+"Z"+M):b.attr("d",M)}else{var A=O(e.px0,e.px1,!0,1);if(T){var L=1-T;b.attr("d","M"+(p+T*e.px1[0])+","+(h+T*e.px1[1])+O(e.px1,e.px0,!1,T)+"l"+L*e.px0[0]+","+L*e.px0[1]+A+"Z")}else b.attr("d","M"+p+","+h+"l"+e.px0[0]+","+e.px0[1]+A+"Z")}var S=c.castOption(y.textposition,e.pts),C=g.selectAll("g.slicetext").data(e.text&&"none"!==S?[0]:[]);C.enter().append("g").classed("slicetext",!0),C.exit().remove(),C.each(function(){var r=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});r.text(e.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(o.font,"outside"===S?function(t,e,r){var n=c.castOption(t.outsidetextfont.color,e.pts)||c.castOption(t.textfont.color,e.pts)||r.color,a=c.castOption(t.outsidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,i=c.castOption(t.outsidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n,family:a,size:i}}(y,e,t._fullLayout.font):function(t,e,r){var n=c.castOption(t.insidetextfont.color,e.pts);!n&&t._input.textfont&&(n=c.castOption(t._input.textfont.color,e.pts));var a=c.castOption(t.insidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,o=c.castOption(t.insidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n||i.contrast(e.color),family:a,size:o}}(y,e,t._fullLayout.font)).call(s.convertToTspans,t);var a,u=o.bBox(r.node());"outside"===S?a=d(u,e):(a=function(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,i=Math.PI*Math.min(e.v/r.vTotal,.5),o=1-r.trace.hole,l=f(e,r),s={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(s.scale>=1)return s;var c=a+1/(2*Math.tan(i)),u=r.r*Math.min(1/(Math.sqrt(c*c+.5)+c),o/(Math.sqrt(a*a+o/2)+a)),d={scale:2*u/t.height,rCenter:Math.cos(u/r.r)-u*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},p=1/a,h=p+1/(2*Math.tan(i)),g=r.r*Math.min(1/(Math.sqrt(h*h+.5)+h),o/(Math.sqrt(p*p+o/2)+p)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},y=v.scale>d.scale?v:d;return s.scale<1&&y.scale>s.scale?y:s}(u,e,v),"auto"===S&&a.scale<1&&(r.call(o.font,y.outsidetextfont),y.outsidetextfont.family===y.insidetextfont.family&&y.outsidetextfont.size===y.insidetextfont.size||(u=o.bBox(r.node())),a=d(u,e)));var g=p+e.pxmid[0]*a.rCenter+(a.x||0),m=h+e.pxmid[1]*a.rCenter+(a.y||0);a.outside&&(e.yLabelMin=m-u.height/2,e.yLabelMid=m,e.yLabelMax=m+u.height/2,e.labelExtraX=0,e.labelExtraY=0,x=!0),r.attr("transform","translate("+g+","+m+")"+(a.scale<1?"scale("+a.scale+")":"")+(a.rotate?"rotate("+a.rotate+")":"")+"translate("+-(u.left+u.right)/2+","+-(u.top+u.bottom)/2+")")})}function O(t,r,n,a){return"a"+a*v.r+","+a*v.r+" 0 "+e.largeArc+(n?" 1 ":" 0 ")+a*(r[0]-t[0])+","+a*(r[1]-t[1])}});var b=n.select(this).selectAll("g.titletext").data(y.title.text?[0]:[]);b.enter().append("g").classed("titletext",!0),b.exit().remove(),b.each(function(){var e,a=l.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});a.text(y.title.text).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(o.font,y.title.font).call(s.convertToTspans,t),e="middle center"===y.title.position?function(t){var e=Math.sqrt(t.titleBox.width*t.titleBox.width+t.titleBox.height*t.titleBox.height);return{x:t.cx,y:t.cy,scale:t.trace.hole*t.r*2/e,tx:0,ty:-t.titleBox.height/2+t.trace.title.font.size}}(v):function(t,e){var r,n,a=1,i=1,o=t.trace,l={x:t.cx,y:t.cy},s={tx:0,ty:0};s.ty+=o.title.font.size,n=h(o),-1!==o.title.position.indexOf("top")?(l.y-=(1+n)*t.r,s.ty-=t.titleBox.height):-1!==o.title.position.indexOf("bottom")&&(l.y+=(1+n)*t.r);-1!==o.title.position.indexOf("left")?(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x-=(1+n)*t.r,s.tx+=t.titleBox.width/2):-1!==o.title.position.indexOf("center")?r=e.w*(o.domain.x[1]-o.domain.x[0]):-1!==o.title.position.indexOf("right")&&(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,l.x+=(1+n)*t.r,s.tx-=t.titleBox.width/2);return a=r/t.titleBox.width,i=p(t,e)/t.titleBox.height,{x:l.x,y:l.y,scale:Math.min(a,i),tx:s.tx,ty:s.ty}}(v,r._size),a.attr("transform","translate("+e.x+","+e.y+")"+(e.scale<1?"scale("+e.scale+")":"")+"translate("+e.tx+","+e.ty+")")}),x&&function(t,e){var r,n,a,i,o,l,s,u,f,d,p,h,g;function v(t,e){return t.pxmid[1]-e.pxmid[1]}function y(t,e){return e.pxmid[1]-t.pxmid[1]}function m(t,r){r||(r={});var a,u,f,p,h,g,v=r.labelExtraY+(n?r.yLabelMax:r.yLabelMin),y=n?t.yLabelMin:t.yLabelMax,m=n?t.yLabelMax:t.yLabelMin,x=t.cyFinal+o(t.px0[1],t.px1[1]),b=v-y;if(b*s>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(u=0;u=(c.castOption(e.pull,f.pts)||0)||((t.pxmid[1]-f.pxmid[1])*s>0?(p=f.cyFinal+o(f.px0[1],f.px1[1]),(b=p-y-t.labelExtraY)*s>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-x)*s>0&&(a=3*l*Math.abs(u-d.indexOf(t)),h=f.cxFinal+i(f.px0[0],f.px1[0]),(g=h+a-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*l>0&&(t.labelExtraX+=g)))}for(n=0;n<2;n++)for(a=n?v:y,o=n?Math.max:Math.min,s=n?1:-1,r=0;r<2;r++){for(i=r?Math.max:Math.min,l=r?1:-1,(u=t[n][r]).sort(a),f=t[1-n][r],d=f.concat(u),h=[],p=0;pMath.abs(c)?o+="l"+c*t.pxmid[0]/t.pxmid[1]+","+c+"H"+(a+t.labelExtraX+l):o+="l"+t.labelExtraX+","+s+"v"+(c-s)+"h"+l}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+l;e.append("path").classed("textline",!0).call(i.stroke,y.outsidetextfont.color).attr({"stroke-width":Math.min(2,y.outsidetextfont.size/8),d:o,fill:"none"})}})})});setTimeout(function(){g.selectAll("tspan").each(function(){var t=n.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":46,"../../components/drawing":67,"../../components/fx":85,"../../lib":162,"../../lib/svg_text_utils":183,"./event_data":307,"./helpers":308,d3:11}],313:[function(t,e,r){"use strict";var n=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each(function(t){n.select(this).call(a,t,e)})})}},{"./style_one":314,d3:11}],314:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("./helpers").castOption;e.exports=function(t,e,r){var i=r.marker.line,o=a(i.color,e.pts)||n.defaultLine,l=a(i.width,e.pts)||0;t.style({"stroke-width":l}).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":46,"./helpers":308}],315:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rl&&M[v].gap;)v--;for(m=M[v].s,h=M.length-1;h>v;h--)M[h].s=m;for(;lA[u]&&u=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===r.xaxis&&i.yaxis===r.yaxis){i.opacity=void 0;break}}}}}},{}],323:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),l=t("./subtypes"),s=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),d=t("./line_shape_defaults"),p=t("./text_defaults"),h=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,a){return n.coerce(t,e,i,r,a)}var y=s(t,e,g,v);if(y||(e.visible=!1),e.visible){var m=c(t,e,g,v),x=!m&&yG!=(I=D[O][1])>=G&&(E=D[O-1][0],R=D[O][0],I-N&&(z=E+(R-E)*(G-N)/(I-N),H=Math.min(H,z),q=Math.max(q,z)));H=Math.max(H,0),q=Math.min(q,d._length);var Y=l.defaultLine;return l.opacity(f.fillcolor)?Y=f.fillcolor:l.opacity((f.line||{}).color)&&(Y=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:H,x1:q,y0:G,y1:G,color:Y,hovertemplate:"%{name}"}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":46,"../../components/fx":85,"../../lib":162,"../../registry":246,"./fill_hover_text":324,"./get_trace_color":326}],328:[function(t,e,r){"use strict";var n={},a=t("./subtypes");n.hasLines=a.hasLines,n.hasMarkers=a.hasMarkers,n.hasText=a.hasText,n.isBubble=a.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":218,"./arrays_to_calcdata":315,"./attributes":316,"./calc":317,"./cross_trace_calc":321,"./cross_trace_defaults":322,"./defaults":323,"./hover":327,"./marker_colorbar":334,"./plot":336,"./select":337,"./style":339,"./subtypes":340}],329:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,l,s){var c=(t.marker||{}).color;(l("line.color",r),a(t,"line"))?i(t,e,o,l,{prefix:"line.",cLetter:"c",noScale:!0}):l("line.color",!n(c)&&c||r);l("line.width"),(s||{}).noDash||l("line.dash")}},{"../../components/colorscale/defaults":56,"../../components/colorscale/helpers":57,"../../lib":162}],330:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),a=n.BADNUM,i=n.LOG_CLIP,o=i+.5,l=i-.5,s=t("../../lib"),c=s.segmentsIntersect,u=s.constrain,f=t("./constants");e.exports=function(t,e){var r,n,i,d,p,h,g,v,y,m,x,b,_,w,k,T,M,A,L=e.xaxis,S=e.yaxis,C="log"===L.type,O="log"===S.type,P=L._length,D=S._length,z=e.connectGaps,E=e.baseTolerance,R=e.shape,N="linear"===R,I=[],F=f.minTolerance,B=new Array(t.length),j=0;function H(e){var r=t[e];if(!r)return!1;var n=L.c2p(r.x),i=S.c2p(r.y);if(n===a){if(C&&(n=L.c2p(r.x,!0)),n===a)return!1;O&&i===a&&(n*=Math.abs(L._m*D*(L._m>0?o:l)/(S._m*P*(S._m>0?o:l)))),n*=1e3}if(i===a){if(O&&(i=S.c2p(r.y,!0)),i===a)return!1;i*=1e3}return[n,i]}function q(t,e,r,n){var a=r-t,i=n-e,o=.5-t,l=.5-e,s=a*a+i*i,c=a*o+i*l;if(c>0&&ctt||t[1]rt)return[u(t[0],K,tt),u(t[1],et,rt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,a){var i=at(n),o=at(a),l=[];if(i&&o&&it(i,o))return l;i&&l.push(i),o&&l.push(o);var c=2*s.constrain((n[t]+a[t])/2,e,r)-((i||n)[t]+(o||a)[t]);c&&((i&&o?c>0==i[t]>o[t]?i:o:i||o)[t]+=c);return l}}function lt(t){var e=t[0],r=t[1],n=e===B[j-1][0],a=r===B[j-1][1];if(!n||!a)if(j>1){var i=e===B[j-2][0],o=r===B[j-2][1];n&&(e===K||e===tt)&&i?o?j--:B[j-1]=t:a&&(r===et||r===rt)&&o?i?j--:B[j-1]=t:B[j++]=t}else B[j++]=t}function st(t){B[j-1][0]!==t[0]&&B[j-1][1]!==t[1]&<([X,Z]),lt(t),W=null,X=Z=0}function ct(t){if(M=t[0]/P,A=t[1]/D,G=t[0]tt?tt:0,Y=t[1]rt?rt:0,G||Y){if(j)if(W){var e=$(W,t);e.length>1&&(st(e[0]),B[j++]=e[1])}else J=$(B[j-1],t)[0],B[j++]=J;else B[j++]=[G||t[0],Y||t[1]];var r=B[j-1];G&&Y&&(r[0]!==G||r[1]!==Y)?(W&&(X!==G&&Z!==Y?lt(X&&Z?(n=W,i=(a=t)[0]-n[0],o=(a[1]-n[1])/i,(n[1]*a[0]-a[1]*n[0])/i>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[X||G,Z||Y]):X&&Z&<([X,Z])),lt([G,Y])):X-G&&Z-Y&<([G||X,Y||Z]),W=t,X=G,Z=Y}else W&&st($(W,t)[0]),B[j++]=t;var n,a,i,o}for("linear"===R||"spline"===R?$=function(t,e){for(var r=[],n=0,a=0;a<4;a++){var i=nt[a],o=c(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&U(o,t)V(h,ut))break;i=h,(_=y[0]*v[0]+y[1]*v[1])>x?(x=_,d=h,g=!1):_=t.length||!h)break;ct(h),n=h}}else ct(d)}W&<([X||W[0],Z||W[1]]),I.push(B.slice(0,j))}return I}},{"../../constants/numerical":143,"../../lib":162,"./constants":320}],331:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],332:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var a,i,o,l,s,c={},u=!1,f=-1,d=0,p=-1;for(i=0;i=0?s=p:(s=p=d,d++),s0?Math.max(e,a):0}}},{"fast-isnumeric":13}],334:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],335:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,l,s,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(r=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",r),a(t,"marker")&&i(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c.noSelect||(s("selected.marker.color"),s("unselected.marker.color"),s("selected.marker.size"),s("unselected.marker.size")),c.noLine||(s("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?n.background:n.defaultLine),a(t,"marker.line")&&i(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0)),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode")),c.gradient)&&("none"!==s("marker.gradient.type")&&s("marker.gradient.color"))}},{"../../components/color":46,"../../components/colorscale/defaults":56,"../../components/colorscale/helpers":57,"./subtypes":340}],336:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,l=i.identity,s=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),d=t("../../lib/polygon").tester;function p(t,e,r,f,p,h,g){var v;!function(t,e,r,a,o){var l=r.xaxis,s=r.yaxis,u=n.extent(i.simpleMap(l.range,l.r2c)),f=n.extent(i.simpleMap(s.range,s.r2c)),d=a[0].trace;if(!c.hasMarkers(d))return;var p=d.marker.maxdisplayed;if(0===p)return;var h=a.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(h.length/p),v=0;o.forEach(function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function m(t){return y?t.transition():t}var x=r.xaxis,b=r.yaxis,_=f[0].trace,w=_.line,k=n.select(h),T=o(k,"g","errorbars"),M=o(k,"g","lines"),A=o(k,"g","points"),L=o(k,"g","text");if(a.getComponentMethod("errorbars","plot")(t,T,r,g),!0===_.visible){var S,C;m(k).style("opacity",_.opacity);var O=_.fill.charAt(_.fill.length-1);"x"!==O&&"y"!==O&&(O=""),r.isRangePlot||(f[0].node3=k);var P="",D=[],z=_._prevtrace;z&&(P=z._prevRevpath||"",C=z._nextFill,D=z._polygons);var E,R,N,I,F,B,j,H,q,V="",U="",G=[],Y=i.noop;if(S=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(C&&C.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(N=s.steps(w.shape),I=s.steps(w.shape.split("").reverse().join(""))):N=I="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?s.smoothclosed(t.slice(1),w.smoothing):s.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return I(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)m(r.style("opacity",0).attr("d",E).call(s.lineGroupStyle)).style("opacity",1);else{var a=m(r);a.attr("d",E),s.singleLineStyle(f,a)}}}}}var X=M.selectAll(".js-line").data(G);m(X.exit()).style("opacity",0).remove(),X.each(Y(!1)),X.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(s.lineGroupStyle).each(Y(!0)),s.setClipUrl(X,r.layerClipId,t),G.length?(S?(S.datum(f),B&&H&&(O?("y"===O?B[1]=H[1]=b.c2p(0,!0):"x"===O&&(B[0]=H[0]=x.c2p(0,!0)),m(S).attr("d","M"+H+"L"+B+"L"+V.substr(1)).call(s.singleFillStyle)):m(S).attr("d",V+"Z").call(s.singleFillStyle))):C&&("tonext"===_.fill.substr(0,6)&&V&&P?("tonext"===_.fill?m(C).attr("d",V+"Z"+P+"Z").call(s.singleFillStyle):m(C).attr("d",V+"L"+P.substr(1)+"Z").call(s.singleFillStyle),_._polygons=_._polygons.concat(D)):(W(C),_._polygons=null)),_._prevRevpath=U,_._prevPolygons=q):(S?W(S):C&&W(C),_._polygons=_._prevRevpath=_._prevPolygons=null),A.datum(f),L.datum(f),function(e,a,i){var o,u=i[0].trace,f=c.hasMarkers(u),d=c.hasText(u),p=tt(u),h=et,g=et;if(f||d){var v=l,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?$:J:_&&!w&&(v=Q),f&&(h=v),d&&(g=v)}var k,T=(o=e.selectAll("path.point").data(h,p)).enter().append("path").classed("point",!0);y&&T.call(s.pointStyle,u,t).call(s.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=s.makePointStyleFns(u)),o.each(function(e){var a=n.select(this),i=m(a);s.translatePoint(e,i,x,b)?(s.singlePointStyle(e,i,u,k,t),r.layerClipId&&s.hideOutsideRangePoint(e,i,x,b,u.xcalendar,u.ycalendar),u.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),a=m(e.select("text"));s.translatePoint(t,a,x,b)?r.layerClipId&&s.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(s.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),r=b.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){m(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(A,L,f);var Z=!1===_.cliponaxis?null:r.layerClipId;s.setClipUrl(A,Z,t),s.setClipUrl(L,Z,t)}function W(t){m(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function $(t){return t.filter(function(t){return t.vis})}function Q(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,a,i,c){var u,d,h=!i,g=!!i&&i.duration>0,v=f(t,e,r);((u=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,r){e.each(function(e){var a=o(n.select(this),"g","fills");s.setClipUrl(a,r.layerClipId,t);var i=e[0].trace,c=[];i._ownfill&&c.push("_ownFill"),i._nexttrace&&c.push("_nextFill");var u=a.selectAll("g").data(c,l);u.enter().append("g"),u.exit().each(function(t){i[t]=null}).remove(),u.order().each(function(t){i[t]=o(n.select(this),"path","js-fill")})})}(t,u,e),g)?(c&&(d=c()),n.transition().duration(i.duration).ease(i.easing).each("end",function(){d&&d()}).each("interrupt",function(){d&&d()}).each(function(){a.selectAll("g.trace").each(function(r,n){p(t,n,e,r,v,this,i)})})):u.each(function(r,n){p(t,n,e,r,v,this,i)});h&&u.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":67,"../../lib":162,"../../lib/polygon":174,"../../registry":246,"./line_points":330,"./link_traces":332,"./subtypes":340,d3:11}],337:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,a,i,o,l=t.cd,s=t.xaxis,c=t.yaxis,u=[],f=l[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", + "X:hover .modebar--hover .modebar-group": "opacity:1;", "X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;", "X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;", "X .modebar-btn svg": "position:relative;top:2px;", @@ -71,7 +71,7 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":165}],2:[function(_dereq_,module,exports){ +},{"../src/lib":163}],2:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -214,7 +214,7 @@ module.exports = { module.exports = _dereq_('../src/traces/choropleth'); -},{"../src/traces/choropleth":273}],4:[function(_dereq_,module,exports){ +},{"../src/traces/choropleth":271}],4:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -227,7 +227,7 @@ module.exports = _dereq_('../src/traces/choropleth'); module.exports = _dereq_('../src/core'); -},{"../src/core":147}],5:[function(_dereq_,module,exports){ +},{"../src/core":144}],5:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -260,7 +260,7 @@ module.exports = Plotly; module.exports = _dereq_('../src/traces/scattergeo'); -},{"../src/traces/scattergeo":313}],7:[function(_dereq_,module,exports){ +},{"../src/traces/scattergeo":311}],7:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -15885,7 +15885,7 @@ module.exports = templatedArray('annotation', { } }); -},{"../../plot_api/plot_template":200,"../../plots/cartesian/constants":216,"../../plots/font_attributes":237,"./arrow_paths":29}],31:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":198,"../../plots/cartesian/constants":214,"../../plots/font_attributes":235,"./arrow_paths":29}],31:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15974,7 +15974,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":165,"../../plots/cartesian/axes":210,"./draw":36}],32:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/cartesian/axes":208,"./draw":36}],32:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16113,7 +16113,7 @@ function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":165,"../../plot_api/plot_template":200,"../../registry":259}],33:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plot_api/plot_template":198,"../../registry":257}],33:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16193,7 +16193,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":165,"../color":45}],34:[function(_dereq_,module,exports){ +},{"../../lib":163,"../color":45}],34:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16256,7 +16256,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":188,"fast-isnumeric":11}],35:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":186,"fast-isnumeric":11}],35:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16362,7 +16362,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":165,"../../plots/array_container_defaults":206,"../../plots/cartesian/axes":210,"./attributes":30,"./common_defaults":33}],36:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/array_container_defaults":204,"../../plots/cartesian/axes":208,"./attributes":30,"./common_defaults":33}],36:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16776,14 +16776,14 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { x: borderfull + xShift - 1, y: borderfull + yShift }) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; annText.call(svgTextUtils.positionText, textx, texty) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } annTextClip.select('rect').call(Drawing.setRect, borderfull, borderfull, @@ -16949,7 +16949,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }); }, doneFn: function() { - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -17032,7 +17032,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }, doneFn: function() { setCursor(annTextGroupInner); - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -17056,13 +17056,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { modifyBase(ya._name + '.autorange', true); } - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); }); } else annText.call(textLayout); } -},{"../../lib":165,"../../lib/setcursor":184,"../../lib/svg_text_utils":186,"../../plot_api/plot_template":200,"../../plots/cartesian/axes":210,"../../plots/plots":251,"../../registry":259,"../color":45,"../dragelement":67,"../drawing":70,"../fx":87,"./draw_arrow_head":37,"d3":9}],37:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../lib/setcursor":182,"../../lib/svg_text_utils":184,"../../plot_api/plot_template":198,"../../plots/cartesian/axes":208,"../../plots/plots":249,"../../registry":257,"../color":45,"../dragelement":63,"../drawing":66,"../fx":84,"./draw_arrow_head":37,"d3":9}],37:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17250,7 +17250,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":221,"./attributes":30,"./calc_autorange":31,"./click":32,"./convert_coords":34,"./defaults":35,"./draw":36}],39:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":219,"./attributes":30,"./calc_autorange":31,"./click":32,"./convert_coords":34,"./defaults":35,"./draw":36}],39:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17338,7 +17338,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":193,"../../plot_api/plot_template":200,"../annotations/attributes":30}],40:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":191,"../../plot_api/plot_template":198,"../annotations/attributes":30}],40:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17403,7 +17403,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":165,"../../plots/cartesian/axes":210}],41:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/cartesian/axes":208}],41:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17479,7 +17479,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":165,"../../plots/array_container_defaults":206,"../../plots/cartesian/axes":210,"../annotations/common_defaults":33,"./attributes":39}],42:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/array_container_defaults":204,"../../plots/cartesian/axes":208,"../annotations/common_defaults":33,"./attributes":39}],42:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17531,7 +17531,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":248,"../annotations/draw":36}],43:[function(_dereq_,module,exports){ +},{"../../plots/gl3d/project":246,"../annotations/draw":36}],43:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17579,7 +17579,7 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":165,"../../registry":259,"./attributes":39,"./convert":40,"./defaults":41,"./draw":42}],44:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../registry":257,"./attributes":39,"./convert":40,"./defaults":41,"./draw":42}],44:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17933,23 +17933,43 @@ module.exports = overrideAll({ exponentformat: axesAttrs.exponentformat, showexponent: axesAttrs.showexponent, title: { - valType: 'string', - - + text: { + valType: 'string', + + + }, + font: fontAttrs({ + + }), + side: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } }, - titlefont: fontAttrs({ - - }), - titleside: { - valType: 'enumerated', - values: ['right', 'top', 'bottom'], - - dflt: 'top', - + + _deprecated: { + title: { + valType: 'string', + + + }, + titlefont: fontAttrs({ + + }), + titleside: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":157,"../../plot_api/edit_types":193,"../../plots/cartesian/layout_attributes":223,"../../plots/font_attributes":237}],47:[function(_dereq_,module,exports){ +},{"../../lib/extend":155,"../../plot_api/edit_types":191,"../../plots/cartesian/layout_attributes":221,"../../plots/font_attributes":235}],47:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17958,10 +17978,10 @@ module.exports = overrideAll({ * LICENSE file in the root directory of this source tree. */ - 'use strict'; var drawColorbar = _dereq_('./draw'); +var flipScale = _dereq_('../colorscale/helpers').flipScale; /** * connectColorbar: create a colorbar from a trace, using its module to @@ -18001,12 +18021,16 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) { var cb = cd[0].t.cb = drawColorbar(gd, cbId); - cb.fillgradient(container.colorscale) + var scl = container.reversescale ? + flipScale(container.colorscale) : + container.colorscale; + + cb.fillgradient(scl) .zrange([container[moduleOpts.min], container[moduleOpts.max]]) .options(container.colorbar)(); }; -},{"./draw":50}],48:[function(_dereq_,module,exports){ +},{"../colorscale/helpers":56,"./draw":50}],48:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18096,12 +18120,12 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); - coerce('title', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'titlefont', layout.font); - coerce('titleside'); + coerce('title.text', layout._dfltTitle.colorbar); + Lib.coerceFont(coerce, 'title.font', layout.font); + coerce('title.side'); }; -},{"../../lib":165,"../../plot_api/plot_template":200,"../../plots/cartesian/tick_label_defaults":230,"../../plots/cartesian/tick_mark_defaults":231,"../../plots/cartesian/tick_value_defaults":232,"./attributes":46}],50:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plot_api/plot_template":198,"../../plots/cartesian/tick_label_defaults":228,"../../plots/cartesian/tick_mark_defaults":229,"../../plots/cartesian/tick_value_defaults":230,"./attributes":46}],50:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18288,9 +18312,9 @@ module.exports = function draw(gd, id) { showticksuffix: opts.showticksuffix, ticksuffix: opts.ticksuffix, title: opts.title, - titlefont: opts.titlefont, showline: true, anchor: 'free', + side: 'right', position: 1 }, cbAxisOut = { @@ -18301,6 +18325,7 @@ module.exports = function draw(gd, id) { letter: 'y', font: fullLayout.font, noHover: true, + noTickson: true, calendar: fullLayout.calendar // not really necessary (yet?) }; @@ -18321,11 +18346,11 @@ module.exports = function draw(gd, id) { // save for other callers to access this axis component.axis = cbAxisOut; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { - cbAxisOut.titleside = opts.titleside; + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { + cbAxisOut.title.side = opts.title.side; cbAxisOut.titlex = opts.x + xpadFrac; cbAxisOut.titley = yBottomFrac + - (opts.titleside === 'top' ? lenFrac - ypadFrac : ypadFrac); + (opts.title.side === 'top' ? lenFrac - ypadFrac : ypadFrac); } if(opts.line.color && opts.tickmode === 'auto') { @@ -18385,17 +18410,18 @@ module.exports = function draw(gd, id) { Math.round(gs.l) + ',-' + Math.round(gs.t) + ')'); - cbAxisOut._axislayer = container.select('.cbaxis'); + var axisLayer = container.select('.cbaxis'); + var titleHeight = 0; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // draw the title so we know how much room it needs // when we squish the axis. This one only applies to // top or bottom titles, not right side. var x = gs.l + (opts.x + xpadFrac) * gs.w, - fontSize = cbAxisOut.titlefont.size, + fontSize = cbAxisOut.title.font.size, y; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; } @@ -18409,7 +18435,7 @@ module.exports = function draw(gd, id) { } function drawAxis() { - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // squish the axis top to make room for the title var titleGroup = container.select('.cbtitle'), titleText = titleGroup.select('text'), @@ -18440,7 +18466,7 @@ module.exports = function draw(gd, id) { // TODO: configurable titleHeight += 5; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; } @@ -18461,8 +18487,7 @@ module.exports = function draw(gd, id) { .attr('transform', 'translate(0,' + Math.round(gs.h * (1 - cbAxisOut.domain[1])) + ')'); - cbAxisOut._axislayer.attr('transform', 'translate(0,' + - Math.round(-gs.t) + ')'); + axisLayer.attr('transform', 'translate(0,' + Math.round(-gs.t) + ')'); var fills = container.select('.cbfills') .selectAll('rect.cbfill') @@ -18529,12 +18554,7 @@ module.exports = function draw(gd, id) { }); // force full redraw of labels and ticks - cbAxisOut._axislayer.selectAll('g.' + cbAxisOut._id + 'tick,path') - .remove(); - - cbAxisOut._pos = xLeft + thickPx + - (opts.outlinewidth||0) / 2 - (opts.ticks === 'outside' ? 1 : 0); - cbAxisOut.side = 'right'; + axisLayer.selectAll('g.' + cbAxisOut._id + 'tick,path').remove(); // separate out axis and title drawing, // so we don't need such complicated logic in Titles.draw @@ -18542,11 +18562,33 @@ module.exports = function draw(gd, id) { // this title call only handles side=right return Lib.syncOrAsync([ function() { - return Axes.doTicksSingle(gd, cbAxisOut, true); + var shift = xLeft + thickPx + + (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0); + + var vals = Axes.calcTicks(cbAxisOut); + var transFn = Axes.makeTransFn(cbAxisOut); + var labelFns = Axes.makeLabelFns(cbAxisOut, shift); + var tickSign = Axes.getTickSigns(cbAxisOut)[2]; + + Axes.drawTicks(gd, cbAxisOut, { + vals: cbAxisOut.ticks === 'inside' ? Axes.clipEnds(cbAxisOut, vals) : vals, + layer: axisLayer, + path: Axes.makeTickPath(cbAxisOut, shift, tickSign), + transFn: transFn + }); + + return Axes.drawLabels(gd, cbAxisOut, { + vals: vals, + layer: axisLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); }, function() { - if(['top', 'bottom'].indexOf(opts.titleside) === -1) { - var fontSize = cbAxisOut.titlefont.size, + if(['top', 'bottom'].indexOf(opts.title.side) === -1) { + var fontSize = cbAxisOut.title.font.size, y = cbAxisOut._offset + cbAxisOut._length / 2, x = gs.l + (cbAxisOut.position || 0) * gs.w + ((cbAxisOut.side === 'right') ? 10 + fontSize * ((cbAxisOut.showticklabels ? 1 : 0.5)) : @@ -18558,7 +18600,7 @@ module.exports = function draw(gd, id) { drawTitle('h' + cbAxisOut._id + 'title', { avoid: { selection: d3.select(gd).selectAll('g.' + cbAxisOut._id + 'tick'), - side: opts.titleside, + side: opts.title.side, offsetLeft: gs.l, offsetTop: 0, maxShift: fullLayout.width @@ -18571,15 +18613,10 @@ module.exports = function draw(gd, id) { } function drawTitle(titleClass, titleOpts) { - var trace = getTrace(); - var propName = 'colorbar.title'; - var containerName = trace._module.colorbar.container; - if(containerName) propName = containerName + '.' + propName; - var dfltTitleOpts = { propContainer: cbAxisOut, - propName: propName, - traceIndex: trace.index, + propName: getPropName('title'), + traceIndex: getTrace().index, placeholder: fullLayout._dfltTitle.colorbar, containerGroup: container.select('.cbtitle') }; @@ -18603,7 +18640,7 @@ module.exports = function draw(gd, id) { // TODO: why are we redrawing multiple times now with this? // I guess autoMargin doesn't like being post-promise? var innerWidth = thickPx + opts.outlinewidth / 2 + - Drawing.bBox(cbAxisOut._axislayer.node()).width; + Drawing.bBox(axisLayer.node()).width; titleEl = titleCont.select('text'); if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) { var mathJaxNode = titleCont @@ -18611,11 +18648,11 @@ module.exports = function draw(gd, id) { .node(), titleWidth; if(mathJaxNode && - ['top', 'bottom'].indexOf(opts.titleside) !== -1) { + ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; } else { - // note: the formula below works for all titlesides, + // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift // transform gets removed by Drawing.bBox @@ -18644,7 +18681,7 @@ module.exports = function draw(gd, id) { container.selectAll('.cboutline').attr({ x: xLeft, y: yTopPx + opts.ypad + - (opts.titleside === 'top' ? titleHeight : 0), + (opts.title.side === 'top' ? titleHeight : 0), width: Math.max(thickPx, 2), height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2) }) @@ -18731,11 +18768,10 @@ module.exports = function draw(gd, id) { setCursor(container); if(xf !== undefined && yf !== undefined) { - Registry.call('restyle', - gd, - {'colorbar.x': xf, 'colorbar.y': yf}, - getTrace().index - ); + var update = {}; + update[getPropName('x')] = xf; + update[getPropName('y')] = yf; + Registry.call('_guiRestyle', gd, update, getTrace().index); } } }); @@ -18753,6 +18789,14 @@ module.exports = function draw(gd, id) { } } + function getPropName(suffix) { + var trace = getTrace(); + var propName = 'colorbar.'; + var containerName = trace._module.colorbar.container; + if(containerName) propName = containerName + '.' + propName; + return propName + suffix; + } + // setter/getters for every item defined in opts Object.keys(opts).forEach(function(name) { component[name] = function(v) { @@ -18786,7 +18830,7 @@ module.exports = function draw(gd, id) { return component; }; -},{"../../constants/alignment":143,"../../lib":165,"../../lib/extend":157,"../../lib/setcursor":184,"../../lib/svg_text_utils":186,"../../plots/cartesian/axes":210,"../../plots/cartesian/axis_defaults":212,"../../plots/cartesian/layout_attributes":223,"../../plots/cartesian/position_defaults":226,"../../plots/plots":251,"../../registry":259,"../color":45,"../dragelement":67,"../drawing":70,"../titles":136,"./attributes":46,"./constants":48,"d3":9,"tinycolor2":27}],51:[function(_dereq_,module,exports){ +},{"../../constants/alignment":140,"../../lib":163,"../../lib/extend":155,"../../lib/setcursor":182,"../../lib/svg_text_utils":184,"../../plots/cartesian/axes":208,"../../plots/cartesian/axis_defaults":210,"../../plots/cartesian/layout_attributes":221,"../../plots/cartesian/position_defaults":224,"../../plots/plots":249,"../../registry":257,"../color":45,"../dragelement":63,"../drawing":66,"../titles":133,"./attributes":46,"./constants":48,"d3":9,"tinycolor2":27}],51:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18805,7 +18849,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":165}],52:[function(_dereq_,module,exports){ +},{"../../lib":163}],52:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18816,7 +18860,7 @@ module.exports = function hasColorbar(container) { 'use strict'; -var palettes = _dereq_('./scales.js'); +var palettes = _dereq_('./scales.js').scales; var paletteStr = Object.keys(palettes); function code(s) { @@ -18963,7 +19007,7 @@ module.exports = function colorScaleAttrs(context, opts) { valType: 'boolean', dflt: false, - editType: 'calc', + editType: 'plot', }; @@ -18980,7 +19024,7 @@ module.exports = function colorScaleAttrs(context, opts) { return attrs; }; -},{"./scales.js":64}],53:[function(_dereq_,module,exports){ +},{"./scales.js":60}],53:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18989,49 +19033,19 @@ module.exports = function colorScaleAttrs(context, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); -var scales = _dereq_('./scales'); -var flipScale = _dereq_('./flip_scale'); - - -module.exports = function calc(trace, vals, containerStr, cLetter) { - var container = trace; - var inputContainer = trace._input; - var fullInputContainer = trace._fullInput; - - // set by traces with groupby transforms - var updateStyle = trace.updateStyle; - - function doUpdate(attr, inputVal, fullVal) { - if(fullVal === undefined) fullVal = inputVal; - - if(updateStyle) { - updateStyle(trace._input, containerStr ? (containerStr + '.' + attr) : attr, inputVal); - } - else { - inputContainer[attr] = inputVal; - } - - container[attr] = fullVal; - if(fullInputContainer && (trace !== trace._fullInput)) { - if(updateStyle) { - updateStyle(trace._fullInput, containerStr ? (containerStr + '.' + attr) : attr, fullVal); - } - else { - fullInputContainer[attr] = fullVal; - } - } - } +module.exports = function calc(gd, trace, opts) { + var fullLayout = gd._fullLayout; + var vals = opts.vals; + var containerStr = opts.containerStr; + var cLetter = opts.cLetter; - if(containerStr) { - container = Lib.nestedProperty(container, containerStr).get(); - inputContainer = Lib.nestedProperty(inputContainer, containerStr).get(); - fullInputContainer = Lib.nestedProperty(fullInputContainer, containerStr).get() || {}; - } + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() : + trace; var autoAttr = cLetter + 'auto'; var minAttr = cLetter + 'min'; @@ -19054,37 +19068,19 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { max += 0.5; } - doUpdate(minAttr, min); - doUpdate(maxAttr, max); - - /* - * If auto was explicitly false but min or max was missing, - * we filled in the missing piece here but later the trace does - * not look auto. - * Otherwise make sure the trace still looks auto as far as later - * changes are concerned. - */ - doUpdate(autoAttr, (auto !== false || (min === undefined && max === undefined))); + container['_' + minAttr] = container[minAttr] = min; + container['_' + maxAttr] = container[maxAttr] = max; if(container.autocolorscale) { - if(min * max < 0) scl = scales.RdBu; - else if(min >= 0) scl = scales.Reds; - else scl = scales.Blues; - - // reversescale is handled at the containerOut level - doUpdate('colorscale', scl, container.reversescale ? flipScale(scl) : scl); + if(min * max < 0) scl = fullLayout.colorscale.diverging; + else if(min >= 0) scl = fullLayout.colorscale.sequential; + else scl = fullLayout.colorscale.sequentialminus; - // We pushed a colorscale back to input, which will change the default autocolorscale next time - // to avoid spurious redraws from Plotly.react, update resulting autocolorscale now - // This is a conscious decision so that changing the data later does not unexpectedly - // give you a new colorscale - if(!inputContainer.autocolorscale) { - doUpdate('autocolorscale', false); - } + container._colorscale = container.colorscale = scl; } }; -},{"../../lib":165,"./flip_scale":57,"./scales":64}],54:[function(_dereq_,module,exports){ +},{"../../lib":163}],54:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19095,12 +19091,68 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { 'use strict'; -var scales = _dereq_('./scales'); +var Lib = _dereq_('../../lib'); +var hasColorscale = _dereq_('./helpers').hasColorscale; +module.exports = function crossTraceDefaults(fullData) { + function replace(cont, k) { + var val = cont['_' + k]; + if(val !== undefined) { + cont[k] = val; + } + } + + function relinkColorAtts(trace, cAttrs) { + var cont = cAttrs.container ? + Lib.nestedProperty(trace, cAttrs.container).get() : + trace; + + if(cont) { + var isAuto = cont.zauto || cont.cauto; + var minAttr = cAttrs.min; + var maxAttr = cAttrs.max; + + if(isAuto || cont[minAttr] === undefined) { + replace(cont, minAttr); + } + if(isAuto || cont[maxAttr] === undefined) { + replace(cont, maxAttr); + } + if(cont.autocolorscale) { + replace(cont, 'colorscale'); + } + } + } + + for(var i = 0; i < fullData.length; i++) { + var trace = fullData[i]; + var _module = trace._module; + + if(_module.colorbar) { + relinkColorAtts(trace, _module.colorbar); + } + + // TODO could generalize _module.colorscale and use it here? + + if(hasColorscale(trace, 'marker.line')) { + relinkColorAtts(trace, { + container: 'marker.line', + min: 'cmin', + max: 'cmax' + }); + } -module.exports = scales.RdBu; + if(hasColorscale(trace, 'line')) { + relinkColorAtts(trace, { + container: 'line', + min: 'cmin', + max: 'cmax' + }); + } + } +}; -},{"./scales":64}],55:[function(_dereq_,module,exports){ +},{"../../lib":163,"./helpers":56}],55:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19109,33 +19161,32 @@ module.exports = scales.RdBu; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); - var hasColorbar = _dereq_('../colorbar/has_colorbar'); var colorbarDefaults = _dereq_('../colorbar/defaults'); -var isValidScale = _dereq_('./is_valid_scale'); -var flipScale = _dereq_('./flip_scale'); +var isValidScale = _dereq_('./scales').isValid; -module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { - var prefix = opts.prefix, - cLetter = opts.cLetter, - containerStr = prefix.slice(0, prefix.length - 1), - containerIn = prefix ? - Lib.nestedProperty(traceIn, containerStr).get() || {} : - traceIn, - containerOut = prefix ? - Lib.nestedProperty(traceOut, containerStr).get() || {} : - traceOut, - minIn = containerIn[cLetter + 'min'], - maxIn = containerIn[cLetter + 'max'], - sclIn = containerIn.colorscale; +function npMaybe(cont, prefix) { + var containerStr = prefix.slice(0, prefix.length - 1); + return prefix ? + Lib.nestedProperty(cont, containerStr).get() || {} : + cont; +} +module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { + var prefix = opts.prefix; + var cLetter = opts.cLetter; + var containerIn = npMaybe(traceIn, prefix); + var containerOut = npMaybe(traceOut, prefix); + var template = npMaybe(traceOut._template || {}, prefix) || {}; + + var minIn = containerIn[cLetter + 'min']; + var maxIn = containerIn[cLetter + 'max']; var validMinMax = isNumeric(minIn) && isNumeric(maxIn) && (minIn < maxIn); coerce(prefix + cLetter + 'auto', !validMinMax); coerce(prefix + cLetter + 'min'); @@ -19143,19 +19194,17 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, // handles both the trace case (autocolorscale is false by default) and // the marker and marker.line case (autocolorscale is true by default) + var sclIn = containerIn.colorscale; + var sclTemplate = template.colorscale; var autoColorscaleDflt; if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn); + if(sclTemplate !== undefined) autoColorscaleDflt = !isValidScale(sclTemplate); coerce(prefix + 'autocolorscale', autoColorscaleDflt); - var sclOut = coerce(prefix + 'colorscale'); - - // reversescale is handled at the containerOut level - var reverseScale = coerce(prefix + 'reversescale'); - if(reverseScale) containerOut.colorscale = flipScale(sclOut); - // ... until Scatter.colorbar can handle marker line colorbars - if(prefix === 'marker.line.') return; + coerce(prefix + 'colorscale'); + coerce(prefix + 'reversescale'); - if(!opts.noScale) { + if(!opts.noScale && prefix !== 'marker.line.') { // handles both the trace case where the dflt is listed in attributes and // the marker case where the dflt is determined by hasColorbar var showScaleDflt; @@ -19166,109 +19215,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, } }; -},{"../../lib":165,"../colorbar/defaults":49,"../colorbar/has_colorbar":51,"./flip_scale":57,"./is_valid_scale":61,"fast-isnumeric":11}],56:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -/** - * Extract colorscale into numeric domain and color range. - * - * @param {array} scl colorscale array of arrays - * @param {number} cmin minimum color value (used to clamp scale) - * @param {number} cmax maximum color value (used to clamp scale) - */ -module.exports = function extractScale(scl, cmin, cmax) { - var N = scl.length, - domain = new Array(N), - range = new Array(N); - - for(var i = 0; i < N; i++) { - var si = scl[i]; - - domain[i] = cmin + si[0] * (cmax - cmin); - range[i] = si[1]; - } - - return { - domain: domain, - range: range - }; -}; - -},{}],57:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function flipScale(scl) { - var N = scl.length, - sclNew = new Array(N), - si; - - for(var i = N - 1, j = 0; i >= 0; i--, j++) { - si = scl[i]; - sclNew[j] = [1 - si[0], si[1]]; - } - - return sclNew; -}; - -},{}],58:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var defaultScale = _dereq_('./default_scale'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function getScale(scl, dflt) { - if(!dflt) dflt = defaultScale; - if(!scl) return dflt; - - function parseScale() { - try { - scl = scales[scl] || JSON.parse(scl); - } - catch(e) { - scl = dflt; - } - } - - if(typeof scl === 'string') { - parseScale(); - // occasionally scl is double-JSON encoded... - if(typeof scl === 'string') parseScale(); - } - - if(!isValidScaleArray(scl)) return dflt; - return scl; -}; - -},{"./default_scale":54,"./is_valid_scale_array":62,"./scales":64}],59:[function(_dereq_,module,exports){ +},{"../../lib":163,"../colorbar/defaults":49,"../colorbar/has_colorbar":51,"./scales":60,"fast-isnumeric":11}],56:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19279,11 +19226,16 @@ module.exports = function getScale(scl, dflt) { 'use strict'; +var d3 = _dereq_('d3'); +var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); + var Lib = _dereq_('../../lib'); -var isValidScale = _dereq_('./is_valid_scale'); +var Color = _dereq_('../color'); + +var isValidScale = _dereq_('./scales').isValid; -module.exports = function hasColorscale(trace, containerStr) { +function hasColorscale(trace, containerStr) { var container = containerStr ? Lib.nestedProperty(trace, containerStr).get() || {} : trace; @@ -19308,117 +19260,61 @@ module.exports = function hasColorscale(trace, containerStr) { Lib.isPlainObject(container.colorbar) ) ); -}; - -},{"../../lib":165,"./is_valid_scale":61,"fast-isnumeric":11}],60:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -exports.scales = _dereq_('./scales'); - -exports.defaultScale = _dereq_('./default_scale'); - -exports.attributes = _dereq_('./attributes'); - -exports.handleDefaults = _dereq_('./defaults'); - -exports.calc = _dereq_('./calc'); - -exports.hasColorscale = _dereq_('./has_colorscale'); - -exports.isValidScale = _dereq_('./is_valid_scale'); - -exports.getScale = _dereq_('./get_scale'); - -exports.flipScale = _dereq_('./flip_scale'); - -exports.extractScale = _dereq_('./extract_scale'); - -exports.makeColorScaleFunc = _dereq_('./make_color_scale_func'); - -},{"./attributes":52,"./calc":53,"./default_scale":54,"./defaults":55,"./extract_scale":56,"./flip_scale":57,"./get_scale":58,"./has_colorscale":59,"./is_valid_scale":61,"./make_color_scale_func":63,"./scales":64}],61:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function isValidScale(scl) { - if(scales[scl] !== undefined) return true; - else return isValidScaleArray(scl); -}; +} -},{"./is_valid_scale_array":62,"./scales":64}],62:[function(_dereq_,module,exports){ /** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var tinycolor = _dereq_('tinycolor2'); - - -module.exports = function isValidScaleArray(scl) { - var highestVal = 0; + * Extract colorscale into numeric domain and color range. + * + * @param {object} cont colorscale container (e.g. trace, marker) + * - colorscale {array of arrays} + * - cmin/zmin {number} + * - cmax/zmax {number} + * - reversescale {boolean} + * @param {object} opts + * - cLetter {string} 'c' (for cmin/cmax) or 'z' (for zmin/zmax) + * + * @return {object} + * - domain {array} + * - range {array} + */ +function extractScale(cont, opts) { + var cLetter = opts.cLetter; - if(!Array.isArray(scl) || scl.length < 2) return false; + var scl = cont.reversescale ? + flipScale(cont.colorscale) : + cont.colorscale; - if(!scl[0] || !scl[scl.length - 1]) return false; + // minimum color value (used to clamp scale) + var cmin = cont[cLetter + 'min']; + // maximum color value (used to clamp scale) + var cmax = cont[cLetter + 'max']; - if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + var N = scl.length; + var domain = new Array(N); + var range = new Array(N); - for(var i = 0; i < scl.length; i++) { + for(var i = 0; i < N; i++) { var si = scl[i]; - - if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { - return false; - } - - highestVal = +si[0]; + domain[i] = cmin + si[0] * (cmax - cmin); + range[i] = si[1]; } - return true; -}; - -},{"tinycolor2":27}],63:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; + return { + domain: domain, + range: range + }; +} -var d3 = _dereq_('d3'); -var tinycolor = _dereq_('tinycolor2'); -var isNumeric = _dereq_('fast-isnumeric'); +function flipScale(scl) { + var N = scl.length; + var sclNew = new Array(N); -var Color = _dereq_('../color'); + for(var i = N - 1, j = 0; i >= 0; i--, j++) { + var si = scl[i]; + sclNew[j] = [1 - si[0], si[1]]; + } + return sclNew; +} /** * General colorscale function generator. @@ -19433,7 +19329,7 @@ var Color = _dereq_('../color'); * * @return {function} */ -module.exports = function makeColorScaleFunc(specs, opts) { +function makeColorScaleFunc(specs, opts) { opts = opts || {}; var domain = specs.domain, @@ -19485,7 +19381,7 @@ module.exports = function makeColorScaleFunc(specs, opts) { sclFunc.range = function() { return range; }; return sclFunc; -}; +} function colorArray2rbga(colorArray) { var colorObj = { @@ -19498,7 +19394,14 @@ function colorArray2rbga(colorArray) { return tinycolor(colorObj).toRgbString(); } -},{"../color":45,"d3":9,"fast-isnumeric":11,"tinycolor2":27}],64:[function(_dereq_,module,exports){ +module.exports = { + hasColorscale: hasColorscale, + extractScale: extractScale, + flipScale: flipScale, + makeColorScaleFunc: makeColorScaleFunc +}; + +},{"../../lib":163,"../color":45,"./scales":60,"d3":9,"fast-isnumeric":11,"tinycolor2":27}],57:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19509,8 +19412,116 @@ function colorArray2rbga(colorArray) { 'use strict'; +var scales = _dereq_('./scales'); +var helpers = _dereq_('./helpers'); module.exports = { + moduleType: 'component', + name: 'colorscale', + + attributes: _dereq_('./attributes'), + layoutAttributes: _dereq_('./layout_attributes'), + + supplyLayoutDefaults: _dereq_('./layout_defaults'), + handleDefaults: _dereq_('./defaults'), + crossTraceDefaults: _dereq_('./cross_trace_defaults'), + + calc: _dereq_('./calc'), + + // ./scales.js is required in lib/coerce.js ; + // it needs to be a seperate module to avoid circular a dependency + scales: scales.scales, + defaultScale: scales.defaultScale, + getScale: scales.get, + isValidScale: scales.isValid, + + hasColorscale: helpers.hasColorscale, + flipScale: helpers.flipScale, + extractScale: helpers.extractScale, + makeColorScaleFunc: helpers.makeColorScaleFunc +}; + +},{"./attributes":52,"./calc":53,"./cross_trace_defaults":54,"./defaults":55,"./helpers":56,"./layout_attributes":58,"./layout_defaults":59,"./scales":60}],58:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var scales = _dereq_('./scales').scales; + +var msg = 'Note that `autocolorscale` must be true for this attribute to work.'; + +module.exports = { + editType: 'calc', + sequential: { + valType: 'colorscale', + dflt: scales.Reds, + + editType: 'calc', + + }, + sequentialminus: { + valType: 'colorscale', + dflt: scales.Blues, + + editType: 'calc', + + }, + diverging: { + valType: 'colorscale', + dflt: scales.RdBu, + + editType: 'calc', + + } +}; + +},{"./scales":60}],59:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var Lib = _dereq_('../../lib'); +var colorscaleAttrs = _dereq_('./layout_attributes'); +var Template = _dereq_('../../plot_api/plot_template'); + +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var colorscaleIn = layoutIn.colorscale; + var colorscaleOut = Template.newContainer(layoutOut, 'colorscale'); + function coerce(attr, dflt) { + return Lib.coerce(colorscaleIn, colorscaleOut, colorscaleAttrs, attr, dflt); + } + + coerce('sequential'); + coerce('sequentialminus'); + coerce('diverging'); +}; + +},{"../../lib":163,"../../plot_api/plot_template":198,"./layout_attributes":58}],60:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var tinycolor = _dereq_('tinycolor2'); + +var scales = { 'Greys': [ [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] ], @@ -19641,7 +19652,67 @@ module.exports = { ] }; -},{}],65:[function(_dereq_,module,exports){ +var defaultScale = scales.RdBu; + +function getScale(scl, dflt) { + if(!dflt) dflt = defaultScale; + if(!scl) return dflt; + + function parseScale() { + try { + scl = scales[scl] || JSON.parse(scl); + } catch(e) { + scl = dflt; + } + } + + if(typeof scl === 'string') { + parseScale(); + // occasionally scl is double-JSON encoded... + if(typeof scl === 'string') parseScale(); + } + + if(!isValidScaleArray(scl)) return dflt; + return scl; +} + + +function isValidScaleArray(scl) { + var highestVal = 0; + + if(!Array.isArray(scl) || scl.length < 2) return false; + + if(!scl[0] || !scl[scl.length - 1]) return false; + + if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + + for(var i = 0; i < scl.length; i++) { + var si = scl[i]; + + if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { + return false; + } + + highestVal = +si[0]; + } + + return true; +} + +function isValidScale(scl) { + if(scales[scl] !== undefined) return true; + else return isValidScaleArray(scl); +} + +module.exports = { + scales: scales, + defaultScale: defaultScale, + + get: getScale, + isValid: isValidScale +}; + +},{"tinycolor2":27}],61:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19674,7 +19745,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],66:[function(_dereq_,module,exports){ +},{}],62:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19712,7 +19783,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":165}],67:[function(_dereq_,module,exports){ +},{"../../lib":163}],63:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19839,8 +19910,6 @@ dragElement.init = function init(options) { var clampFn = options.clampFn || _clampFn; function onStart(e) { - e.preventDefault(); - // make dragging and dragged into properties of gd // so that others can look at and modify them gd._dragged = false; @@ -19882,11 +19951,15 @@ dragElement.init = function init(options) { document.documentElement.style.cursor = window.getComputedStyle(element).cursor; } - document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onDone); - document.addEventListener('touchmove', onMove); document.addEventListener('touchend', onDone); + if(options.dragmode !== false) { + e.preventDefault(); + document.addEventListener('mousemove', onMove); + document.addEventListener('touchmove', onMove); + } + return; } @@ -19910,13 +19983,15 @@ dragElement.init = function init(options) { } function onDone(e) { - document.removeEventListener('mousemove', onMove); + if(options.dragmode !== false) { + e.preventDefault(); + document.removeEventListener('mousemove', onMove); + document.removeEventListener('touchmove', onMove); + } + document.removeEventListener('mouseup', onDone); - document.removeEventListener('touchmove', onMove); document.removeEventListener('touchend', onDone); - e.preventDefault(); - if(hasHover) { Lib.removeElement(dragCover); } @@ -20009,7 +20084,7 @@ function pointerOffset(e) { ); } -},{"../../constants/interactions":144,"../../lib":165,"../../plots/cartesian/constants":216,"../../registry":259,"./align":65,"./cursor":66,"./unhover":68,"has-hover":13,"has-passive-events":14,"mouse-event-offset":17}],68:[function(_dereq_,module,exports){ +},{"../../constants/interactions":141,"../../lib":163,"../../plots/cartesian/constants":214,"../../registry":257,"./align":61,"./cursor":62,"./unhover":64,"has-hover":13,"has-passive-events":14,"mouse-event-offset":17}],64:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -20067,7 +20142,7 @@ unhover.raw = function unhoverRaw(gd, evt) { } }; -},{"../../lib/events":156,"../../lib/get_graph_div":163,"../../lib/throttle":187,"../fx/constants":82}],69:[function(_dereq_,module,exports){ +},{"../../lib/events":154,"../../lib/get_graph_div":161,"../../lib/throttle":185,"../fx/constants":78}],65:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -20092,7 +20167,7 @@ exports.dash = { }; -},{}],70:[function(_dereq_,module,exports){ +},{}],66:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -20293,7 +20368,11 @@ drawing.fillGroupStyle = function(s) { s.style('stroke-width', 0) .each(function(d) { var shape = d3.select(this); - shape.call(Color.fill, d[0].trace.fillcolor); + // N.B. 'd' won't be a calcdata item when + // fill !== 'none' on a segment-less and marker-less trace + if(d[0].trace) { + shape.call(Color.fill, d[0].trace.fillcolor); + } }); }; @@ -20734,7 +20813,7 @@ drawing.tryColorscale = function(marker, prefix) { if(scl && Lib.isArrayOrTypedArray(colorArray)) { return Colorscale.makeColorScaleFunc( - Colorscale.extractScale(scl, cont.cmin, cont.cmax) + Colorscale.extractScale(cont, {cLetter: 'c'}) ); } } @@ -21095,32 +21174,28 @@ function nodeHash(node) { node.getAttribute('style'); } -/* - * make a robust clipPath url from a local id - * note! We'd better not be exporting from a page - * with a or the svg will not be portable! +/** + * Set clipPath URL in a way that work for all situations. + * + * In details, graphs on pages with HTML tags need to prepend + * the clip path ids with the page's base url EXCEPT during toImage exports. + * + * @param {d3 selection} s : node to add clip-path attribute + * @param {string} localId : local clip-path (w/o base url) id + * @param {DOM element || object} gd + * - context._baseUrl {string} + * - context._exportedPlot {boolean} */ -drawing.setClipUrl = function(s, localId) { +drawing.setClipUrl = function(s, localId, gd) { if(!localId) { s.attr('clip-path', null); return; } - if(drawing.baseUrl === undefined) { - var base = d3.select('base'); - - // Stash base url once and for all! - // We may have to stash this elsewhere when - // we'll try to support for child windows - // more info -> https://github.com/plotly/plotly.js/issues/702 - if(base.size() && base.attr('href')) { - drawing.baseUrl = window.location.href.split('#')[0]; - } else { - drawing.baseUrl = ''; - } - } + var context = gd._context; + var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - s.attr('clip-path', 'url(' + drawing.baseUrl + '#' + localId + ')'); + s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')'); }; drawing.getTranslate = function(element) { @@ -21252,7 +21327,7 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../constants/alignment":143,"../../constants/interactions":144,"../../constants/xmlns_namespaces":146,"../../lib":165,"../../lib/svg_text_utils":186,"../../registry":259,"../../traces/scatter/make_bubble_size_func":298,"../../traces/scatter/subtypes":305,"../color":45,"../colorscale":60,"./symbol_defs":71,"d3":9,"fast-isnumeric":11,"tinycolor2":27}],71:[function(_dereq_,module,exports){ +},{"../../constants/alignment":140,"../../constants/interactions":141,"../../constants/xmlns_namespaces":143,"../../lib":163,"../../lib/svg_text_utils":184,"../../registry":257,"../../traces/scatter/make_bubble_size_func":296,"../../traces/scatter/subtypes":303,"../color":45,"../colorscale":57,"./symbol_defs":67,"d3":9,"fast-isnumeric":11,"tinycolor2":27}],67:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21740,7 +21815,7 @@ module.exports = { } }; -},{"d3":9}],72:[function(_dereq_,module,exports){ +},{"d3":9}],68:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21855,7 +21930,7 @@ module.exports = { } }; -},{}],73:[function(_dereq_,module,exports){ +},{}],69:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21937,7 +22012,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max); } -},{"../../plots/cartesian/axes":210,"../../registry":259,"./compute_error":74,"fast-isnumeric":11}],74:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":208,"../../registry":257,"./compute_error":70,"fast-isnumeric":11}],70:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22041,7 +22116,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],75:[function(_dereq_,module,exports){ +},{}],71:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22117,7 +22192,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":165,"../../plot_api/plot_template":200,"../../registry":259,"./attributes":72,"fast-isnumeric":11}],76:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plot_api/plot_template":198,"../../registry":257,"./attributes":68,"fast-isnumeric":11}],72:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22186,7 +22261,7 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":165,"../../plot_api/edit_types":193,"./attributes":72,"./calc":73,"./compute_error":74,"./defaults":75,"./plot":77,"./style":78}],77:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plot_api/edit_types":191,"./attributes":68,"./calc":69,"./compute_error":70,"./defaults":71,"./plot":73,"./style":74}],73:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22204,7 +22279,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); var subTypes = _dereq_('../../traces/scatter/subtypes'); -module.exports = function plot(traces, plotinfo, transitionOpts) { +module.exports = function plot(gd, traces, plotinfo, transitionOpts) { var isNew; var xa = plotinfo.xaxis; @@ -22255,7 +22330,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { .style('opacity', 1); } - Drawing.setClipUrl(errorbars, plotinfo.layerClipId); + Drawing.setClipUrl(errorbars, plotinfo.layerClipId, gd); errorbars.each(function(d) { var errorbar = d3.select(this); @@ -22360,7 +22435,7 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":305,"../drawing":70,"d3":9,"fast-isnumeric":11}],78:[function(_dereq_,module,exports){ +},{"../../traces/scatter/subtypes":303,"../drawing":66,"d3":9,"fast-isnumeric":11}],74:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22397,7 +22472,7 @@ module.exports = function style(traces) { }); }; -},{"../color":45,"d3":9}],79:[function(_dereq_,module,exports){ +},{"../color":45,"d3":9}],75:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22443,7 +22518,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":237}],80:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":235}],76:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22480,6 +22555,8 @@ module.exports = function calc(gd) { fillFn(trace.hoverinfo, cd, 'hi', makeCoerceHoverInfo(trace)); + if(trace.hovertemplate) fillFn(trace.hovertemplate, cd, 'ht'); + if(!trace.hoverlabel) continue; fillFn(trace.hoverlabel.bgcolor, cd, 'hbg'); @@ -22499,7 +22576,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":165,"../../registry":259}],81:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../registry":257}],77:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22537,7 +22614,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":259,"./hover":85}],82:[function(_dereq_,module,exports){ +},{"../../registry":257,"./hover":81}],78:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22569,7 +22646,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],83:[function(_dereq_,module,exports){ +},{}],79:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22592,7 +22669,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, layout.hoverlabel); }; -},{"../../lib":165,"./attributes":79,"./hoverlabel_defaults":86}],84:[function(_dereq_,module,exports){ +},{"../../lib":163,"./attributes":75,"./hoverlabel_defaults":82}],80:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22835,7 +22912,7 @@ function getPointData(val, pointNumber) { } } -},{"../../lib":165}],85:[function(_dereq_,module,exports){ +},{"../../lib":163}],81:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22964,13 +23041,17 @@ exports.loneHover = function loneHover(hoverItem, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; var container3 = d3.select(opts.container); @@ -22984,7 +23065,6 @@ exports.loneHover = function loneHover(hoverItem, opts) { container: container3, outerContainer: outerContainer3 }; - var hoverLabel = createHoverText([pointData], fullOpts, opts.gd); alignHoverText(hoverLabel, fullOpts.rotateLabels); @@ -23018,13 +23098,17 @@ exports.multiHovers = function multiHovers(hoverItems, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; }); @@ -23500,7 +23584,14 @@ function _hover(gd, evt, subplot, noHoverEvent) { // other people and send it to the event for(itemnum = 0; itemnum < hoverData.length; itemnum++) { var pt = hoverData[itemnum]; - newhoverdata.push(helpers.makeEventData(pt, pt.trace, pt.cd)); + var eventData = helpers.makeEventData(pt, pt.trace, pt.cd); + + var ht = false; + if(pt.cd[pt.index] && pt.cd[pt.index].ht) ht = pt.cd[pt.index].ht; + hoverData[itemnum].hovertemplate = ht || pt.trace.hovertemplate || false; + hoverData[itemnum].eventData = [eventData]; + + newhoverdata.push(eventData); } gd._hoverdata = newhoverdata; @@ -23558,6 +23649,8 @@ function _hover(gd, evt, subplot, noHoverEvent) { }); } +var EXTRA_STRING_REGEX = /([\s\S]*)<\/extra>/; + function createHoverText(hoverData, opts, gd) { var hovermode = opts.hovermode; var rotateLabels = opts.rotateLabels; @@ -23601,11 +23694,13 @@ function createHoverText(hoverData, opts, gd) { if(allHaveZ && hoverData[i].zLabel === undefined) allHaveZ = false; traceHoverinfo = hoverData[i].hoverinfo || hoverData[i].trace.hoverinfo; - var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); - if(parts.indexOf('all') === -1 && - parts.indexOf(hovermode) === -1) { - showCommonLabel = false; - break; + if(traceHoverinfo) { + var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); + if(parts.indexOf('all') === -1 && + parts.indexOf(hovermode) === -1) { + showCommonLabel = false; + break; + } } } @@ -23788,6 +23883,19 @@ function createHoverText(hoverData, opts, gd) { text = name; } + // hovertemplate + var hovertemplate = d.hovertemplate || false; + var hovertemplateLabels = d.hovertemplateLabels || d; + var eventData = d.eventData[0] || {}; + if(hovertemplate) { + text = Lib.hovertemplateString(hovertemplate, hovertemplateLabels, eventData); + + text = text.replace(EXTRA_STRING_REGEX, function(match, extra) { + name = extra; // Assign name for secondary text label + return ''; // Remove from main text label + }); + } + // main label var tx = g.select('text.nums') .call(Drawing.font, @@ -24186,7 +24294,7 @@ function cleanPoint(d, hovermode) { var infomode = d.hoverinfo || d.trace.hoverinfo; - if(infomode !== 'all') { + if(infomode && infomode !== 'all') { infomode = Array.isArray(infomode) ? infomode : infomode.split('+'); if(infomode.indexOf('x') === -1) d.xLabel = undefined; if(infomode.indexOf('y') === -1) d.yLabel = undefined; @@ -24372,8 +24480,11 @@ function hoverChanged(gd, evt, oldhoverdata) { for(var i = oldhoverdata.length - 1; i >= 0; i--) { var oldPt = oldhoverdata[i]; var newPt = gd._hoverdata[i]; + if(oldPt.curveNumber !== newPt.curveNumber || - String(oldPt.pointNumber) !== String(newPt.pointNumber)) { + String(oldPt.pointNumber) !== String(newPt.pointNumber) || + String(oldPt.pointNumbers) !== String(newPt.pointNumbers) + ) { return true; } } @@ -24389,7 +24500,7 @@ function spikesChanged(gd, oldspikepoints) { return false; } -},{"../../lib":165,"../../lib/events":156,"../../lib/override_cursor":176,"../../lib/svg_text_utils":186,"../../plots/cartesian/axes":210,"../../registry":259,"../color":45,"../dragelement":67,"../drawing":70,"./constants":82,"./helpers":84,"d3":9,"fast-isnumeric":11,"tinycolor2":27}],86:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../lib/events":154,"../../lib/override_cursor":174,"../../lib/svg_text_utils":184,"../../plots/cartesian/axes":208,"../../registry":257,"../color":45,"../dragelement":63,"../drawing":66,"./constants":78,"./helpers":80,"d3":9,"fast-isnumeric":11,"tinycolor2":27}],82:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24411,7 +24522,49 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts Lib.coerceFont(coerce, 'hoverlabel.font', opts.font); }; -},{"../../lib":165}],87:[function(_dereq_,module,exports){ +},{"../../lib":163}],83:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function(opts, extra) { + opts = opts || {}; + extra = extra || {}; + + var descPart = extra.description ? ' ' + extra.description : ''; + var keys = extra.keys || []; + if(keys.length > 0) { + var quotedKeys = []; + for(var i = 0; i < keys.length; i++) { + quotedKeys[i] = '`' + keys[i] + '`'; + } + descPart = descPart + 'Finally, the template string has access to '; + if(keys.length === 1) { + descPart = 'variable ' + quotedKeys[0]; + } else { + descPart = 'variables ' + quotedKeys.slice(0, -1).join(', ') + ' and ' + quotedKeys.slice(-1) + '.'; + } + } + + var hovertemplate = { + valType: 'string', + + dflt: '', + arrayOk: true, + editType: 'none', + + }; + + return hovertemplate; +}; + +},{}],84:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24491,7 +24644,7 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":165,"../dragelement":67,"./attributes":79,"./calc":80,"./click":81,"./constants":82,"./defaults":83,"./helpers":84,"./hover":85,"./layout_attributes":88,"./layout_defaults":89,"./layout_global_defaults":90,"d3":9}],88:[function(_dereq_,module,exports){ +},{"../../lib":163,"../dragelement":63,"./attributes":75,"./calc":76,"./click":77,"./constants":78,"./defaults":79,"./helpers":80,"./hover":81,"./layout_attributes":85,"./layout_defaults":86,"./layout_global_defaults":87,"d3":9}],85:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24524,7 +24677,7 @@ module.exports = { dragmode: { valType: 'enumerated', - values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'], + values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable', false], dflt: 'zoom', editType: 'modebar', @@ -24586,7 +24739,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":237,"./constants":82}],89:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":235,"./constants":78}],86:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24659,7 +24812,7 @@ function isHoriz(fullData) { return out; } -},{"../../lib":165,"./layout_attributes":88}],90:[function(_dereq_,module,exports){ +},{"../../lib":163,"./layout_attributes":85}],87:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24682,7 +24835,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":165,"./hoverlabel_defaults":86,"./layout_attributes":88}],91:[function(_dereq_,module,exports){ +},{"../../lib":163,"./hoverlabel_defaults":82,"./layout_attributes":85}],88:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25067,7 +25220,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":165,"../../lib/regex":180,"../../plot_api/plot_template":200,"../../plots/cartesian/constants":216,"../../plots/domain":236}],92:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../lib/regex":178,"../../plot_api/plot_template":198,"../../plots/cartesian/constants":214,"../../plots/domain":234}],89:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25202,7 +25355,7 @@ module.exports = templatedArray('image', { editType: 'arraydraw' }); -},{"../../plot_api/plot_template":200,"../../plots/cartesian/constants":216}],93:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":198,"../../plots/cartesian/constants":214}],90:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25285,7 +25438,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":188,"fast-isnumeric":11}],94:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":186,"fast-isnumeric":11}],91:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25346,7 +25499,7 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":165,"../../plots/array_container_defaults":206,"../../plots/cartesian/axes":210,"./attributes":92}],95:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/array_container_defaults":204,"../../plots/cartesian/axes":208,"./attributes":89}],92:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25517,9 +25670,10 @@ module.exports = function draw(gd) { yId = ya ? ya._id : '', clipAxes = xId + yId; - thisImage.call(Drawing.setClipUrl, clipAxes ? - ('clip' + fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + thisImage, + clipAxes ? ('clip' + fullLayout._uid + clipAxes) : null, + gd ); } @@ -25567,7 +25721,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":146,"../../plots/cartesian/axes":210,"../drawing":70,"d3":9}],96:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":143,"../../plots/cartesian/axes":208,"../drawing":66,"d3":9}],93:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25591,56 +25745,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":221,"./attributes":92,"./convert_coords":93,"./defaults":94,"./draw":95}],97:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - - -/** - * Determine the position anchor property of x/y xanchor/yanchor components. - * - * - values < 1/3 align the low side at that fraction, - * - values [1/3, 2/3] align the center at that fraction, - * - values > 2/3 align the right at that fraction. - */ - -exports.isRightAnchor = function isRightAnchor(opts) { - return ( - opts.xanchor === 'right' || - (opts.xanchor === 'auto' && opts.x >= 2 / 3) - ); -}; - -exports.isCenterAnchor = function isCenterAnchor(opts) { - return ( - opts.xanchor === 'center' || - (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) - ); -}; - -exports.isBottomAnchor = function isBottomAnchor(opts) { - return ( - opts.yanchor === 'bottom' || - (opts.yanchor === 'auto' && opts.y <= 1 / 3) - ); -}; - -exports.isMiddleAnchor = function isMiddleAnchor(opts) { - return ( - opts.yanchor === 'middle' || - (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) - ); -}; - -},{}],98:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":219,"./attributes":89,"./convert_coords":90,"./defaults":91,"./draw":92}],94:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25738,11 +25843,25 @@ module.exports = { editType: 'legend', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + valign: { + valType: 'enumerated', + values: ['top', 'middle', 'bottom'], + dflt: 'middle', + + editType: 'legend', + }, editType: 'legend' }; -},{"../../plots/font_attributes":237,"../color/attributes":44}],99:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":235,"../color/attributes":44}],95:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25761,7 +25880,7 @@ module.exports = { textOffsetX: 40 }; -},{}],100:[function(_dereq_,module,exports){ +},{}],96:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25830,7 +25949,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { basePlotLayoutAttributes, 'showlegend', legendReallyHasATrace && legendTraceCount > 1); - if(showLegend === false) return; + if(showLegend === false && !containerIn.uirevision) return; var containerOut = Template.newContainer(layoutOut, 'legend'); @@ -25838,6 +25957,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); } + coerce('uirevision', layoutOut.uirevision); + + if(showLegend === false) return; + coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); @@ -25846,7 +25969,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('orientation'); if(containerOut.orientation === 'h') { var xaxis = layoutIn.xaxis; - if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { + if(Registry.getComponentMethod('rangeslider', 'isVisible')(xaxis)) { defaultX = 0; defaultXAnchor = 'left'; defaultY = 1.1; @@ -25867,10 +25990,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('xanchor', defaultXAnchor); coerce('y', defaultY); coerce('yanchor', defaultYAnchor); + coerce('valign'); Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); }; -},{"../../lib":165,"../../plot_api/plot_template":200,"../../plots/layout_attributes":249,"../../registry":259,"./attributes":98,"./helpers":104}],101:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plot_api/plot_template":198,"../../plots/layout_attributes":247,"../../registry":257,"./attributes":94,"./helpers":100}],97:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25903,7 +26027,6 @@ var FROM_BR = alignmentConstants.FROM_BR; var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); -var anchorUtils = _dereq_('./anchor_utils'); var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; @@ -26027,17 +26150,17 @@ module.exports = function draw(gd) { lx = gs.l + gs.w * opts.x, ly = gs.t + gs.h * (1 - opts.y); - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= opts._width; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= opts._height; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -26097,7 +26220,7 @@ module.exports = function draw(gd) { y: opts.borderwidth }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; @@ -26135,7 +26258,7 @@ module.exports = function draw(gd) { y: opts.borderwidth + scrollBoxY }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -26212,7 +26335,7 @@ module.exports = function draw(gd) { }, doneFn: function() { if(xf !== undefined && yf !== undefined) { - Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf}); + Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf}); } }, clickFn: function(numClicks, e) { @@ -26319,7 +26442,7 @@ function drawTexts(g, gd, maxLength) { update.name = newName; } - return Registry.call('restyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, traceIndex); }); } else { textLayout(textEl); @@ -26409,6 +26532,7 @@ function computeTextDimensions(g, gd) { // to avoid getBoundingClientRect var textY = lineHeight * (0.3 + (1 - textLines) / 2); svgTextUtils.positionText(text, constants.textOffsetX, textY); + legendItem.lineHeight = lineHeight; } height = Math.max(height, 16) + 3; @@ -26572,18 +26696,18 @@ function expandMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -26603,10 +26727,10 @@ function expandHorizontalMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } @@ -26621,7 +26745,7 @@ function expandHorizontalMargin(gd) { }); } -},{"../../constants/alignment":143,"../../constants/interactions":144,"../../lib":165,"../../lib/events":156,"../../lib/svg_text_utils":186,"../../plots/plots":251,"../../registry":259,"../color":45,"../dragelement":67,"../drawing":70,"./anchor_utils":97,"./constants":99,"./get_legend_data":102,"./handle_click":103,"./helpers":104,"./style":106,"d3":9}],102:[function(_dereq_,module,exports){ +},{"../../constants/alignment":140,"../../constants/interactions":141,"../../lib":163,"../../lib/events":154,"../../lib/svg_text_utils":184,"../../plots/plots":249,"../../registry":257,"../color":45,"../dragelement":63,"../drawing":66,"./constants":95,"./get_legend_data":98,"./handle_click":99,"./helpers":100,"./style":102,"d3":9}],98:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26727,7 +26851,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":259,"./helpers":104}],103:[function(_dereq_,module,exports){ +},{"../../registry":257,"./helpers":100}],99:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26841,7 +26965,7 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices); + Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices); } else { var hasLegendgroup = legendgroup && legendgroup.length; var traceIndicesInGroup = []; @@ -26947,11 +27071,11 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', gd, attrUpdate, attrIndices); + Registry.call('_guiRestyle', gd, attrUpdate, attrIndices); } }; -},{"../../lib":165,"../../registry":259}],104:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../registry":257}],100:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26975,7 +27099,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],105:[function(_dereq_,module,exports){ +},{}],101:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26999,7 +27123,7 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":98,"./defaults":100,"./draw":101,"./style":106}],106:[function(_dereq_,module,exports){ +},{"./attributes":94,"./defaults":96,"./draw":97,"./style":102}],102:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27027,6 +27151,19 @@ module.exports = function style(s, gd) { var layers = Lib.ensureSingle(traceGroup, 'g', 'layers'); layers.style('opacity', d[0].trace.opacity); + // Marker vertical alignment + var valign = gd._fullLayout.legend.valign; + var lineHeight = d[0].lineHeight; + var height = d[0].height; + + if(valign === 'middle' || !lineHeight || !height) { + layers.attr('transform', null); // this here is a fun d3 trick to unset DOM attributes + } else { + var factor = {top: 1, bottom: -1}[valign]; + var markerOffsetY = factor * (0.5 * (lineHeight - height + 3)); + layers.attr('transform', 'translate(0,' + markerOffsetY + ')'); + } + var fill = layers .selectAll('g.legendfill') .data([d]); @@ -27346,7 +27483,7 @@ module.exports = function style(s, gd) { } }; -},{"../../lib":165,"../../registry":259,"../../traces/pie/style_one":279,"../../traces/scatter/subtypes":305,"../color":45,"../drawing":70,"d3":9}],107:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../registry":257,"../../traces/pie/style_one":277,"../../traces/scatter/subtypes":303,"../color":45,"../drawing":66,"d3":9}],103:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27610,7 +27747,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -27666,7 +27803,7 @@ function handleDrag3d(gd, ev) { var val2d = (val === 'pan') ? val : 'zoom'; layoutUpdate.dragmode = val2d; - Registry.call('relayout', gd, layoutUpdate); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.resetCameraDefault3d = { @@ -27705,7 +27842,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -27719,54 +27856,48 @@ modeBarButtons.hoverClosest3d = { click: handleHover3d }; -function handleHover3d(gd, ev) { +function getNextHover3d(gd, ev) { var button = ev.currentTarget; - var val = button._previousVal || false; - var layout = gd.layout; + var val = button._previousVal; var fullLayout = gd._fullLayout; var sceneIds = fullLayout._subplots.gl3d; var axes = ['xaxis', 'yaxis', 'zaxis']; - var spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor']; // initialize 'current spike' object to be stored in the DOM var currentSpikes = {}; - var axisSpikes = {}; var layoutUpdate = {}; if(val) { - layoutUpdate = Lib.extendDeep(layout, val); + layoutUpdate = val; button._previousVal = null; } else { - layoutUpdate = { - 'allaxes.showspikes': false - }; - for(var i = 0; i < sceneIds.length; i++) { - var sceneId = sceneIds[i], - sceneLayout = fullLayout[sceneId], - sceneSpikes = currentSpikes[sceneId] = {}; + var sceneId = sceneIds[i]; + var sceneLayout = fullLayout[sceneId]; - sceneSpikes.hovermode = sceneLayout.hovermode; - layoutUpdate[sceneId + '.hovermode'] = false; + var hovermodeAStr = sceneId + '.hovermode'; + currentSpikes[hovermodeAStr] = sceneLayout.hovermode; + layoutUpdate[hovermodeAStr] = false; // copy all the current spike attrs for(var j = 0; j < 3; j++) { var axis = axes[j]; - axisSpikes = sceneSpikes[axis] = {}; - - for(var k = 0; k < spikeAttrs.length; k++) { - var spikeAttr = spikeAttrs[k]; - axisSpikes[spikeAttr] = sceneLayout[axis][spikeAttr]; - } + var spikeAStr = sceneId + '.' + axis + '.showspikes'; + layoutUpdate[spikeAStr] = false; + currentSpikes[spikeAStr] = sceneLayout[axis].showspikes; } } - button._previousVal = Lib.extendDeep({}, currentSpikes); + button._previousVal = currentSpikes; } + return layoutUpdate; +} - Registry.call('relayout', gd, layoutUpdate); +function handleHover3d(gd, ev) { + var layoutUpdate = getNextHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.zoomInGeo = { @@ -27822,7 +27953,7 @@ function handleGeo(gd, ev) { var scale = geoLayout.projection.scale; var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; - Registry.call('relayout', gd, id + '.projection.scale', newScale); + Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); } else if(attr === 'reset') { resetView(gd, 'geo'); } @@ -27850,18 +27981,20 @@ modeBarButtons.hoverClosestPie = { click: toggleHover }; -function toggleHover(gd) { +function getNextHover(gd) { var fullLayout = gd._fullLayout; - var onHoverVal; + if(fullLayout.hovermode) return false; + if(fullLayout._has('cartesian')) { - onHoverVal = fullLayout._isHoriz ? 'y' : 'x'; + return fullLayout._isHoriz ? 'y' : 'x'; } - else onHoverVal = 'closest'; - - var newHover = gd._fullLayout.hovermode ? false : onHoverVal; + return 'closest'; +} - Registry.call('relayout', gd, 'hovermode', newHover); +function toggleHover(gd) { + var newHover = getNextHover(gd); + Registry.call('_guiRelayout', gd, 'hovermode', newHover); } // buttons when more then one plot types are present @@ -27875,12 +28008,10 @@ modeBarButtons.toggleHover = { icon: Icons.tooltip_basic, gravity: 'ne', click: function(gd, ev) { - toggleHover(gd); + var layoutUpdate = getNextHover3d(gd, ev); + layoutUpdate.hovermode = getNextHover(gd); - // the 3d hovermode update must come - // last so that layout.hovermode update does not - // override scene?.hovermode?.layout. - handleHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } }; @@ -27916,7 +28047,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } }; @@ -27963,10 +28094,10 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', gd, aObj); + Registry.call('_guiRelayout', gd, aObj); } -},{"../../../build/ploticon":2,"../../lib":165,"../../plots/cartesian/axis_ids":213,"../../plots/plots":251,"../../registry":259}],108:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":163,"../../plots/cartesian/axis_ids":211,"../../plots/plots":249,"../../registry":257}],104:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27980,7 +28111,7 @@ function resetView(gd, subplotType) { exports.manage = _dereq_('./manage'); -},{"./manage":109}],109:[function(_dereq_,module,exports){ +},{"./manage":105}],105:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28012,7 +28143,7 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar) { + if(!context.displayModeBar && !context.watermark) { if(modeBar) { modeBar.destroy(); delete fullLayout._modeBar; @@ -28040,11 +28171,15 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); } + else if(!context.displayModeBar && context.watermark) { + buttonGroups = []; + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, - context.modeBarButtonsToAdd + context.modeBarButtonsToAdd, + context.showSendToCloud ); } @@ -28053,7 +28188,7 @@ module.exports = function manageModeBar(gd) { }; // logic behind which buttons are displayed by default -function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { +function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; @@ -28084,7 +28219,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { } // buttons common to all plot types - addGroup(['toImage', 'sendDataToCloud']); + var commonGroup = ['toImage']; + if(showSendToCloud) commonGroup.push('sendDataToCloud'); + addGroup(commonGroup); var zoomGroup = []; var hoverGroup = []; @@ -28235,7 +28372,7 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":213,"../../registry":259,"../../traces/scatter/subtypes":305,"./buttons":107,"./modebar":110}],110:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axis_ids":211,"../../registry":257,"../../traces/scatter/subtypes":303,"./buttons":103,"./modebar":106}],106:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28318,11 +28455,16 @@ proto.update = function(graphInfo, buttons) { this.updateButtons(buttons); - if(context.displaylogo) { + if(context.watermark || context.displaylogo) { + var logoGroup = this.getLogo(); + if(context.watermark) { + logoGroup.className = logoGroup.className + ' watermark'; + } + if(fullLayout.modebar.orientation === 'v') { - this.element.prepend(this.getLogo()); + this.element.prepend(logoGroup); } else { - this.element.appendChild(this.getLogo()); + this.element.appendChild(logoGroup); } this.hasLogo = true; @@ -28581,7 +28723,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../../build/ploticon":2,"../../lib":165,"d3":9,"fast-isnumeric":11}],111:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":163,"d3":9,"fast-isnumeric":11}],107:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28717,7 +28859,7 @@ module.exports = { editType: 'plot' }; -},{"../../plot_api/plot_template":200,"../../plots/font_attributes":237,"../color/attributes":44}],112:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":198,"../../plots/font_attributes":235,"../color/attributes":44}],108:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28746,7 +28888,7 @@ module.exports = { darkAmount: 10 }; -},{}],113:[function(_dereq_,module,exports){ +},{}],109:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28839,7 +28981,7 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":165,"../../plot_api/plot_template":200,"../../plots/array_container_defaults":206,"../color":45,"./attributes":111,"./constants":112}],114:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plot_api/plot_template":198,"../../plots/array_container_defaults":204,"../color":45,"./attributes":107,"./constants":108}],110:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28859,7 +29001,6 @@ var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var alignmentConstants = _dereq_('../../constants/alignment'); var LINE_SPACING = alignmentConstants.LINE_SPACING; @@ -28911,7 +29052,7 @@ module.exports = function draw(gd) { button.on('click', function() { if(gd._dragged) return; - Registry.call('relayout', gd, update); + Registry.call('_guiRelayout', gd, update); }); button.on('mouseover', function() { @@ -29060,21 +29201,21 @@ function reposition(gd, buttons, opts, axName, selector) { var ly = graphSize.t + graphSize.h * (1 - opts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= width; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(opts)) { + if(Lib.isCenterAnchor(opts)) { lx -= width / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(opts)) { + if(Lib.isMiddleAnchor(opts)) { ly -= height / 2; yanchor = 'middle'; } @@ -29096,7 +29237,7 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', 'translate(' + lx + ',' + ly + ')'); } -},{"../../constants/alignment":143,"../../lib":165,"../../lib/svg_text_utils":186,"../../plots/cartesian/axis_ids":213,"../../plots/plots":251,"../../registry":259,"../color":45,"../drawing":70,"../legend/anchor_utils":97,"./constants":112,"./get_update_object":115,"d3":9}],115:[function(_dereq_,module,exports){ +},{"../../constants/alignment":140,"../../lib":163,"../../lib/svg_text_utils":184,"../../plots/cartesian/axis_ids":211,"../../plots/plots":249,"../../registry":257,"../color":45,"../drawing":66,"./constants":108,"./get_update_object":111,"d3":9}],111:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29153,7 +29294,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":9}],116:[function(_dereq_,module,exports){ +},{"d3":9}],112:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29180,7 +29321,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":111,"./defaults":113,"./draw":114}],117:[function(_dereq_,module,exports){ +},{"./attributes":107,"./defaults":109,"./draw":110}],113:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29254,7 +29395,7 @@ module.exports = { editType: 'calc' }; -},{"../color/attributes":44}],118:[function(_dereq_,module,exports){ +},{"../color/attributes":44}],114:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29288,7 +29429,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":209,"../../plots/cartesian/axis_ids":213,"./constants":119}],119:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/autorange":207,"../../plots/cartesian/axis_ids":211,"./constants":115}],115:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29344,7 +29485,7 @@ module.exports = { extraPad: 15 }; -},{}],120:[function(_dereq_,module,exports){ +},{}],116:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29430,7 +29571,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":165,"../../plot_api/plot_template":200,"../../plots/cartesian/axis_ids":213,"./attributes":117,"./oppaxis_attributes":123}],121:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plot_api/plot_template":198,"../../plots/cartesian/axis_ids":211,"./attributes":113,"./oppaxis_attributes":120}],117:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29452,7 +29593,7 @@ var Color = _dereq_('../color'); var Titles = _dereq_('../titles'); var Cartesian = _dereq_('../../plots/cartesian'); -var Axes = _dereq_('../../plots/cartesian/axes'); +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); var dragElement = _dereq_('../dragelement'); var setCursor = _dereq_('../../lib/setcursor'); @@ -29460,8 +29601,13 @@ var setCursor = _dereq_('../../lib/setcursor'); var constants = _dereq_('./constants'); module.exports = function(gd) { - var fullLayout = gd._fullLayout, - rangeSliderData = makeRangeSliderData(fullLayout); + var fullLayout = gd._fullLayout; + var rangeSliderData = fullLayout._rangeSliderData; + for(var i = 0; i < rangeSliderData.length; i++) { + var opts = rangeSliderData[i][constants.name]; + // fullLayout._uid may not exist when we call makeData + opts._clipId = opts._id + '-' + fullLayout._uid; + } /* * @@ -29488,10 +29634,6 @@ module.exports = function(gd) { .selectAll('g.' + constants.containerClassName) .data(rangeSliderData, keyFunction); - rangeSliders.enter().append('g') - .classed(constants.containerClassName, true) - .attr('pointer-events', 'all'); - // remove exiting sliders and their corresponding clip paths rangeSliders.exit().each(function(axisOpts) { var opts = axisOpts[constants.name]; @@ -29501,48 +29643,51 @@ module.exports = function(gd) { // return early if no range slider is visible if(rangeSliderData.length === 0) return; + rangeSliders.enter().append('g') + .classed(constants.containerClassName, true) + .attr('pointer-events', 'all'); + // for all present range sliders rangeSliders.each(function(axisOpts) { - var rangeSlider = d3.select(this), - opts = axisOpts[constants.name], - oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)], - oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)]; + var rangeSlider = d3.select(this); + var opts = axisOpts[constants.name]; + var oppAxisOpts = fullLayout[axisIDs.id2name(axisOpts.anchor)]; + var oppAxisRangeOpts = opts[axisIDs.id2name(axisOpts.anchor)]; // update range // Expand slider range to the axis range - // TODO: what if the ranges are reversed? if(opts.range) { - var outRange = opts.range; - var axRange = axisOpts.range; + var rng = Lib.simpleMap(opts.range, axisOpts.r2l); + var axRng = Lib.simpleMap(axisOpts.range, axisOpts.r2l); + var newRng; + + if(axRng[0] < axRng[1]) { + newRng = [ + Math.min(rng[0], axRng[0]), + Math.max(rng[1], axRng[1]) + ]; + } else { + newRng = [ + Math.max(rng[0], axRng[0]), + Math.min(rng[1], axRng[1]) + ]; + } - outRange[0] = axisOpts.l2r(Math.min(axisOpts.r2l(outRange[0]), axisOpts.r2l(axRange[0]))); - outRange[1] = axisOpts.l2r(Math.max(axisOpts.r2l(outRange[1]), axisOpts.r2l(axRange[1]))); - opts._input.range = outRange.slice(); + opts.range = opts._input.range = Lib.simpleMap(newRng, axisOpts.l2r); } axisOpts.cleanRange('rangeslider.range'); - // update range slider dimensions var margin = fullLayout.margin; var graphSize = fullLayout._size; var domain = axisOpts.domain; - var tickHeight = (axisOpts._boundingBox || {}).height || 0; - - var oppBottom = Infinity; - var subplotData = Axes.getSubplots(gd, axisOpts); - for(var i = 0; i < subplotData.length; i++) { - var oppAxis = Axes.getFromId(gd, subplotData[i].substr(subplotData[i].indexOf('y'))); - oppBottom = Math.min(oppBottom, oppAxis.domain[0]); - } + var tickHeight = opts._tickHeight; - opts._id = constants.name + axisOpts._id; - opts._clipId = opts._id + '-' + fullLayout._uid; + var oppBottom = opts._oppBottom; opts._width = graphSize.w * (domain[1] - domain[0]); - opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; - opts._offsetShift = Math.floor(opts.borderwidth / 2); var x = Math.round(margin.l + (graphSize.w * domain[0])); @@ -29605,41 +29750,14 @@ module.exports = function(gd) { placeholder: fullLayout._dfltTitle.x, attributes: { x: axisOpts._offset + axisOpts._length / 2, - y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size, + y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.title.font.size, 'text-anchor': 'middle' } }); } - - // update margins - Plots.autoMargin(gd, opts._id, { - x: domain[0], - y: oppBottom, - l: 0, - r: 0, - t: 0, - b: opts._height + margin.b + tickHeight, - pad: constants.extraPad + opts._offsetShift * 2 - }); }); }; -function makeRangeSliderData(fullLayout) { - var axes = Axes.list({ _fullLayout: fullLayout }, 'x', true), - name = constants.name, - out = []; - - if(fullLayout._has('gl2d')) return out; - - for(var i = 0; i < axes.length; i++) { - var ax = axes[i]; - - if(ax[name] && ax[name].visible) out.push(ax); - } - - return out; -} - function setupDragElement(rangeSlider, gd, axisOpts, opts) { var slideBox = rangeSlider.select('rect.' + constants.slideBoxClassName).node(), grabAreaMin = rangeSlider.select('rect.' + constants.grabAreaMinClassName).node(), @@ -29719,7 +29837,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) { dataMax = clamp(opts.p2d(opts._pixelMax)); window.requestAnimationFrame(function() { - Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); + Registry.call('_guiRelayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); }); } @@ -29826,15 +29944,14 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) { } function drawRangePlot(rangeSlider, gd, axisOpts, opts) { - var subplotData = Axes.getSubplots(gd, axisOpts), - calcData = gd.calcdata; + var calcData = gd.calcdata; var rangePlots = rangeSlider.selectAll('g.' + constants.rangePlotClassName) - .data(subplotData, Lib.identity); + .data(axisOpts._subplotsWith, Lib.identity); rangePlots.enter().append('g') .attr('class', function(id) { return constants.rangePlotClassName + ' ' + id; }) - .call(Drawing.setClipUrl, opts._clipId); + .call(Drawing.setClipUrl, opts._clipId, gd); rangePlots.order(); @@ -29846,7 +29963,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var plotgroup = d3.select(this), isMainPlot = (i === 0); - var oppAxisOpts = Axes.getFromId(gd, id, 'y'), + var oppAxisOpts = axisIDs.getFromId(gd, id, 'y'), oppAxisName = oppAxisOpts._name, oppAxisRangeOpts = opts[oppAxisName]; @@ -29878,6 +29995,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var xa = mockFigure._fullLayout.xaxis; var ya = mockFigure._fullLayout[oppAxisName]; + xa.clearCalc(); + xa.setScale(); + ya.clearCalc(); + ya.setScale(); + var plotinfo = { id: id, plotgroup: plotgroup, @@ -30030,7 +30152,77 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":165,"../../lib/setcursor":184,"../../plots/cartesian":222,"../../plots/cartesian/axes":210,"../../plots/plots":251,"../../registry":259,"../color":45,"../dragelement":67,"../drawing":70,"../titles":136,"./constants":119,"d3":9}],122:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../lib/setcursor":182,"../../plots/cartesian":220,"../../plots/cartesian/axis_ids":211,"../../plots/plots":249,"../../registry":257,"../color":45,"../dragelement":63,"../drawing":66,"../titles":133,"./constants":115,"d3":9}],118:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); +var constants = _dereq_('./constants'); +var name = constants.name; + +function isVisible(ax) { + var rangeSlider = ax && ax[name]; + return rangeSlider && rangeSlider.visible; +} +exports.isVisible = isVisible; + +exports.makeData = function(fullLayout) { + var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true); + var margin = fullLayout.margin; + var rangeSliderData = []; + + if(!fullLayout._has('gl2d')) { + for(var i = 0; i < axes.length; i++) { + var ax = axes[i]; + + if(isVisible(ax)) { + rangeSliderData.push(ax); + + var opts = ax[name]; + opts._id = name + ax._id; + opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; + opts._offsetShift = Math.floor(opts.borderwidth / 2); + } + } + } + + fullLayout._rangeSliderData = rangeSliderData; +}; + +exports.autoMarginOpts = function(gd, ax) { + var opts = ax[name]; + + var oppBottom = Infinity; + var counterAxes = ax._counterAxes; + for(var j = 0; j < counterAxes.length; j++) { + var counterId = counterAxes[j]; + var oppAxis = axisIDs.getFromId(gd, counterId); + oppBottom = Math.min(oppBottom, oppAxis.domain[0]); + } + opts._oppBottom = oppBottom; + + var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0; + opts._tickHeight = tickHeight; + + return { + x: 0, + y: oppBottom, + l: 0, + r: 0, + t: 0, + b: opts._height + gd._fullLayout.margin.b + tickHeight, + pad: constants.extraPad + opts._offsetShift * 2 + }; +}; + +},{"../../plots/cartesian/axis_ids":211,"./constants":115}],119:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30044,6 +30236,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { var Lib = _dereq_('../../lib'); var attrs = _dereq_('./attributes'); var oppAxisAttrs = _dereq_('./oppaxis_attributes'); +var helpers = _dereq_('./helpers'); module.exports = { moduleType: 'component', @@ -30062,10 +30255,13 @@ module.exports = { layoutAttributes: _dereq_('./attributes'), handleDefaults: _dereq_('./defaults'), calcAutorange: _dereq_('./calc_autorange'), - draw: _dereq_('./draw') + draw: _dereq_('./draw'), + isVisible: helpers.isVisible, + makeData: helpers.makeData, + autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":165,"./attributes":117,"./calc_autorange":118,"./defaults":120,"./draw":121,"./oppaxis_attributes":123}],123:[function(_dereq_,module,exports){ +},{"../../lib":163,"./attributes":113,"./calc_autorange":114,"./defaults":116,"./draw":117,"./helpers":118,"./oppaxis_attributes":120}],120:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30103,7 +30299,7 @@ module.exports = { editType: 'calc' }; -},{}],124:[function(_dereq_,module,exports){ +},{}],121:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30239,7 +30435,7 @@ module.exports = templatedArray('shape', { editType: 'arraydraw' }); -},{"../../lib/extend":157,"../../plot_api/plot_template":200,"../../traces/scatter/attributes":281,"../annotations/attributes":30,"../drawing/attributes":69}],125:[function(_dereq_,module,exports){ +},{"../../lib/extend":155,"../../plot_api/plot_template":198,"../../traces/scatter/attributes":279,"../annotations/attributes":30,"../drawing/attributes":65}],122:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30248,7 +30444,6 @@ module.exports = templatedArray('shape', { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); @@ -30326,7 +30521,7 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { } function shapeBounds(ax, v0, v1, path, paramsToUse) { - var convertVal = (ax.type === 'category') ? ax.r2c : ax.d2c; + var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; if(!path) return; @@ -30357,7 +30552,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":165,"../../plots/cartesian/axes":210,"./constants":126,"./helpers":129}],126:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/cartesian/axes":208,"./constants":123,"./helpers":126}],123:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30421,7 +30616,7 @@ module.exports = { } }; -},{}],127:[function(_dereq_,module,exports){ +},{}],124:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30546,7 +30741,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":165,"../../plots/array_container_defaults":206,"../../plots/cartesian/axes":210,"./attributes":124,"./helpers":129}],128:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/array_container_defaults":204,"../../plots/cartesian/axes":208,"./attributes":121,"./helpers":126}],125:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30669,9 +30864,10 @@ function setClipPath(shapePath, gd, shapeOptions) { // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 var clipAxes = (shapeOptions.xref + shapeOptions.yref).replace(/paper/g, ''); - shapePath.call(Drawing.setClipUrl, clipAxes ? - ('clip' + gd._fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } @@ -30855,7 +31051,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { // Don't rely on clipPath being activated during re-layout setClipPath(shapePath, gd, shapeOptions); - Registry.call('relayout', gd, editHelpers.getUpdateObj()); + Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj()); } function abortDrag() { @@ -31042,9 +31238,10 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(xref !== 'paper' && !xa.autorange) clipAxes += xref; if(yref !== 'paper' && !ya.autorange) clipAxes += yref; - shapePath.call(Drawing.setClipUrl, clipAxes ? - 'clip' + gd._fullLayout._uid + clipAxes : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } } @@ -31176,7 +31373,7 @@ function movePath(pathIn, moveX, moveY) { }); } -},{"../../lib":165,"../../lib/setcursor":184,"../../plot_api/plot_template":200,"../../plots/cartesian/axes":210,"../../registry":259,"../color":45,"../dragelement":67,"../drawing":70,"./constants":126,"./helpers":129}],129:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../lib/setcursor":182,"../../plot_api/plot_template":198,"../../plots/cartesian/axes":208,"../../registry":257,"../color":45,"../dragelement":63,"../drawing":66,"./constants":123,"./helpers":126}],126:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31301,7 +31498,7 @@ exports.roundPositionForSharpStrokeRendering = function(pos, strokeWidth) { return strokeWidthIsOdd ? posValAsInt + 0.5 : posValAsInt; }; -},{"../../lib":165,"./constants":126}],130:[function(_dereq_,module,exports){ +},{"../../lib":163,"./constants":123}],127:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31328,7 +31525,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":221,"./attributes":124,"./calc_autorange":125,"./defaults":127,"./draw":128}],131:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":219,"./attributes":121,"./calc_autorange":122,"./defaults":124,"./draw":125}],128:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31430,7 +31627,7 @@ module.exports = overrideAll(templatedArray('slider', { }, - pad: extendDeepAll({}, padAttrs, { + pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { }, {t: {dflt: 20}}), xanchor: { @@ -31571,7 +31768,7 @@ module.exports = overrideAll(templatedArray('slider', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":157,"../../plot_api/edit_types":193,"../../plot_api/plot_template":200,"../../plots/animation_attributes":205,"../../plots/font_attributes":237,"../../plots/pad_attributes":250,"./constants":132}],132:[function(_dereq_,module,exports){ +},{"../../lib/extend":155,"../../plot_api/edit_types":191,"../../plot_api/plot_template":198,"../../plots/animation_attributes":203,"../../plots/font_attributes":235,"../../plots/pad_attributes":248,"./constants":129}],129:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31665,7 +31862,7 @@ module.exports = { currentValueInset: 0, }; -},{}],133:[function(_dereq_,module,exports){ +},{}],130:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31782,7 +31979,7 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":165,"../../plots/array_container_defaults":206,"./attributes":131,"./constants":132}],134:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/array_container_defaults":204,"./attributes":128,"./constants":129}],131:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31800,7 +31997,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var constants = _dereq_('./constants'); @@ -31992,21 +32188,21 @@ function findDimensions(gd, sliderOpts) { dims.height = dims.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + dims.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(sliderOpts)) { + if(Lib.isRightAnchor(sliderOpts)) { dims.lx -= dims.outerLength; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(sliderOpts)) { + if(Lib.isCenterAnchor(sliderOpts)) { dims.lx -= dims.outerLength / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(sliderOpts)) { + if(Lib.isBottomAnchor(sliderOpts)) { dims.ly -= dims.height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(sliderOpts)) { + if(Lib.isMiddleAnchor(sliderOpts)) { dims.ly -= dims.height / 2; yanchor = 'middle'; } @@ -32413,7 +32609,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":143,"../../lib":165,"../../lib/svg_text_utils":186,"../../plot_api/plot_template":200,"../../plots/plots":251,"../color":45,"../drawing":70,"../legend/anchor_utils":97,"./constants":132,"d3":9}],135:[function(_dereq_,module,exports){ +},{"../../constants/alignment":140,"../../lib":163,"../../lib/svg_text_utils":184,"../../plot_api/plot_template":198,"../../plots/plots":249,"../color":45,"../drawing":66,"./constants":129,"d3":9}],132:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32436,7 +32632,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":131,"./constants":132,"./defaults":133,"./draw":134}],136:[function(_dereq_,module,exports){ +},{"./attributes":128,"./constants":129,"./defaults":130,"./draw":131}],133:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32506,19 +32702,21 @@ function draw(gd, titleClass, options) { var group = options.containerGroup; var fullLayout = gd._fullLayout; - var titlefont = cont.titlefont || {}; - var font = titlefont.family; - var fontSize = titlefont.size; - var fontColor = titlefont.color; var opacity = 1; var isplaceholder = false; - var txt = (cont.title || '').trim(); + var title = cont.title; + var txt = (title && title.text ? title.text : '').trim(); + + var font = title && title.font ? title.font : {}; + var fontFamily = font.family; + var fontSize = font.size; + var fontColor = font.color; // only make this title editable if we positively identify its property // as one that has editing enabled. var editAttr; - if(prop === 'title') editAttr = 'titleText'; + if(prop === 'title.text') editAttr = 'titleText'; else if(prop.indexOf('axis') !== -1) editAttr = 'axisTitleText'; else if(prop.indexOf('colorbar' !== -1)) editAttr = 'colorbarTitleText'; var editable = gd._context.edits[editAttr]; @@ -32576,7 +32774,7 @@ function draw(gd, titleClass, options) { titleEl.attr('transform', transformVal); titleEl.style({ - 'font-family': font, + 'font-family': fontFamily, 'font-size': d3.round(fontSize, 2) + 'px', fill: Color.rgb(fontColor), opacity: opacity * Color.opacity(fontColor), @@ -32676,9 +32874,9 @@ function draw(gd, titleClass, options) { el.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { if(traceIndex !== undefined) { - Registry.call('restyle', gd, prop, text, traceIndex); + Registry.call('_guiRestyle', gd, prop, text, traceIndex); } else { - Registry.call('relayout', gd, prop, text); + Registry.call('_guiRelayout', gd, prop, text); } }) .on('cancel', function() { @@ -32695,7 +32893,7 @@ function draw(gd, titleClass, options) { return group; } -},{"../../constants/interactions":144,"../../lib":165,"../../lib/svg_text_utils":186,"../../plots/plots":251,"../../registry":259,"../color":45,"../drawing":70,"d3":9,"fast-isnumeric":11}],137:[function(_dereq_,module,exports){ +},{"../../constants/interactions":141,"../../lib":163,"../../lib/svg_text_utils":184,"../../plots/plots":249,"../../registry":257,"../color":45,"../drawing":66,"d3":9,"fast-isnumeric":11}],134:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32824,7 +33022,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { }, - pad: extendFlat({}, padAttrs, { + pad: extendFlat(padAttrs({editType: 'arraydraw'}), { }), @@ -32853,7 +33051,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":157,"../../plot_api/edit_types":193,"../../plot_api/plot_template":200,"../../plots/font_attributes":237,"../../plots/pad_attributes":250,"../color/attributes":44}],138:[function(_dereq_,module,exports){ +},{"../../lib/extend":155,"../../plot_api/edit_types":191,"../../plot_api/plot_template":198,"../../plots/font_attributes":235,"../../plots/pad_attributes":248,"../color/attributes":44}],135:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32934,7 +33132,7 @@ module.exports = { } }; -},{}],139:[function(_dereq_,module,exports){ +},{}],136:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33017,7 +33215,7 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":165,"../../plots/array_container_defaults":206,"./attributes":137,"./constants":138}],140:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/array_container_defaults":204,"./attributes":134,"./constants":135}],137:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33036,7 +33234,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var LINE_SPACING = _dereq_('../../constants/alignment').LINE_SPACING; @@ -33586,21 +33783,21 @@ function findDimensions(gd, menuOpts) { dims.ly = graphSize.t + graphSize.h * (1 - menuOpts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(menuOpts)) { + if(Lib.isRightAnchor(menuOpts)) { dims.lx -= paddedWidth; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(menuOpts)) { + if(Lib.isCenterAnchor(menuOpts)) { dims.lx -= paddedWidth / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(menuOpts)) { + if(Lib.isBottomAnchor(menuOpts)) { dims.ly -= paddedHeight; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(menuOpts)) { + if(Lib.isMiddleAnchor(menuOpts)) { dims.ly -= paddedHeight / 2; yanchor = 'middle'; } @@ -33667,9 +33864,9 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":143,"../../lib":165,"../../lib/svg_text_utils":186,"../../plot_api/plot_template":200,"../../plots/plots":251,"../color":45,"../drawing":70,"../legend/anchor_utils":97,"./constants":138,"./scrollbox":142,"d3":9}],141:[function(_dereq_,module,exports){ -arguments[4][135][0].apply(exports,arguments) -},{"./attributes":137,"./constants":138,"./defaults":139,"./draw":140,"dup":135}],142:[function(_dereq_,module,exports){ +},{"../../constants/alignment":140,"../../lib":163,"../../lib/svg_text_utils":184,"../../plot_api/plot_template":198,"../../plots/plots":249,"../color":45,"../drawing":66,"./constants":135,"./scrollbox":139,"d3":9}],138:[function(_dereq_,module,exports){ +arguments[4][132][0].apply(exports,arguments) +},{"./attributes":134,"./constants":135,"./defaults":136,"./draw":137,"dup":132}],139:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33926,7 +34123,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { height: Math.ceil(clipB) - Math.floor(clipT) }); - this.container.call(Drawing.setClipUrl, clipId); + this.container.call(Drawing.setClipUrl, clipId, this.gd); this.bg.attr({ x: l, @@ -34140,7 +34337,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":165,"../color":45,"../drawing":70,"d3":9}],143:[function(_dereq_,module,exports){ +},{"../../lib":163,"../color":45,"../drawing":66,"d3":9}],140:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34184,12 +34381,17 @@ module.exports = { // multiple of fontSize to get the vertical offset between lines LINE_SPACING: 1.3, - // multiple of fontSize to shift from the baseline to the midline + // multiple of fontSize to shift from the baseline + // to the cap (captical letter) line // (to use when we don't calculate this shift from Drawing.bBox) - // To be precise this should be half the cap height (capital letter) - // of the font, and according to wikipedia: + // This is an approximation since in reality cap height can differ + // from font to font. However, according to Wikipedia // an "average" font might have a cap height of 70% of the em // https://en.wikipedia.org/wiki/Em_(typography)#History + CAP_SHIFT: 0.70, + + // half the cap height (distance between baseline and cap line) + // of an "average" font (for more info see above). MID_SHIFT: 0.35, OPPOSITE_SIDE: { @@ -34200,7 +34402,7 @@ module.exports = { } }; -},{}],144:[function(_dereq_,module,exports){ +},{}],141:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34227,7 +34429,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],145:[function(_dereq_,module,exports){ +},{}],142:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34292,7 +34494,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],146:[function(_dereq_,module,exports){ +},{}],143:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34316,7 +34518,7 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],147:[function(_dereq_,module,exports){ +},{}],144:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34328,7 +34530,7 @@ exports.svgAttrs = { 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.42.5'; +exports.version = '1.43.0'; // inject promise polyfill _dereq_('es6-promise').polyfill(); @@ -34337,7 +34539,7 @@ _dereq_('es6-promise').polyfill(); _dereq_('../build/plotcss'); // inject default MathJax config -_dereq_('./fonts/mathjax_config'); +_dereq_('./fonts/mathjax_config')(); // include registry module and expose register method var Registry = _dereq_('./registry'); @@ -34348,7 +34550,8 @@ var plotApi = _dereq_('./plot_api'); var methodNames = Object.keys(plotApi); for(var i = 0; i < methodNames.length; i++) { var name = methodNames[i]; - exports[name] = plotApi[name]; + // _ -> private API methods, but still registered for internal use + if(name.charAt(0) !== '_') exports[name] = plotApi[name]; register({ moduleType: 'apiMethod', name: name, @@ -34372,7 +34575,8 @@ register([ _dereq_('./components/rangeslider'), _dereq_('./components/rangeselector'), _dereq_('./components/grid'), - _dereq_('./components/errorbars') + _dereq_('./components/errorbars'), + _dereq_('./components/colorscale') ]); // locales en and en-US are required for default behavior @@ -34394,7 +34598,7 @@ exports.Queue = _dereq_('./lib/queue'); // export d3 used in the bundle exports.d3 = _dereq_('d3'); -},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":38,"./components/annotations3d":43,"./components/errorbars":76,"./components/fx":87,"./components/grid":91,"./components/images":96,"./components/legend":105,"./components/rangeselector":116,"./components/rangeslider":122,"./components/shapes":130,"./components/sliders":135,"./components/updatemenus":141,"./fonts/mathjax_config":148,"./lib/queue":179,"./locale-en":191,"./locale-en-us":190,"./plot_api":195,"./plot_api/plot_schema":199,"./plots/plots":251,"./registry":259,"./snapshot":264,"./traces/scatter":293,"d3":9,"es6-promise":10}],148:[function(_dereq_,module,exports){ +},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":38,"./components/annotations3d":43,"./components/colorscale":57,"./components/errorbars":72,"./components/fx":84,"./components/grid":88,"./components/images":93,"./components/legend":101,"./components/rangeselector":112,"./components/rangeslider":119,"./components/shapes":127,"./components/sliders":132,"./components/updatemenus":138,"./fonts/mathjax_config":145,"./lib/queue":177,"./locale-en":189,"./locale-en-us":188,"./plot_api":193,"./plot_api/plot_schema":197,"./plots/plots":249,"./registry":257,"./snapshot":262,"./traces/scatter":291,"d3":9,"es6-promise":10}],145:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34407,31 +34611,89 @@ exports.d3 = _dereq_('d3'); /* global MathJax:false */ +module.exports = function() { + if(typeof MathJax !== 'undefined') { + var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; + + if(globalConfig) { + MathJax.Hub.Config({ + messageStyle: 'none', + skipStartupTypeset: true, + displayAlign: 'left', + tex2jax: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + } + }); + MathJax.Hub.Configured(); + } + } +}; + +},{}],146:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + + /** - * Check and configure MathJax + * Determine the position anchor property of x/y xanchor/yanchor components. + * + * - values < 1/3 align the low side at that fraction, + * - values [1/3, 2/3] align the center at that fraction, + * - values > 2/3 align the right at that fraction. */ -if(typeof MathJax !== 'undefined') { - exports.MathJax = true; - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } +exports.isLeftAnchor = function isLeftAnchor(opts) { + return ( + opts.xanchor === 'left' || + (opts.xanchor === 'auto' && opts.x <= 1 / 3) + ); +}; -} else { - exports.MathJax = false; -} +exports.isCenterAnchor = function isCenterAnchor(opts) { + return ( + opts.xanchor === 'center' || + (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) + ); +}; -},{}],149:[function(_dereq_,module,exports){ +exports.isRightAnchor = function isRightAnchor(opts) { + return ( + opts.xanchor === 'right' || + (opts.xanchor === 'auto' && opts.x >= 2 / 3) + ); +}; + +exports.isTopAnchor = function isTopAnchor(opts) { + return ( + opts.yanchor === 'top' || + (opts.yanchor === 'auto' && opts.y >= 2 / 3) + ); +}; + +exports.isMiddleAnchor = function isMiddleAnchor(opts) { + return ( + opts.yanchor === 'middle' || + (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) + ); +}; + +exports.isBottomAnchor = function isBottomAnchor(opts) { + return ( + opts.yanchor === 'bottom' || + (opts.yanchor === 'auto' && opts.y <= 1 / 3) + ); +}; + +},{}],147:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34672,7 +34934,7 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":172}],150:[function(_dereq_,module,exports){ +},{"./mod":170}],148:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34808,7 +35070,30 @@ exports.concat = function() { return out; }; -},{}],151:[function(_dereq_,module,exports){ +exports.maxRowLength = function(z) { + return _rowLength(z, Math.max, 0); +}; + +exports.minRowLength = function(z) { + return _rowLength(z, Math.min, Infinity); +}; + +function _rowLength(z, fn, len0) { + if(isArrayOrTypedArray(z)) { + if(isArrayOrTypedArray(z[0])) { + var len = len0; + for(var i = 0; i < z.length; i++) { + len = fn(len, z[i].length); + } + return len; + } else { + return z.length; + } + } + return 0; +} + +},{}],149:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34841,7 +35126,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":145,"fast-isnumeric":11}],152:[function(_dereq_,module,exports){ +},{"../constants/numerical":142,"fast-isnumeric":11}],150:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34869,7 +35154,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],153:[function(_dereq_,module,exports){ +},{}],151:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34892,7 +35177,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],154:[function(_dereq_,module,exports){ +},{}],152:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34901,18 +35186,17 @@ module.exports = function clearResponsive(gd) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); var baseTraceAttrs = _dereq_('../plots/attributes'); -var getColorscale = _dereq_('../components/colorscale/get_scale'); -var colorscaleNames = Object.keys(_dereq_('../components/colorscale/scales')); +var scales = _dereq_('../components/colorscale/scales'); +var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; + var nestedProperty = _dereq_('./nested_property'); var counterRegex = _dereq_('./regex').counter; -var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; var modHalf = _dereq_('./mod').modHalf; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -35030,7 +35314,7 @@ exports.valObjectMeta = { coerceFunction: function(v, propOut, dflt) { - propOut.set(getColorscale(v, dflt)); + propOut.set(scales.get(v, dflt)); } }, angle: { @@ -35364,7 +35648,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/get_scale":58,"../components/colorscale/scales":64,"../constants/interactions":144,"../plots/attributes":207,"./array":150,"./mod":172,"./nested_property":173,"./regex":180,"fast-isnumeric":11,"tinycolor2":27}],155:[function(_dereq_,module,exports){ +},{"../components/colorscale/scales":60,"../constants/interactions":141,"../plots/attributes":205,"./array":148,"./mod":170,"./nested_property":171,"./regex":178,"fast-isnumeric":11,"tinycolor2":27}],153:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35967,7 +36251,7 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":145,"../registry":259,"./loggers":169,"./mod":172,"d3":9,"fast-isnumeric":11}],156:[function(_dereq_,module,exports){ +},{"../constants/numerical":142,"../registry":257,"./loggers":167,"./mod":170,"d3":9,"fast-isnumeric":11}],154:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36141,7 +36425,7 @@ var Events = { module.exports = Events; -},{"events":7}],157:[function(_dereq_,module,exports){ +},{"events":7}],155:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36257,7 +36541,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":166}],158:[function(_dereq_,module,exports){ +},{"./is_plain_object.js":164}],156:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36308,7 +36592,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],159:[function(_dereq_,module,exports){ +},{}],157:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36355,7 +36639,7 @@ function isCalcData(cont) { ); } -},{}],160:[function(_dereq_,module,exports){ +},{}],158:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36419,7 +36703,7 @@ function countryNameToISO3(countryName) { return false; } -},{"../lib":165,"country-regex":8}],161:[function(_dereq_,module,exports){ +},{"../lib":163,"country-regex":8}],159:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36536,7 +36820,7 @@ exports.makeBlank = function() { }; }; -},{"../constants/numerical":145}],162:[function(_dereq_,module,exports){ +},{"../constants/numerical":142}],160:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36782,7 +37066,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":172}],163:[function(_dereq_,module,exports){ +},{"./mod":170}],161:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36820,7 +37104,7 @@ module.exports = function(gd) { return gd; // otherwise assume that gd is a DOM element }; -},{}],164:[function(_dereq_,module,exports){ +},{}],162:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36836,7 +37120,7 @@ module.exports = function(gd) { module.exports = function identity(d) { return d; }; -},{}],165:[function(_dereq_,module,exports){ +},{}],163:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36870,6 +37154,8 @@ lib.isArrayOrTypedArray = arrayModule.isArrayOrTypedArray; lib.isArray1D = arrayModule.isArray1D; lib.ensureArray = arrayModule.ensureArray; lib.concat = arrayModule.concat; +lib.maxRowLength = arrayModule.maxRowLength; +lib.minRowLength = arrayModule.minRowLength; var modModule = _dereq_('./mod'); lib.mod = modModule.mod; @@ -36939,6 +37225,14 @@ lib.pathArc = anglesModule.pathArc; lib.pathSector = anglesModule.pathSector; lib.pathAnnulus = anglesModule.pathAnnulus; +var anchorUtils = _dereq_('./anchor_utils'); +lib.isLeftAnchor = anchorUtils.isLeftAnchor; +lib.isCenterAnchor = anchorUtils.isCenterAnchor; +lib.isRightAnchor = anchorUtils.isRightAnchor; +lib.isTopAnchor = anchorUtils.isTopAnchor; +lib.isMiddleAnchor = anchorUtils.isMiddleAnchor; +lib.isBottomAnchor = anchorUtils.isBottomAnchor; + var geom2dModule = _dereq_('./geometry2d'); lib.segmentsIntersect = geom2dModule.segmentsIntersect; lib.segmentDistance = geom2dModule.segmentDistance; @@ -37473,7 +37767,13 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) objOut[k] = v.slice(0, arrayLen); + else if(Array.isArray(v)) { + if(k === 'colorscale') { + objOut[k] = v.slice(); + } else { + objOut[k] = v.slice(0, arrayLen); + } + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -37818,10 +38118,10 @@ lib.numSeparate = function(value, separators, separatethousands) { return x1 + x2; }; -var TEMPLATE_STRING_REGEX = /%{([^\s%{}]*)}/g; +var TEMPLATE_STRING_REGEX = /%{([^\s%{}:]*)(:[^}]*)?}/g; var SIMPLE_PROPERTY_REGEX = /^\w*$/; -/* +/** * Substitute values from an object into a string * * Examples: @@ -37833,7 +38133,6 @@ var SIMPLE_PROPERTY_REGEX = /^\w*$/; * * @return {string} templated string */ - lib.templateString = function(string, obj) { // Not all that useful, but cache nestedProperty instantiation // just in case it speeds things up *slightly*: @@ -37848,6 +38147,67 @@ lib.templateString = function(string, obj) { }); }; +var TEMPLATE_STRING_FORMAT_SEPARATOR = /^:/; +var numberOfHoverTemplateWarnings = 0; +var maximumNumberOfHoverTemplateWarnings = 10; +/** + * Substitute values from an object into a string and optionally formats them using d3-format, + * or fallback to associated labels. + * + * Examples: + * Lib.templateString('name: %{trace}', {trace: 'asdf'}) --> 'name: asdf' + * Lib.templateString('name: %{trace[0].name}', {trace: [{name: 'asdf'}]}) --> 'name: asdf' + * Lib.templateString('price: %{y:$.2f}', {y: 1}) --> 'price: $1.00' + * + * @param {string} input string containing %{...:...} template strings + * @param {obj} data object containing fallback text when no formatting is specified, ex.: {yLabel: 'formattedYValue'} + * @param {obj} data objects containing substitution values + * + * @return {string} templated string + */ +lib.hovertemplateString = function(string, labels) { + var args = arguments; + // Not all that useful, but cache nestedProperty instantiation + // just in case it speeds things up *slightly*: + var getterCache = {}; + + return string.replace(TEMPLATE_STRING_REGEX, function(match, key, format) { + var obj, value, i; + for(i = 2; i < args.length; i++) { + obj = args[i]; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; + } + + if(value === undefined) { + if(numberOfHoverTemplateWarnings < maximumNumberOfHoverTemplateWarnings) { + lib.warn('Variable \'' + key + '\' in hovertemplate could not be found!'); + value = match; + } + + if(numberOfHoverTemplateWarnings === maximumNumberOfHoverTemplateWarnings) { + lib.warn('Too many hovertemplate warnings - additional warnings will be suppressed'); + } + numberOfHoverTemplateWarnings++; + } + + if(format) { + value = d3.format(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value); + } else { + if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + } + return value; + }); +}; + /* * alphanumeric string sort, tailored for subplot IDs like scene2, scene10, x10y13 etc */ @@ -37890,7 +38250,7 @@ lib.pseudoRandom = function() { return randSeed / 4294967296; }; -},{"../constants/numerical":145,"./angles":149,"./array":150,"./clean_number":151,"./clear_responsive":153,"./coerce":154,"./dates":155,"./extend":157,"./filter_unique":158,"./filter_visible":159,"./geometry2d":162,"./get_graph_div":163,"./identity":164,"./is_plain_object":166,"./keyed_container":167,"./localize":168,"./loggers":169,"./make_trace_groups":170,"./matrix":171,"./mod":172,"./nested_property":173,"./noop":174,"./notifier":175,"./push_unique":178,"./regex":180,"./relative_attr":181,"./relink_private":182,"./search":183,"./stats":185,"./throttle":187,"./to_log_range":188,"d3":9,"fast-isnumeric":11}],166:[function(_dereq_,module,exports){ +},{"../constants/numerical":142,"./anchor_utils":146,"./angles":147,"./array":148,"./clean_number":149,"./clear_responsive":151,"./coerce":152,"./dates":153,"./extend":155,"./filter_unique":156,"./filter_visible":157,"./geometry2d":160,"./get_graph_div":161,"./identity":162,"./is_plain_object":164,"./keyed_container":165,"./localize":166,"./loggers":167,"./make_trace_groups":168,"./matrix":169,"./mod":170,"./nested_property":171,"./noop":172,"./notifier":173,"./push_unique":176,"./regex":178,"./relative_attr":179,"./relink_private":180,"./search":181,"./stats":183,"./throttle":185,"./to_log_range":186,"d3":9,"fast-isnumeric":11}],164:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37919,7 +38279,7 @@ module.exports = function isPlainObject(obj) { ); }; -},{}],167:[function(_dereq_,module,exports){ +},{}],165:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38112,7 +38472,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":173}],168:[function(_dereq_,module,exports){ +},{"./nested_property":171}],166:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38168,7 +38528,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":259}],169:[function(_dereq_,module,exports){ +},{"../registry":257}],167:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38254,7 +38614,7 @@ function apply(f, args) { } } -},{"../plot_api/plot_config":198}],170:[function(_dereq_,module,exports){ +},{"../plot_api/plot_config":196}],168:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38291,7 +38651,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{}],171:[function(_dereq_,module,exports){ +},{}],169:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38401,7 +38761,7 @@ exports.apply2DTransform2 = function(transform) { }; }; -},{}],172:[function(_dereq_,module,exports){ +},{}],170:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38436,7 +38796,7 @@ module.exports = { modHalf: modHalf }; -},{}],173:[function(_dereq_,module,exports){ +},{}],171:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38683,7 +39043,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":150,"fast-isnumeric":11}],174:[function(_dereq_,module,exports){ +},{"./array":148,"fast-isnumeric":11}],172:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38699,7 +39059,7 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],175:[function(_dereq_,module,exports){ +},{}],173:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38781,7 +39141,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":9,"fast-isnumeric":11}],176:[function(_dereq_,module,exports){ +},{"d3":9,"fast-isnumeric":11}],174:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38830,7 +39190,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":184}],177:[function(_dereq_,module,exports){ +},{"./setcursor":182}],175:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39083,7 +39443,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":145,"./matrix":171}],178:[function(_dereq_,module,exports){ +},{"../constants/numerical":142,"./matrix":169}],176:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39123,7 +39483,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],179:[function(_dereq_,module,exports){ +},{}],177:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39334,7 +39694,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":165,"../plot_api/plot_config":198}],180:[function(_dereq_,module,exports){ +},{"../lib":163,"../plot_api/plot_config":196}],178:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39353,16 +39713,18 @@ module.exports = queue; * @param {Optional(string)} tail: a fixed piece after the id * eg counterRegex('scene', '.annotations') for scene2.annotations etc. * @param {boolean} openEnded: if true, the string may continue past the match. + * @param {boolean} matchBeginning: if false, the string may start before the match. */ -exports.counter = function(head, tail, openEnded) { +exports.counter = function(head, tail, openEnded, matchBeginning) { var fullTail = (tail || '') + (openEnded ? '' : '$'); + var startWithPrefix = matchBeginning === false ? '' : '^'; if(head === 'xy') { - return new RegExp('^x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + 'x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); } - return new RegExp('^' + head + '([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],181:[function(_dereq_,module,exports){ +},{}],179:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39415,7 +39777,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],182:[function(_dereq_,module,exports){ +},{}],180:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39478,7 +39840,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":150,"./is_plain_object":166}],183:[function(_dereq_,module,exports){ +},{"./array":148,"./is_plain_object":164}],181:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39666,7 +40028,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"./identity":164,"./loggers":169,"fast-isnumeric":11}],184:[function(_dereq_,module,exports){ +},{"./identity":162,"./loggers":167,"fast-isnumeric":11}],182:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39689,7 +40051,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],185:[function(_dereq_,module,exports){ +},{}],183:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39790,7 +40152,7 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":150,"fast-isnumeric":11}],186:[function(_dereq_,module,exports){ +},{"./array":148,"fast-isnumeric":11}],184:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40565,7 +40927,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":143,"../constants/xmlns_namespaces":146,"../lib":165,"d3":9}],187:[function(_dereq_,module,exports){ +},{"../constants/alignment":140,"../constants/xmlns_namespaces":143,"../lib":163,"d3":9}],185:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40669,7 +41031,7 @@ function _clearTimeout(cache) { } } -},{}],188:[function(_dereq_,module,exports){ +},{}],186:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40697,7 +41059,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":11}],189:[function(_dereq_,module,exports){ +},{"fast-isnumeric":11}],187:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40733,7 +41095,7 @@ topojsonUtils.getTopojsonFeatures = function(trace, topojson) { return topojsonFeature(topojson, obj).features; }; -},{"../plots/geo/constants":239,"topojson-client":28}],190:[function(_dereq_,module,exports){ +},{"../plots/geo/constants":237,"topojson-client":28}],188:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40755,7 +41117,7 @@ module.exports = { } }; -},{}],191:[function(_dereq_,module,exports){ +},{}],189:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40798,7 +41160,7 @@ module.exports = { } }; -},{}],192:[function(_dereq_,module,exports){ +},{}],190:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40856,7 +41218,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":259}],193:[function(_dereq_,module,exports){ +},{"../registry":257}],191:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40982,7 +41344,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":165}],194:[function(_dereq_,module,exports){ +},{"../lib":163}],192:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -41038,6 +41400,8 @@ exports.cleanLayout = function(layout) { } var axisAttrRegex = (Plots.subplotsRegistry.cartesian || {}).attrRegex; + var polarAttrRegex = (Plots.subplotsRegistry.polar || {}).attrRegex; + var ternaryAttrRegex = (Plots.subplotsRegistry.ternary || {}).attrRegex; var sceneAttrRegex = (Plots.subplotsRegistry.gl3d || {}).attrRegex; var keys = Object.keys(layout); @@ -41076,6 +41440,24 @@ exports.cleanLayout = function(layout) { } delete ax.autotick; } + + cleanTitle(ax); + } + + // modifications for polar + else if(polarAttrRegex && polarAttrRegex.test(key)) { + var polar = layout[key]; + + cleanTitle(polar.radialaxis); + } + + // modifications for ternary + else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + var ternary = layout[key]; + + cleanTitle(ternary.aaxis); + cleanTitle(ternary.baxis); + cleanTitle(ternary.caxis); } // modifications for 3D scenes @@ -41099,11 +41481,16 @@ exports.cleanLayout = function(layout) { scene.camera = { eye: {x: eye[0], y: eye[1], z: eye[2]}, center: {x: center[0], y: center[1], z: center[2]}, - up: {x: mat[1], y: mat[5], z: mat[9]} + up: {x: 0, y: 0, z: 1} // we just ignore calculating camera z up in this case }; delete scene.cameraposition; } + + // clean axis titles + cleanTitle(scene.xaxis); + cleanTitle(scene.yaxis); + cleanTitle(scene.zaxis); } } @@ -41161,6 +41548,9 @@ exports.cleanLayout = function(layout) { } } + // clean plot title + cleanTitle(layout); + /* * Moved from rotate -> orbit for dragmode */ @@ -41170,6 +41560,11 @@ exports.cleanLayout = function(layout) { // supported, but new tinycolor does not because they're not valid css Color.clean(layout); + // clean the layout container in layout.template + if(layout.template && layout.template.layout) { + exports.cleanLayout(layout.template.layout); + } + return layout; }; @@ -41181,6 +41576,46 @@ function cleanAxRef(container, attr) { } } +/** + * Cleans up old title attribute structure (flat) in favor of the new one (nested). + * + * @param {Object} titleContainer - an object potentially including deprecated title attributes + */ +function cleanTitle(titleContainer) { + if(titleContainer) { + + // title -> title.text + // (although title used to be a string attribute, + // numbers are accepted as well) + if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') { + titleContainer.title = { + text: titleContainer.title + }; + } + + rewireAttr('titlefont', 'font'); + rewireAttr('titleposition', 'position'); + rewireAttr('titleside', 'side'); + rewireAttr('titleoffset', 'offset'); + } + + function rewireAttr(oldAttrName, newAttrName) { + var oldAttrSet = titleContainer[oldAttrName]; + var newAttrSet = titleContainer.title && titleContainer.title[newAttrName]; + + if(oldAttrSet && !newAttrSet) { + + // Ensure title object exists + if(!titleContainer.title) { + titleContainer.title = {}; + } + + titleContainer.title[newAttrName] = titleContainer[oldAttrName]; + delete titleContainer[oldAttrName]; + } + } +} + /* * cleanData: Make a few changes to the data for backward compatibility * before it gets used for anything. Modifies the data traces users provide. @@ -41384,6 +41819,13 @@ exports.cleanData = function(data) { delete trace.autobiny; delete trace.ybins; } + + cleanTitle(trace); + if(trace.colorbar) cleanTitle(trace.colorbar); + if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar); + if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar); + if(trace.aaxis) cleanTitle(trace.aaxis); + if(trace.baxis) cleanTitle(trace.baxis); } }; @@ -41424,11 +41866,14 @@ function commonPrefix(name1, name2, show1, show2) { function cleanTextPosition(textposition) { var posY = 'middle', posX = 'center'; - if(textposition.indexOf('top') !== -1) posY = 'top'; - else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; - if(textposition.indexOf('left') !== -1) posX = 'left'; - else if(textposition.indexOf('right') !== -1) posX = 'right'; + if(typeof textposition === 'string') { + if(textposition.indexOf('top') !== -1) posY = 'top'; + else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; + + if(textposition.indexOf('left') !== -1) posX = 'left'; + else if(textposition.indexOf('right') !== -1) posX = 'right'; + } return posY + ' ' + posX; } @@ -41604,7 +42049,7 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":45,"../lib":165,"../plots/cartesian/axis_ids":213,"../plots/plots":251,"../registry":259,"fast-isnumeric":11,"gl-mat4/fromQuat":12}],195:[function(_dereq_,module,exports){ +},{"../components/color":45,"../lib":163,"../plots/cartesian/axis_ids":211,"../plots/plots":249,"../registry":257,"fast-isnumeric":11,"gl-mat4/fromQuat":12}],193:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -41623,6 +42068,10 @@ exports.restyle = main.restyle; exports.relayout = main.relayout; exports.redraw = main.redraw; exports.update = main.update; +exports._guiRestyle = main._guiRestyle; +exports._guiRelayout = main._guiRelayout; +exports._guiUpdate = main._guiUpdate; +exports._storeDirectGUIEdit = main._storeDirectGUIEdit; exports.react = main.react; exports.extendTraces = main.extendTraces; exports.prependTraces = main.prependTraces; @@ -41643,7 +42092,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":261,"./plot_api":197,"./template_api":202,"./to_image":203,"./validate":204}],196:[function(_dereq_,module,exports){ +},{"../snapshot/download":259,"./plot_api":195,"./template_api":200,"./to_image":201,"./validate":202}],194:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -41655,7 +42104,6 @@ exports.validateTemplate = templateApi.validateTemplate; 'use strict'; -var nestedProperty = _dereq_('../lib/nested_property'); var isPlainObject = _dereq_('../lib/is_plain_object'); var noop = _dereq_('../lib/noop'); var Loggers = _dereq_('../lib/loggers'); @@ -41712,11 +42160,15 @@ var isRemoveVal = exports.isRemoveVal = function isRemoveVal(val) { * the flags for which actions we're going to perform to display these (and * any other) changes. If we're already `recalc`ing, we don't need to redraw * individual items + * @param {function} _nestedProperty + * a (possibly modified for gui edits) nestedProperty constructor + * The modified version takes a 3rd argument, for a prefix to the attribute + * string necessary for storing GUI edits * * @returns {bool} `true` if it managed to complete drawing of the changes * `false` would mean the parent should replot. */ -exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags) { +exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags, _nestedProperty) { var componentType = np.astr, supplyComponentDefaults = Registry.getComponentMethod(componentType, 'supplyLayoutDefaults'), draw = Registry.getComponentMethod(componentType, 'draw'), @@ -41756,7 +42208,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, // redoing supplyDefaults // TODO: this assumes componentArray is in gd.layout - which will not be // true after we extend this to restyle - componentArrayFull = nestedProperty(fullLayout, componentType).get(); + componentArrayFull = _nestedProperty(fullLayout, componentType).get(); var deletes = [], firstIndexChange = -1, @@ -41767,7 +42219,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, objEdits, objKeys, objVal, - adding; + adding, prefix; // first make the add and edit changes for(i = 0; i < componentNums.length; i++) { @@ -41806,7 +42258,9 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, } else { for(j = 0; j < objKeys.length; j++) { - nestedProperty(componentArray[componentNum], objKeys[j]).set(objEdits[objKeys[j]]); + prefix = componentType + '[' + componentNum + '].'; + _nestedProperty(componentArray[componentNum], objKeys[j], prefix) + .set(objEdits[objKeys[j]]); } } } @@ -41857,7 +42311,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":166,"../lib/loggers":169,"../lib/nested_property":173,"../lib/noop":174,"../lib/search":183,"../registry":259,"./container_array_match":192}],197:[function(_dereq_,module,exports){ +},{"../lib/is_plain_object":164,"../lib/loggers":167,"../lib/noop":172,"../lib/search":181,"../registry":257,"./container_array_match":190}],195:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -41875,6 +42329,8 @@ var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); var Lib = _dereq_('../lib'); +var nestedProperty = Lib.nestedProperty; + var Events = _dereq_('../lib/events'); var Queue = _dereq_('../lib/queue'); @@ -41970,9 +42426,6 @@ exports.plot = function(gd, data, layout, config) { // so we can share cached text across tabs Drawing.makeTester(); - // clear stashed base url - delete Drawing.baseUrl; - // collect promises for any async actions during plotting // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all @@ -42017,7 +42470,7 @@ exports.plot = function(gd, data, layout, config) { // Legacy polar plots if(!fullLayout._has('polar') && data && data[0] && data[0].r) { Lib.log('Legacy polar charts are deprecated!'); - return plotPolar(gd, data, layout); + return plotLegacyPolar(gd, data, layout); } // so we don't try to re-call Plotly.plot from inside @@ -42193,8 +42646,7 @@ exports.plot = function(gd, data, layout, config) { return Lib.syncOrAsync([ Registry.getComponentMethod('shapes', 'calcAutorange'), Registry.getComponentMethod('annotations', 'calcAutorange'), - doAutoRangeAndConstraints, - Registry.getComponentMethod('rangeslider', 'calcAutorange') + doAutoRangeAndConstraints ], gd); } @@ -42206,11 +42658,16 @@ exports.plot = function(gd, data, layout, config) { // store initial ranges *after* enforcing constraints, otherwise // we will never look like we're at the initial ranges if(graphWasEmpty) Axes.saveRangeInitial(gd); + + // this one is different from shapes/annotations calcAutorange + // the others incorporate those components into ax._extremes, + // this one actually sets the ranges in rangesliders. + Registry.getComponentMethod('rangeslider', 'calcAutorange')(gd); } // draw ticks, titles, and calculate axis scaling (._b, ._m) function drawAxes() { - return Axes.doTicks(gd, graphWasEmpty ? '' : 'redraw'); + return Axes.draw(gd, graphWasEmpty ? '' : 'redraw'); } var seq = [ @@ -42279,7 +42736,16 @@ function opaqueSetBackground(gd, bgColor) { } function setPlotContext(gd, config) { - if(!gd._context) gd._context = Lib.extendDeep({}, defaultConfig); + if(!gd._context) { + gd._context = Lib.extendDeep({}, defaultConfig); + + // stash href, used to make robust clipPath URLs + var base = d3.select('base'); + gd._context._baseUrl = base.size() && base.attr('href') ? + window.location.href.split('#')[0] : + ''; + } + var context = gd._context; var i, keys, key; @@ -42325,6 +42791,9 @@ function setPlotContext(gd, config) { } } } + + // not part of the user-facing config options + context._exportedPlot = config._exportedPlot; } // staticPlot forces a bunch of others: @@ -42354,7 +42823,7 @@ function setPlotContext(gd, config) { context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0; } -function plotPolar(gd, data, layout) { +function plotLegacyPolar(gd, data, layout) { // build or reuse the container skeleton var plotContainer = d3.select(gd).selectAll('.plot-container') .data([0]); @@ -42395,7 +42864,7 @@ function plotPolar(gd, data, layout) { // editable title var opacity = 1; - var txt = gd._fullLayout.title; + var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; if(txt === '' || !txt) opacity = 0; var titleLayout = function() { @@ -42429,7 +42898,7 @@ function plotPolar(gd, data, layout) { var setContenteditable = function() { this.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { - gd.framework({layout: {title: text}}); + gd.framework({layout: {title: {text: text}}}); this.text(text) .call(titleLayout); this.call(setContenteditable); @@ -42702,7 +43171,7 @@ function getExtendProperties(gd, update, indices, maxPoints) { * instance that references the key and value for this particular trace. */ trace = gd.data[indices[j]]; - prop = Lib.nestedProperty(trace, key); + prop = nestedProperty(trace, key); /* * Target is the existing gd.data.trace.dataArray value like "x" or "marker.size" @@ -43173,7 +43642,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) { * If the array is too short, it will wrap around (useful for * style files that want to specify cyclical default values). */ -exports.restyle = function restyle(gd, astr, val, _traces) { +function restyle(gd, astr, val, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -43243,7 +43712,8 @@ exports.restyle = function restyle(gd, astr, val, _traces) { gd.emit('plotly_restyle', specs.eventData); return gd; }); -}; +} +exports.restyle = restyle; // for undo: undefined initial vals must be turned into nulls // so that we unset rather than ignore them @@ -43252,11 +43722,77 @@ function undefinedToNull(val) { return val; } +/** + * Factory function to wrap nestedProperty with GUI edits if necessary + * with GUI edits we add an optional prefix to the nestedProperty constructor + * to prepend to the attribute string in the preGUI store. + */ +function makeNP(preGUI, guiEditFlag) { + if(!guiEditFlag) return nestedProperty; + + return function(container, attr, prefix) { + var np = nestedProperty(container, attr); + var npSet = np.set; + np.set = function(val) { + var fullAttr = (prefix || '') + attr; + storeCurrent(fullAttr, np.get(), val, preGUI); + npSet(val); + }; + return np; + }; +} + +function storeCurrent(attr, val, newVal, preGUI) { + if(Array.isArray(val) || Array.isArray(newVal)) { + var arrayVal = Array.isArray(val) ? val : []; + var arrayNew = Array.isArray(newVal) ? newVal : []; + var maxLen = Math.max(arrayVal.length, arrayNew.length); + for(var i = 0; i < maxLen; i++) { + storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); + } + } + else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + var objVal = Lib.isPlainObject(val) ? val : {}; + var objNew = Lib.isPlainObject(newVal) ? newVal : {}; + var objBoth = Lib.extendFlat({}, objVal, objNew); + for(var key in objBoth) { + storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); + } + } + else if(preGUI[attr] === undefined) { + preGUI[attr] = undefinedToNull(val); + } +} + +/** + * storeDirectGUIEdit: for routines that skip restyle/relayout and mock it + * by emitting a plotly_restyle or plotly_relayout event, this routine + * keeps track of the initial state in _preGUI for use by uirevision + * Does *not* apply these changes to data/layout - that's the responsibility + * of the calling routine. + * + * @param {object} container: the input attributes container (eg `layout` or a `trace`) + * @param {object} preGUI: where original values should be stored, either + * `layout._preGUI` or `layout._tracePreGUI[uid]` + * @param {object} edits: the {attr: val} object as normally passed to `relayout` etc + */ +exports._storeDirectGUIEdit = function(container, preGUI, edits) { + for(var attr in edits) { + var np = nestedProperty(container, attr); + storeCurrent(attr, np.get(), edits[attr], preGUI); + } +}; + function _restyle(gd, aobj, traces) { - var fullLayout = gd._fullLayout, - fullData = gd._fullData, - data = gd.data, - i; + var fullLayout = gd._fullLayout; + var fullData = gd._fullData; + var data = gd.data; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var eventData = Lib.extendDeepAll({}, aobj); + var i; + + cleanDeprecatedAttributeKeys(aobj); // initialize flags var flags = editTypes.traceFlags(); @@ -43280,6 +43816,16 @@ function _restyle(gd, aobj, traces) { function rangeAttr(axName) { return 'LAYOUT' + axName + '.range'; } + function getFullTrace(traceIndex) { + // usually fullData maps 1:1 onto data, but with groupby transforms + // the fullData index can be greater. Take the *first* matching trace. + for(var j = traceIndex; j < fullData.length; j++) { + if(fullData[j]._input === data[traceIndex]) return fullData[j]; + } + // should never get here - and if we *do* it should cause an error + // later on undefined fullTrace is passed to nestedProperty. + } + // for attrs that interact (like scales & autoscales), save the // old vals before making the change // val=undefined will not set a value, just record what the value was. @@ -43295,9 +43841,11 @@ function _restyle(gd, aobj, traces) { var extraparam; if(attr.substr(0, 6) === 'LAYOUT') { - extraparam = Lib.nestedProperty(gd.layout, attr.replace('LAYOUT', '')); + extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', '')); } else { - extraparam = Lib.nestedProperty(data[traces[i]], attr); + var tracei = traces[i]; + var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid]; + extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr); } if(!(attr in undoit)) { @@ -43352,7 +43900,7 @@ function _restyle(gd, aobj, traces) { redoit[ai] = vi; if(ai.substr(0, 6) === 'LAYOUT') { - param = Lib.nestedProperty(gd.layout, ai.replace('LAYOUT', '')); + param = layoutNP(gd.layout, ai.replace('LAYOUT', '')); undoit[ai] = [undefinedToNull(param.get())]; // since we're allowing val to be an array, allow it here too, // even though that's meaningless @@ -43367,8 +43915,9 @@ function _restyle(gd, aobj, traces) { undoit[ai] = a0(); for(i = 0; i < traces.length; i++) { cont = data[traces[i]]; - contFull = fullData[traces[i]]; - param = Lib.nestedProperty(cont, ai); + contFull = getFullTrace(traces[i]); + var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid]; + param = makeNP(preGUI, guiEditFlag)(cont, ai); oldVal = param.get(); newVal = Array.isArray(vi) ? vi[i % vi.length] : vi; @@ -43378,7 +43927,7 @@ function _restyle(gd, aobj, traces) { var prefix = ai.substr(0, ai.length - finalPart.length - 1); var prefixDot = prefix ? prefix + '.' : ''; var innerContFull = prefix ? - Lib.nestedProperty(contFull, prefix).get() : contFull; + nestedProperty(contFull, prefix).get() : contFull; valObject = PlotSchema.getTraceValObject(contFull, param.parts); @@ -43425,14 +43974,14 @@ function _restyle(gd, aobj, traces) { Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo); if(oldVal === 'pie') { - Lib.nestedProperty(cont, 'marker.color') - .set(Lib.nestedProperty(cont, 'marker.colors').get()); + nestedProperty(cont, 'marker.color') + .set(nestedProperty(cont, 'marker.colors').get()); // super kludgy - but if all pies are gone we won't remove them otherwise fullLayout._pielayer.selectAll('g.trace').remove(); } else if(Registry.traceIs(cont, 'cartesian')) { - Lib.nestedProperty(cont, 'marker.colors') - .set(Lib.nestedProperty(cont, 'marker.color').get()); + nestedProperty(cont, 'marker.colors') + .set(nestedProperty(cont, 'marker.color').get()); } } @@ -43503,7 +44052,7 @@ function _restyle(gd, aobj, traces) { // swap hovermode if set to "compare x/y data" if(ai === 'orientationaxes') { - var hovermode = Lib.nestedProperty(gd.layout, 'hovermode'); + var hovermode = nestedProperty(gd.layout, 'hovermode'); if(hovermode.get() === 'x') { hovermode.set('y'); } else if(hovermode.get() === 'y') { @@ -43542,10 +44091,53 @@ function _restyle(gd, aobj, traces) { undoit: undoit, redoit: redoit, traces: traces, - eventData: Lib.extendDeepNoArrays([], [redoit, traces]) + eventData: Lib.extendDeepNoArrays([], [eventData, traces]) }; } +/** + * Converts deprecated attribute keys to + * the current API to ensure backwards compatibility. + * + * This is needed for the update mechanism to determine which + * subroutines to run based on the actual attribute + * definitions (that don't include the deprecated ones). + * + * E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'} + * and {titlefont: {...}} to {'title.font': {...}}. + * + * @param aobj + */ +function cleanDeprecatedAttributeKeys(aobj) { + var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false); + var colorbarRegex = /colorbar\.title$/; + var keys = Object.keys(aobj); + var i, key, value; + + for(i = 0; i < keys.length; i++) { + key = keys[i]; + value = aobj[key]; + + if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) && + (typeof value === 'string' || typeof value === 'number')) { + replace(key, key.replace('title', 'title.text')); + } else if(key.indexOf('titlefont') > -1) { + replace(key, key.replace('titlefont', 'title.font')); + } else if(key.indexOf('titleposition') > -1) { + replace(key, key.replace('titleposition', 'title.position')); + } else if(key.indexOf('titleside') > -1) { + replace(key, key.replace('titleside', 'title.side')); + } else if(key.indexOf('titleoffset') > -1) { + replace(key, key.replace('titleoffset', 'title.offset')); + } + } + + function replace(oldAttrStr, newAttrStr) { + aobj[newAttrStr] = aobj[oldAttrStr]; + delete aobj[oldAttrStr]; + } +} + /** * relayout: update layout attributes of an existing plot * @@ -43566,7 +44158,7 @@ function _restyle(gd, aobj, traces) { * attribute object `{astr1: val1, astr2: val2 ...}` * allows setting multiple attributes simultaneously */ -exports.relayout = function relayout(gd, astr, val) { +function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -43629,7 +44221,8 @@ exports.relayout = function relayout(gd, astr, val) { gd.emit('plotly_relayout', specs.eventData); return gd; }); -}; +} +exports.relayout = relayout; // Optimization mostly for large splom traces where // Plots.supplyDefaults can take > 100ms @@ -43657,13 +44250,24 @@ function addAxRangeSequence(seq, rangesAltered) { // N.B. leave as sequence of subroutines (for now) instead of // subroutine of its own so that finalDraw always gets // executed after drawData - var doTicks = rangesAltered ? - function(gd) { return Axes.doTicks(gd, Object.keys(rangesAltered), true); } : - function(gd) { return Axes.doTicks(gd, 'redraw'); }; + var drawAxes = rangesAltered ? + function(gd) { + var opts = {skipTitle: true}; + for(var id in rangesAltered) { + if(Axes.getFromId(gd, id).automargin) { + opts = {}; + break; + } + } + return Axes.draw(gd, Object.keys(rangesAltered), opts); + } : + function(gd) { + return Axes.draw(gd, 'redraw'); + }; seq.push( subroutines.doAutoRangeAndConstraints, - doTicks, + drawAxes, subroutines.drawData, subroutines.finalDraw ); @@ -43674,14 +44278,19 @@ var AX_AUTORANGE_RE = /^[xyz]axis[0-9]*\.autorange$/; var AX_DOMAIN_RE = /^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/; function _relayout(gd, aobj) { - var layout = gd.layout, - fullLayout = gd._fullLayout, - keys = Object.keys(aobj), - axes = Axes.list(gd), - arrayEdits = {}, - arrayStr, - i, - j; + var layout = gd.layout; + var fullLayout = gd._fullLayout; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var keys = Object.keys(aobj); + var axes = Axes.list(gd); + var eventData = Lib.extendDeepAll({}, aobj); + var arrayEdits = {}; + + var arrayStr, i, j; + + cleanDeprecatedAttributeKeys(aobj); + keys = Object.keys(aobj); // look for 'allaxes', split out into all axes // in case of 3D the axis are nested within a scene which is held in _id @@ -43721,7 +44330,7 @@ function _relayout(gd, aobj) { // via a parent) do not override with this auto-generated extra if(attr in aobj || helpers.hasParent(aobj, attr)) return; - var p = Lib.nestedProperty(layout, attr); + var p = layoutNP(layout, attr); if(!(attr in undoit)) { undoit[attr] = undefinedToNull(p.get()); } @@ -43746,7 +44355,7 @@ function _relayout(gd, aobj) { throw new Error('cannot set ' + ai + 'and a parent attribute simultaneously'); } - var p = Lib.nestedProperty(layout, ai); + var p = layoutNP(layout, ai); var vi = aobj[ai]; var plen = p.parts.length; // p.parts may end with an index integer if the property is an array @@ -43758,8 +44367,8 @@ function _relayout(gd, aobj) { var pleafPlus = p.parts[pend - 1] + '.' + pleaf; // trunk nodes (everything except the leaf) var ptrunk = p.parts.slice(0, pend).join('.'); - var parentIn = Lib.nestedProperty(gd.layout, ptrunk).get(); - var parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + var parentIn = nestedProperty(gd.layout, ptrunk).get(); + var parentFull = nestedProperty(fullLayout, ptrunk).get(); var vOld = p.get(); if(vi === undefined) continue; @@ -43804,12 +44413,12 @@ function _relayout(gd, aobj) { // check autorange vs range else if(pleafPlus.match(AX_RANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - var axFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + var axFull = nestedProperty(fullLayout, ptrunk).get(); if(axFull._inputDomain) { // if we're autoranging and this axis has a constrained domain, // reset it so we don't get locked into a shrunken size @@ -43817,7 +44426,7 @@ function _relayout(gd, aobj) { } } else if(pleafPlus.match(AX_DOMAIN_RE)) { - Lib.nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); + nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } // toggling axis type between log and linear: we need to convert @@ -43886,10 +44495,10 @@ function _relayout(gd, aobj) { doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleaf.match(AX_NAME_PATTERN)) { - var fullProp = Lib.nestedProperty(fullLayout, ai).get(), + var fullProp = nestedProperty(fullLayout, ai).get(), newType = (vi || {}).type; // This can potentially cause strange behavior if the autotype is not @@ -43911,8 +44520,6 @@ function _relayout(gd, aobj) { arrayStr = containerArrayMatch.array; i = containerArrayMatch.index; var propStr = containerArrayMatch.property; - var componentArray = Lib.nestedProperty(layout, arrayStr); - var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; if(i !== '' && propStr === '') { @@ -43922,7 +44529,7 @@ function _relayout(gd, aobj) { if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { - undoit[ai] = obji; + undoit[ai] = (nestedProperty(layout, arrayStr).get() || [])[i]; } else { Lib.warn('unrecognized full object value', aobj); } @@ -43966,7 +44573,7 @@ function _relayout(gd, aobj) { // now we've collected component edits - execute them all together for(arrayStr in arrayEdits) { var finished = manageArrays.applyContainerArrayChanges(gd, - Lib.nestedProperty(layout, arrayStr), arrayEdits[arrayStr], flags); + layoutNP(layout, arrayStr), arrayEdits[arrayStr], flags, layoutNP); if(!finished) flags.plot = true; } @@ -44009,7 +44616,7 @@ function _relayout(gd, aobj) { rangesAltered: rangesAltered, undoit: undoit, redoit: redoit, - eventData: Lib.extendDeep({}, redoit) + eventData: eventData }; } @@ -44044,7 +44651,7 @@ function updateAutosize(gd) { * integer or array of integers for the traces to alter (all if omitted) * */ -exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { +function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -44124,7 +44731,235 @@ exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { return gd; }); -}; +} +exports.update = update; + +/* + * internal-use-only restyle/relayout/update variants that record the initial + * values in (fullLayout|fullTrace)._preGUI so changes can be persisted across + * Plotly.react data updates, dependent on uirevision attributes + */ +function guiEdit(func) { + return function wrappedEdit(gd) { + gd._fullLayout._guiEditing = true; + var p = func.apply(null, arguments); + gd._fullLayout._guiEditing = false; + return p; + }; +} +exports._guiRestyle = guiEdit(restyle); +exports._guiRelayout = guiEdit(relayout); +exports._guiUpdate = guiEdit(update); + +// For connecting edited layout attributes to uirevision attrs +// If no `attr` we use `match[1] + '.uirevision'` +// Ordered by most common edits first, to minimize our search time +var layoutUIControlPatterns = [ + {pattern: /^hiddenlabels/, attr: 'legend.uirevision'}, + {pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/}, + + // showspikes and modes include those nested inside scenes + {pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'}, + {pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'}, + + {pattern: /^(scene\d*)\.camera/}, + {pattern: /^(geo\d*)\.(projection|center)/}, + {pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/}, + {pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/}, + {pattern: /^(polar\d*\.angularaxis)\.rotation/}, + {pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/}, + + {pattern: /^legend\.(x|y)$/, attr: 'editrevision'}, + {pattern: /^(shapes|annotations)/, attr: 'editrevision'}, + {pattern: /^title\.text$/, attr: 'editrevision'} +]; + +// same for trace attributes: if `attr` is given it's in layout, +// or with no `attr` we use `trace.uirevision` +var traceUIControlPatterns = [ + {pattern: /^selectedpoints$/, attr: 'selectionrevision'}, + // "visible" includes trace.transforms[i].styles[j].value.visible + {pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'}, + {pattern: /^dimensions\[\d+\]\.constraintrange/}, + + // below this you must be in editable: true mode + // TODO: I still put name and title with `trace.uirevision` + // reasonable or should these be `editrevision`? + // Also applies to axis titles up in the layout section + + // "name" also includes transform.styles + {pattern: /(^|value\.)name$/}, + // including nested colorbar attributes (ie marker.colorbar) + {pattern: /colorbar\.title\.text$/}, + {pattern: /colorbar\.(x|y)$/, attr: 'editrevision'} +]; + +function findUIPattern(key, patternSpecs) { + for(var i = 0; i < patternSpecs.length; i++) { + var spec = patternSpecs[i]; + var match = key.match(spec.pattern); + if(match) { + return {head: match[1], attr: spec.attr}; + } + } +} + +// We're finding the new uirevision before supplyDefaults, so do the +// inheritance manually. Note that only `undefined` inherits - other +// falsy values are returned. +function getNewRev(revAttr, container) { + var newRev = nestedProperty(container, revAttr).get(); + if(newRev !== undefined) return newRev; + + var parts = revAttr.split('.'); + parts.pop(); + while(parts.length > 1) { + parts.pop(); + newRev = nestedProperty(container, parts.join('.') + '.uirevision').get(); + if(newRev !== undefined) return newRev; + } + + return container.uirevision; +} + +function getFullTraceIndexFromUid(uid, fullData) { + for(var i = 0; i < fullData.length; i++) { + if(fullData[i]._fullInput.uid === uid) return i; + } + return -1; +} + +function getTraceIndexFromUid(uid, data, tracei) { + for(var i = 0; i < data.length; i++) { + if(data[i].uid === uid) return i; + } + // fall back on trace order, but only if user didn't provide a uid for that trace + return data[tracei].uid ? -1 : tracei; +} + +function valsMatch(v1, v2) { + var v1IsObj = Lib.isPlainObject(v1); + var v1IsArray = Array.isArray(v1); + if(v1IsObj || v1IsArray) { + return ( + (v1IsObj && Lib.isPlainObject(v2)) || + (v1IsArray && Array.isArray(v2)) + ) && JSON.stringify(v1) === JSON.stringify(v2); + } + return v1 === v2; +} + +function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { + var layoutPreGUI = oldFullLayout._preGUI; + var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal; + var bothInheritAutorange = []; + var newRangeAccepted = {}; + for(key in layoutPreGUI) { + match = findUIPattern(key, layoutUIControlPatterns); + if(match) { + revAttr = match.attr || (match.head + '.uirevision'); + oldRev = nestedProperty(oldFullLayout, revAttr).get(); + newRev = oldRev && getNewRev(revAttr, layout); + if(newRev && (newRev === oldRev)) { + preGUIVal = layoutPreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(layout, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + if(newVal === undefined && key.substr(key.length - 9) === 'autorange') { + bothInheritAutorange.push(key.substr(0, key.length - 10)); + } + newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key); + } + // if we got this far, the new value was accepted as the new starting + // point (either because it changed or revision changed) + // so remove it from _preGUI for next time. + delete layoutPreGUI[key]; + + if(key.substr(key.length - 8, 6) === 'range[') { + newRangeAccepted[key.substr(0, key.length - 9)] = 1; + } + } + + // Special logic for `autorange`, since it interacts with `range`: + // If the new figure's matching `range` was kept, and `autorange` + // wasn't supplied explicitly in either the original or the new figure, + // we shouldn't alter that - but we may just have done that, so fix it. + for(var i = 0; i < bothInheritAutorange.length; i++) { + var axAttr = bothInheritAutorange[i]; + if(newRangeAccepted[axAttr]) { + var newAx = nestedProperty(layout, axAttr).get(); + if(newAx) delete newAx.autorange; + } + } + + // Now traces - try to match them up by uid (in case we added/deleted in + // the middle), then fall back on index. + var allTracePreGUI = oldFullLayout._tracePreGUI; + for(var uid in allTracePreGUI) { + var tracePreGUI = allTracePreGUI[uid]; + var newTrace = null; + var fullInput; + for(key in tracePreGUI) { + // wait until we know we have preGUI values to look for traces + // but if we don't find both, stop looking at this uid + if(!newTrace) { + var fulli = getFullTraceIndexFromUid(uid, oldFullData); + if(fulli < 0) { + // Somehow we didn't even have this trace in oldFullData... + // I guess this could happen with `deleteTraces` or something + delete allTracePreGUI[uid]; + break; + } + var fullTrace = oldFullData[fulli]; + fullInput = fullTrace._fullInput; + + var newTracei = getTraceIndexFromUid(uid, data, fullInput.index); + if(newTracei < 0) { + // No match in new data + delete allTracePreGUI[uid]; + break; + } + newTrace = data[newTracei]; + } + + match = findUIPattern(key, traceUIControlPatterns); + if(match) { + if(match.attr) { + oldRev = nestedProperty(oldFullLayout, match.attr).get(); + newRev = oldRev && getNewRev(match.attr, layout); + } + else { + oldRev = fullInput.uirevision; + // inheritance for trace.uirevision is simple, just layout.uirevision + newRev = newTrace.uirevision; + if(newRev === undefined) newRev = layout.uirevision; + } + + if(newRev && newRev === oldRev) { + preGUIVal = tracePreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(newTrace, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + newNP.set(undefinedToNull(nestedProperty(fullInput, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); + } + delete tracePreGUI[key]; + } + } +} /** * Plotly.react: @@ -44188,6 +45023,8 @@ exports.react = function(gd, data, layout, config) { gd.layout = layout || {}; helpers.cleanLayout(gd.layout); + applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout); + // "true" skips updating calcdata and remapping arrays from calcTransforms, // which supplyDefaults usually does at the end, but we may need to NOT do // if the diff (which we haven't determined yet) says we'll recalc @@ -45242,7 +46079,7 @@ function makePlotFramework(gd) { gd.emit('plotly_framework'); } -},{"../components/color":45,"../components/colorbar/connect":47,"../components/drawing":70,"../constants/xmlns_namespaces":146,"../lib":165,"../lib/events":156,"../lib/queue":179,"../lib/svg_text_utils":186,"../plots/cartesian/axes":210,"../plots/cartesian/constants":216,"../plots/cartesian/graph_interact":220,"../plots/plots":251,"../plots/polar/legacy":254,"../registry":259,"./edit_types":193,"./helpers":194,"./manage_arrays":196,"./plot_config":198,"./plot_schema":199,"./subroutines":201,"d3":9,"fast-isnumeric":11,"has-hover":13}],198:[function(_dereq_,module,exports){ +},{"../components/color":45,"../components/colorbar/connect":47,"../components/drawing":66,"../constants/xmlns_namespaces":143,"../lib":163,"../lib/events":154,"../lib/queue":177,"../lib/svg_text_utils":184,"../plots/cartesian/axes":208,"../plots/cartesian/constants":214,"../plots/cartesian/graph_interact":218,"../plots/plots":249,"../plots/polar/legacy":252,"../registry":257,"./edit_types":191,"./helpers":192,"./manage_arrays":194,"./plot_config":196,"./plot_schema":197,"./subroutines":199,"d3":9,"fast-isnumeric":11,"has-hover":13}],196:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45335,12 +46172,34 @@ module.exports = { */ showAxisRangeEntryBoxes: true, - // link to open this plot in plotly + /* + * Add a text link to open this plot in plotly? + * This link shows up in the bottom right corner of the plot, and works + * identically to the newer ModeBar button controlled by `showSendToCloud` + * unless `sendData: false` is used. + */ showLink: false, - // if we show a link, does it contain data or just link to a plotly file? + /* + * If we show a text link (`showLink: true`), does it contain data or just + * a reference to a plotly cloud file? This option should only be used on + * plot.ly or another plotly server, and is not supported by the newer + * ModeBar button `showSendToCloud`. + */ sendData: true, + /* + * Should we include a ModeBar button, labeled "Edit in Chart Studio", + * that sends this chart to plot.ly or another plotly server as specified + * by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0 + * this button was included by default, now it is opt-in using this flag. + * + * Note that this button can (depending on `plotlyServerURL`) send your data + * to an external server. However that server doesn't persist your data + * until you arrive at the Chart Studio and explicitly click "Save". + */ + showSendToCloud: false, + // text appearing in the sendData link linkText: 'Edit chart', @@ -45378,6 +46237,9 @@ module.exports = { // add the plotly logo on the end of the mode bar displaylogo: true, + // watermark the images with the company's logo + watermark: false, + // increase the pixel ratio for Gl plot images plotGlPixelRatio: 2, @@ -45444,7 +46306,7 @@ module.exports = { locales: {} }; -},{}],199:[function(_dereq_,module,exports){ +},{}],197:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46130,7 +46992,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":165,"../plots/animation_attributes":205,"../plots/attributes":207,"../plots/frame_attributes":238,"../plots/layout_attributes":249,"../plots/polar/legacy/area_attributes":252,"../plots/polar/legacy/axis_attributes":253,"../registry":259,"./edit_types":193}],200:[function(_dereq_,module,exports){ +},{"../lib":163,"../plots/animation_attributes":203,"../plots/attributes":205,"../plots/frame_attributes":236,"../plots/layout_attributes":247,"../plots/polar/legacy/area_attributes":250,"../plots/polar/legacy/axis_attributes":251,"../registry":257,"./edit_types":191}],198:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46444,7 +47306,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":165,"../plots/attributes":207}],201:[function(_dereq_,module,exports){ +},{"../lib":163,"../plots/attributes":205}],199:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46474,6 +47336,10 @@ var enforceAxisConstraints = axisConstraints.enforce; var cleanAxisConstraints = axisConstraints.clean; var doAutoRange = _dereq_('../plots/cartesian/autorange').doAutoRange; +var SVG_TEXT_ANCHOR_START = 'start'; +var SVG_TEXT_ANCHOR_MIDDLE = 'middle'; +var SVG_TEXT_ANCHOR_END = 'end'; + exports.layoutStyles = function(gd) { return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd); }; @@ -46498,7 +47364,7 @@ function lsInner(gd) { var gs = fullLayout._size; var pad = gs.p; var axList = Axes.list(gd, '', true); - var i, subplot, plotinfo, xa, ya; + var i, subplot, plotinfo, ax, xa, ya; fullLayout._paperdiv.style({ width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px', @@ -46534,10 +47400,7 @@ function lsInner(gd) { // some preparation of axis position info for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - - // reset scale in case the margins have changed - ax.setScale(); + ax = axList[i]; var counterAx = ax._anchorAxis; @@ -46556,11 +47419,6 @@ function lsInner(gd) { ax._mainMirrorPosition = (ax.mirror && counterAx) ? getLinePosition(ax, counterAx, alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; - - // Figure out which subplot to draw ticks, labels, & axis lines on - // do this as a separate loop so we already have all the - // _mainAxis and _anchorAxis links set - ax._mainSubplot = findMainSubplot(ax, fullLayout); } // figure out which backgrounds we need to draw, @@ -46671,7 +47529,7 @@ function lsInner(gd) { layerClipId = null; } - Drawing.setClipUrl(plotinfo.plot, plotClipId); + Drawing.setClipUrl(plotinfo.plot, plotClipId, gd); // stash layer clipId value (null or same as clipId) // to DRY up Drawing.setClipUrl calls on trace-module and trace layers @@ -46801,48 +47659,6 @@ function lsInner(gd) { return gd._promises.length && Promise.all(gd._promises); } -function findMainSubplot(ax, fullLayout) { - var subplotList = fullLayout._subplots; - var ids = subplotList.cartesian.concat(subplotList.gl2d || []); - var mockGd = {_fullLayout: fullLayout}; - - var isX = ax._id.charAt(0) === 'x'; - var anchorAx = ax._mainAxis._anchorAxis; - var mainSubplotID = ''; - var nextBestMainSubplotID = ''; - var anchorID = ''; - - // First try the main ID with the anchor - if(anchorAx) { - anchorID = anchorAx._mainAxis._id; - mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); - } - - // Then look for a subplot with the counteraxis overlaying the anchor - // If that fails just use the first subplot including this axis - if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { - mainSubplotID = ''; - - for(var j = 0; j < ids.length; j++) { - var id = ids[j]; - var yIndex = id.indexOf('y'); - var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); - var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); - - if(idPart === ax._id) { - if(!nextBestMainSubplotID) nextBestMainSubplotID = id; - var counterAx = Axes.getFromId(mockGd, counterPart); - if(anchorID && counterAx.overlaying === anchorID) { - mainSubplotID = id; - break; - } - } - } - } - - return mainSubplotID || nextBestMainSubplotID; -} - function shouldShowLinesOrTicks(ax, subplot) { return (ax.ticks || ax.showline) && (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); @@ -46897,18 +47713,92 @@ function findCounterAxisLineWidth(ax, side, counterAx, axList) { exports.drawMainTitle = function(gd) { var fullLayout = gd._fullLayout; + var textAnchor = getMainTitleTextAnchor(fullLayout); + var dy = getMainTitleDy(fullLayout); + Titles.draw(gd, 'gtitle', { propContainer: fullLayout, - propName: 'title', + propName: 'title.text', placeholder: fullLayout._dfltTitle.plot, attributes: { - x: fullLayout.width / 2, - y: fullLayout._size.t / 2, - 'text-anchor': 'middle' + x: getMainTitleX(fullLayout, textAnchor), + y: getMainTitleY(fullLayout, dy), + 'text-anchor': textAnchor, + dy: dy } }); }; +function getMainTitleX(fullLayout, textAnchor) { + var title = fullLayout.title; + var gs = fullLayout._size; + var hPadShift = 0; + + if(textAnchor === SVG_TEXT_ANCHOR_START) { + hPadShift = title.pad.l; + } else if(textAnchor === SVG_TEXT_ANCHOR_END) { + hPadShift = -title.pad.r; + } + + switch(title.xref) { + case 'paper': + return gs.l + gs.w * title.x + hPadShift; + case 'container': + default: + return fullLayout.width * title.x + hPadShift; + } +} + +function getMainTitleY(fullLayout, dy) { + var title = fullLayout.title; + var gs = fullLayout._size; + var vPadShift = 0; + + if(dy === '0em' || !dy) { + vPadShift = -title.pad.b; + } else if(dy === alignmentConstants.CAP_SHIFT + 'em') { + vPadShift = title.pad.t; + } + + if(title.y === 'auto') { + return gs.t / 2; + } else { + switch(title.yref) { + case 'paper': + return gs.t + gs.h - gs.h * title.y + vPadShift; + case 'container': + default: + return fullLayout.height - fullLayout.height * title.y + vPadShift; + } + } +} + +function getMainTitleTextAnchor(fullLayout) { + var title = fullLayout.title; + + var textAnchor = SVG_TEXT_ANCHOR_MIDDLE; + if(Lib.isRightAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_END; + } else if(Lib.isLeftAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_START; + } + + return textAnchor; +} + +function getMainTitleDy(fullLayout) { + var title = fullLayout.title; + + var dy = '0em'; + if(Lib.isTopAnchor(title)) { + dy = alignmentConstants.CAP_SHIFT + 'em'; + } else if(Lib.isMiddleAnchor(title)) { + dy = alignmentConstants.MID_SHIFT + 'em'; + } + + return dy; +} + exports.doTraceStyle = function(gd) { var calcdata = gd.calcdata; var editStyleCalls = []; @@ -46986,7 +47876,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.doTicks(gd, 'redraw'); + Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -47121,6 +48011,8 @@ exports.doAutoRangeAndConstraints = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; cleanAxisConstraints(gd, ax); + // in case margins changed, update scale + ax.setScale(); doAutoRange(gd, ax); } @@ -47152,7 +48044,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('updatemenus', 'draw')(gd); }; -},{"../components/color":45,"../components/drawing":70,"../components/modebar":108,"../components/titles":136,"../constants/alignment":143,"../lib":165,"../lib/clear_gl_canvases":152,"../plots/cartesian/autorange":209,"../plots/cartesian/axes":210,"../plots/cartesian/constraints":218,"../plots/plots":251,"../registry":259,"d3":9}],202:[function(_dereq_,module,exports){ +},{"../components/color":45,"../components/drawing":66,"../components/modebar":104,"../components/titles":133,"../constants/alignment":140,"../lib":163,"../lib/clear_gl_canvases":150,"../plots/cartesian/autorange":207,"../plots/cartesian/axes":208,"../plots/cartesian/constraints":216,"../plots/plots":249,"../registry":257,"d3":9}],200:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47626,7 +48518,7 @@ function format(opts) { return opts; } -},{"../lib":165,"../plots/attributes":207,"../plots/plots":251,"./plot_config":198,"./plot_schema":199,"./plot_template":200}],203:[function(_dereq_,module,exports){ +},{"../lib":163,"../plots/attributes":205,"../plots/plots":249,"./plot_config":196,"./plot_schema":197,"./plot_template":198}],201:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47746,6 +48638,7 @@ function toImage(gd, opts) { // extend config for static plot var configImage = Lib.extendFlat({}, config, { + _exportedPlot: true, staticPlot: true, setBackground: setBackground }); @@ -47816,7 +48709,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":165,"../snapshot/helpers":263,"../snapshot/svgtoimg":265,"../snapshot/tosvg":267,"./plot_api":197}],204:[function(_dereq_,module,exports){ +},{"../lib":163,"../snapshot/helpers":261,"../snapshot/svgtoimg":263,"../snapshot/tosvg":265,"./plot_api":195}],202:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48262,7 +49155,7 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":165,"../plots/plots":251,"./plot_config":198,"./plot_schema":199}],205:[function(_dereq_,module,exports){ +},{"../lib":163,"../plots/plots":249,"./plot_config":196,"./plot_schema":197}],203:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48364,7 +49257,7 @@ module.exports = { } }; -},{}],206:[function(_dereq_,module,exports){ +},{}],204:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48460,7 +49353,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":165,"../plot_api/plot_template":200}],207:[function(_dereq_,module,exports){ +},{"../lib":163,"../plot_api/plot_template":198}],205:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48582,10 +49475,16 @@ module.exports = { _isLinkedToArray: 'transform', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + } }; -},{"../components/fx/attributes":79}],208:[function(_dereq_,module,exports){ +},{"../components/fx/attributes":75}],206:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48614,7 +49513,7 @@ module.exports = { } }; -},{}],209:[function(_dereq_,module,exports){ +},{}],207:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48629,6 +49528,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; +var Registry = _dereq_('../../registry'); module.exports = { getAutoRange: getAutoRange, @@ -48853,10 +49753,6 @@ function concatExtremes(gd, ax) { } function doAutoRange(gd, ax) { - if(!ax._length) ax.setScale(); - - var axIn; - if(ax.autorange) { ax.range = getAutoRange(gd, ax); @@ -48866,20 +49762,28 @@ function doAutoRange(gd, ax) { // doAutoRange will get called on fullLayout, // but we want to report its results back to layout - axIn = ax._input; + var axIn = ax._input; + + // before we edit _input, store preGUI values + var edits = {}; + edits[ax._attr + '.range'] = ax.range; + edits[ax._attr + '.autorange'] = ax.autorange; + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, edits); + axIn.range = ax.range.slice(); axIn.autorange = ax.autorange; } - if(ax._anchorAxis && ax._anchorAxis.rangeslider) { - var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name]; + var anchorAx = ax._anchorAxis; + + if(anchorAx && anchorAx.rangeslider) { + var axeRangeOpts = anchorAx.rangeslider[ax._name]; if(axeRangeOpts) { if(axeRangeOpts.rangemode === 'auto') { axeRangeOpts.range = getAutoRange(gd, ax); } } - axIn = ax._anchorAxis._input; - axIn.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); } } @@ -49097,7 +50001,7 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":145,"../../lib":165,"fast-isnumeric":11}],210:[function(_dereq_,module,exports){ +},{"../../constants/numerical":142,"../../lib":163,"../../registry":257,"fast-isnumeric":11}],208:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49257,6 +50161,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t ax.d2c(targetArray[i]); } } + // TODO what to do for transforms? } else { ax = axes.getFromTrace(gd, trace, d2cTarget); } @@ -49297,7 +50202,7 @@ axes.counterLetter = function(id) { axes.minDtick = function(ax, newDiff, newFirst, allow) { // doesn't make sense to do forced min dTick on log or category axes, // and the plot itself may decide to cancel (ie non-grouped bars) - if(['log', 'category'].indexOf(ax.type) !== -1 || !allow) { + if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; } // undefined means there's nothing there yet @@ -49329,18 +50234,15 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // save a copy of the initial axis ranges in fullLayout // use them in mode bar and dblclick events axes.saveRangeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._rangeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.range[0] === ax._rangeInitial[0] && - ax.range[1] === ax._rangeInitial[1] - ) + var hasChanged = isNew || !( + ax.range[0] === ax._rangeInitial[0] && + ax.range[1] === ax._rangeInitial[1] ); if((isNew && ax.autorange === false) || (overwrite && hasChanged)) { @@ -49354,21 +50256,16 @@ axes.saveRangeInitial = function(gd, overwrite) { // save a copy of the initial spike visibility axes.saveShowSpikeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false, - allSpikesEnabled = 'on'; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; + var allSpikesEnabled = 'on'; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._showSpikeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.showspikes === ax._showspikes - ) - ); + var hasChanged = isNew || !(ax.showspikes === ax._showspikes); - if((isNew) || (overwrite && hasChanged)) { + if(isNew || (overwrite && hasChanged)) { ax._showSpikeInitial = ax.showspikes; hasOneAxisChanged = true; } @@ -49385,7 +50282,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { var dataMin = Lib.aggNums(Math.min, null, data); var dataMax = Lib.aggNums(Math.max, null, data); - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { return { start: dataMin - 0.5, end: dataMax + 0.5, @@ -49403,8 +50300,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { type: 'linear', range: [dataMin, dataMax] }; - } - else { + } else { dummyAx = { type: ax.type, range: Lib.simpleMap([dataMin, dataMax], ax.c2r, 0, calendar), @@ -49489,10 +50385,10 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { - var edgecount = 0, - midcount = 0, - intcount = 0, - blankCount = 0; + var edgecount = 0; + var midcount = 0; + var intcount = 0; + var blankCount = 0; function nearEdge(v) { // is a value within 1% of a bin edge? @@ -49583,14 +50479,14 @@ axes.prepTicks = function(ax) { // calculate max number of (auto) ticks to display based on plot size if(ax.tickmode === 'auto' || !ax.dtick) { - var nt = ax.nticks, - minPx; + var nt = ax.nticks; + var minPx; + if(!nt) { - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; nt = ax._length / minPx; - } - else { + } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; nt = Lib.constrain(ax._length / minPx, 4, 9) + 1; } @@ -49652,7 +50548,7 @@ axes.calcTicks = function calcTicks(ax) { // return the full set of tick vals var vals = []; - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { endTick = (axrev) ? Math.max(-0.5, endTick) : Math.min(ax._categories.length - 0.5, endTick); } @@ -49696,23 +50592,22 @@ axes.calcTicks = function calcTicks(ax) { }; function arrayTicks(ax) { - var vals = ax.tickvals, - text = ax.ticktext, - ticksOut = new Array(vals.length), - rng = Lib.simpleMap(ax.range, ax.r2l), - r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001, - r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001, - tickMin = Math.min(r0expanded, r1expanded), - tickMax = Math.max(r0expanded, r1expanded), - vali, - i, - j = 0; + var vals = ax.tickvals; + var text = ax.ticktext; + var ticksOut = new Array(vals.length); + var rng = Lib.simpleMap(ax.range, ax.r2l); + var r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001; + var r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001; + var tickMin = Math.min(r0expanded, r1expanded); + var tickMax = Math.max(r0expanded, r1expanded); + var j = 0; // without a text array, just format the given values as any other ticks // except with more precision to the numbers if(!Array.isArray(text)) text = []; // make sure showing ticks doesn't accidentally add new categories + // TODO multicategory, if we allow ticktext / tickvals var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; // array ticks on log axes always show the full number @@ -49721,8 +50616,8 @@ function arrayTicks(ax) { ax.dtick = 'L' + Math.pow(10, Math.floor(Math.min(ax.range[0], ax.range[1])) - 1); } - for(i = 0; i < vals.length; i++) { - vali = tickVal2l(vals[i]); + for(var i = 0; i < vals.length; i++) { + var vali = tickVal2l(vals[i]); if(vali > tickMin && vali < tickMax) { if(text[i] === undefined) ticksOut[j] = axes.tickText(ax, vali); else ticksOut[j] = tickTextObj(ax, vali, String(text[i])); @@ -49735,17 +50630,17 @@ function arrayTicks(ax) { return ticksOut; } -var roundBase10 = [2, 5, 10], - roundBase24 = [1, 2, 3, 6, 12], - roundBase60 = [1, 2, 5, 10, 15, 30], - // 2&3 day ticks are weird, but need something btwn 1&7 - roundDays = [1, 2, 3, 7, 14], - // approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) - // these don't have to be exact, just close enough to round to the right value - roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1], - roundLog2 = [-0.301, 0, 0.301, 0.699, 1], - // N.B. `thetaunit; 'radians' angular axes must be converted to degrees - roundAngles = [15, 30, 45, 90, 180]; +var roundBase10 = [2, 5, 10]; +var roundBase24 = [1, 2, 3, 6, 12]; +var roundBase60 = [1, 2, 5, 10, 15, 30]; +// 2&3 day ticks are weird, but need something btwn 1&7 +var roundDays = [1, 2, 3, 7, 14]; +// approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) +// these don't have to be exact, just close enough to round to the right value +var roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1]; +var roundLog2 = [-0.301, 0, 0.301, 0.699, 1]; +// N.B. `thetaunit; 'radians' angular axes must be converted to degrees +var roundAngles = [15, 30, 45, 90, 180]; function roundDTick(roughDTick, base, roundingSet) { return base * Lib.roundUp(roughDTick / base, roundingSet); @@ -49836,7 +50731,7 @@ axes.autoTicks = function(ax, roughDTick) { ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } } - else if(ax.type === 'category') { + else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); } @@ -49876,7 +50771,7 @@ function autoTickRound(ax) { dtick = 1; } - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { ax._tickround = null; } if(ax.type === 'date') { @@ -49968,36 +50863,34 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { // calculate the first tick on an axis axes.tickFirst = function(ax) { - var r2l = ax.r2l || Number, - rng = Lib.simpleMap(ax.range, r2l), - axrev = rng[1] < rng[0], - sRound = axrev ? Math.floor : Math.ceil, - // add a tiny extra bit to make sure we get ticks - // that may have been rounded out - r0 = rng[0] * 1.0001 - rng[1] * 0.0001, - dtick = ax.dtick, - tick0 = r2l(ax.tick0); + var r2l = ax.r2l || Number; + var rng = Lib.simpleMap(ax.range, r2l); + var axrev = rng[1] < rng[0]; + var sRound = axrev ? Math.floor : Math.ceil; + // add a tiny extra bit to make sure we get ticks + // that may have been rounded out + var r0 = rng[0] * 1.0001 - rng[1] * 0.0001; + var dtick = ax.dtick; + var tick0 = r2l(ax.tick0); if(isNumeric(dtick)) { var tmin = sRound((r0 - tick0) / dtick) * dtick + tick0; // make sure no ticks outside the category list - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { tmin = Lib.constrain(tmin, 0, ax._categories.length - 1); } return tmin; } - var tType = dtick.charAt(0), - dtNum = Number(dtick.substr(1)); + var tType = dtick.charAt(0); + var dtNum = Number(dtick.substr(1)); // Dates: months (or years) if(tType === 'M') { - var cnt = 0, - t0 = tick0, - t1, - mult, - newDTick; + var cnt = 0; + var t0 = tick0; + var t1, mult, newDTick; // This algorithm should work for *any* nonlinear (but close to linear!) // tick spacing. Limit to 10 iterations, for gregorian months it's normally <=3. @@ -50039,16 +50932,18 @@ axes.tickFirst = function(ax) { // hover is a (truthy) flag for whether to show numbers with a bit // more precision for hovertext axes.tickText = function(ax, x, hover) { - var out = tickTextObj(ax, x), - hideexp, - arrayMode = ax.tickmode === 'array', - extraPrecision = hover || arrayMode, - i, - tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; + var out = tickTextObj(ax, x); + var arrayMode = ax.tickmode === 'array'; + var extraPrecision = hover || arrayMode; + var axType = ax.type; + // TODO multicategory, if we allow ticktext / tickvals + var tickVal2l = axType === 'category' ? ax.d2l_noadd : ax.d2l; + var i; if(arrayMode && Array.isArray(ax.ticktext)) { - var rng = Lib.simpleMap(ax.range, ax.r2l), - minDiff = Math.abs(rng[1] - rng[0]) / 10000; + var rng = Lib.simpleMap(ax.range, ax.r2l); + var minDiff = Math.abs(rng[1] - rng[0]) / 10000; + for(i = 0; i < ax.ticktext.length; i++) { if(Math.abs(x - tickVal2l(ax.tickvals[i])) < minDiff) break; } @@ -50059,28 +50954,25 @@ axes.tickText = function(ax, x, hover) { } function isHidden(showAttr) { - var first_or_last; - if(showAttr === undefined) return true; if(hover) return showAttr === 'none'; - first_or_last = { + var firstOrLast = { first: ax._tmin, last: ax._tmax }[showAttr]; - return showAttr !== 'all' && x !== first_or_last; + return showAttr !== 'all' && x !== firstOrLast; } - if(hover) { - hideexp = 'never'; - } else { - hideexp = ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - } + var hideexp = hover ? + 'never' : + ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - if(ax.type === 'date') formatDate(ax, out, hover, extraPrecision); - else if(ax.type === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); - else if(ax.type === 'category') formatCategory(ax, out); + if(axType === 'date') formatDate(ax, out, hover, extraPrecision); + else if(axType === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); + else if(axType === 'category') formatCategory(ax, out); + else if(axType === 'multicategory') formatMultiCategory(ax, out, hover); else if(isAngular(ax)) formatAngle(ax, out, hover, extraPrecision, hideexp); else formatLinear(ax, out, hover, extraPrecision, hideexp); @@ -50088,6 +50980,20 @@ axes.tickText = function(ax, x, hover) { if(ax.tickprefix && !isHidden(ax.showtickprefix)) out.text = ax.tickprefix + out.text; if(ax.ticksuffix && !isHidden(ax.showticksuffix)) out.text += ax.ticksuffix; + // Setup ticks and grid lines boundaries + // at 1/2 a 'category' to the left/bottom + if(ax.tickson === 'boundaries' || ax.showdividers) { + var inbounds = function(v) { + var p = ax.l2p(v); + return p >= 0 && p <= ax._length ? v : null; + }; + + out.xbnd = [ + inbounds(out.x - 0.5), + inbounds(out.x + ax.dtick - 0.5) + ]; + } + return out; }; @@ -50137,8 +51043,8 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround, - fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); + var tr = ax._tickround; + var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); if(extraPrecision) { // second or sub-second precision: extra always shows max digits. @@ -50147,8 +51053,8 @@ function formatDate(ax, out, hover, extraPrecision) { else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr]; } - var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat), - headStr; + var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat); + var headStr; var splitIndex = dateStr.indexOf('\n'); if(splitIndex !== -1) { @@ -50265,6 +51171,22 @@ function formatCategory(ax, out) { out.text = String(tt); } +function formatMultiCategory(ax, out, hover) { + var v = Math.round(out.x); + var cats = ax._categories[v] || []; + var tt = cats[1] === undefined ? '' : String(cats[1]); + var tt2 = cats[0] === undefined ? '' : String(cats[0]); + + if(hover) { + // TODO is this what we want? + out.text = tt2 + ' - ' + tt; + } else { + // setup for secondary labels + out.text = tt; + out.text2 = tt2; + } +} + function formatLinear(ax, out, hover, extraPrecision, hideexp) { if(hideexp === 'never') { // If this is a hover label, then we must *never* hide the exponent @@ -50370,14 +51292,13 @@ function beyondSI(exponent) { } function numFormat(v, ax, fmtoverride, hover) { - // negative? - var isNeg = v < 0, - // max number of digits past decimal point to show - tickRound = ax._tickround, - exponentFormat = fmtoverride || ax.exponentformat || 'B', - exponent = ax._tickexponent, - tickformat = axes.getTickFormat(ax), - separatethousands = ax.separatethousands; + var isNeg = v < 0; + // max number of digits past decimal point to show + var tickRound = ax._tickround; + var exponentFormat = fmtoverride || ax.exponentformat || 'B'; + var exponent = ax._tickexponent; + var tickformat = axes.getTickFormat(ax); + var separatethousands = ax.separatethousands; // special case for hover: set exponent just for this value, and // add a couple more digits of precision over tick labels @@ -50550,6 +51471,9 @@ axes.getTickFormat = function(ax) { // as an array of items like 'xy', 'x2y', 'x2y2'... // sorted by x (x,x2,x3...) then y // optionally restrict to only subplots containing axis object ax +// +// NOTE: this is currently only used OUTSIDE plotly.js (toolpanel, webapp) +// ideally we get rid of it there (or just copy this there) and remove it here axes.getSubplots = function(gd, ax) { var subplotObj = gd._fullLayout._subplots; var allSubplots = subplotObj.cartesian.concat(subplotObj.gl2d || []); @@ -50568,18 +51492,20 @@ axes.getSubplots = function(gd, ax) { }; // find all subplots with axis 'ax' +// NOTE: this is only used in axes.getSubplots (only used outside plotly.js) and +// gl2d/convert (where it restricts axis subplots to only those with gl2d) axes.findSubplotsWithAxis = function(subplots, ax) { var axMatch = new RegExp( (ax._id.charAt(0) === 'x') ? ('^' + ax._id + 'y') : (ax._id + '$') ); - var subplotsWithAxis = []; + var subplotsWithAx = []; for(var i = 0; i < subplots.length; i++) { var sp = subplots[i]; - if(axMatch.test(sp)) subplotsWithAxis.push(sp); + if(axMatch.test(sp)) subplotsWithAx.push(sp); } - return subplotsWithAxis; + return subplotsWithAx; }; // makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings @@ -50632,24 +51558,25 @@ axes.makeClipPaths = function(gd) { * * @param {DOM element} gd : graph div * @param {string or array of strings} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update + * @param {object} opts: + * - @param {boolean} skipTitle : optional flag to skip axis title draw/update * - * Signature 1: Axes.doTicks(gd, 'redraw') + * Signature 1: Axes.draw(gd, 'redraw') * use this to clear and redraw all axes on graph * - * Signature 2: Axes.doTicks(gd, '') + * Signature 2: Axes.draw(gd, '') * use this to draw all axes on graph w/o the selectAll().remove() * of the 'redraw' signature * - * Signature 3: Axes.doTicks(gd, [axId, axId2, ...]) + * Signature 3: Axes.draw(gd, [axId, axId2, ...]) * where the items are axis id string, * use this to update multiple axes in one call * - * N.B doTicks updates: + * N.B draw updates: * - ax._r (stored range for use by zoom/pan) * - ax._rl (stored linearized range for use by zoom/pan) */ -axes.doTicks = function(gd, arg, skipTitle) { +axes.draw = function(gd, arg, opts) { var fullLayout = gd._fullLayout; if(arg === 'redraw') { @@ -50661,6 +51588,8 @@ axes.doTicks = function(gd, arg, skipTitle) { plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove(); if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); @@ -50670,13 +51599,13 @@ axes.doTicks = function(gd, arg, skipTitle) { var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; - Lib.syncOrAsync(axList.map(function(axid) { + return Lib.syncOrAsync(axList.map(function(axId) { return function() { - if(!axid) return; + if(!axId) return; - var axDone = axes.doTicksSingle(gd, axid, skipTitle); + var ax = axes.getFromId(gd, axId); + var axDone = axes.drawOne(gd, ax, opts); - var ax = axes.getFromId(gd, axid); ax._r = ax.range.slice(); ax._rl = Lib.simpleMap(ax._r, ax.r2l); @@ -50686,692 +51615,1077 @@ axes.doTicks = function(gd, arg, skipTitle) { }; /** - * Per-axis drawing routine! - * - * This routine draws axis ticks and much more (... grids, labels, title etc.) - * Supports multiple argument signatures. - * N.B. this thing is async in general (because of MathJax rendering) + * Draw one cartesian axis * - * @param {DOM element} gd : graph div - * @param {string or object} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * @return {promise} - * - * Signature 1: Axes.doTicks(gd, ax) - * where ax is an axis object as in fullLayout - * - * Signature 2: Axes.doTicks(gd, axId) - * where axId is a axis id string + * @param {DOM element} gd + * @param {object} ax (full) axis object + * @param {object} opts + * - @param {boolean} skipTitle (set to true to skip axis title draw call) */ -axes.doTicksSingle = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; - var independent = false; - var ax; +axes.drawOne = function(gd, ax, opts) { + opts = opts || {}; - if(Lib.isPlainObject(arg)) { - ax = arg; - independent = true; - } else { - ax = axes.getFromId(gd, arg); - } + var i, sp, plotinfo; - // set scaling to pixels ax.setScale(); - var axid = ax._id; - var axLetter = axid.charAt(0); - var counterLetter = axes.counterLetter(axid); + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var counterLetter = axes.counterLetter(axId); + var mainSubplot = ax._mainSubplot; + var mainLinePosition = ax._mainLinePosition; + var mainMirrorPosition = ax._mainMirrorPosition; + var mainPlotinfo = fullLayout._plots[mainSubplot]; + var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; + var subplotsWithAx = ax._subplotsWith; + var vals = ax._vals = axes.calcTicks(ax); - var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; - var tcls = axid + 'tick'; - var gcls = axid + 'grid'; - var zcls = axid + 'zl'; - var pad = (ax.linewidth || 1) / 2; - var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); - var labelShift = 0; - var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); - var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); - var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); - var sides, transfn, tickpathfn, subplots; - var tickLabels; - var i; - if(ax._counterangle && ax.ticks === 'outside') { - var caRad = ax._counterangle * Math.PI / 180; - labelStandoff = ax.ticklen * Math.cos(caRad) + 1; - labelShift = ax.ticklen * Math.sin(caRad); + // Add a couple of axis properties that should cause us to recreate + // elements. Used in d3 data function. + var axInfo = [ax.mirror, mainLinePosition, mainMirrorPosition].join('_'); + for(i = 0; i < vals.length; i++) { + vals[i].axInfo = axInfo; } - if(ax.showticklabels && (ax.ticks === 'outside' || ax.showline)) { - labelStandoff += 0.2 * ax.tickfont.size; - } + if(!ax.visible) return; - // positioning arguments for x vs y axes - if(axLetter === 'x') { - sides = ['bottom', 'top']; - transfn = ax._transfn || function(d) { - return 'translate(' + (ax._offset + ax.l2p(d.x)) + ',0)'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M0,' + shift + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len); - } - else return 'M0,' + shift + 'v' + len; - }; - } - else if(axLetter === 'y') { - sides = ['left', 'right']; - transfn = ax._transfn || function(d) { - return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M' + shift + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); - } - else return 'M' + shift + ',0h' + len; - }; - } - else if(isAngular(ax)) { - sides = ['left', 'right']; - transfn = ax._transfn; - tickpathfn = function(shift, len) { - return 'M' + shift + ',0h' + len; - }; - } - else { - Lib.warn('Unrecognized doTicks axis:', axid); - return; + // stash selections to avoid DOM queries e.g. + // - stash tickLabels selection, so that drawTitle can use it to scoot title + ax._selections = {}; + // stash tick angle (including the computed 'auto' values) per tick-label class + ax._tickAngles = {}; + + var transFn = axes.makeTransFn(ax); + var tickVals; + // We remove zero lines, grid lines, and inside ticks if they're within 1px of the end + // The key case here is removing zero lines when the axis bound is zero + var valsClipped; + + if(ax.tickson === 'boundaries') { + var boundaryVals = getBoundaryVals(ax, vals); + valsClipped = axes.clipEnds(ax, boundaryVals); + tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals; + } else { + valsClipped = axes.clipEnds(ax, vals); + tickVals = ax.ticks === 'inside' ? valsClipped : vals; } - var axside = ax.side || sides[0]; - // which direction do the side[0], side[1], and free ticks go? - // then we flip if outside XOR y axis - var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; - if((ax.ticks !== 'inside') === (axLetter === 'x')) { - ticksign = ticksign.map(function(v) { return -v; }); - } + var gridVals = ax._gridVals = valsClipped; + var dividerVals = getDividerVals(ax, vals); - if(!ax.visible) return; + if(!fullLayout._hasOnlyLargeSploms) { + // keep track of which subplots (by main conteraxis) we've already + // drawn grids for, so we don't overdraw overlaying subplots + var finishedGrids = {}; - if(ax._tickFilter) { - vals = vals.filter(ax._tickFilter); - } + for(i = 0; i < subplotsWithAx.length; i++) { + sp = subplotsWithAx[i]; + plotinfo = fullLayout._plots[sp]; - // Remove zero lines, grid lines, and inside ticks if they're within - // 1 pixel of the end. - // The key case here is removing zero lines when the axis bound is zero. - // Don't clip angular values. - var valsClipped = ax._valsClipped = isAngular(ax) ? - vals : - vals.filter(function(d) { return clipEnds(ax, d.x); }); + var counterAxis = plotinfo[counterLetter + 'axis']; + var mainCounterID = counterAxis._mainAxis._id; + if(finishedGrids[mainCounterID]) continue; + finishedGrids[mainCounterID] = 1; - function drawTicks(container, tickpath) { - var ticks = container.selectAll('path.' + tcls) - .data(ax.ticks === 'inside' ? valsClipped : vals, datafn); + var gridPath = axLetter === 'x' ? + 'M0,' + counterAxis._offset + 'v' + counterAxis._length : + 'M' + counterAxis._offset + ',0h' + counterAxis._length; - if(tickpath && ax.ticks) { - ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) - .classed('crisp', 1) - .call(Color.stroke, ax.tickcolor) - .style('stroke-width', tickWidth + 'px') - .attr('d', tickpath); - ticks.attr('transform', transfn); - ticks.exit().remove(); + axes.drawGrid(gd, ax, { + vals: gridVals, + counterAxis: counterAxis, + layer: plotinfo.gridlayer.select('.' + axId), + path: gridPath, + transFn: transFn + }); + axes.drawZeroLine(gd, ax, { + counterAxis: counterAxis, + layer: plotinfo.zerolinelayer, + path: gridPath, + transFn: transFn + }); } - else ticks.remove(); } - function drawLabels(container, position) { - // tick labels - for now just the main labels. - // TODO: mirror labels, esp for subplots - tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); + var tickSigns = axes.getTickSigns(ax); + var tickSubplots = []; - if(!isNumeric(position)) { - tickLabels.remove(); - drawAxTitle(); - return; - } - if(!ax.showticklabels) { - tickLabels.remove(); - drawAxTitle(); - calcBoundingBox(); - return; + if(ax.ticks) { + var mainTickPath = axes.makeTickPath(ax, mainLinePosition, tickSigns[2]); + var mirrorTickPath; + var fullTickPath; + if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { + mirrorTickPath = axes.makeTickPath(ax, mainMirrorPosition, tickSigns[3]); + fullTickPath = mainTickPath + mirrorTickPath; + } else { + mirrorTickPath = ''; + fullTickPath = mainTickPath; } - var labelx, labely, labelanchor, labelpos0, flipit; - if(axLetter === 'x') { - flipit = (axside === 'bottom') ? 1 : -1; - labelx = function(d) { return d.dx + labelShift * flipit; }; - labelpos0 = position + (labelStandoff + pad) * flipit; - labely = function(d) { - return d.dy + labelpos0 + d.fontSize * - ((axside === 'bottom') ? 1 : -0.2); - }; - labelanchor = function(angle) { - if(!isNumeric(angle) || angle === 0 || angle === 180) { - return 'middle'; - } - return (angle * flipit < 0) ? 'end' : 'start'; - }; - } - else if(axLetter === 'y') { - flipit = (axside === 'right') ? 1 : -1; - labely = function(d) { - return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit; - }; - labelx = function(d) { - return d.dx + position + (labelStandoff + pad + - ((Math.abs(ax.tickangle) === 90) ? d.fontSize / 2 : 0)) * flipit; - }; - labelanchor = function(angle) { - if(isNumeric(angle) && Math.abs(angle) === 90) { - return 'middle'; - } - return axside === 'right' ? 'start' : 'end'; + var tickPath; + if(ax.showdividers && ax.ticks === 'outside' && ax.tickson === 'boundaries') { + var dividerLookup = {}; + for(i = 0; i < dividerVals.length; i++) { + dividerLookup[dividerVals[i].x] = 1; + } + tickPath = function(d) { + return dividerLookup[d.x] ? mirrorTickPath : fullTickPath; }; + } else { + tickPath = fullTickPath; } - else if(isAngular(ax)) { - ax._labelShift = labelShift; - ax._labelStandoff = labelStandoff; - ax._pad = pad; - - labelx = ax._labelx; - labely = ax._labely; - labelanchor = ax._labelanchor; - } - - var maxFontSize = 0, - autoangle = 0, - labelsReady = []; - tickLabels.enter().append('g').classed(tcls, 1) - .append('text') - // only so tex has predictable alignment that we can - // alter later - .attr('text-anchor', 'middle') - .each(function(d) { - var thisLabel = d3.select(this), - newPromise = gd._promises.length; - thisLabel - .call(svgTextUtils.positionText, labelx(d), labely(d)) - .call(Drawing.font, d.font, d.fontSize, d.fontColor) - .text(d.text) - .call(svgTextUtils.convertToTspans, gd); - newPromise = gd._promises[newPromise]; - if(newPromise) { - // if we have an async label, we'll deal with that - // all here so take it out of gd._promises and - // instead position the label and promise this in - // labelsReady - labelsReady.push(gd._promises.pop().then(function() { - positionLabels(thisLabel, ax.tickangle); - })); - } - else { - // sync label: just position it now. - positionLabels(thisLabel, ax.tickangle); - } - }); - tickLabels.exit().remove(); - tickLabels.each(function(d) { - maxFontSize = Math.max(maxFontSize, d.fontSize); + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: mainAxLayer, + path: tickPath, + transFn: transFn }); - if(isAngular(ax)) { - tickLabels.each(function(d) { - d3.select(this).select('text') - .call(svgTextUtils.positionText, labelx(d), labely(d)); + tickSubplots = Object.keys(ax._linepositions || {}); + } + + for(i = 0; i < tickSubplots.length; i++) { + sp = tickSubplots[i]; + plotinfo = fullLayout._plots[sp]; + // [bottom or left, top or right], free and main are handled above + var linepositions = ax._linepositions[sp] || []; + var spTickPath = axes.makeTickPath(ax, linepositions[0], tickSigns[0]) + + axes.makeTickPath(ax, linepositions[1], tickSigns[1]); + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: plotinfo[axLetter + 'axislayer'], + path: spTickPath, + transFn: transFn + }); + } + + var seq = []; + + // tick labels - for now just the main labels. + // TODO: mirror labels, esp for subplots + + seq.push(function() { + var labelFns = axes.makeLabelFns(ax, mainLinePosition); + return axes.drawLabels(gd, ax, { + vals: vals, + layer: mainAxLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn, + }); + }); + + if(ax.type === 'multicategory') { + var labelLength = 0; + var pad = {x: 2, y: 10}[axLetter]; + var sgn = tickSigns[2] * (ax.ticks === 'inside' ? -1 : 1); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick') + pad; + labelLength += ax._tickAngles[axId + 'tick'] ? ax.tickfont.size * LINE_SPACING : 0; + var secondaryPosition = mainLinePosition + labelLength * sgn; + var secondaryLabelFns = axes.makeLabelFns(ax, secondaryPosition); + + return axes.drawLabels(gd, ax, { + vals: getSecondaryLabelVals(ax, vals), + layer: mainAxLayer, + cls: axId + 'tick2', + repositionOnUpdate: true, + secondary: true, + transFn: transFn, + labelXFn: secondaryLabelFns.labelXFn, + labelYFn: secondaryLabelFns.labelYFn, + labelAnchorFn: secondaryLabelFns.labelAnchorFn, }); - } + }); - // How much to shift a multi-line label to center it vertically. - function getAnchorHeight(lineCount, lineHeight, angle) { - var h = (lineCount - 1) * lineHeight; - if(axLetter === 'x') { - if(angle < -60 || 60 < angle) { - return -0.5 * h; - } else if(axside === 'top') { - return -h; - } - } else { - angle *= axside === 'left' ? 1 : -1; - if(angle < -30) { - return -h; - } else if(angle < 30) { - return -0.5 * h; - } - } - return 0; - } - - function positionLabels(s, angle) { - s.each(function(d) { - var anchor = labelanchor(angle, d); - var thisLabel = d3.select(this), - mathjaxGroup = thisLabel.select('.text-math-group'), - transform = transfn.call(thisLabel.node(), d) + - ((isNumeric(angle) && +angle !== 0) ? - (' rotate(' + angle + ',' + labelx(d) + ',' + - (labely(d) - d.fontSize / 2) + ')') : - ''); - var anchorHeight = getAnchorHeight( - svgTextUtils.lineCount(thisLabel), - LINE_SPACING * d.fontSize, - isNumeric(angle) ? +angle : 0); - if(anchorHeight) { - transform += ' translate(0, ' + anchorHeight + ')'; - } - if(mathjaxGroup.empty()) { - thisLabel.select('text').attr({ - transform: transform, - 'text-anchor': anchor - }); - } - else { - var mjShift = - Drawing.bBox(mathjaxGroup.node()).width * - {end: -0.5, start: 0.5}[anchor]; - mathjaxGroup.attr('transform', transform + - (mjShift ? 'translate(' + mjShift + ',0)' : '')); - } + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick2'); + ax._labelLength = labelLength; + + return drawDividers(gd, ax, { + vals: dividerVals, + layer: mainAxLayer, + path: axes.makeTickPath(ax, mainLinePosition, sgn, labelLength), + transFn: transFn }); - } + }); + } - // make sure all labels are correctly positioned at their base angle - // the positionLabels call above is only for newly drawn labels. - // do this without waiting, using the last calculated angle to - // minimize flicker, then do it again when we know all labels are - // there, putting back the prescribed angle to check for overlaps. - positionLabels(tickLabels, ax._lastangle || ax.tickangle); - - function allLabelsReady() { - return labelsReady.length && Promise.all(labelsReady); - } - - function fixLabelOverlaps() { - positionLabels(tickLabels, ax.tickangle); - - // check for auto-angling if x labels overlap - // don't auto-angle at all for log axes with - // base and digit format - if(axLetter === 'x' && !isNumeric(ax.tickangle) && - (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')) { - var lbbArray = []; - tickLabels.each(function(d) { - var s = d3.select(this), - thisLabel = s.select('.text-math-group'), - x = ax.l2p(d.x); - if(thisLabel.empty()) thisLabel = s.select('text'); - - var bb = Drawing.bBox(thisLabel.node()); - - lbbArray.push({ - // ignore about y, just deal with x overlaps - top: 0, - bottom: 10, - height: 10, - left: x - bb.width / 2, - // impose a 2px gap - right: x + bb.width / 2 + 2, - width: bb.width + 2 - }); - }); - for(i = 0; i < lbbArray.length - 1; i++) { - if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { - // any overlap at all - set 30 degrees - autoangle = 30; - break; - } - } - if(autoangle) { - var tickspacing = Math.abs( - (vals[vals.length - 1].x - vals[0].x) * ax._m - ) / (vals.length - 1); - if(tickspacing < maxFontSize * 2.5) { - autoangle = 90; - } - positionLabels(tickLabels, autoangle); - } - ax._lastangle = autoangle; - } + function extendRange(range, newRange) { + range[0] = Math.min(range[0], newRange[0]); + range[1] = Math.max(range[1], newRange[1]); + } - // update the axis title - // (so it can move out of the way if needed) - // TODO: separate out scoot so we don't need to do - // a full redraw of the title (mostly relevant for MathJax) - drawAxTitle(); - return axid + ' done'; - } + function calcBoundingBox() { + if(ax.showticklabels) { + var gdBB = gd.getBoundingClientRect(); + var bBox = mainAxLayer.node().getBoundingClientRect(); - function calcBoundingBox() { - if(ax.showticklabels) { - var gdBB = gd.getBoundingClientRect(); - var bBox = container.node().getBoundingClientRect(); + /* + * the way we're going to use this, the positioning that matters + * is relative to the origin of gd. This is important particularly + * if gd is scrollable, and may have been scrolled between the time + * we calculate this and the time we use it + */ - /* - * the way we're going to use this, the positioning that matters - * is relative to the origin of gd. This is important particularly - * if gd is scrollable, and may have been scrolled between the time - * we calculate this and the time we use it - */ + ax._boundingBox = { + width: bBox.width, + height: bBox.height, + left: bBox.left - gdBB.left, + right: bBox.right - gdBB.left, + top: bBox.top - gdBB.top, + bottom: bBox.bottom - gdBB.top + }; + } else { + var gs = fullLayout._size; + var pos; + + // set dummy bbox for ticklabel-less axes + + if(axLetter === 'x') { + pos = ax.anchor === 'free' ? + gs.t + gs.h * (1 - ax.position) : + gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); ax._boundingBox = { - width: bBox.width, - height: bBox.height, - left: bBox.left - gdBB.left, - right: bBox.right - gdBB.left, - top: bBox.top - gdBB.top, - bottom: bBox.bottom - gdBB.top + top: pos, + bottom: pos, + left: ax._offset, + right: ax._offset + ax._length, + width: ax._length, + height: 0 }; } else { - var gs = fullLayout._size; - var pos; + pos = ax.anchor === 'free' ? + gs.l + gs.w * ax.position : + gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - // set dummy bbox for ticklabel-less axes - - if(axLetter === 'x') { - pos = ax.anchor === 'free' ? - gs.t + gs.h * (1 - ax.position) : - gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); - - ax._boundingBox = { - top: pos, - bottom: pos, - left: ax._offset, - right: ax._offset + ax._length, - width: ax._length, - height: 0 - }; - } else { - pos = ax.anchor === 'free' ? - gs.l + gs.w * ax.position : - gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - - ax._boundingBox = { - left: pos, - right: pos, - bottom: ax._offset + ax._length, - top: ax._offset, - height: ax._length, - width: 0 - }; - } + ax._boundingBox = { + left: pos, + right: pos, + bottom: ax._offset + ax._length, + top: ax._offset, + height: ax._length, + width: 0 + }; } + } - /* - * for spikelines: what's the full domain of positions in the - * opposite direction that are associated with this axis? - * This means any axes that we make a subplot with, plus the - * position of the axis itself if it's free. - */ - if(subplots) { - var fullRange = ax._counterSpan = [Infinity, -Infinity]; - - for(i = 0; i < subplots.length; i++) { - var subplot = fullLayout._plots[subplots[i]]; - var counterAxis = subplot[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + /* + * for spikelines: what's the full domain of positions in the + * opposite direction that are associated with this axis? + * This means any axes that we make a subplot with, plus the + * position of the axis itself if it's free. + */ + if(subplotsWithAx) { + var fullRange = ax._counterSpan = [Infinity, -Infinity]; - extendRange(fullRange, [ - counterAxis._offset, - counterAxis._offset + counterAxis._length - ]); - } + for(var i = 0; i < subplotsWithAx.length; i++) { + var plotinfo = fullLayout._plots[subplotsWithAx[i]]; + var counterAxis = plotinfo[(axLetter === 'x') ? 'yaxis' : 'xaxis']; - if(ax.anchor === 'free') { - extendRange(fullRange, (axLetter === 'x') ? - [ax._boundingBox.bottom, ax._boundingBox.top] : - [ax._boundingBox.right, ax._boundingBox.left]); - } + extendRange(fullRange, [ + counterAxis._offset, + counterAxis._offset + counterAxis._length + ]); } - function extendRange(range, newRange) { - range[0] = Math.min(range[0], newRange[0]); - range[1] = Math.max(range[1], newRange[1]); + if(ax.anchor === 'free') { + extendRange(fullRange, (axLetter === 'x') ? + [ax._boundingBox.bottom, ax._boundingBox.top] : + [ax._boundingBox.right, ax._boundingBox.left]); } } + } - function doAutoMargins() { - var pushKey = ax._name + '.automargin'; - if(axLetter !== 'x' && axLetter !== 'y') { return; } - if(!ax.automargin) { - Plots.autoMargin(gd, pushKey); - return; - } + var hasRangeSlider = Registry.getComponentMethod('rangeslider', 'isVisible')(ax); + + function doAutoMargins() { + var push, rangeSliderPush; + + if(hasRangeSlider) { + rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); + } + Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); - var s = ax.side[0]; - var push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + var s = ax.side.charAt(0); + if(ax.automargin && (!hasRangeSlider || s !== 'b')) { + push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; if(axLetter === 'x') { push.y = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 't' ? 1 : 0]); + ax._anchorAxis.domain[s === 't' ? 1 : 0]); push[s] += ax._boundingBox.height; - } - else { + } else { push.x = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 'r' ? 1 : 0]); + ax._anchorAxis.domain[s === 'r' ? 1 : 0]); push[s] += ax._boundingBox.width; } - if(ax.title !== fullLayout._dfltTitle[axLetter]) { - push[s] += ax.titlefont.size; + if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { + push[s] += ax.title.font.size; } - - Plots.autoMargin(gd, pushKey, push); } - var done = Lib.syncOrAsync([ - allLabelsReady, - fixLabelOverlaps, - calcBoundingBox, - doAutoMargins - ]); - if(done && done.then) gd._promises.push(done); - return done; + Plots.autoMargin(gd, axAutoMarginID(ax), push); } - function drawAxTitle() { - if(skipTitle) return; + seq.push(calcBoundingBox, doAutoMargins); - // now this only applies to regular cartesian axes; colorbars and - // others ALWAYS call doTicks with skipTitle=true so they can - // configure their own titles. + if(!opts.skipTitle && + !(hasRangeSlider && ax._boundingBox && ax.side === 'bottom') + ) { + seq.push(function() { return drawTitle(gd, ax); }); + } - // rangeslider takes over a bottom title so drop it here - if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; + return Lib.syncOrAsync(seq); +}; - var avoid = { - selection: tickLabels, - side: ax.side - }; - var axLetter = axid.charAt(0); - var gs = gd._fullLayout._size; - var offsetBase = 1.5; - var fontSize = ax.titlefont.size; +function getBoundaryVals(ax, vals) { + var out = []; + var i; - var transform, counterAxis, x, y; + // boundaryVals are never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; - if(tickLabels.size()) { - var translation = Drawing.getTranslate(tickLabels.node().parentNode); - avoid.offsetLeft = translation.x; - avoid.offsetTop = translation.y; + if(vals.length) { + for(i = 0; i < vals.length; i++) { + _push(vals[i], 0); } + _push(vals[i - 1], 1); + } - var titleStandoff = 10 + fontSize * offsetBase + - (ax.linewidth ? ax.linewidth - 1 : 0); + return out; +} - if(axLetter === 'x') { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : - axisIds.getFromId(gd, ax.anchor); +function getSecondaryLabelVals(ax, vals) { + var out = []; + var lookup = {}; - x = ax._offset + ax._length / 2; + for(var i = 0; i < vals.length; i++) { + var d = vals[i]; + if(lookup[d.text2]) { + lookup[d.text2].push(d.x); + } else { + lookup[d.text2] = [d.x]; + } + } - if(ax.side === 'top') { - y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); - } - else { - y = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1.5 : 0.5); - } - y += counterAxis._offset; + for(var k in lookup) { + out.push(tickTextObj(ax, Lib.interp(lookup[k], 0.5), k)); + } - if(!avoid.side) avoid.side = 'bottom'; + return out; +} + +function getDividerVals(ax, vals) { + var out = []; + var i, current; + + // never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); } - else { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + }; - y = ax._offset + ax._length / 2; - if(ax.side === 'right') { - x = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1 : 0.5); - } - else { - x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + if(ax.showdividers && vals.length) { + for(i = 0; i < vals.length; i++) { + var d = vals[i]; + if(d.text2 !== current) { + _push(d, 0); } - x += counterAxis._offset; + current = d.text2; + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getLabelLevelSpan(ax, cls) { + var axLetter = ax._id.charAt(0); + var angle = ax._tickAngles[cls] || 0; + var rad = Lib.deg2rad(angle); + var sinA = Math.sin(rad); + var cosA = Math.cos(rad); + var maxX = 0; + var maxY = 0; + + // N.B. Drawing.bBox does not take into account rotate transforms + + ax._selections[cls].each(function() { + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + var w = bb.width; + var h = bb.height; + maxX = Math.max(maxX, cosA * w, sinA * h); + maxY = Math.max(maxY, sinA * w, cosA * h); + }); + + return {x: maxY, y: maxX}[axLetter]; +} + +/** + * Which direction do the 'ax.side' values, and free ticks go? + * + * @param {object} ax (full) axis object + * - {string} _id (starting with 'x' or 'y') + * - {string} side + * - {string} ticks + * @return {array} all entries are either -1 or 1 + * - [0]: sign for top/right ticks (i.e. negative SVG direction) + * - [1]: sign for bottom/left ticks (i.e. positive SVG direction) + * - [2]: sign for ticks corresponding to 'ax.side' + * - [3]: sign for ticks mirroring 'ax.side' + */ +axes.getTickSigns = function(ax) { + var axLetter = ax._id.charAt(0); + var sideOpposite = {x: 'top', y: 'right'}[axLetter]; + var main = ax.side === sideOpposite ? 1 : -1; + var out = [-1, 1, main, -main]; + // then we flip if outside XOR y axis + if((ax.ticks !== 'inside') === (axLetter === 'x')) { + out = out.map(function(v) { return -v; }); + } + return out; +}; + +/** + * Make axis translate transform function + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} _offset + * - {fn} l2p + * @return {fn} function of calcTicks items + */ +axes.makeTransFn = function(ax) { + var axLetter = ax._id.charAt(0); + var offset = ax._offset; + return axLetter === 'x' ? + function(d) { return 'translate(' + (offset + ax.l2p(d.x)) + ',0)'; } : + function(d) { return 'translate(0,' + (offset + ax.l2p(d.x)) + ')'; }; +}; + +/** + * Make axis tick path string + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} ticklen + * - {number} linewidth + * @param {number} shift along direction of ticklen + * @param {1 or -1} sng tick sign + * @param {number (optional)} len tick length + * @return {string} + */ +axes.makeTickPath = function(ax, shift, sgn, len) { + len = len !== undefined ? len : ax.ticklen; + + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + + return axLetter === 'x' ? + 'M0,' + (shift + pad * sgn) + 'v' + (len * sgn) : + 'M' + (shift + pad * sgn) + ',0h' + (len * sgn); +}; + +/** + * Make axis tick label x, y and anchor functions + * + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} ticklen + * - {string} side + * - {number} linewidth + * - {number} tickfont.size + * - {boolean} showline + * @param {number} shift + * @param {number} angle [in degrees] ... + * @return {object} + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + * - {number} labelStandoff + * - {number} labelShift + */ +axes.makeLabelFns = function(ax, shift, angle) { + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside'; + + var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0; + var labelShift = 0; + + if(angle && ax.ticks === 'outside') { + var rad = Lib.deg2rad(angle); + labelStandoff = ax.ticklen * Math.cos(rad) + 1; + labelShift = ax.ticklen * Math.sin(rad); + } + + if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) { + labelStandoff += 0.2 * ax.tickfont.size; + } + + // Used in polar angular label x/y functions + // TODO generalize makeLabelFns so that it just work for angular axes + var out = { + labelStandoff: labelStandoff, + labelShift: labelShift + }; + + var x0, y0, ff, flipIt; + if(axLetter === 'x') { + flipIt = ax.side === 'bottom' ? 1 : -1; + x0 = labelShift * flipIt; + y0 = shift + (labelStandoff + pad) * flipIt; + ff = ax.side === 'bottom' ? 1 : -0.2; + + out.labelXFn = function(d) { return d.dx + x0; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * ff; }; + out.labelAnchorFn = function(a) { + if(!isNumeric(a) || a === 0 || a === 180) { + return 'middle'; + } + return (a * flipIt < 0) ? 'end' : 'start'; + }; + } else if(axLetter === 'y') { + flipIt = ax.side === 'right' ? 1 : -1; + x0 = labelStandoff + pad; + y0 = -labelShift * flipIt; + ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0; + + out.labelXFn = function(d) { return d.dx + shift + (x0 + d.fontSize * ff) * flipIt; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; }; + out.labelAnchorFn = function(a) { + if(isNumeric(a) && Math.abs(a) === 90) { + return 'middle'; + } + return ax.side === 'right' ? 'start' : 'end'; + }; + } + + return out; +}; + +function tickDataFn(d) { + return [d.text, d.x, d.axInfo, d.font, d.fontSize, d.fontColor].join('_'); +} + +/** + * Draw axis ticks + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} linewidth + * - {string} tickcolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawTicks = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'tick'; + + var ticks = opts.layer.selectAll('path.' + cls) + .data(ax.ticks ? opts.vals : [], tickDataFn); + + ticks.exit().remove(); + + ticks.enter().append('path') + .classed(cls, 1) + .classed('ticks', 1) + .classed('crisp', opts.crisp !== false) + .call(Color.stroke, ax.tickcolor) + .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') + .attr('d', opts.path); + + ticks.attr('transform', opts.transFn); +}; - transform = {rotate: '-90', offset: 0}; - if(!avoid.side) avoid.side = 'left'; +/** + * Draw axis grid + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showgrid + * - {string} gridcolor + * - {string} gridwidth + * - {boolean} zeroline + * - {string} type + * - {string} dtick + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * optional - only required if this axis supports zero lines + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawGrid = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'grid'; + var vals = opts.vals; + var counterAx = opts.counterAxis; + if(ax.showgrid === false) { + vals = []; + } + else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + var isArrayMode = ax.tickmode === 'array'; + for(var i = 0; i < vals.length; i++) { + var xi = vals[i].x; + if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) { + vals = vals.slice(0, i).concat(vals.slice(i + 1)); + // In array mode you can in principle have multiple + // ticks at 0, so test them all. Otherwise once we found + // one we can stop. + if(isArrayMode) i--; + else break; + } } + } + + var grid = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + grid.exit().remove(); + + grid.enter().append('path') + .classed(cls, 1) + .classed('crisp', opts.crisp !== false); + + ax._gw = Drawing.crispRound(gd, ax.gridwidth, 1); + + grid.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.gridcolor || '#ddd') + .style('stroke-width', ax._gw + 'px'); - Titles.draw(gd, axid + 'title', { - propContainer: ax, - propName: ax._name + '.title', - placeholder: fullLayout._dfltTitle[axLetter], - avoid: avoid, - transform: transform, - attributes: {x: x, y: y, 'text-anchor': 'middle'} + if(typeof opts.path === 'function') grid.attr('d', opts.path); +}; + +/** + * Draw axis zero-line + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} zeroline + * - {number} zerolinewidth + * - {string} zerolinecolor + * - {number (optional)} _gridWidthCrispRound + * @param {object} opts + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawZeroLine = function(gd, ax, opts) { + opts = opts || opts; + + var cls = ax._id + 'zl'; + var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis); + + var zl = opts.layer.selectAll('path.' + cls) + .data(show ? [{x: 0, id: ax._id}] : []); + + zl.exit().remove(); + + zl.enter().append('path') + .classed(cls, 1) + .classed('zl', 1) + .classed('crisp', opts.crisp !== false) + .each(function() { + // use the fact that only one element can enter to trigger a sort. + // If several zerolines enter at the same time we will sort once per, + // but generally this should be a minimal overhead. + opts.layer.selectAll('path').sort(function(da, db) { + return axisIds.idSort(da.id, db.id); + }); }); - } - function drawGrid(plotinfo, counteraxis) { - if(fullLayout._hasOnlyLargeSploms) return; - - var gridcontainer = plotinfo.gridlayer.selectAll('.' + axid); - var zlcontainer = plotinfo.zerolinelayer; - var gridpath = ax._gridpath || ((axLetter === 'x' ? - ('M0,' + counteraxis._offset + 'v') : - ('M' + counteraxis._offset + ',0h') - ) + counteraxis._length); - var grid = gridcontainer.selectAll('path.' + gcls) - .data((ax.showgrid === false) ? [] : valsClipped, datafn); - grid.enter().append('path').classed(gcls, 1) - .classed('crisp', 1) - .attr('d', gridpath) + zl.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); +}; + +/** + * Draw axis tick labels + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showticklabels + * - {number} tickangle + * - {object (optional)} _selections + * - {object} (optional)} _tickAngles + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string (optional)} cls (node className) + * - {boolean} repositionOnUpdate (set to true to reposition update selection) + * - {boolean} secondary + * - {fn} transFn + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + */ +axes.drawLabels = function(gd, ax, opts) { + opts = opts || {}; + + var axId = ax._id; + var axLetter = axId.charAt(0); + var cls = opts.cls || axId + 'tick'; + var vals = opts.vals; + var labelXFn = opts.labelXFn; + var labelYFn = opts.labelYFn; + var labelAnchorFn = opts.labelAnchorFn; + var tickAngle = opts.secondary ? 0 : ax.tickangle; + var lastAngle = (ax._tickAngles || {})[cls]; + + var tickLabels = opts.layer.selectAll('g.' + cls) + .data(ax.showticklabels ? vals : [], tickDataFn); + + var labelsReady = []; + + tickLabels.enter().append('g') + .classed(cls, 1) + .append('text') + // only so tex has predictable alignment that we can + // alter later + .attr('text-anchor', 'middle') .each(function(d) { - if(ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - Math.abs(d.x) < ax.dtick / 100) { - d3.select(this).remove(); + var thisLabel = d3.select(this); + var newPromise = gd._promises.length; + + thisLabel + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)) + .call(Drawing.font, d.font, d.fontSize, d.fontColor) + .text(d.text) + .call(svgTextUtils.convertToTspans, gd); + + if(gd._promises[newPromise]) { + // if we have an async label, we'll deal with that + // all here so take it out of gd._promises and + // instead position the label and promise this in + // labelsReady + labelsReady.push(gd._promises.pop().then(function() { + positionLabels(thisLabel, tickAngle); + })); + } else { + // sync label: just position it now. + positionLabels(thisLabel, tickAngle); } }); - grid.attr('transform', transfn) - .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', gridWidth + 'px'); - if(typeof gridpath === 'function') grid.attr('d', gridpath); - grid.exit().remove(); - - // zero line - if(zlcontainer) { - var zlData = {x: 0, id: axid}; - var showZl = axes.shouldShowZeroLine(gd, ax, counteraxis); - var zl = zlcontainer.selectAll('path.' + zcls) - .data(showZl ? [zlData] : []); - zl.enter().append('path').classed(zcls, 1).classed('zl', 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function() { - // use the fact that only one element can enter to trigger a sort. - // If several zerolines enter at the same time we will sort once per, - // but generally this should be a minimal overhead. - zlcontainer.selectAll('path').sort(function(da, db) { - return axisIds.idSort(da.id, db.id); - }); - }); - zl.attr('transform', transfn) - .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', zeroLineWidth + 'px'); - zl.exit().remove(); - } + + tickLabels.exit().remove(); + + if(opts.repositionOnUpdate) { + tickLabels.each(function(d) { + d3.select(this).select('text') + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)); + }); } - if(independent) { - drawTicks(ax._axislayer, tickpathfn(ax._pos + pad * ticksign[2], ticksign[2] * ax.ticklen)); - if(ax._counteraxis) { - var fictionalPlotinfo = { - gridlayer: ax._gridlayer, - zerolinelayer: ax._zerolinelayer - }; - drawGrid(fictionalPlotinfo, ax._counteraxis); + // How much to shift a multi-line label to center it vertically. + function getAnchorHeight(lineCount, lineHeight, angle) { + var h = (lineCount - 1) * lineHeight; + if(axLetter === 'x') { + if(angle < -60 || 60 < angle) { + return -0.5 * h; + } else if(ax.side === 'top') { + return -h; + } + } else { + angle *= ax.side === 'left' ? 1 : -1; + if(angle < -30) { + return -h; + } else if(angle < 30) { + return -0.5 * h; + } } - return drawLabels(ax._axislayer, ax._pos); + return 0; } - else if(fullLayout._has('cartesian')) { - subplots = axes.getSubplots(gd, ax); - - // keep track of which subplots (by main conteraxis) we've already - // drawn grids for, so we don't overdraw overlaying subplots - var finishedGrids = {}; - subplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; - var counterAxis = plotinfo[counterLetter + 'axis']; + function positionLabels(s, angle) { + s.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + var anchor = labelAnchorFn(angle, d); + + var transform = opts.transFn.call(thisLabel.node(), d) + + ((isNumeric(angle) && +angle !== 0) ? + (' rotate(' + angle + ',' + labelXFn(d) + ',' + + (labelYFn(d) - d.fontSize / 2) + ')') : + ''); + + var anchorHeight = getAnchorHeight( + svgTextUtils.lineCount(thisLabel), + LINE_SPACING * d.fontSize, + isNumeric(angle) ? +angle : 0 + ); - var mainCounterID = counterAxis._mainAxis._id; - if(finishedGrids[mainCounterID]) return; - finishedGrids[mainCounterID] = 1; + if(anchorHeight) { + transform += ' translate(0, ' + anchorHeight + ')'; + } - drawGrid(plotinfo, counterAxis, subplot); + if(mathjaxGroup.empty()) { + thisLabel.select('text').attr({ + transform: transform, + 'text-anchor': anchor + }); + } else { + var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; + var mjShift = mjWidth * {end: -0.5, start: 0.5}[anchor]; + mathjaxGroup.attr('transform', transform + (mjShift ? 'translate(' + mjShift + ',0)' : '')); + } }); + } - var mainSubplot = ax._mainSubplot; - var mainPlotinfo = fullLayout._plots[mainSubplot]; - var tickSubplots = []; + // make sure all labels are correctly positioned at their base angle + // the positionLabels call above is only for newly drawn labels. + // do this without waiting, using the last calculated angle to + // minimize flicker, then do it again when we know all labels are + // there, putting back the prescribed angle to check for overlaps. + positionLabels(tickLabels, lastAngle || tickAngle); - if(ax.ticks) { - var mainSign = ticksign[2]; - var tickpath = tickpathfn(ax._mainLinePosition + pad * mainSign, mainSign * ax.ticklen); - if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { - tickpath += tickpathfn(ax._mainMirrorPosition - pad * mainSign, -mainSign * ax.ticklen); - } - drawTicks(mainPlotinfo[axLetter + 'axislayer'], tickpath); + function allLabelsReady() { + return labelsReady.length && Promise.all(labelsReady); + } - tickSubplots = Object.keys(ax._linepositions || {}); - } + function fixLabelOverlaps() { + positionLabels(tickLabels, tickAngle); + + var autoangle = null; - tickSubplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; + // check for auto-angling if x labels overlap + // don't auto-angle at all for log axes with + // base and digit format + if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) && + (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D') + ) { + autoangle = 0; - var container = plotinfo[axLetter + 'axislayer']; + var maxFontSize = 0; + var lbbArray = []; + var i; - // [bottom or left, top or right] - // free and main are handled above - var linepositions = ax._linepositions[subplot] || []; + tickLabels.each(function(d) { + maxFontSize = Math.max(maxFontSize, d.fontSize); + + var x = ax.l2p(d.x); + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + + lbbArray.push({ + // ignore about y, just deal with x overlaps + top: 0, + bottom: 10, + height: 10, + left: x - bb.width / 2, + // impose a 2px gap + right: x + bb.width / 2 + 2, + width: bb.width + 2 + }); + }); + + if((ax.tickson === 'boundaries' || ax.showdividers) && !opts.secondary) { + var gap = 2; + if(ax.ticks) gap += ax.tickwidth / 2; + + // TODO should secondary labels also fall into this fix-overlap regime? + + for(i = 0; i < lbbArray.length; i++) { + var xbnd = vals[i].xbnd; + var lbb = lbbArray[i]; + if( + (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || + (xbnd[1] !== null && (ax.l2p(xbnd[1]) - lbb.right) < gap) + ) { + autoangle = 90; + break; + } + } + } else { + var vLen = vals.length; + var tickSpacing = Math.abs((vals[vLen - 1].x - vals[0].x) * ax._m) / (vLen - 1); + var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory'; - function tickPathSide(sidei) { - var tsign = ticksign[sidei]; - return tickpathfn(linepositions[sidei] + pad * tsign, tsign * ax.ticklen); + // any overlap at all - set 30 degrees or 90 degrees + for(i = 0; i < lbbArray.length - 1; i++) { + if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { + autoangle = rotate90 ? 90 : 30; + break; + } + } } - drawTicks(container, tickPathSide(0) + tickPathSide(1)); - }); + if(autoangle) { + positionLabels(tickLabels, autoangle); + } + } - var mainContainer = mainPlotinfo[axLetter + 'axislayer']; + if(ax._tickAngles) { + ax._tickAngles[cls] = autoangle === null ? + (isNumeric(tickAngle) ? tickAngle : 0) : + autoangle; + } + } - return drawLabels(mainContainer, ax._mainLinePosition); + if(ax._selections) { + ax._selections[cls] = tickLabels; } + + var done = Lib.syncOrAsync([allLabelsReady, fixLabelOverlaps]); + if(done && done.then) gd._promises.push(done); + return done; }; +/** + * Draw axis dividers + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} showdividers + * - {number} dividerwidth + * - {string} dividercolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {fn} path + * - {fn} transFn + */ +function drawDividers(gd, ax, opts) { + var cls = ax._id + 'divider'; + var vals = opts.vals; + + var dividers = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + dividers.exit().remove(); + + dividers.enter().insert('path', ':first-child') + .classed(cls, 1) + .classed('crisp', 1) + .call(Color.stroke, ax.dividercolor) + .style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px'); + + dividers + .attr('transform', opts.transFn) + .attr('d', opts.path); +} + +function drawTitle(gd, ax) { + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var gs = fullLayout._size; + var fontSize = ax.title.font.size; + + var titleStandoff; + if(ax.type === 'multicategory') { + titleStandoff = ax._labelLength; + } else { + var offsetBase = 1.5; + titleStandoff = 10 + fontSize * offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); + } + + var transform, counterAxis, x, y; + + if(axLetter === 'x') { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + x = ax._offset + ax._length / 2; + + if(ax.side === 'top') { + y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); + } else { + y = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1.5 : 0.5); + } + y += counterAxis._offset; + } else { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + y = ax._offset + ax._length / 2; + + if(ax.side === 'right') { + x = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1 : 0.5); + } else { + x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + } + x += counterAxis._offset; + + transform = {rotate: '-90', offset: 0}; + } + + var avoid; + + if(ax.type !== 'multicategory') { + var tickLabels = ax._selections[ax._id + 'tick']; + + avoid = { + selection: tickLabels, + side: ax.side + }; + + if(tickLabels && tickLabels.node() && tickLabels.node().parentNode) { + var translation = Drawing.getTranslate(tickLabels.node().parentNode); + avoid.offsetLeft = translation.x; + avoid.offsetTop = translation.y; + } + } + + return Titles.draw(gd, axId + 'title', { + propContainer: ax, + propName: ax._name + '.title.text', + placeholder: fullLayout._dfltTitle[axLetter], + avoid: avoid, + transform: transform, + attributes: {x: x, y: y, 'text-anchor': 'middle'} + }); +} + axes.shouldShowZeroLine = function(gd, ax, counterAxis) { var rng = Lib.simpleMap(ax.range, ax.r2l); return ( (rng[0] * rng[1] <= 0) && ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - ax._valsClipped.length && + ax._gridVals.length && ( clipEnds(ax, 0) || !anyCounterAxLineAtZero(gd, ax, counterAxis, rng) || @@ -51380,6 +52694,10 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { ); }; +axes.clipEnds = function(ax, vals) { + return vals.filter(function(d) { return clipEnds(ax, d.x); }); +}; + function clipEnds(ax, l) { var p = ax.l2p(l); return (p > 1 && p < ax._length - 1); @@ -51455,6 +52773,12 @@ function hasBarsOrFill(gd, ax) { return false; } +function selectTickLabel(gTick) { + var s = d3.select(gTick); + var mj = s.select('.text-math-group'); + return mj.empty() ? s.select('text') : mj; +} + /** * Find all margin pushers for 2D axes and reserve them for later use * Both label and rangeslider automargin calculations happen later so @@ -51469,14 +52793,17 @@ axes.allowAutoMargin = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; if(ax.automargin) { - Plots.allowAutoMargin(gd, ax._name + '.automargin'); + Plots.allowAutoMargin(gd, axAutoMarginID(ax)); } - if(ax.rangeslider && ax.rangeslider.visible) { - Plots.allowAutoMargin(gd, 'rangeslider' + ax._id); + if(Registry.getComponentMethod('rangeslider', 'isVisible')(ax)) { + Plots.allowAutoMargin(gd, rangeSliderAutoMarginID(ax)); } } }; +function axAutoMarginID(ax) { return ax._id + '.automargin'; } +function rangeSliderAutoMarginID(ax) { return ax._id + '.rangeslider'; } + // swap all the presentation attributes of the axes showing these traces axes.swap = function(gd, traces) { var axGroups = makeAxisGroups(gd, traces); @@ -51532,11 +52859,10 @@ function mergeAxisGroups(intoSet, fromSet) { } function swapAxisGroup(gd, xIds, yIds) { - var i, - j, - xFullAxes = [], - yFullAxes = [], - layout = gd.layout; + var xFullAxes = []; + var yFullAxes = []; + var layout = gd.layout; + var i, j; for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i])); for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i])); @@ -51549,12 +52875,12 @@ function swapAxisGroup(gd, xIds, yIds) { var numericTypes = ['linear', 'log']; for(i = 0; i < allAxKeys.length; i++) { - var keyi = allAxKeys[i], - xVal = xFullAxes[0][keyi], - yVal = yFullAxes[0][keyi], - allEqual = true, - coerceLinearX = false, - coerceLinearY = false; + var keyi = allAxKeys[i]; + var xVal = xFullAxes[0][keyi]; + var yVal = yFullAxes[0][keyi]; + var allEqual = true; + var coerceLinearX = false; + var coerceLinearY = false; if(keyi.charAt(0) === '_' || typeof xVal === 'function' || noSwapAttrs.indexOf(keyi) !== -1) { continue; @@ -51600,17 +52926,18 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes, dfltTitle) { // in case the value is the default for either axis, // look at the first axis in each list and see if // this key's value is undefined - var np = Lib.nestedProperty, - xVal = np(layout[xFullAxes[0]._name], key).get(), - yVal = np(layout[yFullAxes[0]._name], key).get(), - i; + var np = Lib.nestedProperty; + var xVal = np(layout[xFullAxes[0]._name], key).get(); + var yVal = np(layout[yFullAxes[0]._name], key).get(); + var i; + if(key === 'title') { // special handling of placeholder titles - if(xVal === dfltTitle.x) { - xVal = dfltTitle.y; + if(xVal && xVal.text === dfltTitle.x) { + xVal.text = dfltTitle.y; } - if(yVal === dfltTitle.y) { - yVal = dfltTitle.x; + if(yVal && yVal.text === dfltTitle.y) { + yVal.text = dfltTitle.x; } } @@ -51626,7 +52953,7 @@ function isAngular(ax) { return ax._id === 'angularaxis'; } -},{"../../components/color":45,"../../components/drawing":70,"../../components/titles":136,"../../constants/alignment":143,"../../constants/numerical":145,"../../lib":165,"../../lib/svg_text_utils":186,"../../plots/plots":251,"../../registry":259,"./autorange":209,"./axis_autotype":211,"./axis_ids":213,"./clean_ticks":215,"./layout_attributes":223,"./set_convert":229,"d3":9,"fast-isnumeric":11}],211:[function(_dereq_,module,exports){ +},{"../../components/color":45,"../../components/drawing":66,"../../components/titles":133,"../../constants/alignment":140,"../../constants/numerical":142,"../../lib":163,"../../lib/svg_text_utils":184,"../../plots/plots":249,"../../registry":257,"./autorange":207,"./axis_autotype":209,"./axis_ids":211,"./clean_ticks":213,"./layout_attributes":221,"./set_convert":227,"d3":9,"fast-isnumeric":11}],209:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51643,7 +52970,10 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var BADNUM = _dereq_('../../constants/numerical').BADNUM; -module.exports = function autoType(array, calendar) { +module.exports = function autoType(array, calendar, opts) { + opts = opts || {}; + + if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory'; if(moreDates(array, calendar)) return 'date'; if(category(array)) return 'category'; if(linearOK(array)) return 'linear'; @@ -51711,7 +53041,14 @@ function category(a) { return curvecats > curvenums * 2; } -},{"../../constants/numerical":145,"../../lib":165,"fast-isnumeric":11}],212:[function(_dereq_,module,exports){ +// very-loose requirements for multicategory, +// trace modules that should never auto-type to multicategory +// should be declared with 'noMultiCategory' +function multiCategory(a) { + return Lib.isArrayOrTypedArray(a[0]) && Lib.isArrayOrTypedArray(a[1]); +} + +},{"../../constants/numerical":142,"../../lib":163,"fast-isnumeric":11}],210:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51742,6 +53079,7 @@ var setConvert = _dereq_('./set_convert'); * outerTicks: boolean, should ticks default to outside? * showGrid: boolean, should gridlines be shown by default? * noHover: boolean, this axis doesn't support hover effects? + * noTickson: boolean, this axis doesn't support 'tickson' * data: the plot data, used to manage categories * bgColor: the plot background color, to calculate default gridline colors */ @@ -51782,8 +53120,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, // try to get default title from splom trace, fallback to graph-wide value var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter]; - coerce('title', dfltTitle); - Lib.coerceFont(coerce, 'titlefont', { + coerce('title.text', dfltTitle); + Lib.coerceFont(coerce, 'title.font', { family: font.family, size: Math.round(font.size * 1.2), color: dfltFontColor @@ -51803,10 +53141,29 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, if(options.automargin) coerce('automargin'); + var isMultiCategory = containerOut.type === 'multicategory'; + + if(!options.noTickson && + (containerOut.type === 'category' || isMultiCategory) && + (containerOut.ticks || containerOut.showgrid) + ) { + var ticksonDflt; + if(isMultiCategory) ticksonDflt = 'boundaries'; + coerce('tickson', ticksonDflt); + } + + if(isMultiCategory) { + var showDividers = coerce('showdividers'); + if(showDividers) { + coerce('dividercolor'); + coerce('dividerwidth'); + } + } + return containerOut; }; -},{"../../lib":165,"../../registry":259,"./category_order_defaults":214,"./layout_attributes":223,"./line_grid_defaults":225,"./set_convert":229,"./tick_label_defaults":230,"./tick_mark_defaults":231,"./tick_value_defaults":232}],213:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../registry":257,"./category_order_defaults":212,"./layout_attributes":221,"./line_grid_defaults":223,"./set_convert":227,"./tick_label_defaults":228,"./tick_mark_defaults":229,"./tick_value_defaults":230}],211:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51924,7 +53281,7 @@ exports.idSort = function(id1, id2) { return +(id1.substr(1) || 1) - +(id2.substr(1) || 1); }; -},{"../../registry":259,"./constants":216}],214:[function(_dereq_,module,exports){ +},{"../../registry":257,"./constants":214}],212:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52018,7 +53375,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],215:[function(_dereq_,module,exports){ +},{}],213:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52107,7 +53464,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":145,"../../lib":165,"fast-isnumeric":11}],216:[function(_dereq_,module,exports){ +},{"../../constants/numerical":142,"../../lib":163,"fast-isnumeric":11}],214:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52189,7 +53546,7 @@ module.exports = { } }; -},{"../../lib/regex":180}],217:[function(_dereq_,module,exports){ +},{"../../lib/regex":178}],215:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52343,7 +53700,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[scaleanchor] = 1; } -},{"../../lib":165,"./axis_ids":213}],218:[function(_dereq_,module,exports){ +},{"../../lib":163,"./axis_ids":211}],216:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52485,7 +53842,6 @@ exports.enforce = function enforceAxisConstraints(gd) { var getPad = makePadFn(ax); updateDomain(ax, factor); - ax.setScale(); var m = Math.abs(ax._m); var extremes = concatExtremes(gd, ax); var minArray = extremes.min; @@ -52552,9 +53908,10 @@ function updateDomain(ax, factor) { center + (inputDomain[0] - center) / factor, center + (inputDomain[1] - center) / factor ]; + ax.setScale(); } -},{"../../constants/alignment":143,"../../constants/numerical":145,"./autorange":209,"./axis_ids":213,"./scale_zoom":227}],219:[function(_dereq_,module,exports){ +},{"../../constants/alignment":140,"../../constants/numerical":142,"./autorange":207,"./axis_ids":211,"./scale_zoom":225}],217:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52576,6 +53933,7 @@ var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Fx = _dereq_('../../components/fx'); +var Axes = _dereq_('./axes'); var setCursor = _dereq_('../../lib/setcursor'); var dragElement = _dereq_('../../components/dragelement'); var FROM_TL = _dereq_('../../constants/alignment').FROM_TL; @@ -52584,7 +53942,6 @@ var redrawReglTraces = _dereq_('../../plot_api/subroutines').redrawReglTraces; var Plots = _dereq_('../plots'); -var doTicksSingle = _dereq_('./axes').doTicksSingle; var getFromId = _dereq_('./axis_ids').getFromId; var prepSelect = _dereq_('./select').prepSelect; var clearSelect = _dereq_('./select').clearSelect; @@ -52828,7 +54185,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { .on('edit', function(text) { var v = ax.d2r(text); if(v !== undefined) { - Registry.call('relayout', gd, attrStr, v); + Registry.call('_guiRelayout', gd, attrStr, v); } }); } @@ -53073,6 +54430,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { return; } + // prevent axis drawing from monkeying with margins until we're done + gd._fullLayout._replotting = true; + if(xActive === 'ew' || yActive === 'ns') { if(xActive) dragAxList(xaxes, dx); if(yActive) dragAxList(yaxes, dy); @@ -53176,8 +54536,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { updates = {}; for(i = 0; i < activeAxIds.length; i++) { var axId = activeAxIds[i]; - doTicksSingle(gd, axId, true); var ax = getFromId(gd, axId); + Axes.drawOne(gd, ax, {skipTitle: true}); updates[ax._name + '.range[0]'] = ax.range[0]; updates[ax._name + '.range[1]'] = ax.range[1]; } @@ -53269,7 +54629,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, attrs); } // dragTail - finish a drag event with a redraw @@ -53283,7 +54643,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // accumulated MathJax promises - wait for them before we relayout. Lib.syncOrAsync([ Plots.previousPromises, - function() { Registry.call('relayout', gd, updates); } + function() { + gd._fullLayout._replotting = false; + Registry.call('_guiRelayout', gd, updates); + } ], gd); } @@ -53741,7 +55104,7 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":45,"../../components/dragelement":67,"../../components/drawing":70,"../../components/fx":87,"../../constants/alignment":143,"../../lib":165,"../../lib/clear_gl_canvases":152,"../../lib/setcursor":184,"../../lib/svg_text_utils":186,"../../plot_api/subroutines":201,"../../registry":259,"../plots":251,"./axes":210,"./axis_ids":213,"./constants":216,"./scale_zoom":227,"./select":228,"d3":9,"has-passive-events":14,"tinycolor2":27}],220:[function(_dereq_,module,exports){ +},{"../../components/color":45,"../../components/dragelement":63,"../../components/drawing":66,"../../components/fx":84,"../../constants/alignment":140,"../../lib":163,"../../lib/clear_gl_canvases":150,"../../lib/setcursor":182,"../../lib/svg_text_utils":184,"../../plot_api/subroutines":199,"../../registry":257,"../plots":249,"./axes":208,"./axis_ids":211,"./constants":214,"./scale_zoom":225,"./select":226,"d3":9,"has-passive-events":14,"tinycolor2":27}],218:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53909,7 +55272,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":67,"../../components/fx":87,"../../lib/setcursor":184,"./constants":216,"./dragbox":219,"d3":9}],221:[function(_dereq_,module,exports){ +},{"../../components/dragelement":63,"../../components/fx":84,"../../lib/setcursor":182,"./constants":214,"./dragbox":217,"d3":9}],219:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53984,7 +55347,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":165,"../../registry":259}],222:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../registry":257}],220:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54249,7 +55612,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback // layers that allow `cliponaxis: false` if(className !== 'scatterlayer' && className !== 'barlayer') { - Drawing.setClipUrl(sel, plotinfo.layerClipId); + Drawing.setClipUrl(sel, plotinfo.layerClipId, gd); } }); @@ -54607,7 +55970,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":70,"../../constants/xmlns_namespaces":146,"../../lib":165,"../../registry":259,"../get_data":247,"../plots":251,"./attributes":208,"./axis_ids":213,"./constants":216,"./graph_interact":220,"./layout_attributes":223,"./layout_defaults":224,"./transition_axes":233,"d3":9}],223:[function(_dereq_,module,exports){ +},{"../../components/drawing":66,"../../constants/xmlns_namespaces":143,"../../lib":163,"../../registry":257,"../get_data":245,"../plots":249,"./attributes":206,"./axis_ids":211,"./constants":214,"./graph_interact":218,"./layout_attributes":221,"./layout_defaults":222,"./transition_axes":231,"d3":9}],221:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54642,21 +56005,24 @@ module.exports = { }, title: { - valType: 'string', - - editType: 'ticks', - + text: { + valType: 'string', + + editType: 'ticks', + + }, + font: fontAttrs({ + editType: 'ticks', + + }), + editType: 'ticks' }, - titlefont: fontAttrs({ - editType: 'ticks', - - }), type: { valType: 'enumerated', // '-' means we haven't yet run autotype or couldn't find any data // it gets turned into linear in gd._fullLayout but not copied back // to gd.data like the others are. - values: ['-', 'linear', 'log', 'date', 'category'], + values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', editType: 'calc', @@ -54785,6 +56151,14 @@ module.exports = { editType: 'ticks', + }, + tickson: { + valType: 'enumerated', + values: ['labels', 'boundaries'], + + dflt: 'labels', + editType: 'ticks', + }, mirror: { valType: 'enumerated', @@ -55038,6 +56412,30 @@ module.exports = { editType: 'ticks', }, + + showdividers: { + valType: 'boolean', + dflt: true, + + editType: 'ticks', + + }, + dividercolor: { + valType: 'color', + dflt: colorAttrs.defaultLine, + + editType: 'ticks', + + }, + dividerwidth: { + valType: 'number', + dflt: 1, + + editType: 'ticks', + + }, + // TODO dividerlen: that would override "to label base" length? + // positioning attributes // anchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -55119,6 +56517,12 @@ module.exports = { editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'calc', @@ -55128,11 +56532,21 @@ module.exports = { editType: 'ticks', - } + }, + title: { + valType: 'string', + + editType: 'ticks', + + }, + titlefont: fontAttrs({ + editType: 'ticks', + + }) } }; -},{"../../components/color/attributes":44,"../../components/drawing/attributes":69,"../../lib/extend":157,"../../plot_api/plot_template":200,"../font_attributes":237,"./constants":216}],224:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":44,"../../components/drawing/attributes":65,"../../lib/extend":155,"../../plot_api/plot_template":198,"../font_attributes":235,"./constants":214}],222:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55291,9 +56705,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; }); axLayoutOut._annIndices = []; axLayoutOut._shapeIndices = []; + axLayoutOut._subplotsWith = []; + axLayoutOut._counterAxes = []; // set up some private properties - axLayoutOut._name = axName; + axLayoutOut._name = axLayoutOut._attr = axName; var id = axLayoutOut._id = name2id(axName); var overlayableAxes = getOverlayableAxes(axLetter, axName); @@ -55311,6 +56727,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id] }; + coerce('uirevision', layoutOut.uirevision); + handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions); handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut); @@ -55372,11 +56790,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var anchoredAxis = layoutOut[id2name(axLayoutOut.anchor)]; - var fixedRangeDflt = ( - anchoredAxis && - anchoredAxis.rangeslider && - anchoredAxis.rangeslider.visible - ); + var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis); coerce('fixedrange', fixedRangeDflt); } @@ -55401,7 +56815,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } }; -},{"../../components/color":45,"../../lib":165,"../../plot_api/plot_template":200,"../../registry":259,"../layout_attributes":249,"./axis_defaults":212,"./axis_ids":213,"./constraint_defaults":217,"./layout_attributes":223,"./position_defaults":226,"./type_defaults":234}],225:[function(_dereq_,module,exports){ +},{"../../components/color":45,"../../lib":163,"../../plot_api/plot_template":198,"../../registry":257,"../layout_attributes":247,"./axis_defaults":210,"./axis_ids":211,"./constraint_defaults":215,"./layout_attributes":221,"./position_defaults":224,"./type_defaults":232}],223:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55466,7 +56880,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":44,"../../lib":165,"tinycolor2":27}],226:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":44,"../../lib":163,"tinycolor2":27}],224:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55550,7 +56964,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":165,"fast-isnumeric":11}],227:[function(_dereq_,module,exports){ +},{"../../lib":163,"fast-isnumeric":11}],225:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55578,7 +56992,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ]; }; -},{"../../constants/alignment":143}],228:[function(_dereq_,module,exports){ +},{"../../constants/alignment":140}],226:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56247,13 +57661,22 @@ function isOnlyOnePointSelected(searchTraces) { function updateSelectedState(gd, searchTraces, eventData) { var i, searchInfo, cd, trace; + // before anything else, update preGUI if necessary + for(i = 0; i < searchTraces.length; i++) { + var fullInputTrace = searchTraces[i].cd[0].trace._fullInput; + var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid]; + if(tracePreGUI.selectedpoints === undefined) { + tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null; + } + } + if(eventData) { var pts = eventData.points || []; for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; - trace.selectedpoints = []; - trace._input.selectedpoints = []; + trace._input.selectedpoints = trace._fullInput.selectedpoints = []; + if(trace._fullInput !== trace) trace.selectedpoints = []; } for(i = 0; i < pts.length; i++) { @@ -56263,10 +57686,14 @@ function updateSelectedState(gd, searchTraces, eventData) { if(pt.pointIndices) { [].push.apply(data.selectedpoints, pt.pointIndices); - [].push.apply(fullData.selectedpoints, pt.pointIndices); + if(trace._fullInput !== trace) { + [].push.apply(fullData.selectedpoints, pt.pointIndices); + } } else { data.selectedpoints.push(pt.pointIndex); - fullData.selectedpoints.push(pt.pointIndex); + if(trace._fullInput !== trace) { + fullData.selectedpoints.push(pt.pointIndex); + } } } } @@ -56275,6 +57702,9 @@ function updateSelectedState(gd, searchTraces, eventData) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; delete trace._input.selectedpoints; + if(trace._fullInput !== trace) { + delete trace._fullInput.selectedpoints; + } } } @@ -56352,7 +57782,7 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":45,"../../components/fx":87,"../../components/fx/helpers":84,"../../lib/clear_gl_canvases":152,"../../lib/polygon":177,"../../lib/throttle":187,"../../plot_api/subroutines":201,"../../registry":259,"./axis_ids":213,"./constants":216,"polybooljs":18}],229:[function(_dereq_,module,exports){ +},{"../../components/color":45,"../../components/fx":84,"../../components/fx/helpers":80,"../../lib/clear_gl_canvases":150,"../../lib/polygon":175,"../../lib/throttle":185,"../../plot_api/subroutines":199,"../../registry":257,"./axis_ids":211,"./constants":214,"polybooljs":18}],227:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56385,6 +57815,10 @@ function fromLog(v) { return Math.pow(10, v); } +function isValidCategory(v) { + return v !== null && v !== undefined; +} + /** * Define the conversion functions for an axis data is used in 5 ways: * @@ -56478,7 +57912,7 @@ module.exports = function setConvert(ax, fullLayout) { * a disconnect between the array and the index returned */ function setCategoryIndex(v) { - if(v !== null && v !== undefined) { + if(isValidCategory(v)) { if(ax._categoriesMap === undefined) { ax._categoriesMap = {}; } @@ -56497,14 +57931,58 @@ module.exports = function setConvert(ax, fullLayout) { return BADNUM; } + function setMultiCategoryIndex(arrayIn, len) { + var arrayOut = new Array(len); + var i; + + // [ [arrayIn[0][i], arrayIn[1][i]], for i .. len ] + var tmp = new Array(len); + // [ [cnt, {$cat: index}], for j .. arrayIn.length ] + var seen = [[0, {}], [0, {}]]; + + if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) { + for(i = 0; i < len; i++) { + var v0 = arrayIn[0][i]; + var v1 = arrayIn[1][i]; + if(isValidCategory(v0) && isValidCategory(v1)) { + tmp[i] = [v0, v1]; + if(!(v0 in seen[0][1])) { + seen[0][1][v0] = seen[0][0]++; + } + if(!(v1 in seen[1][1])) { + seen[1][1][v1] = seen[1][0]++; + } + } + } + + tmp.sort(function(a, b) { + var ind0 = seen[0][1]; + var d = ind0[a[0]] - ind0[b[0]]; + if(d) return d; + + var ind1 = seen[1][1]; + return ind1[a[1]] - ind1[b[1]]; + }); + } + + for(i = 0; i < len; i++) { + arrayOut[i] = setCategoryIndex(tmp[i]); + } + + return arrayOut; + } + function getCategoryIndex(v) { - // d2l/d2c variant that that won't add categories but will also - // allow numbers to be mapped to the linearized axis positions if(ax._categoriesMap) { - var index = ax._categoriesMap[v]; - if(index !== undefined) return index; + return ax._categoriesMap[v]; } + } + function getCategoryPosition(v) { + // d2l/d2c variant that that won't add categories but will also + // allow numbers to be mapped to the linearized axis positions + var index = getCategoryIndex(v); + if(index !== undefined) return index; if(isNumeric(v)) return +v; } @@ -56590,15 +58068,15 @@ module.exports = function setConvert(ax, fullLayout) { ax.d2c = ax.d2l = setCategoryIndex; ax.r2d = ax.c2d = ax.l2d = getCategoryName; - ax.d2r = ax.d2l_noadd = getCategoryIndex; + ax.d2r = ax.d2l_noadd = getCategoryPosition; ax.r2c = function(v) { - var index = getCategoryIndex(v); + var index = getCategoryPosition(v); return index !== undefined ? index : ax.fraction2r(0.5); }; ax.l2r = ax.c2r = ensureNumber; - ax.r2l = getCategoryIndex; + ax.r2l = getCategoryPosition; ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; ax.p2d = function(px) { return getCategoryName(p2l(px)); }; @@ -56610,6 +58088,34 @@ module.exports = function setConvert(ax, fullLayout) { return ensureNumber(v); }; } + else if(ax.type === 'multicategory') { + // N.B. multicategory axes don't define d2c and d2l, + // as 'data-to-calcdata' conversion needs to take into + // account all data array items as in ax.makeCalcdata. + + ax.r2d = ax.c2d = ax.l2d = getCategoryName; + ax.d2r = ax.d2l_noadd = getCategoryPosition; + + ax.r2c = function(v) { + var index = getCategoryPosition(v); + return index !== undefined ? index : ax.fraction2r(0.5); + }; + + ax.r2c_just_indices = getCategoryIndex; + + ax.l2r = ax.c2r = ensureNumber; + ax.r2l = getCategoryPosition; + + ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; + ax.p2d = function(px) { return getCategoryName(p2l(px)); }; + ax.r2p = ax.d2p; + ax.p2r = p2l; + + ax.cleanPos = function(v) { + if(Array.isArray(v) || (typeof v === 'string' && v !== '')) return v; + return ensureNumber(v); + }; + } // find the range value at the specified (linear) fraction of the axis ax.fraction2r = function(v) { @@ -56703,11 +58209,6 @@ module.exports = function setConvert(ax, fullLayout) { ax.setScale = function(usePrivateRange) { var gs = fullLayout._size; - // TODO cleaner way to handle this case - if(!ax._categories) ax._categories = []; - // Add a map to optimize the performance of category collection - if(!ax._categoriesMap) ax._categoriesMap = {}; - // make sure we have a domain (pull it in from the axis // this one is overlaying if necessary) if(ax.overlaying) { @@ -56762,7 +58263,7 @@ module.exports = function setConvert(ax, fullLayout) { if(axLetter in trace) { arrayIn = trace[axLetter]; - len = trace._length || arrayIn.length; + len = trace._length || Lib.minRowLength(arrayIn); if(Lib.isTypedArray(arrayIn) && (axType === 'linear' || axType === 'log')) { if(len === arrayIn.length) { @@ -56772,6 +58273,10 @@ module.exports = function setConvert(ax, fullLayout) { } } + if(axType === 'multicategory') { + return setMultiCategoryIndex(arrayIn, len); + } + arrayOut = new Array(len); for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); @@ -56848,7 +58353,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":145,"../../lib":165,"./axis_ids":213,"./constants":216,"d3":9,"fast-isnumeric":11}],230:[function(_dereq_,module,exports){ +},{"../../constants/numerical":142,"../../lib":163,"./axis_ids":211,"./constants":214,"d3":9,"fast-isnumeric":11}],228:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56949,7 +58454,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../lib":165,"../array_container_defaults":206,"./layout_attributes":223}],231:[function(_dereq_,module,exports){ +},{"../../lib":163,"../array_container_defaults":204,"./layout_attributes":221}],229:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56982,7 +58487,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":165,"./layout_attributes":223}],232:[function(_dereq_,module,exports){ +},{"../../lib":163,"./layout_attributes":221}],230:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56991,22 +58496,18 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); - module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { var tickmode; if(containerIn.tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; - } - else { - var tickmodeDefault = - Array.isArray(containerIn.tickvals) ? 'array' : + } else { + var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : containerIn.dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); @@ -57021,15 +58522,14 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe containerIn.dtick, axType); containerOut.tick0 = cleanTicks.tick0( containerIn.tick0, axType, containerOut.calendar, dtick); - } - else { + } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto'; else coerce('ticktext'); } }; -},{"./clean_ticks":215}],233:[function(_dereq_,module,exports){ +},{"./clean_ticks":213}],231:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57151,14 +58651,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo } function ticksAndAnnotations(xa, ya) { - var activeAxIds = [], - i; - - activeAxIds = [xa._id, ya._id]; + var activeAxIds = [xa._id, ya._id]; + var i; - for(i = 0; i < activeAxIds.length; i++) { - Axes.doTicksSingle(gd, activeAxIds[i], true); - } + Axes.drawOne(gd, xa, {skipTitle: true}); + Axes.drawOne(gd, ya, {skipTitle: true}); function redrawObjs(objArray, method, shortCircuit) { for(i = 0; i < objArray.length; i++) { @@ -57357,7 +58854,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo return Promise.resolve(); }; -},{"../../components/drawing":70,"../../registry":259,"./axes":210,"./constants":216,"d3":9}],234:[function(_dereq_,module,exports){ +},{"../../components/drawing":66,"../../registry":257,"./axes":208,"./constants":214,"d3":9}],232:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57368,7 +58865,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo 'use strict'; -var Registry = _dereq_('../../registry'); +var traceIs = _dereq_('../../registry').traceIs; var autoType = _dereq_('./axis_autotype'); /* @@ -57417,6 +58914,7 @@ function setAutoType(ax, data) { var calAttr = axLetter + 'calendar'; var calendar = d0[calAttr]; + var opts = {noMultiCategory: !traceIs(d0, 'cartesian') || traceIs(d0, 'noMultiCategory')}; var i; // check all boxes on this x axis to see @@ -57427,8 +58925,7 @@ function setAutoType(ax, data) { for(i = 0; i < data.length; i++) { var trace = data[i]; - if(!Registry.traceIs(trace, 'box-violin') || - (trace[axLetter + 'axis'] || axLetter) !== id) continue; + if(!traceIs(trace, 'box-violin') || (trace[axLetter + 'axis'] || axLetter) !== id) continue; if(trace[posLetter] !== undefined) boxPositions.push(trace[posLetter][0]); else if(trace.name !== undefined) boxPositions.push(trace.name); @@ -57437,7 +58934,7 @@ function setAutoType(ax, data) { if(trace[calAttr] !== calendar) calendar = undefined; } - ax.type = autoType(boxPositions, calendar); + ax.type = autoType(boxPositions, calendar, opts); } else if(d0.type === 'splom') { var dimensions = d0.dimensions; @@ -57445,13 +58942,13 @@ function setAutoType(ax, data) { for(i = 0; i < dimensions.length; i++) { var dim = dimensions[i]; if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) { - ax.type = autoType(dim.values, calendar); + ax.type = autoType(dim.values, calendar, opts); break; } } } else { - ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar); + ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -57482,9 +58979,9 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace), - isBox = Registry.traceIs(trace, 'box-violin'), - isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); + var posLetter = getBoxPosLetter(trace); + var isBox = traceIs(trace, 'box-violin'); + var isCandlestick = traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox && @@ -57495,7 +58992,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":259,"./axis_autotype":211}],235:[function(_dereq_,module,exports){ +},{"../../registry":257,"./axis_autotype":209}],233:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57919,7 +59416,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":165,"../registry":259}],236:[function(_dereq_,module,exports){ +},{"../lib":163,"../registry":257}],234:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58027,7 +59524,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { coerce('domain.y', dfltY); }; -},{"../lib/extend":157}],237:[function(_dereq_,module,exports){ +},{"../lib/extend":155}],235:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58092,7 +59589,7 @@ module.exports = function(opts) { return attrs; }; -},{}],238:[function(_dereq_,module,exports){ +},{}],236:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58138,7 +59635,7 @@ module.exports = { } }; -},{}],239:[function(_dereq_,module,exports){ +},{}],237:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58313,7 +59810,7 @@ exports.layerNameToAdjective = { frame: 'frame' }; -},{}],240:[function(_dereq_,module,exports){ +},{}],238:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58683,7 +60180,7 @@ proto.updateFx = function(fullLayout, geoLayout) { updateObj[_this.id + '.' + k] = viewInitial[k]; } - Registry.call('relayout', gd, updateObj); + Registry.call('_guiRelayout', gd, updateObj); gd.emit('plotly_doubleclick', null); } @@ -58786,7 +60283,8 @@ proto.updateFx = function(fullLayout, geoLayout) { proto.makeFramework = function() { var _this = this; - var fullLayout = _this.graphDiv._fullLayout; + var gd = _this.graphDiv; + var fullLayout = gd._fullLayout; var clipId = 'clip' + fullLayout._uid + _this.id; _this.clipDef = fullLayout._clips.append('clipPath') @@ -58796,7 +60294,7 @@ proto.makeFramework = function() { _this.framework = d3.select(_this.container).append('g') .attr('class', 'geo ' + _this.id) - .call(Drawing.setClipUrl, clipId); + .call(Drawing.setClipUrl, clipId, gd); // sane lonlat to px _this.project = function(v) { @@ -59022,7 +60520,7 @@ function makeRangeBox(lon, lat) { }; } -},{"../../components/color":45,"../../components/dragelement":67,"../../components/drawing":70,"../../components/fx":87,"../../lib":165,"../../lib/topojson_utils":189,"../../registry":259,"../cartesian/axes":210,"../cartesian/select":228,"../plots":251,"./constants":239,"./projections":245,"./zoom":246,"d3":9,"topojson-client":28}],241:[function(_dereq_,module,exports){ +},{"../../components/color":45,"../../components/dragelement":63,"../../components/drawing":66,"../../components/fx":84,"../../lib":163,"../../lib/topojson_utils":187,"../../registry":257,"../cartesian/axes":208,"../cartesian/select":226,"../plots":249,"./constants":237,"./projections":243,"./zoom":244,"d3":9,"topojson-client":28}],239:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59114,7 +60612,7 @@ exports.updateFx = function(gd) { } }; -},{"../../lib":165,"../../plots/get_data":247,"./geo":240,"./layout/attributes":242,"./layout/defaults":243,"./layout/layout_attributes":244}],242:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../plots/get_data":245,"./geo":238,"./layout/attributes":240,"./layout/defaults":241,"./layout/layout_attributes":242}],240:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59136,7 +60634,7 @@ module.exports = { } }; -},{}],243:[function(_dereq_,module,exports){ +},{}],241:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59300,7 +60798,7 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce) { coerce('bgcolor'); } -},{"../../subplot_defaults":258,"../constants":239,"./layout_attributes":244}],244:[function(_dereq_,module,exports){ +},{"../../subplot_defaults":256,"../constants":237,"./layout_attributes":242}],242:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59357,7 +60855,7 @@ var geoAxesAttrs = { } }; -module.exports = overrideAll({ +var attrs = module.exports = overrideAll({ domain: domainAttrs({name: 'geo'}, { }), @@ -59567,7 +61065,15 @@ module.exports = overrideAll({ lataxis: geoAxesAttrs }, 'plot', 'from-root'); -},{"../../../components/color/attributes":44,"../../../plot_api/edit_types":193,"../../domain":236,"../constants":239}],245:[function(_dereq_,module,exports){ +// set uirevision outside of overrideAll so it can be `editType: 'none'` +attrs.uirevision = { + valType: 'any', + + editType: 'none', + +}; + +},{"../../../components/color/attributes":44,"../../../plot_api/edit_types":191,"../../domain":234,"../constants":237}],243:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60013,7 +61519,7 @@ function addProjectionsToD3(d3) { module.exports = addProjectionsToD3; -},{}],246:[function(_dereq_,module,exports){ +},{}],244:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60027,6 +61533,7 @@ module.exports = addProjectionsToD3; var d3 = _dereq_('d3'); var Lib = _dereq_('../../lib'); +var Registry = _dereq_('../../registry'); var radians = Math.PI / 180; var degrees = 180 / Math.PI; @@ -60063,8 +61570,10 @@ function initZoom(geo, projection) { function sync(geo, projection, cb) { var id = geo.id; var gd = geo.graphDiv; - var userOpts = gd.layout[id]; - var fullOpts = gd._fullLayout[id]; + var layout = gd.layout; + var userOpts = layout[id]; + var fullLayout = gd._fullLayout; + var fullOpts = fullLayout[id]; var eventData = {}; @@ -60080,6 +61589,7 @@ function sync(geo, projection, cb) { cb(set); set('projection.scale', projection.scale() / geo.fitScale); + Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, eventData); gd.emit('plotly_relayout', eventData); } @@ -60487,7 +61997,7 @@ function d3_eventDispatch(target) { return dispatch; } -},{"../../lib":165,"d3":9}],247:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../registry":257,"d3":9}],245:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60615,7 +62125,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":259,"./cartesian/constants":216}],248:[function(_dereq_,module,exports){ +},{"../registry":257,"./cartesian/constants":214}],246:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60649,7 +62159,7 @@ function project(camera, v) { module.exports = project; -},{}],249:[function(_dereq_,module,exports){ +},{}],247:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60662,6 +62172,9 @@ module.exports = project; var fontAttrs = _dereq_('./font_attributes'); var colorAttrs = _dereq_('../components/color/attributes'); +var colorscaleAttrs = _dereq_('../components/colorscale/layout_attributes'); +var padAttrs = _dereq_('./pad_attributes'); +var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', @@ -60674,15 +62187,71 @@ globalFont.color.dflt = colorAttrs.defaultLine; module.exports = { font: globalFont, title: { - valType: 'string', - - editType: 'layoutstyle', - + text: { + valType: 'string', + + editType: 'layoutstyle', + + }, + font: fontAttrs({ + editType: 'layoutstyle', + + }), + xref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + yref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + x: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.5, + + editType: 'layoutstyle', + + }, + y: { + valType: 'number', + min: 0, + max: 1, + dflt: 'auto', + + editType: 'layoutstyle', + + }, + xanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'left', 'center', 'right'], + + editType: 'layoutstyle', + + }, + yanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'top', 'middle', 'bottom'], + + editType: 'layoutstyle', + + }, + pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { + + }), + editType: 'layoutstyle' }, - titlefont: fontAttrs({ - editType: 'layoutstyle', - - }), autosize: { valType: 'boolean', @@ -60801,11 +62370,30 @@ module.exports = { editType: 'calc', }, + colorscale: colorscaleAttrs, datarevision: { valType: 'any', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editrevision: { + valType: 'any', + + editType: 'none', + + }, + selectionrevision: { + valType: 'any', + + editType: 'none', + }, template: { valType: 'any', @@ -60839,12 +62427,30 @@ module.exports = { editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'modebar' + }, + _deprecated: { + title: { + valType: 'string', + + editType: 'layoutstyle', + + }, + titlefont: fontAttrs({ + editType: 'layoutstyle', + + }) } }; -},{"../components/color/attributes":44,"./font_attributes":237}],250:[function(_dereq_,module,exports){ +},{"../components/color/attributes":44,"../components/colorscale/layout_attributes":58,"../lib/extend":155,"./font_attributes":235,"./pad_attributes":248}],248:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60855,42 +62461,51 @@ module.exports = { 'use strict'; -// This is used exclusively by components inside component arrays, -// hence the 'arraydraw' editType. If this ever gets used elsewhere -// we could generalize it as a function ala font_attributes -module.exports = { - t: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - r: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - b: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - l: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - editType: 'arraydraw' +/** + * Creates a set of padding attributes. + * + * @param {object} opts + * @param {string} editType: + * the editType for all pieces of this padding definition + * + * @return {object} attributes object containing {t, r, b, l} as specified + */ +module.exports = function(opts) { + var editType = opts.editType; + return { + t: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + r: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + b: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + l: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + editType: editType + }; }; -},{}],251:[function(_dereq_,module,exports){ +},{}],249:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61342,6 +62957,7 @@ plots.supplyDefaults = function(gd, opts) { for(i = 0; i < crossTraceDefaultsFuncs.length; i++) { crossTraceDefaultsFuncs[i](newFullData, newFullLayout); } + Registry.getComponentMethod('colorscale', 'crossTraceDefaults')(newFullData, newFullLayout); // turn on flag to optimize large splom-only graphs // mostly by omitting SVG layers during Cartesian.drawFramework @@ -61372,15 +62988,29 @@ plots.supplyDefaults = function(gd, opts) { // relink functions and _ attributes to promote consistency between plots relinkPrivateKeys(newFullLayout, oldFullLayout); - // TODO may return a promise - plots.doAutoMargin(gd); - - // set scale after auto margin routine - var axList = axisIDs.list(gd); - for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - ax.setScale(); + // For persisting GUI-driven changes in layout + // _preGUI and _tracePreGUI were already copied over in relinkPrivateKeys + if(!newFullLayout._preGUI) newFullLayout._preGUI = {}; + // track trace GUI changes by uid rather than by trace index + if(!newFullLayout._tracePreGUI) newFullLayout._tracePreGUI = {}; + var tracePreGUI = newFullLayout._tracePreGUI; + var uids = {}; + var uid; + for(uid in tracePreGUI) uids[uid] = 'old'; + for(i = 0; i < newFullData.length; i++) { + uid = newFullData[i]._fullInput.uid; + if(!uids[uid]) tracePreGUI[uid] = {}; + uids[uid] = 'new'; } + for(uid in uids) { + if(uids[uid] === 'old') delete tracePreGUI[uid]; + } + + // set up containers for margin calculations + initMargins(newFullLayout); + + // collect and do some initial calculations for rangesliders + Registry.getComponentMethod('rangeslider', 'makeData')(newFullLayout); // update object references in calcdata if(!skipUpdateCalc && oldCalcdata.length === newFullData.length) { @@ -61690,6 +63320,12 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa plotinfo.id = id; } + // add these axis ids to each others' subplot lists + xaxis._counterAxes.push(yaxis._id); + yaxis._counterAxes.push(xaxis._id); + xaxis._subplotsWith.push(id); + yaxis._subplotsWith.push(id); + // update x and y axis layout object refs plotinfo.xaxis = xaxis; plotinfo.yaxis = yaxis; @@ -61717,8 +63353,9 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // while we're at it, link overlaying axes to their main axes and // anchored axes to the axes they're anchored to var axList = axisIDs.list(mockGd, null, true); + var ax; for(i = 0; i < axList.length; i++) { - var ax = axList[i]; + ax = axList[i]; var mainAx = null; if(ax.overlaying) { @@ -61746,8 +63383,53 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa null : axisIDs.getFromId(mockGd, ax.anchor); } + + // finally, we can find the main subplot for each axis + // (on which the ticks & labels are drawn) + for(i = 0; i < axList.length; i++) { + ax = axList[i]; + ax._counterAxes.sort(axisIDs.idSort); + ax._subplotsWith.sort(Lib.subplotSort); + ax._mainSubplot = findMainSubplot(ax, newFullLayout); + } }; +function findMainSubplot(ax, fullLayout) { + var mockGd = {_fullLayout: fullLayout}; + + var isX = ax._id.charAt(0) === 'x'; + var anchorAx = ax._mainAxis._anchorAxis; + var mainSubplotID = ''; + var nextBestMainSubplotID = ''; + var anchorID = ''; + + // First try the main ID with the anchor + if(anchorAx) { + anchorID = anchorAx._mainAxis._id; + mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); + } + + // Then look for a subplot with the counteraxis overlaying the anchor + // If that fails just use the first subplot including this axis + if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { + mainSubplotID = ''; + + var counterIDs = ax._counterAxes; + for(var j = 0; j < counterIDs.length; j++) { + var counterPart = counterIDs[j]; + var id = isX ? (ax._id + counterPart) : (counterPart + ax._id); + if(!nextBestMainSubplotID) nextBestMainSubplotID = id; + var counterAx = axisIDs.getFromId(mockGd, counterPart); + if(anchorID && counterAx.overlaying === anchorID) { + mainSubplotID = id; + break; + } + } + } + + return mainSubplotID || nextBestMainSubplotID; +} + // This function clears any trace attributes with valType: color and // no set dflt filed in the plot schema. This is needed because groupby (which // is the only transform for which this currently applies) supplies parent @@ -62015,6 +63697,8 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac coerce('type'); coerce('name', layout._traceWord + ' ' + traceInIndex); + coerce('uirevision', layout.uirevision); + // we want even invisible traces to make their would-be subplots visible // so coerce the subplot id(s) now no matter what var _module = plots.getModule(traceOut); @@ -62088,7 +63772,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac if(_module) { _module.supplyDefaults(traceIn, traceOut, defaultColor, layout); - Lib.coerceHoverinfo(traceIn, traceOut, layout); + if(!traceOut.hovertemplate) Lib.coerceHoverinfo(traceIn, traceOut, layout); } if(!Registry.traceIs(traceOut, 'noOpacity')) coerce('opacity'); @@ -62217,14 +63901,25 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { var globalFont = Lib.coerceFont(coerce, 'font'); - coerce('title', layoutOut._dfltTitle.plot); + coerce('title.text', layoutOut._dfltTitle.plot); - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: globalFont.family, size: Math.round(globalFont.size * 1.4), color: globalFont.color }); + coerce('title.xref'); + coerce('title.yref'); + coerce('title.x'); + coerce('title.y'); + coerce('title.xanchor'); + coerce('title.yanchor'); + coerce('title.pad.t'); + coerce('title.pad.r'); + coerce('title.pad.b'); + coerce('title.pad.l'); + // Make sure that autosize is defaulted to *true* // on layouts with no set width and height for backward compatibly, // in particular https://plot.ly/javascript/responsive-fluid-layout/ @@ -62257,12 +63952,16 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('colorway'); coerce('datarevision'); + var uirevision = coerce('uirevision'); + coerce('editrevision', uirevision); + coerce('selectionrevision', uirevision); coerce('modebar.orientation'); coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); + coerce('modebar.uirevision', uirevision); Registry.getComponentMethod( 'calendars', @@ -62544,7 +64243,20 @@ plots.allowAutoMargin = function(gd, id) { gd._fullLayout._pushmarginIds[id] = 1; }; -function setupAutoMargin(fullLayout) { +function initMargins(fullLayout) { + var margin = fullLayout.margin; + + if(!fullLayout._size) { + var gs = fullLayout._size = { + l: Math.round(margin.l), + r: Math.round(margin.r), + t: Math.round(margin.t), + b: Math.round(margin.b), + p: Math.round(margin.pad) + }; + gs.w = Math.round(fullLayout.width) - gs.l - gs.r; + gs.h = Math.round(fullLayout.height) - gs.t - gs.b; + } if(!fullLayout._pushmargin) fullLayout._pushmargin = {}; if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {}; } @@ -62567,8 +64279,6 @@ function setupAutoMargin(fullLayout) { plots.autoMargin = function(gd, id, o) { var fullLayout = gd._fullLayout; - setupAutoMargin(fullLayout); - var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -62612,18 +64322,19 @@ plots.autoMargin = function(gd, id, o) { plots.doAutoMargin = function(gd) { var fullLayout = gd._fullLayout; if(!fullLayout._size) fullLayout._size = {}; - setupAutoMargin(fullLayout); + initMargins(fullLayout); - var gs = fullLayout._size, - oldmargins = JSON.stringify(gs); + var gs = fullLayout._size; + var oldmargins = JSON.stringify(gs); + var margin = fullLayout.margin; // adjust margins for outside components // fullLayout.margin is the requested margin, // fullLayout._size has margins and plotsize after adjustment - var ml = Math.max(fullLayout.margin.l || 0, 0); - var mr = Math.max(fullLayout.margin.r || 0, 0); - var mt = Math.max(fullLayout.margin.t || 0, 0); - var mb = Math.max(fullLayout.margin.b || 0, 0); + var ml = margin.l; + var mr = margin.r; + var mt = margin.t; + var mb = margin.b; var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -62693,7 +64404,7 @@ plots.doAutoMargin = function(gd) { gs.r = Math.round(mr); gs.t = Math.round(mt); gs.b = Math.round(mb); - gs.p = Math.round(fullLayout.margin.pad); + gs.p = Math.round(margin.pad); gs.w = Math.round(fullLayout.width) - gs.l - gs.r; gs.h = Math.round(fullLayout.height) - gs.t - gs.b; @@ -63574,7 +65285,7 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl subplot.traceHash = traceHash; }; -},{"../components/color":45,"../constants/numerical":145,"../lib":165,"../plot_api/plot_schema":199,"../plot_api/plot_template":200,"../plots/cartesian/axis_ids":213,"../registry":259,"./animation_attributes":205,"./attributes":207,"./command":235,"./font_attributes":237,"./frame_attributes":238,"./layout_attributes":249,"d3":9,"fast-isnumeric":11}],252:[function(_dereq_,module,exports){ +},{"../components/color":45,"../constants/numerical":142,"../lib":163,"../plot_api/plot_schema":197,"../plot_api/plot_template":198,"../plots/cartesian/axis_ids":211,"../registry":257,"./animation_attributes":203,"./attributes":205,"./command":233,"./font_attributes":235,"./frame_attributes":236,"./layout_attributes":247,"d3":9,"fast-isnumeric":11}],250:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63618,7 +65329,7 @@ module.exports = { } }; -},{"../../../lib/extend":157,"../../../traces/scatter/attributes":281}],253:[function(_dereq_,module,exports){ +},{"../../../lib/extend":155,"../../../traces/scatter/attributes":279}],251:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63740,7 +65451,7 @@ module.exports = overrideAll({ } }, 'plot', 'nested'); -},{"../../../lib/extend":157,"../../../plot_api/edit_types":193,"../../cartesian/layout_attributes":223}],254:[function(_dereq_,module,exports){ +},{"../../../lib/extend":155,"../../../plot_api/edit_types":191,"../../cartesian/layout_attributes":221}],252:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63755,7 +65466,7 @@ var Polar = module.exports = _dereq_('./micropolar'); Polar.manager = _dereq_('./micropolar_manager'); -},{"./micropolar":255,"./micropolar_manager":256}],255:[function(_dereq_,module,exports){ +},{"./micropolar":253,"./micropolar_manager":254}],253:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63973,8 +65684,8 @@ var µ = module.exports = { version: '0.2.2' }; centeringOffset[0] = Math.max(0, centeringOffset[0]); centeringOffset[1] = Math.max(0, centeringOffset[1]); svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title); + if (axisConfig.title && axisConfig.title.text) { + var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); var titleBBox = title.node().getBBox(); title.attr({ x: chartCenter[0] - titleBBox.width / 2, @@ -65175,7 +66886,7 @@ var µ = module.exports = { version: '0.2.2' }; return exports; }; -},{"../../../constants/alignment":143,"../../../lib":165,"d3":9}],256:[function(_dereq_,module,exports){ +},{"../../../constants/alignment":140,"../../../lib":163,"d3":9}],254:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65261,7 +66972,7 @@ manager.fillLayout = function(_gd) { _gd._fullLayout = extendDeepAll(dflts, _gd.layout); }; -},{"../../../components/color":45,"../../../lib":165,"./micropolar":255,"./undo_manager":257,"d3":9}],257:[function(_dereq_,module,exports){ +},{"../../../components/color":45,"../../../lib":163,"./micropolar":253,"./undo_manager":255,"d3":9}],255:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65327,7 +67038,7 @@ module.exports = function UndoManager() { }; }; -},{}],258:[function(_dereq_,module,exports){ +},{}],256:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65397,6 +67108,12 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o subplotLayoutOut = Template.newContainer(layoutOut, id, baseId); + // All subplot containers get a `uirevision` inheriting from the base. + // Currently all subplots containers have some user interaction + // attributes, but if we ever add one that doesn't, we would need an + // option to skip this step. + coerce('uirevision', layoutOut.uirevision); + var dfltDomains = {}; dfltDomains[partition] = [i / idsLength, (i + 1) / idsLength]; handleDomainDefaults(subplotLayoutOut, layoutOut, coerce, dfltDomains); @@ -65406,7 +67123,7 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o } }; -},{"../lib":165,"../plot_api/plot_template":200,"./domain":236}],259:[function(_dereq_,module,exports){ +},{"../lib":163,"../plot_api/plot_template":198,"./domain":234}],257:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65848,7 +67565,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/extend":157,"./lib/is_plain_object":166,"./lib/loggers":169,"./lib/noop":174,"./lib/push_unique":178,"./plots/attributes":207,"./plots/layout_attributes":249}],260:[function(_dereq_,module,exports){ +},{"./lib/extend":155,"./lib/is_plain_object":164,"./lib/loggers":167,"./lib/noop":172,"./lib/push_unique":176,"./plots/attributes":205,"./plots/layout_attributes":247}],258:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65875,7 +67592,7 @@ function cloneLayoutOverride(tileClass) { autosize: true, width: 150, height: 150, - title: '', + title: {text: ''}, showlegend: false, margin: {l: 5, r: 5, t: 5, b: 5, pad: 0}, annotations: [] @@ -65884,7 +67601,7 @@ function cloneLayoutOverride(tileClass) { case 'thumbnail': override = { - title: '', + title: {text: ''}, hidesources: true, showlegend: false, borderwidth: 0, @@ -65932,7 +67649,7 @@ module.exports = function clonePlot(graphObj, options) { for(i = 0; i < keys.length; i++) { if(keyIsAxis(keys[i])) { - newLayout[keys[i]].title = ''; + newLayout[keys[i]].title = {text: ''}; } } @@ -65960,7 +67677,7 @@ module.exports = function clonePlot(graphObj, options) { var axesImageOverride = {}; if(options.tileClass === 'thumbnail') { axesImageOverride = { - title: '', + title: {text: ''}, showaxeslabels: false, showticklabels: false, linetickenable: false @@ -66022,7 +67739,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":165}],261:[function(_dereq_,module,exports){ +},{"../lib":163}],259:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66090,7 +67807,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":165,"../plot_api/to_image":203,"./filesaver":262}],262:[function(_dereq_,module,exports){ +},{"../lib":163,"../plot_api/to_image":201,"./filesaver":260}],260:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66162,7 +67879,7 @@ var fileSaver = function(url, name) { module.exports = fileSaver; -},{}],263:[function(_dereq_,module,exports){ +},{}],261:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66199,7 +67916,7 @@ exports.getRedrawFunc = function(gd) { }; }; -},{}],264:[function(_dereq_,module,exports){ +},{}],262:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66225,7 +67942,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":260,"./download":261,"./helpers":263,"./svgtoimg":265,"./toimage":266,"./tosvg":267}],265:[function(_dereq_,module,exports){ +},{"./cloneplot":258,"./download":259,"./helpers":261,"./svgtoimg":263,"./toimage":264,"./tosvg":265}],263:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66341,7 +68058,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":165,"events":7}],266:[function(_dereq_,module,exports){ +},{"../lib":163,"events":7}],264:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66420,7 +68137,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":165,"../registry":259,"./cloneplot":260,"./helpers":263,"./svgtoimg":265,"./tosvg":267,"events":7}],267:[function(_dereq_,module,exports){ +},{"../lib":163,"../registry":257,"./cloneplot":258,"./helpers":261,"./svgtoimg":263,"./tosvg":265,"events":7}],265:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66602,7 +68319,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":45,"../components/drawing":70,"../constants/xmlns_namespaces":146,"../lib":165,"d3":9}],268:[function(_dereq_,module,exports){ +},{"../components/color":45,"../components/drawing":66,"../constants/xmlns_namespaces":143,"../lib":163,"d3":9}],266:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66684,7 +68401,7 @@ module.exports = extendFlat({ {colorbar: colorbarAttrs} ); -},{"../../components/colorbar/attributes":46,"../../components/colorscale/attributes":52,"../../lib/extend":157,"../../plots/attributes":207,"../scattergeo/attributes":308}],269:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":46,"../../components/colorscale/attributes":52,"../../lib/extend":155,"../../plots/attributes":205,"../scattergeo/attributes":306}],267:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66717,13 +68434,17 @@ module.exports = function calc(gd, trace) { } arraysToCalcdata(calcTrace, trace); - colorscaleCalc(trace, trace.z, '', 'z'); + colorscaleCalc(gd, trace, { + vals: trace.z, + containerStr: '', + cLetter: 'z' + }); calcSelection(calcTrace, trace); return calcTrace; }; -},{"../../components/colorscale/calc":53,"../../constants/numerical":145,"../scatter/arrays_to_calcdata":280,"../scatter/calc_selection":283,"fast-isnumeric":11}],270:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":53,"../../constants/numerical":142,"../scatter/arrays_to_calcdata":278,"../scatter/calc_selection":281,"fast-isnumeric":11}],268:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66768,7 +68489,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/colorscale/defaults":55,"../../lib":165,"./attributes":268}],271:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":55,"../../lib":163,"./attributes":266}],269:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66787,7 +68508,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],272:[function(_dereq_,module,exports){ +},{}],270:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66877,7 +68598,7 @@ function makeHoverInfo(pointData, trace, pt, axis) { pointData.extraText = text.join('
'); } -},{"../../plots/cartesian/axes":210,"../scatter/fill_hover_text":289,"./attributes":268}],273:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":208,"../scatter/fill_hover_text":287,"./attributes":266}],271:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66912,7 +68633,7 @@ Choropleth.meta = { module.exports = Choropleth; -},{"../../plots/geo":241,"../heatmap/colorbar":277,"./attributes":268,"./calc":269,"./defaults":270,"./event_data":271,"./hover":272,"./plot":274,"./select":275,"./style":276}],274:[function(_dereq_,module,exports){ +},{"../../plots/geo":239,"../heatmap/colorbar":275,"./attributes":266,"./calc":267,"./defaults":268,"./event_data":269,"./hover":270,"./plot":272,"./select":273,"./style":274}],272:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67080,7 +68801,7 @@ function feature2polygons(feature) { return polygons; } -},{"../../lib":165,"../../lib/geo_location_utils":160,"../../lib/polygon":177,"../../lib/topojson_utils":189,"./style":276,"d3":9}],275:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../lib/geo_location_utils":158,"../../lib/polygon":175,"../../lib/topojson_utils":187,"./style":274,"d3":9}],273:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67129,7 +68850,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],276:[function(_dereq_,module,exports){ +},{}],274:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67157,11 +68878,7 @@ function styleTrace(gd, calcTrace) { var markerLine = marker.line || {}; var sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - trace.colorscale, - trace.zmin, - trace.zmax - ) + Colorscale.extractScale(trace, {cLetter: 'z'}) ); locs.each(function(d) { @@ -67191,7 +68908,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/color":45,"../../components/colorscale":60,"../../components/drawing":70,"d3":9}],277:[function(_dereq_,module,exports){ +},{"../../components/color":45,"../../components/colorscale":57,"../../components/drawing":66,"d3":9}],275:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67207,7 +68924,7 @@ module.exports = { max: 'zmax' }; -},{}],278:[function(_dereq_,module,exports){ +},{}],276:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67249,7 +68966,7 @@ exports.castOption = function castOption(item, indices) { else if(item) return item; }; -},{"../../lib":165}],279:[function(_dereq_,module,exports){ +},{"../../lib":163}],277:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67273,7 +68990,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":45,"./helpers":278}],280:[function(_dereq_,module,exports){ +},{"../../components/color":45,"./helpers":276}],278:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67325,7 +69042,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":165}],281:[function(_dereq_,module,exports){ +},{"../../lib":163}],279:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67336,6 +69053,7 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -67447,6 +69165,9 @@ module.exports = { editType: 'style', }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), line: { color: { valType: 'color', @@ -67721,7 +69442,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":46,"../../components/colorscale/attributes":52,"../../components/drawing":70,"../../components/drawing/attributes":69,"../../lib/extend":157,"../../plots/font_attributes":237,"./constants":285}],282:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":46,"../../components/colorscale/attributes":52,"../../components/drawing":66,"../../components/drawing/attributes":65,"../../components/fx/hovertemplate_attributes":83,"../../lib/extend":155,"../../plots/font_attributes":235,"./constants":283}],280:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67811,7 +69532,7 @@ function calc(gd, trace) { } arraysToCalcdata(cd, trace); - calcColorscale(trace); + calcColorscale(gd, trace); calcSelection(cd, trace); if(stackGroupOpts) { @@ -68011,7 +69732,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":145,"../../lib":165,"../../plots/cartesian/axes":210,"./arrays_to_calcdata":280,"./calc_selection":283,"./colorscale_calc":284,"./subtypes":305,"fast-isnumeric":11}],283:[function(_dereq_,module,exports){ +},{"../../constants/numerical":142,"../../lib":163,"../../plots/cartesian/axes":208,"./arrays_to_calcdata":278,"./calc_selection":281,"./colorscale_calc":282,"./subtypes":303,"fast-isnumeric":11}],281:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68030,7 +69751,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":165}],284:[function(_dereq_,module,exports){ +},{"../../lib":163}],282:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68039,31 +69760,41 @@ module.exports = function calcSelection(cd, trace) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var subTypes = _dereq_('./subtypes'); - -module.exports = function calcMarkerColorscale(trace) { +module.exports = function calcMarkerColorscale(gd, trace) { if(subTypes.hasLines(trace) && hasColorscale(trace, 'line')) { - calcColorscale(trace, trace.line.color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } if(subTypes.hasMarkers(trace)) { if(hasColorscale(trace, 'marker')) { - calcColorscale(trace, trace.marker.color, 'marker', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - calcColorscale(trace, trace.marker.line.color, 'marker.line', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } } }; -},{"../../components/colorscale/calc":53,"../../components/colorscale/has_colorscale":59,"./subtypes":305}],285:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":53,"../../components/colorscale/helpers":56,"./subtypes":303}],283:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68087,10 +69818,12 @@ module.exports = { // number of viewport sizes away from the visible region // at which we clip all lines to the perimeter - maxScreensAway: 20 + maxScreensAway: 20, + + eventDataKeys: [] }; -},{}],286:[function(_dereq_,module,exports){ +},{}],284:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68273,7 +70006,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":282}],287:[function(_dereq_,module,exports){ +},{"./calc":280}],285:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68312,7 +70045,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],288:[function(_dereq_,module,exports){ +},{}],286:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68390,7 +70123,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout dfltHoverOn.push('fills'); } coerce('hoveron', dfltHoverOn.join('+') || 'points'); - + if(traceOut.hoveron !== 'fills') coerce('hovertemplate'); var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults'); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'}); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'}); @@ -68398,7 +70131,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":165,"../../registry":259,"./attributes":281,"./constants":285,"./fillcolor_defaults":290,"./line_defaults":294,"./line_shape_defaults":296,"./marker_defaults":300,"./stack_defaults":303,"./subtypes":305,"./text_defaults":306,"./xy_defaults":307}],289:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../registry":257,"./attributes":279,"./constants":283,"./fillcolor_defaults":288,"./line_defaults":292,"./line_shape_defaults":294,"./marker_defaults":298,"./stack_defaults":301,"./subtypes":303,"./text_defaults":304,"./xy_defaults":305}],287:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68441,7 +70174,7 @@ function isValid(v) { return v || v === 0; } -},{"../../lib":165}],290:[function(_dereq_,module,exports){ +},{"../../lib":163}],288:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68479,7 +70212,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":45,"../../lib":165}],291:[function(_dereq_,module,exports){ +},{"../../components/color":45,"../../lib":163}],289:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68532,7 +70265,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":45,"./subtypes":305}],292:[function(_dereq_,module,exports){ +},{"../../components/color":45,"./subtypes":303}],290:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68628,7 +70361,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { y1: yc + rad, yLabelVal: yLabelVal, - spikeDistance: dxy(di) + spikeDistance: dxy(di), + hovertemplate: trace.hovertemplate }); fillHoverText(di, trace, pointData); @@ -68712,7 +70446,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { x1: xmax, y0: yAvg, y1: yAvg, - color: color + color: color, + hovertemplate: '%{name}' }); delete pointData.index; @@ -68727,7 +70462,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":45,"../../components/fx":87,"../../lib":165,"../../registry":259,"./fill_hover_text":289,"./get_trace_color":291}],293:[function(_dereq_,module,exports){ +},{"../../components/color":45,"../../components/fx":84,"../../lib":163,"../../registry":257,"./fill_hover_text":287,"./get_trace_color":289}],291:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68774,7 +70509,7 @@ Scatter.meta = { module.exports = Scatter; -},{"../../plots/cartesian":222,"./arrays_to_calcdata":280,"./attributes":281,"./calc":282,"./cross_trace_calc":286,"./cross_trace_defaults":287,"./defaults":288,"./hover":292,"./marker_colorbar":299,"./plot":301,"./select":302,"./style":304,"./subtypes":305}],294:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":220,"./arrays_to_calcdata":278,"./attributes":279,"./calc":280,"./cross_trace_calc":284,"./cross_trace_defaults":285,"./defaults":286,"./hover":290,"./marker_colorbar":297,"./plot":299,"./select":300,"./style":302,"./subtypes":303}],292:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68786,7 +70521,7 @@ module.exports = Scatter; 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) { @@ -68805,7 +70540,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":55,"../../components/colorscale/has_colorscale":59,"../../lib":165}],295:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":55,"../../components/colorscale/helpers":56,"../../lib":163}],293:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69270,7 +71005,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":145,"../../lib":165,"./constants":285}],296:[function(_dereq_,module,exports){ +},{"../../constants/numerical":142,"../../lib":163,"./constants":283}],294:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69289,7 +71024,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],297:[function(_dereq_,module,exports){ +},{}],295:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69382,7 +71117,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],298:[function(_dereq_,module,exports){ +},{}],296:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69424,7 +71159,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":11}],299:[function(_dereq_,module,exports){ +},{"fast-isnumeric":11}],297:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69442,7 +71177,7 @@ module.exports = { max: 'cmax' }; -},{}],300:[function(_dereq_,module,exports){ +},{}],298:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69451,11 +71186,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var subTypes = _dereq_('./subtypes'); @@ -69525,7 +71259,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":45,"../../components/colorscale/defaults":55,"../../components/colorscale/has_colorscale":59,"./subtypes":305}],301:[function(_dereq_,module,exports){ +},{"../../components/color":45,"../../components/colorscale/defaults":55,"../../components/colorscale/helpers":56,"./subtypes":303}],299:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69616,7 +71350,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition function createFills(gd, traceJoin, plotinfo) { traceJoin.each(function(d) { var fills = ensureSingle(d3.select(this), 'g', 'fills'); - Drawing.setClipUrl(fills, plotinfo.layerClipId); + Drawing.setClipUrl(fills, plotinfo.layerClipId, gd); var trace = d[0].trace; @@ -69668,7 +71402,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition var text = ensureSingle(tr, 'g', 'text'); // error bars are at the bottom - Registry.getComponentMethod('errorbars', 'plot')(errorBarGroup, plotinfo, transitionOpts); + Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts); if(trace.visible !== true) return; @@ -69823,7 +71557,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.lineGroupStyle) .each(makeUpdate(true)); - Drawing.setClipUrl(lineJoin, plotinfo.layerClipId); + Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd); function clearFill(selection) { transition(selection).attr('d', 'M0,0Z'); @@ -70051,8 +71785,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = trace.cliponaxis === false; var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId; - Drawing.setClipUrl(points, clipUrl); - Drawing.setClipUrl(text, clipUrl); + Drawing.setClipUrl(points, clipUrl, gd); + Drawing.setClipUrl(text, clipUrl, gd); } function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { @@ -70097,7 +71831,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":70,"../../lib":165,"../../lib/polygon":177,"../../registry":259,"./line_points":295,"./link_traces":297,"./subtypes":305,"d3":9}],302:[function(_dereq_,module,exports){ +},{"../../components/drawing":66,"../../lib":163,"../../lib/polygon":175,"../../registry":257,"./line_points":293,"./link_traces":295,"./subtypes":303,"d3":9}],300:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70152,7 +71886,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":305}],303:[function(_dereq_,module,exports){ +},{"./subtypes":303}],301:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70258,7 +71992,7 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],304:[function(_dereq_,module,exports){ +},{}],302:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70330,7 +72064,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":70,"../../registry":259,"d3":9}],305:[function(_dereq_,module,exports){ +},{"../../components/drawing":66,"../../registry":257,"d3":9}],303:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70369,7 +72103,7 @@ module.exports = { } }; -},{"../../lib":165}],306:[function(_dereq_,module,exports){ +},{"../../lib":163}],304:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70399,7 +72133,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":165}],307:[function(_dereq_,module,exports){ +},{"../../lib":163}],305:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70408,34 +72142,32 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var Lib = _dereq_('../../lib'); var Registry = _dereq_('../../registry'); - module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { - var len, - x = coerce('x'), - y = coerce('y'); + var x = coerce('x'); + var y = coerce('y'); + var len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); if(x) { + var xlen = Lib.minRowLength(x); if(y) { - len = Math.min(x.length, y.length); - } - else { - len = x.length; + len = Math.min(xlen, Lib.minRowLength(y)); + } else { + len = xlen; coerce('y0'); coerce('dy'); } - } - else { + } else { if(!y) return 0; - len = traceOut.y.length; + len = Lib.minRowLength(y); coerce('x0'); coerce('dx'); } @@ -70445,7 +72177,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../registry":259}],308:[function(_dereq_,module,exports){ +},{"../../lib":163,"../../registry":257}],306:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70544,7 +72276,7 @@ module.exports = overrideAll({ }) }, 'calc', 'nested'); -},{"../../components/colorscale/attributes":52,"../../components/drawing/attributes":69,"../../lib/extend":157,"../../plot_api/edit_types":193,"../../plots/attributes":207,"../scatter/attributes":281}],309:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":52,"../../components/drawing/attributes":65,"../../lib/extend":155,"../../plot_api/edit_types":191,"../../plots/attributes":205,"../scatter/attributes":279}],307:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70586,7 +72318,7 @@ module.exports = function calc(gd, trace) { } arraysToCalcdata(calcTrace, trace); - calcMarkerColorscale(trace); + calcMarkerColorscale(gd, trace); calcSelection(calcTrace, trace); if(len) { @@ -70601,7 +72333,7 @@ module.exports = function calc(gd, trace) { return calcTrace; }; -},{"../../constants/numerical":145,"../../lib":165,"../scatter/arrays_to_calcdata":280,"../scatter/calc_selection":283,"../scatter/colorscale_calc":284,"fast-isnumeric":11}],310:[function(_dereq_,module,exports){ +},{"../../constants/numerical":142,"../../lib":163,"../scatter/arrays_to_calcdata":278,"../scatter/calc_selection":281,"../scatter/colorscale_calc":282,"fast-isnumeric":11}],308:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70680,7 +72412,7 @@ function handleLonLatLocDefaults(traceIn, traceOut, coerce) { return len; } -},{"../../lib":165,"../scatter/fillcolor_defaults":290,"../scatter/line_defaults":294,"../scatter/marker_defaults":300,"../scatter/subtypes":305,"../scatter/text_defaults":306,"./attributes":308}],311:[function(_dereq_,module,exports){ +},{"../../lib":163,"../scatter/fillcolor_defaults":288,"../scatter/line_defaults":292,"../scatter/marker_defaults":298,"../scatter/subtypes":303,"../scatter/text_defaults":304,"./attributes":306}],309:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70701,7 +72433,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],312:[function(_dereq_,module,exports){ +},{}],310:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70808,7 +72540,7 @@ function getExtraText(trace, pt, axis, labels) { return text.join('
'); } -},{"../../components/fx":87,"../../constants/numerical":145,"../../plots/cartesian/axes":210,"../scatter/fill_hover_text":289,"../scatter/get_trace_color":291,"./attributes":308}],313:[function(_dereq_,module,exports){ +},{"../../components/fx":84,"../../constants/numerical":142,"../../plots/cartesian/axes":208,"../scatter/fill_hover_text":287,"../scatter/get_trace_color":289,"./attributes":306}],311:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70844,7 +72576,7 @@ ScatterGeo.meta = { module.exports = ScatterGeo; -},{"../../plots/geo":241,"../scatter/marker_colorbar":299,"../scatter/style":304,"./attributes":308,"./calc":309,"./defaults":310,"./event_data":311,"./hover":312,"./plot":314,"./select":315,"./style":316}],314:[function(_dereq_,module,exports){ +},{"../../plots/geo":239,"../scatter/marker_colorbar":297,"../scatter/style":302,"./attributes":306,"./calc":307,"./defaults":308,"./event_data":309,"./hover":310,"./plot":312,"./select":313,"./style":314}],312:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70938,7 +72670,7 @@ function calcGeoJSON(calcTrace, topojson) { } } -},{"../../constants/numerical":145,"../../lib":165,"../../lib/geo_location_utils":160,"../../lib/geojson_utils":161,"../../lib/topojson_utils":189,"../scatter/subtypes":305,"./style":316,"d3":9}],315:[function(_dereq_,module,exports){ +},{"../../constants/numerical":142,"../../lib":163,"../../lib/geo_location_utils":158,"../../lib/geojson_utils":159,"../../lib/topojson_utils":187,"../scatter/subtypes":303,"./style":314,"d3":9}],313:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70995,7 +72727,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"../../constants/numerical":145,"../scatter/subtypes":305}],316:[function(_dereq_,module,exports){ +},{"../../constants/numerical":142,"../scatter/subtypes":303}],314:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71044,5 +72776,5 @@ function styleTrace(gd, calcTrace) { }); } -},{"../../components/color":45,"../../components/drawing":70,"../scatter/style":304,"d3":9}]},{},[5])(5) +},{"../../components/color":45,"../../components/drawing":66,"../scatter/style":302,"d3":9}]},{},[5])(5) }); diff --git a/dist/plotly-geo.min.js b/dist/plotly-geo.min.js index baf7e6dedb8..9223813a722 100644 --- a/dist/plotly-geo.min.js +++ b/dist/plotly-geo.min.js @@ -1,7 +1,7 @@ /** -* plotly.js (geo - minified) v1.42.5 +* plotly.js (geo - minified) v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,n,r){function a(o,l){if(!n[o]){if(!e[o]){var s="function"==typeof require&&require;if(!l&&s)return s(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[o]={exports:{}};e[o][0].call(u.exports,function(t){return a(e[o][1][t]||t)},u,u.exports,t,e,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;oplotly-logomark"}}},{}],3:[function(t,e,n){"use strict";e.exports=t("../src/traces/choropleth")},{"../src/traces/choropleth":273}],4:[function(t,e,n){"use strict";e.exports=t("../src/core")},{"../src/core":147}],5:[function(t,e,n){"use strict";var r=t("./core");r.register([t("./scattergeo"),t("./choropleth")]),e.exports=r},{"./choropleth":3,"./core":4,"./scattergeo":6}],6:[function(t,e,n){"use strict";e.exports=t("../src/traces/scattergeo")},{"../src/traces/scattergeo":313}],7:[function(t,e,n){var r=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return n},i=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var l,s=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),l=0===c.x}catch(t){l=!1}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,n,a){var i,o,l;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),l=o[e]):(o=t._events=r(null),t._eventsCount=0),l){if("function"==typeof l?l=o[e]=a?[n,l]:[l,n]:a?l.unshift(n):l.push(n),!l.warned&&(i=u(t))&&i>0&&l.length>i){l.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+l.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=l.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else l=o[e]=n,++t._eventsCount;return t}function d(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var s=new Error('Unhandled "error" event. ('+e+")");throw s.context=e,s}if(!(n=o[t]))return!1;var c="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,a=v(t,r),i=0;i=0;o--)if(n[o]===e||n[o].listener===e){l=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(var n=e,r=n+1,a=t.length;r=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],8:[function(t,e,n){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",CPV:"verde",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai)(?!.*\\brep).*china|^(?=.*peo)(?=.*rep).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COG:"^(?!.*\\bdem)(?!.*\\bd[\\.]?r)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CSK:"czechoslovakia",CZE:"^(?=.*rep).*czech|czechia|bohemia",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bd[\\.]?r|\\bd[\\.]?r.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"(^ireland)|(^republic.*ireland)",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat|people|north|d.*p.*.r).*\\bkorea|dprk|korea.*(d.*p.*r)",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"fed.*micronesia|micronesia.*fed",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",KOR:"^(?!.*d.*p.*r)(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea(?!.*d.*p.*r)",MDA:"moldov|b(a|e)ssarabia",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"south.africa|s\\\\..?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa|^(?!.*peo)(?=.*rep).*china",TJK:"tajik",THA:"thailand|\\bsiam",MKD:"macedonia|fyrom",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",TZA:"tanzania",USA:"united.?states\\b(?!.*islands)|\\bu\\.?s\\.?a\\.?\\b|^\\s*u\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],9:[function(t,e,n){!function(){var t={version:"3.5.17"},n=[].slice,r=function(t){return n.call(t)},a=this.document;function i(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(a)try{r(a.documentElement.childNodes)[0].nodeType}catch(t){r=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),a)try{a.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var l=this.Element.prototype,s=l.setAttribute,c=l.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;l.setAttribute=function(t,e){s.call(this,t,e+"")},l.setAttributeNS=function(t,e,n){c.call(this,t,e,n+"")},u.setProperty=function(t,e,n){f.call(this,t,e+"",n)}}function d(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function h(t){return!isNaN(t)}function g(t){return{left:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[i],n)<0?r=i+1:a=i}return r},right:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[i],n)>0?a=i:r=i+1}return r}}}t.ascending=d,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var n,r,a=-1,i=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++ar&&(n=r)}else{for(;++a=r){n=r;break}for(;++ar&&(n=r)}return n},t.max=function(t,e){var n,r,a=-1,i=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++an&&(n=r)}else{for(;++a=r){n=r;break}for(;++an&&(n=r)}return n},t.extent=function(t,e){var n,r,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=r){n=a=r;break}for(;++ir&&(n=r),a=r){n=a=r;break}for(;++ir&&(n=r),a1)return o/(s-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(d);function y(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,n){return d(t(e),n)}:t)},t.shuffle=function(t,e,n){(i=arguments.length)<3&&(n=t.length,i<2&&(e=0));for(var r,a,i=n-e;i;)a=Math.random()*i--|0,r=t[i+e],t[i+e]=t[a+e],t[a+e]=r;return t},t.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},t.pairs=function(t){for(var e=0,n=t.length-1,r=t[0],a=new Array(n<0?0:n);e=0;)for(e=(r=t[a]).length;--e>=0;)n[--o]=r[e];return n};var m=Math.abs;function x(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n==1/0)throw new Error("infinite range");var r,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(m(n)),o=-1;if(t*=i,e*=i,(n*=i)<0)for(;(r=t+n*++o)>e;)a.push(r/i);else for(;(r=t+n*++o)=a.length)return n?n.call(r,i):e?i.sort(e):i;for(var s,c,u,f,d=-1,p=i.length,h=a[l++],g=new b;++d=a.length)return e;var r=[],o=i[n++];return e.forEach(function(e,a){r.push({key:e,values:t(a,n)})}),o?r.sort(function(t,e){return o(t.key,e.key)}):r}(o(t.map,e,0),0)},r.key=function(t){return a.push(t),r},r.sortKeys=function(t){return i[a.length-1]=t,r},r.sortValues=function(t){return e=t,r},r.rollup=function(t){return n=t,r},r},t.set=function(t){var e=new P;if(t)for(var n=0,r=t.length;n=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},t.event=null,t.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]};function V(t){return q(t,Y),t}var U=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},Z=function(t,e){var n=t.matches||t[D(t,"matchesSelector")];return(Z=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(U=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,Z=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var Y=t.selection.prototype=[];function X(t){return"function"==typeof t?t:function(){return U(t,this)}}function W(t){return"function"==typeof t?t:function(){return G(t,this)}}Y.select=function(t){var e,n,r,a,i=[];t=X(t);for(var o=-1,l=this.length;++o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Q.hasOwnProperty(n)?{space:Q[n],local:t}:t}},Y.attr=function(e,n){if(arguments.length<2){if("string"==typeof e){var r=this.node();return(e=t.ns.qualify(e)).local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}for(n in e)this.each($(n,e[n]));return this}return this.each($(e,n))},Y.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=et(t)).length,a=-1;if(e=n.classList){for(;++a=0;)(n=r[a])&&(i&&i!==n.nextSibling&&i.parentNode.insertBefore(n,i),i=n);return this},Y.sort=function(t){t=function(t){arguments.length||(t=d);return function(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}}.apply(this,arguments);for(var e=-1,n=this.length;++e0&&(e=e.slice(0,o));var s=ht.get(e);function c(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return s&&(e=s,l=vt),o?n?function(){var t=l(n,r(arguments));c.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=n}:c:n?R:function(){var n,r=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(n=a.match(r)){var i=this[a];this.removeEventListener(n[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=dt,dt.append=Y.append,dt.empty=Y.empty,dt.node=Y.node,dt.call=Y.call,dt.size=Y.size,dt.select=function(t){for(var e,n,r,a,i,o=[],l=-1,s=this.length;++l=r&&(r=e+1);!(o=l[r])&&++r0?1:t<0?-1:0}function zt(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function Dt(t){return t>1?0:t<-1?Tt:Math.acos(t)}function Et(t){return t>1?St:t<-1?-St:Math.asin(t)}function Rt(t){return((t=Math.exp(t))+1/t)/2}function Nt(t){return(t=Math.sin(t/2))*t}var It=Math.SQRT2;t.interpolateZoom=function(t,e){var n,r,a=t[0],i=t[1],o=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-i,d=u*u+f*f;if(d0&&(e=e.transition().duration(g)),e.call(w.event)}function L(){c&&c.domain(s.range().map(function(t){return(t-d.x)/d.k}).map(s.invert)),f&&f.domain(u.range().map(function(t){return(t-d.y)/d.k}).map(u.invert))}function S(t){v++||t({type:"zoomstart"})}function C(t){L(),t({type:"zoom",scale:d.k,translate:[d.x,d.y]})}function P(t){--v||(t({type:"zoomend"}),n=null)}function O(){var e=this,n=_.of(e,arguments),r=0,a=t.select(o(e)).on(m,function(){r=1,T(t.mouse(e),i),C(n)}).on(x,function(){a.on(m,null).on(x,null),l(r),P(n)}),i=k(t.mouse(e)),l=xt(e);fl.call(e),S(n)}function z(){var e,n=this,r=_.of(n,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+o,c="touchend"+o,u=[],f=t.select(n),p=xt(n);function h(){var r=t.touches(n);return e=d.k,r.forEach(function(t){t.identifier in a&&(a[t.identifier]=k(t))}),r}function g(){var e=t.event.target;t.select(e).on(s,v).on(c,m),u.push(e);for(var r=t.event.changedTouches,o=0,f=r.length;o1){y=p[0];var x=p[1],b=y[0]-x[0],_=y[1]-x[1];i=b*b+_*_}}function v(){var o,s,c,u,f=t.touches(n);fl.call(n);for(var d=0,p=f.length;d360?t-=360:t<0&&(t+=360),t<60?r+(a-r)*t/60:t<180?a:t<240?r+(a-r)*(240-t)/60:r}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,r=2*(n=n<0?0:n>1?1:n)-(a=n<=.5?n*(1+e):n+e-n*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,n,r){return this instanceof Gt?(this.h=+e,this.c=+n,void(this.l=+r)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Xt?e.l:(e=de((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,n,r)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Ut(this.h,this.s,this.l)},t.hcl=Gt;var Zt=Gt.prototype=new Ht;function Yt(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Xt(n,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Xt(t,e,n){return this instanceof Xt?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof Xt?new Xt(t.l,t.a,t.b):t instanceof Gt?Yt(t.h,t.c,t.l):de((t=ie(t)).r,t.g,t.b):new Xt(t,e,n)}Zt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Wt*(arguments.length?t:1)))},Zt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Wt*(arguments.length?t:1)))},Zt.rgb=function(){return Yt(this.h,this.c,this.l).rgb()},t.lab=Xt;var Wt=18,Jt=.95047,Qt=1,$t=1.08883,Kt=Xt.prototype=new Ht;function te(t,e,n){var r=(t+16)/116,a=r+e/500,i=r-n/200;return new ie(ae(3.2404542*(a=ne(a)*Jt)-1.5371385*(r=ne(r)*Qt)-.4985314*(i=ne(i)*$t)),ae(-.969266*a+1.8760108*r+.041556*i),ae(.0556434*a-.2040259*r+1.0572252*i))}function ee(t,e,n){return t>0?new Gt(Math.atan2(n,e)*Pt,Math.sqrt(e*e+n*n),t):new Gt(NaN,NaN,t)}function ne(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function re(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,n){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ue(""+t,ie,Ut):new ie(t,e,n)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function le(t){return oe(t)+""}Kt.brighter=function(t){return new Xt(Math.min(100,this.l+Wt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Xt(Math.max(0,this.l-Wt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var se=ie.prototype=new Ht;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,n){var r,a,i,o=0,l=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=r[2].split(","),r[1]){case"hsl":return n(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(he(a[0]),he(a[1]),he(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,l=240&i,l|=l>>4,s=15&i,s|=s<<4):7===t.length&&(o=(16711680&i)>>16,l=(65280&i)>>8,s=255&i)),e(o,l,s))}function fe(t,e,n){var r,a,i=Math.min(t/=255,e/=255,n/=255),o=Math.max(t,e,n),l=o-i,s=(o+i)/2;return l?(a=s<.5?l/(o+i):l/(2-o-i),r=t==o?(e-n)/l+(e0&&s<1?0:r),new qt(r,a,s)}function de(t,e,n){var r=re((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(n=pe(n)))/Jt),a=re((.2126729*t+.7151522*e+.072175*n)/Qt);return Xt(116*a-16,500*(r-a),200*(a-re((.0193339*t+.119192*e+.9503041*n)/$t)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function he(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}se.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,n=this.g,r=this.b,a=30;return e||n||r?(e&&e=200&&e<300||304===e){try{t=a.call(o,c)}catch(t){return void l.error.call(o,t)}l.load.call(o,t)}else l.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var n=t.event;t.event=e;try{l.progress.call(o,c)}finally{t.event=n}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(n=null==t?null:t+"",o):n},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(r(arguments)))}}),o.send=function(t,r,a){if(2===arguments.length&&"function"==typeof r&&(a=r,r=null),c.open(t,e,!0),null==n||"accept"in s||(s.accept=n+",*/*"),c.setRequestHeader)for(var i in s)c.setRequestHeader(i,s[i]);return null!=n&&c.overrideMimeType&&c.overrideMimeType(n),null!=u&&(c.responseType=u),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),l.beforesend.call(o,c),c.send(null==r?null:r),o},o.abort=function(){return c.abort(),o},t.rebind(o,l,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=ye(O),t.dsv=function(t,e){var n=new RegExp('["'+t+"\n]"),r=t.charCodeAt(0);function a(t,n,r){arguments.length<3&&(r=n,n=null);var a=me(t,e,null==n?i:o(n),r);return a.row=function(t){return arguments.length?a.response(null==(n=t)?i:o(t)):n},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function l(e){return e.map(s).join(t)}function s(t){return n.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var n;return a.parseRows(t,function(t,r){if(n)return n(t,r-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,n){return e(a(t),n)}:a})},a.parseRows=function(t,e){var n,a,i={},o={},l=[],s=t.length,c=0,u=0;function f(){if(c>=s)return o;if(a)return a=!1,i;var e=c;if(34===t.charCodeAt(e)){for(var n=e;n++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Te,e)),_e=0):(_e=1,ke(Te))}function Ae(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Le(){for(var t,e=xe,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}});t.formatPrefix=function(e,n){var r=0;return(e=+e)&&(e<0&&(e*=-1),n&&(e=t.round(e,Se(e,n))),r=1+Math.floor(1e-12+Math.log(e)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),Ce[8+r/3]};var Pe=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Oe=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,n){return(e=t.round(e,Se(e,n))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),n))))}});function ze(t){return t+""}var De=t.time={},Ee=Date;function Re(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Re.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ne.setUTCDate.apply(this._,arguments)},setDay:function(){Ne.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ne.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ne.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ne.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ne.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ne.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ne.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ne.setTime.apply(this._,arguments)}};var Ne=Date.prototype;function Ie(t,e,n){function r(e){var n=t(e),r=i(n,1);return e-n1)for(;o68?1900:2e3),n+a[0].length):-1}function Je(t,e,n){return/^[+-]\d{4}$/.test(e=e.slice(n,n+5))?(t.Z=-e,n+5):-1}function Qe(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function $e(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Ke(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function tn(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function en(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function nn(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function rn(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function an(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=m(e)/60|0,a=m(e)%60;return n+qe(r,"0",2)+qe(a,"0",2)}function on(t,e,n){He.lastIndex=0;var r=He.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ln(t){for(var e=t.length,n=-1;++n0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),i.push(t.substring(n-=l,n+l)),!((s+=l+1)>e));)l=a[o=(o+1)%a.length];return i.reverse().join(r)}:O;return function(e){var r=Pe.exec(e),a=r[1]||" ",l=r[2]||">",s=r[3]||"-",c=r[4]||"",u=r[5],f=+r[6],d=r[7],p=r[8],h=r[9],g=1,v="",y="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===a&&"="===l)&&(u=a="0",l="="),h){case"n":d=!0,h="g";break;case"%":g=100,y="%",h="f";break;case"p":g=100,y="%",h="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+h.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":g=-1,h="r"}"$"===c&&(v=i[0],y=i[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):"e"!=h&&"f"!=h||(p=Math.max(0,Math.min(20,p)))),h=Oe.get(h)||ze;var b=u&&d;return function(e){var r=y;if(m&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===s?"":s;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),r=c.symbol+y}else e*=g;var _,w,k=(e=h(e,p)).lastIndexOf(".");if(k<0){var M=x?e.lastIndexOf("e"):-1;M<0?(_=e,w=""):(_=e.substring(0,M),w=e.substring(M))}else _=e.substring(0,k),w=n+e.substring(k+1);!u&&d&&(_=o(_,1/0));var T=v.length+_.length+w.length+(b?0:i.length),A=T"===l?A+i+e:"^"===l?A.substring(0,T>>=1)+i+e+A.substring(T):i+(b?e:A+e))+r}}}(e),timeFormat:function(e){var n=e.dateTime,r=e.date,a=e.time,i=e.periods,o=e.days,l=e.shortDays,s=e.months,c=e.shortMonths;function u(t){var e=t.length;function n(n){for(var r,a,i,o=[],l=-1,s=0;++l=c)return-1;if(37===(a=e.charCodeAt(l++))){if(o=e.charAt(l++),!(i=w[o in je?e.charAt(l++):o])||(r=i(t,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}u.utc=function(t){var e=u(t);function n(t){try{var n=new(Ee=Re);return n._=t,e(n)}finally{Ee=Date}}return n.parse=function(t){try{Ee=Re;var n=e.parse(t);return n&&n._}finally{Ee=Date}},n.toString=e.toString,n},u.multi=u.utc.multi=ln;var d=t.map(),p=Ve(o),h=Ue(o),g=Ve(l),v=Ue(l),y=Ve(s),m=Ue(s),x=Ve(c),b=Ue(c);i.forEach(function(t,e){d.set(t.toLowerCase(),e)});var _={a:function(t){return l[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:u(n),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+De.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(De.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(De.mondayOfYear(t),e,2)},x:u(r),X:u(a),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:an,"%":function(){return"%"}},w={a:function(t,e,n){g.lastIndex=0;var r=g.exec(e.slice(n));return r?(t.w=v.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){p.lastIndex=0;var r=p.exec(e.slice(n));return r?(t.w=h.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){x.lastIndex=0;var r=x.exec(e.slice(n));return r?(t.m=b.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){y.lastIndex=0;var r=y.exec(e.slice(n));return r?(t.m=m.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,e,n){return f(t,_.c.toString(),e,n)},d:$e,e:$e,H:tn,I:tn,j:Ke,L:rn,m:Qe,M:en,p:function(t,e,n){var r=d.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)},S:nn,U:Ze,w:Ge,W:Ye,x:function(t,e,n){return f(t,_.x.toString(),e,n)},X:function(t,e,n){return f(t,_.X.toString(),e,n)},y:We,Y:Xe,Z:Je,"%":on};return u}(e)}};var sn=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function cn(){}t.format=sn.numberFormat,t.geo={},cn.prototype={s:0,t:0,add:function(t){fn(t,this.t,un),fn(un.s,this.s,this),this.s?this.t+=un.t:this.s=un.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var un=new cn;function fn(t,e,n){var r=n.s=t+e,a=r-t,i=r-a;n.t=t-i+(e-a)}function dn(t,e){t&&hn.hasOwnProperty(t.type)&&hn[t.type](t,e)}t.geo.stream=function(t,e){t&&pn.hasOwnProperty(t.type)?pn[t.type](t,e):dn(t,e)};var pn={Feature:function(t,e){dn(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,a=n.length;++r=0?1:-1,l=o*i,s=Math.cos(e),c=Math.sin(e),u=a*c,f=r*s+u*Math.cos(l),d=u*o*Math.sin(l);Cn.add(Math.atan2(d,f)),n=t,r=s,a=c}Pn.point=function(o,l){Pn.point=i,n=(t=o)*Ct,r=Math.cos(l=(e=l)*Ct/2+Tt/4),a=Math.sin(l)},Pn.lineEnd=function(){i(t,e)}}function zn(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function Dn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function En(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Rn(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Nn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function In(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Fn(t){return[Math.atan2(t[1],t[0]),Et(t[2])]}function jn(t,e){return m(t[0]-e[0])kt?a=90:c<-kt&&(n=-90),f[0]=e,f[1]=r}};function p(t,i){u.push(f=[e=t,r=t]),ia&&(a=i)}function h(t,o){var l=zn([t*Ct,o*Ct]);if(s){var c=En(s,l),u=En([c[1],-c[0],0],c);In(u),u=Fn(u);var f=t-i,d=f>0?1:-1,h=u[0]*Pt*d,g=m(f)>180;if(g^(d*ia&&(a=v);else if(g^(d*i<(h=(h+360)%360-180)&&ha&&(a=o);g?t_(e,r)&&(r=t):_(t,r)>_(e,r)&&(e=t):r>=e?(tr&&(r=t)):t>i?_(e,t)>_(e,r)&&(r=t):_(t,r)>_(e,r)&&(e=t)}else p(t,o);s=l,i=t}function g(){d.point=h}function v(){f[0]=e,f[1]=r,d.point=p,s=null}function y(t,e){if(s){var n=t-i;c+=m(n)>180?n+(n>0?360:-360):n}else o=t,l=e;Pn.point(t,e),h(t,e)}function x(){Pn.lineStart()}function b(){y(o,l),Pn.lineEnd(),m(c)>kt&&(e=-(r=180)),f[0]=e,f[1]=r,s=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):l.push(g=p);for(var s,c,p,h=-1/0,g=(o=0,l[c=l.length-1]);o<=c;g=p,++o)p=l[o],(s=_(g[1],p[0]))>h&&(h=s,e=p[0],r=g[1])}return u=f=null,e===1/0||n===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,n],[r,a]]}}(),t.geo.centroid=function(e){mn=xn=bn=_n=wn=kn=Mn=Tn=An=Ln=Sn=0,t.geo.stream(e,Bn);var n=An,r=Ln,a=Sn,i=n*n+r*r+a*a;return i=0;--l)a.point((f=u[l])[0],f[1]);else r(p.x,p.p.x,-1,a);p=p.p}u=(p=p.o).z,h=!h}while(!p.v);a.lineEnd()}}}function Wn(t){if(e=t.length){for(var e,n,r=0,a=t[0];++r=0?1:-1,k=w*_,M=k>Tt,T=h*x;if(Cn.add(Math.atan2(T*w*Math.sin(k),g*b+T*Math.cos(k))),i+=M?_+w*At:_,M^d>=n^y>=n){var A=En(zn(f),zn(t));In(A);var L=En(a,A);In(L);var S=(M^_>=0?-1:1)*Et(L[2]);(r>S||r===S&&(A[0]||A[1]))&&(o+=M^_>=0?1:-1)}if(!v++)break;d=y,h=x,g=b,f=t}}return(i<-kt||i0){for(x||(o.polygonStart(),x=!0),o.lineStart();++i1&&2&e&&n.push(n.pop().concat(n.shift())),l.push(n.filter($n))}return u}}function $n(t){return t.length>1}function Kn(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:R,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function tr(t,e){return((t=t.x)[0]<0?t[1]-St-kt:St-t[1])-((e=e.x)[0]<0?e[1]-St-kt:St-e[1])}var er=Qn(Yn,function(t){var e,n=NaN,r=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var l=i>0?Tt:-Tt,s=m(i-n);m(s-Tt)0?St:-St),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),t.point(i,r),e=0):a!==l&&s>=Tt&&(m(n-a)kt?Math.atan((Math.sin(e)*(i=Math.cos(r))*Math.sin(n)-Math.sin(r)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+r)/2}(n,r,i,o),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),e=0),t.point(n=i,r=o),a=l},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}},function(t,e,n,r){var a;if(null==t)a=n*St,r.point(-Tt,a),r.point(0,a),r.point(Tt,a),r.point(Tt,0),r.point(Tt,-a),r.point(0,-a),r.point(-Tt,-a),r.point(-Tt,0),r.point(-Tt,a);else if(m(t[0]-e[0])>kt){var i=t[0]0)){if(i/=d,d<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=n-s,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>u&&(u=i)}else if(d>0){if(i0)){if(i/=p,p<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=r-c,p||!(i<0)){if(i/=p,p<0){if(i>f)return;i>u&&(u=i)}else if(p>0){if(i0&&(a.a={x:s+u*d,y:c+u*p}),f<1&&(a.b={x:s+f*d,y:c+f*p}),a}}}}}}var rr=1e9;function ar(e,n,r,a){return function(s){var c,u,f,d,p,h,g,v,y,m,x,b=s,_=Kn(),w=nr(e,n,r,a),k={point:A,lineStart:function(){k.point=L,u&&u.push(f=[]);m=!0,y=!1,g=v=NaN},lineEnd:function(){c&&(L(d,p),h&&y&&_.rejoin(),c.push(_.buffer()));k.point=A,y&&s.lineEnd()},polygonStart:function(){s=_,c=[],u=[],x=!0},polygonEnd:function(){s=b,c=t.merge(c);var n=function(t){for(var e=0,n=u.length,r=t[1],a=0;ar&&zt(c,i,t)>0&&++e:i[1]<=r&&zt(c,i,t)<0&&--e,c=i;return 0!==e}([e,a]),r=x&&n,i=c.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),M(null,null,1,s),s.lineEnd()),i&&Xn(c,o,n,M,s),s.polygonEnd()),c=u=f=null}};function M(t,o,s,c){var u=0,f=0;if(null==t||(u=i(t,s))!==(f=i(o,s))||l(t,o)<0^s>0)do{c.point(0===u||3===u?e:r,u>1?a:n)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function T(t,i){return e<=t&&t<=r&&n<=i&&i<=a}function A(t,e){T(t,e)&&s.point(t,e)}function L(t,e){var n=T(t=Math.max(-rr,Math.min(rr,t)),e=Math.max(-rr,Math.min(rr,e)));if(u&&f.push([t,e]),m)d=t,p=e,h=n,m=!1,n&&(s.lineStart(),s.point(t,e));else if(n&&y)s.point(t,e);else{var r={a:{x:g,y:v},b:{x:t,y:e}};w(r)?(y||(s.lineStart(),s.point(r.a.x,r.a.y)),s.point(r.b.x,r.b.y),n||s.lineEnd(),x=!1):n&&(s.lineStart(),s.point(t,e),x=!1)}g=t,v=e,y=n}return k};function i(t,a){return m(t[0]-e)0?0:3:m(t[0]-r)0?2:1:m(t[1]-n)0?1:0:a>0?3:2}function o(t,e){return l(t.x,e.x)}function l(t,e){var n=i(t,1),r=i(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}}function ir(t){var e=0,n=Tt/3,r=Cr(t),a=r(e,n);return a.parallels=function(t){return arguments.length?r(e=t[0]*Tt/180,n=t[1]*Tt/180):[e/Tt*180,n/Tt*180]},a}function or(t,e){var n=Math.sin(t),r=(n+Math.sin(e))/2,a=1+n*(2*r-n),i=Math.sqrt(a)/r;function o(t,e){var n=Math.sqrt(a-2*r*Math.sin(e))/r;return[n*Math.sin(t*=r),i-n*Math.cos(t)]}return o.invert=function(t,e){var n=i-e;return[Math.atan2(t,n)/r,Et((a-(t*t+n*n)*r*r)/(2*r))]},o}t.geo.clipExtent=function(){var t,e,n,r,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(l){return arguments.length?(i=ar(t=+l[0][0],e=+l[0][1],n=+l[1][0],r=+l[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[n,r]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return ir(or)}).raw=or,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,n,r,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,n){e=[t,n]}};function c(t){var i=t[0],o=t[1];return e=null,n(i,o),e||(r(i,o),e)||a(i,o),e}return c.invert=function(t){var e=i.scale(),n=i.translate(),r=(t[0]-n[0])/e,a=(t[1]-n[1])/e;return(a>=.12&&a<.234&&r>=-.425&&r<-.214?o:a>=.166&&a<.234&&r>=-.214&&r<-.115?l:i).invert(t)},c.stream=function(t){var e=i.stream(t),n=o.stream(t),r=l.stream(t);return{point:function(t,a){e.point(t,a),n.point(t,a),r.point(t,a)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),l.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),l.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),u=+t[0],f=+t[1];return n=i.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(s).point,r=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(s).point,a=l.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(s).point,c},c.scale(1070)};var lr,sr,cr,ur,fr,dr,pr={point:R,lineStart:R,lineEnd:R,polygonStart:function(){sr=0,pr.lineStart=hr},polygonEnd:function(){pr.lineStart=pr.lineEnd=pr.point=R,lr+=m(sr/2)}};function hr(){var t,e,n,r;function a(t,e){sr+=r*t-n*e,n=t,r=e}pr.point=function(i,o){pr.point=a,t=n=i,e=r=o},pr.lineEnd=function(){a(t,e)}}var gr={point:function(t,e){tfr&&(fr=t);edr&&(dr=e)},lineStart:R,lineEnd:R,polygonStart:R,polygonEnd:R};function vr(){var t=yr(4.5),e=[],n={point:r,lineStart:function(){n.point=a},lineEnd:o,polygonStart:function(){n.lineEnd=l},polygonEnd:function(){n.lineEnd=o,n.point=r},pointRadius:function(e){return t=yr(e),n},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function r(n,r){e.push("M",n,",",r,t)}function a(t,r){e.push("M",t,",",r),n.point=i}function i(t,n){e.push("L",t,",",n)}function o(){n.point=r}function l(){e.push("Z")}return n}function yr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var mr,xr={point:br,lineStart:_r,lineEnd:wr,polygonStart:function(){xr.lineStart=kr},polygonEnd:function(){xr.point=br,xr.lineStart=_r,xr.lineEnd=wr}};function br(t,e){bn+=t,_n+=e,++wn}function _r(){var t,e;function n(n,r){var a=n-t,i=r-e,o=Math.sqrt(a*a+i*i);kn+=o*(t+n)/2,Mn+=o*(e+r)/2,Tn+=o,br(t=n,e=r)}xr.point=function(r,a){xr.point=n,br(t=r,e=a)}}function wr(){xr.point=br}function kr(){var t,e,n,r;function a(t,e){var a=t-n,i=e-r,o=Math.sqrt(a*a+i*i);kn+=o*(n+t)/2,Mn+=o*(r+e)/2,Tn+=o,An+=(o=r*t-n*e)*(n+t),Ln+=o*(r+e),Sn+=3*o,br(n=t,r=e)}xr.point=function(i,o){xr.point=a,br(t=n=i,e=r=o)},xr.lineEnd=function(){a(t,e)}}function Mr(t){var e=4.5,n={point:r,lineStart:function(){n.point=a},lineEnd:o,polygonStart:function(){n.lineEnd=l},polygonEnd:function(){n.lineEnd=o,n.point=r},pointRadius:function(t){return e=t,n},result:R};function r(n,r){t.moveTo(n+e,r),t.arc(n,r,e,0,At)}function a(e,r){t.moveTo(e,r),n.point=i}function i(e,n){t.lineTo(e,n)}function o(){n.point=r}function l(){t.closePath()}return n}function Tr(t){var e=.5,n=Math.cos(30*Ct),r=16;function a(e){return(r?function(e){var n,a,o,l,s,c,u,f,d,p,h,g,v={point:y,lineStart:m,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=m}};function y(n,r){n=t(n,r),e.point(n[0],n[1])}function m(){f=NaN,v.point=x,e.lineStart()}function x(n,a){var o=zn([n,a]),l=t(n,a);i(f,d,u,p,h,g,f=l[0],d=l[1],u=n,p=o[0],h=o[1],g=o[2],r,e),e.point(f,d)}function b(){v.point=y,e.lineEnd()}function _(){m(),v.point=w,v.lineEnd=k}function w(t,e){x(n=t,e),a=f,o=d,l=p,s=h,c=g,v.point=x}function k(){i(f,d,u,p,h,g,a,o,n,l,s,c,r,e),v.lineEnd=b,b()}return v}:function(e){return Lr(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})})(e)}function i(r,a,o,l,s,c,u,f,d,p,h,g,v,y){var x=u-r,b=f-a,_=x*x+b*b;if(_>4*e&&v--){var w=l+p,k=s+h,M=c+g,T=Math.sqrt(w*w+k*k+M*M),A=Math.asin(M/=T),L=m(m(M)-1)e||m((x*O+b*z)/_-.5)>.3||l*p+s*h+c*g0&&16,a):Math.sqrt(e)},a}function Ar(t){this.stream=t}function Lr(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sr(t){return Cr(function(){return t})()}function Cr(e){var n,r,a,i,o,l,s=Tr(function(t,e){return[(t=n(t,e))[0]*c+i,o-t[1]*c]}),c=150,u=480,f=250,d=0,p=0,h=0,g=0,v=0,y=er,x=O,b=null,_=null;function w(t){return[(t=a(t[0]*Ct,t[1]*Ct))[0]*c+i,o-t[1]*c]}function k(t){return(t=a.invert((t[0]-i)/c,(o-t[1])/c))&&[t[0]*Pt,t[1]*Pt]}function M(){a=Zn(r=Dr(h,g,v),n);var t=n(d,p);return i=u-t[0]*c,o=f+t[1]*c,T()}function T(){return l&&(l.valid=!1,l=null),w}return w.stream=function(t){return l&&(l.valid=!1),(l=Pr(y(r,s(x(t))))).valid=!0,l},w.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,er):function(t){var e=Math.cos(t),n=e>0,r=m(e)>kt;return Qn(a,function(t){var e,l,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var p,h=[f,d],g=a(f,d),v=n?g?0:o(f,d):g?o(f+(f<0?Tt:-Tt),d):0;if(!e&&(c=s=g)&&t.lineStart(),g!==s&&(p=i(e,h),(jn(e,p)||jn(h,p))&&(h[0]+=kt,h[1]+=kt,g=a(h[0],h[1]))),g!==s)u=0,g?(t.lineStart(),p=i(h,e),t.point(p[0],p[1])):(p=i(e,h),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(r&&e&&n^g){var y;v&l||!(y=i(h,e,!0))||(u=0,n?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!g||e&&jn(e,h)||t.point(h[0],h[1]),e=h,s=g,l=v},lineEnd:function(){s&&t.lineEnd(),e=null},clean:function(){return u|(c&&s)<<1}}},Ir(t,6*Ct),n?[0,-t]:[-Tt,t-Tt]);function a(t,n){return Math.cos(t)*Math.cos(n)>e}function i(t,n,r){var a=[1,0,0],i=En(zn(t),zn(n)),o=Dn(i,i),l=i[0],s=o-l*l;if(!s)return!r&&t;var c=e*o/s,u=-e*l/s,f=En(a,i),d=Nn(a,c);Rn(d,Nn(i,u));var p=f,h=Dn(d,p),g=Dn(p,p),v=h*h-g*(Dn(d,d)-1);if(!(v<0)){var y=Math.sqrt(v),x=Nn(p,(-h-y)/g);if(Rn(x,d),x=Fn(x),!r)return x;var b,_=t[0],w=n[0],k=t[1],M=n[1];w<_&&(b=_,_=w,w=b);var T=w-_,A=m(T-Tt)0^x[1]<(m(x[0]-_)Tt^(_<=x[0]&&x[0]<=w)){var L=Nn(p,(-h+y)/g);return Rn(L,d),[x,Fn(L)]}}}function o(e,r){var a=n?t:Tt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),r<-a?i|=4:r>a&&(i|=8),i}}((b=+t)*Ct),T()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?ar(t[0][0],t[0][1],t[1][0],t[1][1]):O,T()):_},w.scale=function(t){return arguments.length?(c=+t,M()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],M()):[u,f]},w.center=function(t){return arguments.length?(d=t[0]%360*Ct,p=t[1]%360*Ct,M()):[d*Pt,p*Pt]},w.rotate=function(t){return arguments.length?(h=t[0]%360*Ct,g=t[1]%360*Ct,v=t.length>2?t[2]%360*Ct:0,M()):[h*Pt,g*Pt,v*Pt]},t.rebind(w,s,"precision"),function(){return n=e.apply(this,arguments),w.invert=n.invert&&k,M()}}function Pr(t){return Lr(t,function(e,n){t.point(e*Ct,n*Ct)})}function Or(t,e){return[t,e]}function zr(t,e){return[t>Tt?t-At:t<-Tt?t+At:t,e]}function Dr(t,e,n){return t?e||n?Zn(Rr(t),Nr(e,n)):Rr(t):e||n?Nr(e,n):zr}function Er(t){return function(e,n){return[(e+=t)>Tt?e-At:e<-Tt?e+At:e,n]}}function Rr(t){var e=Er(t);return e.invert=Er(-t),e}function Nr(t,e){var n=Math.cos(t),r=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*n+l*r;return[Math.atan2(s*a-u*i,l*n-c*r),Et(u*a+s*i)]}return o.invert=function(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*a-s*i;return[Math.atan2(s*a+c*i,l*n+u*r),Et(u*n-l*r)]},o}function Ir(t,e){var n=Math.cos(t),r=Math.sin(t);return function(a,i,o,l){var s=o*e;null!=a?(a=Fr(n,a),i=Fr(n,i),(o>0?ai)&&(a+=o*At)):(a=t+o*At,i=t-.5*s);for(var c,u=a;o>0?u>i:u2?t[2]*Ct:0),e.invert=function(e){return(e=t.invert(e[0]*Ct,e[1]*Ct))[0]*=Pt,e[1]*=Pt,e},e},zr.invert=Or,t.geo.circle=function(){var t,e,n=[0,0],r=6;function a(){var t="function"==typeof n?n.apply(this,arguments):n,r=Dr(-t[0]*Ct,-t[1]*Ct,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=r(t,e)),t[0]*=Pt,t[1]*=Pt}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(n=t,a):n},a.angle=function(n){return arguments.length?(e=Ir((t=+n)*Ct,r*Ct),a):t},a.precision=function(n){return arguments.length?(e=Ir(t*Ct,(r=+n)*Ct),a):r},a.angle(90)},t.geo.distance=function(t,e){var n,r=(e[0]-t[0])*Ct,a=t[1]*Ct,i=e[1]*Ct,o=Math.sin(r),l=Math.cos(r),s=Math.sin(a),c=Math.cos(a),u=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((n=f*o)*n+(n=c*u-s*f*l)*n),s*u+c*f*l)},t.geo.graticule=function(){var e,n,r,a,i,o,l,s,c,u,f,d,p=10,h=p,g=90,v=360,y=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(a/g)*g,r,g).map(f).concat(t.range(Math.ceil(s/v)*v,l,v).map(d)).concat(t.range(Math.ceil(n/p)*p,e,p).filter(function(t){return m(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/h)*h,i,h).filter(function(t){return m(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(d(l).slice(1),f(r).reverse().slice(1),d(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(a=+t[0][0],r=+t[1][0],s=+t[0][1],l=+t[1][1],a>r&&(t=a,a=r,r=t),s>l&&(t=s,s=l,l=t),x.precision(y)):[[a,s],[r,l]]},x.minorExtent=function(t){return arguments.length?(n=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],n>e&&(t=n,n=e,e=t),o>i&&(t=o,o=i,i=t),x.precision(y)):[[n,o],[e,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],h=+t[1],x):[p,h]},x.precision=function(t){return arguments.length?(y=+t,c=jr(o,i,90),u=Br(n,e,y),f=jr(s,l,90),d=Br(a,r,y),x):y},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,n,r=Hr,a=qr;function i(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||r.apply(this,arguments),n||a.apply(this,arguments))},i.source=function(t){return arguments.length?(r=t,e="function"==typeof t?null:t,i):r},i.target=function(t){return arguments.length?(a=t,n="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return n=t[0]*Ct,r=t[1]*Ct,a=e[0]*Ct,i=e[1]*Ct,o=Math.cos(r),l=Math.sin(r),s=Math.cos(i),c=Math.sin(i),u=o*Math.cos(n),f=o*Math.sin(n),d=s*Math.cos(a),p=s*Math.sin(a),h=2*Math.asin(Math.sqrt(Nt(i-r)+o*s*Nt(a-n))),g=1/Math.sin(h),(v=h?function(t){var e=Math.sin(t*=h)*g,n=Math.sin(h-t)*g,r=n*u+e*d,a=n*f+e*p,i=n*l+e*c;return[Math.atan2(a,r)*Pt,Math.atan2(i,Math.sqrt(r*r+a*a))*Pt]}:function(){return[n*Pt,r*Pt]}).distance=h,v;var n,r,a,i,o,l,s,c,u,f,d,p,h,g,v},t.geo.length=function(e){return mr=0,t.geo.stream(e,Vr),mr};var Vr={sphere:R,point:R,lineStart:function(){var t,e,n;function r(r,a){var i=Math.sin(a*=Ct),o=Math.cos(a),l=m((r*=Ct)-t),s=Math.cos(l);mr+=Math.atan2(Math.sqrt((l=o*Math.sin(l))*l+(l=n*i-e*o*s)*l),e*i+n*o*s),t=r,e=i,n=o}Vr.point=function(a,i){t=a*Ct,e=Math.sin(i*=Ct),n=Math.cos(i),Vr.point=r},Vr.lineEnd=function(){Vr.point=Vr.lineEnd=R}},lineEnd:R,polygonStart:R,polygonEnd:R};function Ur(t,e){function n(e,n){var r=Math.cos(e),a=Math.cos(n),i=t(r*a);return[i*a*Math.sin(e),i*Math.sin(n)]}return n.invert=function(t,n){var r=Math.sqrt(t*t+n*n),a=e(r),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,r*o),Math.asin(r&&n*i/r)]},n}var Gr=Ur(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sr(Gr)}).raw=Gr;var Zr=Ur(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},O);function Yr(t,e){var n=Math.cos(t),r=function(t){return Math.tan(Tt/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(r(e)/r(t)),i=n*Math.pow(r(t),a)/a;if(!a)return Jr;function o(t,e){i>0?e<-St+kt&&(e=-St+kt):e>St-kt&&(e=St-kt);var n=i/Math.pow(r(e),a);return[n*Math.sin(a*t),i-n*Math.cos(a*t)]}return o.invert=function(t,e){var n=i-e,r=Ot(a)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/a,2*Math.atan(Math.pow(i/r,1/a))-St]},o}function Xr(t,e){var n=Math.cos(t),r=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/r+t;if(m(r)1&&zt(t[n[r-2]],t[n[r-1]],t[a])<=0;)--r;n[r++]=a}return n.slice(0,r)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sr(Kr)}).raw=Kr,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=Qr(ta),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):[(t=n())[0],t[1],t[2]-90]},n([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,n=na;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,a=ve(e),i=ve(n),o=t.length,l=[],s=[];for(r=0;r=0;--r)p.push(t[l[c[r]][2]]);for(r=+f;rkt)l=l.L;else{if(!((a=i-wa(l,o))>kt)){r>-kt?(e=l.P,n=l):a>-kt?(e=l,n=l.N):e=n=l;break}if(!l.R){e=l;break}l=l.R}var s=ya(t);if(fa.insert(e,s),e||n){if(e===n)return La(e),n=ya(e.site),fa.insert(s,n),s.edge=n.edge=Pa(e.site,s.site),Aa(e),void Aa(n);if(n){La(e),La(n);var c=e.site,u=c.x,f=c.y,d=t.x-u,p=t.y-f,h=n.site,g=h.x-u,v=h.y-f,y=2*(d*v-p*g),m=d*d+p*p,x=g*g+v*v,b={x:(v*m-p*x)/y+u,y:(d*x-g*m)/y+f};Oa(n.edge,c,h,b),s.edge=Pa(c,t,null,b),n.edge=Pa(t,h,null,b),Aa(e),Aa(n)}else s.edge=Pa(e.site,s.site)}}function _a(t,e){var n=t.site,r=n.x,a=n.y,i=a-e;if(!i)return r;var o=t.P;if(!o)return-1/0;var l=(n=o.site).x,s=n.y,c=s-e;if(!c)return l;var u=l-r,f=1/i-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-i/2)))/f+r:(r+l)/2}function wa(t,e){var n=t.N;if(n)return _a(n,e);var r=t.site;return r.y===e?r.x:1/0}function ka(t){this.site=t,this.edges=[]}function Ma(t,e){return e.angle-t.angle}function Ta(){Ea(this),this.x=this.y=this.arc=this.site=this.cy=null}function Aa(t){var e=t.P,n=t.N;if(e&&n){var r=e.site,a=t.site,i=n.site;if(r!==i){var o=a.x,l=a.y,s=r.x-o,c=r.y-l,u=i.x-o,f=2*(s*(v=i.y-l)-c*u);if(!(f>=-Mt)){var d=s*s+c*c,p=u*u+v*v,h=(v*d-c*p)/f,g=(s*p-u*d)/f,v=g+l,y=ga.pop()||new Ta;y.arc=t,y.site=a,y.x=h+o,y.y=v+Math.sqrt(h*h+g*g),y.cy=v,t.circle=y;for(var m=null,x=pa._;x;)if(y.y=l)return;if(d>h){if(i){if(i.y>=c)return}else i={x:v,y:s};n={x:v,y:c}}else{if(i){if(i.y1)if(d>h){if(i){if(i.y>=c)return}else i={x:(s-a)/r,y:s};n={x:(c-a)/r,y:c}}else{if(i){if(i.y=l)return}else i={x:o,y:r*o+a};n={x:l,y:r*l+a}}else{if(i){if(i.xkt||m(a-n)>kt)&&(l.splice(o,0,new za((y=i.site,x=u,b=m(r-f)kt?{x:f,y:m(e-f)kt?{x:m(n-h)kt?{x:d,y:m(e-d)kt?{x:m(n-p)=n&&c.x<=a&&c.y>=r&&c.y<=o?[[n,o],[a,o],[a,r],[n,r]]:[]).point=t[l]}),e}function l(t){return t.map(function(t,e){return{x:Math.round(r(t,e)/kt)*kt,y:Math.round(a(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Fa(l(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fa(l(t)).cells.forEach(function(n,r){for(var a,i,o,l,s=n.site,c=n.edges.sort(Ma),u=-1,f=c.length,d=c[f-1].edge,p=d.l===s?d.r:d.l;++ui&&(a=e.slice(i,a),l[o]?l[o]+=a:l[++o]=a),(n=n[0])===(r=r[0])?l[o]?l[o]+=r:l[++o]=r:(l[++o]=null,s.push({i:o,x:Ga(n,r)})),i=Xa.lastIndex;return ig&&(g=s.x),s.y>v&&(v=s.y),c.push(s.x),u.push(s.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-h;function M(t,e,n,r,a,i,o,l){if(!isNaN(n)&&!isNaN(r))if(t.leaf){var s=t.x,c=t.y;if(null!=s)if(m(s-n)+m(c-r)<.01)T(t,e,n,r,a,i,o,l);else{var u=t.point;t.x=t.y=t.point=null,T(t,u,s,c,a,i,o,l),T(t,e,n,r,a,i,o,l)}else t.x=n,t.y=r,t.point=e}else T(t,e,n,r,a,i,o,l)}function T(t,e,n,r,a,i,o,l){var s=.5*(a+o),c=.5*(i+l),u=n>=s,f=r>=c,d=f<<1|u;t.leaf=!1,u?a=s:o=s,f?i=c:l=c,M(t=t.nodes[d]||(t.nodes[d]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(A,t,+y(t,++f),+x(t,f),p,h,g,v)}}),e,n,r,a,i,o,l)}w>k?v=h+w:g=p+k;var A={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(A,t,+y(t,++f),+x(t,f),p,h,g,v)}};if(A.visit=function(t){!function t(e,n,r,a,i,o){if(!e(n,r,a,i,o)){var l=.5*(r+i),s=.5*(a+o),c=n.nodes;c[0]&&t(e,c[0],r,a,l,s),c[1]&&t(e,c[1],l,a,i,s),c[2]&&t(e,c[2],r,s,l,o),c[3]&&t(e,c[3],l,s,i,o)}}(t,A,p,h,g,v)},A.find=function(t){return function(t,e,n,r,a,i,o){var l,s=1/0;return function t(c,u,f,d,p){if(!(u>i||f>o||d=_)<<1|e>=b,k=w+4;w=0&&!(r=t.interpolators[a](e,n)););return r}function Ja(t,e){var n,r=[],a=[],i=t.length,o=e.length,l=Math.min(t.length,e.length);for(n=0;n=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function ii(t){return 1-Math.cos(t*St)}function oi(t){return Math.pow(2,10*(t-1))}function li(t){return 1-Math.sqrt(1-t*t)}function si(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ci(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function ui(t){var e,n,r,a=[t.a,t.b],i=[t.c,t.d],o=di(a),l=fi(a,i),s=di(((e=i)[0]+=(r=-l)*(n=a)[0],e[1]+=r*n[1],e))||0;a[0]*i[1]=0?t.slice(0,r):t,i=r>=0?t.slice(r+1):"in";return a=$a.get(a)||Qa,i=Ka.get(i)||O,e=i(a.apply(null,n.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,n){e=t.hcl(e),n=t.hcl(n);var r=e.h,a=e.c,i=e.l,o=n.h-r,l=n.c-a,s=n.l-i;isNaN(l)&&(l=0,a=isNaN(a)?n.c:a);isNaN(o)?(o=0,r=isNaN(r)?n.h:r):o>180?o-=360:o<-180&&(o+=360);return function(t){return Yt(r+o*t,a+l*t,i+s*t)+""}},t.interpolateHsl=function(e,n){e=t.hsl(e),n=t.hsl(n);var r=e.h,a=e.s,i=e.l,o=n.h-r,l=n.s-a,s=n.l-i;isNaN(l)&&(l=0,a=isNaN(a)?n.s:a);isNaN(o)?(o=0,r=isNaN(r)?n.h:r):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ut(r+o*t,a+l*t,i+s*t)+""}},t.interpolateLab=function(e,n){e=t.lab(e),n=t.lab(n);var r=e.l,a=e.a,i=e.b,o=n.l-r,l=n.a-a,s=n.b-i;return function(t){return te(r+o*t,a+l*t,i+s*t)+""}},t.interpolateRound=ci,t.transform=function(e){var n=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){n.setAttribute("transform",t);var e=n.transform.baseVal.consolidate()}return new ui(e?e.matrix:pi)})(e)},ui.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pi={a:1,b:0,c:0,d:1,e:0,f:0};function hi(t){return t.length?t.pop()+",":""}function gi(e,n){var r=[],a=[];return e=t.transform(e),n=t.transform(n),function(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push("translate(",null,",",null,")");r.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&n.push("translate("+e+")")}(e.translate,n.translate,r,a),function(t,e,n,r){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(hi(n)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&n.push(hi(n)+"rotate("+e+")")}(e.rotate,n.rotate,r,a),function(t,e,n,r){t!==e?r.push({i:n.push(hi(n)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&n.push(hi(n)+"skewX("+e+")")}(e.skew,n.skew,r,a),function(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push(hi(n)+"scale(",null,",",null,")");r.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(hi(n)+"scale("+e+")")}(e.scale,n.scale,r,a),e=n=null,function(t){for(var e,n=-1,i=a.length;++n0?r=t:(e.c=null,e.t=NaN,e=null,s.end({type:"end",alpha:r=0})):t>0&&(s.start({type:"start",alpha:r=t}),e=Me(l.tick)),l):r},l.start=function(){var t,e,n,r=y.length,s=m.length,u=c[0],h=c[1];for(t=0;t=0;)n.push(a[r])}function Ci(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(u=c[s]),u.parent=i,u.depth=i.depth+1;n&&(i.value=0),i.children=c}else n&&(i.value=+n.call(r,i,i.depth)||0),delete i.children;return Ci(a,function(e){var r,a;t&&(r=e.children)&&r.sort(t),n&&(a=e.parent)&&(a.value+=e.value)}),l}return r.sort=function(e){return arguments.length?(t=e,r):t},r.children=function(t){return arguments.length?(e=t,r):e},r.value=function(t){return arguments.length?(n=t,r):n},r.revalue=function(t){return n&&(Si(t,function(t){t.children&&(t.value=0)}),Ci(t,function(t){var e;t.children||(t.value=+n.call(r,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},r},t.layout.partition=function(){var e=t.layout.hierarchy(),n=[1,1];function r(t,r){var a=e.call(this,t,r);return function t(e,n,r,a){var i=e.children;if(e.x=n,e.y=e.depth*a,e.dx=r,e.dy=a,i&&(o=i.length)){var o,l,s,c=-1;for(r=e.value?r/e.value:0;++cl&&(l=r),o.push(r)}for(n=0;na&&(r=n,a=e);return r}function Vi(t){return t.reduce(Ui,0)}function Ui(t,e){return t+e[1]}function Gi(t,e){return Zi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Zi(t,e){for(var n=-1,r=+t[0],a=(t[1]-r)/e,i=[];++n<=e;)i[n]=a*n+r;return i}function Yi(e){return[t.min(e),t.max(e)]}function Xi(t,e){return t.value-e.value}function Wi(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function Qi(t,e){var n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return.999*a*a>n*n+r*r}function $i(t){if((e=t.children)&&(s=e.length)){var e,n,r,a,i,o,l,s,c=1/0,u=-1/0,f=1/0,d=-1/0;if(e.forEach(Ki),(n=e[0]).x=-n.r,n.y=0,x(n),s>1&&((r=e[1]).x=r.r,r.y=0,x(r),s>2))for(eo(n,r,a=e[2]),x(a),Wi(n,a),n._pack_prev=a,Wi(a,r),r=n._pack_next,i=3;i0)for(o=-1;++o=f[0]&&s<=f[1]&&((l=c[t.bisect(d,s,1,h)-1]).y+=g,l.push(i[o]));return c}return i.value=function(t){return arguments.length?(n=t,i):n},i.range=function(t){return arguments.length?(r=ve(t),i):r},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Zi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,n=t.layout.hierarchy().sort(Xi),r=0,a=[1,1];function i(t,i){var o=n.call(this,t,i),l=o[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,Ci(l,function(t){t.r=+u(t.value)}),Ci(l,$i),r){var f=r*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;Ci(l,function(t){t.r+=f}),Ci(l,$i),Ci(l,function(t){t.r-=f})}return function t(e,n,r,a){var i=e.children;e.x=n+=a*e.x;e.y=r+=a*e.y;e.r*=a;if(i)for(var o=-1,l=i.length;++op.x&&(p=t),t.depth>h.depth&&(h=t)});var g=n(d,p)/2-d.x,v=r[0]/(p.x+n(p,d)/2+g),y=r[1]/(h.depth||1);Si(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*y})}return c}function o(t){var e=t.children,r=t.parent.children,a=t.i?r[t.i-1]:null;if(e.length){!function(t){var e,n=0,r=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+n(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+n(t._,a._));t.parent.A=function(t,e,r){if(e){for(var a,i=t,o=t,l=e,s=i.parent.children[0],c=i.m,u=o.m,f=l.m,d=s.m;l=ao(l),i=ro(i),l&&i;)s=ro(s),(o=ao(o)).a=t,(a=l.z+f-i.z-c+n(l._,i._))>0&&(io(oo(l,t,r),t,a),c+=a,u+=a),f+=l.m,c+=i.m,d+=s.m,u+=o.m;l&&!ao(o)&&(o.t=l,o.m+=f-u),i&&!ro(s)&&(s.t=i,s.m+=c-d,r=t)}return r}(t,a,t.parent.A||r[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=r[0],t.y=t.depth*r[1]}return i.separation=function(t){return arguments.length?(n=t,i):n},i.size=function(t){return arguments.length?(a=null==(r=t)?s:null,i):a?null:r},i.nodeSize=function(t){return arguments.length?(a=null==(r=t)?null:s,i):a?r:null},Li(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),n=no,r=[1,1],a=!1;function i(i,o){var l,s=e.call(this,i,o),c=s[0],u=0;Ci(c,function(e){var r=e.children;r&&r.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(r),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(r)):(e.x=l?u+=n(e,l):0,e.y=0,l=e)});var f=function t(e){var n=e.children;return n&&n.length?t(n[0]):e}(c),d=function t(e){var n,r=e.children;return r&&(n=r.length)?t(r[n-1]):e}(c),p=f.x-n(f,d)/2,h=d.x+n(d,f)/2;return Ci(c,a?function(t){t.x=(t.x-c.x)*r[0],t.y=(c.y-t.y)*r[1]}:function(t){t.x=(t.x-p)/(h-p)*r[0],t.y=(1-(c.y?t.y/c.y:1))*r[1]}),s}return i.separation=function(t){return arguments.length?(n=t,i):n},i.size=function(t){return arguments.length?(a=null==(r=t),i):a?null:r},i.nodeSize=function(t){return arguments.length?(a=null!=(r=t),i):a?r:null},Li(i,e)},t.layout.treemap=function(){var e,n=t.layout.hierarchy(),r=Math.round,a=[1,1],i=null,o=lo,l=!1,s="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var n,r,a=-1,i=t.length;++a0;)l.push(n=c[a-1]),l.area+=n.area,"squarify"!==s||(r=p(l,g))<=d?(c.pop(),d=r):(l.area-=l.pop().area,h(l,g,i,!1),g=Math.min(i.dx,i.dy),l.length=l.area=0,d=1/0);l.length&&(h(l,g,i,!0),l.length=l.area=0),e.forEach(f)}}function d(t){var e=t.children;if(e&&e.length){var n,r=o(t),a=e.slice(),i=[];for(u(a,r.dx*r.dy/t.value),i.area=0;n=a.pop();)i.push(n),i.area+=n.area,null!=n.z&&(h(i,n.z?r.dx:r.dy,r,!a.length),i.length=i.area=0);e.forEach(d)}}function p(t,e){for(var n,r=t.area,a=0,i=1/0,o=-1,l=t.length;++oa&&(a=n));return e*=e,(r*=r)?Math.max(e*a*c/r,r/(e*i*c)):1/0}function h(t,e,n,a){var i,o=-1,l=t.length,s=n.x,c=n.y,u=e?r(t.area/e):0;if(e==n.dx){for((a||u>n.dy)&&(u=n.dy);++on.dx)&&(u=n.dx);++o1);return t+e*n*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var n=t.random.irwinHall(e);return function(){return n()/e}},irwinHall:function(t){return function(){for(var e=0,n=0;n2?vo:fo,l=a?yi:vi;return i=t(e,n,l,r),o=t(n,e,l,Wa),s}function s(t){return i(t)}s.invert=function(t){return o(t)};s.domain=function(t){return arguments.length?(e=t.map(Number),l()):e};s.range=function(t){return arguments.length?(n=t,l()):n};s.rangeRound=function(t){return s.range(t).interpolate(ci)};s.clamp=function(t){return arguments.length?(a=t,l()):a};s.interpolate=function(t){return arguments.length?(r=t,l()):r};s.ticks=function(t){return bo(e,t)};s.tickFormat=function(t,n){return _o(e,t,n)};s.nice=function(t){return mo(e,t),l()};s.copy=function(){return t(e,n,r,a)};return l()}([0,1],[0,1],Wa,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(n,r,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(r)}function l(t){return a?Math.pow(r,t):-Math.pow(r,-t)}function s(t){return n(o(t))}s.invert=function(t){return l(n.invert(t))};s.domain=function(t){return arguments.length?(a=t[0]>=0,n.domain((i=t.map(Number)).map(o)),s):i};s.base=function(t){return arguments.length?(r=+t,n.domain(i.map(o)),s):r};s.nice=function(){var t=po(i.map(o),a?Math:To);return n.domain(t),i=t.map(l),s};s.ticks=function(){var t=co(i),e=[],n=t[0],s=t[1],c=Math.floor(o(n)),u=Math.ceil(o(s)),f=r%1?2:r;if(isFinite(u-c)){if(a){for(;c0;d--)e.push(l(c)*d);for(c=0;e[c]s;u--);e=e.slice(c,u)}return e};s.tickFormat=function(e,n){if(!arguments.length)return Mo;arguments.length<2?n=Mo:"function"!=typeof n&&(n=t.format(n));var a=Math.max(1,r*e/s.ticks().length);return function(t){var e=t/l(Math.round(o(t)));return e*r0?a[t-1]:n[0],tf?0:1;if(c=Lt)return s(c,p)+(l?s(l,1-p):"")+"Z";var h,g,v,y,m,x,b,_,w,k,M,T,A=0,L=0,S=[];if((y=(+o.apply(this,arguments)||0)/2)&&(v=r===zo?Math.sqrt(l*l+c*c):+r.apply(this,arguments),p||(L*=-1),c&&(L=Et(v/c*Math.sin(y))),l&&(A=Et(v/l*Math.sin(y)))),c){m=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var C=Math.abs(f-u-2*L)<=Tt?0:1;if(L&&Fo(m,x,b,_)===p^C){var P=(u+f)/2;m=c*Math.cos(P),x=c*Math.sin(P),b=_=null}}else m=x=0;if(l){w=l*Math.cos(f-A),k=l*Math.sin(f-A),M=l*Math.cos(u+A),T=l*Math.sin(u+A);var O=Math.abs(u-f+2*A)<=Tt?0:1;if(A&&Fo(w,k,M,T)===1-p^O){var z=(u+f)/2;w=l*Math.cos(z),k=l*Math.sin(z),M=T=null}}else w=k=0;if(d>kt&&(h=Math.min(Math.abs(c-l)/2,+n.apply(this,arguments)))>.001){g=l0?0:1}function jo(t,e,n,r,a){var i=t[0]-e[0],o=t[1]-e[1],l=(a?r:-r)/Math.sqrt(i*i+o*o),s=l*o,c=-l*i,u=t[0]+s,f=t[1]+c,d=e[0]+s,p=e[1]+c,h=(u+d)/2,g=(f+p)/2,v=d-u,y=p-f,m=v*v+y*y,x=n-r,b=u*p-d*f,_=(y<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-b*b)),w=(b*y-v*_)/m,k=(-b*v-y*_)/m,M=(b*y+v*_)/m,T=(-b*v+y*_)/m,A=w-h,L=k-g,S=M-h,C=T-g;return A*A+L*L>S*S+C*C&&(w=M,k=T),[[w-s,k-c],[w*n/x,k*n/x]]}function Bo(t){var e=ea,n=na,r=Yn,a=qo,i=a.key,o=.7;function l(i){var l,s=[],c=[],u=-1,f=i.length,d=ve(e),p=ve(n);function h(){s.push("M",a(t(c),o))}for(;++u1&&a.push("H",r[0]);return a.join("")},"step-before":Uo,"step-after":Go,basis:Xo,"basis-open":function(t){if(t.length<4)return qo(t);var e,n=[],r=-1,a=t.length,i=[0],o=[0];for(;++r<3;)e=t[r],i.push(e[0]),o.push(e[1]);n.push(Wo($o,i)+","+Wo($o,o)),--r;for(;++r9&&(a=3*e/Math.sqrt(a),o[l]=a*n,o[l+1]=a*r));l=-1;for(;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+o[l]*o[l])),i.push([a||0,o[l]*a||0]);return i}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Vo(t){return t.join("L")+"Z"}function Uo(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1){l=e[1],i=t[s],s++,r+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-l[0])+","+(i[1]-l[1])+","+i[0]+","+i[1];for(var c=2;cTt)+",1 "+e}function s(t,e,n,r){return"Q 0,0 "+r}return i.radius=function(t){return arguments.length?(n=ve(t),i):n},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(r=ve(t),i):r},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Hr,e=qr,n=al;function r(r,a){var i=t.call(this,r,a),o=e.call(this,r,a),l=(i.y+o.y)/2,s=[i,{x:i.x,y:l},{x:o.x,y:l},o];return"M"+(s=s.map(n))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return r.source=function(e){return arguments.length?(t=ve(e),r):t},r.target=function(t){return arguments.length?(e=ve(t),r):e},r.projection=function(t){return arguments.length?(n=t,r):n},r},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),n=al,r=e.projection;return e.projection=function(t){return arguments.length?r(function(t){return function(){var e=t.apply(this,arguments),n=e[0],r=e[1]-St;return[n*Math.cos(r),n*Math.sin(r)]}}(n=t)):n},e},t.svg.symbol=function(){var t=ol,e=il;function n(n,r){return(sl.get(t.call(this,n,r))||ll)(e.call(this,n,r))}return n.type=function(e){return arguments.length?(t=ve(e),n):t},n.size=function(t){return arguments.length?(e=ve(t),n):e},n};var sl=t.map({circle:ll,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*ul)),n=e*ul;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cl),n=e*cl/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cl),n=e*cl/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});t.svg.symbolTypes=sl.keys();var cl=Math.sqrt(3),ul=Math.tan(30*Ct);Y.transition=function(t){for(var e,n,r=hl||++yl,a=bl(t),i=[],o=gl||{time:Date.now(),ease:ai,delay:0,duration:250},l=-1,s=this.length;++l0;)c[--d].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[r]:delete t[n],1}f||(i=a.time,o=Me(function(t){var e=f.delay;if(o.t=e+i,e<=t)return d(t-e);o.c=d},0,i),f=u[r]={tween:new b,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++u.count)}vl.call=Y.call,vl.empty=Y.empty,vl.node=Y.node,vl.size=Y.size,t.transition=function(e,n){return e&&e.transition?hl?e.transition(n):e:t.selection().transition(e)},t.transition.prototype=vl,vl.select=function(t){var e,n,r,a=this.id,i=this.namespace,o=[];t=X(t);for(var l=-1,s=this.length;++lrect,.s>rect").attr("width",l[1]-l[0])}function g(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function v(){var f,v,y=this,m=t.select(t.event.target),x=r.of(y,arguments),b=t.select(y),_=m.datum(),w=!/^(n|s)$/.test(_)&&a,k=!/^(e|w)$/.test(_)&&i,M=m.classed("extent"),T=xt(y),A=t.mouse(y),L=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(M||(f=null,A[0]-=l[1],A[1]-=s[1],M=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==M&&(A[0]+=l[1],A[1]+=s[1],M=0,F())});if(t.event.changedTouches?L.on("touchmove.brush",P).on("touchend.brush",z):L.on("mousemove.brush",P).on("mouseup.brush",z),b.interrupt().selectAll("*").interrupt(),M)A[0]=l[0]-A[0],A[1]=s[0]-A[1];else if(_){var S=+/w$/.test(_),C=+/^n/.test(_);v=[l[1-S]-A[0],s[1-C]-A[1]],A[0]=l[S],A[1]=s[C]}else t.event.altKey&&(f=A.slice());function P(){var e=t.mouse(y),n=!1;v&&(e[0]+=v[0],e[1]+=v[1]),M||(t.event.altKey?(f||(f=[(l[0]+l[1])/2,(s[0]+s[1])/2]),A[0]=l[+(e[0]1?{floor:function(e){for(;l(e=t.floor(e));)e=Dl(e-1);return e},ceil:function(e){for(;l(e=t.ceil(e));)e=Dl(+e+1);return e}}:t))},a.ticks=function(t,e){var n=co(a.domain()),r=null==t?i(n,10):"number"==typeof t?i(n,t):!t.range&&[{range:t},e];return r&&(t=r[0],e=r[1]),t.range(n[0],Dl(+n[1]+1),e<1?1:e)},a.tickFormat=function(){return r},a.copy=function(){return zl(e.copy(),n,r)},yo(a,e)}function Dl(t){return new Date(t)}Sl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ol:Pl,Ol.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Ol.toString=Pl.toString,De.second=Ie(function(t){return new Ee(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),De.seconds=De.second.range,De.seconds.utc=De.second.utc.range,De.minute=Ie(function(t){return new Ee(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),De.minutes=De.minute.range,De.minutes.utc=De.minute.utc.range,De.hour=Ie(function(t){var e=t.getTimezoneOffset()/60;return new Ee(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),De.hours=De.hour.range,De.hours.utc=De.hour.utc.range,De.month=Ie(function(t){return(t=De.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),De.months=De.month.range,De.months.utc=De.month.utc.range;var El=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Rl=[[De.second,1],[De.second,5],[De.second,15],[De.second,30],[De.minute,1],[De.minute,5],[De.minute,15],[De.minute,30],[De.hour,1],[De.hour,3],[De.hour,6],[De.hour,12],[De.day,1],[De.day,2],[De.week,1],[De.month,1],[De.month,3],[De.year,1]],Nl=Sl.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Yn]]),Il={range:function(e,n,r){return t.range(Math.ceil(e/r)*r,+n,r).map(Dl)},floor:O,ceil:O};Rl.year=De.year,De.scale=function(){return zl(t.scale.linear(),Rl,Nl)};var Fl=Rl.map(function(t){return[t[0].utc,t[1]]}),jl=Cl.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Yn]]);function Bl(t){return JSON.parse(t.responseText)}function Hl(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Fl.year=De.year.utc,De.scale.utc=function(){return zl(t.scale.linear(),Fl,jl)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return me(t,"application/json",Bl,e)},t.html=function(t,e){return me(t,"text/html",Hl,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],10:[function(t,e,n){(function(r,a){!function(t,r){"object"==typeof n&&"undefined"!=typeof e?e.exports=r():t.ES6Promise=r()}(this,function(){"use strict";function e(t){return"function"==typeof t}var n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,l=void 0,s=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(l?l(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,d="undefined"==typeof self&&"undefined"!=typeof r&&"[object process]"==={}.toString.call(r),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],17:[function(t,e,n){var r={left:0,top:0};e.exports=function(t,e,n){e=e||t.currentTarget||t.srcElement,Array.isArray(n)||(n=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(l=e,l===window||l===document||l===document.body?r:l.getBoundingClientRect());var l;return n[0]=a-o.left,n[1]=i-o.top,n}},{}],18:[function(t,e,n){var r,a=t("./lib/build-log"),i=t("./lib/epsilon"),o=t("./lib/intersecter"),l=t("./lib/segment-chainer"),s=t("./lib/segment-selector"),c=t("./lib/geojson"),u=!1,f=i();function d(t,e,n){var a=r.segments(t),i=r.segments(e),o=n(r.combine(a,i));return r.polygon(o)}r={buildLog:function(t){return!0===t?u=a():!1===t&&(u=!1),!1!==u&&u.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,u);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,u).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:s.union(t.combined,u),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:s.intersect(t.combined,u),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:s.difference(t.combined,u),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:s.differenceRev(t.combined,u),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:s.xor(t.combined,u),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:l(t.segments,f,u),inverted:t.inverted}},polygonFromGeoJSON:function(t){return c.toPolygon(r,t)},polygonToGeoJSON:function(t){return c.fromPolygon(r,f,t)},union:function(t,e){return d(t,e,r.selectUnion)},intersect:function(t,e){return d(t,e,r.selectIntersect)},difference:function(t,e){return d(t,e,r.selectDifference)},differenceRev:function(t,e){return d(t,e,r.selectDifferenceRev)},xor:function(t,e){return d(t,e,r.selectXor)}},"object"==typeof window&&(window.PolyBool=r),e.exports=r},{"./lib/build-log":19,"./lib/epsilon":20,"./lib/geojson":21,"./lib/intersecter":22,"./lib/segment-chainer":24,"./lib/segment-selector":25}],19:[function(t,e,n){e.exports=function(){var t,e=0,n=!1;function r(e,n){return t.list.push({type:e,data:n?JSON.parse(JSON.stringify(n)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return r("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return r("div_seg",{seg:t,pt:e}),r("chop",{seg:t,pt:e})},statusRemove:function(t){return r("pop_seg",{seg:t})},segmentUpdate:function(t){return r("seg_update",{seg:t})},segmentNew:function(t,e){return r("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return r("rem_seg",{seg:t})},tempStatus:function(t,e,n){return r("temp_status",{seg:t,above:e,below:n})},rewind:function(t){return r("rewind",{seg:t})},status:function(t,e,n){return r("status",{seg:t,above:e,below:n})},vert:function(e){return e===n?t:(n=e,r("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),r("log",{txt:t})},reset:function(){return r("reset")},selected:function(t){return r("selected",{segs:t})},chainStart:function(t){return r("chain_start",{seg:t})},chainRemoveHead:function(t,e){return r("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return r("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return r("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return r("chain_match",{index:t})},chainClose:function(t){return r("chain_close",{index:t})},chainAddHead:function(t,e){return r("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return r("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return r("chain_con",{index1:t,index2:e})},chainReverse:function(t){return r("chain_rev",{index:t})},chainJoin:function(t,e){return r("chain_join",{index1:t,index2:e})},done:function(){return r("done")}}}},{}],20:[function(t,e,n){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,n,r){var a=n[0],i=n[1],o=r[0],l=r[1],s=e[0];return(o-a)*(e[1]-i)-(l-i)*(s-a)>=-t},pointBetween:function(e,n,r){var a=e[1]-n[1],i=r[0]-n[0],o=e[0]-n[0],l=r[1]-n[1],s=o*i+a*l;return!(s-t)},pointsSameX:function(e,n){return Math.abs(e[0]-n[0])t!=o-a>t&&(i-c)*(a-u)/(o-u)+c-r>t&&(l=!l),i=c,o=u}return l}};return e}},{}],21:[function(t,e,n){var r={toPolygon:function(t,e){function n(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function n(e){var n=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[n]})}for(var r=n(e[0]),a=1;a0})}function u(t,r){var a=t.seg,i=r.seg,o=a.start,l=a.end,c=i.start,u=i.end;n&&n.checkIntersection(a,i);var f=e.linesIntersect(o,l,c,u);if(!1===f){if(!e.pointsCollinear(o,l,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(l,c))return!1;var d=e.pointsSame(o,c),p=e.pointsSame(l,u);if(d&&p)return r;var h=!d&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(l,c,u);if(d)return g?s(r,l):s(t,u),r;h&&(p||(g?s(r,l):s(t,u)),s(r,o))}else 0===f.alongA&&(-1===f.alongB?s(t,c):0===f.alongB?s(t,f.pt):1===f.alongB&&s(t,u)),0===f.alongB&&(-1===f.alongA?s(r,o):0===f.alongA?s(r,f.pt):1===f.alongA&&s(r,l));return!1}for(var f=[];!i.isEmpty();){var d=i.getHead();if(n&&n.vert(d.pt[0]),d.isStart){n&&n.segmentNew(d.seg,d.primary);var p=c(d),h=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(h){var t=u(d,h);if(t)return t}return!!g&&u(d,g)}n&&n.tempStatus(d.seg,!!h&&h.seg,!!g&&g.seg);var y,m,x=v();if(x)t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=d.seg.myFill,n&&n.segmentUpdate(x.seg),d.other.remove(),d.remove();if(i.getHead()!==d){n&&n.rewind(d.seg);continue}t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=g?g.seg.myFill.above:a,d.seg.myFill.above=m?!d.seg.myFill.below:d.seg.myFill.below):null===d.seg.otherFill&&(y=g?d.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:d.primary?o:a,d.seg.otherFill={above:y,below:y}),n&&n.status(d.seg,!!h&&h.seg,!!g&&g.seg),d.other.status=p.insert(r.node({ev:d}))}else{var b=d.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(l.exists(b.prev)&&l.exists(b.next)&&u(b.prev.ev,b.next.ev),n&&n.statusRemove(b.ev.seg),b.remove(),!d.primary){var _=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=_}f.push(d.seg)}i.getHead().remove()}return n&&n.done(),f}return t?{addRegion:function(t){for(var r,a,i,o=t[t.length-1],s=0;s1)for(var n=1;n1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}if(t=P(t,360),e=P(e,100),n=P(n,100),0===e)r=a=i=n;else{var l=n<.5?n*(1+e):n+e-n*e,s=2*n-l;r=o(s,l,t+1/3),a=o(s,l,t),i=o(s,l,t-1/3)}return{r:255*r,g:255*a,b:255*i}}(e.h,s,u),f=!0,d="hsl"),e.hasOwnProperty("a")&&(i=e.a));var p,h,g;return i=C(i),{ok:f,format:e.format||d,r:o(255,l(a.r,0)),g:o(255,l(a.g,0)),b:o(255,l(a.b,0)),a:i}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=i(100*this._a)/100,this._format=s.format||u.format,this._gradientType=s.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=u.ok,this._tc_id=a++}function u(t,e,n){t=P(t,255),e=P(e,255),n=P(n,255);var r,a,i=l(t,e,n),s=o(t,e,n),c=(i+s)/2;if(i==s)r=a=0;else{var u=i-s;switch(a=c>.5?u/(2-i-s):u/(i+s),i){case t:r=(e-n)/u+(e>1)+720)%360;--e;)r.h=(r.h+a)%360,i.push(c(r));return i}function A(t,e){e=e||6;for(var n=c(t).toHsv(),r=n.h,a=n.s,i=n.v,o=[],l=1/e;e--;)o.push(c({h:r,s:a,v:i})),i=(i+l)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,n,r,a=this.toRgb();return e=a.r/255,n=a.g/255,r=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))},setAlpha:function(t){return this._a=C(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),n=i(100*t.s),r=i(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=i(360*t.h),n=i(100*t.s),r=i(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return d(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,n,r,a){var o=[D(i(t).toString(16)),D(i(e).toString(16)),D(i(n).toString(16)),D(R(r))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*P(this._r,255))+"%",g:i(100*P(this._g,255))+"%",b:i(100*P(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*P(this._r,255))+"%, "+i(100*P(this._g,255))+"%, "+i(100*P(this._b,255))+"%)":"rgba("+i(100*P(this._r,255))+"%, "+i(100*P(this._g,255))+"%, "+i(100*P(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[d(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),n=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var a=c(t);n="#"+p(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0;return e||!r||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(T,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(M,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]="a"===r?t[r]:E(t[r]));t=n}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:s(),g:s(),b:s()})},c.mix=function(t,e,n){n=0===n?0:n||50;var r=c(t).toRgb(),a=c(e).toRgb(),i=n/100;return c({r:(a.r-r.r)*i+r.r,g:(a.g-r.g)*i+r.g,b:(a.b-r.b)*i+r.b,a:(a.a-r.a)*i+r.a})},c.readability=function(e,n){var r=c(e),a=c(n);return(t.max(r.getLuminance(),a.getLuminance())+.05)/(t.min(r.getLuminance(),a.getLuminance())+.05)},c.isReadable=function(t,e,n){var r,a,i=c.readability(t,e);switch(a=!1,(r=function(t){var e,n;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==n&&"large"!==n&&(n="small");return{level:e,size:n}}(n)).level+r.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},c.mostReadable=function(t,e,n){var r,a,i,o,l=null,s=0;a=(n=n||{}).includeFallbackColors,i=n.level,o=n.size;for(var u=0;us&&(s=r,l=c(e[u]));return c.isReadable(t,l,{level:i,size:o})||!a?l:(n.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],n))};var L=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=c.hexNames=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}(L);function C(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function P(e,n){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(n,l(0,parseFloat(e))),r&&(e=parseInt(e*n,10)/100),t.abs(e-n)<1e-6?1:e%n/parseFloat(n)}function O(t){return o(1,l(0,t))}function z(t){return parseInt(t,16)}function D(t){return 1==t.length?"0"+t:""+t}function E(t){return t<=1&&(t=100*t+"%"),t}function R(e){return t.round(255*parseFloat(e)).toString(16)}function N(t){return z(t)/255}var I,F,j,B=(F="[\\s|\\(]+("+(I="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",j="[\\s|\\(]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",{CSS_UNIT:new RegExp(I),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+j),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+j),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+j),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function H(t){return!!B.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],28:[function(t,e,n){var r;r=this,function(t){"use strict";var e=function(t){return t},n=function(t){if(null==(n=t.transform))return e;var n,r,a,i=n.scale[0],o=n.scale[1],l=n.translate[0],s=n.translate[1];return function(t,e){return e||(r=a=0),t[0]=(r+=t[0])*i+l,t[1]=(a+=t[1])*o+s,t}},r=function(t){var e=t.bbox;function r(t){s[0]=t[0],s[1]=t[1],l(s),s[0]f&&(f=s[0]),s[1]d&&(d=s[1])}function a(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(a);break;case"Point":r(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(r)}}if(!e){var i,o,l=n(t),s=new Array(2),c=1/0,u=c,f=-c,d=-c;for(o in t.arcs.forEach(function(t){for(var e=-1,n=t.length;++ef&&(f=s[0]),s[1]d&&(d=s[1])}),t.objects)a(t.objects[o]);e=t.bbox=[c,u,f,d]}return e},a=function(t,e){for(var n,r=t.length,a=r-e;a<--r;)n=t[a],t[a++]=t[r],t[r]=n};function i(t,e){var n=e.id,r=e.bbox,a=null==e.properties?{}:e.properties,i=o(t,e);return null==n&&null==r?{type:"Feature",properties:a,geometry:i}:null==r?{type:"Feature",id:n,properties:a,geometry:i}:{type:"Feature",id:n,bbox:r,properties:a,geometry:i}}function o(t,e){var r=n(t),i=t.arcs;function o(t,e){e.length&&e.pop();for(var n=i[t<0?~t:t],o=0,l=n.length;o1)r=function(t,e,n){var r,a=[],i=[];function o(t){var e=t<0?~t:t;(i[e]||(i[e]=[])).push({i:t,g:r})}function l(t){t.forEach(o)}function s(t){t.forEach(l)}return function t(e){switch(r=e,e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"LineString":l(e.arcs);break;case"MultiLineString":case"Polygon":s(e.arcs);break;case"MultiPolygon":e.arcs.forEach(s)}}(e),i.forEach(null==n?function(t){a.push(t[0].i)}:function(t){n(t[0].g,t[t.length-1].g)&&a.push(t[0].i)}),a}(0,e,n);else for(a=0,r=new Array(i=t.arcs.length);a1)for(var i,o,c=1,u=s(a[0]);cu&&(o=a[0],a[0]=a[c],a[c]=o,u=i);return a})}}var u=function(t,e){for(var n=0,r=t.length;n>>1;t[a]=2))throw new Error("n must be \u22652");if(t.transform)throw new Error("already quantized");var n,a=r(t),i=a[0],o=(a[2]-i)/(e-1)||1,l=a[1],s=(a[3]-l)/(e-1)||1;function c(t){t[0]=Math.round((t[0]-i)/o),t[1]=Math.round((t[1]-l)/s)}function u(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(u);break;case"Point":c(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(c)}}for(n in t.arcs.forEach(function(t){for(var e,n,r,a=1,c=1,u=t.length,f=t[0],d=f[0]=Math.round((f[0]-i)/o),p=f[1]=Math.round((f[1]-l)/s);a0||n.explicitOff.length>0},onClick:function(t,e){var n,l,s=o(t,e),c=s.on,u=s.off.concat(s.explicitOff),f={},d=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(n=0;n2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var V=!1,U=["x","y"],G=0;G1)&&(K===$?((st=tt.r2fraction(e["a"+Q]))<0||st>1)&&(V=!0):V=!0),Z=tt._offset+tt.r2p(e[Q]),W=.5}else"x"===Q?(X=e[Q],Z=b.l+b.w*X):(X=1-e[Q],Z=b.t+b.h*X),W=e.showarrow?.5:X;if(e.showarrow){lt.head=Z;var ct=e["a"+Q];J=nt*q(.5,e.xanchor)-rt*q(.5,e.yanchor),K===$?(lt.tail=tt._offset+tt.r2p(ct),Y=J):(lt.tail=Z+ct,Y=J+ct),lt.text=lt.tail+J;var ut=x["x"===Q?"width":"height"];if("paper"===$&&(lt.head=o.constrain(lt.head,1,ut-1)),"pixel"===K){var ft=-Math.max(lt.tail-3,lt.text),dt=Math.min(lt.tail+3,lt.text)-ut;ft>0?(lt.tail+=ft,lt.text+=ft):dt>0&&(lt.tail-=dt,lt.text-=dt)}lt.tail+=ot,lt.head+=ot}else Y=J=at*q(W,it),lt.text=Z+J;lt.text+=ot,J+=ot,Y+=ot,e["_"+Q+"padplus"]=at/2+Y,e["_"+Q+"padminus"]=at/2-Y,e["_"+Q+"size"]=at,e["_"+Q+"shift"]=J}if(t._dragging||!V){var pt=0,ht=0;if("left"!==e.align&&(pt=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(ht=(z-m)*("middle"===e.valign?.5:1)),u)r.select("svg").attr({x:N+pt-1,y:N+ht}).call(c.setClipUrl,F?A:null);else{var gt=N+ht-h.top,vt=N+pt-h.left;H.call(f.positionText,vt,gt).call(c.setClipUrl,F?A:null)}j.select("rect").call(c.setRect,N,N,w,z),I.call(c.setRect,E/2,E/2,R-E,B-E),D.call(c.setTranslate,Math.round(L.x.text-R/2),Math.round(L.y.text-B/2)),P.attr({transform:"rotate("+S+","+L.x.text+","+L.y.text+")"});var yt,mt=function(n,r){C.selectAll(".annotation-arrow-g").remove();var u=L.x.head,f=L.y.head,d=L.x.tail+n,h=L.y.tail+r,y=L.x.text+n,m=L.y.text+r,x=o.rotationXYMatrix(S,y,m),w=o.apply2DTransform(x),A=o.apply2DTransform2(x),O=+I.attr("width"),z=+I.attr("height"),E=y-.5*O,R=E+O,N=m-.5*z,F=N+z,j=[[E,N,E,F],[E,F,R,F],[R,F,R,N],[R,N,E,N]].map(A);if(!j.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){j.forEach(function(t){var e=o.segmentsIntersect(d,h,u,f,t[0],t[1],t[2],t[3]);e&&(d=e.x,h=e.y)});var B=e.arrowwidth,H=e.arrowcolor,q=e.arrowside,V=C.append("g").style({opacity:s.opacity(H)}).classed("annotation-arrow-g",!0),U=V.append("path").attr("d","M"+d+","+h+"L"+u+","+f).style("stroke-width",B+"px").call(s.stroke,s.rgb(H));if(g(U,q,e),_.annotationPosition&&U.node().parentNode&&!i){var G=u,Z=f;if(e.standoff){var Y=Math.sqrt(Math.pow(u-d,2)+Math.pow(f-h,2));G+=e.standoff*(d-u)/Y,Z+=e.standoff*(h-f)/Y}var X,W,J=V.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(d-G)+","+(h-Z),transform:"translate("+G+","+Z+")"}).style("stroke-width",B+6+"px").call(s.stroke,"rgba(0,0,0,0)").call(s.fill,"rgba(0,0,0,0)");p.init({element:J.node(),gd:t,prepFn:function(){var t=c.getTranslate(D);X=t.x,W=t.y,l&&l.autorange&&k(l._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,n){var r=w(X,W),a=r[0]+t,i=r[1]+n;D.call(c.setTranslate,a,i),M("x",l?l.p2r(l.r2p(e.x)+t):e.x+t/b.w),M("y",v?v.p2r(v.r2p(e.y)+n):e.y-n/b.h),e.axref===e.xref&&M("ax",l.p2r(l.r2p(e.ax)+t)),e.ayref===e.yref&&M("ay",v.p2r(v.r2p(e.ay)+n)),V.attr("transform","translate("+t+","+n+")"),P.attr({transform:"rotate("+S+","+a+","+i+")"})},doneFn:function(){a.call("relayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&mt(0,0),O)p.init({element:D.node(),gd:t,prepFn:function(){yt=P.attr("transform")},moveFn:function(t,n){var r="pointer";if(e.showarrow)e.axref===e.xref?M("ax",l.p2r(l.r2p(e.ax)+t)):M("ax",e.ax+t),e.ayref===e.yref?M("ay",v.p2r(v.r2p(e.ay)+n)):M("ay",e.ay+n),mt(t,n);else{if(i)return;var a,o;if(l)a=l.p2r(l.r2p(e.x)+t);else{var s=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-s/2;a=p.align(c+t/b.w,s,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+n);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-n/b.h,u,0,1,e.yanchor)}M("x",a),M("y",o),l&&v||(r=p.getCursor(l?.5:a,v?.5:o,e.xanchor,e.yanchor))}P.attr({transform:"translate("+t+","+n+")"+yt}),d(D,r)},doneFn:function(){d(D),a.call("relayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else D.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var n=0;n=0,v=e.indexOf("end")>=0,y=f.backoff*p+n.standoff,m=d.backoff*h+n.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},l={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-l.x,b=o.y-l.y;if(c=(s=Math.atan2(b,x))+Math.PI,y&&m&&y+m>Math.sqrt(x*x+b*b))return void O();if(y){if(y*y>x*x+b*b)return void O();var _=y*Math.cos(s),w=y*Math.sin(s);l.x+=_,l.y+=w,t.attr({x2:l.x,y2:l.y})}if(m){if(m*m>x*x+b*b)return void O();var k=m*Math.cos(s),M=m*Math.sin(s);o.x-=k,o.y-=M,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var T=u.getTotalLength(),A="";if(T1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+l+'"]').remove():(s._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(s.x)*n[0],e.yaxis.r2l(s.y)*n[1],e.zaxis.r2l(s.z)*n[2]]),r(t.graphDiv,s,l,t.id,s._xa,s._ya))}}},{"../../plots/gl3d/project":248,"../annotations/draw":36}],43:[function(t,e,n){"use strict";var r=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var n=r.subplotsRegistry.gl3d;if(!n)return;for(var i=n.attrRegex,o=Object.keys(t),l=0;l=0))return t;if(3===o)r[o]>1&&(r[o]=1);else if(r[o]>=1)return t}var l=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return i?"rgba("+l+", "+r[3]+")":"rgb("+l+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(r(t))},i.opacity=function(t){return t?r(t).getAlpha():0},i.addOpacity=function(t,e){var n=r(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},i.combine=function(t,e){var n=r(t).toRgb();if(1===n.a)return r(t).toRgbString();var a=r(e||s).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-n.a)+n.r*n.a,g:i.g*(1-n.a)+n.g*n.a,b:i.b*(1-n.a)+n.b*n.a};return r(o).toRgbString()},i.contrast=function(t,e,n){var a=r(t);return 1!==a.getAlpha()&&(a=r(i.combine(t,s))),(a.isDark()?e?a.lighten(e):s:n?a.darken(n):l).toString()},i.stroke=function(t,e){var n=r(e);t.style({stroke:i.tinyRGB(n),"stroke-opacity":n.getAlpha()})},i.fill=function(t,e){var n=r(e);t.style({fill:i.tinyRGB(n),"fill-opacity":n.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,n,r,a,o=Object.keys(t);for(e=0;e0?L>=E:L<=E));S++)L>N&&L0?L>=E:L<=E));S++)L>C[0]&&L1){var it=Math.pow(10,Math.floor(Math.log(at)/Math.LN10));nt*=it*c.roundUp(at/it,[2,5,10]),(Math.abs(n.levels.start)/n.levels.size+1e-6)%1<2e-6&&(tt.tick0=0)}tt.dtick=nt}tt.domain=[J+Y,J+U-Y],tt.setScale();var ot=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(M.colorbar,!0).each(function(){var t=r.select(this);t.append("rect").classed(M.cbbg,!0),t.append("g").classed(M.cbfills,!0),t.append("g").classed(M.cblines,!0),t.append("g").classed(M.cbaxis,!0).classed(M.crisp,!0),t.append("g").classed(M.cbtitleunshift,!0).append("g").classed(M.cbtitle,!0),t.append("rect").classed(M.cboutline,!0),t.select(".cbtitle").datum(0)})});ot.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var lt=ot.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")");tt._axislayer=ot.select(".cbaxis");var st=0;if(-1!==["top","bottom"].indexOf(n.titleside)){var ct,ut=k.l+(n.x+G)*k.w,ft=tt.titlefont.size;ct="top"===n.titleside?(1-(J+U-Y))*k.h+k.t+3+.75*ft:(1-(J+Y))*k.h+k.t-3-.25*ft,yt(tt._id+"title",{attributes:{x:ut,y:ct,"text-anchor":"start"}})}var dt,pt,ht,gt=c.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(n.titleside)){var i=ot.select(".cbtitle"),o=i.select("text"),s=[-n.outlinewidth/2,n.outlinewidth/2],u=i.select(".h"+tt._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),u?(st=d.bBox(u).height)>f&&(s[1]-=(st-f)/2):o.node()&&!o.classed(M.jsPlaceholder)&&(st=d.bBox(o.node()).height),st){if(st+=5,"top"===n.titleside)tt.domain[1]-=st/k.h,s[1]*=-1;else{tt.domain[0]+=st/k.h;var p=g.lineCount(o);s[1]+=(1-p)*f}i.attr("transform","translate("+s+")"),tt.setScale()}}ot.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-tt.domain[1]))+")"),tt._axislayer.attr("transform","translate(0,"+Math.round(-k.t)+")");var h=ot.select(".cbfills").selectAll("rect.cbfill").data(O);h.enter().append("rect").classed(M.cbfill,!0).style("stroke","none"),h.exit().remove();var m=C.map(tt.c2p).map(Math.round).sort(function(t,e){return t-e});h.each(function(i,o){var l=[0===o?C[0]:(O[o]+O[o-1])/2,o===O.length-1?C[1]:(O[o]+O[o+1])/2].map(tt.c2p).map(Math.round);l[1]=c.constrain(l[1]+(l[1]>l[0])?1:-1,m[0],m[1]);var s=r.select(this).attr({x:X,width:Math.max(H,2),y:r.min(l),height:Math.max(r.max(l)-r.min(l),2)});if(n.fillgradient)d.gradient(s,t,e,"vertical",n.fillgradient,"fill");else{var u=D(i).replace("e-","");s.attr("fill",a(u).toHexString())}});var x=ot.select(".cblines").selectAll("path.cbline").data(n.line.color&&n.line.width?P:[]);return x.enter().append("path").classed(M.cbline,!0),x.exit().remove(),x.each(function(t){r.select(this).attr("d","M"+X+","+(Math.round(tt.c2p(t))+n.line.width/2%1)+"h"+H).call(d.lineGroupStyle,n.line.width,z(t),n.line.dash)}),tt._axislayer.selectAll("g."+tt._id+"tick,path").remove(),tt._pos=X+H+(n.outlinewidth||0)/2-("outside"===n.ticks?1:0),tt.side="right",c.syncOrAsync([function(){return l.doTicksSingle(t,tt,!0)},function(){if(-1===["top","bottom"].indexOf(n.titleside)){var e=tt.titlefont.size,a=tt._offset+tt._length/2,i=k.l+(tt.position||0)*k.w+("right"===tt.side?10+e*(tt.showticklabels?1:.5):-10-e*(tt.showticklabels?.5:0));yt("h"+tt._id+"title",{avoid:{selection:r.select(t).selectAll("g."+tt._id+"tick"),side:n.titleside,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var r=H+n.outlinewidth/2+d.bBox(tt._axislayer.node()).width;if((F=lt.select("text")).node()&&!F.classed(M.jsPlaceholder)){var a,o=lt.select(".h"+tt._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(n.titleside)?d.bBox(o).width:d.bBox(lt.node()).right-X-k.l,r=Math.max(r,a)}var l=2*n.xpad+r+n.borderwidth+n.outlinewidth/2,s=Q-$;ot.select(".cbbg").attr({x:X-n.xpad-(n.borderwidth+n.outlinewidth)/2,y:$-Z,width:Math.max(l,2),height:Math.max(s+2*Z,2)}).call(p.fill,n.bgcolor).call(p.stroke,n.bordercolor).style({"stroke-width":n.borderwidth}),ot.selectAll(".cboutline").attr({x:X,y:$+n.ypad+("top"===n.titleside?st:0),width:Math.max(H,2),height:Math.max(s-2*n.ypad-st,2)}).call(p.stroke,n.outlinecolor).style({fill:"None","stroke-width":n.outlinewidth});var c=({center:.5,right:1}[n.xanchor]||0)*l;ot.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=m[n.yanchor],h=x[n.yanchor];"pixels"===n.lenmode?(u.y=n.y,u.t=s*f,u.b=s*h):(u.t=u.b=0,u.yt=n.y+n.len*f,u.yb=n.y-n.len*h);var g=m[n.xanchor],v=x[n.xanchor];if("pixels"===n.thicknessmode)u.x=n.x,u.l=l*g,u.r=l*v;else{var y=l-H;u.l=y*g,u.r=y*v,u.xl=n.x-n.thickness*g,u.xr=n.x+n.thickness*v}i.autoMargin(t,e,u)}],t);if(gt&>.then&&(t._promises||[]).push(gt),t._context.edits.colorbarPosition)s.init({element:ot.node(),gd:t,prepFn:function(){dt=ot.attr("transform"),f(ot)},moveFn:function(t,e){ot.attr("transform",dt+" translate("+t+","+e+")"),pt=s.align(W+t/k.w,q,0,1,n.xanchor),ht=s.align(J-e/k.h,U,0,1,n.yanchor);var r=s.getCursor(pt,ht,n.xanchor,n.yanchor);f(ot,r)},doneFn:function(){f(ot),void 0!==pt&&void 0!==ht&&o.call("restyle",t,{"colorbar.x":pt,"colorbar.y":ht},A().index)}});return gt}function vt(t,e){return c.coerce(K,tt,w,t,e)}function yt(e,n){var r=A(),a="colorbar.title",i=r._module.colorbar.container;i&&(a=i+"."+a);var o={propContainer:tt,propName:a,traceIndex:r.index,placeholder:v._dfltTitle.colorbar,containerGroup:ot.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;ot.selectAll("."+l+",."+l+"-math-group").remove(),h.draw(t,e,u(o,n||{}))}v._infolayer.selectAll("g."+e).remove()}function A(){var n,r,a=e.substr(2);for(n=0;n=0?a.Reds:a.Blues,l.reversescale?i(m):m),s.autocolorscale||f("autocolorscale",!1))}},{"../../lib":165,"./flip_scale":57,"./scales":64}],54:[function(t,e,n){"use strict";var r=t("./scales");e.exports=r.RdBu},{"./scales":64}],55:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),i=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,n,c,u){var f,d=u.prefix,p=u.cLetter,h=d.slice(0,d.length-1),g=d?a.nestedProperty(t,h).get()||{}:t,v=d?a.nestedProperty(e,h).get()||{}:e,y=g[p+"min"],m=g[p+"max"],x=g.colorscale;c(d+p+"auto",!(r(y)&&r(m)&&y=0;a--,i++)e=t[a],r[i]=[1-e[0],e[1]];return r}},{}],58:[function(t,e,n){"use strict";var r=t("./scales"),a=t("./default_scale"),i=t("./is_valid_scale_array");e.exports=function(t,e){if(e||(e=a),!t)return e;function n(){try{t=r[t]||JSON.parse(t)}catch(n){t=e}}return"string"==typeof t&&(n(),"string"==typeof t&&n()),i(t)?t:e}},{"./default_scale":54,"./is_valid_scale_array":62,"./scales":64}],59:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),i=t("./is_valid_scale");e.exports=function(t,e){var n=e?a.nestedProperty(t,e).get()||{}:t,o=n.color,l=!1;if(a.isArrayOrTypedArray(o))for(var s=0;s4/3-l?o:l}},{}],66:[function(t,e,n){"use strict";var r=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,i){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:r.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":165}],67:[function(t,e,n){"use strict";var r=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),l=t("../../lib"),s=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function d(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return r(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,n,r,f,h,g,v,y,m=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;m._mouseDownTime||(m._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,n){return Math.abs(t)b&&(x=Math.max(x-1,1)),m._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!y){var n;try{n=new MouseEvent("click",e)}catch(t){var r=p(e);(n=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,r[0],r[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(n)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(m),m._dragged=!1}else m._dragged=!1}},u.coverSlip=d},{"../../constants/interactions":144,"../../lib":165,"../../plots/cartesian/constants":216,"../../registry":259,"./align":65,"./cursor":66,"./unhover":68,"has-hover":13,"has-passive-events":14,"mouse-event-offset":17}],68:[function(t,e,n){"use strict";var r=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),l=e.exports={};l.wrapped=function(t,e,n){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),l.raw(t,e,n)},l.raw=function(t,e){var n=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===r.triggerHandler(t,"plotly_beforehover",e)||(n._hoverlayer.selectAll("g").remove(),n._hoverlayer.selectAll("line").remove(),n._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":156,"../../lib/get_graph_div":163,"../../lib/throttle":187,"../fx/constants":82}],69:[function(t,e,n){"use strict";n.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],70:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,h=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,n,r){c.isPlainObject(e)&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(l.fill,r)},v.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},v.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},v.setRect=function(t,e,n,r,a){t.call(v.setPosition,e,n).call(v.setSize,r,a)},v.translatePoint=function(t,e,n,r){var i=n.c2p(t.x),o=r.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,n){t.each(function(t){var a=r.select(this);v.translatePoint(t,a,e,n)})},v.hideOutsideRangePoint=function(t,e,n,r,a,i){e.attr("display",n.isPtWithinRange(t,a)&&r.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var n=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,l=i.ycalendar,s="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(s).each(function(t){v.hideOutsideRangePoint(t,r.select(this),n,a,o,l)})})}},v.crispRound=function(t,e,n){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):n||0},v.singleLineStyle=function(t,e,n,r,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=n||i.width||0,s=a||i.dash||"";l.stroke(e,r||i.color),v.dashLine(e,s,o)},v.lineGroupStyle=function(t,e,n,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,s=a||i.dash||"";r.select(this).call(l.stroke,n||i.color).call(v.dashLine,s,o)})},v.dashLine=function(t,e,n){n=+n||0,e=v.dashStyle(e,n),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},v.dashStyle=function(t,e){e=+e||1;var n=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=n+"px,"+n+"px":"dash"===t?t=3*n+"px,"+3*n+"px":"longdash"===t?t=5*n+"px,"+5*n+"px":"dashdot"===t?t=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===t&&(t=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t},v.singleFillStyle=function(t){var e=(((r.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(l.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){r.select(this).call(l.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var m=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var n=t%100;return v.symbolFuncs[n](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=r.format("~.1f"),M={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,n,a,o,s){for(var u=o.length,f=M[a],d=new Array(u),p=0;p=100,e.attr("d",b(u,s))}var f,d,p,h=!1;if(t.so)p=o.outlierwidth,d=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,d="mlc"in t?t.mlcc=r.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?l.defaultLine:o.color,c.isArrayOrTypedArray(i.color)&&(f=l.defaultLine,h=!0),f="mc"in t?t.mcc=r.markerScale(t.mc):i.color||"rgba(0,0,0,0)",r.selectedColorFn&&(f=r.selectedColorFn(t))}if(t.om)e.call(l.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var y=i.gradient,m=t.mgt;if(m?h=!0:m=y&&y.type,Array.isArray(m)&&(m=m[0],M[m]||(m=0)),m&&"none"!==m){var x=t.mgc;x?h=!0:x=y.color;var _=n.uid;h&&(_+="-"+t.i),v.gradient(e,a,_,m,[[0,x],[1,f]],"fill")}else l.fill(e,f);p&&l.stroke(e,d)}},v.makePointStyleFns=function(t){var e={},n=t.marker;return e.markerScale=v.tryColorscale(n,""),e.lineScale=v.tryColorscale(n,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=h.isBubble(t)?g(t):function(){return(n.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},n=t.selected||{},r=t.unselected||{},a=t.marker||{},i=n.marker||{},l=r.marker||{},s=a.opacity,u=i.opacity,f=l.opacity,d=void 0!==u,h=void 0!==f;(c.isArrayOrTypedArray(s)||d||h)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?d?u:e:h?f:p*e});var g=a.color,v=i.color,y=l.color;(v||y)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:y||e});var m=a.size,x=i.size,b=l.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||m/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},n=t.selected||{},r=t.unselected||{},a=t.textfont||{},i=n.textfont||{},o=r.textfont||{},s=a.color,c=i.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||s;return t.selected?c||e:u||(c?e:l.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var n=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];n.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",n.selectedOpacityFn(e))}),n.selectedColorFn&&i.push(function(t,e){l.fill(t,n.selectedColorFn(e))}),n.selectedSizeFn&&i.push(function(t,e){var r=e.mx||a.symbol||0,i=n.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(r),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=r.select(this),n=0;n0?n:0}v.textPointStyle=function(t,e,n){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=r.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var l=t.tp||e.textposition,s=L(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,s,f).text(o).call(u.convertToTspans,n).call(A,l,s,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var n=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=r.select(this),i=n.selectedTextColorFn(t),o=t.tp||e.textposition,s=L(t,e);l.fill(a,i),A(a,o,s,t.mrc2||t.mrc)})}};var S=.5;function C(t,e,n,a){var i=t[0]-e[0],o=t[1]-e[1],l=n[0]-e[0],s=n[1]-e[1],c=Math.pow(i*i+o*o,S/2),u=Math.pow(l*l+s*s,S/2),f=(u*u*i-c*c*l)*a,d=(u*u*o-c*c*s)*a,p=3*u*(c+u),h=3*c*(c+u);return[[r.round(e[0]+(p&&f/p),2),r.round(e[1]+(p&&d/p),2)],[r.round(e[0]-(h&&f/h),2),r.round(e[1]-(h&&d/h),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,r="M"+t[0],a=[];for(n=1;n=1e4&&(v.savedBBoxes={},z=0),n&&(v.savedBBoxes[n]=y),z++,c.extendFlat({},y)},v.setClipUrl=function(t,e){if(e){if(void 0===v.baseUrl){var n=r.select("base");n.size()&&n.attr("href")?v.baseUrl=window.location.href.split("#")[0]:v.baseUrl=""}t.attr("clip-path","url("+v.baseUrl+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,n){return[e,n].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,n){var r=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[r]("transform")||"";return e=e||0,n=n||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+n+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,n){return[e,n].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,n){var r=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[r]("transform")||"";return e=e||1,n=n||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+n+")").trim(),t[a]("transform",i),i};var E=/\s*sc.*/;v.setPointGroupScale=function(t,e,n){if(e=e||1,n=n||1,t){var r=1===e&&1===n?"":" scale("+e+","+n+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(E,"");t=(t+=r).trim(),this.setAttribute("transform",t)})}};var R=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,n){t&&t.each(function(){var t,a=r.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),l=parseFloat(i.attr("y")||0),s=(a.attr("transform")||"").match(R);t=1===e&&1===n?[]:["translate("+o+","+l+")","scale("+e+","+n+")","translate("+-o+","+-l+")"],s&&t.push(s),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":143,"../../constants/interactions":144,"../../constants/xmlns_namespaces":146,"../../lib":165,"../../lib/svg_text_utils":186,"../../registry":259,"../../traces/scatter/make_bubble_size_func":298,"../../traces/scatter/subtypes":305,"../color":45,"../colorscale":60,"./symbol_defs":71,d3:9,"fast-isnumeric":11,tinycolor2:27}],71:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+n+a+i+a+i+o+i+o+n+o+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+e+","+r.round(t/2,2)+"H"+e+"L0,-"+r.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+r.round(t/2,2)+"H"+e+"L0,"+r.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M"+r.round(t/2,2)+",-"+e+"V"+e+"L-"+r.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+r.round(t/2,2)+",-"+e+"V"+e+"L"+r.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),a=r.round(-t,2),i=r.round(-.309*t,2);return"M"+e+","+i+"L"+n+","+r.round(.809*t,2)+"H-"+n+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+n+"V"+n+"L0,"+e+"L-"+a+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+a+"H"+n+"L"+e+",0L"+n+",-"+a+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),a=r.round(.951*e,2),i=r.round(.363*e,2),o=r.round(.588*e,2),l=r.round(-e,2),s=r.round(-.309*e,2),c=r.round(.118*e,2),u=r.round(.809*e,2);return"M"+n+","+s+"H"+a+"L"+i+","+c+"L"+o+","+u+"L0,"+r.round(.382*e,2)+"L-"+o+","+u+"L-"+i+","+c+"L-"+a+","+s+"H-"+n+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),a=r.round(.76*t,2);return"M-"+a+",0l-"+n+",-"+e+"h"+a+"l"+n+",-"+e+"l"+n+","+e+"h"+a+"l-"+n+","+e+"l"+n+","+e+"h-"+a+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),i=r.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+n+o+e+","+n+o+"0,-"+a+o+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),i=r.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+n+o+"-"+e+",-"+n+o+"0,"+a+o+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:9}],72:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],73:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function l(t,e,n,a){var l=e["error_"+a]||{},s=[];if(l.visible&&-1!==["linear","log"].indexOf(n.type)){for(var c=o(l),u=0;u0;t.each(function(t){var u,f=t[0].trace,d=f.error_x||{},p=f.error_y||{};f.ids&&(u=function(t){return t.id});var h=o.hasMarkers(f)&&f.marker.maxdisplayed>0;p.visible||d.visible||(t=[]);var g=r.select(this).selectAll("g.errorbar").data(t,u);if(g.exit().remove(),t.length){d.visible||g.selectAll("path.xerror").remove(),p.visible||g.selectAll("path.yerror").remove(),g.style("opacity",1);var v=g.enter().append("g").classed("errorbar",!0);c&&v.style("opacity",0).transition().duration(n.duration).style("opacity",1),i.setClipUrl(g,e.layerClipId),g.each(function(t){var e=r.select(this),i=function(t,e,n){var r={x:e.c2p(t.x),y:n.c2p(t.y)};void 0!==t.yh&&(r.yh=n.c2p(t.yh),r.ys=n.c2p(t.ys),a(r.ys)||(r.noYS=!0,r.ys=n.c2p(t.ys,!0)));void 0!==t.xh&&(r.xh=e.c2p(t.xh),r.xs=e.c2p(t.xs),a(r.xs)||(r.noXS=!0,r.xs=e.c2p(t.xs,!0)));return r}(t,l,s);if(!h||t.vis){var o,u=e.select("path.yerror");if(p.visible&&a(i.x)&&a(i.yh)&&a(i.ys)){var f=p.width;o="M"+(i.x-f)+","+i.yh+"h"+2*f+"m-"+f+",0V"+i.ys,i.noYS||(o+="m-"+f+",0h"+2*f),!u.size()?u=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):c&&(u=u.transition().duration(n.duration).ease(n.easing)),u.attr("d",o)}else u.remove();var g=e.select("path.xerror");if(d.visible&&a(i.y)&&a(i.xh)&&a(i.xs)){var v=(d.copy_ystyle?p:d).width;o="M"+i.xh+","+(i.y-v)+"v"+2*v+"m0,-"+v+"H"+i.xs,i.noXS||(o+="m0,-"+v+"v"+2*v),!g.size()?g=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):c&&(g=g.transition().duration(n.duration).ease(n.easing)),g.attr("d",o)}else g.remove()}})}})}},{"../../traces/scatter/subtypes":305,"../drawing":70,d3:9,"fast-isnumeric":11}],78:[function(t,e,n){"use strict";var r=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},i=e.error_x||{},o=r.select(this);o.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(a.stroke,n.color),i.copy_ystyle&&(i=n),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":45,d3:9}],79:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:r({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":237}],80:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../registry");function i(t,e,n,a){a=a||r.identity,Array.isArray(t)&&(e[0][n]=a(t))}e.exports=function(t){var e=t.calcdata,n=t._fullLayout;function o(t){return function(e){return r.coerceHoverinfo({hoverinfo:e},{_module:t._module},n)}}for(var l=0;l=0&&n.index-1&&o.length>x&&(o=x>3?o.substr(0,x-3)+"...":o.substr(0,x))}void 0!==t.zLabel?(void 0!==t.xLabel&&(c+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(c+="y: "+t.yLabel+"
"),c+=(c?"z: ":"")+t.zLabel):P&&t[a+"Label"]===M?c=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(c=t.yLabel):c=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(c+=(c?"
":"")+t.text),void 0!==t.extraText&&(c+=(c?"
":"")+t.extraText),""===c&&(""===o&&e.remove(),c=o);var b=e.select("text.nums").call(u.font,t.fontFamily||h,t.fontSize||g,t.fontColor||m).text(c).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,n),_=e.select("text.name"),T=0;o&&o!==c?(_.call(u.font,t.fontFamily||h,t.fontSize||g,v).text(o).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,n),T=_.node().getBoundingClientRect().width+2*k):(_.remove(),e.select("rect").remove()),e.select("path").style({fill:p,stroke:m});var A,O,z=b.node().getBoundingClientRect(),D=t.xa._offset+(t.x0+t.x1)/2,E=t.ya._offset+(t.y0+t.y1)/2,R=Math.abs(t.x1-t.x0),N=Math.abs(t.y1-t.y0),I=z.width+w+k+T;t.ty0=L-z.top,t.bx=z.width+2*k,t.by=z.height+2*k,t.anchor="start",t.txwidth=z.width,t.tx2width=T,t.offset=0,i?(t.pos=D,A=E+N/2+I<=C,O=E-N/2-I>=0,"top"!==t.idealAlign&&A||!O?A?(E+=N/2,t.anchor="start"):t.anchor="middle":(E-=N/2,t.anchor="end")):(t.pos=E,A=D+R/2+I<=S,O=D-R/2-I>=0,"left"!==t.idealAlign&&A||!O?A?(D+=R/2,t.anchor="start"):t.anchor="middle":(D-=R/2,t.anchor="end")),b.attr("text-anchor",t.anchor),T&&_.attr("text-anchor",t.anchor),e.attr("transform","translate("+D+","+E+")"+(i?"rotate("+y+")":""))}),N}function T(t,e){t.each(function(t){var n=r.select(this);if(t.del)n.remove();else{var a="end"===t.anchor?-1:1,i=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],l=o*(w+k),c=l+o*(t.txwidth+k),f=0,d=t.offset;"middle"===t.anchor&&(l-=t.tx2width/2,c+=t.txwidth/2+k),e&&(d*=-_,f=t.offset*b),n.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(d-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+d)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(d-w)+"Z"),i.call(s.positionText,l+f,d+t.ty0-t.by/2+k),t.tx2width&&(n.select("text.name").call(s.positionText,c+o*k+f,d+t.ty0-t.by/2+k),n.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,d-t.by/2-1,t.tx2width,t.by+2))}})}function A(t,e){var n=t.index,r=t.trace||{},a=t.cd[0],i=t.cd[n]||{},l=Array.isArray(n)?function(t,e){return o.castOption(a,n,t)||o.extractOption({},r,"",e)}:function(t,e){return o.extractOption(i,r,t,e)};function s(e,n,r){var a=l(n,r);a&&(t[e]=a)}if(s("hoverinfo","hi","hoverinfo"),s("bgcolor","hbg","hoverlabel.bgcolor"),s("borderColor","hbc","hoverlabel.bordercolor"),s("fontFamily","htf","hoverlabel.font.family"),s("fontSize","hts","hoverlabel.font.size"),s("fontColor","htc","hoverlabel.font.color"),s("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function L(t,e){var n,r,a=e.container,o=e.fullLayout,l=e.event,s=!!t.hLinePoint,c=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),c||s){var d=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(s){var p,h,g=t.hLinePoint;n=g&&g.xa,"cursor"===(r=g&&g.ya).spikesnap?(p=l.pointerX,h=l.pointerY):(p=n._offset+g.x,h=r._offset+g.y);var v,y,m=i.readability(g.color,d)<1.5?f.contrast(d):g.color,x=r.spikemode,b=r.spikethickness,_=r.spikecolor||m,w=r._boundingBox,k=(w.left+w.right)/2w[0]._length||et<0||et>k[0]._length)return d.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,R="xval"in e?g.flat(s,e.xval):g.p2c(w,tt),N="yval"in e?g.flat(s,e.yval):g.p2c(k,et),!a(R[0])||!a(N[0]))return o.warn("Fx.hover failed",e,t),d.unhoverRaw(t,e)}var at=1/0;for(F=0;FY&&(J.splice(0,Y),at=J[0].distance),m&&0!==W&&0===J.length){Z.distance=W,Z.index=!1;var ct=B._module.hoverPoints(Z,U,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=W})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var dt=ft[0];a(dt.x0)&&a(dt.y0)&&(ut=vt(dt),(!$.vLinePoint||$.vLinePoint.spikeDistance>ut.spikeDistance)&&($.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var ht=pt[0];a(ht.x0)&&a(ht.y0)&&(ut=vt(ht),(!$.hLinePoint||$.hLinePoint.spikeDistance>ut.spikeDistance)&&($.hLinePoint=ut))}}}}function gt(t,e){for(var n,r=null,a=1/0,i=0;i1||J.length>1)||"closest"===E&&K&&J.length>1,Ct=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),Pt={hovermode:E,rotateLabels:St,bgColor:Ct,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},Ot=M(J,Pt,t);if(function(t,e,n){var r,a,i,o,l,s,c,u=0,f=1,d=t.map(function(t,r){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!r&&o&&o[0]>o[1]!==i&&(f=-1),[{i:r,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?x:1)/2,pmin:0,pmax:i?n.width:n.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],n=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=n.pos+n.dp+n.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;r=!1}if(!(i<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=i;r=!1}if(r){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos>e.pmax-1&&(s.del=!0,c--);for(o=0;o=0;l--)t[l].dp-=i;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(;!r&&u<=t.length;){for(u++,r=!0,o=0;o.01&&v.pmin===y.pmin&&v.pmax===y.pmax){for(l=g.length-1;l>=0;l--)g[l].dp+=a;for(h.push.apply(h,g),d.splice(o+1,1),c=0,l=h.length-1;l>=0;l--)c+=h[l].dp;for(i=c/h.length,l=h.length-1;l>=0;l--)h[l].dp-=i;r=!1}else o++}d.forEach(p)}for(o=d.length-1;o>=0;o--){var m=d[o];for(l=m.length-1;l>=0;l--){var b=m[l],_=t[b.i];_.offset=b.dp,_.del=b.del}}}(J,St?"xa":"ya",u),T(Ot,St),e.target&&e.target.tagName){var zt=h.getComponentMethod("annotations","hasClickToShow")(t,At);c(r.select(e.target),zt?"pointer":"")}if(!e.target||i||!function(t,e,n){if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var a=n[r],i=t._hoverdata[r];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber))return!0}return!1}(t,0,Tt))return;Tt&&t.emit("plotly_unhover",{event:e,points:Tt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:R,yvals:N})}(t,e,n,i)})},n.loneHover=function(t,e){var n={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0},a=r.select(e.container),i=e.outerContainer?r.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M([n],o,e.gd);return T(l,o.rotateLabels),l.node()},n.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var n=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0}}),a=r.select(e.container),i=e.outerContainer?r.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=M(n,o,e.gd),s=0;return l.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5-1?o="closest":(e._isHoriz=function(t){for(var e=!0,n=0;n1){d||p||h||"independent"===M("pattern")&&(d=!0),v._hasSubplotGrid=d;var x,b,_="top to bottom"===M("roworder"),w=d?.2:.1,k=d?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",M,w,x,m),y:u("y",M,k,b,y,_)}}else delete e.grid}function M(t,e){return r.coerce(n,v,s,t,e)}},contentDefaults:function(t,e){var n=e.grid;if(n&&n._domains){var r,a,i,o,l,s,u,d=t.grid||{},p=e._subplots,h=n._hasSubplotGrid,g=n.rows,v=n.columns,y="independent"===n.pattern,m=n._axisMap={};if(h){var x=d.subplots||[];s=n.subplots=new Array(g);var b=1;for(r=0;r=2/3},n.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],98:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes");e.exports={bgcolor:{valType:"color",editType:"legend"},bordercolor:{valType:"color",dflt:a.defaultLine,editType:"legend"},borderwidth:{valType:"number",min:0,dflt:0,editType:"legend"},font:r({editType:"legend"}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v",editType:"legend"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"],editType:"legend"},tracegroupgap:{valType:"number",min:0,dflt:10,editType:"legend"},x:{valType:"number",min:-2,max:3,dflt:1.02,editType:"legend"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left",editType:"legend"},y:{valType:"number",min:-2,max:3,dflt:1,editType:"legend"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"legend"},editType:"legend"}},{"../../plots/font_attributes":237,"../color/attributes":44}],99:[function(t,e,n){"use strict";e.exports={scrollBarWidth:6,scrollBarMinHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4,textOffsetX:40}},{}],100:[function(t,e,n){"use strict";var r=t("../../registry"),a=t("../../lib"),i=t("../../plot_api/plot_template"),o=t("./attributes"),l=t("../../plots/layout_attributes"),s=t("./helpers");e.exports=function(t,e,n){for(var c,u,f,d,p=t.legend||{},h=0,g=!1,v="normal",y=0;y1)){var x=i.newContainer(e,"legend");if(_("bgcolor",e.paper_bgcolor),_("bordercolor"),_("borderwidth"),a.coerceFont(_,"font",e.font),_("orientation"),"h"===x.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(c=0,f="left",u=1.1,d="bottom"):(c=0,f="left",u=-.1,d="top")}_("traceorder",v),s.isGrouped(e.legend)&&_("tracegroupgap"),_("x",c),_("xanchor",f),_("y",u),_("yanchor",d),a.noneOrAll(p,x,["x","y"])}function _(t,e){return a.coerce(p,x,o,t,e)}}},{"../../lib":165,"../../plot_api/plot_template":200,"../../plots/layout_attributes":249,"../../registry":259,"./attributes":98,"./helpers":104}],101:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib/events"),s=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),d=t("./handle_click"),p=t("./constants"),h=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,y=g.FROM_TL,m=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=t("./anchor_utils"),k=h.DBLCLICKDELAY;function M(t,e,n,r,a){var i=n.data()[0][0].trace,o={event:a,node:n.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=n.datum()[0].label),!1!==l.triggerHandler(t,"plotly_legendclick",o))if(1===r)e._clickTimeout=setTimeout(function(){d(n,t,r)},k);else if(2===r){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==l.triggerHandler(t,"plotly_legenddoubleclick",o)&&d(n,t,r)}}function T(t,e,n){var r=t.data()[0][0],i=e._fullLayout,l=r.trace,s=o.traceIs(l,"pie"),u=l.index,d=s?r.label:l.name,h=e._context.edits.legendText&&!s,g=a.ensureSingle(t,"text","legendtext");function y(n){f.convertToTspans(n,e,function(){!function(t,e){var n=t.data()[0][0];if(!n.trace.showlegend)return void t.remove();var r,a,i=t.select("g[class*=math-group]"),o=i.node(),l=e._fullLayout.legend.font.size*v;if(o){var s=c.bBox(o);r=s.height,a=s.width,c.setTranslate(i,0,r/4)}else{var u=t.select(".legendtext"),d=f.lineCount(u),h=u.node();r=l*d,a=h?c.bBox(h).width:0;var g=l*(.3+(1-d)/2);f.positionText(u,p.textOffsetX,g)}r=Math.max(r,16)+3,n.height=r,n.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,i.legend.font).text(h?A(d,n):d),f.positionText(g,p.textOffsetX,0),h?g.call(f.makeEditable,{gd:e,text:d}).call(y).on("edit",function(t){this.text(A(t,n)).call(y);var i=r.trace._fullInput||{},l={};if(o.hasTransform(i,"groupby")){var s=o.getTransformIndices(i,"groupby"),c=s[s.length-1],f=a.keyedContainer(i,"transforms["+c+"].styles","target","value.name");f.set(r.trace._group,t),l=f.constructUpdate()}else l.name=t;return o.call("restyle",e,l,u)}):y(g)}function A(t,e){var n=Math.max(4,e);if(t&&t.trim().length>=n/2)return t;for(var r=n-(t=t||"").length;r>0;r--)t+=" ";return t}function L(t,e){var n,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(n=(new Date).getTime())-e._legendMouseDownTimek&&(i=Math.max(i-1,1)),M(e,n,t,i,r.event)}})}function S(t,e,n){var a=t._fullLayout,i=a.legend,o=i.borderwidth,l=_.isGrouped(i),s=0;if(i._width=0,i._height=0,_.isVertical(i))l&&e.each(function(t,e){c.setTranslate(this,0,e*i.tracegroupgap)}),n.each(function(t){var e=t[0],n=e.height,r=e.width;c.setTranslate(this,o,5+o+i._height+n/2),i._height+=n,i._width=Math.max(i._width,r)}),i._width+=45+2*o,i._height+=10+2*o,l&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),s=40;else if(l){for(var u=[i._width],f=e.data(),d=0,p=f.length;do+w-k,n.each(function(t){var e=t[0],n=v?40+t[0].width:x;o+b+k+n>a._size.w&&(b=0,y+=m,i._height=i._height+m,m=0),c.setTranslate(this,o+b,5+o+e.height/2+y),i._width+=k+n,i._height=Math.max(i._height,e.height),b+=k+n,m=Math.max(e.height,m)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var M=t._context.edits.legendText||t._context.edits.legendPosition;n.each(function(t){var e=t[0],n=r.select(this).select(".legendtoggle");c.setRect(n,0,-e.height/2,(M?0:i._width)+s,e.height)})}function C(t){var e=t._fullLayout.legend,n="left";w.isRightAnchor(e)?n="right":w.isCenterAnchor(e)&&(n="center");var r="top";w.isBottomAnchor(e)?r="bottom":w.isMiddleAnchor(e)&&(r="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[n],r:e._width*m[n],b:e._height*m[r],t:e._height*y[r]})}e.exports=function(t){var e=t._fullLayout,n="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var l=e.legend,f=e.showlegend&&x(t.calcdata,l),d=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+n).remove(),void i.autoMargin(t,"legend");for(var h=0,g=0;gf?function(t){var e=t._fullLayout.legend,n="left";w.isRightAnchor(e)?n="right":w.isCenterAnchor(e)&&(n="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[n],r:e._width*m[n],b:0,t:0})}(t):C(t);var d=e._size,h=d.l+d.w*l.x,g=d.t+d.h*(1-l.y);w.isRightAnchor(l)?h-=l._width:w.isCenterAnchor(l)&&(h-=l._width/2),w.isBottomAnchor(l)?g-=l._height:w.isMiddleAnchor(l)&&(g-=l._height/2);var v=l._width,x=d.w;v>x?(h=d.l,v=x):(h+v>u&&(h=u-v),h<0&&(h=0),v=Math.min(u-h,l._width));var b,_,k,T,A=l._height,L=d.h;if(A>L?(g=d.t,A=L):(g+A>f&&(g=f-A),g<0&&(g=0),A=Math.min(f-g,l._height)),c.setTranslate(O,h,g),R.on(".drag",null),O.on("wheel",null),l._height<=A||t._context.staticPlot)D.attr({width:v-l.borderwidth,height:A-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),c.setTranslate(E,0,0),z.select("rect").attr({width:v-2*l.borderwidth,height:A-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth}),c.setClipUrl(E,n),c.setRect(R,0,0,0,0),delete l._scrollY;else{var F,j,B=Math.max(p.scrollBarMinHeight,A*A/l._height),H=A-B-2*p.scrollBarMargin,q=l._height-A,V=H/q,U=Math.min(l._scrollY||0,q);D.attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),z.select("rect").attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth+U}),c.setClipUrl(E,n),Z(U,B,V),O.on("wheel",function(){Z(U=a.constrain(l._scrollY+r.event.deltaY/H*q,0,q),B,V),0!==U&&U!==q&&r.event.preventDefault()});var G=r.behavior.drag().on("dragstart",function(){F=r.event.sourceEvent.clientY,j=U}).on("drag",function(){var t=r.event.sourceEvent;2===t.buttons||t.ctrlKey||Z(U=a.constrain((t.clientY-F)/V+j,0,q),B,V)});R.call(G)}function Z(e,n,r){l._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(E,0,-e),c.setRect(R,v,p.scrollBarMargin+e*r,p.scrollBarWidth,n),z.select("rect").attr({y:l.borderwidth+e})}t._context.edits.legendPosition&&(O.classed("cursor-move",!0),s.init({element:O.node(),gd:t,prepFn:function(){var t=c.getTranslate(O);k=t.x,T=t.y},moveFn:function(t,e){var n=k+t,r=T+e;c.setTranslate(O,n,r),b=s.align(n,0,d.l,d.l+d.w,l.xanchor),_=s.align(r,0,d.t+d.h,d.t,l.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("relayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(n,r){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return r.clientX>=t.left&&r.clientX<=t.right&&r.clientY>=t.top&&r.clientY<=t.bottom});a.size()>0&&M(t,O,a,n,r)}}))}],t)}}},{"../../constants/alignment":143,"../../constants/interactions":144,"../../lib":165,"../../lib/events":156,"../../lib/svg_text_utils":186,"../../plots/plots":251,"../../registry":259,"../color":45,"../dragelement":67,"../drawing":70,"./anchor_utils":97,"./constants":99,"./get_legend_data":102,"./handle_click":103,"./helpers":104,"./style":106,d3:9}],102:[function(t,e,n){"use strict";var r=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var n,i,o={},l=[],s=!1,c={},u=0;function f(t,n){if(""!==t&&a.isGrouped(e))-1===l.indexOf(t)?(l.push(t),s=!0,o[t]=[[n]]):o[t].push([n]);else{var r="~~i"+u;l.push(r),o[r]=[[n]],u++}}for(n=0;nn[1])return n[1]}return a}function h(t){return t[0]}if(u||f||d){var g={},v={};if(u){g.mc=p("marker.color",h),g.mx=p("marker.symbol",h),g.mo=p("marker.opacity",i.mean,[.2,1]),g.mlc=p("marker.line.color",h),g.mlw=p("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=p("marker.size",i.mean,[2,16]);g.ms=y,v.marker.size=y}d&&(v.line={width:p("line.width",h,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",h),g.ts=10,g.tc=p("textfont.color",h),g.tf=p("textfont.family",h)),n=[i.minExtend(l,g)],(a=i.minExtend(c,v)).selectedpoints=null}var m=r.select(this).select("g.legendpoints"),x=m.selectAll("path.scatterpts").data(u?n:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,a,e),u&&(n[0].mrc=3);var b=m.selectAll("g.pointtext").data(f?n:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,n=r.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);n.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),n.exit().remove(),n.each(function(t,n){var a=e[n?"increasing":"decreasing"],i=a.line.width,o=r.select(this);o.style("stroke-width",i+"px").call(l.fill,a.fillcolor),i&&l.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,n=r.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);n.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),n.exit().remove(),n.each(function(t,n){var a=e[n?"increasing":"decreasing"],i=a.line.width,s=r.select(this);s.style("fill","none").call(o.dashLine,a.line.dash,i),i&&l.stroke(s,a.line.color)})})}},{"../../lib":165,"../../registry":259,"../../traces/pie/style_one":279,"../../traces/scatter/subtypes":305,"../color":45,"../drawing":70,d3:9}],107:[function(t,e,n){"use strict";var r=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),l=t("../../../build/ploticon"),s=o._,c=e.exports={};function u(t,e){var n,a,o=e.currentTarget,l=o.getAttribute("data-attr"),s=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=i.list(t,null,!0),d="on";if("zoom"===l){var p,h="in"===s?.5:2,g=(1+h)/2,v=(1-h)/2;for(a=0;a1?(_=["toggleHover"],w=["resetViews"]):f?(b=["zoomInGeo","zoomOutGeo"],_=["hoverClosestGeo"],w=["resetGeo"]):u?(_=["hoverClosest3d"],w=["resetCameraDefault3d","resetCameraLastSave3d"]):g?(_=["toggleHover"],w=["resetViewMapbox"]):_=p?["hoverClosestGl2d"]:d?["hoverClosestPie"]:["toggleHover"];c&&(_=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!c&&!p||y||(b=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==w[0]&&(w=["resetScale2d"]));u?k=["zoom3d","pan3d","orbitRotation","tableRotation"]:(c||p)&&!y||h?k=["zoom2d","pan2d"]:g||f?k=["pan2d"]:v&&(k=["zoom2d"]);(function(t){for(var e=!1,n=0;n0)){var g=function(t,e,n){for(var r=n.filter(function(n){return e[n].anchor===t._id}),a=0,i=0;i0?d+c:c;return{ppad:c,ppadplus:u?h:g,ppadminus:u?g:h}}return{ppad:c}}function u(t,e,n,r,a){var l="category"===t.type?t.r2c:t.d2c;if(void 0!==e)return[l(e),l(n)];if(r){var s,c,u,f,d=1/0,p=-1/0,h=r.match(i.segmentRE);for("date"===t.type&&(l=o.decodeDate(l)),s=0;sp&&(p=f)));return p>=d?[d,p]:void 0}}e.exports=function(t){var e=t._fullLayout,n=r.filterVisible(e.shapes);if(n.length&&t._fullData.length)for(var o=0;o10?t/2:10;return r.append("circle").attr({"data-line-point":"start-point",cx:R?V(n.xanchor)+n.x0:V(n.x0),cy:N?U(n.yanchor)-n.y0:U(n.y0),r:i}).style(a).classed("cursor-grab",!0),r.append("circle").attr({"data-line-point":"end-point",cx:R?V(n.xanchor)+n.x1:V(n.x1),cy:N?U(n.yanchor)-n.y1:U(n.y1),r:i}).style(a).classed("cursor-grab",!0),r}():e,X={element:Y.node(),gd:t,prepFn:function(r){R&&(_=V(n.xanchor));N&&(w=U(n.yanchor));"path"===n.type?O=n.path:(y=R?n.x0:V(n.x0),m=N?n.y0:U(n.y0),x=R?n.x1:V(n.x1),b=N?n.y1:U(n.y1));yb?(k=m,L="y0",M=b,S="y1"):(k=b,L="y1",M=m,S="y0");W(r),$(p,n),function(t,e,n){var r=e.xref,a=e.yref,o=i.getFromId(n,r),s=i.getFromId(n,a),c="";"paper"===r||o.autorange||(c+=r);"paper"===a||s.autorange||(c+=a);t.call(l.setClipUrl,c?"clip"+n._fullLayout._uid+c:null)}(e,n,t),X.moveFn="move"===z?J:Q},doneFn:function(){u(e),K(p),h(e,t,n),r.call("relayout",t,j.getUpdateObj())},clickFn:function(){K(p)}};function W(t){if(I)z="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var n=X.element.getBoundingClientRect(),r=n.right-n.left,a=n.bottom-n.top,i=t.clientX-n.left,o=t.clientY-n.top,l=!F&&r>D&&a>E&&!t.shiftKey?c.getCursor(i/r,1-o/a):"move";u(e,l),z=l.split("-")[0]}}function J(r,a){if("path"===n.type){var i=function(t){return t},o=i,l=i;R?B("xanchor",n.xanchor=G(_+r)):(o=function(t){return G(V(t)+r)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?B("yanchor",n.yanchor=Z(w+a)):(l=function(t){return Z(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),B("path",n.path=v(O,o,l))}else R?B("xanchor",n.xanchor=G(_+r)):(B("x0",n.x0=G(y+r)),B("x1",n.x1=G(x+r))),N?B("yanchor",n.yanchor=Z(w+a)):(B("y0",n.y0=Z(m+a)),B("y1",n.y1=Z(b+a)));e.attr("d",g(t,n)),$(p,n)}function Q(r,a){if(F){var i=function(t){return t},o=i,l=i;R?B("xanchor",n.xanchor=G(_+r)):(o=function(t){return G(V(t)+r)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?B("yanchor",n.yanchor=Z(w+a)):(l=function(t){return Z(U(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),B("path",n.path=v(O,o,l))}else if(I){if("resize-over-start-point"===z){var s=y+r,c=N?m-a:m+a;B("x0",n.x0=R?s:G(s)),B("y0",n.y0=N?c:Z(c))}else if("resize-over-end-point"===z){var u=x+r,f=N?b-a:b+a;B("x1",n.x1=R?u:G(u)),B("y1",n.y1=N?f:Z(f))}}else{var h=~z.indexOf("n")?k+a:k,j=~z.indexOf("s")?M+a:M,Y=~z.indexOf("w")?T+r:T,X=~z.indexOf("e")?A+r:A;~z.indexOf("n")&&N&&(h=k-a),~z.indexOf("s")&&N&&(j=M-a),(!N&&j-h>E||N&&h-j>E)&&(B(L,n[L]=N?h:Z(h)),B(S,n[S]=N?j:Z(j))),X-Y>D&&(B(C,n[C]=R?Y:G(Y)),B(P,n[P]=R?X:G(X)))}e.attr("d",g(t,n)),$(p,n)}function $(t,e){(R||N)&&function(){var n="path"!==e.type,r=t.selectAll(".visual-cue").data([0]);r.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=V(R?e.xanchor:a.midRange(n?[e.x0,e.x1]:d.extractPathCoords(e.path,f.paramIsX))),o=U(N?e.yanchor:a.midRange(n?[e.y0,e.y1]:d.extractPathCoords(e.path,f.paramIsY)));if(i=d.roundPositionForSharpStrokeRendering(i,1),o=d.roundPositionForSharpStrokeRendering(o,1),R&&N){var l="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";r.attr("d",l)}else if(R){var s="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";r.attr("d",s)}else{var c="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";r.attr("d",c)}}()}function K(t){t.selectAll(".visual-cue").remove()}c.init(X),Y.node().onmousemove=W}(t,x,n,e,p)}}function h(t,e,n){var r=(n.xref+n.yref).replace(/paper/g,"");t.call(l.setClipUrl,r?"clip"+e._fullLayout._uid+r:null)}function g(t,e){var n,r,o,l,s,c,u,p,h=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),y=t._fullLayout._size;if(g?(n=d.shapePositionToRange(g),r=function(t){return g._offset+g.r2p(n(t,!0))}):r=function(t){return y.l+y.w*t},v?(o=d.shapePositionToRange(v),l=function(t){return v._offset+v.r2p(o(t,!0))}):l=function(t){return y.t+y.h*(1-t)},"path"===h)return g&&"date"===g.type&&(r=d.decodeDate(r)),v&&"date"===v.type&&(l=d.decodeDate(l)),function(t,e,n){var r=t.path,i=t.xsizemode,o=t.ysizemode,l=t.xanchor,s=t.yanchor;return r.replace(f.segmentRE,function(t){var r=0,c=t.charAt(0),u=f.paramIsX[c],d=f.paramIsY[c],p=f.numParams[c],h=t.substr(1).replace(f.paramRE,function(t){return u[r]?t="pixel"===i?e(l)+Number(t):e(t):d[r]&&(t="pixel"===o?n(s)-Number(t):n(t)),++r>p&&(t="X"),t});return r>p&&(h=h.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),c+h})}(e,r,l);if("pixel"===e.xsizemode){var m=r(e.xanchor);s=m+e.x0,c=m+e.x1}else s=r(e.x0),c=r(e.x1);if("pixel"===e.ysizemode){var x=l(e.yanchor);u=x-e.y0,p=x-e.y1}else u=l(e.y0),p=l(e.y1);if("line"===h)return"M"+s+","+u+"L"+c+","+p;if("rect"===h)return"M"+s+","+u+"H"+c+"V"+p+"H"+s+"Z";var b=(s+c)/2,_=(u+p)/2,w=Math.abs(b-s),k=Math.abs(_-u),M="A"+w+","+k,T=b+w+","+_;return"M"+T+M+" 0 1,1 "+(b+","+(_-k))+M+" 0 0,1 "+T+"Z"}function v(t,e,n){return t.replace(f.segmentRE,function(t){var r=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],l=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return r>=l?t:(i[r]?t=e(t):o[r]&&(t=n(t)),r++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var n in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var r=e._plots[n].shapelayer;r&&r.selectAll("path").remove()}for(var a=0;a0&&(l=l.transition().duration(e.transition.duration).ease(e.transition.easing)),l.attr("transform","translate("+(o-.5*f.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function S(t,e){var n=t._dims;return n.inputAreaStart+f.stepInset+(n.inputAreaLength-2*f.stepInset)*Math.min(1,Math.max(0,e))}function C(t,e){var n=t._dims;return Math.min(1,Math.max(0,(e-f.stepInset-n.inputAreaStart)/(n.inputAreaLength-2*f.stepInset-2*n.inputAreaStart)))}function P(t,e,n){var r=n._dims,a=l.ensureSingle(t,"rect",f.railTouchRectClass,function(r){r.call(T,e,t,n).style("pointer-events","all")});a.attr({width:r.inputAreaLength,height:Math.max(r.inputAreaWidth,f.tickOffset+n.ticklen+r.labelHeight)}).call(i.fill,n.bgcolor).attr("opacity",0),o.setTranslate(a,0,r.currentValueTotalHeight)}function O(t,e){var n=e._dims,r=n.inputAreaLength-2*f.railInset,a=l.ensureSingle(t,"rect",f.railRectClass);a.attr({width:r,height:f.railWidth,rx:f.railRadius,ry:f.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,f.railInset,.5*(n.inputAreaWidth-f.railWidth)+n.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,n=function(t,e){for(var n=t[f.name],r=[],a=0;a0?[0]:[]);function l(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,v(e))}if(i.enter().append("g").classed(f.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){r.select(this).selectAll("g."+f.groupClassName).each(l)}).remove(),0!==n.length){var s=i.selectAll("g."+f.groupClassName).data(n,y);s.enter().append("g").classed(f.groupClassName,!0),s.exit().each(l).remove();for(var c=0;c0||d<0){var g={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[m.side];e.attr("transform","translate("+g+")")}}}z.call(D),P&&(C?z.on(".opacity",null):(L=0,S=!0,z.text(v).on("mouseover.opacity",function(){r.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),z.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("restyle",t,g,e,y):o.call("relayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(D)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return z.classed("js-placeholder",S),_}};var d=/ [XY][0-9]* /},{"../../constants/interactions":144,"../../lib":165,"../../lib/svg_text_utils":186,"../../plots/plots":251,"../../registry":259,"../color":45,"../drawing":70,d3:9,"fast-isnumeric":11}],137:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,l=t("../../plots/pad_attributes"),s=t("../../plot_api/plot_template").templatedArray,c=s("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(s("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i({},l,{}),font:r({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":157,"../../plot_api/edit_types":193,"../../plot_api/plot_template":200,"../../plots/font_attributes":237,"../../plots/pad_attributes":250,"../color/attributes":44}],138:[function(t,e,n){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],139:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,l=i.buttons;function s(t,e,n){function o(n,a){return r.coerce(t,e,i,n,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),r.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),r.coerceFont(o,"font",n.font),o("bgcolor",n.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function n(n,a){return r.coerce(t,e,l,n,a)}n("visible","skip"===t.method||Array.isArray(t.args))&&(n("method"),n("args"),n("label"),n("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:s})}},{"../../lib":165,"../../plots/array_container_defaults":206,"./attributes":137,"./constants":138}],140:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../legend/anchor_utils"),u=t("../../plot_api/plot_template").arrayEditor,f=t("../../constants/alignment").LINE_SPACING,d=t("./constants"),p=t("./scrollbox");function h(t){return t._index}function g(t,e){return+t.attr(d.menuIndexAttrName)===e._index}function v(t,e,n,r,a,i,o,l){e.active=o,u(t.layout,d.name,e).applyUpdate("active",o),"buttons"===e.type?m(t,r,null,null,e):"dropdown"===e.type&&(a.attr(d.menuIndexAttrName,"-1"),y(t,r,a,i,e),l||m(t,r,a,i,e))}function y(t,e,n,r,a){var i=l.ensureSingle(e,"g",d.headerClassName,function(t){t.style("pointer-events","all")}),s=a._dims,c=a.active,u=a.buttons[c]||d.blankHeaderOpts,f={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},p={width:s.headerWidth,height:s.headerHeight};i.call(x,a,u,t).call(L,a,f,p),l.ensureSingle(e,"text",d.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(d.arrowSymbol[a.direction])}).attr({x:s.headerWidth-d.arrowOffsetX+a.pad.l,y:s.headerHeight/2+d.textOffsetY+a.pad.t}),i.on("click",function(){n.call(S,String(g(n,a)?-1:a._index)),m(t,e,n,r,a)}),i.on("mouseover",function(){i.call(k)}),i.on("mouseout",function(){i.call(M,a)}),o.setTranslate(e,s.lx,s.ly)}function m(t,e,n,i,o){n||(n=e).attr("pointer-events","all");var s=function(t){return-1==+t.attr(d.menuIndexAttrName)}(n)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?d.dropdownButtonClassName:d.buttonClassName,u=n.selectAll("g."+c).data(l.filterVisible(s)),f=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(f.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var h=0,g=0,y=o._dims,m=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(m?g=y.headerHeight+d.gapButtonHeader:h=y.headerWidth+d.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(g=-d.gapButtonHeader+d.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(h=-d.gapButtonHeader+d.gapButton-y.openWidth);var b={x:y.lx+h+o.pad.l,y:y.ly+g+o.pad.t,yPad:d.gapButton,xPad:d.gapButton,index:0},_={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(l,s){var c=r.select(this);c.call(x,o,l,t).call(L,o,b),c.on("click",function(){r.event.defaultPrevented||(v(t,o,0,e,n,i,s),l.execute&&a.executeAPICommand(t,l.method,l.args),t.emit("plotly_buttonclicked",{menu:o,button:l,active:o.active}))}),c.on("mouseover",function(){c.call(k)}),c.on("mouseout",function(){c.call(M,o),u.call(w,o)})}),u.call(w,o),m?(_.w=Math.max(y.openWidth,y.headerWidth),_.h=b.y-_.t):(_.w=b.x-_.l,_.h=Math.max(y.openHeight,y.headerHeight)),_.direction=o.direction,i&&(u.size()?function(t,e,n,r,a,i){var o,l,s,c=a.direction,u="up"===c||"down"===c,f=a._dims,p=a.active;if(u)for(l=0,s=0;s0?[0]:[]);if(o.enter().append("g").classed(d.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){r.select(this).selectAll("g."+d.headerGroupClassName).each(i)}).remove(),0!==n.length){var s=o.selectAll("g."+d.headerGroupClassName).data(n,h);s.enter().append("g").classed(d.headerGroupClassName,!0);for(var c=l.ensureSingle(o,"g",d.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,T=l.barLength+2*l.barPad,A=l.barWidth+2*l.barPad,L=h,S=v+y;S+A>c&&(S=c-A);var C=this.container.selectAll("rect.scrollbar-horizontal").data(M?[0]:[]);C.exit().on(".drag",null).remove(),C.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,l.barColor),M?(this.hbar=C.attr({rx:l.barRadius,ry:l.barRadius,x:L,y:S,width:T,height:A}),this._hbarXMin=L+T/2,this._hbarTranslateMax=w-T):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var P=y>k,O=l.barWidth+2*l.barPad,z=l.barLength+2*l.barPad,D=h+g,E=v;D+O>s&&(D=s-O);var R=this.container.selectAll("rect.scrollbar-vertical").data(P?[0]:[]);R.exit().on(".drag",null).remove(),R.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,l.barColor),P?(this.vbar=R.attr({rx:l.barRadius,ry:l.barRadius,x:D,y:E,width:O,height:z}),this._vbarYMin=E+z/2,this._vbarTranslateMax=k-z):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var N=this.id,I=u-.5,F=P?f+O+.5:f+.5,j=d-.5,B=M?p+A+.5:p+.5,H=o._topdefs.selectAll("#"+N).data(M||P?[0]:[]);if(H.exit().remove(),H.enter().append("clipPath").attr("id",N).append("rect"),M||P?(this._clipRect=H.select("rect").attr({x:Math.floor(I),y:Math.floor(j),width:Math.ceil(F)-Math.floor(I),height:Math.ceil(B)-Math.floor(j)}),this.container.call(i.setClipUrl,N),this.bg.attr({x:h,y:v,width:g,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),M||P){var q=r.behavior.drag().on("dragstart",function(){r.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var V=r.behavior.drag().on("dragstart",function(){r.event.sourceEvent.preventDefault(),r.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));M&&this.hbar.on(".drag",null).call(V),P&&this.vbar.on(".drag",null).call(V)}this.setTranslate(e,n)},l.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},l.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=r.event.dx),this.vbar&&(e-=r.event.dy),this.setTranslate(t,e)},l.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=r.event.deltaY),this.vbar&&(e+=r.event.deltaY),this.setTranslate(t,e)},l.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var n=t+this._hbarXMin,a=n+this._hbarTranslateMax;t=(o.constrain(r.event.x,n,a)-n)/(a-n)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,l=i+this._vbarTranslateMax;e=(o.constrain(r.event.y,i,l)-i)/(l-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},l.prototype.setTranslate=function(t,e){var n=this.position.w-this._box.w,r=this.position.h-this._box.h;if(t=o.constrain(t||0,0,n),e=o.constrain(e||0,0,r),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/n;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var l=e/r;this.vbar.call(i.setTranslate,t,e+l*this._vbarTranslateMax)}}},{"../../lib":165,"../color":45,"../drawing":70,d3:9}],143:[function(t,e,n){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],144:[function(t,e,n){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],145:[function(t,e,n){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],146:[function(t,e,n){"use strict";n.xmlns="http://www.w3.org/2000/xmlns/",n.svg="http://www.w3.org/2000/svg",n.xlink="http://www.w3.org/1999/xlink",n.svgAttrs={xmlns:n.svg,"xmlns:xlink":n.xlink}},{}],147:[function(t,e,n){"use strict";n.version="1.42.5",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config");for(var r=t("./registry"),a=n.register=r.register,i=t("./plot_api"),o=Object.keys(i),l=0;ll-1e-15}function c(t,e){return i(e-t,l)}function u(t,e){if(s(e))return!0;var n,r;e[0](r=a(r,l))&&(r+=l);var i=a(t,l),o=i+l;return i>=n&&i<=r||o>=n&&o<=r}function f(t,e,n,r,a,i,c){a=a||0,i=i||0;var u,f,d,p,h,g=s([n,r]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(u=0,f=o,d=l):n=a&&t<=i);var a,i},pathArc:function(t,e,n,r,a){return f(null,t,e,n,r,a,0)},pathSector:function(t,e,n,r,a){return f(null,t,e,n,r,a,1)},pathAnnulus:function(t,e,n,r,a,i){return f(t,e,n,r,a,i,1)}}},{"./mod":172}],150:[function(t,e,n){"use strict";var r=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function l(t){return r(t)||o(t)}n.isTypedArray=o,n.isArrayOrTypedArray=l,n.isArray1D=function(t){return!l(t[0])},n.ensureArray=function(t,e){return r(t)||(t=[]),t.length=e,t},n.concat=function(){var t,e,n,a,i,o,l,s,c=[],u=!0,f=0;for(n=0;na.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,a){t%1||!r(t)||void 0!==a.min&&ta.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var a="number"==typeof t;!0!==r.strict&&a?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){a(t).isValid()?e.set(t):e.set(n)}},colorlist:{coerceFunction:function(t,e,n){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(o(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?e.set(u(+t,360)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n,r){var a=r.regex||s(n);"string"==typeof t&&a.test(t)?e.set(t):e.set(n)},validateFunction:function(t,e){var n=e.dflt;return t===n||"string"==typeof t&&!!s(n).test(t)}},flaglist:{coerceFunction:function(t,e,n,r){if("string"==typeof t)if(-1===(r.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=r&&t<=a?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),y=t.charAt(0);!c||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:m);if(!k)return u;var M=k[1],T=k[3]||"1",A=Number(k[5]||1),L=Number(k[7]||0),S=Number(k[9]||0),C=Number(k[11]||0);if(c){if(2===M.length)return u;var P;M=Number(M);try{var O=v.getComponentMethod("calendars","getCal")(e);if(w){var z="i"===T.charAt(T.length-1);T=parseInt(T,10),P=O.newDate(M,O.toMonthIndex(M,T,z),A)}else P=O.newDate(M,Number(T),A)}catch(t){return u}return P?(P.toJD()-g)*f+L*d+S*p+C*h:u}M=2===M.length?(Number(M)+2e3-b)%100+b:Number(M),T-=1;var D=new Date(Date.UTC(2e3,T,A,L,S));return D.setUTCFullYear(M),D.getUTCMonth()!==T?u:D.getUTCDate()!==A?u:D.getTime()+C*h},r=n.MIN_MS=n.dateTime2ms("-9999"),a=n.MAX_MS=n.dateTime2ms("9999-12-31 23:59:59.9999"),n.isDateTime=function(t,e){return n.dateTime2ms(t,e)!==u};var k=90*f,M=3*d,T=5*p;function A(t,e,n,r,a){if((e||n||r||a)&&(t+=" "+w(e,2)+":"+w(n,2),(r||a)&&(t+=":"+w(r,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}n.ms2DateTime=function(t,e,n){if("number"!=typeof t||!(t>=r&&t<=a))return u;e||(e=0);var i,o,l,c,m,x,b=Math.floor(10*s(t+.05,1)),w=Math.round(t-b/10);if(_(n)){var L=Math.floor(w/f)+g,S=Math.floor(s(t,f));try{i=v.getComponentMethod("calendars","getCal")(n).fromJD(L).formatDate("yyyy-mm-dd")}catch(t){i=y("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=r+f&&t<=a-f))return u;var e=Math.floor(10*s(t+.05,1)),n=new Date(Math.round(t-e/10));return A(i.time.format("%Y-%m-%d")(n),n.getHours(),n.getMinutes(),n.getSeconds(),10*n.getUTCMilliseconds()+e)},n.cleanDate=function(t,e,r){if(t===u)return e;if(n.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(r))return l.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=n.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!n.isDateTime(t,r))return l.error("unrecognized date",t),e;return t};var L=/%\d?f/g;function S(t,e,n,r){t=t.replace(L,function(t){var n=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(n).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(r))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,r)}catch(t){return"Invalid"}return n(t)(a)}var C=[59,59.9,59.99,59.999,59.9999];n.formatDate=function(t,e,n,r,a,i){if(a=_(a)&&a,!e)if("y"===n)e=i.year;else if("m"===n)e=i.month;else{if("d"!==n)return function(t,e){var n=s(t+.05,f),r=w(Math.floor(n/d),2)+":"+w(s(Math.floor(n/p),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(s(t/h,60),C[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),r+=":"+a}return r}(t,n)+"\n"+S(i.dayMonthYear,t,r,a);e=i.dayMonth+"\n"+i.year}return S(e,t,r,a)};var P=3*f;n.incrementMonth=function(t,e,n){n=_(n)&&n;var r=s(t,f);if(t=Math.round(t-r),n)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(n),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+r}catch(e){l.error("invalid ms "+t+" in calendar "+n)}var c=new Date(t+P);return c.setUTCMonth(c.getUTCMonth()+e)+r-P},n.findExactDates=function(t,e){for(var n,r,a=0,i=0,l=0,s=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u0&&(n.push(a),a=[])}return a.length>0&&n.push(a),n},n.makeLine=function(t){return 1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}},n.makePolygon=function(t){if(1===t.length)return{type:"Polygon",coordinates:t};for(var e=new Array(t.length),n=0;n1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}function s(t,e,n,r,a){var i=r*t+a*e;if(i<0)return r*r+a*a;if(i>n){var o=r-t,l=a-e;return o*o+l*l}var s=r*e-a*t;return s*s/n}n.segmentsIntersect=l,n.segmentDistance=function(t,e,n,r,a,i,o,c){if(l(t,e,n,r,a,i,o,c))return 0;var u=n-t,f=r-e,d=o-a,p=c-i,h=u*u+f*f,g=d*d+p*p,v=Math.min(s(u,f,h,a-t,i-e),s(u,f,h,o-t,c-e),s(d,p,g,t-a,e-i),s(d,p,g,n-a,r-i));return Math.sqrt(v)},n.getTextLocation=function(t,e,n,l){if(t===a&&l===i||(r={},a=t,i=l),r[n])return r[n];var s=t.getPointAtLength(o(n-l/2,e)),c=t.getPointAtLength(o(n+l/2,e)),u=Math.atan((c.y-s.y)/(c.x-s.x)),f=t.getPointAtLength(o(n,e)),d={x:(4*f.x+s.x+c.x)/6,y:(4*f.y+s.y+c.y)/6,theta:u};return r[n]=d,d},n.clearLocationCache=function(){a=null},n.getVisibleSegment=function(t,e,n){var r,a,i=e.left,o=e.right,l=e.top,s=e.bottom,c=0,u=t.getTotalLength(),f=u;function d(e){var n=t.getPointAtLength(e);0===e?r=n:e===u&&(a=n);var c=n.xo?n.x-o:0,f=n.ys?n.y-s:0;return Math.sqrt(c*c+f*f)}for(var p=d(c);p;){if((c+=p+n)>f)return;p=d(c)}for(p=d(f);p;){if(c>(f-=p+n))return;p=d(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(r.x-a.x)<.1&&Math.abs(r.y-a.y)<.1}},n.findPointOnPath=function(t,e,n,r){for(var a,i,o,l=(r=r||{}).pathLength||t.getTotalLength(),s=r.tolerance||.001,c=r.iterationLimit||30,u=t.getPointAtLength(0)[n]>t.getPointAtLength(l)[n]?-1:1,f=0,d=0,p=l;f0?p=a:d=a,f++}return i}},{"./mod":172}],163:[function(t,e,n){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],164:[function(t,e,n){"use strict";e.exports=function(t){return t}},{}],165:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),i=t("../constants/numerical"),o=i.FP_SAFE,l=i.BADNUM,s=e.exports={};s.nestedProperty=t("./nested_property"),s.keyedContainer=t("./keyed_container"),s.relativeAttr=t("./relative_attr"),s.isPlainObject=t("./is_plain_object"),s.toLogRange=t("./to_log_range"),s.relinkPrivateKeys=t("./relink_private");var c=t("./array");s.isTypedArray=c.isTypedArray,s.isArrayOrTypedArray=c.isArrayOrTypedArray,s.isArray1D=c.isArray1D,s.ensureArray=c.ensureArray,s.concat=c.concat;var u=t("./mod");s.mod=u.mod,s.modHalf=u.modHalf;var f=t("./coerce");s.valObjectMeta=f.valObjectMeta,s.coerce=f.coerce,s.coerce2=f.coerce2,s.coerceFont=f.coerceFont,s.coerceHoverinfo=f.coerceHoverinfo,s.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,s.validate=f.validate;var d=t("./dates");s.dateTime2ms=d.dateTime2ms,s.isDateTime=d.isDateTime,s.ms2DateTime=d.ms2DateTime,s.ms2DateTimeLocal=d.ms2DateTimeLocal,s.cleanDate=d.cleanDate,s.isJSDate=d.isJSDate,s.formatDate=d.formatDate,s.incrementMonth=d.incrementMonth,s.dateTick0=d.dateTick0,s.dfltRange=d.dfltRange,s.findExactDates=d.findExactDates,s.MIN_MS=d.MIN_MS,s.MAX_MS=d.MAX_MS;var p=t("./search");s.findBin=p.findBin,s.sorterAsc=p.sorterAsc,s.sorterDes=p.sorterDes,s.distinctVals=p.distinctVals,s.roundUp=p.roundUp,s.sort=p.sort,s.findIndexOfMin=p.findIndexOfMin;var h=t("./stats");s.aggNums=h.aggNums,s.len=h.len,s.mean=h.mean,s.midRange=h.midRange,s.variance=h.variance,s.stdev=h.stdev,s.interp=h.interp;var g=t("./matrix");s.init2dArray=g.init2dArray,s.transposeRagged=g.transposeRagged,s.dot=g.dot,s.translationMatrix=g.translationMatrix,s.rotationMatrix=g.rotationMatrix,s.rotationXYMatrix=g.rotationXYMatrix,s.apply2DTransform=g.apply2DTransform,s.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");s.deg2rad=v.deg2rad,s.rad2deg=v.rad2deg,s.angleDelta=v.angleDelta,s.angleDist=v.angleDist,s.isFullCircle=v.isFullCircle,s.isAngleInsideSector=v.isAngleInsideSector,s.isPtInsideSector=v.isPtInsideSector,s.pathArc=v.pathArc,s.pathSector=v.pathSector,s.pathAnnulus=v.pathAnnulus;var y=t("./geometry2d");s.segmentsIntersect=y.segmentsIntersect,s.segmentDistance=y.segmentDistance,s.getTextLocation=y.getTextLocation,s.clearLocationCache=y.clearLocationCache,s.getVisibleSegment=y.getVisibleSegment,s.findPointOnPath=y.findPointOnPath;var m=t("./extend");s.extendFlat=m.extendFlat,s.extendDeep=m.extendDeep,s.extendDeepAll=m.extendDeepAll,s.extendDeepNoArrays=m.extendDeepNoArrays;var x=t("./loggers");s.log=x.log,s.warn=x.warn,s.error=x.error;var b=t("./regex");s.counterRegex=b.counter;var _=t("./throttle");function w(t){var e={};for(var n in t)for(var r=t[n],a=0;ao?l:a(t)?Number(t):l:l},s.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},s.noop=t("./noop"),s.identity=t("./identity"),s.repeat=function(t,e){for(var n=new Array(e),r=0;rn?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},s.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},s.simpleMap=function(t,e,n,r){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,n)?a>10?(s.warn("randstr failed uniqueness"),c):t(e,n,r,(a||0)+1):c},s.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={optionList:[],_newoption:function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)}};return n["_"+e]=t,n},s.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var n,r,a,i,o=t.length,l=2*o,s=2*e-1,c=new Array(s),u=new Array(o);for(n=0;n=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=o&&(a=l-1-a),i+=t[a]*c[r];u[n]=i}return u},s.syncOrAsync=function(t,e,n){var r;function a(){return s.syncOrAsync(t,e,n)}for(;t.length;)if((r=(0,t.splice(0,1)[0])(e))&&r.then)return r.then(a).then(void 0,s.promiseError);return n&&n(e)},s.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},s.noneOrAll=function(t,e,n){if(t){var r,a=!1,i=!0;for(r=0;r1?a+o[1]:"";if(i&&(o.length>1||l.length>4||n))for(;r.test(l);)l=l.replace(r,"$1"+i+"$2");return l+s};var T=/%{([^\s%{}]*)}/g,A=/^\w*$/;s.templateString=function(t,e){var n={};return t.replace(T,function(t,r){return A.test(r)?e[r]||"":(n[r]=n[r]||s.nestedProperty(e,r).get,n[r]()||"")})};s.subplotSort=function(t,e){for(var n=Math.min(t.length,e.length)+1,r=0,a=0,i=0;i=48&&o<=57,c=l>=48&&l<=57;if(s&&(r=10*r+o-48),c&&(a=10*a+l-48),!s||!c){if(r!==a)return r-a;if(o!==l)return o-l}}return a-r};var L=2e9;s.seedPseudoRandom=function(){L=2e9},s.pseudoRandom=function(){var t=L;return L=(69069*L+1)%4294967296,Math.abs(L-t)<429496729?s.pseudoRandom():L/4294967296}},{"../constants/numerical":145,"./angles":149,"./array":150,"./clean_number":151,"./clear_responsive":153,"./coerce":154,"./dates":155,"./extend":157,"./filter_unique":158,"./filter_visible":159,"./geometry2d":162,"./get_graph_div":163,"./identity":164,"./is_plain_object":166,"./keyed_container":167,"./localize":168,"./loggers":169,"./make_trace_groups":170,"./matrix":171,"./mod":172,"./nested_property":173,"./noop":174,"./notifier":175,"./push_unique":178,"./regex":180,"./relative_attr":181,"./relink_private":182,"./search":183,"./stats":185,"./throttle":187,"./to_log_range":188,d3:9,"fast-isnumeric":11}],166:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],167:[function(t,e,n){"use strict";var r=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,n,i){var o,l,s;n=n||"name",i=i||"value";var c={};e&&e.length?(s=r(t,e),l=s.get()):l=t,e=e||"";var u={};if(l)for(o=0;o2)return c[e]=2|c[e],d.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],173:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(r(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,i,o,s=0,c=e.split(".");s/g),o=0;oi||c===a||cl||e&&s(t))}:function(t,e){var s=t[0],c=t[1];if(s===a||si||c===a||cl)return!1;var u,f,d,p,h,g=n.length,v=n[0][0],y=n[0][1],m=0;for(u=1;uMath.max(f,v)||c>Math.max(d,y)))if(cu||Math.abs(r(o,d))>a)return!0;return!1};i.filter=function(t,e){var n=[t[0]],r=0,a=0;function i(i){t.push(i);var l=n.length,s=r;n.splice(a+1);for(var c=s+1;c1&&i(t.pop());return{addPt:i,raw:t,filtered:n}}},{"../constants/numerical":145,"./matrix":171}],178:[function(t,e,n){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var n,r=e.toString();for(n=0;na.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,n;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;ne}function c(t,e){return t>=e}n.findBin=function(t,e,n){if(r(e.start))return n?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,u,f=0,d=e.length,p=0,h=d>1?(e[d-1]-e[0])/(d-1):1;for(u=h>=0?n?o:l:n?c:s,t+=1e-9*h*(n?-1:1)*(h>=0?1:-1);f90&&a.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,a=e[r]-e[0]||1,i=a/(r||1)/1e4,o=[e[0]],l=0;le[l]+i&&(a=Math.min(a,e[l+1]-e[l]),o.push(e[l+1]));return{vals:o,minDiff:a}},n.roundUp=function(t,e,n){for(var r,a=0,i=e.length-1,o=0,l=n?0:1,s=n?1:0,c=n?Math.ceil:Math.floor;a0&&(r=1),n&&r)return t.sort(e)}return r?t:t.reverse()},n.findIndexOfMin=function(t,e){e=e||i;for(var n,r=1/0,a=0;ai.length)&&(o=i.length),r(e)||(e=!1),a(i[0])){for(s=new Array(o),l=0;lt.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"./array":150,"fast-isnumeric":11}],186:[function(t,e,n){"use strict";var r=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function l(t,e){return t.node().getBoundingClientRect()[e]}var s=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;n.convertToTspans=function(t,e,v){var L=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&L.match(s),P=r.select(t.node().parentNode);if(!P.empty()){var O=t.attr("class")?t.attr("class").split(" ")[0]:"text";return O+="-math",P.selectAll("svg."+O).remove(),P.selectAll("g."+O+"-group").remove(),t.style("display",null).attr({"data-unformatted":L,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var n=parseInt(t.node().style.fontSize,10),i={fontSize:n};!function(t,e,n){var i,o,l,s;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),l=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var n="math-output-"+a.randstr({},64);return s=r.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(s.node())},function(){var e=r.select("body").select("#MathJax_SVG_glyphs");if(s.select(".MathJax_SVG").empty()||!s.select("svg").node())a.log("There was an error in the tex syntax.",t),n();else{var o=s.select("svg").node().getBoundingClientRect();n(s.select(".MathJax_SVG"),e,o)}if(s.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==l&&(MathJax.Hub.processSectionDelay=l),MathJax.Hub.Config(o)})}(S[2],i,function(r,a,i){P.selectAll("svg."+O).remove(),P.selectAll("g."+O+"-group").remove();var o=r&&r.select("svg");if(!o||!o.node())return z(),void e();var s=P.append("g").classed(O+"-group",!0).attr({"pointer-events":"none","data-unformatted":L,"data-math":"Y"});s.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:O,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=l(o,"width"),f=l(o,"height"),d=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(n||l(t,"height"))/4;"y"===O[0]?(s.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===O[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===O[0]?o.attr({x:0,y:p}):o.attr({x:d,y:+t.attr("y")+p-f/2}),v&&v.call(t,s),e(s)})})):z(),t}function z(){P.empty()||(O=t.attr("class")+"-math",P.select("svg."+O).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var n,l=!1,s=[],c=-1;function u(){c++;var e=document.createElementNS(i.svg,"tspan");r.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),n=e;var a=s;if(s=[{node:e}],a.length>1)for(var l=1;l doesnt match end tag <"+t+">. Pretending it did match.",e),n=s[s.length-1].node}else a.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(n=t,s=[{node:t}]);for(var P=e.split(m),O=0;O|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},d={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},h="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,m=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,M=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function T(t,e){if(!t)return null;var n=t.match(e),r=n&&(n[3]||n[4]);return r&&C(r)}var A=/(^|;)\s*color:/;n.plainText=function(t){return(t||"").replace(v," ")};var L={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function C(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var n=String.fromCharCode;return t<=65535?n(t):n(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):L[e])||t})}function P(t,e,n){var r,a,i,o=n.horizontalAlign,l=n.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-r.height}:"middle"===l?function(){return s.top+(s.height-r.height)/2}:function(){return s.top},i="right"===o?function(){return s.right-r.width}:"center"===o?function(){return s.left+(s.width-r.width)/2}:function(){return s.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:i()-c.left+"px","z-index":1e3}),this}}n.convertEntities=C,n.lineCount=function(t){return t.selectAll("tspan.line").size()||1},n.positionText=function(t,e,n){return t.each(function(){var t=r.select(this);function a(e,n){return void 0===n?null===(n=t.attr(e))&&(t.attr(e,0),n=0):t.attr(e,n),n}var i=a("x",e),o=a("y",n);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},n.makeEditable=function(t,e){var n=e.gd,a=e.delegate,i=r.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function l(){!function(){var a=r.select(n).select(".svg-container"),o=a.append("div"),l=t.node().style,c=parseFloat(l.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":l.fontFamily||"Arial","font-size":c,color:e.fill||l.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(P(t,a,e)).on("blur",function(){n._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=r.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&r.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;r.select(this).transition().duration(0).remove(),r.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;n._editing=!0,r.select(document).on("mouseup",function(){if(r.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===r.event.which?(n._editing=!1,t.style({opacity:1}),r.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),r.select(this).call(P(t,a,e)))}).on("keydown",function(){13===r.event.which&&this.blur()}).call(s)}(),t.style({opacity:0});var a,l=o.attr("class");(a=l?"."+l.split(" ")[0]+"-math-group":"[class*=-math-group]")&&r.select(t.node().parentNode).select(a).style({opacity:0})}function s(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}return e.immediate?l():o.on("click",l),r.rebind(t,i,"on")}},{"../constants/alignment":143,"../constants/xmlns_namespaces":146,"../lib":165,d3:9}],187:[function(t,e,n){"use strict";var r={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}n.throttle=function(t,e,n){var i=r[t],o=Date.now();if(!i){for(var l in r)r[l].tsi.ts+e?s():i.timer=setTimeout(function(){s(),i.timer=null},e)},n.done=function(t){var e=r[t];return e&&e.timer?new Promise(function(t){var n=e.onDone;e.onDone=function(){n&&n(),t(),e.onDone=null}}):Promise.resolve()},n.clear=function(t){if(t)a(r[t]),delete r[t];else for(var e in r)n.clear(e)}},{}],188:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var n=Math.log(Math.min(e[0],e[1]))/Math.LN10;return r(n)||(n=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),n}},{"fast-isnumeric":11}],189:[function(t,e,n){"use strict";var r=e.exports={},a=t("../plots/geo/constants").locationmodeToLayer,i=t("topojson-client").feature;r.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},r.getTopojsonPath=function(t,e){return t+e+".json"},r.getTopojsonFeatures=function(t,e){var n=a[t.locationmode],r=e.objects[n];return i(e,r).features}},{"../plots/geo/constants":239,"topojson-client":28}],190:[function(t,e,n){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],191:[function(t,e,n){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],192:[function(t,e,n){"use strict";var r=t("../registry");e.exports=function(t){for(var e,n,a=r.layoutArrayContainers,i=r.layoutArrayRegexes,o=t.split("[")[0],l=0;l0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},n.cleanLayout=function(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var r=(l.subplotsRegistry.cartesian||{}).attrRegex,i=(l.subplotsRegistry.gl3d||{}).attrRegex,s=Object.keys(t);for(e=0;e3?(A.x=1.02,A.xanchor="left"):A.x<-2&&(A.x=-.02,A.xanchor="right"),A.y>3?(A.y=1.02,A.yanchor="bottom"):A.y<-2&&(A.y=-.02,A.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t},n.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}n.hasParent=function(t,e){for(var n=m(e);n;){if(n in t)return!0;n=m(n)}return!1};var x=["x","y","z"];n.clearAxisTypes=function(t,e,n){for(var r=0;r1&&o.warn("Full array edits are incompatible with other edits",f);var m=n[""][""];if(u(m))e.set(null);else{if(!Array.isArray(m))return o.warn("Unrecognized full array edit value",f,m),!0;e.set(m)}return!g&&(d(v,y),p(t),!0)}var x,b,_,w,k,M,T,A=Object.keys(n).map(Number).sort(l),L=e.get(),S=L||[],C=r(y,f).get(),P=[],O=-1,z=S.length;for(x=0;xS.length-(T?0:1))o.warn("index out of range",f,_);else if(void 0!==M)k.length>1&&o.warn("Insertion & removal are incompatible with edits to the same index.",f,_),u(M)?P.push(_):T?("add"===M&&(M={}),S.splice(_,0,M),C&&C.splice(_,0,{})):o.warn("Unrecognized full object edit value",f,_,M),-1===O&&(O=_);else for(b=0;b=0;x--)S.splice(P[x],1),C&&C.splice(P[x],1);if(S.length?L||e.set(S):e.set(null),g)return!1;if(d(v,y),h!==i){var D;if(-1===O)D=A;else{for(z=Math.max(S.length,z),D=[],x=0;x=O);x++)D.push(_);for(x=O;x=t.data.length||a<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(a,r+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+n+" must be unique.")}}function D(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),z(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&z(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function E(t,e,n,r,i){!function(t,e,n,r){var a=o.isPlainObject(r);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof n)throw new Error("indices must be an integer or array of integers");for(var i in z(t,n,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==n.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in r)||!Array.isArray(r[i])||r[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,n,r);for(var l=function(t,e,n,r){var i,l,s,c,u,f=o.isPlainObject(r),d=[];for(var p in Array.isArray(n)||(n=[n]),n=O(n,t.data.length-1),e)for(var h=0;h=0&&n=0&&n0&&"string"!=typeof C.parts[O];)O--;var z=C.parts[O],D=C.parts[O-1]+"."+z,E=C.parts.slice(0,O).join("."),R=o.nestedProperty(t.layout,E).get(),I=o.nestedProperty(l,E).get(),F=C.get();if(void 0!==P){m[S]=P,x[S]="reverse"===z?P:N(F);var j=u.getLayoutValObject(l,C.parts);if(j&&j.impliedEdits&&null!==P)for(var V in j.impliedEdits)b(o.relativeAttr(S,V),j.impliedEdits[V]);if(-1!==["width","height"].indexOf(S))if(P){b("autosize",null);var G="height"===S?"width":"height";b(G,l[G])}else l[S]=t._initialAutoSize[S];else if("autosize"===S)b("width",P?null:l.width),b("height",P?null:l.height);else if(D.match(B))L(D),o.nestedProperty(l,E+"._inputRange").set(null);else if(D.match(H)){L(D),o.nestedProperty(l,E+"._inputRange").set(null);var Z=o.nestedProperty(l,E).get();Z._inputDomain&&(Z._input.domain=Z._inputDomain.slice())}else D.match(q)&&o.nestedProperty(l,E+"._inputDomain").set(null);if("type"===z){var Y=R,X="linear"===I.type&&"log"===P,W="log"===I.type&&"linear"===P;if(X||W){if(Y&&Y.range)if(I.autorange)X&&(Y.range=Y.range[1]>Y.range[0]?[1,2]:[2,1]);else{var J=Y.range[0],Q=Y.range[1];X?(J<=0&&Q<=0&&b(E+".autorange",!0),J<=0?J=Q/1e6:Q<=0&&(Q=J/1e6),b(E+".range[0]",Math.log(J)/Math.LN10),b(E+".range[1]",Math.log(Q)/Math.LN10)):(b(E+".range[0]",Math.pow(10,J)),b(E+".range[1]",Math.pow(10,Q)))}else b(E+".autorange",!0);Array.isArray(l._subplots.polar)&&l._subplots.polar.length&&l[C.parts[0]]&&"radialaxis"===C.parts[1]&&delete l[C.parts[0]]._subplot.viewInitial["radialaxis.range"],c.getComponentMethod("annotations","convertCoords")(t,I,P,b),c.getComponentMethod("images","convertCoords")(t,I,P,b)}else b(E+".autorange",!0),b(E+".range",null);o.nestedProperty(l,E+"._inputRange").set(null)}else if(z.match(T)){var $=o.nestedProperty(l,S).get(),K=(P||{}).type;K&&"-"!==K||(K="linear"),c.getComponentMethod("annotations","convertCoords")(t,$,K,b),c.getComponentMethod("images","convertCoords")(t,$,K,b)}var tt=_.containerArrayMatch(S);if(tt){n=tt.array,r=tt.index;var et=tt.property,nt=(o.nestedProperty(i,n)||[])[r]||{},rt=j||{editType:"calc"};""!==r&&""===et&&(_.isAddVal(P)?x[S]=null:_.isRemoveVal(P)?x[S]=nt:o.warn("unrecognized full object value",e)),M.update(y,rt),d[n]||(d[n]={});var at=d[n][r];at||(at=d[n][r]={}),at[et]=P,delete e[S]}else"reverse"===z?(R.range?R.range.reverse():(b(E+".autorange",!0),R.range=[1,0]),I.autorange?y.calc=!0:y.plot=!0):(l._has("scatter-like")&&l._has("regl")&&"dragmode"===S&&("lasso"===P||"select"===P)&&"lasso"!==F&&"select"!==F?y.plot=!0:j?M.update(y,j):y.calc=!0,C.set(P))}}for(n in d){_.applyContainerArrayChanges(t,o.nestedProperty(i,n),d[n],y)||(y.plot=!0)}var it=l._axisConstraintGroups||[];for(k in A)for(r=0;r=a.length?a[0]:a[t]:a}function s(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function c(t,e){var n=0;return function(){if(t&&++n===e)return t()}}return void 0===r._frameWaitingCnt&&(r._frameWaitingCnt=0),new Promise(function(i,u){function d(){r._currentFrame&&r._currentFrame.onComplete&&r._currentFrame.onComplete();var e=r._currentFrame=r._frameQueue.shift();if(e){var n=e.name?e.name.toString():null;t._fullLayout._currentFrame=n,r._lastFrameAt=Date.now(),r._timeToNext=e.frameOpts.duration,f.transition(t,e.frame.data,e.frame.layout,w.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:n,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(r._animationRaf),r._animationRaf=null}function p(){t.emit("plotly_animating"),r._lastFrameAt=-1/0,r._timeToNext=0,r._runningTransitions=0,r._currentFrame=null;var e=function(){r._animationRaf=window.requestAnimationFrame(e),Date.now()-r._lastFrameAt>r._timeToNext&&d()};e()}var h,g,v=0;function y(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var m=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))m.push({type:"object",data:y(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(h=0;h0&&MM)&&T.push(g);m=T}}m.length>0?function(e){if(0!==e.length){for(var a=0;a=0;r--)if(o.isPlainObject(e[r])){var g=e[r].name,v=(u[g]||h[g]||{}).name,y=e[r].name,m=u[v]||h[v];v&&y&&"number"==typeof y&&m&&A<5&&(A++,o.warn('addFrames: overwriting frame "'+(u[v]||h[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===A&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),h[g]={name:g},p.push({frame:f.supplyFrameDefaults(e[r]),index:n&&void 0!==n[r]&&null!==n[r]?n[r]:d+r})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;r--){if("number"==typeof(a=p[r].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;u[a.name="frame "+t._transitionData._counter++];);if(u[a.name]){for(i=0;i=0;n--)r=e[n],i.push({type:"delete",index:r}),l.unshift({type:"insert",index:r,value:a[r]});var c=f.modifyFrames,u=f.modifyFrames,d=[t,l],p=[t,i];return s&&s.add(t,c,d,u,p),f.modifyFrames(t,i)},n.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},n=t._fullData||[];return f.cleanPlot([],{},n,e),f.purge(t),l.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":45,"../components/colorbar/connect":47,"../components/drawing":70,"../constants/xmlns_namespaces":146,"../lib":165,"../lib/events":156,"../lib/queue":179,"../lib/svg_text_utils":186,"../plots/cartesian/axes":210,"../plots/cartesian/constants":216,"../plots/cartesian/graph_interact":220,"../plots/plots":251,"../plots/polar/legacy":254,"../registry":259,"./edit_types":193,"./helpers":194,"./manage_arrays":196,"./plot_config":198,"./plot_schema":199,"./subroutines":201,d3:9,"fast-isnumeric":11,"has-hover":13}],198:[function(t,e,n){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],199:[function(t,e,n){"use strict";var r=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),l=t("../plots/frame_attributes"),s=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),d=a.extendFlat,p=a.extendDeepAll,h=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",y=[g,v,"_arrayAttrRegexps","_deprecated"];function m(t,e,n){if(!t)return!1;if(t._isLinkedToArray)if(x(e[n]))n++;else if(n=i.length)return!1;if(2===t.dimensions){if(n++,e.length===n)return t;var o=e[n];if(!x(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){n.crawl(t,function(t,e,r){n.isValObject(t)?"data_array"===t.valType?(t.role="data",r[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(r[e+"src"]={valType:"string",editType:"none"}):h(t)&&(t.role="object")})}(t),function(t){n.crawl(t,function(t,e,n){if(!t)return;var r=t[v];if(!r)return;delete t[v],n[e]={items:{}},n[e].items[r]=t,n[e].role="object"})}(t),function(t){!function t(e){for(var n in e)if(h(e[n]))t(e[n]);else if(Array.isArray(e[n]))for(var r=0;r=s.length)return!1;a=(n=(r.transformsRegistry[s[u].type]||{}).attributes)&&n[e[2]],l=3}else if("area"===t.type)a=c[o];else{var f=t._module;if(f||(f=(r.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(n=f.attributes)&&n[o])){var d=f.basePlotModule;d&&d.attributes&&(a=d.attributes[o])}a||(a=i[o])}return m(a,e,l)},n.getLayoutValObject=function(t,e){return m(function(t,e){var n,a,i,l,s=t._basePlotModules;if(s){var c;for(n=0;n=a&&(n._input||{})._templateitemname;l&&(o=a);var s,c=e+"["+o+"]";function u(){s={},l&&(s[c]={},s[c][i]=l)}function f(t,e){l?r.nestedProperty(s[c],t).set(e):s[c+"."+t]=e}function d(){var t=s;return u(),t}return u(),{modifyBase:function(t,e){s[t]=e},modifyItem:f,getUpdateObj:d,applyUpdate:function(e,n){e&&f(e,n);var a=d();for(var i in a)r.nestedProperty(t,i).set(a[i])}}}},{"../lib":165,"../plots/attributes":207}],201:[function(t,e,n){"use strict";var r=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),l=t("../lib/clear_gl_canvases"),s=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),d=t("../plots/cartesian/axes"),p=t("../constants/alignment"),h=t("../plots/cartesian/constraints"),g=h.enforce,v=h.clean,y=t("../plots/cartesian/autorange").doAutoRange;function m(t,e,n){for(var r=0;r=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function x(t){var e,a,i,l,u,h=t._fullLayout,g=h._size,v=g.p,y=d.list(t,"",!0);if(h._paperdiv.style({width:t._context.responsive&&h.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":h.width+"px",height:t._context.responsive&&h.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":h.height+"px"}).selectAll(".main-svg").call(c.setSize,h.width,h.height),t._context.setBackground(t,h.paper_bgcolor),n.drawMainTitle(t),f.manage(t),!h._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,n){var r=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===n?e._offset-v-r:e._offset+e._length+v+r:g.t+g.h*(1-(t.position||0))+r%1:e?"right"===n?e._offset+e._length+v+r:e._offset-v-r:g.l+g.w*(t.position||0)+r%1}for(e=0;ek?u.push({code:"unused",traceType:m,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:m,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,n){for(var r in e)if("_"!==r.charAt(0)){var i=e[r],o=p(e,r,n);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&u.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&h(i)&&t(i,o)}}({data:v,layout:d},""),u.length)return u.map(g)}},{"../lib":165,"../plots/attributes":207,"../plots/plots":251,"./plot_config":198,"./plot_schema":199,"./plot_template":200}],203:[function(t,e,n){"use strict";var r=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),l=t("../snapshot/svgtoimg"),s={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var n,u,f;function d(t){return!(t in e)||a.validate(e[t],s[t])}if(e=e||{},a.isPlainObject(t)?(n=t.data||[],u=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),n=a.extendDeep([],t.data),u=a.extendDeep({},t.layout),f=t._context),!d("width")||!d("height"))throw new Error("Height and width should be pixel values.");if(!d("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function h(t,n){return a.coerce(e,p,s,t,n)}var g=h("format"),v=h("width"),y=h("height"),m=h("scale"),x=h("setBackground"),b=h("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},u);v&&(w.width=v),y&&(w.height=y);var k=a.extendFlat({},f,{staticPlot:!0,setBackground:x}),M=i.getRedrawFunc(_);function T(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function A(){return new Promise(function(t,e){var n=o(_,g,m),i=_._fullLayout.width,s=_._fullLayout.height;if(r.purge(_),document.body.removeChild(_),"svg"===g)return t(b?n:"data:image/svg+xml,"+encodeURIComponent(n));var c=document.createElement("canvas");c.id=a.randstr(),l({format:g,width:i,height:s,scale:m,canvas:c,svg:n,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){r.plot(_,n,w,k).then(M).then(T).then(A).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":165,"../snapshot/helpers":263,"../snapshot/svgtoimg":265,"../snapshot/tosvg":267,"./plot_api":197}],204:[function(t,e,n){"use strict";var r=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),l=r.isPlainObject,s=Array.isArray,c=r.isArrayOrTypedArray;function u(t,e,n,a,i,o){o=o||[];for(var f=Object.keys(t),d=0;dx.length&&a.push(p("unused",i,y.concat(x.length)));var M,T,A,L,S,C=x.length,P=Array.isArray(k);if(P&&(C=Math.min(C,k.length)),2===b.dimensions)for(T=0;Tx[T].length&&a.push(p("unused",i,y.concat(T,x[T].length)));var O=x[T].length;for(M=0;M<(P?Math.min(O,k[T].length):O);M++)A=P?k[T][M]:k,L=m[T][M],S=x[T][M],r.validate(L,A)?S!==L&&S!==+L&&a.push(p("dynamic",i,y.concat(T,M),L,S)):a.push(p("value",i,y.concat(T,M),L))}else a.push(p("array",i,y.concat(T),m[T]));else for(T=0;T1&&d.push(p("object","layout"))),a.supplyDefaults(h);for(var g=h._fullData,v=n.length,y=0;y0&&((b=T-o(v)-o(y))>A?_/b>L&&(m=v,x=y,L=_/b):_/T>L&&(m={val:v.val,pad:0},x={val:y.val,pad:0},L=_/T));if(d===p){var S=d-1,C=d+1;if(k)if(0===d)i=[0,1];else{var P=(d>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),O=d/(1-Math.min(.5,P/T));i=d>0?[0,O]:[O,0]}else i=M?[Math.max(0,S),Math.max(1,C)]:[S,C]}else k?(m.val>=0&&(m={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):M&&(m.val-L*o(m)<0&&(m={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),L=(x.val-m.val)/(T-o(m)-o(x)),i=[m.val-L*o(m),x.val+L*o(x)];return h&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function l(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function s(t,e){var n,r,a,i=e._id,o=t._fullData,l=t._fullLayout,s=[],f=[];function d(t,e){for(n=0;n=n&&(c.extrapad||!o)){l=!1;break}a(e,c.val)&&c.pad<=n&&(o||!c.extrapad)&&(t.splice(s,1),s--)}if(l){var u=i&&0===e;t.push({val:e,pad:u?0:n,extrapad:!u&&o})}}function d(t){return r(t)&&Math.abs(t)=e}e.exports={getAutoRange:o,makePadFn:l,doAutoRange:function(t,e){e._length||e.setScale();var n;e.autorange&&(e.range=o(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l),(n=e._input).range=e.range.slice(),n.autorange=e.autorange);if(e._anchorAxis&&e._anchorAxis.rangeslider){var r=e._anchorAxis.rangeslider[e._name];r&&"auto"===r.rangemode&&(r.range=o(t,e)),(n=e._anchorAxis._input).rangeslider[e._name]=a.extendFlat({},r)}},findExtremes:function(t,e,n){n||(n={});t._m||t.setScale();var a,o,l,s,f,p,h,g,v,y=[],m=[],x=e.length,b=n.padded||!1,_=n.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function M(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var T=M((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),A=M((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),L=M(n.vpadplus||n.vpad),S=M(n.vpadminus||n.vpad);if(!k){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=O;a--)P(a);return{min:y,max:m}},concatExtremes:s}},{"../../constants/numerical":145,"../../lib":165,"fast-isnumeric":11}],210:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),d=t("./layout_attributes"),p=t("./clean_ticks"),h=t("../../constants/numerical"),g=h.ONEAVGYEAR,v=h.ONEAVGMONTH,y=h.ONEDAY,m=h.ONEHOUR,x=h.ONEMIN,b=h.ONESEC,_=h.MINUS_SIGN,w=h.BADNUM,k=t("../../constants/alignment").MID_SHIFT,M=t("../../constants/alignment").LINE_SPACING,T=e.exports={};T.setConvert=t("./set_convert");var A=t("./axis_autotype"),L=t("./axis_ids");T.id2name=L.id2name,T.name2id=L.name2id,T.cleanId=L.cleanId,T.list=L.list,T.listIds=L.listIds,T.getFromId=L.getFromId,T.getFromTrace=L.getFromTrace;var S=t("./autorange");T.getAutoRange=S.getAutoRange,T.findExtremes=S.findExtremes,T.coerceRef=function(t,e,n,r,a,i){var o=r.charAt(r.length-1),s=n._fullLayout._subplots[o+"axis"],c=r+"ref",u={};return a||(a=s[0]||i),i||(i=a),u[c]={valType:"enumerated",values:s.concat(i?[i]:[]),dflt:a},l.coerce(t,e,u,c)},T.coercePosition=function(t,e,n,r,a,i){var o,s;if("paper"===r||"pixel"===r)o=l.ensureNumber,s=n(a,i);else{var c=T.getFromId(e,r);s=n(a,i=c.fraction2r(i)),o=c.cleanPos}t[a]=o(s)},T.cleanPosition=function(t,e,n){return("paper"===n||"pixel"===n?l.ensureNumber:T.getFromId(e,n).cleanPos)(t)};var C=T.getDataConversions=function(t,e,n,r){var a,i="x"===n||"y"===n||"z"===n?n:r;if(Array.isArray(i)){if(a={type:A(r),_categories:[]},T.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.saveRangeInitial=function(t,e){for(var n=T.list(t,"",!0),r=!1,a=0;a.3*d||u(r)||u(i))){var p=n.dtick/2;t+=t+p.8){var o=Number(n.substr(1));i.exactYears>.8&&o%12==0?t=T.tickIncrement(t,"M6","reverse")+1.5*y:i.exactMonths>.8?t=T.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var s=T.tickIncrement(t,n);if(s<=r)return s}return t}(x,t,m,c,i)),v=x,0;v<=u;)v=T.tickIncrement(v,m,!1,i),0;return{start:e.c2r(x,0,i),end:e.c2r(v,0,i),size:m,_dataSpan:u-c}},T.prepTicks=function(t){var e=l.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var n,r=t.nticks;r||("category"===t.type?(n=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/n):(n="y"===t._id.charAt(0)?40:80,r=l.constrain(t._length/n,4,9)+1),"radialaxis"===t._name&&(r*=2)),"array"===t.tickmode&&(r*=100),T.autoTicks(t,Math.abs(e[1]-e[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),B(t)},T.calcTicks=function(t){T.prepTicks(t);var e=l.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e,n,r=t.tickvals,a=t.ticktext,i=new Array(r.length),o=l.simpleMap(t.range,t.r2l),s=1.0001*o[0]-1e-4*o[1],c=1.0001*o[1]-1e-4*o[0],u=Math.min(s,c),f=Math.max(s,c),d=0;Array.isArray(a)||(a=[]);var p="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(n=0;nu&&e=r:c<=r)&&!(i.length>s||c===o);c=T.tickIncrement(c,t.dtick,a,t.calendar))o=c,i.push(c);J(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(i.length),f=0;f10||"01-01"!==r.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&i<=10||e>=15*y)t._tickround="d";else if(e>=x&&i<=16||e>=m)t._tickround="M";else if(e>=b&&i<=19||e>=x)t._tickround="S";else{var o=t.l2r(n+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var l=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var s=Math.max(Math.abs(l[0]),Math.abs(l[1])),c=Math.floor(Math.log(s)/Math.LN10+.01);Math.abs(c)>3&&(V(t.exponentformat)&&!U(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function H(t,e,n){var r=t.tickfont||{};return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}T.autoTicks=function(t,e){var n;function r(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=l.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,n=r(10),t.dtick="M"+12*j(e,n,z)):i>v?(e/=v,t.dtick="M"+j(e,1,D)):i>y?(t.dtick=j(e,y,R),t.tick0=l.dateTick0(t.calendar,!0)):i>m?t.dtick=j(e,m,D):i>x?t.dtick=j(e,x,E):i>b?t.dtick=j(e,b,E):(n=r(10),t.dtick=j(e,n,z))}else if("log"===t.type){t.tick0=0;var o=l.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var s=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/s,n=r(10),t.dtick="L"+j(e,n,z)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):J(t)?(t.tick0=0,n=1,t.dtick=j(e,n,F)):(t.tick0=0,n=r(10),t.dtick=j(e,n,z));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},T.tickIncrement=function(t,e,n,i){var o=n?-1:1;if(a(e))return t+o*e;var s=e.charAt(0),c=o*Number(e.substr(1));if("M"===s)return l.incrementMonth(t,c,i);if("L"===s)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===s){var u="D2"===e?I:N,f=t+.01*o,d=l.roundUp(l.mod(f,1),u,n);return Math.floor(f)+Math.log(r.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.r2l||Number,n=l.simpleMap(t.range,e),i=n[1]"+s,t._prevDateHead=s));e.text=c}(t,o,n,c):"log"===t.type?function(t,e,n,r,i){var o=t.dtick,s=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===i&&(i="");r&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,s),t,i,r);else if(a(o)||"D"===u&&l.mod(s+.01,1)<.1){var f=Math.round(s),d=Math.abs(f),p=t.exponentformat;"power"===p||V(p)&&U(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+d+"",e.fontSize*=1.25):("e"===p||"E"===p)&&d>2?e.text="1"+p+(f>0?"+":_)+d:(e.text=G(Math.pow(10,s),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,l.mod(s,1)))),e.fontSize*=.75}if("D1"===t.dtick){var h=String(e.text).charAt(0);"0"!==h&&"1"!==h||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(s<0?.5:.25)))}}(t,o,0,c,r):"category"===t.type?function(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n="");e.text=String(n)}(t,o):J(t)?function(t,e,n,r,a){if("radians"!==t.thetaunit||n)e.text=G(e.x,t,a,r);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var n=function(t){var n=1;for(;!e(Math.round(t*n)/n,t);)n*=10;return n}(t),r=t*n,a=Math.abs(function t(n,r){return e(r,0)?n:t(r,n%r)}(r,n));return[Math.round(r/a),Math.round(n/a)]}(i);if(o[1]>=100)e.text=G(l.deg2rad(e.x),t,a,r);else{var s=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),s&&(e.text=_+e.text)}}}}(t,o,n,c,r):function(t,e,n,r,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,r)}(t,o,0,c,r),t.tickprefix&&!p(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!p(t.showticksuffix)&&(o.text+=t.ticksuffix),o},T.hoverLabelText=function(t,e,n){if(n!==w&&n!==e)return T.hoverLabelText(t,e)+" - "+T.hoverLabelText(t,n);var r="log"===t.type&&e<=0,a=T.tickText(t,t.c2l(r?-e:e),"hover").text;return r?0===e?"0":_+a:a};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function V(t){return"SI"===t||"B"===t}function U(t){return t>14||t<-15}function G(t,e,n,r){var i=t<0,o=e._tickround,s=n||e.exponentformat||"B",c=e._tickexponent,u=T.getTickFormat(e),f=e.separatethousands;if(r){var d={exponentformat:s,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};B(d),o=(Number(d._tickround)||0)+4,c=d._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,h=Math.pow(10,-o)/2;if("none"===s&&(c=0),(t=Math.abs(t))"+p+"":"B"===s&&9===c?t+="B":V(s)&&(t+=q[c/3+5]));return i?_+t:t}function Z(t,e){var n=t.l2p(e);return n>1&&n=0,i=u(t,e[1])<=0;return(n||a)&&(r||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){n=r;break}break;case"log":for(e=0;e1)for(r=1;r2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),n=0,r=0,o={},l=0;l2*n}(t)?"category":function(t){if(!t)return!1;for(var e=0;er?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":259,"./constants":216}],214:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var l,s=n("categoryorder",a);"array"===s&&(l=n("categoryarray")),o||"array"!==s||(s=e.categoryorder="trace"),"trace"===s?e._initialCategories=[]:"array"===s?e._initialCategories=l.slice():(l=function(t,e){var n,r,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)n=e.axData;else for(n=[],r=0;rl*x)||k)for(n=0;nD&&NO&&(O=N);p/=(O-P)/(2*z),P=u.l2r(P),O=u.l2r(O),u.range=u._input.range=L=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function E(t,e,n,r,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+n+", "+r+")").attr("d",a+"Z")}function R(t,e,n){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+n+")").attr("d","M0,0Z")}function N(t,e,n,r,a,i){t.attr("d",r+"M"+n.l+","+n.t+"v"+n.h+"h"+n.w+"v-"+n.h+"h-"+n.w+"Z"),I(t,e,a,i)}function I(t,e,n,r){n||(t.transition().style("fill",r>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){r.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function j(t){L&&t.data&&t._context.showTips&&(l.notifier(l._(t,"Double-click to zoom back out"),"long"),L=!1)}function B(t){return"lasso"===t||"select"===t}function H(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,A)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(i){var n=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(n,t._onwheel),t._onwheel=e,t.addEventListener(n,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function V(t){var e=[];for(var n in t)e.push(t[n]);return e}e.exports={makeDragBox:function(t,e,n,i,c,d,L,S){var I,U,G,Z,Y,X,W,J,Q,$,K,tt,et,nt,rt,at,it,ot,lt,st,ct,ut=t._fullLayout._zoomlayer,ft=L+S==="nsew",dt=1===(L+S).length;function pt(){if(I=e.xaxis,U=e.yaxis,Q=I._length,$=U._length,W=I._offset,J=U._offset,(G={})[I._id]=I,(Z={})[U._id]=U,L&&S)for(var n=e.overlays,r=0;r-1&&w(a,t,Y,X,e.id,At),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===n&&dt){var l=L?U:I,c="s"===L||"w"===S?0:1,u=l._name+".range["+c+"]",d=function(t,e){var n,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,r.format("."+n+"g")(Math.pow(10,a))):(n=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,r.format("."+String(n)+"g")(a))}(l,c),p="left",h="middle";if(l.fixedrange)return;L?(h="n"===L?"top":"bottom","right"===l.side&&(p="right")):"e"===S&&(p="right"),t._context.showAxisRangeEntryBoxes&&r.select(gt).call(s.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(d),fill:l.tickfont?l.tickfont.color:"#444",horizontalAlign:p,verticalAlign:h}).on("edit",function(e){var n=l.d2r(e);void 0!==n&&o.call("relayout",t,u,n)})}}function Ct(e,n){if(t._transitioningWithDuration)return!1;var r=Math.max(0,Math.min(Q,e+vt)),a=Math.max(0,Math.min($,n+yt)),i=Math.abs(r-vt),o=Math.abs(a-yt);function l(){wt="",mt.r=mt.l,mt.t=mt.b,Mt.attr("d","M0,0Z")}mt.l=Math.min(vt,r),mt.r=Math.max(vt,r),mt.t=Math.min(yt,a),mt.b=Math.max(yt,a),rt?i>A||o>A?(wt="xy",i/Q>o/$?(o=i*$/Q,yt>a?mt.t=yt-o:mt.b=yt+o):(i=o*Q/$,vt>r?mt.l=vt-i:mt.r=vt+i),Mt.attr("d",H(mt))):l():!et||o10||n.scrollWidth-n.clientWidth>10)){clearTimeout(Et);var r=-e.deltaY;if(isFinite(r)||(r=e.wheelDelta/10),isFinite(r)){var a,i=Math.exp(-Math.min(Math.max(r,-20),20)/200),o=Nt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(at){for(S||(s=.5),a=0;ag[1]-.01&&(e.domain=l),a.noneOrAll(t.domain,e.domain,l)}return n("layer"),e}},{"../../lib":165,"fast-isnumeric":11}],227:[function(t,e,n){"use strict";var r=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,n){void 0===n&&(n=r[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*n;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":143}],228:[function(t,e,n){"use strict";var r=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),l=t("../../lib/polygon"),s=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),d=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),h=p.MINSELECT,g=l.filter,v=l.tester;function y(t){return t._id}function m(t,e,n,r,a,i,o){var l,s,c,u,f,d,p,h,g,v=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,m=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var x=function(t,e){var n,r,a=t[0],i=-1,o=[];for(r=0;r0?function(t,e){var n,r,a,i=[];for(a=0;a0&&i.push(n);if(1===i.length&&i[0]===e.searchInfo&&(r=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=n.selectedpoints.length)>1)return!1}return 1===a}(l)&&(d=A(x))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",r)}function A(t){var e=t.searchInfo.cd[0].trace,n=t.pointNumber,r=t.pointNumbers,a=r.length>0?r[0]:n;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function L(t,e,n){var r,i,o,l;if(n){var s=n.points||[];for(r=0;r-1&&m(e,A,a.xaxes,a.yaxes,a.subplot,a,U),"event"===n&&A.emit("plotly_selected",void 0);o.click(A,e)})},a.doneFn=function(){Z.remove(),s.done(Y).then(function(){s.clear(Y),a.gd.emit("plotly_selected",b),d&&a.selectionDefs&&(d.subtract=V,a.selectionDefs.push(d),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:C,selectOnClick:m}},{"../../components/color":45,"../../components/fx":87,"../../components/fx/helpers":84,"../../lib/clear_gl_canvases":152,"../../lib/polygon":177,"../../lib/throttle":187,"../../plot_api/subroutines":201,"../../registry":259,"./axis_ids":213,"./constants":216,polybooljs:18}],229:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,l=i.ms2DateTime,s=i.dateTime2ms,c=i.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,d=u.BADNUM,p=u.LOG_CLIP,h=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}e.exports=function(t,e){e=e||{};var n=(t._id||"x").charAt(0);function u(e,n){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&n&&t.range&&2===t.range.length){var r=t.range[0],a=t.range[1];return.5*(r+a-2*p*Math.abs(r-a))}return d}function y(e,n,r){var o=s(e,r||t.calendar);if(o===d){if(!a(e))return d;e=+e;var l=Math.floor(10*i.mod(e+.05,1)),c=Math.round(e-l/10);o=s(new Date(c))+l/10}return o}function m(e,n,r){return l(e,n,r||t.calendar)}function x(e){return t._categories[Math.round(e)]}function b(e){if(t._categoriesMap){var n=t._categoriesMap[e];if(void 0!==n)return n}if(a(e))return+e}function _(e){return a(e)?r.round(t._b+t._m*e,2):d}function w(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=_,t.p2l=w,t.c2p="log"===t.type?function(t,e){return _(u(t,e))}:_,t.p2c="log"===t.type?function(t){return v(w(t))}:w,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=w,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,n){return t.l2p(t.d2r(e,n))},t.p2d=function(t){return v(w(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=w,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=y,t.c2d=t.c2r=t.l2d=t.l2r=m,t.d2p=t.r2p=function(e,n,r){return t.l2p(y(e,0,r))},t.p2d=t.p2r=function(t,e,n){return m(w(t),e,n)},t.cleanPos=function(e){return i.cleanDate(e,d,t.calendar)}):"category"===t.type&&(t.d2c=t.d2l=function(e){if(null!=e){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var n=t._categories.length-1;return t._categoriesMap[e]=n,n}return d},t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=b,t.r2c=function(e){var n=b(e);return void 0!==n?n:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=b,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(w(t))},t.r2p=t.d2p,t.p2r=w,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var n=t.r2l(t.range[0]),r=t.r2l(t.range[1]);return t.l2r(n+e*(r-n))},t.r2fraction=function(e){var n=t.r2l(t.range[0]),r=t.r2l(t.range[1]);return(t.r2l(e)-n)/(r-n)},t.cleanRange=function(e,r){r||(r={}),e||(e="range");var o,l,s=i.nestedProperty(t,e).get();if(l=(l="date"===t.type?i.dfltRange(t.calendar):"y"===n?h.DFLTRANGEY:r.dfltRange||h.DFLTRANGEX).slice(),s&&2===s.length)for("date"===t.type&&(s[0]=i.cleanDate(s[0],d,t.calendar),s[1]=i.cleanDate(s[1],d,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(s[o],t.calendar)){t[e]=l;break}if(t.r2l(s[0])===t.r2l(s[1])){var c=i.constrain(t.r2l(s[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);s[0]=t.l2r(c-1e3),s[1]=t.l2r(c+1e3);break}}else{if(!a(s[o])){if(!a(s[1-o])){t[e]=l;break}s[o]=s[1-o]*(o?10:.1)}if(s[o]<-f?s[o]=-f:s[o]>f&&(s[o]=f),s[0]===s[1]){var u=Math.max(1,Math.abs(1e-6*s[0]));s[0]-=u,s[1]+=u}}else i.nestedProperty(t,e).set(l)},t.setScale=function(r){var a=e._size;if(t._categories||(t._categories=[]),t._categoriesMap||(t._categoriesMap={}),t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=r&&t._r?"_r":"range",l=t.calendar;t.cleanRange(o);var s=t.r2l(t[o][0],l),c=t.r2l(t[o][1],l);if("y"===n?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-c),t._b=-t._m*c):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,n){var r,a,o,l,s=t.type,c="date"===s&&e[n+"calendar"];if(n in e){if(r=e[n],l=e._length||r.length,i.isTypedArray(r)&&("linear"===s||"log"===s)){if(l===r.length)return r;if(r.subarray)return r.subarray(0,l)}for(a=new Array(l),o=0;o rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,n._offset).call(i.setScale,1,1);var r=t.plot.selectAll(".scatterlayer .trace");r.selectAll(".point").call(i.setPointGroupScale,1,1),r.selectAll(".textpoint").call(i.setTextPointsScale,1,1),r.call(i.hideOutsideRangePoints,t)}function x(e,n){var r,l,s,u=g[e.xaxis._id],f=g[e.yaxis._id],d=[];if(u){l=(r=t._fullLayout[u.axisName])._r,s=u.to,d[0]=(l[0]*(1-n)+n*s[0]-l[0])/(l[1]-l[0])*e.xaxis._length;var p=l[1]-l[0],h=s[1]-s[0];r.range[0]=l[0]*(1-n)+n*s[0],r.range[1]=l[1]*(1-n)+n*s[1],d[2]=e.xaxis._length*(1-n+n*h/p)}else d[0]=0,d[2]=e.xaxis._length;if(f){l=(r=t._fullLayout[f.axisName])._r,s=f.to,d[1]=(l[1]*(1-n)+n*s[1]-l[1])/(l[0]-l[1])*e.yaxis._length;var v=l[1]-l[0],y=s[1]-s[0];r.range[0]=l[0]*(1-n)+n*s[0],r.range[1]=l[1]*(1-n)+n*s[1],d[3]=e.yaxis._length*(1-n+n*y/v)}else d[1]=0,d[3]=e.yaxis._length;!function(e,n){var r,i=[];for(i=[e._id,n._id],r=0;rn.duration?(function(){for(var e={},n=0;n0&&(a["_"+n+"axes"]||{})[e])return a;if((a[n+"axis"]||n)===e){if(o(a,n))return a;if((a[n]||[]).length||a[n+"0"])return a}}}(e,n,l);if(!s)return;if("histogram"===s.type&&l==={v:"y",h:"x"}[s.orientation||"v"])return void(t.type="linear");var c,u=l+"calendar",f=s[u];if(o(s,l)){var d=i(s),p=[];for(c=0;c0?".":"")+i;a.isPlainObject(o)?s(o,e,l,r+1):e(l,i,o)}})}n.manageCommandObserver=function(t,e,r,o){var l={},s=!0;e&&e._commandObserver&&(l=e._commandObserver),l.cache||(l.cache={}),l.lookupTable={};var c=n.hasSimpleAPICommandBindings(t,r,l.lookupTable);if(e&&e._commandObserver){if(c)return l;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,l}if(c){i(t,c,l.cache),l.check=function(){if(s){var e=i(t,c,l.cache);return e.changed&&o&&void 0!==l.lookupTable[e.value]&&(l.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:l.lookupTable[e.value]})).then(l.enable,l.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;fa*Math.PI/180}return!1},n.getPath=function(){return r.geo.path().projection(n)},n.getBounds=function(t){return n.getPath().bounds(t)},n.fitExtent=function(t,e){var r=t[1][0]-t[0][0],a=t[1][1]-t[0][1],i=n.clipExtent&&n.clipExtent();n.scale(150).translate([0,0]),i&&n.clipExtent(null);var o=n.getBounds(e),l=Math.min(r/(o[1][0]-o[0][0]),a/(o[1][1]-o[0][1])),s=+t[0][0]+(r-l*(o[1][0]+o[0][0]))/2,c=+t[0][1]+(a-l*(o[1][1]+o[0][1]))/2;return i&&n.clipExtent(i),n.scale(150*l).translate([s,c])},n.precision(g.precision),a&&n.clipAngle(a-g.clipPad);return n}(e);u.center([c.lon-s.lon,c.lat-s.lat]).rotate([-s.lon,-s.lat,s.roll]).parallels(l.parallels);var f=[[n.l+n.w*o.x[0],n.t+n.h*(1-o.y[1])],[n.l+n.w*o.x[1],n.t+n.h*(1-o.y[0])]],d=e.lonaxis,p=e.lataxis,h=function(t,e){var n=g.clipPad,r=t[0]+n,a=t[1]-n,i=e[0]+n,o=e[1]-n;r>0&&a<0&&(a+=360);var l=(a-r)/4;return{type:"Polygon",coordinates:[[[r,i],[r,o],[r+l,o],[r+2*l,o],[r+3*l,o],[a,o],[a,i],[a-l,i],[a-2*l,i],[a-3*l,i],[r,i]]]}}(d.range,p.range);u.fitExtent(f,h);var v=this.bounds=u.getBounds(h),y=this.fitScale=u.scale(),m=u.translate();if(!isFinite(v[0][0])||!isFinite(v[0][1])||!isFinite(v[1][0])||!isFinite(v[1][1])||isNaN(m[0])||isNaN(m[0])){for(var x=this.graphDiv,b=["projection.rotation","center","lonaxis.range","lataxis.range"],_="Invalid geo settings, relayout'ing to default view.",w={},k=0;k-1&&p(r.event,i,[n.xaxis],[n.yaxis],n.id,g),c.indexOf("event")>-1&&s.click(i,r.event))})}function v(t){return n.projection.invert([t[0]+n.xaxis._offset,t[1]+n.yaxis._offset])}},x.makeFramework=function(){var t=this,e=t.graphDiv._fullLayout,n="clip"+e._uid+t.id;t.clipDef=e._clips.append("clipPath").attr("id",n),t.clipRect=t.clipDef.append("rect"),t.framework=r.select(t.container).append("g").attr("class","geo "+t.id).call(l.setClipUrl,n),t.project=function(e){var n=t.projection(e);return n?[n[0]-t.xaxis._offset,n[1]-t.yaxis._offset]:[null,null]},t.xaxis={_id:"x",c2p:function(e){return t.project(e)[0]}},t.yaxis={_id:"y",c2p:function(e){return t.project(e)[1]}},t.mockAxis={type:"linear",showexponent:"all",exponentformat:"B"},u.setConvert(t.mockAxis,e)},x.saveViewInitial=function(t){var e=t.center||{},n=t.projection,r=n.rotation||{};t._isScoped?this.viewInitial={"center.lon":e.lon,"center.lat":e.lat,"projection.scale":n.scale}:t._isClipped?this.viewInitial={"projection.scale":n.scale,"projection.rotation.lon":r.lon,"projection.rotation.lat":r.lat}:this.viewInitial={"center.lon":e.lon,"center.lat":e.lat,"projection.scale":n.scale,"projection.rotation.lon":r.lon}},x.render=function(){var t,e=this.projection,n=e.getPath();function r(t){var n=e(t.lonlat);return n?"translate("+n[0]+","+n[1]+")":null}function a(t){return e.isLonLatOverEdges(t.lonlat)?"none":null}for(t in this.basePaths)this.basePaths[t].attr("d",n);for(t in this.dataPaths)this.dataPaths[t].attr("d",function(t){return n(t.geojson)});for(t in this.dataPoints)this.dataPoints[t].attr("display",a).attr("transform",r)}},{"../../components/color":45,"../../components/dragelement":67,"../../components/drawing":70,"../../components/fx":87,"../../lib":165,"../../lib/topojson_utils":189,"../../registry":259,"../cartesian/axes":210,"../cartesian/select":228,"../plots":251,"./constants":239,"./projections":245,"./zoom":246,d3:9,"topojson-client":28}],241:[function(t,e,n){"use strict";var r=t("./geo"),a=t("../../plots/get_data").getSubplotCalcData,i=t("../../lib").counterRegex,o="geo";n.name=o,n.attr=o,n.idRoot=o,n.idRegex=n.attrRegex=i(o),n.attributes=t("./layout/attributes"),n.layoutAttributes=t("./layout/layout_attributes"),n.supplyLayoutDefaults=t("./layout/defaults"),n.plot=function(t){var e=t._fullLayout,n=t.calcdata,i=e._subplots.geo;void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var l=0;l0&&k<0&&(k+=360);var M,T,A,L=(w+k)/2;if(!c){var S=u?l.projRotate:[L,0,0];M=n("projection.rotation.lon",S[0]),n("projection.rotation.lat",S[1]),n("projection.rotation.roll",S[2]),n("showcoastlines",!u)&&(n("coastlinecolor"),n("coastlinewidth")),n("showocean")&&n("oceancolor")}(c?(T=-96.6,A=38.7):(T=u?L:M,A=(_[0]+_[1])/2),n("center.lon",T),n("center.lat",A),f)&&n("projection.parallels",l.projParallels||[0,60]);n("projection.scale"),n("showland")&&n("landcolor"),n("showlakes")&&n("lakecolor"),n("showrivers")&&(n("rivercolor"),n("riverwidth")),n("showcountries",u&&"usa"!==i)&&(n("countrycolor"),n("countrywidth")),("usa"===i||"north america"===i&&50===r)&&(n("showsubunits",!0),n("subunitcolor"),n("subunitwidth")),u||n("showframe",!0)&&(n("framecolor"),n("framewidth")),n("bgcolor")}e.exports=function(t,e,n){r(t,e,n,{type:"geo",attributes:i,handleDefaults:l,partition:"y"})}},{"../../subplot_defaults":258,"../constants":239,"./layout_attributes":244}],244:[function(t,e,n){"use strict";var r=t("../../../components/color/attributes"),a=t("../../domain").attributes,i=t("../constants"),o=t("../../../plot_api/edit_types").overrideAll,l={range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},showgrid:{valType:"boolean",dflt:!1},tick0:{valType:"number"},dtick:{valType:"number"},gridcolor:{valType:"color",dflt:r.lightLine},gridwidth:{valType:"number",min:0,dflt:1}};e.exports=o({domain:a({name:"geo"},{}),resolution:{valType:"enumerated",values:[110,50],dflt:110,coerceNumber:!0},scope:{valType:"enumerated",values:Object.keys(i.scopeDefaults),dflt:"world"},projection:{type:{valType:"enumerated",values:Object.keys(i.projNames)},rotation:{lon:{valType:"number"},lat:{valType:"number"},roll:{valType:"number"}},parallels:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},scale:{valType:"number",min:0,dflt:1}},center:{lon:{valType:"number"},lat:{valType:"number"}},showcoastlines:{valType:"boolean"},coastlinecolor:{valType:"color",dflt:r.defaultLine},coastlinewidth:{valType:"number",min:0,dflt:1},showland:{valType:"boolean",dflt:!1},landcolor:{valType:"color",dflt:i.landColor},showocean:{valType:"boolean",dflt:!1},oceancolor:{valType:"color",dflt:i.waterColor},showlakes:{valType:"boolean",dflt:!1},lakecolor:{valType:"color",dflt:i.waterColor},showrivers:{valType:"boolean",dflt:!1},rivercolor:{valType:"color",dflt:i.waterColor},riverwidth:{valType:"number",min:0,dflt:1},showcountries:{valType:"boolean"},countrycolor:{valType:"color",dflt:r.defaultLine},countrywidth:{valType:"number",min:0,dflt:1},showsubunits:{valType:"boolean"},subunitcolor:{valType:"color",dflt:r.defaultLine},subunitwidth:{valType:"number",min:0,dflt:1},showframe:{valType:"boolean"},framecolor:{valType:"color",dflt:r.defaultLine},framewidth:{valType:"number",min:0,dflt:1},bgcolor:{valType:"color",dflt:r.background},lonaxis:l,lataxis:l},"plot","from-root")},{"../../../components/color/attributes":44,"../../../plot_api/edit_types":193,"../../domain":236,"../constants":239}],245:[function(t,e,n){"use strict";e.exports=function(t){function e(t,e){return{type:"Feature",id:t.id,properties:t.properties,geometry:n(t.geometry,e)}}function n(e,r){if(!e)return null;if("GeometryCollection"===e.type)return{type:"GeometryCollection",geometries:object.geometries.map(function(t){return n(t,r)})};if(!c.hasOwnProperty(e.type))return null;var a=c[e.type];return t.geo.stream(e,r(a)),a.result()}t.geo.project=function(t,e){var a=e.stream;if(!a)throw new Error("not yet supported");return(t&&r.hasOwnProperty(t.type)?r[t.type]:n)(t,a)};var r={Feature:e,FeatureCollection:function(t,n){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,n)})}}},a=[],i=[],o={point:function(t,e){a.push([t,e])},result:function(){var t=a.length?a.length<2?{type:"Point",coordinates:a[0]}:{type:"MultiPoint",coordinates:a}:null;return a=[],t}},l={lineStart:u,point:function(t,e){a.push([t,e])},lineEnd:function(){a.length&&(i.push(a),a=[])},result:function(){var t=i.length?i.length<2?{type:"LineString",coordinates:i[0]}:{type:"MultiLineString",coordinates:i}:null;return i=[],t}},s={polygonStart:u,lineStart:u,point:function(t,e){a.push([t,e])},lineEnd:function(){var t=a.length;if(t){do{a.push(a[0].slice())}while(++t<4);i.push(a),a=[]}},polygonEnd:u,result:function(){if(!i.length)return null;var t=[],e=[];return i.forEach(function(n){!function(t){if((e=t.length)<4)return!1;for(var e,n=0,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++nr^p>r&&n<(d-c)*(r-u)/(p-u)+c&&(a=!a)}return a}(t[0],n))return t.push(e),!0})||t.push([e])}),i=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},c={Point:o,MultiPoint:o,LineString:l,MultiLineString:l,Polygon:s,MultiPolygon:s,Sphere:s};function u(){}var f=1e-6,d=f*f,p=Math.PI,h=p/2,g=(Math.sqrt(p),p/180),v=180/p;function y(t){return t>1?h:t<-1?-h:Math.asin(t)}function m(t){return t>1?0:t<-1?p:Math.acos(t)}var x=t.geo.projection,b=t.geo.projectionMutator;function _(t,e){var n=(2+h)*Math.sin(e);e/=2;for(var r=0,a=1/0;r<10&&Math.abs(a)>f;r++){var i=Math.cos(e);e-=a=(e+Math.sin(e)*(i+2)-n)/(2*i*(1+i))}return[2/Math.sqrt(p*(4+p))*t*(1+Math.cos(e)),2*Math.sqrt(p/(4+p))*Math.sin(e)]}t.geo.interrupt=function(e){var n,r=[[[[-p,0],[0,h],[p,0]]],[[[-p,0],[0,-h],[p,0]]]];function a(t,n){for(var a=n<0?-1:1,i=r[+(n<0)],o=0,l=i.length-1;oi[o][2][0];++o);var s=e(t-i[o][1][0],n);return s[0]+=e(i[o][1][0],a*n>a*i[o][0][1]?i[o][0][1]:n)[0],s}e.invert&&(a.invert=function(t,i){for(var o=n[+(i<0)],l=r[+(i<0)],c=0,u=o.length;c=0;--a){var o=r[1][a],s=180*o[0][0]/p,c=180*o[0][1]/p,u=180*o[1][1]/p,f=180*o[2][0]/p,d=180*o[2][1]/p;n.push(l([[f-e,d-e],[f-e,u+e],[s+e,u+e],[s+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(n)]}}(),s)},a},i.lobes=function(t){return arguments.length?(r=t.map(function(t){return t.map(function(t){return[[t[0][0]*p/180,t[0][1]*p/180],[t[1][0]*p/180,t[1][1]*p/180],[t[2][0]*p/180,t[2][1]*p/180]]})}),n=r.map(function(t){return t.map(function(t){var n,r=e(t[0][0],t[0][1])[0],a=e(t[2][0],t[2][1])[0],i=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return i>o&&(n=i,i=o,o=n),[[r,i],[a,o]]})}),i):r.map(function(t){return t.map(function(t){return[[180*t[0][0]/p,180*t[0][1]/p],[180*t[1][0]/p,180*t[1][1]/p],[180*t[2][0]/p,180*t[2][1]/p]]})})},i},_.invert=function(t,e){var n=.5*e*Math.sqrt((4+p)/p),r=y(n),a=Math.cos(r);return[t/(2/Math.sqrt(p*(4+p))*(1+a)),y((r+n*(a+2))/(2+h))]},(t.geo.eckert4=function(){return x(_)}).raw=_;var w=t.geo.azimuthalEqualArea.raw;function k(t,e){if(arguments.length<2&&(e=t),1===e)return w;if(e===1/0)return M;function n(n,r){var a=w(n/e,r);return a[0]*=t,a}return n.invert=function(n,r){var a=w.invert(n/t,r);return a[0]*=e,a},n}function M(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function T(t,e){return[3*t/(2*p)*Math.sqrt(p*p/3-e*e),e]}function A(t,e){return[t,1.25*Math.log(Math.tan(p/4+.4*e))]}function L(t){return function(e){var n,r=t*Math.sin(e),a=30;do{e-=n=(e+Math.sin(e)-r)/(1+Math.cos(e))}while(Math.abs(n)>f&&--a>0);return e/2}}M.invert=function(t,e){var n=2*y(e/2);return[t*Math.cos(n/2)/Math.cos(n),n]},(t.geo.hammer=function(){var t=2,e=b(k),n=e(t);return n.coefficient=function(n){return arguments.length?e(t=+n):t},n}).raw=k,T.invert=function(t,e){return[2/3*p*t/Math.sqrt(p*p/3-e*e),e]},(t.geo.kavrayskiy7=function(){return x(T)}).raw=T,A.invert=function(t,e){return[t,2.5*Math.atan(Math.exp(.8*e))-.625*p]},(t.geo.miller=function(){return x(A)}).raw=A,L(p);var S=function(t,e,n){var r=L(n);function a(n,a){return[t*n*Math.cos(a=r(a)),e*Math.sin(a)]}return a.invert=function(r,a){var i=y(a/e);return[r/(t*Math.cos(i)),y((2*i+Math.sin(2*i))/n)]},a}(Math.SQRT2/h,Math.SQRT2,p);function C(t,e){var n=e*e,r=n*n;return[t*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791)),e*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))]}(t.geo.mollweide=function(){return x(S)}).raw=S,C.invert=function(t,e){var n,r=e,a=25;do{var i=r*r,o=i*i;r-=n=(r*(1.007226+i*(.015085+o*(.028874*i-.044475-.005916*o)))-e)/(1.007226+i*(.045255+o*(.259866*i-.311325-.005916*11*o)))}while(Math.abs(n)>f&&--a>0);return[t/(.8707+(i=r*r)*(i*(i*i*i*(.003971-.001529*i)-.013791)-.131979)),r]},(t.geo.naturalEarth=function(){return x(C)}).raw=C;var P=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];function O(t,e){var n,r=Math.min(18,36*Math.abs(e)/p),a=Math.floor(r),i=r-a,o=(n=P[a])[0],l=n[1],s=(n=P[++a])[0],c=n[1],u=(n=P[Math.min(19,++a)])[0],f=n[1];return[t*(s+i*(u-o)/2+i*i*(u-2*s+o)/2),(e>0?h:-h)*(c+i*(f-l)/2+i*i*(f-2*c+l)/2)]}function z(t,e){return[t*Math.cos(e),e]}function D(t,e){var n,r=Math.cos(e),a=(n=m(r*Math.cos(t/=2)))?n/Math.sin(n):1;return[2*r*Math.sin(t)*a,Math.sin(e)*a]}function E(t,e){var n=D(t,e);return[(n[0]+t/h)/2,(n[1]+e)/2]}P.forEach(function(t){t[1]*=1.0144}),O.invert=function(t,e){var n=e/h,r=90*n,a=Math.min(18,Math.abs(r/5)),i=Math.max(0,Math.floor(a));do{var o=P[i][1],l=P[i+1][1],s=P[Math.min(19,i+2)][1],c=s-o,u=s-2*l+o,f=2*(Math.abs(n)-l)/c,p=u/c,y=f*(1-p*f*(1-2*p*f));if(y>=0||1===i){r=(e>=0?5:-5)*(y+a);var m,x=50;do{y=(a=Math.min(18,Math.abs(r)/5))-(i=Math.floor(a)),o=P[i][1],l=P[i+1][1],s=P[Math.min(19,i+2)][1],r-=(m=(e>=0?h:-h)*(l+y*(s-o)/2+y*y*(s-2*l+o)/2)-e)*v}while(Math.abs(m)>d&&--x>0);break}}while(--i>=0);var b=P[i][0],_=P[i+1][0],w=P[Math.min(19,i+2)][0];return[t/(_+y*(w-b)/2+y*y*(w-2*_+b)/2),r*g]},(t.geo.robinson=function(){return x(O)}).raw=O,z.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return x(z)}).raw=z,D.invert=function(t,e){if(!(t*t+4*e*e>p*p+f)){var n=t,r=e,a=25;do{var i,o=Math.sin(n),l=Math.sin(n/2),s=Math.cos(n/2),c=Math.sin(r),u=Math.cos(r),d=Math.sin(2*r),h=c*c,g=u*u,v=l*l,y=1-g*s*s,x=y?m(u*s)*Math.sqrt(i=1/y):i=0,b=2*x*u*l-t,_=x*c-e,w=i*(g*v+x*u*s*h),k=i*(.5*o*d-2*x*c*l),M=.25*i*(d*l-x*c*g*o),T=i*(h*s+x*v*u),A=k*M-T*w;if(!A)break;var L=(_*k-b*T)/A,S=(b*M-_*w)/A;n-=L,r-=S}while((Math.abs(L)>f||Math.abs(S)>f)&&--a>0);return[n,r]}},(t.geo.aitoff=function(){return x(D)}).raw=D,E.invert=function(t,e){var n=t,r=e,a=25;do{var i,o=Math.cos(r),l=Math.sin(r),s=Math.sin(2*r),c=l*l,u=o*o,d=Math.sin(n),p=Math.cos(n/2),g=Math.sin(n/2),v=g*g,y=1-u*p*p,x=y?m(o*p)*Math.sqrt(i=1/y):i=0,b=.5*(2*x*o*g+n/h)-t,_=.5*(x*l+r)-e,w=.5*i*(u*v+x*o*p*c)+.5/h,k=i*(d*s/4-x*l*g),M=.125*i*(s*g-x*l*u*d),T=.5*i*(c*p+x*v*o)+.5,A=k*M-T*w,L=(_*k-b*T)/A,S=(b*M-_*w)/A;n-=L,r-=S}while((Math.abs(L)>f||Math.abs(S)>f)&&--a>0);return[n,r]},(t.geo.winkel3=function(){return x(E)}).raw=E}},{}],246:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../lib"),i=Math.PI/180,o=180/Math.PI,l={cursor:"pointer"},s={cursor:"auto"};function c(t,e){return r.behavior.zoom().translate(e.translate()).scale(e.scale())}function u(t,e,n){var r=t.id,i=t.graphDiv,o=i.layout[r],l=i._fullLayout[r],s={};function c(t,e){var n=a.nestedProperty(l,t);n.get()!==e&&(n.set(e),a.nestedProperty(o,t).set(e),s[r+"."+t]=e)}n(c),c("projection.scale",e.scale()/t.fitScale),i.emit("plotly_relayout",s)}function f(t,e){var n=c(0,e);function a(n){var r=e.invert(t.midPt);n("center.lon",r[0]),n("center.lat",r[1])}return n.on("zoomstart",function(){r.select(this).style(l)}).on("zoom",function(){e.scale(r.event.scale).translate(r.event.translate),t.render()}).on("zoomend",function(){r.select(this).style(s),u(t,e,a)}),n}function d(t,e){var n,a,i,o,f,d,p,h,g,v=c(0,e),y=2;function m(t){return e.invert(t)}function x(n){var r=e.rotate(),a=e.invert(t.midPt);n("projection.rotation.lon",-r[0]),n("center.lon",a[0]),n("center.lat",a[1])}return v.on("zoomstart",function(){r.select(this).style(l),n=r.mouse(this),a=e.rotate(),i=e.translate(),o=a,f=m(n)}).on("zoom",function(){if(d=r.mouse(this),function(t){var n=m(t);if(!n)return!0;var r=e(n);return Math.abs(r[0]-t[0])>y||Math.abs(r[1]-t[1])>y}(n))return v.scale(e.scale()),void v.translate(e.translate());e.scale(r.event.scale),e.translate([i[0],r.event.translate[1]]),f?m(d)&&(h=m(d),p=[o[0]+(h[0]-f[0]),a[1],a[2]],e.rotate(p),o=p):f=m(n=d),g=!0,t.render()}).on("zoomend",function(){r.select(this).style(s),g&&u(t,e,x)}),v}function p(t,e){var n,a={r:e.rotate(),k:e.scale()},f=c(0,e),d=function(t){var e=0,n=arguments.length,a=[];for(;++eh?(i=(f>0?90:-90)-p,a=0):(i=Math.asin(f/h)*o-p,a=Math.sqrt(h*h-f*f));var v=180-i-2*p,m=(Math.atan2(d,u)-Math.atan2(c,a))*o,x=(Math.atan2(d,u)-Math.atan2(c,-a))*o,b=g(n[0],n[1],i,m),_=g(n[0],n[1],v,x);return b<=_?[i,m,n[2]]:[v,x,n[2]]}(k,n,S);isFinite(M[0])&&isFinite(M[1])&&isFinite(M[2])||(M=S),e.rotate(M),S=M}}else n=h(e,A=b);d.of(this,arguments)({type:"zoom"})}),T=d.of(this,arguments),p++||T({type:"zoomstart"})}).on("zoomend",function(){var n;r.select(this).style(s),v.call(f,"zoom",null),n=d.of(this,arguments),--p||n({type:"zoomend"}),u(t,e,x)}).on("zoom.redraw",function(){t.render()}),r.rebind(f,d,"on")}function h(t,e){var n=t.invert(e);return n&&isFinite(n[0])&&isFinite(n[1])&&function(t){var e=t[0]*i,n=t[1]*i,r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}(n)}function g(t,e,n,r){var a=v(n-t),i=v(r-e);return Math.sqrt(a*a+i*i)}function v(t){return(t%360+540)%360-180}function y(t,e,n){var r=n*i,a=t.slice(),o=0===e?1:0,l=2===e?1:2,s=Math.cos(r),c=Math.sin(r);return a[o]=t[o]*s-t[l]*c,a[l]=t[l]*s+t[o]*c,a}function m(t,e){for(var n=0,r=0,a=t.length;r=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),n.attr(i);var o=n.select(".js-link-to-tool"),l=n.select(".js-link-spacer"),u=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var n=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)n.on("click",function(){v.sendDataToCloud(t)});else{var r=window.location.pathname.split("/"),a=window.location.search;n.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+r[2].split(".")[0]+"/"+r[1]+a})}}(t,o),l.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,n=r.select(t).append("div").attr("id","hiddenform").style("display","none"),a=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var n=t._context.locale,r=!1,a={};function o(t){for(var n=!0,i=0;i1&&D.length>1){for(i.getComponentMethod("grid","sizeDefaults")(c,l),o=0;o15&&D.length>15&&0===l.shapes.length&&0===l.images.length,l._hasCartesian=l._has("cartesian"),l._hasGeo=l._has("geo"),l._hasGL3D=l._has("gl3d"),l._hasGL2D=l._has("gl2d"),l._hasTernary=l._has("ternary"),l._hasPie=l._has("pie"),v.linkSubplots(d,l,u,a),v.cleanPlot(d,l,u,a),h(l,a),v.doAutoMargin(t);var F=f.list(t);for(o=0;o0){var f=1-2*l;r=Math.round(f*r),i=Math.round(f*i)}}var d=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;r1,g=!e.height&&Math.abs(n.height-i)>1;(g||h)&&(h&&(n.width=r),g&&(n.height=i)),t._initialAutoSize||(t._initialAutoSize={width:r,height:i}),v.sanitizeMargins(n)},v.supplyLayoutModuleDefaults=function(t,e,n,r){var a,o,l,c=i.componentsRegistry,u=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in c)(l=c[a]).includeBasePlot&&l.includeBasePlot(t,e);for(var d in u.length||u.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[d].sort(s.subplotSort);for(o=0;o.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0);var s=void 0!==n.xl?n.xl:n.x,c=void 0!==n.xr?n.xr:n.x,u=void 0!==n.yt?n.yt:n.y,f=void 0!==n.yb?n.yb:n.y;a[e]={l:{val:s,size:n.l+o},r:{val:c,size:n.r+o},b:{val:f,size:n.b+o},t:{val:u,size:n.t+o}},i[e]=1}else delete a[e],delete i[e];r._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),T(e);var n=e._size,r=JSON.stringify(n),o=Math.max(e.margin.l||0,0),l=Math.max(e.margin.r||0,0),s=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin,f=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var d in u)f[d]||delete u[d];for(var p in u.base={l:{val:0,size:o},r:{val:1,size:l},t:{val:1,size:s},b:{val:0,size:c}},u){var h=u[p].l||{},g=u[p].b||{},v=h.val,y=h.size,m=g.val,x=g.size;for(var b in u){if(a(y)&&u[b].r){var _=u[b].r.val,w=u[b].r.size;if(_>v){var k=(y*_+(w-e.width)*v)/(_-v),M=(w*(1-v)+(y-e.width)*(1-_))/(_-v);k>=0&&M>=0&&k+M>o+l&&(o=k,l=M)}}if(a(x)&&u[b].t){var A=u[b].t.val,L=u[b].t.size;if(A>m){var S=(x*A+(L-e.height)*m)/(A-m),C=(L*(1-m)+(x-e.height)*(1-A))/(A-m);S>=0&&C>=0&&S+C>c+s&&(c=S,s=C)}}}}}if(n.l=Math.round(o),n.r=Math.round(l),n.t=Math.round(s),n.b=Math.round(c),n.p=Math.round(e.margin.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,!e._replotting&&"{}"!==r&&r!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,n,r,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,l=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(s.isPlainObject(t)){var e,r,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if("string"==typeof(r=t[e+"src"])&&r.indexOf(":")>0&&!s.isPlainObject(t.stream))continue}else if("keepall"!==n&&"string"==typeof(r=t[e+"src"])&&r.indexOf(":")>0)continue;a[e]=c(t[e])}return a}return Array.isArray(t)?t.map(c):s.isTypedArray(t)?s.simpleMap(t,s.identity):s.isJSDate(t)?s.ms2DateTimeLocal(+t):t}var u={data:(i||[]).map(function(t){var n=c(t);return e&&delete n.fit,n})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),l&&(u.frames=c(l)),"object"===r?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var n,r,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(n=0;n0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var r,l,c=0,u=0;function f(){return c++,function(){var n;u++,p||u!==c||(n=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(n)))}}var h=t._fullLayout._basePlotModules,g=!1;if(n)for(l=0;l=0;l--)if(o[l].enabled){n._indexToPoints=o[l]._indexToPoints;break}r&&r.calc&&(i=r.calc(t,n))}Array.isArray(i)&&i[0]||(i=[{x:u,y:u}]),i[0].t||(i[0].t={}),i[0].trace=n,h[e]=i}}for(m&&A(c),a=0;a=0?d.angularAxis.domain:r.extent(k),S=Math.abs(k[1]-k[0]);T&&!M&&(S=0);var C=L.slice();A&&M&&(C[1]+=S);var P=d.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),d.angularAxis.ticksStep&&(P=(C[1]-C[0])/P);var O=d.angularAxis.ticksStep||(C[1]-C[0])/(P*(d.minorTicks+1));w&&(O=Math.max(Math.round(O),1)),C[2]||(C[2]=O);var z=r.range.apply(this,C);if(z=z.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=r.scale.linear().domain(C.slice(0,2)).range("clockwise"===d.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=A?S:0,"undefined"==typeof(t=r.select(this).select("svg.chart-root"))||t.empty()){var D=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),E=this.appendChild(this.ownerDocument.importNode(D.documentElement,!0));t=r.select(E)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var R,N=t.select(".chart-group"),I={fill:"none",stroke:d.tickColor},F={"font-size":d.font.size,"font-family":d.font.family,fill:d.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+d.font.outlineColor}).join(",")};if(d.showLegend){R=t.select(".legend-group").attr({transform:"translate("+[x,d.margin.top]+")"}).style({display:"block"});var j=p.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:R,elements:j,reverseOrder:d.legend.reverseOrder})})();var B=R.node().getBBox();x=Math.min(d.width-B.width-d.margin.left-d.margin.right,d.height-d.margin.top-d.margin.bottom)/2,x=Math.max(10,x),_=[d.margin.left+x,d.margin.top+x],n.range([0,x]),u.layout.radialAxis.domain=n.domain(),R.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else R=t.select(".legend-group").style({display:"none"});t.attr({width:d.width,height:d.height}).style({opacity:d.opacity}),N.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(d.width-(d.margin.left+d.margin.right+2*x+(B?B.width:0)))/2,(d.height-(d.margin.top+d.margin.bottom+2*x))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),t.select(".outer-group").attr("transform","translate("+H+")"),d.title){var q=t.select("g.title-group text").style(F).text(d.title),V=q.node().getBBox();q.attr({x:_[0]-V.width/2,y:_[1]-x-20})}var U=t.select(".radial.axis-group");if(d.radialAxis.gridLinesVisible){var G=U.selectAll("circle.grid-circle").data(n.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(I),G.attr("r",n),G.exit().remove()}U.select("circle.outside-circle").attr({r:x}).style(I);var Z=t.select("circle.background-circle").attr({r:x}).style({fill:d.backgroundColor,stroke:d.stroke});function Y(t,e){return l(t)%360+d.orientation}if(d.radialAxis.visible){var X=r.svg.axis().scale(n).ticks(5).tickSize(5);U.call(X).attr({transform:"rotate("+d.radialAxis.orientation+")"}),U.selectAll(".domain").style(I),U.selectAll("g>text").text(function(t,e){return this.textContent+d.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===d.radialAxis.tickOrientation?"rotate("+-d.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),U.selectAll("g>line").style({stroke:"black"})}var W=t.select(".angular.axis-group").selectAll("g.angular-tick").data(z),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+Y(t)+")"}}).style({display:d.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(d.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(d.minorTicks+1)==0)}).style(I),J.selectAll(".minor").style({stroke:d.minorTickColor}),W.select("line.grid-line").attr({x1:d.tickLength?x-d.tickLength:0,x2:x}).style({display:d.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(F);var Q=W.select("text.axis-text").attr({x:x+d.labelOffset,dy:i+"em",transform:function(t,e){var n=Y(t),r=x+d.labelOffset,a=d.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-n+" "+r+" 0)":"radial"==a?n<270&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(n<=180&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:d.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(d.minorTicks+1)!=0?"":w?w[t]+d.angularAxis.ticksSuffix:t+d.angularAxis.ticksSuffix}).style(F);d.angularAxis.rewriteTicks&&Q.text(function(t,e){return e%(d.minorTicks+1)!=0?"":d.angularAxis.rewriteTicks(this.textContent,e)});var $=r.max(N.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));R.attr({transform:"translate("+[x+$,d.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||K){var et=[];p.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=l,r.container=tt.filter(function(t,n){return n==e}),r.geometry=t.geometry,r.orientation=d.orientation,r.direction=d.direction,r.index=e,et.push({data:t,geometryConfig:r})});var nt=r.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),rt=[];nt.forEach(function(t,e){"unstacked"===t.key?rt=rt.concat(t.values.map(function(t,e){return[t]})):rt.push(t.values)}),rt.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return a(o[n].defaultConfig(),t)});o[n]().config(r)()})}var at,it,ot=t.select(".guides-group"),lt=t.select(".tooltips-group"),st=o.tooltipPanel().config({container:lt,fontSize:8})(),ct=o.tooltipPanel().config({container:lt,fontSize:8})(),ut=o.tooltipPanel().config({container:lt,hasTick:!0})();if(!M){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});N.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos(Z).angle;ft.attr({x2:-x,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-d.orientation)%360;at=l.invert(r);var a=o.util.convertToCartesian(x+12,n+180);st.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var dt=ot.select("circle").style({stroke:"grey",fill:"none"});N.on("mousemove.radial-guide",function(t,e){var r=o.util.getMousePos(Z).radius;dt.attr({r:r}).style({opacity:.5}),it=n.invert(o.util.getMousePos(Z).radius);var a=o.util.convertToCartesian(r,d.radialAxis.orientation);ct.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){dt.style({opacity:0}),ut.hide(),st.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,n){var a=r.select(this),i=this.style.fill,l="black",s=this.style.opacity||1;if(a.attr({"data-opacity":s}),i&&"none"!==i){a.attr({"data-fill":i}),l=r.hsl(i).darker().toString(),a.style({fill:l,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};M&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=t.node().getBoundingClientRect(),p=[f.left+f.width/2-H[0]-d.left,f.top+f.height/2-H[1]-d.top];ut.config({color:l}).text(u),ut.move(p)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),l=r.hsl(i).darker().toString(),a.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=r.event.which)return!1;r.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var n=r.select(this),a=n.attr("data-fill");a?n.style({fill:a,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})})}(c),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),a(s.data[e],o.Axis.defaultConfig().data[0]),a(s.data[e],t)}),a(s.layout,o.Axis.defaultConfig().layout),a(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return n},d.angularScale=function(t){return l},d.svg=function(){return t},r.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:r.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6;return r.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180;return[e,t(r)]})},o.util.dataFromEquation=function(t,e,n){var a=e||6,i=[],o=[];r.range(0,360+a,a).forEach(function(e,n){var r=e*Math.PI/180,a=t(r);i.push(e),o.push(a)});var l={t:i,r:o};return n&&(l.name=n),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return r.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return r.zip(t,e).map(function(t,e){return r.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return-2===n},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180;return[t*Math.cos(n),t*Math.sin(n)]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=r.mouse(t.node()),n=e[0],a=e[1],i={};return i.x=n,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,n)+Math.PI)/Math.PI,i.radius=Math.sqrt(n*n+a*a),i},o.util.duplicatesCount=function(t){for(var e,n={},r={},a=0,i=t.length;a0)){var s=r.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({class:"line",d:u(l),transform:function(t,n){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return h.fill(n,a,i)},"fill-opacity":0,stroke:function(t,e){return h.stroke(n,a,i)},"stroke-width":function(t,e){return h["stroke-width"](n,a,i)},"stroke-dasharray":function(t,e){return h["stroke-dasharray"](n,a,i)},opacity:function(t,e){return h.opacity(n,a,i)},display:function(t,e){return h.display(n,a,i)}})}};var f=e.angularScale.range(),d=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=r.svg.arc().startAngle(function(t){return-d/2}).endAngle(function(t){return d/2}).innerRadius(function(t){return e.radialScale(s+(t[2]||0))}).outerRadius(function(t){return e.radialScale(s+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,n,a){r.select(this).attr({class:"mark arc",d:p,transform:function(t,n){return"rotate("+(e.orientation+l(t[0])+90)+")"}})};var h={fill:function(e,n,r){return t[r].data.color},stroke:function(e,n,r){return t[r].data.strokeColor},"stroke-width":function(e,n,r){return t[r].data.strokeSize+"px"},"stroke-dasharray":function(e,r,a){return n[t[a].data.strokeDash]},opacity:function(e,n,r){return t[r].data.opacity},display:function(e,n,r){return"undefined"==typeof t[r].data.visible||t[r].data.visible?"block":"none"}},g=r.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(h).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,n){t[n]||(t[n]={}),a(t[n],o.PolyChart.defaultConfig()),a(t[n],e)}),this):t},i.getColorScale=function(){},r.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:r.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=r.dispatch("hover");function n(){var e=t.legendConfig,i=t.data.map(function(t,n){return[].concat(t).map(function(t,r){var i=a({},e.elements[n]);return i.name=t,i.color=[].concat(e.elements[n].color)[r],i})}),o=r.merge(i);o=o.filter(function(t,n){return e.elements[n]&&(e.elements[n].visibleInLegend||"undefined"==typeof e.elements[n].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var l=e.container;("string"==typeof l||l.nodeName)&&(l=r.select(l));var s=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,d=l.classed("legend-group",!0).selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var h=r.range(o.length),g=r.scale[u?"linear":"ordinal"]().domain(h).range(s),v=r.scale[u?"linear":"ordinal"]().domain(h)[u?"range":"rangePoints"]([0,f]);if(u){var y=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var m=d.select(".legend-marks").selectAll("path.legend-mark").data(o);m.enter().append("path").classed("legend-mark",!0),m.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var n,a,i,o=t.symbol;return i=3*(a=c),"line"===(n=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=r.svg.symbolTypes.indexOf(n)?r.svg.symbol().type(n).size(i)():r.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),m.exit().remove()}var x=r.svg.axis().scale(v).orient("right"),b=d.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),n}return n.config=function(e){return arguments.length?(a(t,e),this):t},r.rebind(n,e,"on"),n},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,n,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){var r=(t=i.container.selectAll("g."+l).data([0])).enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return n=r.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=r.append("text").attr({dx:i.padding+s,dy:.3*+i.fontSize}),c};return c.text=function(a){var o=r.hsl(i.color).l,l=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":i.fontSize+"px"}).text(f);var d=i.padding,p=e.node().getBBox(),h={fill:i.color,stroke:l,"stroke-width":"2px"},g=p.width+2*d+s,v=p.height+2*d;return n.attr({d:"M"+[[s,-v/2],[s,-v/4],[i.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(h),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return a(i,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=a({},t);return[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]].forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",!0===r.dotVisible?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var r=i.indexOf(t.geometry);-1!=r&&(n.data[e].groupId=r)})}if(t.layout){var l=a({},t.layout);if([[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var s=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};r.entries(l.margin).forEach(function(t,e){u[c[s.indexOf(t.key)]]=t.value}),l.margin=u}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),n.layout=l}return n}};return t}},{"../../../constants/alignment":143,"../../../lib":165,d3:9}],256:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),l=t("./undo_manager"),s=a.extendDeepAll,c=e.exports={};c.framework=function(t){var e,n,a,i,u,f=new l;function d(n,l){return l&&(u=l),r.select(r.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?s(e,n):n,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return d.isPolar=!0,d.svg=function(){return a.svg()},d.getConfig=function(){return e},d.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},d.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},d.setUndoPoint=function(){var t,r,a=this,i=o.util.cloneJson(e);t=i,r=n,f.add({undo:function(){r&&a(r)},redo:function(){a(t)}}),n=o.util.cloneJson(i)},d.undo=function(){f.undo()},d.redo=function(){f.redo()},d},c.fillLayout=function(t){var e=r.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:n,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../../components/color":45,"../../../lib":165,"./micropolar":255,"./undo_manager":257,d3:9}],257:[function(t,e,n){"use strict";e.exports=function(){var t,e=[],n=-1,r=!1;function a(t,e){return t?(r=!0,t[e](),r=!1,this):this}return{add:function(t){return r?this:(e.splice(n+1,e.length-n),e.push(t),n=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var r=e[n];return r?(a(r,"undo"),n-=1,t&&t(r.undo),this):this},redo:function(){var r=e[n+1];return r?(a(r,"redo"),n+=1,t&&t(r.redo),this):this},clear:function(){e=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return n-1&&(u[d[n]].title="");for(n=0;npath, .legendlines>path, .cbfill").each(function(){var t=r.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(s,"TOBESTRIPPED"));var n=this.style.stroke;n&&-1!==n.indexOf("url(")&&t.style("stroke",n.replace(s,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||d.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),d.node().setAttributeNS(l.xmlns,"xmlns",l.svg),d.node().setAttributeNS(l.xmlns,"xmlns:xlink",l.xlink),"svg"===e&&n&&(d.attr("width",n*h),d.attr("height",n*g),d.attr("viewBox","0 0 "+h+" "+g));var _=(new window.XMLSerializer).serializeToString(d.node());return _=function(t){var e=r.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),n}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":45,"../components/drawing":70,"../constants/xmlns_namespaces":146,"../lib":165,d3:9}],268:[function(t,e,n){"use strict";var r=t("../scattergeo/attributes"),a=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),o=t("../../plots/attributes"),l=t("../../lib/extend").extendFlat,s=r.marker.line;e.exports=l({locations:{valType:"data_array",editType:"calc"},locationmode:r.locationmode,z:{valType:"data_array",editType:"calc"},text:l({},r.text,{}),marker:{line:{color:s.color,width:l({},s.width,{dflt:1}),editType:"calc"},opacity:{valType:"number",arrayOk:!0,min:0,max:1,dflt:1,editType:"style"},editType:"calc"},selected:{marker:{opacity:r.selected.marker.opacity,editType:"plot"},editType:"plot"},unselected:{marker:{opacity:r.unselected.marker.opacity,editType:"plot"},editType:"plot"},hoverinfo:l({},o.hoverinfo,{editType:"calc",flags:["location","z","text","name"]})},a("",{cLetter:"z",editTypeOverride:"calc"}),{colorbar:i})},{"../../components/colorbar/attributes":46,"../../components/colorscale/attributes":52,"../../lib/extend":157,"../../plots/attributes":207,"../scattergeo/attributes":308}],269:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../constants/numerical").BADNUM,i=t("../../components/colorscale/calc"),o=t("../scatter/arrays_to_calcdata"),l=t("../scatter/calc_selection");e.exports=function(t,e){for(var n=e._length,s=new Array(n),c=0;c")}(t,f,o,d.mockAxis),[t]}},{"../../plots/cartesian/axes":210,"../scatter/fill_hover_text":289,"./attributes":268}],273:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../heatmap/colorbar"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style").style,r.styleOnSelect=t("./style").styleOnSelect,r.hoverPoints=t("./hover"),r.eventData=t("./event_data"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="choropleth",r.basePlotModule=t("../../plots/geo"),r.categories=["geo","noOpacity"],r.meta={},e.exports=r},{"../../plots/geo":241,"../heatmap/colorbar":277,"./attributes":268,"./calc":269,"./defaults":270,"./event_data":271,"./hover":272,"./plot":274,"./select":275,"./style":276}],274:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../lib"),i=t("../../lib/polygon"),o=t("../../lib/topojson_utils").getTopojsonFeatures,l=t("../../lib/geo_location_utils").locationToFeature,s=t("./style").style;function c(t,e){for(var n=t[0].trace,r=t.length,a=o(n,e),i=0;i0&&t[e+1][0]<0)return e;return null}switch(e="RUS"===s||"FJI"===s?function(t){var e;if(null===u(t))e=t;else for(e=new Array(t.length),a=0;ae?n[r++]=[t[a][0]+360,t[a][1]]:a===e?(n[r++]=t[a],n[r++]=[t[a][0],-90]):n[r++]=t[a];var o=i.tester(n);o.pts.pop(),c.push(o)}:function(t){c.push(i.tester(t))},o.type){case"MultiPolygon":for(n=0;nl&&T[v].gap;)v--;for(m=T[v].s,h=T.length-1;h>v;h--)T[h].s=m;for(;lA[u]&&u=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===n.xaxis&&i.yaxis===n.yaxis){i.opacity=void 0;break}}}}}},{}],288:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),l=t("./subtypes"),s=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),d=t("./line_shape_defaults"),p=t("./text_defaults"),h=t("./fillcolor_defaults");e.exports=function(t,e,n,g){function v(n,a){return r.coerce(t,e,i,n,a)}var y=s(t,e,g,v);if(y||(e.visible=!1),e.visible){var m=c(t,e,g,v),x=!m&&yG!=(I=z[P][1])>=G&&(E=z[P-1][0],R=z[P][0],I-N&&(D=E+(R-E)*(G-N)/(I-N),H=Math.min(H,D),q=Math.max(q,D)));H=Math.max(H,0),q=Math.min(q,d._length);var Z=l.defaultLine;return l.opacity(f.fillcolor)?Z=f.fillcolor:l.opacity((f.line||{}).color)&&(Z=f.line.color),r.extendFlat(t,{distance:t.maxHoverDistance,x0:H,x1:q,y0:G,y1:G,color:Z}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":45,"../../components/fx":87,"../../lib":165,"../../registry":259,"./fill_hover_text":289,"./get_trace_color":291}],293:[function(t,e,n){"use strict";var r={},a=t("./subtypes");r.hasLines=a.hasLines,r.hasMarkers=a.hasMarkers,r.hasText=a.hasText,r.isBubble=a.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.crossTraceDefaults=t("./cross_trace_defaults"),r.calc=t("./calc").calc,r.crossTraceCalc=t("./cross_trace_calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./marker_colorbar"),r.style=t("./style").style,r.styleOnSelect=t("./style").styleOnSelect,r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.animatable=!0,r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],r.meta={},e.exports=r},{"../../plots/cartesian":222,"./arrays_to_calcdata":280,"./attributes":281,"./calc":282,"./cross_trace_calc":286,"./cross_trace_defaults":287,"./defaults":288,"./hover":292,"./marker_colorbar":299,"./plot":301,"./select":302,"./style":304,"./subtypes":305}],294:[function(t,e,n){"use strict";var r=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,l,s){var c=(t.marker||{}).color;(l("line.color",n),a(t,"line"))?i(t,e,o,l,{prefix:"line.",cLetter:"c",noScale:!0}):l("line.color",!r(c)&&c||n);l("line.width"),(s||{}).noDash||l("line.dash")}},{"../../components/colorscale/defaults":55,"../../components/colorscale/has_colorscale":59,"../../lib":165}],295:[function(t,e,n){"use strict";var r=t("../../constants/numerical"),a=r.BADNUM,i=r.LOG_CLIP,o=i+.5,l=i-.5,s=t("../../lib"),c=s.segmentsIntersect,u=s.constrain,f=t("./constants");e.exports=function(t,e){var n,r,i,d,p,h,g,v,y,m,x,b,_,w,k,M,T,A,L=e.xaxis,S=e.yaxis,C="log"===L.type,P="log"===S.type,O=L._length,z=S._length,D=e.connectGaps,E=e.baseTolerance,R=e.shape,N="linear"===R,I=[],F=f.minTolerance,j=new Array(t.length),B=0;function H(e){var n=t[e];if(!n)return!1;var r=L.c2p(n.x),i=S.c2p(n.y);if(r===a){if(C&&(r=L.c2p(n.x,!0)),r===a)return!1;P&&i===a&&(r*=Math.abs(L._m*z*(L._m>0?o:l)/(S._m*O*(S._m>0?o:l)))),r*=1e3}if(i===a){if(P&&(i=S.c2p(n.y,!0)),i===a)return!1;i*=1e3}return[r,i]}function q(t,e,n,r){var a=n-t,i=r-e,o=.5-t,l=.5-e,s=a*a+i*i,c=a*o+i*l;if(c>0&&ctt||t[1]nt)return[u(t[0],K,tt),u(t[1],et,nt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===nt)||void 0)}function ot(t,e,n){return function(r,a){var i=at(r),o=at(a),l=[];if(i&&o&&it(i,o))return l;i&&l.push(i),o&&l.push(o);var c=2*s.constrain((r[t]+a[t])/2,e,n)-((i||r)[t]+(o||a)[t]);c&&((i&&o?c>0==i[t]>o[t]?i:o:i||o)[t]+=c);return l}}function lt(t){var e=t[0],n=t[1],r=e===j[B-1][0],a=n===j[B-1][1];if(!r||!a)if(B>1){var i=e===j[B-2][0],o=n===j[B-2][1];r&&(e===K||e===tt)&&i?o?B--:j[B-1]=t:a&&(n===et||n===nt)&&o?i?B--:j[B-1]=t:j[B++]=t}else j[B++]=t}function st(t){j[B-1][0]!==t[0]&&j[B-1][1]!==t[1]&<([Y,X]),lt(t),W=null,Y=X=0}function ct(t){if(T=t[0]/O,A=t[1]/z,G=t[0]tt?tt:0,Z=t[1]nt?nt:0,G||Z){if(B)if(W){var e=Q(W,t);e.length>1&&(st(e[0]),j[B++]=e[1])}else J=Q(j[B-1],t)[0],j[B++]=J;else j[B++]=[G||t[0],Z||t[1]];var n=j[B-1];G&&Z&&(n[0]!==G||n[1]!==Z)?(W&&(Y!==G&&X!==Z?lt(Y&&X?(r=W,i=(a=t)[0]-r[0],o=(a[1]-r[1])/i,(r[1]*a[0]-a[1]*r[0])/i>0?[o>0?K:tt,nt]:[o>0?tt:K,et]):[Y||G,X||Z]):Y&&X&<([Y,X])),lt([G,Z])):Y-G&&X-Z&<([G||Y,Z||X]),W=t,Y=G,X=Z}else W&&st(Q(W,t)[0]),j[B++]=t;var r,a,i,o}for("linear"===R||"spline"===R?Q=function(t,e){for(var n=[],r=0,a=0;a<4;a++){var i=rt[a],o=c(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!r||Math.abs(o.x-n[0][0])>1||Math.abs(o.y-n[0][1])>1)&&(o=[o.x,o.y],r&&U(o,t)V(h,ut))break;i=h,(_=y[0]*v[0]+y[1]*v[1])>x?(x=_,d=h,g=!1):_=t.length||!h)break;ct(h),r=h}}else ct(d)}W&<([Y||W[0],X||W[1]]),I.push(j.slice(0,B))}return I}},{"../../constants/numerical":145,"../../lib":165,"./constants":285}],296:[function(t,e,n){"use strict";e.exports=function(t,e,n){"spline"===n("line.shape")&&n("line.smoothing")}},{}],297:[function(t,e,n){"use strict";var r={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,n){var a,i,o,l,s,c={},u=!1,f=-1,d=0,p=-1;for(i=0;i=0?s=p:(s=p=d,d++),s0?Math.max(e,a):0}}},{"fast-isnumeric":11}],299:[function(t,e,n){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],300:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,n,l,s,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(n=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",n),a(t,"marker")&&i(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c.noSelect||(s("selected.marker.color"),s("unselected.marker.color"),s("selected.marker.size"),s("unselected.marker.size")),c.noLine||(s("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?r.background:r.defaultLine),a(t,"marker.line")&&i(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0)),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode")),c.gradient)&&("none"!==s("marker.gradient.type")&&s("marker.gradient.color"))}},{"../../components/color":45,"../../components/colorscale/defaults":55,"../../components/colorscale/has_colorscale":59,"./subtypes":305}],301:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,l=i.identity,s=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),d=t("../../lib/polygon").tester;function p(t,e,n,f,p,h,g){var v;!function(t,e,n,a,o){var l=n.xaxis,s=n.yaxis,u=r.extent(i.simpleMap(l.range,l.r2c)),f=r.extent(i.simpleMap(s.range,s.r2c)),d=a[0].trace;if(!c.hasMarkers(d))return;var p=d.marker.maxdisplayed;if(0===p)return;var h=a.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(h.length/p),v=0;o.forEach(function(t,n){var r=t[0].trace;c.hasMarkers(r)&&r.marker.maxdisplayed>0&&n0;function m(t){return y?t.transition():t}var x=n.xaxis,b=n.yaxis,_=f[0].trace,w=_.line,k=r.select(h),M=o(k,"g","errorbars"),T=o(k,"g","lines"),A=o(k,"g","points"),L=o(k,"g","text");if(a.getComponentMethod("errorbars","plot")(M,n,g),!0===_.visible){var S,C;m(k).style("opacity",_.opacity);var P=_.fill.charAt(_.fill.length-1);"x"!==P&&"y"!==P&&(P=""),n.isRangePlot||(f[0].node3=k);var O="",z=[],D=_._prevtrace;D&&(O=D._prevRevpath||"",C=D._nextFill,z=D._polygons);var E,R,N,I,F,j,B,H,q,V="",U="",G=[],Z=i.noop;if(S=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(C&&C.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(N=s.steps(w.shape),I=s.steps(w.shape.split("").reverse().join(""))):N=I="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?s.smoothclosed(t.slice(1),w.smoothing):s.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return I(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=_._polygons=new Array(G.length),v=0;v1){var n=r.select(this);if(n.datum(f),t)m(n.style("opacity",0).attr("d",E).call(s.lineGroupStyle)).style("opacity",1);else{var a=m(n);a.attr("d",E),s.singleLineStyle(f,a)}}}}}var Y=T.selectAll(".js-line").data(G);m(Y.exit()).style("opacity",0).remove(),Y.each(Z(!1)),Y.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(s.lineGroupStyle).each(Z(!0)),s.setClipUrl(Y,n.layerClipId),G.length?(S?(S.datum(f),j&&H&&(P?("y"===P?j[1]=H[1]=b.c2p(0,!0):"x"===P&&(j[0]=H[0]=x.c2p(0,!0)),m(S).attr("d","M"+H+"L"+j+"L"+V.substr(1)).call(s.singleFillStyle)):m(S).attr("d",V+"Z").call(s.singleFillStyle))):C&&("tonext"===_.fill.substr(0,6)&&V&&O?("tonext"===_.fill?m(C).attr("d",V+"Z"+O+"Z").call(s.singleFillStyle):m(C).attr("d",V+"L"+O.substr(1)+"Z").call(s.singleFillStyle),_._polygons=_._polygons.concat(z)):(W(C),_._polygons=null)),_._prevRevpath=U,_._prevPolygons=q):(S?W(S):C&&W(C),_._polygons=_._prevRevpath=_._prevPolygons=null),A.datum(f),L.datum(f),function(e,a,i){var o,u=i[0].trace,f=c.hasMarkers(u),d=c.hasText(u),p=tt(u),h=et,g=et;if(f||d){var v=l,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?Q:J:_&&!w&&(v=$),f&&(h=v),d&&(g=v)}var k,M=(o=e.selectAll("path.point").data(h,p)).enter().append("path").classed("point",!0);y&&M.call(s.pointStyle,u,t).call(s.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=s.makePointStyleFns(u)),o.each(function(e){var a=r.select(this),i=m(a);s.translatePoint(e,i,x,b)?(s.singlePointStyle(e,i,u,k,t),n.layerClipId&&s.hideOutsideRangePoint(e,i,x,b,u.xcalendar,u.ycalendar),u.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=r.select(this),a=m(e.select("text"));s.translatePoint(t,a,x,b)?n.layerClipId&&s.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(s.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),n=b.c2p(t.y);r.select(this).selectAll("tspan.line").each(function(){m(r.select(this)).attr({x:e,y:n})})}),o.exit().remove()}(A,L,f);var X=!1===_.cliponaxis?null:n.layerClipId;s.setClipUrl(A,X),s.setClipUrl(L,X)}function W(t){m(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function Q(t){return t.filter(function(t){return t.vis})}function $(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,n,a,i,c){var u,d,h=!i,g=!!i&&i.duration>0,v=f(t,e,n);((u=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,n){e.each(function(t){var e=o(r.select(this),"g","fills");s.setClipUrl(e,n.layerClipId);var a=t[0].trace,i=[];a._ownfill&&i.push("_ownFill"),a._nexttrace&&i.push("_nextFill");var c=e.selectAll("g").data(i,l);c.enter().append("g"),c.exit().each(function(t){a[t]=null}).remove(),c.order().each(function(t){a[t]=o(r.select(this),"path","js-fill")})})}(0,u,e),g)?(c&&(d=c()),r.transition().duration(i.duration).ease(i.easing).each("end",function(){d&&d()}).each("interrupt",function(){d&&d()}).each(function(){a.selectAll("g.trace").each(function(n,r){p(t,r,e,n,v,this,i)})})):u.each(function(n,r){p(t,r,e,n,v,this,i)});h&&u.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":70,"../../lib":165,"../../lib/polygon":177,"../../registry":259,"./line_points":295,"./link_traces":297,"./subtypes":305,d3:9}],302:[function(t,e,n){"use strict";var r=t("./subtypes");e.exports=function(t,e){var n,a,i,o,l=t.cd,s=t.xaxis,c=t.yaxis,u=[],f=l[0].trace;if(!r.hasMarkers(f)&&!r.hasText(f))return[];if(!1===e)for(n=0;n")}(u,v,p.mockAxis,c[0].t.labels),[t]}}},{"../../components/fx":87,"../../constants/numerical":145,"../../plots/cartesian/axes":210,"../scatter/fill_hover_text":289,"../scatter/get_trace_color":291,"./attributes":308}],313:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../scatter/marker_colorbar"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style"),r.styleOnSelect=t("../scatter/style").styleOnSelect,r.hoverPoints=t("./hover"),r.eventData=t("./event_data"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scattergeo",r.basePlotModule=t("../../plots/geo"),r.categories=["geo","symbols","showLegend","scatter-like"],r.meta={},e.exports=r},{"../../plots/geo":241,"../scatter/marker_colorbar":299,"../scatter/style":304,"./attributes":308,"./calc":309,"./defaults":310,"./event_data":311,"./hover":312,"./plot":314,"./select":315,"./style":316}],314:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../lib"),i=t("../../constants/numerical").BADNUM,o=t("../../lib/topojson_utils").getTopojsonFeatures,l=t("../../lib/geo_location_utils").locationToFeature,s=t("../../lib/geojson_utils"),c=t("../scatter/subtypes"),u=t("./style");function f(t,e){var n=t[0].trace;if(Array.isArray(n.locations))for(var r=o(n,e),a=n.locationmode,s=0;s:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;margin-left:0px;margin-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var i in a){var o=i.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");r.addStyleRule(o,a[i])}},{"../src/lib":163}],2:[function(t,e,n){"use strict";e.exports={undo:{width:857.1,height:1e3,path:"m857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z",transform:"matrix(1 0 0 -1 0 850)"},home:{width:928.6,height:1e3,path:"m786 296v-267q0-15-11-26t-25-10h-214v214h-143v-214h-214q-15 0-25 10t-11 26v267q0 1 0 2t0 2l321 264 321-264q1-1 1-4z m124 39l-34-41q-5-5-12-6h-2q-7 0-12 3l-386 322-386-322q-7-4-13-4-7 2-12 7l-35 41q-4 5-3 13t6 12l401 334q18 15 42 15t43-15l136-114v109q0 8 5 13t13 5h107q8 0 13-5t5-13v-227l122-102q5-5 6-12t-4-13z",transform:"matrix(1 0 0 -1 0 850)"},"camera-retro":{width:1e3,height:1e3,path:"m518 386q0 8-5 13t-13 5q-37 0-63-27t-26-63q0-8 5-13t13-5 12 5 5 13q0 23 16 38t38 16q8 0 13 5t5 13z m125-73q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101z m-572-320h858v71h-858v-71z m643 320q0 89-62 152t-152 62-151-62-63-152 63-151 151-63 152 63 62 151z m-571 358h214v72h-214v-72z m-72-107h858v143h-462l-36-71h-360v-72z m929 143v-714q0-30-21-51t-50-21h-858q-29 0-50 21t-21 51v714q0 30 21 51t50 21h858q29 0 50-21t21-51z",transform:"matrix(1 0 0 -1 0 850)"},zoombox:{width:1e3,height:1e3,path:"m1000-25l-250 251c40 63 63 138 63 218 0 224-182 406-407 406-224 0-406-182-406-406s183-406 407-406c80 0 155 22 218 62l250-250 125 125z m-812 250l0 438 437 0 0-438-437 0z m62 375l313 0 0-312-313 0 0 312z",transform:"matrix(1 0 0 -1 0 850)"},pan:{width:1e3,height:1e3,path:"m1000 350l-187 188 0-125-250 0 0 250 125 0-188 187-187-187 125 0 0-250-250 0 0 125-188-188 186-187 0 125 252 0 0-250-125 0 187-188 188 188-125 0 0 250 250 0 0-126 187 188z",transform:"matrix(1 0 0 -1 0 850)"},zoom_plus:{width:875,height:1e3,path:"m1 787l0-875 875 0 0 875-875 0z m687-500l-187 0 0-187-125 0 0 187-188 0 0 125 188 0 0 187 125 0 0-187 187 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},zoom_minus:{width:875,height:1e3,path:"m0 788l0-876 875 0 0 876-875 0z m688-500l-500 0 0 125 500 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},autoscale:{width:1e3,height:1e3,path:"m250 850l-187 0-63 0 0-62 0-188 63 0 0 188 187 0 0 62z m688 0l-188 0 0-62 188 0 0-188 62 0 0 188 0 62-62 0z m-875-938l0 188-63 0 0-188 0-62 63 0 187 0 0 62-187 0z m875 188l0-188-188 0 0-62 188 0 62 0 0 62 0 188-62 0z m-125 188l-1 0-93-94-156 156 156 156 92-93 2 0 0 250-250 0 0-2 93-92-156-156-156 156 94 92 0 2-250 0 0-250 0 0 93 93 157-156-157-156-93 94 0 0 0-250 250 0 0 0-94 93 156 157 156-157-93-93 0 0 250 0 0 250z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_basic:{width:1500,height:1e3,path:"m375 725l0 0-375-375 375-374 0-1 1125 0 0 750-1125 0z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_compare:{width:1125,height:1e3,path:"m187 786l0 2-187-188 188-187 0 0 937 0 0 373-938 0z m0-499l0 1-187-188 188-188 0 0 937 0 0 376-938-1z",transform:"matrix(1 0 0 -1 0 850)"},plotlylogo:{width:1542,height:1e3,path:"m0-10h182v-140h-182v140z m228 146h183v-286h-183v286z m225 714h182v-1000h-182v1000z m225-285h182v-715h-182v715z m225 142h183v-857h-183v857z m231-428h182v-429h-182v429z m225-291h183v-138h-183v138z",transform:"matrix(1 0 0 -1 0 850)"},"z-axis":{width:1e3,height:1e3,path:"m833 5l-17 108v41l-130-65 130-66c0 0 0 38 0 39 0-1 36-14 39-25 4-15-6-22-16-30-15-12-39-16-56-20-90-22-187-23-279-23-261 0-341 34-353 59 3 60 228 110 228 110-140-8-351-35-351-116 0-120 293-142 474-142 155 0 477 22 477 142 0 50-74 79-163 96z m-374 94c-58-5-99-21-99-40 0-24 65-43 144-43 79 0 143 19 143 43 0 19-42 34-98 40v216h87l-132 135-133-135h88v-216z m167 515h-136v1c16 16 31 34 46 52l84 109v54h-230v-71h124v-1c-16-17-28-32-44-51l-89-114v-51h245v72z",transform:"matrix(1 0 0 -1 0 850)"},"3d_rotate":{width:1e3,height:1e3,path:"m922 660c-5 4-9 7-14 11-359 263-580-31-580-31l-102 28 58-400c0 1 1 1 2 2 118 108 351 249 351 249s-62 27-100 42c88 83 222 183 347 122 16-8 30-17 44-27-2 1-4 2-6 4z m36-329c0 0 64 229-88 296-62 27-124 14-175-11 157-78 225-208 249-266 8-19 11-31 11-31 2 5 6 15 11 32-5-13-8-20-8-20z m-775-239c70-31 117-50 198-32-121 80-199 346-199 346l-96-15-58-12c0 0 55-226 155-287z m603 133l-317-139c0 0 4-4 19-14 7-5 24-15 24-15s-177-147-389 4c235-287 536-112 536-112l31-22 100 299-4-1z m-298-153c6-4 14-9 24-15 0 0-17 10-24 15z",transform:"matrix(1 0 0 -1 0 850)"},camera:{width:1e3,height:1e3,path:"m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z m400 150h-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28l-31-94c-6-15-23-28-40-28h-120c-55 0-100-45-100-100v-450c0-55 45-100 100-100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250-250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35-35z",transform:"matrix(1 0 0 -1 0 850)"},movie:{width:1e3,height:1e3,path:"m938 413l-188-125c0 37-17 71-44 94 64 38 107 107 107 187 0 121-98 219-219 219-121 0-219-98-219-219 0-61 25-117 66-156h-115c30 33 49 76 49 125 0 103-84 187-187 187s-188-84-188-187c0-57 26-107 65-141-38-22-65-62-65-109v-250c0-70 56-126 125-126h500c69 0 125 56 125 126l188-126c34 0 62 28 62 63v375c0 35-28 63-62 63z m-750 0c-69 0-125 56-125 125s56 125 125 125 125-56 125-125-56-125-125-125z m406-1c-87 0-157 70-157 157 0 86 70 156 157 156s156-70 156-156-70-157-156-157z",transform:"matrix(1 0 0 -1 0 850)"},question:{width:857.1,height:1e3,path:"m500 82v107q0 8-5 13t-13 5h-107q-8 0-13-5t-5-13v-107q0-8 5-13t13-5h107q8 0 13 5t5 13z m143 375q0 49-31 91t-77 65-95 23q-136 0-207-119-9-14 4-24l74-55q4-4 10-4 9 0 14 7 30 38 48 51 19 14 48 14 27 0 48-15t21-33q0-21-11-34t-38-25q-35-16-65-48t-29-70v-20q0-8 5-13t13-5h107q8 0 13 5t5 13q0 10 12 27t30 28q18 10 28 16t25 19 25 27 16 34 7 45z m214-107q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z",transform:"matrix(1 0 0 -1 0 850)"},disk:{width:857.1,height:1e3,path:"m214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z",transform:"matrix(1 0 0 -1 0 850)"},lasso:{width:1031,height:1e3,path:"m1018 538c-36 207-290 336-568 286-277-48-473-256-436-463 10-57 36-108 76-151-13-66 11-137 68-183 34-28 75-41 114-42l-55-70 0 0c-2-1-3-2-4-3-10-14-8-34 5-45 14-11 34-8 45 4 1 1 2 3 2 5l0 0 113 140c16 11 31 24 45 40 4 3 6 7 8 11 48-3 100 0 151 9 278 48 473 255 436 462z m-624-379c-80 14-149 48-197 96 42 42 109 47 156 9 33-26 47-66 41-105z m-187-74c-19 16-33 37-39 60 50-32 109-55 174-68-42-25-95-24-135 8z m360 75c-34-7-69-9-102-8 8 62-16 128-68 170-73 59-175 54-244-5-9 20-16 40-20 61-28 159 121 317 333 354s407-60 434-217c28-159-121-318-333-355z",transform:"matrix(1 0 0 -1 0 850)"},selectbox:{width:1e3,height:1e3,path:"m0 850l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-285l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z",transform:"matrix(1 0 0 -1 0 850)"},spikeline:{width:1e3,height:1e3,path:"M512 409c0-57-46-104-103-104-57 0-104 47-104 104 0 57 47 103 104 103 57 0 103-46 103-103z m-327-39l92 0 0 92-92 0z m-185 0l92 0 0 92-92 0z m370-186l92 0 0 93-92 0z m0-184l92 0 0 92-92 0z",transform:"matrix(1.5 0 0 -1.5 0 850)"},newplotlylogo:{name:"newplotlylogo",svg:"plotly-logomark"}}},{}],3:[function(t,e,n){"use strict";e.exports=t("../src/traces/choropleth")},{"../src/traces/choropleth":271}],4:[function(t,e,n){"use strict";e.exports=t("../src/core")},{"../src/core":144}],5:[function(t,e,n){"use strict";var r=t("./core");r.register([t("./scattergeo"),t("./choropleth")]),e.exports=r},{"./choropleth":3,"./core":4,"./scattergeo":6}],6:[function(t,e,n){"use strict";e.exports=t("../src/traces/scattergeo")},{"../src/traces/scattergeo":311}],7:[function(t,e,n){var r=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return n},i=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var l,s=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),l=0===c.x}catch(t){l=!1}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,n,a){var i,o,l;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),l=o[e]):(o=t._events=r(null),t._eventsCount=0),l){if("function"==typeof l?l=o[e]=a?[n,l]:[l,n]:a?l.unshift(n):l.push(n),!l.warned&&(i=u(t))&&i>0&&l.length>i){l.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+l.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=l.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else l=o[e]=n,++t._eventsCount;return t}function d(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var s=new Error('Unhandled "error" event. ('+e+")");throw s.context=e,s}if(!(n=o[t]))return!1;var c="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,a=v(t,r),i=0;i=0;o--)if(n[o]===e||n[o].listener===e){l=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(var n=e,r=n+1,a=t.length;r=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],8:[function(t,e,n){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",CPV:"verde",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai)(?!.*\\brep).*china|^(?=.*peo)(?=.*rep).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COG:"^(?!.*\\bdem)(?!.*\\bd[\\.]?r)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CSK:"czechoslovakia",CZE:"^(?=.*rep).*czech|czechia|bohemia",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bd[\\.]?r|\\bd[\\.]?r.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"(^ireland)|(^republic.*ireland)",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat|people|north|d.*p.*.r).*\\bkorea|dprk|korea.*(d.*p.*r)",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"fed.*micronesia|micronesia.*fed",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",KOR:"^(?!.*d.*p.*r)(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea(?!.*d.*p.*r)",MDA:"moldov|b(a|e)ssarabia",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"south.africa|s\\\\..?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa|^(?!.*peo)(?=.*rep).*china",TJK:"tajik",THA:"thailand|\\bsiam",MKD:"macedonia|fyrom",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",TZA:"tanzania",USA:"united.?states\\b(?!.*islands)|\\bu\\.?s\\.?a\\.?\\b|^\\s*u\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],9:[function(t,e,n){!function(){var t={version:"3.5.17"},n=[].slice,r=function(t){return n.call(t)},a=this.document;function i(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(a)try{r(a.documentElement.childNodes)[0].nodeType}catch(t){r=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),a)try{a.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var l=this.Element.prototype,s=l.setAttribute,c=l.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;l.setAttribute=function(t,e){s.call(this,t,e+"")},l.setAttributeNS=function(t,e,n){c.call(this,t,e,n+"")},u.setProperty=function(t,e,n){f.call(this,t,e+"",n)}}function d(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function h(t){return!isNaN(t)}function g(t){return{left:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[i],n)<0?r=i+1:a=i}return r},right:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[i],n)>0?a=i:r=i+1}return r}}}t.ascending=d,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var n,r,a=-1,i=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++ar&&(n=r)}else{for(;++a=r){n=r;break}for(;++ar&&(n=r)}return n},t.max=function(t,e){var n,r,a=-1,i=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++an&&(n=r)}else{for(;++a=r){n=r;break}for(;++an&&(n=r)}return n},t.extent=function(t,e){var n,r,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=r){n=a=r;break}for(;++ir&&(n=r),a=r){n=a=r;break}for(;++ir&&(n=r),a1)return o/(s-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(d);function y(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,n){return d(t(e),n)}:t)},t.shuffle=function(t,e,n){(i=arguments.length)<3&&(n=t.length,i<2&&(e=0));for(var r,a,i=n-e;i;)a=Math.random()*i--|0,r=t[i+e],t[i+e]=t[a+e],t[a+e]=r;return t},t.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},t.pairs=function(t){for(var e=0,n=t.length-1,r=t[0],a=new Array(n<0?0:n);e=0;)for(e=(r=t[a]).length;--e>=0;)n[--o]=r[e];return n};var m=Math.abs;function x(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n==1/0)throw new Error("infinite range");var r,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(m(n)),o=-1;if(t*=i,e*=i,(n*=i)<0)for(;(r=t+n*++o)>e;)a.push(r/i);else for(;(r=t+n*++o)=a.length)return n?n.call(r,i):e?i.sort(e):i;for(var s,c,u,f,d=-1,p=i.length,h=a[l++],g=new b;++d=a.length)return e;var r=[],o=i[n++];return e.forEach(function(e,a){r.push({key:e,values:t(a,n)})}),o?r.sort(function(t,e){return o(t.key,e.key)}):r}(o(t.map,e,0),0)},r.key=function(t){return a.push(t),r},r.sortKeys=function(t){return i[a.length-1]=t,r},r.sortValues=function(t){return e=t,r},r.rollup=function(t){return n=t,r},r},t.set=function(t){var e=new P;if(t)for(var n=0,r=t.length;n=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},t.event=null,t.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]};function U(t){return q(t,Z),t}var V=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},Y=function(t,e){var n=t.matches||t[D(t,"matchesSelector")];return(Y=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(V=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,Y=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var Z=t.selection.prototype=[];function X(t){return"function"==typeof t?t:function(){return V(t,this)}}function W(t){return"function"==typeof t?t:function(){return G(t,this)}}Z.select=function(t){var e,n,r,a,i=[];t=X(t);for(var o=-1,l=this.length;++o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),$.hasOwnProperty(n)?{space:$[n],local:t}:t}},Z.attr=function(e,n){if(arguments.length<2){if("string"==typeof e){var r=this.node();return(e=t.ns.qualify(e)).local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}for(n in e)this.each(Q(n,e[n]));return this}return this.each(Q(e,n))},Z.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=et(t)).length,a=-1;if(e=n.classList){for(;++a=0;)(n=r[a])&&(i&&i!==n.nextSibling&&i.parentNode.insertBefore(n,i),i=n);return this},Z.sort=function(t){t=function(t){arguments.length||(t=d);return function(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}}.apply(this,arguments);for(var e=-1,n=this.length;++e0&&(e=e.slice(0,o));var s=ht.get(e);function c(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return s&&(e=s,l=vt),o?n?function(){var t=l(n,r(arguments));c.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=n}:c:n?E:function(){var n,r=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(n=a.match(r)){var i=this[a];this.removeEventListener(n[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=dt,dt.append=Z.append,dt.empty=Z.empty,dt.node=Z.node,dt.call=Z.call,dt.size=Z.size,dt.select=function(t){for(var e,n,r,a,i,o=[],l=-1,s=this.length;++l=r&&(r=e+1);!(o=l[r])&&++r0?1:t<0?-1:0}function zt(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function Dt(t){return t>1?0:t<-1?Tt:Math.acos(t)}function Rt(t){return t>1?St:t<-1?-St:Math.asin(t)}function Et(t){return((t=Math.exp(t))+1/t)/2}function Nt(t){return(t=Math.sin(t/2))*t}var It=Math.SQRT2;t.interpolateZoom=function(t,e){var n,r,a=t[0],i=t[1],o=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-i,d=u*u+f*f;if(d0&&(e=e.transition().duration(g)),e.call(w.event)}function L(){c&&c.domain(s.range().map(function(t){return(t-d.x)/d.k}).map(s.invert)),f&&f.domain(u.range().map(function(t){return(t-d.y)/d.k}).map(u.invert))}function S(t){v++||t({type:"zoomstart"})}function C(t){L(),t({type:"zoom",scale:d.k,translate:[d.x,d.y]})}function P(t){--v||(t({type:"zoomend"}),n=null)}function O(){var e=this,n=_.of(e,arguments),r=0,a=t.select(o(e)).on(m,function(){r=1,T(t.mouse(e),i),C(n)}).on(x,function(){a.on(m,null).on(x,null),l(r),P(n)}),i=k(t.mouse(e)),l=xt(e);fl.call(e),S(n)}function z(){var e,n=this,r=_.of(n,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+o,c="touchend"+o,u=[],f=t.select(n),p=xt(n);function h(){var r=t.touches(n);return e=d.k,r.forEach(function(t){t.identifier in a&&(a[t.identifier]=k(t))}),r}function g(){var e=t.event.target;t.select(e).on(s,v).on(c,m),u.push(e);for(var r=t.event.changedTouches,o=0,f=r.length;o1){y=p[0];var x=p[1],b=y[0]-x[0],_=y[1]-x[1];i=b*b+_*_}}function v(){var o,s,c,u,f=t.touches(n);fl.call(n);for(var d=0,p=f.length;d360?t-=360:t<0&&(t+=360),t<60?r+(a-r)*t/60:t<180?a:t<240?r+(a-r)*(240-t)/60:r}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,r=2*(n=n<0?0:n>1?1:n)-(a=n<=.5?n*(1+e):n+e-n*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,n,r){return this instanceof Gt?(this.h=+e,this.c=+n,void(this.l=+r)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Xt?e.l:(e=de((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,n,r)}Ut.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Ut.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Ut.rgb=function(){return Vt(this.h,this.s,this.l)},t.hcl=Gt;var Yt=Gt.prototype=new Ht;function Zt(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Xt(n,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Xt(t,e,n){return this instanceof Xt?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof Xt?new Xt(t.l,t.a,t.b):t instanceof Gt?Zt(t.h,t.c,t.l):de((t=ie(t)).r,t.g,t.b):new Xt(t,e,n)}Yt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Wt*(arguments.length?t:1)))},Yt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Wt*(arguments.length?t:1)))},Yt.rgb=function(){return Zt(this.h,this.c,this.l).rgb()},t.lab=Xt;var Wt=18,Jt=.95047,$t=1,Qt=1.08883,Kt=Xt.prototype=new Ht;function te(t,e,n){var r=(t+16)/116,a=r+e/500,i=r-n/200;return new ie(ae(3.2404542*(a=ne(a)*Jt)-1.5371385*(r=ne(r)*$t)-.4985314*(i=ne(i)*Qt)),ae(-.969266*a+1.8760108*r+.041556*i),ae(.0556434*a-.2040259*r+1.0572252*i))}function ee(t,e,n){return t>0?new Gt(Math.atan2(n,e)*Pt,Math.sqrt(e*e+n*n),t):new Gt(NaN,NaN,t)}function ne(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function re(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,n){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ue(""+t,ie,Vt):new ie(t,e,n)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function le(t){return oe(t)+""}Kt.brighter=function(t){return new Xt(Math.min(100,this.l+Wt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Xt(Math.max(0,this.l-Wt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var se=ie.prototype=new Ht;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,n){var r,a,i,o=0,l=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=r[2].split(","),r[1]){case"hsl":return n(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(he(a[0]),he(a[1]),he(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,l=240&i,l|=l>>4,s=15&i,s|=s<<4):7===t.length&&(o=(16711680&i)>>16,l=(65280&i)>>8,s=255&i)),e(o,l,s))}function fe(t,e,n){var r,a,i=Math.min(t/=255,e/=255,n/=255),o=Math.max(t,e,n),l=o-i,s=(o+i)/2;return l?(a=s<.5?l/(o+i):l/(2-o-i),r=t==o?(e-n)/l+(e0&&s<1?0:r),new qt(r,a,s)}function de(t,e,n){var r=re((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(n=pe(n)))/Jt),a=re((.2126729*t+.7151522*e+.072175*n)/$t);return Xt(116*a-16,500*(r-a),200*(a-re((.0193339*t+.119192*e+.9503041*n)/Qt)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function he(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}se.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,n=this.g,r=this.b,a=30;return e||n||r?(e&&e=200&&e<300||304===e){try{t=a.call(o,c)}catch(t){return void l.error.call(o,t)}l.load.call(o,t)}else l.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var n=t.event;t.event=e;try{l.progress.call(o,c)}finally{t.event=n}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(n=null==t?null:t+"",o):n},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(r(arguments)))}}),o.send=function(t,r,a){if(2===arguments.length&&"function"==typeof r&&(a=r,r=null),c.open(t,e,!0),null==n||"accept"in s||(s.accept=n+",*/*"),c.setRequestHeader)for(var i in s)c.setRequestHeader(i,s[i]);return null!=n&&c.overrideMimeType&&c.overrideMimeType(n),null!=u&&(c.responseType=u),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),l.beforesend.call(o,c),c.send(null==r?null:r),o},o.abort=function(){return c.abort(),o},t.rebind(o,l,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=ye(O),t.dsv=function(t,e){var n=new RegExp('["'+t+"\n]"),r=t.charCodeAt(0);function a(t,n,r){arguments.length<3&&(r=n,n=null);var a=me(t,e,null==n?i:o(n),r);return a.row=function(t){return arguments.length?a.response(null==(n=t)?i:o(t)):n},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function l(e){return e.map(s).join(t)}function s(t){return n.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var n;return a.parseRows(t,function(t,r){if(n)return n(t,r-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,n){return e(a(t),n)}:a})},a.parseRows=function(t,e){var n,a,i={},o={},l=[],s=t.length,c=0,u=0;function f(){if(c>=s)return o;if(a)return a=!1,i;var e=c;if(34===t.charCodeAt(e)){for(var n=e;n++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Te,e)),_e=0):(_e=1,ke(Te))}function Ae(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Le(){for(var t,e=xe,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}});t.formatPrefix=function(e,n){var r=0;return(e=+e)&&(e<0&&(e*=-1),n&&(e=t.round(e,Se(e,n))),r=1+Math.floor(1e-12+Math.log(e)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),Ce[8+r/3]};var Pe=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Oe=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,n){return(e=t.round(e,Se(e,n))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),n))))}});function ze(t){return t+""}var De=t.time={},Re=Date;function Ee(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Ee.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ne.setUTCDate.apply(this._,arguments)},setDay:function(){Ne.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ne.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ne.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ne.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ne.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ne.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ne.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ne.setTime.apply(this._,arguments)}};var Ne=Date.prototype;function Ie(t,e,n){function r(e){var n=t(e),r=i(n,1);return e-n1)for(;o68?1900:2e3),n+a[0].length):-1}function Je(t,e,n){return/^[+-]\d{4}$/.test(e=e.slice(n,n+5))?(t.Z=-e,n+5):-1}function $e(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Qe(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Ke(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function tn(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function en(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function nn(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function rn(t,e,n){Be.lastIndex=0;var r=Be.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function an(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=m(e)/60|0,a=m(e)%60;return n+qe(r,"0",2)+qe(a,"0",2)}function on(t,e,n){He.lastIndex=0;var r=He.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ln(t){for(var e=t.length,n=-1;++n0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),i.push(t.substring(n-=l,n+l)),!((s+=l+1)>e));)l=a[o=(o+1)%a.length];return i.reverse().join(r)}:O;return function(e){var r=Pe.exec(e),a=r[1]||" ",l=r[2]||">",s=r[3]||"-",c=r[4]||"",u=r[5],f=+r[6],d=r[7],p=r[8],h=r[9],g=1,v="",y="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===a&&"="===l)&&(u=a="0",l="="),h){case"n":d=!0,h="g";break;case"%":g=100,y="%",h="f";break;case"p":g=100,y="%",h="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+h.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":g=-1,h="r"}"$"===c&&(v=i[0],y=i[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):"e"!=h&&"f"!=h||(p=Math.max(0,Math.min(20,p)))),h=Oe.get(h)||ze;var b=u&&d;return function(e){var r=y;if(m&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===s?"":s;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),r=c.symbol+y}else e*=g;var _,w,k=(e=h(e,p)).lastIndexOf(".");if(k<0){var M=x?e.lastIndexOf("e"):-1;M<0?(_=e,w=""):(_=e.substring(0,M),w=e.substring(M))}else _=e.substring(0,k),w=n+e.substring(k+1);!u&&d&&(_=o(_,1/0));var T=v.length+_.length+w.length+(b?0:i.length),A=T"===l?A+i+e:"^"===l?A.substring(0,T>>=1)+i+e+A.substring(T):i+(b?e:A+e))+r}}}(e),timeFormat:function(e){var n=e.dateTime,r=e.date,a=e.time,i=e.periods,o=e.days,l=e.shortDays,s=e.months,c=e.shortMonths;function u(t){var e=t.length;function n(n){for(var r,a,i,o=[],l=-1,s=0;++l=c)return-1;if(37===(a=e.charCodeAt(l++))){if(o=e.charAt(l++),!(i=w[o in je?e.charAt(l++):o])||(r=i(t,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}u.utc=function(t){var e=u(t);function n(t){try{var n=new(Re=Ee);return n._=t,e(n)}finally{Re=Date}}return n.parse=function(t){try{Re=Ee;var n=e.parse(t);return n&&n._}finally{Re=Date}},n.toString=e.toString,n},u.multi=u.utc.multi=ln;var d=t.map(),p=Ue(o),h=Ve(o),g=Ue(l),v=Ve(l),y=Ue(s),m=Ve(s),x=Ue(c),b=Ve(c);i.forEach(function(t,e){d.set(t.toLowerCase(),e)});var _={a:function(t){return l[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:u(n),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+De.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(De.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(De.mondayOfYear(t),e,2)},x:u(r),X:u(a),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:an,"%":function(){return"%"}},w={a:function(t,e,n){g.lastIndex=0;var r=g.exec(e.slice(n));return r?(t.w=v.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){p.lastIndex=0;var r=p.exec(e.slice(n));return r?(t.w=h.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){x.lastIndex=0;var r=x.exec(e.slice(n));return r?(t.m=b.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){y.lastIndex=0;var r=y.exec(e.slice(n));return r?(t.m=m.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,e,n){return f(t,_.c.toString(),e,n)},d:Qe,e:Qe,H:tn,I:tn,j:Ke,L:rn,m:$e,M:en,p:function(t,e,n){var r=d.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)},S:nn,U:Ye,w:Ge,W:Ze,x:function(t,e,n){return f(t,_.x.toString(),e,n)},X:function(t,e,n){return f(t,_.X.toString(),e,n)},y:We,Y:Xe,Z:Je,"%":on};return u}(e)}};var sn=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function cn(){}t.format=sn.numberFormat,t.geo={},cn.prototype={s:0,t:0,add:function(t){fn(t,this.t,un),fn(un.s,this.s,this),this.s?this.t+=un.t:this.s=un.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var un=new cn;function fn(t,e,n){var r=n.s=t+e,a=r-t,i=r-a;n.t=t-i+(e-a)}function dn(t,e){t&&hn.hasOwnProperty(t.type)&&hn[t.type](t,e)}t.geo.stream=function(t,e){t&&pn.hasOwnProperty(t.type)?pn[t.type](t,e):dn(t,e)};var pn={Feature:function(t,e){dn(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,a=n.length;++r=0?1:-1,l=o*i,s=Math.cos(e),c=Math.sin(e),u=a*c,f=r*s+u*Math.cos(l),d=u*o*Math.sin(l);Cn.add(Math.atan2(d,f)),n=t,r=s,a=c}Pn.point=function(o,l){Pn.point=i,n=(t=o)*Ct,r=Math.cos(l=(e=l)*Ct/2+Tt/4),a=Math.sin(l)},Pn.lineEnd=function(){i(t,e)}}function zn(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function Dn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Rn(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function En(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Nn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function In(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Fn(t){return[Math.atan2(t[1],t[0]),Rt(t[2])]}function jn(t,e){return m(t[0]-e[0])kt?a=90:c<-kt&&(n=-90),f[0]=e,f[1]=r}};function p(t,i){u.push(f=[e=t,r=t]),ia&&(a=i)}function h(t,o){var l=zn([t*Ct,o*Ct]);if(s){var c=Rn(s,l),u=Rn([c[1],-c[0],0],c);In(u),u=Fn(u);var f=t-i,d=f>0?1:-1,h=u[0]*Pt*d,g=m(f)>180;if(g^(d*ia&&(a=v);else if(g^(d*i<(h=(h+360)%360-180)&&ha&&(a=o);g?t_(e,r)&&(r=t):_(t,r)>_(e,r)&&(e=t):r>=e?(tr&&(r=t)):t>i?_(e,t)>_(e,r)&&(r=t):_(t,r)>_(e,r)&&(e=t)}else p(t,o);s=l,i=t}function g(){d.point=h}function v(){f[0]=e,f[1]=r,d.point=p,s=null}function y(t,e){if(s){var n=t-i;c+=m(n)>180?n+(n>0?360:-360):n}else o=t,l=e;Pn.point(t,e),h(t,e)}function x(){Pn.lineStart()}function b(){y(o,l),Pn.lineEnd(),m(c)>kt&&(e=-(r=180)),f[0]=e,f[1]=r,s=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):l.push(g=p);for(var s,c,p,h=-1/0,g=(o=0,l[c=l.length-1]);o<=c;g=p,++o)p=l[o],(s=_(g[1],p[0]))>h&&(h=s,e=p[0],r=g[1])}return u=f=null,e===1/0||n===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,n],[r,a]]}}(),t.geo.centroid=function(e){mn=xn=bn=_n=wn=kn=Mn=Tn=An=Ln=Sn=0,t.geo.stream(e,Bn);var n=An,r=Ln,a=Sn,i=n*n+r*r+a*a;return i=0;--l)a.point((f=u[l])[0],f[1]);else r(p.x,p.p.x,-1,a);p=p.p}u=(p=p.o).z,h=!h}while(!p.v);a.lineEnd()}}}function Wn(t){if(e=t.length){for(var e,n,r=0,a=t[0];++r=0?1:-1,k=w*_,M=k>Tt,T=h*x;if(Cn.add(Math.atan2(T*w*Math.sin(k),g*b+T*Math.cos(k))),i+=M?_+w*At:_,M^d>=n^y>=n){var A=Rn(zn(f),zn(t));In(A);var L=Rn(a,A);In(L);var S=(M^_>=0?-1:1)*Rt(L[2]);(r>S||r===S&&(A[0]||A[1]))&&(o+=M^_>=0?1:-1)}if(!v++)break;d=y,h=x,g=b,f=t}}return(i<-kt||i0){for(x||(o.polygonStart(),x=!0),o.lineStart();++i1&&2&e&&n.push(n.pop().concat(n.shift())),l.push(n.filter(Qn))}return u}}function Qn(t){return t.length>1}function Kn(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:E,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function tr(t,e){return((t=t.x)[0]<0?t[1]-St-kt:St-t[1])-((e=e.x)[0]<0?e[1]-St-kt:St-e[1])}var er=$n(Zn,function(t){var e,n=NaN,r=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var l=i>0?Tt:-Tt,s=m(i-n);m(s-Tt)0?St:-St),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),t.point(i,r),e=0):a!==l&&s>=Tt&&(m(n-a)kt?Math.atan((Math.sin(e)*(i=Math.cos(r))*Math.sin(n)-Math.sin(r)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+r)/2}(n,r,i,o),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),e=0),t.point(n=i,r=o),a=l},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}},function(t,e,n,r){var a;if(null==t)a=n*St,r.point(-Tt,a),r.point(0,a),r.point(Tt,a),r.point(Tt,0),r.point(Tt,-a),r.point(0,-a),r.point(-Tt,-a),r.point(-Tt,0),r.point(-Tt,a);else if(m(t[0]-e[0])>kt){var i=t[0]0)){if(i/=d,d<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=n-s,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>u&&(u=i)}else if(d>0){if(i0)){if(i/=p,p<0){if(i0){if(i>f)return;i>u&&(u=i)}if(i=r-c,p||!(i<0)){if(i/=p,p<0){if(i>f)return;i>u&&(u=i)}else if(p>0){if(i0&&(a.a={x:s+u*d,y:c+u*p}),f<1&&(a.b={x:s+f*d,y:c+f*p}),a}}}}}}var rr=1e9;function ar(e,n,r,a){return function(s){var c,u,f,d,p,h,g,v,y,m,x,b=s,_=Kn(),w=nr(e,n,r,a),k={point:A,lineStart:function(){k.point=L,u&&u.push(f=[]);m=!0,y=!1,g=v=NaN},lineEnd:function(){c&&(L(d,p),h&&y&&_.rejoin(),c.push(_.buffer()));k.point=A,y&&s.lineEnd()},polygonStart:function(){s=_,c=[],u=[],x=!0},polygonEnd:function(){s=b,c=t.merge(c);var n=function(t){for(var e=0,n=u.length,r=t[1],a=0;ar&&zt(c,i,t)>0&&++e:i[1]<=r&&zt(c,i,t)<0&&--e,c=i;return 0!==e}([e,a]),r=x&&n,i=c.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),M(null,null,1,s),s.lineEnd()),i&&Xn(c,o,n,M,s),s.polygonEnd()),c=u=f=null}};function M(t,o,s,c){var u=0,f=0;if(null==t||(u=i(t,s))!==(f=i(o,s))||l(t,o)<0^s>0)do{c.point(0===u||3===u?e:r,u>1?a:n)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function T(t,i){return e<=t&&t<=r&&n<=i&&i<=a}function A(t,e){T(t,e)&&s.point(t,e)}function L(t,e){var n=T(t=Math.max(-rr,Math.min(rr,t)),e=Math.max(-rr,Math.min(rr,e)));if(u&&f.push([t,e]),m)d=t,p=e,h=n,m=!1,n&&(s.lineStart(),s.point(t,e));else if(n&&y)s.point(t,e);else{var r={a:{x:g,y:v},b:{x:t,y:e}};w(r)?(y||(s.lineStart(),s.point(r.a.x,r.a.y)),s.point(r.b.x,r.b.y),n||s.lineEnd(),x=!1):n&&(s.lineStart(),s.point(t,e),x=!1)}g=t,v=e,y=n}return k};function i(t,a){return m(t[0]-e)0?0:3:m(t[0]-r)0?2:1:m(t[1]-n)0?1:0:a>0?3:2}function o(t,e){return l(t.x,e.x)}function l(t,e){var n=i(t,1),r=i(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}}function ir(t){var e=0,n=Tt/3,r=Cr(t),a=r(e,n);return a.parallels=function(t){return arguments.length?r(e=t[0]*Tt/180,n=t[1]*Tt/180):[e/Tt*180,n/Tt*180]},a}function or(t,e){var n=Math.sin(t),r=(n+Math.sin(e))/2,a=1+n*(2*r-n),i=Math.sqrt(a)/r;function o(t,e){var n=Math.sqrt(a-2*r*Math.sin(e))/r;return[n*Math.sin(t*=r),i-n*Math.cos(t)]}return o.invert=function(t,e){var n=i-e;return[Math.atan2(t,n)/r,Rt((a-(t*t+n*n)*r*r)/(2*r))]},o}t.geo.clipExtent=function(){var t,e,n,r,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(l){return arguments.length?(i=ar(t=+l[0][0],e=+l[0][1],n=+l[1][0],r=+l[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[n,r]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return ir(or)}).raw=or,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,n,r,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,n){e=[t,n]}};function c(t){var i=t[0],o=t[1];return e=null,n(i,o),e||(r(i,o),e)||a(i,o),e}return c.invert=function(t){var e=i.scale(),n=i.translate(),r=(t[0]-n[0])/e,a=(t[1]-n[1])/e;return(a>=.12&&a<.234&&r>=-.425&&r<-.214?o:a>=.166&&a<.234&&r>=-.214&&r<-.115?l:i).invert(t)},c.stream=function(t){var e=i.stream(t),n=o.stream(t),r=l.stream(t);return{point:function(t,a){e.point(t,a),n.point(t,a),r.point(t,a)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),l.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),l.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),u=+t[0],f=+t[1];return n=i.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(s).point,r=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(s).point,a=l.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(s).point,c},c.scale(1070)};var lr,sr,cr,ur,fr,dr,pr={point:E,lineStart:E,lineEnd:E,polygonStart:function(){sr=0,pr.lineStart=hr},polygonEnd:function(){pr.lineStart=pr.lineEnd=pr.point=E,lr+=m(sr/2)}};function hr(){var t,e,n,r;function a(t,e){sr+=r*t-n*e,n=t,r=e}pr.point=function(i,o){pr.point=a,t=n=i,e=r=o},pr.lineEnd=function(){a(t,e)}}var gr={point:function(t,e){tfr&&(fr=t);edr&&(dr=e)},lineStart:E,lineEnd:E,polygonStart:E,polygonEnd:E};function vr(){var t=yr(4.5),e=[],n={point:r,lineStart:function(){n.point=a},lineEnd:o,polygonStart:function(){n.lineEnd=l},polygonEnd:function(){n.lineEnd=o,n.point=r},pointRadius:function(e){return t=yr(e),n},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function r(n,r){e.push("M",n,",",r,t)}function a(t,r){e.push("M",t,",",r),n.point=i}function i(t,n){e.push("L",t,",",n)}function o(){n.point=r}function l(){e.push("Z")}return n}function yr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var mr,xr={point:br,lineStart:_r,lineEnd:wr,polygonStart:function(){xr.lineStart=kr},polygonEnd:function(){xr.point=br,xr.lineStart=_r,xr.lineEnd=wr}};function br(t,e){bn+=t,_n+=e,++wn}function _r(){var t,e;function n(n,r){var a=n-t,i=r-e,o=Math.sqrt(a*a+i*i);kn+=o*(t+n)/2,Mn+=o*(e+r)/2,Tn+=o,br(t=n,e=r)}xr.point=function(r,a){xr.point=n,br(t=r,e=a)}}function wr(){xr.point=br}function kr(){var t,e,n,r;function a(t,e){var a=t-n,i=e-r,o=Math.sqrt(a*a+i*i);kn+=o*(n+t)/2,Mn+=o*(r+e)/2,Tn+=o,An+=(o=r*t-n*e)*(n+t),Ln+=o*(r+e),Sn+=3*o,br(n=t,r=e)}xr.point=function(i,o){xr.point=a,br(t=n=i,e=r=o)},xr.lineEnd=function(){a(t,e)}}function Mr(t){var e=4.5,n={point:r,lineStart:function(){n.point=a},lineEnd:o,polygonStart:function(){n.lineEnd=l},polygonEnd:function(){n.lineEnd=o,n.point=r},pointRadius:function(t){return e=t,n},result:E};function r(n,r){t.moveTo(n+e,r),t.arc(n,r,e,0,At)}function a(e,r){t.moveTo(e,r),n.point=i}function i(e,n){t.lineTo(e,n)}function o(){n.point=r}function l(){t.closePath()}return n}function Tr(t){var e=.5,n=Math.cos(30*Ct),r=16;function a(e){return(r?function(e){var n,a,o,l,s,c,u,f,d,p,h,g,v={point:y,lineStart:m,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=m}};function y(n,r){n=t(n,r),e.point(n[0],n[1])}function m(){f=NaN,v.point=x,e.lineStart()}function x(n,a){var o=zn([n,a]),l=t(n,a);i(f,d,u,p,h,g,f=l[0],d=l[1],u=n,p=o[0],h=o[1],g=o[2],r,e),e.point(f,d)}function b(){v.point=y,e.lineEnd()}function _(){m(),v.point=w,v.lineEnd=k}function w(t,e){x(n=t,e),a=f,o=d,l=p,s=h,c=g,v.point=x}function k(){i(f,d,u,p,h,g,a,o,n,l,s,c,r,e),v.lineEnd=b,b()}return v}:function(e){return Lr(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})})(e)}function i(r,a,o,l,s,c,u,f,d,p,h,g,v,y){var x=u-r,b=f-a,_=x*x+b*b;if(_>4*e&&v--){var w=l+p,k=s+h,M=c+g,T=Math.sqrt(w*w+k*k+M*M),A=Math.asin(M/=T),L=m(m(M)-1)e||m((x*O+b*z)/_-.5)>.3||l*p+s*h+c*g0&&16,a):Math.sqrt(e)},a}function Ar(t){this.stream=t}function Lr(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sr(t){return Cr(function(){return t})()}function Cr(e){var n,r,a,i,o,l,s=Tr(function(t,e){return[(t=n(t,e))[0]*c+i,o-t[1]*c]}),c=150,u=480,f=250,d=0,p=0,h=0,g=0,v=0,y=er,x=O,b=null,_=null;function w(t){return[(t=a(t[0]*Ct,t[1]*Ct))[0]*c+i,o-t[1]*c]}function k(t){return(t=a.invert((t[0]-i)/c,(o-t[1])/c))&&[t[0]*Pt,t[1]*Pt]}function M(){a=Yn(r=Dr(h,g,v),n);var t=n(d,p);return i=u-t[0]*c,o=f+t[1]*c,T()}function T(){return l&&(l.valid=!1,l=null),w}return w.stream=function(t){return l&&(l.valid=!1),(l=Pr(y(r,s(x(t))))).valid=!0,l},w.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,er):function(t){var e=Math.cos(t),n=e>0,r=m(e)>kt;return $n(a,function(t){var e,l,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var p,h=[f,d],g=a(f,d),v=n?g?0:o(f,d):g?o(f+(f<0?Tt:-Tt),d):0;if(!e&&(c=s=g)&&t.lineStart(),g!==s&&(p=i(e,h),(jn(e,p)||jn(h,p))&&(h[0]+=kt,h[1]+=kt,g=a(h[0],h[1]))),g!==s)u=0,g?(t.lineStart(),p=i(h,e),t.point(p[0],p[1])):(p=i(e,h),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(r&&e&&n^g){var y;v&l||!(y=i(h,e,!0))||(u=0,n?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!g||e&&jn(e,h)||t.point(h[0],h[1]),e=h,s=g,l=v},lineEnd:function(){s&&t.lineEnd(),e=null},clean:function(){return u|(c&&s)<<1}}},Ir(t,6*Ct),n?[0,-t]:[-Tt,t-Tt]);function a(t,n){return Math.cos(t)*Math.cos(n)>e}function i(t,n,r){var a=[1,0,0],i=Rn(zn(t),zn(n)),o=Dn(i,i),l=i[0],s=o-l*l;if(!s)return!r&&t;var c=e*o/s,u=-e*l/s,f=Rn(a,i),d=Nn(a,c);En(d,Nn(i,u));var p=f,h=Dn(d,p),g=Dn(p,p),v=h*h-g*(Dn(d,d)-1);if(!(v<0)){var y=Math.sqrt(v),x=Nn(p,(-h-y)/g);if(En(x,d),x=Fn(x),!r)return x;var b,_=t[0],w=n[0],k=t[1],M=n[1];w<_&&(b=_,_=w,w=b);var T=w-_,A=m(T-Tt)0^x[1]<(m(x[0]-_)Tt^(_<=x[0]&&x[0]<=w)){var L=Nn(p,(-h+y)/g);return En(L,d),[x,Fn(L)]}}}function o(e,r){var a=n?t:Tt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),r<-a?i|=4:r>a&&(i|=8),i}}((b=+t)*Ct),T()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?ar(t[0][0],t[0][1],t[1][0],t[1][1]):O,T()):_},w.scale=function(t){return arguments.length?(c=+t,M()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],M()):[u,f]},w.center=function(t){return arguments.length?(d=t[0]%360*Ct,p=t[1]%360*Ct,M()):[d*Pt,p*Pt]},w.rotate=function(t){return arguments.length?(h=t[0]%360*Ct,g=t[1]%360*Ct,v=t.length>2?t[2]%360*Ct:0,M()):[h*Pt,g*Pt,v*Pt]},t.rebind(w,s,"precision"),function(){return n=e.apply(this,arguments),w.invert=n.invert&&k,M()}}function Pr(t){return Lr(t,function(e,n){t.point(e*Ct,n*Ct)})}function Or(t,e){return[t,e]}function zr(t,e){return[t>Tt?t-At:t<-Tt?t+At:t,e]}function Dr(t,e,n){return t?e||n?Yn(Er(t),Nr(e,n)):Er(t):e||n?Nr(e,n):zr}function Rr(t){return function(e,n){return[(e+=t)>Tt?e-At:e<-Tt?e+At:e,n]}}function Er(t){var e=Rr(t);return e.invert=Rr(-t),e}function Nr(t,e){var n=Math.cos(t),r=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*n+l*r;return[Math.atan2(s*a-u*i,l*n-c*r),Rt(u*a+s*i)]}return o.invert=function(t,e){var o=Math.cos(e),l=Math.cos(t)*o,s=Math.sin(t)*o,c=Math.sin(e),u=c*a-s*i;return[Math.atan2(s*a+c*i,l*n+u*r),Rt(u*n-l*r)]},o}function Ir(t,e){var n=Math.cos(t),r=Math.sin(t);return function(a,i,o,l){var s=o*e;null!=a?(a=Fr(n,a),i=Fr(n,i),(o>0?ai)&&(a+=o*At)):(a=t+o*At,i=t-.5*s);for(var c,u=a;o>0?u>i:u2?t[2]*Ct:0),e.invert=function(e){return(e=t.invert(e[0]*Ct,e[1]*Ct))[0]*=Pt,e[1]*=Pt,e},e},zr.invert=Or,t.geo.circle=function(){var t,e,n=[0,0],r=6;function a(){var t="function"==typeof n?n.apply(this,arguments):n,r=Dr(-t[0]*Ct,-t[1]*Ct,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=r(t,e)),t[0]*=Pt,t[1]*=Pt}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(n=t,a):n},a.angle=function(n){return arguments.length?(e=Ir((t=+n)*Ct,r*Ct),a):t},a.precision=function(n){return arguments.length?(e=Ir(t*Ct,(r=+n)*Ct),a):r},a.angle(90)},t.geo.distance=function(t,e){var n,r=(e[0]-t[0])*Ct,a=t[1]*Ct,i=e[1]*Ct,o=Math.sin(r),l=Math.cos(r),s=Math.sin(a),c=Math.cos(a),u=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((n=f*o)*n+(n=c*u-s*f*l)*n),s*u+c*f*l)},t.geo.graticule=function(){var e,n,r,a,i,o,l,s,c,u,f,d,p=10,h=p,g=90,v=360,y=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(a/g)*g,r,g).map(f).concat(t.range(Math.ceil(s/v)*v,l,v).map(d)).concat(t.range(Math.ceil(n/p)*p,e,p).filter(function(t){return m(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/h)*h,i,h).filter(function(t){return m(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(d(l).slice(1),f(r).reverse().slice(1),d(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(a=+t[0][0],r=+t[1][0],s=+t[0][1],l=+t[1][1],a>r&&(t=a,a=r,r=t),s>l&&(t=s,s=l,l=t),x.precision(y)):[[a,s],[r,l]]},x.minorExtent=function(t){return arguments.length?(n=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],n>e&&(t=n,n=e,e=t),o>i&&(t=o,o=i,i=t),x.precision(y)):[[n,o],[e,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],h=+t[1],x):[p,h]},x.precision=function(t){return arguments.length?(y=+t,c=jr(o,i,90),u=Br(n,e,y),f=jr(s,l,90),d=Br(a,r,y),x):y},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,n,r=Hr,a=qr;function i(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||r.apply(this,arguments),n||a.apply(this,arguments))},i.source=function(t){return arguments.length?(r=t,e="function"==typeof t?null:t,i):r},i.target=function(t){return arguments.length?(a=t,n="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return n=t[0]*Ct,r=t[1]*Ct,a=e[0]*Ct,i=e[1]*Ct,o=Math.cos(r),l=Math.sin(r),s=Math.cos(i),c=Math.sin(i),u=o*Math.cos(n),f=o*Math.sin(n),d=s*Math.cos(a),p=s*Math.sin(a),h=2*Math.asin(Math.sqrt(Nt(i-r)+o*s*Nt(a-n))),g=1/Math.sin(h),(v=h?function(t){var e=Math.sin(t*=h)*g,n=Math.sin(h-t)*g,r=n*u+e*d,a=n*f+e*p,i=n*l+e*c;return[Math.atan2(a,r)*Pt,Math.atan2(i,Math.sqrt(r*r+a*a))*Pt]}:function(){return[n*Pt,r*Pt]}).distance=h,v;var n,r,a,i,o,l,s,c,u,f,d,p,h,g,v},t.geo.length=function(e){return mr=0,t.geo.stream(e,Ur),mr};var Ur={sphere:E,point:E,lineStart:function(){var t,e,n;function r(r,a){var i=Math.sin(a*=Ct),o=Math.cos(a),l=m((r*=Ct)-t),s=Math.cos(l);mr+=Math.atan2(Math.sqrt((l=o*Math.sin(l))*l+(l=n*i-e*o*s)*l),e*i+n*o*s),t=r,e=i,n=o}Ur.point=function(a,i){t=a*Ct,e=Math.sin(i*=Ct),n=Math.cos(i),Ur.point=r},Ur.lineEnd=function(){Ur.point=Ur.lineEnd=E}},lineEnd:E,polygonStart:E,polygonEnd:E};function Vr(t,e){function n(e,n){var r=Math.cos(e),a=Math.cos(n),i=t(r*a);return[i*a*Math.sin(e),i*Math.sin(n)]}return n.invert=function(t,n){var r=Math.sqrt(t*t+n*n),a=e(r),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,r*o),Math.asin(r&&n*i/r)]},n}var Gr=Vr(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sr(Gr)}).raw=Gr;var Yr=Vr(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},O);function Zr(t,e){var n=Math.cos(t),r=function(t){return Math.tan(Tt/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(r(e)/r(t)),i=n*Math.pow(r(t),a)/a;if(!a)return Jr;function o(t,e){i>0?e<-St+kt&&(e=-St+kt):e>St-kt&&(e=St-kt);var n=i/Math.pow(r(e),a);return[n*Math.sin(a*t),i-n*Math.cos(a*t)]}return o.invert=function(t,e){var n=i-e,r=Ot(a)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/a,2*Math.atan(Math.pow(i/r,1/a))-St]},o}function Xr(t,e){var n=Math.cos(t),r=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/r+t;if(m(r)1&&zt(t[n[r-2]],t[n[r-1]],t[a])<=0;)--r;n[r++]=a}return n.slice(0,r)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sr(Kr)}).raw=Kr,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=$r(ta),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):[(t=n())[0],t[1],t[2]-90]},n([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,n=na;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,a=ve(e),i=ve(n),o=t.length,l=[],s=[];for(r=0;r=0;--r)p.push(t[l[c[r]][2]]);for(r=+f;rkt)l=l.L;else{if(!((a=i-wa(l,o))>kt)){r>-kt?(e=l.P,n=l):a>-kt?(e=l,n=l.N):e=n=l;break}if(!l.R){e=l;break}l=l.R}var s=ya(t);if(fa.insert(e,s),e||n){if(e===n)return La(e),n=ya(e.site),fa.insert(s,n),s.edge=n.edge=Pa(e.site,s.site),Aa(e),void Aa(n);if(n){La(e),La(n);var c=e.site,u=c.x,f=c.y,d=t.x-u,p=t.y-f,h=n.site,g=h.x-u,v=h.y-f,y=2*(d*v-p*g),m=d*d+p*p,x=g*g+v*v,b={x:(v*m-p*x)/y+u,y:(d*x-g*m)/y+f};Oa(n.edge,c,h,b),s.edge=Pa(c,t,null,b),n.edge=Pa(t,h,null,b),Aa(e),Aa(n)}else s.edge=Pa(e.site,s.site)}}function _a(t,e){var n=t.site,r=n.x,a=n.y,i=a-e;if(!i)return r;var o=t.P;if(!o)return-1/0;var l=(n=o.site).x,s=n.y,c=s-e;if(!c)return l;var u=l-r,f=1/i-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-i/2)))/f+r:(r+l)/2}function wa(t,e){var n=t.N;if(n)return _a(n,e);var r=t.site;return r.y===e?r.x:1/0}function ka(t){this.site=t,this.edges=[]}function Ma(t,e){return e.angle-t.angle}function Ta(){Ra(this),this.x=this.y=this.arc=this.site=this.cy=null}function Aa(t){var e=t.P,n=t.N;if(e&&n){var r=e.site,a=t.site,i=n.site;if(r!==i){var o=a.x,l=a.y,s=r.x-o,c=r.y-l,u=i.x-o,f=2*(s*(v=i.y-l)-c*u);if(!(f>=-Mt)){var d=s*s+c*c,p=u*u+v*v,h=(v*d-c*p)/f,g=(s*p-u*d)/f,v=g+l,y=ga.pop()||new Ta;y.arc=t,y.site=a,y.x=h+o,y.y=v+Math.sqrt(h*h+g*g),y.cy=v,t.circle=y;for(var m=null,x=pa._;x;)if(y.y=l)return;if(d>h){if(i){if(i.y>=c)return}else i={x:v,y:s};n={x:v,y:c}}else{if(i){if(i.y1)if(d>h){if(i){if(i.y>=c)return}else i={x:(s-a)/r,y:s};n={x:(c-a)/r,y:c}}else{if(i){if(i.y=l)return}else i={x:o,y:r*o+a};n={x:l,y:r*l+a}}else{if(i){if(i.xkt||m(a-n)>kt)&&(l.splice(o,0,new za((y=i.site,x=u,b=m(r-f)kt?{x:f,y:m(e-f)kt?{x:m(n-h)kt?{x:d,y:m(e-d)kt?{x:m(n-p)=n&&c.x<=a&&c.y>=r&&c.y<=o?[[n,o],[a,o],[a,r],[n,r]]:[]).point=t[l]}),e}function l(t){return t.map(function(t,e){return{x:Math.round(r(t,e)/kt)*kt,y:Math.round(a(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Fa(l(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fa(l(t)).cells.forEach(function(n,r){for(var a,i,o,l,s=n.site,c=n.edges.sort(Ma),u=-1,f=c.length,d=c[f-1].edge,p=d.l===s?d.r:d.l;++ui&&(a=e.slice(i,a),l[o]?l[o]+=a:l[++o]=a),(n=n[0])===(r=r[0])?l[o]?l[o]+=r:l[++o]=r:(l[++o]=null,s.push({i:o,x:Ga(n,r)})),i=Xa.lastIndex;return ig&&(g=s.x),s.y>v&&(v=s.y),c.push(s.x),u.push(s.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-h;function M(t,e,n,r,a,i,o,l){if(!isNaN(n)&&!isNaN(r))if(t.leaf){var s=t.x,c=t.y;if(null!=s)if(m(s-n)+m(c-r)<.01)T(t,e,n,r,a,i,o,l);else{var u=t.point;t.x=t.y=t.point=null,T(t,u,s,c,a,i,o,l),T(t,e,n,r,a,i,o,l)}else t.x=n,t.y=r,t.point=e}else T(t,e,n,r,a,i,o,l)}function T(t,e,n,r,a,i,o,l){var s=.5*(a+o),c=.5*(i+l),u=n>=s,f=r>=c,d=f<<1|u;t.leaf=!1,u?a=s:o=s,f?i=c:l=c,M(t=t.nodes[d]||(t.nodes[d]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(A,t,+y(t,++f),+x(t,f),p,h,g,v)}}),e,n,r,a,i,o,l)}w>k?v=h+w:g=p+k;var A={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(A,t,+y(t,++f),+x(t,f),p,h,g,v)}};if(A.visit=function(t){!function t(e,n,r,a,i,o){if(!e(n,r,a,i,o)){var l=.5*(r+i),s=.5*(a+o),c=n.nodes;c[0]&&t(e,c[0],r,a,l,s),c[1]&&t(e,c[1],l,a,i,s),c[2]&&t(e,c[2],r,s,l,o),c[3]&&t(e,c[3],l,s,i,o)}}(t,A,p,h,g,v)},A.find=function(t){return function(t,e,n,r,a,i,o){var l,s=1/0;return function t(c,u,f,d,p){if(!(u>i||f>o||d=_)<<1|e>=b,k=w+4;w=0&&!(r=t.interpolators[a](e,n)););return r}function Ja(t,e){var n,r=[],a=[],i=t.length,o=e.length,l=Math.min(t.length,e.length);for(n=0;n=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function ii(t){return 1-Math.cos(t*St)}function oi(t){return Math.pow(2,10*(t-1))}function li(t){return 1-Math.sqrt(1-t*t)}function si(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ci(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function ui(t){var e,n,r,a=[t.a,t.b],i=[t.c,t.d],o=di(a),l=fi(a,i),s=di(((e=i)[0]+=(r=-l)*(n=a)[0],e[1]+=r*n[1],e))||0;a[0]*i[1]=0?t.slice(0,r):t,i=r>=0?t.slice(r+1):"in";return a=Qa.get(a)||$a,i=Ka.get(i)||O,e=i(a.apply(null,n.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,n){e=t.hcl(e),n=t.hcl(n);var r=e.h,a=e.c,i=e.l,o=n.h-r,l=n.c-a,s=n.l-i;isNaN(l)&&(l=0,a=isNaN(a)?n.c:a);isNaN(o)?(o=0,r=isNaN(r)?n.h:r):o>180?o-=360:o<-180&&(o+=360);return function(t){return Zt(r+o*t,a+l*t,i+s*t)+""}},t.interpolateHsl=function(e,n){e=t.hsl(e),n=t.hsl(n);var r=e.h,a=e.s,i=e.l,o=n.h-r,l=n.s-a,s=n.l-i;isNaN(l)&&(l=0,a=isNaN(a)?n.s:a);isNaN(o)?(o=0,r=isNaN(r)?n.h:r):o>180?o-=360:o<-180&&(o+=360);return function(t){return Vt(r+o*t,a+l*t,i+s*t)+""}},t.interpolateLab=function(e,n){e=t.lab(e),n=t.lab(n);var r=e.l,a=e.a,i=e.b,o=n.l-r,l=n.a-a,s=n.b-i;return function(t){return te(r+o*t,a+l*t,i+s*t)+""}},t.interpolateRound=ci,t.transform=function(e){var n=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){n.setAttribute("transform",t);var e=n.transform.baseVal.consolidate()}return new ui(e?e.matrix:pi)})(e)},ui.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pi={a:1,b:0,c:0,d:1,e:0,f:0};function hi(t){return t.length?t.pop()+",":""}function gi(e,n){var r=[],a=[];return e=t.transform(e),n=t.transform(n),function(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push("translate(",null,",",null,")");r.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&n.push("translate("+e+")")}(e.translate,n.translate,r,a),function(t,e,n,r){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(hi(n)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&n.push(hi(n)+"rotate("+e+")")}(e.rotate,n.rotate,r,a),function(t,e,n,r){t!==e?r.push({i:n.push(hi(n)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&n.push(hi(n)+"skewX("+e+")")}(e.skew,n.skew,r,a),function(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push(hi(n)+"scale(",null,",",null,")");r.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(hi(n)+"scale("+e+")")}(e.scale,n.scale,r,a),e=n=null,function(t){for(var e,n=-1,i=a.length;++n0?r=t:(e.c=null,e.t=NaN,e=null,s.end({type:"end",alpha:r=0})):t>0&&(s.start({type:"start",alpha:r=t}),e=Me(l.tick)),l):r},l.start=function(){var t,e,n,r=y.length,s=m.length,u=c[0],h=c[1];for(t=0;t=0;)n.push(a[r])}function Ci(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(u=c[s]),u.parent=i,u.depth=i.depth+1;n&&(i.value=0),i.children=c}else n&&(i.value=+n.call(r,i,i.depth)||0),delete i.children;return Ci(a,function(e){var r,a;t&&(r=e.children)&&r.sort(t),n&&(a=e.parent)&&(a.value+=e.value)}),l}return r.sort=function(e){return arguments.length?(t=e,r):t},r.children=function(t){return arguments.length?(e=t,r):e},r.value=function(t){return arguments.length?(n=t,r):n},r.revalue=function(t){return n&&(Si(t,function(t){t.children&&(t.value=0)}),Ci(t,function(t){var e;t.children||(t.value=+n.call(r,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},r},t.layout.partition=function(){var e=t.layout.hierarchy(),n=[1,1];function r(t,r){var a=e.call(this,t,r);return function t(e,n,r,a){var i=e.children;if(e.x=n,e.y=e.depth*a,e.dx=r,e.dy=a,i&&(o=i.length)){var o,l,s,c=-1;for(r=e.value?r/e.value:0;++cl&&(l=r),o.push(r)}for(n=0;na&&(r=n,a=e);return r}function Ui(t){return t.reduce(Vi,0)}function Vi(t,e){return t+e[1]}function Gi(t,e){return Yi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Yi(t,e){for(var n=-1,r=+t[0],a=(t[1]-r)/e,i=[];++n<=e;)i[n]=a*n+r;return i}function Zi(e){return[t.min(e),t.max(e)]}function Xi(t,e){return t.value-e.value}function Wi(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function $i(t,e){var n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return.999*a*a>n*n+r*r}function Qi(t){if((e=t.children)&&(s=e.length)){var e,n,r,a,i,o,l,s,c=1/0,u=-1/0,f=1/0,d=-1/0;if(e.forEach(Ki),(n=e[0]).x=-n.r,n.y=0,x(n),s>1&&((r=e[1]).x=r.r,r.y=0,x(r),s>2))for(eo(n,r,a=e[2]),x(a),Wi(n,a),n._pack_prev=a,Wi(a,r),r=n._pack_next,i=3;i0)for(o=-1;++o=f[0]&&s<=f[1]&&((l=c[t.bisect(d,s,1,h)-1]).y+=g,l.push(i[o]));return c}return i.value=function(t){return arguments.length?(n=t,i):n},i.range=function(t){return arguments.length?(r=ve(t),i):r},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Yi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,n=t.layout.hierarchy().sort(Xi),r=0,a=[1,1];function i(t,i){var o=n.call(this,t,i),l=o[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,Ci(l,function(t){t.r=+u(t.value)}),Ci(l,Qi),r){var f=r*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;Ci(l,function(t){t.r+=f}),Ci(l,Qi),Ci(l,function(t){t.r-=f})}return function t(e,n,r,a){var i=e.children;e.x=n+=a*e.x;e.y=r+=a*e.y;e.r*=a;if(i)for(var o=-1,l=i.length;++op.x&&(p=t),t.depth>h.depth&&(h=t)});var g=n(d,p)/2-d.x,v=r[0]/(p.x+n(p,d)/2+g),y=r[1]/(h.depth||1);Si(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*y})}return c}function o(t){var e=t.children,r=t.parent.children,a=t.i?r[t.i-1]:null;if(e.length){!function(t){var e,n=0,r=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+n(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+n(t._,a._));t.parent.A=function(t,e,r){if(e){for(var a,i=t,o=t,l=e,s=i.parent.children[0],c=i.m,u=o.m,f=l.m,d=s.m;l=ao(l),i=ro(i),l&&i;)s=ro(s),(o=ao(o)).a=t,(a=l.z+f-i.z-c+n(l._,i._))>0&&(io(oo(l,t,r),t,a),c+=a,u+=a),f+=l.m,c+=i.m,d+=s.m,u+=o.m;l&&!ao(o)&&(o.t=l,o.m+=f-u),i&&!ro(s)&&(s.t=i,s.m+=c-d,r=t)}return r}(t,a,t.parent.A||r[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=r[0],t.y=t.depth*r[1]}return i.separation=function(t){return arguments.length?(n=t,i):n},i.size=function(t){return arguments.length?(a=null==(r=t)?s:null,i):a?null:r},i.nodeSize=function(t){return arguments.length?(a=null==(r=t)?null:s,i):a?r:null},Li(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),n=no,r=[1,1],a=!1;function i(i,o){var l,s=e.call(this,i,o),c=s[0],u=0;Ci(c,function(e){var r=e.children;r&&r.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(r),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(r)):(e.x=l?u+=n(e,l):0,e.y=0,l=e)});var f=function t(e){var n=e.children;return n&&n.length?t(n[0]):e}(c),d=function t(e){var n,r=e.children;return r&&(n=r.length)?t(r[n-1]):e}(c),p=f.x-n(f,d)/2,h=d.x+n(d,f)/2;return Ci(c,a?function(t){t.x=(t.x-c.x)*r[0],t.y=(c.y-t.y)*r[1]}:function(t){t.x=(t.x-p)/(h-p)*r[0],t.y=(1-(c.y?t.y/c.y:1))*r[1]}),s}return i.separation=function(t){return arguments.length?(n=t,i):n},i.size=function(t){return arguments.length?(a=null==(r=t),i):a?null:r},i.nodeSize=function(t){return arguments.length?(a=null!=(r=t),i):a?r:null},Li(i,e)},t.layout.treemap=function(){var e,n=t.layout.hierarchy(),r=Math.round,a=[1,1],i=null,o=lo,l=!1,s="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var n,r,a=-1,i=t.length;++a0;)l.push(n=c[a-1]),l.area+=n.area,"squarify"!==s||(r=p(l,g))<=d?(c.pop(),d=r):(l.area-=l.pop().area,h(l,g,i,!1),g=Math.min(i.dx,i.dy),l.length=l.area=0,d=1/0);l.length&&(h(l,g,i,!0),l.length=l.area=0),e.forEach(f)}}function d(t){var e=t.children;if(e&&e.length){var n,r=o(t),a=e.slice(),i=[];for(u(a,r.dx*r.dy/t.value),i.area=0;n=a.pop();)i.push(n),i.area+=n.area,null!=n.z&&(h(i,n.z?r.dx:r.dy,r,!a.length),i.length=i.area=0);e.forEach(d)}}function p(t,e){for(var n,r=t.area,a=0,i=1/0,o=-1,l=t.length;++oa&&(a=n));return e*=e,(r*=r)?Math.max(e*a*c/r,r/(e*i*c)):1/0}function h(t,e,n,a){var i,o=-1,l=t.length,s=n.x,c=n.y,u=e?r(t.area/e):0;if(e==n.dx){for((a||u>n.dy)&&(u=n.dy);++on.dx)&&(u=n.dx);++o1);return t+e*n*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var n=t.random.irwinHall(e);return function(){return n()/e}},irwinHall:function(t){return function(){for(var e=0,n=0;n2?vo:fo,l=a?yi:vi;return i=t(e,n,l,r),o=t(n,e,l,Wa),s}function s(t){return i(t)}s.invert=function(t){return o(t)};s.domain=function(t){return arguments.length?(e=t.map(Number),l()):e};s.range=function(t){return arguments.length?(n=t,l()):n};s.rangeRound=function(t){return s.range(t).interpolate(ci)};s.clamp=function(t){return arguments.length?(a=t,l()):a};s.interpolate=function(t){return arguments.length?(r=t,l()):r};s.ticks=function(t){return bo(e,t)};s.tickFormat=function(t,n){return _o(e,t,n)};s.nice=function(t){return mo(e,t),l()};s.copy=function(){return t(e,n,r,a)};return l()}([0,1],[0,1],Wa,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(n,r,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(r)}function l(t){return a?Math.pow(r,t):-Math.pow(r,-t)}function s(t){return n(o(t))}s.invert=function(t){return l(n.invert(t))};s.domain=function(t){return arguments.length?(a=t[0]>=0,n.domain((i=t.map(Number)).map(o)),s):i};s.base=function(t){return arguments.length?(r=+t,n.domain(i.map(o)),s):r};s.nice=function(){var t=po(i.map(o),a?Math:To);return n.domain(t),i=t.map(l),s};s.ticks=function(){var t=co(i),e=[],n=t[0],s=t[1],c=Math.floor(o(n)),u=Math.ceil(o(s)),f=r%1?2:r;if(isFinite(u-c)){if(a){for(;c0;d--)e.push(l(c)*d);for(c=0;e[c]s;u--);e=e.slice(c,u)}return e};s.tickFormat=function(e,n){if(!arguments.length)return Mo;arguments.length<2?n=Mo:"function"!=typeof n&&(n=t.format(n));var a=Math.max(1,r*e/s.ticks().length);return function(t){var e=t/l(Math.round(o(t)));return e*r0?a[t-1]:n[0],tf?0:1;if(c=Lt)return s(c,p)+(l?s(l,1-p):"")+"Z";var h,g,v,y,m,x,b,_,w,k,M,T,A=0,L=0,S=[];if((y=(+o.apply(this,arguments)||0)/2)&&(v=r===zo?Math.sqrt(l*l+c*c):+r.apply(this,arguments),p||(L*=-1),c&&(L=Rt(v/c*Math.sin(y))),l&&(A=Rt(v/l*Math.sin(y)))),c){m=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var C=Math.abs(f-u-2*L)<=Tt?0:1;if(L&&Fo(m,x,b,_)===p^C){var P=(u+f)/2;m=c*Math.cos(P),x=c*Math.sin(P),b=_=null}}else m=x=0;if(l){w=l*Math.cos(f-A),k=l*Math.sin(f-A),M=l*Math.cos(u+A),T=l*Math.sin(u+A);var O=Math.abs(u-f+2*A)<=Tt?0:1;if(A&&Fo(w,k,M,T)===1-p^O){var z=(u+f)/2;w=l*Math.cos(z),k=l*Math.sin(z),M=T=null}}else w=k=0;if(d>kt&&(h=Math.min(Math.abs(c-l)/2,+n.apply(this,arguments)))>.001){g=l0?0:1}function jo(t,e,n,r,a){var i=t[0]-e[0],o=t[1]-e[1],l=(a?r:-r)/Math.sqrt(i*i+o*o),s=l*o,c=-l*i,u=t[0]+s,f=t[1]+c,d=e[0]+s,p=e[1]+c,h=(u+d)/2,g=(f+p)/2,v=d-u,y=p-f,m=v*v+y*y,x=n-r,b=u*p-d*f,_=(y<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-b*b)),w=(b*y-v*_)/m,k=(-b*v-y*_)/m,M=(b*y+v*_)/m,T=(-b*v+y*_)/m,A=w-h,L=k-g,S=M-h,C=T-g;return A*A+L*L>S*S+C*C&&(w=M,k=T),[[w-s,k-c],[w*n/x,k*n/x]]}function Bo(t){var e=ea,n=na,r=Zn,a=qo,i=a.key,o=.7;function l(i){var l,s=[],c=[],u=-1,f=i.length,d=ve(e),p=ve(n);function h(){s.push("M",a(t(c),o))}for(;++u1&&a.push("H",r[0]);return a.join("")},"step-before":Vo,"step-after":Go,basis:Xo,"basis-open":function(t){if(t.length<4)return qo(t);var e,n=[],r=-1,a=t.length,i=[0],o=[0];for(;++r<3;)e=t[r],i.push(e[0]),o.push(e[1]);n.push(Wo(Qo,i)+","+Wo(Qo,o)),--r;for(;++r9&&(a=3*e/Math.sqrt(a),o[l]=a*n,o[l+1]=a*r));l=-1;for(;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+o[l]*o[l])),i.push([a||0,o[l]*a||0]);return i}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Uo(t){return t.join("L")+"Z"}function Vo(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1){l=e[1],i=t[s],s++,r+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-l[0])+","+(i[1]-l[1])+","+i[0]+","+i[1];for(var c=2;cTt)+",1 "+e}function s(t,e,n,r){return"Q 0,0 "+r}return i.radius=function(t){return arguments.length?(n=ve(t),i):n},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(r=ve(t),i):r},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Hr,e=qr,n=al;function r(r,a){var i=t.call(this,r,a),o=e.call(this,r,a),l=(i.y+o.y)/2,s=[i,{x:i.x,y:l},{x:o.x,y:l},o];return"M"+(s=s.map(n))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return r.source=function(e){return arguments.length?(t=ve(e),r):t},r.target=function(t){return arguments.length?(e=ve(t),r):e},r.projection=function(t){return arguments.length?(n=t,r):n},r},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),n=al,r=e.projection;return e.projection=function(t){return arguments.length?r(function(t){return function(){var e=t.apply(this,arguments),n=e[0],r=e[1]-St;return[n*Math.cos(r),n*Math.sin(r)]}}(n=t)):n},e},t.svg.symbol=function(){var t=ol,e=il;function n(n,r){return(sl.get(t.call(this,n,r))||ll)(e.call(this,n,r))}return n.type=function(e){return arguments.length?(t=ve(e),n):t},n.size=function(t){return arguments.length?(e=ve(t),n):e},n};var sl=t.map({circle:ll,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*ul)),n=e*ul;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cl),n=e*cl/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cl),n=e*cl/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});t.svg.symbolTypes=sl.keys();var cl=Math.sqrt(3),ul=Math.tan(30*Ct);Z.transition=function(t){for(var e,n,r=hl||++yl,a=bl(t),i=[],o=gl||{time:Date.now(),ease:ai,delay:0,duration:250},l=-1,s=this.length;++l0;)c[--d].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[r]:delete t[n],1}f||(i=a.time,o=Me(function(t){var e=f.delay;if(o.t=e+i,e<=t)return d(t-e);o.c=d},0,i),f=u[r]={tween:new b,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++u.count)}vl.call=Z.call,vl.empty=Z.empty,vl.node=Z.node,vl.size=Z.size,t.transition=function(e,n){return e&&e.transition?hl?e.transition(n):e:t.selection().transition(e)},t.transition.prototype=vl,vl.select=function(t){var e,n,r,a=this.id,i=this.namespace,o=[];t=X(t);for(var l=-1,s=this.length;++lrect,.s>rect").attr("width",l[1]-l[0])}function g(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function v(){var f,v,y=this,m=t.select(t.event.target),x=r.of(y,arguments),b=t.select(y),_=m.datum(),w=!/^(n|s)$/.test(_)&&a,k=!/^(e|w)$/.test(_)&&i,M=m.classed("extent"),T=xt(y),A=t.mouse(y),L=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(M||(f=null,A[0]-=l[1],A[1]-=s[1],M=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==M&&(A[0]+=l[1],A[1]+=s[1],M=0,F())});if(t.event.changedTouches?L.on("touchmove.brush",P).on("touchend.brush",z):L.on("mousemove.brush",P).on("mouseup.brush",z),b.interrupt().selectAll("*").interrupt(),M)A[0]=l[0]-A[0],A[1]=s[0]-A[1];else if(_){var S=+/w$/.test(_),C=+/^n/.test(_);v=[l[1-S]-A[0],s[1-C]-A[1]],A[0]=l[S],A[1]=s[C]}else t.event.altKey&&(f=A.slice());function P(){var e=t.mouse(y),n=!1;v&&(e[0]+=v[0],e[1]+=v[1]),M||(t.event.altKey?(f||(f=[(l[0]+l[1])/2,(s[0]+s[1])/2]),A[0]=l[+(e[0]1?{floor:function(e){for(;l(e=t.floor(e));)e=Dl(e-1);return e},ceil:function(e){for(;l(e=t.ceil(e));)e=Dl(+e+1);return e}}:t))},a.ticks=function(t,e){var n=co(a.domain()),r=null==t?i(n,10):"number"==typeof t?i(n,t):!t.range&&[{range:t},e];return r&&(t=r[0],e=r[1]),t.range(n[0],Dl(+n[1]+1),e<1?1:e)},a.tickFormat=function(){return r},a.copy=function(){return zl(e.copy(),n,r)},yo(a,e)}function Dl(t){return new Date(t)}Sl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ol:Pl,Ol.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Ol.toString=Pl.toString,De.second=Ie(function(t){return new Re(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),De.seconds=De.second.range,De.seconds.utc=De.second.utc.range,De.minute=Ie(function(t){return new Re(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),De.minutes=De.minute.range,De.minutes.utc=De.minute.utc.range,De.hour=Ie(function(t){var e=t.getTimezoneOffset()/60;return new Re(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),De.hours=De.hour.range,De.hours.utc=De.hour.utc.range,De.month=Ie(function(t){return(t=De.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),De.months=De.month.range,De.months.utc=De.month.utc.range;var Rl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],El=[[De.second,1],[De.second,5],[De.second,15],[De.second,30],[De.minute,1],[De.minute,5],[De.minute,15],[De.minute,30],[De.hour,1],[De.hour,3],[De.hour,6],[De.hour,12],[De.day,1],[De.day,2],[De.week,1],[De.month,1],[De.month,3],[De.year,1]],Nl=Sl.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Zn]]),Il={range:function(e,n,r){return t.range(Math.ceil(e/r)*r,+n,r).map(Dl)},floor:O,ceil:O};El.year=De.year,De.scale=function(){return zl(t.scale.linear(),El,Nl)};var Fl=El.map(function(t){return[t[0].utc,t[1]]}),jl=Cl.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Zn]]);function Bl(t){return JSON.parse(t.responseText)}function Hl(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Fl.year=De.year.utc,De.scale.utc=function(){return zl(t.scale.linear(),Fl,jl)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return me(t,"application/json",Bl,e)},t.html=function(t,e){return me(t,"text/html",Hl,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],10:[function(t,e,n){(function(r,a){!function(t,r){"object"==typeof n&&"undefined"!=typeof e?e.exports=r():t.ES6Promise=r()}(this,function(){"use strict";function e(t){return"function"==typeof t}var n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,l=void 0,s=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(l?l(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,d="undefined"==typeof self&&"undefined"!=typeof r&&"[object process]"==={}.toString.call(r),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],17:[function(t,e,n){var r={left:0,top:0};e.exports=function(t,e,n){e=e||t.currentTarget||t.srcElement,Array.isArray(n)||(n=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(l=e,l===window||l===document||l===document.body?r:l.getBoundingClientRect());var l;return n[0]=a-o.left,n[1]=i-o.top,n}},{}],18:[function(t,e,n){var r,a=t("./lib/build-log"),i=t("./lib/epsilon"),o=t("./lib/intersecter"),l=t("./lib/segment-chainer"),s=t("./lib/segment-selector"),c=t("./lib/geojson"),u=!1,f=i();function d(t,e,n){var a=r.segments(t),i=r.segments(e),o=n(r.combine(a,i));return r.polygon(o)}r={buildLog:function(t){return!0===t?u=a():!1===t&&(u=!1),!1!==u&&u.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,u);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,u).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:s.union(t.combined,u),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:s.intersect(t.combined,u),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:s.difference(t.combined,u),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:s.differenceRev(t.combined,u),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:s.xor(t.combined,u),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:l(t.segments,f,u),inverted:t.inverted}},polygonFromGeoJSON:function(t){return c.toPolygon(r,t)},polygonToGeoJSON:function(t){return c.fromPolygon(r,f,t)},union:function(t,e){return d(t,e,r.selectUnion)},intersect:function(t,e){return d(t,e,r.selectIntersect)},difference:function(t,e){return d(t,e,r.selectDifference)},differenceRev:function(t,e){return d(t,e,r.selectDifferenceRev)},xor:function(t,e){return d(t,e,r.selectXor)}},"object"==typeof window&&(window.PolyBool=r),e.exports=r},{"./lib/build-log":19,"./lib/epsilon":20,"./lib/geojson":21,"./lib/intersecter":22,"./lib/segment-chainer":24,"./lib/segment-selector":25}],19:[function(t,e,n){e.exports=function(){var t,e=0,n=!1;function r(e,n){return t.list.push({type:e,data:n?JSON.parse(JSON.stringify(n)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return r("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return r("div_seg",{seg:t,pt:e}),r("chop",{seg:t,pt:e})},statusRemove:function(t){return r("pop_seg",{seg:t})},segmentUpdate:function(t){return r("seg_update",{seg:t})},segmentNew:function(t,e){return r("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return r("rem_seg",{seg:t})},tempStatus:function(t,e,n){return r("temp_status",{seg:t,above:e,below:n})},rewind:function(t){return r("rewind",{seg:t})},status:function(t,e,n){return r("status",{seg:t,above:e,below:n})},vert:function(e){return e===n?t:(n=e,r("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),r("log",{txt:t})},reset:function(){return r("reset")},selected:function(t){return r("selected",{segs:t})},chainStart:function(t){return r("chain_start",{seg:t})},chainRemoveHead:function(t,e){return r("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return r("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return r("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return r("chain_match",{index:t})},chainClose:function(t){return r("chain_close",{index:t})},chainAddHead:function(t,e){return r("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return r("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return r("chain_con",{index1:t,index2:e})},chainReverse:function(t){return r("chain_rev",{index:t})},chainJoin:function(t,e){return r("chain_join",{index1:t,index2:e})},done:function(){return r("done")}}}},{}],20:[function(t,e,n){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,n,r){var a=n[0],i=n[1],o=r[0],l=r[1],s=e[0];return(o-a)*(e[1]-i)-(l-i)*(s-a)>=-t},pointBetween:function(e,n,r){var a=e[1]-n[1],i=r[0]-n[0],o=e[0]-n[0],l=r[1]-n[1],s=o*i+a*l;return!(s-t)},pointsSameX:function(e,n){return Math.abs(e[0]-n[0])t!=o-a>t&&(i-c)*(a-u)/(o-u)+c-r>t&&(l=!l),i=c,o=u}return l}};return e}},{}],21:[function(t,e,n){var r={toPolygon:function(t,e){function n(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function n(e){var n=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[n]})}for(var r=n(e[0]),a=1;a0})}function u(t,r){var a=t.seg,i=r.seg,o=a.start,l=a.end,c=i.start,u=i.end;n&&n.checkIntersection(a,i);var f=e.linesIntersect(o,l,c,u);if(!1===f){if(!e.pointsCollinear(o,l,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(l,c))return!1;var d=e.pointsSame(o,c),p=e.pointsSame(l,u);if(d&&p)return r;var h=!d&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(l,c,u);if(d)return g?s(r,l):s(t,u),r;h&&(p||(g?s(r,l):s(t,u)),s(r,o))}else 0===f.alongA&&(-1===f.alongB?s(t,c):0===f.alongB?s(t,f.pt):1===f.alongB&&s(t,u)),0===f.alongB&&(-1===f.alongA?s(r,o):0===f.alongA?s(r,f.pt):1===f.alongA&&s(r,l));return!1}for(var f=[];!i.isEmpty();){var d=i.getHead();if(n&&n.vert(d.pt[0]),d.isStart){n&&n.segmentNew(d.seg,d.primary);var p=c(d),h=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(h){var t=u(d,h);if(t)return t}return!!g&&u(d,g)}n&&n.tempStatus(d.seg,!!h&&h.seg,!!g&&g.seg);var y,m,x=v();if(x)t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=d.seg.myFill,n&&n.segmentUpdate(x.seg),d.other.remove(),d.remove();if(i.getHead()!==d){n&&n.rewind(d.seg);continue}t?(m=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=g?g.seg.myFill.above:a,d.seg.myFill.above=m?!d.seg.myFill.below:d.seg.myFill.below):null===d.seg.otherFill&&(y=g?d.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:d.primary?o:a,d.seg.otherFill={above:y,below:y}),n&&n.status(d.seg,!!h&&h.seg,!!g&&g.seg),d.other.status=p.insert(r.node({ev:d}))}else{var b=d.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(l.exists(b.prev)&&l.exists(b.next)&&u(b.prev.ev,b.next.ev),n&&n.statusRemove(b.ev.seg),b.remove(),!d.primary){var _=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=_}f.push(d.seg)}i.getHead().remove()}return n&&n.done(),f}return t?{addRegion:function(t){for(var r,a,i,o=t[t.length-1],s=0;s1)for(var n=1;n1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}if(t=P(t,360),e=P(e,100),n=P(n,100),0===e)r=a=i=n;else{var l=n<.5?n*(1+e):n+e-n*e,s=2*n-l;r=o(s,l,t+1/3),a=o(s,l,t),i=o(s,l,t-1/3)}return{r:255*r,g:255*a,b:255*i}}(e.h,s,u),f=!0,d="hsl"),e.hasOwnProperty("a")&&(i=e.a));var p,h,g;return i=C(i),{ok:f,format:e.format||d,r:o(255,l(a.r,0)),g:o(255,l(a.g,0)),b:o(255,l(a.b,0)),a:i}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=i(100*this._a)/100,this._format=s.format||u.format,this._gradientType=s.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=u.ok,this._tc_id=a++}function u(t,e,n){t=P(t,255),e=P(e,255),n=P(n,255);var r,a,i=l(t,e,n),s=o(t,e,n),c=(i+s)/2;if(i==s)r=a=0;else{var u=i-s;switch(a=c>.5?u/(2-i-s):u/(i+s),i){case t:r=(e-n)/u+(e>1)+720)%360;--e;)r.h=(r.h+a)%360,i.push(c(r));return i}function A(t,e){e=e||6;for(var n=c(t).toHsv(),r=n.h,a=n.s,i=n.v,o=[],l=1/e;e--;)o.push(c({h:r,s:a,v:i})),i=(i+l)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,n,r,a=this.toRgb();return e=a.r/255,n=a.g/255,r=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))},setAlpha:function(t){return this._a=C(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),n=i(100*t.s),r=i(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=i(360*t.h),n=i(100*t.s),r=i(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return d(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,n,r,a){var o=[D(i(t).toString(16)),D(i(e).toString(16)),D(i(n).toString(16)),D(E(r))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*P(this._r,255))+"%",g:i(100*P(this._g,255))+"%",b:i(100*P(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*P(this._r,255))+"%, "+i(100*P(this._g,255))+"%, "+i(100*P(this._b,255))+"%)":"rgba("+i(100*P(this._r,255))+"%, "+i(100*P(this._g,255))+"%, "+i(100*P(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[d(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),n=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var a=c(t);n="#"+p(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0;return e||!r||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(T,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(M,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]="a"===r?t[r]:R(t[r]));t=n}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:s(),g:s(),b:s()})},c.mix=function(t,e,n){n=0===n?0:n||50;var r=c(t).toRgb(),a=c(e).toRgb(),i=n/100;return c({r:(a.r-r.r)*i+r.r,g:(a.g-r.g)*i+r.g,b:(a.b-r.b)*i+r.b,a:(a.a-r.a)*i+r.a})},c.readability=function(e,n){var r=c(e),a=c(n);return(t.max(r.getLuminance(),a.getLuminance())+.05)/(t.min(r.getLuminance(),a.getLuminance())+.05)},c.isReadable=function(t,e,n){var r,a,i=c.readability(t,e);switch(a=!1,(r=function(t){var e,n;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==n&&"large"!==n&&(n="small");return{level:e,size:n}}(n)).level+r.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},c.mostReadable=function(t,e,n){var r,a,i,o,l=null,s=0;a=(n=n||{}).includeFallbackColors,i=n.level,o=n.size;for(var u=0;us&&(s=r,l=c(e[u]));return c.isReadable(t,l,{level:i,size:o})||!a?l:(n.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],n))};var L=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=c.hexNames=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}(L);function C(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function P(e,n){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(n,l(0,parseFloat(e))),r&&(e=parseInt(e*n,10)/100),t.abs(e-n)<1e-6?1:e%n/parseFloat(n)}function O(t){return o(1,l(0,t))}function z(t){return parseInt(t,16)}function D(t){return 1==t.length?"0"+t:""+t}function R(t){return t<=1&&(t=100*t+"%"),t}function E(e){return t.round(255*parseFloat(e)).toString(16)}function N(t){return z(t)/255}var I,F,j,B=(F="[\\s|\\(]+("+(I="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",j="[\\s|\\(]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")[,|\\s]+("+I+")\\s*\\)?",{CSS_UNIT:new RegExp(I),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+j),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+j),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+j),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function H(t){return!!B.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],28:[function(t,e,n){var r;r=this,function(t){"use strict";var e=function(t){return t},n=function(t){if(null==(n=t.transform))return e;var n,r,a,i=n.scale[0],o=n.scale[1],l=n.translate[0],s=n.translate[1];return function(t,e){return e||(r=a=0),t[0]=(r+=t[0])*i+l,t[1]=(a+=t[1])*o+s,t}},r=function(t){var e=t.bbox;function r(t){s[0]=t[0],s[1]=t[1],l(s),s[0]f&&(f=s[0]),s[1]d&&(d=s[1])}function a(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(a);break;case"Point":r(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(r)}}if(!e){var i,o,l=n(t),s=new Array(2),c=1/0,u=c,f=-c,d=-c;for(o in t.arcs.forEach(function(t){for(var e=-1,n=t.length;++ef&&(f=s[0]),s[1]d&&(d=s[1])}),t.objects)a(t.objects[o]);e=t.bbox=[c,u,f,d]}return e},a=function(t,e){for(var n,r=t.length,a=r-e;a<--r;)n=t[a],t[a++]=t[r],t[r]=n};function i(t,e){var n=e.id,r=e.bbox,a=null==e.properties?{}:e.properties,i=o(t,e);return null==n&&null==r?{type:"Feature",properties:a,geometry:i}:null==r?{type:"Feature",id:n,properties:a,geometry:i}:{type:"Feature",id:n,bbox:r,properties:a,geometry:i}}function o(t,e){var r=n(t),i=t.arcs;function o(t,e){e.length&&e.pop();for(var n=i[t<0?~t:t],o=0,l=n.length;o1)r=function(t,e,n){var r,a=[],i=[];function o(t){var e=t<0?~t:t;(i[e]||(i[e]=[])).push({i:t,g:r})}function l(t){t.forEach(o)}function s(t){t.forEach(l)}return function t(e){switch(r=e,e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"LineString":l(e.arcs);break;case"MultiLineString":case"Polygon":s(e.arcs);break;case"MultiPolygon":e.arcs.forEach(s)}}(e),i.forEach(null==n?function(t){a.push(t[0].i)}:function(t){n(t[0].g,t[t.length-1].g)&&a.push(t[0].i)}),a}(0,e,n);else for(a=0,r=new Array(i=t.arcs.length);a1)for(var i,o,c=1,u=s(a[0]);cu&&(o=a[0],a[0]=a[c],a[c]=o,u=i);return a})}}var u=function(t,e){for(var n=0,r=t.length;n>>1;t[a]=2))throw new Error("n must be \u22652");if(t.transform)throw new Error("already quantized");var n,a=r(t),i=a[0],o=(a[2]-i)/(e-1)||1,l=a[1],s=(a[3]-l)/(e-1)||1;function c(t){t[0]=Math.round((t[0]-i)/o),t[1]=Math.round((t[1]-l)/s)}function u(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(u);break;case"Point":c(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(c)}}for(n in t.arcs.forEach(function(t){for(var e,n,r,a=1,c=1,u=t.length,f=t[0],d=f[0]=Math.round((f[0]-i)/o),p=f[1]=Math.round((f[1]-l)/s);a0||n.explicitOff.length>0},onClick:function(t,e){var n,l,s=o(t,e),c=s.on,u=s.off.concat(s.explicitOff),f={},d=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(n=0;n2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var U=!1,V=["x","y"],G=0;G1)&&(K===Q?((st=tt.r2fraction(e["a"+$]))<0||st>1)&&(U=!0):U=!0),Y=tt._offset+tt.r2p(e[$]),W=.5}else"x"===$?(X=e[$],Y=b.l+b.w*X):(X=1-e[$],Y=b.t+b.h*X),W=e.showarrow?.5:X;if(e.showarrow){lt.head=Y;var ct=e["a"+$];J=nt*q(.5,e.xanchor)-rt*q(.5,e.yanchor),K===Q?(lt.tail=tt._offset+tt.r2p(ct),Z=J):(lt.tail=Y+ct,Z=J+ct),lt.text=lt.tail+J;var ut=x["x"===$?"width":"height"];if("paper"===Q&&(lt.head=o.constrain(lt.head,1,ut-1)),"pixel"===K){var ft=-Math.max(lt.tail-3,lt.text),dt=Math.min(lt.tail+3,lt.text)-ut;ft>0?(lt.tail+=ft,lt.text+=ft):dt>0&&(lt.tail-=dt,lt.text-=dt)}lt.tail+=ot,lt.head+=ot}else Z=J=at*q(W,it),lt.text=Y+J;lt.text+=ot,J+=ot,Z+=ot,e["_"+$+"padplus"]=at/2+Z,e["_"+$+"padminus"]=at/2-Z,e["_"+$+"size"]=at,e["_"+$+"shift"]=J}if(t._dragging||!U){var pt=0,ht=0;if("left"!==e.align&&(pt=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(ht=(z-m)*("middle"===e.valign?.5:1)),u)r.select("svg").attr({x:N+pt-1,y:N+ht}).call(c.setClipUrl,F?A:null,t);else{var gt=N+ht-h.top,vt=N+pt-h.left;H.call(f.positionText,vt,gt).call(c.setClipUrl,F?A:null,t)}j.select("rect").call(c.setRect,N,N,w,z),I.call(c.setRect,R/2,R/2,E-R,B-R),D.call(c.setTranslate,Math.round(L.x.text-E/2),Math.round(L.y.text-B/2)),P.attr({transform:"rotate("+S+","+L.x.text+","+L.y.text+")"});var yt,mt=function(n,r){C.selectAll(".annotation-arrow-g").remove();var u=L.x.head,f=L.y.head,d=L.x.tail+n,h=L.y.tail+r,y=L.x.text+n,m=L.y.text+r,x=o.rotationXYMatrix(S,y,m),w=o.apply2DTransform(x),A=o.apply2DTransform2(x),O=+I.attr("width"),z=+I.attr("height"),R=y-.5*O,E=R+O,N=m-.5*z,F=N+z,j=[[R,N,R,F],[R,F,E,F],[E,F,E,N],[E,N,R,N]].map(A);if(!j.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){j.forEach(function(t){var e=o.segmentsIntersect(d,h,u,f,t[0],t[1],t[2],t[3]);e&&(d=e.x,h=e.y)});var B=e.arrowwidth,H=e.arrowcolor,q=e.arrowside,U=C.append("g").style({opacity:s.opacity(H)}).classed("annotation-arrow-g",!0),V=U.append("path").attr("d","M"+d+","+h+"L"+u+","+f).style("stroke-width",B+"px").call(s.stroke,s.rgb(H));if(g(V,q,e),_.annotationPosition&&V.node().parentNode&&!i){var G=u,Y=f;if(e.standoff){var Z=Math.sqrt(Math.pow(u-d,2)+Math.pow(f-h,2));G+=e.standoff*(d-u)/Z,Y+=e.standoff*(h-f)/Z}var X,W,J=U.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(d-G)+","+(h-Y),transform:"translate("+G+","+Y+")"}).style("stroke-width",B+6+"px").call(s.stroke,"rgba(0,0,0,0)").call(s.fill,"rgba(0,0,0,0)");p.init({element:J.node(),gd:t,prepFn:function(){var t=c.getTranslate(D);X=t.x,W=t.y,l&&l.autorange&&k(l._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,n){var r=w(X,W),a=r[0]+t,i=r[1]+n;D.call(c.setTranslate,a,i),M("x",l?l.p2r(l.r2p(e.x)+t):e.x+t/b.w),M("y",v?v.p2r(v.r2p(e.y)+n):e.y-n/b.h),e.axref===e.xref&&M("ax",l.p2r(l.r2p(e.ax)+t)),e.ayref===e.yref&&M("ay",v.p2r(v.r2p(e.ay)+n)),U.attr("transform","translate("+t+","+n+")"),P.attr({transform:"rotate("+S+","+a+","+i+")"})},doneFn:function(){a.call("_guiRelayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&mt(0,0),O)p.init({element:D.node(),gd:t,prepFn:function(){yt=P.attr("transform")},moveFn:function(t,n){var r="pointer";if(e.showarrow)e.axref===e.xref?M("ax",l.p2r(l.r2p(e.ax)+t)):M("ax",e.ax+t),e.ayref===e.yref?M("ay",v.p2r(v.r2p(e.ay)+n)):M("ay",e.ay+n),mt(t,n);else{if(i)return;var a,o;if(l)a=l.p2r(l.r2p(e.x)+t);else{var s=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-s/2;a=p.align(c+t/b.w,s,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+n);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-n/b.h,u,0,1,e.yanchor)}M("x",a),M("y",o),l&&v||(r=p.getCursor(l?.5:a,v?.5:o,e.xanchor,e.yanchor))}P.attr({transform:"translate("+t+","+n+")"+yt}),d(D,r)},doneFn:function(){d(D),a.call("_guiRelayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else D.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var n=0;n=0,v=e.indexOf("end")>=0,y=f.backoff*p+n.standoff,m=d.backoff*h+n.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},l={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-l.x,b=o.y-l.y;if(c=(s=Math.atan2(b,x))+Math.PI,y&&m&&y+m>Math.sqrt(x*x+b*b))return void O();if(y){if(y*y>x*x+b*b)return void O();var _=y*Math.cos(s),w=y*Math.sin(s);l.x+=_,l.y+=w,t.attr({x2:l.x,y2:l.y})}if(m){if(m*m>x*x+b*b)return void O();var k=m*Math.cos(s),M=m*Math.sin(s);o.x-=k,o.y-=M,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var T=u.getTotalLength(),A="";if(T1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+l+'"]').remove():(s._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(s.x)*n[0],e.yaxis.r2l(s.y)*n[1],e.zaxis.r2l(s.z)*n[2]]),r(t.graphDiv,s,l,t.id,s._xa,s._ya))}}},{"../../plots/gl3d/project":246,"../annotations/draw":36}],43:[function(t,e,n){"use strict";var r=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var n=r.subplotsRegistry.gl3d;if(!n)return;for(var i=n.attrRegex,o=Object.keys(t),l=0;l=0))return t;if(3===o)r[o]>1&&(r[o]=1);else if(r[o]>=1)return t}var l=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return i?"rgba("+l+", "+r[3]+")":"rgb("+l+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(r(t))},i.opacity=function(t){return t?r(t).getAlpha():0},i.addOpacity=function(t,e){var n=r(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},i.combine=function(t,e){var n=r(t).toRgb();if(1===n.a)return r(t).toRgbString();var a=r(e||s).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-n.a)+n.r*n.a,g:i.g*(1-n.a)+n.g*n.a,b:i.b*(1-n.a)+n.b*n.a};return r(o).toRgbString()},i.contrast=function(t,e,n){var a=r(t);return 1!==a.getAlpha()&&(a=r(i.combine(t,s))),(a.isDark()?e?a.lighten(e):s:n?a.darken(n):l).toString()},i.stroke=function(t,e){var n=r(e);t.style({stroke:i.tinyRGB(n),"stroke-opacity":n.getAlpha()})},i.fill=function(t,e){var n=r(e);t.style({fill:i.tinyRGB(n),"fill-opacity":n.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,n,r,a,o=Object.keys(t);for(e=0;e0?S>=E:S<=E));C++)S>I&&S0?S>=E:S<=E));C++)S>P[0]&&S1){var ot=Math.pow(10,Math.floor(Math.log(it)/Math.LN10));rt*=ot*c.roundUp(it/ot,[2,5,10]),(Math.abs(n.levels.start)/n.levels.size+1e-6)%1<2e-6&&(et.tick0=0)}et.dtick=rt}et.domain=[$+X,$+G-X],et.setScale();var lt=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(M.colorbar,!0).each(function(){var t=r.select(this);t.append("rect").classed(M.cbbg,!0),t.append("g").classed(M.cbfills,!0),t.append("g").classed(M.cblines,!0),t.append("g").classed(M.cbaxis,!0).classed(M.crisp,!0),t.append("g").classed(M.cbtitleunshift,!0).append("g").classed(M.cbtitle,!0),t.append("rect").classed(M.cboutline,!0),t.select(".cbtitle").datum(0)})});lt.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var st=lt.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")"),ct=lt.select(".cbaxis"),ut=0;if(-1!==["top","bottom"].indexOf(n.title.side)){var ft,dt=k.l+(n.x+Y)*k.w,pt=et.title.font.size;ft="top"===n.title.side?(1-($+G-X))*k.h+k.t+3+.75*pt:(1-($+X))*k.h+k.t-3-.25*pt,xt(et._id+"title",{attributes:{x:dt,y:ft,"text-anchor":"start"}})}var ht,gt,vt,yt=c.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(n.title.side)){var i=lt.select(".cbtitle"),o=i.select("text"),s=[-n.outlinewidth/2,n.outlinewidth/2],u=i.select(".h"+et._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),u?(ut=d.bBox(u).height)>f&&(s[1]-=(ut-f)/2):o.node()&&!o.classed(M.jsPlaceholder)&&(ut=d.bBox(o.node()).height),ut){if(ut+=5,"top"===n.title.side)et.domain[1]-=ut/k.h,s[1]*=-1;else{et.domain[0]+=ut/k.h;var p=g.lineCount(o);s[1]+=(1-p)*f}i.attr("transform","translate("+s+")"),et.setScale()}}lt.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-et.domain[1]))+")"),ct.attr("transform","translate(0,"+Math.round(-k.t)+")");var h=lt.select(".cbfills").selectAll("rect.cbfill").data(z);h.enter().append("rect").classed(M.cbfill,!0).style("stroke","none"),h.exit().remove();var m=P.map(et.c2p).map(Math.round).sort(function(t,e){return t-e});h.each(function(i,o){var l=[0===o?P[0]:(z[o]+z[o-1])/2,o===z.length-1?P[1]:(z[o]+z[o+1])/2].map(et.c2p).map(Math.round);l[1]=c.constrain(l[1]+(l[1]>l[0])?1:-1,m[0],m[1]);var s=r.select(this).attr({x:W,width:Math.max(q,2),y:r.min(l),height:Math.max(r.max(l)-r.min(l),2)});if(n.fillgradient)d.gradient(s,t,e,"vertical",n.fillgradient,"fill");else{var u=R(i).replace("e-","");s.attr("fill",a(u).toHexString())}});var x=lt.select(".cblines").selectAll("path.cbline").data(n.line.color&&n.line.width?O:[]);return x.enter().append("path").classed(M.cbline,!0),x.exit().remove(),x.each(function(t){r.select(this).attr("d","M"+W+","+(Math.round(et.c2p(t))+n.line.width/2%1)+"h"+q).call(d.lineGroupStyle,n.line.width,D(t),n.line.dash)}),ct.selectAll("g."+et._id+"tick,path").remove(),c.syncOrAsync([function(){var e=W+q+(n.outlinewidth||0)/2-("outside"===n.ticks?1:0),r=l.calcTicks(et),a=l.makeTransFn(et),i=l.makeLabelFns(et,e),o=l.getTickSigns(et)[2];return l.drawTicks(t,et,{vals:"inside"===et.ticks?l.clipEnds(et,r):r,layer:ct,path:l.makeTickPath(et,e,o),transFn:a}),l.drawLabels(t,et,{vals:r,layer:ct,transFn:a,labelXFn:i.labelXFn,labelYFn:i.labelYFn,labelAnchorFn:i.labelAnchorFn})},function(){if(-1===["top","bottom"].indexOf(n.title.side)){var e=et.title.font.size,a=et._offset+et._length/2,i=k.l+(et.position||0)*k.w+("right"===et.side?10+e*(et.showticklabels?1:.5):-10-e*(et.showticklabels?.5:0));xt("h"+et._id+"title",{avoid:{selection:r.select(t).selectAll("g."+et._id+"tick"),side:n.title.side,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var r=q+n.outlinewidth/2+d.bBox(ct.node()).width;if((j=st.select("text")).node()&&!j.classed(M.jsPlaceholder)){var a,o=st.select(".h"+et._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(n.title.side)?d.bBox(o).width:d.bBox(st.node()).right-W-k.l,r=Math.max(r,a)}var l=2*n.xpad+r+n.borderwidth+n.outlinewidth/2,s=Q-K;lt.select(".cbbg").attr({x:W-n.xpad-(n.borderwidth+n.outlinewidth)/2,y:K-Z,width:Math.max(l,2),height:Math.max(s+2*Z,2)}).call(p.fill,n.bgcolor).call(p.stroke,n.bordercolor).style({"stroke-width":n.borderwidth}),lt.selectAll(".cboutline").attr({x:W,y:K+n.ypad+("top"===n.title.side?ut:0),width:Math.max(q,2),height:Math.max(s-2*n.ypad-ut,2)}).call(p.stroke,n.outlinecolor).style({fill:"None","stroke-width":n.outlinewidth});var c=({center:.5,right:1}[n.xanchor]||0)*l;lt.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=m[n.yanchor],h=x[n.yanchor];"pixels"===n.lenmode?(u.y=n.y,u.t=s*f,u.b=s*h):(u.t=u.b=0,u.yt=n.y+n.len*f,u.yb=n.y-n.len*h);var g=m[n.xanchor],v=x[n.xanchor];if("pixels"===n.thicknessmode)u.x=n.x,u.l=l*g,u.r=l*v;else{var y=l-q;u.l=y*g,u.r=y*v,u.xl=n.x-n.thickness*g,u.xr=n.x+n.thickness*v}i.autoMargin(t,e,u)}],t);if(yt&&yt.then&&(t._promises||[]).push(yt),t._context.edits.colorbarPosition)s.init({element:lt.node(),gd:t,prepFn:function(){ht=lt.attr("transform"),f(lt)},moveFn:function(t,e){lt.attr("transform",ht+" translate("+t+","+e+")"),gt=s.align(J+t/k.w,U,0,1,n.xanchor),vt=s.align($-e/k.h,G,0,1,n.yanchor);var r=s.getCursor(gt,vt,n.xanchor,n.yanchor);f(lt,r)},doneFn:function(){if(f(lt),void 0!==gt&&void 0!==vt){var e={};e[L("x")]=gt,e[L("y")]=vt,o.call("_guiRestyle",t,e,A().index)}}});return yt}function mt(t,e){return c.coerce(tt,et,w,t,e)}function xt(e,n){var r={propContainer:et,propName:L("title"),traceIndex:A().index,placeholder:v._dfltTitle.colorbar,containerGroup:lt.select(".cbtitle")},a="h"===e.charAt(0)?e.substr(1):"h"+e;lt.selectAll("."+a+",."+a+"-math-group").remove(),h.draw(t,e,u(r,n||{}))}v._infolayer.selectAll("g."+e).remove()}function A(){var n,r,a=e.substr(2);for(n=0;n=0?a.colorscale.sequential:a.colorscale.sequentialminus,s._colorscale=s.colorscale=h)}},{"../../lib":163}],54:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./helpers").hasColorscale;e.exports=function(t){function e(t,e){var n=t["_"+e];void 0!==n&&(t[e]=n)}function n(t,n){var a=n.container?r.nestedProperty(t,n.container).get():t;if(a){var i=a.zauto||a.cauto,o=n.min,l=n.max;(i||void 0===a[o])&&e(a,o),(i||void 0===a[l])&&e(a,l),a.autocolorscale&&e(a,"colorscale")}}for(var i=0;i=0;r--,a++){var i=t[r];n[a]=[1-i[0],i[1]]}return n}function u(t){var e={r:t[0],g:t[1],b:t[2],a:t[3]};return a(e).toRgbString()}e.exports={hasColorscale:function(t,e){var n=e?o.nestedProperty(t,e).get()||{}:t,r=n.color,a=!1;if(o.isArrayOrTypedArray(r))for(var l=0;l4/3-l?o:l}},{}],62:[function(t,e,n){"use strict";var r=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,i){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:r.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":163}],63:[function(t,e,n){"use strict";var r=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),l=t("../../lib"),s=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function d(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return r(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,n,r,f,h,g,v,y,m=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;m._mouseDownTime||(m._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,n){return Math.abs(t)b&&(x=Math.max(x-1,1)),m._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!y){var n;try{n=new MouseEvent("click",e)}catch(t){var r=p(e);(n=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,r[0],r[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(n)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(m),m._dragged=!1}else m._dragged=!1}},u.coverSlip=d},{"../../constants/interactions":141,"../../lib":163,"../../plots/cartesian/constants":214,"../../registry":257,"./align":61,"./cursor":62,"./unhover":64,"has-hover":13,"has-passive-events":14,"mouse-event-offset":17}],64:[function(t,e,n){"use strict";var r=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),l=e.exports={};l.wrapped=function(t,e,n){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),l.raw(t,e,n)},l.raw=function(t,e){var n=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===r.triggerHandler(t,"plotly_beforehover",e)||(n._hoverlayer.selectAll("g").remove(),n._hoverlayer.selectAll("line").remove(),n._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":154,"../../lib/get_graph_div":161,"../../lib/throttle":185,"../fx/constants":78}],65:[function(t,e,n){"use strict";n.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],66:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,h=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,n,r){c.isPlainObject(e)&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(l.fill,r)},v.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},v.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},v.setRect=function(t,e,n,r,a){t.call(v.setPosition,e,n).call(v.setSize,r,a)},v.translatePoint=function(t,e,n,r){var i=n.c2p(t.x),o=r.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,n){t.each(function(t){var a=r.select(this);v.translatePoint(t,a,e,n)})},v.hideOutsideRangePoint=function(t,e,n,r,a,i){e.attr("display",n.isPtWithinRange(t,a)&&r.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var n=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,l=i.ycalendar,s="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(s).each(function(t){v.hideOutsideRangePoint(t,r.select(this),n,a,o,l)})})}},v.crispRound=function(t,e,n){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):n||0},v.singleLineStyle=function(t,e,n,r,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=n||i.width||0,s=a||i.dash||"";l.stroke(e,r||i.color),v.dashLine(e,s,o)},v.lineGroupStyle=function(t,e,n,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,s=a||i.dash||"";r.select(this).call(l.stroke,n||i.color).call(v.dashLine,s,o)})},v.dashLine=function(t,e,n){n=+n||0,e=v.dashStyle(e,n),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},v.dashStyle=function(t,e){e=+e||1;var n=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=n+"px,"+n+"px":"dash"===t?t=3*n+"px,"+3*n+"px":"longdash"===t?t=5*n+"px,"+5*n+"px":"dashdot"===t?t=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===t&&(t=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t},v.singleFillStyle=function(t){var e=(((r.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(l.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){var e=r.select(this);t[0].trace&&e.call(l.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var m=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var n=t%100;return v.symbolFuncs[n](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=r.format("~.1f"),M={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,n,a,o,s){for(var u=o.length,f=M[a],d=new Array(u),p=0;p=100,e.attr("d",b(u,s))}var f,d,p,h=!1;if(t.so)p=o.outlierwidth,d=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,d="mlc"in t?t.mlcc=r.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?l.defaultLine:o.color,c.isArrayOrTypedArray(i.color)&&(f=l.defaultLine,h=!0),f="mc"in t?t.mcc=r.markerScale(t.mc):i.color||"rgba(0,0,0,0)",r.selectedColorFn&&(f=r.selectedColorFn(t))}if(t.om)e.call(l.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var y=i.gradient,m=t.mgt;if(m?h=!0:m=y&&y.type,Array.isArray(m)&&(m=m[0],M[m]||(m=0)),m&&"none"!==m){var x=t.mgc;x?h=!0:x=y.color;var _=n.uid;h&&(_+="-"+t.i),v.gradient(e,a,_,m,[[0,x],[1,f]],"fill")}else l.fill(e,f);p&&l.stroke(e,d)}},v.makePointStyleFns=function(t){var e={},n=t.marker;return e.markerScale=v.tryColorscale(n,""),e.lineScale=v.tryColorscale(n,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=h.isBubble(t)?g(t):function(){return(n.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},n=t.selected||{},r=t.unselected||{},a=t.marker||{},i=n.marker||{},l=r.marker||{},s=a.opacity,u=i.opacity,f=l.opacity,d=void 0!==u,h=void 0!==f;(c.isArrayOrTypedArray(s)||d||h)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?d?u:e:h?f:p*e});var g=a.color,v=i.color,y=l.color;(v||y)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:y||e});var m=a.size,x=i.size,b=l.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||m/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},n=t.selected||{},r=t.unselected||{},a=t.textfont||{},i=n.textfont||{},o=r.textfont||{},s=a.color,c=i.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||s;return t.selected?c||e:u||(c?e:l.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var n=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];n.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",n.selectedOpacityFn(e))}),n.selectedColorFn&&i.push(function(t,e){l.fill(t,n.selectedColorFn(e))}),n.selectedSizeFn&&i.push(function(t,e){var r=e.mx||a.symbol||0,i=n.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(r),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=r.select(this),n=0;n0?n:0}v.textPointStyle=function(t,e,n){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=r.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var l=t.tp||e.textposition,s=L(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,s,f).text(o).call(u.convertToTspans,n).call(A,l,s,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var n=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=r.select(this),i=n.selectedTextColorFn(t),o=t.tp||e.textposition,s=L(t,e);l.fill(a,i),A(a,o,s,t.mrc2||t.mrc)})}};var S=.5;function C(t,e,n,a){var i=t[0]-e[0],o=t[1]-e[1],l=n[0]-e[0],s=n[1]-e[1],c=Math.pow(i*i+o*o,S/2),u=Math.pow(l*l+s*s,S/2),f=(u*u*i-c*c*l)*a,d=(u*u*o-c*c*s)*a,p=3*u*(c+u),h=3*c*(c+u);return[[r.round(e[0]+(p&&f/p),2),r.round(e[1]+(p&&d/p),2)],[r.round(e[0]-(h&&f/h),2),r.round(e[1]-(h&&d/h),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,r="M"+t[0],a=[];for(n=1;n=1e4&&(v.savedBBoxes={},z=0),n&&(v.savedBBoxes[n]=y),z++,c.extendFlat({},y)},v.setClipUrl=function(t,e,n){if(e){var r=n._context,a=r._exportedPlot?"":r._baseUrl||"";t.attr("clip-path","url("+a+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,n){return[e,n].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,n){var r=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[r]("transform")||"";return e=e||0,n=n||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+n+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,n){return[e,n].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,n){var r=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[r]("transform")||"";return e=e||1,n=n||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+n+")").trim(),t[a]("transform",i),i};var R=/\s*sc.*/;v.setPointGroupScale=function(t,e,n){if(e=e||1,n=n||1,t){var r=1===e&&1===n?"":" scale("+e+","+n+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(R,"");t=(t+=r).trim(),this.setAttribute("transform",t)})}};var E=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,n){t&&t.each(function(){var t,a=r.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),l=parseFloat(i.attr("y")||0),s=(a.attr("transform")||"").match(E);t=1===e&&1===n?[]:["translate("+o+","+l+")","scale("+e+","+n+")","translate("+-o+","+-l+")"],s&&t.push(s),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":140,"../../constants/interactions":141,"../../constants/xmlns_namespaces":143,"../../lib":163,"../../lib/svg_text_utils":184,"../../registry":257,"../../traces/scatter/make_bubble_size_func":296,"../../traces/scatter/subtypes":303,"../color":45,"../colorscale":57,"./symbol_defs":67,d3:9,"fast-isnumeric":11,tinycolor2:27}],67:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+n+a+i+a+i+o+i+o+n+o+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+e+","+r.round(t/2,2)+"H"+e+"L0,-"+r.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+r.round(t/2,2)+"H"+e+"L0,"+r.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M"+r.round(t/2,2)+",-"+e+"V"+e+"L-"+r.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+r.round(t/2,2)+",-"+e+"V"+e+"L"+r.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),a=r.round(-t,2),i=r.round(-.309*t,2);return"M"+e+","+i+"L"+n+","+r.round(.809*t,2)+"H-"+n+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+n+"V"+n+"L0,"+e+"L-"+a+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+a+"H"+n+"L"+e+",0L"+n+",-"+a+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),a=r.round(.951*e,2),i=r.round(.363*e,2),o=r.round(.588*e,2),l=r.round(-e,2),s=r.round(-.309*e,2),c=r.round(.118*e,2),u=r.round(.809*e,2);return"M"+n+","+s+"H"+a+"L"+i+","+c+"L"+o+","+u+"L0,"+r.round(.382*e,2)+"L-"+o+","+u+"L-"+i+","+c+"L-"+a+","+s+"H-"+n+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),a=r.round(.76*t,2);return"M-"+a+",0l-"+n+",-"+e+"h"+a+"l"+n+",-"+e+"l"+n+","+e+"h"+a+"l-"+n+","+e+"l"+n+","+e+"h-"+a+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),i=r.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+n+o+e+","+n+o+"0,-"+a+o+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),i=r.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+n+o+"-"+e+",-"+n+o+"0,"+a+o+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:9}],68:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],69:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function l(t,e,n,a){var l=e["error_"+a]||{},s=[];if(l.visible&&-1!==["linear","log"].indexOf(n.type)){for(var c=o(l),u=0;u0;e.each(function(e){var f,d=e[0].trace,p=d.error_x||{},h=d.error_y||{};d.ids&&(f=function(t){return t.id});var g=o.hasMarkers(d)&&d.marker.maxdisplayed>0;h.visible||p.visible||(e=[]);var v=r.select(this).selectAll("g.errorbar").data(e,f);if(v.exit().remove(),e.length){p.visible||v.selectAll("path.xerror").remove(),h.visible||v.selectAll("path.yerror").remove(),v.style("opacity",1);var y=v.enter().append("g").classed("errorbar",!0);u&&y.style("opacity",0).transition().duration(l.duration).style("opacity",1),i.setClipUrl(v,n.layerClipId,t),v.each(function(t){var e=r.select(this),n=function(t,e,n){var r={x:e.c2p(t.x),y:n.c2p(t.y)};void 0!==t.yh&&(r.yh=n.c2p(t.yh),r.ys=n.c2p(t.ys),a(r.ys)||(r.noYS=!0,r.ys=n.c2p(t.ys,!0)));void 0!==t.xh&&(r.xh=e.c2p(t.xh),r.xs=e.c2p(t.xs),a(r.xs)||(r.noXS=!0,r.xs=e.c2p(t.xs,!0)));return r}(t,s,c);if(!g||t.vis){var i,o=e.select("path.yerror");if(h.visible&&a(n.x)&&a(n.yh)&&a(n.ys)){var f=h.width;i="M"+(n.x-f)+","+n.yh+"h"+2*f+"m-"+f+",0V"+n.ys,n.noYS||(i+="m-"+f+",0h"+2*f),!o.size()?o=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):u&&(o=o.transition().duration(l.duration).ease(l.easing)),o.attr("d",i)}else o.remove();var d=e.select("path.xerror");if(p.visible&&a(n.y)&&a(n.xh)&&a(n.xs)){var v=(p.copy_ystyle?h:p).width;i="M"+n.xh+","+(n.y-v)+"v"+2*v+"m0,-"+v+"H"+n.xs,n.noXS||(i+="m0,-"+v+"v"+2*v),!d.size()?d=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):u&&(d=d.transition().duration(l.duration).ease(l.easing)),d.attr("d",i)}else d.remove()}})}})}},{"../../traces/scatter/subtypes":303,"../drawing":66,d3:9,"fast-isnumeric":11}],74:[function(t,e,n){"use strict";var r=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},i=e.error_x||{},o=r.select(this);o.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(a.stroke,n.color),i.copy_ystyle&&(i=n),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":45,d3:9}],75:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:r({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":235}],76:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../registry");function i(t,e,n,a){a=a||r.identity,Array.isArray(t)&&(e[0][n]=a(t))}e.exports=function(t){var e=t.calcdata,n=t._fullLayout;function o(t){return function(e){return r.coerceHoverinfo({hoverinfo:e},{_module:t._module},n)}}for(var l=0;l=0&&n.indexw[0]._length||et<0||et>k[0]._length)return d.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,E="xval"in e?g.flat(s,e.xval):g.p2c(w,tt),N="yval"in e?g.flat(s,e.yval):g.p2c(k,et),!a(E[0])||!a(N[0]))return o.warn("Fx.hover failed",e,t),d.unhoverRaw(t,e)}var at=1/0;for(F=0;F<$.length;F++)if((j=$[F])&&j[0]&&j[0].trace&&!0===j[0].trace.visible&&(B=j[0].trace,-1===["carpet","contourcarpet"].indexOf(B._module.name))){if("splom"===B.type?H=s[q=0]:(H=g.getSubplot(B),q=s.indexOf(H)),U=R,Y={cd:j,trace:B,xa:w[q],ya:k[q],maxHoverDistance:X,maxSpikeDistance:W,index:!1,distance:Math.min(at,X),spikeDistance:1/0,xSpike:void 0,ySpike:void 0,color:f.defaultLine,name:B.name,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},u[H]&&(Y.subplot=u[H]._subplot),u._splomScenes&&u._splomScenes[B.uid]&&(Y.scene=u._splomScenes[B.uid]),Z=J.length,"array"===U){var it=e[F];"pointNumber"in it?(Y.index=it.pointNumber,U="closest"):(U="","xval"in it&&(V=it.xval,U="x"),"yval"in it&&(G=it.yval,U=U?"closest":"y"))}else V=E[q],G=N[q];if(0!==X)if(B._module&&B._module.hoverPoints){var ot=B._module.hoverPoints(Y,V,G,U,u._hoverlayer);if(ot)for(var lt,st=0;stZ&&(J.splice(0,Z),at=J[0].distance),m&&0!==W&&0===J.length){Y.distance=W,Y.index=!1;var ct=B._module.hoverPoints(Y,V,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=W})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var dt=ft[0];a(dt.x0)&&a(dt.y0)&&(ut=vt(dt),(!Q.vLinePoint||Q.vLinePoint.spikeDistance>ut.spikeDistance)&&(Q.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var ht=pt[0];a(ht.x0)&&a(ht.y0)&&(ut=vt(ht),(!Q.hLinePoint||Q.hLinePoint.spikeDistance>ut.spikeDistance)&&(Q.hLinePoint=ut))}}}}function gt(t,e){for(var n,r=null,a=1/0,i=0;i1||J.length>1)||"closest"===R&&K&&J.length>1,Ot=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),zt={hovermode:R,rotateLabels:Pt,bgColor:Ot,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},Dt=T(J,zt,t);if(function(t,e,n){var r,a,i,o,l,s,c,u=0,f=1,d=t.map(function(t,r){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!r&&o&&o[0]>o[1]!==i&&(f=-1),[{i:r,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?x:1)/2,pmin:0,pmax:i?n.width:n.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],n=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=n.pos+n.dp+n.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;r=!1}if(!(i<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=i;r=!1}if(r){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos>e.pmax-1&&(s.del=!0,c--);for(o=0;o=0;l--)t[l].dp-=i;for(o=t.length-1;o>=0&&!(c<=0);o--)(s=t[o]).pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(;!r&&u<=t.length;){for(u++,r=!0,o=0;o.01&&v.pmin===y.pmin&&v.pmax===y.pmax){for(l=g.length-1;l>=0;l--)g[l].dp+=a;for(h.push.apply(h,g),d.splice(o+1,1),c=0,l=h.length-1;l>=0;l--)c+=h[l].dp;for(i=c/h.length,l=h.length-1;l>=0;l--)h[l].dp-=i;r=!1}else o++}d.forEach(p)}for(o=d.length-1;o>=0;o--){var m=d[o];for(l=m.length-1;l>=0;l--){var b=m[l],_=t[b.i];_.offset=b.dp,_.del=b.del}}}(J,Pt?"xa":"ya",u),A(Dt,Pt),e.target&&e.target.tagName){var Rt=h.getComponentMethod("annotations","hasClickToShow")(t,At);c(r.select(e.target),Rt?"pointer":"")}if(!e.target||i||!function(t,e,n){if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var a=n[r],i=t._hoverdata[r];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber)||String(a.pointNumbers)!==String(i.pointNumbers))return!0}return!1}(t,0,Tt))return;Tt&&t.emit("plotly_unhover",{event:e,points:Tt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:E,yvals:N})}(t,e,n,i)})},n.loneHover=function(t,e){var n={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1},a=r.select(e.container),i=e.outerContainer?r.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=T([n],o,e.gd);return A(l,o.rotateLabels),l.node()},n.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var n=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1}}),a=r.select(e.container),i=e.outerContainer?r.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},l=T(n,o,e.gd),s=0;return l.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5([\s\S]*)<\/extra>/;function T(t,e,n){var a=e.hovermode,i=e.rotateLabels,l=e.bgColor,c=e.container,d=e.outerContainer,p=e.commonLabelOpts||{},h=e.fontFamily||v.HOVERFONT,g=e.fontSize||v.HOVERFONTSIZE,m=t[0],x=m.xa,b=m.ya,_="y"===a?"yLabel":"xLabel",T=m[_],A=(String(T)||"").split(" ")[0],L=d.node().getBoundingClientRect(),S=L.top,C=L.width,P=L.height,O=void 0!==T&&m.distance<=e.hoverdistance&&("x"===a||"y"===a);if(O){var z,D,R=!0;for(z=0;z-1&&c.length>b&&(c=b>3?c.substr(0,b-3)+"...":c.substr(0,b))}void 0!==t.zLabel?(void 0!==t.xLabel&&(d+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(d+="y: "+t.yLabel+"
"),d+=(d?"z: ":"")+t.zLabel):O&&t[a+"Label"]===T?d=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(d=t.yLabel):d=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(d+=(d?"
":"")+t.text),void 0!==t.extraText&&(d+=(d?"
":"")+t.extraText),""===d&&(""===c&&e.remove(),d=c);var _=t.hovertemplate||!1,A=t.hovertemplateLabels||t,L=t.eventData[0]||{};_&&(d=(d=o.hovertemplateString(_,A,L)).replace(M,function(t,e){return c=e,""}));var z=e.select("text.nums").call(u.font,t.fontFamily||h,t.fontSize||g,t.fontColor||x).text(d).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,n),D=e.select("text.name"),R=0;c&&c!==d?(D.call(u.font,t.fontFamily||h,t.fontSize||g,m).text(c).attr("data-notex",1).call(s.positionText,0,0).call(s.convertToTspans,n),R=D.node().getBoundingClientRect().width+2*k):(D.remove(),e.select("rect").remove()),e.select("path").style({fill:v,stroke:x});var E,N,I=z.node().getBoundingClientRect(),F=t.xa._offset+(t.x0+t.x1)/2,j=t.ya._offset+(t.y0+t.y1)/2,B=Math.abs(t.x1-t.x0),H=Math.abs(t.y1-t.y0),q=I.width+w+k+R;t.ty0=S-I.top,t.bx=I.width+2*k,t.by=I.height+2*k,t.anchor="start",t.txwidth=I.width,t.tx2width=R,t.offset=0,i?(t.pos=F,E=j+H/2+q<=P,N=j-H/2-q>=0,"top"!==t.idealAlign&&E||!N?E?(j+=H/2,t.anchor="start"):t.anchor="middle":(j-=H/2,t.anchor="end")):(t.pos=j,E=F+B/2+q<=C,N=F-B/2-q>=0,"left"!==t.idealAlign&&E||!N?E?(F+=B/2,t.anchor="start"):t.anchor="middle":(F-=B/2,t.anchor="end")),z.attr("text-anchor",t.anchor),R&&D.attr("text-anchor",t.anchor),e.attr("transform","translate("+F+","+j+")"+(i?"rotate("+y+")":""))}),I}function A(t,e){t.each(function(t){var n=r.select(this);if(t.del)n.remove();else{var a="end"===t.anchor?-1:1,i=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],l=o*(w+k),c=l+o*(t.txwidth+k),f=0,d=t.offset;"middle"===t.anchor&&(l-=t.tx2width/2,c+=t.txwidth/2+k),e&&(d*=-_,f=t.offset*b),n.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(d-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+d)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(d-w)+"Z"),i.call(s.positionText,l+f,d+t.ty0-t.by/2+k),t.tx2width&&(n.select("text.name").call(s.positionText,c+o*k+f,d+t.ty0-t.by/2+k),n.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,d-t.by/2-1,t.tx2width,t.by+2))}})}function L(t,e){var n=t.index,r=t.trace||{},a=t.cd[0],i=t.cd[n]||{},l=Array.isArray(n)?function(t,e){return o.castOption(a,n,t)||o.extractOption({},r,"",e)}:function(t,e){return o.extractOption(i,r,t,e)};function s(e,n,r){var a=l(n,r);a&&(t[e]=a)}if(s("hoverinfo","hi","hoverinfo"),s("bgcolor","hbg","hoverlabel.bgcolor"),s("borderColor","hbc","hoverlabel.bordercolor"),s("fontFamily","htf","hoverlabel.font.family"),s("fontSize","hts","hoverlabel.font.size"),s("fontColor","htc","hoverlabel.font.color"),s("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return f&&"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function S(t,e){var n,r,a=e.container,o=e.fullLayout,l=e.event,s=!!t.hLinePoint,c=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),c||s){var d=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(s){var p,h,g=t.hLinePoint;n=g&&g.xa,"cursor"===(r=g&&g.ya).spikesnap?(p=l.pointerX,h=l.pointerY):(p=n._offset+g.x,h=r._offset+g.y);var v,y,m=i.readability(g.color,d)<1.5?f.contrast(d):g.color,x=r.spikemode,b=r.spikethickness,_=r.spikecolor||m,w=r._boundingBox,k=(w.left+w.right)/20){for(var r=[],a=0;a-1?o="closest":(e._isHoriz=function(t){for(var e=!0,n=0;n1){d||p||h||"independent"===M("pattern")&&(d=!0),v._hasSubplotGrid=d;var x,b,_="top to bottom"===M("roworder"),w=d?.2:.1,k=d?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",M,w,x,m),y:u("y",M,k,b,y,_)}}else delete e.grid}function M(t,e){return r.coerce(n,v,s,t,e)}},contentDefaults:function(t,e){var n=e.grid;if(n&&n._domains){var r,a,i,o,l,s,u,d=t.grid||{},p=e._subplots,h=n._hasSubplotGrid,g=n.rows,v=n.columns,y="independent"===n.pattern,m=n._axisMap={};if(h){var x=d.subplots||[];s=n.subplots=new Array(g);var b=1;for(r=0;r1);if(!1!==x||p.uirevision){var b=i.newContainer(e,"legend");if(w("uirevision",e.uirevision),!1!==x){if(w("bgcolor",e.paper_bgcolor),w("bordercolor"),w("borderwidth"),a.coerceFont(w,"font",e.font),w("orientation"),"h"===b.orientation){var _=t.xaxis;r.getComponentMethod("rangeslider","isVisible")(_)?(c=0,f="left",u=1.1,d="bottom"):(c=0,f="left",u=-.1,d="top")}w("traceorder",v),s.isGrouped(e.legend)&&w("tracegroupgap"),w("x",c),w("xanchor",f),w("y",u),w("yanchor",d),w("valign"),a.noneOrAll(p,b,["x","y"])}}function w(t,e){return a.coerce(p,b,o,t,e)}}},{"../../lib":163,"../../plot_api/plot_template":198,"../../plots/layout_attributes":247,"../../registry":257,"./attributes":94,"./helpers":100}],97:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib/events"),s=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),d=t("./handle_click"),p=t("./constants"),h=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,y=g.FROM_TL,m=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=h.DBLCLICKDELAY;function k(t,e,n,r,a){var i=n.data()[0][0].trace,o={event:a,node:n.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=n.datum()[0].label),!1!==l.triggerHandler(t,"plotly_legendclick",o))if(1===r)e._clickTimeout=setTimeout(function(){d(n,t,r)},w);else if(2===r){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==l.triggerHandler(t,"plotly_legenddoubleclick",o)&&d(n,t,r)}}function M(t,e,n){var r=t.data()[0][0],i=e._fullLayout,l=r.trace,s=o.traceIs(l,"pie"),u=l.index,d=s?r.label:l.name,h=e._context.edits.legendText&&!s,g=a.ensureSingle(t,"text","legendtext");function y(n){f.convertToTspans(n,e,function(){!function(t,e){var n=t.data()[0][0];if(!n.trace.showlegend)return void t.remove();var r,a,i=t.select("g[class*=math-group]"),o=i.node(),l=e._fullLayout.legend.font.size*v;if(o){var s=c.bBox(o);r=s.height,a=s.width,c.setTranslate(i,0,r/4)}else{var u=t.select(".legendtext"),d=f.lineCount(u),h=u.node();r=l*d,a=h?c.bBox(h).width:0;var g=l*(.3+(1-d)/2);f.positionText(u,p.textOffsetX,g),n.lineHeight=l}r=Math.max(r,16)+3,n.height=r,n.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,i.legend.font).text(h?T(d,n):d),f.positionText(g,p.textOffsetX,0),h?g.call(f.makeEditable,{gd:e,text:d}).call(y).on("edit",function(t){this.text(T(t,n)).call(y);var i=r.trace._fullInput||{},l={};if(o.hasTransform(i,"groupby")){var s=o.getTransformIndices(i,"groupby"),c=s[s.length-1],f=a.keyedContainer(i,"transforms["+c+"].styles","target","value.name");f.set(r.trace._group,t),l=f.constructUpdate()}else l.name=t;return o.call("_guiRestyle",e,l,u)}):y(g)}function T(t,e){var n=Math.max(4,e);if(t&&t.trim().length>=n/2)return t;for(var r=n-(t=t||"").length;r>0;r--)t+=" ";return t}function A(t,e){var n,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(n=(new Date).getTime())-e._legendMouseDownTimew&&(i=Math.max(i-1,1)),k(e,n,t,i,r.event)}})}function L(t,e,n){var a=t._fullLayout,i=a.legend,o=i.borderwidth,l=_.isGrouped(i),s=0;if(i._width=0,i._height=0,_.isVertical(i))l&&e.each(function(t,e){c.setTranslate(this,0,e*i.tracegroupgap)}),n.each(function(t){var e=t[0],n=e.height,r=e.width;c.setTranslate(this,o,5+o+i._height+n/2),i._height+=n,i._width=Math.max(i._width,r)}),i._width+=45+2*o,i._height+=10+2*o,l&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),s=40;else if(l){for(var u=[i._width],f=e.data(),d=0,p=f.length;do+w-k,n.each(function(t){var e=t[0],n=v?40+t[0].width:x;o+b+k+n>a._size.w&&(b=0,y+=m,i._height=i._height+m,m=0),c.setTranslate(this,o+b,5+o+e.height/2+y),i._width+=k+n,i._height=Math.max(i._height,e.height),b+=k+n,m=Math.max(e.height,m)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var M=t._context.edits.legendText||t._context.edits.legendPosition;n.each(function(t){var e=t[0],n=r.select(this).select(".legendtoggle");c.setRect(n,0,-e.height/2,(M?0:i._width)+s,e.height)})}function S(t){var e=t._fullLayout.legend,n="left";a.isRightAnchor(e)?n="right":a.isCenterAnchor(e)&&(n="center");var r="top";a.isBottomAnchor(e)?r="bottom":a.isMiddleAnchor(e)&&(r="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[n],r:e._width*m[n],b:e._height*m[r],t:e._height*y[r]})}e.exports=function(t){var e=t._fullLayout,n="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var l=e.legend,f=e.showlegend&&x(t.calcdata,l),d=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+n).remove(),void i.autoMargin(t,"legend");for(var h=0,g=0;gf?function(t){var e=t._fullLayout.legend,n="left";a.isRightAnchor(e)?n="right":a.isCenterAnchor(e)&&(n="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[n],r:e._width*m[n],b:0,t:0})}(t):S(t);var d=e._size,h=d.l+d.w*l.x,g=d.t+d.h*(1-l.y);a.isRightAnchor(l)?h-=l._width:a.isCenterAnchor(l)&&(h-=l._width/2),a.isBottomAnchor(l)?g-=l._height:a.isMiddleAnchor(l)&&(g-=l._height/2);var v=l._width,x=d.w;v>x?(h=d.l,v=x):(h+v>u&&(h=u-v),h<0&&(h=0),v=Math.min(u-h,l._width));var b,_,w,M,T=l._height,A=d.h;if(T>A?(g=d.t,T=A):(g+T>f&&(g=f-T),g<0&&(g=0),T=Math.min(f-g,l._height)),c.setTranslate(P,h,g),R.on(".drag",null),P.on("wheel",null),l._height<=T||t._context.staticPlot)z.attr({width:v-l.borderwidth,height:T-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),c.setTranslate(D,0,0),O.select("rect").attr({width:v-2*l.borderwidth,height:T-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth}),c.setClipUrl(D,n,t),c.setRect(R,0,0,0,0),delete l._scrollY;else{var I,F,j=Math.max(p.scrollBarMinHeight,T*T/l._height),B=T-j-2*p.scrollBarMargin,H=l._height-T,q=B/H,U=Math.min(l._scrollY||0,H);z.attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:T-l.borderwidth,x:l.borderwidth/2,y:l.borderwidth/2}),O.select("rect").attr({width:v-2*l.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:T-2*l.borderwidth,x:l.borderwidth,y:l.borderwidth+U}),c.setClipUrl(D,n,t),G(U,j,q),P.on("wheel",function(){G(U=a.constrain(l._scrollY+r.event.deltaY/B*H,0,H),j,q),0!==U&&U!==H&&r.event.preventDefault()});var V=r.behavior.drag().on("dragstart",function(){I=r.event.sourceEvent.clientY,F=U}).on("drag",function(){var t=r.event.sourceEvent;2===t.buttons||t.ctrlKey||G(U=a.constrain((t.clientY-I)/q+F,0,H),j,q)});R.call(V)}function G(e,n,r){l._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(D,0,-e),c.setRect(R,v,p.scrollBarMargin+e*r,p.scrollBarWidth,n),O.select("rect").attr({y:l.borderwidth+e})}t._context.edits.legendPosition&&(P.classed("cursor-move",!0),s.init({element:P.node(),gd:t,prepFn:function(){var t=c.getTranslate(P);w=t.x,M=t.y},moveFn:function(t,e){var n=w+t,r=M+e;c.setTranslate(P,n,r),b=s.align(n,0,d.l,d.l+d.w,l.xanchor),_=s.align(r,0,d.t+d.h,d.t,l.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("_guiRelayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(n,r){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return r.clientX>=t.left&&r.clientX<=t.right&&r.clientY>=t.top&&r.clientY<=t.bottom});a.size()>0&&k(t,P,a,n,r)}}))}],t)}}},{"../../constants/alignment":140,"../../constants/interactions":141,"../../lib":163,"../../lib/events":154,"../../lib/svg_text_utils":184,"../../plots/plots":249,"../../registry":257,"../color":45,"../dragelement":63,"../drawing":66,"./constants":95,"./get_legend_data":98,"./handle_click":99,"./helpers":100,"./style":102,d3:9}],98:[function(t,e,n){"use strict";var r=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var n,i,o={},l=[],s=!1,c={},u=0;function f(t,n){if(""!==t&&a.isGrouped(e))-1===l.indexOf(t)?(l.push(t),s=!0,o[t]=[[n]]):o[t].push([n]);else{var r="~~i"+u;l.push(r),o[r]=[[n]],u++}}for(n=0;nn[1])return n[1]}return a}function h(t){return t[0]}if(u||f||d){var g={},v={};if(u){g.mc=p("marker.color",h),g.mx=p("marker.symbol",h),g.mo=p("marker.opacity",i.mean,[.2,1]),g.mlc=p("marker.line.color",h),g.mlw=p("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=p("marker.size",i.mean,[2,16]);g.ms=y,v.marker.size=y}d&&(v.line={width:p("line.width",h,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",h),g.ts=10,g.tc=p("textfont.color",h),g.tf=p("textfont.family",h)),n=[i.minExtend(l,g)],(a=i.minExtend(c,v)).selectedpoints=null}var m=r.select(this).select("g.legendpoints"),x=m.selectAll("path.scatterpts").data(u?n:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,a,e),u&&(n[0].mrc=3);var b=m.selectAll("g.pointtext").data(f?n:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,n=r.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);n.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),n.exit().remove(),n.each(function(t,n){var a=e[n?"increasing":"decreasing"],i=a.line.width,o=r.select(this);o.style("stroke-width",i+"px").call(l.fill,a.fillcolor),i&&l.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,n=r.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);n.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),n.exit().remove(),n.each(function(t,n){var a=e[n?"increasing":"decreasing"],i=a.line.width,s=r.select(this);s.style("fill","none").call(o.dashLine,a.line.dash,i),i&&l.stroke(s,a.line.color)})})}},{"../../lib":163,"../../registry":257,"../../traces/pie/style_one":277,"../../traces/scatter/subtypes":303,"../color":45,"../drawing":66,d3:9}],103:[function(t,e,n){"use strict";var r=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),l=t("../../../build/ploticon"),s=o._,c=e.exports={};function u(t,e){var n,a,o=e.currentTarget,l=o.getAttribute("data-attr"),s=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=i.list(t,null,!0),d="on";if("zoom"===l){var p,h="in"===s?.5:2,g=(1+h)/2,v=(1-h)/2;for(a=0;a1?(k=["toggleHover"],M=["resetViews"]):d?(w=["zoomInGeo","zoomOutGeo"],k=["hoverClosestGeo"],M=["resetGeo"]):f?(k=["hoverClosest3d"],M=["resetCameraDefault3d","resetCameraLastSave3d"]):v?(k=["toggleHover"],M=["resetViewMapbox"]):k=h?["hoverClosestGl2d"]:p?["hoverClosestPie"]:["toggleHover"];u&&(k=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!u&&!h||m||(w=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==M[0]&&(M=["resetScale2d"]));f?T=["zoom3d","pan3d","orbitRotation","tableRotation"]:(u||h)&&!m||g?T=["zoom2d","pan2d"]:v||d?T=["pan2d"]:y&&(T=["zoom2d"]);(function(t){for(var e=!1,n=0;n0)){var g=function(t,e,n){for(var r=n.filter(function(n){return e[n].anchor===t._id}),a=0,i=0;i0?d+c:c;return{ppad:c,ppadplus:u?h:g,ppadminus:u?g:h}}return{ppad:c}}function u(t,e,n,r,a){var l="category"===t.type||"multicategory"===t.type?t.r2c:t.d2c;if(void 0!==e)return[l(e),l(n)];if(r){var s,c,u,f,d=1/0,p=-1/0,h=r.match(i.segmentRE);for("date"===t.type&&(l=o.decodeDate(l)),s=0;sp&&(p=f)));return p>=d?[d,p]:void 0}}e.exports=function(t){var e=t._fullLayout,n=r.filterVisible(e.shapes);if(n.length&&t._fullData.length)for(var o=0;o10?t/2:10;return r.append("circle").attr({"data-line-point":"start-point",cx:E?U(n.xanchor)+n.x0:U(n.x0),cy:N?V(n.yanchor)-n.y0:V(n.y0),r:i}).style(a).classed("cursor-grab",!0),r.append("circle").attr({"data-line-point":"end-point",cx:E?U(n.xanchor)+n.x1:U(n.x1),cy:N?V(n.yanchor)-n.y1:V(n.y1),r:i}).style(a).classed("cursor-grab",!0),r}():e,X={element:Z.node(),gd:t,prepFn:function(r){E&&(_=U(n.xanchor));N&&(w=V(n.yanchor));"path"===n.type?O=n.path:(y=E?n.x0:U(n.x0),m=N?n.y0:V(n.y0),x=E?n.x1:U(n.x1),b=N?n.y1:V(n.y1));yb?(k=m,L="y0",M=b,S="y1"):(k=b,L="y1",M=m,S="y0");W(r),Q(p,n),function(t,e,n){var r=e.xref,a=e.yref,o=i.getFromId(n,r),s=i.getFromId(n,a),c="";"paper"===r||o.autorange||(c+=r);"paper"===a||s.autorange||(c+=a);l.setClipUrl(t,c?"clip"+n._fullLayout._uid+c:null,n)}(e,n,t),X.moveFn="move"===z?J:$},doneFn:function(){u(e),K(p),h(e,t,n),r.call("_guiRelayout",t,j.getUpdateObj())},clickFn:function(){K(p)}};function W(t){if(I)z="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var n=X.element.getBoundingClientRect(),r=n.right-n.left,a=n.bottom-n.top,i=t.clientX-n.left,o=t.clientY-n.top,l=!F&&r>D&&a>R&&!t.shiftKey?c.getCursor(i/r,1-o/a):"move";u(e,l),z=l.split("-")[0]}}function J(r,a){if("path"===n.type){var i=function(t){return t},o=i,l=i;E?B("xanchor",n.xanchor=G(_+r)):(o=function(t){return G(U(t)+r)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?B("yanchor",n.yanchor=Y(w+a)):(l=function(t){return Y(V(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),B("path",n.path=v(O,o,l))}else E?B("xanchor",n.xanchor=G(_+r)):(B("x0",n.x0=G(y+r)),B("x1",n.x1=G(x+r))),N?B("yanchor",n.yanchor=Y(w+a)):(B("y0",n.y0=Y(m+a)),B("y1",n.y1=Y(b+a)));e.attr("d",g(t,n)),Q(p,n)}function $(r,a){if(F){var i=function(t){return t},o=i,l=i;E?B("xanchor",n.xanchor=G(_+r)):(o=function(t){return G(U(t)+r)},H&&"date"===H.type&&(o=d.encodeDate(o))),N?B("yanchor",n.yanchor=Y(w+a)):(l=function(t){return Y(V(t)+a)},q&&"date"===q.type&&(l=d.encodeDate(l))),B("path",n.path=v(O,o,l))}else if(I){if("resize-over-start-point"===z){var s=y+r,c=N?m-a:m+a;B("x0",n.x0=E?s:G(s)),B("y0",n.y0=N?c:Y(c))}else if("resize-over-end-point"===z){var u=x+r,f=N?b-a:b+a;B("x1",n.x1=E?u:G(u)),B("y1",n.y1=N?f:Y(f))}}else{var h=~z.indexOf("n")?k+a:k,j=~z.indexOf("s")?M+a:M,Z=~z.indexOf("w")?T+r:T,X=~z.indexOf("e")?A+r:A;~z.indexOf("n")&&N&&(h=k-a),~z.indexOf("s")&&N&&(j=M-a),(!N&&j-h>R||N&&h-j>R)&&(B(L,n[L]=N?h:Y(h)),B(S,n[S]=N?j:Y(j))),X-Z>D&&(B(C,n[C]=E?Z:G(Z)),B(P,n[P]=E?X:G(X)))}e.attr("d",g(t,n)),Q(p,n)}function Q(t,e){(E||N)&&function(){var n="path"!==e.type,r=t.selectAll(".visual-cue").data([0]);r.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=U(E?e.xanchor:a.midRange(n?[e.x0,e.x1]:d.extractPathCoords(e.path,f.paramIsX))),o=V(N?e.yanchor:a.midRange(n?[e.y0,e.y1]:d.extractPathCoords(e.path,f.paramIsY)));if(i=d.roundPositionForSharpStrokeRendering(i,1),o=d.roundPositionForSharpStrokeRendering(o,1),E&&N){var l="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";r.attr("d",l)}else if(E){var s="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";r.attr("d",s)}else{var c="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";r.attr("d",c)}}()}function K(t){t.selectAll(".visual-cue").remove()}c.init(X),Z.node().onmousemove=W}(t,x,n,e,p)}}function h(t,e,n){var r=(n.xref+n.yref).replace(/paper/g,"");l.setClipUrl(t,r?"clip"+e._fullLayout._uid+r:null,e)}function g(t,e){var n,r,o,l,s,c,u,p,h=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),y=t._fullLayout._size;if(g?(n=d.shapePositionToRange(g),r=function(t){return g._offset+g.r2p(n(t,!0))}):r=function(t){return y.l+y.w*t},v?(o=d.shapePositionToRange(v),l=function(t){return v._offset+v.r2p(o(t,!0))}):l=function(t){return y.t+y.h*(1-t)},"path"===h)return g&&"date"===g.type&&(r=d.decodeDate(r)),v&&"date"===v.type&&(l=d.decodeDate(l)),function(t,e,n){var r=t.path,i=t.xsizemode,o=t.ysizemode,l=t.xanchor,s=t.yanchor;return r.replace(f.segmentRE,function(t){var r=0,c=t.charAt(0),u=f.paramIsX[c],d=f.paramIsY[c],p=f.numParams[c],h=t.substr(1).replace(f.paramRE,function(t){return u[r]?t="pixel"===i?e(l)+Number(t):e(t):d[r]&&(t="pixel"===o?n(s)-Number(t):n(t)),++r>p&&(t="X"),t});return r>p&&(h=h.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),c+h})}(e,r,l);if("pixel"===e.xsizemode){var m=r(e.xanchor);s=m+e.x0,c=m+e.x1}else s=r(e.x0),c=r(e.x1);if("pixel"===e.ysizemode){var x=l(e.yanchor);u=x-e.y0,p=x-e.y1}else u=l(e.y0),p=l(e.y1);if("line"===h)return"M"+s+","+u+"L"+c+","+p;if("rect"===h)return"M"+s+","+u+"H"+c+"V"+p+"H"+s+"Z";var b=(s+c)/2,_=(u+p)/2,w=Math.abs(b-s),k=Math.abs(_-u),M="A"+w+","+k,T=b+w+","+_;return"M"+T+M+" 0 1,1 "+(b+","+(_-k))+M+" 0 0,1 "+T+"Z"}function v(t,e,n){return t.replace(f.segmentRE,function(t){var r=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],l=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return r>=l?t:(i[r]?t=e(t):o[r]&&(t=n(t)),r++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var n in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var r=e._plots[n].shapelayer;r&&r.selectAll("path").remove()}for(var a=0;a0&&(l=l.transition().duration(e.transition.duration).ease(e.transition.easing)),l.attr("transform","translate("+(o-.5*u.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function L(t,e){var n=t._dims;return n.inputAreaStart+u.stepInset+(n.inputAreaLength-2*u.stepInset)*Math.min(1,Math.max(0,e))}function S(t,e){var n=t._dims;return Math.min(1,Math.max(0,(e-u.stepInset-n.inputAreaStart)/(n.inputAreaLength-2*u.stepInset-2*n.inputAreaStart)))}function C(t,e,n){var r=n._dims,a=l.ensureSingle(t,"rect",u.railTouchRectClass,function(r){r.call(M,e,t,n).style("pointer-events","all")});a.attr({width:r.inputAreaLength,height:Math.max(r.inputAreaWidth,u.tickOffset+n.ticklen+r.labelHeight)}).call(i.fill,n.bgcolor).attr("opacity",0),o.setTranslate(a,0,r.currentValueTotalHeight)}function P(t,e){var n=e._dims,r=n.inputAreaLength-2*u.railInset,a=l.ensureSingle(t,"rect",u.railRectClass);a.attr({width:r,height:u.railWidth,rx:u.railRadius,ry:u.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,u.railInset,.5*(n.inputAreaWidth-u.railWidth)+n.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,n=function(t,e){for(var n=t[u.name],r=[],a=0;a0?[0]:[]);function l(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,g(e))}if(i.enter().append("g").classed(u.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){r.select(this).selectAll("g."+u.groupClassName).each(l)}).remove(),0!==n.length){var s=i.selectAll("g."+u.groupClassName).data(n,v);s.enter().append("g").classed(u.groupClassName,!0),s.exit().each(l).remove();for(var c=0;c0||d<0){var g={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[m.side];e.attr("transform","translate("+g+")")}}}D.call(R),O&&(A?D.on(".opacity",null):(k=0,M=!0,D.text(v).on("mouseover.opacity",function(){r.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),D.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("_guiRestyle",t,g,e,y):o.call("_guiRelayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(R)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return D.classed("js-placeholder",M),_}};var d=/ [XY][0-9]* /},{"../../constants/interactions":141,"../../lib":163,"../../lib/svg_text_utils":184,"../../plots/plots":249,"../../registry":257,"../color":45,"../drawing":66,d3:9,"fast-isnumeric":11}],134:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,l=t("../../plots/pad_attributes"),s=t("../../plot_api/plot_template").templatedArray,c=s("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(s("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i(l({editType:"arraydraw"}),{}),font:r({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":155,"../../plot_api/edit_types":191,"../../plot_api/plot_template":198,"../../plots/font_attributes":235,"../../plots/pad_attributes":248,"../color/attributes":44}],135:[function(t,e,n){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],136:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,l=i.buttons;function s(t,e,n){function o(n,a){return r.coerce(t,e,i,n,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),r.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),r.coerceFont(o,"font",n.font),o("bgcolor",n.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function n(n,a){return r.coerce(t,e,l,n,a)}n("visible","skip"===t.method||Array.isArray(t.args))&&(n("method"),n("args"),n("label"),n("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:s})}},{"../../lib":163,"../../plots/array_container_defaults":204,"./attributes":134,"./constants":135}],137:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../plot_api/plot_template").arrayEditor,u=t("../../constants/alignment").LINE_SPACING,f=t("./constants"),d=t("./scrollbox");function p(t){return t._index}function h(t,e){return+t.attr(f.menuIndexAttrName)===e._index}function g(t,e,n,r,a,i,o,l){e.active=o,c(t.layout,f.name,e).applyUpdate("active",o),"buttons"===e.type?y(t,r,null,null,e):"dropdown"===e.type&&(a.attr(f.menuIndexAttrName,"-1"),v(t,r,a,i,e),l||y(t,r,a,i,e))}function v(t,e,n,r,a){var i=l.ensureSingle(e,"g",f.headerClassName,function(t){t.style("pointer-events","all")}),s=a._dims,c=a.active,u=a.buttons[c]||f.blankHeaderOpts,d={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},p={width:s.headerWidth,height:s.headerHeight};i.call(m,a,u,t).call(A,a,d,p),l.ensureSingle(e,"text",f.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(f.arrowSymbol[a.direction])}).attr({x:s.headerWidth-f.arrowOffsetX+a.pad.l,y:s.headerHeight/2+f.textOffsetY+a.pad.t}),i.on("click",function(){n.call(L,String(h(n,a)?-1:a._index)),y(t,e,n,r,a)}),i.on("mouseover",function(){i.call(w)}),i.on("mouseout",function(){i.call(k,a)}),o.setTranslate(e,s.lx,s.ly)}function y(t,e,n,i,o){n||(n=e).attr("pointer-events","all");var s=function(t){return-1==+t.attr(f.menuIndexAttrName)}(n)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?f.dropdownButtonClassName:f.buttonClassName,u=n.selectAll("g."+c).data(l.filterVisible(s)),d=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(d.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var h=0,v=0,y=o._dims,x=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(x?v=y.headerHeight+f.gapButtonHeader:h=y.headerWidth+f.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(v=-f.gapButtonHeader+f.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(h=-f.gapButtonHeader+f.gapButton-y.openWidth);var b={x:y.lx+h+o.pad.l,y:y.ly+v+o.pad.t,yPad:f.gapButton,xPad:f.gapButton,index:0},M={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(l,s){var c=r.select(this);c.call(m,o,l,t).call(A,o,b),c.on("click",function(){r.event.defaultPrevented||(g(t,o,0,e,n,i,s),l.execute&&a.executeAPICommand(t,l.method,l.args),t.emit("plotly_buttonclicked",{menu:o,button:l,active:o.active}))}),c.on("mouseover",function(){c.call(w)}),c.on("mouseout",function(){c.call(k,o),u.call(_,o)})}),u.call(_,o),x?(M.w=Math.max(y.openWidth,y.headerWidth),M.h=b.y-M.t):(M.w=b.x-M.l,M.h=Math.max(y.openHeight,y.headerHeight)),M.direction=o.direction,i&&(u.size()?function(t,e,n,r,a,i){var o,l,s,c=a.direction,u="up"===c||"down"===c,d=a._dims,p=a.active;if(u)for(l=0,s=0;s0?[0]:[]);if(o.enter().append("g").classed(f.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){r.select(this).selectAll("g."+f.headerGroupClassName).each(i)}).remove(),0!==n.length){var s=o.selectAll("g."+f.headerGroupClassName).data(n,p);s.enter().append("g").classed(f.headerGroupClassName,!0);for(var c=l.ensureSingle(o,"g",f.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,T=l.barLength+2*l.barPad,A=l.barWidth+2*l.barPad,L=h,S=v+y;S+A>c&&(S=c-A);var C=this.container.selectAll("rect.scrollbar-horizontal").data(M?[0]:[]);C.exit().on(".drag",null).remove(),C.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,l.barColor),M?(this.hbar=C.attr({rx:l.barRadius,ry:l.barRadius,x:L,y:S,width:T,height:A}),this._hbarXMin=L+T/2,this._hbarTranslateMax=w-T):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var P=y>k,O=l.barWidth+2*l.barPad,z=l.barLength+2*l.barPad,D=h+g,R=v;D+O>s&&(D=s-O);var E=this.container.selectAll("rect.scrollbar-vertical").data(P?[0]:[]);E.exit().on(".drag",null).remove(),E.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,l.barColor),P?(this.vbar=E.attr({rx:l.barRadius,ry:l.barRadius,x:D,y:R,width:O,height:z}),this._vbarYMin=R+z/2,this._vbarTranslateMax=k-z):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var N=this.id,I=u-.5,F=P?f+O+.5:f+.5,j=d-.5,B=M?p+A+.5:p+.5,H=o._topdefs.selectAll("#"+N).data(M||P?[0]:[]);if(H.exit().remove(),H.enter().append("clipPath").attr("id",N).append("rect"),M||P?(this._clipRect=H.select("rect").attr({x:Math.floor(I),y:Math.floor(j),width:Math.ceil(F)-Math.floor(I),height:Math.ceil(B)-Math.floor(j)}),this.container.call(i.setClipUrl,N,this.gd),this.bg.attr({x:h,y:v,width:g,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),M||P){var q=r.behavior.drag().on("dragstart",function(){r.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var U=r.behavior.drag().on("dragstart",function(){r.event.sourceEvent.preventDefault(),r.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));M&&this.hbar.on(".drag",null).call(U),P&&this.vbar.on(".drag",null).call(U)}this.setTranslate(e,n)},l.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},l.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=r.event.dx),this.vbar&&(e-=r.event.dy),this.setTranslate(t,e)},l.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=r.event.deltaY),this.vbar&&(e+=r.event.deltaY),this.setTranslate(t,e)},l.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var n=t+this._hbarXMin,a=n+this._hbarTranslateMax;t=(o.constrain(r.event.x,n,a)-n)/(a-n)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,l=i+this._vbarTranslateMax;e=(o.constrain(r.event.y,i,l)-i)/(l-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},l.prototype.setTranslate=function(t,e){var n=this.position.w-this._box.w,r=this.position.h-this._box.h;if(t=o.constrain(t||0,0,n),e=o.constrain(e||0,0,r),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/n;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var l=e/r;this.vbar.call(i.setTranslate,t,e+l*this._vbarTranslateMax)}}},{"../../lib":163,"../color":45,"../drawing":66,d3:9}],140:[function(t,e,n){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,CAP_SHIFT:.7,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],141:[function(t,e,n){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],142:[function(t,e,n){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],143:[function(t,e,n){"use strict";n.xmlns="http://www.w3.org/2000/xmlns/",n.svg="http://www.w3.org/2000/svg",n.xlink="http://www.w3.org/1999/xlink",n.svgAttrs={xmlns:n.svg,"xmlns:xlink":n.xlink}},{}],144:[function(t,e,n){"use strict";n.version="1.43.0",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config")();for(var r=t("./registry"),a=n.register=r.register,i=t("./plot_api"),o=Object.keys(i),l=0;l1/3&&t.x<2/3},n.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},n.isTopAnchor=function(t){return"top"===t.yanchor||"auto"===t.yanchor&&t.y>=2/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3}},{}],147:[function(t,e,n){"use strict";var r=t("./mod"),a=r.mod,i=r.modHalf,o=Math.PI,l=2*o;function s(t){return Math.abs(t[1]-t[0])>l-1e-15}function c(t,e){return i(e-t,l)}function u(t,e){if(s(e))return!0;var n,r;e[0](r=a(r,l))&&(r+=l);var i=a(t,l),o=i+l;return i>=n&&i<=r||o>=n&&o<=r}function f(t,e,n,r,a,i,c){a=a||0,i=i||0;var u,f,d,p,h,g=s([n,r]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(u=0,f=o,d=l):n=a&&t<=i);var a,i},pathArc:function(t,e,n,r,a){return f(null,t,e,n,r,a,0)},pathSector:function(t,e,n,r,a){return f(null,t,e,n,r,a,1)},pathAnnulus:function(t,e,n,r,a,i){return f(t,e,n,r,a,i,1)}}},{"./mod":170}],148:[function(t,e,n){"use strict";var r=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function l(t){return r(t)||o(t)}function s(t,e,n){if(l(t)){if(l(t[0])){for(var r=n,a=0;aa.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,a){t%1||!r(t)||void 0!==a.min&&ta.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var a="number"==typeof t;!0!==r.strict&&a?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){a(t).isValid()?e.set(t):e.set(n)}},colorlist:{coerceFunction:function(t,e,n){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(o.get(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?e.set(u(+t,360)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n,r){var a=r.regex||c(n);"string"==typeof t&&a.test(t)?e.set(t):e.set(n)},validateFunction:function(t,e){var n=e.dflt;return t===n||"string"==typeof t&&!!c(n).test(t)}},flaglist:{coerceFunction:function(t,e,n,r){if("string"==typeof t)if(-1===(r.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=r&&t<=a?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),y=t.charAt(0);!c||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:m);if(!k)return u;var M=k[1],T=k[3]||"1",A=Number(k[5]||1),L=Number(k[7]||0),S=Number(k[9]||0),C=Number(k[11]||0);if(c){if(2===M.length)return u;var P;M=Number(M);try{var O=v.getComponentMethod("calendars","getCal")(e);if(w){var z="i"===T.charAt(T.length-1);T=parseInt(T,10),P=O.newDate(M,O.toMonthIndex(M,T,z),A)}else P=O.newDate(M,Number(T),A)}catch(t){return u}return P?(P.toJD()-g)*f+L*d+S*p+C*h:u}M=2===M.length?(Number(M)+2e3-b)%100+b:Number(M),T-=1;var D=new Date(Date.UTC(2e3,T,A,L,S));return D.setUTCFullYear(M),D.getUTCMonth()!==T?u:D.getUTCDate()!==A?u:D.getTime()+C*h},r=n.MIN_MS=n.dateTime2ms("-9999"),a=n.MAX_MS=n.dateTime2ms("9999-12-31 23:59:59.9999"),n.isDateTime=function(t,e){return n.dateTime2ms(t,e)!==u};var k=90*f,M=3*d,T=5*p;function A(t,e,n,r,a){if((e||n||r||a)&&(t+=" "+w(e,2)+":"+w(n,2),(r||a)&&(t+=":"+w(r,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}n.ms2DateTime=function(t,e,n){if("number"!=typeof t||!(t>=r&&t<=a))return u;e||(e=0);var i,o,l,c,m,x,b=Math.floor(10*s(t+.05,1)),w=Math.round(t-b/10);if(_(n)){var L=Math.floor(w/f)+g,S=Math.floor(s(t,f));try{i=v.getComponentMethod("calendars","getCal")(n).fromJD(L).formatDate("yyyy-mm-dd")}catch(t){i=y("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=r+f&&t<=a-f))return u;var e=Math.floor(10*s(t+.05,1)),n=new Date(Math.round(t-e/10));return A(i.time.format("%Y-%m-%d")(n),n.getHours(),n.getMinutes(),n.getSeconds(),10*n.getUTCMilliseconds()+e)},n.cleanDate=function(t,e,r){if(t===u)return e;if(n.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(r))return l.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=n.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!n.isDateTime(t,r))return l.error("unrecognized date",t),e;return t};var L=/%\d?f/g;function S(t,e,n,r){t=t.replace(L,function(t){var n=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(n).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(r))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,r)}catch(t){return"Invalid"}return n(t)(a)}var C=[59,59.9,59.99,59.999,59.9999];n.formatDate=function(t,e,n,r,a,i){if(a=_(a)&&a,!e)if("y"===n)e=i.year;else if("m"===n)e=i.month;else{if("d"!==n)return function(t,e){var n=s(t+.05,f),r=w(Math.floor(n/d),2)+":"+w(s(Math.floor(n/p),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(s(t/h,60),C[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),r+=":"+a}return r}(t,n)+"\n"+S(i.dayMonthYear,t,r,a);e=i.dayMonth+"\n"+i.year}return S(e,t,r,a)};var P=3*f;n.incrementMonth=function(t,e,n){n=_(n)&&n;var r=s(t,f);if(t=Math.round(t-r),n)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(n),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+r}catch(e){l.error("invalid ms "+t+" in calendar "+n)}var c=new Date(t+P);return c.setUTCMonth(c.getUTCMonth()+e)+r-P},n.findExactDates=function(t,e){for(var n,r,a=0,i=0,l=0,s=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u0&&(n.push(a),a=[])}return a.length>0&&n.push(a),n},n.makeLine=function(t){return 1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}},n.makePolygon=function(t){if(1===t.length)return{type:"Polygon",coordinates:t};for(var e=new Array(t.length),n=0;n1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}function s(t,e,n,r,a){var i=r*t+a*e;if(i<0)return r*r+a*a;if(i>n){var o=r-t,l=a-e;return o*o+l*l}var s=r*e-a*t;return s*s/n}n.segmentsIntersect=l,n.segmentDistance=function(t,e,n,r,a,i,o,c){if(l(t,e,n,r,a,i,o,c))return 0;var u=n-t,f=r-e,d=o-a,p=c-i,h=u*u+f*f,g=d*d+p*p,v=Math.min(s(u,f,h,a-t,i-e),s(u,f,h,o-t,c-e),s(d,p,g,t-a,e-i),s(d,p,g,n-a,r-i));return Math.sqrt(v)},n.getTextLocation=function(t,e,n,l){if(t===a&&l===i||(r={},a=t,i=l),r[n])return r[n];var s=t.getPointAtLength(o(n-l/2,e)),c=t.getPointAtLength(o(n+l/2,e)),u=Math.atan((c.y-s.y)/(c.x-s.x)),f=t.getPointAtLength(o(n,e)),d={x:(4*f.x+s.x+c.x)/6,y:(4*f.y+s.y+c.y)/6,theta:u};return r[n]=d,d},n.clearLocationCache=function(){a=null},n.getVisibleSegment=function(t,e,n){var r,a,i=e.left,o=e.right,l=e.top,s=e.bottom,c=0,u=t.getTotalLength(),f=u;function d(e){var n=t.getPointAtLength(e);0===e?r=n:e===u&&(a=n);var c=n.xo?n.x-o:0,f=n.ys?n.y-s:0;return Math.sqrt(c*c+f*f)}for(var p=d(c);p;){if((c+=p+n)>f)return;p=d(c)}for(p=d(f);p;){if(c>(f-=p+n))return;p=d(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(r.x-a.x)<.1&&Math.abs(r.y-a.y)<.1}},n.findPointOnPath=function(t,e,n,r){for(var a,i,o,l=(r=r||{}).pathLength||t.getTotalLength(),s=r.tolerance||.001,c=r.iterationLimit||30,u=t.getPointAtLength(0)[n]>t.getPointAtLength(l)[n]?-1:1,f=0,d=0,p=l;f0?p=a:d=a,f++}return i}},{"./mod":170}],161:[function(t,e,n){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],162:[function(t,e,n){"use strict";e.exports=function(t){return t}},{}],163:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),i=t("../constants/numerical"),o=i.FP_SAFE,l=i.BADNUM,s=e.exports={};s.nestedProperty=t("./nested_property"),s.keyedContainer=t("./keyed_container"),s.relativeAttr=t("./relative_attr"),s.isPlainObject=t("./is_plain_object"),s.toLogRange=t("./to_log_range"),s.relinkPrivateKeys=t("./relink_private");var c=t("./array");s.isTypedArray=c.isTypedArray,s.isArrayOrTypedArray=c.isArrayOrTypedArray,s.isArray1D=c.isArray1D,s.ensureArray=c.ensureArray,s.concat=c.concat,s.maxRowLength=c.maxRowLength,s.minRowLength=c.minRowLength;var u=t("./mod");s.mod=u.mod,s.modHalf=u.modHalf;var f=t("./coerce");s.valObjectMeta=f.valObjectMeta,s.coerce=f.coerce,s.coerce2=f.coerce2,s.coerceFont=f.coerceFont,s.coerceHoverinfo=f.coerceHoverinfo,s.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,s.validate=f.validate;var d=t("./dates");s.dateTime2ms=d.dateTime2ms,s.isDateTime=d.isDateTime,s.ms2DateTime=d.ms2DateTime,s.ms2DateTimeLocal=d.ms2DateTimeLocal,s.cleanDate=d.cleanDate,s.isJSDate=d.isJSDate,s.formatDate=d.formatDate,s.incrementMonth=d.incrementMonth,s.dateTick0=d.dateTick0,s.dfltRange=d.dfltRange,s.findExactDates=d.findExactDates,s.MIN_MS=d.MIN_MS,s.MAX_MS=d.MAX_MS;var p=t("./search");s.findBin=p.findBin,s.sorterAsc=p.sorterAsc,s.sorterDes=p.sorterDes,s.distinctVals=p.distinctVals,s.roundUp=p.roundUp,s.sort=p.sort,s.findIndexOfMin=p.findIndexOfMin;var h=t("./stats");s.aggNums=h.aggNums,s.len=h.len,s.mean=h.mean,s.midRange=h.midRange,s.variance=h.variance,s.stdev=h.stdev,s.interp=h.interp;var g=t("./matrix");s.init2dArray=g.init2dArray,s.transposeRagged=g.transposeRagged,s.dot=g.dot,s.translationMatrix=g.translationMatrix,s.rotationMatrix=g.rotationMatrix,s.rotationXYMatrix=g.rotationXYMatrix,s.apply2DTransform=g.apply2DTransform,s.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");s.deg2rad=v.deg2rad,s.rad2deg=v.rad2deg,s.angleDelta=v.angleDelta,s.angleDist=v.angleDist,s.isFullCircle=v.isFullCircle,s.isAngleInsideSector=v.isAngleInsideSector,s.isPtInsideSector=v.isPtInsideSector,s.pathArc=v.pathArc,s.pathSector=v.pathSector,s.pathAnnulus=v.pathAnnulus;var y=t("./anchor_utils");s.isLeftAnchor=y.isLeftAnchor,s.isCenterAnchor=y.isCenterAnchor,s.isRightAnchor=y.isRightAnchor,s.isTopAnchor=y.isTopAnchor,s.isMiddleAnchor=y.isMiddleAnchor,s.isBottomAnchor=y.isBottomAnchor;var m=t("./geometry2d");s.segmentsIntersect=m.segmentsIntersect,s.segmentDistance=m.segmentDistance,s.getTextLocation=m.getTextLocation,s.clearLocationCache=m.clearLocationCache,s.getVisibleSegment=m.getVisibleSegment,s.findPointOnPath=m.findPointOnPath;var x=t("./extend");s.extendFlat=x.extendFlat,s.extendDeep=x.extendDeep,s.extendDeepAll=x.extendDeepAll,s.extendDeepNoArrays=x.extendDeepNoArrays;var b=t("./loggers");s.log=b.log,s.warn=b.warn,s.error=b.error;var _=t("./regex");s.counterRegex=_.counter;var w=t("./throttle");function k(t){var e={};for(var n in t)for(var r=t[n],a=0;ao?l:a(t)?Number(t):l:l},s.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},s.noop=t("./noop"),s.identity=t("./identity"),s.repeat=function(t,e){for(var n=new Array(e),r=0;rn?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},s.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},s.simpleMap=function(t,e,n,r){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,n)?a>10?(s.warn("randstr failed uniqueness"),c):t(e,n,r,(a||0)+1):c},s.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={optionList:[],_newoption:function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)}};return n["_"+e]=t,n},s.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var n,r,a,i,o=t.length,l=2*o,s=2*e-1,c=new Array(s),u=new Array(o);for(n=0;n=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=o&&(a=l-1-a),i+=t[a]*c[r];u[n]=i}return u},s.syncOrAsync=function(t,e,n){var r;function a(){return s.syncOrAsync(t,e,n)}for(;t.length;)if((r=(0,t.splice(0,1)[0])(e))&&r.then)return r.then(a).then(void 0,s.promiseError);return n&&n(e)},s.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},s.noneOrAll=function(t,e,n){if(t){var r,a=!1,i=!0;for(r=0;r1?a+o[1]:"";if(i&&(o.length>1||l.length>4||n))for(;r.test(l);)l=l.replace(r,"$1"+i+"$2");return l+s};var A=/%{([^\s%{}:]*)(:[^}]*)?}/g,L=/^\w*$/;s.templateString=function(t,e){var n={};return t.replace(A,function(t,r){return L.test(r)?e[r]||"":(n[r]=n[r]||s.nestedProperty(e,r).get,n[r]()||"")})};var S=/^:/,C=0;s.hovertemplateString=function(t,e){var n=arguments,a={};return t.replace(A,function(t,i,o){var l,c,u;for(u=2;u=48&&o<=57,c=l>=48&&l<=57;if(s&&(r=10*r+o-48),c&&(a=10*a+l-48),!s||!c){if(r!==a)return r-a;if(o!==l)return o-l}}return a-r};var P=2e9;s.seedPseudoRandom=function(){P=2e9},s.pseudoRandom=function(){var t=P;return P=(69069*P+1)%4294967296,Math.abs(P-t)<429496729?s.pseudoRandom():P/4294967296}},{"../constants/numerical":142,"./anchor_utils":146,"./angles":147,"./array":148,"./clean_number":149,"./clear_responsive":151,"./coerce":152,"./dates":153,"./extend":155,"./filter_unique":156,"./filter_visible":157,"./geometry2d":160,"./get_graph_div":161,"./identity":162,"./is_plain_object":164,"./keyed_container":165,"./localize":166,"./loggers":167,"./make_trace_groups":168,"./matrix":169,"./mod":170,"./nested_property":171,"./noop":172,"./notifier":173,"./push_unique":176,"./regex":178,"./relative_attr":179,"./relink_private":180,"./search":181,"./stats":183,"./throttle":185,"./to_log_range":186,d3:9,"fast-isnumeric":11}],164:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],165:[function(t,e,n){"use strict";var r=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,n,i){var o,l,s;n=n||"name",i=i||"value";var c={};e&&e.length?(s=r(t,e),l=s.get()):l=t,e=e||"";var u={};if(l)for(o=0;o2)return c[e]=2|c[e],d.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],171:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(r(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,i,o,s=0,c=e.split(".");s/g),o=0;oi||c===a||cl||e&&s(t))}:function(t,e){var s=t[0],c=t[1];if(s===a||si||c===a||cl)return!1;var u,f,d,p,h,g=n.length,v=n[0][0],y=n[0][1],m=0;for(u=1;uMath.max(f,v)||c>Math.max(d,y)))if(cu||Math.abs(r(o,d))>a)return!0;return!1};i.filter=function(t,e){var n=[t[0]],r=0,a=0;function i(i){t.push(i);var l=n.length,s=r;n.splice(a+1);for(var c=s+1;c1&&i(t.pop());return{addPt:i,raw:t,filtered:n}}},{"../constants/numerical":142,"./matrix":169}],176:[function(t,e,n){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var n,r=e.toString();for(n=0;na.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,n;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;ne}function c(t,e){return t>=e}n.findBin=function(t,e,n){if(r(e.start))return n?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,u,f=0,d=e.length,p=0,h=d>1?(e[d-1]-e[0])/(d-1):1;for(u=h>=0?n?o:l:n?c:s,t+=1e-9*h*(n?-1:1)*(h>=0?1:-1);f90&&a.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,a=e[r]-e[0]||1,i=a/(r||1)/1e4,o=[e[0]],l=0;le[l]+i&&(a=Math.min(a,e[l+1]-e[l]),o.push(e[l+1]));return{vals:o,minDiff:a}},n.roundUp=function(t,e,n){for(var r,a=0,i=e.length-1,o=0,l=n?0:1,s=n?1:0,c=n?Math.ceil:Math.floor;a0&&(r=1),n&&r)return t.sort(e)}return r?t:t.reverse()},n.findIndexOfMin=function(t,e){e=e||i;for(var n,r=1/0,a=0;ai.length)&&(o=i.length),r(e)||(e=!1),a(i[0])){for(s=new Array(o),l=0;lt.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"./array":148,"fast-isnumeric":11}],184:[function(t,e,n){"use strict";var r=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function l(t,e){return t.node().getBoundingClientRect()[e]}var s=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;n.convertToTspans=function(t,e,v){var L=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&L.match(s),P=r.select(t.node().parentNode);if(!P.empty()){var O=t.attr("class")?t.attr("class").split(" ")[0]:"text";return O+="-math",P.selectAll("svg."+O).remove(),P.selectAll("g."+O+"-group").remove(),t.style("display",null).attr({"data-unformatted":L,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var n=parseInt(t.node().style.fontSize,10),i={fontSize:n};!function(t,e,n){var i,o,l,s;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),l=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var n="math-output-"+a.randstr({},64);return s=r.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(s.node())},function(){var e=r.select("body").select("#MathJax_SVG_glyphs");if(s.select(".MathJax_SVG").empty()||!s.select("svg").node())a.log("There was an error in the tex syntax.",t),n();else{var o=s.select("svg").node().getBoundingClientRect();n(s.select(".MathJax_SVG"),e,o)}if(s.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==l&&(MathJax.Hub.processSectionDelay=l),MathJax.Hub.Config(o)})}(S[2],i,function(r,a,i){P.selectAll("svg."+O).remove(),P.selectAll("g."+O+"-group").remove();var o=r&&r.select("svg");if(!o||!o.node())return z(),void e();var s=P.append("g").classed(O+"-group",!0).attr({"pointer-events":"none","data-unformatted":L,"data-math":"Y"});s.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:O,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=l(o,"width"),f=l(o,"height"),d=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(n||l(t,"height"))/4;"y"===O[0]?(s.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===O[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===O[0]?o.attr({x:0,y:p}):o.attr({x:d,y:+t.attr("y")+p-f/2}),v&&v.call(t,s),e(s)})})):z(),t}function z(){P.empty()||(O=t.attr("class")+"-math",P.select("svg."+O).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var n,l=!1,s=[],c=-1;function u(){c++;var e=document.createElementNS(i.svg,"tspan");r.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),n=e;var a=s;if(s=[{node:e}],a.length>1)for(var l=1;l doesnt match end tag <"+t+">. Pretending it did match.",e),n=s[s.length-1].node}else a.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(n=t,s=[{node:t}]);for(var P=e.split(m),O=0;O|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},d={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},h="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,m=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,M=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function T(t,e){if(!t)return null;var n=t.match(e),r=n&&(n[3]||n[4]);return r&&C(r)}var A=/(^|;)\s*color:/;n.plainText=function(t){return(t||"").replace(v," ")};var L={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function C(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var n=String.fromCharCode;return t<=65535?n(t):n(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):L[e])||t})}function P(t,e,n){var r,a,i,o=n.horizontalAlign,l=n.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-r.height}:"middle"===l?function(){return s.top+(s.height-r.height)/2}:function(){return s.top},i="right"===o?function(){return s.right-r.width}:"center"===o?function(){return s.left+(s.width-r.width)/2}:function(){return s.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:i()-c.left+"px","z-index":1e3}),this}}n.convertEntities=C,n.lineCount=function(t){return t.selectAll("tspan.line").size()||1},n.positionText=function(t,e,n){return t.each(function(){var t=r.select(this);function a(e,n){return void 0===n?null===(n=t.attr(e))&&(t.attr(e,0),n=0):t.attr(e,n),n}var i=a("x",e),o=a("y",n);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},n.makeEditable=function(t,e){var n=e.gd,a=e.delegate,i=r.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function l(){!function(){var a=r.select(n).select(".svg-container"),o=a.append("div"),l=t.node().style,c=parseFloat(l.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":l.fontFamily||"Arial","font-size":c,color:e.fill||l.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(P(t,a,e)).on("blur",function(){n._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=r.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&r.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;r.select(this).transition().duration(0).remove(),r.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;n._editing=!0,r.select(document).on("mouseup",function(){if(r.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===r.event.which?(n._editing=!1,t.style({opacity:1}),r.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),r.select(this).call(P(t,a,e)))}).on("keydown",function(){13===r.event.which&&this.blur()}).call(s)}(),t.style({opacity:0});var a,l=o.attr("class");(a=l?"."+l.split(" ")[0]+"-math-group":"[class*=-math-group]")&&r.select(t.node().parentNode).select(a).style({opacity:0})}function s(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}return e.immediate?l():o.on("click",l),r.rebind(t,i,"on")}},{"../constants/alignment":140,"../constants/xmlns_namespaces":143,"../lib":163,d3:9}],185:[function(t,e,n){"use strict";var r={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}n.throttle=function(t,e,n){var i=r[t],o=Date.now();if(!i){for(var l in r)r[l].tsi.ts+e?s():i.timer=setTimeout(function(){s(),i.timer=null},e)},n.done=function(t){var e=r[t];return e&&e.timer?new Promise(function(t){var n=e.onDone;e.onDone=function(){n&&n(),t(),e.onDone=null}}):Promise.resolve()},n.clear=function(t){if(t)a(r[t]),delete r[t];else for(var e in r)n.clear(e)}},{}],186:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var n=Math.log(Math.min(e[0],e[1]))/Math.LN10;return r(n)||(n=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),n}},{"fast-isnumeric":11}],187:[function(t,e,n){"use strict";var r=e.exports={},a=t("../plots/geo/constants").locationmodeToLayer,i=t("topojson-client").feature;r.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},r.getTopojsonPath=function(t,e){return t+e+".json"},r.getTopojsonFeatures=function(t,e){var n=a[t.locationmode],r=e.objects[n];return i(e,r).features}},{"../plots/geo/constants":237,"topojson-client":28}],188:[function(t,e,n){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],189:[function(t,e,n){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],190:[function(t,e,n){"use strict";var r=t("../registry");e.exports=function(t){for(var e,n,a=r.layoutArrayContainers,i=r.layoutArrayRegexes,o=t.split("[")[0],l=0;l0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},n.cleanLayout=function(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var i=(l.subplotsRegistry.cartesian||{}).attrRegex,s=(l.subplotsRegistry.polar||{}).attrRegex,u=(l.subplotsRegistry.ternary||{}).attrRegex,h=(l.subplotsRegistry.gl3d||{}).attrRegex,g=Object.keys(t);for(e=0;e3?(O.x=1.02,O.xanchor="left"):O.x<-2&&(O.x=-.02,O.xanchor="right"),O.y>3?(O.y=1.02,O.yanchor="bottom"):O.y<-2&&(O.y=-.02,O.yanchor="top")),p(t),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t.template&&t.template.layout&&n.cleanLayout(t.template.layout),t},n.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}n.hasParent=function(t,e){for(var n=x(e);n;){if(n in t)return!0;n=x(n)}return!1};var b=["x","y","z"];n.clearAxisTypes=function(t,e,n){for(var r=0;r1&&i.warn("Full array edits are incompatible with other edits",f);var m=n[""][""];if(c(m))e.set(null);else{if(!Array.isArray(m))return i.warn("Unrecognized full array edit value",f,m),!0;e.set(m)}return!g&&(d(v,y),p(t),!0)}var x,b,_,w,k,M,T,A,L=Object.keys(n).map(Number).sort(o),S=e.get(),C=S||[],P=u(y,f).get(),O=[],z=-1,D=C.length;for(x=0;xC.length-(T?0:1))i.warn("index out of range",f,_);else if(void 0!==M)k.length>1&&i.warn("Insertion & removal are incompatible with edits to the same index.",f,_),c(M)?O.push(_):T?("add"===M&&(M={}),C.splice(_,0,M),P&&P.splice(_,0,{})):i.warn("Unrecognized full object edit value",f,_,M),-1===z&&(z=_);else for(b=0;b=0;x--)C.splice(O[x],1),P&&P.splice(O[x],1);if(C.length?S||e.set(C):e.set(null),g)return!1;if(d(v,y),h!==a){var R;if(-1===z)R=L;else{for(D=Math.max(C.length,D),R=[],x=0;x=z);x++)R.push(_);for(x=z;x=t.data.length||a<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(a,r+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+n+" must be unique.")}}function R(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),D(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&D(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function E(t,e,n,r,i){!function(t,e,n,r){var a=o.isPlainObject(r);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof n)throw new Error("indices must be an integer or array of integers");for(var i in D(t,n,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==n.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in r)||!Array.isArray(r[i])||r[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,n,r);for(var s=function(t,e,n,r){var i,s,c,u,f,d=o.isPlainObject(r),p=[];for(var h in Array.isArray(n)||(n=[n]),n=z(n,t.data.length-1),e)for(var g=0;g-1?s(n,n.replace("titlefont","title.font")):n.indexOf("titleposition")>-1?s(n,n.replace("titleposition","title.position")):n.indexOf("titleside")>-1?s(n,n.replace("titleside","title.side")):n.indexOf("titleoffset")>-1&&s(n,n.replace("titleoffset","title.offset")):s(n,n.replace("title","title.text"));function s(e,n){t[n]=t[e],delete t[e]}}function U(t,e,n){if(t=o.getGraphDiv(t),k.clearPromiseQueue(t),t.framework&&t.framework.isPolar)return Promise.resolve(t);var r={};if("string"==typeof e)r[e]=n;else{if(!o.isPlainObject(e))return o.warn("Relayout fail.",e,n),Promise.reject();r=o.extendFlat({},e)}Object.keys(r).length&&(t.changed=!0);var a=W(t,r),i=a.flags;i.calc&&(t.calcdata=void 0);var l=[d.previousPromises];i.layoutReplot?l.push(M.layoutReplot):Object.keys(r).length&&(V(t,i,a)||d.supplyDefaults(t),i.legend&&l.push(M.doLegend),i.layoutstyle&&l.push(M.layoutStyles),i.axrange&&G(l,a.rangesAltered),i.ticks&&l.push(M.doTicksRelayout),i.modebar&&l.push(M.doModeBar),i.camera&&l.push(M.doCamera),l.push(S)),l.push(d.rehover),c.add(t,U,[t,a.undoit],U,[t,a.redoit]);var s=o.syncOrAsync(l,t);return s&&s.then||(s=Promise.resolve(t)),s.then(function(){return t.emit("plotly_relayout",a.eventData),t})}function V(t,e,n){var r;if(!e.axrange)return!1;for(r in e)if("axrange"!==r&&e[r])return!1;for(r in n.rangesAltered){var a=h.id2name(r),i=t.layout[a],o=t._fullLayout[a];o.autorange=i.autorange,o.range=i.range.slice(),o.cleanRange()}return!0}function G(t,e){var n=e?function(t){var n={skipTitle:!0};for(var r in e)if(h.getFromId(t,r).automargin){n={};break}return h.draw(t,Object.keys(e),n)}:function(t){return h.draw(t,"redraw")};t.push(M.doAutoRangeAndConstraints,n,M.drawData,M.finalDraw)}n.plot=function(t,e,a,i){var l;if(t=o.getGraphDiv(t),s.init(t),o.isPlainObject(e)){var c=e;e=c.data,a=c.layout,i=c.config,l=c.frames}if(!1===s.triggerHandler(t,"plotly_beforeplot",[e,a,i]))return Promise.reject();e||a||o.isPlotDiv(t)||o.warn("Calling Plotly.plot as if redrawing but this container doesn't yet have a plot.",t),O(t,i),a||(a={}),r.select(t).classed("js-plotly-plot",!0),g.makeTester(),Array.isArray(t._promises)||(t._promises=[]);var f=0===(t.data||[]).length&&Array.isArray(e);if(Array.isArray(e)&&(k.cleanData(e),f?t.data=e:t.data.push.apply(t.data,e),t.empty=!1),t.layout&&!f||(t.layout=k.cleanLayout(a)),t._dragging&&!t._transitioning)return t._replotPending=!0,Promise.reject();t._replotPending=!1,d.supplyDefaults(t);var v=t._fullLayout,x=v._has("cartesian");if(!v._has("polar")&&e&&e[0]&&e[0].r)return o.log("Legacy polar charts are deprecated!"),function(t,e,n){var a=r.select(t).selectAll(".plot-container").data([0]);a.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=a.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e);n&&(t.layout=n);p.manager.fillLayout(t),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=p.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var l=t.framework.svg(),s=1,c=t._fullLayout.title?t._fullLayout.title.text:"";""!==c&&c||(s=0);var u=function(){this.call(b.convertToTspans,t)},f=l.select(".title-group text").call(u);if(t._context.edits.titleText){var h=o._(t,"Click to enter Plot title");c&&c!==h||(s=.2,f.attr({"data-unformatted":h}).text(h).style({opacity:s}).on("mouseover.opacity",function(){r.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(1e3).style("opacity",0)}));var g=function(){this.call(b.makeEditable,{gd:t}).on("edit",function(e){t.framework({layout:{title:{text:e}}}),this.text(e).call(u),this.call(g)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(u)})};f.call(g)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),d.addLinks(t),Promise.resolve()}(t,e,a);v._replotting=!0,f&<(t),t.framework!==lt&&(t.framework=lt,lt(t)),g.initGradients(t),f&&h.saveShowSpikeInitial(t);var _=!t.calcdata||t.calcdata.length!==(t._fullData||[]).length;_&&d.doCalcdata(t);for(var w=0;w=0&&n=0&&n0&&"string"!=typeof D.parts[E];)E--;var N=D.parts[E],I=D.parts[E-1]+"."+N,B=D.parts.slice(0,E).join("."),H=l(t.layout,B).get(),U=l(s,B).get(),V=D.get();if(void 0!==R){M[z]=R,L[z]="reverse"===N?R:F(V);var G=f.getLayoutValObject(s,D.parts);if(G&&G.impliedEdits&&null!==R)for(var W in G.impliedEdits)S(o.relativeAttr(z,W),G.impliedEdits[W]);if(-1!==["width","height"].indexOf(z))if(R){S("autosize",null);var $="height"===z?"width":"height";S($,s[$])}else s[z]=t._initialAutoSize[z];else if("autosize"===z)S("width",R?null:s.width),S("height",R?null:s.height);else if(I.match(Y))O(I),l(s,B+"._inputRange").set(null);else if(I.match(Z)){O(I),l(s,B+"._inputRange").set(null);var Q=l(s,B).get();Q._inputDomain&&(Q._input.domain=Q._inputDomain.slice())}else I.match(X)&&l(s,B+"._inputDomain").set(null);if("type"===N){var K=H,tt="linear"===U.type&&"log"===R,et="log"===U.type&&"linear"===R;if(tt||et){if(K&&K.range)if(U.autorange)tt&&(K.range=K.range[1]>K.range[0]?[1,2]:[2,1]);else{var nt=K.range[0],rt=K.range[1];tt?(nt<=0&&rt<=0&&S(B+".autorange",!0),nt<=0?nt=rt/1e6:rt<=0&&(rt=nt/1e6),S(B+".range[0]",Math.log(nt)/Math.LN10),S(B+".range[1]",Math.log(rt)/Math.LN10)):(S(B+".range[0]",Math.pow(10,nt)),S(B+".range[1]",Math.pow(10,rt)))}else S(B+".autorange",!0);Array.isArray(s._subplots.polar)&&s._subplots.polar.length&&s[D.parts[0]]&&"radialaxis"===D.parts[1]&&delete s[D.parts[0]]._subplot.viewInitial["radialaxis.range"],u.getComponentMethod("annotations","convertCoords")(t,U,R,S),u.getComponentMethod("images","convertCoords")(t,U,R,S)}else S(B+".autorange",!0),S(B+".range",null);l(s,B+"._inputRange").set(null)}else if(N.match(A)){var at=l(s,z).get(),it=(R||{}).type;it&&"-"!==it||(it="linear"),u.getComponentMethod("annotations","convertCoords")(t,at,it,S),u.getComponentMethod("images","convertCoords")(t,at,it,S)}var ot=w.containerArrayMatch(z);if(ot){n=ot.array,r=ot.index;var lt=ot.property,st=G||{editType:"calc"};""!==r&&""===lt&&(w.isAddVal(R)?L[z]=null:w.isRemoveVal(R)?L[z]=(l(i,n).get()||[])[r]:o.warn("unrecognized full object value",e)),T.update(_,st),y[n]||(y[n]={});var ct=y[n][r];ct||(ct=y[n][r]={}),ct[lt]=R,delete e[z]}else"reverse"===N?(H.range?H.range.reverse():(S(B+".autorange",!0),H.range=[1,0]),U.autorange?_.calc=!0:_.plot=!0):(s._has("scatter-like")&&s._has("regl")&&"dragmode"===z&&("lasso"===R||"select"===R)&&"lasso"!==V&&"select"!==V?_.plot=!0:G?T.update(_,G):_.calc=!0,D.set(R))}}for(n in y){w.applyContainerArrayChanges(t,d(i,n),y[n],_,d)||(_.plot=!0)}var ut=s._axisConstraintGroups||[];for(C in P)for(r=0;r1;)if(r.pop(),void 0!==(n=l(e,r.join(".")+".uirevision").get()))return n;return e.uirevision}function rt(t,e){for(var n=0;n=a.length?a[0]:a[t]:a}function s(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function c(t,e){var n=0;return function(){if(t&&++n===e)return t()}}return void 0===r._frameWaitingCnt&&(r._frameWaitingCnt=0),new Promise(function(i,u){function f(){r._currentFrame&&r._currentFrame.onComplete&&r._currentFrame.onComplete();var e=r._currentFrame=r._frameQueue.shift();if(e){var n=e.name?e.name.toString():null;t._fullLayout._currentFrame=n,r._lastFrameAt=Date.now(),r._timeToNext=e.frameOpts.duration,d.transition(t,e.frame.data,e.frame.layout,k.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:n,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(r._animationRaf),r._animationRaf=null}function p(){t.emit("plotly_animating"),r._lastFrameAt=-1/0,r._timeToNext=0,r._runningTransitions=0,r._currentFrame=null;var e=function(){r._animationRaf=window.requestAnimationFrame(e),Date.now()-r._lastFrameAt>r._timeToNext&&f()};e()}var h,g,v=0;function y(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var m=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))m.push({type:"object",data:y(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(h=0;h0&&MM)&&T.push(g);m=T}}m.length>0?function(e){if(0!==e.length){for(var a=0;a=0;r--)if(o.isPlainObject(e[r])){var g=e[r].name,v=(u[g]||h[g]||{}).name,y=e[r].name,m=u[v]||h[v];v&&y&&"number"==typeof y&&m&&L<5&&(L++,o.warn('addFrames: overwriting frame "'+(u[v]||h[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===L&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),h[g]={name:g},p.push({frame:d.supplyFrameDefaults(e[r]),index:n&&void 0!==n[r]&&null!==n[r]?n[r]:f+r})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;r--){if("number"==typeof(a=p[r].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;u[a.name="frame "+t._transitionData._counter++];);if(u[a.name]){for(i=0;i=0;n--)r=e[n],i.push({type:"delete",index:r}),l.unshift({type:"insert",index:r,value:a[r]});var s=d.modifyFrames,u=d.modifyFrames,f=[t,l],p=[t,i];return c&&c.add(t,s,f,u,p),d.modifyFrames(t,i)},n.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},n=t._fullData||[];return d.cleanPlot([],{},n,e),d.purge(t),s.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":45,"../components/colorbar/connect":47,"../components/drawing":66,"../constants/xmlns_namespaces":143,"../lib":163,"../lib/events":154,"../lib/queue":177,"../lib/svg_text_utils":184,"../plots/cartesian/axes":208,"../plots/cartesian/constants":214,"../plots/cartesian/graph_interact":218,"../plots/plots":249,"../plots/polar/legacy":252,"../registry":257,"./edit_types":191,"./helpers":192,"./manage_arrays":194,"./plot_config":196,"./plot_schema":197,"./subroutines":199,d3:9,"fast-isnumeric":11,"has-hover":13}],196:[function(t,e,n){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,showSendToCloud:!1,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,watermark:!1,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],197:[function(t,e,n){"use strict";var r=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),l=t("../plots/frame_attributes"),s=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),d=a.extendFlat,p=a.extendDeepAll,h=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",y=[g,v,"_arrayAttrRegexps","_deprecated"];function m(t,e,n){if(!t)return!1;if(t._isLinkedToArray)if(x(e[n]))n++;else if(n=i.length)return!1;if(2===t.dimensions){if(n++,e.length===n)return t;var o=e[n];if(!x(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){n.crawl(t,function(t,e,r){n.isValObject(t)?"data_array"===t.valType?(t.role="data",r[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(r[e+"src"]={valType:"string",editType:"none"}):h(t)&&(t.role="object")})}(t),function(t){n.crawl(t,function(t,e,n){if(!t)return;var r=t[v];if(!r)return;delete t[v],n[e]={items:{}},n[e].items[r]=t,n[e].role="object"})}(t),function(t){!function t(e){for(var n in e)if(h(e[n]))t(e[n]);else if(Array.isArray(e[n]))for(var r=0;r=s.length)return!1;a=(n=(r.transformsRegistry[s[u].type]||{}).attributes)&&n[e[2]],l=3}else if("area"===t.type)a=c[o];else{var f=t._module;if(f||(f=(r.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(n=f.attributes)&&n[o])){var d=f.basePlotModule;d&&d.attributes&&(a=d.attributes[o])}a||(a=i[o])}return m(a,e,l)},n.getLayoutValObject=function(t,e){return m(function(t,e){var n,a,i,l,s=t._basePlotModules;if(s){var c;for(n=0;n=a&&(n._input||{})._templateitemname;l&&(o=a);var s,c=e+"["+o+"]";function u(){s={},l&&(s[c]={},s[c][i]=l)}function f(t,e){l?r.nestedProperty(s[c],t).set(e):s[c+"."+t]=e}function d(){var t=s;return u(),t}return u(),{modifyBase:function(t,e){s[t]=e},modifyItem:f,getUpdateObj:d,applyUpdate:function(e,n){e&&f(e,n);var a=d();for(var i in a)r.nestedProperty(t,i).set(a[i])}}}},{"../lib":163,"../plots/attributes":205}],199:[function(t,e,n){"use strict";var r=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),l=t("../lib/clear_gl_canvases"),s=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),d=t("../plots/cartesian/axes"),p=t("../constants/alignment"),h=t("../plots/cartesian/constraints"),g=h.enforce,v=h.clean,y=t("../plots/cartesian/autorange").doAutoRange,m="start",x="middle",b="end";function _(t,e,n){for(var r=0;r=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function w(t){var e,a,i,l,u,h,g=t._fullLayout,v=g._size,y=v.p,m=d.list(t,"",!0);if(g._paperdiv.style({width:t._context.responsive&&g.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":g.width+"px",height:t._context.responsive&&g.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":g.height+"px"}).selectAll(".main-svg").call(c.setSize,g.width,g.height),t._context.setBackground(t,g.paper_bgcolor),n.drawMainTitle(t),f.manage(t),!g._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,n){var r=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===n?e._offset-y-r:e._offset+e._length+y+r:v.t+v.h*(1-(t.position||0))+r%1:e?"right"===n?e._offset+e._length+y+r:e._offset-y-r:v.l+v.w*(t.position||0)+r%1}for(e=0;ek?u.push({code:"unused",traceType:m,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:m,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,n){for(var r in e)if("_"!==r.charAt(0)){var i=e[r],o=p(e,r,n);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&u.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&h(i)&&t(i,o)}}({data:v,layout:d},""),u.length)return u.map(g)}},{"../lib":163,"../plots/attributes":205,"../plots/plots":249,"./plot_config":196,"./plot_schema":197,"./plot_template":198}],201:[function(t,e,n){"use strict";var r=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),l=t("../snapshot/svgtoimg"),s={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var n,u,f;function d(t){return!(t in e)||a.validate(e[t],s[t])}if(e=e||{},a.isPlainObject(t)?(n=t.data||[],u=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),n=a.extendDeep([],t.data),u=a.extendDeep({},t.layout),f=t._context),!d("width")||!d("height"))throw new Error("Height and width should be pixel values.");if(!d("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function h(t,n){return a.coerce(e,p,s,t,n)}var g=h("format"),v=h("width"),y=h("height"),m=h("scale"),x=h("setBackground"),b=h("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},u);v&&(w.width=v),y&&(w.height=y);var k=a.extendFlat({},f,{_exportedPlot:!0,staticPlot:!0,setBackground:x}),M=i.getRedrawFunc(_);function T(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function A(){return new Promise(function(t,e){var n=o(_,g,m),i=_._fullLayout.width,s=_._fullLayout.height;if(r.purge(_),document.body.removeChild(_),"svg"===g)return t(b?n:"data:image/svg+xml,"+encodeURIComponent(n));var c=document.createElement("canvas");c.id=a.randstr(),l({format:g,width:i,height:s,scale:m,canvas:c,svg:n,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){r.plot(_,n,w,k).then(M).then(T).then(A).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":163,"../snapshot/helpers":261,"../snapshot/svgtoimg":263,"../snapshot/tosvg":265,"./plot_api":195}],202:[function(t,e,n){"use strict";var r=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),l=r.isPlainObject,s=Array.isArray,c=r.isArrayOrTypedArray;function u(t,e,n,a,i,o){o=o||[];for(var f=Object.keys(t),d=0;dx.length&&a.push(p("unused",i,y.concat(x.length)));var M,T,A,L,S,C=x.length,P=Array.isArray(k);if(P&&(C=Math.min(C,k.length)),2===b.dimensions)for(T=0;Tx[T].length&&a.push(p("unused",i,y.concat(T,x[T].length)));var O=x[T].length;for(M=0;M<(P?Math.min(O,k[T].length):O);M++)A=P?k[T][M]:k,L=m[T][M],S=x[T][M],r.validate(L,A)?S!==L&&S!==+L&&a.push(p("dynamic",i,y.concat(T,M),L,S)):a.push(p("value",i,y.concat(T,M),L))}else a.push(p("array",i,y.concat(T),m[T]));else for(T=0;T1&&d.push(p("object","layout"))),a.supplyDefaults(h);for(var g=h._fullData,v=n.length,y=0;y0&&((b=T-o(v)-o(y))>A?_/b>L&&(m=v,x=y,L=_/b):_/T>L&&(m={val:v.val,pad:0},x={val:y.val,pad:0},L=_/T));if(d===p){var S=d-1,C=d+1;if(k)if(0===d)i=[0,1];else{var P=(d>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),O=d/(1-Math.min(.5,P/T));i=d>0?[0,O]:[O,0]}else i=M?[Math.max(0,S),Math.max(1,C)]:[S,C]}else k?(m.val>=0&&(m={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):M&&(m.val-L*o(m)<0&&(m={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),L=(x.val-m.val)/(T-o(m)-o(x)),i=[m.val-L*o(m),x.val+L*o(x)];return h&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function s(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function c(t,e){var n,r,a,i=e._id,o=t._fullData,l=t._fullLayout,s=[],c=[];function d(t,e){for(n=0;n=n&&(c.extrapad||!o)){l=!1;break}a(e,c.val)&&c.pad<=n&&(o||!c.extrapad)&&(t.splice(s,1),s--)}if(l){var u=i&&0===e;t.push({val:e,pad:u?0:n,extrapad:!u&&o})}}function p(t){return r(t)&&Math.abs(t)=e}e.exports={getAutoRange:l,makePadFn:s,doAutoRange:function(t,e){if(e.autorange){e.range=l(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l);var n=e._input,r={};r[e._attr+".range"]=e.range,r[e._attr+".autorange"]=e.autorange,o.call("_storeDirectGUIEdit",t.layout,t._fullLayout._preGUI,r),n.range=e.range.slice(),n.autorange=e.autorange}var i=e._anchorAxis;if(i&&i.rangeslider){var s=i.rangeslider[e._name];s&&"auto"===s.rangemode&&(s.range=l(t,e)),i._input.rangeslider[e._name]=a.extendFlat({},s)}},findExtremes:function(t,e,n){n||(n={});t._m||t.setScale();var a,o,l,s,c,d,h,g,v,y=[],m=[],x=e.length,b=n.padded||!1,_=n.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function M(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var T=M((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),A=M((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),L=M(n.vpadplus||n.vpad),S=M(n.vpadminus||n.vpad);if(!k){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=O;a--)P(a);return{min:y,max:m}},concatExtremes:c}},{"../../constants/numerical":142,"../../lib":163,"../../registry":257,"fast-isnumeric":11}],208:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),l=t("../../lib"),s=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),d=t("./layout_attributes"),p=t("./clean_ticks"),h=t("../../constants/numerical"),g=h.ONEAVGYEAR,v=h.ONEAVGMONTH,y=h.ONEDAY,m=h.ONEHOUR,x=h.ONEMIN,b=h.ONESEC,_=h.MINUS_SIGN,w=h.BADNUM,k=t("../../constants/alignment").MID_SHIFT,M=t("../../constants/alignment").LINE_SPACING,T=e.exports={};T.setConvert=t("./set_convert");var A=t("./axis_autotype"),L=t("./axis_ids");T.id2name=L.id2name,T.name2id=L.name2id,T.cleanId=L.cleanId,T.list=L.list,T.listIds=L.listIds,T.getFromId=L.getFromId,T.getFromTrace=L.getFromTrace;var S=t("./autorange");T.getAutoRange=S.getAutoRange,T.findExtremes=S.findExtremes,T.coerceRef=function(t,e,n,r,a,i){var o=r.charAt(r.length-1),s=n._fullLayout._subplots[o+"axis"],c=r+"ref",u={};return a||(a=s[0]||i),i||(i=a),u[c]={valType:"enumerated",values:s.concat(i?[i]:[]),dflt:a},l.coerce(t,e,u,c)},T.coercePosition=function(t,e,n,r,a,i){var o,s;if("paper"===r||"pixel"===r)o=l.ensureNumber,s=n(a,i);else{var c=T.getFromId(e,r);s=n(a,i=c.fraction2r(i)),o=c.cleanPos}t[a]=o(s)},T.cleanPosition=function(t,e,n){return("paper"===n||"pixel"===n?l.ensureNumber:T.getFromId(e,n).cleanPos)(t)};var C=T.getDataConversions=function(t,e,n,r){var a,i="x"===n||"y"===n||"z"===n?n:r;if(Array.isArray(i)){if(a={type:A(r),_categories:[]},T.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.saveRangeInitial=function(t,e){for(var n=T.list(t,"",!0),r=!1,a=0;a.3*d||u(r)||u(i))){var p=n.dtick/2;t+=t+p.8){var o=Number(n.substr(1));i.exactYears>.8&&o%12==0?t=T.tickIncrement(t,"M6","reverse")+1.5*y:i.exactMonths>.8?t=T.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var s=T.tickIncrement(t,n);if(s<=r)return s}return t}(x,t,m,c,i)),v=x,0;v<=u;)v=T.tickIncrement(v,m,!1,i),0;return{start:e.c2r(x,0,i),end:e.c2r(v,0,i),size:m,_dataSpan:u-c}},T.prepTicks=function(t){var e=l.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var n,r=t.nticks;r||("category"===t.type||"multicategory"===t.type?(n=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/n):(n="y"===t._id.charAt(0)?40:80,r=l.constrain(t._length/n,4,9)+1),"radialaxis"===t._name&&(r*=2)),"array"===t.tickmode&&(r*=100),T.autoTicks(t,Math.abs(e[1]-e[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),B(t)},T.calcTicks=function(t){T.prepTicks(t);var e=l.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e=t.tickvals,n=t.ticktext,r=new Array(e.length),a=l.simpleMap(t.range,t.r2l),i=1.0001*a[0]-1e-4*a[1],o=1.0001*a[1]-1e-4*a[0],s=Math.min(i,o),c=Math.max(i,o),u=0;Array.isArray(n)||(n=[]);var f="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(var d=0;ds&&p=r:c<=r)&&!(i.length>s||c===o);c=T.tickIncrement(c,t.dtick,a,t.calendar))o=c,i.push(c);et(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(i.length),f=0;f10||"01-01"!==r.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&i<=10||e>=15*y)t._tickround="d";else if(e>=x&&i<=16||e>=m)t._tickround="M";else if(e>=b&&i<=19||e>=x)t._tickround="S";else{var o=t.l2r(n+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var l=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var s=Math.max(Math.abs(l[0]),Math.abs(l[1])),c=Math.floor(Math.log(s)/Math.LN10+.01);Math.abs(c)>3&&(U(t.exponentformat)&&!V(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function H(t,e,n){var r=t.tickfont||{};return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}T.autoTicks=function(t,e){var n;function r(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=l.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,n=r(10),t.dtick="M"+12*j(e,n,z)):i>v?(e/=v,t.dtick="M"+j(e,1,D)):i>y?(t.dtick=j(e,y,E),t.tick0=l.dateTick0(t.calendar,!0)):i>m?t.dtick=j(e,m,D):i>x?t.dtick=j(e,x,R):i>b?t.dtick=j(e,b,R):(n=r(10),t.dtick=j(e,n,z))}else if("log"===t.type){t.tick0=0;var o=l.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var s=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/s,n=r(10),t.dtick="L"+j(e,n,z)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type||"multicategory"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):et(t)?(t.tick0=0,n=1,t.dtick=j(e,n,F)):(t.tick0=0,n=r(10),t.dtick=j(e,n,z));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},T.tickIncrement=function(t,e,n,i){var o=n?-1:1;if(a(e))return t+o*e;var s=e.charAt(0),c=o*Number(e.substr(1));if("M"===s)return l.incrementMonth(t,c,i);if("L"===s)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===s){var u="D2"===e?I:N,f=t+.01*o,d=l.roundUp(l.mod(f,1),u,n);return Math.floor(f)+Math.log(r.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.r2l||Number,n=l.simpleMap(t.range,e),i=n[1]"+s,t._prevDateHead=s));e.text=c}(t,i,n,s):"log"===c?function(t,e,n,r,i){var o=t.dtick,s=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===i&&(i="");r&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,s),t,i,r);else if(a(o)||"D"===u&&l.mod(s+.01,1)<.1){var f=Math.round(s),d=Math.abs(f),p=t.exponentformat;"power"===p||U(p)&&V(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+d+"",e.fontSize*=1.25):("e"===p||"E"===p)&&d>2?e.text="1"+p+(f>0?"+":_)+d:(e.text=G(Math.pow(10,s),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,l.mod(s,1)))),e.fontSize*=.75}if("D1"===t.dtick){var h=String(e.text).charAt(0);"0"!==h&&"1"!==h||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(s<0?.5:.25)))}}(t,i,0,s,h):"category"===c?function(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n="");e.text=String(n)}(t,i):"multicategory"===c?function(t,e,n){var r=Math.round(e.x),a=t._categories[r]||[],i=void 0===a[1]?"":String(a[1]),o=void 0===a[0]?"":String(a[0]);n?e.text=o+" - "+i:(e.text=i,e.text2=o)}(t,i,n):et(t)?function(t,e,n,r,a){if("radians"!==t.thetaunit||n)e.text=G(e.x,t,a,r);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var n=function(t){var n=1;for(;!e(Math.round(t*n)/n,t);)n*=10;return n}(t),r=t*n,a=Math.abs(function t(n,r){return e(r,0)?n:t(r,n%r)}(r,n));return[Math.round(r/a),Math.round(n/a)]}(i);if(o[1]>=100)e.text=G(l.deg2rad(e.x),t,a,r);else{var s=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),s&&(e.text=_+e.text)}}}}(t,i,n,s,h):function(t,e,n,r,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,r)}(t,i,0,s,h),t.tickprefix&&!p(t.showtickprefix)&&(i.text=t.tickprefix+i.text),t.ticksuffix&&!p(t.showticksuffix)&&(i.text+=t.ticksuffix),"boundaries"===t.tickson||t.showdividers){var g=function(e){var n=t.l2p(e);return n>=0&&n<=t._length?e:null};i.xbnd=[g(i.x-.5),g(i.x+t.dtick-.5)]}return i},T.hoverLabelText=function(t,e,n){if(n!==w&&n!==e)return T.hoverLabelText(t,e)+" - "+T.hoverLabelText(t,n);var r="log"===t.type&&e<=0,a=T.tickText(t,t.c2l(r?-e:e),"hover").text;return r?0===e?"0":_+a:a};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function U(t){return"SI"===t||"B"===t}function V(t){return t>14||t<-15}function G(t,e,n,r){var i=t<0,o=e._tickround,s=n||e.exponentformat||"B",c=e._tickexponent,u=T.getTickFormat(e),f=e.separatethousands;if(r){var d={exponentformat:s,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};B(d),o=(Number(d._tickround)||0)+4,c=d._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,h=Math.pow(10,-o)/2;if("none"===s&&(c=0),(t=Math.abs(t))"+p+"":"B"===s&&9===c?t+="B":U(s)&&(t+=q[c/3+5]));return i?_+t:t}function Y(t,e){var n=t._id.charAt(0),r=t._tickAngles[e]||0,a=l.deg2rad(r),i=Math.sin(a),o=Math.cos(a),s=0,c=0;return t._selections[e].each(function(){var t=W(this),e=f.bBox(t.node()),n=e.width,r=e.height;s=Math.max(s,o*n,i*r),c=Math.max(c,i*n,o*r)}),{x:c,y:s}[n]}function Z(t){return[t.text,t.x,t.axInfo,t.font,t.fontSize,t.fontColor].join("_")}function X(t,e){var n=t.l2p(e);return n>1&&n=0,i=u(t,e[1])<=0;return(n||a)&&(r||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){n=r;break}break;case"log":for(e=0;e1)for(r=1;r2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),n=0,r=0,o={},l=0;l2*n}(t)?"category":function(t){if(!t)return!1;for(var e=0;er?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":257,"./constants":214}],212:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var l,s=n("categoryorder",a);"array"===s&&(l=n("categoryarray")),o||"array"!==s||(s=e.categoryorder="trace"),"trace"===s?e._initialCategories=[]:"array"===s?e._initialCategories=l.slice():(l=function(t,e){var n,r,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)n=e.axData;else for(n=[],r=0;rl*x)||k)for(n=0;nD&&NO&&(O=N);p/=(O-P)/(2*z),P=u.l2r(P),O=u.l2r(O),u.range=u._input.range=L=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function R(t,e,n,r,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+n+", "+r+")").attr("d",a+"Z")}function E(t,e,n){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+n+")").attr("d","M0,0Z")}function N(t,e,n,r,a,i){t.attr("d",r+"M"+n.l+","+n.t+"v"+n.h+"h"+n.w+"v-"+n.h+"h-"+n.w+"Z"),I(t,e,a,i)}function I(t,e,n,r){n||(t.transition().style("fill",r>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){r.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function j(t){L&&t.data&&t._context.showTips&&(l.notifier(l._(t,"Double-click to zoom back out"),"long"),L=!1)}function B(t){return"lasso"===t||"select"===t}function H(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,A)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(i){var n=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(n,t._onwheel),t._onwheel=e,t.addEventListener(n,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function U(t){var e=[];for(var n in t)e.push(t[n]);return e}e.exports={makeDragBox:function(t,e,n,i,c,p,L,S){var I,V,G,Y,Z,X,W,J,$,Q,K,tt,et,nt,rt,at,it,ot,lt,st,ct,ut=t._fullLayout._zoomlayer,ft=L+S==="nsew",dt=1===(L+S).length;function pt(){if(I=e.xaxis,V=e.yaxis,$=I._length,Q=V._length,W=I._offset,J=V._offset,(G={})[I._id]=I,(Y={})[V._id]=V,L&&S)for(var n=e.overlays,r=0;r-1&&w(a,t,Z,X,e.id,At),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===n&&dt){var l=L?V:I,c="s"===L||"w"===S?0:1,u=l._name+".range["+c+"]",d=function(t,e){var n,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,r.format("."+n+"g")(Math.pow(10,a))):(n=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,r.format("."+String(n)+"g")(a))}(l,c),p="left",h="middle";if(l.fixedrange)return;L?(h="n"===L?"top":"bottom","right"===l.side&&(p="right")):"e"===S&&(p="right"),t._context.showAxisRangeEntryBoxes&&r.select(gt).call(s.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(d),fill:l.tickfont?l.tickfont.color:"#444",horizontalAlign:p,verticalAlign:h}).on("edit",function(e){var n=l.d2r(e);void 0!==n&&o.call("_guiRelayout",t,u,n)})}}function Ct(e,n){if(t._transitioningWithDuration)return!1;var r=Math.max(0,Math.min($,e+vt)),a=Math.max(0,Math.min(Q,n+yt)),i=Math.abs(r-vt),o=Math.abs(a-yt);function l(){wt="",mt.r=mt.l,mt.t=mt.b,Mt.attr("d","M0,0Z")}mt.l=Math.min(vt,r),mt.r=Math.max(vt,r),mt.t=Math.min(yt,a),mt.b=Math.max(yt,a),rt?i>A||o>A?(wt="xy",i/$>o/Q?(o=i*Q/$,yt>a?mt.t=yt-o:mt.b=yt+o):(i=o*$/Q,vt>r?mt.l=vt-i:mt.r=vt+i),Mt.attr("d",H(mt))):l():!et||o10||n.scrollWidth-n.clientWidth>10)){clearTimeout(Rt);var r=-e.deltaY;if(isFinite(r)||(r=e.wheelDelta/10),isFinite(r)){var a,i=Math.exp(-Math.min(Math.max(r,-20),20)/200),o=Nt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(at){for(S||(s=.5),a=0;ag[1]-.01&&(e.domain=l),a.noneOrAll(t.domain,e.domain,l)}return n("layer"),e}},{"../../lib":163,"fast-isnumeric":11}],225:[function(t,e,n){"use strict";var r=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,n){void 0===n&&(n=r[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*n;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":140}],226:[function(t,e,n){"use strict";var r=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),l=t("../../lib/polygon"),s=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),d=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),h=p.MINSELECT,g=l.filter,v=l.tester;function y(t){return t._id}function m(t,e,n,r,a,i,o){var l,s,c,u,f,d,p,h,g,v=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,m=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var x=function(t,e){var n,r,a=t[0],i=-1,o=[];for(r=0;r0?function(t,e){var n,r,a,i=[];for(a=0;a0&&i.push(n);if(1===i.length&&i[0]===e.searchInfo&&(r=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=n.selectedpoints.length)>1)return!1}return 1===a}(l)&&(d=A(x))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",r)}function A(t){var e=t.searchInfo.cd[0].trace,n=t.pointNumber,r=t.pointNumbers,a=r.length>0?r[0]:n;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function L(t,e,n){var r,i,o,l;for(r=0;r-1&&m(e,A,a.xaxes,a.yaxes,a.subplot,a,V),"event"===n&&A.emit("plotly_selected",void 0);o.click(A,e)})},a.doneFn=function(){Y.remove(),s.done(Z).then(function(){s.clear(Z),a.gd.emit("plotly_selected",b),d&&a.selectionDefs&&(d.subtract=U,a.selectionDefs.push(d),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:C,selectOnClick:m}},{"../../components/color":45,"../../components/fx":84,"../../components/fx/helpers":80,"../../lib/clear_gl_canvases":150,"../../lib/polygon":175,"../../lib/throttle":185,"../../plot_api/subroutines":199,"../../registry":257,"./axis_ids":211,"./constants":214,polybooljs:18}],227:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,l=i.ms2DateTime,s=i.dateTime2ms,c=i.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,d=u.BADNUM,p=u.LOG_CLIP,h=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}function y(t){return null!=t}e.exports=function(t,e){e=e||{};var n=(t._id||"x").charAt(0);function u(e,n){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&n&&t.range&&2===t.range.length){var r=t.range[0],a=t.range[1];return.5*(r+a-2*p*Math.abs(r-a))}return d}function m(e,n,r){var o=s(e,r||t.calendar);if(o===d){if(!a(e))return d;e=+e;var l=Math.floor(10*i.mod(e+.05,1)),c=Math.round(e-l/10);o=s(new Date(c))+l/10}return o}function x(e,n,r){return l(e,n,r||t.calendar)}function b(e){return t._categories[Math.round(e)]}function _(e){if(y(e)){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var n=t._categories.length-1;return t._categoriesMap[e]=n,n}return d}function w(e){if(t._categoriesMap)return t._categoriesMap[e]}function k(t){var e=w(t);return void 0!==e?e:a(t)?+t:void 0}function M(e){return a(e)?r.round(t._b+t._m*e,2):d}function T(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=M,t.p2l=T,t.c2p="log"===t.type?function(t,e){return M(u(t,e))}:M,t.p2c="log"===t.type?function(t){return v(T(t))}:T,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=T,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,n){return t.l2p(t.d2r(e,n))},t.p2d=function(t){return v(T(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=T,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=m,t.c2d=t.c2r=t.l2d=t.l2r=x,t.d2p=t.r2p=function(e,n,r){return t.l2p(m(e,0,r))},t.p2d=t.p2r=function(t,e,n){return x(T(t),e,n)},t.cleanPos=function(e){return i.cleanDate(e,d,t.calendar)}):"category"===t.type?(t.d2c=t.d2l=_,t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var n=k(e);return void 0!==n?n:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(T(t))},t.r2p=t.d2p,t.p2r=T,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}):"multicategory"===t.type&&(t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var n=k(e);return void 0!==n?n:t.fraction2r(.5)},t.r2c_just_indices=w,t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(T(t))},t.r2p=t.d2p,t.p2r=T,t.cleanPos=function(t){return Array.isArray(t)||"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var n=t.r2l(t.range[0]),r=t.r2l(t.range[1]);return t.l2r(n+e*(r-n))},t.r2fraction=function(e){var n=t.r2l(t.range[0]),r=t.r2l(t.range[1]);return(t.r2l(e)-n)/(r-n)},t.cleanRange=function(e,r){r||(r={}),e||(e="range");var o,l,s=i.nestedProperty(t,e).get();if(l=(l="date"===t.type?i.dfltRange(t.calendar):"y"===n?h.DFLTRANGEY:r.dfltRange||h.DFLTRANGEX).slice(),s&&2===s.length)for("date"===t.type&&(s[0]=i.cleanDate(s[0],d,t.calendar),s[1]=i.cleanDate(s[1],d,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(s[o],t.calendar)){t[e]=l;break}if(t.r2l(s[0])===t.r2l(s[1])){var c=i.constrain(t.r2l(s[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);s[0]=t.l2r(c-1e3),s[1]=t.l2r(c+1e3);break}}else{if(!a(s[o])){if(!a(s[1-o])){t[e]=l;break}s[o]=s[1-o]*(o?10:.1)}if(s[o]<-f?s[o]=-f:s[o]>f&&(s[o]=f),s[0]===s[1]){var u=Math.max(1,Math.abs(1e-6*s[0]));s[0]-=u,s[1]+=u}}else i.nestedProperty(t,e).set(l)},t.setScale=function(r){var a=e._size;if(t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=r&&t._r?"_r":"range",l=t.calendar;t.cleanRange(o);var s=t.r2l(t[o][0],l),c=t.r2l(t[o][1],l);if("y"===n?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-c),t._b=-t._m*c):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,n){var r,a,o,l,s=t.type,c="date"===s&&e[n+"calendar"];if(n in e){if(r=e[n],l=e._length||i.minRowLength(r),i.isTypedArray(r)&&("linear"===s||"log"===s)){if(l===r.length)return r;if(r.subarray)return r.subarray(0,l)}if("multicategory"===s)return function(t,e){var n,r=new Array(e),a=new Array(e),o=[[0,{}],[0,{}]];if(i.isArrayOrTypedArray(t[0])&&i.isArrayOrTypedArray(t[1])){for(n=0;n rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,n._offset).call(i.setScale,1,1);var r=t.plot.selectAll(".scatterlayer .trace");r.selectAll(".point").call(i.setPointGroupScale,1,1),r.selectAll(".textpoint").call(i.setTextPointsScale,1,1),r.call(i.hideOutsideRangePoints,t)}function x(e,n){var r,l,s,u=g[e.xaxis._id],f=g[e.yaxis._id],d=[];if(u){l=(r=t._fullLayout[u.axisName])._r,s=u.to,d[0]=(l[0]*(1-n)+n*s[0]-l[0])/(l[1]-l[0])*e.xaxis._length;var p=l[1]-l[0],h=s[1]-s[0];r.range[0]=l[0]*(1-n)+n*s[0],r.range[1]=l[1]*(1-n)+n*s[1],d[2]=e.xaxis._length*(1-n+n*h/p)}else d[0]=0,d[2]=e.xaxis._length;if(f){l=(r=t._fullLayout[f.axisName])._r,s=f.to,d[1]=(l[1]*(1-n)+n*s[1]-l[1])/(l[0]-l[1])*e.yaxis._length;var v=l[1]-l[0],y=s[1]-s[0];r.range[0]=l[0]*(1-n)+n*s[0],r.range[1]=l[1]*(1-n)+n*s[1],d[3]=e.yaxis._length*(1-n+n*y/v)}else d[1]=0,d[3]=e.yaxis._length;!function(e,n){var r,i=[e._id,n._id];function l(e,n,a){for(r=0;rn.duration?(function(){for(var e={},n=0;n0&&(a["_"+n+"axes"]||{})[e])return a;if((a[n+"axis"]||n)===e){if(o(a,n))return a;if((a[n]||[]).length||a[n+"0"])return a}}}(e,n,l);if(!s)return;if("histogram"===s.type&&l==={v:"y",h:"x"}[s.orientation||"v"])return void(t.type="linear");var c,u=l+"calendar",f=s[u],d={noMultiCategory:!r(s,"cartesian")||r(s,"noMultiCategory")};if(o(s,l)){var p=i(s),h=[];for(c=0;c0?".":"")+i;a.isPlainObject(o)?s(o,e,l,r+1):e(l,i,o)}})}n.manageCommandObserver=function(t,e,r,o){var l={},s=!0;e&&e._commandObserver&&(l=e._commandObserver),l.cache||(l.cache={}),l.lookupTable={};var c=n.hasSimpleAPICommandBindings(t,r,l.lookupTable);if(e&&e._commandObserver){if(c)return l;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,l}if(c){i(t,c,l.cache),l.check=function(){if(s){var e=i(t,c,l.cache);return e.changed&&o&&void 0!==l.lookupTable[e.value]&&(l.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:l.lookupTable[e.value]})).then(l.enable,l.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;fa*Math.PI/180}return!1},n.getPath=function(){return r.geo.path().projection(n)},n.getBounds=function(t){return n.getPath().bounds(t)},n.fitExtent=function(t,e){var r=t[1][0]-t[0][0],a=t[1][1]-t[0][1],i=n.clipExtent&&n.clipExtent();n.scale(150).translate([0,0]),i&&n.clipExtent(null);var o=n.getBounds(e),l=Math.min(r/(o[1][0]-o[0][0]),a/(o[1][1]-o[0][1])),s=+t[0][0]+(r-l*(o[1][0]+o[0][0]))/2,c=+t[0][1]+(a-l*(o[1][1]+o[0][1]))/2;return i&&n.clipExtent(i),n.scale(150*l).translate([s,c])},n.precision(g.precision),a&&n.clipAngle(a-g.clipPad);return n}(e);u.center([c.lon-s.lon,c.lat-s.lat]).rotate([-s.lon,-s.lat,s.roll]).parallels(l.parallels);var f=[[n.l+n.w*o.x[0],n.t+n.h*(1-o.y[1])],[n.l+n.w*o.x[1],n.t+n.h*(1-o.y[0])]],d=e.lonaxis,p=e.lataxis,h=function(t,e){var n=g.clipPad,r=t[0]+n,a=t[1]-n,i=e[0]+n,o=e[1]-n;r>0&&a<0&&(a+=360);var l=(a-r)/4;return{type:"Polygon",coordinates:[[[r,i],[r,o],[r+l,o],[r+2*l,o],[r+3*l,o],[a,o],[a,i],[a-l,i],[a-2*l,i],[a-3*l,i],[r,i]]]}}(d.range,p.range);u.fitExtent(f,h);var v=this.bounds=u.getBounds(h),y=this.fitScale=u.scale(),m=u.translate();if(!isFinite(v[0][0])||!isFinite(v[0][1])||!isFinite(v[1][0])||!isFinite(v[1][1])||isNaN(m[0])||isNaN(m[0])){for(var x=this.graphDiv,b=["projection.rotation","center","lonaxis.range","lataxis.range"],_="Invalid geo settings, relayout'ing to default view.",w={},k=0;k-1&&p(r.event,i,[n.xaxis],[n.yaxis],n.id,g),c.indexOf("event")>-1&&s.click(i,r.event))})}function v(t){return n.projection.invert([t[0]+n.xaxis._offset,t[1]+n.yaxis._offset])}},x.makeFramework=function(){var t=this,e=t.graphDiv,n=e._fullLayout,a="clip"+n._uid+t.id;t.clipDef=n._clips.append("clipPath").attr("id",a),t.clipRect=t.clipDef.append("rect"),t.framework=r.select(t.container).append("g").attr("class","geo "+t.id).call(l.setClipUrl,a,e),t.project=function(e){var n=t.projection(e);return n?[n[0]-t.xaxis._offset,n[1]-t.yaxis._offset]:[null,null]},t.xaxis={_id:"x",c2p:function(e){return t.project(e)[0]}},t.yaxis={_id:"y",c2p:function(e){return t.project(e)[1]}},t.mockAxis={type:"linear",showexponent:"all",exponentformat:"B"},u.setConvert(t.mockAxis,n)},x.saveViewInitial=function(t){var e=t.center||{},n=t.projection,r=n.rotation||{};t._isScoped?this.viewInitial={"center.lon":e.lon,"center.lat":e.lat,"projection.scale":n.scale}:t._isClipped?this.viewInitial={"projection.scale":n.scale,"projection.rotation.lon":r.lon,"projection.rotation.lat":r.lat}:this.viewInitial={"center.lon":e.lon,"center.lat":e.lat,"projection.scale":n.scale,"projection.rotation.lon":r.lon}},x.render=function(){var t,e=this.projection,n=e.getPath();function r(t){var n=e(t.lonlat);return n?"translate("+n[0]+","+n[1]+")":null}function a(t){return e.isLonLatOverEdges(t.lonlat)?"none":null}for(t in this.basePaths)this.basePaths[t].attr("d",n);for(t in this.dataPaths)this.dataPaths[t].attr("d",function(t){return n(t.geojson)});for(t in this.dataPoints)this.dataPoints[t].attr("display",a).attr("transform",r)}},{"../../components/color":45,"../../components/dragelement":63,"../../components/drawing":66,"../../components/fx":84,"../../lib":163,"../../lib/topojson_utils":187,"../../registry":257,"../cartesian/axes":208,"../cartesian/select":226,"../plots":249,"./constants":237,"./projections":243,"./zoom":244,d3:9,"topojson-client":28}],239:[function(t,e,n){"use strict";var r=t("./geo"),a=t("../../plots/get_data").getSubplotCalcData,i=t("../../lib").counterRegex,o="geo";n.name=o,n.attr=o,n.idRoot=o,n.idRegex=n.attrRegex=i(o),n.attributes=t("./layout/attributes"),n.layoutAttributes=t("./layout/layout_attributes"),n.supplyLayoutDefaults=t("./layout/defaults"),n.plot=function(t){var e=t._fullLayout,n=t.calcdata,i=e._subplots.geo;void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var l=0;l0&&k<0&&(k+=360);var M,T,A,L=(w+k)/2;if(!c){var S=u?l.projRotate:[L,0,0];M=n("projection.rotation.lon",S[0]),n("projection.rotation.lat",S[1]),n("projection.rotation.roll",S[2]),n("showcoastlines",!u)&&(n("coastlinecolor"),n("coastlinewidth")),n("showocean")&&n("oceancolor")}(c?(T=-96.6,A=38.7):(T=u?L:M,A=(_[0]+_[1])/2),n("center.lon",T),n("center.lat",A),f)&&n("projection.parallels",l.projParallels||[0,60]);n("projection.scale"),n("showland")&&n("landcolor"),n("showlakes")&&n("lakecolor"),n("showrivers")&&(n("rivercolor"),n("riverwidth")),n("showcountries",u&&"usa"!==i)&&(n("countrycolor"),n("countrywidth")),("usa"===i||"north america"===i&&50===r)&&(n("showsubunits",!0),n("subunitcolor"),n("subunitwidth")),u||n("showframe",!0)&&(n("framecolor"),n("framewidth")),n("bgcolor")}e.exports=function(t,e,n){r(t,e,n,{type:"geo",attributes:i,handleDefaults:l,partition:"y"})}},{"../../subplot_defaults":256,"../constants":237,"./layout_attributes":242}],242:[function(t,e,n){"use strict";var r=t("../../../components/color/attributes"),a=t("../../domain").attributes,i=t("../constants"),o=t("../../../plot_api/edit_types").overrideAll,l={range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},showgrid:{valType:"boolean",dflt:!1},tick0:{valType:"number"},dtick:{valType:"number"},gridcolor:{valType:"color",dflt:r.lightLine},gridwidth:{valType:"number",min:0,dflt:1}};(e.exports=o({domain:a({name:"geo"},{}),resolution:{valType:"enumerated",values:[110,50],dflt:110,coerceNumber:!0},scope:{valType:"enumerated",values:Object.keys(i.scopeDefaults),dflt:"world"},projection:{type:{valType:"enumerated",values:Object.keys(i.projNames)},rotation:{lon:{valType:"number"},lat:{valType:"number"},roll:{valType:"number"}},parallels:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},scale:{valType:"number",min:0,dflt:1}},center:{lon:{valType:"number"},lat:{valType:"number"}},showcoastlines:{valType:"boolean"},coastlinecolor:{valType:"color",dflt:r.defaultLine},coastlinewidth:{valType:"number",min:0,dflt:1},showland:{valType:"boolean",dflt:!1},landcolor:{valType:"color",dflt:i.landColor},showocean:{valType:"boolean",dflt:!1},oceancolor:{valType:"color",dflt:i.waterColor},showlakes:{valType:"boolean",dflt:!1},lakecolor:{valType:"color",dflt:i.waterColor},showrivers:{valType:"boolean",dflt:!1},rivercolor:{valType:"color",dflt:i.waterColor},riverwidth:{valType:"number",min:0,dflt:1},showcountries:{valType:"boolean"},countrycolor:{valType:"color",dflt:r.defaultLine},countrywidth:{valType:"number",min:0,dflt:1},showsubunits:{valType:"boolean"},subunitcolor:{valType:"color",dflt:r.defaultLine},subunitwidth:{valType:"number",min:0,dflt:1},showframe:{valType:"boolean"},framecolor:{valType:"color",dflt:r.defaultLine},framewidth:{valType:"number",min:0,dflt:1},bgcolor:{valType:"color",dflt:r.background},lonaxis:l,lataxis:l},"plot","from-root")).uirevision={valType:"any",editType:"none"}},{"../../../components/color/attributes":44,"../../../plot_api/edit_types":191,"../../domain":234,"../constants":237}],243:[function(t,e,n){"use strict";e.exports=function(t){function e(t,e){return{type:"Feature",id:t.id,properties:t.properties,geometry:n(t.geometry,e)}}function n(e,r){if(!e)return null;if("GeometryCollection"===e.type)return{type:"GeometryCollection",geometries:object.geometries.map(function(t){return n(t,r)})};if(!c.hasOwnProperty(e.type))return null;var a=c[e.type];return t.geo.stream(e,r(a)),a.result()}t.geo.project=function(t,e){var a=e.stream;if(!a)throw new Error("not yet supported");return(t&&r.hasOwnProperty(t.type)?r[t.type]:n)(t,a)};var r={Feature:e,FeatureCollection:function(t,n){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,n)})}}},a=[],i=[],o={point:function(t,e){a.push([t,e])},result:function(){var t=a.length?a.length<2?{type:"Point",coordinates:a[0]}:{type:"MultiPoint",coordinates:a}:null;return a=[],t}},l={lineStart:u,point:function(t,e){a.push([t,e])},lineEnd:function(){a.length&&(i.push(a),a=[])},result:function(){var t=i.length?i.length<2?{type:"LineString",coordinates:i[0]}:{type:"MultiLineString",coordinates:i}:null;return i=[],t}},s={polygonStart:u,lineStart:u,point:function(t,e){a.push([t,e])},lineEnd:function(){var t=a.length;if(t){do{a.push(a[0].slice())}while(++t<4);i.push(a),a=[]}},polygonEnd:u,result:function(){if(!i.length)return null;var t=[],e=[];return i.forEach(function(n){!function(t){if((e=t.length)<4)return!1;for(var e,n=0,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++nr^p>r&&n<(d-c)*(r-u)/(p-u)+c&&(a=!a)}return a}(t[0],n))return t.push(e),!0})||t.push([e])}),i=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},c={Point:o,MultiPoint:o,LineString:l,MultiLineString:l,Polygon:s,MultiPolygon:s,Sphere:s};function u(){}var f=1e-6,d=f*f,p=Math.PI,h=p/2,g=(Math.sqrt(p),p/180),v=180/p;function y(t){return t>1?h:t<-1?-h:Math.asin(t)}function m(t){return t>1?0:t<-1?p:Math.acos(t)}var x=t.geo.projection,b=t.geo.projectionMutator;function _(t,e){var n=(2+h)*Math.sin(e);e/=2;for(var r=0,a=1/0;r<10&&Math.abs(a)>f;r++){var i=Math.cos(e);e-=a=(e+Math.sin(e)*(i+2)-n)/(2*i*(1+i))}return[2/Math.sqrt(p*(4+p))*t*(1+Math.cos(e)),2*Math.sqrt(p/(4+p))*Math.sin(e)]}t.geo.interrupt=function(e){var n,r=[[[[-p,0],[0,h],[p,0]]],[[[-p,0],[0,-h],[p,0]]]];function a(t,n){for(var a=n<0?-1:1,i=r[+(n<0)],o=0,l=i.length-1;oi[o][2][0];++o);var s=e(t-i[o][1][0],n);return s[0]+=e(i[o][1][0],a*n>a*i[o][0][1]?i[o][0][1]:n)[0],s}e.invert&&(a.invert=function(t,i){for(var o=n[+(i<0)],l=r[+(i<0)],c=0,u=o.length;c=0;--a){var o=r[1][a],s=180*o[0][0]/p,c=180*o[0][1]/p,u=180*o[1][1]/p,f=180*o[2][0]/p,d=180*o[2][1]/p;n.push(l([[f-e,d-e],[f-e,u+e],[s+e,u+e],[s+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(n)]}}(),s)},a},i.lobes=function(t){return arguments.length?(r=t.map(function(t){return t.map(function(t){return[[t[0][0]*p/180,t[0][1]*p/180],[t[1][0]*p/180,t[1][1]*p/180],[t[2][0]*p/180,t[2][1]*p/180]]})}),n=r.map(function(t){return t.map(function(t){var n,r=e(t[0][0],t[0][1])[0],a=e(t[2][0],t[2][1])[0],i=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return i>o&&(n=i,i=o,o=n),[[r,i],[a,o]]})}),i):r.map(function(t){return t.map(function(t){return[[180*t[0][0]/p,180*t[0][1]/p],[180*t[1][0]/p,180*t[1][1]/p],[180*t[2][0]/p,180*t[2][1]/p]]})})},i},_.invert=function(t,e){var n=.5*e*Math.sqrt((4+p)/p),r=y(n),a=Math.cos(r);return[t/(2/Math.sqrt(p*(4+p))*(1+a)),y((r+n*(a+2))/(2+h))]},(t.geo.eckert4=function(){return x(_)}).raw=_;var w=t.geo.azimuthalEqualArea.raw;function k(t,e){if(arguments.length<2&&(e=t),1===e)return w;if(e===1/0)return M;function n(n,r){var a=w(n/e,r);return a[0]*=t,a}return n.invert=function(n,r){var a=w.invert(n/t,r);return a[0]*=e,a},n}function M(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function T(t,e){return[3*t/(2*p)*Math.sqrt(p*p/3-e*e),e]}function A(t,e){return[t,1.25*Math.log(Math.tan(p/4+.4*e))]}function L(t){return function(e){var n,r=t*Math.sin(e),a=30;do{e-=n=(e+Math.sin(e)-r)/(1+Math.cos(e))}while(Math.abs(n)>f&&--a>0);return e/2}}M.invert=function(t,e){var n=2*y(e/2);return[t*Math.cos(n/2)/Math.cos(n),n]},(t.geo.hammer=function(){var t=2,e=b(k),n=e(t);return n.coefficient=function(n){return arguments.length?e(t=+n):t},n}).raw=k,T.invert=function(t,e){return[2/3*p*t/Math.sqrt(p*p/3-e*e),e]},(t.geo.kavrayskiy7=function(){return x(T)}).raw=T,A.invert=function(t,e){return[t,2.5*Math.atan(Math.exp(.8*e))-.625*p]},(t.geo.miller=function(){return x(A)}).raw=A,L(p);var S=function(t,e,n){var r=L(n);function a(n,a){return[t*n*Math.cos(a=r(a)),e*Math.sin(a)]}return a.invert=function(r,a){var i=y(a/e);return[r/(t*Math.cos(i)),y((2*i+Math.sin(2*i))/n)]},a}(Math.SQRT2/h,Math.SQRT2,p);function C(t,e){var n=e*e,r=n*n;return[t*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791)),e*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))]}(t.geo.mollweide=function(){return x(S)}).raw=S,C.invert=function(t,e){var n,r=e,a=25;do{var i=r*r,o=i*i;r-=n=(r*(1.007226+i*(.015085+o*(.028874*i-.044475-.005916*o)))-e)/(1.007226+i*(.045255+o*(.259866*i-.311325-.005916*11*o)))}while(Math.abs(n)>f&&--a>0);return[t/(.8707+(i=r*r)*(i*(i*i*i*(.003971-.001529*i)-.013791)-.131979)),r]},(t.geo.naturalEarth=function(){return x(C)}).raw=C;var P=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];function O(t,e){var n,r=Math.min(18,36*Math.abs(e)/p),a=Math.floor(r),i=r-a,o=(n=P[a])[0],l=n[1],s=(n=P[++a])[0],c=n[1],u=(n=P[Math.min(19,++a)])[0],f=n[1];return[t*(s+i*(u-o)/2+i*i*(u-2*s+o)/2),(e>0?h:-h)*(c+i*(f-l)/2+i*i*(f-2*c+l)/2)]}function z(t,e){return[t*Math.cos(e),e]}function D(t,e){var n,r=Math.cos(e),a=(n=m(r*Math.cos(t/=2)))?n/Math.sin(n):1;return[2*r*Math.sin(t)*a,Math.sin(e)*a]}function R(t,e){var n=D(t,e);return[(n[0]+t/h)/2,(n[1]+e)/2]}P.forEach(function(t){t[1]*=1.0144}),O.invert=function(t,e){var n=e/h,r=90*n,a=Math.min(18,Math.abs(r/5)),i=Math.max(0,Math.floor(a));do{var o=P[i][1],l=P[i+1][1],s=P[Math.min(19,i+2)][1],c=s-o,u=s-2*l+o,f=2*(Math.abs(n)-l)/c,p=u/c,y=f*(1-p*f*(1-2*p*f));if(y>=0||1===i){r=(e>=0?5:-5)*(y+a);var m,x=50;do{y=(a=Math.min(18,Math.abs(r)/5))-(i=Math.floor(a)),o=P[i][1],l=P[i+1][1],s=P[Math.min(19,i+2)][1],r-=(m=(e>=0?h:-h)*(l+y*(s-o)/2+y*y*(s-2*l+o)/2)-e)*v}while(Math.abs(m)>d&&--x>0);break}}while(--i>=0);var b=P[i][0],_=P[i+1][0],w=P[Math.min(19,i+2)][0];return[t/(_+y*(w-b)/2+y*y*(w-2*_+b)/2),r*g]},(t.geo.robinson=function(){return x(O)}).raw=O,z.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return x(z)}).raw=z,D.invert=function(t,e){if(!(t*t+4*e*e>p*p+f)){var n=t,r=e,a=25;do{var i,o=Math.sin(n),l=Math.sin(n/2),s=Math.cos(n/2),c=Math.sin(r),u=Math.cos(r),d=Math.sin(2*r),h=c*c,g=u*u,v=l*l,y=1-g*s*s,x=y?m(u*s)*Math.sqrt(i=1/y):i=0,b=2*x*u*l-t,_=x*c-e,w=i*(g*v+x*u*s*h),k=i*(.5*o*d-2*x*c*l),M=.25*i*(d*l-x*c*g*o),T=i*(h*s+x*v*u),A=k*M-T*w;if(!A)break;var L=(_*k-b*T)/A,S=(b*M-_*w)/A;n-=L,r-=S}while((Math.abs(L)>f||Math.abs(S)>f)&&--a>0);return[n,r]}},(t.geo.aitoff=function(){return x(D)}).raw=D,R.invert=function(t,e){var n=t,r=e,a=25;do{var i,o=Math.cos(r),l=Math.sin(r),s=Math.sin(2*r),c=l*l,u=o*o,d=Math.sin(n),p=Math.cos(n/2),g=Math.sin(n/2),v=g*g,y=1-u*p*p,x=y?m(o*p)*Math.sqrt(i=1/y):i=0,b=.5*(2*x*o*g+n/h)-t,_=.5*(x*l+r)-e,w=.5*i*(u*v+x*o*p*c)+.5/h,k=i*(d*s/4-x*l*g),M=.125*i*(s*g-x*l*u*d),T=.5*i*(c*p+x*v*o)+.5,A=k*M-T*w,L=(_*k-b*T)/A,S=(b*M-_*w)/A;n-=L,r-=S}while((Math.abs(L)>f||Math.abs(S)>f)&&--a>0);return[n,r]},(t.geo.winkel3=function(){return x(R)}).raw=R}},{}],244:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../lib"),i=t("../../registry"),o=Math.PI/180,l=180/Math.PI,s={cursor:"pointer"},c={cursor:"auto"};function u(t,e){return r.behavior.zoom().translate(e.translate()).scale(e.scale())}function f(t,e,n){var r=t.id,o=t.graphDiv,l=o.layout,s=l[r],c=o._fullLayout,u=c[r],f={};function d(t,e){var n=a.nestedProperty(u,t);n.get()!==e&&(n.set(e),a.nestedProperty(s,t).set(e),f[r+"."+t]=e)}n(d),d("projection.scale",e.scale()/t.fitScale),i.call("_storeDirectGUIEdit",l,c._preGUI,f),o.emit("plotly_relayout",f)}function d(t,e){var n=u(0,e);function a(n){var r=e.invert(t.midPt);n("center.lon",r[0]),n("center.lat",r[1])}return n.on("zoomstart",function(){r.select(this).style(s)}).on("zoom",function(){e.scale(r.event.scale).translate(r.event.translate),t.render()}).on("zoomend",function(){r.select(this).style(c),f(t,e,a)}),n}function p(t,e){var n,a,i,o,l,d,p,h,g,v=u(0,e),y=2;function m(t){return e.invert(t)}function x(n){var r=e.rotate(),a=e.invert(t.midPt);n("projection.rotation.lon",-r[0]),n("center.lon",a[0]),n("center.lat",a[1])}return v.on("zoomstart",function(){r.select(this).style(s),n=r.mouse(this),a=e.rotate(),i=e.translate(),o=a,l=m(n)}).on("zoom",function(){if(d=r.mouse(this),function(t){var n=m(t);if(!n)return!0;var r=e(n);return Math.abs(r[0]-t[0])>y||Math.abs(r[1]-t[1])>y}(n))return v.scale(e.scale()),void v.translate(e.translate());e.scale(r.event.scale),e.translate([i[0],r.event.translate[1]]),l?m(d)&&(h=m(d),p=[o[0]+(h[0]-l[0]),a[1],a[2]],e.rotate(p),o=p):l=m(n=d),g=!0,t.render()}).on("zoomend",function(){r.select(this).style(c),g&&f(t,e,x)}),v}function h(t,e){var n,a={r:e.rotate(),k:e.scale()},i=u(0,e),d=function(t){var e=0,n=arguments.length,a=[];for(;++eh?(i=(f>0?90:-90)-p,a=0):(i=Math.asin(f/h)*l-p,a=Math.sqrt(h*h-f*f));var g=180-i-2*p,y=(Math.atan2(d,u)-Math.atan2(c,a))*l,x=(Math.atan2(d,u)-Math.atan2(c,-a))*l,b=v(n[0],n[1],i,y),_=v(n[0],n[1],g,x);return b<=_?[i,y,n[2]]:[g,x,n[2]]}(k,n,S);isFinite(M[0])&&isFinite(M[1])&&isFinite(M[2])||(M=S),e.rotate(M),S=M}}else n=g(e,A=b);d.of(this,arguments)({type:"zoom"})}),T=d.of(this,arguments),p++||T({type:"zoomstart"})}).on("zoomend",function(){var n;r.select(this).style(c),h.call(i,"zoom",null),n=d.of(this,arguments),--p||n({type:"zoomend"}),f(t,e,y)}).on("zoom.redraw",function(){t.render()}),r.rebind(i,d,"on")}function g(t,e){var n=t.invert(e);return n&&isFinite(n[0])&&isFinite(n[1])&&function(t){var e=t[0]*o,n=t[1]*o,r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}(n)}function v(t,e,n,r){var a=y(n-t),i=y(r-e);return Math.sqrt(a*a+i*i)}function y(t){return(t%360+540)%360-180}function m(t,e,n){var r=n*o,a=t.slice(),i=0===e?1:0,l=2===e?1:2,s=Math.cos(r),c=Math.sin(r);return a[i]=t[i]*s-t[l]*c,a[l]=t[l]*s+t[i]*c,a}function x(t,e){for(var n=0,r=0,a=t.length;r=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),n.attr(i);var o=n.select(".js-link-to-tool"),l=n.select(".js-link-spacer"),u=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var n=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)n.on("click",function(){v.sendDataToCloud(t)});else{var r=window.location.pathname.split("/"),a=window.location.search;n.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+r[2].split(".")[0]+"/"+r[1]+a})}}(t,o),l.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,n=r.select(t).append("div").attr("id","hiddenform").style("display","none"),a=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var n=t._context.locale,r=!1,a={};function o(t){for(var n=!0,i=0;i1&&D.length>1){for(i.getComponentMethod("grid","sizeDefaults")(c,l),o=0;o15&&D.length>15&&0===l.shapes.length&&0===l.images.length,l._hasCartesian=l._has("cartesian"),l._hasGeo=l._has("geo"),l._hasGL3D=l._has("gl3d"),l._hasGL2D=l._has("gl2d"),l._hasTernary=l._has("ternary"),l._hasPie=l._has("pie"),v.linkSubplots(f,l,u,a),v.cleanPlot(f,l,u,a),h(l,a),l._preGUI||(l._preGUI={}),l._tracePreGUI||(l._tracePreGUI={});var F,j=l._tracePreGUI,B={};for(F in j)B[F]="old";for(o=0;o0){var f=1-2*l;r=Math.round(f*r),i=Math.round(f*i)}}var d=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;r1,g=!e.height&&Math.abs(n.height-i)>1;(g||h)&&(h&&(n.width=r),g&&(n.height=i)),t._initialAutoSize||(t._initialAutoSize={width:r,height:i}),v.sanitizeMargins(n)},v.supplyLayoutModuleDefaults=function(t,e,n,r){var a,o,l,c=i.componentsRegistry,u=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in c)(l=c[a]).includeBasePlot&&l.includeBasePlot(t,e);for(var d in u.length||u.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[d].sort(s.subplotSort);for(o=0;o.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0);var s=void 0!==n.xl?n.xl:n.x,c=void 0!==n.xr?n.xr:n.x,u=void 0!==n.yt?n.yt:n.y,f=void 0!==n.yb?n.yb:n.y;a[e]={l:{val:s,size:n.l+o},r:{val:c,size:n.r+o},b:{val:f,size:n.b+o},t:{val:u,size:n.t+o}},i[e]=1}else delete a[e],delete i[e];r._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),A(e);var n=e._size,r=JSON.stringify(n),o=e.margin,l=o.l,s=o.r,c=o.t,u=o.b,f=e._pushmargin,d=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var p in f)d[p]||delete f[p];for(var h in f.base={l:{val:0,size:l},r:{val:1,size:s},t:{val:1,size:c},b:{val:0,size:u}},f){var g=f[h].l||{},v=f[h].b||{},y=g.val,m=g.size,x=v.val,b=v.size;for(var _ in f){if(a(m)&&f[_].r){var w=f[_].r.val,k=f[_].r.size;if(w>y){var M=(m*w+(k-e.width)*y)/(w-y),T=(k*(1-y)+(m-e.width)*(1-w))/(w-y);M>=0&&T>=0&&M+T>l+s&&(l=M,s=T)}}if(a(b)&&f[_].t){var L=f[_].t.val,S=f[_].t.size;if(L>x){var C=(b*L+(S-e.height)*x)/(L-x),P=(S*(1-x)+(b-e.height)*(1-L))/(L-x);C>=0&&P>=0&&C+P>u+c&&(u=C,c=P)}}}}}if(n.l=Math.round(l),n.r=Math.round(s),n.t=Math.round(c),n.b=Math.round(u),n.p=Math.round(o.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,!e._replotting&&"{}"!==r&&r!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,n,r,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,l=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(s.isPlainObject(t)){var e,r,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if("string"==typeof(r=t[e+"src"])&&r.indexOf(":")>0&&!s.isPlainObject(t.stream))continue}else if("keepall"!==n&&"string"==typeof(r=t[e+"src"])&&r.indexOf(":")>0)continue;a[e]=c(t[e])}return a}return Array.isArray(t)?t.map(c):s.isTypedArray(t)?s.simpleMap(t,s.identity):s.isJSDate(t)?s.ms2DateTimeLocal(+t):t}var u={data:(i||[]).map(function(t){var n=c(t);return e&&delete n.fit,n})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),l&&(u.frames=c(l)),"object"===r?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var n,r,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(n=0;n0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var r,l,c=0,u=0;function f(){return c++,function(){var n;u++,p||u!==c||(n=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(n)))}}var h=t._fullLayout._basePlotModules,g=!1;if(n)for(l=0;l=0;l--)if(o[l].enabled){n._indexToPoints=o[l]._indexToPoints;break}r&&r.calc&&(i=r.calc(t,n))}Array.isArray(i)&&i[0]||(i=[{x:u,y:u}]),i[0].t||(i[0].t={}),i[0].trace=n,h[e]=i}}for(m&&L(c),a=0;a=0?d.angularAxis.domain:r.extent(k),S=Math.abs(k[1]-k[0]);T&&!M&&(S=0);var C=L.slice();A&&M&&(C[1]+=S);var P=d.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),d.angularAxis.ticksStep&&(P=(C[1]-C[0])/P);var O=d.angularAxis.ticksStep||(C[1]-C[0])/(P*(d.minorTicks+1));w&&(O=Math.max(Math.round(O),1)),C[2]||(C[2]=O);var z=r.range.apply(this,C);if(z=z.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=r.scale.linear().domain(C.slice(0,2)).range("clockwise"===d.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=A?S:0,"undefined"==typeof(t=r.select(this).select("svg.chart-root"))||t.empty()){var D=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),R=this.appendChild(this.ownerDocument.importNode(D.documentElement,!0));t=r.select(R)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var E,N=t.select(".chart-group"),I={fill:"none",stroke:d.tickColor},F={"font-size":d.font.size,"font-family":d.font.family,fill:d.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+d.font.outlineColor}).join(",")};if(d.showLegend){E=t.select(".legend-group").attr({transform:"translate("+[x,d.margin.top]+")"}).style({display:"block"});var j=p.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:E,elements:j,reverseOrder:d.legend.reverseOrder})})();var B=E.node().getBBox();x=Math.min(d.width-B.width-d.margin.left-d.margin.right,d.height-d.margin.top-d.margin.bottom)/2,x=Math.max(10,x),_=[d.margin.left+x,d.margin.top+x],n.range([0,x]),u.layout.radialAxis.domain=n.domain(),E.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else E=t.select(".legend-group").style({display:"none"});t.attr({width:d.width,height:d.height}).style({opacity:d.opacity}),N.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(d.width-(d.margin.left+d.margin.right+2*x+(B?B.width:0)))/2,(d.height-(d.margin.top+d.margin.bottom+2*x))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),t.select(".outer-group").attr("transform","translate("+H+")"),d.title&&d.title.text){var q=t.select("g.title-group text").style(F).text(d.title.text),U=q.node().getBBox();q.attr({x:_[0]-U.width/2,y:_[1]-x-20})}var V=t.select(".radial.axis-group");if(d.radialAxis.gridLinesVisible){var G=V.selectAll("circle.grid-circle").data(n.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(I),G.attr("r",n),G.exit().remove()}V.select("circle.outside-circle").attr({r:x}).style(I);var Y=t.select("circle.background-circle").attr({r:x}).style({fill:d.backgroundColor,stroke:d.stroke});function Z(t,e){return l(t)%360+d.orientation}if(d.radialAxis.visible){var X=r.svg.axis().scale(n).ticks(5).tickSize(5);V.call(X).attr({transform:"rotate("+d.radialAxis.orientation+")"}),V.selectAll(".domain").style(I),V.selectAll("g>text").text(function(t,e){return this.textContent+d.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===d.radialAxis.tickOrientation?"rotate("+-d.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),V.selectAll("g>line").style({stroke:"black"})}var W=t.select(".angular.axis-group").selectAll("g.angular-tick").data(z),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+Z(t)+")"}}).style({display:d.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(d.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(d.minorTicks+1)==0)}).style(I),J.selectAll(".minor").style({stroke:d.minorTickColor}),W.select("line.grid-line").attr({x1:d.tickLength?x-d.tickLength:0,x2:x}).style({display:d.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(F);var $=W.select("text.axis-text").attr({x:x+d.labelOffset,dy:i+"em",transform:function(t,e){var n=Z(t),r=x+d.labelOffset,a=d.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-n+" "+r+" 0)":"radial"==a?n<270&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(n<=180&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:d.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(d.minorTicks+1)!=0?"":w?w[t]+d.angularAxis.ticksSuffix:t+d.angularAxis.ticksSuffix}).style(F);d.angularAxis.rewriteTicks&&$.text(function(t,e){return e%(d.minorTicks+1)!=0?"":d.angularAxis.rewriteTicks(this.textContent,e)});var Q=r.max(N.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));E.attr({transform:"translate("+[x+Q,d.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||K){var et=[];p.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=l,r.container=tt.filter(function(t,n){return n==e}),r.geometry=t.geometry,r.orientation=d.orientation,r.direction=d.direction,r.index=e,et.push({data:t,geometryConfig:r})});var nt=r.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),rt=[];nt.forEach(function(t,e){"unstacked"===t.key?rt=rt.concat(t.values.map(function(t,e){return[t]})):rt.push(t.values)}),rt.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return a(o[n].defaultConfig(),t)});o[n]().config(r)()})}var at,it,ot=t.select(".guides-group"),lt=t.select(".tooltips-group"),st=o.tooltipPanel().config({container:lt,fontSize:8})(),ct=o.tooltipPanel().config({container:lt,fontSize:8})(),ut=o.tooltipPanel().config({container:lt,hasTick:!0})();if(!M){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});N.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos(Y).angle;ft.attr({x2:-x,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-d.orientation)%360;at=l.invert(r);var a=o.util.convertToCartesian(x+12,n+180);st.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var dt=ot.select("circle").style({stroke:"grey",fill:"none"});N.on("mousemove.radial-guide",function(t,e){var r=o.util.getMousePos(Y).radius;dt.attr({r:r}).style({opacity:.5}),it=n.invert(o.util.getMousePos(Y).radius);var a=o.util.convertToCartesian(r,d.radialAxis.orientation);ct.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){dt.style({opacity:0}),ut.hide(),st.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,n){var a=r.select(this),i=this.style.fill,l="black",s=this.style.opacity||1;if(a.attr({"data-opacity":s}),i&&"none"!==i){a.attr({"data-fill":i}),l=r.hsl(i).darker().toString(),a.style({fill:l,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};M&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=t.node().getBoundingClientRect(),p=[f.left+f.width/2-H[0]-d.left,f.top+f.height/2-H[1]-d.top];ut.config({color:l}).text(u),ut.move(p)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),l=r.hsl(i).darker().toString(),a.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=r.event.which)return!1;r.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var n=r.select(this),a=n.attr("data-fill");a?n.style({fill:a,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})})}(c),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),a(s.data[e],o.Axis.defaultConfig().data[0]),a(s.data[e],t)}),a(s.layout,o.Axis.defaultConfig().layout),a(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return n},d.angularScale=function(t){return l},d.svg=function(){return t},r.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:r.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6;return r.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180;return[e,t(r)]})},o.util.dataFromEquation=function(t,e,n){var a=e||6,i=[],o=[];r.range(0,360+a,a).forEach(function(e,n){var r=e*Math.PI/180,a=t(r);i.push(e),o.push(a)});var l={t:i,r:o};return n&&(l.name=n),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return r.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return r.zip(t,e).map(function(t,e){return r.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return-2===n},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180;return[t*Math.cos(n),t*Math.sin(n)]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=r.mouse(t.node()),n=e[0],a=e[1],i={};return i.x=n,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,n)+Math.PI)/Math.PI,i.radius=Math.sqrt(n*n+a*a),i},o.util.duplicatesCount=function(t){for(var e,n={},r={},a=0,i=t.length;a0)){var s=r.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({class:"line",d:u(l),transform:function(t,n){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return h.fill(n,a,i)},"fill-opacity":0,stroke:function(t,e){return h.stroke(n,a,i)},"stroke-width":function(t,e){return h["stroke-width"](n,a,i)},"stroke-dasharray":function(t,e){return h["stroke-dasharray"](n,a,i)},opacity:function(t,e){return h.opacity(n,a,i)},display:function(t,e){return h.display(n,a,i)}})}};var f=e.angularScale.range(),d=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=r.svg.arc().startAngle(function(t){return-d/2}).endAngle(function(t){return d/2}).innerRadius(function(t){return e.radialScale(s+(t[2]||0))}).outerRadius(function(t){return e.radialScale(s+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,n,a){r.select(this).attr({class:"mark arc",d:p,transform:function(t,n){return"rotate("+(e.orientation+l(t[0])+90)+")"}})};var h={fill:function(e,n,r){return t[r].data.color},stroke:function(e,n,r){return t[r].data.strokeColor},"stroke-width":function(e,n,r){return t[r].data.strokeSize+"px"},"stroke-dasharray":function(e,r,a){return n[t[a].data.strokeDash]},opacity:function(e,n,r){return t[r].data.opacity},display:function(e,n,r){return"undefined"==typeof t[r].data.visible||t[r].data.visible?"block":"none"}},g=r.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(h).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,n){t[n]||(t[n]={}),a(t[n],o.PolyChart.defaultConfig()),a(t[n],e)}),this):t},i.getColorScale=function(){},r.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:r.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=r.dispatch("hover");function n(){var e=t.legendConfig,i=t.data.map(function(t,n){return[].concat(t).map(function(t,r){var i=a({},e.elements[n]);return i.name=t,i.color=[].concat(e.elements[n].color)[r],i})}),o=r.merge(i);o=o.filter(function(t,n){return e.elements[n]&&(e.elements[n].visibleInLegend||"undefined"==typeof e.elements[n].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var l=e.container;("string"==typeof l||l.nodeName)&&(l=r.select(l));var s=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,d=l.classed("legend-group",!0).selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var h=r.range(o.length),g=r.scale[u?"linear":"ordinal"]().domain(h).range(s),v=r.scale[u?"linear":"ordinal"]().domain(h)[u?"range":"rangePoints"]([0,f]);if(u){var y=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var m=d.select(".legend-marks").selectAll("path.legend-mark").data(o);m.enter().append("path").classed("legend-mark",!0),m.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var n,a,i,o=t.symbol;return i=3*(a=c),"line"===(n=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=r.svg.symbolTypes.indexOf(n)?r.svg.symbol().type(n).size(i)():r.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),m.exit().remove()}var x=r.svg.axis().scale(v).orient("right"),b=d.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),n}return n.config=function(e){return arguments.length?(a(t,e),this):t},r.rebind(n,e,"on"),n},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,n,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){var r=(t=i.container.selectAll("g."+l).data([0])).enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return n=r.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=r.append("text").attr({dx:i.padding+s,dy:.3*+i.fontSize}),c};return c.text=function(a){var o=r.hsl(i.color).l,l=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":i.fontSize+"px"}).text(f);var d=i.padding,p=e.node().getBBox(),h={fill:i.color,stroke:l,"stroke-width":"2px"},g=p.width+2*d+s,v=p.height+2*d;return n.attr({d:"M"+[[s,-v/2],[s,-v/4],[i.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(h),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return a(i,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=a({},t);return[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]].forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",!0===r.dotVisible?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var r=i.indexOf(t.geometry);-1!=r&&(n.data[e].groupId=r)})}if(t.layout){var l=a({},t.layout);if([[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var s=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};r.entries(l.margin).forEach(function(t,e){u[c[s.indexOf(t.key)]]=t.value}),l.margin=u}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),n.layout=l}return n}};return t}},{"../../../constants/alignment":140,"../../../lib":163,d3:9}],254:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),l=t("./undo_manager"),s=a.extendDeepAll,c=e.exports={};c.framework=function(t){var e,n,a,i,u,f=new l;function d(n,l){return l&&(u=l),r.select(r.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?s(e,n):n,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return d.isPolar=!0,d.svg=function(){return a.svg()},d.getConfig=function(){return e},d.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},d.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},d.setUndoPoint=function(){var t,r,a=this,i=o.util.cloneJson(e);t=i,r=n,f.add({undo:function(){r&&a(r)},redo:function(){a(t)}}),n=o.util.cloneJson(i)},d.undo=function(){f.undo()},d.redo=function(){f.redo()},d},c.fillLayout=function(t){var e=r.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:n,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../../components/color":45,"../../../lib":163,"./micropolar":253,"./undo_manager":255,d3:9}],255:[function(t,e,n){"use strict";e.exports=function(){var t,e=[],n=-1,r=!1;function a(t,e){return t?(r=!0,t[e](),r=!1,this):this}return{add:function(t){return r?this:(e.splice(n+1,e.length-n),e.push(t),n=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var r=e[n];return r?(a(r,"undo"),n-=1,t&&t(r.undo),this):this},redo:function(){var r=e[n+1];return r?(a(r,"redo"),n+=1,t&&t(r.redo),this):this},clear:function(){e=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return n-1&&(u[d[n]].title={text:""});for(n=0;npath, .legendlines>path, .cbfill").each(function(){var t=r.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(s,"TOBESTRIPPED"));var n=this.style.stroke;n&&-1!==n.indexOf("url(")&&t.style("stroke",n.replace(s,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||d.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),d.node().setAttributeNS(l.xmlns,"xmlns",l.svg),d.node().setAttributeNS(l.xmlns,"xmlns:xlink",l.xlink),"svg"===e&&n&&(d.attr("width",n*h),d.attr("height",n*g),d.attr("viewBox","0 0 "+h+" "+g));var _=(new window.XMLSerializer).serializeToString(d.node());return _=function(t){var e=r.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),n}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":45,"../components/drawing":66,"../constants/xmlns_namespaces":143,"../lib":163,d3:9}],266:[function(t,e,n){"use strict";var r=t("../scattergeo/attributes"),a=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),o=t("../../plots/attributes"),l=t("../../lib/extend").extendFlat,s=r.marker.line;e.exports=l({locations:{valType:"data_array",editType:"calc"},locationmode:r.locationmode,z:{valType:"data_array",editType:"calc"},text:l({},r.text,{}),marker:{line:{color:s.color,width:l({},s.width,{dflt:1}),editType:"calc"},opacity:{valType:"number",arrayOk:!0,min:0,max:1,dflt:1,editType:"style"},editType:"calc"},selected:{marker:{opacity:r.selected.marker.opacity,editType:"plot"},editType:"plot"},unselected:{marker:{opacity:r.unselected.marker.opacity,editType:"plot"},editType:"plot"},hoverinfo:l({},o.hoverinfo,{editType:"calc",flags:["location","z","text","name"]})},a("",{cLetter:"z",editTypeOverride:"calc"}),{colorbar:i})},{"../../components/colorbar/attributes":46,"../../components/colorscale/attributes":52,"../../lib/extend":155,"../../plots/attributes":205,"../scattergeo/attributes":306}],267:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../constants/numerical").BADNUM,i=t("../../components/colorscale/calc"),o=t("../scatter/arrays_to_calcdata"),l=t("../scatter/calc_selection");e.exports=function(t,e){for(var n=e._length,s=new Array(n),c=0;c")}(t,f,o,d.mockAxis),[t]}},{"../../plots/cartesian/axes":208,"../scatter/fill_hover_text":287,"./attributes":266}],271:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../heatmap/colorbar"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style").style,r.styleOnSelect=t("./style").styleOnSelect,r.hoverPoints=t("./hover"),r.eventData=t("./event_data"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="choropleth",r.basePlotModule=t("../../plots/geo"),r.categories=["geo","noOpacity"],r.meta={},e.exports=r},{"../../plots/geo":239,"../heatmap/colorbar":275,"./attributes":266,"./calc":267,"./defaults":268,"./event_data":269,"./hover":270,"./plot":272,"./select":273,"./style":274}],272:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../lib"),i=t("../../lib/polygon"),o=t("../../lib/topojson_utils").getTopojsonFeatures,l=t("../../lib/geo_location_utils").locationToFeature,s=t("./style").style;function c(t,e){for(var n=t[0].trace,r=t.length,a=o(n,e),i=0;i0&&t[e+1][0]<0)return e;return null}switch(e="RUS"===s||"FJI"===s?function(t){var e;if(null===u(t))e=t;else for(e=new Array(t.length),a=0;ae?n[r++]=[t[a][0]+360,t[a][1]]:a===e?(n[r++]=t[a],n[r++]=[t[a][0],-90]):n[r++]=t[a];var o=i.tester(n);o.pts.pop(),c.push(o)}:function(t){c.push(i.tester(t))},o.type){case"MultiPolygon":for(n=0;nl&&T[v].gap;)v--;for(m=T[v].s,h=T.length-1;h>v;h--)T[h].s=m;for(;lA[u]&&u=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===n.xaxis&&i.yaxis===n.yaxis){i.opacity=void 0;break}}}}}},{}],286:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),l=t("./subtypes"),s=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),d=t("./line_shape_defaults"),p=t("./text_defaults"),h=t("./fillcolor_defaults");e.exports=function(t,e,n,g){function v(n,a){return r.coerce(t,e,i,n,a)}var y=s(t,e,g,v);if(y||(e.visible=!1),e.visible){var m=c(t,e,g,v),x=!m&&yG!=(I=z[P][1])>=G&&(R=z[P-1][0],E=z[P][0],I-N&&(D=R+(E-R)*(G-N)/(I-N),H=Math.min(H,D),q=Math.max(q,D)));H=Math.max(H,0),q=Math.min(q,d._length);var Y=l.defaultLine;return l.opacity(f.fillcolor)?Y=f.fillcolor:l.opacity((f.line||{}).color)&&(Y=f.line.color),r.extendFlat(t,{distance:t.maxHoverDistance,x0:H,x1:q,y0:G,y1:G,color:Y,hovertemplate:"%{name}"}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":45,"../../components/fx":84,"../../lib":163,"../../registry":257,"./fill_hover_text":287,"./get_trace_color":289}],291:[function(t,e,n){"use strict";var r={},a=t("./subtypes");r.hasLines=a.hasLines,r.hasMarkers=a.hasMarkers,r.hasText=a.hasText,r.isBubble=a.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.crossTraceDefaults=t("./cross_trace_defaults"),r.calc=t("./calc").calc,r.crossTraceCalc=t("./cross_trace_calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./marker_colorbar"),r.style=t("./style").style,r.styleOnSelect=t("./style").styleOnSelect,r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.animatable=!0,r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],r.meta={},e.exports=r},{"../../plots/cartesian":220,"./arrays_to_calcdata":278,"./attributes":279,"./calc":280,"./cross_trace_calc":284,"./cross_trace_defaults":285,"./defaults":286,"./hover":290,"./marker_colorbar":297,"./plot":299,"./select":300,"./style":302,"./subtypes":303}],292:[function(t,e,n){"use strict";var r=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,l,s){var c=(t.marker||{}).color;(l("line.color",n),a(t,"line"))?i(t,e,o,l,{prefix:"line.",cLetter:"c",noScale:!0}):l("line.color",!r(c)&&c||n);l("line.width"),(s||{}).noDash||l("line.dash")}},{"../../components/colorscale/defaults":55,"../../components/colorscale/helpers":56,"../../lib":163}],293:[function(t,e,n){"use strict";var r=t("../../constants/numerical"),a=r.BADNUM,i=r.LOG_CLIP,o=i+.5,l=i-.5,s=t("../../lib"),c=s.segmentsIntersect,u=s.constrain,f=t("./constants");e.exports=function(t,e){var n,r,i,d,p,h,g,v,y,m,x,b,_,w,k,M,T,A,L=e.xaxis,S=e.yaxis,C="log"===L.type,P="log"===S.type,O=L._length,z=S._length,D=e.connectGaps,R=e.baseTolerance,E=e.shape,N="linear"===E,I=[],F=f.minTolerance,j=new Array(t.length),B=0;function H(e){var n=t[e];if(!n)return!1;var r=L.c2p(n.x),i=S.c2p(n.y);if(r===a){if(C&&(r=L.c2p(n.x,!0)),r===a)return!1;P&&i===a&&(r*=Math.abs(L._m*z*(L._m>0?o:l)/(S._m*O*(S._m>0?o:l)))),r*=1e3}if(i===a){if(P&&(i=S.c2p(n.y,!0)),i===a)return!1;i*=1e3}return[r,i]}function q(t,e,n,r){var a=n-t,i=r-e,o=.5-t,l=.5-e,s=a*a+i*i,c=a*o+i*l;if(c>0&&ctt||t[1]nt)return[u(t[0],K,tt),u(t[1],et,nt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===nt)||void 0)}function ot(t,e,n){return function(r,a){var i=at(r),o=at(a),l=[];if(i&&o&&it(i,o))return l;i&&l.push(i),o&&l.push(o);var c=2*s.constrain((r[t]+a[t])/2,e,n)-((i||r)[t]+(o||a)[t]);c&&((i&&o?c>0==i[t]>o[t]?i:o:i||o)[t]+=c);return l}}function lt(t){var e=t[0],n=t[1],r=e===j[B-1][0],a=n===j[B-1][1];if(!r||!a)if(B>1){var i=e===j[B-2][0],o=n===j[B-2][1];r&&(e===K||e===tt)&&i?o?B--:j[B-1]=t:a&&(n===et||n===nt)&&o?i?B--:j[B-1]=t:j[B++]=t}else j[B++]=t}function st(t){j[B-1][0]!==t[0]&&j[B-1][1]!==t[1]&<([Z,X]),lt(t),W=null,Z=X=0}function ct(t){if(T=t[0]/O,A=t[1]/z,G=t[0]tt?tt:0,Y=t[1]nt?nt:0,G||Y){if(B)if(W){var e=$(W,t);e.length>1&&(st(e[0]),j[B++]=e[1])}else J=$(j[B-1],t)[0],j[B++]=J;else j[B++]=[G||t[0],Y||t[1]];var n=j[B-1];G&&Y&&(n[0]!==G||n[1]!==Y)?(W&&(Z!==G&&X!==Y?lt(Z&&X?(r=W,i=(a=t)[0]-r[0],o=(a[1]-r[1])/i,(r[1]*a[0]-a[1]*r[0])/i>0?[o>0?K:tt,nt]:[o>0?tt:K,et]):[Z||G,X||Y]):Z&&X&<([Z,X])),lt([G,Y])):Z-G&&X-Y&<([G||Z,Y||X]),W=t,Z=G,X=Y}else W&&st($(W,t)[0]),j[B++]=t;var r,a,i,o}for("linear"===E||"spline"===E?$=function(t,e){for(var n=[],r=0,a=0;a<4;a++){var i=rt[a],o=c(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!r||Math.abs(o.x-n[0][0])>1||Math.abs(o.y-n[0][1])>1)&&(o=[o.x,o.y],r&&V(o,t)U(h,ut))break;i=h,(_=y[0]*v[0]+y[1]*v[1])>x?(x=_,d=h,g=!1):_=t.length||!h)break;ct(h),r=h}}else ct(d)}W&<([Z||W[0],X||W[1]]),I.push(j.slice(0,B))}return I}},{"../../constants/numerical":142,"../../lib":163,"./constants":283}],294:[function(t,e,n){"use strict";e.exports=function(t,e,n){"spline"===n("line.shape")&&n("line.smoothing")}},{}],295:[function(t,e,n){"use strict";var r={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,n){var a,i,o,l,s,c={},u=!1,f=-1,d=0,p=-1;for(i=0;i=0?s=p:(s=p=d,d++),s0?Math.max(e,a):0}}},{"fast-isnumeric":11}],297:[function(t,e,n){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],298:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,n,l,s,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(n=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",n),a(t,"marker")&&i(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c.noSelect||(s("selected.marker.color"),s("unselected.marker.color"),s("selected.marker.size"),s("unselected.marker.size")),c.noLine||(s("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?r.background:r.defaultLine),a(t,"marker.line")&&i(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0)),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode")),c.gradient)&&("none"!==s("marker.gradient.type")&&s("marker.gradient.color"))}},{"../../components/color":45,"../../components/colorscale/defaults":55,"../../components/colorscale/helpers":56,"./subtypes":303}],299:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,l=i.identity,s=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),d=t("../../lib/polygon").tester;function p(t,e,n,f,p,h,g){var v;!function(t,e,n,a,o){var l=n.xaxis,s=n.yaxis,u=r.extent(i.simpleMap(l.range,l.r2c)),f=r.extent(i.simpleMap(s.range,s.r2c)),d=a[0].trace;if(!c.hasMarkers(d))return;var p=d.marker.maxdisplayed;if(0===p)return;var h=a.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(h.length/p),v=0;o.forEach(function(t,n){var r=t[0].trace;c.hasMarkers(r)&&r.marker.maxdisplayed>0&&n0;function m(t){return y?t.transition():t}var x=n.xaxis,b=n.yaxis,_=f[0].trace,w=_.line,k=r.select(h),M=o(k,"g","errorbars"),T=o(k,"g","lines"),A=o(k,"g","points"),L=o(k,"g","text");if(a.getComponentMethod("errorbars","plot")(t,M,n,g),!0===_.visible){var S,C;m(k).style("opacity",_.opacity);var P=_.fill.charAt(_.fill.length-1);"x"!==P&&"y"!==P&&(P=""),n.isRangePlot||(f[0].node3=k);var O="",z=[],D=_._prevtrace;D&&(O=D._prevRevpath||"",C=D._nextFill,z=D._polygons);var R,E,N,I,F,j,B,H,q,U="",V="",G=[],Y=i.noop;if(S=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(C&&C.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(N=s.steps(w.shape),I=s.steps(w.shape.split("").reverse().join(""))):N=I="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?s.smoothclosed(t.slice(1),w.smoothing):s.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return I(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=_._polygons=new Array(G.length),v=0;v1){var n=r.select(this);if(n.datum(f),t)m(n.style("opacity",0).attr("d",R).call(s.lineGroupStyle)).style("opacity",1);else{var a=m(n);a.attr("d",R),s.singleLineStyle(f,a)}}}}}var Z=T.selectAll(".js-line").data(G);m(Z.exit()).style("opacity",0).remove(),Z.each(Y(!1)),Z.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(s.lineGroupStyle).each(Y(!0)),s.setClipUrl(Z,n.layerClipId,t),G.length?(S?(S.datum(f),j&&H&&(P?("y"===P?j[1]=H[1]=b.c2p(0,!0):"x"===P&&(j[0]=H[0]=x.c2p(0,!0)),m(S).attr("d","M"+H+"L"+j+"L"+U.substr(1)).call(s.singleFillStyle)):m(S).attr("d",U+"Z").call(s.singleFillStyle))):C&&("tonext"===_.fill.substr(0,6)&&U&&O?("tonext"===_.fill?m(C).attr("d",U+"Z"+O+"Z").call(s.singleFillStyle):m(C).attr("d",U+"L"+O.substr(1)+"Z").call(s.singleFillStyle),_._polygons=_._polygons.concat(z)):(W(C),_._polygons=null)),_._prevRevpath=V,_._prevPolygons=q):(S?W(S):C&&W(C),_._polygons=_._prevRevpath=_._prevPolygons=null),A.datum(f),L.datum(f),function(e,a,i){var o,u=i[0].trace,f=c.hasMarkers(u),d=c.hasText(u),p=tt(u),h=et,g=et;if(f||d){var v=l,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?$:J:_&&!w&&(v=Q),f&&(h=v),d&&(g=v)}var k,M=(o=e.selectAll("path.point").data(h,p)).enter().append("path").classed("point",!0);y&&M.call(s.pointStyle,u,t).call(s.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=s.makePointStyleFns(u)),o.each(function(e){var a=r.select(this),i=m(a);s.translatePoint(e,i,x,b)?(s.singlePointStyle(e,i,u,k,t),n.layerClipId&&s.hideOutsideRangePoint(e,i,x,b,u.xcalendar,u.ycalendar),u.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=r.select(this),a=m(e.select("text"));s.translatePoint(t,a,x,b)?n.layerClipId&&s.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(s.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),n=b.c2p(t.y);r.select(this).selectAll("tspan.line").each(function(){m(r.select(this)).attr({x:e,y:n})})}),o.exit().remove()}(A,L,f);var X=!1===_.cliponaxis?null:n.layerClipId;s.setClipUrl(A,X,t),s.setClipUrl(L,X,t)}function W(t){m(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function $(t){return t.filter(function(t){return t.vis})}function Q(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,n,a,i,c){var u,d,h=!i,g=!!i&&i.duration>0,v=f(t,e,n);((u=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,n){e.each(function(e){var a=o(r.select(this),"g","fills");s.setClipUrl(a,n.layerClipId,t);var i=e[0].trace,c=[];i._ownfill&&c.push("_ownFill"),i._nexttrace&&c.push("_nextFill");var u=a.selectAll("g").data(c,l);u.enter().append("g"),u.exit().each(function(t){i[t]=null}).remove(),u.order().each(function(t){i[t]=o(r.select(this),"path","js-fill")})})}(t,u,e),g)?(c&&(d=c()),r.transition().duration(i.duration).ease(i.easing).each("end",function(){d&&d()}).each("interrupt",function(){d&&d()}).each(function(){a.selectAll("g.trace").each(function(n,r){p(t,r,e,n,v,this,i)})})):u.each(function(n,r){p(t,r,e,n,v,this,i)});h&&u.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":66,"../../lib":163,"../../lib/polygon":175,"../../registry":257,"./line_points":293,"./link_traces":295,"./subtypes":303,d3:9}],300:[function(t,e,n){"use strict";var r=t("./subtypes");e.exports=function(t,e){var n,a,i,o,l=t.cd,s=t.xaxis,c=t.yaxis,u=[],f=l[0].trace;if(!r.hasMarkers(f)&&!r.hasText(f))return[];if(!1===e)for(n=0;n")}(u,v,p.mockAxis,c[0].t.labels),[t]}}},{"../../components/fx":84,"../../constants/numerical":142,"../../plots/cartesian/axes":208,"../scatter/fill_hover_text":287,"../scatter/get_trace_color":289,"./attributes":306}],311:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../scatter/marker_colorbar"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style"),r.styleOnSelect=t("../scatter/style").styleOnSelect,r.hoverPoints=t("./hover"),r.eventData=t("./event_data"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scattergeo",r.basePlotModule=t("../../plots/geo"),r.categories=["geo","symbols","showLegend","scatter-like"],r.meta={},e.exports=r},{"../../plots/geo":239,"../scatter/marker_colorbar":297,"../scatter/style":302,"./attributes":306,"./calc":307,"./defaults":308,"./event_data":309,"./hover":310,"./plot":312,"./select":313,"./style":314}],312:[function(t,e,n){"use strict";var r=t("d3"),a=t("../../lib"),i=t("../../constants/numerical").BADNUM,o=t("../../lib/topojson_utils").getTopojsonFeatures,l=t("../../lib/geo_location_utils").locationToFeature,s=t("../../lib/geojson_utils"),c=t("../scatter/subtypes"),u=t("./style");function f(t,e){var n=t[0].trace;if(Array.isArray(n.locations))for(var r=o(n,e),a=n.locationmode,s=0;s:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", + "X:hover .modebar--hover .modebar-group": "opacity:1;", "X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;", "X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;", "X .modebar-btn svg": "position:relative;top:2px;", @@ -71,7 +71,7 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":441}],2:[function(_dereq_,module,exports){ +},{"../src/lib":437}],2:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -214,7 +214,7 @@ module.exports = { module.exports = _dereq_('../src/traces/contourgl'); -},{"../src/traces/contourgl":553}],4:[function(_dereq_,module,exports){ +},{"../src/traces/contourgl":549}],4:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -227,7 +227,7 @@ module.exports = _dereq_('../src/traces/contourgl'); module.exports = _dereq_('../src/core'); -},{"../src/core":422}],5:[function(_dereq_,module,exports){ +},{"../src/core":418}],5:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -240,7 +240,7 @@ module.exports = _dereq_('../src/core'); module.exports = _dereq_('../src/traces/heatmapgl'); -},{"../src/traces/heatmapgl":568}],6:[function(_dereq_,module,exports){ +},{"../src/traces/heatmapgl":563}],6:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -277,7 +277,7 @@ module.exports = Plotly; module.exports = _dereq_('../src/traces/parcoords'); -},{"../src/traces/parcoords":580}],8:[function(_dereq_,module,exports){ +},{"../src/traces/parcoords":575}],8:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -290,7 +290,7 @@ module.exports = _dereq_('../src/traces/parcoords'); module.exports = _dereq_('../src/traces/pointcloud'); -},{"../src/traces/pointcloud":590}],9:[function(_dereq_,module,exports){ +},{"../src/traces/pointcloud":585}],9:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -303,7 +303,7 @@ module.exports = _dereq_('../src/traces/pointcloud'); module.exports = _dereq_('../src/traces/scattergl'); -},{"../src/traces/scattergl":624}],10:[function(_dereq_,module,exports){ +},{"../src/traces/scattergl":619}],10:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -316,7 +316,7 @@ module.exports = _dereq_('../src/traces/scattergl'); module.exports = _dereq_('../src/traces/splom'); -},{"../src/traces/splom":628}],11:[function(_dereq_,module,exports){ +},{"../src/traces/splom":623}],11:[function(_dereq_,module,exports){ module.exports = absolutize @@ -6049,7 +6049,7 @@ function boxIntersectWrapper(arg0, arg1, arg2) { throw new Error('box-intersect: Invalid arguments') } } -},{"./lib/intersect":44,"./lib/sweep":48,"typedarray-pool":290}],43:[function(_dereq_,module,exports){ +},{"./lib/intersect":44,"./lib/sweep":48,"typedarray-pool":289}],43:[function(_dereq_,module,exports){ 'use strict' var DIMENSION = 'd' @@ -6689,7 +6689,7 @@ function boxIntersectIter( } } } -},{"./brute":43,"./median":45,"./partition":46,"./sweep":48,"bit-twiddle":39,"typedarray-pool":290}],45:[function(_dereq_,module,exports){ +},{"./brute":43,"./median":45,"./partition":46,"./sweep":48,"bit-twiddle":39,"typedarray-pool":289}],45:[function(_dereq_,module,exports){ 'use strict' module.exports = findMedian @@ -7525,7 +7525,7 @@ red_loop: } } } -},{"./sort":47,"bit-twiddle":39,"typedarray-pool":290}],49:[function(_dereq_,module,exports){ +},{"./sort":47,"bit-twiddle":39,"typedarray-pool":289}],49:[function(_dereq_,module,exports){ },{}],50:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. @@ -8101,7 +8101,7 @@ function typedArraySupport () { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } return arr.foo() === 42 } catch (e) { return false @@ -10954,7 +10954,7 @@ function cleanPSLG (points, edges, colors) { return modified } -},{"./lib/rat-seg-intersect":60,"big-rat":25,"big-rat/cmp":23,"big-rat/to-float":37,"box-intersect":42,"nextafter":221,"rat-vec":251,"robust-segment-intersect":265,"union-find":291}],60:[function(_dereq_,module,exports){ +},{"./lib/rat-seg-intersect":60,"big-rat":25,"big-rat/cmp":23,"big-rat/to-float":37,"box-intersect":42,"nextafter":221,"rat-vec":251,"robust-segment-intersect":265,"union-find":290}],60:[function(_dereq_,module,exports){ 'use strict' module.exports = solveIntersection @@ -11694,7 +11694,7 @@ function compareAngle(a, b, c, d) { } } } -},{"robust-orientation":262,"robust-product":263,"robust-sum":267,"signum":268,"two-sum":289}],69:[function(_dereq_,module,exports){ +},{"robust-orientation":262,"robust-product":263,"robust-sum":267,"signum":268,"two-sum":288}],69:[function(_dereq_,module,exports){ module.exports=[ "xx-small", "x-small", @@ -11874,7 +11874,7 @@ function parseLineHeight(value) { return value } -},{"./lib/util":74,"css-font-stretch-keywords":70,"css-font-style-keywords":71,"css-font-weight-keywords":72,"css-global-keywords":77,"css-system-font-keywords":78,"string-split-by":276,"unquote":293}],76:[function(_dereq_,module,exports){ +},{"./lib/util":74,"css-font-stretch-keywords":70,"css-font-style-keywords":71,"css-font-weight-keywords":72,"css-global-keywords":77,"css-system-font-keywords":78,"string-split-by":276,"unquote":292}],76:[function(_dereq_,module,exports){ 'use strict' var pick = _dereq_('pick-by-alias') @@ -12466,7 +12466,7 @@ function generateCWiseOp(proc, typesig) { } module.exports = generateCWiseOp -},{"uniq":292}],81:[function(_dereq_,module,exports){ +},{"uniq":291}],81:[function(_dereq_,module,exports){ "use strict" // The function below is called when constructing a cwise function object, and does the following: @@ -23179,7 +23179,7 @@ function edgeToAdjacency(edges, numVertices) { } return adj } -},{"uniq":292}],94:[function(_dereq_,module,exports){ +},{"uniq":291}],94:[function(_dereq_,module,exports){ // Inspired by Google Closure: // http://closure-library.googlecode.com/svn/docs/ // closure_goog_array_array.js.html#goog.array.clear @@ -27141,7 +27141,7 @@ function createBuffer(gl, data, type, usage) { module.exports = createBuffer -},{"ndarray":220,"ndarray-ops":219,"typedarray-pool":290}],157:[function(_dereq_,module,exports){ +},{"ndarray":220,"ndarray-ops":219,"typedarray-pool":289}],157:[function(_dereq_,module,exports){ module.exports = { 0: 'NONE', 1: 'ONE', @@ -27871,7 +27871,7 @@ function createContour2D (plot, options) { return contours } -},{"./lib/shaders":160,"binary-search-bounds":161,"cdt2d":52,"clean-pslg":59,"gl-buffer":156,"gl-shader":180,"iota-array":205,"ndarray":220,"surface-nets":278}],160:[function(_dereq_,module,exports){ +},{"./lib/shaders":160,"binary-search-bounds":161,"cdt2d":52,"clean-pslg":59,"gl-buffer":156,"gl-shader":180,"iota-array":205,"ndarray":220,"surface-nets":277}],160:[function(_dereq_,module,exports){ 'use strict' var glslify = _dereq_('glslify') @@ -28724,7 +28724,7 @@ function createHeatmap2D (plot, options) { return heatmap } -},{"./lib/shaders":165,"binary-search-bounds":166,"gl-buffer":156,"gl-shader":180,"iota-array":205,"typedarray-pool":290}],165:[function(_dereq_,module,exports){ +},{"./lib/shaders":165,"binary-search-bounds":166,"gl-buffer":156,"gl-shader":180,"iota-array":205,"typedarray-pool":289}],165:[function(_dereq_,module,exports){ 'use strict' var glslify = _dereq_('glslify') @@ -28787,1260 +28787,1260 @@ function fromQuat(out, q) { return out; }; },{}],168:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createBoxes - -var createBuffer = _dereq_('gl-buffer') -var createShader = _dereq_('gl-shader') - -var shaders = _dereq_('./shaders') - -function Boxes(plot, vbo, shader) { - this.plot = plot - this.vbo = vbo - this.shader = shader -} - -var proto = Boxes.prototype - -proto.bind = function() { - var shader = this.shader - this.vbo.bind() - this.shader.bind() - shader.attributes.coord.pointer() - shader.uniforms.screenBox = this.plot.screenBox -} - -proto.drawBox = (function() { - var lo = [0,0] - var hi = [0,0] - return function(loX, loY, hiX, hiY, color) { - var plot = this.plot - var shader = this.shader - var gl = plot.gl - - lo[0] = loX - lo[1] = loY - hi[0] = hiX - hi[1] = hiY - - shader.uniforms.lo = lo - shader.uniforms.hi = hi - shader.uniforms.color = color - - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4) - } -}()) - -proto.dispose = function() { - this.vbo.dispose() - this.shader.dispose() -} - -function createBoxes(plot) { - var gl = plot.gl - var vbo = createBuffer(gl, [ - 0,0, - 0,1, - 1,0, - 1,1]) - var shader = createShader(gl, shaders.boxVert, shaders.lineFrag) - return new Boxes(plot, vbo, shader) -} +'use strict' + +module.exports = createBoxes + +var createBuffer = _dereq_('gl-buffer') +var createShader = _dereq_('gl-shader') + +var shaders = _dereq_('./shaders') + +function Boxes(plot, vbo, shader) { + this.plot = plot + this.vbo = vbo + this.shader = shader +} + +var proto = Boxes.prototype + +proto.bind = function() { + var shader = this.shader + this.vbo.bind() + this.shader.bind() + shader.attributes.coord.pointer() + shader.uniforms.screenBox = this.plot.screenBox +} + +proto.drawBox = (function() { + var lo = [0,0] + var hi = [0,0] + return function(loX, loY, hiX, hiY, color) { + var plot = this.plot + var shader = this.shader + var gl = plot.gl + + lo[0] = loX + lo[1] = loY + hi[0] = hiX + hi[1] = hiY + + shader.uniforms.lo = lo + shader.uniforms.hi = hi + shader.uniforms.color = color + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4) + } +}()) + +proto.dispose = function() { + this.vbo.dispose() + this.shader.dispose() +} + +function createBoxes(plot) { + var gl = plot.gl + var vbo = createBuffer(gl, [ + 0,0, + 0,1, + 1,0, + 1,1]) + var shader = createShader(gl, shaders.boxVert, shaders.lineFrag) + return new Boxes(plot, vbo, shader) +} },{"./shaders":171,"gl-buffer":156,"gl-shader":180}],169:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createGrid - -var createBuffer = _dereq_('gl-buffer') -var createShader = _dereq_('gl-shader') -var bsearch = _dereq_('binary-search-bounds') -var shaders = _dereq_('./shaders') - -function Grid(plot, vbo, shader, tickShader) { - this.plot = plot - this.vbo = vbo - this.shader = shader - this.tickShader = tickShader - this.ticks = [[], []] -} - -function compareTickNum(a, b) { - return a - b -} - -var proto = Grid.prototype - -proto.draw = (function() { - - var DATA_SHIFT = [0,0] - var DATA_SCALE = [0,0] - var DATA_AXIS = [0,0] - - return function() { - var plot = this.plot - var vbo = this.vbo - var shader = this.shader - var ticks = this.ticks - var gl = plot.gl - var bounds = plot._tickBounds - var dataBox = plot.dataBox - var viewPixels = plot.viewBox - var lineWidth = plot.gridLineWidth - var gridColor = plot.gridLineColor - var gridEnable = plot.gridLineEnable - var pixelRatio = plot.pixelRatio - - for(var i=0; i<2; ++i) { - var lo = bounds[i] - var hi = bounds[i+2] - var boundScale = hi - lo - var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) - var dataWidth = dataBox[i+2] - dataBox[i] - DATA_SCALE[i] = 2.0 * boundScale / dataWidth - DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth - } - - shader.bind() - vbo.bind() - shader.attributes.dataCoord.pointer() - shader.uniforms.dataShift = DATA_SHIFT - shader.uniforms.dataScale = DATA_SCALE - - var offset = 0 - for(var i=0; i<2; ++i) { - DATA_AXIS[0] = DATA_AXIS[1] = 0 - DATA_AXIS[i] = 1 - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.lineWidth = lineWidth[i] / (viewPixels[i+2] - viewPixels[i]) * pixelRatio - shader.uniforms.color = gridColor[i] - - var size = ticks[i].length * 6 - if(gridEnable[i] && size) { - gl.drawArrays(gl.TRIANGLES, offset, size) - } - offset += size - } - } -})() - -proto.drawTickMarks = (function() { - var DATA_SHIFT = [0,0] - var DATA_SCALE = [0,0] - var X_AXIS = [1,0] - var Y_AXIS = [0,1] - var SCR_OFFSET = [0,0] - var TICK_SCALE = [0,0] - - return function() { - var plot = this.plot - var vbo = this.vbo - var shader = this.tickShader - var ticks = this.ticks - var gl = plot.gl - var bounds = plot._tickBounds - var dataBox = plot.dataBox - var viewBox = plot.viewBox - var pixelRatio = plot.pixelRatio - var screenBox = plot.screenBox - - var screenWidth = screenBox[2] - screenBox[0] - var screenHeight = screenBox[3] - screenBox[1] - var viewWidth = viewBox[2] - viewBox[0] - var viewHeight = viewBox[3] - viewBox[1] - - for(var i=0; i<2; ++i) { - var lo = bounds[i] - var hi = bounds[i+2] - var boundScale = hi - lo - var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) - var dataWidth = (dataBox[i+2] - dataBox[i]) - DATA_SCALE[i] = 2.0 * boundScale / dataWidth - DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth - } - - DATA_SCALE[0] *= viewWidth / screenWidth - DATA_SHIFT[0] *= viewWidth / screenWidth - - DATA_SCALE[1] *= viewHeight / screenHeight - DATA_SHIFT[1] *= viewHeight / screenHeight - - shader.bind() - vbo.bind() - - shader.attributes.dataCoord.pointer() - - var uniforms = shader.uniforms - uniforms.dataShift = DATA_SHIFT - uniforms.dataScale = DATA_SCALE - - var tickMarkLength = plot.tickMarkLength - var tickMarkWidth = plot.tickMarkWidth - var tickMarkColor = plot.tickMarkColor - - var xTicksOffset = 0 - var yTicksOffset = ticks[0].length * 6 - - var xStart = Math.min(bsearch.ge(ticks[0], (dataBox[0] - bounds[0]) / (bounds[2] - bounds[0]), compareTickNum), ticks[0].length) - var xEnd = Math.min(bsearch.gt(ticks[0], (dataBox[2] - bounds[0]) / (bounds[2] - bounds[0]), compareTickNum), ticks[0].length) - var xOffset = xTicksOffset + 6 * xStart - var xCount = 6 * Math.max(0, xEnd - xStart) - - var yStart = Math.min(bsearch.ge(ticks[1], (dataBox[1] - bounds[1]) / (bounds[3] - bounds[1]), compareTickNum), ticks[1].length) - var yEnd = Math.min(bsearch.gt(ticks[1], (dataBox[3] - bounds[1]) / (bounds[3] - bounds[1]), compareTickNum), ticks[1].length) - var yOffset = yTicksOffset + 6 * yStart - var yCount = 6 * Math.max(0, yEnd - yStart) - - SCR_OFFSET[0] = 2.0 * (viewBox[0] - tickMarkLength[1]) / screenWidth - 1.0 - SCR_OFFSET[1] = (viewBox[3] + viewBox[1]) / screenHeight - 1.0 - TICK_SCALE[0] = tickMarkLength[1] * pixelRatio / screenWidth - TICK_SCALE[1] = tickMarkWidth[1] * pixelRatio / screenHeight - - if(yCount) { - uniforms.color = tickMarkColor[1] - uniforms.tickScale = TICK_SCALE - uniforms.dataAxis = Y_AXIS - uniforms.screenOffset = SCR_OFFSET - gl.drawArrays(gl.TRIANGLES, yOffset, yCount) - } - - SCR_OFFSET[0] = (viewBox[2] + viewBox[0]) / screenWidth - 1.0 - SCR_OFFSET[1] = 2.0 * (viewBox[1] - tickMarkLength[0]) / screenHeight - 1.0 - TICK_SCALE[0] = tickMarkWidth[0] * pixelRatio / screenWidth - TICK_SCALE[1] = tickMarkLength[0] * pixelRatio / screenHeight - - if(xCount) { - uniforms.color = tickMarkColor[0] - uniforms.tickScale = TICK_SCALE - uniforms.dataAxis = X_AXIS - uniforms.screenOffset = SCR_OFFSET - gl.drawArrays(gl.TRIANGLES, xOffset, xCount) - } - - SCR_OFFSET[0] = 2.0 * (viewBox[2] + tickMarkLength[3]) / screenWidth - 1.0 - SCR_OFFSET[1] = (viewBox[3] + viewBox[1]) / screenHeight - 1.0 - TICK_SCALE[0] = tickMarkLength[3] * pixelRatio / screenWidth - TICK_SCALE[1] = tickMarkWidth[3] * pixelRatio / screenHeight - - if(yCount) { - uniforms.color = tickMarkColor[3] - uniforms.tickScale = TICK_SCALE - uniforms.dataAxis = Y_AXIS - uniforms.screenOffset = SCR_OFFSET - gl.drawArrays(gl.TRIANGLES, yOffset, yCount) - } - - SCR_OFFSET[0] = (viewBox[2] + viewBox[0]) / screenWidth - 1.0 - SCR_OFFSET[1] = 2.0 * (viewBox[3] + tickMarkLength[2]) / screenHeight - 1.0 - TICK_SCALE[0] = tickMarkWidth[2] * pixelRatio / screenWidth - TICK_SCALE[1] = tickMarkLength[2] * pixelRatio / screenHeight - - if(xCount) { - uniforms.color = tickMarkColor[2] - uniforms.tickScale = TICK_SCALE - uniforms.dataAxis = X_AXIS - uniforms.screenOffset = SCR_OFFSET - gl.drawArrays(gl.TRIANGLES, xOffset, xCount) - } - } -})() - -proto.update = (function() { - var OFFSET_X = [1, 1, -1, -1, 1, -1] - var OFFSET_Y = [1, -1, 1, 1, -1, -1] - - return function(options) { - var ticks = options.ticks - var bounds = options.bounds - var data = new Float32Array(6 * 3 * (ticks[0].length + ticks[1].length)) - - var zeroLineEnable = this.plot.zeroLineEnable - - var ptr = 0 - var gridTicks = [[], []] - for(var dim=0; dim<2; ++dim) { - var localTicks = gridTicks[dim] - var axisTicks = ticks[dim] - var lo = bounds[dim] - var hi = bounds[dim+2] - for(var i=0; i tickOffset[start]) { - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = textColor[axis] - shader.uniforms.angle = textAngle[axis] - gl.drawArrays( - gl.TRIANGLES, - tickOffset[start], - tickOffset[end] - tickOffset[start]) - } - } - if(labelEnable[axis] && labelCount) { - SCREEN_OFFSET[axis^1] -= screenScale * pixelRatio * labelPad[axis] - shader.uniforms.dataAxis = ZERO_2 - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = labelColor[axis] - shader.uniforms.angle = labelAngle[axis] - gl.drawArrays( - gl.TRIANGLES, - labelOffset, - labelCount) - } - - SCREEN_OFFSET[axis^1] = screenScale * viewBox[2+(axis^1)] - 1.0 - if(tickEnable[axis+2]) { - SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * tickPad[axis+2] - if(start < end && tickOffset[end] > tickOffset[start]) { - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = textColor[axis+2] - shader.uniforms.angle = textAngle[axis+2] - gl.drawArrays( - gl.TRIANGLES, - tickOffset[start], - tickOffset[end] - tickOffset[start]) - } - } - if(labelEnable[axis+2] && labelCount) { - SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * labelPad[axis+2] - shader.uniforms.dataAxis = ZERO_2 - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = labelColor[axis+2] - shader.uniforms.angle = labelAngle[axis+2] - gl.drawArrays( - gl.TRIANGLES, - labelOffset, - labelCount) - } - - } -})() - -proto.drawTitle = (function() { - var DATA_AXIS = [0,0] - var SCREEN_OFFSET = [0,0] - - return function() { - var plot = this.plot - var shader = this.shader - var gl = plot.gl - var screenBox = plot.screenBox - var titleCenter = plot.titleCenter - var titleAngle = plot.titleAngle - var titleColor = plot.titleColor - var pixelRatio = plot.pixelRatio - - if(!this.titleCount) { - return - } - - for(var i=0; i<2; ++i) { - SCREEN_OFFSET[i] = 2.0 * (titleCenter[i]*pixelRatio - screenBox[i]) / - (screenBox[2+i] - screenBox[i]) - 1 - } - - shader.bind() - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.angle = titleAngle - shader.uniforms.color = titleColor - - gl.drawArrays(gl.TRIANGLES, this.titleOffset, this.titleCount) - } -})() - -proto.bind = (function() { - var DATA_SHIFT = [0,0] - var DATA_SCALE = [0,0] - var TEXT_SCALE = [0,0] - - return function() { - var plot = this.plot - var shader = this.shader - var bounds = plot._tickBounds - var dataBox = plot.dataBox - var screenBox = plot.screenBox - var viewBox = plot.viewBox - - shader.bind() - - //Set up coordinate scaling uniforms - for(var i=0; i<2; ++i) { - - var lo = bounds[i] - var hi = bounds[i+2] - var boundScale = hi - lo - var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) - var dataWidth = (dataBox[i+2] - dataBox[i]) - - var viewLo = viewBox[i] - var viewHi = viewBox[i+2] - var viewScale = viewHi - viewLo - var screenLo = screenBox[i] - var screenHi = screenBox[i+2] - var screenScale = screenHi - screenLo - - DATA_SCALE[i] = 2.0 * boundScale / dataWidth * viewScale / screenScale - DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth * viewScale / screenScale - } - - TEXT_SCALE[1] = 2.0 * plot.pixelRatio / (screenBox[3] - screenBox[1]) - TEXT_SCALE[0] = TEXT_SCALE[1] * (screenBox[3] - screenBox[1]) / (screenBox[2] - screenBox[0]) - - shader.uniforms.dataScale = DATA_SCALE - shader.uniforms.dataShift = DATA_SHIFT - shader.uniforms.textScale = TEXT_SCALE - - //Set attributes - this.vbo.bind() - shader.attributes.textCoordinate.pointer() - } -})() - -proto.update = function(options) { - var vertices = [] - var axesTicks = options.ticks - var bounds = options.bounds - var i, j, k, data, scale, dimension - - for(dimension=0; dimension<2; ++dimension) { - var offsets = [Math.floor(vertices.length/3)], tickX = [-Infinity] - - //Copy vertices over to buffer - var ticks = axesTicks[dimension] - for(i=0; i tickOffset[start]) { + shader.uniforms.dataAxis = DATA_AXIS + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = textColor[axis] + shader.uniforms.angle = textAngle[axis] + gl.drawArrays( + gl.TRIANGLES, + tickOffset[start], + tickOffset[end] - tickOffset[start]) + } + } + if(labelEnable[axis] && labelCount) { + SCREEN_OFFSET[axis^1] -= screenScale * pixelRatio * labelPad[axis] + shader.uniforms.dataAxis = ZERO_2 + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = labelColor[axis] + shader.uniforms.angle = labelAngle[axis] + gl.drawArrays( + gl.TRIANGLES, + labelOffset, + labelCount) + } + + SCREEN_OFFSET[axis^1] = screenScale * viewBox[2+(axis^1)] - 1.0 + if(tickEnable[axis+2]) { + SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * tickPad[axis+2] + if(start < end && tickOffset[end] > tickOffset[start]) { + shader.uniforms.dataAxis = DATA_AXIS + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = textColor[axis+2] + shader.uniforms.angle = textAngle[axis+2] + gl.drawArrays( + gl.TRIANGLES, + tickOffset[start], + tickOffset[end] - tickOffset[start]) + } + } + if(labelEnable[axis+2] && labelCount) { + SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * labelPad[axis+2] + shader.uniforms.dataAxis = ZERO_2 + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = labelColor[axis+2] + shader.uniforms.angle = labelAngle[axis+2] + gl.drawArrays( + gl.TRIANGLES, + labelOffset, + labelCount) + } + + } +})() + +proto.drawTitle = (function() { + var DATA_AXIS = [0,0] + var SCREEN_OFFSET = [0,0] + + return function() { + var plot = this.plot + var shader = this.shader + var gl = plot.gl + var screenBox = plot.screenBox + var titleCenter = plot.titleCenter + var titleAngle = plot.titleAngle + var titleColor = plot.titleColor + var pixelRatio = plot.pixelRatio + + if(!this.titleCount) { + return + } + + for(var i=0; i<2; ++i) { + SCREEN_OFFSET[i] = 2.0 * (titleCenter[i]*pixelRatio - screenBox[i]) / + (screenBox[2+i] - screenBox[i]) - 1 + } + + shader.bind() + shader.uniforms.dataAxis = DATA_AXIS + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.angle = titleAngle + shader.uniforms.color = titleColor + + gl.drawArrays(gl.TRIANGLES, this.titleOffset, this.titleCount) + } +})() + +proto.bind = (function() { + var DATA_SHIFT = [0,0] + var DATA_SCALE = [0,0] + var TEXT_SCALE = [0,0] + + return function() { + var plot = this.plot + var shader = this.shader + var bounds = plot._tickBounds + var dataBox = plot.dataBox + var screenBox = plot.screenBox + var viewBox = plot.viewBox + + shader.bind() + + //Set up coordinate scaling uniforms + for(var i=0; i<2; ++i) { + + var lo = bounds[i] + var hi = bounds[i+2] + var boundScale = hi - lo + var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) + var dataWidth = (dataBox[i+2] - dataBox[i]) + + var viewLo = viewBox[i] + var viewHi = viewBox[i+2] + var viewScale = viewHi - viewLo + var screenLo = screenBox[i] + var screenHi = screenBox[i+2] + var screenScale = screenHi - screenLo + + DATA_SCALE[i] = 2.0 * boundScale / dataWidth * viewScale / screenScale + DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth * viewScale / screenScale + } + + TEXT_SCALE[1] = 2.0 * plot.pixelRatio / (screenBox[3] - screenBox[1]) + TEXT_SCALE[0] = TEXT_SCALE[1] * (screenBox[3] - screenBox[1]) / (screenBox[2] - screenBox[0]) + + shader.uniforms.dataScale = DATA_SCALE + shader.uniforms.dataShift = DATA_SHIFT + shader.uniforms.textScale = TEXT_SCALE + + //Set attributes + this.vbo.bind() + shader.attributes.textCoordinate.pointer() + } +})() + +proto.update = function(options) { + var vertices = [] + var axesTicks = options.ticks + var bounds = options.bounds + var i, j, k, data, scale, dimension -},{"./shaders":171,"binary-search-bounds":173,"gl-buffer":156,"gl-shader":180,"text-cache":283}],173:[function(_dereq_,module,exports){ + for(dimension=0; dimension<2; ++dimension) { + var offsets = [Math.floor(vertices.length/3)], tickX = [-Infinity] + + //Copy vertices over to buffer + var ticks = axesTicks[dimension] + for(i=0; i= 0)) { - continue - } - - var zeroIntercept = screenBox[i] - - dataBox[i] * (screenBox[i+2] - screenBox[i]) / (dataBox[i+2] - dataBox[i]) - - if(i === 0) { - line.drawLine( - zeroIntercept, screenBox[1], zeroIntercept, screenBox[3], - zeroLineWidth[i], - zeroLineColor[i]) - } else { - line.drawLine( - screenBox[0], zeroIntercept, screenBox[2], zeroIntercept, - zeroLineWidth[i], - zeroLineColor[i]) - } - } - } - - //Draw traces - for(var i=0; i=0; --i) { - this.objects[i].dispose() - } - this.objects.length = 0 - for(var i=this.overlays.length-1; i>=0; --i) { - this.overlays[i].dispose() - } - this.overlays.length = 0 - - this.gl = null -} - -proto.addObject = function(object) { - if(this.objects.indexOf(object) < 0) { - this.objects.push(object) - this.setDirty() - } -} - -proto.removeObject = function(object) { - var objects = this.objects - for(var i=0; i= 0)) { + continue + } + + var zeroIntercept = screenBox[i] - + dataBox[i] * (screenBox[i+2] - screenBox[i]) / (dataBox[i+2] - dataBox[i]) + + if(i === 0) { + line.drawLine( + zeroIntercept, screenBox[1], zeroIntercept, screenBox[3], + zeroLineWidth[i], + zeroLineColor[i]) + } else { + line.drawLine( + screenBox[0], zeroIntercept, screenBox[2], zeroIntercept, + zeroLineWidth[i], + zeroLineColor[i]) + } + } + } + + //Draw traces + for(var i=0; i=0; --i) { + this.objects[i].dispose() + } + this.objects.length = 0 + for(var i=this.overlays.length-1; i>=0; --i) { + this.overlays[i].dispose() + } + this.overlays.length = 0 + + this.gl = null +} + +proto.addObject = function(object) { + if(this.objects.indexOf(object) < 0) { + this.objects.push(object) + this.setDirty() + } +} + +proto.removeObject = function(object) { + var objects = this.objects + for(var i=0; i 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]) - circleOptions.vert = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nvec2 paletteCoord(float id) {\n return vec2(\n (mod(id, paletteSize.x) + .5) / paletteSize.x,\n (floor(id / paletteSize.x) + .5) / paletteSize.y\n );\n}\nvec2 paletteCoord(vec2 id) {\n return vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n );\n}\n\nvec4 getColor(vec4 id) {\n // zero-palette means we deal with direct buffer\n if (paletteSize.x == 0.) return id / 255.;\n return texture2D(palette, paletteCoord(id.xy));\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]) - - // polyfill IE - if (ie) { - circleOptions.frag = circleOptions.frag.replace('smoothstep', 'smoothStep') - markerOptions.frag = markerOptions.frag.replace('smoothstep', 'smoothStep') - } - - this.drawCircle = regl(circleOptions) -} - -// single pass defaults -Scatter.defaults = { - color: 'black', - borderColor: 'transparent', - borderSize: 0, - size: 12, - opacity: 1, - marker: undefined, - viewport: null, - range: null, - pixelSize: null, - count: 0, - offset: 0, - bounds: null, - positions: [], - snap: 1e4 -} - - -// update & redraw +},{"array-bounds":13,"array-normalize":14,"color-normalize":63,"earcut":92,"es6-weak-map":145,"flatten-vertex-data":150,"glslify":199,"object-assign":223,"parse-rect":226,"pick-by-alias":232,"to-float32":284}],256:[function(_dereq_,module,exports){ +'use strict'; + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance"); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} + +var rgba = _dereq_('color-normalize'); + +var getBounds = _dereq_('array-bounds'); + +var colorId = _dereq_('color-id'); + +var cluster = _dereq_('point-cluster'); + +var extend = _dereq_('object-assign'); + +var glslify = _dereq_('glslify'); + +var pick = _dereq_('pick-by-alias'); + +var updateDiff = _dereq_('update-diff'); + +var flatten = _dereq_('flatten-vertex-data'); + +var ie = _dereq_('is-iexplorer'); + +var f32 = _dereq_('to-float32'); + +var parseRect = _dereq_('parse-rect'); + +var scatter = Scatter; + +function Scatter(regl, options) { + var _this = this; + + if (!(this instanceof Scatter)) return new Scatter(regl, options); + + if (typeof regl === 'function') { + if (!options) options = {}; + options.regl = regl; + } else { + options = regl; + regl = null; + } + + if (options && options.length) options.positions = options; + regl = options.regl; // persistent variables + + var gl = regl._gl, + paletteTexture, + palette = [], + paletteIds = {}, + // state + groups = [], + // textures for marker keys + markerTextures = [null], + markerCache = [null]; + var maxColors = 255, + maxSize = 100; // direct color buffer mode + // IE does not support palette anyways + + this.tooManyColors = ie; // texture with color palette + + paletteTexture = regl.texture({ + data: new Uint8Array(maxColors * 4), + width: maxColors, + height: 1, + type: 'uint8', + format: 'rgba', + wrapS: 'clamp', + wrapT: 'clamp', + mag: 'nearest', + min: 'nearest' + }); + extend(this, { + regl: regl, + gl: gl, + groups: groups, + markerCache: markerCache, + markerTextures: markerTextures, + palette: palette, + paletteIds: paletteIds, + paletteTexture: paletteTexture, + maxColors: maxColors, + maxSize: maxSize, + canvas: gl.canvas + }); + this.update(options); // common shader options + + var shaderOptions = { + uniforms: { + pixelRatio: regl.context('pixelRatio'), + palette: paletteTexture, + paletteSize: function paletteSize(ctx, prop) { + return [_this.tooManyColors ? 0 : maxColors, paletteTexture.height]; + }, + scale: regl.prop('scale'), + scaleFract: regl.prop('scaleFract'), + translate: regl.prop('translate'), + translateFract: regl.prop('translateFract'), + opacity: regl.prop('opacity'), + marker: regl.prop('markerTexture') + }, + attributes: { + // FIXME: optimize these parts + x: function x(ctx, prop) { + return prop.xAttr || { + buffer: prop.positionBuffer, + stride: 8, + offset: 0 + }; + }, + y: function y(ctx, prop) { + return prop.yAttr || { + buffer: prop.positionBuffer, + stride: 8, + offset: 4 + }; + }, + xFract: function xFract(ctx, prop) { + return prop.xAttr ? { + constant: [0, 0] + } : { + buffer: prop.positionFractBuffer, + stride: 8, + offset: 0 + }; + }, + yFract: function yFract(ctx, prop) { + return prop.yAttr ? { + constant: [0, 0] + } : { + buffer: prop.positionFractBuffer, + stride: 8, + offset: 4 + }; + }, + size: function size(ctx, prop) { + return prop.size.length ? { + buffer: prop.sizeBuffer, + stride: 2, + offset: 0 + } : { + constant: [Math.round(prop.size * 255 / _this.maxSize)] + }; + }, + borderSize: function borderSize(ctx, prop) { + return prop.borderSize.length ? { + buffer: prop.sizeBuffer, + stride: 2, + offset: 1 + } : { + constant: [Math.round(prop.borderSize * 255 / _this.maxSize)] + }; + }, + colorId: function colorId(ctx, prop) { + return prop.color.length ? { + buffer: prop.colorBuffer, + stride: _this.tooManyColors ? 8 : 4, + offset: 0 + } : { + constant: _this.tooManyColors ? palette.slice(prop.color * 4, prop.color * 4 + 4) : [prop.color] + }; + }, + borderColorId: function borderColorId(ctx, prop) { + return prop.borderColor.length ? { + buffer: prop.colorBuffer, + stride: _this.tooManyColors ? 8 : 4, + offset: _this.tooManyColors ? 4 : 2 + } : { + constant: _this.tooManyColors ? palette.slice(prop.borderColor * 4, prop.borderColor * 4 + 4) : [prop.borderColor] + }; + }, + isActive: function isActive(ctx, prop) { + return prop.activation === true ? { + constant: [1] + } : prop.activation ? prop.activation : { + constant: [0] + }; + } + }, + blend: { + enable: true, + color: [0, 0, 0, 1], + // photoshop blending + func: { + srcRGB: 'src alpha', + dstRGB: 'one minus src alpha', + srcAlpha: 'one minus dst alpha', + dstAlpha: 'one' + } + }, + scissor: { + enable: true, + box: regl.prop('viewport') + }, + viewport: regl.prop('viewport'), + stencil: { + enable: false + }, + depth: { + enable: false + }, + elements: regl.prop('elements'), + count: regl.prop('count'), + offset: regl.prop('offset'), + primitive: 'points' // draw sdf-marker + + }; + var markerOptions = extend({}, shaderOptions); + markerOptions.frag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragWidth, fragBorderColorLevel, fragColorLevel;\n\nuniform sampler2D marker;\nuniform float pixelRatio, opacity;\n\nfloat smoothStep(float x, float y) {\n return 1.0 / (1.0 + exp(50.0*(x - y)));\n}\n\nvoid main() {\n float dist = texture2D(marker, gl_PointCoord).r, delta = fragWidth;\n\n // max-distance alpha\n if (dist < 0.003) discard;\n\n // null-border case\n if (fragBorderColorLevel == fragColorLevel || fragBorderColor.a == 0.) {\n float colorAmt = smoothstep(.5 - delta, .5 + delta, dist);\n gl_FragColor = vec4(fragColor.rgb, colorAmt * fragColor.a * opacity);\n }\n else {\n float borderColorAmt = smoothstep(fragBorderColorLevel - delta, fragBorderColorLevel + delta, dist);\n float colorAmt = smoothstep(fragColorLevel - delta, fragColorLevel + delta, dist);\n\n vec4 color = fragBorderColor;\n color.a *= borderColorAmt;\n color = mix(color, fragColor, colorAmt);\n color.a *= opacity;\n\n gl_FragColor = color;\n }\n\n}\n"]); + markerOptions.vert = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract, paletteSize;\nuniform float pixelRatio;\nuniform sampler2D palette;\n\nconst float maxSize = 100.;\nconst float borderLevel = .5;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragPointSize, fragBorderRadius, fragWidth, fragBorderColorLevel, fragColorLevel;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = 2. * size * pixelRatio;\n fragPointSize = size * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragColor = color;\n fragBorderColor = borderColor;\n fragWidth = 1. / gl_PointSize;\n\n fragBorderColorLevel = clamp(borderLevel - borderLevel * borderSize / size, 0., 1.);\n fragColorLevel = clamp(borderLevel + (1. - borderLevel) * borderSize / size, 0., 1.);\n}"]); + this.drawMarker = regl(markerOptions); // draw circle + + var circleOptions = extend({}, shaderOptions); + circleOptions.frag = glslify(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\n\nuniform float opacity;\nvarying float fragBorderRadius, fragWidth;\n\nfloat smoothStep(float edge0, float edge1, float x) {\n\tfloat t;\n\tt = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n\treturn t * t * (3.0 - 2.0 * t);\n}\n\nvoid main() {\n\tfloat radius, alpha = 1.0, delta = fragWidth;\n\n\tradius = length(2.0 * gl_PointCoord.xy - 1.0);\n\n\tif (radius > 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]); + circleOptions.vert = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]); // polyfill IE + + if (ie) { + circleOptions.frag = circleOptions.frag.replace('smoothstep', 'smoothStep'); + markerOptions.frag = markerOptions.frag.replace('smoothstep', 'smoothStep'); + } + + this.drawCircle = regl(circleOptions); +} // single pass defaults + + +Scatter.defaults = { + color: 'black', + borderColor: 'transparent', + borderSize: 0, + size: 12, + opacity: 1, + marker: undefined, + viewport: null, + range: null, + pixelSize: null, + count: 0, + offset: 0, + bounds: null, + positions: [], + snap: 1e4 // update & redraw + +}; + Scatter.prototype.render = function () { - var ref; + if (arguments.length) { + this.update.apply(this, arguments); + } + + this.draw(); + return this; +}; // draw all groups or only indicated ones + - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (args.length) { - (ref = this).update.apply(ref, args) - } - - this.draw() - - return this -} - - -// draw all groups or only indicated ones Scatter.prototype.draw = function () { - var this$1 = this; - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - var ref = this; - var groups = ref.groups; - - // if directly array passed - treat as passes - if (args.length === 1 && Array.isArray(args[0]) && (args[0][0] === null || Array.isArray(args[0][0]))) { - args = args[0] - } + var _this2 = this; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var groups = this.groups; // if directly array passed - treat as passes + + if (args.length === 1 && Array.isArray(args[0]) && (args[0][0] === null || Array.isArray(args[0][0]))) { + args = args[0]; + } // FIXME: remove once https://github.com/regl-project/regl/issues/474 resolved + + + this.regl._refresh(); + + if (args.length) { + for (var i = 0; i < args.length; i++) { + this.drawItem(i, args[i]); + } + } // draw all passes + else { + groups.forEach(function (group, i) { + _this2.drawItem(i); + }); + } + + return this; +}; // draw specific scatter group + + +Scatter.prototype.drawItem = function (id, els) { + var groups = this.groups; + var group = groups[id]; // debug viewport + // let { viewport } = group + // gl.enable(gl.SCISSOR_TEST); + // gl.scissor(viewport.x, viewport.y, viewport.width, viewport.height); + // gl.clearColor(0, 0, 0, .5); + // gl.clear(gl.COLOR_BUFFER_BIT); + + if (typeof els === 'number') { + id = els; + group = groups[els]; + els = null; + } + + if (!(group && group.count && group.opacity)) return; // draw circles + + if (group.activation[0]) { + // TODO: optimize this performance by making groups and regl.this props + this.drawCircle(this.getMarkerDrawOptions(0, group, els)); + } // draw all other available markers + + + var batch = []; + + for (var i = 1; i < group.activation.length; i++) { + if (!group.activation[i] || group.activation[i] !== true && !group.activation[i].data.length) continue; + batch.push.apply(batch, _toConsumableArray(this.getMarkerDrawOptions(i, group, els))); + } + + if (batch.length) { + this.drawMarker(batch); + } +}; // get options for the marker ids + + +Scatter.prototype.getMarkerDrawOptions = function (markerId, group, elements) { + var range = group.range, + tree = group.tree, + viewport = group.viewport, + activation = group.activation, + selectionBuffer = group.selectionBuffer, + count = group.count; + var regl = this.regl; // direct points + + if (!tree) { + // if elements array - draw unclustered points + if (elements) { + return [extend({}, group, { + markerTexture: this.markerTextures[markerId], + activation: activation[markerId], + count: elements.length, + elements: elements, + offset: 0 + })]; + } + + return [extend({}, group, { + markerTexture: this.markerTextures[markerId], + activation: activation[markerId], + offset: 0 + })]; + } // clustered points + + + var batch = []; + var lod = tree.range(range, { + lod: true, + px: [(range[2] - range[0]) / viewport.width, (range[3] - range[1]) / viewport.height] + }); // enable elements by using selection buffer + + if (elements) { + var markerActivation = activation[markerId]; + var mask = markerActivation.data; + var data = new Uint8Array(count); + + for (var i = 0; i < elements.length; i++) { + var id = elements[i]; + data[id] = mask ? mask[id] : 1; + } + + selectionBuffer.subdata(data); + } + + for (var l = lod.length; l--;) { + var _lod$l = _slicedToArray(lod[l], 2), + from = _lod$l[0], + to = _lod$l[1]; + + batch.push(extend({}, group, { + markerTexture: this.markerTextures[markerId], + activation: elements ? selectionBuffer : activation[markerId], + offset: from, + count: to - from + })); + } + + return batch; +}; // update groups options + + +Scatter.prototype.update = function () { + var _this3 = this; + + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + if (!args.length) return; // passes are as single array + + if (args.length === 1 && Array.isArray(args[0])) args = args[0]; + var groups = this.groups, + gl = this.gl, + regl = this.regl, + maxSize = this.maxSize, + maxColors = this.maxColors, + palette = this.palette; + this.groups = groups = args.map(function (options, i) { + var group = groups[i]; + if (options === undefined) return group; + if (options === null) options = { + positions: null + };else if (typeof options === 'function') options = { + ondraw: options + };else if (typeof options[0] === 'number') options = { + positions: options // copy options to avoid mutation & handle aliases + + }; + options = pick(options, { + positions: 'positions data points', + snap: 'snap cluster lod tree', + size: 'sizes size radius', + borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', + color: 'colors color fill fill-color fillColor', + borderColor: 'borderColors borderColor stroke stroke-color strokeColor', + marker: 'markers marker shape', + range: 'range dataBox databox', + viewport: 'viewport viewPort viewBox viewbox', + opacity: 'opacity alpha transparency', + bounds: 'bound bounds boundaries limits', + tooManyColors: 'tooManyColors palette paletteMode optimizePalette enablePalette' + }); + if (options.positions === null) options.positions = []; + if (options.tooManyColors != null) _this3.tooManyColors = options.tooManyColors; + + if (!group) { + groups[i] = group = { + id: i, + scale: null, + translate: null, + scaleFract: null, + translateFract: null, + // buffers for active markers + activation: [], + // buffer for filtered markers + selectionBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'stream', + type: 'uint8' + }), + // buffers with data: it is faster to switch them per-pass + // than provide one congregate buffer + sizeBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'uint8' + }), + colorBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'uint8' + }), + positionBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'float' + }), + positionFractBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'float' + }) + }; + options = extend({}, Scatter.defaults, options); + } // force update triggers + + + if (options.positions && !('marker' in options)) { + options.marker = group.marker; + delete group.marker; + } // updating markers cause recalculating snapping + + + if (options.marker && !('positions' in options)) { + options.positions = group.positions; + delete group.positions; + } // global count of points + + + var hasSize = 0, + hasColor = 0; + updateDiff(group, options, [{ + snap: true, + size: function size(s, group) { + if (s == null) s = Scatter.defaults.size; + hasSize += s && s.length ? 1 : 0; + return s; + }, + borderSize: function borderSize(s, group) { + if (s == null) s = Scatter.defaults.borderSize; + hasSize += s && s.length ? 1 : 0; + return s; + }, + opacity: parseFloat, + // add colors to palette, save references + color: function color(c, group) { + if (c == null) c = Scatter.defaults.color; + c = _this3.updateColor(c); + hasColor++; + return c; + }, + borderColor: function borderColor(c, group) { + if (c == null) c = Scatter.defaults.borderColor; + c = _this3.updateColor(c); + hasColor++; + return c; + }, + bounds: function bounds(_bounds, group, options) { + if (!('range' in options)) options.range = null; + return _bounds; + }, + positions: function positions(_positions, group, options) { + var snap = group.snap; + var positionBuffer = group.positionBuffer, + positionFractBuffer = group.positionFractBuffer, + selectionBuffer = group.selectionBuffer; // separate buffers for x/y coordinates + + if (_positions.x || _positions.y) { + if (_positions.x.length) { + group.xAttr = { + buffer: regl.buffer(_positions.x), + offset: 0, + stride: 4, + count: _positions.x.length + }; + } else { + group.xAttr = { + buffer: _positions.x.buffer, + offset: _positions.x.offset * 4 || 0, + stride: (_positions.x.stride || 1) * 4, + count: _positions.x.count + }; + } + + if (_positions.y.length) { + group.yAttr = { + buffer: regl.buffer(_positions.y), + offset: 0, + stride: 4, + count: _positions.y.length + }; + } else { + group.yAttr = { + buffer: _positions.y.buffer, + offset: _positions.y.offset * 4 || 0, + stride: (_positions.y.stride || 1) * 4, + count: _positions.y.count + }; + } + + group.count = Math.max(group.xAttr.count, group.yAttr.count); + return _positions; + } + + _positions = flatten(_positions, 'float64'); + var count = group.count = Math.floor(_positions.length / 2); + var bounds = group.bounds = count ? getBounds(_positions, 2) : null; // if range is not provided updated - recalc it + + if (!options.range && !group.range) { + delete group.range; + options.range = bounds; + } // reset marker + + + if (!options.marker && !group.marker) { + delete group.marker; + options.marker = null; + } // build cluster tree if required + + + if (snap && (snap === true || count > snap)) { + group.tree = cluster(_positions, { + bounds: bounds + }); + } // existing tree instance + else if (snap && snap.length) { + group.tree = snap; + } + + if (group.tree) { + var opts = { + primitive: 'points', + usage: 'static', + data: group.tree, + type: 'uint32' + }; + if (group.elements) group.elements(opts);else group.elements = regl.elements(opts); + } // update position buffers + + + positionBuffer({ + data: f32.float(_positions), + usage: 'dynamic' + }); + positionFractBuffer({ + data: f32.fract(_positions), + usage: 'dynamic' + }); // expand selectionBuffer + + selectionBuffer({ + data: new Uint8Array(count), + type: 'uint8', + usage: 'stream' + }); + return _positions; + } + }, { + // create marker ids corresponding to known marker textures + marker: function marker(markers, group, options) { + var activation = group.activation; // reset marker elements + + activation.forEach(function (buffer) { + return buffer && buffer.destroy && buffer.destroy(); + }); + activation.length = 0; // single sdf marker + + if (!markers || typeof markers[0] === 'number') { + var id = _this3.addMarker(markers); + + activation[id] = true; + } // per-point markers use mask buffers to enable markers in vert shader + else { + var markerMasks = []; + + for (var _i = 0, l = Math.min(markers.length, group.count); _i < l; _i++) { + var _id = _this3.addMarker(markers[_i]); + + if (!markerMasks[_id]) markerMasks[_id] = new Uint8Array(group.count); // enable marker by default + + markerMasks[_id][_i] = 1; + } + + for (var _id2 = 0; _id2 < markerMasks.length; _id2++) { + if (!markerMasks[_id2]) continue; + var opts = { + data: markerMasks[_id2], + type: 'uint8', + usage: 'static' + }; + + if (!activation[_id2]) { + activation[_id2] = regl.buffer(opts); + } else { + activation[_id2](opts); + } + + activation[_id2].data = markerMasks[_id2]; + } + } + + return markers; + }, + range: function range(_range, group, options) { + var bounds = group.bounds; // FIXME: why do we need this? + + if (!bounds) return; + if (!_range) _range = bounds; + group.scale = [1 / (_range[2] - _range[0]), 1 / (_range[3] - _range[1])]; + group.translate = [-_range[0], -_range[1]]; + group.scaleFract = f32.fract(group.scale); + group.translateFract = f32.fract(group.translate); + return _range; + }, + viewport: function viewport(vp) { + var rect = parseRect(vp || [gl.drawingBufferWidth, gl.drawingBufferHeight]); // normalize viewport to the canvas coordinates + // rect.y = gl.drawingBufferHeight - rect.height - rect.y + + return rect; + } + }]); // update size buffer, if needed + + if (hasSize) { + var _group = group, + count = _group.count, + size = _group.size, + borderSize = _group.borderSize, + sizeBuffer = _group.sizeBuffer; + var sizes = new Uint8Array(count * 2); + + if (size.length || borderSize.length) { + for (var _i2 = 0; _i2 < count; _i2++) { + // we downscale size to allow for fractions + sizes[_i2 * 2] = Math.round((size[_i2] == null ? size : size[_i2]) * 255 / maxSize); + sizes[_i2 * 2 + 1] = Math.round((borderSize[_i2] == null ? borderSize : borderSize[_i2]) * 255 / maxSize); + } + } + + sizeBuffer({ + data: sizes, + usage: 'dynamic' + }); + } // update color buffer if needed + + + if (hasColor) { + var _group2 = group, + _count = _group2.count, + color = _group2.color, + borderColor = _group2.borderColor, + colorBuffer = _group2.colorBuffer; + var colors; // if too many colors - put colors to buffer directly + + if (_this3.tooManyColors) { + if (color.length || borderColor.length) { + colors = new Uint8Array(_count * 8); + + for (var _i3 = 0; _i3 < _count; _i3++) { + var _colorId = color[_i3]; + colors[_i3 * 8] = palette[_colorId * 4]; + colors[_i3 * 8 + 1] = palette[_colorId * 4 + 1]; + colors[_i3 * 8 + 2] = palette[_colorId * 4 + 2]; + colors[_i3 * 8 + 3] = palette[_colorId * 4 + 3]; + var borderColorId = borderColor[_i3]; + colors[_i3 * 8 + 4] = palette[borderColorId * 4]; + colors[_i3 * 8 + 5] = palette[borderColorId * 4 + 1]; + colors[_i3 * 8 + 6] = palette[borderColorId * 4 + 2]; + colors[_i3 * 8 + 7] = palette[borderColorId * 4 + 3]; + } + } + } // if limited amount of colors - keep palette color picking + // that saves significant memory + else { + if (color.length || borderColor.length) { + // we need slight data increase by 2 due to vec4 borderId in shader + colors = new Uint8Array(_count * 4 + 2); + + for (var _i4 = 0; _i4 < _count; _i4++) { + // put color coords in palette texture + if (color[_i4] != null) { + colors[_i4 * 4] = color[_i4] % maxColors; + colors[_i4 * 4 + 1] = Math.floor(color[_i4] / maxColors); + } + + if (borderColor[_i4] != null) { + colors[_i4 * 4 + 2] = borderColor[_i4] % maxColors; + colors[_i4 * 4 + 3] = Math.floor(borderColor[_i4] / maxColors); + } + } + } + } + + colorBuffer({ + data: colors || new Uint8Array(0), + type: 'uint8', + usage: 'dynamic' + }); + } + + return group; + }); +}; // get (and create) marker texture id + + +Scatter.prototype.addMarker = function (sdf) { + var markerTextures = this.markerTextures, + regl = this.regl, + markerCache = this.markerCache; + var pos = sdf == null ? 0 : markerCache.indexOf(sdf); + if (pos >= 0) return pos; // convert sdf to 0..255 range + + var distArr; + + if (sdf instanceof Uint8Array || sdf instanceof Uint8ClampedArray) { + distArr = sdf; + } else { + distArr = new Uint8Array(sdf.length); + + for (var i = 0, l = sdf.length; i < l; i++) { + distArr[i] = sdf[i] * 255; + } + } + + var radius = Math.floor(Math.sqrt(distArr.length)); + pos = markerTextures.length; + markerCache.push(sdf); + markerTextures.push(regl.texture({ + channels: 1, + data: distArr, + radius: radius, + mag: 'linear', + min: 'linear' + })); + return pos; +}; // register color to palette, return it's index or list of indexes + + +Scatter.prototype.updateColor = function (colors) { + var paletteIds = this.paletteIds, + palette = this.palette, + maxColors = this.maxColors; + + if (!Array.isArray(colors)) { + colors = [colors]; + } + + var idx = []; // if color groups - flatten them + + if (typeof colors[0] === 'number') { + var grouped = []; + + if (Array.isArray(colors)) { + for (var i = 0; i < colors.length; i += 4) { + grouped.push(colors.slice(i, i + 4)); + } + } else { + for (var _i5 = 0; _i5 < colors.length; _i5 += 4) { + grouped.push(colors.subarray(_i5, _i5 + 4)); + } + } + + colors = grouped; + } + + for (var _i6 = 0; _i6 < colors.length; _i6++) { + var color = colors[_i6]; + color = rgba(color, 'uint8'); + var id = colorId(color, false); // if new color - save it + + if (paletteIds[id] == null) { + var pos = palette.length; + paletteIds[id] = Math.floor(pos / 4); + palette[pos] = color[0]; + palette[pos + 1] = color[1]; + palette[pos + 2] = color[2]; + palette[pos + 3] = color[3]; + } + + idx[_i6] = paletteIds[id]; + } // detect if too many colors in palette + + + if (!this.tooManyColors && palette.length > maxColors * 4) this.tooManyColors = true; // limit max color + + this.updatePalette(palette); // keep static index for single-color property + + return idx.length === 1 ? idx[0] : idx; +}; + +Scatter.prototype.updatePalette = function (palette) { + if (this.tooManyColors) return; + var maxColors = this.maxColors, + paletteTexture = this.paletteTexture; + var requiredHeight = Math.ceil(palette.length * .25 / maxColors); // pad data + + if (requiredHeight > 1) { + palette = palette.slice(); + + for (var i = palette.length * .25 % maxColors; i < requiredHeight * maxColors; i++) { + palette.push(0, 0, 0, 0); + } + } // ensure height + + + if (paletteTexture.height < requiredHeight) { + paletteTexture.resize(maxColors, requiredHeight); + } // update full data + + + paletteTexture.subimage({ + width: Math.min(palette.length * .25, maxColors), + height: requiredHeight, + data: palette + }, 0, 0); +}; // remove unused stuff + + +Scatter.prototype.destroy = function () { + this.groups.forEach(function (group) { + group.sizeBuffer.destroy(); + group.positionBuffer.destroy(); + group.positionFractBuffer.destroy(); + group.colorBuffer.destroy(); + group.activation.forEach(function (b) { + return b && b.destroy && b.destroy(); + }); + group.selectionBuffer.destroy(); + if (group.elements) group.elements.destroy(); + }); + this.groups.length = 0; + this.paletteTexture.destroy(); + this.markerTextures.forEach(function (txt) { + return txt && txt.destroy && txt.destroy(); + }); + return this; +}; + +var extend$1 = _dereq_('object-assign'); + +var reglScatter2d = function reglScatter2d(regl, options) { + var scatter$$1 = new scatter(regl, options); + var render = scatter$$1.render.bind(scatter$$1); // expose API + + extend$1(render, { + render: render, + update: scatter$$1.update.bind(scatter$$1), + draw: scatter$$1.draw.bind(scatter$$1), + destroy: scatter$$1.destroy.bind(scatter$$1), + regl: scatter$$1.regl, + gl: scatter$$1.gl, + canvas: scatter$$1.gl.canvas, + groups: scatter$$1.groups, + markers: scatter$$1.markerCache, + palette: scatter$$1.palette + }); + return render; +}; + +module.exports = reglScatter2d; + +},{"array-bounds":13,"color-id":61,"color-normalize":63,"flatten-vertex-data":150,"glslify":257,"is-iexplorer":208,"object-assign":223,"parse-rect":226,"pick-by-alias":232,"point-cluster":236,"to-float32":284,"update-diff":293}],257:[function(_dereq_,module,exports){ +arguments[4][199][0].apply(exports,arguments) +},{"dup":199}],258:[function(_dereq_,module,exports){ +'use strict' - // FIXME: remove once https://github.com/regl-project/regl/issues/474 resolved - this.regl._refresh() - if (args.length) { - for (var i = 0; i < args.length; i++) { - this$1.drawItem(i, args[i]) - } - } - // draw all passes - else { - groups.forEach(function (group, i) { - this$1.drawItem(i) - }) - } +var createScatter = _dereq_('regl-scatter2d') +var pick = _dereq_('pick-by-alias') +var getBounds = _dereq_('array-bounds') +var raf = _dereq_('raf') +var arrRange = _dereq_('array-range') +var rect = _dereq_('parse-rect') +var flatten = _dereq_('flatten-vertex-data') - return this -} -// draw specific scatter group -Scatter.prototype.drawItem = function (id, els) { - var this$1 = this; +module.exports = SPLOM - var ref = this; - var groups = ref.groups; - var group = groups[id] - - // debug viewport - // let { viewport } = group - // gl.enable(gl.SCISSOR_TEST); - // gl.scissor(viewport.x, viewport.y, viewport.width, viewport.height); - // gl.clearColor(0, 0, 0, .5); - // gl.clear(gl.COLOR_BUFFER_BIT); - - if (typeof els === 'number') { - id = els - group = groups[els] - els = null - } - if (!(group && group.count && group.opacity)) { return } +// @constructor +function SPLOM (regl, options) { + if (!(this instanceof SPLOM)) { return new SPLOM(regl, options) } - // draw circles - if (group.activation[0]) { - // TODO: optimize this performance by making groups and regl.this props - this.drawCircle(this.getMarkerDrawOptions(0, group, els)) - } + // render passes + this.traces = [] - // draw all other available markers - var batch = [] + // passes for scatter, combined across traces + this.passes = {} - for (var i = 1; i < group.activation.length; i++) { - if (!group.activation[i] || (group.activation[i] !== true && !group.activation[i].data.length)) { continue } + this.regl = regl - batch.push.apply(batch, this$1.getMarkerDrawOptions(i, group, els)) - } + // main scatter drawing instance + this.scatter = createScatter(regl) - if (batch.length) { - this.drawMarker(batch) - } + this.canvas = this.scatter.canvas } -// get options for the marker ids -Scatter.prototype.getMarkerDrawOptions = function(markerId, group, elements) { - var this$1 = this; - var range = group.range; - var tree = group.tree; - var viewport = group.viewport; - var activation = group.activation; - var selectionBuffer = group.selectionBuffer; - var count = group.count; - var ref = this; - var regl = ref.regl; - - // direct points - if (!tree) { - // if elements array - draw unclustered points - if (elements) { - return [extend({}, group, { - markerTexture: this.markerTextures[markerId], - activation: activation[markerId], - count: elements.length, - elements: elements, - offset: 0 - })] - } - - return [ extend({}, group, { - markerTexture: this.markerTextures[markerId], - activation: activation[markerId], - offset: 0 - }) ] +// update & draw passes once per frame +SPLOM.prototype.render = function () { + var this$1 = this; + var ref; + + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + if (args.length) { + (ref = this).update.apply(ref, args) } - // clustered points - var batch = [] - - var lod = tree.range(range, { lod: true, px: [ - (range[2] - range[0]) / viewport.width, - (range[3] - range[1]) / viewport.height - ]}) - - // enable elements by using selection buffer - if (elements) { - var markerActivation = activation[markerId] - var mask = markerActivation.data - var data = new Uint8Array(count) - for (var i = 0; i < elements.length; i++) { - var id = elements[i] - data[id] = mask ? mask[id] : 1 + if (this.regl.attributes.preserveDrawingBuffer) { return this.draw() } + + // make sure draw is not called more often than once a frame + if (this.dirty) { + if (this.planned == null) { + this.planned = raf(function () { + this$1.draw() + this$1.dirty = true + this$1.planned = null + }) } - selectionBuffer.subdata(data) } - - for (var l = lod.length; l--;) { - var ref$1 = lod[l]; - var from = ref$1[0]; - var to = ref$1[1]; - - batch.push(extend({}, group, { - markerTexture: this$1.markerTextures[markerId], - activation: elements ? selectionBuffer : activation[markerId], - offset: from, - count: to - from - })) + else { + this.draw() + this.dirty = true + raf(function () { + this$1.dirty = false + }) } - return batch + return this } -// update groups options -Scatter.prototype.update = function () { + +// update passes +SPLOM.prototype.update = function () { var this$1 = this; + var ref; + var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - + while ( len-- ) args[ len ] = arguments[ len ]; if (!args.length) { return } - // passes are as single array - if (args.length === 1 && Array.isArray(args[0])) { args = args[0] } - - var ref = this; - var groups = ref.groups; - var gl = ref.gl; - var regl = ref.regl; - var maxSize = ref.maxSize; - var maxColors = ref.maxColors; - var palette = ref.palette; - - this.groups = groups = args.map(function (options, i) { - var group = groups[i] - - if (options === undefined) { return group } - - if (options === null) { options = { positions: null } } - else if (typeof options === 'function') { options = { ondraw: options } } - else if (typeof options[0] === 'number') { options = { positions: options } } - - // copy options to avoid mutation & handle aliases - options = pick(options, { - positions: 'positions data points', - snap: 'snap cluster lod tree', - size: 'sizes size radius', - borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', - color: 'colors color fill fill-color fillColor', - borderColor: 'borderColors borderColor stroke stroke-color strokeColor', - marker: 'markers marker shape', - range: 'range dataBox databox', - viewport: 'viewport viewPort viewBox viewbox', - opacity: 'opacity alpha transparency', - bounds: 'bound bounds boundaries limits' - }) + for (var i = 0; i < args.length; i++) { + this$1.updateItem(i, args[i]) + } - if (options.positions === null) { options.positions = [] } - - if (!group) { - groups[i] = group = { - id: i, - scale: null, - translate: null, - scaleFract: null, - translateFract: null, - - // buffers for active markers - activation: [], - - // buffer for filtered markers - selectionBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'stream', - type: 'uint8' - }), - - // buffers with data: it is faster to switch them per-pass - // than provide one congregate buffer - sizeBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'uint8' - }), - colorBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'uint8' - }), - positionBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'float' - }), - positionFractBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'float' - }) - } - options = extend({}, Scatter.defaults, options) - } + // remove nulled passes + this.traces = this.traces.filter(Boolean) - // force update triggers - if (options.positions && !('marker' in options)) { - options.marker = group.marker - delete group.marker + // FIXME: update passes independently + var passes = [] + var offset = 0 + for (var i$1 = 0; i$1 < this.traces.length; i$1++) { + var trace = this$1.traces[i$1] + var tracePasses = this$1.traces[i$1].passes + for (var j = 0; j < tracePasses.length; j++) { + passes.push(this$1.passes[tracePasses[j]]) } + // save offset of passes + trace.passOffset = offset + offset += trace.passes.length + } - // updating markers cause recalculating snapping - if (options.marker && !('positions' in options)) { - options.positions = group.positions - delete group.positions - } + (ref = this.scatter).update.apply(ref, passes) - // global count of points - var hasSize = 0, hasColor = 0 + return this +} - updateDiff(group, options, [{ - snap: true, - size: function (s, group) { - if (s == null) { s = Scatter.defaults.size } - hasSize += s && s.length ? 1 : 0 - return s - }, - borderSize: function (s, group) { - if (s == null) { s = Scatter.defaults.borderSize } - hasSize += s && s.length ? 1 : 0 - return s - }, - opacity: parseFloat, - - // add colors to palette, save references - color: function (c, group) { - if (c == null) { c = Scatter.defaults.color } - c = this$1.updateColor(c) - hasColor++ - return c - }, - borderColor: function (c, group) { - if (c == null) { c = Scatter.defaults.borderColor } - c = this$1.updateColor(c) - hasColor++ - return c - }, - bounds: function (bounds, group, options) { - if (!('range' in options)) { options.range = null } - return bounds - }, +// update trace by index, not supposed to be called directly +SPLOM.prototype.updateItem = function (i, options) { + var this$1 = this; - positions: function (positions, group, options) { - var snap = group.snap; - var positionBuffer = group.positionBuffer; - var positionFractBuffer = group.positionFractBuffer; - var selectionBuffer = group.selectionBuffer; - - // separate buffers for x/y coordinates - if (positions.x || positions.y) { - if (positions.x.length) { - group.xAttr = { - buffer: regl.buffer(positions.x), - offset: 0, - stride: 4, - count: positions.x.length - } - } - else { - group.xAttr = { - buffer: positions.x.buffer, - offset: positions.x.offset * 4 || 0, - stride: (positions.x.stride || 1) * 4, - count: positions.x.count - } - } - if (positions.y.length) { - group.yAttr = { - buffer: regl.buffer(positions.y), - offset: 0, - stride: 4, - count: positions.y.length - } - } - else { - group.yAttr = { - buffer: positions.y.buffer, - offset: positions.y.offset * 4 || 0, - stride: (positions.y.stride || 1) * 4, - count: positions.y.count - } - } - group.count = Math.max(group.xAttr.count, group.yAttr.count) + var ref = this; + var regl = ref.regl; - return positions - } + // remove pass if null + if (options === null) { + this.traces[i] = null + return this + } - positions = flatten(positions, 'float64') + if (!options) { return this } + + var o = pick(options, { + data: 'data items columns rows values dimensions samples x', + snap: 'snap cluster', + size: 'sizes size radius', + color: 'colors color fill fill-color fillColor', + opacity: 'opacity alpha transparency opaque', + borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', + borderColor: 'borderColors borderColor bordercolor stroke stroke-color strokeColor', + marker: 'markers marker shape', + range: 'range ranges databox dataBox', + viewport: 'viewport viewBox viewbox', + domain: 'domain domains area areas', + padding: 'pad padding paddings pads margin margins', + transpose: 'transpose transposed', + diagonal: 'diagonal diag showDiagonal', + upper: 'upper up top upperhalf upperHalf showupperhalf showUpper showUpperHalf', + lower: 'lower low bottom lowerhalf lowerHalf showlowerhalf showLowerHalf showLower' + }) - var count = group.count = Math.floor(positions.length / 2) - var bounds = group.bounds = count ? getBounds(positions, 2) : null + // we provide regl buffer per-trace, since trace data can be changed + var trace = (this.traces[i] || (this.traces[i] = { + id: i, + buffer: regl.buffer({ + usage: 'dynamic', + type: 'float', + data: new Uint8Array() + }), + color: 'black', + marker: null, + size: 12, + borderColor: 'transparent', + borderSize: 1, + viewport: rect([regl._gl.drawingBufferWidth, regl._gl.drawingBufferHeight]), + padding: [0, 0, 0, 0], + opacity: 1, + diagonal: true, + upper: true, + lower: true + })) - // if range is not provided updated - recalc it - if (!options.range && !group.range) { - delete group.range - options.range = bounds - } - // reset marker - if (!options.marker && !group.marker) { - delete group.marker; - options.marker = null; - } + // save styles + if (o.color != null) { + trace.color = o.color + } + if (o.size != null) { + trace.size = o.size + } + if (o.marker != null) { + trace.marker = o.marker + } + if (o.borderColor != null) { + trace.borderColor = o.borderColor + } + if (o.borderSize != null) { + trace.borderSize = o.borderSize + } + if (o.opacity != null) { + trace.opacity = o.opacity + } + if (o.viewport) { + trace.viewport = rect(o.viewport) + } + if (o.diagonal != null) { trace.diagonal = o.diagonal } + if (o.upper != null) { trace.upper = o.upper } + if (o.lower != null) { trace.lower = o.lower } - // build cluster tree if required - if (snap && (snap === true || count > snap)) { - group.tree = cluster(positions, { bounds: bounds }) - } - // existing tree instance - else if (snap && snap.length) { - group.tree = snap - } + // put flattened data into buffer + if (o.data) { + trace.buffer(flatten(o.data)) + trace.columns = o.data.length + trace.count = o.data[0].length - if (group.tree) { - var opts = { - primitive: 'points', - usage: 'static', - data: group.tree, - type: 'uint32' - } - if (group.elements) { group.elements(opts) } - else { group.elements = regl.elements(opts) } - } + // detect bounds per-column + trace.bounds = [] - // update position buffers - positionBuffer({ - data: f32.float(positions), - usage: 'dynamic' - }) - positionFractBuffer({ - data: f32.fract(positions), - usage: 'dynamic' - }) + for (var i$1 = 0; i$1 < trace.columns; i$1++) { + trace.bounds[i$1] = getBounds(o.data[i$1], 1) + } + } - // expand selectionBuffer - selectionBuffer({ - data: new Uint8Array(count), - type: 'uint8', - usage: 'stream' - }) + // add proper range updating markers + var multirange + if (o.range) { + trace.range = o.range + multirange = trace.range && typeof trace.range[0] !== 'number' + } - return positions - } - }, { - // create marker ids corresponding to known marker textures - marker: function (markers, group, options) { - var activation = group.activation; - - // reset marker elements - activation.forEach(function (buffer) { return buffer && buffer.destroy && buffer.destroy(); }) - activation.length = 0 - - // single sdf marker - if (!markers || typeof markers[0] === 'number') { - var id = this$1.addMarker(markers) - activation[id] = true - } + if (o.domain) { + trace.domain = o.domain + } + var multipadding = false + if (o.padding != null) { + // multiple paddings + if (Array.isArray(o.padding) && o.padding.length === trace.columns && typeof o.padding[o.padding.length - 1] === 'number') { + trace.padding = o.padding.map(getPad) + multipadding = true + } + // single padding + else { + trace.padding = getPad(o.padding) + } + } - // per-point markers use mask buffers to enable markers in vert shader - else { - var markerMasks = [] + // create passes + var m = trace.columns + var n = trace.count - for (var i = 0, l = Math.min(markers.length, group.count); i < l; i++) { - var id$1 = this$1.addMarker(markers[i]) + var w = trace.viewport.width + var h = trace.viewport.height + var left = trace.viewport.x + var top = trace.viewport.y + var iw = w / m + var ih = h / m - if (!markerMasks[id$1]) { markerMasks[id$1] = new Uint8Array(group.count) } + trace.passes = [] - // enable marker by default - markerMasks[id$1][i] = 1 - } + for (var i$2 = 0; i$2 < m; i$2++) { + for (var j = 0; j < m; j++) { + if (!trace.diagonal && j === i$2) { continue } + if (!trace.upper && i$2 > j) { continue } + if (!trace.lower && i$2 < j) { continue } - for (var id$2 = 0; id$2 < markerMasks.length; id$2++) { - if (!markerMasks[id$2]) { continue } + var key = passId(trace.id, i$2, j) - var opts = { - data: markerMasks[id$2], - type: 'uint8', - usage: 'static' - } - if (!activation[id$2]) { - activation[id$2] = regl.buffer(opts) - } - else { - activation[id$2](opts) - } + var pass = this$1.passes[key] || (this$1.passes[key] = {}) - activation[id$2].data = markerMasks[id$2] + if (o.data) { + if (o.transpose) { + pass.positions = { + x: {buffer: trace.buffer, offset: j, count: n, stride: m}, + y: {buffer: trace.buffer, offset: i$2, count: n, stride: m} } } - - return markers - }, - - range: function (range, group, options) { - var bounds = group.bounds - - // FIXME: why do we need this? - if (!bounds) { return } - if (!range) { range = bounds } - - group.scale = [1 / (range[2] - range[0]), 1 / (range[3] - range[1])] - group.translate = [-range[0], -range[1]] - - group.scaleFract = f32.fract(group.scale) - group.translateFract = f32.fract(group.translate) - - return range - }, - - viewport: function (vp) { - var rect = parseRect(vp || [ - gl.drawingBufferWidth, - gl.drawingBufferHeight - ]) - - // normalize viewport to the canvas coordinates - // rect.y = gl.drawingBufferHeight - rect.height - rect.y - - return rect - } - }]) - - // update size buffer, if needed - if (hasSize) { - var count = group.count; - var size = group.size; - var borderSize = group.borderSize; - var sizeBuffer = group.sizeBuffer; - - var sizes = new Uint8Array(count*2) - if (size.length || borderSize.length) { - for (var i$1 = 0; i$1 < count; i$1++) { - // we downscale size to allow for fractions - sizes[i$1*2] = Math.round((size[i$1] == null ? size : size[i$1]) * 255 / maxSize) - sizes[i$1*2 + 1] = Math.round((borderSize[i$1] == null ? borderSize : borderSize[i$1]) * 255 / maxSize) - } - } - sizeBuffer({ - data: sizes, - usage: 'dynamic' - }) - } - - // update color buffer if needed - if (hasColor) { - var count$1 = group.count; - var color = group.color; - var borderColor = group.borderColor; - var colorBuffer = group.colorBuffer; - var colors - - // if too many colors - put colors to buffer directly - if (this$1.tooManyColors) { - if (color.length || borderColor.length) { - colors = new Uint8Array(count$1 * 8) - for (var i$2 = 0; i$2 < count$1; i$2++) { - var colorId = color[i$2] - colors[i$2*8] = palette[colorId*4] - colors[i$2*8 + 1] = palette[colorId*4 + 1] - colors[i$2*8 + 2] = palette[colorId*4 + 2] - colors[i$2*8 + 3] = palette[colorId*4 + 3] - - var borderColorId = borderColor[i$2] - colors[i$2*8 + 4] = palette[borderColorId*4] - colors[i$2*8 + 5] = palette[borderColorId*4 + 1] - colors[i$2*8 + 6] = palette[borderColorId*4 + 2] - colors[i$2*8 + 7] = palette[borderColorId*4 + 3] + else { + pass.positions = { + x: {buffer: trace.buffer, offset: j * n, count: n}, + y: {buffer: trace.buffer, offset: i$2 * n, count: n} } } + + pass.bounds = getBox(trace.bounds, i$2, j) } - // if limited amount of colors - keep palette color picking - // that saves significant memory - else { - if (color.length || borderColor.length) { - // we need slight data increase by 2 due to vec4 borderId in shader - colors = new Uint8Array(count$1 * 4 + 2) - for (var i$3 = 0; i$3 < count$1; i$3++) { - // put color coords in palette texture - if (color[i$3] != null) { - colors[i$3*4] = color[i$3] % maxColors - colors[i$3*4 + 1] = Math.floor(color[i$3] / maxColors) - } - if (borderColor[i$3] != null) { - colors[i$3*4 + 2] = borderColor[i$3] % maxColors - colors[i$3*4 + 3] = Math.floor(borderColor[i$3] / maxColors) - } - } + if (o.domain || o.viewport || o.data) { + var pad = multipadding ? getBox(trace.padding, i$2, j) : trace.padding + if (trace.domain) { + var ref$1 = getBox(trace.domain, i$2, j); + var lox = ref$1[0]; + var loy = ref$1[1]; + var hix = ref$1[2]; + var hiy = ref$1[3]; + + pass.viewport = [ + left + lox * w + pad[0], + top + loy * h + pad[1], + left + hix * w - pad[2], + top + hiy * h - pad[3] + ] + } + // consider auto-domain equipartial + else { + pass.viewport = [ + left + j * iw + iw * pad[0], + top + i$2 * ih + ih * pad[1], + left + (j + 1) * iw - iw * pad[2], + top + (i$2 + 1) * ih - ih * pad[3] + ] } } - colorBuffer({ - data: colors || new Uint8Array(0), - type: 'uint8', - usage: 'dynamic' - }) - } - - return group - }) -} - - -// get (and create) marker texture id -Scatter.prototype.addMarker = function (sdf) { - var ref = this; - var markerTextures = ref.markerTextures; - var regl = ref.regl; - var markerCache = ref.markerCache; - - var pos = sdf == null ? 0 : markerCache.indexOf(sdf) + if (o.color) { pass.color = trace.color } + if (o.size) { pass.size = trace.size } + if (o.marker) { pass.marker = trace.marker } + if (o.borderSize) { pass.borderSize = trace.borderSize } + if (o.borderColor) { pass.borderColor = trace.borderColor } + if (o.opacity) { pass.opacity = trace.opacity } - if (pos >= 0) { return pos } + if (o.range) { + pass.range = multirange ? getBox(trace.range, i$2, j) : trace.range || pass.bounds + } - // convert sdf to 0..255 range - var distArr - if (sdf instanceof Uint8Array || sdf instanceof Uint8ClampedArray) { - distArr = sdf - } - else { - distArr = new Uint8Array(sdf.length) - for (var i = 0, l = sdf.length; i < l; i++) { - distArr[i] = sdf[i] * 255 + trace.passes.push(key) } } - var radius = Math.floor(Math.sqrt(distArr.length)) - - pos = markerTextures.length - - markerCache.push(sdf) - markerTextures.push(regl.texture({ - channels: 1, - data: distArr, - radius: radius, - mag: 'linear', - min: 'linear' - })) - - return pos + return this } -// register color to palette, return it's index or list of indexes -Scatter.prototype.updateColor = function (colors) { - var ref = this; - var paletteIds = ref.paletteIds; - var palette = ref.palette; - var maxColors = ref.maxColors; - if (!Array.isArray(colors)) { - colors = [colors] +// draw all or passed passes +SPLOM.prototype.draw = function () { + var this$1 = this; + var ref$2; + + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + if (!args.length) { + this.scatter.draw() } - - var idx = [] - - // if color groups - flatten them - if (typeof colors[0] === 'number') { - var grouped = [] - - if (Array.isArray(colors)) { - for (var i = 0; i < colors.length; i+=4) { - grouped.push(colors.slice(i, i+4)) + else { + var idx = [] + for (var i = 0; i < args.length; i++) { + // draw(0, 2, 5) - draw traces + if (typeof args[i] === 'number' ) { + var ref = this$1.traces[args[i]]; + var passes = ref.passes; + var passOffset = ref.passOffset; + idx.push.apply(idx, arrRange(passOffset, passOffset + passes.length)) } - } - else { - for (var i$1 = 0; i$1 < colors.length; i$1+=4) { - grouped.push(colors.subarray(i$1, i$1+4)) + // draw([0, 1, 2 ...], [3, 4, 5]) - draw points + else if (args[i].length) { + var els = args[i] + var ref$1 = this$1.traces[i]; + var passes$1 = ref$1.passes; + var passOffset$1 = ref$1.passOffset; + passes$1 = passes$1.map(function (passId, i) { + idx[passOffset$1 + i] = els + }) } } - - colors = grouped + (ref$2 = this.scatter).draw.apply(ref$2, idx) } - for (var i$2 = 0; i$2 < colors.length; i$2++) { - var color = colors[i$2] + return this +} - color = rgba(color, 'uint8') - var id = colorId(color, false) +// dispose resources +SPLOM.prototype.destroy = function () { + this.traces.forEach(function (trace) { + if (trace.buffer && trace.buffer.destroy) { trace.buffer.destroy() } + }) + this.traces = null + this.passes = null - // if new color - save it - if (paletteIds[id] == null) { - var pos = palette.length - paletteIds[id] = Math.floor(pos / 4) - palette[pos] = color[0] - palette[pos+1] = color[1] - palette[pos+2] = color[2] - palette[pos+3] = color[3] - } + this.scatter.destroy() - idx[i$2] = paletteIds[id] - } + return this +} - // detect if too many colors in palette - if (!this.tooManyColors && palette.length > maxColors * maxColors * 4) { this.tooManyColors = true } - // limit max color - this.updatePalette(palette) +// return pass corresponding to trace i- j- square +function passId (trace, i, j) { + var id = (trace.id != null ? trace.id : trace) + var n = i + var m = j + var key = id << 16 | (n & 0xff) << 8 | m & 0xff - // keep static index for single-color property - return idx.length === 1 ? idx[0] : idx + return key } -Scatter.prototype.updatePalette = function (palette) { - if (this.tooManyColors) { return } - var ref = this; - var maxColors = ref.maxColors; - var paletteTexture = ref.paletteTexture; - - var requiredHeight = Math.ceil(palette.length * .25 / maxColors) +// return bounding box corresponding to a pass +function getBox (items, i, j) { + var ilox, iloy, ihix, ihiy, jlox, jloy, jhix, jhiy + var iitem = items[i], jitem = items[j] - // pad data - if (requiredHeight > 1) { - palette = palette.slice() - for (var i = (palette.length * .25) % maxColors; i < requiredHeight * maxColors; i++) { - palette.push(0, 0, 0, 0) - } + if (iitem.length > 2) { + ilox = iitem[0] + ihix = iitem[2] + iloy = iitem[1] + ihiy = iitem[3] + } + else if (iitem.length) { + ilox = iloy = iitem[0] + ihix = ihiy = iitem[1] + } + else { + ilox = iitem.x + iloy = iitem.y + ihix = iitem.x + iitem.width + ihiy = iitem.y + iitem.height } - // ensure height - if (paletteTexture.height < requiredHeight) { - paletteTexture.resize(maxColors, requiredHeight) + if (jitem.length > 2) { + jlox = jitem[0] + jhix = jitem[2] + jloy = jitem[1] + jhiy = jitem[3] + } + else if (jitem.length) { + jlox = jloy = jitem[0] + jhix = jhiy = jitem[1] + } + else { + jlox = jitem.x + jloy = jitem.y + jhix = jitem.x + jitem.width + jhiy = jitem.y + jitem.height } - // update full data - paletteTexture.subimage({ - width: Math.min(palette.length * .25, maxColors), - height: requiredHeight, - data: palette - }, 0, 0) + return [ jlox, iloy, jhix, ihiy ] } -// remove unused stuff -Scatter.prototype.destroy = function () { - this.groups.forEach(function (group) { - group.sizeBuffer.destroy() - group.positionBuffer.destroy() - group.positionFractBuffer.destroy() - group.colorBuffer.destroy() - group.activation.forEach(function (b) { return b && b.destroy && b.destroy(); }) - group.selectionBuffer.destroy() - - if (group.elements) { group.elements.destroy() } - }) - this.groups.length = 0 - - this.paletteTexture.destroy() - - this.markerTextures.forEach(function (txt) { return txt && txt.destroy && txt.destroy(); }) - return this +function getPad (arg) { + if (typeof arg === 'number') { return [arg, arg, arg, arg] } + else if (arg.length === 2) { return [arg[0], arg[1], arg[0], arg[1]] } + else { + var box = rect(arg) + return [box.x, box.y, box.x + box.width, box.y + box.height] + } } -},{"array-bounds":13,"color-id":61,"color-normalize":63,"flatten-vertex-data":150,"glslify":199,"is-iexplorer":208,"object-assign":223,"parse-rect":226,"pick-by-alias":232,"point-cluster":236,"to-float32":285,"update-diff":294}],258:[function(_dereq_,module,exports){ -'use strict' - - -var createScatter = _dereq_('regl-scatter2d/scatter') -var pick = _dereq_('pick-by-alias') -var getBounds = _dereq_('array-bounds') -var raf = _dereq_('raf') -var arrRange = _dereq_('array-range') -var rect = _dereq_('parse-rect') -var flatten = _dereq_('flatten-vertex-data') - - -module.exports = SPLOM - - -// @constructor -function SPLOM (regl, options) { - if (!(this instanceof SPLOM)) { return new SPLOM(regl, options) } - - // render passes - this.traces = [] - - // passes for scatter, combined across traces - this.passes = {} - - this.regl = regl - - // main scatter drawing instance - this.scatter = createScatter(regl) - - this.canvas = this.scatter.canvas -} - - -// update & draw passes once per frame -SPLOM.prototype.render = function () { - var this$1 = this; - var ref; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (args.length) { - (ref = this).update.apply(ref, args) - } - - if (this.regl.attributes.preserveDrawingBuffer) { return this.draw() } - - // make sure draw is not called more often than once a frame - if (this.dirty) { - if (this.planned == null) { - this.planned = raf(function () { - this$1.draw() - this$1.dirty = true - this$1.planned = null - }) - } - } - else { - this.draw() - this.dirty = true - raf(function () { - this$1.dirty = false - }) - } - - return this -} - - -// update passes -SPLOM.prototype.update = function () { - var this$1 = this; - var ref; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (!args.length) { return } - - for (var i = 0; i < args.length; i++) { - this$1.updateItem(i, args[i]) - } - - // remove nulled passes - this.traces = this.traces.filter(Boolean) - - // FIXME: update passes independently - var passes = [] - var offset = 0 - for (var i$1 = 0; i$1 < this.traces.length; i$1++) { - var trace = this$1.traces[i$1] - var tracePasses = this$1.traces[i$1].passes - for (var j = 0; j < tracePasses.length; j++) { - passes.push(this$1.passes[tracePasses[j]]) - } - // save offset of passes - trace.passOffset = offset - offset += trace.passes.length - } - - (ref = this.scatter).update.apply(ref, passes) - - return this -} - - -// update trace by index, not supposed to be called directly -SPLOM.prototype.updateItem = function (i, options) { - var this$1 = this; - - var ref = this; - var regl = ref.regl; - - // remove pass if null - if (options === null) { - this.traces[i] = null - return this - } - - if (!options) { return this } - - var o = pick(options, { - data: 'data items columns rows values dimensions samples x', - snap: 'snap cluster', - size: 'sizes size radius', - color: 'colors color fill fill-color fillColor', - opacity: 'opacity alpha transparency opaque', - borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', - borderColor: 'borderColors borderColor bordercolor stroke stroke-color strokeColor', - marker: 'markers marker shape', - range: 'range ranges databox dataBox', - viewport: 'viewport viewBox viewbox', - domain: 'domain domains area areas', - padding: 'pad padding paddings pads margin margins', - transpose: 'transpose transposed', - diagonal: 'diagonal diag showDiagonal', - upper: 'upper up top upperhalf upperHalf showupperhalf showUpper showUpperHalf', - lower: 'lower low bottom lowerhalf lowerHalf showlowerhalf showLowerHalf showLower' - }) - - // we provide regl buffer per-trace, since trace data can be changed - var trace = (this.traces[i] || (this.traces[i] = { - id: i, - buffer: regl.buffer({ - usage: 'dynamic', - type: 'float', - data: new Uint8Array() - }), - color: 'black', - marker: null, - size: 12, - borderColor: 'transparent', - borderSize: 1, - viewport: rect([regl._gl.drawingBufferWidth, regl._gl.drawingBufferHeight]), - padding: [0, 0, 0, 0], - opacity: 1, - diagonal: true, - upper: true, - lower: true - })) - - - // save styles - if (o.color != null) { - trace.color = o.color - } - if (o.size != null) { - trace.size = o.size - } - if (o.marker != null) { - trace.marker = o.marker - } - if (o.borderColor != null) { - trace.borderColor = o.borderColor - } - if (o.borderSize != null) { - trace.borderSize = o.borderSize - } - if (o.opacity != null) { - trace.opacity = o.opacity - } - if (o.viewport) { - trace.viewport = rect(o.viewport) - } - if (o.diagonal != null) { trace.diagonal = o.diagonal } - if (o.upper != null) { trace.upper = o.upper } - if (o.lower != null) { trace.lower = o.lower } - - // put flattened data into buffer - if (o.data) { - trace.buffer(flatten(o.data)) - trace.columns = o.data.length - trace.count = o.data[0].length - - // detect bounds per-column - trace.bounds = [] - - for (var i$1 = 0; i$1 < trace.columns; i$1++) { - trace.bounds[i$1] = getBounds(o.data[i$1], 1) - } - } - - // add proper range updating markers - var multirange - if (o.range) { - trace.range = o.range - multirange = trace.range && typeof trace.range[0] !== 'number' - } - - if (o.domain) { - trace.domain = o.domain - } - var multipadding = false - if (o.padding != null) { - // multiple paddings - if (Array.isArray(o.padding) && o.padding.length === trace.columns && typeof o.padding[o.padding.length - 1] === 'number') { - trace.padding = o.padding.map(getPad) - multipadding = true - } - // single padding - else { - trace.padding = getPad(o.padding) - } - } - - // create passes - var m = trace.columns - var n = trace.count - - var w = trace.viewport.width - var h = trace.viewport.height - var left = trace.viewport.x - var top = trace.viewport.y - var iw = w / m - var ih = h / m - - trace.passes = [] - - for (var i$2 = 0; i$2 < m; i$2++) { - for (var j = 0; j < m; j++) { - if (!trace.diagonal && j === i$2) { continue } - if (!trace.upper && i$2 > j) { continue } - if (!trace.lower && i$2 < j) { continue } - - var key = passId(trace.id, i$2, j) - - var pass = this$1.passes[key] || (this$1.passes[key] = {}) - - if (o.data) { - if (o.transpose) { - pass.positions = { - x: {buffer: trace.buffer, offset: j, count: n, stride: m}, - y: {buffer: trace.buffer, offset: i$2, count: n, stride: m} - } - } - else { - pass.positions = { - x: {buffer: trace.buffer, offset: j * n, count: n}, - y: {buffer: trace.buffer, offset: i$2 * n, count: n} - } - } - - pass.bounds = getBox(trace.bounds, i$2, j) - } - - if (o.domain || o.viewport || o.data) { - var pad = multipadding ? getBox(trace.padding, i$2, j) : trace.padding - if (trace.domain) { - var ref$1 = getBox(trace.domain, i$2, j); - var lox = ref$1[0]; - var loy = ref$1[1]; - var hix = ref$1[2]; - var hiy = ref$1[3]; - - pass.viewport = [ - left + lox * w + pad[0], - top + loy * h + pad[1], - left + hix * w - pad[2], - top + hiy * h - pad[3] - ] - } - // consider auto-domain equipartial - else { - pass.viewport = [ - left + j * iw + iw * pad[0], - top + i$2 * ih + ih * pad[1], - left + (j + 1) * iw - iw * pad[2], - top + (i$2 + 1) * ih - ih * pad[3] - ] - } - } - - if (o.color) { pass.color = trace.color } - if (o.size) { pass.size = trace.size } - if (o.marker) { pass.marker = trace.marker } - if (o.borderSize) { pass.borderSize = trace.borderSize } - if (o.borderColor) { pass.borderColor = trace.borderColor } - if (o.opacity) { pass.opacity = trace.opacity } - - if (o.range) { - pass.range = multirange ? getBox(trace.range, i$2, j) : trace.range || pass.bounds - } - - trace.passes.push(key) - } - } - - return this -} - - -// draw all or passed passes -SPLOM.prototype.draw = function () { - var this$1 = this; - var ref$2; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (!args.length) { - this.scatter.draw() - } - else { - var idx = [] - for (var i = 0; i < args.length; i++) { - // draw(0, 2, 5) - draw traces - if (typeof args[i] === 'number' ) { - var ref = this$1.traces[args[i]]; - var passes = ref.passes; - var passOffset = ref.passOffset; - idx.push.apply(idx, arrRange(passOffset, passOffset + passes.length)) - } - // draw([0, 1, 2 ...], [3, 4, 5]) - draw points - else if (args[i].length) { - var els = args[i] - var ref$1 = this$1.traces[i]; - var passes$1 = ref$1.passes; - var passOffset$1 = ref$1.passOffset; - passes$1 = passes$1.map(function (passId, i) { - idx[passOffset$1 + i] = els - }) - } - } - (ref$2 = this.scatter).draw.apply(ref$2, idx) - } - - return this -} - - -// dispose resources -SPLOM.prototype.destroy = function () { - this.traces.forEach(function (trace) { - if (trace.buffer && trace.buffer.destroy) { trace.buffer.destroy() } - }) - this.traces = null - this.passes = null - - this.scatter.destroy() - - return this -} - - -// return pass corresponding to trace i- j- square -function passId (trace, i, j) { - var id = (trace.id != null ? trace.id : trace) - var n = i - var m = j - var key = id << 16 | (n & 0xff) << 8 | m & 0xff - - return key -} - - -// return bounding box corresponding to a pass -function getBox (items, i, j) { - var ilox, iloy, ihix, ihiy, jlox, jloy, jhix, jhiy - var iitem = items[i], jitem = items[j] - - if (iitem.length > 2) { - ilox = iitem[0] - ihix = iitem[2] - iloy = iitem[1] - ihiy = iitem[3] - } - else if (iitem.length) { - ilox = iloy = iitem[0] - ihix = ihiy = iitem[1] - } - else { - ilox = iitem.x - iloy = iitem.y - ihix = iitem.x + iitem.width - ihiy = iitem.y + iitem.height - } - - if (jitem.length > 2) { - jlox = jitem[0] - jhix = jitem[2] - jloy = jitem[1] - jhiy = jitem[3] - } - else if (jitem.length) { - jlox = jloy = jitem[0] - jhix = jhiy = jitem[1] - } - else { - jlox = jitem.x - jloy = jitem.y - jhix = jitem.x + jitem.width - jhiy = jitem.y + jitem.height - } - - return [ jlox, iloy, jhix, ihiy ] -} - - -function getPad (arg) { - if (typeof arg === 'number') { return [arg, arg, arg, arg] } - else if (arg.length === 2) { return [arg[0], arg[1], arg[0], arg[1]] } - else { - var box = rect(arg) - return [box.x, box.y, box.x + box.width, box.y + box.height] - } -} - -},{"array-bounds":13,"array-range":15,"flatten-vertex-data":150,"parse-rect":226,"pick-by-alias":232,"raf":249,"regl-scatter2d/scatter":257}],259:[function(_dereq_,module,exports){ -(function(pa,W){"object"===typeof exports&&"undefined"!==typeof module?module.exports=W():"function"===typeof define&&define.amd?define(W):pa.createREGL=W()})(this,function(){function pa(a,b){this.id=Ab++;this.type=a;this.data=b}function W(a){if(0===a.length)return[];var b=a.charAt(0),c=a.charAt(a.length-1);if(1>>=b;c=(255>>=c;b|=c;c=(15>>=c;b|=c;c=(3>>c>>1}function cb(){function a(a){a:{for(var b=16;268435456>=b;b*=16)if(a<=b){a=b;break a}a=0}b=c[bb(a)>>2];return 0>2].push(a)}var c=O(8,function(){return[]});return{alloc:a,free:b,allocType:function(b,c){var d=null;switch(b){case 5120:d=new Int8Array(a(c),0,c);break;case 5121:d=new Uint8Array(a(c),0,c);break;case 5122:d=new Int16Array(a(2*c),0,c);break;case 5123:d=new Uint16Array(a(2*c),0,c);break;case 5124:d=new Int32Array(a(4*c),0,c);break;case 5125:d=new Uint32Array(a(4*c),0,c);break;case 5126:d=new Float32Array(a(4*c),0,c);break;default:return null}return d.length!==c?d.subarray(0, -c):d},freeType:function(a){b(a.buffer)}}}function ka(a){return!!a&&"object"===typeof a&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&"number"===typeof a.offset&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||P(a.data))}function db(a,b,c,e,f,d){for(var n=0;ne&&(e=d.buffer.byteLength,5123===k?e>>=1:5125===k&&(e>>=2));d.vertCount=e;e=g;0>g&&(e=4,g=d.buffer.dimension,1===g&&(e=0),2===g&&(e=1),3===g&&(e=4));d.primType=e}function n(a){e.elementsCount--;delete k[a.id];a.buffer.destroy();a.buffer=null}var k={},r=0,p={uint8:5121,uint16:5123};b.oes_element_index_uint&&(p.uint32=5125);f.prototype.bind=function(){this.buffer.bind()};var u=[];return{create:function(a,b){function l(a){if(a)if("number"===typeof a)g(a),h.primType=4,h.vertCount=a|0, -h.type=5121;else{var b=null,c=35044,e=-1,f=-1,m=0,k=0;if(Array.isArray(a)||P(a)||ka(a))b=a;else if("data"in a&&(b=a.data),"usage"in a&&(c=jb[a.usage]),"primitive"in a&&(e=Sa[a.primitive]),"count"in a&&(f=a.count|0),"type"in a&&(k=p[a.type]),"length"in a)m=a.length|0;else if(m=f,5123===k||5122===k)m*=2;else if(5125===k||5124===k)m*=4;d(h,b,c,e,f,m,k)}else g(),h.primType=4,h.vertCount=0,h.type=5121;return l}var g=c.create(null,34963,!0),h=new f(g._buffer);e.elementsCount++;l(a);l._reglType="elements"; -l._elements=h;l.subdata=function(a,b){g.subdata(a,b);return l};l.destroy=function(){n(h)};return l},createStream:function(a){var b=u.pop();b||(b=new f(c.create(null,34963,!0,!1)._buffer));d(b,a,35040,-1,-1,0,0);return b},destroyStream:function(a){u.push(a)},getElements:function(a){return"function"===typeof a&&a._elements instanceof f?a._elements:null},clear:function(){R(k).forEach(n)}}}function kb(a){for(var b=z.allocType(5123,a.length),c=0;c>>31<<15,d=(e<<1>>>24)-127,e=e>>13&1023;b[c]=-24>d?f:-14>d?f+(e+1024>>-14-d):15>=d,c.height>>=d,C(c,e[d]),a.mipmask|=1<b;++b)a.images[b]=null;return a}function ib(a){for(var b=a.images,c=0;cb){for(var c=0;c=--this.refCount&&w(this)}});n.profile&&(d.getTotalTextureSize=function(){var a=0;Object.keys(Z).forEach(function(b){a+=Z[b].stats.size});return a});return{create2D:function(b,c){function e(a,b){var c=f.texInfo;v.call(c);var d=x();"number"===typeof a?"number"===typeof b?t(d,a|0,b|0):t(d,a|0,a|0):a?(N(c,a),B(d,a)):t(d,1,1);c.genMipmaps&&(d.mipmask=(d.width<<1)-1);f.mipmask=d.mipmask;r(f,d);f.internalformat=d.internalformat; -e.width=d.width;e.height=d.height;T(f);X(d,3553);Q(c,3553);Ba();ib(d);n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d.width,d.height,c.genMipmaps,!1));e.format=O[f.internalformat];e.type=ba[f.type];e.mag=oa[c.magFilter];e.min=Aa[c.minFilter];e.wrapS=ia[c.wrapS];e.wrapT=ia[c.wrapT];return e}var f=new E(3553);Z[f.id]=f;d.textureCount++;e(b,c);e.subimage=function(a,b,c,d){b|=0;c|=0;d|=0;var q=g();r(q,f);q.width=0;q.height=0;C(q,a);q.width=q.width||(f.width>>d)-b;q.height=q.height||(f.height>>d)- -c;T(f);l(q,3553,b,c,d);Ba();h(q);return e};e.resize=function(b,c){var d=b|0,g=c|0||d;if(d===f.width&&g===f.height)return e;e.width=f.width=d;e.height=f.height=g;T(f);for(var q,y=f.channels,G=f.type,H=0;f.mipmask>>H;++H){var ea=d>>H,fa=g>>H;if(!ea||!fa)break;q=z.zero.allocType(G,ea*fa*y);a.texImage2D(3553,H,f.format,ea,fa,0,f.format,f.type,q);q&&z.zero.freeType(q)}Ba();n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d,g,!1,!1));return e};e._reglType="texture2d";e._texture=f;n.profile&&(e.stats= -f.stats);e.destroy=function(){f.decRef()};return e},createCube:function(b,c,e,f,k,m){function A(a,b,c,d,e,J){var I,da=w.texInfo;v.call(da);for(I=0;6>I;++I)q[I]=x();if("number"===typeof a||!a)for(a=a|0||1,I=0;6>I;++I)t(q[I],a,a);else if("object"===typeof a)if(b)B(q[0],a),B(q[1],b),B(q[2],c),B(q[3],d),B(q[4],e),B(q[5],J);else if(N(da,a),p(w,a),"faces"in a)for(a=a.faces,I=0;6>I;++I)r(q[I],w),B(q[I],a[I]);else for(I=0;6>I;++I)B(q[I],a);r(w,q[0]);w.mipmask=da.genMipmaps?(q[0].width<<1)-1:q[0].mipmask; -w.internalformat=q[0].internalformat;A.width=q[0].width;A.height=q[0].height;T(w);for(I=0;6>I;++I)X(q[I],34069+I);Q(da,34067);Ba();n.profile&&(w.stats.size=Ja(w.internalformat,w.type,A.width,A.height,da.genMipmaps,!0));A.format=O[w.internalformat];A.type=ba[w.type];A.mag=oa[da.magFilter];A.min=Aa[da.minFilter];A.wrapS=ia[da.wrapS];A.wrapT=ia[da.wrapT];for(I=0;6>I;++I)ib(q[I]);return A}var w=new E(34067);Z[w.id]=w;d.cubeCount++;var q=Array(6);A(b,c,e,f,k,m);A.subimage=function(a,b,c,q,d){c|=0;q|=0; -d|=0;var e=g();r(e,w);e.width=0;e.height=0;C(e,b);e.width=e.width||(w.width>>d)-c;e.height=e.height||(w.height>>d)-q;T(w);l(e,34069+a,c,q,d);Ba();h(e);return A};A.resize=function(b){b|=0;if(b!==w.width){A.width=w.width=b;A.height=w.height=b;T(w);for(var c=0;6>c;++c)for(var q=0;w.mipmask>>q;++q)a.texImage2D(34069+c,q,w.format,b>>q,b>>q,0,w.format,w.type,null);Ba();n.profile&&(w.stats.size=Ja(w.internalformat,w.type,A.width,A.height,!1,!0));return A}};A._reglType="textureCube";A._texture=w;n.profile&& -(A.stats=w.stats);A.destroy=function(){w.decRef()};return A},clear:function(){for(var b=0;bc;++c)if(0!==(b.mipmask&1<>c,b.height>>c,0,b.internalformat,b.type,null); -else for(var e=0;6>e;++e)a.texImage2D(34069+e,c,b.internalformat,b.width>>c,b.height>>c,0,b.internalformat,b.type,null);Q(b.texInfo,b.target)})}}}function Ob(a,b,c,e,f,d){function n(a,b,c){this.target=a;this.texture=b;this.renderbuffer=c;var e=a=0;b?(a=b.width,e=b.height):c&&(a=c.width,e=c.height);this.width=a;this.height=e}function k(a){a&&(a.texture&&a.texture._texture.decRef(),a.renderbuffer&&a.renderbuffer._renderbuffer.decRef())}function r(a,b,c){a&&(a.texture?a.texture._texture.refCount+=1: -a.renderbuffer._renderbuffer.refCount+=1)}function p(b,c){c&&(c.texture?a.framebufferTexture2D(36160,b,c.target,c.texture._texture.texture,0):a.framebufferRenderbuffer(36160,b,36161,c.renderbuffer._renderbuffer.renderbuffer))}function u(a){var b=3553,c=null,e=null,d=a;"object"===typeof a&&(d=a.data,"target"in a&&(b=a.target|0));a=d._reglType;"texture2d"===a?c=d:"textureCube"===a?c=d:"renderbuffer"===a&&(e=d,b=36161);return new n(b,c,e)}function m(a,b,c,d,g){if(c)return a=e.create2D({width:a,height:b, -format:d,type:g}),a._texture.refCount=0,new n(3553,a,null);a=f.create({width:a,height:b,format:d});a._renderbuffer.refCount=0;return new n(36161,null,a)}function C(a){return a&&(a.texture||a.renderbuffer)}function l(a,b,c){a&&(a.texture?a.texture.resize(b,c):a.renderbuffer&&a.renderbuffer.resize(b,c))}function g(){this.id=N++;Q[this.id]=this;this.framebuffer=a.createFramebuffer();this.height=this.width=0;this.colorAttachments=[];this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment= -null}function h(a){a.colorAttachments.forEach(k);k(a.depthAttachment);k(a.stencilAttachment);k(a.depthStencilAttachment)}function qa(b){a.deleteFramebuffer(b.framebuffer);b.framebuffer=null;d.framebufferCount--;delete Q[b.id]}function t(b){var e;a.bindFramebuffer(36160,b.framebuffer);var d=b.colorAttachments;for(e=0;ed;++d){for(k=0;ka;++a)c[a].resize(d);b.width=b.height=d;return b},_reglType:"framebufferCube",destroy:function(){c.forEach(function(a){a.destroy()})}})},clear:function(){R(Q).forEach(qa)},restore:function(){R(Q).forEach(function(b){b.framebuffer=a.createFramebuffer();t(b)})}})}function ub(){this.w=this.z=this.y=this.x=this.state=0;this.buffer=null;this.size=0;this.normalized=!1;this.type=5126;this.divisor=this.stride=this.offset= -0}function Pb(a,b,c,e){a=c.maxAttributes;b=Array(a);for(c=0;ca&&(a=b.stats.uniformsCount)});return a},c.getMaxAttributesCount=function(){var a= -0;C.forEach(function(b){b.stats.attributesCount>a&&(a=b.stats.attributesCount)});return a});return{clear:function(){var b=a.deleteShader.bind(a);R(p).forEach(b);p={};R(u).forEach(b);u={};C.forEach(function(b){a.deleteProgram(b.program)});C.length=0;m={};c.shaderCount=0},program:function(a,b,d){var e=m[b];e||(e=m[b]={});var f=e[a];f||(f=new k(b,a),c.shaderCount++,r(f,d),e[a]=f,C.push(f));return f},restore:function(){p={};u={};for(var a=0;a>>=b;c=(255>>=c;b|=c;c=(15>>=c;b|=c;c=(3>>c>>1}function cb(){function a(a){a:{for(var b=16;268435456>=b;b*=16)if(a<=b){a=b;break a}a=0}b=c[bb(a)>>2];return 0>2].push(a)}var c=J(8,function(){return[]});return{alloc:a,free:b,allocType:function(b,c){var d=null;switch(b){case 5120:d=new Int8Array(a(c),0,c);break;case 5121:d=new Uint8Array(a(c),0,c);break;case 5122:d=new Int16Array(a(2*c),0,c);break;case 5123:d=new Uint16Array(a(2*c),0,c);break;case 5124:d=new Int32Array(a(4*c),0,c);break;case 5125:d=new Uint32Array(a(4*c),0,c);break;case 5126:d=new Float32Array(a(4*c),0,c);break;default:return null}return d.length!== +c?d.subarray(0,c):d},freeType:function(a){b(a.buffer)}}}function ma(a){return!!a&&"object"===typeof a&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&"number"===typeof a.offset&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||M(a.data))}function db(a,b,c,e,g,d){for(var n=0;nd&&(d=e.buffer.byteLength,5123===f?d>>=1:5125===f&&(d>>=2));e.vertCount=d;d=h;0>h&&(d=4,h=e.buffer.dimension,1===h&&(d=0),2===h&&(d=1),3===h&&(d=4));e.primType=d}function n(a){e.elementsCount--;delete f[a.id];a.buffer.destroy();a.buffer=null}var f={},r=0,q={uint8:5121,uint16:5123};b.oes_element_index_uint&&(q.uint32=5125);g.prototype.bind=function(){this.buffer.bind()};var t=[];return{create:function(a,b){function k(a){if(a)if("number"===typeof a)h(a),l.primType=4,l.vertCount=a|0, +l.type=5121;else{var b=null,c=35044,e=-1,g=-1,f=0,m=0;if(Array.isArray(a)||M(a)||ma(a))b=a;else if("data"in a&&(b=a.data),"usage"in a&&(c=jb[a.usage]),"primitive"in a&&(e=Sa[a.primitive]),"count"in a&&(g=a.count|0),"type"in a&&(m=q[a.type]),"length"in a)f=a.length|0;else if(f=g,5123===m||5122===m)f*=2;else if(5125===m||5124===m)f*=4;d(l,b,c,e,g,f,m)}else h(),l.primType=4,l.vertCount=0,l.type=5121;return k}var h=c.create(null,34963,!0),l=new g(h._buffer);e.elementsCount++;k(a);k._reglType="elements"; +k._elements=l;k.subdata=function(a,b){h.subdata(a,b);return k};k.destroy=function(){n(l)};return k},createStream:function(a){var b=t.pop();b||(b=new g(c.create(null,34963,!0,!1)._buffer));d(b,a,35040,-1,-1,0,0);return b},destroyStream:function(a){t.push(a)},getElements:function(a){return"function"===typeof a&&a._elements instanceof g?a._elements:null},clear:function(){S(f).forEach(n)}}}function kb(a){for(var b=x.allocType(5123,a.length),c=0;c>>31<<15,d=(e<<1>>>24)-127,e=e>>13&1023;b[c]=-24>d?g:-14>d?g+(e+1024>>-14-d):15>=e,c.height>>=e,C(c,d[e]),a.mipmask|=1<b;++b)a.images[b]=null;return a}function ib(a){for(var b=a.images,c=0;cb){for(var c=0;c=--this.refCount&&A(this)}});n.profile&&(d.getTotalTextureSize=function(){var a=0;Object.keys(X).forEach(function(b){a+=X[b].stats.size});return a});return{create2D:function(b,c){function e(a,b){var c=f.texInfo;y.call(c);var d=D();"number"===typeof a?"number"===typeof b?v(d,a|0,b|0):v(d,a|0,a|0):a?(O(c,a),N(d,a)):v(d,1,1);c.genMipmaps&&(d.mipmask=(d.width<<1)-1);f.mipmask=d.mipmask;r(f,d);f.internalformat=d.internalformat; +e.width=d.width;e.height=d.height;T(f);B(d,3553);R(c,3553);Aa();ib(d);n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d.width,d.height,c.genMipmaps,!1));e.format=J[f.internalformat];e.type=da[f.type];e.mag=oa[c.magFilter];e.min=za[c.minFilter];e.wrapS=ka[c.wrapS];e.wrapT=ka[c.wrapT];return e}var f=new F(3553);X[f.id]=f;d.textureCount++;e(b,c);e.subimage=function(a,b,c,d){b|=0;c|=0;d|=0;var p=h();r(p,f);p.width=0;p.height=0;C(p,a);p.width=p.width||(f.width>>d)-b;p.height=p.height||(f.height>>d)- +c;T(f);k(p,3553,b,c,d);Aa();l(p);return e};e.resize=function(b,c){var d=b|0,h=c|0||d;if(d===f.width&&h===f.height)return e;e.width=f.width=d;e.height=f.height=h;T(f);for(var p,w=f.channels,z=f.type,I=0;f.mipmask>>I;++I){var fa=d>>I,ga=h>>I;if(!fa||!ga)break;p=x.zero.allocType(z,fa*ga*w);a.texImage2D(3553,I,f.format,fa,ga,0,f.format,f.type,p);p&&x.zero.freeType(p)}Aa();n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d,h,!1,!1));return e};e._reglType="texture2d";e._texture=f;n.profile&&(e.stats= +f.stats);e.destroy=function(){f.decRef()};return e},createCube:function(b,c,e,f,g,ua){function A(a,b,c,d,e,f){var H,Y=m.texInfo;y.call(Y);for(H=0;6>H;++H)p[H]=D();if("number"===typeof a||!a)for(a=a|0||1,H=0;6>H;++H)v(p[H],a,a);else if("object"===typeof a)if(b)N(p[0],a),N(p[1],b),N(p[2],c),N(p[3],d),N(p[4],e),N(p[5],f);else if(O(Y,a),q(m,a),"faces"in a)for(a=a.faces,H=0;6>H;++H)r(p[H],m),N(p[H],a[H]);else for(H=0;6>H;++H)N(p[H],a);r(m,p[0]);m.mipmask=Y.genMipmaps?(p[0].width<<1)-1:p[0].mipmask;m.internalformat= +p[0].internalformat;A.width=p[0].width;A.height=p[0].height;T(m);for(H=0;6>H;++H)B(p[H],34069+H);R(Y,34067);Aa();n.profile&&(m.stats.size=Ja(m.internalformat,m.type,A.width,A.height,Y.genMipmaps,!0));A.format=J[m.internalformat];A.type=da[m.type];A.mag=oa[Y.magFilter];A.min=za[Y.minFilter];A.wrapS=ka[Y.wrapS];A.wrapT=ka[Y.wrapT];for(H=0;6>H;++H)ib(p[H]);return A}var m=new F(34067);X[m.id]=m;d.cubeCount++;var p=Array(6);A(b,c,e,f,g,ua);A.subimage=function(a,b,c,p,d){c|=0;p|=0;d|=0;var e=h();r(e,m); +e.width=0;e.height=0;C(e,b);e.width=e.width||(m.width>>d)-c;e.height=e.height||(m.height>>d)-p;T(m);k(e,34069+a,c,p,d);Aa();l(e);return A};A.resize=function(b){b|=0;if(b!==m.width){A.width=m.width=b;A.height=m.height=b;T(m);for(var c=0;6>c;++c)for(var p=0;m.mipmask>>p;++p)a.texImage2D(34069+c,p,m.format,b>>p,b>>p,0,m.format,m.type,null);Aa();n.profile&&(m.stats.size=Ja(m.internalformat,m.type,A.width,A.height,!1,!0));return A}};A._reglType="textureCube";A._texture=m;n.profile&&(A.stats=m.stats);A.destroy= +function(){m.decRef()};return A},clear:function(){for(var b=0;bc;++c)if(0!==(b.mipmask&1<> +c,b.height>>c,0,b.internalformat,b.type,null);else for(var d=0;6>d;++d)a.texImage2D(34069+d,c,b.internalformat,b.width>>c,b.height>>c,0,b.internalformat,b.type,null);R(b.texInfo,b.target)})}}}function Ob(a,b,c,e,g,d){function n(a,b,c){this.target=a;this.texture=b;this.renderbuffer=c;var d=a=0;b?(a=b.width,d=b.height):c&&(a=c.width,d=c.height);this.width=a;this.height=d}function f(a){a&&(a.texture&&a.texture._texture.decRef(),a.renderbuffer&&a.renderbuffer._renderbuffer.decRef())}function r(a,b,c){a&& +(a.texture?a.texture._texture.refCount+=1:a.renderbuffer._renderbuffer.refCount+=1)}function q(b,c){c&&(c.texture?a.framebufferTexture2D(36160,b,c.target,c.texture._texture.texture,0):a.framebufferRenderbuffer(36160,b,36161,c.renderbuffer._renderbuffer.renderbuffer))}function t(a){var b=3553,c=null,d=null,e=a;"object"===typeof a&&(e=a.data,"target"in a&&(b=a.target|0));a=e._reglType;"texture2d"===a?c=e:"textureCube"===a?c=e:"renderbuffer"===a&&(d=e,b=36161);return new n(b,c,d)}function m(a,b,c,d, +f){if(c)return a=e.create2D({width:a,height:b,format:d,type:f}),a._texture.refCount=0,new n(3553,a,null);a=g.create({width:a,height:b,format:d});a._renderbuffer.refCount=0;return new n(36161,null,a)}function C(a){return a&&(a.texture||a.renderbuffer)}function k(a,b,c){a&&(a.texture?a.texture.resize(b,c):a.renderbuffer&&a.renderbuffer.resize(b,c),a.width=b,a.height=c)}function h(){this.id=O++;R[this.id]=this;this.framebuffer=a.createFramebuffer();this.height=this.width=0;this.colorAttachments=[];this.depthStencilAttachment= +this.stencilAttachment=this.depthAttachment=null}function l(a){a.colorAttachments.forEach(f);f(a.depthAttachment);f(a.stencilAttachment);f(a.depthStencilAttachment)}function u(b){a.deleteFramebuffer(b.framebuffer);b.framebuffer=null;d.framebufferCount--;delete R[b.id]}function v(b){var d;a.bindFramebuffer(36160,b.framebuffer);var e=b.colorAttachments;for(d=0;dd;++d){for(m=0;ma;++a)c[a].resize(d);b.width=b.height=d;return b},_reglType:"framebufferCube",destroy:function(){c.forEach(function(a){a.destroy()})}})},clear:function(){S(R).forEach(u)},restore:function(){B.cur=null;B.next=null;B.dirty=!0;S(R).forEach(function(b){b.framebuffer=a.createFramebuffer();v(b)})}})}function ub(){this.w=this.z=this.y= +this.x=this.state=0;this.buffer=null;this.size=0;this.normalized=!1;this.type=5126;this.divisor=this.stride=this.offset=0}function Pb(a,b,c,e){a=c.maxAttributes;b=Array(a);for(c=0;c +a&&(a=b.stats.uniformsCount)});return a},c.getMaxAttributesCount=function(){var a=0;C.forEach(function(b){b.stats.attributesCount>a&&(a=b.stats.attributesCount)});return a});return{clear:function(){var b=a.deleteShader.bind(a);S(q).forEach(b);q={};S(t).forEach(b);t={};C.forEach(function(b){a.deleteProgram(b.program)});C.length=0;m={};c.shaderCount=0},program:function(a,b,d){var e=m[b];e||(e=m[b]={});var g=e[a];g||(g=new f(b,a),c.shaderCount++,r(g,d),e[a]=g,C.push(g));return g},restore:function(){q= +{};t={};for(var a=0;a"+b+"?"+e+".constant["+b+"]:0;"}).join(""),"}}else{", -"if(",f,"(",e,".buffer)){",h,"=",g,".createStream(",34962,",",e,".buffer);","}else{",h,"=",g,".getBuffer(",e,".buffer);","}",k,'="type" in ',e,"?",q.glTypes,"[",e,".type]:",h,".dtype;",y.normalized,"=!!",e,".normalized;");d("size");d("offset");d("stride");d("divisor");c("}}");c.exit("if(",y.isStream,"){",g,".destroyStream(",h,");","}");return y})});return g}function M(a){var b=a["static"],c=a.dynamic,d={};Object.keys(b).forEach(function(a){var c=b[a];d[a]=x(function(a,b){return"number"===typeof c|| -"boolean"===typeof c?""+c:a.link(c)})});Object.keys(c).forEach(function(a){var b=c[a];d[a]=K(b,function(a,c){return a.invoke(c,b)})});return d}function w(a,b,c,d,e){var f=z(a,e),g=D(a,f,e),l=N(a,e),k=Q(a,e),m=P(a,e),xa=g.viewport;xa&&(k.viewport=xa);xa=h("scissor.box");(g=g[xa])&&(k[xa]=g);g=0>1)",u],");")}function b(){c(ba,".drawArraysInstancedANGLE(",[p,r,t,u],");")}n?B?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")):b()}function g(){function a(){c(l+".drawElements("+[p,t,C,r+"<<(("+C+"-5121)>>1)"]+");")}function b(){c(l+".drawArrays("+[p,r,t]+");")}n?B?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")): -b()}var h=a.shared,l=h.gl,k=h.draw,m=d.draw,n=function(){var e=m.elements,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(k,".","elements");e&&f("if("+e+")"+l+".bindBuffer(34963,"+e+".buffer.buffer);");return e}(),p=e("primitive"),r=e("offset"),t=function(){var e=m.count,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(k,".","count");return e}();if("number"===typeof t){if(0===t)return}else c("if(",t,"){"),c.exit("}");var u, -ba;ga&&(u=e("instances"),ba=a.instancing);var C=n+".type",B=m.elements&&wa(m.elements);ga&&("number"!==typeof u||0<=u)?"string"===typeof u?(c("if(",u,">0){"),f(),c("}else if(",u,"<0){"),g(),c("}")):f():g()}function ca(a,b,c,d,e){b=B();e=b.proc("body",e);ga&&(b.instancing=e.def(b.shared.extensions,".angle_instanced_arrays"));a(b,e,c,d);return b.compile().body}function W(a,b,c,d){ya(a,b);U(a,b,c,d.attributes,function(){return!0});Y(a,b,c,d.uniforms,function(){return!0});S(a,b,b,c)}function ba(a,b){var c= -a.proc("draw",1);ya(a,c);A(a,c,b.context);L(a,c,b.framebuffer);V(a,c,b);R(a,c,b.state);F(a,c,b,!1,!0);var d=b.shader.progVar.append(a,c);c(a.shared.gl,".useProgram(",d,".program);");if(b.shader.program)W(a,c,b,b.shader.program);else{var e=a.global.def("{}"),f=c.def(d,".id"),g=c.def(e,"[",f,"]");c(a.cond(g).then(g,".call(this,a0);")["else"](g,"=",e,"[",f,"]=",a.link(function(c){return ca(W,a,b,c,1)}),"(",d,");",g,".call(this,a0);"))}0=--this.refCount&&n(this)};f.profile&&(e.getTotalRenderbufferSize=function(){var a=0;Object.keys(u).forEach(function(b){a+=u[b].stats.size});return a});return{create:function(b,c){function l(b,c){var d=0,e=0,m=32854;"object"===typeof b&&b?("shape"in b?(e=b.shape,d=e[0]|0,e=e[1]|0):("radius"in b&&(d=e=b.radius|0),"width"in b&&(d=b.width|0),"height"in b&&(e=b.height|0)),"format"in b&&(m=k[b.format])): -"number"===typeof b?(d=b|0,e="number"===typeof c?c|0:d):b||(d=e=1);if(d!==g.width||e!==g.height||m!==g.format)return l.width=g.width=d,l.height=g.height=e,g.format=m,a.bindRenderbuffer(36161,g.renderbuffer),a.renderbufferStorage(36161,m,d,e),f.profile&&(g.stats.size=M[g.format]*g.width*g.height),l.format=r[g.format],l}var g=new d(a.createRenderbuffer());u[g.id]=g;e.renderbufferCount++;l(b,c);l.resize=function(b,c){var d=b|0,e=c|0||d;if(d===g.width&&e===g.height)return l;l.width=g.width=d;l.height= -g.height=e;a.bindRenderbuffer(36161,g.renderbuffer);a.renderbufferStorage(36161,g.format,d,e);f.profile&&(g.stats.size=M[g.format]*g.width*g.height);return l};l._reglType="renderbuffer";l._renderbuffer=g;f.profile&&(l.stats=g.stats);l.destroy=function(){g.decRef()};return l},clear:function(){R(u).forEach(n)},restore:function(){R(u).forEach(function(b){b.renderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,b.renderbuffer);a.renderbufferStorage(36161,b.format,b.width,b.height)});a.bindRenderbuffer(36161, -null)}}},Wa=[];Wa[6408]=4;Wa[6407]=3;var Na=[];Na[5121]=1;Na[5126]=4;Na[36193]=2;var Da=["x","y","z","w"],Ub="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),Ga={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771, -"one minus constant alpha":32772,"src alpha saturate":776},Xa={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Pa={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},wb={cw:2304,ccw:2305},xb=new aa(!1,!1,!1,function(){}),Xb=function(a,b){function c(){this.endQueryIndex=this.startQueryIndex=-1;this.sum=0;this.stats= -null}function e(a,b,d){var e=k.pop()||new c;e.startQueryIndex=a;e.endQueryIndex=b;e.sum=0;e.stats=d;r.push(e)}var f=b.ext_disjoint_timer_query;if(!f)return null;var d=[],n=[],k=[],r=[],p=[],u=[];return{beginQuery:function(a){var b=d.pop()||f.createQueryEXT();f.beginQueryEXT(35007,b);n.push(b);e(n.length-1,n.length,a)},endQuery:function(){f.endQueryEXT(35007)},pushScopeStats:e,update:function(){var a,b;a=n.length;if(0!==a){u.length=Math.max(u.length,a+1);p.length=Math.max(p.length,a+1);p[0]=0;var c= -u[0]=0;for(b=a=0;b=F.length&&e()}var c=yb(F,a);F[c]=b}}}function p(){var a=S.viewport,b=S.scissor_box;a[0]=a[1]=b[0]=b[1]=0;N.viewportWidth=N.framebufferWidth=N.drawingBufferWidth=a[2]=b[2]=l.drawingBufferWidth;N.viewportHeight=N.framebufferHeight=N.drawingBufferHeight=a[3]=b[3]=l.drawingBufferHeight}function u(){N.tick+=1;N.time=v();p();V.procs.poll()}function m(){p();V.procs.refresh();x&&x.update()}function v(){return(zb()-O)/1E3}a=Eb(a);if(!a)return null;var l=a.gl,g=l.getContextAttributes(); -l.isContextLost();var h=Fb(l,a);if(!h)return null;var z=Bb(),t={bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},B=h.extensions,x=Xb(l,B),O=zb(),K=l.drawingBufferWidth,P=l.drawingBufferHeight,N={tick:0,time:0,viewportWidth:K,viewportHeight:P,framebufferWidth:K,framebufferHeight:P,drawingBufferWidth:K,drawingBufferHeight:P,pixelRatio:a.pixelRatio},Q=Vb(l,B),K=Pb(l,B,Q,z),E=Gb(l,t,a,K),T=Hb(l,B,E,t),R=Qb(l,z,t,a),w=Kb(l, -B,Q,function(){V.procs.poll()},N,t,a),A=Wb(l,B,Q,t,a),L=Ob(l,B,Q,w,A,t),V=Tb(l,z,B,Q,E,T,w,L,{},K,R,{elements:null,primitive:4,count:-1,offset:0,instances:-1},N,x,a),z=Rb(l,L,V.procs.poll,N,g,B,Q),S=V.next,M=l.canvas,F=[],U=[],Y=[],W=[a.onDestroy],ca=null;M&&(M.addEventListener("webglcontextlost",f,!1),M.addEventListener("webglcontextrestored",d,!1));var aa=L.setFBO=n({framebuffer:ja.define.call(null,1,"framebuffer")});m();g=D(n,{clear:function(a){if("framebuffer"in a)if(a.framebuffer&&"framebufferCube"=== -a.framebuffer_reglType)for(var b=0;6>b;++b)aa(D({framebuffer:a.framebuffer.faces[b]},a),k);else aa(a,k);else k(null,a)},prop:ja.define.bind(null,1),context:ja.define.bind(null,2),"this":ja.define.bind(null,3),draw:n({}),buffer:function(a){return E.create(a,34962,!1,!1)},elements:function(a){return T.create(a,!1)},texture:w.create2D,cube:w.createCube,renderbuffer:A.create,framebuffer:L.create,framebufferCube:L.createCube,attributes:g,frame:r,on:function(a,b){var c;switch(a){case "frame":return r(b); -case "lost":c=U;break;case "restore":c=Y;break;case "destroy":c=W}c.push(b);return{cancel:function(){for(var a=0;a"+b+"?"+e+".constant["+b+"]:0;"}).join(""),"}}else{", +"if(",f,"(",e,".buffer)){",z,"=",g,".createStream(",34962,",",e,".buffer);","}else{",z,"=",g,".getBuffer(",e,".buffer);","}",k,'="type" in ',e,"?",p.glTypes,"[",e,".type]:",z,".dtype;",w.normalized,"=!!",e,".normalized;");d("size");d("offset");d("stride");d("divisor");c("}}");c.exit("if(",w.isStream,"){",g,".destroyStream(",z,");","}");return w})});return f}function M(a){var b=a["static"],c=a.dynamic,d={};Object.keys(b).forEach(function(a){var c=b[a];d[a]=D(function(a,b){return"number"===typeof c|| +"boolean"===typeof c?""+c:a.link(c)})});Object.keys(c).forEach(function(a){var b=c[a];d[a]=P(b,function(a,c){return a.invoke(c,b)})});return d}function A(a,b,c,d,e){var f=y(a,e),g=x(a,f,e),h=O(a,e),k=R(a,e),m=E(a,e),ba=g.viewport;ba&&(k.viewport=ba);ba=l("scissor.box");(g=g[ba])&&(k[ba]=g);g=0>1)",v],");")}function b(){c(u,".drawArraysInstancedANGLE(",[q,r,t,v],");")}n?da?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")):b()}function g(){function a(){c(k+".drawElements("+[q,t,C,r+"<<(("+C+"-5121)>>1)"]+");")}function b(){c(k+".drawArrays("+[q,r,t]+");")}n?da?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")): +b()}var h=a.shared,k=h.gl,m=h.draw,l=d.draw,n=function(){var e=l.elements,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(m,".","elements");e&&f("if("+e+")"+k+".bindBuffer(34963,"+e+".buffer.buffer);");return e}(),q=e("primitive"),r=e("offset"),t=function(){var e=l.count,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(m,".","count");return e}();if("number"===typeof t){if(0===t)return}else c("if(",t,"){"),c.exit("}");var v, +u;ea&&(v=e("instances"),u=a.instancing);var C=n+".type",da=l.elements&&va(l.elements);ea&&("number"!==typeof v||0<=v)?"string"===typeof v?(c("if(",v,">0){"),f(),c("}else if(",v,"<0){"),g(),c("}")):f():g()}function ca(a,b,c,d,e){b=N();e=b.proc("body",e);ea&&(b.instancing=e.def(b.shared.extensions,".angle_instanced_arrays"));a(b,e,c,d);return b.compile().body}function L(a,b,c,d){wa(a,b);U(a,b,c,d.attributes,function(){return!0});W(a,b,c,d.uniforms,function(){return!0});S(a,b,b,c)}function da(a,b){var c= +a.proc("draw",1);wa(a,c);ua(a,c,b.context);K(a,c,b.framebuffer);V(a,c,b);Q(a,c,b.state);G(a,c,b,!1,!0);var d=b.shader.progVar.append(a,c);c(a.shared.gl,".useProgram(",d,".program);");if(b.shader.program)L(a,c,b,b.shader.program);else{var e=a.global.def("{}"),f=c.def(d,".id"),g=c.def(e,"[",f,"]");c(a.cond(g).then(g,".call(this,a0);")["else"](g,"=",e,"[",f,"]=",a.link(function(c){return ca(L,a,b,c,1)}),"(",d,");",g,".call(this,a0);"))}0=--this.refCount&&n(this)};g.profile&&(e.getTotalRenderbufferSize=function(){var a=0;Object.keys(t).forEach(function(b){a+=t[b].stats.size});return a});return{create:function(b,c){function k(b,c){var d=0,e=0,m=32854; +"object"===typeof b&&b?("shape"in b?(e=b.shape,d=e[0]|0,e=e[1]|0):("radius"in b&&(d=e=b.radius|0),"width"in b&&(d=b.width|0),"height"in b&&(e=b.height|0)),"format"in b&&(m=f[b.format])):"number"===typeof b?(d=b|0,e="number"===typeof c?c|0:d):b||(d=e=1);if(d!==h.width||e!==h.height||m!==h.format)return k.width=h.width=d,k.height=h.height=e,h.format=m,a.bindRenderbuffer(36161,h.renderbuffer),a.renderbufferStorage(36161,m,d,e),g.profile&&(h.stats.size=Q[h.format]*h.width*h.height),k.format=r[h.format], +k}var h=new d(a.createRenderbuffer());t[h.id]=h;e.renderbufferCount++;k(b,c);k.resize=function(b,c){var d=b|0,e=c|0||d;if(d===h.width&&e===h.height)return k;k.width=h.width=d;k.height=h.height=e;a.bindRenderbuffer(36161,h.renderbuffer);a.renderbufferStorage(36161,h.format,d,e);g.profile&&(h.stats.size=Q[h.format]*h.width*h.height);return k};k._reglType="renderbuffer";k._renderbuffer=h;g.profile&&(k.stats=h.stats);k.destroy=function(){h.decRef()};return k},clear:function(){S(t).forEach(n)},restore:function(){S(t).forEach(function(b){b.renderbuffer= +a.createRenderbuffer();a.bindRenderbuffer(36161,b.renderbuffer);a.renderbufferStorage(36161,b.format,b.width,b.height)});a.bindRenderbuffer(36161,null)}}},Wa=[];Wa[6408]=4;Wa[6407]=3;var Na=[];Na[5121]=1;Na[5126]=4;Na[36193]=2;var Da=["x","y","z","w"],Ub="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),Ga={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771, +"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Xa={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Pa={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056, +invert:5386},wb={cw:2304,ccw:2305},xb=new Z(!1,!1,!1,function(){}),Xb=function(a,b){function c(){this.endQueryIndex=this.startQueryIndex=-1;this.sum=0;this.stats=null}function e(a,b,d){var e=n.pop()||new c;e.startQueryIndex=a;e.endQueryIndex=b;e.sum=0;e.stats=d;f.push(e)}if(!b.ext_disjoint_timer_query)return null;var g=[],d=[],n=[],f=[],r=[],q=[];return{beginQuery:function(a){var c=g.pop()||b.ext_disjoint_timer_query.createQueryEXT();b.ext_disjoint_timer_query.beginQueryEXT(35007,c);d.push(c);e(d.length- +1,d.length,a)},endQuery:function(){b.ext_disjoint_timer_query.endQueryEXT(35007)},pushScopeStats:e,update:function(){var a,c;a=d.length;if(0!==a){q.length=Math.max(q.length,a+1);r.length=Math.max(r.length,a+1);r[0]=0;var e=q[0]=0;for(c=a=0;c=G.length&&e()}var c=yb(G,a);G[c]=b}}}function q(){var a=S.viewport,b=S.scissor_box;a[0]=a[1]=b[0]=b[1]=0;O.viewportWidth= +O.framebufferWidth=O.drawingBufferWidth=a[2]=b[2]=k.drawingBufferWidth;O.viewportHeight=O.framebufferHeight=O.drawingBufferHeight=a[3]=b[3]=k.drawingBufferHeight}function t(){O.tick+=1;O.time=y();q();V.procs.poll()}function m(){q();V.procs.refresh();B&&B.update()}function y(){return(zb()-D)/1E3}a=Eb(a);if(!a)return null;var k=a.gl,h=k.getContextAttributes();k.isContextLost();var l=Fb(k,a);if(!l)return null;var u=Bb(),v={bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0, +cubeCount:0,renderbufferCount:0,maxTextureUnits:0},x=l.extensions,B=Xb(k,x),D=zb(),J=k.drawingBufferWidth,P=k.drawingBufferHeight,O={tick:0,time:0,viewportWidth:J,viewportHeight:P,framebufferWidth:J,framebufferHeight:P,drawingBufferWidth:J,drawingBufferHeight:P,pixelRatio:a.pixelRatio},R=Vb(k,x),J=Pb(k,x,R,u),F=Gb(k,v,a,J),T=Hb(k,x,F,v),Q=Qb(k,u,v,a),A=Kb(k,x,R,function(){V.procs.poll()},O,v,a),M=Wb(k,x,R,v,a),K=Ob(k,x,R,A,M,v),V=Tb(k,u,x,R,F,T,A,K,{},J,Q,{elements:null,primitive:4,count:-1,offset:0, +instances:-1},O,B,a),u=Rb(k,K,V.procs.poll,O,h,x,R),S=V.next,L=k.canvas,G=[],U=[],W=[],Z=[a.onDestroy],ca=null;L&&(L.addEventListener("webglcontextlost",g,!1),L.addEventListener("webglcontextrestored",d,!1));var aa=K.setFBO=n({framebuffer:la.define.call(null,1,"framebuffer")});m();h=E(n,{clear:function(a){if("framebuffer"in a)if(a.framebuffer&&"framebufferCube"===a.framebuffer_reglType)for(var b=0;6>b;++b)aa(E({framebuffer:a.framebuffer.faces[b]},a),f);else aa(a,f);else f(null,a)},prop:la.define.bind(null, +1),context:la.define.bind(null,2),"this":la.define.bind(null,3),draw:n({}),buffer:function(a){return F.create(a,34962,!1,!1)},elements:function(a){return T.create(a,!1)},texture:A.create2D,cube:A.createCube,renderbuffer:M.create,framebuffer:K.create,framebufferCube:K.createCube,attributes:h,frame:r,on:function(a,b){var c;switch(a){case "frame":return r(b);case "lost":c=U;break;case "restore":c=W;break;case "destroy":c=Z}c.push(b);return{cancel:function(){for(var a=0;a0) { - shapeX += 0.02 - } - } - - var data = new Float32Array(bufferSize) - var ptr = 0 - var xOffset = -0.5 * shapeX - for(var i=0; i0) { + shapeX += 0.02 + } + } + + var data = new Float32Array(bufferSize) + var ptr = 0 + var xOffset = -0.5 * shapeX + for(var i=0; i" + var clsTag = "" + + var nOPN = opnTag.length + var nCLS = clsTag.length + + var isRecursive = (TAG_CHR[0] === CHR_super0) || + (TAG_CHR[0] === CHR_sub0); + + var a = 0 + var b = -nCLS + while (a > -1) { + a = str.indexOf(opnTag, a) + if(a === -1) break + + b = str.indexOf(clsTag, a + nOPN) + if(b === -1) break + + if(b <= a) break + + for(var i = a; i < b + nCLS; ++i){ + if((i < a + nOPN) || (i >= b)) { + map[i] = null + str = str.substr(0, i) + " " + str.substr(i + 1) + } else { + if(map[i] !== null) { + var pos = map[i].indexOf(TAG_CHR[0]) + if(pos === -1) { + map[i] += TAG_CHR + } else { // i.e. to handle multiple sub/super-scripts + if(isRecursive) { + // i.e to increase the sub/sup number + map[i] = map[i].substr(0, pos + 1) + (1 + parseInt(map[i][pos + 1])) + map[i].substr(pos + 2) + } + } + } + } + } + + var start = a + nOPN + var remainingStr = str.substr(start, b - start) + + var c = remainingStr.indexOf(opnTag) + if(c !== -1) a = c + else a = b + nCLS + } + + return map +} + function transformPositions(positions, options, size) { var align = options.textAlign || "start" var baseline = options.textBaseline || "alphabetic" @@ -47482,27 +47523,169 @@ function transformPositions(positions, options, size) { }) } -function getPixels(canvas, context, str, size) { - var width = Math.ceil(context.measureText(str).width + 2*size)|0 - if(width > 8192) { - throw new Error("vectorize-text: String too long (sorry, this will get fixed later)") +function getPixels(canvas, context, rawString, fontSize, lineSpacing, styletags) { + + rawString = rawString.replace(/\n/g, '') // don't accept \n in the input + + if(styletags.breaklines === true) { + rawString = rawString.replace(/\/g, '\n') // replace
tags with \n in the string + } else { + rawString = rawString.replace(/\/g, ' ') // don't accept
tags in the input and replace with space in this case + } + + var activeStyle = "" + var map = [] + for(j = 0; j < rawString.length; ++j) { + map[j] = activeStyle + } + + if(styletags.bolds === true) map = parseTag(TAG_bold, CHR_bold, rawString, map) + if(styletags.italics === true) map = parseTag(TAG_italic, CHR_italic, rawString, map) + if(styletags.superscripts === true) map = parseTag(TAG_super, CHR_super, rawString, map) + if(styletags.subscripts === true) map = parseTag(TAG_sub, CHR_sub, rawString, map) + + var allStyles = [] + var plainText = "" + for(j = 0; j < rawString.length; ++j) { + if(map[j] !== null) { + plainText += rawString[j] + allStyles.push(map[j]) + } } - var height = 3 * size - if(canvas.height < height) { - canvas.height = height + + var allTexts = plainText.split('\n') + + var numberOfLines = allTexts.length + var lineHeight = Math.round(lineSpacing * fontSize) + var offsetX = fontSize + var offsetY = fontSize * 2 + var maxWidth = 0 + var minHeight = numberOfLines * lineHeight + offsetY + + if(canvas.height < minHeight) { + canvas.height = minHeight } context.fillStyle = "#000" context.fillRect(0, 0, canvas.width, canvas.height) context.fillStyle = "#fff" - context.fillText(str, size, 2*size) + var i, j, xPos, yPos, zPos + var nDone = 0 - //Cut pixels from image - var pixelData = context.getImageData(0, 0, width, height) - var pixels = ndarray(pixelData.data, [height, width, 4]) + for(i = 0; i < numberOfLines; ++i) { + + var txt = allTexts[i] + '\n' + xPos = 0 + yPos = i * lineHeight + zPos = fontSize + + var buffer = "" + function writeBuffer() { + if(buffer !== "") { + var delta = context.measureText(buffer).width + + context.fillText(buffer, offsetX + xPos, offsetY + yPos) + xPos += delta + } + } + + function changeStyle(oldStyle, newStyle) { + + function getTextFontSize() { + return "" + Math.round(zPos) + "px "; + } + + var ctxFont = "" + context.font; + + if(styletags.subscripts === true) { + var oldIndex_Sub = oldStyle.indexOf(CHR_sub0); + var newIndex_Sub = newStyle.indexOf(CHR_sub0); + + var oldSub = (oldIndex_Sub > -1) ? parseInt(oldStyle[1 + oldIndex_Sub]) : 0; + var newSub = (newIndex_Sub > -1) ? parseInt(newStyle[1 + newIndex_Sub]) : 0; + + if(oldSub !== newSub) { + ctxFont = ctxFont.replace(getTextFontSize(), "?px ") + zPos *= Math.pow(0.75, (newSub - oldSub)) + ctxFont = ctxFont.replace("?px ", getTextFontSize()) + } + yPos += 0.25 * lineHeight * (newSub - oldSub); + } + + if(styletags.superscripts === true) { + var oldIndex_Super = oldStyle.indexOf(CHR_super0); + var newIndex_Super = newStyle.indexOf(CHR_super0); + + var oldSuper = (oldIndex_Super > -1) ? parseInt(oldStyle[1 + oldIndex_Super]) : 0; + var newSuper = (newIndex_Super > -1) ? parseInt(newStyle[1 + newIndex_Super]) : 0; + + if(oldSuper !== newSuper) { + ctxFont = ctxFont.replace(getTextFontSize(), "?px ") + zPos *= Math.pow(0.75, (newSuper - oldSuper)) + ctxFont = ctxFont.replace("?px ", getTextFontSize()) + } + yPos -= 0.25 * lineHeight * (newSuper - oldSuper); + } + + if(styletags.bolds === true) { + var wasBold = (oldStyle.indexOf(CHR_bold) > -1) + var is_Bold = (newStyle.indexOf(CHR_bold) > -1) + + if(!wasBold && is_Bold) { + if(wasItalic) { + ctxFont = ctxFont.replace("italic ", "italic bold ") + } else { + ctxFont = "bold " + ctxFont + } + } + if(wasBold && !is_Bold) { + ctxFont = ctxFont.replace("bold ", '') + } + } + + if(styletags.italics === true) { + var wasItalic = (oldStyle.indexOf(CHR_italic) > -1) + var is_Italic = (newStyle.indexOf(CHR_italic) > -1) + + if(!wasItalic && is_Italic) { + ctxFont = "italic " + ctxFont + } + if(wasItalic && !is_Italic) { + ctxFont = ctxFont.replace("italic ", '') + } + } + + context.font = ctxFont + } + + for(j = 0; j < txt.length; ++j) { + var style = (j + nDone < allStyles.length) ? allStyles[j + nDone] : allStyles[allStyles.length - 1] + if(activeStyle === style) { + buffer += txt[j] + } else { + writeBuffer() + buffer = txt[j] + + if(style !== undefined) { + changeStyle(activeStyle, style) + activeStyle = style + } + } + } + writeBuffer() + + nDone += txt.length + + var width = Math.round(xPos + 2 * offsetX) | 0 + if(maxWidth < width) maxWidth = width + } - return pixels.pick(-1,-1,0).transpose(1,0) + //Cut pixels from image + var xCut = maxWidth + var yCut = offsetY + lineHeight * numberOfLines + var pixels = ndarray(context.getImageData(0, 0, xCut, yCut).data, [yCut, xCut, 4]) + return pixels.pick(-1, -1, 0).transpose(1, 0) } function getContour(pixels, doSimplify) { @@ -47589,20 +47772,65 @@ function processPixels(pixels, options, size) { } function vectorizeText(str, canvas, context, options) { - var size = options.size || 64 - var family = options.font || "normal" - context.font = size + "px " + family + var size = 64 + var lineSpacing = 1.25 + var styletags = { + breaklines: false, + bolds: false, + italics: false, + subscripts: false, + superscripts: false + } + + if(options) { + + if(options.size && + options.size > 0) size = + options.size + + if(options.lineSpacing && + options.lineSpacing > 0) lineSpacing = + options.lineSpacing + + if(options.styletags && + options.styletags.breaklines) styletags.breaklines = + options.styletags.breaklines ? true : false + + if(options.styletags && + options.styletags.bolds) styletags.bolds = + options.styletags.bolds ? true : false + + if(options.styletags && + options.styletags.italics) styletags.italics = + options.styletags.italics ? true : false + + if(options.styletags && + options.styletags.subscripts) styletags.subscripts = + options.styletags.subscripts ? true : false + + if(options.styletags && + options.styletags.superscripts) styletags.superscripts = + options.styletags.superscripts ? true : false + } + + context.font = [ + options.fontStyle, + options.fontVariant, + options.fontWeight, + size + "px", + options.font + ].filter(function(d) {return d}).join(" ") context.textAlign = "start" context.textBaseline = "alphabetic" context.direction = "ltr" - var pixels = getPixels(canvas, context, str, size) + var pixels = getPixels(canvas, context, str, size, lineSpacing, styletags) return processPixels(pixels, options, size) } -},{"cdt2d":52,"clean-pslg":59,"ndarray":220,"planar-graph-to-polyline":235,"simplify-planar-graph":272,"surface-nets":278}],297:[function(_dereq_,module,exports){ +},{"cdt2d":52,"clean-pslg":59,"ndarray":220,"planar-graph-to-polyline":235,"simplify-planar-graph":272,"surface-nets":277}],296:[function(_dereq_,module,exports){ var hiddenStore = _dereq_('./hidden-store.js'); module.exports = createStore; @@ -47623,7 +47851,7 @@ function createStore() { }; } -},{"./hidden-store.js":298}],298:[function(_dereq_,module,exports){ +},{"./hidden-store.js":297}],297:[function(_dereq_,module,exports){ module.exports = hiddenStore; function hiddenStore(obj, key) { @@ -47641,7 +47869,7 @@ function hiddenStore(obj, key) { return store; } -},{}],299:[function(_dereq_,module,exports){ +},{}],298:[function(_dereq_,module,exports){ // Original - @Gozola. // https://gist.github.com/Gozala/1269991 // This is a reimplemented version (with a few bug fixes). @@ -47672,14 +47900,14 @@ function weakMap() { } } -},{"./create-store.js":297}],300:[function(_dereq_,module,exports){ +},{"./create-store.js":296}],299:[function(_dereq_,module,exports){ var getContext = _dereq_('get-canvas-context') module.exports = function getWebGLContext (opt) { return getContext('webgl', opt) } -},{"get-canvas-context":155}],301:[function(_dereq_,module,exports){ +},{"get-canvas-context":155}],300:[function(_dereq_,module,exports){ module.exports = _dereq_('cwise-compiler')({ args: ['array', { offset: [1], @@ -47731,7 +47959,7 @@ module.exports = _dereq_('cwise-compiler')({ funcName: 'zeroCrossings' }) -},{"cwise-compiler":79}],302:[function(_dereq_,module,exports){ +},{"cwise-compiler":79}],301:[function(_dereq_,module,exports){ "use strict" module.exports = findZeroCrossings @@ -47744,7 +47972,7 @@ function findZeroCrossings(array, level) { core(array.hi(array.shape[0]-1), cross, level) return cross } -},{"./lib/zc-core":301}],303:[function(_dereq_,module,exports){ +},{"./lib/zc-core":300}],302:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47815,7 +48043,7 @@ module.exports = [ } ]; -},{}],304:[function(_dereq_,module,exports){ +},{}],303:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48170,7 +48398,7 @@ module.exports = templatedArray('annotation', { } }); -},{"../../plot_api/plot_template":478,"../../plots/cartesian/constants":494,"../../plots/font_attributes":515,"./arrow_paths":303}],305:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":474,"../../plots/cartesian/constants":490,"../../plots/font_attributes":511,"./arrow_paths":302}],304:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48259,7 +48487,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":441,"../../plots/cartesian/axes":488,"./draw":310}],306:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/cartesian/axes":484,"./draw":309}],305:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48398,7 +48626,7 @@ function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":441,"../../plot_api/plot_template":478,"../../registry":532}],307:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plot_api/plot_template":474,"../../registry":528}],306:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48478,7 +48706,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":441,"../color":319}],308:[function(_dereq_,module,exports){ +},{"../../lib":437,"../color":318}],307:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48541,7 +48769,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":467,"fast-isnumeric":149}],309:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":463,"fast-isnumeric":149}],308:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48647,7 +48875,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":441,"../../plots/array_container_defaults":484,"../../plots/cartesian/axes":488,"./attributes":304,"./common_defaults":307}],310:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/array_container_defaults":480,"../../plots/cartesian/axes":484,"./attributes":303,"./common_defaults":306}],309:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49061,14 +49289,14 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { x: borderfull + xShift - 1, y: borderfull + yShift }) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; annText.call(svgTextUtils.positionText, textx, texty) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } annTextClip.select('rect').call(Drawing.setRect, borderfull, borderfull, @@ -49234,7 +49462,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }); }, doneFn: function() { - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -49317,7 +49545,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }, doneFn: function() { setCursor(annTextGroupInner); - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -49341,13 +49569,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { modifyBase(ya._name + '.autorange', true); } - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); }); } else annText.call(textLayout); } -},{"../../lib":441,"../../lib/setcursor":461,"../../lib/svg_text_utils":465,"../../plot_api/plot_template":478,"../../plots/cartesian/axes":488,"../../plots/plots":525,"../../registry":532,"../color":319,"../dragelement":341,"../drawing":344,"../fx":361,"./draw_arrow_head":311,"d3":85}],311:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../lib/setcursor":457,"../../lib/svg_text_utils":461,"../../plot_api/plot_template":474,"../../plots/cartesian/axes":484,"../../plots/plots":521,"../../registry":528,"../color":318,"../dragelement":336,"../drawing":339,"../fx":357,"./draw_arrow_head":310,"d3":85}],310:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49501,7 +49729,7 @@ module.exports = function drawArrowHead(el3, ends, options) { if(doEnd) drawhead(headStyle, end, endRot, scale); }; -},{"../color":319,"./arrow_paths":303,"d3":85}],312:[function(_dereq_,module,exports){ +},{"../color":318,"./arrow_paths":302,"d3":85}],311:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49535,7 +49763,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":499,"./attributes":304,"./calc_autorange":305,"./click":306,"./convert_coords":308,"./defaults":309,"./draw":310}],313:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":495,"./attributes":303,"./calc_autorange":304,"./click":305,"./convert_coords":307,"./defaults":308,"./draw":309}],312:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49623,7 +49851,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":471,"../../plot_api/plot_template":478,"../annotations/attributes":304}],314:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":467,"../../plot_api/plot_template":474,"../annotations/attributes":303}],313:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49688,7 +49916,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":441,"../../plots/cartesian/axes":488}],315:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/cartesian/axes":484}],314:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49764,7 +49992,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":441,"../../plots/array_container_defaults":484,"../../plots/cartesian/axes":488,"../annotations/common_defaults":307,"./attributes":313}],316:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/array_container_defaults":480,"../../plots/cartesian/axes":484,"../annotations/common_defaults":306,"./attributes":312}],315:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49816,7 +50044,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":522,"../annotations/draw":310}],317:[function(_dereq_,module,exports){ +},{"../../plots/gl3d/project":518,"../annotations/draw":309}],316:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49864,7 +50092,7 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":441,"../../registry":532,"./attributes":313,"./convert":314,"./defaults":315,"./draw":316}],318:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528,"./attributes":312,"./convert":313,"./defaults":314,"./draw":315}],317:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -49904,7 +50132,7 @@ exports.borderLine = '#BEC8D9'; // gives back exactly lightLine if the other colors are defaults. exports.lightFraction = 100 * (0xe - 0x4) / (0xf - 0x4); -},{}],319:[function(_dereq_,module,exports){ +},{}],318:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50075,7 +50303,7 @@ function cleanOne(val) { return 'rgb(' + rgbStr + ')'; } -},{"./attributes":318,"fast-isnumeric":149,"tinycolor2":284}],320:[function(_dereq_,module,exports){ +},{"./attributes":317,"fast-isnumeric":149,"tinycolor2":283}],319:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50218,23 +50446,43 @@ module.exports = overrideAll({ exponentformat: axesAttrs.exponentformat, showexponent: axesAttrs.showexponent, title: { - valType: 'string', - - + text: { + valType: 'string', + + + }, + font: fontAttrs({ + + }), + side: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } }, - titlefont: fontAttrs({ - - }), - titleside: { - valType: 'enumerated', - values: ['right', 'top', 'bottom'], - - dflt: 'top', - + + _deprecated: { + title: { + valType: 'string', + + + }, + titlefont: fontAttrs({ + + }), + titleside: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":432,"../../plot_api/edit_types":471,"../../plots/cartesian/layout_attributes":501,"../../plots/font_attributes":515}],321:[function(_dereq_,module,exports){ +},{"../../lib/extend":429,"../../plot_api/edit_types":467,"../../plots/cartesian/layout_attributes":497,"../../plots/font_attributes":511}],320:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50243,10 +50491,10 @@ module.exports = overrideAll({ * LICENSE file in the root directory of this source tree. */ - 'use strict'; var drawColorbar = _dereq_('./draw'); +var flipScale = _dereq_('../colorscale/helpers').flipScale; /** * connectColorbar: create a colorbar from a trace, using its module to @@ -50286,12 +50534,16 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) { var cb = cd[0].t.cb = drawColorbar(gd, cbId); - cb.fillgradient(container.colorscale) + var scl = container.reversescale ? + flipScale(container.colorscale) : + container.colorscale; + + cb.fillgradient(scl) .zrange([container[moduleOpts.min], container[moduleOpts.max]]) .options(container.colorbar)(); }; -},{"./draw":324}],322:[function(_dereq_,module,exports){ +},{"../colorscale/helpers":329,"./draw":323}],321:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50319,7 +50571,7 @@ module.exports = { } }; -},{}],323:[function(_dereq_,module,exports){ +},{}],322:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50381,12 +50633,12 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); - coerce('title', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'titlefont', layout.font); - coerce('titleside'); + coerce('title.text', layout._dfltTitle.colorbar); + Lib.coerceFont(coerce, 'title.font', layout.font); + coerce('title.side'); }; -},{"../../lib":441,"../../plot_api/plot_template":478,"../../plots/cartesian/tick_label_defaults":508,"../../plots/cartesian/tick_mark_defaults":509,"../../plots/cartesian/tick_value_defaults":510,"./attributes":320}],324:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plot_api/plot_template":474,"../../plots/cartesian/tick_label_defaults":504,"../../plots/cartesian/tick_mark_defaults":505,"../../plots/cartesian/tick_value_defaults":506,"./attributes":319}],323:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50573,9 +50825,9 @@ module.exports = function draw(gd, id) { showticksuffix: opts.showticksuffix, ticksuffix: opts.ticksuffix, title: opts.title, - titlefont: opts.titlefont, showline: true, anchor: 'free', + side: 'right', position: 1 }, cbAxisOut = { @@ -50586,6 +50838,7 @@ module.exports = function draw(gd, id) { letter: 'y', font: fullLayout.font, noHover: true, + noTickson: true, calendar: fullLayout.calendar // not really necessary (yet?) }; @@ -50606,11 +50859,11 @@ module.exports = function draw(gd, id) { // save for other callers to access this axis component.axis = cbAxisOut; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { - cbAxisOut.titleside = opts.titleside; + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { + cbAxisOut.title.side = opts.title.side; cbAxisOut.titlex = opts.x + xpadFrac; cbAxisOut.titley = yBottomFrac + - (opts.titleside === 'top' ? lenFrac - ypadFrac : ypadFrac); + (opts.title.side === 'top' ? lenFrac - ypadFrac : ypadFrac); } if(opts.line.color && opts.tickmode === 'auto') { @@ -50670,17 +50923,18 @@ module.exports = function draw(gd, id) { Math.round(gs.l) + ',-' + Math.round(gs.t) + ')'); - cbAxisOut._axislayer = container.select('.cbaxis'); + var axisLayer = container.select('.cbaxis'); + var titleHeight = 0; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // draw the title so we know how much room it needs // when we squish the axis. This one only applies to // top or bottom titles, not right side. var x = gs.l + (opts.x + xpadFrac) * gs.w, - fontSize = cbAxisOut.titlefont.size, + fontSize = cbAxisOut.title.font.size, y; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; } @@ -50694,7 +50948,7 @@ module.exports = function draw(gd, id) { } function drawAxis() { - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // squish the axis top to make room for the title var titleGroup = container.select('.cbtitle'), titleText = titleGroup.select('text'), @@ -50725,7 +50979,7 @@ module.exports = function draw(gd, id) { // TODO: configurable titleHeight += 5; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; } @@ -50746,8 +51000,7 @@ module.exports = function draw(gd, id) { .attr('transform', 'translate(0,' + Math.round(gs.h * (1 - cbAxisOut.domain[1])) + ')'); - cbAxisOut._axislayer.attr('transform', 'translate(0,' + - Math.round(-gs.t) + ')'); + axisLayer.attr('transform', 'translate(0,' + Math.round(-gs.t) + ')'); var fills = container.select('.cbfills') .selectAll('rect.cbfill') @@ -50814,12 +51067,7 @@ module.exports = function draw(gd, id) { }); // force full redraw of labels and ticks - cbAxisOut._axislayer.selectAll('g.' + cbAxisOut._id + 'tick,path') - .remove(); - - cbAxisOut._pos = xLeft + thickPx + - (opts.outlinewidth||0) / 2 - (opts.ticks === 'outside' ? 1 : 0); - cbAxisOut.side = 'right'; + axisLayer.selectAll('g.' + cbAxisOut._id + 'tick,path').remove(); // separate out axis and title drawing, // so we don't need such complicated logic in Titles.draw @@ -50827,11 +51075,33 @@ module.exports = function draw(gd, id) { // this title call only handles side=right return Lib.syncOrAsync([ function() { - return Axes.doTicksSingle(gd, cbAxisOut, true); + var shift = xLeft + thickPx + + (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0); + + var vals = Axes.calcTicks(cbAxisOut); + var transFn = Axes.makeTransFn(cbAxisOut); + var labelFns = Axes.makeLabelFns(cbAxisOut, shift); + var tickSign = Axes.getTickSigns(cbAxisOut)[2]; + + Axes.drawTicks(gd, cbAxisOut, { + vals: cbAxisOut.ticks === 'inside' ? Axes.clipEnds(cbAxisOut, vals) : vals, + layer: axisLayer, + path: Axes.makeTickPath(cbAxisOut, shift, tickSign), + transFn: transFn + }); + + return Axes.drawLabels(gd, cbAxisOut, { + vals: vals, + layer: axisLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); }, function() { - if(['top', 'bottom'].indexOf(opts.titleside) === -1) { - var fontSize = cbAxisOut.titlefont.size, + if(['top', 'bottom'].indexOf(opts.title.side) === -1) { + var fontSize = cbAxisOut.title.font.size, y = cbAxisOut._offset + cbAxisOut._length / 2, x = gs.l + (cbAxisOut.position || 0) * gs.w + ((cbAxisOut.side === 'right') ? 10 + fontSize * ((cbAxisOut.showticklabels ? 1 : 0.5)) : @@ -50843,7 +51113,7 @@ module.exports = function draw(gd, id) { drawTitle('h' + cbAxisOut._id + 'title', { avoid: { selection: d3.select(gd).selectAll('g.' + cbAxisOut._id + 'tick'), - side: opts.titleside, + side: opts.title.side, offsetLeft: gs.l, offsetTop: 0, maxShift: fullLayout.width @@ -50856,15 +51126,10 @@ module.exports = function draw(gd, id) { } function drawTitle(titleClass, titleOpts) { - var trace = getTrace(); - var propName = 'colorbar.title'; - var containerName = trace._module.colorbar.container; - if(containerName) propName = containerName + '.' + propName; - var dfltTitleOpts = { propContainer: cbAxisOut, - propName: propName, - traceIndex: trace.index, + propName: getPropName('title'), + traceIndex: getTrace().index, placeholder: fullLayout._dfltTitle.colorbar, containerGroup: container.select('.cbtitle') }; @@ -50888,7 +51153,7 @@ module.exports = function draw(gd, id) { // TODO: why are we redrawing multiple times now with this? // I guess autoMargin doesn't like being post-promise? var innerWidth = thickPx + opts.outlinewidth / 2 + - Drawing.bBox(cbAxisOut._axislayer.node()).width; + Drawing.bBox(axisLayer.node()).width; titleEl = titleCont.select('text'); if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) { var mathJaxNode = titleCont @@ -50896,11 +51161,11 @@ module.exports = function draw(gd, id) { .node(), titleWidth; if(mathJaxNode && - ['top', 'bottom'].indexOf(opts.titleside) !== -1) { + ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; } else { - // note: the formula below works for all titlesides, + // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift // transform gets removed by Drawing.bBox @@ -50929,7 +51194,7 @@ module.exports = function draw(gd, id) { container.selectAll('.cboutline').attr({ x: xLeft, y: yTopPx + opts.ypad + - (opts.titleside === 'top' ? titleHeight : 0), + (opts.title.side === 'top' ? titleHeight : 0), width: Math.max(thickPx, 2), height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2) }) @@ -51016,11 +51281,10 @@ module.exports = function draw(gd, id) { setCursor(container); if(xf !== undefined && yf !== undefined) { - Registry.call('restyle', - gd, - {'colorbar.x': xf, 'colorbar.y': yf}, - getTrace().index - ); + var update = {}; + update[getPropName('x')] = xf; + update[getPropName('y')] = yf; + Registry.call('_guiRestyle', gd, update, getTrace().index); } } }); @@ -51038,6 +51302,14 @@ module.exports = function draw(gd, id) { } } + function getPropName(suffix) { + var trace = getTrace(); + var propName = 'colorbar.'; + var containerName = trace._module.colorbar.container; + if(containerName) propName = containerName + '.' + propName; + return propName + suffix; + } + // setter/getters for every item defined in opts Object.keys(opts).forEach(function(name) { component[name] = function(v) { @@ -51071,7 +51343,7 @@ module.exports = function draw(gd, id) { return component; }; -},{"../../constants/alignment":417,"../../lib":441,"../../lib/extend":432,"../../lib/setcursor":461,"../../lib/svg_text_utils":465,"../../plots/cartesian/axes":488,"../../plots/cartesian/axis_defaults":490,"../../plots/cartesian/layout_attributes":501,"../../plots/cartesian/position_defaults":504,"../../plots/plots":525,"../../registry":532,"../color":319,"../dragelement":341,"../drawing":344,"../titles":410,"./attributes":320,"./constants":322,"d3":85,"tinycolor2":284}],325:[function(_dereq_,module,exports){ +},{"../../constants/alignment":413,"../../lib":437,"../../lib/extend":429,"../../lib/setcursor":457,"../../lib/svg_text_utils":461,"../../plots/cartesian/axes":484,"../../plots/cartesian/axis_defaults":486,"../../plots/cartesian/layout_attributes":497,"../../plots/cartesian/position_defaults":500,"../../plots/plots":521,"../../registry":528,"../color":318,"../dragelement":336,"../drawing":339,"../titles":406,"./attributes":319,"./constants":321,"d3":85,"tinycolor2":283}],324:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51090,7 +51362,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":441}],326:[function(_dereq_,module,exports){ +},{"../../lib":437}],325:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51101,7 +51373,7 @@ module.exports = function hasColorbar(container) { 'use strict'; -var palettes = _dereq_('./scales.js'); +var palettes = _dereq_('./scales.js').scales; var paletteStr = Object.keys(palettes); function code(s) { @@ -51248,7 +51520,7 @@ module.exports = function colorScaleAttrs(context, opts) { valType: 'boolean', dflt: false, - editType: 'calc', + editType: 'plot', }; @@ -51265,7 +51537,7 @@ module.exports = function colorScaleAttrs(context, opts) { return attrs; }; -},{"./scales.js":338}],327:[function(_dereq_,module,exports){ +},{"./scales.js":333}],326:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51274,49 +51546,19 @@ module.exports = function colorScaleAttrs(context, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); -var scales = _dereq_('./scales'); -var flipScale = _dereq_('./flip_scale'); - - -module.exports = function calc(trace, vals, containerStr, cLetter) { - var container = trace; - var inputContainer = trace._input; - var fullInputContainer = trace._fullInput; - - // set by traces with groupby transforms - var updateStyle = trace.updateStyle; - - function doUpdate(attr, inputVal, fullVal) { - if(fullVal === undefined) fullVal = inputVal; - - if(updateStyle) { - updateStyle(trace._input, containerStr ? (containerStr + '.' + attr) : attr, inputVal); - } - else { - inputContainer[attr] = inputVal; - } - - container[attr] = fullVal; - if(fullInputContainer && (trace !== trace._fullInput)) { - if(updateStyle) { - updateStyle(trace._fullInput, containerStr ? (containerStr + '.' + attr) : attr, fullVal); - } - else { - fullInputContainer[attr] = fullVal; - } - } - } +module.exports = function calc(gd, trace, opts) { + var fullLayout = gd._fullLayout; + var vals = opts.vals; + var containerStr = opts.containerStr; + var cLetter = opts.cLetter; - if(containerStr) { - container = Lib.nestedProperty(container, containerStr).get(); - inputContainer = Lib.nestedProperty(inputContainer, containerStr).get(); - fullInputContainer = Lib.nestedProperty(fullInputContainer, containerStr).get() || {}; - } + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() : + trace; var autoAttr = cLetter + 'auto'; var minAttr = cLetter + 'min'; @@ -51339,37 +51581,19 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { max += 0.5; } - doUpdate(minAttr, min); - doUpdate(maxAttr, max); - - /* - * If auto was explicitly false but min or max was missing, - * we filled in the missing piece here but later the trace does - * not look auto. - * Otherwise make sure the trace still looks auto as far as later - * changes are concerned. - */ - doUpdate(autoAttr, (auto !== false || (min === undefined && max === undefined))); + container['_' + minAttr] = container[minAttr] = min; + container['_' + maxAttr] = container[maxAttr] = max; if(container.autocolorscale) { - if(min * max < 0) scl = scales.RdBu; - else if(min >= 0) scl = scales.Reds; - else scl = scales.Blues; - - // reversescale is handled at the containerOut level - doUpdate('colorscale', scl, container.reversescale ? flipScale(scl) : scl); + if(min * max < 0) scl = fullLayout.colorscale.diverging; + else if(min >= 0) scl = fullLayout.colorscale.sequential; + else scl = fullLayout.colorscale.sequentialminus; - // We pushed a colorscale back to input, which will change the default autocolorscale next time - // to avoid spurious redraws from Plotly.react, update resulting autocolorscale now - // This is a conscious decision so that changing the data later does not unexpectedly - // give you a new colorscale - if(!inputContainer.autocolorscale) { - doUpdate('autocolorscale', false); - } + container._colorscale = container.colorscale = scl; } }; -},{"../../lib":441,"./flip_scale":331,"./scales":338}],328:[function(_dereq_,module,exports){ +},{"../../lib":437}],327:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51380,12 +51604,68 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { 'use strict'; -var scales = _dereq_('./scales'); +var Lib = _dereq_('../../lib'); +var hasColorscale = _dereq_('./helpers').hasColorscale; + +module.exports = function crossTraceDefaults(fullData) { + function replace(cont, k) { + var val = cont['_' + k]; + if(val !== undefined) { + cont[k] = val; + } + } + + function relinkColorAtts(trace, cAttrs) { + var cont = cAttrs.container ? + Lib.nestedProperty(trace, cAttrs.container).get() : + trace; + + if(cont) { + var isAuto = cont.zauto || cont.cauto; + var minAttr = cAttrs.min; + var maxAttr = cAttrs.max; + + if(isAuto || cont[minAttr] === undefined) { + replace(cont, minAttr); + } + if(isAuto || cont[maxAttr] === undefined) { + replace(cont, maxAttr); + } + if(cont.autocolorscale) { + replace(cont, 'colorscale'); + } + } + } + for(var i = 0; i < fullData.length; i++) { + var trace = fullData[i]; + var _module = trace._module; -module.exports = scales.RdBu; + if(_module.colorbar) { + relinkColorAtts(trace, _module.colorbar); + } -},{"./scales":338}],329:[function(_dereq_,module,exports){ + // TODO could generalize _module.colorscale and use it here? + + if(hasColorscale(trace, 'marker.line')) { + relinkColorAtts(trace, { + container: 'marker.line', + min: 'cmin', + max: 'cmax' + }); + } + + if(hasColorscale(trace, 'line')) { + relinkColorAtts(trace, { + container: 'line', + min: 'cmin', + max: 'cmax' + }); + } + } +}; + +},{"../../lib":437,"./helpers":329}],328:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51394,33 +51674,32 @@ module.exports = scales.RdBu; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); - var hasColorbar = _dereq_('../colorbar/has_colorbar'); var colorbarDefaults = _dereq_('../colorbar/defaults'); -var isValidScale = _dereq_('./is_valid_scale'); -var flipScale = _dereq_('./flip_scale'); +var isValidScale = _dereq_('./scales').isValid; -module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { - var prefix = opts.prefix, - cLetter = opts.cLetter, - containerStr = prefix.slice(0, prefix.length - 1), - containerIn = prefix ? - Lib.nestedProperty(traceIn, containerStr).get() || {} : - traceIn, - containerOut = prefix ? - Lib.nestedProperty(traceOut, containerStr).get() || {} : - traceOut, - minIn = containerIn[cLetter + 'min'], - maxIn = containerIn[cLetter + 'max'], - sclIn = containerIn.colorscale; +function npMaybe(cont, prefix) { + var containerStr = prefix.slice(0, prefix.length - 1); + return prefix ? + Lib.nestedProperty(cont, containerStr).get() || {} : + cont; +} +module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { + var prefix = opts.prefix; + var cLetter = opts.cLetter; + var containerIn = npMaybe(traceIn, prefix); + var containerOut = npMaybe(traceOut, prefix); + var template = npMaybe(traceOut._template || {}, prefix) || {}; + + var minIn = containerIn[cLetter + 'min']; + var maxIn = containerIn[cLetter + 'max']; var validMinMax = isNumeric(minIn) && isNumeric(maxIn) && (minIn < maxIn); coerce(prefix + cLetter + 'auto', !validMinMax); coerce(prefix + cLetter + 'min'); @@ -51428,19 +51707,17 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, // handles both the trace case (autocolorscale is false by default) and // the marker and marker.line case (autocolorscale is true by default) + var sclIn = containerIn.colorscale; + var sclTemplate = template.colorscale; var autoColorscaleDflt; if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn); + if(sclTemplate !== undefined) autoColorscaleDflt = !isValidScale(sclTemplate); coerce(prefix + 'autocolorscale', autoColorscaleDflt); - var sclOut = coerce(prefix + 'colorscale'); - - // reversescale is handled at the containerOut level - var reverseScale = coerce(prefix + 'reversescale'); - if(reverseScale) containerOut.colorscale = flipScale(sclOut); - // ... until Scatter.colorbar can handle marker line colorbars - if(prefix === 'marker.line.') return; + coerce(prefix + 'colorscale'); + coerce(prefix + 'reversescale'); - if(!opts.noScale) { + if(!opts.noScale && prefix !== 'marker.line.') { // handles both the trace case where the dflt is listed in attributes and // the marker case where the dflt is determined by hasColorbar var showScaleDflt; @@ -51451,7 +51728,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, } }; -},{"../../lib":441,"../colorbar/defaults":323,"../colorbar/has_colorbar":325,"./flip_scale":331,"./is_valid_scale":335,"fast-isnumeric":149}],330:[function(_dereq_,module,exports){ +},{"../../lib":437,"../colorbar/defaults":322,"../colorbar/has_colorbar":324,"./scales":333,"fast-isnumeric":149}],329:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51460,24 +51737,77 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var d3 = _dereq_('d3'); +var tinycolor = _dereq_('tinycolor2'); +var isNumeric = _dereq_('fast-isnumeric'); + +var Lib = _dereq_('../../lib'); +var Color = _dereq_('../color'); + +var isValidScale = _dereq_('./scales').isValid; + +function hasColorscale(trace, containerStr) { + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() || {} : + trace; + var color = container.color; + + var isArrayWithOneNumber = false; + if(Lib.isArrayOrTypedArray(color)) { + for(var i = 0; i < color.length; i++) { + if(isNumeric(color[i])) { + isArrayWithOneNumber = true; + break; + } + } + } + + return ( + Lib.isPlainObject(container) && ( + isArrayWithOneNumber || + container.showscale === true || + (isNumeric(container.cmin) && isNumeric(container.cmax)) || + isValidScale(container.colorscale) || + Lib.isPlainObject(container.colorbar) + ) + ); +} + /** * Extract colorscale into numeric domain and color range. * - * @param {array} scl colorscale array of arrays - * @param {number} cmin minimum color value (used to clamp scale) - * @param {number} cmax maximum color value (used to clamp scale) + * @param {object} cont colorscale container (e.g. trace, marker) + * - colorscale {array of arrays} + * - cmin/zmin {number} + * - cmax/zmax {number} + * - reversescale {boolean} + * @param {object} opts + * - cLetter {string} 'c' (for cmin/cmax) or 'z' (for zmin/zmax) + * + * @return {object} + * - domain {array} + * - range {array} */ -module.exports = function extractScale(scl, cmin, cmax) { - var N = scl.length, - domain = new Array(N), - range = new Array(N); +function extractScale(cont, opts) { + var cLetter = opts.cLetter; + + var scl = cont.reversescale ? + flipScale(cont.colorscale) : + cont.colorscale; + + // minimum color value (used to clamp scale) + var cmin = cont[cLetter + 'min']; + // maximum color value (used to clamp scale) + var cmax = cont[cLetter + 'max']; + + var N = scl.length; + var domain = new Array(N); + var range = new Array(N); for(var i = 0; i < N; i++) { var si = scl[i]; - domain[i] = cmin + si[0] * (cmax - cmin); range[i] = si[1]; } @@ -51486,9 +51816,105 @@ module.exports = function extractScale(scl, cmin, cmax) { domain: domain, range: range }; +} + +function flipScale(scl) { + var N = scl.length; + var sclNew = new Array(N); + + for(var i = N - 1, j = 0; i >= 0; i--, j++) { + var si = scl[i]; + sclNew[j] = [1 - si[0], si[1]]; + } + return sclNew; +} + +/** + * General colorscale function generator. + * + * @param {object} specs output of Colorscale.extractScale or precomputed domain, range. + * - domain {array} + * - range {array} + * + * @param {object} opts + * - noNumericCheck {boolean} if true, scale func bypasses numeric checks + * - returnArray {boolean} if true, scale func return 4-item array instead of color strings + * + * @return {function} + */ +function makeColorScaleFunc(specs, opts) { + opts = opts || {}; + + var domain = specs.domain, + range = specs.range, + N = range.length, + _range = new Array(N); + + for(var i = 0; i < N; i++) { + var rgba = tinycolor(range[i]).toRgb(); + _range[i] = [rgba.r, rgba.g, rgba.b, rgba.a]; + } + + var _sclFunc = d3.scale.linear() + .domain(domain) + .range(_range) + .clamp(true); + + var noNumericCheck = opts.noNumericCheck, + returnArray = opts.returnArray, + sclFunc; + + if(noNumericCheck && returnArray) { + sclFunc = _sclFunc; + } + else if(noNumericCheck) { + sclFunc = function(v) { + return colorArray2rbga(_sclFunc(v)); + }; + } + else if(returnArray) { + sclFunc = function(v) { + if(isNumeric(v)) return _sclFunc(v); + else if(tinycolor(v).isValid()) return v; + else return Color.defaultLine; + }; + } + else { + sclFunc = function(v) { + if(isNumeric(v)) return colorArray2rbga(_sclFunc(v)); + else if(tinycolor(v).isValid()) return v; + else return Color.defaultLine; + }; + } + + // colorbar draw looks into the d3 scale closure for domain and range + + sclFunc.domain = _sclFunc.domain; + + sclFunc.range = function() { return range; }; + + return sclFunc; +} + +function colorArray2rbga(colorArray) { + var colorObj = { + r: colorArray[0], + g: colorArray[1], + b: colorArray[2], + a: colorArray[3] + }; + + return tinycolor(colorObj).toRgbString(); +} + +module.exports = { + hasColorscale: hasColorscale, + extractScale: extractScale, + flipScale: flipScale, + makeColorScaleFunc: makeColorScaleFunc }; -},{}],331:[function(_dereq_,module,exports){ +},{"../../lib":437,"../color":318,"./scales":333,"d3":85,"fast-isnumeric":149,"tinycolor2":283}],330:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51497,23 +51923,38 @@ module.exports = function extractScale(scl, cmin, cmax) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -module.exports = function flipScale(scl) { - var N = scl.length, - sclNew = new Array(N), - si; +var scales = _dereq_('./scales'); +var helpers = _dereq_('./helpers'); - for(var i = N - 1, j = 0; i >= 0; i--, j++) { - si = scl[i]; - sclNew[j] = [1 - si[0], si[1]]; - } +module.exports = { + moduleType: 'component', + name: 'colorscale', - return sclNew; + attributes: _dereq_('./attributes'), + layoutAttributes: _dereq_('./layout_attributes'), + + supplyLayoutDefaults: _dereq_('./layout_defaults'), + handleDefaults: _dereq_('./defaults'), + crossTraceDefaults: _dereq_('./cross_trace_defaults'), + + calc: _dereq_('./calc'), + + // ./scales.js is required in lib/coerce.js ; + // it needs to be a seperate module to avoid circular a dependency + scales: scales.scales, + defaultScale: scales.defaultScale, + getScale: scales.get, + isValidScale: scales.isValid, + + hasColorscale: helpers.hasColorscale, + flipScale: helpers.flipScale, + extractScale: helpers.extractScale, + makeColorScaleFunc: helpers.makeColorScaleFunc }; -},{}],332:[function(_dereq_,module,exports){ +},{"./attributes":325,"./calc":326,"./cross_trace_defaults":327,"./defaults":328,"./helpers":329,"./layout_attributes":331,"./layout_defaults":332,"./scales":333}],331:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51522,38 +51963,38 @@ module.exports = function flipScale(scl) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var scales = _dereq_('./scales'); -var defaultScale = _dereq_('./default_scale'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function getScale(scl, dflt) { - if(!dflt) dflt = defaultScale; - if(!scl) return dflt; +var scales = _dereq_('./scales').scales; - function parseScale() { - try { - scl = scales[scl] || JSON.parse(scl); - } - catch(e) { - scl = dflt; - } - } +var msg = 'Note that `autocolorscale` must be true for this attribute to work.'; - if(typeof scl === 'string') { - parseScale(); - // occasionally scl is double-JSON encoded... - if(typeof scl === 'string') parseScale(); +module.exports = { + editType: 'calc', + sequential: { + valType: 'colorscale', + dflt: scales.Reds, + + editType: 'calc', + + }, + sequentialminus: { + valType: 'colorscale', + dflt: scales.Blues, + + editType: 'calc', + + }, + diverging: { + valType: 'colorscale', + dflt: scales.RdBu, + + editType: 'calc', + } - - if(!isValidScaleArray(scl)) return dflt; - return scl; }; -},{"./default_scale":328,"./is_valid_scale_array":336,"./scales":338}],333:[function(_dereq_,module,exports){ +},{"./scales":333}],332:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51564,38 +52005,23 @@ module.exports = function getScale(scl, dflt) { 'use strict'; -var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); -var isValidScale = _dereq_('./is_valid_scale'); - -module.exports = function hasColorscale(trace, containerStr) { - var container = containerStr ? - Lib.nestedProperty(trace, containerStr).get() || {} : - trace; - var color = container.color; +var colorscaleAttrs = _dereq_('./layout_attributes'); +var Template = _dereq_('../../plot_api/plot_template'); - var isArrayWithOneNumber = false; - if(Lib.isArrayOrTypedArray(color)) { - for(var i = 0; i < color.length; i++) { - if(isNumeric(color[i])) { - isArrayWithOneNumber = true; - break; - } - } +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var colorscaleIn = layoutIn.colorscale; + var colorscaleOut = Template.newContainer(layoutOut, 'colorscale'); + function coerce(attr, dflt) { + return Lib.coerce(colorscaleIn, colorscaleOut, colorscaleAttrs, attr, dflt); } - return ( - Lib.isPlainObject(container) && ( - isArrayWithOneNumber || - container.showscale === true || - (isNumeric(container.cmin) && isNumeric(container.cmax)) || - isValidScale(container.colorscale) || - Lib.isPlainObject(container.colorbar) - ) - ); + coerce('sequential'); + coerce('sequentialminus'); + coerce('diverging'); }; -},{"../../lib":441,"./is_valid_scale":335,"fast-isnumeric":149}],334:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plot_api/plot_template":474,"./layout_attributes":331}],333:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51604,68 +52030,167 @@ module.exports = function hasColorscale(trace, containerStr) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -exports.scales = _dereq_('./scales'); +var tinycolor = _dereq_('tinycolor2'); -exports.defaultScale = _dereq_('./default_scale'); +var scales = { + 'Greys': [ + [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] + ], -exports.attributes = _dereq_('./attributes'); + 'YlGnBu': [ + [0, 'rgb(8,29,88)'], [0.125, 'rgb(37,52,148)'], + [0.25, 'rgb(34,94,168)'], [0.375, 'rgb(29,145,192)'], + [0.5, 'rgb(65,182,196)'], [0.625, 'rgb(127,205,187)'], + [0.75, 'rgb(199,233,180)'], [0.875, 'rgb(237,248,217)'], + [1, 'rgb(255,255,217)'] + ], -exports.handleDefaults = _dereq_('./defaults'); + 'Greens': [ + [0, 'rgb(0,68,27)'], [0.125, 'rgb(0,109,44)'], + [0.25, 'rgb(35,139,69)'], [0.375, 'rgb(65,171,93)'], + [0.5, 'rgb(116,196,118)'], [0.625, 'rgb(161,217,155)'], + [0.75, 'rgb(199,233,192)'], [0.875, 'rgb(229,245,224)'], + [1, 'rgb(247,252,245)'] + ], + + 'YlOrRd': [ + [0, 'rgb(128,0,38)'], [0.125, 'rgb(189,0,38)'], + [0.25, 'rgb(227,26,28)'], [0.375, 'rgb(252,78,42)'], + [0.5, 'rgb(253,141,60)'], [0.625, 'rgb(254,178,76)'], + [0.75, 'rgb(254,217,118)'], [0.875, 'rgb(255,237,160)'], + [1, 'rgb(255,255,204)'] + ], -exports.calc = _dereq_('./calc'); + 'Bluered': [ + [0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)'] + ], -exports.hasColorscale = _dereq_('./has_colorscale'); + // modified RdBu based on + // www.sandia.gov/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf + 'RdBu': [ + [0, 'rgb(5,10,172)'], [0.35, 'rgb(106,137,247)'], + [0.5, 'rgb(190,190,190)'], [0.6, 'rgb(220,170,132)'], + [0.7, 'rgb(230,145,90)'], [1, 'rgb(178,10,28)'] + ], + + // Scale for non-negative numeric values + 'Reds': [ + [0, 'rgb(220,220,220)'], [0.2, 'rgb(245,195,157)'], + [0.4, 'rgb(245,160,105)'], [1, 'rgb(178,10,28)'] + ], -exports.isValidScale = _dereq_('./is_valid_scale'); + // Scale for non-positive numeric values + 'Blues': [ + [0, 'rgb(5,10,172)'], [0.35, 'rgb(40,60,190)'], + [0.5, 'rgb(70,100,245)'], [0.6, 'rgb(90,120,245)'], + [0.7, 'rgb(106,137,247)'], [1, 'rgb(220,220,220)'] + ], -exports.getScale = _dereq_('./get_scale'); + 'Picnic': [ + [0, 'rgb(0,0,255)'], [0.1, 'rgb(51,153,255)'], + [0.2, 'rgb(102,204,255)'], [0.3, 'rgb(153,204,255)'], + [0.4, 'rgb(204,204,255)'], [0.5, 'rgb(255,255,255)'], + [0.6, 'rgb(255,204,255)'], [0.7, 'rgb(255,153,255)'], + [0.8, 'rgb(255,102,204)'], [0.9, 'rgb(255,102,102)'], + [1, 'rgb(255,0,0)'] + ], -exports.flipScale = _dereq_('./flip_scale'); + 'Rainbow': [ + [0, 'rgb(150,0,90)'], [0.125, 'rgb(0,0,200)'], + [0.25, 'rgb(0,25,255)'], [0.375, 'rgb(0,152,255)'], + [0.5, 'rgb(44,255,150)'], [0.625, 'rgb(151,255,0)'], + [0.75, 'rgb(255,234,0)'], [0.875, 'rgb(255,111,0)'], + [1, 'rgb(255,0,0)'] + ], -exports.extractScale = _dereq_('./extract_scale'); + 'Portland': [ + [0, 'rgb(12,51,131)'], [0.25, 'rgb(10,136,186)'], + [0.5, 'rgb(242,211,56)'], [0.75, 'rgb(242,143,56)'], + [1, 'rgb(217,30,30)'] + ], -exports.makeColorScaleFunc = _dereq_('./make_color_scale_func'); + 'Jet': [ + [0, 'rgb(0,0,131)'], [0.125, 'rgb(0,60,170)'], + [0.375, 'rgb(5,255,255)'], [0.625, 'rgb(255,255,0)'], + [0.875, 'rgb(250,0,0)'], [1, 'rgb(128,0,0)'] + ], -},{"./attributes":326,"./calc":327,"./default_scale":328,"./defaults":329,"./extract_scale":330,"./flip_scale":331,"./get_scale":332,"./has_colorscale":333,"./is_valid_scale":335,"./make_color_scale_func":337,"./scales":338}],335:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ + 'Hot': [ + [0, 'rgb(0,0,0)'], [0.3, 'rgb(230,0,0)'], + [0.6, 'rgb(255,210,0)'], [1, 'rgb(255,255,255)'] + ], + 'Blackbody': [ + [0, 'rgb(0,0,0)'], [0.2, 'rgb(230,0,0)'], + [0.4, 'rgb(230,210,0)'], [0.7, 'rgb(255,255,255)'], + [1, 'rgb(160,200,255)'] + ], -'use strict'; + 'Earth': [ + [0, 'rgb(0,0,130)'], [0.1, 'rgb(0,180,180)'], + [0.2, 'rgb(40,210,40)'], [0.4, 'rgb(230,230,50)'], + [0.6, 'rgb(120,70,20)'], [1, 'rgb(255,255,255)'] + ], -var scales = _dereq_('./scales'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); + 'Electric': [ + [0, 'rgb(0,0,0)'], [0.15, 'rgb(30,0,100)'], + [0.4, 'rgb(120,0,100)'], [0.6, 'rgb(160,90,0)'], + [0.8, 'rgb(230,200,0)'], [1, 'rgb(255,250,220)'] + ], + 'Viridis': [ + [0, '#440154'], [0.06274509803921569, '#48186a'], + [0.12549019607843137, '#472d7b'], [0.18823529411764706, '#424086'], + [0.25098039215686274, '#3b528b'], [0.3137254901960784, '#33638d'], + [0.3764705882352941, '#2c728e'], [0.4392156862745098, '#26828e'], + [0.5019607843137255, '#21918c'], [0.5647058823529412, '#1fa088'], + [0.6274509803921569, '#28ae80'], [0.6901960784313725, '#3fbc73'], + [0.7529411764705882, '#5ec962'], [0.8156862745098039, '#84d44b'], + [0.8784313725490196, '#addc30'], [0.9411764705882353, '#d8e219'], + [1, '#fde725'] + ], -module.exports = function isValidScale(scl) { - if(scales[scl] !== undefined) return true; - else return isValidScaleArray(scl); + 'Cividis': [ + [0.000000, 'rgb(0,32,76)'], [0.058824, 'rgb(0,42,102)'], + [0.117647, 'rgb(0,52,110)'], [0.176471, 'rgb(39,63,108)'], + [0.235294, 'rgb(60,74,107)'], [0.294118, 'rgb(76,85,107)'], + [0.352941, 'rgb(91,95,109)'], [0.411765, 'rgb(104,106,112)'], + [0.470588, 'rgb(117,117,117)'], [0.529412, 'rgb(131,129,120)'], + [0.588235, 'rgb(146,140,120)'], [0.647059, 'rgb(161,152,118)'], + [0.705882, 'rgb(176,165,114)'], [0.764706, 'rgb(192,177,109)'], + [0.823529, 'rgb(209,191,102)'], [0.882353, 'rgb(225,204,92)'], + [0.941176, 'rgb(243,219,79)'], [1.000000, 'rgb(255,233,69)'] + ] }; -},{"./is_valid_scale_array":336,"./scales":338}],336:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +var defaultScale = scales.RdBu; +function getScale(scl, dflt) { + if(!dflt) dflt = defaultScale; + if(!scl) return dflt; -'use strict'; + function parseScale() { + try { + scl = scales[scl] || JSON.parse(scl); + } catch(e) { + scl = dflt; + } + } -var tinycolor = _dereq_('tinycolor2'); + if(typeof scl === 'string') { + parseScale(); + // occasionally scl is double-JSON encoded... + if(typeof scl === 'string') parseScale(); + } + + if(!isValidScaleArray(scl)) return dflt; + return scl; +} -module.exports = function isValidScaleArray(scl) { +function isValidScaleArray(scl) { var highestVal = 0; if(!Array.isArray(scl) || scl.length < 2) return false; @@ -51685,248 +52210,22 @@ module.exports = function isValidScaleArray(scl) { } return true; -}; - -},{"tinycolor2":284}],337:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var d3 = _dereq_('d3'); -var tinycolor = _dereq_('tinycolor2'); -var isNumeric = _dereq_('fast-isnumeric'); - -var Color = _dereq_('../color'); - -/** - * General colorscale function generator. - * - * @param {object} specs output of Colorscale.extractScale or precomputed domain, range. - * - domain {array} - * - range {array} - * - * @param {object} opts - * - noNumericCheck {boolean} if true, scale func bypasses numeric checks - * - returnArray {boolean} if true, scale func return 4-item array instead of color strings - * - * @return {function} - */ -module.exports = function makeColorScaleFunc(specs, opts) { - opts = opts || {}; - - var domain = specs.domain, - range = specs.range, - N = range.length, - _range = new Array(N); - - for(var i = 0; i < N; i++) { - var rgba = tinycolor(range[i]).toRgb(); - _range[i] = [rgba.r, rgba.g, rgba.b, rgba.a]; - } - - var _sclFunc = d3.scale.linear() - .domain(domain) - .range(_range) - .clamp(true); - - var noNumericCheck = opts.noNumericCheck, - returnArray = opts.returnArray, - sclFunc; - - if(noNumericCheck && returnArray) { - sclFunc = _sclFunc; - } - else if(noNumericCheck) { - sclFunc = function(v) { - return colorArray2rbga(_sclFunc(v)); - }; - } - else if(returnArray) { - sclFunc = function(v) { - if(isNumeric(v)) return _sclFunc(v); - else if(tinycolor(v).isValid()) return v; - else return Color.defaultLine; - }; - } - else { - sclFunc = function(v) { - if(isNumeric(v)) return colorArray2rbga(_sclFunc(v)); - else if(tinycolor(v).isValid()) return v; - else return Color.defaultLine; - }; - } - - // colorbar draw looks into the d3 scale closure for domain and range - - sclFunc.domain = _sclFunc.domain; - - sclFunc.range = function() { return range; }; - - return sclFunc; -}; - -function colorArray2rbga(colorArray) { - var colorObj = { - r: colorArray[0], - g: colorArray[1], - b: colorArray[2], - a: colorArray[3] - }; - - return tinycolor(colorObj).toRgbString(); } -},{"../color":319,"d3":85,"fast-isnumeric":149,"tinycolor2":284}],338:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - +function isValidScale(scl) { + if(scales[scl] !== undefined) return true; + else return isValidScaleArray(scl); +} module.exports = { - 'Greys': [ - [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] - ], + scales: scales, + defaultScale: defaultScale, - 'YlGnBu': [ - [0, 'rgb(8,29,88)'], [0.125, 'rgb(37,52,148)'], - [0.25, 'rgb(34,94,168)'], [0.375, 'rgb(29,145,192)'], - [0.5, 'rgb(65,182,196)'], [0.625, 'rgb(127,205,187)'], - [0.75, 'rgb(199,233,180)'], [0.875, 'rgb(237,248,217)'], - [1, 'rgb(255,255,217)'] - ], - - 'Greens': [ - [0, 'rgb(0,68,27)'], [0.125, 'rgb(0,109,44)'], - [0.25, 'rgb(35,139,69)'], [0.375, 'rgb(65,171,93)'], - [0.5, 'rgb(116,196,118)'], [0.625, 'rgb(161,217,155)'], - [0.75, 'rgb(199,233,192)'], [0.875, 'rgb(229,245,224)'], - [1, 'rgb(247,252,245)'] - ], - - 'YlOrRd': [ - [0, 'rgb(128,0,38)'], [0.125, 'rgb(189,0,38)'], - [0.25, 'rgb(227,26,28)'], [0.375, 'rgb(252,78,42)'], - [0.5, 'rgb(253,141,60)'], [0.625, 'rgb(254,178,76)'], - [0.75, 'rgb(254,217,118)'], [0.875, 'rgb(255,237,160)'], - [1, 'rgb(255,255,204)'] - ], - - 'Bluered': [ - [0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)'] - ], - - // modified RdBu based on - // www.sandia.gov/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf - 'RdBu': [ - [0, 'rgb(5,10,172)'], [0.35, 'rgb(106,137,247)'], - [0.5, 'rgb(190,190,190)'], [0.6, 'rgb(220,170,132)'], - [0.7, 'rgb(230,145,90)'], [1, 'rgb(178,10,28)'] - ], - - // Scale for non-negative numeric values - 'Reds': [ - [0, 'rgb(220,220,220)'], [0.2, 'rgb(245,195,157)'], - [0.4, 'rgb(245,160,105)'], [1, 'rgb(178,10,28)'] - ], - - // Scale for non-positive numeric values - 'Blues': [ - [0, 'rgb(5,10,172)'], [0.35, 'rgb(40,60,190)'], - [0.5, 'rgb(70,100,245)'], [0.6, 'rgb(90,120,245)'], - [0.7, 'rgb(106,137,247)'], [1, 'rgb(220,220,220)'] - ], - - 'Picnic': [ - [0, 'rgb(0,0,255)'], [0.1, 'rgb(51,153,255)'], - [0.2, 'rgb(102,204,255)'], [0.3, 'rgb(153,204,255)'], - [0.4, 'rgb(204,204,255)'], [0.5, 'rgb(255,255,255)'], - [0.6, 'rgb(255,204,255)'], [0.7, 'rgb(255,153,255)'], - [0.8, 'rgb(255,102,204)'], [0.9, 'rgb(255,102,102)'], - [1, 'rgb(255,0,0)'] - ], - - 'Rainbow': [ - [0, 'rgb(150,0,90)'], [0.125, 'rgb(0,0,200)'], - [0.25, 'rgb(0,25,255)'], [0.375, 'rgb(0,152,255)'], - [0.5, 'rgb(44,255,150)'], [0.625, 'rgb(151,255,0)'], - [0.75, 'rgb(255,234,0)'], [0.875, 'rgb(255,111,0)'], - [1, 'rgb(255,0,0)'] - ], - - 'Portland': [ - [0, 'rgb(12,51,131)'], [0.25, 'rgb(10,136,186)'], - [0.5, 'rgb(242,211,56)'], [0.75, 'rgb(242,143,56)'], - [1, 'rgb(217,30,30)'] - ], - - 'Jet': [ - [0, 'rgb(0,0,131)'], [0.125, 'rgb(0,60,170)'], - [0.375, 'rgb(5,255,255)'], [0.625, 'rgb(255,255,0)'], - [0.875, 'rgb(250,0,0)'], [1, 'rgb(128,0,0)'] - ], - - 'Hot': [ - [0, 'rgb(0,0,0)'], [0.3, 'rgb(230,0,0)'], - [0.6, 'rgb(255,210,0)'], [1, 'rgb(255,255,255)'] - ], - - 'Blackbody': [ - [0, 'rgb(0,0,0)'], [0.2, 'rgb(230,0,0)'], - [0.4, 'rgb(230,210,0)'], [0.7, 'rgb(255,255,255)'], - [1, 'rgb(160,200,255)'] - ], - - 'Earth': [ - [0, 'rgb(0,0,130)'], [0.1, 'rgb(0,180,180)'], - [0.2, 'rgb(40,210,40)'], [0.4, 'rgb(230,230,50)'], - [0.6, 'rgb(120,70,20)'], [1, 'rgb(255,255,255)'] - ], - - 'Electric': [ - [0, 'rgb(0,0,0)'], [0.15, 'rgb(30,0,100)'], - [0.4, 'rgb(120,0,100)'], [0.6, 'rgb(160,90,0)'], - [0.8, 'rgb(230,200,0)'], [1, 'rgb(255,250,220)'] - ], - - 'Viridis': [ - [0, '#440154'], [0.06274509803921569, '#48186a'], - [0.12549019607843137, '#472d7b'], [0.18823529411764706, '#424086'], - [0.25098039215686274, '#3b528b'], [0.3137254901960784, '#33638d'], - [0.3764705882352941, '#2c728e'], [0.4392156862745098, '#26828e'], - [0.5019607843137255, '#21918c'], [0.5647058823529412, '#1fa088'], - [0.6274509803921569, '#28ae80'], [0.6901960784313725, '#3fbc73'], - [0.7529411764705882, '#5ec962'], [0.8156862745098039, '#84d44b'], - [0.8784313725490196, '#addc30'], [0.9411764705882353, '#d8e219'], - [1, '#fde725'] - ], - - 'Cividis': [ - [0.000000, 'rgb(0,32,76)'], [0.058824, 'rgb(0,42,102)'], - [0.117647, 'rgb(0,52,110)'], [0.176471, 'rgb(39,63,108)'], - [0.235294, 'rgb(60,74,107)'], [0.294118, 'rgb(76,85,107)'], - [0.352941, 'rgb(91,95,109)'], [0.411765, 'rgb(104,106,112)'], - [0.470588, 'rgb(117,117,117)'], [0.529412, 'rgb(131,129,120)'], - [0.588235, 'rgb(146,140,120)'], [0.647059, 'rgb(161,152,118)'], - [0.705882, 'rgb(176,165,114)'], [0.764706, 'rgb(192,177,109)'], - [0.823529, 'rgb(209,191,102)'], [0.882353, 'rgb(225,204,92)'], - [0.941176, 'rgb(243,219,79)'], [1.000000, 'rgb(255,233,69)'] - ] + get: getScale, + isValid: isValidScale }; -},{}],339:[function(_dereq_,module,exports){ +},{"tinycolor2":283}],334:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51959,7 +52258,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],340:[function(_dereq_,module,exports){ +},{}],335:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51997,7 +52296,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":441}],341:[function(_dereq_,module,exports){ +},{"../../lib":437}],336:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52124,8 +52423,6 @@ dragElement.init = function init(options) { var clampFn = options.clampFn || _clampFn; function onStart(e) { - e.preventDefault(); - // make dragging and dragged into properties of gd // so that others can look at and modify them gd._dragged = false; @@ -52167,11 +52464,15 @@ dragElement.init = function init(options) { document.documentElement.style.cursor = window.getComputedStyle(element).cursor; } - document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onDone); - document.addEventListener('touchmove', onMove); document.addEventListener('touchend', onDone); + if(options.dragmode !== false) { + e.preventDefault(); + document.addEventListener('mousemove', onMove); + document.addEventListener('touchmove', onMove); + } + return; } @@ -52195,13 +52496,15 @@ dragElement.init = function init(options) { } function onDone(e) { - document.removeEventListener('mousemove', onMove); + if(options.dragmode !== false) { + e.preventDefault(); + document.removeEventListener('mousemove', onMove); + document.removeEventListener('touchmove', onMove); + } + document.removeEventListener('mouseup', onDone); - document.removeEventListener('touchmove', onMove); document.removeEventListener('touchend', onDone); - e.preventDefault(); - if(hasHover) { Lib.removeElement(dragCover); } @@ -52294,7 +52597,7 @@ function pointerOffset(e) { ); } -},{"../../constants/interactions":419,"../../lib":441,"../../plots/cartesian/constants":494,"../../registry":532,"./align":339,"./cursor":340,"./unhover":342,"has-hover":200,"has-passive-events":201,"mouse-event-offset":215}],342:[function(_dereq_,module,exports){ +},{"../../constants/interactions":415,"../../lib":437,"../../plots/cartesian/constants":490,"../../registry":528,"./align":334,"./cursor":335,"./unhover":337,"has-hover":200,"has-passive-events":201,"mouse-event-offset":215}],337:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52352,7 +52655,7 @@ unhover.raw = function unhoverRaw(gd, evt) { } }; -},{"../../lib/events":431,"../../lib/get_graph_div":436,"../../lib/throttle":466,"../fx/constants":356}],343:[function(_dereq_,module,exports){ +},{"../../lib/events":428,"../../lib/get_graph_div":433,"../../lib/throttle":462,"../fx/constants":351}],338:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52377,7 +52680,7 @@ exports.dash = { }; -},{}],344:[function(_dereq_,module,exports){ +},{}],339:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -52578,7 +52881,11 @@ drawing.fillGroupStyle = function(s) { s.style('stroke-width', 0) .each(function(d) { var shape = d3.select(this); - shape.call(Color.fill, d[0].trace.fillcolor); + // N.B. 'd' won't be a calcdata item when + // fill !== 'none' on a segment-less and marker-less trace + if(d[0].trace) { + shape.call(Color.fill, d[0].trace.fillcolor); + } }); }; @@ -53019,7 +53326,7 @@ drawing.tryColorscale = function(marker, prefix) { if(scl && Lib.isArrayOrTypedArray(colorArray)) { return Colorscale.makeColorScaleFunc( - Colorscale.extractScale(scl, cont.cmin, cont.cmax) + Colorscale.extractScale(cont, {cLetter: 'c'}) ); } } @@ -53380,32 +53687,28 @@ function nodeHash(node) { node.getAttribute('style'); } -/* - * make a robust clipPath url from a local id - * note! We'd better not be exporting from a page - * with a or the svg will not be portable! +/** + * Set clipPath URL in a way that work for all situations. + * + * In details, graphs on pages with HTML tags need to prepend + * the clip path ids with the page's base url EXCEPT during toImage exports. + * + * @param {d3 selection} s : node to add clip-path attribute + * @param {string} localId : local clip-path (w/o base url) id + * @param {DOM element || object} gd + * - context._baseUrl {string} + * - context._exportedPlot {boolean} */ -drawing.setClipUrl = function(s, localId) { +drawing.setClipUrl = function(s, localId, gd) { if(!localId) { s.attr('clip-path', null); return; } - if(drawing.baseUrl === undefined) { - var base = d3.select('base'); - - // Stash base url once and for all! - // We may have to stash this elsewhere when - // we'll try to support for child windows - // more info -> https://github.com/plotly/plotly.js/issues/702 - if(base.size() && base.attr('href')) { - drawing.baseUrl = window.location.href.split('#')[0]; - } else { - drawing.baseUrl = ''; - } - } + var context = gd._context; + var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - s.attr('clip-path', 'url(' + drawing.baseUrl + '#' + localId + ')'); + s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')'); }; drawing.getTranslate = function(element) { @@ -53537,7 +53840,7 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../constants/alignment":417,"../../constants/interactions":419,"../../constants/xmlns_namespaces":421,"../../lib":441,"../../lib/svg_text_utils":465,"../../registry":532,"../../traces/scatter/make_bubble_size_func":609,"../../traces/scatter/subtypes":616,"../color":319,"../colorscale":334,"./symbol_defs":345,"d3":85,"fast-isnumeric":149,"tinycolor2":284}],345:[function(_dereq_,module,exports){ +},{"../../constants/alignment":413,"../../constants/interactions":415,"../../constants/xmlns_namespaces":417,"../../lib":437,"../../lib/svg_text_utils":461,"../../registry":528,"../../traces/scatter/make_bubble_size_func":604,"../../traces/scatter/subtypes":611,"../color":318,"../colorscale":330,"./symbol_defs":340,"d3":85,"fast-isnumeric":149,"tinycolor2":283}],340:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54025,7 +54328,7 @@ module.exports = { } }; -},{"d3":85}],346:[function(_dereq_,module,exports){ +},{"d3":85}],341:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54140,7 +54443,7 @@ module.exports = { } }; -},{}],347:[function(_dereq_,module,exports){ +},{}],342:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54222,7 +54525,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max); } -},{"../../plots/cartesian/axes":488,"../../registry":532,"./compute_error":348,"fast-isnumeric":149}],348:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":484,"../../registry":528,"./compute_error":343,"fast-isnumeric":149}],343:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54326,7 +54629,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],349:[function(_dereq_,module,exports){ +},{}],344:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54402,7 +54705,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":441,"../../plot_api/plot_template":478,"../../registry":532,"./attributes":346,"fast-isnumeric":149}],350:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plot_api/plot_template":474,"../../registry":528,"./attributes":341,"fast-isnumeric":149}],345:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54471,7 +54774,7 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":441,"../../plot_api/edit_types":471,"./attributes":346,"./calc":347,"./compute_error":348,"./defaults":349,"./plot":351,"./style":352}],351:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plot_api/edit_types":467,"./attributes":341,"./calc":342,"./compute_error":343,"./defaults":344,"./plot":346,"./style":347}],346:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54489,7 +54792,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); var subTypes = _dereq_('../../traces/scatter/subtypes'); -module.exports = function plot(traces, plotinfo, transitionOpts) { +module.exports = function plot(gd, traces, plotinfo, transitionOpts) { var isNew; var xa = plotinfo.xaxis; @@ -54540,7 +54843,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { .style('opacity', 1); } - Drawing.setClipUrl(errorbars, plotinfo.layerClipId); + Drawing.setClipUrl(errorbars, plotinfo.layerClipId, gd); errorbars.each(function(d) { var errorbar = d3.select(this); @@ -54645,7 +54948,7 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":616,"../drawing":344,"d3":85,"fast-isnumeric":149}],352:[function(_dereq_,module,exports){ +},{"../../traces/scatter/subtypes":611,"../drawing":339,"d3":85,"fast-isnumeric":149}],347:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54682,7 +54985,7 @@ module.exports = function style(traces) { }); }; -},{"../color":319,"d3":85}],353:[function(_dereq_,module,exports){ +},{"../color":318,"d3":85}],348:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54728,7 +55031,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":515}],354:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":511}],349:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54765,6 +55068,8 @@ module.exports = function calc(gd) { fillFn(trace.hoverinfo, cd, 'hi', makeCoerceHoverInfo(trace)); + if(trace.hovertemplate) fillFn(trace.hovertemplate, cd, 'ht'); + if(!trace.hoverlabel) continue; fillFn(trace.hoverlabel.bgcolor, cd, 'hbg'); @@ -54784,7 +55089,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":441,"../../registry":532}],355:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528}],350:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54822,7 +55127,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":532,"./hover":359}],356:[function(_dereq_,module,exports){ +},{"../../registry":528,"./hover":354}],351:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54854,7 +55159,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],357:[function(_dereq_,module,exports){ +},{}],352:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54877,7 +55182,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, layout.hoverlabel); }; -},{"../../lib":441,"./attributes":353,"./hoverlabel_defaults":360}],358:[function(_dereq_,module,exports){ +},{"../../lib":437,"./attributes":348,"./hoverlabel_defaults":355}],353:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55120,7 +55425,7 @@ function getPointData(val, pointNumber) { } } -},{"../../lib":441}],359:[function(_dereq_,module,exports){ +},{"../../lib":437}],354:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55249,13 +55554,17 @@ exports.loneHover = function loneHover(hoverItem, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; var container3 = d3.select(opts.container); @@ -55269,7 +55578,6 @@ exports.loneHover = function loneHover(hoverItem, opts) { container: container3, outerContainer: outerContainer3 }; - var hoverLabel = createHoverText([pointData], fullOpts, opts.gd); alignHoverText(hoverLabel, fullOpts.rotateLabels); @@ -55303,13 +55611,17 @@ exports.multiHovers = function multiHovers(hoverItems, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; }); @@ -55785,7 +56097,14 @@ function _hover(gd, evt, subplot, noHoverEvent) { // other people and send it to the event for(itemnum = 0; itemnum < hoverData.length; itemnum++) { var pt = hoverData[itemnum]; - newhoverdata.push(helpers.makeEventData(pt, pt.trace, pt.cd)); + var eventData = helpers.makeEventData(pt, pt.trace, pt.cd); + + var ht = false; + if(pt.cd[pt.index] && pt.cd[pt.index].ht) ht = pt.cd[pt.index].ht; + hoverData[itemnum].hovertemplate = ht || pt.trace.hovertemplate || false; + hoverData[itemnum].eventData = [eventData]; + + newhoverdata.push(eventData); } gd._hoverdata = newhoverdata; @@ -55843,6 +56162,8 @@ function _hover(gd, evt, subplot, noHoverEvent) { }); } +var EXTRA_STRING_REGEX = /([\s\S]*)<\/extra>/; + function createHoverText(hoverData, opts, gd) { var hovermode = opts.hovermode; var rotateLabels = opts.rotateLabels; @@ -55886,11 +56207,13 @@ function createHoverText(hoverData, opts, gd) { if(allHaveZ && hoverData[i].zLabel === undefined) allHaveZ = false; traceHoverinfo = hoverData[i].hoverinfo || hoverData[i].trace.hoverinfo; - var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); - if(parts.indexOf('all') === -1 && - parts.indexOf(hovermode) === -1) { - showCommonLabel = false; - break; + if(traceHoverinfo) { + var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); + if(parts.indexOf('all') === -1 && + parts.indexOf(hovermode) === -1) { + showCommonLabel = false; + break; + } } } @@ -56073,6 +56396,19 @@ function createHoverText(hoverData, opts, gd) { text = name; } + // hovertemplate + var hovertemplate = d.hovertemplate || false; + var hovertemplateLabels = d.hovertemplateLabels || d; + var eventData = d.eventData[0] || {}; + if(hovertemplate) { + text = Lib.hovertemplateString(hovertemplate, hovertemplateLabels, eventData); + + text = text.replace(EXTRA_STRING_REGEX, function(match, extra) { + name = extra; // Assign name for secondary text label + return ''; // Remove from main text label + }); + } + // main label var tx = g.select('text.nums') .call(Drawing.font, @@ -56471,7 +56807,7 @@ function cleanPoint(d, hovermode) { var infomode = d.hoverinfo || d.trace.hoverinfo; - if(infomode !== 'all') { + if(infomode && infomode !== 'all') { infomode = Array.isArray(infomode) ? infomode : infomode.split('+'); if(infomode.indexOf('x') === -1) d.xLabel = undefined; if(infomode.indexOf('y') === -1) d.yLabel = undefined; @@ -56657,8 +56993,11 @@ function hoverChanged(gd, evt, oldhoverdata) { for(var i = oldhoverdata.length - 1; i >= 0; i--) { var oldPt = oldhoverdata[i]; var newPt = gd._hoverdata[i]; + if(oldPt.curveNumber !== newPt.curveNumber || - String(oldPt.pointNumber) !== String(newPt.pointNumber)) { + String(oldPt.pointNumber) !== String(newPt.pointNumber) || + String(oldPt.pointNumbers) !== String(newPt.pointNumbers) + ) { return true; } } @@ -56674,7 +57013,7 @@ function spikesChanged(gd, oldspikepoints) { return false; } -},{"../../lib":441,"../../lib/events":431,"../../lib/override_cursor":452,"../../lib/svg_text_utils":465,"../../plots/cartesian/axes":488,"../../registry":532,"../color":319,"../dragelement":341,"../drawing":344,"./constants":356,"./helpers":358,"d3":85,"fast-isnumeric":149,"tinycolor2":284}],360:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../lib/events":428,"../../lib/override_cursor":448,"../../lib/svg_text_utils":461,"../../plots/cartesian/axes":484,"../../registry":528,"../color":318,"../dragelement":336,"../drawing":339,"./constants":351,"./helpers":353,"d3":85,"fast-isnumeric":149,"tinycolor2":283}],355:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56696,7 +57035,49 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts Lib.coerceFont(coerce, 'hoverlabel.font', opts.font); }; -},{"../../lib":441}],361:[function(_dereq_,module,exports){ +},{"../../lib":437}],356:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function(opts, extra) { + opts = opts || {}; + extra = extra || {}; + + var descPart = extra.description ? ' ' + extra.description : ''; + var keys = extra.keys || []; + if(keys.length > 0) { + var quotedKeys = []; + for(var i = 0; i < keys.length; i++) { + quotedKeys[i] = '`' + keys[i] + '`'; + } + descPart = descPart + 'Finally, the template string has access to '; + if(keys.length === 1) { + descPart = 'variable ' + quotedKeys[0]; + } else { + descPart = 'variables ' + quotedKeys.slice(0, -1).join(', ') + ' and ' + quotedKeys.slice(-1) + '.'; + } + } + + var hovertemplate = { + valType: 'string', + + dflt: '', + arrayOk: true, + editType: 'none', + + }; + + return hovertemplate; +}; + +},{}],357:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56776,7 +57157,7 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":441,"../dragelement":341,"./attributes":353,"./calc":354,"./click":355,"./constants":356,"./defaults":357,"./helpers":358,"./hover":359,"./layout_attributes":362,"./layout_defaults":363,"./layout_global_defaults":364,"d3":85}],362:[function(_dereq_,module,exports){ +},{"../../lib":437,"../dragelement":336,"./attributes":348,"./calc":349,"./click":350,"./constants":351,"./defaults":352,"./helpers":353,"./hover":354,"./layout_attributes":358,"./layout_defaults":359,"./layout_global_defaults":360,"d3":85}],358:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56809,7 +57190,7 @@ module.exports = { dragmode: { valType: 'enumerated', - values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'], + values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable', false], dflt: 'zoom', editType: 'modebar', @@ -56871,7 +57252,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":515,"./constants":356}],363:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":511,"./constants":351}],359:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56944,7 +57325,7 @@ function isHoriz(fullData) { return out; } -},{"../../lib":441,"./layout_attributes":362}],364:[function(_dereq_,module,exports){ +},{"../../lib":437,"./layout_attributes":358}],360:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56967,7 +57348,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":441,"./hoverlabel_defaults":360,"./layout_attributes":362}],365:[function(_dereq_,module,exports){ +},{"../../lib":437,"./hoverlabel_defaults":355,"./layout_attributes":358}],361:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57352,7 +57733,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":441,"../../lib/regex":457,"../../plot_api/plot_template":478,"../../plots/cartesian/constants":494,"../../plots/domain":514}],366:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../lib/regex":453,"../../plot_api/plot_template":474,"../../plots/cartesian/constants":490,"../../plots/domain":510}],362:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57487,7 +57868,7 @@ module.exports = templatedArray('image', { editType: 'arraydraw' }); -},{"../../plot_api/plot_template":478,"../../plots/cartesian/constants":494}],367:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":474,"../../plots/cartesian/constants":490}],363:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57570,7 +57951,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":467,"fast-isnumeric":149}],368:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":463,"fast-isnumeric":149}],364:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57631,7 +58012,7 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":441,"../../plots/array_container_defaults":484,"../../plots/cartesian/axes":488,"./attributes":366}],369:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/array_container_defaults":480,"../../plots/cartesian/axes":484,"./attributes":362}],365:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57802,9 +58183,10 @@ module.exports = function draw(gd) { yId = ya ? ya._id : '', clipAxes = xId + yId; - thisImage.call(Drawing.setClipUrl, clipAxes ? - ('clip' + fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + thisImage, + clipAxes ? ('clip' + fullLayout._uid + clipAxes) : null, + gd ); } @@ -57852,7 +58234,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":421,"../../plots/cartesian/axes":488,"../drawing":344,"d3":85}],370:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":417,"../../plots/cartesian/axes":484,"../drawing":339,"d3":85}],366:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57876,56 +58258,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":499,"./attributes":366,"./convert_coords":367,"./defaults":368,"./draw":369}],371:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - - -/** - * Determine the position anchor property of x/y xanchor/yanchor components. - * - * - values < 1/3 align the low side at that fraction, - * - values [1/3, 2/3] align the center at that fraction, - * - values > 2/3 align the right at that fraction. - */ - -exports.isRightAnchor = function isRightAnchor(opts) { - return ( - opts.xanchor === 'right' || - (opts.xanchor === 'auto' && opts.x >= 2 / 3) - ); -}; - -exports.isCenterAnchor = function isCenterAnchor(opts) { - return ( - opts.xanchor === 'center' || - (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) - ); -}; - -exports.isBottomAnchor = function isBottomAnchor(opts) { - return ( - opts.yanchor === 'bottom' || - (opts.yanchor === 'auto' && opts.y <= 1 / 3) - ); -}; - -exports.isMiddleAnchor = function isMiddleAnchor(opts) { - return ( - opts.yanchor === 'middle' || - (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) - ); -}; - -},{}],372:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":495,"./attributes":362,"./convert_coords":363,"./defaults":364,"./draw":365}],367:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58023,11 +58356,25 @@ module.exports = { editType: 'legend', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + valign: { + valType: 'enumerated', + values: ['top', 'middle', 'bottom'], + dflt: 'middle', + + editType: 'legend', + }, editType: 'legend' }; -},{"../../plots/font_attributes":515,"../color/attributes":318}],373:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":511,"../color/attributes":317}],368:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58046,7 +58393,7 @@ module.exports = { textOffsetX: 40 }; -},{}],374:[function(_dereq_,module,exports){ +},{}],369:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58115,7 +58462,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { basePlotLayoutAttributes, 'showlegend', legendReallyHasATrace && legendTraceCount > 1); - if(showLegend === false) return; + if(showLegend === false && !containerIn.uirevision) return; var containerOut = Template.newContainer(layoutOut, 'legend'); @@ -58123,6 +58470,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); } + coerce('uirevision', layoutOut.uirevision); + + if(showLegend === false) return; + coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); @@ -58131,7 +58482,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('orientation'); if(containerOut.orientation === 'h') { var xaxis = layoutIn.xaxis; - if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { + if(Registry.getComponentMethod('rangeslider', 'isVisible')(xaxis)) { defaultX = 0; defaultXAnchor = 'left'; defaultY = 1.1; @@ -58152,10 +58503,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('xanchor', defaultXAnchor); coerce('y', defaultY); coerce('yanchor', defaultYAnchor); + coerce('valign'); Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); }; -},{"../../lib":441,"../../plot_api/plot_template":478,"../../plots/layout_attributes":523,"../../registry":532,"./attributes":372,"./helpers":378}],375:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plot_api/plot_template":474,"../../plots/layout_attributes":519,"../../registry":528,"./attributes":367,"./helpers":373}],370:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58188,7 +58540,6 @@ var FROM_BR = alignmentConstants.FROM_BR; var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); -var anchorUtils = _dereq_('./anchor_utils'); var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; @@ -58312,17 +58663,17 @@ module.exports = function draw(gd) { lx = gs.l + gs.w * opts.x, ly = gs.t + gs.h * (1 - opts.y); - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= opts._width; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= opts._height; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -58382,7 +58733,7 @@ module.exports = function draw(gd) { y: opts.borderwidth }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; @@ -58420,7 +58771,7 @@ module.exports = function draw(gd) { y: opts.borderwidth + scrollBoxY }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -58497,7 +58848,7 @@ module.exports = function draw(gd) { }, doneFn: function() { if(xf !== undefined && yf !== undefined) { - Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf}); + Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf}); } }, clickFn: function(numClicks, e) { @@ -58604,7 +58955,7 @@ function drawTexts(g, gd, maxLength) { update.name = newName; } - return Registry.call('restyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, traceIndex); }); } else { textLayout(textEl); @@ -58694,6 +59045,7 @@ function computeTextDimensions(g, gd) { // to avoid getBoundingClientRect var textY = lineHeight * (0.3 + (1 - textLines) / 2); svgTextUtils.positionText(text, constants.textOffsetX, textY); + legendItem.lineHeight = lineHeight; } height = Math.max(height, 16) + 3; @@ -58857,18 +59209,18 @@ function expandMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -58888,10 +59240,10 @@ function expandHorizontalMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } @@ -58906,7 +59258,7 @@ function expandHorizontalMargin(gd) { }); } -},{"../../constants/alignment":417,"../../constants/interactions":419,"../../lib":441,"../../lib/events":431,"../../lib/svg_text_utils":465,"../../plots/plots":525,"../../registry":532,"../color":319,"../dragelement":341,"../drawing":344,"./anchor_utils":371,"./constants":373,"./get_legend_data":376,"./handle_click":377,"./helpers":378,"./style":380,"d3":85}],376:[function(_dereq_,module,exports){ +},{"../../constants/alignment":413,"../../constants/interactions":415,"../../lib":437,"../../lib/events":428,"../../lib/svg_text_utils":461,"../../plots/plots":521,"../../registry":528,"../color":318,"../dragelement":336,"../drawing":339,"./constants":368,"./get_legend_data":371,"./handle_click":372,"./helpers":373,"./style":375,"d3":85}],371:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59012,7 +59364,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":532,"./helpers":378}],377:[function(_dereq_,module,exports){ +},{"../../registry":528,"./helpers":373}],372:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59126,7 +59478,7 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices); + Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices); } else { var hasLegendgroup = legendgroup && legendgroup.length; var traceIndicesInGroup = []; @@ -59232,11 +59584,11 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', gd, attrUpdate, attrIndices); + Registry.call('_guiRestyle', gd, attrUpdate, attrIndices); } }; -},{"../../lib":441,"../../registry":532}],378:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528}],373:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59260,7 +59612,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],379:[function(_dereq_,module,exports){ +},{}],374:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59284,7 +59636,7 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":372,"./defaults":374,"./draw":375,"./style":380}],380:[function(_dereq_,module,exports){ +},{"./attributes":367,"./defaults":369,"./draw":370,"./style":375}],375:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59312,6 +59664,19 @@ module.exports = function style(s, gd) { var layers = Lib.ensureSingle(traceGroup, 'g', 'layers'); layers.style('opacity', d[0].trace.opacity); + // Marker vertical alignment + var valign = gd._fullLayout.legend.valign; + var lineHeight = d[0].lineHeight; + var height = d[0].height; + + if(valign === 'middle' || !lineHeight || !height) { + layers.attr('transform', null); // this here is a fun d3 trick to unset DOM attributes + } else { + var factor = {top: 1, bottom: -1}[valign]; + var markerOffsetY = factor * (0.5 * (lineHeight - height + 3)); + layers.attr('transform', 'translate(0,' + markerOffsetY + ')'); + } + var fill = layers .selectAll('g.legendfill') .data([d]); @@ -59631,7 +59996,7 @@ module.exports = function style(s, gd) { } }; -},{"../../lib":441,"../../registry":532,"../../traces/pie/style_one":586,"../../traces/scatter/subtypes":616,"../color":319,"../drawing":344,"d3":85}],381:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528,"../../traces/pie/style_one":581,"../../traces/scatter/subtypes":611,"../color":318,"../drawing":339,"d3":85}],376:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59895,7 +60260,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -59951,7 +60316,7 @@ function handleDrag3d(gd, ev) { var val2d = (val === 'pan') ? val : 'zoom'; layoutUpdate.dragmode = val2d; - Registry.call('relayout', gd, layoutUpdate); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.resetCameraDefault3d = { @@ -59990,7 +60355,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -60004,54 +60369,48 @@ modeBarButtons.hoverClosest3d = { click: handleHover3d }; -function handleHover3d(gd, ev) { +function getNextHover3d(gd, ev) { var button = ev.currentTarget; - var val = button._previousVal || false; - var layout = gd.layout; + var val = button._previousVal; var fullLayout = gd._fullLayout; var sceneIds = fullLayout._subplots.gl3d; var axes = ['xaxis', 'yaxis', 'zaxis']; - var spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor']; // initialize 'current spike' object to be stored in the DOM var currentSpikes = {}; - var axisSpikes = {}; var layoutUpdate = {}; if(val) { - layoutUpdate = Lib.extendDeep(layout, val); + layoutUpdate = val; button._previousVal = null; } else { - layoutUpdate = { - 'allaxes.showspikes': false - }; - for(var i = 0; i < sceneIds.length; i++) { - var sceneId = sceneIds[i], - sceneLayout = fullLayout[sceneId], - sceneSpikes = currentSpikes[sceneId] = {}; + var sceneId = sceneIds[i]; + var sceneLayout = fullLayout[sceneId]; - sceneSpikes.hovermode = sceneLayout.hovermode; - layoutUpdate[sceneId + '.hovermode'] = false; + var hovermodeAStr = sceneId + '.hovermode'; + currentSpikes[hovermodeAStr] = sceneLayout.hovermode; + layoutUpdate[hovermodeAStr] = false; // copy all the current spike attrs for(var j = 0; j < 3; j++) { var axis = axes[j]; - axisSpikes = sceneSpikes[axis] = {}; - - for(var k = 0; k < spikeAttrs.length; k++) { - var spikeAttr = spikeAttrs[k]; - axisSpikes[spikeAttr] = sceneLayout[axis][spikeAttr]; - } + var spikeAStr = sceneId + '.' + axis + '.showspikes'; + layoutUpdate[spikeAStr] = false; + currentSpikes[spikeAStr] = sceneLayout[axis].showspikes; } } - button._previousVal = Lib.extendDeep({}, currentSpikes); + button._previousVal = currentSpikes; } + return layoutUpdate; +} - Registry.call('relayout', gd, layoutUpdate); +function handleHover3d(gd, ev) { + var layoutUpdate = getNextHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.zoomInGeo = { @@ -60107,7 +60466,7 @@ function handleGeo(gd, ev) { var scale = geoLayout.projection.scale; var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; - Registry.call('relayout', gd, id + '.projection.scale', newScale); + Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); } else if(attr === 'reset') { resetView(gd, 'geo'); } @@ -60135,18 +60494,20 @@ modeBarButtons.hoverClosestPie = { click: toggleHover }; -function toggleHover(gd) { +function getNextHover(gd) { var fullLayout = gd._fullLayout; - var onHoverVal; + if(fullLayout.hovermode) return false; + if(fullLayout._has('cartesian')) { - onHoverVal = fullLayout._isHoriz ? 'y' : 'x'; + return fullLayout._isHoriz ? 'y' : 'x'; } - else onHoverVal = 'closest'; - - var newHover = gd._fullLayout.hovermode ? false : onHoverVal; + return 'closest'; +} - Registry.call('relayout', gd, 'hovermode', newHover); +function toggleHover(gd) { + var newHover = getNextHover(gd); + Registry.call('_guiRelayout', gd, 'hovermode', newHover); } // buttons when more then one plot types are present @@ -60160,12 +60521,10 @@ modeBarButtons.toggleHover = { icon: Icons.tooltip_basic, gravity: 'ne', click: function(gd, ev) { - toggleHover(gd); + var layoutUpdate = getNextHover3d(gd, ev); + layoutUpdate.hovermode = getNextHover(gd); - // the 3d hovermode update must come - // last so that layout.hovermode update does not - // override scene?.hovermode?.layout. - handleHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } }; @@ -60201,7 +60560,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } }; @@ -60248,10 +60607,10 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', gd, aObj); + Registry.call('_guiRelayout', gd, aObj); } -},{"../../../build/ploticon":2,"../../lib":441,"../../plots/cartesian/axis_ids":491,"../../plots/plots":525,"../../registry":532}],382:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":437,"../../plots/cartesian/axis_ids":487,"../../plots/plots":521,"../../registry":528}],377:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60265,7 +60624,7 @@ function resetView(gd, subplotType) { exports.manage = _dereq_('./manage'); -},{"./manage":383}],383:[function(_dereq_,module,exports){ +},{"./manage":378}],378:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60297,7 +60656,7 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar) { + if(!context.displayModeBar && !context.watermark) { if(modeBar) { modeBar.destroy(); delete fullLayout._modeBar; @@ -60325,11 +60684,15 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); } + else if(!context.displayModeBar && context.watermark) { + buttonGroups = []; + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, - context.modeBarButtonsToAdd + context.modeBarButtonsToAdd, + context.showSendToCloud ); } @@ -60338,7 +60701,7 @@ module.exports = function manageModeBar(gd) { }; // logic behind which buttons are displayed by default -function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { +function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; @@ -60369,7 +60732,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { } // buttons common to all plot types - addGroup(['toImage', 'sendDataToCloud']); + var commonGroup = ['toImage']; + if(showSendToCloud) commonGroup.push('sendDataToCloud'); + addGroup(commonGroup); var zoomGroup = []; var hoverGroup = []; @@ -60520,7 +60885,7 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":491,"../../registry":532,"../../traces/scatter/subtypes":616,"./buttons":381,"./modebar":384}],384:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axis_ids":487,"../../registry":528,"../../traces/scatter/subtypes":611,"./buttons":376,"./modebar":379}],379:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60603,11 +60968,16 @@ proto.update = function(graphInfo, buttons) { this.updateButtons(buttons); - if(context.displaylogo) { + if(context.watermark || context.displaylogo) { + var logoGroup = this.getLogo(); + if(context.watermark) { + logoGroup.className = logoGroup.className + ' watermark'; + } + if(fullLayout.modebar.orientation === 'v') { - this.element.prepend(this.getLogo()); + this.element.prepend(logoGroup); } else { - this.element.appendChild(this.getLogo()); + this.element.appendChild(logoGroup); } this.hasLogo = true; @@ -60866,7 +61236,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../../build/ploticon":2,"../../lib":441,"d3":85,"fast-isnumeric":149}],385:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":437,"d3":85,"fast-isnumeric":149}],380:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61002,7 +61372,7 @@ module.exports = { editType: 'plot' }; -},{"../../plot_api/plot_template":478,"../../plots/font_attributes":515,"../color/attributes":318}],386:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":474,"../../plots/font_attributes":511,"../color/attributes":317}],381:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61031,7 +61401,7 @@ module.exports = { darkAmount: 10 }; -},{}],387:[function(_dereq_,module,exports){ +},{}],382:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61124,7 +61494,7 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":441,"../../plot_api/plot_template":478,"../../plots/array_container_defaults":484,"../color":319,"./attributes":385,"./constants":386}],388:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plot_api/plot_template":474,"../../plots/array_container_defaults":480,"../color":318,"./attributes":380,"./constants":381}],383:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61144,7 +61514,6 @@ var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var alignmentConstants = _dereq_('../../constants/alignment'); var LINE_SPACING = alignmentConstants.LINE_SPACING; @@ -61196,7 +61565,7 @@ module.exports = function draw(gd) { button.on('click', function() { if(gd._dragged) return; - Registry.call('relayout', gd, update); + Registry.call('_guiRelayout', gd, update); }); button.on('mouseover', function() { @@ -61345,21 +61714,21 @@ function reposition(gd, buttons, opts, axName, selector) { var ly = graphSize.t + graphSize.h * (1 - opts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= width; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(opts)) { + if(Lib.isCenterAnchor(opts)) { lx -= width / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(opts)) { + if(Lib.isMiddleAnchor(opts)) { ly -= height / 2; yanchor = 'middle'; } @@ -61381,7 +61750,7 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', 'translate(' + lx + ',' + ly + ')'); } -},{"../../constants/alignment":417,"../../lib":441,"../../lib/svg_text_utils":465,"../../plots/cartesian/axis_ids":491,"../../plots/plots":525,"../../registry":532,"../color":319,"../drawing":344,"../legend/anchor_utils":371,"./constants":386,"./get_update_object":389,"d3":85}],389:[function(_dereq_,module,exports){ +},{"../../constants/alignment":413,"../../lib":437,"../../lib/svg_text_utils":461,"../../plots/cartesian/axis_ids":487,"../../plots/plots":521,"../../registry":528,"../color":318,"../drawing":339,"./constants":381,"./get_update_object":384,"d3":85}],384:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61438,7 +61807,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":85}],390:[function(_dereq_,module,exports){ +},{"d3":85}],385:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61465,7 +61834,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":385,"./defaults":387,"./draw":388}],391:[function(_dereq_,module,exports){ +},{"./attributes":380,"./defaults":382,"./draw":383}],386:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61539,7 +61908,7 @@ module.exports = { editType: 'calc' }; -},{"../color/attributes":318}],392:[function(_dereq_,module,exports){ +},{"../color/attributes":317}],387:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61573,7 +61942,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":487,"../../plots/cartesian/axis_ids":491,"./constants":393}],393:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/autorange":483,"../../plots/cartesian/axis_ids":487,"./constants":388}],388:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61629,7 +61998,7 @@ module.exports = { extraPad: 15 }; -},{}],394:[function(_dereq_,module,exports){ +},{}],389:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61715,7 +62084,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":441,"../../plot_api/plot_template":478,"../../plots/cartesian/axis_ids":491,"./attributes":391,"./oppaxis_attributes":397}],395:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plot_api/plot_template":474,"../../plots/cartesian/axis_ids":487,"./attributes":386,"./oppaxis_attributes":393}],390:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61737,7 +62106,7 @@ var Color = _dereq_('../color'); var Titles = _dereq_('../titles'); var Cartesian = _dereq_('../../plots/cartesian'); -var Axes = _dereq_('../../plots/cartesian/axes'); +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); var dragElement = _dereq_('../dragelement'); var setCursor = _dereq_('../../lib/setcursor'); @@ -61745,8 +62114,13 @@ var setCursor = _dereq_('../../lib/setcursor'); var constants = _dereq_('./constants'); module.exports = function(gd) { - var fullLayout = gd._fullLayout, - rangeSliderData = makeRangeSliderData(fullLayout); + var fullLayout = gd._fullLayout; + var rangeSliderData = fullLayout._rangeSliderData; + for(var i = 0; i < rangeSliderData.length; i++) { + var opts = rangeSliderData[i][constants.name]; + // fullLayout._uid may not exist when we call makeData + opts._clipId = opts._id + '-' + fullLayout._uid; + } /* * @@ -61773,10 +62147,6 @@ module.exports = function(gd) { .selectAll('g.' + constants.containerClassName) .data(rangeSliderData, keyFunction); - rangeSliders.enter().append('g') - .classed(constants.containerClassName, true) - .attr('pointer-events', 'all'); - // remove exiting sliders and their corresponding clip paths rangeSliders.exit().each(function(axisOpts) { var opts = axisOpts[constants.name]; @@ -61786,48 +62156,51 @@ module.exports = function(gd) { // return early if no range slider is visible if(rangeSliderData.length === 0) return; + rangeSliders.enter().append('g') + .classed(constants.containerClassName, true) + .attr('pointer-events', 'all'); + // for all present range sliders rangeSliders.each(function(axisOpts) { - var rangeSlider = d3.select(this), - opts = axisOpts[constants.name], - oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)], - oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)]; + var rangeSlider = d3.select(this); + var opts = axisOpts[constants.name]; + var oppAxisOpts = fullLayout[axisIDs.id2name(axisOpts.anchor)]; + var oppAxisRangeOpts = opts[axisIDs.id2name(axisOpts.anchor)]; // update range // Expand slider range to the axis range - // TODO: what if the ranges are reversed? if(opts.range) { - var outRange = opts.range; - var axRange = axisOpts.range; + var rng = Lib.simpleMap(opts.range, axisOpts.r2l); + var axRng = Lib.simpleMap(axisOpts.range, axisOpts.r2l); + var newRng; + + if(axRng[0] < axRng[1]) { + newRng = [ + Math.min(rng[0], axRng[0]), + Math.max(rng[1], axRng[1]) + ]; + } else { + newRng = [ + Math.max(rng[0], axRng[0]), + Math.min(rng[1], axRng[1]) + ]; + } - outRange[0] = axisOpts.l2r(Math.min(axisOpts.r2l(outRange[0]), axisOpts.r2l(axRange[0]))); - outRange[1] = axisOpts.l2r(Math.max(axisOpts.r2l(outRange[1]), axisOpts.r2l(axRange[1]))); - opts._input.range = outRange.slice(); + opts.range = opts._input.range = Lib.simpleMap(newRng, axisOpts.l2r); } axisOpts.cleanRange('rangeslider.range'); - // update range slider dimensions var margin = fullLayout.margin; var graphSize = fullLayout._size; var domain = axisOpts.domain; - var tickHeight = (axisOpts._boundingBox || {}).height || 0; - - var oppBottom = Infinity; - var subplotData = Axes.getSubplots(gd, axisOpts); - for(var i = 0; i < subplotData.length; i++) { - var oppAxis = Axes.getFromId(gd, subplotData[i].substr(subplotData[i].indexOf('y'))); - oppBottom = Math.min(oppBottom, oppAxis.domain[0]); - } + var tickHeight = opts._tickHeight; - opts._id = constants.name + axisOpts._id; - opts._clipId = opts._id + '-' + fullLayout._uid; + var oppBottom = opts._oppBottom; opts._width = graphSize.w * (domain[1] - domain[0]); - opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; - opts._offsetShift = Math.floor(opts.borderwidth / 2); var x = Math.round(margin.l + (graphSize.w * domain[0])); @@ -61890,41 +62263,14 @@ module.exports = function(gd) { placeholder: fullLayout._dfltTitle.x, attributes: { x: axisOpts._offset + axisOpts._length / 2, - y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size, + y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.title.font.size, 'text-anchor': 'middle' } }); } - - // update margins - Plots.autoMargin(gd, opts._id, { - x: domain[0], - y: oppBottom, - l: 0, - r: 0, - t: 0, - b: opts._height + margin.b + tickHeight, - pad: constants.extraPad + opts._offsetShift * 2 - }); }); }; -function makeRangeSliderData(fullLayout) { - var axes = Axes.list({ _fullLayout: fullLayout }, 'x', true), - name = constants.name, - out = []; - - if(fullLayout._has('gl2d')) return out; - - for(var i = 0; i < axes.length; i++) { - var ax = axes[i]; - - if(ax[name] && ax[name].visible) out.push(ax); - } - - return out; -} - function setupDragElement(rangeSlider, gd, axisOpts, opts) { var slideBox = rangeSlider.select('rect.' + constants.slideBoxClassName).node(), grabAreaMin = rangeSlider.select('rect.' + constants.grabAreaMinClassName).node(), @@ -62004,7 +62350,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) { dataMax = clamp(opts.p2d(opts._pixelMax)); window.requestAnimationFrame(function() { - Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); + Registry.call('_guiRelayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); }); } @@ -62111,15 +62457,14 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) { } function drawRangePlot(rangeSlider, gd, axisOpts, opts) { - var subplotData = Axes.getSubplots(gd, axisOpts), - calcData = gd.calcdata; + var calcData = gd.calcdata; var rangePlots = rangeSlider.selectAll('g.' + constants.rangePlotClassName) - .data(subplotData, Lib.identity); + .data(axisOpts._subplotsWith, Lib.identity); rangePlots.enter().append('g') .attr('class', function(id) { return constants.rangePlotClassName + ' ' + id; }) - .call(Drawing.setClipUrl, opts._clipId); + .call(Drawing.setClipUrl, opts._clipId, gd); rangePlots.order(); @@ -62131,7 +62476,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var plotgroup = d3.select(this), isMainPlot = (i === 0); - var oppAxisOpts = Axes.getFromId(gd, id, 'y'), + var oppAxisOpts = axisIDs.getFromId(gd, id, 'y'), oppAxisName = oppAxisOpts._name, oppAxisRangeOpts = opts[oppAxisName]; @@ -62163,6 +62508,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var xa = mockFigure._fullLayout.xaxis; var ya = mockFigure._fullLayout[oppAxisName]; + xa.clearCalc(); + xa.setScale(); + ya.clearCalc(); + ya.setScale(); + var plotinfo = { id: id, plotgroup: plotgroup, @@ -62315,7 +62665,77 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":441,"../../lib/setcursor":461,"../../plots/cartesian":500,"../../plots/cartesian/axes":488,"../../plots/plots":525,"../../registry":532,"../color":319,"../dragelement":341,"../drawing":344,"../titles":410,"./constants":393,"d3":85}],396:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../lib/setcursor":457,"../../plots/cartesian":496,"../../plots/cartesian/axis_ids":487,"../../plots/plots":521,"../../registry":528,"../color":318,"../dragelement":336,"../drawing":339,"../titles":406,"./constants":388,"d3":85}],391:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); +var constants = _dereq_('./constants'); +var name = constants.name; + +function isVisible(ax) { + var rangeSlider = ax && ax[name]; + return rangeSlider && rangeSlider.visible; +} +exports.isVisible = isVisible; + +exports.makeData = function(fullLayout) { + var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true); + var margin = fullLayout.margin; + var rangeSliderData = []; + + if(!fullLayout._has('gl2d')) { + for(var i = 0; i < axes.length; i++) { + var ax = axes[i]; + + if(isVisible(ax)) { + rangeSliderData.push(ax); + + var opts = ax[name]; + opts._id = name + ax._id; + opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; + opts._offsetShift = Math.floor(opts.borderwidth / 2); + } + } + } + + fullLayout._rangeSliderData = rangeSliderData; +}; + +exports.autoMarginOpts = function(gd, ax) { + var opts = ax[name]; + + var oppBottom = Infinity; + var counterAxes = ax._counterAxes; + for(var j = 0; j < counterAxes.length; j++) { + var counterId = counterAxes[j]; + var oppAxis = axisIDs.getFromId(gd, counterId); + oppBottom = Math.min(oppBottom, oppAxis.domain[0]); + } + opts._oppBottom = oppBottom; + + var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0; + opts._tickHeight = tickHeight; + + return { + x: 0, + y: oppBottom, + l: 0, + r: 0, + t: 0, + b: opts._height + gd._fullLayout.margin.b + tickHeight, + pad: constants.extraPad + opts._offsetShift * 2 + }; +}; + +},{"../../plots/cartesian/axis_ids":487,"./constants":388}],392:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62329,6 +62749,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { var Lib = _dereq_('../../lib'); var attrs = _dereq_('./attributes'); var oppAxisAttrs = _dereq_('./oppaxis_attributes'); +var helpers = _dereq_('./helpers'); module.exports = { moduleType: 'component', @@ -62347,10 +62768,13 @@ module.exports = { layoutAttributes: _dereq_('./attributes'), handleDefaults: _dereq_('./defaults'), calcAutorange: _dereq_('./calc_autorange'), - draw: _dereq_('./draw') + draw: _dereq_('./draw'), + isVisible: helpers.isVisible, + makeData: helpers.makeData, + autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":441,"./attributes":391,"./calc_autorange":392,"./defaults":394,"./draw":395,"./oppaxis_attributes":397}],397:[function(_dereq_,module,exports){ +},{"../../lib":437,"./attributes":386,"./calc_autorange":387,"./defaults":389,"./draw":390,"./helpers":391,"./oppaxis_attributes":393}],393:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62388,7 +62812,7 @@ module.exports = { editType: 'calc' }; -},{}],398:[function(_dereq_,module,exports){ +},{}],394:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62524,7 +62948,7 @@ module.exports = templatedArray('shape', { editType: 'arraydraw' }); -},{"../../lib/extend":432,"../../plot_api/plot_template":478,"../../traces/scatter/attributes":592,"../annotations/attributes":304,"../drawing/attributes":343}],399:[function(_dereq_,module,exports){ +},{"../../lib/extend":429,"../../plot_api/plot_template":474,"../../traces/scatter/attributes":587,"../annotations/attributes":303,"../drawing/attributes":338}],395:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62533,7 +62957,6 @@ module.exports = templatedArray('shape', { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); @@ -62611,7 +63034,7 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { } function shapeBounds(ax, v0, v1, path, paramsToUse) { - var convertVal = (ax.type === 'category') ? ax.r2c : ax.d2c; + var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; if(!path) return; @@ -62642,7 +63065,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":441,"../../plots/cartesian/axes":488,"./constants":400,"./helpers":403}],400:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/cartesian/axes":484,"./constants":396,"./helpers":399}],396:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62706,7 +63129,7 @@ module.exports = { } }; -},{}],401:[function(_dereq_,module,exports){ +},{}],397:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62831,7 +63254,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":441,"../../plots/array_container_defaults":484,"../../plots/cartesian/axes":488,"./attributes":398,"./helpers":403}],402:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/array_container_defaults":480,"../../plots/cartesian/axes":484,"./attributes":394,"./helpers":399}],398:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62954,9 +63377,10 @@ function setClipPath(shapePath, gd, shapeOptions) { // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 var clipAxes = (shapeOptions.xref + shapeOptions.yref).replace(/paper/g, ''); - shapePath.call(Drawing.setClipUrl, clipAxes ? - ('clip' + gd._fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } @@ -63140,7 +63564,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { // Don't rely on clipPath being activated during re-layout setClipPath(shapePath, gd, shapeOptions); - Registry.call('relayout', gd, editHelpers.getUpdateObj()); + Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj()); } function abortDrag() { @@ -63327,9 +63751,10 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(xref !== 'paper' && !xa.autorange) clipAxes += xref; if(yref !== 'paper' && !ya.autorange) clipAxes += yref; - shapePath.call(Drawing.setClipUrl, clipAxes ? - 'clip' + gd._fullLayout._uid + clipAxes : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } } @@ -63461,7 +63886,7 @@ function movePath(pathIn, moveX, moveY) { }); } -},{"../../lib":441,"../../lib/setcursor":461,"../../plot_api/plot_template":478,"../../plots/cartesian/axes":488,"../../registry":532,"../color":319,"../dragelement":341,"../drawing":344,"./constants":400,"./helpers":403}],403:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../lib/setcursor":457,"../../plot_api/plot_template":474,"../../plots/cartesian/axes":484,"../../registry":528,"../color":318,"../dragelement":336,"../drawing":339,"./constants":396,"./helpers":399}],399:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63586,7 +64011,7 @@ exports.roundPositionForSharpStrokeRendering = function(pos, strokeWidth) { return strokeWidthIsOdd ? posValAsInt + 0.5 : posValAsInt; }; -},{"../../lib":441,"./constants":400}],404:[function(_dereq_,module,exports){ +},{"../../lib":437,"./constants":396}],400:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63613,7 +64038,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":499,"./attributes":398,"./calc_autorange":399,"./defaults":401,"./draw":402}],405:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":495,"./attributes":394,"./calc_autorange":395,"./defaults":397,"./draw":398}],401:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63715,7 +64140,7 @@ module.exports = overrideAll(templatedArray('slider', { }, - pad: extendDeepAll({}, padAttrs, { + pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { }, {t: {dflt: 20}}), xanchor: { @@ -63856,7 +64281,7 @@ module.exports = overrideAll(templatedArray('slider', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":432,"../../plot_api/edit_types":471,"../../plot_api/plot_template":478,"../../plots/animation_attributes":483,"../../plots/font_attributes":515,"../../plots/pad_attributes":524,"./constants":406}],406:[function(_dereq_,module,exports){ +},{"../../lib/extend":429,"../../plot_api/edit_types":467,"../../plot_api/plot_template":474,"../../plots/animation_attributes":479,"../../plots/font_attributes":511,"../../plots/pad_attributes":520,"./constants":402}],402:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63950,7 +64375,7 @@ module.exports = { currentValueInset: 0, }; -},{}],407:[function(_dereq_,module,exports){ +},{}],403:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64067,7 +64492,7 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":441,"../../plots/array_container_defaults":484,"./attributes":405,"./constants":406}],408:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/array_container_defaults":480,"./attributes":401,"./constants":402}],404:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64085,7 +64510,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var constants = _dereq_('./constants'); @@ -64277,21 +64701,21 @@ function findDimensions(gd, sliderOpts) { dims.height = dims.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + dims.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(sliderOpts)) { + if(Lib.isRightAnchor(sliderOpts)) { dims.lx -= dims.outerLength; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(sliderOpts)) { + if(Lib.isCenterAnchor(sliderOpts)) { dims.lx -= dims.outerLength / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(sliderOpts)) { + if(Lib.isBottomAnchor(sliderOpts)) { dims.ly -= dims.height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(sliderOpts)) { + if(Lib.isMiddleAnchor(sliderOpts)) { dims.ly -= dims.height / 2; yanchor = 'middle'; } @@ -64698,7 +65122,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":417,"../../lib":441,"../../lib/svg_text_utils":465,"../../plot_api/plot_template":478,"../../plots/plots":525,"../color":319,"../drawing":344,"../legend/anchor_utils":371,"./constants":406,"d3":85}],409:[function(_dereq_,module,exports){ +},{"../../constants/alignment":413,"../../lib":437,"../../lib/svg_text_utils":461,"../../plot_api/plot_template":474,"../../plots/plots":521,"../color":318,"../drawing":339,"./constants":402,"d3":85}],405:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64721,7 +65145,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":405,"./constants":406,"./defaults":407,"./draw":408}],410:[function(_dereq_,module,exports){ +},{"./attributes":401,"./constants":402,"./defaults":403,"./draw":404}],406:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64791,19 +65215,21 @@ function draw(gd, titleClass, options) { var group = options.containerGroup; var fullLayout = gd._fullLayout; - var titlefont = cont.titlefont || {}; - var font = titlefont.family; - var fontSize = titlefont.size; - var fontColor = titlefont.color; var opacity = 1; var isplaceholder = false; - var txt = (cont.title || '').trim(); + var title = cont.title; + var txt = (title && title.text ? title.text : '').trim(); + + var font = title && title.font ? title.font : {}; + var fontFamily = font.family; + var fontSize = font.size; + var fontColor = font.color; // only make this title editable if we positively identify its property // as one that has editing enabled. var editAttr; - if(prop === 'title') editAttr = 'titleText'; + if(prop === 'title.text') editAttr = 'titleText'; else if(prop.indexOf('axis') !== -1) editAttr = 'axisTitleText'; else if(prop.indexOf('colorbar' !== -1)) editAttr = 'colorbarTitleText'; var editable = gd._context.edits[editAttr]; @@ -64861,7 +65287,7 @@ function draw(gd, titleClass, options) { titleEl.attr('transform', transformVal); titleEl.style({ - 'font-family': font, + 'font-family': fontFamily, 'font-size': d3.round(fontSize, 2) + 'px', fill: Color.rgb(fontColor), opacity: opacity * Color.opacity(fontColor), @@ -64961,9 +65387,9 @@ function draw(gd, titleClass, options) { el.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { if(traceIndex !== undefined) { - Registry.call('restyle', gd, prop, text, traceIndex); + Registry.call('_guiRestyle', gd, prop, text, traceIndex); } else { - Registry.call('relayout', gd, prop, text); + Registry.call('_guiRelayout', gd, prop, text); } }) .on('cancel', function() { @@ -64980,7 +65406,7 @@ function draw(gd, titleClass, options) { return group; } -},{"../../constants/interactions":419,"../../lib":441,"../../lib/svg_text_utils":465,"../../plots/plots":525,"../../registry":532,"../color":319,"../drawing":344,"d3":85,"fast-isnumeric":149}],411:[function(_dereq_,module,exports){ +},{"../../constants/interactions":415,"../../lib":437,"../../lib/svg_text_utils":461,"../../plots/plots":521,"../../registry":528,"../color":318,"../drawing":339,"d3":85,"fast-isnumeric":149}],407:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65109,7 +65535,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { }, - pad: extendFlat({}, padAttrs, { + pad: extendFlat(padAttrs({editType: 'arraydraw'}), { }), @@ -65138,7 +65564,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":432,"../../plot_api/edit_types":471,"../../plot_api/plot_template":478,"../../plots/font_attributes":515,"../../plots/pad_attributes":524,"../color/attributes":318}],412:[function(_dereq_,module,exports){ +},{"../../lib/extend":429,"../../plot_api/edit_types":467,"../../plot_api/plot_template":474,"../../plots/font_attributes":511,"../../plots/pad_attributes":520,"../color/attributes":317}],408:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65219,7 +65645,7 @@ module.exports = { } }; -},{}],413:[function(_dereq_,module,exports){ +},{}],409:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65302,7 +65728,7 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":441,"../../plots/array_container_defaults":484,"./attributes":411,"./constants":412}],414:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/array_container_defaults":480,"./attributes":407,"./constants":408}],410:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65321,7 +65747,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var LINE_SPACING = _dereq_('../../constants/alignment').LINE_SPACING; @@ -65871,21 +66296,21 @@ function findDimensions(gd, menuOpts) { dims.ly = graphSize.t + graphSize.h * (1 - menuOpts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(menuOpts)) { + if(Lib.isRightAnchor(menuOpts)) { dims.lx -= paddedWidth; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(menuOpts)) { + if(Lib.isCenterAnchor(menuOpts)) { dims.lx -= paddedWidth / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(menuOpts)) { + if(Lib.isBottomAnchor(menuOpts)) { dims.ly -= paddedHeight; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(menuOpts)) { + if(Lib.isMiddleAnchor(menuOpts)) { dims.ly -= paddedHeight / 2; yanchor = 'middle'; } @@ -65952,9 +66377,9 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":417,"../../lib":441,"../../lib/svg_text_utils":465,"../../plot_api/plot_template":478,"../../plots/plots":525,"../color":319,"../drawing":344,"../legend/anchor_utils":371,"./constants":412,"./scrollbox":416,"d3":85}],415:[function(_dereq_,module,exports){ -arguments[4][409][0].apply(exports,arguments) -},{"./attributes":411,"./constants":412,"./defaults":413,"./draw":414,"dup":409}],416:[function(_dereq_,module,exports){ +},{"../../constants/alignment":413,"../../lib":437,"../../lib/svg_text_utils":461,"../../plot_api/plot_template":474,"../../plots/plots":521,"../color":318,"../drawing":339,"./constants":408,"./scrollbox":412,"d3":85}],411:[function(_dereq_,module,exports){ +arguments[4][405][0].apply(exports,arguments) +},{"./attributes":407,"./constants":408,"./defaults":409,"./draw":410,"dup":405}],412:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66211,7 +66636,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { height: Math.ceil(clipB) - Math.floor(clipT) }); - this.container.call(Drawing.setClipUrl, clipId); + this.container.call(Drawing.setClipUrl, clipId, this.gd); this.bg.attr({ x: l, @@ -66425,7 +66850,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":441,"../color":319,"../drawing":344,"d3":85}],417:[function(_dereq_,module,exports){ +},{"../../lib":437,"../color":318,"../drawing":339,"d3":85}],413:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66469,12 +66894,17 @@ module.exports = { // multiple of fontSize to get the vertical offset between lines LINE_SPACING: 1.3, - // multiple of fontSize to shift from the baseline to the midline + // multiple of fontSize to shift from the baseline + // to the cap (captical letter) line // (to use when we don't calculate this shift from Drawing.bBox) - // To be precise this should be half the cap height (capital letter) - // of the font, and according to wikipedia: + // This is an approximation since in reality cap height can differ + // from font to font. However, according to Wikipedia // an "average" font might have a cap height of 70% of the em // https://en.wikipedia.org/wiki/Em_(typography)#History + CAP_SHIFT: 0.70, + + // half the cap height (distance between baseline and cap line) + // of an "average" font (for more info see above). MID_SHIFT: 0.35, OPPOSITE_SIDE: { @@ -66485,7 +66915,7 @@ module.exports = { } }; -},{}],418:[function(_dereq_,module,exports){ +},{}],414:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66523,7 +66953,7 @@ module.exports = { } }; -},{}],419:[function(_dereq_,module,exports){ +},{}],415:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66550,7 +66980,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],420:[function(_dereq_,module,exports){ +},{}],416:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66615,7 +67045,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],421:[function(_dereq_,module,exports){ +},{}],417:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66639,7 +67069,7 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],422:[function(_dereq_,module,exports){ +},{}],418:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66651,7 +67081,7 @@ exports.svgAttrs = { 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.42.5'; +exports.version = '1.43.0'; // inject promise polyfill _dereq_('es6-promise').polyfill(); @@ -66660,7 +67090,7 @@ _dereq_('es6-promise').polyfill(); _dereq_('../build/plotcss'); // inject default MathJax config -_dereq_('./fonts/mathjax_config'); +_dereq_('./fonts/mathjax_config')(); // include registry module and expose register method var Registry = _dereq_('./registry'); @@ -66671,7 +67101,8 @@ var plotApi = _dereq_('./plot_api'); var methodNames = Object.keys(plotApi); for(var i = 0; i < methodNames.length; i++) { var name = methodNames[i]; - exports[name] = plotApi[name]; + // _ -> private API methods, but still registered for internal use + if(name.charAt(0) !== '_') exports[name] = plotApi[name]; register({ moduleType: 'apiMethod', name: name, @@ -66695,7 +67126,8 @@ register([ _dereq_('./components/rangeslider'), _dereq_('./components/rangeselector'), _dereq_('./components/grid'), - _dereq_('./components/errorbars') + _dereq_('./components/errorbars'), + _dereq_('./components/colorscale') ]); // locales en and en-US are required for default behavior @@ -66717,7 +67149,7 @@ exports.Queue = _dereq_('./lib/queue'); // export d3 used in the bundle exports.d3 = _dereq_('d3'); -},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":312,"./components/annotations3d":317,"./components/errorbars":350,"./components/fx":361,"./components/grid":365,"./components/images":370,"./components/legend":379,"./components/rangeselector":390,"./components/rangeslider":396,"./components/shapes":404,"./components/sliders":409,"./components/updatemenus":415,"./fonts/mathjax_config":423,"./lib/queue":456,"./locale-en":469,"./locale-en-us":468,"./plot_api":473,"./plot_api/plot_schema":477,"./plots/plots":525,"./registry":532,"./snapshot":537,"./traces/scatter":604,"d3":85,"es6-promise":139}],423:[function(_dereq_,module,exports){ +},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":311,"./components/annotations3d":316,"./components/colorscale":330,"./components/errorbars":345,"./components/fx":357,"./components/grid":361,"./components/images":366,"./components/legend":374,"./components/rangeselector":385,"./components/rangeslider":392,"./components/shapes":400,"./components/sliders":405,"./components/updatemenus":411,"./fonts/mathjax_config":419,"./lib/queue":452,"./locale-en":465,"./locale-en-us":464,"./plot_api":469,"./plot_api/plot_schema":473,"./plots/plots":521,"./registry":528,"./snapshot":533,"./traces/scatter":599,"d3":85,"es6-promise":139}],419:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66730,31 +67162,89 @@ exports.d3 = _dereq_('d3'); /* global MathJax:false */ +module.exports = function() { + if(typeof MathJax !== 'undefined') { + var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; + + if(globalConfig) { + MathJax.Hub.Config({ + messageStyle: 'none', + skipStartupTypeset: true, + displayAlign: 'left', + tex2jax: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + } + }); + MathJax.Hub.Configured(); + } + } +}; + +},{}],420:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + + /** - * Check and configure MathJax + * Determine the position anchor property of x/y xanchor/yanchor components. + * + * - values < 1/3 align the low side at that fraction, + * - values [1/3, 2/3] align the center at that fraction, + * - values > 2/3 align the right at that fraction. */ -if(typeof MathJax !== 'undefined') { - exports.MathJax = true; - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } +exports.isLeftAnchor = function isLeftAnchor(opts) { + return ( + opts.xanchor === 'left' || + (opts.xanchor === 'auto' && opts.x <= 1 / 3) + ); +}; -} else { - exports.MathJax = false; -} +exports.isCenterAnchor = function isCenterAnchor(opts) { + return ( + opts.xanchor === 'center' || + (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) + ); +}; + +exports.isRightAnchor = function isRightAnchor(opts) { + return ( + opts.xanchor === 'right' || + (opts.xanchor === 'auto' && opts.x >= 2 / 3) + ); +}; + +exports.isTopAnchor = function isTopAnchor(opts) { + return ( + opts.yanchor === 'top' || + (opts.yanchor === 'auto' && opts.y >= 2 / 3) + ); +}; + +exports.isMiddleAnchor = function isMiddleAnchor(opts) { + return ( + opts.yanchor === 'middle' || + (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) + ); +}; -},{}],424:[function(_dereq_,module,exports){ +exports.isBottomAnchor = function isBottomAnchor(opts) { + return ( + opts.yanchor === 'bottom' || + (opts.yanchor === 'auto' && opts.y <= 1 / 3) + ); +}; + +},{}],421:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66995,7 +67485,7 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":448}],425:[function(_dereq_,module,exports){ +},{"./mod":444}],422:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67131,7 +67621,30 @@ exports.concat = function() { return out; }; -},{}],426:[function(_dereq_,module,exports){ +exports.maxRowLength = function(z) { + return _rowLength(z, Math.max, 0); +}; + +exports.minRowLength = function(z) { + return _rowLength(z, Math.min, Infinity); +}; + +function _rowLength(z, fn, len0) { + if(isArrayOrTypedArray(z)) { + if(isArrayOrTypedArray(z[0])) { + var len = len0; + for(var i = 0; i < z.length; i++) { + len = fn(len, z[i].length); + } + return len; + } else { + return z.length; + } + } + return 0; +} + +},{}],423:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67164,7 +67677,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":420,"fast-isnumeric":149}],427:[function(_dereq_,module,exports){ +},{"../constants/numerical":416,"fast-isnumeric":149}],424:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67192,7 +67705,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],428:[function(_dereq_,module,exports){ +},{}],425:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67215,7 +67728,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],429:[function(_dereq_,module,exports){ +},{}],426:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67224,18 +67737,17 @@ module.exports = function clearResponsive(gd) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); var baseTraceAttrs = _dereq_('../plots/attributes'); -var getColorscale = _dereq_('../components/colorscale/get_scale'); -var colorscaleNames = Object.keys(_dereq_('../components/colorscale/scales')); +var scales = _dereq_('../components/colorscale/scales'); +var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; + var nestedProperty = _dereq_('./nested_property'); var counterRegex = _dereq_('./regex').counter; -var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; var modHalf = _dereq_('./mod').modHalf; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -67353,7 +67865,7 @@ exports.valObjectMeta = { coerceFunction: function(v, propOut, dflt) { - propOut.set(getColorscale(v, dflt)); + propOut.set(scales.get(v, dflt)); } }, angle: { @@ -67687,7 +68199,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/get_scale":332,"../components/colorscale/scales":338,"../constants/interactions":419,"../plots/attributes":485,"./array":425,"./mod":448,"./nested_property":449,"./regex":457,"fast-isnumeric":149,"tinycolor2":284}],430:[function(_dereq_,module,exports){ +},{"../components/colorscale/scales":333,"../constants/interactions":415,"../plots/attributes":481,"./array":422,"./mod":444,"./nested_property":445,"./regex":453,"fast-isnumeric":149,"tinycolor2":283}],427:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68290,7 +68802,7 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":420,"../registry":532,"./loggers":445,"./mod":448,"d3":85,"fast-isnumeric":149}],431:[function(_dereq_,module,exports){ +},{"../constants/numerical":416,"../registry":528,"./loggers":441,"./mod":444,"d3":85,"fast-isnumeric":149}],428:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68464,7 +68976,7 @@ var Events = { module.exports = Events; -},{"events":50}],432:[function(_dereq_,module,exports){ +},{"events":50}],429:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68580,7 +69092,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":442}],433:[function(_dereq_,module,exports){ +},{"./is_plain_object.js":438}],430:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68631,7 +69143,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],434:[function(_dereq_,module,exports){ +},{}],431:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68678,7 +69190,7 @@ function isCalcData(cont) { ); } -},{}],435:[function(_dereq_,module,exports){ +},{}],432:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68924,7 +69436,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":448}],436:[function(_dereq_,module,exports){ +},{"./mod":444}],433:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68962,7 +69474,7 @@ module.exports = function(gd) { return gd; // otherwise assume that gd is a DOM element }; -},{}],437:[function(_dereq_,module,exports){ +},{}],434:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69013,11 +69525,7 @@ function formatColor(containerIn, opacityIn, len) { if(containerIn.colorscale !== undefined) { sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - containerIn.colorscale, - containerIn.cmin, - containerIn.cmax - ) + Colorscale.extractScale(containerIn, {cLetter: 'c'}) ); } else { @@ -69070,7 +69578,7 @@ module.exports = { parseColorScale: parseColorScale }; -},{"../components/color/attributes":318,"../components/colorscale":334,"./array":425,"color-normalize":63,"fast-isnumeric":149,"tinycolor2":284}],438:[function(_dereq_,module,exports){ +},{"../components/color/attributes":317,"../components/colorscale":330,"./array":422,"color-normalize":63,"fast-isnumeric":149,"tinycolor2":283}],435:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69106,54 +69614,7 @@ module.exports = { unwrap: function(d) {return d[0];} }; -},{"./identity":440}],439:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var toSuperScript = _dereq_('superscript-text'); -var fixEntities = _dereq_('./svg_text_utils').convertEntities; - -function fixSuperScript(x) { - var idx = 0; - - while((idx = x.indexOf('', idx)) >= 0) { - var nidx = x.indexOf('', idx); - if(nidx < idx) break; - - x = x.slice(0, idx) + toSuperScript(x.slice(idx + 5, nidx)) + x.slice(nidx + 6); - } - - return x; -} - -function fixBR(x) { - return x.replace(/\/g, '\n'); -} - -function stripTags(x) { - return x.replace(/\<.*\>/g, ''); -} - -function convertHTMLToUnicode(html) { - return '' + - fixEntities( - stripTags( - fixSuperScript( - fixBR( - html)))); -} - -module.exports = convertHTMLToUnicode; - -},{"./svg_text_utils":465,"superscript-text":277}],440:[function(_dereq_,module,exports){ +},{"./identity":436}],436:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69169,7 +69630,7 @@ module.exports = convertHTMLToUnicode; module.exports = function identity(d) { return d; }; -},{}],441:[function(_dereq_,module,exports){ +},{}],437:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69203,6 +69664,8 @@ lib.isArrayOrTypedArray = arrayModule.isArrayOrTypedArray; lib.isArray1D = arrayModule.isArray1D; lib.ensureArray = arrayModule.ensureArray; lib.concat = arrayModule.concat; +lib.maxRowLength = arrayModule.maxRowLength; +lib.minRowLength = arrayModule.minRowLength; var modModule = _dereq_('./mod'); lib.mod = modModule.mod; @@ -69272,6 +69735,14 @@ lib.pathArc = anglesModule.pathArc; lib.pathSector = anglesModule.pathSector; lib.pathAnnulus = anglesModule.pathAnnulus; +var anchorUtils = _dereq_('./anchor_utils'); +lib.isLeftAnchor = anchorUtils.isLeftAnchor; +lib.isCenterAnchor = anchorUtils.isCenterAnchor; +lib.isRightAnchor = anchorUtils.isRightAnchor; +lib.isTopAnchor = anchorUtils.isTopAnchor; +lib.isMiddleAnchor = anchorUtils.isMiddleAnchor; +lib.isBottomAnchor = anchorUtils.isBottomAnchor; + var geom2dModule = _dereq_('./geometry2d'); lib.segmentsIntersect = geom2dModule.segmentsIntersect; lib.segmentDistance = geom2dModule.segmentDistance; @@ -69806,7 +70277,13 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) objOut[k] = v.slice(0, arrayLen); + else if(Array.isArray(v)) { + if(k === 'colorscale') { + objOut[k] = v.slice(); + } else { + objOut[k] = v.slice(0, arrayLen); + } + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -70151,10 +70628,10 @@ lib.numSeparate = function(value, separators, separatethousands) { return x1 + x2; }; -var TEMPLATE_STRING_REGEX = /%{([^\s%{}]*)}/g; +var TEMPLATE_STRING_REGEX = /%{([^\s%{}:]*)(:[^}]*)?}/g; var SIMPLE_PROPERTY_REGEX = /^\w*$/; -/* +/** * Substitute values from an object into a string * * Examples: @@ -70166,7 +70643,6 @@ var SIMPLE_PROPERTY_REGEX = /^\w*$/; * * @return {string} templated string */ - lib.templateString = function(string, obj) { // Not all that useful, but cache nestedProperty instantiation // just in case it speeds things up *slightly*: @@ -70181,6 +70657,67 @@ lib.templateString = function(string, obj) { }); }; +var TEMPLATE_STRING_FORMAT_SEPARATOR = /^:/; +var numberOfHoverTemplateWarnings = 0; +var maximumNumberOfHoverTemplateWarnings = 10; +/** + * Substitute values from an object into a string and optionally formats them using d3-format, + * or fallback to associated labels. + * + * Examples: + * Lib.templateString('name: %{trace}', {trace: 'asdf'}) --> 'name: asdf' + * Lib.templateString('name: %{trace[0].name}', {trace: [{name: 'asdf'}]}) --> 'name: asdf' + * Lib.templateString('price: %{y:$.2f}', {y: 1}) --> 'price: $1.00' + * + * @param {string} input string containing %{...:...} template strings + * @param {obj} data object containing fallback text when no formatting is specified, ex.: {yLabel: 'formattedYValue'} + * @param {obj} data objects containing substitution values + * + * @return {string} templated string + */ +lib.hovertemplateString = function(string, labels) { + var args = arguments; + // Not all that useful, but cache nestedProperty instantiation + // just in case it speeds things up *slightly*: + var getterCache = {}; + + return string.replace(TEMPLATE_STRING_REGEX, function(match, key, format) { + var obj, value, i; + for(i = 2; i < args.length; i++) { + obj = args[i]; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; + } + + if(value === undefined) { + if(numberOfHoverTemplateWarnings < maximumNumberOfHoverTemplateWarnings) { + lib.warn('Variable \'' + key + '\' in hovertemplate could not be found!'); + value = match; + } + + if(numberOfHoverTemplateWarnings === maximumNumberOfHoverTemplateWarnings) { + lib.warn('Too many hovertemplate warnings - additional warnings will be suppressed'); + } + numberOfHoverTemplateWarnings++; + } + + if(format) { + value = d3.format(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value); + } else { + if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + } + return value; + }); +}; + /* * alphanumeric string sort, tailored for subplot IDs like scene2, scene10, x10y13 etc */ @@ -70223,7 +70760,7 @@ lib.pseudoRandom = function() { return randSeed / 4294967296; }; -},{"../constants/numerical":420,"./angles":424,"./array":425,"./clean_number":426,"./clear_responsive":428,"./coerce":429,"./dates":430,"./extend":432,"./filter_unique":433,"./filter_visible":434,"./geometry2d":435,"./get_graph_div":436,"./identity":440,"./is_plain_object":442,"./keyed_container":443,"./localize":444,"./loggers":445,"./make_trace_groups":446,"./matrix":447,"./mod":448,"./nested_property":449,"./noop":450,"./notifier":451,"./push_unique":455,"./regex":457,"./relative_attr":458,"./relink_private":459,"./search":460,"./stats":463,"./throttle":466,"./to_log_range":467,"d3":85,"fast-isnumeric":149}],442:[function(_dereq_,module,exports){ +},{"../constants/numerical":416,"./anchor_utils":420,"./angles":421,"./array":422,"./clean_number":423,"./clear_responsive":425,"./coerce":426,"./dates":427,"./extend":429,"./filter_unique":430,"./filter_visible":431,"./geometry2d":432,"./get_graph_div":433,"./identity":436,"./is_plain_object":438,"./keyed_container":439,"./localize":440,"./loggers":441,"./make_trace_groups":442,"./matrix":443,"./mod":444,"./nested_property":445,"./noop":446,"./notifier":447,"./push_unique":451,"./regex":453,"./relative_attr":454,"./relink_private":455,"./search":456,"./stats":459,"./throttle":462,"./to_log_range":463,"d3":85,"fast-isnumeric":149}],438:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70252,7 +70789,7 @@ module.exports = function isPlainObject(obj) { ); }; -},{}],443:[function(_dereq_,module,exports){ +},{}],439:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70445,7 +70982,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":449}],444:[function(_dereq_,module,exports){ +},{"./nested_property":445}],440:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70501,7 +71038,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":532}],445:[function(_dereq_,module,exports){ +},{"../registry":528}],441:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70587,7 +71124,7 @@ function apply(f, args) { } } -},{"../plot_api/plot_config":476}],446:[function(_dereq_,module,exports){ +},{"../plot_api/plot_config":472}],442:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70624,7 +71161,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{}],447:[function(_dereq_,module,exports){ +},{}],443:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70734,7 +71271,7 @@ exports.apply2DTransform2 = function(transform) { }; }; -},{}],448:[function(_dereq_,module,exports){ +},{}],444:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70769,7 +71306,7 @@ module.exports = { modHalf: modHalf }; -},{}],449:[function(_dereq_,module,exports){ +},{}],445:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71016,7 +71553,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":425,"fast-isnumeric":149}],450:[function(_dereq_,module,exports){ +},{"./array":422,"fast-isnumeric":149}],446:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71032,7 +71569,7 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],451:[function(_dereq_,module,exports){ +},{}],447:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71114,7 +71651,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":85,"fast-isnumeric":149}],452:[function(_dereq_,module,exports){ +},{"d3":85,"fast-isnumeric":149}],448:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71163,7 +71700,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":461}],453:[function(_dereq_,module,exports){ +},{"./setcursor":457}],449:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71416,7 +71953,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":420,"./matrix":447}],454:[function(_dereq_,module,exports){ +},{"../constants/numerical":416,"./matrix":443}],450:[function(_dereq_,module,exports){ (function (global){ /** * Copyright 2012-2018, Plotly, Inc. @@ -71488,7 +72025,7 @@ module.exports = function prepareRegl(gd, extensions) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./show_no_webgl_msg":462,"regl":259}],455:[function(_dereq_,module,exports){ +},{"./show_no_webgl_msg":458,"regl":259}],451:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71528,7 +72065,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],456:[function(_dereq_,module,exports){ +},{}],452:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71739,7 +72276,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":441,"../plot_api/plot_config":476}],457:[function(_dereq_,module,exports){ +},{"../lib":437,"../plot_api/plot_config":472}],453:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71758,16 +72295,18 @@ module.exports = queue; * @param {Optional(string)} tail: a fixed piece after the id * eg counterRegex('scene', '.annotations') for scene2.annotations etc. * @param {boolean} openEnded: if true, the string may continue past the match. + * @param {boolean} matchBeginning: if false, the string may start before the match. */ -exports.counter = function(head, tail, openEnded) { +exports.counter = function(head, tail, openEnded, matchBeginning) { var fullTail = (tail || '') + (openEnded ? '' : '$'); + var startWithPrefix = matchBeginning === false ? '' : '^'; if(head === 'xy') { - return new RegExp('^x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + 'x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); } - return new RegExp('^' + head + '([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],458:[function(_dereq_,module,exports){ +},{}],454:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71820,7 +72359,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],459:[function(_dereq_,module,exports){ +},{}],455:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71883,7 +72422,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":425,"./is_plain_object":442}],460:[function(_dereq_,module,exports){ +},{"./array":422,"./is_plain_object":438}],456:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72071,7 +72610,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"./identity":440,"./loggers":445,"fast-isnumeric":149}],461:[function(_dereq_,module,exports){ +},{"./identity":436,"./loggers":441,"fast-isnumeric":149}],457:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72094,7 +72633,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],462:[function(_dereq_,module,exports){ +},{}],458:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72158,7 +72697,7 @@ module.exports = function showNoWebGlMsg(scene) { return false; }; -},{"../components/color":319}],463:[function(_dereq_,module,exports){ +},{"../components/color":318}],459:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72259,7 +72798,7 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":425,"fast-isnumeric":149}],464:[function(_dereq_,module,exports){ +},{"./array":422,"fast-isnumeric":149}],460:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72280,7 +72819,7 @@ function str2RgbaArray(color) { module.exports = str2RgbaArray; -},{"color-normalize":63}],465:[function(_dereq_,module,exports){ +},{"color-normalize":63}],461:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73055,7 +73594,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":417,"../constants/xmlns_namespaces":421,"../lib":441,"d3":85}],466:[function(_dereq_,module,exports){ +},{"../constants/alignment":413,"../constants/xmlns_namespaces":417,"../lib":437,"d3":85}],462:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73159,7 +73698,7 @@ function _clearTimeout(cache) { } } -},{}],467:[function(_dereq_,module,exports){ +},{}],463:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73187,7 +73726,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":149}],468:[function(_dereq_,module,exports){ +},{"fast-isnumeric":149}],464:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73209,7 +73748,7 @@ module.exports = { } }; -},{}],469:[function(_dereq_,module,exports){ +},{}],465:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73252,7 +73791,7 @@ module.exports = { } }; -},{}],470:[function(_dereq_,module,exports){ +},{}],466:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73310,7 +73849,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":532}],471:[function(_dereq_,module,exports){ +},{"../registry":528}],467:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73436,7 +73975,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":441}],472:[function(_dereq_,module,exports){ +},{"../lib":437}],468:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73492,6 +74031,8 @@ exports.cleanLayout = function(layout) { } var axisAttrRegex = (Plots.subplotsRegistry.cartesian || {}).attrRegex; + var polarAttrRegex = (Plots.subplotsRegistry.polar || {}).attrRegex; + var ternaryAttrRegex = (Plots.subplotsRegistry.ternary || {}).attrRegex; var sceneAttrRegex = (Plots.subplotsRegistry.gl3d || {}).attrRegex; var keys = Object.keys(layout); @@ -73530,6 +74071,24 @@ exports.cleanLayout = function(layout) { } delete ax.autotick; } + + cleanTitle(ax); + } + + // modifications for polar + else if(polarAttrRegex && polarAttrRegex.test(key)) { + var polar = layout[key]; + + cleanTitle(polar.radialaxis); + } + + // modifications for ternary + else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + var ternary = layout[key]; + + cleanTitle(ternary.aaxis); + cleanTitle(ternary.baxis); + cleanTitle(ternary.caxis); } // modifications for 3D scenes @@ -73553,11 +74112,16 @@ exports.cleanLayout = function(layout) { scene.camera = { eye: {x: eye[0], y: eye[1], z: eye[2]}, center: {x: center[0], y: center[1], z: center[2]}, - up: {x: mat[1], y: mat[5], z: mat[9]} + up: {x: 0, y: 0, z: 1} // we just ignore calculating camera z up in this case }; delete scene.cameraposition; } + + // clean axis titles + cleanTitle(scene.xaxis); + cleanTitle(scene.yaxis); + cleanTitle(scene.zaxis); } } @@ -73615,6 +74179,9 @@ exports.cleanLayout = function(layout) { } } + // clean plot title + cleanTitle(layout); + /* * Moved from rotate -> orbit for dragmode */ @@ -73624,6 +74191,11 @@ exports.cleanLayout = function(layout) { // supported, but new tinycolor does not because they're not valid css Color.clean(layout); + // clean the layout container in layout.template + if(layout.template && layout.template.layout) { + exports.cleanLayout(layout.template.layout); + } + return layout; }; @@ -73635,6 +74207,46 @@ function cleanAxRef(container, attr) { } } +/** + * Cleans up old title attribute structure (flat) in favor of the new one (nested). + * + * @param {Object} titleContainer - an object potentially including deprecated title attributes + */ +function cleanTitle(titleContainer) { + if(titleContainer) { + + // title -> title.text + // (although title used to be a string attribute, + // numbers are accepted as well) + if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') { + titleContainer.title = { + text: titleContainer.title + }; + } + + rewireAttr('titlefont', 'font'); + rewireAttr('titleposition', 'position'); + rewireAttr('titleside', 'side'); + rewireAttr('titleoffset', 'offset'); + } + + function rewireAttr(oldAttrName, newAttrName) { + var oldAttrSet = titleContainer[oldAttrName]; + var newAttrSet = titleContainer.title && titleContainer.title[newAttrName]; + + if(oldAttrSet && !newAttrSet) { + + // Ensure title object exists + if(!titleContainer.title) { + titleContainer.title = {}; + } + + titleContainer.title[newAttrName] = titleContainer[oldAttrName]; + delete titleContainer[oldAttrName]; + } + } +} + /* * cleanData: Make a few changes to the data for backward compatibility * before it gets used for anything. Modifies the data traces users provide. @@ -73838,6 +74450,13 @@ exports.cleanData = function(data) { delete trace.autobiny; delete trace.ybins; } + + cleanTitle(trace); + if(trace.colorbar) cleanTitle(trace.colorbar); + if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar); + if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar); + if(trace.aaxis) cleanTitle(trace.aaxis); + if(trace.baxis) cleanTitle(trace.baxis); } }; @@ -73878,11 +74497,14 @@ function commonPrefix(name1, name2, show1, show2) { function cleanTextPosition(textposition) { var posY = 'middle', posX = 'center'; - if(textposition.indexOf('top') !== -1) posY = 'top'; - else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; - if(textposition.indexOf('left') !== -1) posX = 'left'; - else if(textposition.indexOf('right') !== -1) posX = 'right'; + if(typeof textposition === 'string') { + if(textposition.indexOf('top') !== -1) posY = 'top'; + else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; + + if(textposition.indexOf('left') !== -1) posX = 'left'; + else if(textposition.indexOf('right') !== -1) posX = 'right'; + } return posY + ' ' + posX; } @@ -74058,7 +74680,7 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":319,"../lib":441,"../plots/cartesian/axis_ids":491,"../plots/plots":525,"../registry":532,"fast-isnumeric":149,"gl-mat4/fromQuat":167}],473:[function(_dereq_,module,exports){ +},{"../components/color":318,"../lib":437,"../plots/cartesian/axis_ids":487,"../plots/plots":521,"../registry":528,"fast-isnumeric":149,"gl-mat4/fromQuat":167}],469:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74077,6 +74699,10 @@ exports.restyle = main.restyle; exports.relayout = main.relayout; exports.redraw = main.redraw; exports.update = main.update; +exports._guiRestyle = main._guiRestyle; +exports._guiRelayout = main._guiRelayout; +exports._guiUpdate = main._guiUpdate; +exports._storeDirectGUIEdit = main._storeDirectGUIEdit; exports.react = main.react; exports.extendTraces = main.extendTraces; exports.prependTraces = main.prependTraces; @@ -74097,7 +74723,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":534,"./plot_api":475,"./template_api":480,"./to_image":481,"./validate":482}],474:[function(_dereq_,module,exports){ +},{"../snapshot/download":530,"./plot_api":471,"./template_api":476,"./to_image":477,"./validate":478}],470:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74109,7 +74735,6 @@ exports.validateTemplate = templateApi.validateTemplate; 'use strict'; -var nestedProperty = _dereq_('../lib/nested_property'); var isPlainObject = _dereq_('../lib/is_plain_object'); var noop = _dereq_('../lib/noop'); var Loggers = _dereq_('../lib/loggers'); @@ -74166,11 +74791,15 @@ var isRemoveVal = exports.isRemoveVal = function isRemoveVal(val) { * the flags for which actions we're going to perform to display these (and * any other) changes. If we're already `recalc`ing, we don't need to redraw * individual items + * @param {function} _nestedProperty + * a (possibly modified for gui edits) nestedProperty constructor + * The modified version takes a 3rd argument, for a prefix to the attribute + * string necessary for storing GUI edits * * @returns {bool} `true` if it managed to complete drawing of the changes * `false` would mean the parent should replot. */ -exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags) { +exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags, _nestedProperty) { var componentType = np.astr, supplyComponentDefaults = Registry.getComponentMethod(componentType, 'supplyLayoutDefaults'), draw = Registry.getComponentMethod(componentType, 'draw'), @@ -74210,7 +74839,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, // redoing supplyDefaults // TODO: this assumes componentArray is in gd.layout - which will not be // true after we extend this to restyle - componentArrayFull = nestedProperty(fullLayout, componentType).get(); + componentArrayFull = _nestedProperty(fullLayout, componentType).get(); var deletes = [], firstIndexChange = -1, @@ -74221,7 +74850,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, objEdits, objKeys, objVal, - adding; + adding, prefix; // first make the add and edit changes for(i = 0; i < componentNums.length; i++) { @@ -74260,7 +74889,9 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, } else { for(j = 0; j < objKeys.length; j++) { - nestedProperty(componentArray[componentNum], objKeys[j]).set(objEdits[objKeys[j]]); + prefix = componentType + '[' + componentNum + '].'; + _nestedProperty(componentArray[componentNum], objKeys[j], prefix) + .set(objEdits[objKeys[j]]); } } } @@ -74311,7 +74942,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":442,"../lib/loggers":445,"../lib/nested_property":449,"../lib/noop":450,"../lib/search":460,"../registry":532,"./container_array_match":470}],475:[function(_dereq_,module,exports){ +},{"../lib/is_plain_object":438,"../lib/loggers":441,"../lib/noop":446,"../lib/search":456,"../registry":528,"./container_array_match":466}],471:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74329,6 +74960,8 @@ var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); var Lib = _dereq_('../lib'); +var nestedProperty = Lib.nestedProperty; + var Events = _dereq_('../lib/events'); var Queue = _dereq_('../lib/queue'); @@ -74424,9 +75057,6 @@ exports.plot = function(gd, data, layout, config) { // so we can share cached text across tabs Drawing.makeTester(); - // clear stashed base url - delete Drawing.baseUrl; - // collect promises for any async actions during plotting // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all @@ -74471,7 +75101,7 @@ exports.plot = function(gd, data, layout, config) { // Legacy polar plots if(!fullLayout._has('polar') && data && data[0] && data[0].r) { Lib.log('Legacy polar charts are deprecated!'); - return plotPolar(gd, data, layout); + return plotLegacyPolar(gd, data, layout); } // so we don't try to re-call Plotly.plot from inside @@ -74647,8 +75277,7 @@ exports.plot = function(gd, data, layout, config) { return Lib.syncOrAsync([ Registry.getComponentMethod('shapes', 'calcAutorange'), Registry.getComponentMethod('annotations', 'calcAutorange'), - doAutoRangeAndConstraints, - Registry.getComponentMethod('rangeslider', 'calcAutorange') + doAutoRangeAndConstraints ], gd); } @@ -74660,11 +75289,16 @@ exports.plot = function(gd, data, layout, config) { // store initial ranges *after* enforcing constraints, otherwise // we will never look like we're at the initial ranges if(graphWasEmpty) Axes.saveRangeInitial(gd); + + // this one is different from shapes/annotations calcAutorange + // the others incorporate those components into ax._extremes, + // this one actually sets the ranges in rangesliders. + Registry.getComponentMethod('rangeslider', 'calcAutorange')(gd); } // draw ticks, titles, and calculate axis scaling (._b, ._m) function drawAxes() { - return Axes.doTicks(gd, graphWasEmpty ? '' : 'redraw'); + return Axes.draw(gd, graphWasEmpty ? '' : 'redraw'); } var seq = [ @@ -74733,7 +75367,16 @@ function opaqueSetBackground(gd, bgColor) { } function setPlotContext(gd, config) { - if(!gd._context) gd._context = Lib.extendDeep({}, defaultConfig); + if(!gd._context) { + gd._context = Lib.extendDeep({}, defaultConfig); + + // stash href, used to make robust clipPath URLs + var base = d3.select('base'); + gd._context._baseUrl = base.size() && base.attr('href') ? + window.location.href.split('#')[0] : + ''; + } + var context = gd._context; var i, keys, key; @@ -74779,6 +75422,9 @@ function setPlotContext(gd, config) { } } } + + // not part of the user-facing config options + context._exportedPlot = config._exportedPlot; } // staticPlot forces a bunch of others: @@ -74808,7 +75454,7 @@ function setPlotContext(gd, config) { context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0; } -function plotPolar(gd, data, layout) { +function plotLegacyPolar(gd, data, layout) { // build or reuse the container skeleton var plotContainer = d3.select(gd).selectAll('.plot-container') .data([0]); @@ -74849,7 +75495,7 @@ function plotPolar(gd, data, layout) { // editable title var opacity = 1; - var txt = gd._fullLayout.title; + var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; if(txt === '' || !txt) opacity = 0; var titleLayout = function() { @@ -74883,7 +75529,7 @@ function plotPolar(gd, data, layout) { var setContenteditable = function() { this.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { - gd.framework({layout: {title: text}}); + gd.framework({layout: {title: {text: text}}}); this.text(text) .call(titleLayout); this.call(setContenteditable); @@ -75156,7 +75802,7 @@ function getExtendProperties(gd, update, indices, maxPoints) { * instance that references the key and value for this particular trace. */ trace = gd.data[indices[j]]; - prop = Lib.nestedProperty(trace, key); + prop = nestedProperty(trace, key); /* * Target is the existing gd.data.trace.dataArray value like "x" or "marker.size" @@ -75627,7 +76273,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) { * If the array is too short, it will wrap around (useful for * style files that want to specify cyclical default values). */ -exports.restyle = function restyle(gd, astr, val, _traces) { +function restyle(gd, astr, val, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -75697,7 +76343,8 @@ exports.restyle = function restyle(gd, astr, val, _traces) { gd.emit('plotly_restyle', specs.eventData); return gd; }); -}; +} +exports.restyle = restyle; // for undo: undefined initial vals must be turned into nulls // so that we unset rather than ignore them @@ -75706,11 +76353,77 @@ function undefinedToNull(val) { return val; } +/** + * Factory function to wrap nestedProperty with GUI edits if necessary + * with GUI edits we add an optional prefix to the nestedProperty constructor + * to prepend to the attribute string in the preGUI store. + */ +function makeNP(preGUI, guiEditFlag) { + if(!guiEditFlag) return nestedProperty; + + return function(container, attr, prefix) { + var np = nestedProperty(container, attr); + var npSet = np.set; + np.set = function(val) { + var fullAttr = (prefix || '') + attr; + storeCurrent(fullAttr, np.get(), val, preGUI); + npSet(val); + }; + return np; + }; +} + +function storeCurrent(attr, val, newVal, preGUI) { + if(Array.isArray(val) || Array.isArray(newVal)) { + var arrayVal = Array.isArray(val) ? val : []; + var arrayNew = Array.isArray(newVal) ? newVal : []; + var maxLen = Math.max(arrayVal.length, arrayNew.length); + for(var i = 0; i < maxLen; i++) { + storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); + } + } + else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + var objVal = Lib.isPlainObject(val) ? val : {}; + var objNew = Lib.isPlainObject(newVal) ? newVal : {}; + var objBoth = Lib.extendFlat({}, objVal, objNew); + for(var key in objBoth) { + storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); + } + } + else if(preGUI[attr] === undefined) { + preGUI[attr] = undefinedToNull(val); + } +} + +/** + * storeDirectGUIEdit: for routines that skip restyle/relayout and mock it + * by emitting a plotly_restyle or plotly_relayout event, this routine + * keeps track of the initial state in _preGUI for use by uirevision + * Does *not* apply these changes to data/layout - that's the responsibility + * of the calling routine. + * + * @param {object} container: the input attributes container (eg `layout` or a `trace`) + * @param {object} preGUI: where original values should be stored, either + * `layout._preGUI` or `layout._tracePreGUI[uid]` + * @param {object} edits: the {attr: val} object as normally passed to `relayout` etc + */ +exports._storeDirectGUIEdit = function(container, preGUI, edits) { + for(var attr in edits) { + var np = nestedProperty(container, attr); + storeCurrent(attr, np.get(), edits[attr], preGUI); + } +}; + function _restyle(gd, aobj, traces) { - var fullLayout = gd._fullLayout, - fullData = gd._fullData, - data = gd.data, - i; + var fullLayout = gd._fullLayout; + var fullData = gd._fullData; + var data = gd.data; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var eventData = Lib.extendDeepAll({}, aobj); + var i; + + cleanDeprecatedAttributeKeys(aobj); // initialize flags var flags = editTypes.traceFlags(); @@ -75734,6 +76447,16 @@ function _restyle(gd, aobj, traces) { function rangeAttr(axName) { return 'LAYOUT' + axName + '.range'; } + function getFullTrace(traceIndex) { + // usually fullData maps 1:1 onto data, but with groupby transforms + // the fullData index can be greater. Take the *first* matching trace. + for(var j = traceIndex; j < fullData.length; j++) { + if(fullData[j]._input === data[traceIndex]) return fullData[j]; + } + // should never get here - and if we *do* it should cause an error + // later on undefined fullTrace is passed to nestedProperty. + } + // for attrs that interact (like scales & autoscales), save the // old vals before making the change // val=undefined will not set a value, just record what the value was. @@ -75749,9 +76472,11 @@ function _restyle(gd, aobj, traces) { var extraparam; if(attr.substr(0, 6) === 'LAYOUT') { - extraparam = Lib.nestedProperty(gd.layout, attr.replace('LAYOUT', '')); + extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', '')); } else { - extraparam = Lib.nestedProperty(data[traces[i]], attr); + var tracei = traces[i]; + var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid]; + extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr); } if(!(attr in undoit)) { @@ -75806,7 +76531,7 @@ function _restyle(gd, aobj, traces) { redoit[ai] = vi; if(ai.substr(0, 6) === 'LAYOUT') { - param = Lib.nestedProperty(gd.layout, ai.replace('LAYOUT', '')); + param = layoutNP(gd.layout, ai.replace('LAYOUT', '')); undoit[ai] = [undefinedToNull(param.get())]; // since we're allowing val to be an array, allow it here too, // even though that's meaningless @@ -75821,8 +76546,9 @@ function _restyle(gd, aobj, traces) { undoit[ai] = a0(); for(i = 0; i < traces.length; i++) { cont = data[traces[i]]; - contFull = fullData[traces[i]]; - param = Lib.nestedProperty(cont, ai); + contFull = getFullTrace(traces[i]); + var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid]; + param = makeNP(preGUI, guiEditFlag)(cont, ai); oldVal = param.get(); newVal = Array.isArray(vi) ? vi[i % vi.length] : vi; @@ -75832,7 +76558,7 @@ function _restyle(gd, aobj, traces) { var prefix = ai.substr(0, ai.length - finalPart.length - 1); var prefixDot = prefix ? prefix + '.' : ''; var innerContFull = prefix ? - Lib.nestedProperty(contFull, prefix).get() : contFull; + nestedProperty(contFull, prefix).get() : contFull; valObject = PlotSchema.getTraceValObject(contFull, param.parts); @@ -75879,14 +76605,14 @@ function _restyle(gd, aobj, traces) { Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo); if(oldVal === 'pie') { - Lib.nestedProperty(cont, 'marker.color') - .set(Lib.nestedProperty(cont, 'marker.colors').get()); + nestedProperty(cont, 'marker.color') + .set(nestedProperty(cont, 'marker.colors').get()); // super kludgy - but if all pies are gone we won't remove them otherwise fullLayout._pielayer.selectAll('g.trace').remove(); } else if(Registry.traceIs(cont, 'cartesian')) { - Lib.nestedProperty(cont, 'marker.colors') - .set(Lib.nestedProperty(cont, 'marker.color').get()); + nestedProperty(cont, 'marker.colors') + .set(nestedProperty(cont, 'marker.color').get()); } } @@ -75957,7 +76683,7 @@ function _restyle(gd, aobj, traces) { // swap hovermode if set to "compare x/y data" if(ai === 'orientationaxes') { - var hovermode = Lib.nestedProperty(gd.layout, 'hovermode'); + var hovermode = nestedProperty(gd.layout, 'hovermode'); if(hovermode.get() === 'x') { hovermode.set('y'); } else if(hovermode.get() === 'y') { @@ -75996,10 +76722,53 @@ function _restyle(gd, aobj, traces) { undoit: undoit, redoit: redoit, traces: traces, - eventData: Lib.extendDeepNoArrays([], [redoit, traces]) + eventData: Lib.extendDeepNoArrays([], [eventData, traces]) }; } +/** + * Converts deprecated attribute keys to + * the current API to ensure backwards compatibility. + * + * This is needed for the update mechanism to determine which + * subroutines to run based on the actual attribute + * definitions (that don't include the deprecated ones). + * + * E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'} + * and {titlefont: {...}} to {'title.font': {...}}. + * + * @param aobj + */ +function cleanDeprecatedAttributeKeys(aobj) { + var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false); + var colorbarRegex = /colorbar\.title$/; + var keys = Object.keys(aobj); + var i, key, value; + + for(i = 0; i < keys.length; i++) { + key = keys[i]; + value = aobj[key]; + + if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) && + (typeof value === 'string' || typeof value === 'number')) { + replace(key, key.replace('title', 'title.text')); + } else if(key.indexOf('titlefont') > -1) { + replace(key, key.replace('titlefont', 'title.font')); + } else if(key.indexOf('titleposition') > -1) { + replace(key, key.replace('titleposition', 'title.position')); + } else if(key.indexOf('titleside') > -1) { + replace(key, key.replace('titleside', 'title.side')); + } else if(key.indexOf('titleoffset') > -1) { + replace(key, key.replace('titleoffset', 'title.offset')); + } + } + + function replace(oldAttrStr, newAttrStr) { + aobj[newAttrStr] = aobj[oldAttrStr]; + delete aobj[oldAttrStr]; + } +} + /** * relayout: update layout attributes of an existing plot * @@ -76020,7 +76789,7 @@ function _restyle(gd, aobj, traces) { * attribute object `{astr1: val1, astr2: val2 ...}` * allows setting multiple attributes simultaneously */ -exports.relayout = function relayout(gd, astr, val) { +function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -76083,7 +76852,8 @@ exports.relayout = function relayout(gd, astr, val) { gd.emit('plotly_relayout', specs.eventData); return gd; }); -}; +} +exports.relayout = relayout; // Optimization mostly for large splom traces where // Plots.supplyDefaults can take > 100ms @@ -76111,13 +76881,24 @@ function addAxRangeSequence(seq, rangesAltered) { // N.B. leave as sequence of subroutines (for now) instead of // subroutine of its own so that finalDraw always gets // executed after drawData - var doTicks = rangesAltered ? - function(gd) { return Axes.doTicks(gd, Object.keys(rangesAltered), true); } : - function(gd) { return Axes.doTicks(gd, 'redraw'); }; + var drawAxes = rangesAltered ? + function(gd) { + var opts = {skipTitle: true}; + for(var id in rangesAltered) { + if(Axes.getFromId(gd, id).automargin) { + opts = {}; + break; + } + } + return Axes.draw(gd, Object.keys(rangesAltered), opts); + } : + function(gd) { + return Axes.draw(gd, 'redraw'); + }; seq.push( subroutines.doAutoRangeAndConstraints, - doTicks, + drawAxes, subroutines.drawData, subroutines.finalDraw ); @@ -76128,14 +76909,19 @@ var AX_AUTORANGE_RE = /^[xyz]axis[0-9]*\.autorange$/; var AX_DOMAIN_RE = /^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/; function _relayout(gd, aobj) { - var layout = gd.layout, - fullLayout = gd._fullLayout, - keys = Object.keys(aobj), - axes = Axes.list(gd), - arrayEdits = {}, - arrayStr, - i, - j; + var layout = gd.layout; + var fullLayout = gd._fullLayout; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var keys = Object.keys(aobj); + var axes = Axes.list(gd); + var eventData = Lib.extendDeepAll({}, aobj); + var arrayEdits = {}; + + var arrayStr, i, j; + + cleanDeprecatedAttributeKeys(aobj); + keys = Object.keys(aobj); // look for 'allaxes', split out into all axes // in case of 3D the axis are nested within a scene which is held in _id @@ -76175,7 +76961,7 @@ function _relayout(gd, aobj) { // via a parent) do not override with this auto-generated extra if(attr in aobj || helpers.hasParent(aobj, attr)) return; - var p = Lib.nestedProperty(layout, attr); + var p = layoutNP(layout, attr); if(!(attr in undoit)) { undoit[attr] = undefinedToNull(p.get()); } @@ -76200,7 +76986,7 @@ function _relayout(gd, aobj) { throw new Error('cannot set ' + ai + 'and a parent attribute simultaneously'); } - var p = Lib.nestedProperty(layout, ai); + var p = layoutNP(layout, ai); var vi = aobj[ai]; var plen = p.parts.length; // p.parts may end with an index integer if the property is an array @@ -76212,8 +76998,8 @@ function _relayout(gd, aobj) { var pleafPlus = p.parts[pend - 1] + '.' + pleaf; // trunk nodes (everything except the leaf) var ptrunk = p.parts.slice(0, pend).join('.'); - var parentIn = Lib.nestedProperty(gd.layout, ptrunk).get(); - var parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + var parentIn = nestedProperty(gd.layout, ptrunk).get(); + var parentFull = nestedProperty(fullLayout, ptrunk).get(); var vOld = p.get(); if(vi === undefined) continue; @@ -76258,12 +77044,12 @@ function _relayout(gd, aobj) { // check autorange vs range else if(pleafPlus.match(AX_RANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - var axFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + var axFull = nestedProperty(fullLayout, ptrunk).get(); if(axFull._inputDomain) { // if we're autoranging and this axis has a constrained domain, // reset it so we don't get locked into a shrunken size @@ -76271,7 +77057,7 @@ function _relayout(gd, aobj) { } } else if(pleafPlus.match(AX_DOMAIN_RE)) { - Lib.nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); + nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } // toggling axis type between log and linear: we need to convert @@ -76340,10 +77126,10 @@ function _relayout(gd, aobj) { doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleaf.match(AX_NAME_PATTERN)) { - var fullProp = Lib.nestedProperty(fullLayout, ai).get(), + var fullProp = nestedProperty(fullLayout, ai).get(), newType = (vi || {}).type; // This can potentially cause strange behavior if the autotype is not @@ -76365,8 +77151,6 @@ function _relayout(gd, aobj) { arrayStr = containerArrayMatch.array; i = containerArrayMatch.index; var propStr = containerArrayMatch.property; - var componentArray = Lib.nestedProperty(layout, arrayStr); - var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; if(i !== '' && propStr === '') { @@ -76376,7 +77160,7 @@ function _relayout(gd, aobj) { if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { - undoit[ai] = obji; + undoit[ai] = (nestedProperty(layout, arrayStr).get() || [])[i]; } else { Lib.warn('unrecognized full object value', aobj); } @@ -76420,7 +77204,7 @@ function _relayout(gd, aobj) { // now we've collected component edits - execute them all together for(arrayStr in arrayEdits) { var finished = manageArrays.applyContainerArrayChanges(gd, - Lib.nestedProperty(layout, arrayStr), arrayEdits[arrayStr], flags); + layoutNP(layout, arrayStr), arrayEdits[arrayStr], flags, layoutNP); if(!finished) flags.plot = true; } @@ -76463,7 +77247,7 @@ function _relayout(gd, aobj) { rangesAltered: rangesAltered, undoit: undoit, redoit: redoit, - eventData: Lib.extendDeep({}, redoit) + eventData: eventData }; } @@ -76498,7 +77282,7 @@ function updateAutosize(gd) { * integer or array of integers for the traces to alter (all if omitted) * */ -exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { +function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -76578,7 +77362,235 @@ exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { return gd; }); -}; +} +exports.update = update; + +/* + * internal-use-only restyle/relayout/update variants that record the initial + * values in (fullLayout|fullTrace)._preGUI so changes can be persisted across + * Plotly.react data updates, dependent on uirevision attributes + */ +function guiEdit(func) { + return function wrappedEdit(gd) { + gd._fullLayout._guiEditing = true; + var p = func.apply(null, arguments); + gd._fullLayout._guiEditing = false; + return p; + }; +} +exports._guiRestyle = guiEdit(restyle); +exports._guiRelayout = guiEdit(relayout); +exports._guiUpdate = guiEdit(update); + +// For connecting edited layout attributes to uirevision attrs +// If no `attr` we use `match[1] + '.uirevision'` +// Ordered by most common edits first, to minimize our search time +var layoutUIControlPatterns = [ + {pattern: /^hiddenlabels/, attr: 'legend.uirevision'}, + {pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/}, + + // showspikes and modes include those nested inside scenes + {pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'}, + {pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'}, + + {pattern: /^(scene\d*)\.camera/}, + {pattern: /^(geo\d*)\.(projection|center)/}, + {pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/}, + {pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/}, + {pattern: /^(polar\d*\.angularaxis)\.rotation/}, + {pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/}, + + {pattern: /^legend\.(x|y)$/, attr: 'editrevision'}, + {pattern: /^(shapes|annotations)/, attr: 'editrevision'}, + {pattern: /^title\.text$/, attr: 'editrevision'} +]; + +// same for trace attributes: if `attr` is given it's in layout, +// or with no `attr` we use `trace.uirevision` +var traceUIControlPatterns = [ + {pattern: /^selectedpoints$/, attr: 'selectionrevision'}, + // "visible" includes trace.transforms[i].styles[j].value.visible + {pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'}, + {pattern: /^dimensions\[\d+\]\.constraintrange/}, + + // below this you must be in editable: true mode + // TODO: I still put name and title with `trace.uirevision` + // reasonable or should these be `editrevision`? + // Also applies to axis titles up in the layout section + + // "name" also includes transform.styles + {pattern: /(^|value\.)name$/}, + // including nested colorbar attributes (ie marker.colorbar) + {pattern: /colorbar\.title\.text$/}, + {pattern: /colorbar\.(x|y)$/, attr: 'editrevision'} +]; + +function findUIPattern(key, patternSpecs) { + for(var i = 0; i < patternSpecs.length; i++) { + var spec = patternSpecs[i]; + var match = key.match(spec.pattern); + if(match) { + return {head: match[1], attr: spec.attr}; + } + } +} + +// We're finding the new uirevision before supplyDefaults, so do the +// inheritance manually. Note that only `undefined` inherits - other +// falsy values are returned. +function getNewRev(revAttr, container) { + var newRev = nestedProperty(container, revAttr).get(); + if(newRev !== undefined) return newRev; + + var parts = revAttr.split('.'); + parts.pop(); + while(parts.length > 1) { + parts.pop(); + newRev = nestedProperty(container, parts.join('.') + '.uirevision').get(); + if(newRev !== undefined) return newRev; + } + + return container.uirevision; +} + +function getFullTraceIndexFromUid(uid, fullData) { + for(var i = 0; i < fullData.length; i++) { + if(fullData[i]._fullInput.uid === uid) return i; + } + return -1; +} + +function getTraceIndexFromUid(uid, data, tracei) { + for(var i = 0; i < data.length; i++) { + if(data[i].uid === uid) return i; + } + // fall back on trace order, but only if user didn't provide a uid for that trace + return data[tracei].uid ? -1 : tracei; +} + +function valsMatch(v1, v2) { + var v1IsObj = Lib.isPlainObject(v1); + var v1IsArray = Array.isArray(v1); + if(v1IsObj || v1IsArray) { + return ( + (v1IsObj && Lib.isPlainObject(v2)) || + (v1IsArray && Array.isArray(v2)) + ) && JSON.stringify(v1) === JSON.stringify(v2); + } + return v1 === v2; +} + +function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { + var layoutPreGUI = oldFullLayout._preGUI; + var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal; + var bothInheritAutorange = []; + var newRangeAccepted = {}; + for(key in layoutPreGUI) { + match = findUIPattern(key, layoutUIControlPatterns); + if(match) { + revAttr = match.attr || (match.head + '.uirevision'); + oldRev = nestedProperty(oldFullLayout, revAttr).get(); + newRev = oldRev && getNewRev(revAttr, layout); + if(newRev && (newRev === oldRev)) { + preGUIVal = layoutPreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(layout, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + if(newVal === undefined && key.substr(key.length - 9) === 'autorange') { + bothInheritAutorange.push(key.substr(0, key.length - 10)); + } + newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key); + } + // if we got this far, the new value was accepted as the new starting + // point (either because it changed or revision changed) + // so remove it from _preGUI for next time. + delete layoutPreGUI[key]; + + if(key.substr(key.length - 8, 6) === 'range[') { + newRangeAccepted[key.substr(0, key.length - 9)] = 1; + } + } + + // Special logic for `autorange`, since it interacts with `range`: + // If the new figure's matching `range` was kept, and `autorange` + // wasn't supplied explicitly in either the original or the new figure, + // we shouldn't alter that - but we may just have done that, so fix it. + for(var i = 0; i < bothInheritAutorange.length; i++) { + var axAttr = bothInheritAutorange[i]; + if(newRangeAccepted[axAttr]) { + var newAx = nestedProperty(layout, axAttr).get(); + if(newAx) delete newAx.autorange; + } + } + + // Now traces - try to match them up by uid (in case we added/deleted in + // the middle), then fall back on index. + var allTracePreGUI = oldFullLayout._tracePreGUI; + for(var uid in allTracePreGUI) { + var tracePreGUI = allTracePreGUI[uid]; + var newTrace = null; + var fullInput; + for(key in tracePreGUI) { + // wait until we know we have preGUI values to look for traces + // but if we don't find both, stop looking at this uid + if(!newTrace) { + var fulli = getFullTraceIndexFromUid(uid, oldFullData); + if(fulli < 0) { + // Somehow we didn't even have this trace in oldFullData... + // I guess this could happen with `deleteTraces` or something + delete allTracePreGUI[uid]; + break; + } + var fullTrace = oldFullData[fulli]; + fullInput = fullTrace._fullInput; + + var newTracei = getTraceIndexFromUid(uid, data, fullInput.index); + if(newTracei < 0) { + // No match in new data + delete allTracePreGUI[uid]; + break; + } + newTrace = data[newTracei]; + } + + match = findUIPattern(key, traceUIControlPatterns); + if(match) { + if(match.attr) { + oldRev = nestedProperty(oldFullLayout, match.attr).get(); + newRev = oldRev && getNewRev(match.attr, layout); + } + else { + oldRev = fullInput.uirevision; + // inheritance for trace.uirevision is simple, just layout.uirevision + newRev = newTrace.uirevision; + if(newRev === undefined) newRev = layout.uirevision; + } + + if(newRev && newRev === oldRev) { + preGUIVal = tracePreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(newTrace, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + newNP.set(undefinedToNull(nestedProperty(fullInput, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); + } + delete tracePreGUI[key]; + } + } +} /** * Plotly.react: @@ -76642,6 +77654,8 @@ exports.react = function(gd, data, layout, config) { gd.layout = layout || {}; helpers.cleanLayout(gd.layout); + applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout); + // "true" skips updating calcdata and remapping arrays from calcTransforms, // which supplyDefaults usually does at the end, but we may need to NOT do // if the diff (which we haven't determined yet) says we'll recalc @@ -77696,7 +78710,7 @@ function makePlotFramework(gd) { gd.emit('plotly_framework'); } -},{"../components/color":319,"../components/colorbar/connect":321,"../components/drawing":344,"../constants/xmlns_namespaces":421,"../lib":441,"../lib/events":431,"../lib/queue":456,"../lib/svg_text_utils":465,"../plots/cartesian/axes":488,"../plots/cartesian/constants":494,"../plots/cartesian/graph_interact":498,"../plots/plots":525,"../plots/polar/legacy":528,"../registry":532,"./edit_types":471,"./helpers":472,"./manage_arrays":474,"./plot_config":476,"./plot_schema":477,"./subroutines":479,"d3":85,"fast-isnumeric":149,"has-hover":200}],476:[function(_dereq_,module,exports){ +},{"../components/color":318,"../components/colorbar/connect":320,"../components/drawing":339,"../constants/xmlns_namespaces":417,"../lib":437,"../lib/events":428,"../lib/queue":452,"../lib/svg_text_utils":461,"../plots/cartesian/axes":484,"../plots/cartesian/constants":490,"../plots/cartesian/graph_interact":494,"../plots/plots":521,"../plots/polar/legacy":524,"../registry":528,"./edit_types":467,"./helpers":468,"./manage_arrays":470,"./plot_config":472,"./plot_schema":473,"./subroutines":475,"d3":85,"fast-isnumeric":149,"has-hover":200}],472:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77789,12 +78803,34 @@ module.exports = { */ showAxisRangeEntryBoxes: true, - // link to open this plot in plotly + /* + * Add a text link to open this plot in plotly? + * This link shows up in the bottom right corner of the plot, and works + * identically to the newer ModeBar button controlled by `showSendToCloud` + * unless `sendData: false` is used. + */ showLink: false, - // if we show a link, does it contain data or just link to a plotly file? + /* + * If we show a text link (`showLink: true`), does it contain data or just + * a reference to a plotly cloud file? This option should only be used on + * plot.ly or another plotly server, and is not supported by the newer + * ModeBar button `showSendToCloud`. + */ sendData: true, + /* + * Should we include a ModeBar button, labeled "Edit in Chart Studio", + * that sends this chart to plot.ly or another plotly server as specified + * by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0 + * this button was included by default, now it is opt-in using this flag. + * + * Note that this button can (depending on `plotlyServerURL`) send your data + * to an external server. However that server doesn't persist your data + * until you arrive at the Chart Studio and explicitly click "Save". + */ + showSendToCloud: false, + // text appearing in the sendData link linkText: 'Edit chart', @@ -77832,6 +78868,9 @@ module.exports = { // add the plotly logo on the end of the mode bar displaylogo: true, + // watermark the images with the company's logo + watermark: false, + // increase the pixel ratio for Gl plot images plotGlPixelRatio: 2, @@ -77898,7 +78937,7 @@ module.exports = { locales: {} }; -},{}],477:[function(_dereq_,module,exports){ +},{}],473:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78584,7 +79623,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":441,"../plots/animation_attributes":483,"../plots/attributes":485,"../plots/frame_attributes":516,"../plots/layout_attributes":523,"../plots/polar/legacy/area_attributes":526,"../plots/polar/legacy/axis_attributes":527,"../registry":532,"./edit_types":471}],478:[function(_dereq_,module,exports){ +},{"../lib":437,"../plots/animation_attributes":479,"../plots/attributes":481,"../plots/frame_attributes":512,"../plots/layout_attributes":519,"../plots/polar/legacy/area_attributes":522,"../plots/polar/legacy/axis_attributes":523,"../registry":528,"./edit_types":467}],474:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78898,7 +79937,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":441,"../plots/attributes":485}],479:[function(_dereq_,module,exports){ +},{"../lib":437,"../plots/attributes":481}],475:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78928,6 +79967,10 @@ var enforceAxisConstraints = axisConstraints.enforce; var cleanAxisConstraints = axisConstraints.clean; var doAutoRange = _dereq_('../plots/cartesian/autorange').doAutoRange; +var SVG_TEXT_ANCHOR_START = 'start'; +var SVG_TEXT_ANCHOR_MIDDLE = 'middle'; +var SVG_TEXT_ANCHOR_END = 'end'; + exports.layoutStyles = function(gd) { return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd); }; @@ -78952,7 +79995,7 @@ function lsInner(gd) { var gs = fullLayout._size; var pad = gs.p; var axList = Axes.list(gd, '', true); - var i, subplot, plotinfo, xa, ya; + var i, subplot, plotinfo, ax, xa, ya; fullLayout._paperdiv.style({ width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px', @@ -78988,10 +80031,7 @@ function lsInner(gd) { // some preparation of axis position info for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - - // reset scale in case the margins have changed - ax.setScale(); + ax = axList[i]; var counterAx = ax._anchorAxis; @@ -79010,11 +80050,6 @@ function lsInner(gd) { ax._mainMirrorPosition = (ax.mirror && counterAx) ? getLinePosition(ax, counterAx, alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; - - // Figure out which subplot to draw ticks, labels, & axis lines on - // do this as a separate loop so we already have all the - // _mainAxis and _anchorAxis links set - ax._mainSubplot = findMainSubplot(ax, fullLayout); } // figure out which backgrounds we need to draw, @@ -79125,7 +80160,7 @@ function lsInner(gd) { layerClipId = null; } - Drawing.setClipUrl(plotinfo.plot, plotClipId); + Drawing.setClipUrl(plotinfo.plot, plotClipId, gd); // stash layer clipId value (null or same as clipId) // to DRY up Drawing.setClipUrl calls on trace-module and trace layers @@ -79255,48 +80290,6 @@ function lsInner(gd) { return gd._promises.length && Promise.all(gd._promises); } -function findMainSubplot(ax, fullLayout) { - var subplotList = fullLayout._subplots; - var ids = subplotList.cartesian.concat(subplotList.gl2d || []); - var mockGd = {_fullLayout: fullLayout}; - - var isX = ax._id.charAt(0) === 'x'; - var anchorAx = ax._mainAxis._anchorAxis; - var mainSubplotID = ''; - var nextBestMainSubplotID = ''; - var anchorID = ''; - - // First try the main ID with the anchor - if(anchorAx) { - anchorID = anchorAx._mainAxis._id; - mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); - } - - // Then look for a subplot with the counteraxis overlaying the anchor - // If that fails just use the first subplot including this axis - if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { - mainSubplotID = ''; - - for(var j = 0; j < ids.length; j++) { - var id = ids[j]; - var yIndex = id.indexOf('y'); - var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); - var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); - - if(idPart === ax._id) { - if(!nextBestMainSubplotID) nextBestMainSubplotID = id; - var counterAx = Axes.getFromId(mockGd, counterPart); - if(anchorID && counterAx.overlaying === anchorID) { - mainSubplotID = id; - break; - } - } - } - } - - return mainSubplotID || nextBestMainSubplotID; -} - function shouldShowLinesOrTicks(ax, subplot) { return (ax.ticks || ax.showline) && (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); @@ -79351,18 +80344,92 @@ function findCounterAxisLineWidth(ax, side, counterAx, axList) { exports.drawMainTitle = function(gd) { var fullLayout = gd._fullLayout; + var textAnchor = getMainTitleTextAnchor(fullLayout); + var dy = getMainTitleDy(fullLayout); + Titles.draw(gd, 'gtitle', { propContainer: fullLayout, - propName: 'title', + propName: 'title.text', placeholder: fullLayout._dfltTitle.plot, attributes: { - x: fullLayout.width / 2, - y: fullLayout._size.t / 2, - 'text-anchor': 'middle' + x: getMainTitleX(fullLayout, textAnchor), + y: getMainTitleY(fullLayout, dy), + 'text-anchor': textAnchor, + dy: dy } }); }; +function getMainTitleX(fullLayout, textAnchor) { + var title = fullLayout.title; + var gs = fullLayout._size; + var hPadShift = 0; + + if(textAnchor === SVG_TEXT_ANCHOR_START) { + hPadShift = title.pad.l; + } else if(textAnchor === SVG_TEXT_ANCHOR_END) { + hPadShift = -title.pad.r; + } + + switch(title.xref) { + case 'paper': + return gs.l + gs.w * title.x + hPadShift; + case 'container': + default: + return fullLayout.width * title.x + hPadShift; + } +} + +function getMainTitleY(fullLayout, dy) { + var title = fullLayout.title; + var gs = fullLayout._size; + var vPadShift = 0; + + if(dy === '0em' || !dy) { + vPadShift = -title.pad.b; + } else if(dy === alignmentConstants.CAP_SHIFT + 'em') { + vPadShift = title.pad.t; + } + + if(title.y === 'auto') { + return gs.t / 2; + } else { + switch(title.yref) { + case 'paper': + return gs.t + gs.h - gs.h * title.y + vPadShift; + case 'container': + default: + return fullLayout.height - fullLayout.height * title.y + vPadShift; + } + } +} + +function getMainTitleTextAnchor(fullLayout) { + var title = fullLayout.title; + + var textAnchor = SVG_TEXT_ANCHOR_MIDDLE; + if(Lib.isRightAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_END; + } else if(Lib.isLeftAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_START; + } + + return textAnchor; +} + +function getMainTitleDy(fullLayout) { + var title = fullLayout.title; + + var dy = '0em'; + if(Lib.isTopAnchor(title)) { + dy = alignmentConstants.CAP_SHIFT + 'em'; + } else if(Lib.isMiddleAnchor(title)) { + dy = alignmentConstants.MID_SHIFT + 'em'; + } + + return dy; +} + exports.doTraceStyle = function(gd) { var calcdata = gd.calcdata; var editStyleCalls = []; @@ -79440,7 +80507,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.doTicks(gd, 'redraw'); + Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -79575,6 +80642,8 @@ exports.doAutoRangeAndConstraints = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; cleanAxisConstraints(gd, ax); + // in case margins changed, update scale + ax.setScale(); doAutoRange(gd, ax); } @@ -79606,7 +80675,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('updatemenus', 'draw')(gd); }; -},{"../components/color":319,"../components/drawing":344,"../components/modebar":382,"../components/titles":410,"../constants/alignment":417,"../lib":441,"../lib/clear_gl_canvases":427,"../plots/cartesian/autorange":487,"../plots/cartesian/axes":488,"../plots/cartesian/constraints":496,"../plots/plots":525,"../registry":532,"d3":85}],480:[function(_dereq_,module,exports){ +},{"../components/color":318,"../components/drawing":339,"../components/modebar":377,"../components/titles":406,"../constants/alignment":413,"../lib":437,"../lib/clear_gl_canvases":424,"../plots/cartesian/autorange":483,"../plots/cartesian/axes":484,"../plots/cartesian/constraints":492,"../plots/plots":521,"../registry":528,"d3":85}],476:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80080,7 +81149,7 @@ function format(opts) { return opts; } -},{"../lib":441,"../plots/attributes":485,"../plots/plots":525,"./plot_config":476,"./plot_schema":477,"./plot_template":478}],481:[function(_dereq_,module,exports){ +},{"../lib":437,"../plots/attributes":481,"../plots/plots":521,"./plot_config":472,"./plot_schema":473,"./plot_template":474}],477:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80200,6 +81269,7 @@ function toImage(gd, opts) { // extend config for static plot var configImage = Lib.extendFlat({}, config, { + _exportedPlot: true, staticPlot: true, setBackground: setBackground }); @@ -80270,7 +81340,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":441,"../snapshot/helpers":536,"../snapshot/svgtoimg":538,"../snapshot/tosvg":540,"./plot_api":475}],482:[function(_dereq_,module,exports){ +},{"../lib":437,"../snapshot/helpers":532,"../snapshot/svgtoimg":534,"../snapshot/tosvg":536,"./plot_api":471}],478:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80716,7 +81786,7 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":441,"../plots/plots":525,"./plot_config":476,"./plot_schema":477}],483:[function(_dereq_,module,exports){ +},{"../lib":437,"../plots/plots":521,"./plot_config":472,"./plot_schema":473}],479:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80818,7 +81888,7 @@ module.exports = { } }; -},{}],484:[function(_dereq_,module,exports){ +},{}],480:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80914,7 +81984,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":441,"../plot_api/plot_template":478}],485:[function(_dereq_,module,exports){ +},{"../lib":437,"../plot_api/plot_template":474}],481:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81036,10 +82106,16 @@ module.exports = { _isLinkedToArray: 'transform', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + } }; -},{"../components/fx/attributes":353}],486:[function(_dereq_,module,exports){ +},{"../components/fx/attributes":348}],482:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81068,7 +82144,7 @@ module.exports = { } }; -},{}],487:[function(_dereq_,module,exports){ +},{}],483:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81083,6 +82159,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; +var Registry = _dereq_('../../registry'); module.exports = { getAutoRange: getAutoRange, @@ -81307,10 +82384,6 @@ function concatExtremes(gd, ax) { } function doAutoRange(gd, ax) { - if(!ax._length) ax.setScale(); - - var axIn; - if(ax.autorange) { ax.range = getAutoRange(gd, ax); @@ -81320,20 +82393,28 @@ function doAutoRange(gd, ax) { // doAutoRange will get called on fullLayout, // but we want to report its results back to layout - axIn = ax._input; + var axIn = ax._input; + + // before we edit _input, store preGUI values + var edits = {}; + edits[ax._attr + '.range'] = ax.range; + edits[ax._attr + '.autorange'] = ax.autorange; + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, edits); + axIn.range = ax.range.slice(); axIn.autorange = ax.autorange; } - if(ax._anchorAxis && ax._anchorAxis.rangeslider) { - var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name]; + var anchorAx = ax._anchorAxis; + + if(anchorAx && anchorAx.rangeslider) { + var axeRangeOpts = anchorAx.rangeslider[ax._name]; if(axeRangeOpts) { if(axeRangeOpts.rangemode === 'auto') { axeRangeOpts.range = getAutoRange(gd, ax); } } - axIn = ax._anchorAxis._input; - axIn.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); } } @@ -81551,7 +82632,7 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":420,"../../lib":441,"fast-isnumeric":149}],488:[function(_dereq_,module,exports){ +},{"../../constants/numerical":416,"../../lib":437,"../../registry":528,"fast-isnumeric":149}],484:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81711,6 +82792,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t ax.d2c(targetArray[i]); } } + // TODO what to do for transforms? } else { ax = axes.getFromTrace(gd, trace, d2cTarget); } @@ -81751,7 +82833,7 @@ axes.counterLetter = function(id) { axes.minDtick = function(ax, newDiff, newFirst, allow) { // doesn't make sense to do forced min dTick on log or category axes, // and the plot itself may decide to cancel (ie non-grouped bars) - if(['log', 'category'].indexOf(ax.type) !== -1 || !allow) { + if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; } // undefined means there's nothing there yet @@ -81783,18 +82865,15 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // save a copy of the initial axis ranges in fullLayout // use them in mode bar and dblclick events axes.saveRangeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._rangeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.range[0] === ax._rangeInitial[0] && - ax.range[1] === ax._rangeInitial[1] - ) + var hasChanged = isNew || !( + ax.range[0] === ax._rangeInitial[0] && + ax.range[1] === ax._rangeInitial[1] ); if((isNew && ax.autorange === false) || (overwrite && hasChanged)) { @@ -81808,21 +82887,16 @@ axes.saveRangeInitial = function(gd, overwrite) { // save a copy of the initial spike visibility axes.saveShowSpikeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false, - allSpikesEnabled = 'on'; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; + var allSpikesEnabled = 'on'; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._showSpikeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.showspikes === ax._showspikes - ) - ); + var hasChanged = isNew || !(ax.showspikes === ax._showspikes); - if((isNew) || (overwrite && hasChanged)) { + if(isNew || (overwrite && hasChanged)) { ax._showSpikeInitial = ax.showspikes; hasOneAxisChanged = true; } @@ -81839,7 +82913,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { var dataMin = Lib.aggNums(Math.min, null, data); var dataMax = Lib.aggNums(Math.max, null, data); - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { return { start: dataMin - 0.5, end: dataMax + 0.5, @@ -81857,8 +82931,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { type: 'linear', range: [dataMin, dataMax] }; - } - else { + } else { dummyAx = { type: ax.type, range: Lib.simpleMap([dataMin, dataMax], ax.c2r, 0, calendar), @@ -81943,10 +83016,10 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { - var edgecount = 0, - midcount = 0, - intcount = 0, - blankCount = 0; + var edgecount = 0; + var midcount = 0; + var intcount = 0; + var blankCount = 0; function nearEdge(v) { // is a value within 1% of a bin edge? @@ -82037,14 +83110,14 @@ axes.prepTicks = function(ax) { // calculate max number of (auto) ticks to display based on plot size if(ax.tickmode === 'auto' || !ax.dtick) { - var nt = ax.nticks, - minPx; + var nt = ax.nticks; + var minPx; + if(!nt) { - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; nt = ax._length / minPx; - } - else { + } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; nt = Lib.constrain(ax._length / minPx, 4, 9) + 1; } @@ -82106,7 +83179,7 @@ axes.calcTicks = function calcTicks(ax) { // return the full set of tick vals var vals = []; - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { endTick = (axrev) ? Math.max(-0.5, endTick) : Math.min(ax._categories.length - 0.5, endTick); } @@ -82150,23 +83223,22 @@ axes.calcTicks = function calcTicks(ax) { }; function arrayTicks(ax) { - var vals = ax.tickvals, - text = ax.ticktext, - ticksOut = new Array(vals.length), - rng = Lib.simpleMap(ax.range, ax.r2l), - r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001, - r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001, - tickMin = Math.min(r0expanded, r1expanded), - tickMax = Math.max(r0expanded, r1expanded), - vali, - i, - j = 0; + var vals = ax.tickvals; + var text = ax.ticktext; + var ticksOut = new Array(vals.length); + var rng = Lib.simpleMap(ax.range, ax.r2l); + var r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001; + var r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001; + var tickMin = Math.min(r0expanded, r1expanded); + var tickMax = Math.max(r0expanded, r1expanded); + var j = 0; // without a text array, just format the given values as any other ticks // except with more precision to the numbers if(!Array.isArray(text)) text = []; // make sure showing ticks doesn't accidentally add new categories + // TODO multicategory, if we allow ticktext / tickvals var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; // array ticks on log axes always show the full number @@ -82175,8 +83247,8 @@ function arrayTicks(ax) { ax.dtick = 'L' + Math.pow(10, Math.floor(Math.min(ax.range[0], ax.range[1])) - 1); } - for(i = 0; i < vals.length; i++) { - vali = tickVal2l(vals[i]); + for(var i = 0; i < vals.length; i++) { + var vali = tickVal2l(vals[i]); if(vali > tickMin && vali < tickMax) { if(text[i] === undefined) ticksOut[j] = axes.tickText(ax, vali); else ticksOut[j] = tickTextObj(ax, vali, String(text[i])); @@ -82189,17 +83261,17 @@ function arrayTicks(ax) { return ticksOut; } -var roundBase10 = [2, 5, 10], - roundBase24 = [1, 2, 3, 6, 12], - roundBase60 = [1, 2, 5, 10, 15, 30], - // 2&3 day ticks are weird, but need something btwn 1&7 - roundDays = [1, 2, 3, 7, 14], - // approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) - // these don't have to be exact, just close enough to round to the right value - roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1], - roundLog2 = [-0.301, 0, 0.301, 0.699, 1], - // N.B. `thetaunit; 'radians' angular axes must be converted to degrees - roundAngles = [15, 30, 45, 90, 180]; +var roundBase10 = [2, 5, 10]; +var roundBase24 = [1, 2, 3, 6, 12]; +var roundBase60 = [1, 2, 5, 10, 15, 30]; +// 2&3 day ticks are weird, but need something btwn 1&7 +var roundDays = [1, 2, 3, 7, 14]; +// approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) +// these don't have to be exact, just close enough to round to the right value +var roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1]; +var roundLog2 = [-0.301, 0, 0.301, 0.699, 1]; +// N.B. `thetaunit; 'radians' angular axes must be converted to degrees +var roundAngles = [15, 30, 45, 90, 180]; function roundDTick(roughDTick, base, roundingSet) { return base * Lib.roundUp(roughDTick / base, roundingSet); @@ -82290,7 +83362,7 @@ axes.autoTicks = function(ax, roughDTick) { ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } } - else if(ax.type === 'category') { + else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); } @@ -82330,7 +83402,7 @@ function autoTickRound(ax) { dtick = 1; } - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { ax._tickround = null; } if(ax.type === 'date') { @@ -82422,36 +83494,34 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { // calculate the first tick on an axis axes.tickFirst = function(ax) { - var r2l = ax.r2l || Number, - rng = Lib.simpleMap(ax.range, r2l), - axrev = rng[1] < rng[0], - sRound = axrev ? Math.floor : Math.ceil, - // add a tiny extra bit to make sure we get ticks - // that may have been rounded out - r0 = rng[0] * 1.0001 - rng[1] * 0.0001, - dtick = ax.dtick, - tick0 = r2l(ax.tick0); + var r2l = ax.r2l || Number; + var rng = Lib.simpleMap(ax.range, r2l); + var axrev = rng[1] < rng[0]; + var sRound = axrev ? Math.floor : Math.ceil; + // add a tiny extra bit to make sure we get ticks + // that may have been rounded out + var r0 = rng[0] * 1.0001 - rng[1] * 0.0001; + var dtick = ax.dtick; + var tick0 = r2l(ax.tick0); if(isNumeric(dtick)) { var tmin = sRound((r0 - tick0) / dtick) * dtick + tick0; // make sure no ticks outside the category list - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { tmin = Lib.constrain(tmin, 0, ax._categories.length - 1); } return tmin; } - var tType = dtick.charAt(0), - dtNum = Number(dtick.substr(1)); + var tType = dtick.charAt(0); + var dtNum = Number(dtick.substr(1)); // Dates: months (or years) if(tType === 'M') { - var cnt = 0, - t0 = tick0, - t1, - mult, - newDTick; + var cnt = 0; + var t0 = tick0; + var t1, mult, newDTick; // This algorithm should work for *any* nonlinear (but close to linear!) // tick spacing. Limit to 10 iterations, for gregorian months it's normally <=3. @@ -82493,16 +83563,18 @@ axes.tickFirst = function(ax) { // hover is a (truthy) flag for whether to show numbers with a bit // more precision for hovertext axes.tickText = function(ax, x, hover) { - var out = tickTextObj(ax, x), - hideexp, - arrayMode = ax.tickmode === 'array', - extraPrecision = hover || arrayMode, - i, - tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; + var out = tickTextObj(ax, x); + var arrayMode = ax.tickmode === 'array'; + var extraPrecision = hover || arrayMode; + var axType = ax.type; + // TODO multicategory, if we allow ticktext / tickvals + var tickVal2l = axType === 'category' ? ax.d2l_noadd : ax.d2l; + var i; if(arrayMode && Array.isArray(ax.ticktext)) { - var rng = Lib.simpleMap(ax.range, ax.r2l), - minDiff = Math.abs(rng[1] - rng[0]) / 10000; + var rng = Lib.simpleMap(ax.range, ax.r2l); + var minDiff = Math.abs(rng[1] - rng[0]) / 10000; + for(i = 0; i < ax.ticktext.length; i++) { if(Math.abs(x - tickVal2l(ax.tickvals[i])) < minDiff) break; } @@ -82513,28 +83585,25 @@ axes.tickText = function(ax, x, hover) { } function isHidden(showAttr) { - var first_or_last; - if(showAttr === undefined) return true; if(hover) return showAttr === 'none'; - first_or_last = { + var firstOrLast = { first: ax._tmin, last: ax._tmax }[showAttr]; - return showAttr !== 'all' && x !== first_or_last; + return showAttr !== 'all' && x !== firstOrLast; } - if(hover) { - hideexp = 'never'; - } else { - hideexp = ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - } + var hideexp = hover ? + 'never' : + ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - if(ax.type === 'date') formatDate(ax, out, hover, extraPrecision); - else if(ax.type === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); - else if(ax.type === 'category') formatCategory(ax, out); + if(axType === 'date') formatDate(ax, out, hover, extraPrecision); + else if(axType === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); + else if(axType === 'category') formatCategory(ax, out); + else if(axType === 'multicategory') formatMultiCategory(ax, out, hover); else if(isAngular(ax)) formatAngle(ax, out, hover, extraPrecision, hideexp); else formatLinear(ax, out, hover, extraPrecision, hideexp); @@ -82542,6 +83611,20 @@ axes.tickText = function(ax, x, hover) { if(ax.tickprefix && !isHidden(ax.showtickprefix)) out.text = ax.tickprefix + out.text; if(ax.ticksuffix && !isHidden(ax.showticksuffix)) out.text += ax.ticksuffix; + // Setup ticks and grid lines boundaries + // at 1/2 a 'category' to the left/bottom + if(ax.tickson === 'boundaries' || ax.showdividers) { + var inbounds = function(v) { + var p = ax.l2p(v); + return p >= 0 && p <= ax._length ? v : null; + }; + + out.xbnd = [ + inbounds(out.x - 0.5), + inbounds(out.x + ax.dtick - 0.5) + ]; + } + return out; }; @@ -82591,8 +83674,8 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround, - fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); + var tr = ax._tickround; + var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); if(extraPrecision) { // second or sub-second precision: extra always shows max digits. @@ -82601,8 +83684,8 @@ function formatDate(ax, out, hover, extraPrecision) { else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr]; } - var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat), - headStr; + var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat); + var headStr; var splitIndex = dateStr.indexOf('\n'); if(splitIndex !== -1) { @@ -82719,6 +83802,22 @@ function formatCategory(ax, out) { out.text = String(tt); } +function formatMultiCategory(ax, out, hover) { + var v = Math.round(out.x); + var cats = ax._categories[v] || []; + var tt = cats[1] === undefined ? '' : String(cats[1]); + var tt2 = cats[0] === undefined ? '' : String(cats[0]); + + if(hover) { + // TODO is this what we want? + out.text = tt2 + ' - ' + tt; + } else { + // setup for secondary labels + out.text = tt; + out.text2 = tt2; + } +} + function formatLinear(ax, out, hover, extraPrecision, hideexp) { if(hideexp === 'never') { // If this is a hover label, then we must *never* hide the exponent @@ -82824,14 +83923,13 @@ function beyondSI(exponent) { } function numFormat(v, ax, fmtoverride, hover) { - // negative? - var isNeg = v < 0, - // max number of digits past decimal point to show - tickRound = ax._tickround, - exponentFormat = fmtoverride || ax.exponentformat || 'B', - exponent = ax._tickexponent, - tickformat = axes.getTickFormat(ax), - separatethousands = ax.separatethousands; + var isNeg = v < 0; + // max number of digits past decimal point to show + var tickRound = ax._tickround; + var exponentFormat = fmtoverride || ax.exponentformat || 'B'; + var exponent = ax._tickexponent; + var tickformat = axes.getTickFormat(ax); + var separatethousands = ax.separatethousands; // special case for hover: set exponent just for this value, and // add a couple more digits of precision over tick labels @@ -83004,6 +84102,9 @@ axes.getTickFormat = function(ax) { // as an array of items like 'xy', 'x2y', 'x2y2'... // sorted by x (x,x2,x3...) then y // optionally restrict to only subplots containing axis object ax +// +// NOTE: this is currently only used OUTSIDE plotly.js (toolpanel, webapp) +// ideally we get rid of it there (or just copy this there) and remove it here axes.getSubplots = function(gd, ax) { var subplotObj = gd._fullLayout._subplots; var allSubplots = subplotObj.cartesian.concat(subplotObj.gl2d || []); @@ -83022,18 +84123,20 @@ axes.getSubplots = function(gd, ax) { }; // find all subplots with axis 'ax' +// NOTE: this is only used in axes.getSubplots (only used outside plotly.js) and +// gl2d/convert (where it restricts axis subplots to only those with gl2d) axes.findSubplotsWithAxis = function(subplots, ax) { var axMatch = new RegExp( (ax._id.charAt(0) === 'x') ? ('^' + ax._id + 'y') : (ax._id + '$') ); - var subplotsWithAxis = []; + var subplotsWithAx = []; for(var i = 0; i < subplots.length; i++) { var sp = subplots[i]; - if(axMatch.test(sp)) subplotsWithAxis.push(sp); + if(axMatch.test(sp)) subplotsWithAx.push(sp); } - return subplotsWithAxis; + return subplotsWithAx; }; // makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings @@ -83064,760 +84167,1148 @@ axes.makeClipPaths = function(gd) { var axClips = fullLayout._clips.selectAll('.axesclip') .data(clipList, function(d) { return d.x._id + d.y._id; }); - axClips.enter().append('clipPath') - .classed('axesclip', true) - .attr('id', function(d) { return 'clip' + fullLayout._uid + d.x._id + d.y._id; }) - .append('rect'); + axClips.enter().append('clipPath') + .classed('axesclip', true) + .attr('id', function(d) { return 'clip' + fullLayout._uid + d.x._id + d.y._id; }) + .append('rect'); + + axClips.exit().remove(); + + axClips.each(function(d) { + d3.select(this).select('rect').attr({ + x: d.x._offset || 0, + y: d.y._offset || 0, + width: d.x._length || 1, + height: d.y._length || 1 + }); + }); +}; + +/** + * Main multi-axis drawing routine! + * + * @param {DOM element} gd : graph div + * @param {string or array of strings} arg : polymorphic argument + * @param {object} opts: + * - @param {boolean} skipTitle : optional flag to skip axis title draw/update + * + * Signature 1: Axes.draw(gd, 'redraw') + * use this to clear and redraw all axes on graph + * + * Signature 2: Axes.draw(gd, '') + * use this to draw all axes on graph w/o the selectAll().remove() + * of the 'redraw' signature + * + * Signature 3: Axes.draw(gd, [axId, axId2, ...]) + * where the items are axis id string, + * use this to update multiple axes in one call + * + * N.B draw updates: + * - ax._r (stored range for use by zoom/pan) + * - ax._rl (stored linearized range for use by zoom/pan) + */ +axes.draw = function(gd, arg, opts) { + var fullLayout = gd._fullLayout; + + if(arg === 'redraw') { + fullLayout._paper.selectAll('g.subplot').each(function(d) { + var id = d[0]; + var plotinfo = fullLayout._plots[id]; + var xa = plotinfo.xaxis; + var ya = plotinfo.yaxis; + + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); + plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove(); + if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); + if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); + fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); + fullLayout._infolayer.select('.g-' + ya._id + 'title').remove(); + }); + } + + var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; + + return Lib.syncOrAsync(axList.map(function(axId) { + return function() { + if(!axId) return; + + var ax = axes.getFromId(gd, axId); + var axDone = axes.drawOne(gd, ax, opts); + + ax._r = ax.range.slice(); + ax._rl = Lib.simpleMap(ax._r, ax.r2l); + + return axDone; + }; + })); +}; + +/** + * Draw one cartesian axis + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * @param {object} opts + * - @param {boolean} skipTitle (set to true to skip axis title draw call) + */ +axes.drawOne = function(gd, ax, opts) { + opts = opts || {}; + + var i, sp, plotinfo; + + ax.setScale(); + + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var counterLetter = axes.counterLetter(axId); + var mainSubplot = ax._mainSubplot; + var mainLinePosition = ax._mainLinePosition; + var mainMirrorPosition = ax._mainMirrorPosition; + var mainPlotinfo = fullLayout._plots[mainSubplot]; + var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; + var subplotsWithAx = ax._subplotsWith; + + var vals = ax._vals = axes.calcTicks(ax); + + // Add a couple of axis properties that should cause us to recreate + // elements. Used in d3 data function. + var axInfo = [ax.mirror, mainLinePosition, mainMirrorPosition].join('_'); + for(i = 0; i < vals.length; i++) { + vals[i].axInfo = axInfo; + } + + if(!ax.visible) return; + + // stash selections to avoid DOM queries e.g. + // - stash tickLabels selection, so that drawTitle can use it to scoot title + ax._selections = {}; + // stash tick angle (including the computed 'auto' values) per tick-label class + ax._tickAngles = {}; + + var transFn = axes.makeTransFn(ax); + var tickVals; + // We remove zero lines, grid lines, and inside ticks if they're within 1px of the end + // The key case here is removing zero lines when the axis bound is zero + var valsClipped; + + if(ax.tickson === 'boundaries') { + var boundaryVals = getBoundaryVals(ax, vals); + valsClipped = axes.clipEnds(ax, boundaryVals); + tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals; + } else { + valsClipped = axes.clipEnds(ax, vals); + tickVals = ax.ticks === 'inside' ? valsClipped : vals; + } + + var gridVals = ax._gridVals = valsClipped; + var dividerVals = getDividerVals(ax, vals); + + if(!fullLayout._hasOnlyLargeSploms) { + // keep track of which subplots (by main conteraxis) we've already + // drawn grids for, so we don't overdraw overlaying subplots + var finishedGrids = {}; + + for(i = 0; i < subplotsWithAx.length; i++) { + sp = subplotsWithAx[i]; + plotinfo = fullLayout._plots[sp]; + + var counterAxis = plotinfo[counterLetter + 'axis']; + var mainCounterID = counterAxis._mainAxis._id; + if(finishedGrids[mainCounterID]) continue; + finishedGrids[mainCounterID] = 1; + + var gridPath = axLetter === 'x' ? + 'M0,' + counterAxis._offset + 'v' + counterAxis._length : + 'M' + counterAxis._offset + ',0h' + counterAxis._length; + + axes.drawGrid(gd, ax, { + vals: gridVals, + counterAxis: counterAxis, + layer: plotinfo.gridlayer.select('.' + axId), + path: gridPath, + transFn: transFn + }); + axes.drawZeroLine(gd, ax, { + counterAxis: counterAxis, + layer: plotinfo.zerolinelayer, + path: gridPath, + transFn: transFn + }); + } + } + + var tickSigns = axes.getTickSigns(ax); + var tickSubplots = []; + + if(ax.ticks) { + var mainTickPath = axes.makeTickPath(ax, mainLinePosition, tickSigns[2]); + var mirrorTickPath; + var fullTickPath; + if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { + mirrorTickPath = axes.makeTickPath(ax, mainMirrorPosition, tickSigns[3]); + fullTickPath = mainTickPath + mirrorTickPath; + } else { + mirrorTickPath = ''; + fullTickPath = mainTickPath; + } + + var tickPath; + if(ax.showdividers && ax.ticks === 'outside' && ax.tickson === 'boundaries') { + var dividerLookup = {}; + for(i = 0; i < dividerVals.length; i++) { + dividerLookup[dividerVals[i].x] = 1; + } + tickPath = function(d) { + return dividerLookup[d.x] ? mirrorTickPath : fullTickPath; + }; + } else { + tickPath = fullTickPath; + } + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: mainAxLayer, + path: tickPath, + transFn: transFn + }); + + tickSubplots = Object.keys(ax._linepositions || {}); + } + + for(i = 0; i < tickSubplots.length; i++) { + sp = tickSubplots[i]; + plotinfo = fullLayout._plots[sp]; + // [bottom or left, top or right], free and main are handled above + var linepositions = ax._linepositions[sp] || []; + var spTickPath = axes.makeTickPath(ax, linepositions[0], tickSigns[0]) + + axes.makeTickPath(ax, linepositions[1], tickSigns[1]); + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: plotinfo[axLetter + 'axislayer'], + path: spTickPath, + transFn: transFn + }); + } + + var seq = []; + + // tick labels - for now just the main labels. + // TODO: mirror labels, esp for subplots + + seq.push(function() { + var labelFns = axes.makeLabelFns(ax, mainLinePosition); + return axes.drawLabels(gd, ax, { + vals: vals, + layer: mainAxLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn, + }); + }); + + if(ax.type === 'multicategory') { + var labelLength = 0; + var pad = {x: 2, y: 10}[axLetter]; + var sgn = tickSigns[2] * (ax.ticks === 'inside' ? -1 : 1); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick') + pad; + labelLength += ax._tickAngles[axId + 'tick'] ? ax.tickfont.size * LINE_SPACING : 0; + var secondaryPosition = mainLinePosition + labelLength * sgn; + var secondaryLabelFns = axes.makeLabelFns(ax, secondaryPosition); + + return axes.drawLabels(gd, ax, { + vals: getSecondaryLabelVals(ax, vals), + layer: mainAxLayer, + cls: axId + 'tick2', + repositionOnUpdate: true, + secondary: true, + transFn: transFn, + labelXFn: secondaryLabelFns.labelXFn, + labelYFn: secondaryLabelFns.labelYFn, + labelAnchorFn: secondaryLabelFns.labelAnchorFn, + }); + }); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick2'); + ax._labelLength = labelLength; + + return drawDividers(gd, ax, { + vals: dividerVals, + layer: mainAxLayer, + path: axes.makeTickPath(ax, mainLinePosition, sgn, labelLength), + transFn: transFn + }); + }); + } + + function extendRange(range, newRange) { + range[0] = Math.min(range[0], newRange[0]); + range[1] = Math.max(range[1], newRange[1]); + } + + function calcBoundingBox() { + if(ax.showticklabels) { + var gdBB = gd.getBoundingClientRect(); + var bBox = mainAxLayer.node().getBoundingClientRect(); + + /* + * the way we're going to use this, the positioning that matters + * is relative to the origin of gd. This is important particularly + * if gd is scrollable, and may have been scrolled between the time + * we calculate this and the time we use it + */ + + ax._boundingBox = { + width: bBox.width, + height: bBox.height, + left: bBox.left - gdBB.left, + right: bBox.right - gdBB.left, + top: bBox.top - gdBB.top, + bottom: bBox.bottom - gdBB.top + }; + } else { + var gs = fullLayout._size; + var pos; + + // set dummy bbox for ticklabel-less axes + + if(axLetter === 'x') { + pos = ax.anchor === 'free' ? + gs.t + gs.h * (1 - ax.position) : + gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); + + ax._boundingBox = { + top: pos, + bottom: pos, + left: ax._offset, + right: ax._offset + ax._length, + width: ax._length, + height: 0 + }; + } else { + pos = ax.anchor === 'free' ? + gs.l + gs.w * ax.position : + gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; + + ax._boundingBox = { + left: pos, + right: pos, + bottom: ax._offset + ax._length, + top: ax._offset, + height: ax._length, + width: 0 + }; + } + } + + /* + * for spikelines: what's the full domain of positions in the + * opposite direction that are associated with this axis? + * This means any axes that we make a subplot with, plus the + * position of the axis itself if it's free. + */ + if(subplotsWithAx) { + var fullRange = ax._counterSpan = [Infinity, -Infinity]; + + for(var i = 0; i < subplotsWithAx.length; i++) { + var plotinfo = fullLayout._plots[subplotsWithAx[i]]; + var counterAxis = plotinfo[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + + extendRange(fullRange, [ + counterAxis._offset, + counterAxis._offset + counterAxis._length + ]); + } + + if(ax.anchor === 'free') { + extendRange(fullRange, (axLetter === 'x') ? + [ax._boundingBox.bottom, ax._boundingBox.top] : + [ax._boundingBox.right, ax._boundingBox.left]); + } + } + } + + var hasRangeSlider = Registry.getComponentMethod('rangeslider', 'isVisible')(ax); + + function doAutoMargins() { + var push, rangeSliderPush; + + if(hasRangeSlider) { + rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); + } + Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); + + var s = ax.side.charAt(0); + if(ax.automargin && (!hasRangeSlider || s !== 'b')) { + push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + + if(axLetter === 'x') { + push.y = (ax.anchor === 'free' ? ax.position : + ax._anchorAxis.domain[s === 't' ? 1 : 0]); + push[s] += ax._boundingBox.height; + } else { + push.x = (ax.anchor === 'free' ? ax.position : + ax._anchorAxis.domain[s === 'r' ? 1 : 0]); + push[s] += ax._boundingBox.width; + } + + if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { + push[s] += ax.title.font.size; + } + } + + Plots.autoMargin(gd, axAutoMarginID(ax), push); + } + + seq.push(calcBoundingBox, doAutoMargins); + + if(!opts.skipTitle && + !(hasRangeSlider && ax._boundingBox && ax.side === 'bottom') + ) { + seq.push(function() { return drawTitle(gd, ax); }); + } + + return Lib.syncOrAsync(seq); +}; + +function getBoundaryVals(ax, vals) { + var out = []; + var i; + + // boundaryVals are never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; + + if(vals.length) { + for(i = 0; i < vals.length; i++) { + _push(vals[i], 0); + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getSecondaryLabelVals(ax, vals) { + var out = []; + var lookup = {}; + + for(var i = 0; i < vals.length; i++) { + var d = vals[i]; + if(lookup[d.text2]) { + lookup[d.text2].push(d.x); + } else { + lookup[d.text2] = [d.x]; + } + } - axClips.exit().remove(); + for(var k in lookup) { + out.push(tickTextObj(ax, Lib.interp(lookup[k], 0.5), k)); + } - axClips.each(function(d) { - d3.select(this).select('rect').attr({ - x: d.x._offset || 0, - y: d.y._offset || 0, - width: d.x._length || 1, - height: d.y._length || 1 - }); - }); -}; + return out; +} -/** - * Main multi-axis drawing routine! - * - * @param {DOM element} gd : graph div - * @param {string or array of strings} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * - * Signature 1: Axes.doTicks(gd, 'redraw') - * use this to clear and redraw all axes on graph - * - * Signature 2: Axes.doTicks(gd, '') - * use this to draw all axes on graph w/o the selectAll().remove() - * of the 'redraw' signature - * - * Signature 3: Axes.doTicks(gd, [axId, axId2, ...]) - * where the items are axis id string, - * use this to update multiple axes in one call - * - * N.B doTicks updates: - * - ax._r (stored range for use by zoom/pan) - * - ax._rl (stored linearized range for use by zoom/pan) - */ -axes.doTicks = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; +function getDividerVals(ax, vals) { + var out = []; + var i, current; - if(arg === 'redraw') { - fullLayout._paper.selectAll('g.subplot').each(function(d) { - var id = d[0]; - var plotinfo = fullLayout._plots[id]; - var xa = plotinfo.xaxis; - var ya = plotinfo.yaxis; + // never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; - plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); - plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); - if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); - if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); - fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); - fullLayout._infolayer.select('.g-' + ya._id + 'title').remove(); - }); + if(ax.showdividers && vals.length) { + for(i = 0; i < vals.length; i++) { + var d = vals[i]; + if(d.text2 !== current) { + _push(d, 0); + } + current = d.text2; + } + _push(vals[i - 1], 1); } - var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; - - Lib.syncOrAsync(axList.map(function(axid) { - return function() { - if(!axid) return; + return out; +} - var axDone = axes.doTicksSingle(gd, axid, skipTitle); +function getLabelLevelSpan(ax, cls) { + var axLetter = ax._id.charAt(0); + var angle = ax._tickAngles[cls] || 0; + var rad = Lib.deg2rad(angle); + var sinA = Math.sin(rad); + var cosA = Math.cos(rad); + var maxX = 0; + var maxY = 0; + + // N.B. Drawing.bBox does not take into account rotate transforms + + ax._selections[cls].each(function() { + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + var w = bb.width; + var h = bb.height; + maxX = Math.max(maxX, cosA * w, sinA * h); + maxY = Math.max(maxY, sinA * w, cosA * h); + }); - var ax = axes.getFromId(gd, axid); - ax._r = ax.range.slice(); - ax._rl = Lib.simpleMap(ax._r, ax.r2l); + return {x: maxY, y: maxX}[axLetter]; +} - return axDone; - }; - })); +/** + * Which direction do the 'ax.side' values, and free ticks go? + * + * @param {object} ax (full) axis object + * - {string} _id (starting with 'x' or 'y') + * - {string} side + * - {string} ticks + * @return {array} all entries are either -1 or 1 + * - [0]: sign for top/right ticks (i.e. negative SVG direction) + * - [1]: sign for bottom/left ticks (i.e. positive SVG direction) + * - [2]: sign for ticks corresponding to 'ax.side' + * - [3]: sign for ticks mirroring 'ax.side' + */ +axes.getTickSigns = function(ax) { + var axLetter = ax._id.charAt(0); + var sideOpposite = {x: 'top', y: 'right'}[axLetter]; + var main = ax.side === sideOpposite ? 1 : -1; + var out = [-1, 1, main, -main]; + // then we flip if outside XOR y axis + if((ax.ticks !== 'inside') === (axLetter === 'x')) { + out = out.map(function(v) { return -v; }); + } + return out; }; /** - * Per-axis drawing routine! - * - * This routine draws axis ticks and much more (... grids, labels, title etc.) - * Supports multiple argument signatures. - * N.B. this thing is async in general (because of MathJax rendering) - * - * @param {DOM element} gd : graph div - * @param {string or object} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * @return {promise} + * Make axis translate transform function * - * Signature 1: Axes.doTicks(gd, ax) - * where ax is an axis object as in fullLayout + * @param {object} ax (full) axis object + * - {string} _id + * - {number} _offset + * - {fn} l2p + * @return {fn} function of calcTicks items + */ +axes.makeTransFn = function(ax) { + var axLetter = ax._id.charAt(0); + var offset = ax._offset; + return axLetter === 'x' ? + function(d) { return 'translate(' + (offset + ax.l2p(d.x)) + ',0)'; } : + function(d) { return 'translate(0,' + (offset + ax.l2p(d.x)) + ')'; }; +}; + +/** + * Make axis tick path string * - * Signature 2: Axes.doTicks(gd, axId) - * where axId is a axis id string + * @param {object} ax (full) axis object + * - {string} _id + * - {number} ticklen + * - {number} linewidth + * @param {number} shift along direction of ticklen + * @param {1 or -1} sng tick sign + * @param {number (optional)} len tick length + * @return {string} */ -axes.doTicksSingle = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; - var independent = false; - var ax; +axes.makeTickPath = function(ax, shift, sgn, len) { + len = len !== undefined ? len : ax.ticklen; - if(Lib.isPlainObject(arg)) { - ax = arg; - independent = true; - } else { - ax = axes.getFromId(gd, arg); - } + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; - // set scaling to pixels - ax.setScale(); + return axLetter === 'x' ? + 'M0,' + (shift + pad * sgn) + 'v' + (len * sgn) : + 'M' + (shift + pad * sgn) + ',0h' + (len * sgn); +}; - var axid = ax._id; - var axLetter = axid.charAt(0); - var counterLetter = axes.counterLetter(axid); - var vals = ax._vals = axes.calcTicks(ax); - var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; - var tcls = axid + 'tick'; - var gcls = axid + 'grid'; - var zcls = axid + 'zl'; +/** + * Make axis tick label x, y and anchor functions + * + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} ticklen + * - {string} side + * - {number} linewidth + * - {number} tickfont.size + * - {boolean} showline + * @param {number} shift + * @param {number} angle [in degrees] ... + * @return {object} + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + * - {number} labelStandoff + * - {number} labelShift + */ +axes.makeLabelFns = function(ax, shift, angle) { + var axLetter = ax._id.charAt(0); var pad = (ax.linewidth || 1) / 2; - var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); + var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside'; + + var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0; var labelShift = 0; - var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); - var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); - var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); - var sides, transfn, tickpathfn, subplots; - var tickLabels; - var i; - if(ax._counterangle && ax.ticks === 'outside') { - var caRad = ax._counterangle * Math.PI / 180; - labelStandoff = ax.ticklen * Math.cos(caRad) + 1; - labelShift = ax.ticklen * Math.sin(caRad); + if(angle && ax.ticks === 'outside') { + var rad = Lib.deg2rad(angle); + labelStandoff = ax.ticklen * Math.cos(rad) + 1; + labelShift = ax.ticklen * Math.sin(rad); } - if(ax.showticklabels && (ax.ticks === 'outside' || ax.showline)) { + if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) { labelStandoff += 0.2 * ax.tickfont.size; } - // positioning arguments for x vs y axes + // Used in polar angular label x/y functions + // TODO generalize makeLabelFns so that it just work for angular axes + var out = { + labelStandoff: labelStandoff, + labelShift: labelShift + }; + + var x0, y0, ff, flipIt; if(axLetter === 'x') { - sides = ['bottom', 'top']; - transfn = ax._transfn || function(d) { - return 'translate(' + (ax._offset + ax.l2p(d.x)) + ',0)'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M0,' + shift + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len); - } - else return 'M0,' + shift + 'v' + len; - }; - } - else if(axLetter === 'y') { - sides = ['left', 'right']; - transfn = ax._transfn || function(d) { - return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M' + shift + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); - } - else return 'M' + shift + ',0h' + len; + flipIt = ax.side === 'bottom' ? 1 : -1; + x0 = labelShift * flipIt; + y0 = shift + (labelStandoff + pad) * flipIt; + ff = ax.side === 'bottom' ? 1 : -0.2; + + out.labelXFn = function(d) { return d.dx + x0; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * ff; }; + out.labelAnchorFn = function(a) { + if(!isNumeric(a) || a === 0 || a === 180) { + return 'middle'; + } + return (a * flipIt < 0) ? 'end' : 'start'; }; - } - else if(isAngular(ax)) { - sides = ['left', 'right']; - transfn = ax._transfn; - tickpathfn = function(shift, len) { - return 'M' + shift + ',0h' + len; + } else if(axLetter === 'y') { + flipIt = ax.side === 'right' ? 1 : -1; + x0 = labelStandoff + pad; + y0 = -labelShift * flipIt; + ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0; + + out.labelXFn = function(d) { return d.dx + shift + (x0 + d.fontSize * ff) * flipIt; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; }; + out.labelAnchorFn = function(a) { + if(isNumeric(a) && Math.abs(a) === 90) { + return 'middle'; + } + return ax.side === 'right' ? 'start' : 'end'; }; } - else { - Lib.warn('Unrecognized doTicks axis:', axid); - return; - } - var axside = ax.side || sides[0]; - // which direction do the side[0], side[1], and free ticks go? - // then we flip if outside XOR y axis - var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; - if((ax.ticks !== 'inside') === (axLetter === 'x')) { - ticksign = ticksign.map(function(v) { return -v; }); - } + return out; +}; - if(!ax.visible) return; +function tickDataFn(d) { + return [d.text, d.x, d.axInfo, d.font, d.fontSize, d.fontColor].join('_'); +} - if(ax._tickFilter) { - vals = vals.filter(ax._tickFilter); - } +/** + * Draw axis ticks + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} linewidth + * - {string} tickcolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawTicks = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'tick'; + + var ticks = opts.layer.selectAll('path.' + cls) + .data(ax.ticks ? opts.vals : [], tickDataFn); + + ticks.exit().remove(); + + ticks.enter().append('path') + .classed(cls, 1) + .classed('ticks', 1) + .classed('crisp', opts.crisp !== false) + .call(Color.stroke, ax.tickcolor) + .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') + .attr('d', opts.path); - // Remove zero lines, grid lines, and inside ticks if they're within - // 1 pixel of the end. - // The key case here is removing zero lines when the axis bound is zero. - // Don't clip angular values. - var valsClipped = ax._valsClipped = isAngular(ax) ? - vals : - vals.filter(function(d) { return clipEnds(ax, d.x); }); + ticks.attr('transform', opts.transFn); +}; - function drawTicks(container, tickpath) { - var ticks = container.selectAll('path.' + tcls) - .data(ax.ticks === 'inside' ? valsClipped : vals, datafn); +/** + * Draw axis grid + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showgrid + * - {string} gridcolor + * - {string} gridwidth + * - {boolean} zeroline + * - {string} type + * - {string} dtick + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * optional - only required if this axis supports zero lines + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawGrid = function(gd, ax, opts) { + opts = opts || {}; - if(tickpath && ax.ticks) { - ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) - .classed('crisp', 1) - .call(Color.stroke, ax.tickcolor) - .style('stroke-width', tickWidth + 'px') - .attr('d', tickpath); - ticks.attr('transform', transfn); - ticks.exit().remove(); + var cls = ax._id + 'grid'; + var vals = opts.vals; + var counterAx = opts.counterAxis; + if(ax.showgrid === false) { + vals = []; + } + else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + var isArrayMode = ax.tickmode === 'array'; + for(var i = 0; i < vals.length; i++) { + var xi = vals[i].x; + if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) { + vals = vals.slice(0, i).concat(vals.slice(i + 1)); + // In array mode you can in principle have multiple + // ticks at 0, so test them all. Otherwise once we found + // one we can stop. + if(isArrayMode) i--; + else break; + } } - else ticks.remove(); } - function drawLabels(container, position) { - // tick labels - for now just the main labels. - // TODO: mirror labels, esp for subplots - tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); + var grid = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); - if(!isNumeric(position)) { - tickLabels.remove(); - drawAxTitle(); - return; - } - if(!ax.showticklabels) { - tickLabels.remove(); - drawAxTitle(); - calcBoundingBox(); - return; - } + grid.exit().remove(); - var labelx, labely, labelanchor, labelpos0, flipit; - if(axLetter === 'x') { - flipit = (axside === 'bottom') ? 1 : -1; - labelx = function(d) { return d.dx + labelShift * flipit; }; - labelpos0 = position + (labelStandoff + pad) * flipit; - labely = function(d) { - return d.dy + labelpos0 + d.fontSize * - ((axside === 'bottom') ? 1 : -0.2); - }; - labelanchor = function(angle) { - if(!isNumeric(angle) || angle === 0 || angle === 180) { - return 'middle'; - } - return (angle * flipit < 0) ? 'end' : 'start'; - }; - } - else if(axLetter === 'y') { - flipit = (axside === 'right') ? 1 : -1; - labely = function(d) { - return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit; - }; - labelx = function(d) { - return d.dx + position + (labelStandoff + pad + - ((Math.abs(ax.tickangle) === 90) ? d.fontSize / 2 : 0)) * flipit; - }; - labelanchor = function(angle) { - if(isNumeric(angle) && Math.abs(angle) === 90) { - return 'middle'; - } - return axside === 'right' ? 'start' : 'end'; - }; - } - else if(isAngular(ax)) { - ax._labelShift = labelShift; - ax._labelStandoff = labelStandoff; - ax._pad = pad; - - labelx = ax._labelx; - labely = ax._labely; - labelanchor = ax._labelanchor; - } - - var maxFontSize = 0, - autoangle = 0, - labelsReady = []; - tickLabels.enter().append('g').classed(tcls, 1) - .append('text') - // only so tex has predictable alignment that we can - // alter later - .attr('text-anchor', 'middle') - .each(function(d) { - var thisLabel = d3.select(this), - newPromise = gd._promises.length; - thisLabel - .call(svgTextUtils.positionText, labelx(d), labely(d)) - .call(Drawing.font, d.font, d.fontSize, d.fontColor) - .text(d.text) - .call(svgTextUtils.convertToTspans, gd); - newPromise = gd._promises[newPromise]; - if(newPromise) { - // if we have an async label, we'll deal with that - // all here so take it out of gd._promises and - // instead position the label and promise this in - // labelsReady - labelsReady.push(gd._promises.pop().then(function() { - positionLabels(thisLabel, ax.tickangle); - })); - } - else { - // sync label: just position it now. - positionLabels(thisLabel, ax.tickangle); - } - }); - tickLabels.exit().remove(); + grid.enter().append('path') + .classed(cls, 1) + .classed('crisp', opts.crisp !== false); - tickLabels.each(function(d) { - maxFontSize = Math.max(maxFontSize, d.fontSize); - }); + ax._gw = Drawing.crispRound(gd, ax.gridwidth, 1); - if(isAngular(ax)) { - tickLabels.each(function(d) { - d3.select(this).select('text') - .call(svgTextUtils.positionText, labelx(d), labely(d)); - }); - } + grid.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.gridcolor || '#ddd') + .style('stroke-width', ax._gw + 'px'); - // How much to shift a multi-line label to center it vertically. - function getAnchorHeight(lineCount, lineHeight, angle) { - var h = (lineCount - 1) * lineHeight; - if(axLetter === 'x') { - if(angle < -60 || 60 < angle) { - return -0.5 * h; - } else if(axside === 'top') { - return -h; - } - } else { - angle *= axside === 'left' ? 1 : -1; - if(angle < -30) { - return -h; - } else if(angle < 30) { - return -0.5 * h; - } - } - return 0; - } - - function positionLabels(s, angle) { - s.each(function(d) { - var anchor = labelanchor(angle, d); - var thisLabel = d3.select(this), - mathjaxGroup = thisLabel.select('.text-math-group'), - transform = transfn.call(thisLabel.node(), d) + - ((isNumeric(angle) && +angle !== 0) ? - (' rotate(' + angle + ',' + labelx(d) + ',' + - (labely(d) - d.fontSize / 2) + ')') : - ''); - var anchorHeight = getAnchorHeight( - svgTextUtils.lineCount(thisLabel), - LINE_SPACING * d.fontSize, - isNumeric(angle) ? +angle : 0); - if(anchorHeight) { - transform += ' translate(0, ' + anchorHeight + ')'; - } - if(mathjaxGroup.empty()) { - thisLabel.select('text').attr({ - transform: transform, - 'text-anchor': anchor - }); - } - else { - var mjShift = - Drawing.bBox(mathjaxGroup.node()).width * - {end: -0.5, start: 0.5}[anchor]; - mathjaxGroup.attr('transform', transform + - (mjShift ? 'translate(' + mjShift + ',0)' : '')); - } - }); - } + if(typeof opts.path === 'function') grid.attr('d', opts.path); +}; - // make sure all labels are correctly positioned at their base angle - // the positionLabels call above is only for newly drawn labels. - // do this without waiting, using the last calculated angle to - // minimize flicker, then do it again when we know all labels are - // there, putting back the prescribed angle to check for overlaps. - positionLabels(tickLabels, ax._lastangle || ax.tickangle); - - function allLabelsReady() { - return labelsReady.length && Promise.all(labelsReady); - } - - function fixLabelOverlaps() { - positionLabels(tickLabels, ax.tickangle); - - // check for auto-angling if x labels overlap - // don't auto-angle at all for log axes with - // base and digit format - if(axLetter === 'x' && !isNumeric(ax.tickangle) && - (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')) { - var lbbArray = []; - tickLabels.each(function(d) { - var s = d3.select(this), - thisLabel = s.select('.text-math-group'), - x = ax.l2p(d.x); - if(thisLabel.empty()) thisLabel = s.select('text'); - - var bb = Drawing.bBox(thisLabel.node()); - - lbbArray.push({ - // ignore about y, just deal with x overlaps - top: 0, - bottom: 10, - height: 10, - left: x - bb.width / 2, - // impose a 2px gap - right: x + bb.width / 2 + 2, - width: bb.width + 2 - }); - }); - for(i = 0; i < lbbArray.length - 1; i++) { - if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { - // any overlap at all - set 30 degrees - autoangle = 30; - break; - } - } - if(autoangle) { - var tickspacing = Math.abs( - (vals[vals.length - 1].x - vals[0].x) * ax._m - ) / (vals.length - 1); - if(tickspacing < maxFontSize * 2.5) { - autoangle = 90; - } - positionLabels(tickLabels, autoangle); - } - ax._lastangle = autoangle; - } +/** + * Draw axis zero-line + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} zeroline + * - {number} zerolinewidth + * - {string} zerolinecolor + * - {number (optional)} _gridWidthCrispRound + * @param {object} opts + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawZeroLine = function(gd, ax, opts) { + opts = opts || opts; - // update the axis title - // (so it can move out of the way if needed) - // TODO: separate out scoot so we don't need to do - // a full redraw of the title (mostly relevant for MathJax) - drawAxTitle(); - return axid + ' done'; - } + var cls = ax._id + 'zl'; + var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis); - function calcBoundingBox() { - if(ax.showticklabels) { - var gdBB = gd.getBoundingClientRect(); - var bBox = container.node().getBoundingClientRect(); + var zl = opts.layer.selectAll('path.' + cls) + .data(show ? [{x: 0, id: ax._id}] : []); - /* - * the way we're going to use this, the positioning that matters - * is relative to the origin of gd. This is important particularly - * if gd is scrollable, and may have been scrolled between the time - * we calculate this and the time we use it - */ + zl.exit().remove(); - ax._boundingBox = { - width: bBox.width, - height: bBox.height, - left: bBox.left - gdBB.left, - right: bBox.right - gdBB.left, - top: bBox.top - gdBB.top, - bottom: bBox.bottom - gdBB.top - }; - } else { - var gs = fullLayout._size; - var pos; + zl.enter().append('path') + .classed(cls, 1) + .classed('zl', 1) + .classed('crisp', opts.crisp !== false) + .each(function() { + // use the fact that only one element can enter to trigger a sort. + // If several zerolines enter at the same time we will sort once per, + // but generally this should be a minimal overhead. + opts.layer.selectAll('path').sort(function(da, db) { + return axisIds.idSort(da.id, db.id); + }); + }); - // set dummy bbox for ticklabel-less axes + zl.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); +}; - if(axLetter === 'x') { - pos = ax.anchor === 'free' ? - gs.t + gs.h * (1 - ax.position) : - gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); - - ax._boundingBox = { - top: pos, - bottom: pos, - left: ax._offset, - right: ax._offset + ax._length, - width: ax._length, - height: 0 - }; - } else { - pos = ax.anchor === 'free' ? - gs.l + gs.w * ax.position : - gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - - ax._boundingBox = { - left: pos, - right: pos, - bottom: ax._offset + ax._length, - top: ax._offset, - height: ax._length, - width: 0 - }; - } - } +/** + * Draw axis tick labels + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showticklabels + * - {number} tickangle + * - {object (optional)} _selections + * - {object} (optional)} _tickAngles + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string (optional)} cls (node className) + * - {boolean} repositionOnUpdate (set to true to reposition update selection) + * - {boolean} secondary + * - {fn} transFn + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + */ +axes.drawLabels = function(gd, ax, opts) { + opts = opts || {}; - /* - * for spikelines: what's the full domain of positions in the - * opposite direction that are associated with this axis? - * This means any axes that we make a subplot with, plus the - * position of the axis itself if it's free. - */ - if(subplots) { - var fullRange = ax._counterSpan = [Infinity, -Infinity]; + var axId = ax._id; + var axLetter = axId.charAt(0); + var cls = opts.cls || axId + 'tick'; + var vals = opts.vals; + var labelXFn = opts.labelXFn; + var labelYFn = opts.labelYFn; + var labelAnchorFn = opts.labelAnchorFn; + var tickAngle = opts.secondary ? 0 : ax.tickangle; + var lastAngle = (ax._tickAngles || {})[cls]; - for(i = 0; i < subplots.length; i++) { - var subplot = fullLayout._plots[subplots[i]]; - var counterAxis = subplot[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + var tickLabels = opts.layer.selectAll('g.' + cls) + .data(ax.showticklabels ? vals : [], tickDataFn); - extendRange(fullRange, [ - counterAxis._offset, - counterAxis._offset + counterAxis._length - ]); - } + var labelsReady = []; - if(ax.anchor === 'free') { - extendRange(fullRange, (axLetter === 'x') ? - [ax._boundingBox.bottom, ax._boundingBox.top] : - [ax._boundingBox.right, ax._boundingBox.left]); + tickLabels.enter().append('g') + .classed(cls, 1) + .append('text') + // only so tex has predictable alignment that we can + // alter later + .attr('text-anchor', 'middle') + .each(function(d) { + var thisLabel = d3.select(this); + var newPromise = gd._promises.length; + + thisLabel + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)) + .call(Drawing.font, d.font, d.fontSize, d.fontColor) + .text(d.text) + .call(svgTextUtils.convertToTspans, gd); + + if(gd._promises[newPromise]) { + // if we have an async label, we'll deal with that + // all here so take it out of gd._promises and + // instead position the label and promise this in + // labelsReady + labelsReady.push(gd._promises.pop().then(function() { + positionLabels(thisLabel, tickAngle); + })); + } else { + // sync label: just position it now. + positionLabels(thisLabel, tickAngle); } - } + }); - function extendRange(range, newRange) { - range[0] = Math.min(range[0], newRange[0]); - range[1] = Math.max(range[1], newRange[1]); - } - } + tickLabels.exit().remove(); - function doAutoMargins() { - var pushKey = ax._name + '.automargin'; - if(axLetter !== 'x' && axLetter !== 'y') { return; } - if(!ax.automargin) { - Plots.autoMargin(gd, pushKey); - return; + if(opts.repositionOnUpdate) { + tickLabels.each(function(d) { + d3.select(this).select('text') + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)); + }); + } + + // How much to shift a multi-line label to center it vertically. + function getAnchorHeight(lineCount, lineHeight, angle) { + var h = (lineCount - 1) * lineHeight; + if(axLetter === 'x') { + if(angle < -60 || 60 < angle) { + return -0.5 * h; + } else if(ax.side === 'top') { + return -h; } + } else { + angle *= ax.side === 'left' ? 1 : -1; + if(angle < -30) { + return -h; + } else if(angle < 30) { + return -0.5 * h; + } + } + return 0; + } - var s = ax.side[0]; - var push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + function positionLabels(s, angle) { + s.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + var anchor = labelAnchorFn(angle, d); + + var transform = opts.transFn.call(thisLabel.node(), d) + + ((isNumeric(angle) && +angle !== 0) ? + (' rotate(' + angle + ',' + labelXFn(d) + ',' + + (labelYFn(d) - d.fontSize / 2) + ')') : + ''); + + var anchorHeight = getAnchorHeight( + svgTextUtils.lineCount(thisLabel), + LINE_SPACING * d.fontSize, + isNumeric(angle) ? +angle : 0 + ); - if(axLetter === 'x') { - push.y = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 't' ? 1 : 0]); - push[s] += ax._boundingBox.height; - } - else { - push.x = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 'r' ? 1 : 0]); - push[s] += ax._boundingBox.width; + if(anchorHeight) { + transform += ' translate(0, ' + anchorHeight + ')'; } - if(ax.title !== fullLayout._dfltTitle[axLetter]) { - push[s] += ax.titlefont.size; + if(mathjaxGroup.empty()) { + thisLabel.select('text').attr({ + transform: transform, + 'text-anchor': anchor + }); + } else { + var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; + var mjShift = mjWidth * {end: -0.5, start: 0.5}[anchor]; + mathjaxGroup.attr('transform', transform + (mjShift ? 'translate(' + mjShift + ',0)' : '')); } + }); + } - Plots.autoMargin(gd, pushKey, push); - } + // make sure all labels are correctly positioned at their base angle + // the positionLabels call above is only for newly drawn labels. + // do this without waiting, using the last calculated angle to + // minimize flicker, then do it again when we know all labels are + // there, putting back the prescribed angle to check for overlaps. + positionLabels(tickLabels, lastAngle || tickAngle); - var done = Lib.syncOrAsync([ - allLabelsReady, - fixLabelOverlaps, - calcBoundingBox, - doAutoMargins - ]); - if(done && done.then) gd._promises.push(done); - return done; + function allLabelsReady() { + return labelsReady.length && Promise.all(labelsReady); } - function drawAxTitle() { - if(skipTitle) return; - - // now this only applies to regular cartesian axes; colorbars and - // others ALWAYS call doTicks with skipTitle=true so they can - // configure their own titles. + function fixLabelOverlaps() { + positionLabels(tickLabels, tickAngle); - // rangeslider takes over a bottom title so drop it here - if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; + var autoangle = null; - var avoid = { - selection: tickLabels, - side: ax.side - }; - var axLetter = axid.charAt(0); - var gs = gd._fullLayout._size; - var offsetBase = 1.5; - var fontSize = ax.titlefont.size; + // check for auto-angling if x labels overlap + // don't auto-angle at all for log axes with + // base and digit format + if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) && + (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D') + ) { + autoangle = 0; - var transform, counterAxis, x, y; + var maxFontSize = 0; + var lbbArray = []; + var i; - if(tickLabels.size()) { - var translation = Drawing.getTranslate(tickLabels.node().parentNode); - avoid.offsetLeft = translation.x; - avoid.offsetTop = translation.y; - } + tickLabels.each(function(d) { + maxFontSize = Math.max(maxFontSize, d.fontSize); + + var x = ax.l2p(d.x); + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + + lbbArray.push({ + // ignore about y, just deal with x overlaps + top: 0, + bottom: 10, + height: 10, + left: x - bb.width / 2, + // impose a 2px gap + right: x + bb.width / 2 + 2, + width: bb.width + 2 + }); + }); - var titleStandoff = 10 + fontSize * offsetBase + - (ax.linewidth ? ax.linewidth - 1 : 0); + if((ax.tickson === 'boundaries' || ax.showdividers) && !opts.secondary) { + var gap = 2; + if(ax.ticks) gap += ax.tickwidth / 2; - if(axLetter === 'x') { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + // TODO should secondary labels also fall into this fix-overlap regime? - x = ax._offset + ax._length / 2; + for(i = 0; i < lbbArray.length; i++) { + var xbnd = vals[i].xbnd; + var lbb = lbbArray[i]; + if( + (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || + (xbnd[1] !== null && (ax.l2p(xbnd[1]) - lbb.right) < gap) + ) { + autoangle = 90; + break; + } + } + } else { + var vLen = vals.length; + var tickSpacing = Math.abs((vals[vLen - 1].x - vals[0].x) * ax._m) / (vLen - 1); + var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory'; - if(ax.side === 'top') { - y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); - } - else { - y = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1.5 : 0.5); + // any overlap at all - set 30 degrees or 90 degrees + for(i = 0; i < lbbArray.length - 1; i++) { + if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { + autoangle = rotate90 ? 90 : 30; + break; + } + } } - y += counterAxis._offset; - if(!avoid.side) avoid.side = 'bottom'; - } - else { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : - axisIds.getFromId(gd, ax.anchor); - - y = ax._offset + ax._length / 2; - if(ax.side === 'right') { - x = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1 : 0.5); - } - else { - x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + if(autoangle) { + positionLabels(tickLabels, autoangle); } - x += counterAxis._offset; - - transform = {rotate: '-90', offset: 0}; - if(!avoid.side) avoid.side = 'left'; } - Titles.draw(gd, axid + 'title', { - propContainer: ax, - propName: ax._name + '.title', - placeholder: fullLayout._dfltTitle[axLetter], - avoid: avoid, - transform: transform, - attributes: {x: x, y: y, 'text-anchor': 'middle'} - }); - } - - function drawGrid(plotinfo, counteraxis) { - if(fullLayout._hasOnlyLargeSploms) return; - - var gridcontainer = plotinfo.gridlayer.selectAll('.' + axid); - var zlcontainer = plotinfo.zerolinelayer; - var gridpath = ax._gridpath || ((axLetter === 'x' ? - ('M0,' + counteraxis._offset + 'v') : - ('M' + counteraxis._offset + ',0h') - ) + counteraxis._length); - var grid = gridcontainer.selectAll('path.' + gcls) - .data((ax.showgrid === false) ? [] : valsClipped, datafn); - grid.enter().append('path').classed(gcls, 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function(d) { - if(ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - Math.abs(d.x) < ax.dtick / 100) { - d3.select(this).remove(); - } - }); - grid.attr('transform', transfn) - .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', gridWidth + 'px'); - if(typeof gridpath === 'function') grid.attr('d', gridpath); - grid.exit().remove(); - - // zero line - if(zlcontainer) { - var zlData = {x: 0, id: axid}; - var showZl = axes.shouldShowZeroLine(gd, ax, counteraxis); - var zl = zlcontainer.selectAll('path.' + zcls) - .data(showZl ? [zlData] : []); - zl.enter().append('path').classed(zcls, 1).classed('zl', 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function() { - // use the fact that only one element can enter to trigger a sort. - // If several zerolines enter at the same time we will sort once per, - // but generally this should be a minimal overhead. - zlcontainer.selectAll('path').sort(function(da, db) { - return axisIds.idSort(da.id, db.id); - }); - }); - zl.attr('transform', transfn) - .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', zeroLineWidth + 'px'); - zl.exit().remove(); + if(ax._tickAngles) { + ax._tickAngles[cls] = autoangle === null ? + (isNumeric(tickAngle) ? tickAngle : 0) : + autoangle; } } - if(independent) { - drawTicks(ax._axislayer, tickpathfn(ax._pos + pad * ticksign[2], ticksign[2] * ax.ticklen)); - if(ax._counteraxis) { - var fictionalPlotinfo = { - gridlayer: ax._gridlayer, - zerolinelayer: ax._zerolinelayer - }; - drawGrid(fictionalPlotinfo, ax._counteraxis); - } - return drawLabels(ax._axislayer, ax._pos); + if(ax._selections) { + ax._selections[cls] = tickLabels; } - else if(fullLayout._has('cartesian')) { - subplots = axes.getSubplots(gd, ax); - // keep track of which subplots (by main conteraxis) we've already - // drawn grids for, so we don't overdraw overlaying subplots - var finishedGrids = {}; + var done = Lib.syncOrAsync([allLabelsReady, fixLabelOverlaps]); + if(done && done.then) gd._promises.push(done); + return done; +}; - subplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; - var counterAxis = plotinfo[counterLetter + 'axis']; +/** + * Draw axis dividers + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} showdividers + * - {number} dividerwidth + * - {string} dividercolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {fn} path + * - {fn} transFn + */ +function drawDividers(gd, ax, opts) { + var cls = ax._id + 'divider'; + var vals = opts.vals; - var mainCounterID = counterAxis._mainAxis._id; - if(finishedGrids[mainCounterID]) return; - finishedGrids[mainCounterID] = 1; + var dividers = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); - drawGrid(plotinfo, counterAxis, subplot); - }); + dividers.exit().remove(); - var mainSubplot = ax._mainSubplot; - var mainPlotinfo = fullLayout._plots[mainSubplot]; - var tickSubplots = []; + dividers.enter().insert('path', ':first-child') + .classed(cls, 1) + .classed('crisp', 1) + .call(Color.stroke, ax.dividercolor) + .style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px'); - if(ax.ticks) { - var mainSign = ticksign[2]; - var tickpath = tickpathfn(ax._mainLinePosition + pad * mainSign, mainSign * ax.ticklen); - if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { - tickpath += tickpathfn(ax._mainMirrorPosition - pad * mainSign, -mainSign * ax.ticklen); - } - drawTicks(mainPlotinfo[axLetter + 'axislayer'], tickpath); + dividers + .attr('transform', opts.transFn) + .attr('d', opts.path); +} - tickSubplots = Object.keys(ax._linepositions || {}); +function drawTitle(gd, ax) { + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var gs = fullLayout._size; + var fontSize = ax.title.font.size; + + var titleStandoff; + if(ax.type === 'multicategory') { + titleStandoff = ax._labelLength; + } else { + var offsetBase = 1.5; + titleStandoff = 10 + fontSize * offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); + } + + var transform, counterAxis, x, y; + + if(axLetter === 'x') { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + x = ax._offset + ax._length / 2; + + if(ax.side === 'top') { + y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); + } else { + y = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1.5 : 0.5); } + y += counterAxis._offset; + } else { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : + axisIds.getFromId(gd, ax.anchor); - tickSubplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; + y = ax._offset + ax._length / 2; - var container = plotinfo[axLetter + 'axislayer']; + if(ax.side === 'right') { + x = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1 : 0.5); + } else { + x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + } + x += counterAxis._offset; - // [bottom or left, top or right] - // free and main are handled above - var linepositions = ax._linepositions[subplot] || []; + transform = {rotate: '-90', offset: 0}; + } - function tickPathSide(sidei) { - var tsign = ticksign[sidei]; - return tickpathfn(linepositions[sidei] + pad * tsign, tsign * ax.ticklen); - } + var avoid; - drawTicks(container, tickPathSide(0) + tickPathSide(1)); - }); + if(ax.type !== 'multicategory') { + var tickLabels = ax._selections[ax._id + 'tick']; - var mainContainer = mainPlotinfo[axLetter + 'axislayer']; + avoid = { + selection: tickLabels, + side: ax.side + }; - return drawLabels(mainContainer, ax._mainLinePosition); + if(tickLabels && tickLabels.node() && tickLabels.node().parentNode) { + var translation = Drawing.getTranslate(tickLabels.node().parentNode); + avoid.offsetLeft = translation.x; + avoid.offsetTop = translation.y; + } } -}; + + return Titles.draw(gd, axId + 'title', { + propContainer: ax, + propName: ax._name + '.title.text', + placeholder: fullLayout._dfltTitle[axLetter], + avoid: avoid, + transform: transform, + attributes: {x: x, y: y, 'text-anchor': 'middle'} + }); +} axes.shouldShowZeroLine = function(gd, ax, counterAxis) { var rng = Lib.simpleMap(ax.range, ax.r2l); @@ -83825,7 +85316,7 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { (rng[0] * rng[1] <= 0) && ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - ax._valsClipped.length && + ax._gridVals.length && ( clipEnds(ax, 0) || !anyCounterAxLineAtZero(gd, ax, counterAxis, rng) || @@ -83834,6 +85325,10 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { ); }; +axes.clipEnds = function(ax, vals) { + return vals.filter(function(d) { return clipEnds(ax, d.x); }); +}; + function clipEnds(ax, l) { var p = ax.l2p(l); return (p > 1 && p < ax._length - 1); @@ -83909,6 +85404,12 @@ function hasBarsOrFill(gd, ax) { return false; } +function selectTickLabel(gTick) { + var s = d3.select(gTick); + var mj = s.select('.text-math-group'); + return mj.empty() ? s.select('text') : mj; +} + /** * Find all margin pushers for 2D axes and reserve them for later use * Both label and rangeslider automargin calculations happen later so @@ -83923,14 +85424,17 @@ axes.allowAutoMargin = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; if(ax.automargin) { - Plots.allowAutoMargin(gd, ax._name + '.automargin'); + Plots.allowAutoMargin(gd, axAutoMarginID(ax)); } - if(ax.rangeslider && ax.rangeslider.visible) { - Plots.allowAutoMargin(gd, 'rangeslider' + ax._id); + if(Registry.getComponentMethod('rangeslider', 'isVisible')(ax)) { + Plots.allowAutoMargin(gd, rangeSliderAutoMarginID(ax)); } } }; +function axAutoMarginID(ax) { return ax._id + '.automargin'; } +function rangeSliderAutoMarginID(ax) { return ax._id + '.rangeslider'; } + // swap all the presentation attributes of the axes showing these traces axes.swap = function(gd, traces) { var axGroups = makeAxisGroups(gd, traces); @@ -83986,11 +85490,10 @@ function mergeAxisGroups(intoSet, fromSet) { } function swapAxisGroup(gd, xIds, yIds) { - var i, - j, - xFullAxes = [], - yFullAxes = [], - layout = gd.layout; + var xFullAxes = []; + var yFullAxes = []; + var layout = gd.layout; + var i, j; for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i])); for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i])); @@ -84003,12 +85506,12 @@ function swapAxisGroup(gd, xIds, yIds) { var numericTypes = ['linear', 'log']; for(i = 0; i < allAxKeys.length; i++) { - var keyi = allAxKeys[i], - xVal = xFullAxes[0][keyi], - yVal = yFullAxes[0][keyi], - allEqual = true, - coerceLinearX = false, - coerceLinearY = false; + var keyi = allAxKeys[i]; + var xVal = xFullAxes[0][keyi]; + var yVal = yFullAxes[0][keyi]; + var allEqual = true; + var coerceLinearX = false; + var coerceLinearY = false; if(keyi.charAt(0) === '_' || typeof xVal === 'function' || noSwapAttrs.indexOf(keyi) !== -1) { continue; @@ -84054,17 +85557,18 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes, dfltTitle) { // in case the value is the default for either axis, // look at the first axis in each list and see if // this key's value is undefined - var np = Lib.nestedProperty, - xVal = np(layout[xFullAxes[0]._name], key).get(), - yVal = np(layout[yFullAxes[0]._name], key).get(), - i; + var np = Lib.nestedProperty; + var xVal = np(layout[xFullAxes[0]._name], key).get(); + var yVal = np(layout[yFullAxes[0]._name], key).get(); + var i; + if(key === 'title') { // special handling of placeholder titles - if(xVal === dfltTitle.x) { - xVal = dfltTitle.y; + if(xVal && xVal.text === dfltTitle.x) { + xVal.text = dfltTitle.y; } - if(yVal === dfltTitle.y) { - yVal = dfltTitle.x; + if(yVal && yVal.text === dfltTitle.y) { + yVal.text = dfltTitle.x; } } @@ -84080,7 +85584,7 @@ function isAngular(ax) { return ax._id === 'angularaxis'; } -},{"../../components/color":319,"../../components/drawing":344,"../../components/titles":410,"../../constants/alignment":417,"../../constants/numerical":420,"../../lib":441,"../../lib/svg_text_utils":465,"../../plots/plots":525,"../../registry":532,"./autorange":487,"./axis_autotype":489,"./axis_ids":491,"./clean_ticks":493,"./layout_attributes":501,"./set_convert":507,"d3":85,"fast-isnumeric":149}],489:[function(_dereq_,module,exports){ +},{"../../components/color":318,"../../components/drawing":339,"../../components/titles":406,"../../constants/alignment":413,"../../constants/numerical":416,"../../lib":437,"../../lib/svg_text_utils":461,"../../plots/plots":521,"../../registry":528,"./autorange":483,"./axis_autotype":485,"./axis_ids":487,"./clean_ticks":489,"./layout_attributes":497,"./set_convert":503,"d3":85,"fast-isnumeric":149}],485:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84097,7 +85601,10 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var BADNUM = _dereq_('../../constants/numerical').BADNUM; -module.exports = function autoType(array, calendar) { +module.exports = function autoType(array, calendar, opts) { + opts = opts || {}; + + if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory'; if(moreDates(array, calendar)) return 'date'; if(category(array)) return 'category'; if(linearOK(array)) return 'linear'; @@ -84165,7 +85672,14 @@ function category(a) { return curvecats > curvenums * 2; } -},{"../../constants/numerical":420,"../../lib":441,"fast-isnumeric":149}],490:[function(_dereq_,module,exports){ +// very-loose requirements for multicategory, +// trace modules that should never auto-type to multicategory +// should be declared with 'noMultiCategory' +function multiCategory(a) { + return Lib.isArrayOrTypedArray(a[0]) && Lib.isArrayOrTypedArray(a[1]); +} + +},{"../../constants/numerical":416,"../../lib":437,"fast-isnumeric":149}],486:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84196,6 +85710,7 @@ var setConvert = _dereq_('./set_convert'); * outerTicks: boolean, should ticks default to outside? * showGrid: boolean, should gridlines be shown by default? * noHover: boolean, this axis doesn't support hover effects? + * noTickson: boolean, this axis doesn't support 'tickson' * data: the plot data, used to manage categories * bgColor: the plot background color, to calculate default gridline colors */ @@ -84236,8 +85751,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, // try to get default title from splom trace, fallback to graph-wide value var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter]; - coerce('title', dfltTitle); - Lib.coerceFont(coerce, 'titlefont', { + coerce('title.text', dfltTitle); + Lib.coerceFont(coerce, 'title.font', { family: font.family, size: Math.round(font.size * 1.2), color: dfltFontColor @@ -84257,10 +85772,29 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, if(options.automargin) coerce('automargin'); + var isMultiCategory = containerOut.type === 'multicategory'; + + if(!options.noTickson && + (containerOut.type === 'category' || isMultiCategory) && + (containerOut.ticks || containerOut.showgrid) + ) { + var ticksonDflt; + if(isMultiCategory) ticksonDflt = 'boundaries'; + coerce('tickson', ticksonDflt); + } + + if(isMultiCategory) { + var showDividers = coerce('showdividers'); + if(showDividers) { + coerce('dividercolor'); + coerce('dividerwidth'); + } + } + return containerOut; }; -},{"../../lib":441,"../../registry":532,"./category_order_defaults":492,"./layout_attributes":501,"./line_grid_defaults":503,"./set_convert":507,"./tick_label_defaults":508,"./tick_mark_defaults":509,"./tick_value_defaults":510}],491:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528,"./category_order_defaults":488,"./layout_attributes":497,"./line_grid_defaults":499,"./set_convert":503,"./tick_label_defaults":504,"./tick_mark_defaults":505,"./tick_value_defaults":506}],487:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84378,7 +85912,7 @@ exports.idSort = function(id1, id2) { return +(id1.substr(1) || 1) - +(id2.substr(1) || 1); }; -},{"../../registry":532,"./constants":494}],492:[function(_dereq_,module,exports){ +},{"../../registry":528,"./constants":490}],488:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84472,7 +86006,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],493:[function(_dereq_,module,exports){ +},{}],489:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84561,7 +86095,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":420,"../../lib":441,"fast-isnumeric":149}],494:[function(_dereq_,module,exports){ +},{"../../constants/numerical":416,"../../lib":437,"fast-isnumeric":149}],490:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84643,7 +86177,7 @@ module.exports = { } }; -},{"../../lib/regex":457}],495:[function(_dereq_,module,exports){ +},{"../../lib/regex":453}],491:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84797,7 +86331,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[scaleanchor] = 1; } -},{"../../lib":441,"./axis_ids":491}],496:[function(_dereq_,module,exports){ +},{"../../lib":437,"./axis_ids":487}],492:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84939,7 +86473,6 @@ exports.enforce = function enforceAxisConstraints(gd) { var getPad = makePadFn(ax); updateDomain(ax, factor); - ax.setScale(); var m = Math.abs(ax._m); var extremes = concatExtremes(gd, ax); var minArray = extremes.min; @@ -85006,9 +86539,10 @@ function updateDomain(ax, factor) { center + (inputDomain[0] - center) / factor, center + (inputDomain[1] - center) / factor ]; + ax.setScale(); } -},{"../../constants/alignment":417,"../../constants/numerical":420,"./autorange":487,"./axis_ids":491,"./scale_zoom":505}],497:[function(_dereq_,module,exports){ +},{"../../constants/alignment":413,"../../constants/numerical":416,"./autorange":483,"./axis_ids":487,"./scale_zoom":501}],493:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85030,6 +86564,7 @@ var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Fx = _dereq_('../../components/fx'); +var Axes = _dereq_('./axes'); var setCursor = _dereq_('../../lib/setcursor'); var dragElement = _dereq_('../../components/dragelement'); var FROM_TL = _dereq_('../../constants/alignment').FROM_TL; @@ -85038,7 +86573,6 @@ var redrawReglTraces = _dereq_('../../plot_api/subroutines').redrawReglTraces; var Plots = _dereq_('../plots'); -var doTicksSingle = _dereq_('./axes').doTicksSingle; var getFromId = _dereq_('./axis_ids').getFromId; var prepSelect = _dereq_('./select').prepSelect; var clearSelect = _dereq_('./select').clearSelect; @@ -85282,7 +86816,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { .on('edit', function(text) { var v = ax.d2r(text); if(v !== undefined) { - Registry.call('relayout', gd, attrStr, v); + Registry.call('_guiRelayout', gd, attrStr, v); } }); } @@ -85527,6 +87061,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { return; } + // prevent axis drawing from monkeying with margins until we're done + gd._fullLayout._replotting = true; + if(xActive === 'ew' || yActive === 'ns') { if(xActive) dragAxList(xaxes, dx); if(yActive) dragAxList(yaxes, dy); @@ -85630,8 +87167,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { updates = {}; for(i = 0; i < activeAxIds.length; i++) { var axId = activeAxIds[i]; - doTicksSingle(gd, axId, true); var ax = getFromId(gd, axId); + Axes.drawOne(gd, ax, {skipTitle: true}); updates[ax._name + '.range[0]'] = ax.range[0]; updates[ax._name + '.range[1]'] = ax.range[1]; } @@ -85723,7 +87260,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, attrs); } // dragTail - finish a drag event with a redraw @@ -85737,7 +87274,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // accumulated MathJax promises - wait for them before we relayout. Lib.syncOrAsync([ Plots.previousPromises, - function() { Registry.call('relayout', gd, updates); } + function() { + gd._fullLayout._replotting = false; + Registry.call('_guiRelayout', gd, updates); + } ], gd); } @@ -86195,7 +87735,7 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":319,"../../components/dragelement":341,"../../components/drawing":344,"../../components/fx":361,"../../constants/alignment":417,"../../lib":441,"../../lib/clear_gl_canvases":427,"../../lib/setcursor":461,"../../lib/svg_text_utils":465,"../../plot_api/subroutines":479,"../../registry":532,"../plots":525,"./axes":488,"./axis_ids":491,"./constants":494,"./scale_zoom":505,"./select":506,"d3":85,"has-passive-events":201,"tinycolor2":284}],498:[function(_dereq_,module,exports){ +},{"../../components/color":318,"../../components/dragelement":336,"../../components/drawing":339,"../../components/fx":357,"../../constants/alignment":413,"../../lib":437,"../../lib/clear_gl_canvases":424,"../../lib/setcursor":457,"../../lib/svg_text_utils":461,"../../plot_api/subroutines":475,"../../registry":528,"../plots":521,"./axes":484,"./axis_ids":487,"./constants":490,"./scale_zoom":501,"./select":502,"d3":85,"has-passive-events":201,"tinycolor2":283}],494:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86363,7 +87903,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":341,"../../components/fx":361,"../../lib/setcursor":461,"./constants":494,"./dragbox":497,"d3":85}],499:[function(_dereq_,module,exports){ +},{"../../components/dragelement":336,"../../components/fx":357,"../../lib/setcursor":457,"./constants":490,"./dragbox":493,"d3":85}],495:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86438,7 +87978,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":441,"../../registry":532}],500:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528}],496:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86703,7 +88243,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback // layers that allow `cliponaxis: false` if(className !== 'scatterlayer' && className !== 'barlayer') { - Drawing.setClipUrl(sel, plotinfo.layerClipId); + Drawing.setClipUrl(sel, plotinfo.layerClipId, gd); } }); @@ -87061,7 +88601,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":344,"../../constants/xmlns_namespaces":421,"../../lib":441,"../../registry":532,"../get_data":517,"../plots":525,"./attributes":486,"./axis_ids":491,"./constants":494,"./graph_interact":498,"./layout_attributes":501,"./layout_defaults":502,"./transition_axes":511,"d3":85}],501:[function(_dereq_,module,exports){ +},{"../../components/drawing":339,"../../constants/xmlns_namespaces":417,"../../lib":437,"../../registry":528,"../get_data":513,"../plots":521,"./attributes":482,"./axis_ids":487,"./constants":490,"./graph_interact":494,"./layout_attributes":497,"./layout_defaults":498,"./transition_axes":507,"d3":85}],497:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87096,21 +88636,24 @@ module.exports = { }, title: { - valType: 'string', - - editType: 'ticks', - + text: { + valType: 'string', + + editType: 'ticks', + + }, + font: fontAttrs({ + editType: 'ticks', + + }), + editType: 'ticks' }, - titlefont: fontAttrs({ - editType: 'ticks', - - }), type: { valType: 'enumerated', // '-' means we haven't yet run autotype or couldn't find any data // it gets turned into linear in gd._fullLayout but not copied back // to gd.data like the others are. - values: ['-', 'linear', 'log', 'date', 'category'], + values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', editType: 'calc', @@ -87239,6 +88782,14 @@ module.exports = { editType: 'ticks', + }, + tickson: { + valType: 'enumerated', + values: ['labels', 'boundaries'], + + dflt: 'labels', + editType: 'ticks', + }, mirror: { valType: 'enumerated', @@ -87492,6 +89043,30 @@ module.exports = { editType: 'ticks', }, + + showdividers: { + valType: 'boolean', + dflt: true, + + editType: 'ticks', + + }, + dividercolor: { + valType: 'color', + dflt: colorAttrs.defaultLine, + + editType: 'ticks', + + }, + dividerwidth: { + valType: 'number', + dflt: 1, + + editType: 'ticks', + + }, + // TODO dividerlen: that would override "to label base" length? + // positioning attributes // anchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -87573,6 +89148,12 @@ module.exports = { editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'calc', @@ -87582,11 +89163,21 @@ module.exports = { editType: 'ticks', - } + }, + title: { + valType: 'string', + + editType: 'ticks', + + }, + titlefont: fontAttrs({ + editType: 'ticks', + + }) } }; -},{"../../components/color/attributes":318,"../../components/drawing/attributes":343,"../../lib/extend":432,"../../plot_api/plot_template":478,"../font_attributes":515,"./constants":494}],502:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":317,"../../components/drawing/attributes":338,"../../lib/extend":429,"../../plot_api/plot_template":474,"../font_attributes":511,"./constants":490}],498:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87745,9 +89336,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; }); axLayoutOut._annIndices = []; axLayoutOut._shapeIndices = []; + axLayoutOut._subplotsWith = []; + axLayoutOut._counterAxes = []; // set up some private properties - axLayoutOut._name = axName; + axLayoutOut._name = axLayoutOut._attr = axName; var id = axLayoutOut._id = name2id(axName); var overlayableAxes = getOverlayableAxes(axLetter, axName); @@ -87765,6 +89358,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id] }; + coerce('uirevision', layoutOut.uirevision); + handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions); handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut); @@ -87826,11 +89421,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var anchoredAxis = layoutOut[id2name(axLayoutOut.anchor)]; - var fixedRangeDflt = ( - anchoredAxis && - anchoredAxis.rangeslider && - anchoredAxis.rangeslider.visible - ); + var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis); coerce('fixedrange', fixedRangeDflt); } @@ -87855,7 +89446,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } }; -},{"../../components/color":319,"../../lib":441,"../../plot_api/plot_template":478,"../../registry":532,"../layout_attributes":523,"./axis_defaults":490,"./axis_ids":491,"./constraint_defaults":495,"./layout_attributes":501,"./position_defaults":504,"./type_defaults":512}],503:[function(_dereq_,module,exports){ +},{"../../components/color":318,"../../lib":437,"../../plot_api/plot_template":474,"../../registry":528,"../layout_attributes":519,"./axis_defaults":486,"./axis_ids":487,"./constraint_defaults":491,"./layout_attributes":497,"./position_defaults":500,"./type_defaults":508}],499:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87920,7 +89511,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":318,"../../lib":441,"tinycolor2":284}],504:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":317,"../../lib":437,"tinycolor2":283}],500:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88004,7 +89595,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":441,"fast-isnumeric":149}],505:[function(_dereq_,module,exports){ +},{"../../lib":437,"fast-isnumeric":149}],501:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88032,7 +89623,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ]; }; -},{"../../constants/alignment":417}],506:[function(_dereq_,module,exports){ +},{"../../constants/alignment":413}],502:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88701,13 +90292,22 @@ function isOnlyOnePointSelected(searchTraces) { function updateSelectedState(gd, searchTraces, eventData) { var i, searchInfo, cd, trace; + // before anything else, update preGUI if necessary + for(i = 0; i < searchTraces.length; i++) { + var fullInputTrace = searchTraces[i].cd[0].trace._fullInput; + var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid]; + if(tracePreGUI.selectedpoints === undefined) { + tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null; + } + } + if(eventData) { var pts = eventData.points || []; for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; - trace.selectedpoints = []; - trace._input.selectedpoints = []; + trace._input.selectedpoints = trace._fullInput.selectedpoints = []; + if(trace._fullInput !== trace) trace.selectedpoints = []; } for(i = 0; i < pts.length; i++) { @@ -88717,10 +90317,14 @@ function updateSelectedState(gd, searchTraces, eventData) { if(pt.pointIndices) { [].push.apply(data.selectedpoints, pt.pointIndices); - [].push.apply(fullData.selectedpoints, pt.pointIndices); + if(trace._fullInput !== trace) { + [].push.apply(fullData.selectedpoints, pt.pointIndices); + } } else { data.selectedpoints.push(pt.pointIndex); - fullData.selectedpoints.push(pt.pointIndex); + if(trace._fullInput !== trace) { + fullData.selectedpoints.push(pt.pointIndex); + } } } } @@ -88729,6 +90333,9 @@ function updateSelectedState(gd, searchTraces, eventData) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; delete trace._input.selectedpoints; + if(trace._fullInput !== trace) { + delete trace._fullInput.selectedpoints; + } } } @@ -88806,7 +90413,7 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":319,"../../components/fx":361,"../../components/fx/helpers":358,"../../lib/clear_gl_canvases":427,"../../lib/polygon":453,"../../lib/throttle":466,"../../plot_api/subroutines":479,"../../registry":532,"./axis_ids":491,"./constants":494,"polybooljs":240}],507:[function(_dereq_,module,exports){ +},{"../../components/color":318,"../../components/fx":357,"../../components/fx/helpers":353,"../../lib/clear_gl_canvases":424,"../../lib/polygon":449,"../../lib/throttle":462,"../../plot_api/subroutines":475,"../../registry":528,"./axis_ids":487,"./constants":490,"polybooljs":240}],503:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88839,6 +90446,10 @@ function fromLog(v) { return Math.pow(10, v); } +function isValidCategory(v) { + return v !== null && v !== undefined; +} + /** * Define the conversion functions for an axis data is used in 5 ways: * @@ -88932,7 +90543,7 @@ module.exports = function setConvert(ax, fullLayout) { * a disconnect between the array and the index returned */ function setCategoryIndex(v) { - if(v !== null && v !== undefined) { + if(isValidCategory(v)) { if(ax._categoriesMap === undefined) { ax._categoriesMap = {}; } @@ -88951,14 +90562,58 @@ module.exports = function setConvert(ax, fullLayout) { return BADNUM; } + function setMultiCategoryIndex(arrayIn, len) { + var arrayOut = new Array(len); + var i; + + // [ [arrayIn[0][i], arrayIn[1][i]], for i .. len ] + var tmp = new Array(len); + // [ [cnt, {$cat: index}], for j .. arrayIn.length ] + var seen = [[0, {}], [0, {}]]; + + if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) { + for(i = 0; i < len; i++) { + var v0 = arrayIn[0][i]; + var v1 = arrayIn[1][i]; + if(isValidCategory(v0) && isValidCategory(v1)) { + tmp[i] = [v0, v1]; + if(!(v0 in seen[0][1])) { + seen[0][1][v0] = seen[0][0]++; + } + if(!(v1 in seen[1][1])) { + seen[1][1][v1] = seen[1][0]++; + } + } + } + + tmp.sort(function(a, b) { + var ind0 = seen[0][1]; + var d = ind0[a[0]] - ind0[b[0]]; + if(d) return d; + + var ind1 = seen[1][1]; + return ind1[a[1]] - ind1[b[1]]; + }); + } + + for(i = 0; i < len; i++) { + arrayOut[i] = setCategoryIndex(tmp[i]); + } + + return arrayOut; + } + function getCategoryIndex(v) { - // d2l/d2c variant that that won't add categories but will also - // allow numbers to be mapped to the linearized axis positions if(ax._categoriesMap) { - var index = ax._categoriesMap[v]; - if(index !== undefined) return index; + return ax._categoriesMap[v]; } + } + function getCategoryPosition(v) { + // d2l/d2c variant that that won't add categories but will also + // allow numbers to be mapped to the linearized axis positions + var index = getCategoryIndex(v); + if(index !== undefined) return index; if(isNumeric(v)) return +v; } @@ -89044,15 +90699,15 @@ module.exports = function setConvert(ax, fullLayout) { ax.d2c = ax.d2l = setCategoryIndex; ax.r2d = ax.c2d = ax.l2d = getCategoryName; - ax.d2r = ax.d2l_noadd = getCategoryIndex; + ax.d2r = ax.d2l_noadd = getCategoryPosition; ax.r2c = function(v) { - var index = getCategoryIndex(v); + var index = getCategoryPosition(v); return index !== undefined ? index : ax.fraction2r(0.5); }; ax.l2r = ax.c2r = ensureNumber; - ax.r2l = getCategoryIndex; + ax.r2l = getCategoryPosition; ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; ax.p2d = function(px) { return getCategoryName(p2l(px)); }; @@ -89064,6 +90719,34 @@ module.exports = function setConvert(ax, fullLayout) { return ensureNumber(v); }; } + else if(ax.type === 'multicategory') { + // N.B. multicategory axes don't define d2c and d2l, + // as 'data-to-calcdata' conversion needs to take into + // account all data array items as in ax.makeCalcdata. + + ax.r2d = ax.c2d = ax.l2d = getCategoryName; + ax.d2r = ax.d2l_noadd = getCategoryPosition; + + ax.r2c = function(v) { + var index = getCategoryPosition(v); + return index !== undefined ? index : ax.fraction2r(0.5); + }; + + ax.r2c_just_indices = getCategoryIndex; + + ax.l2r = ax.c2r = ensureNumber; + ax.r2l = getCategoryPosition; + + ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; + ax.p2d = function(px) { return getCategoryName(p2l(px)); }; + ax.r2p = ax.d2p; + ax.p2r = p2l; + + ax.cleanPos = function(v) { + if(Array.isArray(v) || (typeof v === 'string' && v !== '')) return v; + return ensureNumber(v); + }; + } // find the range value at the specified (linear) fraction of the axis ax.fraction2r = function(v) { @@ -89157,11 +90840,6 @@ module.exports = function setConvert(ax, fullLayout) { ax.setScale = function(usePrivateRange) { var gs = fullLayout._size; - // TODO cleaner way to handle this case - if(!ax._categories) ax._categories = []; - // Add a map to optimize the performance of category collection - if(!ax._categoriesMap) ax._categoriesMap = {}; - // make sure we have a domain (pull it in from the axis // this one is overlaying if necessary) if(ax.overlaying) { @@ -89216,7 +90894,7 @@ module.exports = function setConvert(ax, fullLayout) { if(axLetter in trace) { arrayIn = trace[axLetter]; - len = trace._length || arrayIn.length; + len = trace._length || Lib.minRowLength(arrayIn); if(Lib.isTypedArray(arrayIn) && (axType === 'linear' || axType === 'log')) { if(len === arrayIn.length) { @@ -89226,6 +90904,10 @@ module.exports = function setConvert(ax, fullLayout) { } } + if(axType === 'multicategory') { + return setMultiCategoryIndex(arrayIn, len); + } + arrayOut = new Array(len); for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); @@ -89302,7 +90984,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":420,"../../lib":441,"./axis_ids":491,"./constants":494,"d3":85,"fast-isnumeric":149}],508:[function(_dereq_,module,exports){ +},{"../../constants/numerical":416,"../../lib":437,"./axis_ids":487,"./constants":490,"d3":85,"fast-isnumeric":149}],504:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89403,7 +91085,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../lib":441,"../array_container_defaults":484,"./layout_attributes":501}],509:[function(_dereq_,module,exports){ +},{"../../lib":437,"../array_container_defaults":480,"./layout_attributes":497}],505:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89436,7 +91118,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":441,"./layout_attributes":501}],510:[function(_dereq_,module,exports){ +},{"../../lib":437,"./layout_attributes":497}],506:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89445,22 +91127,18 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); - module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { var tickmode; if(containerIn.tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; - } - else { - var tickmodeDefault = - Array.isArray(containerIn.tickvals) ? 'array' : + } else { + var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : containerIn.dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); @@ -89475,15 +91153,14 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe containerIn.dtick, axType); containerOut.tick0 = cleanTicks.tick0( containerIn.tick0, axType, containerOut.calendar, dtick); - } - else { + } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto'; else coerce('ticktext'); } }; -},{"./clean_ticks":493}],511:[function(_dereq_,module,exports){ +},{"./clean_ticks":489}],507:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89605,14 +91282,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo } function ticksAndAnnotations(xa, ya) { - var activeAxIds = [], - i; - - activeAxIds = [xa._id, ya._id]; + var activeAxIds = [xa._id, ya._id]; + var i; - for(i = 0; i < activeAxIds.length; i++) { - Axes.doTicksSingle(gd, activeAxIds[i], true); - } + Axes.drawOne(gd, xa, {skipTitle: true}); + Axes.drawOne(gd, ya, {skipTitle: true}); function redrawObjs(objArray, method, shortCircuit) { for(i = 0; i < objArray.length; i++) { @@ -89811,7 +91485,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo return Promise.resolve(); }; -},{"../../components/drawing":344,"../../registry":532,"./axes":488,"./constants":494,"d3":85}],512:[function(_dereq_,module,exports){ +},{"../../components/drawing":339,"../../registry":528,"./axes":484,"./constants":490,"d3":85}],508:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89822,7 +91496,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo 'use strict'; -var Registry = _dereq_('../../registry'); +var traceIs = _dereq_('../../registry').traceIs; var autoType = _dereq_('./axis_autotype'); /* @@ -89871,6 +91545,7 @@ function setAutoType(ax, data) { var calAttr = axLetter + 'calendar'; var calendar = d0[calAttr]; + var opts = {noMultiCategory: !traceIs(d0, 'cartesian') || traceIs(d0, 'noMultiCategory')}; var i; // check all boxes on this x axis to see @@ -89881,8 +91556,7 @@ function setAutoType(ax, data) { for(i = 0; i < data.length; i++) { var trace = data[i]; - if(!Registry.traceIs(trace, 'box-violin') || - (trace[axLetter + 'axis'] || axLetter) !== id) continue; + if(!traceIs(trace, 'box-violin') || (trace[axLetter + 'axis'] || axLetter) !== id) continue; if(trace[posLetter] !== undefined) boxPositions.push(trace[posLetter][0]); else if(trace.name !== undefined) boxPositions.push(trace.name); @@ -89891,7 +91565,7 @@ function setAutoType(ax, data) { if(trace[calAttr] !== calendar) calendar = undefined; } - ax.type = autoType(boxPositions, calendar); + ax.type = autoType(boxPositions, calendar, opts); } else if(d0.type === 'splom') { var dimensions = d0.dimensions; @@ -89899,13 +91573,13 @@ function setAutoType(ax, data) { for(i = 0; i < dimensions.length; i++) { var dim = dimensions[i]; if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) { - ax.type = autoType(dim.values, calendar); + ax.type = autoType(dim.values, calendar, opts); break; } } } else { - ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar); + ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -89936,9 +91610,9 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace), - isBox = Registry.traceIs(trace, 'box-violin'), - isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); + var posLetter = getBoxPosLetter(trace); + var isBox = traceIs(trace, 'box-violin'); + var isCandlestick = traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox && @@ -89949,7 +91623,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":532,"./axis_autotype":489}],513:[function(_dereq_,module,exports){ +},{"../../registry":528,"./axis_autotype":485}],509:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90373,7 +92047,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":441,"../registry":532}],514:[function(_dereq_,module,exports){ +},{"../lib":437,"../registry":528}],510:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90481,7 +92155,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { coerce('domain.y', dfltY); }; -},{"../lib/extend":432}],515:[function(_dereq_,module,exports){ +},{"../lib/extend":429}],511:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90546,7 +92220,7 @@ module.exports = function(opts) { return attrs; }; -},{}],516:[function(_dereq_,module,exports){ +},{}],512:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90592,7 +92266,7 @@ module.exports = { } }; -},{}],517:[function(_dereq_,module,exports){ +},{}],513:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90720,7 +92394,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":532,"./cartesian/constants":494}],518:[function(_dereq_,module,exports){ +},{"../registry":528,"./cartesian/constants":490}],514:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91022,7 +92696,7 @@ function createCamera(scene) { return result; } -},{"../cartesian/constants":494,"has-passive-events":201,"mouse-change":214,"mouse-event-offset":215,"mouse-wheel":217}],519:[function(_dereq_,module,exports){ +},{"../cartesian/constants":490,"has-passive-events":201,"mouse-change":214,"mouse-event-offset":215,"mouse-wheel":217}],515:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91036,7 +92710,6 @@ function createCamera(scene) { var Axes = _dereq_('../cartesian/axes'); -var convertHTMLToUnicode = _dereq_('../../lib/html2unicode'); var str2RGBArray = _dereq_('../../lib/str2rgbarray'); function Axes2DOptions(scene) { @@ -91139,14 +92812,14 @@ proto.merge = function(options) { // '_name' is e.g. xaxis, xaxis2, yaxis, yaxis4 ... ax = options[this.scene[axisName]._name]; - axTitle = ax.title === this.scene.fullLayout._dfltTitle[axisLetter] ? '' : ax.title; + axTitle = ax.title.text === this.scene.fullLayout._dfltTitle[axisLetter] ? '' : ax.title.text; for(j = 0; j <= 2; j += 2) { this.labelEnable[i + j] = false; - this.labels[i + j] = convertHTMLToUnicode(axTitle); - this.labelColor[i + j] = str2RGBArray(ax.titlefont.color); - this.labelFont[i + j] = ax.titlefont.family; - this.labelSize[i + j] = ax.titlefont.size; + this.labels[i + j] = axTitle; + this.labelColor[i + j] = str2RGBArray(ax.title.font.color); + this.labelFont[i + j] = ax.title.font.family; + this.labelSize[i + j] = ax.title.font.size; this.labelPad[i + j] = this.getLabelPad(axisName, ax); this.tickEnable[i + j] = false; @@ -91234,7 +92907,7 @@ proto.hasAxisInAltrPos = function(axisName, ax) { proto.getLabelPad = function(axisName, ax) { var offsetBase = 1.5, - fontSize = ax.titlefont.size, + fontSize = ax.title.font.size, showticklabels = ax.showticklabels; if(axisName === 'xaxis') { @@ -91268,7 +92941,7 @@ function createAxes2D(scene) { module.exports = createAxes2D; -},{"../../lib/html2unicode":439,"../../lib/str2rgbarray":464,"../cartesian/axes":488}],520:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":460,"../cartesian/axes":484}],516:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91419,7 +93092,7 @@ exports.updateFx = function(gd) { } }; -},{"../../components/fx/layout_attributes":362,"../../constants/xmlns_namespaces":421,"../../plot_api/edit_types":471,"../cartesian":500,"../cartesian/attributes":486,"../cartesian/constants":494,"../get_data":517,"../layout_attributes":523,"./scene2d":521}],521:[function(_dereq_,module,exports){ +},{"../../components/fx/layout_attributes":358,"../../constants/xmlns_namespaces":417,"../../plot_api/edit_types":467,"../cartesian":496,"../cartesian/attributes":482,"../cartesian/constants":490,"../get_data":513,"../layout_attributes":519,"./scene2d":517}],517:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91442,7 +93115,6 @@ var getContext = _dereq_('webgl-context'); var createOptions = _dereq_('./convert'); var createCamera = _dereq_('./camera'); -var convertHTMLToUnicode = _dereq_('../../lib/html2unicode'); var showNoWebGlMsg = _dereq_('../../lib/show_no_webgl_msg'); var axisConstraints = _dereq_('../cartesian/constraints'); var enforceAxisConstraints = axisConstraints.enforce; @@ -91701,7 +93373,7 @@ proto.computeTickMarks = function() { for(var j = 0; j < 2; ++j) { for(var i = 0; i < nextTicks[j].length; ++i) { // coercing tick value (may not be a string) to a string - nextTicks[j][i].text = convertHTMLToUnicode(nextTicks[j][i].text + ''); + nextTicks[j][i].text = nextTicks[j][i].text + ''; } } @@ -91735,27 +93407,31 @@ proto.updateRefs = function(newFullLayout) { }; proto.relayoutCallback = function() { - var graphDiv = this.graphDiv, - xaxis = this.xaxis, - yaxis = this.yaxis, - layout = graphDiv.layout; + var graphDiv = this.graphDiv; + var xaxis = this.xaxis; + var yaxis = this.yaxis; + var layout = graphDiv.layout; + + // make a meaningful value to be passed on to possible 'plotly_relayout' subscriber(s) + var update = {}; + var xrange = update[xaxis._name + '.range'] = xaxis.range.slice(); + var yrange = update[yaxis._name + '.range'] = yaxis.range.slice(); + update[xaxis._name + '.autorange'] = xaxis.autorange; + update[yaxis._name + '.autorange'] = yaxis.autorange; - // update user layout - layout.xaxis.autorange = xaxis.autorange; - layout.xaxis.range = xaxis.range.slice(0); - layout.yaxis.autorange = yaxis.autorange; - layout.yaxis.range = yaxis.range.slice(0); + Registry.call('_storeDirectGUIEdit', graphDiv.layout, graphDiv._fullLayout._preGUI, update); - // make a meaningful value to be passed on to the possible 'plotly_relayout' subscriber(s) - // scene.camera has no many useful projection or scale information - // helps determine which one is the latest input (if async) - var update = { - lastInputTime: this.camera.lastInputTime - }; + // update the input layout + var xaIn = layout[xaxis._name]; + xaIn.range = xrange; + xaIn.autorange = xaxis.autorange; - update[xaxis._name] = xaxis.range.slice(0); - update[yaxis._name] = yaxis.range.slice(0); + var yaIn = layout[yaxis._name]; + yaIn.range = yrange; + yaIn.autorange = yaxis.autorange; + // lastInputTime helps determine which one is the latest input (if async) + update.lastInputTime = this.camera.lastInputTime; graphDiv.emit('plotly_relayout', update); }; @@ -92141,7 +93817,7 @@ proto.hoverFormatter = function(axisName, val) { return Axes.tickText(axis, axis.c2l(val), 'hover').text; }; -},{"../../components/fx":361,"../../lib/html2unicode":439,"../../lib/show_no_webgl_msg":462,"../../plots/cartesian/axes":488,"../../registry":532,"../cartesian/autorange":487,"../cartesian/constants":494,"../cartesian/constraints":496,"./camera":518,"./convert":519,"gl-plot2d":174,"gl-select-box":178,"gl-spikes2d":187,"webgl-context":300}],522:[function(_dereq_,module,exports){ +},{"../../components/fx":357,"../../lib/show_no_webgl_msg":458,"../../plots/cartesian/axes":484,"../../registry":528,"../cartesian/autorange":483,"../cartesian/constants":490,"../cartesian/constraints":492,"./camera":514,"./convert":515,"gl-plot2d":174,"gl-select-box":178,"gl-spikes2d":187,"webgl-context":299}],518:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92175,7 +93851,7 @@ function project(camera, v) { module.exports = project; -},{}],523:[function(_dereq_,module,exports){ +},{}],519:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92188,6 +93864,9 @@ module.exports = project; var fontAttrs = _dereq_('./font_attributes'); var colorAttrs = _dereq_('../components/color/attributes'); +var colorscaleAttrs = _dereq_('../components/colorscale/layout_attributes'); +var padAttrs = _dereq_('./pad_attributes'); +var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', @@ -92200,15 +93879,71 @@ globalFont.color.dflt = colorAttrs.defaultLine; module.exports = { font: globalFont, title: { - valType: 'string', - - editType: 'layoutstyle', - + text: { + valType: 'string', + + editType: 'layoutstyle', + + }, + font: fontAttrs({ + editType: 'layoutstyle', + + }), + xref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + yref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + x: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.5, + + editType: 'layoutstyle', + + }, + y: { + valType: 'number', + min: 0, + max: 1, + dflt: 'auto', + + editType: 'layoutstyle', + + }, + xanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'left', 'center', 'right'], + + editType: 'layoutstyle', + + }, + yanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'top', 'middle', 'bottom'], + + editType: 'layoutstyle', + + }, + pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { + + }), + editType: 'layoutstyle' }, - titlefont: fontAttrs({ - editType: 'layoutstyle', - - }), autosize: { valType: 'boolean', @@ -92327,11 +94062,30 @@ module.exports = { editType: 'calc', }, + colorscale: colorscaleAttrs, datarevision: { valType: 'any', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editrevision: { + valType: 'any', + + editType: 'none', + + }, + selectionrevision: { + valType: 'any', + + editType: 'none', + }, template: { valType: 'any', @@ -92365,12 +94119,30 @@ module.exports = { editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'modebar' + }, + _deprecated: { + title: { + valType: 'string', + + editType: 'layoutstyle', + + }, + titlefont: fontAttrs({ + editType: 'layoutstyle', + + }) } }; -},{"../components/color/attributes":318,"./font_attributes":515}],524:[function(_dereq_,module,exports){ +},{"../components/color/attributes":317,"../components/colorscale/layout_attributes":331,"../lib/extend":429,"./font_attributes":511,"./pad_attributes":520}],520:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92381,42 +94153,51 @@ module.exports = { 'use strict'; -// This is used exclusively by components inside component arrays, -// hence the 'arraydraw' editType. If this ever gets used elsewhere -// we could generalize it as a function ala font_attributes -module.exports = { - t: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - r: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - b: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - l: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - editType: 'arraydraw' +/** + * Creates a set of padding attributes. + * + * @param {object} opts + * @param {string} editType: + * the editType for all pieces of this padding definition + * + * @return {object} attributes object containing {t, r, b, l} as specified + */ +module.exports = function(opts) { + var editType = opts.editType; + return { + t: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + r: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + b: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + l: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + editType: editType + }; }; -},{}],525:[function(_dereq_,module,exports){ +},{}],521:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92868,6 +94649,7 @@ plots.supplyDefaults = function(gd, opts) { for(i = 0; i < crossTraceDefaultsFuncs.length; i++) { crossTraceDefaultsFuncs[i](newFullData, newFullLayout); } + Registry.getComponentMethod('colorscale', 'crossTraceDefaults')(newFullData, newFullLayout); // turn on flag to optimize large splom-only graphs // mostly by omitting SVG layers during Cartesian.drawFramework @@ -92898,16 +94680,30 @@ plots.supplyDefaults = function(gd, opts) { // relink functions and _ attributes to promote consistency between plots relinkPrivateKeys(newFullLayout, oldFullLayout); - // TODO may return a promise - plots.doAutoMargin(gd); - - // set scale after auto margin routine - var axList = axisIDs.list(gd); - for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - ax.setScale(); + // For persisting GUI-driven changes in layout + // _preGUI and _tracePreGUI were already copied over in relinkPrivateKeys + if(!newFullLayout._preGUI) newFullLayout._preGUI = {}; + // track trace GUI changes by uid rather than by trace index + if(!newFullLayout._tracePreGUI) newFullLayout._tracePreGUI = {}; + var tracePreGUI = newFullLayout._tracePreGUI; + var uids = {}; + var uid; + for(uid in tracePreGUI) uids[uid] = 'old'; + for(i = 0; i < newFullData.length; i++) { + uid = newFullData[i]._fullInput.uid; + if(!uids[uid]) tracePreGUI[uid] = {}; + uids[uid] = 'new'; + } + for(uid in uids) { + if(uids[uid] === 'old') delete tracePreGUI[uid]; } + // set up containers for margin calculations + initMargins(newFullLayout); + + // collect and do some initial calculations for rangesliders + Registry.getComponentMethod('rangeslider', 'makeData')(newFullLayout); + // update object references in calcdata if(!skipUpdateCalc && oldCalcdata.length === newFullData.length) { plots.supplyDefaultsUpdateCalc(oldCalcdata, newFullData); @@ -93216,6 +95012,12 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa plotinfo.id = id; } + // add these axis ids to each others' subplot lists + xaxis._counterAxes.push(yaxis._id); + yaxis._counterAxes.push(xaxis._id); + xaxis._subplotsWith.push(id); + yaxis._subplotsWith.push(id); + // update x and y axis layout object refs plotinfo.xaxis = xaxis; plotinfo.yaxis = yaxis; @@ -93243,8 +95045,9 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // while we're at it, link overlaying axes to their main axes and // anchored axes to the axes they're anchored to var axList = axisIDs.list(mockGd, null, true); + var ax; for(i = 0; i < axList.length; i++) { - var ax = axList[i]; + ax = axList[i]; var mainAx = null; if(ax.overlaying) { @@ -93272,8 +95075,53 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa null : axisIDs.getFromId(mockGd, ax.anchor); } + + // finally, we can find the main subplot for each axis + // (on which the ticks & labels are drawn) + for(i = 0; i < axList.length; i++) { + ax = axList[i]; + ax._counterAxes.sort(axisIDs.idSort); + ax._subplotsWith.sort(Lib.subplotSort); + ax._mainSubplot = findMainSubplot(ax, newFullLayout); + } }; +function findMainSubplot(ax, fullLayout) { + var mockGd = {_fullLayout: fullLayout}; + + var isX = ax._id.charAt(0) === 'x'; + var anchorAx = ax._mainAxis._anchorAxis; + var mainSubplotID = ''; + var nextBestMainSubplotID = ''; + var anchorID = ''; + + // First try the main ID with the anchor + if(anchorAx) { + anchorID = anchorAx._mainAxis._id; + mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); + } + + // Then look for a subplot with the counteraxis overlaying the anchor + // If that fails just use the first subplot including this axis + if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { + mainSubplotID = ''; + + var counterIDs = ax._counterAxes; + for(var j = 0; j < counterIDs.length; j++) { + var counterPart = counterIDs[j]; + var id = isX ? (ax._id + counterPart) : (counterPart + ax._id); + if(!nextBestMainSubplotID) nextBestMainSubplotID = id; + var counterAx = axisIDs.getFromId(mockGd, counterPart); + if(anchorID && counterAx.overlaying === anchorID) { + mainSubplotID = id; + break; + } + } + } + + return mainSubplotID || nextBestMainSubplotID; +} + // This function clears any trace attributes with valType: color and // no set dflt filed in the plot schema. This is needed because groupby (which // is the only transform for which this currently applies) supplies parent @@ -93541,6 +95389,8 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac coerce('type'); coerce('name', layout._traceWord + ' ' + traceInIndex); + coerce('uirevision', layout.uirevision); + // we want even invisible traces to make their would-be subplots visible // so coerce the subplot id(s) now no matter what var _module = plots.getModule(traceOut); @@ -93614,7 +95464,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac if(_module) { _module.supplyDefaults(traceIn, traceOut, defaultColor, layout); - Lib.coerceHoverinfo(traceIn, traceOut, layout); + if(!traceOut.hovertemplate) Lib.coerceHoverinfo(traceIn, traceOut, layout); } if(!Registry.traceIs(traceOut, 'noOpacity')) coerce('opacity'); @@ -93743,14 +95593,25 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { var globalFont = Lib.coerceFont(coerce, 'font'); - coerce('title', layoutOut._dfltTitle.plot); + coerce('title.text', layoutOut._dfltTitle.plot); - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: globalFont.family, size: Math.round(globalFont.size * 1.4), color: globalFont.color }); + coerce('title.xref'); + coerce('title.yref'); + coerce('title.x'); + coerce('title.y'); + coerce('title.xanchor'); + coerce('title.yanchor'); + coerce('title.pad.t'); + coerce('title.pad.r'); + coerce('title.pad.b'); + coerce('title.pad.l'); + // Make sure that autosize is defaulted to *true* // on layouts with no set width and height for backward compatibly, // in particular https://plot.ly/javascript/responsive-fluid-layout/ @@ -93783,12 +95644,16 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('colorway'); coerce('datarevision'); + var uirevision = coerce('uirevision'); + coerce('editrevision', uirevision); + coerce('selectionrevision', uirevision); coerce('modebar.orientation'); coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); + coerce('modebar.uirevision', uirevision); Registry.getComponentMethod( 'calendars', @@ -94070,7 +95935,20 @@ plots.allowAutoMargin = function(gd, id) { gd._fullLayout._pushmarginIds[id] = 1; }; -function setupAutoMargin(fullLayout) { +function initMargins(fullLayout) { + var margin = fullLayout.margin; + + if(!fullLayout._size) { + var gs = fullLayout._size = { + l: Math.round(margin.l), + r: Math.round(margin.r), + t: Math.round(margin.t), + b: Math.round(margin.b), + p: Math.round(margin.pad) + }; + gs.w = Math.round(fullLayout.width) - gs.l - gs.r; + gs.h = Math.round(fullLayout.height) - gs.t - gs.b; + } if(!fullLayout._pushmargin) fullLayout._pushmargin = {}; if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {}; } @@ -94093,8 +95971,6 @@ function setupAutoMargin(fullLayout) { plots.autoMargin = function(gd, id, o) { var fullLayout = gd._fullLayout; - setupAutoMargin(fullLayout); - var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -94138,18 +96014,19 @@ plots.autoMargin = function(gd, id, o) { plots.doAutoMargin = function(gd) { var fullLayout = gd._fullLayout; if(!fullLayout._size) fullLayout._size = {}; - setupAutoMargin(fullLayout); + initMargins(fullLayout); - var gs = fullLayout._size, - oldmargins = JSON.stringify(gs); + var gs = fullLayout._size; + var oldmargins = JSON.stringify(gs); + var margin = fullLayout.margin; // adjust margins for outside components // fullLayout.margin is the requested margin, // fullLayout._size has margins and plotsize after adjustment - var ml = Math.max(fullLayout.margin.l || 0, 0); - var mr = Math.max(fullLayout.margin.r || 0, 0); - var mt = Math.max(fullLayout.margin.t || 0, 0); - var mb = Math.max(fullLayout.margin.b || 0, 0); + var ml = margin.l; + var mr = margin.r; + var mt = margin.t; + var mb = margin.b; var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -94219,7 +96096,7 @@ plots.doAutoMargin = function(gd) { gs.r = Math.round(mr); gs.t = Math.round(mt); gs.b = Math.round(mb); - gs.p = Math.round(fullLayout.margin.pad); + gs.p = Math.round(margin.pad); gs.w = Math.round(fullLayout.width) - gs.l - gs.r; gs.h = Math.round(fullLayout.height) - gs.t - gs.b; @@ -95100,7 +96977,7 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl subplot.traceHash = traceHash; }; -},{"../components/color":319,"../constants/numerical":420,"../lib":441,"../plot_api/plot_schema":477,"../plot_api/plot_template":478,"../plots/cartesian/axis_ids":491,"../registry":532,"./animation_attributes":483,"./attributes":485,"./command":513,"./font_attributes":515,"./frame_attributes":516,"./layout_attributes":523,"d3":85,"fast-isnumeric":149}],526:[function(_dereq_,module,exports){ +},{"../components/color":318,"../constants/numerical":416,"../lib":437,"../plot_api/plot_schema":473,"../plot_api/plot_template":474,"../plots/cartesian/axis_ids":487,"../registry":528,"./animation_attributes":479,"./attributes":481,"./command":509,"./font_attributes":511,"./frame_attributes":512,"./layout_attributes":519,"d3":85,"fast-isnumeric":149}],522:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95144,7 +97021,7 @@ module.exports = { } }; -},{"../../../lib/extend":432,"../../../traces/scatter/attributes":592}],527:[function(_dereq_,module,exports){ +},{"../../../lib/extend":429,"../../../traces/scatter/attributes":587}],523:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95266,7 +97143,7 @@ module.exports = overrideAll({ } }, 'plot', 'nested'); -},{"../../../lib/extend":432,"../../../plot_api/edit_types":471,"../../cartesian/layout_attributes":501}],528:[function(_dereq_,module,exports){ +},{"../../../lib/extend":429,"../../../plot_api/edit_types":467,"../../cartesian/layout_attributes":497}],524:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95281,7 +97158,7 @@ var Polar = module.exports = _dereq_('./micropolar'); Polar.manager = _dereq_('./micropolar_manager'); -},{"./micropolar":529,"./micropolar_manager":530}],529:[function(_dereq_,module,exports){ +},{"./micropolar":525,"./micropolar_manager":526}],525:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95499,8 +97376,8 @@ var µ = module.exports = { version: '0.2.2' }; centeringOffset[0] = Math.max(0, centeringOffset[0]); centeringOffset[1] = Math.max(0, centeringOffset[1]); svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title); + if (axisConfig.title && axisConfig.title.text) { + var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); var titleBBox = title.node().getBBox(); title.attr({ x: chartCenter[0] - titleBBox.width / 2, @@ -96701,7 +98578,7 @@ var µ = module.exports = { version: '0.2.2' }; return exports; }; -},{"../../../constants/alignment":417,"../../../lib":441,"d3":85}],530:[function(_dereq_,module,exports){ +},{"../../../constants/alignment":413,"../../../lib":437,"d3":85}],526:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96787,7 +98664,7 @@ manager.fillLayout = function(_gd) { _gd._fullLayout = extendDeepAll(dflts, _gd.layout); }; -},{"../../../components/color":319,"../../../lib":441,"./micropolar":529,"./undo_manager":531,"d3":85}],531:[function(_dereq_,module,exports){ +},{"../../../components/color":318,"../../../lib":437,"./micropolar":525,"./undo_manager":527,"d3":85}],527:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96853,7 +98730,7 @@ module.exports = function UndoManager() { }; }; -},{}],532:[function(_dereq_,module,exports){ +},{}],528:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97295,7 +99172,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/extend":432,"./lib/is_plain_object":442,"./lib/loggers":445,"./lib/noop":450,"./lib/push_unique":455,"./plots/attributes":485,"./plots/layout_attributes":523}],533:[function(_dereq_,module,exports){ +},{"./lib/extend":429,"./lib/is_plain_object":438,"./lib/loggers":441,"./lib/noop":446,"./lib/push_unique":451,"./plots/attributes":481,"./plots/layout_attributes":519}],529:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97322,7 +99199,7 @@ function cloneLayoutOverride(tileClass) { autosize: true, width: 150, height: 150, - title: '', + title: {text: ''}, showlegend: false, margin: {l: 5, r: 5, t: 5, b: 5, pad: 0}, annotations: [] @@ -97331,7 +99208,7 @@ function cloneLayoutOverride(tileClass) { case 'thumbnail': override = { - title: '', + title: {text: ''}, hidesources: true, showlegend: false, borderwidth: 0, @@ -97379,7 +99256,7 @@ module.exports = function clonePlot(graphObj, options) { for(i = 0; i < keys.length; i++) { if(keyIsAxis(keys[i])) { - newLayout[keys[i]].title = ''; + newLayout[keys[i]].title = {text: ''}; } } @@ -97407,7 +99284,7 @@ module.exports = function clonePlot(graphObj, options) { var axesImageOverride = {}; if(options.tileClass === 'thumbnail') { axesImageOverride = { - title: '', + title: {text: ''}, showaxeslabels: false, showticklabels: false, linetickenable: false @@ -97469,7 +99346,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":441}],534:[function(_dereq_,module,exports){ +},{"../lib":437}],530:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97537,7 +99414,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":441,"../plot_api/to_image":481,"./filesaver":535}],535:[function(_dereq_,module,exports){ +},{"../lib":437,"../plot_api/to_image":477,"./filesaver":531}],531:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97609,7 +99486,7 @@ var fileSaver = function(url, name) { module.exports = fileSaver; -},{}],536:[function(_dereq_,module,exports){ +},{}],532:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97646,7 +99523,7 @@ exports.getRedrawFunc = function(gd) { }; }; -},{}],537:[function(_dereq_,module,exports){ +},{}],533:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97672,7 +99549,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":533,"./download":534,"./helpers":536,"./svgtoimg":538,"./toimage":539,"./tosvg":540}],538:[function(_dereq_,module,exports){ +},{"./cloneplot":529,"./download":530,"./helpers":532,"./svgtoimg":534,"./toimage":535,"./tosvg":536}],534:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97788,7 +99665,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":441,"events":50}],539:[function(_dereq_,module,exports){ +},{"../lib":437,"events":50}],535:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97867,7 +99744,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":441,"../registry":532,"./cloneplot":533,"./helpers":536,"./svgtoimg":538,"./tosvg":540,"events":50}],540:[function(_dereq_,module,exports){ +},{"../lib":437,"../registry":528,"./cloneplot":529,"./helpers":532,"./svgtoimg":534,"./tosvg":536,"events":50}],536:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98049,7 +99926,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":319,"../components/drawing":344,"../constants/xmlns_namespaces":421,"../lib":441,"d3":85}],541:[function(_dereq_,module,exports){ +},{"../components/color":318,"../components/drawing":339,"../constants/xmlns_namespaces":417,"../lib":437,"d3":85}],537:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98228,7 +100105,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":320,"../../components/colorscale/attributes":326,"../../components/drawing/attributes":343,"../../constants/filter_ops":418,"../../lib/extend":432,"../../plots/font_attributes":515,"../heatmap/attributes":554,"../scatter/attributes":592}],542:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":319,"../../components/colorscale/attributes":325,"../../components/drawing/attributes":338,"../../constants/filter_ops":414,"../../lib/extend":429,"../../plots/font_attributes":511,"../heatmap/attributes":550,"../scatter/attributes":587}],538:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98252,7 +100129,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../heatmap/calc":555,"./set_contours":550}],543:[function(_dereq_,module,exports){ +},{"../heatmap/calc":551,"./set_contours":546}],539:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98303,7 +100180,7 @@ module.exports = function colorbar(gd, cd) { .options(trace.colorbar)(); }; -},{"../../components/colorbar/draw":324,"./end_plus":547,"./make_color_map":549}],544:[function(_dereq_,module,exports){ +},{"../../components/colorbar/draw":323,"./end_plus":543,"./make_color_map":545}],540:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98398,7 +100275,7 @@ function handleConstraintValueDefaults(coerce, contours) { } } -},{"../../components/color":319,"../../constants/filter_ops":418,"./label_defaults":548,"fast-isnumeric":149}],545:[function(_dereq_,module,exports){ +},{"../../components/color":318,"../../constants/filter_ops":414,"./label_defaults":544,"fast-isnumeric":149}],541:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98427,7 +100304,7 @@ module.exports = function handleContourDefaults(traceIn, traceOut, coerce, coerc if(autoContour || !contourSize) coerce('ncontours'); }; -},{}],546:[function(_dereq_,module,exports){ +},{}],542:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98476,7 +100353,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../lib":441,"../heatmap/xyz_defaults":565,"./attributes":541,"./constraint_defaults":544,"./contours_defaults":545,"./style_defaults":551}],547:[function(_dereq_,module,exports){ +},{"../../lib":437,"../heatmap/xyz_defaults":560,"./attributes":537,"./constraint_defaults":540,"./contours_defaults":541,"./style_defaults":547}],543:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98496,7 +100373,7 @@ module.exports = function endPlus(contours) { return contours.end + contours.size / 1e6; }; -},{}],548:[function(_dereq_,module,exports){ +},{}],544:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98526,7 +100403,7 @@ module.exports = function handleLabelDefaults(coerce, layout, lineColor, opts) { if(opts.hasHover !== false) coerce('zhoverformat'); }; -},{"../../lib":441}],549:[function(_dereq_,module,exports){ +},{"../../lib":437}],545:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98555,11 +100432,13 @@ module.exports = function makeColorMap(trace) { nc = 1; } - var scl = trace.colorscale, - len = scl.length; + var scl = trace.reversescale ? + Colorscale.flipScale(trace.colorscale) : + trace.colorscale; - var domain = new Array(len), - range = new Array(len); + var len = scl.length; + var domain = new Array(len); + var range = new Array(len); var si, i; @@ -98610,7 +100489,7 @@ module.exports = function makeColorMap(trace) { }); }; -},{"../../components/colorscale":334,"./end_plus":547,"d3":85}],550:[function(_dereq_,module,exports){ +},{"../../components/colorscale":330,"./end_plus":543,"d3":85}],546:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98714,7 +100593,7 @@ function autoContours(start, end, ncontours) { return dummyAx; } -},{"../../lib":441,"../../plots/cartesian/axes":488}],551:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/cartesian/axes":484}],547:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98759,7 +100638,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, layout, handleLabelDefaults(coerce, layout, lineColor, opts); }; -},{"../../components/colorscale/defaults":329,"./label_defaults":548}],552:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":328,"./label_defaults":544}],548:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98948,7 +100827,7 @@ function createContour(scene, fullTrace, calcTrace) { module.exports = createContour; -},{"../../lib/str2rgbarray":464,"../../plots/cartesian/axes":488,"../contour/make_color_map":549,"gl-contour2d":159,"gl-heatmap2d":164}],553:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":460,"../../plots/cartesian/axes":484,"../contour/make_color_map":545,"gl-contour2d":159,"gl-heatmap2d":164}],549:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98981,7 +100860,7 @@ ContourGl.meta = { module.exports = ContourGl; -},{"../../plot_api/edit_types":471,"../../plots/gl2d":520,"../contour/attributes":541,"../contour/calc":542,"../contour/colorbar":543,"../contour/defaults":546,"./convert":552}],554:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":467,"../../plots/gl2d":516,"../contour/attributes":537,"../contour/calc":538,"../contour/colorbar":539,"../contour/defaults":542,"./convert":548}],550:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99084,7 +100963,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":320,"../../components/colorscale/attributes":326,"../../lib/extend":432,"../scatter/attributes":592}],555:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":319,"../../components/colorscale/attributes":325,"../../lib/extend":429,"../scatter/attributes":587}],551:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99103,7 +100982,6 @@ var Axes = _dereq_('../../plots/cartesian/axes'); var histogram2dCalc = _dereq_('../histogram2d/calc'); var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var convertColumnData = _dereq_('./convert_column_xyz'); -var maxRowLength = _dereq_('./max_row_length'); var clean2dArray = _dereq_('./clean_2d_array'); var interp2d = _dereq_('./interp2d'); var findEmpties = _dereq_('./find_empties'); @@ -99203,7 +101081,7 @@ module.exports = function calc(gd, trace) { } // create arrays of brick boundaries, to be used by autorange and heatmap.plot - var xlen = maxRowLength(z); + var xlen = Lib.maxRowLength(z); var xIn = trace.xtype === 'scaled' ? '' : x; var xArray = makeBoundArray(trace, xIn, x0, dx, xlen, xa); var yIn = trace.ytype === 'scaled' ? '' : y; @@ -99233,7 +101111,11 @@ module.exports = function calc(gd, trace) { // auto-z and autocolorscale if applicable if(!isContour || trace.contours.type !== 'constraint') { - colorscaleCalc(trace, z, '', 'z'); + colorscaleCalc(gd, trace, { + vals: z, + containerStr: '', + cLetter: 'z' + }); } if(isContour && trace.contours && trace.contours.coloring === 'heatmap') { @@ -99249,7 +101131,7 @@ module.exports = function calc(gd, trace) { return [cd0]; }; -},{"../../components/colorscale/calc":327,"../../lib":441,"../../plots/cartesian/axes":488,"../../registry":532,"../histogram2d/calc":573,"./clean_2d_array":556,"./convert_column_xyz":558,"./find_empties":560,"./interp2d":561,"./make_bound_array":562,"./max_row_length":563}],556:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":326,"../../lib":437,"../../plots/cartesian/axes":484,"../../registry":528,"../histogram2d/calc":568,"./clean_2d_array":552,"./convert_column_xyz":554,"./find_empties":556,"./interp2d":557,"./make_bound_array":558}],552:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99294,7 +101176,7 @@ module.exports = function clean2dArray(zOld, transpose) { return zNew; }; -},{"fast-isnumeric":149}],557:[function(_dereq_,module,exports){ +},{"fast-isnumeric":149}],553:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99310,7 +101192,7 @@ module.exports = { max: 'zmax' }; -},{}],558:[function(_dereq_,module,exports){ +},{}],554:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99327,43 +101209,36 @@ var BADNUM = _dereq_('../../constants/numerical').BADNUM; module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, arrayVarNames) { var colLen = trace._length; - var col1 = trace[var1Name].slice(0, colLen); - var col2 = trace[var2Name].slice(0, colLen); + var col1 = ax1.makeCalcdata(trace, var1Name); + var col2 = ax2.makeCalcdata(trace, var2Name); var textCol = trace.text; var hasColumnText = (textCol !== undefined && Lib.isArray1D(textCol)); - var col1Calendar = trace[var1Name + 'calendar']; - var col2Calendar = trace[var2Name + 'calendar']; - - var i, j, arrayVar, newArray, arrayVarName; - - for(i = 0; i < colLen; i++) { - col1[i] = ax1.d2c(col1[i], 0, col1Calendar); - col2[i] = ax2.d2c(col2[i], 0, col2Calendar); - } + var i, j; - var col1dv = Lib.distinctVals(col1), - col1vals = col1dv.vals, - col2dv = Lib.distinctVals(col2), - col2vals = col2dv.vals, - newArrays = []; + var col1dv = Lib.distinctVals(col1); + var col1vals = col1dv.vals; + var col2dv = Lib.distinctVals(col2); + var col2vals = col2dv.vals; + var newArrays = []; + var text; for(i = 0; i < arrayVarNames.length; i++) { newArrays[i] = Lib.init2dArray(col2vals.length, col1vals.length); } - var i1, i2, text; - - if(hasColumnText) text = Lib.init2dArray(col2vals.length, col1vals.length); + if(hasColumnText) { + text = Lib.init2dArray(col2vals.length, col1vals.length); + } for(i = 0; i < colLen; i++) { if(col1[i] !== BADNUM && col2[i] !== BADNUM) { - i1 = Lib.findBin(col1[i] + col1dv.minDiff / 2, col1vals); - i2 = Lib.findBin(col2[i] + col2dv.minDiff / 2, col2vals); + var i1 = Lib.findBin(col1[i] + col1dv.minDiff / 2, col1vals); + var i2 = Lib.findBin(col2[i] + col2dv.minDiff / 2, col2vals); for(j = 0; j < arrayVarNames.length; j++) { - arrayVarName = arrayVarNames[j]; - arrayVar = trace[arrayVarName]; - newArray = newArrays[j]; + var arrayVarName = arrayVarNames[j]; + var arrayVar = trace[arrayVarName]; + var newArray = newArrays[j]; newArray[i2][i1] = arrayVar[i]; } @@ -99379,7 +101254,7 @@ module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, if(hasColumnText) trace._text = text; }; -},{"../../constants/numerical":420,"../../lib":441}],559:[function(_dereq_,module,exports){ +},{"../../constants/numerical":416,"../../lib":437}],555:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99419,7 +101294,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}); }; -},{"../../components/colorscale/defaults":329,"../../lib":441,"./attributes":554,"./style_defaults":564,"./xyz_defaults":565}],560:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":328,"../../lib":437,"./attributes":550,"./style_defaults":559,"./xyz_defaults":560}],556:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99430,7 +101305,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout 'use strict'; -var maxRowLength = _dereq_('./max_row_length'); +var maxRowLength = _dereq_('../../lib').maxRowLength; /* Return a list of empty points in 2D array z * each empty point z[i][j] gives an array [i, j, neighborCount] @@ -99525,7 +101400,7 @@ module.exports = function findEmpties(z) { return empties.sort(function(a, b) { return b[2] - a[2]; }); }; -},{"./max_row_length":563}],561:[function(_dereq_,module,exports){ +},{"../../lib":437}],557:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99660,7 +101535,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { return maxFractionalChange; } -},{"../../lib":441}],562:[function(_dereq_,module,exports){ +},{"../../lib":437}],558:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99730,10 +101605,15 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, var calendar = trace[ax._id.charAt(0) + 'calendar']; - if(isHist || ax.type === 'category') v0 = ax.r2c(v0In, 0, calendar) || 0; - else if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) v0 = arrayIn[0]; - else if(v0In === undefined) v0 = 0; - else v0 = ax.d2c(v0In, 0, calendar); + if(isHist || ax.type === 'category' || ax.type === 'multicategory') { + v0 = ax.r2c(v0In, 0, calendar) || 0; + } else if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) { + v0 = arrayIn[0]; + } else if(v0In === undefined) { + v0 = 0; + } else { + v0 = ax.d2c(v0In, 0, calendar); + } for(i = (isContour || isGL2D) ? 0 : -0.5; i < numbricks; i++) { arrayOut.push(v0 + dv * i); @@ -99743,29 +101623,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, return arrayOut; }; -},{"../../lib":441,"../../registry":532}],563:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function maxRowLength(z) { - var len = 0; - - for(var i = 0; i < z.length; i++) { - len = Math.max(len, z[i].length); - } - - return len; -}; - -},{}],564:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528}],559:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99788,7 +101646,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { coerce('zhoverformat'); }; -},{}],565:[function(_dereq_,module,exports){ +},{}],560:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99797,7 +101655,6 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -99817,10 +101674,13 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x x = coerce(xName); y = coerce(yName); + var xlen = Lib.minRowLength(x); + var ylen = Lib.minRowLength(y); + // column z must be accompanied by xName and yName arrays - if(!(x && x.length && y && y.length)) return 0; + if(xlen === 0 || ylen === 0) return 0; - traceOut._length = Math.min(x.length, y.length, z.length); + traceOut._length = Math.min(xlen, ylen, z.length); } else { x = coordDefaults(xName, coerce); @@ -99841,10 +101701,8 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x }; function coordDefaults(coordStr, coerce) { - var coord = coerce(coordStr), - coordType = coord ? - coerce(coordStr + 'type', 'array') : - 'scaled'; + var coord = coerce(coordStr); + var coordType = coord ? coerce(coordStr + 'type', 'array') : 'scaled'; if(coordType === 'scaled') { coerce(coordStr + '0'); @@ -99886,7 +101744,7 @@ function isValidZ(z) { return (allRowsAreArrays && oneRowIsFilled && hasOneNumber); } -},{"../../lib":441,"../../registry":532,"fast-isnumeric":149}],566:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528,"fast-isnumeric":149}],561:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99929,7 +101787,7 @@ extendFlat( module.exports = overrideAll(attrs, 'calc', 'nested'); -},{"../../components/colorbar/attributes":320,"../../components/colorscale/attributes":326,"../../lib/extend":432,"../../plot_api/edit_types":471,"../heatmap/attributes":554}],567:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":319,"../../components/colorscale/attributes":325,"../../lib/extend":429,"../../plot_api/edit_types":467,"../heatmap/attributes":550}],562:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100071,7 +101929,7 @@ function createHeatmap(scene, fullTrace, calcTrace) { module.exports = createHeatmap; -},{"../../lib/str2rgbarray":464,"../../plots/cartesian/axes":488,"gl-heatmap2d":164}],568:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":460,"../../plots/cartesian/axes":484,"gl-heatmap2d":164}],563:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100102,7 +101960,7 @@ HeatmapGl.meta = { module.exports = HeatmapGl; -},{"../../plots/gl2d":520,"../heatmap/calc":555,"../heatmap/colorbar":557,"../heatmap/defaults":559,"./attributes":566,"./convert":567}],569:[function(_dereq_,module,exports){ +},{"../../plots/gl2d":516,"../heatmap/calc":551,"../heatmap/colorbar":553,"../heatmap/defaults":555,"./attributes":561,"./convert":562}],564:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100128,7 +101986,7 @@ module.exports = function doAvg(size, counts) { return total; }; -},{}],570:[function(_dereq_,module,exports){ +},{}],565:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100204,7 +102062,7 @@ module.exports = { } }; -},{"fast-isnumeric":149}],571:[function(_dereq_,module,exports){ +},{"fast-isnumeric":149}],566:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100382,7 +102240,7 @@ function dateParts(v, pa, calendar) { return parts; } -},{"../../constants/numerical":420,"../../plots/cartesian/axes":488}],572:[function(_dereq_,module,exports){ +},{"../../constants/numerical":416,"../../plots/cartesian/axes":484}],567:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100417,7 +102275,7 @@ module.exports = { } }; -},{}],573:[function(_dereq_,module,exports){ +},{}],568:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100682,7 +102540,7 @@ function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) { return out; } -},{"../../lib":441,"../../plots/cartesian/axes":488,"../histogram/average":569,"../histogram/bin_functions":570,"../histogram/bin_label_vals":571,"../histogram/norm_functions":572}],574:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/cartesian/axes":484,"../histogram/average":564,"../histogram/bin_functions":565,"../histogram/bin_label_vals":566,"../histogram/norm_functions":567}],569:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100797,7 +102655,7 @@ module.exports = { }) }; -},{"../../components/colorbar/attributes":320,"../../components/colorscale/attributes":326,"../../lib/extend":432,"../../plot_api/plot_template":478,"../../plots/cartesian/layout_attributes":501,"../../plots/domain":514,"../../plots/font_attributes":515}],575:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":319,"../../components/colorscale/attributes":325,"../../lib/extend":429,"../../plot_api/plot_template":474,"../../plots/cartesian/layout_attributes":497,"../../plots/domain":510,"../../plots/font_attributes":511}],570:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101329,7 +103187,7 @@ module.exports = { cleanRanges: cleanRanges }; -},{"../../lib":441,"../../lib/gup":438,"./constants":578,"d3":85}],576:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../lib/gup":435,"./constants":573,"d3":85}],571:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101398,7 +103256,7 @@ exports.toSVG = function(gd) { }, 60); }; -},{"../../constants/xmlns_namespaces":421,"../../plots/get_data":517,"./plot":584,"d3":85}],577:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":417,"../../plots/get_data":513,"./plot":579,"d3":85}],572:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101409,7 +103267,7 @@ exports.toSVG = function(gd) { 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var Lib = _dereq_('../../lib'); var wrap = _dereq_('../../lib/gup').wrap; @@ -101420,7 +103278,11 @@ module.exports = function calc(gd, trace) { var cscale = cs ? trace.line.colorscale : [[0, trace.line.color], [1, trace.line.color]]; if(hasColorscale(trace, 'line')) { - calcColorscale(trace, color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: color, + containerStr: 'line', + cLetter: 'c' + }); } return wrap({ @@ -101437,7 +103299,7 @@ function constHalf(len) { return out; } -},{"../../components/colorscale/calc":327,"../../components/colorscale/has_colorscale":333,"../../lib":441,"../../lib/gup":438}],578:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":326,"../../components/colorscale/helpers":329,"../../lib":437,"../../lib/gup":435}],573:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101498,7 +103360,7 @@ module.exports = { } }; -},{}],579:[function(_dereq_,module,exports){ +},{}],574:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101510,7 +103372,7 @@ module.exports = { 'use strict'; var Lib = _dereq_('../../lib'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var handleDomainDefaults = _dereq_('../../plots/domain').defaults; var handleArrayContainerDefaults = _dereq_('../../plots/array_container_defaults'); @@ -101604,7 +103466,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceFont(coerce, 'rangefont', fontDflt); }; -},{"../../components/colorscale/defaults":329,"../../components/colorscale/has_colorscale":333,"../../lib":441,"../../plots/array_container_defaults":484,"../../plots/domain":514,"./attributes":574,"./axisbrush":575,"./constants":578,"./merge_length":582}],580:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":328,"../../components/colorscale/helpers":329,"../../lib":437,"../../plots/array_container_defaults":480,"../../plots/domain":510,"./attributes":569,"./axisbrush":570,"./constants":573,"./merge_length":577}],575:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101637,7 +103499,7 @@ Parcoords.meta = { module.exports = Parcoords; -},{"./attributes":574,"./base_plot":576,"./calc":577,"./defaults":579,"./plot":584}],581:[function(_dereq_,module,exports){ +},{"./attributes":569,"./base_plot":571,"./calc":572,"./defaults":574,"./plot":579}],576:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102169,7 +104031,7 @@ module.exports = function(canvasGL, d) { }; }; -},{"../../lib":441,"glslify":199}],582:[function(_dereq_,module,exports){ +},{"../../lib":437,"glslify":199}],577:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102207,7 +104069,7 @@ module.exports = function(traceOut, dimensions, dataAttr, len) { return len; }; -},{}],583:[function(_dereq_,module,exports){ +},{}],578:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102218,16 +104080,20 @@ module.exports = function(traceOut, dimensions, dataAttr, len) { 'use strict'; -var lineLayerMaker = _dereq_('./lines'); -var c = _dereq_('./constants'); -var Lib = _dereq_('../../lib'); var d3 = _dereq_('d3'); + +var Lib = _dereq_('../../lib'); var Drawing = _dereq_('../../components/drawing'); +var Colorscale = _dereq_('../../components/colorscale'); + var gup = _dereq_('../../lib/gup'); var keyFun = gup.keyFun; var repeat = gup.repeat; var unwrap = gup.unwrap; + +var c = _dereq_('./constants'); var brush = _dereq_('./axisbrush'); +var lineLayerMaker = _dereq_('./lines'); function visible(dimension) { return !('visible' in dimension) || dimension.visible; } @@ -102339,8 +104205,8 @@ function model(layout, d, i) { var cd0 = unwrap(d), trace = cd0.trace, lineColor = cd0.lineColor, - cscale = cd0.cscale, line = trace.line, + cscale = line.reversescale ? Colorscale.flipScale(cd0.cscale) : cd0.cscale, domain = trace.domain, dimensions = trace.dimensions, width = layout.width, @@ -102862,7 +104728,7 @@ module.exports = function(root, svg, parcoordsLineLayers, styledData, layout, ca brush.ensureAxisBrush(axisOverlays); }; -},{"../../components/drawing":344,"../../lib":441,"../../lib/gup":438,"./axisbrush":575,"./constants":578,"./lines":581,"d3":85}],584:[function(_dereq_,module,exports){ +},{"../../components/colorscale":330,"../../components/drawing":339,"../../lib":437,"../../lib/gup":435,"./axisbrush":570,"./constants":573,"./lines":576,"d3":85}],579:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102887,12 +104753,17 @@ module.exports = function plot(gd, cdparcoords) { var gdDimensions = {}; var gdDimensionsOriginalOrder = {}; + var fullIndices = {}; + var inputIndices = {}; var size = fullLayout._size; cdparcoords.forEach(function(d, i) { - gdDimensions[i] = gd.data[i].dimensions; - gdDimensionsOriginalOrder[i] = gd.data[i].dimensions.slice(); + var trace = d[0].trace; + fullIndices[i] = trace.index; + var iIn = inputIndices[i] = trace._fullInput.index; + gdDimensions[i] = gd.data[iIn].dimensions; + gdDimensionsOriginalOrder[i] = gd.data[iIn].dimensions.slice(); }); var filterChanged = function(i, originalDimensionIndex, newRanges) { @@ -102902,21 +104773,36 @@ module.exports = function plot(gd, cdparcoords) { var gdDimension = gdDimensionsOriginalOrder[i][originalDimensionIndex]; var newConstraints = newRanges.map(function(r) { return r.slice(); }); + + // Store constraint range in preGUI + // This one doesn't work if it's stored in pieces in _storeDirectGUIEdit + // because it's an array of variable dimensionality. So store the whole + // thing at once manually. + var aStr = 'dimensions[' + originalDimensionIndex + '].constraintrange'; + var preGUI = fullLayout._tracePreGUI[gd._fullData[fullIndices[i]]._fullInput.uid]; + if(preGUI[aStr] === undefined) { + var initialVal = gdDimension.constraintrange; + preGUI[aStr] = initialVal || null; + } + + var fullDimension = gd._fullData[fullIndices[i]].dimensions[originalDimensionIndex]; + if(!newConstraints.length) { delete gdDimension.constraintrange; + delete fullDimension.constraintrange; newConstraints = null; } else { if(newConstraints.length === 1) newConstraints = newConstraints[0]; gdDimension.constraintrange = newConstraints; + fullDimension.constraintrange = newConstraints.slice(); // wrap in another array for restyle event data newConstraints = [newConstraints]; } var restyleData = {}; - var aStr = 'dimensions[' + originalDimensionIndex + '].constraintrange'; restyleData[aStr] = newConstraints; - gd.emit('plotly_restyle', [restyleData, [i]]); + gd.emit('plotly_restyle', [restyleData, [inputIndices[i]]]); }; var hover = function(eventData) { @@ -102968,7 +104854,17 @@ module.exports = function plot(gd, cdparcoords) { gdDimensions[i].splice(gdDimensionsOriginalOrder[i].indexOf(d), 0, d); // insert at original index }); - gd.emit('plotly_restyle'); + // TODO: we can't really store this part of the interaction state + // directly as below, since it incudes data arrays. If we want to + // persist column order we may have to do something special for this + // case to just store the order itself. + // Registry.call('_storeDirectGUIEdit', + // gd.data[inputIndices[i]], + // fullLayout._tracePreGUI[gd._fullData[fullIndices[i]]._fullInput.uid], + // {dimensions: gdDimensions[i]} + // ); + + gd.emit('plotly_restyle', [{dimensions: [gdDimensions[i]]}, [inputIndices[i]]]); }; parcoords( @@ -102994,7 +104890,7 @@ module.exports = function plot(gd, cdparcoords) { }); }; -},{"../../lib/prepare_regl":454,"./parcoords":583}],585:[function(_dereq_,module,exports){ +},{"../../lib/prepare_regl":450,"./parcoords":578}],580:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103036,7 +104932,7 @@ exports.castOption = function castOption(item, indices) { else if(item) return item; }; -},{"../../lib":441}],586:[function(_dereq_,module,exports){ +},{"../../lib":437}],581:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103060,7 +104956,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":319,"./helpers":585}],587:[function(_dereq_,module,exports){ +},{"../../components/color":318,"./helpers":580}],582:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103163,7 +105059,7 @@ module.exports = { transforms: undefined }; -},{"../scatter/attributes":592}],588:[function(_dereq_,module,exports){ +},{"../scatter/attributes":587}],583:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103380,7 +105276,7 @@ function createPointcloud(scene, data) { module.exports = createPointcloud; -},{"../../lib/str2rgbarray":464,"../../plots/cartesian/autorange":487,"../scatter/get_trace_color":602,"gl-pointcloud2d":176}],589:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":460,"../../plots/cartesian/autorange":483,"../scatter/get_trace_color":597,"gl-pointcloud2d":176}],584:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103428,7 +105324,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor) { traceOut._length = null; }; -},{"../../lib":441,"./attributes":587}],590:[function(_dereq_,module,exports){ +},{"../../lib":437,"./attributes":582}],585:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103458,7 +105354,7 @@ pointcloud.meta = { module.exports = pointcloud; -},{"../../plots/gl2d":520,"../scatter3d/calc":619,"./attributes":587,"./convert":588,"./defaults":589}],591:[function(_dereq_,module,exports){ +},{"../../plots/gl2d":516,"../scatter3d/calc":614,"./attributes":582,"./convert":583,"./defaults":584}],586:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103510,7 +105406,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":441}],592:[function(_dereq_,module,exports){ +},{"../../lib":437}],587:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103521,6 +105417,7 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -103632,6 +105529,9 @@ module.exports = { editType: 'style', }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), line: { color: { valType: 'color', @@ -103906,7 +105806,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":320,"../../components/colorscale/attributes":326,"../../components/drawing":344,"../../components/drawing/attributes":343,"../../lib/extend":432,"../../plots/font_attributes":515,"./constants":596}],593:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":319,"../../components/colorscale/attributes":325,"../../components/drawing":339,"../../components/drawing/attributes":338,"../../components/fx/hovertemplate_attributes":356,"../../lib/extend":429,"../../plots/font_attributes":511,"./constants":591}],588:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103996,7 +105896,7 @@ function calc(gd, trace) { } arraysToCalcdata(cd, trace); - calcColorscale(trace); + calcColorscale(gd, trace); calcSelection(cd, trace); if(stackGroupOpts) { @@ -104196,7 +106096,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":420,"../../lib":441,"../../plots/cartesian/axes":488,"./arrays_to_calcdata":591,"./calc_selection":594,"./colorscale_calc":595,"./subtypes":616,"fast-isnumeric":149}],594:[function(_dereq_,module,exports){ +},{"../../constants/numerical":416,"../../lib":437,"../../plots/cartesian/axes":484,"./arrays_to_calcdata":586,"./calc_selection":589,"./colorscale_calc":590,"./subtypes":611,"fast-isnumeric":149}],589:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104215,7 +106115,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":441}],595:[function(_dereq_,module,exports){ +},{"../../lib":437}],590:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104224,31 +106124,41 @@ module.exports = function calcSelection(cd, trace) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var subTypes = _dereq_('./subtypes'); - -module.exports = function calcMarkerColorscale(trace) { +module.exports = function calcMarkerColorscale(gd, trace) { if(subTypes.hasLines(trace) && hasColorscale(trace, 'line')) { - calcColorscale(trace, trace.line.color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } if(subTypes.hasMarkers(trace)) { if(hasColorscale(trace, 'marker')) { - calcColorscale(trace, trace.marker.color, 'marker', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - calcColorscale(trace, trace.marker.line.color, 'marker.line', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } } }; -},{"../../components/colorscale/calc":327,"../../components/colorscale/has_colorscale":333,"./subtypes":616}],596:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":326,"../../components/colorscale/helpers":329,"./subtypes":611}],591:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104272,10 +106182,12 @@ module.exports = { // number of viewport sizes away from the visible region // at which we clip all lines to the perimeter - maxScreensAway: 20 + maxScreensAway: 20, + + eventDataKeys: [] }; -},{}],597:[function(_dereq_,module,exports){ +},{}],592:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104458,7 +106370,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":593}],598:[function(_dereq_,module,exports){ +},{"./calc":588}],593:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104497,7 +106409,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],599:[function(_dereq_,module,exports){ +},{}],594:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104575,7 +106487,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout dfltHoverOn.push('fills'); } coerce('hoveron', dfltHoverOn.join('+') || 'points'); - + if(traceOut.hoveron !== 'fills') coerce('hovertemplate'); var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults'); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'}); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'}); @@ -104583,7 +106495,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":441,"../../registry":532,"./attributes":592,"./constants":596,"./fillcolor_defaults":601,"./line_defaults":605,"./line_shape_defaults":607,"./marker_defaults":611,"./stack_defaults":614,"./subtypes":616,"./text_defaults":617,"./xy_defaults":618}],600:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528,"./attributes":587,"./constants":591,"./fillcolor_defaults":596,"./line_defaults":600,"./line_shape_defaults":602,"./marker_defaults":606,"./stack_defaults":609,"./subtypes":611,"./text_defaults":612,"./xy_defaults":613}],595:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104626,7 +106538,7 @@ function isValid(v) { return v || v === 0; } -},{"../../lib":441}],601:[function(_dereq_,module,exports){ +},{"../../lib":437}],596:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104664,7 +106576,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":319,"../../lib":441}],602:[function(_dereq_,module,exports){ +},{"../../components/color":318,"../../lib":437}],597:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104717,7 +106629,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":319,"./subtypes":616}],603:[function(_dereq_,module,exports){ +},{"../../components/color":318,"./subtypes":611}],598:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104813,7 +106725,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { y1: yc + rad, yLabelVal: yLabelVal, - spikeDistance: dxy(di) + spikeDistance: dxy(di), + hovertemplate: trace.hovertemplate }); fillHoverText(di, trace, pointData); @@ -104897,7 +106810,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { x1: xmax, y0: yAvg, y1: yAvg, - color: color + color: color, + hovertemplate: '%{name}' }); delete pointData.index; @@ -104912,7 +106826,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":319,"../../components/fx":361,"../../lib":441,"../../registry":532,"./fill_hover_text":600,"./get_trace_color":602}],604:[function(_dereq_,module,exports){ +},{"../../components/color":318,"../../components/fx":357,"../../lib":437,"../../registry":528,"./fill_hover_text":595,"./get_trace_color":597}],599:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104959,7 +106873,7 @@ Scatter.meta = { module.exports = Scatter; -},{"../../plots/cartesian":500,"./arrays_to_calcdata":591,"./attributes":592,"./calc":593,"./cross_trace_calc":597,"./cross_trace_defaults":598,"./defaults":599,"./hover":603,"./marker_colorbar":610,"./plot":612,"./select":613,"./style":615,"./subtypes":616}],605:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":496,"./arrays_to_calcdata":586,"./attributes":587,"./calc":588,"./cross_trace_calc":592,"./cross_trace_defaults":593,"./defaults":594,"./hover":598,"./marker_colorbar":605,"./plot":607,"./select":608,"./style":610,"./subtypes":611}],600:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104971,7 +106885,7 @@ module.exports = Scatter; 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) { @@ -104990,7 +106904,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":329,"../../components/colorscale/has_colorscale":333,"../../lib":441}],606:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":328,"../../components/colorscale/helpers":329,"../../lib":437}],601:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105455,7 +107369,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":420,"../../lib":441,"./constants":596}],607:[function(_dereq_,module,exports){ +},{"../../constants/numerical":416,"../../lib":437,"./constants":591}],602:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105474,7 +107388,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],608:[function(_dereq_,module,exports){ +},{}],603:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105567,7 +107481,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],609:[function(_dereq_,module,exports){ +},{}],604:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105609,7 +107523,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":149}],610:[function(_dereq_,module,exports){ +},{"fast-isnumeric":149}],605:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105627,7 +107541,7 @@ module.exports = { max: 'cmax' }; -},{}],611:[function(_dereq_,module,exports){ +},{}],606:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105636,11 +107550,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var subTypes = _dereq_('./subtypes'); @@ -105710,7 +107623,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":319,"../../components/colorscale/defaults":329,"../../components/colorscale/has_colorscale":333,"./subtypes":616}],612:[function(_dereq_,module,exports){ +},{"../../components/color":318,"../../components/colorscale/defaults":328,"../../components/colorscale/helpers":329,"./subtypes":611}],607:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105801,7 +107714,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition function createFills(gd, traceJoin, plotinfo) { traceJoin.each(function(d) { var fills = ensureSingle(d3.select(this), 'g', 'fills'); - Drawing.setClipUrl(fills, plotinfo.layerClipId); + Drawing.setClipUrl(fills, plotinfo.layerClipId, gd); var trace = d[0].trace; @@ -105853,7 +107766,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition var text = ensureSingle(tr, 'g', 'text'); // error bars are at the bottom - Registry.getComponentMethod('errorbars', 'plot')(errorBarGroup, plotinfo, transitionOpts); + Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts); if(trace.visible !== true) return; @@ -106008,7 +107921,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.lineGroupStyle) .each(makeUpdate(true)); - Drawing.setClipUrl(lineJoin, plotinfo.layerClipId); + Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd); function clearFill(selection) { transition(selection).attr('d', 'M0,0Z'); @@ -106236,8 +108149,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = trace.cliponaxis === false; var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId; - Drawing.setClipUrl(points, clipUrl); - Drawing.setClipUrl(text, clipUrl); + Drawing.setClipUrl(points, clipUrl, gd); + Drawing.setClipUrl(text, clipUrl, gd); } function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { @@ -106282,7 +108195,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":344,"../../lib":441,"../../lib/polygon":453,"../../registry":532,"./line_points":606,"./link_traces":608,"./subtypes":616,"d3":85}],613:[function(_dereq_,module,exports){ +},{"../../components/drawing":339,"../../lib":437,"../../lib/polygon":449,"../../registry":528,"./line_points":601,"./link_traces":603,"./subtypes":611,"d3":85}],608:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106337,7 +108250,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":616}],614:[function(_dereq_,module,exports){ +},{"./subtypes":611}],609:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106443,7 +108356,7 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],615:[function(_dereq_,module,exports){ +},{}],610:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106515,7 +108428,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":344,"../../registry":532,"d3":85}],616:[function(_dereq_,module,exports){ +},{"../../components/drawing":339,"../../registry":528,"d3":85}],611:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106554,7 +108467,7 @@ module.exports = { } }; -},{"../../lib":441}],617:[function(_dereq_,module,exports){ +},{"../../lib":437}],612:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106584,7 +108497,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":441}],618:[function(_dereq_,module,exports){ +},{"../../lib":437}],613:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106593,34 +108506,32 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var Lib = _dereq_('../../lib'); var Registry = _dereq_('../../registry'); - module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { - var len, - x = coerce('x'), - y = coerce('y'); + var x = coerce('x'); + var y = coerce('y'); + var len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); if(x) { + var xlen = Lib.minRowLength(x); if(y) { - len = Math.min(x.length, y.length); - } - else { - len = x.length; + len = Math.min(xlen, Lib.minRowLength(y)); + } else { + len = xlen; coerce('y0'); coerce('dy'); } - } - else { + } else { if(!y) return 0; - len = traceOut.y.length; + len = Lib.minRowLength(y); coerce('x0'); coerce('dx'); } @@ -106630,7 +108541,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../registry":532}],619:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528}],614:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106642,8 +108553,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { 'use strict'; var arraysToCalcdata = _dereq_('../scatter/arrays_to_calcdata'); -var calcColorscales = _dereq_('../scatter/colorscale_calc'); - +var calcColorscale = _dereq_('../scatter/colorscale_calc'); /** * This is a kludge to put the array attributes into @@ -106654,12 +108564,12 @@ module.exports = function calc(gd, trace) { var cd = [{x: false, y: false, trace: trace, t: {}}]; arraysToCalcdata(cd, trace); - calcColorscales(trace); + calcColorscale(gd, trace); return cd; }; -},{"../scatter/arrays_to_calcdata":591,"../scatter/colorscale_calc":595}],620:[function(_dereq_,module,exports){ +},{"../scatter/arrays_to_calcdata":586,"../scatter/colorscale_calc":590}],615:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106754,8 +108664,9 @@ var attrs = module.exports = overrideAll({ }, 'calc', 'nested'); attrs.x.editType = attrs.y.editType = attrs.x0.editType = attrs.y0.editType = 'calc+clearAxisTypes'; +attrs.hovertemplate = scatterAttrs.hovertemplate; -},{"../../components/colorscale/attributes":326,"../../lib/extend":432,"../../plot_api/edit_types":471,"../../plots/attributes":485,"../scatter/attributes":592,"./constants":621}],621:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":325,"../../lib/extend":429,"../../plot_api/edit_types":467,"../../plots/attributes":481,"../scatter/attributes":587,"./constants":616}],616:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106788,7 +108699,7 @@ module.exports = { } }; -},{}],622:[function(_dereq_,module,exports){ +},{}],617:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107403,7 +109314,7 @@ module.exports = { textPosition: convertTextPosition }; -},{"../../components/drawing":344,"../../constants/interactions":419,"../../lib":441,"../../lib/gl_format_color":437,"../../plots/cartesian/axis_ids":491,"../../registry":532,"../scatter/make_bubble_size_func":609,"../scatter/subtypes":616,"./constants":621,"color-normalize":63,"fast-isnumeric":149,"svg-path-sdf":282}],623:[function(_dereq_,module,exports){ +},{"../../components/drawing":339,"../../constants/interactions":415,"../../lib":437,"../../lib/gl_format_color":434,"../../plots/cartesian/axis_ids":487,"../../registry":528,"../scatter/make_bubble_size_func":604,"../scatter/subtypes":611,"./constants":616,"color-normalize":63,"fast-isnumeric":149,"svg-path-sdf":281}],618:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107443,6 +109354,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); + coerce('hovertemplate'); coerce('mode', defaultMode); if(subTypes.hasLines(traceOut)) { @@ -107472,7 +109384,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":441,"../../registry":532,"../scatter/constants":596,"../scatter/fillcolor_defaults":601,"../scatter/line_defaults":605,"../scatter/marker_defaults":611,"../scatter/subtypes":616,"../scatter/text_defaults":617,"../scatter/xy_defaults":618,"./attributes":620}],624:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../registry":528,"../scatter/constants":591,"../scatter/fillcolor_defaults":596,"../scatter/line_defaults":600,"../scatter/marker_defaults":606,"../scatter/subtypes":611,"../scatter/text_defaults":612,"../scatter/xy_defaults":613,"./attributes":615}],619:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107502,7 +109414,7 @@ var scatterCalc = _dereq_('../scatter/calc'); var calcMarkerSize = scatterCalc.calcMarkerSize; var calcAxisExpansion = scatterCalc.calcAxisExpansion; var setFirstScatter = scatterCalc.setFirstScatter; -var calcColorscales = _dereq_('../scatter/colorscale_calc'); +var calcColorscale = _dereq_('../scatter/colorscale_calc'); var linkTraces = _dereq_('../scatter/link_traces'); var getTraceColor = _dereq_('../scatter/get_trace_color'); var fillHoverText = _dereq_('../scatter/fill_hover_text'); @@ -107559,7 +109471,7 @@ function calc(gd, trace) { } // create scene options and scene - calcColorscales(trace); + calcColorscale(gd, trace); var opts = sceneOptions(gd, subplot, trace, positions, x, y); var scene = sceneUpdate(gd, subplot); @@ -108291,6 +110203,11 @@ function calcHover(pointData, x, y, trace) { di.hi = Array.isArray(hoverinfo) ? hoverinfo[id] : hoverinfo; } + var hovertemplate = trace.hovertemplate; + if(hovertemplate) { + di.ht = Array.isArray(hovertemplate) ? hovertemplate[id] : hovertemplate; + } + var fakeCd = {}; fakeCd[pointData.index] = di; @@ -108307,7 +110224,9 @@ function calcHover(pointData, x, y, trace) { cd: fakeCd, distance: minDist, - spikeDistance: dxy + spikeDistance: dxy, + + hovertemplate: di.ht }); if(di.htx) pointData.text = di.htx; @@ -108452,7 +110371,7 @@ module.exports = { } }; -},{"../../components/color":319,"../../constants/interactions":419,"../../constants/numerical":420,"../../lib":441,"../../lib/prepare_regl":454,"../../plots/cartesian":500,"../../plots/cartesian/autorange":487,"../../plots/cartesian/axis_ids":491,"../../registry":532,"../scatter/calc":593,"../scatter/colorscale_calc":595,"../scatter/cross_trace_defaults":598,"../scatter/fill_hover_text":600,"../scatter/get_trace_color":602,"../scatter/link_traces":608,"../scatter/marker_colorbar":610,"../scatter/subtypes":616,"./attributes":620,"./constants":621,"./convert":622,"./defaults":623,"array-range":15,"gl-text":188,"point-cluster":236,"regl-error2d":254,"regl-line2d":255,"regl-scatter2d":256}],625:[function(_dereq_,module,exports){ +},{"../../components/color":318,"../../constants/interactions":415,"../../constants/numerical":416,"../../lib":437,"../../lib/prepare_regl":450,"../../plots/cartesian":496,"../../plots/cartesian/autorange":483,"../../plots/cartesian/axis_ids":487,"../../registry":528,"../scatter/calc":588,"../scatter/colorscale_calc":590,"../scatter/cross_trace_defaults":593,"../scatter/fill_hover_text":595,"../scatter/get_trace_color":597,"../scatter/link_traces":603,"../scatter/marker_colorbar":605,"../scatter/subtypes":611,"./attributes":615,"./constants":616,"./convert":617,"./defaults":618,"array-range":15,"gl-text":188,"point-cluster":236,"regl-error2d":254,"regl-line2d":255,"regl-scatter2d":256}],620:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108604,7 +110523,7 @@ module.exports = { opacity: scatterGlAttrs.opacity }; -},{"../../components/colorscale/attributes":326,"../../lib/extend":432,"../../plot_api/plot_template":478,"../../plots/cartesian/constants":494,"../scatter/attributes":592,"../scattergl/attributes":620}],626:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":325,"../../lib/extend":429,"../../plot_api/plot_template":474,"../../plots/cartesian/constants":490,"../scatter/attributes":587,"../scattergl/attributes":615}],621:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108847,7 +110766,7 @@ module.exports = { toSVG: Cartesian.toSVG }; -},{"../../lib/prepare_regl":454,"../../plots/cartesian":500,"../../plots/cartesian/axes":488,"../../plots/cartesian/axis_ids":491,"../../plots/get_data":517,"../../registry":532,"regl-line2d":255}],627:[function(_dereq_,module,exports){ +},{"../../lib/prepare_regl":450,"../../plots/cartesian":496,"../../plots/cartesian/axes":484,"../../plots/cartesian/axis_ids":487,"../../plots/get_data":513,"../../registry":528,"regl-line2d":255}],622:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109017,7 +110936,7 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) { } } -},{"../../lib":441,"../../plots/array_container_defaults":484,"../parcoords/merge_length":582,"../scatter/marker_defaults":611,"../scatter/subtypes":616,"./attributes":625}],628:[function(_dereq_,module,exports){ +},{"../../lib":437,"../../plots/array_container_defaults":480,"../parcoords/merge_length":577,"../scatter/marker_defaults":606,"../scatter/subtypes":611,"./attributes":620}],623:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109039,7 +110958,7 @@ var AxisIDs = _dereq_('../../plots/cartesian/axis_ids'); var subTypes = _dereq_('../scatter/subtypes'); var calcMarkerSize = _dereq_('../scatter/calc').calcMarkerSize; var calcAxisExpansion = _dereq_('../scatter/calc').calcAxisExpansion; -var calcColorscales = _dereq_('../scatter/colorscale_calc'); +var calcColorscale = _dereq_('../scatter/colorscale_calc'); var convertMarkerSelection = _dereq_('../scattergl/convert').markerSelection; var convertMarkerStyle = _dereq_('../scattergl/convert').markerStyle; var calcHover = _dereq_('../scattergl').calcHover; @@ -109100,7 +111019,7 @@ function calc(gd, trace) { } } - calcColorscales(trace); + calcColorscale(gd, trace); Lib.extendFlat(opts, convertMarkerStyle(trace)); var visibleLength = cdata.length; @@ -109330,7 +111249,7 @@ function editStyle(gd, cd0) { var scene = gd._fullLayout._splomScenes[trace.uid]; if(scene) { - calcColorscales(trace); + calcColorscale(gd, trace); Lib.extendFlat(scene.matrixOptions, convertMarkerStyle(trace)); // TODO [un]selected styles? @@ -109497,5 +111416,5 @@ module.exports = { // register it here Registry.register(Grid); -},{"../../components/grid":365,"../../constants/numerical":420,"../../lib":441,"../../plots/cartesian/axis_ids":491,"../../registry":532,"../scatter/calc":593,"../scatter/colorscale_calc":595,"../scatter/marker_colorbar":610,"../scatter/subtypes":616,"../scattergl":624,"../scattergl/constants":621,"../scattergl/convert":622,"./attributes":625,"./base_plot":626,"./defaults":627,"array-range":15,"regl-splom":258}]},{},[6])(6) +},{"../../components/grid":361,"../../constants/numerical":416,"../../lib":437,"../../plots/cartesian/axis_ids":487,"../../registry":528,"../scatter/calc":588,"../scatter/colorscale_calc":590,"../scatter/marker_colorbar":605,"../scatter/subtypes":611,"../scattergl":619,"../scattergl/constants":616,"../scattergl/convert":617,"./attributes":620,"./base_plot":621,"./defaults":622,"array-range":15,"regl-splom":258}]},{},[6])(6) }); diff --git a/dist/plotly-gl2d.min.js b/dist/plotly-gl2d.min.js index 3dfd78a12b0..48fea8a7142 100644 --- a/dist/plotly-gl2d.min.js +++ b/dist/plotly-gl2d.min.js @@ -1,7 +1,7 @@ /** -* plotly.js (gl2d - minified) v1.42.5 +* plotly.js (gl2d - minified) v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,r,n){function a(o,s){if(!r[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(i)return i(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[o]={exports:{}};e[o][0].call(c.exports,function(t){return a(e[o][1][t]||t)},c,c.exports,t,e,r,n)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;oplotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/contourgl")},{"../src/traces/contourgl":553}],4:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":422}],5:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmapgl")},{"../src/traces/heatmapgl":568}],6:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./scattergl"),t("./splom"),t("./pointcloud"),t("./heatmapgl"),t("./contourgl"),t("./parcoords")]),e.exports=n},{"./contourgl":3,"./core":4,"./heatmapgl":5,"./parcoords":7,"./pointcloud":8,"./scattergl":9,"./splom":10}],7:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcoords")},{"../src/traces/parcoords":580}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/pointcloud")},{"../src/traces/pointcloud":590}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergl")},{"../src/traces/scattergl":624}],10:[function(t,e,r){"use strict";e.exports=t("../src/traces/splom")},{"../src/traces/splom":628}],11:[function(t,e,r){e.exports=function(t){var e=0,r=0,n=0,a=0;return t.map(function(t){var i=(t=t.slice())[0],o=i.toUpperCase();if(i!=o)switch(t[0]=o,i){case"a":t[6]+=n,t[7]+=a;break;case"v":t[1]+=a;break;case"h":t[1]+=n;break;default:for(var s=1;sa&&(a=t[o]),t[o]=0;u--)if(c[u]!==f[u])return!1;for(u=c.length-1;u>=0;u--)if(l=c[u],!y(t[l],e[l],r,n))return!1;return!0}(t,e,r,o))}return r?t===e:t==e}function b(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function x(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function _(t,e,r,n){var a;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),a=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!a&&v(a,r,"Missing expected exception"+n);var o="string"==typeof n,s=!t&&a&&!r;if((!t&&i.isError(a)&&o&&x(a,r)||s)&&v(a,r,"Got unwanted exception"+n),t&&a&&r&&!x(a,r)||!t&&a)throw a}f.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=p(g((e=this).actual),128)+" "+e.operator+" "+p(g(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var a=n.stack,i=d(r),o=a.indexOf("\n"+i);if(o>=0){var s=a.indexOf("\n",o+1);a=a.substring(s+1)}this.stack=a}}},i.inherits(f.AssertionError,Error),f.fail=v,f.ok=m,f.equal=function(t,e,r){t!=e&&v(t,e,r,"==",f.equal)},f.notEqual=function(t,e,r){t==e&&v(t,e,r,"!=",f.notEqual)},f.deepEqual=function(t,e,r){y(t,e,!1)||v(t,e,r,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(t,e,r){y(t,e,!0)||v(t,e,r,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(t,e,r){y(t,e,!1)&&v(t,e,r,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function t(e,r,n){y(e,r,!0)&&v(e,r,n,"notDeepStrictEqual",t)},f.strictEqual=function(t,e,r){t!==e&&v(t,e,r,"===",f.strictEqual)},f.notStrictEqual=function(t,e,r){t===e&&v(t,e,r,"!==",f.notStrictEqual)},f.throws=function(t,e,r){_(!0,t,e,r)},f.doesNotThrow=function(t,e,r){_(!1,t,e,r)},f.ifError=function(t){if(t)throw t};var w=Object.keys||function(t){var e=[];for(var r in t)o.call(t,r)&&e.push(r);return e}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":19}],17:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],18:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],19:[function(t,e,r){(function(e,n){var a=/%[sdj%]/g;r.format=function(t){if(!m(t)){for(var e=[],r=0;r=i)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),l=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=l),c(n,t,n.depth)}function l(t,e){var r=s.styles[e];return r?"\x1b["+s.colors[r][0]+"m"+t+"\x1b["+s.colors[r][1]+"m":t}function u(t,e){return t}function c(t,e,n){if(t.customInspect&&e&&A(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var a=e.inspect(n,t);return m(a)||(a=c(t,a,n)),a}var i=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(v(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,e);if(i)return i;var o=Object.keys(e),s=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),w(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(e);if(0===o.length){if(A(e)){var l=e.name?": "+e.name:"";return t.stylize("[Function"+l+"]","special")}if(b(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(w(e))return f(e)}var u,x="",k=!1,T=["{","}"];(d(e)&&(k=!0,T=["[","]"]),A(e))&&(x=" [Function"+(e.name?": "+e.name:"")+"]");return b(e)&&(x=" "+RegExp.prototype.toString.call(e)),_(e)&&(x=" "+Date.prototype.toUTCString.call(e)),w(e)&&(x=" "+f(e)),0!==o.length||k&&0!=e.length?n<0?b(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),u=k?function(t,e,r,n,a){for(var i=[],o=0,s=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(u,x,T)):T[0]+x+T[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,a,i){var o,s,l;if((l=Object.getOwnPropertyDescriptor(e,a)||{value:e[a]}).get?s=l.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):l.set&&(s=t.stylize("[Setter]","special")),E(n,a)||(o="["+a+"]"),s||(t.seen.indexOf(l.value)<0?(s=g(r)?c(t,l.value,null):c(t,l.value,r-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),y(o)){if(i&&a.match(/^\d+$/))return s;(o=JSON.stringify(""+a)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+s}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function g(t){return null===t}function v(t){return"number"==typeof t}function m(t){return"string"==typeof t}function y(t){return void 0===t}function b(t){return x(t)&&"[object RegExp]"===k(t)}function x(t){return"object"==typeof t&&null!==t}function _(t){return x(t)&&"[object Date]"===k(t)}function w(t){return x(t)&&("[object Error]"===k(t)||t instanceof Error)}function A(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(y(i)&&(i=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(i)){var n=e.pid;o[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else o[t]=function(){};return o[t]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=g,r.isNullOrUndefined=function(t){return null==t},r.isNumber=v,r.isString=m,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=y,r.isRegExp=b,r.isObject=x,r.isDate=_,r.isError=w,r.isFunction=A,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t},r.isBuffer=t("./support/isBuffer");var M=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function E(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":"),[t.getDate(),M[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!x(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":18,_process:248,inherits:17}],20:[function(t,e,r){e.exports=function(t){return atob(t)}},{}],21:[function(t,e,r){"use strict";r.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=u(t),n=r[0],o=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,o)),l=0,c=o>0?n-4:n,f=0;f>16&255,s[l++]=e>>8&255,s[l++]=255&e;2===o&&(e=a[t.charCodeAt(f)]<<2|a[t.charCodeAt(f+1)]>>4,s[l++]=255&e);1===o&&(e=a[t.charCodeAt(f)]<<10|a[t.charCodeAt(f+1)]<<4|a[t.charCodeAt(f+2)]>>2,s[l++]=e>>8&255,s[l++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,a=r%3,i=[],o=0,s=r-a;os?s:o+16383));1===a?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===a&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],a=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var a,i,o=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return o.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],22:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}},{"./lib/rationalize":32}],23:[function(t,e,r){"use strict";e.exports=function(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}},{}],24:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]),t[1].mul(e[0]))}},{"./lib/rationalize":32}],25:[function(t,e,r){"use strict";var n=t("./is-rat"),a=t("./lib/is-bn"),i=t("./lib/num-to-bn"),o=t("./lib/str-to-bn"),s=t("./lib/rationalize"),l=t("./div");e.exports=function t(e,r){if(n(e))return r?l(e,t(r)):[e[0].clone(),e[1].clone()];var u=0;var c,f;if(a(e))c=e.clone();else if("string"==typeof e)c=o(e);else{if(0===e)return[i(0),i(1)];if(e===Math.floor(e))c=i(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),u-=256;c=i(e)}}if(n(r))c.mul(r[1]),f=r[0].clone();else if(a(r))f=r.clone();else if("string"==typeof r)f=o(r);else if(r)if(r===Math.floor(r))f=i(r);else{for(;r!==Math.floor(r);)r*=Math.pow(2,256),u+=256;f=i(r)}else f=i(1);u>0?c=c.ushln(u):u<0&&(f=f.ushln(-u));return s(c,f)}},{"./div":24,"./is-rat":26,"./lib/is-bn":30,"./lib/num-to-bn":31,"./lib/rationalize":32,"./lib/str-to-bn":33}],26:[function(t,e,r){"use strict";var n=t("./lib/is-bn");e.exports=function(t){return Array.isArray(t)&&2===t.length&&n(t[0])&&n(t[1])}},{"./lib/is-bn":30}],27:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return t.cmp(new n(0))}},{"bn.js":41}],28:[function(t,e,r){"use strict";var n=t("./bn-sign");e.exports=function(t){var e=t.length,r=t.words,a=0;if(1===e)a=r[0];else if(2===e)a=r[0]+67108864*r[1];else for(var i=0;i20)return 52;return r+32}},{"bit-twiddle":39,"double-bits":88}],30:[function(t,e,r){"use strict";t("bn.js");e.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},{"bn.js":41}],31:[function(t,e,r){"use strict";var n=t("bn.js"),a=t("double-bits");e.exports=function(t){var e=a.exponent(t);return e<52?new n(t):new n(t*Math.pow(2,52-e)).ushln(e-52)}},{"bn.js":41,"double-bits":88}],32:[function(t,e,r){"use strict";var n=t("./num-to-bn"),a=t("./bn-sign");e.exports=function(t,e){var r=a(t),i=a(e);if(0===r)return[n(0),n(1)];if(0===i)return[n(0),n(0)];i<0&&(t=t.neg(),e=e.neg());var o=t.gcd(e);if(o.cmpn(1))return[t.div(o),e.div(o)];return[t,e]}},{"./bn-sign":27,"./num-to-bn":31}],33:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return new n(t)}},{"bn.js":41}],34:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[0]),t[1].mul(e[1]))}},{"./lib/rationalize":32}],35:[function(t,e,r){"use strict";var n=t("./lib/bn-sign");e.exports=function(t){return n(t[0])*n(t[1])}},{"./lib/bn-sign":27}],36:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},{"./lib/rationalize":32}],37:[function(t,e,r){"use strict";var n=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=function(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var i=e.abs().divmod(r.abs()),o=i.div,s=n(o),l=i.mod,u=e.negative!==r.negative?-1:1;if(0===l.cmpn(0))return u*s;if(s){var c=a(s)+4,f=n(l.ushln(c).divRound(r));return u*(s+f*Math.pow(2,-c))}var h=r.bitLength()-l.bitLength()+53,f=n(l.ushln(h).divRound(r));return h<1023?u*f*Math.pow(2,-h):(f*=Math.pow(2,-1023),u*f*Math.pow(2,1023-h))}},{"./lib/bn-to-num":28,"./lib/ctz":29}],38:[function(t,e,r){"use strict";function n(t,e,r,n,a,i){var o=["function ",t,"(a,l,h,",n.join(","),"){",i?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",a?".get(m)":"[m]"];return i?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),i?o.push("return -1};"):o.push("return i};"),o.join("")}function a(t,e,r,a){return new Function([n("A","x"+t+"y",e,["y"],!1,a),n("B","x"+t+"y",e,["y"],!0,a),n("P","c(x,y)"+t+"0",e,["y","c"],!1,a),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,a),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""))()}e.exports={ge:a(">=",!1,"GE"),gt:a(">",!1,"GT"),lt:a("<",!0,"LT"),le:a("<=",!0,"LE"),eq:a("-",!0,"EQ",!0)}},{}],39:[function(t,e,r){"use strict";function n(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}r.INT_BITS=32,r.INT_MAX=2147483647,r.INT_MIN=-1<<31,r.sign=function(t){return(t>0)-(t<0)},r.abs=function(t){var e=t>>31;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var a=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,a=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--a;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},r.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},r.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},r.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],40:[function(t,e,r){"use strict";var n=t("clamp");e.exports=function(t,e){e||(e={});var r,o,s,l,u,c,f,h,d,p,g,v=null==e.cutoff?.25:e.cutoff,m=null==e.radius?8:e.radius,y=e.channel||0;if(ArrayBuffer.isView(t)||Array.isArray(t)){if(!e.width||!e.height)throw Error("For raw data width and height should be provided by options");r=e.width,o=e.height,l=t,c=e.stride?e.stride:Math.floor(t.length/r/o)}else window.HTMLCanvasElement&&t instanceof window.HTMLCanvasElement?(f=(h=t).getContext("2d"),r=h.width,o=h.height,d=f.getImageData(0,0,r,o),l=d.data,c=4):window.CanvasRenderingContext2D&&t instanceof window.CanvasRenderingContext2D?(h=t.canvas,f=t,r=h.width,o=h.height,d=f.getImageData(0,0,r,o),l=d.data,c=4):window.ImageData&&t instanceof window.ImageData&&(d=t,r=t.width,o=t.height,l=d.data,c=4);if(s=Math.max(r,o),window.Uint8ClampedArray&&l instanceof window.Uint8ClampedArray||window.Uint8Array&&l instanceof window.Uint8Array)for(u=l,l=Array(r*o),p=0,g=u.length;p=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function l(t,e,r,n){for(var a=0,i=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return a}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var a=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&a++,16===e?this._parseHex(t,a):this._parseBase(t,e,a),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},i.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},i.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var a=0;a=0;a-=3)o=t[a]|t[a-1]<<8|t[a-2]<<16,this.words[i]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===r)for(a=0,i=0;a>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)a=s(t,r,r+6),this.words[n]|=a<>>26-i&4194303,(i+=24)>=26&&(i-=26,n++);r+6!==e&&(a=s(t,e,r+6),this.words[n]|=a<>>26-i&4194303),this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,a=1;a<=67108863;a*=e)n++;n--,a=a/e|0;for(var i=t.length-r,o=i%n,s=Math.min(i,i-o)+r,u=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var a=0|t.words[0],i=0|e.words[0],o=a*i,s=67108863&o,l=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&l,h=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=h;d++){var p=u-d|0;c+=(o=(a=0|t.words[p])*(i=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,l=0|c}return 0!==l?r.words[u]=0|l:r.length--,r.strip()}i.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var a=0,i=0,o=0;o>>24-a&16777215)||o!==this.length-1?u[6-l.length]+l+r:l+r,(a+=2)>=26&&(a-=26,o--)}for(0!==i&&(r=i.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var h=c[t],d=f[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?g+r:u[h-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return n("undefined"!=typeof o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,r){var a=this.byteLength(),i=r||Math.max(1,a);n(a<=i,"byte array longer than desired length"),n(i>0,"Requested array length <= 0"),this.strip();var o,s,l="le"===e,u=new t(i),c=this.clone();if(l){for(s=0;!c.isZero();s++)o=c.andln(255),c.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-r),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,a=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var a=0,i=0;i>>26;for(;0!==a&&i>>26;if(this.length=r.length,0!==a)this.words[this.length]=a,this.length++;else if(r!==this)for(;it.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,a=this.cmp(t);if(0===a)return this.negative=0,this.length=1,this.words[0]=0,this;a>0?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==i&&o>26,this.words[o]=67108863&e;if(0===i&&o>>13,d=0|o[1],p=8191&d,g=d>>>13,v=0|o[2],m=8191&v,y=v>>>13,b=0|o[3],x=8191&b,_=b>>>13,w=0|o[4],A=8191&w,k=w>>>13,T=0|o[5],M=8191&T,E=T>>>13,C=0|o[6],S=8191&C,L=C>>>13,O=0|o[7],D=8191&O,R=O>>>13,P=0|o[8],z=8191&P,I=P>>>13,F=0|o[9],N=8191&F,B=F>>>13,j=0|s[0],U=8191&j,H=j>>>13,V=0|s[1],q=8191&V,G=V>>>13,X=0|s[2],W=8191&X,Y=X>>>13,Z=0|s[3],J=8191&Z,Q=Z>>>13,$=0|s[4],K=8191&$,tt=$>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,at=0|s[6],it=8191&at,ot=at>>>13,st=0|s[7],lt=8191&st,ut=st>>>13,ct=0|s[8],ft=8191&ct,ht=ct>>>13,dt=0|s[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(u+(n=Math.imul(f,U))|0)+((8191&(a=(a=Math.imul(f,H))+Math.imul(h,U)|0))<<13)|0;u=((i=Math.imul(h,H))+(a>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,U),a=(a=Math.imul(p,H))+Math.imul(g,U)|0,i=Math.imul(g,H);var mt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(a=(a=a+Math.imul(f,G)|0)+Math.imul(h,q)|0))<<13)|0;u=((i=i+Math.imul(h,G)|0)+(a>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,U),a=(a=Math.imul(m,H))+Math.imul(y,U)|0,i=Math.imul(y,H),n=n+Math.imul(p,q)|0,a=(a=a+Math.imul(p,G)|0)+Math.imul(g,q)|0,i=i+Math.imul(g,G)|0;var yt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(a=(a=a+Math.imul(f,Y)|0)+Math.imul(h,W)|0))<<13)|0;u=((i=i+Math.imul(h,Y)|0)+(a>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(x,U),a=(a=Math.imul(x,H))+Math.imul(_,U)|0,i=Math.imul(_,H),n=n+Math.imul(m,q)|0,a=(a=a+Math.imul(m,G)|0)+Math.imul(y,q)|0,i=i+Math.imul(y,G)|0,n=n+Math.imul(p,W)|0,a=(a=a+Math.imul(p,Y)|0)+Math.imul(g,W)|0,i=i+Math.imul(g,Y)|0;var bt=(u+(n=n+Math.imul(f,J)|0)|0)+((8191&(a=(a=a+Math.imul(f,Q)|0)+Math.imul(h,J)|0))<<13)|0;u=((i=i+Math.imul(h,Q)|0)+(a>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(A,U),a=(a=Math.imul(A,H))+Math.imul(k,U)|0,i=Math.imul(k,H),n=n+Math.imul(x,q)|0,a=(a=a+Math.imul(x,G)|0)+Math.imul(_,q)|0,i=i+Math.imul(_,G)|0,n=n+Math.imul(m,W)|0,a=(a=a+Math.imul(m,Y)|0)+Math.imul(y,W)|0,i=i+Math.imul(y,Y)|0,n=n+Math.imul(p,J)|0,a=(a=a+Math.imul(p,Q)|0)+Math.imul(g,J)|0,i=i+Math.imul(g,Q)|0;var xt=(u+(n=n+Math.imul(f,K)|0)|0)+((8191&(a=(a=a+Math.imul(f,tt)|0)+Math.imul(h,K)|0))<<13)|0;u=((i=i+Math.imul(h,tt)|0)+(a>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(M,U),a=(a=Math.imul(M,H))+Math.imul(E,U)|0,i=Math.imul(E,H),n=n+Math.imul(A,q)|0,a=(a=a+Math.imul(A,G)|0)+Math.imul(k,q)|0,i=i+Math.imul(k,G)|0,n=n+Math.imul(x,W)|0,a=(a=a+Math.imul(x,Y)|0)+Math.imul(_,W)|0,i=i+Math.imul(_,Y)|0,n=n+Math.imul(m,J)|0,a=(a=a+Math.imul(m,Q)|0)+Math.imul(y,J)|0,i=i+Math.imul(y,Q)|0,n=n+Math.imul(p,K)|0,a=(a=a+Math.imul(p,tt)|0)+Math.imul(g,K)|0,i=i+Math.imul(g,tt)|0;var _t=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(a=(a=a+Math.imul(f,nt)|0)+Math.imul(h,rt)|0))<<13)|0;u=((i=i+Math.imul(h,nt)|0)+(a>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(S,U),a=(a=Math.imul(S,H))+Math.imul(L,U)|0,i=Math.imul(L,H),n=n+Math.imul(M,q)|0,a=(a=a+Math.imul(M,G)|0)+Math.imul(E,q)|0,i=i+Math.imul(E,G)|0,n=n+Math.imul(A,W)|0,a=(a=a+Math.imul(A,Y)|0)+Math.imul(k,W)|0,i=i+Math.imul(k,Y)|0,n=n+Math.imul(x,J)|0,a=(a=a+Math.imul(x,Q)|0)+Math.imul(_,J)|0,i=i+Math.imul(_,Q)|0,n=n+Math.imul(m,K)|0,a=(a=a+Math.imul(m,tt)|0)+Math.imul(y,K)|0,i=i+Math.imul(y,tt)|0,n=n+Math.imul(p,rt)|0,a=(a=a+Math.imul(p,nt)|0)+Math.imul(g,rt)|0,i=i+Math.imul(g,nt)|0;var wt=(u+(n=n+Math.imul(f,it)|0)|0)+((8191&(a=(a=a+Math.imul(f,ot)|0)+Math.imul(h,it)|0))<<13)|0;u=((i=i+Math.imul(h,ot)|0)+(a>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(D,U),a=(a=Math.imul(D,H))+Math.imul(R,U)|0,i=Math.imul(R,H),n=n+Math.imul(S,q)|0,a=(a=a+Math.imul(S,G)|0)+Math.imul(L,q)|0,i=i+Math.imul(L,G)|0,n=n+Math.imul(M,W)|0,a=(a=a+Math.imul(M,Y)|0)+Math.imul(E,W)|0,i=i+Math.imul(E,Y)|0,n=n+Math.imul(A,J)|0,a=(a=a+Math.imul(A,Q)|0)+Math.imul(k,J)|0,i=i+Math.imul(k,Q)|0,n=n+Math.imul(x,K)|0,a=(a=a+Math.imul(x,tt)|0)+Math.imul(_,K)|0,i=i+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,a=(a=a+Math.imul(m,nt)|0)+Math.imul(y,rt)|0,i=i+Math.imul(y,nt)|0,n=n+Math.imul(p,it)|0,a=(a=a+Math.imul(p,ot)|0)+Math.imul(g,it)|0,i=i+Math.imul(g,ot)|0;var At=(u+(n=n+Math.imul(f,lt)|0)|0)+((8191&(a=(a=a+Math.imul(f,ut)|0)+Math.imul(h,lt)|0))<<13)|0;u=((i=i+Math.imul(h,ut)|0)+(a>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(z,U),a=(a=Math.imul(z,H))+Math.imul(I,U)|0,i=Math.imul(I,H),n=n+Math.imul(D,q)|0,a=(a=a+Math.imul(D,G)|0)+Math.imul(R,q)|0,i=i+Math.imul(R,G)|0,n=n+Math.imul(S,W)|0,a=(a=a+Math.imul(S,Y)|0)+Math.imul(L,W)|0,i=i+Math.imul(L,Y)|0,n=n+Math.imul(M,J)|0,a=(a=a+Math.imul(M,Q)|0)+Math.imul(E,J)|0,i=i+Math.imul(E,Q)|0,n=n+Math.imul(A,K)|0,a=(a=a+Math.imul(A,tt)|0)+Math.imul(k,K)|0,i=i+Math.imul(k,tt)|0,n=n+Math.imul(x,rt)|0,a=(a=a+Math.imul(x,nt)|0)+Math.imul(_,rt)|0,i=i+Math.imul(_,nt)|0,n=n+Math.imul(m,it)|0,a=(a=a+Math.imul(m,ot)|0)+Math.imul(y,it)|0,i=i+Math.imul(y,ot)|0,n=n+Math.imul(p,lt)|0,a=(a=a+Math.imul(p,ut)|0)+Math.imul(g,lt)|0,i=i+Math.imul(g,ut)|0;var kt=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(a=(a=a+Math.imul(f,ht)|0)+Math.imul(h,ft)|0))<<13)|0;u=((i=i+Math.imul(h,ht)|0)+(a>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,U),a=(a=Math.imul(N,H))+Math.imul(B,U)|0,i=Math.imul(B,H),n=n+Math.imul(z,q)|0,a=(a=a+Math.imul(z,G)|0)+Math.imul(I,q)|0,i=i+Math.imul(I,G)|0,n=n+Math.imul(D,W)|0,a=(a=a+Math.imul(D,Y)|0)+Math.imul(R,W)|0,i=i+Math.imul(R,Y)|0,n=n+Math.imul(S,J)|0,a=(a=a+Math.imul(S,Q)|0)+Math.imul(L,J)|0,i=i+Math.imul(L,Q)|0,n=n+Math.imul(M,K)|0,a=(a=a+Math.imul(M,tt)|0)+Math.imul(E,K)|0,i=i+Math.imul(E,tt)|0,n=n+Math.imul(A,rt)|0,a=(a=a+Math.imul(A,nt)|0)+Math.imul(k,rt)|0,i=i+Math.imul(k,nt)|0,n=n+Math.imul(x,it)|0,a=(a=a+Math.imul(x,ot)|0)+Math.imul(_,it)|0,i=i+Math.imul(_,ot)|0,n=n+Math.imul(m,lt)|0,a=(a=a+Math.imul(m,ut)|0)+Math.imul(y,lt)|0,i=i+Math.imul(y,ut)|0,n=n+Math.imul(p,ft)|0,a=(a=a+Math.imul(p,ht)|0)+Math.imul(g,ft)|0,i=i+Math.imul(g,ht)|0;var Tt=(u+(n=n+Math.imul(f,pt)|0)|0)+((8191&(a=(a=a+Math.imul(f,gt)|0)+Math.imul(h,pt)|0))<<13)|0;u=((i=i+Math.imul(h,gt)|0)+(a>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,q),a=(a=Math.imul(N,G))+Math.imul(B,q)|0,i=Math.imul(B,G),n=n+Math.imul(z,W)|0,a=(a=a+Math.imul(z,Y)|0)+Math.imul(I,W)|0,i=i+Math.imul(I,Y)|0,n=n+Math.imul(D,J)|0,a=(a=a+Math.imul(D,Q)|0)+Math.imul(R,J)|0,i=i+Math.imul(R,Q)|0,n=n+Math.imul(S,K)|0,a=(a=a+Math.imul(S,tt)|0)+Math.imul(L,K)|0,i=i+Math.imul(L,tt)|0,n=n+Math.imul(M,rt)|0,a=(a=a+Math.imul(M,nt)|0)+Math.imul(E,rt)|0,i=i+Math.imul(E,nt)|0,n=n+Math.imul(A,it)|0,a=(a=a+Math.imul(A,ot)|0)+Math.imul(k,it)|0,i=i+Math.imul(k,ot)|0,n=n+Math.imul(x,lt)|0,a=(a=a+Math.imul(x,ut)|0)+Math.imul(_,lt)|0,i=i+Math.imul(_,ut)|0,n=n+Math.imul(m,ft)|0,a=(a=a+Math.imul(m,ht)|0)+Math.imul(y,ft)|0,i=i+Math.imul(y,ht)|0;var Mt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(a=(a=a+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((i=i+Math.imul(g,gt)|0)+(a>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,W),a=(a=Math.imul(N,Y))+Math.imul(B,W)|0,i=Math.imul(B,Y),n=n+Math.imul(z,J)|0,a=(a=a+Math.imul(z,Q)|0)+Math.imul(I,J)|0,i=i+Math.imul(I,Q)|0,n=n+Math.imul(D,K)|0,a=(a=a+Math.imul(D,tt)|0)+Math.imul(R,K)|0,i=i+Math.imul(R,tt)|0,n=n+Math.imul(S,rt)|0,a=(a=a+Math.imul(S,nt)|0)+Math.imul(L,rt)|0,i=i+Math.imul(L,nt)|0,n=n+Math.imul(M,it)|0,a=(a=a+Math.imul(M,ot)|0)+Math.imul(E,it)|0,i=i+Math.imul(E,ot)|0,n=n+Math.imul(A,lt)|0,a=(a=a+Math.imul(A,ut)|0)+Math.imul(k,lt)|0,i=i+Math.imul(k,ut)|0,n=n+Math.imul(x,ft)|0,a=(a=a+Math.imul(x,ht)|0)+Math.imul(_,ft)|0,i=i+Math.imul(_,ht)|0;var Et=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(a=(a=a+Math.imul(m,gt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((i=i+Math.imul(y,gt)|0)+(a>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(N,J),a=(a=Math.imul(N,Q))+Math.imul(B,J)|0,i=Math.imul(B,Q),n=n+Math.imul(z,K)|0,a=(a=a+Math.imul(z,tt)|0)+Math.imul(I,K)|0,i=i+Math.imul(I,tt)|0,n=n+Math.imul(D,rt)|0,a=(a=a+Math.imul(D,nt)|0)+Math.imul(R,rt)|0,i=i+Math.imul(R,nt)|0,n=n+Math.imul(S,it)|0,a=(a=a+Math.imul(S,ot)|0)+Math.imul(L,it)|0,i=i+Math.imul(L,ot)|0,n=n+Math.imul(M,lt)|0,a=(a=a+Math.imul(M,ut)|0)+Math.imul(E,lt)|0,i=i+Math.imul(E,ut)|0,n=n+Math.imul(A,ft)|0,a=(a=a+Math.imul(A,ht)|0)+Math.imul(k,ft)|0,i=i+Math.imul(k,ht)|0;var Ct=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(a=(a=a+Math.imul(x,gt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((i=i+Math.imul(_,gt)|0)+(a>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,K),a=(a=Math.imul(N,tt))+Math.imul(B,K)|0,i=Math.imul(B,tt),n=n+Math.imul(z,rt)|0,a=(a=a+Math.imul(z,nt)|0)+Math.imul(I,rt)|0,i=i+Math.imul(I,nt)|0,n=n+Math.imul(D,it)|0,a=(a=a+Math.imul(D,ot)|0)+Math.imul(R,it)|0,i=i+Math.imul(R,ot)|0,n=n+Math.imul(S,lt)|0,a=(a=a+Math.imul(S,ut)|0)+Math.imul(L,lt)|0,i=i+Math.imul(L,ut)|0,n=n+Math.imul(M,ft)|0,a=(a=a+Math.imul(M,ht)|0)+Math.imul(E,ft)|0,i=i+Math.imul(E,ht)|0;var St=(u+(n=n+Math.imul(A,pt)|0)|0)+((8191&(a=(a=a+Math.imul(A,gt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((i=i+Math.imul(k,gt)|0)+(a>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(N,rt),a=(a=Math.imul(N,nt))+Math.imul(B,rt)|0,i=Math.imul(B,nt),n=n+Math.imul(z,it)|0,a=(a=a+Math.imul(z,ot)|0)+Math.imul(I,it)|0,i=i+Math.imul(I,ot)|0,n=n+Math.imul(D,lt)|0,a=(a=a+Math.imul(D,ut)|0)+Math.imul(R,lt)|0,i=i+Math.imul(R,ut)|0,n=n+Math.imul(S,ft)|0,a=(a=a+Math.imul(S,ht)|0)+Math.imul(L,ft)|0,i=i+Math.imul(L,ht)|0;var Lt=(u+(n=n+Math.imul(M,pt)|0)|0)+((8191&(a=(a=a+Math.imul(M,gt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((i=i+Math.imul(E,gt)|0)+(a>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(N,it),a=(a=Math.imul(N,ot))+Math.imul(B,it)|0,i=Math.imul(B,ot),n=n+Math.imul(z,lt)|0,a=(a=a+Math.imul(z,ut)|0)+Math.imul(I,lt)|0,i=i+Math.imul(I,ut)|0,n=n+Math.imul(D,ft)|0,a=(a=a+Math.imul(D,ht)|0)+Math.imul(R,ft)|0,i=i+Math.imul(R,ht)|0;var Ot=(u+(n=n+Math.imul(S,pt)|0)|0)+((8191&(a=(a=a+Math.imul(S,gt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((i=i+Math.imul(L,gt)|0)+(a>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(N,lt),a=(a=Math.imul(N,ut))+Math.imul(B,lt)|0,i=Math.imul(B,ut),n=n+Math.imul(z,ft)|0,a=(a=a+Math.imul(z,ht)|0)+Math.imul(I,ft)|0,i=i+Math.imul(I,ht)|0;var Dt=(u+(n=n+Math.imul(D,pt)|0)|0)+((8191&(a=(a=a+Math.imul(D,gt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((i=i+Math.imul(R,gt)|0)+(a>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,n=Math.imul(N,ft),a=(a=Math.imul(N,ht))+Math.imul(B,ft)|0,i=Math.imul(B,ht);var Rt=(u+(n=n+Math.imul(z,pt)|0)|0)+((8191&(a=(a=a+Math.imul(z,gt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((i=i+Math.imul(I,gt)|0)+(a>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Pt=(u+(n=Math.imul(N,pt))|0)+((8191&(a=(a=Math.imul(N,gt))+Math.imul(B,pt)|0))<<13)|0;return u=((i=Math.imul(B,gt))+(a>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,l[0]=vt,l[1]=mt,l[2]=yt,l[3]=bt,l[4]=xt,l[5]=_t,l[6]=wt,l[7]=At,l[8]=kt,l[9]=Tt,l[10]=Mt,l[11]=Et,l[12]=Ct,l[13]=St,l[14]=Lt,l[15]=Ot,l[16]=Dt,l[17]=Rt,l[18]=Pt,0!==u&&(l[19]=u,r.length++),r};function p(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(d=h),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?h(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,a=0,i=0;i>>26)|0)>>>26,o&=67108863}r.words[i]=s,n=o,o=a}return 0!==n?r.words[i]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,a,i){for(var o=0;o>>=1)a++;return 1<>>=13,r[2*o+1]=8191&i,i>>>=13;for(o=2*e;o>=26,e+=a/67108864|0,e+=i>>>26,this.words[r]=67108863&i}return 0!==e&&(this.words[r]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>a}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n=0);var e,r=t%26,a=(t-r)/26,i=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==a){for(e=this.length-1;e>=0;e--)this.words[e+a]=this.words[e];for(e=0;e=0),a=e?(e-e%26)/26:0;var i=t%26,o=Math.min((t-i)/26,this.length),s=67108863^67108863>>>i<o)for(this.length-=o,u=0;u=0&&(0!==c||u>=a);u--){var f=0|this.words[u];this.words[u]=c<<26-i|f>>>i,c=f&s}return l&&0!==c&&(l.words[l.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,a=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var a=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(l/67108864|0),this.words[a+r]=67108863&i}for(;a>26,this.words[a+r]=67108863&i;if(0===s)return this.strip();for(n(-1===s),s=0,a=0;a>26,this.words[a]=67108863&i;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),a=t,o=0|a.words[a.length-1];0!==(r=26-this._countBits(o))&&(a=a.ushln(r),n.iushln(r),o=0|a.words[a.length-1]);var s,l=n.length-a.length;if("mod"!==e){(s=new i(null)).length=l+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var h=67108864*(0|n.words[a.length+f])+(0|n.words[a.length+f-1]);for(h=Math.min(h/o|0,67108863),n._ishlnsubmul(a,h,f);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(a,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=h)}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(a=s.div.neg()),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:a,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(a=s.div.neg()),{div:a,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var a,o,s},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),a=t.andln(1),i=r.cmp(n);return i<0||1===a&&0===i?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,a=this.length-1;a>=0;a--)r=(e*r+(0|this.words[a]))%t;return r},i.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var a=(0|this.words[r])+67108864*e;this.words[r]=a/t|0,e=a%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),f=e.clone();!e.isZero();){for(var h=0,d=1;0==(e.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(e.iushrn(h);h-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(c),o.isub(f)),a.iushrn(1),o.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(c),l.isub(f)),s.iushrn(1),l.iushrn(1);e.cmp(r)>=0?(e.isub(r),a.isub(s),o.isub(l)):(r.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:r.iushln(u)}},i.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a,o=new i(1),s=new i(0),l=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,c=1;0==(e.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(l),o.iushrn(1);for(var f=0,h=1;0==(r.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(s)):(r.isub(e),s.isub(o))}return(a=0===e.cmpn(1)?o:s).cmpn(0)<0&&a.iadd(t),a},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var a=e.cmp(r);if(a<0){var i=e;e=r,r=i}else if(0===a||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,a=1<>>26,s&=67108863,this.words[o]=s}return 0!==i&&(this.words[o]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var a=0|this.words[0];e=a===t?0:at.length)return 1;if(this.length=0;r--){var n=0|this.words[r],a=0|t.words[r];if(n!==a){na&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new w(t)},i.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function x(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},a(y,m),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,a=i}a>>>=22,t.words[n-10]=a,0===a&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=a,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new b;else if("p192"===t)e=new x;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return v[t]=e,e},w.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new i(1)).iushrn(2);return this.pow(t,r)}for(var a=this.m.subn(1),o=0;!a.isZero()&&0===a.andln(1);)o++,a.iushrn(1);n(!a.isZero());var s=new i(1).toRed(this),l=s.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,u).cmp(l);)c.redIAdd(l);for(var f=this.pow(c,a),h=this.pow(t,a.addn(1).iushrn(1)),d=this.pow(t,a),p=o;0!==d.cmp(s);){for(var g=d,v=0;0!==g.cmp(s);v++)g=g.redSqr();n(v=0;n--){for(var u=e.words[n],c=l-1;c>=0;c--){var f=u>>c&1;a!==r[0]&&(a=this.sqr(a)),0!==f||0!==o?(o<<=1,o|=f,(4===++s||0===n&&0===c)&&(a=this.mul(a,r[o]),s=0,o=0)):s=0}l=26}return a},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new A(t)},a(A,w),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).iushrn(this.shift),i=a;return a.cmp(this.m)>=0?i=a.isub(this.m):a.cmpn(0)<0&&(i=a.iadd(this.m)),i._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof e||e,this)},{buffer:49}],42:[function(t,e,r){"use strict";e.exports=function(t,e,r){switch(arguments.length){case 1:return n=[],u(a=t,a,c,!0),n;case 2:return"function"==typeof e?u(t,t,e,!0):function(t,e){return n=[],u(t,e,c,!1),n}(t,e);case 3:return u(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}var a};var n,a=t("typedarray-pool"),i=t("./lib/sweep"),o=t("./lib/intersect");function s(t,e){for(var r=0;r>>1;if(!(c<=0)){var f,h=a.mallocDouble(2*c*s),d=a.mallocInt32(s);if((s=l(t,c,h,d))>0){if(1===c&&n)i.init(s),f=i.sweepComplete(c,r,0,s,h,d,0,s,h,d);else{var p=a.mallocDouble(2*c*u),g=a.mallocInt32(u);(u=l(e,c,p,g))>0&&(i.init(s+u),f=1===c?i.sweepBipartite(c,r,0,s,h,d,0,u,p,g):o(c,r,n,s,h,d,u,p,g),a.free(p),a.free(g))}a.free(h),a.free(d)}return f}}}function c(t,e){n.push([t,e])}},{"./lib/intersect":44,"./lib/sweep":48,"typedarray-pool":290}],43:[function(t,e,r){"use strict";var n="d",a="ax",i="vv",o="fp",s="es",l="rs",u="re",c="rb",f="ri",h="rp",d="bs",p="be",g="bb",v="bi",m="bp",y="rv",b="Q",x=[n,a,i,l,u,c,f,d,p,g,v];function _(t){var e="bruteForce"+(t?"Full":"Partial"),r=[],_=x.slice();t||_.splice(3,0,o);var w=["function "+e+"("+_.join()+"){"];function A(e,o){var _=function(t,e,r){var o="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),_=["function ",o,"(",x.join(),"){","var ",s,"=2*",n,";"],w="for(var i="+l+","+h+"="+s+"*"+l+";i<"+u+";++i,"+h+"+="+s+"){var x0="+c+"["+a+"+"+h+"],x1="+c+"["+a+"+"+h+"+"+n+"],xi="+f+"[i];",A="for(var j="+d+","+m+"="+s+"*"+d+";j<"+p+";++j,"+m+"+="+s+"){var y0="+g+"["+a+"+"+m+"],"+(r?"y1="+g+"["+a+"+"+m+"+"+n+"],":"")+"yi="+v+"[j];";return t?_.push(w,b,":",A):_.push(A,b,":",w),r?_.push("if(y1"+p+"-"+d+"){"),t?(A(!0,!1),w.push("}else{"),A(!1,!1)):(w.push("if("+o+"){"),A(!0,!0),w.push("}else{"),A(!0,!1),w.push("}}else{if("+o+"){"),A(!1,!0),w.push("}else{"),A(!1,!1),w.push("}")),w.push("}}return "+e);var k=r.join("")+w.join("");return new Function(k)()}r.partial=_(!1),r.full=_(!0)},{}],44:[function(t,e,r){"use strict";e.exports=function(t,e,r,i,c,E,C,S,L){!function(t,e){var r=8*a.log2(e+1)*(t+1)|0,i=a.nextPow2(x*r);w.length0;){var P=(D-=1)*x,z=w[P],I=w[P+1],F=w[P+2],N=w[P+3],B=w[P+4],j=w[P+5],U=D*_,H=A[U],V=A[U+1],q=1&j,G=!!(16&j),X=c,W=E,Y=S,Z=L;if(q&&(X=S,W=L,Y=c,Z=E),!(2&j&&(F=v(t,z,I,F,X,W,V),I>=F)||4&j&&(I=m(t,z,I,F,X,W,H))>=F)){var J=F-I,Q=B-N;if(G){if(t*J*(J+Q)=p0)&&!(p1>=hi)",["p0","p1"]),g=c("lo===p0",["p0"]),v=c("lo>>1,h=2*t,d=f,p=s[h*f+e];for(;u=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(c-1),A=h*d,k=0;kr&&a[f+e]>u;--c,f-=o){for(var h=f,d=f+o,p=0;p=0&&a.push("lo=e[k+n]");t.indexOf("hi")>=0&&a.push("hi=e[k+o]");return r.push(n.replace("_",a.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],47:[function(t,e,r){"use strict";e.exports=function(t,e){e<=4*n?a(0,e-1,t):function t(e,r,f){var h=(r-e+1)/6|0,d=e+h,p=r-h,g=e+r>>1,v=g-h,m=g+h,y=d,b=v,x=g,_=m,w=p,A=e+1,k=r-1,T=0;u(y,b,f)&&(T=y,y=b,b=T);u(_,w,f)&&(T=_,_=w,w=T);u(y,x,f)&&(T=y,y=x,x=T);u(b,x,f)&&(T=b,b=x,x=T);u(y,_,f)&&(T=y,y=_,_=T);u(x,_,f)&&(T=x,x=_,_=T);u(b,w,f)&&(T=b,b=w,w=T);u(b,x,f)&&(T=b,b=x,x=T);u(_,w,f)&&(T=_,_=w,w=T);var M=f[2*b];var E=f[2*b+1];var C=f[2*_];var S=f[2*_+1];var L=2*y;var O=2*x;var D=2*w;var R=2*d;var P=2*g;var z=2*p;for(var I=0;I<2;++I){var F=f[L+I],N=f[O+I],B=f[D+I];f[R+I]=F,f[P+I]=N,f[z+I]=B}o(v,e,f);o(m,r,f);for(var j=A;j<=k;++j)if(c(j,M,E,f))j!==A&&i(j,A,f),++A;else if(!c(j,C,S,f))for(;;){if(c(k,C,S,f)){c(k,M,E,f)?(s(j,A,k,f),++A,--k):(i(j,k,f),--k);break}if(--kt;){var u=r[l-2],c=r[l-1];if(ur[e+1])}function c(t,e,r,n){var a=n[t*=2];return a>>1;i(d,E);for(var C=0,S=0,A=0;A=o)p(u,c,S--,L=L-o|0);else if(L>=0)p(s,l,C--,L);else if(L<=-o){L=-L-o|0;for(var O=0;O>>1;i(d,C);for(var S=0,L=0,O=0,k=0;k>1==d[2*k+3]>>1&&(R=2,k+=1),D<0){for(var P=-(D>>1)-1,z=0;z>1)-1;0===R?p(s,l,S--,P):1===R?p(u,c,L--,P):2===R&&p(f,h,O--,P)}}},scanBipartite:function(t,e,r,n,a,u,c,f,h,v,m,y){var b=0,x=2*t,_=e,w=e+t,A=1,k=1;n?k=o:A=o;for(var T=a;T>>1;i(d,S);for(var L=0,T=0;T=o?(D=!n,M-=o):(D=!!n,M-=1),D)g(s,l,L++,M);else{var R=y[M],P=x*M,z=m[P+e+1],I=m[P+e+1+t];t:for(var F=0;F>>1;i(d,A);for(var k=0,b=0;b=o)s[k++]=x-o;else{var M=p[x-=1],E=v*x,C=h[E+e+1],S=h[E+e+1+t];t:for(var L=0;L=0;--L)if(s[L]===x){for(var P=L+1;P0&&s.length>i){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=o[e]=r,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(r=o[t]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,a=v(t,n),i=0;i=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(var r=e,n=r+1,a=t.length;n=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return p(this,t,!0)},o.prototype.rawListeners=function(t){return p(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],51:[function(t,e,r){"use strict";var n=t("base64-js"),a=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=o(r),a=n.write(t,e);a!==r&&(n=n.slice(0,a));return n}(t,e);if(ArrayBuffer.isView(t))return f(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(j(t,ArrayBuffer)||t&&j(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var a=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return N(t).length;default:if(a)return n?-1:F(t).length;e=(""+e).toLowerCase(),a=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,a){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=a?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(a)return-1;r=t.length-1}else if(r<0){if(!a)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,a);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,a);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,a){var i,o=1,s=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(a){var c=-1;for(i=r;is&&(r=s-l),i=r;i>=0;i--){for(var f=!0,h=0;ha&&(n=a):n=a;var i=e.length;n>i/2&&(n=i/2);for(var o=0;o>8,a=r%256,i.push(a),i.push(n);return i}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function k(t,e,r){r=Math.min(t.length,r);for(var n=[],a=e;a239?4:u>223?3:u>191?2:1;if(a+f<=r)switch(f){case 1:u<128&&(c=u);break;case 2:128==(192&(i=t[a+1]))&&(l=(31&u)<<6|63&i)>127&&(c=l);break;case 3:i=t[a+1],o=t[a+2],128==(192&i)&&128==(192&o)&&(l=(15&u)<<12|(63&i)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:i=t[a+1],o=t[a+2],s=t[a+3],128==(192&i)&&128==(192&o)&&128==(192&s)&&(l=(15&u)<<18|(63&i)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(c=l)}null===c?(c=65533,f=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),a+=f}return function(t){var e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return k(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,a){if(j(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===a&&(a=this.length),e<0||r>t.length||n<0||a>this.length)throw new RangeError("out of range index");if(n>=a&&e>=r)return 0;if(n>=a)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(a>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),l=Math.min(i,o),u=this.slice(n,a),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var a=this.length-e;if((void 0===r||r>a)&&(r=a),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return x(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function M(t,e,r){var n="";r=Math.min(t.length,r);for(var a=e;an)&&(r=n);for(var a="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,a,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>a||et.length)throw new RangeError("Index out of range")}function D(t,e,r,n,a,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||D(t,0,r,4),a.write(t,e,r,n,23,4),r+4}function P(t,e,r,n,i){return e=+e,r>>>=0,i||D(t,0,r,8),a.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t],a=1,i=0;++i>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t+--e],a=1;e>0&&(a*=256);)n+=this[t+--e]*a;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t],a=1,i=0;++i=(a*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||L(t,e,this.length);for(var n=e,a=1,i=this[t+--n];n>0&&(a*=256);)i+=this[t+--n]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||L(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||L(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||L(t,4,this.length),a.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||L(t,4,this.length),a.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||L(t,8,this.length),a.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||L(t,8,this.length),a.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var a=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var a=r-1,i=1;for(this[e+a]=255&t;--a>=0&&(i*=256);)this[e+a]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var a=Math.pow(2,8*r-1);O(this,t,e,r,a-1,-a)}var i=0,o=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var a=Math.pow(2,8*r-1);O(this,t,e,r,a-1,-a)}var i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return P(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return P(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return a},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var a=t.charCodeAt(0);("utf8"===n&&a<128||"latin1"===n)&&(t=a)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!a){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&i.push(239,191,189);continue}a=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),a=r;continue}r=65536+(a-55296<<10|r-56320)}else a&&(e-=3)>-1&&i.push(239,191,189);if(a=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function N(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function B(t,e,r,n){for(var a=0;a=e.length||a>=t.length);++a)e[a+r]=t[a];return a}function j(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}},{"base64-js":21,ieee754:202}],52:[function(t,e,r){"use strict";var n=t("./lib/monotone"),a=t("./lib/triangulation"),i=t("./lib/delaunay"),o=t("./lib/filter");function s(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function l(t,e){return t[0]-e[0]||t[1]-e[1]}function u(t,e,r){return e in t?t[e]:r}e.exports=function(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var c=!!u(r,"delaunay",!0),f=!!u(r,"interior",!0),h=!!u(r,"exterior",!0),d=!!u(r,"infinity",!1);if(!f&&!h||0===t.length)return[];var p=n(t,e);if(c||f!==h||d){for(var g=a(t.length,function(t){return t.map(s).sort(l)}(e)),v=0;v0;){for(var c=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;p=0||(e.flip(s,c),a(t,e,r,f,s,h),a(t,e,r,s,h,f),a(t,e,r,h,c,f),a(t,e,r,c,f,h)))}}},{"binary-search-bounds":57,"robust-in-sphere":261}],54:[function(t,e,r){"use strict";var n,a=t("binary-search-bounds");function i(t,e,r,n,a,i,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=a,this.next=i,this.boundary=o}function o(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}e.exports=function(t,e,r){var n=function(t,e){for(var r=t.cells(),n=r.length,a=0;a0||l.length>0;){for(;s.length>0;){var d=s.pop();if(u[d]!==-a){u[d]=a;c[d];for(var p=0;p<3;++p){var g=h[3*d+p];g>=0&&0===u[g]&&(f[3*d+p]?l.push(g):(s.push(g),u[g]=a))}}}var v=l;l=s,s=v,l.length=0,a=-a}var m=function(t,e,r){for(var n=0,a=0;a1&&a(r[h[d-2]],r[h[d-1]],i)>0;)t.push([h[d-1],h[d-2],o]),d-=1;h.length=d,h.push(o);var p=c.upperIds;for(d=p.length;d>1&&a(r[p[d-2]],r[p[d-1]],i)<0;)t.push([p[d-2],p[d-1],o]),d-=1;p.length=d,p.push(o)}}function d(t,e){var r;return(r=t.a[0]m[0]&&a.push(new u(m,v,s,f),new u(v,m,o,f))}a.sort(c);for(var y=a[0].a[0]-(1+Math.abs(a[0].a[0]))*Math.pow(2,-52),b=[new l([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=a.length;f<_;++f){var w=a[f],A=w.type;A===i?h(x,b,t,w.a,w.idx):A===s?p(b,t,w):g(b,t,w)}return x}},{"binary-search-bounds":57,"robust-orientation":262}],56:[function(t,e,r){"use strict";var n=t("binary-search-bounds");function a(t,e){this.stars=t,this.edges=e}e.exports=function(t,e){for(var r=new Array(t),n=0;n=0}}(),i.removeTriangle=function(t,e,r){var n=this.stars;o(n[t],e,r),o(n[e],r,t),o(n[r],t,e)},i.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},i.opposite=function(t,e){for(var r=this.stars[e],n=1,a=r.length;n>>1,x=a[m]"];return a?e.indexOf("c")<0?i.push(";if(x===y){return m}else if(x<=y){"):i.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):i.push(";if(",e,"){i=m;"),r?i.push("l=m+1}else{h=m-1}"):i.push("h=m-1}else{l=m+1}"),i.push("}"),a?i.push("return -1};"):i.push("return i};"),i.join("")}function a(t,e,r,a){return new Function([n("A","x"+t+"y",e,["y"],a),n("P","c(x,y)"+t+"0",e,["y","c"],a),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}e.exports={ge:a(">=",!1,"GE"),gt:a(">",!1,"GT"),lt:a("<",!0,"LT"),le:a("<=",!0,"LE"),eq:a("-",!0,"EQ",!0)}},{}],58:[function(t,e,r){e.exports=function(t,e,r){return er?r:t:te?e:t}},{}],59:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n;if(r){n=e;for(var a=new Array(e.length),i=0;ie[2]?1:0)}function m(t,e,r){if(0!==t.length){if(e)for(var n=0;n=0;--i){var b=e[c=(E=n[i])[0]],x=b[0],_=b[1],w=t[x],A=t[_];if((w[0]-A[0]||w[1]-A[1])<0){var k=x;x=_,_=k}b[0]=x;var T,M=b[1]=E[1];for(a&&(T=b[2]);i>0&&n[i-1][0]===c;){var E,C=(E=n[--i])[1];a?e.push([M,C,T]):e.push([M,C]),M=C}a?e.push([M,_,T]):e.push([M,_])}return h}(t,e,h,v,r));return m(e,y,r),!!y||(h.length>0||v.length>0)}},{"./lib/rat-seg-intersect":60,"big-rat":25,"big-rat/cmp":23,"big-rat/to-float":37,"box-intersect":42,nextafter:221,"rat-vec":251,"robust-segment-intersect":265,"union-find":291}],60:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var i=s(e,t),f=s(n,r),h=c(i,f);if(0===o(h))return null;var d=s(t,r),p=c(f,d),g=a(p,h),v=u(i,g);return l(t,v)};var n=t("big-rat/mul"),a=t("big-rat/div"),i=t("big-rat/sub"),o=t("big-rat/sign"),s=t("rat-vec/sub"),l=t("rat-vec/add"),u=t("rat-vec/muls");function c(t,e){return i(n(t[0],e[1]),n(t[1],e[0]))}},{"big-rat/div":24,"big-rat/mul":34,"big-rat/sign":35,"big-rat/sub":36,"rat-vec/add":250,"rat-vec/muls":252,"rat-vec/sub":253}],61:[function(t,e,r){"use strict";var n=t("clamp");function a(t,e){null==e&&(e=!0);var r=t[0],a=t[1],i=t[2],o=t[3];return null==o&&(o=e?1:255),e&&(r*=255,a*=255,i*=255,o*=255),16777216*(r=255&n(r,0,255))+((a=255&n(a,0,255))<<16)+((i=255&n(i,0,255))<<8)+(o=255&n(o,0,255))}e.exports=a,e.exports.to=a,e.exports.from=function(t,e){var r=(t=+t)>>>24,n=(16711680&t)>>>16,a=(65280&t)>>>8,i=255&t;return!1===e?[r,n,a,i]:[r/255,n/255,a/255,i/255]}},{clamp:58}],62:[function(t,e,r){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],63:[function(t,e,r){"use strict";var n=t("color-rgba"),a=t("clamp"),i=t("dtype");e.exports=function(t,e){"float"!==e&&e||(e="array"),"uint"===e&&(e="uint8"),"uint_clamped"===e&&(e="uint8_clamped");var r=new(i(e))(4),o="uint8"!==e&&"uint8_clamped"!==e;return t.length&&"string"!=typeof t||((t=n(t))[0]/=255,t[1]/=255,t[2]/=255),function(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||!!(Array.isArray(t)&&(t[0]>1||0===t[0])&&(t[1]>1||0===t[1])&&(t[2]>1||0===t[2])&&(!t[3]||t[3]>1))}(t)?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:255,o&&(r[0]/=255,r[1]/=255,r[2]/=255,r[3]/=255),r):(o?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:1):(r[0]=a(Math.floor(255*t[0]),0,255),r[1]=a(Math.floor(255*t[1]),0,255),r[2]=a(Math.floor(255*t[2]),0,255),r[3]=null==t[3]?255:a(Math.floor(255*t[3]),0,255)),r)}},{clamp:58,"color-rgba":65,dtype:90}],64:[function(t,e,r){(function(r){"use strict";var n=t("color-name"),a=t("is-plain-obj"),i=t("defined");e.exports=function(t){var e,s,l=[],u=1;if("string"==typeof t)if(n[t])l=n[t].slice(),s="rgb";else if("transparent"===t)u=0,s="rgb",l=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var c=t.slice(1),f=c.length,h=f<=4;u=1,h?(l=[parseInt(c[0]+c[0],16),parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16)],4===f&&(u=parseInt(c[3]+c[3],16)/255)):(l=[parseInt(c[0]+c[1],16),parseInt(c[2]+c[3],16),parseInt(c[4]+c[5],16)],8===f&&(u=parseInt(c[6]+c[7],16)/255)),l[0]||(l[0]=0),l[1]||(l[1]=0),l[2]||(l[2]=0),s="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var d=e[1],c=d.replace(/a$/,"");s=c;var f="cmyk"===c?4:"gray"===c?1:3;l=e[2].trim().split(/\s*,\s*/).map(function(t,e){if(/%$/.test(t))return e===f?parseFloat(t)/100:"rgb"===c?255*parseFloat(t)/100:parseFloat(t);if("h"===c[e]){if(/deg$/.test(t))return parseFloat(t);if(void 0!==o[t])return o[t]}return parseFloat(t)}),d===c&&l.push(1),u=void 0===l[f]?1:l[f],l=l.slice(0,f)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(l=t.match(/([0-9]+)/g).map(function(t){return parseFloat(t)}),s=t.match(/([a-z])/gi).join("").toLowerCase());else if(isNaN(t))if(a(t)){var p=i(t.r,t.red,t.R,null);null!==p?(s="rgb",l=[p,i(t.g,t.green,t.G),i(t.b,t.blue,t.B)]):(s="hsl",l=[i(t.h,t.hue,t.H),i(t.s,t.saturation,t.S),i(t.l,t.lightness,t.L,t.b,t.brightness)]),u=i(t.a,t.alpha,t.opacity,1),null!=t.opacity&&(u/=100)}else(Array.isArray(t)||r.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(t))&&(l=[t[0],t[1],t[2]],s="rgb",u=4===t.length?t[3]:1);else s="rgb",l=[t>>>16,(65280&t)>>>8,255&t];return{space:s,values:l,alpha:u}};var o={red:0,orange:60,yellow:120,green:180,blue:240,purple:300}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"color-name":62,defined:86,"is-plain-obj":210}],65:[function(t,e,r){"use strict";var n=t("color-parse"),a=t("color-space/hsl"),i=t("clamp");e.exports=function(t){var e,r=n(t);return r.space?((e=Array(3))[0]=i(r.values[0],0,255),e[1]=i(r.values[1],0,255),e[2]=i(r.values[2],0,255),"h"===r.space[0]&&(e=a.rgb(e)),e.push(i(r.alpha,0,1)),e):[]}},{clamp:58,"color-parse":64,"color-space/hsl":66}],66:[function(t,e,r){"use strict";var n=t("./rgb");e.exports={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e,r,n,a,i,o=t[0]/360,s=t[1]/100,l=t[2]/100;if(0===s)return[i=255*l,i,i];e=2*l-(r=l<.5?l*(1+s):l+s-l*s),a=[0,0,0];for(var u=0;u<3;u++)(n=o+1/3*-(u-1))<0?n++:n>1&&n--,i=6*n<1?e+6*(r-e)*n:2*n<1?r:3*n<2?e+(r-e)*(2/3-n)*6:e,a[u]=255*i;return a}},n.hsl=function(t){var e,r,n=t[0]/255,a=t[1]/255,i=t[2]/255,o=Math.min(n,a,i),s=Math.max(n,a,i),l=s-o;return s===o?e=0:n===s?e=(a-i)/l:a===s?e=2+(i-n)/l:i===s&&(e=4+(n-a)/l),(e=Math.min(60*e,360))<0&&(e+=360),r=(o+s)/2,[e,100*(s===o?0:r<=.5?l/(s+o):l/(2-s-o)),100*r]}},{"./rgb":67}],67:[function(t,e,r){"use strict";e.exports={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]}},{}],68:[function(t,e,r){"use strict";e.exports=function(t,e,r,i){var o=n(e,r,i);if(0===o){var s=a(n(t,e,r)),u=a(n(t,e,i));if(s===u){if(0===s){var c=l(t,e,r),f=l(t,e,i);return c===f?0:c?1:-1}return 0}return 0===u?s>0?-1:l(t,e,i)?-1:1:0===s?u>0?1:l(t,e,r)?1:-1:a(u-s)}var h=n(t,e,r);if(h>0)return o>0&&n(t,e,i)>0?1:-1;if(h<0)return o>0||n(t,e,i)>0?1:-1;var d=n(t,e,i);return d>0?1:l(t,e,r)?1:-1};var n=t("robust-orientation"),a=t("signum"),i=t("two-sum"),o=t("robust-product"),s=t("robust-sum");function l(t,e,r){var n=i(t[0],-e[0]),a=i(t[1],-e[1]),l=i(r[0],-e[0]),u=i(r[1],-e[1]),c=s(o(n,l),o(a,u));return c[c.length-1]>=0}},{"robust-orientation":262,"robust-product":263,"robust-sum":267,signum:268,"two-sum":289}],69:[function(t,e,r){e.exports=["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller"]},{}],70:[function(t,e,r){e.exports=["normal","condensed","semi-condensed","extra-condensed","ultra-condensed","expanded","semi-expanded","extra-expanded","ultra-expanded"]},{}],71:[function(t,e,r){e.exports=["normal","italic","oblique"]},{}],72:[function(t,e,r){e.exports=["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900"]},{}],73:[function(t,e,r){"use strict";e.exports={parse:t("./parse"),stringify:t("./stringify")}},{"./parse":75,"./stringify":76}],74:[function(t,e,r){"use strict";var n=t("css-font-size-keywords");e.exports={isSize:function(t){return/^[\d\.]/.test(t)||-1!==t.indexOf("/")||-1!==n.indexOf(t)}}},{"css-font-size-keywords":69}],75:[function(t,e,r){"use strict";var n=t("unquote"),a=t("css-global-keywords"),i=t("css-system-font-keywords"),o=t("css-font-weight-keywords"),s=t("css-font-style-keywords"),l=t("css-font-stretch-keywords"),u=t("string-split-by"),c=t("./lib/util").isSize;e.exports=h;var f=h.cache={};function h(t){if("string"!=typeof t)throw new Error("Font argument must be a string.");if(f[t])return f[t];if(""===t)throw new Error("Cannot parse an empty string.");if(-1!==i.indexOf(t))return f[t]={system:t};for(var e,r={style:"normal",variant:"normal",weight:"normal",stretch:"normal",lineHeight:"normal",size:"1rem",family:["serif"]},h=u(t,/\s+/);e=h.shift();){if(-1!==a.indexOf(e))return["style","variant","weight","stretch"].forEach(function(t){r[t]=e}),f[t]=r;if(-1===s.indexOf(e))if("normal"!==e&&"small-caps"!==e)if(-1===l.indexOf(e)){if(-1===o.indexOf(e)){if(c(e)){var p=u(e,"/");if(r.size=p[0],null!=p[1]?r.lineHeight=d(p[1]):"/"===h[0]&&(h.shift(),r.lineHeight=d(h.shift())),!h.length)throw new Error("Missing required font-family.");return r.family=u(h.join(" "),/\s*,\s*/).map(n),f[t]=r}throw new Error("Unknown or unsupported font token: "+e)}r.weight=e}else r.stretch=e;else r.variant=e;else r.style=e}throw new Error("Missing required font-size.")}function d(t){var e=parseFloat(t);return e.toString()===t?e:t}},{"./lib/util":74,"css-font-stretch-keywords":70,"css-font-style-keywords":71,"css-font-weight-keywords":72,"css-global-keywords":77,"css-system-font-keywords":78,"string-split-by":276,unquote:293}],76:[function(t,e,r){"use strict";var n=t("pick-by-alias"),a=t("./lib/util").isSize,i=g(t("css-global-keywords")),o=g(t("css-system-font-keywords")),s=g(t("css-font-weight-keywords")),l=g(t("css-font-style-keywords")),u=g(t("css-font-stretch-keywords")),c={normal:1,"small-caps":1},f={serif:1,"sans-serif":1,monospace:1,cursive:1,fantasy:1,"system-ui":1},h="1rem",d="serif";function p(t,e){if(t&&!e[t]&&!i[t])throw Error("Unknown keyword `"+t+"`");return t}function g(t){for(var e={},r=0;r0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},{"./lib/thunk.js":81}],80:[function(t,e,r){"use strict";var n=t("uniq");function a(t,e,r){var n,a,i=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],u=[],c=0,f=0;for(n=0;n0&&l.push("var "+u.join(",")),n=i-1;n>=0;--n)c=t[n],l.push(["for(i",n,"=0;i",n,"0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",c,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r){for(var n=t.body,a=[],i=[],o=0;o0&&y.push("shape=SS.slice(0)"),t.indexArgs.length>0){var b=new Array(r);for(l=0;l0&&m.push("var "+y.join(",")),l=0;l3&&m.push(i(t.pre,t,s));var A=i(t.body,t,s),k=function(t){for(var e=0,r=t[0].length;e0,u=[],c=0;c0;){"].join("")),u.push(["if(j",c,"<",s,"){"].join("")),u.push(["s",e[c],"=j",c].join("")),u.push(["j",c,"=0"].join("")),u.push(["}else{s",e[c],"=",s].join("")),u.push(["j",c,"-=",s,"}"].join("")),l&&u.push(["index[",e[c],"]=j",c].join(""));for(c=0;c3&&m.push(i(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+m.join("\n")+"\n----------");var T=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",k,function(t){for(var e=new Array(t.length),r=!0,n=0;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}(s)].join("");return new Function(["function ",T,"(",v.join(","),"){",m.join("\n"),"} return ",T].join(""))()}},{uniq:292}],81:[function(t,e,r){"use strict";var n=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],a=t.funcName+"_cwise_thunk";e.push(["return function ",a,"(",t.shimArgs.join(","),"){"].join(""));for(var i=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],u=[],c=0;c0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[c]))),u.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[c])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),c=0;ce?1:t>=e?0:NaN}function d(t){return null===t?NaN:+t}function p(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)<0?n=i+1:a=i}return n},right:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)>0?a=i:n=i+1}return n}}}t.ascending=h,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++an&&(r=n)}else{for(;++a=n){r=n;break}for(;++an&&(r=n)}return r},t.max=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++ar&&(r=n)}else{for(;++a=n){r=n;break}for(;++ar&&(r=n)}return r},t.extent=function(t,e){var r,n,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=n){r=a=n;break}for(;++in&&(r=n),a=n){r=a=n;break}for(;++in&&(r=n),a1)return o/(l-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(h);function m(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return h(t(e),r)}:t)},t.shuffle=function(t,e,r){(i=arguments.length)<3&&(r=t.length,i<2&&(e=0));for(var n,a,i=r-e;i;)a=Math.random()*i--|0,n=t[i+e],t[i+e]=t[a+e],t[a+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],a=new Array(r<0?0:r);e=0;)for(e=(n=t[a]).length;--e>=0;)r[--o]=n[e];return r};var y=Math.abs;function b(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function x(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(y(r)),o=-1;if(t*=i,e*=i,(r*=i)<0)for(;(n=t+r*++o)>e;)a.push(n/i);else for(;(n=t+r*++o)=a.length)return r?r.call(n,i):e?i.sort(e):i;for(var l,u,c,f,h=-1,d=i.length,p=a[s++],g=new x;++h=a.length)return e;var n=[],o=i[r++];return e.forEach(function(e,a){n.push({key:e,values:t(a,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return a.push(t),n},n.sortKeys=function(t){return i[a.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new L;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(U,"\\$&")};var U=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,H={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function V(t){return H(t,W),t}var q=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},X=function(t,e){var r=t.matches||t[R(t,"matchesSelector")];return(X=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(q=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,X=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var W=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return q(t,this)}}function Z(t){return"function"==typeof t?t:function(){return G(t,this)}}W.select=function(t){var e,r,n,a,i=[];t=Y(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Q.hasOwnProperty(r)?{space:Q[r],local:t}:t}},W.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each($(r,e[r]));return this}return this.each($(e,r))},W.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,a=-1;if(e=r.classList){for(;++a=0;)(r=n[a])&&(i&&i!==r.nextSibling&&i.parentNode.insertBefore(r,i),i=r);return this},W.sort=function(t){t=function(t){arguments.length||(t=h);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var l=pt.get(e);function u(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return l&&(e=l,s=vt),o?r?function(){var t=s(r,n(arguments));u.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=r}:u:r?z:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(r=a.match(n)){var i=this[a];this.removeEventListener(r[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=ht,ht.append=W.append,ht.empty=W.empty,ht.node=W.node,ht.call=W.call,ht.size=W.size,ht.select=function(t){for(var e,r,n,a,i,o=[],s=-1,l=this.length;++s=n&&(n=e+1);!(o=s[n])&&++n0?1:t<0?-1:0}function Dt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function Rt(t){return t>1?0:t<-1?Tt:Math.acos(t)}function Pt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function zt(t){return((t=Math.exp(t))+1/t)/2}function It(t){return(t=Math.sin(t/2))*t}var Ft=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,a=t[0],i=t[1],o=t[2],s=e[0],l=e[1],u=e[2],c=s-a,f=l-i,h=c*c+f*f;if(h0&&(e=e.transition().duration(g)),e.call(w.event)}function E(){u&&u.domain(l.range().map(function(t){return(t-h.x)/h.k}).map(l.invert)),f&&f.domain(c.range().map(function(t){return(t-h.y)/h.k}).map(c.invert))}function C(t){v++||t({type:"zoomstart"})}function S(t){E(),t({type:"zoom",scale:h.k,translate:[h.x,h.y]})}function L(t){--v||(t({type:"zoomend"}),r=null)}function O(){var e=this,r=_.of(e,arguments),n=0,a=t.select(o(e)).on(y,function(){n=1,T(t.mouse(e),i),S(r)}).on(b,function(){a.on(y,null).on(b,null),s(n),L(r)}),i=A(t.mouse(e)),s=bt(e);fs.call(e),C(r)}function D(){var e,r=this,n=_.of(r,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,l="touchmove"+o,u="touchend"+o,c=[],f=t.select(r),d=bt(r);function p(){var n=t.touches(r);return e=h.k,n.forEach(function(t){t.identifier in a&&(a[t.identifier]=A(t))}),n}function g(){var e=t.event.target;t.select(e).on(l,v).on(u,y),c.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){m=d[0];var b=d[1],x=m[0]-b[0],_=m[1]-b[1];i=x*x+_*_}}function v(){var o,l,u,c,f=t.touches(r);fs.call(r);for(var h=0,d=f.length;h360?t-=360:t<0&&(t+=360),t<60?n+(a-n)*t/60:t<180?a:t<240?n+(a-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(a=r<=.5?r*(1+e):r+e-r*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Yt?e.l:(e=he((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ht(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ht(this.h,this.s,t*this.l)},Vt.rgb=function(){return qt(this.h,this.s,this.l)},t.hcl=Gt;var Xt=Gt.prototype=new Ut;function Wt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Yt(r,Math.cos(t*=St)*e,Math.sin(t)*e)}function Yt(t,e,r){return this instanceof Yt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Yt?new Yt(t.l,t.a,t.b):t instanceof Gt?Wt(t.h,t.c,t.l):he((t=ie(t)).r,t.g,t.b):new Yt(t,e,r)}Xt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Zt*(arguments.length?t:1)))},Xt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Zt*(arguments.length?t:1)))},Xt.rgb=function(){return Wt(this.h,this.c,this.l).rgb()},t.lab=Yt;var Zt=18,Jt=.95047,Qt=1,$t=1.08883,Kt=Yt.prototype=new Ut;function te(t,e,r){var n=(t+16)/116,a=n+e/500,i=n-r/200;return new ie(ae(3.2404542*(a=re(a)*Jt)-1.5371385*(n=re(n)*Qt)-.4985314*(i=re(i)*$t)),ae(-.969266*a+1.8760108*n+.041556*i),ae(.0556434*a-.2040259*n+1.0572252*i))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Lt,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,r){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ce(""+t,ie,qt):new ie(t,e,r)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function se(t){return oe(t)+""}Kt.brighter=function(t){return new Yt(Math.min(100,this.l+Zt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Yt(Math.max(0,this.l-Zt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var le=ie.prototype=new Ut;function ue(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ce(t,e,r){var n,a,i,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=n[2].split(","),n[1]){case"hsl":return r(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(pe(a[0]),pe(a[1]),pe(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,s=240&i,s|=s>>4,l=15&i,l|=l<<4):7===t.length&&(o=(16711680&i)>>16,s=(65280&i)>>8,l=255&i)),e(o,s,l))}function fe(t,e,r){var n,a,i=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-i,l=(o+i)/2;return s?(a=l<.5?s/(o+i):s/(2-o-i),n=t==o?(e-r)/s+(e0&&l<1?0:n),new Ht(n,a,l)}function he(t,e,r){var n=ne((.4124564*(t=de(t))+.3575761*(e=de(e))+.1804375*(r=de(r)))/Jt),a=ne((.2126729*t+.7151522*e+.072175*r)/Qt);return Yt(116*a-16,500*(n-a),200*(a-ne((.0193339*t+.119192*e+.9503041*r)/$t)))}function de(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function pe(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}le.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,a=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=a.call(o,u)}catch(t){return void s.error.call(o,t)}s.load.call(o,t)}else s.error.call(o,u)}return!this.XDomainRequest||"withCredentials"in u||!/^(http(s)?:)?\/\//.test(e)||(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=f:u.onreadystatechange=function(){u.readyState>3&&f()},u.onprogress=function(e){var r=t.event;t.event=e;try{s.progress.call(o,u)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,a){if(2===arguments.length&&"function"==typeof n&&(a=n,n=null),u.open(t,e,!0),null==r||"accept"in l||(l.accept=r+",*/*"),u.setRequestHeader)for(var i in l)u.setRequestHeader(i,l[i]);return null!=r&&u.overrideMimeType&&u.overrideMimeType(r),null!=c&&(u.responseType=c),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),s.beforesend.call(o,u),u.send(null==n?null:n),o},o.abort=function(){return u.abort(),o},t.rebind(o,s,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=me(O),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function a(t,r,n){arguments.length<3&&(n=r,r=null);var a=ye(t,e,null==r?i:o(r),n);return a.row=function(t){return arguments.length?a.response(null==(r=t)?i:o(t)):r},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function s(e){return e.map(l).join(t)}function l(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var r;return a.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(a(t),r)}:a})},a.parseRows=function(t,e){var r,a,i={},o={},s=[],l=t.length,u=0,c=0;function f(){if(u>=l)return o;if(a)return a=!1,i;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Te,e)),_e=0):(_e=1,Ae(Te))}function Me(){for(var t=Date.now(),e=be;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Ee(){for(var t,e=be,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Ce(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Se[8+n/3]};var Le=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Oe=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Ce(e,r))).toFixed(Math.max(0,Math.min(20,Ce(e*(1+1e-15),r))))}});function De(t){return t+""}var Re=t.time={},Pe=Date;function ze(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}ze.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ie.setUTCDate.apply(this._,arguments)},setDay:function(){Ie.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ie.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ie.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ie.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ie.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ie.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ie.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ie.setTime.apply(this._,arguments)}};var Ie=Date.prototype;function Fe(t,e,r){function n(e){var r=t(e),n=i(r,1);return e-r1)for(;o68?1900:2e3),r+a[0].length):-1}function Je(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function Qe(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function $e(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ar(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=y(e)/60|0,a=y(e)%60;return r+He(n,"0",2)+He(a,"0",2)}function ir(t,e,r){Ue.lastIndex=0;var n=Ue.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),i.push(t.substring(r-=s,r+s)),!((l+=s+1)>e));)s=a[o=(o+1)%a.length];return i.reverse().join(n)}:O;return function(e){var n=Le.exec(e),a=n[1]||" ",s=n[2]||">",l=n[3]||"-",u=n[4]||"",c=n[5],f=+n[6],h=n[7],d=n[8],p=n[9],g=1,v="",m="",y=!1,b=!0;switch(d&&(d=+d.substring(1)),(c||"0"===a&&"="===s)&&(c=a="0",s="="),p){case"n":h=!0,p="g";break;case"%":g=100,m="%",p="f";break;case"p":g=100,m="%",p="r";break;case"b":case"o":case"x":case"X":"#"===u&&(v="0"+p.toLowerCase());case"c":b=!1;case"d":y=!0,d=0;break;case"s":g=-1,p="r"}"$"===u&&(v=i[0],m=i[1]),"r"!=p||d||(p="g"),null!=d&&("g"==p?d=Math.max(1,Math.min(21,d)):"e"!=p&&"f"!=p||(d=Math.max(0,Math.min(20,d)))),p=Oe.get(p)||De;var x=c&&h;return function(e){var n=m;if(y&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===l?"":l;if(g<0){var u=t.formatPrefix(e,d);e=u.scale(e),n=u.symbol+m}else e*=g;var _,w,A=(e=p(e,d)).lastIndexOf(".");if(A<0){var k=b?e.lastIndexOf("e"):-1;k<0?(_=e,w=""):(_=e.substring(0,k),w=e.substring(k))}else _=e.substring(0,A),w=r+e.substring(A+1);!c&&h&&(_=o(_,1/0));var T=v.length+_.length+w.length+(x?0:i.length),M=T"===s?M+i+e:"^"===s?M.substring(0,T>>=1)+i+e+M.substring(T):i+(x?e:M+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,a=e.time,i=e.periods,o=e.days,s=e.shortDays,l=e.months,u=e.shortMonths;function c(t){var e=t.length;function r(r){for(var n,a,i,o=[],s=-1,l=0;++s=u)return-1;if(37===(a=e.charCodeAt(s++))){if(o=e.charAt(s++),!(i=w[o in Be?e.charAt(s++):o])||(n=i(t,r,n))<0)return-1}else if(a!=r.charCodeAt(n++))return-1}return n}c.utc=function(t){var e=c(t);function r(t){try{var r=new(Pe=ze);return r._=t,e(r)}finally{Pe=Date}}return r.parse=function(t){try{Pe=ze;var r=e.parse(t);return r&&r._}finally{Pe=Date}},r.toString=e.toString,r},c.multi=c.utc.multi=or;var h=t.map(),d=Ve(o),p=qe(o),g=Ve(s),v=qe(s),m=Ve(l),y=qe(l),b=Ve(u),x=qe(u);i.forEach(function(t,e){h.set(t.toLowerCase(),e)});var _={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:c(r),d:function(t,e){return He(t.getDate(),e,2)},e:function(t,e){return He(t.getDate(),e,2)},H:function(t,e){return He(t.getHours(),e,2)},I:function(t,e){return He(t.getHours()%12||12,e,2)},j:function(t,e){return He(1+Re.dayOfYear(t),e,3)},L:function(t,e){return He(t.getMilliseconds(),e,3)},m:function(t,e){return He(t.getMonth()+1,e,2)},M:function(t,e){return He(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return He(t.getSeconds(),e,2)},U:function(t,e){return He(Re.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return He(Re.mondayOfYear(t),e,2)},x:c(n),X:c(a),y:function(t,e){return He(t.getFullYear()%100,e,2)},Y:function(t,e){return He(t.getFullYear()%1e4,e,4)},Z:ar,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){d.lastIndex=0;var n=d.exec(e.slice(r));return n?(t.w=p.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){b.lastIndex=0;var n=b.exec(e.slice(r));return n?(t.m=x.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){m.lastIndex=0;var n=m.exec(e.slice(r));return n?(t.m=y.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:$e,e:$e,H:tr,I:tr,j:Ke,L:nr,m:Qe,M:er,p:function(t,e,r){var n=h.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:Xe,w:Ge,W:We,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:Ze,Y:Ye,Z:Je,"%":ir};return c}(e)}};var sr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function lr(){}t.format=sr.numberFormat,t.geo={},lr.prototype={s:0,t:0,add:function(t){cr(t,this.t,ur),cr(ur.s,this.s,this),this.s?this.t+=ur.t:this.s=ur.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ur=new lr;function cr(t,e,r){var n=r.s=t+e,a=n-t,i=n-a;r.t=t-i+(e-a)}function fr(t,e){t&&dr.hasOwnProperty(t.type)&&dr[t.type](t,e)}t.geo.stream=function(t,e){t&&hr.hasOwnProperty(t.type)?hr[t.type](t,e):fr(t,e)};var hr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,a=r.length;++n=0?1:-1,s=o*i,l=Math.cos(e),u=Math.sin(e),c=a*u,f=n*l+c*Math.cos(s),h=c*o*Math.sin(s);Cr.add(Math.atan2(h,f)),r=t,n=l,a=u}Sr.point=function(o,s){Sr.point=i,r=(t=o)*St,n=Math.cos(s=(e=s)*St/2+Tt/4),a=Math.sin(s)},Sr.lineEnd=function(){i(t,e)}}function Or(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Dr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Rr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Pr(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function zr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Ir(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Fr(t){return[Math.atan2(t[1],t[0]),Pt(t[2])]}function Nr(t,e){return y(t[0]-e[0])At?a=90:u<-At&&(r=-90),f[0]=e,f[1]=n}};function d(t,i){c.push(f=[e=t,n=t]),ia&&(a=i)}function p(t,o){var s=Or([t*St,o*St]);if(l){var u=Rr(l,s),c=Rr([u[1],-u[0],0],u);Ir(c),c=Fr(c);var f=t-i,h=f>0?1:-1,p=c[0]*Lt*h,g=y(f)>180;if(g^(h*ia&&(a=v);else if(g^(h*i<(p=(p+360)%360-180)&&pa&&(a=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>i?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else d(t,o);l=s,i=t}function g(){h.point=p}function v(){f[0]=e,f[1]=n,h.point=d,l=null}function m(t,e){if(l){var r=t-i;u+=y(r)>180?r+(r>0?360:-360):r}else o=t,s=e;Sr.point(t,e),p(t,e)}function b(){Sr.lineStart()}function x(){m(o,s),Sr.lineEnd(),y(u)>At&&(e=-(n=180)),f[0]=e,f[1]=n,l=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function A(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=d[1]),_(d[0],g[1])>_(g[0],g[1])&&(g[0]=d[0])):s.push(g=d);for(var l,u,d,p=-1/0,g=(o=0,s[u=s.length-1]);o<=u;g=d,++o)d=s[o],(l=_(g[1],d[0]))>p&&(p=l,e=d[0],n=g[1])}return c=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,a]]}}(),t.geo.centroid=function(e){mr=yr=br=xr=_r=wr=Ar=kr=Tr=Mr=Er=0,t.geo.stream(e,Br);var r=Tr,n=Mr,a=Er,i=r*r+n*n+a*a;return i=0;--s)a.point((f=c[s])[0],f[1]);else n(d.x,d.p.x,-1,a);d=d.p}c=(d=d.o).z,p=!p}while(!d.v);a.lineEnd()}}}function Yr(t){if(e=t.length){for(var e,r,n=0,a=t[0];++n=0?1:-1,A=w*_,k=A>Tt,T=p*b;if(Cr.add(Math.atan2(T*w*Math.sin(A),g*x+T*Math.cos(A))),i+=k?_+w*Mt:_,k^h>=r^m>=r){var M=Rr(Or(f),Or(t));Ir(M);var E=Rr(a,M);Ir(E);var C=(k^_>=0?-1:1)*Pt(E[2]);(n>C||n===C&&(M[0]||M[1]))&&(o+=k^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(i<-At||i0){for(b||(o.polygonStart(),b=!0),o.lineStart();++i1&&2&e&&r.push(r.pop().concat(r.shift())),s.push(r.filter(Qr))}return c}}function Qr(t){return t.length>1}function $r(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:z,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-Ct-At:Ct-t[1])-((e=e.x)[0]<0?e[1]-Ct-At:Ct-e[1])}var tn=Jr(Xr,function(t){var e,r=NaN,n=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var s=i>0?Tt:-Tt,l=y(i-r);y(l-Tt)0?Ct:-Ct),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(i,n),e=0):a!==s&&l>=Tt&&(y(r-a)At?Math.atan((Math.sin(e)*(i=Math.cos(n))*Math.sin(r)-Math.sin(n)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+n)/2}(r,n,i,o),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(s,n),e=0),t.point(r=i,n=o),a=s},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var a;if(null==t)a=r*Ct,n.point(-Tt,a),n.point(0,a),n.point(Tt,a),n.point(Tt,0),n.point(Tt,-a),n.point(0,-a),n.point(-Tt,-a),n.point(-Tt,0),n.point(-Tt,a);else if(y(t[0]-e[0])>At){var i=t[0]0)){if(i/=h,h<0){if(i0){if(i>f)return;i>c&&(c=i)}if(i=r-l,h||!(i<0)){if(i/=h,h<0){if(i>f)return;i>c&&(c=i)}else if(h>0){if(i0)){if(i/=d,d<0){if(i0){if(i>f)return;i>c&&(c=i)}if(i=n-u,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>c&&(c=i)}else if(d>0){if(i0&&(a.a={x:l+c*h,y:u+c*d}),f<1&&(a.b={x:l+f*h,y:u+f*d}),a}}}}}}var rn=1e9;function nn(e,r,n,a){return function(l){var u,c,f,h,d,p,g,v,m,y,b,x=l,_=$r(),w=en(e,r,n,a),A={point:M,lineStart:function(){A.point=E,c&&c.push(f=[]);y=!0,m=!1,g=v=NaN},lineEnd:function(){u&&(E(h,d),p&&m&&_.rejoin(),u.push(_.buffer()));A.point=M,m&&l.lineEnd()},polygonStart:function(){l=_,u=[],c=[],b=!0},polygonEnd:function(){l=x,u=t.merge(u);var r=function(t){for(var e=0,r=c.length,n=t[1],a=0;an&&Dt(u,i,t)>0&&++e:i[1]<=n&&Dt(u,i,t)<0&&--e,u=i;return 0!==e}([e,a]),n=b&&r,i=u.length;(n||i)&&(l.polygonStart(),n&&(l.lineStart(),k(null,null,1,l),l.lineEnd()),i&&Wr(u,o,r,k,l),l.polygonEnd()),u=c=f=null}};function k(t,o,l,u){var c=0,f=0;if(null==t||(c=i(t,l))!==(f=i(o,l))||s(t,o)<0^l>0)do{u.point(0===c||3===c?e:n,c>1?a:r)}while((c=(c+l+4)%4)!==f);else u.point(o[0],o[1])}function T(t,i){return e<=t&&t<=n&&r<=i&&i<=a}function M(t,e){T(t,e)&&l.point(t,e)}function E(t,e){var r=T(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(c&&f.push([t,e]),y)h=t,d=e,p=r,y=!1,r&&(l.lineStart(),l.point(t,e));else if(r&&m)l.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(m||(l.lineStart(),l.point(n.a.x,n.a.y)),l.point(n.b.x,n.b.y),r||l.lineEnd(),b=!1):r&&(l.lineStart(),l.point(t,e),b=!1)}g=t,v=e,m=r}return A};function i(t,a){return y(t[0]-e)0?0:3:y(t[0]-n)0?2:1:y(t[1]-r)0?1:0:a>0?3:2}function o(t,e){return s(t.x,e.x)}function s(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Tt/3,n=Sn(t),a=n(e,r);return a.parallels=function(t){return arguments.length?n(e=t[0]*Tt/180,r=t[1]*Tt/180):[e/Tt*180,r/Tt*180]},a}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,a=1+r*(2*n-r),i=Math.sqrt(a)/n;function o(t,e){var r=Math.sqrt(a-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),i-r*Math.cos(t)]}return o.invert=function(t,e){var r=i-e;return[Math.atan2(t,r)/n,Pt((a-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(s){return arguments.length?(i=nn(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};function u(t){var i=t[0],o=t[1];return e=null,r(i,o),e||(n(i,o),e)||a(i,o),e}return u.invert=function(t){var e=i.scale(),r=i.translate(),n=(t[0]-r[0])/e,a=(t[1]-r[1])/e;return(a>=.12&&a<.234&&n>=-.425&&n<-.214?o:a>=.166&&a<.234&&n>=-.214&&n<-.115?s:i).invert(t)},u.stream=function(t){var e=i.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,a){e.point(t,a),r.point(t,a),n.point(t,a)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},u.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),s.precision(t),u):i.precision()},u.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),s.scale(t),u.translate(i.translate())):i.scale()},u.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),c=+t[0],f=+t[1];return r=i.translate(t).clipExtent([[c-.455*e,f-.238*e],[c+.455*e,f+.238*e]]).stream(l).point,n=o.translate([c-.307*e,f+.201*e]).clipExtent([[c-.425*e+At,f+.12*e+At],[c-.214*e-At,f+.234*e-At]]).stream(l).point,a=s.translate([c-.205*e,f+.212*e]).clipExtent([[c-.214*e+At,f+.166*e+At],[c-.115*e-At,f+.234*e-At]]).stream(l).point,u},u.scale(1070)};var sn,ln,un,cn,fn,hn,dn={point:z,lineStart:z,lineEnd:z,polygonStart:function(){ln=0,dn.lineStart=pn},polygonEnd:function(){dn.lineStart=dn.lineEnd=dn.point=z,sn+=y(ln/2)}};function pn(){var t,e,r,n;function a(t,e){ln+=n*t-r*e,r=t,n=e}dn.point=function(i,o){dn.point=a,t=r=i,e=n=o},dn.lineEnd=function(){a(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);ehn&&(hn=e)},lineStart:z,lineEnd:z,polygonStart:z,polygonEnd:z};function vn(){var t=mn(4.5),e=[],r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=mn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function a(t,n){e.push("M",t,",",n),r.point=i}function i(t,r){e.push("L",t,",",r)}function o(){r.point=n}function s(){e.push("Z")}return r}function mn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var yn,bn={point:xn,lineStart:_n,lineEnd:wn,polygonStart:function(){bn.lineStart=An},polygonEnd:function(){bn.point=xn,bn.lineStart=_n,bn.lineEnd=wn}};function xn(t,e){br+=t,xr+=e,++_r}function _n(){var t,e;function r(r,n){var a=r-t,i=n-e,o=Math.sqrt(a*a+i*i);wr+=o*(t+r)/2,Ar+=o*(e+n)/2,kr+=o,xn(t=r,e=n)}bn.point=function(n,a){bn.point=r,xn(t=n,e=a)}}function wn(){bn.point=xn}function An(){var t,e,r,n;function a(t,e){var a=t-r,i=e-n,o=Math.sqrt(a*a+i*i);wr+=o*(r+t)/2,Ar+=o*(n+e)/2,kr+=o,Tr+=(o=n*t-r*e)*(r+t),Mr+=o*(n+e),Er+=3*o,xn(r=t,n=e)}bn.point=function(i,o){bn.point=a,xn(t=r=i,e=n=o)},bn.lineEnd=function(){a(t,e)}}function kn(t){var e=4.5,r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:z};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,Mt)}function a(e,n){t.moveTo(e,n),r.point=i}function i(e,r){t.lineTo(e,r)}function o(){r.point=n}function s(){t.closePath()}return r}function Tn(t){var e=.5,r=Math.cos(30*St),n=16;function a(e){return(n?function(e){var r,a,o,s,l,u,c,f,h,d,p,g,v={point:m,lineStart:y,lineEnd:x,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=y}};function m(r,n){r=t(r,n),e.point(r[0],r[1])}function y(){f=NaN,v.point=b,e.lineStart()}function b(r,a){var o=Or([r,a]),s=t(r,a);i(f,h,c,d,p,g,f=s[0],h=s[1],c=r,d=o[0],p=o[1],g=o[2],n,e),e.point(f,h)}function x(){v.point=m,e.lineEnd()}function _(){y(),v.point=w,v.lineEnd=A}function w(t,e){b(r=t,e),a=f,o=h,s=d,l=p,u=g,v.point=b}function A(){i(f,h,c,d,p,g,a,o,r,s,l,u,n,e),v.lineEnd=x,x()}return v}:function(e){return En(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function i(n,a,o,s,l,u,c,f,h,d,p,g,v,m){var b=c-n,x=f-a,_=b*b+x*x;if(_>4*e&&v--){var w=s+d,A=l+p,k=u+g,T=Math.sqrt(w*w+A*A+k*k),M=Math.asin(k/=T),E=y(y(k)-1)e||y((b*O+x*D)/_-.5)>.3||s*d+l*p+u*g0&&16,a):Math.sqrt(e)},a}function Mn(t){this.stream=t}function En(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Cn(t){return Sn(function(){return t})()}function Sn(e){var r,n,a,i,o,s,l=Tn(function(t,e){return[(t=r(t,e))[0]*u+i,o-t[1]*u]}),u=150,c=480,f=250,h=0,d=0,p=0,g=0,v=0,m=tn,b=O,x=null,_=null;function w(t){return[(t=a(t[0]*St,t[1]*St))[0]*u+i,o-t[1]*u]}function A(t){return(t=a.invert((t[0]-i)/u,(o-t[1])/u))&&[t[0]*Lt,t[1]*Lt]}function k(){a=Gr(n=Rn(p,g,v),r);var t=r(h,d);return i=c-t[0]*u,o=f+t[1]*u,T()}function T(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Ln(m(n,l(b(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(m=null==t?(x=t,tn):function(t){var e=Math.cos(t),r=e>0,n=y(e)>At;return Jr(a,function(t){var e,s,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(f,h){var d,p=[f,h],g=a(f,h),v=r?g?0:o(f,h):g?o(f+(f<0?Tt:-Tt),h):0;if(!e&&(u=l=g)&&t.lineStart(),g!==l&&(d=i(e,p),(Nr(e,d)||Nr(p,d))&&(p[0]+=At,p[1]+=At,g=a(p[0],p[1]))),g!==l)c=0,g?(t.lineStart(),d=i(p,e),t.point(d[0],d[1])):(d=i(e,p),t.point(d[0],d[1]),t.lineEnd()),e=d;else if(n&&e&&r^g){var m;v&s||!(m=i(p,e,!0))||(c=0,r?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||e&&Nr(e,p)||t.point(p[0],p[1]),e=p,l=g,s=v},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return c|(u&&l)<<1}}},Fn(t,6*St),r?[0,-t]:[-Tt,t-Tt]);function a(t,r){return Math.cos(t)*Math.cos(r)>e}function i(t,r,n){var a=[1,0,0],i=Rr(Or(t),Or(r)),o=Dr(i,i),s=i[0],l=o-s*s;if(!l)return!n&&t;var u=e*o/l,c=-e*s/l,f=Rr(a,i),h=zr(a,u);Pr(h,zr(i,c));var d=f,p=Dr(h,d),g=Dr(d,d),v=p*p-g*(Dr(h,h)-1);if(!(v<0)){var m=Math.sqrt(v),b=zr(d,(-p-m)/g);if(Pr(b,h),b=Fr(b),!n)return b;var x,_=t[0],w=r[0],A=t[1],k=r[1];w<_&&(x=_,_=w,w=x);var T=w-_,M=y(T-Tt)0^b[1]<(y(b[0]-_)Tt^(_<=b[0]&&b[0]<=w)){var E=zr(d,(-p+m)/g);return Pr(E,h),[b,Fr(E)]}}}function o(e,n){var a=r?t:Tt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),n<-a?i|=4:n>a&&(i|=8),i}}((x=+t)*St),T()):x},w.clipExtent=function(t){return arguments.length?(_=t,b=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):O,T()):_},w.scale=function(t){return arguments.length?(u=+t,k()):u},w.translate=function(t){return arguments.length?(c=+t[0],f=+t[1],k()):[c,f]},w.center=function(t){return arguments.length?(h=t[0]%360*St,d=t[1]%360*St,k()):[h*Lt,d*Lt]},w.rotate=function(t){return arguments.length?(p=t[0]%360*St,g=t[1]%360*St,v=t.length>2?t[2]%360*St:0,k()):[p*Lt,g*Lt,v*Lt]},t.rebind(w,l,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&A,k()}}function Ln(t){return En(t,function(e,r){t.point(e*St,r*St)})}function On(t,e){return[t,e]}function Dn(t,e){return[t>Tt?t-Mt:t<-Tt?t+Mt:t,e]}function Rn(t,e,r){return t?e||r?Gr(zn(t),In(e,r)):zn(t):e||r?In(e,r):Dn}function Pn(t){return function(e,r){return[(e+=t)>Tt?e-Mt:e<-Tt?e+Mt:e,r]}}function zn(t){var e=Pn(t);return e.invert=Pn(-t),e}function In(t,e){var r=Math.cos(t),n=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*r+s*n;return[Math.atan2(l*a-c*i,s*r-u*n),Pt(c*a+l*i)]}return o.invert=function(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*a-l*i;return[Math.atan2(l*a+u*i,s*r+c*n),Pt(c*r-s*n)]},o}function Fn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(a,i,o,s){var l=o*e;null!=a?(a=Nn(r,a),i=Nn(r,i),(o>0?ai)&&(a+=o*Mt)):(a=t+o*Mt,i=t-.5*l);for(var u,c=a;o>0?c>i:c2?t[2]*St:0),e.invert=function(e){return(e=t.invert(e[0]*St,e[1]*St))[0]*=Lt,e[1]*=Lt,e},e},Dn.invert=On,t.geo.circle=function(){var t,e,r=[0,0],n=6;function a(){var t="function"==typeof r?r.apply(this,arguments):r,n=Rn(-t[0]*St,-t[1]*St,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=n(t,e)),t[0]*=Lt,t[1]*=Lt}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(r=t,a):r},a.angle=function(r){return arguments.length?(e=Fn((t=+r)*St,n*St),a):t},a.precision=function(r){return arguments.length?(e=Fn(t*St,(n=+r)*St),a):n},a.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*St,a=t[1]*St,i=e[1]*St,o=Math.sin(n),s=Math.cos(n),l=Math.sin(a),u=Math.cos(a),c=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((r=f*o)*r+(r=u*c-l*f*s)*r),l*c+u*f*s)},t.geo.graticule=function(){var e,r,n,a,i,o,s,l,u,c,f,h,d=10,p=d,g=90,v=360,m=2.5;function b(){return{type:"MultiLineString",coordinates:x()}}function x(){return t.range(Math.ceil(a/g)*g,n,g).map(f).concat(t.range(Math.ceil(l/v)*v,s,v).map(h)).concat(t.range(Math.ceil(r/d)*d,e,d).filter(function(t){return y(t%g)>At}).map(u)).concat(t.range(Math.ceil(o/p)*p,i,p).filter(function(t){return y(t%v)>At}).map(c))}return b.lines=function(){return x().map(function(t){return{type:"LineString",coordinates:t}})},b.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(h(s).slice(1),f(n).reverse().slice(1),h(l).reverse().slice(1))]}},b.extent=function(t){return arguments.length?b.majorExtent(t).minorExtent(t):b.minorExtent()},b.majorExtent=function(t){return arguments.length?(a=+t[0][0],n=+t[1][0],l=+t[0][1],s=+t[1][1],a>n&&(t=a,a=n,n=t),l>s&&(t=l,l=s,s=t),b.precision(m)):[[a,l],[n,s]]},b.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),o>i&&(t=o,o=i,i=t),b.precision(m)):[[r,o],[e,i]]},b.step=function(t){return arguments.length?b.majorStep(t).minorStep(t):b.minorStep()},b.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],b):[g,v]},b.minorStep=function(t){return arguments.length?(d=+t[0],p=+t[1],b):[d,p]},b.precision=function(t){return arguments.length?(m=+t,u=Bn(o,i,90),c=jn(r,e,m),f=Bn(l,s,90),h=jn(a,n,m),b):m},b.majorExtent([[-180,-90+At],[180,90-At]]).minorExtent([[-180,-80-At],[180,80+At]])},t.geo.greatArc=function(){var e,r,n=Un,a=Hn;function i(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||a.apply(this,arguments))},i.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,i):n},i.target=function(t){return arguments.length?(a=t,r="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return r=t[0]*St,n=t[1]*St,a=e[0]*St,i=e[1]*St,o=Math.cos(n),s=Math.sin(n),l=Math.cos(i),u=Math.sin(i),c=o*Math.cos(r),f=o*Math.sin(r),h=l*Math.cos(a),d=l*Math.sin(a),p=2*Math.asin(Math.sqrt(It(i-n)+o*l*It(a-r))),g=1/Math.sin(p),(v=p?function(t){var e=Math.sin(t*=p)*g,r=Math.sin(p-t)*g,n=r*c+e*h,a=r*f+e*d,i=r*s+e*u;return[Math.atan2(a,n)*Lt,Math.atan2(i,Math.sqrt(n*n+a*a))*Lt]}:function(){return[r*Lt,n*Lt]}).distance=p,v;var r,n,a,i,o,s,l,u,c,f,h,d,p,g,v},t.geo.length=function(e){return yn=0,t.geo.stream(e,Vn),yn};var Vn={sphere:z,point:z,lineStart:function(){var t,e,r;function n(n,a){var i=Math.sin(a*=St),o=Math.cos(a),s=y((n*=St)-t),l=Math.cos(s);yn+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=r*i-e*o*l)*s),e*i+r*o*l),t=n,e=i,r=o}Vn.point=function(a,i){t=a*St,e=Math.sin(i*=St),r=Math.cos(i),Vn.point=n},Vn.lineEnd=function(){Vn.point=Vn.lineEnd=z}},lineEnd:z,polygonStart:z,polygonEnd:z};function qn(t,e){function r(e,r){var n=Math.cos(e),a=Math.cos(r),i=t(n*a);return[i*a*Math.sin(e),i*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),a=e(n),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,n*o),Math.asin(n&&r*i/n)]},r}var Gn=qn(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Cn(Gn)}).raw=Gn;var Xn=qn(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},O);function Wn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Tt/4+t/2)},a=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),i=r*Math.pow(n(t),a)/a;if(!a)return Jn;function o(t,e){i>0?e<-Ct+At&&(e=-Ct+At):e>Ct-At&&(e=Ct-At);var r=i/Math.pow(n(e),a);return[r*Math.sin(a*t),i-r*Math.cos(a*t)]}return o.invert=function(t,e){var r=i-e,n=Ot(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(i/n,1/a))-Ct]},o}function Yn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),a=r/n+t;if(y(n)1&&Dt(t[r[n-2]],t[r[n-1]],t[a])<=0;)--n;r[n++]=a}return r.slice(0,n)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Cn(Kn)}).raw=Kn,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ct]},(t.geo.transverseMercator=function(){var t=Qn(ta),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,r=ra;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,a=ve(e),i=ve(r),o=t.length,s=[],l=[];for(n=0;n=0;--n)d.push(t[s[u[n]][2]]);for(n=+f;nAt)s=s.L;else{if(!((a=i-wa(s,o))>At)){n>-At?(e=s.P,r=s):a>-At?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=ma(t);if(fa.insert(e,l),e||r){if(e===r)return Ea(e),r=ma(e.site),fa.insert(l,r),l.edge=r.edge=La(e.site,l.site),Ma(e),void Ma(r);if(r){Ea(e),Ea(r);var u=e.site,c=u.x,f=u.y,h=t.x-c,d=t.y-f,p=r.site,g=p.x-c,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+c,y:(h*b-g*y)/m+f};Oa(r.edge,u,p,x),l.edge=La(u,t,null,x),r.edge=La(t,p,null,x),Ma(e),Ma(r)}else l.edge=La(e.site,l.site)}}function _a(t,e){var r=t.site,n=r.x,a=r.y,i=a-e;if(!i)return n;var o=t.P;if(!o)return-1/0;var s=(r=o.site).x,l=r.y,u=l-e;if(!u)return s;var c=s-n,f=1/i-1/u,h=c/u;return f?(-h+Math.sqrt(h*h-2*f*(c*c/(-2*u)-l+u/2+a-i/2)))/f+n:(n+s)/2}function wa(t,e){var r=t.N;if(r)return _a(r,e);var n=t.site;return n.y===e?n.x:1/0}function Aa(t){this.site=t,this.edges=[]}function ka(t,e){return e.angle-t.angle}function Ta(){Pa(this),this.x=this.y=this.arc=this.site=this.cy=null}function Ma(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,a=t.site,i=r.site;if(n!==i){var o=a.x,s=a.y,l=n.x-o,u=n.y-s,c=i.x-o,f=2*(l*(v=i.y-s)-u*c);if(!(f>=-kt)){var h=l*l+u*u,d=c*c+v*v,p=(v*h-u*d)/f,g=(l*d-c*h)/f,v=g+s,m=ga.pop()||new Ta;m.arc=t,m.site=a,m.x=p+o,m.y=v+Math.sqrt(p*p+g*g),m.cy=v,t.circle=m;for(var y=null,b=da._;b;)if(m.y=s)return;if(h>p){if(i){if(i.y>=u)return}else i={x:v,y:l};r={x:v,y:u}}else{if(i){if(i.y1)if(h>p){if(i){if(i.y>=u)return}else i={x:(l-a)/n,y:l};r={x:(u-a)/n,y:u}}else{if(i){if(i.y=s)return}else i={x:o,y:n*o+a};r={x:s,y:n*s+a}}else{if(i){if(i.xAt||y(a-r)>At)&&(s.splice(o,0,new Da((m=i.site,b=c,x=y(n-f)At?{x:f,y:y(e-f)At?{x:y(r-p)At?{x:h,y:y(e-h)At?{x:y(r-d)=r&&u.x<=a&&u.y>=n&&u.y<=o?[[r,o],[a,o],[a,n],[r,n]]:[]).point=t[s]}),e}function s(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/At)*At,y:Math.round(a(t,e)/At)*At,i:e}})}return o.links=function(t){return Na(s(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Na(s(t)).cells.forEach(function(r,n){for(var a,i,o,s,l=r.site,u=r.edges.sort(ka),c=-1,f=u.length,h=u[f-1].edge,d=h.l===l?h.r:h.l;++ci&&(a=e.slice(i,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:Ga(r,n)})),i=Ya.lastIndex;return ig&&(g=l.x),l.y>v&&(v=l.y),u.push(l.x),c.push(l.y);else for(f=0;fg&&(g=x),_>v&&(v=_),u.push(x),c.push(_)}var w=g-d,A=v-p;function k(t,e,r,n,a,i,o,s){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var l=t.x,u=t.y;if(null!=l)if(y(l-r)+y(u-n)<.01)T(t,e,r,n,a,i,o,s);else{var c=t.point;t.x=t.y=t.point=null,T(t,c,l,u,a,i,o,s),T(t,e,r,n,a,i,o,s)}else t.x=r,t.y=n,t.point=e}else T(t,e,r,n,a,i,o,s)}function T(t,e,r,n,a,i,o,s){var l=.5*(a+o),u=.5*(i+s),c=r>=l,f=n>=u,h=f<<1|c;t.leaf=!1,c?a=l:o=l,f?i=u:s=u,k(t=t.nodes[h]||(t.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){k(M,t,+m(t,++f),+b(t,f),d,p,g,v)}}),e,r,n,a,i,o,s)}w>A?v=p+w:g=d+A;var M={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){k(M,t,+m(t,++f),+b(t,f),d,p,g,v)}};if(M.visit=function(t){!function t(e,r,n,a,i,o){if(!e(r,n,a,i,o)){var s=.5*(n+i),l=.5*(a+o),u=r.nodes;u[0]&&t(e,u[0],n,a,s,l),u[1]&&t(e,u[1],s,a,i,l),u[2]&&t(e,u[2],n,l,s,o),u[3]&&t(e,u[3],s,l,i,o)}}(t,M,d,p,g,v)},M.find=function(t){return function(t,e,r,n,a,i,o){var s,l=1/0;return function t(u,c,f,h,d){if(!(c>i||f>o||h=_)<<1|e>=x,A=w+4;w=0&&!(n=t.interpolators[a](e,r)););return n}function Ja(t,e){var r,n=[],a=[],i=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function ii(t){return 1-Math.cos(t*Ct)}function oi(t){return Math.pow(2,10*(t-1))}function si(t){return 1-Math.sqrt(1-t*t)}function li(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ui(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ci(t){var e,r,n,a=[t.a,t.b],i=[t.c,t.d],o=hi(a),s=fi(a,i),l=hi(((e=i)[0]+=(n=-s)*(r=a)[0],e[1]+=n*r[1],e))||0;a[0]*i[1]=0?t.slice(0,n):t,i=n>=0?t.slice(n+1):"in";return a=$a.get(a)||Qa,i=Ka.get(i)||O,e=i(a.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,a=e.c,i=e.l,o=r.h-n,s=r.c-a,l=r.l-i;isNaN(s)&&(s=0,a=isNaN(a)?r.c:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Wt(n+o*t,a+s*t,i+l*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,a=e.s,i=e.l,o=r.h-n,s=r.s-a,l=r.l-i;isNaN(s)&&(s=0,a=isNaN(a)?r.s:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return qt(n+o*t,a+s*t,i+l*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,a=e.a,i=e.b,o=r.l-n,s=r.a-a,l=r.b-i;return function(t){return te(n+o*t,a+s*t,i+l*t)+""}},t.interpolateRound=ui,t.transform=function(e){var r=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ci(e?e.matrix:di)})(e)},ci.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var di={a:1,b:0,c:0,d:1,e:0,f:0};function pi(t){return t.length?t.pop()+",":""}function gi(e,r){var n=[],a=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push("translate(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,a),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(pi(r)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&r.push(pi(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,a),function(t,e,r,n){t!==e?n.push({i:r.push(pi(r)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&r.push(pi(r)+"skewX("+e+")")}(e.skew,r.skew,n,a),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push(pi(r)+"scale(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(pi(r)+"scale("+e+")")}(e.scale,r.scale,n,a),e=r=null,function(t){for(var e,r=-1,i=a.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:n=0})):t>0&&(l.start({type:"start",alpha:n=t}),e=ke(s.tick)),s):n},s.start=function(){var t,e,r,n=m.length,l=y.length,c=u[0],p=u[1];for(t=0;t=0;)r.push(a[n])}function Si(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(c=u[l]),c.parent=i,c.depth=i.depth+1;r&&(i.value=0),i.children=u}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Si(a,function(e){var n,a;t&&(n=e.children)&&n.sort(t),r&&(a=e.parent)&&(a.value+=e.value)}),s}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Ci(t,function(t){t.children&&(t.value=0)}),Si(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var a=e.call(this,t,n);return function t(e,r,n,a){var i=e.children;if(e.x=r,e.y=e.depth*a,e.dx=n,e.dy=a,i&&(o=i.length)){var o,s,l,u=-1;for(n=e.value?n/e.value:0;++us&&(s=n),o.push(n)}for(r=0;ra&&(n=r,a=e);return n}function Vi(t){return t.reduce(qi,0)}function qi(t,e){return t+e[1]}function Gi(t,e){return Xi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Xi(t,e){for(var r=-1,n=+t[0],a=(t[1]-n)/e,i=[];++r<=e;)i[r]=a*r+n;return i}function Wi(e){return[t.min(e),t.max(e)]}function Yi(t,e){return t.value-e.value}function Zi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function Qi(t,e){var r=e.x-t.x,n=e.y-t.y,a=t.r+e.r;return.999*a*a>r*r+n*n}function $i(t){if((e=t.children)&&(l=e.length)){var e,r,n,a,i,o,s,l,u=1/0,c=-1/0,f=1/0,h=-1/0;if(e.forEach(Ki),(r=e[0]).x=-r.r,r.y=0,b(r),l>1&&((n=e[1]).x=n.r,n.y=0,b(n),l>2))for(eo(r,n,a=e[2]),b(a),Zi(r,a),r._pack_prev=a,Zi(a,n),n=r._pack_next,i=3;i0)for(o=-1;++o=f[0]&&l<=f[1]&&((s=u[t.bisect(h,l,1,p)-1]).y+=g,s.push(i[o]));return u}return i.value=function(t){return arguments.length?(r=t,i):r},i.range=function(t){return arguments.length?(n=ve(t),i):n},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Xi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Yi),n=0,a=[1,1];function i(t,i){var o=r.call(this,t,i),s=o[0],l=a[0],u=a[1],c=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,Si(s,function(t){t.r=+c(t.value)}),Si(s,$i),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/u))/2;Si(s,function(t){t.r+=f}),Si(s,$i),Si(s,function(t){t.r-=f})}return function t(e,r,n,a){var i=e.children;e.x=r+=a*e.x;e.y=n+=a*e.y;e.r*=a;if(i)for(var o=-1,s=i.length;++od.x&&(d=t),t.depth>p.depth&&(p=t)});var g=r(h,d)/2-h.x,v=n[0]/(d.x+r(d,h)/2+g),m=n[1]/(p.depth||1);Ci(c,function(t){t.x=(t.x+g)*v,t.y=t.depth*m})}return u}function o(t){var e=t.children,n=t.parent.children,a=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+r(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+r(t._,a._));t.parent.A=function(t,e,n){if(e){for(var a,i=t,o=t,s=e,l=i.parent.children[0],u=i.m,c=o.m,f=s.m,h=l.m;s=ao(s),i=no(i),s&&i;)l=no(l),(o=ao(o)).a=t,(a=s.z+f-i.z-u+r(s._,i._))>0&&(io(oo(s,t,n),t,a),u+=a,c+=a),f+=s.m,u+=i.m,h+=l.m,c+=o.m;s&&!ao(o)&&(o.t=s,o.m+=f-c),i&&!no(l)&&(l.t=i,l.m+=u-h,n=t)}return n}(t,a,t.parent.A||n[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function l(t){t.x*=n[0],t.y=t.depth*n[1]}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t)?l:null,i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null==(n=t)?null:l,i):a?n:null},Ei(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],a=!1;function i(i,o){var s,l=e.call(this,i,o),u=l[0],c=0;Si(u,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=s?c+=r(e,s):0,e.y=0,s=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(u),h=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(u),d=f.x-r(f,h)/2,p=h.x+r(h,f)/2;return Si(u,a?function(t){t.x=(t.x-u.x)*n[0],t.y=(u.y-t.y)*n[1]}:function(t){t.x=(t.x-d)/(p-d)*n[0],t.y=(1-(u.y?t.y/u.y:1))*n[1]}),l}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t),i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null!=(n=t),i):a?n:null},Ei(i,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,a=[1,1],i=null,o=so,s=!1,l="squarify",u=.5*(1+Math.sqrt(5));function c(t,e){for(var r,n,a=-1,i=t.length;++a0;)s.push(r=u[a-1]),s.area+=r.area,"squarify"!==l||(n=d(s,g))<=h?(u.pop(),h=n):(s.area-=s.pop().area,p(s,g,i,!1),g=Math.min(i.dx,i.dy),s.length=s.area=0,h=1/0);s.length&&(p(s,g,i,!0),s.length=s.area=0),e.forEach(f)}}function h(t){var e=t.children;if(e&&e.length){var r,n=o(t),a=e.slice(),i=[];for(c(a,n.dx*n.dy/t.value),i.area=0;r=a.pop();)i.push(r),i.area+=r.area,null!=r.z&&(p(i,r.z?n.dx:n.dy,n,!a.length),i.length=i.area=0);e.forEach(h)}}function d(t,e){for(var r,n=t.area,a=0,i=1/0,o=-1,s=t.length;++oa&&(a=r));return e*=e,(n*=n)?Math.max(e*a*u/n,n/(e*i*u)):1/0}function p(t,e,r,a){var i,o=-1,s=t.length,l=r.x,u=r.y,c=e?n(t.area/e):0;if(e==r.dx){for((a||c>r.dy)&&(c=r.dy);++or.dx)&&(c=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,s=a?mi:vi;return i=t(e,r,s,n),o=t(r,e,s,Za),l}function l(t){return i(t)}l.invert=function(t){return o(t)};l.domain=function(t){return arguments.length?(e=t.map(Number),s()):e};l.range=function(t){return arguments.length?(r=t,s()):r};l.rangeRound=function(t){return l.range(t).interpolate(ui)};l.clamp=function(t){return arguments.length?(a=t,s()):a};l.interpolate=function(t){return arguments.length?(n=t,s()):n};l.ticks=function(t){return xo(e,t)};l.tickFormat=function(t,r){return _o(e,t,r)};l.nice=function(t){return yo(e,t),s()};l.copy=function(){return t(e,r,n,a)};return s()}([0,1],[0,1],Za,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function Ao(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function s(t){return a?Math.pow(n,t):-Math.pow(n,-t)}function l(t){return r(o(t))}l.invert=function(t){return s(r.invert(t))};l.domain=function(t){return arguments.length?(a=t[0]>=0,r.domain((i=t.map(Number)).map(o)),l):i};l.base=function(t){return arguments.length?(n=+t,r.domain(i.map(o)),l):n};l.nice=function(){var t=ho(i.map(o),a?Math:To);return r.domain(t),i=t.map(s),l};l.ticks=function(){var t=uo(i),e=[],r=t[0],l=t[1],u=Math.floor(o(r)),c=Math.ceil(o(l)),f=n%1?2:n;if(isFinite(c-u)){if(a){for(;u0;h--)e.push(s(u)*h);for(u=0;e[u]l;c--);e=e.slice(u,c)}return e};l.tickFormat=function(e,r){if(!arguments.length)return ko;arguments.length<2?r=ko:"function"!=typeof r&&(r=t.format(r));var a=Math.max(1,n*e/l.ticks().length);return function(t){var e=t/s(Math.round(o(t)));return e*n0?a[t-1]:r[0],tf?0:1;if(u=Et)return l(u,d)+(s?l(s,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,A,k,T,M=0,E=0,C=[];if((m=(+o.apply(this,arguments)||0)/2)&&(v=n===Do?Math.sqrt(s*s+u*u):+n.apply(this,arguments),d||(E*=-1),u&&(E=Pt(v/u*Math.sin(m))),s&&(M=Pt(v/s*Math.sin(m)))),u){y=u*Math.cos(c+E),b=u*Math.sin(c+E),x=u*Math.cos(f-E),_=u*Math.sin(f-E);var S=Math.abs(f-c-2*E)<=Tt?0:1;if(E&&No(y,b,x,_)===d^S){var L=(c+f)/2;y=u*Math.cos(L),b=u*Math.sin(L),x=_=null}}else y=b=0;if(s){w=s*Math.cos(f-M),A=s*Math.sin(f-M),k=s*Math.cos(c+M),T=s*Math.sin(c+M);var O=Math.abs(c-f+2*M)<=Tt?0:1;if(M&&No(w,A,k,T)===1-d^O){var D=(c+f)/2;w=s*Math.cos(D),A=s*Math.sin(D),k=T=null}}else w=A=0;if(h>At&&(p=Math.min(Math.abs(u-s)/2,+r.apply(this,arguments)))>.001){g=s0?0:1}function Bo(t,e,r,n,a){var i=t[0]-e[0],o=t[1]-e[1],s=(a?n:-n)/Math.sqrt(i*i+o*o),l=s*o,u=-s*i,c=t[0]+l,f=t[1]+u,h=e[0]+l,d=e[1]+u,p=(c+h)/2,g=(f+d)/2,v=h-c,m=d-f,y=v*v+m*m,b=r-n,x=c*d-h*f,_=(m<0?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,A=(-x*v-m*_)/y,k=(x*m+v*_)/y,T=(-x*v+m*_)/y,M=w-p,E=A-g,C=k-p,S=T-g;return M*M+E*E>C*C+S*S&&(w=k,A=T),[[w-l,A-u],[w*r/b,A*r/b]]}function jo(t){var e=ea,r=ra,n=Xr,a=Ho,i=a.key,o=.7;function s(i){var s,l=[],u=[],c=-1,f=i.length,h=ve(e),d=ve(r);function p(){l.push("M",a(t(u),o))}for(;++c1&&a.push("H",n[0]);return a.join("")},"step-before":qo,"step-after":Go,basis:Yo,"basis-open":function(t){if(t.length<4)return Ho(t);var e,r=[],n=-1,a=t.length,i=[0],o=[0];for(;++n<3;)e=t[n],i.push(e[0]),o.push(e[1]);r.push(Zo($o,i)+","+Zo($o,o)),--n;for(;++n9&&(a=3*e/Math.sqrt(a),o[s]=a*r,o[s+1]=a*n));s=-1;for(;++s<=l;)a=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),i.push([a||0,o[s]*a||0]);return i}(t))}});function Ho(t){return t.length>1?t.join("L"):t+"Z"}function Vo(t){return t.join("L")+"Z"}function qo(t){for(var e=0,r=t.length,n=t[0],a=[n[0],",",n[1]];++e1){s=e[1],i=t[l],l++,n+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-s[0])+","+(i[1]-s[1])+","+i[0]+","+i[1];for(var u=2;uTt)+",1 "+e}function l(t,e,r,n){return"Q 0,0 "+n}return i.radius=function(t){return arguments.length?(r=ve(t),i):r},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(n=ve(t),i):n},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Un,e=Hn,r=as;function n(n,a){var i=t.call(this,n,a),o=e.call(this,n,a),s=(i.y+o.y)/2,l=[i,{x:i.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(r))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=as,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-Ct;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=os,e=is;function r(r,n){return(ls.get(t.call(this,r,n))||ss)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var ls=t.map({circle:ss,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*cs)),r=e*cs;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/us),r=e*us/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/us),r=e*us/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=ls.keys();var us=Math.sqrt(3),cs=Math.tan(30*St);W.transition=function(t){for(var e,r,n=ps||++ms,a=xs(t),i=[],o=gs||{time:Date.now(),ease:ai,delay:0,duration:250},s=-1,l=this.length;++s0;)u[--h].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--c.count?delete c[n]:delete t[r],1}f||(i=a.time,o=ke(function(t){var e=f.delay;if(o.t=e+i,e<=t)return h(t-e);o.c=h},0,i),f=c[n]={tween:new x,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++c.count)}vs.call=W.call,vs.empty=W.empty,vs.node=W.node,vs.size=W.size,t.transition=function(e,r){return e&&e.transition?ps?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vs,vs.select=function(t){var e,r,n,a=this.id,i=this.namespace,o=[];t=Y(t);for(var s=-1,l=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function g(t){t.select(".extent").attr("y",l[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function v(){var f,v,m=this,y=t.select(t.event.target),b=n.of(m,arguments),x=t.select(m),_=y.datum(),w=!/^(n|s)$/.test(_)&&a,A=!/^(e|w)$/.test(_)&&i,k=y.classed("extent"),T=bt(m),M=t.mouse(m),E=t.select(o(m)).on("keydown.brush",function(){32==t.event.keyCode&&(k||(f=null,M[0]-=s[1],M[1]-=l[1],k=2),N())}).on("keyup.brush",function(){32==t.event.keyCode&&2==k&&(M[0]+=s[1],M[1]+=l[1],k=0,N())});if(t.event.changedTouches?E.on("touchmove.brush",L).on("touchend.brush",D):E.on("mousemove.brush",L).on("mouseup.brush",D),x.interrupt().selectAll("*").interrupt(),k)M[0]=s[0]-M[0],M[1]=l[0]-M[1];else if(_){var C=+/w$/.test(_),S=+/^n/.test(_);v=[s[1-C]-M[0],l[1-S]-M[1]],M[0]=s[C],M[1]=l[S]}else t.event.altKey&&(f=M.slice());function L(){var e=t.mouse(m),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),k||(t.event.altKey?(f||(f=[(s[0]+s[1])/2,(l[0]+l[1])/2]),M[0]=s[+(e[0]1?{floor:function(e){for(;s(e=t.floor(e));)e=Rs(e-1);return e},ceil:function(e){for(;s(e=t.ceil(e));)e=Rs(+e+1);return e}}:t))},a.ticks=function(t,e){var r=uo(a.domain()),n=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],Rs(+r[1]+1),e<1?1:e)},a.tickFormat=function(){return n},a.copy=function(){return Ds(e.copy(),r,n)},mo(a,e)}function Rs(t){return new Date(t)}Cs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Os:Ls,Os.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Os.toString=Ls.toString,Re.second=Fe(function(t){return new Pe(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),Re.seconds=Re.second.range,Re.seconds.utc=Re.second.utc.range,Re.minute=Fe(function(t){return new Pe(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),Re.minutes=Re.minute.range,Re.minutes.utc=Re.minute.utc.range,Re.hour=Fe(function(t){var e=t.getTimezoneOffset()/60;return new Pe(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),Re.hours=Re.hour.range,Re.hours.utc=Re.hour.utc.range,Re.month=Fe(function(t){return(t=Re.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),Re.months=Re.month.range,Re.months.utc=Re.month.utc.range;var Ps=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],zs=[[Re.second,1],[Re.second,5],[Re.second,15],[Re.second,30],[Re.minute,1],[Re.minute,5],[Re.minute,15],[Re.minute,30],[Re.hour,1],[Re.hour,3],[Re.hour,6],[Re.hour,12],[Re.day,1],[Re.day,2],[Re.week,1],[Re.month,1],[Re.month,3],[Re.year,1]],Is=Cs.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Xr]]),Fs={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(Rs)},floor:O,ceil:O};zs.year=Re.year,Re.scale=function(){return Ds(t.scale.linear(),zs,Is)};var Ns=zs.map(function(t){return[t[0].utc,t[1]]}),Bs=Ss.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Xr]]);function js(t){return JSON.parse(t.responseText)}function Us(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Ns.year=Re.year.utc,Re.scale.utc=function(){return Ds(t.scale.linear(),Ns,Bs)},t.text=me(function(t){return t.responseText}),t.json=function(t,e){return ye(t,"application/json",js,e)},t.html=function(t,e){return ye(t,"text/html",Us,e)},t.xml=me(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],86:[function(t,e,r){e.exports=function(){for(var t=0;ts*l){var d=(h-f)/s;i[c]=1e3*d}}return i}function o(t){for(var e=[],r=t[0];r<=t[1];r++)for(var n=String.fromCharCode(r),a=t[0];a>>31},e.exports.exponent=function(t){return(e.exports.hi(t)<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),a=1048575&n;return 2146435072&n&&(a+=1<<20),[r,a]},e.exports.denormalized=function(t){return!(2146435072&e.exports.hi(t))}}).call(this,t("buffer").Buffer)},{buffer:51}],89:[function(t,e,r){var n=t("abs-svg-path"),a=t("normalize-svg-path"),i={M:"moveTo",C:"bezierCurveTo"};e.exports=function(t,e){t.beginPath(),a(n(e)).forEach(function(e){var r=e[0],n=e.slice(1);t[i[r]].apply(t,n)}),t.closePath()}},{"abs-svg-path":11,"normalize-svg-path":222}],90:[function(t,e,r){e.exports=function(t){switch(t){case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"uint8":return Uint8Array;case"uint16":return Uint16Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;case"array":return Array;case"uint8_clamped":return Uint8ClampedArray}}},{}],91:[function(t,e,r){"use strict";e.exports=function(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return function(t,e){var r,n;for(r=new Array(t),n=0;n80*r){n=l=t[0],s=u=t[1];for(var x=r;xl&&(l=c),d>u&&(u=d);g=0!==(g=Math.max(l-n,u-s))?1/g:0}return o(y,b,r,n,s,g),b}function a(t,e,r,n,a){var i,o;if(a===T(t,e,r,n)>0)for(i=e;i=e;i-=n)o=w(i,t[i],t[i+1],o);return o&&y(o,o.next)&&(A(o),o=o.next),o}function i(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!y(n,n.next)&&0!==m(n.prev,n,n.next))n=n.next;else{if(A(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function o(t,e,r,n,a,f,h){if(t){!h&&f&&function(t,e,r,n){var a=t;do{null===a.z&&(a.z=d(a.x,a.y,e,r,n)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next}while(a!==t);a.prevZ.nextZ=null,a.prevZ=null,function(t){var e,r,n,a,i,o,s,l,u=1;do{for(r=t,t=null,i=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(a=r,r=r.nextZ,s--):(a=n,n=n.nextZ,l--),i?i.nextZ=a:t=a,a.prevZ=i,i=a;r=n}i.nextZ=null,u*=2}while(o>1)}(a)}(t,n,a,f);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,f?l(t,n,a,f):s(t))e.push(p.i/r),e.push(t.i/r),e.push(g.i/r),A(t),t=g.next,v=g.next;else if((t=g)===v){h?1===h?o(t=u(t,e,r),e,r,n,a,f,2):2===h&&c(t,e,r,n,a,f):o(i(t),e,r,n,a,f,1);break}}}function s(t){var e=t.prev,r=t,n=t.next;if(m(e,r,n)>=0)return!1;for(var a=t.next.next;a!==t.prev;){if(g(e.x,e.y,r.x,r.y,n.x,n.y,a.x,a.y)&&m(a.prev,a,a.next)>=0)return!1;a=a.next}return!0}function l(t,e,r,n){var a=t.prev,i=t,o=t.next;if(m(a,i,o)>=0)return!1;for(var s=a.xi.x?a.x>o.x?a.x:o.x:i.x>o.x?i.x:o.x,c=a.y>i.y?a.y>o.y?a.y:o.y:i.y>o.y?i.y:o.y,f=d(s,l,e,r,n),h=d(u,c,e,r,n),p=t.prevZ,v=t.nextZ;p&&p.z>=f&&v&&v.z<=h;){if(p!==t.prev&&p!==t.next&&g(a.x,a.y,i.x,i.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,v!==t.prev&&v!==t.next&&g(a.x,a.y,i.x,i.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;p&&p.z>=f;){if(p!==t.prev&&p!==t.next&&g(a.x,a.y,i.x,i.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;v&&v.z<=h;){if(v!==t.prev&&v!==t.next&&g(a.x,a.y,i.x,i.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function u(t,e,r){var n=t;do{var a=n.prev,i=n.next.next;!y(a,i)&&b(a,n,n.next,i)&&x(a,i)&&x(i,a)&&(e.push(a.i/r),e.push(n.i/r),e.push(i.i/r),A(n),A(n.next),n=t=i),n=n.next}while(n!==t);return n}function c(t,e,r,n,a,s){var l=t;do{for(var u=l.next.next;u!==l.prev;){if(l.i!==u.i&&v(l,u)){var c=_(l,u);return l=i(l,l.next),c=i(c,c.next),o(l,e,r,n,a,s),void o(c,e,r,n,a,s)}u=u.next}l=l.next}while(l!==t)}function f(t,e){return t.x-e.x}function h(t,e){if(e=function(t,e){var r,n=e,a=t.x,i=t.y,o=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){var s=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=a&&s>o){if(o=s,s===a){if(i===n.y)return n;if(i===n.next.y)return n.next}r=n.x=n.x&&n.x>=c&&a!==n.x&&g(ir.x)&&x(n,t)&&(r=n,h=l),n=n.next;return r}(t,e)){var r=_(e,t);i(r,r.next)}}function d(t,e,r,n,a){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*a)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*a)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,r=t;do{e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(i-s)-(a-o)*(n-s)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&b(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&x(t,e)&&x(e,t)&&function(t,e){var r=t,n=!1,a=(t.x+e.x)/2,i=(t.y+e.y)/2;do{r.y>i!=r.next.y>i&&r.next.y!==r.y&&a<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)}function m(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function y(t,e){return t.x===e.x&&t.y===e.y}function b(t,e,r,n){return!!(y(t,e)&&y(r,n)||y(t,n)&&y(r,e))||m(t,e,r)>0!=m(t,e,n)>0&&m(r,n,t)>0!=m(r,n,e)>0}function x(t,e){return m(t.prev,t,t.next)<0?m(t,e,t.next)>=0&&m(t,t.prev,e)>=0:m(t,e,t.prev)<0||m(t,t.next,e)<0}function _(t,e){var r=new k(t.i,t.x,t.y),n=new k(e.i,e.x,e.y),a=t.next,i=e.prev;return t.next=e,e.prev=t,r.next=a,a.prev=r,n.next=r,r.prev=n,i.next=n,n.prev=i,n}function w(t,e,r,n){var a=new k(t,e,r);return n?(a.next=n.next,a.prev=n,n.next.prev=a,n.next=a):(a.prev=a,a.next=a),a}function A(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function k(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T(t,e,r,n){for(var a=0,i=e,o=r-n;i0&&(n+=t[a-1].length,r.holes.push(n))}return r}},{}],93:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if("number"!=typeof e){e=0;for(var a=0;a=55296&&y<=56319&&(w+=t[++r]),w=A?h.call(A,k,w,g):w,e?(d.value=w,p(v,g,d)):v[g]=w,++g;m=g}if(void 0===m)for(m=o(t.length),e&&(v=new e(m)),r=0;r0?1:-1}},{}],104:[function(t,e,r){"use strict";var n=t("../math/sign"),a=Math.abs,i=Math.floor;e.exports=function(t){return isNaN(t)?0:0!==(t=Number(t))&&isFinite(t)?n(t)*i(a(t)):t}},{"../math/sign":101}],105:[function(t,e,r){"use strict";var n=t("./to-integer"),a=Math.max;e.exports=function(t){return a(0,n(t))}},{"./to-integer":104}],106:[function(t,e,r){"use strict";var n=t("./valid-callable"),a=t("./valid-value"),i=Function.prototype.bind,o=Function.prototype.call,s=Object.keys,l=Object.prototype.propertyIsEnumerable;e.exports=function(t,e){return function(r,u){var c,f=arguments[2],h=arguments[3];return r=Object(a(r)),n(u),c=s(r),h&&c.sort("function"==typeof h?i.call(h,r):void 0),"function"!=typeof t&&(t=c[t]),o.call(t,c,function(t,n){return l.call(r,t)?o.call(u,f,r[t],t,r,n):e})}}},{"./valid-callable":124,"./valid-value":126}],107:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Object.assign:t("./shim")},{"./is-implemented":108,"./shim":109}],108:[function(t,e,r){"use strict";e.exports=function(){var t,e=Object.assign;return"function"==typeof e&&(e(t={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},{}],109:[function(t,e,r){"use strict";var n=t("../keys"),a=t("../valid-value"),i=Math.max;e.exports=function(t,e){var r,o,s,l=i(arguments.length,2);for(t=Object(a(t)),s=function(n){try{t[n]=e[n]}catch(t){r||(r=t)}},o=1;o-1}},{}],130:[function(t,e,r){"use strict";var n=Object.prototype.toString,a=n.call("");e.exports=function(t){return"string"==typeof t||t&&"object"==typeof t&&(t instanceof String||n.call(t)===a)||!1}},{}],131:[function(t,e,r){"use strict";var n=Object.create(null),a=Math.random;e.exports=function(){var t;do{t=a().toString(36).slice(2)}while(n[t]);return t}},{}],132:[function(t,e,r){"use strict";var n,a=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("es6-symbol"),l=t("./"),u=Object.defineProperty;n=e.exports=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");l.call(this,t),e=e?i.call(e,"key+value")?"key+value":i.call(e,"key")?"key":"value":"value",u(this,"__kind__",o("",e))},a&&a(n,l),delete n.prototype.constructor,n.prototype=Object.create(l.prototype,{_resolve:o(function(t){return"value"===this.__kind__?this.__list__[t]:"key+value"===this.__kind__?[t,this.__list__[t]]:t})}),u(n.prototype,s.toStringTag,o("c","Array Iterator"))},{"./":135,d:84,"es5-ext/object/set-prototype-of":121,"es5-ext/string/#/contains":127,"es6-symbol":140}],133:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),a=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,l=Function.prototype.call,u=Array.prototype.some;e.exports=function(t,e){var r,c,f,h,d,p,g,v,m=arguments[2];if(s(t)||n(t)?r="array":i(t)?r="string":t=o(t),a(e),f=function(){h=!0},"array"!==r)if("string"!==r)for(c=t.next();!c.done;){if(l.call(e,m,c.value,f),h)return;c=t.next()}else for(p=t.length,d=0;d=55296&&v<=56319&&(g+=t[++d]),l.call(e,m,g,f),!h);++d);else u.call(t,function(t){return l.call(e,m,t,f),h})}},{"./get":134,"es5-ext/function/is-arguments":98,"es5-ext/object/valid-callable":124,"es5-ext/string/is-string":130}],134:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),a=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),l=t("es6-symbol").iterator;e.exports=function(t){return"function"==typeof s(t)[l]?t[l]():n(t)?new i(t):a(t)?new o(t):new i(t)}},{"./array":132,"./string":137,"./valid-iterable":138,"es5-ext/function/is-arguments":98,"es5-ext/string/is-string":130,"es6-symbol":140}],135:[function(t,e,r){"use strict";var n,a=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),l=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),f=Object.defineProperty,h=Object.defineProperties;e.exports=n=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");h(this,{__list__:l("w",s(t)),__context__:l("w",e),__nextIndex__:l("w",0)}),e&&(o(e.on),e.on("_add",this._onAdd),e.on("_delete",this._onDelete),e.on("_clear",this._onClear))},delete n.prototype.constructor,h(n.prototype,i({_next:l(function(){var t;if(this.__list__)return this.__redo__&&void 0!==(t=this.__redo__.shift())?t:this.__nextIndex__=this.__nextIndex__||(++this.__nextIndex__,this.__redo__?(this.__redo__.forEach(function(e,r){e>=t&&(this.__redo__[r]=++e)},this),this.__redo__.push(t)):f(this,"__redo__",l("c",[t])))}),_onDelete:l(function(t){var e;t>=this.__nextIndex__||(--this.__nextIndex__,this.__redo__&&(-1!==(e=this.__redo__.indexOf(t))&&this.__redo__.splice(e,1),this.__redo__.forEach(function(e,r){e>t&&(this.__redo__[r]=--e)},this)))}),_onClear:l(function(){this.__redo__&&a.call(this.__redo__),this.__nextIndex__=0})}))),f(n.prototype,c.iterator,l(function(){return this}))},{d:84,"d/auto-bind":83,"es5-ext/array/#/clear":94,"es5-ext/object/assign":107,"es5-ext/object/valid-callable":124,"es5-ext/object/valid-value":126,"es6-symbol":140}],136:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),a=t("es5-ext/object/is-value"),i=t("es5-ext/string/is-string"),o=t("es6-symbol").iterator,s=Array.isArray;e.exports=function(t){return!!a(t)&&(!!s(t)||(!!i(t)||(!!n(t)||"function"==typeof t[o])))}},{"es5-ext/function/is-arguments":98,"es5-ext/object/is-value":115,"es5-ext/string/is-string":130,"es6-symbol":140}],137:[function(t,e,r){"use strict";var n,a=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("es6-symbol"),s=t("./"),l=Object.defineProperty;n=e.exports=function(t){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");t=String(t),s.call(this,t),l(this,"__length__",i("",t.length))},a&&a(n,s),delete n.prototype.constructor,n.prototype=Object.create(s.prototype,{_next:i(function(){if(this.__list__)return this.__nextIndex__=55296&&e<=56319?r+this.__list__[this.__nextIndex__++]:r})}),l(n.prototype,o.toStringTag,i("c","String Iterator"))},{"./":135,d:84,"es5-ext/object/set-prototype-of":121,"es6-symbol":140}],138:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":136}],139:[function(t,e,r){(function(n,a){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,s=void 0,l=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(s?s(v):_())};var u="undefined"!=typeof window?window:void 0,c=u||{},f=c.MutationObserver||c.WebKitMutationObserver,h="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),d="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function p(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;te[0]-o[0]/2&&(h=o[0]/2,d+=o[1]);return r}},{"css-font/stringify":76}],152:[function(t,e,r){"use strict";function n(t,e){e||(e={}),("string"==typeof t||Array.isArray(t))&&(e.family=t);var r=Array.isArray(e.family)?e.family.join(", "):e.family;if(!r)throw Error("`family` must be defined");var s=e.size||e.fontSize||e.em||48,l=e.weight||e.fontWeight||"",u=(t=[e.style||e.fontStyle||"",l,s].join(" ")+"px "+r,e.origin||"top");if(n.cache[r]&&s<=n.cache[r].em)return a(n.cache[r],u);var c=e.canvas||n.canvas,f=c.getContext("2d"),h={upper:void 0!==e.upper?e.upper:"H",lower:void 0!==e.lower?e.lower:"x",descent:void 0!==e.descent?e.descent:"p",ascent:void 0!==e.ascent?e.ascent:"h",tittle:void 0!==e.tittle?e.tittle:"i",overshoot:void 0!==e.overshoot?e.overshoot:"O"},d=Math.ceil(1.5*s);c.height=d,c.width=.5*d,f.font=t;var p={top:0};f.clearRect(0,0,d,d),f.textBaseline="top",f.fillStyle="black",f.fillText("H",0,0);var g=i(f.getImageData(0,0,d,d));f.clearRect(0,0,d,d),f.textBaseline="bottom",f.fillText("H",0,d);var v=i(f.getImageData(0,0,d,d));p.lineHeight=p.bottom=d-v+g,f.clearRect(0,0,d,d),f.textBaseline="alphabetic",f.fillText("H",0,d);var m=d-i(f.getImageData(0,0,d,d))-1+g;p.baseline=p.alphabetic=m,f.clearRect(0,0,d,d),f.textBaseline="middle",f.fillText("H",0,.5*d);var y=i(f.getImageData(0,0,d,d));p.median=p.middle=d-y-1+g-.5*d,f.clearRect(0,0,d,d),f.textBaseline="hanging",f.fillText("H",0,.5*d);var b=i(f.getImageData(0,0,d,d));p.hanging=d-b-1+g-.5*d,f.clearRect(0,0,d,d),f.textBaseline="ideographic",f.fillText("H",0,d);var x=i(f.getImageData(0,0,d,d));if(p.ideographic=d-x-1+g,h.upper&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.upper,0,0),p.upper=i(f.getImageData(0,0,d,d)),p.capHeight=p.baseline-p.upper),h.lower&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.lower,0,0),p.lower=i(f.getImageData(0,0,d,d)),p.xHeight=p.baseline-p.lower),h.tittle&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.tittle,0,0),p.tittle=i(f.getImageData(0,0,d,d))),h.ascent&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.ascent,0,0),p.ascent=i(f.getImageData(0,0,d,d))),h.descent&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.descent,0,0),p.descent=o(f.getImageData(0,0,d,d))),h.overshoot){f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.overshoot,0,0);var _=o(f.getImageData(0,0,d,d));p.overshoot=_-m}for(var w in p)p[w]/=s;return p.em=s,n.cache[r]=p,a(p,u)}function a(t,e){var r={};for(var n in"string"==typeof e&&(e=t[e]),t)"em"!==n&&(r[n]=t[n]-e);return r}function i(t){for(var e=t.height,r=t.data,n=3;n0;n-=4)if(0!==r[n])return Math.floor(.25*(n-3)/e)}e.exports=n,n.canvas=document.createElement("canvas"),n.cache={}},{}],153:[function(t,e,r){"use strict";e.exports=function(t){return new u(t||p,null)};var n=0,a=1;function i(t,e,r,n,a,i){this._color=t,this.key=e,this.value=r,this.left=n,this.right=a,this._count=i}function o(t){return new i(t._color,t.key,t.value,t.left,t.right,t._count)}function s(t,e){return new i(t,e.key,e.value,e.left,e.right,e._count)}function l(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function u(t,e){this._compare=t,this.root=e}var c=u.prototype;function f(t,e){this.tree=t,this._stack=e}Object.defineProperty(c,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(c,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(c,"length",{get:function(){return this.root?this.root._count:0}}),c.insert=function(t,e){for(var r=this._compare,o=this.root,c=[],f=[];o;){var h=r(t,o.key);c.push(o),f.push(h),o=h<=0?o.left:o.right}c.push(new i(n,t,e,null,null,1));for(var d=c.length-2;d>=0;--d){o=c[d];f[d]<=0?c[d]=new i(o._color,o.key,o.value,c[d+1],o.right,o._count+1):c[d]=new i(o._color,o.key,o.value,o.left,c[d+1],o._count+1)}for(d=c.length-1;d>1;--d){var p=c[d-1];o=c[d];if(p._color===a||o._color===a)break;var g=c[d-2];if(g.left===p)if(p.left===o){if(!(v=g.right)||v._color!==n){if(g._color=n,g.left=p.right,p._color=a,p.right=g,c[d-2]=p,c[d-1]=o,l(g),l(p),d>=3)(m=c[d-3]).left===g?m.left=p:m.right=p;break}p._color=a,g.right=s(a,v),g._color=n,d-=1}else{if(!(v=g.right)||v._color!==n){if(p.right=o.left,g._color=n,g.left=o.right,o._color=a,o.left=p,o.right=g,c[d-2]=o,c[d-1]=p,l(g),l(p),l(o),d>=3)(m=c[d-3]).left===g?m.left=o:m.right=o;break}p._color=a,g.right=s(a,v),g._color=n,d-=1}else if(p.right===o){if(!(v=g.left)||v._color!==n){if(g._color=n,g.right=p.left,p._color=a,p.left=g,c[d-2]=p,c[d-1]=o,l(g),l(p),d>=3)(m=c[d-3]).right===g?m.right=p:m.left=p;break}p._color=a,g.left=s(a,v),g._color=n,d-=1}else{var v;if(!(v=g.left)||v._color!==n){var m;if(p.left=o.right,g._color=n,g.right=o.left,o._color=a,o.right=p,o.left=g,c[d-2]=o,c[d-1]=p,l(g),l(p),l(o),d>=3)(m=c[d-3]).right===g?m.right=o:m.left=o;break}p._color=a,g.left=s(a,v),g._color=n,d-=1}}return c[0]._color=a,new u(r,c[0])},c.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return function t(e,r){var n;if(r.left&&(n=t(e,r.left)))return n;return(n=e(r.key,r.value))||(r.right?t(e,r.right):void 0)}(t,this.root);case 2:return function t(e,r,n,a){if(r(e,a.key)<=0){var i;if(a.left&&(i=t(e,r,n,a.left)))return i;if(i=n(a.key,a.value))return i}if(a.right)return t(e,r,n,a.right)}(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return function t(e,r,n,a,i){var o,s=n(e,i.key),l=n(r,i.key);if(s<=0){if(i.left&&(o=t(e,r,n,a,i.left)))return o;if(l>0&&(o=a(i.key,i.value)))return o}if(l>0&&i.right)return t(e,r,n,a,i.right)}(e,r,this._compare,t,this.root)}},Object.defineProperty(c,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(c,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),c.at=function(t){if(t<0)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},c.ge=function(t){for(var e=this._compare,r=this.root,n=[],a=0;r;){var i=e(t,r.key);n.push(r),i<=0&&(a=n.length),r=i<=0?r.left:r.right}return n.length=a,new f(this,n)},c.gt=function(t){for(var e=this._compare,r=this.root,n=[],a=0;r;){var i=e(t,r.key);n.push(r),i<0&&(a=n.length),r=i<0?r.left:r.right}return n.length=a,new f(this,n)},c.lt=function(t){for(var e=this._compare,r=this.root,n=[],a=0;r;){var i=e(t,r.key);n.push(r),i>0&&(a=n.length),r=i<=0?r.left:r.right}return n.length=a,new f(this,n)},c.le=function(t){for(var e=this._compare,r=this.root,n=[],a=0;r;){var i=e(t,r.key);n.push(r),i>=0&&(a=n.length),r=i<0?r.left:r.right}return n.length=a,new f(this,n)},c.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var a=e(t,r.key);if(n.push(r),0===a)return new f(this,n);r=a<=0?r.left:r.right}return new f(this,[])},c.remove=function(t){var e=this.find(t);return e?e.remove():this},c.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=n<=0?r.left:r.right}};var h=f.prototype;function d(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function p(t,e){return te?1:0}Object.defineProperty(h,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(h,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),h.clone=function(){return new f(this.tree,this._stack.slice())},h.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new i(r._color,r.key,r.value,r.left,r.right,r._count);for(var c=t.length-2;c>=0;--c){(r=t[c]).left===t[c+1]?e[c]=new i(r._color,r.key,r.value,e[c+1],r.right,r._count):e[c]=new i(r._color,r.key,r.value,r.left,e[c+1],r._count)}if((r=e[e.length-1]).left&&r.right){var f=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var h=e[f-1];e.push(new i(r._color,h.key,h.value,r.left,r.right,r._count)),e[f-1].key=r.key,e[f-1].value=r.value;for(c=e.length-2;c>=f;--c)r=e[c],e[c]=new i(r._color,r.key,r.value,r.left,e[c+1],r._count);e[f-1].left=e[f]}if((r=e[e.length-1])._color===n){var p=e[e.length-2];p.left===r?p.left=null:p.right===r&&(p.right=null),e.pop();for(c=0;c=0;--c){if(e=t[c],0===c)return void(e._color=a);if((r=t[c-1]).left===e){if((i=r.right).right&&i.right._color===n)return u=(i=r.right=o(i)).right=o(i.right),r.right=i.left,i.left=r,i.right=u,i._color=r._color,e._color=a,r._color=a,u._color=a,l(r),l(i),c>1&&((f=t[c-2]).left===r?f.left=i:f.right=i),void(t[c-1]=i);if(i.left&&i.left._color===n)return u=(i=r.right=o(i)).left=o(i.left),r.right=u.left,i.left=u.right,u.left=r,u.right=i,u._color=r._color,r._color=a,i._color=a,e._color=a,l(r),l(i),l(u),c>1&&((f=t[c-2]).left===r?f.left=u:f.right=u),void(t[c-1]=u);if(i._color===a){if(r._color===n)return r._color=a,void(r.right=s(n,i));r.right=s(n,i);continue}i=o(i),r.right=i.left,i.left=r,i._color=r._color,r._color=n,l(r),l(i),c>1&&((f=t[c-2]).left===r?f.left=i:f.right=i),t[c-1]=i,t[c]=r,c+11&&((f=t[c-2]).right===r?f.right=i:f.left=i),void(t[c-1]=i);if(i.right&&i.right._color===n)return u=(i=r.left=o(i)).right=o(i.right),r.left=u.right,i.right=u.left,u.right=r,u.left=i,u._color=r._color,r._color=a,i._color=a,e._color=a,l(r),l(i),l(u),c>1&&((f=t[c-2]).right===r?f.right=u:f.left=u),void(t[c-1]=u);if(i._color===a){if(r._color===n)return r._color=a,void(r.left=s(n,i));r.left=s(n,i);continue}var f;i=o(i),r.left=i.right,i.right=r,i._color=r._color,r._color=n,l(r),l(i),c>1&&((f=t[c-2]).right===r?f.right=i:f.left=i),t[c-1]=i,t[c]=r,c+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(h,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(h,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),h.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),h.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),n=e[e.length-1];r[r.length-1]=new i(n._color,n.key,t,n.left,n.right,n._count);for(var a=e.length-2;a>=0;--a)(n=e[a]).left===e[a+1]?r[a]=new i(n._color,n.key,n.value,r[a+1],n.right,n._count):r[a]=new i(n._color,n.key,n.value,n.left,r[a+1],n._count);return new u(this.tree._compare,r[0])},h.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],154:[function(t,e,r){var n=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],a=607/128,i=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function o(t){if(t<0)return Number("0/0");for(var e=i[0],r=i.length-1;r>0;--r)e+=i[r]/(t+r);var n=t+a+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}e.exports=function t(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*t(1-e));if(e>100)return Math.exp(o(e));e-=1;for(var r=n[0],a=1;a<9;a++)r+=n[a]/(e+a);var i=e+7+.5;return Math.sqrt(2*Math.PI)*Math.pow(i,e+.5)*Math.exp(-i)*r},e.exports.log=o},{}],155:[function(t,e,r){e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("must specify type string");if(e=e||{},"undefined"==typeof document&&!e.canvas)return null;var r=e.canvas||document.createElement("canvas");"number"==typeof e.width&&(r.width=e.width);"number"==typeof e.height&&(r.height=e.height);var n,a=e;try{var i=[t];0===t.indexOf("webgl")&&i.push("experimental-"+t);for(var o=0;or)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,i,a),r}function c(t,e){for(var r=n.malloc(t.length,e),a=t.length,i=0;i=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=u(this.gl,this.type,this.length,this.usage,t.data,e):this.length=u(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=n.malloc(t.size,r),l=i(s,t.shape);a.assign(l,t),this.length=u(this.gl,this.type,this.length,this.usage,e<0?s:s.subarray(0,t.size),e),n.free(s)}}else if(Array.isArray(t)){var f;f=this.type===this.gl.ELEMENT_ARRAY_BUFFER?c(t,"uint16"):c(t,"float32"),this.length=u(this.gl,this.type,this.length,this.usage,e<0?f:f.subarray(0,t.length),e),n.free(f)}else if("object"==typeof t&&"number"==typeof t.length)this.length=u(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");(t|=0)<=0&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=function(t,e,r,n){if(r=r||t.ARRAY_BUFFER,n=n||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(n!==t.DYNAMIC_DRAW&&n!==t.STATIC_DRAW&&n!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var a=t.createBuffer(),i=new s(t,r,a,0,n);return i.update(e),i}},{ndarray:220,"ndarray-ops":219,"typedarray-pool":290}],157:[function(t,e,r){e.exports={0:"NONE",1:"ONE",2:"LINE_LOOP",3:"LINE_STRIP",4:"TRIANGLES",5:"TRIANGLE_STRIP",6:"TRIANGLE_FAN",256:"DEPTH_BUFFER_BIT",512:"NEVER",513:"LESS",514:"EQUAL",515:"LEQUAL",516:"GREATER",517:"NOTEQUAL",518:"GEQUAL",519:"ALWAYS",768:"SRC_COLOR",769:"ONE_MINUS_SRC_COLOR",770:"SRC_ALPHA",771:"ONE_MINUS_SRC_ALPHA",772:"DST_ALPHA",773:"ONE_MINUS_DST_ALPHA",774:"DST_COLOR",775:"ONE_MINUS_DST_COLOR",776:"SRC_ALPHA_SATURATE",1024:"STENCIL_BUFFER_BIT",1028:"FRONT",1029:"BACK",1032:"FRONT_AND_BACK",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",2304:"CW",2305:"CCW",2849:"LINE_WIDTH",2884:"CULL_FACE",2885:"CULL_FACE_MODE",2886:"FRONT_FACE",2928:"DEPTH_RANGE",2929:"DEPTH_TEST",2930:"DEPTH_WRITEMASK",2931:"DEPTH_CLEAR_VALUE",2932:"DEPTH_FUNC",2960:"STENCIL_TEST",2961:"STENCIL_CLEAR_VALUE",2962:"STENCIL_FUNC",2963:"STENCIL_VALUE_MASK",2964:"STENCIL_FAIL",2965:"STENCIL_PASS_DEPTH_FAIL",2966:"STENCIL_PASS_DEPTH_PASS",2967:"STENCIL_REF",2968:"STENCIL_WRITEMASK",2978:"VIEWPORT",3024:"DITHER",3042:"BLEND",3088:"SCISSOR_BOX",3089:"SCISSOR_TEST",3106:"COLOR_CLEAR_VALUE",3107:"COLOR_WRITEMASK",3317:"UNPACK_ALIGNMENT",3333:"PACK_ALIGNMENT",3379:"MAX_TEXTURE_SIZE",3386:"MAX_VIEWPORT_DIMS",3408:"SUBPIXEL_BITS",3410:"RED_BITS",3411:"GREEN_BITS",3412:"BLUE_BITS",3413:"ALPHA_BITS",3414:"DEPTH_BITS",3415:"STENCIL_BITS",3553:"TEXTURE_2D",4352:"DONT_CARE",4353:"FASTEST",4354:"NICEST",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT",5386:"INVERT",5890:"TEXTURE",6401:"STENCIL_INDEX",6402:"DEPTH_COMPONENT",6406:"ALPHA",6407:"RGB",6408:"RGBA",6409:"LUMINANCE",6410:"LUMINANCE_ALPHA",7680:"KEEP",7681:"REPLACE",7682:"INCR",7683:"DECR",7936:"VENDOR",7937:"RENDERER",7938:"VERSION",9728:"NEAREST",9729:"LINEAR",9984:"NEAREST_MIPMAP_NEAREST",9985:"LINEAR_MIPMAP_NEAREST",9986:"NEAREST_MIPMAP_LINEAR",9987:"LINEAR_MIPMAP_LINEAR",10240:"TEXTURE_MAG_FILTER",10241:"TEXTURE_MIN_FILTER",10242:"TEXTURE_WRAP_S",10243:"TEXTURE_WRAP_T",10497:"REPEAT",10752:"POLYGON_OFFSET_UNITS",16384:"COLOR_BUFFER_BIT",32769:"CONSTANT_COLOR",32770:"ONE_MINUS_CONSTANT_COLOR",32771:"CONSTANT_ALPHA",32772:"ONE_MINUS_CONSTANT_ALPHA",32773:"BLEND_COLOR",32774:"FUNC_ADD",32777:"BLEND_EQUATION_RGB",32778:"FUNC_SUBTRACT",32779:"FUNC_REVERSE_SUBTRACT",32819:"UNSIGNED_SHORT_4_4_4_4",32820:"UNSIGNED_SHORT_5_5_5_1",32823:"POLYGON_OFFSET_FILL",32824:"POLYGON_OFFSET_FACTOR",32854:"RGBA4",32855:"RGB5_A1",32873:"TEXTURE_BINDING_2D",32926:"SAMPLE_ALPHA_TO_COVERAGE",32928:"SAMPLE_COVERAGE",32936:"SAMPLE_BUFFERS",32937:"SAMPLES",32938:"SAMPLE_COVERAGE_VALUE",32939:"SAMPLE_COVERAGE_INVERT",32968:"BLEND_DST_RGB",32969:"BLEND_SRC_RGB",32970:"BLEND_DST_ALPHA",32971:"BLEND_SRC_ALPHA",33071:"CLAMP_TO_EDGE",33170:"GENERATE_MIPMAP_HINT",33189:"DEPTH_COMPONENT16",33306:"DEPTH_STENCIL_ATTACHMENT",33635:"UNSIGNED_SHORT_5_6_5",33648:"MIRRORED_REPEAT",33901:"ALIASED_POINT_SIZE_RANGE",33902:"ALIASED_LINE_WIDTH_RANGE",33984:"TEXTURE0",33985:"TEXTURE1",33986:"TEXTURE2",33987:"TEXTURE3",33988:"TEXTURE4",33989:"TEXTURE5",33990:"TEXTURE6",33991:"TEXTURE7",33992:"TEXTURE8",33993:"TEXTURE9",33994:"TEXTURE10",33995:"TEXTURE11",33996:"TEXTURE12",33997:"TEXTURE13",33998:"TEXTURE14",33999:"TEXTURE15",34000:"TEXTURE16",34001:"TEXTURE17",34002:"TEXTURE18",34003:"TEXTURE19",34004:"TEXTURE20",34005:"TEXTURE21",34006:"TEXTURE22",34007:"TEXTURE23",34008:"TEXTURE24",34009:"TEXTURE25",34010:"TEXTURE26",34011:"TEXTURE27",34012:"TEXTURE28",34013:"TEXTURE29",34014:"TEXTURE30",34015:"TEXTURE31",34016:"ACTIVE_TEXTURE",34024:"MAX_RENDERBUFFER_SIZE",34041:"DEPTH_STENCIL",34055:"INCR_WRAP",34056:"DECR_WRAP",34067:"TEXTURE_CUBE_MAP",34068:"TEXTURE_BINDING_CUBE_MAP",34069:"TEXTURE_CUBE_MAP_POSITIVE_X",34070:"TEXTURE_CUBE_MAP_NEGATIVE_X",34071:"TEXTURE_CUBE_MAP_POSITIVE_Y",34072:"TEXTURE_CUBE_MAP_NEGATIVE_Y",34073:"TEXTURE_CUBE_MAP_POSITIVE_Z",34074:"TEXTURE_CUBE_MAP_NEGATIVE_Z",34076:"MAX_CUBE_MAP_TEXTURE_SIZE",34338:"VERTEX_ATTRIB_ARRAY_ENABLED",34339:"VERTEX_ATTRIB_ARRAY_SIZE",34340:"VERTEX_ATTRIB_ARRAY_STRIDE",34341:"VERTEX_ATTRIB_ARRAY_TYPE",34342:"CURRENT_VERTEX_ATTRIB",34373:"VERTEX_ATTRIB_ARRAY_POINTER",34466:"NUM_COMPRESSED_TEXTURE_FORMATS",34467:"COMPRESSED_TEXTURE_FORMATS",34660:"BUFFER_SIZE",34661:"BUFFER_USAGE",34816:"STENCIL_BACK_FUNC",34817:"STENCIL_BACK_FAIL",34818:"STENCIL_BACK_PASS_DEPTH_FAIL",34819:"STENCIL_BACK_PASS_DEPTH_PASS",34877:"BLEND_EQUATION_ALPHA",34921:"MAX_VERTEX_ATTRIBS",34922:"VERTEX_ATTRIB_ARRAY_NORMALIZED",34930:"MAX_TEXTURE_IMAGE_UNITS",34962:"ARRAY_BUFFER",34963:"ELEMENT_ARRAY_BUFFER",34964:"ARRAY_BUFFER_BINDING",34965:"ELEMENT_ARRAY_BUFFER_BINDING",34975:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",35040:"STREAM_DRAW",35044:"STATIC_DRAW",35048:"DYNAMIC_DRAW",35632:"FRAGMENT_SHADER",35633:"VERTEX_SHADER",35660:"MAX_VERTEX_TEXTURE_IMAGE_UNITS",35661:"MAX_COMBINED_TEXTURE_IMAGE_UNITS",35663:"SHADER_TYPE",35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",35712:"DELETE_STATUS",35713:"COMPILE_STATUS",35714:"LINK_STATUS",35715:"VALIDATE_STATUS",35716:"INFO_LOG_LENGTH",35717:"ATTACHED_SHADERS",35718:"ACTIVE_UNIFORMS",35719:"ACTIVE_UNIFORM_MAX_LENGTH",35720:"SHADER_SOURCE_LENGTH",35721:"ACTIVE_ATTRIBUTES",35722:"ACTIVE_ATTRIBUTE_MAX_LENGTH",35724:"SHADING_LANGUAGE_VERSION",35725:"CURRENT_PROGRAM",36003:"STENCIL_BACK_REF",36004:"STENCIL_BACK_VALUE_MASK",36005:"STENCIL_BACK_WRITEMASK",36006:"FRAMEBUFFER_BINDING",36007:"RENDERBUFFER_BINDING",36048:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36049:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36050:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36051:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36053:"FRAMEBUFFER_COMPLETE",36054:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36055:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36057:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36061:"FRAMEBUFFER_UNSUPPORTED",36064:"COLOR_ATTACHMENT0",36096:"DEPTH_ATTACHMENT",36128:"STENCIL_ATTACHMENT",36160:"FRAMEBUFFER",36161:"RENDERBUFFER",36162:"RENDERBUFFER_WIDTH",36163:"RENDERBUFFER_HEIGHT",36164:"RENDERBUFFER_INTERNAL_FORMAT",36168:"STENCIL_INDEX8",36176:"RENDERBUFFER_RED_SIZE",36177:"RENDERBUFFER_GREEN_SIZE",36178:"RENDERBUFFER_BLUE_SIZE",36179:"RENDERBUFFER_ALPHA_SIZE",36180:"RENDERBUFFER_DEPTH_SIZE",36181:"RENDERBUFFER_STENCIL_SIZE",36194:"RGB565",36336:"LOW_FLOAT",36337:"MEDIUM_FLOAT",36338:"HIGH_FLOAT",36339:"LOW_INT",36340:"MEDIUM_INT",36341:"HIGH_INT",36346:"SHADER_COMPILER",36347:"MAX_VERTEX_UNIFORM_VECTORS",36348:"MAX_VARYING_VECTORS",36349:"MAX_FRAGMENT_UNIFORM_VECTORS",37440:"UNPACK_FLIP_Y_WEBGL",37441:"UNPACK_PREMULTIPLY_ALPHA_WEBGL",37442:"CONTEXT_LOST_WEBGL",37443:"UNPACK_COLORSPACE_CONVERSION_WEBGL",37444:"BROWSER_DEFAULT_WEBGL"}},{}],158:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":157}],159:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.gl,n=a(r,f.vertex,f.fragment),o=a(r,f.fillVertex,f.fragment),s=i(r),l=i(r),u=i(r),c=i(r),d=i(r),p=new h(t,n,o,s,l,u,c,d);return p.update(e),t.addObject(p),p};var n=t("iota-array"),a=t("gl-shader"),i=t("gl-buffer"),o=t("ndarray"),s=t("surface-nets"),l=t("cdt2d"),u=t("clean-pslg"),c=t("binary-search-bounds"),f=t("./lib/shaders");function h(t,e,r,n,a,i,o,s){this.plot=t,this.shader=e,this.fillShader=r,this.positionBuffer=n,this.colorBuffer=a,this.idBuffer=i,this.fillPositionBuffer=o,this.fillColorBuffer=s,this.fillVerts=0,this.shape=[0,0],this.bounds=[1/0,1/0,-1/0,-1/0],this.numVertices=0,this.lineWidth=1}var d,p,g=h.prototype,v=[1,0,0,0,0,1,1,0,1,1,0,1];function m(t,e){var r=Math.floor(e);if(r<0)return t[0];if(r>=t.length-1)return t[t.length-1];var n=e-r;return(1-n)*t[r]+n*t[r+1]}g.draw=(d=[1,0,0,0,1,0,0,0,1],p=[0,0],function(){var t,e,r=this.plot,n=this.shader,a=this.fillShader,i=this.bounds,o=this.numVertices,s=this.fillVerts,l=r.gl,u=r.viewBox,c=r.dataBox,f=i[2]-i[0],h=i[3]-i[1],g=c[2]-c[0],v=c[3]-c[1];if(d[0]=2*f/g,d[4]=2*h/v,d[6]=2*(i[0]-c[0])/g-1,d[7]=2*(i[1]-c[1])/v-1,p[0]=u[2]-u[0],p[1]=u[3]-u[1],s>0&&(a.bind(),(t=a.uniforms).viewTransform=d,t.screenShape=p,e=n.attributes,this.fillPositionBuffer.bind(),e.position.pointer(),this.fillColorBuffer.bind(),e.color.pointer(l.UNSIGNED_BYTE,!0),l.drawArrays(l.TRIANGLES,0,s)),o>0){n.bind();var m=this.lineWidth*r.pixelRatio;(t=n.uniforms).viewTransform=d,t.screenShape=p,t.lineWidth=m,t.pointSize=1e3,e=n.attributes,this.positionBuffer.bind(),e.position.pointer(l.FLOAT,!1,16,0),e.tangent.pointer(l.FLOAT,!1,16,8),this.colorBuffer.bind(),e.color.pointer(l.UNSIGNED_BYTE,!0),l.drawArrays(l.TRIANGLES,0,o),t.lineWidth=0,t.pointSize=m,this.positionBuffer.bind(),e.position.pointer(l.FLOAT,!1,48,0),e.tangent.pointer(l.FLOAT,!1,48,8),this.colorBuffer.bind(),e.color.pointer(l.UNSIGNED_BYTE,!0,12,0),l.drawArrays(l.POINTS,0,o/3)}}),g.drawPick=function(t){return t},g.pick=function(t,e,r){return null},g.update=function(t){var e=(t=t||{}).shape||[0,0],r=t.x||n(e[0]),a=t.y||n(e[1]),i=t.z||new Float32Array(e[0]*e[1]),f=t.levels||[],h=t.levelColors||[],d=this.bounds,p=d[0]=r[0],g=d[1]=a[0],y=d[2]=r[r.length-1],b=d[3]=a[a.length-1];p===y&&(d[2]+=1,y+=1),g===b&&(d[3]+=1,b+=1);var x=1/(y-p),_=1/(b-g);this.lineWidth=t.lineWidth||1;var w=o(i,e),A=[],k=[],T=[],M=[],E=[[0,0],[e[0]-1,0],[0,e[1]-1],[e[0]-1,e[1]-1]];function C(t,e,r,n){var a=n-r;return Math.abs(a)<1e-6?e:Math.floor(e)+Math.max(.001,Math.min(.999,(t-r)/a))}for(var S=0;S0&&L===f[S-1])){for(var O=s(w,L),D=255*h[4*S]|0,R=255*h[4*S+1]|0,P=255*h[4*S+2]|0,z=255*h[4*S+3]|0,I=O.cells,F=O.positions,N=Array(F.length),B=0;B1)){var V,q=H[0],G=H[1],X=w.get(Math.floor(q),Math.floor(G)),W=w.get(Math.floor(q),Math.ceil(G)),Y=w.get(Math.ceil(q),Math.floor(G)),Z=w.get(Math.ceil(q),Math.ceil(G));0===Math.floor(H[0])&&X<=L!=Wc||r<0||r>c)throw new Error("gl-fbo: Parameters are too large for FBO");var f=1;if("color"in(n=n||{})){if((f=Math.max(0|n.color,0))<0)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(f>1){if(!u)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(f>t.getParameter(u.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+f+" draw buffers")}}var h=t.UNSIGNED_BYTE,d=t.getExtension("OES_texture_float");if(n.float&&f>0){if(!d)throw new Error("gl-fbo: Context does not support floating point textures");h=t.FLOAT}else n.preferFloat&&f>0&&d&&(h=t.FLOAT);var g=!0;"depth"in n&&(g=!!n.depth);var v=!1;"stencil"in n&&(v=!!n.stencil);return new p(t,e,r,h,f,g,v,u)};var a,i,o,s,l=null;function u(t){return[t.getParameter(t.FRAMEBUFFER_BINDING),t.getParameter(t.RENDERBUFFER_BINDING),t.getParameter(t.TEXTURE_BINDING_2D)]}function c(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function f(t){switch(t){case a:throw new Error("gl-fbo: Framebuffer unsupported");case i:throw new Error("gl-fbo: Framebuffer incomplete attachment");case o:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case s:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function h(t,e,r,a,i,o){if(!a)return null;var s=n(t,e,r,i,a);return s.magFilter=t.NEAREST,s.minFilter=t.NEAREST,s.mipSamples=1,s.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_2D,s.handle,0),s}function d(t,e,r,n,a){var i=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,i),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,a,t.RENDERBUFFER,i),i}function p(t,e,r,n,a,i,o,s){this.gl=t,this._shape=[0|e,0|r],this._destroyed=!1,this._ext=s,this.color=new Array(a);for(var p=0;p1&&s.drawBuffersWEBGL(l[o]);var y=r.getExtension("WEBGL_depth_texture");y?p?t.depth=h(r,a,i,y.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g&&(t.depth=h(r,a,i,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):g&&p?t._depth_rb=d(r,a,i,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g?t._depth_rb=d(r,a,i,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):p&&(t._depth_rb=d(r,a,i,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){for(t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null),m=0;ma||r<0||r>a)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var i=u(n),o=0;o>8*d&255;this.pickOffset=r,a.bind();var p=a.uniforms;p.viewTransform=t,p.pickOffset=e,p.shape=this.shape;var g=a.attributes;return this.positionBuffer.bind(),g.position.pointer(),this.weightBuffer.bind(),g.weight.pointer(s.UNSIGNED_BYTE,!1),this.idBuffer.bind(),g.pickId.pointer(s.UNSIGNED_BYTE,!1),s.drawArrays(s.TRIANGLES,0,o),r+this.shape[0]*this.shape[1]}}}(),f.pick=function(t,e,r){var n=this.pickOffset,a=this.shape[0]*this.shape[1];if(r=n+a)return null;var i=r-n,o=this.xData,s=this.yData;return{object:this,pointId:i,dataCoord:[o[i%this.shape[0]],s[i/this.shape[0]|0]]}},f.update=function(t){var e=(t=t||{}).shape||[0,0],r=t.x||a(e[0]),o=t.y||a(e[1]),s=t.z||new Float32Array(e[0]*e[1]);this.xData=r,this.yData=o;var l=t.colorLevels||[0],u=t.colorValues||[0,0,0,1],c=l.length,f=this.bounds,d=f[0]=r[0],p=f[1]=o[0],g=1/((f[2]=r[r.length-1])-d),v=1/((f[3]=o[o.length-1])-p),m=e[0],y=e[1];this.shape=[m,y];var b=(m-1)*(y-1)*(h.length>>>1);this.numVertices=b;for(var x=i.mallocUint8(4*b),_=i.mallocFloat32(2*b),w=i.mallocUint8(2*b),A=i.mallocUint32(b),k=0,T=0;Ta[k]&&(r.uniforms.dataAxis=u,r.uniforms.screenOffset=c,r.uniforms.color=v[t],r.uniforms.angle=m[t],i.drawArrays(i.TRIANGLES,a[k],a[T]-a[k]))),y[t]&&A&&(c[1^t]-=M*d*b[t],r.uniforms.dataAxis=f,r.uniforms.screenOffset=c,r.uniforms.color=x[t],r.uniforms.angle=_[t],i.drawArrays(i.TRIANGLES,w,A)),c[1^t]=M*s[2+(1^t)]-1,p[t+2]&&(c[1^t]+=M*d*g[t+2],ka[k]&&(r.uniforms.dataAxis=u,r.uniforms.screenOffset=c,r.uniforms.color=v[t+2],r.uniforms.angle=m[t+2],i.drawArrays(i.TRIANGLES,a[k],a[T]-a[k]))),y[t+2]&&A&&(c[1^t]+=M*d*b[t+2],r.uniforms.dataAxis=f,r.uniforms.screenOffset=c,r.uniforms.color=x[t+2],r.uniforms.angle=_[t+2],i.drawArrays(i.TRIANGLES,w,A))}),g.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,a=r.gl,i=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,u=r.pixelRatio;if(this.titleCount){for(var c=0;c<2;++c)e[c]=2*(o[c]*u-i[c])/(i[2+c]-i[c])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,a.drawArrays(a.TRIANGLES,this.titleOffset,this.titleCount)}}}(),g.bind=(h=[0,0],d=[0,0],p=[0,0],function(){var t=this.plot,e=this.shader,r=t._tickBounds,n=t.dataBox,a=t.screenBox,i=t.viewBox;e.bind();for(var o=0;o<2;++o){var s=r[o],l=r[o+2]-s,u=.5*(n[o+2]+n[o]),c=n[o+2]-n[o],f=i[o],g=i[o+2]-f,v=a[o],m=a[o+2]-v;d[o]=2*l/c*g/m,h[o]=2*(s-u)/c*g/m}p[1]=2*t.pixelRatio/(a[3]-a[1]),p[0]=p[1]*(a[3]-a[1])/(a[2]-a[0]),e.uniforms.dataScale=d,e.uniforms.dataShift=h,e.uniforms.textScale=p,this.vbo.bind(),e.attributes.textCoordinate.pointer()}),g.update=function(t){var e,r,n,a,o,s=[],l=t.ticks,u=t.bounds;for(o=0;o<2;++o){var c=[Math.floor(s.length/3)],f=[-1/0],h=l[o];for(e=0;e=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(p=0;p=0;--t)this.objects[t].dispose();this.objects.length=0;for(t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},u.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},u.removeObject=function(t){for(var e=this.objects,r=0;r 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]),r.pickVertex=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]),r.pickFragment=n(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"])},{glslify:199}],176:[function(t,e,r){"use strict";var n=t("gl-shader"),a=t("gl-buffer"),i=t("typedarray-pool"),o=t("./lib/shader");function s(t,e,r,n,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.shader=n,this.pickShader=a,this.sizeMin=.5,this.sizeMinCap=2,this.sizeMax=20,this.areaRatio=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.blend=!1,this.pickOffset=0,this.points=null}e.exports=function(t,e){var r=t.gl,i=a(r),l=a(r),u=n(r,o.pointVertex,o.pointFragment),c=n(r,o.pickVertex,o.pickFragment),f=new s(t,i,l,u,c);return f.update(e),t.addObject(f),f};var l,u,c=s.prototype;c.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.plot.removeObject(this)},c.update=function(t){var e;function r(e,r){return e in t?t[e]:r}t=t||{},this.sizeMin=r("sizeMin",.5),this.sizeMax=r("sizeMax",20),this.color=r("color",[1,0,0,1]).slice(),this.areaRatio=r("areaRatio",1),this.borderColor=r("borderColor",[0,0,0,1]).slice(),this.blend=r("blend",!1);var n=t.positions.length>>>1,a=t.positions instanceof Float32Array,o=t.idToIndex instanceof Int32Array&&t.idToIndex.length>=n,s=t.positions,l=a?s:i.mallocFloat32(s.length),u=o?t.idToIndex:i.mallocInt32(n);if(a||l.set(s),!o)for(l.set(s),e=0;e>>1;for(r=0;r=e[0]&&i<=e[2]&&o>=e[1]&&o<=e[3]&&n++}return n}(this.points,a),c=this.plot.pickPixelRatio*Math.max(Math.min(this.sizeMinCap,this.sizeMin),Math.min(this.sizeMax,this.sizeMax/Math.pow(s,.33333)));l[0]=2/i,l[4]=2/o,l[6]=-2*a[0]/i-1,l[7]=-2*a[1]/o-1,this.offsetBuffer.bind(),r.bind(),r.attributes.position.pointer(),r.uniforms.matrix=l,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointCloud=c<5,r.uniforms.pointSize=c,r.uniforms.centerFraction=Math.min(1,Math.max(0,Math.sqrt(1-this.areaRatio))),e&&(u[0]=255&t,u[1]=t>>8&255,u[2]=t>>16&255,u[3]=t>>24&255,this.pickBuffer.bind(),r.attributes.pickId.pointer(n.UNSIGNED_BYTE),r.uniforms.pickOffset=u,this.pickOffset=t);var f=n.getParameter(n.BLEND),h=n.getParameter(n.DITHER);return f&&!this.blend&&n.disable(n.BLEND),h&&n.disable(n.DITHER),n.drawArrays(n.POINTS,0,this.pointCount),f&&!this.blend&&n.enable(n.BLEND),h&&n.enable(n.DITHER),t+this.pointCount}),c.draw=c.unifiedDraw,c.drawPick=c.unifiedDraw,c.pick=function(t,e,r){var n=this.pickOffset,a=this.pointCount;if(r=n+a)return null;var i=r-n,o=this.points;return{object:this,pointId:i,dataCoord:[o[2*i],o[2*i+1]]}}},{"./lib/shader":175,"gl-buffer":156,"gl-shader":180,"typedarray-pool":290}],177:[function(t,e,r){"use strict";var n=t("glslify");r.boxVertex=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n"]),r.boxFragment=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"])},{glslify:199}],178:[function(t,e,r){"use strict";var n=t("gl-shader"),a=t("gl-buffer"),i=t("./lib/shaders");function o(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-1/0,-1/0],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}e.exports=function(t,e){var r=t.gl,s=a(r,[0,0,0,1,1,0,1,1]),l=n(r,i.boxVertex,i.boxFragment),u=new o(t,s,l);return u.update(e),t.addOverlay(u),u};var s=o.prototype;s.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),a=(this.outerFill,this.outerColor),i=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,u=t.viewBox,c=t.pixelRatio,f=(e[0]-l[0])*(u[2]-u[0])/(l[2]-l[0])+u[0],h=(e[1]-l[1])*(u[3]-u[1])/(l[3]-l[1])+u[1],d=(e[2]-l[0])*(u[2]-u[0])/(l[2]-l[0])+u[0],p=(e[3]-l[1])*(u[3]-u[1])/(l[3]-l[1])+u[1];if(f=Math.max(f,u[0]),h=Math.max(h,u[1]),d=Math.min(d,u[2]),p=Math.min(p,u[3]),!(d0){var m=r*c;o.drawBox(f-m,h-m,d+m,h+m,i),o.drawBox(f-m,p-m,d+m,p+m,i),o.drawBox(f-m,h-m,f+m,p+m,i),o.drawBox(d-m,h-m,d+m,p+m,i)}}}},s.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},s.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":177,"gl-buffer":156,"gl-shader":180}],179:[function(t,e,r){"use strict";e.exports=function(t,e){var r=n(t,e),i=a.mallocUint8(e[0]*e[1]*4);return new u(t,r,i)};var n=t("gl-fbo"),a=t("typedarray-pool"),i=t("ndarray"),o=t("bit-twiddle").nextPow2,s=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(_inline_55_arg0_<255||_inline_55_arg1_<255||_inline_55_arg2_<255||_inline_55_arg3_<255){var _inline_55_l=_inline_55_arg4_-_inline_55_arg6_[0],_inline_55_a=_inline_55_arg5_-_inline_55_arg6_[1],_inline_55_f=_inline_55_l*_inline_55_l+_inline_55_a*_inline_55_a;_inline_55_fthis.buffer.length){a.free(this.buffer);for(var n=this.buffer=a.mallocUint8(o(r*e*4)),i=0;ir)for(t=r;te)for(t=e;t=0){for(var A=0|w.type.charAt(w.type.length-1),k=new Array(A),T=0;T=0;)M+=1;_[y]=M}var E=new Array(r.length);function C(){h.program=o.program(d,h._vref,h._fref,x,_);for(var t=0;t=0){var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new n("","Invalid data type for attribute "+f+": "+h);o(t,e,d[0],a,p,i,f)}else{if(!(h.indexOf("mat")>=0))throw new n("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new n("","Invalid data type for attribute "+f+": "+h);s(t,e,d,a,p,i,f)}}}return i};var n=t("./GLError");function a(t,e,r,n,a,i){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=a,this._constFunc=i}var i=a.prototype;function o(t,e,r,n,i,o,s){for(var l=["gl","v"],u=[],c=0;c4)throw new a("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new a("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(i<2||i>4)throw new a("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new a("","Unrecognized data type for vector "+name+": "+r)}}}function u(e){for(var n=["return function updateProperty(obj){"],a=function t(e,r){if("object"!=typeof r)return[[e,r]];var n=[];for(var a in r){var i=r[a],o=e;parseInt(a)+""===a?o+="["+a+"]":o+="."+a,"object"==typeof i?n.push.apply(n,t(o,i)):n.push([o,i])}return n}("",e),i=0;i4)throw new a("","Invalid data type");return"b"===t.charAt(0)?o(r,!1):o(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(r<2||r>4)throw new a("","Invalid uniform dimension type for matrix "+name+": "+t);return o(r*r,0)}throw new a("","Unknown uniform data type for "+name+": "+t)}}(r[c].type);var d}function f(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var u=1;u1)for(var l=0;l halfCharStep + halfCharWidth ||\n\t\t\t\t\tfloor(uv.x) < halfCharStep - halfCharWidth) return;\n\n\t\t\t\tuv += charId * charStep;\n\t\t\t\tuv = uv / atlasSize;\n\n\t\t\t\tvec4 color = fontColor;\n\t\t\t\tvec4 mask = texture2D(atlas, uv);\n\n\t\t\t\tfloat maskY = lightness(mask);\n\t\t\t\t// float colorY = lightness(color);\n\t\t\t\tcolor.a *= maskY;\n\t\t\t\tcolor.a *= opacity;\n\n\t\t\t\t// color.a += .1;\n\n\t\t\t\t// antialiasing, see yiq color space y-channel formula\n\t\t\t\t// color.rgb += (1. - color.rgb) * (1. - mask.rgb);\n\n\t\t\t\tgl_FragColor = color;\n\t\t\t}"});return{regl:t,draw:e,atlas:{}}},A.prototype.update=function(t){var e=this;if("string"==typeof t)t={text:t};else if(!t)return;null!=(t=a(t,{position:"position positions coord coords coordinates",font:"font fontFace fontface typeface cssFont css-font family fontFamily",fontSize:"fontSize fontsize size font-size",text:"text texts chars characters value values symbols",align:"align alignment textAlign textbaseline",baseline:"baseline textBaseline textbaseline",direction:"dir direction textDirection",color:"color colour fill fill-color fillColor textColor textcolor",kerning:"kerning kern",range:"range dataBox",viewport:"vp viewport viewBox viewbox viewPort",opacity:"opacity alpha transparency visible visibility opaque",offset:"offset positionOffset padding shift indent indentation"},!0)).opacity&&(Array.isArray(t.opacity)?this.opacity=t.opacity.map(function(t){return parseFloat(t)}):this.opacity=parseFloat(t.opacity)),null!=t.viewport&&(this.viewport=f(t.viewport),A.normalViewport&&(this.viewport.y=this.canvas.height-this.viewport.y-this.viewport.height),this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null==this.viewport&&(this.viewport={x:0,y:0,width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight},this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null!=t.kerning&&(this.kerning=t.kerning),null!=t.offset&&("number"==typeof t.offset&&(t.offset=[t.offset,0]),this.positionOffset=y(t.offset)),t.direction&&(this.direction=t.direction),t.range&&(this.range=t.range,this.scale=[1/(t.range[2]-t.range[0]),1/(t.range[3]-t.range[1])],this.translate=[-t.range[0],-t.range[1]]),t.scale&&(this.scale=t.scale),t.translate&&(this.translate=t.translate),this.scale||(this.scale=[1/this.viewport.width,1/this.viewport.height]),this.translate||(this.translate=[0,0]),this.font.length||t.font||(t.font=A.baseFontSize+"px sans-serif");var r,i=!1,o=!1;if(t.font&&(Array.isArray(t.font)?t.font:[t.font]).forEach(function(t,r){if("string"==typeof t)try{t=n.parse(t)}catch(e){t=n.parse(A.baseFontSize+"px "+t)}else t=n.parse(n.stringify(t));var a=n.stringify({size:A.baseFontSize,family:t.family,stretch:_?t.stretch:void 0,variant:t.variant,weight:t.weight,style:t.style}),s=d(t.size),l=Math.round(s[0]*p(s[1]));if(l!==e.fontSize[r]&&(o=!0,e.fontSize[r]=l),!(e.font[r]&&a==e.font[r].baseString||(i=!0,e.font[r]=A.fonts[a],e.font[r]))){var u=t.family.join(", "),c=[t.style];t.style!=t.variant&&c.push(t.variant),t.variant!=t.weight&&c.push(t.weight),_&&t.weight!=t.stretch&&c.push(t.stretch),e.font[r]={baseString:a,family:u,weight:t.weight,stretch:t.stretch,style:t.style,variant:t.variant,width:{},kerning:{},metrics:m(u,{origin:"top",fontSize:A.baseFontSize,fontStyle:c.join(" ")})},A.fonts[a]=e.font[r]}}),(i||o)&&this.font.forEach(function(r,a){var i=n.stringify({size:e.fontSize[a],family:r.family,stretch:_?r.stretch:void 0,variant:r.variant,weight:r.weight,style:r.style});if(e.fontAtlas[a]=e.shader.atlas[i],!e.fontAtlas[a]){var o=r.metrics;e.shader.atlas[i]=e.fontAtlas[a]={fontString:i,step:2*Math.ceil(e.fontSize[a]*o.bottom*.5),em:e.fontSize[a],cols:0,rows:0,height:0,width:0,chars:[],ids:{},texture:e.regl.texture()}}null==t.text&&(t.text=e.text)}),"string"==typeof t.text&&t.position&&t.position.length>2){for(var s=Array(.5*t.position.length),h=0;h2){for(var w=!t.position[0].length,k=c.mallocFloat(2*this.count),T=0,M=0;T1?e.align[r]:e.align[0]:e.align;if("number"==typeof n)return n;switch(n){case"right":case"end":return-t;case"center":case"centre":case"middle":return.5*-t}return 0})),null==this.baseline&&null==t.baseline&&(t.baseline=0),null!=t.baseline&&(this.baseline=t.baseline,Array.isArray(this.baseline)||(this.baseline=[this.baseline]),this.baselineOffset=this.baseline.map(function(t,r){var n=(e.font[r]||e.font[0]).metrics,a=0;return a+=.5*n.bottom,a+="number"==typeof t?t-n.baseline:-n[t],A.normalViewport||(a*=-1),a})),null!=t.color)if(t.color||(t.color="transparent"),"string"!=typeof t.color&&isNaN(t.color)){var q;if("number"==typeof t.color[0]&&t.color.length>this.counts.length){var G=t.color.length;q=c.mallocUint8(G);for(var X=(t.color.subarray||t.color.slice).bind(t.color),W=0;W4||this.baselineOffset.length>1||this.align&&this.align.length>1||this.fontAtlas.length>1||this.positionOffset.length>2){var J=Math.max(.5*this.position.length||0,.25*this.color.length||0,this.baselineOffset.length||0,this.alignOffset.length||0,this.font.length||0,this.opacity.length||0,.5*this.positionOffset.length||0);this.batch=Array(J);for(var Q=0;Q1?e.counts[Q]:e.counts[0],offset:e.textOffsets.length>1?e.textOffsets[Q]:e.textOffsets[0],color:e.color?e.color.length<=4?e.color:e.color.subarray(4*Q,4*Q+4):[0,0,0,255],opacity:Array.isArray(e.opacity)?e.opacity[Q]:e.opacity,baseline:null!=e.baselineOffset[Q]?e.baselineOffset[Q]:e.baselineOffset[0],align:e.align?null!=e.alignOffset[Q]?e.alignOffset[Q]:e.alignOffset[0]:0,atlas:e.fontAtlas[Q]||e.fontAtlas[0],positionOffset:e.positionOffset.length>2?e.positionOffset.subarray(2*Q,2*Q+2):e.positionOffset}}else this.count?this.batch=[{count:this.count,offset:0,color:this.color||[0,0,0,255],opacity:Array.isArray(this.opacity)?this.opacity[0]:this.opacity,baseline:this.baselineOffset[0],align:this.alignOffset?this.alignOffset[0]:0,atlas:this.fontAtlas[0],positionOffset:this.positionOffset}]:this.batch=[]},A.prototype.destroy=function(){},A.prototype.kerning=!0,A.prototype.position={constant:new Float32Array(2)},A.prototype.translate=null,A.prototype.scale=null,A.prototype.font=null,A.prototype.text="",A.prototype.positionOffset=[0,0],A.prototype.opacity=1,A.prototype.color=new Uint8Array([0,0,0,255]),A.prototype.alignOffset=[0,0],A.normalViewport=!1,A.maxAtlasSize=1024,A.atlasCanvas=document.createElement("canvas"),A.atlasContext=A.atlasCanvas.getContext("2d",{alpha:!1}),A.baseFontSize=64,A.fonts={},e.exports=A},{"bit-twiddle":39,"color-normalize":63,"css-font":73,"detect-kerning":87,"es6-weak-map":145,"flatten-vertex-data":150,"font-atlas":151,"font-measure":152,"gl-util/context":190,"is-plain-obj":210,"object-assign":223,"parse-rect":226,"parse-unit":228,"pick-by-alias":232,regl:259,"to-px":286,"typedarray-pool":290}],189:[function(t,e,r){"use strict";var n=t("ndarray"),a=t("ndarray-ops"),i=t("typedarray-pool");e.exports=function(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");o||function(t){o=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],s=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],l=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}(t);if("number"==typeof arguments[1])return v(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return v(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1],r=u(e)?e:e.raw;if(r)return function(t,e,r,n,a,i){var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,a,a,i,e),new h(t,o,r,n,a,i)}(t,r,0|e.width,0|e.height,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return function(t,e){var r=e.dtype,o=e.shape.slice(),s=t.getParameter(t.MAX_TEXTURE_SIZE);if(o[0]<0||o[0]>s||o[1]<0||o[1]>s)throw new Error("gl-texture2d: Invalid texture size");var l=p(o,e.stride.slice()),u=0;"float32"===r?u=t.FLOAT:"float64"===r?(u=t.FLOAT,l=!1,r="float32"):"uint8"===r?u=t.UNSIGNED_BYTE:(u=t.UNSIGNED_BYTE,l=!1,r="uint8");var f,d,v=0;if(2===o.length)v=t.LUMINANCE,o=[o[0],o[1],1],e=n(e.data,o,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==o.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===o[2])v=t.ALPHA;else if(2===o[2])v=t.LUMINANCE_ALPHA;else if(3===o[2])v=t.RGB;else{if(4!==o[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}}u!==t.FLOAT||t.getExtension("OES_texture_float")||(u=t.UNSIGNED_BYTE,l=!1);var m=e.size;if(l)f=0===e.offset&&e.data.length===m?e.data:e.data.subarray(e.offset,e.offset+m);else{var y=[o[2],o[2]*o[0],1];d=i.malloc(m,r);var b=n(d,o,y,0);"float32"!==r&&"float64"!==r||u!==t.UNSIGNED_BYTE?a.assign(b,e):c(b,e),f=d.subarray(0,m)}var x=g(t);t.texImage2D(t.TEXTURE_2D,0,v,o[0],o[1],0,v,u,f),l||i.free(d);return new h(t,x,o[0],o[1],v,u)}(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")};var o=null,s=null,l=null;function u(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement||"undefined"!=typeof ImageData&&t instanceof ImageData}var c=function(t,e){a.muls(t,e,255)};function f(t,e,r){var n=t.gl,a=n.getParameter(n.MAX_TEXTURE_SIZE);if(e<0||e>a||r<0||r>a)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function h(t,e,r,n,a,i){this.gl=t,this.handle=e,this.format=a,this.type=i,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}var d=h.prototype;function p(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function g(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function v(t,e,r,n,a){var i=t.getParameter(t.MAX_TEXTURE_SIZE);if(e<0||e>i||r<0||r>i)throw new Error("gl-texture2d: Invalid texture shape");if(a===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,a,null),new h(t,o,e,r,n,a)}Object.defineProperties(d,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=this.gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;e<2;++e)if(l.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return f(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return f(this,t|=0,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t|=0,f(this,this._shape[0],t),t}}}),d.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},d.dispose=function(){this.gl.deleteTexture(this.handle)},d.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},d.setPixels=function(t,e,r,o){var s=this.gl;this.bind(),Array.isArray(e)?(o=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),o=o||0;var l=u(t)?t:t.raw;if(l){this._mipLevels.indexOf(o)<0?(s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,this.type,l),this._mipLevels.push(o)):s.texSubImage2D(s.TEXTURE_2D,o,e,r,this.format,this.type,l)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>o||r+t.shape[0]>this._shape[0]>>>o||e<0||r<0)throw new Error("gl-texture2d: Texture dimensions are out of bounds");!function(t,e,r,o,s,l,u,f){var h=f.dtype,d=f.shape.slice();if(d.length<2||d.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var g=0,v=0,m=p(d,f.stride.slice());"float32"===h?g=t.FLOAT:"float64"===h?(g=t.FLOAT,m=!1,h="float32"):"uint8"===h?g=t.UNSIGNED_BYTE:(g=t.UNSIGNED_BYTE,m=!1,h="uint8");if(2===d.length)v=t.LUMINANCE,d=[d[0],d[1],1],f=n(f.data,d,[f.stride[0],f.stride[1],1],f.offset);else{if(3!==d.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===d[2])v=t.ALPHA;else if(2===d[2])v=t.LUMINANCE_ALPHA;else if(3===d[2])v=t.RGB;else{if(4!==d[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}d[2]}v!==t.LUMINANCE&&v!==t.ALPHA||s!==t.LUMINANCE&&s!==t.ALPHA||(v=s);if(v!==s)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=f.size,b=u.indexOf(o)<0;b&&u.push(o);if(g===l&&m)0===f.offset&&f.data.length===y?b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,f.data):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,f.data):b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,f.data.subarray(f.offset,f.offset+y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,f.data.subarray(f.offset,f.offset+y));else{var x;x=l===t.FLOAT?i.mallocFloat32(y):i.mallocUint8(y);var _=n(x,d,[d[2],d[2]*d[0],1]);g===t.FLOAT&&l===t.UNSIGNED_BYTE?c(_,f):a.assign(_,f),b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,x.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,x.subarray(0,y)),l===t.FLOAT?i.freeFloat32(x):i.freeUint8(x)}}(s,e,r,o,this.format,this.type,this._mipLevels,t)}}},{ndarray:220,"ndarray-ops":219,"typedarray-pool":290}],190:[function(t,e,r){"use strict";var n=t("pick-by-alias");function a(t){if(t.container)if(t.container==document.body)document.body.style.width||(t.canvas.width=t.width||t.pixelRatio*window.innerWidth),document.body.style.height||(t.canvas.height=t.height||t.pixelRatio*window.innerHeight);else{var e=t.container.getBoundingClientRect();t.canvas.width=t.width||e.right-e.left,t.canvas.height=t.height||e.bottom-e.top}}function i(t){return"function"==typeof t.getContext&&"width"in t&&"height"in t}e.exports=function(t){var e;if(t?"string"==typeof t&&(t={container:t}):t={},i(t)?t={container:t}:t="string"==typeof(e=t).nodeName&&"function"==typeof e.appendChild&&"function"==typeof e.getBoundingClientRect?{container:t}:function(t){return"function"==typeof t.drawArrays||"function"==typeof t.drawElements}(t)?{gl:t}:n(t,{container:"container target element el canvas holder parent parentNode wrapper use ref root node",gl:"gl context webgl glContext",attrs:"attributes attrs contextAttributes",pixelRatio:"pixelRatio pxRatio px ratio pxratio pixelratio"},!0),t.pixelRatio||(t.pixelRatio=window.pixelRatio||1),t.gl)return t.gl;if(t.canvas&&(t.container=t.canvas.parentNode),t.container){if("string"==typeof t.container){var r=document.querySelector(t.container);if(!r)throw Error("Element "+t.container+" is not found");t.container=r}i(t.container)?(t.canvas=t.container,t.container=t.canvas.parentNode):t.canvas||(t.canvas=document.createElement("canvas"),t.container.appendChild(t.canvas),a(t))}else t.canvas||(t.container=document.body||document.documentElement,t.canvas=document.createElement("canvas"),t.canvas.style.position="absolute",t.canvas.style.top=0,t.canvas.style.left=0,t.container.appendChild(t.canvas),a(t));if(!t.gl)try{t.gl=t.canvas.getContext("webgl",t.attrs)}catch(e){try{t.gl=t.canvas.getContext("experimental-webgl",t.attrs)}catch(e){t.gl=t.canvas.getContext("webgl-experimental",t.attrs)}}return t.gl}},{"pick-by-alias":232}],191:[function(t,e,r){var n=t("glsl-tokenizer"),a=t("atob-lite");e.exports=function(t){for(var e=Array.isArray(t)?t:n(t),r=0;r0)continue;r=t.slice(0,1).join("")}return F(r),O+=r.length,(E=E.slice(r.length)).length}}function q(){return/[^a-fA-F0-9]/.test(e)?(F(E.join("")),M=l,k):(E.push(e),r=e,k+1)}function G(){return"."===e?(E.push(e),M=g,r=e,k+1):/[eE]/.test(e)?(E.push(e),M=g,r=e,k+1):"x"===e&&1===E.length&&"0"===E[0]?(M=_,E.push(e),r=e,k+1):/[^\d]/.test(e)?(F(E.join("")),M=l,k):(E.push(e),r=e,k+1)}function X(){return"f"===e&&(E.push(e),r=e,k+=1),/[eE]/.test(e)?(E.push(e),r=e,k+1):"-"===e&&/[eE]/.test(r)?(E.push(e),r=e,k+1):/[^\d]/.test(e)?(F(E.join("")),M=l,k):(E.push(e),r=e,k+1)}function W(){if(/[^\d\w_]/.test(e)){var t=E.join("");return M=I.indexOf(t)>-1?y:z.indexOf(t)>-1?m:v,F(E.join("")),M=l,k}return E.push(e),r=e,k+1}};var n=t("./lib/literals"),a=t("./lib/operators"),i=t("./lib/builtins"),o=t("./lib/literals-300es"),s=t("./lib/builtins-300es"),l=999,u=9999,c=0,f=1,h=2,d=3,p=4,g=5,v=6,m=7,y=8,b=9,x=10,_=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":194,"./lib/builtins-300es":193,"./lib/literals":196,"./lib/literals-300es":195,"./lib/operators":197}],193:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":194}],194:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],195:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":196}],196:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],197:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],198:[function(t,e,r){var n=t("./index");e.exports=function(t,e){var r=n(e),a=[];return a=(a=a.concat(r(t))).concat(r(null))}},{"./index":192}],199:[function(t,e,r){e.exports=function(t){"string"==typeof t&&(t=[t]);for(var e=[].slice.call(arguments,1),r=[],n=0;n>1,c=-7,f=r?a-1:0,h=r?-1:1,d=t[e+f];for(f+=h,i=d&(1<<-c)-1,d>>=-c,c+=s;c>0;i=256*i+t[e+f],f+=h,c-=8);for(o=i&(1<<-c)-1,i>>=-c,c+=n;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===i)i=1-u;else{if(i===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),i-=u}return(d?-1:1)*o*Math.pow(2,i-n)},r.write=function(t,e,r,n,a,i){var o,s,l,u=8*i-a-1,c=(1<>1,h=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*l-1)*Math.pow(2,a),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,a),o=0));a>=8;t[r+d]=255&s,d+=p,s/=256,a-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*g}},{}],203:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),a=0,i=1;function o(t,e,r,n,a){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=a,this.count=(e?e.count:0)+(r?r.count:0)+n.length}e.exports=function(t){if(!t||0===t.length)return new b(null);return new b(y(t))};var s=o.prototype;function l(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function u(t,e){var r=y(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function c(t,e){var r=t.intervals([]);r.push(e),u(t,r)}function f(t,e){var r=t.intervals([]),n=r.indexOf(e);return n<0?a:(r.splice(n,1),u(t,r),i)}function h(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var a=r(t[n]);if(a)return a}}function p(t,e){for(var r=0;r>1],a=[],i=[],s=[];for(r=0;r3*(e+1)?c(this,t):this.left.insert(t):this.left=y([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?c(this,t):this.right.insert(t):this.right=y([t]);else{var r=n.ge(this.leftPoints,t,v),a=n.ge(this.rightPoints,t,m);this.leftPoints.splice(r,0,t),this.rightPoints.splice(a,0,t)}},s.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1)?f(this,t):2===(u=this.left.remove(t))?(this.left=null,this.count-=1,i):(u===i&&(this.count-=1),u):a;if(t[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(e-1)?f(this,t):2===(u=this.right.remove(t))?(this.right=null,this.count-=1,i):(u===i&&(this.count-=1),u):a;if(1===this.count)return this.leftPoints[0]===t?2:a;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var r=this,o=this.left;o.right;)r=o,o=o.right;if(r===this)o.right=this.right;else{var s=this.left,u=this.right;r.count-=o.count,r.right=o.left,o.left=s,o.right=u}l(this,o),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?l(this,this.left):l(this,this.right);return i}for(s=n.ge(this.leftPoints,t,v);sthis.mid){var r;if(this.right)if(r=this.right.queryPoint(t,e))return r;return d(this.rightPoints,t,e)}return p(this.leftPoints,e)},s.queryInterval=function(t,e,r){var n;if(tthis.mid&&this.right&&(n=this.right.queryInterval(t,e,r)))return n;return ethis.mid?d(this.rightPoints,t,r):p(this.leftPoints,r)};var x=b.prototype;x.insert=function(t){this.root?this.root.insert(t):this.root=new o(t[0],null,null,[t],[t])},x.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),e!==a}return!1},x.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},x.queryInterval=function(t,e,r){if(t<=e&&this.root)return this.root.queryInterval(t,e,r)},Object.defineProperty(x,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(x,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":38}],204:[function(t,e,r){"use strict";e.exports=function(t,e){e=e||new Array(t.length);for(var r=0;r13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],212:[function(t,e,r){"use strict";e.exports=function(t){return"string"==typeof t&&(t=t.trim(),!!(/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(t)&&/[\dz]$/i.test(t)&&t.length>4))}},{}],213:[function(t,e,r){"use strict";e.exports=Math.log2||function(t){return Math.log(t)*Math.LOG2E}},{}],214:[function(t,e,r){"use strict";e.exports=function(t,e){e||(e=t,t=window);var r=0,a=0,i=0,o={shift:!1,alt:!1,control:!1,meta:!1},s=!1;function l(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==o.alt,o.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==o.shift,o.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==o.control,o.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==o.meta,o.meta=!!t.metaKey),e}function u(t,s){var u=n.x(s),c=n.y(s);"buttons"in s&&(t=0|s.buttons),(t!==r||u!==a||c!==i||l(s))&&(r=0|t,a=u||0,i=c||0,e&&e(r,a,i,o))}function c(t){u(0,t)}function f(){(r||a||i||o.shift||o.alt||o.meta||o.control)&&(a=i=0,r=0,o.shift=o.alt=o.control=o.meta=!1,e&&e(0,0,0,o))}function h(t){l(t)&&e&&e(r,a,i,o)}function d(t){0===n.buttons(t)?u(0,t):u(r,t)}function p(t){u(r|n.buttons(t),t)}function g(t){u(r&~n.buttons(t),t)}function v(){s||(s=!0,t.addEventListener("mousemove",d),t.addEventListener("mousedown",p),t.addEventListener("mouseup",g),t.addEventListener("mouseleave",c),t.addEventListener("mouseenter",c),t.addEventListener("mouseout",c),t.addEventListener("mouseover",c),t.addEventListener("blur",f),t.addEventListener("keyup",h),t.addEventListener("keydown",h),t.addEventListener("keypress",h),t!==window&&(window.addEventListener("blur",f),window.addEventListener("keyup",h),window.addEventListener("keydown",h),window.addEventListener("keypress",h)))}v();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return s},set:function(e){e?v():s&&(s=!1,t.removeEventListener("mousemove",d),t.removeEventListener("mousedown",p),t.removeEventListener("mouseup",g),t.removeEventListener("mouseleave",c),t.removeEventListener("mouseenter",c),t.removeEventListener("mouseout",c),t.removeEventListener("mouseover",c),t.removeEventListener("blur",f),t.removeEventListener("keyup",h),t.removeEventListener("keydown",h),t.removeEventListener("keypress",h),t!==window&&(window.removeEventListener("blur",f),window.removeEventListener("keyup",h),window.removeEventListener("keydown",h),window.removeEventListener("keypress",h)))},enumerable:!0},buttons:{get:function(){return r},enumerable:!0},x:{get:function(){return a},enumerable:!0},y:{get:function(){return i},enumerable:!0},mods:{get:function(){return o},enumerable:!0}}),m};var n=t("mouse-event")},{"mouse-event":216}],215:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(s=e,s===window||s===document||s===document.body?n:s.getBoundingClientRect());var s;return r[0]=a-o.left,r[1]=i-o.top,r}},{}],216:[function(t,e,r){"use strict";function n(t){return t.target||t.srcElement||window}r.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){if(2===(e=t.which))return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1< 0");"function"!=typeof t.vertex&&e("Must specify vertex creation function");"function"!=typeof t.cell&&e("Must specify cell creation function");"function"!=typeof t.phase&&e("Must specify phase function");for(var C=t.getters||[],S=new Array(M),L=0;L=0?S[L]=!0:S[L]=!1;return function(t,e,r,M,E,C){var S=C.length,L=E.length;if(L<2)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var O="extractContour"+E.join("_"),D=[],R=[],P=[],z=0;z0&&B.push(l(z,E[I-1])+"*"+s(E[I-1])),R.push(p(z,E[I])+"=("+B.join("-")+")|0")}for(var z=0;z=0;--z)j.push(s(E[z]));R.push(w+"=("+j.join("*")+")|0",x+"=mallocUint32("+w+")",b+"=mallocUint32("+w+")",A+"=0"),R.push(g(0)+"=0");for(var I=1;I<1<0;k=k-1&p)w.push(b+"["+A+"+"+m(k)+"]");w.push(y(0));for(var k=0;k=0;--e)G(e,0);for(var r=[],e=0;e0){",d(E[e]),"=1;");t(e-1,r|1<>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in l){var e=l[t];r[t]=o({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var c=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=n({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=n({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=n({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=n({args:["array","array"],pre:a,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":79}],220:[function(t,e,r){var n=t("iota-array"),a=t("is-buffer"),i="undefined"!=typeof Float64Array;function o(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,r=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&i.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):i.push("ORDER})")),i.push("proto.set=function "+r+"_set("+l.join(",")+",v){"),a?i.push("return this.data.set("+c+",v)}"):i.push("return this.data["+c+"]=v}"),i.push("proto.get=function "+r+"_get("+l.join(",")+"){"),a?i.push("return this.data.get("+c+")}"):i.push("return this.data["+c+"]}"),i.push("proto.index=function "+r+"_index(",l.join(),"){return "+c+"}"),i.push("proto.hi=function "+r+"_hi("+l.join(",")+"){return new "+r+"(this.data,"+o.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+o.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var d=o.map(function(t){return"a"+t+"=this.shape["+t+"]"}),p=o.map(function(t){return"c"+t+"=this.stride["+t+"]"});i.push("proto.lo=function "+r+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+p.join(","));for(var g=0;g=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");i.push("return new "+r+"(this.data,"+o.map(function(t){return"a"+t}).join(",")+","+o.map(function(t){return"c"+t}).join(",")+",b)}"),i.push("proto.step=function "+r+"_step("+l.join(",")+"){var "+o.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+o.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(g=0;g=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");return i.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),i.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+o.map(function(t){return"shape["+t+"]"}).join(",")+","+o.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",i.join("\n"))(u[t],s)}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,r,n){if(void 0===t)return(0,u.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var o=e.length;if(void 0===r){r=new Array(o);for(var s=o-1,c=1;s>=0;--s)r[s]=c,c*=e[s]}if(void 0===n)for(n=0,s=0;s>>0;e.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-a:a;var r=n.hi(t),o=n.lo(t);e>t==t>0?o===i?(r+=1,o=0):o+=1:0===o?(o=i,r-=1):o-=1;return n.pack(o,r)}},{"double-bits":88}],222:[function(t,e,r){var n=Math.PI,a=u(120);function i(t,e,r,n){return["C",t,e,r,n,r,n]}function o(t,e,r,n,a,i){return["C",t/3+2/3*r,e/3+2/3*n,a/3+2/3*r,i/3+2/3*n,a,i]}function s(t,e,r,i,o,u,c,f,h,d){if(d)A=d[0],k=d[1],_=d[2],w=d[3];else{var p=l(t,e,-o);t=p.x,e=p.y;var g=(t-(f=(p=l(f,h,-o)).x))/2,v=(e-(h=p.y))/2,m=g*g/(r*r)+v*v/(i*i);m>1&&(r*=m=Math.sqrt(m),i*=m);var y=r*r,b=i*i,x=(u==c?-1:1)*Math.sqrt(Math.abs((y*b-y*v*v-b*g*g)/(y*v*v+b*g*g)));x==1/0&&(x=1);var _=x*r*v/i+(t+f)/2,w=x*-i*g/r+(e+h)/2,A=Math.asin(((e-w)/i).toFixed(9)),k=Math.asin(((h-w)/i).toFixed(9));(A=t<_?n-A:A)<0&&(A=2*n+A),(k=f<_?n-k:k)<0&&(k=2*n+k),c&&A>k&&(A-=2*n),!c&&k>A&&(k-=2*n)}if(Math.abs(k-A)>a){var T=k,M=f,E=h;k=A+a*(c&&k>A?1:-1);var C=s(f=_+r*Math.cos(k),h=w+i*Math.sin(k),r,i,o,0,c,M,E,[k,T,_,w])}var S=Math.tan((k-A)/4),L=4/3*r*S,O=4/3*i*S,D=[2*t-(t+L*Math.sin(A)),2*e-(e-O*Math.cos(A)),f+L*Math.sin(k),h-O*Math.cos(k),f,h];if(d)return D;C&&(D=D.concat(C));for(var R=0;R7&&(r.push(m.splice(0,7)),m.unshift("C"));break;case"S":var b=d,x=p;"C"!=e&&"S"!=e||(b+=b-n,x+=x-a),m=["C",b,x,m[1],m[2],m[3],m[4]];break;case"T":"Q"==e||"T"==e?(f=2*d-f,h=2*p-h):(f=d,h=p),m=o(d,p,f,h,m[1],m[2]);break;case"Q":f=m[1],h=m[2],m=o(d,p,m[1],m[2],m[3],m[4]);break;case"L":m=i(d,p,m[1],m[2]);break;case"H":m=i(d,p,m[1],p);break;case"V":m=i(d,p,d,m[1]);break;case"Z":m=i(d,p,l,c)}e=y,d=m[m.length-2],p=m[m.length-1],m.length>4?(n=m[m.length-4],a=m[m.length-3]):(n=d,a=p),r.push(m)}return r}},{}],223:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,o,s=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),l=1;l1e4)throw Error("References have circular dependency. Please, check them.");r[n]=t}),n=n.reverse(),r=r.map(function(e){return n.forEach(function(r){e=e.replace(new RegExp("(\\"+a+r+"(?![0-9]))","g"),t[0]+"$1"+t[1])}),e})});var o=new RegExp("\\"+a+"([0-9]+)");return i?r:function t(e,r,n){for(var a,i=[],s=0;a=o.exec(e);){if(s++>1e4)throw Error("Circular references in parenthesis");i.push(e.slice(0,a.index)),i.push(t(r[a[1]],r)),e=e.slice(a.index+a[0].length)}return i.push(e),i}(r[0],r)}function a(t,e){if(e&&e.flat){var r,n=e&&e.escape||"___",a=t[0];if(!a)return"";for(var i=new RegExp("\\"+n+"([0-9]+)"),o=0;a!=r;){if(o++>1e4)throw Error("Circular references in "+t);r=a,a=a.replace(i,s)}return a}return t.reduce(function t(e,r){return Array.isArray(r)&&(r=r.reduce(t,"")),e+r},"");function s(e,r){if(null==t[r])throw Error("Reference "+r+"is undefined");return t[r]}}function i(t,e){return Array.isArray(t)?a(t,e):n(t,e)}i.parse=n,i.stringify=a,e.exports=i},{}],226:[function(t,e,r){"use strict";var n=t("pick-by-alias");e.exports=function(t){var e;arguments.length>1&&(t=arguments);"string"==typeof t?t=t.split(/\s/).map(parseFloat):"number"==typeof t&&(t=[t]);t.length&&"number"==typeof t[0]?e=1===t.length?{width:t[0],height:t[0],x:0,y:0}:2===t.length?{width:t[0],height:t[1],x:0,y:0}:{x:t[0],y:t[1],width:t[2]-t[0]||0,height:t[3]-t[1]||0}:t&&(t=n(t,{left:"x l left Left",top:"y t top Top",width:"w width W Width",height:"h height W Width",bottom:"b bottom Bottom",right:"r right Right"}),e={x:t.left||0,y:t.top||0},null==t.width?t.right?e.width=t.right-e.x:e.width=0:e.width=t.width,null==t.height?t.bottom?e.height=t.bottom-e.y:e.height=0:e.height=t.height);return e}},{"pick-by-alias":232}],227:[function(t,e,r){e.exports=function(t){var e=[];return t.replace(a,function(t,r,a){var o=r.toLowerCase();for(a=function(t){var e=t.match(i);return e?e.map(Number):[]}(a),"m"==o&&a.length>2&&(e.push([r].concat(a.splice(0,2))),o="l",r="m"==r?"l":"L");;){if(a.length==n[o])return a.unshift(r),e.push(a);if(a.length0;--o)i=l[o],r=s[o],s[o]=s[i],s[i]=r,l[o]=l[r],l[r]=i,u=(u+r)*o;return n.freeUint32(l),n.freeUint32(s),u},r.unrank=function(t,e,r){switch(t){case 0:return r||[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}var n,a,i,o=1;for((r=r||new Array(t))[0]=0,i=1;i0;--i)e=e-(n=e/o|0)*o|0,o=o/i|0,a=0|r[i],r[i]=0|r[n],r[n]=0|a;return r}},{"invert-permutation":204,"typedarray-pool":290}],232:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n,i,o={};if("string"==typeof e&&(e=a(e)),Array.isArray(e)){var s={};for(i=0;i0){o=i[c][r][0],l=c;break}s=o[1^l];for(var f=0;f<2;++f)for(var h=i[f][r],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&u(o,l),s)}function f(t,r){var a=i[r][t][0],o=[t];u(a,r);for(var s=a[1^r];;){for(;s!==t;)o.push(s),s=c(o[o.length-2],s,!1);if(i[0][t].length+i[1][t].length===0)break;var l=o[o.length-1],f=t,h=o[1],d=c(l,f,!0);if(n(e[l],e[f],e[h],e[d])<0)break;o.push(t),s=c(l,f)}return o}function h(t,e){return e[1]===e[e.length-1]}for(var o=0;o0;){i[0][o].length;var g=f(o,d);h(p,g)?p.push.apply(p,g):(p.length>0&&l.push(p),p=g)}p.length>0&&l.push(p)}return l};var n=t("compare-angle")},{"compare-angle":68}],234:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=n(t,e.length),a=new Array(e.length),i=new Array(e.length),o=[],s=0;s0;){var u=o.pop();a[u]=!1;for(var c=r[u],s=0;s0})).length,v=new Array(g),m=new Array(g),d=0;d0;){var B=F.pop(),j=S[B];l(j,function(t,e){return t-e});var U,H=j.length,V=N[B];if(0===V){var A=p[B];U=[A]}for(var d=0;d=0)&&(N[q]=1^V,F.push(q),0===V)){var A=p[q];I(A)||(A.reverse(),U.push(A))}}0===V&&r.push(U)}return r};var n=t("edges-to-adjacency-list"),a=t("planar-dual"),i=t("point-in-big-polygon"),o=t("two-product"),s=t("robust-sum"),l=t("uniq"),u=t("./lib/trim-leaves");function c(t,e){for(var r=new Array(t),n=0;n>>1;e.dtype||(e.dtype="array"),"string"==typeof e.dtype?p=new(f(e.dtype))(v):e.dtype&&(p=e.dtype,Array.isArray(p)&&(p.length=v));for(var m=0;mr){for(var h=0;hl||T>u||M=S||o===s)){var c=y[i];void 0===s&&(s=c.length);for(var f=o;f=g&&d<=m&&p>=v&&p<=w&&O.push(h)}var x=b[i],_=x[4*o+0],A=x[4*o+1],C=x[4*o+2],L=x[4*o+3],D=function(t,e){for(var r=null,n=0;null===r;)if(r=t[4*e+n],++n>t.length)return null;return r}(x,o+1),R=.5*a,P=i+1;e(r,n,R,P,_,A||C||L||D),e(r,n+R,R,P,A,C||L||D),e(r+R,n,R,P,C,L||D),e(r+R,n+R,R,P,L,D)}}}(0,0,1,0,0,1),O},p;function C(t,e,r){for(var n=1,a=.5,i=.5,o=.5,s=0;s0&&e[a]===r[0]))return 1;i=t[a-1]}for(var s=1;i;){var l=i.key,u=n(r,l[0],l[1]);if(l[0][0]0))return 0;s=-1,i=i.right}else if(u>0)i=i.left;else{if(!(u<0))return 0;s=1,i=i.right}}return s}}(m.slabs,m.coordinates);return 0===i.length?y:function(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}(l(i),y)};var n=t("robust-orientation")[3],a=t("slab-decomposition"),i=t("interval-tree-1d"),o=t("binary-search-bounds");function s(){return!0}function l(t){for(var e={},r=0;r=-t},pointBetween:function(e,r,n){var a=e[1]-r[1],i=n[0]-r[0],o=e[0]-r[0],s=n[1]-r[1],l=o*i+a*s;return!(l-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-a>t&&(i-u)*(a-c)/(o-c)+u-n>t&&(s=!s),i=u,o=c}return s}};return e}},{}],243:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),a=1;a0})}function c(t,n){var a=t.seg,i=n.seg,o=a.start,s=a.end,u=i.start,c=i.end;r&&r.checkIntersection(a,i);var f=e.linesIntersect(o,s,u,c);if(!1===f){if(!e.pointsCollinear(o,s,u))return!1;if(e.pointsSame(o,c)||e.pointsSame(s,u))return!1;var h=e.pointsSame(o,u),d=e.pointsSame(s,c);if(h&&d)return n;var p=!h&&e.pointBetween(o,u,c),g=!d&&e.pointBetween(s,u,c);if(h)return g?l(n,s):l(t,c),n;p&&(d||(g?l(n,s):l(t,c)),l(n,o))}else 0===f.alongA&&(-1===f.alongB?l(t,u):0===f.alongB?l(t,f.pt):1===f.alongB&&l(t,c)),0===f.alongB&&(-1===f.alongA?l(n,o):0===f.alongA?l(n,f.pt):1===f.alongA&&l(n,s));return!1}for(var f=[];!i.isEmpty();){var h=i.getHead();if(r&&r.vert(h.pt[0]),h.isStart){r&&r.segmentNew(h.seg,h.primary);var d=u(h),p=d.before?d.before.ev:null,g=d.after?d.after.ev:null;function v(){if(p){var t=c(h,p);if(t)return t}return!!g&&c(h,g)}r&&r.tempStatus(h.seg,!!p&&p.seg,!!g&&g.seg);var m,y,b=v();if(b)t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below)&&(b.seg.myFill.above=!b.seg.myFill.above):b.seg.otherFill=h.seg.myFill,r&&r.segmentUpdate(b.seg),h.other.remove(),h.remove();if(i.getHead()!==h){r&&r.rewind(h.seg);continue}t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below,h.seg.myFill.below=g?g.seg.myFill.above:a,h.seg.myFill.above=y?!h.seg.myFill.below:h.seg.myFill.below):null===h.seg.otherFill&&(m=g?h.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:h.primary?o:a,h.seg.otherFill={above:m,below:m}),r&&r.status(h.seg,!!p&&p.seg,!!g&&g.seg),h.other.status=d.insert(n.node({ev:h}))}else{var x=h.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(s.exists(x.prev)&&s.exists(x.next)&&c(x.prev.ev,x.next.ev),r&&r.statusRemove(x.ev.seg),x.remove(),!h.primary){var _=h.seg.myFill;h.seg.myFill=h.seg.otherFill,h.seg.otherFill=_}f.push(h.seg)}i.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,a,i,o=t[t.length-1],l=0;l1)for(var r=1;r1&&(t.scaleRatio=[t.scale[0]*t.viewport.width,t.scale[1]*t.viewport.height],r(t),t.after&&t.after(t))}function A(t){if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var e=0,r=0;if(x.groups=b=t.map(function(t,u){var c=b[u];return t?("function"==typeof t?t={after:t}:"number"==typeof t[0]&&(t={positions:t}),t=o(t,{color:"color colors fill",capSize:"capSize cap capsize cap-size",lineWidth:"lineWidth line-width width line thickness",opacity:"opacity alpha",range:"range dataBox",viewport:"viewport viewBox",errors:"errors error",positions:"positions position data points"}),c||(b[u]=c={id:u,scale:null,translate:null,scaleFract:null,translateFract:null,draw:!0},t=s({},y,t)),i(c,t,[{lineWidth:function(t){return.5*+t},capSize:function(t){return.5*+t},opacity:parseFloat,errors:function(t){return t=l(t),r+=t.length,t},positions:function(t,r){return t=l(t,"float64"),r.count=Math.floor(t.length/2),r.bounds=n(t,2),r.offset=e,e+=r.count,t}},{color:function(t,e){var r=e.count;if(t||(t="transparent"),!Array.isArray(t)||"number"==typeof t[0]){var n=t;t=Array(r);for(var i=0;i 0. && baClipping < length(normalWidth * endBotJoin)) {\n\t\t//handle miter clipping\n\t\tbTopCoord -= normalWidth * endTopJoin;\n\t\tbTopCoord += normalize(endTopJoin * normalWidth) * baClipping;\n\t}\n\n\tif (nextReverse) {\n\t\t//make join rectangular\n\t\tvec2 miterShift = normalWidth * endJoinDirection * miterLimit * .5;\n\t\tfloat normalAdjust = 1. - min(miterLimit / endMiterRatio, 1.);\n\t\tbBotCoord = bCoord + miterShift - normalAdjust * normalWidth * currNormal * .5;\n\t\tbTopCoord = bCoord + miterShift + normalAdjust * normalWidth * currNormal * .5;\n\t}\n\telse if (!prevReverse && abClipping > 0. && abClipping < length(normalWidth * startBotJoin)) {\n\t\t//handle miter clipping\n\t\taBotCoord -= normalWidth * startBotJoin;\n\t\taBotCoord += normalize(startBotJoin * normalWidth) * abClipping;\n\t}\n\n\tvec2 aTopPosition = (aTopCoord) * adjustedScale + translate;\n\tvec2 aBotPosition = (aBotCoord) * adjustedScale + translate;\n\n\tvec2 bTopPosition = (bTopCoord) * adjustedScale + translate;\n\tvec2 bBotPosition = (bBotCoord) * adjustedScale + translate;\n\n\t//position is normalized 0..1 coord on the screen\n\tvec2 position = (aTopPosition * lineTop + aBotPosition * lineBot) * lineStart + (bTopPosition * lineTop + bBotPosition * lineBot) * lineEnd;\n\n\tstartCoord = aCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\tendCoord = bCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tenableStartMiter = step(dot(currTangent, prevTangent), .5);\n\tenableEndMiter = step(dot(currTangent, nextTangent), .5);\n\n\t//bevel miter cutoffs\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * miterLimit * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * miterLimit * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n\n\t//round miter cutoffs\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * abs(dot(startJoinDirection, currNormal)) * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * abs(dot(endJoinDirection, currNormal)) * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nuniform sampler2D dashPattern;\nuniform float dashSize, pixelRatio, thickness, opacity, id, miterMode;\n\nvarying vec4 fragColor;\nvarying vec2 tangent;\nvarying vec4 startCutoff, endCutoff;\nvarying vec2 startCoord, endCoord;\nvarying float enableStartMiter, enableEndMiter;\n\nfloat distToLine(vec2 p, vec2 a, vec2 b) {\n\tvec2 diff = b - a;\n\tvec2 perp = normalize(vec2(-diff.y, diff.x));\n\treturn dot(p - a, perp);\n}\n\nvoid main() {\n\tfloat alpha = 1., distToStart, distToEnd;\n\tfloat cutoff = thickness * .5;\n\n\t//bevel miter\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToStart + 1., 0.), 1.);\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToEnd + 1., 0.), 1.);\n\t\t}\n\t}\n\n\t// round miter\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - startCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - endCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\t}\n\n\tfloat t = fract(dot(tangent, gl_FragCoord.xy) / dashSize) * .5 + .25;\n\tfloat dash = texture2D(dashPattern, vec2(t, .5)).r;\n\n\tgl_FragColor = fragColor;\n\tgl_FragColor.a *= alpha * opacity * dash;\n}\n"]),attributes:{lineEnd:{buffer:r,divisor:0,stride:8,offset:0},lineTop:{buffer:r,divisor:0,stride:8,offset:4},aColor:{buffer:t.prop("colorBuffer"),stride:4,offset:0,divisor:1},bColor:{buffer:t.prop("colorBuffer"),stride:4,offset:4,divisor:1},prevCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:0,divisor:1},aCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:8,divisor:1},bCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:16,divisor:1},nextCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:24,divisor:1}}},n))}catch(t){e=a}return{fill:t({primitive:"triangle",elements:function(t,e){return e.triangles},offset:0,vert:o(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec2 position, positionFract;\n\nuniform vec4 color;\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio, id;\nuniform vec4 viewport;\nuniform float opacity;\n\nvarying vec4 fragColor;\n\nconst float MAX_LINES = 256.;\n\nvoid main() {\n\tfloat depth = (MAX_LINES - 4. - id) / (MAX_LINES);\n\n\tvec2 position = position * scale + translate\n + positionFract * scale + translateFract\n + position * scaleFract\n + positionFract * scaleFract;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tfragColor = color / 255.;\n\tfragColor.a *= opacity;\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n\tgl_FragColor = fragColor;\n}\n"]),uniforms:{scale:t.prop("scale"),color:t.prop("fill"),scaleFract:t.prop("scaleFract"),translateFract:t.prop("translateFract"),translate:t.prop("translate"),opacity:t.prop("opacity"),pixelRatio:t.context("pixelRatio"),id:t.prop("id"),viewport:function(t,e){return[e.viewport.x,e.viewport.y,t.viewportWidth,t.viewportHeight]}},attributes:{position:{buffer:t.prop("positionBuffer"),stride:8,offset:8},positionFract:{buffer:t.prop("positionFractBuffer"),stride:8,offset:8}},blend:n.blend,depth:{enable:!1},scissor:n.scissor,stencil:n.stencil,viewport:n.viewport}),rect:a,miter:e}},v.defaults={dashes:null,join:"miter",miterLimit:1,thickness:10,cap:"square",color:"black",opacity:1,overlay:!1,viewport:null,range:null,close:!1,fill:null},v.prototype.render=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];e.length&&(t=this).update.apply(t,e),this.draw()},v.prototype.draw=function(){for(var t=this,e=[],r=arguments.length;r--;)e[r]=arguments[r];return(e.length?e:this.passes).forEach(function(e,r){var n;if(e&&Array.isArray(e))return(n=t).draw.apply(n,e);"number"==typeof e&&(e=t.passes[e]),e&&e.count>1&&e.opacity&&(t.regl._refresh(),e.fill&&e.triangles&&e.triangles.length>2&&t.shaders.fill(e),e.thickness&&(e.scale[0]*e.viewport.width>v.precisionThreshold||e.scale[1]*e.viewport.height>v.precisionThreshold?t.shaders.rect(e):"rect"===e.join||!e.join&&(e.thickness<=2||e.count>=v.maxPoints)?t.shaders.rect(e):t.shaders.miter(e)))}),this},v.prototype.update=function(t){var e=this;if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var r=this.regl,o=this.gl;if(t.forEach(function(t,f){var p=e.passes[f];if(void 0!==t)if(null!==t){if("number"==typeof t[0]&&(t={positions:t}),t=s(t,{positions:"positions points data coords",thickness:"thickness lineWidth lineWidths line-width linewidth width stroke-width strokewidth strokeWidth",join:"lineJoin linejoin join type mode",miterLimit:"miterlimit miterLimit",dashes:"dash dashes dasharray dash-array dashArray",color:"color colour stroke colors colours stroke-color strokeColor",fill:"fill fill-color fillColor",opacity:"alpha opacity",overlay:"overlay crease overlap intersect",close:"closed close closed-path closePath",range:"range dataBox",viewport:"viewport viewBox",hole:"holes hole hollow"}),p||(e.passes[f]=p={id:f,scale:null,scaleFract:null,translate:null,translateFract:null,count:0,hole:[],depth:0,dashLength:1,dashTexture:r.texture({channels:1,data:new Uint8Array([255]),width:1,height:1,mag:"linear",min:"linear"}),colorBuffer:r.buffer({usage:"dynamic",type:"uint8",data:new Uint8Array}),positionBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array}),positionFractBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array})},t=i({},v.defaults,t)),null!=t.thickness&&(p.thickness=parseFloat(t.thickness)),null!=t.opacity&&(p.opacity=parseFloat(t.opacity)),null!=t.miterLimit&&(p.miterLimit=parseFloat(t.miterLimit)),null!=t.overlay&&(p.overlay=!!t.overlay,f 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]),c.vert=l(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nvec2 paletteCoord(float id) {\n return vec2(\n (mod(id, paletteSize.x) + .5) / paletteSize.x,\n (floor(id / paletteSize.x) + .5) / paletteSize.y\n );\n}\nvec2 paletteCoord(vec2 id) {\n return vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n );\n}\n\nvec4 getColor(vec4 id) {\n // zero-palette means we deal with direct buffer\n if (paletteSize.x == 0.) return id / 255.;\n return texture2D(palette, paletteCoord(id.xy));\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]),h&&(c.frag=c.frag.replace("smoothstep","smoothStep"),u.frag=u.frag.replace("smoothstep","smoothStep")),this.drawCircle=t(c)}e.exports=g,g.defaults={color:"black",borderColor:"transparent",borderSize:0,size:12,opacity:1,marker:void 0,viewport:null,range:null,pixelSize:null,count:0,offset:0,bounds:null,positions:[],snap:1e4},g.prototype.render=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];return e.length&&(t=this).update.apply(t,e),this.draw(),this},g.prototype.draw=function(){for(var t=this,e=[],r=arguments.length;r--;)e[r]=arguments[r];var n=this.groups;if(1===e.length&&Array.isArray(e[0])&&(null===e[0][0]||Array.isArray(e[0][0]))&&(e=e[0]),this.regl._refresh(),e.length)for(var a=0;an)?e.tree=o(t,{bounds:h}):n&&n.length&&(e.tree=n),e.tree){var p={primitive:"points",usage:"static",data:e.tree,type:"uint32"};e.elements?e.elements(p):e.elements=l.elements(p)}return i({data:d.float(t),usage:"dynamic"}),s({data:d.fract(t),usage:"dynamic"}),u({data:new Uint8Array(c),type:"uint8",usage:"stream"}),t}},{marker:function(e,r,n){var a=r.activation;if(a.forEach(function(t){return t&&t.destroy&&t.destroy()}),a.length=0,e&&"number"!=typeof e[0]){for(var i=[],o=0,s=Math.min(e.length,r.count);o=0)return i;if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)e=t;else{e=new Uint8Array(t.length);for(var o=0,s=t.length;oa*a*4&&(this.tooManyColors=!0),this.updatePalette(r),1===o.length?o[0]:o},g.prototype.updatePalette=function(t){if(!this.tooManyColors){var e=this.maxColors,r=this.paletteTexture,n=Math.ceil(.25*t.length/e);if(n>1)for(var a=.25*(t=t.slice()).length%e;a2?(s[0],s[2],n=s[1],a=s[3]):s.length?(n=s[0],a=s[1]):(s.x,n=s.y,s.x+s.width,a=s.y+s.height),l.length>2?(i=l[0],o=l[2],l[1],l[3]):l.length?(i=l[0],o=l[1]):(i=l.x,l.y,o=l.x+l.width,l.y+l.height),[i,n,o,a]}function d(t){if("number"==typeof t)return[t,t,t,t];if(2===t.length)return[t[0],t[1],t[0],t[1]];var e=l(t);return[e.x,e.y,e.x+e.width,e.y+e.height]}e.exports=c,c.prototype.render=function(){for(var t,e=this,r=[],n=arguments.length;n--;)r[n]=arguments[n];return r.length&&(t=this).update.apply(t,r),this.regl.attributes.preserveDrawingBuffer?this.draw():(this.dirty?null==this.planned&&(this.planned=o(function(){e.draw(),e.dirty=!0,e.planned=null})):(this.draw(),this.dirty=!0,o(function(){e.dirty=!1})),this)},c.prototype.update=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e.length){for(var n=0;nk))&&(s.lower||!(A>>=e))<<3,(e|=r=(15<(t>>>=r))<<2)|(r=(3<(t>>>=r))<<1)|t>>>r>>1}function s(){function t(t){t:{for(var e=16;268435456>=e;e*=16)if(t<=e){t=e;break t}t=0}return 0<(e=r[o(t)>>2]).length?e.pop():new ArrayBuffer(t)}function e(t){r[o(t.byteLength)>>2].push(t)}var r=i(8,function(){return[]});return{alloc:t,free:e,allocType:function(e,r){var n=null;switch(e){case 5120:n=new Int8Array(t(r),0,r);break;case 5121:n=new Uint8Array(t(r),0,r);break;case 5122:n=new Int16Array(t(2*r),0,r);break;case 5123:n=new Uint16Array(t(2*r),0,r);break;case 5124:n=new Int32Array(t(4*r),0,r);break;case 5125:n=new Uint32Array(t(4*r),0,r);break;case 5126:n=new Float32Array(t(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(t){e(t.buffer)}}}function l(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||W(t.data))}function u(t,e,r,n,a,i){for(var o=0;o(a=s)&&(a=n.buffer.byteLength,5123===f?a>>=1:5125===f&&(a>>=2)),n.vertCount=a,a=o,0>o&&(a=4,1===(o=n.buffer.dimension)&&(a=0),2===o&&(a=1),3===o&&(a=4)),n.primType=a}function o(t){n.elementsCount--,delete s[t.id],t.buffer.destroy(),t.buffer=null}var s={},u=0,c={uint8:5121,uint16:5123};e.oes_element_index_uint&&(c.uint32=5125),a.prototype.bind=function(){this.buffer.bind()};var f=[];return{create:function(t,e){function s(t){if(t)if("number"==typeof t)u(t),f.primType=4,f.vertCount=0|t,f.type=5121;else{var e=null,r=35044,n=-1,a=-1,o=0,h=0;Array.isArray(t)||W(t)||l(t)?e=t:("data"in t&&(e=t.data),"usage"in t&&(r=$[t.usage]),"primitive"in t&&(n=rt[t.primitive]),"count"in t&&(a=0|t.count),"type"in t&&(h=c[t.type]),"length"in t?o=0|t.length:(o=a,5123===h||5122===h?o*=2:5125!==h&&5124!==h||(o*=4))),i(f,e,r,n,a,o,h)}else u(),f.primType=4,f.vertCount=0,f.type=5121;return s}var u=r.create(null,34963,!0),f=new a(u._buffer);return n.elementsCount++,s(t),s._reglType="elements",s._elements=f,s.subdata=function(t,e){return u.subdata(t,e),s},s.destroy=function(){o(f)},s},createStream:function(t){var e=f.pop();return e||(e=new a(r.create(null,34963,!0,!1)._buffer)),i(e,t,35040,-1,-1,0,0),e},destroyStream:function(t){f.push(t)},getElements:function(t){return"function"==typeof t&&t._elements instanceof a?t._elements:null},clear:function(){Y(s).forEach(o)}}}function g(t){for(var e=G.allocType(5123,t.length),r=0;r>>31<<15,a=(i<<1>>>24)-127,i=i>>13&1023;e[r]=-24>a?n:-14>a?n+(i+1024>>-14-a):15>=a,r.height>>=a,d(r,n[a]),t.mipmask|=1<e;++e)t.images[e]=null;return t}function L(t){for(var e=t.images,r=0;re){for(var r=0;r=--this.refCount&&F(this)}}),o.profile&&(i.getTotalTextureSize=function(){var t=0;return Object.keys(mt).forEach(function(e){t+=mt[e].stats.size}),t}),{create2D:function(e,r){function n(t,e){var r=a.texInfo;O.call(r);var i=S();return"number"==typeof t?M(i,0|t,"number"==typeof e?0|e:0|t):t?(D(r,t),E(i,t)):M(i,1,1),r.genMipmaps&&(i.mipmask=(i.width<<1)-1),a.mipmask=i.mipmask,u(a,i),a.internalformat=i.internalformat,n.width=i.width,n.height=i.height,z(a),C(i,3553),R(r,3553),I(),L(i),o.profile&&(a.stats.size=A(a.internalformat,a.type,i.width,i.height,r.genMipmaps,!1)),n.format=tt[a.internalformat],n.type=et[a.type],n.mag=rt[r.magFilter],n.min=nt[r.minFilter],n.wrapS=at[r.wrapS],n.wrapT=at[r.wrapT],n}var a=new P(3553);return mt[a.id]=a,i.textureCount++,n(e,r),n.subimage=function(t,e,r,i){e|=0,r|=0,i|=0;var o=m();return u(o,a),o.width=0,o.height=0,d(o,t),o.width=o.width||(a.width>>i)-e,o.height=o.height||(a.height>>i)-r,z(a),p(o,3553,e,r,i),I(),k(o),n},n.resize=function(e,r){var i=0|e,s=0|r||i;if(i===a.width&&s===a.height)return n;n.width=a.width=i,n.height=a.height=s,z(a);for(var l,u=a.channels,c=a.type,f=0;a.mipmask>>f;++f){var h=i>>f,d=s>>f;if(!h||!d)break;l=G.zero.allocType(c,h*d*u),t.texImage2D(3553,f,a.format,h,d,0,a.format,a.type,l),l&&G.zero.freeType(l)}return I(),o.profile&&(a.stats.size=A(a.internalformat,a.type,i,s,!1,!1)),n},n._reglType="texture2d",n._texture=a,o.profile&&(n.stats=a.stats),n.destroy=function(){a.decRef()},n},createCube:function(e,r,n,a,s,l){function f(t,e,r,n,a,i){var s,l=h.texInfo;for(O.call(l),s=0;6>s;++s)g[s]=S();if("number"!=typeof t&&t){if("object"==typeof t)if(e)E(g[0],t),E(g[1],e),E(g[2],r),E(g[3],n),E(g[4],a),E(g[5],i);else if(D(l,t),c(h,t),"faces"in t)for(t=t.faces,s=0;6>s;++s)u(g[s],h),E(g[s],t[s]);else for(s=0;6>s;++s)E(g[s],t)}else for(t=0|t||1,s=0;6>s;++s)M(g[s],t,t);for(u(h,g[0]),h.mipmask=l.genMipmaps?(g[0].width<<1)-1:g[0].mipmask,h.internalformat=g[0].internalformat,f.width=g[0].width,f.height=g[0].height,z(h),s=0;6>s;++s)C(g[s],34069+s);for(R(l,34067),I(),o.profile&&(h.stats.size=A(h.internalformat,h.type,f.width,f.height,l.genMipmaps,!0)),f.format=tt[h.internalformat],f.type=et[h.type],f.mag=rt[l.magFilter],f.min=nt[l.minFilter],f.wrapS=at[l.wrapS],f.wrapT=at[l.wrapT],s=0;6>s;++s)L(g[s]);return f}var h=new P(34067);mt[h.id]=h,i.cubeCount++;var g=Array(6);return f(e,r,n,a,s,l),f.subimage=function(t,e,r,n,a){r|=0,n|=0,a|=0;var i=m();return u(i,h),i.width=0,i.height=0,d(i,e),i.width=i.width||(h.width>>a)-r,i.height=i.height||(h.height>>a)-n,z(h),p(i,34069+t,r,n,a),I(),k(i),f},f.resize=function(e){if((e|=0)!==h.width){f.width=h.width=e,f.height=h.height=e,z(h);for(var r=0;6>r;++r)for(var n=0;h.mipmask>>n;++n)t.texImage2D(34069+r,n,h.format,e>>n,e>>n,0,h.format,h.type,null);return I(),o.profile&&(h.stats.size=A(h.internalformat,h.type,f.width,f.height,!1,!0)),f}},f._reglType="textureCube",f._texture=h,o.profile&&(f.stats=h.stats),f.destroy=function(){h.decRef()},f},clear:function(){for(var e=0;er;++r)if(0!=(e.mipmask&1<>r,e.height>>r,0,e.internalformat,e.type,null);else for(var n=0;6>n;++n)t.texImage2D(34069+n,r,e.internalformat,e.width>>r,e.height>>r,0,e.internalformat,e.type,null);R(e.texInfo,e.target)})}}}function T(t,e,r,n,a,i){function o(t,e,r){this.target=t,this.texture=e,this.renderbuffer=r;var n=t=0;e?(t=e.width,n=e.height):r&&(t=r.width,n=r.height),this.width=t,this.height=n}function s(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function l(t,e,r){t&&(t.texture?t.texture._texture.refCount+=1:t.renderbuffer._renderbuffer.refCount+=1)}function u(e,r){r&&(r.texture?t.framebufferTexture2D(36160,e,r.target,r.texture._texture.texture,0):t.framebufferRenderbuffer(36160,e,36161,r.renderbuffer._renderbuffer.renderbuffer))}function c(t){var e=3553,r=null,n=null,a=t;return"object"==typeof t&&(a=t.data,"target"in t&&(e=0|t.target)),"texture2d"===(t=a._reglType)?r=a:"textureCube"===t?r=a:"renderbuffer"===t&&(n=a,e=36161),new o(e,r,n)}function f(t,e,r,i,s){return r?((t=n.create2D({width:t,height:e,format:i,type:s}))._texture.refCount=0,new o(3553,t,null)):((t=a.create({width:t,height:e,format:i}))._renderbuffer.refCount=0,new o(36161,null,t))}function h(t){return t&&(t.texture||t.renderbuffer)}function d(t,e,r){t&&(t.texture?t.texture.resize(e,r):t.renderbuffer&&t.renderbuffer.resize(e,r))}function p(){this.id=A++,k[this.id]=this,this.framebuffer=t.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function g(t){t.colorAttachments.forEach(s),s(t.depthAttachment),s(t.stencilAttachment),s(t.depthStencilAttachment)}function v(e){t.deleteFramebuffer(e.framebuffer),e.framebuffer=null,i.framebufferCount--,delete k[e.id]}function m(e){var n;t.bindFramebuffer(36160,e.framebuffer);var a=e.colorAttachments;for(n=0;na;++a){for(u=0;ut;++t)r[t].resize(n);return e.width=e.height=n,e},_reglType:"framebufferCube",destroy:function(){r.forEach(function(t){t.destroy()})}})},clear:function(){Y(k).forEach(v)},restore:function(){Y(k).forEach(function(e){e.framebuffer=t.createFramebuffer(),m(e)})}})}function M(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function E(t,e,r,n){function a(t,e,r,n){this.name=t,this.id=e,this.location=r,this.info=n}function i(t,e){for(var r=0;rt&&(t=e.stats.uniformsCount)}),t},r.getMaxAttributesCount=function(){var t=0;return h.forEach(function(e){e.stats.attributesCount>t&&(t=e.stats.attributesCount)}),t}),{clear:function(){var e=t.deleteShader.bind(t);Y(u).forEach(e),u={},Y(c).forEach(e),c={},h.forEach(function(e){t.deleteProgram(e.program)}),h.length=0,f={},r.shaderCount=0},program:function(t,e,n){var a=f[e];a||(a=f[e]={});var i=a[t];return i||(i=new s(e,t),r.shaderCount++,l(i),a[t]=i,h.push(i)),i},restore:function(){u={},c={};for(var t=0;t"+e+"?"+a+".constant["+e+"]:0;"}).join(""),"}}else{","if(",o,"(",a,".buffer)){",c,"=",s,".createStream(",34962,",",a,".buffer);","}else{",c,"=",s,".getBuffer(",a,".buffer);","}",f,'="type" in ',a,"?",i.glTypes,"[",a,".type]:",c,".dtype;",l.normalized,"=!!",a,".normalized;"),n("size"),n("offset"),n("stride"),n("divisor"),r("}}"),r.exit("if(",l.isStream,"){",s,".destroyStream(",c,");","}"),l})}),o}function T(t,e,r,n,a){var o=_(t),s=function(t,e,r){function n(t){if(t in a){var r=a[t];t=!0;var n,o,s=0|r.x,l=0|r.y;return"width"in r?n=0|r.width:t=!1,"height"in r?o=0|r.height:t=!1,new P(!t&&e&&e.thisDep,!t&&e&&e.contextDep,!t&&e&&e.propDep,function(t,e){var a=t.shared.context,i=n;"width"in r||(i=e.def(a,".","framebufferWidth","-",s));var u=o;return"height"in r||(u=e.def(a,".","framebufferHeight","-",l)),[s,l,i,u]})}if(t in i){var u=i[t];return t=F(u,function(t,e){var r=t.invoke(e,u),n=t.shared.context,a=e.def(r,".x|0"),i=e.def(r,".y|0");return[a,i,e.def('"width" in ',r,"?",r,".width|0:","(",n,".","framebufferWidth","-",a,")"),r=e.def('"height" in ',r,"?",r,".height|0:","(",n,".","framebufferHeight","-",i,")")]}),e&&(t.thisDep=t.thisDep||e.thisDep,t.contextDep=t.contextDep||e.contextDep,t.propDep=t.propDep||e.propDep),t}return e?new P(e.thisDep,e.contextDep,e.propDep,function(t,e){var r=t.shared.context;return[0,0,e.def(r,".","framebufferWidth"),e.def(r,".","framebufferHeight")]}):null}var a=t.static,i=t.dynamic;if(t=n("viewport")){var o=t;t=new P(t.thisDep,t.contextDep,t.propDep,function(t,e){var r=o.append(t,e),n=t.shared.context;return e.set(n,".viewportWidth",r[2]),e.set(n,".viewportHeight",r[3]),r})}return{viewport:t,scissor_box:n("scissor.box")}}(t,o),l=A(t),u=function(t,e){var r=t.static,n=t.dynamic,a={};return nt.forEach(function(t){function e(e,i){if(t in r){var s=e(r[t]);a[o]=I(function(){return s})}else if(t in n){var l=n[t];a[o]=F(l,function(t,e){return i(t,e,t.invoke(e,l))})}}var o=m(t);switch(t){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":return e(function(t){return t},function(t,e,r){return r});case"depth.func":return e(function(t){return At[t]},function(t,e,r){return e.def(t.constants.compareFuncs,"[",r,"]")});case"depth.range":return e(function(t){return t},function(t,e,r){return[e.def("+",r,"[0]"),e=e.def("+",r,"[1]")]});case"blend.func":return e(function(t){return[wt["srcRGB"in t?t.srcRGB:t.src],wt["dstRGB"in t?t.dstRGB:t.dst],wt["srcAlpha"in t?t.srcAlpha:t.src],wt["dstAlpha"in t?t.dstAlpha:t.dst]]},function(t,e,r){function n(t,n){return e.def('"',t,n,'" in ',r,"?",r,".",t,n,":",r,".",t)}t=t.constants.blendFuncs;var a=n("src","RGB"),i=n("dst","RGB"),o=(a=e.def(t,"[",a,"]"),e.def(t,"[",n("src","Alpha"),"]"));return[a,i=e.def(t,"[",i,"]"),o,t=e.def(t,"[",n("dst","Alpha"),"]")]});case"blend.equation":return e(function(t){return"string"==typeof t?[J[t],J[t]]:"object"==typeof t?[J[t.rgb],J[t.alpha]]:void 0},function(t,e,r){var n=t.constants.blendEquations,a=e.def(),i=e.def();return(t=t.cond("typeof ",r,'==="string"')).then(a,"=",i,"=",n,"[",r,"];"),t.else(a,"=",n,"[",r,".rgb];",i,"=",n,"[",r,".alpha];"),e(t),[a,i]});case"blend.color":return e(function(t){return i(4,function(e){return+t[e]})},function(t,e,r){return i(4,function(t){return e.def("+",r,"[",t,"]")})});case"stencil.mask":return e(function(t){return 0|t},function(t,e,r){return e.def(r,"|0")});case"stencil.func":return e(function(t){return[At[t.cmp||"keep"],t.ref||0,"mask"in t?t.mask:-1]},function(t,e,r){return[t=e.def('"cmp" in ',r,"?",t.constants.compareFuncs,"[",r,".cmp]",":",7680),e.def(r,".ref|0"),e=e.def('"mask" in ',r,"?",r,".mask|0:-1")]});case"stencil.opFront":case"stencil.opBack":return e(function(e){return["stencil.opBack"===t?1029:1028,kt[e.fail||"keep"],kt[e.zfail||"keep"],kt[e.zpass||"keep"]]},function(e,r,n){function a(t){return r.def('"',t,'" in ',n,"?",i,"[",n,".",t,"]:",7680)}var i=e.constants.stencilOps;return["stencil.opBack"===t?1029:1028,a("fail"),a("zfail"),a("zpass")]});case"polygonOffset.offset":return e(function(t){return[0|t.factor,0|t.units]},function(t,e,r){return[e.def(r,".factor|0"),e=e.def(r,".units|0")]});case"cull.face":return e(function(t){var e=0;return"front"===t?e=1028:"back"===t&&(e=1029),e},function(t,e,r){return e.def(r,'==="front"?',1028,":",1029)});case"lineWidth":return e(function(t){return t},function(t,e,r){return r});case"frontFace":return e(function(t){return Tt[t]},function(t,e,r){return e.def(r+'==="cw"?2304:2305')});case"colorMask":return e(function(t){return t.map(function(t){return!!t})},function(t,e,r){return i(4,function(t){return"!!"+r+"["+t+"]"})});case"sample.coverage":return e(function(t){return["value"in t?t.value:1,!!t.invert]},function(t,e,r){return[e.def('"value" in ',r,"?+",r,".value:1"),e=e.def("!!",r,".invert")]})}}),a}(t),c=w(t),f=s.viewport;return f&&(u.viewport=f),(s=s[f=m("scissor.box")])&&(u[f]=s),(o={framebuffer:o,draw:l,shader:c,state:u,dirty:s=0>1)",s],");")}function e(){r(l,".drawArraysInstancedANGLE(",[p,g,v,s],");")}d?y?t():(r("if(",d,"){"),t(),r("}else{"),e(),r("}")):e()}function o(){function t(){r(c+".drawElements("+[p,v,m,g+"<<(("+m+"-5121)>>1)"]+");")}function e(){r(c+".drawArrays("+[p,g,v]+");")}d?y?t():(r("if(",d,"){"),t(),r("}else{"),e(),r("}")):e()}var s,l,u=t.shared,c=u.gl,f=u.draw,h=n.draw,d=function(){var a=h.elements,i=e;return a?((a.contextDep&&n.contextDynamic||a.propDep)&&(i=r),a=a.append(t,i)):a=i.def(f,".","elements"),a&&i("if("+a+")"+c+".bindBuffer(34963,"+a+".buffer.buffer);"),a}(),p=a("primitive"),g=a("offset"),v=function(){var a=h.count,i=e;return a?((a.contextDep&&n.contextDynamic||a.propDep)&&(i=r),a=a.append(t,i)):a=i.def(f,".","count"),a}();if("number"==typeof v){if(0===v)return}else r("if(",v,"){"),r.exit("}");$&&(s=a("instances"),l=t.instancing);var m=d+".type",y=h.elements&&z(h.elements);$&&("number"!=typeof s||0<=s)?"string"==typeof s?(r("if(",s,">0){"),i(),r("}else if(",s,"<0){"),o(),r("}")):i():o()}function V(t,e,r,n,a){return a=(e=x()).proc("body",a),$&&(e.instancing=a.def(e.shared.extensions,".angle_instanced_arrays")),t(e,a,r,n),e.compile().body}function q(t,e,r,n){L(t,e),B(t,e,r,n.attributes,function(){return!0}),j(t,e,r,n.uniforms,function(){return!0}),U(t,e,e,r)}function G(t,e,r,n){function a(){return!0}t.batchId="a1",L(t,e),B(t,e,r,n.attributes,a),j(t,e,r,n.uniforms,a),U(t,e,e,r)}function X(t,e,r,n){function a(t){return t.contextDep&&o||t.propDep}function i(t){return!a(t)}L(t,e);var o=r.contextDep,s=e.def(),l=e.def();t.shared.props=l,t.batchId=s;var u=t.scope(),c=t.scope();e(u.entry,"for(",s,"=0;",s,"<","a1",";++",s,"){",l,"=","a0","[",s,"];",c,"}",u.exit),r.needsContext&&M(t,c,r.context),r.needsFramebuffer&&E(t,c,r.framebuffer),S(t,c,r.state,a),r.profile&&a(r.profile)&&N(t,c,r,!1,!0),n?(B(t,u,r,n.attributes,i),B(t,c,r,n.attributes,a),j(t,u,r,n.uniforms,i),j(t,c,r,n.uniforms,a),U(t,u,c,r)):(e=t.global.def("{}"),n=r.shader.progVar.append(t,c),l=c.def(n,".id"),u=c.def(e,"[",l,"]"),c(t.shared.gl,".useProgram(",n,".program);","if(!",u,"){",u,"=",e,"[",l,"]=",t.link(function(e){return V(G,t,r,e,2)}),"(",n,");}",u,".call(this,a0[",s,"],",s,");"))}function W(t,r){function n(e){var n=r.shader[e];n&&a.set(i.shader,"."+e,n.append(t,a))}var a=t.proc("scope",3);t.batchId="a2";var i=t.shared,o=i.current;M(t,a,r.context),r.framebuffer&&r.framebuffer.append(t,a),R(Object.keys(r.state)).forEach(function(e){var n=r.state[e].append(t,a);v(n)?n.forEach(function(r,n){a.set(t.next[e],"["+n+"]",r)}):a.set(i.next,"."+e,n)}),N(t,a,r,!0,!0),["elements","offset","count","instances","primitive"].forEach(function(e){var n=r.draw[e];n&&a.set(i.draw,"."+e,""+n.append(t,a))}),Object.keys(r.uniforms).forEach(function(n){a.set(i.uniforms,"["+e.id(n)+"]",r.uniforms[n].append(t,a))}),Object.keys(r.attributes).forEach(function(e){var n=r.attributes[e].append(t,a),i=t.scopeAttrib(e);Object.keys(new Z).forEach(function(t){a.set(i,"."+t,n[t])})}),n("vert"),n("frag"),0=--this.refCount&&o(this)},a.profile&&(n.getTotalRenderbufferSize=function(){var t=0;return Object.keys(c).forEach(function(e){t+=c[e].stats.size}),t}),{create:function(e,r){function o(e,r){var n=0,i=0,c=32854;if("object"==typeof e&&e?("shape"in e?(n=0|(i=e.shape)[0],i=0|i[1]):("radius"in e&&(n=i=0|e.radius),"width"in e&&(n=0|e.width),"height"in e&&(i=0|e.height)),"format"in e&&(c=s[e.format])):"number"==typeof e?(n=0|e,i="number"==typeof r?0|r:n):e||(n=i=1),n!==u.width||i!==u.height||c!==u.format)return o.width=u.width=n,o.height=u.height=i,u.format=c,t.bindRenderbuffer(36161,u.renderbuffer),t.renderbufferStorage(36161,c,n,i),a.profile&&(u.stats.size=vt[u.format]*u.width*u.height),o.format=l[u.format],o}var u=new i(t.createRenderbuffer());return c[u.id]=u,n.renderbufferCount++,o(e,r),o.resize=function(e,r){var n=0|e,i=0|r||n;return n===u.width&&i===u.height?o:(o.width=u.width=n,o.height=u.height=i,t.bindRenderbuffer(36161,u.renderbuffer),t.renderbufferStorage(36161,u.format,n,i),a.profile&&(u.stats.size=vt[u.format]*u.width*u.height),o)},o._reglType="renderbuffer",o._renderbuffer=u,a.profile&&(o.stats=u.stats),o.destroy=function(){u.decRef()},o},clear:function(){Y(c).forEach(o)},restore:function(){Y(c).forEach(function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,e.renderbuffer),t.renderbufferStorage(36161,e.format,e.width,e.height)}),t.bindRenderbuffer(36161,null)}}},yt=[];yt[6408]=4,yt[6407]=3;var bt=[];bt[5121]=1,bt[5126]=4,bt[36193]=2;var xt=["x","y","z","w"],_t="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),wt={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},At={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},kt={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Tt={cw:2304,ccw:2305},Mt=new P(!1,!1,!1,function(){});return function(t){function e(){if(0===Z.length)w&&w.update(),K=null;else{K=V.next(e),f();for(var t=Z.length-1;0<=t;--t){var r=Z[t];r&&r(O,null,0)}v.flush(),w&&w.update()}}function r(){!K&&0=Z.length&&n()}}}}function c(){var t=W.viewport,e=W.scissor_box;t[0]=t[1]=e[0]=e[1]=0,O.viewportWidth=O.framebufferWidth=O.drawingBufferWidth=t[2]=e[2]=v.drawingBufferWidth,O.viewportHeight=O.framebufferHeight=O.drawingBufferHeight=t[3]=e[3]=v.drawingBufferHeight}function f(){O.tick+=1,O.time=g(),c(),G.procs.poll()}function h(){c(),G.procs.refresh(),w&&w.update()}function g(){return(q()-A)/1e3}if(!(t=a(t)))return null;var v=t.gl,m=v.getContextAttributes();v.isContextLost();var y=function(t,e){function r(e){var r;e=e.toLowerCase();try{r=n[e]=t.getExtension(e)}catch(t){}return!!r}for(var n={},a=0;ae;++e)tt(j({framebuffer:t.framebuffer.faces[e]},t),l);else tt(t,l);else l(0,t)},prop:H.define.bind(null,1),context:H.define.bind(null,2),this:H.define.bind(null,3),draw:s({}),buffer:function(t){return R.create(t,34962,!1,!1)},elements:function(t){return P.create(t,!1)},texture:I.create2D,cube:I.createCube,renderbuffer:F.create,framebuffer:U.create,framebufferCube:U.createCube,attributes:m,frame:u,on:function(t,e){var r;switch(t){case"frame":return u(e);case"lost":r=J;break;case"restore":r=Q;break;case"destroy":r=$}return r.push(e),{cancel:function(){for(var t=0;t=r)return a.substr(0,r);for(;r>a.length&&e>1;)1&e&&(a+=t),e>>=1,t+=t;return a=(a+=t).substr(0,r)}},{}],261:[function(t,e,r){"use strict";var n=t("two-product"),a=t("robust-sum"),i=t("robust-subtract"),o=t("robust-scale"),s=6;function l(t,e){for(var r=new Array(t.length-1),n=1;n>1;return["sum(",u(t.slice(0,e)),",",u(t.slice(e)),")"].join("")}function c(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return c(e,t)}function f(t){if(2===t.length)return[["diff(",c(t[0][0],t[1][1]),",",c(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r>1;return["sum(",u(t.slice(0,e)),",",u(t.slice(e)),")"].join("")}function c(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(i<=0)return o;n=a+i}else{if(!(a<0))return o;if(i>=0)return o;n=-(a+i)}var s=3.3306690738754716e-16*n;return o>=s||o<=-s?o:h(t,e,r)},function(t,e,r,n){var a=t[0]-n[0],i=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],u=r[1]-n[1],c=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],p=i*u,g=o*l,v=o*s,m=a*u,y=a*l,b=i*s,x=c*(p-g)+f*(v-m)+h*(y-b),_=7.771561172376103e-16*((Math.abs(p)+Math.abs(g))*Math.abs(c)+(Math.abs(v)+Math.abs(m))*Math.abs(f)+(Math.abs(y)+Math.abs(b))*Math.abs(h));return x>_||-x>_?x:d(t,e,r,n)}];!function(){for(;p.length<=s;)p.push(f(p.length));for(var t=[],r=["slow"],n=0;n<=s;++n)t.push("a"+n),r.push("o"+n);var a=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(n=2;n<=s;++n)a.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");a.push("}var s=new Array(arguments.length);for(var i=0;i0&&o>0||i<0&&o<0)return!1;var s=n(r,t,e),l=n(a,t,e);if(s>0&&l>0||s<0&&l<0)return!1;if(0===i&&0===o&&0===s&&0===l)return function(t,e,r,n){for(var a=0;a<2;++a){var i=t[a],o=e[a],s=Math.min(i,o),l=Math.max(i,o),u=r[a],c=n[a],f=Math.min(u,c),h=Math.max(u,c);if(h=n?(a=f,(l+=1)=n?(a=f,(l+=1)0?1:0}},{}],269:[function(t,e,r){arguments[4][39][0].apply(r,arguments)},{dup:39}],270:[function(t,e,r){"use strict";var n=t("bit-twiddle"),a=t("union-find");function i(t,e){var r=t.length,n=t.length-e.length,a=Math.min;if(n)return n;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return(s=t[0]+t[1]-e[0]-e[1])||a(t[0],t[1])-a(e[0],e[1]);case 3:var i=t[0]+t[1],o=e[0]+e[1];if(s=i+t[2]-(o+e[2]))return s;var s,l=a(t[0],t[1]),u=a(e[0],e[1]);return(s=a(l,t[2])-a(u,e[2]))||a(l+t[2],i)-a(u+e[2],o);default:var c=t.slice(0);c.sort();var f=e.slice(0);f.sort();for(var h=0;h>1,s=i(t[o],e);s<=0?(0===s&&(a=o),r=o+1):s>0&&(n=o-1)}return a}function c(t,e){for(var r=new Array(t.length),a=0,o=r.length;a=t.length||0!==i(t[v],s)););}return r}function f(t,e){if(e<0)return[];for(var r=[],a=(1<>>c&1&&u.push(a[c]);e.push(u)}return s(e)},r.skeleton=f,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function b(t){for(var e=m(t);;){var r=e,n=2*t+1,a=2*(t+1),i=t;if(n0;){var r=y(t);if(r>=0){var n=m(r);if(e0){var t=k[0];return v(0,E-1),E-=1,b(0),t}return-1}function w(t,e){var r=k[t];return u[r]===e?t:(u[r]=-1/0,x(t),_(),u[r]=e,x((E+=1)-1))}function A(t){if(!c[t]){c[t]=!0;var e=s[t],r=l[t];s[r]>=0&&(s[r]=e),l[e]>=0&&(l[e]=r),T[e]>=0&&w(T[e],g(e)),T[r]>=0&&w(T[r],g(r))}}for(var k=[],T=new Array(i),f=0;f>1;f>=0;--f)b(f);for(;;){var C=_();if(C<0||u[C]>r)break;A(C)}for(var S=[],f=0;f=0&&r>=0&&e!==r){var n=T[e],a=T[r];n!==a&&O.push([n,a])}}),a.unique(a.normalize(O)),{positions:S,edges:O}};var n=t("robust-orientation"),a=t("simplicial-complex")},{"robust-orientation":262,"simplicial-complex":270}],273:[function(t,e,r){"use strict";e.exports=function(t,e){var r,i,o,s;if(e[0][0]e[1][0]))return a(e,t);r=e[1],i=e[0]}if(t[0][0]t[1][0]))return-a(t,e);o=t[1],s=t[0]}var l=n(r,i,s),u=n(r,i,o);if(l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;if(l=n(s,o,i),u=n(s,o,r),l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;return i[0]-s[0]};var n=t("robust-orientation");function a(t,e){var r,a,i,o;if(e[0][0]e[1][0])){var s=Math.min(t[0][1],t[1][1]),l=Math.max(t[0][1],t[1][1]),u=Math.min(e[0][1],e[1][1]),c=Math.max(e[0][1],e[1][1]);return lc?s-c:l-c}r=e[1],a=e[0]}t[0][1]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=u(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=u(t.right,e))return l;t=t.left}}return r}function c(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function f(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}s.prototype.castUp=function(t){var e=n.le(this.coordinates,t[0]);if(e<0)return-1;this.slabs[e];var r=u(this.slabs[e],t),a=-1;if(r&&(a=r.value),this.coordinates[e]===t[0]){var s=null;if(r&&(s=r.key),e>0){var c=u(this.slabs[e-1],t);c&&(s?o(c.key,s)>0&&(s=c.key,a=c.value):(a=c.value,s=c.key))}var f=this.horizontal[e];if(f.length>0){var h=n.ge(f,t[1],l);if(h=f.length)return a;d=f[h]}}if(d.start)if(s){var p=i(s[0],s[1],[t[0],d.y]);s[0][0]>s[1][0]&&(p=-p),p>0&&(a=d.index)}else a=d.index;else d.y!==t[1]&&(a=d.index)}}}return a}},{"./lib/order-segments":273,"binary-search-bounds":38,"functional-red-black-tree":153,"robust-orientation":262}],275:[function(t,e,r){!function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function e(r){return function(r,n){var a,i,o,s,l,u,c,f,h,d=1,p=r.length,g="";for(i=0;i=0),s[8]){case"b":a=parseInt(a,10).toString(2);break;case"c":a=String.fromCharCode(parseInt(a,10));break;case"d":case"i":a=parseInt(a,10);break;case"j":a=JSON.stringify(a,null,s[6]?parseInt(s[6]):0);break;case"e":a=s[7]?parseFloat(a).toExponential(s[7]):parseFloat(a).toExponential();break;case"f":a=s[7]?parseFloat(a).toFixed(s[7]):parseFloat(a);break;case"g":a=s[7]?String(Number(a.toPrecision(s[7]))):parseFloat(a);break;case"o":a=(parseInt(a,10)>>>0).toString(8);break;case"s":a=String(a),a=s[7]?a.substring(0,s[7]):a;break;case"t":a=String(!!a),a=s[7]?a.substring(0,s[7]):a;break;case"T":a=Object.prototype.toString.call(a).slice(8,-1).toLowerCase(),a=s[7]?a.substring(0,s[7]):a;break;case"u":a=parseInt(a,10)>>>0;break;case"v":a=a.valueOf(),a=s[7]?a.substring(0,s[7]):a;break;case"x":a=(parseInt(a,10)>>>0).toString(16);break;case"X":a=(parseInt(a,10)>>>0).toString(16).toUpperCase()}t.json.test(s[8])?g+=a:(!t.number.test(s[8])||f&&!s[3]?h="":(h=f?"+":"-",a=a.toString().replace(t.sign,"")),u=s[4]?"0"===s[4]?"0":s[4].charAt(1):" ",c=s[6]-(h+a).length,l=s[6]&&c>0?u.repeat(c):"",g+=s[5]?h+a+l:"0"===u?h+l+a:l+h+a)}return g}(function(e){if(a[e])return a[e];var r,n=e,i=[],o=0;for(;n;){if(null!==(r=t.text.exec(n)))i.push(r[0]);else if(null!==(r=t.modulo.exec(n)))i.push("%");else{if(null===(r=t.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){o|=1;var s=[],l=r[2],u=[];if(null===(u=t.key.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(l=l.substring(u[0].length));)if(null!==(u=t.key_access.exec(l)))s.push(u[1]);else{if(null===(u=t.index_access.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}r[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");i.push(r)}n=n.substring(r[0].length)}return a[e]=i}(r),arguments)}function n(t,r){return e.apply(null,[t].concat(r||[]))}var a=Object.create(null);"undefined"!=typeof r&&(r.sprintf=e,r.vsprintf=n),"undefined"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}()},{}],276:[function(t,e,r){"use strict";var n=t("parenthesis");e.exports=function(t,e,r){if(null==t)throw Error("First argument should be a string");if(null==e)throw Error("Separator should be a string or a RegExp");r?("string"==typeof r||Array.isArray(r))&&(r={ignore:r}):r={},null==r.escape&&(r.escape=!0),null==r.ignore?r.ignore=["[]","()","{}","<>",'""',"''","``","\u201c\u201d","\xab\xbb"]:("string"==typeof r.ignore&&(r.ignore=[r.ignore]),r.ignore=r.ignore.map(function(t){return 1===t.length&&(t+=t),t}));var a=n.parse(t,{flat:!0,brackets:r.ignore}),i=a[0].split(e);if(r.escape){for(var o=[],s=0;s c)|0 },"),"generic"===e&&i.push("getters:[0],");for(var s=[],l=[],u=0;u>>7){");for(var u=0;u<1<<(1<128&&u%128==0){f.length>0&&h.push("}}");var d="vExtra"+f.length;i.push("case ",u>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&u,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;bb)&&!(u&1<<_)!=!(u&1<0&&(T="+"+v[x]+"*c");var M=p[x].length/y*.5,E=.5+m[x]/y*.5;k.push("d"+x+"-"+E+"-"+M+"*("+p[x].join("+")+T+")/("+g[x].join("+")+")")}h.push("a.push([",k.join(),"]);","break;")}i.push("}},"),f.length>0&&h.push("}}");for(var C=[],u=0;u<1<1&&(i=1),i<-1&&(i=-1),a*Math.acos(i)};r.default=function(t){var e=t.px,r=t.py,l=t.cx,u=t.cy,c=t.rx,f=t.ry,h=t.xAxisRotation,d=void 0===h?0:h,p=t.largeArcFlag,g=void 0===p?0:p,v=t.sweepFlag,m=void 0===v?0:v,y=[];if(0===c||0===f)return[];var b=Math.sin(d*a/360),x=Math.cos(d*a/360),_=x*(e-l)/2+b*(r-u)/2,w=-b*(e-l)/2+x*(r-u)/2;if(0===_&&0===w)return[];c=Math.abs(c),f=Math.abs(f);var A=Math.pow(_,2)/Math.pow(c,2)+Math.pow(w,2)/Math.pow(f,2);A>1&&(c*=Math.sqrt(A),f*=Math.sqrt(A));var k=function(t,e,r,n,i,o,l,u,c,f,h,d){var p=Math.pow(i,2),g=Math.pow(o,2),v=Math.pow(h,2),m=Math.pow(d,2),y=p*g-p*m-g*v;y<0&&(y=0),y/=p*m+g*v;var b=(y=Math.sqrt(y)*(l===u?-1:1))*i/o*d,x=y*-o/i*h,_=f*b-c*x+(t+r)/2,w=c*b+f*x+(e+n)/2,A=(h-b)/i,k=(d-x)/o,T=(-h-b)/i,M=(-d-x)/o,E=s(1,0,A,k),C=s(A,k,T,M);return 0===u&&C>0&&(C-=a),1===u&&C<0&&(C+=a),[_,w,E,C]}(e,r,l,u,c,f,g,m,b,x,_,w),T=n(k,4),M=T[0],E=T[1],C=T[2],S=T[3],L=Math.abs(S)/(a/4);Math.abs(1-L)<1e-7&&(L=1);var O=Math.max(Math.ceil(L),1);S/=O;for(var D=0;De[2]&&(e[2]=u[c+0]),u[c+1]>e[3]&&(e[3]=u[c+1]);return e}},{"abs-svg-path":11,assert:16,"is-svg-path":212,"normalize-svg-path":281,"parse-svg-path":227}],281:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=[],o=0,s=0,l=0,u=0,c=null,f=null,h=0,d=0,p=0,g=t.length;p4?(o=v[v.length-4],s=v[v.length-3]):(o=h,s=d),r.push(v)}return r};var n=t("svg-arc-to-cubic-bezier");function a(t,e,r,n){return["C",t,e,r,n,r,n]}function i(t,e,r,n,a,i){return["C",t/3+2/3*r,e/3+2/3*n,a/3+2/3*r,i/3+2/3*n,a,i]}},{"svg-arc-to-cubic-bezier":279}],282:[function(t,e,r){"use strict";var n=t("svg-path-bounds"),a=t("parse-svg-path"),i=t("draw-svg-path"),o=t("is-svg-path"),s=t("bitmap-sdf"),l=document.createElement("canvas"),u=l.getContext("2d");e.exports=function(t,e){if(!o(t))throw Error("Argument should be valid svg path string");e||(e={});var r,c;e.shape?(r=e.shape[0],c=e.shape[1]):(r=l.width=e.w||e.width||200,c=l.height=e.h||e.height||200);var f=Math.min(r,c),h=e.stroke||0,d=e.viewbox||e.viewBox||n(t),p=[r/(d[2]-d[0]),c/(d[3]-d[1])],g=Math.min(p[0]||0,p[1]||0)/2;u.fillStyle="black",u.fillRect(0,0,r,c),u.fillStyle="white",h&&("number"!=typeof h&&(h=1),u.strokeStyle=h>0?"white":"black",u.lineWidth=Math.abs(h));if(u.translate(.5*r,.5*c),u.scale(g,g),function(){var t=document.createElement("canvas").getContext("2d");t.canvas.width=t.canvas.height=1;var e=new Path2D("M0,0h1v1h-1v-1Z");t.fillStyle="black",t.fill(e);var r=t.getImageData(0,0,1,1);return r&&r.data&&255===r.data[3]}()){var v=new Path2D(t);u.fill(v),h&&u.stroke(v)}else{var m=a(t);i(u,m),u.fill(),h&&u.stroke()}return u.setTransform(1,0,0,1,0,0),s(u,{cutoff:null!=e.cutoff?e.cutoff:.5,radius:null!=e.radius?e.radius:.5*f})}},{"bitmap-sdf":40,"draw-svg-path":89,"is-svg-path":212,"parse-svg-path":227,"svg-path-bounds":280}],283:[function(t,e,r){(function(r){"use strict";e.exports=function t(e,r,a){var a=a||{};var o=i[e];o||(o=i[e]={" ":{data:new Float32Array(0),shape:.2}});var s=o[r];if(!s)if(r.length<=1||!/\d/.test(r))s=o[r]=function(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),a=0,i=0,o=0;o0&&(f+=.02);for(var d=new Float32Array(c),p=0,g=-.5*f,h=0;h1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=L(t,360),e=L(e,100),r=L(r,100),0===e)n=a=i=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;n=o(l,s,t+1/3),a=o(l,s,t),i=o(l,s,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(e.h,l,c),f=!0,h="hsl"),e.hasOwnProperty("a")&&(i=e.a));var d,p,g;return i=S(i),{ok:f,format:e.format||h,r:o(255,s(a.r,0)),g:o(255,s(a.g,0)),b:o(255,s(a.b,0)),a:i}}(e);this._originalInput=e,this._r=c.r,this._g=c.g,this._b=c.b,this._a=c.a,this._roundA=i(100*this._a)/100,this._format=l.format||c.format,this._gradientType=l.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=c.ok,this._tc_id=a++}function c(t,e,r){t=L(t,255),e=L(e,255),r=L(r,255);var n,a,i=s(t,e,r),l=o(t,e,r),u=(i+l)/2;if(i==l)n=a=0;else{var c=i-l;switch(a=u>.5?c/(2-i-l):c/(i+l),i){case t:n=(e-r)/c+(e>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(u(n));return i}function M(t,e){e=e||6;for(var r=u(t).toHsv(),n=r.h,a=r.s,i=r.v,o=[],s=1/e;e--;)o.push(u({h:n,s:a,v:i})),i=(i+s)%1;return o}u.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,a=this.toRgb();return e=a.r/255,r=a.g/255,n=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=S(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=c(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return h(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,a){var o=[R(i(t).toString(16)),R(i(e).toString(16)),R(i(r).toString(16)),R(z(n))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*L(this._r,255))+"%",g:i(100*L(this._g,255))+"%",b:i(100*L(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*L(this._r,255))+"%, "+i(100*L(this._g,255))+"%, "+i(100*L(this._b,255))+"%)":"rgba("+i(100*L(this._r,255))+"%, "+i(100*L(this._g,255))+"%, "+i(100*L(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(C[h(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+d(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=u(t);r="#"+d(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return u(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(m,arguments)},brighten:function(){return this._applyModification(y,arguments)},darken:function(){return this._applyModification(b,arguments)},desaturate:function(){return this._applyModification(p,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(T,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(M,arguments)},splitcomplement:function(){return this._applyCombination(k,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(A,arguments)}},u.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:P(t[n]));t=r}return u(t,e)},u.equals=function(t,e){return!(!t||!e)&&u(t).toRgbString()==u(e).toRgbString()},u.random=function(){return u.fromRatio({r:l(),g:l(),b:l()})},u.mix=function(t,e,r){r=0===r?0:r||50;var n=u(t).toRgb(),a=u(e).toRgb(),i=r/100;return u({r:(a.r-n.r)*i+n.r,g:(a.g-n.g)*i+n.g,b:(a.b-n.b)*i+n.b,a:(a.a-n.a)*i+n.a})},u.readability=function(e,r){var n=u(e),a=u(r);return(t.max(n.getLuminance(),a.getLuminance())+.05)/(t.min(n.getLuminance(),a.getLuminance())+.05)},u.isReadable=function(t,e,r){var n,a,i=u.readability(t,e);switch(a=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},u.mostReadable=function(t,e,r){var n,a,i,o,s=null,l=0;a=(r=r||{}).includeFallbackColors,i=r.level,o=r.size;for(var c=0;cl&&(l=n,s=u(e[c]));return u.isReadable(t,s,{level:i,size:o})||!a?s:(r.includeFallbackColors=!1,u.mostReadable(t,["#fff","#000"],r))};var E=u.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},C=u.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(E);function S(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function L(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,s(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function O(t){return o(1,s(0,t))}function D(t){return parseInt(t,16)}function R(t){return 1==t.length?"0"+t:""+t}function P(t){return t<=1&&(t=100*t+"%"),t}function z(e){return t.round(255*parseFloat(e)).toString(16)}function I(t){return D(t)/255}var F,N,B,j=(N="[\\s|\\(]+("+(F="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",B="[\\s|\\(]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",{CSS_UNIT:new RegExp(F),rgb:new RegExp("rgb"+N),rgba:new RegExp("rgba"+B),hsl:new RegExp("hsl"+N),hsla:new RegExp("hsla"+B),hsv:new RegExp("hsv"+N),hsva:new RegExp("hsva"+B),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function U(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=u:window.tinycolor=u}(Math)},{}],285:[function(t,e,r){"use strict";function n(t){if(t instanceof Float32Array)return t;if("number"==typeof t)return new Float32Array([t])[0];var e=new Float32Array(t);return e.set(t),e}e.exports=n,e.exports.float32=e.exports.float=n,e.exports.fract32=e.exports.fract=function(t){if("number"==typeof t)return n(t-n(t));for(var e=n(t),r=0,a=e.length;r0?r.pop():new ArrayBuffer(t)}function h(t){return new Uint8Array(f(t),0,t)}function d(t){return new Uint16Array(f(2*t),0,t)}function p(t){return new Uint32Array(f(4*t),0,t)}function g(t){return new Int8Array(f(t),0,t)}function v(t){return new Int16Array(f(2*t),0,t)}function m(t){return new Int32Array(f(4*t),0,t)}function y(t){return new Float32Array(f(4*t),0,t)}function b(t){return new Float64Array(f(8*t),0,t)}function x(t){return o?new Uint8ClampedArray(f(t),0,t):h(t)}function _(t){return new DataView(f(t),0,t)}function w(t){t=a.nextPow2(t);var e=a.log2(t),r=u[e];return r.length>0?r.pop():new n(t)}r.free=function(t){if(n.isBuffer(t))u[a.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|a.log2(e);l[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=function(t){c(t.buffer)},r.freeArrayBuffer=c,r.freeBuffer=function(t){u[a.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return f(t);switch(e){case"uint8":return h(t);case"uint16":return d(t);case"uint32":return p(t);case"int8":return g(t);case"int16":return v(t);case"int32":return m(t);case"float":case"float32":return y(t);case"double":case"float64":return b(t);case"uint8_clamped":return x(t);case"buffer":return w(t);case"data":case"dataview":return _(t);default:return null}return null},r.mallocArrayBuffer=f,r.mallocUint8=h,r.mallocUint16=d,r.mallocUint32=p,r.mallocInt8=g,r.mallocInt16=v,r.mallocInt32=m,r.mallocFloat32=r.mallocFloat=y,r.mallocFloat64=r.mallocDouble=b,r.mallocUint8Clamped=x,r.mallocDataView=_,r.mallocBuffer=w,r.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,l[t].length=0,u[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":39,buffer:51,dup:91}],291:[function(t,e,r){"use strict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var o=3*n;t.height= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":79}],302:[function(t,e,r){"use strict";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t("./lib/zc-core")},{"./lib/zc-core":301}],303:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],304:[function(t,e,r){"use strict";var n=t("./arrow_paths"),a=t("../../plots/font_attributes"),i=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:a({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",i.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",i.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:a({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":478,"../../plots/cartesian/constants":494,"../../plots/font_attributes":515,"./arrow_paths":303}],305:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=a.getFromId(t,e.xref),n=a.getFromId(t,e.yref);e._extremes={},r&&s(e,r),n&&s(e,n)})}function s(t,e){var r,n=e._id,i=n.charAt(0),o=t[i],s=t["a"+i],l=t[i+"ref"],u=t["a"+i+"ref"],c=t["_"+i+"padplus"],f=t["_"+i+"padminus"],h={x:1,y:-1}[i]*t[i+"shift"],d=3*t.arrowsize*t.arrowwidth||0,p=d+h,g=d-h,v=3*t.startarrowsize*t.arrowwidth||0,m=v+h,y=v-h;if(u===l){var b=a.findExtremes(e,[e.r2c(o)],{ppadplus:p,ppadminus:g}),x=a.findExtremes(e,[e.r2c(s)],{ppadplus:Math.max(c,m),ppadminus:Math.max(f,y)});r={min:[b.min[0],x.min[0]],max:[b.max[0],x.max[0]]}}else m=s?m+s:m,y=s?y-s:y,r=a.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(c,p,m),ppadminus:Math.max(f,g,y)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([i,o],t)}},{"../../lib":441,"../../plots/cartesian/axes":488,"./draw":310}],306:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,a,i,o,l,u,c=t._fullLayout.annotations,f=[],h=[],d=[],p=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,s,l=o(t,e),u=l.on,c=l.off.concat(l.explicitOff),f={},h=t._fullLayout.annotations;if(!u.length&&!c.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var V=!1,q=["x","y"],G=0;G1)&&(K===$?((lt=tt.r2fraction(e["a"+Q]))<0||lt>1)&&(V=!0):V=!0),X=tt._offset+tt.r2p(e[Q]),Z=.5}else"x"===Q?(Y=e[Q],X=x.l+x.w*Y):(Y=1-e[Q],X=x.t+x.h*Y),Z=e.showarrow?.5:Y;if(e.showarrow){st.head=X;var ut=e["a"+Q];J=rt*H(.5,e.xanchor)-nt*H(.5,e.yanchor),K===$?(st.tail=tt._offset+tt.r2p(ut),W=J):(st.tail=X+ut,W=J+ut),st.text=st.tail+J;var ct=b["x"===Q?"width":"height"];if("paper"===$&&(st.head=o.constrain(st.head,1,ct-1)),"pixel"===K){var ft=-Math.max(st.tail-3,st.text),ht=Math.min(st.tail+3,st.text)-ct;ft>0?(st.tail+=ft,st.text+=ft):ht>0&&(st.tail-=ht,st.text-=ht)}st.tail+=ot,st.head+=ot}else W=J=at*H(Z,it),st.text=X+J;st.text+=ot,J+=ot,W+=ot,e["_"+Q+"padplus"]=at/2+W,e["_"+Q+"padminus"]=at/2-W,e["_"+Q+"size"]=at,e["_"+Q+"shift"]=J}if(t._dragging||!V){var dt=0,pt=0;if("left"!==e.align&&(dt=(w-m)*("center"===e.align?.5:1)),"top"!==e.valign&&(pt=(D-y)*("middle"===e.valign?.5:1)),c)n.select("svg").attr({x:I+dt-1,y:I+pt}).call(u.setClipUrl,N?M:null);else{var gt=I+pt-p.top,vt=I+dt-p.left;U.call(f.positionText,vt,gt).call(u.setClipUrl,N?M:null)}B.select("rect").call(u.setRect,I,I,w,D),F.call(u.setRect,P/2,P/2,z-P,j-P),R.call(u.setTranslate,Math.round(E.x.text-z/2),Math.round(E.y.text-j/2)),L.attr({transform:"rotate("+C+","+E.x.text+","+E.y.text+")"});var mt,yt=function(r,n){S.selectAll(".annotation-arrow-g").remove();var c=E.x.head,f=E.y.head,h=E.x.tail+r,p=E.y.tail+n,m=E.x.text+r,y=E.y.text+n,b=o.rotationXYMatrix(C,m,y),w=o.apply2DTransform(b),M=o.apply2DTransform2(b),O=+F.attr("width"),D=+F.attr("height"),P=m-.5*O,z=P+O,I=y-.5*D,N=I+D,B=[[P,I,P,N],[P,N,z,N],[z,N,z,I],[z,I,P,I]].map(M);if(!B.reduce(function(t,e){return t^!!o.segmentsIntersect(c,f,c+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){B.forEach(function(t){var e=o.segmentsIntersect(h,p,c,f,t[0],t[1],t[2],t[3]);e&&(h=e.x,p=e.y)});var j=e.arrowwidth,U=e.arrowcolor,H=e.arrowside,V=S.append("g").style({opacity:l.opacity(U)}).classed("annotation-arrow-g",!0),q=V.append("path").attr("d","M"+h+","+p+"L"+c+","+f).style("stroke-width",j+"px").call(l.stroke,l.rgb(U));if(g(q,H,e),_.annotationPosition&&q.node().parentNode&&!i){var G=c,X=f;if(e.standoff){var W=Math.sqrt(Math.pow(c-h,2)+Math.pow(f-p,2));G+=e.standoff*(h-c)/W,X+=e.standoff*(p-f)/W}var Y,Z,J=V.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(h-G)+","+(p-X),transform:"translate("+G+","+X+")"}).style("stroke-width",j+6+"px").call(l.stroke,"rgba(0,0,0,0)").call(l.fill,"rgba(0,0,0,0)");d.init({element:J.node(),gd:t,prepFn:function(){var t=u.getTranslate(R);Y=t.x,Z=t.y,s&&s.autorange&&A(s._name+".autorange",!0),v&&v.autorange&&A(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(Y,Z),a=n[0]+t,i=n[1]+r;R.call(u.setTranslate,a,i),k("x",s?s.p2r(s.r2p(e.x)+t):e.x+t/x.w),k("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/x.h),e.axref===e.xref&&k("ax",s.p2r(s.r2p(e.ax)+t)),e.ayref===e.yref&&k("ay",v.p2r(v.r2p(e.ay)+r)),V.attr("transform","translate("+t+","+r+")"),L.attr({transform:"rotate("+C+","+a+","+i+")"})},doneFn:function(){a.call("relayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&yt(0,0),O)d.init({element:R.node(),gd:t,prepFn:function(){mt=L.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?k("ax",s.p2r(s.r2p(e.ax)+t)):k("ax",e.ax+t),e.ayref===e.yref?k("ay",v.p2r(v.r2p(e.ay)+r)):k("ay",e.ay+r),yt(t,r);else{if(i)return;var a,o;if(s)a=s.p2r(s.r2p(e.x)+t);else{var l=e._xsize/x.w,u=e.x+(e._xshift-e.xshift)/x.w-l/2;a=d.align(u+t/x.w,l,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var c=e._ysize/x.h,f=e.y-(e._yshift+e.yshift)/x.h-c/2;o=d.align(f-r/x.h,c,0,1,e.yanchor)}k("x",a),k("y",o),s&&v||(n=d.getCursor(s?.5:a,v?.5:o,e.xanchor,e.yanchor))}L.attr({transform:"translate("+t+","+r+")"+mt}),h(R,n)},doneFn:function(){h(R),a.call("relayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else R.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,m=f.backoff*d+r.standoff,y=h.backoff*p+r.startstandoff;if("line"===c.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},s={x:+t.attr("x2"),y:+t.attr("y2")};var b=o.x-s.x,x=o.y-s.y;if(u=(l=Math.atan2(x,b))+Math.PI,m&&y&&m+y>Math.sqrt(b*b+x*x))return void O();if(m){if(m*m>b*b+x*x)return void O();var _=m*Math.cos(l),w=m*Math.sin(l);s.x+=_,s.y+=w,t.attr({x2:s.x,y2:s.y})}if(y){if(y*y>b*b+x*x)return void O();var A=y*Math.cos(l),k=y*Math.sin(l);o.x-=A,o.y-=k,t.attr({x1:o.x,y1:o.y})}}else if("path"===c.nodeName){var T=c.getTotalLength(),M="";if(T1){u=!0;break}}u?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*r[0],e.yaxis.r2l(l.y)*r[1],e.zaxis.r2l(l.z)*r[2]]),n(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":522,"../annotations/draw":310}],317:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var i=r.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(n(t))},i.opacity=function(t){return t?n(t).getAlpha():0},i.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},i.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var a=n(e||l).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-r.a)+r.r*r.a,g:i.g*(1-r.a)+r.g*r.a,b:i.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},i.contrast=function(t,e,r){var a=n(t);return 1!==a.getAlpha()&&(a=n(i.combine(t,l))),(a.isDark()?e?a.lighten(e):l:r?a.darken(r):s).toString()},i.stroke=function(t,e){var r=n(e);t.style({stroke:i.tinyRGB(r),"stroke-opacity":r.getAlpha()})},i.fill=function(t,e){var r=n(e);t.style({fill:i.tinyRGB(r),"fill-opacity":r.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,r,n,a,o=Object.keys(t);for(e=0;e0?E>=P:E<=P));C++)E>I&&E0?E>=P:E<=P));C++)E>S[0]&&E1){var it=Math.pow(10,Math.floor(Math.log(at)/Math.LN10));rt*=it*u.roundUp(at/it,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(tt.tick0=0)}tt.dtick=rt}tt.domain=[J+W,J+q-W],tt.setScale();var ot=u.ensureSingle(v._infolayer,"g",e,function(t){t.classed(k.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(k.cbbg,!0),t.append("g").classed(k.cbfills,!0),t.append("g").classed(k.cblines,!0),t.append("g").classed(k.cbaxis,!0).classed(k.crisp,!0),t.append("g").classed(k.cbtitleunshift,!0).append("g").classed(k.cbtitle,!0),t.append("rect").classed(k.cboutline,!0),t.select(".cbtitle").datum(0)})});ot.attr("transform","translate("+Math.round(A.l)+","+Math.round(A.t)+")");var st=ot.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(A.l)+",-"+Math.round(A.t)+")");tt._axislayer=ot.select(".cbaxis");var lt=0;if(-1!==["top","bottom"].indexOf(r.titleside)){var ut,ct=A.l+(r.x+G)*A.w,ft=tt.titlefont.size;ut="top"===r.titleside?(1-(J+q-W))*A.h+A.t+3+.75*ft:(1-(J+W))*A.h+A.t-3-.25*ft,mt(tt._id+"title",{attributes:{x:ct,y:ut,"text-anchor":"start"}})}var ht,dt,pt,gt=u.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.titleside)){var i=ot.select(".cbtitle"),o=i.select("text"),l=[-r.outlinewidth/2,r.outlinewidth/2],c=i.select(".h"+tt._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*m),c?(lt=h.bBox(c).height)>f&&(l[1]-=(lt-f)/2):o.node()&&!o.classed(k.jsPlaceholder)&&(lt=h.bBox(o.node()).height),lt){if(lt+=5,"top"===r.titleside)tt.domain[1]-=lt/A.h,l[1]*=-1;else{tt.domain[0]+=lt/A.h;var d=g.lineCount(o);l[1]+=(1-d)*f}i.attr("transform","translate("+l+")"),tt.setScale()}}ot.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(A.h*(1-tt.domain[1]))+")"),tt._axislayer.attr("transform","translate(0,"+Math.round(-A.t)+")");var p=ot.select(".cbfills").selectAll("rect.cbfill").data(O);p.enter().append("rect").classed(k.cbfill,!0).style("stroke","none"),p.exit().remove();var y=S.map(tt.c2p).map(Math.round).sort(function(t,e){return t-e});p.each(function(i,o){var s=[0===o?S[0]:(O[o]+O[o-1])/2,o===O.length-1?S[1]:(O[o]+O[o+1])/2].map(tt.c2p).map(Math.round);s[1]=u.constrain(s[1]+(s[1]>s[0])?1:-1,y[0],y[1]);var l=n.select(this).attr({x:Y,width:Math.max(U,2),y:n.min(s),height:Math.max(n.max(s)-n.min(s),2)});if(r.fillgradient)h.gradient(l,t,e,"vertical",r.fillgradient,"fill");else{var c=R(i).replace("e-","");l.attr("fill",a(c).toHexString())}});var b=ot.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?L:[]);return b.enter().append("path").classed(k.cbline,!0),b.exit().remove(),b.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round(tt.c2p(t))+r.line.width/2%1)+"h"+U).call(h.lineGroupStyle,r.line.width,D(t),r.line.dash)}),tt._axislayer.selectAll("g."+tt._id+"tick,path").remove(),tt._pos=Y+U+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),tt.side="right",u.syncOrAsync([function(){return s.doTicksSingle(t,tt,!0)},function(){if(-1===["top","bottom"].indexOf(r.titleside)){var e=tt.titlefont.size,a=tt._offset+tt._length/2,i=A.l+(tt.position||0)*A.w+("right"===tt.side?10+e*(tt.showticklabels?1:.5):-10-e*(tt.showticklabels?.5:0));mt("h"+tt._id+"title",{avoid:{selection:n.select(t).selectAll("g."+tt._id+"tick"),side:r.titleside,offsetLeft:A.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var n=U+r.outlinewidth/2+h.bBox(tt._axislayer.node()).width;if((N=st.select("text")).node()&&!N.classed(k.jsPlaceholder)){var a,o=st.select(".h"+tt._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(r.titleside)?h.bBox(o).width:h.bBox(st.node()).right-Y-A.l,n=Math.max(n,a)}var s=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,l=Q-$;ot.select(".cbbg").attr({x:Y-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:$-X,width:Math.max(s,2),height:Math.max(l+2*X,2)}).call(d.fill,r.bgcolor).call(d.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),ot.selectAll(".cboutline").attr({x:Y,y:$+r.ypad+("top"===r.titleside?lt:0),width:Math.max(U,2),height:Math.max(l-2*r.ypad-lt,2)}).call(d.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var u=({center:.5,right:1}[r.xanchor]||0)*s;ot.attr("transform","translate("+(A.l-u)+","+A.t+")");var c={},f=y[r.yanchor],p=b[r.yanchor];"pixels"===r.lenmode?(c.y=r.y,c.t=l*f,c.b=l*p):(c.t=c.b=0,c.yt=r.y+r.len*f,c.yb=r.y-r.len*p);var g=y[r.xanchor],v=b[r.xanchor];if("pixels"===r.thicknessmode)c.x=r.x,c.l=s*g,c.r=s*v;else{var m=s-U;c.l=m*g,c.r=m*v,c.xl=r.x-r.thickness*g,c.xr=r.x+r.thickness*v}i.autoMargin(t,e,c)}],t);if(gt&>.then&&(t._promises||[]).push(gt),t._context.edits.colorbarPosition)l.init({element:ot.node(),gd:t,prepFn:function(){ht=ot.attr("transform"),f(ot)},moveFn:function(t,e){ot.attr("transform",ht+" translate("+t+","+e+")"),dt=l.align(Z+t/A.w,H,0,1,r.xanchor),pt=l.align(J-e/A.h,q,0,1,r.yanchor);var n=l.getCursor(dt,pt,r.xanchor,r.yanchor);f(ot,n)},doneFn:function(){f(ot),void 0!==dt&&void 0!==pt&&o.call("restyle",t,{"colorbar.x":dt,"colorbar.y":pt},M().index)}});return gt}function vt(t,e){return u.coerce(K,tt,w,t,e)}function mt(e,r){var n=M(),a="colorbar.title",i=n._module.colorbar.container;i&&(a=i+"."+a);var o={propContainer:tt,propName:a,traceIndex:n.index,placeholder:v._dfltTitle.colorbar,containerGroup:ot.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;ot.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,c(o,r||{}))}v._infolayer.selectAll("g."+e).remove()}function M(){var r,n,a=e.substr(2);for(r=0;r=0?a.Reds:a.Blues,s.reversescale?i(y):y),l.autocolorscale||f("autocolorscale",!1))}},{"../../lib":441,"./flip_scale":331,"./scales":338}],328:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":338}],329:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,u,c){var f,h=c.prefix,d=c.cLetter,p=h.slice(0,h.length-1),g=h?a.nestedProperty(t,p).get()||{}:t,v=h?a.nestedProperty(e,p).get()||{}:e,m=g[d+"min"],y=g[d+"max"],b=g.colorscale;u(h+d+"auto",!(n(m)&&n(y)&&m=0;a--,i++)e=t[a],n[i]=[1-e[0],e[1]];return n}},{}],332:[function(t,e,r){"use strict";var n=t("./scales"),a=t("./default_scale"),i=t("./is_valid_scale_array");e.exports=function(t,e){if(e||(e=a),!t)return e;function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return"string"==typeof t&&(r(),"string"==typeof t&&r()),i(t)?t:e}},{"./default_scale":328,"./is_valid_scale_array":336,"./scales":338}],333:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../lib"),i=t("./is_valid_scale");e.exports=function(t,e){var r=e?a.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(a.isArrayOrTypedArray(o))for(var l=0;l4/3-s?o:s}},{}],340:[function(t,e,r){"use strict";var n=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,i){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:n.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":441}],341:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),s=t("../../lib"),l=t("../../plots/cartesian/constants"),u=t("../../constants/interactions"),c=e.exports={};c.align=t("./align"),c.getCursor=t("./cursor");var f=t("./unhover");function h(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function d(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}c.unhover=f.wrapped,c.unhoverRaw=f.raw,c.init=function(t){var e,r,n,f,p,g,v,m,y=t.gd,b=1,x=u.DBLCLICKDELAY,_=t.element;y._mouseDownTime||(y._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=A,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=A,_.addEventListener("touchstart",A,{passive:!1})):_.ontouchstart=A;var w=t.clampFn||function(t,e,r){return Math.abs(t)x&&(b=Math.max(b-1,1)),y._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(b,g),!m){var r;try{r=new MouseEvent("click",e)}catch(t){var n=d(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(y),y._dragged=!1}else y._dragged=!1}},c.coverSlip=h},{"../../constants/interactions":419,"../../lib":441,"../../plots/cartesian/constants":494,"../../registry":532,"./align":339,"./cursor":340,"./unhover":342,"has-hover":200,"has-passive-events":201,"mouse-event-offset":215}],342:[function(t,e,r){"use strict";var n=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,r){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,r)},s.raw=function(t,e){var r=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":431,"../../lib/get_graph_div":436,"../../lib/throttle":466,"../fx/constants":356}],343:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],344:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),s=t("../color"),l=t("../colorscale"),u=t("../../lib"),c=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../constants/alignment").LINE_SPACING,d=t("../../constants/interactions").DESELECTDIM,p=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){u.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,a){t.call(v.setPosition,e,r).call(v.setSize,n,a)},v.translatePoint=function(t,e,r,n){var i=r.c2p(t.x),o=n.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var a=n.select(this);v.translatePoint(t,a,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,a,i){e.attr("display",r.isPtWithinRange(t,a)&&n.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,s=i.ycalendar,l="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(l).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,a,o,s)})})}},v.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=r||i.width||0,l=a||i.dash||"";s.stroke(e,n||i.color),v.dashLine(e,l,o)},v.lineGroupStyle=function(t,e,r,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,l=a||i.dash||"";n.select(this).call(s.stroke,r||i.color).call(v.dashLine,l,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(s.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){n.select(this).call(s.fill,t[0].trace.fillcolor)})};var m=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(m).forEach(function(t){var e=m[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var y=v.symbolNames.length,b="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function x(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?b:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=y||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},A=n.format("~.1f"),k={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,a,o,l){for(var c=o.length,f=k[a],h=new Array(c),d=0;d=100,e.attr("d",x(c,l))}var f,h,d,p=!1;if(t.so)d=o.outlierwidth,h=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;d=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,h="mlc"in t?t.mlcc=n.lineScale(t.mlc):u.isArrayOrTypedArray(o.color)?s.defaultLine:o.color,u.isArrayOrTypedArray(i.color)&&(f=s.defaultLine,p=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):i.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(s.stroke,f).style({"stroke-width":(d||1)+"px",fill:"none"});else{e.style("stroke-width",d+"px");var m=i.gradient,y=t.mgt;if(y?p=!0:y=m&&m.type,Array.isArray(y)&&(y=y[0],k[y]||(y=0)),y&&"none"!==y){var b=t.mgc;b?p=!0:b=m.color;var _=r.uid;p&&(_+="-"+t.i),v.gradient(e,a,_,y,[[0,b],[1,f]],"fill")}else s.fill(e,f);d&&s.stroke(e,h)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=p.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&u.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.marker||{},i=r.marker||{},s=n.marker||{},l=a.opacity,c=i.opacity,f=s.opacity,h=void 0!==c,p=void 0!==f;(u.isArrayOrTypedArray(l)||h||p)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?h?c:e:p?f:d*e});var g=a.color,v=i.color,m=s.color;(v||m)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:m||e});var y=a.size,b=i.size,x=s.size,_=void 0!==b,w=void 0!==x;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||y/2;return t.selected?_?b/2:e:w?x/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.textfont||{},i=r.textfont||{},o=n.textfont||{},l=a.color,u=i.color,c=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||l;return t.selected?u||e:c||(u?e:s.addOpacity(e,d))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];r.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&i.push(function(t,e){s.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&i.push(function(t,e){var n=e.mx||a.symbol||0,i=r.selectedSizeFn(e);t.attr("d",x(v.symbolNumber(n),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=n.select(this),o=u.extractOption(t,e,"tx","text");if(o||0===o){var s=t.tp||e.textposition,l=E(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,l,f).text(o).call(c.convertToTspans,r).call(M,s,l,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=n.select(this),i=r.selectedTextColorFn(t),o=t.tp||e.textposition,l=E(t,e);s.fill(a,i),M(a,o,l,t.mrc2||t.mrc)})}};var C=.5;function S(t,e,r,a){var i=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],u=Math.pow(i*i+o*o,C/2),c=Math.pow(s*s+l*l,C/2),f=(c*c*i-u*u*s)*a,h=(c*c*o-u*u*l)*a,d=3*c*(u+c),p=3*u*(u+c);return[[n.round(e[0]+(d&&f/d),2),n.round(e[1]+(d&&h/d),2)],[n.round(e[0]-(p&&f/p),2),n.round(e[1]-(p&&h/p),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],a=[];for(r=1;r=1e4&&(v.savedBBoxes={},D=0),r&&(v.savedBBoxes[r]=m),D++,u.extendFlat({},m)},v.setClipUrl=function(t,e){if(e){if(void 0===v.baseUrl){var r=n.select("base");r.size()&&r.attr("href")?v.baseUrl=window.location.href.split("#")[0]:v.baseUrl=""}t.attr("clip-path","url("+v.baseUrl+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||0,r=r||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+r+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||1,r=r||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+r+")").trim(),t[a]("transform",i),i};var P=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(P,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var z=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,a=n.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),s=parseFloat(i.attr("y")||0),l=(a.attr("transform")||"").match(z);t=1===e&&1===r?[]:["translate("+o+","+s+")","scale("+e+","+r+")","translate("+-o+","+-s+")"],l&&t.push(l),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":417,"../../constants/interactions":419,"../../constants/xmlns_namespaces":421,"../../lib":441,"../../lib/svg_text_utils":465,"../../registry":532,"../../traces/scatter/make_bubble_size_func":609,"../../traces/scatter/subtypes":616,"../color":319,"../colorscale":334,"./symbol_defs":345,d3:85,"fast-isnumeric":149,tinycolor2:284}],345:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+a+i+a+i+o+i+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),a=n.round(-t,2),i=n.round(-.309*t,2);return"M"+e+","+i+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+r+"V"+r+"L0,"+e+"L-"+a+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+a+"H"+r+"L"+e+",0L"+r+",-"+a+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),a=n.round(.951*e,2),i=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(-.309*e,2),u=n.round(.118*e,2),c=n.round(.809*e,2);return"M"+r+","+l+"H"+a+"L"+i+","+u+"L"+o+","+c+"L0,"+n.round(.382*e,2)+"L-"+o+","+c+"L-"+i+","+u+"L-"+a+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),a=n.round(.76*t,2);return"M-"+a+",0l-"+r+",-"+e+"h"+a+"l"+r+",-"+e+"l"+r+","+e+"h"+a+"l-"+r+","+e+"l"+r+","+e+"h-"+a+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+a+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+a+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:85}],346:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],347:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function s(t,e,r,a){var s=e["error_"+a]||{},l=[];if(s.visible&&-1!==["linear","log"].indexOf(r.type)){for(var u=o(s),c=0;c0;t.each(function(t){var c,f=t[0].trace,h=f.error_x||{},d=f.error_y||{};f.ids&&(c=function(t){return t.id});var p=o.hasMarkers(f)&&f.marker.maxdisplayed>0;d.visible||h.visible||(t=[]);var g=n.select(this).selectAll("g.errorbar").data(t,c);if(g.exit().remove(),t.length){h.visible||g.selectAll("path.xerror").remove(),d.visible||g.selectAll("path.yerror").remove(),g.style("opacity",1);var v=g.enter().append("g").classed("errorbar",!0);u&&v.style("opacity",0).transition().duration(r.duration).style("opacity",1),i.setClipUrl(g,e.layerClipId),g.each(function(t){var e=n.select(this),i=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,s,l);if(!p||t.vis){var o,c=e.select("path.yerror");if(d.visible&&a(i.x)&&a(i.yh)&&a(i.ys)){var f=d.width;o="M"+(i.x-f)+","+i.yh+"h"+2*f+"m-"+f+",0V"+i.ys,i.noYS||(o+="m-"+f+",0h"+2*f),!c.size()?c=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):u&&(c=c.transition().duration(r.duration).ease(r.easing)),c.attr("d",o)}else c.remove();var g=e.select("path.xerror");if(h.visible&&a(i.y)&&a(i.xh)&&a(i.xs)){var v=(h.copy_ystyle?d:h).width;o="M"+i.xh+","+(i.y-v)+"v"+2*v+"m0,-"+v+"H"+i.xs,i.noXS||(o+="m0,-"+v+"v"+2*v),!g.size()?g=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):u&&(g=g.transition().duration(r.duration).ease(r.easing)),g.attr("d",o)}else g.remove()}})}})}},{"../../traces/scatter/subtypes":616,"../drawing":344,d3:85,"fast-isnumeric":149}],352:[function(t,e,r){"use strict";var n=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},i=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(a.stroke,r.color),i.copy_ystyle&&(i=r),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":319,d3:85}],353:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":515}],354:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry");function i(t,e,r,a){a=a||n.identity,Array.isArray(t)&&(e[0][r]=a(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var s=0;s=0&&r.index-1&&o.length>b&&(o=b>3?o.substr(0,b-3)+"...":o.substr(0,b))}void 0!==t.zLabel?(void 0!==t.xLabel&&(u+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(u+="y: "+t.yLabel+"
"),u+=(u?"z: ":"")+t.zLabel):L&&t[a+"Label"]===k?u=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(u=t.yLabel):u=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(u+=(u?"
":"")+t.text),void 0!==t.extraText&&(u+=(u?"
":"")+t.extraText),""===u&&(""===o&&e.remove(),u=o);var x=e.select("text.nums").call(c.font,t.fontFamily||p,t.fontSize||g,t.fontColor||y).text(u).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),_=e.select("text.name"),T=0;o&&o!==u?(_.call(c.font,t.fontFamily||p,t.fontSize||g,v).text(o).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),T=_.node().getBoundingClientRect().width+2*A):(_.remove(),e.select("rect").remove()),e.select("path").style({fill:d,stroke:y});var M,O,D=x.node().getBoundingClientRect(),R=t.xa._offset+(t.x0+t.x1)/2,P=t.ya._offset+(t.y0+t.y1)/2,z=Math.abs(t.x1-t.x0),I=Math.abs(t.y1-t.y0),F=D.width+w+A+T;t.ty0=E-D.top,t.bx=D.width+2*A,t.by=D.height+2*A,t.anchor="start",t.txwidth=D.width,t.tx2width=T,t.offset=0,i?(t.pos=R,M=P+I/2+F<=S,O=P-I/2-F>=0,"top"!==t.idealAlign&&M||!O?M?(P+=I/2,t.anchor="start"):t.anchor="middle":(P-=I/2,t.anchor="end")):(t.pos=P,M=R+z/2+F<=C,O=R-z/2-F>=0,"left"!==t.idealAlign&&M||!O?M?(R+=z/2,t.anchor="start"):t.anchor="middle":(R-=z/2,t.anchor="end")),x.attr("text-anchor",t.anchor),T&&_.attr("text-anchor",t.anchor),e.attr("transform","translate("+R+","+P+")"+(i?"rotate("+m+")":""))}),I}function T(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var a="end"===t.anchor?-1:1,i=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],s=o*(w+A),u=s+o*(t.txwidth+A),f=0,h=t.offset;"middle"===t.anchor&&(s-=t.tx2width/2,u+=t.txwidth/2+A),e&&(h*=-_,f=t.offset*x),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(h-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+h)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(h-w)+"Z"),i.call(l.positionText,s+f,h+t.ty0-t.by/2+A),t.tx2width&&(r.select("text.name").call(l.positionText,u+o*A+f,h+t.ty0-t.by/2+A),r.select("rect").call(c.setRect,u+(o-1)*t.tx2width/2+f,h-t.by/2-1,t.tx2width,t.by+2))}})}function M(t,e){var r=t.index,n=t.trace||{},a=t.cd[0],i=t.cd[r]||{},s=Array.isArray(r)?function(t,e){return o.castOption(a,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(i,n,t,e)};function l(e,r,n){var a=s(r,n);a&&(t[e]=a)}if(l("hoverinfo","hi","hoverinfo"),l("bgcolor","hbg","hoverlabel.bgcolor"),l("borderColor","hbc","hoverlabel.bordercolor"),l("fontFamily","htf","hoverlabel.font.family"),l("fontSize","hts","hoverlabel.font.size"),l("fontColor","htc","hoverlabel.font.color"),l("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:d.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:d.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var u=d.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+u+" / -"+d.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+u,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var c=d.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+c+" / -"+d.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+c,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function E(t,e){var r,n,a=e.container,o=e.fullLayout,s=e.event,l=!!t.hLinePoint,u=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),u||l){var h=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(l){var d,p,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(d=s.pointerX,p=s.pointerY):(d=r._offset+g.x,p=n._offset+g.y);var v,m,y=i.readability(g.color,h)<1.5?f.contrast(h):g.color,b=n.spikemode,x=n.spikethickness,_=n.spikecolor||y,w=n._boundingBox,A=(w.left+w.right)/2w[0]._length||et<0||et>A[0]._length)return h.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+A[0]._offset,z="xval"in e?g.flat(l,e.xval):g.p2c(w,tt),I="yval"in e?g.flat(l,e.yval):g.p2c(A,et),!a(z[0])||!a(I[0]))return o.warn("Fx.hover failed",e,t),h.unhoverRaw(t,e)}var at=1/0;for(N=0;NW&&(J.splice(0,W),at=J[0].distance),y&&0!==Z&&0===J.length){X.distance=Z,X.index=!1;var ut=j._module.hoverPoints(X,q,G,"closest",c._hoverlayer);if(ut&&(ut=ut.filter(function(t){return t.spikeDistance<=Z})),ut&&ut.length){var ct,ft=ut.filter(function(t){return t.xa.showspikes});if(ft.length){var ht=ft[0];a(ht.x0)&&a(ht.y0)&&(ct=vt(ht),(!$.vLinePoint||$.vLinePoint.spikeDistance>ct.spikeDistance)&&($.vLinePoint=ct))}var dt=ut.filter(function(t){return t.ya.showspikes});if(dt.length){var pt=dt[0];a(pt.x0)&&a(pt.y0)&&(ct=vt(pt),(!$.hLinePoint||$.hLinePoint.spikeDistance>ct.spikeDistance)&&($.hLinePoint=ct))}}}}function gt(t,e){for(var r,n=null,a=1/0,i=0;i1||J.length>1)||"closest"===P&&K&&J.length>1,St=f.combine(c.plot_bgcolor||f.background,c.paper_bgcolor),Lt={hovermode:P,rotateLabels:Ct,bgColor:St,container:c._hoverlayer,outerContainer:c._paperdiv,commonLabelOpts:c.hoverlabel,hoverdistance:c.hoverdistance},Ot=k(J,Lt,t);if(function(t,e,r){var n,a,i,o,s,l,u,c=0,f=1,h=t.map(function(t,n){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!n&&o&&o[0]>o[1]!==i&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?b:1)/2,pmin:0,pmax:i?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function d(t){var e=t[0],r=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=r.pos+r.dp+r.size-e.pmax,a>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=a;n=!1}if(!(i<.01)){if(a<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=i;n=!1}if(n){var u=0;for(o=0;oe.pmax&&u++;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos>e.pmax-1&&(l.del=!0,u--);for(o=0;o=0;s--)t[s].dp-=i;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos+l.dp+l.size>e.pmax&&(l.del=!0,u--)}}}for(;!n&&c<=t.length;){for(c++,n=!0,o=0;o.01&&v.pmin===m.pmin&&v.pmax===m.pmax){for(s=g.length-1;s>=0;s--)g[s].dp+=a;for(p.push.apply(p,g),h.splice(o+1,1),u=0,s=p.length-1;s>=0;s--)u+=p[s].dp;for(i=u/p.length,s=p.length-1;s>=0;s--)p[s].dp-=i;n=!1}else o++}h.forEach(d)}for(o=h.length-1;o>=0;o--){var y=h[o];for(s=y.length-1;s>=0;s--){var x=y[s],_=t[x.i];_.offset=x.dp,_.del=x.del}}}(J,Ct?"xa":"ya",c),T(Ot,Ct),e.target&&e.target.tagName){var Dt=p.getComponentMethod("annotations","hasClickToShow")(t,Mt);u(n.select(e.target),Dt?"pointer":"")}if(!e.target||i||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var a=r[n],i=t._hoverdata[n];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber))return!0}return!1}(t,0,Tt))return;Tt&&t.emit("plotly_unhover",{event:e,points:Tt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:A,xvals:z,yvals:I})}(t,e,r,i)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0},a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},s=k([r],o,e.gd);return T(s,o.rotateLabels),s.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0}}),a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},s=k(r,o,e.gd),l=0;return s.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){h||d||p||"independent"===k("pattern")&&(h=!0),v._hasSubplotGrid=h;var b,x,_="top to bottom"===k("roworder"),w=h?.2:.1,A=h?.3:.1;g&&e._splomGridDflt&&(b=e._splomGridDflt.xside,x=e._splomGridDflt.yside),v._domains={x:c("x",k,w,b,y),y:c("y",k,A,x,m,_)}}else delete e.grid}function k(t,e){return n.coerce(r,v,l,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,a,i,o,s,l,c,h=t.grid||{},d=e._subplots,p=r._hasSubplotGrid,g=r.rows,v=r.columns,m="independent"===r.pattern,y=r._axisMap={};if(p){var b=h.subplots||[];l=r.subplots=new Array(g);var x=1;for(n=0;n=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],372:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes");e.exports={bgcolor:{valType:"color",editType:"legend"},bordercolor:{valType:"color",dflt:a.defaultLine,editType:"legend"},borderwidth:{valType:"number",min:0,dflt:0,editType:"legend"},font:n({editType:"legend"}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v",editType:"legend"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"],editType:"legend"},tracegroupgap:{valType:"number",min:0,dflt:10,editType:"legend"},x:{valType:"number",min:-2,max:3,dflt:1.02,editType:"legend"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left",editType:"legend"},y:{valType:"number",min:-2,max:3,dflt:1,editType:"legend"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"legend"},editType:"legend"}},{"../../plots/font_attributes":515,"../color/attributes":318}],373:[function(t,e,r){"use strict";e.exports={scrollBarWidth:6,scrollBarMinHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4,textOffsetX:40}},{}],374:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib"),i=t("../../plot_api/plot_template"),o=t("./attributes"),s=t("../../plots/layout_attributes"),l=t("./helpers");e.exports=function(t,e,r){for(var u,c,f,h,d=t.legend||{},p=0,g=!1,v="normal",m=0;m1)){var b=i.newContainer(e,"legend");if(_("bgcolor",e.paper_bgcolor),_("bordercolor"),_("borderwidth"),a.coerceFont(_,"font",e.font),_("orientation"),"h"===b.orientation){var x=t.xaxis;x&&x.rangeslider&&x.rangeslider.visible?(u=0,f="left",c=1.1,h="bottom"):(u=0,f="left",c=-.1,h="top")}_("traceorder",v),l.isGrouped(e.legend)&&_("tracegroupgap"),_("x",u),_("xanchor",f),_("y",c),_("yanchor",h),a.noneOrAll(d,b,["x","y"])}function _(t,e){return a.coerce(d,b,o,t,e)}}},{"../../lib":441,"../../plot_api/plot_template":478,"../../plots/layout_attributes":523,"../../registry":532,"./attributes":372,"./helpers":378}],375:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib/events"),l=t("../dragelement"),u=t("../drawing"),c=t("../color"),f=t("../../lib/svg_text_utils"),h=t("./handle_click"),d=t("./constants"),p=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,m=g.FROM_TL,y=g.FROM_BR,b=t("./get_legend_data"),x=t("./style"),_=t("./helpers"),w=t("./anchor_utils"),A=p.DBLCLICKDELAY;function k(t,e,r,n,a){var i=r.data()[0][0].trace,o={event:a,node:r.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=r.datum()[0].label),!1!==s.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){h(r,t,n)},A);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==s.triggerHandler(t,"plotly_legenddoubleclick",o)&&h(r,t,n)}}function T(t,e,r){var n=t.data()[0][0],i=e._fullLayout,s=n.trace,l=o.traceIs(s,"pie"),c=s.index,h=l?n.label:s.name,p=e._context.edits.legendText&&!l,g=a.ensureSingle(t,"text","legendtext");function m(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,a,i=t.select("g[class*=math-group]"),o=i.node(),s=e._fullLayout.legend.font.size*v;if(o){var l=u.bBox(o);n=l.height,a=l.width,u.setTranslate(i,0,n/4)}else{var c=t.select(".legendtext"),h=f.lineCount(c),p=c.node();n=s*h,a=p?u.bBox(p).width:0;var g=s*(.3+(1-h)/2);f.positionText(c,d.textOffsetX,g)}n=Math.max(n,16)+3,r.height=n,r.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(u.font,i.legend.font).text(p?M(h,r):h),f.positionText(g,d.textOffsetX,0),p?g.call(f.makeEditable,{gd:e,text:h}).call(m).on("edit",function(t){this.text(M(t,r)).call(m);var i=n.trace._fullInput||{},s={};if(o.hasTransform(i,"groupby")){var l=o.getTransformIndices(i,"groupby"),u=l[l.length-1],f=a.keyedContainer(i,"transforms["+u+"].styles","target","value.name");f.set(n.trace._group,t),s=f.constructUpdate()}else s.name=t;return o.call("restyle",e,s,c)}):m(g)}function M(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function E(t,e){var r,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(c.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimeA&&(i=Math.max(i-1,1)),k(e,r,t,i,n.event)}})}function C(t,e,r){var a=t._fullLayout,i=a.legend,o=i.borderwidth,s=_.isGrouped(i),l=0;if(i._width=0,i._height=0,_.isVertical(i))s&&e.each(function(t,e){u.setTranslate(this,0,e*i.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;u.setTranslate(this,o,5+o+i._height+r/2),i._height+=r,i._width=Math.max(i._width,n)}),i._width+=45+2*o,i._height+=10+2*o,s&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),l=40;else if(s){for(var c=[i._width],f=e.data(),h=0,d=f.length;ho+w-A,r.each(function(t){var e=t[0],r=v?40+t[0].width:b;o+x+A+r>a._size.w&&(x=0,m+=y,i._height=i._height+y,y=0),u.setTranslate(this,o+x,5+o+e.height/2+m),i._width+=A+r,i._height=Math.max(i._height,e.height),x+=A+r,y=Math.max(e.height,y)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var k=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");u.setRect(r,0,-e.height/2,(k?0:i._width)+l,e.height)})}function S(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");var n="top";w.isBottomAnchor(e)?n="bottom":w.isMiddleAnchor(e)&&(n="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*m[r],r:e._width*y[r],b:e._height*y[n],t:e._height*m[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var s=e.legend,f=e.showlegend&&b(t.calcdata,s),h=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void i.autoMargin(t,"legend");for(var p=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*m[r],r:e._width*y[r],b:0,t:0})}(t):S(t);var h=e._size,p=h.l+h.w*s.x,g=h.t+h.h*(1-s.y);w.isRightAnchor(s)?p-=s._width:w.isCenterAnchor(s)&&(p-=s._width/2),w.isBottomAnchor(s)?g-=s._height:w.isMiddleAnchor(s)&&(g-=s._height/2);var v=s._width,b=h.w;v>b?(p=h.l,v=b):(p+v>c&&(p=c-v),p<0&&(p=0),v=Math.min(c-p,s._width));var x,_,A,T,M=s._height,E=h.h;if(M>E?(g=h.t,M=E):(g+M>f&&(g=f-M),g<0&&(g=0),M=Math.min(f-g,s._height)),u.setTranslate(O,p,g),z.on(".drag",null),O.on("wheel",null),s._height<=M||t._context.staticPlot)R.attr({width:v-s.borderwidth,height:M-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),u.setTranslate(P,0,0),D.select("rect").attr({width:v-2*s.borderwidth,height:M-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth}),u.setClipUrl(P,r),u.setRect(z,0,0,0,0),delete s._scrollY;else{var N,B,j=Math.max(d.scrollBarMinHeight,M*M/s._height),U=M-j-2*d.scrollBarMargin,H=s._height-M,V=U/H,q=Math.min(s._scrollY||0,H);R.attr({width:v-2*s.borderwidth+d.scrollBarWidth+d.scrollBarMargin,height:M-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),D.select("rect").attr({width:v-2*s.borderwidth+d.scrollBarWidth+d.scrollBarMargin,height:M-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth+q}),u.setClipUrl(P,r),X(q,j,V),O.on("wheel",function(){X(q=a.constrain(s._scrollY+n.event.deltaY/U*H,0,H),j,V),0!==q&&q!==H&&n.event.preventDefault()});var G=n.behavior.drag().on("dragstart",function(){N=n.event.sourceEvent.clientY,B=q}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||X(q=a.constrain((t.clientY-N)/V+B,0,H),j,V)});z.call(G)}function X(e,r,n){s._scrollY=t._fullLayout.legend._scrollY=e,u.setTranslate(P,0,-e),u.setRect(z,v,d.scrollBarMargin+e*n,d.scrollBarWidth,r),D.select("rect").attr({y:s.borderwidth+e})}t._context.edits.legendPosition&&(O.classed("cursor-move",!0),l.init({element:O.node(),gd:t,prepFn:function(){var t=u.getTranslate(O);A=t.x,T=t.y},moveFn:function(t,e){var r=A+t,n=T+e;u.setTranslate(O,r,n),x=l.align(r,0,h.l,h.l+h.w,s.xanchor),_=l.align(n,0,h.t+h.h,h.t,s.yanchor)},doneFn:function(){void 0!==x&&void 0!==_&&o.call("relayout",t,{"legend.x":x,"legend.y":_})},clickFn:function(r,n){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});a.size()>0&&k(t,O,a,r,n)}}))}],t)}}},{"../../constants/alignment":417,"../../constants/interactions":419,"../../lib":441,"../../lib/events":431,"../../lib/svg_text_utils":465,"../../plots/plots":525,"../../registry":532,"../color":319,"../dragelement":341,"../drawing":344,"./anchor_utils":371,"./constants":373,"./get_legend_data":376,"./handle_click":377,"./helpers":378,"./style":380,d3:85}],376:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var r,i,o={},s=[],l=!1,u={},c=0;function f(t,r){if(""!==t&&a.isGrouped(e))-1===s.indexOf(t)?(s.push(t),l=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+c;s.push(n),o[n]=[[r]],c++}}for(r=0;rr[1])return r[1]}return a}function p(t){return t[0]}if(c||f||h){var g={},v={};if(c){g.mc=d("marker.color",p),g.mx=d("marker.symbol",p),g.mo=d("marker.opacity",i.mean,[.2,1]),g.mlc=d("marker.line.color",p),g.mlw=d("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var m=d("marker.size",i.mean,[2,16]);g.ms=m,v.marker.size=m}h&&(v.line={width:d("line.width",p,[0,10])}),f&&(g.tx="Aa",g.tp=d("textposition",p),g.ts=10,g.tc=d("textfont.color",p),g.tf=d("textfont.family",p)),r=[i.minExtend(s,g)],(a=i.minExtend(u,v)).selectedpoints=null}var y=n.select(this).select("g.legendpoints"),b=y.selectAll("path.scatterpts").data(c?r:[]);b.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),b.exit().remove(),b.call(o.pointStyle,a,e),c&&(r[0].mrc=3);var x=y.selectAll("g.pointtext").data(f?r:[]);x.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),x.exit().remove(),x.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,o=n.select(this);o.style("stroke-width",i+"px").call(s.fill,a.fillcolor),i&&s.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,l=n.select(this);l.style("fill","none").call(o.dashLine,a.line.dash,i),i&&s.stroke(l,a.line.color)})})}},{"../../lib":441,"../../registry":532,"../../traces/pie/style_one":586,"../../traces/scatter/subtypes":616,"../color":319,"../drawing":344,d3:85}],381:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),s=t("../../../build/ploticon"),l=o._,u=e.exports={};function c(t,e){var r,a,o=e.currentTarget,s=o.getAttribute("data-attr"),l=o.getAttribute("data-val")||!0,u=t._fullLayout,c={},f=i.list(t,null,!0),h="on";if("zoom"===s){var d,p="in"===l?.5:2,g=(1+p)/2,v=(1-p)/2;for(a=0;a1?(_=["toggleHover"],w=["resetViews"]):f?(x=["zoomInGeo","zoomOutGeo"],_=["hoverClosestGeo"],w=["resetGeo"]):c?(_=["hoverClosest3d"],w=["resetCameraDefault3d","resetCameraLastSave3d"]):g?(_=["toggleHover"],w=["resetViewMapbox"]):_=d?["hoverClosestGl2d"]:h?["hoverClosestPie"]:["toggleHover"];u&&(_=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!u&&!d||m||(x=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==w[0]&&(w=["resetScale2d"]));c?A=["zoom3d","pan3d","orbitRotation","tableRotation"]:(u||d)&&!m||p?A=["zoom2d","pan2d"]:g||f?A=["pan2d"]:v&&(A=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),a=0,i=0;i0?h+u:u;return{ppad:u,ppadplus:c?p:g,ppadminus:c?g:p}}return{ppad:u}}function c(t,e,r,n,a){var s="category"===t.type?t.r2c:t.d2c;if(void 0!==e)return[s(e),s(r)];if(n){var l,u,c,f,h=1/0,d=-1/0,p=n.match(i.segmentRE);for("date"===t.type&&(s=o.decodeDate(s)),l=0;ld&&(d=f)));return d>=h?[h,d]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:z?V(r.xanchor)+r.x0:V(r.x0),cy:I?q(r.yanchor)-r.y0:q(r.y0),r:i}).style(a).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:z?V(r.xanchor)+r.x1:V(r.x1),cy:I?q(r.yanchor)-r.y1:q(r.y1),r:i}).style(a).classed("cursor-grab",!0),n}():e,Y={element:W.node(),gd:t,prepFn:function(n){z&&(_=V(r.xanchor));I&&(w=q(r.yanchor));"path"===r.type?O=r.path:(m=z?r.x0:V(r.x0),y=I?r.y0:q(r.y0),b=z?r.x1:V(r.x1),x=I?r.y1:q(r.y1));mx?(A=y,E="y0",k=x,C="y1"):(A=x,E="y1",k=y,C="y0");Z(n),$(d,r),function(t,e,r){var n=e.xref,a=e.yref,o=i.getFromId(r,n),l=i.getFromId(r,a),u="";"paper"===n||o.autorange||(u+=n);"paper"===a||l.autorange||(u+=a);t.call(s.setClipUrl,u?"clip"+r._fullLayout._uid+u:null)}(e,r,t),Y.moveFn="move"===D?J:Q},doneFn:function(){c(e),K(d),p(e,t,r),n.call("relayout",t,B.getUpdateObj())},clickFn:function(){K(d)}};function Z(t){if(F)D="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Y.element.getBoundingClientRect(),n=r.right-r.left,a=r.bottom-r.top,i=t.clientX-r.left,o=t.clientY-r.top,s=!N&&n>R&&a>P&&!t.shiftKey?u.getCursor(i/n,1-o/a):"move";c(e,s),D=s.split("-")[0]}}function J(n,a){if("path"===r.type){var i=function(t){return t},o=i,s=i;z?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},U&&"date"===U.type&&(o=h.encodeDate(o))),I?j("yanchor",r.yanchor=X(w+a)):(s=function(t){return X(q(t)+a)},H&&"date"===H.type&&(s=h.encodeDate(s))),j("path",r.path=v(O,o,s))}else z?j("xanchor",r.xanchor=G(_+n)):(j("x0",r.x0=G(m+n)),j("x1",r.x1=G(b+n))),I?j("yanchor",r.yanchor=X(w+a)):(j("y0",r.y0=X(y+a)),j("y1",r.y1=X(x+a)));e.attr("d",g(t,r)),$(d,r)}function Q(n,a){if(N){var i=function(t){return t},o=i,s=i;z?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},U&&"date"===U.type&&(o=h.encodeDate(o))),I?j("yanchor",r.yanchor=X(w+a)):(s=function(t){return X(q(t)+a)},H&&"date"===H.type&&(s=h.encodeDate(s))),j("path",r.path=v(O,o,s))}else if(F){if("resize-over-start-point"===D){var l=m+n,u=I?y-a:y+a;j("x0",r.x0=z?l:G(l)),j("y0",r.y0=I?u:X(u))}else if("resize-over-end-point"===D){var c=b+n,f=I?x-a:x+a;j("x1",r.x1=z?c:G(c)),j("y1",r.y1=I?f:X(f))}}else{var p=~D.indexOf("n")?A+a:A,B=~D.indexOf("s")?k+a:k,W=~D.indexOf("w")?T+n:T,Y=~D.indexOf("e")?M+n:M;~D.indexOf("n")&&I&&(p=A-a),~D.indexOf("s")&&I&&(B=k-a),(!I&&B-p>P||I&&p-B>P)&&(j(E,r[E]=I?p:X(p)),j(C,r[C]=I?B:X(B))),Y-W>R&&(j(S,r[S]=z?W:G(W)),j(L,r[L]=z?Y:G(Y)))}e.attr("d",g(t,r)),$(d,r)}function $(t,e){(z||I)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=V(z?e.xanchor:a.midRange(r?[e.x0,e.x1]:h.extractPathCoords(e.path,f.paramIsX))),o=q(I?e.yanchor:a.midRange(r?[e.y0,e.y1]:h.extractPathCoords(e.path,f.paramIsY)));if(i=h.roundPositionForSharpStrokeRendering(i,1),o=h.roundPositionForSharpStrokeRendering(o,1),z&&I){var s="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",s)}else if(z){var l="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",l)}else{var u="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",u)}}()}function K(t){t.selectAll(".visual-cue").remove()}u.init(Y),W.node().onmousemove=Z}(t,b,r,e,d)}}function p(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");t.call(s.setClipUrl,n?"clip"+e._fullLayout._uid+n:null)}function g(t,e){var r,n,o,s,l,u,c,d,p=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),m=t._fullLayout._size;if(g?(r=h.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return m.l+m.w*t},v?(o=h.shapePositionToRange(v),s=function(t){return v._offset+v.r2p(o(t,!0))}):s=function(t){return m.t+m.h*(1-t)},"path"===p)return g&&"date"===g.type&&(n=h.decodeDate(n)),v&&"date"===v.type&&(s=h.decodeDate(s)),function(t,e,r){var n=t.path,i=t.xsizemode,o=t.ysizemode,s=t.xanchor,l=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,u=t.charAt(0),c=f.paramIsX[u],h=f.paramIsY[u],d=f.numParams[u],p=t.substr(1).replace(f.paramRE,function(t){return c[n]?t="pixel"===i?e(s)+Number(t):e(t):h[n]&&(t="pixel"===o?r(l)-Number(t):r(t)),++n>d&&(t="X"),t});return n>d&&(p=p.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),u+p})}(e,n,s);if("pixel"===e.xsizemode){var y=n(e.xanchor);l=y+e.x0,u=y+e.x1}else l=n(e.x0),u=n(e.x1);if("pixel"===e.ysizemode){var b=s(e.yanchor);c=b-e.y0,d=b-e.y1}else c=s(e.y0),d=s(e.y1);if("line"===p)return"M"+l+","+c+"L"+u+","+d;if("rect"===p)return"M"+l+","+c+"H"+u+"V"+d+"H"+l+"Z";var x=(l+u)/2,_=(c+d)/2,w=Math.abs(x-l),A=Math.abs(_-c),k="A"+w+","+A,T=x+w+","+_;return"M"+T+k+" 0 1,1 "+(x+","+(_-A))+k+" 0 0,1 "+T+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],s=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return n>=s?t:(i[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var a=0;a0&&(s=s.transition().duration(e.transition.duration).ease(e.transition.easing)),s.attr("transform","translate("+(o-.5*f.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function C(t,e){var r=t._dims;return r.inputAreaStart+f.stepInset+(r.inputAreaLength-2*f.stepInset)*Math.min(1,Math.max(0,e))}function S(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-f.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*f.stepInset-2*r.inputAreaStart)))}function L(t,e,r){var n=r._dims,a=s.ensureSingle(t,"rect",f.railTouchRectClass,function(n){n.call(T,e,t,r).style("pointer-events","all")});a.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,f.tickOffset+r.ticklen+n.labelHeight)}).call(i.fill,r.bgcolor).attr("opacity",0),o.setTranslate(a,0,n.currentValueTotalHeight)}function O(t,e){var r=e._dims,n=r.inputAreaLength-2*f.railInset,a=s.ensureSingle(t,"rect",f.railRectClass);a.attr({width:n,height:f.railWidth,rx:f.railRadius,ry:f.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,f.railInset,.5*(r.inputAreaWidth-f.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[f.name],n=[],a=0;a0?[0]:[]);function s(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,v(e))}if(i.enter().append("g").classed(f.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){n.select(this).selectAll("g."+f.groupClassName).each(s)}).remove(),0!==r.length){var l=i.selectAll("g."+f.groupClassName).data(r,m);l.enter().append("g").classed(f.groupClassName,!0),l.exit().each(s).remove();for(var u=0;u0||h<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[y.side];e.attr("transform","translate("+g+")")}}}D.call(R),L&&(S?D.on(".opacity",null):(E=0,C=!0,D.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),D.call(c.makeEditable,{gd:t}).on("edit",function(e){void 0!==m?o.call("restyle",t,g,e,m):o.call("relayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(R)}).on("input",function(t){this.text(t||" ").call(c.positionText,b.x,b.y)}));return D.classed("js-placeholder",C),_}};var h=/ [XY][0-9]* /},{"../../constants/interactions":419,"../../lib":441,"../../lib/svg_text_utils":465,"../../plots/plots":525,"../../registry":532,"../color":319,"../drawing":344,d3:85,"fast-isnumeric":149}],411:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes"),l=t("../../plot_api/plot_template").templatedArray,u=l("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(l("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:u,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i({},s,{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":432,"../../plot_api/edit_types":471,"../../plot_api/plot_template":478,"../../plots/font_attributes":515,"../../plots/pad_attributes":524,"../color/attributes":318}],412:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],413:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,s=i.buttons;function l(t,e,r){function o(r,a){return n.coerce(t,e,i,r,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:u}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function u(t,e){function r(r,a){return n.coerce(t,e,s,r,a)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:l})}},{"../../lib":441,"../../plots/array_container_defaults":484,"./attributes":411,"./constants":412}],414:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../legend/anchor_utils"),c=t("../../plot_api/plot_template").arrayEditor,f=t("../../constants/alignment").LINE_SPACING,h=t("./constants"),d=t("./scrollbox");function p(t){return t._index}function g(t,e){return+t.attr(h.menuIndexAttrName)===e._index}function v(t,e,r,n,a,i,o,s){e.active=o,c(t.layout,h.name,e).applyUpdate("active",o),"buttons"===e.type?y(t,n,null,null,e):"dropdown"===e.type&&(a.attr(h.menuIndexAttrName,"-1"),m(t,n,a,i,e),s||y(t,n,a,i,e))}function m(t,e,r,n,a){var i=s.ensureSingle(e,"g",h.headerClassName,function(t){t.style("pointer-events","all")}),l=a._dims,u=a.active,c=a.buttons[u]||h.blankHeaderOpts,f={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},d={width:l.headerWidth,height:l.headerHeight};i.call(b,a,c,t).call(E,a,f,d),s.ensureSingle(e,"text",h.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(h.arrowSymbol[a.direction])}).attr({x:l.headerWidth-h.arrowOffsetX+a.pad.l,y:l.headerHeight/2+h.textOffsetY+a.pad.t}),i.on("click",function(){r.call(C,String(g(r,a)?-1:a._index)),y(t,e,r,n,a)}),i.on("mouseover",function(){i.call(A)}),i.on("mouseout",function(){i.call(k,a)}),o.setTranslate(e,l.lx,l.ly)}function y(t,e,r,i,o){r||(r=e).attr("pointer-events","all");var l=function(t){return-1==+t.attr(h.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,u="dropdown"===o.type?h.dropdownButtonClassName:h.buttonClassName,c=r.selectAll("g."+u).data(s.filterVisible(l)),f=c.enter().append("g").classed(u,!0),d=c.exit();"dropdown"===o.type?(f.attr("opacity","0").transition().attr("opacity","1"),d.transition().attr("opacity","0").remove()):d.remove();var p=0,g=0,m=o._dims,y=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(y?g=m.headerHeight+h.gapButtonHeader:p=m.headerWidth+h.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(g=-h.gapButtonHeader+h.gapButton-m.openHeight),"dropdown"===o.type&&"left"===o.direction&&(p=-h.gapButtonHeader+h.gapButton-m.openWidth);var x={x:m.lx+p+o.pad.l,y:m.ly+g+o.pad.t,yPad:h.gapButton,xPad:h.gapButton,index:0},_={l:x.x+o.borderwidth,t:x.y+o.borderwidth};c.each(function(s,l){var u=n.select(this);u.call(b,o,s,t).call(E,o,x),u.on("click",function(){n.event.defaultPrevented||(v(t,o,0,e,r,i,l),s.execute&&a.executeAPICommand(t,s.method,s.args),t.emit("plotly_buttonclicked",{menu:o,button:s,active:o.active}))}),u.on("mouseover",function(){u.call(A)}),u.on("mouseout",function(){u.call(k,o),c.call(w,o)})}),c.call(w,o),y?(_.w=Math.max(m.openWidth,m.headerWidth),_.h=x.y-_.t):(_.w=x.x-_.l,_.h=Math.max(m.openHeight,m.headerHeight)),_.direction=o.direction,i&&(c.size()?function(t,e,r,n,a,i){var o,s,l,u=a.direction,c="up"===u||"down"===u,f=a._dims,d=a.active;if(c)for(s=0,l=0;l0?[0]:[]);if(o.enter().append("g").classed(h.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+h.headerGroupClassName).each(i)}).remove(),0!==r.length){var l=o.selectAll("g."+h.headerGroupClassName).data(r,p);l.enter().append("g").classed(h.headerGroupClassName,!0);for(var u=s.ensureSingle(o,"g",h.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),c=0;cw,T=s.barLength+2*s.barPad,M=s.barWidth+2*s.barPad,E=p,C=v+m;C+M>u&&(C=u-M);var S=this.container.selectAll("rect.scrollbar-horizontal").data(k?[0]:[]);S.exit().on(".drag",null).remove(),S.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,s.barColor),k?(this.hbar=S.attr({rx:s.barRadius,ry:s.barRadius,x:E,y:C,width:T,height:M}),this._hbarXMin=E+T/2,this._hbarTranslateMax=w-T):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var L=m>A,O=s.barWidth+2*s.barPad,D=s.barLength+2*s.barPad,R=p+g,P=v;R+O>l&&(R=l-O);var z=this.container.selectAll("rect.scrollbar-vertical").data(L?[0]:[]);z.exit().on(".drag",null).remove(),z.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,s.barColor),L?(this.vbar=z.attr({rx:s.barRadius,ry:s.barRadius,x:R,y:P,width:O,height:D}),this._vbarYMin=P+D/2,this._vbarTranslateMax=A-D):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var I=this.id,F=c-.5,N=L?f+O+.5:f+.5,B=h-.5,j=k?d+M+.5:d+.5,U=o._topdefs.selectAll("#"+I).data(k||L?[0]:[]);if(U.exit().remove(),U.enter().append("clipPath").attr("id",I).append("rect"),k||L?(this._clipRect=U.select("rect").attr({x:Math.floor(F),y:Math.floor(B),width:Math.ceil(N)-Math.floor(F),height:Math.ceil(j)-Math.floor(B)}),this.container.call(i.setClipUrl,I),this.bg.attr({x:p,y:v,width:g,height:m})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),k||L){var H=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(H);var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));k&&this.hbar.on(".drag",null).call(V),L&&this.vbar.on(".drag",null).call(V)}this.setTranslate(e,r)},s.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},s.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},s.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},s.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,a=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,a)-r)/(a-r)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,s=i+this._vbarTranslateMax;e=(o.constrain(n.event.y,i,s)-i)/(s-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},s.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/r;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var s=e/n;this.vbar.call(i.setTranslate,t,e+s*this._vbarTranslateMax)}}},{"../../lib":441,"../color":319,"../drawing":344,d3:85}],417:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],418:[function(t,e,r){"use strict";e.exports={COMPARISON_OPS:["=","!=","<",">=",">","<="],COMPARISON_OPS2:["=","<",">=",">","<="],INTERVAL_OPS:["[]","()","[)","(]","][",")(","](",")["],SET_OPS:["{}","}{"],CONSTRAINT_REDUCTION:{"=":"=","<":"<","<=":"<",">":">",">=":">","[]":"[]","()":"[]","[)":"[]","(]":"[]","][":"][",")(":"][","](":"][",")[":"]["}}},{}],419:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],420:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],421:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],422:[function(t,e,r){"use strict";r.version="1.42.5",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config");for(var n=t("./registry"),a=r.register=n.register,i=t("./plot_api"),o=Object.keys(i),s=0;ss-1e-15}function u(t,e){return i(e-t,s)}function c(t,e){if(l(e))return!0;var r,n;e[0](n=a(n,s))&&(n+=s);var i=a(t,s),o=i+s;return i>=r&&i<=n||o>=r&&o<=n}function f(t,e,r,n,a,i,u){a=a||0,i=i||0;var c,f,h,d,p,g=l([r,n]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(c=0,f=o,h=s):r=a&&t<=i);var a,i},pathArc:function(t,e,r,n,a){return f(null,t,e,r,n,a,0)},pathSector:function(t,e,r,n,a){return f(null,t,e,r,n,a,1)},pathAnnulus:function(t,e,r,n,a,i){return f(t,e,r,n,a,i,1)}}},{"./mod":448}],425:[function(t,e,r){"use strict";var n=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function s(t){return n(t)||o(t)}r.isTypedArray=o,r.isArrayOrTypedArray=s,r.isArray1D=function(t){return!s(t[0])},r.ensureArray=function(t,e){return n(t)||(t=[]),t.length=e,t},r.concat=function(){var t,e,r,a,i,o,s,l,u=[],c=!0,f=0;for(r=0;ra.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,a){t%1||!n(t)||void 0!==a.min&&ta.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var a="number"==typeof t;!0!==n.strict&&a?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){a(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(c(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var a=n.regex||l(r);"string"==typeof t&&a.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!l(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=n&&t<=a?t:c}if("string"!=typeof t&&"number"!=typeof t)return c;t=String(t);var u=_(e),m=t.charAt(0);!u||"G"!==m&&"g"!==m||(t=t.substr(1),e="");var w=u&&"chinese"===e.substr(0,7),A=t.match(w?b:y);if(!A)return c;var k=A[1],T=A[3]||"1",M=Number(A[5]||1),E=Number(A[7]||0),C=Number(A[9]||0),S=Number(A[11]||0);if(u){if(2===k.length)return c;var L;k=Number(k);try{var O=v.getComponentMethod("calendars","getCal")(e);if(w){var D="i"===T.charAt(T.length-1);T=parseInt(T,10),L=O.newDate(k,O.toMonthIndex(k,T,D),M)}else L=O.newDate(k,Number(T),M)}catch(t){return c}return L?(L.toJD()-g)*f+E*h+C*d+S*p:c}k=2===k.length?(Number(k)+2e3-x)%100+x:Number(k),T-=1;var R=new Date(Date.UTC(2e3,T,M,E,C));return R.setUTCFullYear(k),R.getUTCMonth()!==T?c:R.getUTCDate()!==M?c:R.getTime()+S*p},n=r.MIN_MS=r.dateTime2ms("-9999"),a=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==c};var A=90*f,k=3*h,T=5*d;function M(t,e,r,n,a){if((e||r||n||a)&&(t+=" "+w(e,2)+":"+w(r,2),(n||a)&&(t+=":"+w(n,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=a))return c;e||(e=0);var i,o,s,u,y,b,x=Math.floor(10*l(t+.05,1)),w=Math.round(t-x/10);if(_(r)){var E=Math.floor(w/f)+g,C=Math.floor(l(t,f));try{i=v.getComponentMethod("calendars","getCal")(r).fromJD(E).formatDate("yyyy-mm-dd")}catch(t){i=m("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=n+f&&t<=a-f))return c;var e=Math.floor(10*l(t+.05,1)),r=new Date(Math.round(t-e/10));return M(i.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===c)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return s.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return s.error("unrecognized date",t),e;return t};var E=/%\d?f/g;function C(t,e,r,n){t=t.replace(E,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(a)}var S=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,a,i){if(a=_(a)&&a,!e)if("y"===r)e=i.year;else if("m"===r)e=i.month;else{if("d"!==r)return function(t,e){var r=l(t+.05,f),n=w(Math.floor(r/h),2)+":"+w(l(Math.floor(r/d),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(l(t/p,60),S[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+a}return n}(t,r)+"\n"+C(i.dayMonthYear,t,n,a);e=i.dayMonth+"\n"+i.year}return C(e,t,n,a)};var L=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=l(t,f);if(t=Math.round(t-n),r)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(r),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){s.error("invalid ms "+t+" in calendar "+r)}var u=new Date(t+L);return u.setUTCMonth(u.getUTCMonth()+e)+n-L},r.findExactDates=function(t,e){for(var r,n,a=0,i=0,s=0,l=0,u=_(e)&&v.getComponentMethod("calendars","getCal")(e),c=0;c1||g<0||g>1?null:{x:t+l*g,y:e+f*g}}function l(t,e,r,n,a){var i=n*t+a*e;if(i<0)return n*n+a*a;if(i>r){var o=n-t,s=a-e;return o*o+s*s}var l=n*e-a*t;return l*l/r}r.segmentsIntersect=s,r.segmentDistance=function(t,e,r,n,a,i,o,u){if(s(t,e,r,n,a,i,o,u))return 0;var c=r-t,f=n-e,h=o-a,d=u-i,p=c*c+f*f,g=h*h+d*d,v=Math.min(l(c,f,p,a-t,i-e),l(c,f,p,o-t,u-e),l(h,d,g,t-a,e-i),l(h,d,g,r-a,n-i));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,s){if(t===a&&s===i||(n={},a=t,i=s),n[r])return n[r];var l=t.getPointAtLength(o(r-s/2,e)),u=t.getPointAtLength(o(r+s/2,e)),c=Math.atan((u.y-l.y)/(u.x-l.x)),f=t.getPointAtLength(o(r,e)),h={x:(4*f.x+l.x+u.x)/6,y:(4*f.y+l.y+u.y)/6,theta:c};return n[r]=h,h},r.clearLocationCache=function(){a=null},r.getVisibleSegment=function(t,e,r){var n,a,i=e.left,o=e.right,s=e.top,l=e.bottom,u=0,c=t.getTotalLength(),f=c;function h(e){var r=t.getPointAtLength(e);0===e?n=r:e===c&&(a=r);var u=r.xo?r.x-o:0,f=r.yl?r.y-l:0;return Math.sqrt(u*u+f*f)}for(var d=h(u);d;){if((u+=d+r)>f)return;d=h(u)}for(d=h(f);d;){if(u>(f-=d+r))return;d=h(f)}return{min:u,max:f,len:f-u,total:c,isClosed:0===u&&f===c&&Math.abs(n.x-a.x)<.1&&Math.abs(n.y-a.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var a,i,o,s=(n=n||{}).pathLength||t.getTotalLength(),l=n.tolerance||.001,u=n.iterationLimit||30,c=t.getPointAtLength(0)[r]>t.getPointAtLength(s)[r]?-1:1,f=0,h=0,d=s;f0?d=a:h=a,f++}return i}},{"./mod":448}],436:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],437:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("tinycolor2"),i=t("color-normalize"),o=t("../components/colorscale"),s=t("../components/color/attributes").defaultLine,l=t("./array").isArrayOrTypedArray,u=i(s),c=1;function f(t,e){var r=t;return r[3]*=e,r}function h(t){if(n(t))return u;var e=i(t);return e.length?e:u}function d(t){return n(t)?t:c}e.exports={formatColor:function(t,e,r){var n,a,s,p,g,v=t.color,m=l(v),y=l(e),b=[];if(n=void 0!==t.colorscale?o.makeColorScaleFunc(o.extractScale(t.colorscale,t.cmin,t.cmax)):h,a=m?function(t,e){return void 0===t[e]?u:i(n(t[e]))}:h,s=y?function(t,e){return void 0===t[e]?c:d(t[e])}:d,m||y)for(var x=0;x/g,"")}(function(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(r/g,"\n"))))}},{"./svg_text_utils":465,"superscript-text":277}],440:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],441:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../constants/numerical"),o=i.FP_SAFE,s=i.BADNUM,l=e.exports={};l.nestedProperty=t("./nested_property"),l.keyedContainer=t("./keyed_container"),l.relativeAttr=t("./relative_attr"),l.isPlainObject=t("./is_plain_object"),l.toLogRange=t("./to_log_range"),l.relinkPrivateKeys=t("./relink_private");var u=t("./array");l.isTypedArray=u.isTypedArray,l.isArrayOrTypedArray=u.isArrayOrTypedArray,l.isArray1D=u.isArray1D,l.ensureArray=u.ensureArray,l.concat=u.concat;var c=t("./mod");l.mod=c.mod,l.modHalf=c.modHalf;var f=t("./coerce");l.valObjectMeta=f.valObjectMeta,l.coerce=f.coerce,l.coerce2=f.coerce2,l.coerceFont=f.coerceFont,l.coerceHoverinfo=f.coerceHoverinfo,l.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,l.validate=f.validate;var h=t("./dates");l.dateTime2ms=h.dateTime2ms,l.isDateTime=h.isDateTime,l.ms2DateTime=h.ms2DateTime,l.ms2DateTimeLocal=h.ms2DateTimeLocal,l.cleanDate=h.cleanDate,l.isJSDate=h.isJSDate,l.formatDate=h.formatDate,l.incrementMonth=h.incrementMonth,l.dateTick0=h.dateTick0,l.dfltRange=h.dfltRange,l.findExactDates=h.findExactDates,l.MIN_MS=h.MIN_MS,l.MAX_MS=h.MAX_MS;var d=t("./search");l.findBin=d.findBin,l.sorterAsc=d.sorterAsc,l.sorterDes=d.sorterDes,l.distinctVals=d.distinctVals,l.roundUp=d.roundUp,l.sort=d.sort,l.findIndexOfMin=d.findIndexOfMin;var p=t("./stats");l.aggNums=p.aggNums,l.len=p.len,l.mean=p.mean,l.midRange=p.midRange,l.variance=p.variance,l.stdev=p.stdev,l.interp=p.interp;var g=t("./matrix");l.init2dArray=g.init2dArray,l.transposeRagged=g.transposeRagged,l.dot=g.dot,l.translationMatrix=g.translationMatrix,l.rotationMatrix=g.rotationMatrix,l.rotationXYMatrix=g.rotationXYMatrix,l.apply2DTransform=g.apply2DTransform,l.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");l.deg2rad=v.deg2rad,l.rad2deg=v.rad2deg,l.angleDelta=v.angleDelta,l.angleDist=v.angleDist,l.isFullCircle=v.isFullCircle,l.isAngleInsideSector=v.isAngleInsideSector,l.isPtInsideSector=v.isPtInsideSector,l.pathArc=v.pathArc,l.pathSector=v.pathSector,l.pathAnnulus=v.pathAnnulus;var m=t("./geometry2d");l.segmentsIntersect=m.segmentsIntersect,l.segmentDistance=m.segmentDistance,l.getTextLocation=m.getTextLocation,l.clearLocationCache=m.clearLocationCache,l.getVisibleSegment=m.getVisibleSegment,l.findPointOnPath=m.findPointOnPath;var y=t("./extend");l.extendFlat=y.extendFlat,l.extendDeep=y.extendDeep,l.extendDeepAll=y.extendDeepAll,l.extendDeepNoArrays=y.extendDeepNoArrays;var b=t("./loggers");l.log=b.log,l.warn=b.warn,l.error=b.error;var x=t("./regex");l.counterRegex=x.counter;var _=t("./throttle");function w(t){var e={};for(var r in t)for(var n=t[r],a=0;ao?s:a(t)?Number(t):s:s},l.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},l.noop=t("./noop"),l.identity=t("./identity"),l.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},l.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},l.simpleMap=function(t,e,r,n){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,r)?a>10?(l.warn("randstr failed uniqueness"),u):t(e,r,n,(a||0)+1):u},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,a,i,o=t.length,s=2*o,l=2*e-1,u=new Array(l),c=new Array(o);for(r=0;r=s&&(a-=s*Math.floor(a/s)),a<0?a=-1-a:a>=o&&(a=s-1-a),i+=t[a]*u[n];c[r]=i}return c},l.syncOrAsync=function(t,e,r){var n;function a(){return l.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(a).then(void 0,l.promiseError);return r&&r(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,r){if(t){var n,a=!1,i=!0;for(n=0;n1?a+o[1]:"";if(i&&(o.length>1||s.length>4||r))for(;n.test(s);)s=s.replace(n,"$1"+i+"$2");return s+l};var T=/%{([^\s%{}]*)}/g,M=/^\w*$/;l.templateString=function(t,e){var r={};return t.replace(T,function(t,n){return M.test(n)?e[n]||"":(r[n]=r[n]||l.nestedProperty(e,n).get,r[n]()||"")})};l.subplotSort=function(t,e){for(var r=Math.min(t.length,e.length)+1,n=0,a=0,i=0;i=48&&o<=57,u=s>=48&&s<=57;if(l&&(n=10*n+o-48),u&&(a=10*a+s-48),!l||!u){if(n!==a)return n-a;if(o!==s)return o-s}}return a-n};var E=2e9;l.seedPseudoRandom=function(){E=2e9},l.pseudoRandom=function(){var t=E;return E=(69069*E+1)%4294967296,Math.abs(E-t)<429496729?l.pseudoRandom():E/4294967296}},{"../constants/numerical":420,"./angles":424,"./array":425,"./clean_number":426,"./clear_responsive":428,"./coerce":429,"./dates":430,"./extend":432,"./filter_unique":433,"./filter_visible":434,"./geometry2d":435,"./get_graph_div":436,"./identity":440,"./is_plain_object":442,"./keyed_container":443,"./localize":444,"./loggers":445,"./make_trace_groups":446,"./matrix":447,"./mod":448,"./nested_property":449,"./noop":450,"./notifier":451,"./push_unique":455,"./regex":457,"./relative_attr":458,"./relink_private":459,"./search":460,"./stats":463,"./throttle":466,"./to_log_range":467,d3:85,"fast-isnumeric":149}],442:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],443:[function(t,e,r){"use strict";var n=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,r,i){var o,s,l;r=r||"name",i=i||"value";var u={};e&&e.length?(l=n(t,e),s=l.get()):s=t,e=e||"";var c={};if(s)for(o=0;o2)return u[e]=2|u[e],h.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],449:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,l=0,u=e.split(".");l/g),o=0;oi||u===a||us||e&&l(t))}:function(t,e){var l=t[0],u=t[1];if(l===a||li||u===a||us)return!1;var c,f,h,d,p,g=r.length,v=r[0][0],m=r[0][1],y=0;for(c=1;cMath.max(f,v)||u>Math.max(h,m)))if(uc||Math.abs(n(o,h))>a)return!0;return!1};i.filter=function(t,e){var r=[t[0]],n=0,a=0;function i(i){t.push(i);var s=r.length,l=n;r.splice(a+1);for(var u=l+1;u1&&i(t.pop());return{addPt:i,raw:t,filtered:r}}},{"../constants/numerical":420,"./matrix":447}],454:[function(t,e,r){(function(r){"use strict";var n=t("./show_no_webgl_msg"),a=t("regl");e.exports=function(t,e){var i=t._fullLayout,o=!0;return i._glcanvas.each(function(n){if(!n.regl&&(!n.pick||i._has("parcoords"))){try{n.regl=a({canvas:this,attributes:{antialias:!n.pick,preserveDrawingBuffer:!0},pixelRatio:t._context.plotGlPixelRatio||r.devicePixelRatio,extensions:e||[]})}catch(t){o=!1}o&&this.addEventListener("webglcontextlost",function(e){t&&t.emit&&t.emit("plotly_webglcontextlost",{event:e,layer:n.key})},!1)}}),o||n({container:i._glcontainer.node()}),o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./show_no_webgl_msg":462,regl:259}],455:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ra.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function u(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,c,f=0,h=e.length,d=0,p=h>1?(e[h-1]-e[0])/(h-1):1;for(c=p>=0?r?o:s:r?u:l,t+=1e-9*p*(r?-1:1)*(p>=0?1:-1);f90&&a.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,a=e[n]-e[0]||1,i=a/(n||1)/1e4,o=[e[0]],s=0;se[s]+i&&(a=Math.min(a,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:a}},r.roundUp=function(t,e,r){for(var n,a=0,i=e.length-1,o=0,s=r?0:1,l=r?1:0,u=r?Math.ceil:Math.floor;a0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||i;for(var r,n=1/0,a=0;ai.length)&&(o=i.length),n(e)||(e=!1),a(i[0])){for(l=new Array(o),s=0;st.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":425,"fast-isnumeric":149}],464:[function(t,e,r){"use strict";var n=t("color-normalize");e.exports=function(t){return t?n(t):[0,0,0,1]}},{"color-normalize":63}],465:[function(t,e,r){"use strict";var n=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function s(t,e){return t.node().getBoundingClientRect()[e]}var l=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var E=t.text(),C=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&E.match(l),L=n.select(t.node().parentNode);if(!L.empty()){var O=t.attr("class")?t.attr("class").split(" ")[0]:"text";return O+="-math",L.selectAll("svg."+O).remove(),L.selectAll("g."+O+"-group").remove(),t.style("display",null).attr({"data-unformatted":E,"data-math":"N"}),C?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),i={fontSize:r};!function(t,e,r){var i,o,s,l;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),s=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+a.randstr({},64);return l=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(u,"\\lt ").replace(c,"\\gt ")),MathJax.Hub.Typeset(l.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(l.select(".MathJax_SVG").empty()||!l.select("svg").node())a.log("There was an error in the tex syntax.",t),r();else{var o=l.select("svg").node().getBoundingClientRect();r(l.select(".MathJax_SVG"),e,o)}if(l.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==s&&(MathJax.Hub.processSectionDelay=s),MathJax.Hub.Config(o)})}(C[2],i,function(n,a,i){L.selectAll("svg."+O).remove(),L.selectAll("g."+O+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return D(),void e();var l=L.append("g").classed(O+"-group",!0).attr({"pointer-events":"none","data-unformatted":E,"data-math":"Y"});l.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:O,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=t.node().style.fill||"black";o.select("g").attr({fill:u,stroke:u});var c=s(o,"width"),f=s(o,"height"),h=+t.attr("x")-c*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],d=-(r||s(t,"height"))/4;"y"===O[0]?(l.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-c/2,d-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===O[0]?o.attr({x:t.attr("x"),y:d-f/2}):"a"===O[0]?o.attr({x:0,y:d}):o.attr({x:h,y:+t.attr("y")+d-f/2}),v&&v.call(t,l),e(l)})})):D(),t}function D(){L.empty()||(O=t.attr("class")+"-math",L.select("svg."+O).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(m," ");var r,s=!1,l=[],u=-1;function c(){u++;var e=document.createElementNS(i.svg,"tspan");n.select(e).attr({class:"line",dy:u*o+"em"}),t.appendChild(e),r=e;var a=l;if(l=[{node:e}],a.length>1)for(var s=1;s doesnt match end tag <"+t+">. Pretending it did match.",e),r=l[l.length-1].node}else a.log("Ignoring unexpected end tag .",e)}x.test(e)?c():(r=t,l=[{node:t}]);for(var L=e.split(y),O=0;O|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},h={sub:"0.3em",sup:"-0.6em"},d={sub:"-0.21em",sup:"0.42em"},p="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),m=/(\r\n?|\n)/g,y=/(<[^<>]*>)/,b=/<(\/?)([^ >]*)(\s+(.*))?>/i,x=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,A=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,k=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function T(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&S(n)}var M=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var E={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},C=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function S(t){return t.replace(C,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):E[e])||t})}function L(t,e,r){var n,a,i,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),u=e.node().getBoundingClientRect();return a="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},i="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:a()-u.top+"px",left:i()-u.left+"px","z-index":1e3}),this}}r.convertEntities=S,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function a(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var i=a("x",e),o=a("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},r.makeEditable=function(t,e){var r=e.gd,a=e.delegate,i=n.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function s(){!function(){var a=n.select(r).select(".svg-container"),o=a.append("div"),s=t.node().style,u=parseFloat(s.fontSize||12),c=e.text;void 0===c&&(c=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":s.fontFamily||"Arial","font-size":u,color:e.fill||s.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-u/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(c).call(L(t,a,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=n.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),n.select(this).call(L(t,a,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(l)}(),t.style({opacity:0});var a,s=o.attr("class");(a=s?"."+s.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(a).style({opacity:0})}function l(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?s():o.on("click",s),n.rebind(t,i,"on")}},{"../constants/alignment":417,"../constants/xmlns_namespaces":421,"../lib":441,d3:85}],466:[function(t,e,r){"use strict";var n={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var i=n[t],o=Date.now();if(!i){for(var s in n)n[s].tsi.ts+e?l():i.timer=setTimeout(function(){l(),i.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)a(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],467:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":149}],468:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],469:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],470:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,a=n.layoutArrayContainers,i=n.layoutArrayRegexes,o=t.split("[")[0],s=0;s0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var n=(s.subplotsRegistry.cartesian||{}).attrRegex,i=(s.subplotsRegistry.gl3d||{}).attrRegex,l=Object.keys(t);for(e=0;e3?(M.x=1.02,M.xanchor="left"):M.x<-2&&(M.x=-.02,M.xanchor="right"),M.y>3?(M.y=1.02,M.yanchor="bottom"):M.y<-2&&(M.y=-.02,M.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=y(e);r;){if(r in t)return!0;r=y(r)}return!1};var b=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&o.warn("Full array edits are incompatible with other edits",f);var y=r[""][""];if(c(y))e.set(null);else{if(!Array.isArray(y))return o.warn("Unrecognized full array edit value",f,y),!0;e.set(y)}return!g&&(h(v,m),d(t),!0)}var b,x,_,w,A,k,T,M=Object.keys(r).map(Number).sort(s),E=e.get(),C=E||[],S=n(m,f).get(),L=[],O=-1,D=C.length;for(b=0;bC.length-(T?0:1))o.warn("index out of range",f,_);else if(void 0!==k)A.length>1&&o.warn("Insertion & removal are incompatible with edits to the same index.",f,_),c(k)?L.push(_):T?("add"===k&&(k={}),C.splice(_,0,k),S&&S.splice(_,0,{})):o.warn("Unrecognized full object edit value",f,_,k),-1===O&&(O=_);else for(x=0;x=0;b--)C.splice(L[b],1),S&&S.splice(L[b],1);if(C.length?E||e.set(C):e.set(null),g)return!1;if(h(v,m),p!==i){var R;if(-1===O)R=M;else{for(D=Math.max(C.length,D),R=[],b=0;b=O);b++)R.push(_);for(b=O;b=t.data.length||a<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(a,n+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+r+" must be unique.")}}function R(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),D(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&D(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function P(t,e,r,n,i){!function(t,e,r,n){var a=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var i in D(t,r,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==r.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in n)||!Array.isArray(n[i])||n[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var s=function(t,e,r,n){var i,s,l,u,c,f=o.isPlainObject(n),h=[];for(var d in Array.isArray(r)||(r=[r]),r=O(r,t.data.length-1),e)for(var p=0;p=0&&r=0&&r0&&"string"!=typeof S.parts[O];)O--;var D=S.parts[O],R=S.parts[O-1]+"."+D,P=S.parts.slice(0,O).join("."),z=o.nestedProperty(t.layout,P).get(),F=o.nestedProperty(s,P).get(),N=S.get();if(void 0!==L){y[C]=L,b[C]="reverse"===D?L:I(N);var B=c.getLayoutValObject(s,S.parts);if(B&&B.impliedEdits&&null!==L)for(var V in B.impliedEdits)x(o.relativeAttr(C,V),B.impliedEdits[V]);if(-1!==["width","height"].indexOf(C))if(L){x("autosize",null);var G="height"===C?"width":"height";x(G,s[G])}else s[C]=t._initialAutoSize[C];else if("autosize"===C)x("width",L?null:s.width),x("height",L?null:s.height);else if(R.match(j))E(R),o.nestedProperty(s,P+"._inputRange").set(null);else if(R.match(U)){E(R),o.nestedProperty(s,P+"._inputRange").set(null);var X=o.nestedProperty(s,P).get();X._inputDomain&&(X._input.domain=X._inputDomain.slice())}else R.match(H)&&o.nestedProperty(s,P+"._inputDomain").set(null);if("type"===D){var W=z,Y="linear"===F.type&&"log"===L,Z="log"===F.type&&"linear"===L;if(Y||Z){if(W&&W.range)if(F.autorange)Y&&(W.range=W.range[1]>W.range[0]?[1,2]:[2,1]);else{var J=W.range[0],Q=W.range[1];Y?(J<=0&&Q<=0&&x(P+".autorange",!0),J<=0?J=Q/1e6:Q<=0&&(Q=J/1e6),x(P+".range[0]",Math.log(J)/Math.LN10),x(P+".range[1]",Math.log(Q)/Math.LN10)):(x(P+".range[0]",Math.pow(10,J)),x(P+".range[1]",Math.pow(10,Q)))}else x(P+".autorange",!0);Array.isArray(s._subplots.polar)&&s._subplots.polar.length&&s[S.parts[0]]&&"radialaxis"===S.parts[1]&&delete s[S.parts[0]]._subplot.viewInitial["radialaxis.range"],u.getComponentMethod("annotations","convertCoords")(t,F,L,x),u.getComponentMethod("images","convertCoords")(t,F,L,x)}else x(P+".autorange",!0),x(P+".range",null);o.nestedProperty(s,P+"._inputRange").set(null)}else if(D.match(T)){var $=o.nestedProperty(s,C).get(),K=(L||{}).type;K&&"-"!==K||(K="linear"),u.getComponentMethod("annotations","convertCoords")(t,$,K,x),u.getComponentMethod("images","convertCoords")(t,$,K,x)}var tt=_.containerArrayMatch(C);if(tt){r=tt.array,n=tt.index;var et=tt.property,rt=(o.nestedProperty(i,r)||[])[n]||{},nt=B||{editType:"calc"};""!==n&&""===et&&(_.isAddVal(L)?b[C]=null:_.isRemoveVal(L)?b[C]=rt:o.warn("unrecognized full object value",e)),k.update(m,nt),h[r]||(h[r]={});var at=h[r][n];at||(at=h[r][n]={}),at[et]=L,delete e[C]}else"reverse"===D?(z.range?z.range.reverse():(x(P+".autorange",!0),z.range=[1,0]),F.autorange?m.calc=!0:m.plot=!0):(s._has("scatter-like")&&s._has("regl")&&"dragmode"===C&&("lasso"===L||"select"===L)&&"lasso"!==N&&"select"!==N?m.plot=!0:B?k.update(m,B):m.calc=!0,S.set(L))}}for(r in h){_.applyContainerArrayChanges(t,o.nestedProperty(i,r),h[r],m)||(m.plot=!0)}var it=s._axisConstraintGroups||[];for(A in M)for(n=0;n=a.length?a[0]:a[t]:a}function l(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function u(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(i,c){function h(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,f.transition(t,e.frame.data,e.frame.layout,w.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function d(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&h()};e()}var p,g,v=0;function m(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var y=[],b=null==e,x=Array.isArray(e);if(!b&&!x&&o.isPlainObject(e))y.push({type:"object",data:m(o.extendFlat({},e))});else if(b||-1!==["string","number"].indexOf(typeof e))for(p=0;p0&&kk)&&T.push(g);y=T}}y.length>0?function(e){if(0!==e.length){for(var a=0;a=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(c[g]||p[g]||{}).name,m=e[n].name,y=c[v]||p[v];v&&m&&"number"==typeof m&&y&&M<5&&(M++,o.warn('addFrames: overwriting frame "'+(c[v]||p[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===M&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),p[g]={name:g},d.push({frame:f.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:h+n})}d.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(a=d[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;c[a.name="frame "+t._transitionData._counter++];);if(c[a.name]){for(i=0;i=0;r--)n=e[r],i.push({type:"delete",index:n}),s.unshift({type:"insert",index:n,value:a[n]});var u=f.modifyFrames,c=f.modifyFrames,h=[t,s],d=[t,i];return l&&l.add(t,u,h,c,d),f.modifyFrames(t,i)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return f.cleanPlot([],{},r,e),f.purge(t),s.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":319,"../components/colorbar/connect":321,"../components/drawing":344,"../constants/xmlns_namespaces":421,"../lib":441,"../lib/events":431,"../lib/queue":456,"../lib/svg_text_utils":465,"../plots/cartesian/axes":488,"../plots/cartesian/constants":494,"../plots/cartesian/graph_interact":498,"../plots/plots":525,"../plots/polar/legacy":528,"../registry":532,"./edit_types":471,"./helpers":472,"./manage_arrays":474,"./plot_config":476,"./plot_schema":477,"./subroutines":479,d3:85,"fast-isnumeric":149,"has-hover":200}],476:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],477:[function(t,e,r){"use strict";var n=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),s=t("../plots/frame_attributes"),l=t("../plots/animation_attributes"),u=t("../plots/polar/legacy/area_attributes"),c=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),h=a.extendFlat,d=a.extendDeepAll,p=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",m=[g,v,"_arrayAttrRegexps","_deprecated"];function y(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(b(e[r]))r++;else if(r=i.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!b(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function b(t){return t===Math.round(t)&&t>=0}function x(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):p(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(p(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=l.length)return!1;a=(r=(n.transformsRegistry[l[c].type]||{}).attributes)&&r[e[2]],s=3}else if("area"===t.type)a=u[o];else{var f=t._module;if(f||(f=(n.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(r=f.attributes)&&r[o])){var h=f.basePlotModule;h&&h.attributes&&(a=h.attributes[o])}a||(a=i[o])}return y(a,e,s)},r.getLayoutValObject=function(t,e){return y(function(t,e){var r,a,i,s,l=t._basePlotModules;if(l){var u;for(r=0;r=a&&(r._input||{})._templateitemname;s&&(o=a);var l,u=e+"["+o+"]";function c(){l={},s&&(l[u]={},l[u][i]=s)}function f(t,e){s?n.nestedProperty(l[u],t).set(e):l[u+"."+t]=e}function h(){var t=l;return c(),t}return c(),{modifyBase:function(t,e){l[t]=e},modifyItem:f,getUpdateObj:h,applyUpdate:function(e,r){e&&f(e,r);var a=h();for(var i in a)n.nestedProperty(t,i).set(a[i])}}}},{"../lib":441,"../plots/attributes":485}],479:[function(t,e,r){"use strict";var n=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),s=t("../lib/clear_gl_canvases"),l=t("../components/color"),u=t("../components/drawing"),c=t("../components/titles"),f=t("../components/modebar"),h=t("../plots/cartesian/axes"),d=t("../constants/alignment"),p=t("../plots/cartesian/constraints"),g=p.enforce,v=p.clean,m=t("../plots/cartesian/autorange").doAutoRange;function y(t,e,r){for(var n=0;n=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function b(t){var e,a,i,s,c,p=t._fullLayout,g=p._size,v=g.p,m=h.list(t,"",!0);if(p._paperdiv.style({width:t._context.responsive&&p.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":p.width+"px",height:t._context.responsive&&p.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":p.height+"px"}).selectAll(".main-svg").call(u.setSize,p.width,p.height),t._context.setBackground(t,p.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!p._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function b(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-v-n:e._offset+e._length+v+n:g.t+g.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+v+n:e._offset-v-n:g.l+g.w*(t.position||0)+n%1}for(e=0;eA?c.push({code:"unused",traceType:y,templateCount:w,dataCount:A}):A>w&&c.push({code:"reused",traceType:y,templateCount:w,dataCount:A})}}else c.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var i=e[n],o=d(e,n,r);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&c.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&p(i)&&t(i,o)}}({data:v,layout:h},""),c.length)return c.map(g)}},{"../lib":441,"../plots/attributes":485,"../plots/plots":525,"./plot_config":476,"./plot_schema":477,"./plot_template":478}],481:[function(t,e,r){"use strict";var n=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),s=t("../snapshot/svgtoimg"),l={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},u=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,c,f;function h(t){return!(t in e)||a.validate(e[t],l[t])}if(e=e||{},a.isPlainObject(t)?(r=t.data||[],c=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),r=a.extendDeep([],t.data),c=a.extendDeep({},t.layout),f=t._context),!h("width")||!h("height"))throw new Error("Height and width should be pixel values.");if(!h("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var d={};function p(t,r){return a.coerce(e,d,l,t,r)}var g=p("format"),v=p("width"),m=p("height"),y=p("scale"),b=p("setBackground"),x=p("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},c);v&&(w.width=v),m&&(w.height=m);var A=a.extendFlat({},f,{staticPlot:!0,setBackground:b}),k=i.getRedrawFunc(_);function T(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function M(){return new Promise(function(t,e){var r=o(_,g,y),i=_._fullLayout.width,l=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(x?r:"data:image/svg+xml,"+encodeURIComponent(r));var u=document.createElement("canvas");u.id=a.randstr(),s({format:g,width:i,height:l,scale:y,canvas:u,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,A).then(k).then(T).then(M).then(function(e){t(function(t){return x?t.replace(u,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":441,"../snapshot/helpers":536,"../snapshot/svgtoimg":538,"../snapshot/tosvg":540,"./plot_api":475}],482:[function(t,e,r){"use strict";var n=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),s=n.isPlainObject,l=Array.isArray,u=n.isArrayOrTypedArray;function c(t,e,r,a,i,o){o=o||[];for(var f=Object.keys(t),h=0;hb.length&&a.push(d("unused",i,m.concat(b.length)));var k,T,M,E,C,S=b.length,L=Array.isArray(A);if(L&&(S=Math.min(S,A.length)),2===x.dimensions)for(T=0;Tb[T].length&&a.push(d("unused",i,m.concat(T,b[T].length)));var O=b[T].length;for(k=0;k<(L?Math.min(O,A[T].length):O);k++)M=L?A[T][k]:A,E=y[T][k],C=b[T][k],n.validate(E,M)?C!==E&&C!==+E&&a.push(d("dynamic",i,m.concat(T,k),E,C)):a.push(d("value",i,m.concat(T,k),E))}else a.push(d("array",i,m.concat(T),y[T]));else for(T=0;T1&&h.push(d("object","layout"))),a.supplyDefaults(p);for(var g=p._fullData,v=r.length,m=0;m0&&((x=T-o(v)-o(m))>M?_/x>E&&(y=v,b=m,E=_/x):_/T>E&&(y={val:v.val,pad:0},b={val:m.val,pad:0},E=_/T));if(h===d){var C=h-1,S=h+1;if(A)if(0===h)i=[0,1];else{var L=(h>0?f:c).reduce(function(t,e){return Math.max(t,o(e))},0),O=h/(1-Math.min(.5,L/T));i=h>0?[0,O]:[O,0]}else i=k?[Math.max(0,C),Math.max(1,S)]:[C,S]}else A?(y.val>=0&&(y={val:0,pad:0}),b.val<=0&&(b={val:0,pad:0})):k&&(y.val-E*o(y)<0&&(y={val:0,pad:0}),b.val<=0&&(b={val:1,pad:0})),E=(b.val-y.val)/(T-o(y)-o(b)),i=[y.val-E*o(y),b.val+E*o(b)];return p&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function s(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function l(t,e){var r,n,a,i=e._id,o=t._fullData,s=t._fullLayout,l=[],f=[];function h(t,e){for(r=0;r=r&&(u.extrapad||!o)){s=!1;break}a(e,u.val)&&u.pad<=r&&(o||!u.extrapad)&&(t.splice(l,1),l--)}if(s){var c=i&&0===e;t.push({val:e,pad:c?0:r,extrapad:!c&&o})}}function h(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:o,makePadFn:s,doAutoRange:function(t,e){e._length||e.setScale();var r;e.autorange&&(e.range=o(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l),(r=e._input).range=e.range.slice(),r.autorange=e.autorange);if(e._anchorAxis&&e._anchorAxis.rangeslider){var n=e._anchorAxis.rangeslider[e._name];n&&"auto"===n.rangemode&&(n.range=o(t,e)),(r=e._anchorAxis._input).rangeslider[e._name]=a.extendFlat({},n)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var a,o,s,l,f,d,p,g,v,m=[],y=[],b=e.length,x=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,A=!1;function k(t){if(Array.isArray(t))return A=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var T=k((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),M=k((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),E=k(r.vpadplus||r.vpad),C=k(r.vpadminus||r.vpad);if(!A){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=O;a--)L(a);return{min:m,max:y}},concatExtremes:l}},{"../../constants/numerical":420,"../../lib":441,"fast-isnumeric":149}],488:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../../components/titles"),c=t("../../components/color"),f=t("../../components/drawing"),h=t("./layout_attributes"),d=t("./clean_ticks"),p=t("../../constants/numerical"),g=p.ONEAVGYEAR,v=p.ONEAVGMONTH,m=p.ONEDAY,y=p.ONEHOUR,b=p.ONEMIN,x=p.ONESEC,_=p.MINUS_SIGN,w=p.BADNUM,A=t("../../constants/alignment").MID_SHIFT,k=t("../../constants/alignment").LINE_SPACING,T=e.exports={};T.setConvert=t("./set_convert");var M=t("./axis_autotype"),E=t("./axis_ids");T.id2name=E.id2name,T.name2id=E.name2id,T.cleanId=E.cleanId,T.list=E.list,T.listIds=E.listIds,T.getFromId=E.getFromId,T.getFromTrace=E.getFromTrace;var C=t("./autorange");T.getAutoRange=C.getAutoRange,T.findExtremes=C.findExtremes,T.coerceRef=function(t,e,r,n,a,i){var o=n.charAt(n.length-1),l=r._fullLayout._subplots[o+"axis"],u=n+"ref",c={};return a||(a=l[0]||i),i||(i=a),c[u]={valType:"enumerated",values:l.concat(i?[i]:[]),dflt:a},s.coerce(t,e,c,u)},T.coercePosition=function(t,e,r,n,a,i){var o,l;if("paper"===n||"pixel"===n)o=s.ensureNumber,l=r(a,i);else{var u=T.getFromId(e,n);l=r(a,i=u.fraction2r(i)),o=u.cleanPos}t[a]=o(l)},T.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?s.ensureNumber:T.getFromId(e,r).cleanPos)(t)};var S=T.getDataConversions=function(t,e,r,n){var a,i="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(i)){if(a={type:M(n),_categories:[]},T.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.saveRangeInitial=function(t,e){for(var r=T.list(t,"",!0),n=!1,a=0;a.3*h||c(n)||c(i))){var d=r.dtick/2;t+=t+d.8){var o=Number(r.substr(1));i.exactYears>.8&&o%12==0?t=T.tickIncrement(t,"M6","reverse")+1.5*m:i.exactMonths>.8?t=T.tickIncrement(t,"M1","reverse")+15.5*m:t-=m/2;var l=T.tickIncrement(t,r);if(l<=n)return l}return t}(b,t,y,u,i)),v=b,0;v<=c;)v=T.tickIncrement(v,y,!1,i),0;return{start:e.c2r(b,0,i),end:e.c2r(v,0,i),size:y,_dataSpan:c-u}},T.prepTicks=function(t){var e=s.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=s.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),T.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},T.calcTicks=function(t){T.prepTicks(t);var e=s.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e,r,n=t.tickvals,a=t.ticktext,i=new Array(n.length),o=s.simpleMap(t.range,t.r2l),l=1.0001*o[0]-1e-4*o[1],u=1.0001*o[1]-1e-4*o[0],c=Math.min(l,u),f=Math.max(l,u),h=0;Array.isArray(a)||(a=[]);var d="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(r=0;rc&&e=n:u<=n)&&!(i.length>l||u===o);u=T.tickIncrement(u,t.dtick,a,t.calendar))o=u,i.push(u);J(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var c=new Array(i.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=m&&i<=10||e>=15*m)t._tickround="d";else if(e>=b&&i<=16||e>=y)t._tickround="M";else if(e>=x&&i<=19||e>=b)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var s=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var l=Math.max(Math.abs(s[0]),Math.abs(s[1])),u=Math.floor(Math.log(l)/Math.LN10+.01);Math.abs(u)>3&&(V(t.exponentformat)&&!q(u)?t._tickexponent=3*Math.round((u-1)/3):t._tickexponent=u)}else t._tickround=null}function U(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}T.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=s.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,r=n(10),t.dtick="M"+12*B(e,r,D)):i>v?(e/=v,t.dtick="M"+B(e,1,R)):i>m?(t.dtick=B(e,m,z),t.tick0=s.dateTick0(t.calendar,!0)):i>y?t.dtick=B(e,y,R):i>b?t.dtick=B(e,b,P):i>x?t.dtick=B(e,x,P):(r=n(10),t.dtick=B(e,r,D))}else if("log"===t.type){t.tick0=0;var o=s.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var l=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/l,r=n(10),t.dtick="L"+B(e,r,D)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):J(t)?(t.tick0=0,r=1,t.dtick=B(e,r,N)):(t.tick0=0,r=n(10),t.dtick=B(e,r,D));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var u=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(u)}},T.tickIncrement=function(t,e,r,i){var o=r?-1:1;if(a(e))return t+o*e;var l=e.charAt(0),u=o*Number(e.substr(1));if("M"===l)return s.incrementMonth(t,u,i);if("L"===l)return Math.log(Math.pow(10,t)+u)/Math.LN10;if("D"===l){var c="D2"===e?F:I,f=t+.01*o,h=s.roundUp(s.mod(f,1),c,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.r2l||Number,r=s.simpleMap(t.range,e),i=r[1]"+l,t._prevDateHead=l));e.text=u}(t,o,r,u):"log"===t.type?function(t,e,r,n,i){var o=t.dtick,l=e.x,u=t.tickformat,c="string"==typeof o&&o.charAt(0);"never"===i&&(i="");n&&"L"!==c&&(o="L3",c="L");if(u||"L"===c)e.text=G(Math.pow(10,l),t,i,n);else if(a(o)||"D"===c&&s.mod(l+.01,1)<.1){var f=Math.round(l),h=Math.abs(f),d=t.exponentformat;"power"===d||V(d)&&q(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+h+"",e.fontSize*=1.25):("e"===d||"E"===d)&&h>2?e.text="1"+d+(f>0?"+":_)+h:(e.text=G(Math.pow(10,l),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==c)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,s.mod(l,1)))),e.fontSize*=.75}if("D1"===t.dtick){var p=String(e.text).charAt(0);"0"!==p&&"1"!==p||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(l<0?.5:.25)))}}(t,o,0,u,n):"category"===t.type?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,o):J(t)?function(t,e,r,n,a){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,a,n);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,a=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/a),Math.round(r/a)]}(i);if(o[1]>=100)e.text=G(s.deg2rad(e.x),t,a,n);else{var l=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),l&&(e.text=_+e.text)}}}}(t,o,r,u,n):function(t,e,r,n,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,n)}(t,o,0,u,n),t.tickprefix&&!d(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!d(t.showticksuffix)&&(o.text+=t.ticksuffix),o},T.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return T.hoverLabelText(t,e)+" - "+T.hoverLabelText(t,r);var n="log"===t.type&&e<=0,a=T.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+a:a};var H=["f","p","n","\u03bc","m","","k","M","G","T"];function V(t){return"SI"===t||"B"===t}function q(t){return t>14||t<-15}function G(t,e,r,n){var i=t<0,o=e._tickround,l=r||e.exponentformat||"B",u=e._tickexponent,c=T.getTickFormat(e),f=e.separatethousands;if(n){var h={exponentformat:l,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(h),o=(Number(h._tickround)||0)+4,u=h._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return e._numFormat(c)(t).replace(/-/g,_);var d,p=Math.pow(10,-o)/2;if("none"===l&&(u=0),(t=Math.abs(t))"+d+"":"B"===l&&9===u?t+="B":V(l)&&(t+=H[u/3+5]));return i?_+t:t}function X(t,e){var r=t.l2p(e);return r>1&&r=0,i=c(t,e[1])<=0;return(r||a)&&(n||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},s=0;s2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":532,"./constants":494}],492:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var s,l=r("categoryorder",a);"array"===l&&(s=r("categoryarray")),o||"array"!==l||(l=e.categoryorder="trace"),"trace"===l?e._initialCategories=[]:"array"===l?e._initialCategories=s.slice():(s=function(t,e){var r,n,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;ns*b)||A)for(r=0;rR&&IO&&(O=I);d/=(O-L)/(2*D),L=c.l2r(L),O=c.l2r(O),c.range=c._input.range=E=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function P(t,e,r,n,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",a+"Z")}function z(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:u.background,stroke:u.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function I(t,e,r,n,a,i){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),F(t,e,a,i)}function F(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function N(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function B(t){E&&t.data&&t._context.showTips&&(s.notifier(s._(t,"Double-click to zoom back out"),"long"),E=!1)}function j(t){return"lasso"===t||"select"===t}function U(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,M)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function H(t,e){if(i){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function V(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,i,u,h,E,C){var F,q,G,X,W,Y,Z,J,Q,$,K,tt,et,rt,nt,at,it,ot,st,lt,ut,ct=t._fullLayout._zoomlayer,ft=E+C==="nsew",ht=1===(E+C).length;function dt(){if(F=e.xaxis,q=e.yaxis,Q=F._length,$=q._length,Z=F._offset,J=q._offset,(G={})[F._id]=F,(X={})[q._id]=q,E&&C)for(var r=e.overlays,n=0;n-1&&w(a,t,W,Y,e.id,Mt),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===r&&ht){var s=E?q:F,u="s"===E||"w"===C?0:1,c=s._name+".range["+u+"]",h=function(t,e){var r,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,a))):(r=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,n.format("."+String(r)+"g")(a))}(s,u),d="left",p="middle";if(s.fixedrange)return;E?(p="n"===E?"top":"bottom","right"===s.side&&(d="right")):"e"===C&&(d="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(l.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(h),fill:s.tickfont?s.tickfont.color:"#444",horizontalAlign:d,verticalAlign:p}).on("edit",function(e){var r=s.d2r(e);void 0!==r&&o.call("relayout",t,c,r)})}}function St(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min(Q,e+vt)),a=Math.max(0,Math.min($,r+mt)),i=Math.abs(n-vt),o=Math.abs(a-mt);function s(){wt="",yt.r=yt.l,yt.t=yt.b,kt.attr("d","M0,0Z")}yt.l=Math.min(vt,n),yt.r=Math.max(vt,n),yt.t=Math.min(mt,a),yt.b=Math.max(mt,a),nt?i>M||o>M?(wt="xy",i/Q>o/$?(o=i*$/Q,mt>a?yt.t=mt-o:yt.b=mt+o):(i=o*Q/$,vt>n?yt.l=vt-i:yt.r=vt+i),kt.attr("d",U(yt))):s():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Pt);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var a,i=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=It.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-o.left)/o.width,u=(o.bottom-e.clientY)/o.height;if(at){for(C||(l=.5),a=0;ag[1]-.01&&(e.domain=s),a.noneOrAll(t.domain,e.domain,s)}return r("layer"),e}},{"../../lib":441,"fast-isnumeric":149}],505:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*r;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":417}],506:[function(t,e,r){"use strict";var n=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),s=t("../../lib/polygon"),l=t("../../lib/throttle"),u=t("../../components/fx/helpers").makeEventData,c=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),h=t("../../plot_api/subroutines").redrawReglTraces,d=t("./constants"),p=d.MINSELECT,g=s.filter,v=s.tester;function m(t){return t._id}function y(t,e,r,n,a,i,o){var s,l,u,c,f,h,d,p,g,v=e._hoverdata,m=e._fullLayout.clickmode.indexOf("event")>-1,y=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var b=function(t,e){var r,n,a=t[0],i=-1,o=[];for(n=0;n0?function(t,e){var r,n,a,i=[];for(a=0;a0&&i.push(r);if(1===i.length&&i[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=r.selectedpoints.length)>1)return!1}return 1===a}(s)&&(h=M(b))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",n)}function M(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,a=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function E(t,e,r){var n,i,o,s;if(r){var l=r.points||[];for(n=0;n-1&&y(e,M,a.xaxes,a.yaxes,a.subplot,a,q),"event"===r&&M.emit("plotly_selected",void 0);o.click(M,e)})},a.doneFn=function(){X.remove(),l.done(W).then(function(){l.clear(W),a.gd.emit("plotly_selected",x),h&&a.selectionDefs&&(h.subtract=V,a.selectionDefs.push(h),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:S,selectOnClick:y}},{"../../components/color":319,"../../components/fx":361,"../../components/fx/helpers":358,"../../lib/clear_gl_canvases":427,"../../lib/polygon":453,"../../lib/throttle":466,"../../plot_api/subroutines":479,"../../registry":532,"./axis_ids":491,"./constants":494,polybooljs:240}],507:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,s=i.ms2DateTime,l=i.dateTime2ms,u=i.ensureNumber,c=t("../../constants/numerical"),f=c.FP_SAFE,h=c.BADNUM,d=c.LOG_CLIP,p=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function c(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],a=t.range[1];return.5*(n+a-2*d*Math.abs(n-a))}return h}function m(e,r,n){var o=l(e,n||t.calendar);if(o===h){if(!a(e))return h;e=+e;var s=Math.floor(10*i.mod(e+.05,1)),u=Math.round(e-s/10);o=l(new Date(u))+s/10}return o}function y(e,r,n){return s(e,r,n||t.calendar)}function b(e){return t._categories[Math.round(e)]}function x(e){if(t._categoriesMap){var r=t._categoriesMap[e];if(void 0!==r)return r}if(a(e))return+e}function _(e){return a(e)?n.round(t._b+t._m*e,2):h}function w(e){return(e-t._b)/t._m}t.c2l="log"===t.type?c:u,t.l2c="log"===t.type?v:u,t.l2p=_,t.p2l=w,t.c2p="log"===t.type?function(t,e){return _(c(t,e))}:_,t.p2c="log"===t.type?function(t){return v(w(t))}:w,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=u,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=w,t.cleanPos=u):"log"===t.type?(t.d2r=t.d2l=function(t,e){return c(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=u,t.c2r=c,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(w(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=w,t.cleanPos=u):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=m,t.c2d=t.c2r=t.l2d=t.l2r=y,t.d2p=t.r2p=function(e,r,n){return t.l2p(m(e,0,n))},t.p2d=t.p2r=function(t,e,r){return y(w(t),e,r)},t.cleanPos=function(e){return i.cleanDate(e,h,t.calendar)}):"category"===t.type&&(t.d2c=t.d2l=function(e){if(null!=e){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return h},t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=x,t.r2c=function(e){var r=x(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=u,t.r2l=x,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(w(t))},t.r2p=t.d2p,t.p2r=w,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:u(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,s,l=i.nestedProperty(t,e).get();if(s=(s="date"===t.type?i.dfltRange(t.calendar):"y"===r?p.DFLTRANGEY:n.dfltRange||p.DFLTRANGEX).slice(),l&&2===l.length)for("date"===t.type&&(l[0]=i.cleanDate(l[0],h,t.calendar),l[1]=i.cleanDate(l[1],h,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(l[o],t.calendar)){t[e]=s;break}if(t.r2l(l[0])===t.r2l(l[1])){var u=i.constrain(t.r2l(l[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);l[0]=t.l2r(u-1e3),l[1]=t.l2r(u+1e3);break}}else{if(!a(l[o])){if(!a(l[1-o])){t[e]=s;break}l[o]=l[1-o]*(o?10:.1)}if(l[o]<-f?l[o]=-f:l[o]>f&&(l[o]=f),l[0]===l[1]){var c=Math.max(1,Math.abs(1e-6*l[0]));l[0]-=c,l[1]+=c}}else i.nestedProperty(t,e).set(s)},t.setScale=function(n){var a=e._size;if(t._categories||(t._categories=[]),t._categoriesMap||(t._categoriesMap={}),t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=n&&t._r?"_r":"range",s=t.calendar;t.cleanRange(o);var l=t.r2l(t[o][0],s),u=t.r2l(t[o][1],s);if("y"===r?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(l-u),t._b=-t._m*u):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(u-l),t._b=-t._m*l),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,a,o,s,l=t.type,u="date"===l&&e[r+"calendar"];if(r in e){if(n=e[r],s=e._length||n.length,i.isTypedArray(n)&&("linear"===l||"log"===l)){if(s===n.length)return n;if(n.subarray)return n.subarray(0,s)}for(a=new Array(s),o=0;o rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,r._offset).call(i.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(i.setPointGroupScale,1,1),n.selectAll(".textpoint").call(i.setTextPointsScale,1,1),n.call(i.hideOutsideRangePoints,t)}function b(e,r){var n,s,l,c=g[e.xaxis._id],f=g[e.yaxis._id],h=[];if(c){s=(n=t._fullLayout[c.axisName])._r,l=c.to,h[0]=(s[0]*(1-r)+r*l[0]-s[0])/(s[1]-s[0])*e.xaxis._length;var d=s[1]-s[0],p=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[2]=e.xaxis._length*(1-r+r*p/d)}else h[0]=0,h[2]=e.xaxis._length;if(f){s=(n=t._fullLayout[f.axisName])._r,l=f.to,h[1]=(s[1]*(1-r)+r*l[1]-s[1])/(s[0]-s[1])*e.yaxis._length;var v=s[1]-s[0],m=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[3]=e.yaxis._length*(1-r+r*m/v)}else h[1]=0,h[3]=e.yaxis._length;!function(e,r){var n,i=[];for(i=[e._id,r._id],n=0;nr.duration?(function(){for(var e={},r=0;r0&&(a["_"+r+"axes"]||{})[e])return a;if((a[r+"axis"]||r)===e){if(o(a,r))return a;if((a[r]||[]).length||a[r+"0"])return a}}}(e,r,s);if(!l)return;if("histogram"===l.type&&s==={v:"y",h:"x"}[l.orientation||"v"])return void(t.type="linear");var u,c=s+"calendar",f=l[c];if(o(l,s)){var h=i(l),d=[];for(u=0;u0?".":"")+i;a.isPlainObject(o)?l(o,e,s,n+1):e(s,i,o)}})}r.manageCommandObserver=function(t,e,n,o){var s={},l=!0;e&&e._commandObserver&&(s=e._commandObserver),s.cache||(s.cache={}),s.lookupTable={};var u=r.hasSimpleAPICommandBindings(t,n,s.lookupTable);if(e&&e._commandObserver){if(u)return s;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,s}if(u){i(t,u,s.cache),s.check=function(){if(l){var e=i(t,u,s.cache);return e.changed&&o&&void 0!==s.lookupTable[e.value]&&(s.disable(),Promise.resolve(o({value:e.value,type:u.type,prop:u.prop,traces:u.traces,index:s.lookupTable[e.value]})).then(s.enable,s.enable)),e.changed}};for(var c=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;fMath.abs(s)?(u.boxEnd[1]=u.boxStart[1]+Math.abs(i)*_*(s>=0?1:-1),u.boxEnd[1]l[3]&&(u.boxEnd[1]=l[3],u.boxEnd[0]=u.boxStart[0]+(l[3]-u.boxStart[1])/Math.abs(_))):(u.boxEnd[0]=u.boxStart[0]+Math.abs(s)/_*(i>=0?1:-1),u.boxEnd[0]l[2]&&(u.boxEnd[0]=l[2],u.boxEnd[1]=u.boxStart[1]+(l[2]-u.boxStart[0])*Math.abs(_)))}}else u.boxEnabled?(i=u.boxStart[0]!==u.boxEnd[0],s=u.boxStart[1]!==u.boxEnd[1],i||s?(i&&(v(0,u.boxStart[0],u.boxEnd[0]),t.xaxis.autorange=!1),s&&(v(1,u.boxStart[1],u.boxEnd[1]),t.yaxis.autorange=!1),t.relayoutCallback()):t.glplot.setDirty(),u.boxEnabled=!1,u.boxInited=!1):u.boxInited&&(u.boxInited=!1);break;case"pan":u.boxEnabled=!1,u.boxInited=!1,e?(u.panning||(u.dragStart[0]=n,u.dragStart[1]=a),Math.abs(u.dragStart[0]-n)=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),r.attr(i);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),a=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+a})}}(t,o),s.text(o.text()&&c.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),a=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var b,x=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,a={};function o(t){for(var r=!0,i=0;i1&&R.length>1){for(i.getComponentMethod("grid","sizeDefaults")(u,s),o=0;o15&&R.length>15&&0===s.shapes.length&&0===s.images.length,s._hasCartesian=s._has("cartesian"),s._hasGeo=s._has("geo"),s._hasGL3D=s._has("gl3d"),s._hasGL2D=s._has("gl2d"),s._hasTernary=s._has("ternary"),s._hasPie=s._has("pie"),v.linkSubplots(h,s,c,a),v.cleanPlot(h,s,c,a),p(s,a),v.doAutoMargin(t);var N=f.list(t);for(o=0;o0){var f=1-2*s;n=Math.round(f*n),i=Math.round(f*i)}}var h=v.layoutAttributes.width.min,d=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-i)>1;(g||p)&&(p&&(r.width=n),g&&(r.height=i)),t._initialAutoSize||(t._initialAutoSize={width:n,height:i}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var a,o,s,u=i.componentsRegistry,c=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in u)(s=u[a]).includeBasePlot&&s.includeBasePlot(t,e);for(var h in c.length||c.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[h].sort(l.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var l=void 0!==r.xl?r.xl:r.x,u=void 0!==r.xr?r.xr:r.x,c=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;a[e]={l:{val:l,size:r.l+o},r:{val:u,size:r.r+o},b:{val:f,size:r.b+o},t:{val:c,size:r.t+o}},i[e]=1}else delete a[e],delete i[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),T(e);var r=e._size,n=JSON.stringify(r),o=Math.max(e.margin.l||0,0),s=Math.max(e.margin.r||0,0),l=Math.max(e.margin.t||0,0),u=Math.max(e.margin.b||0,0),c=e._pushmargin,f=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var h in c)f[h]||delete c[h];for(var d in c.base={l:{val:0,size:o},r:{val:1,size:s},t:{val:1,size:l},b:{val:0,size:u}},c){var p=c[d].l||{},g=c[d].b||{},v=p.val,m=p.size,y=g.val,b=g.size;for(var x in c){if(a(m)&&c[x].r){var _=c[x].r.val,w=c[x].r.size;if(_>v){var A=(m*_+(w-e.width)*v)/(_-v),k=(w*(1-v)+(m-e.width)*(1-_))/(_-v);A>=0&&k>=0&&A+k>o+s&&(o=A,s=k)}}if(a(b)&&c[x].t){var M=c[x].t.val,E=c[x].t.size;if(M>y){var C=(b*M+(E-e.height)*y)/(M-y),S=(E*(1-y)+(b-e.height)*(1-M))/(M-y);C>=0&&S>=0&&C+S>u+l&&(u=C,l=S)}}}}}if(r.l=Math.round(o),r.r=Math.round(s),r.t=Math.round(l),r.b=Math.round(u),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,r,n,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,s=(t._transitionData||{})._frames;function u(t){if("function"==typeof t)return null;if(l.isPlainObject(t)){var e,n,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!l.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;a[e]=u(t[e])}return a}return Array.isArray(t)?t.map(u):l.isTypedArray(t)?l.simpleMap(t,l.identity):l.isJSDate(t)?l.ms2DateTimeLocal(+t):t}var c={data:(i||[]).map(function(t){var r=u(t);return e&&delete r.fit,r})};return e||(c.layout=u(o)),t.framework&&t.framework.isPolar&&(c=t.framework.getConfig()),s&&(c.frames=u(s)),"object"===n?c:JSON.stringify(c)},v.modifyFrames=function(t,e){var r,n,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){d=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,s,u=0,c=0;function f(){return u++,function(){var r;c++,d||c!==u||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var p=t._fullLayout._basePlotModules,g=!1;if(r)for(s=0;s=0;s--)if(o[s].enabled){r._indexToPoints=o[s]._indexToPoints;break}n&&n.calc&&(i=n.calc(t,r))}Array.isArray(i)&&i[0]||(i=[{x:c,y:c}]),i[0].t||(i[0].t={}),i[0].trace=r,p[e]=i}}for(y&&M(u),a=0;a=0?h.angularAxis.domain:n.extent(A),C=Math.abs(A[1]-A[0]);T&&!k&&(C=0);var S=E.slice();M&&k&&(S[1]+=C);var L=h.angularAxis.ticksCount||4;L>8&&(L=L/(L/8)+L%8),h.angularAxis.ticksStep&&(L=(S[1]-S[0])/L);var O=h.angularAxis.ticksStep||(S[1]-S[0])/(L*(h.minorTicks+1));w&&(O=Math.max(Math.round(O),1)),S[2]||(S[2]=O);var D=n.range.apply(this,S);if(D=D.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=n.scale.linear().domain(S.slice(0,2)).range("clockwise"===h.direction?[0,360]:[360,0]),c.layout.angularAxis.domain=s.domain(),c.layout.angularAxis.endPadding=M?C:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var R=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),P=this.appendChild(this.ownerDocument.importNode(R.documentElement,!0));t=n.select(P)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var z,I=t.select(".chart-group"),F={fill:"none",stroke:h.tickColor},N={"font-size":h.font.size,"font-family":h.font.family,fill:h.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+h.font.outlineColor}).join(",")};if(h.showLegend){z=t.select(".legend-group").attr({transform:"translate("+[b,h.margin.top]+")"}).style({display:"block"});var B=d.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:z,elements:B,reverseOrder:h.legend.reverseOrder})})();var j=z.node().getBBox();b=Math.min(h.width-j.width-h.margin.left-h.margin.right,h.height-h.margin.top-h.margin.bottom)/2,b=Math.max(10,b),_=[h.margin.left+b,h.margin.top+b],r.range([0,b]),c.layout.radialAxis.domain=r.domain(),z.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else z=t.select(".legend-group").style({display:"none"});t.attr({width:h.width,height:h.height}).style({opacity:h.opacity}),I.attr("transform","translate("+_+")").style({cursor:"crosshair"});var U=[(h.width-(h.margin.left+h.margin.right+2*b+(j?j.width:0)))/2,(h.height-(h.margin.top+h.margin.bottom+2*b))/2];if(U[0]=Math.max(0,U[0]),U[1]=Math.max(0,U[1]),t.select(".outer-group").attr("transform","translate("+U+")"),h.title){var H=t.select("g.title-group text").style(N).text(h.title),V=H.node().getBBox();H.attr({x:_[0]-V.width/2,y:_[1]-b-20})}var q=t.select(".radial.axis-group");if(h.radialAxis.gridLinesVisible){var G=q.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(F),G.attr("r",r),G.exit().remove()}q.select("circle.outside-circle").attr({r:b}).style(F);var X=t.select("circle.background-circle").attr({r:b}).style({fill:h.backgroundColor,stroke:h.stroke});function W(t,e){return s(t)%360+h.orientation}if(h.radialAxis.visible){var Y=n.svg.axis().scale(r).ticks(5).tickSize(5);q.call(Y).attr({transform:"rotate("+h.radialAxis.orientation+")"}),q.selectAll(".domain").style(F),q.selectAll("g>text").text(function(t,e){return this.textContent+h.radialAxis.ticksSuffix}).style(N).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===h.radialAxis.tickOrientation?"rotate("+-h.radialAxis.orientation+") translate("+[0,N["font-size"]]+")":"translate("+[0,N["font-size"]]+")"}}),q.selectAll("g>line").style({stroke:"black"})}var Z=t.select(".angular.axis-group").selectAll("g.angular-tick").data(D),J=Z.enter().append("g").classed("angular-tick",!0);Z.attr({transform:function(t,e){return"rotate("+W(t)+")"}}).style({display:h.angularAxis.visible?"block":"none"}),Z.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(h.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(h.minorTicks+1)==0)}).style(F),J.selectAll(".minor").style({stroke:h.minorTickColor}),Z.select("line.grid-line").attr({x1:h.tickLength?b-h.tickLength:0,x2:b}).style({display:h.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(N);var Q=Z.select("text.axis-text").attr({x:b+h.labelOffset,dy:i+"em",transform:function(t,e){var r=W(t),n=b+h.labelOffset,a=h.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-r+" "+n+" 0)":"radial"==a?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:h.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(h.minorTicks+1)!=0?"":w?w[t]+h.angularAxis.ticksSuffix:t+h.angularAxis.ticksSuffix}).style(N);h.angularAxis.rewriteTicks&&Q.text(function(t,e){return e%(h.minorTicks+1)!=0?"":h.angularAxis.rewriteTicks(this.textContent,e)});var $=n.max(I.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));z.attr({transform:"translate("+[b+$,h.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(d);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),d[0]||K){var et=[];d.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=s,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=h.orientation,n.direction=h.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return a(o[r].defaultConfig(),t)});o[r]().config(n)()})}var at,it,ot=t.select(".guides-group"),st=t.select(".tooltips-group"),lt=o.tooltipPanel().config({container:st,fontSize:8})(),ut=o.tooltipPanel().config({container:st,fontSize:8})(),ct=o.tooltipPanel().config({container:st,hasTick:!0})();if(!k){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});I.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(X).angle;ft.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-h.orientation)%360;at=s.invert(n);var a=o.util.convertToCartesian(b+12,r+180);lt.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var ht=ot.select("circle").style({stroke:"grey",fill:"none"});I.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(X).radius;ht.attr({r:n}).style({opacity:.5}),it=r.invert(o.util.getMousePos(X).radius);var a=o.util.convertToCartesian(n,h.radialAxis.orientation);ut.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){ht.style({opacity:0}),ct.hide(),lt.hide(),ut.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var a=n.select(this),i=this.style.fill,s="black",l=this.style.opacity||1;if(a.attr({"data-opacity":l}),i&&"none"!==i){a.attr({"data-fill":i}),s=n.hsl(i).darker().toString(),a.style({fill:s,opacity:1});var u={t:o.util.round(e[0]),r:o.util.round(e[1])};k&&(u.t=w[e[0]]);var c="t: "+u.t+", r: "+u.r,f=this.getBoundingClientRect(),h=t.node().getBoundingClientRect(),d=[f.left+f.width/2-U[0]-h.left,f.top+f.height/2-U[1]-h.top];ct.config({color:s}).text(c),ct.move(d)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),s=n.hsl(i).darker().toString(),a.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ct.show()}).on("mouseout.tooltip",function(t,e){ct.hide();var r=n.select(this),a=r.attr("data-fill");a?r.style({fill:a,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(u),this},h.config=function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),a(l.data[e],o.Axis.defaultConfig().data[0]),a(l.data[e],t)}),a(l.layout,o.Axis.defaultConfig().layout),a(l.layout,e.layout),this},h.getLiveConfig=function(){return c},h.getinputConfig=function(){return u},h.radialScale=function(t){return r},h.angularScale=function(t){return s},h.svg=function(){return t},n.rebind(h,f,"on"),h},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var a=e||6,i=[],o=[];n.range(0,360+a,a).forEach(function(e,r){var n=e*Math.PI/180,a=t(n);i.push(e),o.push(a)});var s={t:i,r:o};return r&&(s.name=r),s},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],a=e[1],i={};return i.x=r,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,r)+Math.PI)/Math.PI,i.radius=Math.sqrt(r*r+a*a),i},o.util.duplicatesCount=function(t){for(var e,r={},n={},a=0,i=t.length;a0)){var l=n.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:c(s),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return p.fill(r,a,i)},"fill-opacity":0,stroke:function(t,e){return p.stroke(r,a,i)},"stroke-width":function(t,e){return p["stroke-width"](r,a,i)},"stroke-dasharray":function(t,e){return p["stroke-dasharray"](r,a,i)},opacity:function(t,e){return p.opacity(r,a,i)},display:function(t,e){return p.display(r,a,i)}})}};var f=e.angularScale.range(),h=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,d=n.svg.arc().startAngle(function(t){return-h/2}).endAngle(function(t){return h/2}).innerRadius(function(t){return e.radialScale(l+(t[2]||0))}).outerRadius(function(t){return e.radialScale(l+(t[2]||0))+e.radialScale(t[1])});u.arc=function(t,r,a){n.select(this).attr({class:"mark arc",d:d,transform:function(t,r){return"rotate("+(e.orientation+s(t[0])+90)+")"}})};var p={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,a){return r[t[a].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(p).each(u[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),a(t[r],o.PolyChart.defaultConfig()),a(t[r],e)}),this):t},i.getColorScale=function(){},n.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,i=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var i=a({},e.elements[r]);return i.name=t,i.color=[].concat(e.elements[r].color)[n],i})}),o=n.merge(i);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var s=e.container;("string"==typeof s||s.nodeName)&&(s=n.select(s));var l=o.map(function(t,e){return t.color}),u=e.fontSize,c=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=c?e.height:u*o.length,h=s.classed("legend-group",!0).selectAll("svg").data([0]),d=h.enter().append("svg").attr({width:300,height:f+u,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});d.append("g").classed("legend-axis",!0),d.append("g").classed("legend-marks",!0);var p=n.range(o.length),g=n.scale[c?"linear":"ordinal"]().domain(p).range(l),v=n.scale[c?"linear":"ordinal"]().domain(p)[c?"range":"rangePoints"]([0,f]);if(c){var m=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);m.enter().append("stop"),m.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var y=h.select(".legend-marks").selectAll("path.legend-mark").data(o);y.enter().append("path").classed("legend-mark",!0),y.attr({transform:function(t,e){return"translate("+[u/2,v(e)+u/2]+")"},d:function(t,e){var r,a,i,o=t.symbol;return i=3*(a=u),"line"===(r=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(i)():n.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),y.exit().remove()}var b=n.svg.axis().scale(v).orient("right"),x=h.select("g.legend-axis").attr({transform:"translate("+[c?e.colorBandWidth:u,u/2]+")"}).call(b);return x.selectAll(".domain").style({fill:"none",stroke:"none"}),x.selectAll("line").style({fill:"none",stroke:c?e.textColor:"none"}),x.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(a(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,u=function(){var n=(t=i.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:i.padding+l,dy:.3*+i.fontSize}),u};return u.text=function(a){var o=n.hsl(i.color).l,s=o>=.5?"#aaa":"white",c=o>=.5?"black":"white",f=a||"";e.style({fill:c,"font-size":i.fontSize+"px"}).text(f);var h=i.padding,d=e.node().getBBox(),p={fill:i.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[i.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),u},u.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),u},u.hide=function(){if(t)return t.style({display:"none"}),u},u.show=function(){if(t)return t.style({display:"block"}),u},u.config=function(t){return a(i,t),u},u},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=a({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=i.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var s=a({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var l=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],c={};n.entries(s.margin).forEach(function(t,e){c[u[l.indexOf(t.key)]]=t.value}),s.margin=c}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r}};return t}},{"../../../constants/alignment":417,"../../../lib":441,d3:85}],530:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=a.extendDeepAll,u=e.exports={};u.framework=function(t){var e,r,a,i,c,f=new s;function h(r,s){return s&&(c=s),n.select(n.select(c).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?l(e,r):r,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(c),t.data=e.data,t.layout=e.layout,u.fillLayout(t),e}return h.isPolar=!0,h.svg=function(){return a.svg()},h.getConfig=function(){return e},h.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},h.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},h.setUndoPoint=function(){var t,n,a=this,i=o.util.cloneJson(e);t=i,n=r,f.add({undo:function(){n&&a(n)},redo:function(){a(t)}}),r=o.util.cloneJson(i)},h.undo=function(){f.undo()},h.redo=function(){f.redo()},h},u.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=l(o,t.layout)}},{"../../../components/color":319,"../../../lib":441,"./micropolar":529,"./undo_manager":531,d3:85}],531:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function a(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(a(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(a(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r-1&&(c[h[r]].title="");for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(l,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(l,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||h.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),h.node().setAttributeNS(s.xmlns,"xmlns",s.svg),h.node().setAttributeNS(s.xmlns,"xmlns:xlink",s.xlink),"svg"===e&&r&&(h.attr("width",r*p),h.attr("height",r*g),h.attr("viewBox","0 0 "+p+" "+g));var _=(new window.XMLSerializer).serializeToString(h.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(u,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":319,"../components/drawing":344,"../constants/xmlns_namespaces":421,"../lib":441,d3:85}],541:[function(t,e,r){"use strict";var n=t("../heatmap/attributes"),a=t("../scatter/attributes"),i=t("../../components/colorscale/attributes"),o=t("../../components/colorbar/attributes"),s=t("../../components/drawing/attributes").dash,l=t("../../plots/font_attributes"),u=t("../../lib/extend").extendFlat,c=t("../../constants/filter_ops"),f=c.COMPARISON_OPS2,h=c.INTERVAL_OPS,d=a.line;e.exports=u({z:n.z,x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:n.text,transpose:n.transpose,xtype:n.xtype,ytype:n.ytype,zhoverformat:n.zhoverformat,connectgaps:n.connectgaps,fillcolor:{valType:"color",editType:"calc"},autocontour:{valType:"boolean",dflt:!0,editType:"calc",impliedEdits:{"contours.start":void 0,"contours.end":void 0,"contours.size":void 0}},ncontours:{valType:"integer",dflt:15,min:1,editType:"calc"},contours:{type:{valType:"enumerated",values:["levels","constraint"],dflt:"levels",editType:"calc"},start:{valType:"number",dflt:null,editType:"plot",impliedEdits:{"^autocontour":!1}},end:{valType:"number",dflt:null,editType:"plot",impliedEdits:{"^autocontour":!1}},size:{valType:"number",dflt:null,min:0,editType:"plot",impliedEdits:{"^autocontour":!1}},coloring:{valType:"enumerated",values:["fill","heatmap","lines","none"],dflt:"fill",editType:"calc"},showlines:{valType:"boolean",dflt:!0,editType:"plot"},showlabels:{valType:"boolean",dflt:!1,editType:"plot"},labelfont:l({editType:"plot",colorEditType:"style"}),labelformat:{valType:"string",dflt:"",editType:"plot"},operation:{valType:"enumerated",values:[].concat(f).concat(h),dflt:"=",editType:"calc"},value:{valType:"any",dflt:0,editType:"calc"},editType:"calc",impliedEdits:{autocontour:!1}},line:{color:u({},d.color,{editType:"style+colorbars"}),width:u({},d.width,{editType:"style+colorbars"}),dash:s,smoothing:u({},d.smoothing,{}),editType:"plot"}},i("",{cLetter:"z",autoColorDflt:!1,editTypeOverride:"calc"}),{colorbar:o})},{"../../components/colorbar/attributes":320,"../../components/colorscale/attributes":326,"../../components/drawing/attributes":343,"../../constants/filter_ops":418,"../../lib/extend":432,"../../plots/font_attributes":515,"../heatmap/attributes":554,"../scatter/attributes":592}],542:[function(t,e,r){"use strict";var n=t("../heatmap/calc"),a=t("./set_contours");e.exports=function(t,e){var r=n(t,e);return a(e),r}},{"../heatmap/calc":555,"./set_contours":550}],543:[function(t,e,r){"use strict";var n=t("../../components/colorbar/draw"),a=t("./make_color_map"),i=t("./end_plus");e.exports=function(t,e){var r=e[0].trace,o="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+o).remove(),r.showscale){var s=e[0].t.cb=n(t,o),l=r.contours,u=r.line,c=l.size||1,f=l.coloring,h=a(r,{isColorbar:!0});s.fillgradient("heatmap"===f?r.colorscale:"").zrange("heatmap"===f?[r.zmin,r.zmax]:"").fillcolor("fill"===f?h:"").line({color:"lines"===f?h:u.color,width:!1!==l.showlines?u.width:0,dash:u.dash}).levels({start:l.start,end:i(l),size:c}).options(r.colorbar)()}}},{"../../components/colorbar/draw":324,"./end_plus":547,"./make_color_map":549}],544:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./label_defaults"),i=t("../../components/color"),o=i.addOpacity,s=i.opacity,l=t("../../constants/filter_ops"),u=l.CONSTRAINT_REDUCTION,c=l.COMPARISON_OPS2;e.exports=function(t,e,r,i,l,f){var h,d,p,g=e.contours,v=r("contours.operation");(g._operation=u[v],function(t,e){var r;-1===c.indexOf(e.operation)?(t("contours.value",[0,1]),Array.isArray(e.value)?e.value.length>2?e.value=e.value.slice(2):0===e.length?e.value=[0,1]:e.length<2?(r=parseFloat(e.value[0]),e.value=[r,r+1]):e.value=[parseFloat(e.value[0]),parseFloat(e.value[1])]:n(e.value)&&(r=parseFloat(e.value),e.value=[r,r+1])):(t("contours.value",0),n(e.value)||(Array.isArray(e.value)?e.value=parseFloat(e.value[0]):e.value=0))}(r,g),"="===v?h=g.showlines=!0:(h=r("contours.showlines"),p=r("fillcolor",o((t.line||{}).color||l,.5))),h)&&(d=r("line.color",p&&s(p)?o(e.fillcolor,1):l),r("line.width",2),r("line.dash"));r("line.smoothing"),a(r,i,d,f)}},{"../../components/color":319,"../../constants/filter_ops":418,"./label_defaults":548,"fast-isnumeric":149}],545:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var a=n("contours.start"),i=n("contours.end"),o=!1===a||!1===i,s=r("contours.size");!(o?e.autocontour=!0:r("autocontour",!1))&&s||r("ncontours")}},{}],546:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../heatmap/xyz_defaults"),i=t("./constraint_defaults"),o=t("./contours_defaults"),s=t("./style_defaults"),l=t("./attributes");e.exports=function(t,e,r,u){function c(r,a){return n.coerce(t,e,l,r,a)}if(a(t,e,c,u)){c("text");var f="constraint"===c("contours.type");c("connectgaps",n.isArray1D(e.z)),f?i(t,e,c,u,r):(o(t,e,c,function(r){return n.coerce2(t,e,l,r)}),s(t,e,c,u))}else e.visible=!1}},{"../../lib":441,"../heatmap/xyz_defaults":565,"./attributes":541,"./constraint_defaults":544,"./contours_defaults":545,"./style_defaults":551}],547:[function(t,e,r){"use strict";e.exports=function(t){return t.end+t.size/1e6}},{}],548:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r,a){if(a||(a={}),t("contours.showlabels")){var i=e.font;n.coerceFont(t,"contours.labelfont",{family:i.family,size:i.size,color:r}),t("contours.labelformat")}!1!==a.hasHover&&t("zhoverformat")}},{"../../lib":441}],549:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../components/colorscale"),i=t("./end_plus");e.exports=function(t){var e=t.contours,r=e.start,o=i(e),s=e.size||1,l=Math.floor((o-r)/s)+1,u="lines"===e.coloring?0:1;isFinite(s)||(s=1,l=1);var c,f,h=t.colorscale,d=h.length,p=new Array(d),g=new Array(d);if("heatmap"===e.coloring){for(t.zauto&&!1===t.autocontour&&(t.zmin=r-s/2,t.zmax=t.zmin+l*s),f=0;fe.end&&(e.start=e.end=(e.start+e.end)/2),t._input.contours||(t._input.contours={}),a.extendFlat(t._input.contours,{start:e.start,end:e.end,size:e.size}),t._input.autocontour=!0}else if("constraint"!==e.type){var l,u=e.start,c=e.end,f=t._input.contours;if(u>c&&(e.start=f.start=c,c=e.end=f.end=u,u=e.start),!(e.size>0))l=u===c?1:i(u,c,t.ncontours).dtick,f.size=e.size=l}}},{"../../lib":441,"../../plots/cartesian/axes":488}],551:[function(t,e,r){"use strict";var n=t("../../components/colorscale/defaults"),a=t("./label_defaults");e.exports=function(t,e,r,i,o){var s,l=r("contours.coloring"),u="";"fill"===l&&(s=r("contours.showlines")),!1!==s&&("lines"!==l&&(u=r("line.color","#000")),r("line.width",.5),r("line.dash")),"none"!==l&&(!0!==t.showlegend&&(e.showlegend=!1),e._dfltShowLegend=!1,n(t,e,i,r,{prefix:"",cLetter:"z"})),r("line.smoothing"),a(r,i,u,o)}},{"../../components/colorscale/defaults":329,"./label_defaults":548}],552:[function(t,e,r){"use strict";var n=t("gl-contour2d"),a=t("gl-heatmap2d"),i=t("../../plots/cartesian/axes"),o=t("../contour/make_color_map"),s=t("../../lib/str2rgbarray");function l(t,e){this.scene=t,this.uid=e,this.type="contourgl",this.name="",this.hoverinfo="all",this.xData=[],this.yData=[],this.zData=[],this.textLabels=[],this.idToIndex=[],this.bounds=[0,0,0,0],this.contourOptions={z:new Float32Array(0),x:[],y:[],shape:[0,0],levels:[0],levelColors:[0,0,0,1],lineWidth:1},this.contour=n(t.glplot,this.contourOptions),this.contour._trace=this,this.heatmapOptions={z:new Float32Array(0),x:[],y:[],shape:[0,0],colorLevels:[0],colorValues:[0,0,0,0]},this.heatmap=a(t.glplot,this.heatmapOptions),this.heatmap._trace=this}var u=l.prototype;function c(t,e){for(var r=t.contours,n=r.start,a=r.end,i=r.size||1,l=e.fill,u=o(t),c=Math.floor((a-n)/i)+(l?2:1),f=new Array(c),h=new Array(4*c),d=0;dO){S("x scale is not linear");break}}if(v.length&&"fast"===E){var D=(v[v.length-1]-v[0])/(v.length-1),R=Math.abs(D/100);for(x=0;xR){S("y scale is not linear");break}}}var P=u(b),z="scaled"===e.xtype?"":r,I=d(e,z,p,g,P,w),F="scaled"===e.ytype?"":v,N=d(e,F,m,y,b.length,A);M||(e._extremes[w._id]=i.findExtremes(w,I),e._extremes[A._id]=i.findExtremes(A,N));var B={x:I,y:N,z:b,text:e._text||e.text};if(z&&z.length===I.length-1&&(B.xCenter=z),F&&F.length===N.length-1&&(B.yCenter=F),T&&(B.xRanges=_.xRanges,B.yRanges=_.yRanges,B.pts=_.pts),k&&"constraint"===e.contours.type||s(e,b,"","z"),k&&e.contours&&"heatmap"===e.contours.coloring){var j={type:"contour"===e.type?"heatmap":"histogram2d",xcalendar:e.xcalendar,ycalendar:e.ycalendar};B.xfill=d(j,z,p,g,P,w),B.yfill=d(j,F,m,y,b.length,A)}return[B]}},{"../../components/colorscale/calc":327,"../../lib":441,"../../plots/cartesian/axes":488,"../../registry":532,"../histogram2d/calc":573,"./clean_2d_array":556,"./convert_column_xyz":558,"./find_empties":560,"./interp2d":561,"./make_bound_array":562,"./max_row_length":563}],556:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){var r,a,i,o,s,l;function u(t){if(n(t))return+t}if(e){for(r=0,s=0;s=0;o--)(s=((f[[(r=(i=h[o])[0])-1,a=i[1]]]||g)[2]+(f[[r+1,a]]||g)[2]+(f[[r,a-1]]||g)[2]+(f[[r,a+1]]||g)[2])/20)&&(l[i]=[r,a,s],h.splice(o,1),u=!0);if(!u)throw"findEmpties iterated with no new neighbors";for(i in l)f[i]=l[i],c.push(l[i])}return c.sort(function(t,e){return e[2]-t[2]})}},{"./max_row_length":563}],561:[function(t,e,r){"use strict";var n=t("../../lib"),a=[[-1,0],[1,0],[0,-1],[0,1]];function i(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o,s,l,u,c,f,h,d,p,g,v,m=0;for(s=0;sg&&(m=Math.max(m,Math.abs(t[i][o]-p)/(v-g))))}return m}e.exports=function(t,e){var r,a=1;for(o(t,e),r=0;r.01;r++)a=o(t,e,i(a));return a>.01&&n.log("interp2d didn't converge quickly",a),t}},{"../../lib":441}],562:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib").isArrayOrTypedArray;e.exports=function(t,e,r,i,o,s){var l,u,c,f=[],h=n.traceIs(t,"contour"),d=n.traceIs(t,"histogram"),p=n.traceIs(t,"gl2d");if(a(e)&&e.length>1&&!d&&"category"!==s.type){var g=e.length;if(!(g<=o))return h?e.slice(0,o):e.slice(0,o+1);if(h||p)f=e.slice(0,o);else if(1===o)f=[e[0]-.5,e[0]+.5];else{for(f=[1.5*e[0]-.5*e[1]],c=1;c0&&(i=!0);for(var l=0;li){var o=i-r[t];return r[t]=i,o}}return 0},max:function(t,e,r,a){var i=a[e];if(n(i)){if(i=Number(i),!n(r[t]))return r[t]=i,i;if(r[t]u?t>o?t>1.1*a?a:t>1.1*i?i:o:t>s?s:t>l?l:u:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function d(t,e,r,n,i,s){if(n&&t>o){var l=p(e,i,s),u=p(r,i,s),c=t===a?0:1;return l[c]!==u[c]}return Math.floor(r/t)-Math.floor(e/t)>.1}function p(t,e,r){var n=e.c2d(t,a,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}e.exports=function(t,e,r,n,i){var s,l,u=-1.1*e,h=-.1*e,d=t-h,p=r[0],g=r[1],v=Math.min(f(p+h,p+d,n,i),f(g+h,g+d,n,i)),m=Math.min(f(p+u,p+h,n,i),f(g+u,g+h,n,i));if(v>m&&mo){var y=s===a?1:6,b=s===a?"M12":"M1";return function(e,r){var o=n.c2d(e,a,i),s=o.indexOf("-",y);s>0&&(o=o.substr(0,s));var u=n.d2c(o,0,i);if(uT&&v.splice(T,v.length-T),y.length>T&&y.splice(T,y.length-T),u(e,"x",v,g,_,A,b),u(e,"y",y,m,w,k,x);var M=[],E=[],C=[],S="string"==typeof e.xbins.size,L="string"==typeof e.ybins.size,O=[],D=[],R=S?O:e.xbins,P=L?D:e.ybins,z=0,I=[],F=[],N=e.histnorm,B=e.histfunc,j=-1!==N.indexOf("density"),U="max"===B||"min"===B?null:0,H=i.count,V=o[N],q=!1,G=[],X=[],W="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";W&&"count"!==B&&(q="avg"===B,H=i[B]);var Y=e.xbins,Z=_(Y.start),J=_(Y.end)+(Z-a.tickIncrement(Z,Y.size,!1,b))/1e6;for(r=Z;r=0&&d=0&&p=0;i--){var o=t[i];if(e>f(n,o))return u(n,a);if(e>o||i===t.length-1)return u(o,n);a=n,n=o}}function p(t,e){for(var r=0;r=e[r][0]&&t<=e[r][1])return!0;return!1}function g(t){t.attr("x",-n.bar.captureWidth/2).attr("width",n.bar.captureWidth)}function v(t){t.attr("visibility","visible").style("visibility","visible").attr("fill","yellow").attr("opacity",0)}function m(t){if(!t.brush.filterSpecified)return"0,"+t.height;for(var e,r,n,a=y(t.brush.filter.getConsolidated(),t.height),i=[0],o=a.length?a[0][0]:null,s=0;se){h=r;break}}if(i=c,isNaN(i)&&(i=isNaN(f)||isNaN(h)?isNaN(f)?h:f:e-u[f][1]t[1]+r||e=.9*t[1]+.1*t[0]?"n":e<=.9*t[0]+.1*t[1]?"s":"ns"}(p,e);g&&(o.interval=l[i],o.intervalPix=p,o.region=g)}}if(t.ordinal&&!o.region){var v=t.unitTickvals,m=t.unitToPaddedPx.invert(e);for(r=0;r=b[0]&&m<=b[1]){o.clickableOrdinalRange=b;break}}}return o}function A(t){t.on("mousemove",function(t){if(a.event.preventDefault(),!t.parent.inBrushDrag){var e=w(t,t.height-a.mouse(this)[1]-2*n.verticalPadding),r="crosshair";e.clickableOrdinalRange?r="pointer":e.region&&(r=e.region+"-resize"),a.select(document.body).style("cursor",r)}}).on("mouseleave",function(t){t.parent.inBrushDrag||b()}).call(a.behavior.drag().on("dragstart",function(t){a.event.sourceEvent.stopPropagation();var e=t.height-a.mouse(this)[1]-2*n.verticalPadding,r=t.unitToPaddedPx.invert(e),i=t.brush,o=w(t,e),s=o.interval,l=i.svgBrush;if(l.wasDragged=!1,l.grabbingBar="ns"===o.region,l.grabbingBar){var u=s.map(t.unitToPaddedPx);l.grabPoint=e-u[0]-n.verticalPadding,l.barLength=u[1]-u[0]}l.clickableOrdinalRange=o.clickableOrdinalRange,l.stayingIntervals=t.multiselect&&i.filterSpecified?i.filter.getConsolidated():[],s&&(l.stayingIntervals=l.stayingIntervals.filter(function(t){return t[0]!==s[0]&&t[1]!==s[1]})),l.startExtent=o.region?s["s"===o.region?1:0]:r,t.parent.inBrushDrag=!0,l.brushStartCallback()}).on("drag",function(t){a.event.sourceEvent.stopPropagation();var e=t.height-a.mouse(this)[1]-2*n.verticalPadding,r=t.brush.svgBrush;r.wasDragged=!0,r.grabbingBar?r.newExtent=[e-r.grabPoint,e+r.barLength-r.grabPoint].map(t.unitToPaddedPx.invert):r.newExtent=[r.startExtent,t.unitToPaddedPx.invert(e)].sort(s);var i=Math.max(0,-r.newExtent[0]),o=Math.max(0,r.newExtent[1]-1);r.newExtent[0]+=i,r.newExtent[1]-=o,r.grabbingBar&&(r.newExtent[1]+=i,r.newExtent[0]-=o),t.brush.filterSpecified=!0,r.extent=r.stayingIntervals.concat([r.newExtent]),r.brushCallback(t),_(this.parentNode)}).on("dragend",function(t){a.event.sourceEvent.stopPropagation();var e=t.brush,r=e.filter,n=e.svgBrush,i=n.grabbingBar;if(n.grabbingBar=!1,n.grabLocation=void 0,t.parent.inBrushDrag=!1,b(),!n.wasDragged)return n.wasDragged=void 0,n.clickableOrdinalRange?e.filterSpecified&&t.multiselect?n.extent.push(n.clickableOrdinalRange):(n.extent=[n.clickableOrdinalRange],e.filterSpecified=!0):i?(n.extent=n.stayingIntervals,0===n.extent.length&&T(e)):T(e),n.brushCallback(t),_(this.parentNode),void n.brushEndCallback(e.filterSpecified?r.getConsolidated():[]);var o=function(){r.set(r.getConsolidated())};if(t.ordinal){var s=t.unitTickvals;s[s.length-1]n.newExtent[0];n.extent=n.stayingIntervals.concat(l?[n.newExtent]:[]),n.extent.length||T(e),n.brushCallback(t),l?_(this.parentNode,o):(o(),_(this.parentNode))}else o();n.brushEndCallback(e.filterSpecified?r.getConsolidated():[])}))}function k(t,e){return t[0]-e[0]}function T(t){t.filterSpecified=!1,t.svgBrush.extent=[[0,1]]}function M(t){for(var e,r=t.slice(),n=[],a=r.shift();a;){for(e=a.slice();(a=r.shift())&&a[0]<=e[1];)e[1]=Math.max(e[1],a[1]);n.push(e)}return n}e.exports={makeBrush:function(t,e,r,n,a,i){var o,l=function(){var t,e,r=[];return{set:function(n){r=n.map(function(t){return t.slice().sort(s)}).sort(k),t=M(r),e=r.reduce(function(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1])]},[1/0,-1/0])},get:function(){return r.slice()},getConsolidated:function(){return t},getBounds:function(){return e}}}();return l.set(r),{filter:l,filterSpecified:e,svgBrush:{extent:[],brushStartCallback:n,brushCallback:(o=a,function(t){var e=t.brush,r=function(t){return t.svgBrush.extent.map(function(t){return t.slice()})}(e).slice();e.filter.set(r),o()}),brushEndCallback:i}}},ensureAxisBrush:function(t){var e=t.selectAll("."+n.cn.axisBrush).data(o,i);e.enter().append("g").classed(n.cn.axisBrush,!0),function(t){var e=t.selectAll(".background").data(o);e.enter().append("rect").classed("background",!0).call(g).call(v).style("pointer-events","auto").attr("transform","translate(0 "+n.verticalPadding+")"),e.call(A).attr("height",function(t){return t.height-n.verticalPadding});var r=t.selectAll(".highlight-shadow").data(o);r.enter().append("line").classed("highlight-shadow",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width+n.bar.strokeWidth).attr("stroke",n.bar.strokeColor).attr("opacity",n.bar.strokeOpacity).attr("stroke-linecap","butt"),r.attr("y1",function(t){return t.height}).call(x);var a=t.selectAll(".highlight").data(o);a.enter().append("line").classed("highlight",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width-n.bar.strokeWidth).attr("stroke",n.bar.fillColor).attr("opacity",n.bar.fillOpacity).attr("stroke-linecap","butt"),a.attr("y1",function(t){return t.height}).call(x)}(e)},cleanRanges:function(t,e){if(Array.isArray(t[0])?(t=t.map(function(t){return t.sort(s)}),t=e.multiselect?M(t.sort(k)):[t[0]]):t=[t.sort(s)],e.tickvals){var r=e.tickvals.slice().sort(s);if(!(t=t.map(function(t){var e=[h(r,t[0],[]),d(r,t[1],[])];if(e[1]>e[0])return e}).filter(function(t){return t})).length)return}return t.length>1?t:t[0]}}},{"../../lib":441,"../../lib/gup":438,"./constants":578,d3:85}],576:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/get_data").getModuleCalcData,i=t("./plot"),o=t("../../constants/xmlns_namespaces");r.name="parcoords",r.plot=function(t){var e=a(t.calcdata,"parcoords")[0];e.length&&i(t,e)},r.clean=function(t,e,r,n){var a=n._has&&n._has("parcoords"),i=e._has&&e._has("parcoords");a&&!i&&(n._paperdiv.selectAll(".parcoords").remove(),n._glimages.selectAll("*").remove())},r.toSVG=function(t){var e=t._fullLayout._glimages,r=n.select(t).selectAll(".svg-container");r.filter(function(t,e){return e===r.size()-1}).selectAll(".gl-canvas-context, .gl-canvas-focus").each(function(){var t=this.toDataURL("image/png");e.append("svg:image").attr({xmlns:o.svg,"xlink:href":t,preserveAspectRatio:"none",x:0,y:0,width:this.width,height:this.height})}),window.setTimeout(function(){n.selectAll("#filterBarPattern").attr("id","filterBarPattern")},60)}},{"../../constants/xmlns_namespaces":421,"../../plots/get_data":517,"./plot":584,d3:85}],577:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/calc"),i=t("../../lib"),o=t("../../lib/gup").wrap;e.exports=function(t,e){var r=!!e.line.colorscale&&i.isArrayOrTypedArray(e.line.color),s=r?e.line.color:function(t){for(var e=new Array(t),r=0;rc&&(n.log("parcoords traces support up to "+c+" dimensions at the moment"),p.splice(c));var g=s(t,e,{name:"dimensions",handleItemDefaults:h}),v=function(t,e,r,o,s){var l=s("line.color",r);if(a(t,"line")&&n.isArrayOrTypedArray(l)){if(l.length)return s("line.colorscale"),i(t,e,o,s,{prefix:"line.",cLetter:"c"}),l.length;e.line.color=r}return 1/0}(t,e,r,u,d);o(e,u,d),Array.isArray(g)&&g.length||(e.visible=!1),f(e,g,"values",v);var m={family:u.font.family,size:Math.round(u.font.size/1.2),color:u.font.color};n.coerceFont(d,"labelfont",m),n.coerceFont(d,"tickfont",m),n.coerceFont(d,"rangefont",m)}},{"../../components/colorscale/defaults":329,"../../components/colorscale/has_colorscale":333,"../../lib":441,"../../plots/array_container_defaults":484,"../../plots/domain":514,"./attributes":574,"./axisbrush":575,"./constants":578,"./merge_length":582}],580:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.colorbar={container:"line",min:"cmin",max:"cmax"},n.moduleType="trace",n.name="parcoords",n.basePlotModule=t("./base_plot"),n.categories=["gl","regl","noOpacity"],n.meta={},e.exports=n},{"./attributes":574,"./base_plot":576,"./calc":577,"./defaults":579,"./plot":584}],581:[function(t,e,r){"use strict";var n=t("glslify"),a=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\nuniform sampler2D mask;\nuniform float maskHeight;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec4 unit_1 = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit_1, unit_1);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nconst int bitsPerByte = 8;\n\nint mod2(int a) {\n return a - 2 * (a / 2);\n}\n\nint mod8(int a) {\n return a - 8 * (a / 8);\n}\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit_0 = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nbool withinBoundingBox(\n mat4 d[4],\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD\n ) {\n\n return mshow(d[0], loA, hiA) &&\n mshow(d[1], loB, hiB) &&\n mshow(d[2], loC, hiC) &&\n mshow(d[3], loD, hiD);\n}\n\nbool withinRasterMask(mat4 d[4], sampler2D mask, float height) {\n bool result = true;\n int bitInByteStepper;\n float valY, valueY, scaleX;\n int hit, bitmask, valX;\n for(int i = 0; i < 4; i++) {\n for(int j = 0; j < 4; j++) {\n for(int k = 0; k < 4; k++) {\n bitInByteStepper = mod8(j * 4 + k);\n valX = i * 2 + j / 2;\n valY = d[i][j][k];\n valueY = valY * (height - 1.0) + 0.5;\n scaleX = (float(valX) + 0.5) / 8.0;\n hit = int(texture2D(mask, vec2(scaleX, (valueY + 0.5) / height))[3] * 255.0) / int(pow(2.0, float(bitInByteStepper)));\n result = result && mod2(hit) == 1;\n }\n }\n }\n return result;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D,\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD,\n sampler2D mask, float maskHeight\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n float show = float(\n withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD)\n && withinRasterMask(dims, mask, maskHeight)\n );\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD,\n mask, maskHeight\n );\n\n float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);\n fragColor = texture2D(palette, vec2((clampedColorIndex * 255.0 + 0.5) / 256.0, 0.5));\n}\n"]),i=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec2 xyProjection = vec2(1, 1);\n\nvec4 unit = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit, unit);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depth,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D\n );\n\n float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);\n fragColor = texture2D(palette, vec2((clampedColorIndex * 255.0 + 0.5) / 256.0, 0.5));\n}\n"]),o=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D mask;\nuniform float maskHeight;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec4 unit_1 = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit_1, unit_1);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nconst int bitsPerByte = 8;\n\nint mod2(int a) {\n return a - 2 * (a / 2);\n}\n\nint mod8(int a) {\n return a - 8 * (a / 8);\n}\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit_0 = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nbool withinBoundingBox(\n mat4 d[4],\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD\n ) {\n\n return mshow(d[0], loA, hiA) &&\n mshow(d[1], loB, hiB) &&\n mshow(d[2], loC, hiC) &&\n mshow(d[3], loD, hiD);\n}\n\nbool withinRasterMask(mat4 d[4], sampler2D mask, float height) {\n bool result = true;\n int bitInByteStepper;\n float valY, valueY, scaleX;\n int hit, bitmask, valX;\n for(int i = 0; i < 4; i++) {\n for(int j = 0; j < 4; j++) {\n for(int k = 0; k < 4; k++) {\n bitInByteStepper = mod8(j * 4 + k);\n valX = i * 2 + j / 2;\n valY = d[i][j][k];\n valueY = valY * (height - 1.0) + 0.5;\n scaleX = (float(valX) + 0.5) / 8.0;\n hit = int(texture2D(mask, vec2(scaleX, (valueY + 0.5) / height))[3] * 255.0) / int(pow(2.0, float(bitInByteStepper)));\n result = result && mod2(hit) == 1;\n }\n }\n }\n return result;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D,\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD,\n sampler2D mask, float maskHeight\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n float show = float(\n withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD)\n && withinRasterMask(dims, mask, maskHeight)\n );\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD,\n mask, maskHeight\n );\n\n fragColor = vec4(pf.rgb, 1.0);\n}\n"]),s=n(["precision lowp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}\n"]),l=t("../../lib"),u=1e-6,c=1e-7,f=2048,h=64,d=2,p=4,g=8,v=h/g,m=[119,119,119],y=new Uint8Array(4),b=new Uint8Array(4),x={shape:[256,1],format:"rgba",type:"uint8",mag:"nearest",min:"nearest"};function _(t,e,r,n,a){var i=t._gl;i.enable(i.SCISSOR_TEST),i.scissor(e,r,n,a),t.clear({color:[0,0,0,0],depth:1})}function w(t,e,r,n,a,i){var o=i.key;r.drawCompleted||(!function(t){t.read({x:0,y:0,width:1,height:1,data:y})}(t),r.drawCompleted=!0),function s(l){var u;u=Math.min(n,a-l*n),i.offset=d*l*n,i.count=d*u,0===l&&(window.cancelAnimationFrame(r.currentRafs[o]),delete r.currentRafs[o],_(t,i.scissorX,i.scissorY,i.scissorWidth,i.viewBoxSize[1])),r.clearOnly||(e(i),l*n+u>>8*e)%256/255}function k(t,e,r){var n,a,i,o=[];for(a=0;a=h-4?A(o,h-2-s):.5);return i}(p,d,a);!function(t,e,r){for(var n=0;n<16;n++)t["p"+n.toString(16)](k(e,r,n))}(S,p,o),L=E.texture(l.extendFlat({data:function(t,e,r){for(var n=[],a=0;a<256;a++){var i=t(a/255);n.push((e?m:i).concat(r))}return n}(r.unitToColor,T,Math.round(255*(T?i:1)))},x))}var R=[0,1];var P=[];function z(t,e,n,a,i,o,s,u,c,f,h){var d,p,g,v,m=[t,e],y=[0,1].map(function(){return[0,1,2,3].map(function(){return new Float32Array(16)})});for(d=0;d<2;d++)for(v=m[d],p=0;p<4;p++)for(g=0;g<16;g++)y[d][p][g]=g+16*p===v?1:0;var b=r.lines.canvasOverdrag,x=r.domain,_=r.canvasWidth,w=r.canvasHeight;return l.extendFlat({key:s,resolution:[_,w],viewBoxPosition:[n+b,a],viewBoxSize:[i,o],i:t,ii:e,dim1A:y[0][0],dim1B:y[0][1],dim1C:y[0][2],dim1D:y[0][3],dim2A:y[1][0],dim2B:y[1][1],dim2C:y[1][2],dim2D:y[1][3],colorClamp:R,scissorX:(u===c?0:n+b)+(r.pad.l-b)+r.layoutWidth*x.x[0],scissorWidth:(u===f?_-n+b:i+.5)+(u===c?n+b:0),scissorY:a+r.pad.b+r.layoutHeight*x.y[0],scissorHeight:o,viewportX:r.pad.l-b+r.layoutWidth*x.x[0],viewportY:r.pad.b+r.layoutHeight*x.y[0],viewportWidth:_,viewportHeight:w},h)}return{setColorDomain:function(t){R[0]=t[0],R[1]=t[1]},render:function(t,e,n){var a,i,o,s=t.length,l=1/0,u=-1/0;for(a=0;au&&(u=t[a].dim2.canvasX,o=a),t[a].dim1.canvasXn._length&&(k=k.slice(0,n._length));var T,M=n.tickvals;function E(t,e){return{val:t,text:T[e]}}function C(t,e){return t.val-e.val}if(Array.isArray(M)&&M.length){T=n.ticktext,Array.isArray(T)&&T.length?T.length>M.length?T=T.slice(0,M.length):M.length>T.length&&(M=M.slice(0,T.length)):T=M.map(o.format(n.tickformat));for(var S=1;S=r||s>=n)return;var l=t.lineLayer.readPixel(i,n-1-s),u=0!==l[3],c=u?l[2]+256*(l[1]+256*l[0]):null,f={x:i,y:s,clientX:e.clientX,clientY:e.clientY,dataIndex:t.model.key,curveNumber:c};c!==k&&(u?p.hover(f):p.unhover&&p.unhover(f),k=c)}}),A.style("opacity",function(t){return t.pick?.01:1}),e.style("background","rgba(255, 255, 255, 0)");var T=e.selectAll("."+a.cn.parcoords).data(w,u);T.exit().remove(),T.enter().append("g").classed(a.cn.parcoords,!0).style("shape-rendering","crispEdges").style("pointer-events","none"),T.attr("transform",function(t){return"translate("+t.model.translateX+","+t.model.translateY+")"});var M=T.selectAll("."+a.cn.parcoordsControlView).data(c,u);M.enter().append("g").classed(a.cn.parcoordsControlView,!0),M.attr("transform",function(t){return"translate("+t.model.pad.l+","+t.model.pad.t+")"});var E=M.selectAll("."+a.cn.yAxis).data(function(t){return t.dimensions},u);function C(t,e){for(var r=e.panels||(e.panels=[]),n=t.data(),a=n.length-1,i=0;iline").attr("fill","none").attr("stroke","black").attr("stroke-opacity",.25).attr("stroke-width","1px"),L.selectAll("text").style("text-shadow","1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff").style("cursor","default").style("user-select","none");var O=S.selectAll("."+a.cn.axisHeading).data(c,u);O.enter().append("g").classed(a.cn.axisHeading,!0);var D=O.selectAll("."+a.cn.axisTitle).data(c,u);D.enter().append("text").classed(a.cn.axisTitle,!0).attr("text-anchor","middle").style("cursor","ew-resize").style("user-select","none").style("pointer-events","auto"),D.attr("transform","translate(0,"+-a.axisTitleOffset+")").text(function(t){return t.label}).each(function(t){s.font(o.select(this),t.model.labelFont)});var R=S.selectAll("."+a.cn.axisExtent).data(c,u);R.enter().append("g").classed(a.cn.axisExtent,!0);var P=R.selectAll("."+a.cn.axisExtentTop).data(c,u);P.enter().append("g").classed(a.cn.axisExtentTop,!0),P.attr("transform","translate(0,"+-a.axisExtentOffset+")");var z=P.selectAll("."+a.cn.axisExtentTopText).data(c,u);function I(t,e){if(t.ordinal)return"";var r=t.domainScale.domain();return o.format(t.tickFormat)(r[e?r.length-1:0])}z.enter().append("text").classed(a.cn.axisExtentTopText,!0).call(y),z.text(function(t){return I(t,!0)}).each(function(t){s.font(o.select(this),t.model.rangeFont)});var F=R.selectAll("."+a.cn.axisExtentBottom).data(c,u);F.enter().append("g").classed(a.cn.axisExtentBottom,!0),F.attr("transform",function(t){return"translate(0,"+(t.model.height+a.axisExtentOffset)+")"});var N=F.selectAll("."+a.cn.axisExtentBottomText).data(c,u);N.enter().append("text").classed(a.cn.axisExtentBottomText,!0).attr("dy","0.75em").call(y),N.text(function(t){return I(t)}).each(function(t){s.font(o.select(this),t.model.rangeFont)}),h.ensureAxisBrush(S)}},{"../../components/drawing":344,"../../lib":441,"../../lib/gup":438,"./axisbrush":575,"./constants":578,"./lines":581,d3:85}],584:[function(t,e,r){"use strict";var n=t("./parcoords"),a=t("../../lib/prepare_regl");e.exports=function(t,e){var r=t._fullLayout,i=r._toppaper,o=r._paperdiv,s=r._glcontainer;if(a(t)){var l={},u={},c=r._size;e.forEach(function(e,r){l[r]=t.data[r].dimensions,u[r]=t.data[r].dimensions.slice()});n(o,i,s,e,{width:c.w,height:c.h,margin:{t:c.t,r:c.r,b:c.b,l:c.l}},{filterChanged:function(e,r,n){var a=u[e][r],i=n.map(function(t){return t.slice()});i.length?(1===i.length&&(i=i[0]),a.constraintrange=i,i=[i]):(delete a.constraintrange,i=null);var o={};o["dimensions["+r+"].constraintrange"]=i,t.emit("plotly_restyle",[o,[e]])},hover:function(e){t.emit("plotly_hover",e)},unhover:function(e){t.emit("plotly_unhover",e)},axesMoved:function(e,r){function n(t){return!("visible"in t)||t.visible}function a(t,e,r){var n=e.indexOf(r),a=t.indexOf(n);return-1===a&&(a+=e.length),a}var i=function(t){return function(e,n){return a(r,t,e)-a(r,t,n)}}(u[e].filter(n));l[e].sort(i),u[e].filter(function(t){return!n(t)}).sort(function(t){return u[e].indexOf(t)}).forEach(function(t){l[e].splice(l[e].indexOf(t),1),l[e].splice(u[e].indexOf(t),0,t)}),t.emit("plotly_restyle")}})}}},{"../../lib/prepare_regl":454,"./parcoords":583}],585:[function(t,e,r){"use strict";var n=t("../../lib");r.formatPiePercent=function(t,e){var r=(100*t).toPrecision(3);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)+"%"},r.formatPieValue=function(t,e){var r=t.toPrecision(10);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)},r.getFirstFilled=function(t,e){if(Array.isArray(t))for(var r=0;r>>1,h)p[0]=t.xbounds[0],p[2]=t.xbounds[1],p[1]=t.ybounds[0],p[3]=t.ybounds[1];else for(l=0;lp[2]&&(p[2]=o),sp[3]&&(p[3]=s);if(d)r=d;else for(r=new Int32Array(e),l=0;lp[2]&&(p[2]=o),sp[3]&&(p[3]=s);this.idToIndex=r,this.pointcloudOptions.idToIndex=r,this.pointcloudOptions.positions=n;var g=a(t.marker.color),v=a(t.marker.border.color),m=t.opacity*t.marker.opacity;g[3]*=m,this.pointcloudOptions.color=g;var y=t.marker.blend;if(null===y){y=u.length<100||c.length<100}this.pointcloudOptions.blend=y,v[3]*=m,this.pointcloudOptions.borderColor=v;var b=t.marker.sizemin,x=Math.max(t.marker.sizemax,t.marker.sizemin);this.pointcloudOptions.sizeMin=b,this.pointcloudOptions.sizeMax=x,this.pointcloudOptions.areaRatio=t.marker.border.arearatio,this.pointcloud.update(this.pointcloudOptions);var _=this.scene.xaxis,w=this.scene.yaxis,A=x/2||.5;t._extremes[_._id]=i(_,[p[0],p[2]],{ppad:A}),t._extremes[w._id]=i(w,[p[1],p[3]],{ppad:A})},l.dispose=function(){this.pointcloud.dispose()},e.exports=function(t,e){var r=new s(t,e.uid);return r.update(e),r}},{"../../lib/str2rgbarray":464,"../../plots/cartesian/autorange":487,"../scatter/get_trace_color":602,"gl-pointcloud2d":176}],589:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./attributes");e.exports=function(t,e,r){function i(r,i){return n.coerce(t,e,a,r,i)}i("x"),i("y"),i("xbounds"),i("ybounds"),t.xy&&t.xy instanceof Float32Array&&(e.xy=t.xy),t.indices&&t.indices instanceof Int32Array&&(e.indices=t.indices),i("text"),i("marker.color",r),i("marker.opacity"),i("marker.blend"),i("marker.sizemin"),i("marker.sizemax"),i("marker.border.color",r),i("marker.border.arearatio"),e._length=null}},{"../../lib":441,"./attributes":587}],590:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../scatter3d/calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="pointcloud",n.basePlotModule=t("../../plots/gl2d"),n.categories=["gl","gl2d","showLegend"],n.meta={},e.exports=n},{"../../plots/gl2d":520,"../scatter3d/calc":619,"./attributes":587,"./convert":588,"./defaults":589}],591:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rs&&T[v].gap;)v--;for(y=T[v].s,p=T.length-1;p>v;p--)T[p].s=y;for(;sM[c]&&c=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===r.xaxis&&i.yaxis===r.yaxis){i.opacity=void 0;break}}}}}},{}],599:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),s=t("./subtypes"),l=t("./xy_defaults"),u=t("./stack_defaults"),c=t("./marker_defaults"),f=t("./line_defaults"),h=t("./line_shape_defaults"),d=t("./text_defaults"),p=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,a){return n.coerce(t,e,i,r,a)}var m=l(t,e,g,v);if(m||(e.visible=!1),e.visible){var y=u(t,e,g,v),b=!y&&mG!=(F=D[L][1])>=G&&(P=D[L-1][0],z=D[L][0],F-I&&(R=P+(z-P)*(G-I)/(F-I),U=Math.min(U,R),H=Math.max(H,R)));U=Math.max(U,0),H=Math.min(H,h._length);var X=s.defaultLine;return s.opacity(f.fillcolor)?X=f.fillcolor:s.opacity((f.line||{}).color)&&(X=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:U,x1:H,y0:G,y1:G,color:X}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":319,"../../components/fx":361,"../../lib":441,"../../registry":532,"./fill_hover_text":600,"./get_trace_color":602}],604:[function(t,e,r){"use strict";var n={},a=t("./subtypes");n.hasLines=a.hasLines,n.hasMarkers=a.hasMarkers,n.hasText=a.hasText,n.isBubble=a.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":500,"./arrays_to_calcdata":591,"./attributes":592,"./calc":593,"./cross_trace_calc":597,"./cross_trace_defaults":598,"./defaults":599,"./hover":603,"./marker_colorbar":610,"./plot":612,"./select":613,"./style":615,"./subtypes":616}],605:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s,l){var u=(t.marker||{}).color;(s("line.color",r),a(t,"line"))?i(t,e,o,s,{prefix:"line.",cLetter:"c",noScale:!0}):s("line.color",!n(u)&&u||r);s("line.width"),(l||{}).noDash||s("line.dash")}},{"../../components/colorscale/defaults":329,"../../components/colorscale/has_colorscale":333,"../../lib":441}],606:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),a=n.BADNUM,i=n.LOG_CLIP,o=i+.5,s=i-.5,l=t("../../lib"),u=l.segmentsIntersect,c=l.constrain,f=t("./constants");e.exports=function(t,e){var r,n,i,h,d,p,g,v,m,y,b,x,_,w,A,k,T,M,E=e.xaxis,C=e.yaxis,S="log"===E.type,L="log"===C.type,O=E._length,D=C._length,R=e.connectGaps,P=e.baseTolerance,z=e.shape,I="linear"===z,F=[],N=f.minTolerance,B=new Array(t.length),j=0;function U(e){var r=t[e];if(!r)return!1;var n=E.c2p(r.x),i=C.c2p(r.y);if(n===a){if(S&&(n=E.c2p(r.x,!0)),n===a)return!1;L&&i===a&&(n*=Math.abs(E._m*D*(E._m>0?o:s)/(C._m*O*(C._m>0?o:s)))),n*=1e3}if(i===a){if(L&&(i=C.c2p(r.y,!0)),i===a)return!1;i*=1e3}return[n,i]}function H(t,e,r,n){var a=r-t,i=n-e,o=.5-t,s=.5-e,l=a*a+i*i,u=a*o+i*s;if(u>0&&utt||t[1]rt)return[c(t[0],K,tt),c(t[1],et,rt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,a){var i=at(n),o=at(a),s=[];if(i&&o&&it(i,o))return s;i&&s.push(i),o&&s.push(o);var u=2*l.constrain((n[t]+a[t])/2,e,r)-((i||n)[t]+(o||a)[t]);u&&((i&&o?u>0==i[t]>o[t]?i:o:i||o)[t]+=u);return s}}function st(t){var e=t[0],r=t[1],n=e===B[j-1][0],a=r===B[j-1][1];if(!n||!a)if(j>1){var i=e===B[j-2][0],o=r===B[j-2][1];n&&(e===K||e===tt)&&i?o?j--:B[j-1]=t:a&&(r===et||r===rt)&&o?i?j--:B[j-1]=t:B[j++]=t}else B[j++]=t}function lt(t){B[j-1][0]!==t[0]&&B[j-1][1]!==t[1]&&st([W,Y]),st(t),Z=null,W=Y=0}function ut(t){if(T=t[0]/O,M=t[1]/D,G=t[0]tt?tt:0,X=t[1]rt?rt:0,G||X){if(j)if(Z){var e=Q(Z,t);e.length>1&&(lt(e[0]),B[j++]=e[1])}else J=Q(B[j-1],t)[0],B[j++]=J;else B[j++]=[G||t[0],X||t[1]];var r=B[j-1];G&&X&&(r[0]!==G||r[1]!==X)?(Z&&(W!==G&&Y!==X?st(W&&Y?(n=Z,i=(a=t)[0]-n[0],o=(a[1]-n[1])/i,(n[1]*a[0]-a[1]*n[0])/i>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[W||G,Y||X]):W&&Y&&st([W,Y])),st([G,X])):W-G&&Y-X&&st([G||W,X||Y]),Z=t,W=G,Y=X}else Z&<(Q(Z,t)[0]),B[j++]=t;var n,a,i,o}for("linear"===z||"spline"===z?Q=function(t,e){for(var r=[],n=0,a=0;a<4;a++){var i=nt[a],o=u(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&q(o,t)V(p,ct))break;i=p,(_=m[0]*v[0]+m[1]*v[1])>b?(b=_,h=p,g=!1):_=t.length||!p)break;ut(p),n=p}}else ut(h)}Z&&st([W||Z[0],Y||Z[1]]),F.push(B.slice(0,j))}return F}},{"../../constants/numerical":420,"../../lib":441,"./constants":596}],607:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],608:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var a,i,o,s,l,u={},c=!1,f=-1,h=0,d=-1;for(i=0;i=0?l=d:(l=d=h,h++),l0?Math.max(e,a):0}}},{"fast-isnumeric":149}],610:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],611:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l,u){var c=o.isBubble(t),f=(t.line||{}).color;(u=u||{},f&&(r=f),l("marker.symbol"),l("marker.opacity",c?.7:1),l("marker.size"),l("marker.color",r),a(t,"marker")&&i(t,e,s,l,{prefix:"marker.",cLetter:"c"}),u.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),u.noLine||(l("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:c?n.background:n.defaultLine),a(t,"marker.line")&&i(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",c?1:0)),c&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),u.gradient)&&("none"!==l("marker.gradient.type")&&l("marker.gradient.color"))}},{"../../components/color":319,"../../components/colorscale/defaults":329,"../../components/colorscale/has_colorscale":333,"./subtypes":616}],612:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,s=i.identity,l=t("../../components/drawing"),u=t("./subtypes"),c=t("./line_points"),f=t("./link_traces"),h=t("../../lib/polygon").tester;function d(t,e,r,f,d,p,g){var v;!function(t,e,r,a,o){var s=r.xaxis,l=r.yaxis,c=n.extent(i.simpleMap(s.range,s.r2c)),f=n.extent(i.simpleMap(l.range,l.r2c)),h=a[0].trace;if(!u.hasMarkers(h))return;var d=h.marker.maxdisplayed;if(0===d)return;var p=a.filter(function(t){return t.x>=c[0]&&t.x<=c[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(p.length/d),v=0;o.forEach(function(t,r){var n=t[0].trace;u.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function y(t){return m?t.transition():t}var b=r.xaxis,x=r.yaxis,_=f[0].trace,w=_.line,A=n.select(p),k=o(A,"g","errorbars"),T=o(A,"g","lines"),M=o(A,"g","points"),E=o(A,"g","text");if(a.getComponentMethod("errorbars","plot")(k,r,g),!0===_.visible){var C,S;y(A).style("opacity",_.opacity);var L=_.fill.charAt(_.fill.length-1);"x"!==L&&"y"!==L&&(L=""),r.isRangePlot||(f[0].node3=A);var O="",D=[],R=_._prevtrace;R&&(O=R._prevRevpath||"",S=R._nextFill,D=R._polygons);var P,z,I,F,N,B,j,U,H,V="",q="",G=[],X=i.noop;if(C=_._ownFill,u.hasLines(_)||"none"!==_.fill){for(S&&S.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(I=l.steps(w.shape),F=l.steps(w.shape.split("").reverse().join(""))):I=F="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?l.smoothclosed(t.slice(1),w.smoothing):l.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},N=function(t){return F(t.reverse())},G=c(f,{xaxis:b,yaxis:x,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),H=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)y(r.style("opacity",0).attr("d",P).call(l.lineGroupStyle)).style("opacity",1);else{var a=y(r);a.attr("d",P),l.singleLineStyle(f,a)}}}}}var W=T.selectAll(".js-line").data(G);y(W.exit()).style("opacity",0).remove(),W.each(X(!1)),W.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(l.lineGroupStyle).each(X(!0)),l.setClipUrl(W,r.layerClipId),G.length?(C?(C.datum(f),B&&U&&(L?("y"===L?B[1]=U[1]=x.c2p(0,!0):"x"===L&&(B[0]=U[0]=b.c2p(0,!0)),y(C).attr("d","M"+U+"L"+B+"L"+V.substr(1)).call(l.singleFillStyle)):y(C).attr("d",V+"Z").call(l.singleFillStyle))):S&&("tonext"===_.fill.substr(0,6)&&V&&O?("tonext"===_.fill?y(S).attr("d",V+"Z"+O+"Z").call(l.singleFillStyle):y(S).attr("d",V+"L"+O.substr(1)+"Z").call(l.singleFillStyle),_._polygons=_._polygons.concat(D)):(Z(S),_._polygons=null)),_._prevRevpath=q,_._prevPolygons=H):(C?Z(C):S&&Z(S),_._polygons=_._prevRevpath=_._prevPolygons=null),M.datum(f),E.datum(f),function(e,a,i){var o,c=i[0].trace,f=u.hasMarkers(c),h=u.hasText(c),d=tt(c),p=et,g=et;if(f||h){var v=s,_=c.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[b._id+x._id][_].stackgaps;c.marker.maxdisplayed||c._needsCull?v=w?Q:J:_&&!w&&(v=$),f&&(p=v),h&&(g=v)}var A,k=(o=e.selectAll("path.point").data(p,d)).enter().append("path").classed("point",!0);m&&k.call(l.pointStyle,c,t).call(l.translatePoints,b,x).style("opacity",0).transition().style("opacity",1),o.order(),f&&(A=l.makePointStyleFns(c)),o.each(function(e){var a=n.select(this),i=y(a);l.translatePoint(e,i,b,x)?(l.singlePointStyle(e,i,c,A,t),r.layerClipId&&l.hideOutsideRangePoint(e,i,b,x,c.xcalendar,c.ycalendar),c.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),m?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,d)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),a=y(e.select("text"));l.translatePoint(t,a,b,x)?r.layerClipId&&l.hideOutsideRangePoint(t,e,b,x,c.xcalendar,c.ycalendar):e.remove()}),o.selectAll("text").call(l.textPointStyle,c,t).each(function(t){var e=b.c2p(t.x),r=x.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){y(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(M,E,f);var Y=!1===_.cliponaxis?null:r.layerClipId;l.setClipUrl(M,Y),l.setClipUrl(E,Y)}function Z(t){y(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function Q(t){return t.filter(function(t){return t.vis})}function $(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,a,i,u){var c,h,p=!i,g=!!i&&i.duration>0,v=f(t,e,r);((c=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),c.order(),function(t,e,r){e.each(function(t){var e=o(n.select(this),"g","fills");l.setClipUrl(e,r.layerClipId);var a=t[0].trace,i=[];a._ownfill&&i.push("_ownFill"),a._nexttrace&&i.push("_nextFill");var u=e.selectAll("g").data(i,s);u.enter().append("g"),u.exit().each(function(t){a[t]=null}).remove(),u.order().each(function(t){a[t]=o(n.select(this),"path","js-fill")})})}(0,c,e),g)?(u&&(h=u()),n.transition().duration(i.duration).ease(i.easing).each("end",function(){h&&h()}).each("interrupt",function(){h&&h()}).each(function(){a.selectAll("g.trace").each(function(r,n){d(t,n,e,r,v,this,i)})})):c.each(function(r,n){d(t,n,e,r,v,this,i)});p&&c.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":344,"../../lib":441,"../../lib/polygon":453,"../../registry":532,"./line_points":606,"./link_traces":608,"./subtypes":616,d3:85}],613:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,a,i,o,s=t.cd,l=t.xaxis,u=t.yaxis,c=[],f=s[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;rd.TOO_MANY_POINTS?"rect":f.hasMarkers(e)?"rect":"round";if(u&&e.connectgaps){var h=n[0],p=n[1];for(a=0;a1?l[a]:l[0]:l,p=Array.isArray(u)?u.length>1?u[a]:u[0]:u,v=g[d],m=g[p],y=c?c/.8+1:0,b=-m*y-.5*m;o.offset[a]=[v*y/h,b/h]}}return o}}},{"../../components/drawing":344,"../../constants/interactions":419,"../../lib":441,"../../lib/gl_format_color":437,"../../plots/cartesian/axis_ids":491,"../../registry":532,"../scatter/make_bubble_size_func":609,"../scatter/subtypes":616,"./constants":621,"color-normalize":63,"fast-isnumeric":149,"svg-path-sdf":282}],623:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("../scatter/constants"),s=t("../scatter/subtypes"),l=t("../scatter/xy_defaults"),u=t("../scatter/marker_defaults"),c=t("../scatter/line_defaults"),f=t("../scatter/fillcolor_defaults"),h=t("../scatter/text_defaults");e.exports=function(t,e,r,d){function p(r,a){return n.coerce(t,e,i,r,a)}var g=!!t.marker&&/-open/.test(t.marker.symbol),v=s.isBubble(t),m=l(t,e,d,p);if(m){var y=m1&&c.extendFlat(o.line,k.linePositions(t,r,n)),o.errorX||o.errorY){var s=k.errorBarPositions(t,r,n,a,i);o.errorX&&c.extendFlat(o.errorX,s.x),o.errorY&&c.extendFlat(o.errorY,s.y)}return o.text&&(c.extendFlat(o.text,{positions:n},k.textPosition(t,r,o.text,o.marker)),c.extendFlat(o.textSel,{positions:n},k.textPosition(t,r,o.text,o.markerSel)),c.extendFlat(o.textUnsel,{positions:n},k.textPosition(t,r,o.text,o.markerUnsel))),o}(t,0,e,_,g,v),L=S(0,u);return b(i,e),f=M&&(E.marker.cluster=p.tree),L.lineOptions.push(E.line),L.errorXOptions.push(E.errorX),L.errorYOptions.push(E.errorY),L.fillOptions.push(E.fill),L.markerOptions.push(E.marker),L.markerSelectedOptions.push(E.markerSel),L.markerUnselectedOptions.push(E.markerUnsel),L.textOptions.push(E.text),L.textSelectedOptions.push(E.textSel),L.textUnselectedOptions.push(E.textUnsel),p._scene=L,p.index=L.count,p.x=g,p.y=v,p.positions=_,L.count++,[{x:!1,y:!1,t:p,trace:e}]},plot:function(t,e,r){if(r.length){var o,s,u=t._fullLayout,h=e._scene,d=e.xaxis,p=e.yaxis;if(h)if(f(t,["ANGLE_instanced_arrays","OES_element_index_uint"])){var g=u._glcanvas.data()[0].regl;if(_(t,e,r),h.dirty){if(!0===h.error2d&&(h.error2d=i(g)),!0===h.line2d&&(h.line2d=a(g)),!0===h.scatter2d&&(h.scatter2d=n(g)),!0===h.fill2d&&(h.fill2d=a(g)),!0===h.glText)for(h.glText=new Array(h.count),o=0;or&&(isNaN(e[n])||isNaN(e[n+1]));)n-=2;t.positions=e.slice(r,n+2)}return t}),h.line2d.update(h.lineOptions)),h.error2d){var v=(h.errorXOptions||[]).concat(h.errorYOptions||[]);h.error2d.update(v)}h.scatter2d&&h.scatter2d.update(h.markerOptions),h.fillOrder=c.repeat(null,h.count),h.fill2d&&(h.fillOptions=h.fillOptions.map(function(t,e){var n=r[e];if(t&&n&&n[0]&&n[0].trace){var a,i,o=n[0],s=o.trace,l=o.t,u=h.lineOptions[e],c=[];s._ownfill&&c.push(e),s._nexttrace&&c.push(e+1),c.length&&(h.fillOrder[e]=c);var f,d,p=[],g=u&&u.positions||l.positions;if("tozeroy"===s.fill){for(f=0;ff&&isNaN(g[d+1]);)d-=2;0!==g[f+1]&&(p=[g[f],0]),p=p.concat(g.slice(f,d+2)),0!==g[d+1]&&(p=p.concat([g[d],0]))}else if("tozerox"===s.fill){for(f=0;ff&&isNaN(g[d]);)d-=2;0!==g[f]&&(p=[0,g[f+1]]),p=p.concat(g.slice(f,d+2)),0!==g[d]&&(p=p.concat([0,g[d+1]]))}else if("toself"===s.fill||"tonext"===s.fill){for(p=[],a=0,i=0;i-1;for(o=0;oi&&l?r._splomSubplots[E]=1:a-1,T="lasso"===y||"select"===y||!!h.selectedpoints||k;if(p.selectBatch=null,p.unselectBatch=null,T){var M=h._length;if(p.selectBatch||(p.selectBatch=[],p.unselectBatch=[]),h.selectedpoints){p.selectBatch=h.selectedpoints;var E=h.selectedpoints,C={};for(i=0;im?2*(b.sizeAvg||Math.max(b.size,3)):c(e,y),n=0;n:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;margin-left:0px;margin-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var i in a){var o=i.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");n.addStyleRule(o,a[i])}},{"../src/lib":437}],2:[function(t,e,r){"use strict";e.exports={undo:{width:857.1,height:1e3,path:"m857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z",transform:"matrix(1 0 0 -1 0 850)"},home:{width:928.6,height:1e3,path:"m786 296v-267q0-15-11-26t-25-10h-214v214h-143v-214h-214q-15 0-25 10t-11 26v267q0 1 0 2t0 2l321 264 321-264q1-1 1-4z m124 39l-34-41q-5-5-12-6h-2q-7 0-12 3l-386 322-386-322q-7-4-13-4-7 2-12 7l-35 41q-4 5-3 13t6 12l401 334q18 15 42 15t43-15l136-114v109q0 8 5 13t13 5h107q8 0 13-5t5-13v-227l122-102q5-5 6-12t-4-13z",transform:"matrix(1 0 0 -1 0 850)"},"camera-retro":{width:1e3,height:1e3,path:"m518 386q0 8-5 13t-13 5q-37 0-63-27t-26-63q0-8 5-13t13-5 12 5 5 13q0 23 16 38t38 16q8 0 13 5t5 13z m125-73q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101z m-572-320h858v71h-858v-71z m643 320q0 89-62 152t-152 62-151-62-63-152 63-151 151-63 152 63 62 151z m-571 358h214v72h-214v-72z m-72-107h858v143h-462l-36-71h-360v-72z m929 143v-714q0-30-21-51t-50-21h-858q-29 0-50 21t-21 51v714q0 30 21 51t50 21h858q29 0 50-21t21-51z",transform:"matrix(1 0 0 -1 0 850)"},zoombox:{width:1e3,height:1e3,path:"m1000-25l-250 251c40 63 63 138 63 218 0 224-182 406-407 406-224 0-406-182-406-406s183-406 407-406c80 0 155 22 218 62l250-250 125 125z m-812 250l0 438 437 0 0-438-437 0z m62 375l313 0 0-312-313 0 0 312z",transform:"matrix(1 0 0 -1 0 850)"},pan:{width:1e3,height:1e3,path:"m1000 350l-187 188 0-125-250 0 0 250 125 0-188 187-187-187 125 0 0-250-250 0 0 125-188-188 186-187 0 125 252 0 0-250-125 0 187-188 188 188-125 0 0 250 250 0 0-126 187 188z",transform:"matrix(1 0 0 -1 0 850)"},zoom_plus:{width:875,height:1e3,path:"m1 787l0-875 875 0 0 875-875 0z m687-500l-187 0 0-187-125 0 0 187-188 0 0 125 188 0 0 187 125 0 0-187 187 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},zoom_minus:{width:875,height:1e3,path:"m0 788l0-876 875 0 0 876-875 0z m688-500l-500 0 0 125 500 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},autoscale:{width:1e3,height:1e3,path:"m250 850l-187 0-63 0 0-62 0-188 63 0 0 188 187 0 0 62z m688 0l-188 0 0-62 188 0 0-188 62 0 0 188 0 62-62 0z m-875-938l0 188-63 0 0-188 0-62 63 0 187 0 0 62-187 0z m875 188l0-188-188 0 0-62 188 0 62 0 0 62 0 188-62 0z m-125 188l-1 0-93-94-156 156 156 156 92-93 2 0 0 250-250 0 0-2 93-92-156-156-156 156 94 92 0 2-250 0 0-250 0 0 93 93 157-156-157-156-93 94 0 0 0-250 250 0 0 0-94 93 156 157 156-157-93-93 0 0 250 0 0 250z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_basic:{width:1500,height:1e3,path:"m375 725l0 0-375-375 375-374 0-1 1125 0 0 750-1125 0z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_compare:{width:1125,height:1e3,path:"m187 786l0 2-187-188 188-187 0 0 937 0 0 373-938 0z m0-499l0 1-187-188 188-188 0 0 937 0 0 376-938-1z",transform:"matrix(1 0 0 -1 0 850)"},plotlylogo:{width:1542,height:1e3,path:"m0-10h182v-140h-182v140z m228 146h183v-286h-183v286z m225 714h182v-1000h-182v1000z m225-285h182v-715h-182v715z m225 142h183v-857h-183v857z m231-428h182v-429h-182v429z m225-291h183v-138h-183v138z",transform:"matrix(1 0 0 -1 0 850)"},"z-axis":{width:1e3,height:1e3,path:"m833 5l-17 108v41l-130-65 130-66c0 0 0 38 0 39 0-1 36-14 39-25 4-15-6-22-16-30-15-12-39-16-56-20-90-22-187-23-279-23-261 0-341 34-353 59 3 60 228 110 228 110-140-8-351-35-351-116 0-120 293-142 474-142 155 0 477 22 477 142 0 50-74 79-163 96z m-374 94c-58-5-99-21-99-40 0-24 65-43 144-43 79 0 143 19 143 43 0 19-42 34-98 40v216h87l-132 135-133-135h88v-216z m167 515h-136v1c16 16 31 34 46 52l84 109v54h-230v-71h124v-1c-16-17-28-32-44-51l-89-114v-51h245v72z",transform:"matrix(1 0 0 -1 0 850)"},"3d_rotate":{width:1e3,height:1e3,path:"m922 660c-5 4-9 7-14 11-359 263-580-31-580-31l-102 28 58-400c0 1 1 1 2 2 118 108 351 249 351 249s-62 27-100 42c88 83 222 183 347 122 16-8 30-17 44-27-2 1-4 2-6 4z m36-329c0 0 64 229-88 296-62 27-124 14-175-11 157-78 225-208 249-266 8-19 11-31 11-31 2 5 6 15 11 32-5-13-8-20-8-20z m-775-239c70-31 117-50 198-32-121 80-199 346-199 346l-96-15-58-12c0 0 55-226 155-287z m603 133l-317-139c0 0 4-4 19-14 7-5 24-15 24-15s-177-147-389 4c235-287 536-112 536-112l31-22 100 299-4-1z m-298-153c6-4 14-9 24-15 0 0-17 10-24 15z",transform:"matrix(1 0 0 -1 0 850)"},camera:{width:1e3,height:1e3,path:"m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z m400 150h-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28l-31-94c-6-15-23-28-40-28h-120c-55 0-100-45-100-100v-450c0-55 45-100 100-100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250-250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35-35z",transform:"matrix(1 0 0 -1 0 850)"},movie:{width:1e3,height:1e3,path:"m938 413l-188-125c0 37-17 71-44 94 64 38 107 107 107 187 0 121-98 219-219 219-121 0-219-98-219-219 0-61 25-117 66-156h-115c30 33 49 76 49 125 0 103-84 187-187 187s-188-84-188-187c0-57 26-107 65-141-38-22-65-62-65-109v-250c0-70 56-126 125-126h500c69 0 125 56 125 126l188-126c34 0 62 28 62 63v375c0 35-28 63-62 63z m-750 0c-69 0-125 56-125 125s56 125 125 125 125-56 125-125-56-125-125-125z m406-1c-87 0-157 70-157 157 0 86 70 156 157 156s156-70 156-156-70-157-156-157z",transform:"matrix(1 0 0 -1 0 850)"},question:{width:857.1,height:1e3,path:"m500 82v107q0 8-5 13t-13 5h-107q-8 0-13-5t-5-13v-107q0-8 5-13t13-5h107q8 0 13 5t5 13z m143 375q0 49-31 91t-77 65-95 23q-136 0-207-119-9-14 4-24l74-55q4-4 10-4 9 0 14 7 30 38 48 51 19 14 48 14 27 0 48-15t21-33q0-21-11-34t-38-25q-35-16-65-48t-29-70v-20q0-8 5-13t13-5h107q8 0 13 5t5 13q0 10 12 27t30 28q18 10 28 16t25 19 25 27 16 34 7 45z m214-107q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z",transform:"matrix(1 0 0 -1 0 850)"},disk:{width:857.1,height:1e3,path:"m214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z",transform:"matrix(1 0 0 -1 0 850)"},lasso:{width:1031,height:1e3,path:"m1018 538c-36 207-290 336-568 286-277-48-473-256-436-463 10-57 36-108 76-151-13-66 11-137 68-183 34-28 75-41 114-42l-55-70 0 0c-2-1-3-2-4-3-10-14-8-34 5-45 14-11 34-8 45 4 1 1 2 3 2 5l0 0 113 140c16 11 31 24 45 40 4 3 6 7 8 11 48-3 100 0 151 9 278 48 473 255 436 462z m-624-379c-80 14-149 48-197 96 42 42 109 47 156 9 33-26 47-66 41-105z m-187-74c-19 16-33 37-39 60 50-32 109-55 174-68-42-25-95-24-135 8z m360 75c-34-7-69-9-102-8 8 62-16 128-68 170-73 59-175 54-244-5-9 20-16 40-20 61-28 159 121 317 333 354s407-60 434-217c28-159-121-318-333-355z",transform:"matrix(1 0 0 -1 0 850)"},selectbox:{width:1e3,height:1e3,path:"m0 850l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-285l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z",transform:"matrix(1 0 0 -1 0 850)"},spikeline:{width:1e3,height:1e3,path:"M512 409c0-57-46-104-103-104-57 0-104 47-104 104 0 57 47 103 104 103 57 0 103-46 103-103z m-327-39l92 0 0 92-92 0z m-185 0l92 0 0 92-92 0z m370-186l92 0 0 93-92 0z m0-184l92 0 0 92-92 0z",transform:"matrix(1.5 0 0 -1.5 0 850)"},newplotlylogo:{name:"newplotlylogo",svg:"plotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/contourgl")},{"../src/traces/contourgl":549}],4:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":418}],5:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmapgl")},{"../src/traces/heatmapgl":563}],6:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./scattergl"),t("./splom"),t("./pointcloud"),t("./heatmapgl"),t("./contourgl"),t("./parcoords")]),e.exports=n},{"./contourgl":3,"./core":4,"./heatmapgl":5,"./parcoords":7,"./pointcloud":8,"./scattergl":9,"./splom":10}],7:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcoords")},{"../src/traces/parcoords":575}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/pointcloud")},{"../src/traces/pointcloud":585}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergl")},{"../src/traces/scattergl":619}],10:[function(t,e,r){"use strict";e.exports=t("../src/traces/splom")},{"../src/traces/splom":623}],11:[function(t,e,r){e.exports=function(t){var e=0,r=0,n=0,a=0;return t.map(function(t){var i=(t=t.slice())[0],o=i.toUpperCase();if(i!=o)switch(t[0]=o,i){case"a":t[6]+=n,t[7]+=a;break;case"v":t[1]+=a;break;case"h":t[1]+=n;break;default:for(var s=1;sa&&(a=t[o]),t[o]=0;u--)if(c[u]!==f[u])return!1;for(u=c.length-1;u>=0;u--)if(l=c[u],!y(t[l],e[l],r,n))return!1;return!0}(t,e,r,o))}return r?t===e:t==e}function b(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function x(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function _(t,e,r,n){var a;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),a=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!a&&v(a,r,"Missing expected exception"+n);var o="string"==typeof n,s=!t&&a&&!r;if((!t&&i.isError(a)&&o&&x(a,r)||s)&&v(a,r,"Got unwanted exception"+n),t&&a&&r&&!x(a,r)||!t&&a)throw a}f.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=p(g((e=this).actual),128)+" "+e.operator+" "+p(g(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var a=n.stack,i=d(r),o=a.indexOf("\n"+i);if(o>=0){var s=a.indexOf("\n",o+1);a=a.substring(s+1)}this.stack=a}}},i.inherits(f.AssertionError,Error),f.fail=v,f.ok=m,f.equal=function(t,e,r){t!=e&&v(t,e,r,"==",f.equal)},f.notEqual=function(t,e,r){t==e&&v(t,e,r,"!=",f.notEqual)},f.deepEqual=function(t,e,r){y(t,e,!1)||v(t,e,r,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(t,e,r){y(t,e,!0)||v(t,e,r,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(t,e,r){y(t,e,!1)&&v(t,e,r,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function t(e,r,n){y(e,r,!0)&&v(e,r,n,"notDeepStrictEqual",t)},f.strictEqual=function(t,e,r){t!==e&&v(t,e,r,"===",f.strictEqual)},f.notStrictEqual=function(t,e,r){t===e&&v(t,e,r,"!==",f.notStrictEqual)},f.throws=function(t,e,r){_(!0,t,e,r)},f.doesNotThrow=function(t,e,r){_(!1,t,e,r)},f.ifError=function(t){if(t)throw t};var w=Object.keys||function(t){var e=[];for(var r in t)o.call(t,r)&&e.push(r);return e}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":19}],17:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],18:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],19:[function(t,e,r){(function(e,n){var a=/%[sdj%]/g;r.format=function(t){if(!m(t)){for(var e=[],r=0;r=i)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),l=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=l),c(n,t,n.depth)}function l(t,e){var r=s.styles[e];return r?"\x1b["+s.colors[r][0]+"m"+t+"\x1b["+s.colors[r][1]+"m":t}function u(t,e){return t}function c(t,e,n){if(t.customInspect&&e&&A(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var a=e.inspect(n,t);return m(a)||(a=c(t,a,n)),a}var i=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(v(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,e);if(i)return i;var o=Object.keys(e),s=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),w(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(e);if(0===o.length){if(A(e)){var l=e.name?": "+e.name:"";return t.stylize("[Function"+l+"]","special")}if(b(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(w(e))return f(e)}var u,x="",k=!1,T=["{","}"];(d(e)&&(k=!0,T=["[","]"]),A(e))&&(x=" [Function"+(e.name?": "+e.name:"")+"]");return b(e)&&(x=" "+RegExp.prototype.toString.call(e)),_(e)&&(x=" "+Date.prototype.toUTCString.call(e)),w(e)&&(x=" "+f(e)),0!==o.length||k&&0!=e.length?n<0?b(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),u=k?function(t,e,r,n,a){for(var i=[],o=0,s=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(u,x,T)):T[0]+x+T[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,a,i){var o,s,l;if((l=Object.getOwnPropertyDescriptor(e,a)||{value:e[a]}).get?s=l.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):l.set&&(s=t.stylize("[Setter]","special")),E(n,a)||(o="["+a+"]"),s||(t.seen.indexOf(l.value)<0?(s=g(r)?c(t,l.value,null):c(t,l.value,r-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),y(o)){if(i&&a.match(/^\d+$/))return s;(o=JSON.stringify(""+a)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+s}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function g(t){return null===t}function v(t){return"number"==typeof t}function m(t){return"string"==typeof t}function y(t){return void 0===t}function b(t){return x(t)&&"[object RegExp]"===k(t)}function x(t){return"object"==typeof t&&null!==t}function _(t){return x(t)&&"[object Date]"===k(t)}function w(t){return x(t)&&("[object Error]"===k(t)||t instanceof Error)}function A(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(y(i)&&(i=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(i)){var n=e.pid;o[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else o[t]=function(){};return o[t]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=g,r.isNullOrUndefined=function(t){return null==t},r.isNumber=v,r.isString=m,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=y,r.isRegExp=b,r.isObject=x,r.isDate=_,r.isError=w,r.isFunction=A,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t},r.isBuffer=t("./support/isBuffer");var M=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function E(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":"),[t.getDate(),M[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!x(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":18,_process:248,inherits:17}],20:[function(t,e,r){e.exports=function(t){return atob(t)}},{}],21:[function(t,e,r){"use strict";r.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=u(t),n=r[0],o=r[1],s=new i(function(t,e,r){return 3*(e+r)/4-r}(0,n,o)),l=0,c=o>0?n-4:n,f=0;f>16&255,s[l++]=e>>8&255,s[l++]=255&e;2===o&&(e=a[t.charCodeAt(f)]<<2|a[t.charCodeAt(f+1)]>>4,s[l++]=255&e);1===o&&(e=a[t.charCodeAt(f)]<<10|a[t.charCodeAt(f+1)]<<4|a[t.charCodeAt(f+2)]>>2,s[l++]=e>>8&255,s[l++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,a=r%3,i=[],o=0,s=r-a;os?s:o+16383));1===a?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===a&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],a=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var a,i,o=[],s=e;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return o.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],22:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}},{"./lib/rationalize":32}],23:[function(t,e,r){"use strict";e.exports=function(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}},{}],24:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]),t[1].mul(e[0]))}},{"./lib/rationalize":32}],25:[function(t,e,r){"use strict";var n=t("./is-rat"),a=t("./lib/is-bn"),i=t("./lib/num-to-bn"),o=t("./lib/str-to-bn"),s=t("./lib/rationalize"),l=t("./div");e.exports=function t(e,r){if(n(e))return r?l(e,t(r)):[e[0].clone(),e[1].clone()];var u=0;var c,f;if(a(e))c=e.clone();else if("string"==typeof e)c=o(e);else{if(0===e)return[i(0),i(1)];if(e===Math.floor(e))c=i(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),u-=256;c=i(e)}}if(n(r))c.mul(r[1]),f=r[0].clone();else if(a(r))f=r.clone();else if("string"==typeof r)f=o(r);else if(r)if(r===Math.floor(r))f=i(r);else{for(;r!==Math.floor(r);)r*=Math.pow(2,256),u+=256;f=i(r)}else f=i(1);u>0?c=c.ushln(u):u<0&&(f=f.ushln(-u));return s(c,f)}},{"./div":24,"./is-rat":26,"./lib/is-bn":30,"./lib/num-to-bn":31,"./lib/rationalize":32,"./lib/str-to-bn":33}],26:[function(t,e,r){"use strict";var n=t("./lib/is-bn");e.exports=function(t){return Array.isArray(t)&&2===t.length&&n(t[0])&&n(t[1])}},{"./lib/is-bn":30}],27:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return t.cmp(new n(0))}},{"bn.js":41}],28:[function(t,e,r){"use strict";var n=t("./bn-sign");e.exports=function(t){var e=t.length,r=t.words,a=0;if(1===e)a=r[0];else if(2===e)a=r[0]+67108864*r[1];else for(var i=0;i20)return 52;return r+32}},{"bit-twiddle":39,"double-bits":88}],30:[function(t,e,r){"use strict";t("bn.js");e.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},{"bn.js":41}],31:[function(t,e,r){"use strict";var n=t("bn.js"),a=t("double-bits");e.exports=function(t){var e=a.exponent(t);return e<52?new n(t):new n(t*Math.pow(2,52-e)).ushln(e-52)}},{"bn.js":41,"double-bits":88}],32:[function(t,e,r){"use strict";var n=t("./num-to-bn"),a=t("./bn-sign");e.exports=function(t,e){var r=a(t),i=a(e);if(0===r)return[n(0),n(1)];if(0===i)return[n(0),n(0)];i<0&&(t=t.neg(),e=e.neg());var o=t.gcd(e);if(o.cmpn(1))return[t.div(o),e.div(o)];return[t,e]}},{"./bn-sign":27,"./num-to-bn":31}],33:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return new n(t)}},{"bn.js":41}],34:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[0]),t[1].mul(e[1]))}},{"./lib/rationalize":32}],35:[function(t,e,r){"use strict";var n=t("./lib/bn-sign");e.exports=function(t){return n(t[0])*n(t[1])}},{"./lib/bn-sign":27}],36:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},{"./lib/rationalize":32}],37:[function(t,e,r){"use strict";var n=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=function(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var i=e.abs().divmod(r.abs()),o=i.div,s=n(o),l=i.mod,u=e.negative!==r.negative?-1:1;if(0===l.cmpn(0))return u*s;if(s){var c=a(s)+4,f=n(l.ushln(c).divRound(r));return u*(s+f*Math.pow(2,-c))}var h=r.bitLength()-l.bitLength()+53,f=n(l.ushln(h).divRound(r));return h<1023?u*f*Math.pow(2,-h):(f*=Math.pow(2,-1023),u*f*Math.pow(2,1023-h))}},{"./lib/bn-to-num":28,"./lib/ctz":29}],38:[function(t,e,r){"use strict";function n(t,e,r,n,a,i){var o=["function ",t,"(a,l,h,",n.join(","),"){",i?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",a?".get(m)":"[m]"];return i?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),i?o.push("return -1};"):o.push("return i};"),o.join("")}function a(t,e,r,a){return new Function([n("A","x"+t+"y",e,["y"],!1,a),n("B","x"+t+"y",e,["y"],!0,a),n("P","c(x,y)"+t+"0",e,["y","c"],!1,a),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,a),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""))()}e.exports={ge:a(">=",!1,"GE"),gt:a(">",!1,"GT"),lt:a("<",!0,"LT"),le:a("<=",!0,"LE"),eq:a("-",!0,"EQ",!0)}},{}],39:[function(t,e,r){"use strict";function n(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}r.INT_BITS=32,r.INT_MAX=2147483647,r.INT_MIN=-1<<31,r.sign=function(t){return(t>0)-(t<0)},r.abs=function(t){var e=t>>31;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var a=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,a=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--a;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},r.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},r.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},r.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],40:[function(t,e,r){"use strict";var n=t("clamp");e.exports=function(t,e){e||(e={});var r,o,s,l,u,c,f,h,d,p,g,v=null==e.cutoff?.25:e.cutoff,m=null==e.radius?8:e.radius,y=e.channel||0;if(ArrayBuffer.isView(t)||Array.isArray(t)){if(!e.width||!e.height)throw Error("For raw data width and height should be provided by options");r=e.width,o=e.height,l=t,c=e.stride?e.stride:Math.floor(t.length/r/o)}else window.HTMLCanvasElement&&t instanceof window.HTMLCanvasElement?(f=(h=t).getContext("2d"),r=h.width,o=h.height,d=f.getImageData(0,0,r,o),l=d.data,c=4):window.CanvasRenderingContext2D&&t instanceof window.CanvasRenderingContext2D?(h=t.canvas,f=t,r=h.width,o=h.height,d=f.getImageData(0,0,r,o),l=d.data,c=4):window.ImageData&&t instanceof window.ImageData&&(d=t,r=t.width,o=t.height,l=d.data,c=4);if(s=Math.max(r,o),window.Uint8ClampedArray&&l instanceof window.Uint8ClampedArray||window.Uint8Array&&l instanceof window.Uint8Array)for(u=l,l=Array(r*o),p=0,g=u.length;p=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function l(t,e,r,n){for(var a=0,i=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return a}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var a=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&a++,16===e?this._parseHex(t,a):this._parseBase(t,e,a),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},i.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},i.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var a=0;a=0;a-=3)o=t[a]|t[a-1]<<8|t[a-2]<<16,this.words[i]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===r)for(a=0,i=0;a>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)a=s(t,r,r+6),this.words[n]|=a<>>26-i&4194303,(i+=24)>=26&&(i-=26,n++);r+6!==e&&(a=s(t,e,r+6),this.words[n]|=a<>>26-i&4194303),this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,a=1;a<=67108863;a*=e)n++;n--,a=a/e|0;for(var i=t.length-r,o=i%n,s=Math.min(i,i-o)+r,u=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var a=0|t.words[0],i=0|e.words[0],o=a*i,s=67108863&o,l=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&l,h=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=h;d++){var p=u-d|0;c+=(o=(a=0|t.words[p])*(i=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,l=0|c}return 0!==l?r.words[u]=0|l:r.length--,r.strip()}i.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var a=0,i=0,o=0;o>>24-a&16777215)||o!==this.length-1?u[6-l.length]+l+r:l+r,(a+=2)>=26&&(a-=26,o--)}for(0!==i&&(r=i.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var h=c[t],d=f[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?g+r:u[h-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return n("undefined"!=typeof o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,r){var a=this.byteLength(),i=r||Math.max(1,a);n(a<=i,"byte array longer than desired length"),n(i>0,"Requested array length <= 0"),this.strip();var o,s,l="le"===e,u=new t(i),c=this.clone();if(l){for(s=0;!c.isZero();s++)o=c.andln(255),c.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-r),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,a=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var a=0,i=0;i>>26;for(;0!==a&&i>>26;if(this.length=r.length,0!==a)this.words[this.length]=a,this.length++;else if(r!==this)for(;it.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,a=this.cmp(t);if(0===a)return this.negative=0,this.length=1,this.words[0]=0,this;a>0?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==i&&o>26,this.words[o]=67108863&e;if(0===i&&o>>13,d=0|o[1],p=8191&d,g=d>>>13,v=0|o[2],m=8191&v,y=v>>>13,b=0|o[3],x=8191&b,_=b>>>13,w=0|o[4],A=8191&w,k=w>>>13,T=0|o[5],M=8191&T,E=T>>>13,C=0|o[6],S=8191&C,L=C>>>13,O=0|o[7],D=8191&O,R=O>>>13,P=0|o[8],I=8191&P,z=P>>>13,F=0|o[9],N=8191&F,B=F>>>13,j=0|s[0],U=8191&j,H=j>>>13,V=0|s[1],q=8191&V,G=V>>>13,X=0|s[2],W=8191&X,Y=X>>>13,Z=0|s[3],J=8191&Z,Q=Z>>>13,$=0|s[4],K=8191&$,tt=$>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,at=0|s[6],it=8191&at,ot=at>>>13,st=0|s[7],lt=8191&st,ut=st>>>13,ct=0|s[8],ft=8191&ct,ht=ct>>>13,dt=0|s[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(u+(n=Math.imul(f,U))|0)+((8191&(a=(a=Math.imul(f,H))+Math.imul(h,U)|0))<<13)|0;u=((i=Math.imul(h,H))+(a>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,U),a=(a=Math.imul(p,H))+Math.imul(g,U)|0,i=Math.imul(g,H);var mt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(a=(a=a+Math.imul(f,G)|0)+Math.imul(h,q)|0))<<13)|0;u=((i=i+Math.imul(h,G)|0)+(a>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,U),a=(a=Math.imul(m,H))+Math.imul(y,U)|0,i=Math.imul(y,H),n=n+Math.imul(p,q)|0,a=(a=a+Math.imul(p,G)|0)+Math.imul(g,q)|0,i=i+Math.imul(g,G)|0;var yt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(a=(a=a+Math.imul(f,Y)|0)+Math.imul(h,W)|0))<<13)|0;u=((i=i+Math.imul(h,Y)|0)+(a>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(x,U),a=(a=Math.imul(x,H))+Math.imul(_,U)|0,i=Math.imul(_,H),n=n+Math.imul(m,q)|0,a=(a=a+Math.imul(m,G)|0)+Math.imul(y,q)|0,i=i+Math.imul(y,G)|0,n=n+Math.imul(p,W)|0,a=(a=a+Math.imul(p,Y)|0)+Math.imul(g,W)|0,i=i+Math.imul(g,Y)|0;var bt=(u+(n=n+Math.imul(f,J)|0)|0)+((8191&(a=(a=a+Math.imul(f,Q)|0)+Math.imul(h,J)|0))<<13)|0;u=((i=i+Math.imul(h,Q)|0)+(a>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(A,U),a=(a=Math.imul(A,H))+Math.imul(k,U)|0,i=Math.imul(k,H),n=n+Math.imul(x,q)|0,a=(a=a+Math.imul(x,G)|0)+Math.imul(_,q)|0,i=i+Math.imul(_,G)|0,n=n+Math.imul(m,W)|0,a=(a=a+Math.imul(m,Y)|0)+Math.imul(y,W)|0,i=i+Math.imul(y,Y)|0,n=n+Math.imul(p,J)|0,a=(a=a+Math.imul(p,Q)|0)+Math.imul(g,J)|0,i=i+Math.imul(g,Q)|0;var xt=(u+(n=n+Math.imul(f,K)|0)|0)+((8191&(a=(a=a+Math.imul(f,tt)|0)+Math.imul(h,K)|0))<<13)|0;u=((i=i+Math.imul(h,tt)|0)+(a>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(M,U),a=(a=Math.imul(M,H))+Math.imul(E,U)|0,i=Math.imul(E,H),n=n+Math.imul(A,q)|0,a=(a=a+Math.imul(A,G)|0)+Math.imul(k,q)|0,i=i+Math.imul(k,G)|0,n=n+Math.imul(x,W)|0,a=(a=a+Math.imul(x,Y)|0)+Math.imul(_,W)|0,i=i+Math.imul(_,Y)|0,n=n+Math.imul(m,J)|0,a=(a=a+Math.imul(m,Q)|0)+Math.imul(y,J)|0,i=i+Math.imul(y,Q)|0,n=n+Math.imul(p,K)|0,a=(a=a+Math.imul(p,tt)|0)+Math.imul(g,K)|0,i=i+Math.imul(g,tt)|0;var _t=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(a=(a=a+Math.imul(f,nt)|0)+Math.imul(h,rt)|0))<<13)|0;u=((i=i+Math.imul(h,nt)|0)+(a>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(S,U),a=(a=Math.imul(S,H))+Math.imul(L,U)|0,i=Math.imul(L,H),n=n+Math.imul(M,q)|0,a=(a=a+Math.imul(M,G)|0)+Math.imul(E,q)|0,i=i+Math.imul(E,G)|0,n=n+Math.imul(A,W)|0,a=(a=a+Math.imul(A,Y)|0)+Math.imul(k,W)|0,i=i+Math.imul(k,Y)|0,n=n+Math.imul(x,J)|0,a=(a=a+Math.imul(x,Q)|0)+Math.imul(_,J)|0,i=i+Math.imul(_,Q)|0,n=n+Math.imul(m,K)|0,a=(a=a+Math.imul(m,tt)|0)+Math.imul(y,K)|0,i=i+Math.imul(y,tt)|0,n=n+Math.imul(p,rt)|0,a=(a=a+Math.imul(p,nt)|0)+Math.imul(g,rt)|0,i=i+Math.imul(g,nt)|0;var wt=(u+(n=n+Math.imul(f,it)|0)|0)+((8191&(a=(a=a+Math.imul(f,ot)|0)+Math.imul(h,it)|0))<<13)|0;u=((i=i+Math.imul(h,ot)|0)+(a>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(D,U),a=(a=Math.imul(D,H))+Math.imul(R,U)|0,i=Math.imul(R,H),n=n+Math.imul(S,q)|0,a=(a=a+Math.imul(S,G)|0)+Math.imul(L,q)|0,i=i+Math.imul(L,G)|0,n=n+Math.imul(M,W)|0,a=(a=a+Math.imul(M,Y)|0)+Math.imul(E,W)|0,i=i+Math.imul(E,Y)|0,n=n+Math.imul(A,J)|0,a=(a=a+Math.imul(A,Q)|0)+Math.imul(k,J)|0,i=i+Math.imul(k,Q)|0,n=n+Math.imul(x,K)|0,a=(a=a+Math.imul(x,tt)|0)+Math.imul(_,K)|0,i=i+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,a=(a=a+Math.imul(m,nt)|0)+Math.imul(y,rt)|0,i=i+Math.imul(y,nt)|0,n=n+Math.imul(p,it)|0,a=(a=a+Math.imul(p,ot)|0)+Math.imul(g,it)|0,i=i+Math.imul(g,ot)|0;var At=(u+(n=n+Math.imul(f,lt)|0)|0)+((8191&(a=(a=a+Math.imul(f,ut)|0)+Math.imul(h,lt)|0))<<13)|0;u=((i=i+Math.imul(h,ut)|0)+(a>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(I,U),a=(a=Math.imul(I,H))+Math.imul(z,U)|0,i=Math.imul(z,H),n=n+Math.imul(D,q)|0,a=(a=a+Math.imul(D,G)|0)+Math.imul(R,q)|0,i=i+Math.imul(R,G)|0,n=n+Math.imul(S,W)|0,a=(a=a+Math.imul(S,Y)|0)+Math.imul(L,W)|0,i=i+Math.imul(L,Y)|0,n=n+Math.imul(M,J)|0,a=(a=a+Math.imul(M,Q)|0)+Math.imul(E,J)|0,i=i+Math.imul(E,Q)|0,n=n+Math.imul(A,K)|0,a=(a=a+Math.imul(A,tt)|0)+Math.imul(k,K)|0,i=i+Math.imul(k,tt)|0,n=n+Math.imul(x,rt)|0,a=(a=a+Math.imul(x,nt)|0)+Math.imul(_,rt)|0,i=i+Math.imul(_,nt)|0,n=n+Math.imul(m,it)|0,a=(a=a+Math.imul(m,ot)|0)+Math.imul(y,it)|0,i=i+Math.imul(y,ot)|0,n=n+Math.imul(p,lt)|0,a=(a=a+Math.imul(p,ut)|0)+Math.imul(g,lt)|0,i=i+Math.imul(g,ut)|0;var kt=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(a=(a=a+Math.imul(f,ht)|0)+Math.imul(h,ft)|0))<<13)|0;u=((i=i+Math.imul(h,ht)|0)+(a>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,U),a=(a=Math.imul(N,H))+Math.imul(B,U)|0,i=Math.imul(B,H),n=n+Math.imul(I,q)|0,a=(a=a+Math.imul(I,G)|0)+Math.imul(z,q)|0,i=i+Math.imul(z,G)|0,n=n+Math.imul(D,W)|0,a=(a=a+Math.imul(D,Y)|0)+Math.imul(R,W)|0,i=i+Math.imul(R,Y)|0,n=n+Math.imul(S,J)|0,a=(a=a+Math.imul(S,Q)|0)+Math.imul(L,J)|0,i=i+Math.imul(L,Q)|0,n=n+Math.imul(M,K)|0,a=(a=a+Math.imul(M,tt)|0)+Math.imul(E,K)|0,i=i+Math.imul(E,tt)|0,n=n+Math.imul(A,rt)|0,a=(a=a+Math.imul(A,nt)|0)+Math.imul(k,rt)|0,i=i+Math.imul(k,nt)|0,n=n+Math.imul(x,it)|0,a=(a=a+Math.imul(x,ot)|0)+Math.imul(_,it)|0,i=i+Math.imul(_,ot)|0,n=n+Math.imul(m,lt)|0,a=(a=a+Math.imul(m,ut)|0)+Math.imul(y,lt)|0,i=i+Math.imul(y,ut)|0,n=n+Math.imul(p,ft)|0,a=(a=a+Math.imul(p,ht)|0)+Math.imul(g,ft)|0,i=i+Math.imul(g,ht)|0;var Tt=(u+(n=n+Math.imul(f,pt)|0)|0)+((8191&(a=(a=a+Math.imul(f,gt)|0)+Math.imul(h,pt)|0))<<13)|0;u=((i=i+Math.imul(h,gt)|0)+(a>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,q),a=(a=Math.imul(N,G))+Math.imul(B,q)|0,i=Math.imul(B,G),n=n+Math.imul(I,W)|0,a=(a=a+Math.imul(I,Y)|0)+Math.imul(z,W)|0,i=i+Math.imul(z,Y)|0,n=n+Math.imul(D,J)|0,a=(a=a+Math.imul(D,Q)|0)+Math.imul(R,J)|0,i=i+Math.imul(R,Q)|0,n=n+Math.imul(S,K)|0,a=(a=a+Math.imul(S,tt)|0)+Math.imul(L,K)|0,i=i+Math.imul(L,tt)|0,n=n+Math.imul(M,rt)|0,a=(a=a+Math.imul(M,nt)|0)+Math.imul(E,rt)|0,i=i+Math.imul(E,nt)|0,n=n+Math.imul(A,it)|0,a=(a=a+Math.imul(A,ot)|0)+Math.imul(k,it)|0,i=i+Math.imul(k,ot)|0,n=n+Math.imul(x,lt)|0,a=(a=a+Math.imul(x,ut)|0)+Math.imul(_,lt)|0,i=i+Math.imul(_,ut)|0,n=n+Math.imul(m,ft)|0,a=(a=a+Math.imul(m,ht)|0)+Math.imul(y,ft)|0,i=i+Math.imul(y,ht)|0;var Mt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(a=(a=a+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((i=i+Math.imul(g,gt)|0)+(a>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,W),a=(a=Math.imul(N,Y))+Math.imul(B,W)|0,i=Math.imul(B,Y),n=n+Math.imul(I,J)|0,a=(a=a+Math.imul(I,Q)|0)+Math.imul(z,J)|0,i=i+Math.imul(z,Q)|0,n=n+Math.imul(D,K)|0,a=(a=a+Math.imul(D,tt)|0)+Math.imul(R,K)|0,i=i+Math.imul(R,tt)|0,n=n+Math.imul(S,rt)|0,a=(a=a+Math.imul(S,nt)|0)+Math.imul(L,rt)|0,i=i+Math.imul(L,nt)|0,n=n+Math.imul(M,it)|0,a=(a=a+Math.imul(M,ot)|0)+Math.imul(E,it)|0,i=i+Math.imul(E,ot)|0,n=n+Math.imul(A,lt)|0,a=(a=a+Math.imul(A,ut)|0)+Math.imul(k,lt)|0,i=i+Math.imul(k,ut)|0,n=n+Math.imul(x,ft)|0,a=(a=a+Math.imul(x,ht)|0)+Math.imul(_,ft)|0,i=i+Math.imul(_,ht)|0;var Et=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(a=(a=a+Math.imul(m,gt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((i=i+Math.imul(y,gt)|0)+(a>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(N,J),a=(a=Math.imul(N,Q))+Math.imul(B,J)|0,i=Math.imul(B,Q),n=n+Math.imul(I,K)|0,a=(a=a+Math.imul(I,tt)|0)+Math.imul(z,K)|0,i=i+Math.imul(z,tt)|0,n=n+Math.imul(D,rt)|0,a=(a=a+Math.imul(D,nt)|0)+Math.imul(R,rt)|0,i=i+Math.imul(R,nt)|0,n=n+Math.imul(S,it)|0,a=(a=a+Math.imul(S,ot)|0)+Math.imul(L,it)|0,i=i+Math.imul(L,ot)|0,n=n+Math.imul(M,lt)|0,a=(a=a+Math.imul(M,ut)|0)+Math.imul(E,lt)|0,i=i+Math.imul(E,ut)|0,n=n+Math.imul(A,ft)|0,a=(a=a+Math.imul(A,ht)|0)+Math.imul(k,ft)|0,i=i+Math.imul(k,ht)|0;var Ct=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(a=(a=a+Math.imul(x,gt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((i=i+Math.imul(_,gt)|0)+(a>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,K),a=(a=Math.imul(N,tt))+Math.imul(B,K)|0,i=Math.imul(B,tt),n=n+Math.imul(I,rt)|0,a=(a=a+Math.imul(I,nt)|0)+Math.imul(z,rt)|0,i=i+Math.imul(z,nt)|0,n=n+Math.imul(D,it)|0,a=(a=a+Math.imul(D,ot)|0)+Math.imul(R,it)|0,i=i+Math.imul(R,ot)|0,n=n+Math.imul(S,lt)|0,a=(a=a+Math.imul(S,ut)|0)+Math.imul(L,lt)|0,i=i+Math.imul(L,ut)|0,n=n+Math.imul(M,ft)|0,a=(a=a+Math.imul(M,ht)|0)+Math.imul(E,ft)|0,i=i+Math.imul(E,ht)|0;var St=(u+(n=n+Math.imul(A,pt)|0)|0)+((8191&(a=(a=a+Math.imul(A,gt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((i=i+Math.imul(k,gt)|0)+(a>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(N,rt),a=(a=Math.imul(N,nt))+Math.imul(B,rt)|0,i=Math.imul(B,nt),n=n+Math.imul(I,it)|0,a=(a=a+Math.imul(I,ot)|0)+Math.imul(z,it)|0,i=i+Math.imul(z,ot)|0,n=n+Math.imul(D,lt)|0,a=(a=a+Math.imul(D,ut)|0)+Math.imul(R,lt)|0,i=i+Math.imul(R,ut)|0,n=n+Math.imul(S,ft)|0,a=(a=a+Math.imul(S,ht)|0)+Math.imul(L,ft)|0,i=i+Math.imul(L,ht)|0;var Lt=(u+(n=n+Math.imul(M,pt)|0)|0)+((8191&(a=(a=a+Math.imul(M,gt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((i=i+Math.imul(E,gt)|0)+(a>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(N,it),a=(a=Math.imul(N,ot))+Math.imul(B,it)|0,i=Math.imul(B,ot),n=n+Math.imul(I,lt)|0,a=(a=a+Math.imul(I,ut)|0)+Math.imul(z,lt)|0,i=i+Math.imul(z,ut)|0,n=n+Math.imul(D,ft)|0,a=(a=a+Math.imul(D,ht)|0)+Math.imul(R,ft)|0,i=i+Math.imul(R,ht)|0;var Ot=(u+(n=n+Math.imul(S,pt)|0)|0)+((8191&(a=(a=a+Math.imul(S,gt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((i=i+Math.imul(L,gt)|0)+(a>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(N,lt),a=(a=Math.imul(N,ut))+Math.imul(B,lt)|0,i=Math.imul(B,ut),n=n+Math.imul(I,ft)|0,a=(a=a+Math.imul(I,ht)|0)+Math.imul(z,ft)|0,i=i+Math.imul(z,ht)|0;var Dt=(u+(n=n+Math.imul(D,pt)|0)|0)+((8191&(a=(a=a+Math.imul(D,gt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((i=i+Math.imul(R,gt)|0)+(a>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,n=Math.imul(N,ft),a=(a=Math.imul(N,ht))+Math.imul(B,ft)|0,i=Math.imul(B,ht);var Rt=(u+(n=n+Math.imul(I,pt)|0)|0)+((8191&(a=(a=a+Math.imul(I,gt)|0)+Math.imul(z,pt)|0))<<13)|0;u=((i=i+Math.imul(z,gt)|0)+(a>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Pt=(u+(n=Math.imul(N,pt))|0)+((8191&(a=(a=Math.imul(N,gt))+Math.imul(B,pt)|0))<<13)|0;return u=((i=Math.imul(B,gt))+(a>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,l[0]=vt,l[1]=mt,l[2]=yt,l[3]=bt,l[4]=xt,l[5]=_t,l[6]=wt,l[7]=At,l[8]=kt,l[9]=Tt,l[10]=Mt,l[11]=Et,l[12]=Ct,l[13]=St,l[14]=Lt,l[15]=Ot,l[16]=Dt,l[17]=Rt,l[18]=Pt,0!==u&&(l[19]=u,r.length++),r};function p(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(d=h),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?h(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,a=0,i=0;i>>26)|0)>>>26,o&=67108863}r.words[i]=s,n=o,o=a}return 0!==n?r.words[i]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,a,i){for(var o=0;o>>=1)a++;return 1<>>=13,r[2*o+1]=8191&i,i>>>=13;for(o=2*e;o>=26,e+=a/67108864|0,e+=i>>>26,this.words[r]=67108863&i}return 0!==e&&(this.words[r]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>a}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n=0);var e,r=t%26,a=(t-r)/26,i=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==a){for(e=this.length-1;e>=0;e--)this.words[e+a]=this.words[e];for(e=0;e=0),a=e?(e-e%26)/26:0;var i=t%26,o=Math.min((t-i)/26,this.length),s=67108863^67108863>>>i<o)for(this.length-=o,u=0;u=0&&(0!==c||u>=a);u--){var f=0|this.words[u];this.words[u]=c<<26-i|f>>>i,c=f&s}return l&&0!==c&&(l.words[l.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,a=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var a=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(l/67108864|0),this.words[a+r]=67108863&i}for(;a>26,this.words[a+r]=67108863&i;if(0===s)return this.strip();for(n(-1===s),s=0,a=0;a>26,this.words[a]=67108863&i;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),a=t,o=0|a.words[a.length-1];0!==(r=26-this._countBits(o))&&(a=a.ushln(r),n.iushln(r),o=0|a.words[a.length-1]);var s,l=n.length-a.length;if("mod"!==e){(s=new i(null)).length=l+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var h=67108864*(0|n.words[a.length+f])+(0|n.words[a.length+f-1]);for(h=Math.min(h/o|0,67108863),n._ishlnsubmul(a,h,f);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(a,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=h)}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(a=s.div.neg()),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:a,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(a=s.div.neg()),{div:a,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var a,o,s},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),a=t.andln(1),i=r.cmp(n);return i<0||1===a&&0===i?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,a=this.length-1;a>=0;a--)r=(e*r+(0|this.words[a]))%t;return r},i.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var a=(0|this.words[r])+67108864*e;this.words[r]=a/t|0,e=a%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),f=e.clone();!e.isZero();){for(var h=0,d=1;0==(e.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(e.iushrn(h);h-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(c),o.isub(f)),a.iushrn(1),o.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(c),l.isub(f)),s.iushrn(1),l.iushrn(1);e.cmp(r)>=0?(e.isub(r),a.isub(s),o.isub(l)):(r.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:r.iushln(u)}},i.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a,o=new i(1),s=new i(0),l=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,c=1;0==(e.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(l),o.iushrn(1);for(var f=0,h=1;0==(r.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(s)):(r.isub(e),s.isub(o))}return(a=0===e.cmpn(1)?o:s).cmpn(0)<0&&a.iadd(t),a},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var a=e.cmp(r);if(a<0){var i=e;e=r,r=i}else if(0===a||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,a=1<>>26,s&=67108863,this.words[o]=s}return 0!==i&&(this.words[o]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var a=0|this.words[0];e=a===t?0:at.length)return 1;if(this.length=0;r--){var n=0|this.words[r],a=0|t.words[r];if(n!==a){na&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new w(t)},i.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function x(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},a(y,m),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,a=i}a>>>=22,t.words[n-10]=a,0===a&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=a,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new b;else if("p192"===t)e=new x;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return v[t]=e,e},w.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new i(1)).iushrn(2);return this.pow(t,r)}for(var a=this.m.subn(1),o=0;!a.isZero()&&0===a.andln(1);)o++,a.iushrn(1);n(!a.isZero());var s=new i(1).toRed(this),l=s.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,u).cmp(l);)c.redIAdd(l);for(var f=this.pow(c,a),h=this.pow(t,a.addn(1).iushrn(1)),d=this.pow(t,a),p=o;0!==d.cmp(s);){for(var g=d,v=0;0!==g.cmp(s);v++)g=g.redSqr();n(v=0;n--){for(var u=e.words[n],c=l-1;c>=0;c--){var f=u>>c&1;a!==r[0]&&(a=this.sqr(a)),0!==f||0!==o?(o<<=1,o|=f,(4===++s||0===n&&0===c)&&(a=this.mul(a,r[o]),s=0,o=0)):s=0}l=26}return a},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new A(t)},a(A,w),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).iushrn(this.shift),i=a;return a.cmp(this.m)>=0?i=a.isub(this.m):a.cmpn(0)<0&&(i=a.iadd(this.m)),i._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof e||e,this)},{buffer:49}],42:[function(t,e,r){"use strict";e.exports=function(t,e,r){switch(arguments.length){case 1:return n=[],u(a=t,a,c,!0),n;case 2:return"function"==typeof e?u(t,t,e,!0):function(t,e){return n=[],u(t,e,c,!1),n}(t,e);case 3:return u(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}var a};var n,a=t("typedarray-pool"),i=t("./lib/sweep"),o=t("./lib/intersect");function s(t,e){for(var r=0;r>>1;if(!(c<=0)){var f,h=a.mallocDouble(2*c*s),d=a.mallocInt32(s);if((s=l(t,c,h,d))>0){if(1===c&&n)i.init(s),f=i.sweepComplete(c,r,0,s,h,d,0,s,h,d);else{var p=a.mallocDouble(2*c*u),g=a.mallocInt32(u);(u=l(e,c,p,g))>0&&(i.init(s+u),f=1===c?i.sweepBipartite(c,r,0,s,h,d,0,u,p,g):o(c,r,n,s,h,d,u,p,g),a.free(p),a.free(g))}a.free(h),a.free(d)}return f}}}function c(t,e){n.push([t,e])}},{"./lib/intersect":44,"./lib/sweep":48,"typedarray-pool":289}],43:[function(t,e,r){"use strict";var n="d",a="ax",i="vv",o="fp",s="es",l="rs",u="re",c="rb",f="ri",h="rp",d="bs",p="be",g="bb",v="bi",m="bp",y="rv",b="Q",x=[n,a,i,l,u,c,f,d,p,g,v];function _(t){var e="bruteForce"+(t?"Full":"Partial"),r=[],_=x.slice();t||_.splice(3,0,o);var w=["function "+e+"("+_.join()+"){"];function A(e,o){var _=function(t,e,r){var o="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),_=["function ",o,"(",x.join(),"){","var ",s,"=2*",n,";"],w="for(var i="+l+","+h+"="+s+"*"+l+";i<"+u+";++i,"+h+"+="+s+"){var x0="+c+"["+a+"+"+h+"],x1="+c+"["+a+"+"+h+"+"+n+"],xi="+f+"[i];",A="for(var j="+d+","+m+"="+s+"*"+d+";j<"+p+";++j,"+m+"+="+s+"){var y0="+g+"["+a+"+"+m+"],"+(r?"y1="+g+"["+a+"+"+m+"+"+n+"],":"")+"yi="+v+"[j];";return t?_.push(w,b,":",A):_.push(A,b,":",w),r?_.push("if(y1"+p+"-"+d+"){"),t?(A(!0,!1),w.push("}else{"),A(!1,!1)):(w.push("if("+o+"){"),A(!0,!0),w.push("}else{"),A(!0,!1),w.push("}}else{if("+o+"){"),A(!1,!0),w.push("}else{"),A(!1,!1),w.push("}")),w.push("}}return "+e);var k=r.join("")+w.join("");return new Function(k)()}r.partial=_(!1),r.full=_(!0)},{}],44:[function(t,e,r){"use strict";e.exports=function(t,e,r,i,c,E,C,S,L){!function(t,e){var r=8*a.log2(e+1)*(t+1)|0,i=a.nextPow2(x*r);w.length0;){var P=(D-=1)*x,I=w[P],z=w[P+1],F=w[P+2],N=w[P+3],B=w[P+4],j=w[P+5],U=D*_,H=A[U],V=A[U+1],q=1&j,G=!!(16&j),X=c,W=E,Y=S,Z=L;if(q&&(X=S,W=L,Y=c,Z=E),!(2&j&&(F=v(t,I,z,F,X,W,V),z>=F)||4&j&&(z=m(t,I,z,F,X,W,H))>=F)){var J=F-z,Q=B-N;if(G){if(t*J*(J+Q)=p0)&&!(p1>=hi)",["p0","p1"]),g=c("lo===p0",["p0"]),v=c("lo>>1,h=2*t,d=f,p=s[h*f+e];for(;u=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(c-1),A=h*d,k=0;kr&&a[f+e]>u;--c,f-=o){for(var h=f,d=f+o,p=0;p=0&&a.push("lo=e[k+n]");t.indexOf("hi")>=0&&a.push("hi=e[k+o]");return r.push(n.replace("_",a.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],47:[function(t,e,r){"use strict";e.exports=function(t,e){e<=4*n?a(0,e-1,t):function t(e,r,f){var h=(r-e+1)/6|0,d=e+h,p=r-h,g=e+r>>1,v=g-h,m=g+h,y=d,b=v,x=g,_=m,w=p,A=e+1,k=r-1,T=0;u(y,b,f)&&(T=y,y=b,b=T);u(_,w,f)&&(T=_,_=w,w=T);u(y,x,f)&&(T=y,y=x,x=T);u(b,x,f)&&(T=b,b=x,x=T);u(y,_,f)&&(T=y,y=_,_=T);u(x,_,f)&&(T=x,x=_,_=T);u(b,w,f)&&(T=b,b=w,w=T);u(b,x,f)&&(T=b,b=x,x=T);u(_,w,f)&&(T=_,_=w,w=T);var M=f[2*b];var E=f[2*b+1];var C=f[2*_];var S=f[2*_+1];var L=2*y;var O=2*x;var D=2*w;var R=2*d;var P=2*g;var I=2*p;for(var z=0;z<2;++z){var F=f[L+z],N=f[O+z],B=f[D+z];f[R+z]=F,f[P+z]=N,f[I+z]=B}o(v,e,f);o(m,r,f);for(var j=A;j<=k;++j)if(c(j,M,E,f))j!==A&&i(j,A,f),++A;else if(!c(j,C,S,f))for(;;){if(c(k,C,S,f)){c(k,M,E,f)?(s(j,A,k,f),++A,--k):(i(j,k,f),--k);break}if(--kt;){var u=r[l-2],c=r[l-1];if(ur[e+1])}function c(t,e,r,n){var a=n[t*=2];return a>>1;i(d,E);for(var C=0,S=0,A=0;A=o)p(u,c,S--,L=L-o|0);else if(L>=0)p(s,l,C--,L);else if(L<=-o){L=-L-o|0;for(var O=0;O>>1;i(d,C);for(var S=0,L=0,O=0,k=0;k>1==d[2*k+3]>>1&&(R=2,k+=1),D<0){for(var P=-(D>>1)-1,I=0;I>1)-1;0===R?p(s,l,S--,P):1===R?p(u,c,L--,P):2===R&&p(f,h,O--,P)}}},scanBipartite:function(t,e,r,n,a,u,c,f,h,v,m,y){var b=0,x=2*t,_=e,w=e+t,A=1,k=1;n?k=o:A=o;for(var T=a;T>>1;i(d,S);for(var L=0,T=0;T=o?(D=!n,M-=o):(D=!!n,M-=1),D)g(s,l,L++,M);else{var R=y[M],P=x*M,I=m[P+e+1],z=m[P+e+1+t];t:for(var F=0;F>>1;i(d,A);for(var k=0,b=0;b=o)s[k++]=x-o;else{var M=p[x-=1],E=v*x,C=h[E+e+1],S=h[E+e+1+t];t:for(var L=0;L=0;--L)if(s[L]===x){for(var P=L+1;P0&&s.length>i){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=o[e]=r,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(r=o[t]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,a=v(t,n),i=0;i=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(var r=e,n=r+1,a=t.length;n=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return p(this,t,!0)},o.prototype.rawListeners=function(t){return p(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],51:[function(t,e,r){"use strict";var n=t("base64-js"),a=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=o(r),a=n.write(t,e);a!==r&&(n=n.slice(0,a));return n}(t,e);if(ArrayBuffer.isView(t))return f(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(j(t,ArrayBuffer)||t&&j(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var a=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return N(t).length;default:if(a)return n?-1:F(t).length;e=(""+e).toLowerCase(),a=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,a){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=a?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(a)return-1;r=t.length-1}else if(r<0){if(!a)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,a);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,a);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,a){var i,o=1,s=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(a){var c=-1;for(i=r;is&&(r=s-l),i=r;i>=0;i--){for(var f=!0,h=0;ha&&(n=a):n=a;var i=e.length;n>i/2&&(n=i/2);for(var o=0;o>8,a=r%256,i.push(a),i.push(n);return i}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function k(t,e,r){r=Math.min(t.length,r);for(var n=[],a=e;a239?4:u>223?3:u>191?2:1;if(a+f<=r)switch(f){case 1:u<128&&(c=u);break;case 2:128==(192&(i=t[a+1]))&&(l=(31&u)<<6|63&i)>127&&(c=l);break;case 3:i=t[a+1],o=t[a+2],128==(192&i)&&128==(192&o)&&(l=(15&u)<<12|(63&i)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:i=t[a+1],o=t[a+2],s=t[a+3],128==(192&i)&&128==(192&o)&&128==(192&s)&&(l=(15&u)<<18|(63&i)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(c=l)}null===c?(c=65533,f=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),a+=f}return function(t){var e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return k(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,a){if(j(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===a&&(a=this.length),e<0||r>t.length||n<0||a>this.length)throw new RangeError("out of range index");if(n>=a&&e>=r)return 0;if(n>=a)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(a>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),l=Math.min(i,o),u=this.slice(n,a),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var a=this.length-e;if((void 0===r||r>a)&&(r=a),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return x(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function M(t,e,r){var n="";r=Math.min(t.length,r);for(var a=e;an)&&(r=n);for(var a="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,a,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>a||et.length)throw new RangeError("Index out of range")}function D(t,e,r,n,a,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||D(t,0,r,4),a.write(t,e,r,n,23,4),r+4}function P(t,e,r,n,i){return e=+e,r>>>=0,i||D(t,0,r,8),a.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t],a=1,i=0;++i>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t+--e],a=1;e>0&&(a*=256);)n+=this[t+--e]*a;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t],a=1,i=0;++i=(a*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||L(t,e,this.length);for(var n=e,a=1,i=this[t+--n];n>0&&(a*=256);)i+=this[t+--n]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||L(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||L(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||L(t,4,this.length),a.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||L(t,4,this.length),a.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||L(t,8,this.length),a.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||L(t,8,this.length),a.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var a=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var a=r-1,i=1;for(this[e+a]=255&t;--a>=0&&(i*=256);)this[e+a]=t/i&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var a=Math.pow(2,8*r-1);O(this,t,e,r,a-1,-a)}var i=0,o=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var a=Math.pow(2,8*r-1);O(this,t,e,r,a-1,-a)}var i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return P(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return P(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return a},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var a=t.charCodeAt(0);("utf8"===n&&a<128||"latin1"===n)&&(t=a)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!a){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&i.push(239,191,189);continue}a=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),a=r;continue}r=65536+(a-55296<<10|r-56320)}else a&&(e-=3)>-1&&i.push(239,191,189);if(a=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function N(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function B(t,e,r,n){for(var a=0;a=e.length||a>=t.length);++a)e[a+r]=t[a];return a}function j(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}},{"base64-js":21,ieee754:202}],52:[function(t,e,r){"use strict";var n=t("./lib/monotone"),a=t("./lib/triangulation"),i=t("./lib/delaunay"),o=t("./lib/filter");function s(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function l(t,e){return t[0]-e[0]||t[1]-e[1]}function u(t,e,r){return e in t?t[e]:r}e.exports=function(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var c=!!u(r,"delaunay",!0),f=!!u(r,"interior",!0),h=!!u(r,"exterior",!0),d=!!u(r,"infinity",!1);if(!f&&!h||0===t.length)return[];var p=n(t,e);if(c||f!==h||d){for(var g=a(t.length,function(t){return t.map(s).sort(l)}(e)),v=0;v0;){for(var c=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;p=0||(e.flip(s,c),a(t,e,r,f,s,h),a(t,e,r,s,h,f),a(t,e,r,h,c,f),a(t,e,r,c,f,h)))}}},{"binary-search-bounds":57,"robust-in-sphere":261}],54:[function(t,e,r){"use strict";var n,a=t("binary-search-bounds");function i(t,e,r,n,a,i,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=a,this.next=i,this.boundary=o}function o(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}e.exports=function(t,e,r){var n=function(t,e){for(var r=t.cells(),n=r.length,a=0;a0||l.length>0;){for(;s.length>0;){var d=s.pop();if(u[d]!==-a){u[d]=a;c[d];for(var p=0;p<3;++p){var g=h[3*d+p];g>=0&&0===u[g]&&(f[3*d+p]?l.push(g):(s.push(g),u[g]=a))}}}var v=l;l=s,s=v,l.length=0,a=-a}var m=function(t,e,r){for(var n=0,a=0;a1&&a(r[h[d-2]],r[h[d-1]],i)>0;)t.push([h[d-1],h[d-2],o]),d-=1;h.length=d,h.push(o);var p=c.upperIds;for(d=p.length;d>1&&a(r[p[d-2]],r[p[d-1]],i)<0;)t.push([p[d-2],p[d-1],o]),d-=1;p.length=d,p.push(o)}}function d(t,e){var r;return(r=t.a[0]m[0]&&a.push(new u(m,v,s,f),new u(v,m,o,f))}a.sort(c);for(var y=a[0].a[0]-(1+Math.abs(a[0].a[0]))*Math.pow(2,-52),b=[new l([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=a.length;f<_;++f){var w=a[f],A=w.type;A===i?h(x,b,t,w.a,w.idx):A===s?p(b,t,w):g(b,t,w)}return x}},{"binary-search-bounds":57,"robust-orientation":262}],56:[function(t,e,r){"use strict";var n=t("binary-search-bounds");function a(t,e){this.stars=t,this.edges=e}e.exports=function(t,e){for(var r=new Array(t),n=0;n=0}}(),i.removeTriangle=function(t,e,r){var n=this.stars;o(n[t],e,r),o(n[e],r,t),o(n[r],t,e)},i.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},i.opposite=function(t,e){for(var r=this.stars[e],n=1,a=r.length;n>>1,x=a[m]"];return a?e.indexOf("c")<0?i.push(";if(x===y){return m}else if(x<=y){"):i.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):i.push(";if(",e,"){i=m;"),r?i.push("l=m+1}else{h=m-1}"):i.push("h=m-1}else{l=m+1}"),i.push("}"),a?i.push("return -1};"):i.push("return i};"),i.join("")}function a(t,e,r,a){return new Function([n("A","x"+t+"y",e,["y"],a),n("P","c(x,y)"+t+"0",e,["y","c"],a),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}e.exports={ge:a(">=",!1,"GE"),gt:a(">",!1,"GT"),lt:a("<",!0,"LT"),le:a("<=",!0,"LE"),eq:a("-",!0,"EQ",!0)}},{}],58:[function(t,e,r){e.exports=function(t,e,r){return er?r:t:te?e:t}},{}],59:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n;if(r){n=e;for(var a=new Array(e.length),i=0;ie[2]?1:0)}function m(t,e,r){if(0!==t.length){if(e)for(var n=0;n=0;--i){var b=e[c=(E=n[i])[0]],x=b[0],_=b[1],w=t[x],A=t[_];if((w[0]-A[0]||w[1]-A[1])<0){var k=x;x=_,_=k}b[0]=x;var T,M=b[1]=E[1];for(a&&(T=b[2]);i>0&&n[i-1][0]===c;){var E,C=(E=n[--i])[1];a?e.push([M,C,T]):e.push([M,C]),M=C}a?e.push([M,_,T]):e.push([M,_])}return h}(t,e,h,v,r));return m(e,y,r),!!y||(h.length>0||v.length>0)}},{"./lib/rat-seg-intersect":60,"big-rat":25,"big-rat/cmp":23,"big-rat/to-float":37,"box-intersect":42,nextafter:221,"rat-vec":251,"robust-segment-intersect":265,"union-find":290}],60:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var i=s(e,t),f=s(n,r),h=c(i,f);if(0===o(h))return null;var d=s(t,r),p=c(f,d),g=a(p,h),v=u(i,g);return l(t,v)};var n=t("big-rat/mul"),a=t("big-rat/div"),i=t("big-rat/sub"),o=t("big-rat/sign"),s=t("rat-vec/sub"),l=t("rat-vec/add"),u=t("rat-vec/muls");function c(t,e){return i(n(t[0],e[1]),n(t[1],e[0]))}},{"big-rat/div":24,"big-rat/mul":34,"big-rat/sign":35,"big-rat/sub":36,"rat-vec/add":250,"rat-vec/muls":252,"rat-vec/sub":253}],61:[function(t,e,r){"use strict";var n=t("clamp");function a(t,e){null==e&&(e=!0);var r=t[0],a=t[1],i=t[2],o=t[3];return null==o&&(o=e?1:255),e&&(r*=255,a*=255,i*=255,o*=255),16777216*(r=255&n(r,0,255))+((a=255&n(a,0,255))<<16)+((i=255&n(i,0,255))<<8)+(o=255&n(o,0,255))}e.exports=a,e.exports.to=a,e.exports.from=function(t,e){var r=(t=+t)>>>24,n=(16711680&t)>>>16,a=(65280&t)>>>8,i=255&t;return!1===e?[r,n,a,i]:[r/255,n/255,a/255,i/255]}},{clamp:58}],62:[function(t,e,r){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],63:[function(t,e,r){"use strict";var n=t("color-rgba"),a=t("clamp"),i=t("dtype");e.exports=function(t,e){"float"!==e&&e||(e="array"),"uint"===e&&(e="uint8"),"uint_clamped"===e&&(e="uint8_clamped");var r=new(i(e))(4),o="uint8"!==e&&"uint8_clamped"!==e;return t.length&&"string"!=typeof t||((t=n(t))[0]/=255,t[1]/=255,t[2]/=255),function(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||!!(Array.isArray(t)&&(t[0]>1||0===t[0])&&(t[1]>1||0===t[1])&&(t[2]>1||0===t[2])&&(!t[3]||t[3]>1))}(t)?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:255,o&&(r[0]/=255,r[1]/=255,r[2]/=255,r[3]/=255),r):(o?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:1):(r[0]=a(Math.floor(255*t[0]),0,255),r[1]=a(Math.floor(255*t[1]),0,255),r[2]=a(Math.floor(255*t[2]),0,255),r[3]=null==t[3]?255:a(Math.floor(255*t[3]),0,255)),r)}},{clamp:58,"color-rgba":65,dtype:90}],64:[function(t,e,r){(function(r){"use strict";var n=t("color-name"),a=t("is-plain-obj"),i=t("defined");e.exports=function(t){var e,s,l=[],u=1;if("string"==typeof t)if(n[t])l=n[t].slice(),s="rgb";else if("transparent"===t)u=0,s="rgb",l=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var c=t.slice(1),f=c.length,h=f<=4;u=1,h?(l=[parseInt(c[0]+c[0],16),parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16)],4===f&&(u=parseInt(c[3]+c[3],16)/255)):(l=[parseInt(c[0]+c[1],16),parseInt(c[2]+c[3],16),parseInt(c[4]+c[5],16)],8===f&&(u=parseInt(c[6]+c[7],16)/255)),l[0]||(l[0]=0),l[1]||(l[1]=0),l[2]||(l[2]=0),s="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var d=e[1],c=d.replace(/a$/,"");s=c;var f="cmyk"===c?4:"gray"===c?1:3;l=e[2].trim().split(/\s*,\s*/).map(function(t,e){if(/%$/.test(t))return e===f?parseFloat(t)/100:"rgb"===c?255*parseFloat(t)/100:parseFloat(t);if("h"===c[e]){if(/deg$/.test(t))return parseFloat(t);if(void 0!==o[t])return o[t]}return parseFloat(t)}),d===c&&l.push(1),u=void 0===l[f]?1:l[f],l=l.slice(0,f)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(l=t.match(/([0-9]+)/g).map(function(t){return parseFloat(t)}),s=t.match(/([a-z])/gi).join("").toLowerCase());else if(isNaN(t))if(a(t)){var p=i(t.r,t.red,t.R,null);null!==p?(s="rgb",l=[p,i(t.g,t.green,t.G),i(t.b,t.blue,t.B)]):(s="hsl",l=[i(t.h,t.hue,t.H),i(t.s,t.saturation,t.S),i(t.l,t.lightness,t.L,t.b,t.brightness)]),u=i(t.a,t.alpha,t.opacity,1),null!=t.opacity&&(u/=100)}else(Array.isArray(t)||r.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(t))&&(l=[t[0],t[1],t[2]],s="rgb",u=4===t.length?t[3]:1);else s="rgb",l=[t>>>16,(65280&t)>>>8,255&t];return{space:s,values:l,alpha:u}};var o={red:0,orange:60,yellow:120,green:180,blue:240,purple:300}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"color-name":62,defined:86,"is-plain-obj":210}],65:[function(t,e,r){"use strict";var n=t("color-parse"),a=t("color-space/hsl"),i=t("clamp");e.exports=function(t){var e,r=n(t);return r.space?((e=Array(3))[0]=i(r.values[0],0,255),e[1]=i(r.values[1],0,255),e[2]=i(r.values[2],0,255),"h"===r.space[0]&&(e=a.rgb(e)),e.push(i(r.alpha,0,1)),e):[]}},{clamp:58,"color-parse":64,"color-space/hsl":66}],66:[function(t,e,r){"use strict";var n=t("./rgb");e.exports={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e,r,n,a,i,o=t[0]/360,s=t[1]/100,l=t[2]/100;if(0===s)return[i=255*l,i,i];e=2*l-(r=l<.5?l*(1+s):l+s-l*s),a=[0,0,0];for(var u=0;u<3;u++)(n=o+1/3*-(u-1))<0?n++:n>1&&n--,i=6*n<1?e+6*(r-e)*n:2*n<1?r:3*n<2?e+(r-e)*(2/3-n)*6:e,a[u]=255*i;return a}},n.hsl=function(t){var e,r,n=t[0]/255,a=t[1]/255,i=t[2]/255,o=Math.min(n,a,i),s=Math.max(n,a,i),l=s-o;return s===o?e=0:n===s?e=(a-i)/l:a===s?e=2+(i-n)/l:i===s&&(e=4+(n-a)/l),(e=Math.min(60*e,360))<0&&(e+=360),r=(o+s)/2,[e,100*(s===o?0:r<=.5?l/(s+o):l/(2-s-o)),100*r]}},{"./rgb":67}],67:[function(t,e,r){"use strict";e.exports={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]}},{}],68:[function(t,e,r){"use strict";e.exports=function(t,e,r,i){var o=n(e,r,i);if(0===o){var s=a(n(t,e,r)),u=a(n(t,e,i));if(s===u){if(0===s){var c=l(t,e,r),f=l(t,e,i);return c===f?0:c?1:-1}return 0}return 0===u?s>0?-1:l(t,e,i)?-1:1:0===s?u>0?1:l(t,e,r)?1:-1:a(u-s)}var h=n(t,e,r);if(h>0)return o>0&&n(t,e,i)>0?1:-1;if(h<0)return o>0||n(t,e,i)>0?1:-1;var d=n(t,e,i);return d>0?1:l(t,e,r)?1:-1};var n=t("robust-orientation"),a=t("signum"),i=t("two-sum"),o=t("robust-product"),s=t("robust-sum");function l(t,e,r){var n=i(t[0],-e[0]),a=i(t[1],-e[1]),l=i(r[0],-e[0]),u=i(r[1],-e[1]),c=s(o(n,l),o(a,u));return c[c.length-1]>=0}},{"robust-orientation":262,"robust-product":263,"robust-sum":267,signum:268,"two-sum":288}],69:[function(t,e,r){e.exports=["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller"]},{}],70:[function(t,e,r){e.exports=["normal","condensed","semi-condensed","extra-condensed","ultra-condensed","expanded","semi-expanded","extra-expanded","ultra-expanded"]},{}],71:[function(t,e,r){e.exports=["normal","italic","oblique"]},{}],72:[function(t,e,r){e.exports=["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900"]},{}],73:[function(t,e,r){"use strict";e.exports={parse:t("./parse"),stringify:t("./stringify")}},{"./parse":75,"./stringify":76}],74:[function(t,e,r){"use strict";var n=t("css-font-size-keywords");e.exports={isSize:function(t){return/^[\d\.]/.test(t)||-1!==t.indexOf("/")||-1!==n.indexOf(t)}}},{"css-font-size-keywords":69}],75:[function(t,e,r){"use strict";var n=t("unquote"),a=t("css-global-keywords"),i=t("css-system-font-keywords"),o=t("css-font-weight-keywords"),s=t("css-font-style-keywords"),l=t("css-font-stretch-keywords"),u=t("string-split-by"),c=t("./lib/util").isSize;e.exports=h;var f=h.cache={};function h(t){if("string"!=typeof t)throw new Error("Font argument must be a string.");if(f[t])return f[t];if(""===t)throw new Error("Cannot parse an empty string.");if(-1!==i.indexOf(t))return f[t]={system:t};for(var e,r={style:"normal",variant:"normal",weight:"normal",stretch:"normal",lineHeight:"normal",size:"1rem",family:["serif"]},h=u(t,/\s+/);e=h.shift();){if(-1!==a.indexOf(e))return["style","variant","weight","stretch"].forEach(function(t){r[t]=e}),f[t]=r;if(-1===s.indexOf(e))if("normal"!==e&&"small-caps"!==e)if(-1===l.indexOf(e)){if(-1===o.indexOf(e)){if(c(e)){var p=u(e,"/");if(r.size=p[0],null!=p[1]?r.lineHeight=d(p[1]):"/"===h[0]&&(h.shift(),r.lineHeight=d(h.shift())),!h.length)throw new Error("Missing required font-family.");return r.family=u(h.join(" "),/\s*,\s*/).map(n),f[t]=r}throw new Error("Unknown or unsupported font token: "+e)}r.weight=e}else r.stretch=e;else r.variant=e;else r.style=e}throw new Error("Missing required font-size.")}function d(t){var e=parseFloat(t);return e.toString()===t?e:t}},{"./lib/util":74,"css-font-stretch-keywords":70,"css-font-style-keywords":71,"css-font-weight-keywords":72,"css-global-keywords":77,"css-system-font-keywords":78,"string-split-by":276,unquote:292}],76:[function(t,e,r){"use strict";var n=t("pick-by-alias"),a=t("./lib/util").isSize,i=g(t("css-global-keywords")),o=g(t("css-system-font-keywords")),s=g(t("css-font-weight-keywords")),l=g(t("css-font-style-keywords")),u=g(t("css-font-stretch-keywords")),c={normal:1,"small-caps":1},f={serif:1,"sans-serif":1,monospace:1,cursive:1,fantasy:1,"system-ui":1},h="1rem",d="serif";function p(t,e){if(t&&!e[t]&&!i[t])throw Error("Unknown keyword `"+t+"`");return t}function g(t){for(var e={},r=0;r0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},{"./lib/thunk.js":81}],80:[function(t,e,r){"use strict";var n=t("uniq");function a(t,e,r){var n,a,i=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],u=[],c=0,f=0;for(n=0;n0&&l.push("var "+u.join(",")),n=i-1;n>=0;--n)c=t[n],l.push(["for(i",n,"=0;i",n,"0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",c,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r){for(var n=t.body,a=[],i=[],o=0;o0&&y.push("shape=SS.slice(0)"),t.indexArgs.length>0){var b=new Array(r);for(l=0;l0&&m.push("var "+y.join(",")),l=0;l3&&m.push(i(t.pre,t,s));var A=i(t.body,t,s),k=function(t){for(var e=0,r=t[0].length;e0,u=[],c=0;c0;){"].join("")),u.push(["if(j",c,"<",s,"){"].join("")),u.push(["s",e[c],"=j",c].join("")),u.push(["j",c,"=0"].join("")),u.push(["}else{s",e[c],"=",s].join("")),u.push(["j",c,"-=",s,"}"].join("")),l&&u.push(["index[",e[c],"]=j",c].join(""));for(c=0;c3&&m.push(i(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+m.join("\n")+"\n----------");var T=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",k,function(t){for(var e=new Array(t.length),r=!0,n=0;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}(s)].join("");return new Function(["function ",T,"(",v.join(","),"){",m.join("\n"),"} return ",T].join(""))()}},{uniq:291}],81:[function(t,e,r){"use strict";var n=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],a=t.funcName+"_cwise_thunk";e.push(["return function ",a,"(",t.shimArgs.join(","),"){"].join(""));for(var i=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],u=[],c=0;c0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[c]))),u.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[c])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),c=0;ce?1:t>=e?0:NaN}function d(t){return null===t?NaN:+t}function p(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)<0?n=i+1:a=i}return n},right:function(e,r,n,a){for(arguments.length<3&&(n=0),arguments.length<4&&(a=e.length);n>>1;t(e[i],r)>0?a=i:n=i+1}return n}}}t.ascending=h,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++an&&(r=n)}else{for(;++a=n){r=n;break}for(;++an&&(r=n)}return r},t.max=function(t,e){var r,n,a=-1,i=t.length;if(1===arguments.length){for(;++a=n){r=n;break}for(;++ar&&(r=n)}else{for(;++a=n){r=n;break}for(;++ar&&(r=n)}return r},t.extent=function(t,e){var r,n,a,i=-1,o=t.length;if(1===arguments.length){for(;++i=n){r=a=n;break}for(;++in&&(r=n),a=n){r=a=n;break}for(;++in&&(r=n),a1)return o/(l-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(h);function m(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return h(t(e),r)}:t)},t.shuffle=function(t,e,r){(i=arguments.length)<3&&(r=t.length,i<2&&(e=0));for(var n,a,i=r-e;i;)a=Math.random()*i--|0,n=t[i+e],t[i+e]=t[a+e],t[a+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],a=new Array(r<0?0:r);e=0;)for(e=(n=t[a]).length;--e>=0;)r[--o]=n[e];return r};var y=Math.abs;function b(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function x(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,a=[],i=function(t){var e=1;for(;t*e%1;)e*=10;return e}(y(r)),o=-1;if(t*=i,e*=i,(r*=i)<0)for(;(n=t+r*++o)>e;)a.push(n/i);else for(;(n=t+r*++o)=a.length)return r?r.call(n,i):e?i.sort(e):i;for(var l,u,c,f,h=-1,d=i.length,p=a[s++],g=new x;++h=a.length)return e;var n=[],o=i[r++];return e.forEach(function(e,a){n.push({key:e,values:t(a,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return a.push(t),n},n.sortKeys=function(t){return i[a.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new L;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(U,"\\$&")};var U=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,H={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function V(t){return H(t,W),t}var q=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},X=function(t,e){var r=t.matches||t[R(t,"matchesSelector")];return(X=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(q=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,X=Sizzle.matchesSelector),t.selection=function(){return t.select(a.documentElement)};var W=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return q(t,this)}}function Z(t){return"function"==typeof t?t:function(){return G(t,this)}}W.select=function(t){var e,r,n,a,i=[];t=Y(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Q.hasOwnProperty(r)?{space:Q[r],local:t}:t}},W.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each($(r,e[r]));return this}return this.each($(e,r))},W.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,a=-1;if(e=r.classList){for(;++a=0;)(r=n[a])&&(i&&i!==r.nextSibling&&i.parentNode.insertBefore(r,i),i=r);return this},W.sort=function(t){t=function(t){arguments.length||(t=h);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var l=pt.get(e);function u(){var t=this[i];t&&(this.removeEventListener(e,t,t.$),delete this[i])}return l&&(e=l,s=vt),o?r?function(){var t=s(r,n(arguments));u.call(this),this.addEventListener(e,this[i]=t,t.$=a),t._=r}:u:r?I:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var a in this)if(r=a.match(n)){var i=this[a];this.removeEventListener(r[1],i,i.$),delete this[a]}}}t.selection.enter=ft,t.selection.enter.prototype=ht,ht.append=W.append,ht.empty=W.empty,ht.node=W.node,ht.call=W.call,ht.size=W.size,ht.select=function(t){for(var e,r,n,a,i,o=[],s=-1,l=this.length;++s=n&&(n=e+1);!(o=s[n])&&++n0?1:t<0?-1:0}function Dt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function Rt(t){return t>1?0:t<-1?Tt:Math.acos(t)}function Pt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function It(t){return((t=Math.exp(t))+1/t)/2}function zt(t){return(t=Math.sin(t/2))*t}var Ft=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,a=t[0],i=t[1],o=t[2],s=e[0],l=e[1],u=e[2],c=s-a,f=l-i,h=c*c+f*f;if(h0&&(e=e.transition().duration(g)),e.call(w.event)}function E(){u&&u.domain(l.range().map(function(t){return(t-h.x)/h.k}).map(l.invert)),f&&f.domain(c.range().map(function(t){return(t-h.y)/h.k}).map(c.invert))}function C(t){v++||t({type:"zoomstart"})}function S(t){E(),t({type:"zoom",scale:h.k,translate:[h.x,h.y]})}function L(t){--v||(t({type:"zoomend"}),r=null)}function O(){var e=this,r=_.of(e,arguments),n=0,a=t.select(o(e)).on(y,function(){n=1,T(t.mouse(e),i),S(r)}).on(b,function(){a.on(y,null).on(b,null),s(n),L(r)}),i=A(t.mouse(e)),s=bt(e);fs.call(e),C(r)}function D(){var e,r=this,n=_.of(r,arguments),a={},i=0,o=".zoom-"+t.event.changedTouches[0].identifier,l="touchmove"+o,u="touchend"+o,c=[],f=t.select(r),d=bt(r);function p(){var n=t.touches(r);return e=h.k,n.forEach(function(t){t.identifier in a&&(a[t.identifier]=A(t))}),n}function g(){var e=t.event.target;t.select(e).on(l,v).on(u,y),c.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){m=d[0];var b=d[1],x=m[0]-b[0],_=m[1]-b[1];i=x*x+_*_}}function v(){var o,l,u,c,f=t.touches(r);fs.call(r);for(var h=0,d=f.length;h360?t-=360:t<0&&(t+=360),t<60?n+(a-n)*t/60:t<180?a:t<240?n+(a-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(a=r<=.5?r*(1+e):r+e-r*e),new ie(i(t+120),i(t),i(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Yt?e.l:(e=he((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ht(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ht(this.h,this.s,t*this.l)},Vt.rgb=function(){return qt(this.h,this.s,this.l)},t.hcl=Gt;var Xt=Gt.prototype=new Ut;function Wt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Yt(r,Math.cos(t*=St)*e,Math.sin(t)*e)}function Yt(t,e,r){return this instanceof Yt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Yt?new Yt(t.l,t.a,t.b):t instanceof Gt?Wt(t.h,t.c,t.l):he((t=ie(t)).r,t.g,t.b):new Yt(t,e,r)}Xt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Zt*(arguments.length?t:1)))},Xt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Zt*(arguments.length?t:1)))},Xt.rgb=function(){return Wt(this.h,this.c,this.l).rgb()},t.lab=Yt;var Zt=18,Jt=.95047,Qt=1,$t=1.08883,Kt=Yt.prototype=new Ut;function te(t,e,r){var n=(t+16)/116,a=n+e/500,i=n-r/200;return new ie(ae(3.2404542*(a=re(a)*Jt)-1.5371385*(n=re(n)*Qt)-.4985314*(i=re(i)*$t)),ae(-.969266*a+1.8760108*n+.041556*i),ae(.0556434*a-.2040259*n+1.0572252*i))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Lt,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ae(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ie(t,e,r){return this instanceof ie?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ie?new ie(t.r,t.g,t.b):ce(""+t,ie,qt):new ie(t,e,r)}function oe(t){return new ie(t>>16,t>>8&255,255&t)}function se(t){return oe(t)+""}Kt.brighter=function(t){return new Yt(Math.min(100,this.l+Zt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Yt(Math.max(0,this.l-Zt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ie;var le=ie.prototype=new Ut;function ue(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ce(t,e,r){var n,a,i,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=n[2].split(","),n[1]){case"hsl":return r(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(pe(a[0]),pe(a[1]),pe(a[2]))}return(i=ge.get(t))?e(i.r,i.g,i.b):(null==t||"#"!==t.charAt(0)||isNaN(i=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&i)>>4,o|=o>>4,s=240&i,s|=s>>4,l=15&i,l|=l<<4):7===t.length&&(o=(16711680&i)>>16,s=(65280&i)>>8,l=255&i)),e(o,s,l))}function fe(t,e,r){var n,a,i=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-i,l=(o+i)/2;return s?(a=l<.5?s/(o+i):s/(2-o-i),n=t==o?(e-r)/s+(e0&&l<1?0:n),new Ht(n,a,l)}function he(t,e,r){var n=ne((.4124564*(t=de(t))+.3575761*(e=de(e))+.1804375*(r=de(r)))/Jt),a=ne((.2126729*t+.7151522*e+.072175*r)/Qt);return Yt(116*a-16,500*(n-a),200*(a-ne((.0193339*t+.119192*e+.9503041*r)/$t)))}function de(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function pe(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}le.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,a=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=a.call(o,u)}catch(t){return void s.error.call(o,t)}s.load.call(o,t)}else s.error.call(o,u)}return!this.XDomainRequest||"withCredentials"in u||!/^(http(s)?:)?\/\//.test(e)||(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=f:u.onreadystatechange=function(){u.readyState>3&&f()},u.onprogress=function(e){var r=t.event;t.event=e;try{s.progress.call(o,u)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return a=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,a){if(2===arguments.length&&"function"==typeof n&&(a=n,n=null),u.open(t,e,!0),null==r||"accept"in l||(l.accept=r+",*/*"),u.setRequestHeader)for(var i in l)u.setRequestHeader(i,l[i]);return null!=r&&u.overrideMimeType&&u.overrideMimeType(r),null!=c&&(u.responseType=c),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),s.beforesend.call(o,u),u.send(null==n?null:n),o},o.abort=function(){return u.abort(),o},t.rebind(o,s,"on"),null==i?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(i))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=me(O),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function a(t,r,n){arguments.length<3&&(n=r,r=null);var a=ye(t,e,null==r?i:o(r),n);return a.row=function(t){return arguments.length?a.response(null==(r=t)?i:o(t)):r},a}function i(t){return a.parse(t.responseText)}function o(t){return function(e){return a.parse(e.responseText,t)}}function s(e){return e.map(l).join(t)}function l(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return a.parse=function(t,e){var r;return a.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(a(t),r)}:a})},a.parseRows=function(t,e){var r,a,i={},o={},s=[],l=t.length,u=0,c=0;function f(){if(u>=l)return o;if(a)return a=!1,i;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Te,e)),_e=0):(_e=1,Ae(Te))}function Me(){for(var t=Date.now(),e=be;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Ee(){for(var t,e=be,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Ce(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Se[8+n/3]};var Le=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Oe=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Ce(e,r))).toFixed(Math.max(0,Math.min(20,Ce(e*(1+1e-15),r))))}});function De(t){return t+""}var Re=t.time={},Pe=Date;function Ie(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Ie.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ze.setUTCDate.apply(this._,arguments)},setDay:function(){ze.setUTCDay.apply(this._,arguments)},setFullYear:function(){ze.setUTCFullYear.apply(this._,arguments)},setHours:function(){ze.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ze.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ze.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ze.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ze.setUTCSeconds.apply(this._,arguments)},setTime:function(){ze.setTime.apply(this._,arguments)}};var ze=Date.prototype;function Fe(t,e,r){function n(e){var r=t(e),n=i(r,1);return e-r1)for(;o68?1900:2e3),r+a[0].length):-1}function Je(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function Qe(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function $e(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ar(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=y(e)/60|0,a=y(e)%60;return r+He(n,"0",2)+He(a,"0",2)}function ir(t,e,r){Ue.lastIndex=0;var n=Ue.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),i.push(t.substring(r-=s,r+s)),!((l+=s+1)>e));)s=a[o=(o+1)%a.length];return i.reverse().join(n)}:O;return function(e){var n=Le.exec(e),a=n[1]||" ",s=n[2]||">",l=n[3]||"-",u=n[4]||"",c=n[5],f=+n[6],h=n[7],d=n[8],p=n[9],g=1,v="",m="",y=!1,b=!0;switch(d&&(d=+d.substring(1)),(c||"0"===a&&"="===s)&&(c=a="0",s="="),p){case"n":h=!0,p="g";break;case"%":g=100,m="%",p="f";break;case"p":g=100,m="%",p="r";break;case"b":case"o":case"x":case"X":"#"===u&&(v="0"+p.toLowerCase());case"c":b=!1;case"d":y=!0,d=0;break;case"s":g=-1,p="r"}"$"===u&&(v=i[0],m=i[1]),"r"!=p||d||(p="g"),null!=d&&("g"==p?d=Math.max(1,Math.min(21,d)):"e"!=p&&"f"!=p||(d=Math.max(0,Math.min(20,d)))),p=Oe.get(p)||De;var x=c&&h;return function(e){var n=m;if(y&&e%1)return"";var i=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===l?"":l;if(g<0){var u=t.formatPrefix(e,d);e=u.scale(e),n=u.symbol+m}else e*=g;var _,w,A=(e=p(e,d)).lastIndexOf(".");if(A<0){var k=b?e.lastIndexOf("e"):-1;k<0?(_=e,w=""):(_=e.substring(0,k),w=e.substring(k))}else _=e.substring(0,A),w=r+e.substring(A+1);!c&&h&&(_=o(_,1/0));var T=v.length+_.length+w.length+(x?0:i.length),M=T"===s?M+i+e:"^"===s?M.substring(0,T>>=1)+i+e+M.substring(T):i+(x?e:M+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,a=e.time,i=e.periods,o=e.days,s=e.shortDays,l=e.months,u=e.shortMonths;function c(t){var e=t.length;function r(r){for(var n,a,i,o=[],s=-1,l=0;++s=u)return-1;if(37===(a=e.charCodeAt(s++))){if(o=e.charAt(s++),!(i=w[o in Be?e.charAt(s++):o])||(n=i(t,r,n))<0)return-1}else if(a!=r.charCodeAt(n++))return-1}return n}c.utc=function(t){var e=c(t);function r(t){try{var r=new(Pe=Ie);return r._=t,e(r)}finally{Pe=Date}}return r.parse=function(t){try{Pe=Ie;var r=e.parse(t);return r&&r._}finally{Pe=Date}},r.toString=e.toString,r},c.multi=c.utc.multi=or;var h=t.map(),d=Ve(o),p=qe(o),g=Ve(s),v=qe(s),m=Ve(l),y=qe(l),b=Ve(u),x=qe(u);i.forEach(function(t,e){h.set(t.toLowerCase(),e)});var _={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:c(r),d:function(t,e){return He(t.getDate(),e,2)},e:function(t,e){return He(t.getDate(),e,2)},H:function(t,e){return He(t.getHours(),e,2)},I:function(t,e){return He(t.getHours()%12||12,e,2)},j:function(t,e){return He(1+Re.dayOfYear(t),e,3)},L:function(t,e){return He(t.getMilliseconds(),e,3)},m:function(t,e){return He(t.getMonth()+1,e,2)},M:function(t,e){return He(t.getMinutes(),e,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,e){return He(t.getSeconds(),e,2)},U:function(t,e){return He(Re.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return He(Re.mondayOfYear(t),e,2)},x:c(n),X:c(a),y:function(t,e){return He(t.getFullYear()%100,e,2)},Y:function(t,e){return He(t.getFullYear()%1e4,e,4)},Z:ar,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){d.lastIndex=0;var n=d.exec(e.slice(r));return n?(t.w=p.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){b.lastIndex=0;var n=b.exec(e.slice(r));return n?(t.m=x.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){m.lastIndex=0;var n=m.exec(e.slice(r));return n?(t.m=y.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:$e,e:$e,H:tr,I:tr,j:Ke,L:nr,m:Qe,M:er,p:function(t,e,r){var n=h.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:Xe,w:Ge,W:We,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:Ze,Y:Ye,Z:Je,"%":ir};return c}(e)}};var sr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function lr(){}t.format=sr.numberFormat,t.geo={},lr.prototype={s:0,t:0,add:function(t){cr(t,this.t,ur),cr(ur.s,this.s,this),this.s?this.t+=ur.t:this.s=ur.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ur=new lr;function cr(t,e,r){var n=r.s=t+e,a=n-t,i=n-a;r.t=t-i+(e-a)}function fr(t,e){t&&dr.hasOwnProperty(t.type)&&dr[t.type](t,e)}t.geo.stream=function(t,e){t&&hr.hasOwnProperty(t.type)?hr[t.type](t,e):fr(t,e)};var hr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,a=r.length;++n=0?1:-1,s=o*i,l=Math.cos(e),u=Math.sin(e),c=a*u,f=n*l+c*Math.cos(s),h=c*o*Math.sin(s);Cr.add(Math.atan2(h,f)),r=t,n=l,a=u}Sr.point=function(o,s){Sr.point=i,r=(t=o)*St,n=Math.cos(s=(e=s)*St/2+Tt/4),a=Math.sin(s)},Sr.lineEnd=function(){i(t,e)}}function Or(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Dr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Rr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Pr(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Ir(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function zr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Fr(t){return[Math.atan2(t[1],t[0]),Pt(t[2])]}function Nr(t,e){return y(t[0]-e[0])At?a=90:u<-At&&(r=-90),f[0]=e,f[1]=n}};function d(t,i){c.push(f=[e=t,n=t]),ia&&(a=i)}function p(t,o){var s=Or([t*St,o*St]);if(l){var u=Rr(l,s),c=Rr([u[1],-u[0],0],u);zr(c),c=Fr(c);var f=t-i,h=f>0?1:-1,p=c[0]*Lt*h,g=y(f)>180;if(g^(h*ia&&(a=v);else if(g^(h*i<(p=(p+360)%360-180)&&pa&&(a=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>i?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else d(t,o);l=s,i=t}function g(){h.point=p}function v(){f[0]=e,f[1]=n,h.point=d,l=null}function m(t,e){if(l){var r=t-i;u+=y(r)>180?r+(r>0?360:-360):r}else o=t,s=e;Sr.point(t,e),p(t,e)}function b(){Sr.lineStart()}function x(){m(o,s),Sr.lineEnd(),y(u)>At&&(e=-(n=180)),f[0]=e,f[1]=n,l=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function A(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=d[1]),_(d[0],g[1])>_(g[0],g[1])&&(g[0]=d[0])):s.push(g=d);for(var l,u,d,p=-1/0,g=(o=0,s[u=s.length-1]);o<=u;g=d,++o)d=s[o],(l=_(g[1],d[0]))>p&&(p=l,e=d[0],n=g[1])}return c=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,a]]}}(),t.geo.centroid=function(e){mr=yr=br=xr=_r=wr=Ar=kr=Tr=Mr=Er=0,t.geo.stream(e,Br);var r=Tr,n=Mr,a=Er,i=r*r+n*n+a*a;return i=0;--s)a.point((f=c[s])[0],f[1]);else n(d.x,d.p.x,-1,a);d=d.p}c=(d=d.o).z,p=!p}while(!d.v);a.lineEnd()}}}function Yr(t){if(e=t.length){for(var e,r,n=0,a=t[0];++n=0?1:-1,A=w*_,k=A>Tt,T=p*b;if(Cr.add(Math.atan2(T*w*Math.sin(A),g*x+T*Math.cos(A))),i+=k?_+w*Mt:_,k^h>=r^m>=r){var M=Rr(Or(f),Or(t));zr(M);var E=Rr(a,M);zr(E);var C=(k^_>=0?-1:1)*Pt(E[2]);(n>C||n===C&&(M[0]||M[1]))&&(o+=k^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(i<-At||i0){for(b||(o.polygonStart(),b=!0),o.lineStart();++i1&&2&e&&r.push(r.pop().concat(r.shift())),s.push(r.filter(Qr))}return c}}function Qr(t){return t.length>1}function $r(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:I,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-Ct-At:Ct-t[1])-((e=e.x)[0]<0?e[1]-Ct-At:Ct-e[1])}var tn=Jr(Xr,function(t){var e,r=NaN,n=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(i,o){var s=i>0?Tt:-Tt,l=y(i-r);y(l-Tt)0?Ct:-Ct),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(i,n),e=0):a!==s&&l>=Tt&&(y(r-a)At?Math.atan((Math.sin(e)*(i=Math.cos(n))*Math.sin(r)-Math.sin(n)*(a=Math.cos(e))*Math.sin(t))/(a*i*o)):(e+n)/2}(r,n,i,o),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(s,n),e=0),t.point(r=i,n=o),a=s},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var a;if(null==t)a=r*Ct,n.point(-Tt,a),n.point(0,a),n.point(Tt,a),n.point(Tt,0),n.point(Tt,-a),n.point(0,-a),n.point(-Tt,-a),n.point(-Tt,0),n.point(-Tt,a);else if(y(t[0]-e[0])>At){var i=t[0]0)){if(i/=h,h<0){if(i0){if(i>f)return;i>c&&(c=i)}if(i=r-l,h||!(i<0)){if(i/=h,h<0){if(i>f)return;i>c&&(c=i)}else if(h>0){if(i0)){if(i/=d,d<0){if(i0){if(i>f)return;i>c&&(c=i)}if(i=n-u,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>c&&(c=i)}else if(d>0){if(i0&&(a.a={x:l+c*h,y:u+c*d}),f<1&&(a.b={x:l+f*h,y:u+f*d}),a}}}}}}var rn=1e9;function nn(e,r,n,a){return function(l){var u,c,f,h,d,p,g,v,m,y,b,x=l,_=$r(),w=en(e,r,n,a),A={point:M,lineStart:function(){A.point=E,c&&c.push(f=[]);y=!0,m=!1,g=v=NaN},lineEnd:function(){u&&(E(h,d),p&&m&&_.rejoin(),u.push(_.buffer()));A.point=M,m&&l.lineEnd()},polygonStart:function(){l=_,u=[],c=[],b=!0},polygonEnd:function(){l=x,u=t.merge(u);var r=function(t){for(var e=0,r=c.length,n=t[1],a=0;an&&Dt(u,i,t)>0&&++e:i[1]<=n&&Dt(u,i,t)<0&&--e,u=i;return 0!==e}([e,a]),n=b&&r,i=u.length;(n||i)&&(l.polygonStart(),n&&(l.lineStart(),k(null,null,1,l),l.lineEnd()),i&&Wr(u,o,r,k,l),l.polygonEnd()),u=c=f=null}};function k(t,o,l,u){var c=0,f=0;if(null==t||(c=i(t,l))!==(f=i(o,l))||s(t,o)<0^l>0)do{u.point(0===c||3===c?e:n,c>1?a:r)}while((c=(c+l+4)%4)!==f);else u.point(o[0],o[1])}function T(t,i){return e<=t&&t<=n&&r<=i&&i<=a}function M(t,e){T(t,e)&&l.point(t,e)}function E(t,e){var r=T(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(c&&f.push([t,e]),y)h=t,d=e,p=r,y=!1,r&&(l.lineStart(),l.point(t,e));else if(r&&m)l.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(m||(l.lineStart(),l.point(n.a.x,n.a.y)),l.point(n.b.x,n.b.y),r||l.lineEnd(),b=!1):r&&(l.lineStart(),l.point(t,e),b=!1)}g=t,v=e,m=r}return A};function i(t,a){return y(t[0]-e)0?0:3:y(t[0]-n)0?2:1:y(t[1]-r)0?1:0:a>0?3:2}function o(t,e){return s(t.x,e.x)}function s(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Tt/3,n=Sn(t),a=n(e,r);return a.parallels=function(t){return arguments.length?n(e=t[0]*Tt/180,r=t[1]*Tt/180):[e/Tt*180,r/Tt*180]},a}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,a=1+r*(2*n-r),i=Math.sqrt(a)/n;function o(t,e){var r=Math.sqrt(a-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),i-r*Math.cos(t)]}return o.invert=function(t,e){var r=i-e;return[Math.atan2(t,r)/n,Pt((a-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,a,i,o={stream:function(t){return a&&(a.valid=!1),(a=i(t)).valid=!0,a},extent:function(s){return arguments.length?(i=nn(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),a&&(a.valid=!1,a=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,a,i=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};function u(t){var i=t[0],o=t[1];return e=null,r(i,o),e||(n(i,o),e)||a(i,o),e}return u.invert=function(t){var e=i.scale(),r=i.translate(),n=(t[0]-r[0])/e,a=(t[1]-r[1])/e;return(a>=.12&&a<.234&&n>=-.425&&n<-.214?o:a>=.166&&a<.234&&n>=-.214&&n<-.115?s:i).invert(t)},u.stream=function(t){var e=i.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,a){e.point(t,a),r.point(t,a),n.point(t,a)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},u.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),s.precision(t),u):i.precision()},u.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),s.scale(t),u.translate(i.translate())):i.scale()},u.translate=function(t){if(!arguments.length)return i.translate();var e=i.scale(),c=+t[0],f=+t[1];return r=i.translate(t).clipExtent([[c-.455*e,f-.238*e],[c+.455*e,f+.238*e]]).stream(l).point,n=o.translate([c-.307*e,f+.201*e]).clipExtent([[c-.425*e+At,f+.12*e+At],[c-.214*e-At,f+.234*e-At]]).stream(l).point,a=s.translate([c-.205*e,f+.212*e]).clipExtent([[c-.214*e+At,f+.166*e+At],[c-.115*e-At,f+.234*e-At]]).stream(l).point,u},u.scale(1070)};var sn,ln,un,cn,fn,hn,dn={point:I,lineStart:I,lineEnd:I,polygonStart:function(){ln=0,dn.lineStart=pn},polygonEnd:function(){dn.lineStart=dn.lineEnd=dn.point=I,sn+=y(ln/2)}};function pn(){var t,e,r,n;function a(t,e){ln+=n*t-r*e,r=t,n=e}dn.point=function(i,o){dn.point=a,t=r=i,e=n=o},dn.lineEnd=function(){a(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);ehn&&(hn=e)},lineStart:I,lineEnd:I,polygonStart:I,polygonEnd:I};function vn(){var t=mn(4.5),e=[],r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=mn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function a(t,n){e.push("M",t,",",n),r.point=i}function i(t,r){e.push("L",t,",",r)}function o(){r.point=n}function s(){e.push("Z")}return r}function mn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var yn,bn={point:xn,lineStart:_n,lineEnd:wn,polygonStart:function(){bn.lineStart=An},polygonEnd:function(){bn.point=xn,bn.lineStart=_n,bn.lineEnd=wn}};function xn(t,e){br+=t,xr+=e,++_r}function _n(){var t,e;function r(r,n){var a=r-t,i=n-e,o=Math.sqrt(a*a+i*i);wr+=o*(t+r)/2,Ar+=o*(e+n)/2,kr+=o,xn(t=r,e=n)}bn.point=function(n,a){bn.point=r,xn(t=n,e=a)}}function wn(){bn.point=xn}function An(){var t,e,r,n;function a(t,e){var a=t-r,i=e-n,o=Math.sqrt(a*a+i*i);wr+=o*(r+t)/2,Ar+=o*(n+e)/2,kr+=o,Tr+=(o=n*t-r*e)*(r+t),Mr+=o*(n+e),Er+=3*o,xn(r=t,n=e)}bn.point=function(i,o){bn.point=a,xn(t=r=i,e=n=o)},bn.lineEnd=function(){a(t,e)}}function kn(t){var e=4.5,r={point:n,lineStart:function(){r.point=a},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:I};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,Mt)}function a(e,n){t.moveTo(e,n),r.point=i}function i(e,r){t.lineTo(e,r)}function o(){r.point=n}function s(){t.closePath()}return r}function Tn(t){var e=.5,r=Math.cos(30*St),n=16;function a(e){return(n?function(e){var r,a,o,s,l,u,c,f,h,d,p,g,v={point:m,lineStart:y,lineEnd:x,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=y}};function m(r,n){r=t(r,n),e.point(r[0],r[1])}function y(){f=NaN,v.point=b,e.lineStart()}function b(r,a){var o=Or([r,a]),s=t(r,a);i(f,h,c,d,p,g,f=s[0],h=s[1],c=r,d=o[0],p=o[1],g=o[2],n,e),e.point(f,h)}function x(){v.point=m,e.lineEnd()}function _(){y(),v.point=w,v.lineEnd=A}function w(t,e){b(r=t,e),a=f,o=h,s=d,l=p,u=g,v.point=b}function A(){i(f,h,c,d,p,g,a,o,r,s,l,u,n,e),v.lineEnd=x,x()}return v}:function(e){return En(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function i(n,a,o,s,l,u,c,f,h,d,p,g,v,m){var b=c-n,x=f-a,_=b*b+x*x;if(_>4*e&&v--){var w=s+d,A=l+p,k=u+g,T=Math.sqrt(w*w+A*A+k*k),M=Math.asin(k/=T),E=y(y(k)-1)e||y((b*O+x*D)/_-.5)>.3||s*d+l*p+u*g0&&16,a):Math.sqrt(e)},a}function Mn(t){this.stream=t}function En(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Cn(t){return Sn(function(){return t})()}function Sn(e){var r,n,a,i,o,s,l=Tn(function(t,e){return[(t=r(t,e))[0]*u+i,o-t[1]*u]}),u=150,c=480,f=250,h=0,d=0,p=0,g=0,v=0,m=tn,b=O,x=null,_=null;function w(t){return[(t=a(t[0]*St,t[1]*St))[0]*u+i,o-t[1]*u]}function A(t){return(t=a.invert((t[0]-i)/u,(o-t[1])/u))&&[t[0]*Lt,t[1]*Lt]}function k(){a=Gr(n=Rn(p,g,v),r);var t=r(h,d);return i=c-t[0]*u,o=f+t[1]*u,T()}function T(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Ln(m(n,l(b(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(m=null==t?(x=t,tn):function(t){var e=Math.cos(t),r=e>0,n=y(e)>At;return Jr(a,function(t){var e,s,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(f,h){var d,p=[f,h],g=a(f,h),v=r?g?0:o(f,h):g?o(f+(f<0?Tt:-Tt),h):0;if(!e&&(u=l=g)&&t.lineStart(),g!==l&&(d=i(e,p),(Nr(e,d)||Nr(p,d))&&(p[0]+=At,p[1]+=At,g=a(p[0],p[1]))),g!==l)c=0,g?(t.lineStart(),d=i(p,e),t.point(d[0],d[1])):(d=i(e,p),t.point(d[0],d[1]),t.lineEnd()),e=d;else if(n&&e&&r^g){var m;v&s||!(m=i(p,e,!0))||(c=0,r?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||e&&Nr(e,p)||t.point(p[0],p[1]),e=p,l=g,s=v},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return c|(u&&l)<<1}}},Fn(t,6*St),r?[0,-t]:[-Tt,t-Tt]);function a(t,r){return Math.cos(t)*Math.cos(r)>e}function i(t,r,n){var a=[1,0,0],i=Rr(Or(t),Or(r)),o=Dr(i,i),s=i[0],l=o-s*s;if(!l)return!n&&t;var u=e*o/l,c=-e*s/l,f=Rr(a,i),h=Ir(a,u);Pr(h,Ir(i,c));var d=f,p=Dr(h,d),g=Dr(d,d),v=p*p-g*(Dr(h,h)-1);if(!(v<0)){var m=Math.sqrt(v),b=Ir(d,(-p-m)/g);if(Pr(b,h),b=Fr(b),!n)return b;var x,_=t[0],w=r[0],A=t[1],k=r[1];w<_&&(x=_,_=w,w=x);var T=w-_,M=y(T-Tt)0^b[1]<(y(b[0]-_)Tt^(_<=b[0]&&b[0]<=w)){var E=Ir(d,(-p+m)/g);return Pr(E,h),[b,Fr(E)]}}}function o(e,n){var a=r?t:Tt-t,i=0;return e<-a?i|=1:e>a&&(i|=2),n<-a?i|=4:n>a&&(i|=8),i}}((x=+t)*St),T()):x},w.clipExtent=function(t){return arguments.length?(_=t,b=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):O,T()):_},w.scale=function(t){return arguments.length?(u=+t,k()):u},w.translate=function(t){return arguments.length?(c=+t[0],f=+t[1],k()):[c,f]},w.center=function(t){return arguments.length?(h=t[0]%360*St,d=t[1]%360*St,k()):[h*Lt,d*Lt]},w.rotate=function(t){return arguments.length?(p=t[0]%360*St,g=t[1]%360*St,v=t.length>2?t[2]%360*St:0,k()):[p*Lt,g*Lt,v*Lt]},t.rebind(w,l,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&A,k()}}function Ln(t){return En(t,function(e,r){t.point(e*St,r*St)})}function On(t,e){return[t,e]}function Dn(t,e){return[t>Tt?t-Mt:t<-Tt?t+Mt:t,e]}function Rn(t,e,r){return t?e||r?Gr(In(t),zn(e,r)):In(t):e||r?zn(e,r):Dn}function Pn(t){return function(e,r){return[(e+=t)>Tt?e-Mt:e<-Tt?e+Mt:e,r]}}function In(t){var e=Pn(t);return e.invert=Pn(-t),e}function zn(t,e){var r=Math.cos(t),n=Math.sin(t),a=Math.cos(e),i=Math.sin(e);function o(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*r+s*n;return[Math.atan2(l*a-c*i,s*r-u*n),Pt(c*a+l*i)]}return o.invert=function(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*a-l*i;return[Math.atan2(l*a+u*i,s*r+c*n),Pt(c*r-s*n)]},o}function Fn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(a,i,o,s){var l=o*e;null!=a?(a=Nn(r,a),i=Nn(r,i),(o>0?ai)&&(a+=o*Mt)):(a=t+o*Mt,i=t-.5*l);for(var u,c=a;o>0?c>i:c2?t[2]*St:0),e.invert=function(e){return(e=t.invert(e[0]*St,e[1]*St))[0]*=Lt,e[1]*=Lt,e},e},Dn.invert=On,t.geo.circle=function(){var t,e,r=[0,0],n=6;function a(){var t="function"==typeof r?r.apply(this,arguments):r,n=Rn(-t[0]*St,-t[1]*St,0).invert,a=[];return e(null,null,1,{point:function(t,e){a.push(t=n(t,e)),t[0]*=Lt,t[1]*=Lt}}),{type:"Polygon",coordinates:[a]}}return a.origin=function(t){return arguments.length?(r=t,a):r},a.angle=function(r){return arguments.length?(e=Fn((t=+r)*St,n*St),a):t},a.precision=function(r){return arguments.length?(e=Fn(t*St,(n=+r)*St),a):n},a.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*St,a=t[1]*St,i=e[1]*St,o=Math.sin(n),s=Math.cos(n),l=Math.sin(a),u=Math.cos(a),c=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((r=f*o)*r+(r=u*c-l*f*s)*r),l*c+u*f*s)},t.geo.graticule=function(){var e,r,n,a,i,o,s,l,u,c,f,h,d=10,p=d,g=90,v=360,m=2.5;function b(){return{type:"MultiLineString",coordinates:x()}}function x(){return t.range(Math.ceil(a/g)*g,n,g).map(f).concat(t.range(Math.ceil(l/v)*v,s,v).map(h)).concat(t.range(Math.ceil(r/d)*d,e,d).filter(function(t){return y(t%g)>At}).map(u)).concat(t.range(Math.ceil(o/p)*p,i,p).filter(function(t){return y(t%v)>At}).map(c))}return b.lines=function(){return x().map(function(t){return{type:"LineString",coordinates:t}})},b.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(h(s).slice(1),f(n).reverse().slice(1),h(l).reverse().slice(1))]}},b.extent=function(t){return arguments.length?b.majorExtent(t).minorExtent(t):b.minorExtent()},b.majorExtent=function(t){return arguments.length?(a=+t[0][0],n=+t[1][0],l=+t[0][1],s=+t[1][1],a>n&&(t=a,a=n,n=t),l>s&&(t=l,l=s,s=t),b.precision(m)):[[a,l],[n,s]]},b.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),o>i&&(t=o,o=i,i=t),b.precision(m)):[[r,o],[e,i]]},b.step=function(t){return arguments.length?b.majorStep(t).minorStep(t):b.minorStep()},b.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],b):[g,v]},b.minorStep=function(t){return arguments.length?(d=+t[0],p=+t[1],b):[d,p]},b.precision=function(t){return arguments.length?(m=+t,u=Bn(o,i,90),c=jn(r,e,m),f=Bn(l,s,90),h=jn(a,n,m),b):m},b.majorExtent([[-180,-90+At],[180,90-At]]).minorExtent([[-180,-80-At],[180,80+At]])},t.geo.greatArc=function(){var e,r,n=Un,a=Hn;function i(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||a.apply(this,arguments)]}}return i.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||a.apply(this,arguments))},i.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,i):n},i.target=function(t){return arguments.length?(a=t,r="function"==typeof t?null:t,i):a},i.precision=function(){return arguments.length?i:0},i},t.geo.interpolate=function(t,e){return r=t[0]*St,n=t[1]*St,a=e[0]*St,i=e[1]*St,o=Math.cos(n),s=Math.sin(n),l=Math.cos(i),u=Math.sin(i),c=o*Math.cos(r),f=o*Math.sin(r),h=l*Math.cos(a),d=l*Math.sin(a),p=2*Math.asin(Math.sqrt(zt(i-n)+o*l*zt(a-r))),g=1/Math.sin(p),(v=p?function(t){var e=Math.sin(t*=p)*g,r=Math.sin(p-t)*g,n=r*c+e*h,a=r*f+e*d,i=r*s+e*u;return[Math.atan2(a,n)*Lt,Math.atan2(i,Math.sqrt(n*n+a*a))*Lt]}:function(){return[r*Lt,n*Lt]}).distance=p,v;var r,n,a,i,o,s,l,u,c,f,h,d,p,g,v},t.geo.length=function(e){return yn=0,t.geo.stream(e,Vn),yn};var Vn={sphere:I,point:I,lineStart:function(){var t,e,r;function n(n,a){var i=Math.sin(a*=St),o=Math.cos(a),s=y((n*=St)-t),l=Math.cos(s);yn+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=r*i-e*o*l)*s),e*i+r*o*l),t=n,e=i,r=o}Vn.point=function(a,i){t=a*St,e=Math.sin(i*=St),r=Math.cos(i),Vn.point=n},Vn.lineEnd=function(){Vn.point=Vn.lineEnd=I}},lineEnd:I,polygonStart:I,polygonEnd:I};function qn(t,e){function r(e,r){var n=Math.cos(e),a=Math.cos(r),i=t(n*a);return[i*a*Math.sin(e),i*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),a=e(n),i=Math.sin(a),o=Math.cos(a);return[Math.atan2(t*i,n*o),Math.asin(n&&r*i/n)]},r}var Gn=qn(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Cn(Gn)}).raw=Gn;var Xn=qn(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},O);function Wn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Tt/4+t/2)},a=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),i=r*Math.pow(n(t),a)/a;if(!a)return Jn;function o(t,e){i>0?e<-Ct+At&&(e=-Ct+At):e>Ct-At&&(e=Ct-At);var r=i/Math.pow(n(e),a);return[r*Math.sin(a*t),i-r*Math.cos(a*t)]}return o.invert=function(t,e){var r=i-e,n=Ot(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(i/n,1/a))-Ct]},o}function Yn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),a=r/n+t;if(y(n)1&&Dt(t[r[n-2]],t[r[n-1]],t[a])<=0;)--n;r[n++]=a}return r.slice(0,n)}function aa(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Cn(Kn)}).raw=Kn,ta.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ct]},(t.geo.transverseMercator=function(){var t=Qn(ta),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ta,t.geom={},t.geom.hull=function(t){var e=ea,r=ra;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,a=ve(e),i=ve(r),o=t.length,s=[],l=[];for(n=0;n=0;--n)d.push(t[s[u[n]][2]]);for(n=+f;nAt)s=s.L;else{if(!((a=i-wa(s,o))>At)){n>-At?(e=s.P,r=s):a>-At?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=ma(t);if(fa.insert(e,l),e||r){if(e===r)return Ea(e),r=ma(e.site),fa.insert(l,r),l.edge=r.edge=La(e.site,l.site),Ma(e),void Ma(r);if(r){Ea(e),Ea(r);var u=e.site,c=u.x,f=u.y,h=t.x-c,d=t.y-f,p=r.site,g=p.x-c,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+c,y:(h*b-g*y)/m+f};Oa(r.edge,u,p,x),l.edge=La(u,t,null,x),r.edge=La(t,p,null,x),Ma(e),Ma(r)}else l.edge=La(e.site,l.site)}}function _a(t,e){var r=t.site,n=r.x,a=r.y,i=a-e;if(!i)return n;var o=t.P;if(!o)return-1/0;var s=(r=o.site).x,l=r.y,u=l-e;if(!u)return s;var c=s-n,f=1/i-1/u,h=c/u;return f?(-h+Math.sqrt(h*h-2*f*(c*c/(-2*u)-l+u/2+a-i/2)))/f+n:(n+s)/2}function wa(t,e){var r=t.N;if(r)return _a(r,e);var n=t.site;return n.y===e?n.x:1/0}function Aa(t){this.site=t,this.edges=[]}function ka(t,e){return e.angle-t.angle}function Ta(){Pa(this),this.x=this.y=this.arc=this.site=this.cy=null}function Ma(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,a=t.site,i=r.site;if(n!==i){var o=a.x,s=a.y,l=n.x-o,u=n.y-s,c=i.x-o,f=2*(l*(v=i.y-s)-u*c);if(!(f>=-kt)){var h=l*l+u*u,d=c*c+v*v,p=(v*h-u*d)/f,g=(l*d-c*h)/f,v=g+s,m=ga.pop()||new Ta;m.arc=t,m.site=a,m.x=p+o,m.y=v+Math.sqrt(p*p+g*g),m.cy=v,t.circle=m;for(var y=null,b=da._;b;)if(m.y=s)return;if(h>p){if(i){if(i.y>=u)return}else i={x:v,y:l};r={x:v,y:u}}else{if(i){if(i.y1)if(h>p){if(i){if(i.y>=u)return}else i={x:(l-a)/n,y:l};r={x:(u-a)/n,y:u}}else{if(i){if(i.y=s)return}else i={x:o,y:n*o+a};r={x:s,y:n*s+a}}else{if(i){if(i.xAt||y(a-r)>At)&&(s.splice(o,0,new Da((m=i.site,b=c,x=y(n-f)At?{x:f,y:y(e-f)At?{x:y(r-p)At?{x:h,y:y(e-h)At?{x:y(r-d)=r&&u.x<=a&&u.y>=n&&u.y<=o?[[r,o],[a,o],[a,n],[r,n]]:[]).point=t[s]}),e}function s(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/At)*At,y:Math.round(a(t,e)/At)*At,i:e}})}return o.links=function(t){return Na(s(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Na(s(t)).cells.forEach(function(r,n){for(var a,i,o,s,l=r.site,u=r.edges.sort(ka),c=-1,f=u.length,h=u[f-1].edge,d=h.l===l?h.r:h.l;++ci&&(a=e.slice(i,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:Ga(r,n)})),i=Ya.lastIndex;return ig&&(g=l.x),l.y>v&&(v=l.y),u.push(l.x),c.push(l.y);else for(f=0;fg&&(g=x),_>v&&(v=_),u.push(x),c.push(_)}var w=g-d,A=v-p;function k(t,e,r,n,a,i,o,s){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var l=t.x,u=t.y;if(null!=l)if(y(l-r)+y(u-n)<.01)T(t,e,r,n,a,i,o,s);else{var c=t.point;t.x=t.y=t.point=null,T(t,c,l,u,a,i,o,s),T(t,e,r,n,a,i,o,s)}else t.x=r,t.y=n,t.point=e}else T(t,e,r,n,a,i,o,s)}function T(t,e,r,n,a,i,o,s){var l=.5*(a+o),u=.5*(i+s),c=r>=l,f=n>=u,h=f<<1|c;t.leaf=!1,c?a=l:o=l,f?i=u:s=u,k(t=t.nodes[h]||(t.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){k(M,t,+m(t,++f),+b(t,f),d,p,g,v)}}),e,r,n,a,i,o,s)}w>A?v=p+w:g=d+A;var M={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){k(M,t,+m(t,++f),+b(t,f),d,p,g,v)}};if(M.visit=function(t){!function t(e,r,n,a,i,o){if(!e(r,n,a,i,o)){var s=.5*(n+i),l=.5*(a+o),u=r.nodes;u[0]&&t(e,u[0],n,a,s,l),u[1]&&t(e,u[1],s,a,i,l),u[2]&&t(e,u[2],n,l,s,o),u[3]&&t(e,u[3],s,l,i,o)}}(t,M,d,p,g,v)},M.find=function(t){return function(t,e,r,n,a,i,o){var s,l=1/0;return function t(u,c,f,h,d){if(!(c>i||f>o||h=_)<<1|e>=x,A=w+4;w=0&&!(n=t.interpolators[a](e,r)););return n}function Ja(t,e){var r,n=[],a=[],i=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function ii(t){return 1-Math.cos(t*Ct)}function oi(t){return Math.pow(2,10*(t-1))}function si(t){return 1-Math.sqrt(1-t*t)}function li(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ui(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ci(t){var e,r,n,a=[t.a,t.b],i=[t.c,t.d],o=hi(a),s=fi(a,i),l=hi(((e=i)[0]+=(n=-s)*(r=a)[0],e[1]+=n*r[1],e))||0;a[0]*i[1]=0?t.slice(0,n):t,i=n>=0?t.slice(n+1):"in";return a=$a.get(a)||Qa,i=Ka.get(i)||O,e=i(a.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,a=e.c,i=e.l,o=r.h-n,s=r.c-a,l=r.l-i;isNaN(s)&&(s=0,a=isNaN(a)?r.c:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Wt(n+o*t,a+s*t,i+l*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,a=e.s,i=e.l,o=r.h-n,s=r.s-a,l=r.l-i;isNaN(s)&&(s=0,a=isNaN(a)?r.s:a);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return qt(n+o*t,a+s*t,i+l*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,a=e.a,i=e.b,o=r.l-n,s=r.a-a,l=r.b-i;return function(t){return te(n+o*t,a+s*t,i+l*t)+""}},t.interpolateRound=ui,t.transform=function(e){var r=a.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ci(e?e.matrix:di)})(e)},ci.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var di={a:1,b:0,c:0,d:1,e:0,f:0};function pi(t){return t.length?t.pop()+",":""}function gi(e,r){var n=[],a=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push("translate(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,a),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(pi(r)+"rotate(",null,")")-2,x:Ga(t,e)})):e&&r.push(pi(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,a),function(t,e,r,n){t!==e?n.push({i:r.push(pi(r)+"skewX(",null,")")-2,x:Ga(t,e)}):e&&r.push(pi(r)+"skewX("+e+")")}(e.skew,r.skew,n,a),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var a=r.push(pi(r)+"scale(",null,",",null,")");n.push({i:a-4,x:Ga(t[0],e[0])},{i:a-2,x:Ga(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(pi(r)+"scale("+e+")")}(e.scale,r.scale,n,a),e=r=null,function(t){for(var e,r=-1,i=a.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:n=0})):t>0&&(l.start({type:"start",alpha:n=t}),e=ke(s.tick)),s):n},s.start=function(){var t,e,r,n=m.length,l=y.length,c=u[0],p=u[1];for(t=0;t=0;)r.push(a[n])}function Si(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(i=t.children)&&(a=i.length))for(var a,i,o=-1;++o=0;)o.push(c=u[l]),c.parent=i,c.depth=i.depth+1;r&&(i.value=0),i.children=u}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Si(a,function(e){var n,a;t&&(n=e.children)&&n.sort(t),r&&(a=e.parent)&&(a.value+=e.value)}),s}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Ci(t,function(t){t.children&&(t.value=0)}),Si(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var a=e.call(this,t,n);return function t(e,r,n,a){var i=e.children;if(e.x=r,e.y=e.depth*a,e.dx=n,e.dy=a,i&&(o=i.length)){var o,s,l,u=-1;for(n=e.value?n/e.value:0;++us&&(s=n),o.push(n)}for(r=0;ra&&(n=r,a=e);return n}function Vi(t){return t.reduce(qi,0)}function qi(t,e){return t+e[1]}function Gi(t,e){return Xi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Xi(t,e){for(var r=-1,n=+t[0],a=(t[1]-n)/e,i=[];++r<=e;)i[r]=a*r+n;return i}function Wi(e){return[t.min(e),t.max(e)]}function Yi(t,e){return t.value-e.value}function Zi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ji(t,e){t._pack_next=e,e._pack_prev=t}function Qi(t,e){var r=e.x-t.x,n=e.y-t.y,a=t.r+e.r;return.999*a*a>r*r+n*n}function $i(t){if((e=t.children)&&(l=e.length)){var e,r,n,a,i,o,s,l,u=1/0,c=-1/0,f=1/0,h=-1/0;if(e.forEach(Ki),(r=e[0]).x=-r.r,r.y=0,b(r),l>1&&((n=e[1]).x=n.r,n.y=0,b(n),l>2))for(eo(r,n,a=e[2]),b(a),Zi(r,a),r._pack_prev=a,Zi(a,n),n=r._pack_next,i=3;i0)for(o=-1;++o=f[0]&&l<=f[1]&&((s=u[t.bisect(h,l,1,p)-1]).y+=g,s.push(i[o]));return u}return i.value=function(t){return arguments.length?(r=t,i):r},i.range=function(t){return arguments.length?(n=ve(t),i):n},i.bins=function(t){return arguments.length?(a="number"==typeof t?function(e){return Xi(e,t)}:ve(t),i):a},i.frequency=function(t){return arguments.length?(e=!!t,i):e},i},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Yi),n=0,a=[1,1];function i(t,i){var o=r.call(this,t,i),s=o[0],l=a[0],u=a[1],c=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,Si(s,function(t){t.r=+c(t.value)}),Si(s,$i),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/u))/2;Si(s,function(t){t.r+=f}),Si(s,$i),Si(s,function(t){t.r-=f})}return function t(e,r,n,a){var i=e.children;e.x=r+=a*e.x;e.y=n+=a*e.y;e.r*=a;if(i)for(var o=-1,s=i.length;++od.x&&(d=t),t.depth>p.depth&&(p=t)});var g=r(h,d)/2-h.x,v=n[0]/(d.x+r(d,h)/2+g),m=n[1]/(p.depth||1);Ci(c,function(t){t.x=(t.x+g)*v,t.y=t.depth*m})}return u}function o(t){var e=t.children,n=t.parent.children,a=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,a=t.children,i=a.length;for(;--i>=0;)(e=a[i]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;a?(t.z=a.z+r(t._,a._),t.m=t.z-i):t.z=i}else a&&(t.z=a.z+r(t._,a._));t.parent.A=function(t,e,n){if(e){for(var a,i=t,o=t,s=e,l=i.parent.children[0],u=i.m,c=o.m,f=s.m,h=l.m;s=ao(s),i=no(i),s&&i;)l=no(l),(o=ao(o)).a=t,(a=s.z+f-i.z-u+r(s._,i._))>0&&(io(oo(s,t,n),t,a),u+=a,c+=a),f+=s.m,u+=i.m,h+=l.m,c+=o.m;s&&!ao(o)&&(o.t=s,o.m+=f-c),i&&!no(l)&&(l.t=i,l.m+=u-h,n=t)}return n}(t,a,t.parent.A||n[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function l(t){t.x*=n[0],t.y=t.depth*n[1]}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t)?l:null,i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null==(n=t)?null:l,i):a?n:null},Ei(i,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],a=!1;function i(i,o){var s,l=e.call(this,i,o),u=l[0],c=0;Si(u,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=s?c+=r(e,s):0,e.y=0,s=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(u),h=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(u),d=f.x-r(f,h)/2,p=h.x+r(h,f)/2;return Si(u,a?function(t){t.x=(t.x-u.x)*n[0],t.y=(u.y-t.y)*n[1]}:function(t){t.x=(t.x-d)/(p-d)*n[0],t.y=(1-(u.y?t.y/u.y:1))*n[1]}),l}return i.separation=function(t){return arguments.length?(r=t,i):r},i.size=function(t){return arguments.length?(a=null==(n=t),i):a?null:n},i.nodeSize=function(t){return arguments.length?(a=null!=(n=t),i):a?n:null},Ei(i,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,a=[1,1],i=null,o=so,s=!1,l="squarify",u=.5*(1+Math.sqrt(5));function c(t,e){for(var r,n,a=-1,i=t.length;++a0;)s.push(r=u[a-1]),s.area+=r.area,"squarify"!==l||(n=d(s,g))<=h?(u.pop(),h=n):(s.area-=s.pop().area,p(s,g,i,!1),g=Math.min(i.dx,i.dy),s.length=s.area=0,h=1/0);s.length&&(p(s,g,i,!0),s.length=s.area=0),e.forEach(f)}}function h(t){var e=t.children;if(e&&e.length){var r,n=o(t),a=e.slice(),i=[];for(c(a,n.dx*n.dy/t.value),i.area=0;r=a.pop();)i.push(r),i.area+=r.area,null!=r.z&&(p(i,r.z?n.dx:n.dy,n,!a.length),i.length=i.area=0);e.forEach(h)}}function d(t,e){for(var r,n=t.area,a=0,i=1/0,o=-1,s=t.length;++oa&&(a=r));return e*=e,(n*=n)?Math.max(e*a*u/n,n/(e*i*u)):1/0}function p(t,e,r,a){var i,o=-1,s=t.length,l=r.x,u=r.y,c=e?n(t.area/e):0;if(e==r.dx){for((a||c>r.dy)&&(c=r.dy);++or.dx)&&(c=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,s=a?mi:vi;return i=t(e,r,s,n),o=t(r,e,s,Za),l}function l(t){return i(t)}l.invert=function(t){return o(t)};l.domain=function(t){return arguments.length?(e=t.map(Number),s()):e};l.range=function(t){return arguments.length?(r=t,s()):r};l.rangeRound=function(t){return l.range(t).interpolate(ui)};l.clamp=function(t){return arguments.length?(a=t,s()):a};l.interpolate=function(t){return arguments.length?(n=t,s()):n};l.ticks=function(t){return xo(e,t)};l.tickFormat=function(t,r){return _o(e,t,r)};l.nice=function(t){return yo(e,t),s()};l.copy=function(){return t(e,r,n,a)};return s()}([0,1],[0,1],Za,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function Ao(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,a,i){function o(t){return(a?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function s(t){return a?Math.pow(n,t):-Math.pow(n,-t)}function l(t){return r(o(t))}l.invert=function(t){return s(r.invert(t))};l.domain=function(t){return arguments.length?(a=t[0]>=0,r.domain((i=t.map(Number)).map(o)),l):i};l.base=function(t){return arguments.length?(n=+t,r.domain(i.map(o)),l):n};l.nice=function(){var t=ho(i.map(o),a?Math:To);return r.domain(t),i=t.map(s),l};l.ticks=function(){var t=uo(i),e=[],r=t[0],l=t[1],u=Math.floor(o(r)),c=Math.ceil(o(l)),f=n%1?2:n;if(isFinite(c-u)){if(a){for(;u0;h--)e.push(s(u)*h);for(u=0;e[u]l;c--);e=e.slice(u,c)}return e};l.tickFormat=function(e,r){if(!arguments.length)return ko;arguments.length<2?r=ko:"function"!=typeof r&&(r=t.format(r));var a=Math.max(1,n*e/l.ticks().length);return function(t){var e=t/s(Math.round(o(t)));return e*n0?a[t-1]:r[0],tf?0:1;if(u=Et)return l(u,d)+(s?l(s,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,A,k,T,M=0,E=0,C=[];if((m=(+o.apply(this,arguments)||0)/2)&&(v=n===Do?Math.sqrt(s*s+u*u):+n.apply(this,arguments),d||(E*=-1),u&&(E=Pt(v/u*Math.sin(m))),s&&(M=Pt(v/s*Math.sin(m)))),u){y=u*Math.cos(c+E),b=u*Math.sin(c+E),x=u*Math.cos(f-E),_=u*Math.sin(f-E);var S=Math.abs(f-c-2*E)<=Tt?0:1;if(E&&No(y,b,x,_)===d^S){var L=(c+f)/2;y=u*Math.cos(L),b=u*Math.sin(L),x=_=null}}else y=b=0;if(s){w=s*Math.cos(f-M),A=s*Math.sin(f-M),k=s*Math.cos(c+M),T=s*Math.sin(c+M);var O=Math.abs(c-f+2*M)<=Tt?0:1;if(M&&No(w,A,k,T)===1-d^O){var D=(c+f)/2;w=s*Math.cos(D),A=s*Math.sin(D),k=T=null}}else w=A=0;if(h>At&&(p=Math.min(Math.abs(u-s)/2,+r.apply(this,arguments)))>.001){g=s0?0:1}function Bo(t,e,r,n,a){var i=t[0]-e[0],o=t[1]-e[1],s=(a?n:-n)/Math.sqrt(i*i+o*o),l=s*o,u=-s*i,c=t[0]+l,f=t[1]+u,h=e[0]+l,d=e[1]+u,p=(c+h)/2,g=(f+d)/2,v=h-c,m=d-f,y=v*v+m*m,b=r-n,x=c*d-h*f,_=(m<0?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,A=(-x*v-m*_)/y,k=(x*m+v*_)/y,T=(-x*v+m*_)/y,M=w-p,E=A-g,C=k-p,S=T-g;return M*M+E*E>C*C+S*S&&(w=k,A=T),[[w-l,A-u],[w*r/b,A*r/b]]}function jo(t){var e=ea,r=ra,n=Xr,a=Ho,i=a.key,o=.7;function s(i){var s,l=[],u=[],c=-1,f=i.length,h=ve(e),d=ve(r);function p(){l.push("M",a(t(u),o))}for(;++c1&&a.push("H",n[0]);return a.join("")},"step-before":qo,"step-after":Go,basis:Yo,"basis-open":function(t){if(t.length<4)return Ho(t);var e,r=[],n=-1,a=t.length,i=[0],o=[0];for(;++n<3;)e=t[n],i.push(e[0]),o.push(e[1]);r.push(Zo($o,i)+","+Zo($o,o)),--n;for(;++n9&&(a=3*e/Math.sqrt(a),o[s]=a*r,o[s+1]=a*n));s=-1;for(;++s<=l;)a=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),i.push([a||0,o[s]*a||0]);return i}(t))}});function Ho(t){return t.length>1?t.join("L"):t+"Z"}function Vo(t){return t.join("L")+"Z"}function qo(t){for(var e=0,r=t.length,n=t[0],a=[n[0],",",n[1]];++e1){s=e[1],i=t[l],l++,n+="C"+(a[0]+o[0])+","+(a[1]+o[1])+","+(i[0]-s[0])+","+(i[1]-s[1])+","+i[0]+","+i[1];for(var u=2;uTt)+",1 "+e}function l(t,e,r,n){return"Q 0,0 "+n}return i.radius=function(t){return arguments.length?(r=ve(t),i):r},i.source=function(e){return arguments.length?(t=ve(e),i):t},i.target=function(t){return arguments.length?(e=ve(t),i):e},i.startAngle=function(t){return arguments.length?(n=ve(t),i):n},i.endAngle=function(t){return arguments.length?(a=ve(t),i):a},i},t.svg.diagonal=function(){var t=Un,e=Hn,r=as;function n(n,a){var i=t.call(this,n,a),o=e.call(this,n,a),s=(i.y+o.y)/2,l=[i,{x:i.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(r))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=as,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-Ct;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=os,e=is;function r(r,n){return(ls.get(t.call(this,r,n))||ss)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var ls=t.map({circle:ss,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*cs)),r=e*cs;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/us),r=e*us/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/us),r=e*us/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=ls.keys();var us=Math.sqrt(3),cs=Math.tan(30*St);W.transition=function(t){for(var e,r,n=ps||++ms,a=xs(t),i=[],o=gs||{time:Date.now(),ease:ai,delay:0,duration:250},s=-1,l=this.length;++s0;)u[--h].call(t,o);if(i>=1)return f.event&&f.event.end.call(t,t.__data__,e),--c.count?delete c[n]:delete t[r],1}f||(i=a.time,o=ke(function(t){var e=f.delay;if(o.t=e+i,e<=t)return h(t-e);o.c=h},0,i),f=c[n]={tween:new x,time:i,timer:o,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++c.count)}vs.call=W.call,vs.empty=W.empty,vs.node=W.node,vs.size=W.size,t.transition=function(e,r){return e&&e.transition?ps?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vs,vs.select=function(t){var e,r,n,a=this.id,i=this.namespace,o=[];t=Y(t);for(var s=-1,l=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function g(t){t.select(".extent").attr("y",l[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function v(){var f,v,m=this,y=t.select(t.event.target),b=n.of(m,arguments),x=t.select(m),_=y.datum(),w=!/^(n|s)$/.test(_)&&a,A=!/^(e|w)$/.test(_)&&i,k=y.classed("extent"),T=bt(m),M=t.mouse(m),E=t.select(o(m)).on("keydown.brush",function(){32==t.event.keyCode&&(k||(f=null,M[0]-=s[1],M[1]-=l[1],k=2),N())}).on("keyup.brush",function(){32==t.event.keyCode&&2==k&&(M[0]+=s[1],M[1]+=l[1],k=0,N())});if(t.event.changedTouches?E.on("touchmove.brush",L).on("touchend.brush",D):E.on("mousemove.brush",L).on("mouseup.brush",D),x.interrupt().selectAll("*").interrupt(),k)M[0]=s[0]-M[0],M[1]=l[0]-M[1];else if(_){var C=+/w$/.test(_),S=+/^n/.test(_);v=[s[1-C]-M[0],l[1-S]-M[1]],M[0]=s[C],M[1]=l[S]}else t.event.altKey&&(f=M.slice());function L(){var e=t.mouse(m),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),k||(t.event.altKey?(f||(f=[(s[0]+s[1])/2,(l[0]+l[1])/2]),M[0]=s[+(e[0]1?{floor:function(e){for(;s(e=t.floor(e));)e=Rs(e-1);return e},ceil:function(e){for(;s(e=t.ceil(e));)e=Rs(+e+1);return e}}:t))},a.ticks=function(t,e){var r=uo(a.domain()),n=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],Rs(+r[1]+1),e<1?1:e)},a.tickFormat=function(){return n},a.copy=function(){return Ds(e.copy(),r,n)},mo(a,e)}function Rs(t){return new Date(t)}Cs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Os:Ls,Os.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Os.toString=Ls.toString,Re.second=Fe(function(t){return new Pe(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),Re.seconds=Re.second.range,Re.seconds.utc=Re.second.utc.range,Re.minute=Fe(function(t){return new Pe(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),Re.minutes=Re.minute.range,Re.minutes.utc=Re.minute.utc.range,Re.hour=Fe(function(t){var e=t.getTimezoneOffset()/60;return new Pe(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),Re.hours=Re.hour.range,Re.hours.utc=Re.hour.utc.range,Re.month=Fe(function(t){return(t=Re.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),Re.months=Re.month.range,Re.months.utc=Re.month.utc.range;var Ps=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Is=[[Re.second,1],[Re.second,5],[Re.second,15],[Re.second,30],[Re.minute,1],[Re.minute,5],[Re.minute,15],[Re.minute,30],[Re.hour,1],[Re.hour,3],[Re.hour,6],[Re.hour,12],[Re.day,1],[Re.day,2],[Re.week,1],[Re.month,1],[Re.month,3],[Re.year,1]],zs=Cs.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Xr]]),Fs={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(Rs)},floor:O,ceil:O};Is.year=Re.year,Re.scale=function(){return Ds(t.scale.linear(),Is,zs)};var Ns=Is.map(function(t){return[t[0].utc,t[1]]}),Bs=Ss.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Xr]]);function js(t){return JSON.parse(t.responseText)}function Us(t){var e=a.createRange();return e.selectNode(a.body),e.createContextualFragment(t.responseText)}Ns.year=Re.year.utc,Re.scale.utc=function(){return Ds(t.scale.linear(),Ns,Bs)},t.text=me(function(t){return t.responseText}),t.json=function(t,e){return ye(t,"application/json",js,e)},t.html=function(t,e){return ye(t,"text/html",Us,e)},t.xml=me(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],86:[function(t,e,r){e.exports=function(){for(var t=0;ts*l){var d=(h-f)/s;i[c]=1e3*d}}return i}function o(t){for(var e=[],r=t[0];r<=t[1];r++)for(var n=String.fromCharCode(r),a=t[0];a>>31},e.exports.exponent=function(t){return(e.exports.hi(t)<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),a=1048575&n;return 2146435072&n&&(a+=1<<20),[r,a]},e.exports.denormalized=function(t){return!(2146435072&e.exports.hi(t))}}).call(this,t("buffer").Buffer)},{buffer:51}],89:[function(t,e,r){var n=t("abs-svg-path"),a=t("normalize-svg-path"),i={M:"moveTo",C:"bezierCurveTo"};e.exports=function(t,e){t.beginPath(),a(n(e)).forEach(function(e){var r=e[0],n=e.slice(1);t[i[r]].apply(t,n)}),t.closePath()}},{"abs-svg-path":11,"normalize-svg-path":222}],90:[function(t,e,r){e.exports=function(t){switch(t){case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"uint8":return Uint8Array;case"uint16":return Uint16Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;case"array":return Array;case"uint8_clamped":return Uint8ClampedArray}}},{}],91:[function(t,e,r){"use strict";e.exports=function(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return function(t,e){var r,n;for(r=new Array(t),n=0;n80*r){n=l=t[0],s=u=t[1];for(var x=r;xl&&(l=c),d>u&&(u=d);g=0!==(g=Math.max(l-n,u-s))?1/g:0}return o(y,b,r,n,s,g),b}function a(t,e,r,n,a){var i,o;if(a===T(t,e,r,n)>0)for(i=e;i=e;i-=n)o=w(i,t[i],t[i+1],o);return o&&y(o,o.next)&&(A(o),o=o.next),o}function i(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!y(n,n.next)&&0!==m(n.prev,n,n.next))n=n.next;else{if(A(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function o(t,e,r,n,a,f,h){if(t){!h&&f&&function(t,e,r,n){var a=t;do{null===a.z&&(a.z=d(a.x,a.y,e,r,n)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next}while(a!==t);a.prevZ.nextZ=null,a.prevZ=null,function(t){var e,r,n,a,i,o,s,l,u=1;do{for(r=t,t=null,i=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(a=r,r=r.nextZ,s--):(a=n,n=n.nextZ,l--),i?i.nextZ=a:t=a,a.prevZ=i,i=a;r=n}i.nextZ=null,u*=2}while(o>1)}(a)}(t,n,a,f);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,f?l(t,n,a,f):s(t))e.push(p.i/r),e.push(t.i/r),e.push(g.i/r),A(t),t=g.next,v=g.next;else if((t=g)===v){h?1===h?o(t=u(t,e,r),e,r,n,a,f,2):2===h&&c(t,e,r,n,a,f):o(i(t),e,r,n,a,f,1);break}}}function s(t){var e=t.prev,r=t,n=t.next;if(m(e,r,n)>=0)return!1;for(var a=t.next.next;a!==t.prev;){if(g(e.x,e.y,r.x,r.y,n.x,n.y,a.x,a.y)&&m(a.prev,a,a.next)>=0)return!1;a=a.next}return!0}function l(t,e,r,n){var a=t.prev,i=t,o=t.next;if(m(a,i,o)>=0)return!1;for(var s=a.xi.x?a.x>o.x?a.x:o.x:i.x>o.x?i.x:o.x,c=a.y>i.y?a.y>o.y?a.y:o.y:i.y>o.y?i.y:o.y,f=d(s,l,e,r,n),h=d(u,c,e,r,n),p=t.prevZ,v=t.nextZ;p&&p.z>=f&&v&&v.z<=h;){if(p!==t.prev&&p!==t.next&&g(a.x,a.y,i.x,i.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,v!==t.prev&&v!==t.next&&g(a.x,a.y,i.x,i.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;p&&p.z>=f;){if(p!==t.prev&&p!==t.next&&g(a.x,a.y,i.x,i.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;v&&v.z<=h;){if(v!==t.prev&&v!==t.next&&g(a.x,a.y,i.x,i.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function u(t,e,r){var n=t;do{var a=n.prev,i=n.next.next;!y(a,i)&&b(a,n,n.next,i)&&x(a,i)&&x(i,a)&&(e.push(a.i/r),e.push(n.i/r),e.push(i.i/r),A(n),A(n.next),n=t=i),n=n.next}while(n!==t);return n}function c(t,e,r,n,a,s){var l=t;do{for(var u=l.next.next;u!==l.prev;){if(l.i!==u.i&&v(l,u)){var c=_(l,u);return l=i(l,l.next),c=i(c,c.next),o(l,e,r,n,a,s),void o(c,e,r,n,a,s)}u=u.next}l=l.next}while(l!==t)}function f(t,e){return t.x-e.x}function h(t,e){if(e=function(t,e){var r,n=e,a=t.x,i=t.y,o=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){var s=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=a&&s>o){if(o=s,s===a){if(i===n.y)return n;if(i===n.next.y)return n.next}r=n.x=n.x&&n.x>=c&&a!==n.x&&g(ir.x)&&x(n,t)&&(r=n,h=l),n=n.next;return r}(t,e)){var r=_(e,t);i(r,r.next)}}function d(t,e,r,n,a){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*a)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*a)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,r=t;do{e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(i-s)-(a-o)*(n-s)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&b(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&x(t,e)&&x(e,t)&&function(t,e){var r=t,n=!1,a=(t.x+e.x)/2,i=(t.y+e.y)/2;do{r.y>i!=r.next.y>i&&r.next.y!==r.y&&a<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)}function m(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function y(t,e){return t.x===e.x&&t.y===e.y}function b(t,e,r,n){return!!(y(t,e)&&y(r,n)||y(t,n)&&y(r,e))||m(t,e,r)>0!=m(t,e,n)>0&&m(r,n,t)>0!=m(r,n,e)>0}function x(t,e){return m(t.prev,t,t.next)<0?m(t,e,t.next)>=0&&m(t,t.prev,e)>=0:m(t,e,t.prev)<0||m(t,t.next,e)<0}function _(t,e){var r=new k(t.i,t.x,t.y),n=new k(e.i,e.x,e.y),a=t.next,i=e.prev;return t.next=e,e.prev=t,r.next=a,a.prev=r,n.next=r,r.prev=n,i.next=n,n.prev=i,n}function w(t,e,r,n){var a=new k(t,e,r);return n?(a.next=n.next,a.prev=n,n.next.prev=a,n.next=a):(a.prev=a,a.next=a),a}function A(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function k(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T(t,e,r,n){for(var a=0,i=e,o=r-n;i0&&(n+=t[a-1].length,r.holes.push(n))}return r}},{}],93:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if("number"!=typeof e){e=0;for(var a=0;a=55296&&y<=56319&&(w+=t[++r]),w=A?h.call(A,k,w,g):w,e?(d.value=w,p(v,g,d)):v[g]=w,++g;m=g}if(void 0===m)for(m=o(t.length),e&&(v=new e(m)),r=0;r0?1:-1}},{}],104:[function(t,e,r){"use strict";var n=t("../math/sign"),a=Math.abs,i=Math.floor;e.exports=function(t){return isNaN(t)?0:0!==(t=Number(t))&&isFinite(t)?n(t)*i(a(t)):t}},{"../math/sign":101}],105:[function(t,e,r){"use strict";var n=t("./to-integer"),a=Math.max;e.exports=function(t){return a(0,n(t))}},{"./to-integer":104}],106:[function(t,e,r){"use strict";var n=t("./valid-callable"),a=t("./valid-value"),i=Function.prototype.bind,o=Function.prototype.call,s=Object.keys,l=Object.prototype.propertyIsEnumerable;e.exports=function(t,e){return function(r,u){var c,f=arguments[2],h=arguments[3];return r=Object(a(r)),n(u),c=s(r),h&&c.sort("function"==typeof h?i.call(h,r):void 0),"function"!=typeof t&&(t=c[t]),o.call(t,c,function(t,n){return l.call(r,t)?o.call(u,f,r[t],t,r,n):e})}}},{"./valid-callable":124,"./valid-value":126}],107:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Object.assign:t("./shim")},{"./is-implemented":108,"./shim":109}],108:[function(t,e,r){"use strict";e.exports=function(){var t,e=Object.assign;return"function"==typeof e&&(e(t={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},{}],109:[function(t,e,r){"use strict";var n=t("../keys"),a=t("../valid-value"),i=Math.max;e.exports=function(t,e){var r,o,s,l=i(arguments.length,2);for(t=Object(a(t)),s=function(n){try{t[n]=e[n]}catch(t){r||(r=t)}},o=1;o-1}},{}],130:[function(t,e,r){"use strict";var n=Object.prototype.toString,a=n.call("");e.exports=function(t){return"string"==typeof t||t&&"object"==typeof t&&(t instanceof String||n.call(t)===a)||!1}},{}],131:[function(t,e,r){"use strict";var n=Object.create(null),a=Math.random;e.exports=function(){var t;do{t=a().toString(36).slice(2)}while(n[t]);return t}},{}],132:[function(t,e,r){"use strict";var n,a=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("es6-symbol"),l=t("./"),u=Object.defineProperty;n=e.exports=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");l.call(this,t),e=e?i.call(e,"key+value")?"key+value":i.call(e,"key")?"key":"value":"value",u(this,"__kind__",o("",e))},a&&a(n,l),delete n.prototype.constructor,n.prototype=Object.create(l.prototype,{_resolve:o(function(t){return"value"===this.__kind__?this.__list__[t]:"key+value"===this.__kind__?[t,this.__list__[t]]:t})}),u(n.prototype,s.toStringTag,o("c","Array Iterator"))},{"./":135,d:84,"es5-ext/object/set-prototype-of":121,"es5-ext/string/#/contains":127,"es6-symbol":140}],133:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),a=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,l=Function.prototype.call,u=Array.prototype.some;e.exports=function(t,e){var r,c,f,h,d,p,g,v,m=arguments[2];if(s(t)||n(t)?r="array":i(t)?r="string":t=o(t),a(e),f=function(){h=!0},"array"!==r)if("string"!==r)for(c=t.next();!c.done;){if(l.call(e,m,c.value,f),h)return;c=t.next()}else for(p=t.length,d=0;d=55296&&v<=56319&&(g+=t[++d]),l.call(e,m,g,f),!h);++d);else u.call(t,function(t){return l.call(e,m,t,f),h})}},{"./get":134,"es5-ext/function/is-arguments":98,"es5-ext/object/valid-callable":124,"es5-ext/string/is-string":130}],134:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),a=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),l=t("es6-symbol").iterator;e.exports=function(t){return"function"==typeof s(t)[l]?t[l]():n(t)?new i(t):a(t)?new o(t):new i(t)}},{"./array":132,"./string":137,"./valid-iterable":138,"es5-ext/function/is-arguments":98,"es5-ext/string/is-string":130,"es6-symbol":140}],135:[function(t,e,r){"use strict";var n,a=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),l=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),f=Object.defineProperty,h=Object.defineProperties;e.exports=n=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");h(this,{__list__:l("w",s(t)),__context__:l("w",e),__nextIndex__:l("w",0)}),e&&(o(e.on),e.on("_add",this._onAdd),e.on("_delete",this._onDelete),e.on("_clear",this._onClear))},delete n.prototype.constructor,h(n.prototype,i({_next:l(function(){var t;if(this.__list__)return this.__redo__&&void 0!==(t=this.__redo__.shift())?t:this.__nextIndex__=this.__nextIndex__||(++this.__nextIndex__,this.__redo__?(this.__redo__.forEach(function(e,r){e>=t&&(this.__redo__[r]=++e)},this),this.__redo__.push(t)):f(this,"__redo__",l("c",[t])))}),_onDelete:l(function(t){var e;t>=this.__nextIndex__||(--this.__nextIndex__,this.__redo__&&(-1!==(e=this.__redo__.indexOf(t))&&this.__redo__.splice(e,1),this.__redo__.forEach(function(e,r){e>t&&(this.__redo__[r]=--e)},this)))}),_onClear:l(function(){this.__redo__&&a.call(this.__redo__),this.__nextIndex__=0})}))),f(n.prototype,c.iterator,l(function(){return this}))},{d:84,"d/auto-bind":83,"es5-ext/array/#/clear":94,"es5-ext/object/assign":107,"es5-ext/object/valid-callable":124,"es5-ext/object/valid-value":126,"es6-symbol":140}],136:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),a=t("es5-ext/object/is-value"),i=t("es5-ext/string/is-string"),o=t("es6-symbol").iterator,s=Array.isArray;e.exports=function(t){return!!a(t)&&(!!s(t)||(!!i(t)||(!!n(t)||"function"==typeof t[o])))}},{"es5-ext/function/is-arguments":98,"es5-ext/object/is-value":115,"es5-ext/string/is-string":130,"es6-symbol":140}],137:[function(t,e,r){"use strict";var n,a=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("es6-symbol"),s=t("./"),l=Object.defineProperty;n=e.exports=function(t){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");t=String(t),s.call(this,t),l(this,"__length__",i("",t.length))},a&&a(n,s),delete n.prototype.constructor,n.prototype=Object.create(s.prototype,{_next:i(function(){if(this.__list__)return this.__nextIndex__=55296&&e<=56319?r+this.__list__[this.__nextIndex__++]:r})}),l(n.prototype,o.toStringTag,i("c","String Iterator"))},{"./":135,d:84,"es5-ext/object/set-prototype-of":121,"es6-symbol":140}],138:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":136}],139:[function(t,e,r){(function(n,a){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,o=void 0,s=void 0,l=function(t,e){g[i]=t,g[i+1]=e,2===(i+=2)&&(s?s(v):_())};var u="undefined"!=typeof window?window:void 0,c=u||{},f=c.MutationObserver||c.WebKitMutationObserver,h="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),d="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function p(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;te[0]-o[0]/2&&(h=o[0]/2,d+=o[1]);return r}},{"css-font/stringify":76}],152:[function(t,e,r){"use strict";function n(t,e){e||(e={}),("string"==typeof t||Array.isArray(t))&&(e.family=t);var r=Array.isArray(e.family)?e.family.join(", "):e.family;if(!r)throw Error("`family` must be defined");var s=e.size||e.fontSize||e.em||48,l=e.weight||e.fontWeight||"",u=(t=[e.style||e.fontStyle||"",l,s].join(" ")+"px "+r,e.origin||"top");if(n.cache[r]&&s<=n.cache[r].em)return a(n.cache[r],u);var c=e.canvas||n.canvas,f=c.getContext("2d"),h={upper:void 0!==e.upper?e.upper:"H",lower:void 0!==e.lower?e.lower:"x",descent:void 0!==e.descent?e.descent:"p",ascent:void 0!==e.ascent?e.ascent:"h",tittle:void 0!==e.tittle?e.tittle:"i",overshoot:void 0!==e.overshoot?e.overshoot:"O"},d=Math.ceil(1.5*s);c.height=d,c.width=.5*d,f.font=t;var p={top:0};f.clearRect(0,0,d,d),f.textBaseline="top",f.fillStyle="black",f.fillText("H",0,0);var g=i(f.getImageData(0,0,d,d));f.clearRect(0,0,d,d),f.textBaseline="bottom",f.fillText("H",0,d);var v=i(f.getImageData(0,0,d,d));p.lineHeight=p.bottom=d-v+g,f.clearRect(0,0,d,d),f.textBaseline="alphabetic",f.fillText("H",0,d);var m=d-i(f.getImageData(0,0,d,d))-1+g;p.baseline=p.alphabetic=m,f.clearRect(0,0,d,d),f.textBaseline="middle",f.fillText("H",0,.5*d);var y=i(f.getImageData(0,0,d,d));p.median=p.middle=d-y-1+g-.5*d,f.clearRect(0,0,d,d),f.textBaseline="hanging",f.fillText("H",0,.5*d);var b=i(f.getImageData(0,0,d,d));p.hanging=d-b-1+g-.5*d,f.clearRect(0,0,d,d),f.textBaseline="ideographic",f.fillText("H",0,d);var x=i(f.getImageData(0,0,d,d));if(p.ideographic=d-x-1+g,h.upper&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.upper,0,0),p.upper=i(f.getImageData(0,0,d,d)),p.capHeight=p.baseline-p.upper),h.lower&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.lower,0,0),p.lower=i(f.getImageData(0,0,d,d)),p.xHeight=p.baseline-p.lower),h.tittle&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.tittle,0,0),p.tittle=i(f.getImageData(0,0,d,d))),h.ascent&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.ascent,0,0),p.ascent=i(f.getImageData(0,0,d,d))),h.descent&&(f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.descent,0,0),p.descent=o(f.getImageData(0,0,d,d))),h.overshoot){f.clearRect(0,0,d,d),f.textBaseline="top",f.fillText(h.overshoot,0,0);var _=o(f.getImageData(0,0,d,d));p.overshoot=_-m}for(var w in p)p[w]/=s;return p.em=s,n.cache[r]=p,a(p,u)}function a(t,e){var r={};for(var n in"string"==typeof e&&(e=t[e]),t)"em"!==n&&(r[n]=t[n]-e);return r}function i(t){for(var e=t.height,r=t.data,n=3;n0;n-=4)if(0!==r[n])return Math.floor(.25*(n-3)/e)}e.exports=n,n.canvas=document.createElement("canvas"),n.cache={}},{}],153:[function(t,e,r){"use strict";e.exports=function(t){return new u(t||p,null)};var n=0,a=1;function i(t,e,r,n,a,i){this._color=t,this.key=e,this.value=r,this.left=n,this.right=a,this._count=i}function o(t){return new i(t._color,t.key,t.value,t.left,t.right,t._count)}function s(t,e){return new i(t,e.key,e.value,e.left,e.right,e._count)}function l(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function u(t,e){this._compare=t,this.root=e}var c=u.prototype;function f(t,e){this.tree=t,this._stack=e}Object.defineProperty(c,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(c,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(c,"length",{get:function(){return this.root?this.root._count:0}}),c.insert=function(t,e){for(var r=this._compare,o=this.root,c=[],f=[];o;){var h=r(t,o.key);c.push(o),f.push(h),o=h<=0?o.left:o.right}c.push(new i(n,t,e,null,null,1));for(var d=c.length-2;d>=0;--d){o=c[d];f[d]<=0?c[d]=new i(o._color,o.key,o.value,c[d+1],o.right,o._count+1):c[d]=new i(o._color,o.key,o.value,o.left,c[d+1],o._count+1)}for(d=c.length-1;d>1;--d){var p=c[d-1];o=c[d];if(p._color===a||o._color===a)break;var g=c[d-2];if(g.left===p)if(p.left===o){if(!(v=g.right)||v._color!==n){if(g._color=n,g.left=p.right,p._color=a,p.right=g,c[d-2]=p,c[d-1]=o,l(g),l(p),d>=3)(m=c[d-3]).left===g?m.left=p:m.right=p;break}p._color=a,g.right=s(a,v),g._color=n,d-=1}else{if(!(v=g.right)||v._color!==n){if(p.right=o.left,g._color=n,g.left=o.right,o._color=a,o.left=p,o.right=g,c[d-2]=o,c[d-1]=p,l(g),l(p),l(o),d>=3)(m=c[d-3]).left===g?m.left=o:m.right=o;break}p._color=a,g.right=s(a,v),g._color=n,d-=1}else if(p.right===o){if(!(v=g.left)||v._color!==n){if(g._color=n,g.right=p.left,p._color=a,p.left=g,c[d-2]=p,c[d-1]=o,l(g),l(p),d>=3)(m=c[d-3]).right===g?m.right=p:m.left=p;break}p._color=a,g.left=s(a,v),g._color=n,d-=1}else{var v;if(!(v=g.left)||v._color!==n){var m;if(p.left=o.right,g._color=n,g.right=o.left,o._color=a,o.right=p,o.left=g,c[d-2]=o,c[d-1]=p,l(g),l(p),l(o),d>=3)(m=c[d-3]).right===g?m.right=o:m.left=o;break}p._color=a,g.left=s(a,v),g._color=n,d-=1}}return c[0]._color=a,new u(r,c[0])},c.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return function t(e,r){var n;if(r.left&&(n=t(e,r.left)))return n;return(n=e(r.key,r.value))||(r.right?t(e,r.right):void 0)}(t,this.root);case 2:return function t(e,r,n,a){if(r(e,a.key)<=0){var i;if(a.left&&(i=t(e,r,n,a.left)))return i;if(i=n(a.key,a.value))return i}if(a.right)return t(e,r,n,a.right)}(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return function t(e,r,n,a,i){var o,s=n(e,i.key),l=n(r,i.key);if(s<=0){if(i.left&&(o=t(e,r,n,a,i.left)))return o;if(l>0&&(o=a(i.key,i.value)))return o}if(l>0&&i.right)return t(e,r,n,a,i.right)}(e,r,this._compare,t,this.root)}},Object.defineProperty(c,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(c,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),c.at=function(t){if(t<0)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},c.ge=function(t){for(var e=this._compare,r=this.root,n=[],a=0;r;){var i=e(t,r.key);n.push(r),i<=0&&(a=n.length),r=i<=0?r.left:r.right}return n.length=a,new f(this,n)},c.gt=function(t){for(var e=this._compare,r=this.root,n=[],a=0;r;){var i=e(t,r.key);n.push(r),i<0&&(a=n.length),r=i<0?r.left:r.right}return n.length=a,new f(this,n)},c.lt=function(t){for(var e=this._compare,r=this.root,n=[],a=0;r;){var i=e(t,r.key);n.push(r),i>0&&(a=n.length),r=i<=0?r.left:r.right}return n.length=a,new f(this,n)},c.le=function(t){for(var e=this._compare,r=this.root,n=[],a=0;r;){var i=e(t,r.key);n.push(r),i>=0&&(a=n.length),r=i<0?r.left:r.right}return n.length=a,new f(this,n)},c.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var a=e(t,r.key);if(n.push(r),0===a)return new f(this,n);r=a<=0?r.left:r.right}return new f(this,[])},c.remove=function(t){var e=this.find(t);return e?e.remove():this},c.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=n<=0?r.left:r.right}};var h=f.prototype;function d(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function p(t,e){return te?1:0}Object.defineProperty(h,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(h,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),h.clone=function(){return new f(this.tree,this._stack.slice())},h.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new i(r._color,r.key,r.value,r.left,r.right,r._count);for(var c=t.length-2;c>=0;--c){(r=t[c]).left===t[c+1]?e[c]=new i(r._color,r.key,r.value,e[c+1],r.right,r._count):e[c]=new i(r._color,r.key,r.value,r.left,e[c+1],r._count)}if((r=e[e.length-1]).left&&r.right){var f=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var h=e[f-1];e.push(new i(r._color,h.key,h.value,r.left,r.right,r._count)),e[f-1].key=r.key,e[f-1].value=r.value;for(c=e.length-2;c>=f;--c)r=e[c],e[c]=new i(r._color,r.key,r.value,r.left,e[c+1],r._count);e[f-1].left=e[f]}if((r=e[e.length-1])._color===n){var p=e[e.length-2];p.left===r?p.left=null:p.right===r&&(p.right=null),e.pop();for(c=0;c=0;--c){if(e=t[c],0===c)return void(e._color=a);if((r=t[c-1]).left===e){if((i=r.right).right&&i.right._color===n)return u=(i=r.right=o(i)).right=o(i.right),r.right=i.left,i.left=r,i.right=u,i._color=r._color,e._color=a,r._color=a,u._color=a,l(r),l(i),c>1&&((f=t[c-2]).left===r?f.left=i:f.right=i),void(t[c-1]=i);if(i.left&&i.left._color===n)return u=(i=r.right=o(i)).left=o(i.left),r.right=u.left,i.left=u.right,u.left=r,u.right=i,u._color=r._color,r._color=a,i._color=a,e._color=a,l(r),l(i),l(u),c>1&&((f=t[c-2]).left===r?f.left=u:f.right=u),void(t[c-1]=u);if(i._color===a){if(r._color===n)return r._color=a,void(r.right=s(n,i));r.right=s(n,i);continue}i=o(i),r.right=i.left,i.left=r,i._color=r._color,r._color=n,l(r),l(i),c>1&&((f=t[c-2]).left===r?f.left=i:f.right=i),t[c-1]=i,t[c]=r,c+11&&((f=t[c-2]).right===r?f.right=i:f.left=i),void(t[c-1]=i);if(i.right&&i.right._color===n)return u=(i=r.left=o(i)).right=o(i.right),r.left=u.right,i.right=u.left,u.right=r,u.left=i,u._color=r._color,r._color=a,i._color=a,e._color=a,l(r),l(i),l(u),c>1&&((f=t[c-2]).right===r?f.right=u:f.left=u),void(t[c-1]=u);if(i._color===a){if(r._color===n)return r._color=a,void(r.left=s(n,i));r.left=s(n,i);continue}var f;i=o(i),r.left=i.right,i.right=r,i._color=r._color,r._color=n,l(r),l(i),c>1&&((f=t[c-2]).right===r?f.right=i:f.left=i),t[c-1]=i,t[c]=r,c+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(h,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(h,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),h.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),h.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),n=e[e.length-1];r[r.length-1]=new i(n._color,n.key,t,n.left,n.right,n._count);for(var a=e.length-2;a>=0;--a)(n=e[a]).left===e[a+1]?r[a]=new i(n._color,n.key,n.value,r[a+1],n.right,n._count):r[a]=new i(n._color,n.key,n.value,n.left,r[a+1],n._count);return new u(this.tree._compare,r[0])},h.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],154:[function(t,e,r){var n=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],a=607/128,i=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function o(t){if(t<0)return Number("0/0");for(var e=i[0],r=i.length-1;r>0;--r)e+=i[r]/(t+r);var n=t+a+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}e.exports=function t(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*t(1-e));if(e>100)return Math.exp(o(e));e-=1;for(var r=n[0],a=1;a<9;a++)r+=n[a]/(e+a);var i=e+7+.5;return Math.sqrt(2*Math.PI)*Math.pow(i,e+.5)*Math.exp(-i)*r},e.exports.log=o},{}],155:[function(t,e,r){e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("must specify type string");if(e=e||{},"undefined"==typeof document&&!e.canvas)return null;var r=e.canvas||document.createElement("canvas");"number"==typeof e.width&&(r.width=e.width);"number"==typeof e.height&&(r.height=e.height);var n,a=e;try{var i=[t];0===t.indexOf("webgl")&&i.push("experimental-"+t);for(var o=0;or)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,i,a),r}function c(t,e){for(var r=n.malloc(t.length,e),a=t.length,i=0;i=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=u(this.gl,this.type,this.length,this.usage,t.data,e):this.length=u(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=n.malloc(t.size,r),l=i(s,t.shape);a.assign(l,t),this.length=u(this.gl,this.type,this.length,this.usage,e<0?s:s.subarray(0,t.size),e),n.free(s)}}else if(Array.isArray(t)){var f;f=this.type===this.gl.ELEMENT_ARRAY_BUFFER?c(t,"uint16"):c(t,"float32"),this.length=u(this.gl,this.type,this.length,this.usage,e<0?f:f.subarray(0,t.length),e),n.free(f)}else if("object"==typeof t&&"number"==typeof t.length)this.length=u(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");(t|=0)<=0&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=function(t,e,r,n){if(r=r||t.ARRAY_BUFFER,n=n||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(n!==t.DYNAMIC_DRAW&&n!==t.STATIC_DRAW&&n!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var a=t.createBuffer(),i=new s(t,r,a,0,n);return i.update(e),i}},{ndarray:220,"ndarray-ops":219,"typedarray-pool":289}],157:[function(t,e,r){e.exports={0:"NONE",1:"ONE",2:"LINE_LOOP",3:"LINE_STRIP",4:"TRIANGLES",5:"TRIANGLE_STRIP",6:"TRIANGLE_FAN",256:"DEPTH_BUFFER_BIT",512:"NEVER",513:"LESS",514:"EQUAL",515:"LEQUAL",516:"GREATER",517:"NOTEQUAL",518:"GEQUAL",519:"ALWAYS",768:"SRC_COLOR",769:"ONE_MINUS_SRC_COLOR",770:"SRC_ALPHA",771:"ONE_MINUS_SRC_ALPHA",772:"DST_ALPHA",773:"ONE_MINUS_DST_ALPHA",774:"DST_COLOR",775:"ONE_MINUS_DST_COLOR",776:"SRC_ALPHA_SATURATE",1024:"STENCIL_BUFFER_BIT",1028:"FRONT",1029:"BACK",1032:"FRONT_AND_BACK",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",2304:"CW",2305:"CCW",2849:"LINE_WIDTH",2884:"CULL_FACE",2885:"CULL_FACE_MODE",2886:"FRONT_FACE",2928:"DEPTH_RANGE",2929:"DEPTH_TEST",2930:"DEPTH_WRITEMASK",2931:"DEPTH_CLEAR_VALUE",2932:"DEPTH_FUNC",2960:"STENCIL_TEST",2961:"STENCIL_CLEAR_VALUE",2962:"STENCIL_FUNC",2963:"STENCIL_VALUE_MASK",2964:"STENCIL_FAIL",2965:"STENCIL_PASS_DEPTH_FAIL",2966:"STENCIL_PASS_DEPTH_PASS",2967:"STENCIL_REF",2968:"STENCIL_WRITEMASK",2978:"VIEWPORT",3024:"DITHER",3042:"BLEND",3088:"SCISSOR_BOX",3089:"SCISSOR_TEST",3106:"COLOR_CLEAR_VALUE",3107:"COLOR_WRITEMASK",3317:"UNPACK_ALIGNMENT",3333:"PACK_ALIGNMENT",3379:"MAX_TEXTURE_SIZE",3386:"MAX_VIEWPORT_DIMS",3408:"SUBPIXEL_BITS",3410:"RED_BITS",3411:"GREEN_BITS",3412:"BLUE_BITS",3413:"ALPHA_BITS",3414:"DEPTH_BITS",3415:"STENCIL_BITS",3553:"TEXTURE_2D",4352:"DONT_CARE",4353:"FASTEST",4354:"NICEST",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT",5386:"INVERT",5890:"TEXTURE",6401:"STENCIL_INDEX",6402:"DEPTH_COMPONENT",6406:"ALPHA",6407:"RGB",6408:"RGBA",6409:"LUMINANCE",6410:"LUMINANCE_ALPHA",7680:"KEEP",7681:"REPLACE",7682:"INCR",7683:"DECR",7936:"VENDOR",7937:"RENDERER",7938:"VERSION",9728:"NEAREST",9729:"LINEAR",9984:"NEAREST_MIPMAP_NEAREST",9985:"LINEAR_MIPMAP_NEAREST",9986:"NEAREST_MIPMAP_LINEAR",9987:"LINEAR_MIPMAP_LINEAR",10240:"TEXTURE_MAG_FILTER",10241:"TEXTURE_MIN_FILTER",10242:"TEXTURE_WRAP_S",10243:"TEXTURE_WRAP_T",10497:"REPEAT",10752:"POLYGON_OFFSET_UNITS",16384:"COLOR_BUFFER_BIT",32769:"CONSTANT_COLOR",32770:"ONE_MINUS_CONSTANT_COLOR",32771:"CONSTANT_ALPHA",32772:"ONE_MINUS_CONSTANT_ALPHA",32773:"BLEND_COLOR",32774:"FUNC_ADD",32777:"BLEND_EQUATION_RGB",32778:"FUNC_SUBTRACT",32779:"FUNC_REVERSE_SUBTRACT",32819:"UNSIGNED_SHORT_4_4_4_4",32820:"UNSIGNED_SHORT_5_5_5_1",32823:"POLYGON_OFFSET_FILL",32824:"POLYGON_OFFSET_FACTOR",32854:"RGBA4",32855:"RGB5_A1",32873:"TEXTURE_BINDING_2D",32926:"SAMPLE_ALPHA_TO_COVERAGE",32928:"SAMPLE_COVERAGE",32936:"SAMPLE_BUFFERS",32937:"SAMPLES",32938:"SAMPLE_COVERAGE_VALUE",32939:"SAMPLE_COVERAGE_INVERT",32968:"BLEND_DST_RGB",32969:"BLEND_SRC_RGB",32970:"BLEND_DST_ALPHA",32971:"BLEND_SRC_ALPHA",33071:"CLAMP_TO_EDGE",33170:"GENERATE_MIPMAP_HINT",33189:"DEPTH_COMPONENT16",33306:"DEPTH_STENCIL_ATTACHMENT",33635:"UNSIGNED_SHORT_5_6_5",33648:"MIRRORED_REPEAT",33901:"ALIASED_POINT_SIZE_RANGE",33902:"ALIASED_LINE_WIDTH_RANGE",33984:"TEXTURE0",33985:"TEXTURE1",33986:"TEXTURE2",33987:"TEXTURE3",33988:"TEXTURE4",33989:"TEXTURE5",33990:"TEXTURE6",33991:"TEXTURE7",33992:"TEXTURE8",33993:"TEXTURE9",33994:"TEXTURE10",33995:"TEXTURE11",33996:"TEXTURE12",33997:"TEXTURE13",33998:"TEXTURE14",33999:"TEXTURE15",34000:"TEXTURE16",34001:"TEXTURE17",34002:"TEXTURE18",34003:"TEXTURE19",34004:"TEXTURE20",34005:"TEXTURE21",34006:"TEXTURE22",34007:"TEXTURE23",34008:"TEXTURE24",34009:"TEXTURE25",34010:"TEXTURE26",34011:"TEXTURE27",34012:"TEXTURE28",34013:"TEXTURE29",34014:"TEXTURE30",34015:"TEXTURE31",34016:"ACTIVE_TEXTURE",34024:"MAX_RENDERBUFFER_SIZE",34041:"DEPTH_STENCIL",34055:"INCR_WRAP",34056:"DECR_WRAP",34067:"TEXTURE_CUBE_MAP",34068:"TEXTURE_BINDING_CUBE_MAP",34069:"TEXTURE_CUBE_MAP_POSITIVE_X",34070:"TEXTURE_CUBE_MAP_NEGATIVE_X",34071:"TEXTURE_CUBE_MAP_POSITIVE_Y",34072:"TEXTURE_CUBE_MAP_NEGATIVE_Y",34073:"TEXTURE_CUBE_MAP_POSITIVE_Z",34074:"TEXTURE_CUBE_MAP_NEGATIVE_Z",34076:"MAX_CUBE_MAP_TEXTURE_SIZE",34338:"VERTEX_ATTRIB_ARRAY_ENABLED",34339:"VERTEX_ATTRIB_ARRAY_SIZE",34340:"VERTEX_ATTRIB_ARRAY_STRIDE",34341:"VERTEX_ATTRIB_ARRAY_TYPE",34342:"CURRENT_VERTEX_ATTRIB",34373:"VERTEX_ATTRIB_ARRAY_POINTER",34466:"NUM_COMPRESSED_TEXTURE_FORMATS",34467:"COMPRESSED_TEXTURE_FORMATS",34660:"BUFFER_SIZE",34661:"BUFFER_USAGE",34816:"STENCIL_BACK_FUNC",34817:"STENCIL_BACK_FAIL",34818:"STENCIL_BACK_PASS_DEPTH_FAIL",34819:"STENCIL_BACK_PASS_DEPTH_PASS",34877:"BLEND_EQUATION_ALPHA",34921:"MAX_VERTEX_ATTRIBS",34922:"VERTEX_ATTRIB_ARRAY_NORMALIZED",34930:"MAX_TEXTURE_IMAGE_UNITS",34962:"ARRAY_BUFFER",34963:"ELEMENT_ARRAY_BUFFER",34964:"ARRAY_BUFFER_BINDING",34965:"ELEMENT_ARRAY_BUFFER_BINDING",34975:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",35040:"STREAM_DRAW",35044:"STATIC_DRAW",35048:"DYNAMIC_DRAW",35632:"FRAGMENT_SHADER",35633:"VERTEX_SHADER",35660:"MAX_VERTEX_TEXTURE_IMAGE_UNITS",35661:"MAX_COMBINED_TEXTURE_IMAGE_UNITS",35663:"SHADER_TYPE",35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",35712:"DELETE_STATUS",35713:"COMPILE_STATUS",35714:"LINK_STATUS",35715:"VALIDATE_STATUS",35716:"INFO_LOG_LENGTH",35717:"ATTACHED_SHADERS",35718:"ACTIVE_UNIFORMS",35719:"ACTIVE_UNIFORM_MAX_LENGTH",35720:"SHADER_SOURCE_LENGTH",35721:"ACTIVE_ATTRIBUTES",35722:"ACTIVE_ATTRIBUTE_MAX_LENGTH",35724:"SHADING_LANGUAGE_VERSION",35725:"CURRENT_PROGRAM",36003:"STENCIL_BACK_REF",36004:"STENCIL_BACK_VALUE_MASK",36005:"STENCIL_BACK_WRITEMASK",36006:"FRAMEBUFFER_BINDING",36007:"RENDERBUFFER_BINDING",36048:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36049:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36050:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36051:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36053:"FRAMEBUFFER_COMPLETE",36054:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36055:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36057:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36061:"FRAMEBUFFER_UNSUPPORTED",36064:"COLOR_ATTACHMENT0",36096:"DEPTH_ATTACHMENT",36128:"STENCIL_ATTACHMENT",36160:"FRAMEBUFFER",36161:"RENDERBUFFER",36162:"RENDERBUFFER_WIDTH",36163:"RENDERBUFFER_HEIGHT",36164:"RENDERBUFFER_INTERNAL_FORMAT",36168:"STENCIL_INDEX8",36176:"RENDERBUFFER_RED_SIZE",36177:"RENDERBUFFER_GREEN_SIZE",36178:"RENDERBUFFER_BLUE_SIZE",36179:"RENDERBUFFER_ALPHA_SIZE",36180:"RENDERBUFFER_DEPTH_SIZE",36181:"RENDERBUFFER_STENCIL_SIZE",36194:"RGB565",36336:"LOW_FLOAT",36337:"MEDIUM_FLOAT",36338:"HIGH_FLOAT",36339:"LOW_INT",36340:"MEDIUM_INT",36341:"HIGH_INT",36346:"SHADER_COMPILER",36347:"MAX_VERTEX_UNIFORM_VECTORS",36348:"MAX_VARYING_VECTORS",36349:"MAX_FRAGMENT_UNIFORM_VECTORS",37440:"UNPACK_FLIP_Y_WEBGL",37441:"UNPACK_PREMULTIPLY_ALPHA_WEBGL",37442:"CONTEXT_LOST_WEBGL",37443:"UNPACK_COLORSPACE_CONVERSION_WEBGL",37444:"BROWSER_DEFAULT_WEBGL"}},{}],158:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":157}],159:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.gl,n=a(r,f.vertex,f.fragment),o=a(r,f.fillVertex,f.fragment),s=i(r),l=i(r),u=i(r),c=i(r),d=i(r),p=new h(t,n,o,s,l,u,c,d);return p.update(e),t.addObject(p),p};var n=t("iota-array"),a=t("gl-shader"),i=t("gl-buffer"),o=t("ndarray"),s=t("surface-nets"),l=t("cdt2d"),u=t("clean-pslg"),c=t("binary-search-bounds"),f=t("./lib/shaders");function h(t,e,r,n,a,i,o,s){this.plot=t,this.shader=e,this.fillShader=r,this.positionBuffer=n,this.colorBuffer=a,this.idBuffer=i,this.fillPositionBuffer=o,this.fillColorBuffer=s,this.fillVerts=0,this.shape=[0,0],this.bounds=[1/0,1/0,-1/0,-1/0],this.numVertices=0,this.lineWidth=1}var d,p,g=h.prototype,v=[1,0,0,0,0,1,1,0,1,1,0,1];function m(t,e){var r=Math.floor(e);if(r<0)return t[0];if(r>=t.length-1)return t[t.length-1];var n=e-r;return(1-n)*t[r]+n*t[r+1]}g.draw=(d=[1,0,0,0,1,0,0,0,1],p=[0,0],function(){var t,e,r=this.plot,n=this.shader,a=this.fillShader,i=this.bounds,o=this.numVertices,s=this.fillVerts,l=r.gl,u=r.viewBox,c=r.dataBox,f=i[2]-i[0],h=i[3]-i[1],g=c[2]-c[0],v=c[3]-c[1];if(d[0]=2*f/g,d[4]=2*h/v,d[6]=2*(i[0]-c[0])/g-1,d[7]=2*(i[1]-c[1])/v-1,p[0]=u[2]-u[0],p[1]=u[3]-u[1],s>0&&(a.bind(),(t=a.uniforms).viewTransform=d,t.screenShape=p,e=n.attributes,this.fillPositionBuffer.bind(),e.position.pointer(),this.fillColorBuffer.bind(),e.color.pointer(l.UNSIGNED_BYTE,!0),l.drawArrays(l.TRIANGLES,0,s)),o>0){n.bind();var m=this.lineWidth*r.pixelRatio;(t=n.uniforms).viewTransform=d,t.screenShape=p,t.lineWidth=m,t.pointSize=1e3,e=n.attributes,this.positionBuffer.bind(),e.position.pointer(l.FLOAT,!1,16,0),e.tangent.pointer(l.FLOAT,!1,16,8),this.colorBuffer.bind(),e.color.pointer(l.UNSIGNED_BYTE,!0),l.drawArrays(l.TRIANGLES,0,o),t.lineWidth=0,t.pointSize=m,this.positionBuffer.bind(),e.position.pointer(l.FLOAT,!1,48,0),e.tangent.pointer(l.FLOAT,!1,48,8),this.colorBuffer.bind(),e.color.pointer(l.UNSIGNED_BYTE,!0,12,0),l.drawArrays(l.POINTS,0,o/3)}}),g.drawPick=function(t){return t},g.pick=function(t,e,r){return null},g.update=function(t){var e=(t=t||{}).shape||[0,0],r=t.x||n(e[0]),a=t.y||n(e[1]),i=t.z||new Float32Array(e[0]*e[1]),f=t.levels||[],h=t.levelColors||[],d=this.bounds,p=d[0]=r[0],g=d[1]=a[0],y=d[2]=r[r.length-1],b=d[3]=a[a.length-1];p===y&&(d[2]+=1,y+=1),g===b&&(d[3]+=1,b+=1);var x=1/(y-p),_=1/(b-g);this.lineWidth=t.lineWidth||1;var w=o(i,e),A=[],k=[],T=[],M=[],E=[[0,0],[e[0]-1,0],[0,e[1]-1],[e[0]-1,e[1]-1]];function C(t,e,r,n){var a=n-r;return Math.abs(a)<1e-6?e:Math.floor(e)+Math.max(.001,Math.min(.999,(t-r)/a))}for(var S=0;S0&&L===f[S-1])){for(var O=s(w,L),D=255*h[4*S]|0,R=255*h[4*S+1]|0,P=255*h[4*S+2]|0,I=255*h[4*S+3]|0,z=O.cells,F=O.positions,N=Array(F.length),B=0;B1)){var V,q=H[0],G=H[1],X=w.get(Math.floor(q),Math.floor(G)),W=w.get(Math.floor(q),Math.ceil(G)),Y=w.get(Math.ceil(q),Math.floor(G)),Z=w.get(Math.ceil(q),Math.ceil(G));0===Math.floor(H[0])&&X<=L!=Wc||r<0||r>c)throw new Error("gl-fbo: Parameters are too large for FBO");var f=1;if("color"in(n=n||{})){if((f=Math.max(0|n.color,0))<0)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(f>1){if(!u)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(f>t.getParameter(u.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+f+" draw buffers")}}var h=t.UNSIGNED_BYTE,d=t.getExtension("OES_texture_float");if(n.float&&f>0){if(!d)throw new Error("gl-fbo: Context does not support floating point textures");h=t.FLOAT}else n.preferFloat&&f>0&&d&&(h=t.FLOAT);var g=!0;"depth"in n&&(g=!!n.depth);var v=!1;"stencil"in n&&(v=!!n.stencil);return new p(t,e,r,h,f,g,v,u)};var a,i,o,s,l=null;function u(t){return[t.getParameter(t.FRAMEBUFFER_BINDING),t.getParameter(t.RENDERBUFFER_BINDING),t.getParameter(t.TEXTURE_BINDING_2D)]}function c(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function f(t){switch(t){case a:throw new Error("gl-fbo: Framebuffer unsupported");case i:throw new Error("gl-fbo: Framebuffer incomplete attachment");case o:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case s:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function h(t,e,r,a,i,o){if(!a)return null;var s=n(t,e,r,i,a);return s.magFilter=t.NEAREST,s.minFilter=t.NEAREST,s.mipSamples=1,s.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_2D,s.handle,0),s}function d(t,e,r,n,a){var i=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,i),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,a,t.RENDERBUFFER,i),i}function p(t,e,r,n,a,i,o,s){this.gl=t,this._shape=[0|e,0|r],this._destroyed=!1,this._ext=s,this.color=new Array(a);for(var p=0;p1&&s.drawBuffersWEBGL(l[o]);var y=r.getExtension("WEBGL_depth_texture");y?p?t.depth=h(r,a,i,y.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g&&(t.depth=h(r,a,i,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):g&&p?t._depth_rb=d(r,a,i,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g?t._depth_rb=d(r,a,i,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):p&&(t._depth_rb=d(r,a,i,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){for(t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null),m=0;ma||r<0||r>a)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var i=u(n),o=0;o>8*d&255;this.pickOffset=r,a.bind();var p=a.uniforms;p.viewTransform=t,p.pickOffset=e,p.shape=this.shape;var g=a.attributes;return this.positionBuffer.bind(),g.position.pointer(),this.weightBuffer.bind(),g.weight.pointer(s.UNSIGNED_BYTE,!1),this.idBuffer.bind(),g.pickId.pointer(s.UNSIGNED_BYTE,!1),s.drawArrays(s.TRIANGLES,0,o),r+this.shape[0]*this.shape[1]}}}(),f.pick=function(t,e,r){var n=this.pickOffset,a=this.shape[0]*this.shape[1];if(r=n+a)return null;var i=r-n,o=this.xData,s=this.yData;return{object:this,pointId:i,dataCoord:[o[i%this.shape[0]],s[i/this.shape[0]|0]]}},f.update=function(t){var e=(t=t||{}).shape||[0,0],r=t.x||a(e[0]),o=t.y||a(e[1]),s=t.z||new Float32Array(e[0]*e[1]);this.xData=r,this.yData=o;var l=t.colorLevels||[0],u=t.colorValues||[0,0,0,1],c=l.length,f=this.bounds,d=f[0]=r[0],p=f[1]=o[0],g=1/((f[2]=r[r.length-1])-d),v=1/((f[3]=o[o.length-1])-p),m=e[0],y=e[1];this.shape=[m,y];var b=(m-1)*(y-1)*(h.length>>>1);this.numVertices=b;for(var x=i.mallocUint8(4*b),_=i.mallocFloat32(2*b),w=i.mallocUint8(2*b),A=i.mallocUint32(b),k=0,T=0;Ta[k]&&(r.uniforms.dataAxis=u,r.uniforms.screenOffset=c,r.uniforms.color=v[t],r.uniforms.angle=m[t],i.drawArrays(i.TRIANGLES,a[k],a[T]-a[k]))),y[t]&&A&&(c[1^t]-=M*d*b[t],r.uniforms.dataAxis=f,r.uniforms.screenOffset=c,r.uniforms.color=x[t],r.uniforms.angle=_[t],i.drawArrays(i.TRIANGLES,w,A)),c[1^t]=M*s[2+(1^t)]-1,p[t+2]&&(c[1^t]+=M*d*g[t+2],ka[k]&&(r.uniforms.dataAxis=u,r.uniforms.screenOffset=c,r.uniforms.color=v[t+2],r.uniforms.angle=m[t+2],i.drawArrays(i.TRIANGLES,a[k],a[T]-a[k]))),y[t+2]&&A&&(c[1^t]+=M*d*b[t+2],r.uniforms.dataAxis=f,r.uniforms.screenOffset=c,r.uniforms.color=x[t+2],r.uniforms.angle=_[t+2],i.drawArrays(i.TRIANGLES,w,A))}),g.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,a=r.gl,i=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,u=r.pixelRatio;if(this.titleCount){for(var c=0;c<2;++c)e[c]=2*(o[c]*u-i[c])/(i[2+c]-i[c])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,a.drawArrays(a.TRIANGLES,this.titleOffset,this.titleCount)}}}(),g.bind=(h=[0,0],d=[0,0],p=[0,0],function(){var t=this.plot,e=this.shader,r=t._tickBounds,n=t.dataBox,a=t.screenBox,i=t.viewBox;e.bind();for(var o=0;o<2;++o){var s=r[o],l=r[o+2]-s,u=.5*(n[o+2]+n[o]),c=n[o+2]-n[o],f=i[o],g=i[o+2]-f,v=a[o],m=a[o+2]-v;d[o]=2*l/c*g/m,h[o]=2*(s-u)/c*g/m}p[1]=2*t.pixelRatio/(a[3]-a[1]),p[0]=p[1]*(a[3]-a[1])/(a[2]-a[0]),e.uniforms.dataScale=d,e.uniforms.dataShift=h,e.uniforms.textScale=p,this.vbo.bind(),e.attributes.textCoordinate.pointer()}),g.update=function(t){var e,r,n,a,o,s=[],l=t.ticks,u=t.bounds;for(o=0;o<2;++o){var c=[Math.floor(s.length/3)],f=[-1/0],h=l[o];for(e=0;e=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(p=0;p=0;--t)this.objects[t].dispose();this.objects.length=0;for(t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},u.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},u.removeObject=function(t){for(var e=this.objects,r=0;r 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]),r.pickVertex=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]),r.pickFragment=n(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"])},{glslify:199}],176:[function(t,e,r){"use strict";var n=t("gl-shader"),a=t("gl-buffer"),i=t("typedarray-pool"),o=t("./lib/shader");function s(t,e,r,n,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.shader=n,this.pickShader=a,this.sizeMin=.5,this.sizeMinCap=2,this.sizeMax=20,this.areaRatio=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.blend=!1,this.pickOffset=0,this.points=null}e.exports=function(t,e){var r=t.gl,i=a(r),l=a(r),u=n(r,o.pointVertex,o.pointFragment),c=n(r,o.pickVertex,o.pickFragment),f=new s(t,i,l,u,c);return f.update(e),t.addObject(f),f};var l,u,c=s.prototype;c.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.plot.removeObject(this)},c.update=function(t){var e;function r(e,r){return e in t?t[e]:r}t=t||{},this.sizeMin=r("sizeMin",.5),this.sizeMax=r("sizeMax",20),this.color=r("color",[1,0,0,1]).slice(),this.areaRatio=r("areaRatio",1),this.borderColor=r("borderColor",[0,0,0,1]).slice(),this.blend=r("blend",!1);var n=t.positions.length>>>1,a=t.positions instanceof Float32Array,o=t.idToIndex instanceof Int32Array&&t.idToIndex.length>=n,s=t.positions,l=a?s:i.mallocFloat32(s.length),u=o?t.idToIndex:i.mallocInt32(n);if(a||l.set(s),!o)for(l.set(s),e=0;e>>1;for(r=0;r=e[0]&&i<=e[2]&&o>=e[1]&&o<=e[3]&&n++}return n}(this.points,a),c=this.plot.pickPixelRatio*Math.max(Math.min(this.sizeMinCap,this.sizeMin),Math.min(this.sizeMax,this.sizeMax/Math.pow(s,.33333)));l[0]=2/i,l[4]=2/o,l[6]=-2*a[0]/i-1,l[7]=-2*a[1]/o-1,this.offsetBuffer.bind(),r.bind(),r.attributes.position.pointer(),r.uniforms.matrix=l,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointCloud=c<5,r.uniforms.pointSize=c,r.uniforms.centerFraction=Math.min(1,Math.max(0,Math.sqrt(1-this.areaRatio))),e&&(u[0]=255&t,u[1]=t>>8&255,u[2]=t>>16&255,u[3]=t>>24&255,this.pickBuffer.bind(),r.attributes.pickId.pointer(n.UNSIGNED_BYTE),r.uniforms.pickOffset=u,this.pickOffset=t);var f=n.getParameter(n.BLEND),h=n.getParameter(n.DITHER);return f&&!this.blend&&n.disable(n.BLEND),h&&n.disable(n.DITHER),n.drawArrays(n.POINTS,0,this.pointCount),f&&!this.blend&&n.enable(n.BLEND),h&&n.enable(n.DITHER),t+this.pointCount}),c.draw=c.unifiedDraw,c.drawPick=c.unifiedDraw,c.pick=function(t,e,r){var n=this.pickOffset,a=this.pointCount;if(r=n+a)return null;var i=r-n,o=this.points;return{object:this,pointId:i,dataCoord:[o[2*i],o[2*i+1]]}}},{"./lib/shader":175,"gl-buffer":156,"gl-shader":180,"typedarray-pool":289}],177:[function(t,e,r){"use strict";var n=t("glslify");r.boxVertex=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n"]),r.boxFragment=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"])},{glslify:199}],178:[function(t,e,r){"use strict";var n=t("gl-shader"),a=t("gl-buffer"),i=t("./lib/shaders");function o(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-1/0,-1/0],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}e.exports=function(t,e){var r=t.gl,s=a(r,[0,0,0,1,1,0,1,1]),l=n(r,i.boxVertex,i.boxFragment),u=new o(t,s,l);return u.update(e),t.addOverlay(u),u};var s=o.prototype;s.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),a=(this.outerFill,this.outerColor),i=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,u=t.viewBox,c=t.pixelRatio,f=(e[0]-l[0])*(u[2]-u[0])/(l[2]-l[0])+u[0],h=(e[1]-l[1])*(u[3]-u[1])/(l[3]-l[1])+u[1],d=(e[2]-l[0])*(u[2]-u[0])/(l[2]-l[0])+u[0],p=(e[3]-l[1])*(u[3]-u[1])/(l[3]-l[1])+u[1];if(f=Math.max(f,u[0]),h=Math.max(h,u[1]),d=Math.min(d,u[2]),p=Math.min(p,u[3]),!(d0){var m=r*c;o.drawBox(f-m,h-m,d+m,h+m,i),o.drawBox(f-m,p-m,d+m,p+m,i),o.drawBox(f-m,h-m,f+m,p+m,i),o.drawBox(d-m,h-m,d+m,p+m,i)}}}},s.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},s.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":177,"gl-buffer":156,"gl-shader":180}],179:[function(t,e,r){"use strict";e.exports=function(t,e){var r=n(t,e),i=a.mallocUint8(e[0]*e[1]*4);return new u(t,r,i)};var n=t("gl-fbo"),a=t("typedarray-pool"),i=t("ndarray"),o=t("bit-twiddle").nextPow2,s=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(_inline_55_arg0_<255||_inline_55_arg1_<255||_inline_55_arg2_<255||_inline_55_arg3_<255){var _inline_55_l=_inline_55_arg4_-_inline_55_arg6_[0],_inline_55_a=_inline_55_arg5_-_inline_55_arg6_[1],_inline_55_f=_inline_55_l*_inline_55_l+_inline_55_a*_inline_55_a;_inline_55_fthis.buffer.length){a.free(this.buffer);for(var n=this.buffer=a.mallocUint8(o(r*e*4)),i=0;ir)for(t=r;te)for(t=e;t=0){for(var A=0|w.type.charAt(w.type.length-1),k=new Array(A),T=0;T=0;)M+=1;_[y]=M}var E=new Array(r.length);function C(){h.program=o.program(d,h._vref,h._fref,x,_);for(var t=0;t=0){var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new n("","Invalid data type for attribute "+f+": "+h);o(t,e,d[0],a,p,i,f)}else{if(!(h.indexOf("mat")>=0))throw new n("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new n("","Invalid data type for attribute "+f+": "+h);s(t,e,d,a,p,i,f)}}}return i};var n=t("./GLError");function a(t,e,r,n,a,i){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=a,this._constFunc=i}var i=a.prototype;function o(t,e,r,n,i,o,s){for(var l=["gl","v"],u=[],c=0;c4)throw new a("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new a("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(i<2||i>4)throw new a("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new a("","Unrecognized data type for vector "+name+": "+r)}}}function u(e){for(var n=["return function updateProperty(obj){"],a=function t(e,r){if("object"!=typeof r)return[[e,r]];var n=[];for(var a in r){var i=r[a],o=e;parseInt(a)+""===a?o+="["+a+"]":o+="."+a,"object"==typeof i?n.push.apply(n,t(o,i)):n.push([o,i])}return n}("",e),i=0;i4)throw new a("","Invalid data type");return"b"===t.charAt(0)?o(r,!1):o(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(r<2||r>4)throw new a("","Invalid uniform dimension type for matrix "+name+": "+t);return o(r*r,0)}throw new a("","Unknown uniform data type for "+name+": "+t)}}(r[c].type);var d}function f(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var u=1;u1)for(var l=0;l halfCharStep + halfCharWidth ||\n\t\t\t\t\tfloor(uv.x) < halfCharStep - halfCharWidth) return;\n\n\t\t\t\tuv += charId * charStep;\n\t\t\t\tuv = uv / atlasSize;\n\n\t\t\t\tvec4 color = fontColor;\n\t\t\t\tvec4 mask = texture2D(atlas, uv);\n\n\t\t\t\tfloat maskY = lightness(mask);\n\t\t\t\t// float colorY = lightness(color);\n\t\t\t\tcolor.a *= maskY;\n\t\t\t\tcolor.a *= opacity;\n\n\t\t\t\t// color.a += .1;\n\n\t\t\t\t// antialiasing, see yiq color space y-channel formula\n\t\t\t\t// color.rgb += (1. - color.rgb) * (1. - mask.rgb);\n\n\t\t\t\tgl_FragColor = color;\n\t\t\t}"});return{regl:t,draw:e,atlas:{}}},A.prototype.update=function(t){var e=this;if("string"==typeof t)t={text:t};else if(!t)return;null!=(t=a(t,{position:"position positions coord coords coordinates",font:"font fontFace fontface typeface cssFont css-font family fontFamily",fontSize:"fontSize fontsize size font-size",text:"text texts chars characters value values symbols",align:"align alignment textAlign textbaseline",baseline:"baseline textBaseline textbaseline",direction:"dir direction textDirection",color:"color colour fill fill-color fillColor textColor textcolor",kerning:"kerning kern",range:"range dataBox",viewport:"vp viewport viewBox viewbox viewPort",opacity:"opacity alpha transparency visible visibility opaque",offset:"offset positionOffset padding shift indent indentation"},!0)).opacity&&(Array.isArray(t.opacity)?this.opacity=t.opacity.map(function(t){return parseFloat(t)}):this.opacity=parseFloat(t.opacity)),null!=t.viewport&&(this.viewport=f(t.viewport),A.normalViewport&&(this.viewport.y=this.canvas.height-this.viewport.y-this.viewport.height),this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null==this.viewport&&(this.viewport={x:0,y:0,width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight},this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null!=t.kerning&&(this.kerning=t.kerning),null!=t.offset&&("number"==typeof t.offset&&(t.offset=[t.offset,0]),this.positionOffset=y(t.offset)),t.direction&&(this.direction=t.direction),t.range&&(this.range=t.range,this.scale=[1/(t.range[2]-t.range[0]),1/(t.range[3]-t.range[1])],this.translate=[-t.range[0],-t.range[1]]),t.scale&&(this.scale=t.scale),t.translate&&(this.translate=t.translate),this.scale||(this.scale=[1/this.viewport.width,1/this.viewport.height]),this.translate||(this.translate=[0,0]),this.font.length||t.font||(t.font=A.baseFontSize+"px sans-serif");var r,i=!1,o=!1;if(t.font&&(Array.isArray(t.font)?t.font:[t.font]).forEach(function(t,r){if("string"==typeof t)try{t=n.parse(t)}catch(e){t=n.parse(A.baseFontSize+"px "+t)}else t=n.parse(n.stringify(t));var a=n.stringify({size:A.baseFontSize,family:t.family,stretch:_?t.stretch:void 0,variant:t.variant,weight:t.weight,style:t.style}),s=d(t.size),l=Math.round(s[0]*p(s[1]));if(l!==e.fontSize[r]&&(o=!0,e.fontSize[r]=l),!(e.font[r]&&a==e.font[r].baseString||(i=!0,e.font[r]=A.fonts[a],e.font[r]))){var u=t.family.join(", "),c=[t.style];t.style!=t.variant&&c.push(t.variant),t.variant!=t.weight&&c.push(t.weight),_&&t.weight!=t.stretch&&c.push(t.stretch),e.font[r]={baseString:a,family:u,weight:t.weight,stretch:t.stretch,style:t.style,variant:t.variant,width:{},kerning:{},metrics:m(u,{origin:"top",fontSize:A.baseFontSize,fontStyle:c.join(" ")})},A.fonts[a]=e.font[r]}}),(i||o)&&this.font.forEach(function(r,a){var i=n.stringify({size:e.fontSize[a],family:r.family,stretch:_?r.stretch:void 0,variant:r.variant,weight:r.weight,style:r.style});if(e.fontAtlas[a]=e.shader.atlas[i],!e.fontAtlas[a]){var o=r.metrics;e.shader.atlas[i]=e.fontAtlas[a]={fontString:i,step:2*Math.ceil(e.fontSize[a]*o.bottom*.5),em:e.fontSize[a],cols:0,rows:0,height:0,width:0,chars:[],ids:{},texture:e.regl.texture()}}null==t.text&&(t.text=e.text)}),"string"==typeof t.text&&t.position&&t.position.length>2){for(var s=Array(.5*t.position.length),h=0;h2){for(var w=!t.position[0].length,k=c.mallocFloat(2*this.count),T=0,M=0;T1?e.align[r]:e.align[0]:e.align;if("number"==typeof n)return n;switch(n){case"right":case"end":return-t;case"center":case"centre":case"middle":return.5*-t}return 0})),null==this.baseline&&null==t.baseline&&(t.baseline=0),null!=t.baseline&&(this.baseline=t.baseline,Array.isArray(this.baseline)||(this.baseline=[this.baseline]),this.baselineOffset=this.baseline.map(function(t,r){var n=(e.font[r]||e.font[0]).metrics,a=0;return a+=.5*n.bottom,a+="number"==typeof t?t-n.baseline:-n[t],A.normalViewport||(a*=-1),a})),null!=t.color)if(t.color||(t.color="transparent"),"string"!=typeof t.color&&isNaN(t.color)){var q;if("number"==typeof t.color[0]&&t.color.length>this.counts.length){var G=t.color.length;q=c.mallocUint8(G);for(var X=(t.color.subarray||t.color.slice).bind(t.color),W=0;W4||this.baselineOffset.length>1||this.align&&this.align.length>1||this.fontAtlas.length>1||this.positionOffset.length>2){var J=Math.max(.5*this.position.length||0,.25*this.color.length||0,this.baselineOffset.length||0,this.alignOffset.length||0,this.font.length||0,this.opacity.length||0,.5*this.positionOffset.length||0);this.batch=Array(J);for(var Q=0;Q1?e.counts[Q]:e.counts[0],offset:e.textOffsets.length>1?e.textOffsets[Q]:e.textOffsets[0],color:e.color?e.color.length<=4?e.color:e.color.subarray(4*Q,4*Q+4):[0,0,0,255],opacity:Array.isArray(e.opacity)?e.opacity[Q]:e.opacity,baseline:null!=e.baselineOffset[Q]?e.baselineOffset[Q]:e.baselineOffset[0],align:e.align?null!=e.alignOffset[Q]?e.alignOffset[Q]:e.alignOffset[0]:0,atlas:e.fontAtlas[Q]||e.fontAtlas[0],positionOffset:e.positionOffset.length>2?e.positionOffset.subarray(2*Q,2*Q+2):e.positionOffset}}else this.count?this.batch=[{count:this.count,offset:0,color:this.color||[0,0,0,255],opacity:Array.isArray(this.opacity)?this.opacity[0]:this.opacity,baseline:this.baselineOffset[0],align:this.alignOffset?this.alignOffset[0]:0,atlas:this.fontAtlas[0],positionOffset:this.positionOffset}]:this.batch=[]},A.prototype.destroy=function(){},A.prototype.kerning=!0,A.prototype.position={constant:new Float32Array(2)},A.prototype.translate=null,A.prototype.scale=null,A.prototype.font=null,A.prototype.text="",A.prototype.positionOffset=[0,0],A.prototype.opacity=1,A.prototype.color=new Uint8Array([0,0,0,255]),A.prototype.alignOffset=[0,0],A.normalViewport=!1,A.maxAtlasSize=1024,A.atlasCanvas=document.createElement("canvas"),A.atlasContext=A.atlasCanvas.getContext("2d",{alpha:!1}),A.baseFontSize=64,A.fonts={},e.exports=A},{"bit-twiddle":39,"color-normalize":63,"css-font":73,"detect-kerning":87,"es6-weak-map":145,"flatten-vertex-data":150,"font-atlas":151,"font-measure":152,"gl-util/context":190,"is-plain-obj":210,"object-assign":223,"parse-rect":226,"parse-unit":228,"pick-by-alias":232,regl:259,"to-px":285,"typedarray-pool":289}],189:[function(t,e,r){"use strict";var n=t("ndarray"),a=t("ndarray-ops"),i=t("typedarray-pool");e.exports=function(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");o||function(t){o=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],s=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],l=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}(t);if("number"==typeof arguments[1])return v(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return v(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1],r=u(e)?e:e.raw;if(r)return function(t,e,r,n,a,i){var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,a,a,i,e),new h(t,o,r,n,a,i)}(t,r,0|e.width,0|e.height,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return function(t,e){var r=e.dtype,o=e.shape.slice(),s=t.getParameter(t.MAX_TEXTURE_SIZE);if(o[0]<0||o[0]>s||o[1]<0||o[1]>s)throw new Error("gl-texture2d: Invalid texture size");var l=p(o,e.stride.slice()),u=0;"float32"===r?u=t.FLOAT:"float64"===r?(u=t.FLOAT,l=!1,r="float32"):"uint8"===r?u=t.UNSIGNED_BYTE:(u=t.UNSIGNED_BYTE,l=!1,r="uint8");var f,d,v=0;if(2===o.length)v=t.LUMINANCE,o=[o[0],o[1],1],e=n(e.data,o,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==o.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===o[2])v=t.ALPHA;else if(2===o[2])v=t.LUMINANCE_ALPHA;else if(3===o[2])v=t.RGB;else{if(4!==o[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}}u!==t.FLOAT||t.getExtension("OES_texture_float")||(u=t.UNSIGNED_BYTE,l=!1);var m=e.size;if(l)f=0===e.offset&&e.data.length===m?e.data:e.data.subarray(e.offset,e.offset+m);else{var y=[o[2],o[2]*o[0],1];d=i.malloc(m,r);var b=n(d,o,y,0);"float32"!==r&&"float64"!==r||u!==t.UNSIGNED_BYTE?a.assign(b,e):c(b,e),f=d.subarray(0,m)}var x=g(t);t.texImage2D(t.TEXTURE_2D,0,v,o[0],o[1],0,v,u,f),l||i.free(d);return new h(t,x,o[0],o[1],v,u)}(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")};var o=null,s=null,l=null;function u(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement||"undefined"!=typeof ImageData&&t instanceof ImageData}var c=function(t,e){a.muls(t,e,255)};function f(t,e,r){var n=t.gl,a=n.getParameter(n.MAX_TEXTURE_SIZE);if(e<0||e>a||r<0||r>a)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function h(t,e,r,n,a,i){this.gl=t,this.handle=e,this.format=a,this.type=i,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}var d=h.prototype;function p(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function g(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function v(t,e,r,n,a){var i=t.getParameter(t.MAX_TEXTURE_SIZE);if(e<0||e>i||r<0||r>i)throw new Error("gl-texture2d: Invalid texture shape");if(a===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,a,null),new h(t,o,e,r,n,a)}Object.defineProperties(d,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=this.gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;e<2;++e)if(l.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return f(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return f(this,t|=0,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t|=0,f(this,this._shape[0],t),t}}}),d.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},d.dispose=function(){this.gl.deleteTexture(this.handle)},d.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},d.setPixels=function(t,e,r,o){var s=this.gl;this.bind(),Array.isArray(e)?(o=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),o=o||0;var l=u(t)?t:t.raw;if(l){this._mipLevels.indexOf(o)<0?(s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,this.type,l),this._mipLevels.push(o)):s.texSubImage2D(s.TEXTURE_2D,o,e,r,this.format,this.type,l)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>o||r+t.shape[0]>this._shape[0]>>>o||e<0||r<0)throw new Error("gl-texture2d: Texture dimensions are out of bounds");!function(t,e,r,o,s,l,u,f){var h=f.dtype,d=f.shape.slice();if(d.length<2||d.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var g=0,v=0,m=p(d,f.stride.slice());"float32"===h?g=t.FLOAT:"float64"===h?(g=t.FLOAT,m=!1,h="float32"):"uint8"===h?g=t.UNSIGNED_BYTE:(g=t.UNSIGNED_BYTE,m=!1,h="uint8");if(2===d.length)v=t.LUMINANCE,d=[d[0],d[1],1],f=n(f.data,d,[f.stride[0],f.stride[1],1],f.offset);else{if(3!==d.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===d[2])v=t.ALPHA;else if(2===d[2])v=t.LUMINANCE_ALPHA;else if(3===d[2])v=t.RGB;else{if(4!==d[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}d[2]}v!==t.LUMINANCE&&v!==t.ALPHA||s!==t.LUMINANCE&&s!==t.ALPHA||(v=s);if(v!==s)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=f.size,b=u.indexOf(o)<0;b&&u.push(o);if(g===l&&m)0===f.offset&&f.data.length===y?b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,f.data):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,f.data):b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,f.data.subarray(f.offset,f.offset+y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,f.data.subarray(f.offset,f.offset+y));else{var x;x=l===t.FLOAT?i.mallocFloat32(y):i.mallocUint8(y);var _=n(x,d,[d[2],d[2]*d[0],1]);g===t.FLOAT&&l===t.UNSIGNED_BYTE?c(_,f):a.assign(_,f),b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,x.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,x.subarray(0,y)),l===t.FLOAT?i.freeFloat32(x):i.freeUint8(x)}}(s,e,r,o,this.format,this.type,this._mipLevels,t)}}},{ndarray:220,"ndarray-ops":219,"typedarray-pool":289}],190:[function(t,e,r){"use strict";var n=t("pick-by-alias");function a(t){if(t.container)if(t.container==document.body)document.body.style.width||(t.canvas.width=t.width||t.pixelRatio*window.innerWidth),document.body.style.height||(t.canvas.height=t.height||t.pixelRatio*window.innerHeight);else{var e=t.container.getBoundingClientRect();t.canvas.width=t.width||e.right-e.left,t.canvas.height=t.height||e.bottom-e.top}}function i(t){return"function"==typeof t.getContext&&"width"in t&&"height"in t}e.exports=function(t){var e;if(t?"string"==typeof t&&(t={container:t}):t={},i(t)?t={container:t}:t="string"==typeof(e=t).nodeName&&"function"==typeof e.appendChild&&"function"==typeof e.getBoundingClientRect?{container:t}:function(t){return"function"==typeof t.drawArrays||"function"==typeof t.drawElements}(t)?{gl:t}:n(t,{container:"container target element el canvas holder parent parentNode wrapper use ref root node",gl:"gl context webgl glContext",attrs:"attributes attrs contextAttributes",pixelRatio:"pixelRatio pxRatio px ratio pxratio pixelratio"},!0),t.pixelRatio||(t.pixelRatio=window.pixelRatio||1),t.gl)return t.gl;if(t.canvas&&(t.container=t.canvas.parentNode),t.container){if("string"==typeof t.container){var r=document.querySelector(t.container);if(!r)throw Error("Element "+t.container+" is not found");t.container=r}i(t.container)?(t.canvas=t.container,t.container=t.canvas.parentNode):t.canvas||(t.canvas=document.createElement("canvas"),t.container.appendChild(t.canvas),a(t))}else t.canvas||(t.container=document.body||document.documentElement,t.canvas=document.createElement("canvas"),t.canvas.style.position="absolute",t.canvas.style.top=0,t.canvas.style.left=0,t.container.appendChild(t.canvas),a(t));if(!t.gl)try{t.gl=t.canvas.getContext("webgl",t.attrs)}catch(e){try{t.gl=t.canvas.getContext("experimental-webgl",t.attrs)}catch(e){t.gl=t.canvas.getContext("webgl-experimental",t.attrs)}}return t.gl}},{"pick-by-alias":232}],191:[function(t,e,r){var n=t("glsl-tokenizer"),a=t("atob-lite");e.exports=function(t){for(var e=Array.isArray(t)?t:n(t),r=0;r0)continue;r=t.slice(0,1).join("")}return F(r),O+=r.length,(E=E.slice(r.length)).length}}function q(){return/[^a-fA-F0-9]/.test(e)?(F(E.join("")),M=l,k):(E.push(e),r=e,k+1)}function G(){return"."===e?(E.push(e),M=g,r=e,k+1):/[eE]/.test(e)?(E.push(e),M=g,r=e,k+1):"x"===e&&1===E.length&&"0"===E[0]?(M=_,E.push(e),r=e,k+1):/[^\d]/.test(e)?(F(E.join("")),M=l,k):(E.push(e),r=e,k+1)}function X(){return"f"===e&&(E.push(e),r=e,k+=1),/[eE]/.test(e)?(E.push(e),r=e,k+1):"-"===e&&/[eE]/.test(r)?(E.push(e),r=e,k+1):/[^\d]/.test(e)?(F(E.join("")),M=l,k):(E.push(e),r=e,k+1)}function W(){if(/[^\d\w_]/.test(e)){var t=E.join("");return M=z.indexOf(t)>-1?y:I.indexOf(t)>-1?m:v,F(E.join("")),M=l,k}return E.push(e),r=e,k+1}};var n=t("./lib/literals"),a=t("./lib/operators"),i=t("./lib/builtins"),o=t("./lib/literals-300es"),s=t("./lib/builtins-300es"),l=999,u=9999,c=0,f=1,h=2,d=3,p=4,g=5,v=6,m=7,y=8,b=9,x=10,_=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":194,"./lib/builtins-300es":193,"./lib/literals":196,"./lib/literals-300es":195,"./lib/operators":197}],193:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":194}],194:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],195:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":196}],196:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],197:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],198:[function(t,e,r){var n=t("./index");e.exports=function(t,e){var r=n(e),a=[];return a=(a=a.concat(r(t))).concat(r(null))}},{"./index":192}],199:[function(t,e,r){e.exports=function(t){"string"==typeof t&&(t=[t]);for(var e=[].slice.call(arguments,1),r=[],n=0;n>1,c=-7,f=r?a-1:0,h=r?-1:1,d=t[e+f];for(f+=h,i=d&(1<<-c)-1,d>>=-c,c+=s;c>0;i=256*i+t[e+f],f+=h,c-=8);for(o=i&(1<<-c)-1,i>>=-c,c+=n;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===i)i=1-u;else{if(i===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),i-=u}return(d?-1:1)*o*Math.pow(2,i-n)},r.write=function(t,e,r,n,a,i){var o,s,l,u=8*i-a-1,c=(1<>1,h=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*l-1)*Math.pow(2,a),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,a),o=0));a>=8;t[r+d]=255&s,d+=p,s/=256,a-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*g}},{}],203:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),a=0,i=1;function o(t,e,r,n,a){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=a,this.count=(e?e.count:0)+(r?r.count:0)+n.length}e.exports=function(t){if(!t||0===t.length)return new b(null);return new b(y(t))};var s=o.prototype;function l(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function u(t,e){var r=y(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function c(t,e){var r=t.intervals([]);r.push(e),u(t,r)}function f(t,e){var r=t.intervals([]),n=r.indexOf(e);return n<0?a:(r.splice(n,1),u(t,r),i)}function h(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var a=r(t[n]);if(a)return a}}function p(t,e){for(var r=0;r>1],a=[],i=[],s=[];for(r=0;r3*(e+1)?c(this,t):this.left.insert(t):this.left=y([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?c(this,t):this.right.insert(t):this.right=y([t]);else{var r=n.ge(this.leftPoints,t,v),a=n.ge(this.rightPoints,t,m);this.leftPoints.splice(r,0,t),this.rightPoints.splice(a,0,t)}},s.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1)?f(this,t):2===(u=this.left.remove(t))?(this.left=null,this.count-=1,i):(u===i&&(this.count-=1),u):a;if(t[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(e-1)?f(this,t):2===(u=this.right.remove(t))?(this.right=null,this.count-=1,i):(u===i&&(this.count-=1),u):a;if(1===this.count)return this.leftPoints[0]===t?2:a;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var r=this,o=this.left;o.right;)r=o,o=o.right;if(r===this)o.right=this.right;else{var s=this.left,u=this.right;r.count-=o.count,r.right=o.left,o.left=s,o.right=u}l(this,o),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?l(this,this.left):l(this,this.right);return i}for(s=n.ge(this.leftPoints,t,v);sthis.mid){var r;if(this.right)if(r=this.right.queryPoint(t,e))return r;return d(this.rightPoints,t,e)}return p(this.leftPoints,e)},s.queryInterval=function(t,e,r){var n;if(tthis.mid&&this.right&&(n=this.right.queryInterval(t,e,r)))return n;return ethis.mid?d(this.rightPoints,t,r):p(this.leftPoints,r)};var x=b.prototype;x.insert=function(t){this.root?this.root.insert(t):this.root=new o(t[0],null,null,[t],[t])},x.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),e!==a}return!1},x.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},x.queryInterval=function(t,e,r){if(t<=e&&this.root)return this.root.queryInterval(t,e,r)},Object.defineProperty(x,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(x,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":38}],204:[function(t,e,r){"use strict";e.exports=function(t,e){e=e||new Array(t.length);for(var r=0;r13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],212:[function(t,e,r){"use strict";e.exports=function(t){return"string"==typeof t&&(t=t.trim(),!!(/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(t)&&/[\dz]$/i.test(t)&&t.length>4))}},{}],213:[function(t,e,r){"use strict";e.exports=Math.log2||function(t){return Math.log(t)*Math.LOG2E}},{}],214:[function(t,e,r){"use strict";e.exports=function(t,e){e||(e=t,t=window);var r=0,a=0,i=0,o={shift:!1,alt:!1,control:!1,meta:!1},s=!1;function l(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==o.alt,o.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==o.shift,o.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==o.control,o.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==o.meta,o.meta=!!t.metaKey),e}function u(t,s){var u=n.x(s),c=n.y(s);"buttons"in s&&(t=0|s.buttons),(t!==r||u!==a||c!==i||l(s))&&(r=0|t,a=u||0,i=c||0,e&&e(r,a,i,o))}function c(t){u(0,t)}function f(){(r||a||i||o.shift||o.alt||o.meta||o.control)&&(a=i=0,r=0,o.shift=o.alt=o.control=o.meta=!1,e&&e(0,0,0,o))}function h(t){l(t)&&e&&e(r,a,i,o)}function d(t){0===n.buttons(t)?u(0,t):u(r,t)}function p(t){u(r|n.buttons(t),t)}function g(t){u(r&~n.buttons(t),t)}function v(){s||(s=!0,t.addEventListener("mousemove",d),t.addEventListener("mousedown",p),t.addEventListener("mouseup",g),t.addEventListener("mouseleave",c),t.addEventListener("mouseenter",c),t.addEventListener("mouseout",c),t.addEventListener("mouseover",c),t.addEventListener("blur",f),t.addEventListener("keyup",h),t.addEventListener("keydown",h),t.addEventListener("keypress",h),t!==window&&(window.addEventListener("blur",f),window.addEventListener("keyup",h),window.addEventListener("keydown",h),window.addEventListener("keypress",h)))}v();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return s},set:function(e){e?v():s&&(s=!1,t.removeEventListener("mousemove",d),t.removeEventListener("mousedown",p),t.removeEventListener("mouseup",g),t.removeEventListener("mouseleave",c),t.removeEventListener("mouseenter",c),t.removeEventListener("mouseout",c),t.removeEventListener("mouseover",c),t.removeEventListener("blur",f),t.removeEventListener("keyup",h),t.removeEventListener("keydown",h),t.removeEventListener("keypress",h),t!==window&&(window.removeEventListener("blur",f),window.removeEventListener("keyup",h),window.removeEventListener("keydown",h),window.removeEventListener("keypress",h)))},enumerable:!0},buttons:{get:function(){return r},enumerable:!0},x:{get:function(){return a},enumerable:!0},y:{get:function(){return i},enumerable:!0},mods:{get:function(){return o},enumerable:!0}}),m};var n=t("mouse-event")},{"mouse-event":216}],215:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var a=t.clientX||0,i=t.clientY||0,o=(s=e,s===window||s===document||s===document.body?n:s.getBoundingClientRect());var s;return r[0]=a-o.left,r[1]=i-o.top,r}},{}],216:[function(t,e,r){"use strict";function n(t){return t.target||t.srcElement||window}r.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){if(2===(e=t.which))return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1< 0");"function"!=typeof t.vertex&&e("Must specify vertex creation function");"function"!=typeof t.cell&&e("Must specify cell creation function");"function"!=typeof t.phase&&e("Must specify phase function");for(var C=t.getters||[],S=new Array(M),L=0;L=0?S[L]=!0:S[L]=!1;return function(t,e,r,M,E,C){var S=C.length,L=E.length;if(L<2)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var O="extractContour"+E.join("_"),D=[],R=[],P=[],I=0;I0&&B.push(l(I,E[z-1])+"*"+s(E[z-1])),R.push(p(I,E[z])+"=("+B.join("-")+")|0")}for(var I=0;I=0;--I)j.push(s(E[I]));R.push(w+"=("+j.join("*")+")|0",x+"=mallocUint32("+w+")",b+"=mallocUint32("+w+")",A+"=0"),R.push(g(0)+"=0");for(var z=1;z<1<0;k=k-1&p)w.push(b+"["+A+"+"+m(k)+"]");w.push(y(0));for(var k=0;k=0;--e)G(e,0);for(var r=[],e=0;e0){",d(E[e]),"=1;");t(e-1,r|1<>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in l){var e=l[t];r[t]=o({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var c=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=n({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=n({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=n({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=n({args:["array","array"],pre:a,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":79}],220:[function(t,e,r){var n=t("iota-array"),a=t("is-buffer"),i="undefined"!=typeof Float64Array;function o(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,r=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&i.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):i.push("ORDER})")),i.push("proto.set=function "+r+"_set("+l.join(",")+",v){"),a?i.push("return this.data.set("+c+",v)}"):i.push("return this.data["+c+"]=v}"),i.push("proto.get=function "+r+"_get("+l.join(",")+"){"),a?i.push("return this.data.get("+c+")}"):i.push("return this.data["+c+"]}"),i.push("proto.index=function "+r+"_index(",l.join(),"){return "+c+"}"),i.push("proto.hi=function "+r+"_hi("+l.join(",")+"){return new "+r+"(this.data,"+o.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+o.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var d=o.map(function(t){return"a"+t+"=this.shape["+t+"]"}),p=o.map(function(t){return"c"+t+"=this.stride["+t+"]"});i.push("proto.lo=function "+r+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+p.join(","));for(var g=0;g=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");i.push("return new "+r+"(this.data,"+o.map(function(t){return"a"+t}).join(",")+","+o.map(function(t){return"c"+t}).join(",")+",b)}"),i.push("proto.step=function "+r+"_step("+l.join(",")+"){var "+o.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+o.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(g=0;g=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");return i.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),i.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+o.map(function(t){return"shape["+t+"]"}).join(",")+","+o.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",i.join("\n"))(u[t],s)}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,r,n){if(void 0===t)return(0,u.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var o=e.length;if(void 0===r){r=new Array(o);for(var s=o-1,c=1;s>=0;--s)r[s]=c,c*=e[s]}if(void 0===n)for(n=0,s=0;s>>0;e.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-a:a;var r=n.hi(t),o=n.lo(t);e>t==t>0?o===i?(r+=1,o=0):o+=1:0===o?(o=i,r-=1):o-=1;return n.pack(o,r)}},{"double-bits":88}],222:[function(t,e,r){var n=Math.PI,a=u(120);function i(t,e,r,n){return["C",t,e,r,n,r,n]}function o(t,e,r,n,a,i){return["C",t/3+2/3*r,e/3+2/3*n,a/3+2/3*r,i/3+2/3*n,a,i]}function s(t,e,r,i,o,u,c,f,h,d){if(d)A=d[0],k=d[1],_=d[2],w=d[3];else{var p=l(t,e,-o);t=p.x,e=p.y;var g=(t-(f=(p=l(f,h,-o)).x))/2,v=(e-(h=p.y))/2,m=g*g/(r*r)+v*v/(i*i);m>1&&(r*=m=Math.sqrt(m),i*=m);var y=r*r,b=i*i,x=(u==c?-1:1)*Math.sqrt(Math.abs((y*b-y*v*v-b*g*g)/(y*v*v+b*g*g)));x==1/0&&(x=1);var _=x*r*v/i+(t+f)/2,w=x*-i*g/r+(e+h)/2,A=Math.asin(((e-w)/i).toFixed(9)),k=Math.asin(((h-w)/i).toFixed(9));(A=t<_?n-A:A)<0&&(A=2*n+A),(k=f<_?n-k:k)<0&&(k=2*n+k),c&&A>k&&(A-=2*n),!c&&k>A&&(k-=2*n)}if(Math.abs(k-A)>a){var T=k,M=f,E=h;k=A+a*(c&&k>A?1:-1);var C=s(f=_+r*Math.cos(k),h=w+i*Math.sin(k),r,i,o,0,c,M,E,[k,T,_,w])}var S=Math.tan((k-A)/4),L=4/3*r*S,O=4/3*i*S,D=[2*t-(t+L*Math.sin(A)),2*e-(e-O*Math.cos(A)),f+L*Math.sin(k),h-O*Math.cos(k),f,h];if(d)return D;C&&(D=D.concat(C));for(var R=0;R7&&(r.push(m.splice(0,7)),m.unshift("C"));break;case"S":var b=d,x=p;"C"!=e&&"S"!=e||(b+=b-n,x+=x-a),m=["C",b,x,m[1],m[2],m[3],m[4]];break;case"T":"Q"==e||"T"==e?(f=2*d-f,h=2*p-h):(f=d,h=p),m=o(d,p,f,h,m[1],m[2]);break;case"Q":f=m[1],h=m[2],m=o(d,p,m[1],m[2],m[3],m[4]);break;case"L":m=i(d,p,m[1],m[2]);break;case"H":m=i(d,p,m[1],p);break;case"V":m=i(d,p,d,m[1]);break;case"Z":m=i(d,p,l,c)}e=y,d=m[m.length-2],p=m[m.length-1],m.length>4?(n=m[m.length-4],a=m[m.length-3]):(n=d,a=p),r.push(m)}return r}},{}],223:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,o,s=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),l=1;l1e4)throw Error("References have circular dependency. Please, check them.");r[n]=t}),n=n.reverse(),r=r.map(function(e){return n.forEach(function(r){e=e.replace(new RegExp("(\\"+a+r+"(?![0-9]))","g"),t[0]+"$1"+t[1])}),e})});var o=new RegExp("\\"+a+"([0-9]+)");return i?r:function t(e,r,n){for(var a,i=[],s=0;a=o.exec(e);){if(s++>1e4)throw Error("Circular references in parenthesis");i.push(e.slice(0,a.index)),i.push(t(r[a[1]],r)),e=e.slice(a.index+a[0].length)}return i.push(e),i}(r[0],r)}function a(t,e){if(e&&e.flat){var r,n=e&&e.escape||"___",a=t[0];if(!a)return"";for(var i=new RegExp("\\"+n+"([0-9]+)"),o=0;a!=r;){if(o++>1e4)throw Error("Circular references in "+t);r=a,a=a.replace(i,s)}return a}return t.reduce(function t(e,r){return Array.isArray(r)&&(r=r.reduce(t,"")),e+r},"");function s(e,r){if(null==t[r])throw Error("Reference "+r+"is undefined");return t[r]}}function i(t,e){return Array.isArray(t)?a(t,e):n(t,e)}i.parse=n,i.stringify=a,e.exports=i},{}],226:[function(t,e,r){"use strict";var n=t("pick-by-alias");e.exports=function(t){var e;arguments.length>1&&(t=arguments);"string"==typeof t?t=t.split(/\s/).map(parseFloat):"number"==typeof t&&(t=[t]);t.length&&"number"==typeof t[0]?e=1===t.length?{width:t[0],height:t[0],x:0,y:0}:2===t.length?{width:t[0],height:t[1],x:0,y:0}:{x:t[0],y:t[1],width:t[2]-t[0]||0,height:t[3]-t[1]||0}:t&&(t=n(t,{left:"x l left Left",top:"y t top Top",width:"w width W Width",height:"h height W Width",bottom:"b bottom Bottom",right:"r right Right"}),e={x:t.left||0,y:t.top||0},null==t.width?t.right?e.width=t.right-e.x:e.width=0:e.width=t.width,null==t.height?t.bottom?e.height=t.bottom-e.y:e.height=0:e.height=t.height);return e}},{"pick-by-alias":232}],227:[function(t,e,r){e.exports=function(t){var e=[];return t.replace(a,function(t,r,a){var o=r.toLowerCase();for(a=function(t){var e=t.match(i);return e?e.map(Number):[]}(a),"m"==o&&a.length>2&&(e.push([r].concat(a.splice(0,2))),o="l",r="m"==r?"l":"L");;){if(a.length==n[o])return a.unshift(r),e.push(a);if(a.length0;--o)i=l[o],r=s[o],s[o]=s[i],s[i]=r,l[o]=l[r],l[r]=i,u=(u+r)*o;return n.freeUint32(l),n.freeUint32(s),u},r.unrank=function(t,e,r){switch(t){case 0:return r||[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}var n,a,i,o=1;for((r=r||new Array(t))[0]=0,i=1;i0;--i)e=e-(n=e/o|0)*o|0,o=o/i|0,a=0|r[i],r[i]=0|r[n],r[n]=0|a;return r}},{"invert-permutation":204,"typedarray-pool":289}],232:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n,i,o={};if("string"==typeof e&&(e=a(e)),Array.isArray(e)){var s={};for(i=0;i0){o=i[c][r][0],l=c;break}s=o[1^l];for(var f=0;f<2;++f)for(var h=i[f][r],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&u(o,l),s)}function f(t,r){var a=i[r][t][0],o=[t];u(a,r);for(var s=a[1^r];;){for(;s!==t;)o.push(s),s=c(o[o.length-2],s,!1);if(i[0][t].length+i[1][t].length===0)break;var l=o[o.length-1],f=t,h=o[1],d=c(l,f,!0);if(n(e[l],e[f],e[h],e[d])<0)break;o.push(t),s=c(l,f)}return o}function h(t,e){return e[1]===e[e.length-1]}for(var o=0;o0;){i[0][o].length;var g=f(o,d);h(p,g)?p.push.apply(p,g):(p.length>0&&l.push(p),p=g)}p.length>0&&l.push(p)}return l};var n=t("compare-angle")},{"compare-angle":68}],234:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=n(t,e.length),a=new Array(e.length),i=new Array(e.length),o=[],s=0;s0;){var u=o.pop();a[u]=!1;for(var c=r[u],s=0;s0})).length,v=new Array(g),m=new Array(g),d=0;d0;){var B=F.pop(),j=S[B];l(j,function(t,e){return t-e});var U,H=j.length,V=N[B];if(0===V){var A=p[B];U=[A]}for(var d=0;d=0)&&(N[q]=1^V,F.push(q),0===V)){var A=p[q];z(A)||(A.reverse(),U.push(A))}}0===V&&r.push(U)}return r};var n=t("edges-to-adjacency-list"),a=t("planar-dual"),i=t("point-in-big-polygon"),o=t("two-product"),s=t("robust-sum"),l=t("uniq"),u=t("./lib/trim-leaves");function c(t,e){for(var r=new Array(t),n=0;n>>1;e.dtype||(e.dtype="array"),"string"==typeof e.dtype?p=new(f(e.dtype))(v):e.dtype&&(p=e.dtype,Array.isArray(p)&&(p.length=v));for(var m=0;mr){for(var h=0;hl||T>u||M=S||o===s)){var c=y[i];void 0===s&&(s=c.length);for(var f=o;f=g&&d<=m&&p>=v&&p<=w&&O.push(h)}var x=b[i],_=x[4*o+0],A=x[4*o+1],C=x[4*o+2],L=x[4*o+3],D=function(t,e){for(var r=null,n=0;null===r;)if(r=t[4*e+n],++n>t.length)return null;return r}(x,o+1),R=.5*a,P=i+1;e(r,n,R,P,_,A||C||L||D),e(r,n+R,R,P,A,C||L||D),e(r+R,n,R,P,C,L||D),e(r+R,n+R,R,P,L,D)}}}(0,0,1,0,0,1),O},p;function C(t,e,r){for(var n=1,a=.5,i=.5,o=.5,s=0;s0&&e[a]===r[0]))return 1;i=t[a-1]}for(var s=1;i;){var l=i.key,u=n(r,l[0],l[1]);if(l[0][0]0))return 0;s=-1,i=i.right}else if(u>0)i=i.left;else{if(!(u<0))return 0;s=1,i=i.right}}return s}}(m.slabs,m.coordinates);return 0===i.length?y:function(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}(l(i),y)};var n=t("robust-orientation")[3],a=t("slab-decomposition"),i=t("interval-tree-1d"),o=t("binary-search-bounds");function s(){return!0}function l(t){for(var e={},r=0;r=-t},pointBetween:function(e,r,n){var a=e[1]-r[1],i=n[0]-r[0],o=e[0]-r[0],s=n[1]-r[1],l=o*i+a*s;return!(l-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-a>t&&(i-u)*(a-c)/(o-c)+u-n>t&&(s=!s),i=u,o=c}return s}};return e}},{}],243:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),a=1;a0})}function c(t,n){var a=t.seg,i=n.seg,o=a.start,s=a.end,u=i.start,c=i.end;r&&r.checkIntersection(a,i);var f=e.linesIntersect(o,s,u,c);if(!1===f){if(!e.pointsCollinear(o,s,u))return!1;if(e.pointsSame(o,c)||e.pointsSame(s,u))return!1;var h=e.pointsSame(o,u),d=e.pointsSame(s,c);if(h&&d)return n;var p=!h&&e.pointBetween(o,u,c),g=!d&&e.pointBetween(s,u,c);if(h)return g?l(n,s):l(t,c),n;p&&(d||(g?l(n,s):l(t,c)),l(n,o))}else 0===f.alongA&&(-1===f.alongB?l(t,u):0===f.alongB?l(t,f.pt):1===f.alongB&&l(t,c)),0===f.alongB&&(-1===f.alongA?l(n,o):0===f.alongA?l(n,f.pt):1===f.alongA&&l(n,s));return!1}for(var f=[];!i.isEmpty();){var h=i.getHead();if(r&&r.vert(h.pt[0]),h.isStart){r&&r.segmentNew(h.seg,h.primary);var d=u(h),p=d.before?d.before.ev:null,g=d.after?d.after.ev:null;function v(){if(p){var t=c(h,p);if(t)return t}return!!g&&c(h,g)}r&&r.tempStatus(h.seg,!!p&&p.seg,!!g&&g.seg);var m,y,b=v();if(b)t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below)&&(b.seg.myFill.above=!b.seg.myFill.above):b.seg.otherFill=h.seg.myFill,r&&r.segmentUpdate(b.seg),h.other.remove(),h.remove();if(i.getHead()!==h){r&&r.rewind(h.seg);continue}t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below,h.seg.myFill.below=g?g.seg.myFill.above:a,h.seg.myFill.above=y?!h.seg.myFill.below:h.seg.myFill.below):null===h.seg.otherFill&&(m=g?h.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:h.primary?o:a,h.seg.otherFill={above:m,below:m}),r&&r.status(h.seg,!!p&&p.seg,!!g&&g.seg),h.other.status=d.insert(n.node({ev:h}))}else{var x=h.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(s.exists(x.prev)&&s.exists(x.next)&&c(x.prev.ev,x.next.ev),r&&r.statusRemove(x.ev.seg),x.remove(),!h.primary){var _=h.seg.myFill;h.seg.myFill=h.seg.otherFill,h.seg.otherFill=_}f.push(h.seg)}i.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,a,i,o=t[t.length-1],l=0;l1)for(var r=1;r1&&(t.scaleRatio=[t.scale[0]*t.viewport.width,t.scale[1]*t.viewport.height],r(t),t.after&&t.after(t))}function A(t){if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var e=0,r=0;if(x.groups=b=t.map(function(t,u){var c=b[u];return t?("function"==typeof t?t={after:t}:"number"==typeof t[0]&&(t={positions:t}),t=o(t,{color:"color colors fill",capSize:"capSize cap capsize cap-size",lineWidth:"lineWidth line-width width line thickness",opacity:"opacity alpha",range:"range dataBox",viewport:"viewport viewBox",errors:"errors error",positions:"positions position data points"}),c||(b[u]=c={id:u,scale:null,translate:null,scaleFract:null,translateFract:null,draw:!0},t=s({},y,t)),i(c,t,[{lineWidth:function(t){return.5*+t},capSize:function(t){return.5*+t},opacity:parseFloat,errors:function(t){return t=l(t),r+=t.length,t},positions:function(t,r){return t=l(t,"float64"),r.count=Math.floor(t.length/2),r.bounds=n(t,2),r.offset=e,e+=r.count,t}},{color:function(t,e){var r=e.count;if(t||(t="transparent"),!Array.isArray(t)||"number"==typeof t[0]){var n=t;t=Array(r);for(var i=0;i 0. && baClipping < length(normalWidth * endBotJoin)) {\n\t\t//handle miter clipping\n\t\tbTopCoord -= normalWidth * endTopJoin;\n\t\tbTopCoord += normalize(endTopJoin * normalWidth) * baClipping;\n\t}\n\n\tif (nextReverse) {\n\t\t//make join rectangular\n\t\tvec2 miterShift = normalWidth * endJoinDirection * miterLimit * .5;\n\t\tfloat normalAdjust = 1. - min(miterLimit / endMiterRatio, 1.);\n\t\tbBotCoord = bCoord + miterShift - normalAdjust * normalWidth * currNormal * .5;\n\t\tbTopCoord = bCoord + miterShift + normalAdjust * normalWidth * currNormal * .5;\n\t}\n\telse if (!prevReverse && abClipping > 0. && abClipping < length(normalWidth * startBotJoin)) {\n\t\t//handle miter clipping\n\t\taBotCoord -= normalWidth * startBotJoin;\n\t\taBotCoord += normalize(startBotJoin * normalWidth) * abClipping;\n\t}\n\n\tvec2 aTopPosition = (aTopCoord) * adjustedScale + translate;\n\tvec2 aBotPosition = (aBotCoord) * adjustedScale + translate;\n\n\tvec2 bTopPosition = (bTopCoord) * adjustedScale + translate;\n\tvec2 bBotPosition = (bBotCoord) * adjustedScale + translate;\n\n\t//position is normalized 0..1 coord on the screen\n\tvec2 position = (aTopPosition * lineTop + aBotPosition * lineBot) * lineStart + (bTopPosition * lineTop + bBotPosition * lineBot) * lineEnd;\n\n\tstartCoord = aCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\tendCoord = bCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tenableStartMiter = step(dot(currTangent, prevTangent), .5);\n\tenableEndMiter = step(dot(currTangent, nextTangent), .5);\n\n\t//bevel miter cutoffs\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * miterLimit * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * miterLimit * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n\n\t//round miter cutoffs\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * abs(dot(startJoinDirection, currNormal)) * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * abs(dot(endJoinDirection, currNormal)) * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nuniform sampler2D dashPattern;\nuniform float dashSize, pixelRatio, thickness, opacity, id, miterMode;\n\nvarying vec4 fragColor;\nvarying vec2 tangent;\nvarying vec4 startCutoff, endCutoff;\nvarying vec2 startCoord, endCoord;\nvarying float enableStartMiter, enableEndMiter;\n\nfloat distToLine(vec2 p, vec2 a, vec2 b) {\n\tvec2 diff = b - a;\n\tvec2 perp = normalize(vec2(-diff.y, diff.x));\n\treturn dot(p - a, perp);\n}\n\nvoid main() {\n\tfloat alpha = 1., distToStart, distToEnd;\n\tfloat cutoff = thickness * .5;\n\n\t//bevel miter\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToStart + 1., 0.), 1.);\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToEnd + 1., 0.), 1.);\n\t\t}\n\t}\n\n\t// round miter\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - startCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - endCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\t}\n\n\tfloat t = fract(dot(tangent, gl_FragCoord.xy) / dashSize) * .5 + .25;\n\tfloat dash = texture2D(dashPattern, vec2(t, .5)).r;\n\n\tgl_FragColor = fragColor;\n\tgl_FragColor.a *= alpha * opacity * dash;\n}\n"]),attributes:{lineEnd:{buffer:r,divisor:0,stride:8,offset:0},lineTop:{buffer:r,divisor:0,stride:8,offset:4},aColor:{buffer:t.prop("colorBuffer"),stride:4,offset:0,divisor:1},bColor:{buffer:t.prop("colorBuffer"),stride:4,offset:4,divisor:1},prevCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:0,divisor:1},aCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:8,divisor:1},bCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:16,divisor:1},nextCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:24,divisor:1}}},n))}catch(t){e=a}return{fill:t({primitive:"triangle",elements:function(t,e){return e.triangles},offset:0,vert:o(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec2 position, positionFract;\n\nuniform vec4 color;\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio, id;\nuniform vec4 viewport;\nuniform float opacity;\n\nvarying vec4 fragColor;\n\nconst float MAX_LINES = 256.;\n\nvoid main() {\n\tfloat depth = (MAX_LINES - 4. - id) / (MAX_LINES);\n\n\tvec2 position = position * scale + translate\n + positionFract * scale + translateFract\n + position * scaleFract\n + positionFract * scaleFract;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tfragColor = color / 255.;\n\tfragColor.a *= opacity;\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n\tgl_FragColor = fragColor;\n}\n"]),uniforms:{scale:t.prop("scale"),color:t.prop("fill"),scaleFract:t.prop("scaleFract"),translateFract:t.prop("translateFract"),translate:t.prop("translate"),opacity:t.prop("opacity"),pixelRatio:t.context("pixelRatio"),id:t.prop("id"),viewport:function(t,e){return[e.viewport.x,e.viewport.y,t.viewportWidth,t.viewportHeight]}},attributes:{position:{buffer:t.prop("positionBuffer"),stride:8,offset:8},positionFract:{buffer:t.prop("positionFractBuffer"),stride:8,offset:8}},blend:n.blend,depth:{enable:!1},scissor:n.scissor,stencil:n.stencil,viewport:n.viewport}),rect:a,miter:e}},v.defaults={dashes:null,join:"miter",miterLimit:1,thickness:10,cap:"square",color:"black",opacity:1,overlay:!1,viewport:null,range:null,close:!1,fill:null},v.prototype.render=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];e.length&&(t=this).update.apply(t,e),this.draw()},v.prototype.draw=function(){for(var t=this,e=[],r=arguments.length;r--;)e[r]=arguments[r];return(e.length?e:this.passes).forEach(function(e,r){var n;if(e&&Array.isArray(e))return(n=t).draw.apply(n,e);"number"==typeof e&&(e=t.passes[e]),e&&e.count>1&&e.opacity&&(t.regl._refresh(),e.fill&&e.triangles&&e.triangles.length>2&&t.shaders.fill(e),e.thickness&&(e.scale[0]*e.viewport.width>v.precisionThreshold||e.scale[1]*e.viewport.height>v.precisionThreshold?t.shaders.rect(e):"rect"===e.join||!e.join&&(e.thickness<=2||e.count>=v.maxPoints)?t.shaders.rect(e):t.shaders.miter(e)))}),this},v.prototype.update=function(t){var e=this;if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var r=this.regl,o=this.gl;if(t.forEach(function(t,f){var p=e.passes[f];if(void 0!==t)if(null!==t){if("number"==typeof t[0]&&(t={positions:t}),t=s(t,{positions:"positions points data coords",thickness:"thickness lineWidth lineWidths line-width linewidth width stroke-width strokewidth strokeWidth",join:"lineJoin linejoin join type mode",miterLimit:"miterlimit miterLimit",dashes:"dash dashes dasharray dash-array dashArray",color:"color colour stroke colors colours stroke-color strokeColor",fill:"fill fill-color fillColor",opacity:"alpha opacity",overlay:"overlay crease overlap intersect",close:"closed close closed-path closePath",range:"range dataBox",viewport:"viewport viewBox",hole:"holes hole hollow"}),p||(e.passes[f]=p={id:f,scale:null,scaleFract:null,translate:null,translateFract:null,count:0,hole:[],depth:0,dashLength:1,dashTexture:r.texture({channels:1,data:new Uint8Array([255]),width:1,height:1,mag:"linear",min:"linear"}),colorBuffer:r.buffer({usage:"dynamic",type:"uint8",data:new Uint8Array}),positionBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array}),positionFractBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array})},t=i({},v.defaults,t)),null!=t.thickness&&(p.thickness=parseFloat(t.thickness)),null!=t.opacity&&(p.opacity=parseFloat(t.opacity)),null!=t.miterLimit&&(p.miterLimit=parseFloat(t.miterLimit)),null!=t.overlay&&(p.overlay=!!t.overlay,f 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]),l.vert=c(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]),p&&(l.frag=l.frag.replace("smoothstep","smoothStep"),s.frag=s.frag.replace("smoothstep","smoothStep")),this.drawCircle=t(l)}y.defaults={color:"black",borderColor:"transparent",borderSize:0,size:12,opacity:1,marker:void 0,viewport:null,range:null,pixelSize:null,count:0,offset:0,bounds:null,positions:[],snap:1e4},y.prototype.render=function(){return arguments.length&&this.update.apply(this,arguments),this.draw(),this},y.prototype.draw=function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;nn)?e.tree=l(t,{bounds:f}):n&&n.length&&(e.tree=n),e.tree){var h={primitive:"points",usage:"static",data:e.tree,type:"uint32"};e.elements?e.elements(h):e.elements=s.elements(h)}return a({data:g.float(t),usage:"dynamic"}),i({data:g.fract(t),usage:"dynamic"}),u({data:new Uint8Array(c),type:"uint8",usage:"stream"}),t}},{marker:function(e,r,n){var a=r.activation;if(a.forEach(function(t){return t&&t.destroy&&t.destroy()}),a.length=0,e&&"number"!=typeof e[0]){for(var i=[],o=0,l=Math.min(e.length,r.count);o=0)return i;if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)e=t;else{e=new Uint8Array(t.length);for(var o=0,s=t.length;o4*n&&(this.tooManyColors=!0),this.updatePalette(r),1===a.length?a[0]:a},y.prototype.updatePalette=function(t){if(!this.tooManyColors){var e=this.maxColors,r=this.paletteTexture,n=Math.ceil(.25*t.length/e);if(n>1)for(var a=.25*(t=t.slice()).length%e;a2?(s[0],s[2],n=s[1],a=s[3]):s.length?(n=s[0],a=s[1]):(s.x,n=s.y,s.x+s.width,a=s.y+s.height),l.length>2?(i=l[0],o=l[2],l[1],l[3]):l.length?(i=l[0],o=l[1]):(i=l.x,l.y,o=l.x+l.width,l.y+l.height),[i,n,o,a]}function d(t){if("number"==typeof t)return[t,t,t,t];if(2===t.length)return[t[0],t[1],t[0],t[1]];var e=l(t);return[e.x,e.y,e.x+e.width,e.y+e.height]}e.exports=c,c.prototype.render=function(){for(var t,e=this,r=[],n=arguments.length;n--;)r[n]=arguments[n];return r.length&&(t=this).update.apply(t,r),this.regl.attributes.preserveDrawingBuffer?this.draw():(this.dirty?null==this.planned&&(this.planned=o(function(){e.draw(),e.dirty=!0,e.planned=null})):(this.draw(),this.dirty=!0,o(function(){e.dirty=!1})),this)},c.prototype.update=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e.length){for(var n=0;nk))&&(s.lower||!(A>>=e))<<3,(e|=r=(15<(t>>>=r))<<2)|(r=(3<(t>>>=r))<<1)|t>>>r>>1}function s(){function t(t){t:{for(var e=16;268435456>=e;e*=16)if(t<=e){t=e;break t}t=0}return 0<(e=r[o(t)>>2]).length?e.pop():new ArrayBuffer(t)}function e(t){r[o(t.byteLength)>>2].push(t)}var r=i(8,function(){return[]});return{alloc:t,free:e,allocType:function(e,r){var n=null;switch(e){case 5120:n=new Int8Array(t(r),0,r);break;case 5121:n=new Uint8Array(t(r),0,r);break;case 5122:n=new Int16Array(t(2*r),0,r);break;case 5123:n=new Uint16Array(t(2*r),0,r);break;case 5124:n=new Int32Array(t(4*r),0,r);break;case 5125:n=new Uint32Array(t(4*r),0,r);break;case 5126:n=new Float32Array(t(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(t){e(t.buffer)}}}function l(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||W(t.data))}function u(t,e,r,n,a,i){for(var o=0;o(a=s)&&(a=n.buffer.byteLength,5123===f?a>>=1:5125===f&&(a>>=2)),n.vertCount=a,a=o,0>o&&(a=4,1===(o=n.buffer.dimension)&&(a=0),2===o&&(a=1),3===o&&(a=4)),n.primType=a}function o(t){n.elementsCount--,delete s[t.id],t.buffer.destroy(),t.buffer=null}var s={},u=0,c={uint8:5121,uint16:5123};e.oes_element_index_uint&&(c.uint32=5125),a.prototype.bind=function(){this.buffer.bind()};var f=[];return{create:function(t,e){function s(t){if(t)if("number"==typeof t)u(t),f.primType=4,f.vertCount=0|t,f.type=5121;else{var e=null,r=35044,n=-1,a=-1,o=0,h=0;Array.isArray(t)||W(t)||l(t)?e=t:("data"in t&&(e=t.data),"usage"in t&&(r=$[t.usage]),"primitive"in t&&(n=rt[t.primitive]),"count"in t&&(a=0|t.count),"type"in t&&(h=c[t.type]),"length"in t?o=0|t.length:(o=a,5123===h||5122===h?o*=2:5125!==h&&5124!==h||(o*=4))),i(f,e,r,n,a,o,h)}else u(),f.primType=4,f.vertCount=0,f.type=5121;return s}var u=r.create(null,34963,!0),f=new a(u._buffer);return n.elementsCount++,s(t),s._reglType="elements",s._elements=f,s.subdata=function(t,e){return u.subdata(t,e),s},s.destroy=function(){o(f)},s},createStream:function(t){var e=f.pop();return e||(e=new a(r.create(null,34963,!0,!1)._buffer)),i(e,t,35040,-1,-1,0,0),e},destroyStream:function(t){f.push(t)},getElements:function(t){return"function"==typeof t&&t._elements instanceof a?t._elements:null},clear:function(){Y(s).forEach(o)}}}function g(t){for(var e=G.allocType(5123,t.length),r=0;r>>31<<15,a=(i<<1>>>24)-127,i=i>>13&1023;e[r]=-24>a?n:-14>a?n+(i+1024>>-14-a):15>=a,r.height>>=a,d(r,n[a]),t.mipmask|=1<e;++e)t.images[e]=null;return t}function L(t){for(var e=t.images,r=0;re){for(var r=0;r=--this.refCount&&F(this)}}),o.profile&&(i.getTotalTextureSize=function(){var t=0;return Object.keys(mt).forEach(function(e){t+=mt[e].stats.size}),t}),{create2D:function(e,r){function n(t,e){var r=a.texInfo;O.call(r);var i=S();return"number"==typeof t?M(i,0|t,"number"==typeof e?0|e:0|t):t?(D(r,t),E(i,t)):M(i,1,1),r.genMipmaps&&(i.mipmask=(i.width<<1)-1),a.mipmask=i.mipmask,u(a,i),a.internalformat=i.internalformat,n.width=i.width,n.height=i.height,I(a),C(i,3553),R(r,3553),z(),L(i),o.profile&&(a.stats.size=A(a.internalformat,a.type,i.width,i.height,r.genMipmaps,!1)),n.format=tt[a.internalformat],n.type=et[a.type],n.mag=rt[r.magFilter],n.min=nt[r.minFilter],n.wrapS=at[r.wrapS],n.wrapT=at[r.wrapT],n}var a=new P(3553);return mt[a.id]=a,i.textureCount++,n(e,r),n.subimage=function(t,e,r,i){e|=0,r|=0,i|=0;var o=m();return u(o,a),o.width=0,o.height=0,d(o,t),o.width=o.width||(a.width>>i)-e,o.height=o.height||(a.height>>i)-r,I(a),p(o,3553,e,r,i),z(),k(o),n},n.resize=function(e,r){var i=0|e,s=0|r||i;if(i===a.width&&s===a.height)return n;n.width=a.width=i,n.height=a.height=s,I(a);for(var l,u=a.channels,c=a.type,f=0;a.mipmask>>f;++f){var h=i>>f,d=s>>f;if(!h||!d)break;l=G.zero.allocType(c,h*d*u),t.texImage2D(3553,f,a.format,h,d,0,a.format,a.type,l),l&&G.zero.freeType(l)}return z(),o.profile&&(a.stats.size=A(a.internalformat,a.type,i,s,!1,!1)),n},n._reglType="texture2d",n._texture=a,o.profile&&(n.stats=a.stats),n.destroy=function(){a.decRef()},n},createCube:function(e,r,n,a,s,l){function f(t,e,r,n,a,i){var s,l=h.texInfo;for(O.call(l),s=0;6>s;++s)g[s]=S();if("number"!=typeof t&&t){if("object"==typeof t)if(e)E(g[0],t),E(g[1],e),E(g[2],r),E(g[3],n),E(g[4],a),E(g[5],i);else if(D(l,t),c(h,t),"faces"in t)for(t=t.faces,s=0;6>s;++s)u(g[s],h),E(g[s],t[s]);else for(s=0;6>s;++s)E(g[s],t)}else for(t=0|t||1,s=0;6>s;++s)M(g[s],t,t);for(u(h,g[0]),h.mipmask=l.genMipmaps?(g[0].width<<1)-1:g[0].mipmask,h.internalformat=g[0].internalformat,f.width=g[0].width,f.height=g[0].height,I(h),s=0;6>s;++s)C(g[s],34069+s);for(R(l,34067),z(),o.profile&&(h.stats.size=A(h.internalformat,h.type,f.width,f.height,l.genMipmaps,!0)),f.format=tt[h.internalformat],f.type=et[h.type],f.mag=rt[l.magFilter],f.min=nt[l.minFilter],f.wrapS=at[l.wrapS],f.wrapT=at[l.wrapT],s=0;6>s;++s)L(g[s]);return f}var h=new P(34067);mt[h.id]=h,i.cubeCount++;var g=Array(6);return f(e,r,n,a,s,l),f.subimage=function(t,e,r,n,a){r|=0,n|=0,a|=0;var i=m();return u(i,h),i.width=0,i.height=0,d(i,e),i.width=i.width||(h.width>>a)-r,i.height=i.height||(h.height>>a)-n,I(h),p(i,34069+t,r,n,a),z(),k(i),f},f.resize=function(e){if((e|=0)!==h.width){f.width=h.width=e,f.height=h.height=e,I(h);for(var r=0;6>r;++r)for(var n=0;h.mipmask>>n;++n)t.texImage2D(34069+r,n,h.format,e>>n,e>>n,0,h.format,h.type,null);return z(),o.profile&&(h.stats.size=A(h.internalformat,h.type,f.width,f.height,!1,!0)),f}},f._reglType="textureCube",f._texture=h,o.profile&&(f.stats=h.stats),f.destroy=function(){h.decRef()},f},clear:function(){for(var e=0;er;++r)if(0!=(e.mipmask&1<>r,e.height>>r,0,e.internalformat,e.type,null);else for(var n=0;6>n;++n)t.texImage2D(34069+n,r,e.internalformat,e.width>>r,e.height>>r,0,e.internalformat,e.type,null);R(e.texInfo,e.target)})}}}function T(t,e,r,n,a,i){function o(t,e,r){this.target=t,this.texture=e,this.renderbuffer=r;var n=t=0;e?(t=e.width,n=e.height):r&&(t=r.width,n=r.height),this.width=t,this.height=n}function s(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function l(t,e,r){t&&(t.texture?t.texture._texture.refCount+=1:t.renderbuffer._renderbuffer.refCount+=1)}function u(e,r){r&&(r.texture?t.framebufferTexture2D(36160,e,r.target,r.texture._texture.texture,0):t.framebufferRenderbuffer(36160,e,36161,r.renderbuffer._renderbuffer.renderbuffer))}function c(t){var e=3553,r=null,n=null,a=t;return"object"==typeof t&&(a=t.data,"target"in t&&(e=0|t.target)),"texture2d"===(t=a._reglType)?r=a:"textureCube"===t?r=a:"renderbuffer"===t&&(n=a,e=36161),new o(e,r,n)}function f(t,e,r,i,s){return r?((t=n.create2D({width:t,height:e,format:i,type:s}))._texture.refCount=0,new o(3553,t,null)):((t=a.create({width:t,height:e,format:i}))._renderbuffer.refCount=0,new o(36161,null,t))}function h(t){return t&&(t.texture||t.renderbuffer)}function d(t,e,r){t&&(t.texture?t.texture.resize(e,r):t.renderbuffer&&t.renderbuffer.resize(e,r),t.width=e,t.height=r)}function p(){this.id=A++,k[this.id]=this,this.framebuffer=t.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function g(t){t.colorAttachments.forEach(s),s(t.depthAttachment),s(t.stencilAttachment),s(t.depthStencilAttachment)}function v(e){t.deleteFramebuffer(e.framebuffer),e.framebuffer=null,i.framebufferCount--,delete k[e.id]}function m(e){var n;t.bindFramebuffer(36160,e.framebuffer);var a=e.colorAttachments;for(n=0;na;++a){for(u=0;ut;++t)r[t].resize(n);return e.width=e.height=n,e},_reglType:"framebufferCube",destroy:function(){r.forEach(function(t){t.destroy()})}})},clear:function(){Y(k).forEach(v)},restore:function(){b.cur=null,b.next=null,b.dirty=!0,Y(k).forEach(function(e){e.framebuffer=t.createFramebuffer(),m(e)})}})}function M(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function E(t,e,r,n){function a(t,e,r,n){this.name=t,this.id=e,this.location=r,this.info=n}function i(t,e){for(var r=0;rt&&(t=e.stats.uniformsCount)}),t},r.getMaxAttributesCount=function(){var t=0;return h.forEach(function(e){e.stats.attributesCount>t&&(t=e.stats.attributesCount)}),t}),{clear:function(){var e=t.deleteShader.bind(t);Y(u).forEach(e),u={},Y(c).forEach(e),c={},h.forEach(function(e){t.deleteProgram(e.program)}),h.length=0,f={},r.shaderCount=0},program:function(t,e,n){var a=f[e];a||(a=f[e]={});var i=a[t];return i||(i=new s(e,t),r.shaderCount++,l(i),a[t]=i,h.push(i)),i},restore:function(){u={},c={};for(var t=0;t"+e+"?"+a+".constant["+e+"]:0;"}).join(""),"}}else{","if(",o,"(",a,".buffer)){",c,"=",s,".createStream(",34962,",",a,".buffer);","}else{",c,"=",s,".getBuffer(",a,".buffer);","}",f,'="type" in ',a,"?",i.glTypes,"[",a,".type]:",c,".dtype;",l.normalized,"=!!",a,".normalized;"),n("size"),n("offset"),n("stride"),n("divisor"),r("}}"),r.exit("if(",l.isStream,"){",s,".destroyStream(",c,");","}"),l})}),o}function T(t,e,r,n,a){var o=_(t),s=function(t,e,r){function n(t){if(t in a){var r=a[t];t=!0;var n,o,s=0|r.x,l=0|r.y;return"width"in r?n=0|r.width:t=!1,"height"in r?o=0|r.height:t=!1,new P(!t&&e&&e.thisDep,!t&&e&&e.contextDep,!t&&e&&e.propDep,function(t,e){var a=t.shared.context,i=n;"width"in r||(i=e.def(a,".","framebufferWidth","-",s));var u=o;return"height"in r||(u=e.def(a,".","framebufferHeight","-",l)),[s,l,i,u]})}if(t in i){var u=i[t];return t=F(u,function(t,e){var r=t.invoke(e,u),n=t.shared.context,a=e.def(r,".x|0"),i=e.def(r,".y|0");return[a,i,e.def('"width" in ',r,"?",r,".width|0:","(",n,".","framebufferWidth","-",a,")"),r=e.def('"height" in ',r,"?",r,".height|0:","(",n,".","framebufferHeight","-",i,")")]}),e&&(t.thisDep=t.thisDep||e.thisDep,t.contextDep=t.contextDep||e.contextDep,t.propDep=t.propDep||e.propDep),t}return e?new P(e.thisDep,e.contextDep,e.propDep,function(t,e){var r=t.shared.context;return[0,0,e.def(r,".","framebufferWidth"),e.def(r,".","framebufferHeight")]}):null}var a=t.static,i=t.dynamic;if(t=n("viewport")){var o=t;t=new P(t.thisDep,t.contextDep,t.propDep,function(t,e){var r=o.append(t,e),n=t.shared.context;return e.set(n,".viewportWidth",r[2]),e.set(n,".viewportHeight",r[3]),r})}return{viewport:t,scissor_box:n("scissor.box")}}(t,o),l=A(t),u=function(t,e){var r=t.static,n=t.dynamic,a={};return nt.forEach(function(t){function e(e,i){if(t in r){var s=e(r[t]);a[o]=z(function(){return s})}else if(t in n){var l=n[t];a[o]=F(l,function(t,e){return i(t,e,t.invoke(e,l))})}}var o=m(t);switch(t){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":return e(function(t){return t},function(t,e,r){return r});case"depth.func":return e(function(t){return At[t]},function(t,e,r){return e.def(t.constants.compareFuncs,"[",r,"]")});case"depth.range":return e(function(t){return t},function(t,e,r){return[e.def("+",r,"[0]"),e=e.def("+",r,"[1]")]});case"blend.func":return e(function(t){return[wt["srcRGB"in t?t.srcRGB:t.src],wt["dstRGB"in t?t.dstRGB:t.dst],wt["srcAlpha"in t?t.srcAlpha:t.src],wt["dstAlpha"in t?t.dstAlpha:t.dst]]},function(t,e,r){function n(t,n){return e.def('"',t,n,'" in ',r,"?",r,".",t,n,":",r,".",t)}t=t.constants.blendFuncs;var a=n("src","RGB"),i=n("dst","RGB"),o=(a=e.def(t,"[",a,"]"),e.def(t,"[",n("src","Alpha"),"]"));return[a,i=e.def(t,"[",i,"]"),o,t=e.def(t,"[",n("dst","Alpha"),"]")]});case"blend.equation":return e(function(t){return"string"==typeof t?[J[t],J[t]]:"object"==typeof t?[J[t.rgb],J[t.alpha]]:void 0},function(t,e,r){var n=t.constants.blendEquations,a=e.def(),i=e.def();return(t=t.cond("typeof ",r,'==="string"')).then(a,"=",i,"=",n,"[",r,"];"),t.else(a,"=",n,"[",r,".rgb];",i,"=",n,"[",r,".alpha];"),e(t),[a,i]});case"blend.color":return e(function(t){return i(4,function(e){return+t[e]})},function(t,e,r){return i(4,function(t){return e.def("+",r,"[",t,"]")})});case"stencil.mask":return e(function(t){return 0|t},function(t,e,r){return e.def(r,"|0")});case"stencil.func":return e(function(t){return[At[t.cmp||"keep"],t.ref||0,"mask"in t?t.mask:-1]},function(t,e,r){return[t=e.def('"cmp" in ',r,"?",t.constants.compareFuncs,"[",r,".cmp]",":",7680),e.def(r,".ref|0"),e=e.def('"mask" in ',r,"?",r,".mask|0:-1")]});case"stencil.opFront":case"stencil.opBack":return e(function(e){return["stencil.opBack"===t?1029:1028,kt[e.fail||"keep"],kt[e.zfail||"keep"],kt[e.zpass||"keep"]]},function(e,r,n){function a(t){return r.def('"',t,'" in ',n,"?",i,"[",n,".",t,"]:",7680)}var i=e.constants.stencilOps;return["stencil.opBack"===t?1029:1028,a("fail"),a("zfail"),a("zpass")]});case"polygonOffset.offset":return e(function(t){return[0|t.factor,0|t.units]},function(t,e,r){return[e.def(r,".factor|0"),e=e.def(r,".units|0")]});case"cull.face":return e(function(t){var e=0;return"front"===t?e=1028:"back"===t&&(e=1029),e},function(t,e,r){return e.def(r,'==="front"?',1028,":",1029)});case"lineWidth":return e(function(t){return t},function(t,e,r){return r});case"frontFace":return e(function(t){return Tt[t]},function(t,e,r){return e.def(r+'==="cw"?2304:2305')});case"colorMask":return e(function(t){return t.map(function(t){return!!t})},function(t,e,r){return i(4,function(t){return"!!"+r+"["+t+"]"})});case"sample.coverage":return e(function(t){return["value"in t?t.value:1,!!t.invert]},function(t,e,r){return[e.def('"value" in ',r,"?+",r,".value:1"),e=e.def("!!",r,".invert")]})}}),a}(t),c=w(t),f=s.viewport;return f&&(u.viewport=f),(s=s[f=m("scissor.box")])&&(u[f]=s),(o={framebuffer:o,draw:l,shader:c,state:u,dirty:s=0>1)",s],");")}function e(){r(l,".drawArraysInstancedANGLE(",[p,g,v,s],");")}d?y?t():(r("if(",d,"){"),t(),r("}else{"),e(),r("}")):e()}function o(){function t(){r(c+".drawElements("+[p,v,m,g+"<<(("+m+"-5121)>>1)"]+");")}function e(){r(c+".drawArrays("+[p,g,v]+");")}d?y?t():(r("if(",d,"){"),t(),r("}else{"),e(),r("}")):e()}var s,l,u=t.shared,c=u.gl,f=u.draw,h=n.draw,d=function(){var a=h.elements,i=e;return a?((a.contextDep&&n.contextDynamic||a.propDep)&&(i=r),a=a.append(t,i)):a=i.def(f,".","elements"),a&&i("if("+a+")"+c+".bindBuffer(34963,"+a+".buffer.buffer);"),a}(),p=a("primitive"),g=a("offset"),v=function(){var a=h.count,i=e;return a?((a.contextDep&&n.contextDynamic||a.propDep)&&(i=r),a=a.append(t,i)):a=i.def(f,".","count"),a}();if("number"==typeof v){if(0===v)return}else r("if(",v,"){"),r.exit("}");$&&(s=a("instances"),l=t.instancing);var m=d+".type",y=h.elements&&I(h.elements);$&&("number"!=typeof s||0<=s)?"string"==typeof s?(r("if(",s,">0){"),i(),r("}else if(",s,"<0){"),o(),r("}")):i():o()}function V(t,e,r,n,a){return a=(e=x()).proc("body",a),$&&(e.instancing=a.def(e.shared.extensions,".angle_instanced_arrays")),t(e,a,r,n),e.compile().body}function q(t,e,r,n){L(t,e),B(t,e,r,n.attributes,function(){return!0}),j(t,e,r,n.uniforms,function(){return!0}),U(t,e,e,r)}function G(t,e,r,n){function a(){return!0}t.batchId="a1",L(t,e),B(t,e,r,n.attributes,a),j(t,e,r,n.uniforms,a),U(t,e,e,r)}function X(t,e,r,n){function a(t){return t.contextDep&&o||t.propDep}function i(t){return!a(t)}L(t,e);var o=r.contextDep,s=e.def(),l=e.def();t.shared.props=l,t.batchId=s;var u=t.scope(),c=t.scope();e(u.entry,"for(",s,"=0;",s,"<","a1",";++",s,"){",l,"=","a0","[",s,"];",c,"}",u.exit),r.needsContext&&M(t,c,r.context),r.needsFramebuffer&&E(t,c,r.framebuffer),S(t,c,r.state,a),r.profile&&a(r.profile)&&N(t,c,r,!1,!0),n?(B(t,u,r,n.attributes,i),B(t,c,r,n.attributes,a),j(t,u,r,n.uniforms,i),j(t,c,r,n.uniforms,a),U(t,u,c,r)):(e=t.global.def("{}"),n=r.shader.progVar.append(t,c),l=c.def(n,".id"),u=c.def(e,"[",l,"]"),c(t.shared.gl,".useProgram(",n,".program);","if(!",u,"){",u,"=",e,"[",l,"]=",t.link(function(e){return V(G,t,r,e,2)}),"(",n,");}",u,".call(this,a0[",s,"],",s,");"))}function W(t,r){function n(e){var n=r.shader[e];n&&a.set(i.shader,"."+e,n.append(t,a))}var a=t.proc("scope",3);t.batchId="a2";var i=t.shared,o=i.current;M(t,a,r.context),r.framebuffer&&r.framebuffer.append(t,a),R(Object.keys(r.state)).forEach(function(e){var n=r.state[e].append(t,a);v(n)?n.forEach(function(r,n){a.set(t.next[e],"["+n+"]",r)}):a.set(i.next,"."+e,n)}),N(t,a,r,!0,!0),["elements","offset","count","instances","primitive"].forEach(function(e){var n=r.draw[e];n&&a.set(i.draw,"."+e,""+n.append(t,a))}),Object.keys(r.uniforms).forEach(function(n){a.set(i.uniforms,"["+e.id(n)+"]",r.uniforms[n].append(t,a))}),Object.keys(r.attributes).forEach(function(e){var n=r.attributes[e].append(t,a),i=t.scopeAttrib(e);Object.keys(new Z).forEach(function(t){a.set(i,"."+t,n[t])})}),n("vert"),n("frag"),0=--this.refCount&&o(this)},a.profile&&(n.getTotalRenderbufferSize=function(){var t=0;return Object.keys(c).forEach(function(e){t+=c[e].stats.size}),t}),{create:function(e,r){function o(e,r){var n=0,i=0,c=32854;if("object"==typeof e&&e?("shape"in e?(n=0|(i=e.shape)[0],i=0|i[1]):("radius"in e&&(n=i=0|e.radius),"width"in e&&(n=0|e.width),"height"in e&&(i=0|e.height)),"format"in e&&(c=s[e.format])):"number"==typeof e?(n=0|e,i="number"==typeof r?0|r:n):e||(n=i=1),n!==u.width||i!==u.height||c!==u.format)return o.width=u.width=n,o.height=u.height=i,u.format=c,t.bindRenderbuffer(36161,u.renderbuffer),t.renderbufferStorage(36161,c,n,i),a.profile&&(u.stats.size=vt[u.format]*u.width*u.height),o.format=l[u.format],o}var u=new i(t.createRenderbuffer());return c[u.id]=u,n.renderbufferCount++,o(e,r),o.resize=function(e,r){var n=0|e,i=0|r||n;return n===u.width&&i===u.height?o:(o.width=u.width=n,o.height=u.height=i,t.bindRenderbuffer(36161,u.renderbuffer),t.renderbufferStorage(36161,u.format,n,i),a.profile&&(u.stats.size=vt[u.format]*u.width*u.height),o)},o._reglType="renderbuffer",o._renderbuffer=u,a.profile&&(o.stats=u.stats),o.destroy=function(){u.decRef()},o},clear:function(){Y(c).forEach(o)},restore:function(){Y(c).forEach(function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,e.renderbuffer),t.renderbufferStorage(36161,e.format,e.width,e.height)}),t.bindRenderbuffer(36161,null)}}},yt=[];yt[6408]=4,yt[6407]=3;var bt=[];bt[5121]=1,bt[5126]=4,bt[36193]=2;var xt=["x","y","z","w"],_t="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),wt={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},At={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},kt={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Tt={cw:2304,ccw:2305},Mt=new P(!1,!1,!1,function(){});return function(t){function e(){if(0===Z.length)w&&w.update(),K=null;else{K=V.next(e),f();for(var t=Z.length-1;0<=t;--t){var r=Z[t];r&&r(O,null,0)}v.flush(),w&&w.update()}}function r(){!K&&0=Z.length&&n()}}}}function c(){var t=W.viewport,e=W.scissor_box;t[0]=t[1]=e[0]=e[1]=0,O.viewportWidth=O.framebufferWidth=O.drawingBufferWidth=t[2]=e[2]=v.drawingBufferWidth,O.viewportHeight=O.framebufferHeight=O.drawingBufferHeight=t[3]=e[3]=v.drawingBufferHeight}function f(){O.tick+=1,O.time=g(),c(),G.procs.poll()}function h(){c(),G.procs.refresh(),w&&w.update()}function g(){return(q()-A)/1e3}if(!(t=a(t)))return null;var v=t.gl,m=v.getContextAttributes();v.isContextLost();var y=function(t,e){function r(e){var r;e=e.toLowerCase();try{r=n[e]=t.getExtension(e)}catch(t){}return!!r}for(var n={},a=0;ae;++e)tt(j({framebuffer:t.framebuffer.faces[e]},t),l);else tt(t,l);else l(0,t)},prop:H.define.bind(null,1),context:H.define.bind(null,2),this:H.define.bind(null,3),draw:s({}),buffer:function(t){return R.create(t,34962,!1,!1)},elements:function(t){return P.create(t,!1)},texture:z.create2D,cube:z.createCube,renderbuffer:F.create,framebuffer:U.create,framebufferCube:U.createCube,attributes:m,frame:u,on:function(t,e){var r;switch(t){case"frame":return u(e);case"lost":r=J;break;case"restore":r=Q;break;case"destroy":r=$}return r.push(e),{cancel:function(){for(var t=0;t=r)return a.substr(0,r);for(;r>a.length&&e>1;)1&e&&(a+=t),e>>=1,t+=t;return a=(a+=t).substr(0,r)}},{}],261:[function(t,e,r){"use strict";var n=t("two-product"),a=t("robust-sum"),i=t("robust-subtract"),o=t("robust-scale"),s=6;function l(t,e){for(var r=new Array(t.length-1),n=1;n>1;return["sum(",u(t.slice(0,e)),",",u(t.slice(e)),")"].join("")}function c(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return c(e,t)}function f(t){if(2===t.length)return[["diff(",c(t[0][0],t[1][1]),",",c(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r>1;return["sum(",u(t.slice(0,e)),",",u(t.slice(e)),")"].join("")}function c(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(i<=0)return o;n=a+i}else{if(!(a<0))return o;if(i>=0)return o;n=-(a+i)}var s=3.3306690738754716e-16*n;return o>=s||o<=-s?o:h(t,e,r)},function(t,e,r,n){var a=t[0]-n[0],i=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],u=r[1]-n[1],c=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],p=i*u,g=o*l,v=o*s,m=a*u,y=a*l,b=i*s,x=c*(p-g)+f*(v-m)+h*(y-b),_=7.771561172376103e-16*((Math.abs(p)+Math.abs(g))*Math.abs(c)+(Math.abs(v)+Math.abs(m))*Math.abs(f)+(Math.abs(y)+Math.abs(b))*Math.abs(h));return x>_||-x>_?x:d(t,e,r,n)}];!function(){for(;p.length<=s;)p.push(f(p.length));for(var t=[],r=["slow"],n=0;n<=s;++n)t.push("a"+n),r.push("o"+n);var a=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(n=2;n<=s;++n)a.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");a.push("}var s=new Array(arguments.length);for(var i=0;i0&&o>0||i<0&&o<0)return!1;var s=n(r,t,e),l=n(a,t,e);if(s>0&&l>0||s<0&&l<0)return!1;if(0===i&&0===o&&0===s&&0===l)return function(t,e,r,n){for(var a=0;a<2;++a){var i=t[a],o=e[a],s=Math.min(i,o),l=Math.max(i,o),u=r[a],c=n[a],f=Math.min(u,c),h=Math.max(u,c);if(h=n?(a=f,(l+=1)=n?(a=f,(l+=1)0?1:0}},{}],269:[function(t,e,r){arguments[4][39][0].apply(r,arguments)},{dup:39}],270:[function(t,e,r){"use strict";var n=t("bit-twiddle"),a=t("union-find");function i(t,e){var r=t.length,n=t.length-e.length,a=Math.min;if(n)return n;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return(s=t[0]+t[1]-e[0]-e[1])||a(t[0],t[1])-a(e[0],e[1]);case 3:var i=t[0]+t[1],o=e[0]+e[1];if(s=i+t[2]-(o+e[2]))return s;var s,l=a(t[0],t[1]),u=a(e[0],e[1]);return(s=a(l,t[2])-a(u,e[2]))||a(l+t[2],i)-a(u+e[2],o);default:var c=t.slice(0);c.sort();var f=e.slice(0);f.sort();for(var h=0;h>1,s=i(t[o],e);s<=0?(0===s&&(a=o),r=o+1):s>0&&(n=o-1)}return a}function c(t,e){for(var r=new Array(t.length),a=0,o=r.length;a=t.length||0!==i(t[v],s)););}return r}function f(t,e){if(e<0)return[];for(var r=[],a=(1<>>c&1&&u.push(a[c]);e.push(u)}return s(e)},r.skeleton=f,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function b(t){for(var e=m(t);;){var r=e,n=2*t+1,a=2*(t+1),i=t;if(n0;){var r=y(t);if(r>=0){var n=m(r);if(e0){var t=k[0];return v(0,E-1),E-=1,b(0),t}return-1}function w(t,e){var r=k[t];return u[r]===e?t:(u[r]=-1/0,x(t),_(),u[r]=e,x((E+=1)-1))}function A(t){if(!c[t]){c[t]=!0;var e=s[t],r=l[t];s[r]>=0&&(s[r]=e),l[e]>=0&&(l[e]=r),T[e]>=0&&w(T[e],g(e)),T[r]>=0&&w(T[r],g(r))}}for(var k=[],T=new Array(i),f=0;f>1;f>=0;--f)b(f);for(;;){var C=_();if(C<0||u[C]>r)break;A(C)}for(var S=[],f=0;f=0&&r>=0&&e!==r){var n=T[e],a=T[r];n!==a&&O.push([n,a])}}),a.unique(a.normalize(O)),{positions:S,edges:O}};var n=t("robust-orientation"),a=t("simplicial-complex")},{"robust-orientation":262,"simplicial-complex":270}],273:[function(t,e,r){"use strict";e.exports=function(t,e){var r,i,o,s;if(e[0][0]e[1][0]))return a(e,t);r=e[1],i=e[0]}if(t[0][0]t[1][0]))return-a(t,e);o=t[1],s=t[0]}var l=n(r,i,s),u=n(r,i,o);if(l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;if(l=n(s,o,i),u=n(s,o,r),l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;return i[0]-s[0]};var n=t("robust-orientation");function a(t,e){var r,a,i,o;if(e[0][0]e[1][0])){var s=Math.min(t[0][1],t[1][1]),l=Math.max(t[0][1],t[1][1]),u=Math.min(e[0][1],e[1][1]),c=Math.max(e[0][1],e[1][1]);return lc?s-c:l-c}r=e[1],a=e[0]}t[0][1]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=u(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=u(t.right,e))return l;t=t.left}}return r}function c(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function f(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}s.prototype.castUp=function(t){var e=n.le(this.coordinates,t[0]);if(e<0)return-1;this.slabs[e];var r=u(this.slabs[e],t),a=-1;if(r&&(a=r.value),this.coordinates[e]===t[0]){var s=null;if(r&&(s=r.key),e>0){var c=u(this.slabs[e-1],t);c&&(s?o(c.key,s)>0&&(s=c.key,a=c.value):(a=c.value,s=c.key))}var f=this.horizontal[e];if(f.length>0){var h=n.ge(f,t[1],l);if(h=f.length)return a;d=f[h]}}if(d.start)if(s){var p=i(s[0],s[1],[t[0],d.y]);s[0][0]>s[1][0]&&(p=-p),p>0&&(a=d.index)}else a=d.index;else d.y!==t[1]&&(a=d.index)}}}return a}},{"./lib/order-segments":273,"binary-search-bounds":38,"functional-red-black-tree":153,"robust-orientation":262}],275:[function(t,e,r){!function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function e(r){return function(r,n){var a,i,o,s,l,u,c,f,h,d=1,p=r.length,g="";for(i=0;i=0),s[8]){case"b":a=parseInt(a,10).toString(2);break;case"c":a=String.fromCharCode(parseInt(a,10));break;case"d":case"i":a=parseInt(a,10);break;case"j":a=JSON.stringify(a,null,s[6]?parseInt(s[6]):0);break;case"e":a=s[7]?parseFloat(a).toExponential(s[7]):parseFloat(a).toExponential();break;case"f":a=s[7]?parseFloat(a).toFixed(s[7]):parseFloat(a);break;case"g":a=s[7]?String(Number(a.toPrecision(s[7]))):parseFloat(a);break;case"o":a=(parseInt(a,10)>>>0).toString(8);break;case"s":a=String(a),a=s[7]?a.substring(0,s[7]):a;break;case"t":a=String(!!a),a=s[7]?a.substring(0,s[7]):a;break;case"T":a=Object.prototype.toString.call(a).slice(8,-1).toLowerCase(),a=s[7]?a.substring(0,s[7]):a;break;case"u":a=parseInt(a,10)>>>0;break;case"v":a=a.valueOf(),a=s[7]?a.substring(0,s[7]):a;break;case"x":a=(parseInt(a,10)>>>0).toString(16);break;case"X":a=(parseInt(a,10)>>>0).toString(16).toUpperCase()}t.json.test(s[8])?g+=a:(!t.number.test(s[8])||f&&!s[3]?h="":(h=f?"+":"-",a=a.toString().replace(t.sign,"")),u=s[4]?"0"===s[4]?"0":s[4].charAt(1):" ",c=s[6]-(h+a).length,l=s[6]&&c>0?u.repeat(c):"",g+=s[5]?h+a+l:"0"===u?h+l+a:l+h+a)}return g}(function(e){if(a[e])return a[e];var r,n=e,i=[],o=0;for(;n;){if(null!==(r=t.text.exec(n)))i.push(r[0]);else if(null!==(r=t.modulo.exec(n)))i.push("%");else{if(null===(r=t.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){o|=1;var s=[],l=r[2],u=[];if(null===(u=t.key.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(l=l.substring(u[0].length));)if(null!==(u=t.key_access.exec(l)))s.push(u[1]);else{if(null===(u=t.index_access.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}r[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");i.push(r)}n=n.substring(r[0].length)}return a[e]=i}(r),arguments)}function n(t,r){return e.apply(null,[t].concat(r||[]))}var a=Object.create(null);"undefined"!=typeof r&&(r.sprintf=e,r.vsprintf=n),"undefined"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}()},{}],276:[function(t,e,r){"use strict";var n=t("parenthesis");e.exports=function(t,e,r){if(null==t)throw Error("First argument should be a string");if(null==e)throw Error("Separator should be a string or a RegExp");r?("string"==typeof r||Array.isArray(r))&&(r={ignore:r}):r={},null==r.escape&&(r.escape=!0),null==r.ignore?r.ignore=["[]","()","{}","<>",'""',"''","``","\u201c\u201d","\xab\xbb"]:("string"==typeof r.ignore&&(r.ignore=[r.ignore]),r.ignore=r.ignore.map(function(t){return 1===t.length&&(t+=t),t}));var a=n.parse(t,{flat:!0,brackets:r.ignore}),i=a[0].split(e);if(r.escape){for(var o=[],s=0;s c)|0 },"),"generic"===e&&i.push("getters:[0],");for(var s=[],l=[],u=0;u>>7){");for(var u=0;u<1<<(1<128&&u%128==0){f.length>0&&h.push("}}");var d="vExtra"+f.length;i.push("case ",u>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&u,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;bb)&&!(u&1<<_)!=!(u&1<0&&(T="+"+v[x]+"*c");var M=p[x].length/y*.5,E=.5+m[x]/y*.5;k.push("d"+x+"-"+E+"-"+M+"*("+p[x].join("+")+T+")/("+g[x].join("+")+")")}h.push("a.push([",k.join(),"]);","break;")}i.push("}},"),f.length>0&&h.push("}}");for(var C=[],u=0;u<1<1&&(i=1),i<-1&&(i=-1),a*Math.acos(i)};r.default=function(t){var e=t.px,r=t.py,l=t.cx,u=t.cy,c=t.rx,f=t.ry,h=t.xAxisRotation,d=void 0===h?0:h,p=t.largeArcFlag,g=void 0===p?0:p,v=t.sweepFlag,m=void 0===v?0:v,y=[];if(0===c||0===f)return[];var b=Math.sin(d*a/360),x=Math.cos(d*a/360),_=x*(e-l)/2+b*(r-u)/2,w=-b*(e-l)/2+x*(r-u)/2;if(0===_&&0===w)return[];c=Math.abs(c),f=Math.abs(f);var A=Math.pow(_,2)/Math.pow(c,2)+Math.pow(w,2)/Math.pow(f,2);A>1&&(c*=Math.sqrt(A),f*=Math.sqrt(A));var k=function(t,e,r,n,i,o,l,u,c,f,h,d){var p=Math.pow(i,2),g=Math.pow(o,2),v=Math.pow(h,2),m=Math.pow(d,2),y=p*g-p*m-g*v;y<0&&(y=0),y/=p*m+g*v;var b=(y=Math.sqrt(y)*(l===u?-1:1))*i/o*d,x=y*-o/i*h,_=f*b-c*x+(t+r)/2,w=c*b+f*x+(e+n)/2,A=(h-b)/i,k=(d-x)/o,T=(-h-b)/i,M=(-d-x)/o,E=s(1,0,A,k),C=s(A,k,T,M);return 0===u&&C>0&&(C-=a),1===u&&C<0&&(C+=a),[_,w,E,C]}(e,r,l,u,c,f,g,m,b,x,_,w),T=n(k,4),M=T[0],E=T[1],C=T[2],S=T[3],L=Math.abs(S)/(a/4);Math.abs(1-L)<1e-7&&(L=1);var O=Math.max(Math.ceil(L),1);S/=O;for(var D=0;De[2]&&(e[2]=u[c+0]),u[c+1]>e[3]&&(e[3]=u[c+1]);return e}},{"abs-svg-path":11,assert:16,"is-svg-path":212,"normalize-svg-path":280,"parse-svg-path":227}],280:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=[],o=0,s=0,l=0,u=0,c=null,f=null,h=0,d=0,p=0,g=t.length;p4?(o=v[v.length-4],s=v[v.length-3]):(o=h,s=d),r.push(v)}return r};var n=t("svg-arc-to-cubic-bezier");function a(t,e,r,n){return["C",t,e,r,n,r,n]}function i(t,e,r,n,a,i){return["C",t/3+2/3*r,e/3+2/3*n,a/3+2/3*r,i/3+2/3*n,a,i]}},{"svg-arc-to-cubic-bezier":278}],281:[function(t,e,r){"use strict";var n,a=t("svg-path-bounds"),i=t("parse-svg-path"),o=t("draw-svg-path"),s=t("is-svg-path"),l=t("bitmap-sdf"),u=document.createElement("canvas"),c=u.getContext("2d");e.exports=function(t,e){if(!s(t))throw Error("Argument should be valid svg path string");e||(e={});var r,f;e.shape?(r=e.shape[0],f=e.shape[1]):(r=u.width=e.w||e.width||200,f=u.height=e.h||e.height||200);var h=Math.min(r,f),d=e.stroke||0,p=e.viewbox||e.viewBox||a(t),g=[r/(p[2]-p[0]),f/(p[3]-p[1])],v=Math.min(g[0]||0,g[1]||0)/2;c.fillStyle="black",c.fillRect(0,0,r,f),c.fillStyle="white",d&&("number"!=typeof d&&(d=1),c.strokeStyle=d>0?"white":"black",c.lineWidth=Math.abs(d));if(c.translate(.5*r,.5*f),c.scale(v,v),function(){if(null!=n)return n;var t=document.createElement("canvas").getContext("2d");if(t.canvas.width=t.canvas.height=1,!window.Path2D)return n=!1;var e=new Path2D("M0,0h1v1h-1v-1Z");t.fillStyle="black",t.fill(e);var r=t.getImageData(0,0,1,1);return n=r&&r.data&&255===r.data[3]}()){var m=new Path2D(t);c.fill(m),d&&c.stroke(m)}else{var y=i(t);o(c,y),c.fill(),d&&c.stroke()}return c.setTransform(1,0,0,1,0,0),l(c,{cutoff:null!=e.cutoff?e.cutoff:.5,radius:null!=e.radius?e.radius:.5*h})}},{"bitmap-sdf":40,"draw-svg-path":89,"is-svg-path":212,"parse-svg-path":227,"svg-path-bounds":279}],282:[function(t,e,r){(function(r){"use strict";e.exports=function t(e,r,a){var a=a||{};var o=i[e];o||(o=i[e]={" ":{data:new Float32Array(0),shape:.2}});var s=o[r];if(!s)if(r.length<=1||!/\d/.test(r))s=o[r]=function(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),a=0,i=0,o=0;o0&&(f+=.02);for(var d=new Float32Array(c),p=0,g=-.5*f,h=0;h1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=L(t,360),e=L(e,100),r=L(r,100),0===e)n=a=i=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;n=o(l,s,t+1/3),a=o(l,s,t),i=o(l,s,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(e.h,l,c),f=!0,h="hsl"),e.hasOwnProperty("a")&&(i=e.a));var d,p,g;return i=S(i),{ok:f,format:e.format||h,r:o(255,s(a.r,0)),g:o(255,s(a.g,0)),b:o(255,s(a.b,0)),a:i}}(e);this._originalInput=e,this._r=c.r,this._g=c.g,this._b=c.b,this._a=c.a,this._roundA=i(100*this._a)/100,this._format=l.format||c.format,this._gradientType=l.gradientType,this._r<1&&(this._r=i(this._r)),this._g<1&&(this._g=i(this._g)),this._b<1&&(this._b=i(this._b)),this._ok=c.ok,this._tc_id=a++}function c(t,e,r){t=L(t,255),e=L(e,255),r=L(r,255);var n,a,i=s(t,e,r),l=o(t,e,r),u=(i+l)/2;if(i==l)n=a=0;else{var c=i-l;switch(a=u>.5?c/(2-i-l):c/(i+l),i){case t:n=(e-r)/c+(e>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(u(n));return i}function M(t,e){e=e||6;for(var r=u(t).toHsv(),n=r.h,a=r.s,i=r.v,o=[],s=1/e;e--;)o.push(u({h:n,s:a,v:i})),i=(i+s)%1;return o}u.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,a=this.toRgb();return e=a.r/255,r=a.g/255,n=a.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=S(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=c(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),n=i(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return h(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,a){var o=[R(i(t).toString(16)),R(i(e).toString(16)),R(i(r).toString(16)),R(I(n))];if(a&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*L(this._r,255))+"%",g:i(100*L(this._g,255))+"%",b:i(100*L(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*L(this._r,255))+"%, "+i(100*L(this._g,255))+"%, "+i(100*L(this._b,255))+"%)":"rgba("+i(100*L(this._r,255))+"%, "+i(100*L(this._g,255))+"%, "+i(100*L(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(C[h(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+d(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=u(t);r="#"+d(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return u(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(m,arguments)},brighten:function(){return this._applyModification(y,arguments)},darken:function(){return this._applyModification(b,arguments)},desaturate:function(){return this._applyModification(p,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(T,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(M,arguments)},splitcomplement:function(){return this._applyCombination(k,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(A,arguments)}},u.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:P(t[n]));t=r}return u(t,e)},u.equals=function(t,e){return!(!t||!e)&&u(t).toRgbString()==u(e).toRgbString()},u.random=function(){return u.fromRatio({r:l(),g:l(),b:l()})},u.mix=function(t,e,r){r=0===r?0:r||50;var n=u(t).toRgb(),a=u(e).toRgb(),i=r/100;return u({r:(a.r-n.r)*i+n.r,g:(a.g-n.g)*i+n.g,b:(a.b-n.b)*i+n.b,a:(a.a-n.a)*i+n.a})},u.readability=function(e,r){var n=u(e),a=u(r);return(t.max(n.getLuminance(),a.getLuminance())+.05)/(t.min(n.getLuminance(),a.getLuminance())+.05)},u.isReadable=function(t,e,r){var n,a,i=u.readability(t,e);switch(a=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":a=i>=4.5;break;case"AAlarge":a=i>=3;break;case"AAAsmall":a=i>=7}return a},u.mostReadable=function(t,e,r){var n,a,i,o,s=null,l=0;a=(r=r||{}).includeFallbackColors,i=r.level,o=r.size;for(var c=0;cl&&(l=n,s=u(e[c]));return u.isReadable(t,s,{level:i,size:o})||!a?s:(r.includeFallbackColors=!1,u.mostReadable(t,["#fff","#000"],r))};var E=u.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},C=u.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(E);function S(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function L(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,s(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function O(t){return o(1,s(0,t))}function D(t){return parseInt(t,16)}function R(t){return 1==t.length?"0"+t:""+t}function P(t){return t<=1&&(t=100*t+"%"),t}function I(e){return t.round(255*parseFloat(e)).toString(16)}function z(t){return D(t)/255}var F,N,B,j=(N="[\\s|\\(]+("+(F="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",B="[\\s|\\(]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",{CSS_UNIT:new RegExp(F),rgb:new RegExp("rgb"+N),rgba:new RegExp("rgba"+B),hsl:new RegExp("hsl"+N),hsla:new RegExp("hsla"+B),hsv:new RegExp("hsv"+N),hsva:new RegExp("hsva"+B),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function U(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=u:window.tinycolor=u}(Math)},{}],284:[function(t,e,r){"use strict";function n(t){if(t instanceof Float32Array)return t;if("number"==typeof t)return new Float32Array([t])[0];var e=new Float32Array(t);return e.set(t),e}e.exports=n,e.exports.float32=e.exports.float=n,e.exports.fract32=e.exports.fract=function(t){if("number"==typeof t)return n(t-n(t));for(var e=n(t),r=0,a=e.length;r0?r.pop():new ArrayBuffer(t)}function h(t){return new Uint8Array(f(t),0,t)}function d(t){return new Uint16Array(f(2*t),0,t)}function p(t){return new Uint32Array(f(4*t),0,t)}function g(t){return new Int8Array(f(t),0,t)}function v(t){return new Int16Array(f(2*t),0,t)}function m(t){return new Int32Array(f(4*t),0,t)}function y(t){return new Float32Array(f(4*t),0,t)}function b(t){return new Float64Array(f(8*t),0,t)}function x(t){return o?new Uint8ClampedArray(f(t),0,t):h(t)}function _(t){return new DataView(f(t),0,t)}function w(t){t=a.nextPow2(t);var e=a.log2(t),r=u[e];return r.length>0?r.pop():new n(t)}r.free=function(t){if(n.isBuffer(t))u[a.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|a.log2(e);l[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=function(t){c(t.buffer)},r.freeArrayBuffer=c,r.freeBuffer=function(t){u[a.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return f(t);switch(e){case"uint8":return h(t);case"uint16":return d(t);case"uint32":return p(t);case"int8":return g(t);case"int16":return v(t);case"int32":return m(t);case"float":case"float32":return y(t);case"double":case"float64":return b(t);case"uint8_clamped":return x(t);case"buffer":return w(t);case"data":case"dataview":return _(t);default:return null}return null},r.mallocArrayBuffer=f,r.mallocUint8=h,r.mallocUint16=d,r.mallocUint32=p,r.mallocInt8=g,r.mallocInt16=v,r.mallocInt32=m,r.mallocFloat32=r.mallocFloat=y,r.mallocFloat64=r.mallocDouble=b,r.mallocUint8Clamped=x,r.mallocDataView=_,r.mallocBuffer=w,r.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,l[t].length=0,u[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":39,buffer:51,dup:91}],290:[function(t,e,r){"use strict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e0&&(i=n.size),n.lineSpacing&&n.lineSpacing>0&&(o=n.lineSpacing),n.styletags&&n.styletags.breaklines&&(s.breaklines=!!n.styletags.breaklines),n.styletags&&n.styletags.bolds&&(s.bolds=!!n.styletags.bolds),n.styletags&&n.styletags.italics&&(s.italics=!!n.styletags.italics),n.styletags&&n.styletags.subscripts&&(s.subscripts=!!n.styletags.subscripts),n.styletags&&n.styletags.superscripts&&(s.superscripts=!!n.styletags.superscripts));return r.font=[n.fontStyle,n.fontVariant,n.fontWeight,i+"px",n.font].filter(function(t){return t}).join(" "),r.textAlign="start",r.textBaseline="alphabetic",r.direction="ltr",w(function(t,e,r,n,i,o){r=r.replace(/\n/g,""),r=!0===o.breaklines?r.replace(/\/g,"\n"):r.replace(/\/g," ");var s="",l=[];for(A=0;A-1?parseInt(t[1+i]):0,u=s>-1?parseInt(r[1+s]):0;l!==u&&(a=a.replace(n(),"?px "),M*=Math.pow(.75,u-l),a=a.replace("?px ",n())),T+=.25*S*(u-l)}if(!0===o.superscripts){var f=t.indexOf(p),d=r.indexOf(p),g=f>-1?parseInt(t[1+f]):0,v=d>-1?parseInt(r[1+d]):0;g!==v&&(a=a.replace(n(),"?px "),M*=Math.pow(.75,v-g),a=a.replace("?px ",n())),T-=.25*S*(v-g)}if(!0===o.bolds){var y=t.indexOf(c)>-1,b=r.indexOf(c)>-1;!y&&b&&(a=x?a.replace("italic ","italic bold "):"bold "+a),y&&!b&&(a=a.replace("bold ",""))}if(!0===o.italics){var x=t.indexOf(h)>-1,_=r.indexOf(h)>-1;!x&&_&&(a="italic "+a),x&&!_&&(a=a.replace("italic ",""))}e.font=a}for(A=0;A",i="",o=a.length,s=i.length,l=e[0]===p||e[0]===m,u=0,c=-s;u>-1&&-1!==(u=r.indexOf(a,u))&&-1!==(c=r.indexOf(i,u+o))&&!(c<=u);){for(var f=u;f=c)n[f]=null,r=r.substr(0,f)+" "+r.substr(f+1);else if(null!==n[f]){var h=n[f].indexOf(e[0]);-1===h?n[f]+=e:l&&(n[f]=n[f].substr(0,h+1)+(1+parseInt(n[f][h+1]))+n[f].substr(h+2))}var d=u+o,g=r.substr(d,c-d).indexOf(a);u=-1!==g?g:c+s}return n}function x(t,e){var r=n(t,128);return e?i(r.cells,r.positions,.25):{edges:r.cells,positions:r.positions}}function _(t,e,r,n){var a=x(t,n),i=function(t,e,r){for(var n=e.textAlign||"start",a=e.textBaseline||"alphabetic",i=[1<<30,1<<30],o=[0,0],s=t.length,l=0;l= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":79}],301:[function(t,e,r){"use strict";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t("./lib/zc-core")},{"./lib/zc-core":300}],302:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],303:[function(t,e,r){"use strict";var n=t("./arrow_paths"),a=t("../../plots/font_attributes"),i=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:a({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",i.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",i.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",i.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:a({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":474,"../../plots/cartesian/constants":490,"../../plots/font_attributes":511,"./arrow_paths":302}],304:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/cartesian/axes"),i=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=a.getFromId(t,e.xref),n=a.getFromId(t,e.yref);e._extremes={},r&&s(e,r),n&&s(e,n)})}function s(t,e){var r,n=e._id,i=n.charAt(0),o=t[i],s=t["a"+i],l=t[i+"ref"],u=t["a"+i+"ref"],c=t["_"+i+"padplus"],f=t["_"+i+"padminus"],h={x:1,y:-1}[i]*t[i+"shift"],d=3*t.arrowsize*t.arrowwidth||0,p=d+h,g=d-h,v=3*t.startarrowsize*t.arrowwidth||0,m=v+h,y=v-h;if(u===l){var b=a.findExtremes(e,[e.r2c(o)],{ppadplus:p,ppadminus:g}),x=a.findExtremes(e,[e.r2c(s)],{ppadplus:Math.max(c,m),ppadminus:Math.max(f,y)});r={min:[b.min[0],x.min[0]],max:[b.max[0],x.max[0]]}}else m=s?m+s:m,y=s?y-s:y,r=a.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(c,p,m),ppadminus:Math.max(f,g,y)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([i,o],t)}},{"../../lib":437,"../../plots/cartesian/axes":484,"./draw":309}],305:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,a,i,o,l,u,c=t._fullLayout.annotations,f=[],h=[],d=[],p=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,s,l=o(t,e),u=l.on,c=l.off.concat(l.explicitOff),f={},h=t._fullLayout.annotations;if(!u.length&&!c.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var V=!1,q=["x","y"],G=0;G1)&&(K===$?((lt=tt.r2fraction(e["a"+Q]))<0||lt>1)&&(V=!0):V=!0),X=tt._offset+tt.r2p(e[Q]),Z=.5}else"x"===Q?(Y=e[Q],X=x.l+x.w*Y):(Y=1-e[Q],X=x.t+x.h*Y),Z=e.showarrow?.5:Y;if(e.showarrow){st.head=X;var ut=e["a"+Q];J=rt*H(.5,e.xanchor)-nt*H(.5,e.yanchor),K===$?(st.tail=tt._offset+tt.r2p(ut),W=J):(st.tail=X+ut,W=J+ut),st.text=st.tail+J;var ct=b["x"===Q?"width":"height"];if("paper"===$&&(st.head=o.constrain(st.head,1,ct-1)),"pixel"===K){var ft=-Math.max(st.tail-3,st.text),ht=Math.min(st.tail+3,st.text)-ct;ft>0?(st.tail+=ft,st.text+=ft):ht>0&&(st.tail-=ht,st.text-=ht)}st.tail+=ot,st.head+=ot}else W=J=at*H(Z,it),st.text=X+J;st.text+=ot,J+=ot,W+=ot,e["_"+Q+"padplus"]=at/2+W,e["_"+Q+"padminus"]=at/2-W,e["_"+Q+"size"]=at,e["_"+Q+"shift"]=J}if(t._dragging||!V){var dt=0,pt=0;if("left"!==e.align&&(dt=(w-m)*("center"===e.align?.5:1)),"top"!==e.valign&&(pt=(D-y)*("middle"===e.valign?.5:1)),c)n.select("svg").attr({x:z+dt-1,y:z+pt}).call(u.setClipUrl,N?M:null,t);else{var gt=z+pt-p.top,vt=z+dt-p.left;U.call(f.positionText,vt,gt).call(u.setClipUrl,N?M:null,t)}B.select("rect").call(u.setRect,z,z,w,D),F.call(u.setRect,P/2,P/2,I-P,j-P),R.call(u.setTranslate,Math.round(E.x.text-I/2),Math.round(E.y.text-j/2)),L.attr({transform:"rotate("+C+","+E.x.text+","+E.y.text+")"});var mt,yt=function(r,n){S.selectAll(".annotation-arrow-g").remove();var c=E.x.head,f=E.y.head,h=E.x.tail+r,p=E.y.tail+n,m=E.x.text+r,y=E.y.text+n,b=o.rotationXYMatrix(C,m,y),w=o.apply2DTransform(b),M=o.apply2DTransform2(b),O=+F.attr("width"),D=+F.attr("height"),P=m-.5*O,I=P+O,z=y-.5*D,N=z+D,B=[[P,z,P,N],[P,N,I,N],[I,N,I,z],[I,z,P,z]].map(M);if(!B.reduce(function(t,e){return t^!!o.segmentsIntersect(c,f,c+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){B.forEach(function(t){var e=o.segmentsIntersect(h,p,c,f,t[0],t[1],t[2],t[3]);e&&(h=e.x,p=e.y)});var j=e.arrowwidth,U=e.arrowcolor,H=e.arrowside,V=S.append("g").style({opacity:l.opacity(U)}).classed("annotation-arrow-g",!0),q=V.append("path").attr("d","M"+h+","+p+"L"+c+","+f).style("stroke-width",j+"px").call(l.stroke,l.rgb(U));if(g(q,H,e),_.annotationPosition&&q.node().parentNode&&!i){var G=c,X=f;if(e.standoff){var W=Math.sqrt(Math.pow(c-h,2)+Math.pow(f-p,2));G+=e.standoff*(h-c)/W,X+=e.standoff*(p-f)/W}var Y,Z,J=V.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(h-G)+","+(p-X),transform:"translate("+G+","+X+")"}).style("stroke-width",j+6+"px").call(l.stroke,"rgba(0,0,0,0)").call(l.fill,"rgba(0,0,0,0)");d.init({element:J.node(),gd:t,prepFn:function(){var t=u.getTranslate(R);Y=t.x,Z=t.y,s&&s.autorange&&A(s._name+".autorange",!0),v&&v.autorange&&A(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(Y,Z),a=n[0]+t,i=n[1]+r;R.call(u.setTranslate,a,i),k("x",s?s.p2r(s.r2p(e.x)+t):e.x+t/x.w),k("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/x.h),e.axref===e.xref&&k("ax",s.p2r(s.r2p(e.ax)+t)),e.ayref===e.yref&&k("ay",v.p2r(v.r2p(e.ay)+r)),V.attr("transform","translate("+t+","+r+")"),L.attr({transform:"rotate("+C+","+a+","+i+")"})},doneFn:function(){a.call("_guiRelayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&yt(0,0),O)d.init({element:R.node(),gd:t,prepFn:function(){mt=L.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?k("ax",s.p2r(s.r2p(e.ax)+t)):k("ax",e.ax+t),e.ayref===e.yref?k("ay",v.p2r(v.r2p(e.ay)+r)):k("ay",e.ay+r),yt(t,r);else{if(i)return;var a,o;if(s)a=s.p2r(s.r2p(e.x)+t);else{var l=e._xsize/x.w,u=e.x+(e._xshift-e.xshift)/x.w-l/2;a=d.align(u+t/x.w,l,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var c=e._ysize/x.h,f=e.y-(e._yshift+e.yshift)/x.h-c/2;o=d.align(f-r/x.h,c,0,1,e.yanchor)}k("x",a),k("y",o),s&&v||(n=d.getCursor(s?.5:a,v?.5:o,e.xanchor,e.yanchor))}L.attr({transform:"translate("+t+","+r+")"+mt}),h(R,n)},doneFn:function(){h(R),a.call("_guiRelayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else R.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,m=f.backoff*d+r.standoff,y=h.backoff*p+r.startstandoff;if("line"===c.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},s={x:+t.attr("x2"),y:+t.attr("y2")};var b=o.x-s.x,x=o.y-s.y;if(u=(l=Math.atan2(x,b))+Math.PI,m&&y&&m+y>Math.sqrt(b*b+x*x))return void O();if(m){if(m*m>b*b+x*x)return void O();var _=m*Math.cos(l),w=m*Math.sin(l);s.x+=_,s.y+=w,t.attr({x2:s.x,y2:s.y})}if(y){if(y*y>b*b+x*x)return void O();var A=y*Math.cos(l),k=y*Math.sin(l);o.x-=A,o.y-=k,t.attr({x1:o.x,y1:o.y})}}else if("path"===c.nodeName){var T=c.getTotalLength(),M="";if(T1){u=!0;break}}u?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l._pdata=a(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*r[0],e.yaxis.r2l(l.y)*r[1],e.zaxis.r2l(l.z)*r[2]]),n(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":518,"../annotations/draw":309}],316:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var i=r.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(n(t))},i.opacity=function(t){return t?n(t).getAlpha():0},i.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},i.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var a=n(e||l).toRgb(),i=1===a.a?a:{r:255*(1-a.a)+a.r*a.a,g:255*(1-a.a)+a.g*a.a,b:255*(1-a.a)+a.b*a.a},o={r:i.r*(1-r.a)+r.r*r.a,g:i.g*(1-r.a)+r.g*r.a,b:i.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},i.contrast=function(t,e,r){var a=n(t);return 1!==a.getAlpha()&&(a=n(i.combine(t,l))),(a.isDark()?e?a.lighten(e):l:r?a.darken(r):s).toString()},i.stroke=function(t,e){var r=n(e);t.style({stroke:i.tinyRGB(r),"stroke-opacity":r.getAlpha()})},i.fill=function(t,e){var r=n(e);t.style({fill:i.tinyRGB(r),"fill-opacity":r.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,r,n,a,o=Object.keys(t);for(e=0;e0?C>=I:C<=I));S++)C>F&&C0?C>=I:C<=I));S++)C>L[0]&&C1){var ot=Math.pow(10,Math.floor(Math.log(it)/Math.LN10));nt*=ot*u.roundUp(it/ot,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(et.tick0=0)}et.dtick=nt}et.domain=[Q+Y,Q+G-Y],et.setScale();var st=u.ensureSingle(v._infolayer,"g",e,function(t){t.classed(k.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(k.cbbg,!0),t.append("g").classed(k.cbfills,!0),t.append("g").classed(k.cblines,!0),t.append("g").classed(k.cbaxis,!0).classed(k.crisp,!0),t.append("g").classed(k.cbtitleunshift,!0).append("g").classed(k.cbtitle,!0),t.append("rect").classed(k.cboutline,!0),t.select(".cbtitle").datum(0)})});st.attr("transform","translate("+Math.round(A.l)+","+Math.round(A.t)+")");var lt=st.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(A.l)+",-"+Math.round(A.t)+")"),ut=st.select(".cbaxis"),ct=0;if(-1!==["top","bottom"].indexOf(r.title.side)){var ft,ht=A.l+(r.x+X)*A.w,dt=et.title.font.size;ft="top"===r.title.side?(1-(Q+G-Y))*A.h+A.t+3+.75*dt:(1-(Q+Y))*A.h+A.t-3-.25*dt,bt(et._id+"title",{attributes:{x:ht,y:ft,"text-anchor":"start"}})}var pt,gt,vt,mt=u.syncOrAsync([i.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.title.side)){var i=st.select(".cbtitle"),o=i.select("text"),l=[-r.outlinewidth/2,r.outlinewidth/2],c=i.select(".h"+et._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*m),c?(ct=h.bBox(c).height)>f&&(l[1]-=(ct-f)/2):o.node()&&!o.classed(k.jsPlaceholder)&&(ct=h.bBox(o.node()).height),ct){if(ct+=5,"top"===r.title.side)et.domain[1]-=ct/A.h,l[1]*=-1;else{et.domain[0]+=ct/A.h;var d=g.lineCount(o);l[1]+=(1-d)*f}i.attr("transform","translate("+l+")"),et.setScale()}}st.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(A.h*(1-et.domain[1]))+")"),ut.attr("transform","translate(0,"+Math.round(-A.t)+")");var p=st.select(".cbfills").selectAll("rect.cbfill").data(D);p.enter().append("rect").classed(k.cbfill,!0).style("stroke","none"),p.exit().remove();var y=L.map(et.c2p).map(Math.round).sort(function(t,e){return t-e});p.each(function(i,o){var s=[0===o?L[0]:(D[o]+D[o-1])/2,o===D.length-1?L[1]:(D[o]+D[o+1])/2].map(et.c2p).map(Math.round);s[1]=u.constrain(s[1]+(s[1]>s[0])?1:-1,y[0],y[1]);var l=n.select(this).attr({x:Z,width:Math.max(H,2),y:n.min(s),height:Math.max(n.max(s)-n.min(s),2)});if(r.fillgradient)h.gradient(l,t,e,"vertical",r.fillgradient,"fill");else{var c=P(i).replace("e-","");l.attr("fill",a(c).toHexString())}});var b=st.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?O:[]);return b.enter().append("path").classed(k.cbline,!0),b.exit().remove(),b.each(function(t){n.select(this).attr("d","M"+Z+","+(Math.round(et.c2p(t))+r.line.width/2%1)+"h"+H).call(h.lineGroupStyle,r.line.width,R(t),r.line.dash)}),ut.selectAll("g."+et._id+"tick,path").remove(),u.syncOrAsync([function(){var e=Z+H+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),n=s.calcTicks(et),a=s.makeTransFn(et),i=s.makeLabelFns(et,e),o=s.getTickSigns(et)[2];return s.drawTicks(t,et,{vals:"inside"===et.ticks?s.clipEnds(et,n):n,layer:ut,path:s.makeTickPath(et,e,o),transFn:a}),s.drawLabels(t,et,{vals:n,layer:ut,transFn:a,labelXFn:i.labelXFn,labelYFn:i.labelYFn,labelAnchorFn:i.labelAnchorFn})},function(){if(-1===["top","bottom"].indexOf(r.title.side)){var e=et.title.font.size,a=et._offset+et._length/2,i=A.l+(et.position||0)*A.w+("right"===et.side?10+e*(et.showticklabels?1:.5):-10-e*(et.showticklabels?.5:0));bt("h"+et._id+"title",{avoid:{selection:n.select(t).selectAll("g."+et._id+"tick"),side:r.title.side,offsetLeft:A.l,offsetTop:0,maxShift:v.width},attributes:{x:i,y:a,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},i.previousPromises,function(){var n=H+r.outlinewidth/2+h.bBox(ut.node()).width;if((B=lt.select("text")).node()&&!B.classed(k.jsPlaceholder)){var a,o=lt.select(".h"+et._id+"title-math-group").node();a=o&&-1!==["top","bottom"].indexOf(r.title.side)?h.bBox(o).width:h.bBox(lt.node()).right-Z-A.l,n=Math.max(n,a)}var s=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,l=$-K;st.select(".cbbg").attr({x:Z-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:K-W,width:Math.max(s,2),height:Math.max(l+2*W,2)}).call(d.fill,r.bgcolor).call(d.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),st.selectAll(".cboutline").attr({x:Z,y:K+r.ypad+("top"===r.title.side?ct:0),width:Math.max(H,2),height:Math.max(l-2*r.ypad-ct,2)}).call(d.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var u=({center:.5,right:1}[r.xanchor]||0)*s;st.attr("transform","translate("+(A.l-u)+","+A.t+")");var c={},f=y[r.yanchor],p=b[r.yanchor];"pixels"===r.lenmode?(c.y=r.y,c.t=l*f,c.b=l*p):(c.t=c.b=0,c.yt=r.y+r.len*f,c.yb=r.y-r.len*p);var g=y[r.xanchor],v=b[r.xanchor];if("pixels"===r.thicknessmode)c.x=r.x,c.l=s*g,c.r=s*v;else{var m=s-H;c.l=m*g,c.r=m*v,c.xl=r.x-r.thickness*g,c.xr=r.x+r.thickness*v}i.autoMargin(t,e,c)}],t);if(mt&&mt.then&&(t._promises||[]).push(mt),t._context.edits.colorbarPosition)l.init({element:st.node(),gd:t,prepFn:function(){pt=st.attr("transform"),f(st)},moveFn:function(t,e){st.attr("transform",pt+" translate("+t+","+e+")"),gt=l.align(J+t/A.w,V,0,1,r.xanchor),vt=l.align(Q-e/A.h,G,0,1,r.yanchor);var n=l.getCursor(gt,vt,r.xanchor,r.yanchor);f(st,n)},doneFn:function(){if(f(st),void 0!==gt&&void 0!==vt){var e={};e[E("x")]=gt,e[E("y")]=vt,o.call("_guiRestyle",t,e,M().index)}}});return mt}function yt(t,e){return u.coerce(tt,et,w,t,e)}function bt(e,r){var n={propContainer:et,propName:E("title"),traceIndex:M().index,placeholder:v._dfltTitle.colorbar,containerGroup:st.select(".cbtitle")},a="h"===e.charAt(0)?e.substr(1):"h"+e;st.selectAll("."+a+",."+a+"-math-group").remove(),p.draw(t,e,c(n,r||{}))}v._infolayer.selectAll("g."+e).remove()}function M(){var r,n,a=e.substr(2);for(r=0;r=0?a.colorscale.sequential:a.colorscale.sequentialminus,l._colorscale=l.colorscale=p)}},{"../../lib":437}],327:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./helpers").hasColorscale;e.exports=function(t){function e(t,e){var r=t["_"+e];void 0!==r&&(t[e]=r)}function r(t,r){var a=r.container?n.nestedProperty(t,r.container).get():t;if(a){var i=a.zauto||a.cauto,o=r.min,s=r.max;(i||void 0===a[o])&&e(a,o),(i||void 0===a[s])&&e(a,s),a.autocolorscale&&e(a,"colorscale")}}for(var i=0;i=0;n--,a++){var i=t[n];r[a]=[1-i[0],i[1]]}return r}function c(t){var e={r:t[0],g:t[1],b:t[2],a:t[3]};return a(e).toRgbString()}e.exports={hasColorscale:function(t,e){var r=e?o.nestedProperty(t,e).get()||{}:t,n=r.color,a=!1;if(o.isArrayOrTypedArray(n))for(var s=0;s4/3-s?o:s}},{}],335:[function(t,e,r){"use strict";var n=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,i){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===i?0:"middle"===i?1:"top"===i?2:n.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":437}],336:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),a=t("has-hover"),i=t("has-passive-events"),o=t("../../registry"),s=t("../../lib"),l=t("../../plots/cartesian/constants"),u=t("../../constants/interactions"),c=e.exports={};c.align=t("./align"),c.getCursor=t("./cursor");var f=t("./unhover");function h(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function d(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}c.unhover=f.wrapped,c.unhoverRaw=f.raw,c.init=function(t){var e,r,n,f,p,g,v,m,y=t.gd,b=1,x=u.DBLCLICKDELAY,_=t.element;y._mouseDownTime||(y._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=A,i?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=A,_.addEventListener("touchstart",A,{passive:!1})):_.ontouchstart=A;var w=t.clampFn||function(t,e,r){return Math.abs(t)x&&(b=Math.max(b-1,1)),y._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(b,g),!m){var r;try{r=new MouseEvent("click",e)}catch(t){var n=d(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(y),y._dragged=!1}else y._dragged=!1}},c.coverSlip=h},{"../../constants/interactions":415,"../../lib":437,"../../plots/cartesian/constants":490,"../../registry":528,"./align":334,"./cursor":335,"./unhover":337,"has-hover":200,"has-passive-events":201,"mouse-event-offset":215}],337:[function(t,e,r){"use strict";var n=t("../../lib/events"),a=t("../../lib/throttle"),i=t("../../lib/get_graph_div"),o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,r){(t=i(t))._fullLayout&&a.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,r)},s.raw=function(t,e){var r=t._fullLayout,a=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&a&&t.emit("plotly_unhover",{event:e,points:a}))}},{"../../lib/events":428,"../../lib/get_graph_div":433,"../../lib/throttle":462,"../fx/constants":351}],338:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],339:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("tinycolor2"),o=t("../../registry"),s=t("../color"),l=t("../colorscale"),u=t("../../lib"),c=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../constants/alignment").LINE_SPACING,d=t("../../constants/interactions").DESELECTDIM,p=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){u.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,a){t.call(v.setPosition,e,r).call(v.setSize,n,a)},v.translatePoint=function(t,e,r,n){var i=r.c2p(t.x),o=n.c2p(t.y);return!!(a(i)&&a(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",o):e.attr("transform","translate("+i+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var a=n.select(this);v.translatePoint(t,a,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,a,i){e.attr("display",r.isPtWithinRange(t,a)&&n.isPtWithinRange(t,i)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,a=e.yaxis;t.each(function(e){var i=e[0].trace,o=i.xcalendar,s=i.ycalendar,l="bar"===i.type?".bartext":".point,.textpoint";t.selectAll(l).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,a,o,s)})})}},v.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,a){e.style("fill","none");var i=(((t||[])[0]||{}).trace||{}).line||{},o=r||i.width||0,l=a||i.dash||"";s.stroke(e,n||i.color),v.dashLine(e,l,o)},v.lineGroupStyle=function(t,e,r,a){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},o=e||i.width||0,l=a||i.dash||"";n.select(this).call(s.stroke,r||i.color).call(v.dashLine,l,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(s.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){var e=n.select(this);t[0].trace&&e.call(s.fill,t[0].trace.fillcolor)})};var m=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(m).forEach(function(t){var e=m[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var y=v.symbolNames.length,b="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function x(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?b:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=y||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},A=n.format("~.1f"),k={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,a,o,l){for(var c=o.length,f=k[a],h=new Array(c),d=0;d=100,e.attr("d",x(c,l))}var f,h,d,p=!1;if(t.so)d=o.outlierwidth,h=o.outliercolor,f=i.outliercolor;else{var g=(o||{}).width;d=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,h="mlc"in t?t.mlcc=n.lineScale(t.mlc):u.isArrayOrTypedArray(o.color)?s.defaultLine:o.color,u.isArrayOrTypedArray(i.color)&&(f=s.defaultLine,p=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):i.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(s.stroke,f).style({"stroke-width":(d||1)+"px",fill:"none"});else{e.style("stroke-width",d+"px");var m=i.gradient,y=t.mgt;if(y?p=!0:y=m&&m.type,Array.isArray(y)&&(y=y[0],k[y]||(y=0)),y&&"none"!==y){var b=t.mgc;b?p=!0:b=m.color;var _=r.uid;p&&(_+="-"+t.i),v.gradient(e,a,_,y,[[0,b],[1,f]],"fill")}else s.fill(e,f);d&&s.stroke(e,h)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=p.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&u.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.marker||{},i=r.marker||{},s=n.marker||{},l=a.opacity,c=i.opacity,f=s.opacity,h=void 0!==c,p=void 0!==f;(u.isArrayOrTypedArray(l)||h||p)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?a.opacity:t.mo;return t.selected?h?c:e:p?f:d*e});var g=a.color,v=i.color,m=s.color;(v||m)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:m||e});var y=a.size,b=i.size,x=s.size,_=void 0!==b,w=void 0!==x;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||y/2;return t.selected?_?b/2:e:w?x/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},a=t.textfont||{},i=r.textfont||{},o=n.textfont||{},l=a.color,u=i.color,c=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||l;return t.selected?u||e:c||(u?e:s.addOpacity(e,d))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),a=e.marker||{},i=[];r.selectedOpacityFn&&i.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&i.push(function(t,e){s.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&i.push(function(t,e){var n=e.mx||a.symbol||0,i=r.selectedSizeFn(e);t.attr("d",x(v.symbolNumber(n),i)),e.mrc2=i}),i.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var a;if(e.selectedpoints){var i=v.makeSelectedTextStyleFns(e);a=i.selectedTextColorFn}t.each(function(t){var i=n.select(this),o=u.extractOption(t,e,"tx","text");if(o||0===o){var s=t.tp||e.textposition,l=E(t,e),f=a?a(t):t.tc||e.textfont.color;i.call(v.font,t.tf||e.textfont.family,l,f).text(o).call(c.convertToTspans,r).call(M,s,l,t.mrc)}else i.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var a=n.select(this),i=r.selectedTextColorFn(t),o=t.tp||e.textposition,l=E(t,e);s.fill(a,i),M(a,o,l,t.mrc2||t.mrc)})}};var C=.5;function S(t,e,r,a){var i=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],u=Math.pow(i*i+o*o,C/2),c=Math.pow(s*s+l*l,C/2),f=(c*c*i-u*u*s)*a,h=(c*c*o-u*u*l)*a,d=3*c*(u+c),p=3*u*(u+c);return[[n.round(e[0]+(d&&f/d),2),n.round(e[1]+(d&&h/d),2)],[n.round(e[0]-(p&&f/p),2),n.round(e[1]-(p&&h/p),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],a=[];for(r=1;r=1e4&&(v.savedBBoxes={},D=0),r&&(v.savedBBoxes[r]=m),D++,u.extendFlat({},m)},v.setClipUrl=function(t,e,r){if(e){var n=r._context,a=n._exportedPlot?"":n._baseUrl||"";t.attr("clip-path","url("+a+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||0,r=r||0,i=i.replace(/(\btranslate\(.*?\);?)/,"").trim(),i=(i+=" translate("+e+", "+r+")").trim(),t[a]("transform",i),i},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",a=t.attr?"attr":"setAttribute",i=t[n]("transform")||"";return e=e||1,r=r||1,i=i.replace(/(\bscale\(.*?\);?)/,"").trim(),i=(i+=" scale("+e+", "+r+")").trim(),t[a]("transform",i),i};var P=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(P,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var I=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,a=n.select(this),i=a.select("text");if(i.node()){var o=parseFloat(i.attr("x")||0),s=parseFloat(i.attr("y")||0),l=(a.attr("transform")||"").match(I);t=1===e&&1===r?[]:["translate("+o+","+s+")","scale("+e+","+r+")","translate("+-o+","+-s+")"],l&&t.push(l),a.attr("transform",t.join(" "))}})}},{"../../constants/alignment":413,"../../constants/interactions":415,"../../constants/xmlns_namespaces":417,"../../lib":437,"../../lib/svg_text_utils":461,"../../registry":528,"../../traces/scatter/make_bubble_size_func":604,"../../traces/scatter/subtypes":611,"../color":318,"../colorscale":330,"./symbol_defs":340,d3:85,"fast-isnumeric":149,tinycolor2:283}],340:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,a="l"+e+",-"+e,i="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+a+i+a+i+o+i+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),a=n.round(-t,2),i=n.round(-.309*t,2);return"M"+e+","+i+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+i+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+r+"V"+r+"L0,"+e+"L-"+a+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),a=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+a+"H"+r+"L"+e+",0L"+r+",-"+a+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),a=n.round(.951*e,2),i=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(-.309*e,2),u=n.round(.118*e,2),c=n.round(.809*e,2);return"M"+r+","+l+"H"+a+"L"+i+","+u+"L"+o+","+c+"L0,"+n.round(.382*e,2)+"L-"+o+","+c+"L-"+i+","+u+"L-"+a+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),a=n.round(.76*t,2);return"M-"+a+",0l-"+r+",-"+e+"h"+a+"l"+r+",-"+e+"l"+r+","+e+"h"+a+"l-"+r+","+e+"l"+r+","+e+"h-"+a+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+a+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),a=n.round(1.6*t,2),i=n.round(4*t,2),o="A "+i+","+i+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+a+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),a="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),a=n.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:85}],341:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],342:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("../../registry"),i=t("../../plots/cartesian/axes"),o=t("./compute_error");function s(t,e,r,a){var s=e["error_"+a]||{},l=[];if(s.visible&&-1!==["linear","log"].indexOf(r.type)){for(var u=o(s),c=0;c0;e.each(function(e){var f,h=e[0].trace,d=h.error_x||{},p=h.error_y||{};h.ids&&(f=function(t){return t.id});var g=o.hasMarkers(h)&&h.marker.maxdisplayed>0;p.visible||d.visible||(e=[]);var v=n.select(this).selectAll("g.errorbar").data(e,f);if(v.exit().remove(),e.length){d.visible||v.selectAll("path.xerror").remove(),p.visible||v.selectAll("path.yerror").remove(),v.style("opacity",1);var m=v.enter().append("g").classed("errorbar",!0);c&&m.style("opacity",0).transition().duration(s.duration).style("opacity",1),i.setClipUrl(v,r.layerClipId,t),v.each(function(t){var e=n.select(this),r=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,l,u);if(!g||t.vis){var i,o=e.select("path.yerror");if(p.visible&&a(r.x)&&a(r.yh)&&a(r.ys)){var f=p.width;i="M"+(r.x-f)+","+r.yh+"h"+2*f+"m-"+f+",0V"+r.ys,r.noYS||(i+="m-"+f+",0h"+2*f),!o.size()?o=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):c&&(o=o.transition().duration(s.duration).ease(s.easing)),o.attr("d",i)}else o.remove();var h=e.select("path.xerror");if(d.visible&&a(r.y)&&a(r.xh)&&a(r.xs)){var v=(d.copy_ystyle?p:d).width;i="M"+r.xh+","+(r.y-v)+"v"+2*v+"m0,-"+v+"H"+r.xs,r.noXS||(i+="m0,-"+v+"v"+2*v),!h.size()?h=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):c&&(h=h.transition().duration(s.duration).ease(s.easing)),h.attr("d",i)}else h.remove()}})}})}},{"../../traces/scatter/subtypes":611,"../drawing":339,d3:85,"fast-isnumeric":149}],347:[function(t,e,r){"use strict";var n=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},i=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(a.stroke,r.color),i.copy_ystyle&&(i=r),o.selectAll("path.xerror").style("stroke-width",i.thickness+"px").call(a.stroke,i.color)})}},{"../color":318,d3:85}],348:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":511}],349:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry");function i(t,e,r,a){a=a||n.identity,Array.isArray(t)&&(e[0][r]=a(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var s=0;s=0&&r.indexw[0]._length||et<0||et>A[0]._length)return h.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+A[0]._offset,I="xval"in e?g.flat(l,e.xval):g.p2c(w,tt),z="yval"in e?g.flat(l,e.yval):g.p2c(A,et),!a(I[0])||!a(z[0]))return o.warn("Fx.hover failed",e,t),h.unhoverRaw(t,e)}var at=1/0;for(N=0;NW&&(J.splice(0,W),at=J[0].distance),y&&0!==Z&&0===J.length){X.distance=Z,X.index=!1;var ut=j._module.hoverPoints(X,q,G,"closest",c._hoverlayer);if(ut&&(ut=ut.filter(function(t){return t.spikeDistance<=Z})),ut&&ut.length){var ct,ft=ut.filter(function(t){return t.xa.showspikes});if(ft.length){var ht=ft[0];a(ht.x0)&&a(ht.y0)&&(ct=vt(ht),(!$.vLinePoint||$.vLinePoint.spikeDistance>ct.spikeDistance)&&($.vLinePoint=ct))}var dt=ut.filter(function(t){return t.ya.showspikes});if(dt.length){var pt=dt[0];a(pt.x0)&&a(pt.y0)&&(ct=vt(pt),(!$.hLinePoint||$.hLinePoint.spikeDistance>ct.spikeDistance)&&($.hLinePoint=ct))}}}}function gt(t,e){for(var r,n=null,a=1/0,i=0;i1||J.length>1)||"closest"===P&&K&&J.length>1,Ot=f.combine(c.plot_bgcolor||f.background,c.paper_bgcolor),Dt={hovermode:P,rotateLabels:Lt,bgColor:Ot,container:c._hoverlayer,outerContainer:c._paperdiv,commonLabelOpts:c.hoverlabel,hoverdistance:c.hoverdistance},Rt=T(J,Dt,t);if(function(t,e,r){var n,a,i,o,s,l,u,c=0,f=1,h=t.map(function(t,n){var a=t[e],i="x"===a._id.charAt(0),o=a.range;return!n&&o&&o[0]>o[1]!==i&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?b:1)/2,pmin:0,pmax:i?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function d(t){var e=t[0],r=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,i=r.pos+r.dp+r.size-e.pmax,a>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=a;n=!1}if(!(i<.01)){if(a<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=i;n=!1}if(n){var u=0;for(o=0;oe.pmax&&u++;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos>e.pmax-1&&(l.del=!0,u--);for(o=0;o=0;s--)t[s].dp-=i;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos+l.dp+l.size>e.pmax&&(l.del=!0,u--)}}}for(;!n&&c<=t.length;){for(c++,n=!0,o=0;o.01&&v.pmin===m.pmin&&v.pmax===m.pmax){for(s=g.length-1;s>=0;s--)g[s].dp+=a;for(p.push.apply(p,g),h.splice(o+1,1),u=0,s=p.length-1;s>=0;s--)u+=p[s].dp;for(i=u/p.length,s=p.length-1;s>=0;s--)p[s].dp-=i;n=!1}else o++}h.forEach(d)}for(o=h.length-1;o>=0;o--){var y=h[o];for(s=y.length-1;s>=0;s--){var x=y[s],_=t[x.i];_.offset=x.dp,_.del=x.del}}}(J,Lt?"xa":"ya",c),M(Rt,Lt),e.target&&e.target.tagName){var Pt=p.getComponentMethod("annotations","hasClickToShow")(t,Mt);u(n.select(e.target),Pt?"pointer":"")}if(!e.target||i||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var a=r[n],i=t._hoverdata[n];if(a.curveNumber!==i.curveNumber||String(a.pointNumber)!==String(i.pointNumber)||String(a.pointNumbers)!==String(i.pointNumbers))return!0}return!1}(t,0,Tt))return;Tt&&t.emit("plotly_unhover",{event:e,points:Tt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:A,xvals:I,yvals:z})}(t,e,r,i)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1},a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},s=T([r],o,e.gd);return M(s,o.rotateLabels),s.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1}}),a=n.select(e.container),i=e.outerContainer?n.select(e.outerContainer):a,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:a,outerContainer:i},s=T(r,o,e.gd),l=0;return s.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5([\s\S]*)<\/extra>/;function T(t,e,r){var a=e.hovermode,i=e.rotateLabels,s=e.bgColor,u=e.container,h=e.outerContainer,d=e.commonLabelOpts||{},p=e.fontFamily||v.HOVERFONT,g=e.fontSize||v.HOVERFONTSIZE,y=t[0],b=y.xa,x=y.ya,_="y"===a?"yLabel":"xLabel",T=y[_],M=(String(T)||"").split(" ")[0],E=h.node().getBoundingClientRect(),C=E.top,S=E.width,L=E.height,O=void 0!==T&&y.distance<=e.hoverdistance&&("x"===a||"y"===a);if(O){var D,R,P=!0;for(D=0;D-1&&u.length>x&&(u=x>3?u.substr(0,x-3)+"...":u.substr(0,x))}void 0!==t.zLabel?(void 0!==t.xLabel&&(h+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(h+="y: "+t.yLabel+"
"),h+=(h?"z: ":"")+t.zLabel):O&&t[a+"Label"]===T?h=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(h=t.yLabel):h=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(h+=(h?"
":"")+t.text),void 0!==t.extraText&&(h+=(h?"
":"")+t.extraText),""===h&&(""===u&&e.remove(),h=u);var _=t.hovertemplate||!1,M=t.hovertemplateLabels||t,E=t.eventData[0]||{};_&&(h=(h=o.hovertemplateString(_,M,E)).replace(k,function(t,e){return u=e,""}));var D=e.select("text.nums").call(c.font,t.fontFamily||p,t.fontSize||g,t.fontColor||b).text(h).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),R=e.select("text.name"),P=0;u&&u!==h?(R.call(c.font,t.fontFamily||p,t.fontSize||g,y).text(u).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),P=R.node().getBoundingClientRect().width+2*A):(R.remove(),e.select("rect").remove()),e.select("path").style({fill:v,stroke:b});var I,z,F=D.node().getBoundingClientRect(),N=t.xa._offset+(t.x0+t.x1)/2,B=t.ya._offset+(t.y0+t.y1)/2,j=Math.abs(t.x1-t.x0),U=Math.abs(t.y1-t.y0),H=F.width+w+A+P;t.ty0=C-F.top,t.bx=F.width+2*A,t.by=F.height+2*A,t.anchor="start",t.txwidth=F.width,t.tx2width=P,t.offset=0,i?(t.pos=N,I=B+U/2+H<=L,z=B-U/2-H>=0,"top"!==t.idealAlign&&I||!z?I?(B+=U/2,t.anchor="start"):t.anchor="middle":(B-=U/2,t.anchor="end")):(t.pos=B,I=N+j/2+H<=S,z=N-j/2-H>=0,"left"!==t.idealAlign&&I||!z?I?(N+=j/2,t.anchor="start"):t.anchor="middle":(N-=j/2,t.anchor="end")),D.attr("text-anchor",t.anchor),P&&R.attr("text-anchor",t.anchor),e.attr("transform","translate("+N+","+B+")"+(i?"rotate("+m+")":""))}),F}function M(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var a="end"===t.anchor?-1:1,i=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],s=o*(w+A),u=s+o*(t.txwidth+A),f=0,h=t.offset;"middle"===t.anchor&&(s-=t.tx2width/2,u+=t.txwidth/2+A),e&&(h*=-_,f=t.offset*x),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(h-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(a*w+f)+","+(w+h)+"v"+(t.by/2-w)+"h"+a*t.bx+"v-"+t.by+"H"+(a*w+f)+"V"+(h-w)+"Z"),i.call(l.positionText,s+f,h+t.ty0-t.by/2+A),t.tx2width&&(r.select("text.name").call(l.positionText,u+o*A+f,h+t.ty0-t.by/2+A),r.select("rect").call(c.setRect,u+(o-1)*t.tx2width/2+f,h-t.by/2-1,t.tx2width,t.by+2))}})}function E(t,e){var r=t.index,n=t.trace||{},a=t.cd[0],i=t.cd[r]||{},s=Array.isArray(r)?function(t,e){return o.castOption(a,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(i,n,t,e)};function l(e,r,n){var a=s(r,n);a&&(t[e]=a)}if(l("hoverinfo","hi","hoverinfo"),l("bgcolor","hbg","hoverlabel.bgcolor"),l("borderColor","hbc","hoverlabel.bordercolor"),l("fontFamily","htf","hoverlabel.font.family"),l("fontSize","hts","hoverlabel.font.size"),l("fontColor","htc","hoverlabel.font.color"),l("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:d.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:d.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var u=d.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+u+" / -"+d.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+u,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var c=d.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+c+" / -"+d.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+c,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return f&&"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function C(t,e){var r,n,a=e.container,o=e.fullLayout,s=e.event,l=!!t.hLinePoint,u=!!t.vLinePoint;if(a.selectAll(".spikeline").remove(),u||l){var h=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(l){var d,p,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(d=s.pointerX,p=s.pointerY):(d=r._offset+g.x,p=n._offset+g.y);var v,m,y=i.readability(g.color,h)<1.5?f.contrast(h):g.color,b=n.spikemode,x=n.spikethickness,_=n.spikecolor||y,w=n._boundingBox,A=(w.left+w.right)/20){for(var n=[],a=0;a-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){h||d||p||"independent"===k("pattern")&&(h=!0),v._hasSubplotGrid=h;var b,x,_="top to bottom"===k("roworder"),w=h?.2:.1,A=h?.3:.1;g&&e._splomGridDflt&&(b=e._splomGridDflt.xside,x=e._splomGridDflt.yside),v._domains={x:c("x",k,w,b,y),y:c("y",k,A,x,m,_)}}else delete e.grid}function k(t,e){return n.coerce(r,v,l,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,a,i,o,s,l,c,h=t.grid||{},d=e._subplots,p=r._hasSubplotGrid,g=r.rows,v=r.columns,m="independent"===r.pattern,y=r._axisMap={};if(p){var b=h.subplots||[];l=r.subplots=new Array(g);var x=1;for(n=0;n1);if(!1!==b||d.uirevision){var x=i.newContainer(e,"legend");if(w("uirevision",e.uirevision),!1!==b){if(w("bgcolor",e.paper_bgcolor),w("bordercolor"),w("borderwidth"),a.coerceFont(w,"font",e.font),w("orientation"),"h"===x.orientation){var _=t.xaxis;n.getComponentMethod("rangeslider","isVisible")(_)?(u=0,f="left",c=1.1,h="bottom"):(u=0,f="left",c=-.1,h="top")}w("traceorder",v),l.isGrouped(e.legend)&&w("tracegroupgap"),w("x",u),w("xanchor",f),w("y",c),w("yanchor",h),w("valign"),a.noneOrAll(d,x,["x","y"])}}function w(t,e){return a.coerce(d,x,o,t,e)}}},{"../../lib":437,"../../plot_api/plot_template":474,"../../plots/layout_attributes":519,"../../registry":528,"./attributes":367,"./helpers":373}],370:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../lib"),i=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib/events"),l=t("../dragelement"),u=t("../drawing"),c=t("../color"),f=t("../../lib/svg_text_utils"),h=t("./handle_click"),d=t("./constants"),p=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,m=g.FROM_TL,y=g.FROM_BR,b=t("./get_legend_data"),x=t("./style"),_=t("./helpers"),w=p.DBLCLICKDELAY;function A(t,e,r,n,a){var i=r.data()[0][0].trace,o={event:a,node:r.node(),curveNumber:i.index,expandedIndex:i._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(i._group&&(o.group=i._group),"pie"===i.type&&(o.label=r.datum()[0].label),!1!==s.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){h(r,t,n)},w);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==s.triggerHandler(t,"plotly_legenddoubleclick",o)&&h(r,t,n)}}function k(t,e,r){var n=t.data()[0][0],i=e._fullLayout,s=n.trace,l=o.traceIs(s,"pie"),c=s.index,h=l?n.label:s.name,p=e._context.edits.legendText&&!l,g=a.ensureSingle(t,"text","legendtext");function m(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,a,i=t.select("g[class*=math-group]"),o=i.node(),s=e._fullLayout.legend.font.size*v;if(o){var l=u.bBox(o);n=l.height,a=l.width,u.setTranslate(i,0,n/4)}else{var c=t.select(".legendtext"),h=f.lineCount(c),p=c.node();n=s*h,a=p?u.bBox(p).width:0;var g=s*(.3+(1-h)/2);f.positionText(c,d.textOffsetX,g),r.lineHeight=s}n=Math.max(n,16)+3,r.height=n,r.width=a}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(u.font,i.legend.font).text(p?T(h,r):h),f.positionText(g,d.textOffsetX,0),p?g.call(f.makeEditable,{gd:e,text:h}).call(m).on("edit",function(t){this.text(T(t,r)).call(m);var i=n.trace._fullInput||{},s={};if(o.hasTransform(i,"groupby")){var l=o.getTransformIndices(i,"groupby"),u=l[l.length-1],f=a.keyedContainer(i,"transforms["+u+"].styles","target","value.name");f.set(n.trace._group,t),s=f.constructUpdate()}else s.name=t;return o.call("_guiRestyle",e,s,c)}):m(g)}function T(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function M(t,e){var r,i=1,o=a.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(c.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimew&&(i=Math.max(i-1,1)),A(e,r,t,i,n.event)}})}function E(t,e,r){var a=t._fullLayout,i=a.legend,o=i.borderwidth,s=_.isGrouped(i),l=0;if(i._width=0,i._height=0,_.isVertical(i))s&&e.each(function(t,e){u.setTranslate(this,0,e*i.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;u.setTranslate(this,o,5+o+i._height+r/2),i._height+=r,i._width=Math.max(i._width,n)}),i._width+=45+2*o,i._height+=10+2*o,s&&(i._height+=(i._lgroupsLength-1)*i.tracegroupgap),l=40;else if(s){for(var c=[i._width],f=e.data(),h=0,d=f.length;ho+w-A,r.each(function(t){var e=t[0],r=v?40+t[0].width:b;o+x+A+r>a._size.w&&(x=0,m+=y,i._height=i._height+y,y=0),u.setTranslate(this,o+x,5+o+e.height/2+m),i._width+=A+r,i._height=Math.max(i._height,e.height),x+=A+r,y=Math.max(e.height,y)}),i._width+=2*o,i._height+=10+2*o}i._width=Math.ceil(i._width),i._height=Math.ceil(i._height);var k=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");u.setRect(r,0,-e.height/2,(k?0:i._width)+l,e.height)})}function C(t){var e=t._fullLayout.legend,r="left";a.isRightAnchor(e)?r="right":a.isCenterAnchor(e)&&(r="center");var n="top";a.isBottomAnchor(e)?n="bottom":a.isMiddleAnchor(e)&&(n="middle"),i.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*m[r],r:e._width*y[r],b:e._height*y[n],t:e._height*m[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var s=e.legend,f=e.showlegend&&b(t.calcdata,s),h=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void i.autoMargin(t,"legend");for(var p=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";a.isRightAnchor(e)?r="right":a.isCenterAnchor(e)&&(r="center");i.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*m[r],r:e._width*y[r],b:0,t:0})}(t):C(t);var h=e._size,p=h.l+h.w*s.x,g=h.t+h.h*(1-s.y);a.isRightAnchor(s)?p-=s._width:a.isCenterAnchor(s)&&(p-=s._width/2),a.isBottomAnchor(s)?g-=s._height:a.isMiddleAnchor(s)&&(g-=s._height/2);var v=s._width,b=h.w;v>b?(p=h.l,v=b):(p+v>c&&(p=c-v),p<0&&(p=0),v=Math.min(c-p,s._width));var x,_,w,k,T=s._height,M=h.h;if(T>M?(g=h.t,T=M):(g+T>f&&(g=f-T),g<0&&(g=0),T=Math.min(f-g,s._height)),u.setTranslate(L,p,g),P.on(".drag",null),L.on("wheel",null),s._height<=T||t._context.staticPlot)D.attr({width:v-s.borderwidth,height:T-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),u.setTranslate(R,0,0),O.select("rect").attr({width:v-2*s.borderwidth,height:T-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth}),u.setClipUrl(R,r,t),u.setRect(P,0,0,0,0),delete s._scrollY;else{var F,N,B=Math.max(d.scrollBarMinHeight,T*T/s._height),j=T-B-2*d.scrollBarMargin,U=s._height-T,H=j/U,V=Math.min(s._scrollY||0,U);D.attr({width:v-2*s.borderwidth+d.scrollBarWidth+d.scrollBarMargin,height:T-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),O.select("rect").attr({width:v-2*s.borderwidth+d.scrollBarWidth+d.scrollBarMargin,height:T-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth+V}),u.setClipUrl(R,r,t),G(V,B,H),L.on("wheel",function(){G(V=a.constrain(s._scrollY+n.event.deltaY/j*U,0,U),B,H),0!==V&&V!==U&&n.event.preventDefault()});var q=n.behavior.drag().on("dragstart",function(){F=n.event.sourceEvent.clientY,N=V}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||G(V=a.constrain((t.clientY-F)/H+N,0,U),B,H)});P.call(q)}function G(e,r,n){s._scrollY=t._fullLayout.legend._scrollY=e,u.setTranslate(R,0,-e),u.setRect(P,v,d.scrollBarMargin+e*n,d.scrollBarWidth,r),O.select("rect").attr({y:s.borderwidth+e})}t._context.edits.legendPosition&&(L.classed("cursor-move",!0),l.init({element:L.node(),gd:t,prepFn:function(){var t=u.getTranslate(L);w=t.x,k=t.y},moveFn:function(t,e){var r=w+t,n=k+e;u.setTranslate(L,r,n),x=l.align(r,0,h.l,h.l+h.w,s.xanchor),_=l.align(n,0,h.t+h.h,h.t,s.yanchor)},doneFn:function(){void 0!==x&&void 0!==_&&o.call("_guiRelayout",t,{"legend.x":x,"legend.y":_})},clickFn:function(r,n){var a=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});a.size()>0&&A(t,L,a,r,n)}}))}],t)}}},{"../../constants/alignment":413,"../../constants/interactions":415,"../../lib":437,"../../lib/events":428,"../../lib/svg_text_utils":461,"../../plots/plots":521,"../../registry":528,"../color":318,"../dragelement":336,"../drawing":339,"./constants":368,"./get_legend_data":371,"./handle_click":372,"./helpers":373,"./style":375,d3:85}],371:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("./helpers");e.exports=function(t,e){var r,i,o={},s=[],l=!1,u={},c=0;function f(t,r){if(""!==t&&a.isGrouped(e))-1===s.indexOf(t)?(s.push(t),l=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+c;s.push(n),o[n]=[[r]],c++}}for(r=0;rr[1])return r[1]}return a}function p(t){return t[0]}if(c||f||h){var g={},v={};if(c){g.mc=d("marker.color",p),g.mx=d("marker.symbol",p),g.mo=d("marker.opacity",i.mean,[.2,1]),g.mlc=d("marker.line.color",p),g.mlw=d("marker.line.width",i.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var m=d("marker.size",i.mean,[2,16]);g.ms=m,v.marker.size=m}h&&(v.line={width:d("line.width",p,[0,10])}),f&&(g.tx="Aa",g.tp=d("textposition",p),g.ts=10,g.tc=d("textfont.color",p),g.tf=d("textfont.family",p)),r=[i.minExtend(s,g)],(a=i.minExtend(u,v)).selectedpoints=null}var y=n.select(this).select("g.legendpoints"),b=y.selectAll("path.scatterpts").data(c?r:[]);b.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),b.exit().remove(),b.call(o.pointStyle,a,e),c&&(r[0].mrc=3);var x=y.selectAll("g.pointtext").data(f?r:[]);x.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),x.exit().remove(),x.selectAll("text").call(o.textPointStyle,a,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,o=n.select(this);o.style("stroke-width",i+"px").call(s.fill,a.fillcolor),i&&s.stroke(o,a.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var a=e[r?"increasing":"decreasing"],i=a.line.width,l=n.select(this);l.style("fill","none").call(o.dashLine,a.line.dash,i),i&&s.stroke(l,a.line.color)})})}},{"../../lib":437,"../../registry":528,"../../traces/pie/style_one":581,"../../traces/scatter/subtypes":611,"../color":318,"../drawing":339,d3:85}],376:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../plots/plots"),i=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),s=t("../../../build/ploticon"),l=o._,u=e.exports={};function c(t,e){var r,a,o=e.currentTarget,s=o.getAttribute("data-attr"),l=o.getAttribute("data-val")||!0,u=t._fullLayout,c={},f=i.list(t,null,!0),h="on";if("zoom"===s){var d,p="in"===l?.5:2,g=(1+p)/2,v=(1-p)/2;for(a=0;a1?(A=["toggleHover"],k=["resetViews"]):h?(w=["zoomInGeo","zoomOutGeo"],A=["hoverClosestGeo"],k=["resetGeo"]):f?(A=["hoverClosest3d"],k=["resetCameraDefault3d","resetCameraLastSave3d"]):v?(A=["toggleHover"],k=["resetViewMapbox"]):A=p?["hoverClosestGl2d"]:d?["hoverClosestPie"]:["toggleHover"];c&&(A=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!c&&!p||y||(w=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==k[0]&&(k=["resetScale2d"]));f?T=["zoom3d","pan3d","orbitRotation","tableRotation"]:(c||p)&&!y||g?T=["zoom2d","pan2d"]:v||h?T=["pan2d"]:m&&(T=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),a=0,i=0;i0?h+u:u;return{ppad:u,ppadplus:c?p:g,ppadminus:c?g:p}}return{ppad:u}}function c(t,e,r,n,a){var s="category"===t.type||"multicategory"===t.type?t.r2c:t.d2c;if(void 0!==e)return[s(e),s(r)];if(n){var l,u,c,f,h=1/0,d=-1/0,p=n.match(i.segmentRE);for("date"===t.type&&(s=o.decodeDate(s)),l=0;ld&&(d=f)));return d>=h?[h,d]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:I?V(r.xanchor)+r.x0:V(r.x0),cy:z?q(r.yanchor)-r.y0:q(r.y0),r:i}).style(a).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:I?V(r.xanchor)+r.x1:V(r.x1),cy:z?q(r.yanchor)-r.y1:q(r.y1),r:i}).style(a).classed("cursor-grab",!0),n}():e,Y={element:W.node(),gd:t,prepFn:function(n){I&&(_=V(r.xanchor));z&&(w=q(r.yanchor));"path"===r.type?O=r.path:(m=I?r.x0:V(r.x0),y=z?r.y0:q(r.y0),b=I?r.x1:V(r.x1),x=z?r.y1:q(r.y1));mx?(A=y,E="y0",k=x,C="y1"):(A=x,E="y1",k=y,C="y0");Z(n),$(d,r),function(t,e,r){var n=e.xref,a=e.yref,o=i.getFromId(r,n),l=i.getFromId(r,a),u="";"paper"===n||o.autorange||(u+=n);"paper"===a||l.autorange||(u+=a);s.setClipUrl(t,u?"clip"+r._fullLayout._uid+u:null,r)}(e,r,t),Y.moveFn="move"===D?J:Q},doneFn:function(){c(e),K(d),p(e,t,r),n.call("_guiRelayout",t,B.getUpdateObj())},clickFn:function(){K(d)}};function Z(t){if(F)D="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Y.element.getBoundingClientRect(),n=r.right-r.left,a=r.bottom-r.top,i=t.clientX-r.left,o=t.clientY-r.top,s=!N&&n>R&&a>P&&!t.shiftKey?u.getCursor(i/n,1-o/a):"move";c(e,s),D=s.split("-")[0]}}function J(n,a){if("path"===r.type){var i=function(t){return t},o=i,s=i;I?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},U&&"date"===U.type&&(o=h.encodeDate(o))),z?j("yanchor",r.yanchor=X(w+a)):(s=function(t){return X(q(t)+a)},H&&"date"===H.type&&(s=h.encodeDate(s))),j("path",r.path=v(O,o,s))}else I?j("xanchor",r.xanchor=G(_+n)):(j("x0",r.x0=G(m+n)),j("x1",r.x1=G(b+n))),z?j("yanchor",r.yanchor=X(w+a)):(j("y0",r.y0=X(y+a)),j("y1",r.y1=X(x+a)));e.attr("d",g(t,r)),$(d,r)}function Q(n,a){if(N){var i=function(t){return t},o=i,s=i;I?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(V(t)+n)},U&&"date"===U.type&&(o=h.encodeDate(o))),z?j("yanchor",r.yanchor=X(w+a)):(s=function(t){return X(q(t)+a)},H&&"date"===H.type&&(s=h.encodeDate(s))),j("path",r.path=v(O,o,s))}else if(F){if("resize-over-start-point"===D){var l=m+n,u=z?y-a:y+a;j("x0",r.x0=I?l:G(l)),j("y0",r.y0=z?u:X(u))}else if("resize-over-end-point"===D){var c=b+n,f=z?x-a:x+a;j("x1",r.x1=I?c:G(c)),j("y1",r.y1=z?f:X(f))}}else{var p=~D.indexOf("n")?A+a:A,B=~D.indexOf("s")?k+a:k,W=~D.indexOf("w")?T+n:T,Y=~D.indexOf("e")?M+n:M;~D.indexOf("n")&&z&&(p=A-a),~D.indexOf("s")&&z&&(B=k-a),(!z&&B-p>P||z&&p-B>P)&&(j(E,r[E]=z?p:X(p)),j(C,r[C]=z?B:X(B))),Y-W>R&&(j(S,r[S]=I?W:G(W)),j(L,r[L]=I?Y:G(Y)))}e.attr("d",g(t,r)),$(d,r)}function $(t,e){(I||z)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var i=V(I?e.xanchor:a.midRange(r?[e.x0,e.x1]:h.extractPathCoords(e.path,f.paramIsX))),o=q(z?e.yanchor:a.midRange(r?[e.y0,e.y1]:h.extractPathCoords(e.path,f.paramIsY)));if(i=h.roundPositionForSharpStrokeRendering(i,1),o=h.roundPositionForSharpStrokeRendering(o,1),I&&z){var s="M"+(i-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",s)}else if(I){var l="M"+(i-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",l)}else{var u="M"+(i-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",u)}}()}function K(t){t.selectAll(".visual-cue").remove()}u.init(Y),W.node().onmousemove=Z}(t,b,r,e,d)}}function p(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");s.setClipUrl(t,n?"clip"+e._fullLayout._uid+n:null,e)}function g(t,e){var r,n,o,s,l,u,c,d,p=e.type,g=i.getFromId(t,e.xref),v=i.getFromId(t,e.yref),m=t._fullLayout._size;if(g?(r=h.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return m.l+m.w*t},v?(o=h.shapePositionToRange(v),s=function(t){return v._offset+v.r2p(o(t,!0))}):s=function(t){return m.t+m.h*(1-t)},"path"===p)return g&&"date"===g.type&&(n=h.decodeDate(n)),v&&"date"===v.type&&(s=h.decodeDate(s)),function(t,e,r){var n=t.path,i=t.xsizemode,o=t.ysizemode,s=t.xanchor,l=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,u=t.charAt(0),c=f.paramIsX[u],h=f.paramIsY[u],d=f.numParams[u],p=t.substr(1).replace(f.paramRE,function(t){return c[n]?t="pixel"===i?e(s)+Number(t):e(t):h[n]&&(t="pixel"===o?r(l)-Number(t):r(t)),++n>d&&(t="X"),t});return n>d&&(p=p.replace(/[\s,]*X.*/,""),a.log("Ignoring extra params in segment "+t)),u+p})}(e,n,s);if("pixel"===e.xsizemode){var y=n(e.xanchor);l=y+e.x0,u=y+e.x1}else l=n(e.x0),u=n(e.x1);if("pixel"===e.ysizemode){var b=s(e.yanchor);c=b-e.y0,d=b-e.y1}else c=s(e.y0),d=s(e.y1);if("line"===p)return"M"+l+","+c+"L"+u+","+d;if("rect"===p)return"M"+l+","+c+"H"+u+"V"+d+"H"+l+"Z";var x=(l+u)/2,_=(c+d)/2,w=Math.abs(x-l),A=Math.abs(_-c),k="A"+w+","+A,T=x+w+","+_;return"M"+T+k+" 0 1,1 "+(x+","+(_-A))+k+" 0 0,1 "+T+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,a=t.charAt(0),i=f.paramIsX[a],o=f.paramIsY[a],s=f.numParams[a];return a+t.substr(1).replace(f.paramRE,function(t){return n>=s?t:(i[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var a=0;a0&&(s=s.transition().duration(e.transition.duration).ease(e.transition.easing)),s.attr("transform","translate("+(o-.5*c.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function E(t,e){var r=t._dims;return r.inputAreaStart+c.stepInset+(r.inputAreaLength-2*c.stepInset)*Math.min(1,Math.max(0,e))}function C(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-c.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*c.stepInset-2*r.inputAreaStart)))}function S(t,e,r){var n=r._dims,a=s.ensureSingle(t,"rect",c.railTouchRectClass,function(n){n.call(k,e,t,r).style("pointer-events","all")});a.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,c.tickOffset+r.ticklen+n.labelHeight)}).call(i.fill,r.bgcolor).attr("opacity",0),o.setTranslate(a,0,n.currentValueTotalHeight)}function L(t,e){var r=e._dims,n=r.inputAreaLength-2*c.railInset,a=s.ensureSingle(t,"rect",c.railRectClass);a.attr({width:n,height:c.railWidth,rx:c.railRadius,ry:c.railRadius,"shape-rendering":"crispEdges"}).call(i.stroke,e.bordercolor).call(i.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(a,c.railInset,.5*(r.inputAreaWidth-c.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[c.name],n=[],a=0;a0?[0]:[]);function s(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),a.autoMargin(t,g(e))}if(i.enter().append("g").classed(c.containerClassName,!0).style("cursor","ew-resize"),i.exit().each(function(){n.select(this).selectAll("g."+c.groupClassName).each(s)}).remove(),0!==r.length){var l=i.selectAll("g."+c.groupClassName).data(r,v);l.enter().append("g").classed(c.groupClassName,!0),l.exit().each(s).remove();for(var u=0;u0||h<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[y.side];e.attr("transform","translate("+g+")")}}}R.call(P),O&&(M?R.on(".opacity",null):(A=0,k=!0,R.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),R.call(c.makeEditable,{gd:t}).on("edit",function(e){void 0!==m?o.call("_guiRestyle",t,g,e,m):o.call("_guiRelayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(P)}).on("input",function(t){this.text(t||" ").call(c.positionText,b.x,b.y)}));return R.classed("js-placeholder",k),_}};var h=/ [XY][0-9]* /},{"../../constants/interactions":415,"../../lib":437,"../../lib/svg_text_utils":461,"../../plots/plots":521,"../../registry":528,"../color":318,"../drawing":339,d3:85,"fast-isnumeric":149}],407:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),a=t("../color/attributes"),i=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes"),l=t("../../plot_api/plot_template").templatedArray,u=l("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(l("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:u,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:i(s({editType:"arraydraw"}),{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":429,"../../plot_api/edit_types":467,"../../plot_api/plot_template":474,"../../plots/font_attributes":511,"../../plots/pad_attributes":520,"../color/attributes":317}],408:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],409:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../plots/array_container_defaults"),i=t("./attributes"),o=t("./constants").name,s=i.buttons;function l(t,e,r){function o(r,a){return n.coerce(t,e,i,r,a)}o("visible",a(t,e,{name:"buttons",handleItemDefaults:u}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function u(t,e){function r(r,a){return n.coerce(t,e,s,r,a)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){a(t,e,{name:o,handleItemDefaults:l})}},{"../../lib":437,"../../plots/array_container_defaults":480,"./attributes":407,"./constants":408}],410:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/plots"),i=t("../color"),o=t("../drawing"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../../plot_api/plot_template").arrayEditor,c=t("../../constants/alignment").LINE_SPACING,f=t("./constants"),h=t("./scrollbox");function d(t){return t._index}function p(t,e){return+t.attr(f.menuIndexAttrName)===e._index}function g(t,e,r,n,a,i,o,s){e.active=o,u(t.layout,f.name,e).applyUpdate("active",o),"buttons"===e.type?m(t,n,null,null,e):"dropdown"===e.type&&(a.attr(f.menuIndexAttrName,"-1"),v(t,n,a,i,e),s||m(t,n,a,i,e))}function v(t,e,r,n,a){var i=s.ensureSingle(e,"g",f.headerClassName,function(t){t.style("pointer-events","all")}),l=a._dims,u=a.active,c=a.buttons[u]||f.blankHeaderOpts,h={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},d={width:l.headerWidth,height:l.headerHeight};i.call(y,a,c,t).call(M,a,h,d),s.ensureSingle(e,"text",f.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,a.font).text(f.arrowSymbol[a.direction])}).attr({x:l.headerWidth-f.arrowOffsetX+a.pad.l,y:l.headerHeight/2+f.textOffsetY+a.pad.t}),i.on("click",function(){r.call(E,String(p(r,a)?-1:a._index)),m(t,e,r,n,a)}),i.on("mouseover",function(){i.call(w)}),i.on("mouseout",function(){i.call(A,a)}),o.setTranslate(e,l.lx,l.ly)}function m(t,e,r,i,o){r||(r=e).attr("pointer-events","all");var l=function(t){return-1==+t.attr(f.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,u="dropdown"===o.type?f.dropdownButtonClassName:f.buttonClassName,c=r.selectAll("g."+u).data(s.filterVisible(l)),h=c.enter().append("g").classed(u,!0),d=c.exit();"dropdown"===o.type?(h.attr("opacity","0").transition().attr("opacity","1"),d.transition().attr("opacity","0").remove()):d.remove();var p=0,v=0,m=o._dims,b=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(b?v=m.headerHeight+f.gapButtonHeader:p=m.headerWidth+f.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(v=-f.gapButtonHeader+f.gapButton-m.openHeight),"dropdown"===o.type&&"left"===o.direction&&(p=-f.gapButtonHeader+f.gapButton-m.openWidth);var x={x:m.lx+p+o.pad.l,y:m.ly+v+o.pad.t,yPad:f.gapButton,xPad:f.gapButton,index:0},k={l:x.x+o.borderwidth,t:x.y+o.borderwidth};c.each(function(s,l){var u=n.select(this);u.call(y,o,s,t).call(M,o,x),u.on("click",function(){n.event.defaultPrevented||(g(t,o,0,e,r,i,l),s.execute&&a.executeAPICommand(t,s.method,s.args),t.emit("plotly_buttonclicked",{menu:o,button:s,active:o.active}))}),u.on("mouseover",function(){u.call(w)}),u.on("mouseout",function(){u.call(A,o),c.call(_,o)})}),c.call(_,o),b?(k.w=Math.max(m.openWidth,m.headerWidth),k.h=x.y-k.t):(k.w=x.x-k.l,k.h=Math.max(m.openHeight,m.headerHeight)),k.direction=o.direction,i&&(c.size()?function(t,e,r,n,a,i){var o,s,l,u=a.direction,c="up"===u||"down"===u,h=a._dims,d=a.active;if(c)for(s=0,l=0;l0?[0]:[]);if(o.enter().append("g").classed(f.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+f.headerGroupClassName).each(i)}).remove(),0!==r.length){var l=o.selectAll("g."+f.headerGroupClassName).data(r,d);l.enter().append("g").classed(f.headerGroupClassName,!0);for(var u=s.ensureSingle(o,"g",f.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),c=0;cw,T=s.barLength+2*s.barPad,M=s.barWidth+2*s.barPad,E=p,C=v+m;C+M>u&&(C=u-M);var S=this.container.selectAll("rect.scrollbar-horizontal").data(k?[0]:[]);S.exit().on(".drag",null).remove(),S.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,s.barColor),k?(this.hbar=S.attr({rx:s.barRadius,ry:s.barRadius,x:E,y:C,width:T,height:M}),this._hbarXMin=E+T/2,this._hbarTranslateMax=w-T):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var L=m>A,O=s.barWidth+2*s.barPad,D=s.barLength+2*s.barPad,R=p+g,P=v;R+O>l&&(R=l-O);var I=this.container.selectAll("rect.scrollbar-vertical").data(L?[0]:[]);I.exit().on(".drag",null).remove(),I.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,s.barColor),L?(this.vbar=I.attr({rx:s.barRadius,ry:s.barRadius,x:R,y:P,width:O,height:D}),this._vbarYMin=P+D/2,this._vbarTranslateMax=A-D):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var z=this.id,F=c-.5,N=L?f+O+.5:f+.5,B=h-.5,j=k?d+M+.5:d+.5,U=o._topdefs.selectAll("#"+z).data(k||L?[0]:[]);if(U.exit().remove(),U.enter().append("clipPath").attr("id",z).append("rect"),k||L?(this._clipRect=U.select("rect").attr({x:Math.floor(F),y:Math.floor(B),width:Math.ceil(N)-Math.floor(F),height:Math.ceil(j)-Math.floor(B)}),this.container.call(i.setClipUrl,z,this.gd),this.bg.attr({x:p,y:v,width:g,height:m})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),k||L){var H=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(H);var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));k&&this.hbar.on(".drag",null).call(V),L&&this.vbar.on(".drag",null).call(V)}this.setTranslate(e,r)},s.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(i.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},s.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},s.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},s.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,a=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,a)-r)/(a-r)*(this.position.w-this._box.w)}if(this.vbar){var i=e+this._vbarYMin,s=i+this._vbarTranslateMax;e=(o.constrain(n.event.y,i,s)-i)/(s-i)*(this.position.h-this._box.h)}this.setTranslate(t,e)},s.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(i.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var a=t/r;this.hbar.call(i.setTranslate,t+a*this._hbarTranslateMax,e)}if(this.vbar){var s=e/n;this.vbar.call(i.setTranslate,t,e+s*this._vbarTranslateMax)}}},{"../../lib":437,"../color":318,"../drawing":339,d3:85}],413:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,CAP_SHIFT:.7,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],414:[function(t,e,r){"use strict";e.exports={COMPARISON_OPS:["=","!=","<",">=",">","<="],COMPARISON_OPS2:["=","<",">=",">","<="],INTERVAL_OPS:["[]","()","[)","(]","][",")(","](",")["],SET_OPS:["{}","}{"],CONSTRAINT_REDUCTION:{"=":"=","<":"<","<=":"<",">":">",">=":">","[]":"[]","()":"[]","[)":"[]","(]":"[]","][":"][",")(":"][","](":"][",")[":"]["}}},{}],415:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],416:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],417:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],418:[function(t,e,r){"use strict";r.version="1.43.0",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config")();for(var n=t("./registry"),a=r.register=n.register,i=t("./plot_api"),o=Object.keys(i),s=0;s1/3&&t.x<2/3},r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isTopAnchor=function(t){return"top"===t.yanchor||"auto"===t.yanchor&&t.y>=2/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3}},{}],421:[function(t,e,r){"use strict";var n=t("./mod"),a=n.mod,i=n.modHalf,o=Math.PI,s=2*o;function l(t){return Math.abs(t[1]-t[0])>s-1e-15}function u(t,e){return i(e-t,s)}function c(t,e){if(l(e))return!0;var r,n;e[0](n=a(n,s))&&(n+=s);var i=a(t,s),o=i+s;return i>=r&&i<=n||o>=r&&o<=n}function f(t,e,r,n,a,i,u){a=a||0,i=i||0;var c,f,h,d,p,g=l([r,n]);function v(t,e){return[t*Math.cos(e)+a,i-t*Math.sin(e)]}g?(c=0,f=o,h=s):r=a&&t<=i);var a,i},pathArc:function(t,e,r,n,a){return f(null,t,e,r,n,a,0)},pathSector:function(t,e,r,n,a){return f(null,t,e,r,n,a,1)},pathAnnulus:function(t,e,r,n,a,i){return f(t,e,r,n,a,i,1)}}},{"./mod":444}],422:[function(t,e,r){"use strict";var n=Array.isArray,a="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},i="undefined"==typeof DataView?function(){}:DataView;function o(t){return a.isView(t)&&!(t instanceof i)}function s(t){return n(t)||o(t)}function l(t,e,r){if(s(t)){if(s(t[0])){for(var n=r,a=0;aa.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,a){t%1||!n(t)||void 0!==a.min&&ta.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var a="number"==typeof t;!0!==n.strict&&a?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){a(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return a(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o.get(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(c(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var a=n.regex||u(r);"string"==typeof t&&a.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!u(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var a=t.split("+"),i=0;i=n&&t<=a?t:c}if("string"!=typeof t&&"number"!=typeof t)return c;t=String(t);var u=_(e),m=t.charAt(0);!u||"G"!==m&&"g"!==m||(t=t.substr(1),e="");var w=u&&"chinese"===e.substr(0,7),A=t.match(w?b:y);if(!A)return c;var k=A[1],T=A[3]||"1",M=Number(A[5]||1),E=Number(A[7]||0),C=Number(A[9]||0),S=Number(A[11]||0);if(u){if(2===k.length)return c;var L;k=Number(k);try{var O=v.getComponentMethod("calendars","getCal")(e);if(w){var D="i"===T.charAt(T.length-1);T=parseInt(T,10),L=O.newDate(k,O.toMonthIndex(k,T,D),M)}else L=O.newDate(k,Number(T),M)}catch(t){return c}return L?(L.toJD()-g)*f+E*h+C*d+S*p:c}k=2===k.length?(Number(k)+2e3-x)%100+x:Number(k),T-=1;var R=new Date(Date.UTC(2e3,T,M,E,C));return R.setUTCFullYear(k),R.getUTCMonth()!==T?c:R.getUTCDate()!==M?c:R.getTime()+S*p},n=r.MIN_MS=r.dateTime2ms("-9999"),a=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==c};var A=90*f,k=3*h,T=5*d;function M(t,e,r,n,a){if((e||r||n||a)&&(t+=" "+w(e,2)+":"+w(r,2),(n||a)&&(t+=":"+w(n,2),a))){for(var i=4;a%10==0;)i-=1,a/=10;t+="."+w(a,i)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=a))return c;e||(e=0);var i,o,s,u,y,b,x=Math.floor(10*l(t+.05,1)),w=Math.round(t-x/10);if(_(r)){var E=Math.floor(w/f)+g,C=Math.floor(l(t,f));try{i=v.getComponentMethod("calendars","getCal")(r).fromJD(E).formatDate("yyyy-mm-dd")}catch(t){i=m("G%Y-%m-%d")(new Date(w))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=n+f&&t<=a-f))return c;var e=Math.floor(10*l(t+.05,1)),r=new Date(Math.round(t-e/10));return M(i.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===c)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return s.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return s.error("unrecognized date",t),e;return t};var E=/%\d?f/g;function C(t,e,r,n){t=t.replace(E,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(a)}var S=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,a,i){if(a=_(a)&&a,!e)if("y"===r)e=i.year;else if("m"===r)e=i.month;else{if("d"!==r)return function(t,e){var r=l(t+.05,f),n=w(Math.floor(r/h),2)+":"+w(l(Math.floor(r/d),60),2);if("M"!==e){o(e)||(e=0);var a=(100+Math.min(l(t/p,60),S[e])).toFixed(e).substr(1);e>0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+a}return n}(t,r)+"\n"+C(i.dayMonthYear,t,n,a);e=i.dayMonth+"\n"+i.year}return C(e,t,n,a)};var L=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=l(t,f);if(t=Math.round(t-n),r)try{var a=Math.round(t/f)+g,i=v.getComponentMethod("calendars","getCal")(r),o=i.fromJD(a);return e%12?i.add(o,e,"m"):i.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){s.error("invalid ms "+t+" in calendar "+r)}var u=new Date(t+L);return u.setUTCMonth(u.getUTCMonth()+e)+n-L},r.findExactDates=function(t,e){for(var r,n,a=0,i=0,s=0,l=0,u=_(e)&&v.getComponentMethod("calendars","getCal")(e),c=0;c1||g<0||g>1?null:{x:t+l*g,y:e+f*g}}function l(t,e,r,n,a){var i=n*t+a*e;if(i<0)return n*n+a*a;if(i>r){var o=n-t,s=a-e;return o*o+s*s}var l=n*e-a*t;return l*l/r}r.segmentsIntersect=s,r.segmentDistance=function(t,e,r,n,a,i,o,u){if(s(t,e,r,n,a,i,o,u))return 0;var c=r-t,f=n-e,h=o-a,d=u-i,p=c*c+f*f,g=h*h+d*d,v=Math.min(l(c,f,p,a-t,i-e),l(c,f,p,o-t,u-e),l(h,d,g,t-a,e-i),l(h,d,g,r-a,n-i));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,s){if(t===a&&s===i||(n={},a=t,i=s),n[r])return n[r];var l=t.getPointAtLength(o(r-s/2,e)),u=t.getPointAtLength(o(r+s/2,e)),c=Math.atan((u.y-l.y)/(u.x-l.x)),f=t.getPointAtLength(o(r,e)),h={x:(4*f.x+l.x+u.x)/6,y:(4*f.y+l.y+u.y)/6,theta:c};return n[r]=h,h},r.clearLocationCache=function(){a=null},r.getVisibleSegment=function(t,e,r){var n,a,i=e.left,o=e.right,s=e.top,l=e.bottom,u=0,c=t.getTotalLength(),f=c;function h(e){var r=t.getPointAtLength(e);0===e?n=r:e===c&&(a=r);var u=r.xo?r.x-o:0,f=r.yl?r.y-l:0;return Math.sqrt(u*u+f*f)}for(var d=h(u);d;){if((u+=d+r)>f)return;d=h(u)}for(d=h(f);d;){if(u>(f-=d+r))return;d=h(f)}return{min:u,max:f,len:f-u,total:c,isClosed:0===u&&f===c&&Math.abs(n.x-a.x)<.1&&Math.abs(n.y-a.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var a,i,o,s=(n=n||{}).pathLength||t.getTotalLength(),l=n.tolerance||.001,u=n.iterationLimit||30,c=t.getPointAtLength(0)[r]>t.getPointAtLength(s)[r]?-1:1,f=0,h=0,d=s;f0?d=a:h=a,f++}return i}},{"./mod":444}],433:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],434:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("tinycolor2"),i=t("color-normalize"),o=t("../components/colorscale"),s=t("../components/color/attributes").defaultLine,l=t("./array").isArrayOrTypedArray,u=i(s),c=1;function f(t,e){var r=t;return r[3]*=e,r}function h(t){if(n(t))return u;var e=i(t);return e.length?e:u}function d(t){return n(t)?t:c}e.exports={formatColor:function(t,e,r){var n,a,s,p,g,v=t.color,m=l(v),y=l(e),b=[];if(n=void 0!==t.colorscale?o.makeColorScaleFunc(o.extractScale(t,{cLetter:"c"})):h,a=m?function(t,e){return void 0===t[e]?u:i(n(t[e]))}:h,s=y?function(t,e){return void 0===t[e]?c:d(t[e])}:d,m||y)for(var x=0;xo?s:a(t)?Number(t):s:s},l.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(a(t)&&t>=0&&t%1==0)},l.noop=t("./noop"),l.identity=t("./identity"),l.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},l.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},l.simpleMap=function(t,e,r,n){for(var a=t.length,i=new Array(a),o=0;o=Math.pow(2,r)?a>10?(l.warn("randstr failed uniqueness"),u):t(e,r,n,(a||0)+1):u},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,a,i,o=t.length,s=2*o,l=2*e-1,u=new Array(l),c=new Array(o);for(r=0;r=s&&(a-=s*Math.floor(a/s)),a<0?a=-1-a:a>=o&&(a=s-1-a),i+=t[a]*u[n];c[r]=i}return c},l.syncOrAsync=function(t,e,r){var n;function a(){return l.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(a).then(void 0,l.promiseError);return r&&r(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,r){if(t){var n,a=!1,i=!0;for(n=0;n1?a+o[1]:"";if(i&&(o.length>1||s.length>4||r))for(;n.test(s);)s=s.replace(n,"$1"+i+"$2");return s+l};var M=/%{([^\s%{}:]*)(:[^}]*)?}/g,E=/^\w*$/;l.templateString=function(t,e){var r={};return t.replace(M,function(t,n){return E.test(n)?e[n]||"":(r[n]=r[n]||l.nestedProperty(e,n).get,r[n]()||"")})};var C=/^:/,S=0;l.hovertemplateString=function(t,e){var r=arguments,a={};return t.replace(M,function(t,i,o){var s,u,c;for(c=2;c=48&&o<=57,u=s>=48&&s<=57;if(l&&(n=10*n+o-48),u&&(a=10*a+s-48),!l||!u){if(n!==a)return n-a;if(o!==s)return o-s}}return a-n};var L=2e9;l.seedPseudoRandom=function(){L=2e9},l.pseudoRandom=function(){var t=L;return L=(69069*L+1)%4294967296,Math.abs(L-t)<429496729?l.pseudoRandom():L/4294967296}},{"../constants/numerical":416,"./anchor_utils":420,"./angles":421,"./array":422,"./clean_number":423,"./clear_responsive":425,"./coerce":426,"./dates":427,"./extend":429,"./filter_unique":430,"./filter_visible":431,"./geometry2d":432,"./get_graph_div":433,"./identity":436,"./is_plain_object":438,"./keyed_container":439,"./localize":440,"./loggers":441,"./make_trace_groups":442,"./matrix":443,"./mod":444,"./nested_property":445,"./noop":446,"./notifier":447,"./push_unique":451,"./regex":453,"./relative_attr":454,"./relink_private":455,"./search":456,"./stats":459,"./throttle":462,"./to_log_range":463,d3:85,"fast-isnumeric":149}],438:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],439:[function(t,e,r){"use strict";var n=t("./nested_property"),a=/^\w*$/;e.exports=function(t,e,r,i){var o,s,l;r=r||"name",i=i||"value";var u={};e&&e.length?(l=n(t,e),s=l.get()):s=t,e=e||"";var c={};if(s)for(o=0;o2)return u[e]=2|u[e],h.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],445:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,l=0,u=e.split(".");l/g),o=0;oi||u===a||us||e&&l(t))}:function(t,e){var l=t[0],u=t[1];if(l===a||li||u===a||us)return!1;var c,f,h,d,p,g=r.length,v=r[0][0],m=r[0][1],y=0;for(c=1;cMath.max(f,v)||u>Math.max(h,m)))if(uc||Math.abs(n(o,h))>a)return!0;return!1};i.filter=function(t,e){var r=[t[0]],n=0,a=0;function i(i){t.push(i);var s=r.length,l=n;r.splice(a+1);for(var u=l+1;u1&&i(t.pop());return{addPt:i,raw:t,filtered:r}}},{"../constants/numerical":416,"./matrix":443}],450:[function(t,e,r){(function(r){"use strict";var n=t("./show_no_webgl_msg"),a=t("regl");e.exports=function(t,e){var i=t._fullLayout,o=!0;return i._glcanvas.each(function(n){if(!n.regl&&(!n.pick||i._has("parcoords"))){try{n.regl=a({canvas:this,attributes:{antialias:!n.pick,preserveDrawingBuffer:!0},pixelRatio:t._context.plotGlPixelRatio||r.devicePixelRatio,extensions:e||[]})}catch(t){o=!1}o&&this.addEventListener("webglcontextlost",function(e){t&&t.emit&&t.emit("plotly_webglcontextlost",{event:e,layer:n.key})},!1)}}),o||n({container:i._glcontainer.node()}),o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./show_no_webgl_msg":458,regl:259}],451:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ra.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function u(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var i,c,f=0,h=e.length,d=0,p=h>1?(e[h-1]-e[0])/(h-1):1;for(c=p>=0?r?o:s:r?u:l,t+=1e-9*p*(r?-1:1)*(p>=0?1:-1);f90&&a.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,a=e[n]-e[0]||1,i=a/(n||1)/1e4,o=[e[0]],s=0;se[s]+i&&(a=Math.min(a,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:a}},r.roundUp=function(t,e,r){for(var n,a=0,i=e.length-1,o=0,s=r?0:1,l=r?1:0,u=r?Math.ceil:Math.floor;a0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||i;for(var r,n=1/0,a=0;ai.length)&&(o=i.length),n(e)||(e=!1),a(i[0])){for(l=new Array(o),s=0;st.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":422,"fast-isnumeric":149}],460:[function(t,e,r){"use strict";var n=t("color-normalize");e.exports=function(t){return t?n(t):[0,0,0,1]}},{"color-normalize":63}],461:[function(t,e,r){"use strict";var n=t("d3"),a=t("../lib"),i=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function s(t,e){return t.node().getBoundingClientRect()[e]}var l=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var E=t.text(),C=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&E.match(l),L=n.select(t.node().parentNode);if(!L.empty()){var O=t.attr("class")?t.attr("class").split(" ")[0]:"text";return O+="-math",L.selectAll("svg."+O).remove(),L.selectAll("g."+O+"-group").remove(),t.style("display",null).attr({"data-unformatted":E,"data-math":"N"}),C?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),i={fontSize:r};!function(t,e,r){var i,o,s,l;MathJax.Hub.Queue(function(){return o=a.extendDeepAll({},MathJax.Hub.config),s=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(i=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+a.randstr({},64);return l=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(u,"\\lt ").replace(c,"\\gt ")),MathJax.Hub.Typeset(l.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(l.select(".MathJax_SVG").empty()||!l.select("svg").node())a.log("There was an error in the tex syntax.",t),r();else{var o=l.select("svg").node().getBoundingClientRect();r(l.select(".MathJax_SVG"),e,o)}if(l.remove(),"SVG"!==i)return MathJax.Hub.setRenderer(i)},function(){return void 0!==s&&(MathJax.Hub.processSectionDelay=s),MathJax.Hub.Config(o)})}(C[2],i,function(n,a,i){L.selectAll("svg."+O).remove(),L.selectAll("g."+O+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return D(),void e();var l=L.append("g").classed(O+"-group",!0).attr({"pointer-events":"none","data-unformatted":E,"data-math":"Y"});l.node().appendChild(o.node()),a&&a.node()&&o.node().insertBefore(a.node().cloneNode(!0),o.node().firstChild),o.attr({class:O,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=t.node().style.fill||"black";o.select("g").attr({fill:u,stroke:u});var c=s(o,"width"),f=s(o,"height"),h=+t.attr("x")-c*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],d=-(r||s(t,"height"))/4;"y"===O[0]?(l.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-c/2,d-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===O[0]?o.attr({x:t.attr("x"),y:d-f/2}):"a"===O[0]?o.attr({x:0,y:d}):o.attr({x:h,y:+t.attr("y")+d-f/2}),v&&v.call(t,l),e(l)})})):D(),t}function D(){L.empty()||(O=t.attr("class")+"-math",L.select("svg."+O).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(m," ");var r,s=!1,l=[],u=-1;function c(){u++;var e=document.createElementNS(i.svg,"tspan");n.select(e).attr({class:"line",dy:u*o+"em"}),t.appendChild(e),r=e;var a=l;if(l=[{node:e}],a.length>1)for(var s=1;s doesnt match end tag <"+t+">. Pretending it did match.",e),r=l[l.length-1].node}else a.log("Ignoring unexpected end tag .",e)}x.test(e)?c():(r=t,l=[{node:t}]);for(var L=e.split(y),O=0;O|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},h={sub:"0.3em",sup:"-0.6em"},d={sub:"-0.21em",sup:"0.42em"},p="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),m=/(\r\n?|\n)/g,y=/(<[^<>]*>)/,b=/<(\/?)([^ >]*)(\s+(.*))?>/i,x=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,A=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,k=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function T(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&S(n)}var M=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var E={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},C=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function S(t){return t.replace(C,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):E[e])||t})}function L(t,e,r){var n,a,i,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),u=e.node().getBoundingClientRect();return a="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},i="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:a()-u.top+"px",left:i()-u.left+"px","z-index":1e3}),this}}r.convertEntities=S,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function a(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var i=a("x",e),o=a("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:i,y:o})})},r.makeEditable=function(t,e){var r=e.gd,a=e.delegate,i=n.dispatch("edit","input","cancel"),o=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");function s(){!function(){var a=n.select(r).select(".svg-container"),o=a.append("div"),s=t.node().style,u=parseFloat(s.fontSize||12),c=e.text;void 0===c&&(c=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":s.fontFamily||"Arial","font-size":u,color:e.fill||s.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-u/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(c).call(L(t,a,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,a=n.select(this).attr("class");(e=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),i.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),i.cancel.call(t,this.textContent)):(i.input.call(t,this.textContent),n.select(this).call(L(t,a,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(l)}(),t.style({opacity:0});var a,s=o.attr("class");(a=s?"."+s.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(a).style({opacity:0})}function l(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?s():o.on("click",s),n.rebind(t,i,"on")}},{"../constants/alignment":413,"../constants/xmlns_namespaces":417,"../lib":437,d3:85}],462:[function(t,e,r){"use strict";var n={};function a(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var i=n[t],o=Date.now();if(!i){for(var s in n)n[s].tsi.ts+e?l():i.timer=setTimeout(function(){l(),i.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)a(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],463:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":149}],464:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],465:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],466:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,a=n.layoutArrayContainers,i=n.layoutArrayRegexes,o=t.split("[")[0],s=0;s0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var i=(s.subplotsRegistry.cartesian||{}).attrRegex,l=(s.subplotsRegistry.polar||{}).attrRegex,c=(s.subplotsRegistry.ternary||{}).attrRegex,p=(s.subplotsRegistry.gl3d||{}).attrRegex,g=Object.keys(t);for(e=0;e3?(O.x=1.02,O.xanchor="left"):O.x<-2&&(O.x=-.02,O.xanchor="right"),O.y>3?(O.y=1.02,O.yanchor="bottom"):O.y<-2&&(O.y=-.02,O.yanchor="top")),d(t),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t.template&&t.template.layout&&r.cleanLayout(t.template.layout),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=b(e);r;){if(r in t)return!0;r=b(r)}return!1};var x=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&i.warn("Full array edits are incompatible with other edits",f);var y=r[""][""];if(u(y))e.set(null);else{if(!Array.isArray(y))return i.warn("Unrecognized full array edit value",f,y),!0;e.set(y)}return!g&&(h(v,m),d(t),!0)}var b,x,_,w,A,k,T,M,E=Object.keys(r).map(Number).sort(o),C=e.get(),S=C||[],L=c(m,f).get(),O=[],D=-1,R=S.length;for(b=0;bS.length-(T?0:1))i.warn("index out of range",f,_);else if(void 0!==k)A.length>1&&i.warn("Insertion & removal are incompatible with edits to the same index.",f,_),u(k)?O.push(_):T?("add"===k&&(k={}),S.splice(_,0,k),L&&L.splice(_,0,{})):i.warn("Unrecognized full object edit value",f,_,k),-1===D&&(D=_);else for(x=0;x=0;b--)S.splice(O[b],1),L&&L.splice(O[b],1);if(S.length?C||e.set(S):e.set(null),g)return!1;if(h(v,m),p!==a){var P;if(-1===D)P=E;else{for(R=Math.max(S.length,R),P=[],b=0;b=D);b++)P.push(_);for(b=D;b=t.data.length||a<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(a,n+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+r+" must be unique.")}}function P(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),R(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&R(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function I(t,e,r,n,i){!function(t,e,r,n){var a=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var i in R(t,r,"indices"),e){if(!Array.isArray(e[i])||e[i].length!==r.length)throw new Error("attribute "+i+" must be an array of length equal to indices array length");if(a&&(!(i in n)||!Array.isArray(n[i])||n[i].length!==e[i].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var l=function(t,e,r,n){var i,l,u,c,f,h=o.isPlainObject(n),d=[];for(var p in Array.isArray(r)||(r=[r]),r=D(r,t.data.length-1),e)for(var g=0;g-1?l(r,r.replace("titlefont","title.font")):r.indexOf("titleposition")>-1?l(r,r.replace("titleposition","title.position")):r.indexOf("titleside")>-1?l(r,r.replace("titleside","title.side")):r.indexOf("titleoffset")>-1&&l(r,r.replace("titleoffset","title.offset")):l(r,r.replace("title","title.text"));function l(e,r){t[r]=t[e],delete t[e]}}function V(t,e,r){if(t=o.getGraphDiv(t),A.clearPromiseQueue(t),t.framework&&t.framework.isPolar)return Promise.resolve(t);var n={};if("string"==typeof e)n[e]=r;else{if(!o.isPlainObject(e))return o.warn("Relayout fail.",e,r),Promise.reject();n=o.extendFlat({},e)}Object.keys(n).length&&(t.changed=!0);var a=Z(t,n),i=a.flags;i.calc&&(t.calcdata=void 0);var s=[h.previousPromises];i.layoutReplot?s.push(k.layoutReplot):Object.keys(n).length&&(q(t,i,a)||h.supplyDefaults(t),i.legend&&s.push(k.doLegend),i.layoutstyle&&s.push(k.layoutStyles),i.axrange&&G(s,a.rangesAltered),i.ticks&&s.push(k.doTicksRelayout),i.modebar&&s.push(k.doModeBar),i.camera&&s.push(k.doCamera),s.push(C)),s.push(h.rehover),u.add(t,V,[t,a.undoit],V,[t,a.redoit]);var l=o.syncOrAsync(s,t);return l&&l.then||(l=Promise.resolve(t)),l.then(function(){return t.emit("plotly_relayout",a.eventData),t})}function q(t,e,r){var n;if(!e.axrange)return!1;for(n in e)if("axrange"!==n&&e[n])return!1;for(n in r.rangesAltered){var a=p.id2name(n),i=t.layout[a],o=t._fullLayout[a];o.autorange=i.autorange,o.range=i.range.slice(),o.cleanRange()}return!0}function G(t,e){var r=e?function(t){var r={skipTitle:!0};for(var n in e)if(p.getFromId(t,n).automargin){r={};break}return p.draw(t,Object.keys(e),r)}:function(t){return p.draw(t,"redraw")};t.push(k.doAutoRangeAndConstraints,r,k.drawData,k.finalDraw)}r.plot=function(t,e,a,i){var s;if(t=o.getGraphDiv(t),l.init(t),o.isPlainObject(e)){var u=e;e=u.data,a=u.layout,i=u.config,s=u.frames}if(!1===l.triggerHandler(t,"plotly_beforeplot",[e,a,i]))return Promise.reject();e||a||o.isPlotDiv(t)||o.warn("Calling Plotly.plot as if redrawing but this container doesn't yet have a plot.",t),O(t,i),a||(a={}),n.select(t).classed("js-plotly-plot",!0),g.makeTester(),Array.isArray(t._promises)||(t._promises=[]);var f=0===(t.data||[]).length&&Array.isArray(e);if(Array.isArray(e)&&(A.cleanData(e),f?t.data=e:t.data.push.apply(t.data,e),t.empty=!1),t.layout&&!f||(t.layout=A.cleanLayout(a)),t._dragging&&!t._transitioning)return t._replotPending=!0,Promise.reject();t._replotPending=!1,h.supplyDefaults(t);var v=t._fullLayout,b=v._has("cartesian");if(!v._has("polar")&&e&&e[0]&&e[0].r)return o.log("Legacy polar charts are deprecated!"),function(t,e,r){var a=n.select(t).selectAll(".plot-container").data([0]);a.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=a.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e);r&&(t.layout=r);d.manager.fillLayout(t),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=d.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var s=t.framework.svg(),l=1,u=t._fullLayout.title?t._fullLayout.title.text:"";""!==u&&u||(l=0);var c=function(){this.call(x.convertToTspans,t)},f=s.select(".title-group text").call(c);if(t._context.edits.titleText){var p=o._(t,"Click to enter Plot title");u&&u!==p||(l=.2,f.attr({"data-unformatted":p}).text(p).style({opacity:l}).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)}));var g=function(){this.call(x.makeEditable,{gd:t}).on("edit",function(e){t.framework({layout:{title:{text:e}}}),this.text(e).call(c),this.call(g)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};f.call(g)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),h.addLinks(t),Promise.resolve()}(t,e,a);v._replotting=!0,f&&st(t),t.framework!==st&&(t.framework=st,st(t)),g.initGradients(t),f&&p.saveShowSpikeInitial(t);var _=!t.calcdata||t.calcdata.length!==(t._fullData||[]).length;_&&h.doCalcdata(t);for(var w=0;w=0&&r=0&&r0&&"string"!=typeof R.parts[I];)I--;var z=R.parts[I],F=R.parts[I-1]+"."+z,j=R.parts.slice(0,I).join("."),U=s(t.layout,j).get(),V=s(l,j).get(),q=R.get();if(void 0!==P){k[D]=P,E[D]="reverse"===z?P:N(q);var G=f.getLayoutValObject(l,R.parts);if(G&&G.impliedEdits&&null!==P)for(var Z in G.impliedEdits)C(o.relativeAttr(D,Z),G.impliedEdits[Z]);if(-1!==["width","height"].indexOf(D))if(P){C("autosize",null);var Q="height"===D?"width":"height";C(Q,l[Q])}else l[D]=t._initialAutoSize[D];else if("autosize"===D)C("width",P?null:l.width),C("height",P?null:l.height);else if(F.match(X))O(F),s(l,j+"._inputRange").set(null);else if(F.match(W)){O(F),s(l,j+"._inputRange").set(null);var $=s(l,j).get();$._inputDomain&&($._input.domain=$._inputDomain.slice())}else F.match(Y)&&s(l,j+"._inputDomain").set(null);if("type"===z){var K=U,tt="linear"===V.type&&"log"===P,et="log"===V.type&&"linear"===P;if(tt||et){if(K&&K.range)if(V.autorange)tt&&(K.range=K.range[1]>K.range[0]?[1,2]:[2,1]);else{var rt=K.range[0],nt=K.range[1];tt?(rt<=0&&nt<=0&&C(j+".autorange",!0),rt<=0?rt=nt/1e6:nt<=0&&(nt=rt/1e6),C(j+".range[0]",Math.log(rt)/Math.LN10),C(j+".range[1]",Math.log(nt)/Math.LN10)):(C(j+".range[0]",Math.pow(10,rt)),C(j+".range[1]",Math.pow(10,nt)))}else C(j+".autorange",!0);Array.isArray(l._subplots.polar)&&l._subplots.polar.length&&l[R.parts[0]]&&"radialaxis"===R.parts[1]&&delete l[R.parts[0]]._subplot.viewInitial["radialaxis.range"],c.getComponentMethod("annotations","convertCoords")(t,V,P,C),c.getComponentMethod("images","convertCoords")(t,V,P,C)}else C(j+".autorange",!0),C(j+".range",null);s(l,j+"._inputRange").set(null)}else if(z.match(M)){var at=s(l,D).get(),it=(P||{}).type;it&&"-"!==it||(it="linear"),c.getComponentMethod("annotations","convertCoords")(t,at,it,C),c.getComponentMethod("images","convertCoords")(t,at,it,C)}var ot=w.containerArrayMatch(D);if(ot){r=ot.array,n=ot.index;var st=ot.property,lt=G||{editType:"calc"};""!==n&&""===st&&(w.isAddVal(P)?E[D]=null:w.isRemoveVal(P)?E[D]=(s(i,r).get()||[])[n]:o.warn("unrecognized full object value",e)),T.update(_,lt),m[r]||(m[r]={});var ut=m[r][n];ut||(ut=m[r][n]={}),ut[st]=P,delete e[D]}else"reverse"===z?(U.range?U.range.reverse():(C(j+".autorange",!0),U.range=[1,0]),V.autorange?_.calc=!0:_.plot=!0):(l._has("scatter-like")&&l._has("regl")&&"dragmode"===D&&("lasso"===P||"select"===P)&&"lasso"!==q&&"select"!==q?_.plot=!0:G?T.update(_,G):_.calc=!0,R.set(P))}}for(r in m){w.applyContainerArrayChanges(t,h(i,r),m[r],_,h)||(_.plot=!0)}var ct=l._axisConstraintGroups||[];for(S in L)for(n=0;n1;)if(n.pop(),void 0!==(r=s(e,n.join(".")+".uirevision").get()))return r;return e.uirevision}function nt(t,e){for(var r=0;r=a.length?a[0]:a[t]:a}function l(t){return Array.isArray(i)?t>=i.length?i[0]:i[t]:i}function u(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(i,c){function f(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,h.transition(t,e.frame.data,e.frame.layout,A.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function d(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&f()};e()}var p,g,v=0;function m(t){return Array.isArray(a)?v>=a.length?t.transitionOpts=a[v]:t.transitionOpts=a[0]:t.transitionOpts=a,v++,t}var y=[],b=null==e,x=Array.isArray(e);if(!b&&!x&&o.isPlainObject(e))y.push({type:"object",data:m(o.extendFlat({},e))});else if(b||-1!==["string","number"].indexOf(typeof e))for(p=0;p0&&kk)&&T.push(g);y=T}}y.length>0?function(e){if(0!==e.length){for(var a=0;a=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(c[g]||p[g]||{}).name,m=e[n].name,y=c[v]||p[v];v&&m&&"number"==typeof m&&y&&E<5&&(E++,o.warn('addFrames: overwriting frame "'+(c[v]||p[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===E&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),p[g]={name:g},d.push({frame:h.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:f+n})}d.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(a=d[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;c[a.name="frame "+t._transitionData._counter++];);if(c[a.name]){for(i=0;i=0;r--)n=e[r],i.push({type:"delete",index:n}),s.unshift({type:"insert",index:n,value:a[n]});var l=h.modifyFrames,c=h.modifyFrames,f=[t,s],d=[t,i];return u&&u.add(t,l,f,c,d),h.modifyFrames(t,i)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return h.cleanPlot([],{},r,e),h.purge(t),l.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":318,"../components/colorbar/connect":320,"../components/drawing":339,"../constants/xmlns_namespaces":417,"../lib":437,"../lib/events":428,"../lib/queue":452,"../lib/svg_text_utils":461,"../plots/cartesian/axes":484,"../plots/cartesian/constants":490,"../plots/cartesian/graph_interact":494,"../plots/plots":521,"../plots/polar/legacy":524,"../registry":528,"./edit_types":467,"./helpers":468,"./manage_arrays":470,"./plot_config":472,"./plot_schema":473,"./subroutines":475,d3:85,"fast-isnumeric":149,"has-hover":200}],472:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,showSendToCloud:!1,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,watermark:!1,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],473:[function(t,e,r){"use strict";var n=t("../registry"),a=t("../lib"),i=t("../plots/attributes"),o=t("../plots/layout_attributes"),s=t("../plots/frame_attributes"),l=t("../plots/animation_attributes"),u=t("../plots/polar/legacy/area_attributes"),c=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),h=a.extendFlat,d=a.extendDeepAll,p=a.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",m=[g,v,"_arrayAttrRegexps","_deprecated"];function y(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(b(e[r]))r++;else if(r=i.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!b(o))return!1;t=i[a][o]}else t=i[a]}else t=i}}return t}function b(t){return t===Math.round(t)&&t>=0}function x(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):p(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(p(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=l.length)return!1;a=(r=(n.transformsRegistry[l[c].type]||{}).attributes)&&r[e[2]],s=3}else if("area"===t.type)a=u[o];else{var f=t._module;if(f||(f=(n.modules[t.type||i.type.dflt]||{})._module),!f)return!1;if(!(a=(r=f.attributes)&&r[o])){var h=f.basePlotModule;h&&h.attributes&&(a=h.attributes[o])}a||(a=i[o])}return y(a,e,s)},r.getLayoutValObject=function(t,e){return y(function(t,e){var r,a,i,s,l=t._basePlotModules;if(l){var u;for(r=0;r=a&&(r._input||{})._templateitemname;s&&(o=a);var l,u=e+"["+o+"]";function c(){l={},s&&(l[u]={},l[u][i]=s)}function f(t,e){s?n.nestedProperty(l[u],t).set(e):l[u+"."+t]=e}function h(){var t=l;return c(),t}return c(),{modifyBase:function(t,e){l[t]=e},modifyItem:f,getUpdateObj:h,applyUpdate:function(e,r){e&&f(e,r);var a=h();for(var i in a)n.nestedProperty(t,i).set(a[i])}}}},{"../lib":437,"../plots/attributes":481}],475:[function(t,e,r){"use strict";var n=t("d3"),a=t("../registry"),i=t("../plots/plots"),o=t("../lib"),s=t("../lib/clear_gl_canvases"),l=t("../components/color"),u=t("../components/drawing"),c=t("../components/titles"),f=t("../components/modebar"),h=t("../plots/cartesian/axes"),d=t("../constants/alignment"),p=t("../plots/cartesian/constraints"),g=p.enforce,v=p.clean,m=t("../plots/cartesian/autorange").doAutoRange,y="start",b="middle",x="end";function _(t,e,r){for(var n=0;n=t[1]||a[1]<=t[0])&&(i[0]e[0]))return!0}return!1}function w(t){var e,a,i,s,c,p,g=t._fullLayout,v=g._size,m=v.p,y=h.list(t,"",!0);if(g._paperdiv.style({width:t._context.responsive&&g.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":g.width+"px",height:t._context.responsive&&g.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":g.height+"px"}).selectAll(".main-svg").call(u.setSize,g.width,g.height),t._context.setBackground(t,g.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!g._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function b(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-m-n:e._offset+e._length+m+n:v.t+v.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+m+n:e._offset-m-n:v.l+v.w*(t.position||0)+n%1}for(e=0;eA?c.push({code:"unused",traceType:y,templateCount:w,dataCount:A}):A>w&&c.push({code:"reused",traceType:y,templateCount:w,dataCount:A})}}else c.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var i=e[n],o=d(e,n,r);a(i)?(Array.isArray(e)&&!1===i._template&&i.templateitemname&&c.push({code:"missing",path:o,templateitemname:i.templateitemname}),t(i,o)):Array.isArray(i)&&p(i)&&t(i,o)}}({data:v,layout:h},""),c.length)return c.map(g)}},{"../lib":437,"../plots/attributes":481,"../plots/plots":521,"./plot_config":472,"./plot_schema":473,"./plot_template":474}],477:[function(t,e,r){"use strict";var n=t("./plot_api"),a=t("../lib"),i=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),s=t("../snapshot/svgtoimg"),l={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},u=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,c,f;function h(t){return!(t in e)||a.validate(e[t],l[t])}if(e=e||{},a.isPlainObject(t)?(r=t.data||[],c=t.layout||{},f=t.config||{}):(t=a.getGraphDiv(t),r=a.extendDeep([],t.data),c=a.extendDeep({},t.layout),f=t._context),!h("width")||!h("height"))throw new Error("Height and width should be pixel values.");if(!h("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var d={};function p(t,r){return a.coerce(e,d,l,t,r)}var g=p("format"),v=p("width"),m=p("height"),y=p("scale"),b=p("setBackground"),x=p("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=a.extendFlat({},c);v&&(w.width=v),m&&(w.height=m);var A=a.extendFlat({},f,{_exportedPlot:!0,staticPlot:!0,setBackground:b}),k=i.getRedrawFunc(_);function T(){return new Promise(function(t){setTimeout(t,i.getDelay(_._fullLayout))})}function M(){return new Promise(function(t,e){var r=o(_,g,y),i=_._fullLayout.width,l=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(x?r:"data:image/svg+xml,"+encodeURIComponent(r));var u=document.createElement("canvas");u.id=a.randstr(),s({format:g,width:i,height:l,scale:y,canvas:u,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,A).then(k).then(T).then(M).then(function(e){t(function(t){return x?t.replace(u,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":437,"../snapshot/helpers":532,"../snapshot/svgtoimg":534,"../snapshot/tosvg":536,"./plot_api":471}],478:[function(t,e,r){"use strict";var n=t("../lib"),a=t("../plots/plots"),i=t("./plot_schema"),o=t("./plot_config"),s=n.isPlainObject,l=Array.isArray,u=n.isArrayOrTypedArray;function c(t,e,r,a,i,o){o=o||[];for(var f=Object.keys(t),h=0;hb.length&&a.push(d("unused",i,m.concat(b.length)));var k,T,M,E,C,S=b.length,L=Array.isArray(A);if(L&&(S=Math.min(S,A.length)),2===x.dimensions)for(T=0;Tb[T].length&&a.push(d("unused",i,m.concat(T,b[T].length)));var O=b[T].length;for(k=0;k<(L?Math.min(O,A[T].length):O);k++)M=L?A[T][k]:A,E=y[T][k],C=b[T][k],n.validate(E,M)?C!==E&&C!==+E&&a.push(d("dynamic",i,m.concat(T,k),E,C)):a.push(d("value",i,m.concat(T,k),E))}else a.push(d("array",i,m.concat(T),y[T]));else for(T=0;T1&&h.push(d("object","layout"))),a.supplyDefaults(p);for(var g=p._fullData,v=r.length,m=0;m0&&((x=T-o(v)-o(m))>M?_/x>E&&(y=v,b=m,E=_/x):_/T>E&&(y={val:v.val,pad:0},b={val:m.val,pad:0},E=_/T));if(h===d){var C=h-1,S=h+1;if(A)if(0===h)i=[0,1];else{var L=(h>0?f:c).reduce(function(t,e){return Math.max(t,o(e))},0),O=h/(1-Math.min(.5,L/T));i=h>0?[0,O]:[O,0]}else i=k?[Math.max(0,C),Math.max(1,S)]:[C,S]}else A?(y.val>=0&&(y={val:0,pad:0}),b.val<=0&&(b={val:0,pad:0})):k&&(y.val-E*o(y)<0&&(y={val:0,pad:0}),b.val<=0&&(b={val:1,pad:0})),E=(b.val-y.val)/(T-o(y)-o(b)),i=[y.val-E*o(y),b.val+E*o(b)];return p&&i.reverse(),a.simpleMap(i,e.l2r||Number)}function l(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function u(t,e){var r,n,a,i=e._id,o=t._fullData,s=t._fullLayout,l=[],u=[];function h(t,e){for(r=0;r=r&&(u.extrapad||!o)){s=!1;break}a(e,u.val)&&u.pad<=r&&(o||!u.extrapad)&&(t.splice(l,1),l--)}if(s){var c=i&&0===e;t.push({val:e,pad:c?0:r,extrapad:!c&&o})}}function d(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:s,makePadFn:l,doAutoRange:function(t,e){if(e.autorange){e.range=s(t,e),e._r=e.range.slice(),e._rl=a.simpleMap(e._r,e.r2l);var r=e._input,n={};n[e._attr+".range"]=e.range,n[e._attr+".autorange"]=e.autorange,o.call("_storeDirectGUIEdit",t.layout,t._fullLayout._preGUI,n),r.range=e.range.slice(),r.autorange=e.autorange}var i=e._anchorAxis;if(i&&i.rangeslider){var l=i.rangeslider[e._name];l&&"auto"===l.rangemode&&(l.range=s(t,e)),i._input.rangeslider[e._name]=a.extendFlat({},l)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var a,o,s,l,u,h,p,g,v,m=[],y=[],b=e.length,x=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,A=!1;function k(t){if(Array.isArray(t))return A=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var T=k((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),M=k((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),E=k(r.vpadplus||r.vpad),C=k(r.vpadminus||r.vpad);if(!A){if(g=1/0,v=-1/0,w)for(a=0;a0&&(g=o),o>v&&o-i&&(g=o),o>v&&o=O;a--)L(a);return{min:m,max:y}},concatExtremes:u}},{"../../constants/numerical":416,"../../lib":437,"../../registry":528,"fast-isnumeric":149}],484:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../../components/titles"),c=t("../../components/color"),f=t("../../components/drawing"),h=t("./layout_attributes"),d=t("./clean_ticks"),p=t("../../constants/numerical"),g=p.ONEAVGYEAR,v=p.ONEAVGMONTH,m=p.ONEDAY,y=p.ONEHOUR,b=p.ONEMIN,x=p.ONESEC,_=p.MINUS_SIGN,w=p.BADNUM,A=t("../../constants/alignment").MID_SHIFT,k=t("../../constants/alignment").LINE_SPACING,T=e.exports={};T.setConvert=t("./set_convert");var M=t("./axis_autotype"),E=t("./axis_ids");T.id2name=E.id2name,T.name2id=E.name2id,T.cleanId=E.cleanId,T.list=E.list,T.listIds=E.listIds,T.getFromId=E.getFromId,T.getFromTrace=E.getFromTrace;var C=t("./autorange");T.getAutoRange=C.getAutoRange,T.findExtremes=C.findExtremes,T.coerceRef=function(t,e,r,n,a,i){var o=n.charAt(n.length-1),l=r._fullLayout._subplots[o+"axis"],u=n+"ref",c={};return a||(a=l[0]||i),i||(i=a),c[u]={valType:"enumerated",values:l.concat(i?[i]:[]),dflt:a},s.coerce(t,e,c,u)},T.coercePosition=function(t,e,r,n,a,i){var o,l;if("paper"===n||"pixel"===n)o=s.ensureNumber,l=r(a,i);else{var u=T.getFromId(e,n);l=r(a,i=u.fraction2r(i)),o=u.cleanPos}t[a]=o(l)},T.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?s.ensureNumber:T.getFromId(e,r).cleanPos)(t)};var S=T.getDataConversions=function(t,e,r,n){var a,i="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(i)){if(a={type:M(n),_categories:[]},T.setConvert(a),"category"===a.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.saveRangeInitial=function(t,e){for(var r=T.list(t,"",!0),n=!1,a=0;a.3*h||c(n)||c(i))){var d=r.dtick/2;t+=t+d.8){var o=Number(r.substr(1));i.exactYears>.8&&o%12==0?t=T.tickIncrement(t,"M6","reverse")+1.5*m:i.exactMonths>.8?t=T.tickIncrement(t,"M1","reverse")+15.5*m:t-=m/2;var l=T.tickIncrement(t,r);if(l<=n)return l}return t}(b,t,y,u,i)),v=b,0;v<=c;)v=T.tickIncrement(v,y,!1,i),0;return{start:e.c2r(b,0,i),end:e.c2r(v,0,i),size:y,_dataSpan:c-u}},T.prepTicks=function(t){var e=s.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type||"multicategory"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=s.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),T.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},T.calcTicks=function(t){T.prepTicks(t);var e=s.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e=t.tickvals,r=t.ticktext,n=new Array(e.length),a=s.simpleMap(t.range,t.r2l),i=1.0001*a[0]-1e-4*a[1],o=1.0001*a[1]-1e-4*a[0],l=Math.min(i,o),u=Math.max(i,o),c=0;Array.isArray(r)||(r=[]);var f="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(var h=0;hl&&d=n:u<=n)&&!(i.length>l||u===o);u=T.tickIncrement(u,t.dtick,a,t.calendar))o=u,i.push(u);et(t)&&360===Math.abs(e[1]-e[0])&&i.pop(),t._tmax=i[i.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var c=new Array(i.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=m&&i<=10||e>=15*m)t._tickround="d";else if(e>=b&&i<=16||e>=y)t._tickround="M";else if(e>=x&&i<=19||e>=b)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(i,o)-20,t._tickround<0&&(t._tickround=4)}}else if(a(e)||"L"===e.charAt(0)){var s=t.range.map(t.r2d||Number);a(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var l=Math.max(Math.abs(s[0]),Math.abs(s[1])),u=Math.floor(Math.log(l)/Math.LN10+.01);Math.abs(u)>3&&(V(t.exponentformat)&&!q(u)?t._tickexponent=3*Math.round((u-1)/3):t._tickexponent=u)}else t._tickround=null}function U(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}T.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=s.dateTick0(t.calendar);var i=2*e;i>g?(e/=g,r=n(10),t.dtick="M"+12*B(e,r,D)):i>v?(e/=v,t.dtick="M"+B(e,1,R)):i>m?(t.dtick=B(e,m,I),t.tick0=s.dateTick0(t.calendar,!0)):i>y?t.dtick=B(e,y,R):i>b?t.dtick=B(e,b,P):i>x?t.dtick=B(e,x,P):(r=n(10),t.dtick=B(e,r,D))}else if("log"===t.type){t.tick0=0;var o=s.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var l=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/l,r=n(10),t.dtick="L"+B(e,r,D)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type||"multicategory"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):et(t)?(t.tick0=0,r=1,t.dtick=B(e,r,N)):(t.tick0=0,r=n(10),t.dtick=B(e,r,D));if(0===t.dtick&&(t.dtick=1),!a(t.dtick)&&"string"!=typeof t.dtick){var u=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(u)}},T.tickIncrement=function(t,e,r,i){var o=r?-1:1;if(a(e))return t+o*e;var l=e.charAt(0),u=o*Number(e.substr(1));if("M"===l)return s.incrementMonth(t,u,i);if("L"===l)return Math.log(Math.pow(10,t)+u)/Math.LN10;if("D"===l){var c="D2"===e?F:z,f=t+.01*o,h=s.roundUp(s.mod(f,1),c,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.r2l||Number,r=s.simpleMap(t.range,e),i=r[1]"+l,t._prevDateHead=l));e.text=u}(t,i,r,l):"log"===u?function(t,e,r,n,i){var o=t.dtick,l=e.x,u=t.tickformat,c="string"==typeof o&&o.charAt(0);"never"===i&&(i="");n&&"L"!==c&&(o="L3",c="L");if(u||"L"===c)e.text=G(Math.pow(10,l),t,i,n);else if(a(o)||"D"===c&&s.mod(l+.01,1)<.1){var f=Math.round(l),h=Math.abs(f),d=t.exponentformat;"power"===d||V(d)&&q(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+h+"",e.fontSize*=1.25):("e"===d||"E"===d)&&h>2?e.text="1"+d+(f>0?"+":_)+h:(e.text=G(Math.pow(10,l),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==c)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,s.mod(l,1)))),e.fontSize*=.75}if("D1"===t.dtick){var p=String(e.text).charAt(0);"0"!==p&&"1"!==p||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(l<0?.5:.25)))}}(t,i,0,l,p):"category"===u?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,i):"multicategory"===u?function(t,e,r){var n=Math.round(e.x),a=t._categories[n]||[],i=void 0===a[1]?"":String(a[1]),o=void 0===a[0]?"":String(a[0]);r?e.text=o+" - "+i:(e.text=i,e.text2=o)}(t,i,r):et(t)?function(t,e,r,n,a){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,a,n);else{var i=e.x/180;if(0===i)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,a=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/a),Math.round(r/a)]}(i);if(o[1]>=100)e.text=G(s.deg2rad(e.x),t,a,n);else{var l=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),l&&(e.text=_+e.text)}}}}(t,i,r,l,p):function(t,e,r,n,a){"never"===a?a="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide");e.text=G(e.x,t,a,n)}(t,i,0,l,p),t.tickprefix&&!d(t.showtickprefix)&&(i.text=t.tickprefix+i.text),t.ticksuffix&&!d(t.showticksuffix)&&(i.text+=t.ticksuffix),"boundaries"===t.tickson||t.showdividers){var g=function(e){var r=t.l2p(e);return r>=0&&r<=t._length?e:null};i.xbnd=[g(i.x-.5),g(i.x+t.dtick-.5)]}return i},T.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return T.hoverLabelText(t,e)+" - "+T.hoverLabelText(t,r);var n="log"===t.type&&e<=0,a=T.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+a:a};var H=["f","p","n","\u03bc","m","","k","M","G","T"];function V(t){return"SI"===t||"B"===t}function q(t){return t>14||t<-15}function G(t,e,r,n){var i=t<0,o=e._tickround,l=r||e.exponentformat||"B",u=e._tickexponent,c=T.getTickFormat(e),f=e.separatethousands;if(n){var h={exponentformat:l,dtick:"none"===e.showexponent?e.dtick:a(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(h),o=(Number(h._tickround)||0)+4,u=h._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return e._numFormat(c)(t).replace(/-/g,_);var d,p=Math.pow(10,-o)/2;if("none"===l&&(u=0),(t=Math.abs(t))"+d+"":"B"===l&&9===u?t+="B":V(l)&&(t+=H[u/3+5]));return i?_+t:t}function X(t,e){var r=t._id.charAt(0),n=t._tickAngles[e]||0,a=s.deg2rad(n),i=Math.sin(a),o=Math.cos(a),l=0,u=0;return t._selections[e].each(function(){var t=Z(this),e=f.bBox(t.node()),r=e.width,n=e.height;l=Math.max(l,o*r,i*n),u=Math.max(u,i*r,o*n)}),{x:u,y:l}[r]}function W(t){return[t.text,t.x,t.axInfo,t.font,t.fontSize,t.fontColor].join("_")}function Y(t,e){var r=t.l2p(e);return r>1&&r=0,i=c(t,e[1])<=0;return(r||a)&&(n||i)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(a)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},s=0;s2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":528,"./constants":490}],488:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var a,i=t.categoryarray,o=Array.isArray(i)&&i.length>0;o&&(a="array");var s,l=r("categoryorder",a);"array"===l&&(s=r("categoryarray")),o||"array"!==l||(l=e.categoryorder="trace"),"trace"===l?e._initialCategories=[]:"array"===l?e._initialCategories=s.slice():(s=function(t,e){var r,n,a,i=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;ns*b)||A)for(r=0;rR&&zO&&(O=z);d/=(O-L)/(2*D),L=c.l2r(L),O=c.l2r(O),c.range=c._input.range=E=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function P(t,e,r,n,a){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",a+"Z")}function I(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:u.background,stroke:u.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function z(t,e,r,n,a,i){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),F(t,e,a,i)}function F(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function N(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function B(t){E&&t.data&&t._context.showTips&&(s.notifier(s._(t,"Double-click to zoom back out"),"long"),E=!1)}function j(t){return"lasso"===t||"select"===t}function U(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,M)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function H(t,e){if(i){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function V(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,i,u,d,E,C){var F,q,G,X,W,Y,Z,J,Q,$,K,tt,et,rt,nt,at,it,ot,st,lt,ut,ct=t._fullLayout._zoomlayer,ft=E+C==="nsew",ht=1===(E+C).length;function dt(){if(F=e.xaxis,q=e.yaxis,Q=F._length,$=q._length,Z=F._offset,J=q._offset,(G={})[F._id]=F,(X={})[q._id]=q,E&&C)for(var r=e.overlays,n=0;n-1&&w(a,t,W,Y,e.id,Mt),i.indexOf("event")>-1&&f.click(t,a,e.id);else if(1===r&&ht){var s=E?q:F,u="s"===E||"w"===C?0:1,c=s._name+".range["+u+"]",h=function(t,e){var r,a=t.range[e],i=Math.abs(a-t.range[1-e]);return"date"===t.type?a:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,a))):(r=Math.floor(Math.log(Math.abs(a))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,n.format("."+String(r)+"g")(a))}(s,u),d="left",p="middle";if(s.fixedrange)return;E?(p="n"===E?"top":"bottom","right"===s.side&&(d="right")):"e"===C&&(d="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(l.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(h),fill:s.tickfont?s.tickfont.color:"#444",horizontalAlign:d,verticalAlign:p}).on("edit",function(e){var r=s.d2r(e);void 0!==r&&o.call("_guiRelayout",t,c,r)})}}function St(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min(Q,e+vt)),a=Math.max(0,Math.min($,r+mt)),i=Math.abs(n-vt),o=Math.abs(a-mt);function s(){wt="",yt.r=yt.l,yt.t=yt.b,kt.attr("d","M0,0Z")}yt.l=Math.min(vt,n),yt.r=Math.max(vt,n),yt.t=Math.min(mt,a),yt.b=Math.max(mt,a),nt?i>M||o>M?(wt="xy",i/Q>o/$?(o=i*$/Q,mt>a?yt.t=mt-o:yt.b=mt+o):(i=o*Q/$,vt>n?yt.l=vt-i:yt.r=vt+i),kt.attr("d",U(yt))):s():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Pt);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var a,i=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=zt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-o.left)/o.width,u=(o.bottom-e.clientY)/o.height;if(at){for(C||(l=.5),a=0;ag[1]-.01&&(e.domain=s),a.noneOrAll(t.domain,e.domain,s)}return r("layer"),e}},{"../../lib":437,"fast-isnumeric":149}],501:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var a=[t.r2l(t.range[0]),t.r2l(t.range[1])],i=a[0]+(a[1]-a[0])*r;t.range=t._input.range=[t.l2r(i+(a[0]-i)*e),t.l2r(i+(a[1]-i)*e)]}},{"../../constants/alignment":413}],502:[function(t,e,r){"use strict";var n=t("polybooljs"),a=t("../../registry"),i=t("../../components/color"),o=t("../../components/fx"),s=t("../../lib/polygon"),l=t("../../lib/throttle"),u=t("../../components/fx/helpers").makeEventData,c=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),h=t("../../plot_api/subroutines").redrawReglTraces,d=t("./constants"),p=d.MINSELECT,g=s.filter,v=s.tester;function m(t){return t._id}function y(t,e,r,n,a,i,o){var s,l,u,c,f,h,d,p,g,v=e._hoverdata,m=e._fullLayout.clickmode.indexOf("event")>-1,y=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,i);var b=function(t,e){var r,n,a=t[0],i=-1,o=[];for(n=0;n0?function(t,e){var r,n,a,i=[];for(a=0;a0&&i.push(r);if(1===i.length&&i[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(a=0;a1)return!1;if((a+=r.selectedpoints.length)>1)return!1}return 1===a}(s)&&(h=M(b))){for(o&&o.remove(),g=0;g0?"M"+a.join("M")+"Z":"M0,0Z",e.attr("d",n)}function M(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,a=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(a)>-1}function E(t,e,r){var n,i,o,s;for(n=0;n-1&&y(e,M,a.xaxes,a.yaxes,a.subplot,a,q),"event"===r&&M.emit("plotly_selected",void 0);o.click(M,e)})},a.doneFn=function(){X.remove(),l.done(W).then(function(){l.clear(W),a.gd.emit("plotly_selected",x),h&&a.selectionDefs&&(h.subtract=V,a.selectionDefs.push(h),a.mergedPolygons.length=0,[].push.apply(a.mergedPolygons,f))})}},clearSelect:S,selectOnClick:y}},{"../../components/color":318,"../../components/fx":357,"../../components/fx/helpers":353,"../../lib/clear_gl_canvases":424,"../../lib/polygon":449,"../../lib/throttle":462,"../../plot_api/subroutines":475,"../../registry":528,"./axis_ids":487,"./constants":490,polybooljs:240}],503:[function(t,e,r){"use strict";var n=t("d3"),a=t("fast-isnumeric"),i=t("../../lib"),o=i.cleanNumber,s=i.ms2DateTime,l=i.dateTime2ms,u=i.ensureNumber,c=t("../../constants/numerical"),f=c.FP_SAFE,h=c.BADNUM,d=c.LOG_CLIP,p=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}function m(t){return null!=t}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function c(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],a=t.range[1];return.5*(n+a-2*d*Math.abs(n-a))}return h}function y(e,r,n){var o=l(e,n||t.calendar);if(o===h){if(!a(e))return h;e=+e;var s=Math.floor(10*i.mod(e+.05,1)),u=Math.round(e-s/10);o=l(new Date(u))+s/10}return o}function b(e,r,n){return s(e,r,n||t.calendar)}function x(e){return t._categories[Math.round(e)]}function _(e){if(m(e)){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return h}function w(e){if(t._categoriesMap)return t._categoriesMap[e]}function A(t){var e=w(t);return void 0!==e?e:a(t)?+t:void 0}function k(e){return a(e)?n.round(t._b+t._m*e,2):h}function T(e){return(e-t._b)/t._m}t.c2l="log"===t.type?c:u,t.l2c="log"===t.type?v:u,t.l2p=k,t.p2l=T,t.c2p="log"===t.type?function(t,e){return k(c(t,e))}:k,t.p2c="log"===t.type?function(t){return v(T(t))}:T,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=u,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=T,t.cleanPos=u):"log"===t.type?(t.d2r=t.d2l=function(t,e){return c(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=u,t.c2r=c,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(T(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=T,t.cleanPos=u):"date"===t.type?(t.d2r=t.r2d=i.identity,t.d2c=t.r2c=t.d2l=t.r2l=y,t.c2d=t.c2r=t.l2d=t.l2r=b,t.d2p=t.r2p=function(e,r,n){return t.l2p(y(e,0,n))},t.p2d=t.p2r=function(t,e,r){return b(T(t),e,r)},t.cleanPos=function(e){return i.cleanDate(e,h,t.calendar)}):"category"===t.type?(t.d2c=t.d2l=_,t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=A,t.r2c=function(e){var r=A(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=u,t.r2l=A,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(T(t))},t.r2p=t.d2p,t.p2r=T,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:u(t)}):"multicategory"===t.type&&(t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=A,t.r2c=function(e){var r=A(e);return void 0!==r?r:t.fraction2r(.5)},t.r2c_just_indices=w,t.l2r=t.c2r=u,t.r2l=A,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(T(t))},t.r2p=t.d2p,t.p2r=T,t.cleanPos=function(t){return Array.isArray(t)||"string"==typeof t&&""!==t?t:u(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,s,l=i.nestedProperty(t,e).get();if(s=(s="date"===t.type?i.dfltRange(t.calendar):"y"===r?p.DFLTRANGEY:n.dfltRange||p.DFLTRANGEX).slice(),l&&2===l.length)for("date"===t.type&&(l[0]=i.cleanDate(l[0],h,t.calendar),l[1]=i.cleanDate(l[1],h,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!i.isDateTime(l[o],t.calendar)){t[e]=s;break}if(t.r2l(l[0])===t.r2l(l[1])){var u=i.constrain(t.r2l(l[0]),i.MIN_MS+1e3,i.MAX_MS-1e3);l[0]=t.l2r(u-1e3),l[1]=t.l2r(u+1e3);break}}else{if(!a(l[o])){if(!a(l[1-o])){t[e]=s;break}l[o]=l[1-o]*(o?10:.1)}if(l[o]<-f?l[o]=-f:l[o]>f&&(l[o]=f),l[0]===l[1]){var c=Math.max(1,Math.abs(1e-6*l[0]));l[0]-=c,l[1]+=c}}else i.nestedProperty(t,e).set(s)},t.setScale=function(n){var a=e._size;if(t.overlaying){var i=g.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var o=n&&t._r?"_r":"range",s=t.calendar;t.cleanRange(o);var l=t.r2l(t[o][0],s),u=t.r2l(t[o][1],s);if("y"===r?(t._offset=a.t+(1-t.domain[1])*a.h,t._length=a.h*(t.domain[1]-t.domain[0]),t._m=t._length/(l-u),t._b=-t._m*u):(t._offset=a.l+t.domain[0]*a.w,t._length=a.w*(t.domain[1]-t.domain[0]),t._m=t._length/(u-l),t._b=-t._m*l),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,a,o,s,l=t.type,u="date"===l&&e[r+"calendar"];if(r in e){if(n=e[r],s=e._length||i.minRowLength(n),i.isTypedArray(n)&&("linear"===l||"log"===l)){if(s===n.length)return n;if(n.subarray)return n.subarray(0,s)}if("multicategory"===l)return function(t,e){var r,n=new Array(e),a=new Array(e),o=[[0,{}],[0,{}]];if(i.isArrayOrTypedArray(t[0])&&i.isArrayOrTypedArray(t[1])){for(r=0;r rect").call(i.setTranslate,0,0).call(i.setScale,1,1),t.plot.call(i.setTranslate,e._offset,r._offset).call(i.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(i.setPointGroupScale,1,1),n.selectAll(".textpoint").call(i.setTextPointsScale,1,1),n.call(i.hideOutsideRangePoints,t)}function b(e,r){var n,s,l,c=g[e.xaxis._id],f=g[e.yaxis._id],h=[];if(c){s=(n=t._fullLayout[c.axisName])._r,l=c.to,h[0]=(s[0]*(1-r)+r*l[0]-s[0])/(s[1]-s[0])*e.xaxis._length;var d=s[1]-s[0],p=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[2]=e.xaxis._length*(1-r+r*p/d)}else h[0]=0,h[2]=e.xaxis._length;if(f){s=(n=t._fullLayout[f.axisName])._r,l=f.to,h[1]=(s[1]*(1-r)+r*l[1]-s[1])/(s[0]-s[1])*e.yaxis._length;var v=s[1]-s[0],m=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[3]=e.yaxis._length*(1-r+r*m/v)}else h[1]=0,h[3]=e.yaxis._length;!function(e,r){var n,i=[e._id,r._id];function s(e,r,a){for(n=0;nr.duration?(function(){for(var e={},r=0;r0&&(a["_"+r+"axes"]||{})[e])return a;if((a[r+"axis"]||r)===e){if(o(a,r))return a;if((a[r]||[]).length||a[r+"0"])return a}}}(e,r,s);if(!l)return;if("histogram"===l.type&&s==={v:"y",h:"x"}[l.orientation||"v"])return void(t.type="linear");var u,c=s+"calendar",f=l[c],h={noMultiCategory:!n(l,"cartesian")||n(l,"noMultiCategory")};if(o(l,s)){var d=i(l),p=[];for(u=0;u0?".":"")+i;a.isPlainObject(o)?l(o,e,s,n+1):e(s,i,o)}})}r.manageCommandObserver=function(t,e,n,o){var s={},l=!0;e&&e._commandObserver&&(s=e._commandObserver),s.cache||(s.cache={}),s.lookupTable={};var u=r.hasSimpleAPICommandBindings(t,n,s.lookupTable);if(e&&e._commandObserver){if(u)return s;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,s}if(u){i(t,u,s.cache),s.check=function(){if(l){var e=i(t,u,s.cache);return e.changed&&o&&void 0!==s.lookupTable[e.value]&&(s.disable(),Promise.resolve(o({value:e.value,type:u.type,prop:u.prop,traces:u.traces,index:s.lookupTable[e.value]})).then(s.enable,s.enable)),e.changed}};for(var c=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;fMath.abs(s)?(u.boxEnd[1]=u.boxStart[1]+Math.abs(i)*_*(s>=0?1:-1),u.boxEnd[1]l[3]&&(u.boxEnd[1]=l[3],u.boxEnd[0]=u.boxStart[0]+(l[3]-u.boxStart[1])/Math.abs(_))):(u.boxEnd[0]=u.boxStart[0]+Math.abs(s)/_*(i>=0?1:-1),u.boxEnd[0]l[2]&&(u.boxEnd[0]=l[2],u.boxEnd[1]=u.boxStart[1]+(l[2]-u.boxStart[0])*Math.abs(_)))}}else u.boxEnabled?(i=u.boxStart[0]!==u.boxEnd[0],s=u.boxStart[1]!==u.boxEnd[1],i||s?(i&&(v(0,u.boxStart[0],u.boxEnd[0]),t.xaxis.autorange=!1),s&&(v(1,u.boxStart[1],u.boxEnd[1]),t.yaxis.autorange=!1),t.relayoutCallback()):t.glplot.setDirty(),u.boxEnabled=!1,u.boxInited=!1):u.boxInited&&(u.boxInited=!1);break;case"pan":u.boxEnabled=!1,u.boxInited=!1,e?(u.panning||(u.dragStart[0]=n,u.dragStart[1]=a),Math.abs(u.dragStart[0]-n)=e.width-20?(i["text-anchor"]="start",i.x=5):(i["text-anchor"]="end",i.x=e._paper.attr("width")-7),r.attr(i);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),a=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+a})}}(t,o),s.text(o.text()&&c.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),a=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return a.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),a.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var b,x=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,a={};function o(t){for(var r=!0,i=0;i1&&R.length>1){for(i.getComponentMethod("grid","sizeDefaults")(u,s),o=0;o15&&R.length>15&&0===s.shapes.length&&0===s.images.length,s._hasCartesian=s._has("cartesian"),s._hasGeo=s._has("geo"),s._hasGL3D=s._has("gl3d"),s._hasGL2D=s._has("gl2d"),s._hasTernary=s._has("ternary"),s._hasPie=s._has("pie"),v.linkSubplots(f,s,c,a),v.cleanPlot(f,s,c,a),p(s,a),s._preGUI||(s._preGUI={}),s._tracePreGUI||(s._tracePreGUI={});var N,B=s._tracePreGUI,j={};for(N in B)j[N]="old";for(o=0;o0){var f=1-2*s;n=Math.round(f*n),i=Math.round(f*i)}}var h=v.layoutAttributes.width.min,d=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-i)>1;(g||p)&&(p&&(r.width=n),g&&(r.height=i)),t._initialAutoSize||(t._initialAutoSize={width:n,height:i}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var a,o,s,u=i.componentsRegistry,c=e._basePlotModules,f=i.subplotsRegistry.cartesian;for(a in u)(s=u[a]).includeBasePlot&&s.includeBasePlot(t,e);for(var h in c.length||c.push(f),e._has("cartesian")&&(i.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[h].sort(l.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var l=void 0!==r.xl?r.xl:r.x,u=void 0!==r.xr?r.xr:r.x,c=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;a[e]={l:{val:l,size:r.l+o},r:{val:u,size:r.r+o},b:{val:f,size:r.b+o},t:{val:c,size:r.t+o}},i[e]=1}else delete a[e],delete i[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),M(e);var r=e._size,n=JSON.stringify(r),o=e.margin,s=o.l,l=o.r,u=o.t,c=o.b,f=e._pushmargin,h=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var d in f)h[d]||delete f[d];for(var p in f.base={l:{val:0,size:s},r:{val:1,size:l},t:{val:1,size:u},b:{val:0,size:c}},f){var g=f[p].l||{},v=f[p].b||{},m=g.val,y=g.size,b=v.val,x=v.size;for(var _ in f){if(a(y)&&f[_].r){var w=f[_].r.val,A=f[_].r.size;if(w>m){var k=(y*w+(A-e.width)*m)/(w-m),T=(A*(1-m)+(y-e.width)*(1-w))/(w-m);k>=0&&T>=0&&k+T>s+l&&(s=k,l=T)}}if(a(x)&&f[_].t){var E=f[_].t.val,C=f[_].t.size;if(E>b){var S=(x*E+(C-e.height)*b)/(E-b),L=(C*(1-b)+(x-e.height)*(1-E))/(E-b);S>=0&&L>=0&&S+L>c+u&&(c=S,u=L)}}}}}if(r.l=Math.round(s),r.r=Math.round(l),r.t=Math.round(u),r.b=Math.round(c),r.p=Math.round(o.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,i.call("plot",t)},v.graphJson=function(t,e,r,n,a){(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var i=a?t._fullData:t.data,o=a?t._fullLayout:t.layout,s=(t._transitionData||{})._frames;function u(t){if("function"==typeof t)return null;if(l.isPlainObject(t)){var e,n,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!l.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;a[e]=u(t[e])}return a}return Array.isArray(t)?t.map(u):l.isTypedArray(t)?l.simpleMap(t,l.identity):l.isJSDate(t)?l.ms2DateTimeLocal(+t):t}var c={data:(i||[]).map(function(t){var r=u(t);return e&&delete r.fit,r})};return e||(c.layout=u(o)),t.framework&&t.framework.isPolar&&(c=t.framework.getConfig()),s&&(c.frames=u(s)),"object"===n?c:JSON.stringify(c)},v.modifyFrames=function(t,e){var r,n,a,i=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){d=!0}),a.redraw&&t._transitionData._interruptCallbacks.push(function(){return i.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,s,u=0,c=0;function f(){return u++,function(){var r;c++,d||c!==u||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(a.redraw)return i.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var p=t._fullLayout._basePlotModules,g=!1;if(r)for(s=0;s=0;s--)if(o[s].enabled){r._indexToPoints=o[s]._indexToPoints;break}n&&n.calc&&(i=n.calc(t,r))}Array.isArray(i)&&i[0]||(i=[{x:c,y:c}]),i[0].t||(i[0].t={}),i[0].trace=r,p[e]=i}}for(y&&E(u),a=0;a=0?h.angularAxis.domain:n.extent(A),C=Math.abs(A[1]-A[0]);T&&!k&&(C=0);var S=E.slice();M&&k&&(S[1]+=C);var L=h.angularAxis.ticksCount||4;L>8&&(L=L/(L/8)+L%8),h.angularAxis.ticksStep&&(L=(S[1]-S[0])/L);var O=h.angularAxis.ticksStep||(S[1]-S[0])/(L*(h.minorTicks+1));w&&(O=Math.max(Math.round(O),1)),S[2]||(S[2]=O);var D=n.range.apply(this,S);if(D=D.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=n.scale.linear().domain(S.slice(0,2)).range("clockwise"===h.direction?[0,360]:[360,0]),c.layout.angularAxis.domain=s.domain(),c.layout.angularAxis.endPadding=M?C:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var R=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),P=this.appendChild(this.ownerDocument.importNode(R.documentElement,!0));t=n.select(P)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var I,z=t.select(".chart-group"),F={fill:"none",stroke:h.tickColor},N={"font-size":h.font.size,"font-family":h.font.family,fill:h.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+h.font.outlineColor}).join(",")};if(h.showLegend){I=t.select(".legend-group").attr({transform:"translate("+[b,h.margin.top]+")"}).style({display:"block"});var B=d.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:a({},o.Legend.defaultConfig().legendConfig,{container:I,elements:B,reverseOrder:h.legend.reverseOrder})})();var j=I.node().getBBox();b=Math.min(h.width-j.width-h.margin.left-h.margin.right,h.height-h.margin.top-h.margin.bottom)/2,b=Math.max(10,b),_=[h.margin.left+b,h.margin.top+b],r.range([0,b]),c.layout.radialAxis.domain=r.domain(),I.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else I=t.select(".legend-group").style({display:"none"});t.attr({width:h.width,height:h.height}).style({opacity:h.opacity}),z.attr("transform","translate("+_+")").style({cursor:"crosshair"});var U=[(h.width-(h.margin.left+h.margin.right+2*b+(j?j.width:0)))/2,(h.height-(h.margin.top+h.margin.bottom+2*b))/2];if(U[0]=Math.max(0,U[0]),U[1]=Math.max(0,U[1]),t.select(".outer-group").attr("transform","translate("+U+")"),h.title&&h.title.text){var H=t.select("g.title-group text").style(N).text(h.title.text),V=H.node().getBBox();H.attr({x:_[0]-V.width/2,y:_[1]-b-20})}var q=t.select(".radial.axis-group");if(h.radialAxis.gridLinesVisible){var G=q.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(F),G.attr("r",r),G.exit().remove()}q.select("circle.outside-circle").attr({r:b}).style(F);var X=t.select("circle.background-circle").attr({r:b}).style({fill:h.backgroundColor,stroke:h.stroke});function W(t,e){return s(t)%360+h.orientation}if(h.radialAxis.visible){var Y=n.svg.axis().scale(r).ticks(5).tickSize(5);q.call(Y).attr({transform:"rotate("+h.radialAxis.orientation+")"}),q.selectAll(".domain").style(F),q.selectAll("g>text").text(function(t,e){return this.textContent+h.radialAxis.ticksSuffix}).style(N).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===h.radialAxis.tickOrientation?"rotate("+-h.radialAxis.orientation+") translate("+[0,N["font-size"]]+")":"translate("+[0,N["font-size"]]+")"}}),q.selectAll("g>line").style({stroke:"black"})}var Z=t.select(".angular.axis-group").selectAll("g.angular-tick").data(D),J=Z.enter().append("g").classed("angular-tick",!0);Z.attr({transform:function(t,e){return"rotate("+W(t)+")"}}).style({display:h.angularAxis.visible?"block":"none"}),Z.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(h.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(h.minorTicks+1)==0)}).style(F),J.selectAll(".minor").style({stroke:h.minorTickColor}),Z.select("line.grid-line").attr({x1:h.tickLength?b-h.tickLength:0,x2:b}).style({display:h.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(N);var Q=Z.select("text.axis-text").attr({x:b+h.labelOffset,dy:i+"em",transform:function(t,e){var r=W(t),n=b+h.labelOffset,a=h.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-r+" "+n+" 0)":"radial"==a?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:h.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(h.minorTicks+1)!=0?"":w?w[t]+h.angularAxis.ticksSuffix:t+h.angularAxis.ticksSuffix}).style(N);h.angularAxis.rewriteTicks&&Q.text(function(t,e){return e%(h.minorTicks+1)!=0?"":h.angularAxis.rewriteTicks(this.textContent,e)});var $=n.max(z.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));I.attr({transform:"translate("+[b+$,h.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(d);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),d[0]||K){var et=[];d.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=s,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=h.orientation,n.direction=h.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return a(o[r].defaultConfig(),t)});o[r]().config(n)()})}var at,it,ot=t.select(".guides-group"),st=t.select(".tooltips-group"),lt=o.tooltipPanel().config({container:st,fontSize:8})(),ut=o.tooltipPanel().config({container:st,fontSize:8})(),ct=o.tooltipPanel().config({container:st,hasTick:!0})();if(!k){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});z.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(X).angle;ft.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-h.orientation)%360;at=s.invert(n);var a=o.util.convertToCartesian(b+12,r+180);lt.text(o.util.round(at)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var ht=ot.select("circle").style({stroke:"grey",fill:"none"});z.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(X).radius;ht.attr({r:n}).style({opacity:.5}),it=r.invert(o.util.getMousePos(X).radius);var a=o.util.convertToCartesian(n,h.radialAxis.orientation);ut.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){ht.style({opacity:0}),ct.hide(),lt.hide(),ut.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var a=n.select(this),i=this.style.fill,s="black",l=this.style.opacity||1;if(a.attr({"data-opacity":l}),i&&"none"!==i){a.attr({"data-fill":i}),s=n.hsl(i).darker().toString(),a.style({fill:s,opacity:1});var u={t:o.util.round(e[0]),r:o.util.round(e[1])};k&&(u.t=w[e[0]]);var c="t: "+u.t+", r: "+u.r,f=this.getBoundingClientRect(),h=t.node().getBoundingClientRect(),d=[f.left+f.width/2-U[0]-h.left,f.top+f.height/2-U[1]-h.top];ct.config({color:s}).text(c),ct.move(d)}else i=this.style.stroke||"black",a.attr({"data-stroke":i}),s=n.hsl(i).darker().toString(),a.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ct.show()}).on("mouseout.tooltip",function(t,e){ct.hide();var r=n.select(this),a=r.attr("data-fill");a?r.style({fill:a,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(u),this},h.config=function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),a(l.data[e],o.Axis.defaultConfig().data[0]),a(l.data[e],t)}),a(l.layout,o.Axis.defaultConfig().layout),a(l.layout,e.layout),this},h.getLiveConfig=function(){return c},h.getinputConfig=function(){return u},h.radialScale=function(t){return r},h.angularScale=function(t){return s},h.svg=function(){return t},n.rebind(h,f,"on"),h},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var a=e||6,i=[],o=[];n.range(0,360+a,a).forEach(function(e,r){var n=e*Math.PI/180,a=t(n);i.push(e),o.push(a)});var s={t:i,r:o};return r&&(s.name=r),s},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],a=e[1],i={};return i.x=r,i.y=a,i.pos=e,i.angle=180*(Math.atan2(a,r)+Math.PI)/Math.PI,i.radius=Math.sqrt(r*r+a*a),i},o.util.duplicatesCount=function(t){for(var e,r={},n={},a=0,i=t.length;a0)){var l=n.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:c(s),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return p.fill(r,a,i)},"fill-opacity":0,stroke:function(t,e){return p.stroke(r,a,i)},"stroke-width":function(t,e){return p["stroke-width"](r,a,i)},"stroke-dasharray":function(t,e){return p["stroke-dasharray"](r,a,i)},opacity:function(t,e){return p.opacity(r,a,i)},display:function(t,e){return p.display(r,a,i)}})}};var f=e.angularScale.range(),h=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,d=n.svg.arc().startAngle(function(t){return-h/2}).endAngle(function(t){return h/2}).innerRadius(function(t){return e.radialScale(l+(t[2]||0))}).outerRadius(function(t){return e.radialScale(l+(t[2]||0))+e.radialScale(t[1])});u.arc=function(t,r,a){n.select(this).attr({class:"mark arc",d:d,transform:function(t,r){return"rotate("+(e.orientation+s(t[0])+90)+")"}})};var p={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,a){return r[t[a].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(p).each(u[e.geometryType]),v.exit().remove(),g.exit().remove()})}return i.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),a(t[r],o.PolyChart.defaultConfig()),a(t[r],e)}),this):t},i.getColorScale=function(){},n.rebind(i,e,"on"),i},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,i=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var i=a({},e.elements[r]);return i.name=t,i.color=[].concat(e.elements[r].color)[n],i})}),o=n.merge(i);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var s=e.container;("string"==typeof s||s.nodeName)&&(s=n.select(s));var l=o.map(function(t,e){return t.color}),u=e.fontSize,c=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=c?e.height:u*o.length,h=s.classed("legend-group",!0).selectAll("svg").data([0]),d=h.enter().append("svg").attr({width:300,height:f+u,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});d.append("g").classed("legend-axis",!0),d.append("g").classed("legend-marks",!0);var p=n.range(o.length),g=n.scale[c?"linear":"ordinal"]().domain(p).range(l),v=n.scale[c?"linear":"ordinal"]().domain(p)[c?"range":"rangePoints"]([0,f]);if(c){var m=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);m.enter().append("stop"),m.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var y=h.select(".legend-marks").selectAll("path.legend-mark").data(o);y.enter().append("path").classed("legend-mark",!0),y.attr({transform:function(t,e){return"translate("+[u/2,v(e)+u/2]+")"},d:function(t,e){var r,a,i,o=t.symbol;return i=3*(a=u),"line"===(r=o)?"M"+[[-a/2,-a/12],[a/2,-a/12],[a/2,a/12],[-a/2,a/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(i)():n.svg.symbol().type("square").size(i)()},fill:function(t,e){return g(e)}}),y.exit().remove()}var b=n.svg.axis().scale(v).orient("right"),x=h.select("g.legend-axis").attr({transform:"translate("+[c?e.colorBandWidth:u,u/2]+")"}).call(b);return x.selectAll(".domain").style({fill:"none",stroke:"none"}),x.selectAll("line").style({fill:"none",stroke:c?e.textColor:"none"}),x.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(a(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,i={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,u=function(){var n=(t=i.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:i.padding+l,dy:.3*+i.fontSize}),u};return u.text=function(a){var o=n.hsl(i.color).l,s=o>=.5?"#aaa":"white",c=o>=.5?"black":"white",f=a||"";e.style({fill:c,"font-size":i.fontSize+"px"}).text(f);var h=i.padding,d=e.node().getBBox(),p={fill:i.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[i.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),u},u.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),u},u.hide=function(){if(t)return t.style({display:"none"}),u},u.show=function(){if(t)return t.style({display:"block"}),u},u.config=function(t){return a(i,t),u},u},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=a({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var i=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=i.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var s=a({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var l=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],c={};n.entries(s.margin).forEach(function(t,e){c[u[l.indexOf(t.key)]]=t.value}),s.margin=c}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r}};return t}},{"../../../constants/alignment":413,"../../../lib":437,d3:85}],526:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../../lib"),i=t("../../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=a.extendDeepAll,u=e.exports={};u.framework=function(t){var e,r,a,i,c,f=new s;function h(r,s){return s&&(c=s),n.select(n.select(c).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?l(e,r):r,a||(a=o.Axis()),i=o.adapter.plotly().convert(e),a.config(i).render(c),t.data=e.data,t.layout=e.layout,u.fillLayout(t),e}return h.isPolar=!0,h.svg=function(){return a.svg()},h.getConfig=function(){return e},h.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},h.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},h.setUndoPoint=function(){var t,n,a=this,i=o.util.cloneJson(e);t=i,n=r,f.add({undo:function(){n&&a(n)},redo:function(){a(t)}}),r=o.util.cloneJson(i)},h.undo=function(){f.undo()},h.redo=function(){f.redo()},h},u.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:i.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=l(o,t.layout)}},{"../../../components/color":318,"../../../lib":437,"./micropolar":525,"./undo_manager":527,d3:85}],527:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function a(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(a(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(a(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r-1&&(c[h[r]].title={text:""});for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(l,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(l,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||h.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),h.node().setAttributeNS(s.xmlns,"xmlns",s.svg),h.node().setAttributeNS(s.xmlns,"xmlns:xlink",s.xlink),"svg"===e&&r&&(h.attr("width",r*p),h.attr("height",r*g),h.attr("viewBox","0 0 "+p+" "+g));var _=(new window.XMLSerializer).serializeToString(h.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(u,"'"),a.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":318,"../components/drawing":339,"../constants/xmlns_namespaces":417,"../lib":437,d3:85}],537:[function(t,e,r){"use strict";var n=t("../heatmap/attributes"),a=t("../scatter/attributes"),i=t("../../components/colorscale/attributes"),o=t("../../components/colorbar/attributes"),s=t("../../components/drawing/attributes").dash,l=t("../../plots/font_attributes"),u=t("../../lib/extend").extendFlat,c=t("../../constants/filter_ops"),f=c.COMPARISON_OPS2,h=c.INTERVAL_OPS,d=a.line;e.exports=u({z:n.z,x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:n.text,transpose:n.transpose,xtype:n.xtype,ytype:n.ytype,zhoverformat:n.zhoverformat,connectgaps:n.connectgaps,fillcolor:{valType:"color",editType:"calc"},autocontour:{valType:"boolean",dflt:!0,editType:"calc",impliedEdits:{"contours.start":void 0,"contours.end":void 0,"contours.size":void 0}},ncontours:{valType:"integer",dflt:15,min:1,editType:"calc"},contours:{type:{valType:"enumerated",values:["levels","constraint"],dflt:"levels",editType:"calc"},start:{valType:"number",dflt:null,editType:"plot",impliedEdits:{"^autocontour":!1}},end:{valType:"number",dflt:null,editType:"plot",impliedEdits:{"^autocontour":!1}},size:{valType:"number",dflt:null,min:0,editType:"plot",impliedEdits:{"^autocontour":!1}},coloring:{valType:"enumerated",values:["fill","heatmap","lines","none"],dflt:"fill",editType:"calc"},showlines:{valType:"boolean",dflt:!0,editType:"plot"},showlabels:{valType:"boolean",dflt:!1,editType:"plot"},labelfont:l({editType:"plot",colorEditType:"style"}),labelformat:{valType:"string",dflt:"",editType:"plot"},operation:{valType:"enumerated",values:[].concat(f).concat(h),dflt:"=",editType:"calc"},value:{valType:"any",dflt:0,editType:"calc"},editType:"calc",impliedEdits:{autocontour:!1}},line:{color:u({},d.color,{editType:"style+colorbars"}),width:u({},d.width,{editType:"style+colorbars"}),dash:s,smoothing:u({},d.smoothing,{}),editType:"plot"}},i("",{cLetter:"z",autoColorDflt:!1,editTypeOverride:"calc"}),{colorbar:o})},{"../../components/colorbar/attributes":319,"../../components/colorscale/attributes":325,"../../components/drawing/attributes":338,"../../constants/filter_ops":414,"../../lib/extend":429,"../../plots/font_attributes":511,"../heatmap/attributes":550,"../scatter/attributes":587}],538:[function(t,e,r){"use strict";var n=t("../heatmap/calc"),a=t("./set_contours");e.exports=function(t,e){var r=n(t,e);return a(e),r}},{"../heatmap/calc":551,"./set_contours":546}],539:[function(t,e,r){"use strict";var n=t("../../components/colorbar/draw"),a=t("./make_color_map"),i=t("./end_plus");e.exports=function(t,e){var r=e[0].trace,o="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+o).remove(),r.showscale){var s=e[0].t.cb=n(t,o),l=r.contours,u=r.line,c=l.size||1,f=l.coloring,h=a(r,{isColorbar:!0});s.fillgradient("heatmap"===f?r.colorscale:"").zrange("heatmap"===f?[r.zmin,r.zmax]:"").fillcolor("fill"===f?h:"").line({color:"lines"===f?h:u.color,width:!1!==l.showlines?u.width:0,dash:u.dash}).levels({start:l.start,end:i(l),size:c}).options(r.colorbar)()}}},{"../../components/colorbar/draw":323,"./end_plus":543,"./make_color_map":545}],540:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),a=t("./label_defaults"),i=t("../../components/color"),o=i.addOpacity,s=i.opacity,l=t("../../constants/filter_ops"),u=l.CONSTRAINT_REDUCTION,c=l.COMPARISON_OPS2;e.exports=function(t,e,r,i,l,f){var h,d,p,g=e.contours,v=r("contours.operation");(g._operation=u[v],function(t,e){var r;-1===c.indexOf(e.operation)?(t("contours.value",[0,1]),Array.isArray(e.value)?e.value.length>2?e.value=e.value.slice(2):0===e.length?e.value=[0,1]:e.length<2?(r=parseFloat(e.value[0]),e.value=[r,r+1]):e.value=[parseFloat(e.value[0]),parseFloat(e.value[1])]:n(e.value)&&(r=parseFloat(e.value),e.value=[r,r+1])):(t("contours.value",0),n(e.value)||(Array.isArray(e.value)?e.value=parseFloat(e.value[0]):e.value=0))}(r,g),"="===v?h=g.showlines=!0:(h=r("contours.showlines"),p=r("fillcolor",o((t.line||{}).color||l,.5))),h)&&(d=r("line.color",p&&s(p)?o(e.fillcolor,1):l),r("line.width",2),r("line.dash"));r("line.smoothing"),a(r,i,d,f)}},{"../../components/color":318,"../../constants/filter_ops":414,"./label_defaults":544,"fast-isnumeric":149}],541:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var a=n("contours.start"),i=n("contours.end"),o=!1===a||!1===i,s=r("contours.size");!(o?e.autocontour=!0:r("autocontour",!1))&&s||r("ncontours")}},{}],542:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../heatmap/xyz_defaults"),i=t("./constraint_defaults"),o=t("./contours_defaults"),s=t("./style_defaults"),l=t("./attributes");e.exports=function(t,e,r,u){function c(r,a){return n.coerce(t,e,l,r,a)}if(a(t,e,c,u)){c("text");var f="constraint"===c("contours.type");c("connectgaps",n.isArray1D(e.z)),f?i(t,e,c,u,r):(o(t,e,c,function(r){return n.coerce2(t,e,l,r)}),s(t,e,c,u))}else e.visible=!1}},{"../../lib":437,"../heatmap/xyz_defaults":560,"./attributes":537,"./constraint_defaults":540,"./contours_defaults":541,"./style_defaults":547}],543:[function(t,e,r){"use strict";e.exports=function(t){return t.end+t.size/1e6}},{}],544:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r,a){if(a||(a={}),t("contours.showlabels")){var i=e.font;n.coerceFont(t,"contours.labelfont",{family:i.family,size:i.size,color:r}),t("contours.labelformat")}!1!==a.hasHover&&t("zhoverformat")}},{"../../lib":437}],545:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../components/colorscale"),i=t("./end_plus");e.exports=function(t){var e=t.contours,r=e.start,o=i(e),s=e.size||1,l=Math.floor((o-r)/s)+1,u="lines"===e.coloring?0:1;isFinite(s)||(s=1,l=1);var c,f,h=t.reversescale?a.flipScale(t.colorscale):t.colorscale,d=h.length,p=new Array(d),g=new Array(d);if("heatmap"===e.coloring){for(t.zauto&&!1===t.autocontour&&(t.zmin=r-s/2,t.zmax=t.zmin+l*s),f=0;fe.end&&(e.start=e.end=(e.start+e.end)/2),t._input.contours||(t._input.contours={}),a.extendFlat(t._input.contours,{start:e.start,end:e.end,size:e.size}),t._input.autocontour=!0}else if("constraint"!==e.type){var l,u=e.start,c=e.end,f=t._input.contours;if(u>c&&(e.start=f.start=c,c=e.end=f.end=u,u=e.start),!(e.size>0))l=u===c?1:i(u,c,t.ncontours).dtick,f.size=e.size=l}}},{"../../lib":437,"../../plots/cartesian/axes":484}],547:[function(t,e,r){"use strict";var n=t("../../components/colorscale/defaults"),a=t("./label_defaults");e.exports=function(t,e,r,i,o){var s,l=r("contours.coloring"),u="";"fill"===l&&(s=r("contours.showlines")),!1!==s&&("lines"!==l&&(u=r("line.color","#000")),r("line.width",.5),r("line.dash")),"none"!==l&&(!0!==t.showlegend&&(e.showlegend=!1),e._dfltShowLegend=!1,n(t,e,i,r,{prefix:"",cLetter:"z"})),r("line.smoothing"),a(r,i,u,o)}},{"../../components/colorscale/defaults":328,"./label_defaults":544}],548:[function(t,e,r){"use strict";var n=t("gl-contour2d"),a=t("gl-heatmap2d"),i=t("../../plots/cartesian/axes"),o=t("../contour/make_color_map"),s=t("../../lib/str2rgbarray");function l(t,e){this.scene=t,this.uid=e,this.type="contourgl",this.name="",this.hoverinfo="all",this.xData=[],this.yData=[],this.zData=[],this.textLabels=[],this.idToIndex=[],this.bounds=[0,0,0,0],this.contourOptions={z:new Float32Array(0),x:[],y:[],shape:[0,0],levels:[0],levelColors:[0,0,0,1],lineWidth:1},this.contour=n(t.glplot,this.contourOptions),this.contour._trace=this,this.heatmapOptions={z:new Float32Array(0),x:[],y:[],shape:[0,0],colorLevels:[0],colorValues:[0,0,0,0]},this.heatmap=a(t.glplot,this.heatmapOptions),this.heatmap._trace=this}var u=l.prototype;function c(t,e){for(var r=t.contours,n=r.start,a=r.end,i=r.size||1,l=e.fill,u=o(t),c=Math.floor((a-n)/i)+(l?2:1),f=new Array(c),h=new Array(4*c),d=0;dL){C("x scale is not linear");break}}if(g.length&&"fast"===M){var O=(g[g.length-1]-g[0])/(g.length-1),D=Math.abs(O/100);for(b=0;bD){C("y scale is not linear");break}}}var R=a.maxRowLength(y),P="scaled"===e.xtype?"":r,I=h(e,P,d,p,R,_),z="scaled"===e.ytype?"":g,F=h(e,z,v,m,y.length,w);T||(e._extremes[_._id]=i.findExtremes(_,I),e._extremes[w._id]=i.findExtremes(w,F));var N={x:I,y:F,z:y,text:e._text||e.text};if(P&&P.length===I.length-1&&(N.xCenter=P),z&&z.length===F.length-1&&(N.yCenter=z),k&&(N.xRanges=x.xRanges,N.yRanges=x.yRanges,N.pts=x.pts),A&&"constraint"===e.contours.type||s(t,e,{vals:y,containerStr:"",cLetter:"z"}),A&&e.contours&&"heatmap"===e.contours.coloring){var B={type:"contour"===e.type?"heatmap":"histogram2d",xcalendar:e.xcalendar,ycalendar:e.ycalendar};N.xfill=h(B,P,d,p,R,_),N.yfill=h(B,z,v,m,y.length,w)}return[N]}},{"../../components/colorscale/calc":326,"../../lib":437,"../../plots/cartesian/axes":484,"../../registry":528,"../histogram2d/calc":568,"./clean_2d_array":552,"./convert_column_xyz":554,"./find_empties":556,"./interp2d":557,"./make_bound_array":558}],552:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){var r,a,i,o,s,l;function u(t){if(n(t))return+t}if(e){for(r=0,s=0;s=0;o--)(s=((f[[(r=(i=h[o])[0])-1,a=i[1]]]||g)[2]+(f[[r+1,a]]||g)[2]+(f[[r,a-1]]||g)[2]+(f[[r,a+1]]||g)[2])/20)&&(l[i]=[r,a,s],h.splice(o,1),u=!0);if(!u)throw"findEmpties iterated with no new neighbors";for(i in l)f[i]=l[i],c.push(l[i])}return c.sort(function(t,e){return e[2]-t[2]})}},{"../../lib":437}],557:[function(t,e,r){"use strict";var n=t("../../lib"),a=[[-1,0],[1,0],[0,-1],[0,1]];function i(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o,s,l,u,c,f,h,d,p,g,v,m=0;for(s=0;sg&&(m=Math.max(m,Math.abs(t[i][o]-p)/(v-g))))}return m}e.exports=function(t,e){var r,a=1;for(o(t,e),r=0;r.01;r++)a=o(t,e,i(a));return a>.01&&n.log("interp2d didn't converge quickly",a),t}},{"../../lib":437}],558:[function(t,e,r){"use strict";var n=t("../../registry"),a=t("../../lib").isArrayOrTypedArray;e.exports=function(t,e,r,i,o,s){var l,u,c,f=[],h=n.traceIs(t,"contour"),d=n.traceIs(t,"histogram"),p=n.traceIs(t,"gl2d");if(a(e)&&e.length>1&&!d&&"category"!==s.type){var g=e.length;if(!(g<=o))return h?e.slice(0,o):e.slice(0,o+1);if(h||p)f=e.slice(0,o);else if(1===o)f=[e[0]-.5,e[0]+.5];else{for(f=[1.5*e[0]-.5*e[1]],c=1;c0&&(i=!0);for(var l=0;li){var o=i-r[t];return r[t]=i,o}}return 0},max:function(t,e,r,a){var i=a[e];if(n(i)){if(i=Number(i),!n(r[t]))return r[t]=i,i;if(r[t]u?t>o?t>1.1*a?a:t>1.1*i?i:o:t>s?s:t>l?l:u:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function d(t,e,r,n,i,s){if(n&&t>o){var l=p(e,i,s),u=p(r,i,s),c=t===a?0:1;return l[c]!==u[c]}return Math.floor(r/t)-Math.floor(e/t)>.1}function p(t,e,r){var n=e.c2d(t,a,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}e.exports=function(t,e,r,n,i){var s,l,u=-1.1*e,h=-.1*e,d=t-h,p=r[0],g=r[1],v=Math.min(f(p+h,p+d,n,i),f(g+h,g+d,n,i)),m=Math.min(f(p+u,p+h,n,i),f(g+u,g+h,n,i));if(v>m&&mo){var y=s===a?1:6,b=s===a?"M12":"M1";return function(e,r){var o=n.c2d(e,a,i),s=o.indexOf("-",y);s>0&&(o=o.substr(0,s));var u=n.d2c(o,0,i);if(uT&&v.splice(T,v.length-T),y.length>T&&y.splice(T,y.length-T),u(e,"x",v,g,_,A,b),u(e,"y",y,m,w,k,x);var M=[],E=[],C=[],S="string"==typeof e.xbins.size,L="string"==typeof e.ybins.size,O=[],D=[],R=S?O:e.xbins,P=L?D:e.ybins,I=0,z=[],F=[],N=e.histnorm,B=e.histfunc,j=-1!==N.indexOf("density"),U="max"===B||"min"===B?null:0,H=i.count,V=o[N],q=!1,G=[],X=[],W="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";W&&"count"!==B&&(q="avg"===B,H=i[B]);var Y=e.xbins,Z=_(Y.start),J=_(Y.end)+(Z-a.tickIncrement(Z,Y.size,!1,b))/1e6;for(r=Z;r=0&&d=0&&p=0;i--){var o=t[i];if(e>f(n,o))return u(n,a);if(e>o||i===t.length-1)return u(o,n);a=n,n=o}}function p(t,e){for(var r=0;r=e[r][0]&&t<=e[r][1])return!0;return!1}function g(t){t.attr("x",-n.bar.captureWidth/2).attr("width",n.bar.captureWidth)}function v(t){t.attr("visibility","visible").style("visibility","visible").attr("fill","yellow").attr("opacity",0)}function m(t){if(!t.brush.filterSpecified)return"0,"+t.height;for(var e,r,n,a=y(t.brush.filter.getConsolidated(),t.height),i=[0],o=a.length?a[0][0]:null,s=0;se){h=r;break}}if(i=c,isNaN(i)&&(i=isNaN(f)||isNaN(h)?isNaN(f)?h:f:e-u[f][1]t[1]+r||e=.9*t[1]+.1*t[0]?"n":e<=.9*t[0]+.1*t[1]?"s":"ns"}(p,e);g&&(o.interval=l[i],o.intervalPix=p,o.region=g)}}if(t.ordinal&&!o.region){var v=t.unitTickvals,m=t.unitToPaddedPx.invert(e);for(r=0;r=b[0]&&m<=b[1]){o.clickableOrdinalRange=b;break}}}return o}function A(t){t.on("mousemove",function(t){if(a.event.preventDefault(),!t.parent.inBrushDrag){var e=w(t,t.height-a.mouse(this)[1]-2*n.verticalPadding),r="crosshair";e.clickableOrdinalRange?r="pointer":e.region&&(r=e.region+"-resize"),a.select(document.body).style("cursor",r)}}).on("mouseleave",function(t){t.parent.inBrushDrag||b()}).call(a.behavior.drag().on("dragstart",function(t){a.event.sourceEvent.stopPropagation();var e=t.height-a.mouse(this)[1]-2*n.verticalPadding,r=t.unitToPaddedPx.invert(e),i=t.brush,o=w(t,e),s=o.interval,l=i.svgBrush;if(l.wasDragged=!1,l.grabbingBar="ns"===o.region,l.grabbingBar){var u=s.map(t.unitToPaddedPx);l.grabPoint=e-u[0]-n.verticalPadding,l.barLength=u[1]-u[0]}l.clickableOrdinalRange=o.clickableOrdinalRange,l.stayingIntervals=t.multiselect&&i.filterSpecified?i.filter.getConsolidated():[],s&&(l.stayingIntervals=l.stayingIntervals.filter(function(t){return t[0]!==s[0]&&t[1]!==s[1]})),l.startExtent=o.region?s["s"===o.region?1:0]:r,t.parent.inBrushDrag=!0,l.brushStartCallback()}).on("drag",function(t){a.event.sourceEvent.stopPropagation();var e=t.height-a.mouse(this)[1]-2*n.verticalPadding,r=t.brush.svgBrush;r.wasDragged=!0,r.grabbingBar?r.newExtent=[e-r.grabPoint,e+r.barLength-r.grabPoint].map(t.unitToPaddedPx.invert):r.newExtent=[r.startExtent,t.unitToPaddedPx.invert(e)].sort(s);var i=Math.max(0,-r.newExtent[0]),o=Math.max(0,r.newExtent[1]-1);r.newExtent[0]+=i,r.newExtent[1]-=o,r.grabbingBar&&(r.newExtent[1]+=i,r.newExtent[0]-=o),t.brush.filterSpecified=!0,r.extent=r.stayingIntervals.concat([r.newExtent]),r.brushCallback(t),_(this.parentNode)}).on("dragend",function(t){a.event.sourceEvent.stopPropagation();var e=t.brush,r=e.filter,n=e.svgBrush,i=n.grabbingBar;if(n.grabbingBar=!1,n.grabLocation=void 0,t.parent.inBrushDrag=!1,b(),!n.wasDragged)return n.wasDragged=void 0,n.clickableOrdinalRange?e.filterSpecified&&t.multiselect?n.extent.push(n.clickableOrdinalRange):(n.extent=[n.clickableOrdinalRange],e.filterSpecified=!0):i?(n.extent=n.stayingIntervals,0===n.extent.length&&T(e)):T(e),n.brushCallback(t),_(this.parentNode),void n.brushEndCallback(e.filterSpecified?r.getConsolidated():[]);var o=function(){r.set(r.getConsolidated())};if(t.ordinal){var s=t.unitTickvals;s[s.length-1]n.newExtent[0];n.extent=n.stayingIntervals.concat(l?[n.newExtent]:[]),n.extent.length||T(e),n.brushCallback(t),l?_(this.parentNode,o):(o(),_(this.parentNode))}else o();n.brushEndCallback(e.filterSpecified?r.getConsolidated():[])}))}function k(t,e){return t[0]-e[0]}function T(t){t.filterSpecified=!1,t.svgBrush.extent=[[0,1]]}function M(t){for(var e,r=t.slice(),n=[],a=r.shift();a;){for(e=a.slice();(a=r.shift())&&a[0]<=e[1];)e[1]=Math.max(e[1],a[1]);n.push(e)}return n}e.exports={makeBrush:function(t,e,r,n,a,i){var o,l=function(){var t,e,r=[];return{set:function(n){r=n.map(function(t){return t.slice().sort(s)}).sort(k),t=M(r),e=r.reduce(function(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1])]},[1/0,-1/0])},get:function(){return r.slice()},getConsolidated:function(){return t},getBounds:function(){return e}}}();return l.set(r),{filter:l,filterSpecified:e,svgBrush:{extent:[],brushStartCallback:n,brushCallback:(o=a,function(t){var e=t.brush,r=function(t){return t.svgBrush.extent.map(function(t){return t.slice()})}(e).slice();e.filter.set(r),o()}),brushEndCallback:i}}},ensureAxisBrush:function(t){var e=t.selectAll("."+n.cn.axisBrush).data(o,i);e.enter().append("g").classed(n.cn.axisBrush,!0),function(t){var e=t.selectAll(".background").data(o);e.enter().append("rect").classed("background",!0).call(g).call(v).style("pointer-events","auto").attr("transform","translate(0 "+n.verticalPadding+")"),e.call(A).attr("height",function(t){return t.height-n.verticalPadding});var r=t.selectAll(".highlight-shadow").data(o);r.enter().append("line").classed("highlight-shadow",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width+n.bar.strokeWidth).attr("stroke",n.bar.strokeColor).attr("opacity",n.bar.strokeOpacity).attr("stroke-linecap","butt"),r.attr("y1",function(t){return t.height}).call(x);var a=t.selectAll(".highlight").data(o);a.enter().append("line").classed("highlight",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width-n.bar.strokeWidth).attr("stroke",n.bar.fillColor).attr("opacity",n.bar.fillOpacity).attr("stroke-linecap","butt"),a.attr("y1",function(t){return t.height}).call(x)}(e)},cleanRanges:function(t,e){if(Array.isArray(t[0])?(t=t.map(function(t){return t.sort(s)}),t=e.multiselect?M(t.sort(k)):[t[0]]):t=[t.sort(s)],e.tickvals){var r=e.tickvals.slice().sort(s);if(!(t=t.map(function(t){var e=[h(r,t[0],[]),d(r,t[1],[])];if(e[1]>e[0])return e}).filter(function(t){return t})).length)return}return t.length>1?t:t[0]}}},{"../../lib":437,"../../lib/gup":435,"./constants":573,d3:85}],571:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../plots/get_data").getModuleCalcData,i=t("./plot"),o=t("../../constants/xmlns_namespaces");r.name="parcoords",r.plot=function(t){var e=a(t.calcdata,"parcoords")[0];e.length&&i(t,e)},r.clean=function(t,e,r,n){var a=n._has&&n._has("parcoords"),i=e._has&&e._has("parcoords");a&&!i&&(n._paperdiv.selectAll(".parcoords").remove(),n._glimages.selectAll("*").remove())},r.toSVG=function(t){var e=t._fullLayout._glimages,r=n.select(t).selectAll(".svg-container");r.filter(function(t,e){return e===r.size()-1}).selectAll(".gl-canvas-context, .gl-canvas-focus").each(function(){var t=this.toDataURL("image/png");e.append("svg:image").attr({xmlns:o.svg,"xlink:href":t,preserveAspectRatio:"none",x:0,y:0,width:this.width,height:this.height})}),window.setTimeout(function(){n.selectAll("#filterBarPattern").attr("id","filterBarPattern")},60)}},{"../../constants/xmlns_namespaces":417,"../../plots/get_data":513,"./plot":579,d3:85}],572:[function(t,e,r){"use strict";var n=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/calc"),i=t("../../lib"),o=t("../../lib/gup").wrap;e.exports=function(t,e){var r=!!e.line.colorscale&&i.isArrayOrTypedArray(e.line.color),s=r?e.line.color:function(t){for(var e=new Array(t),r=0;rc&&(n.log("parcoords traces support up to "+c+" dimensions at the moment"),p.splice(c));var g=s(t,e,{name:"dimensions",handleItemDefaults:h}),v=function(t,e,r,o,s){var l=s("line.color",r);if(a(t,"line")&&n.isArrayOrTypedArray(l)){if(l.length)return s("line.colorscale"),i(t,e,o,s,{prefix:"line.",cLetter:"c"}),l.length;e.line.color=r}return 1/0}(t,e,r,u,d);o(e,u,d),Array.isArray(g)&&g.length||(e.visible=!1),f(e,g,"values",v);var m={family:u.font.family,size:Math.round(u.font.size/1.2),color:u.font.color};n.coerceFont(d,"labelfont",m),n.coerceFont(d,"tickfont",m),n.coerceFont(d,"rangefont",m)}},{"../../components/colorscale/defaults":328,"../../components/colorscale/helpers":329,"../../lib":437,"../../plots/array_container_defaults":480,"../../plots/domain":510,"./attributes":569,"./axisbrush":570,"./constants":573,"./merge_length":577}],575:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.colorbar={container:"line",min:"cmin",max:"cmax"},n.moduleType="trace",n.name="parcoords",n.basePlotModule=t("./base_plot"),n.categories=["gl","regl","noOpacity"],n.meta={},e.exports=n},{"./attributes":569,"./base_plot":571,"./calc":572,"./defaults":574,"./plot":579}],576:[function(t,e,r){"use strict";var n=t("glslify"),a=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\nuniform sampler2D mask;\nuniform float maskHeight;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec4 unit_1 = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit_1, unit_1);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nconst int bitsPerByte = 8;\n\nint mod2(int a) {\n return a - 2 * (a / 2);\n}\n\nint mod8(int a) {\n return a - 8 * (a / 8);\n}\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit_0 = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nbool withinBoundingBox(\n mat4 d[4],\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD\n ) {\n\n return mshow(d[0], loA, hiA) &&\n mshow(d[1], loB, hiB) &&\n mshow(d[2], loC, hiC) &&\n mshow(d[3], loD, hiD);\n}\n\nbool withinRasterMask(mat4 d[4], sampler2D mask, float height) {\n bool result = true;\n int bitInByteStepper;\n float valY, valueY, scaleX;\n int hit, bitmask, valX;\n for(int i = 0; i < 4; i++) {\n for(int j = 0; j < 4; j++) {\n for(int k = 0; k < 4; k++) {\n bitInByteStepper = mod8(j * 4 + k);\n valX = i * 2 + j / 2;\n valY = d[i][j][k];\n valueY = valY * (height - 1.0) + 0.5;\n scaleX = (float(valX) + 0.5) / 8.0;\n hit = int(texture2D(mask, vec2(scaleX, (valueY + 0.5) / height))[3] * 255.0) / int(pow(2.0, float(bitInByteStepper)));\n result = result && mod2(hit) == 1;\n }\n }\n }\n return result;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D,\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD,\n sampler2D mask, float maskHeight\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n float show = float(\n withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD)\n && withinRasterMask(dims, mask, maskHeight)\n );\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD,\n mask, maskHeight\n );\n\n float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);\n fragColor = texture2D(palette, vec2((clampedColorIndex * 255.0 + 0.5) / 256.0, 0.5));\n}\n"]),i=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec2 xyProjection = vec2(1, 1);\n\nvec4 unit = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit, unit);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depth,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D\n );\n\n float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);\n fragColor = texture2D(palette, vec2((clampedColorIndex * 255.0 + 0.5) / 256.0, 0.5));\n}\n"]),o=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D mask;\nuniform float maskHeight;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec4 unit_1 = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit_1, unit_1);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nconst int bitsPerByte = 8;\n\nint mod2(int a) {\n return a - 2 * (a / 2);\n}\n\nint mod8(int a) {\n return a - 8 * (a / 8);\n}\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit_0 = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nbool withinBoundingBox(\n mat4 d[4],\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD\n ) {\n\n return mshow(d[0], loA, hiA) &&\n mshow(d[1], loB, hiB) &&\n mshow(d[2], loC, hiC) &&\n mshow(d[3], loD, hiD);\n}\n\nbool withinRasterMask(mat4 d[4], sampler2D mask, float height) {\n bool result = true;\n int bitInByteStepper;\n float valY, valueY, scaleX;\n int hit, bitmask, valX;\n for(int i = 0; i < 4; i++) {\n for(int j = 0; j < 4; j++) {\n for(int k = 0; k < 4; k++) {\n bitInByteStepper = mod8(j * 4 + k);\n valX = i * 2 + j / 2;\n valY = d[i][j][k];\n valueY = valY * (height - 1.0) + 0.5;\n scaleX = (float(valX) + 0.5) / 8.0;\n hit = int(texture2D(mask, vec2(scaleX, (valueY + 0.5) / height))[3] * 255.0) / int(pow(2.0, float(bitInByteStepper)));\n result = result && mod2(hit) == 1;\n }\n }\n }\n return result;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D,\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD,\n sampler2D mask, float maskHeight\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n float show = float(\n withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD)\n && withinRasterMask(dims, mask, maskHeight)\n );\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD,\n mask, maskHeight\n );\n\n fragColor = vec4(pf.rgb, 1.0);\n}\n"]),s=n(["precision lowp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}\n"]),l=t("../../lib"),u=1e-6,c=1e-7,f=2048,h=64,d=2,p=4,g=8,v=h/g,m=[119,119,119],y=new Uint8Array(4),b=new Uint8Array(4),x={shape:[256,1],format:"rgba",type:"uint8",mag:"nearest",min:"nearest"};function _(t,e,r,n,a){var i=t._gl;i.enable(i.SCISSOR_TEST),i.scissor(e,r,n,a),t.clear({color:[0,0,0,0],depth:1})}function w(t,e,r,n,a,i){var o=i.key;r.drawCompleted||(!function(t){t.read({x:0,y:0,width:1,height:1,data:y})}(t),r.drawCompleted=!0),function s(l){var u;u=Math.min(n,a-l*n),i.offset=d*l*n,i.count=d*u,0===l&&(window.cancelAnimationFrame(r.currentRafs[o]),delete r.currentRafs[o],_(t,i.scissorX,i.scissorY,i.scissorWidth,i.viewBoxSize[1])),r.clearOnly||(e(i),l*n+u>>8*e)%256/255}function k(t,e,r){var n,a,i,o=[];for(a=0;a=h-4?A(o,h-2-s):.5);return i}(p,d,a);!function(t,e,r){for(var n=0;n<16;n++)t["p"+n.toString(16)](k(e,r,n))}(S,p,o),L=E.texture(l.extendFlat({data:function(t,e,r){for(var n=[],a=0;a<256;a++){var i=t(a/255);n.push((e?m:i).concat(r))}return n}(r.unitToColor,T,Math.round(255*(T?i:1)))},x))}var R=[0,1];var P=[];function I(t,e,n,a,i,o,s,u,c,f,h){var d,p,g,v,m=[t,e],y=[0,1].map(function(){return[0,1,2,3].map(function(){return new Float32Array(16)})});for(d=0;d<2;d++)for(v=m[d],p=0;p<4;p++)for(g=0;g<16;g++)y[d][p][g]=g+16*p===v?1:0;var b=r.lines.canvasOverdrag,x=r.domain,_=r.canvasWidth,w=r.canvasHeight;return l.extendFlat({key:s,resolution:[_,w],viewBoxPosition:[n+b,a],viewBoxSize:[i,o],i:t,ii:e,dim1A:y[0][0],dim1B:y[0][1],dim1C:y[0][2],dim1D:y[0][3],dim2A:y[1][0],dim2B:y[1][1],dim2C:y[1][2],dim2D:y[1][3],colorClamp:R,scissorX:(u===c?0:n+b)+(r.pad.l-b)+r.layoutWidth*x.x[0],scissorWidth:(u===f?_-n+b:i+.5)+(u===c?n+b:0),scissorY:a+r.pad.b+r.layoutHeight*x.y[0],scissorHeight:o,viewportX:r.pad.l-b+r.layoutWidth*x.x[0],viewportY:r.pad.b+r.layoutHeight*x.y[0],viewportWidth:_,viewportHeight:w},h)}return{setColorDomain:function(t){R[0]=t[0],R[1]=t[1]},render:function(t,e,n){var a,i,o,s=t.length,l=1/0,u=-1/0;for(a=0;au&&(u=t[a].dim2.canvasX,o=a),t[a].dim1.canvasXi._length&&(k=k.slice(0,i._length));var T,M=i.tickvals;function E(t,e){return{val:t,text:T[e]}}function C(t,e){return t.val-e.val}if(Array.isArray(M)&&M.length){T=i.ticktext,Array.isArray(T)&&T.length?T.length>M.length?T=T.slice(0,M.length):M.length>T.length&&(M=M.slice(0,T.length)):T=M.map(n.format(i.tickformat));for(var S=1;S=r||s>=a)return;var l=t.lineLayer.readPixel(o,a-1-s),u=0!==l[3],c=u?l[2]+256*(l[1]+256*l[0]):null,f={x:o,y:s,clientX:e.clientX,clientY:e.clientY,dataIndex:t.model.key,curveNumber:c};c!==k&&(u?p.hover(f):p.unhover&&p.unhover(f),k=c)}}),A.style("opacity",function(t){return t.pick?.01:1}),e.style("background","rgba(255, 255, 255, 0)");var T=e.selectAll("."+f.cn.parcoords).data(w,l);T.exit().remove(),T.enter().append("g").classed(f.cn.parcoords,!0).style("shape-rendering","crispEdges").style("pointer-events","none"),T.attr("transform",function(t){return"translate("+t.model.translateX+","+t.model.translateY+")"});var M=T.selectAll("."+f.cn.parcoordsControlView).data(u,l);M.enter().append("g").classed(f.cn.parcoordsControlView,!0),M.attr("transform",function(t){return"translate("+t.model.pad.l+","+t.model.pad.t+")"});var E=M.selectAll("."+f.cn.yAxis).data(function(t){return t.dimensions},l);function C(t,e){for(var r=e.panels||(e.panels=[]),n=t.data(),a=n.length-1,i=0;iline").attr("fill","none").attr("stroke","black").attr("stroke-opacity",.25).attr("stroke-width","1px"),L.selectAll("text").style("text-shadow","1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff").style("cursor","default").style("user-select","none");var O=S.selectAll("."+f.cn.axisHeading).data(u,l);O.enter().append("g").classed(f.cn.axisHeading,!0);var D=O.selectAll("."+f.cn.axisTitle).data(u,l);D.enter().append("text").classed(f.cn.axisTitle,!0).attr("text-anchor","middle").style("cursor","ew-resize").style("user-select","none").style("pointer-events","auto"),D.attr("transform","translate(0,"+-f.axisTitleOffset+")").text(function(t){return t.label}).each(function(t){i.font(n.select(this),t.model.labelFont)});var R=S.selectAll("."+f.cn.axisExtent).data(u,l);R.enter().append("g").classed(f.cn.axisExtent,!0);var P=R.selectAll("."+f.cn.axisExtentTop).data(u,l);P.enter().append("g").classed(f.cn.axisExtentTop,!0),P.attr("transform","translate(0,"+-f.axisExtentOffset+")");var I=P.selectAll("."+f.cn.axisExtentTopText).data(u,l);function z(t,e){if(t.ordinal)return"";var r=t.domainScale.domain();return n.format(t.tickFormat)(r[e?r.length-1:0])}I.enter().append("text").classed(f.cn.axisExtentTopText,!0).call(b),I.text(function(t){return z(t,!0)}).each(function(t){i.font(n.select(this),t.model.rangeFont)});var F=R.selectAll("."+f.cn.axisExtentBottom).data(u,l);F.enter().append("g").classed(f.cn.axisExtentBottom,!0),F.attr("transform",function(t){return"translate(0,"+(t.model.height+f.axisExtentOffset)+")"});var N=F.selectAll("."+f.cn.axisExtentBottomText).data(u,l);N.enter().append("text").classed(f.cn.axisExtentBottomText,!0).attr("dy","0.75em").call(b),N.text(function(t){return z(t)}).each(function(t){i.font(n.select(this),t.model.rangeFont)}),h.ensureAxisBrush(S)}},{"../../components/colorscale":330,"../../components/drawing":339,"../../lib":437,"../../lib/gup":435,"./axisbrush":570,"./constants":573,"./lines":576,d3:85}],579:[function(t,e,r){"use strict";var n=t("./parcoords"),a=t("../../lib/prepare_regl");e.exports=function(t,e){var r=t._fullLayout,i=r._toppaper,o=r._paperdiv,s=r._glcontainer;if(a(t)){var l={},u={},c={},f={},h=r._size;e.forEach(function(e,r){var n=e[0].trace;c[r]=n.index;var a=f[r]=n._fullInput.index;l[r]=t.data[a].dimensions,u[r]=t.data[a].dimensions.slice()});n(o,i,s,e,{width:h.w,height:h.h,margin:{t:h.t,r:h.r,b:h.b,l:h.l}},{filterChanged:function(e,n,a){var i=u[e][n],o=a.map(function(t){return t.slice()}),s="dimensions["+n+"].constraintrange",l=r._tracePreGUI[t._fullData[c[e]]._fullInput.uid];if(void 0===l[s]){var h=i.constraintrange;l[s]=h||null}var d=t._fullData[c[e]].dimensions[n];o.length?(1===o.length&&(o=o[0]),i.constraintrange=o,d.constraintrange=o.slice(),o=[o]):(delete i.constraintrange,delete d.constraintrange,o=null);var p={};p[s]=o,t.emit("plotly_restyle",[p,[f[e]]])},hover:function(e){t.emit("plotly_hover",e)},unhover:function(e){t.emit("plotly_unhover",e)},axesMoved:function(e,r){function n(t){return!("visible"in t)||t.visible}function a(t,e,r){var n=e.indexOf(r),a=t.indexOf(n);return-1===a&&(a+=e.length),a}var i=function(t){return function(e,n){return a(r,t,e)-a(r,t,n)}}(u[e].filter(n));l[e].sort(i),u[e].filter(function(t){return!n(t)}).sort(function(t){return u[e].indexOf(t)}).forEach(function(t){l[e].splice(l[e].indexOf(t),1),l[e].splice(u[e].indexOf(t),0,t)}),t.emit("plotly_restyle",[{dimensions:[l[e]]},[f[e]]])}})}}},{"../../lib/prepare_regl":450,"./parcoords":578}],580:[function(t,e,r){"use strict";var n=t("../../lib");r.formatPiePercent=function(t,e){var r=(100*t).toPrecision(3);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)+"%"},r.formatPieValue=function(t,e){var r=t.toPrecision(10);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)},r.getFirstFilled=function(t,e){if(Array.isArray(t))for(var r=0;r>>1,h)p[0]=t.xbounds[0],p[2]=t.xbounds[1],p[1]=t.ybounds[0],p[3]=t.ybounds[1];else for(l=0;lp[2]&&(p[2]=o),sp[3]&&(p[3]=s);if(d)r=d;else for(r=new Int32Array(e),l=0;lp[2]&&(p[2]=o),sp[3]&&(p[3]=s);this.idToIndex=r,this.pointcloudOptions.idToIndex=r,this.pointcloudOptions.positions=n;var g=a(t.marker.color),v=a(t.marker.border.color),m=t.opacity*t.marker.opacity;g[3]*=m,this.pointcloudOptions.color=g;var y=t.marker.blend;if(null===y){y=u.length<100||c.length<100}this.pointcloudOptions.blend=y,v[3]*=m,this.pointcloudOptions.borderColor=v;var b=t.marker.sizemin,x=Math.max(t.marker.sizemax,t.marker.sizemin);this.pointcloudOptions.sizeMin=b,this.pointcloudOptions.sizeMax=x,this.pointcloudOptions.areaRatio=t.marker.border.arearatio,this.pointcloud.update(this.pointcloudOptions);var _=this.scene.xaxis,w=this.scene.yaxis,A=x/2||.5;t._extremes[_._id]=i(_,[p[0],p[2]],{ppad:A}),t._extremes[w._id]=i(w,[p[1],p[3]],{ppad:A})},l.dispose=function(){this.pointcloud.dispose()},e.exports=function(t,e){var r=new s(t,e.uid);return r.update(e),r}},{"../../lib/str2rgbarray":460,"../../plots/cartesian/autorange":483,"../scatter/get_trace_color":597,"gl-pointcloud2d":176}],584:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("./attributes");e.exports=function(t,e,r){function i(r,i){return n.coerce(t,e,a,r,i)}i("x"),i("y"),i("xbounds"),i("ybounds"),t.xy&&t.xy instanceof Float32Array&&(e.xy=t.xy),t.indices&&t.indices instanceof Int32Array&&(e.indices=t.indices),i("text"),i("marker.color",r),i("marker.opacity"),i("marker.blend"),i("marker.sizemin"),i("marker.sizemax"),i("marker.border.color",r),i("marker.border.arearatio"),e._length=null}},{"../../lib":437,"./attributes":582}],585:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../scatter3d/calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="pointcloud",n.basePlotModule=t("../../plots/gl2d"),n.categories=["gl","gl2d","showLegend"],n.meta={},e.exports=n},{"../../plots/gl2d":516,"../scatter3d/calc":614,"./attributes":582,"./convert":583,"./defaults":584}],586:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rs&&T[v].gap;)v--;for(y=T[v].s,p=T.length-1;p>v;p--)T[p].s=y;for(;sM[c]&&c=0;a--){var i=t[a];if("scatter"===i.type&&i.xaxis===r.xaxis&&i.yaxis===r.yaxis){i.opacity=void 0;break}}}}}},{}],594:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("./constants"),s=t("./subtypes"),l=t("./xy_defaults"),u=t("./stack_defaults"),c=t("./marker_defaults"),f=t("./line_defaults"),h=t("./line_shape_defaults"),d=t("./text_defaults"),p=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,a){return n.coerce(t,e,i,r,a)}var m=l(t,e,g,v);if(m||(e.visible=!1),e.visible){var y=u(t,e,g,v),b=!y&&mG!=(F=D[L][1])>=G&&(P=D[L-1][0],I=D[L][0],F-z&&(R=P+(I-P)*(G-z)/(F-z),U=Math.min(U,R),H=Math.max(H,R)));U=Math.max(U,0),H=Math.min(H,h._length);var X=s.defaultLine;return s.opacity(f.fillcolor)?X=f.fillcolor:s.opacity((f.line||{}).color)&&(X=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:U,x1:H,y0:G,y1:G,color:X,hovertemplate:"%{name}"}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":318,"../../components/fx":357,"../../lib":437,"../../registry":528,"./fill_hover_text":595,"./get_trace_color":597}],599:[function(t,e,r){"use strict";var n={},a=t("./subtypes");n.hasLines=a.hasLines,n.hasMarkers=a.hasMarkers,n.hasText=a.hasText,n.isBubble=a.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":496,"./arrays_to_calcdata":586,"./attributes":587,"./calc":588,"./cross_trace_calc":592,"./cross_trace_defaults":593,"./defaults":594,"./hover":598,"./marker_colorbar":605,"./plot":607,"./select":608,"./style":610,"./subtypes":611}],600:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s,l){var u=(t.marker||{}).color;(s("line.color",r),a(t,"line"))?i(t,e,o,s,{prefix:"line.",cLetter:"c",noScale:!0}):s("line.color",!n(u)&&u||r);s("line.width"),(l||{}).noDash||s("line.dash")}},{"../../components/colorscale/defaults":328,"../../components/colorscale/helpers":329,"../../lib":437}],601:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),a=n.BADNUM,i=n.LOG_CLIP,o=i+.5,s=i-.5,l=t("../../lib"),u=l.segmentsIntersect,c=l.constrain,f=t("./constants");e.exports=function(t,e){var r,n,i,h,d,p,g,v,m,y,b,x,_,w,A,k,T,M,E=e.xaxis,C=e.yaxis,S="log"===E.type,L="log"===C.type,O=E._length,D=C._length,R=e.connectGaps,P=e.baseTolerance,I=e.shape,z="linear"===I,F=[],N=f.minTolerance,B=new Array(t.length),j=0;function U(e){var r=t[e];if(!r)return!1;var n=E.c2p(r.x),i=C.c2p(r.y);if(n===a){if(S&&(n=E.c2p(r.x,!0)),n===a)return!1;L&&i===a&&(n*=Math.abs(E._m*D*(E._m>0?o:s)/(C._m*O*(C._m>0?o:s)))),n*=1e3}if(i===a){if(L&&(i=C.c2p(r.y,!0)),i===a)return!1;i*=1e3}return[n,i]}function H(t,e,r,n){var a=r-t,i=n-e,o=.5-t,s=.5-e,l=a*a+i*i,u=a*o+i*s;if(u>0&&utt||t[1]rt)return[c(t[0],K,tt),c(t[1],et,rt)]}function it(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,a){var i=at(n),o=at(a),s=[];if(i&&o&&it(i,o))return s;i&&s.push(i),o&&s.push(o);var u=2*l.constrain((n[t]+a[t])/2,e,r)-((i||n)[t]+(o||a)[t]);u&&((i&&o?u>0==i[t]>o[t]?i:o:i||o)[t]+=u);return s}}function st(t){var e=t[0],r=t[1],n=e===B[j-1][0],a=r===B[j-1][1];if(!n||!a)if(j>1){var i=e===B[j-2][0],o=r===B[j-2][1];n&&(e===K||e===tt)&&i?o?j--:B[j-1]=t:a&&(r===et||r===rt)&&o?i?j--:B[j-1]=t:B[j++]=t}else B[j++]=t}function lt(t){B[j-1][0]!==t[0]&&B[j-1][1]!==t[1]&&st([W,Y]),st(t),Z=null,W=Y=0}function ut(t){if(T=t[0]/O,M=t[1]/D,G=t[0]tt?tt:0,X=t[1]rt?rt:0,G||X){if(j)if(Z){var e=Q(Z,t);e.length>1&&(lt(e[0]),B[j++]=e[1])}else J=Q(B[j-1],t)[0],B[j++]=J;else B[j++]=[G||t[0],X||t[1]];var r=B[j-1];G&&X&&(r[0]!==G||r[1]!==X)?(Z&&(W!==G&&Y!==X?st(W&&Y?(n=Z,i=(a=t)[0]-n[0],o=(a[1]-n[1])/i,(n[1]*a[0]-a[1]*n[0])/i>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[W||G,Y||X]):W&&Y&&st([W,Y])),st([G,X])):W-G&&Y-X&&st([G||W,X||Y]),Z=t,W=G,Y=X}else Z&<(Q(Z,t)[0]),B[j++]=t;var n,a,i,o}for("linear"===I||"spline"===I?Q=function(t,e){for(var r=[],n=0,a=0;a<4;a++){var i=nt[a],o=u(t[0],t[1],e[0],e[1],i[0],i[1],i[2],i[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&q(o,t)V(p,ct))break;i=p,(_=m[0]*v[0]+m[1]*v[1])>b?(b=_,h=p,g=!1):_=t.length||!p)break;ut(p),n=p}}else ut(h)}Z&&st([W||Z[0],Y||Z[1]]),F.push(B.slice(0,j))}return F}},{"../../constants/numerical":416,"../../lib":437,"./constants":591}],602:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],603:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var a,i,o,s,l,u={},c=!1,f=-1,h=0,d=-1;for(i=0;i=0?l=d:(l=d=h,h++),l0?Math.max(e,a):0}}},{"fast-isnumeric":149}],605:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],606:[function(t,e,r){"use strict";var n=t("../../components/color"),a=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l,u){var c=o.isBubble(t),f=(t.line||{}).color;(u=u||{},f&&(r=f),l("marker.symbol"),l("marker.opacity",c?.7:1),l("marker.size"),l("marker.color",r),a(t,"marker")&&i(t,e,s,l,{prefix:"marker.",cLetter:"c"}),u.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),u.noLine||(l("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:c?n.background:n.defaultLine),a(t,"marker.line")&&i(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",c?1:0)),c&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),u.gradient)&&("none"!==l("marker.gradient.type")&&l("marker.gradient.color"))}},{"../../components/color":318,"../../components/colorscale/defaults":328,"../../components/colorscale/helpers":329,"./subtypes":611}],607:[function(t,e,r){"use strict";var n=t("d3"),a=t("../../registry"),i=t("../../lib"),o=i.ensureSingle,s=i.identity,l=t("../../components/drawing"),u=t("./subtypes"),c=t("./line_points"),f=t("./link_traces"),h=t("../../lib/polygon").tester;function d(t,e,r,f,d,p,g){var v;!function(t,e,r,a,o){var s=r.xaxis,l=r.yaxis,c=n.extent(i.simpleMap(s.range,s.r2c)),f=n.extent(i.simpleMap(l.range,l.r2c)),h=a[0].trace;if(!u.hasMarkers(h))return;var d=h.marker.maxdisplayed;if(0===d)return;var p=a.filter(function(t){return t.x>=c[0]&&t.x<=c[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(p.length/d),v=0;o.forEach(function(t,r){var n=t[0].trace;u.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function y(t){return m?t.transition():t}var b=r.xaxis,x=r.yaxis,_=f[0].trace,w=_.line,A=n.select(p),k=o(A,"g","errorbars"),T=o(A,"g","lines"),M=o(A,"g","points"),E=o(A,"g","text");if(a.getComponentMethod("errorbars","plot")(t,k,r,g),!0===_.visible){var C,S;y(A).style("opacity",_.opacity);var L=_.fill.charAt(_.fill.length-1);"x"!==L&&"y"!==L&&(L=""),r.isRangePlot||(f[0].node3=A);var O="",D=[],R=_._prevtrace;R&&(O=R._prevRevpath||"",S=R._nextFill,D=R._polygons);var P,I,z,F,N,B,j,U,H,V="",q="",G=[],X=i.noop;if(C=_._ownFill,u.hasLines(_)||"none"!==_.fill){for(S&&S.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(z=l.steps(w.shape),F=l.steps(w.shape.split("").reverse().join(""))):z=F="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?l.smoothclosed(t.slice(1),w.smoothing):l.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},N=function(t){return F(t.reverse())},G=c(f,{xaxis:b,yaxis:x,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),H=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)y(r.style("opacity",0).attr("d",P).call(l.lineGroupStyle)).style("opacity",1);else{var a=y(r);a.attr("d",P),l.singleLineStyle(f,a)}}}}}var W=T.selectAll(".js-line").data(G);y(W.exit()).style("opacity",0).remove(),W.each(X(!1)),W.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(l.lineGroupStyle).each(X(!0)),l.setClipUrl(W,r.layerClipId,t),G.length?(C?(C.datum(f),B&&U&&(L?("y"===L?B[1]=U[1]=x.c2p(0,!0):"x"===L&&(B[0]=U[0]=b.c2p(0,!0)),y(C).attr("d","M"+U+"L"+B+"L"+V.substr(1)).call(l.singleFillStyle)):y(C).attr("d",V+"Z").call(l.singleFillStyle))):S&&("tonext"===_.fill.substr(0,6)&&V&&O?("tonext"===_.fill?y(S).attr("d",V+"Z"+O+"Z").call(l.singleFillStyle):y(S).attr("d",V+"L"+O.substr(1)+"Z").call(l.singleFillStyle),_._polygons=_._polygons.concat(D)):(Z(S),_._polygons=null)),_._prevRevpath=q,_._prevPolygons=H):(C?Z(C):S&&Z(S),_._polygons=_._prevRevpath=_._prevPolygons=null),M.datum(f),E.datum(f),function(e,a,i){var o,c=i[0].trace,f=u.hasMarkers(c),h=u.hasText(c),d=tt(c),p=et,g=et;if(f||h){var v=s,_=c.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[b._id+x._id][_].stackgaps;c.marker.maxdisplayed||c._needsCull?v=w?Q:J:_&&!w&&(v=$),f&&(p=v),h&&(g=v)}var A,k=(o=e.selectAll("path.point").data(p,d)).enter().append("path").classed("point",!0);m&&k.call(l.pointStyle,c,t).call(l.translatePoints,b,x).style("opacity",0).transition().style("opacity",1),o.order(),f&&(A=l.makePointStyleFns(c)),o.each(function(e){var a=n.select(this),i=y(a);l.translatePoint(e,i,b,x)?(l.singlePointStyle(e,i,c,A,t),r.layerClipId&&l.hideOutsideRangePoint(e,i,b,x,c.xcalendar,c.ycalendar),c.customdata&&a.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):i.remove()}),m?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=a.selectAll("g").data(g,d)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),a=y(e.select("text"));l.translatePoint(t,a,b,x)?r.layerClipId&&l.hideOutsideRangePoint(t,e,b,x,c.xcalendar,c.ycalendar):e.remove()}),o.selectAll("text").call(l.textPointStyle,c,t).each(function(t){var e=b.c2p(t.x),r=x.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){y(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(M,E,f);var Y=!1===_.cliponaxis?null:r.layerClipId;l.setClipUrl(M,Y,t),l.setClipUrl(E,Y,t)}function Z(t){y(t).attr("d","M0,0Z")}function J(t){return t.filter(function(t){return!t.gap&&t.vis})}function Q(t){return t.filter(function(t){return t.vis})}function $(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,a,i,u){var c,h,p=!i,g=!!i&&i.duration>0,v=f(t,e,r);((c=a.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),c.order(),function(t,e,r){e.each(function(e){var a=o(n.select(this),"g","fills");l.setClipUrl(a,r.layerClipId,t);var i=e[0].trace,u=[];i._ownfill&&u.push("_ownFill"),i._nexttrace&&u.push("_nextFill");var c=a.selectAll("g").data(u,s);c.enter().append("g"),c.exit().each(function(t){i[t]=null}).remove(),c.order().each(function(t){i[t]=o(n.select(this),"path","js-fill")})})}(t,c,e),g)?(u&&(h=u()),n.transition().duration(i.duration).ease(i.easing).each("end",function(){h&&h()}).each("interrupt",function(){h&&h()}).each(function(){a.selectAll("g.trace").each(function(r,n){d(t,n,e,r,v,this,i)})})):c.each(function(r,n){d(t,n,e,r,v,this,i)});p&&c.exit().remove(),a.selectAll("path:not([d])").remove()}},{"../../components/drawing":339,"../../lib":437,"../../lib/polygon":449,"../../registry":528,"./line_points":601,"./link_traces":603,"./subtypes":611,d3:85}],608:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,a,i,o,s=t.cd,l=t.xaxis,u=t.yaxis,c=[],f=s[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;rd.TOO_MANY_POINTS?"rect":f.hasMarkers(e)?"rect":"round";if(u&&e.connectgaps){var h=n[0],p=n[1];for(a=0;a1?l[a]:l[0]:l,p=Array.isArray(u)?u.length>1?u[a]:u[0]:u,v=g[d],m=g[p],y=c?c/.8+1:0,b=-m*y-.5*m;o.offset[a]=[v*y/h,b/h]}}return o}}},{"../../components/drawing":339,"../../constants/interactions":415,"../../lib":437,"../../lib/gl_format_color":434,"../../plots/cartesian/axis_ids":487,"../../registry":528,"../scatter/make_bubble_size_func":604,"../scatter/subtypes":611,"./constants":616,"color-normalize":63,"fast-isnumeric":149,"svg-path-sdf":281}],618:[function(t,e,r){"use strict";var n=t("../../lib"),a=t("../../registry"),i=t("./attributes"),o=t("../scatter/constants"),s=t("../scatter/subtypes"),l=t("../scatter/xy_defaults"),u=t("../scatter/marker_defaults"),c=t("../scatter/line_defaults"),f=t("../scatter/fillcolor_defaults"),h=t("../scatter/text_defaults");e.exports=function(t,e,r,d){function p(r,a){return n.coerce(t,e,i,r,a)}var g=!!t.marker&&/-open/.test(t.marker.symbol),v=s.isBubble(t),m=l(t,e,d,p);if(m){var y=m1&&c.extendFlat(o.line,k.linePositions(t,r,n)),o.errorX||o.errorY){var s=k.errorBarPositions(t,r,n,a,i);o.errorX&&c.extendFlat(o.errorX,s.x),o.errorY&&c.extendFlat(o.errorY,s.y)}return o.text&&(c.extendFlat(o.text,{positions:n},k.textPosition(t,r,o.text,o.marker)),c.extendFlat(o.textSel,{positions:n},k.textPosition(t,r,o.text,o.markerSel)),c.extendFlat(o.textUnsel,{positions:n},k.textPosition(t,r,o.text,o.markerUnsel))),o}(t,0,e,_,g,v),L=S(0,u);return b(i,e),f=M&&(E.marker.cluster=p.tree),L.lineOptions.push(E.line),L.errorXOptions.push(E.errorX),L.errorYOptions.push(E.errorY),L.fillOptions.push(E.fill),L.markerOptions.push(E.marker),L.markerSelectedOptions.push(E.markerSel),L.markerUnselectedOptions.push(E.markerUnsel),L.textOptions.push(E.text),L.textSelectedOptions.push(E.textSel),L.textUnselectedOptions.push(E.textUnsel),p._scene=L,p.index=L.count,p.x=g,p.y=v,p.positions=_,L.count++,[{x:!1,y:!1,t:p,trace:e}]},plot:function(t,e,r){if(r.length){var o,s,u=t._fullLayout,h=e._scene,d=e.xaxis,p=e.yaxis;if(h)if(f(t,["ANGLE_instanced_arrays","OES_element_index_uint"])){var g=u._glcanvas.data()[0].regl;if(_(t,e,r),h.dirty){if(!0===h.error2d&&(h.error2d=i(g)),!0===h.line2d&&(h.line2d=a(g)),!0===h.scatter2d&&(h.scatter2d=n(g)),!0===h.fill2d&&(h.fill2d=a(g)),!0===h.glText)for(h.glText=new Array(h.count),o=0;or&&(isNaN(e[n])||isNaN(e[n+1]));)n-=2;t.positions=e.slice(r,n+2)}return t}),h.line2d.update(h.lineOptions)),h.error2d){var v=(h.errorXOptions||[]).concat(h.errorYOptions||[]);h.error2d.update(v)}h.scatter2d&&h.scatter2d.update(h.markerOptions),h.fillOrder=c.repeat(null,h.count),h.fill2d&&(h.fillOptions=h.fillOptions.map(function(t,e){var n=r[e];if(t&&n&&n[0]&&n[0].trace){var a,i,o=n[0],s=o.trace,l=o.t,u=h.lineOptions[e],c=[];s._ownfill&&c.push(e),s._nexttrace&&c.push(e+1),c.length&&(h.fillOrder[e]=c);var f,d,p=[],g=u&&u.positions||l.positions;if("tozeroy"===s.fill){for(f=0;ff&&isNaN(g[d+1]);)d-=2;0!==g[f+1]&&(p=[g[f],0]),p=p.concat(g.slice(f,d+2)),0!==g[d+1]&&(p=p.concat([g[d],0]))}else if("tozerox"===s.fill){for(f=0;ff&&isNaN(g[d]);)d-=2;0!==g[f]&&(p=[0,g[f+1]]),p=p.concat(g.slice(f,d+2)),0!==g[d]&&(p=p.concat([0,g[d+1]]))}else if("toself"===s.fill||"tonext"===s.fill){for(p=[],a=0,i=0;i-1;for(o=0;oi&&l?r._splomSubplots[E]=1:a-1,T="lasso"===y||"select"===y||!!h.selectedpoints||k;if(p.selectBatch=null,p.unselectBatch=null,T){var M=h._length;if(p.selectBatch||(p.selectBatch=[],p.unselectBatch=[]),h.selectedpoints){p.selectBatch=h.selectedpoints;var E=h.selectedpoints,C={};for(i=0;im?2*(b.sizeAvg||Math.max(b.size,3)):c(e,y),n=0;n:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", + "X:hover .modebar--hover .modebar-group": "opacity:1;", "X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;", "X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;", "X .modebar-btn svg": "position:relative;top:2px;", @@ -71,7 +71,7 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":498}],2:[function(_dereq_,module,exports){ +},{"../src/lib":494}],2:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -214,7 +214,7 @@ module.exports = { module.exports = _dereq_('../src/traces/cone'); -},{"../src/traces/cone":610}],4:[function(_dereq_,module,exports){ +},{"../src/traces/cone":606}],4:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -227,7 +227,7 @@ module.exports = _dereq_('../src/traces/cone'); module.exports = _dereq_('../src/core'); -},{"../src/core":480}],5:[function(_dereq_,module,exports){ +},{"../src/core":476}],5:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -263,7 +263,7 @@ module.exports = Plotly; module.exports = _dereq_('../src/traces/mesh3d'); -},{"../src/traces/mesh3d":615}],7:[function(_dereq_,module,exports){ +},{"../src/traces/mesh3d":611}],7:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -276,7 +276,7 @@ module.exports = _dereq_('../src/traces/mesh3d'); module.exports = _dereq_('../src/traces/scatter3d'); -},{"../src/traces/scatter3d":651}],8:[function(_dereq_,module,exports){ +},{"../src/traces/scatter3d":647}],8:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -289,7 +289,7 @@ module.exports = _dereq_('../src/traces/scatter3d'); module.exports = _dereq_('../src/traces/streamtube'); -},{"../src/traces/streamtube":656}],9:[function(_dereq_,module,exports){ +},{"../src/traces/streamtube":652}],9:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -302,7 +302,7 @@ module.exports = _dereq_('../src/traces/streamtube'); module.exports = _dereq_('../src/traces/surface'); -},{"../src/traces/surface":661}],10:[function(_dereq_,module,exports){ +},{"../src/traces/surface":657}],10:[function(_dereq_,module,exports){ 'use strict' module.exports = createCamera @@ -663,7 +663,7 @@ function createViewController(options) { matrix: matrix }, mode) } -},{"matrix-camera-controller":268,"orbit-camera-controller":289,"turntable-camera-controller":345}],12:[function(_dereq_,module,exports){ +},{"matrix-camera-controller":268,"orbit-camera-controller":289,"turntable-camera-controller":344}],12:[function(_dereq_,module,exports){ 'use strict' var weakMap = typeof WeakMap === 'undefined' ? _dereq_('weak-map') : WeakMap @@ -694,7 +694,7 @@ function createABigTriangle(gl) { module.exports = createABigTriangle -},{"gl-buffer":104,"gl-vao":167,"weak-map":353}],13:[function(_dereq_,module,exports){ +},{"gl-buffer":104,"gl-vao":167,"weak-map":352}],13:[function(_dereq_,module,exports){ var padLeft = _dereq_('pad-left') module.exports = addLineNumbers @@ -5171,7 +5171,7 @@ function boxIntersectWrapper(arg0, arg1, arg2) { throw new Error('box-intersect: Invalid arguments') } } -},{"./lib/intersect":42,"./lib/sweep":46,"typedarray-pool":348}],41:[function(_dereq_,module,exports){ +},{"./lib/intersect":42,"./lib/sweep":46,"typedarray-pool":347}],41:[function(_dereq_,module,exports){ 'use strict' var DIMENSION = 'd' @@ -5811,7 +5811,7 @@ function boxIntersectIter( } } } -},{"./brute":41,"./median":43,"./partition":44,"./sweep":46,"bit-twiddle":37,"typedarray-pool":348}],43:[function(_dereq_,module,exports){ +},{"./brute":41,"./median":43,"./partition":44,"./sweep":46,"bit-twiddle":37,"typedarray-pool":347}],43:[function(_dereq_,module,exports){ 'use strict' module.exports = findMedian @@ -6647,7 +6647,7 @@ red_loop: } } } -},{"./sort":45,"bit-twiddle":37,"typedarray-pool":348}],47:[function(_dereq_,module,exports){ +},{"./sort":45,"bit-twiddle":37,"typedarray-pool":347}],47:[function(_dereq_,module,exports){ },{}],48:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. @@ -7223,7 +7223,7 @@ function typedArraySupport () { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } return arr.foo() === 42 } catch (e) { return false @@ -10180,7 +10180,7 @@ function cleanPSLG (points, edges, colors) { return modified } -},{"./lib/rat-seg-intersect":61,"big-rat":23,"big-rat/cmp":21,"big-rat/to-float":35,"box-intersect":40,"nextafter":286,"rat-vec":310,"robust-segment-intersect":324,"union-find":349}],61:[function(_dereq_,module,exports){ +},{"./lib/rat-seg-intersect":61,"big-rat":23,"big-rat/cmp":21,"big-rat/to-float":35,"box-intersect":40,"nextafter":286,"rat-vec":310,"robust-segment-intersect":324,"union-find":348}],61:[function(_dereq_,module,exports){ 'use strict' module.exports = solveIntersection @@ -11113,7 +11113,7 @@ function compareAngle(a, b, c, d) { } } } -},{"robust-orientation":321,"robust-product":322,"robust-sum":326,"signum":327,"two-sum":347}],71:[function(_dereq_,module,exports){ +},{"robust-orientation":321,"robust-product":322,"robust-sum":326,"signum":327,"two-sum":346}],71:[function(_dereq_,module,exports){ module.exports = compareCells var min = Math.min @@ -11826,7 +11826,7 @@ function generateCWiseOp(proc, typesig) { } module.exports = generateCWiseOp -},{"uniq":350}],80:[function(_dereq_,module,exports){ +},{"uniq":349}],80:[function(_dereq_,module,exports){ "use strict" // The function below is called when constructing a cwise function object, and does the following: @@ -21638,7 +21638,7 @@ function triangulate(points, includePointAtInfinity) { return hull } -},{"incremental-convex-hull":253,"uniq":350}],85:[function(_dereq_,module,exports){ +},{"incremental-convex-hull":253,"uniq":349}],85:[function(_dereq_,module,exports){ (function (Buffer){ var hasTypedArrays = false if(typeof Float64Array !== "undefined") { @@ -21852,7 +21852,7 @@ function edgeToAdjacency(edges, numVertices) { } return adj } -},{"uniq":350}],89:[function(_dereq_,module,exports){ +},{"uniq":349}],89:[function(_dereq_,module,exports){ (function (process,global){ /*! * @overview es6-promise - a tiny implementation of Promises/A+. @@ -24452,12754 +24452,12865 @@ function getCanvasContext (type, opts) { } },{}],96:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createAxes - -var createText = _dereq_('./lib/text.js') -var createLines = _dereq_('./lib/lines.js') -var createBackground = _dereq_('./lib/background.js') -var getCubeProperties = _dereq_('./lib/cube.js') -var Ticks = _dereq_('./lib/ticks.js') - -var identity = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1]) - -function copyVec3(a, b) { - a[0] = b[0] - a[1] = b[1] - a[2] = b[2] - return a -} - -function Axes(gl) { - this.gl = gl - - this.pixelRatio = 1 - - this.bounds = [ [-10, -10, -10], - [ 10, 10, 10] ] - this.ticks = [ [], [], [] ] - this.autoTicks = true - this.tickSpacing = [ 1, 1, 1 ] - - this.tickEnable = [ true, true, true ] - this.tickFont = [ 'sans-serif', 'sans-serif', 'sans-serif' ] - this.tickSize = [ 12, 12, 12 ] - this.tickAngle = [ 0, 0, 0 ] - this._tickAlign = [ 'auto', 'auto', 'auto' ] - this.tickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - this.tickPad = [ 10, 10, 10 ] - - this.lastCubeProps = { - cubeEdges: [0,0,0], - axis: [0,0,0] - } - - this.labels = [ 'x', 'y', 'z' ] - this.labelEnable = [ true, true, true ] - this.labelFont = 'sans-serif' - this.labelSize = [ 20, 20, 20 ] - this._labelAngle = [ 0, 0, 0 ] - this._labelAlign = [ 'auto', 'auto', 'auto' ] - this.labelColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - this.labelPad = [ 10, 10, 10 ] - - this.lineEnable = [ true, true, true ] - this.lineMirror = [ false, false, false ] - this.lineWidth = [ 1, 1, 1 ] - this.lineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - - this.lineTickEnable = [ true, true, true ] - this.lineTickMirror = [ false, false, false ] - this.lineTickLength = [ 0, 0, 0 ] - this.lineTickWidth = [ 1, 1, 1 ] - this.lineTickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - - this.gridEnable = [ true, true, true ] - this.gridWidth = [ 1, 1, 1 ] - this.gridColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - - this.zeroEnable = [ true, true, true ] - this.zeroLineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - this.zeroLineWidth = [ 2, 2, 2 ] - - this.backgroundEnable = [ false, false, false ] - this.backgroundColor = [ [0.8, 0.8, 0.8, 0.5], - [0.8, 0.8, 0.8, 0.5], - [0.8, 0.8, 0.8, 0.5] ] - - this._firstInit = true - this._text = null - this._lines = null - this._background = createBackground(gl) -} - -var proto = Axes.prototype - -proto.update = function(options) { - options = options || {} - - //Option parsing helper functions - function parseOption(nest, cons, name) { - if(name in options) { - var opt = options[name] - var prev = this[name] - var next - if(nest ? (Array.isArray(opt) && Array.isArray(opt[0])) : - Array.isArray(opt) ) { - this[name] = next = [ cons(opt[0]), cons(opt[1]), cons(opt[2]) ] - } else { - this[name] = next = [ cons(opt), cons(opt), cons(opt) ] - } - for(var i=0; i<3; ++i) { - if(next[i] !== prev[i]) { - return true - } - } - } - return false - } - - var NUMBER = parseOption.bind(this, false, Number) - var BOOLEAN = parseOption.bind(this, false, Boolean) - var STRING = parseOption.bind(this, false, String) - var COLOR = parseOption.bind(this, true, function(v) { - if(Array.isArray(v)) { - if(v.length === 3) { - return [ +v[0], +v[1], +v[2], 1.0 ] - } else if(v.length === 4) { - return [ +v[0], +v[1], +v[2], +v[3] ] - } - } - return [ 0, 0, 0, 1 ] - }) - - //Tick marks and bounds - var nextTicks - var ticksUpdate = false - var boundsChanged = false - if('bounds' in options) { - var bounds = options.bounds -i_loop: - for(var i=0; i<2; ++i) { - for(var j=0; j<3; ++j) { - if(bounds[i][j] !== this.bounds[i][j]) { - boundsChanged = true - } - this.bounds[i][j] = bounds[i][j] - } - } - } - if('ticks' in options) { - nextTicks = options.ticks - ticksUpdate = true - this.autoTicks = false - for(var i=0; i<3; ++i) { - this.tickSpacing[i] = 0.0 - } - } else if(NUMBER('tickSpacing')) { - this.autoTicks = true - boundsChanged = true - } - - if(this._firstInit) { - if(!('ticks' in options || 'tickSpacing' in options)) { - this.autoTicks = true - } - - //Force tick recomputation on first update - boundsChanged = true - ticksUpdate = true - this._firstInit = false - } - - if(boundsChanged && this.autoTicks) { - nextTicks = Ticks.create(this.bounds, this.tickSpacing) - ticksUpdate = true - } - - //Compare next ticks to previous ticks, only update if needed - if(ticksUpdate) { - for(var i=0; i<3; ++i) { - nextTicks[i].sort(function(a,b) { - return a.x-b.x - }) - } - if(Ticks.equal(nextTicks, this.ticks)) { - ticksUpdate = false - } else { - this.ticks = nextTicks - } - } - - //Parse tick properties - BOOLEAN('tickEnable') - if(STRING('tickFont')) { - ticksUpdate = true //If font changes, must rebuild vbo - } - NUMBER('tickSize') - NUMBER('tickAngle') - NUMBER('tickPad') - COLOR('tickColor') - - //Axis labels - var labelUpdate = STRING('labels') - if(STRING('labelFont')) { - labelUpdate = true - } - BOOLEAN('labelEnable') - NUMBER('labelSize') - NUMBER('labelPad') - COLOR('labelColor') - - //Axis lines - BOOLEAN('lineEnable') - BOOLEAN('lineMirror') - NUMBER('lineWidth') - COLOR('lineColor') - - //Axis line ticks - BOOLEAN('lineTickEnable') - BOOLEAN('lineTickMirror') - NUMBER('lineTickLength') - NUMBER('lineTickWidth') - COLOR('lineTickColor') - - //Grid lines - BOOLEAN('gridEnable') - NUMBER('gridWidth') - COLOR('gridColor') - - //Zero line - BOOLEAN('zeroEnable') - COLOR('zeroLineColor') - NUMBER('zeroLineWidth') - - //Background - BOOLEAN('backgroundEnable') - COLOR('backgroundColor') - - //Update text if necessary - if(!this._text) { - this._text = createText( - this.gl, - this.bounds, - this.labels, - this.labelFont, - this.ticks, - this.tickFont) - } else if(this._text && (labelUpdate || ticksUpdate)) { - this._text.update( - this.bounds, - this.labels, - this.labelFont, - this.ticks, - this.tickFont) - } - - //Update lines if necessary - if(this._lines && ticksUpdate) { - this._lines.dispose() - this._lines = null - } - if(!this._lines) { - this._lines = createLines(this.gl, this.bounds, this.ticks) - } -} - -function OffsetInfo() { - this.primalOffset = [0,0,0] - this.primalMinor = [0,0,0] - this.mirrorOffset = [0,0,0] - this.mirrorMinor = [0,0,0] -} - -var LINE_OFFSET = [ new OffsetInfo(), new OffsetInfo(), new OffsetInfo() ] - -function computeLineOffset(result, i, bounds, cubeEdges, cubeAxis) { - var primalOffset = result.primalOffset - var primalMinor = result.primalMinor - var dualOffset = result.mirrorOffset - var dualMinor = result.mirrorMinor - var e = cubeEdges[i] - - //Calculate offsets - for(var j=0; j<3; ++j) { - if(i === j) { - continue - } - var a = primalOffset, - b = dualOffset, - c = primalMinor, - d = dualMinor - if(e & (1< 0) { - c[j] = -1 - d[j] = 0 - } else { - c[j] = 0 - d[j] = +1 - } - } -} - -var CUBE_ENABLE = [0,0,0] -var DEFAULT_PARAMS = { - model: identity, - view: identity, - projection: identity -} - -proto.isOpaque = function() { - return true -} - -proto.isTransparent = function() { - return false -} - -proto.drawTransparent = function(params) {} - -var ALIGN_OPTION_AUTO = 0 // i.e. as defined in the shader the text would rotate to stay upwards range: [-90,90] - -var PRIMAL_MINOR = [0,0,0] -var MIRROR_MINOR = [0,0,0] -var PRIMAL_OFFSET = [0,0,0] - -proto.draw = function(params) { - params = params || DEFAULT_PARAMS - - var gl = this.gl - - //Geometry for camera and axes - var model = params.model || identity - var view = params.view || identity - var projection = params.projection || identity - var bounds = this.bounds - - //Unpack axis info - var cubeParams = getCubeProperties(model, view, projection, bounds) - var cubeEdges = cubeParams.cubeEdges - var cubeAxis = cubeParams.axis - - var cx = view[12] - var cy = view[13] - var cz = view[14] - var cw = view[15] - - var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight - - for(var i=0; i<3; ++i) { - this.lastCubeProps.cubeEdges[i] = cubeEdges[i] - this.lastCubeProps.axis[i] = cubeAxis[i] - } - - //Compute axis info - var lineOffset = LINE_OFFSET - for(var i=0; i<3; ++i) { - computeLineOffset( - LINE_OFFSET[i], - i, - this.bounds, - cubeEdges, - cubeAxis) - } - - //Set up state parameters - var gl = this.gl - - //Draw background first - var cubeEnable = CUBE_ENABLE - for(var i=0; i<3; ++i) { - if(this.backgroundEnable[i]) { - cubeEnable[i] = cubeAxis[i] - } else { - cubeEnable[i] = 0 - } - } - - this._background.draw( - model, - view, - projection, - bounds, - cubeEnable, - this.backgroundColor) - - //Draw lines - this._lines.bind( - model, - view, - projection, - this) - - //First draw grid lines and zero lines - for(var i=0; i<3; ++i) { - var x = [0,0,0] - if(cubeAxis[i] > 0) { - x[i] = bounds[1][i] - } else { - x[i] = bounds[0][i] - } - - //Draw grid lines - for(var j=0; j<2; ++j) { - var u = (i + 1 + j) % 3 - var v = (i + 1 + (j^1)) % 3 - if(this.gridEnable[u]) { - this._lines.drawGrid(u, v, this.bounds, x, this.gridColor[u], this.gridWidth[u]*this.pixelRatio) - } - } - - //Draw zero lines (need to do this AFTER all grid lines are drawn) - for(var j=0; j<2; ++j) { - var u = (i + 1 + j) % 3 - var v = (i + 1 + (j^1)) % 3 - if(this.zeroEnable[v]) { - //Check if zero line in bounds - if(Math.min(bounds[0][v], bounds[1][v]) <= 0 && Math.max(bounds[0][v], bounds[1][v]) >= 0) { - this._lines.drawZero(u, v, this.bounds, x, this.zeroLineColor[v], this.zeroLineWidth[v]*this.pixelRatio) - } - } - } - } - - //Then draw axis lines and tick marks - for(var i=0; i<3; ++i) { - - //Draw axis lines - if(this.lineEnable[i]) { - this._lines.drawAxisLine(i, this.bounds, lineOffset[i].primalOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) - } - if(this.lineMirror[i]) { - this._lines.drawAxisLine(i, this.bounds, lineOffset[i].mirrorOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) - } - - //Compute minor axes - var primalMinor = copyVec3(PRIMAL_MINOR, lineOffset[i].primalMinor) - var mirrorMinor = copyVec3(MIRROR_MINOR, lineOffset[i].mirrorMinor) - var tickLength = this.lineTickLength - var op = 0 - for(var j=0; j<3; ++j) { - var scaleFactor = pixelScaleF / model[5*j] - primalMinor[j] *= tickLength[j] * scaleFactor - mirrorMinor[j] *= tickLength[j] * scaleFactor - } - - //Draw axis line ticks - if(this.lineTickEnable[i]) { - this._lines.drawAxisTicks(i, lineOffset[i].primalOffset, primalMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) - } - if(this.lineTickMirror[i]) { - this._lines.drawAxisTicks(i, lineOffset[i].mirrorOffset, mirrorMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) - } - } - this._lines.unbind() - - //Draw text sprites - this._text.bind( - model, - view, - projection, - this.pixelRatio) - - var alignOpt // options in shader are from this list {-1, 0, 1, 2, 3, ..., n} - // -1: backward compatible - // 0: raw data - // 1: auto align, free angles - // 2: auto align, horizontal or vertical - //3-n: auto align, round to n directions e.g. 12 -> round to angles with 30-degree steps - - var hv_ratio = 0.5 // can have an effect on the ratio between horizontals and verticals when using option 2 - - var enableAlign - var alignDir - - function alignTo(i) { - alignDir = [0,0,0] - alignDir[i] = 1 - } - - function solveTickAlignments(i, minor, major) { - - var i1 = (i + 1) % 3 - var i2 = (i + 2) % 3 - - var A = minor[i1] - var B = minor[i2] - var C = major[i1] - var D = major[i2] - - if ((A > 0) && (D > 0)) { alignTo(i1); return; } - else if ((A > 0) && (D < 0)) { alignTo(i1); return; } - else if ((A < 0) && (D > 0)) { alignTo(i1); return; } - else if ((A < 0) && (D < 0)) { alignTo(i1); return; } - else if ((B > 0) && (C > 0)) { alignTo(i2); return; } - else if ((B > 0) && (C < 0)) { alignTo(i2); return; } - else if ((B < 0) && (C > 0)) { alignTo(i2); return; } - else if ((B < 0) && (C < 0)) { alignTo(i2); return; } - } - - for(var i=0; i<3; ++i) { - - var minor = lineOffset[i].primalMinor - var major = lineOffset[i].mirrorMinor - - var offset = copyVec3(PRIMAL_OFFSET, lineOffset[i].primalOffset) - - for(var j=0; j<3; ++j) { - if(this.lineTickEnable[i]) { - offset[j] += pixelScaleF * minor[j] * Math.max(this.lineTickLength[j], 0) / model[5*j] - } - } - - var axis = [0,0,0] - axis[i] = 1 - - //Draw tick text - if(this.tickEnable[i]) { - - if(this.tickAngle[i] === -3600) { - this.tickAngle[i] = 0 - this._tickAlign[i] = 'auto' - } else { - this._tickAlign[i] = -1 - } - - enableAlign = 1; - - alignOpt = [this._tickAlign[i], hv_ratio, enableAlign] - if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO - else alignOpt[0] = parseInt('' + alignOpt[0]) - - alignDir = [0,0,0] - solveTickAlignments(i, minor, major) - - //Add tick padding - for(var j=0; j<3; ++j) { - offset[j] += pixelScaleF * minor[j] * this.tickPad[j] / model[5*j] - } - - //Draw axis - this._text.drawTicks( - i, - this.tickSize[i], - this.tickAngle[i], - offset, - this.tickColor[i], - axis, - alignDir, - alignOpt) - } - - //Draw labels - if(this.labelEnable[i]) { - - enableAlign = 0 - alignDir = [0,0,0] - if(this.labels[i].length > 4) { // for large label axis enable alignDir to axis - alignTo(i) - enableAlign = 1 - } - - alignOpt = [this._labelAlign[i], hv_ratio, enableAlign] - if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO - else alignOpt[0] = parseInt('' + alignOpt[0]) - - //Add label padding - for(var j=0; j<3; ++j) { - offset[j] += pixelScaleF * minor[j] * this.labelPad[j] / model[5*j] - } - offset[i] += 0.5 * (bounds[0][i] + bounds[1][i]) - - //Draw axis - this._text.drawLabel( - i, - this.labelSize[i], - this._labelAngle[i], - offset, - this.labelColor[i], - [0,0,0], - alignDir, - alignOpt) - } - } - - this._text.unbind() -} - -proto.dispose = function() { - this._text.dispose() - this._lines.dispose() - this._background.dispose() - this._lines = null - this._text = null - this._background = null - this.gl = null -} - -function createAxes(gl, options) { - var axes = new Axes(gl) - axes.update(options) - return axes -} +'use strict' -},{"./lib/background.js":97,"./lib/cube.js":98,"./lib/lines.js":99,"./lib/text.js":101,"./lib/ticks.js":102}],97:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createBackgroundCube - -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createShader = _dereq_('./shaders').bg - -function BackgroundCube(gl, buffer, vao, shader) { - this.gl = gl - this.buffer = buffer - this.vao = vao - this.shader = shader -} - -var proto = BackgroundCube.prototype - -proto.draw = function(model, view, projection, bounds, enable, colors) { - var needsBG = false - for(var i=0; i<3; ++i) { - needsBG = needsBG || enable[i] - } - if(!needsBG) { - return - } - - var gl = this.gl - - gl.enable(gl.POLYGON_OFFSET_FILL) - gl.polygonOffset(1, 2) - - this.shader.bind() - this.shader.uniforms = { - model: model, - view: view, - projection: projection, - bounds: bounds, - enable: enable, - colors: colors - } - this.vao.bind() - this.vao.draw(this.gl.TRIANGLES, 36) - this.vao.unbind() - - gl.disable(gl.POLYGON_OFFSET_FILL) -} - -proto.dispose = function() { - this.vao.dispose() - this.buffer.dispose() - this.shader.dispose() -} - -function createBackgroundCube(gl) { - //Create cube vertices - var vertices = [] - var indices = [] - var ptr = 0 - for(var d=0; d<3; ++d) { - var u = (d+1) % 3 - var v = (d+2) % 3 - var x = [0,0,0] - var c = [0,0,0] - for(var s=-1; s<=1; s+=2) { - indices.push(ptr, ptr+2, ptr+1, - ptr+1, ptr+2, ptr+3) - x[d] = s - c[d] = s - for(var i=-1; i<=1; i+=2) { - x[u] = i - for(var j=-1; j<=1; j+=2) { - x[v] = j - vertices.push(x[0], x[1], x[2], - c[0], c[1], c[2]) - ptr += 1 - } - } - //Swap u and v - var tt = u - u = v - v = tt - } - } - - //Allocate buffer and vertex array - var buffer = createBuffer(gl, new Float32Array(vertices)) - var elements = createBuffer(gl, new Uint16Array(indices), gl.ELEMENT_ARRAY_BUFFER) - var vao = createVAO(gl, [ - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 0, - stride: 24 - }, - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 12, - stride: 24 - } - ], elements) - - //Create shader object - var shader = createShader(gl) - shader.attributes.position.location = 0 - shader.attributes.normal.location = 1 - - return new BackgroundCube(gl, buffer, vao, shader) -} +module.exports = createAxes -},{"./shaders":100,"gl-buffer":104,"gl-vao":167}],98:[function(_dereq_,module,exports){ -"use strict" - -module.exports = getCubeEdges - -var bits = _dereq_('bit-twiddle') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var splitPoly = _dereq_('split-polygon') -var orient = _dereq_('robust-orientation') - -var mvp = new Array(16) -var imvp = new Array(16) -var pCubeVerts = new Array(8) -var cubeVerts = new Array(8) -var x = new Array(3) -var zero3 = [0,0,0] - -;(function() { - for(var i=0; i<8; ++i) { - pCubeVerts[i] =[1,1,1,1] - cubeVerts[i] = [1,1,1] - } -})() - - -function transformHg(result, x, mat) { - for(var i=0; i<4; ++i) { - result[i] = mat[12+i] - for(var j=0; j<3; ++j) { - result[i] += x[j]*mat[4*j+i] - } - } -} - -var FRUSTUM_PLANES = [ - [ 0, 0, 1, 0, 0], - [ 0, 0,-1, 1, 0], - [ 0,-1, 0, 1, 0], - [ 0, 1, 0, 1, 0], - [-1, 0, 0, 1, 0], - [ 1, 0, 0, 1, 0] -] - -function polygonArea(p) { - for(var i=0; i o0) { - closest |= 1< o0) { - closest |= 1< cubeVerts[i][1]) { - bottom = i - } - } - - //Find left/right neighbors of bottom vertex - var left = -1 - for(var i=0; i<3; ++i) { - var idx = bottom ^ (1< cubeVerts[right][0]) { - right = idx - } - } - - //Determine edge axis coordinates - var cubeEdges = CUBE_EDGES - cubeEdges[0] = cubeEdges[1] = cubeEdges[2] = 0 - cubeEdges[bits.log2(left^bottom)] = bottom&left - cubeEdges[bits.log2(bottom^right)] = bottom&right - var top = right ^ 7 - if(top === closest || top === farthest) { - top = left ^ 7 - cubeEdges[bits.log2(right^top)] = top&right - } else { - cubeEdges[bits.log2(left^top)] = top&left - } - - //Determine visible faces - var axis = CUBE_AXIS - var cutCorner = closest - for(var d=0; d<3; ++d) { - if(cutCorner & (1< HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]) -var textFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]) -exports.text = function(gl) { - return createShader(gl, textVert, textFrag, null, [ - {name: 'position', type: 'vec3'} - ]) -} - -var bgVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]) -var bgFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]) -exports.bg = function(gl) { - return createShader(gl, bgVert, bgFrag, null, [ - {name: 'position', type: 'vec3'}, - {name: 'normal', type: 'vec3'} - ]) -} +function Axes(gl) { + this.gl = gl -},{"gl-shader":148,"glslify":249}],101:[function(_dereq_,module,exports){ -(function (process){ -"use strict" - -module.exports = createTextSprites - -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var vectorizeText = _dereq_('vectorize-text') -var createShader = _dereq_('./shaders').text - -var globals = window || process.global || {} -var __TEXT_CACHE = globals.__TEXT_CACHE || {} -globals.__TEXT_CACHE = {} - -//Vertex buffer format for text is: -// -/// [x,y,z] = Spatial coordinate -// - -var VERTEX_SIZE = 3 -var VERTEX_STRIDE = VERTEX_SIZE * 4 - -function TextSprites( - gl, - shader, - buffer, - vao) { - this.gl = gl - this.shader = shader - this.buffer = buffer - this.vao = vao - this.tickOffset = - this.tickCount = - this.labelOffset = - this.labelCount = null -} - -var proto = TextSprites.prototype - -//Bind textures for rendering -var SHAPE = [0,0] -proto.bind = function(model, view, projection, pixelScale) { - this.vao.bind() - this.shader.bind() - var uniforms = this.shader.uniforms - uniforms.model = model - uniforms.view = view - uniforms.projection = projection - uniforms.pixelScale = pixelScale - SHAPE[0] = this.gl.drawingBufferWidth - SHAPE[1] = this.gl.drawingBufferHeight - this.shader.uniforms.resolution = SHAPE -} - -proto.unbind = function() { - this.vao.unbind() -} - -proto.update = function(bounds, labels, labelFont, ticks, tickFont) { - var gl = this.gl - var data = [] - - function addItem(t, text, font, size) { - var fontcache = __TEXT_CACHE[font] - if(!fontcache) { - fontcache = __TEXT_CACHE[font] = {} - } - var mesh = fontcache[text] - if(!mesh) { - mesh = fontcache[text] = tryVectorizeText(text, { - triangles: true, - font: font, - textAlign: 'center', - textBaseline: 'middle' - }) - } - var scale = (size || 12) / 12 - var positions = mesh.positions - var cells = mesh.cells - var lo = [ Infinity, Infinity] - var hi = [-Infinity,-Infinity] - for(var i=0, nc=cells.length; i=0; --j) { - var p = positions[c[j]] - data.push(scale*p[0], -scale*p[1], t) - } - } - } - - //Generate sprites for all 3 axes, store data in texture atlases - var tickOffset = [0,0,0] - var tickCount = [0,0,0] - var labelOffset = [0,0,0] - var labelCount = [0,0,0] - for(var d=0; d<3; ++d) { - - //Generate label - labelOffset[d] = (data.length/VERTEX_SIZE)|0 - addItem(0.5*(bounds[0][d]+bounds[1][d]), labels[d], labelFont) - labelCount[d] = ((data.length/VERTEX_SIZE)|0) - labelOffset[d] - - //Generate sprites for tick marks - tickOffset[d] = (data.length/VERTEX_SIZE)|0 - for(var i=0; i= 0) { - sigFigs = stepStr.length - u - 1 - } - var shift = Math.pow(10, sigFigs) - var x = Math.round(spacing * i * shift) - var xstr = x + "" - if(xstr.indexOf("e") >= 0) { - return xstr - } - var xi = x / shift, xf = x % shift - if(x < 0) { - xi = -Math.ceil(xi)|0 - xf = (-xf)|0 - } else { - xi = Math.floor(xi)|0 - xf = xf|0 - } - var xis = "" + xi - if(x < 0) { - xis = "-" + xis - } - if(sigFigs) { - var xs = "" + xf - while(xs.length < sigFigs) { - xs = "0" + xs - } - return xis + "." + xs - } else { - return xis - } -} - -function defaultTicks(bounds, tickSpacing) { - var array = [] - for(var d=0; d<3; ++d) { - var ticks = [] - var m = 0.5*(bounds[0][d]+bounds[1][d]) - for(var t=0; t*tickSpacing[d]<=bounds[1][d]; ++t) { - ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) - } - for(var t=-1; t*tickSpacing[d]>=bounds[0][d]; --t) { - ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) - } - array.push(ticks) - } - return array -} - -function ticksEqual(ticksA, ticksB) { - for(var i=0; i<3; ++i) { - if(ticksA[i].length !== ticksB[i].length) { - return false - } - for(var j=0; j len) { - throw new Error("gl-buffer: If resizing buffer, must not specify offset") +var proto = Axes.prototype + +proto.update = function(options) { + options = options || {} + + //Option parsing helper functions + function parseOption(nest, cons, name) { + if(name in options) { + var opt = options[name] + var prev = this[name] + var next + if(nest ? (Array.isArray(opt) && Array.isArray(opt[0])) : + Array.isArray(opt) ) { + this[name] = next = [ cons(opt[0]), cons(opt[1]), cons(opt[2]) ] + } else { + this[name] = next = [ cons(opt), cons(opt), cons(opt) ] + } + for(var i=0; i<3; ++i) { + if(next[i] !== prev[i]) { + return true + } + } + } + return false } - gl.bufferSubData(type, offset, data) - return len -} -function makeScratchTypeArray(array, dtype) { - var res = pool.malloc(array.length, dtype) - var n = array.length - for(var i=0; i=0; --i) { - if(stride[i] !== n) { - return false +function OffsetInfo() { + this.primalOffset = [0,0,0] + this.primalMinor = [0,0,0] + this.mirrorOffset = [0,0,0] + this.mirrorMinor = [0,0,0] +} + +var LINE_OFFSET = [ new OffsetInfo(), new OffsetInfo(), new OffsetInfo() ] + +function computeLineOffset(result, i, bounds, cubeEdges, cubeAxis) { + var primalOffset = result.primalOffset + var primalMinor = result.primalMinor + var dualOffset = result.mirrorOffset + var dualMinor = result.mirrorMinor + var e = cubeEdges[i] + + //Calculate offsets + for(var j=0; j<3; ++j) { + if(i === j) { + continue + } + var a = primalOffset, + b = dualOffset, + c = primalMinor, + d = dualMinor + if(e & (1< 0) { + c[j] = -1 + d[j] = 0 + } else { + c[j] = 0 + d[j] = +1 } - n *= shape[i] } +} + +var CUBE_ENABLE = [0,0,0] +var DEFAULT_PARAMS = { + model: identity, + view: identity, + projection: identity +} + +proto.isOpaque = function() { return true } -proto.update = function(array, offset) { - if(typeof offset !== "number") { - offset = -1 +proto.isTransparent = function() { + return false +} + +proto.drawTransparent = function(params) {} + +var ALIGN_OPTION_AUTO = 0 // i.e. as defined in the shader the text would rotate to stay upwards range: [-90,90] + +var PRIMAL_MINOR = [0,0,0] +var MIRROR_MINOR = [0,0,0] +var PRIMAL_OFFSET = [0,0,0] + +proto.draw = function(params) { + params = params || DEFAULT_PARAMS + + var gl = this.gl + + //Geometry for camera and axes + var model = params.model || identity + var view = params.view || identity + var projection = params.projection || identity + var bounds = this.bounds + + //Unpack axis info + var cubeParams = getCubeProperties(model, view, projection, bounds) + var cubeEdges = cubeParams.cubeEdges + var cubeAxis = cubeParams.axis + + var cx = view[12] + var cy = view[13] + var cz = view[14] + var cw = view[15] + + var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight + + for(var i=0; i<3; ++i) { + this.lastCubeProps.cubeEdges[i] = cubeEdges[i] + this.lastCubeProps.axis[i] = cubeAxis[i] } - this.bind() - if(typeof array === "object" && typeof array.shape !== "undefined") { //ndarray - var dtype = array.dtype - if(SUPPORTED_TYPES.indexOf(dtype) < 0) { - dtype = "float32" + + //Compute axis info + var lineOffset = LINE_OFFSET + for(var i=0; i<3; ++i) { + computeLineOffset( + LINE_OFFSET[i], + i, + this.bounds, + cubeEdges, + cubeAxis) + } + + //Set up state parameters + var gl = this.gl + + //Draw background first + var cubeEnable = CUBE_ENABLE + for(var i=0; i<3; ++i) { + if(this.backgroundEnable[i]) { + cubeEnable[i] = cubeAxis[i] + } else { + cubeEnable[i] = 0 } - if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { - var ext = gl.getExtension('OES_element_index_uint') - if(ext && dtype !== "uint16") { - dtype = "uint32" - } else { - dtype = "uint16" + } + + this._background.draw( + model, + view, + projection, + bounds, + cubeEnable, + this.backgroundColor) + + //Draw lines + this._lines.bind( + model, + view, + projection, + this) + + //First draw grid lines and zero lines + for(var i=0; i<3; ++i) { + var x = [0,0,0] + if(cubeAxis[i] > 0) { + x[i] = bounds[1][i] + } else { + x[i] = bounds[0][i] + } + + //Draw grid lines + for(var j=0; j<2; ++j) { + var u = (i + 1 + j) % 3 + var v = (i + 1 + (j^1)) % 3 + if(this.gridEnable[u]) { + this._lines.drawGrid(u, v, this.bounds, x, this.gridColor[u], this.gridWidth[u]*this.pixelRatio) } } - if(dtype === array.dtype && isPacked(array.shape, array.stride)) { - if(array.offset === 0 && array.data.length === array.shape[0]) { - this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data, offset) - } else { - this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data.subarray(array.offset, array.shape[0]), offset) + + //Draw zero lines (need to do this AFTER all grid lines are drawn) + for(var j=0; j<2; ++j) { + var u = (i + 1 + j) % 3 + var v = (i + 1 + (j^1)) % 3 + if(this.zeroEnable[v]) { + //Check if zero line in bounds + if(Math.min(bounds[0][v], bounds[1][v]) <= 0 && Math.max(bounds[0][v], bounds[1][v]) >= 0) { + this._lines.drawZero(u, v, this.bounds, x, this.zeroLineColor[v], this.zeroLineWidth[v]*this.pixelRatio) + } } - } else { - var tmp = pool.malloc(array.size, dtype) - var ndt = ndarray(tmp, array.shape) - ops.assign(ndt, array) - if(offset < 0) { - this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp, offset) + } + } + + //Then draw axis lines and tick marks + for(var i=0; i<3; ++i) { + + //Draw axis lines + if(this.lineEnable[i]) { + this._lines.drawAxisLine(i, this.bounds, lineOffset[i].primalOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) + } + if(this.lineMirror[i]) { + this._lines.drawAxisLine(i, this.bounds, lineOffset[i].mirrorOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) + } + + //Compute minor axes + var primalMinor = copyVec3(PRIMAL_MINOR, lineOffset[i].primalMinor) + var mirrorMinor = copyVec3(MIRROR_MINOR, lineOffset[i].mirrorMinor) + var tickLength = this.lineTickLength + var op = 0 + for(var j=0; j<3; ++j) { + var scaleFactor = pixelScaleF / model[5*j] + primalMinor[j] *= tickLength[j] * scaleFactor + mirrorMinor[j] *= tickLength[j] * scaleFactor + } + + //Draw axis line ticks + if(this.lineTickEnable[i]) { + this._lines.drawAxisTicks(i, lineOffset[i].primalOffset, primalMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) + } + if(this.lineTickMirror[i]) { + this._lines.drawAxisTicks(i, lineOffset[i].mirrorOffset, mirrorMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) + } + } + this._lines.unbind() + + //Draw text sprites + this._text.bind( + model, + view, + projection, + this.pixelRatio) + + var alignOpt // options in shader are from this list {-1, 0, 1, 2, 3, ..., n} + // -1: backward compatible + // 0: raw data + // 1: auto align, free angles + // 2: auto align, horizontal or vertical + //3-n: auto align, round to n directions e.g. 12 -> round to angles with 30-degree steps + + var hv_ratio = 0.5 // can have an effect on the ratio between horizontals and verticals when using option 2 + + var enableAlign + var alignDir + + function alignTo(i) { + alignDir = [0,0,0] + alignDir[i] = 1 + } + + function solveTickAlignments(i, minor, major) { + + var i1 = (i + 1) % 3 + var i2 = (i + 2) % 3 + + var A = minor[i1] + var B = minor[i2] + var C = major[i1] + var D = major[i2] + + if ((A > 0) && (D > 0)) { alignTo(i1); return; } + else if ((A > 0) && (D < 0)) { alignTo(i1); return; } + else if ((A < 0) && (D > 0)) { alignTo(i1); return; } + else if ((A < 0) && (D < 0)) { alignTo(i1); return; } + else if ((B > 0) && (C > 0)) { alignTo(i2); return; } + else if ((B > 0) && (C < 0)) { alignTo(i2); return; } + else if ((B < 0) && (C > 0)) { alignTo(i2); return; } + else if ((B < 0) && (C < 0)) { alignTo(i2); return; } + } + + for(var i=0; i<3; ++i) { + + var minor = lineOffset[i].primalMinor + var major = lineOffset[i].mirrorMinor + + var offset = copyVec3(PRIMAL_OFFSET, lineOffset[i].primalOffset) + + for(var j=0; j<3; ++j) { + if(this.lineTickEnable[i]) { + offset[j] += pixelScaleF * minor[j] * Math.max(this.lineTickLength[j], 0) / model[5*j] + } + } + + var axis = [0,0,0] + axis[i] = 1 + + //Draw tick text + if(this.tickEnable[i]) { + + if(this.tickAngle[i] === -3600) { + this.tickAngle[i] = 0 + this._tickAlign[i] = 'auto' } else { - this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp.subarray(0, array.size), offset) + this._tickAlign[i] = -1 } - pool.free(tmp) + + enableAlign = 1; + + alignOpt = [this._tickAlign[i], hv_ratio, enableAlign] + if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO + else alignOpt[0] = parseInt('' + alignOpt[0]) + + alignDir = [0,0,0] + solveTickAlignments(i, minor, major) + + //Add tick padding + for(var j=0; j<3; ++j) { + offset[j] += pixelScaleF * minor[j] * this.tickPad[j] / model[5*j] + } + + //Draw axis + this._text.drawTicks( + i, + this.tickSize[i], + this.tickAngle[i], + offset, + this.tickColor[i], + axis, + alignDir, + alignOpt) } - } else if(Array.isArray(array)) { //Vanilla array - var t - if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { - t = makeScratchTypeArray(array, "uint16") - } else { - t = makeScratchTypeArray(array, "float32") + + //Draw labels + if(this.labelEnable[i]) { + + enableAlign = 0 + alignDir = [0,0,0] + if(this.labels[i].length > 4) { // for large label axis enable alignDir to axis + alignTo(i) + enableAlign = 1 + } + + alignOpt = [this.labelAlign[i], hv_ratio, enableAlign] + if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO + else alignOpt[0] = parseInt('' + alignOpt[0]) + + //Add label padding + for(var j=0; j<3; ++j) { + offset[j] += pixelScaleF * minor[j] * this.labelPad[j] / model[5*j] + } + offset[i] += 0.5 * (bounds[0][i] + bounds[1][i]) + + //Draw axis + this._text.drawLabel( + i, + this.labelSize[i], + this.labelAngle[i], + offset, + this.labelColor[i], + [0,0,0], + alignDir, + alignOpt) } - if(offset < 0) { - this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t, offset) - } else { - this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t.subarray(0, array.length), offset) + } + + this._text.unbind() +} + +proto.dispose = function() { + this._text.dispose() + this._lines.dispose() + this._background.dispose() + this._lines = null + this._text = null + this._background = null + this.gl = null +} + +function createAxes(gl, options) { + var axes = new Axes(gl) + axes.update(options) + return axes +} + +},{"./lib/background.js":97,"./lib/cube.js":98,"./lib/lines.js":99,"./lib/text.js":101,"./lib/ticks.js":102}],97:[function(_dereq_,module,exports){ +'use strict' + +module.exports = createBackgroundCube + +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createShader = _dereq_('./shaders').bg + +function BackgroundCube(gl, buffer, vao, shader) { + this.gl = gl + this.buffer = buffer + this.vao = vao + this.shader = shader +} + +var proto = BackgroundCube.prototype + +proto.draw = function(model, view, projection, bounds, enable, colors) { + var needsBG = false + for(var i=0; i<3; ++i) { + needsBG = needsBG || enable[i] + } + if(!needsBG) { + return + } + + var gl = this.gl + + gl.enable(gl.POLYGON_OFFSET_FILL) + gl.polygonOffset(1, 2) + + this.shader.bind() + this.shader.uniforms = { + model: model, + view: view, + projection: projection, + bounds: bounds, + enable: enable, + colors: colors + } + this.vao.bind() + this.vao.draw(this.gl.TRIANGLES, 36) + this.vao.unbind() + + gl.disable(gl.POLYGON_OFFSET_FILL) +} + +proto.dispose = function() { + this.vao.dispose() + this.buffer.dispose() + this.shader.dispose() +} + +function createBackgroundCube(gl) { + //Create cube vertices + var vertices = [] + var indices = [] + var ptr = 0 + for(var d=0; d<3; ++d) { + var u = (d+1) % 3 + var v = (d+2) % 3 + var x = [0,0,0] + var c = [0,0,0] + for(var s=-1; s<=1; s+=2) { + indices.push(ptr, ptr+2, ptr+1, + ptr+1, ptr+2, ptr+3) + x[d] = s + c[d] = s + for(var i=-1; i<=1; i+=2) { + x[u] = i + for(var j=-1; j<=1; j+=2) { + x[v] = j + vertices.push(x[0], x[1], x[2], + c[0], c[1], c[2]) + ptr += 1 + } + } + //Swap u and v + var tt = u + u = v + v = tt } - pool.free(t) - } else if(typeof array === "object" && typeof array.length === "number") { //Typed array - this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array, offset) - } else if(typeof array === "number" || array === undefined) { //Number/default - if(offset >= 0) { - throw new Error("gl-buffer: Cannot specify offset when resizing buffer") + } + + //Allocate buffer and vertex array + var buffer = createBuffer(gl, new Float32Array(vertices)) + var elements = createBuffer(gl, new Uint16Array(indices), gl.ELEMENT_ARRAY_BUFFER) + var vao = createVAO(gl, [ + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 0, + stride: 24 + }, + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 12, + stride: 24 + } + ], elements) + + //Create shader object + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.normal.location = 1 + + return new BackgroundCube(gl, buffer, vao, shader) +} + +},{"./shaders":100,"gl-buffer":104,"gl-vao":167}],98:[function(_dereq_,module,exports){ +"use strict" + +module.exports = getCubeEdges + +var bits = _dereq_('bit-twiddle') +var multiply = _dereq_('gl-mat4/multiply') +var splitPoly = _dereq_('split-polygon') +var orient = _dereq_('robust-orientation') + +var mvp = new Array(16) +var pCubeVerts = new Array(8) +var cubeVerts = new Array(8) +var x = new Array(3) +var zero3 = [0,0,0] + +;(function() { + for(var i=0; i<8; ++i) { + pCubeVerts[i] =[1,1,1,1] + cubeVerts[i] = [1,1,1] + } +})() + + +function transformHg(result, x, mat) { + for(var i=0; i<4; ++i) { + result[i] = mat[12+i] + for(var j=0; j<3; ++j) { + result[i] += x[j]*mat[4*j+i] } - array = array | 0 - if(array <= 0) { - array = 1 + } +} + +var FRUSTUM_PLANES = [ + [ 0, 0, 1, 0, 0], + [ 0, 0,-1, 1, 0], + [ 0,-1, 0, 1, 0], + [ 0, 1, 0, 1, 0], + [-1, 0, 0, 1, 0], + [ 1, 0, 0, 1, 0] +] + +function polygonArea(p) { + for(var i=0; i o0) { + closest |= 1< o0) { + closest |= 1< cubeVerts[i][1]) { + bottom = i + } + } + + //Find left/right neighbors of bottom vertex + var left = -1 + for(var i=0; i<3; ++i) { + var idx = bottom ^ (1< cubeVerts[right][0]) { + right = idx + } + } + + //Determine edge axis coordinates + var cubeEdges = CUBE_EDGES + cubeEdges[0] = cubeEdges[1] = cubeEdges[2] = 0 + cubeEdges[bits.log2(left^bottom)] = bottom&left + cubeEdges[bits.log2(bottom^right)] = bottom&right + var top = right ^ 7 + if(top === closest || top === farthest) { + top = left ^ 7 + cubeEdges[bits.log2(right^top)] = top&right + } else { + cubeEdges[bits.log2(left^top)] = top&left + } + + //Determine visible faces + var axis = CUBE_AXIS + var cutCorner = closest + for(var d=0; d<3; ++d) { + if(cutCorner & (1<= v) { - return i-1; - } - } - return i; -}; - -var tmp = V.create(); -var tmp2 = V.create(); - -var clamp = function(v, min, max) { - return v < min ? min : (v > max ? max : v); -}; - -var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { - var x = point[0]; - var y = point[1]; - var z = point[2]; - - var w = meshgrid[0].length; - var h = meshgrid[1].length; - var d = meshgrid[2].length; - - // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). - // The nearest smaller value index for x is the index x0 such that - // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. - var x0 = findLastSmallerIndex(meshgrid[0], x); - var y0 = findLastSmallerIndex(meshgrid[1], y); - var z0 = findLastSmallerIndex(meshgrid[2], z); - - // Get the nearest larger meshgrid value indices. - // From the above "nearest smaller value", we know that - // meshgrid[0][x0] < x - // meshgrid[0][x0+1] >= x - var x1 = x0 + 1; - var y1 = y0 + 1; - var z1 = z0 + 1; - - if (clampOverflow) { - x0 = clamp(x0, 0, w-1); - x1 = clamp(x1, 0, w-1); - y0 = clamp(y0, 0, h-1); - y1 = clamp(y1, 0, h-1); - z0 = clamp(z0, 0, d-1); - z1 = clamp(z1, 0, d-1); - } - - // Reject points outside the meshgrid, return a zero vector. - if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { - return V.create(); - } - - // Normalize point coordinates to 0..1 scaling factor between x0 and x1. - var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); - var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); - var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); - - if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; - if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; - if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; - - var z0off = z0*w*h; - var z1off = z1*w*h; - - var y0off = y0*w; - var y1off = y1*w; - - var x0off = x0; - var x1off = x1; - - // Sample data array around the (x,y,z) point. - // vZYX = array[zZoff + yYoff + xXoff] - var v000 = array[y0off + z0off + x0off]; - var v001 = array[y0off + z0off + x1off]; - var v010 = array[y1off + z0off + x0off]; - var v011 = array[y1off + z0off + x1off]; - var v100 = array[y0off + z1off + x0off]; - var v101 = array[y0off + z1off + x1off]; - var v110 = array[y1off + z1off + x0off]; - var v111 = array[y1off + z1off + x1off]; - - var result = V.create(); - - // Average samples according to distance to point. - V.lerp(result, v000, v001, xf); - V.lerp(tmp, v010, v011, xf); - V.lerp(result, result, tmp, yf); - V.lerp(tmp, v100, v101, xf); - V.lerp(tmp2, v110, v111, xf); - V.lerp(tmp, tmp, tmp2, yf); - V.lerp(result, result, tmp, zf); - - return result; -}; - -var getOrthogonalVector = function(dst, v) { - // Return up-vector for only-z vector. - if (v[0] === 0 && v[1] === 0) { - V.set(dst, 0, 1, 0); - } else { - // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0). - // From the above if-statement we have ||a|| > 0 U ||b|| > 0. - // Assign z = 0, x = -b, y = a: - // a*-b + b*a + c*0 = -ba + ba + 0 = 0 - V.set(dst, -v[1], v[0], 0); - } - return dst; -}; - -module.exports = function(vectorfield, bounds) { - var positions; - if (vectorfield.positions) { - positions = vectorfield.positions; - } else { - positions = createPositionsForMeshgrid(vectorfield.meshgrid); - } - var meshgrid = vectorfield.meshgrid; - var vectors = vectorfield.vectors; - var geo = { - positions: [], - vertexIntensity: [], - vertexIntensityBounds: vectorfield.vertexIntensityBounds, - vertexNormals: [], - vectors: [], - cells: [], - coneOffset: vectorfield.coneOffset, - colormap: vectorfield.colormap - }; - - if (vectorfield.positions.length === 0) { - if (bounds) { - bounds[0] = [0,0,0]; - bounds[1] = [0,0,0]; - } - return geo; - } - - // Compute bounding box for the dataset. - // Compute maximum velocity for the dataset to use for scaling the cones. - var maxNorm = 0; - var minX = 1/0, maxX = -1/0; - var minY = 1/0, maxY = -1/0; - var minZ = 1/0, maxZ = -1/0; - var p2 = null; - var u2 = null; - var positionVectors = []; - var vectorScale = 1/0; - for (var i = 0; i < positions.length; i++) { - var p = positions[i]; - minX = Math.min(p[0], minX); - maxX = Math.max(p[0], maxX); - minY = Math.min(p[1], minY); - maxY = Math.max(p[1], maxY); - minZ = Math.min(p[2], minZ); - maxZ = Math.max(p[2], maxZ); - var u; - if (meshgrid) { - u = sampleMeshgrid(p, vectors, meshgrid, true); - } else { - u = vectors[i]; - } - if (V.length(u) > maxNorm) { - maxNorm = V.length(u); - } - if (i) { - // Find vector scale [w/ units of time] using "successive" positions - // (not "adjacent" with would be O(n^2)), - // - // The vector scale corresponds to the minimum "time" to travel across two - // two adjacent positions at the average velocity of those two adjacent positions - vectorScale = Math.min(vectorScale, - 2 * V.distance(p2, p) / (V.length(u2) + V.length(u)) - ); - } - p2 = p; - u2 = u; - positionVectors.push(u); - } - var minV = [minX, minY, minZ]; - var maxV = [maxX, maxY, maxZ]; - if (bounds) { - bounds[0] = minV; - bounds[1] = maxV; - } - if (maxNorm === 0) { - maxNorm = 1; - } - - // Inverted max norm would map vector with norm maxNorm to 1 coord space units in length - var invertedMaxNorm = 1 / maxNorm; - - if (!isFinite(vectorScale) || isNaN(vectorScale)) { - vectorScale = 1.0; - } - geo.vectorScale = vectorScale; - - var nml = vec3(0,1,0); - - var coneScale = vectorfield.coneSize || 0.5; - - if (vectorfield.absoluteConeSize) { - coneScale = vectorfield.absoluteConeSize * invertedMaxNorm; - } - - geo.coneScale = coneScale; - - // Build the cone model. - for (var i = 0, j = 0; i < positions.length; i++) { - var p = positions[i]; - var x = p[0], y = p[1], z = p[2]; - var d = positionVectors[i]; - var intensity = V.length(d) * invertedMaxNorm; - for (var k = 0, l = 8; k < l; k++) { - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - - geo.vertexIntensity.push(intensity, intensity, intensity); - geo.vertexIntensity.push(intensity, intensity, intensity); - - geo.vertexNormals.push(nml, nml, nml); - geo.vertexNormals.push(nml, nml, nml); - - var m = geo.positions.length; - geo.cells.push([m-6, m-5, m-4], [m-3, m-2, m-1]); - } - } - - return geo; -}; - -module.exports.createConeMesh = _dereq_('./lib/conemesh'); +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createShader = _dereq_('./shaders').line -},{"./lib/conemesh":107,"gl-vec3":186,"gl-vec4":222}],106:[function(_dereq_,module,exports){ -'use strict' - -var barycentric = _dereq_('barycentric') -var closestPointToTriangle = _dereq_('polytope-closest-point/lib/closest_point_2d.js') - -module.exports = closestPointToPickLocation - -function xformMatrix(m, v) { - var out = [0,0,0,0] - for(var i=0; i<4; ++i) { - for(var j=0; j<4; ++j) { - out[j] += m[4*i + j] * v[i] - } - } - return out -} - -function projectVertex(v, model, view, projection, resolution) { - var p = xformMatrix(projection, - xformMatrix(view, - xformMatrix(model, [v[0], v[1], v[2], 1]))) - for(var i=0; i<3; ++i) { - p[i] /= p[3] - } - return [ 0.5 * resolution[0] * (1.0+p[0]), 0.5 * resolution[1] * (1.0-p[1]) ] -} - -function barycentricCoord(simplex, point) { - if(simplex.length === 2) { - var d0 = 0.0 - var d1 = 0.0 - for(var i=0; i<2; ++i) { - d0 += Math.pow(point[i] - simplex[0][i], 2) - d1 += Math.pow(point[i] - simplex[1][i], 2) - } - d0 = Math.sqrt(d0) - d1 = Math.sqrt(d1) - if(d0+d1 < 1e-6) { - return [1,0] - } - return [d1/(d0+d1),d0/(d1+d0)] - } else if(simplex.length === 3) { - var closestPoint = [0,0] - closestPointToTriangle(simplex[0], simplex[1], simplex[2], point, closestPoint) - return barycentric(simplex, closestPoint) - } - return [] -} - -function interpolate(simplex, weights) { - var result = [0,0,0] - for(var i=0; i 1.0001) { - return null - } - s += weights[i] - } - if(Math.abs(s - 1.0) > 0.001) { - return null - } - return [closestIndex, interpolate(simplex, weights), weights] +var MAJOR_AXIS = [0,0,0] +var MINOR_AXIS = [0,0,0] +var SCREEN_AXIS = [0,0,0] +var OFFSET_VEC = [0,0,0] +var SHAPE = [1,1] + +function zeroVec(a) { + a[0] = a[1] = a[2] = 0 + return a } -},{"barycentric":18,"polytope-closest-point/lib/closest_point_2d.js":306}],107:[function(_dereq_,module,exports){ -'use strict' - -var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small -var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var normals = _dereq_('normals') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var ndarray = _dereq_('ndarray') -var colormap = _dereq_('colormap') -var getContour = _dereq_('simplicial-complex-contour') -var pool = _dereq_('typedarray-pool') -var shaders = _dereq_('./shaders') -var closestPoint = _dereq_('./closest-point') - -var meshShader = shaders.meshShader -var pickShader = shaders.pickShader - -var identityMatrix = [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - -function SimplicialMesh(gl - , texture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) { - - this.gl = gl - this.cells = [] - this.positions = [] - this.intensity = [] - this.texture = texture - this.dirty = true - - this.triShader = triShader - this.lineShader = lineShader - this.pointShader = pointShader - this.pickShader = pickShader - this.pointPickShader = pointPickShader - this.contourShader = contourShader - - this.trianglePositions = trianglePositions - this.triangleVectors = triangleVectors - this.triangleColors = triangleColors - this.triangleNormals = triangleNormals - this.triangleUVs = triangleUVs - this.triangleIds = triangleIds - this.triangleVAO = triangleVAO - this.triangleCount = 0 - - this.lineWidth = 1 - this.edgePositions = edgePositions - this.edgeColors = edgeColors - this.edgeUVs = edgeUVs - this.edgeIds = edgeIds - this.edgeVAO = edgeVAO - this.edgeCount = 0 - - this.pointPositions = pointPositions - this.pointColors = pointColors - this.pointUVs = pointUVs - this.pointSizes = pointSizes - this.pointIds = pointIds - this.pointVAO = pointVAO - this.pointCount = 0 - - this.contourLineWidth = 1 - this.contourPositions = contourPositions - this.contourVAO = contourVAO - this.contourCount = 0 - this.contourColor = [0,0,0] - this.contourEnable = true - - this.pickId = 1 - this.bounds = [ - [ Infinity, Infinity, Infinity], - [-Infinity,-Infinity,-Infinity] ] - this.clipBounds = [ - [-Infinity,-Infinity,-Infinity], - [ Infinity, Infinity, Infinity] ] - - this.lightPosition = [1e5, 1e5, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - - this.opacity = 1.0 - - this.coneScale = 2.0 - this.vectorScale = 1.0 - this.coneOffset = 1.0 / 4.0; - - this._model = identityMatrix - this._view = identityMatrix - this._projection = identityMatrix - this._resolution = [1,1] -} - -var proto = SimplicialMesh.prototype - -proto.isOpaque = function() { - return this.opacity >= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.pickSlots = 1 - -proto.setPickBase = function(id) { - this.pickId = id -} - -function genColormap(param) { - var colors = colormap({ - colormap: param - , nshades: 256 - , format: 'rgba' - }) - - var result = new Uint8Array(256*4) - for(var i=0; i<256; ++i) { - var c = colors[i] - for(var j=0; j<3; ++j) { - result[4*i+j] = c[j] - } - result[4*i+3] = c[3]*255 - } - - return ndarray(result, [256,256,4], [4,0,1]) -} - -function unpackIntensity(cells, numVerts, cellIntensity) { - var result = new Array(numVerts) - for(var i=0; i 0) { - var shader = this.triShader - shader.bind() - shader.uniforms = uniforms - - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0 && this.lineWidth > 0) { - var shader = this.lineShader - shader.bind() - shader.uniforms = uniforms - - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } - - if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { - var shader = this.contourShader - shader.bind() - shader.uniforms = uniforms - - this.contourVAO.bind() - gl.drawArrays(gl.LINES, 0, this.contourCount) - this.contourVAO.unbind() - } -} - -proto.drawPick = function(params) { - params = params || {} - - var gl = this.gl - - var model = params.model || identityMatrix - var view = params.view || identityMatrix - var projection = params.projection || identityMatrix - - var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] - for(var i=0; i<3; ++i) { - clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) - clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) - } - - //Save camera parameters - this._model = [].slice.call(model) - this._view = [].slice.call(view) - this._projection = [].slice.call(projection) - this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - - var uniforms = { - model: model, - view: view, - projection: projection, - clipBounds: clipBounds, - - vectorScale: this.vectorScale, - coneScale: this.coneScale, - coneOffset: this.coneOffset, - - pickId: this.pickId / 255.0, - } - - var shader = this.pickShader - shader.bind() - shader.uniforms = uniforms - - if(this.triangleCount > 0) { - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0) { - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointPickShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } -} - - -proto.pick = function(pickData) { - if(!pickData) { - return null - } - if(pickData.id !== this.pickId) { - return null - } - - var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] - var cell = this.cells[cellId] - var pos = this.positions[cell[1]].slice(0, 3) - - return { - // corresponding to input indices - index: Math.floor(cell[1] / 48), - position: pos, - dataCoordinate: pos - } -} - - -proto.dispose = function() { - this.texture.dispose() - - this.triShader.dispose() - // this.lineShader.dispose() - // this.pointShader.dispose() - this.pickShader.dispose() - // this.pointPickShader.dispose() - - this.triangleVAO.dispose() - this.trianglePositions.dispose() - this.triangleVectors.dispose() - this.triangleColors.dispose() - this.triangleUVs.dispose() - this.triangleNormals.dispose() - this.triangleIds.dispose() - - this.edgeVAO.dispose() - this.edgePositions.dispose() - this.edgeColors.dispose() - this.edgeUVs.dispose() - this.edgeIds.dispose() - - this.pointVAO.dispose() - this.pointPositions.dispose() - this.pointColors.dispose() - this.pointUVs.dispose() - this.pointSizes.dispose() - this.pointIds.dispose() - - this.contourVAO.dispose() - this.contourPositions.dispose() - // this.contourShader.dispose() -} - -function createMeshShader(gl) { - // need to pass meshShader attributes manually, - // to make this work on etpinard's Ubuntu Thinkpad - var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.vector.location = 5 - return shader -} - -function createWireShader(gl) { - var shader = createShader(gl, wireShader.vertex, wireShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - return shader -} - -function createPointShader(gl) { - var shader = createShader(gl, pointShader.vertex, pointShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.pointSize.location = 4 - return shader -} - -function createPickShader(gl) { - var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.vector.location = 5 - return shader -} - -function createPointPickShader(gl) { - var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.pointSize.location = 4 - return shader -} - -function createContourShader(gl) { - var shader = createShader(gl, contourShader.vertex, contourShader.fragment) - shader.attributes.position.location = 0 - return shader -} - -function createSimplicialMesh(gl, params) { - if (arguments.length === 1) { - params = gl; - gl = params.gl; - } - - var triShader = params.triShader || createMeshShader(gl) - var lineShader = null; //createWireShader(gl) - var pointShader = null; //createPointShader(gl) - var pickShader = createPickShader(gl) - var pointPickShader = null; //createPointPickShader(gl) - var contourShader = null; //createContourShader(gl) - - var meshTexture = createTexture(gl, - ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) - meshTexture.generateMipmap() - meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR - meshTexture.magFilter = gl.LINEAR - - var trianglePositions = createBuffer(gl) - var triangleVectors = createBuffer(gl) - var triangleColors = createBuffer(gl) - var triangleUVs = createBuffer(gl) - var triangleNormals = createBuffer(gl) - var triangleIds = createBuffer(gl) - var triangleVAO = createVAO(gl, [ - { buffer: trianglePositions, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: triangleColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: triangleNormals, - type: gl.FLOAT, - size: 3 - }, - { buffer: triangleVectors, - type: gl.FLOAT, - size: 3 - } - ]) - - var edgePositions = createBuffer(gl) - var edgeColors = createBuffer(gl) - var edgeUVs = createBuffer(gl) - var edgeIds = createBuffer(gl) - var edgeVAO = createVAO(gl, [ - { buffer: edgePositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: edgeIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: edgeColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: edgeUVs, - type: gl.FLOAT, - size: 2 - } - ]) - - var pointPositions = createBuffer(gl) - var pointColors = createBuffer(gl) - var pointUVs = createBuffer(gl) - var pointSizes = createBuffer(gl) - var pointIds = createBuffer(gl) - var pointVAO = createVAO(gl, [ - { buffer: pointPositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: pointIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: pointColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: pointUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: pointSizes, - type: gl.FLOAT, - size: 1 - } - ]) - - var contourPositions = createBuffer(gl) - var contourVAO = createVAO(gl, [ - { buffer: contourPositions, - type: gl.FLOAT, - size: 3 - }]) - - var mesh = new SimplicialMesh(gl - , meshTexture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) - - mesh.update(params) - - return mesh -} - -module.exports = createSimplicialMesh -},{"./closest-point":106,"./shaders":108,"colormap":69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-shader":148,"gl-texture2d":163,"gl-vao":167,"ndarray":285,"normals":287,"simplicial-complex-contour":329,"typedarray-pool":348}],108:[function(_dereq_,module,exports){ -var glslify = _dereq_('glslify') - -var triVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]) -var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) -var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) - -exports.meshShader = { - vertex: triVertSrc, - fragment: triFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'normal', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'}, - {name: 'vector', type: 'vec3'} - ] -} -exports.pickShader = { - vertex: pickVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'id', type: 'vec4'}, - {name: 'vector', type: 'vec3'} - ] -} +function copyVec(a,b) { + a[0] = b[0] + a[1] = b[1] + a[2] = b[2] + return a +} + +function Lines(gl, vertBuffer, vao, shader, tickCount, tickOffset, gridCount, gridOffset) { + this.gl = gl + this.vertBuffer = vertBuffer + this.vao = vao + this.shader = shader + this.tickCount = tickCount + this.tickOffset = tickOffset + this.gridCount = gridCount + this.gridOffset = gridOffset +} + +var proto = Lines.prototype + +proto.bind = function(model, view, projection) { + this.shader.bind() + this.shader.uniforms.model = model + this.shader.uniforms.view = view + this.shader.uniforms.projection = projection + + SHAPE[0] = this.gl.drawingBufferWidth + SHAPE[1] = this.gl.drawingBufferHeight + + this.shader.uniforms.screenShape = SHAPE + this.vao.bind() +} + +proto.unbind = function() { + this.vao.unbind() +} + +proto.drawAxisLine = function(j, bounds, offset, color, lineWidth) { + var minorAxis = zeroVec(MINOR_AXIS) + this.shader.uniforms.majorAxis = MINOR_AXIS + + minorAxis[j] = bounds[1][j] - bounds[0][j] + this.shader.uniforms.minorAxis = minorAxis + + var noffset = copyVec(OFFSET_VEC, offset) + noffset[j] += bounds[0][j] + this.shader.uniforms.offset = noffset + + this.shader.uniforms.lineWidth = lineWidth + + this.shader.uniforms.color = color + + var screenAxis = zeroVec(SCREEN_AXIS) + screenAxis[(j+2)%3] = 1 + this.shader.uniforms.screenAxis = screenAxis + this.vao.draw(this.gl.TRIANGLES, 6) + + var screenAxis = zeroVec(SCREEN_AXIS) + screenAxis[(j+1)%3] = 1 + this.shader.uniforms.screenAxis = screenAxis + this.vao.draw(this.gl.TRIANGLES, 6) +} + +proto.drawAxisTicks = function(j, offset, minorAxis, color, lineWidth) { + if(!this.tickCount[j]) { + return + } + + var majorAxis = zeroVec(MAJOR_AXIS) + majorAxis[j] = 1 + this.shader.uniforms.majorAxis = majorAxis + this.shader.uniforms.offset = offset + this.shader.uniforms.minorAxis = minorAxis + this.shader.uniforms.color = color + this.shader.uniforms.lineWidth = lineWidth + + var screenAxis = zeroVec(SCREEN_AXIS) + screenAxis[j] = 1 + this.shader.uniforms.screenAxis = screenAxis + this.vao.draw(this.gl.TRIANGLES, this.tickCount[j], this.tickOffset[j]) +} + + +proto.drawGrid = function(i, j, bounds, offset, color, lineWidth) { + if(!this.gridCount[i]) { + return + } + + var minorAxis = zeroVec(MINOR_AXIS) + minorAxis[j] = bounds[1][j] - bounds[0][j] + this.shader.uniforms.minorAxis = minorAxis + + var noffset = copyVec(OFFSET_VEC, offset) + noffset[j] += bounds[0][j] + this.shader.uniforms.offset = noffset + + var majorAxis = zeroVec(MAJOR_AXIS) + majorAxis[i] = 1 + this.shader.uniforms.majorAxis = majorAxis + + var screenAxis = zeroVec(SCREEN_AXIS) + screenAxis[i] = 1 + this.shader.uniforms.screenAxis = screenAxis + this.shader.uniforms.lineWidth = lineWidth + + this.shader.uniforms.color = color + this.vao.draw(this.gl.TRIANGLES, this.gridCount[i], this.gridOffset[i]) +} + +proto.drawZero = function(j, i, bounds, offset, color, lineWidth) { + var minorAxis = zeroVec(MINOR_AXIS) + this.shader.uniforms.majorAxis = minorAxis + + minorAxis[j] = bounds[1][j] - bounds[0][j] + this.shader.uniforms.minorAxis = minorAxis + + var noffset = copyVec(OFFSET_VEC, offset) + noffset[j] += bounds[0][j] + this.shader.uniforms.offset = noffset + + var screenAxis = zeroVec(SCREEN_AXIS) + screenAxis[i] = 1 + this.shader.uniforms.screenAxis = screenAxis + this.shader.uniforms.lineWidth = lineWidth + + this.shader.uniforms.color = color + this.vao.draw(this.gl.TRIANGLES, 6) +} + +proto.dispose = function() { + this.vao.dispose() + this.vertBuffer.dispose() + this.shader.dispose() +} + +function createLines(gl, bounds, ticks) { + var vertices = [] + var tickOffset = [0,0,0] + var tickCount = [0,0,0] + + //Create grid lines for each axis/direction + var gridOffset = [0,0,0] + var gridCount = [0,0,0] + + //Add zero line + vertices.push( + 0,0,1, 0,1,1, 0,0,-1, + 0,0,-1, 0,1,1, 0,1,-1) + + for(var i=0; i<3; ++i) { + //Axis tick marks + var start = ((vertices.length / 3)|0) + for(var j=0; j HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]) +var textFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]) +exports.text = function(gl) { + return createShader(gl, textVert, textFrag, null, [ + {name: 'position', type: 'vec3'} + ]) +} + +var bgVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]) +var bgFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]) +exports.bg = function(gl) { + return createShader(gl, bgVert, bgFrag, null, [ + {name: 'position', type: 'vec3'}, + {name: 'normal', type: 'vec3'} + ]) +} + +},{"gl-shader":148,"glslify":249}],101:[function(_dereq_,module,exports){ +(function (process){ +"use strict" + +module.exports = createTextSprites + +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var vectorizeText = _dereq_('vectorize-text') +var createShader = _dereq_('./shaders').text + +var globals = window || process.global || {} +var __TEXT_CACHE = globals.__TEXT_CACHE || {} +globals.__TEXT_CACHE = {} + +//Vertex buffer format for text is: +// +/// [x,y,z] = Spatial coordinate +// + +var VERTEX_SIZE = 3 + +function TextSprites( + gl, + shader, + buffer, + vao) { + this.gl = gl + this.shader = shader + this.buffer = buffer + this.vao = vao + this.tickOffset = + this.tickCount = + this.labelOffset = + this.labelCount = null +} + +var proto = TextSprites.prototype + +//Bind textures for rendering +var SHAPE = [0,0] +proto.bind = function(model, view, projection, pixelScale) { + this.vao.bind() + this.shader.bind() + var uniforms = this.shader.uniforms + uniforms.model = model + uniforms.view = view + uniforms.projection = projection + uniforms.pixelScale = pixelScale + SHAPE[0] = this.gl.drawingBufferWidth + SHAPE[1] = this.gl.drawingBufferHeight + this.shader.uniforms.resolution = SHAPE +} + +proto.unbind = function() { + this.vao.unbind() +} + +proto.update = function(bounds, labels, labelFont, ticks, tickFont) { + var data = [] + + function addItem(t, text, font, size, lineSpacing, styletags) { + var fontcache = __TEXT_CACHE[font] + if(!fontcache) { + fontcache = __TEXT_CACHE[font] = {} + } + var mesh = fontcache[text] + if(!mesh) { + mesh = fontcache[text] = tryVectorizeText(text, { + triangles: true, + font: font, + textAlign: 'center', + textBaseline: 'middle', + lineSpacing: lineSpacing, + styletags: styletags + }) + } + var scale = (size || 12) / 12 + var positions = mesh.positions + var cells = mesh.cells + for(var i=0, nc=cells.length; i=0; --j) { + var p = positions[c[j]] + data.push(scale*p[0], -scale*p[1], t) + } + } + } + + //Generate sprites for all 3 axes, store data in texture atlases + var tickOffset = [0,0,0] + var tickCount = [0,0,0] + var labelOffset = [0,0,0] + var labelCount = [0,0,0] + var lineSpacing = 1.25 + var styletags = { + breaklines:true, + bolds: true, + italics: true, + subscripts:true, + superscripts:true + } + for(var d=0; d<3; ++d) { + + //Generate label + labelOffset[d] = (data.length/VERTEX_SIZE)|0 + addItem( + 0.5*(bounds[0][d]+bounds[1][d]), + labels[d], + labelFont[d], + 12, // labelFontSize + lineSpacing, + styletags + ) + labelCount[d] = ((data.length/VERTEX_SIZE)|0) - labelOffset[d] + + //Generate sprites for tick marks + tickOffset[d] = (data.length/VERTEX_SIZE)|0 + for(var i=0; i= 0) { + sigFigs = stepStr.length - u - 1 + } + var shift = Math.pow(10, sigFigs) + var x = Math.round(spacing * i * shift) + var xstr = x + "" + if(xstr.indexOf("e") >= 0) { + return xstr + } + var xi = x / shift, xf = x % shift + if(x < 0) { + xi = -Math.ceil(xi)|0 + xf = (-xf)|0 + } else { + xi = Math.floor(xi)|0 + xf = xf|0 + } + var xis = "" + xi + if(x < 0) { + xis = "-" + xis + } + if(sigFigs) { + var xs = "" + xf + while(xs.length < sigFigs) { + xs = "0" + xs + } + return xis + "." + xs + } else { + return xis + } +} + +function defaultTicks(bounds, tickSpacing) { + var array = [] + for(var d=0; d<3; ++d) { + var ticks = [] + var m = 0.5*(bounds[0][d]+bounds[1][d]) + for(var t=0; t*tickSpacing[d]<=bounds[1][d]; ++t) { + ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) + } + for(var t=-1; t*tickSpacing[d]>=bounds[0][d]; --t) { + ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) + } + array.push(ticks) + } + return array +} + +function ticksEqual(ticksA, ticksB) { + for(var i=0; i<3; ++i) { + if(ticksA[i].length !== ticksB[i].length) { + return false + } + for(var j=0; j len) { + throw new Error("gl-buffer: If resizing buffer, must not specify offset") + } + gl.bufferSubData(type, offset, data) + return len +} + +function makeScratchTypeArray(array, dtype) { + var res = pool.malloc(array.length, dtype) + var n = array.length + for(var i=0; i=0; --i) { + if(stride[i] !== n) { + return false + } + n *= shape[i] + } + return true +} + +proto.update = function(array, offset) { + if(typeof offset !== "number") { + offset = -1 + } + this.bind() + if(typeof array === "object" && typeof array.shape !== "undefined") { //ndarray + var dtype = array.dtype + if(SUPPORTED_TYPES.indexOf(dtype) < 0) { + dtype = "float32" + } + if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { + var ext = gl.getExtension('OES_element_index_uint') + if(ext && dtype !== "uint16") { + dtype = "uint32" + } else { + dtype = "uint16" + } + } + if(dtype === array.dtype && isPacked(array.shape, array.stride)) { + if(array.offset === 0 && array.data.length === array.shape[0]) { + this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data, offset) + } else { + this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data.subarray(array.offset, array.shape[0]), offset) + } + } else { + var tmp = pool.malloc(array.size, dtype) + var ndt = ndarray(tmp, array.shape) + ops.assign(ndt, array) + if(offset < 0) { + this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp, offset) + } else { + this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp.subarray(0, array.size), offset) + } + pool.free(tmp) + } + } else if(Array.isArray(array)) { //Vanilla array + var t + if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { + t = makeScratchTypeArray(array, "uint16") + } else { + t = makeScratchTypeArray(array, "float32") + } + if(offset < 0) { + this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t, offset) + } else { + this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t.subarray(0, array.length), offset) + } + pool.free(t) + } else if(typeof array === "object" && typeof array.length === "number") { //Typed array + this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array, offset) + } else if(typeof array === "number" || array === undefined) { //Number/default + if(offset >= 0) { + throw new Error("gl-buffer: Cannot specify offset when resizing buffer") + } + array = array | 0 + if(array <= 0) { + array = 1 + } + this.gl.bufferData(this.type, array|0, this.usage) + this.length = array + } else { //Error, case should not happen + throw new Error("gl-buffer: Invalid data type") + } +} + +function createBuffer(gl, data, type, usage) { + type = type || gl.ARRAY_BUFFER + usage = usage || gl.DYNAMIC_DRAW + if(type !== gl.ARRAY_BUFFER && type !== gl.ELEMENT_ARRAY_BUFFER) { + throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER") + } + if(usage !== gl.DYNAMIC_DRAW && usage !== gl.STATIC_DRAW && usage !== gl.STREAM_DRAW) { + throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW") + } + var handle = gl.createBuffer() + var result = new GLBuffer(gl, type, handle, 0, usage) + result.update(data) + return result +} + +module.exports = createBuffer + +},{"ndarray":285,"ndarray-ops":279,"typedarray-pool":347}],105:[function(_dereq_,module,exports){ +"use strict"; + +var V = _dereq_('gl-vec3'); +var V4 = _dereq_('gl-vec4'); + +var vec3 = function(x, y, z) { + var v = V.create(); + if (x !== undefined) { + V.set(v, x, y, z); + } + return v; +} + +var createPositionsForMeshgrid = function(meshgrid) { + var xs = meshgrid[0], ys = meshgrid[1], zs = meshgrid[2]; + var positions = []; + for (var z=0; z= v) { + return i-1; + } + } + return i; +}; + +var tmp = V.create(); +var tmp2 = V.create(); + +var clamp = function(v, min, max) { + return v < min ? min : (v > max ? max : v); +}; + +var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { + var x = point[0]; + var y = point[1]; + var z = point[2]; + + var w = meshgrid[0].length; + var h = meshgrid[1].length; + var d = meshgrid[2].length; + + // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). + // The nearest smaller value index for x is the index x0 such that + // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. + var x0 = findLastSmallerIndex(meshgrid[0], x); + var y0 = findLastSmallerIndex(meshgrid[1], y); + var z0 = findLastSmallerIndex(meshgrid[2], z); + + // Get the nearest larger meshgrid value indices. + // From the above "nearest smaller value", we know that + // meshgrid[0][x0] < x + // meshgrid[0][x0+1] >= x + var x1 = x0 + 1; + var y1 = y0 + 1; + var z1 = z0 + 1; + + if (clampOverflow) { + x0 = clamp(x0, 0, w-1); + x1 = clamp(x1, 0, w-1); + y0 = clamp(y0, 0, h-1); + y1 = clamp(y1, 0, h-1); + z0 = clamp(z0, 0, d-1); + z1 = clamp(z1, 0, d-1); + } + + // Reject points outside the meshgrid, return a zero vector. + if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { + return V.create(); + } + + // Normalize point coordinates to 0..1 scaling factor between x0 and x1. + var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); + var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); + var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); + + if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; + if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; + if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; + + var z0off = z0*w*h; + var z1off = z1*w*h; + + var y0off = y0*w; + var y1off = y1*w; + + var x0off = x0; + var x1off = x1; + + // Sample data array around the (x,y,z) point. + // vZYX = array[zZoff + yYoff + xXoff] + var v000 = array[y0off + z0off + x0off]; + var v001 = array[y0off + z0off + x1off]; + var v010 = array[y1off + z0off + x0off]; + var v011 = array[y1off + z0off + x1off]; + var v100 = array[y0off + z1off + x0off]; + var v101 = array[y0off + z1off + x1off]; + var v110 = array[y1off + z1off + x0off]; + var v111 = array[y1off + z1off + x1off]; + + var result = V.create(); + + // Average samples according to distance to point. + V.lerp(result, v000, v001, xf); + V.lerp(tmp, v010, v011, xf); + V.lerp(result, result, tmp, yf); + V.lerp(tmp, v100, v101, xf); + V.lerp(tmp2, v110, v111, xf); + V.lerp(tmp, tmp, tmp2, yf); + V.lerp(result, result, tmp, zf); + + return result; +}; + +var getOrthogonalVector = function(dst, v) { + // Return up-vector for only-z vector. + if (v[0] === 0 && v[1] === 0) { + V.set(dst, 0, 1, 0); + } else { + // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0). + // From the above if-statement we have ||a|| > 0 U ||b|| > 0. + // Assign z = 0, x = -b, y = a: + // a*-b + b*a + c*0 = -ba + ba + 0 = 0 + V.set(dst, -v[1], v[0], 0); + } + return dst; +}; + +module.exports = function(vectorfield, bounds) { + var positions; + if (vectorfield.positions) { + positions = vectorfield.positions; + } else { + positions = createPositionsForMeshgrid(vectorfield.meshgrid); + } + var meshgrid = vectorfield.meshgrid; + var vectors = vectorfield.vectors; + var geo = { + positions: [], + vertexIntensity: [], + vertexIntensityBounds: vectorfield.vertexIntensityBounds, + vertexNormals: [], + vectors: [], + cells: [], + coneOffset: vectorfield.coneOffset, + colormap: vectorfield.colormap + }; + + if (vectorfield.positions.length === 0) { + if (bounds) { + bounds[0] = [0,0,0]; + bounds[1] = [0,0,0]; + } + return geo; + } + + // Compute bounding box for the dataset. + // Compute maximum velocity for the dataset to use for scaling the cones. + var maxNorm = 0; + var minX = 1/0, maxX = -1/0; + var minY = 1/0, maxY = -1/0; + var minZ = 1/0, maxZ = -1/0; + var p2 = null; + var u2 = null; + var positionVectors = []; + var vectorScale = 1/0; + for (var i = 0; i < positions.length; i++) { + var p = positions[i]; + minX = Math.min(p[0], minX); + maxX = Math.max(p[0], maxX); + minY = Math.min(p[1], minY); + maxY = Math.max(p[1], maxY); + minZ = Math.min(p[2], minZ); + maxZ = Math.max(p[2], maxZ); + var u; + if (meshgrid) { + u = sampleMeshgrid(p, vectors, meshgrid, true); + } else { + u = vectors[i]; + } + if (V.length(u) > maxNorm) { + maxNorm = V.length(u); + } + if (i) { + // Find vector scale [w/ units of time] using "successive" positions + // (not "adjacent" with would be O(n^2)), + // + // The vector scale corresponds to the minimum "time" to travel across two + // two adjacent positions at the average velocity of those two adjacent positions + vectorScale = Math.min(vectorScale, + 2 * V.distance(p2, p) / (V.length(u2) + V.length(u)) + ); + } + p2 = p; + u2 = u; + positionVectors.push(u); + } + var minV = [minX, minY, minZ]; + var maxV = [maxX, maxY, maxZ]; + if (bounds) { + bounds[0] = minV; + bounds[1] = maxV; + } + if (maxNorm === 0) { + maxNorm = 1; + } + + // Inverted max norm would map vector with norm maxNorm to 1 coord space units in length + var invertedMaxNorm = 1 / maxNorm; + + if (!isFinite(vectorScale) || isNaN(vectorScale)) { + vectorScale = 1.0; + } + geo.vectorScale = vectorScale; + + var nml = vec3(0,1,0); + + var coneScale = vectorfield.coneSize || 0.5; + + if (vectorfield.absoluteConeSize) { + coneScale = vectorfield.absoluteConeSize * invertedMaxNorm; + } + + geo.coneScale = coneScale; + + // Build the cone model. + for (var i = 0, j = 0; i < positions.length; i++) { + var p = positions[i]; + var x = p[0], y = p[1], z = p[2]; + var d = positionVectors[i]; + var intensity = V.length(d) * invertedMaxNorm; + for (var k = 0, l = 8; k < l; k++) { + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + + geo.vertexIntensity.push(intensity, intensity, intensity); + geo.vertexIntensity.push(intensity, intensity, intensity); + + geo.vertexNormals.push(nml, nml, nml); + geo.vertexNormals.push(nml, nml, nml); + + var m = geo.positions.length; + geo.cells.push([m-6, m-5, m-4], [m-3, m-2, m-1]); + } + } + + return geo; +}; + +module.exports.createConeMesh = _dereq_('./lib/conemesh'); + +},{"./lib/conemesh":107,"gl-vec3":186,"gl-vec4":222}],106:[function(_dereq_,module,exports){ +'use strict' + +var barycentric = _dereq_('barycentric') +var closestPointToTriangle = _dereq_('polytope-closest-point/lib/closest_point_2d.js') + +module.exports = closestPointToPickLocation + +function xformMatrix(m, v) { + var out = [0,0,0,0] + for(var i=0; i<4; ++i) { + for(var j=0; j<4; ++j) { + out[j] += m[4*i + j] * v[i] + } + } + return out +} + +function projectVertex(v, model, view, projection, resolution) { + var p = xformMatrix(projection, + xformMatrix(view, + xformMatrix(model, [v[0], v[1], v[2], 1]))) + for(var i=0; i<3; ++i) { + p[i] /= p[3] + } + return [ 0.5 * resolution[0] * (1.0+p[0]), 0.5 * resolution[1] * (1.0-p[1]) ] +} + +function barycentricCoord(simplex, point) { + if(simplex.length === 2) { + var d0 = 0.0 + var d1 = 0.0 + for(var i=0; i<2; ++i) { + d0 += Math.pow(point[i] - simplex[0][i], 2) + d1 += Math.pow(point[i] - simplex[1][i], 2) + } + d0 = Math.sqrt(d0) + d1 = Math.sqrt(d1) + if(d0+d1 < 1e-6) { + return [1,0] + } + return [d1/(d0+d1),d0/(d1+d0)] + } else if(simplex.length === 3) { + var closestPoint = [0,0] + closestPointToTriangle(simplex[0], simplex[1], simplex[2], point, closestPoint) + return barycentric(simplex, closestPoint) + } + return [] +} + +function interpolate(simplex, weights) { + var result = [0,0,0] + for(var i=0; i 1.0001) { + return null + } + s += weights[i] + } + if(Math.abs(s - 1.0) > 0.001) { + return null + } + return [closestIndex, interpolate(simplex, weights), weights] +} +},{"barycentric":18,"polytope-closest-point/lib/closest_point_2d.js":306}],107:[function(_dereq_,module,exports){ +'use strict' + +var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small +var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; + +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var normals = _dereq_('normals') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var ndarray = _dereq_('ndarray') +var colormap = _dereq_('colormap') +var getContour = _dereq_('simplicial-complex-contour') +var pool = _dereq_('typedarray-pool') +var shaders = _dereq_('./shaders') +var closestPoint = _dereq_('./closest-point') + +var meshShader = shaders.meshShader +var pickShader = shaders.pickShader + +var identityMatrix = [ + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +function SimplicialMesh(gl + , texture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) { + + this.gl = gl + this.cells = [] + this.positions = [] + this.intensity = [] + this.texture = texture + this.dirty = true + + this.triShader = triShader + this.lineShader = lineShader + this.pointShader = pointShader + this.pickShader = pickShader + this.pointPickShader = pointPickShader + this.contourShader = contourShader + + this.trianglePositions = trianglePositions + this.triangleVectors = triangleVectors + this.triangleColors = triangleColors + this.triangleNormals = triangleNormals + this.triangleUVs = triangleUVs + this.triangleIds = triangleIds + this.triangleVAO = triangleVAO + this.triangleCount = 0 + + this.lineWidth = 1 + this.edgePositions = edgePositions + this.edgeColors = edgeColors + this.edgeUVs = edgeUVs + this.edgeIds = edgeIds + this.edgeVAO = edgeVAO + this.edgeCount = 0 + + this.pointPositions = pointPositions + this.pointColors = pointColors + this.pointUVs = pointUVs + this.pointSizes = pointSizes + this.pointIds = pointIds + this.pointVAO = pointVAO + this.pointCount = 0 + + this.contourLineWidth = 1 + this.contourPositions = contourPositions + this.contourVAO = contourVAO + this.contourCount = 0 + this.contourColor = [0,0,0] + this.contourEnable = true + + this.pickId = 1 + this.bounds = [ + [ Infinity, Infinity, Infinity], + [-Infinity,-Infinity,-Infinity] ] + this.clipBounds = [ + [-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity] ] + + this.lightPosition = [1e5, 1e5, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + + this.opacity = 1.0 + + this.coneScale = 2.0 + this.vectorScale = 1.0 + this.coneOffset = 1.0 / 4.0; + + this._model = identityMatrix + this._view = identityMatrix + this._projection = identityMatrix + this._resolution = [1,1] +} + +var proto = SimplicialMesh.prototype + +proto.isOpaque = function() { + return this.opacity >= 1 +} + +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.pickSlots = 1 + +proto.setPickBase = function(id) { + this.pickId = id +} + +function genColormap(param) { + var colors = colormap({ + colormap: param + , nshades: 256 + , format: 'rgba' + }) + + var result = new Uint8Array(256*4) + for(var i=0; i<256; ++i) { + var c = colors[i] + for(var j=0; j<3; ++j) { + result[4*i+j] = c[j] + } + result[4*i+3] = c[3]*255 + } + + return ndarray(result, [256,256,4], [4,0,1]) +} + +function unpackIntensity(cells, numVerts, cellIntensity) { + var result = new Array(numVerts) + for(var i=0; i 0) { + var shader = this.triShader + shader.bind() + shader.uniforms = uniforms + + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0 && this.lineWidth > 0) { + var shader = this.lineShader + shader.bind() + shader.uniforms = uniforms + + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } + + if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { + var shader = this.contourShader + shader.bind() + shader.uniforms = uniforms + + this.contourVAO.bind() + gl.drawArrays(gl.LINES, 0, this.contourCount) + this.contourVAO.unbind() + } +} + +proto.drawPick = function(params) { + params = params || {} + + var gl = this.gl + + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix + + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } + + //Save camera parameters + this._model = [].slice.call(model) + this._view = [].slice.call(view) + this._projection = [].slice.call(projection) + this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] + + var uniforms = { + model: model, + view: view, + projection: projection, + clipBounds: clipBounds, + + vectorScale: this.vectorScale, + coneScale: this.coneScale, + coneOffset: this.coneOffset, + + pickId: this.pickId / 255.0, + } + + var shader = this.pickShader + shader.bind() + shader.uniforms = uniforms + + if(this.triangleCount > 0) { + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0) { + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointPickShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } +} + + +proto.pick = function(pickData) { + if(!pickData) { + return null + } + if(pickData.id !== this.pickId) { + return null + } + + var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] + var cell = this.cells[cellId] + var pos = this.positions[cell[1]].slice(0, 3) + + return { + // corresponding to input indices + index: Math.floor(cell[1] / 48), + position: pos, + dataCoordinate: pos + } +} + + +proto.dispose = function() { + this.texture.dispose() + + this.triShader.dispose() + // this.lineShader.dispose() + // this.pointShader.dispose() + this.pickShader.dispose() + // this.pointPickShader.dispose() + + this.triangleVAO.dispose() + this.trianglePositions.dispose() + this.triangleVectors.dispose() + this.triangleColors.dispose() + this.triangleUVs.dispose() + this.triangleNormals.dispose() + this.triangleIds.dispose() + + this.edgeVAO.dispose() + this.edgePositions.dispose() + this.edgeColors.dispose() + this.edgeUVs.dispose() + this.edgeIds.dispose() + + this.pointVAO.dispose() + this.pointPositions.dispose() + this.pointColors.dispose() + this.pointUVs.dispose() + this.pointSizes.dispose() + this.pointIds.dispose() + + this.contourVAO.dispose() + this.contourPositions.dispose() + // this.contourShader.dispose() +} + +function createMeshShader(gl) { + // need to pass meshShader attributes manually, + // to make this work on etpinard's Ubuntu Thinkpad + var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.vector.location = 5 + return shader +} + +function createWireShader(gl) { + var shader = createShader(gl, wireShader.vertex, wireShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + return shader +} + +function createPointShader(gl) { + var shader = createShader(gl, pointShader.vertex, pointShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.pointSize.location = 4 + return shader +} + +function createPickShader(gl) { + var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.vector.location = 5 + return shader +} + +function createPointPickShader(gl) { + var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.pointSize.location = 4 + return shader +} + +function createContourShader(gl) { + var shader = createShader(gl, contourShader.vertex, contourShader.fragment) + shader.attributes.position.location = 0 + return shader +} + +function createSimplicialMesh(gl, params) { + if (arguments.length === 1) { + params = gl; + gl = params.gl; + } + + var triShader = params.triShader || createMeshShader(gl) + var lineShader = null; //createWireShader(gl) + var pointShader = null; //createPointShader(gl) + var pickShader = createPickShader(gl) + var pointPickShader = null; //createPointPickShader(gl) + var contourShader = null; //createContourShader(gl) + + var meshTexture = createTexture(gl, + ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) + meshTexture.generateMipmap() + meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR + meshTexture.magFilter = gl.LINEAR + + var trianglePositions = createBuffer(gl) + var triangleVectors = createBuffer(gl) + var triangleColors = createBuffer(gl) + var triangleUVs = createBuffer(gl) + var triangleNormals = createBuffer(gl) + var triangleIds = createBuffer(gl) + var triangleVAO = createVAO(gl, [ + { buffer: trianglePositions, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: triangleColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: triangleNormals, + type: gl.FLOAT, + size: 3 + }, + { buffer: triangleVectors, + type: gl.FLOAT, + size: 3 + } + ]) + + var edgePositions = createBuffer(gl) + var edgeColors = createBuffer(gl) + var edgeUVs = createBuffer(gl) + var edgeIds = createBuffer(gl) + var edgeVAO = createVAO(gl, [ + { buffer: edgePositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: edgeIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: edgeColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: edgeUVs, + type: gl.FLOAT, + size: 2 + } + ]) + + var pointPositions = createBuffer(gl) + var pointColors = createBuffer(gl) + var pointUVs = createBuffer(gl) + var pointSizes = createBuffer(gl) + var pointIds = createBuffer(gl) + var pointVAO = createVAO(gl, [ + { buffer: pointPositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: pointIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: pointColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: pointUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: pointSizes, + type: gl.FLOAT, + size: 1 + } + ]) + + var contourPositions = createBuffer(gl) + var contourVAO = createVAO(gl, [ + { buffer: contourPositions, + type: gl.FLOAT, + size: 3 + }]) + + var mesh = new SimplicialMesh(gl + , meshTexture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) + + mesh.update(params) + + return mesh +} + +module.exports = createSimplicialMesh + +},{"./closest-point":106,"./shaders":108,"colormap":69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-shader":148,"gl-texture2d":163,"gl-vao":167,"ndarray":285,"normals":287,"simplicial-complex-contour":329,"typedarray-pool":347}],108:[function(_dereq_,module,exports){ +var glslify = _dereq_('glslify') + +var triVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]) +var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) +var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) + +exports.meshShader = { + vertex: triVertSrc, + fragment: triFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'normal', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'}, + {name: 'vector', type: 'vec3'} + ] +} +exports.pickShader = { + vertex: pickVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'id', type: 'vec4'}, + {name: 'vector', type: 'vec3'} + ] +} + +},{"glslify":249}],109:[function(_dereq_,module,exports){ +module.exports = { + 0: 'NONE', + 1: 'ONE', + 2: 'LINE_LOOP', + 3: 'LINE_STRIP', + 4: 'TRIANGLES', + 5: 'TRIANGLE_STRIP', + 6: 'TRIANGLE_FAN', + 256: 'DEPTH_BUFFER_BIT', + 512: 'NEVER', + 513: 'LESS', + 514: 'EQUAL', + 515: 'LEQUAL', + 516: 'GREATER', + 517: 'NOTEQUAL', + 518: 'GEQUAL', + 519: 'ALWAYS', + 768: 'SRC_COLOR', + 769: 'ONE_MINUS_SRC_COLOR', + 770: 'SRC_ALPHA', + 771: 'ONE_MINUS_SRC_ALPHA', + 772: 'DST_ALPHA', + 773: 'ONE_MINUS_DST_ALPHA', + 774: 'DST_COLOR', + 775: 'ONE_MINUS_DST_COLOR', + 776: 'SRC_ALPHA_SATURATE', + 1024: 'STENCIL_BUFFER_BIT', + 1028: 'FRONT', + 1029: 'BACK', + 1032: 'FRONT_AND_BACK', + 1280: 'INVALID_ENUM', + 1281: 'INVALID_VALUE', + 1282: 'INVALID_OPERATION', + 1285: 'OUT_OF_MEMORY', + 1286: 'INVALID_FRAMEBUFFER_OPERATION', + 2304: 'CW', + 2305: 'CCW', + 2849: 'LINE_WIDTH', + 2884: 'CULL_FACE', + 2885: 'CULL_FACE_MODE', + 2886: 'FRONT_FACE', + 2928: 'DEPTH_RANGE', + 2929: 'DEPTH_TEST', + 2930: 'DEPTH_WRITEMASK', + 2931: 'DEPTH_CLEAR_VALUE', + 2932: 'DEPTH_FUNC', + 2960: 'STENCIL_TEST', + 2961: 'STENCIL_CLEAR_VALUE', + 2962: 'STENCIL_FUNC', + 2963: 'STENCIL_VALUE_MASK', + 2964: 'STENCIL_FAIL', + 2965: 'STENCIL_PASS_DEPTH_FAIL', + 2966: 'STENCIL_PASS_DEPTH_PASS', + 2967: 'STENCIL_REF', + 2968: 'STENCIL_WRITEMASK', + 2978: 'VIEWPORT', + 3024: 'DITHER', + 3042: 'BLEND', + 3088: 'SCISSOR_BOX', + 3089: 'SCISSOR_TEST', + 3106: 'COLOR_CLEAR_VALUE', + 3107: 'COLOR_WRITEMASK', + 3317: 'UNPACK_ALIGNMENT', + 3333: 'PACK_ALIGNMENT', + 3379: 'MAX_TEXTURE_SIZE', + 3386: 'MAX_VIEWPORT_DIMS', + 3408: 'SUBPIXEL_BITS', + 3410: 'RED_BITS', + 3411: 'GREEN_BITS', + 3412: 'BLUE_BITS', + 3413: 'ALPHA_BITS', + 3414: 'DEPTH_BITS', + 3415: 'STENCIL_BITS', + 3553: 'TEXTURE_2D', + 4352: 'DONT_CARE', + 4353: 'FASTEST', + 4354: 'NICEST', + 5120: 'BYTE', + 5121: 'UNSIGNED_BYTE', + 5122: 'SHORT', + 5123: 'UNSIGNED_SHORT', + 5124: 'INT', + 5125: 'UNSIGNED_INT', + 5126: 'FLOAT', + 5386: 'INVERT', + 5890: 'TEXTURE', + 6401: 'STENCIL_INDEX', + 6402: 'DEPTH_COMPONENT', + 6406: 'ALPHA', + 6407: 'RGB', + 6408: 'RGBA', + 6409: 'LUMINANCE', + 6410: 'LUMINANCE_ALPHA', + 7680: 'KEEP', + 7681: 'REPLACE', + 7682: 'INCR', + 7683: 'DECR', + 7936: 'VENDOR', + 7937: 'RENDERER', + 7938: 'VERSION', + 9728: 'NEAREST', + 9729: 'LINEAR', + 9984: 'NEAREST_MIPMAP_NEAREST', + 9985: 'LINEAR_MIPMAP_NEAREST', + 9986: 'NEAREST_MIPMAP_LINEAR', + 9987: 'LINEAR_MIPMAP_LINEAR', + 10240: 'TEXTURE_MAG_FILTER', + 10241: 'TEXTURE_MIN_FILTER', + 10242: 'TEXTURE_WRAP_S', + 10243: 'TEXTURE_WRAP_T', + 10497: 'REPEAT', + 10752: 'POLYGON_OFFSET_UNITS', + 16384: 'COLOR_BUFFER_BIT', + 32769: 'CONSTANT_COLOR', + 32770: 'ONE_MINUS_CONSTANT_COLOR', + 32771: 'CONSTANT_ALPHA', + 32772: 'ONE_MINUS_CONSTANT_ALPHA', + 32773: 'BLEND_COLOR', + 32774: 'FUNC_ADD', + 32777: 'BLEND_EQUATION_RGB', + 32778: 'FUNC_SUBTRACT', + 32779: 'FUNC_REVERSE_SUBTRACT', + 32819: 'UNSIGNED_SHORT_4_4_4_4', + 32820: 'UNSIGNED_SHORT_5_5_5_1', + 32823: 'POLYGON_OFFSET_FILL', + 32824: 'POLYGON_OFFSET_FACTOR', + 32854: 'RGBA4', + 32855: 'RGB5_A1', + 32873: 'TEXTURE_BINDING_2D', + 32926: 'SAMPLE_ALPHA_TO_COVERAGE', + 32928: 'SAMPLE_COVERAGE', + 32936: 'SAMPLE_BUFFERS', + 32937: 'SAMPLES', + 32938: 'SAMPLE_COVERAGE_VALUE', + 32939: 'SAMPLE_COVERAGE_INVERT', + 32968: 'BLEND_DST_RGB', + 32969: 'BLEND_SRC_RGB', + 32970: 'BLEND_DST_ALPHA', + 32971: 'BLEND_SRC_ALPHA', + 33071: 'CLAMP_TO_EDGE', + 33170: 'GENERATE_MIPMAP_HINT', + 33189: 'DEPTH_COMPONENT16', + 33306: 'DEPTH_STENCIL_ATTACHMENT', + 33635: 'UNSIGNED_SHORT_5_6_5', + 33648: 'MIRRORED_REPEAT', + 33901: 'ALIASED_POINT_SIZE_RANGE', + 33902: 'ALIASED_LINE_WIDTH_RANGE', + 33984: 'TEXTURE0', + 33985: 'TEXTURE1', + 33986: 'TEXTURE2', + 33987: 'TEXTURE3', + 33988: 'TEXTURE4', + 33989: 'TEXTURE5', + 33990: 'TEXTURE6', + 33991: 'TEXTURE7', + 33992: 'TEXTURE8', + 33993: 'TEXTURE9', + 33994: 'TEXTURE10', + 33995: 'TEXTURE11', + 33996: 'TEXTURE12', + 33997: 'TEXTURE13', + 33998: 'TEXTURE14', + 33999: 'TEXTURE15', + 34000: 'TEXTURE16', + 34001: 'TEXTURE17', + 34002: 'TEXTURE18', + 34003: 'TEXTURE19', + 34004: 'TEXTURE20', + 34005: 'TEXTURE21', + 34006: 'TEXTURE22', + 34007: 'TEXTURE23', + 34008: 'TEXTURE24', + 34009: 'TEXTURE25', + 34010: 'TEXTURE26', + 34011: 'TEXTURE27', + 34012: 'TEXTURE28', + 34013: 'TEXTURE29', + 34014: 'TEXTURE30', + 34015: 'TEXTURE31', + 34016: 'ACTIVE_TEXTURE', + 34024: 'MAX_RENDERBUFFER_SIZE', + 34041: 'DEPTH_STENCIL', + 34055: 'INCR_WRAP', + 34056: 'DECR_WRAP', + 34067: 'TEXTURE_CUBE_MAP', + 34068: 'TEXTURE_BINDING_CUBE_MAP', + 34069: 'TEXTURE_CUBE_MAP_POSITIVE_X', + 34070: 'TEXTURE_CUBE_MAP_NEGATIVE_X', + 34071: 'TEXTURE_CUBE_MAP_POSITIVE_Y', + 34072: 'TEXTURE_CUBE_MAP_NEGATIVE_Y', + 34073: 'TEXTURE_CUBE_MAP_POSITIVE_Z', + 34074: 'TEXTURE_CUBE_MAP_NEGATIVE_Z', + 34076: 'MAX_CUBE_MAP_TEXTURE_SIZE', + 34338: 'VERTEX_ATTRIB_ARRAY_ENABLED', + 34339: 'VERTEX_ATTRIB_ARRAY_SIZE', + 34340: 'VERTEX_ATTRIB_ARRAY_STRIDE', + 34341: 'VERTEX_ATTRIB_ARRAY_TYPE', + 34342: 'CURRENT_VERTEX_ATTRIB', + 34373: 'VERTEX_ATTRIB_ARRAY_POINTER', + 34466: 'NUM_COMPRESSED_TEXTURE_FORMATS', + 34467: 'COMPRESSED_TEXTURE_FORMATS', + 34660: 'BUFFER_SIZE', + 34661: 'BUFFER_USAGE', + 34816: 'STENCIL_BACK_FUNC', + 34817: 'STENCIL_BACK_FAIL', + 34818: 'STENCIL_BACK_PASS_DEPTH_FAIL', + 34819: 'STENCIL_BACK_PASS_DEPTH_PASS', + 34877: 'BLEND_EQUATION_ALPHA', + 34921: 'MAX_VERTEX_ATTRIBS', + 34922: 'VERTEX_ATTRIB_ARRAY_NORMALIZED', + 34930: 'MAX_TEXTURE_IMAGE_UNITS', + 34962: 'ARRAY_BUFFER', + 34963: 'ELEMENT_ARRAY_BUFFER', + 34964: 'ARRAY_BUFFER_BINDING', + 34965: 'ELEMENT_ARRAY_BUFFER_BINDING', + 34975: 'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING', + 35040: 'STREAM_DRAW', + 35044: 'STATIC_DRAW', + 35048: 'DYNAMIC_DRAW', + 35632: 'FRAGMENT_SHADER', + 35633: 'VERTEX_SHADER', + 35660: 'MAX_VERTEX_TEXTURE_IMAGE_UNITS', + 35661: 'MAX_COMBINED_TEXTURE_IMAGE_UNITS', + 35663: 'SHADER_TYPE', + 35664: 'FLOAT_VEC2', + 35665: 'FLOAT_VEC3', + 35666: 'FLOAT_VEC4', + 35667: 'INT_VEC2', + 35668: 'INT_VEC3', + 35669: 'INT_VEC4', + 35670: 'BOOL', + 35671: 'BOOL_VEC2', + 35672: 'BOOL_VEC3', + 35673: 'BOOL_VEC4', + 35674: 'FLOAT_MAT2', + 35675: 'FLOAT_MAT3', + 35676: 'FLOAT_MAT4', + 35678: 'SAMPLER_2D', + 35680: 'SAMPLER_CUBE', + 35712: 'DELETE_STATUS', + 35713: 'COMPILE_STATUS', + 35714: 'LINK_STATUS', + 35715: 'VALIDATE_STATUS', + 35716: 'INFO_LOG_LENGTH', + 35717: 'ATTACHED_SHADERS', + 35718: 'ACTIVE_UNIFORMS', + 35719: 'ACTIVE_UNIFORM_MAX_LENGTH', + 35720: 'SHADER_SOURCE_LENGTH', + 35721: 'ACTIVE_ATTRIBUTES', + 35722: 'ACTIVE_ATTRIBUTE_MAX_LENGTH', + 35724: 'SHADING_LANGUAGE_VERSION', + 35725: 'CURRENT_PROGRAM', + 36003: 'STENCIL_BACK_REF', + 36004: 'STENCIL_BACK_VALUE_MASK', + 36005: 'STENCIL_BACK_WRITEMASK', + 36006: 'FRAMEBUFFER_BINDING', + 36007: 'RENDERBUFFER_BINDING', + 36048: 'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', + 36049: 'FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', + 36050: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', + 36051: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', + 36053: 'FRAMEBUFFER_COMPLETE', + 36054: 'FRAMEBUFFER_INCOMPLETE_ATTACHMENT', + 36055: 'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT', + 36057: 'FRAMEBUFFER_INCOMPLETE_DIMENSIONS', + 36061: 'FRAMEBUFFER_UNSUPPORTED', + 36064: 'COLOR_ATTACHMENT0', + 36096: 'DEPTH_ATTACHMENT', + 36128: 'STENCIL_ATTACHMENT', + 36160: 'FRAMEBUFFER', + 36161: 'RENDERBUFFER', + 36162: 'RENDERBUFFER_WIDTH', + 36163: 'RENDERBUFFER_HEIGHT', + 36164: 'RENDERBUFFER_INTERNAL_FORMAT', + 36168: 'STENCIL_INDEX8', + 36176: 'RENDERBUFFER_RED_SIZE', + 36177: 'RENDERBUFFER_GREEN_SIZE', + 36178: 'RENDERBUFFER_BLUE_SIZE', + 36179: 'RENDERBUFFER_ALPHA_SIZE', + 36180: 'RENDERBUFFER_DEPTH_SIZE', + 36181: 'RENDERBUFFER_STENCIL_SIZE', + 36194: 'RGB565', + 36336: 'LOW_FLOAT', + 36337: 'MEDIUM_FLOAT', + 36338: 'HIGH_FLOAT', + 36339: 'LOW_INT', + 36340: 'MEDIUM_INT', + 36341: 'HIGH_INT', + 36346: 'SHADER_COMPILER', + 36347: 'MAX_VERTEX_UNIFORM_VECTORS', + 36348: 'MAX_VARYING_VECTORS', + 36349: 'MAX_FRAGMENT_UNIFORM_VECTORS', + 37440: 'UNPACK_FLIP_Y_WEBGL', + 37441: 'UNPACK_PREMULTIPLY_ALPHA_WEBGL', + 37442: 'CONTEXT_LOST_WEBGL', + 37443: 'UNPACK_COLORSPACE_CONVERSION_WEBGL', + 37444: 'BROWSER_DEFAULT_WEBGL' +} + +},{}],110:[function(_dereq_,module,exports){ +var gl10 = _dereq_('./1.0/numbers') + +module.exports = function lookupConstant (number) { + return gl10[number] +} + +},{"./1.0/numbers":109}],111:[function(_dereq_,module,exports){ +'use strict' + +module.exports = createErrorBars + +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createShader = _dereq_('./shaders/index') + +var IDENTITY = [1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +function ErrorBars(gl, buffer, vao, shader) { + this.gl = gl + this.shader = shader + this.buffer = buffer + this.vao = vao + this.pixelRatio = 1 + this.bounds = [[ Infinity, Infinity, Infinity], [-Infinity,-Infinity,-Infinity]] + this.clipBounds = [[-Infinity,-Infinity,-Infinity], [ Infinity, Infinity, Infinity]] + this.lineWidth = [1,1,1] + this.capSize = [10,10,10] + this.lineCount = [0,0,0] + this.lineOffset = [0,0,0] + this.opacity = 1 +} + +var proto = ErrorBars.prototype + +proto.isOpaque = function() { + return this.opacity >= 1 +} + +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.drawTransparent = proto.draw = function(cameraParams) { + var gl = this.gl + var uniforms = this.shader.uniforms + + this.shader.bind() + var view = uniforms.view = cameraParams.view || IDENTITY + var projection = uniforms.projection = cameraParams.projection || IDENTITY + uniforms.model = cameraParams.model || IDENTITY + uniforms.clipBounds = this.clipBounds + uniforms.opacity = this.opacity + + + var cx = view[12] + var cy = view[13] + var cz = view[14] + var cw = view[15] + var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight + + this.vao.bind() + for(var i=0; i<3; ++i) { + gl.lineWidth(this.lineWidth[i]) + uniforms.capSize = this.capSize[i] * pixelScaleF + if (this.lineCount[i]) { + gl.drawArrays(gl.LINES, this.lineOffset[i], this.lineCount[i]) + } + } + this.vao.unbind() +} + +function updateBounds(bounds, point) { + for(var i=0; i<3; ++i) { + bounds[0][i] = Math.min(bounds[0][i], point[i]) + bounds[1][i] = Math.max(bounds[1][i], point[i]) + } +} + +var FACE_TABLE = (function(){ + var table = new Array(3) + for(var d=0; d<3; ++d) { + var row = [] + for(var j=1; j<=2; ++j) { + for(var s=-1; s<=1; s+=2) { + var u = (j+d) % 3 + var y = [0,0,0] + y[u] = s + row.push(y) + } + } + table[d] = row + } + return table +})() + + +function emitFace(verts, x, c, d) { + var offsets = FACE_TABLE[d] + for(var i=0; i 0) { + var x = p.slice() + x[j] += e[1][j] + verts.push(p[0], p[1], p[2], + c[0], c[1], c[2], c[3], + 0, 0, 0, + x[0], x[1], x[2], + c[0], c[1], c[2], c[3], + 0, 0, 0) + updateBounds(this.bounds, x) + vertexCount += 2 + emitFace(verts, x, c, j) + } + } + this.lineCount[j] = vertexCount - this.lineOffset[j] + } + this.buffer.update(verts) + } +} + +proto.dispose = function() { + this.shader.dispose() + this.buffer.dispose() + this.vao.dispose() +} + +function createErrorBars(options) { + var gl = options.gl + var buffer = createBuffer(gl) + var vao = createVAO(gl, [ + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 0, + stride: 40 + }, + { + buffer: buffer, + type: gl.FLOAT, + size: 4, + offset: 12, + stride: 40 + }, + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 28, + stride: 40 + } + ]) + + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.color.location = 1 + shader.attributes.offset.location = 2 + + var result = new ErrorBars(gl, buffer, vao, shader) + result.update(options) + return result +} + +},{"./shaders/index":112,"gl-buffer":104,"gl-vao":167}],112:[function(_dereq_,module,exports){ +'use strict' + +var glslify = _dereq_('glslify') +var createShader = _dereq_('gl-shader') + +var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]) +var fragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]) + +module.exports = function(gl) { + return createShader(gl, vertSrc, fragSrc, null, [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'offset', type: 'vec3'} + ]) +} + +},{"gl-shader":148,"glslify":249}],113:[function(_dereq_,module,exports){ +'use strict' + +var createTexture = _dereq_('gl-texture2d') + +module.exports = createFBO + +var colorAttachmentArrays = null +var FRAMEBUFFER_UNSUPPORTED +var FRAMEBUFFER_INCOMPLETE_ATTACHMENT +var FRAMEBUFFER_INCOMPLETE_DIMENSIONS +var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT + +function saveFBOState(gl) { + var fbo = gl.getParameter(gl.FRAMEBUFFER_BINDING) + var rbo = gl.getParameter(gl.RENDERBUFFER_BINDING) + var tex = gl.getParameter(gl.TEXTURE_BINDING_2D) + return [fbo, rbo, tex] +} + +function restoreFBOState(gl, data) { + gl.bindFramebuffer(gl.FRAMEBUFFER, data[0]) + gl.bindRenderbuffer(gl.RENDERBUFFER, data[1]) + gl.bindTexture(gl.TEXTURE_2D, data[2]) +} + +function lazyInitColorAttachments(gl, ext) { + var maxColorAttachments = gl.getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL) + colorAttachmentArrays = new Array(maxColorAttachments + 1) + for(var i=0; i<=maxColorAttachments; ++i) { + var x = new Array(maxColorAttachments) + for(var j=0; j 1) { + ext.drawBuffersWEBGL(colorAttachmentArrays[numColors]) + } + + //Allocate depth/stencil buffers + var WEBGL_depth_texture = gl.getExtension('WEBGL_depth_texture') + if(WEBGL_depth_texture) { + if(useStencil) { + fbo.depth = initTexture(gl, width, height, + WEBGL_depth_texture.UNSIGNED_INT_24_8_WEBGL, + gl.DEPTH_STENCIL, + gl.DEPTH_STENCIL_ATTACHMENT) + } else if(useDepth) { + fbo.depth = initTexture(gl, width, height, + gl.UNSIGNED_SHORT, + gl.DEPTH_COMPONENT, + gl.DEPTH_ATTACHMENT) + } + } else { + if(useDepth && useStencil) { + fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_STENCIL, gl.DEPTH_STENCIL_ATTACHMENT) + } else if(useDepth) { + fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_COMPONENT16, gl.DEPTH_ATTACHMENT) + } else if(useStencil) { + fbo._depth_rb = initRenderBuffer(gl, width, height, gl.STENCIL_INDEX, gl.STENCIL_ATTACHMENT) + } + } + + //Check frame buffer state + var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER) + if(status !== gl.FRAMEBUFFER_COMPLETE) { + + //Release all partially allocated resources + fbo._destroyed = true + + //Release all resources + gl.bindFramebuffer(gl.FRAMEBUFFER, null) + gl.deleteFramebuffer(fbo.handle) + fbo.handle = null + if(fbo.depth) { + fbo.depth.dispose() + fbo.depth = null + } + if(fbo._depth_rb) { + gl.deleteRenderbuffer(fbo._depth_rb) + fbo._depth_rb = null + } + for(var i=0; i maxFBOSize || + h < 0 || h > maxFBOSize) { + throw new Error('gl-fbo: Can\'t resize FBO, invalid dimensions') + } + + //Update shape + fbo._shape[0] = w + fbo._shape[1] = h + + //Save framebuffer state + var state = saveFBOState(gl) + + //Resize framebuffer attachments + for(var i=0; i maxFBOSize || height < 0 || height > maxFBOSize) { + throw new Error('gl-fbo: Parameters are too large for FBO') + } + + //Handle each option type + options = options || {} + + //Figure out number of color buffers to use + var numColors = 1 + if('color' in options) { + numColors = Math.max(options.color|0, 0) + if(numColors < 0) { + throw new Error('gl-fbo: Must specify a nonnegative number of colors') + } + if(numColors > 1) { + //Check if multiple render targets supported + if(!WEBGL_draw_buffers) { + throw new Error('gl-fbo: Multiple draw buffer extension not supported') + } else if(numColors > gl.getParameter(WEBGL_draw_buffers.MAX_COLOR_ATTACHMENTS_WEBGL)) { + throw new Error('gl-fbo: Context does not support ' + numColors + ' draw buffers') + } + } + } + + //Determine whether to use floating point textures + var colorType = gl.UNSIGNED_BYTE + var OES_texture_float = gl.getExtension('OES_texture_float') + if(options.float && numColors > 0) { + if(!OES_texture_float) { + throw new Error('gl-fbo: Context does not support floating point textures') + } + colorType = gl.FLOAT + } else if(options.preferFloat && numColors > 0) { + if(OES_texture_float) { + colorType = gl.FLOAT + } + } + + //Check if we should use depth buffer + var useDepth = true + if('depth' in options) { + useDepth = !!options.depth + } + + //Check if we should use a stencil buffer + var useStencil = false + if('stencil' in options) { + useStencil = !!options.stencil + } + + return new Framebuffer( + gl, + width, + height, + colorType, + numColors, + useDepth, + useStencil, + WEBGL_draw_buffers) +} + +},{"gl-texture2d":163}],114:[function(_dereq_,module,exports){ + +var sprintf = _dereq_('sprintf-js').sprintf; +var glConstants = _dereq_('gl-constants/lookup'); +var shaderName = _dereq_('glsl-shader-name'); +var addLineNumbers = _dereq_('add-line-numbers'); + +module.exports = formatCompilerError; + +function formatCompilerError(errLog, src, type) { + "use strict"; + + var name = shaderName(src) || 'of unknown name (see npm glsl-shader-name)'; + + var typeName = 'unknown type'; + if (type !== undefined) { + typeName = type === glConstants.FRAGMENT_SHADER ? 'fragment' : 'vertex' + } + + var longForm = sprintf('Error compiling %s shader %s:\n', typeName, name); + var shortForm = sprintf("%s%s", longForm, errLog); + + var errorStrings = errLog.split('\n'); + var errors = {}; + + for (var i = 0; i < errorStrings.length; i++) { + var errorString = errorStrings[i]; + if (errorString === '' || errorString === "\0") continue; + var lineNo = parseInt(errorString.split(':')[2]); + if (isNaN(lineNo)) { + throw new Error(sprintf('Could not parse error: %s', errorString)); + } + errors[lineNo] = errorString; + } + + var lines = addLineNumbers(src).split('\n'); + + for (var i = 0; i < lines.length; i++) { + if (!errors[i+3] && !errors[i+2] && !errors[i+1]) continue; + var line = lines[i]; + longForm += line + '\n'; + if (errors[i+1]) { + var e = errors[i+1]; + e = e.substr(e.split(':', 3).join(':').length + 1).trim(); + longForm += sprintf('^^^ %s\n\n', e); + } + } + + return { + long: longForm.trim(), + short: shortForm.trim() + }; +} + + +},{"add-line-numbers":13,"gl-constants/lookup":110,"glsl-shader-name":241,"sprintf-js":339}],115:[function(_dereq_,module,exports){ +var glslify = _dereq_('glslify') +var createShader = _dereq_('gl-shader') + +var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvec4 project(vec3 p) {\n return projection * view * model * vec4(p, 1.0);\n}\n\nvoid main() {\n vec4 startPoint = project(position);\n vec4 endPoint = project(nextPosition);\n\n vec2 A = startPoint.xy / startPoint.w;\n vec2 B = endPoint.xy / endPoint.w;\n\n float clipAngle = atan(\n (B.y - A.y) * screenShape.y,\n (B.x - A.x) * screenShape.x\n );\n\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(\n sin(clipAngle),\n -cos(clipAngle)\n ) / screenShape;\n\n gl_Position = vec4(startPoint.xy + startPoint.w * offset, startPoint.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n"]) +var forwardFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]) +var pickFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1540259130(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1540259130(pixelArcLength).xyz);\n}"]) + +var ATTRIBUTES = [ + {name: 'position', type: 'vec3'}, + {name: 'nextPosition', type: 'vec3'}, + {name: 'arcLength', type: 'float'}, + {name: 'lineWidth', type: 'float'}, + {name: 'color', type: 'vec4'} +] + +exports.createShader = function(gl) { + return createShader(gl, vertSrc, forwardFrag, null, ATTRIBUTES) +} + +exports.createPickShader = function(gl) { + return createShader(gl, vertSrc, pickFrag, null, ATTRIBUTES) +} + +},{"gl-shader":148,"glslify":249}],116:[function(_dereq_,module,exports){ +'use strict' + +module.exports = createLinePlot + +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var unpackFloat = _dereq_('glsl-read-float') +var bsearch = _dereq_('binary-search-bounds') +var ndarray = _dereq_('ndarray') +var shaders = _dereq_('./lib/shaders') + +var createShader = shaders.createShader +var createPickShader = shaders.createPickShader + +var identity = [1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1] + +function distance (a, b) { + var s = 0.0 + for (var i = 0; i < 3; ++i) { + var d = a[i] - b[i] + s += d * d + } + return Math.sqrt(s) +} + +function filterClipBounds (bounds) { + var result = [[-1e6, -1e6, -1e6], [1e6, 1e6, 1e6]] + for (var i = 0; i < 3; ++i) { + result[0][i] = Math.max(bounds[0][i], result[0][i]) + result[1][i] = Math.min(bounds[1][i], result[1][i]) + } + return result +} + +function PickResult (tau, position, index, dataCoordinate) { + this.arcLength = tau + this.position = position + this.index = index + this.dataCoordinate = dataCoordinate +} + +function LinePlot (gl, shader, pickShader, buffer, vao, texture) { + this.gl = gl + this.shader = shader + this.pickShader = pickShader + this.buffer = buffer + this.vao = vao + this.clipBounds = [ + [ -Infinity, -Infinity, -Infinity ], + [ Infinity, Infinity, Infinity ]] + this.points = [] + this.arcLength = [] + this.vertexCount = 0 + this.bounds = [[0, 0, 0], [0, 0, 0]] + this.pickId = 0 + this.lineWidth = 1 + this.texture = texture + this.dashScale = 1 + this.opacity = 1 + this.dirty = true + this.pixelRatio = 1 +} + +var proto = LinePlot.prototype + +proto.isTransparent = function () { + return this.opacity < 1 +} + +proto.isOpaque = function () { + return this.opacity >= 1 +} + +proto.pickSlots = 1 + +proto.setPickBase = function (id) { + this.pickId = id +} + +proto.drawTransparent = proto.draw = function (camera) { + if (!this.vertexCount) return + var gl = this.gl + var shader = this.shader + var vao = this.vao + shader.bind() + shader.uniforms = { + model: camera.model || identity, + view: camera.view || identity, + projection: camera.projection || identity, + clipBounds: filterClipBounds(this.clipBounds), + dashTexture: this.texture.bind(), + dashScale: this.dashScale / this.arcLength[this.arcLength.length - 1], + opacity: this.opacity, + screenShape: [gl.drawingBufferWidth, gl.drawingBufferHeight], + pixelRatio: this.pixelRatio + } + vao.bind() + vao.draw(gl.TRIANGLE_STRIP, this.vertexCount) + vao.unbind() +} + +proto.drawPick = function (camera) { + if (!this.vertexCount) return + var gl = this.gl + var shader = this.pickShader + var vao = this.vao + shader.bind() + shader.uniforms = { + model: camera.model || identity, + view: camera.view || identity, + projection: camera.projection || identity, + pickId: this.pickId, + clipBounds: filterClipBounds(this.clipBounds), + screenShape: [gl.drawingBufferWidth, gl.drawingBufferHeight], + pixelRatio: this.pixelRatio + } + vao.bind() + vao.draw(gl.TRIANGLE_STRIP, this.vertexCount) + vao.unbind() +} + +proto.update = function (options) { + var i, j + + this.dirty = true + + var connectGaps = !!options.connectGaps + + if ('dashScale' in options) { + this.dashScale = options.dashScale + } + if ('opacity' in options) { + this.opacity = +options.opacity + } + + // Recalculate buffer data + var buffer = [] + var arcLengthArray = [] + var pointArray = [] + var arcLength = 0.0 + var vertexCount = 0 + var bounds = [ + [ Infinity, Infinity, Infinity ], + [ -Infinity, -Infinity, -Infinity ]] + + var positions = options.position || options.positions + if (positions) { + + // Default color + var colors = options.color || options.colors || [0, 0, 0, 1] + + var lineWidth = options.lineWidth || 1 + + var hadGap = false + + fill_loop: + for (i = 1; i < positions.length; ++i) { + var a = positions[i - 1] + var b = positions[i] + + arcLengthArray.push(arcLength) + pointArray.push(a.slice()) + + for (j = 0; j < 3; ++j) { + if (isNaN(a[j]) || isNaN(b[j]) || + !isFinite(a[j]) || !isFinite(b[j])) { + + if (!connectGaps && buffer.length > 0) { + for (var k = 0; k < 24; ++k) { + buffer.push(buffer[buffer.length - 12]) + } + vertexCount += 2 + hadGap = true + } + + continue fill_loop + } + bounds[0][j] = Math.min(bounds[0][j], a[j], b[j]) + bounds[1][j] = Math.max(bounds[1][j], a[j], b[j]) + } + + var acolor, bcolor + if (Array.isArray(colors[0])) { + acolor = (colors.length > i - 1) ? colors[i - 1] : // using index value + (colors.length > 0) ? colors[colors.length - 1] : // using last item + [0, 0, 0, 1]; // using black + + bcolor = (colors.length > i) ? colors[i] : // using index value + (colors.length > 0) ? colors[colors.length - 1] : // using last item + [0, 0, 0, 1]; // using black + } else { + acolor = bcolor = colors + } + + if (acolor.length === 3) { + acolor = [acolor[0], acolor[1], acolor[2], 1] + } + if (bcolor.length === 3) { + bcolor = [bcolor[0], bcolor[1], bcolor[2], 1] + } + + var w0 + if (Array.isArray(lineWidth)) { + w0 = (lineWidth.length > i - 1) ? lineWidth[i - 1] : // using index value + (lineWidth.length > 0) ? lineWidth[lineWidth.length - 1] : // using last item + [0, 0, 0, 1]; // using black + } else { + w0 = lineWidth + } + + var t0 = arcLength + arcLength += distance(a, b) + + if (hadGap) { + for (j = 0; j < 2; ++j) { + buffer.push( + a[0], a[1], a[2], b[0], b[1], b[2], t0, w0, acolor[0], acolor[1], acolor[2], acolor[3]) + } + vertexCount += 2 + hadGap = false + } + + buffer.push( + a[0], a[1], a[2], b[0], b[1], b[2], t0, w0, acolor[0], acolor[1], acolor[2], acolor[3], + a[0], a[1], a[2], b[0], b[1], b[2], t0, -w0, acolor[0], acolor[1], acolor[2], acolor[3], + b[0], b[1], b[2], a[0], a[1], a[2], arcLength, -w0, bcolor[0], bcolor[1], bcolor[2], bcolor[3], + b[0], b[1], b[2], a[0], a[1], a[2], arcLength, w0, bcolor[0], bcolor[1], bcolor[2], bcolor[3]) + + vertexCount += 4 + } + } + this.buffer.update(buffer) + + arcLengthArray.push(arcLength) + pointArray.push(positions[positions.length - 1].slice()) + + this.bounds = bounds + + this.vertexCount = vertexCount + + this.points = pointArray + this.arcLength = arcLengthArray + + if ('dashes' in options) { + var dashArray = options.dashes + + // Calculate prefix sum + var prefixSum = dashArray.slice() + prefixSum.unshift(0) + for (i = 1; i < prefixSum.length; ++i) { + prefixSum[i] = prefixSum[i - 1] + prefixSum[i] + } + + var dashTexture = ndarray(new Array(256 * 4), [256, 1, 4]) + for (i = 0; i < 256; ++i) { + for (j = 0; j < 4; ++j) { + dashTexture.set(i, 0, j, 0) + } + if (bsearch.le(prefixSum, prefixSum[prefixSum.length - 1] * i / 255.0) & 1) { + dashTexture.set(i, 0, 0, 0) + } else { + dashTexture.set(i, 0, 0, 255) + } + } + + this.texture.setPixels(dashTexture) + } +} + +proto.dispose = function () { + this.shader.dispose() + this.vao.dispose() + this.buffer.dispose() +} + +proto.pick = function (selection) { + if (!selection) { + return null + } + if (selection.id !== this.pickId) { + return null + } + var tau = unpackFloat( + selection.value[0], + selection.value[1], + selection.value[2], + 0) + var index = bsearch.le(this.arcLength, tau) + if (index < 0) { + return null + } + if (index === this.arcLength.length - 1) { + return new PickResult( + this.arcLength[this.arcLength.length - 1], + this.points[this.points.length - 1].slice(), + index) + } + var a = this.points[index] + var b = this.points[Math.min(index + 1, this.points.length - 1)] + var t = (tau - this.arcLength[index]) / (this.arcLength[index + 1] - this.arcLength[index]) + var ti = 1.0 - t + var x = [0, 0, 0] + for (var i = 0; i < 3; ++i) { + x[i] = ti * a[i] + t * b[i] + } + var dataIndex = Math.min((t < 0.5) ? index : (index + 1), this.points.length - 1) + return new PickResult( + tau, + x, + dataIndex, + this.points[dataIndex]) +} + +function createLinePlot (options) { + var gl = options.gl || (options.scene && options.scene.gl) + + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.nextPosition.location = 1 + shader.attributes.arcLength.location = 2 + shader.attributes.lineWidth.location = 3 + shader.attributes.color.location = 4 + + var pickShader = createPickShader(gl) + pickShader.attributes.position.location = 0 + pickShader.attributes.nextPosition.location = 1 + pickShader.attributes.arcLength.location = 2 + pickShader.attributes.lineWidth.location = 3 + pickShader.attributes.color.location = 4 + + var buffer = createBuffer(gl) + var vao = createVAO(gl, [ + { + 'buffer': buffer, + 'size': 3, + 'offset': 0, + 'stride': 48 + }, + { + 'buffer': buffer, + 'size': 3, + 'offset': 12, + 'stride': 48 + }, + { + 'buffer': buffer, + 'size': 1, + 'offset': 24, + 'stride': 48 + }, + { + 'buffer': buffer, + 'size': 1, + 'offset': 28, + 'stride': 48 + }, + { + 'buffer': buffer, + 'size': 4, + 'offset': 32, + 'stride': 48 + } + ]) + + // Create texture for dash pattern + var defaultTexture = ndarray(new Array(256 * 4), [256, 1, 4]) + for (var i = 0; i < 256 * 4; ++i) { + defaultTexture.data[i] = 255 + } + var texture = createTexture(gl, defaultTexture) + texture.wrap = gl.REPEAT + + var linePlot = new LinePlot(gl, shader, pickShader, buffer, vao, texture) + linePlot.update(options) + return linePlot +} + +},{"./lib/shaders":115,"binary-search-bounds":36,"gl-buffer":104,"gl-texture2d":163,"gl-vao":167,"glsl-read-float":240,"ndarray":285}],117:[function(_dereq_,module,exports){ +module.exports = invert + +/** + * Inverts a mat2 + * + * @alias mat2.invert + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out + */ +function invert(out, a) { + var a0 = a[0] + var a1 = a[1] + var a2 = a[2] + var a3 = a[3] + var det = a0 * a3 - a2 * a1 + + if (!det) return null + det = 1.0 / det + + out[0] = a3 * det + out[1] = -a1 * det + out[2] = -a2 * det + out[3] = a0 * det + + return out +} + +},{}],118:[function(_dereq_,module,exports){ +module.exports = invert + +/** + * Inverts a mat3 + * + * @alias mat3.invert + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +function invert(out, a) { + var a00 = a[0], a01 = a[1], a02 = a[2] + var a10 = a[3], a11 = a[4], a12 = a[5] + var a20 = a[6], a21 = a[7], a22 = a[8] + + var b01 = a22 * a11 - a12 * a21 + var b11 = -a22 * a10 + a12 * a20 + var b21 = a21 * a10 - a11 * a20 + + // Calculate the determinant + var det = a00 * b01 + a01 * b11 + a02 * b21 + + if (!det) return null + det = 1.0 / det + + out[0] = b01 * det + out[1] = (-a22 * a01 + a02 * a21) * det + out[2] = (a12 * a01 - a02 * a11) * det + out[3] = b11 * det + out[4] = (a22 * a00 - a02 * a20) * det + out[5] = (-a12 * a00 + a02 * a10) * det + out[6] = b21 * det + out[7] = (-a21 * a00 + a01 * a20) * det + out[8] = (a11 * a00 - a01 * a10) * det + + return out +} + +},{}],119:[function(_dereq_,module,exports){ +module.exports = clone; + +/** + * Creates a new mat4 initialized with values from an existing matrix + * + * @param {mat4} a matrix to clone + * @returns {mat4} a new 4x4 matrix + */ +function clone(a) { + var out = new Float32Array(16); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +}; +},{}],120:[function(_dereq_,module,exports){ +module.exports = create; + +/** + * Creates a new identity mat4 + * + * @returns {mat4} a new 4x4 matrix + */ +function create() { + var out = new Float32Array(16); + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +}; +},{}],121:[function(_dereq_,module,exports){ +module.exports = determinant; + +/** + * Calculates the determinant of a mat4 + * + * @param {mat4} a the source matrix + * @returns {Number} determinant of a + */ +function determinant(a) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], + a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], + a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], + a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], + + b00 = a00 * a11 - a01 * a10, + b01 = a00 * a12 - a02 * a10, + b02 = a00 * a13 - a03 * a10, + b03 = a01 * a12 - a02 * a11, + b04 = a01 * a13 - a03 * a11, + b05 = a02 * a13 - a03 * a12, + b06 = a20 * a31 - a21 * a30, + b07 = a20 * a32 - a22 * a30, + b08 = a20 * a33 - a23 * a30, + b09 = a21 * a32 - a22 * a31, + b10 = a21 * a33 - a23 * a31, + b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; +}; +},{}],122:[function(_dereq_,module,exports){ +module.exports = fromQuat; + +/** + * Creates a matrix from a quaternion rotation. + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @returns {mat4} out + */ +function fromQuat(out, q) { + var x = q[0], y = q[1], z = q[2], w = q[3], + x2 = x + x, + y2 = y + y, + z2 = z + z, + + xx = x * x2, + yx = y * x2, + yy = y * y2, + zx = z * x2, + zy = z * y2, + zz = z * z2, + wx = w * x2, + wy = w * y2, + wz = w * z2; + + out[0] = 1 - yy - zz; + out[1] = yx + wz; + out[2] = zx - wy; + out[3] = 0; + + out[4] = yx - wz; + out[5] = 1 - xx - zz; + out[6] = zy + wx; + out[7] = 0; + + out[8] = zx + wy; + out[9] = zy - wx; + out[10] = 1 - xx - yy; + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return out; +}; +},{}],123:[function(_dereq_,module,exports){ +module.exports = fromRotationTranslation; + +/** + * Creates a matrix from a quaternion rotation and vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * var quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {vec3} v Translation vector + * @returns {mat4} out + */ +function fromRotationTranslation(out, q, v) { + // Quaternion math + var x = q[0], y = q[1], z = q[2], w = q[3], + x2 = x + x, + y2 = y + y, + z2 = z + z, + + xx = x * x2, + xy = x * y2, + xz = x * z2, + yy = y * y2, + yz = y * z2, + zz = z * z2, + wx = w * x2, + wy = w * y2, + wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + + return out; +}; +},{}],124:[function(_dereq_,module,exports){ +module.exports = identity; + +/** + * Set a mat4 to the identity matrix + * + * @param {mat4} out the receiving matrix + * @returns {mat4} out + */ +function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +}; +},{}],125:[function(_dereq_,module,exports){ +module.exports = invert; + +/** + * Inverts a mat4 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +function invert(out, a) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], + a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], + a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], + a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], + + b00 = a00 * a11 - a01 * a10, + b01 = a00 * a12 - a02 * a10, + b02 = a00 * a13 - a03 * a10, + b03 = a01 * a12 - a02 * a11, + b04 = a01 * a13 - a03 * a11, + b05 = a02 * a13 - a03 * a12, + b06 = a20 * a31 - a21 * a30, + b07 = a20 * a32 - a22 * a30, + b08 = a20 * a33 - a23 * a30, + b09 = a21 * a32 - a22 * a31, + b10 = a21 * a33 - a23 * a31, + b11 = a22 * a33 - a23 * a32, + + // Calculate the determinant + det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) { + return null; + } + det = 1.0 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return out; +}; +},{}],126:[function(_dereq_,module,exports){ +var identity = _dereq_('./identity'); + +module.exports = lookAt; + +/** + * Generates a look-at matrix with the given eye position, focal point, and up axis + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {vec3} eye Position of the viewer + * @param {vec3} center Point the viewer is looking at + * @param {vec3} up vec3 pointing up + * @returns {mat4} out + */ +function lookAt(out, eye, center, up) { + var x0, x1, x2, y0, y1, y2, z0, z1, z2, len, + eyex = eye[0], + eyey = eye[1], + eyez = eye[2], + upx = up[0], + upy = up[1], + upz = up[2], + centerx = center[0], + centery = center[1], + centerz = center[2]; + + if (Math.abs(eyex - centerx) < 0.000001 && + Math.abs(eyey - centery) < 0.000001 && + Math.abs(eyez - centerz) < 0.000001) { + return identity(out); + } + + z0 = eyex - centerx; + z1 = eyey - centery; + z2 = eyez - centerz; + + len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + z0 *= len; + z1 *= len; + z2 *= len; + + x0 = upy * z2 - upz * z1; + x1 = upz * z0 - upx * z2; + x2 = upx * z1 - upy * z0; + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + if (!len) { + x0 = 0; + x1 = 0; + x2 = 0; + } else { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + y0 = z1 * x2 - z2 * x1; + y1 = z2 * x0 - z0 * x2; + y2 = z0 * x1 - z1 * x0; + + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + if (!len) { + y0 = 0; + y1 = 0; + y2 = 0; + } else { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + + return out; +}; +},{"./identity":124}],127:[function(_dereq_,module,exports){ +module.exports = multiply; + +/** + * Multiplies two mat4's + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out + */ +function multiply(out, a, b) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], + a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], + a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], + a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + // Cache only the current line of the second matrix + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; + out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; + out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; + out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + return out; +}; +},{}],128:[function(_dereq_,module,exports){ +module.exports = perspective; + +/** + * Generates a perspective projection matrix with the given bounds + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ +function perspective(out, fovy, aspect, near, far) { + var f = 1.0 / Math.tan(fovy / 2), + nf = 1 / (near - far); + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = (far + near) * nf; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; + return out; +}; +},{}],129:[function(_dereq_,module,exports){ +module.exports = rotate; + +/** + * Rotates a mat4 by the given angle + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @param {vec3} axis the axis to rotate around + * @returns {mat4} out + */ +function rotate(out, a, rad, axis) { + var x = axis[0], y = axis[1], z = axis[2], + len = Math.sqrt(x * x + y * y + z * z), + s, c, t, + a00, a01, a02, a03, + a10, a11, a12, a13, + a20, a21, a22, a23, + b00, b01, b02, + b10, b11, b12, + b20, b21, b22; + + if (Math.abs(len) < 0.000001) { return null; } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; + + a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; + a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; + a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; + + // Construct the elements of the rotation matrix + b00 = x * x * t + c; b01 = y * x * t + z * s; b02 = z * x * t - y * s; + b10 = x * y * t - z * s; b11 = y * y * t + c; b12 = z * y * t + x * s; + b20 = x * z * t + y * s; b21 = y * z * t - x * s; b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + out[0] = a00 * b00 + a10 * b01 + a20 * b02; + out[1] = a01 * b00 + a11 * b01 + a21 * b02; + out[2] = a02 * b00 + a12 * b01 + a22 * b02; + out[3] = a03 * b00 + a13 * b01 + a23 * b02; + out[4] = a00 * b10 + a10 * b11 + a20 * b12; + out[5] = a01 * b10 + a11 * b11 + a21 * b12; + out[6] = a02 * b10 + a12 * b11 + a22 * b12; + out[7] = a03 * b10 + a13 * b11 + a23 * b12; + out[8] = a00 * b20 + a10 * b21 + a20 * b22; + out[9] = a01 * b20 + a11 * b21 + a21 * b22; + out[10] = a02 * b20 + a12 * b21 + a22 * b22; + out[11] = a03 * b20 + a13 * b21 + a23 * b22; + + if (a !== out) { // If the source and destination differ, copy the unchanged last row + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + return out; +}; +},{}],130:[function(_dereq_,module,exports){ +module.exports = rotateX; + +/** + * Rotates a matrix by the given angle around the X axis + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ +function rotateX(out, a, rad) { + var s = Math.sin(rad), + c = Math.cos(rad), + a10 = a[4], + a11 = a[5], + a12 = a[6], + a13 = a[7], + a20 = a[8], + a21 = a[9], + a22 = a[10], + a23 = a[11]; + + if (a !== out) { // If the source and destination differ, copy the unchanged rows + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + // Perform axis-specific matrix multiplication + out[4] = a10 * c + a20 * s; + out[5] = a11 * c + a21 * s; + out[6] = a12 * c + a22 * s; + out[7] = a13 * c + a23 * s; + out[8] = a20 * c - a10 * s; + out[9] = a21 * c - a11 * s; + out[10] = a22 * c - a12 * s; + out[11] = a23 * c - a13 * s; + return out; +}; +},{}],131:[function(_dereq_,module,exports){ +module.exports = rotateY; + +/** + * Rotates a matrix by the given angle around the Y axis + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ +function rotateY(out, a, rad) { + var s = Math.sin(rad), + c = Math.cos(rad), + a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3], + a20 = a[8], + a21 = a[9], + a22 = a[10], + a23 = a[11]; + + if (a !== out) { // If the source and destination differ, copy the unchanged rows + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + // Perform axis-specific matrix multiplication + out[0] = a00 * c - a20 * s; + out[1] = a01 * c - a21 * s; + out[2] = a02 * c - a22 * s; + out[3] = a03 * c - a23 * s; + out[8] = a00 * s + a20 * c; + out[9] = a01 * s + a21 * c; + out[10] = a02 * s + a22 * c; + out[11] = a03 * s + a23 * c; + return out; +}; +},{}],132:[function(_dereq_,module,exports){ +module.exports = rotateZ; + +/** + * Rotates a matrix by the given angle around the Z axis + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ +function rotateZ(out, a, rad) { + var s = Math.sin(rad), + c = Math.cos(rad), + a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3], + a10 = a[4], + a11 = a[5], + a12 = a[6], + a13 = a[7]; + + if (a !== out) { // If the source and destination differ, copy the unchanged last row + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + // Perform axis-specific matrix multiplication + out[0] = a00 * c + a10 * s; + out[1] = a01 * c + a11 * s; + out[2] = a02 * c + a12 * s; + out[3] = a03 * c + a13 * s; + out[4] = a10 * c - a00 * s; + out[5] = a11 * c - a01 * s; + out[6] = a12 * c - a02 * s; + out[7] = a13 * c - a03 * s; + return out; +}; +},{}],133:[function(_dereq_,module,exports){ +module.exports = scale; + +/** + * Scales the mat4 by the dimensions in the given vec3 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to scale + * @param {vec3} v the vec3 to scale the matrix by + * @returns {mat4} out + **/ +function scale(out, a, v) { + var x = v[0], y = v[1], z = v[2]; -},{"glslify":249}],109:[function(_dereq_,module,exports){ -module.exports = { - 0: 'NONE', - 1: 'ONE', - 2: 'LINE_LOOP', - 3: 'LINE_STRIP', - 4: 'TRIANGLES', - 5: 'TRIANGLE_STRIP', - 6: 'TRIANGLE_FAN', - 256: 'DEPTH_BUFFER_BIT', - 512: 'NEVER', - 513: 'LESS', - 514: 'EQUAL', - 515: 'LEQUAL', - 516: 'GREATER', - 517: 'NOTEQUAL', - 518: 'GEQUAL', - 519: 'ALWAYS', - 768: 'SRC_COLOR', - 769: 'ONE_MINUS_SRC_COLOR', - 770: 'SRC_ALPHA', - 771: 'ONE_MINUS_SRC_ALPHA', - 772: 'DST_ALPHA', - 773: 'ONE_MINUS_DST_ALPHA', - 774: 'DST_COLOR', - 775: 'ONE_MINUS_DST_COLOR', - 776: 'SRC_ALPHA_SATURATE', - 1024: 'STENCIL_BUFFER_BIT', - 1028: 'FRONT', - 1029: 'BACK', - 1032: 'FRONT_AND_BACK', - 1280: 'INVALID_ENUM', - 1281: 'INVALID_VALUE', - 1282: 'INVALID_OPERATION', - 1285: 'OUT_OF_MEMORY', - 1286: 'INVALID_FRAMEBUFFER_OPERATION', - 2304: 'CW', - 2305: 'CCW', - 2849: 'LINE_WIDTH', - 2884: 'CULL_FACE', - 2885: 'CULL_FACE_MODE', - 2886: 'FRONT_FACE', - 2928: 'DEPTH_RANGE', - 2929: 'DEPTH_TEST', - 2930: 'DEPTH_WRITEMASK', - 2931: 'DEPTH_CLEAR_VALUE', - 2932: 'DEPTH_FUNC', - 2960: 'STENCIL_TEST', - 2961: 'STENCIL_CLEAR_VALUE', - 2962: 'STENCIL_FUNC', - 2963: 'STENCIL_VALUE_MASK', - 2964: 'STENCIL_FAIL', - 2965: 'STENCIL_PASS_DEPTH_FAIL', - 2966: 'STENCIL_PASS_DEPTH_PASS', - 2967: 'STENCIL_REF', - 2968: 'STENCIL_WRITEMASK', - 2978: 'VIEWPORT', - 3024: 'DITHER', - 3042: 'BLEND', - 3088: 'SCISSOR_BOX', - 3089: 'SCISSOR_TEST', - 3106: 'COLOR_CLEAR_VALUE', - 3107: 'COLOR_WRITEMASK', - 3317: 'UNPACK_ALIGNMENT', - 3333: 'PACK_ALIGNMENT', - 3379: 'MAX_TEXTURE_SIZE', - 3386: 'MAX_VIEWPORT_DIMS', - 3408: 'SUBPIXEL_BITS', - 3410: 'RED_BITS', - 3411: 'GREEN_BITS', - 3412: 'BLUE_BITS', - 3413: 'ALPHA_BITS', - 3414: 'DEPTH_BITS', - 3415: 'STENCIL_BITS', - 3553: 'TEXTURE_2D', - 4352: 'DONT_CARE', - 4353: 'FASTEST', - 4354: 'NICEST', - 5120: 'BYTE', - 5121: 'UNSIGNED_BYTE', - 5122: 'SHORT', - 5123: 'UNSIGNED_SHORT', - 5124: 'INT', - 5125: 'UNSIGNED_INT', - 5126: 'FLOAT', - 5386: 'INVERT', - 5890: 'TEXTURE', - 6401: 'STENCIL_INDEX', - 6402: 'DEPTH_COMPONENT', - 6406: 'ALPHA', - 6407: 'RGB', - 6408: 'RGBA', - 6409: 'LUMINANCE', - 6410: 'LUMINANCE_ALPHA', - 7680: 'KEEP', - 7681: 'REPLACE', - 7682: 'INCR', - 7683: 'DECR', - 7936: 'VENDOR', - 7937: 'RENDERER', - 7938: 'VERSION', - 9728: 'NEAREST', - 9729: 'LINEAR', - 9984: 'NEAREST_MIPMAP_NEAREST', - 9985: 'LINEAR_MIPMAP_NEAREST', - 9986: 'NEAREST_MIPMAP_LINEAR', - 9987: 'LINEAR_MIPMAP_LINEAR', - 10240: 'TEXTURE_MAG_FILTER', - 10241: 'TEXTURE_MIN_FILTER', - 10242: 'TEXTURE_WRAP_S', - 10243: 'TEXTURE_WRAP_T', - 10497: 'REPEAT', - 10752: 'POLYGON_OFFSET_UNITS', - 16384: 'COLOR_BUFFER_BIT', - 32769: 'CONSTANT_COLOR', - 32770: 'ONE_MINUS_CONSTANT_COLOR', - 32771: 'CONSTANT_ALPHA', - 32772: 'ONE_MINUS_CONSTANT_ALPHA', - 32773: 'BLEND_COLOR', - 32774: 'FUNC_ADD', - 32777: 'BLEND_EQUATION_RGB', - 32778: 'FUNC_SUBTRACT', - 32779: 'FUNC_REVERSE_SUBTRACT', - 32819: 'UNSIGNED_SHORT_4_4_4_4', - 32820: 'UNSIGNED_SHORT_5_5_5_1', - 32823: 'POLYGON_OFFSET_FILL', - 32824: 'POLYGON_OFFSET_FACTOR', - 32854: 'RGBA4', - 32855: 'RGB5_A1', - 32873: 'TEXTURE_BINDING_2D', - 32926: 'SAMPLE_ALPHA_TO_COVERAGE', - 32928: 'SAMPLE_COVERAGE', - 32936: 'SAMPLE_BUFFERS', - 32937: 'SAMPLES', - 32938: 'SAMPLE_COVERAGE_VALUE', - 32939: 'SAMPLE_COVERAGE_INVERT', - 32968: 'BLEND_DST_RGB', - 32969: 'BLEND_SRC_RGB', - 32970: 'BLEND_DST_ALPHA', - 32971: 'BLEND_SRC_ALPHA', - 33071: 'CLAMP_TO_EDGE', - 33170: 'GENERATE_MIPMAP_HINT', - 33189: 'DEPTH_COMPONENT16', - 33306: 'DEPTH_STENCIL_ATTACHMENT', - 33635: 'UNSIGNED_SHORT_5_6_5', - 33648: 'MIRRORED_REPEAT', - 33901: 'ALIASED_POINT_SIZE_RANGE', - 33902: 'ALIASED_LINE_WIDTH_RANGE', - 33984: 'TEXTURE0', - 33985: 'TEXTURE1', - 33986: 'TEXTURE2', - 33987: 'TEXTURE3', - 33988: 'TEXTURE4', - 33989: 'TEXTURE5', - 33990: 'TEXTURE6', - 33991: 'TEXTURE7', - 33992: 'TEXTURE8', - 33993: 'TEXTURE9', - 33994: 'TEXTURE10', - 33995: 'TEXTURE11', - 33996: 'TEXTURE12', - 33997: 'TEXTURE13', - 33998: 'TEXTURE14', - 33999: 'TEXTURE15', - 34000: 'TEXTURE16', - 34001: 'TEXTURE17', - 34002: 'TEXTURE18', - 34003: 'TEXTURE19', - 34004: 'TEXTURE20', - 34005: 'TEXTURE21', - 34006: 'TEXTURE22', - 34007: 'TEXTURE23', - 34008: 'TEXTURE24', - 34009: 'TEXTURE25', - 34010: 'TEXTURE26', - 34011: 'TEXTURE27', - 34012: 'TEXTURE28', - 34013: 'TEXTURE29', - 34014: 'TEXTURE30', - 34015: 'TEXTURE31', - 34016: 'ACTIVE_TEXTURE', - 34024: 'MAX_RENDERBUFFER_SIZE', - 34041: 'DEPTH_STENCIL', - 34055: 'INCR_WRAP', - 34056: 'DECR_WRAP', - 34067: 'TEXTURE_CUBE_MAP', - 34068: 'TEXTURE_BINDING_CUBE_MAP', - 34069: 'TEXTURE_CUBE_MAP_POSITIVE_X', - 34070: 'TEXTURE_CUBE_MAP_NEGATIVE_X', - 34071: 'TEXTURE_CUBE_MAP_POSITIVE_Y', - 34072: 'TEXTURE_CUBE_MAP_NEGATIVE_Y', - 34073: 'TEXTURE_CUBE_MAP_POSITIVE_Z', - 34074: 'TEXTURE_CUBE_MAP_NEGATIVE_Z', - 34076: 'MAX_CUBE_MAP_TEXTURE_SIZE', - 34338: 'VERTEX_ATTRIB_ARRAY_ENABLED', - 34339: 'VERTEX_ATTRIB_ARRAY_SIZE', - 34340: 'VERTEX_ATTRIB_ARRAY_STRIDE', - 34341: 'VERTEX_ATTRIB_ARRAY_TYPE', - 34342: 'CURRENT_VERTEX_ATTRIB', - 34373: 'VERTEX_ATTRIB_ARRAY_POINTER', - 34466: 'NUM_COMPRESSED_TEXTURE_FORMATS', - 34467: 'COMPRESSED_TEXTURE_FORMATS', - 34660: 'BUFFER_SIZE', - 34661: 'BUFFER_USAGE', - 34816: 'STENCIL_BACK_FUNC', - 34817: 'STENCIL_BACK_FAIL', - 34818: 'STENCIL_BACK_PASS_DEPTH_FAIL', - 34819: 'STENCIL_BACK_PASS_DEPTH_PASS', - 34877: 'BLEND_EQUATION_ALPHA', - 34921: 'MAX_VERTEX_ATTRIBS', - 34922: 'VERTEX_ATTRIB_ARRAY_NORMALIZED', - 34930: 'MAX_TEXTURE_IMAGE_UNITS', - 34962: 'ARRAY_BUFFER', - 34963: 'ELEMENT_ARRAY_BUFFER', - 34964: 'ARRAY_BUFFER_BINDING', - 34965: 'ELEMENT_ARRAY_BUFFER_BINDING', - 34975: 'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING', - 35040: 'STREAM_DRAW', - 35044: 'STATIC_DRAW', - 35048: 'DYNAMIC_DRAW', - 35632: 'FRAGMENT_SHADER', - 35633: 'VERTEX_SHADER', - 35660: 'MAX_VERTEX_TEXTURE_IMAGE_UNITS', - 35661: 'MAX_COMBINED_TEXTURE_IMAGE_UNITS', - 35663: 'SHADER_TYPE', - 35664: 'FLOAT_VEC2', - 35665: 'FLOAT_VEC3', - 35666: 'FLOAT_VEC4', - 35667: 'INT_VEC2', - 35668: 'INT_VEC3', - 35669: 'INT_VEC4', - 35670: 'BOOL', - 35671: 'BOOL_VEC2', - 35672: 'BOOL_VEC3', - 35673: 'BOOL_VEC4', - 35674: 'FLOAT_MAT2', - 35675: 'FLOAT_MAT3', - 35676: 'FLOAT_MAT4', - 35678: 'SAMPLER_2D', - 35680: 'SAMPLER_CUBE', - 35712: 'DELETE_STATUS', - 35713: 'COMPILE_STATUS', - 35714: 'LINK_STATUS', - 35715: 'VALIDATE_STATUS', - 35716: 'INFO_LOG_LENGTH', - 35717: 'ATTACHED_SHADERS', - 35718: 'ACTIVE_UNIFORMS', - 35719: 'ACTIVE_UNIFORM_MAX_LENGTH', - 35720: 'SHADER_SOURCE_LENGTH', - 35721: 'ACTIVE_ATTRIBUTES', - 35722: 'ACTIVE_ATTRIBUTE_MAX_LENGTH', - 35724: 'SHADING_LANGUAGE_VERSION', - 35725: 'CURRENT_PROGRAM', - 36003: 'STENCIL_BACK_REF', - 36004: 'STENCIL_BACK_VALUE_MASK', - 36005: 'STENCIL_BACK_WRITEMASK', - 36006: 'FRAMEBUFFER_BINDING', - 36007: 'RENDERBUFFER_BINDING', - 36048: 'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', - 36049: 'FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', - 36050: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', - 36051: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', - 36053: 'FRAMEBUFFER_COMPLETE', - 36054: 'FRAMEBUFFER_INCOMPLETE_ATTACHMENT', - 36055: 'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT', - 36057: 'FRAMEBUFFER_INCOMPLETE_DIMENSIONS', - 36061: 'FRAMEBUFFER_UNSUPPORTED', - 36064: 'COLOR_ATTACHMENT0', - 36096: 'DEPTH_ATTACHMENT', - 36128: 'STENCIL_ATTACHMENT', - 36160: 'FRAMEBUFFER', - 36161: 'RENDERBUFFER', - 36162: 'RENDERBUFFER_WIDTH', - 36163: 'RENDERBUFFER_HEIGHT', - 36164: 'RENDERBUFFER_INTERNAL_FORMAT', - 36168: 'STENCIL_INDEX8', - 36176: 'RENDERBUFFER_RED_SIZE', - 36177: 'RENDERBUFFER_GREEN_SIZE', - 36178: 'RENDERBUFFER_BLUE_SIZE', - 36179: 'RENDERBUFFER_ALPHA_SIZE', - 36180: 'RENDERBUFFER_DEPTH_SIZE', - 36181: 'RENDERBUFFER_STENCIL_SIZE', - 36194: 'RGB565', - 36336: 'LOW_FLOAT', - 36337: 'MEDIUM_FLOAT', - 36338: 'HIGH_FLOAT', - 36339: 'LOW_INT', - 36340: 'MEDIUM_INT', - 36341: 'HIGH_INT', - 36346: 'SHADER_COMPILER', - 36347: 'MAX_VERTEX_UNIFORM_VECTORS', - 36348: 'MAX_VARYING_VECTORS', - 36349: 'MAX_FRAGMENT_UNIFORM_VECTORS', - 37440: 'UNPACK_FLIP_Y_WEBGL', - 37441: 'UNPACK_PREMULTIPLY_ALPHA_WEBGL', - 37442: 'CONTEXT_LOST_WEBGL', - 37443: 'UNPACK_COLORSPACE_CONVERSION_WEBGL', - 37444: 'BROWSER_DEFAULT_WEBGL' + out[0] = a[0] * x; + out[1] = a[1] * x; + out[2] = a[2] * x; + out[3] = a[3] * x; + out[4] = a[4] * y; + out[5] = a[5] * y; + out[6] = a[6] * y; + out[7] = a[7] * y; + out[8] = a[8] * z; + out[9] = a[9] * z; + out[10] = a[10] * z; + out[11] = a[11] * z; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +}; +},{}],134:[function(_dereq_,module,exports){ +module.exports = translate; + +/** + * Translate a mat4 by the given vector + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to translate + * @param {vec3} v vector to translate by + * @returns {mat4} out + */ +function translate(out, a, v) { + var x = v[0], y = v[1], z = v[2], + a00, a01, a02, a03, + a10, a11, a12, a13, + a20, a21, a22, a23; + + if (a === out) { + out[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + out[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + out[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + out[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + } else { + a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; + a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; + a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; + + out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03; + out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13; + out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23; + + out[12] = a00 * x + a10 * y + a20 * z + a[12]; + out[13] = a01 * x + a11 * y + a21 * z + a[13]; + out[14] = a02 * x + a12 * y + a22 * z + a[14]; + out[15] = a03 * x + a13 * y + a23 * z + a[15]; + } + + return out; +}; +},{}],135:[function(_dereq_,module,exports){ +module.exports = transpose; + +/** + * Transpose the values of a mat4 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +function transpose(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache some values + if (out === a) { + var a01 = a[1], a02 = a[2], a03 = a[3], + a12 = a[6], a13 = a[7], + a23 = a[11]; + + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a01; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a02; + out[9] = a12; + out[11] = a[14]; + out[12] = a03; + out[13] = a13; + out[14] = a23; + } else { + out[0] = a[0]; + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a[1]; + out[5] = a[5]; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a[2]; + out[9] = a[6]; + out[10] = a[10]; + out[11] = a[14]; + out[12] = a[3]; + out[13] = a[7]; + out[14] = a[11]; + out[15] = a[15]; + } + + return out; +}; +},{}],136:[function(_dereq_,module,exports){ +'use strict' + +module.exports = invert + +var invert2 = _dereq_('gl-mat2/invert') +var invert3 = _dereq_('gl-mat3/invert') +var invert4 = _dereq_('gl-mat4/invert') + +function invert(out, M) { + switch(M.length) { + case 0: + break + case 1: + out[0] = 1.0 / M[0] + break + case 4: + invert2(out, M) + break + case 9: + invert3(out, M) + break + case 16: + invert4(out, M) + break + default: + throw new Error('currently supports matrices up to 4x4') + break + } + return out +} +},{"gl-mat2/invert":117,"gl-mat3/invert":118,"gl-mat4/invert":125}],137:[function(_dereq_,module,exports){ +arguments[4][106][0].apply(exports,arguments) +},{"barycentric":18,"dup":106,"polytope-closest-point/lib/closest_point_2d.js":306}],138:[function(_dereq_,module,exports){ +var glslify = _dereq_('glslify') + +var triVertSrc = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}\n"]) +var triFragSrc = glslify(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nvec3 normals(vec3 pos) {\n vec3 fdx = dFdx(pos);\n vec3 fdy = dFdy(pos);\n return normalize(cross(fdx, fdy));\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]) +var edgeVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]) +var edgeFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) +var pointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]) +var pointFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) +var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) +var pickPointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]) +var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]) +var contourFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]) + +exports.meshShader = { + vertex: triVertSrc, + fragment: triFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'normal', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'} + ] +} +exports.wireShader = { + vertex: edgeVertSrc, + fragment: edgeFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'} + ] +} +exports.pointShader = { + vertex: pointVertSrc, + fragment: pointFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'}, + {name: 'pointSize', type: 'float'} + ] +} +exports.pickShader = { + vertex: pickVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'id', type: 'vec4'} + ] +} +exports.pointPickShader = { + vertex: pickPointVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'pointSize', type: 'float'}, + {name: 'id', type: 'vec4'} + ] +} +exports.contourShader = { + vertex: contourVertSrc, + fragment: contourFragSrc, + attributes: [ + {name: 'position', type: 'vec3'} + ] +} + +},{"glslify":249}],139:[function(_dereq_,module,exports){ +'use strict' + +var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small +var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; + +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var normals = _dereq_('normals') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var ndarray = _dereq_('ndarray') +var colormap = _dereq_('colormap') +var getContour = _dereq_('simplicial-complex-contour') +var pool = _dereq_('typedarray-pool') +var shaders = _dereq_('./lib/shaders') +var closestPoint = _dereq_('./lib/closest-point') + +var meshShader = shaders.meshShader +var wireShader = shaders.wireShader +var pointShader = shaders.pointShader +var pickShader = shaders.pickShader +var pointPickShader = shaders.pointPickShader +var contourShader = shaders.contourShader + +var identityMatrix = [ + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + + +function SimplicialMesh(gl + , texture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) { + + this.gl = gl + this.cells = [] + this.positions = [] + this.intensity = [] + this.texture = texture + this.dirty = true + + this.triShader = triShader + this.lineShader = lineShader + this.pointShader = pointShader + this.pickShader = pickShader + this.pointPickShader = pointPickShader + this.contourShader = contourShader + + this.trianglePositions = trianglePositions + this.triangleColors = triangleColors + this.triangleNormals = triangleNormals + this.triangleUVs = triangleUVs + this.triangleIds = triangleIds + this.triangleVAO = triangleVAO + this.triangleCount = 0 + + this.lineWidth = 1 + this.edgePositions = edgePositions + this.edgeColors = edgeColors + this.edgeUVs = edgeUVs + this.edgeIds = edgeIds + this.edgeVAO = edgeVAO + this.edgeCount = 0 + + this.pointPositions = pointPositions + this.pointColors = pointColors + this.pointUVs = pointUVs + this.pointSizes = pointSizes + this.pointIds = pointIds + this.pointVAO = pointVAO + this.pointCount = 0 + + this.contourLineWidth = 1 + this.contourPositions = contourPositions + this.contourVAO = contourVAO + this.contourCount = 0 + this.contourColor = [0,0,0] + this.contourEnable = true + + this.pickId = 1 + this.bounds = [ + [ Infinity, Infinity, Infinity], + [-Infinity,-Infinity,-Infinity] ] + this.clipBounds = [ + [-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity] ] + + this.lightPosition = [1e5, 1e5, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + + this.opacity = 1.0 + + this._model = identityMatrix + this._view = identityMatrix + this._projection = identityMatrix + this._resolution = [1,1] +} + +var proto = SimplicialMesh.prototype + +proto.isOpaque = function() { + return this.opacity >= 1 +} + +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.pickSlots = 1 + +proto.setPickBase = function(id) { + this.pickId = id +} + +function genColormap(param) { + var colors = colormap({ + colormap: param + , nshades: 256 + , format: 'rgba' + }) + + var result = new Uint8Array(256*4) + for(var i=0; i<256; ++i) { + var c = colors[i] + for(var j=0; j<3; ++j) { + result[4*i+j] = c[j] + } + result[4*i+3] = c[3]*255 + } + + return ndarray(result, [256,256,4], [4,0,1]) +} + +function unpackIntensity(cells, numVerts, cellIntensity) { + var result = new Array(numVerts) + for(var i=0; i= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.drawTransparent = proto.draw = function(cameraParams) { - var gl = this.gl - var uniforms = this.shader.uniforms - - this.shader.bind() - var view = uniforms.view = cameraParams.view || IDENTITY - var projection = uniforms.projection = cameraParams.projection || IDENTITY - uniforms.model = cameraParams.model || IDENTITY - uniforms.clipBounds = this.clipBounds - uniforms.opacity = this.opacity - - - var cx = view[12] - var cy = view[13] - var cz = view[14] - var cw = view[15] - var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight - - this.vao.bind() - for(var i=0; i<3; ++i) { - gl.lineWidth(this.lineWidth[i]) - uniforms.capSize = this.capSize[i] * pixelScaleF - if (this.lineCount[i]) { - gl.drawArrays(gl.LINES, this.lineOffset[i], this.lineCount[i]) - } - } - this.vao.unbind() -} - -function updateBounds(bounds, point) { - for(var i=0; i<3; ++i) { - bounds[0][i] = Math.min(bounds[0][i], point[i]) - bounds[1][i] = Math.max(bounds[1][i], point[i]) - } -} - -var FACE_TABLE = (function(){ - var table = new Array(3) - for(var d=0; d<3; ++d) { - var row = [] - for(var j=1; j<=2; ++j) { - for(var s=-1; s<=1; s+=2) { - var u = (j+d) % 3 - var y = [0,0,0] - y[u] = s - row.push(y) - } - } - table[d] = row - } - return table -})() - - -function emitFace(verts, x, c, d) { - var offsets = FACE_TABLE[d] - for(var i=0; i 0) { - var x = p.slice() - x[j] += e[1][j] - verts.push(p[0], p[1], p[2], - c[0], c[1], c[2], c[3], - 0, 0, 0, - x[0], x[1], x[2], - c[0], c[1], c[2], c[3], - 0, 0, 0) - updateBounds(this.bounds, x) - vertexCount += 2 + emitFace(verts, x, c, j) - } - } - this.lineCount[j] = vertexCount - this.lineOffset[j] - } - this.buffer.update(verts) - } -} - -proto.dispose = function() { - this.shader.dispose() - this.buffer.dispose() - this.vao.dispose() -} - -function createErrorBars(options) { - var gl = options.gl - var buffer = createBuffer(gl) - var vao = createVAO(gl, [ - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 0, - stride: 40 - }, - { - buffer: buffer, - type: gl.FLOAT, - size: 4, - offset: 12, - stride: 40 - }, - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 28, - stride: 40 - } - ]) - - var shader = createShader(gl) - shader.attributes.position.location = 0 - shader.attributes.color.location = 1 - shader.attributes.offset.location = 2 - - var result = new ErrorBars(gl, buffer, vao, shader) - result.update(options) - return result -} +proto.drawTransparent = proto.draw = function(params) { + params = params || {} + var gl = this.gl + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix -},{"./shaders/index":112,"gl-buffer":104,"gl-vao":167}],112:[function(_dereq_,module,exports){ -'use strict' - -var glslify = _dereq_('glslify') -var createShader = _dereq_('gl-shader') - -var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]) -var fragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]) - -module.exports = function(gl) { - return createShader(gl, vertSrc, fragSrc, null, [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'offset', type: 'vec3'} - ]) -} + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } -},{"gl-shader":148,"glslify":249}],113:[function(_dereq_,module,exports){ -'use strict' + var uniforms = { + model: model, + view: view, + projection: projection, -var createTexture = _dereq_('gl-texture2d') + clipBounds: clipBounds, -module.exports = createFBO + kambient: this.ambientLight, + kdiffuse: this.diffuseLight, + kspecular: this.specularLight, + roughness: this.roughness, + fresnel: this.fresnel, -var colorAttachmentArrays = null -var FRAMEBUFFER_UNSUPPORTED -var FRAMEBUFFER_INCOMPLETE_ATTACHMENT -var FRAMEBUFFER_INCOMPLETE_DIMENSIONS -var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT + eyePosition: [0,0,0], + lightPosition: [0,0,0], -function saveFBOState(gl) { - var fbo = gl.getParameter(gl.FRAMEBUFFER_BINDING) - var rbo = gl.getParameter(gl.RENDERBUFFER_BINDING) - var tex = gl.getParameter(gl.TEXTURE_BINDING_2D) - return [fbo, rbo, tex] + opacity: this.opacity, + + contourColor: this.contourColor, + + texture: 0 + } + + this.texture.bind(0) + + var invCameraMatrix = new Array(16) + multiply(invCameraMatrix, uniforms.view, uniforms.model) + multiply(invCameraMatrix, uniforms.projection, invCameraMatrix) + invert(invCameraMatrix, invCameraMatrix) + + for(var i=0; i<3; ++i) { + uniforms.eyePosition[i] = invCameraMatrix[12+i] / invCameraMatrix[15] + } + + var w = invCameraMatrix[15] + for(var i=0; i<3; ++i) { + w += this.lightPosition[i] * invCameraMatrix[4*i+3] + } + for(var i=0; i<3; ++i) { + var s = invCameraMatrix[12+i] + for(var j=0; j<3; ++j) { + s += invCameraMatrix[4*j+i] * this.lightPosition[j] + } + uniforms.lightPosition[i] = s / w + } + + if(this.triangleCount > 0) { + var shader = this.triShader + shader.bind() + shader.uniforms = uniforms + + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0 && this.lineWidth > 0) { + var shader = this.lineShader + shader.bind() + shader.uniforms = uniforms + + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } + + if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { + var shader = this.contourShader + shader.bind() + shader.uniforms = uniforms + + this.contourVAO.bind() + gl.drawArrays(gl.LINES, 0, this.contourCount) + this.contourVAO.unbind() + } } -function restoreFBOState(gl, data) { - gl.bindFramebuffer(gl.FRAMEBUFFER, data[0]) - gl.bindRenderbuffer(gl.RENDERBUFFER, data[1]) - gl.bindTexture(gl.TEXTURE_2D, data[2]) +proto.drawPick = function(params) { + params = params || {} + + var gl = this.gl + + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix + + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } + + //Save camera parameters + this._model = [].slice.call(model) + this._view = [].slice.call(view) + this._projection = [].slice.call(projection) + this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] + + var uniforms = { + model: model, + view: view, + projection: projection, + clipBounds: clipBounds, + pickId: this.pickId / 255.0, + } + + var shader = this.pickShader + shader.bind() + shader.uniforms = uniforms + + if(this.triangleCount > 0) { + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0) { + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointPickShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } } -function lazyInitColorAttachments(gl, ext) { - var maxColorAttachments = gl.getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL) - colorAttachmentArrays = new Array(maxColorAttachments + 1) - for(var i=0; i<=maxColorAttachments; ++i) { - var x = new Array(maxColorAttachments) - for(var j=0; j 0) { + var base = Math.round(Math.pow(10, y)) + return Math.ceil(x/base) * base } - var result = createTexture(gl, width, height, format, type) - result.magFilter = gl.NEAREST - result.minFilter = gl.NEAREST - result.mipSamples = 1 - result.bind() - gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, result.handle, 0) - return result + return Math.ceil(x) } -//Initialize a render buffer object -function initRenderBuffer(gl, width, height, component, attachment) { - var result = gl.createRenderbuffer() - gl.bindRenderbuffer(gl.RENDERBUFFER, result) - gl.renderbufferStorage(gl.RENDERBUFFER, component, width, height) - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, result) - return result +function defaultBool(x) { + if(typeof x === 'boolean') { + return x + } + return true } -//Rebuild the frame buffer -function rebuildFBO(fbo) { +function createScene(options) { + options = options || {} - //Save FBO state - var state = saveFBOState(fbo.gl) + var stopped = false - var gl = fbo.gl - var handle = fbo.handle = gl.createFramebuffer() - var width = fbo._shape[0] - var height = fbo._shape[1] - var numColors = fbo.color.length - var ext = fbo._ext - var useStencil = fbo._useStencil - var useDepth = fbo._useDepth - var colorType = fbo._colorType + var pixelRatio = options.pixelRatio || parseFloat(window.devicePixelRatio) - //Bind the fbo - gl.bindFramebuffer(gl.FRAMEBUFFER, handle) + var canvas = options.canvas + if(!canvas) { + canvas = document.createElement('canvas') + if(options.container) { + var container = options.container + container.appendChild(canvas) + } else { + document.body.appendChild(canvas) + } + } - //Allocate color buffers - for(var i=0; i 0 && pickBufferCount[numPick-1] === 0) { + pickBufferCount.pop() + pickBuffers.pop().dispose() + } + } + + scene.update = function(options) { + if(stopped) { + return + } + options = options || {} + dirty = true + pickDirty = true + } + + scene.add = function(obj) { + if(stopped) { + return + } + obj.axes = axes + objects.push(obj) + pickBufferIds.push(-1) + dirty = true + pickDirty = true + reallocPickIds() + } + + scene.remove = function(obj) { + if(stopped) { + return + } + var idx = objects.indexOf(obj) + if(idx < 0) { + return + } + objects.splice(idx, 1) + pickBufferIds.pop() + dirty = true + pickDirty = true + reallocPickIds() + } + + scene.dispose = function() { + if(stopped) { + return + } + + stopped = true + + window.removeEventListener('resize', resizeListener) + canvas.removeEventListener('webglcontextlost', checkContextLoss) + scene.mouseListener.enabled = false + + if(scene.contextLost) { + return + } + + //Destroy objects + axes.dispose() + spikes.dispose() + for(var i=0; i selection.distance) { + continue + } + for(var j=0; j 1) { - ext.drawBuffersWEBGL(colorAttachmentArrays[numColors]) } - //Allocate depth/stencil buffers - var WEBGL_depth_texture = gl.getExtension('WEBGL_depth_texture') - if(WEBGL_depth_texture) { - if(useStencil) { - fbo.depth = initTexture(gl, width, height, - WEBGL_depth_texture.UNSIGNED_INT_24_8_WEBGL, - gl.DEPTH_STENCIL, - gl.DEPTH_STENCIL_ATTACHMENT) - } else if(useDepth) { - fbo.depth = initTexture(gl, width, height, - gl.UNSIGNED_SHORT, - gl.DEPTH_COMPONENT, - gl.DEPTH_ATTACHMENT) + canvas.addEventListener('webglcontextlost', checkContextLoss) + + //Render the scene for mouse picking + function renderPick() { + if(checkContextLoss()) { + return } - } else { - if(useDepth && useStencil) { - fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_STENCIL, gl.DEPTH_STENCIL_ATTACHMENT) - } else if(useDepth) { - fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_COMPONENT16, gl.DEPTH_ATTACHMENT) - } else if(useStencil) { - fbo._depth_rb = initRenderBuffer(gl, width, height, gl.STENCIL_INDEX, gl.STENCIL_ATTACHMENT) + + gl.colorMask(true, true, true, true) + gl.depthMask(true) + gl.disable(gl.BLEND) + gl.enable(gl.DEPTH_TEST) + + var numObjs = objects.length + var numPick = pickBuffers.length + for(var j=0; j maxFBOSize || - h < 0 || h > maxFBOSize) { - throw new Error('gl-fbo: Can\'t resize FBO, invalid dimensions') - } + //Call render callback + if(scene.onrender) { + scene.onrender() + } - //Update shape - fbo._shape[0] = w - fbo._shape[1] = h + //Read value + gl.bindFramebuffer(gl.FRAMEBUFFER, null) + gl.viewport(0, 0, width, height) - //Save framebuffer state - var state = saveFBOState(gl) + //General strategy: 3 steps + // 1. render non-transparent objects + // 2. accumulate transparent objects into separate fbo + // 3. composite final scene - //Resize framebuffer attachments - for(var i=0; i maxFBOSize || height < 0 || height > maxFBOSize) { - throw new Error('gl-fbo: Parameters are too large for FBO') + //Clear dirty flags + dirty = false + for(var i=0; i 1) { - //Check if multiple render targets supported - if(!WEBGL_draw_buffers) { - throw new Error('gl-fbo: Multiple draw buffer extension not supported') - } else if(numColors > gl.getParameter(WEBGL_draw_buffers.MAX_COLOR_ATTACHMENTS_WEBGL)) { - throw new Error('gl-fbo: Context does not support ' + numColors + ' draw buffers') - } + //Draw the whole scene + function render() { + if(stopped || scene.contextLost) { + return } + // this order is important: ios safari sometimes has sync raf + redraw() + requestAnimationFrame(render) } + render() - //Determine whether to use floating point textures - var colorType = gl.UNSIGNED_BYTE - var OES_texture_float = gl.getExtension('OES_texture_float') - if(options.float && numColors > 0) { - if(!OES_texture_float) { - throw new Error('gl-fbo: Context does not support floating point textures') - } - colorType = gl.FLOAT - } else if(options.preferFloat && numColors > 0) { - if(OES_texture_float) { - colorType = gl.FLOAT + //Force redraw of whole scene + scene.redraw = function() { + if(stopped) { + return } + dirty = true + redraw() } - //Check if we should use depth buffer - var useDepth = true - if('depth' in options) { - useDepth = !!options.depth - } + return scene +} - //Check if we should use a stencil buffer - var useStencil = false - if('stencil' in options) { - useStencil = !!options.stencil +},{"./lib/shader":140,"3d-view-controls":10,"a-big-triangle":12,"gl-axes3d":96,"gl-axes3d/properties":103,"gl-fbo":113,"gl-mat4/perspective":128,"gl-select-static":147,"gl-spikes3d":156,"is-mobile":259,"mouse-change":270}],142:[function(_dereq_,module,exports){ +module.exports = slerp + +/** + * Performs a spherical linear interpolation between two quat + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @param {Number} t interpolation amount between the two inputs + * @returns {quat} out + */ +function slerp (out, a, b, t) { + // benchmarks: + // http://jsperf.com/quaternion-slerp-implementations + + var ax = a[0], ay = a[1], az = a[2], aw = a[3], + bx = b[0], by = b[1], bz = b[2], bw = b[3] + + var omega, cosom, sinom, scale0, scale1 + + // calc cosine + cosom = ax * bx + ay * by + az * bz + aw * bw + // adjust signs (if necessary) + if (cosom < 0.0) { + cosom = -cosom + bx = -bx + by = -by + bz = -bz + bw = -bw + } + // calculate coefficients + if ((1.0 - cosom) > 0.000001) { + // standard case (slerp) + omega = Math.acos(cosom) + sinom = Math.sin(omega) + scale0 = Math.sin((1.0 - t) * omega) / sinom + scale1 = Math.sin(t * omega) / sinom + } else { + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + scale0 = 1.0 - t + scale1 = t } + // calculate final values + out[0] = scale0 * ax + scale1 * bx + out[1] = scale0 * ay + scale1 * by + out[2] = scale0 * az + scale1 * bz + out[3] = scale0 * aw + scale1 * bw - return new Framebuffer( - gl, - width, - height, - colorType, - numColors, - useDepth, - useStencil, - WEBGL_draw_buffers) + return out } -},{"gl-texture2d":163}],114:[function(_dereq_,module,exports){ - -var sprintf = _dereq_('sprintf-js').sprintf; -var glConstants = _dereq_('gl-constants/lookup'); -var shaderName = _dereq_('glsl-shader-name'); -var addLineNumbers = _dereq_('add-line-numbers'); +},{}],143:[function(_dereq_,module,exports){ +'use strict'; -module.exports = formatCompilerError; +module.exports = function(a){ + return (!a && a !== 0) ? '' : a.toString(); +} -function formatCompilerError(errLog, src, type) { - "use strict"; +},{}],144:[function(_dereq_,module,exports){ +"use strict" - var name = shaderName(src) || 'of unknown name (see npm glsl-shader-name)'; +var vectorizeText = _dereq_("vectorize-text") - var typeName = 'unknown type'; - if (type !== undefined) { - typeName = type === glConstants.FRAGMENT_SHADER ? 'fragment' : 'vertex' - } +module.exports = getGlyph - var longForm = sprintf('Error compiling %s shader %s:\n', typeName, name); - var shortForm = sprintf("%s%s", longForm, errLog); +var GLYPH_CACHE = {} - var errorStrings = errLog.split('\n'); - var errors = {}; +function getGlyph(symbol, font) { + var fontCache = GLYPH_CACHE[font] + if(!fontCache) { + fontCache = GLYPH_CACHE[font] = {} + } + if(symbol in fontCache) { + return fontCache[symbol] + } - for (var i = 0; i < errorStrings.length; i++) { - var errorString = errorStrings[i]; - if (errorString === '' || errorString === "\0") continue; - var lineNo = parseInt(errorString.split(':')[2]); - if (isNaN(lineNo)) { - throw new Error(sprintf('Could not parse error: %s', errorString)); - } - errors[lineNo] = errorString; + var config = { + textAlign: "center", + textBaseline: "middle", + lineHeight: 1.0, + font: font, + lineSpacing: 1.25, + styletags: { + breaklines:true, + bolds: true, + italics: true, + subscripts:true, + superscripts:true } + } - var lines = addLineNumbers(src).split('\n'); + //Get line and triangle meshes for glyph + config.triangles = true; + var triSymbol = vectorizeText(symbol, config) + config.triangles = false; + var lineSymbol = vectorizeText(symbol, config) - for (var i = 0; i < lines.length; i++) { - if (!errors[i+3] && !errors[i+2] && !errors[i+1]) continue; - var line = lines[i]; - longForm += line + '\n'; - if (errors[i+1]) { - var e = errors[i+1]; - e = e.substr(e.split(':', 3).join(':').length + 1).trim(); - longForm += sprintf('^^^ %s\n\n', e); - } + //Calculate bounding box + var bounds = [[Infinity,Infinity], [-Infinity,-Infinity]] + var n = lineSymbol.positions.length + for(var i = 0; i < n; ++i) { + var p = lineSymbol.positions[i] + for(var j=0; j<2; ++j) { + bounds[0][j] = Math.min(bounds[0][j], p[j]) + bounds[1][j] = Math.max(bounds[1][j], p[j]) } + } - return { - long: longForm.trim(), - short: shortForm.trim() - }; + //Save cached symbol + return fontCache[symbol] = [triSymbol, lineSymbol, bounds] } +},{"vectorize-text":350}],145:[function(_dereq_,module,exports){ +var createShaderWrapper = _dereq_('gl-shader') +var glslify = _dereq_('glslify') - -},{"add-line-numbers":13,"gl-constants/lookup":110,"glsl-shader-name":241,"sprintf-js":339}],115:[function(_dereq_,module,exports){ -var glslify = _dereq_('glslify') -var createShader = _dereq_('gl-shader') - -var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvec4 project(vec3 p) {\n return projection * view * model * vec4(p, 1.0);\n}\n\nvoid main() {\n vec4 startPoint = project(position);\n vec4 endPoint = project(nextPosition);\n\n vec2 A = startPoint.xy / startPoint.w;\n vec2 B = endPoint.xy / endPoint.w;\n\n float clipAngle = atan(\n (B.y - A.y) * screenShape.y,\n (B.x - A.x) * screenShape.x\n );\n\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(\n sin(clipAngle),\n -cos(clipAngle)\n ) / screenShape;\n\n gl_Position = vec4(startPoint.xy + startPoint.w * offset, startPoint.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n"]) -var forwardFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]) -var pickFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1540259130(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1540259130(pixelArcLength).xyz);\n}"]) +var perspectiveVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) +var orthographicVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) +var projectionVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]) +var drawFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]) var ATTRIBUTES = [ {name: 'position', type: 'vec3'}, - {name: 'nextPosition', type: 'vec3'}, - {name: 'arcLength', type: 'float'}, - {name: 'lineWidth', type: 'float'}, - {name: 'color', type: 'vec4'} + {name: 'color', type: 'vec4'}, + {name: 'glyph', type: 'vec2'}, + {name: 'id', type: 'vec4'} ] -exports.createShader = function(gl) { - return createShader(gl, vertSrc, forwardFrag, null, ATTRIBUTES) +var perspective = { + vertex: perspectiveVertSrc, + fragment: drawFragSrc, + attributes: ATTRIBUTES + }, + ortho = { + vertex: orthographicVertSrc, + fragment: drawFragSrc, + attributes: ATTRIBUTES + }, + project = { + vertex: projectionVertSrc, + fragment: drawFragSrc, + attributes: ATTRIBUTES + }, + pickPerspective = { + vertex: perspectiveVertSrc, + fragment: pickFragSrc, + attributes: ATTRIBUTES + }, + pickOrtho = { + vertex: orthographicVertSrc, + fragment: pickFragSrc, + attributes: ATTRIBUTES + }, + pickProject = { + vertex: projectionVertSrc, + fragment: pickFragSrc, + attributes: ATTRIBUTES + } + +function createShader(gl, src) { + var shader = createShaderWrapper(gl, src) + var attr = shader.attributes + attr.position.location = 0 + attr.color.location = 1 + attr.glyph.location = 2 + attr.id.location = 3 + return shader } -exports.createPickShader = function(gl) { - return createShader(gl, vertSrc, pickFrag, null, ATTRIBUTES) +exports.createPerspective = function(gl) { + return createShader(gl, perspective) +} +exports.createOrtho = function(gl) { + return createShader(gl, ortho) +} +exports.createProject = function(gl) { + return createShader(gl, project) +} +exports.createPickPerspective = function(gl) { + return createShader(gl, pickPerspective) +} +exports.createPickOrtho = function(gl) { + return createShader(gl, pickOrtho) +} +exports.createPickProject = function(gl) { + return createShader(gl, pickProject) } -},{"gl-shader":148,"glslify":249}],116:[function(_dereq_,module,exports){ +},{"gl-shader":148,"glslify":249}],146:[function(_dereq_,module,exports){ 'use strict' -module.exports = createLinePlot +var isAllBlank = _dereq_('is-string-blank') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var pool = _dereq_('typedarray-pool') +var mat4mult = _dereq_('gl-mat4/multiply') +var shaders = _dereq_('./lib/shaders') +var getGlyph = _dereq_('./lib/glyphs') +var getSimpleString = _dereq_('./lib/get-simple-string') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var unpackFloat = _dereq_('glsl-read-float') -var bsearch = _dereq_('binary-search-bounds') -var ndarray = _dereq_('ndarray') -var shaders = _dereq_('./lib/shaders') +var IDENTITY = [1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] -var createShader = shaders.createShader -var createPickShader = shaders.createPickShader +module.exports = createPointCloud -var identity = [1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1] +function transformMat4(x, m) { + var x0 = x[0] + var x1 = x[1] + var x2 = x[2] + var x3 = x[3] + x[0] = m[0] * x0 + m[4] * x1 + m[8] * x2 + m[12] * x3 + x[1] = m[1] * x0 + m[5] * x1 + m[9] * x2 + m[13] * x3 + x[2] = m[2] * x0 + m[6] * x1 + m[10] * x2 + m[14] * x3 + x[3] = m[3] * x0 + m[7] * x1 + m[11] * x2 + m[15] * x3 + return x +} -function distance (a, b) { - var s = 0.0 - for (var i = 0; i < 3; ++i) { - var d = a[i] - b[i] - s += d * d - } - return Math.sqrt(s) +function project(p, v, m, x) { + transformMat4(x, x, m) + transformMat4(x, x, v) + return transformMat4(x, x, p) } -function filterClipBounds (bounds) { - var result = [[-1e6, -1e6, -1e6], [1e6, 1e6, 1e6]] - for (var i = 0; i < 3; ++i) { - result[0][i] = Math.max(bounds[0][i], result[0][i]) - result[1][i] = Math.min(bounds[1][i], result[1][i]) +function clampVec(v) { + var result = new Array(3) + for(var i=0; i<3; ++i) { + result[i] = Math.min(Math.max(v[i], -1e8), 1e8) } return result } -function PickResult (tau, position, index, dataCoordinate) { - this.arcLength = tau - this.position = position +function ScatterPlotPickResult(index, position) { this.index = index - this.dataCoordinate = dataCoordinate -} - -function LinePlot (gl, shader, pickShader, buffer, vao, texture) { - this.gl = gl - this.shader = shader - this.pickShader = pickShader - this.buffer = buffer - this.vao = vao - this.clipBounds = [ - [ -Infinity, -Infinity, -Infinity ], - [ Infinity, Infinity, Infinity ]] - this.points = [] - this.arcLength = [] - this.vertexCount = 0 - this.bounds = [[0, 0, 0], [0, 0, 0]] - this.pickId = 0 - this.lineWidth = 1 - this.texture = texture - this.dashScale = 1 - this.opacity = 1 - this.dirty = true - this.pixelRatio = 1 -} - -var proto = LinePlot.prototype - -proto.isTransparent = function () { - return this.opacity < 1 -} - -proto.isOpaque = function () { - return this.opacity >= 1 + this.dataCoordinate = this.position = position } -proto.pickSlots = 1 +var MAX_OPACITY = 1 -proto.setPickBase = function (id) { - this.pickId = id +function fixOpacity(a) { + if(a === true) return MAX_OPACITY + if(a > MAX_OPACITY) return MAX_OPACITY + return a } -proto.drawTransparent = proto.draw = function (camera) { - if (!this.vertexCount) return - var gl = this.gl - var shader = this.shader - var vao = this.vao - shader.bind() - shader.uniforms = { - model: camera.model || identity, - view: camera.view || identity, - projection: camera.projection || identity, - clipBounds: filterClipBounds(this.clipBounds), - dashTexture: this.texture.bind(), - dashScale: this.dashScale / this.arcLength[this.arcLength.length - 1], - opacity: this.opacity, - screenShape: [gl.drawingBufferWidth, gl.drawingBufferHeight], - pixelRatio: this.pixelRatio - } - vao.bind() - vao.draw(gl.TRIANGLE_STRIP, this.vertexCount) - vao.unbind() -} +function PointCloud( + gl, + shader, + orthoShader, + projectShader, + pointBuffer, + colorBuffer, + glyphBuffer, + idBuffer, + vao, + pickPerspectiveShader, + pickOrthoShader, + pickProjectShader) { -proto.drawPick = function (camera) { - if (!this.vertexCount) return - var gl = this.gl - var shader = this.pickShader - var vao = this.vao - shader.bind() - shader.uniforms = { - model: camera.model || identity, - view: camera.view || identity, - projection: camera.projection || identity, - pickId: this.pickId, - clipBounds: filterClipBounds(this.clipBounds), - screenShape: [gl.drawingBufferWidth, gl.drawingBufferHeight], - pixelRatio: this.pixelRatio - } - vao.bind() - vao.draw(gl.TRIANGLE_STRIP, this.vertexCount) - vao.unbind() -} + this.gl = gl -proto.update = function (options) { - var i, j + this.pixelRatio = 1 - this.dirty = true + this.shader = shader + this.orthoShader = orthoShader + this.projectShader = projectShader - var connectGaps = !!options.connectGaps + this.pointBuffer = pointBuffer + this.colorBuffer = colorBuffer + this.glyphBuffer = glyphBuffer + this.idBuffer = idBuffer + this.vao = vao + this.vertexCount = 0 + this.lineVertexCount = 0 - if ('dashScale' in options) { - this.dashScale = options.dashScale - } - if ('opacity' in options) { - this.opacity = +options.opacity - } + this.opacity = MAX_OPACITY - // Recalculate buffer data - var buffer = [] - var arcLengthArray = [] - var pointArray = [] - var arcLength = 0.0 - var vertexCount = 0 - var bounds = [ - [ Infinity, Infinity, Infinity ], - [ -Infinity, -Infinity, -Infinity ]] + this.lineWidth = 0 + this.projectScale = [2.0/3.0, 2.0/3.0, 2.0/3.0] + this.projectOpacity = [MAX_OPACITY, MAX_OPACITY, MAX_OPACITY] - var positions = options.position || options.positions - if (positions) { + this.pickId = 0 + this.pickPerspectiveShader = pickPerspectiveShader + this.pickOrthoShader = pickOrthoShader + this.pickProjectShader = pickProjectShader + this.points = [] - // Default color - var colors = options.color || options.colors || [0, 0, 0, 1] + this._selectResult = new ScatterPlotPickResult(0, [0,0,0]) - var lineWidth = options.lineWidth || 1 + this.useOrtho = true + this.bounds = [[ Infinity,Infinity,Infinity], + [-Infinity,-Infinity,-Infinity]] - var hadGap = false + //Axes projections + this.axesProject = [ true, true, true ] + this.axesBounds = [[-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity]] - fill_loop: - for (i = 1; i < positions.length; ++i) { - var a = positions[i - 1] - var b = positions[i] + this.highlightId = [1,1,1,1] + this.highlightScale = 2 - arcLengthArray.push(arcLength) - pointArray.push(a.slice()) + this.clipBounds = [[-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity]] - for (j = 0; j < 3; ++j) { - if (isNaN(a[j]) || isNaN(b[j]) || - !isFinite(a[j]) || !isFinite(b[j])) { + this.dirty = true +} - if (!connectGaps && buffer.length > 0) { - for (var k = 0; k < 24; ++k) { - buffer.push(buffer[buffer.length - 12]) - } - vertexCount += 2 - hadGap = true - } +var proto = PointCloud.prototype - continue fill_loop - } - bounds[0][j] = Math.min(bounds[0][j], a[j], b[j]) - bounds[1][j] = Math.max(bounds[1][j], a[j], b[j]) - } +proto.pickSlots = 1 - var acolor, bcolor - if (Array.isArray(colors[0])) { - acolor = (colors.length > i - 1) ? colors[i - 1] : // using index value - (colors.length > 0) ? colors[colors.length - 1] : // using last item - [0, 0, 0, 1]; // using black +proto.setPickBase = function(pickBase) { + this.pickId = pickBase +} - bcolor = (colors.length > i) ? colors[i] : // using index value - (colors.length > 0) ? colors[colors.length - 1] : // using last item - [0, 0, 0, 1]; // using black - } else { - acolor = bcolor = colors - } +proto.isTransparent = function() { + if(this.opacity < MAX_OPACITY) { + return true + } + for(var i=0; i<3; ++i) { + if(this.axesProject[i] && this.projectOpacity[i] < MAX_OPACITY) { + return true + } + } + return false +} - if (acolor.length === 3) { - acolor = [acolor[0], acolor[1], acolor[2], 1] - } - if (bcolor.length === 3) { - bcolor = [bcolor[0], bcolor[1], bcolor[2], 1] - } +proto.isOpaque = function() { + if(this.opacity >= MAX_OPACITY) { + return true + } + for(var i=0; i<3; ++i) { + if(this.axesProject[i] && this.projectOpacity[i] >= MAX_OPACITY) { + return true + } + } + return false +} - var w0 - if (Array.isArray(lineWidth)) { - w0 = (lineWidth.length > i - 1) ? lineWidth[i - 1] : // using index value - (lineWidth.length > 0) ? lineWidth[lineWidth.length - 1] : // using last item - [0, 0, 0, 1]; // using black - } else { - w0 = lineWidth - } +var VIEW_SHAPE = [0,0] +var U_VEC = [0,0,0] +var V_VEC = [0,0,0] +var MU_VEC = [0,0,0,1] +var MV_VEC = [0,0,0,1] +var SCRATCH_MATRIX = IDENTITY.slice() +var SCRATCH_VEC = [0,0,0] +var CLIP_BOUNDS = [[0,0,0], [0,0,0]] - var t0 = arcLength - arcLength += distance(a, b) +function zeroVec(a) { + a[0] = a[1] = a[2] = 0 + return a +} - if (hadGap) { - for (j = 0; j < 2; ++j) { - buffer.push( - a[0], a[1], a[2], b[0], b[1], b[2], t0, w0, acolor[0], acolor[1], acolor[2], acolor[3]) - } - vertexCount += 2 - hadGap = false - } +function augment(hg, af) { + hg[0] = af[0] + hg[1] = af[1] + hg[2] = af[2] + hg[3] = 1 + return hg +} - buffer.push( - a[0], a[1], a[2], b[0], b[1], b[2], t0, w0, acolor[0], acolor[1], acolor[2], acolor[3], - a[0], a[1], a[2], b[0], b[1], b[2], t0, -w0, acolor[0], acolor[1], acolor[2], acolor[3], - b[0], b[1], b[2], a[0], a[1], a[2], arcLength, -w0, bcolor[0], bcolor[1], bcolor[2], bcolor[3], - b[0], b[1], b[2], a[0], a[1], a[2], arcLength, w0, bcolor[0], bcolor[1], bcolor[2], bcolor[3]) +function setComponent(out, v, i, x) { + out[0] = v[0] + out[1] = v[1] + out[2] = v[2] + out[i] = x + return out +} - vertexCount += 4 +function getClipBounds(bounds) { + var result = CLIP_BOUNDS + for(var i=0; i<2; ++i) { + for(var j=0; j<3; ++j) { + result[i][j] = Math.max(Math.min(bounds[i][j], 1e8), -1e8) } } - this.buffer.update(buffer) + return result +} - arcLengthArray.push(arcLength) - pointArray.push(positions[positions.length - 1].slice()) +function drawProject(shader, points, camera) { + var axesProject = points.axesProject - this.bounds = bounds + var gl = points.gl + var uniforms = shader.uniforms + var model = camera.model || IDENTITY + var view = camera.view || IDENTITY + var projection = camera.projection || IDENTITY + var bounds = points.axesBounds + var clipBounds = getClipBounds(points.clipBounds) - this.vertexCount = vertexCount + var cubeAxis + if(points.axes && points.axes.lastCubeProps) { + cubeAxis = points.axes.lastCubeProps.axis + } else { + cubeAxis = [1,1,1] + } - this.points = pointArray - this.arcLength = arcLengthArray + VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth + VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight - if ('dashes' in options) { - var dashArray = options.dashes + shader.bind() + uniforms.view = view + uniforms.projection = projection + uniforms.screenSize = VIEW_SHAPE + uniforms.highlightId = points.highlightId + uniforms.highlightScale = points.highlightScale + uniforms.clipBounds = clipBounds + uniforms.pickGroup = points.pickId / 255.0 + uniforms.pixelRatio = points.pixelRatio - // Calculate prefix sum - var prefixSum = dashArray.slice() - prefixSum.unshift(0) - for (i = 1; i < prefixSum.length; ++i) { - prefixSum[i] = prefixSum[i - 1] + prefixSum[i] + for(var i=0; i<3; ++i) { + if(!axesProject[i]) { + continue } - var dashTexture = ndarray(new Array(256 * 4), [256, 1, 4]) - for (i = 0; i < 256; ++i) { - for (j = 0; j < 4; ++j) { - dashTexture.set(i, 0, j, 0) - } - if (bsearch.le(prefixSum, prefixSum[prefixSum.length - 1] * i / 255.0) & 1) { - dashTexture.set(i, 0, 0, 0) - } else { - dashTexture.set(i, 0, 0, 255) - } - } + uniforms.scale = points.projectScale[i] + uniforms.opacity = points.projectOpacity[i] - this.texture.setPixels(dashTexture) - } -} + //Project model matrix + var pmodel = SCRATCH_MATRIX + for(var j=0; j<16; ++j) { + pmodel[j] = 0 + } + for(var j=0; j<4; ++j) { + pmodel[5*j] = 1 + } + pmodel[5*i] = 0 + if(cubeAxis[i] < 0) { + pmodel[12+i] = bounds[0][i] + } else { + pmodel[12+i] = bounds[1][i] + } + mat4mult(pmodel, model, pmodel) + uniforms.model = pmodel -proto.dispose = function () { - this.shader.dispose() - this.vao.dispose() - this.buffer.dispose() -} + //Compute initial axes + var u = (i+1)%3 + var v = (i+2)%3 + var du = zeroVec(U_VEC) + var dv = zeroVec(V_VEC) + du[u] = 1 + dv[v] = 1 -proto.pick = function (selection) { - if (!selection) { - return null - } - if (selection.id !== this.pickId) { - return null - } - var tau = unpackFloat( - selection.value[0], - selection.value[1], - selection.value[2], - 0) - var index = bsearch.le(this.arcLength, tau) - if (index < 0) { - return null - } - if (index === this.arcLength.length - 1) { - return new PickResult( - this.arcLength[this.arcLength.length - 1], - this.points[this.points.length - 1].slice(), - index) - } - var a = this.points[index] - var b = this.points[Math.min(index + 1, this.points.length - 1)] - var t = (tau - this.arcLength[index]) / (this.arcLength[index + 1] - this.arcLength[index]) - var ti = 1.0 - t - var x = [0, 0, 0] - for (var i = 0; i < 3; ++i) { - x[i] = ti * a[i] + t * b[i] - } - var dataIndex = Math.min((t < 0.5) ? index : (index + 1), this.points.length - 1) - return new PickResult( - tau, - x, - dataIndex, - this.points[dataIndex]) -} + //Align orientation relative to viewer + var mdu = project(projection, view, model, augment(MU_VEC, du)) + var mdv = project(projection, view, model, augment(MV_VEC, dv)) + if(Math.abs(mdu[1]) > Math.abs(mdv[1])) { + var tmp = mdu + mdu = mdv + mdv = tmp + tmp = du + du = dv + dv = tmp + var t = u + u = v + v = t + } + if(mdu[0] < 0) { + du[u] = -1 + } + if(mdv[1] > 0) { + dv[v] = -1 + } + var su = 0.0 + var sv = 0.0 + for(var j=0; j<4; ++j) { + su += Math.pow(model[4*u+j], 2) + sv += Math.pow(model[4*v+j], 2) + } + du[u] /= Math.sqrt(su) + dv[v] /= Math.sqrt(sv) + uniforms.axes[0] = du + uniforms.axes[1] = dv -function createLinePlot (options) { - var gl = options.gl || (options.scene && options.scene.gl) + //Update fragment clip bounds + uniforms.fragClipBounds[0] = setComponent(SCRATCH_VEC, clipBounds[0], i, -1e8) + uniforms.fragClipBounds[1] = setComponent(SCRATCH_VEC, clipBounds[1], i, 1e8) - var shader = createShader(gl) - shader.attributes.position.location = 0 - shader.attributes.nextPosition.location = 1 - shader.attributes.arcLength.location = 2 - shader.attributes.lineWidth.location = 3 - shader.attributes.color.location = 4 + points.vao.bind() - var pickShader = createPickShader(gl) - pickShader.attributes.position.location = 0 - pickShader.attributes.nextPosition.location = 1 - pickShader.attributes.arcLength.location = 2 - pickShader.attributes.lineWidth.location = 3 - pickShader.attributes.color.location = 4 + //Draw interior + points.vao.draw(gl.TRIANGLES, points.vertexCount) - var buffer = createBuffer(gl) - var vao = createVAO(gl, [ - { - 'buffer': buffer, - 'size': 3, - 'offset': 0, - 'stride': 48 - }, - { - 'buffer': buffer, - 'size': 3, - 'offset': 12, - 'stride': 48 - }, - { - 'buffer': buffer, - 'size': 1, - 'offset': 24, - 'stride': 48 - }, - { - 'buffer': buffer, - 'size': 1, - 'offset': 28, - 'stride': 48 - }, - { - 'buffer': buffer, - 'size': 4, - 'offset': 32, - 'stride': 48 + //Draw edges + if(points.lineWidth > 0) { + gl.lineWidth(points.lineWidth) + points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) } - ]) - // Create texture for dash pattern - var defaultTexture = ndarray(new Array(256 * 4), [256, 1, 4]) - for (var i = 0; i < 256 * 4; ++i) { - defaultTexture.data[i] = 255 + points.vao.unbind() } - var texture = createTexture(gl, defaultTexture) - texture.wrap = gl.REPEAT - - var linePlot = new LinePlot(gl, shader, pickShader, buffer, vao, texture) - linePlot.update(options) - return linePlot } -},{"./lib/shaders":115,"binary-search-bounds":36,"gl-buffer":104,"gl-texture2d":163,"gl-vao":167,"glsl-read-float":240,"ndarray":285}],117:[function(_dereq_,module,exports){ -module.exports = invert -/** - * Inverts a mat2 - * - * @alias mat2.invert - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out - */ -function invert(out, a) { - var a0 = a[0] - var a1 = a[1] - var a2 = a[2] - var a3 = a[3] - var det = a0 * a3 - a2 * a1 +var NEG_INFINITY3 = [-1e8, -1e8, -1e8] +var POS_INFINITY3 = [1e8, 1e8, 1e8] +var CLIP_GROUP = [NEG_INFINITY3, POS_INFINITY3] - if (!det) return null - det = 1.0 / det +function drawFull(shader, pshader, points, camera, transparent, forceDraw) { + var gl = points.gl - out[0] = a3 * det - out[1] = -a1 * det - out[2] = -a2 * det - out[3] = a0 * det - return out -} -},{}],118:[function(_dereq_,module,exports){ -module.exports = invert + if(transparent === (points.projectOpacity < MAX_OPACITY) || forceDraw) { + drawProject(pshader, points, camera) + } -/** - * Inverts a mat3 - * - * @alias mat3.invert - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out - */ -function invert(out, a) { - var a00 = a[0], a01 = a[1], a02 = a[2] - var a10 = a[3], a11 = a[4], a12 = a[5] - var a20 = a[6], a21 = a[7], a22 = a[8] + if(transparent === (points.opacity < MAX_OPACITY) || forceDraw) { - var b01 = a22 * a11 - a12 * a21 - var b11 = -a22 * a10 + a12 * a20 - var b21 = a21 * a10 - a11 * a20 + shader.bind() + var uniforms = shader.uniforms - // Calculate the determinant - var det = a00 * b01 + a01 * b11 + a02 * b21 + uniforms.model = camera.model || IDENTITY + uniforms.view = camera.view || IDENTITY + uniforms.projection = camera.projection || IDENTITY - if (!det) return null - det = 1.0 / det + VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth + VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight + uniforms.screenSize = VIEW_SHAPE - out[0] = b01 * det - out[1] = (-a22 * a01 + a02 * a21) * det - out[2] = (a12 * a01 - a02 * a11) * det - out[3] = b11 * det - out[4] = (a22 * a00 - a02 * a20) * det - out[5] = (-a12 * a00 + a02 * a10) * det - out[6] = b21 * det - out[7] = (-a21 * a00 + a01 * a20) * det - out[8] = (a11 * a00 - a01 * a10) * det + uniforms.highlightId = points.highlightId + uniforms.highlightScale = points.highlightScale - return out -} + uniforms.fragClipBounds = CLIP_GROUP + uniforms.clipBounds = points.axes.bounds -},{}],119:[function(_dereq_,module,exports){ -module.exports = clone; + uniforms.opacity = points.opacity + uniforms.pickGroup = points.pickId / 255.0 -/** - * Creates a new mat4 initialized with values from an existing matrix - * - * @param {mat4} a matrix to clone - * @returns {mat4} a new 4x4 matrix - */ -function clone(a) { - var out = new Float32Array(16); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - return out; -}; -},{}],120:[function(_dereq_,module,exports){ -module.exports = create; + uniforms.pixelRatio = points.pixelRatio -/** - * Creates a new identity mat4 - * - * @returns {mat4} a new 4x4 matrix - */ -function create() { - var out = new Float32Array(16); - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -}; -},{}],121:[function(_dereq_,module,exports){ -module.exports = determinant; + points.vao.bind() -/** - * Calculates the determinant of a mat4 - * - * @param {mat4} a the source matrix - * @returns {Number} determinant of a - */ -function determinant(a) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], - a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], - a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], - a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], + //Draw interior + points.vao.draw(gl.TRIANGLES, points.vertexCount) - b00 = a00 * a11 - a01 * a10, - b01 = a00 * a12 - a02 * a10, - b02 = a00 * a13 - a03 * a10, - b03 = a01 * a12 - a02 * a11, - b04 = a01 * a13 - a03 * a11, - b05 = a02 * a13 - a03 * a12, - b06 = a20 * a31 - a21 * a30, - b07 = a20 * a32 - a22 * a30, - b08 = a20 * a33 - a23 * a30, - b09 = a21 * a32 - a22 * a31, - b10 = a21 * a33 - a23 * a31, - b11 = a22 * a33 - a23 * a32; + //Draw edges + if(points.lineWidth > 0) { + gl.lineWidth(points.lineWidth) + points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) + } - // Calculate the determinant - return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; -}; -},{}],122:[function(_dereq_,module,exports){ -module.exports = fromQuat; + points.vao.unbind() + } -/** - * Creates a matrix from a quaternion rotation. - * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @returns {mat4} out - */ -function fromQuat(out, q) { - var x = q[0], y = q[1], z = q[2], w = q[3], - x2 = x + x, - y2 = y + y, - z2 = z + z, - xx = x * x2, - yx = y * x2, - yy = y * y2, - zx = z * x2, - zy = z * y2, - zz = z * z2, - wx = w * x2, - wy = w * y2, - wz = w * z2; +} - out[0] = 1 - yy - zz; - out[1] = yx + wz; - out[2] = zx - wy; - out[3] = 0; +proto.draw = function(camera) { + var shader = this.useOrtho ? this.orthoShader : this.shader + drawFull(shader, this.projectShader, this, camera, false, false) +} - out[4] = yx - wz; - out[5] = 1 - xx - zz; - out[6] = zy + wx; - out[7] = 0; +proto.drawTransparent = function(camera) { + var shader = this.useOrtho ? this.orthoShader : this.shader + drawFull(shader, this.projectShader, this, camera, true, false) +} - out[8] = zx + wy; - out[9] = zy - wx; - out[10] = 1 - xx - yy; - out[11] = 0; +proto.drawPick = function(camera) { + var shader = this.useOrtho ? this.pickOrthoShader : this.pickPerspectiveShader + drawFull(shader, this.pickProjectShader, this, camera, true, true) +} - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +proto.pick = function(selected) { + if(!selected) { + return null + } + if(selected.id !== this.pickId) { + return null + } + var x = selected.value[2] + (selected.value[1]<<8) + (selected.value[0]<<16) + if(x >= this.pointCount || x < 0) { + return null + } - return out; -}; -},{}],123:[function(_dereq_,module,exports){ -module.exports = fromRotationTranslation; + //Unpack result + var coord = this.points[x] + var result = this._selectResult + result.index = x + for(var i=0; i<3; ++i) { + result.position[i] = result.dataCoordinate[i] = coord[i] + } + return result +} -/** - * Creates a matrix from a quaternion rotation and vector translation - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * var quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); - * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {vec3} v Translation vector - * @returns {mat4} out - */ -function fromRotationTranslation(out, q, v) { - // Quaternion math - var x = q[0], y = q[1], z = q[2], w = q[3], - x2 = x + x, - y2 = y + y, - z2 = z + z, +proto.highlight = function(selection) { + if(!selection) { + this.highlightId = [1,1,1,1] + } else { + var pointId = selection.index + var a0 = pointId &0xff + var a1 = (pointId>>8) &0xff + var a2 = (pointId>>16)&0xff + this.highlightId = [a0/255.0, a1/255.0, a2/255.0, 0] + } +} - xx = x * x2, - xy = x * y2, - xz = x * z2, - yy = y * y2, - yz = y * z2, - zz = z * z2, - wx = w * x2, - wy = w * y2, - wz = w * z2; +function get_glyphData(glyphs, index, font) { + var str - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; - - return out; -}; -},{}],124:[function(_dereq_,module,exports){ -module.exports = identity; + // use the data if presented in an array + if(Array.isArray(glyphs)) { + if(index < glyphs.length) { + str = glyphs[index] + } else { + str = undefined + } + } else { + str = glyphs + } -/** - * Set a mat4 to the identity matrix - * - * @param {mat4} out the receiving matrix - * @returns {mat4} out - */ -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -}; -},{}],125:[function(_dereq_,module,exports){ -module.exports = invert; + str = getSimpleString(str) // this would handle undefined cases -/** - * Inverts a mat4 - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -function invert(out, a) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], - a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], - a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], - a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], + var visible = true + if(isAllBlank(str)) { + str = '▼' // Note: this special character may have minimum number of surfaces + visible = false + } - b00 = a00 * a11 - a01 * a10, - b01 = a00 * a12 - a02 * a10, - b02 = a00 * a13 - a03 * a10, - b03 = a01 * a12 - a02 * a11, - b04 = a01 * a13 - a03 * a11, - b05 = a02 * a13 - a03 * a12, - b06 = a20 * a31 - a21 * a30, - b07 = a20 * a32 - a22 * a30, - b08 = a20 * a33 - a23 * a30, - b09 = a21 * a32 - a22 * a31, - b10 = a21 * a33 - a23 * a31, - b11 = a22 * a33 - a23 * a32, + var glyph = getGlyph(str, font) - // Calculate the determinant - det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + return { mesh:glyph[0], + lines:glyph[1], + bounds:glyph[2], + visible:visible }; +} - if (!det) { - return null; - } - det = 1.0 / det; - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; - return out; -}; -},{}],126:[function(_dereq_,module,exports){ -var identity = _dereq_('./identity'); +proto.update = function(options) { + + options = options || {} + + if('perspective' in options) { + this.useOrtho = !options.perspective + } + if('orthographic' in options) { + this.useOrtho = !!options.orthographic + } + if('lineWidth' in options) { + this.lineWidth = options.lineWidth + } + if('project' in options) { + if(Array.isArray(options.project)) { + this.axesProject = options.project + } else { + var v = !!options.project + this.axesProject = [v,v,v] + } + } + if('projectScale' in options) { + if(Array.isArray(options.projectScale)) { + this.projectScale = options.projectScale.slice() + } else { + var s = +options.projectScale + this.projectScale = [s,s,s] + } + } + if('projectOpacity' in options) { + if(Array.isArray(options.projectOpacity)) { + this.projectOpacity = options.projectOpacity.slice() + } else { + var s = +options.projectOpacity + this.projectOpacity = [s,s,s] + } + for(var i=0; i<3; ++i) { + this.projectOpacity[i] = fixOpacity(this.projectOpacity[i]); + } + } + if('opacity' in options) { + this.opacity = fixOpacity(options.opacity) + } + + //Set dirty flag + this.dirty = true -module.exports = lookAt; + //Create new buffers + var points = options.position -/** - * Generates a look-at matrix with the given eye position, focal point, and up axis - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {vec3} eye Position of the viewer - * @param {vec3} center Point the viewer is looking at - * @param {vec3} up vec3 pointing up - * @returns {mat4} out - */ -function lookAt(out, eye, center, up) { - var x0, x1, x2, y0, y1, y2, z0, z1, z2, len, - eyex = eye[0], - eyey = eye[1], - eyez = eye[2], - upx = up[0], - upy = up[1], - upz = up[2], - centerx = center[0], - centery = center[1], - centerz = center[2]; + //Text font + var font = options.font || 'normal' + var alignment = options.alignment || [0,0] - if (Math.abs(eyex - centerx) < 0.000001 && - Math.abs(eyey - centery) < 0.000001 && - Math.abs(eyez - centerz) < 0.000001) { - return identity(out); + var alignmentX; + var alignmentY; + if (alignment.length === 2) { + alignmentX = alignment[0] + alignmentY = alignment[1] + } else { + alignmentX = [] + alignmentY = [] + for (var i = 0; i < alignment.length; ++i) { + alignmentX[i] = alignment[i][0] + alignmentY[i] = alignment[i][1] } + } - z0 = eyex - centerx; - z1 = eyey - centery; - z2 = eyez - centerz; + //Bounds + var lowerBound = [ Infinity, Infinity, Infinity] + var upperBound = [-Infinity,-Infinity,-Infinity] - len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); - z0 *= len; - z1 *= len; - z2 *= len; + //Unpack options + var glyphs = options.glyph + var colors = options.color + var sizes = options.size + var angles = options.angle + var lineColors = options.lineColor - x0 = upy * z2 - upz * z1; - x1 = upz * z0 - upx * z2; - x2 = upx * z1 - upy * z0; - len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); - if (!len) { - x0 = 0; - x1 = 0; - x2 = 0; - } else { - len = 1 / len; - x0 *= len; - x1 *= len; - x2 *= len; - } + //Picking geometry + var pickCounter = -1 - y0 = z1 * x2 - z2 * x1; - y1 = z2 * x0 - z0 * x2; - y2 = z0 * x1 - z1 * x0; + //First do pass to compute buffer sizes + var triVertexCount = 0 + var lineVertexCount = 0 - len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); - if (!len) { - y0 = 0; - y1 = 0; - y2 = 0; - } else { - len = 1 / len; - y0 *= len; - y1 *= len; - y2 *= len; - } + var numPoints = 0; - out[0] = x0; - out[1] = y0; - out[2] = z0; - out[3] = 0; - out[4] = x1; - out[5] = y1; - out[6] = z1; - out[7] = 0; - out[8] = x2; - out[9] = y2; - out[10] = z2; - out[11] = 0; - out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); - out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); - out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); - out[15] = 1; + if(points.length) { - return out; -}; -},{"./identity":124}],127:[function(_dereq_,module,exports){ -module.exports = multiply; + //Count number of points and buffer size + numPoints = points.length -/** - * Multiplies two mat4's - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @returns {mat4} out - */ -function multiply(out, a, b) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], - a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], - a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], - a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + count_loop: + for(var i=0; i 0) { + var triOffset = 0 + var lineOffset = triVertexCount + var color = [0,0,0,1] + var lineColor = [0,0,0,1] - if (Math.abs(len) < 0.000001) { return null; } - - len = 1 / len; - x *= len; - y *= len; - z *= len; + var isColorArray = Array.isArray(colors) && Array.isArray(colors[0]) + var isLineColorArray = Array.isArray(lineColors) && Array.isArray(lineColors[0]) - s = Math.sin(rad); - c = Math.cos(rad); - t = 1 - c; + fill_loop: + for(var i=0; i 0) ? (1 - glyphBounds[0][0]) : + (textOffsetX < 0) ? (1 + glyphBounds[1][0]) : 1; - out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03; - out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13; - out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23; + textOffsetY *= (textOffsetY > 0) ? (1 - glyphBounds[0][1]) : + (textOffsetY < 0) ? (1 + glyphBounds[1][1]) : 1; - out[12] = a00 * x + a10 * y + a20 * z + a[12]; - out[13] = a01 * x + a11 * y + a21 * z + a[13]; - out[14] = a02 * x + a12 * y + a22 * z + a[14]; - out[15] = a03 * x + a13 * y + a23 * z + a[15]; - } + var textOffset = [textOffsetX, textOffsetY] - return out; -}; -},{}],135:[function(_dereq_,module,exports){ -module.exports = transpose; + //Write out inner marker + var cells = glyphMesh.cells || [] + var verts = glyphMesh.positions || [] -/** - * Transpose the values of a mat4 - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -function transpose(out, a) { - // If we are transposing ourselves we can skip a few steps but have to cache some values - if (out === a) { - var a01 = a[1], a02 = a[2], a03 = a[3], - a12 = a[6], a13 = a[7], - a23 = a[11]; + for(var j=0; j max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]) -var edgeVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]) -var edgeFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) -var pointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]) -var pointFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) -var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) -var pickPointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]) -var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]) -var contourFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]) - -exports.meshShader = { - vertex: triVertSrc, - fragment: triFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'normal', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'} - ] -} -exports.wireShader = { - vertex: edgeVertSrc, - fragment: edgeFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'} - ] -} -exports.pointShader = { - vertex: pointVertSrc, - fragment: pointFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'}, - {name: 'pointSize', type: 'float'} - ] -} -exports.pickShader = { - vertex: pickVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'id', type: 'vec4'} - ] -} -exports.pointPickShader = { - vertex: pickPointVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'pointSize', type: 'float'}, - {name: 'id', type: 'vec4'} - ] -} -exports.contourShader = { - vertex: contourVertSrc, - fragment: contourFragSrc, - attributes: [ - {name: 'position', type: 'vec3'} - ] -} -},{"glslify":249}],139:[function(_dereq_,module,exports){ -'use strict' - -var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small -var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var normals = _dereq_('normals') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var ndarray = _dereq_('ndarray') -var colormap = _dereq_('colormap') -var getContour = _dereq_('simplicial-complex-contour') -var pool = _dereq_('typedarray-pool') -var shaders = _dereq_('./lib/shaders') -var closestPoint = _dereq_('./lib/closest-point') - -var meshShader = shaders.meshShader -var wireShader = shaders.wireShader -var pointShader = shaders.pointShader -var pickShader = shaders.pickShader -var pointPickShader = shaders.pointPickShader -var contourShader = shaders.contourShader - -var identityMatrix = [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - - -function SimplicialMesh(gl - , texture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) { - - this.gl = gl - this.cells = [] - this.positions = [] - this.intensity = [] - this.texture = texture - this.dirty = true - - this.triShader = triShader - this.lineShader = lineShader - this.pointShader = pointShader - this.pickShader = pickShader - this.pointPickShader = pointPickShader - this.contourShader = contourShader - - this.trianglePositions = trianglePositions - this.triangleColors = triangleColors - this.triangleNormals = triangleNormals - this.triangleUVs = triangleUVs - this.triangleIds = triangleIds - this.triangleVAO = triangleVAO - this.triangleCount = 0 - - this.lineWidth = 1 - this.edgePositions = edgePositions - this.edgeColors = edgeColors - this.edgeUVs = edgeUVs - this.edgeIds = edgeIds - this.edgeVAO = edgeVAO - this.edgeCount = 0 - - this.pointPositions = pointPositions - this.pointColors = pointColors - this.pointUVs = pointUVs - this.pointSizes = pointSizes - this.pointIds = pointIds - this.pointVAO = pointVAO - this.pointCount = 0 - - this.contourLineWidth = 1 - this.contourPositions = contourPositions - this.contourVAO = contourVAO - this.contourCount = 0 - this.contourColor = [0,0,0] - this.contourEnable = true - - this.pickId = 1 - this.bounds = [ - [ Infinity, Infinity, Infinity], - [-Infinity,-Infinity,-Infinity] ] - this.clipBounds = [ - [-Infinity,-Infinity,-Infinity], - [ Infinity, Infinity, Infinity] ] - - this.lightPosition = [1e5, 1e5, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - - this.opacity = 1.0 - - this._model = identityMatrix - this._view = identityMatrix - this._projection = identityMatrix - this._resolution = [1,1] -} - -var proto = SimplicialMesh.prototype - -proto.isOpaque = function() { - return this.opacity >= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.pickSlots = 1 - -proto.setPickBase = function(id) { - this.pickId = id -} - -function genColormap(param) { - var colors = colormap({ - colormap: param - , nshades: 256 - , format: 'rgba' - }) - - var result = new Uint8Array(256*4) - for(var i=0; i<256; ++i) { - var c = colors[i] - for(var j=0; j<3; ++j) { - result[4*i+j] = c[j] - } - result[4*i+3] = c[3]*255 - } - - return ndarray(result, [256,256,4], [4,0,1]) -} - -function unpackIntensity(cells, numVerts, cellIntensity) { - var result = new Array(numVerts) - for(var i=0; i 0) { - var shader = this.triShader - shader.bind() - shader.uniforms = uniforms - - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0 && this.lineWidth > 0) { - var shader = this.lineShader - shader.bind() - shader.uniforms = uniforms - - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } - - if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { - var shader = this.contourShader - shader.bind() - shader.uniforms = uniforms - - this.contourVAO.bind() - gl.drawArrays(gl.LINES, 0, this.contourCount) - this.contourVAO.unbind() - } -} - -proto.drawPick = function(params) { - params = params || {} - - var gl = this.gl - - var model = params.model || identityMatrix - var view = params.view || identityMatrix - var projection = params.projection || identityMatrix - - var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] - for(var i=0; i<3; ++i) { - clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) - clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) - } - - //Save camera parameters - this._model = [].slice.call(model) - this._view = [].slice.call(view) - this._projection = [].slice.call(projection) - this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - - var uniforms = { - model: model, - view: view, - projection: projection, - clipBounds: clipBounds, - pickId: this.pickId / 255.0, - } - - var shader = this.pickShader - shader.bind() - shader.uniforms = uniforms - - if(this.triangleCount > 0) { - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0) { - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointPickShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } -} - - -proto.pick = function(pickData) { - if(!pickData) { - return null - } - if(pickData.id !== this.pickId) { - return null - } - - var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] - var cell = this.cells[cellId] - var positions = this.positions - - var simplex = new Array(cell.length) - for(var i=0; i 0) { - var base = Math.round(Math.pow(10, y)) - return Math.ceil(x/base) * base - } - return Math.ceil(x) -} - -function defaultBool(x) { - if(typeof x === 'boolean') { - return x - } - return true -} - -function createScene(options) { - options = options || {} - - var stopped = false - - var pixelRatio = options.pixelRatio || parseFloat(window.devicePixelRatio) - - var canvas = options.canvas - if(!canvas) { - canvas = document.createElement('canvas') - if(options.container) { - var container = options.container - container.appendChild(canvas) - } else { - document.body.appendChild(canvas) - } - } - - var gl = options.gl - if(!gl) { - gl = getContext(canvas, - options.glOptions || { - premultipliedAlpha: true, - antialias: true, - preserveDrawingBuffer: isMobile - }) - } - if(!gl) { - throw new Error('webgl not supported') - } - - //Initial bounds - var bounds = options.bounds || [[-10,-10,-10], [10,10,10]] - - //Create selection - var selection = new MouseSelect() - - //Accumulation buffer - var accumBuffer = createFBO(gl, - [gl.drawingBufferWidth, gl.drawingBufferHeight], { - preferFloat: !isMobile - }) - - var accumShader = createShader(gl) - - //Create a camera - var cameraOptions = options.camera || { - eye: [2,0,0], - center: [0,0,0], - up: [0,1,0], - zoomMin: 0.1, - zoomMax: 100, - mode: 'turntable' - } - - //Create axes - var axesOptions = options.axes || {} - var axes = createAxes(gl, axesOptions) - axes.enable = !axesOptions.disable - - //Create spikes - var spikeOptions = options.spikes || {} - var spikes = createSpikes(gl, spikeOptions) - - //Object list is empty initially - var objects = [] - var pickBufferIds = [] - var pickBufferCount = [] - var pickBuffers = [] - - //Dirty flag, skip redraw if scene static - var dirty = true - var pickDirty = true - - var projection = new Array(16) - var model = new Array(16) - - var cameraParams = { - view: null, - projection: projection, - model: model - } - - var pickDirty = true - - var viewShape = [ gl.drawingBufferWidth, gl.drawingBufferHeight ] - - //Create scene object - var scene = { - gl: gl, - contextLost: false, - pixelRatio: options.pixelRatio || parseFloat(window.devicePixelRatio), - canvas: canvas, - selection: selection, - camera: createCamera(canvas, cameraOptions), - axes: axes, - axesPixels: null, - spikes: spikes, - bounds: bounds, - objects: objects, - shape: viewShape, - aspect: options.aspectRatio || [1,1,1], - pickRadius: options.pickRadius || 10, - zNear: options.zNear || 0.01, - zFar: options.zFar || 1000, - fovy: options.fovy || Math.PI/4, - clearColor: options.clearColor || [0,0,0,0], - autoResize: defaultBool(options.autoResize), - autoBounds: defaultBool(options.autoBounds), - autoScale: !!options.autoScale, - autoCenter: defaultBool(options.autoCenter), - clipToBounds: defaultBool(options.clipToBounds), - snapToData: !!options.snapToData, - onselect: options.onselect || null, - onrender: options.onrender || null, - onclick: options.onclick || null, - cameraParams: cameraParams, - oncontextloss: null, - mouseListener: null - } - - var pickShape = [ (gl.drawingBufferWidth/scene.pixelRatio)|0, (gl.drawingBufferHeight/scene.pixelRatio)|0 ] - - function resizeListener() { - if(stopped) { - return - } - if(!scene.autoResize) { - return - } - var parent = canvas.parentNode - var width = 1 - var height = 1 - if(parent && parent !== document.body) { - width = parent.clientWidth - height = parent.clientHeight - } else { - width = window.innerWidth - height = window.innerHeight - } - var nextWidth = Math.ceil(width * scene.pixelRatio)|0 - var nextHeight = Math.ceil(height * scene.pixelRatio)|0 - if(nextWidth !== canvas.width || nextHeight !== canvas.height) { - canvas.width = nextWidth - canvas.height = nextHeight - var style = canvas.style - style.position = style.position || 'absolute' - style.left = '0px' - style.top = '0px' - style.width = width + 'px' - style.height = height + 'px' - dirty = true - } - } - if(scene.autoResize) { - resizeListener() - } - window.addEventListener('resize', resizeListener) - - function reallocPickIds() { - var numObjs = objects.length - var numPick = pickBuffers.length - for(var i=0; i 0 && pickBufferCount[numPick-1] === 0) { - pickBufferCount.pop() - pickBuffers.pop().dispose() - } - } - - scene.update = function(options) { - if(stopped) { - return - } - options = options || {} - dirty = true - pickDirty = true - } - - scene.add = function(obj) { - if(stopped) { - return - } - obj.axes = axes - objects.push(obj) - pickBufferIds.push(-1) - dirty = true - pickDirty = true - reallocPickIds() - } - - scene.remove = function(obj) { - if(stopped) { - return - } - var idx = objects.indexOf(obj) - if(idx < 0) { - return - } - objects.splice(idx, 1) - pickBufferIds.pop() - dirty = true - pickDirty = true - reallocPickIds() - } - - scene.dispose = function() { - if(stopped) { - return - } - - stopped = true - - window.removeEventListener('resize', resizeListener) - canvas.removeEventListener('webglcontextlost', checkContextLoss) - scene.mouseListener.enabled = false - - if(scene.contextLost) { - return - } - - //Destroy objects - axes.dispose() - spikes.dispose() - for(var i=0; i selection.distance) { - continue - } - for(var j=0; j 0.000001) { - // standard case (slerp) - omega = Math.acos(cosom) - sinom = Math.sin(omega) - scale0 = Math.sin((1.0 - t) * omega) / sinom - scale1 = Math.sin(t * omega) / sinom - } else { - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - scale0 = 1.0 - t - scale1 = t +} + +var proto = SelectBuffer.prototype + +Object.defineProperty(proto, 'shape', { + get: function() { + if(!this.gl) { + return [0,0] + } + return this.fbo.shape.slice() + }, + set: function(v) { + if(!this.gl) { + return + } + this.fbo.shape = v + var c = this.fbo.shape[0] + var r = this.fbo.shape[1] + if(r*c*4 > this.buffer.length) { + pool.free(this.buffer) + var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) + for(var i=0; i oldAttribCount) { + for(i = oldAttribCount; i < newAttribCount; i++) { + this.gl.enableVertexAttribArray(i) + } + } else if(oldAttribCount > newAttribCount) { + for(i = newAttribCount; i < oldAttribCount; i++) { + this.gl.disableVertexAttribArray(i) + } + } + + this.gl.lastAttribCount = newAttribCount + + this.gl.useProgram(this.program) +} + +proto.dispose = function() { + + // disabling vertex attributes so new shader starts with zero + // and it's also useful if all shaders are disposed but the + // gl context is reused for subsequent replotting + var oldAttribCount = this.gl.lastAttribCount + for (var i = 0; i < oldAttribCount; i++) { + this.gl.disableVertexAttribArray(i) + } + this.gl.lastAttribCount = 0 + + if(this._fref) { + this._fref.dispose() + } + if(this._vref) { + this._vref.dispose() + } + this.attributes = + this.types = + this.vertShader = + this.fragShader = + this.program = + this._relink = + this._fref = + this._vref = null +} - return out +function compareAttributes(a, b) { + if(a.name < b.name) { + return -1 + } + return 1 } -},{}],143:[function(_dereq_,module,exports){ -'use strict'; +//Update export hook for glslify-live +proto.update = function( + vertSource + , fragSource + , uniforms + , attributes) { -module.exports = function(a){ - return (!a && a !== 0) ? '' : a.toString(); -} + //If only one object passed, assume glslify style output + if(!fragSource || arguments.length === 1) { + var obj = vertSource + vertSource = obj.vertex + fragSource = obj.fragment + uniforms = obj.uniforms + attributes = obj.attributes + } -},{}],144:[function(_dereq_,module,exports){ -"use strict" + var wrapper = this + var gl = wrapper.gl -var vectorizeText = _dereq_("vectorize-text") + //Compile vertex and fragment shaders + var pvref = wrapper._vref + wrapper._vref = shaderCache.shader(gl, gl.VERTEX_SHADER, vertSource) + if(pvref) { + pvref.dispose() + } + wrapper.vertShader = wrapper._vref.shader + var pfref = this._fref + wrapper._fref = shaderCache.shader(gl, gl.FRAGMENT_SHADER, fragSource) + if(pfref) { + pfref.dispose() + } + wrapper.fragShader = wrapper._fref.shader -module.exports = getGlyph + //If uniforms/attributes is not specified, use RT reflection + if(!uniforms || !attributes) { -var GLYPH_CACHE = {} + //Create initial test program + var testProgram = gl.createProgram() + gl.attachShader(testProgram, wrapper.fragShader) + gl.attachShader(testProgram, wrapper.vertShader) + gl.linkProgram(testProgram) + if(!gl.getProgramParameter(testProgram, gl.LINK_STATUS)) { + var errLog = gl.getProgramInfoLog(testProgram) + throw new GLError(errLog, 'Error linking program:' + errLog) + } -function getGlyph(symbol, font) { - var fontCache = GLYPH_CACHE[font] - if(!fontCache) { - fontCache = GLYPH_CACHE[font] = {} + //Load data from runtime + uniforms = uniforms || runtime.uniforms(gl, testProgram) + attributes = attributes || runtime.attributes(gl, testProgram) + + //Release test program + gl.deleteProgram(testProgram) } - if(symbol in fontCache) { - return fontCache[symbol] + + //Sort attributes lexicographically + // overrides undefined WebGL behavior for attribute locations + attributes = attributes.slice() + attributes.sort(compareAttributes) + + //Convert attribute types, read out locations + var attributeUnpacked = [] + var attributeNames = [] + var attributeLocations = [] + var i + for(i=0; i= 0) { + var size = attr.type.charAt(attr.type.length-1)|0 + var locVector = new Array(size) + for(var j=0; j= 0) { + curLocation += 1 + } + attributeLocations[i] = curLocation + } + } - //Calculate bounding box - var bounds = [[Infinity,Infinity], [-Infinity,-Infinity]] - for(var i=0; i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) -var orthographicVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) -var projectionVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]) -var drawFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]) +//Compiles and links a shader program with the given attribute and vertex list +function createShader( + gl + , vertSource + , fragSource + , uniforms + , attributes) { -var ATTRIBUTES = [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'glyph', type: 'vec2'}, - {name: 'id', type: 'vec4'} -] + var shader = new Shader(gl) -var perspective = { - vertex: perspectiveVertSrc, - fragment: drawFragSrc, - attributes: ATTRIBUTES - }, - ortho = { - vertex: orthographicVertSrc, - fragment: drawFragSrc, - attributes: ATTRIBUTES - }, - project = { - vertex: projectionVertSrc, - fragment: drawFragSrc, - attributes: ATTRIBUTES - }, - pickPerspective = { - vertex: perspectiveVertSrc, - fragment: pickFragSrc, - attributes: ATTRIBUTES - }, - pickOrtho = { - vertex: orthographicVertSrc, - fragment: pickFragSrc, - attributes: ATTRIBUTES - }, - pickProject = { - vertex: projectionVertSrc, - fragment: pickFragSrc, - attributes: ATTRIBUTES - } + shader.update( + vertSource + , fragSource + , uniforms + , attributes) -function createShader(gl, src) { - var shader = createShaderWrapper(gl, src) - var attr = shader.attributes - attr.position.location = 0 - attr.color.location = 1 - attr.glyph.location = 2 - attr.id.location = 3 return shader } -exports.createPerspective = function(gl) { - return createShader(gl, perspective) -} -exports.createOrtho = function(gl) { - return createShader(gl, ortho) -} -exports.createProject = function(gl) { - return createShader(gl, project) -} -exports.createPickPerspective = function(gl) { - return createShader(gl, pickPerspective) -} -exports.createPickOrtho = function(gl) { - return createShader(gl, pickOrtho) -} -exports.createPickProject = function(gl) { - return createShader(gl, pickProject) +module.exports = createShader + +},{"./lib/GLError":149,"./lib/create-attributes":150,"./lib/create-uniforms":151,"./lib/reflect":152,"./lib/runtime-reflect":153,"./lib/shader-cache":154}],149:[function(_dereq_,module,exports){ +function GLError (rawError, shortMessage, longMessage) { + this.shortMessage = shortMessage || '' + this.longMessage = longMessage || '' + this.rawError = rawError || '' + this.message = + 'gl-shader: ' + (shortMessage || rawError || '') + + (longMessage ? '\n'+longMessage : '') + this.stack = (new Error()).stack } +GLError.prototype = new Error +GLError.prototype.name = 'GLError' +GLError.prototype.constructor = GLError +module.exports = GLError -},{"gl-shader":148,"glslify":249}],146:[function(_dereq_,module,exports){ +},{}],150:[function(_dereq_,module,exports){ 'use strict' -var isAllBlank = _dereq_('is-string-blank') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var pool = _dereq_('typedarray-pool') -var mat4mult = _dereq_('gl-mat4/multiply') -var shaders = _dereq_('./lib/shaders') -var getGlyph = _dereq_('./lib/glyphs') -var getSimpleString = _dereq_('./lib/get-simple-string') - -var IDENTITY = [1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - -module.exports = createPointCloud +module.exports = createAttributeWrapper -function transformMat4(x, m) { - var x0 = x[0] - var x1 = x[1] - var x2 = x[2] - var x3 = x[3] - x[0] = m[0] * x0 + m[4] * x1 + m[8] * x2 + m[12] * x3 - x[1] = m[1] * x0 + m[5] * x1 + m[9] * x2 + m[13] * x3 - x[2] = m[2] * x0 + m[6] * x1 + m[10] * x2 + m[14] * x3 - x[3] = m[3] * x0 + m[7] * x1 + m[11] * x2 + m[15] * x3 - return x -} +var GLError = _dereq_("./GLError") -function project(p, v, m, x) { - transformMat4(x, x, m) - transformMat4(x, x, v) - return transformMat4(x, x, p) +function ShaderAttribute( + gl + , wrapper + , index + , locations + , dimension + , constFunc) { + this._gl = gl + this._wrapper = wrapper + this._index = index + this._locations = locations + this._dimension = dimension + this._constFunc = constFunc } -function clampVec(v) { - var result = new Array(3) - for(var i=0; i<3; ++i) { - result[i] = Math.min(Math.max(v[i], -1e8), 1e8) - } - return result -} +var proto = ShaderAttribute.prototype -function ScatterPlotPickResult(index, position) { - this.index = index - this.dataCoordinate = this.position = position -} +proto.pointer = function setAttribPointer( + type + , normalized + , stride + , offset) { -function PointCloud( - gl, - shader, - orthoShader, - projectShader, - pointBuffer, - colorBuffer, - glyphBuffer, - idBuffer, - vao, - pickPerspectiveShader, - pickOrthoShader, - pickProjectShader) { + var self = this + var gl = self._gl + var location = self._locations[self._index] - this.gl = gl + gl.vertexAttribPointer( + location + , self._dimension + , type || gl.FLOAT + , !!normalized + , stride || 0 + , offset || 0) + gl.enableVertexAttribArray(location) +} - this.pixelRatio = 1 +proto.set = function(x0, x1, x2, x3) { + return this._constFunc(this._locations[this._index], x0, x1, x2, x3) +} - this.shader = shader - this.orthoShader = orthoShader - this.projectShader = projectShader +Object.defineProperty(proto, 'location', { + get: function() { + return this._locations[this._index] + } + , set: function(v) { + if(v !== this._locations[this._index]) { + this._locations[this._index] = v|0 + this._wrapper.program = null + } + return v|0 + } +}) - this.pointBuffer = pointBuffer - this.colorBuffer = colorBuffer - this.glyphBuffer = glyphBuffer - this.idBuffer = idBuffer - this.vao = vao - this.vertexCount = 0 - this.lineVertexCount = 0 +//Adds a vector attribute to obj +function addVectorAttribute( + gl + , wrapper + , index + , locations + , dimension + , obj + , name) { - this.opacity = 1.0 + //Construct constant function + var constFuncArgs = [ 'gl', 'v' ] + var varNames = [] + for(var i=0; i= 1) { - return true - } - for(var i=0; i<3; ++i) { - if(this.axesProject[i] && this.projectOpacity[i] >= 1) { - return true + default: + if(type.indexOf('vec') >= 0) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) + } + addVectorAttribute( + gl + , wrapper + , locs[0] + , locations + , d + , obj + , name) + } else if(type.indexOf('mat') >= 0) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) + } + addMatrixAttribute( + gl + , wrapper + , locs + , locations + , d + , obj + , name) + } else { + throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) + } + break } } - return false + return obj } -var VIEW_SHAPE = [0,0] -var U_VEC = [0,0,0] -var V_VEC = [0,0,0] -var MU_VEC = [0,0,0,1] -var MV_VEC = [0,0,0,1] -var SCRATCH_MATRIX = IDENTITY.slice() -var SCRATCH_VEC = [0,0,0] -var CLIP_BOUNDS = [[0,0,0], [0,0,0]] +},{"./GLError":149}],151:[function(_dereq_,module,exports){ +'use strict' -function zeroVec(a) { - a[0] = a[1] = a[2] = 0 - return a -} +var coallesceUniforms = _dereq_('./reflect') +var GLError = _dereq_("./GLError") -function augment(hg, af) { - hg[0] = af[0] - hg[1] = af[1] - hg[2] = af[2] - hg[3] = 1 - return hg -} +module.exports = createUniformWrapper -function setComponent(out, v, i, x) { - out[0] = v[0] - out[1] = v[1] - out[2] = v[2] - out[i] = x - return out +//Binds a function and returns a value +function identity(x) { + var c = new Function('y', 'return function(){return y}') + return c(x) } -function getClipBounds(bounds) { - var result = CLIP_BOUNDS - for(var i=0; i<2; ++i) { - for(var j=0; j<3; ++j) { - result[i][j] = Math.max(Math.min(bounds[i][j], 1e8), -1e8) - } +function makeVector(length, fill) { + var result = new Array(length) + for(var i=0; i 4) { + throw new GLError('', 'Invalid data type') + } + switch(type.charAt(0)) { + case 'b': + case 'i': + return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' + case 'v': + return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' + default: + throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) + } + } else if(type.indexOf('mat') === 0 && type.length === 4) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) + } + return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' + } else { + throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) + } + break + } + } - for(var i=0; i<3; ++i) { - if(!axesProject[i]) { - continue + function enumerateIndices(prefix, type) { + if(typeof type !== 'object') { + return [ [prefix, type] ] } - if((points.projectOpacity[i] < 1) !== transparent) { - continue + var indices = [] + for(var id in type) { + var prop = type[id] + var tprefix = prefix + if(parseInt(id) + '' === id) { + tprefix += '[' + id + ']' + } else { + tprefix += '.' + id + } + if(typeof prop === 'object') { + indices.push.apply(indices, enumerateIndices(tprefix, prop)) + } else { + indices.push([tprefix, prop]) + } } + return indices + } - uniforms.scale = points.projectScale[i] - uniforms.opacity = points.projectOpacity[i] + function makeSetter(type) { + var code = [ 'return function updateProperty(obj){' ] + var indices = enumerateIndices('', type) + for(var i=0; i 4) { + throw new GLError('', 'Invalid data type') + } + if(type.charAt(0) === 'b') { + return makeVector(d, false) + } + return makeVector(d, 0) + } else if(type.indexOf('mat') === 0 && type.length === 4) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) + } + return makeVector(d*d, 0) + } else { + throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) + } + break } - for(var j=0; j<4; ++j) { - pmodel[5*j] = 1 + } + + function storeProperty(obj, prop, type) { + if(typeof type === 'object') { + var child = processObject(type) + Object.defineProperty(obj, prop, { + get: identity(child), + set: makeSetter(type), + enumerable: true, + configurable: false + }) + } else { + if(locations[type]) { + Object.defineProperty(obj, prop, { + get: makeGetter(type), + set: makeSetter(type), + enumerable: true, + configurable: false + }) + } else { + obj[prop] = defaultValue(uniforms[type].type) + } } - pmodel[5*i] = 0 - if(cubeAxis[i] < 0) { - pmodel[12+i] = bounds[0][i] + } + + function processObject(obj) { + var result + if(Array.isArray(obj)) { + result = new Array(obj.length) + for(var i=0; i Math.abs(mdv[1])) { - var tmp = mdu - mdu = mdv - mdv = tmp - tmp = du - du = dv - dv = tmp - var t = u - u = v - v = t - } - if(mdu[0] < 0) { - du[u] = -1 - } - if(mdv[1] > 0) { - dv[v] = -1 - } - var su = 0.0 - var sv = 0.0 - for(var j=0; j<4; ++j) { - su += Math.pow(model[4*u+j], 2) - sv += Math.pow(model[4*v+j], 2) +},{"./GLError":149,"./reflect":152}],152:[function(_dereq_,module,exports){ +'use strict' + +module.exports = makeReflectTypes + +//Construct type info for reflection. +// +// This iterates over the flattened list of uniform type values and smashes them into a JSON object. +// +// The leaves of the resulting object are either indices or type strings representing primitive glslify types +function makeReflectTypes(uniforms, useIndex) { + var obj = {} + for(var i=0; i 1) { + if(!(x[0] in o)) { + o[x[0]] = [] + } + o = o[x[0]] + for(var k=1; k 0) { - gl.lineWidth(points.lineWidth) - points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) +var GL_TABLE = null + +function getType(gl, type) { + if(!GL_TABLE) { + var typeNames = Object.keys(GL_TO_GLSL_TYPES) + GL_TABLE = {} + for(var i=0; i 1) { + for(var j=0; j 0) { - gl.lineWidth(points.lineWidth) - points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) +function compileShader(gl, type, src) { + var shader = gl.createShader(type) + gl.shaderSource(shader, src) + gl.compileShader(shader) + if(!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { + var errLog = gl.getShaderInfoLog(shader) + try { + var fmt = formatCompilerError(errLog, src, type); + } catch (e){ + console.warn('Failed to format compiler error: ' + e); + throw new GLError(errLog, 'Error compiling shader:\n' + errLog) } + throw new GLError(errLog, fmt.short, fmt.long) } - - drawProject(pshader, points, camera, transparent, forceDraw) - - points.vao.unbind() + return shader } -proto.draw = function(camera) { - var shader = this.useOrtho ? this.orthoShader : this.shader - drawFull(shader, this.projectShader, this, camera, false, false) +proto.getShaderReference = function(type, src) { + var gl = this.gl + var shaders = this.shaders[(type === gl.FRAGMENT_SHADER)|0] + var shader = shaders[src] + if(!shader || !gl.isShader(shader.shader)) { + var shaderObj = compileShader(gl, type, src) + shader = shaders[src] = new ShaderReference( + SHADER_COUNTER++, + src, + type, + shaderObj, + [], + 1, + this) + } else { + shader.count += 1 + } + return shader } -proto.drawTransparent = function(camera) { - var shader = this.useOrtho ? this.orthoShader : this.shader - drawFull(shader, this.projectShader, this, camera, true, false) +function linkProgram(gl, vshader, fshader, attribs, locations) { + var program = gl.createProgram() + gl.attachShader(program, vshader) + gl.attachShader(program, fshader) + for(var i=0; i= this.pointCount || x < 0) { - return null +function getCache(gl) { + var ctxCache = CACHE.get(gl) + if(!ctxCache) { + ctxCache = new ContextCache(gl) + CACHE.set(gl, ctxCache) } + return ctxCache +} - //Unpack result - var coord = this.points[x] - var result = this._selectResult - result.index = x - for(var i=0; i<3; ++i) { - result.position[i] = result.dataCoordinate[i] = coord[i] - } - return result +function getShaderReference(gl, type, src) { + return getCache(gl).getShaderReference(type, src) } -proto.highlight = function(selection) { - if(!selection) { - this.highlightId = [1,1,1,1] - } else { - var pointId = selection.index - var a0 = pointId &0xff - var a1 = (pointId>>8) &0xff - var a2 = (pointId>>16)&0xff - this.highlightId = [a0/255.0, a1/255.0, a2/255.0, 0] - } +function createProgram(gl, vref, fref, attribs, locations) { + return getCache(gl).getProgram(vref, fref, attribs, locations) } -function get_glyphData(glyphs, index, font) { - var str +},{"./GLError":149,"gl-format-compiler-error":114,"weakmap-shim":355}],155:[function(_dereq_,module,exports){ +'use strict' - // use the data if presented in an array - if(Array.isArray(glyphs)) { - if(index < glyphs.length) { - str = glyphs[index] - } else { - str = undefined - } - } else { - str = glyphs - } +var glslify = _dereq_('glslify') +var createShader = _dereq_('gl-shader') - str = getSimpleString(str) // this would handle undefined cases +var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, color;\nattribute float weight;\n\nuniform mat4 model, view, projection;\nuniform vec3 coordinates[3];\nuniform vec4 colors[3];\nuniform vec2 screenShape;\nuniform float lineWidth;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vertexPosition = mix(coordinates[0],\n mix(coordinates[2], coordinates[1], 0.5 * (position + 1.0)), abs(position));\n\n vec4 clipPos = projection * view * model * vec4(vertexPosition, 1.0);\n vec2 clipOffset = (projection * view * model * vec4(color, 0.0)).xy;\n vec2 delta = weight * clipOffset * screenShape;\n vec2 lineOffset = normalize(vec2(delta.y, -delta.x)) / screenShape;\n\n gl_Position = vec4(clipPos.xy + clipPos.w * 0.5 * lineWidth * lineOffset, clipPos.z, clipPos.w);\n fragColor = color.x * colors[0] + color.y * colors[1] + color.z * colors[2];\n}\n"]) +var fragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}"]) - var visible = true - if(isAllBlank(str)) { - str = '▼' // Note: this special character may have minimum number of surfaces - visible = false - } +module.exports = function(gl) { + return createShader(gl, vertSrc, fragSrc, null, [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec3'}, + {name: 'weight', type: 'float'} + ]) +} - var glyph = getGlyph(str, font) +},{"gl-shader":148,"glslify":249}],156:[function(_dereq_,module,exports){ +'use strict' - return { mesh:glyph[0], - lines:glyph[1], - bounds:glyph[2], - visible:visible }; +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createShader = _dereq_('./shaders/index') + +module.exports = createSpikes + +var identity = [1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +function AxisSpikes(gl, buffer, vao, shader) { + this.gl = gl + this.buffer = buffer + this.vao = vao + this.shader = shader + this.pixelRatio = 1 + this.bounds = [[-1000,-1000,-1000], [1000,1000,1000]] + this.position = [0,0,0] + this.lineWidth = [2,2,2] + this.colors = [[0,0,0,1], [0,0,0,1], [0,0,0,1]] + this.enabled = [true,true,true] + this.drawSides = [true,true,true] + this.axes = null } +var proto = AxisSpikes.prototype +var OUTER_FACE = [0,0,0] +var INNER_FACE = [0,0,0] -proto.update = function(options) { +var SHAPE = [0,0] - options = options || {} +proto.isTransparent = function() { + return false +} - if('perspective' in options) { - this.useOrtho = !options.perspective - } - if('orthographic' in options) { - this.useOrtho = !!options.orthographic - } - if('lineWidth' in options) { - this.lineWidth = options.lineWidth +proto.drawTransparent = function(camera) {} + +proto.draw = function(camera) { + var gl = this.gl + var vao = this.vao + var shader = this.shader + + vao.bind() + shader.bind() + + var model = camera.model || identity + var view = camera.view || identity + var projection = camera.projection || identity + + var axis + if(this.axes) { + axis = this.axes.lastCubeProps.axis } - if('project' in options) { - if(Array.isArray(options.project)) { - this.axesProject = options.project + + var outerFace = OUTER_FACE + var innerFace = INNER_FACE + for(var i=0; i<3; ++i) { + if(axis && axis[i] < 0) { + outerFace[i] = this.bounds[0][i] + innerFace[i] = this.bounds[1][i] } else { - var v = !!options.project - this.axesProject = [v,v,v] + outerFace[i] = this.bounds[1][i] + innerFace[i] = this.bounds[0][i] } } - if('projectScale' in options) { - if(Array.isArray(options.projectScale)) { - this.projectScale = options.projectScale.slice() - } else { - var s = +options.projectScale - this.projectScale = [s,s,s] + + SHAPE[0] = gl.drawingBufferWidth + SHAPE[1] = gl.drawingBufferHeight + + shader.uniforms.model = model + shader.uniforms.view = view + shader.uniforms.projection = projection + shader.uniforms.coordinates = [this.position, outerFace, innerFace] + shader.uniforms.colors = this.colors + shader.uniforms.screenShape = SHAPE + + for(var i=0; i<3; ++i) { + shader.uniforms.lineWidth = this.lineWidth[i] * this.pixelRatio + if(this.enabled[i]) { + vao.draw(gl.TRIANGLES, 6, 6*i) + if(this.drawSides[i]) { + vao.draw(gl.TRIANGLES, 12, 18+12*i) + } } } - if('projectOpacity' in options) { - if(Array.isArray(options.projectOpacity)) { - this.projectOpacity = options.projectOpacity.slice() - } else { - var s = +options.projectOpacity - this.projectOpacity = [s,s,s] - } + + vao.unbind() +} + +proto.update = function(options) { + if(!options) { + return } - if('opacity' in options) { - this.opacity = options.opacity + if("bounds" in options) { + this.bounds = options.bounds + } + if("position" in options) { + this.position = options.position } + if("lineWidth" in options) { + this.lineWidth = options.lineWidth + } + if("colors" in options) { + this.colors = options.colors + } + if("enabled" in options) { + this.enabled = options.enabled + } + if("drawSides" in options) { + this.drawSides = options.drawSides + } +} - //Set dirty flag - this.dirty = true +proto.dispose = function() { + this.vao.dispose() + this.buffer.dispose() + this.shader.dispose() +} - //Create new buffers - var points = options.position - //Text font - var font = options.font || 'normal' - var alignment = options.alignment || [0,0] - //Bounds - var lowerBound = [ Infinity, Infinity, Infinity] - var upperBound = [-Infinity,-Infinity,-Infinity] +function createSpikes(gl, options) { + //Create buffers + var data = [ ] + + function line(x,y,z,i,l,h) { + var row = [x,y,z, 0,0,0, 1] + row[i+3] = 1 + row[i] = l + data.push.apply(data, row) + row[6] = -1 + data.push.apply(data, row) + row[i] = h + data.push.apply(data, row) + data.push.apply(data, row) + row[6] = 1 + data.push.apply(data, row) + row[i] = l + data.push.apply(data, row) + } + + line(0,0,0, 0, 0, 1) + line(0,0,0, 1, 0, 1) + line(0,0,0, 2, 0, 1) + + line(1,0,0, 1, -1,1) + line(1,0,0, 2, -1,1) + + line(0,1,0, 0, -1,1) + line(0,1,0, 2, -1,1) + + line(0,0,1, 0, -1,1) + line(0,0,1, 1, -1,1) + + var buffer = createBuffer(gl, data) + var vao = createVAO(gl, [{ + type: gl.FLOAT, + buffer: buffer, + size: 3, + offset: 0, + stride: 28 + }, { + type: gl.FLOAT, + buffer: buffer, + size: 3, + offset: 12, + stride: 28 + }, { + type: gl.FLOAT, + buffer: buffer, + size: 1, + offset: 24, + stride: 28 + }]) + + //Create shader + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.color.location = 1 + shader.attributes.weight.location = 2 - //Unpack options - var glyphs = options.glyph - var colors = options.color - var sizes = options.size - var angles = options.angle - var lineColors = options.lineColor + //Create spike object + var spikes = new AxisSpikes(gl, buffer, vao, shader) - //Picking geometry - var pickCounter = -1 + //Set parameters + spikes.update(options) - //First do pass to compute buffer sizes - var triVertexCount = 0 - var lineVertexCount = 0 + //Return resulting object + return spikes +} - var numPoints = 0; +},{"./shaders/index":155,"gl-buffer":104,"gl-vao":167}],157:[function(_dereq_,module,exports){ +arguments[4][106][0].apply(exports,arguments) +},{"barycentric":18,"dup":106,"polytope-closest-point/lib/closest_point_2d.js":306}],158:[function(_dereq_,module,exports){ +var glslify = _dereq_('glslify') - if(points.length) { +var triVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]) +var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) +var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) + +exports.meshShader = { + vertex: triVertSrc, + fragment: triFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'normal', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'}, + {name: 'vector', type: 'vec4'} + ] +} +exports.pickShader = { + vertex: pickVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'id', type: 'vec4'}, + {name: 'vector', type: 'vec4'} + ] +} - //Count number of points and buffer size - numPoints = points.length +},{"glslify":249}],159:[function(_dereq_,module,exports){ +'use strict' - count_loop: - for(var i=0; i= 1 +} - triVertexCount += glyphMesh.cells.length * 3 - lineVertexCount += glyphLines.edges.length * 2 +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.pickSlots = 1 + +proto.setPickBase = function(id) { + this.pickId = id +} + +function genColormap(param) { + var colors = colormap({ + colormap: param + , nshades: 256 + , format: 'rgba' + }) + + var result = new Uint8Array(256*4) + for(var i=0; i<256; ++i) { + var c = colors[i] + for(var j=0; j<3; ++j) { + result[4*i+j] = c[j] } + result[4*i+3] = c[3]*255 } - var vertexCount = triVertexCount + lineVertexCount + return ndarray(result, [256,256,4], [4,0,1]) +} - //Preallocate data - var positionArray = pool.mallocFloat(3*vertexCount) - var colorArray = pool.mallocFloat(4*vertexCount) - var glyphArray = pool.mallocFloat(2*vertexCount) - var idArray = pool.mallocUint32(vertexCount) +function unpackIntensity(cells, numVerts, cellIntensity) { + var result = new Array(numVerts) + for(var i=0; i 0) { - var triOffset = 0 - var lineOffset = triVertexCount - var color = [0,0,0,1] - var lineColor = [0,0,0,1] +function takeZComponent(array) { + var n = array.length + var result = new Array(n) + for(var i=0; i 0) { - textOffset[j] *= (1-glyphBounds[0][j]) - } else if(alignment[j] < 0) { - textOffset[j] *= (1+glyphBounds[1][j]) - } - } + pointCount += 1 + break - //Write out inner marker - var cells = glyphMesh.cells || [] - var verts = glyphMesh.positions || [] + case 2: - for(var j=0; j 0) { + var shader = this.triShader + shader.bind() + shader.uniforms = uniforms -Object.defineProperty(proto, 'shape', { - get: function() { - if(!this.gl) { - return [0,0] - } - return this.fbo.shape.slice() - }, - set: function(v) { - if(!this.gl) { - return - } - this.fbo.shape = v - var c = this.fbo.shape[0] - var r = this.fbo.shape[1] - if(r*c*4 > this.buffer.length) { - pool.free(this.buffer) - var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) - for(var i=0; i 0 && this.lineWidth > 0) { + var shader = this.lineShader + shader.bind() + shader.uniforms = uniforms + + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() } - this.fbo.bind() - gl.clearColor(1,1,1,1) - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) -} + if(this.pointCount > 0) { + var shader = this.pointShader + shader.bind() + shader.uniforms = uniforms -proto.end = function() { - var gl = this.gl - if(!gl) { - return + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() } - gl.bindFramebuffer(gl.FRAMEBUFFER, null) - if(!this._readTimeout) { - clearTimeout(this._readTimeout) + + if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { + var shader = this.contourShader + shader.bind() + shader.uniforms = uniforms + + this.contourVAO.bind() + gl.drawArrays(gl.LINES, 0, this.contourCount) + this.contourVAO.unbind() } - this._readTimeout = setTimeout(this._readCallback, 1) } -proto.query = function(x, y, radius) { - if(!this.gl) { - return null - } +proto.drawPick = function(params) { + params = params || {} - var shape = this.fbo.shape.slice() + var gl = this.gl - x = x|0 - y = y|0 - if(typeof radius !== 'number') { - radius = 1.0 + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix + + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) } - var x0 = Math.min(Math.max(x - radius, 0), shape[0])|0 - var x1 = Math.min(Math.max(x + radius, 0), shape[0])|0 - var y0 = Math.min(Math.max(y - radius, 0), shape[1])|0 - var y1 = Math.min(Math.max(y + radius, 0), shape[1])|0 + //Save camera parameters + this._model = [].slice.call(model) + this._view = [].slice.call(view) + this._projection = [].slice.call(projection) + this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - if(x1 <= x0 || y1 <= y0) { - return null + var uniforms = { + model: model, + view: view, + projection: projection, + clipBounds: clipBounds, + + tubeScale: this.tubeScale, + + pickId: this.pickId / 255.0, } - var dims = [x1-x0,y1-y0] - var region = ndarray( - this.buffer, - [dims[0], dims[1], 4], - [4, shape[0]*4, 1], - 4*(x0 + shape[0]*y0)); + var shader = this.pickShader + shader.bind() + shader.uniforms = uniforms - var closest = selectRange(region.hi(dims[0],dims[1],1), radius, radius) - var dx = closest[0] - var dy = closest[1] - if(dx < 0 || Math.pow(this.radius, 2) < closest[2]) { - return null + if(this.triangleCount > 0) { + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() } - var c0 = region.get(dx, dy, 0) - var c1 = region.get(dx, dy, 1) - var c2 = region.get(dx, dy, 2) - var c3 = region.get(dx, dy, 3) + if(this.edgeCount > 0) { + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } - return new SelectResult( - (dx + x0)|0, - (dy + y0)|0, - c0, - [c1, c2, c3], - Math.sqrt(closest[2])) + if(this.pointCount > 0) { + var shader = this.pointPickShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } } -proto.dispose = function() { - if(!this.gl) { - return + +proto.pick = function(pickData) { + if(!pickData) { + return null } - this.fbo.dispose() - pool.free(this.buffer) - this.gl = null - if(this._readTimeout) { - clearTimeout(this._readTimeout) + if(pickData.id !== this.pickId) { + return null + } + + var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] + var cell = this.cells[cellId] + + var pos = this.positions[cell[1]].slice(0, 3) + var intensity = this.intensity[cell[1]] + var velocity = this.vectors[cell[1]].slice(0, 3) + var divergence = this.vectors[cell[1]][3] + + return { + index: cellId, + position: pos, + intensity: intensity, + velocity: velocity, + divergence: divergence, + dataCoordinate: pos } } -function createSelectBuffer(gl, shape) { - var fbo = createFBO(gl, shape) - var buffer = pool.mallocUint8(shape[0]*shape[1]*4) - return new SelectBuffer(gl, fbo, buffer) + +proto.dispose = function() { + this.texture.dispose() + + this.triShader.dispose() + // this.lineShader.dispose() + // this.pointShader.dispose() + this.pickShader.dispose() + // this.pointPickShader.dispose() + + this.triangleVAO.dispose() + this.trianglePositions.dispose() + this.triangleVectors.dispose() + this.triangleColors.dispose() + this.triangleUVs.dispose() + this.triangleNormals.dispose() + this.triangleIds.dispose() + + this.edgeVAO.dispose() + this.edgePositions.dispose() + this.edgeColors.dispose() + this.edgeUVs.dispose() + this.edgeIds.dispose() + + this.pointVAO.dispose() + this.pointPositions.dispose() + this.pointColors.dispose() + this.pointUVs.dispose() + this.pointSizes.dispose() + this.pointIds.dispose() + + this.contourVAO.dispose() + this.contourPositions.dispose() + // this.contourShader.dispose() +} + +function createMeshShader(gl) { + var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.vector.location = 5 + return shader } -},{"bit-twiddle":37,"cwise/lib/wrapper":81,"gl-fbo":113,"ndarray":285,"typedarray-pool":348}],148:[function(_dereq_,module,exports){ -'use strict' +function createWireShader(gl) { + var shader = createShader(gl, wireShader.vertex, wireShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + return shader +} -var createUniformWrapper = _dereq_('./lib/create-uniforms') -var createAttributeWrapper = _dereq_('./lib/create-attributes') -var makeReflect = _dereq_('./lib/reflect') -var shaderCache = _dereq_('./lib/shader-cache') -var runtime = _dereq_('./lib/runtime-reflect') -var GLError = _dereq_("./lib/GLError") +function createPointShader(gl) { + var shader = createShader(gl, pointShader.vertex, pointShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.pointSize.location = 4 + return shader +} -//Shader object -function Shader(gl) { - this.gl = gl - this.gl.lastAttribCount = 0 // fixme where else should we store info, safe but not nice on the gl object +function createPickShader(gl) { + var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.vector.location = 5 + return shader +} - //Default initialize these to null - this._vref = - this._fref = - this._relink = - this.vertShader = - this.fragShader = - this.program = - this.attributes = - this.uniforms = - this.types = null +function createPointPickShader(gl) { + var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.pointSize.location = 4 + return shader } -var proto = Shader.prototype +function createContourShader(gl) { + var shader = createShader(gl, contourShader.vertex, contourShader.fragment) + shader.attributes.position.location = 0 + return shader +} -proto.bind = function() { - if(!this.program) { - this._relink() - } +function createSimplicialMesh(gl, params) { + if (arguments.length === 1) { + params = gl; + gl = params.gl; + } + + var triShader = params.triShader || createMeshShader(gl) + var lineShader = null; //createWireShader(gl) + var pointShader = null; //createPointShader(gl) + var pickShader = createPickShader(gl) + var pointPickShader = null; //createPointPickShader(gl) + var contourShader = null; //createContourShader(gl) + + var meshTexture = createTexture(gl, + ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) + meshTexture.generateMipmap() + meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR + meshTexture.magFilter = gl.LINEAR + + var trianglePositions = createBuffer(gl) + var triangleVectors = createBuffer(gl) + var triangleColors = createBuffer(gl) + var triangleUVs = createBuffer(gl) + var triangleNormals = createBuffer(gl) + var triangleIds = createBuffer(gl) + var triangleVAO = createVAO(gl, [ + { buffer: trianglePositions, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: triangleColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: triangleNormals, + type: gl.FLOAT, + size: 3 + }, + { buffer: triangleVectors, + type: gl.FLOAT, + size: 4 + } + ]) - // ensuring that we have the right number of enabled vertex attributes - var i - var newAttribCount = this.gl.getProgramParameter(this.program, this.gl.ACTIVE_ATTRIBUTES) // more robust approach - //var newAttribCount = Object.keys(this.attributes).length // avoids the probably immaterial introspection slowdown - var oldAttribCount = this.gl.lastAttribCount - if(newAttribCount > oldAttribCount) { - for(i = oldAttribCount; i < newAttribCount; i++) { - this.gl.enableVertexAttribArray(i) + var edgePositions = createBuffer(gl) + var edgeColors = createBuffer(gl) + var edgeUVs = createBuffer(gl) + var edgeIds = createBuffer(gl) + var edgeVAO = createVAO(gl, [ + { buffer: edgePositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: edgeIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: edgeColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: edgeUVs, + type: gl.FLOAT, + size: 2 } - } else if(oldAttribCount > newAttribCount) { - for(i = newAttribCount; i < oldAttribCount; i++) { - this.gl.disableVertexAttribArray(i) + ]) + + var pointPositions = createBuffer(gl) + var pointColors = createBuffer(gl) + var pointUVs = createBuffer(gl) + var pointSizes = createBuffer(gl) + var pointIds = createBuffer(gl) + var pointVAO = createVAO(gl, [ + { buffer: pointPositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: pointIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: pointColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: pointUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: pointSizes, + type: gl.FLOAT, + size: 1 } - } + ]) - this.gl.lastAttribCount = newAttribCount + var contourPositions = createBuffer(gl) + var contourVAO = createVAO(gl, [ + { buffer: contourPositions, + type: gl.FLOAT, + size: 3 + }]) + + var mesh = new SimplicialMesh(gl + , meshTexture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) + + mesh.update(params) + + return mesh +} + +module.exports = createSimplicialMesh + +},{"./closest-point":157,"./shaders":158,"colormap":69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-shader":148,"gl-texture2d":163,"gl-vao":167,"ndarray":285,"normals":287,"simplicial-complex-contour":329,"typedarray-pool":347}],160:[function(_dereq_,module,exports){ +"use strict"; - this.gl.useProgram(this.program) -} +var vec3 = _dereq_('gl-vec3'); +var vec4 = _dereq_('gl-vec4'); + +var streamToTube = function(stream, maxDivergence, minDistance, maxNorm) { + var points = stream.points; + var velocities = stream.velocities; + var divergences = stream.divergences; + + var p, fwd, r, u, v, up; + up = vec3.set(vec3.create(), 0, 1, 0); + u = vec3.create(); + v = vec3.create(); + var p2 = vec3.create(); + + var verts = []; + var faces = []; + var vectors = []; + var previousVerts = []; + var currentVerts = []; + var intensities = []; + var previousIntensity = 0; + var currentIntensity = 0; + var currentVector = vec4.create(); + var previousVector = vec4.create(); + + var facets = 8; + + for (var i = 0; i < points.length; i++) { + p = points[i]; + fwd = velocities[i]; + r = divergences[i]; + if (maxDivergence === 0) { + r = minDistance * 0.05; + } + currentIntensity = vec3.length(fwd) / maxNorm; + currentVector = vec4.create(); + vec3.copy(currentVector, fwd); + currentVector[3] = r; + + for (var a = 0; a < facets; a++) { + currentVerts[a] = [p[0], p[1], p[2], a]; + } + if (previousVerts.length > 0) { + for (var a = 0; a < facets; a++) { + var a1 = (a+1) % facets; + verts.push( + previousVerts[a], + currentVerts[a], + currentVerts[a1], + + currentVerts[a1], + previousVerts[a1], + previousVerts[a] + ); + vectors.push( + previousVector, + currentVector, + currentVector, + + currentVector, + previousVector, + previousVector + ); + intensities.push( + previousIntensity, + currentIntensity, + currentIntensity, + + currentIntensity, + previousIntensity, + previousIntensity + ); + faces.push( + [verts.length-6, verts.length-5, verts.length-4], + [verts.length-3, verts.length-2, verts.length-1] + ); + } + } + var tmp = previousVerts; + previousVerts = currentVerts; + currentVerts = tmp; + tmp = previousVector; + previousVector = currentVector; + currentVector = tmp; + tmp = previousIntensity; + previousIntensity = currentIntensity; + currentIntensity = tmp; + } + return { + positions: verts, + cells: faces, + vectors: vectors, + vertexIntensity: intensities + }; -proto.dispose = function() { +}; - // disabling vertex attributes so new shader starts with zero - // and it's also useful if all shaders are disposed but the - // gl context is reused for subsequent replotting - var oldAttribCount = this.gl.lastAttribCount - for (var i = 0; i < oldAttribCount; i++) { - this.gl.disableVertexAttribArray(i) - } - this.gl.lastAttribCount = 0 +var createTubes = function(streams, colormap, maxDivergence, minDistance) { - if(this._fref) { - this._fref.dispose() - } - if(this._vref) { - this._vref.dispose() - } - this.attributes = - this.types = - this.vertShader = - this.fragShader = - this.program = - this._relink = - this._fref = - this._vref = null -} + var maxNorm = 0; + for (var i=0; i maxNorm) { + maxNorm = norm; + } + } + } -function compareAttributes(a, b) { - if(a.name < b.name) { - return -1 + var tubes = streams.map(function(s) { + return streamToTube(s, maxDivergence, minDistance, maxNorm); + }); + + var positions = []; + var cells = []; + var vectors = []; + var vertexIntensity = []; + for (var i=0; i < tubes.length; i++) { + var tube = tubes[i]; + var offset = positions.length; + positions = positions.concat(tube.positions); + vectors = vectors.concat(tube.vectors); + vertexIntensity = vertexIntensity.concat(tube.vertexIntensity); + for (var j=0; j v) return i-1; } - return 1 -} + return i; +}; + +var tmp = vec3.create(); +var tmp2 = vec3.create(); + +var clamp = function(v, min, max) { + return v < min ? min : (v > max ? max : v); +}; + +var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { + var x = point[0]; + var y = point[1]; + var z = point[2]; + + var w = meshgrid[0].length; + var h = meshgrid[1].length; + var d = meshgrid[2].length; + + // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). + // The nearest smaller value index for x is the index x0 such that + // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. + var x0 = findLastSmallerIndex(meshgrid[0], x); + var y0 = findLastSmallerIndex(meshgrid[1], y); + var z0 = findLastSmallerIndex(meshgrid[2], z); + + // Get the nearest larger meshgrid value indices. + // From the above "nearest smaller value", we know that + // meshgrid[0][x0] < x + // meshgrid[0][x0+1] >= x + var x1 = x0 + 1; + var y1 = y0 + 1; + var z1 = z0 + 1; + + if (meshgrid[0][x0] === x) x1 = x0; + if (meshgrid[1][y0] === y) y1 = y0; + if (meshgrid[2][z0] === z) z1 = z0; + + if (clampOverflow) { + x0 = clamp(x0, 0, w-1); + x1 = clamp(x1, 0, w-1); + y0 = clamp(y0, 0, h-1); + y1 = clamp(y1, 0, h-1); + z0 = clamp(z0, 0, d-1); + z1 = clamp(z1, 0, d-1); + } + + // Reject points outside the meshgrid, return a zero vector. + if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { + return vec3.create(); + } + + // Normalize point coordinates to 0..1 scaling factor between x0 and x1. + var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); + var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); + var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); + + if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; + if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; + if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; + + var z0off = z0*w*h; + var z1off = z1*w*h; + + var y0off = y0*w; + var y1off = y1*w; + + var x0off = x0; + var x1off = x1; + + // Sample data array around the (x,y,z) point. + // vZYX = array[zZoff + yYoff + xXoff] + var v000 = array[y0off + z0off + x0off]; + var v001 = array[y0off + z0off + x1off]; + var v010 = array[y1off + z0off + x0off]; + var v011 = array[y1off + z0off + x1off]; + var v100 = array[y0off + z1off + x0off]; + var v101 = array[y0off + z1off + x1off]; + var v110 = array[y1off + z1off + x0off]; + var v111 = array[y1off + z1off + x1off]; + + var result = vec3.create(); + + // Average samples according to distance to point. + vec3.lerp(result, v000, v001, xf); + vec3.lerp(tmp, v010, v011, xf); + vec3.lerp(result, result, tmp, yf); + vec3.lerp(tmp, v100, v101, xf); + vec3.lerp(tmp2, v110, v111, xf); + vec3.lerp(tmp, tmp, tmp2, yf); + vec3.lerp(result, result, tmp, zf); + + return result; +}; + + +var vabs = function(dst, v) { + var x = v[0]; + var y = v[1]; + var z = v[2]; + dst[0] = x >= 0 ? x : -x; + dst[1] = y >= 0 ? y : -y; + dst[2] = z >= 0 ? z : -z; + return dst; +}; + +var findMinSeparation = function(xs) { + var minSeparation = 1/0; + xs.sort(function(a, b) { return a - b; }); + for (var i=1; i= minX && x <= maxX && + y >= minY && y <= maxY && + z >= minZ && z <= maxZ + ); + }; - //Release test program - gl.deleteProgram(testProgram) - } + var boundsSize = vec3.distance(bounds[0], bounds[1]); + var maxStepSize = 10 * boundsSize / maxLength; + var maxStepSizeSq = maxStepSize * maxStepSize; - //Sort attributes lexicographically - // overrides undefined WebGL behavior for attribute locations - attributes = attributes.slice() - attributes.sort(compareAttributes) + var minDistance = 1; + var maxDivergence = 0; // For component-wise divergence vec3.create(); + var tmp = vec3.create(); - //Convert attribute types, read out locations - var attributeUnpacked = [] - var attributeNames = [] - var attributeLocations = [] - var i - for(i=0; i= 0) { - var size = attr.type.charAt(attr.type.length-1)|0 - var locVector = new Array(size) - for(var j=0; j= 2) { + minDistance = calculateMinPositionDistance(positions); + } - //For all unspecified attributes, assign them lexicographically min attribute - var curLocation = 0 - for(i=0; i= 0) { - curLocation += 1 - } - attributeLocations[i] = curLocation - } - } + for (var i = 0; i < positions.length; i++) { + var p = vec3.create(); + vec3.copy(p, positions[i]); - //Rebuild program and recompute all uniform locations - var uniformLocations = new Array(uniforms.length) - function relink() { - wrapper.program = shaderCache.program( - gl - , wrapper._vref - , wrapper._fref - , attributeNames - , attributeLocations) + var stream = [p]; + var velocities = []; + var v = vectorField.getVelocity(p); + var op = p; + velocities.push(v); - for(var i=0; i maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { + maxDivergence = dvLength; + } + // In case we need to do component-wise divergence visualization + // vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); + divergences.push(dvLength); + + streams.push({points: stream, velocities: velocities, divergences: divergences}); + + var j = 0; + + while (j < maxLength * 100 && stream.length < maxLength && inBounds(bounds, p)) { + j++; + var np = vec3.clone(v); + var sqLen = vec3.squaredLength(np); + if (sqLen === 0) { + break; + } else if (sqLen > maxStepSizeSq) { + vec3.scale(np, np, maxStepSize / Math.sqrt(sqLen)); + } + vec3.add(np, np, p); + + v = vectorField.getVelocity(np); + + if (vec3.squaredDistance(op, np) - maxStepSizeSq > -0.0001 * maxStepSizeSq) { + stream.push(np); + op = np; + velocities.push(v); + var dv = vectorField.getDivergence(np, v); + var dvLength = vec3.length(dv); + if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { + maxDivergence = dvLength; + } + // In case we need to do component-wise divergence visualization + //vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); + divergences.push(dvLength); + } - //Save relinking procedure, defer until runtime - wrapper._relink = relink + p = np; + } + } - //Generate type info - wrapper.types = { - uniforms: makeReflect(uniforms), - attributes: makeReflect(attributes) - } + // Replace NaNs and Infinities with non-NaN, finite maxDivergence + for (var i=0; i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color — in vertex or in fragment\n vec4 surfaceColor =\n step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) +\n step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]) +var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform vec3 objectOffset;\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n worldCoordinate = objectOffset + dataCoordinate;\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z += zOffset;\n\n gl_Position = clipPosition;\n value = f + objectOffset.z;\n kill = -1.0;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]) +var pickSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]) +exports.createShader = function (gl) { + var shader = createShader(gl, vertSrc, fragSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'vec3'}, + {name: 'normal', type: 'vec3'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + shader.attributes.normal.location = 2 return shader } - -module.exports = createShader - -},{"./lib/GLError":149,"./lib/create-attributes":150,"./lib/create-uniforms":151,"./lib/reflect":152,"./lib/runtime-reflect":153,"./lib/shader-cache":154}],149:[function(_dereq_,module,exports){ -function GLError (rawError, shortMessage, longMessage) { - this.shortMessage = shortMessage || '' - this.longMessage = longMessage || '' - this.rawError = rawError || '' - this.message = - 'gl-shader: ' + (shortMessage || rawError || '') + - (longMessage ? '\n'+longMessage : '') - this.stack = (new Error()).stack +exports.createPickShader = function (gl) { + var shader = createShader(gl, vertSrc, pickSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'vec3'}, + {name: 'normal', type: 'vec3'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + shader.attributes.normal.location = 2 + return shader +} +exports.createContourShader = function (gl) { + var shader = createShader(gl, contourVertSrc, fragSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'float'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + return shader +} +exports.createPickContourShader = function (gl) { + var shader = createShader(gl, contourVertSrc, pickSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'float'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + return shader } -GLError.prototype = new Error -GLError.prototype.name = 'GLError' -GLError.prototype.constructor = GLError -module.exports = GLError -},{}],150:[function(_dereq_,module,exports){ +},{"gl-shader":148,"glslify":249}],162:[function(_dereq_,module,exports){ 'use strict' -module.exports = createAttributeWrapper +module.exports = createSurfacePlot -var GLError = _dereq_("./GLError") +var bits = _dereq_('bit-twiddle') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var pool = _dereq_('typedarray-pool') +var colormap = _dereq_('colormap') +var ops = _dereq_('ndarray-ops') +var pack = _dereq_('ndarray-pack') +var ndarray = _dereq_('ndarray') +var surfaceNets = _dereq_('surface-nets') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var bsearch = _dereq_('binary-search-bounds') +var gradient = _dereq_('ndarray-gradient') +var shaders = _dereq_('./lib/shaders') -function ShaderAttribute( - gl - , wrapper - , index - , locations - , dimension - , constFunc) { - this._gl = gl - this._wrapper = wrapper - this._index = index - this._locations = locations - this._dimension = dimension - this._constFunc = constFunc +var createShader = shaders.createShader +var createContourShader = shaders.createContourShader +var createPickShader = shaders.createPickShader +var createPickContourShader = shaders.createPickContourShader + +var SURFACE_VERTEX_SIZE = 4 * (4 + 3 + 3) + +var IDENTITY = [ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 ] + +var QUAD = [ + [0, 0], + [0, 1], + [1, 0], + [1, 1], + [1, 0], + [0, 1] +] + +var PERMUTATIONS = [ + [0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0] +] + +;(function () { + for (var i = 0; i < 3; ++i) { + var p = PERMUTATIONS[i] + var u = (i + 1) % 3 + var v = (i + 2) % 3 + p[u + 0] = 1 + p[v + 3] = 1 + p[i + 6] = 1 + } +})() + +function SurfacePickResult (position, index, uv, level, dataCoordinate) { + this.position = position + this.index = index + this.uv = uv + this.level = level + this.dataCoordinate = dataCoordinate } -var proto = ShaderAttribute.prototype +var N_COLORS = 256 -proto.pointer = function setAttribPointer( - type - , normalized - , stride - , offset) { +function genColormap (name) { + var x = pack([colormap({ + colormap: name, + nshades: N_COLORS, + format: 'rgba' + }).map(function (c) { + return [c[0], c[1], c[2], 255 * c[3]] + })]) + ops.divseq(x, 255.0) + return x +} - var self = this - var gl = self._gl - var location = self._locations[self._index] +function SurfacePlot ( + gl, + shape, + bounds, + shader, + pickShader, + coordinates, + vao, + colorMap, + contourShader, + contourPickShader, + contourBuffer, + contourVAO, + dynamicBuffer, + dynamicVAO, + objectOffset) { + this.gl = gl + this.shape = shape + this.bounds = bounds + this.objectOffset = objectOffset + this.intensityBounds = [] + + this._shader = shader + this._pickShader = pickShader + this._coordinateBuffer = coordinates + this._vao = vao + this._colorMap = colorMap + + this._contourShader = contourShader + this._contourPickShader = contourPickShader + this._contourBuffer = contourBuffer + this._contourVAO = contourVAO + this._contourOffsets = [[], [], []] + this._contourCounts = [[], [], []] + this._vertexCount = 0 + + this._pickResult = new SurfacePickResult([0, 0, 0], [0, 0], [0, 0], [0, 0, 0], [0, 0, 0]) + + this._dynamicBuffer = dynamicBuffer + this._dynamicVAO = dynamicVAO + this._dynamicOffsets = [0, 0, 0] + this._dynamicCounts = [0, 0, 0] + + this.contourWidth = [ 1, 1, 1 ] + this.contourLevels = [[1], [1], [1]] + this.contourTint = [0, 0, 0] + this.contourColor = [[0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1]] + + this.showContour = true + this.showSurface = true + + this.enableHighlight = [true, true, true] + this.highlightColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]] + this.highlightTint = [ 1, 1, 1 ] + this.highlightLevel = [-1, -1, -1] + + // Dynamic contour options + this.enableDynamic = [ true, true, true ] + this.dynamicLevel = [ NaN, NaN, NaN ] + this.dynamicColor = [ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1] ] + this.dynamicTint = [ 1, 1, 1 ] + this.dynamicWidth = [ 1, 1, 1 ] + + this.axesBounds = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]] + this.surfaceProject = [ false, false, false ] + this.contourProject = [[ false, false, false ], + [ false, false, false ], + [ false, false, false ]] + + this.colorBounds = [ false, false ] + + // Store xyz fields, need this for picking + this._field = [ + ndarray(pool.mallocFloat(1024), [0, 0]), + ndarray(pool.mallocFloat(1024), [0, 0]), + ndarray(pool.mallocFloat(1024), [0, 0]) ] + + this.pickId = 1 + this.clipBounds = [[-Infinity, -Infinity, -Infinity], [Infinity, Infinity, Infinity]] + + this.snapToData = false + + this.opacity = 1.0 + + this.lightPosition = [10, 10000, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + this.vertexColor = 0 - gl.vertexAttribPointer( - location - , self._dimension - , type || gl.FLOAT - , !!normalized - , stride || 0 - , offset || 0) - gl.enableVertexAttribArray(location) + this.dirty = true } -proto.set = function(x0, x1, x2, x3) { - return this._constFunc(this._locations[this._index], x0, x1, x2, x3) +var proto = SurfacePlot.prototype + +proto.isTransparent = function () { + return this.opacity < 1 } -Object.defineProperty(proto, 'location', { - get: function() { - return this._locations[this._index] +proto.isOpaque = function () { + if (this.opacity >= 1) { + return true } - , set: function(v) { - if(v !== this._locations[this._index]) { - this._locations[this._index] = v|0 - this._wrapper.program = null + for (var i = 0; i < 3; ++i) { + if (this._contourCounts[i].length > 0 || this._dynamicCounts[i] > 0) { + return true } - return v|0 } -}) + return false +} -//Adds a vector attribute to obj -function addVectorAttribute( - gl - , wrapper - , index - , locations - , dimension - , obj - , name) { +proto.pickSlots = 1 - //Construct constant function - var constFuncArgs = [ 'gl', 'v' ] - var varNames = [] - for(var i=0; i 0)][i] + multiply(axisSquish, camera.model, axisSquish) -function addMatrixAttribute( - gl - , wrapper - , index - , locations - , dimension - , obj - , name) { + var nclipBounds = PROJECT_DATA.clipBounds[i] + for (k = 0; k < 2; ++k) { + for (j = 0; j < 3; ++j) { + nclipBounds[k][j] = camera.clipBounds[k][j] + } + } + nclipBounds[0][i] = -1e8 + nclipBounds[1][i] = 1e8 + } + + PROJECT_DATA.showSurface = showSurface + PROJECT_DATA.showContour = showContour + + return PROJECT_DATA +} + +var UNIFORMS = { + model: IDENTITY, + view: IDENTITY, + projection: IDENTITY, + inverseModel: IDENTITY.slice(), + lowerBound: [0, 0, 0], + upperBound: [0, 0, 0], + colorMap: 0, + clipBounds: [[0, 0, 0], [0, 0, 0]], + height: 0.0, + contourTint: 0, + contourColor: [0, 0, 0, 1], + permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], + zOffset: -1e-4, + objectOffset: [0, 0, 0], + kambient: 1, + kdiffuse: 1, + kspecular: 1, + lightPosition: [1000, 1000, 1000], + eyePosition: [0, 0, 0], + roughness: 1, + fresnel: 1, + opacity: 1, + vertexColor: 0 +} + +var MATRIX_INVERSE = IDENTITY.slice() +var DEFAULT_PERM = [1, 0, 0, 0, 1, 0, 0, 0, 1] + +function drawCore (params, transparent) { + params = params || {} + var gl = this.gl - var parts = new Array(dimension) - var attrs = new Array(dimension) - for(var i=0; i= 0) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) - } - addVectorAttribute( - gl - , wrapper - , locs[0] - , locations - , d - , obj - , name) - } else if(type.indexOf('mat') >= 0) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) - } - addMatrixAttribute( - gl - , wrapper - , locs - , locations - , d - , obj - , name) - } else { - throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) + shader.uniforms.contourColor = this.dynamicColor[i] + shader.uniforms.contourTint = this.dynamicTint[i] + shader.uniforms.height = this.dynamicLevel[i] + vao.draw(gl.LINES, this._dynamicCounts[i], this._dynamicOffsets[i]) + + for (j = 0; j < 3; ++j) { + if (!this.contourProject[j][i]) { + continue } - break + + shader.uniforms.model = projectData.projections[j] + shader.uniforms.clipBounds = projectData.clipBounds[j] + vao.draw(gl.LINES, this._dynamicCounts[i], this._dynamicOffsets[i]) + } } + + vao.unbind() } - return obj } -},{"./GLError":149}],151:[function(_dereq_,module,exports){ -'use strict' - -var coallesceUniforms = _dereq_('./reflect') -var GLError = _dereq_("./GLError") - -module.exports = createUniformWrapper +proto.draw = function (params) { + return drawCore.call(this, params, false) +} -//Binds a function and returns a value -function identity(x) { - var c = new Function('y', 'return function(){return y}') - return c(x) +proto.drawTransparent = function (params) { + return drawCore.call(this, params, true) } -function makeVector(length, fill) { - var result = new Array(length) - for(var i=0; i 4) { - throw new GLError('', 'Invalid data type') - } - switch(type.charAt(0)) { - case 'b': - case 'i': - return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' - case 'v': - return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' - default: - throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) - } - } else if(type.indexOf('mat') === 0 && type.length === 4) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) - } - return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' - } else { - throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) - } - break + for (var i = 0; i < 2; ++i) { + var clipClamped = uniforms.clipBounds[i] + for (var j = 0; j < 3; ++j) { + clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) } } - function enumerateIndices(prefix, type) { - if(typeof type !== 'object') { - return [ [prefix, type] ] - } - var indices = [] - for(var id in type) { - var prop = type[id] - var tprefix = prefix - if(parseInt(id) + '' === id) { - tprefix += '[' + id + ']' - } else { - tprefix += '.' + id - } - if(typeof prop === 'object') { - indices.push.apply(indices, enumerateIndices(tprefix, prop)) - } else { - indices.push([tprefix, prop]) + var projectData = computeProjectionData(uniforms, this) + + if (projectData.showSurface) { + // Set up uniforms + this._pickShader.bind() + this._pickShader.uniforms = uniforms + + // Draw it + this._vao.bind() + this._vao.draw(gl.TRIANGLES, this._vertexCount) + + // Draw projections of surface + for (i = 0; i < 3; ++i) { + if (!this.surfaceProject[i]) { + continue } + this._pickShader.uniforms.model = projectData.projections[i] + this._pickShader.uniforms.clipBounds = projectData.clipBounds[i] + this._vao.draw(gl.TRIANGLES, this._vertexCount) } - return indices + + this._vao.unbind() } - function makeSetter(type) { - var code = [ 'return function updateProperty(obj){' ] - var indices = enumerateIndices('', type) - for(var i=0; i 4) { - throw new GLError('', 'Invalid data type') - } - if(type.charAt(0) === 'b') { - return makeVector(d, false) - } - return makeVector(d, 0) - } else if(type.indexOf('mat') === 0 && type.length === 4) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) + // Draw projections of surface + for (i = 0; i < 3; ++i) { + shader.uniforms.model = projectData.projections[i] + shader.uniforms.clipBounds = projectData.clipBounds[i] + + for (j = 0; j < 3; ++j) { + if (!this.contourProject[i][j]) { + continue + } + + shader.uniforms.permutation = PERMUTATIONS[j] + gl.lineWidth(this.contourWidth[j]) + for (var k = 0; k < this.contourLevels[j].length; ++k) { + if (this._contourCounts[j][k]) { + shader.uniforms.height = this.contourLevels[j][k] + vao.draw(gl.LINES, this._contourCounts[j][k], this._contourOffsets[j][k]) } - return makeVector(d*d, 0) - } else { - throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) } - break + } } + + vao.unbind() } +} - function storeProperty(obj, prop, type) { - if(typeof type === 'object') { - var child = processObject(type) - Object.defineProperty(obj, prop, { - get: identity(child), - set: makeSetter(type), - enumerable: true, - configurable: false - }) - } else { - if(locations[type]) { - Object.defineProperty(obj, prop, { - get: makeGetter(type), - set: makeSetter(type), - enumerable: true, - configurable: false - }) - } else { - obj[prop] = defaultValue(uniforms[type].type) +proto.pick = function (selection) { + if (!selection) { + return null + } + + if (selection.id !== this.pickId) { + return null + } + + var shape = this._field[2].shape + + var result = this._pickResult + + // Compute uv coordinate + var x = shape[0] * (selection.value[0] + (selection.value[2] >> 4) / 16.0) / 255.0 + var ix = Math.floor(x) + var fx = x - ix + + var y = shape[1] * (selection.value[1] + (selection.value[2] & 15) / 16.0) / 255.0 + var iy = Math.floor(y) + var fy = y - iy + + ix += 1 + iy += 1 + + // Compute xyz coordinate + var pos = result.position + pos[0] = pos[1] = pos[2] = 0 + for (var dx = 0; dx < 2; ++dx) { + var s = dx ? fx : 1.0 - fx + for (var dy = 0; dy < 2; ++dy) { + var t = dy ? fy : 1.0 - fy + + var r = ix + dx + var c = iy + dy + var w = s * t + + for (var i = 0; i < 3; ++i) { + pos[i] += this._field[i].get(r, c) * w } } } - function processObject(obj) { - var result - if(Array.isArray(obj)) { - result = new Array(obj.length) - for(var i=0; i 0) { + levelIndex[j] = 0 } - } else { - result = {} - for(var id in obj) { - storeProperty(result, id, obj[id]) + } else if (levelIndex[j] < this.contourLevels[j].length - 1) { + var a = this.contourLevels[j][levelIndex[j]] + var b = this.contourLevels[j][levelIndex[j] + 1] + if (Math.abs(a - pos[j]) > Math.abs(b - pos[j])) { + levelIndex[j] += 1 } } - return result } - //Return data - var coallesced = coallesceUniforms(uniforms, true) - return { - get: identity(processObject(coallesced)), - set: makeSetter(coallesced), - enumerable: true, - configurable: true + result.index[0] = fx < 0.5 ? ix : (ix + 1) + result.index[1] = fy < 0.5 ? iy : (iy + 1) + + result.uv[0] = x / shape[0] + result.uv[1] = y / shape[1] + + for (i = 0; i < 3; ++i) { + result.dataCoordinate[i] = this._field[i].get(result.index[0], result.index[1]) } + + return result } -},{"./GLError":149,"./reflect":152}],152:[function(_dereq_,module,exports){ -'use strict' +proto.padField = function(dstField, srcField) { + var srcShape = srcField.shape.slice() + var dstShape = dstField.shape.slice() -module.exports = makeReflectTypes + // Center + ops.assign(dstField.lo(1, 1).hi(srcShape[0], srcShape[1]), srcField) -//Construct type info for reflection. -// -// This iterates over the flattened list of uniform type values and smashes them into a JSON object. -// -// The leaves of the resulting object are either indices or type strings representing primitive glslify types -function makeReflectTypes(uniforms, useIndex) { - var obj = {} - for(var i=0; i 1) { - if(!(x[0] in o)) { - o[x[0]] = [] + // Edges + ops.assign(dstField.lo(1).hi(srcShape[0], 1), + srcField.hi(srcShape[0], 1)) + ops.assign(dstField.lo(1, dstShape[1] - 1).hi(srcShape[0], 1), + srcField.lo(0, srcShape[1] - 1).hi(srcShape[0], 1)) + ops.assign(dstField.lo(0, 1).hi(1, srcShape[1]), + srcField.hi(1)) + ops.assign(dstField.lo(dstShape[0] - 1, 1).hi(1, srcShape[1]), + srcField.lo(srcShape[0] - 1)) + // Corners + dstField.set(0, 0, srcField.get(0, 0)) + dstField.set(0, dstShape[1] - 1, srcField.get(0, srcShape[1] - 1)) + dstField.set(dstShape[0] - 1, 0, srcField.get(srcShape[0] - 1, 0)) + dstField.set(dstShape[0] - 1, dstShape[1] - 1, srcField.get(srcShape[0] - 1, srcShape[1] - 1)) +} + +function handleArray (param, ctor) { + if (Array.isArray(param)) { + return [ ctor(param[0]), ctor(param[1]), ctor(param[2]) ] + } + return [ ctor(param), ctor(param), ctor(param) ] +} + +function toColor (x) { + if (Array.isArray(x)) { + if (x.length === 3) { + return [x[0], x[1], x[2], 1] + } + return [x[0], x[1], x[2], x[3]] + } + return [0, 0, 0, 1] +} + +function handleColor (param) { + if (Array.isArray(param)) { + if (Array.isArray(param)) { + return [ + toColor(param[0]), + toColor(param[1]), + toColor(param[2]) ] + } else { + var c = toColor(param) + return [ + c.slice(), + c.slice(), + c.slice() ] + } + } +} + +proto.update = function (params) { + params = params || {} + + this.objectOffset = params.objectOffset || this.objectOffset + + this.dirty = true + + if ('contourWidth' in params) { + this.contourWidth = handleArray(params.contourWidth, Number) + } + if ('showContour' in params) { + this.showContour = handleArray(params.showContour, Boolean) + } + if ('showSurface' in params) { + this.showSurface = !!params.showSurface + } + if ('contourTint' in params) { + this.contourTint = handleArray(params.contourTint, Boolean) + } + if ('contourColor' in params) { + this.contourColor = handleColor(params.contourColor) + } + if ('contourProject' in params) { + this.contourProject = handleArray(params.contourProject, function (x) { + return handleArray(x, Boolean) + }) + } + if ('surfaceProject' in params) { + this.surfaceProject = params.surfaceProject + } + if ('dynamicColor' in params) { + this.dynamicColor = handleColor(params.dynamicColor) + } + if ('dynamicTint' in params) { + this.dynamicTint = handleArray(params.dynamicTint, Number) + } + if ('dynamicWidth' in params) { + this.dynamicWidth = handleArray(params.dynamicWidth, Number) + } + if ('opacity' in params) { + this.opacity = params.opacity + } + if ('colorBounds' in params) { + this.colorBounds = params.colorBounds + } + if ('vertexColor' in params) { + this.vertexColor = params.vertexColor ? 1 : 0; + } + + var field = params.field || (params.coords && params.coords[2]) || null + var levelsChanged = false + + if (!field) { + if (this._field[2].shape[0] || this._field[2].shape[2]) { + field = this._field[2].lo(1, 1).hi(this._field[2].shape[0] - 2, this._field[2].shape[1] - 2) + } else { + field = this._field[2].hi(0, 0) + } + } + + // Update field + if ('field' in params || 'coords' in params) { + var fsize = (field.shape[0] + 2) * (field.shape[1] + 2) + + // Resize if necessary + if (fsize > this._field[2].data.length) { + pool.freeFloat(this._field[2].data) + this._field[2].data = pool.mallocFloat(bits.nextPow2(fsize)) + } + + // Pad field + this._field[2] = ndarray(this._field[2].data, [field.shape[0] + 2, field.shape[1] + 2]) + this.padField(this._field[2], field) + + // Save shape of field + this.shape = field.shape.slice() + var shape = this.shape + + // Resize coordinate fields if necessary + for (var i = 0; i < 2; ++i) { + if (this._field[2].size > this._field[i].data.length) { + pool.freeFloat(this._field[i].data) + this._field[i].data = pool.mallocFloat(this._field[2].size) + } + this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2]) + } + + // Generate x/y coordinates + if (params.coords) { + var coords = params.coords + if (!Array.isArray(coords) || coords.length !== 3) { + throw new Error('gl-surface: invalid coordinates for x/y') + } + for (i = 0; i < 2; ++i) { + var coord = coords[i] + for (j = 0; j < 2; ++j) { + if (coord.shape[j] !== shape[j]) { + throw new Error('gl-surface: coords have incorrect shape') + } } - o = o[x[0]] - for(var k=1; k 1) { - for(var j=0; j 0) { + // If we already added first edge, pop off verts + for (var l = 0; l < 5; ++l) { + contourVerts.pop() + } + vertexCount -= 1 + } + continue edge_loop + } + } + } + levelCounts.push(vertexCount) } + + // Store results + this._contourOffsets[dim] = levelOffsets + this._contourCounts[dim] = levelCounts + } - //Remove shader reference - gl.deleteShader(this.shader) - delete cache.shaders[(this.type === gl.FRAGMENT_SHADER)|0][this.src] + var floatBuffer = pool.mallocFloat(contourVerts.length) + for (i = 0; i < contourVerts.length; ++i) { + floatBuffer[i] = contourVerts[i] + } + this._contourBuffer.update(floatBuffer) + pool.freeFloat(floatBuffer) + } + + if (params.colormap) { + this._colorMap.setPixels(genColormap(params.colormap)) } } -function ContextCache(gl) { - this.gl = gl - this.shaders = [{}, {}] - this.programs = {} +proto.dispose = function () { + this._shader.dispose() + this._vao.dispose() + this._coordinateBuffer.dispose() + this._colorMap.dispose() + this._contourBuffer.dispose() + this._contourVAO.dispose() + this._contourShader.dispose() + this._contourPickShader.dispose() + this._dynamicBuffer.dispose() + this._dynamicVAO.dispose() + for (var i = 0; i < 3; ++i) { + pool.freeFloat(this._field[i].data) + } } -var proto = ContextCache.prototype +proto.highlight = function (selection) { + var i -function compileShader(gl, type, src) { - var shader = gl.createShader(type) - gl.shaderSource(shader, src) - gl.compileShader(shader) - if(!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - var errLog = gl.getShaderInfoLog(shader) - try { - var fmt = formatCompilerError(errLog, src, type); - } catch (e){ - console.warn('Failed to format compiler error: ' + e); - throw new GLError(errLog, 'Error compiling shader:\n' + errLog) + if (!selection) { + this._dynamicCounts = [0, 0, 0] + this.dyanamicLevel = [NaN, NaN, NaN] + this.highlightLevel = [-1, -1, -1] + return + } + + for (i = 0; i < 3; ++i) { + if (this.enableHighlight[i]) { + this.highlightLevel[i] = selection.level[i] + } else { + this.highlightLevel[i] = -1 } - throw new GLError(errLog, fmt.short, fmt.long) } - return shader -} -proto.getShaderReference = function(type, src) { - var gl = this.gl - var shaders = this.shaders[(type === gl.FRAGMENT_SHADER)|0] - var shader = shaders[src] - if(!shader || !gl.isShader(shader.shader)) { - var shaderObj = compileShader(gl, type, src) - shader = shaders[src] = new ShaderReference( - SHADER_COUNTER++, - src, - type, - shaderObj, - [], - 1, - this) + var levels + if (this.snapToData) { + levels = selection.dataCoordinate } else { - shader.count += 1 + levels = selection.position } - return shader -} + for (i = 0; i < 3; ++i) { + levels[i] -= this.objectOffset[i] + } + if ((!this.enableDynamic[0] || levels[0] === this.dynamicLevel[0]) && + (!this.enableDynamic[1] || levels[1] === this.dynamicLevel[1]) && + (!this.enableDynamic[2] || levels[2] === this.dynamicLevel[2])) { + return + } + + var vertexCount = 0 + var shape = this.shape + var scratchBuffer = pool.mallocFloat(12 * shape[0] * shape[1]) + + for (var d = 0; d < 3; ++d) { + if (!this.enableDynamic[d]) { + this.dynamicLevel[d] = NaN + this._dynamicCounts[d] = 0 + continue + } + + this.dynamicLevel[d] = levels[d] + + var u = (d + 1) % 3 + var v = (d + 2) % 3 + + var f = this._field[d] + var g = this._field[u] + var h = this._field[v] + + var graph = surfaceNets(f, levels[d]) + var edges = graph.cells + var positions = graph.positions + + this._dynamicOffsets[d] = vertexCount + + for (i = 0; i < edges.length; ++i) { + var e = edges[i] + for (var j = 0; j < 2; ++j) { + var p = positions[e[j]] + + var x = +p[0] + var ix = x | 0 + var jx = Math.min(ix + 1, shape[0]) | 0 + var fx = x - ix + var hx = 1.0 - fx + + var y = +p[1] + var iy = y | 0 + var jy = Math.min(iy + 1, shape[1]) | 0 + var fy = y - iy + var hy = 1.0 - fy + + var w00 = hx * hy + var w01 = hx * fy + var w10 = fx * hy + var w11 = fx * fy + + var cu = w00 * g.get(ix, iy) + + w01 * g.get(ix, jy) + + w10 * g.get(jx, iy) + + w11 * g.get(jx, jy) + + var cv = w00 * h.get(ix, iy) + + w01 * h.get(ix, jy) + + w10 * h.get(jx, iy) + + w11 * h.get(jx, jy) + + if (isNaN(cu) || isNaN(cv)) { + if (j) { + vertexCount -= 1 + } + break + } -function linkProgram(gl, vshader, fshader, attribs, locations) { - var program = gl.createProgram() - gl.attachShader(program, vshader) - gl.attachShader(program, fshader) - for(var i=0; i 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]) -var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) -var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) - -exports.meshShader = { - vertex: triVertSrc, - fragment: triFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'normal', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'}, - {name: 'vector', type: 'vec4'} - ] -} -exports.pickShader = { - vertex: pickVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'id', type: 'vec4'}, - {name: 'vector', type: 'vec4'} - ] -} + var dynamicBuffer = createBuffer(gl) + var dynamicVAO = createVAO(gl, [ + { + buffer: dynamicBuffer, + size: 2, + type: gl.FLOAT + }]) -},{"glslify":249}],159:[function(_dereq_,module,exports){ -'use strict' - -var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small -var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var normals = _dereq_('normals') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var ndarray = _dereq_('ndarray') -var colormap = _dereq_('colormap') -var getContour = _dereq_('simplicial-complex-contour') -var pool = _dereq_('typedarray-pool') -var shaders = _dereq_('./shaders') -var closestPoint = _dereq_('./closest-point') - -var meshShader = shaders.meshShader -var pickShader = shaders.pickShader - -var identityMatrix = [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - -function SimplicialMesh(gl - , texture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) { - - this.gl = gl - this.cells = [] - this.positions = [] - this.intensity = [] - this.texture = texture - this.dirty = true - - this.triShader = triShader - this.lineShader = lineShader - this.pointShader = pointShader - this.pickShader = pickShader - this.pointPickShader = pointPickShader - this.contourShader = contourShader - - this.trianglePositions = trianglePositions - this.triangleVectors = triangleVectors - this.triangleColors = triangleColors - this.triangleNormals = triangleNormals - this.triangleUVs = triangleUVs - this.triangleIds = triangleIds - this.triangleVAO = triangleVAO - this.triangleCount = 0 - - this.lineWidth = 1 - this.edgePositions = edgePositions - this.edgeColors = edgeColors - this.edgeUVs = edgeUVs - this.edgeIds = edgeIds - this.edgeVAO = edgeVAO - this.edgeCount = 0 - - this.pointPositions = pointPositions - this.pointColors = pointColors - this.pointUVs = pointUVs - this.pointSizes = pointSizes - this.pointIds = pointIds - this.pointVAO = pointVAO - this.pointCount = 0 - - this.contourLineWidth = 1 - this.contourPositions = contourPositions - this.contourVAO = contourVAO - this.contourCount = 0 - this.contourColor = [0,0,0] - this.contourEnable = false - - this.pickId = 1 - this.bounds = [ - [ Infinity, Infinity, Infinity], - [-Infinity,-Infinity,-Infinity] ] - this.clipBounds = [ - [-Infinity,-Infinity,-Infinity], - [ Infinity, Infinity, Infinity] ] - - this.lightPosition = [1e5, 1e5, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - - this.opacity = 1.0 - - this.tubeScale = 1.0 - - this._model = identityMatrix - this._view = identityMatrix - this._projection = identityMatrix - this._resolution = [1,1] -} - -var proto = SimplicialMesh.prototype - -proto.isOpaque = function() { - return this.opacity >= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.pickSlots = 1 - -proto.setPickBase = function(id) { - this.pickId = id -} - -function genColormap(param) { - var colors = colormap({ - colormap: param - , nshades: 256 - , format: 'rgba' - }) - - var result = new Uint8Array(256*4) - for(var i=0; i<256; ++i) { - var c = colors[i] - for(var j=0; j<3; ++j) { - result[4*i+j] = c[j] - } - result[4*i+3] = c[3]*255 - } - - return ndarray(result, [256,256,4], [4,0,1]) -} - -function unpackIntensity(cells, numVerts, cellIntensity) { - var result = new Array(numVerts) - for(var i=0; i 0) { - var shader = this.triShader - shader.bind() - shader.uniforms = uniforms - - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0 && this.lineWidth > 0) { - var shader = this.lineShader - shader.bind() - shader.uniforms = uniforms - - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } - - if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { - var shader = this.contourShader - shader.bind() - shader.uniforms = uniforms - - this.contourVAO.bind() - gl.drawArrays(gl.LINES, 0, this.contourCount) - this.contourVAO.unbind() - } -} - -proto.drawPick = function(params) { - params = params || {} - - var gl = this.gl - - var model = params.model || identityMatrix - var view = params.view || identityMatrix - var projection = params.projection || identityMatrix - - var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] - for(var i=0; i<3; ++i) { - clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) - clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) - } - - //Save camera parameters - this._model = [].slice.call(model) - this._view = [].slice.call(view) - this._projection = [].slice.call(projection) - this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - - var uniforms = { - model: model, - view: view, - projection: projection, - clipBounds: clipBounds, - - tubeScale: this.tubeScale, - - pickId: this.pickId / 255.0, - } - - var shader = this.pickShader - shader.bind() - shader.uniforms = uniforms - - if(this.triangleCount > 0) { - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0) { - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointPickShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } -} - - -proto.pick = function(pickData) { - if(!pickData) { - return null - } - if(pickData.id !== this.pickId) { - return null - } - - var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] - var cell = this.cells[cellId] - - var pos = this.positions[cell[1]].slice(0, 3) - var intensity = this.intensity[cell[1]] - var velocity = this.vectors[cell[1]].slice(0, 3) - var divergence = this.vectors[cell[1]][3] - - return { - index: cellId, - position: pos, - intensity: intensity, - velocity: velocity, - divergence: divergence, - dataCoordinate: pos - } -} - - -proto.dispose = function() { - this.texture.dispose() - - this.triShader.dispose() - // this.lineShader.dispose() - // this.pointShader.dispose() - this.pickShader.dispose() - // this.pointPickShader.dispose() - - this.triangleVAO.dispose() - this.trianglePositions.dispose() - this.triangleVectors.dispose() - this.triangleColors.dispose() - this.triangleUVs.dispose() - this.triangleNormals.dispose() - this.triangleIds.dispose() - - this.edgeVAO.dispose() - this.edgePositions.dispose() - this.edgeColors.dispose() - this.edgeUVs.dispose() - this.edgeIds.dispose() - - this.pointVAO.dispose() - this.pointPositions.dispose() - this.pointColors.dispose() - this.pointUVs.dispose() - this.pointSizes.dispose() - this.pointIds.dispose() - - this.contourVAO.dispose() - this.contourPositions.dispose() - // this.contourShader.dispose() -} - -function createMeshShader(gl) { - var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.vector.location = 5 - return shader -} - -function createWireShader(gl) { - var shader = createShader(gl, wireShader.vertex, wireShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - return shader -} - -function createPointShader(gl) { - var shader = createShader(gl, pointShader.vertex, pointShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.pointSize.location = 4 - return shader -} - -function createPickShader(gl) { - var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.vector.location = 5 - return shader -} - -function createPointPickShader(gl) { - var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.pointSize.location = 4 - return shader -} - -function createContourShader(gl) { - var shader = createShader(gl, contourShader.vertex, contourShader.fragment) - shader.attributes.position.location = 0 - return shader -} - -function createSimplicialMesh(gl, params) { - if (arguments.length === 1) { - params = gl; - gl = params.gl; - } - - var triShader = params.triShader || createMeshShader(gl) - var lineShader = null; //createWireShader(gl) - var pointShader = null; //createPointShader(gl) - var pickShader = createPickShader(gl) - var pointPickShader = null; //createPointPickShader(gl) - var contourShader = null; //createContourShader(gl) - - var meshTexture = createTexture(gl, - ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) - meshTexture.generateMipmap() - meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR - meshTexture.magFilter = gl.LINEAR - - var trianglePositions = createBuffer(gl) - var triangleVectors = createBuffer(gl) - var triangleColors = createBuffer(gl) - var triangleUVs = createBuffer(gl) - var triangleNormals = createBuffer(gl) - var triangleIds = createBuffer(gl) - var triangleVAO = createVAO(gl, [ - { buffer: trianglePositions, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: triangleColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: triangleNormals, - type: gl.FLOAT, - size: 3 - }, - { buffer: triangleVectors, - type: gl.FLOAT, - size: 4 - } - ]) - - var edgePositions = createBuffer(gl) - var edgeColors = createBuffer(gl) - var edgeUVs = createBuffer(gl) - var edgeIds = createBuffer(gl) - var edgeVAO = createVAO(gl, [ - { buffer: edgePositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: edgeIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: edgeColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: edgeUVs, - type: gl.FLOAT, - size: 2 - } - ]) - - var pointPositions = createBuffer(gl) - var pointColors = createBuffer(gl) - var pointUVs = createBuffer(gl) - var pointSizes = createBuffer(gl) - var pointIds = createBuffer(gl) - var pointVAO = createVAO(gl, [ - { buffer: pointPositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: pointIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: pointColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: pointUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: pointSizes, - type: gl.FLOAT, - size: 1 - } - ]) - - var contourPositions = createBuffer(gl) - var contourVAO = createVAO(gl, [ - { buffer: contourPositions, - type: gl.FLOAT, - size: 3 - }]) - - var mesh = new SimplicialMesh(gl - , meshTexture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) - - mesh.update(params) - - return mesh -} - -module.exports = createSimplicialMesh + var cmap = createTexture(gl, 1, N_COLORS, gl.RGBA, gl.UNSIGNED_BYTE) + cmap.minFilter = gl.LINEAR + cmap.magFilter = gl.LINEAR -},{"./closest-point":157,"./shaders":158,"colormap":69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-shader":148,"gl-texture2d":163,"gl-vao":167,"ndarray":285,"normals":287,"simplicial-complex-contour":329,"typedarray-pool":348}],160:[function(_dereq_,module,exports){ -"use strict"; - -var vec3 = _dereq_('gl-vec3'); -var vec4 = _dereq_('gl-vec4'); - -var streamToTube = function(stream, maxDivergence, minDistance, maxNorm) { - var points = stream.points; - var velocities = stream.velocities; - var divergences = stream.divergences; - - var p, fwd, r, u, v, up; - up = vec3.set(vec3.create(), 0, 1, 0); - u = vec3.create(); - v = vec3.create(); - var p2 = vec3.create(); - - var verts = []; - var faces = []; - var vectors = []; - var previousVerts = []; - var currentVerts = []; - var intensities = []; - var previousIntensity = 0; - var currentIntensity = 0; - var currentVector = vec4.create(); - var previousVector = vec4.create(); - - var facets = 8; - - for (var i = 0; i < points.length; i++) { - p = points[i]; - fwd = velocities[i]; - r = divergences[i]; - if (maxDivergence === 0) { - r = minDistance * 0.05; - } - currentIntensity = vec3.length(fwd) / maxNorm; - currentVector = vec4.create(); - vec3.copy(currentVector, fwd); - currentVector[3] = r; - - for (var a = 0; a < facets; a++) { - currentVerts[a] = [p[0], p[1], p[2], a]; - } - if (previousVerts.length > 0) { - for (var a = 0; a < facets; a++) { - var a1 = (a+1) % facets; - verts.push( - previousVerts[a], - currentVerts[a], - currentVerts[a1], - - currentVerts[a1], - previousVerts[a1], - previousVerts[a] - ); - vectors.push( - previousVector, - currentVector, - currentVector, - - currentVector, - previousVector, - previousVector - ); - intensities.push( - previousIntensity, - currentIntensity, - currentIntensity, - - currentIntensity, - previousIntensity, - previousIntensity - ); - faces.push( - [verts.length-6, verts.length-5, verts.length-4], - [verts.length-3, verts.length-2, verts.length-1] - ); - } - } - var tmp = previousVerts; - previousVerts = currentVerts; - currentVerts = tmp; - tmp = previousVector; - previousVector = currentVector; - currentVector = tmp; - tmp = previousIntensity; - previousIntensity = currentIntensity; - currentIntensity = tmp; - } - return { - positions: verts, - cells: faces, - vectors: vectors, - vertexIntensity: intensities - }; - -}; - -var createTubes = function(streams, colormap, maxDivergence, minDistance) { - - var maxNorm = 0; - for (var i=0; i maxNorm) { - maxNorm = norm; - } - } - } - - var tubes = streams.map(function(s) { - return streamToTube(s, maxDivergence, minDistance, maxNorm); - }); - - var positions = []; - var cells = []; - var vectors = []; - var vertexIntensity = []; - for (var i=0; i < tubes.length; i++) { - var tube = tubes[i]; - var offset = positions.length; - positions = positions.concat(tube.positions); - vectors = vectors.concat(tube.vectors); - vertexIntensity = vertexIntensity.concat(tube.vertexIntensity); - for (var j=0; j v) return i-1; - } - return i; -}; - -var tmp = vec3.create(); -var tmp2 = vec3.create(); - -var clamp = function(v, min, max) { - return v < min ? min : (v > max ? max : v); -}; - -var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { - var x = point[0]; - var y = point[1]; - var z = point[2]; - - var w = meshgrid[0].length; - var h = meshgrid[1].length; - var d = meshgrid[2].length; - - // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). - // The nearest smaller value index for x is the index x0 such that - // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. - var x0 = findLastSmallerIndex(meshgrid[0], x); - var y0 = findLastSmallerIndex(meshgrid[1], y); - var z0 = findLastSmallerIndex(meshgrid[2], z); - - // Get the nearest larger meshgrid value indices. - // From the above "nearest smaller value", we know that - // meshgrid[0][x0] < x - // meshgrid[0][x0+1] >= x - var x1 = x0 + 1; - var y1 = y0 + 1; - var z1 = z0 + 1; - - if (meshgrid[0][x0] === x) x1 = x0; - if (meshgrid[1][y0] === y) y1 = y0; - if (meshgrid[2][z0] === z) z1 = z0; - - if (clampOverflow) { - x0 = clamp(x0, 0, w-1); - x1 = clamp(x1, 0, w-1); - y0 = clamp(y0, 0, h-1); - y1 = clamp(y1, 0, h-1); - z0 = clamp(z0, 0, d-1); - z1 = clamp(z1, 0, d-1); - } - - // Reject points outside the meshgrid, return a zero vector. - if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { - return vec3.create(); - } - - // Normalize point coordinates to 0..1 scaling factor between x0 and x1. - var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); - var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); - var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); - - if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; - if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; - if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; - - var z0off = z0*w*h; - var z1off = z1*w*h; - - var y0off = y0*w; - var y1off = y1*w; - - var x0off = x0; - var x1off = x1; - - // Sample data array around the (x,y,z) point. - // vZYX = array[zZoff + yYoff + xXoff] - var v000 = array[y0off + z0off + x0off]; - var v001 = array[y0off + z0off + x1off]; - var v010 = array[y1off + z0off + x0off]; - var v011 = array[y1off + z0off + x1off]; - var v100 = array[y0off + z1off + x0off]; - var v101 = array[y0off + z1off + x1off]; - var v110 = array[y1off + z1off + x0off]; - var v111 = array[y1off + z1off + x1off]; - - var result = vec3.create(); - - // Average samples according to distance to point. - vec3.lerp(result, v000, v001, xf); - vec3.lerp(tmp, v010, v011, xf); - vec3.lerp(result, result, tmp, yf); - vec3.lerp(tmp, v100, v101, xf); - vec3.lerp(tmp2, v110, v111, xf); - vec3.lerp(tmp, tmp, tmp2, yf); - vec3.lerp(result, result, tmp, zf); - - return result; -}; - - -var vabs = function(dst, v) { - var x = v[0]; - var y = v[1]; - var z = v[2]; - dst[0] = x >= 0 ? x : -x; - dst[1] = y >= 0 ? y : -y; - dst[2] = z >= 0 ? z : -z; - return dst; -}; - -var findMinSeparation = function(xs) { - var minSeparation = 1/0; - xs.sort(function(a, b) { return a - b; }); - for (var i=1; i= minX && x <= maxX && - y >= minY && y <= maxY && - z >= minZ && z <= maxZ - ); - }; - - var boundsSize = vec3.distance(bounds[0], bounds[1]); - var maxStepSize = 10 * boundsSize / maxLength; - var maxStepSizeSq = maxStepSize * maxStepSize; - - var minDistance = 1; - var maxDivergence = 0; // For component-wise divergence vec3.create(); - var tmp = vec3.create(); - - if (positions.length >= 2) { - minDistance = calculateMinPositionDistance(positions); - } - - for (var i = 0; i < positions.length; i++) { - var p = vec3.create(); - vec3.copy(p, positions[i]); - - var stream = [p]; - var velocities = []; - var v = vectorField.getVelocity(p); - var op = p; - velocities.push(v); - - var divergences = []; - - var dv = vectorField.getDivergence(p, v); - var dvLength = vec3.length(dv); - if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { - maxDivergence = dvLength; - } - // In case we need to do component-wise divergence visualization - // vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); - divergences.push(dvLength); - - streams.push({points: stream, velocities: velocities, divergences: divergences}); - - var j = 0; - - while (j < maxLength * 100 && stream.length < maxLength && inBounds(bounds, p)) { - j++; - var np = vec3.clone(v); - var sqLen = vec3.squaredLength(np); - if (sqLen === 0) { - break; - } else if (sqLen > maxStepSizeSq) { - vec3.scale(np, np, maxStepSize / Math.sqrt(sqLen)); - } - vec3.add(np, np, p); - - v = vectorField.getVelocity(np); - - if (vec3.squaredDistance(op, np) - maxStepSizeSq > -0.0001 * maxStepSizeSq) { - stream.push(np); - op = np; - velocities.push(v); - var dv = vectorField.getDivergence(np, v); - var dvLength = vec3.length(dv); - if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { - maxDivergence = dvLength; - } - // In case we need to do component-wise divergence visualization - //vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); - divergences.push(dvLength); - } - - p = np; - } - } - - // Replace NaNs and Infinities with non-NaN, finite maxDivergence - for (var i=0; i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color — in vertex or in fragment\n vec4 surfaceColor = step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) + step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]) -var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]) -var pickSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]) - -exports.createShader = function (gl) { - var shader = createShader(gl, vertSrc, fragSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'vec3'}, - {name: 'normal', type: 'vec3'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - shader.attributes.normal.location = 2 - return shader -} -exports.createPickShader = function (gl) { - var shader = createShader(gl, vertSrc, pickSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'vec3'}, - {name: 'normal', type: 'vec3'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - shader.attributes.normal.location = 2 - return shader -} -exports.createContourShader = function (gl) { - var shader = createShader(gl, contourVertSrc, fragSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'float'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - return shader -} -exports.createPickContourShader = function (gl) { - var shader = createShader(gl, contourVertSrc, pickSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'float'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - return shader -} + var nparams = { + levels: [[], [], []] + } + for (var id in params) { + nparams[id] = params[id] + } + nparams.colormap = nparams.colormap || 'jet' -},{"gl-shader":148,"glslify":249}],162:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createSurfacePlot - -var bits = _dereq_('bit-twiddle') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var pool = _dereq_('typedarray-pool') -var colormap = _dereq_('colormap') -var ops = _dereq_('ndarray-ops') -var pack = _dereq_('ndarray-pack') -var ndarray = _dereq_('ndarray') -var surfaceNets = _dereq_('surface-nets') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var bsearch = _dereq_('binary-search-bounds') -var gradient = _dereq_('ndarray-gradient') -var shaders = _dereq_('./lib/shaders') - -var createShader = shaders.createShader -var createContourShader = shaders.createContourShader -var createPickShader = shaders.createPickShader -var createPickContourShader = shaders.createPickContourShader - -var SURFACE_VERTEX_SIZE = 4 * (4 + 3 + 3) - -var IDENTITY = [ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 ] - -var QUAD = [ - [0, 0], - [0, 1], - [1, 0], - [1, 1], - [1, 0], - [0, 1] -] - -var PERMUTATIONS = [ - [0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0] -] - -;(function () { - for (var i = 0; i < 3; ++i) { - var p = PERMUTATIONS[i] - var u = (i + 1) % 3 - var v = (i + 2) % 3 - p[u + 0] = 1 - p[v + 3] = 1 - p[i + 6] = 1 - } -})() - -function SurfacePickResult (position, index, uv, level, dataCoordinate) { - this.position = position - this.index = index - this.uv = uv - this.level = level - this.dataCoordinate = dataCoordinate -} - -var N_COLORS = 256 - -function genColormap (name) { - var x = pack([colormap({ - colormap: name, - nshades: N_COLORS, - format: 'rgba' - }).map(function (c) { - return [c[0], c[1], c[2], 255 * c[3]] - })]) - ops.divseq(x, 255.0) - return x -} - -function SurfacePlot ( - gl, - shape, - bounds, - shader, - pickShader, - coordinates, - vao, - colorMap, - contourShader, - contourPickShader, - contourBuffer, - contourVAO, - dynamicBuffer, - dynamicVAO) { - this.gl = gl - this.shape = shape - this.bounds = bounds - this.intensityBounds = []; - - this._shader = shader - this._pickShader = pickShader - this._coordinateBuffer = coordinates - this._vao = vao - this._colorMap = colorMap - - this._contourShader = contourShader - this._contourPickShader = contourPickShader - this._contourBuffer = contourBuffer - this._contourVAO = contourVAO - this._contourOffsets = [[], [], []] - this._contourCounts = [[], [], []] - this._vertexCount = 0 - - this._pickResult = new SurfacePickResult([0, 0, 0], [0, 0], [0, 0], [0, 0, 0], [0, 0, 0]) - - this._dynamicBuffer = dynamicBuffer - this._dynamicVAO = dynamicVAO - this._dynamicOffsets = [0, 0, 0] - this._dynamicCounts = [0, 0, 0] - - this.contourWidth = [ 1, 1, 1 ] - this.contourLevels = [[1], [1], [1]] - this.contourTint = [0, 0, 0] - this.contourColor = [[0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1]] - - this.showContour = true - this.showSurface = true - - this.enableHighlight = [true, true, true] - this.highlightColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]] - this.highlightTint = [ 1, 1, 1 ] - this.highlightLevel = [-1, -1, -1] - - // Dynamic contour options - this.enableDynamic = [ true, true, true ] - this.dynamicLevel = [ NaN, NaN, NaN ] - this.dynamicColor = [ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1] ] - this.dynamicTint = [ 1, 1, 1 ] - this.dynamicWidth = [ 1, 1, 1 ] - - this.axesBounds = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]] - this.surfaceProject = [ false, false, false ] - this.contourProject = [[ false, false, false ], - [ false, false, false ], - [ false, false, false ]] - - this.colorBounds = [ false, false ] - - // Store xyz fields, need this for picking - this._field = [ - ndarray(pool.mallocFloat(1024), [0, 0]), - ndarray(pool.mallocFloat(1024), [0, 0]), - ndarray(pool.mallocFloat(1024), [0, 0]) ] - - this.pickId = 1 - this.clipBounds = [[-Infinity, -Infinity, -Infinity], [Infinity, Infinity, Infinity]] - - this.snapToData = false - - this.opacity = 1.0 - - this.lightPosition = [10, 10000, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - this.vertexColor = 0; - - this.dirty = true -} - -var proto = SurfacePlot.prototype - -proto.isTransparent = function () { - return this.opacity < 1 -} - -proto.isOpaque = function () { - if (this.opacity >= 1) { - return true - } - for (var i = 0; i < 3; ++i) { - if (this._contourCounts[i].length > 0 || this._dynamicCounts[i] > 0) { - return true - } - } - return false -} - -proto.pickSlots = 1 - -proto.setPickBase = function (id) { - this.pickId = id -} - -var ZERO_VEC = [0, 0, 0] - -var PROJECT_DATA = { - showSurface: false, - showContour: false, - projections: [IDENTITY.slice(), IDENTITY.slice(), IDENTITY.slice()], - clipBounds: [ - [[0, 0, 0], [0, 0, 0]], - [[0, 0, 0], [0, 0, 0]], - [[0, 0, 0], [0, 0, 0]]] -} - -function computeProjectionData (camera, obj) { - var i, j, k - - // Compute cube properties - var cubeAxis = (obj.axes && obj.axes.lastCubeProps.axis) || ZERO_VEC - - var showSurface = obj.showSurface - var showContour = obj.showContour - - for (i = 0; i < 3; ++i) { - showSurface = showSurface || obj.surfaceProject[i] - for (j = 0; j < 3; ++j) { - showContour = showContour || obj.contourProject[i][j] - } - } - - for (i = 0; i < 3; ++i) { - // Construct projection onto axis - var axisSquish = PROJECT_DATA.projections[i] - for (j = 0; j < 16; ++j) { - axisSquish[j] = 0 - } - for (j = 0; j < 4; ++j) { - axisSquish[5 * j] = 1 - } - axisSquish[5 * i] = 0 - axisSquish[12 + i] = obj.axesBounds[+(cubeAxis[i] > 0)][i] - multiply(axisSquish, camera.model, axisSquish) - - var nclipBounds = PROJECT_DATA.clipBounds[i] - for (k = 0; k < 2; ++k) { - for (j = 0; j < 3; ++j) { - nclipBounds[k][j] = camera.clipBounds[k][j] - } - } - nclipBounds[0][i] = -1e8 - nclipBounds[1][i] = 1e8 - } - - PROJECT_DATA.showSurface = showSurface - PROJECT_DATA.showContour = showContour - - return PROJECT_DATA -} - -var UNIFORMS = { - model: IDENTITY, - view: IDENTITY, - projection: IDENTITY, - inverseModel: IDENTITY.slice(), - lowerBound: [0, 0, 0], - upperBound: [0, 0, 0], - colorMap: 0, - clipBounds: [[0, 0, 0], [0, 0, 0]], - height: 0.0, - contourTint: 0, - contourColor: [0, 0, 0, 1], - permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], - zOffset: -1e-4, - kambient: 1, - kdiffuse: 1, - kspecular: 1, - lightPosition: [1000, 1000, 1000], - eyePosition: [0, 0, 0], - roughness: 1, - fresnel: 1, - opacity: 1, - vertexColor: 0 -} - -var MATRIX_INVERSE = IDENTITY.slice() -var DEFAULT_PERM = [1, 0, 0, 0, 1, 0, 0, 0, 1] - -function drawCore (params, transparent) { - params = params || {} - var gl = this.gl - - gl.disable(gl.CULL_FACE) - - this._colorMap.bind(0) - - var uniforms = UNIFORMS - uniforms.model = params.model || IDENTITY - uniforms.view = params.view || IDENTITY - uniforms.projection = params.projection || IDENTITY - uniforms.lowerBound = [this.bounds[0][0], this.bounds[0][1], this.colorBounds[0] || this.bounds[0][2]] - uniforms.upperBound = [this.bounds[1][0], this.bounds[1][1], this.colorBounds[1] || this.bounds[1][2]] - uniforms.contourColor = this.contourColor[0] - - uniforms.inverseModel = invert(uniforms.inverseModel, uniforms.model) - - for (var i = 0; i < 2; ++i) { - var clipClamped = uniforms.clipBounds[i] - for (var j = 0; j < 3; ++j) { - clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) - } - } - - uniforms.kambient = this.ambientLight - uniforms.kdiffuse = this.diffuseLight - uniforms.kspecular = this.specularLight - - uniforms.roughness = this.roughness - uniforms.fresnel = this.fresnel - uniforms.opacity = this.opacity - - uniforms.height = 0.0 - uniforms.permutation = DEFAULT_PERM - - uniforms.vertexColor = this.vertexColor - - // Compute camera matrix inverse - var invCameraMatrix = MATRIX_INVERSE - multiply(invCameraMatrix, uniforms.view, uniforms.model) - multiply(invCameraMatrix, uniforms.projection, invCameraMatrix) - invert(invCameraMatrix, invCameraMatrix) - - for (i = 0; i < 3; ++i) { - uniforms.eyePosition[i] = invCameraMatrix[12 + i] / invCameraMatrix[15] - } - - var w = invCameraMatrix[15] - for (i = 0; i < 3; ++i) { - w += this.lightPosition[i] * invCameraMatrix[4 * i + 3] - } - for (i = 0; i < 3; ++i) { - var s = invCameraMatrix[12 + i] - for (j = 0; j < 3; ++j) { - s += invCameraMatrix[4 * j + i] * this.lightPosition[j] - } - uniforms.lightPosition[i] = s / w - } - - var projectData = computeProjectionData(uniforms, this) - - if (projectData.showSurface && (transparent === (this.opacity < 1))) { - // Set up uniforms - this._shader.bind() - this._shader.uniforms = uniforms - - // Draw it - this._vao.bind() - - if (this.showSurface && this._vertexCount) { - this._vao.draw(gl.TRIANGLES, this._vertexCount) - } - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - if (!this.surfaceProject[i] || !this.vertexCount) { - continue - } - this._shader.uniforms.model = projectData.projections[i] - this._shader.uniforms.clipBounds = projectData.clipBounds[i] - this._vao.draw(gl.TRIANGLES, this._vertexCount) - } - - this._vao.unbind() - } - - if (projectData.showContour && !transparent) { - var shader = this._contourShader - - // Don't apply lighting to contours - uniforms.kambient = 1.0 - uniforms.kdiffuse = 0.0 - uniforms.kspecular = 0.0 - uniforms.opacity = 1.0 - - shader.bind() - shader.uniforms = uniforms - - // Draw contour lines - var vao = this._contourVAO - vao.bind() - - // Draw contour levels - for (i = 0; i < 3; ++i) { - shader.uniforms.permutation = PERMUTATIONS[i] - gl.lineWidth(this.contourWidth[i]) - - for (j = 0; j < this.contourLevels[i].length; ++j) { - if (j === this.highlightLevel[i]) { - shader.uniforms.contourColor = this.highlightColor[i] - shader.uniforms.contourTint = this.highlightTint[i] - } else if (j === 0 || (j - 1) === this.highlightLevel[i]) { - shader.uniforms.contourColor = this.contourColor[i] - shader.uniforms.contourTint = this.contourTint[i] - } - if (!this._contourCounts[i][j]) { - continue - } - shader.uniforms.height = this.contourLevels[i][j] - vao.draw(gl.LINES, this._contourCounts[i][j], this._contourOffsets[i][j]) - } - } - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - shader.uniforms.model = projectData.projections[i] - shader.uniforms.clipBounds = projectData.clipBounds[i] - for (j = 0; j < 3; ++j) { - if (!this.contourProject[i][j]) { - continue - } - shader.uniforms.permutation = PERMUTATIONS[j] - gl.lineWidth(this.contourWidth[j]) - for (var k = 0; k < this.contourLevels[j].length; ++k) { - if (k === this.highlightLevel[j]) { - shader.uniforms.contourColor = this.highlightColor[j] - shader.uniforms.contourTint = this.highlightTint[j] - } else if (k === 0 || (k - 1) === this.highlightLevel[j]) { - shader.uniforms.contourColor = this.contourColor[j] - shader.uniforms.contourTint = this.contourTint[j] - } - shader.uniforms.height = this.contourLevels[j][k] - vao.draw(gl.LINES, this._contourCounts[j][k], this._contourOffsets[j][k]) - } - } - } - vao.unbind() - - // Draw dynamic contours - vao = this._dynamicVAO - vao.bind() - - // Draw contour levels - for (i = 0; i < 3; ++i) { - if (this._dynamicCounts[i] === 0) { - continue - } - - shader.uniforms.model = uniforms.model - shader.uniforms.clipBounds = uniforms.clipBounds - shader.uniforms.permutation = PERMUTATIONS[i] - gl.lineWidth(this.dynamicWidth[i]) - - shader.uniforms.contourColor = this.dynamicColor[i] - shader.uniforms.contourTint = this.dynamicTint[i] - shader.uniforms.height = this.dynamicLevel[i] - vao.draw(gl.LINES, this._dynamicCounts[i], this._dynamicOffsets[i]) - - for (j = 0; j < 3; ++j) { - if (!this.contourProject[j][i]) { - continue - } - - shader.uniforms.model = projectData.projections[j] - shader.uniforms.clipBounds = projectData.clipBounds[j] - vao.draw(gl.LINES, this._dynamicCounts[i], this._dynamicOffsets[i]) - } - } - - vao.unbind() - } -} - -proto.draw = function (params) { - return drawCore.call(this, params, false) -} - -proto.drawTransparent = function (params) { - return drawCore.call(this, params, true) -} - -var PICK_UNIFORMS = { - model: IDENTITY, - view: IDENTITY, - projection: IDENTITY, - inverseModel: IDENTITY, - clipBounds: [[0, 0, 0], [0, 0, 0]], - height: 0.0, - shape: [0, 0], - pickId: 0, - lowerBound: [0, 0, 0], - upperBound: [0, 0, 0], - zOffset: 0.0, - permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], - lightPosition: [0, 0, 0], - eyePosition: [0, 0, 0] -} - -proto.drawPick = function (params) { - params = params || {} - var gl = this.gl - gl.disable(gl.CULL_FACE) - - var uniforms = PICK_UNIFORMS - uniforms.model = params.model || IDENTITY - uniforms.view = params.view || IDENTITY - uniforms.projection = params.projection || IDENTITY - uniforms.shape = this._field[2].shape - uniforms.pickId = this.pickId / 255.0 - uniforms.lowerBound = this.bounds[0] - uniforms.upperBound = this.bounds[1] - uniforms.permutation = DEFAULT_PERM - - for (var i = 0; i < 2; ++i) { - var clipClamped = uniforms.clipBounds[i] - for (var j = 0; j < 3; ++j) { - clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) - } - } - - var projectData = computeProjectionData(uniforms, this) - - if (projectData.showSurface) { - // Set up uniforms - this._pickShader.bind() - this._pickShader.uniforms = uniforms - - // Draw it - this._vao.bind() - this._vao.draw(gl.TRIANGLES, this._vertexCount) - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - if (!this.surfaceProject[i]) { - continue - } - this._pickShader.uniforms.model = projectData.projections[i] - this._pickShader.uniforms.clipBounds = projectData.clipBounds[i] - this._vao.draw(gl.TRIANGLES, this._vertexCount) - } - - this._vao.unbind() - } - - if (projectData.showContour) { - var shader = this._contourPickShader - - shader.bind() - shader.uniforms = uniforms - - var vao = this._contourVAO - vao.bind() - - for (j = 0; j < 3; ++j) { - gl.lineWidth(this.contourWidth[j]) - shader.uniforms.permutation = PERMUTATIONS[j] - for (i = 0; i < this.contourLevels[j].length; ++i) { - if (this._contourCounts[j][i]) { - shader.uniforms.height = this.contourLevels[j][i] - vao.draw(gl.LINES, this._contourCounts[j][i], this._contourOffsets[j][i]) - } - } - } - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - shader.uniforms.model = projectData.projections[i] - shader.uniforms.clipBounds = projectData.clipBounds[i] - - for (j = 0; j < 3; ++j) { - if (!this.contourProject[i][j]) { - continue - } - - shader.uniforms.permutation = PERMUTATIONS[j] - gl.lineWidth(this.contourWidth[j]) - for (var k = 0; k < this.contourLevels[j].length; ++k) { - if (this._contourCounts[j][k]) { - shader.uniforms.height = this.contourLevels[j][k] - vao.draw(gl.LINES, this._contourCounts[j][k], this._contourOffsets[j][k]) - } - } - } - } - - vao.unbind() - } -} - -proto.pick = function (selection) { - if (!selection) { - return null - } - - if (selection.id !== this.pickId) { - return null - } - - var shape = this._field[2].shape - - var result = this._pickResult - - // Compute uv coordinate - var x = shape[0] * (selection.value[0] + (selection.value[2] >> 4) / 16.0) / 255.0 - var ix = Math.floor(x) - var fx = x - ix - - var y = shape[1] * (selection.value[1] + (selection.value[2] & 15) / 16.0) / 255.0 - var iy = Math.floor(y) - var fy = y - iy - - ix += 1 - iy += 1 - - // Compute xyz coordinate - var pos = result.position - pos[0] = pos[1] = pos[2] = 0 - for (var dx = 0; dx < 2; ++dx) { - var s = dx ? fx : 1.0 - fx - for (var dy = 0; dy < 2; ++dy) { - var t = dy ? fy : 1.0 - fy - - var r = ix + dx - var c = iy + dy - var w = s * t - - for (var i = 0; i < 3; ++i) { - pos[i] += this._field[i].get(r, c) * w - } - } - } - - // Find closest level - var levelIndex = this._pickResult.level - for (var j = 0; j < 3; ++j) { - levelIndex[j] = bsearch.le(this.contourLevels[j], pos[j]) - if (levelIndex[j] < 0) { - if (this.contourLevels[j].length > 0) { - levelIndex[j] = 0 - } - } else if (levelIndex[j] < this.contourLevels[j].length - 1) { - var a = this.contourLevels[j][levelIndex[j]] - var b = this.contourLevels[j][levelIndex[j] + 1] - if (Math.abs(a - pos[j]) > Math.abs(b - pos[j])) { - levelIndex[j] += 1 - } - } - } - - result.index[0] = fx < 0.5 ? ix : (ix + 1) - result.index[1] = fy < 0.5 ? iy : (iy + 1) - - result.uv[0] = x / shape[0] - result.uv[1] = y / shape[1] - - for (i = 0; i < 3; ++i) { - result.dataCoordinate[i] = this._field[i].get(result.index[0], result.index[1]) - } - - return result -} - -function padField (nfield, field) { - var shape = field.shape.slice() - var nshape = nfield.shape.slice() - - // Center - ops.assign(nfield.lo(1, 1).hi(shape[0], shape[1]), field) - - // Edges - ops.assign(nfield.lo(1).hi(shape[0], 1), - field.hi(shape[0], 1)) - ops.assign(nfield.lo(1, nshape[1] - 1).hi(shape[0], 1), - field.lo(0, shape[1] - 1).hi(shape[0], 1)) - ops.assign(nfield.lo(0, 1).hi(1, shape[1]), - field.hi(1)) - ops.assign(nfield.lo(nshape[0] - 1, 1).hi(1, shape[1]), - field.lo(shape[0] - 1)) - // Corners - nfield.set(0, 0, field.get(0, 0)) - nfield.set(0, nshape[1] - 1, field.get(0, shape[1] - 1)) - nfield.set(nshape[0] - 1, 0, field.get(shape[0] - 1, 0)) - nfield.set(nshape[0] - 1, nshape[1] - 1, field.get(shape[0] - 1, shape[1] - 1)) -} - -function handleArray (param, ctor) { - if (Array.isArray(param)) { - return [ ctor(param[0]), ctor(param[1]), ctor(param[2]) ] - } - return [ ctor(param), ctor(param), ctor(param) ] -} - -function toColor (x) { - if (Array.isArray(x)) { - if (x.length === 3) { - return [x[0], x[1], x[2], 1] - } - return [x[0], x[1], x[2], x[3]] - } - return [0, 0, 0, 1] -} - -function handleColor (param) { - if (Array.isArray(param)) { - if (Array.isArray(param)) { - return [ - toColor(param[0]), - toColor(param[1]), - toColor(param[2]) ] - } else { - var c = toColor(param) - return [ - c.slice(), - c.slice(), - c.slice() ] - } - } -} - -proto.update = function (params) { - params = params || {} - - this.dirty = true - - if ('contourWidth' in params) { - this.contourWidth = handleArray(params.contourWidth, Number) - } - if ('showContour' in params) { - this.showContour = handleArray(params.showContour, Boolean) - } - if ('showSurface' in params) { - this.showSurface = !!params.showSurface - } - if ('contourTint' in params) { - this.contourTint = handleArray(params.contourTint, Boolean) - } - if ('contourColor' in params) { - this.contourColor = handleColor(params.contourColor) - } - if ('contourProject' in params) { - this.contourProject = handleArray(params.contourProject, function (x) { - return handleArray(x, Boolean) - }) - } - if ('surfaceProject' in params) { - this.surfaceProject = params.surfaceProject - } - if ('dynamicColor' in params) { - this.dynamicColor = handleColor(params.dynamicColor) - } - if ('dynamicTint' in params) { - this.dynamicTint = handleArray(params.dynamicTint, Number) - } - if ('dynamicWidth' in params) { - this.dynamicWidth = handleArray(params.dynamicWidth, Number) - } - if ('opacity' in params) { - this.opacity = params.opacity - } - if ('colorBounds' in params) { - this.colorBounds = params.colorBounds - } - if ('vertexColor' in params) { - this.vertexColor = params.vertexColor ? 1 : 0; - } - - var field = params.field || (params.coords && params.coords[2]) || null - var levelsChanged = false - - if (!field) { - if (this._field[2].shape[0] || this._field[2].shape[2]) { - field = this._field[2].lo(1, 1).hi(this._field[2].shape[0] - 2, this._field[2].shape[1] - 2) - } else { - field = this._field[2].hi(0, 0) - } - } - - // Update field - if ('field' in params || 'coords' in params) { - var fsize = (field.shape[0] + 2) * (field.shape[1] + 2) - - // Resize if necessary - if (fsize > this._field[2].data.length) { - pool.freeFloat(this._field[2].data) - this._field[2].data = pool.mallocFloat(bits.nextPow2(fsize)) - } - - // Pad field - this._field[2] = ndarray(this._field[2].data, [field.shape[0] + 2, field.shape[1] + 2]) - padField(this._field[2], field) - - // Save shape of field - this.shape = field.shape.slice() - var shape = this.shape - - // Resize coordinate fields if necessary - for (var i = 0; i < 2; ++i) { - if (this._field[2].size > this._field[i].data.length) { - pool.freeFloat(this._field[i].data) - this._field[i].data = pool.mallocFloat(this._field[2].size) - } - this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2]) - } - - // Generate x/y coordinates - if (params.coords) { - var coords = params.coords - if (!Array.isArray(coords) || coords.length !== 3) { - throw new Error('gl-surface: invalid coordinates for x/y') - } - for (i = 0; i < 2; ++i) { - var coord = coords[i] - for (j = 0; j < 2; ++j) { - if (coord.shape[j] !== shape[j]) { - throw new Error('gl-surface: coords have incorrect shape') - } - } - padField(this._field[i], coord) - } - } else if (params.ticks) { - var ticks = params.ticks - if (!Array.isArray(ticks) || ticks.length !== 2) { - throw new Error('gl-surface: invalid ticks') - } - for (i = 0; i < 2; ++i) { - var tick = ticks[i] - if (Array.isArray(tick) || tick.length) { - tick = ndarray(tick) - } - if (tick.shape[0] !== shape[i]) { - throw new Error('gl-surface: invalid tick length') - } - // Make a copy view of the tick array - var tick2 = ndarray(tick.data, shape) - tick2.stride[i] = tick.stride[0] - tick2.stride[i ^ 1] = 0 - - // Fill in field array - padField(this._field[i], tick2) - } - } else { - for (i = 0; i < 2; ++i) { - var offset = [0, 0] - offset[i] = 1 - this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2], offset, 0) - } - this._field[0].set(0, 0, 0) - for (var j = 0; j < shape[0]; ++j) { - this._field[0].set(j + 1, 0, j) - } - this._field[0].set(shape[0] + 1, 0, shape[0] - 1) - this._field[1].set(0, 0, 0) - for (j = 0; j < shape[1]; ++j) { - this._field[1].set(0, j + 1, j) - } - this._field[1].set(0, shape[1] + 1, shape[1] - 1) - } - - // Save shape - var fields = this._field - - // Compute surface normals - var dfields = ndarray(pool.mallocFloat(fields[2].size * 3 * 2), [3, shape[0] + 2, shape[1] + 2, 2]) - for (i = 0; i < 3; ++i) { - gradient(dfields.pick(i), fields[i], 'mirror') - } - var normals = ndarray(pool.mallocFloat(fields[2].size * 3), [shape[0] + 2, shape[1] + 2, 3]) - for (i = 0; i < shape[0] + 2; ++i) { - for (j = 0; j < shape[1] + 2; ++j) { - var dxdu = dfields.get(0, i, j, 0) - var dxdv = dfields.get(0, i, j, 1) - var dydu = dfields.get(1, i, j, 0) - var dydv = dfields.get(1, i, j, 1) - var dzdu = dfields.get(2, i, j, 0) - var dzdv = dfields.get(2, i, j, 1) - - var nx = dydu * dzdv - dydv * dzdu - var ny = dzdu * dxdv - dzdv * dxdu - var nz = dxdu * dydv - dxdv * dydu - - var nl = Math.sqrt(nx * nx + ny * ny + nz * nz) - if (nl < 1e-8) { - nl = Math.max(Math.abs(nx), Math.abs(ny), Math.abs(nz)) - if (nl < 1e-8) { - nz = 1.0 - ny = nx = 0.0 - nl = 1.0 - } else { - nl = 1.0 / nl - } - } else { - nl = 1.0 / Math.sqrt(nl) - } - - normals.set(i, j, 0, nx * nl) - normals.set(i, j, 1, ny * nl) - normals.set(i, j, 2, nz * nl) - } - } - pool.free(dfields.data) - - // Initialize surface - var lo = [ Infinity, Infinity, Infinity ] - var hi = [ -Infinity, -Infinity, -Infinity ] - var lo_intensity = Infinity - var hi_intensity = -Infinity - var count = (shape[0] - 1) * (shape[1] - 1) * 6 - var tverts = pool.mallocFloat(bits.nextPow2(10 * count)) - var tptr = 0 - var vertexCount = 0 - for (i = 0; i < shape[0] - 1; ++i) { - j_loop: - for (j = 0; j < shape[1] - 1; ++j) { - // Test for NaNs - for (var dx = 0; dx < 2; ++dx) { - for (var dy = 0; dy < 2; ++dy) { - for (var k = 0; k < 3; ++k) { - var f = this._field[k].get(1 + i + dx, 1 + j + dy) - if (isNaN(f) || !isFinite(f)) { - continue j_loop - } - } - } - } - for (k = 0; k < 6; ++k) { - var r = i + QUAD[k][0] - var c = j + QUAD[k][1] - - var tx = this._field[0].get(r + 1, c + 1) - var ty = this._field[1].get(r + 1, c + 1) - f = this._field[2].get(r + 1, c + 1) - var vf = f - nx = normals.get(r + 1, c + 1, 0) - ny = normals.get(r + 1, c + 1, 1) - nz = normals.get(r + 1, c + 1, 2) - - if (params.intensity) { - vf = params.intensity.get(r, c) - } - - tverts[tptr++] = r - tverts[tptr++] = c - tverts[tptr++] = tx - tverts[tptr++] = ty - tverts[tptr++] = f - tverts[tptr++] = 0 - tverts[tptr++] = vf - tverts[tptr++] = nx - tverts[tptr++] = ny - tverts[tptr++] = nz - - lo[0] = Math.min(lo[0], tx) - lo[1] = Math.min(lo[1], ty) - lo[2] = Math.min(lo[2], f) - lo_intensity = Math.min(lo_intensity, vf) - - hi[0] = Math.max(hi[0], tx) - hi[1] = Math.max(hi[1], ty) - hi[2] = Math.max(hi[2], f) - hi_intensity = Math.max(hi_intensity, vf) - - vertexCount += 1 - } - } - } - - if (params.intensityBounds) { - lo_intensity = +params.intensityBounds[0] - hi_intensity = +params.intensityBounds[1] - } - - // Scale all vertex intensities - for (i = 6; i < tptr; i += 10) { - tverts[i] = (tverts[i] - lo_intensity) / (hi_intensity - lo_intensity) - } - - this._vertexCount = vertexCount - this._coordinateBuffer.update(tverts.subarray(0, tptr)) - pool.freeFloat(tverts) - pool.free(normals.data) - - // Update bounds - this.bounds = [lo, hi] - - // Save intensity - this.intensity = params.intensity || this._field[2] - - if(this.intensityBounds[0] !== lo_intensity || this.intensityBounds[1] !== hi_intensity) { - levelsChanged = true - } - - // Save intensity bound - this.intensityBounds = [lo_intensity, hi_intensity] - } - - // Update level crossings - if ('levels' in params) { - var levels = params.levels - if (!Array.isArray(levels[0])) { - levels = [ [], [], levels ] - } else { - levels = levels.slice() - } - for (i = 0; i < 3; ++i) { - levels[i] = levels[i].slice() - levels.sort(function (a, b) { - return a - b - }) - } - change_test: - for (i = 0; i < 3; ++i) { - if (levels[i].length !== this.contourLevels[i].length) { - levelsChanged = true - break - } - for (j = 0; j < levels[i].length; ++j) { - if (levels[i][j] !== this.contourLevels[i][j]) { - levelsChanged = true - break change_test - } - } - } - this.contourLevels = levels - } - - if (levelsChanged) { - fields = this._field - shape = this.shape - - // Update contour lines - var contourVerts = [] - - for (var dim = 0; dim < 3; ++dim) { - levels = this.contourLevels[dim] - var levelOffsets = [] - var levelCounts = [] - - var parts = [0, 0, 0] - - for (i = 0; i < levels.length; ++i) { - var graph = surfaceNets(this._field[dim], levels[i]) - levelOffsets.push((contourVerts.length / 5) | 0) - vertexCount = 0 - - edge_loop: - for (j = 0; j < graph.cells.length; ++j) { - var e = graph.cells[j] - for (k = 0; k < 2; ++k) { - var p = graph.positions[e[k]] - - var x = p[0] - var ix = Math.floor(x) | 0 - var fx = x - ix - - var y = p[1] - var iy = Math.floor(y) | 0 - var fy = y - iy - - var hole = false - dd_loop: - for (var dd = 0; dd < 3; ++dd) { - parts[dd] = 0.0 - var iu = (dim + dd + 1) % 3 - for (dx = 0; dx < 2; ++dx) { - var s = dx ? fx : 1.0 - fx - r = Math.min(Math.max(ix + dx, 0), shape[0]) | 0 - for (dy = 0; dy < 2; ++dy) { - var t = dy ? fy : 1.0 - fy - c = Math.min(Math.max(iy + dy, 0), shape[1]) | 0 - - if (dd < 2) { - f = this._field[iu].get(r, c) - } else { - f = (this.intensity.get(r, c) - this.intensityBounds[0]) / (this.intensityBounds[1] - this.intensityBounds[0]) - } - if (!isFinite(f) || isNaN(f)) { - hole = true - break dd_loop - } - - var w = s * t - parts[dd] += w * f - } - } - } - - if (!hole) { - contourVerts.push(parts[0], parts[1], p[0], p[1], parts[2]) - vertexCount += 1 - } else { - if (k > 0) { - // If we already added first edge, pop off verts - for (var l = 0; l < 5; ++l) { - contourVerts.pop() - } - vertexCount -= 1 - } - continue edge_loop - } - } - } - levelCounts.push(vertexCount) - } - - // Store results - this._contourOffsets[dim] = levelOffsets - this._contourCounts[dim] = levelCounts - } - - var floatBuffer = pool.mallocFloat(contourVerts.length) - for (i = 0; i < contourVerts.length; ++i) { - floatBuffer[i] = contourVerts[i] - } - this._contourBuffer.update(floatBuffer) - pool.freeFloat(floatBuffer) - } - - if (params.colormap) { - this._colorMap.setPixels(genColormap(params.colormap)) - } -} - -proto.dispose = function () { - this._shader.dispose() - this._vao.dispose() - this._coordinateBuffer.dispose() - this._colorMap.dispose() - this._contourBuffer.dispose() - this._contourVAO.dispose() - this._contourShader.dispose() - this._contourPickShader.dispose() - this._dynamicBuffer.dispose() - this._dynamicVAO.dispose() - for (var i = 0; i < 3; ++i) { - pool.freeFloat(this._field[i].data) - } -} - -proto.highlight = function (selection) { - if (!selection) { - this._dynamicCounts = [0, 0, 0] - this.dyanamicLevel = [NaN, NaN, NaN] - this.highlightLevel = [-1, -1, -1] - return - } - - for (var i = 0; i < 3; ++i) { - if (this.enableHighlight[i]) { - this.highlightLevel[i] = selection.level[i] - } else { - this.highlightLevel[i] = -1 - } - } - - var levels - if (this.snapToData) { - levels = selection.dataCoordinate - } else { - levels = selection.position - } - if ((!this.enableDynamic[0] || levels[0] === this.dynamicLevel[0]) && - (!this.enableDynamic[1] || levels[1] === this.dynamicLevel[1]) && - (!this.enableDynamic[2] || levels[2] === this.dynamicLevel[2])) { - return - } - - var vertexCount = 0 - var shape = this.shape - var scratchBuffer = pool.mallocFloat(12 * shape[0] * shape[1]) - - for (var d = 0; d < 3; ++d) { - if (!this.enableDynamic[d]) { - this.dynamicLevel[d] = NaN - this._dynamicCounts[d] = 0 - continue - } - - this.dynamicLevel[d] = levels[d] - - var u = (d + 1) % 3 - var v = (d + 2) % 3 - - var f = this._field[d] - var g = this._field[u] - var h = this._field[v] - var intensity = this.intensity - - var graph = surfaceNets(f, levels[d]) - var edges = graph.cells - var positions = graph.positions - - this._dynamicOffsets[d] = vertexCount - - for (i = 0; i < edges.length; ++i) { - var e = edges[i] - for (var j = 0; j < 2; ++j) { - var p = positions[e[j]] - - var x = +p[0] - var ix = x | 0 - var jx = Math.min(ix + 1, shape[0]) | 0 - var fx = x - ix - var hx = 1.0 - fx - - var y = +p[1] - var iy = y | 0 - var jy = Math.min(iy + 1, shape[1]) | 0 - var fy = y - iy - var hy = 1.0 - fy - - var w00 = hx * hy - var w01 = hx * fy - var w10 = fx * hy - var w11 = fx * fy - - var cu = w00 * g.get(ix, iy) + - w01 * g.get(ix, jy) + - w10 * g.get(jx, iy) + - w11 * g.get(jx, jy) - - var cv = w00 * h.get(ix, iy) + - w01 * h.get(ix, jy) + - w10 * h.get(jx, iy) + - w11 * h.get(jx, jy) - - if (isNaN(cu) || isNaN(cv)) { - if (j) { - vertexCount -= 1 - } - break - } - - scratchBuffer[2 * vertexCount + 0] = cu - scratchBuffer[2 * vertexCount + 1] = cv - - vertexCount += 1 - } - } - - this._dynamicCounts[d] = vertexCount - this._dynamicOffsets[d] - } - - this._dynamicBuffer.update(scratchBuffer.subarray(0, 2 * vertexCount)) - pool.freeFloat(scratchBuffer) -} - -function createSurfacePlot (params) { - var gl = params.gl - var shader = createShader(gl) - var pickShader = createPickShader(gl) - var contourShader = createContourShader(gl) - var contourPickShader = createPickContourShader(gl) - - var coordinateBuffer = createBuffer(gl) - var vao = createVAO(gl, [ - { buffer: coordinateBuffer, - size: 4, - stride: SURFACE_VERTEX_SIZE, - offset: 0 - }, - { buffer: coordinateBuffer, - size: 3, - stride: SURFACE_VERTEX_SIZE, - offset: 16 - }, - { - buffer: coordinateBuffer, - size: 3, - stride: SURFACE_VERTEX_SIZE, - offset: 28 - } - ]) - - var contourBuffer = createBuffer(gl) - var contourVAO = createVAO(gl, [ - { - buffer: contourBuffer, - size: 4, - stride: 20, - offset: 0 - }, - { - buffer: contourBuffer, - size: 1, - stride: 20, - offset: 16 - } - ]) - - var dynamicBuffer = createBuffer(gl) - var dynamicVAO = createVAO(gl, [ - { - buffer: dynamicBuffer, - size: 2, - type: gl.FLOAT - }]) - - var cmap = createTexture(gl, 1, N_COLORS, gl.RGBA, gl.UNSIGNED_BYTE) - cmap.minFilter = gl.LINEAR - cmap.magFilter = gl.LINEAR - - var surface = new SurfacePlot( - gl, - [0, 0], - [[0, 0, 0], [0, 0, 0]], - shader, - pickShader, - coordinateBuffer, - vao, - cmap, - contourShader, - contourPickShader, - contourBuffer, - contourVAO, - dynamicBuffer, - dynamicVAO - ) - - var nparams = { - levels: [[], [], []] - } - for (var id in params) { - nparams[id] = params[id] - } - nparams.colormap = nparams.colormap || 'jet' - - surface.update(nparams) - - return surface -} + surface.update(nparams) + + return surface +} -},{"./lib/shaders":161,"binary-search-bounds":36,"bit-twiddle":37,"colormap":69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-texture2d":163,"gl-vao":167,"ndarray":285,"ndarray-gradient":276,"ndarray-ops":279,"ndarray-pack":280,"surface-nets":341,"typedarray-pool":348}],163:[function(_dereq_,module,exports){ +},{"./lib/shaders":161,"binary-search-bounds":36,"bit-twiddle":37,"colormap":69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-texture2d":163,"gl-vao":167,"ndarray":285,"ndarray-gradient":276,"ndarray-ops":279,"ndarray-pack":280,"surface-nets":340,"typedarray-pool":347}],163:[function(_dereq_,module,exports){ 'use strict' var ndarray = _dereq_('ndarray') @@ -37762,7 +37873,7 @@ function createTexture2D(gl) { throw new Error('gl-texture2d: Invalid arguments for texture2d constructor') } -},{"ndarray":285,"ndarray-ops":279,"typedarray-pool":348}],164:[function(_dereq_,module,exports){ +},{"ndarray":285,"ndarray-ops":279,"typedarray-pool":347}],164:[function(_dereq_,module,exports){ "use strict" function doBind(gl, elements, attributes) { @@ -42249,7 +42360,7 @@ function mouseWheelListen(element, callback, noScroll) { return listener } -},{"to-px":343}],274:[function(_dereq_,module,exports){ +},{"to-px":342}],274:[function(_dereq_,module,exports){ "use strict" var pool = _dereq_("typedarray-pool") @@ -42665,7 +42776,7 @@ function createSurfaceExtractor(args) { order, typesig) } -},{"typedarray-pool":348}],275:[function(_dereq_,module,exports){ +},{"typedarray-pool":347}],275:[function(_dereq_,module,exports){ "use strict" @@ -44334,7 +44445,7 @@ function compileSort(order, dtype) { } module.exports = compileSort -},{"typedarray-pool":348}],283:[function(_dereq_,module,exports){ +},{"typedarray-pool":347}],283:[function(_dereq_,module,exports){ "use strict" var compile = _dereq_("./lib/compile_sort.js") @@ -45414,7 +45525,7 @@ function permutationSign(p) { return sgn } } -},{"typedarray-pool":348}],293:[function(_dereq_,module,exports){ +},{"typedarray-pool":347}],293:[function(_dereq_,module,exports){ "use strict" var pool = _dereq_("typedarray-pool") @@ -45501,7 +45612,7 @@ function unrank(n, r, p) { exports.rank = rank exports.unrank = unrank -},{"invert-permutation":255,"typedarray-pool":348}],294:[function(_dereq_,module,exports){ +},{"invert-permutation":255,"typedarray-pool":347}],294:[function(_dereq_,module,exports){ "use strict" module.exports = planarDual @@ -45893,7 +46004,7 @@ function planarGraphToPolyline(edges, positions) { return result } -},{"./lib/trim-leaves":295,"edges-to-adjacency-list":88,"planar-dual":294,"point-in-big-polygon":297,"robust-sum":326,"two-product":346,"uniq":350}],297:[function(_dereq_,module,exports){ +},{"./lib/trim-leaves":295,"edges-to-adjacency-list":88,"planar-dual":294,"point-in-big-polygon":297,"robust-sum":326,"two-product":345,"uniq":349}],297:[function(_dereq_,module,exports){ module.exports = preprocessPolygon var orient = _dereq_('robust-orientation')[3] @@ -48368,7 +48479,7 @@ return robustDeterminant") } generateDispatch() -},{"robust-compress":316,"robust-scale":323,"robust-sum":326,"two-product":346}],318:[function(_dereq_,module,exports){ +},{"robust-compress":316,"robust-scale":323,"robust-sum":326,"two-product":345}],318:[function(_dereq_,module,exports){ "use strict" var twoProduct = _dereq_("two-product") @@ -48383,7 +48494,7 @@ function robustDotProduct(a, b) { } return r } -},{"robust-sum":326,"two-product":346}],319:[function(_dereq_,module,exports){ +},{"robust-sum":326,"two-product":345}],319:[function(_dereq_,module,exports){ "use strict" var twoProduct = _dereq_("two-product") @@ -48551,7 +48662,7 @@ function generateInSphereTest() { } generateInSphereTest() -},{"robust-scale":323,"robust-subtract":325,"robust-sum":326,"two-product":346}],320:[function(_dereq_,module,exports){ +},{"robust-scale":323,"robust-subtract":325,"robust-sum":326,"two-product":345}],320:[function(_dereq_,module,exports){ "use strict" var determinant = _dereq_("robust-determinant") @@ -48814,7 +48925,7 @@ function generateOrientationProc() { } generateOrientationProc() -},{"robust-scale":323,"robust-subtract":325,"robust-sum":326,"two-product":346}],322:[function(_dereq_,module,exports){ +},{"robust-scale":323,"robust-subtract":325,"robust-sum":326,"two-product":345}],322:[function(_dereq_,module,exports){ "use strict" var robustSum = _dereq_("robust-sum") @@ -48895,7 +49006,7 @@ function scaleLinearExpansion(e, scale) { g.length = count return g } -},{"two-product":346,"two-sum":347}],324:[function(_dereq_,module,exports){ +},{"two-product":345,"two-sum":346}],324:[function(_dereq_,module,exports){ "use strict" module.exports = segmentsIntersect @@ -49440,7 +49551,7 @@ function extractContour(cells, values, level, d) { vertexWeights: uweights } } -},{"./lib/codegen":330,"ndarray":285,"ndarray-sort":283,"typedarray-pool":348}],330:[function(_dereq_,module,exports){ +},{"./lib/codegen":330,"ndarray":285,"ndarray-sort":283,"typedarray-pool":347}],330:[function(_dereq_,module,exports){ 'use strict' module.exports = getPolygonizer @@ -49537,7 +49648,7 @@ function getPolygonizer(d) { } return alg } -},{"marching-simplex-table":263,"typedarray-pool":348}],331:[function(_dereq_,module,exports){ +},{"marching-simplex-table":263,"typedarray-pool":347}],331:[function(_dereq_,module,exports){ "use strict"; "use restrict"; var bits = _dereq_("bit-twiddle") @@ -49881,7 +49992,7 @@ function connectedComponents(cells, vertex_count) { } exports.connectedComponents = connectedComponents -},{"bit-twiddle":37,"union-find":349}],332:[function(_dereq_,module,exports){ +},{"bit-twiddle":37,"union-find":348}],332:[function(_dereq_,module,exports){ arguments[4][37][0].apply(exports,arguments) },{"dup":37}],333:[function(_dereq_,module,exports){ arguments[4][331][0].apply(exports,arguments) @@ -50854,61 +50965,6 @@ function negative(points, plane) { }() },{}],340:[function(_dereq_,module,exports){ -'use strict' - -module.exports = toSuperScript - -var SUPERSCRIPTS = { - ' ': ' ', - '0': '⁰', - '1': '¹', - '2': '²', - '3': '³', - '4': '⁴', - '5': '⁵', - '6': '⁶', - '7': '⁷', - '8': '⁸', - '9': '⁹', - '+': '⁺', - '-': '⁻', - 'a': 'ᵃ', - 'b': 'ᵇ', - 'c': 'ᶜ', - 'd': 'ᵈ', - 'e': 'ᵉ', - 'f': 'ᶠ', - 'g': 'ᵍ', - 'h': 'ʰ', - 'i': 'ⁱ', - 'j': 'ʲ', - 'k': 'ᵏ', - 'l': 'ˡ', - 'm': 'ᵐ', - 'n': 'ⁿ', - 'o': 'ᵒ', - 'p': 'ᵖ', - 'r': 'ʳ', - 's': 'ˢ', - 't': 'ᵗ', - 'u': 'ᵘ', - 'v': 'ᵛ', - 'w': 'ʷ', - 'x': 'ˣ', - 'y': 'ʸ', - 'z': 'ᶻ' -} - -function toSuperScript(x) { - return x.split('').map(function(c) { - if(c in SUPERSCRIPTS) { - return SUPERSCRIPTS[c] - } - return '' - }).join('') -} - -},{}],341:[function(_dereq_,module,exports){ "use strict" module.exports = surfaceNets @@ -51116,7 +51172,7 @@ function surfaceNets(array,level) { } return proc(array,level) } -},{"ndarray-extract-contour":274,"triangulate-hypercube":344,"zero-crossings":359}],342:[function(_dereq_,module,exports){ +},{"ndarray-extract-contour":274,"triangulate-hypercube":343,"zero-crossings":358}],341:[function(_dereq_,module,exports){ // TinyColor v1.4.1 // https://github.com/bgrins/TinyColor // Brian Grinstead, MIT License @@ -52313,7 +52369,7 @@ else { })(Math); -},{}],343:[function(_dereq_,module,exports){ +},{}],342:[function(_dereq_,module,exports){ 'use strict' var parseUnit = _dereq_('parse-unit') @@ -52374,7 +52430,7 @@ function toPX(str, element) { } return 1 } -},{"parse-unit":291}],344:[function(_dereq_,module,exports){ +},{"parse-unit":291}],343:[function(_dereq_,module,exports){ "use strict" module.exports = triangulateCube @@ -52408,7 +52464,7 @@ function triangulateCube(dimension) { } return result } -},{"gamma":94,"permutation-parity":292,"permutation-rank":293}],345:[function(_dereq_,module,exports){ +},{"gamma":94,"permutation-parity":292,"permutation-rank":293}],344:[function(_dereq_,module,exports){ 'use strict' module.exports = createTurntableController @@ -52981,7 +53037,7 @@ function createTurntableController(options) { theta, phi) } -},{"filtered-vector":92,"gl-mat4/invert":125,"gl-mat4/rotate":129,"gl-vec3/cross":174,"gl-vec3/dot":179,"gl-vec3/normalize":196}],346:[function(_dereq_,module,exports){ +},{"filtered-vector":92,"gl-mat4/invert":125,"gl-mat4/rotate":129,"gl-vec3/cross":174,"gl-vec3/dot":179,"gl-vec3/normalize":196}],345:[function(_dereq_,module,exports){ "use strict" module.exports = twoProduct @@ -53015,7 +53071,7 @@ function twoProduct(a, b, result) { return [ y, x ] } -},{}],347:[function(_dereq_,module,exports){ +},{}],346:[function(_dereq_,module,exports){ "use strict" module.exports = fastTwoSum @@ -53033,7 +53089,7 @@ function fastTwoSum(a, b, result) { } return [ar+br, x] } -},{}],348:[function(_dereq_,module,exports){ +},{}],347:[function(_dereq_,module,exports){ (function (global,Buffer){ 'use strict' @@ -53250,7 +53306,7 @@ exports.clearCache = function clearCache() { } } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer) -},{"bit-twiddle":37,"buffer":49,"dup":87}],349:[function(_dereq_,module,exports){ +},{"bit-twiddle":37,"buffer":49,"dup":87}],348:[function(_dereq_,module,exports){ "use strict"; "use restrict"; module.exports = UnionFind; @@ -53313,7 +53369,7 @@ proto.link = function(x, y) { ++ranks[xr]; } } -},{}],350:[function(_dereq_,module,exports){ +},{}],349:[function(_dereq_,module,exports){ "use strict" function unique_pred(list, compare) { @@ -53372,7 +53428,7 @@ function unique(list, compare, sorted) { module.exports = unique -},{}],351:[function(_dereq_,module,exports){ +},{}],350:[function(_dereq_,module,exports){ "use strict" module.exports = createText @@ -53399,7 +53455,7 @@ function createText(str, options) { options) } -},{"./lib/vtext":352}],352:[function(_dereq_,module,exports){ +},{"./lib/vtext":351}],351:[function(_dereq_,module,exports){ "use strict" module.exports = vectorizeText @@ -53412,6 +53468,72 @@ var cleanPSLG = _dereq_('clean-pslg') var cdt2d = _dereq_('cdt2d') var toPolygonCrappy = _dereq_('planar-graph-to-polyline') +var TAG_bold = "b" +var CHR_bold = 'b|' + +var TAG_italic = "i" +var CHR_italic = 'i|' + +var TAG_super = "sup" +var CHR_super0 = '+' +var CHR_super = '+1' + +var TAG_sub = "sub" +var CHR_sub0 = '-' +var CHR_sub = '-1' + +function parseTag(tag, TAG_CHR, str, map) { + + var opnTag = "<" + tag + ">" + var clsTag = "" + + var nOPN = opnTag.length + var nCLS = clsTag.length + + var isRecursive = (TAG_CHR[0] === CHR_super0) || + (TAG_CHR[0] === CHR_sub0); + + var a = 0 + var b = -nCLS + while (a > -1) { + a = str.indexOf(opnTag, a) + if(a === -1) break + + b = str.indexOf(clsTag, a + nOPN) + if(b === -1) break + + if(b <= a) break + + for(var i = a; i < b + nCLS; ++i){ + if((i < a + nOPN) || (i >= b)) { + map[i] = null + str = str.substr(0, i) + " " + str.substr(i + 1) + } else { + if(map[i] !== null) { + var pos = map[i].indexOf(TAG_CHR[0]) + if(pos === -1) { + map[i] += TAG_CHR + } else { // i.e. to handle multiple sub/super-scripts + if(isRecursive) { + // i.e to increase the sub/sup number + map[i] = map[i].substr(0, pos + 1) + (1 + parseInt(map[i][pos + 1])) + map[i].substr(pos + 2) + } + } + } + } + } + + var start = a + nOPN + var remainingStr = str.substr(start, b - start) + + var c = remainingStr.indexOf(opnTag) + if(c !== -1) a = c + else a = b + nCLS + } + + return map +} + function transformPositions(positions, options, size) { var align = options.textAlign || "start" var baseline = options.textBaseline || "alphabetic" @@ -53485,27 +53607,169 @@ function transformPositions(positions, options, size) { }) } -function getPixels(canvas, context, str, size) { - var width = Math.ceil(context.measureText(str).width + 2*size)|0 - if(width > 8192) { - throw new Error("vectorize-text: String too long (sorry, this will get fixed later)") +function getPixels(canvas, context, rawString, fontSize, lineSpacing, styletags) { + + rawString = rawString.replace(/\n/g, '') // don't accept \n in the input + + if(styletags.breaklines === true) { + rawString = rawString.replace(/\/g, '\n') // replace
tags with \n in the string + } else { + rawString = rawString.replace(/\/g, ' ') // don't accept
tags in the input and replace with space in this case + } + + var activeStyle = "" + var map = [] + for(j = 0; j < rawString.length; ++j) { + map[j] = activeStyle + } + + if(styletags.bolds === true) map = parseTag(TAG_bold, CHR_bold, rawString, map) + if(styletags.italics === true) map = parseTag(TAG_italic, CHR_italic, rawString, map) + if(styletags.superscripts === true) map = parseTag(TAG_super, CHR_super, rawString, map) + if(styletags.subscripts === true) map = parseTag(TAG_sub, CHR_sub, rawString, map) + + var allStyles = [] + var plainText = "" + for(j = 0; j < rawString.length; ++j) { + if(map[j] !== null) { + plainText += rawString[j] + allStyles.push(map[j]) + } } - var height = 3 * size - if(canvas.height < height) { - canvas.height = height + + var allTexts = plainText.split('\n') + + var numberOfLines = allTexts.length + var lineHeight = Math.round(lineSpacing * fontSize) + var offsetX = fontSize + var offsetY = fontSize * 2 + var maxWidth = 0 + var minHeight = numberOfLines * lineHeight + offsetY + + if(canvas.height < minHeight) { + canvas.height = minHeight } context.fillStyle = "#000" context.fillRect(0, 0, canvas.width, canvas.height) context.fillStyle = "#fff" - context.fillText(str, size, 2*size) + var i, j, xPos, yPos, zPos + var nDone = 0 - //Cut pixels from image - var pixelData = context.getImageData(0, 0, width, height) - var pixels = ndarray(pixelData.data, [height, width, 4]) + for(i = 0; i < numberOfLines; ++i) { + + var txt = allTexts[i] + '\n' + xPos = 0 + yPos = i * lineHeight + zPos = fontSize + + var buffer = "" + function writeBuffer() { + if(buffer !== "") { + var delta = context.measureText(buffer).width + + context.fillText(buffer, offsetX + xPos, offsetY + yPos) + xPos += delta + } + } + + function changeStyle(oldStyle, newStyle) { + + function getTextFontSize() { + return "" + Math.round(zPos) + "px "; + } + + var ctxFont = "" + context.font; + + if(styletags.subscripts === true) { + var oldIndex_Sub = oldStyle.indexOf(CHR_sub0); + var newIndex_Sub = newStyle.indexOf(CHR_sub0); + + var oldSub = (oldIndex_Sub > -1) ? parseInt(oldStyle[1 + oldIndex_Sub]) : 0; + var newSub = (newIndex_Sub > -1) ? parseInt(newStyle[1 + newIndex_Sub]) : 0; + + if(oldSub !== newSub) { + ctxFont = ctxFont.replace(getTextFontSize(), "?px ") + zPos *= Math.pow(0.75, (newSub - oldSub)) + ctxFont = ctxFont.replace("?px ", getTextFontSize()) + } + yPos += 0.25 * lineHeight * (newSub - oldSub); + } + + if(styletags.superscripts === true) { + var oldIndex_Super = oldStyle.indexOf(CHR_super0); + var newIndex_Super = newStyle.indexOf(CHR_super0); + + var oldSuper = (oldIndex_Super > -1) ? parseInt(oldStyle[1 + oldIndex_Super]) : 0; + var newSuper = (newIndex_Super > -1) ? parseInt(newStyle[1 + newIndex_Super]) : 0; + + if(oldSuper !== newSuper) { + ctxFont = ctxFont.replace(getTextFontSize(), "?px ") + zPos *= Math.pow(0.75, (newSuper - oldSuper)) + ctxFont = ctxFont.replace("?px ", getTextFontSize()) + } + yPos -= 0.25 * lineHeight * (newSuper - oldSuper); + } + + if(styletags.bolds === true) { + var wasBold = (oldStyle.indexOf(CHR_bold) > -1) + var is_Bold = (newStyle.indexOf(CHR_bold) > -1) + + if(!wasBold && is_Bold) { + if(wasItalic) { + ctxFont = ctxFont.replace("italic ", "italic bold ") + } else { + ctxFont = "bold " + ctxFont + } + } + if(wasBold && !is_Bold) { + ctxFont = ctxFont.replace("bold ", '') + } + } + + if(styletags.italics === true) { + var wasItalic = (oldStyle.indexOf(CHR_italic) > -1) + var is_Italic = (newStyle.indexOf(CHR_italic) > -1) + + if(!wasItalic && is_Italic) { + ctxFont = "italic " + ctxFont + } + if(wasItalic && !is_Italic) { + ctxFont = ctxFont.replace("italic ", '') + } + } + + context.font = ctxFont + } + + for(j = 0; j < txt.length; ++j) { + var style = (j + nDone < allStyles.length) ? allStyles[j + nDone] : allStyles[allStyles.length - 1] + if(activeStyle === style) { + buffer += txt[j] + } else { + writeBuffer() + buffer = txt[j] + + if(style !== undefined) { + changeStyle(activeStyle, style) + activeStyle = style + } + } + } + writeBuffer() + + nDone += txt.length + + var width = Math.round(xPos + 2 * offsetX) | 0 + if(maxWidth < width) maxWidth = width + } - return pixels.pick(-1,-1,0).transpose(1,0) + //Cut pixels from image + var xCut = maxWidth + var yCut = offsetY + lineHeight * numberOfLines + var pixels = ndarray(context.getImageData(0, 0, xCut, yCut).data, [yCut, xCut, 4]) + return pixels.pick(-1, -1, 0).transpose(1, 0) } function getContour(pixels, doSimplify) { @@ -53592,20 +53856,65 @@ function processPixels(pixels, options, size) { } function vectorizeText(str, canvas, context, options) { - var size = options.size || 64 - var family = options.font || "normal" - context.font = size + "px " + family + var size = 64 + var lineSpacing = 1.25 + var styletags = { + breaklines: false, + bolds: false, + italics: false, + subscripts: false, + superscripts: false + } + + if(options) { + + if(options.size && + options.size > 0) size = + options.size + + if(options.lineSpacing && + options.lineSpacing > 0) lineSpacing = + options.lineSpacing + + if(options.styletags && + options.styletags.breaklines) styletags.breaklines = + options.styletags.breaklines ? true : false + + if(options.styletags && + options.styletags.bolds) styletags.bolds = + options.styletags.bolds ? true : false + + if(options.styletags && + options.styletags.italics) styletags.italics = + options.styletags.italics ? true : false + + if(options.styletags && + options.styletags.subscripts) styletags.subscripts = + options.styletags.subscripts ? true : false + + if(options.styletags && + options.styletags.superscripts) styletags.superscripts = + options.styletags.superscripts ? true : false + } + + context.font = [ + options.fontStyle, + options.fontVariant, + options.fontWeight, + size + "px", + options.font + ].filter(function(d) {return d}).join(" ") context.textAlign = "start" context.textBaseline = "alphabetic" context.direction = "ltr" - var pixels = getPixels(canvas, context, str, size) + var pixels = getPixels(canvas, context, str, size, lineSpacing, styletags) return processPixels(pixels, options, size) } -},{"cdt2d":50,"clean-pslg":60,"ndarray":285,"planar-graph-to-polyline":296,"simplify-planar-graph":335,"surface-nets":341}],353:[function(_dereq_,module,exports){ +},{"cdt2d":50,"clean-pslg":60,"ndarray":285,"planar-graph-to-polyline":296,"simplify-planar-graph":335,"surface-nets":340}],352:[function(_dereq_,module,exports){ // Copyright (C) 2011 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -54292,7 +54601,7 @@ function vectorizeText(str, canvas, context, options) { } })(); -},{}],354:[function(_dereq_,module,exports){ +},{}],353:[function(_dereq_,module,exports){ var hiddenStore = _dereq_('./hidden-store.js'); module.exports = createStore; @@ -54313,7 +54622,7 @@ function createStore() { }; } -},{"./hidden-store.js":355}],355:[function(_dereq_,module,exports){ +},{"./hidden-store.js":354}],354:[function(_dereq_,module,exports){ module.exports = hiddenStore; function hiddenStore(obj, key) { @@ -54331,7 +54640,7 @@ function hiddenStore(obj, key) { return store; } -},{}],356:[function(_dereq_,module,exports){ +},{}],355:[function(_dereq_,module,exports){ // Original - @Gozola. // https://gist.github.com/Gozala/1269991 // This is a reimplemented version (with a few bug fixes). @@ -54362,14 +54671,14 @@ function weakMap() { } } -},{"./create-store.js":354}],357:[function(_dereq_,module,exports){ +},{"./create-store.js":353}],356:[function(_dereq_,module,exports){ var getContext = _dereq_('get-canvas-context') module.exports = function getWebGLContext (opt) { return getContext('webgl', opt) } -},{"get-canvas-context":95}],358:[function(_dereq_,module,exports){ +},{"get-canvas-context":95}],357:[function(_dereq_,module,exports){ module.exports = _dereq_('cwise-compiler')({ args: ['array', { offset: [1], @@ -54421,7 +54730,7 @@ module.exports = _dereq_('cwise-compiler')({ funcName: 'zeroCrossings' }) -},{"cwise-compiler":78}],359:[function(_dereq_,module,exports){ +},{"cwise-compiler":78}],358:[function(_dereq_,module,exports){ "use strict" module.exports = findZeroCrossings @@ -54434,7 +54743,7 @@ function findZeroCrossings(array, level) { core(array.hi(array.shape[0]-1), cross, level) return cross } -},{"./lib/zc-core":358}],360:[function(_dereq_,module,exports){ +},{"./lib/zc-core":357}],359:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54505,7 +54814,7 @@ module.exports = [ } ]; -},{}],361:[function(_dereq_,module,exports){ +},{}],360:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54860,7 +55169,7 @@ module.exports = templatedArray('annotation', { } }); -},{"../../plot_api/plot_template":534,"../../plots/cartesian/constants":550,"../../plots/font_attributes":571,"./arrow_paths":360}],362:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":530,"../../plots/cartesian/constants":546,"../../plots/font_attributes":567,"./arrow_paths":359}],361:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54949,7 +55258,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":498,"../../plots/cartesian/axes":544,"./draw":367}],363:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plots/cartesian/axes":540,"./draw":366}],362:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55088,7 +55397,7 @@ function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":498,"../../plot_api/plot_template":534,"../../registry":597}],364:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plot_api/plot_template":530,"../../registry":593}],363:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55168,7 +55477,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":498,"../color":376}],365:[function(_dereq_,module,exports){ +},{"../../lib":494,"../color":375}],364:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55231,7 +55540,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":523,"fast-isnumeric":91}],366:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":519,"fast-isnumeric":91}],365:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55337,7 +55646,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":498,"../../plots/array_container_defaults":540,"../../plots/cartesian/axes":544,"./attributes":361,"./common_defaults":364}],367:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plots/array_container_defaults":536,"../../plots/cartesian/axes":540,"./attributes":360,"./common_defaults":363}],366:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55751,14 +56060,14 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { x: borderfull + xShift - 1, y: borderfull + yShift }) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; annText.call(svgTextUtils.positionText, textx, texty) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } annTextClip.select('rect').call(Drawing.setRect, borderfull, borderfull, @@ -55924,7 +56233,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }); }, doneFn: function() { - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -56007,7 +56316,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }, doneFn: function() { setCursor(annTextGroupInner); - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -56031,13 +56340,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { modifyBase(ya._name + '.autorange', true); } - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); }); } else annText.call(textLayout); } -},{"../../lib":498,"../../lib/setcursor":517,"../../lib/svg_text_utils":521,"../../plot_api/plot_template":534,"../../plots/cartesian/axes":544,"../../plots/plots":589,"../../registry":597,"../color":376,"../dragelement":398,"../drawing":401,"../fx":418,"./draw_arrow_head":368,"d3":82}],368:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../lib/setcursor":513,"../../lib/svg_text_utils":517,"../../plot_api/plot_template":530,"../../plots/cartesian/axes":540,"../../plots/plots":585,"../../registry":593,"../color":375,"../dragelement":393,"../drawing":396,"../fx":414,"./draw_arrow_head":367,"d3":82}],367:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56191,7 +56500,7 @@ module.exports = function drawArrowHead(el3, ends, options) { if(doEnd) drawhead(headStyle, end, endRot, scale); }; -},{"../color":376,"./arrow_paths":360,"d3":82}],369:[function(_dereq_,module,exports){ +},{"../color":375,"./arrow_paths":359,"d3":82}],368:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56225,7 +56534,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":555,"./attributes":361,"./calc_autorange":362,"./click":363,"./convert_coords":365,"./defaults":366,"./draw":367}],370:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":551,"./attributes":360,"./calc_autorange":361,"./click":362,"./convert_coords":364,"./defaults":365,"./draw":366}],369:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56313,7 +56622,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":527,"../../plot_api/plot_template":534,"../annotations/attributes":361}],371:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":523,"../../plot_api/plot_template":530,"../annotations/attributes":360}],370:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56378,7 +56687,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":498,"../../plots/cartesian/axes":544}],372:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plots/cartesian/axes":540}],371:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56454,7 +56763,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":498,"../../plots/array_container_defaults":540,"../../plots/cartesian/axes":544,"../annotations/common_defaults":364,"./attributes":370}],373:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plots/array_container_defaults":536,"../../plots/cartesian/axes":540,"../annotations/common_defaults":363,"./attributes":369}],372:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56506,7 +56815,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":584,"../annotations/draw":367}],374:[function(_dereq_,module,exports){ +},{"../../plots/gl3d/project":580,"../annotations/draw":366}],373:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56554,7 +56863,7 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":498,"../../registry":597,"./attributes":370,"./convert":371,"./defaults":372,"./draw":373}],375:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../registry":593,"./attributes":369,"./convert":370,"./defaults":371,"./draw":372}],374:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56594,7 +56903,7 @@ exports.borderLine = '#BEC8D9'; // gives back exactly lightLine if the other colors are defaults. exports.lightFraction = 100 * (0xe - 0x4) / (0xf - 0x4); -},{}],376:[function(_dereq_,module,exports){ +},{}],375:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56765,7 +57074,7 @@ function cleanOne(val) { return 'rgb(' + rgbStr + ')'; } -},{"./attributes":375,"fast-isnumeric":91,"tinycolor2":342}],377:[function(_dereq_,module,exports){ +},{"./attributes":374,"fast-isnumeric":91,"tinycolor2":341}],376:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56908,23 +57217,43 @@ module.exports = overrideAll({ exponentformat: axesAttrs.exponentformat, showexponent: axesAttrs.showexponent, title: { - valType: 'string', - - + text: { + valType: 'string', + + + }, + font: fontAttrs({ + + }), + side: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } }, - titlefont: fontAttrs({ - - }), - titleside: { - valType: 'enumerated', - values: ['right', 'top', 'bottom'], - - dflt: 'top', - + + _deprecated: { + title: { + valType: 'string', + + + }, + titlefont: fontAttrs({ + + }), + titleside: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":490,"../../plot_api/edit_types":527,"../../plots/cartesian/layout_attributes":557,"../../plots/font_attributes":571}],378:[function(_dereq_,module,exports){ +},{"../../lib/extend":487,"../../plot_api/edit_types":523,"../../plots/cartesian/layout_attributes":553,"../../plots/font_attributes":567}],377:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56933,10 +57262,10 @@ module.exports = overrideAll({ * LICENSE file in the root directory of this source tree. */ - 'use strict'; var drawColorbar = _dereq_('./draw'); +var flipScale = _dereq_('../colorscale/helpers').flipScale; /** * connectColorbar: create a colorbar from a trace, using its module to @@ -56976,12 +57305,16 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) { var cb = cd[0].t.cb = drawColorbar(gd, cbId); - cb.fillgradient(container.colorscale) + var scl = container.reversescale ? + flipScale(container.colorscale) : + container.colorscale; + + cb.fillgradient(scl) .zrange([container[moduleOpts.min], container[moduleOpts.max]]) .options(container.colorbar)(); }; -},{"./draw":381}],379:[function(_dereq_,module,exports){ +},{"../colorscale/helpers":386,"./draw":380}],378:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57009,7 +57342,7 @@ module.exports = { } }; -},{}],380:[function(_dereq_,module,exports){ +},{}],379:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57071,12 +57404,12 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); - coerce('title', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'titlefont', layout.font); - coerce('titleside'); + coerce('title.text', layout._dfltTitle.colorbar); + Lib.coerceFont(coerce, 'title.font', layout.font); + coerce('title.side'); }; -},{"../../lib":498,"../../plot_api/plot_template":534,"../../plots/cartesian/tick_label_defaults":564,"../../plots/cartesian/tick_mark_defaults":565,"../../plots/cartesian/tick_value_defaults":566,"./attributes":377}],381:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plot_api/plot_template":530,"../../plots/cartesian/tick_label_defaults":560,"../../plots/cartesian/tick_mark_defaults":561,"../../plots/cartesian/tick_value_defaults":562,"./attributes":376}],380:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57263,9 +57596,9 @@ module.exports = function draw(gd, id) { showticksuffix: opts.showticksuffix, ticksuffix: opts.ticksuffix, title: opts.title, - titlefont: opts.titlefont, showline: true, anchor: 'free', + side: 'right', position: 1 }, cbAxisOut = { @@ -57276,6 +57609,7 @@ module.exports = function draw(gd, id) { letter: 'y', font: fullLayout.font, noHover: true, + noTickson: true, calendar: fullLayout.calendar // not really necessary (yet?) }; @@ -57296,11 +57630,11 @@ module.exports = function draw(gd, id) { // save for other callers to access this axis component.axis = cbAxisOut; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { - cbAxisOut.titleside = opts.titleside; + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { + cbAxisOut.title.side = opts.title.side; cbAxisOut.titlex = opts.x + xpadFrac; cbAxisOut.titley = yBottomFrac + - (opts.titleside === 'top' ? lenFrac - ypadFrac : ypadFrac); + (opts.title.side === 'top' ? lenFrac - ypadFrac : ypadFrac); } if(opts.line.color && opts.tickmode === 'auto') { @@ -57360,17 +57694,18 @@ module.exports = function draw(gd, id) { Math.round(gs.l) + ',-' + Math.round(gs.t) + ')'); - cbAxisOut._axislayer = container.select('.cbaxis'); + var axisLayer = container.select('.cbaxis'); + var titleHeight = 0; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // draw the title so we know how much room it needs // when we squish the axis. This one only applies to // top or bottom titles, not right side. var x = gs.l + (opts.x + xpadFrac) * gs.w, - fontSize = cbAxisOut.titlefont.size, + fontSize = cbAxisOut.title.font.size, y; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; } @@ -57384,7 +57719,7 @@ module.exports = function draw(gd, id) { } function drawAxis() { - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // squish the axis top to make room for the title var titleGroup = container.select('.cbtitle'), titleText = titleGroup.select('text'), @@ -57415,7 +57750,7 @@ module.exports = function draw(gd, id) { // TODO: configurable titleHeight += 5; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; } @@ -57436,8 +57771,7 @@ module.exports = function draw(gd, id) { .attr('transform', 'translate(0,' + Math.round(gs.h * (1 - cbAxisOut.domain[1])) + ')'); - cbAxisOut._axislayer.attr('transform', 'translate(0,' + - Math.round(-gs.t) + ')'); + axisLayer.attr('transform', 'translate(0,' + Math.round(-gs.t) + ')'); var fills = container.select('.cbfills') .selectAll('rect.cbfill') @@ -57504,12 +57838,7 @@ module.exports = function draw(gd, id) { }); // force full redraw of labels and ticks - cbAxisOut._axislayer.selectAll('g.' + cbAxisOut._id + 'tick,path') - .remove(); - - cbAxisOut._pos = xLeft + thickPx + - (opts.outlinewidth||0) / 2 - (opts.ticks === 'outside' ? 1 : 0); - cbAxisOut.side = 'right'; + axisLayer.selectAll('g.' + cbAxisOut._id + 'tick,path').remove(); // separate out axis and title drawing, // so we don't need such complicated logic in Titles.draw @@ -57517,11 +57846,33 @@ module.exports = function draw(gd, id) { // this title call only handles side=right return Lib.syncOrAsync([ function() { - return Axes.doTicksSingle(gd, cbAxisOut, true); + var shift = xLeft + thickPx + + (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0); + + var vals = Axes.calcTicks(cbAxisOut); + var transFn = Axes.makeTransFn(cbAxisOut); + var labelFns = Axes.makeLabelFns(cbAxisOut, shift); + var tickSign = Axes.getTickSigns(cbAxisOut)[2]; + + Axes.drawTicks(gd, cbAxisOut, { + vals: cbAxisOut.ticks === 'inside' ? Axes.clipEnds(cbAxisOut, vals) : vals, + layer: axisLayer, + path: Axes.makeTickPath(cbAxisOut, shift, tickSign), + transFn: transFn + }); + + return Axes.drawLabels(gd, cbAxisOut, { + vals: vals, + layer: axisLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); }, function() { - if(['top', 'bottom'].indexOf(opts.titleside) === -1) { - var fontSize = cbAxisOut.titlefont.size, + if(['top', 'bottom'].indexOf(opts.title.side) === -1) { + var fontSize = cbAxisOut.title.font.size, y = cbAxisOut._offset + cbAxisOut._length / 2, x = gs.l + (cbAxisOut.position || 0) * gs.w + ((cbAxisOut.side === 'right') ? 10 + fontSize * ((cbAxisOut.showticklabels ? 1 : 0.5)) : @@ -57533,7 +57884,7 @@ module.exports = function draw(gd, id) { drawTitle('h' + cbAxisOut._id + 'title', { avoid: { selection: d3.select(gd).selectAll('g.' + cbAxisOut._id + 'tick'), - side: opts.titleside, + side: opts.title.side, offsetLeft: gs.l, offsetTop: 0, maxShift: fullLayout.width @@ -57546,15 +57897,10 @@ module.exports = function draw(gd, id) { } function drawTitle(titleClass, titleOpts) { - var trace = getTrace(); - var propName = 'colorbar.title'; - var containerName = trace._module.colorbar.container; - if(containerName) propName = containerName + '.' + propName; - var dfltTitleOpts = { propContainer: cbAxisOut, - propName: propName, - traceIndex: trace.index, + propName: getPropName('title'), + traceIndex: getTrace().index, placeholder: fullLayout._dfltTitle.colorbar, containerGroup: container.select('.cbtitle') }; @@ -57578,7 +57924,7 @@ module.exports = function draw(gd, id) { // TODO: why are we redrawing multiple times now with this? // I guess autoMargin doesn't like being post-promise? var innerWidth = thickPx + opts.outlinewidth / 2 + - Drawing.bBox(cbAxisOut._axislayer.node()).width; + Drawing.bBox(axisLayer.node()).width; titleEl = titleCont.select('text'); if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) { var mathJaxNode = titleCont @@ -57586,11 +57932,11 @@ module.exports = function draw(gd, id) { .node(), titleWidth; if(mathJaxNode && - ['top', 'bottom'].indexOf(opts.titleside) !== -1) { + ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; } else { - // note: the formula below works for all titlesides, + // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift // transform gets removed by Drawing.bBox @@ -57619,7 +57965,7 @@ module.exports = function draw(gd, id) { container.selectAll('.cboutline').attr({ x: xLeft, y: yTopPx + opts.ypad + - (opts.titleside === 'top' ? titleHeight : 0), + (opts.title.side === 'top' ? titleHeight : 0), width: Math.max(thickPx, 2), height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2) }) @@ -57706,11 +58052,10 @@ module.exports = function draw(gd, id) { setCursor(container); if(xf !== undefined && yf !== undefined) { - Registry.call('restyle', - gd, - {'colorbar.x': xf, 'colorbar.y': yf}, - getTrace().index - ); + var update = {}; + update[getPropName('x')] = xf; + update[getPropName('y')] = yf; + Registry.call('_guiRestyle', gd, update, getTrace().index); } } }); @@ -57728,6 +58073,14 @@ module.exports = function draw(gd, id) { } } + function getPropName(suffix) { + var trace = getTrace(); + var propName = 'colorbar.'; + var containerName = trace._module.colorbar.container; + if(containerName) propName = containerName + '.' + propName; + return propName + suffix; + } + // setter/getters for every item defined in opts Object.keys(opts).forEach(function(name) { component[name] = function(v) { @@ -57761,7 +58114,7 @@ module.exports = function draw(gd, id) { return component; }; -},{"../../constants/alignment":474,"../../lib":498,"../../lib/extend":490,"../../lib/setcursor":517,"../../lib/svg_text_utils":521,"../../plots/cartesian/axes":544,"../../plots/cartesian/axis_defaults":546,"../../plots/cartesian/layout_attributes":557,"../../plots/cartesian/position_defaults":560,"../../plots/plots":589,"../../registry":597,"../color":376,"../dragelement":398,"../drawing":401,"../titles":467,"./attributes":377,"./constants":379,"d3":82,"tinycolor2":342}],382:[function(_dereq_,module,exports){ +},{"../../constants/alignment":470,"../../lib":494,"../../lib/extend":487,"../../lib/setcursor":513,"../../lib/svg_text_utils":517,"../../plots/cartesian/axes":540,"../../plots/cartesian/axis_defaults":542,"../../plots/cartesian/layout_attributes":553,"../../plots/cartesian/position_defaults":556,"../../plots/plots":585,"../../registry":593,"../color":375,"../dragelement":393,"../drawing":396,"../titles":463,"./attributes":376,"./constants":378,"d3":82,"tinycolor2":341}],381:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57780,7 +58133,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":498}],383:[function(_dereq_,module,exports){ +},{"../../lib":494}],382:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57791,7 +58144,7 @@ module.exports = function hasColorbar(container) { 'use strict'; -var palettes = _dereq_('./scales.js'); +var palettes = _dereq_('./scales.js').scales; var paletteStr = Object.keys(palettes); function code(s) { @@ -57938,7 +58291,7 @@ module.exports = function colorScaleAttrs(context, opts) { valType: 'boolean', dflt: false, - editType: 'calc', + editType: 'plot', }; @@ -57955,7 +58308,7 @@ module.exports = function colorScaleAttrs(context, opts) { return attrs; }; -},{"./scales.js":395}],384:[function(_dereq_,module,exports){ +},{"./scales.js":390}],383:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57964,49 +58317,19 @@ module.exports = function colorScaleAttrs(context, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); -var scales = _dereq_('./scales'); -var flipScale = _dereq_('./flip_scale'); - - -module.exports = function calc(trace, vals, containerStr, cLetter) { - var container = trace; - var inputContainer = trace._input; - var fullInputContainer = trace._fullInput; - - // set by traces with groupby transforms - var updateStyle = trace.updateStyle; - - function doUpdate(attr, inputVal, fullVal) { - if(fullVal === undefined) fullVal = inputVal; - - if(updateStyle) { - updateStyle(trace._input, containerStr ? (containerStr + '.' + attr) : attr, inputVal); - } - else { - inputContainer[attr] = inputVal; - } - - container[attr] = fullVal; - if(fullInputContainer && (trace !== trace._fullInput)) { - if(updateStyle) { - updateStyle(trace._fullInput, containerStr ? (containerStr + '.' + attr) : attr, fullVal); - } - else { - fullInputContainer[attr] = fullVal; - } - } - } +module.exports = function calc(gd, trace, opts) { + var fullLayout = gd._fullLayout; + var vals = opts.vals; + var containerStr = opts.containerStr; + var cLetter = opts.cLetter; - if(containerStr) { - container = Lib.nestedProperty(container, containerStr).get(); - inputContainer = Lib.nestedProperty(inputContainer, containerStr).get(); - fullInputContainer = Lib.nestedProperty(fullInputContainer, containerStr).get() || {}; - } + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() : + trace; var autoAttr = cLetter + 'auto'; var minAttr = cLetter + 'min'; @@ -58029,37 +58352,19 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { max += 0.5; } - doUpdate(minAttr, min); - doUpdate(maxAttr, max); - - /* - * If auto was explicitly false but min or max was missing, - * we filled in the missing piece here but later the trace does - * not look auto. - * Otherwise make sure the trace still looks auto as far as later - * changes are concerned. - */ - doUpdate(autoAttr, (auto !== false || (min === undefined && max === undefined))); + container['_' + minAttr] = container[minAttr] = min; + container['_' + maxAttr] = container[maxAttr] = max; if(container.autocolorscale) { - if(min * max < 0) scl = scales.RdBu; - else if(min >= 0) scl = scales.Reds; - else scl = scales.Blues; - - // reversescale is handled at the containerOut level - doUpdate('colorscale', scl, container.reversescale ? flipScale(scl) : scl); + if(min * max < 0) scl = fullLayout.colorscale.diverging; + else if(min >= 0) scl = fullLayout.colorscale.sequential; + else scl = fullLayout.colorscale.sequentialminus; - // We pushed a colorscale back to input, which will change the default autocolorscale next time - // to avoid spurious redraws from Plotly.react, update resulting autocolorscale now - // This is a conscious decision so that changing the data later does not unexpectedly - // give you a new colorscale - if(!inputContainer.autocolorscale) { - doUpdate('autocolorscale', false); - } + container._colorscale = container.colorscale = scl; } }; -},{"../../lib":498,"./flip_scale":388,"./scales":395}],385:[function(_dereq_,module,exports){ +},{"../../lib":494}],384:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58070,12 +58375,68 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { 'use strict'; -var scales = _dereq_('./scales'); +var Lib = _dereq_('../../lib'); +var hasColorscale = _dereq_('./helpers').hasColorscale; + +module.exports = function crossTraceDefaults(fullData) { + function replace(cont, k) { + var val = cont['_' + k]; + if(val !== undefined) { + cont[k] = val; + } + } + + function relinkColorAtts(trace, cAttrs) { + var cont = cAttrs.container ? + Lib.nestedProperty(trace, cAttrs.container).get() : + trace; + + if(cont) { + var isAuto = cont.zauto || cont.cauto; + var minAttr = cAttrs.min; + var maxAttr = cAttrs.max; + + if(isAuto || cont[minAttr] === undefined) { + replace(cont, minAttr); + } + if(isAuto || cont[maxAttr] === undefined) { + replace(cont, maxAttr); + } + if(cont.autocolorscale) { + replace(cont, 'colorscale'); + } + } + } + + for(var i = 0; i < fullData.length; i++) { + var trace = fullData[i]; + var _module = trace._module; + + if(_module.colorbar) { + relinkColorAtts(trace, _module.colorbar); + } + + // TODO could generalize _module.colorscale and use it here? + if(hasColorscale(trace, 'marker.line')) { + relinkColorAtts(trace, { + container: 'marker.line', + min: 'cmin', + max: 'cmax' + }); + } -module.exports = scales.RdBu; + if(hasColorscale(trace, 'line')) { + relinkColorAtts(trace, { + container: 'line', + min: 'cmin', + max: 'cmax' + }); + } + } +}; -},{"./scales":395}],386:[function(_dereq_,module,exports){ +},{"../../lib":494,"./helpers":386}],385:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58084,33 +58445,32 @@ module.exports = scales.RdBu; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); - var hasColorbar = _dereq_('../colorbar/has_colorbar'); var colorbarDefaults = _dereq_('../colorbar/defaults'); -var isValidScale = _dereq_('./is_valid_scale'); -var flipScale = _dereq_('./flip_scale'); +var isValidScale = _dereq_('./scales').isValid; -module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { - var prefix = opts.prefix, - cLetter = opts.cLetter, - containerStr = prefix.slice(0, prefix.length - 1), - containerIn = prefix ? - Lib.nestedProperty(traceIn, containerStr).get() || {} : - traceIn, - containerOut = prefix ? - Lib.nestedProperty(traceOut, containerStr).get() || {} : - traceOut, - minIn = containerIn[cLetter + 'min'], - maxIn = containerIn[cLetter + 'max'], - sclIn = containerIn.colorscale; +function npMaybe(cont, prefix) { + var containerStr = prefix.slice(0, prefix.length - 1); + return prefix ? + Lib.nestedProperty(cont, containerStr).get() || {} : + cont; +} +module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { + var prefix = opts.prefix; + var cLetter = opts.cLetter; + var containerIn = npMaybe(traceIn, prefix); + var containerOut = npMaybe(traceOut, prefix); + var template = npMaybe(traceOut._template || {}, prefix) || {}; + + var minIn = containerIn[cLetter + 'min']; + var maxIn = containerIn[cLetter + 'max']; var validMinMax = isNumeric(minIn) && isNumeric(maxIn) && (minIn < maxIn); coerce(prefix + cLetter + 'auto', !validMinMax); coerce(prefix + cLetter + 'min'); @@ -58118,19 +58478,17 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, // handles both the trace case (autocolorscale is false by default) and // the marker and marker.line case (autocolorscale is true by default) + var sclIn = containerIn.colorscale; + var sclTemplate = template.colorscale; var autoColorscaleDflt; if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn); + if(sclTemplate !== undefined) autoColorscaleDflt = !isValidScale(sclTemplate); coerce(prefix + 'autocolorscale', autoColorscaleDflt); - var sclOut = coerce(prefix + 'colorscale'); - // reversescale is handled at the containerOut level - var reverseScale = coerce(prefix + 'reversescale'); - if(reverseScale) containerOut.colorscale = flipScale(sclOut); + coerce(prefix + 'colorscale'); + coerce(prefix + 'reversescale'); - // ... until Scatter.colorbar can handle marker line colorbars - if(prefix === 'marker.line.') return; - - if(!opts.noScale) { + if(!opts.noScale && prefix !== 'marker.line.') { // handles both the trace case where the dflt is listed in attributes and // the marker case where the dflt is determined by hasColorbar var showScaleDflt; @@ -58141,7 +58499,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, } }; -},{"../../lib":498,"../colorbar/defaults":380,"../colorbar/has_colorbar":382,"./flip_scale":388,"./is_valid_scale":392,"fast-isnumeric":91}],387:[function(_dereq_,module,exports){ +},{"../../lib":494,"../colorbar/defaults":379,"../colorbar/has_colorbar":381,"./scales":390,"fast-isnumeric":91}],386:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58150,24 +58508,77 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var d3 = _dereq_('d3'); +var tinycolor = _dereq_('tinycolor2'); +var isNumeric = _dereq_('fast-isnumeric'); + +var Lib = _dereq_('../../lib'); +var Color = _dereq_('../color'); + +var isValidScale = _dereq_('./scales').isValid; + +function hasColorscale(trace, containerStr) { + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() || {} : + trace; + var color = container.color; + + var isArrayWithOneNumber = false; + if(Lib.isArrayOrTypedArray(color)) { + for(var i = 0; i < color.length; i++) { + if(isNumeric(color[i])) { + isArrayWithOneNumber = true; + break; + } + } + } + + return ( + Lib.isPlainObject(container) && ( + isArrayWithOneNumber || + container.showscale === true || + (isNumeric(container.cmin) && isNumeric(container.cmax)) || + isValidScale(container.colorscale) || + Lib.isPlainObject(container.colorbar) + ) + ); +} + /** * Extract colorscale into numeric domain and color range. * - * @param {array} scl colorscale array of arrays - * @param {number} cmin minimum color value (used to clamp scale) - * @param {number} cmax maximum color value (used to clamp scale) + * @param {object} cont colorscale container (e.g. trace, marker) + * - colorscale {array of arrays} + * - cmin/zmin {number} + * - cmax/zmax {number} + * - reversescale {boolean} + * @param {object} opts + * - cLetter {string} 'c' (for cmin/cmax) or 'z' (for zmin/zmax) + * + * @return {object} + * - domain {array} + * - range {array} */ -module.exports = function extractScale(scl, cmin, cmax) { - var N = scl.length, - domain = new Array(N), - range = new Array(N); +function extractScale(cont, opts) { + var cLetter = opts.cLetter; + + var scl = cont.reversescale ? + flipScale(cont.colorscale) : + cont.colorscale; + + // minimum color value (used to clamp scale) + var cmin = cont[cLetter + 'min']; + // maximum color value (used to clamp scale) + var cmax = cont[cLetter + 'max']; + + var N = scl.length; + var domain = new Array(N); + var range = new Array(N); for(var i = 0; i < N; i++) { var si = scl[i]; - domain[i] = cmin + si[0] * (cmax - cmin); range[i] = si[1]; } @@ -58176,9 +58587,105 @@ module.exports = function extractScale(scl, cmin, cmax) { domain: domain, range: range }; +} + +function flipScale(scl) { + var N = scl.length; + var sclNew = new Array(N); + + for(var i = N - 1, j = 0; i >= 0; i--, j++) { + var si = scl[i]; + sclNew[j] = [1 - si[0], si[1]]; + } + return sclNew; +} + +/** + * General colorscale function generator. + * + * @param {object} specs output of Colorscale.extractScale or precomputed domain, range. + * - domain {array} + * - range {array} + * + * @param {object} opts + * - noNumericCheck {boolean} if true, scale func bypasses numeric checks + * - returnArray {boolean} if true, scale func return 4-item array instead of color strings + * + * @return {function} + */ +function makeColorScaleFunc(specs, opts) { + opts = opts || {}; + + var domain = specs.domain, + range = specs.range, + N = range.length, + _range = new Array(N); + + for(var i = 0; i < N; i++) { + var rgba = tinycolor(range[i]).toRgb(); + _range[i] = [rgba.r, rgba.g, rgba.b, rgba.a]; + } + + var _sclFunc = d3.scale.linear() + .domain(domain) + .range(_range) + .clamp(true); + + var noNumericCheck = opts.noNumericCheck, + returnArray = opts.returnArray, + sclFunc; + + if(noNumericCheck && returnArray) { + sclFunc = _sclFunc; + } + else if(noNumericCheck) { + sclFunc = function(v) { + return colorArray2rbga(_sclFunc(v)); + }; + } + else if(returnArray) { + sclFunc = function(v) { + if(isNumeric(v)) return _sclFunc(v); + else if(tinycolor(v).isValid()) return v; + else return Color.defaultLine; + }; + } + else { + sclFunc = function(v) { + if(isNumeric(v)) return colorArray2rbga(_sclFunc(v)); + else if(tinycolor(v).isValid()) return v; + else return Color.defaultLine; + }; + } + + // colorbar draw looks into the d3 scale closure for domain and range + + sclFunc.domain = _sclFunc.domain; + + sclFunc.range = function() { return range; }; + + return sclFunc; +} + +function colorArray2rbga(colorArray) { + var colorObj = { + r: colorArray[0], + g: colorArray[1], + b: colorArray[2], + a: colorArray[3] + }; + + return tinycolor(colorObj).toRgbString(); +} + +module.exports = { + hasColorscale: hasColorscale, + extractScale: extractScale, + flipScale: flipScale, + makeColorScaleFunc: makeColorScaleFunc }; -},{}],388:[function(_dereq_,module,exports){ +},{"../../lib":494,"../color":375,"./scales":390,"d3":82,"fast-isnumeric":91,"tinycolor2":341}],387:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58187,23 +58694,38 @@ module.exports = function extractScale(scl, cmin, cmax) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -module.exports = function flipScale(scl) { - var N = scl.length, - sclNew = new Array(N), - si; +var scales = _dereq_('./scales'); +var helpers = _dereq_('./helpers'); - for(var i = N - 1, j = 0; i >= 0; i--, j++) { - si = scl[i]; - sclNew[j] = [1 - si[0], si[1]]; - } +module.exports = { + moduleType: 'component', + name: 'colorscale', - return sclNew; + attributes: _dereq_('./attributes'), + layoutAttributes: _dereq_('./layout_attributes'), + + supplyLayoutDefaults: _dereq_('./layout_defaults'), + handleDefaults: _dereq_('./defaults'), + crossTraceDefaults: _dereq_('./cross_trace_defaults'), + + calc: _dereq_('./calc'), + + // ./scales.js is required in lib/coerce.js ; + // it needs to be a seperate module to avoid circular a dependency + scales: scales.scales, + defaultScale: scales.defaultScale, + getScale: scales.get, + isValidScale: scales.isValid, + + hasColorscale: helpers.hasColorscale, + flipScale: helpers.flipScale, + extractScale: helpers.extractScale, + makeColorScaleFunc: helpers.makeColorScaleFunc }; -},{}],389:[function(_dereq_,module,exports){ +},{"./attributes":382,"./calc":383,"./cross_trace_defaults":384,"./defaults":385,"./helpers":386,"./layout_attributes":388,"./layout_defaults":389,"./scales":390}],388:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58212,38 +58734,38 @@ module.exports = function flipScale(scl) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var scales = _dereq_('./scales'); -var defaultScale = _dereq_('./default_scale'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function getScale(scl, dflt) { - if(!dflt) dflt = defaultScale; - if(!scl) return dflt; +var scales = _dereq_('./scales').scales; - function parseScale() { - try { - scl = scales[scl] || JSON.parse(scl); - } - catch(e) { - scl = dflt; - } - } +var msg = 'Note that `autocolorscale` must be true for this attribute to work.'; - if(typeof scl === 'string') { - parseScale(); - // occasionally scl is double-JSON encoded... - if(typeof scl === 'string') parseScale(); +module.exports = { + editType: 'calc', + sequential: { + valType: 'colorscale', + dflt: scales.Reds, + + editType: 'calc', + + }, + sequentialminus: { + valType: 'colorscale', + dflt: scales.Blues, + + editType: 'calc', + + }, + diverging: { + valType: 'colorscale', + dflt: scales.RdBu, + + editType: 'calc', + } - - if(!isValidScaleArray(scl)) return dflt; - return scl; }; -},{"./default_scale":385,"./is_valid_scale_array":393,"./scales":395}],390:[function(_dereq_,module,exports){ +},{"./scales":390}],389:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58254,38 +58776,23 @@ module.exports = function getScale(scl, dflt) { 'use strict'; -var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); -var isValidScale = _dereq_('./is_valid_scale'); - -module.exports = function hasColorscale(trace, containerStr) { - var container = containerStr ? - Lib.nestedProperty(trace, containerStr).get() || {} : - trace; - var color = container.color; +var colorscaleAttrs = _dereq_('./layout_attributes'); +var Template = _dereq_('../../plot_api/plot_template'); - var isArrayWithOneNumber = false; - if(Lib.isArrayOrTypedArray(color)) { - for(var i = 0; i < color.length; i++) { - if(isNumeric(color[i])) { - isArrayWithOneNumber = true; - break; - } - } +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var colorscaleIn = layoutIn.colorscale; + var colorscaleOut = Template.newContainer(layoutOut, 'colorscale'); + function coerce(attr, dflt) { + return Lib.coerce(colorscaleIn, colorscaleOut, colorscaleAttrs, attr, dflt); } - return ( - Lib.isPlainObject(container) && ( - isArrayWithOneNumber || - container.showscale === true || - (isNumeric(container.cmin) && isNumeric(container.cmax)) || - isValidScale(container.colorscale) || - Lib.isPlainObject(container.colorbar) - ) - ); + coerce('sequential'); + coerce('sequentialminus'); + coerce('diverging'); }; -},{"../../lib":498,"./is_valid_scale":392,"fast-isnumeric":91}],391:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plot_api/plot_template":530,"./layout_attributes":388}],390:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58294,68 +58801,167 @@ module.exports = function hasColorscale(trace, containerStr) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -exports.scales = _dereq_('./scales'); +var tinycolor = _dereq_('tinycolor2'); -exports.defaultScale = _dereq_('./default_scale'); +var scales = { + 'Greys': [ + [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] + ], -exports.attributes = _dereq_('./attributes'); + 'YlGnBu': [ + [0, 'rgb(8,29,88)'], [0.125, 'rgb(37,52,148)'], + [0.25, 'rgb(34,94,168)'], [0.375, 'rgb(29,145,192)'], + [0.5, 'rgb(65,182,196)'], [0.625, 'rgb(127,205,187)'], + [0.75, 'rgb(199,233,180)'], [0.875, 'rgb(237,248,217)'], + [1, 'rgb(255,255,217)'] + ], + + 'Greens': [ + [0, 'rgb(0,68,27)'], [0.125, 'rgb(0,109,44)'], + [0.25, 'rgb(35,139,69)'], [0.375, 'rgb(65,171,93)'], + [0.5, 'rgb(116,196,118)'], [0.625, 'rgb(161,217,155)'], + [0.75, 'rgb(199,233,192)'], [0.875, 'rgb(229,245,224)'], + [1, 'rgb(247,252,245)'] + ], -exports.handleDefaults = _dereq_('./defaults'); + 'YlOrRd': [ + [0, 'rgb(128,0,38)'], [0.125, 'rgb(189,0,38)'], + [0.25, 'rgb(227,26,28)'], [0.375, 'rgb(252,78,42)'], + [0.5, 'rgb(253,141,60)'], [0.625, 'rgb(254,178,76)'], + [0.75, 'rgb(254,217,118)'], [0.875, 'rgb(255,237,160)'], + [1, 'rgb(255,255,204)'] + ], -exports.calc = _dereq_('./calc'); + 'Bluered': [ + [0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)'] + ], -exports.hasColorscale = _dereq_('./has_colorscale'); + // modified RdBu based on + // www.sandia.gov/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf + 'RdBu': [ + [0, 'rgb(5,10,172)'], [0.35, 'rgb(106,137,247)'], + [0.5, 'rgb(190,190,190)'], [0.6, 'rgb(220,170,132)'], + [0.7, 'rgb(230,145,90)'], [1, 'rgb(178,10,28)'] + ], + + // Scale for non-negative numeric values + 'Reds': [ + [0, 'rgb(220,220,220)'], [0.2, 'rgb(245,195,157)'], + [0.4, 'rgb(245,160,105)'], [1, 'rgb(178,10,28)'] + ], -exports.isValidScale = _dereq_('./is_valid_scale'); + // Scale for non-positive numeric values + 'Blues': [ + [0, 'rgb(5,10,172)'], [0.35, 'rgb(40,60,190)'], + [0.5, 'rgb(70,100,245)'], [0.6, 'rgb(90,120,245)'], + [0.7, 'rgb(106,137,247)'], [1, 'rgb(220,220,220)'] + ], -exports.getScale = _dereq_('./get_scale'); + 'Picnic': [ + [0, 'rgb(0,0,255)'], [0.1, 'rgb(51,153,255)'], + [0.2, 'rgb(102,204,255)'], [0.3, 'rgb(153,204,255)'], + [0.4, 'rgb(204,204,255)'], [0.5, 'rgb(255,255,255)'], + [0.6, 'rgb(255,204,255)'], [0.7, 'rgb(255,153,255)'], + [0.8, 'rgb(255,102,204)'], [0.9, 'rgb(255,102,102)'], + [1, 'rgb(255,0,0)'] + ], -exports.flipScale = _dereq_('./flip_scale'); + 'Rainbow': [ + [0, 'rgb(150,0,90)'], [0.125, 'rgb(0,0,200)'], + [0.25, 'rgb(0,25,255)'], [0.375, 'rgb(0,152,255)'], + [0.5, 'rgb(44,255,150)'], [0.625, 'rgb(151,255,0)'], + [0.75, 'rgb(255,234,0)'], [0.875, 'rgb(255,111,0)'], + [1, 'rgb(255,0,0)'] + ], -exports.extractScale = _dereq_('./extract_scale'); + 'Portland': [ + [0, 'rgb(12,51,131)'], [0.25, 'rgb(10,136,186)'], + [0.5, 'rgb(242,211,56)'], [0.75, 'rgb(242,143,56)'], + [1, 'rgb(217,30,30)'] + ], -exports.makeColorScaleFunc = _dereq_('./make_color_scale_func'); + 'Jet': [ + [0, 'rgb(0,0,131)'], [0.125, 'rgb(0,60,170)'], + [0.375, 'rgb(5,255,255)'], [0.625, 'rgb(255,255,0)'], + [0.875, 'rgb(250,0,0)'], [1, 'rgb(128,0,0)'] + ], -},{"./attributes":383,"./calc":384,"./default_scale":385,"./defaults":386,"./extract_scale":387,"./flip_scale":388,"./get_scale":389,"./has_colorscale":390,"./is_valid_scale":392,"./make_color_scale_func":394,"./scales":395}],392:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ + 'Hot': [ + [0, 'rgb(0,0,0)'], [0.3, 'rgb(230,0,0)'], + [0.6, 'rgb(255,210,0)'], [1, 'rgb(255,255,255)'] + ], + 'Blackbody': [ + [0, 'rgb(0,0,0)'], [0.2, 'rgb(230,0,0)'], + [0.4, 'rgb(230,210,0)'], [0.7, 'rgb(255,255,255)'], + [1, 'rgb(160,200,255)'] + ], -'use strict'; + 'Earth': [ + [0, 'rgb(0,0,130)'], [0.1, 'rgb(0,180,180)'], + [0.2, 'rgb(40,210,40)'], [0.4, 'rgb(230,230,50)'], + [0.6, 'rgb(120,70,20)'], [1, 'rgb(255,255,255)'] + ], -var scales = _dereq_('./scales'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); + 'Electric': [ + [0, 'rgb(0,0,0)'], [0.15, 'rgb(30,0,100)'], + [0.4, 'rgb(120,0,100)'], [0.6, 'rgb(160,90,0)'], + [0.8, 'rgb(230,200,0)'], [1, 'rgb(255,250,220)'] + ], + 'Viridis': [ + [0, '#440154'], [0.06274509803921569, '#48186a'], + [0.12549019607843137, '#472d7b'], [0.18823529411764706, '#424086'], + [0.25098039215686274, '#3b528b'], [0.3137254901960784, '#33638d'], + [0.3764705882352941, '#2c728e'], [0.4392156862745098, '#26828e'], + [0.5019607843137255, '#21918c'], [0.5647058823529412, '#1fa088'], + [0.6274509803921569, '#28ae80'], [0.6901960784313725, '#3fbc73'], + [0.7529411764705882, '#5ec962'], [0.8156862745098039, '#84d44b'], + [0.8784313725490196, '#addc30'], [0.9411764705882353, '#d8e219'], + [1, '#fde725'] + ], -module.exports = function isValidScale(scl) { - if(scales[scl] !== undefined) return true; - else return isValidScaleArray(scl); + 'Cividis': [ + [0.000000, 'rgb(0,32,76)'], [0.058824, 'rgb(0,42,102)'], + [0.117647, 'rgb(0,52,110)'], [0.176471, 'rgb(39,63,108)'], + [0.235294, 'rgb(60,74,107)'], [0.294118, 'rgb(76,85,107)'], + [0.352941, 'rgb(91,95,109)'], [0.411765, 'rgb(104,106,112)'], + [0.470588, 'rgb(117,117,117)'], [0.529412, 'rgb(131,129,120)'], + [0.588235, 'rgb(146,140,120)'], [0.647059, 'rgb(161,152,118)'], + [0.705882, 'rgb(176,165,114)'], [0.764706, 'rgb(192,177,109)'], + [0.823529, 'rgb(209,191,102)'], [0.882353, 'rgb(225,204,92)'], + [0.941176, 'rgb(243,219,79)'], [1.000000, 'rgb(255,233,69)'] + ] }; -},{"./is_valid_scale_array":393,"./scales":395}],393:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +var defaultScale = scales.RdBu; +function getScale(scl, dflt) { + if(!dflt) dflt = defaultScale; + if(!scl) return dflt; -'use strict'; + function parseScale() { + try { + scl = scales[scl] || JSON.parse(scl); + } catch(e) { + scl = dflt; + } + } -var tinycolor = _dereq_('tinycolor2'); + if(typeof scl === 'string') { + parseScale(); + // occasionally scl is double-JSON encoded... + if(typeof scl === 'string') parseScale(); + } + + if(!isValidScaleArray(scl)) return dflt; + return scl; +} -module.exports = function isValidScaleArray(scl) { +function isValidScaleArray(scl) { var highestVal = 0; if(!Array.isArray(scl) || scl.length < 2) return false; @@ -58375,248 +58981,22 @@ module.exports = function isValidScaleArray(scl) { } return true; -}; - -},{"tinycolor2":342}],394:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var d3 = _dereq_('d3'); -var tinycolor = _dereq_('tinycolor2'); -var isNumeric = _dereq_('fast-isnumeric'); - -var Color = _dereq_('../color'); - -/** - * General colorscale function generator. - * - * @param {object} specs output of Colorscale.extractScale or precomputed domain, range. - * - domain {array} - * - range {array} - * - * @param {object} opts - * - noNumericCheck {boolean} if true, scale func bypasses numeric checks - * - returnArray {boolean} if true, scale func return 4-item array instead of color strings - * - * @return {function} - */ -module.exports = function makeColorScaleFunc(specs, opts) { - opts = opts || {}; - - var domain = specs.domain, - range = specs.range, - N = range.length, - _range = new Array(N); - - for(var i = 0; i < N; i++) { - var rgba = tinycolor(range[i]).toRgb(); - _range[i] = [rgba.r, rgba.g, rgba.b, rgba.a]; - } - - var _sclFunc = d3.scale.linear() - .domain(domain) - .range(_range) - .clamp(true); - - var noNumericCheck = opts.noNumericCheck, - returnArray = opts.returnArray, - sclFunc; - - if(noNumericCheck && returnArray) { - sclFunc = _sclFunc; - } - else if(noNumericCheck) { - sclFunc = function(v) { - return colorArray2rbga(_sclFunc(v)); - }; - } - else if(returnArray) { - sclFunc = function(v) { - if(isNumeric(v)) return _sclFunc(v); - else if(tinycolor(v).isValid()) return v; - else return Color.defaultLine; - }; - } - else { - sclFunc = function(v) { - if(isNumeric(v)) return colorArray2rbga(_sclFunc(v)); - else if(tinycolor(v).isValid()) return v; - else return Color.defaultLine; - }; - } - - // colorbar draw looks into the d3 scale closure for domain and range - - sclFunc.domain = _sclFunc.domain; - - sclFunc.range = function() { return range; }; - - return sclFunc; -}; - -function colorArray2rbga(colorArray) { - var colorObj = { - r: colorArray[0], - g: colorArray[1], - b: colorArray[2], - a: colorArray[3] - }; - - return tinycolor(colorObj).toRgbString(); } -},{"../color":376,"d3":82,"fast-isnumeric":91,"tinycolor2":342}],395:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - +function isValidScale(scl) { + if(scales[scl] !== undefined) return true; + else return isValidScaleArray(scl); +} module.exports = { - 'Greys': [ - [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] - ], - - 'YlGnBu': [ - [0, 'rgb(8,29,88)'], [0.125, 'rgb(37,52,148)'], - [0.25, 'rgb(34,94,168)'], [0.375, 'rgb(29,145,192)'], - [0.5, 'rgb(65,182,196)'], [0.625, 'rgb(127,205,187)'], - [0.75, 'rgb(199,233,180)'], [0.875, 'rgb(237,248,217)'], - [1, 'rgb(255,255,217)'] - ], - - 'Greens': [ - [0, 'rgb(0,68,27)'], [0.125, 'rgb(0,109,44)'], - [0.25, 'rgb(35,139,69)'], [0.375, 'rgb(65,171,93)'], - [0.5, 'rgb(116,196,118)'], [0.625, 'rgb(161,217,155)'], - [0.75, 'rgb(199,233,192)'], [0.875, 'rgb(229,245,224)'], - [1, 'rgb(247,252,245)'] - ], - - 'YlOrRd': [ - [0, 'rgb(128,0,38)'], [0.125, 'rgb(189,0,38)'], - [0.25, 'rgb(227,26,28)'], [0.375, 'rgb(252,78,42)'], - [0.5, 'rgb(253,141,60)'], [0.625, 'rgb(254,178,76)'], - [0.75, 'rgb(254,217,118)'], [0.875, 'rgb(255,237,160)'], - [1, 'rgb(255,255,204)'] - ], - - 'Bluered': [ - [0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)'] - ], - - // modified RdBu based on - // www.sandia.gov/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf - 'RdBu': [ - [0, 'rgb(5,10,172)'], [0.35, 'rgb(106,137,247)'], - [0.5, 'rgb(190,190,190)'], [0.6, 'rgb(220,170,132)'], - [0.7, 'rgb(230,145,90)'], [1, 'rgb(178,10,28)'] - ], - - // Scale for non-negative numeric values - 'Reds': [ - [0, 'rgb(220,220,220)'], [0.2, 'rgb(245,195,157)'], - [0.4, 'rgb(245,160,105)'], [1, 'rgb(178,10,28)'] - ], - - // Scale for non-positive numeric values - 'Blues': [ - [0, 'rgb(5,10,172)'], [0.35, 'rgb(40,60,190)'], - [0.5, 'rgb(70,100,245)'], [0.6, 'rgb(90,120,245)'], - [0.7, 'rgb(106,137,247)'], [1, 'rgb(220,220,220)'] - ], - - 'Picnic': [ - [0, 'rgb(0,0,255)'], [0.1, 'rgb(51,153,255)'], - [0.2, 'rgb(102,204,255)'], [0.3, 'rgb(153,204,255)'], - [0.4, 'rgb(204,204,255)'], [0.5, 'rgb(255,255,255)'], - [0.6, 'rgb(255,204,255)'], [0.7, 'rgb(255,153,255)'], - [0.8, 'rgb(255,102,204)'], [0.9, 'rgb(255,102,102)'], - [1, 'rgb(255,0,0)'] - ], - - 'Rainbow': [ - [0, 'rgb(150,0,90)'], [0.125, 'rgb(0,0,200)'], - [0.25, 'rgb(0,25,255)'], [0.375, 'rgb(0,152,255)'], - [0.5, 'rgb(44,255,150)'], [0.625, 'rgb(151,255,0)'], - [0.75, 'rgb(255,234,0)'], [0.875, 'rgb(255,111,0)'], - [1, 'rgb(255,0,0)'] - ], - - 'Portland': [ - [0, 'rgb(12,51,131)'], [0.25, 'rgb(10,136,186)'], - [0.5, 'rgb(242,211,56)'], [0.75, 'rgb(242,143,56)'], - [1, 'rgb(217,30,30)'] - ], - - 'Jet': [ - [0, 'rgb(0,0,131)'], [0.125, 'rgb(0,60,170)'], - [0.375, 'rgb(5,255,255)'], [0.625, 'rgb(255,255,0)'], - [0.875, 'rgb(250,0,0)'], [1, 'rgb(128,0,0)'] - ], + scales: scales, + defaultScale: defaultScale, - 'Hot': [ - [0, 'rgb(0,0,0)'], [0.3, 'rgb(230,0,0)'], - [0.6, 'rgb(255,210,0)'], [1, 'rgb(255,255,255)'] - ], - - 'Blackbody': [ - [0, 'rgb(0,0,0)'], [0.2, 'rgb(230,0,0)'], - [0.4, 'rgb(230,210,0)'], [0.7, 'rgb(255,255,255)'], - [1, 'rgb(160,200,255)'] - ], - - 'Earth': [ - [0, 'rgb(0,0,130)'], [0.1, 'rgb(0,180,180)'], - [0.2, 'rgb(40,210,40)'], [0.4, 'rgb(230,230,50)'], - [0.6, 'rgb(120,70,20)'], [1, 'rgb(255,255,255)'] - ], - - 'Electric': [ - [0, 'rgb(0,0,0)'], [0.15, 'rgb(30,0,100)'], - [0.4, 'rgb(120,0,100)'], [0.6, 'rgb(160,90,0)'], - [0.8, 'rgb(230,200,0)'], [1, 'rgb(255,250,220)'] - ], - - 'Viridis': [ - [0, '#440154'], [0.06274509803921569, '#48186a'], - [0.12549019607843137, '#472d7b'], [0.18823529411764706, '#424086'], - [0.25098039215686274, '#3b528b'], [0.3137254901960784, '#33638d'], - [0.3764705882352941, '#2c728e'], [0.4392156862745098, '#26828e'], - [0.5019607843137255, '#21918c'], [0.5647058823529412, '#1fa088'], - [0.6274509803921569, '#28ae80'], [0.6901960784313725, '#3fbc73'], - [0.7529411764705882, '#5ec962'], [0.8156862745098039, '#84d44b'], - [0.8784313725490196, '#addc30'], [0.9411764705882353, '#d8e219'], - [1, '#fde725'] - ], - - 'Cividis': [ - [0.000000, 'rgb(0,32,76)'], [0.058824, 'rgb(0,42,102)'], - [0.117647, 'rgb(0,52,110)'], [0.176471, 'rgb(39,63,108)'], - [0.235294, 'rgb(60,74,107)'], [0.294118, 'rgb(76,85,107)'], - [0.352941, 'rgb(91,95,109)'], [0.411765, 'rgb(104,106,112)'], - [0.470588, 'rgb(117,117,117)'], [0.529412, 'rgb(131,129,120)'], - [0.588235, 'rgb(146,140,120)'], [0.647059, 'rgb(161,152,118)'], - [0.705882, 'rgb(176,165,114)'], [0.764706, 'rgb(192,177,109)'], - [0.823529, 'rgb(209,191,102)'], [0.882353, 'rgb(225,204,92)'], - [0.941176, 'rgb(243,219,79)'], [1.000000, 'rgb(255,233,69)'] - ] + get: getScale, + isValid: isValidScale }; -},{}],396:[function(_dereq_,module,exports){ +},{"tinycolor2":341}],391:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58649,7 +59029,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],397:[function(_dereq_,module,exports){ +},{}],392:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58687,7 +59067,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":498}],398:[function(_dereq_,module,exports){ +},{"../../lib":494}],393:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58814,8 +59194,6 @@ dragElement.init = function init(options) { var clampFn = options.clampFn || _clampFn; function onStart(e) { - e.preventDefault(); - // make dragging and dragged into properties of gd // so that others can look at and modify them gd._dragged = false; @@ -58857,11 +59235,15 @@ dragElement.init = function init(options) { document.documentElement.style.cursor = window.getComputedStyle(element).cursor; } - document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onDone); - document.addEventListener('touchmove', onMove); document.addEventListener('touchend', onDone); + if(options.dragmode !== false) { + e.preventDefault(); + document.addEventListener('mousemove', onMove); + document.addEventListener('touchmove', onMove); + } + return; } @@ -58885,13 +59267,15 @@ dragElement.init = function init(options) { } function onDone(e) { - document.removeEventListener('mousemove', onMove); + if(options.dragmode !== false) { + e.preventDefault(); + document.removeEventListener('mousemove', onMove); + document.removeEventListener('touchmove', onMove); + } + document.removeEventListener('mouseup', onDone); - document.removeEventListener('touchmove', onMove); document.removeEventListener('touchend', onDone); - e.preventDefault(); - if(hasHover) { Lib.removeElement(dragCover); } @@ -58984,7 +59368,7 @@ function pointerOffset(e) { ); } -},{"../../constants/interactions":477,"../../lib":498,"../../plots/cartesian/constants":550,"../../registry":597,"./align":396,"./cursor":397,"./unhover":399,"has-hover":250,"has-passive-events":251,"mouse-event-offset":271}],399:[function(_dereq_,module,exports){ +},{"../../constants/interactions":473,"../../lib":494,"../../plots/cartesian/constants":546,"../../registry":593,"./align":391,"./cursor":392,"./unhover":394,"has-hover":250,"has-passive-events":251,"mouse-event-offset":271}],394:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59042,7 +59426,7 @@ unhover.raw = function unhoverRaw(gd, evt) { } }; -},{"../../lib/events":489,"../../lib/get_graph_div":494,"../../lib/throttle":522,"../fx/constants":413}],400:[function(_dereq_,module,exports){ +},{"../../lib/events":486,"../../lib/get_graph_div":491,"../../lib/throttle":518,"../fx/constants":408}],395:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59067,7 +59451,7 @@ exports.dash = { }; -},{}],401:[function(_dereq_,module,exports){ +},{}],396:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59268,7 +59652,11 @@ drawing.fillGroupStyle = function(s) { s.style('stroke-width', 0) .each(function(d) { var shape = d3.select(this); - shape.call(Color.fill, d[0].trace.fillcolor); + // N.B. 'd' won't be a calcdata item when + // fill !== 'none' on a segment-less and marker-less trace + if(d[0].trace) { + shape.call(Color.fill, d[0].trace.fillcolor); + } }); }; @@ -59709,7 +60097,7 @@ drawing.tryColorscale = function(marker, prefix) { if(scl && Lib.isArrayOrTypedArray(colorArray)) { return Colorscale.makeColorScaleFunc( - Colorscale.extractScale(scl, cont.cmin, cont.cmax) + Colorscale.extractScale(cont, {cLetter: 'c'}) ); } } @@ -60070,32 +60458,28 @@ function nodeHash(node) { node.getAttribute('style'); } -/* - * make a robust clipPath url from a local id - * note! We'd better not be exporting from a page - * with a or the svg will not be portable! +/** + * Set clipPath URL in a way that work for all situations. + * + * In details, graphs on pages with HTML tags need to prepend + * the clip path ids with the page's base url EXCEPT during toImage exports. + * + * @param {d3 selection} s : node to add clip-path attribute + * @param {string} localId : local clip-path (w/o base url) id + * @param {DOM element || object} gd + * - context._baseUrl {string} + * - context._exportedPlot {boolean} */ -drawing.setClipUrl = function(s, localId) { +drawing.setClipUrl = function(s, localId, gd) { if(!localId) { s.attr('clip-path', null); return; } - if(drawing.baseUrl === undefined) { - var base = d3.select('base'); - - // Stash base url once and for all! - // We may have to stash this elsewhere when - // we'll try to support for child windows - // more info -> https://github.com/plotly/plotly.js/issues/702 - if(base.size() && base.attr('href')) { - drawing.baseUrl = window.location.href.split('#')[0]; - } else { - drawing.baseUrl = ''; - } - } + var context = gd._context; + var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - s.attr('clip-path', 'url(' + drawing.baseUrl + '#' + localId + ')'); + s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')'); }; drawing.getTranslate = function(element) { @@ -60227,7 +60611,7 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../constants/alignment":474,"../../constants/interactions":477,"../../constants/xmlns_namespaces":479,"../../lib":498,"../../lib/svg_text_utils":521,"../../registry":597,"../../traces/scatter/make_bubble_size_func":636,"../../traces/scatter/subtypes":643,"../color":376,"../colorscale":391,"./symbol_defs":402,"d3":82,"fast-isnumeric":91,"tinycolor2":342}],402:[function(_dereq_,module,exports){ +},{"../../constants/alignment":470,"../../constants/interactions":473,"../../constants/xmlns_namespaces":475,"../../lib":494,"../../lib/svg_text_utils":517,"../../registry":593,"../../traces/scatter/make_bubble_size_func":632,"../../traces/scatter/subtypes":639,"../color":375,"../colorscale":387,"./symbol_defs":397,"d3":82,"fast-isnumeric":91,"tinycolor2":341}],397:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60715,7 +61099,7 @@ module.exports = { } }; -},{"d3":82}],403:[function(_dereq_,module,exports){ +},{"d3":82}],398:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60830,7 +61214,7 @@ module.exports = { } }; -},{}],404:[function(_dereq_,module,exports){ +},{}],399:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -60912,7 +61296,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max); } -},{"../../plots/cartesian/axes":544,"../../registry":597,"./compute_error":405,"fast-isnumeric":91}],405:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":540,"../../registry":593,"./compute_error":400,"fast-isnumeric":91}],400:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61016,7 +61400,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],406:[function(_dereq_,module,exports){ +},{}],401:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61092,7 +61476,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":498,"../../plot_api/plot_template":534,"../../registry":597,"./attributes":403,"fast-isnumeric":91}],407:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plot_api/plot_template":530,"../../registry":593,"./attributes":398,"fast-isnumeric":91}],402:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61161,7 +61545,7 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":498,"../../plot_api/edit_types":527,"./attributes":403,"./calc":404,"./compute_error":405,"./defaults":406,"./plot":408,"./style":409}],408:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plot_api/edit_types":523,"./attributes":398,"./calc":399,"./compute_error":400,"./defaults":401,"./plot":403,"./style":404}],403:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61179,7 +61563,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); var subTypes = _dereq_('../../traces/scatter/subtypes'); -module.exports = function plot(traces, plotinfo, transitionOpts) { +module.exports = function plot(gd, traces, plotinfo, transitionOpts) { var isNew; var xa = plotinfo.xaxis; @@ -61230,7 +61614,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { .style('opacity', 1); } - Drawing.setClipUrl(errorbars, plotinfo.layerClipId); + Drawing.setClipUrl(errorbars, plotinfo.layerClipId, gd); errorbars.each(function(d) { var errorbar = d3.select(this); @@ -61335,7 +61719,7 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":643,"../drawing":401,"d3":82,"fast-isnumeric":91}],409:[function(_dereq_,module,exports){ +},{"../../traces/scatter/subtypes":639,"../drawing":396,"d3":82,"fast-isnumeric":91}],404:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61372,7 +61756,7 @@ module.exports = function style(traces) { }); }; -},{"../color":376,"d3":82}],410:[function(_dereq_,module,exports){ +},{"../color":375,"d3":82}],405:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61418,7 +61802,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":571}],411:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":567}],406:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61455,6 +61839,8 @@ module.exports = function calc(gd) { fillFn(trace.hoverinfo, cd, 'hi', makeCoerceHoverInfo(trace)); + if(trace.hovertemplate) fillFn(trace.hovertemplate, cd, 'ht'); + if(!trace.hoverlabel) continue; fillFn(trace.hoverlabel.bgcolor, cd, 'hbg'); @@ -61474,7 +61860,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":498,"../../registry":597}],412:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../registry":593}],407:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61512,7 +61898,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":597,"./hover":416}],413:[function(_dereq_,module,exports){ +},{"../../registry":593,"./hover":411}],408:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61544,7 +61930,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],414:[function(_dereq_,module,exports){ +},{}],409:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61567,7 +61953,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, layout.hoverlabel); }; -},{"../../lib":498,"./attributes":410,"./hoverlabel_defaults":417}],415:[function(_dereq_,module,exports){ +},{"../../lib":494,"./attributes":405,"./hoverlabel_defaults":412}],410:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61810,7 +62196,7 @@ function getPointData(val, pointNumber) { } } -},{"../../lib":498}],416:[function(_dereq_,module,exports){ +},{"../../lib":494}],411:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61939,13 +62325,17 @@ exports.loneHover = function loneHover(hoverItem, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; var container3 = d3.select(opts.container); @@ -61959,7 +62349,6 @@ exports.loneHover = function loneHover(hoverItem, opts) { container: container3, outerContainer: outerContainer3 }; - var hoverLabel = createHoverText([pointData], fullOpts, opts.gd); alignHoverText(hoverLabel, fullOpts.rotateLabels); @@ -61993,13 +62382,17 @@ exports.multiHovers = function multiHovers(hoverItems, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; }); @@ -62475,7 +62868,14 @@ function _hover(gd, evt, subplot, noHoverEvent) { // other people and send it to the event for(itemnum = 0; itemnum < hoverData.length; itemnum++) { var pt = hoverData[itemnum]; - newhoverdata.push(helpers.makeEventData(pt, pt.trace, pt.cd)); + var eventData = helpers.makeEventData(pt, pt.trace, pt.cd); + + var ht = false; + if(pt.cd[pt.index] && pt.cd[pt.index].ht) ht = pt.cd[pt.index].ht; + hoverData[itemnum].hovertemplate = ht || pt.trace.hovertemplate || false; + hoverData[itemnum].eventData = [eventData]; + + newhoverdata.push(eventData); } gd._hoverdata = newhoverdata; @@ -62533,6 +62933,8 @@ function _hover(gd, evt, subplot, noHoverEvent) { }); } +var EXTRA_STRING_REGEX = /([\s\S]*)<\/extra>/; + function createHoverText(hoverData, opts, gd) { var hovermode = opts.hovermode; var rotateLabels = opts.rotateLabels; @@ -62576,11 +62978,13 @@ function createHoverText(hoverData, opts, gd) { if(allHaveZ && hoverData[i].zLabel === undefined) allHaveZ = false; traceHoverinfo = hoverData[i].hoverinfo || hoverData[i].trace.hoverinfo; - var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); - if(parts.indexOf('all') === -1 && - parts.indexOf(hovermode) === -1) { - showCommonLabel = false; - break; + if(traceHoverinfo) { + var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); + if(parts.indexOf('all') === -1 && + parts.indexOf(hovermode) === -1) { + showCommonLabel = false; + break; + } } } @@ -62763,6 +63167,19 @@ function createHoverText(hoverData, opts, gd) { text = name; } + // hovertemplate + var hovertemplate = d.hovertemplate || false; + var hovertemplateLabels = d.hovertemplateLabels || d; + var eventData = d.eventData[0] || {}; + if(hovertemplate) { + text = Lib.hovertemplateString(hovertemplate, hovertemplateLabels, eventData); + + text = text.replace(EXTRA_STRING_REGEX, function(match, extra) { + name = extra; // Assign name for secondary text label + return ''; // Remove from main text label + }); + } + // main label var tx = g.select('text.nums') .call(Drawing.font, @@ -63161,7 +63578,7 @@ function cleanPoint(d, hovermode) { var infomode = d.hoverinfo || d.trace.hoverinfo; - if(infomode !== 'all') { + if(infomode && infomode !== 'all') { infomode = Array.isArray(infomode) ? infomode : infomode.split('+'); if(infomode.indexOf('x') === -1) d.xLabel = undefined; if(infomode.indexOf('y') === -1) d.yLabel = undefined; @@ -63347,8 +63764,11 @@ function hoverChanged(gd, evt, oldhoverdata) { for(var i = oldhoverdata.length - 1; i >= 0; i--) { var oldPt = oldhoverdata[i]; var newPt = gd._hoverdata[i]; + if(oldPt.curveNumber !== newPt.curveNumber || - String(oldPt.pointNumber) !== String(newPt.pointNumber)) { + String(oldPt.pointNumber) !== String(newPt.pointNumber) || + String(oldPt.pointNumbers) !== String(newPt.pointNumbers) + ) { return true; } } @@ -63364,7 +63784,7 @@ function spikesChanged(gd, oldspikepoints) { return false; } -},{"../../lib":498,"../../lib/events":489,"../../lib/override_cursor":509,"../../lib/svg_text_utils":521,"../../plots/cartesian/axes":544,"../../registry":597,"../color":376,"../dragelement":398,"../drawing":401,"./constants":413,"./helpers":415,"d3":82,"fast-isnumeric":91,"tinycolor2":342}],417:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../lib/events":486,"../../lib/override_cursor":505,"../../lib/svg_text_utils":517,"../../plots/cartesian/axes":540,"../../registry":593,"../color":375,"../dragelement":393,"../drawing":396,"./constants":408,"./helpers":410,"d3":82,"fast-isnumeric":91,"tinycolor2":341}],412:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63386,7 +63806,49 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts Lib.coerceFont(coerce, 'hoverlabel.font', opts.font); }; -},{"../../lib":498}],418:[function(_dereq_,module,exports){ +},{"../../lib":494}],413:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function(opts, extra) { + opts = opts || {}; + extra = extra || {}; + + var descPart = extra.description ? ' ' + extra.description : ''; + var keys = extra.keys || []; + if(keys.length > 0) { + var quotedKeys = []; + for(var i = 0; i < keys.length; i++) { + quotedKeys[i] = '`' + keys[i] + '`'; + } + descPart = descPart + 'Finally, the template string has access to '; + if(keys.length === 1) { + descPart = 'variable ' + quotedKeys[0]; + } else { + descPart = 'variables ' + quotedKeys.slice(0, -1).join(', ') + ' and ' + quotedKeys.slice(-1) + '.'; + } + } + + var hovertemplate = { + valType: 'string', + + dflt: '', + arrayOk: true, + editType: 'none', + + }; + + return hovertemplate; +}; + +},{}],414:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63466,7 +63928,7 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":498,"../dragelement":398,"./attributes":410,"./calc":411,"./click":412,"./constants":413,"./defaults":414,"./helpers":415,"./hover":416,"./layout_attributes":419,"./layout_defaults":420,"./layout_global_defaults":421,"d3":82}],419:[function(_dereq_,module,exports){ +},{"../../lib":494,"../dragelement":393,"./attributes":405,"./calc":406,"./click":407,"./constants":408,"./defaults":409,"./helpers":410,"./hover":411,"./layout_attributes":415,"./layout_defaults":416,"./layout_global_defaults":417,"d3":82}],415:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63499,7 +63961,7 @@ module.exports = { dragmode: { valType: 'enumerated', - values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'], + values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable', false], dflt: 'zoom', editType: 'modebar', @@ -63561,7 +64023,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":571,"./constants":413}],420:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":567,"./constants":408}],416:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63634,7 +64096,7 @@ function isHoriz(fullData) { return out; } -},{"../../lib":498,"./layout_attributes":419}],421:[function(_dereq_,module,exports){ +},{"../../lib":494,"./layout_attributes":415}],417:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63657,7 +64119,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":498,"./hoverlabel_defaults":417,"./layout_attributes":419}],422:[function(_dereq_,module,exports){ +},{"../../lib":494,"./hoverlabel_defaults":412,"./layout_attributes":415}],418:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64042,7 +64504,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":498,"../../lib/regex":513,"../../plot_api/plot_template":534,"../../plots/cartesian/constants":550,"../../plots/domain":570}],423:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../lib/regex":509,"../../plot_api/plot_template":530,"../../plots/cartesian/constants":546,"../../plots/domain":566}],419:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64177,7 +64639,7 @@ module.exports = templatedArray('image', { editType: 'arraydraw' }); -},{"../../plot_api/plot_template":534,"../../plots/cartesian/constants":550}],424:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":530,"../../plots/cartesian/constants":546}],420:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64260,7 +64722,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":523,"fast-isnumeric":91}],425:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":519,"fast-isnumeric":91}],421:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64321,7 +64783,7 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":498,"../../plots/array_container_defaults":540,"../../plots/cartesian/axes":544,"./attributes":423}],426:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plots/array_container_defaults":536,"../../plots/cartesian/axes":540,"./attributes":419}],422:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64492,9 +64954,10 @@ module.exports = function draw(gd) { yId = ya ? ya._id : '', clipAxes = xId + yId; - thisImage.call(Drawing.setClipUrl, clipAxes ? - ('clip' + fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + thisImage, + clipAxes ? ('clip' + fullLayout._uid + clipAxes) : null, + gd ); } @@ -64542,7 +65005,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":479,"../../plots/cartesian/axes":544,"../drawing":401,"d3":82}],427:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":475,"../../plots/cartesian/axes":540,"../drawing":396,"d3":82}],423:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64566,56 +65029,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":555,"./attributes":423,"./convert_coords":424,"./defaults":425,"./draw":426}],428:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - - -/** - * Determine the position anchor property of x/y xanchor/yanchor components. - * - * - values < 1/3 align the low side at that fraction, - * - values [1/3, 2/3] align the center at that fraction, - * - values > 2/3 align the right at that fraction. - */ - -exports.isRightAnchor = function isRightAnchor(opts) { - return ( - opts.xanchor === 'right' || - (opts.xanchor === 'auto' && opts.x >= 2 / 3) - ); -}; - -exports.isCenterAnchor = function isCenterAnchor(opts) { - return ( - opts.xanchor === 'center' || - (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) - ); -}; - -exports.isBottomAnchor = function isBottomAnchor(opts) { - return ( - opts.yanchor === 'bottom' || - (opts.yanchor === 'auto' && opts.y <= 1 / 3) - ); -}; - -exports.isMiddleAnchor = function isMiddleAnchor(opts) { - return ( - opts.yanchor === 'middle' || - (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) - ); -}; - -},{}],429:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":551,"./attributes":419,"./convert_coords":420,"./defaults":421,"./draw":422}],424:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64713,11 +65127,25 @@ module.exports = { editType: 'legend', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + valign: { + valType: 'enumerated', + values: ['top', 'middle', 'bottom'], + dflt: 'middle', + + editType: 'legend', + }, editType: 'legend' }; -},{"../../plots/font_attributes":571,"../color/attributes":375}],430:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":567,"../color/attributes":374}],425:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64736,7 +65164,7 @@ module.exports = { textOffsetX: 40 }; -},{}],431:[function(_dereq_,module,exports){ +},{}],426:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64805,7 +65233,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { basePlotLayoutAttributes, 'showlegend', legendReallyHasATrace && legendTraceCount > 1); - if(showLegend === false) return; + if(showLegend === false && !containerIn.uirevision) return; var containerOut = Template.newContainer(layoutOut, 'legend'); @@ -64813,6 +65241,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); } + coerce('uirevision', layoutOut.uirevision); + + if(showLegend === false) return; + coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); @@ -64821,7 +65253,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('orientation'); if(containerOut.orientation === 'h') { var xaxis = layoutIn.xaxis; - if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { + if(Registry.getComponentMethod('rangeslider', 'isVisible')(xaxis)) { defaultX = 0; defaultXAnchor = 'left'; defaultY = 1.1; @@ -64842,10 +65274,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('xanchor', defaultXAnchor); coerce('y', defaultY); coerce('yanchor', defaultYAnchor); + coerce('valign'); Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); }; -},{"../../lib":498,"../../plot_api/plot_template":534,"../../plots/layout_attributes":587,"../../registry":597,"./attributes":429,"./helpers":435}],432:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plot_api/plot_template":530,"../../plots/layout_attributes":583,"../../registry":593,"./attributes":424,"./helpers":430}],427:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64878,7 +65311,6 @@ var FROM_BR = alignmentConstants.FROM_BR; var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); -var anchorUtils = _dereq_('./anchor_utils'); var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; @@ -65002,17 +65434,17 @@ module.exports = function draw(gd) { lx = gs.l + gs.w * opts.x, ly = gs.t + gs.h * (1 - opts.y); - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= opts._width; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= opts._height; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -65072,7 +65504,7 @@ module.exports = function draw(gd) { y: opts.borderwidth }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; @@ -65110,7 +65542,7 @@ module.exports = function draw(gd) { y: opts.borderwidth + scrollBoxY }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -65187,7 +65619,7 @@ module.exports = function draw(gd) { }, doneFn: function() { if(xf !== undefined && yf !== undefined) { - Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf}); + Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf}); } }, clickFn: function(numClicks, e) { @@ -65294,7 +65726,7 @@ function drawTexts(g, gd, maxLength) { update.name = newName; } - return Registry.call('restyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, traceIndex); }); } else { textLayout(textEl); @@ -65384,6 +65816,7 @@ function computeTextDimensions(g, gd) { // to avoid getBoundingClientRect var textY = lineHeight * (0.3 + (1 - textLines) / 2); svgTextUtils.positionText(text, constants.textOffsetX, textY); + legendItem.lineHeight = lineHeight; } height = Math.max(height, 16) + 3; @@ -65547,18 +65980,18 @@ function expandMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -65578,10 +66011,10 @@ function expandHorizontalMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } @@ -65596,7 +66029,7 @@ function expandHorizontalMargin(gd) { }); } -},{"../../constants/alignment":474,"../../constants/interactions":477,"../../lib":498,"../../lib/events":489,"../../lib/svg_text_utils":521,"../../plots/plots":589,"../../registry":597,"../color":376,"../dragelement":398,"../drawing":401,"./anchor_utils":428,"./constants":430,"./get_legend_data":433,"./handle_click":434,"./helpers":435,"./style":437,"d3":82}],433:[function(_dereq_,module,exports){ +},{"../../constants/alignment":470,"../../constants/interactions":473,"../../lib":494,"../../lib/events":486,"../../lib/svg_text_utils":517,"../../plots/plots":585,"../../registry":593,"../color":375,"../dragelement":393,"../drawing":396,"./constants":425,"./get_legend_data":428,"./handle_click":429,"./helpers":430,"./style":432,"d3":82}],428:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65702,7 +66135,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":597,"./helpers":435}],434:[function(_dereq_,module,exports){ +},{"../../registry":593,"./helpers":430}],429:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65816,7 +66249,7 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices); + Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices); } else { var hasLegendgroup = legendgroup && legendgroup.length; var traceIndicesInGroup = []; @@ -65922,11 +66355,11 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', gd, attrUpdate, attrIndices); + Registry.call('_guiRestyle', gd, attrUpdate, attrIndices); } }; -},{"../../lib":498,"../../registry":597}],435:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../registry":593}],430:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65950,7 +66383,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],436:[function(_dereq_,module,exports){ +},{}],431:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65974,7 +66407,7 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":429,"./defaults":431,"./draw":432,"./style":437}],437:[function(_dereq_,module,exports){ +},{"./attributes":424,"./defaults":426,"./draw":427,"./style":432}],432:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66002,6 +66435,19 @@ module.exports = function style(s, gd) { var layers = Lib.ensureSingle(traceGroup, 'g', 'layers'); layers.style('opacity', d[0].trace.opacity); + // Marker vertical alignment + var valign = gd._fullLayout.legend.valign; + var lineHeight = d[0].lineHeight; + var height = d[0].height; + + if(valign === 'middle' || !lineHeight || !height) { + layers.attr('transform', null); // this here is a fun d3 trick to unset DOM attributes + } else { + var factor = {top: 1, bottom: -1}[valign]; + var markerOffsetY = factor * (0.5 * (lineHeight - height + 3)); + layers.attr('transform', 'translate(0,' + markerOffsetY + ')'); + } + var fill = layers .selectAll('g.legendfill') .data([d]); @@ -66321,7 +66767,7 @@ module.exports = function style(s, gd) { } }; -},{"../../lib":498,"../../registry":597,"../../traces/pie/style_one":617,"../../traces/scatter/subtypes":643,"../color":376,"../drawing":401,"d3":82}],438:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../registry":593,"../../traces/pie/style_one":613,"../../traces/scatter/subtypes":639,"../color":375,"../drawing":396,"d3":82}],433:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66585,7 +67031,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -66641,7 +67087,7 @@ function handleDrag3d(gd, ev) { var val2d = (val === 'pan') ? val : 'zoom'; layoutUpdate.dragmode = val2d; - Registry.call('relayout', gd, layoutUpdate); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.resetCameraDefault3d = { @@ -66680,7 +67126,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -66694,54 +67140,48 @@ modeBarButtons.hoverClosest3d = { click: handleHover3d }; -function handleHover3d(gd, ev) { +function getNextHover3d(gd, ev) { var button = ev.currentTarget; - var val = button._previousVal || false; - var layout = gd.layout; + var val = button._previousVal; var fullLayout = gd._fullLayout; var sceneIds = fullLayout._subplots.gl3d; var axes = ['xaxis', 'yaxis', 'zaxis']; - var spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor']; // initialize 'current spike' object to be stored in the DOM var currentSpikes = {}; - var axisSpikes = {}; var layoutUpdate = {}; if(val) { - layoutUpdate = Lib.extendDeep(layout, val); + layoutUpdate = val; button._previousVal = null; } else { - layoutUpdate = { - 'allaxes.showspikes': false - }; - for(var i = 0; i < sceneIds.length; i++) { - var sceneId = sceneIds[i], - sceneLayout = fullLayout[sceneId], - sceneSpikes = currentSpikes[sceneId] = {}; + var sceneId = sceneIds[i]; + var sceneLayout = fullLayout[sceneId]; - sceneSpikes.hovermode = sceneLayout.hovermode; - layoutUpdate[sceneId + '.hovermode'] = false; + var hovermodeAStr = sceneId + '.hovermode'; + currentSpikes[hovermodeAStr] = sceneLayout.hovermode; + layoutUpdate[hovermodeAStr] = false; // copy all the current spike attrs for(var j = 0; j < 3; j++) { var axis = axes[j]; - axisSpikes = sceneSpikes[axis] = {}; - - for(var k = 0; k < spikeAttrs.length; k++) { - var spikeAttr = spikeAttrs[k]; - axisSpikes[spikeAttr] = sceneLayout[axis][spikeAttr]; - } + var spikeAStr = sceneId + '.' + axis + '.showspikes'; + layoutUpdate[spikeAStr] = false; + currentSpikes[spikeAStr] = sceneLayout[axis].showspikes; } } - button._previousVal = Lib.extendDeep({}, currentSpikes); + button._previousVal = currentSpikes; } + return layoutUpdate; +} - Registry.call('relayout', gd, layoutUpdate); +function handleHover3d(gd, ev) { + var layoutUpdate = getNextHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.zoomInGeo = { @@ -66797,7 +67237,7 @@ function handleGeo(gd, ev) { var scale = geoLayout.projection.scale; var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; - Registry.call('relayout', gd, id + '.projection.scale', newScale); + Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); } else if(attr === 'reset') { resetView(gd, 'geo'); } @@ -66825,18 +67265,20 @@ modeBarButtons.hoverClosestPie = { click: toggleHover }; -function toggleHover(gd) { +function getNextHover(gd) { var fullLayout = gd._fullLayout; - var onHoverVal; + if(fullLayout.hovermode) return false; + if(fullLayout._has('cartesian')) { - onHoverVal = fullLayout._isHoriz ? 'y' : 'x'; + return fullLayout._isHoriz ? 'y' : 'x'; } - else onHoverVal = 'closest'; - - var newHover = gd._fullLayout.hovermode ? false : onHoverVal; + return 'closest'; +} - Registry.call('relayout', gd, 'hovermode', newHover); +function toggleHover(gd) { + var newHover = getNextHover(gd); + Registry.call('_guiRelayout', gd, 'hovermode', newHover); } // buttons when more then one plot types are present @@ -66850,12 +67292,10 @@ modeBarButtons.toggleHover = { icon: Icons.tooltip_basic, gravity: 'ne', click: function(gd, ev) { - toggleHover(gd); + var layoutUpdate = getNextHover3d(gd, ev); + layoutUpdate.hovermode = getNextHover(gd); - // the 3d hovermode update must come - // last so that layout.hovermode update does not - // override scene?.hovermode?.layout. - handleHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } }; @@ -66891,7 +67331,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } }; @@ -66938,10 +67378,10 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', gd, aObj); + Registry.call('_guiRelayout', gd, aObj); } -},{"../../../build/ploticon":2,"../../lib":498,"../../plots/cartesian/axis_ids":547,"../../plots/plots":589,"../../registry":597}],439:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":494,"../../plots/cartesian/axis_ids":543,"../../plots/plots":585,"../../registry":593}],434:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66955,7 +67395,7 @@ function resetView(gd, subplotType) { exports.manage = _dereq_('./manage'); -},{"./manage":440}],440:[function(_dereq_,module,exports){ +},{"./manage":435}],435:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66987,7 +67427,7 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar) { + if(!context.displayModeBar && !context.watermark) { if(modeBar) { modeBar.destroy(); delete fullLayout._modeBar; @@ -67015,11 +67455,15 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); } + else if(!context.displayModeBar && context.watermark) { + buttonGroups = []; + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, - context.modeBarButtonsToAdd + context.modeBarButtonsToAdd, + context.showSendToCloud ); } @@ -67028,7 +67472,7 @@ module.exports = function manageModeBar(gd) { }; // logic behind which buttons are displayed by default -function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { +function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; @@ -67059,7 +67503,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { } // buttons common to all plot types - addGroup(['toImage', 'sendDataToCloud']); + var commonGroup = ['toImage']; + if(showSendToCloud) commonGroup.push('sendDataToCloud'); + addGroup(commonGroup); var zoomGroup = []; var hoverGroup = []; @@ -67210,7 +67656,7 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":547,"../../registry":597,"../../traces/scatter/subtypes":643,"./buttons":438,"./modebar":441}],441:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axis_ids":543,"../../registry":593,"../../traces/scatter/subtypes":639,"./buttons":433,"./modebar":436}],436:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67293,11 +67739,16 @@ proto.update = function(graphInfo, buttons) { this.updateButtons(buttons); - if(context.displaylogo) { + if(context.watermark || context.displaylogo) { + var logoGroup = this.getLogo(); + if(context.watermark) { + logoGroup.className = logoGroup.className + ' watermark'; + } + if(fullLayout.modebar.orientation === 'v') { - this.element.prepend(this.getLogo()); + this.element.prepend(logoGroup); } else { - this.element.appendChild(this.getLogo()); + this.element.appendChild(logoGroup); } this.hasLogo = true; @@ -67556,7 +68007,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../../build/ploticon":2,"../../lib":498,"d3":82,"fast-isnumeric":91}],442:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":494,"d3":82,"fast-isnumeric":91}],437:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67692,7 +68143,7 @@ module.exports = { editType: 'plot' }; -},{"../../plot_api/plot_template":534,"../../plots/font_attributes":571,"../color/attributes":375}],443:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":530,"../../plots/font_attributes":567,"../color/attributes":374}],438:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67721,7 +68172,7 @@ module.exports = { darkAmount: 10 }; -},{}],444:[function(_dereq_,module,exports){ +},{}],439:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67814,7 +68265,7 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":498,"../../plot_api/plot_template":534,"../../plots/array_container_defaults":540,"../color":376,"./attributes":442,"./constants":443}],445:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plot_api/plot_template":530,"../../plots/array_container_defaults":536,"../color":375,"./attributes":437,"./constants":438}],440:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67834,7 +68285,6 @@ var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var alignmentConstants = _dereq_('../../constants/alignment'); var LINE_SPACING = alignmentConstants.LINE_SPACING; @@ -67886,7 +68336,7 @@ module.exports = function draw(gd) { button.on('click', function() { if(gd._dragged) return; - Registry.call('relayout', gd, update); + Registry.call('_guiRelayout', gd, update); }); button.on('mouseover', function() { @@ -68035,21 +68485,21 @@ function reposition(gd, buttons, opts, axName, selector) { var ly = graphSize.t + graphSize.h * (1 - opts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= width; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(opts)) { + if(Lib.isCenterAnchor(opts)) { lx -= width / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(opts)) { + if(Lib.isMiddleAnchor(opts)) { ly -= height / 2; yanchor = 'middle'; } @@ -68071,7 +68521,7 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', 'translate(' + lx + ',' + ly + ')'); } -},{"../../constants/alignment":474,"../../lib":498,"../../lib/svg_text_utils":521,"../../plots/cartesian/axis_ids":547,"../../plots/plots":589,"../../registry":597,"../color":376,"../drawing":401,"../legend/anchor_utils":428,"./constants":443,"./get_update_object":446,"d3":82}],446:[function(_dereq_,module,exports){ +},{"../../constants/alignment":470,"../../lib":494,"../../lib/svg_text_utils":517,"../../plots/cartesian/axis_ids":543,"../../plots/plots":585,"../../registry":593,"../color":375,"../drawing":396,"./constants":438,"./get_update_object":441,"d3":82}],441:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68128,7 +68578,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":82}],447:[function(_dereq_,module,exports){ +},{"d3":82}],442:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68155,7 +68605,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":442,"./defaults":444,"./draw":445}],448:[function(_dereq_,module,exports){ +},{"./attributes":437,"./defaults":439,"./draw":440}],443:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68229,7 +68679,7 @@ module.exports = { editType: 'calc' }; -},{"../color/attributes":375}],449:[function(_dereq_,module,exports){ +},{"../color/attributes":374}],444:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68263,7 +68713,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":543,"../../plots/cartesian/axis_ids":547,"./constants":450}],450:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/autorange":539,"../../plots/cartesian/axis_ids":543,"./constants":445}],445:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68319,7 +68769,7 @@ module.exports = { extraPad: 15 }; -},{}],451:[function(_dereq_,module,exports){ +},{}],446:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68405,7 +68855,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":498,"../../plot_api/plot_template":534,"../../plots/cartesian/axis_ids":547,"./attributes":448,"./oppaxis_attributes":454}],452:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plot_api/plot_template":530,"../../plots/cartesian/axis_ids":543,"./attributes":443,"./oppaxis_attributes":450}],447:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68427,7 +68877,7 @@ var Color = _dereq_('../color'); var Titles = _dereq_('../titles'); var Cartesian = _dereq_('../../plots/cartesian'); -var Axes = _dereq_('../../plots/cartesian/axes'); +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); var dragElement = _dereq_('../dragelement'); var setCursor = _dereq_('../../lib/setcursor'); @@ -68435,8 +68885,13 @@ var setCursor = _dereq_('../../lib/setcursor'); var constants = _dereq_('./constants'); module.exports = function(gd) { - var fullLayout = gd._fullLayout, - rangeSliderData = makeRangeSliderData(fullLayout); + var fullLayout = gd._fullLayout; + var rangeSliderData = fullLayout._rangeSliderData; + for(var i = 0; i < rangeSliderData.length; i++) { + var opts = rangeSliderData[i][constants.name]; + // fullLayout._uid may not exist when we call makeData + opts._clipId = opts._id + '-' + fullLayout._uid; + } /* * @@ -68463,10 +68918,6 @@ module.exports = function(gd) { .selectAll('g.' + constants.containerClassName) .data(rangeSliderData, keyFunction); - rangeSliders.enter().append('g') - .classed(constants.containerClassName, true) - .attr('pointer-events', 'all'); - // remove exiting sliders and their corresponding clip paths rangeSliders.exit().each(function(axisOpts) { var opts = axisOpts[constants.name]; @@ -68476,48 +68927,51 @@ module.exports = function(gd) { // return early if no range slider is visible if(rangeSliderData.length === 0) return; + rangeSliders.enter().append('g') + .classed(constants.containerClassName, true) + .attr('pointer-events', 'all'); + // for all present range sliders rangeSliders.each(function(axisOpts) { - var rangeSlider = d3.select(this), - opts = axisOpts[constants.name], - oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)], - oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)]; + var rangeSlider = d3.select(this); + var opts = axisOpts[constants.name]; + var oppAxisOpts = fullLayout[axisIDs.id2name(axisOpts.anchor)]; + var oppAxisRangeOpts = opts[axisIDs.id2name(axisOpts.anchor)]; // update range // Expand slider range to the axis range - // TODO: what if the ranges are reversed? if(opts.range) { - var outRange = opts.range; - var axRange = axisOpts.range; + var rng = Lib.simpleMap(opts.range, axisOpts.r2l); + var axRng = Lib.simpleMap(axisOpts.range, axisOpts.r2l); + var newRng; + + if(axRng[0] < axRng[1]) { + newRng = [ + Math.min(rng[0], axRng[0]), + Math.max(rng[1], axRng[1]) + ]; + } else { + newRng = [ + Math.max(rng[0], axRng[0]), + Math.min(rng[1], axRng[1]) + ]; + } - outRange[0] = axisOpts.l2r(Math.min(axisOpts.r2l(outRange[0]), axisOpts.r2l(axRange[0]))); - outRange[1] = axisOpts.l2r(Math.max(axisOpts.r2l(outRange[1]), axisOpts.r2l(axRange[1]))); - opts._input.range = outRange.slice(); + opts.range = opts._input.range = Lib.simpleMap(newRng, axisOpts.l2r); } axisOpts.cleanRange('rangeslider.range'); - // update range slider dimensions var margin = fullLayout.margin; var graphSize = fullLayout._size; var domain = axisOpts.domain; - var tickHeight = (axisOpts._boundingBox || {}).height || 0; - - var oppBottom = Infinity; - var subplotData = Axes.getSubplots(gd, axisOpts); - for(var i = 0; i < subplotData.length; i++) { - var oppAxis = Axes.getFromId(gd, subplotData[i].substr(subplotData[i].indexOf('y'))); - oppBottom = Math.min(oppBottom, oppAxis.domain[0]); - } + var tickHeight = opts._tickHeight; - opts._id = constants.name + axisOpts._id; - opts._clipId = opts._id + '-' + fullLayout._uid; + var oppBottom = opts._oppBottom; opts._width = graphSize.w * (domain[1] - domain[0]); - opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; - opts._offsetShift = Math.floor(opts.borderwidth / 2); var x = Math.round(margin.l + (graphSize.w * domain[0])); @@ -68580,41 +69034,14 @@ module.exports = function(gd) { placeholder: fullLayout._dfltTitle.x, attributes: { x: axisOpts._offset + axisOpts._length / 2, - y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size, + y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.title.font.size, 'text-anchor': 'middle' } }); } - - // update margins - Plots.autoMargin(gd, opts._id, { - x: domain[0], - y: oppBottom, - l: 0, - r: 0, - t: 0, - b: opts._height + margin.b + tickHeight, - pad: constants.extraPad + opts._offsetShift * 2 - }); }); }; -function makeRangeSliderData(fullLayout) { - var axes = Axes.list({ _fullLayout: fullLayout }, 'x', true), - name = constants.name, - out = []; - - if(fullLayout._has('gl2d')) return out; - - for(var i = 0; i < axes.length; i++) { - var ax = axes[i]; - - if(ax[name] && ax[name].visible) out.push(ax); - } - - return out; -} - function setupDragElement(rangeSlider, gd, axisOpts, opts) { var slideBox = rangeSlider.select('rect.' + constants.slideBoxClassName).node(), grabAreaMin = rangeSlider.select('rect.' + constants.grabAreaMinClassName).node(), @@ -68694,7 +69121,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) { dataMax = clamp(opts.p2d(opts._pixelMax)); window.requestAnimationFrame(function() { - Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); + Registry.call('_guiRelayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); }); } @@ -68801,15 +69228,14 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) { } function drawRangePlot(rangeSlider, gd, axisOpts, opts) { - var subplotData = Axes.getSubplots(gd, axisOpts), - calcData = gd.calcdata; + var calcData = gd.calcdata; var rangePlots = rangeSlider.selectAll('g.' + constants.rangePlotClassName) - .data(subplotData, Lib.identity); + .data(axisOpts._subplotsWith, Lib.identity); rangePlots.enter().append('g') .attr('class', function(id) { return constants.rangePlotClassName + ' ' + id; }) - .call(Drawing.setClipUrl, opts._clipId); + .call(Drawing.setClipUrl, opts._clipId, gd); rangePlots.order(); @@ -68821,7 +69247,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var plotgroup = d3.select(this), isMainPlot = (i === 0); - var oppAxisOpts = Axes.getFromId(gd, id, 'y'), + var oppAxisOpts = axisIDs.getFromId(gd, id, 'y'), oppAxisName = oppAxisOpts._name, oppAxisRangeOpts = opts[oppAxisName]; @@ -68853,6 +69279,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var xa = mockFigure._fullLayout.xaxis; var ya = mockFigure._fullLayout[oppAxisName]; + xa.clearCalc(); + xa.setScale(); + ya.clearCalc(); + ya.setScale(); + var plotinfo = { id: id, plotgroup: plotgroup, @@ -69005,7 +69436,77 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":498,"../../lib/setcursor":517,"../../plots/cartesian":556,"../../plots/cartesian/axes":544,"../../plots/plots":589,"../../registry":597,"../color":376,"../dragelement":398,"../drawing":401,"../titles":467,"./constants":450,"d3":82}],453:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../lib/setcursor":513,"../../plots/cartesian":552,"../../plots/cartesian/axis_ids":543,"../../plots/plots":585,"../../registry":593,"../color":375,"../dragelement":393,"../drawing":396,"../titles":463,"./constants":445,"d3":82}],448:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); +var constants = _dereq_('./constants'); +var name = constants.name; + +function isVisible(ax) { + var rangeSlider = ax && ax[name]; + return rangeSlider && rangeSlider.visible; +} +exports.isVisible = isVisible; + +exports.makeData = function(fullLayout) { + var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true); + var margin = fullLayout.margin; + var rangeSliderData = []; + + if(!fullLayout._has('gl2d')) { + for(var i = 0; i < axes.length; i++) { + var ax = axes[i]; + + if(isVisible(ax)) { + rangeSliderData.push(ax); + + var opts = ax[name]; + opts._id = name + ax._id; + opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; + opts._offsetShift = Math.floor(opts.borderwidth / 2); + } + } + } + + fullLayout._rangeSliderData = rangeSliderData; +}; + +exports.autoMarginOpts = function(gd, ax) { + var opts = ax[name]; + + var oppBottom = Infinity; + var counterAxes = ax._counterAxes; + for(var j = 0; j < counterAxes.length; j++) { + var counterId = counterAxes[j]; + var oppAxis = axisIDs.getFromId(gd, counterId); + oppBottom = Math.min(oppBottom, oppAxis.domain[0]); + } + opts._oppBottom = oppBottom; + + var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0; + opts._tickHeight = tickHeight; + + return { + x: 0, + y: oppBottom, + l: 0, + r: 0, + t: 0, + b: opts._height + gd._fullLayout.margin.b + tickHeight, + pad: constants.extraPad + opts._offsetShift * 2 + }; +}; + +},{"../../plots/cartesian/axis_ids":543,"./constants":445}],449:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69019,6 +69520,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { var Lib = _dereq_('../../lib'); var attrs = _dereq_('./attributes'); var oppAxisAttrs = _dereq_('./oppaxis_attributes'); +var helpers = _dereq_('./helpers'); module.exports = { moduleType: 'component', @@ -69037,10 +69539,13 @@ module.exports = { layoutAttributes: _dereq_('./attributes'), handleDefaults: _dereq_('./defaults'), calcAutorange: _dereq_('./calc_autorange'), - draw: _dereq_('./draw') + draw: _dereq_('./draw'), + isVisible: helpers.isVisible, + makeData: helpers.makeData, + autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":498,"./attributes":448,"./calc_autorange":449,"./defaults":451,"./draw":452,"./oppaxis_attributes":454}],454:[function(_dereq_,module,exports){ +},{"../../lib":494,"./attributes":443,"./calc_autorange":444,"./defaults":446,"./draw":447,"./helpers":448,"./oppaxis_attributes":450}],450:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69078,7 +69583,7 @@ module.exports = { editType: 'calc' }; -},{}],455:[function(_dereq_,module,exports){ +},{}],451:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69214,7 +69719,7 @@ module.exports = templatedArray('shape', { editType: 'arraydraw' }); -},{"../../lib/extend":490,"../../plot_api/plot_template":534,"../../traces/scatter/attributes":619,"../annotations/attributes":361,"../drawing/attributes":400}],456:[function(_dereq_,module,exports){ +},{"../../lib/extend":487,"../../plot_api/plot_template":530,"../../traces/scatter/attributes":615,"../annotations/attributes":360,"../drawing/attributes":395}],452:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69223,7 +69728,6 @@ module.exports = templatedArray('shape', { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); @@ -69301,7 +69805,7 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { } function shapeBounds(ax, v0, v1, path, paramsToUse) { - var convertVal = (ax.type === 'category') ? ax.r2c : ax.d2c; + var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; if(!path) return; @@ -69332,7 +69836,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":498,"../../plots/cartesian/axes":544,"./constants":457,"./helpers":460}],457:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plots/cartesian/axes":540,"./constants":453,"./helpers":456}],453:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69396,7 +69900,7 @@ module.exports = { } }; -},{}],458:[function(_dereq_,module,exports){ +},{}],454:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69521,7 +70025,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":498,"../../plots/array_container_defaults":540,"../../plots/cartesian/axes":544,"./attributes":455,"./helpers":460}],459:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plots/array_container_defaults":536,"../../plots/cartesian/axes":540,"./attributes":451,"./helpers":456}],455:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -69644,9 +70148,10 @@ function setClipPath(shapePath, gd, shapeOptions) { // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 var clipAxes = (shapeOptions.xref + shapeOptions.yref).replace(/paper/g, ''); - shapePath.call(Drawing.setClipUrl, clipAxes ? - ('clip' + gd._fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } @@ -69830,7 +70335,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { // Don't rely on clipPath being activated during re-layout setClipPath(shapePath, gd, shapeOptions); - Registry.call('relayout', gd, editHelpers.getUpdateObj()); + Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj()); } function abortDrag() { @@ -70017,9 +70522,10 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(xref !== 'paper' && !xa.autorange) clipAxes += xref; if(yref !== 'paper' && !ya.autorange) clipAxes += yref; - shapePath.call(Drawing.setClipUrl, clipAxes ? - 'clip' + gd._fullLayout._uid + clipAxes : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } } @@ -70151,7 +70657,7 @@ function movePath(pathIn, moveX, moveY) { }); } -},{"../../lib":498,"../../lib/setcursor":517,"../../plot_api/plot_template":534,"../../plots/cartesian/axes":544,"../../registry":597,"../color":376,"../dragelement":398,"../drawing":401,"./constants":457,"./helpers":460}],460:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../lib/setcursor":513,"../../plot_api/plot_template":530,"../../plots/cartesian/axes":540,"../../registry":593,"../color":375,"../dragelement":393,"../drawing":396,"./constants":453,"./helpers":456}],456:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70276,7 +70782,7 @@ exports.roundPositionForSharpStrokeRendering = function(pos, strokeWidth) { return strokeWidthIsOdd ? posValAsInt + 0.5 : posValAsInt; }; -},{"../../lib":498,"./constants":457}],461:[function(_dereq_,module,exports){ +},{"../../lib":494,"./constants":453}],457:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70303,7 +70809,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":555,"./attributes":455,"./calc_autorange":456,"./defaults":458,"./draw":459}],462:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":551,"./attributes":451,"./calc_autorange":452,"./defaults":454,"./draw":455}],458:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70405,7 +70911,7 @@ module.exports = overrideAll(templatedArray('slider', { }, - pad: extendDeepAll({}, padAttrs, { + pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { }, {t: {dflt: 20}}), xanchor: { @@ -70546,7 +71052,7 @@ module.exports = overrideAll(templatedArray('slider', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":490,"../../plot_api/edit_types":527,"../../plot_api/plot_template":534,"../../plots/animation_attributes":539,"../../plots/font_attributes":571,"../../plots/pad_attributes":588,"./constants":463}],463:[function(_dereq_,module,exports){ +},{"../../lib/extend":487,"../../plot_api/edit_types":523,"../../plot_api/plot_template":530,"../../plots/animation_attributes":535,"../../plots/font_attributes":567,"../../plots/pad_attributes":584,"./constants":459}],459:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70640,7 +71146,7 @@ module.exports = { currentValueInset: 0, }; -},{}],464:[function(_dereq_,module,exports){ +},{}],460:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70757,7 +71263,7 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":498,"../../plots/array_container_defaults":540,"./attributes":462,"./constants":463}],465:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plots/array_container_defaults":536,"./attributes":458,"./constants":459}],461:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -70775,7 +71281,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var constants = _dereq_('./constants'); @@ -70967,21 +71472,21 @@ function findDimensions(gd, sliderOpts) { dims.height = dims.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + dims.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(sliderOpts)) { + if(Lib.isRightAnchor(sliderOpts)) { dims.lx -= dims.outerLength; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(sliderOpts)) { + if(Lib.isCenterAnchor(sliderOpts)) { dims.lx -= dims.outerLength / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(sliderOpts)) { + if(Lib.isBottomAnchor(sliderOpts)) { dims.ly -= dims.height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(sliderOpts)) { + if(Lib.isMiddleAnchor(sliderOpts)) { dims.ly -= dims.height / 2; yanchor = 'middle'; } @@ -71388,7 +71893,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":474,"../../lib":498,"../../lib/svg_text_utils":521,"../../plot_api/plot_template":534,"../../plots/plots":589,"../color":376,"../drawing":401,"../legend/anchor_utils":428,"./constants":463,"d3":82}],466:[function(_dereq_,module,exports){ +},{"../../constants/alignment":470,"../../lib":494,"../../lib/svg_text_utils":517,"../../plot_api/plot_template":530,"../../plots/plots":585,"../color":375,"../drawing":396,"./constants":459,"d3":82}],462:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71411,7 +71916,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":462,"./constants":463,"./defaults":464,"./draw":465}],467:[function(_dereq_,module,exports){ +},{"./attributes":458,"./constants":459,"./defaults":460,"./draw":461}],463:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71481,19 +71986,21 @@ function draw(gd, titleClass, options) { var group = options.containerGroup; var fullLayout = gd._fullLayout; - var titlefont = cont.titlefont || {}; - var font = titlefont.family; - var fontSize = titlefont.size; - var fontColor = titlefont.color; var opacity = 1; var isplaceholder = false; - var txt = (cont.title || '').trim(); + var title = cont.title; + var txt = (title && title.text ? title.text : '').trim(); + + var font = title && title.font ? title.font : {}; + var fontFamily = font.family; + var fontSize = font.size; + var fontColor = font.color; // only make this title editable if we positively identify its property // as one that has editing enabled. var editAttr; - if(prop === 'title') editAttr = 'titleText'; + if(prop === 'title.text') editAttr = 'titleText'; else if(prop.indexOf('axis') !== -1) editAttr = 'axisTitleText'; else if(prop.indexOf('colorbar' !== -1)) editAttr = 'colorbarTitleText'; var editable = gd._context.edits[editAttr]; @@ -71551,7 +72058,7 @@ function draw(gd, titleClass, options) { titleEl.attr('transform', transformVal); titleEl.style({ - 'font-family': font, + 'font-family': fontFamily, 'font-size': d3.round(fontSize, 2) + 'px', fill: Color.rgb(fontColor), opacity: opacity * Color.opacity(fontColor), @@ -71651,9 +72158,9 @@ function draw(gd, titleClass, options) { el.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { if(traceIndex !== undefined) { - Registry.call('restyle', gd, prop, text, traceIndex); + Registry.call('_guiRestyle', gd, prop, text, traceIndex); } else { - Registry.call('relayout', gd, prop, text); + Registry.call('_guiRelayout', gd, prop, text); } }) .on('cancel', function() { @@ -71670,7 +72177,7 @@ function draw(gd, titleClass, options) { return group; } -},{"../../constants/interactions":477,"../../lib":498,"../../lib/svg_text_utils":521,"../../plots/plots":589,"../../registry":597,"../color":376,"../drawing":401,"d3":82,"fast-isnumeric":91}],468:[function(_dereq_,module,exports){ +},{"../../constants/interactions":473,"../../lib":494,"../../lib/svg_text_utils":517,"../../plots/plots":585,"../../registry":593,"../color":375,"../drawing":396,"d3":82,"fast-isnumeric":91}],464:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71799,7 +72306,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { }, - pad: extendFlat({}, padAttrs, { + pad: extendFlat(padAttrs({editType: 'arraydraw'}), { }), @@ -71828,7 +72335,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":490,"../../plot_api/edit_types":527,"../../plot_api/plot_template":534,"../../plots/font_attributes":571,"../../plots/pad_attributes":588,"../color/attributes":375}],469:[function(_dereq_,module,exports){ +},{"../../lib/extend":487,"../../plot_api/edit_types":523,"../../plot_api/plot_template":530,"../../plots/font_attributes":567,"../../plots/pad_attributes":584,"../color/attributes":374}],465:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71909,7 +72416,7 @@ module.exports = { } }; -},{}],470:[function(_dereq_,module,exports){ +},{}],466:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -71992,7 +72499,7 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":498,"../../plots/array_container_defaults":540,"./attributes":468,"./constants":469}],471:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../plots/array_container_defaults":536,"./attributes":464,"./constants":465}],467:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72011,7 +72518,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var LINE_SPACING = _dereq_('../../constants/alignment').LINE_SPACING; @@ -72561,21 +73067,21 @@ function findDimensions(gd, menuOpts) { dims.ly = graphSize.t + graphSize.h * (1 - menuOpts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(menuOpts)) { + if(Lib.isRightAnchor(menuOpts)) { dims.lx -= paddedWidth; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(menuOpts)) { + if(Lib.isCenterAnchor(menuOpts)) { dims.lx -= paddedWidth / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(menuOpts)) { + if(Lib.isBottomAnchor(menuOpts)) { dims.ly -= paddedHeight; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(menuOpts)) { + if(Lib.isMiddleAnchor(menuOpts)) { dims.ly -= paddedHeight / 2; yanchor = 'middle'; } @@ -72642,9 +73148,9 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":474,"../../lib":498,"../../lib/svg_text_utils":521,"../../plot_api/plot_template":534,"../../plots/plots":589,"../color":376,"../drawing":401,"../legend/anchor_utils":428,"./constants":469,"./scrollbox":473,"d3":82}],472:[function(_dereq_,module,exports){ -arguments[4][466][0].apply(exports,arguments) -},{"./attributes":468,"./constants":469,"./defaults":470,"./draw":471,"dup":466}],473:[function(_dereq_,module,exports){ +},{"../../constants/alignment":470,"../../lib":494,"../../lib/svg_text_utils":517,"../../plot_api/plot_template":530,"../../plots/plots":585,"../color":375,"../drawing":396,"./constants":465,"./scrollbox":469,"d3":82}],468:[function(_dereq_,module,exports){ +arguments[4][462][0].apply(exports,arguments) +},{"./attributes":464,"./constants":465,"./defaults":466,"./draw":467,"dup":462}],469:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -72901,7 +73407,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { height: Math.ceil(clipB) - Math.floor(clipT) }); - this.container.call(Drawing.setClipUrl, clipId); + this.container.call(Drawing.setClipUrl, clipId, this.gd); this.bg.attr({ x: l, @@ -73115,7 +73621,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":498,"../color":376,"../drawing":401,"d3":82}],474:[function(_dereq_,module,exports){ +},{"../../lib":494,"../color":375,"../drawing":396,"d3":82}],470:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73159,12 +73665,17 @@ module.exports = { // multiple of fontSize to get the vertical offset between lines LINE_SPACING: 1.3, - // multiple of fontSize to shift from the baseline to the midline + // multiple of fontSize to shift from the baseline + // to the cap (captical letter) line // (to use when we don't calculate this shift from Drawing.bBox) - // To be precise this should be half the cap height (capital letter) - // of the font, and according to wikipedia: + // This is an approximation since in reality cap height can differ + // from font to font. However, according to Wikipedia // an "average" font might have a cap height of 70% of the em // https://en.wikipedia.org/wiki/Em_(typography)#History + CAP_SHIFT: 0.70, + + // half the cap height (distance between baseline and cap line) + // of an "average" font (for more info see above). MID_SHIFT: 0.35, OPPOSITE_SIDE: { @@ -73175,7 +73686,7 @@ module.exports = { } }; -},{}],475:[function(_dereq_,module,exports){ +},{}],471:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73196,7 +73707,7 @@ module.exports = { longdashdot: [[0.5, 0.7, 0.8, 1], 10] }; -},{}],476:[function(_dereq_,module,exports){ +},{}],472:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73219,7 +73730,7 @@ module.exports = { x: '❌' }; -},{}],477:[function(_dereq_,module,exports){ +},{}],473:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73246,7 +73757,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],478:[function(_dereq_,module,exports){ +},{}],474:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73311,7 +73822,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],479:[function(_dereq_,module,exports){ +},{}],475:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73335,7 +73846,7 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],480:[function(_dereq_,module,exports){ +},{}],476:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73347,7 +73858,7 @@ exports.svgAttrs = { 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.42.5'; +exports.version = '1.43.0'; // inject promise polyfill _dereq_('es6-promise').polyfill(); @@ -73356,7 +73867,7 @@ _dereq_('es6-promise').polyfill(); _dereq_('../build/plotcss'); // inject default MathJax config -_dereq_('./fonts/mathjax_config'); +_dereq_('./fonts/mathjax_config')(); // include registry module and expose register method var Registry = _dereq_('./registry'); @@ -73367,7 +73878,8 @@ var plotApi = _dereq_('./plot_api'); var methodNames = Object.keys(plotApi); for(var i = 0; i < methodNames.length; i++) { var name = methodNames[i]; - exports[name] = plotApi[name]; + // _ -> private API methods, but still registered for internal use + if(name.charAt(0) !== '_') exports[name] = plotApi[name]; register({ moduleType: 'apiMethod', name: name, @@ -73391,7 +73903,8 @@ register([ _dereq_('./components/rangeslider'), _dereq_('./components/rangeselector'), _dereq_('./components/grid'), - _dereq_('./components/errorbars') + _dereq_('./components/errorbars'), + _dereq_('./components/colorscale') ]); // locales en and en-US are required for default behavior @@ -73413,7 +73926,7 @@ exports.Queue = _dereq_('./lib/queue'); // export d3 used in the bundle exports.d3 = _dereq_('d3'); -},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":369,"./components/annotations3d":374,"./components/errorbars":407,"./components/fx":418,"./components/grid":422,"./components/images":427,"./components/legend":436,"./components/rangeselector":447,"./components/rangeslider":453,"./components/shapes":461,"./components/sliders":466,"./components/updatemenus":472,"./fonts/mathjax_config":481,"./lib/queue":512,"./locale-en":525,"./locale-en-us":524,"./plot_api":529,"./plot_api/plot_schema":533,"./plots/plots":589,"./registry":597,"./snapshot":602,"./traces/scatter":631,"d3":82,"es6-promise":89}],481:[function(_dereq_,module,exports){ +},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":368,"./components/annotations3d":373,"./components/colorscale":387,"./components/errorbars":402,"./components/fx":414,"./components/grid":418,"./components/images":423,"./components/legend":431,"./components/rangeselector":442,"./components/rangeslider":449,"./components/shapes":457,"./components/sliders":462,"./components/updatemenus":468,"./fonts/mathjax_config":477,"./lib/queue":508,"./locale-en":521,"./locale-en-us":520,"./plot_api":525,"./plot_api/plot_schema":529,"./plots/plots":585,"./registry":593,"./snapshot":598,"./traces/scatter":627,"d3":82,"es6-promise":89}],477:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73426,31 +73939,89 @@ exports.d3 = _dereq_('d3'); /* global MathJax:false */ +module.exports = function() { + if(typeof MathJax !== 'undefined') { + var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; + + if(globalConfig) { + MathJax.Hub.Config({ + messageStyle: 'none', + skipStartupTypeset: true, + displayAlign: 'left', + tex2jax: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + } + }); + MathJax.Hub.Configured(); + } + } +}; + +},{}],478:[function(_dereq_,module,exports){ /** - * Check and configure MathJax +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + + +/** + * Determine the position anchor property of x/y xanchor/yanchor components. + * + * - values < 1/3 align the low side at that fraction, + * - values [1/3, 2/3] align the center at that fraction, + * - values > 2/3 align the right at that fraction. */ -if(typeof MathJax !== 'undefined') { - exports.MathJax = true; - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } +exports.isLeftAnchor = function isLeftAnchor(opts) { + return ( + opts.xanchor === 'left' || + (opts.xanchor === 'auto' && opts.x <= 1 / 3) + ); +}; -} else { - exports.MathJax = false; -} +exports.isCenterAnchor = function isCenterAnchor(opts) { + return ( + opts.xanchor === 'center' || + (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) + ); +}; -},{}],482:[function(_dereq_,module,exports){ +exports.isRightAnchor = function isRightAnchor(opts) { + return ( + opts.xanchor === 'right' || + (opts.xanchor === 'auto' && opts.x >= 2 / 3) + ); +}; + +exports.isTopAnchor = function isTopAnchor(opts) { + return ( + opts.yanchor === 'top' || + (opts.yanchor === 'auto' && opts.y >= 2 / 3) + ); +}; + +exports.isMiddleAnchor = function isMiddleAnchor(opts) { + return ( + opts.yanchor === 'middle' || + (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) + ); +}; + +exports.isBottomAnchor = function isBottomAnchor(opts) { + return ( + opts.yanchor === 'bottom' || + (opts.yanchor === 'auto' && opts.y <= 1 / 3) + ); +}; + +},{}],479:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73691,7 +74262,7 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":505}],483:[function(_dereq_,module,exports){ +},{"./mod":501}],480:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73827,7 +74398,30 @@ exports.concat = function() { return out; }; -},{}],484:[function(_dereq_,module,exports){ +exports.maxRowLength = function(z) { + return _rowLength(z, Math.max, 0); +}; + +exports.minRowLength = function(z) { + return _rowLength(z, Math.min, Infinity); +}; + +function _rowLength(z, fn, len0) { + if(isArrayOrTypedArray(z)) { + if(isArrayOrTypedArray(z[0])) { + var len = len0; + for(var i = 0; i < z.length; i++) { + len = fn(len, z[i].length); + } + return len; + } else { + return z.length; + } + } + return 0; +} + +},{}],481:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73860,7 +74454,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":478,"fast-isnumeric":91}],485:[function(_dereq_,module,exports){ +},{"../constants/numerical":474,"fast-isnumeric":91}],482:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73888,7 +74482,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],486:[function(_dereq_,module,exports){ +},{}],483:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73911,7 +74505,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],487:[function(_dereq_,module,exports){ +},{}],484:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -73920,18 +74514,17 @@ module.exports = function clearResponsive(gd) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); var baseTraceAttrs = _dereq_('../plots/attributes'); -var getColorscale = _dereq_('../components/colorscale/get_scale'); -var colorscaleNames = Object.keys(_dereq_('../components/colorscale/scales')); +var scales = _dereq_('../components/colorscale/scales'); +var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; + var nestedProperty = _dereq_('./nested_property'); var counterRegex = _dereq_('./regex').counter; -var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; var modHalf = _dereq_('./mod').modHalf; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -74049,7 +74642,7 @@ exports.valObjectMeta = { coerceFunction: function(v, propOut, dflt) { - propOut.set(getColorscale(v, dflt)); + propOut.set(scales.get(v, dflt)); } }, angle: { @@ -74383,7 +74976,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/get_scale":389,"../components/colorscale/scales":395,"../constants/interactions":477,"../plots/attributes":541,"./array":483,"./mod":505,"./nested_property":506,"./regex":513,"fast-isnumeric":91,"tinycolor2":342}],488:[function(_dereq_,module,exports){ +},{"../components/colorscale/scales":390,"../constants/interactions":473,"../plots/attributes":537,"./array":480,"./mod":501,"./nested_property":502,"./regex":509,"fast-isnumeric":91,"tinycolor2":341}],485:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -74986,7 +75579,7 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":478,"../registry":597,"./loggers":502,"./mod":505,"d3":82,"fast-isnumeric":91}],489:[function(_dereq_,module,exports){ +},{"../constants/numerical":474,"../registry":593,"./loggers":498,"./mod":501,"d3":82,"fast-isnumeric":91}],486:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75160,7 +75753,7 @@ var Events = { module.exports = Events; -},{"events":48}],490:[function(_dereq_,module,exports){ +},{"events":48}],487:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75276,7 +75869,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":499}],491:[function(_dereq_,module,exports){ +},{"./is_plain_object.js":495}],488:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75327,7 +75920,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],492:[function(_dereq_,module,exports){ +},{}],489:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75374,7 +75967,7 @@ function isCalcData(cont) { ); } -},{}],493:[function(_dereq_,module,exports){ +},{}],490:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75620,7 +76213,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":505}],494:[function(_dereq_,module,exports){ +},{"./mod":501}],491:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75658,7 +76251,7 @@ module.exports = function(gd) { return gd; // otherwise assume that gd is a DOM element }; -},{}],495:[function(_dereq_,module,exports){ +},{}],492:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75709,11 +76302,7 @@ function formatColor(containerIn, opacityIn, len) { if(containerIn.colorscale !== undefined) { sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - containerIn.colorscale, - containerIn.cmin, - containerIn.cmax - ) + Colorscale.extractScale(containerIn, {cLetter: 'c'}) ); } else { @@ -75766,54 +76355,7 @@ module.exports = { parseColorScale: parseColorScale }; -},{"../components/color/attributes":375,"../components/colorscale":391,"./array":483,"color-normalize":63,"fast-isnumeric":91,"tinycolor2":342}],496:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var toSuperScript = _dereq_('superscript-text'); -var fixEntities = _dereq_('./svg_text_utils').convertEntities; - -function fixSuperScript(x) { - var idx = 0; - - while((idx = x.indexOf('', idx)) >= 0) { - var nidx = x.indexOf('', idx); - if(nidx < idx) break; - - x = x.slice(0, idx) + toSuperScript(x.slice(idx + 5, nidx)) + x.slice(nidx + 6); - } - - return x; -} - -function fixBR(x) { - return x.replace(/\/g, '\n'); -} - -function stripTags(x) { - return x.replace(/\<.*\>/g, ''); -} - -function convertHTMLToUnicode(html) { - return '' + - fixEntities( - stripTags( - fixSuperScript( - fixBR( - html)))); -} - -module.exports = convertHTMLToUnicode; - -},{"./svg_text_utils":521,"superscript-text":340}],497:[function(_dereq_,module,exports){ +},{"../components/color/attributes":374,"../components/colorscale":387,"./array":480,"color-normalize":63,"fast-isnumeric":91,"tinycolor2":341}],493:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75829,7 +76371,7 @@ module.exports = convertHTMLToUnicode; module.exports = function identity(d) { return d; }; -},{}],498:[function(_dereq_,module,exports){ +},{}],494:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -75863,6 +76405,8 @@ lib.isArrayOrTypedArray = arrayModule.isArrayOrTypedArray; lib.isArray1D = arrayModule.isArray1D; lib.ensureArray = arrayModule.ensureArray; lib.concat = arrayModule.concat; +lib.maxRowLength = arrayModule.maxRowLength; +lib.minRowLength = arrayModule.minRowLength; var modModule = _dereq_('./mod'); lib.mod = modModule.mod; @@ -75932,6 +76476,14 @@ lib.pathArc = anglesModule.pathArc; lib.pathSector = anglesModule.pathSector; lib.pathAnnulus = anglesModule.pathAnnulus; +var anchorUtils = _dereq_('./anchor_utils'); +lib.isLeftAnchor = anchorUtils.isLeftAnchor; +lib.isCenterAnchor = anchorUtils.isCenterAnchor; +lib.isRightAnchor = anchorUtils.isRightAnchor; +lib.isTopAnchor = anchorUtils.isTopAnchor; +lib.isMiddleAnchor = anchorUtils.isMiddleAnchor; +lib.isBottomAnchor = anchorUtils.isBottomAnchor; + var geom2dModule = _dereq_('./geometry2d'); lib.segmentsIntersect = geom2dModule.segmentsIntersect; lib.segmentDistance = geom2dModule.segmentDistance; @@ -76466,7 +77018,13 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) objOut[k] = v.slice(0, arrayLen); + else if(Array.isArray(v)) { + if(k === 'colorscale') { + objOut[k] = v.slice(); + } else { + objOut[k] = v.slice(0, arrayLen); + } + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -76811,10 +77369,10 @@ lib.numSeparate = function(value, separators, separatethousands) { return x1 + x2; }; -var TEMPLATE_STRING_REGEX = /%{([^\s%{}]*)}/g; +var TEMPLATE_STRING_REGEX = /%{([^\s%{}:]*)(:[^}]*)?}/g; var SIMPLE_PROPERTY_REGEX = /^\w*$/; -/* +/** * Substitute values from an object into a string * * Examples: @@ -76826,7 +77384,6 @@ var SIMPLE_PROPERTY_REGEX = /^\w*$/; * * @return {string} templated string */ - lib.templateString = function(string, obj) { // Not all that useful, but cache nestedProperty instantiation // just in case it speeds things up *slightly*: @@ -76841,6 +77398,67 @@ lib.templateString = function(string, obj) { }); }; +var TEMPLATE_STRING_FORMAT_SEPARATOR = /^:/; +var numberOfHoverTemplateWarnings = 0; +var maximumNumberOfHoverTemplateWarnings = 10; +/** + * Substitute values from an object into a string and optionally formats them using d3-format, + * or fallback to associated labels. + * + * Examples: + * Lib.templateString('name: %{trace}', {trace: 'asdf'}) --> 'name: asdf' + * Lib.templateString('name: %{trace[0].name}', {trace: [{name: 'asdf'}]}) --> 'name: asdf' + * Lib.templateString('price: %{y:$.2f}', {y: 1}) --> 'price: $1.00' + * + * @param {string} input string containing %{...:...} template strings + * @param {obj} data object containing fallback text when no formatting is specified, ex.: {yLabel: 'formattedYValue'} + * @param {obj} data objects containing substitution values + * + * @return {string} templated string + */ +lib.hovertemplateString = function(string, labels) { + var args = arguments; + // Not all that useful, but cache nestedProperty instantiation + // just in case it speeds things up *slightly*: + var getterCache = {}; + + return string.replace(TEMPLATE_STRING_REGEX, function(match, key, format) { + var obj, value, i; + for(i = 2; i < args.length; i++) { + obj = args[i]; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; + } + + if(value === undefined) { + if(numberOfHoverTemplateWarnings < maximumNumberOfHoverTemplateWarnings) { + lib.warn('Variable \'' + key + '\' in hovertemplate could not be found!'); + value = match; + } + + if(numberOfHoverTemplateWarnings === maximumNumberOfHoverTemplateWarnings) { + lib.warn('Too many hovertemplate warnings - additional warnings will be suppressed'); + } + numberOfHoverTemplateWarnings++; + } + + if(format) { + value = d3.format(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value); + } else { + if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + } + return value; + }); +}; + /* * alphanumeric string sort, tailored for subplot IDs like scene2, scene10, x10y13 etc */ @@ -76883,7 +77501,7 @@ lib.pseudoRandom = function() { return randSeed / 4294967296; }; -},{"../constants/numerical":478,"./angles":482,"./array":483,"./clean_number":484,"./clear_responsive":486,"./coerce":487,"./dates":488,"./extend":490,"./filter_unique":491,"./filter_visible":492,"./geometry2d":493,"./get_graph_div":494,"./identity":497,"./is_plain_object":499,"./keyed_container":500,"./localize":501,"./loggers":502,"./make_trace_groups":503,"./matrix":504,"./mod":505,"./nested_property":506,"./noop":507,"./notifier":508,"./push_unique":511,"./regex":513,"./relative_attr":514,"./relink_private":515,"./search":516,"./stats":519,"./throttle":522,"./to_log_range":523,"d3":82,"fast-isnumeric":91}],499:[function(_dereq_,module,exports){ +},{"../constants/numerical":474,"./anchor_utils":478,"./angles":479,"./array":480,"./clean_number":481,"./clear_responsive":483,"./coerce":484,"./dates":485,"./extend":487,"./filter_unique":488,"./filter_visible":489,"./geometry2d":490,"./get_graph_div":491,"./identity":493,"./is_plain_object":495,"./keyed_container":496,"./localize":497,"./loggers":498,"./make_trace_groups":499,"./matrix":500,"./mod":501,"./nested_property":502,"./noop":503,"./notifier":504,"./push_unique":507,"./regex":509,"./relative_attr":510,"./relink_private":511,"./search":512,"./stats":515,"./throttle":518,"./to_log_range":519,"d3":82,"fast-isnumeric":91}],495:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76912,7 +77530,7 @@ module.exports = function isPlainObject(obj) { ); }; -},{}],500:[function(_dereq_,module,exports){ +},{}],496:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77105,7 +77723,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":506}],501:[function(_dereq_,module,exports){ +},{"./nested_property":502}],497:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77161,7 +77779,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":597}],502:[function(_dereq_,module,exports){ +},{"../registry":593}],498:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77247,7 +77865,7 @@ function apply(f, args) { } } -},{"../plot_api/plot_config":532}],503:[function(_dereq_,module,exports){ +},{"../plot_api/plot_config":528}],499:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77284,7 +77902,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{}],504:[function(_dereq_,module,exports){ +},{}],500:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77394,7 +78012,7 @@ exports.apply2DTransform2 = function(transform) { }; }; -},{}],505:[function(_dereq_,module,exports){ +},{}],501:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77429,7 +78047,7 @@ module.exports = { modHalf: modHalf }; -},{}],506:[function(_dereq_,module,exports){ +},{}],502:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77676,7 +78294,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":483,"fast-isnumeric":91}],507:[function(_dereq_,module,exports){ +},{"./array":480,"fast-isnumeric":91}],503:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77692,7 +78310,7 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],508:[function(_dereq_,module,exports){ +},{}],504:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77774,7 +78392,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":82,"fast-isnumeric":91}],509:[function(_dereq_,module,exports){ +},{"d3":82,"fast-isnumeric":91}],505:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77823,7 +78441,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":517}],510:[function(_dereq_,module,exports){ +},{"./setcursor":513}],506:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78076,7 +78694,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":478,"./matrix":504}],511:[function(_dereq_,module,exports){ +},{"../constants/numerical":474,"./matrix":500}],507:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78116,7 +78734,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],512:[function(_dereq_,module,exports){ +},{}],508:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78327,7 +78945,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":498,"../plot_api/plot_config":532}],513:[function(_dereq_,module,exports){ +},{"../lib":494,"../plot_api/plot_config":528}],509:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78346,16 +78964,18 @@ module.exports = queue; * @param {Optional(string)} tail: a fixed piece after the id * eg counterRegex('scene', '.annotations') for scene2.annotations etc. * @param {boolean} openEnded: if true, the string may continue past the match. + * @param {boolean} matchBeginning: if false, the string may start before the match. */ -exports.counter = function(head, tail, openEnded) { +exports.counter = function(head, tail, openEnded, matchBeginning) { var fullTail = (tail || '') + (openEnded ? '' : '$'); + var startWithPrefix = matchBeginning === false ? '' : '^'; if(head === 'xy') { - return new RegExp('^x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + 'x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); } - return new RegExp('^' + head + '([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],514:[function(_dereq_,module,exports){ +},{}],510:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78408,7 +79028,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],515:[function(_dereq_,module,exports){ +},{}],511:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78471,7 +79091,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":483,"./is_plain_object":499}],516:[function(_dereq_,module,exports){ +},{"./array":480,"./is_plain_object":495}],512:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78659,7 +79279,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"./identity":497,"./loggers":502,"fast-isnumeric":91}],517:[function(_dereq_,module,exports){ +},{"./identity":493,"./loggers":498,"fast-isnumeric":91}],513:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78682,7 +79302,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],518:[function(_dereq_,module,exports){ +},{}],514:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78746,7 +79366,7 @@ module.exports = function showNoWebGlMsg(scene) { return false; }; -},{"../components/color":376}],519:[function(_dereq_,module,exports){ +},{"../components/color":375}],515:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78847,7 +79467,7 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":483,"fast-isnumeric":91}],520:[function(_dereq_,module,exports){ +},{"./array":480,"fast-isnumeric":91}],516:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78868,7 +79488,7 @@ function str2RgbaArray(color) { module.exports = str2RgbaArray; -},{"color-normalize":63}],521:[function(_dereq_,module,exports){ +},{"color-normalize":63}],517:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79643,7 +80263,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":474,"../constants/xmlns_namespaces":479,"../lib":498,"d3":82}],522:[function(_dereq_,module,exports){ +},{"../constants/alignment":470,"../constants/xmlns_namespaces":475,"../lib":494,"d3":82}],518:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79747,7 +80367,7 @@ function _clearTimeout(cache) { } } -},{}],523:[function(_dereq_,module,exports){ +},{}],519:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79775,7 +80395,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":91}],524:[function(_dereq_,module,exports){ +},{"fast-isnumeric":91}],520:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79797,7 +80417,7 @@ module.exports = { } }; -},{}],525:[function(_dereq_,module,exports){ +},{}],521:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79840,7 +80460,7 @@ module.exports = { } }; -},{}],526:[function(_dereq_,module,exports){ +},{}],522:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79898,7 +80518,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":597}],527:[function(_dereq_,module,exports){ +},{"../registry":593}],523:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80024,7 +80644,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":498}],528:[function(_dereq_,module,exports){ +},{"../lib":494}],524:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80080,6 +80700,8 @@ exports.cleanLayout = function(layout) { } var axisAttrRegex = (Plots.subplotsRegistry.cartesian || {}).attrRegex; + var polarAttrRegex = (Plots.subplotsRegistry.polar || {}).attrRegex; + var ternaryAttrRegex = (Plots.subplotsRegistry.ternary || {}).attrRegex; var sceneAttrRegex = (Plots.subplotsRegistry.gl3d || {}).attrRegex; var keys = Object.keys(layout); @@ -80118,6 +80740,24 @@ exports.cleanLayout = function(layout) { } delete ax.autotick; } + + cleanTitle(ax); + } + + // modifications for polar + else if(polarAttrRegex && polarAttrRegex.test(key)) { + var polar = layout[key]; + + cleanTitle(polar.radialaxis); + } + + // modifications for ternary + else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + var ternary = layout[key]; + + cleanTitle(ternary.aaxis); + cleanTitle(ternary.baxis); + cleanTitle(ternary.caxis); } // modifications for 3D scenes @@ -80141,11 +80781,16 @@ exports.cleanLayout = function(layout) { scene.camera = { eye: {x: eye[0], y: eye[1], z: eye[2]}, center: {x: center[0], y: center[1], z: center[2]}, - up: {x: mat[1], y: mat[5], z: mat[9]} + up: {x: 0, y: 0, z: 1} // we just ignore calculating camera z up in this case }; delete scene.cameraposition; } + + // clean axis titles + cleanTitle(scene.xaxis); + cleanTitle(scene.yaxis); + cleanTitle(scene.zaxis); } } @@ -80203,6 +80848,9 @@ exports.cleanLayout = function(layout) { } } + // clean plot title + cleanTitle(layout); + /* * Moved from rotate -> orbit for dragmode */ @@ -80212,6 +80860,11 @@ exports.cleanLayout = function(layout) { // supported, but new tinycolor does not because they're not valid css Color.clean(layout); + // clean the layout container in layout.template + if(layout.template && layout.template.layout) { + exports.cleanLayout(layout.template.layout); + } + return layout; }; @@ -80223,6 +80876,46 @@ function cleanAxRef(container, attr) { } } +/** + * Cleans up old title attribute structure (flat) in favor of the new one (nested). + * + * @param {Object} titleContainer - an object potentially including deprecated title attributes + */ +function cleanTitle(titleContainer) { + if(titleContainer) { + + // title -> title.text + // (although title used to be a string attribute, + // numbers are accepted as well) + if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') { + titleContainer.title = { + text: titleContainer.title + }; + } + + rewireAttr('titlefont', 'font'); + rewireAttr('titleposition', 'position'); + rewireAttr('titleside', 'side'); + rewireAttr('titleoffset', 'offset'); + } + + function rewireAttr(oldAttrName, newAttrName) { + var oldAttrSet = titleContainer[oldAttrName]; + var newAttrSet = titleContainer.title && titleContainer.title[newAttrName]; + + if(oldAttrSet && !newAttrSet) { + + // Ensure title object exists + if(!titleContainer.title) { + titleContainer.title = {}; + } + + titleContainer.title[newAttrName] = titleContainer[oldAttrName]; + delete titleContainer[oldAttrName]; + } + } +} + /* * cleanData: Make a few changes to the data for backward compatibility * before it gets used for anything. Modifies the data traces users provide. @@ -80426,6 +81119,13 @@ exports.cleanData = function(data) { delete trace.autobiny; delete trace.ybins; } + + cleanTitle(trace); + if(trace.colorbar) cleanTitle(trace.colorbar); + if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar); + if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar); + if(trace.aaxis) cleanTitle(trace.aaxis); + if(trace.baxis) cleanTitle(trace.baxis); } }; @@ -80466,11 +81166,14 @@ function commonPrefix(name1, name2, show1, show2) { function cleanTextPosition(textposition) { var posY = 'middle', posX = 'center'; - if(textposition.indexOf('top') !== -1) posY = 'top'; - else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; - if(textposition.indexOf('left') !== -1) posX = 'left'; - else if(textposition.indexOf('right') !== -1) posX = 'right'; + if(typeof textposition === 'string') { + if(textposition.indexOf('top') !== -1) posY = 'top'; + else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; + + if(textposition.indexOf('left') !== -1) posX = 'left'; + else if(textposition.indexOf('right') !== -1) posX = 'right'; + } return posY + ' ' + posX; } @@ -80646,7 +81349,7 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":376,"../lib":498,"../plots/cartesian/axis_ids":547,"../plots/plots":589,"../registry":597,"fast-isnumeric":91,"gl-mat4/fromQuat":122}],529:[function(_dereq_,module,exports){ +},{"../components/color":375,"../lib":494,"../plots/cartesian/axis_ids":543,"../plots/plots":585,"../registry":593,"fast-isnumeric":91,"gl-mat4/fromQuat":122}],525:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80665,6 +81368,10 @@ exports.restyle = main.restyle; exports.relayout = main.relayout; exports.redraw = main.redraw; exports.update = main.update; +exports._guiRestyle = main._guiRestyle; +exports._guiRelayout = main._guiRelayout; +exports._guiUpdate = main._guiUpdate; +exports._storeDirectGUIEdit = main._storeDirectGUIEdit; exports.react = main.react; exports.extendTraces = main.extendTraces; exports.prependTraces = main.prependTraces; @@ -80685,7 +81392,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":599,"./plot_api":531,"./template_api":536,"./to_image":537,"./validate":538}],530:[function(_dereq_,module,exports){ +},{"../snapshot/download":595,"./plot_api":527,"./template_api":532,"./to_image":533,"./validate":534}],526:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80697,7 +81404,6 @@ exports.validateTemplate = templateApi.validateTemplate; 'use strict'; -var nestedProperty = _dereq_('../lib/nested_property'); var isPlainObject = _dereq_('../lib/is_plain_object'); var noop = _dereq_('../lib/noop'); var Loggers = _dereq_('../lib/loggers'); @@ -80754,11 +81460,15 @@ var isRemoveVal = exports.isRemoveVal = function isRemoveVal(val) { * the flags for which actions we're going to perform to display these (and * any other) changes. If we're already `recalc`ing, we don't need to redraw * individual items + * @param {function} _nestedProperty + * a (possibly modified for gui edits) nestedProperty constructor + * The modified version takes a 3rd argument, for a prefix to the attribute + * string necessary for storing GUI edits * * @returns {bool} `true` if it managed to complete drawing of the changes * `false` would mean the parent should replot. */ -exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags) { +exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags, _nestedProperty) { var componentType = np.astr, supplyComponentDefaults = Registry.getComponentMethod(componentType, 'supplyLayoutDefaults'), draw = Registry.getComponentMethod(componentType, 'draw'), @@ -80798,7 +81508,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, // redoing supplyDefaults // TODO: this assumes componentArray is in gd.layout - which will not be // true after we extend this to restyle - componentArrayFull = nestedProperty(fullLayout, componentType).get(); + componentArrayFull = _nestedProperty(fullLayout, componentType).get(); var deletes = [], firstIndexChange = -1, @@ -80809,7 +81519,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, objEdits, objKeys, objVal, - adding; + adding, prefix; // first make the add and edit changes for(i = 0; i < componentNums.length; i++) { @@ -80848,7 +81558,9 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, } else { for(j = 0; j < objKeys.length; j++) { - nestedProperty(componentArray[componentNum], objKeys[j]).set(objEdits[objKeys[j]]); + prefix = componentType + '[' + componentNum + '].'; + _nestedProperty(componentArray[componentNum], objKeys[j], prefix) + .set(objEdits[objKeys[j]]); } } } @@ -80899,7 +81611,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":499,"../lib/loggers":502,"../lib/nested_property":506,"../lib/noop":507,"../lib/search":516,"../registry":597,"./container_array_match":526}],531:[function(_dereq_,module,exports){ +},{"../lib/is_plain_object":495,"../lib/loggers":498,"../lib/noop":503,"../lib/search":512,"../registry":593,"./container_array_match":522}],527:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80917,6 +81629,8 @@ var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); var Lib = _dereq_('../lib'); +var nestedProperty = Lib.nestedProperty; + var Events = _dereq_('../lib/events'); var Queue = _dereq_('../lib/queue'); @@ -81012,9 +81726,6 @@ exports.plot = function(gd, data, layout, config) { // so we can share cached text across tabs Drawing.makeTester(); - // clear stashed base url - delete Drawing.baseUrl; - // collect promises for any async actions during plotting // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all @@ -81059,7 +81770,7 @@ exports.plot = function(gd, data, layout, config) { // Legacy polar plots if(!fullLayout._has('polar') && data && data[0] && data[0].r) { Lib.log('Legacy polar charts are deprecated!'); - return plotPolar(gd, data, layout); + return plotLegacyPolar(gd, data, layout); } // so we don't try to re-call Plotly.plot from inside @@ -81235,8 +81946,7 @@ exports.plot = function(gd, data, layout, config) { return Lib.syncOrAsync([ Registry.getComponentMethod('shapes', 'calcAutorange'), Registry.getComponentMethod('annotations', 'calcAutorange'), - doAutoRangeAndConstraints, - Registry.getComponentMethod('rangeslider', 'calcAutorange') + doAutoRangeAndConstraints ], gd); } @@ -81248,11 +81958,16 @@ exports.plot = function(gd, data, layout, config) { // store initial ranges *after* enforcing constraints, otherwise // we will never look like we're at the initial ranges if(graphWasEmpty) Axes.saveRangeInitial(gd); + + // this one is different from shapes/annotations calcAutorange + // the others incorporate those components into ax._extremes, + // this one actually sets the ranges in rangesliders. + Registry.getComponentMethod('rangeslider', 'calcAutorange')(gd); } // draw ticks, titles, and calculate axis scaling (._b, ._m) function drawAxes() { - return Axes.doTicks(gd, graphWasEmpty ? '' : 'redraw'); + return Axes.draw(gd, graphWasEmpty ? '' : 'redraw'); } var seq = [ @@ -81321,7 +82036,16 @@ function opaqueSetBackground(gd, bgColor) { } function setPlotContext(gd, config) { - if(!gd._context) gd._context = Lib.extendDeep({}, defaultConfig); + if(!gd._context) { + gd._context = Lib.extendDeep({}, defaultConfig); + + // stash href, used to make robust clipPath URLs + var base = d3.select('base'); + gd._context._baseUrl = base.size() && base.attr('href') ? + window.location.href.split('#')[0] : + ''; + } + var context = gd._context; var i, keys, key; @@ -81367,6 +82091,9 @@ function setPlotContext(gd, config) { } } } + + // not part of the user-facing config options + context._exportedPlot = config._exportedPlot; } // staticPlot forces a bunch of others: @@ -81396,7 +82123,7 @@ function setPlotContext(gd, config) { context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0; } -function plotPolar(gd, data, layout) { +function plotLegacyPolar(gd, data, layout) { // build or reuse the container skeleton var plotContainer = d3.select(gd).selectAll('.plot-container') .data([0]); @@ -81437,7 +82164,7 @@ function plotPolar(gd, data, layout) { // editable title var opacity = 1; - var txt = gd._fullLayout.title; + var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; if(txt === '' || !txt) opacity = 0; var titleLayout = function() { @@ -81471,7 +82198,7 @@ function plotPolar(gd, data, layout) { var setContenteditable = function() { this.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { - gd.framework({layout: {title: text}}); + gd.framework({layout: {title: {text: text}}}); this.text(text) .call(titleLayout); this.call(setContenteditable); @@ -81744,7 +82471,7 @@ function getExtendProperties(gd, update, indices, maxPoints) { * instance that references the key and value for this particular trace. */ trace = gd.data[indices[j]]; - prop = Lib.nestedProperty(trace, key); + prop = nestedProperty(trace, key); /* * Target is the existing gd.data.trace.dataArray value like "x" or "marker.size" @@ -82215,7 +82942,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) { * If the array is too short, it will wrap around (useful for * style files that want to specify cyclical default values). */ -exports.restyle = function restyle(gd, astr, val, _traces) { +function restyle(gd, astr, val, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -82285,7 +83012,8 @@ exports.restyle = function restyle(gd, astr, val, _traces) { gd.emit('plotly_restyle', specs.eventData); return gd; }); -}; +} +exports.restyle = restyle; // for undo: undefined initial vals must be turned into nulls // so that we unset rather than ignore them @@ -82294,11 +83022,77 @@ function undefinedToNull(val) { return val; } +/** + * Factory function to wrap nestedProperty with GUI edits if necessary + * with GUI edits we add an optional prefix to the nestedProperty constructor + * to prepend to the attribute string in the preGUI store. + */ +function makeNP(preGUI, guiEditFlag) { + if(!guiEditFlag) return nestedProperty; + + return function(container, attr, prefix) { + var np = nestedProperty(container, attr); + var npSet = np.set; + np.set = function(val) { + var fullAttr = (prefix || '') + attr; + storeCurrent(fullAttr, np.get(), val, preGUI); + npSet(val); + }; + return np; + }; +} + +function storeCurrent(attr, val, newVal, preGUI) { + if(Array.isArray(val) || Array.isArray(newVal)) { + var arrayVal = Array.isArray(val) ? val : []; + var arrayNew = Array.isArray(newVal) ? newVal : []; + var maxLen = Math.max(arrayVal.length, arrayNew.length); + for(var i = 0; i < maxLen; i++) { + storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); + } + } + else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + var objVal = Lib.isPlainObject(val) ? val : {}; + var objNew = Lib.isPlainObject(newVal) ? newVal : {}; + var objBoth = Lib.extendFlat({}, objVal, objNew); + for(var key in objBoth) { + storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); + } + } + else if(preGUI[attr] === undefined) { + preGUI[attr] = undefinedToNull(val); + } +} + +/** + * storeDirectGUIEdit: for routines that skip restyle/relayout and mock it + * by emitting a plotly_restyle or plotly_relayout event, this routine + * keeps track of the initial state in _preGUI for use by uirevision + * Does *not* apply these changes to data/layout - that's the responsibility + * of the calling routine. + * + * @param {object} container: the input attributes container (eg `layout` or a `trace`) + * @param {object} preGUI: where original values should be stored, either + * `layout._preGUI` or `layout._tracePreGUI[uid]` + * @param {object} edits: the {attr: val} object as normally passed to `relayout` etc + */ +exports._storeDirectGUIEdit = function(container, preGUI, edits) { + for(var attr in edits) { + var np = nestedProperty(container, attr); + storeCurrent(attr, np.get(), edits[attr], preGUI); + } +}; + function _restyle(gd, aobj, traces) { - var fullLayout = gd._fullLayout, - fullData = gd._fullData, - data = gd.data, - i; + var fullLayout = gd._fullLayout; + var fullData = gd._fullData; + var data = gd.data; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var eventData = Lib.extendDeepAll({}, aobj); + var i; + + cleanDeprecatedAttributeKeys(aobj); // initialize flags var flags = editTypes.traceFlags(); @@ -82322,6 +83116,16 @@ function _restyle(gd, aobj, traces) { function rangeAttr(axName) { return 'LAYOUT' + axName + '.range'; } + function getFullTrace(traceIndex) { + // usually fullData maps 1:1 onto data, but with groupby transforms + // the fullData index can be greater. Take the *first* matching trace. + for(var j = traceIndex; j < fullData.length; j++) { + if(fullData[j]._input === data[traceIndex]) return fullData[j]; + } + // should never get here - and if we *do* it should cause an error + // later on undefined fullTrace is passed to nestedProperty. + } + // for attrs that interact (like scales & autoscales), save the // old vals before making the change // val=undefined will not set a value, just record what the value was. @@ -82337,9 +83141,11 @@ function _restyle(gd, aobj, traces) { var extraparam; if(attr.substr(0, 6) === 'LAYOUT') { - extraparam = Lib.nestedProperty(gd.layout, attr.replace('LAYOUT', '')); + extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', '')); } else { - extraparam = Lib.nestedProperty(data[traces[i]], attr); + var tracei = traces[i]; + var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid]; + extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr); } if(!(attr in undoit)) { @@ -82394,7 +83200,7 @@ function _restyle(gd, aobj, traces) { redoit[ai] = vi; if(ai.substr(0, 6) === 'LAYOUT') { - param = Lib.nestedProperty(gd.layout, ai.replace('LAYOUT', '')); + param = layoutNP(gd.layout, ai.replace('LAYOUT', '')); undoit[ai] = [undefinedToNull(param.get())]; // since we're allowing val to be an array, allow it here too, // even though that's meaningless @@ -82409,8 +83215,9 @@ function _restyle(gd, aobj, traces) { undoit[ai] = a0(); for(i = 0; i < traces.length; i++) { cont = data[traces[i]]; - contFull = fullData[traces[i]]; - param = Lib.nestedProperty(cont, ai); + contFull = getFullTrace(traces[i]); + var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid]; + param = makeNP(preGUI, guiEditFlag)(cont, ai); oldVal = param.get(); newVal = Array.isArray(vi) ? vi[i % vi.length] : vi; @@ -82420,7 +83227,7 @@ function _restyle(gd, aobj, traces) { var prefix = ai.substr(0, ai.length - finalPart.length - 1); var prefixDot = prefix ? prefix + '.' : ''; var innerContFull = prefix ? - Lib.nestedProperty(contFull, prefix).get() : contFull; + nestedProperty(contFull, prefix).get() : contFull; valObject = PlotSchema.getTraceValObject(contFull, param.parts); @@ -82467,14 +83274,14 @@ function _restyle(gd, aobj, traces) { Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo); if(oldVal === 'pie') { - Lib.nestedProperty(cont, 'marker.color') - .set(Lib.nestedProperty(cont, 'marker.colors').get()); + nestedProperty(cont, 'marker.color') + .set(nestedProperty(cont, 'marker.colors').get()); // super kludgy - but if all pies are gone we won't remove them otherwise fullLayout._pielayer.selectAll('g.trace').remove(); } else if(Registry.traceIs(cont, 'cartesian')) { - Lib.nestedProperty(cont, 'marker.colors') - .set(Lib.nestedProperty(cont, 'marker.color').get()); + nestedProperty(cont, 'marker.colors') + .set(nestedProperty(cont, 'marker.color').get()); } } @@ -82545,7 +83352,7 @@ function _restyle(gd, aobj, traces) { // swap hovermode if set to "compare x/y data" if(ai === 'orientationaxes') { - var hovermode = Lib.nestedProperty(gd.layout, 'hovermode'); + var hovermode = nestedProperty(gd.layout, 'hovermode'); if(hovermode.get() === 'x') { hovermode.set('y'); } else if(hovermode.get() === 'y') { @@ -82584,10 +83391,53 @@ function _restyle(gd, aobj, traces) { undoit: undoit, redoit: redoit, traces: traces, - eventData: Lib.extendDeepNoArrays([], [redoit, traces]) + eventData: Lib.extendDeepNoArrays([], [eventData, traces]) }; } +/** + * Converts deprecated attribute keys to + * the current API to ensure backwards compatibility. + * + * This is needed for the update mechanism to determine which + * subroutines to run based on the actual attribute + * definitions (that don't include the deprecated ones). + * + * E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'} + * and {titlefont: {...}} to {'title.font': {...}}. + * + * @param aobj + */ +function cleanDeprecatedAttributeKeys(aobj) { + var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false); + var colorbarRegex = /colorbar\.title$/; + var keys = Object.keys(aobj); + var i, key, value; + + for(i = 0; i < keys.length; i++) { + key = keys[i]; + value = aobj[key]; + + if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) && + (typeof value === 'string' || typeof value === 'number')) { + replace(key, key.replace('title', 'title.text')); + } else if(key.indexOf('titlefont') > -1) { + replace(key, key.replace('titlefont', 'title.font')); + } else if(key.indexOf('titleposition') > -1) { + replace(key, key.replace('titleposition', 'title.position')); + } else if(key.indexOf('titleside') > -1) { + replace(key, key.replace('titleside', 'title.side')); + } else if(key.indexOf('titleoffset') > -1) { + replace(key, key.replace('titleoffset', 'title.offset')); + } + } + + function replace(oldAttrStr, newAttrStr) { + aobj[newAttrStr] = aobj[oldAttrStr]; + delete aobj[oldAttrStr]; + } +} + /** * relayout: update layout attributes of an existing plot * @@ -82608,7 +83458,7 @@ function _restyle(gd, aobj, traces) { * attribute object `{astr1: val1, astr2: val2 ...}` * allows setting multiple attributes simultaneously */ -exports.relayout = function relayout(gd, astr, val) { +function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -82671,7 +83521,8 @@ exports.relayout = function relayout(gd, astr, val) { gd.emit('plotly_relayout', specs.eventData); return gd; }); -}; +} +exports.relayout = relayout; // Optimization mostly for large splom traces where // Plots.supplyDefaults can take > 100ms @@ -82699,13 +83550,24 @@ function addAxRangeSequence(seq, rangesAltered) { // N.B. leave as sequence of subroutines (for now) instead of // subroutine of its own so that finalDraw always gets // executed after drawData - var doTicks = rangesAltered ? - function(gd) { return Axes.doTicks(gd, Object.keys(rangesAltered), true); } : - function(gd) { return Axes.doTicks(gd, 'redraw'); }; + var drawAxes = rangesAltered ? + function(gd) { + var opts = {skipTitle: true}; + for(var id in rangesAltered) { + if(Axes.getFromId(gd, id).automargin) { + opts = {}; + break; + } + } + return Axes.draw(gd, Object.keys(rangesAltered), opts); + } : + function(gd) { + return Axes.draw(gd, 'redraw'); + }; seq.push( subroutines.doAutoRangeAndConstraints, - doTicks, + drawAxes, subroutines.drawData, subroutines.finalDraw ); @@ -82716,14 +83578,19 @@ var AX_AUTORANGE_RE = /^[xyz]axis[0-9]*\.autorange$/; var AX_DOMAIN_RE = /^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/; function _relayout(gd, aobj) { - var layout = gd.layout, - fullLayout = gd._fullLayout, - keys = Object.keys(aobj), - axes = Axes.list(gd), - arrayEdits = {}, - arrayStr, - i, - j; + var layout = gd.layout; + var fullLayout = gd._fullLayout; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var keys = Object.keys(aobj); + var axes = Axes.list(gd); + var eventData = Lib.extendDeepAll({}, aobj); + var arrayEdits = {}; + + var arrayStr, i, j; + + cleanDeprecatedAttributeKeys(aobj); + keys = Object.keys(aobj); // look for 'allaxes', split out into all axes // in case of 3D the axis are nested within a scene which is held in _id @@ -82763,7 +83630,7 @@ function _relayout(gd, aobj) { // via a parent) do not override with this auto-generated extra if(attr in aobj || helpers.hasParent(aobj, attr)) return; - var p = Lib.nestedProperty(layout, attr); + var p = layoutNP(layout, attr); if(!(attr in undoit)) { undoit[attr] = undefinedToNull(p.get()); } @@ -82788,7 +83655,7 @@ function _relayout(gd, aobj) { throw new Error('cannot set ' + ai + 'and a parent attribute simultaneously'); } - var p = Lib.nestedProperty(layout, ai); + var p = layoutNP(layout, ai); var vi = aobj[ai]; var plen = p.parts.length; // p.parts may end with an index integer if the property is an array @@ -82800,8 +83667,8 @@ function _relayout(gd, aobj) { var pleafPlus = p.parts[pend - 1] + '.' + pleaf; // trunk nodes (everything except the leaf) var ptrunk = p.parts.slice(0, pend).join('.'); - var parentIn = Lib.nestedProperty(gd.layout, ptrunk).get(); - var parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + var parentIn = nestedProperty(gd.layout, ptrunk).get(); + var parentFull = nestedProperty(fullLayout, ptrunk).get(); var vOld = p.get(); if(vi === undefined) continue; @@ -82846,12 +83713,12 @@ function _relayout(gd, aobj) { // check autorange vs range else if(pleafPlus.match(AX_RANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - var axFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + var axFull = nestedProperty(fullLayout, ptrunk).get(); if(axFull._inputDomain) { // if we're autoranging and this axis has a constrained domain, // reset it so we don't get locked into a shrunken size @@ -82859,7 +83726,7 @@ function _relayout(gd, aobj) { } } else if(pleafPlus.match(AX_DOMAIN_RE)) { - Lib.nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); + nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } // toggling axis type between log and linear: we need to convert @@ -82928,10 +83795,10 @@ function _relayout(gd, aobj) { doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleaf.match(AX_NAME_PATTERN)) { - var fullProp = Lib.nestedProperty(fullLayout, ai).get(), + var fullProp = nestedProperty(fullLayout, ai).get(), newType = (vi || {}).type; // This can potentially cause strange behavior if the autotype is not @@ -82953,8 +83820,6 @@ function _relayout(gd, aobj) { arrayStr = containerArrayMatch.array; i = containerArrayMatch.index; var propStr = containerArrayMatch.property; - var componentArray = Lib.nestedProperty(layout, arrayStr); - var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; if(i !== '' && propStr === '') { @@ -82964,7 +83829,7 @@ function _relayout(gd, aobj) { if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { - undoit[ai] = obji; + undoit[ai] = (nestedProperty(layout, arrayStr).get() || [])[i]; } else { Lib.warn('unrecognized full object value', aobj); } @@ -83008,7 +83873,7 @@ function _relayout(gd, aobj) { // now we've collected component edits - execute them all together for(arrayStr in arrayEdits) { var finished = manageArrays.applyContainerArrayChanges(gd, - Lib.nestedProperty(layout, arrayStr), arrayEdits[arrayStr], flags); + layoutNP(layout, arrayStr), arrayEdits[arrayStr], flags, layoutNP); if(!finished) flags.plot = true; } @@ -83051,7 +83916,7 @@ function _relayout(gd, aobj) { rangesAltered: rangesAltered, undoit: undoit, redoit: redoit, - eventData: Lib.extendDeep({}, redoit) + eventData: eventData }; } @@ -83086,7 +83951,7 @@ function updateAutosize(gd) { * integer or array of integers for the traces to alter (all if omitted) * */ -exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { +function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -83166,7 +84031,235 @@ exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { return gd; }); -}; +} +exports.update = update; + +/* + * internal-use-only restyle/relayout/update variants that record the initial + * values in (fullLayout|fullTrace)._preGUI so changes can be persisted across + * Plotly.react data updates, dependent on uirevision attributes + */ +function guiEdit(func) { + return function wrappedEdit(gd) { + gd._fullLayout._guiEditing = true; + var p = func.apply(null, arguments); + gd._fullLayout._guiEditing = false; + return p; + }; +} +exports._guiRestyle = guiEdit(restyle); +exports._guiRelayout = guiEdit(relayout); +exports._guiUpdate = guiEdit(update); + +// For connecting edited layout attributes to uirevision attrs +// If no `attr` we use `match[1] + '.uirevision'` +// Ordered by most common edits first, to minimize our search time +var layoutUIControlPatterns = [ + {pattern: /^hiddenlabels/, attr: 'legend.uirevision'}, + {pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/}, + + // showspikes and modes include those nested inside scenes + {pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'}, + {pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'}, + + {pattern: /^(scene\d*)\.camera/}, + {pattern: /^(geo\d*)\.(projection|center)/}, + {pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/}, + {pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/}, + {pattern: /^(polar\d*\.angularaxis)\.rotation/}, + {pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/}, + + {pattern: /^legend\.(x|y)$/, attr: 'editrevision'}, + {pattern: /^(shapes|annotations)/, attr: 'editrevision'}, + {pattern: /^title\.text$/, attr: 'editrevision'} +]; + +// same for trace attributes: if `attr` is given it's in layout, +// or with no `attr` we use `trace.uirevision` +var traceUIControlPatterns = [ + {pattern: /^selectedpoints$/, attr: 'selectionrevision'}, + // "visible" includes trace.transforms[i].styles[j].value.visible + {pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'}, + {pattern: /^dimensions\[\d+\]\.constraintrange/}, + + // below this you must be in editable: true mode + // TODO: I still put name and title with `trace.uirevision` + // reasonable or should these be `editrevision`? + // Also applies to axis titles up in the layout section + + // "name" also includes transform.styles + {pattern: /(^|value\.)name$/}, + // including nested colorbar attributes (ie marker.colorbar) + {pattern: /colorbar\.title\.text$/}, + {pattern: /colorbar\.(x|y)$/, attr: 'editrevision'} +]; + +function findUIPattern(key, patternSpecs) { + for(var i = 0; i < patternSpecs.length; i++) { + var spec = patternSpecs[i]; + var match = key.match(spec.pattern); + if(match) { + return {head: match[1], attr: spec.attr}; + } + } +} + +// We're finding the new uirevision before supplyDefaults, so do the +// inheritance manually. Note that only `undefined` inherits - other +// falsy values are returned. +function getNewRev(revAttr, container) { + var newRev = nestedProperty(container, revAttr).get(); + if(newRev !== undefined) return newRev; + + var parts = revAttr.split('.'); + parts.pop(); + while(parts.length > 1) { + parts.pop(); + newRev = nestedProperty(container, parts.join('.') + '.uirevision').get(); + if(newRev !== undefined) return newRev; + } + + return container.uirevision; +} + +function getFullTraceIndexFromUid(uid, fullData) { + for(var i = 0; i < fullData.length; i++) { + if(fullData[i]._fullInput.uid === uid) return i; + } + return -1; +} + +function getTraceIndexFromUid(uid, data, tracei) { + for(var i = 0; i < data.length; i++) { + if(data[i].uid === uid) return i; + } + // fall back on trace order, but only if user didn't provide a uid for that trace + return data[tracei].uid ? -1 : tracei; +} + +function valsMatch(v1, v2) { + var v1IsObj = Lib.isPlainObject(v1); + var v1IsArray = Array.isArray(v1); + if(v1IsObj || v1IsArray) { + return ( + (v1IsObj && Lib.isPlainObject(v2)) || + (v1IsArray && Array.isArray(v2)) + ) && JSON.stringify(v1) === JSON.stringify(v2); + } + return v1 === v2; +} + +function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { + var layoutPreGUI = oldFullLayout._preGUI; + var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal; + var bothInheritAutorange = []; + var newRangeAccepted = {}; + for(key in layoutPreGUI) { + match = findUIPattern(key, layoutUIControlPatterns); + if(match) { + revAttr = match.attr || (match.head + '.uirevision'); + oldRev = nestedProperty(oldFullLayout, revAttr).get(); + newRev = oldRev && getNewRev(revAttr, layout); + if(newRev && (newRev === oldRev)) { + preGUIVal = layoutPreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(layout, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + if(newVal === undefined && key.substr(key.length - 9) === 'autorange') { + bothInheritAutorange.push(key.substr(0, key.length - 10)); + } + newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key); + } + // if we got this far, the new value was accepted as the new starting + // point (either because it changed or revision changed) + // so remove it from _preGUI for next time. + delete layoutPreGUI[key]; + + if(key.substr(key.length - 8, 6) === 'range[') { + newRangeAccepted[key.substr(0, key.length - 9)] = 1; + } + } + + // Special logic for `autorange`, since it interacts with `range`: + // If the new figure's matching `range` was kept, and `autorange` + // wasn't supplied explicitly in either the original or the new figure, + // we shouldn't alter that - but we may just have done that, so fix it. + for(var i = 0; i < bothInheritAutorange.length; i++) { + var axAttr = bothInheritAutorange[i]; + if(newRangeAccepted[axAttr]) { + var newAx = nestedProperty(layout, axAttr).get(); + if(newAx) delete newAx.autorange; + } + } + + // Now traces - try to match them up by uid (in case we added/deleted in + // the middle), then fall back on index. + var allTracePreGUI = oldFullLayout._tracePreGUI; + for(var uid in allTracePreGUI) { + var tracePreGUI = allTracePreGUI[uid]; + var newTrace = null; + var fullInput; + for(key in tracePreGUI) { + // wait until we know we have preGUI values to look for traces + // but if we don't find both, stop looking at this uid + if(!newTrace) { + var fulli = getFullTraceIndexFromUid(uid, oldFullData); + if(fulli < 0) { + // Somehow we didn't even have this trace in oldFullData... + // I guess this could happen with `deleteTraces` or something + delete allTracePreGUI[uid]; + break; + } + var fullTrace = oldFullData[fulli]; + fullInput = fullTrace._fullInput; + + var newTracei = getTraceIndexFromUid(uid, data, fullInput.index); + if(newTracei < 0) { + // No match in new data + delete allTracePreGUI[uid]; + break; + } + newTrace = data[newTracei]; + } + + match = findUIPattern(key, traceUIControlPatterns); + if(match) { + if(match.attr) { + oldRev = nestedProperty(oldFullLayout, match.attr).get(); + newRev = oldRev && getNewRev(match.attr, layout); + } + else { + oldRev = fullInput.uirevision; + // inheritance for trace.uirevision is simple, just layout.uirevision + newRev = newTrace.uirevision; + if(newRev === undefined) newRev = layout.uirevision; + } + + if(newRev && newRev === oldRev) { + preGUIVal = tracePreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(newTrace, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + newNP.set(undefinedToNull(nestedProperty(fullInput, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); + } + delete tracePreGUI[key]; + } + } +} /** * Plotly.react: @@ -83230,6 +84323,8 @@ exports.react = function(gd, data, layout, config) { gd.layout = layout || {}; helpers.cleanLayout(gd.layout); + applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout); + // "true" skips updating calcdata and remapping arrays from calcTransforms, // which supplyDefaults usually does at the end, but we may need to NOT do // if the diff (which we haven't determined yet) says we'll recalc @@ -84284,7 +85379,7 @@ function makePlotFramework(gd) { gd.emit('plotly_framework'); } -},{"../components/color":376,"../components/colorbar/connect":378,"../components/drawing":401,"../constants/xmlns_namespaces":479,"../lib":498,"../lib/events":489,"../lib/queue":512,"../lib/svg_text_utils":521,"../plots/cartesian/axes":544,"../plots/cartesian/constants":550,"../plots/cartesian/graph_interact":554,"../plots/plots":589,"../plots/polar/legacy":592,"../registry":597,"./edit_types":527,"./helpers":528,"./manage_arrays":530,"./plot_config":532,"./plot_schema":533,"./subroutines":535,"d3":82,"fast-isnumeric":91,"has-hover":250}],532:[function(_dereq_,module,exports){ +},{"../components/color":375,"../components/colorbar/connect":377,"../components/drawing":396,"../constants/xmlns_namespaces":475,"../lib":494,"../lib/events":486,"../lib/queue":508,"../lib/svg_text_utils":517,"../plots/cartesian/axes":540,"../plots/cartesian/constants":546,"../plots/cartesian/graph_interact":550,"../plots/plots":585,"../plots/polar/legacy":588,"../registry":593,"./edit_types":523,"./helpers":524,"./manage_arrays":526,"./plot_config":528,"./plot_schema":529,"./subroutines":531,"d3":82,"fast-isnumeric":91,"has-hover":250}],528:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84377,12 +85472,34 @@ module.exports = { */ showAxisRangeEntryBoxes: true, - // link to open this plot in plotly + /* + * Add a text link to open this plot in plotly? + * This link shows up in the bottom right corner of the plot, and works + * identically to the newer ModeBar button controlled by `showSendToCloud` + * unless `sendData: false` is used. + */ showLink: false, - // if we show a link, does it contain data or just link to a plotly file? + /* + * If we show a text link (`showLink: true`), does it contain data or just + * a reference to a plotly cloud file? This option should only be used on + * plot.ly or another plotly server, and is not supported by the newer + * ModeBar button `showSendToCloud`. + */ sendData: true, + /* + * Should we include a ModeBar button, labeled "Edit in Chart Studio", + * that sends this chart to plot.ly or another plotly server as specified + * by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0 + * this button was included by default, now it is opt-in using this flag. + * + * Note that this button can (depending on `plotlyServerURL`) send your data + * to an external server. However that server doesn't persist your data + * until you arrive at the Chart Studio and explicitly click "Save". + */ + showSendToCloud: false, + // text appearing in the sendData link linkText: 'Edit chart', @@ -84420,6 +85537,9 @@ module.exports = { // add the plotly logo on the end of the mode bar displaylogo: true, + // watermark the images with the company's logo + watermark: false, + // increase the pixel ratio for Gl plot images plotGlPixelRatio: 2, @@ -84486,7 +85606,7 @@ module.exports = { locales: {} }; -},{}],533:[function(_dereq_,module,exports){ +},{}],529:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85172,7 +86292,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":498,"../plots/animation_attributes":539,"../plots/attributes":541,"../plots/frame_attributes":572,"../plots/layout_attributes":587,"../plots/polar/legacy/area_attributes":590,"../plots/polar/legacy/axis_attributes":591,"../registry":597,"./edit_types":527}],534:[function(_dereq_,module,exports){ +},{"../lib":494,"../plots/animation_attributes":535,"../plots/attributes":537,"../plots/frame_attributes":568,"../plots/layout_attributes":583,"../plots/polar/legacy/area_attributes":586,"../plots/polar/legacy/axis_attributes":587,"../registry":593,"./edit_types":523}],530:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85486,7 +86606,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":498,"../plots/attributes":541}],535:[function(_dereq_,module,exports){ +},{"../lib":494,"../plots/attributes":537}],531:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85516,6 +86636,10 @@ var enforceAxisConstraints = axisConstraints.enforce; var cleanAxisConstraints = axisConstraints.clean; var doAutoRange = _dereq_('../plots/cartesian/autorange').doAutoRange; +var SVG_TEXT_ANCHOR_START = 'start'; +var SVG_TEXT_ANCHOR_MIDDLE = 'middle'; +var SVG_TEXT_ANCHOR_END = 'end'; + exports.layoutStyles = function(gd) { return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd); }; @@ -85540,7 +86664,7 @@ function lsInner(gd) { var gs = fullLayout._size; var pad = gs.p; var axList = Axes.list(gd, '', true); - var i, subplot, plotinfo, xa, ya; + var i, subplot, plotinfo, ax, xa, ya; fullLayout._paperdiv.style({ width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px', @@ -85576,10 +86700,7 @@ function lsInner(gd) { // some preparation of axis position info for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - - // reset scale in case the margins have changed - ax.setScale(); + ax = axList[i]; var counterAx = ax._anchorAxis; @@ -85598,11 +86719,6 @@ function lsInner(gd) { ax._mainMirrorPosition = (ax.mirror && counterAx) ? getLinePosition(ax, counterAx, alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; - - // Figure out which subplot to draw ticks, labels, & axis lines on - // do this as a separate loop so we already have all the - // _mainAxis and _anchorAxis links set - ax._mainSubplot = findMainSubplot(ax, fullLayout); } // figure out which backgrounds we need to draw, @@ -85713,7 +86829,7 @@ function lsInner(gd) { layerClipId = null; } - Drawing.setClipUrl(plotinfo.plot, plotClipId); + Drawing.setClipUrl(plotinfo.plot, plotClipId, gd); // stash layer clipId value (null or same as clipId) // to DRY up Drawing.setClipUrl calls on trace-module and trace layers @@ -85843,48 +86959,6 @@ function lsInner(gd) { return gd._promises.length && Promise.all(gd._promises); } -function findMainSubplot(ax, fullLayout) { - var subplotList = fullLayout._subplots; - var ids = subplotList.cartesian.concat(subplotList.gl2d || []); - var mockGd = {_fullLayout: fullLayout}; - - var isX = ax._id.charAt(0) === 'x'; - var anchorAx = ax._mainAxis._anchorAxis; - var mainSubplotID = ''; - var nextBestMainSubplotID = ''; - var anchorID = ''; - - // First try the main ID with the anchor - if(anchorAx) { - anchorID = anchorAx._mainAxis._id; - mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); - } - - // Then look for a subplot with the counteraxis overlaying the anchor - // If that fails just use the first subplot including this axis - if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { - mainSubplotID = ''; - - for(var j = 0; j < ids.length; j++) { - var id = ids[j]; - var yIndex = id.indexOf('y'); - var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); - var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); - - if(idPart === ax._id) { - if(!nextBestMainSubplotID) nextBestMainSubplotID = id; - var counterAx = Axes.getFromId(mockGd, counterPart); - if(anchorID && counterAx.overlaying === anchorID) { - mainSubplotID = id; - break; - } - } - } - } - - return mainSubplotID || nextBestMainSubplotID; -} - function shouldShowLinesOrTicks(ax, subplot) { return (ax.ticks || ax.showline) && (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); @@ -85939,18 +87013,92 @@ function findCounterAxisLineWidth(ax, side, counterAx, axList) { exports.drawMainTitle = function(gd) { var fullLayout = gd._fullLayout; + var textAnchor = getMainTitleTextAnchor(fullLayout); + var dy = getMainTitleDy(fullLayout); + Titles.draw(gd, 'gtitle', { propContainer: fullLayout, - propName: 'title', + propName: 'title.text', placeholder: fullLayout._dfltTitle.plot, attributes: { - x: fullLayout.width / 2, - y: fullLayout._size.t / 2, - 'text-anchor': 'middle' + x: getMainTitleX(fullLayout, textAnchor), + y: getMainTitleY(fullLayout, dy), + 'text-anchor': textAnchor, + dy: dy } }); }; +function getMainTitleX(fullLayout, textAnchor) { + var title = fullLayout.title; + var gs = fullLayout._size; + var hPadShift = 0; + + if(textAnchor === SVG_TEXT_ANCHOR_START) { + hPadShift = title.pad.l; + } else if(textAnchor === SVG_TEXT_ANCHOR_END) { + hPadShift = -title.pad.r; + } + + switch(title.xref) { + case 'paper': + return gs.l + gs.w * title.x + hPadShift; + case 'container': + default: + return fullLayout.width * title.x + hPadShift; + } +} + +function getMainTitleY(fullLayout, dy) { + var title = fullLayout.title; + var gs = fullLayout._size; + var vPadShift = 0; + + if(dy === '0em' || !dy) { + vPadShift = -title.pad.b; + } else if(dy === alignmentConstants.CAP_SHIFT + 'em') { + vPadShift = title.pad.t; + } + + if(title.y === 'auto') { + return gs.t / 2; + } else { + switch(title.yref) { + case 'paper': + return gs.t + gs.h - gs.h * title.y + vPadShift; + case 'container': + default: + return fullLayout.height - fullLayout.height * title.y + vPadShift; + } + } +} + +function getMainTitleTextAnchor(fullLayout) { + var title = fullLayout.title; + + var textAnchor = SVG_TEXT_ANCHOR_MIDDLE; + if(Lib.isRightAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_END; + } else if(Lib.isLeftAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_START; + } + + return textAnchor; +} + +function getMainTitleDy(fullLayout) { + var title = fullLayout.title; + + var dy = '0em'; + if(Lib.isTopAnchor(title)) { + dy = alignmentConstants.CAP_SHIFT + 'em'; + } else if(Lib.isMiddleAnchor(title)) { + dy = alignmentConstants.MID_SHIFT + 'em'; + } + + return dy; +} + exports.doTraceStyle = function(gd) { var calcdata = gd.calcdata; var editStyleCalls = []; @@ -86028,7 +87176,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.doTicks(gd, 'redraw'); + Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -86163,6 +87311,8 @@ exports.doAutoRangeAndConstraints = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; cleanAxisConstraints(gd, ax); + // in case margins changed, update scale + ax.setScale(); doAutoRange(gd, ax); } @@ -86194,7 +87344,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('updatemenus', 'draw')(gd); }; -},{"../components/color":376,"../components/drawing":401,"../components/modebar":439,"../components/titles":467,"../constants/alignment":474,"../lib":498,"../lib/clear_gl_canvases":485,"../plots/cartesian/autorange":543,"../plots/cartesian/axes":544,"../plots/cartesian/constraints":552,"../plots/plots":589,"../registry":597,"d3":82}],536:[function(_dereq_,module,exports){ +},{"../components/color":375,"../components/drawing":396,"../components/modebar":434,"../components/titles":463,"../constants/alignment":470,"../lib":494,"../lib/clear_gl_canvases":482,"../plots/cartesian/autorange":539,"../plots/cartesian/axes":540,"../plots/cartesian/constraints":548,"../plots/plots":585,"../registry":593,"d3":82}],532:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86668,7 +87818,7 @@ function format(opts) { return opts; } -},{"../lib":498,"../plots/attributes":541,"../plots/plots":589,"./plot_config":532,"./plot_schema":533,"./plot_template":534}],537:[function(_dereq_,module,exports){ +},{"../lib":494,"../plots/attributes":537,"../plots/plots":585,"./plot_config":528,"./plot_schema":529,"./plot_template":530}],533:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86788,6 +87938,7 @@ function toImage(gd, opts) { // extend config for static plot var configImage = Lib.extendFlat({}, config, { + _exportedPlot: true, staticPlot: true, setBackground: setBackground }); @@ -86858,7 +88009,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":498,"../snapshot/helpers":601,"../snapshot/svgtoimg":603,"../snapshot/tosvg":605,"./plot_api":531}],538:[function(_dereq_,module,exports){ +},{"../lib":494,"../snapshot/helpers":597,"../snapshot/svgtoimg":599,"../snapshot/tosvg":601,"./plot_api":527}],534:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87304,7 +88455,7 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":498,"../plots/plots":589,"./plot_config":532,"./plot_schema":533}],539:[function(_dereq_,module,exports){ +},{"../lib":494,"../plots/plots":585,"./plot_config":528,"./plot_schema":529}],535:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87406,7 +88557,7 @@ module.exports = { } }; -},{}],540:[function(_dereq_,module,exports){ +},{}],536:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87502,7 +88653,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":498,"../plot_api/plot_template":534}],541:[function(_dereq_,module,exports){ +},{"../lib":494,"../plot_api/plot_template":530}],537:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87624,10 +88775,16 @@ module.exports = { _isLinkedToArray: 'transform', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + } }; -},{"../components/fx/attributes":410}],542:[function(_dereq_,module,exports){ +},{"../components/fx/attributes":405}],538:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87656,7 +88813,7 @@ module.exports = { } }; -},{}],543:[function(_dereq_,module,exports){ +},{}],539:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87671,6 +88828,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; +var Registry = _dereq_('../../registry'); module.exports = { getAutoRange: getAutoRange, @@ -87895,10 +89053,6 @@ function concatExtremes(gd, ax) { } function doAutoRange(gd, ax) { - if(!ax._length) ax.setScale(); - - var axIn; - if(ax.autorange) { ax.range = getAutoRange(gd, ax); @@ -87908,20 +89062,28 @@ function doAutoRange(gd, ax) { // doAutoRange will get called on fullLayout, // but we want to report its results back to layout - axIn = ax._input; + var axIn = ax._input; + + // before we edit _input, store preGUI values + var edits = {}; + edits[ax._attr + '.range'] = ax.range; + edits[ax._attr + '.autorange'] = ax.autorange; + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, edits); + axIn.range = ax.range.slice(); axIn.autorange = ax.autorange; } - if(ax._anchorAxis && ax._anchorAxis.rangeslider) { - var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name]; + var anchorAx = ax._anchorAxis; + + if(anchorAx && anchorAx.rangeslider) { + var axeRangeOpts = anchorAx.rangeslider[ax._name]; if(axeRangeOpts) { if(axeRangeOpts.rangemode === 'auto') { axeRangeOpts.range = getAutoRange(gd, ax); } } - axIn = ax._anchorAxis._input; - axIn.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); } } @@ -88139,7 +89301,7 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":478,"../../lib":498,"fast-isnumeric":91}],544:[function(_dereq_,module,exports){ +},{"../../constants/numerical":474,"../../lib":494,"../../registry":593,"fast-isnumeric":91}],540:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88299,6 +89461,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t ax.d2c(targetArray[i]); } } + // TODO what to do for transforms? } else { ax = axes.getFromTrace(gd, trace, d2cTarget); } @@ -88339,7 +89502,7 @@ axes.counterLetter = function(id) { axes.minDtick = function(ax, newDiff, newFirst, allow) { // doesn't make sense to do forced min dTick on log or category axes, // and the plot itself may decide to cancel (ie non-grouped bars) - if(['log', 'category'].indexOf(ax.type) !== -1 || !allow) { + if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; } // undefined means there's nothing there yet @@ -88371,18 +89534,15 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // save a copy of the initial axis ranges in fullLayout // use them in mode bar and dblclick events axes.saveRangeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._rangeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.range[0] === ax._rangeInitial[0] && - ax.range[1] === ax._rangeInitial[1] - ) + var hasChanged = isNew || !( + ax.range[0] === ax._rangeInitial[0] && + ax.range[1] === ax._rangeInitial[1] ); if((isNew && ax.autorange === false) || (overwrite && hasChanged)) { @@ -88396,21 +89556,16 @@ axes.saveRangeInitial = function(gd, overwrite) { // save a copy of the initial spike visibility axes.saveShowSpikeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false, - allSpikesEnabled = 'on'; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; + var allSpikesEnabled = 'on'; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._showSpikeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.showspikes === ax._showspikes - ) - ); + var hasChanged = isNew || !(ax.showspikes === ax._showspikes); - if((isNew) || (overwrite && hasChanged)) { + if(isNew || (overwrite && hasChanged)) { ax._showSpikeInitial = ax.showspikes; hasOneAxisChanged = true; } @@ -88427,7 +89582,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { var dataMin = Lib.aggNums(Math.min, null, data); var dataMax = Lib.aggNums(Math.max, null, data); - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { return { start: dataMin - 0.5, end: dataMax + 0.5, @@ -88445,8 +89600,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { type: 'linear', range: [dataMin, dataMax] }; - } - else { + } else { dummyAx = { type: ax.type, range: Lib.simpleMap([dataMin, dataMax], ax.c2r, 0, calendar), @@ -88531,10 +89685,10 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { - var edgecount = 0, - midcount = 0, - intcount = 0, - blankCount = 0; + var edgecount = 0; + var midcount = 0; + var intcount = 0; + var blankCount = 0; function nearEdge(v) { // is a value within 1% of a bin edge? @@ -88625,14 +89779,14 @@ axes.prepTicks = function(ax) { // calculate max number of (auto) ticks to display based on plot size if(ax.tickmode === 'auto' || !ax.dtick) { - var nt = ax.nticks, - minPx; + var nt = ax.nticks; + var minPx; + if(!nt) { - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; nt = ax._length / minPx; - } - else { + } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; nt = Lib.constrain(ax._length / minPx, 4, 9) + 1; } @@ -88694,7 +89848,7 @@ axes.calcTicks = function calcTicks(ax) { // return the full set of tick vals var vals = []; - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { endTick = (axrev) ? Math.max(-0.5, endTick) : Math.min(ax._categories.length - 0.5, endTick); } @@ -88738,23 +89892,22 @@ axes.calcTicks = function calcTicks(ax) { }; function arrayTicks(ax) { - var vals = ax.tickvals, - text = ax.ticktext, - ticksOut = new Array(vals.length), - rng = Lib.simpleMap(ax.range, ax.r2l), - r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001, - r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001, - tickMin = Math.min(r0expanded, r1expanded), - tickMax = Math.max(r0expanded, r1expanded), - vali, - i, - j = 0; + var vals = ax.tickvals; + var text = ax.ticktext; + var ticksOut = new Array(vals.length); + var rng = Lib.simpleMap(ax.range, ax.r2l); + var r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001; + var r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001; + var tickMin = Math.min(r0expanded, r1expanded); + var tickMax = Math.max(r0expanded, r1expanded); + var j = 0; // without a text array, just format the given values as any other ticks // except with more precision to the numbers if(!Array.isArray(text)) text = []; // make sure showing ticks doesn't accidentally add new categories + // TODO multicategory, if we allow ticktext / tickvals var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; // array ticks on log axes always show the full number @@ -88763,8 +89916,8 @@ function arrayTicks(ax) { ax.dtick = 'L' + Math.pow(10, Math.floor(Math.min(ax.range[0], ax.range[1])) - 1); } - for(i = 0; i < vals.length; i++) { - vali = tickVal2l(vals[i]); + for(var i = 0; i < vals.length; i++) { + var vali = tickVal2l(vals[i]); if(vali > tickMin && vali < tickMax) { if(text[i] === undefined) ticksOut[j] = axes.tickText(ax, vali); else ticksOut[j] = tickTextObj(ax, vali, String(text[i])); @@ -88777,17 +89930,17 @@ function arrayTicks(ax) { return ticksOut; } -var roundBase10 = [2, 5, 10], - roundBase24 = [1, 2, 3, 6, 12], - roundBase60 = [1, 2, 5, 10, 15, 30], - // 2&3 day ticks are weird, but need something btwn 1&7 - roundDays = [1, 2, 3, 7, 14], - // approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) - // these don't have to be exact, just close enough to round to the right value - roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1], - roundLog2 = [-0.301, 0, 0.301, 0.699, 1], - // N.B. `thetaunit; 'radians' angular axes must be converted to degrees - roundAngles = [15, 30, 45, 90, 180]; +var roundBase10 = [2, 5, 10]; +var roundBase24 = [1, 2, 3, 6, 12]; +var roundBase60 = [1, 2, 5, 10, 15, 30]; +// 2&3 day ticks are weird, but need something btwn 1&7 +var roundDays = [1, 2, 3, 7, 14]; +// approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) +// these don't have to be exact, just close enough to round to the right value +var roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1]; +var roundLog2 = [-0.301, 0, 0.301, 0.699, 1]; +// N.B. `thetaunit; 'radians' angular axes must be converted to degrees +var roundAngles = [15, 30, 45, 90, 180]; function roundDTick(roughDTick, base, roundingSet) { return base * Lib.roundUp(roughDTick / base, roundingSet); @@ -88878,7 +90031,7 @@ axes.autoTicks = function(ax, roughDTick) { ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } } - else if(ax.type === 'category') { + else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); } @@ -88918,7 +90071,7 @@ function autoTickRound(ax) { dtick = 1; } - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { ax._tickround = null; } if(ax.type === 'date') { @@ -89010,36 +90163,34 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { // calculate the first tick on an axis axes.tickFirst = function(ax) { - var r2l = ax.r2l || Number, - rng = Lib.simpleMap(ax.range, r2l), - axrev = rng[1] < rng[0], - sRound = axrev ? Math.floor : Math.ceil, - // add a tiny extra bit to make sure we get ticks - // that may have been rounded out - r0 = rng[0] * 1.0001 - rng[1] * 0.0001, - dtick = ax.dtick, - tick0 = r2l(ax.tick0); + var r2l = ax.r2l || Number; + var rng = Lib.simpleMap(ax.range, r2l); + var axrev = rng[1] < rng[0]; + var sRound = axrev ? Math.floor : Math.ceil; + // add a tiny extra bit to make sure we get ticks + // that may have been rounded out + var r0 = rng[0] * 1.0001 - rng[1] * 0.0001; + var dtick = ax.dtick; + var tick0 = r2l(ax.tick0); if(isNumeric(dtick)) { var tmin = sRound((r0 - tick0) / dtick) * dtick + tick0; // make sure no ticks outside the category list - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { tmin = Lib.constrain(tmin, 0, ax._categories.length - 1); } return tmin; } - var tType = dtick.charAt(0), - dtNum = Number(dtick.substr(1)); + var tType = dtick.charAt(0); + var dtNum = Number(dtick.substr(1)); // Dates: months (or years) if(tType === 'M') { - var cnt = 0, - t0 = tick0, - t1, - mult, - newDTick; + var cnt = 0; + var t0 = tick0; + var t1, mult, newDTick; // This algorithm should work for *any* nonlinear (but close to linear!) // tick spacing. Limit to 10 iterations, for gregorian months it's normally <=3. @@ -89081,16 +90232,18 @@ axes.tickFirst = function(ax) { // hover is a (truthy) flag for whether to show numbers with a bit // more precision for hovertext axes.tickText = function(ax, x, hover) { - var out = tickTextObj(ax, x), - hideexp, - arrayMode = ax.tickmode === 'array', - extraPrecision = hover || arrayMode, - i, - tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; + var out = tickTextObj(ax, x); + var arrayMode = ax.tickmode === 'array'; + var extraPrecision = hover || arrayMode; + var axType = ax.type; + // TODO multicategory, if we allow ticktext / tickvals + var tickVal2l = axType === 'category' ? ax.d2l_noadd : ax.d2l; + var i; if(arrayMode && Array.isArray(ax.ticktext)) { - var rng = Lib.simpleMap(ax.range, ax.r2l), - minDiff = Math.abs(rng[1] - rng[0]) / 10000; + var rng = Lib.simpleMap(ax.range, ax.r2l); + var minDiff = Math.abs(rng[1] - rng[0]) / 10000; + for(i = 0; i < ax.ticktext.length; i++) { if(Math.abs(x - tickVal2l(ax.tickvals[i])) < minDiff) break; } @@ -89101,28 +90254,25 @@ axes.tickText = function(ax, x, hover) { } function isHidden(showAttr) { - var first_or_last; - if(showAttr === undefined) return true; if(hover) return showAttr === 'none'; - first_or_last = { + var firstOrLast = { first: ax._tmin, last: ax._tmax }[showAttr]; - return showAttr !== 'all' && x !== first_or_last; + return showAttr !== 'all' && x !== firstOrLast; } - if(hover) { - hideexp = 'never'; - } else { - hideexp = ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - } + var hideexp = hover ? + 'never' : + ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - if(ax.type === 'date') formatDate(ax, out, hover, extraPrecision); - else if(ax.type === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); - else if(ax.type === 'category') formatCategory(ax, out); + if(axType === 'date') formatDate(ax, out, hover, extraPrecision); + else if(axType === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); + else if(axType === 'category') formatCategory(ax, out); + else if(axType === 'multicategory') formatMultiCategory(ax, out, hover); else if(isAngular(ax)) formatAngle(ax, out, hover, extraPrecision, hideexp); else formatLinear(ax, out, hover, extraPrecision, hideexp); @@ -89130,6 +90280,20 @@ axes.tickText = function(ax, x, hover) { if(ax.tickprefix && !isHidden(ax.showtickprefix)) out.text = ax.tickprefix + out.text; if(ax.ticksuffix && !isHidden(ax.showticksuffix)) out.text += ax.ticksuffix; + // Setup ticks and grid lines boundaries + // at 1/2 a 'category' to the left/bottom + if(ax.tickson === 'boundaries' || ax.showdividers) { + var inbounds = function(v) { + var p = ax.l2p(v); + return p >= 0 && p <= ax._length ? v : null; + }; + + out.xbnd = [ + inbounds(out.x - 0.5), + inbounds(out.x + ax.dtick - 0.5) + ]; + } + return out; }; @@ -89179,8 +90343,8 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround, - fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); + var tr = ax._tickround; + var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); if(extraPrecision) { // second or sub-second precision: extra always shows max digits. @@ -89189,8 +90353,8 @@ function formatDate(ax, out, hover, extraPrecision) { else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr]; } - var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat), - headStr; + var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat); + var headStr; var splitIndex = dateStr.indexOf('\n'); if(splitIndex !== -1) { @@ -89307,6 +90471,22 @@ function formatCategory(ax, out) { out.text = String(tt); } +function formatMultiCategory(ax, out, hover) { + var v = Math.round(out.x); + var cats = ax._categories[v] || []; + var tt = cats[1] === undefined ? '' : String(cats[1]); + var tt2 = cats[0] === undefined ? '' : String(cats[0]); + + if(hover) { + // TODO is this what we want? + out.text = tt2 + ' - ' + tt; + } else { + // setup for secondary labels + out.text = tt; + out.text2 = tt2; + } +} + function formatLinear(ax, out, hover, extraPrecision, hideexp) { if(hideexp === 'never') { // If this is a hover label, then we must *never* hide the exponent @@ -89412,14 +90592,13 @@ function beyondSI(exponent) { } function numFormat(v, ax, fmtoverride, hover) { - // negative? - var isNeg = v < 0, - // max number of digits past decimal point to show - tickRound = ax._tickround, - exponentFormat = fmtoverride || ax.exponentformat || 'B', - exponent = ax._tickexponent, - tickformat = axes.getTickFormat(ax), - separatethousands = ax.separatethousands; + var isNeg = v < 0; + // max number of digits past decimal point to show + var tickRound = ax._tickround; + var exponentFormat = fmtoverride || ax.exponentformat || 'B'; + var exponent = ax._tickexponent; + var tickformat = axes.getTickFormat(ax); + var separatethousands = ax.separatethousands; // special case for hover: set exponent just for this value, and // add a couple more digits of precision over tick labels @@ -89592,6 +90771,9 @@ axes.getTickFormat = function(ax) { // as an array of items like 'xy', 'x2y', 'x2y2'... // sorted by x (x,x2,x3...) then y // optionally restrict to only subplots containing axis object ax +// +// NOTE: this is currently only used OUTSIDE plotly.js (toolpanel, webapp) +// ideally we get rid of it there (or just copy this there) and remove it here axes.getSubplots = function(gd, ax) { var subplotObj = gd._fullLayout._subplots; var allSubplots = subplotObj.cartesian.concat(subplotObj.gl2d || []); @@ -89610,18 +90792,20 @@ axes.getSubplots = function(gd, ax) { }; // find all subplots with axis 'ax' +// NOTE: this is only used in axes.getSubplots (only used outside plotly.js) and +// gl2d/convert (where it restricts axis subplots to only those with gl2d) axes.findSubplotsWithAxis = function(subplots, ax) { var axMatch = new RegExp( (ax._id.charAt(0) === 'x') ? ('^' + ax._id + 'y') : (ax._id + '$') ); - var subplotsWithAxis = []; + var subplotsWithAx = []; for(var i = 0; i < subplots.length; i++) { var sp = subplots[i]; - if(axMatch.test(sp)) subplotsWithAxis.push(sp); + if(axMatch.test(sp)) subplotsWithAx.push(sp); } - return subplotsWithAxis; + return subplotsWithAx; }; // makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings @@ -89674,24 +90858,25 @@ axes.makeClipPaths = function(gd) { * * @param {DOM element} gd : graph div * @param {string or array of strings} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update + * @param {object} opts: + * - @param {boolean} skipTitle : optional flag to skip axis title draw/update * - * Signature 1: Axes.doTicks(gd, 'redraw') + * Signature 1: Axes.draw(gd, 'redraw') * use this to clear and redraw all axes on graph * - * Signature 2: Axes.doTicks(gd, '') + * Signature 2: Axes.draw(gd, '') * use this to draw all axes on graph w/o the selectAll().remove() * of the 'redraw' signature * - * Signature 3: Axes.doTicks(gd, [axId, axId2, ...]) + * Signature 3: Axes.draw(gd, [axId, axId2, ...]) * where the items are axis id string, * use this to update multiple axes in one call * - * N.B doTicks updates: + * N.B draw updates: * - ax._r (stored range for use by zoom/pan) * - ax._rl (stored linearized range for use by zoom/pan) */ -axes.doTicks = function(gd, arg, skipTitle) { +axes.draw = function(gd, arg, opts) { var fullLayout = gd._fullLayout; if(arg === 'redraw') { @@ -89703,6 +90888,8 @@ axes.doTicks = function(gd, arg, skipTitle) { plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove(); if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); @@ -89712,13 +90899,13 @@ axes.doTicks = function(gd, arg, skipTitle) { var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; - Lib.syncOrAsync(axList.map(function(axid) { + return Lib.syncOrAsync(axList.map(function(axId) { return function() { - if(!axid) return; + if(!axId) return; - var axDone = axes.doTicksSingle(gd, axid, skipTitle); + var ax = axes.getFromId(gd, axId); + var axDone = axes.drawOne(gd, ax, opts); - var ax = axes.getFromId(gd, axid); ax._r = ax.range.slice(); ax._rl = Lib.simpleMap(ax._r, ax.r2l); @@ -89728,684 +90915,1069 @@ axes.doTicks = function(gd, arg, skipTitle) { }; /** - * Per-axis drawing routine! - * - * This routine draws axis ticks and much more (... grids, labels, title etc.) - * Supports multiple argument signatures. - * N.B. this thing is async in general (because of MathJax rendering) - * - * @param {DOM element} gd : graph div - * @param {string or object} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * @return {promise} - * - * Signature 1: Axes.doTicks(gd, ax) - * where ax is an axis object as in fullLayout + * Draw one cartesian axis + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * @param {object} opts + * - @param {boolean} skipTitle (set to true to skip axis title draw call) + */ +axes.drawOne = function(gd, ax, opts) { + opts = opts || {}; + + var i, sp, plotinfo; + + ax.setScale(); + + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var counterLetter = axes.counterLetter(axId); + var mainSubplot = ax._mainSubplot; + var mainLinePosition = ax._mainLinePosition; + var mainMirrorPosition = ax._mainMirrorPosition; + var mainPlotinfo = fullLayout._plots[mainSubplot]; + var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; + var subplotsWithAx = ax._subplotsWith; + + var vals = ax._vals = axes.calcTicks(ax); + + // Add a couple of axis properties that should cause us to recreate + // elements. Used in d3 data function. + var axInfo = [ax.mirror, mainLinePosition, mainMirrorPosition].join('_'); + for(i = 0; i < vals.length; i++) { + vals[i].axInfo = axInfo; + } + + if(!ax.visible) return; + + // stash selections to avoid DOM queries e.g. + // - stash tickLabels selection, so that drawTitle can use it to scoot title + ax._selections = {}; + // stash tick angle (including the computed 'auto' values) per tick-label class + ax._tickAngles = {}; + + var transFn = axes.makeTransFn(ax); + var tickVals; + // We remove zero lines, grid lines, and inside ticks if they're within 1px of the end + // The key case here is removing zero lines when the axis bound is zero + var valsClipped; + + if(ax.tickson === 'boundaries') { + var boundaryVals = getBoundaryVals(ax, vals); + valsClipped = axes.clipEnds(ax, boundaryVals); + tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals; + } else { + valsClipped = axes.clipEnds(ax, vals); + tickVals = ax.ticks === 'inside' ? valsClipped : vals; + } + + var gridVals = ax._gridVals = valsClipped; + var dividerVals = getDividerVals(ax, vals); + + if(!fullLayout._hasOnlyLargeSploms) { + // keep track of which subplots (by main conteraxis) we've already + // drawn grids for, so we don't overdraw overlaying subplots + var finishedGrids = {}; + + for(i = 0; i < subplotsWithAx.length; i++) { + sp = subplotsWithAx[i]; + plotinfo = fullLayout._plots[sp]; + + var counterAxis = plotinfo[counterLetter + 'axis']; + var mainCounterID = counterAxis._mainAxis._id; + if(finishedGrids[mainCounterID]) continue; + finishedGrids[mainCounterID] = 1; + + var gridPath = axLetter === 'x' ? + 'M0,' + counterAxis._offset + 'v' + counterAxis._length : + 'M' + counterAxis._offset + ',0h' + counterAxis._length; + + axes.drawGrid(gd, ax, { + vals: gridVals, + counterAxis: counterAxis, + layer: plotinfo.gridlayer.select('.' + axId), + path: gridPath, + transFn: transFn + }); + axes.drawZeroLine(gd, ax, { + counterAxis: counterAxis, + layer: plotinfo.zerolinelayer, + path: gridPath, + transFn: transFn + }); + } + } + + var tickSigns = axes.getTickSigns(ax); + var tickSubplots = []; + + if(ax.ticks) { + var mainTickPath = axes.makeTickPath(ax, mainLinePosition, tickSigns[2]); + var mirrorTickPath; + var fullTickPath; + if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { + mirrorTickPath = axes.makeTickPath(ax, mainMirrorPosition, tickSigns[3]); + fullTickPath = mainTickPath + mirrorTickPath; + } else { + mirrorTickPath = ''; + fullTickPath = mainTickPath; + } + + var tickPath; + if(ax.showdividers && ax.ticks === 'outside' && ax.tickson === 'boundaries') { + var dividerLookup = {}; + for(i = 0; i < dividerVals.length; i++) { + dividerLookup[dividerVals[i].x] = 1; + } + tickPath = function(d) { + return dividerLookup[d.x] ? mirrorTickPath : fullTickPath; + }; + } else { + tickPath = fullTickPath; + } + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: mainAxLayer, + path: tickPath, + transFn: transFn + }); + + tickSubplots = Object.keys(ax._linepositions || {}); + } + + for(i = 0; i < tickSubplots.length; i++) { + sp = tickSubplots[i]; + plotinfo = fullLayout._plots[sp]; + // [bottom or left, top or right], free and main are handled above + var linepositions = ax._linepositions[sp] || []; + var spTickPath = axes.makeTickPath(ax, linepositions[0], tickSigns[0]) + + axes.makeTickPath(ax, linepositions[1], tickSigns[1]); + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: plotinfo[axLetter + 'axislayer'], + path: spTickPath, + transFn: transFn + }); + } + + var seq = []; + + // tick labels - for now just the main labels. + // TODO: mirror labels, esp for subplots + + seq.push(function() { + var labelFns = axes.makeLabelFns(ax, mainLinePosition); + return axes.drawLabels(gd, ax, { + vals: vals, + layer: mainAxLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn, + }); + }); + + if(ax.type === 'multicategory') { + var labelLength = 0; + var pad = {x: 2, y: 10}[axLetter]; + var sgn = tickSigns[2] * (ax.ticks === 'inside' ? -1 : 1); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick') + pad; + labelLength += ax._tickAngles[axId + 'tick'] ? ax.tickfont.size * LINE_SPACING : 0; + var secondaryPosition = mainLinePosition + labelLength * sgn; + var secondaryLabelFns = axes.makeLabelFns(ax, secondaryPosition); + + return axes.drawLabels(gd, ax, { + vals: getSecondaryLabelVals(ax, vals), + layer: mainAxLayer, + cls: axId + 'tick2', + repositionOnUpdate: true, + secondary: true, + transFn: transFn, + labelXFn: secondaryLabelFns.labelXFn, + labelYFn: secondaryLabelFns.labelYFn, + labelAnchorFn: secondaryLabelFns.labelAnchorFn, + }); + }); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick2'); + ax._labelLength = labelLength; + + return drawDividers(gd, ax, { + vals: dividerVals, + layer: mainAxLayer, + path: axes.makeTickPath(ax, mainLinePosition, sgn, labelLength), + transFn: transFn + }); + }); + } + + function extendRange(range, newRange) { + range[0] = Math.min(range[0], newRange[0]); + range[1] = Math.max(range[1], newRange[1]); + } + + function calcBoundingBox() { + if(ax.showticklabels) { + var gdBB = gd.getBoundingClientRect(); + var bBox = mainAxLayer.node().getBoundingClientRect(); + + /* + * the way we're going to use this, the positioning that matters + * is relative to the origin of gd. This is important particularly + * if gd is scrollable, and may have been scrolled between the time + * we calculate this and the time we use it + */ + + ax._boundingBox = { + width: bBox.width, + height: bBox.height, + left: bBox.left - gdBB.left, + right: bBox.right - gdBB.left, + top: bBox.top - gdBB.top, + bottom: bBox.bottom - gdBB.top + }; + } else { + var gs = fullLayout._size; + var pos; + + // set dummy bbox for ticklabel-less axes + + if(axLetter === 'x') { + pos = ax.anchor === 'free' ? + gs.t + gs.h * (1 - ax.position) : + gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); + + ax._boundingBox = { + top: pos, + bottom: pos, + left: ax._offset, + right: ax._offset + ax._length, + width: ax._length, + height: 0 + }; + } else { + pos = ax.anchor === 'free' ? + gs.l + gs.w * ax.position : + gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; + + ax._boundingBox = { + left: pos, + right: pos, + bottom: ax._offset + ax._length, + top: ax._offset, + height: ax._length, + width: 0 + }; + } + } + + /* + * for spikelines: what's the full domain of positions in the + * opposite direction that are associated with this axis? + * This means any axes that we make a subplot with, plus the + * position of the axis itself if it's free. + */ + if(subplotsWithAx) { + var fullRange = ax._counterSpan = [Infinity, -Infinity]; + + for(var i = 0; i < subplotsWithAx.length; i++) { + var plotinfo = fullLayout._plots[subplotsWithAx[i]]; + var counterAxis = plotinfo[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + + extendRange(fullRange, [ + counterAxis._offset, + counterAxis._offset + counterAxis._length + ]); + } + + if(ax.anchor === 'free') { + extendRange(fullRange, (axLetter === 'x') ? + [ax._boundingBox.bottom, ax._boundingBox.top] : + [ax._boundingBox.right, ax._boundingBox.left]); + } + } + } + + var hasRangeSlider = Registry.getComponentMethod('rangeslider', 'isVisible')(ax); + + function doAutoMargins() { + var push, rangeSliderPush; + + if(hasRangeSlider) { + rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); + } + Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); + + var s = ax.side.charAt(0); + if(ax.automargin && (!hasRangeSlider || s !== 'b')) { + push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + + if(axLetter === 'x') { + push.y = (ax.anchor === 'free' ? ax.position : + ax._anchorAxis.domain[s === 't' ? 1 : 0]); + push[s] += ax._boundingBox.height; + } else { + push.x = (ax.anchor === 'free' ? ax.position : + ax._anchorAxis.domain[s === 'r' ? 1 : 0]); + push[s] += ax._boundingBox.width; + } + + if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { + push[s] += ax.title.font.size; + } + } + + Plots.autoMargin(gd, axAutoMarginID(ax), push); + } + + seq.push(calcBoundingBox, doAutoMargins); + + if(!opts.skipTitle && + !(hasRangeSlider && ax._boundingBox && ax.side === 'bottom') + ) { + seq.push(function() { return drawTitle(gd, ax); }); + } + + return Lib.syncOrAsync(seq); +}; + +function getBoundaryVals(ax, vals) { + var out = []; + var i; + + // boundaryVals are never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; + + if(vals.length) { + for(i = 0; i < vals.length; i++) { + _push(vals[i], 0); + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getSecondaryLabelVals(ax, vals) { + var out = []; + var lookup = {}; + + for(var i = 0; i < vals.length; i++) { + var d = vals[i]; + if(lookup[d.text2]) { + lookup[d.text2].push(d.x); + } else { + lookup[d.text2] = [d.x]; + } + } + + for(var k in lookup) { + out.push(tickTextObj(ax, Lib.interp(lookup[k], 0.5), k)); + } + + return out; +} + +function getDividerVals(ax, vals) { + var out = []; + var i, current; + + // never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; + + if(ax.showdividers && vals.length) { + for(i = 0; i < vals.length; i++) { + var d = vals[i]; + if(d.text2 !== current) { + _push(d, 0); + } + current = d.text2; + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getLabelLevelSpan(ax, cls) { + var axLetter = ax._id.charAt(0); + var angle = ax._tickAngles[cls] || 0; + var rad = Lib.deg2rad(angle); + var sinA = Math.sin(rad); + var cosA = Math.cos(rad); + var maxX = 0; + var maxY = 0; + + // N.B. Drawing.bBox does not take into account rotate transforms + + ax._selections[cls].each(function() { + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + var w = bb.width; + var h = bb.height; + maxX = Math.max(maxX, cosA * w, sinA * h); + maxY = Math.max(maxY, sinA * w, cosA * h); + }); + + return {x: maxY, y: maxX}[axLetter]; +} + +/** + * Which direction do the 'ax.side' values, and free ticks go? + * + * @param {object} ax (full) axis object + * - {string} _id (starting with 'x' or 'y') + * - {string} side + * - {string} ticks + * @return {array} all entries are either -1 or 1 + * - [0]: sign for top/right ticks (i.e. negative SVG direction) + * - [1]: sign for bottom/left ticks (i.e. positive SVG direction) + * - [2]: sign for ticks corresponding to 'ax.side' + * - [3]: sign for ticks mirroring 'ax.side' + */ +axes.getTickSigns = function(ax) { + var axLetter = ax._id.charAt(0); + var sideOpposite = {x: 'top', y: 'right'}[axLetter]; + var main = ax.side === sideOpposite ? 1 : -1; + var out = [-1, 1, main, -main]; + // then we flip if outside XOR y axis + if((ax.ticks !== 'inside') === (axLetter === 'x')) { + out = out.map(function(v) { return -v; }); + } + return out; +}; + +/** + * Make axis translate transform function + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} _offset + * - {fn} l2p + * @return {fn} function of calcTicks items + */ +axes.makeTransFn = function(ax) { + var axLetter = ax._id.charAt(0); + var offset = ax._offset; + return axLetter === 'x' ? + function(d) { return 'translate(' + (offset + ax.l2p(d.x)) + ',0)'; } : + function(d) { return 'translate(0,' + (offset + ax.l2p(d.x)) + ')'; }; +}; + +/** + * Make axis tick path string * - * Signature 2: Axes.doTicks(gd, axId) - * where axId is a axis id string + * @param {object} ax (full) axis object + * - {string} _id + * - {number} ticklen + * - {number} linewidth + * @param {number} shift along direction of ticklen + * @param {1 or -1} sng tick sign + * @param {number (optional)} len tick length + * @return {string} */ -axes.doTicksSingle = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; - var independent = false; - var ax; +axes.makeTickPath = function(ax, shift, sgn, len) { + len = len !== undefined ? len : ax.ticklen; - if(Lib.isPlainObject(arg)) { - ax = arg; - independent = true; - } else { - ax = axes.getFromId(gd, arg); - } + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; - // set scaling to pixels - ax.setScale(); + return axLetter === 'x' ? + 'M0,' + (shift + pad * sgn) + 'v' + (len * sgn) : + 'M' + (shift + pad * sgn) + ',0h' + (len * sgn); +}; - var axid = ax._id; - var axLetter = axid.charAt(0); - var counterLetter = axes.counterLetter(axid); - var vals = ax._vals = axes.calcTicks(ax); - var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; - var tcls = axid + 'tick'; - var gcls = axid + 'grid'; - var zcls = axid + 'zl'; +/** + * Make axis tick label x, y and anchor functions + * + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} ticklen + * - {string} side + * - {number} linewidth + * - {number} tickfont.size + * - {boolean} showline + * @param {number} shift + * @param {number} angle [in degrees] ... + * @return {object} + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + * - {number} labelStandoff + * - {number} labelShift + */ +axes.makeLabelFns = function(ax, shift, angle) { + var axLetter = ax._id.charAt(0); var pad = (ax.linewidth || 1) / 2; - var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); + var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside'; + + var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0; var labelShift = 0; - var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); - var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); - var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); - var sides, transfn, tickpathfn, subplots; - var tickLabels; - var i; - if(ax._counterangle && ax.ticks === 'outside') { - var caRad = ax._counterangle * Math.PI / 180; - labelStandoff = ax.ticklen * Math.cos(caRad) + 1; - labelShift = ax.ticklen * Math.sin(caRad); + if(angle && ax.ticks === 'outside') { + var rad = Lib.deg2rad(angle); + labelStandoff = ax.ticklen * Math.cos(rad) + 1; + labelShift = ax.ticklen * Math.sin(rad); } - if(ax.showticklabels && (ax.ticks === 'outside' || ax.showline)) { + if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) { labelStandoff += 0.2 * ax.tickfont.size; } - // positioning arguments for x vs y axes + // Used in polar angular label x/y functions + // TODO generalize makeLabelFns so that it just work for angular axes + var out = { + labelStandoff: labelStandoff, + labelShift: labelShift + }; + + var x0, y0, ff, flipIt; if(axLetter === 'x') { - sides = ['bottom', 'top']; - transfn = ax._transfn || function(d) { - return 'translate(' + (ax._offset + ax.l2p(d.x)) + ',0)'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M0,' + shift + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len); - } - else return 'M0,' + shift + 'v' + len; - }; - } - else if(axLetter === 'y') { - sides = ['left', 'right']; - transfn = ax._transfn || function(d) { - return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M' + shift + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); - } - else return 'M' + shift + ',0h' + len; + flipIt = ax.side === 'bottom' ? 1 : -1; + x0 = labelShift * flipIt; + y0 = shift + (labelStandoff + pad) * flipIt; + ff = ax.side === 'bottom' ? 1 : -0.2; + + out.labelXFn = function(d) { return d.dx + x0; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * ff; }; + out.labelAnchorFn = function(a) { + if(!isNumeric(a) || a === 0 || a === 180) { + return 'middle'; + } + return (a * flipIt < 0) ? 'end' : 'start'; }; - } - else if(isAngular(ax)) { - sides = ['left', 'right']; - transfn = ax._transfn; - tickpathfn = function(shift, len) { - return 'M' + shift + ',0h' + len; + } else if(axLetter === 'y') { + flipIt = ax.side === 'right' ? 1 : -1; + x0 = labelStandoff + pad; + y0 = -labelShift * flipIt; + ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0; + + out.labelXFn = function(d) { return d.dx + shift + (x0 + d.fontSize * ff) * flipIt; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; }; + out.labelAnchorFn = function(a) { + if(isNumeric(a) && Math.abs(a) === 90) { + return 'middle'; + } + return ax.side === 'right' ? 'start' : 'end'; }; } - else { - Lib.warn('Unrecognized doTicks axis:', axid); - return; - } - var axside = ax.side || sides[0]; - // which direction do the side[0], side[1], and free ticks go? - // then we flip if outside XOR y axis - var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; - if((ax.ticks !== 'inside') === (axLetter === 'x')) { - ticksign = ticksign.map(function(v) { return -v; }); - } + return out; +}; - if(!ax.visible) return; +function tickDataFn(d) { + return [d.text, d.x, d.axInfo, d.font, d.fontSize, d.fontColor].join('_'); +} - if(ax._tickFilter) { - vals = vals.filter(ax._tickFilter); - } +/** + * Draw axis ticks + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} linewidth + * - {string} tickcolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawTicks = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'tick'; - // Remove zero lines, grid lines, and inside ticks if they're within - // 1 pixel of the end. - // The key case here is removing zero lines when the axis bound is zero. - // Don't clip angular values. - var valsClipped = ax._valsClipped = isAngular(ax) ? - vals : - vals.filter(function(d) { return clipEnds(ax, d.x); }); + var ticks = opts.layer.selectAll('path.' + cls) + .data(ax.ticks ? opts.vals : [], tickDataFn); + + ticks.exit().remove(); + + ticks.enter().append('path') + .classed(cls, 1) + .classed('ticks', 1) + .classed('crisp', opts.crisp !== false) + .call(Color.stroke, ax.tickcolor) + .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') + .attr('d', opts.path); + + ticks.attr('transform', opts.transFn); +}; - function drawTicks(container, tickpath) { - var ticks = container.selectAll('path.' + tcls) - .data(ax.ticks === 'inside' ? valsClipped : vals, datafn); +/** + * Draw axis grid + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showgrid + * - {string} gridcolor + * - {string} gridwidth + * - {boolean} zeroline + * - {string} type + * - {string} dtick + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * optional - only required if this axis supports zero lines + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawGrid = function(gd, ax, opts) { + opts = opts || {}; - if(tickpath && ax.ticks) { - ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) - .classed('crisp', 1) - .call(Color.stroke, ax.tickcolor) - .style('stroke-width', tickWidth + 'px') - .attr('d', tickpath); - ticks.attr('transform', transfn); - ticks.exit().remove(); + var cls = ax._id + 'grid'; + var vals = opts.vals; + var counterAx = opts.counterAxis; + if(ax.showgrid === false) { + vals = []; + } + else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + var isArrayMode = ax.tickmode === 'array'; + for(var i = 0; i < vals.length; i++) { + var xi = vals[i].x; + if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) { + vals = vals.slice(0, i).concat(vals.slice(i + 1)); + // In array mode you can in principle have multiple + // ticks at 0, so test them all. Otherwise once we found + // one we can stop. + if(isArrayMode) i--; + else break; + } } - else ticks.remove(); } - function drawLabels(container, position) { - // tick labels - for now just the main labels. - // TODO: mirror labels, esp for subplots - tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); + var grid = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); - if(!isNumeric(position)) { - tickLabels.remove(); - drawAxTitle(); - return; - } - if(!ax.showticklabels) { - tickLabels.remove(); - drawAxTitle(); - calcBoundingBox(); - return; - } + grid.exit().remove(); - var labelx, labely, labelanchor, labelpos0, flipit; - if(axLetter === 'x') { - flipit = (axside === 'bottom') ? 1 : -1; - labelx = function(d) { return d.dx + labelShift * flipit; }; - labelpos0 = position + (labelStandoff + pad) * flipit; - labely = function(d) { - return d.dy + labelpos0 + d.fontSize * - ((axside === 'bottom') ? 1 : -0.2); - }; - labelanchor = function(angle) { - if(!isNumeric(angle) || angle === 0 || angle === 180) { - return 'middle'; - } - return (angle * flipit < 0) ? 'end' : 'start'; - }; - } - else if(axLetter === 'y') { - flipit = (axside === 'right') ? 1 : -1; - labely = function(d) { - return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit; - }; - labelx = function(d) { - return d.dx + position + (labelStandoff + pad + - ((Math.abs(ax.tickangle) === 90) ? d.fontSize / 2 : 0)) * flipit; - }; - labelanchor = function(angle) { - if(isNumeric(angle) && Math.abs(angle) === 90) { - return 'middle'; - } - return axside === 'right' ? 'start' : 'end'; - }; - } - else if(isAngular(ax)) { - ax._labelShift = labelShift; - ax._labelStandoff = labelStandoff; - ax._pad = pad; - - labelx = ax._labelx; - labely = ax._labely; - labelanchor = ax._labelanchor; - } - - var maxFontSize = 0, - autoangle = 0, - labelsReady = []; - tickLabels.enter().append('g').classed(tcls, 1) - .append('text') - // only so tex has predictable alignment that we can - // alter later - .attr('text-anchor', 'middle') - .each(function(d) { - var thisLabel = d3.select(this), - newPromise = gd._promises.length; - thisLabel - .call(svgTextUtils.positionText, labelx(d), labely(d)) - .call(Drawing.font, d.font, d.fontSize, d.fontColor) - .text(d.text) - .call(svgTextUtils.convertToTspans, gd); - newPromise = gd._promises[newPromise]; - if(newPromise) { - // if we have an async label, we'll deal with that - // all here so take it out of gd._promises and - // instead position the label and promise this in - // labelsReady - labelsReady.push(gd._promises.pop().then(function() { - positionLabels(thisLabel, ax.tickangle); - })); - } - else { - // sync label: just position it now. - positionLabels(thisLabel, ax.tickangle); - } - }); - tickLabels.exit().remove(); + grid.enter().append('path') + .classed(cls, 1) + .classed('crisp', opts.crisp !== false); - tickLabels.each(function(d) { - maxFontSize = Math.max(maxFontSize, d.fontSize); - }); + ax._gw = Drawing.crispRound(gd, ax.gridwidth, 1); - if(isAngular(ax)) { - tickLabels.each(function(d) { - d3.select(this).select('text') - .call(svgTextUtils.positionText, labelx(d), labely(d)); - }); - } + grid.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.gridcolor || '#ddd') + .style('stroke-width', ax._gw + 'px'); - // How much to shift a multi-line label to center it vertically. - function getAnchorHeight(lineCount, lineHeight, angle) { - var h = (lineCount - 1) * lineHeight; - if(axLetter === 'x') { - if(angle < -60 || 60 < angle) { - return -0.5 * h; - } else if(axside === 'top') { - return -h; - } - } else { - angle *= axside === 'left' ? 1 : -1; - if(angle < -30) { - return -h; - } else if(angle < 30) { - return -0.5 * h; - } - } - return 0; - } - - function positionLabels(s, angle) { - s.each(function(d) { - var anchor = labelanchor(angle, d); - var thisLabel = d3.select(this), - mathjaxGroup = thisLabel.select('.text-math-group'), - transform = transfn.call(thisLabel.node(), d) + - ((isNumeric(angle) && +angle !== 0) ? - (' rotate(' + angle + ',' + labelx(d) + ',' + - (labely(d) - d.fontSize / 2) + ')') : - ''); - var anchorHeight = getAnchorHeight( - svgTextUtils.lineCount(thisLabel), - LINE_SPACING * d.fontSize, - isNumeric(angle) ? +angle : 0); - if(anchorHeight) { - transform += ' translate(0, ' + anchorHeight + ')'; - } - if(mathjaxGroup.empty()) { - thisLabel.select('text').attr({ - transform: transform, - 'text-anchor': anchor - }); - } - else { - var mjShift = - Drawing.bBox(mathjaxGroup.node()).width * - {end: -0.5, start: 0.5}[anchor]; - mathjaxGroup.attr('transform', transform + - (mjShift ? 'translate(' + mjShift + ',0)' : '')); - } - }); - } + if(typeof opts.path === 'function') grid.attr('d', opts.path); +}; - // make sure all labels are correctly positioned at their base angle - // the positionLabels call above is only for newly drawn labels. - // do this without waiting, using the last calculated angle to - // minimize flicker, then do it again when we know all labels are - // there, putting back the prescribed angle to check for overlaps. - positionLabels(tickLabels, ax._lastangle || ax.tickangle); - - function allLabelsReady() { - return labelsReady.length && Promise.all(labelsReady); - } - - function fixLabelOverlaps() { - positionLabels(tickLabels, ax.tickangle); - - // check for auto-angling if x labels overlap - // don't auto-angle at all for log axes with - // base and digit format - if(axLetter === 'x' && !isNumeric(ax.tickangle) && - (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')) { - var lbbArray = []; - tickLabels.each(function(d) { - var s = d3.select(this), - thisLabel = s.select('.text-math-group'), - x = ax.l2p(d.x); - if(thisLabel.empty()) thisLabel = s.select('text'); - - var bb = Drawing.bBox(thisLabel.node()); - - lbbArray.push({ - // ignore about y, just deal with x overlaps - top: 0, - bottom: 10, - height: 10, - left: x - bb.width / 2, - // impose a 2px gap - right: x + bb.width / 2 + 2, - width: bb.width + 2 - }); - }); - for(i = 0; i < lbbArray.length - 1; i++) { - if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { - // any overlap at all - set 30 degrees - autoangle = 30; - break; - } - } - if(autoangle) { - var tickspacing = Math.abs( - (vals[vals.length - 1].x - vals[0].x) * ax._m - ) / (vals.length - 1); - if(tickspacing < maxFontSize * 2.5) { - autoangle = 90; - } - positionLabels(tickLabels, autoangle); - } - ax._lastangle = autoangle; - } +/** + * Draw axis zero-line + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} zeroline + * - {number} zerolinewidth + * - {string} zerolinecolor + * - {number (optional)} _gridWidthCrispRound + * @param {object} opts + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawZeroLine = function(gd, ax, opts) { + opts = opts || opts; - // update the axis title - // (so it can move out of the way if needed) - // TODO: separate out scoot so we don't need to do - // a full redraw of the title (mostly relevant for MathJax) - drawAxTitle(); - return axid + ' done'; - } + var cls = ax._id + 'zl'; + var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis); - function calcBoundingBox() { - if(ax.showticklabels) { - var gdBB = gd.getBoundingClientRect(); - var bBox = container.node().getBoundingClientRect(); + var zl = opts.layer.selectAll('path.' + cls) + .data(show ? [{x: 0, id: ax._id}] : []); - /* - * the way we're going to use this, the positioning that matters - * is relative to the origin of gd. This is important particularly - * if gd is scrollable, and may have been scrolled between the time - * we calculate this and the time we use it - */ + zl.exit().remove(); - ax._boundingBox = { - width: bBox.width, - height: bBox.height, - left: bBox.left - gdBB.left, - right: bBox.right - gdBB.left, - top: bBox.top - gdBB.top, - bottom: bBox.bottom - gdBB.top - }; - } else { - var gs = fullLayout._size; - var pos; + zl.enter().append('path') + .classed(cls, 1) + .classed('zl', 1) + .classed('crisp', opts.crisp !== false) + .each(function() { + // use the fact that only one element can enter to trigger a sort. + // If several zerolines enter at the same time we will sort once per, + // but generally this should be a minimal overhead. + opts.layer.selectAll('path').sort(function(da, db) { + return axisIds.idSort(da.id, db.id); + }); + }); - // set dummy bbox for ticklabel-less axes + zl.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); +}; - if(axLetter === 'x') { - pos = ax.anchor === 'free' ? - gs.t + gs.h * (1 - ax.position) : - gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); - - ax._boundingBox = { - top: pos, - bottom: pos, - left: ax._offset, - right: ax._offset + ax._length, - width: ax._length, - height: 0 - }; +/** + * Draw axis tick labels + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showticklabels + * - {number} tickangle + * - {object (optional)} _selections + * - {object} (optional)} _tickAngles + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string (optional)} cls (node className) + * - {boolean} repositionOnUpdate (set to true to reposition update selection) + * - {boolean} secondary + * - {fn} transFn + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + */ +axes.drawLabels = function(gd, ax, opts) { + opts = opts || {}; + + var axId = ax._id; + var axLetter = axId.charAt(0); + var cls = opts.cls || axId + 'tick'; + var vals = opts.vals; + var labelXFn = opts.labelXFn; + var labelYFn = opts.labelYFn; + var labelAnchorFn = opts.labelAnchorFn; + var tickAngle = opts.secondary ? 0 : ax.tickangle; + var lastAngle = (ax._tickAngles || {})[cls]; + + var tickLabels = opts.layer.selectAll('g.' + cls) + .data(ax.showticklabels ? vals : [], tickDataFn); + + var labelsReady = []; + + tickLabels.enter().append('g') + .classed(cls, 1) + .append('text') + // only so tex has predictable alignment that we can + // alter later + .attr('text-anchor', 'middle') + .each(function(d) { + var thisLabel = d3.select(this); + var newPromise = gd._promises.length; + + thisLabel + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)) + .call(Drawing.font, d.font, d.fontSize, d.fontColor) + .text(d.text) + .call(svgTextUtils.convertToTspans, gd); + + if(gd._promises[newPromise]) { + // if we have an async label, we'll deal with that + // all here so take it out of gd._promises and + // instead position the label and promise this in + // labelsReady + labelsReady.push(gd._promises.pop().then(function() { + positionLabels(thisLabel, tickAngle); + })); } else { - pos = ax.anchor === 'free' ? - gs.l + gs.w * ax.position : - gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - - ax._boundingBox = { - left: pos, - right: pos, - bottom: ax._offset + ax._length, - top: ax._offset, - height: ax._length, - width: 0 - }; + // sync label: just position it now. + positionLabels(thisLabel, tickAngle); } - } - - /* - * for spikelines: what's the full domain of positions in the - * opposite direction that are associated with this axis? - * This means any axes that we make a subplot with, plus the - * position of the axis itself if it's free. - */ - if(subplots) { - var fullRange = ax._counterSpan = [Infinity, -Infinity]; + }); - for(i = 0; i < subplots.length; i++) { - var subplot = fullLayout._plots[subplots[i]]; - var counterAxis = subplot[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + tickLabels.exit().remove(); - extendRange(fullRange, [ - counterAxis._offset, - counterAxis._offset + counterAxis._length - ]); - } + if(opts.repositionOnUpdate) { + tickLabels.each(function(d) { + d3.select(this).select('text') + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)); + }); + } - if(ax.anchor === 'free') { - extendRange(fullRange, (axLetter === 'x') ? - [ax._boundingBox.bottom, ax._boundingBox.top] : - [ax._boundingBox.right, ax._boundingBox.left]); - } + // How much to shift a multi-line label to center it vertically. + function getAnchorHeight(lineCount, lineHeight, angle) { + var h = (lineCount - 1) * lineHeight; + if(axLetter === 'x') { + if(angle < -60 || 60 < angle) { + return -0.5 * h; + } else if(ax.side === 'top') { + return -h; } - - function extendRange(range, newRange) { - range[0] = Math.min(range[0], newRange[0]); - range[1] = Math.max(range[1], newRange[1]); + } else { + angle *= ax.side === 'left' ? 1 : -1; + if(angle < -30) { + return -h; + } else if(angle < 30) { + return -0.5 * h; } } + return 0; + } - function doAutoMargins() { - var pushKey = ax._name + '.automargin'; - if(axLetter !== 'x' && axLetter !== 'y') { return; } - if(!ax.automargin) { - Plots.autoMargin(gd, pushKey); - return; - } - - var s = ax.side[0]; - var push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + function positionLabels(s, angle) { + s.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + var anchor = labelAnchorFn(angle, d); + + var transform = opts.transFn.call(thisLabel.node(), d) + + ((isNumeric(angle) && +angle !== 0) ? + (' rotate(' + angle + ',' + labelXFn(d) + ',' + + (labelYFn(d) - d.fontSize / 2) + ')') : + ''); + + var anchorHeight = getAnchorHeight( + svgTextUtils.lineCount(thisLabel), + LINE_SPACING * d.fontSize, + isNumeric(angle) ? +angle : 0 + ); - if(axLetter === 'x') { - push.y = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 't' ? 1 : 0]); - push[s] += ax._boundingBox.height; - } - else { - push.x = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 'r' ? 1 : 0]); - push[s] += ax._boundingBox.width; + if(anchorHeight) { + transform += ' translate(0, ' + anchorHeight + ')'; } - if(ax.title !== fullLayout._dfltTitle[axLetter]) { - push[s] += ax.titlefont.size; + if(mathjaxGroup.empty()) { + thisLabel.select('text').attr({ + transform: transform, + 'text-anchor': anchor + }); + } else { + var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; + var mjShift = mjWidth * {end: -0.5, start: 0.5}[anchor]; + mathjaxGroup.attr('transform', transform + (mjShift ? 'translate(' + mjShift + ',0)' : '')); } + }); + } - Plots.autoMargin(gd, pushKey, push); - } + // make sure all labels are correctly positioned at their base angle + // the positionLabels call above is only for newly drawn labels. + // do this without waiting, using the last calculated angle to + // minimize flicker, then do it again when we know all labels are + // there, putting back the prescribed angle to check for overlaps. + positionLabels(tickLabels, lastAngle || tickAngle); - var done = Lib.syncOrAsync([ - allLabelsReady, - fixLabelOverlaps, - calcBoundingBox, - doAutoMargins - ]); - if(done && done.then) gd._promises.push(done); - return done; + function allLabelsReady() { + return labelsReady.length && Promise.all(labelsReady); } - function drawAxTitle() { - if(skipTitle) return; - - // now this only applies to regular cartesian axes; colorbars and - // others ALWAYS call doTicks with skipTitle=true so they can - // configure their own titles. + function fixLabelOverlaps() { + positionLabels(tickLabels, tickAngle); - // rangeslider takes over a bottom title so drop it here - if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; + var autoangle = null; - var avoid = { - selection: tickLabels, - side: ax.side - }; - var axLetter = axid.charAt(0); - var gs = gd._fullLayout._size; - var offsetBase = 1.5; - var fontSize = ax.titlefont.size; + // check for auto-angling if x labels overlap + // don't auto-angle at all for log axes with + // base and digit format + if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) && + (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D') + ) { + autoangle = 0; - var transform, counterAxis, x, y; + var maxFontSize = 0; + var lbbArray = []; + var i; - if(tickLabels.size()) { - var translation = Drawing.getTranslate(tickLabels.node().parentNode); - avoid.offsetLeft = translation.x; - avoid.offsetTop = translation.y; - } + tickLabels.each(function(d) { + maxFontSize = Math.max(maxFontSize, d.fontSize); + + var x = ax.l2p(d.x); + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + + lbbArray.push({ + // ignore about y, just deal with x overlaps + top: 0, + bottom: 10, + height: 10, + left: x - bb.width / 2, + // impose a 2px gap + right: x + bb.width / 2 + 2, + width: bb.width + 2 + }); + }); - var titleStandoff = 10 + fontSize * offsetBase + - (ax.linewidth ? ax.linewidth - 1 : 0); + if((ax.tickson === 'boundaries' || ax.showdividers) && !opts.secondary) { + var gap = 2; + if(ax.ticks) gap += ax.tickwidth / 2; - if(axLetter === 'x') { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + // TODO should secondary labels also fall into this fix-overlap regime? - x = ax._offset + ax._length / 2; + for(i = 0; i < lbbArray.length; i++) { + var xbnd = vals[i].xbnd; + var lbb = lbbArray[i]; + if( + (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || + (xbnd[1] !== null && (ax.l2p(xbnd[1]) - lbb.right) < gap) + ) { + autoangle = 90; + break; + } + } + } else { + var vLen = vals.length; + var tickSpacing = Math.abs((vals[vLen - 1].x - vals[0].x) * ax._m) / (vLen - 1); + var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory'; - if(ax.side === 'top') { - y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); - } - else { - y = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1.5 : 0.5); + // any overlap at all - set 30 degrees or 90 degrees + for(i = 0; i < lbbArray.length - 1; i++) { + if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { + autoangle = rotate90 ? 90 : 30; + break; + } + } } - y += counterAxis._offset; - - if(!avoid.side) avoid.side = 'bottom'; - } - else { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : - axisIds.getFromId(gd, ax.anchor); - y = ax._offset + ax._length / 2; - if(ax.side === 'right') { - x = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1 : 0.5); - } - else { - x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + if(autoangle) { + positionLabels(tickLabels, autoangle); } - x += counterAxis._offset; - - transform = {rotate: '-90', offset: 0}; - if(!avoid.side) avoid.side = 'left'; } - Titles.draw(gd, axid + 'title', { - propContainer: ax, - propName: ax._name + '.title', - placeholder: fullLayout._dfltTitle[axLetter], - avoid: avoid, - transform: transform, - attributes: {x: x, y: y, 'text-anchor': 'middle'} - }); - } - - function drawGrid(plotinfo, counteraxis) { - if(fullLayout._hasOnlyLargeSploms) return; - - var gridcontainer = plotinfo.gridlayer.selectAll('.' + axid); - var zlcontainer = plotinfo.zerolinelayer; - var gridpath = ax._gridpath || ((axLetter === 'x' ? - ('M0,' + counteraxis._offset + 'v') : - ('M' + counteraxis._offset + ',0h') - ) + counteraxis._length); - var grid = gridcontainer.selectAll('path.' + gcls) - .data((ax.showgrid === false) ? [] : valsClipped, datafn); - grid.enter().append('path').classed(gcls, 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function(d) { - if(ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - Math.abs(d.x) < ax.dtick / 100) { - d3.select(this).remove(); - } - }); - grid.attr('transform', transfn) - .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', gridWidth + 'px'); - if(typeof gridpath === 'function') grid.attr('d', gridpath); - grid.exit().remove(); - - // zero line - if(zlcontainer) { - var zlData = {x: 0, id: axid}; - var showZl = axes.shouldShowZeroLine(gd, ax, counteraxis); - var zl = zlcontainer.selectAll('path.' + zcls) - .data(showZl ? [zlData] : []); - zl.enter().append('path').classed(zcls, 1).classed('zl', 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function() { - // use the fact that only one element can enter to trigger a sort. - // If several zerolines enter at the same time we will sort once per, - // but generally this should be a minimal overhead. - zlcontainer.selectAll('path').sort(function(da, db) { - return axisIds.idSort(da.id, db.id); - }); - }); - zl.attr('transform', transfn) - .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', zeroLineWidth + 'px'); - zl.exit().remove(); + if(ax._tickAngles) { + ax._tickAngles[cls] = autoangle === null ? + (isNumeric(tickAngle) ? tickAngle : 0) : + autoangle; } } - if(independent) { - drawTicks(ax._axislayer, tickpathfn(ax._pos + pad * ticksign[2], ticksign[2] * ax.ticklen)); - if(ax._counteraxis) { - var fictionalPlotinfo = { - gridlayer: ax._gridlayer, - zerolinelayer: ax._zerolinelayer - }; - drawGrid(fictionalPlotinfo, ax._counteraxis); - } - return drawLabels(ax._axislayer, ax._pos); + if(ax._selections) { + ax._selections[cls] = tickLabels; } - else if(fullLayout._has('cartesian')) { - subplots = axes.getSubplots(gd, ax); - // keep track of which subplots (by main conteraxis) we've already - // drawn grids for, so we don't overdraw overlaying subplots - var finishedGrids = {}; + var done = Lib.syncOrAsync([allLabelsReady, fixLabelOverlaps]); + if(done && done.then) gd._promises.push(done); + return done; +}; - subplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; - var counterAxis = plotinfo[counterLetter + 'axis']; +/** + * Draw axis dividers + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} showdividers + * - {number} dividerwidth + * - {string} dividercolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {fn} path + * - {fn} transFn + */ +function drawDividers(gd, ax, opts) { + var cls = ax._id + 'divider'; + var vals = opts.vals; - var mainCounterID = counterAxis._mainAxis._id; - if(finishedGrids[mainCounterID]) return; - finishedGrids[mainCounterID] = 1; + var dividers = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); - drawGrid(plotinfo, counterAxis, subplot); - }); + dividers.exit().remove(); - var mainSubplot = ax._mainSubplot; - var mainPlotinfo = fullLayout._plots[mainSubplot]; - var tickSubplots = []; + dividers.enter().insert('path', ':first-child') + .classed(cls, 1) + .classed('crisp', 1) + .call(Color.stroke, ax.dividercolor) + .style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px'); - if(ax.ticks) { - var mainSign = ticksign[2]; - var tickpath = tickpathfn(ax._mainLinePosition + pad * mainSign, mainSign * ax.ticklen); - if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { - tickpath += tickpathfn(ax._mainMirrorPosition - pad * mainSign, -mainSign * ax.ticklen); - } - drawTicks(mainPlotinfo[axLetter + 'axislayer'], tickpath); + dividers + .attr('transform', opts.transFn) + .attr('d', opts.path); +} + +function drawTitle(gd, ax) { + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var gs = fullLayout._size; + var fontSize = ax.title.font.size; + + var titleStandoff; + if(ax.type === 'multicategory') { + titleStandoff = ax._labelLength; + } else { + var offsetBase = 1.5; + titleStandoff = 10 + fontSize * offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); + } + + var transform, counterAxis, x, y; + + if(axLetter === 'x') { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + x = ax._offset + ax._length / 2; - tickSubplots = Object.keys(ax._linepositions || {}); + if(ax.side === 'top') { + y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); + } else { + y = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1.5 : 0.5); } + y += counterAxis._offset; + } else { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : + axisIds.getFromId(gd, ax.anchor); - tickSubplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; + y = ax._offset + ax._length / 2; - var container = plotinfo[axLetter + 'axislayer']; + if(ax.side === 'right') { + x = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1 : 0.5); + } else { + x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + } + x += counterAxis._offset; - // [bottom or left, top or right] - // free and main are handled above - var linepositions = ax._linepositions[subplot] || []; + transform = {rotate: '-90', offset: 0}; + } - function tickPathSide(sidei) { - var tsign = ticksign[sidei]; - return tickpathfn(linepositions[sidei] + pad * tsign, tsign * ax.ticklen); - } + var avoid; - drawTicks(container, tickPathSide(0) + tickPathSide(1)); - }); + if(ax.type !== 'multicategory') { + var tickLabels = ax._selections[ax._id + 'tick']; - var mainContainer = mainPlotinfo[axLetter + 'axislayer']; + avoid = { + selection: tickLabels, + side: ax.side + }; - return drawLabels(mainContainer, ax._mainLinePosition); + if(tickLabels && tickLabels.node() && tickLabels.node().parentNode) { + var translation = Drawing.getTranslate(tickLabels.node().parentNode); + avoid.offsetLeft = translation.x; + avoid.offsetTop = translation.y; + } } -}; + + return Titles.draw(gd, axId + 'title', { + propContainer: ax, + propName: ax._name + '.title.text', + placeholder: fullLayout._dfltTitle[axLetter], + avoid: avoid, + transform: transform, + attributes: {x: x, y: y, 'text-anchor': 'middle'} + }); +} axes.shouldShowZeroLine = function(gd, ax, counterAxis) { var rng = Lib.simpleMap(ax.range, ax.r2l); @@ -90413,7 +91985,7 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { (rng[0] * rng[1] <= 0) && ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - ax._valsClipped.length && + ax._gridVals.length && ( clipEnds(ax, 0) || !anyCounterAxLineAtZero(gd, ax, counterAxis, rng) || @@ -90422,6 +91994,10 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { ); }; +axes.clipEnds = function(ax, vals) { + return vals.filter(function(d) { return clipEnds(ax, d.x); }); +}; + function clipEnds(ax, l) { var p = ax.l2p(l); return (p > 1 && p < ax._length - 1); @@ -90497,6 +92073,12 @@ function hasBarsOrFill(gd, ax) { return false; } +function selectTickLabel(gTick) { + var s = d3.select(gTick); + var mj = s.select('.text-math-group'); + return mj.empty() ? s.select('text') : mj; +} + /** * Find all margin pushers for 2D axes and reserve them for later use * Both label and rangeslider automargin calculations happen later so @@ -90511,14 +92093,17 @@ axes.allowAutoMargin = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; if(ax.automargin) { - Plots.allowAutoMargin(gd, ax._name + '.automargin'); + Plots.allowAutoMargin(gd, axAutoMarginID(ax)); } - if(ax.rangeslider && ax.rangeslider.visible) { - Plots.allowAutoMargin(gd, 'rangeslider' + ax._id); + if(Registry.getComponentMethod('rangeslider', 'isVisible')(ax)) { + Plots.allowAutoMargin(gd, rangeSliderAutoMarginID(ax)); } } }; +function axAutoMarginID(ax) { return ax._id + '.automargin'; } +function rangeSliderAutoMarginID(ax) { return ax._id + '.rangeslider'; } + // swap all the presentation attributes of the axes showing these traces axes.swap = function(gd, traces) { var axGroups = makeAxisGroups(gd, traces); @@ -90574,11 +92159,10 @@ function mergeAxisGroups(intoSet, fromSet) { } function swapAxisGroup(gd, xIds, yIds) { - var i, - j, - xFullAxes = [], - yFullAxes = [], - layout = gd.layout; + var xFullAxes = []; + var yFullAxes = []; + var layout = gd.layout; + var i, j; for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i])); for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i])); @@ -90591,12 +92175,12 @@ function swapAxisGroup(gd, xIds, yIds) { var numericTypes = ['linear', 'log']; for(i = 0; i < allAxKeys.length; i++) { - var keyi = allAxKeys[i], - xVal = xFullAxes[0][keyi], - yVal = yFullAxes[0][keyi], - allEqual = true, - coerceLinearX = false, - coerceLinearY = false; + var keyi = allAxKeys[i]; + var xVal = xFullAxes[0][keyi]; + var yVal = yFullAxes[0][keyi]; + var allEqual = true; + var coerceLinearX = false; + var coerceLinearY = false; if(keyi.charAt(0) === '_' || typeof xVal === 'function' || noSwapAttrs.indexOf(keyi) !== -1) { continue; @@ -90642,17 +92226,18 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes, dfltTitle) { // in case the value is the default for either axis, // look at the first axis in each list and see if // this key's value is undefined - var np = Lib.nestedProperty, - xVal = np(layout[xFullAxes[0]._name], key).get(), - yVal = np(layout[yFullAxes[0]._name], key).get(), - i; + var np = Lib.nestedProperty; + var xVal = np(layout[xFullAxes[0]._name], key).get(); + var yVal = np(layout[yFullAxes[0]._name], key).get(); + var i; + if(key === 'title') { // special handling of placeholder titles - if(xVal === dfltTitle.x) { - xVal = dfltTitle.y; + if(xVal && xVal.text === dfltTitle.x) { + xVal.text = dfltTitle.y; } - if(yVal === dfltTitle.y) { - yVal = dfltTitle.x; + if(yVal && yVal.text === dfltTitle.y) { + yVal.text = dfltTitle.x; } } @@ -90668,7 +92253,7 @@ function isAngular(ax) { return ax._id === 'angularaxis'; } -},{"../../components/color":376,"../../components/drawing":401,"../../components/titles":467,"../../constants/alignment":474,"../../constants/numerical":478,"../../lib":498,"../../lib/svg_text_utils":521,"../../plots/plots":589,"../../registry":597,"./autorange":543,"./axis_autotype":545,"./axis_ids":547,"./clean_ticks":549,"./layout_attributes":557,"./set_convert":563,"d3":82,"fast-isnumeric":91}],545:[function(_dereq_,module,exports){ +},{"../../components/color":375,"../../components/drawing":396,"../../components/titles":463,"../../constants/alignment":470,"../../constants/numerical":474,"../../lib":494,"../../lib/svg_text_utils":517,"../../plots/plots":585,"../../registry":593,"./autorange":539,"./axis_autotype":541,"./axis_ids":543,"./clean_ticks":545,"./layout_attributes":553,"./set_convert":559,"d3":82,"fast-isnumeric":91}],541:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90685,7 +92270,10 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var BADNUM = _dereq_('../../constants/numerical').BADNUM; -module.exports = function autoType(array, calendar) { +module.exports = function autoType(array, calendar, opts) { + opts = opts || {}; + + if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory'; if(moreDates(array, calendar)) return 'date'; if(category(array)) return 'category'; if(linearOK(array)) return 'linear'; @@ -90753,7 +92341,14 @@ function category(a) { return curvecats > curvenums * 2; } -},{"../../constants/numerical":478,"../../lib":498,"fast-isnumeric":91}],546:[function(_dereq_,module,exports){ +// very-loose requirements for multicategory, +// trace modules that should never auto-type to multicategory +// should be declared with 'noMultiCategory' +function multiCategory(a) { + return Lib.isArrayOrTypedArray(a[0]) && Lib.isArrayOrTypedArray(a[1]); +} + +},{"../../constants/numerical":474,"../../lib":494,"fast-isnumeric":91}],542:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90784,6 +92379,7 @@ var setConvert = _dereq_('./set_convert'); * outerTicks: boolean, should ticks default to outside? * showGrid: boolean, should gridlines be shown by default? * noHover: boolean, this axis doesn't support hover effects? + * noTickson: boolean, this axis doesn't support 'tickson' * data: the plot data, used to manage categories * bgColor: the plot background color, to calculate default gridline colors */ @@ -90824,8 +92420,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, // try to get default title from splom trace, fallback to graph-wide value var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter]; - coerce('title', dfltTitle); - Lib.coerceFont(coerce, 'titlefont', { + coerce('title.text', dfltTitle); + Lib.coerceFont(coerce, 'title.font', { family: font.family, size: Math.round(font.size * 1.2), color: dfltFontColor @@ -90845,10 +92441,29 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, if(options.automargin) coerce('automargin'); + var isMultiCategory = containerOut.type === 'multicategory'; + + if(!options.noTickson && + (containerOut.type === 'category' || isMultiCategory) && + (containerOut.ticks || containerOut.showgrid) + ) { + var ticksonDflt; + if(isMultiCategory) ticksonDflt = 'boundaries'; + coerce('tickson', ticksonDflt); + } + + if(isMultiCategory) { + var showDividers = coerce('showdividers'); + if(showDividers) { + coerce('dividercolor'); + coerce('dividerwidth'); + } + } + return containerOut; }; -},{"../../lib":498,"../../registry":597,"./category_order_defaults":548,"./layout_attributes":557,"./line_grid_defaults":559,"./set_convert":563,"./tick_label_defaults":564,"./tick_mark_defaults":565,"./tick_value_defaults":566}],547:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../registry":593,"./category_order_defaults":544,"./layout_attributes":553,"./line_grid_defaults":555,"./set_convert":559,"./tick_label_defaults":560,"./tick_mark_defaults":561,"./tick_value_defaults":562}],543:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90966,7 +92581,7 @@ exports.idSort = function(id1, id2) { return +(id1.substr(1) || 1) - +(id2.substr(1) || 1); }; -},{"../../registry":597,"./constants":550}],548:[function(_dereq_,module,exports){ +},{"../../registry":593,"./constants":546}],544:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91060,7 +92675,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],549:[function(_dereq_,module,exports){ +},{}],545:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91149,7 +92764,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":478,"../../lib":498,"fast-isnumeric":91}],550:[function(_dereq_,module,exports){ +},{"../../constants/numerical":474,"../../lib":494,"fast-isnumeric":91}],546:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91231,7 +92846,7 @@ module.exports = { } }; -},{"../../lib/regex":513}],551:[function(_dereq_,module,exports){ +},{"../../lib/regex":509}],547:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91385,7 +93000,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[scaleanchor] = 1; } -},{"../../lib":498,"./axis_ids":547}],552:[function(_dereq_,module,exports){ +},{"../../lib":494,"./axis_ids":543}],548:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91527,7 +93142,6 @@ exports.enforce = function enforceAxisConstraints(gd) { var getPad = makePadFn(ax); updateDomain(ax, factor); - ax.setScale(); var m = Math.abs(ax._m); var extremes = concatExtremes(gd, ax); var minArray = extremes.min; @@ -91594,9 +93208,10 @@ function updateDomain(ax, factor) { center + (inputDomain[0] - center) / factor, center + (inputDomain[1] - center) / factor ]; + ax.setScale(); } -},{"../../constants/alignment":474,"../../constants/numerical":478,"./autorange":543,"./axis_ids":547,"./scale_zoom":561}],553:[function(_dereq_,module,exports){ +},{"../../constants/alignment":470,"../../constants/numerical":474,"./autorange":539,"./axis_ids":543,"./scale_zoom":557}],549:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91618,6 +93233,7 @@ var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Fx = _dereq_('../../components/fx'); +var Axes = _dereq_('./axes'); var setCursor = _dereq_('../../lib/setcursor'); var dragElement = _dereq_('../../components/dragelement'); var FROM_TL = _dereq_('../../constants/alignment').FROM_TL; @@ -91626,7 +93242,6 @@ var redrawReglTraces = _dereq_('../../plot_api/subroutines').redrawReglTraces; var Plots = _dereq_('../plots'); -var doTicksSingle = _dereq_('./axes').doTicksSingle; var getFromId = _dereq_('./axis_ids').getFromId; var prepSelect = _dereq_('./select').prepSelect; var clearSelect = _dereq_('./select').clearSelect; @@ -91870,7 +93485,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { .on('edit', function(text) { var v = ax.d2r(text); if(v !== undefined) { - Registry.call('relayout', gd, attrStr, v); + Registry.call('_guiRelayout', gd, attrStr, v); } }); } @@ -92115,6 +93730,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { return; } + // prevent axis drawing from monkeying with margins until we're done + gd._fullLayout._replotting = true; + if(xActive === 'ew' || yActive === 'ns') { if(xActive) dragAxList(xaxes, dx); if(yActive) dragAxList(yaxes, dy); @@ -92218,8 +93836,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { updates = {}; for(i = 0; i < activeAxIds.length; i++) { var axId = activeAxIds[i]; - doTicksSingle(gd, axId, true); var ax = getFromId(gd, axId); + Axes.drawOne(gd, ax, {skipTitle: true}); updates[ax._name + '.range[0]'] = ax.range[0]; updates[ax._name + '.range[1]'] = ax.range[1]; } @@ -92311,7 +93929,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, attrs); } // dragTail - finish a drag event with a redraw @@ -92325,7 +93943,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // accumulated MathJax promises - wait for them before we relayout. Lib.syncOrAsync([ Plots.previousPromises, - function() { Registry.call('relayout', gd, updates); } + function() { + gd._fullLayout._replotting = false; + Registry.call('_guiRelayout', gd, updates); + } ], gd); } @@ -92783,7 +94404,7 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":376,"../../components/dragelement":398,"../../components/drawing":401,"../../components/fx":418,"../../constants/alignment":474,"../../lib":498,"../../lib/clear_gl_canvases":485,"../../lib/setcursor":517,"../../lib/svg_text_utils":521,"../../plot_api/subroutines":535,"../../registry":597,"../plots":589,"./axes":544,"./axis_ids":547,"./constants":550,"./scale_zoom":561,"./select":562,"d3":82,"has-passive-events":251,"tinycolor2":342}],554:[function(_dereq_,module,exports){ +},{"../../components/color":375,"../../components/dragelement":393,"../../components/drawing":396,"../../components/fx":414,"../../constants/alignment":470,"../../lib":494,"../../lib/clear_gl_canvases":482,"../../lib/setcursor":513,"../../lib/svg_text_utils":517,"../../plot_api/subroutines":531,"../../registry":593,"../plots":585,"./axes":540,"./axis_ids":543,"./constants":546,"./scale_zoom":557,"./select":558,"d3":82,"has-passive-events":251,"tinycolor2":341}],550:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92951,7 +94572,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":398,"../../components/fx":418,"../../lib/setcursor":517,"./constants":550,"./dragbox":553,"d3":82}],555:[function(_dereq_,module,exports){ +},{"../../components/dragelement":393,"../../components/fx":414,"../../lib/setcursor":513,"./constants":546,"./dragbox":549,"d3":82}],551:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93026,7 +94647,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":498,"../../registry":597}],556:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../registry":593}],552:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93291,7 +94912,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback // layers that allow `cliponaxis: false` if(className !== 'scatterlayer' && className !== 'barlayer') { - Drawing.setClipUrl(sel, plotinfo.layerClipId); + Drawing.setClipUrl(sel, plotinfo.layerClipId, gd); } }); @@ -93649,7 +95270,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":401,"../../constants/xmlns_namespaces":479,"../../lib":498,"../../registry":597,"../get_data":573,"../plots":589,"./attributes":542,"./axis_ids":547,"./constants":550,"./graph_interact":554,"./layout_attributes":557,"./layout_defaults":558,"./transition_axes":567,"d3":82}],557:[function(_dereq_,module,exports){ +},{"../../components/drawing":396,"../../constants/xmlns_namespaces":475,"../../lib":494,"../../registry":593,"../get_data":569,"../plots":585,"./attributes":538,"./axis_ids":543,"./constants":546,"./graph_interact":550,"./layout_attributes":553,"./layout_defaults":554,"./transition_axes":563,"d3":82}],553:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93684,21 +95305,24 @@ module.exports = { }, title: { - valType: 'string', - - editType: 'ticks', - + text: { + valType: 'string', + + editType: 'ticks', + + }, + font: fontAttrs({ + editType: 'ticks', + + }), + editType: 'ticks' }, - titlefont: fontAttrs({ - editType: 'ticks', - - }), type: { valType: 'enumerated', // '-' means we haven't yet run autotype or couldn't find any data // it gets turned into linear in gd._fullLayout but not copied back // to gd.data like the others are. - values: ['-', 'linear', 'log', 'date', 'category'], + values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', editType: 'calc', @@ -93827,6 +95451,14 @@ module.exports = { editType: 'ticks', + }, + tickson: { + valType: 'enumerated', + values: ['labels', 'boundaries'], + + dflt: 'labels', + editType: 'ticks', + }, mirror: { valType: 'enumerated', @@ -94080,6 +95712,30 @@ module.exports = { editType: 'ticks', }, + + showdividers: { + valType: 'boolean', + dflt: true, + + editType: 'ticks', + + }, + dividercolor: { + valType: 'color', + dflt: colorAttrs.defaultLine, + + editType: 'ticks', + + }, + dividerwidth: { + valType: 'number', + dflt: 1, + + editType: 'ticks', + + }, + // TODO dividerlen: that would override "to label base" length? + // positioning attributes // anchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -94161,6 +95817,12 @@ module.exports = { editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'calc', @@ -94170,11 +95832,21 @@ module.exports = { editType: 'ticks', - } + }, + title: { + valType: 'string', + + editType: 'ticks', + + }, + titlefont: fontAttrs({ + editType: 'ticks', + + }) } }; -},{"../../components/color/attributes":375,"../../components/drawing/attributes":400,"../../lib/extend":490,"../../plot_api/plot_template":534,"../font_attributes":571,"./constants":550}],558:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":374,"../../components/drawing/attributes":395,"../../lib/extend":487,"../../plot_api/plot_template":530,"../font_attributes":567,"./constants":546}],554:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94333,9 +96005,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; }); axLayoutOut._annIndices = []; axLayoutOut._shapeIndices = []; + axLayoutOut._subplotsWith = []; + axLayoutOut._counterAxes = []; // set up some private properties - axLayoutOut._name = axName; + axLayoutOut._name = axLayoutOut._attr = axName; var id = axLayoutOut._id = name2id(axName); var overlayableAxes = getOverlayableAxes(axLetter, axName); @@ -94353,6 +96027,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id] }; + coerce('uirevision', layoutOut.uirevision); + handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions); handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut); @@ -94414,11 +96090,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var anchoredAxis = layoutOut[id2name(axLayoutOut.anchor)]; - var fixedRangeDflt = ( - anchoredAxis && - anchoredAxis.rangeslider && - anchoredAxis.rangeslider.visible - ); + var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis); coerce('fixedrange', fixedRangeDflt); } @@ -94443,7 +96115,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } }; -},{"../../components/color":376,"../../lib":498,"../../plot_api/plot_template":534,"../../registry":597,"../layout_attributes":587,"./axis_defaults":546,"./axis_ids":547,"./constraint_defaults":551,"./layout_attributes":557,"./position_defaults":560,"./type_defaults":568}],559:[function(_dereq_,module,exports){ +},{"../../components/color":375,"../../lib":494,"../../plot_api/plot_template":530,"../../registry":593,"../layout_attributes":583,"./axis_defaults":542,"./axis_ids":543,"./constraint_defaults":547,"./layout_attributes":553,"./position_defaults":556,"./type_defaults":564}],555:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94508,7 +96180,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":375,"../../lib":498,"tinycolor2":342}],560:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":374,"../../lib":494,"tinycolor2":341}],556:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94592,7 +96264,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":498,"fast-isnumeric":91}],561:[function(_dereq_,module,exports){ +},{"../../lib":494,"fast-isnumeric":91}],557:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94620,7 +96292,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ]; }; -},{"../../constants/alignment":474}],562:[function(_dereq_,module,exports){ +},{"../../constants/alignment":470}],558:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95289,13 +96961,22 @@ function isOnlyOnePointSelected(searchTraces) { function updateSelectedState(gd, searchTraces, eventData) { var i, searchInfo, cd, trace; + // before anything else, update preGUI if necessary + for(i = 0; i < searchTraces.length; i++) { + var fullInputTrace = searchTraces[i].cd[0].trace._fullInput; + var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid]; + if(tracePreGUI.selectedpoints === undefined) { + tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null; + } + } + if(eventData) { var pts = eventData.points || []; for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; - trace.selectedpoints = []; - trace._input.selectedpoints = []; + trace._input.selectedpoints = trace._fullInput.selectedpoints = []; + if(trace._fullInput !== trace) trace.selectedpoints = []; } for(i = 0; i < pts.length; i++) { @@ -95305,10 +96986,14 @@ function updateSelectedState(gd, searchTraces, eventData) { if(pt.pointIndices) { [].push.apply(data.selectedpoints, pt.pointIndices); - [].push.apply(fullData.selectedpoints, pt.pointIndices); + if(trace._fullInput !== trace) { + [].push.apply(fullData.selectedpoints, pt.pointIndices); + } } else { data.selectedpoints.push(pt.pointIndex); - fullData.selectedpoints.push(pt.pointIndex); + if(trace._fullInput !== trace) { + fullData.selectedpoints.push(pt.pointIndex); + } } } } @@ -95317,6 +97002,9 @@ function updateSelectedState(gd, searchTraces, eventData) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; delete trace._input.selectedpoints; + if(trace._fullInput !== trace) { + delete trace._fullInput.selectedpoints; + } } } @@ -95394,7 +97082,7 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":376,"../../components/fx":418,"../../components/fx/helpers":415,"../../lib/clear_gl_canvases":485,"../../lib/polygon":510,"../../lib/throttle":522,"../../plot_api/subroutines":535,"../../registry":597,"./axis_ids":547,"./constants":550,"polybooljs":298}],563:[function(_dereq_,module,exports){ +},{"../../components/color":375,"../../components/fx":414,"../../components/fx/helpers":410,"../../lib/clear_gl_canvases":482,"../../lib/polygon":506,"../../lib/throttle":518,"../../plot_api/subroutines":531,"../../registry":593,"./axis_ids":543,"./constants":546,"polybooljs":298}],559:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95427,6 +97115,10 @@ function fromLog(v) { return Math.pow(10, v); } +function isValidCategory(v) { + return v !== null && v !== undefined; +} + /** * Define the conversion functions for an axis data is used in 5 ways: * @@ -95520,7 +97212,7 @@ module.exports = function setConvert(ax, fullLayout) { * a disconnect between the array and the index returned */ function setCategoryIndex(v) { - if(v !== null && v !== undefined) { + if(isValidCategory(v)) { if(ax._categoriesMap === undefined) { ax._categoriesMap = {}; } @@ -95539,14 +97231,58 @@ module.exports = function setConvert(ax, fullLayout) { return BADNUM; } + function setMultiCategoryIndex(arrayIn, len) { + var arrayOut = new Array(len); + var i; + + // [ [arrayIn[0][i], arrayIn[1][i]], for i .. len ] + var tmp = new Array(len); + // [ [cnt, {$cat: index}], for j .. arrayIn.length ] + var seen = [[0, {}], [0, {}]]; + + if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) { + for(i = 0; i < len; i++) { + var v0 = arrayIn[0][i]; + var v1 = arrayIn[1][i]; + if(isValidCategory(v0) && isValidCategory(v1)) { + tmp[i] = [v0, v1]; + if(!(v0 in seen[0][1])) { + seen[0][1][v0] = seen[0][0]++; + } + if(!(v1 in seen[1][1])) { + seen[1][1][v1] = seen[1][0]++; + } + } + } + + tmp.sort(function(a, b) { + var ind0 = seen[0][1]; + var d = ind0[a[0]] - ind0[b[0]]; + if(d) return d; + + var ind1 = seen[1][1]; + return ind1[a[1]] - ind1[b[1]]; + }); + } + + for(i = 0; i < len; i++) { + arrayOut[i] = setCategoryIndex(tmp[i]); + } + + return arrayOut; + } + function getCategoryIndex(v) { - // d2l/d2c variant that that won't add categories but will also - // allow numbers to be mapped to the linearized axis positions if(ax._categoriesMap) { - var index = ax._categoriesMap[v]; - if(index !== undefined) return index; + return ax._categoriesMap[v]; } + } + function getCategoryPosition(v) { + // d2l/d2c variant that that won't add categories but will also + // allow numbers to be mapped to the linearized axis positions + var index = getCategoryIndex(v); + if(index !== undefined) return index; if(isNumeric(v)) return +v; } @@ -95632,15 +97368,15 @@ module.exports = function setConvert(ax, fullLayout) { ax.d2c = ax.d2l = setCategoryIndex; ax.r2d = ax.c2d = ax.l2d = getCategoryName; - ax.d2r = ax.d2l_noadd = getCategoryIndex; + ax.d2r = ax.d2l_noadd = getCategoryPosition; ax.r2c = function(v) { - var index = getCategoryIndex(v); + var index = getCategoryPosition(v); return index !== undefined ? index : ax.fraction2r(0.5); }; ax.l2r = ax.c2r = ensureNumber; - ax.r2l = getCategoryIndex; + ax.r2l = getCategoryPosition; ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; ax.p2d = function(px) { return getCategoryName(p2l(px)); }; @@ -95652,6 +97388,34 @@ module.exports = function setConvert(ax, fullLayout) { return ensureNumber(v); }; } + else if(ax.type === 'multicategory') { + // N.B. multicategory axes don't define d2c and d2l, + // as 'data-to-calcdata' conversion needs to take into + // account all data array items as in ax.makeCalcdata. + + ax.r2d = ax.c2d = ax.l2d = getCategoryName; + ax.d2r = ax.d2l_noadd = getCategoryPosition; + + ax.r2c = function(v) { + var index = getCategoryPosition(v); + return index !== undefined ? index : ax.fraction2r(0.5); + }; + + ax.r2c_just_indices = getCategoryIndex; + + ax.l2r = ax.c2r = ensureNumber; + ax.r2l = getCategoryPosition; + + ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; + ax.p2d = function(px) { return getCategoryName(p2l(px)); }; + ax.r2p = ax.d2p; + ax.p2r = p2l; + + ax.cleanPos = function(v) { + if(Array.isArray(v) || (typeof v === 'string' && v !== '')) return v; + return ensureNumber(v); + }; + } // find the range value at the specified (linear) fraction of the axis ax.fraction2r = function(v) { @@ -95745,11 +97509,6 @@ module.exports = function setConvert(ax, fullLayout) { ax.setScale = function(usePrivateRange) { var gs = fullLayout._size; - // TODO cleaner way to handle this case - if(!ax._categories) ax._categories = []; - // Add a map to optimize the performance of category collection - if(!ax._categoriesMap) ax._categoriesMap = {}; - // make sure we have a domain (pull it in from the axis // this one is overlaying if necessary) if(ax.overlaying) { @@ -95804,7 +97563,7 @@ module.exports = function setConvert(ax, fullLayout) { if(axLetter in trace) { arrayIn = trace[axLetter]; - len = trace._length || arrayIn.length; + len = trace._length || Lib.minRowLength(arrayIn); if(Lib.isTypedArray(arrayIn) && (axType === 'linear' || axType === 'log')) { if(len === arrayIn.length) { @@ -95814,6 +97573,10 @@ module.exports = function setConvert(ax, fullLayout) { } } + if(axType === 'multicategory') { + return setMultiCategoryIndex(arrayIn, len); + } + arrayOut = new Array(len); for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); @@ -95890,7 +97653,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":478,"../../lib":498,"./axis_ids":547,"./constants":550,"d3":82,"fast-isnumeric":91}],564:[function(_dereq_,module,exports){ +},{"../../constants/numerical":474,"../../lib":494,"./axis_ids":543,"./constants":546,"d3":82,"fast-isnumeric":91}],560:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95991,7 +97754,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../lib":498,"../array_container_defaults":540,"./layout_attributes":557}],565:[function(_dereq_,module,exports){ +},{"../../lib":494,"../array_container_defaults":536,"./layout_attributes":553}],561:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96024,7 +97787,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":498,"./layout_attributes":557}],566:[function(_dereq_,module,exports){ +},{"../../lib":494,"./layout_attributes":553}],562:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96033,22 +97796,18 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); - module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { var tickmode; if(containerIn.tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; - } - else { - var tickmodeDefault = - Array.isArray(containerIn.tickvals) ? 'array' : + } else { + var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : containerIn.dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); @@ -96063,15 +97822,14 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe containerIn.dtick, axType); containerOut.tick0 = cleanTicks.tick0( containerIn.tick0, axType, containerOut.calendar, dtick); - } - else { + } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto'; else coerce('ticktext'); } }; -},{"./clean_ticks":549}],567:[function(_dereq_,module,exports){ +},{"./clean_ticks":545}],563:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96193,14 +97951,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo } function ticksAndAnnotations(xa, ya) { - var activeAxIds = [], - i; - - activeAxIds = [xa._id, ya._id]; + var activeAxIds = [xa._id, ya._id]; + var i; - for(i = 0; i < activeAxIds.length; i++) { - Axes.doTicksSingle(gd, activeAxIds[i], true); - } + Axes.drawOne(gd, xa, {skipTitle: true}); + Axes.drawOne(gd, ya, {skipTitle: true}); function redrawObjs(objArray, method, shortCircuit) { for(i = 0; i < objArray.length; i++) { @@ -96399,7 +98154,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo return Promise.resolve(); }; -},{"../../components/drawing":401,"../../registry":597,"./axes":544,"./constants":550,"d3":82}],568:[function(_dereq_,module,exports){ +},{"../../components/drawing":396,"../../registry":593,"./axes":540,"./constants":546,"d3":82}],564:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96410,7 +98165,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo 'use strict'; -var Registry = _dereq_('../../registry'); +var traceIs = _dereq_('../../registry').traceIs; var autoType = _dereq_('./axis_autotype'); /* @@ -96459,6 +98214,7 @@ function setAutoType(ax, data) { var calAttr = axLetter + 'calendar'; var calendar = d0[calAttr]; + var opts = {noMultiCategory: !traceIs(d0, 'cartesian') || traceIs(d0, 'noMultiCategory')}; var i; // check all boxes on this x axis to see @@ -96469,8 +98225,7 @@ function setAutoType(ax, data) { for(i = 0; i < data.length; i++) { var trace = data[i]; - if(!Registry.traceIs(trace, 'box-violin') || - (trace[axLetter + 'axis'] || axLetter) !== id) continue; + if(!traceIs(trace, 'box-violin') || (trace[axLetter + 'axis'] || axLetter) !== id) continue; if(trace[posLetter] !== undefined) boxPositions.push(trace[posLetter][0]); else if(trace.name !== undefined) boxPositions.push(trace.name); @@ -96479,7 +98234,7 @@ function setAutoType(ax, data) { if(trace[calAttr] !== calendar) calendar = undefined; } - ax.type = autoType(boxPositions, calendar); + ax.type = autoType(boxPositions, calendar, opts); } else if(d0.type === 'splom') { var dimensions = d0.dimensions; @@ -96487,13 +98242,13 @@ function setAutoType(ax, data) { for(i = 0; i < dimensions.length; i++) { var dim = dimensions[i]; if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) { - ax.type = autoType(dim.values, calendar); + ax.type = autoType(dim.values, calendar, opts); break; } } } else { - ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar); + ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -96524,9 +98279,9 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace), - isBox = Registry.traceIs(trace, 'box-violin'), - isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); + var posLetter = getBoxPosLetter(trace); + var isBox = traceIs(trace, 'box-violin'); + var isCandlestick = traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox && @@ -96537,7 +98292,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":597,"./axis_autotype":545}],569:[function(_dereq_,module,exports){ +},{"../../registry":593,"./axis_autotype":541}],565:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96961,7 +98716,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":498,"../registry":597}],570:[function(_dereq_,module,exports){ +},{"../lib":494,"../registry":593}],566:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97069,7 +98824,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { coerce('domain.y', dfltY); }; -},{"../lib/extend":490}],571:[function(_dereq_,module,exports){ +},{"../lib/extend":487}],567:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97134,7 +98889,7 @@ module.exports = function(opts) { return attrs; }; -},{}],572:[function(_dereq_,module,exports){ +},{}],568:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97180,7 +98935,7 @@ module.exports = { } }; -},{}],573:[function(_dereq_,module,exports){ +},{}],569:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97308,7 +99063,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":597,"./cartesian/constants":550}],574:[function(_dereq_,module,exports){ +},{"../registry":593,"./cartesian/constants":546}],570:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97582,7 +99337,7 @@ function createCamera(element, options) { return camera; } -},{"3d-view":11,"has-passive-events":251,"mouse-change":270,"mouse-event-offset":271,"mouse-wheel":273,"right-now":315}],575:[function(_dereq_,module,exports){ +},{"3d-view":11,"has-passive-events":251,"mouse-change":270,"mouse-event-offset":271,"mouse-wheel":273,"right-now":315}],571:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97724,7 +99479,7 @@ exports.updateFx = function(gd) { } }; -},{"../../components/fx/layout_attributes":419,"../../constants/xmlns_namespaces":479,"../../lib":498,"../../plot_api/edit_types":527,"../get_data":573,"./layout/attributes":576,"./layout/defaults":580,"./layout/layout_attributes":581,"./scene":585}],576:[function(_dereq_,module,exports){ +},{"../../components/fx/layout_attributes":415,"../../constants/xmlns_namespaces":475,"../../lib":494,"../../plot_api/edit_types":523,"../get_data":569,"./layout/attributes":572,"./layout/defaults":576,"./layout/layout_attributes":577,"./scene":581}],572:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97746,7 +99501,7 @@ module.exports = { } }; -},{}],577:[function(_dereq_,module,exports){ +},{}],573:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97762,7 +99517,6 @@ var axesAttrs = _dereq_('../../cartesian/layout_attributes'); var extendFlat = _dereq_('../../../lib/extend').extendFlat; var overrideAll = _dereq_('../../../plot_api/edit_types').overrideAll; - module.exports = overrideAll({ visible: axesAttrs.visible, showspikes: { @@ -97812,8 +99566,9 @@ module.exports = overrideAll({ categoryorder: axesAttrs.categoryorder, categoryarray: axesAttrs.categoryarray, title: axesAttrs.title, - titlefont: axesAttrs.titlefont, - type: axesAttrs.type, + type: extendFlat({}, axesAttrs.type, { + values: ['-', 'linear', 'log', 'date', 'category'] + }), autorange: axesAttrs.autorange, rangemode: axesAttrs.rangemode, range: axesAttrs.range, @@ -97852,10 +99607,14 @@ module.exports = overrideAll({ gridwidth: axesAttrs.gridwidth, zeroline: axesAttrs.zeroline, zerolinecolor: axesAttrs.zerolinecolor, - zerolinewidth: axesAttrs.zerolinewidth + zerolinewidth: axesAttrs.zerolinewidth, + _deprecated: { + title: axesAttrs._deprecated.title, + titlefont: axesAttrs._deprecated.titlefont + } }, 'plot', 'from-root'); -},{"../../../components/color":376,"../../../lib/extend":490,"../../../plot_api/edit_types":527,"../../cartesian/layout_attributes":557}],578:[function(_dereq_,module,exports){ +},{"../../../components/color":375,"../../../lib/extend":487,"../../../plot_api/edit_types":523,"../../cartesian/layout_attributes":553}],574:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97908,13 +99667,14 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) { letter: axName[0], data: options.data, showGrid: true, + noTickson: true, bgColor: options.bgColor, calendar: options.calendar }, options.fullLayout); coerce('gridcolor', colorMix(containerOut.color, options.bgColor, gridLightness).toRgbString()); - coerce('title', axName[0]); // shouldn't this be on-par with 2D? + coerce('title.text', axName[0]); // shouldn't this be on-par with 2D? containerOut.setScale = Lib.noop; @@ -97929,7 +99689,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) { } }; -},{"../../../lib":498,"../../../plot_api/plot_template":534,"../../cartesian/axis_defaults":546,"../../cartesian/type_defaults":568,"./axis_attributes":577,"tinycolor2":342}],579:[function(_dereq_,module,exports){ +},{"../../../lib":494,"../../../plot_api/plot_template":530,"../../cartesian/axis_defaults":542,"../../cartesian/type_defaults":564,"./axis_attributes":573,"tinycolor2":341}],575:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97941,7 +99701,6 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) { 'use strict'; -var convertHTMLToUnicode = _dereq_('../../../lib/html2unicode'); var str2RgbaArray = _dereq_('../../../lib/str2rgbarray'); var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis']; @@ -98016,11 +99775,11 @@ proto.merge = function(sceneLayout) { } // Axes labels - opts.labels[i] = convertHTMLToUnicode(axes.title); - if('titlefont' in axes) { - if(axes.titlefont.color) opts.labelColor[i] = str2RgbaArray(axes.titlefont.color); - if(axes.titlefont.family) opts.labelFont[i] = axes.titlefont.family; - if(axes.titlefont.size) opts.labelSize[i] = axes.titlefont.size; + opts.labels[i] = axes.title.text; + if('font' in axes.title) { + if(axes.title.font.color) opts.labelColor[i] = str2RgbaArray(axes.title.font.color); + if(axes.title.font.family) opts.labelFont[i] = axes.title.font.family; + if(axes.title.font.size) opts.labelSize[i] = axes.title.font.size; } // Lines @@ -98092,7 +99851,7 @@ function createAxesOptions(plotlyOptions) { module.exports = createAxesOptions; -},{"../../../lib/html2unicode":496,"../../../lib/str2rgbarray":520}],580:[function(_dereq_,module,exports){ +},{"../../../lib/str2rgbarray":516}],576:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98205,11 +99964,36 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) { sceneLayoutIn, sceneLayoutOut, opts ); - coerce('dragmode', opts.getDfltFromLayout('dragmode')); + var dragmode = opts.getDfltFromLayout('dragmode'); + + if(dragmode !== false) { + if(!dragmode) { + + dragmode = 'orbit'; + + if(sceneLayoutIn.camera && + sceneLayoutIn.camera.up) { + + var x = sceneLayoutIn.camera.up.x; + var y = sceneLayoutIn.camera.up.y; + var z = sceneLayoutIn.camera.up.z; + + if(!x || !y || !z) { + dragmode = 'turntable'; + } else if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) { + dragmode = 'turntable'; + } + } else { + dragmode = 'turntable'; + } + } + } + + coerce('dragmode', dragmode); coerce('hovermode', opts.getDfltFromLayout('hovermode')); } -},{"../../../components/color":376,"../../../lib":498,"../../../registry":597,"../../subplot_defaults":596,"./axis_defaults":578,"./layout_attributes":581}],581:[function(_dereq_,module,exports){ +},{"../../../components/color":375,"../../../lib":494,"../../../registry":593,"../../subplot_defaults":592,"./axis_defaults":574,"./layout_attributes":577}],577:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98320,7 +100104,6 @@ module.exports = { valType: 'enumerated', values: ['orbit', 'turntable', 'zoom', 'pan', false], - dflt: 'turntable', editType: 'plot', }, @@ -98331,6 +100114,12 @@ module.exports = { dflt: 'closest', editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'plot', @@ -98344,7 +100133,7 @@ module.exports = { } }; -},{"../../../lib":498,"../../../lib/extend":490,"../../domain":570,"./axis_attributes":577}],582:[function(_dereq_,module,exports){ +},{"../../../lib":494,"../../../lib/extend":487,"../../domain":566,"./axis_attributes":573}],578:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98396,7 +100185,7 @@ function createSpikeOptions(layout) { module.exports = createSpikeOptions; -},{"../../../lib/str2rgbarray":520}],583:[function(_dereq_,module,exports){ +},{"../../../lib/str2rgbarray":516}],579:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98414,7 +100203,6 @@ module.exports = computeTickMarks; var Axes = _dereq_('../../cartesian/axes'); var Lib = _dereq_('../../../lib'); -var convertHTMLToUnicode = _dereq_('../../../lib/html2unicode'); var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis']; @@ -98446,7 +100234,8 @@ function computeTickMarks(scene) { axes._length = (glRange[i].hi - glRange[i].lo) * glRange[i].pixelsPerDataUnit / scene.dataScale[i]; - if(Math.abs(axes._length) === Infinity) { + if(Math.abs(axes._length) === Infinity || + isNaN(axes._length)) { ticks[i] = []; } else { axes._input_range = axes.range.slice(); @@ -98471,7 +100260,11 @@ function computeTickMarks(scene) { var dataTicks = Axes.calcTicks(axes); for(var j = 0; j < dataTicks.length; ++j) { dataTicks[j].x = dataTicks[j].x * scene.dataScale[i]; - dataTicks[j].text = convertHTMLToUnicode(dataTicks[j].text); + + if(axes.type === 'date') { + dataTicks[j].text = + dataTicks[j].text.replace(/\/g, ' '); + } } ticks[i] = dataTicks; @@ -98493,7 +100286,7 @@ function computeTickMarks(scene) { scene.contourLevels = contourLevelsFromTicks(ticks); } -},{"../../../lib":498,"../../../lib/html2unicode":496,"../../cartesian/axes":544}],584:[function(_dereq_,module,exports){ +},{"../../../lib":494,"../../cartesian/axes":540}],580:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98527,7 +100320,7 @@ function project(camera, v) { module.exports = project; -},{}],585:[function(_dereq_,module,exports){ +},{}],581:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98699,7 +100492,7 @@ function render(scene) { scene.drawAnnotations(scene); } -function initializeGLPlot(scene, fullLayout, canvas, gl) { +function initializeGLPlot(scene, canvas, gl) { var gd = scene.graphDiv; var glplotOptions = { @@ -98848,7 +100641,7 @@ function Scene(options, fullLayout) { this.convertAnnotations = Registry.getComponentMethod('annotations3d', 'convert'); this.drawAnnotations = Registry.getComponentMethod('annotations3d', 'draw'); - if(!initializeGLPlot(this, fullLayout)) return; // todo check the necessity for this line + if(!initializeGLPlot(this)) return; // todo check the necessity for this line } var proto = Scene.prototype; @@ -98864,7 +100657,7 @@ proto.recoverContext = function() { requestAnimationFrame(tryRecover); return; } - if(!initializeGLPlot(scene, scene.fullLayout, canvas, gl)) { + if(!initializeGLPlot(scene, canvas, gl)) { Lib.error('Catastrophic and unrecoverable WebGL error. Context lost.'); return; } @@ -99231,10 +101024,10 @@ proto.setCamera = function setCamera(cameraData) { // save camera to user layout (i.e. gd.layout) proto.saveCamera = function saveCamera(layout) { - var cameraData = this.getCamera(), - cameraNestedProp = Lib.nestedProperty(layout, this.id + '.camera'), - cameraDataLastSave = cameraNestedProp.get(), - hasChanged = false; + var cameraData = this.getCamera(); + var cameraNestedProp = Lib.nestedProperty(layout, this.id + '.camera'); + var cameraDataLastSave = cameraNestedProp.get(); + var hasChanged = false; function same(x, y, i, j) { var vectors = ['up', 'center', 'eye'], @@ -99254,7 +101047,14 @@ proto.saveCamera = function saveCamera(layout) { } } - if(hasChanged) cameraNestedProp.set(cameraData); + if(hasChanged) { + cameraNestedProp.set(cameraData); + + var fullLayout = this.fullLayout; + var cameraFullNP = Lib.nestedProperty(fullLayout, this.id + '.camera'); + cameraFullNP.set(cameraData); + Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, cameraData); + } return hasChanged; }; @@ -99273,6 +101073,26 @@ proto.updateFx = function(dragmode, hovermode) { camera.mode = 'turntable'; camera.keyBindingMode = 'rotate'; + // The setter for camera.mode animates the transition to z-up, + // but only if we *don't* explicitly set z-up earlier via the + // relayout. So push `up` back to layout & fullLayout manually now. + var gd = this.graphDiv; + var fullLayout = gd._fullLayout; + var fullCamera = this.fullSceneLayout.camera; + var x = fullCamera.up.x; + var y = fullCamera.up.y; + var z = fullCamera.up.z; + // only push `up` back to (full)layout if it's going to change + if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) return; + + var attr = this.id + '.camera.up'; + var zUp = {x: 0, y: 0, z: 1}; + var edits = {}; + edits[attr] = zUp; + var layout = gd.layout; + Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, edits); + fullCamera.up = zUp; + Lib.nestedProperty(layout, attr).set(zUp); } else { // none rotation modes [pan or zoom] @@ -99349,7 +101169,7 @@ proto.setConvert = function() { module.exports = Scene; -},{"../../components/fx":418,"../../lib":498,"../../lib/show_no_webgl_msg":518,"../../lib/str2rgbarray":520,"../../plots/cartesian/axes":544,"../../registry":597,"./camera":574,"./layout/convert":579,"./layout/spikes":582,"./layout/tick_marks":583,"./project":584,"gl-plot3d":141,"has-passive-events":251,"webgl-context":357}],586:[function(_dereq_,module,exports){ +},{"../../components/fx":414,"../../lib":494,"../../lib/show_no_webgl_msg":514,"../../lib/str2rgbarray":516,"../../plots/cartesian/axes":540,"../../registry":593,"./camera":570,"./layout/convert":575,"./layout/spikes":578,"./layout/tick_marks":579,"./project":580,"gl-plot3d":141,"has-passive-events":251,"webgl-context":356}],582:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99370,7 +101190,7 @@ module.exports = function zip3(x, y, z, len) { return result; }; -},{}],587:[function(_dereq_,module,exports){ +},{}],583:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99383,6 +101203,9 @@ module.exports = function zip3(x, y, z, len) { var fontAttrs = _dereq_('./font_attributes'); var colorAttrs = _dereq_('../components/color/attributes'); +var colorscaleAttrs = _dereq_('../components/colorscale/layout_attributes'); +var padAttrs = _dereq_('./pad_attributes'); +var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', @@ -99395,15 +101218,71 @@ globalFont.color.dflt = colorAttrs.defaultLine; module.exports = { font: globalFont, title: { - valType: 'string', - - editType: 'layoutstyle', - + text: { + valType: 'string', + + editType: 'layoutstyle', + + }, + font: fontAttrs({ + editType: 'layoutstyle', + + }), + xref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + yref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + x: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.5, + + editType: 'layoutstyle', + + }, + y: { + valType: 'number', + min: 0, + max: 1, + dflt: 'auto', + + editType: 'layoutstyle', + + }, + xanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'left', 'center', 'right'], + + editType: 'layoutstyle', + + }, + yanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'top', 'middle', 'bottom'], + + editType: 'layoutstyle', + + }, + pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { + + }), + editType: 'layoutstyle' }, - titlefont: fontAttrs({ - editType: 'layoutstyle', - - }), autosize: { valType: 'boolean', @@ -99522,11 +101401,30 @@ module.exports = { editType: 'calc', }, + colorscale: colorscaleAttrs, datarevision: { valType: 'any', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editrevision: { + valType: 'any', + + editType: 'none', + + }, + selectionrevision: { + valType: 'any', + + editType: 'none', + }, template: { valType: 'any', @@ -99560,12 +101458,30 @@ module.exports = { editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'modebar' + }, + _deprecated: { + title: { + valType: 'string', + + editType: 'layoutstyle', + + }, + titlefont: fontAttrs({ + editType: 'layoutstyle', + + }) } }; -},{"../components/color/attributes":375,"./font_attributes":571}],588:[function(_dereq_,module,exports){ +},{"../components/color/attributes":374,"../components/colorscale/layout_attributes":388,"../lib/extend":487,"./font_attributes":567,"./pad_attributes":584}],584:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99576,42 +101492,51 @@ module.exports = { 'use strict'; -// This is used exclusively by components inside component arrays, -// hence the 'arraydraw' editType. If this ever gets used elsewhere -// we could generalize it as a function ala font_attributes -module.exports = { - t: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - r: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - b: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - l: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - editType: 'arraydraw' +/** + * Creates a set of padding attributes. + * + * @param {object} opts + * @param {string} editType: + * the editType for all pieces of this padding definition + * + * @return {object} attributes object containing {t, r, b, l} as specified + */ +module.exports = function(opts) { + var editType = opts.editType; + return { + t: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + r: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + b: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + l: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + editType: editType + }; }; -},{}],589:[function(_dereq_,module,exports){ +},{}],585:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100063,6 +101988,7 @@ plots.supplyDefaults = function(gd, opts) { for(i = 0; i < crossTraceDefaultsFuncs.length; i++) { crossTraceDefaultsFuncs[i](newFullData, newFullLayout); } + Registry.getComponentMethod('colorscale', 'crossTraceDefaults')(newFullData, newFullLayout); // turn on flag to optimize large splom-only graphs // mostly by omitting SVG layers during Cartesian.drawFramework @@ -100093,16 +102019,30 @@ plots.supplyDefaults = function(gd, opts) { // relink functions and _ attributes to promote consistency between plots relinkPrivateKeys(newFullLayout, oldFullLayout); - // TODO may return a promise - plots.doAutoMargin(gd); - - // set scale after auto margin routine - var axList = axisIDs.list(gd); - for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - ax.setScale(); + // For persisting GUI-driven changes in layout + // _preGUI and _tracePreGUI were already copied over in relinkPrivateKeys + if(!newFullLayout._preGUI) newFullLayout._preGUI = {}; + // track trace GUI changes by uid rather than by trace index + if(!newFullLayout._tracePreGUI) newFullLayout._tracePreGUI = {}; + var tracePreGUI = newFullLayout._tracePreGUI; + var uids = {}; + var uid; + for(uid in tracePreGUI) uids[uid] = 'old'; + for(i = 0; i < newFullData.length; i++) { + uid = newFullData[i]._fullInput.uid; + if(!uids[uid]) tracePreGUI[uid] = {}; + uids[uid] = 'new'; + } + for(uid in uids) { + if(uids[uid] === 'old') delete tracePreGUI[uid]; } + // set up containers for margin calculations + initMargins(newFullLayout); + + // collect and do some initial calculations for rangesliders + Registry.getComponentMethod('rangeslider', 'makeData')(newFullLayout); + // update object references in calcdata if(!skipUpdateCalc && oldCalcdata.length === newFullData.length) { plots.supplyDefaultsUpdateCalc(oldCalcdata, newFullData); @@ -100411,6 +102351,12 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa plotinfo.id = id; } + // add these axis ids to each others' subplot lists + xaxis._counterAxes.push(yaxis._id); + yaxis._counterAxes.push(xaxis._id); + xaxis._subplotsWith.push(id); + yaxis._subplotsWith.push(id); + // update x and y axis layout object refs plotinfo.xaxis = xaxis; plotinfo.yaxis = yaxis; @@ -100438,8 +102384,9 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // while we're at it, link overlaying axes to their main axes and // anchored axes to the axes they're anchored to var axList = axisIDs.list(mockGd, null, true); + var ax; for(i = 0; i < axList.length; i++) { - var ax = axList[i]; + ax = axList[i]; var mainAx = null; if(ax.overlaying) { @@ -100467,8 +102414,53 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa null : axisIDs.getFromId(mockGd, ax.anchor); } + + // finally, we can find the main subplot for each axis + // (on which the ticks & labels are drawn) + for(i = 0; i < axList.length; i++) { + ax = axList[i]; + ax._counterAxes.sort(axisIDs.idSort); + ax._subplotsWith.sort(Lib.subplotSort); + ax._mainSubplot = findMainSubplot(ax, newFullLayout); + } }; +function findMainSubplot(ax, fullLayout) { + var mockGd = {_fullLayout: fullLayout}; + + var isX = ax._id.charAt(0) === 'x'; + var anchorAx = ax._mainAxis._anchorAxis; + var mainSubplotID = ''; + var nextBestMainSubplotID = ''; + var anchorID = ''; + + // First try the main ID with the anchor + if(anchorAx) { + anchorID = anchorAx._mainAxis._id; + mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); + } + + // Then look for a subplot with the counteraxis overlaying the anchor + // If that fails just use the first subplot including this axis + if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { + mainSubplotID = ''; + + var counterIDs = ax._counterAxes; + for(var j = 0; j < counterIDs.length; j++) { + var counterPart = counterIDs[j]; + var id = isX ? (ax._id + counterPart) : (counterPart + ax._id); + if(!nextBestMainSubplotID) nextBestMainSubplotID = id; + var counterAx = axisIDs.getFromId(mockGd, counterPart); + if(anchorID && counterAx.overlaying === anchorID) { + mainSubplotID = id; + break; + } + } + } + + return mainSubplotID || nextBestMainSubplotID; +} + // This function clears any trace attributes with valType: color and // no set dflt filed in the plot schema. This is needed because groupby (which // is the only transform for which this currently applies) supplies parent @@ -100736,6 +102728,8 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac coerce('type'); coerce('name', layout._traceWord + ' ' + traceInIndex); + coerce('uirevision', layout.uirevision); + // we want even invisible traces to make their would-be subplots visible // so coerce the subplot id(s) now no matter what var _module = plots.getModule(traceOut); @@ -100809,7 +102803,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac if(_module) { _module.supplyDefaults(traceIn, traceOut, defaultColor, layout); - Lib.coerceHoverinfo(traceIn, traceOut, layout); + if(!traceOut.hovertemplate) Lib.coerceHoverinfo(traceIn, traceOut, layout); } if(!Registry.traceIs(traceOut, 'noOpacity')) coerce('opacity'); @@ -100938,14 +102932,25 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { var globalFont = Lib.coerceFont(coerce, 'font'); - coerce('title', layoutOut._dfltTitle.plot); + coerce('title.text', layoutOut._dfltTitle.plot); - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: globalFont.family, size: Math.round(globalFont.size * 1.4), color: globalFont.color }); + coerce('title.xref'); + coerce('title.yref'); + coerce('title.x'); + coerce('title.y'); + coerce('title.xanchor'); + coerce('title.yanchor'); + coerce('title.pad.t'); + coerce('title.pad.r'); + coerce('title.pad.b'); + coerce('title.pad.l'); + // Make sure that autosize is defaulted to *true* // on layouts with no set width and height for backward compatibly, // in particular https://plot.ly/javascript/responsive-fluid-layout/ @@ -100978,12 +102983,16 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('colorway'); coerce('datarevision'); + var uirevision = coerce('uirevision'); + coerce('editrevision', uirevision); + coerce('selectionrevision', uirevision); coerce('modebar.orientation'); coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); + coerce('modebar.uirevision', uirevision); Registry.getComponentMethod( 'calendars', @@ -101265,7 +103274,20 @@ plots.allowAutoMargin = function(gd, id) { gd._fullLayout._pushmarginIds[id] = 1; }; -function setupAutoMargin(fullLayout) { +function initMargins(fullLayout) { + var margin = fullLayout.margin; + + if(!fullLayout._size) { + var gs = fullLayout._size = { + l: Math.round(margin.l), + r: Math.round(margin.r), + t: Math.round(margin.t), + b: Math.round(margin.b), + p: Math.round(margin.pad) + }; + gs.w = Math.round(fullLayout.width) - gs.l - gs.r; + gs.h = Math.round(fullLayout.height) - gs.t - gs.b; + } if(!fullLayout._pushmargin) fullLayout._pushmargin = {}; if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {}; } @@ -101288,8 +103310,6 @@ function setupAutoMargin(fullLayout) { plots.autoMargin = function(gd, id, o) { var fullLayout = gd._fullLayout; - setupAutoMargin(fullLayout); - var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -101333,18 +103353,19 @@ plots.autoMargin = function(gd, id, o) { plots.doAutoMargin = function(gd) { var fullLayout = gd._fullLayout; if(!fullLayout._size) fullLayout._size = {}; - setupAutoMargin(fullLayout); + initMargins(fullLayout); - var gs = fullLayout._size, - oldmargins = JSON.stringify(gs); + var gs = fullLayout._size; + var oldmargins = JSON.stringify(gs); + var margin = fullLayout.margin; // adjust margins for outside components // fullLayout.margin is the requested margin, // fullLayout._size has margins and plotsize after adjustment - var ml = Math.max(fullLayout.margin.l || 0, 0); - var mr = Math.max(fullLayout.margin.r || 0, 0); - var mt = Math.max(fullLayout.margin.t || 0, 0); - var mb = Math.max(fullLayout.margin.b || 0, 0); + var ml = margin.l; + var mr = margin.r; + var mt = margin.t; + var mb = margin.b; var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -101414,7 +103435,7 @@ plots.doAutoMargin = function(gd) { gs.r = Math.round(mr); gs.t = Math.round(mt); gs.b = Math.round(mb); - gs.p = Math.round(fullLayout.margin.pad); + gs.p = Math.round(margin.pad); gs.w = Math.round(fullLayout.width) - gs.l - gs.r; gs.h = Math.round(fullLayout.height) - gs.t - gs.b; @@ -102295,7 +104316,7 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl subplot.traceHash = traceHash; }; -},{"../components/color":376,"../constants/numerical":478,"../lib":498,"../plot_api/plot_schema":533,"../plot_api/plot_template":534,"../plots/cartesian/axis_ids":547,"../registry":597,"./animation_attributes":539,"./attributes":541,"./command":569,"./font_attributes":571,"./frame_attributes":572,"./layout_attributes":587,"d3":82,"fast-isnumeric":91}],590:[function(_dereq_,module,exports){ +},{"../components/color":375,"../constants/numerical":474,"../lib":494,"../plot_api/plot_schema":529,"../plot_api/plot_template":530,"../plots/cartesian/axis_ids":543,"../registry":593,"./animation_attributes":535,"./attributes":537,"./command":565,"./font_attributes":567,"./frame_attributes":568,"./layout_attributes":583,"d3":82,"fast-isnumeric":91}],586:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102339,7 +104360,7 @@ module.exports = { } }; -},{"../../../lib/extend":490,"../../../traces/scatter/attributes":619}],591:[function(_dereq_,module,exports){ +},{"../../../lib/extend":487,"../../../traces/scatter/attributes":615}],587:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102461,7 +104482,7 @@ module.exports = overrideAll({ } }, 'plot', 'nested'); -},{"../../../lib/extend":490,"../../../plot_api/edit_types":527,"../../cartesian/layout_attributes":557}],592:[function(_dereq_,module,exports){ +},{"../../../lib/extend":487,"../../../plot_api/edit_types":523,"../../cartesian/layout_attributes":553}],588:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102476,7 +104497,7 @@ var Polar = module.exports = _dereq_('./micropolar'); Polar.manager = _dereq_('./micropolar_manager'); -},{"./micropolar":593,"./micropolar_manager":594}],593:[function(_dereq_,module,exports){ +},{"./micropolar":589,"./micropolar_manager":590}],589:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102694,8 +104715,8 @@ var µ = module.exports = { version: '0.2.2' }; centeringOffset[0] = Math.max(0, centeringOffset[0]); centeringOffset[1] = Math.max(0, centeringOffset[1]); svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title); + if (axisConfig.title && axisConfig.title.text) { + var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); var titleBBox = title.node().getBBox(); title.attr({ x: chartCenter[0] - titleBBox.width / 2, @@ -103896,7 +105917,7 @@ var µ = module.exports = { version: '0.2.2' }; return exports; }; -},{"../../../constants/alignment":474,"../../../lib":498,"d3":82}],594:[function(_dereq_,module,exports){ +},{"../../../constants/alignment":470,"../../../lib":494,"d3":82}],590:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103982,7 +106003,7 @@ manager.fillLayout = function(_gd) { _gd._fullLayout = extendDeepAll(dflts, _gd.layout); }; -},{"../../../components/color":376,"../../../lib":498,"./micropolar":593,"./undo_manager":595,"d3":82}],595:[function(_dereq_,module,exports){ +},{"../../../components/color":375,"../../../lib":494,"./micropolar":589,"./undo_manager":591,"d3":82}],591:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104048,7 +106069,7 @@ module.exports = function UndoManager() { }; }; -},{}],596:[function(_dereq_,module,exports){ +},{}],592:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104118,6 +106139,12 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o subplotLayoutOut = Template.newContainer(layoutOut, id, baseId); + // All subplot containers get a `uirevision` inheriting from the base. + // Currently all subplots containers have some user interaction + // attributes, but if we ever add one that doesn't, we would need an + // option to skip this step. + coerce('uirevision', layoutOut.uirevision); + var dfltDomains = {}; dfltDomains[partition] = [i / idsLength, (i + 1) / idsLength]; handleDomainDefaults(subplotLayoutOut, layoutOut, coerce, dfltDomains); @@ -104127,7 +106154,7 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o } }; -},{"../lib":498,"../plot_api/plot_template":534,"./domain":570}],597:[function(_dereq_,module,exports){ +},{"../lib":494,"../plot_api/plot_template":530,"./domain":566}],593:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104569,7 +106596,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/extend":490,"./lib/is_plain_object":499,"./lib/loggers":502,"./lib/noop":507,"./lib/push_unique":511,"./plots/attributes":541,"./plots/layout_attributes":587}],598:[function(_dereq_,module,exports){ +},{"./lib/extend":487,"./lib/is_plain_object":495,"./lib/loggers":498,"./lib/noop":503,"./lib/push_unique":507,"./plots/attributes":537,"./plots/layout_attributes":583}],594:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104596,7 +106623,7 @@ function cloneLayoutOverride(tileClass) { autosize: true, width: 150, height: 150, - title: '', + title: {text: ''}, showlegend: false, margin: {l: 5, r: 5, t: 5, b: 5, pad: 0}, annotations: [] @@ -104605,7 +106632,7 @@ function cloneLayoutOverride(tileClass) { case 'thumbnail': override = { - title: '', + title: {text: ''}, hidesources: true, showlegend: false, borderwidth: 0, @@ -104653,7 +106680,7 @@ module.exports = function clonePlot(graphObj, options) { for(i = 0; i < keys.length; i++) { if(keyIsAxis(keys[i])) { - newLayout[keys[i]].title = ''; + newLayout[keys[i]].title = {text: ''}; } } @@ -104681,7 +106708,7 @@ module.exports = function clonePlot(graphObj, options) { var axesImageOverride = {}; if(options.tileClass === 'thumbnail') { axesImageOverride = { - title: '', + title: {text: ''}, showaxeslabels: false, showticklabels: false, linetickenable: false @@ -104743,7 +106770,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":498}],599:[function(_dereq_,module,exports){ +},{"../lib":494}],595:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104811,7 +106838,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":498,"../plot_api/to_image":537,"./filesaver":600}],600:[function(_dereq_,module,exports){ +},{"../lib":494,"../plot_api/to_image":533,"./filesaver":596}],596:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104883,7 +106910,7 @@ var fileSaver = function(url, name) { module.exports = fileSaver; -},{}],601:[function(_dereq_,module,exports){ +},{}],597:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104920,7 +106947,7 @@ exports.getRedrawFunc = function(gd) { }; }; -},{}],602:[function(_dereq_,module,exports){ +},{}],598:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104946,7 +106973,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":598,"./download":599,"./helpers":601,"./svgtoimg":603,"./toimage":604,"./tosvg":605}],603:[function(_dereq_,module,exports){ +},{"./cloneplot":594,"./download":595,"./helpers":597,"./svgtoimg":599,"./toimage":600,"./tosvg":601}],599:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105062,7 +107089,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":498,"events":48}],604:[function(_dereq_,module,exports){ +},{"../lib":494,"events":48}],600:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105141,7 +107168,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":498,"../registry":597,"./cloneplot":598,"./helpers":601,"./svgtoimg":603,"./tosvg":605,"events":48}],605:[function(_dereq_,module,exports){ +},{"../lib":494,"../registry":593,"./cloneplot":594,"./helpers":597,"./svgtoimg":599,"./tosvg":601,"events":48}],601:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105323,7 +107350,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":376,"../components/drawing":401,"../constants/xmlns_namespaces":479,"../lib":498,"d3":82}],606:[function(_dereq_,module,exports){ +},{"../components/color":375,"../components/drawing":396,"../constants/xmlns_namespaces":475,"../lib":494,"d3":82}],602:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105477,7 +107504,7 @@ attrs.transforms = undefined; module.exports = attrs; -},{"../../components/colorbar/attributes":377,"../../components/colorscale/attributes":383,"../../lib/extend":490,"../../plots/attributes":541,"../mesh3d/attributes":611}],607:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":376,"../../components/colorscale/attributes":382,"../../lib/extend":487,"../../plots/attributes":537,"../mesh3d/attributes":607}],603:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105514,10 +107541,14 @@ module.exports = function calc(gd, trace) { trace._len = len; trace._normMax = normMax; - colorscaleCalc(trace, [normMin, normMax], '', 'c'); + colorscaleCalc(gd, trace, { + vals: [normMin, normMax], + containerStr: '', + cLetter: 'c' + }); }; -},{"../../components/colorscale/calc":384}],608:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":383}],604:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105662,7 +107693,7 @@ function createConeTrace(scene, data) { module.exports = createConeTrace; -},{"../../lib":498,"../../lib/gl_format_color":495,"../../plots/gl3d/zip3":586,"gl-cone3d":105}],609:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../lib/gl_format_color":492,"../../plots/gl3d/zip3":582,"gl-cone3d":105}],605:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105722,7 +107753,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/colorscale/defaults":386,"../../lib":498,"./attributes":606}],610:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":385,"../../lib":494,"./attributes":602}],606:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105753,7 +107784,7 @@ module.exports = { } }; -},{"../../plots/gl3d":575,"./attributes":606,"./calc":607,"./convert":608,"./defaults":609}],611:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":571,"./attributes":602,"./calc":603,"./convert":604,"./defaults":605}],607:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105919,7 +107950,7 @@ colorscaleAttrs('', { hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {editType: 'calc'}) }); -},{"../../components/colorbar/attributes":377,"../../components/colorscale/attributes":383,"../../lib/extend":490,"../../plots/attributes":541,"../surface/attributes":657}],612:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":376,"../../components/colorscale/attributes":382,"../../lib/extend":487,"../../plots/attributes":537,"../surface/attributes":653}],608:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -105934,11 +107965,15 @@ var colorscaleCalc = _dereq_('../../components/colorscale/calc'); module.exports = function calc(gd, trace) { if(trace.intensity) { - colorscaleCalc(trace, trace.intensity, '', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.intensity, + containerStr: '', + cLetter: 'c' + }); } }; -},{"../../components/colorscale/calc":384}],613:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":383}],609:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106089,7 +108124,7 @@ function createMesh3DTrace(scene, data) { module.exports = createMesh3DTrace; -},{"../../lib/gl_format_color":495,"../../lib/str2rgbarray":520,"../../plots/gl3d/zip3":586,"alpha-shape":16,"convex-hull":73,"delaunay-triangulate":84,"gl-mesh3d":139}],614:[function(_dereq_,module,exports){ +},{"../../lib/gl_format_color":492,"../../lib/str2rgbarray":516,"../../plots/gl3d/zip3":582,"alpha-shape":16,"convex-hull":73,"delaunay-triangulate":84,"gl-mesh3d":139}],610:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106185,7 +108220,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/colorscale/defaults":386,"../../lib":498,"../../registry":597,"./attributes":611}],615:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":385,"../../lib":494,"../../registry":593,"./attributes":607}],611:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106218,7 +108253,7 @@ Mesh3D.meta = { module.exports = Mesh3D; -},{"../../plots/gl3d":575,"./attributes":611,"./calc":612,"./convert":613,"./defaults":614}],616:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":571,"./attributes":607,"./calc":608,"./convert":609,"./defaults":610}],612:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106260,7 +108295,7 @@ exports.castOption = function castOption(item, indices) { else if(item) return item; }; -},{"../../lib":498}],617:[function(_dereq_,module,exports){ +},{"../../lib":494}],613:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106284,7 +108319,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":376,"./helpers":616}],618:[function(_dereq_,module,exports){ +},{"../../components/color":375,"./helpers":612}],614:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106336,7 +108371,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":498}],619:[function(_dereq_,module,exports){ +},{"../../lib":494}],615:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106347,6 +108382,7 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -106458,6 +108494,9 @@ module.exports = { editType: 'style', }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), line: { color: { valType: 'color', @@ -106732,7 +108771,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":377,"../../components/colorscale/attributes":383,"../../components/drawing":401,"../../components/drawing/attributes":400,"../../lib/extend":490,"../../plots/font_attributes":571,"./constants":623}],620:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":376,"../../components/colorscale/attributes":382,"../../components/drawing":396,"../../components/drawing/attributes":395,"../../components/fx/hovertemplate_attributes":413,"../../lib/extend":487,"../../plots/font_attributes":567,"./constants":619}],616:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106822,7 +108861,7 @@ function calc(gd, trace) { } arraysToCalcdata(cd, trace); - calcColorscale(trace); + calcColorscale(gd, trace); calcSelection(cd, trace); if(stackGroupOpts) { @@ -107022,7 +109061,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":478,"../../lib":498,"../../plots/cartesian/axes":544,"./arrays_to_calcdata":618,"./calc_selection":621,"./colorscale_calc":622,"./subtypes":643,"fast-isnumeric":91}],621:[function(_dereq_,module,exports){ +},{"../../constants/numerical":474,"../../lib":494,"../../plots/cartesian/axes":540,"./arrays_to_calcdata":614,"./calc_selection":617,"./colorscale_calc":618,"./subtypes":639,"fast-isnumeric":91}],617:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107041,7 +109080,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":498}],622:[function(_dereq_,module,exports){ +},{"../../lib":494}],618:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107050,31 +109089,41 @@ module.exports = function calcSelection(cd, trace) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var subTypes = _dereq_('./subtypes'); - -module.exports = function calcMarkerColorscale(trace) { +module.exports = function calcMarkerColorscale(gd, trace) { if(subTypes.hasLines(trace) && hasColorscale(trace, 'line')) { - calcColorscale(trace, trace.line.color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } if(subTypes.hasMarkers(trace)) { if(hasColorscale(trace, 'marker')) { - calcColorscale(trace, trace.marker.color, 'marker', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - calcColorscale(trace, trace.marker.line.color, 'marker.line', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } } }; -},{"../../components/colorscale/calc":384,"../../components/colorscale/has_colorscale":390,"./subtypes":643}],623:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":383,"../../components/colorscale/helpers":386,"./subtypes":639}],619:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107098,10 +109147,12 @@ module.exports = { // number of viewport sizes away from the visible region // at which we clip all lines to the perimeter - maxScreensAway: 20 + maxScreensAway: 20, + + eventDataKeys: [] }; -},{}],624:[function(_dereq_,module,exports){ +},{}],620:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107284,7 +109335,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":620}],625:[function(_dereq_,module,exports){ +},{"./calc":616}],621:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107323,7 +109374,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],626:[function(_dereq_,module,exports){ +},{}],622:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107401,7 +109452,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout dfltHoverOn.push('fills'); } coerce('hoveron', dfltHoverOn.join('+') || 'points'); - + if(traceOut.hoveron !== 'fills') coerce('hovertemplate'); var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults'); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'}); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'}); @@ -107409,7 +109460,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":498,"../../registry":597,"./attributes":619,"./constants":623,"./fillcolor_defaults":628,"./line_defaults":632,"./line_shape_defaults":634,"./marker_defaults":638,"./stack_defaults":641,"./subtypes":643,"./text_defaults":644,"./xy_defaults":645}],627:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../registry":593,"./attributes":615,"./constants":619,"./fillcolor_defaults":624,"./line_defaults":628,"./line_shape_defaults":630,"./marker_defaults":634,"./stack_defaults":637,"./subtypes":639,"./text_defaults":640,"./xy_defaults":641}],623:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107452,7 +109503,7 @@ function isValid(v) { return v || v === 0; } -},{"../../lib":498}],628:[function(_dereq_,module,exports){ +},{"../../lib":494}],624:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107490,7 +109541,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":376,"../../lib":498}],629:[function(_dereq_,module,exports){ +},{"../../components/color":375,"../../lib":494}],625:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107543,7 +109594,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":376,"./subtypes":643}],630:[function(_dereq_,module,exports){ +},{"../../components/color":375,"./subtypes":639}],626:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107639,7 +109690,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { y1: yc + rad, yLabelVal: yLabelVal, - spikeDistance: dxy(di) + spikeDistance: dxy(di), + hovertemplate: trace.hovertemplate }); fillHoverText(di, trace, pointData); @@ -107723,7 +109775,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { x1: xmax, y0: yAvg, y1: yAvg, - color: color + color: color, + hovertemplate: '%{name}' }); delete pointData.index; @@ -107738,7 +109791,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":376,"../../components/fx":418,"../../lib":498,"../../registry":597,"./fill_hover_text":627,"./get_trace_color":629}],631:[function(_dereq_,module,exports){ +},{"../../components/color":375,"../../components/fx":414,"../../lib":494,"../../registry":593,"./fill_hover_text":623,"./get_trace_color":625}],627:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107785,7 +109838,7 @@ Scatter.meta = { module.exports = Scatter; -},{"../../plots/cartesian":556,"./arrays_to_calcdata":618,"./attributes":619,"./calc":620,"./cross_trace_calc":624,"./cross_trace_defaults":625,"./defaults":626,"./hover":630,"./marker_colorbar":637,"./plot":639,"./select":640,"./style":642,"./subtypes":643}],632:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":552,"./arrays_to_calcdata":614,"./attributes":615,"./calc":616,"./cross_trace_calc":620,"./cross_trace_defaults":621,"./defaults":622,"./hover":626,"./marker_colorbar":633,"./plot":635,"./select":636,"./style":638,"./subtypes":639}],628:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107797,7 +109850,7 @@ module.exports = Scatter; 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) { @@ -107816,7 +109869,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":386,"../../components/colorscale/has_colorscale":390,"../../lib":498}],633:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":385,"../../components/colorscale/helpers":386,"../../lib":494}],629:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108281,7 +110334,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":478,"../../lib":498,"./constants":623}],634:[function(_dereq_,module,exports){ +},{"../../constants/numerical":474,"../../lib":494,"./constants":619}],630:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108300,7 +110353,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],635:[function(_dereq_,module,exports){ +},{}],631:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108393,7 +110446,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],636:[function(_dereq_,module,exports){ +},{}],632:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108435,7 +110488,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":91}],637:[function(_dereq_,module,exports){ +},{"fast-isnumeric":91}],633:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108453,7 +110506,7 @@ module.exports = { max: 'cmax' }; -},{}],638:[function(_dereq_,module,exports){ +},{}],634:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108462,11 +110515,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var subTypes = _dereq_('./subtypes'); @@ -108536,7 +110588,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":376,"../../components/colorscale/defaults":386,"../../components/colorscale/has_colorscale":390,"./subtypes":643}],639:[function(_dereq_,module,exports){ +},{"../../components/color":375,"../../components/colorscale/defaults":385,"../../components/colorscale/helpers":386,"./subtypes":639}],635:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108627,7 +110679,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition function createFills(gd, traceJoin, plotinfo) { traceJoin.each(function(d) { var fills = ensureSingle(d3.select(this), 'g', 'fills'); - Drawing.setClipUrl(fills, plotinfo.layerClipId); + Drawing.setClipUrl(fills, plotinfo.layerClipId, gd); var trace = d[0].trace; @@ -108679,7 +110731,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition var text = ensureSingle(tr, 'g', 'text'); // error bars are at the bottom - Registry.getComponentMethod('errorbars', 'plot')(errorBarGroup, plotinfo, transitionOpts); + Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts); if(trace.visible !== true) return; @@ -108834,7 +110886,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.lineGroupStyle) .each(makeUpdate(true)); - Drawing.setClipUrl(lineJoin, plotinfo.layerClipId); + Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd); function clearFill(selection) { transition(selection).attr('d', 'M0,0Z'); @@ -109062,8 +111114,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = trace.cliponaxis === false; var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId; - Drawing.setClipUrl(points, clipUrl); - Drawing.setClipUrl(text, clipUrl); + Drawing.setClipUrl(points, clipUrl, gd); + Drawing.setClipUrl(text, clipUrl, gd); } function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { @@ -109108,7 +111160,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":401,"../../lib":498,"../../lib/polygon":510,"../../registry":597,"./line_points":633,"./link_traces":635,"./subtypes":643,"d3":82}],640:[function(_dereq_,module,exports){ +},{"../../components/drawing":396,"../../lib":494,"../../lib/polygon":506,"../../registry":593,"./line_points":629,"./link_traces":631,"./subtypes":639,"d3":82}],636:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109163,7 +111215,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":643}],641:[function(_dereq_,module,exports){ +},{"./subtypes":639}],637:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109269,7 +111321,7 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],642:[function(_dereq_,module,exports){ +},{}],638:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109341,7 +111393,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":401,"../../registry":597,"d3":82}],643:[function(_dereq_,module,exports){ +},{"../../components/drawing":396,"../../registry":593,"d3":82}],639:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109380,7 +111432,7 @@ module.exports = { } }; -},{"../../lib":498}],644:[function(_dereq_,module,exports){ +},{"../../lib":494}],640:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109410,7 +111462,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":498}],645:[function(_dereq_,module,exports){ +},{"../../lib":494}],641:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109419,34 +111471,32 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var Lib = _dereq_('../../lib'); var Registry = _dereq_('../../registry'); - module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { - var len, - x = coerce('x'), - y = coerce('y'); + var x = coerce('x'); + var y = coerce('y'); + var len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); if(x) { + var xlen = Lib.minRowLength(x); if(y) { - len = Math.min(x.length, y.length); - } - else { - len = x.length; + len = Math.min(xlen, Lib.minRowLength(y)); + } else { + len = xlen; coerce('y0'); coerce('dy'); } - } - else { + } else { if(!y) return 0; - len = traceOut.y.length; + len = Lib.minRowLength(y); coerce('x0'); coerce('dx'); } @@ -109456,7 +111506,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../registry":597}],646:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../registry":593}],642:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109587,7 +111637,7 @@ var attrs = module.exports = overrideAll({ colorAttributes('marker') ), - textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center', arrayOk: false}), + textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}), textfont: { color: scatterAttrs.textfont.color, size: scatterAttrs.textfont.size, @@ -109599,7 +111649,7 @@ var attrs = module.exports = overrideAll({ attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes'; -},{"../../components/colorscale/attributes":383,"../../constants/gl3d_dashes":475,"../../constants/gl3d_markers":476,"../../lib/extend":490,"../../plot_api/edit_types":527,"../../plots/attributes":541,"../scatter/attributes":619}],647:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":382,"../../constants/gl3d_dashes":471,"../../constants/gl3d_markers":472,"../../lib/extend":487,"../../plot_api/edit_types":523,"../../plots/attributes":537,"../scatter/attributes":615}],643:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109611,8 +111661,7 @@ attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes'; 'use strict'; var arraysToCalcdata = _dereq_('../scatter/arrays_to_calcdata'); -var calcColorscales = _dereq_('../scatter/colorscale_calc'); - +var calcColorscale = _dereq_('../scatter/colorscale_calc'); /** * This is a kludge to put the array attributes into @@ -109623,12 +111672,12 @@ module.exports = function calc(gd, trace) { var cd = [{x: false, y: false, trace: trace, t: {}}]; arraysToCalcdata(cd, trace); - calcColorscales(trace); + calcColorscale(gd, trace); return cd; }; -},{"../scatter/arrays_to_calcdata":618,"../scatter/colorscale_calc":622}],648:[function(_dereq_,module,exports){ +},{"../scatter/arrays_to_calcdata":614,"../scatter/colorscale_calc":618}],644:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109715,7 +111764,7 @@ function calculateErrors(data, scaleFactor, sceneLayout) { module.exports = calculateErrors; -},{"../../registry":597}],649:[function(_dereq_,module,exports){ +},{"../../registry":593}],645:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109851,14 +111900,47 @@ function calculateErrorParams(errors) { return {capSize: capSize, color: color, lineWidth: lineWidth}; } +function parseAlignmentX(a) { + if(a === null || a === undefined) return 0; + + return (a.indexOf('left') > -1) ? -1 : + (a.indexOf('right') > -1) ? 1 : 0; +} + +function parseAlignmentY(a) { + if(a === null || a === undefined) return 0; + + return (a.indexOf('top') > -1) ? -1 : + (a.indexOf('bottom') > -1) ? 1 : 0; +} + function calculateTextOffset(tp) { // Read out text properties - var textOffset = [0, 0]; - if(Array.isArray(tp)) return [0, -1]; - if(tp.indexOf('bottom') >= 0) textOffset[1] += 1; - if(tp.indexOf('top') >= 0) textOffset[1] -= 1; - if(tp.indexOf('left') >= 0) textOffset[0] -= 1; - if(tp.indexOf('right') >= 0) textOffset[0] += 1; + + var defaultAlignmentX = 0; + var defaultAlignmentY = 0; + + var textOffset = [ + defaultAlignmentX, + defaultAlignmentY + ]; + + if(Array.isArray(tp)) { + for(var i = 0; i < tp.length; i++) { + textOffset[i] = [ + defaultAlignmentX, + defaultAlignmentY + ]; + if(tp[i]) { + textOffset[i][0] = parseAlignmentX(tp[i]); + textOffset[i][1] = parseAlignmentY(tp[i]); + } + } + } else { + textOffset[0] = parseAlignmentX(tp); + textOffset[1] = parseAlignmentY(tp); + } + return textOffset; } @@ -109951,7 +112033,7 @@ function convertPlotlyOptions(scene, data) { } if('textposition' in data) { - params.textOffset = calculateTextOffset(data.textposition); // arrayOk === false + params.textOffset = calculateTextOffset(data.textposition); params.textColor = formatColor(data.textfont, 1, len); params.textSize = formatParam(data.textfont.size, len, Lib.identity, 12); params.textFont = data.textfont.family; // arrayOk === false @@ -110191,7 +112273,7 @@ function createLineWithMarkers(scene, data) { module.exports = createLineWithMarkers; -},{"../../constants/gl3d_dashes":475,"../../constants/gl3d_markers":476,"../../lib":498,"../../lib/gl_format_color":495,"../../lib/str2rgbarray":520,"../scatter/make_bubble_size_func":636,"./calc_errors":648,"delaunay-triangulate":84,"gl-error3d":111,"gl-line3d":116,"gl-mesh3d":139,"gl-scatter3d":146}],650:[function(_dereq_,module,exports){ +},{"../../constants/gl3d_dashes":471,"../../constants/gl3d_markers":472,"../../lib":494,"../../lib/gl_format_color":492,"../../lib/str2rgbarray":516,"../scatter/make_bubble_size_func":632,"./calc_errors":644,"delaunay-triangulate":84,"gl-error3d":111,"gl-line3d":116,"gl-mesh3d":139,"gl-scatter3d":146}],646:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110279,7 +112361,7 @@ function handleXYZDefaults(traceIn, traceOut, coerce, layout) { return len; } -},{"../../lib":498,"../../registry":597,"../scatter/line_defaults":632,"../scatter/marker_defaults":638,"../scatter/subtypes":643,"../scatter/text_defaults":644,"./attributes":646}],651:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../registry":593,"../scatter/line_defaults":628,"../scatter/marker_defaults":634,"../scatter/subtypes":639,"../scatter/text_defaults":640,"./attributes":642}],647:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110310,7 +112392,7 @@ Scatter3D.meta = { module.exports = Scatter3D; -},{"../../constants/gl3d_markers":476,"../../plots/gl3d":575,"../scatter/marker_colorbar":637,"./attributes":646,"./calc":647,"./convert":649,"./defaults":650}],652:[function(_dereq_,module,exports){ +},{"../../constants/gl3d_markers":472,"../../plots/gl3d":571,"../scatter/marker_colorbar":633,"./attributes":642,"./calc":643,"./convert":645,"./defaults":646}],648:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110450,7 +112532,7 @@ attrs.transforms = undefined; module.exports = attrs; -},{"../../components/colorbar/attributes":377,"../../components/colorscale/attributes":383,"../../lib/extend":490,"../../plots/attributes":541,"../mesh3d/attributes":611}],653:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":376,"../../components/colorscale/attributes":382,"../../lib/extend":487,"../../plots/attributes":537,"../mesh3d/attributes":607}],649:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110496,7 +112578,11 @@ module.exports = function calc(gd, trace) { normMin = Math.min(normMin, norm); } - colorscaleCalc(trace, [normMin, normMax], '', 'c'); + colorscaleCalc(gd, trace, { + vals: [normMin, normMax], + containerStr: '', + cLetter: 'c' + }); var xMax = -Infinity; var xMin = Infinity; @@ -110540,7 +112626,7 @@ module.exports = function calc(gd, trace) { trace._zbnds = [zMin, zMax]; }; -},{"../../components/colorscale/calc":384}],654:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":383}],650:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110768,7 +112854,7 @@ function createStreamtubeTrace(scene, data) { module.exports = createStreamtubeTrace; -},{"../../lib":498,"../../lib/gl_format_color":495,"../../plots/gl3d/zip3":586,"gl-streamtube3d":160}],655:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../lib/gl_format_color":492,"../../plots/gl3d/zip3":582,"gl-streamtube3d":160}],651:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110831,7 +112917,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/colorscale/defaults":386,"../../lib":498,"./attributes":652}],656:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":385,"../../lib":494,"./attributes":648}],652:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110881,7 +112967,7 @@ module.exports = { } }; -},{"../../plots/gl3d":575,"./attributes":652,"./calc":653,"./convert":654,"./defaults":655}],657:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":571,"./attributes":648,"./calc":649,"./convert":650,"./defaults":651}],653:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -111110,7 +113196,7 @@ colorscaleAttrs('', { attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes'; attrs.transforms = undefined; -},{"../../components/color":376,"../../components/colorbar/attributes":377,"../../components/colorscale/attributes":383,"../../lib/extend":490,"../../plot_api/edit_types":527,"../../plots/attributes":541}],658:[function(_dereq_,module,exports){ +},{"../../components/color":375,"../../components/colorbar/attributes":376,"../../components/colorscale/attributes":382,"../../lib/extend":487,"../../plot_api/edit_types":523,"../../plots/attributes":537}],654:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -111128,13 +113214,21 @@ var colorscaleCalc = _dereq_('../../components/colorscale/calc'); // Compute auto-z and autocolorscale if applicable module.exports = function calc(gd, trace) { if(trace.surfacecolor) { - colorscaleCalc(trace, trace.surfacecolor, '', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.surfacecolor, + containerStr: '', + cLetter: 'c' + }); } else { - colorscaleCalc(trace, trace.z, '', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.z, + containerStr: '', + cLetter: 'c' + }); } }; -},{"../../components/colorscale/calc":384}],659:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":383}],655:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -111147,71 +113241,95 @@ module.exports = function calc(gd, trace) { 'use strict'; var createSurface = _dereq_('gl-surface3d'); + var ndarray = _dereq_('ndarray'); var homography = _dereq_('ndarray-homography'); var fill = _dereq_('ndarray-fill'); -var ops = _dereq_('ndarray-ops'); var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; var parseColorScale = _dereq_('../../lib/gl_format_color').parseColorScale; var str2RgbaArray = _dereq_('../../lib/str2rgbarray'); -var MIN_RESOLUTION = 128; - function SurfaceTrace(scene, surface, uid) { this.scene = scene; this.uid = uid; this.surface = surface; this.data = null; this.showContour = [false, false, false]; - this.dataScale = 1.0; + this.minValues = [Infinity, Infinity, Infinity]; + this.maxValues = [-Infinity, -Infinity, -Infinity]; + this.dataScaleX = 1.0; + this.dataScaleY = 1.0; + this.refineData = true; } var proto = SurfaceTrace.prototype; +proto.getXat = function(a, b, calendar, axis) { + var v = ( + (!isArrayOrTypedArray(this.data.x)) ? + a : + (isArrayOrTypedArray(this.data.x[0])) ? + this.data.x[b][a] : + this.data.x[a] + ); + + return (calendar === undefined) ? v : axis.d2l(v, 0, calendar); +}; + +proto.getYat = function(a, b, calendar, axis) { + var v = ( + (!isArrayOrTypedArray(this.data.y)) ? + b : + (isArrayOrTypedArray(this.data.y[0])) ? + this.data.y[b][a] : + this.data.y[b] + ); + + return (calendar === undefined) ? v : axis.d2l(v, 0, calendar); +}; + +proto.getZat = function(a, b, calendar, axis) { + var v = ( + this.data.z[b][a] + ); + + return (calendar === undefined) ? v : axis.d2l(v, 0, calendar); +}; + proto.handlePick = function(selection) { if(selection.object === this.surface) { - var selectIndex = selection.index = [ - Math.min( - Math.round(selection.data.index[0] / this.dataScale - 1)|0, - this.data.z[0].length - 1 - ), - Math.min( - Math.round(selection.data.index[1] / this.dataScale - 1)|0, - this.data.z.length - 1 - ) - ]; - var traceCoordinate = [0, 0, 0]; - if(!isArrayOrTypedArray(this.data.x)) { - traceCoordinate[0] = selectIndex[0]; - } else if(isArrayOrTypedArray(this.data.x[0])) { - traceCoordinate[0] = this.data.x[selectIndex[1]][selectIndex[0]]; - } else { - traceCoordinate[0] = this.data.x[selectIndex[0]]; - } + var xRatio = (selection.data.index[0] - 1) / this.dataScaleX - 1; + var yRatio = (selection.data.index[1] - 1) / this.dataScaleY - 1; - if(!isArrayOrTypedArray(this.data.y)) { - traceCoordinate[1] = selectIndex[1]; - } else if(isArrayOrTypedArray(this.data.y[0])) { - traceCoordinate[1] = this.data.y[selectIndex[1]][selectIndex[0]]; - } else { - traceCoordinate[1] = this.data.y[selectIndex[1]]; - } + var j = Math.max(Math.min(Math.round(xRatio), this.data.z[0].length - 1), 0); + var k = Math.max(Math.min(Math.round(yRatio), this.data._ylength - 1), 0); + + selection.index = [j, k]; - traceCoordinate[2] = this.data.z[selectIndex[1]][selectIndex[0]]; - selection.traceCoordinate = traceCoordinate; + selection.traceCoordinate = [ + this.getXat(j, k), + this.getYat(j, k), + this.getZat(j, k) + ]; - var sceneLayout = this.scene.fullSceneLayout; selection.dataCoordinate = [ - sceneLayout.xaxis.d2l(traceCoordinate[0], 0, this.data.xcalendar) * this.scene.dataScale[0], - sceneLayout.yaxis.d2l(traceCoordinate[1], 0, this.data.ycalendar) * this.scene.dataScale[1], - sceneLayout.zaxis.d2l(traceCoordinate[2], 0, this.data.zcalendar) * this.scene.dataScale[2] + this.getXat(j, k, this.data.xcalendar, this.scene.fullSceneLayout.xaxis), + this.getYat(j, k, this.data.ycalendar, this.scene.fullSceneLayout.yaxis), + this.getZat(j, k, this.data.zcalendar, this.scene.fullSceneLayout.zaxis) ]; + for(var i = 0; i < 3; i++) { + var v = selection.dataCoordinate[i]; + if(v !== null && v !== undefined) { + selection.dataCoordinate[i] *= this.scene.dataScale[i]; + } + } + var text = this.data.text; - if(Array.isArray(text) && text[selectIndex[1]] && text[selectIndex[1]][selectIndex[0]] !== undefined) { - selection.textLabel = text[selectIndex[1]][selectIndex[0]]; + if(Array.isArray(text) && text[k] && text[k][j] !== undefined) { + selection.textLabel = text[k][j]; } else if(text) { selection.textLabel = text; } else { @@ -111241,58 +113359,220 @@ function isColormapCircular(colormap) { ); } -// Pad coords by +1 -function padField(field) { - var shape = field.shape; - var nshape = [shape[0] + 2, shape[1] + 2]; - var nfield = ndarray(new Float32Array(nshape[0] * nshape[1]), nshape); +var shortPrimes = [ + 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, + 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, + 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, + 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, + 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, + 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, + 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, + 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, + 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, + 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, + 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, + 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, + 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, + 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, + 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, + 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, + 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, + 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, + 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, + 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, + 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, + 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, + 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, + 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, + 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, + 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, + 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, + 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, + 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, + 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999 +]; - // Center - ops.assign(nfield.lo(1, 1).hi(shape[0], shape[1]), field); +function getPow(a, b) { + if(a < b) return 0; + var n = 0; + while(Math.floor(a % b) === 0) { + a /= b; + n++; + } + return n; +} - // Edges - ops.assign(nfield.lo(1).hi(shape[0], 1), - field.hi(shape[0], 1)); - ops.assign(nfield.lo(1, nshape[1] - 1).hi(shape[0], 1), - field.lo(0, shape[1] - 1).hi(shape[0], 1)); - ops.assign(nfield.lo(0, 1).hi(1, shape[1]), - field.hi(1)); - ops.assign(nfield.lo(nshape[0] - 1, 1).hi(1, shape[1]), - field.lo(shape[0] - 1)); +function getFactors(a) { + var powers = []; + for(var i = 0; i < shortPrimes.length; i++) { + var b = shortPrimes[i]; + powers.push( + getPow(a, b) + ); + } + return powers; +} - // Corners - nfield.set(0, 0, field.get(0, 0)); - nfield.set(0, nshape[1] - 1, field.get(0, shape[1] - 1)); - nfield.set(nshape[0] - 1, 0, field.get(shape[0] - 1, 0)); - nfield.set(nshape[0] - 1, nshape[1] - 1, field.get(shape[0] - 1, shape[1] - 1)); +function smallestDivisor(a) { + var A = getFactors(a); + var result = a; + for(var i = 0; i < shortPrimes.length; i++) { + if(A[i] > 0) { + result = shortPrimes[i]; + break; + } + } + return result; +} - return nfield; +function leastCommonMultiple(a, b) { + if(a < 1 || b < 1) return undefined; + var A = getFactors(a); + var B = getFactors(b); + var n = 1; + for(var i = 0; i < shortPrimes.length; i++) { + n *= Math.pow( + shortPrimes[i], Math.max(A[i], B[i]) + ); + } + return n; +} + +function arrayLCM(A) { + if(A.length === 0) return undefined; + var n = 1; + for(var i = 0; i < A.length; i++) { + n = leastCommonMultiple(n, A[i]); + } + return n; } -function refine(coords) { - var minScale = Math.max(coords[0].shape[0], coords[0].shape[1]); +proto.calcXnums = function(xlen) { + var i; + var nums = []; + for(i = 1; i < xlen; i++) { + var a = this.getXat(i - 1, 0); + var b = this.getXat(i, 0); + + if(b !== a && + a !== undefined && a !== null && + b !== undefined && b !== null) { + nums[i - 1] = Math.abs(b - a); + } else { + nums[i - 1] = 0; + } + } - if(minScale < MIN_RESOLUTION) { - var scaleF = MIN_RESOLUTION / minScale; - var nshape = [ - Math.floor((coords[0].shape[0]) * scaleF + 1)|0, - Math.floor((coords[0].shape[1]) * scaleF + 1)|0 ]; - var nsize = nshape[0] * nshape[1]; + var totalDist = 0; + for(i = 1; i < xlen; i++) { + totalDist += nums[i - 1]; + } - for(var i = 0; i < coords.length; ++i) { - var padImg = padField(coords[i]); - var scaledImg = ndarray(new Float32Array(nsize), nshape); - homography(scaledImg, padImg, [scaleF, 0, 0, - 0, scaleF, 0, - 0, 0, 1]); - coords[i] = scaledImg; + for(i = 1; i < xlen; i++) { + if(nums[i - 1] === 0) { + nums[i - 1] = 1; + } else { + nums[i - 1] = Math.round(totalDist / nums[i - 1]); } + } - return scaleF; + return nums; +}; + +proto.calcYnums = function(ylen) { + var i; + var nums = []; + for(i = 1; i < ylen; i++) { + var a = this.getYat(0, i - 1); + var b = this.getYat(0, i); + + if(b !== a && + a !== undefined && a !== null && + b !== undefined && b !== null) { + nums[i - 1] = Math.abs(b - a); + } else { + nums[i - 1] = 0; + } } - return 1.0; -} + var totalDist = 0; + for(i = 1; i < ylen; i++) { + totalDist += nums[i - 1]; + } + + for(i = 1; i < ylen; i++) { + if(nums[i - 1] === 0) { + nums[i - 1] = 1; + } else { + nums[i - 1] = Math.round(totalDist / nums[i - 1]); + } + } + + return nums; +}; + +var highlyComposites = [1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1260]; + +var MIN_RESOLUTION = highlyComposites[9]; +var MAX_RESOLUTION = highlyComposites[13]; + +proto.estimateScale = function(resSrc, axis) { + var nums = (axis === 0) ? + this.calcXnums(resSrc) : + this.calcYnums(resSrc); + + var resDst = 1 + arrayLCM(nums); + + while(resDst < MIN_RESOLUTION) { + resDst *= 2; + } + + while(resDst > MAX_RESOLUTION) { + resDst--; + resDst /= smallestDivisor(resDst); + resDst++; + + if(resDst < MIN_RESOLUTION) { + // resDst = MIN_RESOLUTION; // option 1: use min resolution + resDst = MAX_RESOLUTION; // option 2: use max resolution + } + } + + var scale = Math.round(resDst / resSrc); + return (scale > 1) ? scale : 1; +}; + +proto.refineCoords = function(coords) { + + var scaleW = this.dataScaleX; + var scaleH = this.dataScaleY; + + var width = coords[0].shape[0]; + var height = coords[0].shape[1]; + + var newWidth = Math.floor(coords[0].shape[0] * scaleW + 1) | 0; + var newHeight = Math.floor(coords[0].shape[1] * scaleH + 1) | 0; + + // Pad coords by +1 + var padWidth = 1 + width + 1; + var padHeight = 1 + height + 1; + var padImg = ndarray(new Float32Array(padWidth * padHeight), [padWidth, padHeight]); + + for(var i = 0; i < coords.length; ++i) { + + this.surface.padField(padImg, coords[i]); + + var scaledImg = ndarray(new Float32Array(newWidth * newHeight), [newWidth, newHeight]); + homography(scaledImg, padImg, + [ + scaleW, 0, 0, + 0, scaleH, 0, + 0, 0, 1 + ] + ); + coords[i] = scaledImg; + } +}; proto.setContourLevels = function() { var nlevels = [[], [], []]; @@ -111311,28 +113591,14 @@ proto.setContourLevels = function() { }; proto.update = function(data) { - var i, - scene = this.scene, + var scene = this.scene, sceneLayout = scene.fullSceneLayout, surface = this.surface, alpha = data.opacity, colormap = parseColorScale(data.colorscale, alpha), - z = data.z, - x = data.x, - y = data.y, - xaxis = sceneLayout.xaxis, - yaxis = sceneLayout.yaxis, - zaxis = sceneLayout.zaxis, scaleFactor = scene.dataScale, - xlen = z[0].length, + xlen = data.z[0].length, ylen = data._ylength, - coords = [ - ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), - ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), - ndarray(new Float32Array(xlen * ylen), [xlen, ylen]) - ], - xc = coords[0], - yc = coords[1], contourLevels = scene.contourLevels; // Save data @@ -111346,46 +113612,87 @@ proto.update = function(data) { * which is the transpose of 'gl-surface-plot'. */ - var xcalendar = data.xcalendar, - ycalendar = data.ycalendar, - zcalendar = data.zcalendar; + var i, j, k, v; + var rawCoords = []; + for(i = 0; i < 3; i++) { + rawCoords[i] = []; + for(j = 0; j < xlen; j++) { + rawCoords[i][j] = []; + /* + for(k = 0; k < ylen; k++) { + rawCoords[i][j][k] = undefined; + } + */ + } + } - fill(coords[2], function(row, col) { - return zaxis.d2l(z[col][row], 0, zcalendar) * scaleFactor[2]; - }); + // coords x, y & z + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + rawCoords[0][j][k] = this.getXat(j, k, data.xcalendar, sceneLayout.xaxis); + rawCoords[1][j][k] = this.getYat(j, k, data.ycalendar, sceneLayout.yaxis); + rawCoords[2][j][k] = this.getZat(j, k, data.zcalendar, sceneLayout.zaxis); + } + } - // coords x - if(!isArrayOrTypedArray(x)) { - fill(xc, function(row) { - return xaxis.d2l(row, 0, xcalendar) * scaleFactor[0]; - }); - } else if(isArrayOrTypedArray(x[0])) { - fill(xc, function(row, col) { - return xaxis.d2l(x[col][row], 0, xcalendar) * scaleFactor[0]; - }); - } else { - // ticks x - fill(xc, function(row) { - return xaxis.d2l(x[row], 0, xcalendar) * scaleFactor[0]; - }); + // Note: log axes are not defined in surfaces yet. + // but they could be defined here... + + for(i = 0; i < 3; i++) { + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + v = rawCoords[i][j][k]; + if(v === null || v === undefined) { + rawCoords[i][j][k] = NaN; + } else { + v = rawCoords[i][j][k] *= scaleFactor[i]; + } + } + } } - // coords y - if(!isArrayOrTypedArray(x)) { - fill(yc, function(row, col) { - return yaxis.d2l(col, 0, xcalendar) * scaleFactor[1]; - }); - } else if(isArrayOrTypedArray(y[0])) { - fill(yc, function(row, col) { - return yaxis.d2l(y[col][row], 0, ycalendar) * scaleFactor[1]; - }); - } else { - // ticks y - fill(yc, function(row, col) { - return yaxis.d2l(y[col], 0, ycalendar) * scaleFactor[1]; - }); + for(i = 0; i < 3; i++) { + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + v = rawCoords[i][j][k]; + if(v !== null && v !== undefined) { + if(this.minValues[i] > v) { + this.minValues[i] = v; + } + if(this.maxValues[i] < v) { + this.maxValues[i] = v; + } + } + } + } + } + + for(i = 0; i < 3; i++) { + data._objectOffset[i] = 0.5 * (this.minValues[i] + this.maxValues[i]); + } + + for(i = 0; i < 3; i++) { + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + v = rawCoords[i][j][k]; + if(v !== null && v !== undefined) { + rawCoords[i][j][k] -= data._objectOffset[i]; + } + } + } } + // convert processed raw data to Float32 matrices + var coords = [ + ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), + ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), + ndarray(new Float32Array(xlen * ylen), [xlen, ylen]) + ]; + fill(coords[0], function(row, col) { return rawCoords[0][row][col]; }); + fill(coords[1], function(row, col) { return rawCoords[1][row][col]; }); + fill(coords[2], function(row, col) { return rawCoords[2][row][col]; }); + rawCoords = []; // free memory + var params = { colormap: colormap, levels: [[], [], []], @@ -111407,7 +113714,7 @@ proto.update = function(data) { params.intensityBounds = [data.cmin, data.cmax]; - // Refine if necessary + // Refine surface color if necessary if(data.surfacecolor) { var intensity = ndarray(new Float32Array(xlen * ylen), [xlen, ylen]); @@ -111424,7 +113731,18 @@ proto.update = function(data) { params.intensityBounds[1] *= scaleFactor[2]; } - this.dataScale = refine(coords); + if(MAX_RESOLUTION < coords[0].shape[0] || + MAX_RESOLUTION < coords[0].shape[1]) { + this.refineData = false; + } + + if(this.refineData === true) { + this.dataScaleX = this.estimateScale(coords[0].shape[0], 0); + this.dataScaleY = this.estimateScale(coords[0].shape[1], 1); + if(this.dataScaleX !== 1 || this.dataScaleY !== 1) { + this.refineCoords(coords); + } + } if(data.surfacecolor) { params.intensity = coords.pop(); @@ -111473,8 +113791,13 @@ proto.update = function(data) { params.vertexColor = true; } - params.coords = coords; + params.objectOffset = [ + data._objectOffset[0], + data._objectOffset[1], + data._objectOffset[2] + ]; + params.coords = coords; surface.update(params); surface.visible = data.visible; @@ -111517,7 +113840,7 @@ function createSurfaceTrace(scene, data) { module.exports = createSurfaceTrace; -},{"../../lib":498,"../../lib/gl_format_color":495,"../../lib/str2rgbarray":520,"gl-surface3d":162,"ndarray":285,"ndarray-fill":275,"ndarray-homography":277,"ndarray-ops":279}],660:[function(_dereq_,module,exports){ +},{"../../lib":494,"../../lib/gl_format_color":492,"../../lib/str2rgbarray":516,"gl-surface3d":162,"ndarray":285,"ndarray-fill":275,"ndarray-homography":277}],656:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -111555,6 +113878,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._xlength = (Array.isArray(x) && Lib.isArrayOrTypedArray(x[0])) ? z.length : z[0].length; traceOut._ylength = z.length; + traceOut._objectOffset = [0, 0, 0]; + var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y', 'z'], layout); @@ -111628,7 +113953,7 @@ function mapLegacy(traceIn, oldAttr, newAttr) { } } -},{"../../components/colorscale/defaults":386,"../../lib":498,"../../registry":597,"./attributes":657}],661:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":385,"../../lib":494,"../../registry":593,"./attributes":653}],657:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -111661,5 +113986,5 @@ Surface.meta = { module.exports = Surface; -},{"../../plots/gl3d":575,"./attributes":657,"./calc":658,"./convert":659,"./defaults":660}]},{},[5])(5) +},{"../../plots/gl3d":571,"./attributes":653,"./calc":654,"./convert":655,"./defaults":656}]},{},[5])(5) }); diff --git a/dist/plotly-gl3d.min.js b/dist/plotly-gl3d.min.js index 039e40d0eac..b418424dc6f 100644 --- a/dist/plotly-gl3d.min.js +++ b/dist/plotly-gl3d.min.js @@ -1,7 +1,7 @@ /** -* plotly.js (gl3d - minified) v1.42.5 +* plotly.js (gl3d - minified) v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,r,n){function i(o,s){if(!r[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[o]={exports:{}};e[o][0].call(c.exports,function(t){return i(e[o][1][t]||t)},c,c.exports,t,e,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oplotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/cone")},{"../src/traces/cone":610}],4:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":480}],5:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./scatter3d"),t("./surface"),t("./mesh3d"),t("./cone"),t("./streamtube")]),e.exports=n},{"./cone":3,"./core":4,"./mesh3d":6,"./scatter3d":7,"./streamtube":8,"./surface":9}],6:[function(t,e,r){"use strict";e.exports=t("../src/traces/mesh3d")},{"../src/traces/mesh3d":615}],7:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatter3d")},{"../src/traces/scatter3d":651}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/streamtube")},{"../src/traces/streamtube":656}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/surface")},{"../src/traces/surface":661}],10:[function(t,e,r){"use strict";e.exports=function(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]);"zoomMin"in e&&(r[0]=e.zoomMin);"zoomMax"in e&&(r[1]=e.zoomMax);var u=i({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=0,h=t.clientWidth,d=t.clientHeight,p={view:u,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:u.modes,tick:function(){var e=n(),r=this.delay;u.idle(e-r),u.flush(e-(100+2*r));var i=e-2*r;u.recalcMatrix(i);for(var a=!0,o=u.computedMatrix,s=0;s<16;++s)a=a&&c[s]===o[s],c[s]=o[s];var l=t.clientWidth===h&&t.clientHeight===d;return h=t.clientWidth,d=t.clientHeight,a?!l:(f=Math.exp(u.computedRadius[0]),!0)},lookAt:function(t,e,r){u.lookAt(u.lastT(),t,e,r)},rotate:function(t,e,r){u.rotate(u.lastT(),t,e,r)},pan:function(t,e,r){u.pan(u.lastT(),t,e,r)},translate:function(t,e,r){u.translate(u.lastT(),t,e,r)}};Object.defineProperties(p,{matrix:{get:function(){return u.computedMatrix},set:function(t){return u.setMatrix(u.lastT(),t),u.computedMatrix},enumerable:!0},mode:{get:function(){return u.getMode()},set:function(t){return u.setMode(t),u.getMode()},enumerable:!0},center:{get:function(){return u.computedCenter},set:function(t){return u.lookAt(u.lastT(),t),u.computedCenter},enumerable:!0},eye:{get:function(){return u.computedEye},set:function(t){return u.lookAt(u.lastT(),null,t),u.computedEye},enumerable:!0},up:{get:function(){return u.computedUp},set:function(t){return u.lookAt(u.lastT(),null,null,t),u.computedUp},enumerable:!0},distance:{get:function(){return f},set:function(t){return u.setDistance(u.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return u.getDistanceLimits(r)},set:function(t){return u.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var g=0,v=0,m={shift:!1,control:!1,alt:!1,meta:!1};function y(e,r,i,a){var o=1/t.clientHeight,s=o*(r-g),l=o*(i-v),c=p.flipX?1:-1,h=p.flipY?1:-1,d=Math.PI*p.rotateSpeed,y=n();if(1&e)a.shift?u.rotate(y,0,0,-s*d):u.rotate(y,c*d*s,-h*d*l,0);else if(2&e)u.pan(y,-p.translateSpeed*s*f,p.translateSpeed*l*f,0);else if(4&e){var b=p.zoomSpeed*l/window.innerHeight*(y-u.lastT())*50;u.pan(y,0,0,f*(Math.exp(b)-1))}g=r,v=i,m=a}return a(t,y),t.addEventListener("touchstart",function(e){var r=s(e.changedTouches[0],t);y(0,r[0],r[1],m),y(1,r[0],r[1],m),e.preventDefault()},!!l&&{passive:!1}),t.addEventListener("touchmove",function(e){var r=s(e.changedTouches[0],t);y(1,r[0],r[1],m),e.preventDefault()},!!l&&{passive:!1}),t.addEventListener("touchend",function(e){s(e.changedTouches[0],t),y(0,g,v,m),e.preventDefault()},!!l&&{passive:!1}),o(t,function(t,e,r){var i=p.flipX?1:-1,a=p.flipY?1:-1,o=n();if(Math.abs(t)>Math.abs(e))u.rotate(o,0,0,-t*i*Math.PI*p.rotateSpeed/window.innerWidth);else{var s=p.zoomSpeed*a*e/window.innerHeight*(o-u.lastT())/100;u.pan(o,0,0,f*(Math.exp(s)-1))}},!0),p};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset"),l=t("has-passive-events")},{"3d-view":11,"has-passive-events":251,"mouse-change":270,"mouse-event-offset":271,"mouse-wheel":273,"right-now":315}],11:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).eye||[0,0,1],r=t.center||[0,0,0],s=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],u=t.mode||"turntable",c=n(),f=i(),h=a();return c.setDistanceLimits(l[0],l[1]),c.lookAt(0,e,r,s),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,s),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,s),new o({turntable:c,orbit:f,matrix:h},u)};var n=t("turntable-camera-controller"),i=t("orbit-camera-controller"),a=t("matrix-camera-controller");function o(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.turntable),this.modes=this._controllerNames,this.computedMatrix=this._active.computedMatrix,this.computedEye=this._active.computedEye,this.computedUp=this._active.computedUp,this.computedCenter=this._active.computedCenter,this.computedRadius=this._active.computedRadius}var s=o.prototype;[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]].forEach(function(t){for(var e=t[0],r=[],n=0;n0?n-4:n,f=0;f>16&255,s[l++]=e>>8&255,s[l++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,s[l++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,s[l++]=e>>8&255,s[l++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,a=[],o=0,s=r-i;os?s:o+16383));1===i?(e=t[r-1],a.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],a.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,a,o=[],s=e;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],20:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}},{"./lib/rationalize":30}],21:[function(t,e,r){"use strict";e.exports=function(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}},{}],22:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]),t[1].mul(e[0]))}},{"./lib/rationalize":30}],23:[function(t,e,r){"use strict";var n=t("./is-rat"),i=t("./lib/is-bn"),a=t("./lib/num-to-bn"),o=t("./lib/str-to-bn"),s=t("./lib/rationalize"),l=t("./div");e.exports=function t(e,r){if(n(e))return r?l(e,t(r)):[e[0].clone(),e[1].clone()];var u=0;var c,f;if(i(e))c=e.clone();else if("string"==typeof e)c=o(e);else{if(0===e)return[a(0),a(1)];if(e===Math.floor(e))c=a(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),u-=256;c=a(e)}}if(n(r))c.mul(r[1]),f=r[0].clone();else if(i(r))f=r.clone();else if("string"==typeof r)f=o(r);else if(r)if(r===Math.floor(r))f=a(r);else{for(;r!==Math.floor(r);)r*=Math.pow(2,256),u+=256;f=a(r)}else f=a(1);u>0?c=c.ushln(u):u<0&&(f=f.ushln(-u));return s(c,f)}},{"./div":22,"./is-rat":24,"./lib/is-bn":28,"./lib/num-to-bn":29,"./lib/rationalize":30,"./lib/str-to-bn":31}],24:[function(t,e,r){"use strict";var n=t("./lib/is-bn");e.exports=function(t){return Array.isArray(t)&&2===t.length&&n(t[0])&&n(t[1])}},{"./lib/is-bn":28}],25:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return t.cmp(new n(0))}},{"bn.js":38}],26:[function(t,e,r){"use strict";var n=t("./bn-sign");e.exports=function(t){var e=t.length,r=t.words,i=0;if(1===e)i=r[0];else if(2===e)i=r[0]+67108864*r[1];else for(var a=0;a20)return 52;return r+32}},{"bit-twiddle":37,"double-bits":85}],28:[function(t,e,r){"use strict";t("bn.js");e.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},{"bn.js":38}],29:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("double-bits");e.exports=function(t){var e=i.exponent(t);return e<52?new n(t):new n(t*Math.pow(2,52-e)).ushln(e-52)}},{"bn.js":38,"double-bits":85}],30:[function(t,e,r){"use strict";var n=t("./num-to-bn"),i=t("./bn-sign");e.exports=function(t,e){var r=i(t),a=i(e);if(0===r)return[n(0),n(1)];if(0===a)return[n(0),n(0)];a<0&&(t=t.neg(),e=e.neg());var o=t.gcd(e);if(o.cmpn(1))return[t.div(o),e.div(o)];return[t,e]}},{"./bn-sign":25,"./num-to-bn":29}],31:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return new n(t)}},{"bn.js":38}],32:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[0]),t[1].mul(e[1]))}},{"./lib/rationalize":30}],33:[function(t,e,r){"use strict";var n=t("./lib/bn-sign");e.exports=function(t){return n(t[0])*n(t[1])}},{"./lib/bn-sign":25}],34:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},{"./lib/rationalize":30}],35:[function(t,e,r){"use strict";var n=t("./lib/bn-to-num"),i=t("./lib/ctz");e.exports=function(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var a=e.abs().divmod(r.abs()),o=a.div,s=n(o),l=a.mod,u=e.negative!==r.negative?-1:1;if(0===l.cmpn(0))return u*s;if(s){var c=i(s)+4,f=n(l.ushln(c).divRound(r));return u*(s+f*Math.pow(2,-c))}var h=r.bitLength()-l.bitLength()+53,f=n(l.ushln(h).divRound(r));return h<1023?u*f*Math.pow(2,-h):(f*=Math.pow(2,-1023),u*f*Math.pow(2,1023-h))}},{"./lib/bn-to-num":26,"./lib/ctz":27}],36:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],37:[function(t,e,r){"use strict";function n(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}r.INT_BITS=32,r.INT_MAX=2147483647,r.INT_MIN=-1<<31,r.sign=function(t){return(t>0)-(t<0)},r.abs=function(t){var e=t>>31;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},r.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},r.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},r.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},r.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],38:[function(t,e,r){!function(e,r){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function a(t,e,r){if(a.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof e?e.exports=a:r.BN=a,a.BN=a,a.wordSize=26;try{o=t("buffer").Buffer}catch(t){}function s(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;a=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function l(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return i}a.isBN=function(t){return t instanceof a||null!==t&&"object"==typeof t&&t.constructor.wordSize===a.wordSize&&Array.isArray(t.words)},a.max=function(t,e){return t.cmp(e)>0?t:e},a.min=function(t,e){return t.cmp(e)<0?t:e},a.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if("le"===r)for(i=0,a=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},a.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=s(t,r,r+6),this.words[n]|=i<>>26-a&4194303,(a+=24)>=26&&(a-=26,n++);r+6!==e&&(i=s(t,e,r+6),this.words[n]|=i<>>26-a&4194303),this.strip()},a.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,o=a%n,s=Math.min(a,a-o)+r,u=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],a=0|e.words[0],o=i*a,s=67108863&o,l=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&l,h=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=h;d++){var p=u-d|0;c+=(o=(i=0|t.words[p])*(a=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,l=0|c}return 0!==l?r.words[u]=0|l:r.length--,r.strip()}a.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,a=0,o=0;o>>24-i&16777215)||o!==this.length-1?u[6-l.length]+l+r:l+r,(i+=2)>=26&&(i-=26,o--)}for(0!==a&&(r=a.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var h=c[t],d=f[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?g+r:u[h-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(t,e){return n("undefined"!=typeof o),this.toArrayLike(o,t,e)},a.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},a.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,"byte array longer than desired length"),n(a>0,"Requested array length <= 0"),this.strip();var o,s,l="le"===e,u=new t(a),c=this.clone();if(l){for(s=0;!c.isZero();s++)o=c.andln(255),c.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},a.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},a.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},a.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},a.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},a.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},a.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},a.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},a.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},a.prototype.notn=function(t){return this.clone().inotn(t)},a.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26;for(;0!==i&&a>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},a.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,g=d>>>13,v=0|o[2],m=8191&v,y=v>>>13,b=0|o[3],x=8191&b,_=b>>>13,w=0|o[4],M=8191&w,A=w>>>13,T=0|o[5],k=8191&T,E=T>>>13,S=0|o[6],L=8191&S,C=S>>>13,O=0|o[7],R=8191&O,P=O>>>13,z=0|o[8],I=8191&z,N=z>>>13,D=0|o[9],F=8191&D,j=D>>>13,B=0|s[0],U=8191&B,V=B>>>13,H=0|s[1],q=8191&H,G=H>>>13,W=0|s[2],X=8191&W,Y=W>>>13,Z=0|s[3],Q=8191&Z,J=Z>>>13,$=0|s[4],K=8191&$,tt=$>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],at=8191&it,ot=it>>>13,st=0|s[7],lt=8191&st,ut=st>>>13,ct=0|s[8],ft=8191&ct,ht=ct>>>13,dt=0|s[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(u+(n=Math.imul(f,U))|0)+((8191&(i=(i=Math.imul(f,V))+Math.imul(h,U)|0))<<13)|0;u=((a=Math.imul(h,V))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,U),i=(i=Math.imul(p,V))+Math.imul(g,U)|0,a=Math.imul(g,V);var mt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(h,q)|0))<<13)|0;u=((a=a+Math.imul(h,G)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,U),i=(i=Math.imul(m,V))+Math.imul(y,U)|0,a=Math.imul(y,V),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(g,q)|0,a=a+Math.imul(g,G)|0;var yt=(u+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,Y)|0)+Math.imul(h,X)|0))<<13)|0;u=((a=a+Math.imul(h,Y)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(x,U),i=(i=Math.imul(x,V))+Math.imul(_,U)|0,a=Math.imul(_,V),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,G)|0)+Math.imul(y,q)|0,a=a+Math.imul(y,G)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(g,X)|0,a=a+Math.imul(g,Y)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(h,Q)|0))<<13)|0;u=((a=a+Math.imul(h,J)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(M,U),i=(i=Math.imul(M,V))+Math.imul(A,U)|0,a=Math.imul(A,V),n=n+Math.imul(x,q)|0,i=(i=i+Math.imul(x,G)|0)+Math.imul(_,q)|0,a=a+Math.imul(_,G)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(y,X)|0,a=a+Math.imul(y,Y)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(g,Q)|0,a=a+Math.imul(g,J)|0;var xt=(u+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(h,K)|0))<<13)|0;u=((a=a+Math.imul(h,tt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(k,U),i=(i=Math.imul(k,V))+Math.imul(E,U)|0,a=Math.imul(E,V),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,G)|0)+Math.imul(A,q)|0,a=a+Math.imul(A,G)|0,n=n+Math.imul(x,X)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(_,X)|0,a=a+Math.imul(_,Y)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(y,Q)|0,a=a+Math.imul(y,J)|0,n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(g,K)|0,a=a+Math.imul(g,tt)|0;var _t=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(h,rt)|0))<<13)|0;u=((a=a+Math.imul(h,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(L,U),i=(i=Math.imul(L,V))+Math.imul(C,U)|0,a=Math.imul(C,V),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(E,q)|0,a=a+Math.imul(E,G)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(A,X)|0,a=a+Math.imul(A,Y)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(_,Q)|0,a=a+Math.imul(_,J)|0,n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(y,K)|0,a=a+Math.imul(y,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(g,rt)|0,a=a+Math.imul(g,nt)|0;var wt=(u+(n=n+Math.imul(f,at)|0)|0)+((8191&(i=(i=i+Math.imul(f,ot)|0)+Math.imul(h,at)|0))<<13)|0;u=((a=a+Math.imul(h,ot)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(R,U),i=(i=Math.imul(R,V))+Math.imul(P,U)|0,a=Math.imul(P,V),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,G)|0)+Math.imul(C,q)|0,a=a+Math.imul(C,G)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,Y)|0)+Math.imul(E,X)|0,a=a+Math.imul(E,Y)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(A,Q)|0,a=a+Math.imul(A,J)|0,n=n+Math.imul(x,K)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(_,K)|0,a=a+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(y,rt)|0,a=a+Math.imul(y,nt)|0,n=n+Math.imul(p,at)|0,i=(i=i+Math.imul(p,ot)|0)+Math.imul(g,at)|0,a=a+Math.imul(g,ot)|0;var Mt=(u+(n=n+Math.imul(f,lt)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(h,lt)|0))<<13)|0;u=((a=a+Math.imul(h,ut)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(I,U),i=(i=Math.imul(I,V))+Math.imul(N,U)|0,a=Math.imul(N,V),n=n+Math.imul(R,q)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(P,q)|0,a=a+Math.imul(P,G)|0,n=n+Math.imul(L,X)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(C,X)|0,a=a+Math.imul(C,Y)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(E,Q)|0,a=a+Math.imul(E,J)|0,n=n+Math.imul(M,K)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(A,K)|0,a=a+Math.imul(A,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(_,rt)|0,a=a+Math.imul(_,nt)|0,n=n+Math.imul(m,at)|0,i=(i=i+Math.imul(m,ot)|0)+Math.imul(y,at)|0,a=a+Math.imul(y,ot)|0,n=n+Math.imul(p,lt)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(g,lt)|0,a=a+Math.imul(g,ut)|0;var At=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ht)|0)+Math.imul(h,ft)|0))<<13)|0;u=((a=a+Math.imul(h,ht)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(F,U),i=(i=Math.imul(F,V))+Math.imul(j,U)|0,a=Math.imul(j,V),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,G)|0)+Math.imul(N,q)|0,a=a+Math.imul(N,G)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(P,X)|0,a=a+Math.imul(P,Y)|0,n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,J)|0)+Math.imul(C,Q)|0,a=a+Math.imul(C,J)|0,n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(E,K)|0,a=a+Math.imul(E,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(A,rt)|0,a=a+Math.imul(A,nt)|0,n=n+Math.imul(x,at)|0,i=(i=i+Math.imul(x,ot)|0)+Math.imul(_,at)|0,a=a+Math.imul(_,ot)|0,n=n+Math.imul(m,lt)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(y,lt)|0,a=a+Math.imul(y,ut)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ht)|0)+Math.imul(g,ft)|0,a=a+Math.imul(g,ht)|0;var Tt=(u+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,gt)|0)+Math.imul(h,pt)|0))<<13)|0;u=((a=a+Math.imul(h,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(F,q),i=(i=Math.imul(F,G))+Math.imul(j,q)|0,a=Math.imul(j,G),n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(N,X)|0,a=a+Math.imul(N,Y)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(P,Q)|0,a=a+Math.imul(P,J)|0,n=n+Math.imul(L,K)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(C,K)|0,a=a+Math.imul(C,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(E,rt)|0,a=a+Math.imul(E,nt)|0,n=n+Math.imul(M,at)|0,i=(i=i+Math.imul(M,ot)|0)+Math.imul(A,at)|0,a=a+Math.imul(A,ot)|0,n=n+Math.imul(x,lt)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(_,lt)|0,a=a+Math.imul(_,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ht)|0)+Math.imul(y,ft)|0,a=a+Math.imul(y,ht)|0;var kt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((a=a+Math.imul(g,gt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(F,X),i=(i=Math.imul(F,Y))+Math.imul(j,X)|0,a=Math.imul(j,Y),n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(N,Q)|0,a=a+Math.imul(N,J)|0,n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(P,K)|0,a=a+Math.imul(P,tt)|0,n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(C,rt)|0,a=a+Math.imul(C,nt)|0,n=n+Math.imul(k,at)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(E,at)|0,a=a+Math.imul(E,ot)|0,n=n+Math.imul(M,lt)|0,i=(i=i+Math.imul(M,ut)|0)+Math.imul(A,lt)|0,a=a+Math.imul(A,ut)|0,n=n+Math.imul(x,ft)|0,i=(i=i+Math.imul(x,ht)|0)+Math.imul(_,ft)|0,a=a+Math.imul(_,ht)|0;var Et=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,gt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((a=a+Math.imul(y,gt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(F,Q),i=(i=Math.imul(F,J))+Math.imul(j,Q)|0,a=Math.imul(j,J),n=n+Math.imul(I,K)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(N,K)|0,a=a+Math.imul(N,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(P,rt)|0,a=a+Math.imul(P,nt)|0,n=n+Math.imul(L,at)|0,i=(i=i+Math.imul(L,ot)|0)+Math.imul(C,at)|0,a=a+Math.imul(C,ot)|0,n=n+Math.imul(k,lt)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(E,lt)|0,a=a+Math.imul(E,ut)|0,n=n+Math.imul(M,ft)|0,i=(i=i+Math.imul(M,ht)|0)+Math.imul(A,ft)|0,a=a+Math.imul(A,ht)|0;var St=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,gt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((a=a+Math.imul(_,gt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(F,K),i=(i=Math.imul(F,tt))+Math.imul(j,K)|0,a=Math.imul(j,tt),n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(N,rt)|0,a=a+Math.imul(N,nt)|0,n=n+Math.imul(R,at)|0,i=(i=i+Math.imul(R,ot)|0)+Math.imul(P,at)|0,a=a+Math.imul(P,ot)|0,n=n+Math.imul(L,lt)|0,i=(i=i+Math.imul(L,ut)|0)+Math.imul(C,lt)|0,a=a+Math.imul(C,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ht)|0)+Math.imul(E,ft)|0,a=a+Math.imul(E,ht)|0;var Lt=(u+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,gt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((a=a+Math.imul(A,gt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(F,rt),i=(i=Math.imul(F,nt))+Math.imul(j,rt)|0,a=Math.imul(j,nt),n=n+Math.imul(I,at)|0,i=(i=i+Math.imul(I,ot)|0)+Math.imul(N,at)|0,a=a+Math.imul(N,ot)|0,n=n+Math.imul(R,lt)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(P,lt)|0,a=a+Math.imul(P,ut)|0,n=n+Math.imul(L,ft)|0,i=(i=i+Math.imul(L,ht)|0)+Math.imul(C,ft)|0,a=a+Math.imul(C,ht)|0;var Ct=(u+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,gt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((a=a+Math.imul(E,gt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(F,at),i=(i=Math.imul(F,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),n=n+Math.imul(I,lt)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(N,lt)|0,a=a+Math.imul(N,ut)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ht)|0)+Math.imul(P,ft)|0,a=a+Math.imul(P,ht)|0;var Ot=(u+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,gt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((a=a+Math.imul(C,gt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(F,lt),i=(i=Math.imul(F,ut))+Math.imul(j,lt)|0,a=Math.imul(j,ut),n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ht)|0)+Math.imul(N,ft)|0,a=a+Math.imul(N,ht)|0;var Rt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,gt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((a=a+Math.imul(P,gt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(F,ft),i=(i=Math.imul(F,ht))+Math.imul(j,ft)|0,a=Math.imul(j,ht);var Pt=(u+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,gt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((a=a+Math.imul(N,gt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var zt=(u+(n=Math.imul(F,pt))|0)+((8191&(i=(i=Math.imul(F,gt))+Math.imul(j,pt)|0))<<13)|0;return u=((a=Math.imul(j,gt))+(i>>>13)|0)+(zt>>>26)|0,zt&=67108863,l[0]=vt,l[1]=mt,l[2]=yt,l[3]=bt,l[4]=xt,l[5]=_t,l[6]=wt,l[7]=Mt,l[8]=At,l[9]=Tt,l[10]=kt,l[11]=Et,l[12]=St,l[13]=Lt,l[14]=Ct,l[15]=Ot,l[16]=Rt,l[17]=Pt,l[18]=zt,0!==u&&(l[19]=u,r.length++),r};function p(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(d=h),a.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?h(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,n=o,o=i}return 0!==n?r.words[a]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=a.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,i,a){for(var o=0;o>>=1)i++;return 1<>>=13,r[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=a>>>26,this.words[r]=67108863&a}return 0!==e&&(this.words[r]=e,this.length++),this},a.prototype.muln=function(t){return this.clone().imuln(t)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new a(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,u=0;u=0&&(0!==c||u>=i);u--){var f=0|this.words[u];this.words[u]=c<<26-a|f>>>a,c=f&s}return l&&0!==c&&(l.words[l.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},a.prototype.shln=function(t){return this.clone().ishln(t)},a.prototype.ushln=function(t){return this.clone().iushln(t)},a.prototype.shrn=function(t){return this.clone().ishrn(t)},a.prototype.ushrn=function(t){return this.clone().iushrn(t)},a.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},a.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(l/67108864|0),this.words[i+r]=67108863&a}for(;i>26,this.words[i+r]=67108863&a;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&a;return this.negative=1,this.strip()},a.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var s,l=n.length-i.length;if("mod"!==e){(s=new a(null)).length=l+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var h=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(h=Math.min(h/o|0,67108863),n._ishlnsubmul(i,h,f);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=h)}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},a.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(i=s.div.neg()),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new a(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new a(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new a(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,s},a.prototype.div=function(t){return this.divmod(t,"div",!1).div},a.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},a.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},a.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),a=r.cmp(n);return a<0||1===i&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},a.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},a.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},a.prototype.divn=function(t){return this.clone().idivn(t)},a.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new a(1),o=new a(0),s=new a(0),l=new a(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),f=e.clone();!e.isZero();){for(var h=0,d=1;0==(e.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(e.iushrn(h);h-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(c),o.isub(f)),i.iushrn(1),o.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(c),l.isub(f)),s.iushrn(1),l.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(s),o.isub(l)):(r.isub(e),s.isub(i),l.isub(o))}return{a:s,b:l,gcd:r.iushln(u)}},a.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new a(1),s=new a(0),l=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,c=1;0==(e.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(l),o.iushrn(1);for(var f=0,h=1;0==(r.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(s)):(r.isub(e),s.isub(o))}return(i=0===e.cmpn(1)?o:s).cmpn(0)<0&&i.iadd(t),i},a.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},a.prototype.invm=function(t){return this.egcd(t).a.umod(t)},a.prototype.isEven=function(){return 0==(1&this.words[0])},a.prototype.isOdd=function(){return 1==(1&this.words[0])},a.prototype.andln=function(t){return this.words[0]&t},a.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},a.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},a.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},a.prototype.gtn=function(t){return 1===this.cmpn(t)},a.prototype.gt=function(t){return 1===this.cmp(t)},a.prototype.gten=function(t){return this.cmpn(t)>=0},a.prototype.gte=function(t){return this.cmp(t)>=0},a.prototype.ltn=function(t){return-1===this.cmpn(t)},a.prototype.lt=function(t){return-1===this.cmp(t)},a.prototype.lten=function(t){return this.cmpn(t)<=0},a.prototype.lte=function(t){return this.cmp(t)<=0},a.prototype.eqn=function(t){return 0===this.cmpn(t)},a.prototype.eq=function(t){return 0===this.cmp(t)},a.red=function(t){return new w(t)},a.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},a.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(t){return this.red=t,this},a.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},a.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},a.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},a.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},a.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},a.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},a.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},a.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},a.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new a(e,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function x(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=a._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function M(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var t=new a(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(y,m),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=a}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},a._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new b;else if("p192"===t)e=new x;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return v[t]=e,e},w.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new a(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var s=new a(1).toRed(this),l=s.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new a(2*c*c).toRed(this);0!==this.pow(c,u).cmp(l);)c.redIAdd(l);for(var f=this.pow(c,i),h=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=o;0!==d.cmp(s);){for(var g=d,v=0;0!==g.cmp(s);v++)g=g.redSqr();n(v=0;n--){for(var u=e.words[n],c=l-1;c>=0;c--){var f=u>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==o?(o<<=1,o|=f,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[o]),s=0,o=0)):s=0}l=26}return i},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},a.mont=function(t){return new M(t)},i(M,w),M.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},M.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},M.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},M.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new a(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},M.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof e||e,this)},{buffer:47}],39:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i=t.length,a=0;for(e=0;e>>1;if(!(c<=0)){var f,h=i.mallocDouble(2*c*s),d=i.mallocInt32(s);if((s=l(t,c,h,d))>0){if(1===c&&n)a.init(s),f=a.sweepComplete(c,r,0,s,h,d,0,s,h,d);else{var p=i.mallocDouble(2*c*u),g=i.mallocInt32(u);(u=l(e,c,p,g))>0&&(a.init(s+u),f=1===c?a.sweepBipartite(c,r,0,s,h,d,0,u,p,g):o(c,r,n,s,h,d,u,p,g),i.free(p),i.free(g))}i.free(h),i.free(d)}return f}}}function c(t,e){n.push([t,e])}},{"./lib/intersect":42,"./lib/sweep":46,"typedarray-pool":348}],41:[function(t,e,r){"use strict";var n="d",i="ax",a="vv",o="fp",s="es",l="rs",u="re",c="rb",f="ri",h="rp",d="bs",p="be",g="bb",v="bi",m="bp",y="rv",b="Q",x=[n,i,a,l,u,c,f,d,p,g,v];function _(t){var e="bruteForce"+(t?"Full":"Partial"),r=[],_=x.slice();t||_.splice(3,0,o);var w=["function "+e+"("+_.join()+"){"];function M(e,o){var _=function(t,e,r){var o="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),_=["function ",o,"(",x.join(),"){","var ",s,"=2*",n,";"],w="for(var i="+l+","+h+"="+s+"*"+l+";i<"+u+";++i,"+h+"+="+s+"){var x0="+c+"["+i+"+"+h+"],x1="+c+"["+i+"+"+h+"+"+n+"],xi="+f+"[i];",M="for(var j="+d+","+m+"="+s+"*"+d+";j<"+p+";++j,"+m+"+="+s+"){var y0="+g+"["+i+"+"+m+"],"+(r?"y1="+g+"["+i+"+"+m+"+"+n+"],":"")+"yi="+v+"[j];";return t?_.push(w,b,":",M):_.push(M,b,":",w),r?_.push("if(y1"+p+"-"+d+"){"),t?(M(!0,!1),w.push("}else{"),M(!1,!1)):(w.push("if("+o+"){"),M(!0,!0),w.push("}else{"),M(!0,!1),w.push("}}else{if("+o+"){"),M(!1,!0),w.push("}else{"),M(!1,!1),w.push("}")),w.push("}}return "+e);var A=r.join("")+w.join("");return new Function(A)()}r.partial=_(!1),r.full=_(!0)},{}],42:[function(t,e,r){"use strict";e.exports=function(t,e,r,a,c,E,S,L,C){!function(t,e){var r=8*i.log2(e+1)*(t+1)|0,a=i.nextPow2(x*r);w.length0;){var z=(R-=1)*x,I=w[z],N=w[z+1],D=w[z+2],F=w[z+3],j=w[z+4],B=w[z+5],U=R*_,V=M[U],H=M[U+1],q=1&B,G=!!(16&B),W=c,X=E,Y=L,Z=C;if(q&&(W=L,X=C,Y=c,Z=E),!(2&B&&(D=v(t,I,N,D,W,X,H),N>=D)||4&B&&(N=m(t,I,N,D,W,X,V))>=D)){var Q=D-N,J=j-F;if(G){if(t*Q*(Q+J)=p0)&&!(p1>=hi)",["p0","p1"]),g=c("lo===p0",["p0"]),v=c("lo>>1,h=2*t,d=f,p=s[h*f+e];for(;u=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(c-1),M=h*d,A=0;Ar&&i[f+e]>u;--c,f-=o){for(var h=f,d=f+o,p=0;p=0&&i.push("lo=e[k+n]");t.indexOf("hi")>=0&&i.push("hi=e[k+o]");return r.push(n.replace("_",i.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],45:[function(t,e,r){"use strict";e.exports=function(t,e){e<=4*n?i(0,e-1,t):function t(e,r,f){var h=(r-e+1)/6|0,d=e+h,p=r-h,g=e+r>>1,v=g-h,m=g+h,y=d,b=v,x=g,_=m,w=p,M=e+1,A=r-1,T=0;u(y,b,f)&&(T=y,y=b,b=T);u(_,w,f)&&(T=_,_=w,w=T);u(y,x,f)&&(T=y,y=x,x=T);u(b,x,f)&&(T=b,b=x,x=T);u(y,_,f)&&(T=y,y=_,_=T);u(x,_,f)&&(T=x,x=_,_=T);u(b,w,f)&&(T=b,b=w,w=T);u(b,x,f)&&(T=b,b=x,x=T);u(_,w,f)&&(T=_,_=w,w=T);var k=f[2*b];var E=f[2*b+1];var S=f[2*_];var L=f[2*_+1];var C=2*y;var O=2*x;var R=2*w;var P=2*d;var z=2*g;var I=2*p;for(var N=0;N<2;++N){var D=f[C+N],F=f[O+N],j=f[R+N];f[P+N]=D,f[z+N]=F,f[I+N]=j}o(v,e,f);o(m,r,f);for(var B=M;B<=A;++B)if(c(B,k,E,f))B!==M&&a(B,M,f),++M;else if(!c(B,S,L,f))for(;;){if(c(A,S,L,f)){c(A,k,E,f)?(s(B,M,A,f),++M,--A):(a(B,A,f),--A);break}if(--At;){var u=r[l-2],c=r[l-1];if(ur[e+1])}function c(t,e,r,n){var i=n[t*=2];return i>>1;a(d,E);for(var S=0,L=0,M=0;M=o)p(u,c,L--,C=C-o|0);else if(C>=0)p(s,l,S--,C);else if(C<=-o){C=-C-o|0;for(var O=0;O>>1;a(d,S);for(var L=0,C=0,O=0,A=0;A>1==d[2*A+3]>>1&&(P=2,A+=1),R<0){for(var z=-(R>>1)-1,I=0;I>1)-1;0===P?p(s,l,L--,z):1===P?p(u,c,C--,z):2===P&&p(f,h,O--,z)}}},scanBipartite:function(t,e,r,n,i,u,c,f,h,v,m,y){var b=0,x=2*t,_=e,w=e+t,M=1,A=1;n?A=o:M=o;for(var T=i;T>>1;a(d,L);for(var C=0,T=0;T=o?(R=!n,k-=o):(R=!!n,k-=1),R)g(s,l,C++,k);else{var P=y[k],z=x*k,I=m[z+e+1],N=m[z+e+1+t];t:for(var D=0;D>>1;a(d,M);for(var A=0,b=0;b=o)s[A++]=x-o;else{var k=p[x-=1],E=v*x,S=h[E+e+1],L=h[E+e+1+t];t:for(var C=0;C=0;--C)if(s[C]===x){for(var z=C+1;z0&&s.length>a){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=o[e]=r,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(r=o[t]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,i=v(t,n),a=0;a=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,a=o;break}if(a<0)return this;0===a?r.shift():function(t,e){for(var r=e,n=r+1,i=t.length;n=0;a--)this.removeListener(t,e[a]);return this},o.prototype.listeners=function(t){return p(this,t,!0)},o.prototype.rawListeners=function(t){return p(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],49:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var a=2147483647;function o(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return f(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(B(t,ArrayBuffer)||t&&B(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||B(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:D(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var a,o=1,s=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var c=-1;for(a=r;as&&(r=s-l),a=r;a>=0;a--){for(var f=!0,h=0;hi&&(n=i):n=i;var a=e.length;n>a/2&&(n=a/2);for(var o=0;o>8,i=r%256,a.push(i),a.push(n);return a}(e,t.length-r),t,r,n)}function M(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+f<=r)switch(f){case 1:u<128&&(c=u);break;case 2:128==(192&(a=t[i+1]))&&(l=(31&u)<<6|63&a)>127&&(c=l);break;case 3:a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&(l=(15&u)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(l=(15&u)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(c=l)}null===c?(c=65533,f=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=f}return function(t){var e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return M(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(B(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var a=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),l=Math.min(a,o),u=this.slice(n,i),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return x(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",a=e;ar)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,a){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,n,a){return e=+e,r>>>=0,a||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function z(t,e,r,n,a){return e=+e,r>>>=0,a||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],i=1,a=0;++a>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],i=1,a=0;++a=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*e)),a},s.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[e]=255&t;++a>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,a=1;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=t/a&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return z(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return z(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--a)t[a+e]=this[a+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(a=e;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function B(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}},{"base64-js":19,ieee754:252}],50:[function(t,e,r){"use strict";var n=t("./lib/monotone"),i=t("./lib/triangulation"),a=t("./lib/delaunay"),o=t("./lib/filter");function s(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function l(t,e){return t[0]-e[0]||t[1]-e[1]}function u(t,e,r){return e in t?t[e]:r}e.exports=function(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var c=!!u(r,"delaunay",!0),f=!!u(r,"interior",!0),h=!!u(r,"exterior",!0),d=!!u(r,"infinity",!1);if(!f&&!h||0===t.length)return[];var p=n(t,e);if(c||f!==h||d){for(var g=i(t.length,function(t){return t.map(s).sort(l)}(e)),v=0;v0;){for(var c=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;p=0||(e.flip(s,c),i(t,e,r,f,s,h),i(t,e,r,s,h,f),i(t,e,r,h,c,f),i(t,e,r,c,f,h)))}}},{"binary-search-bounds":55,"robust-in-sphere":319}],52:[function(t,e,r){"use strict";var n,i=t("binary-search-bounds");function a(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function o(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}e.exports=function(t,e,r){var n=function(t,e){for(var r=t.cells(),n=r.length,i=0;i0||l.length>0;){for(;s.length>0;){var d=s.pop();if(u[d]!==-i){u[d]=i;c[d];for(var p=0;p<3;++p){var g=h[3*d+p];g>=0&&0===u[g]&&(f[3*d+p]?l.push(g):(s.push(g),u[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=function(t,e,r){for(var n=0,i=0;i1&&i(r[h[d-2]],r[h[d-1]],a)>0;)t.push([h[d-1],h[d-2],o]),d-=1;h.length=d,h.push(o);var p=c.upperIds;for(d=p.length;d>1&&i(r[p[d-2]],r[p[d-1]],a)<0;)t.push([p[d-2],p[d-1],o]),d-=1;p.length=d,p.push(o)}}function d(t,e){var r;return(r=t.a[0]m[0]&&i.push(new u(m,v,s,f),new u(v,m,o,f))}i.sort(c);for(var y=i[0].a[0]-(1+Math.abs(i[0].a[0]))*Math.pow(2,-52),b=[new l([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=i.length;f<_;++f){var w=i[f],M=w.type;M===a?h(x,b,t,w.a,w.idx):M===s?p(b,t,w):g(b,t,w)}return x}},{"binary-search-bounds":55,"robust-orientation":321}],54:[function(t,e,r){"use strict";var n=t("binary-search-bounds");function i(t,e){this.stars=t,this.edges=e}e.exports=function(t,e){for(var r=new Array(t),n=0;n=0}}(),a.removeTriangle=function(t,e,r){var n=this.stars;o(n[t],e,r),o(n[e],r,t),o(n[r],t,e)},a.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},a.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;n>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],56:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1,r=1;rr?r:t:te?e:t}},{}],60:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n;if(r){n=e;for(var i=new Array(e.length),a=0;ae[2]?1:0)}function m(t,e,r){if(0!==t.length){if(e)for(var n=0;n=0;--a){var b=e[c=(E=n[a])[0]],x=b[0],_=b[1],w=t[x],M=t[_];if((w[0]-M[0]||w[1]-M[1])<0){var A=x;x=_,_=A}b[0]=x;var T,k=b[1]=E[1];for(i&&(T=b[2]);a>0&&n[a-1][0]===c;){var E,S=(E=n[--a])[1];i?e.push([k,S,T]):e.push([k,S]),k=S}i?e.push([k,_,T]):e.push([k,_])}return h}(t,e,h,v,r));return m(e,y,r),!!y||(h.length>0||v.length>0)}},{"./lib/rat-seg-intersect":61,"big-rat":23,"big-rat/cmp":21,"big-rat/to-float":35,"box-intersect":40,nextafter:286,"rat-vec":310,"robust-segment-intersect":324,"union-find":349}],61:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var a=s(e,t),f=s(n,r),h=c(a,f);if(0===o(h))return null;var d=s(t,r),p=c(f,d),g=i(p,h),v=u(a,g);return l(t,v)};var n=t("big-rat/mul"),i=t("big-rat/div"),a=t("big-rat/sub"),o=t("big-rat/sign"),s=t("rat-vec/sub"),l=t("rat-vec/add"),u=t("rat-vec/muls");function c(t,e){return a(n(t[0],e[1]),n(t[1],e[0]))}},{"big-rat/div":22,"big-rat/mul":32,"big-rat/sign":33,"big-rat/sub":34,"rat-vec/add":309,"rat-vec/muls":311,"rat-vec/sub":312}],62:[function(t,e,r){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],63:[function(t,e,r){"use strict";var n=t("color-rgba"),i=t("clamp"),a=t("dtype");e.exports=function(t,e){"float"!==e&&e||(e="array"),"uint"===e&&(e="uint8"),"uint_clamped"===e&&(e="uint8_clamped");var r=new(a(e))(4),o="uint8"!==e&&"uint8_clamped"!==e;return t.length&&"string"!=typeof t||((t=n(t))[0]/=255,t[1]/=255,t[2]/=255),function(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||!!(Array.isArray(t)&&(t[0]>1||0===t[0])&&(t[1]>1||0===t[1])&&(t[2]>1||0===t[2])&&(!t[3]||t[3]>1))}(t)?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:255,o&&(r[0]/=255,r[1]/=255,r[2]/=255,r[3]/=255),r):(o?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:1):(r[0]=i(Math.floor(255*t[0]),0,255),r[1]=i(Math.floor(255*t[1]),0,255),r[2]=i(Math.floor(255*t[2]),0,255),r[3]=null==t[3]?255:i(Math.floor(255*t[3]),0,255)),r)}},{clamp:59,"color-rgba":65,dtype:86}],64:[function(t,e,r){(function(r){"use strict";var n=t("color-name"),i=t("is-plain-obj"),a=t("defined");e.exports=function(t){var e,s,l=[],u=1;if("string"==typeof t)if(n[t])l=n[t].slice(),s="rgb";else if("transparent"===t)u=0,s="rgb",l=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var c=t.slice(1),f=c.length,h=f<=4;u=1,h?(l=[parseInt(c[0]+c[0],16),parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16)],4===f&&(u=parseInt(c[3]+c[3],16)/255)):(l=[parseInt(c[0]+c[1],16),parseInt(c[2]+c[3],16),parseInt(c[4]+c[5],16)],8===f&&(u=parseInt(c[6]+c[7],16)/255)),l[0]||(l[0]=0),l[1]||(l[1]=0),l[2]||(l[2]=0),s="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var d=e[1],c=d.replace(/a$/,"");s=c;var f="cmyk"===c?4:"gray"===c?1:3;l=e[2].trim().split(/\s*,\s*/).map(function(t,e){if(/%$/.test(t))return e===f?parseFloat(t)/100:"rgb"===c?255*parseFloat(t)/100:parseFloat(t);if("h"===c[e]){if(/deg$/.test(t))return parseFloat(t);if(void 0!==o[t])return o[t]}return parseFloat(t)}),d===c&&l.push(1),u=void 0===l[f]?1:l[f],l=l.slice(0,f)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(l=t.match(/([0-9]+)/g).map(function(t){return parseFloat(t)}),s=t.match(/([a-z])/gi).join("").toLowerCase());else if(isNaN(t))if(i(t)){var p=a(t.r,t.red,t.R,null);null!==p?(s="rgb",l=[p,a(t.g,t.green,t.G),a(t.b,t.blue,t.B)]):(s="hsl",l=[a(t.h,t.hue,t.H),a(t.s,t.saturation,t.S),a(t.l,t.lightness,t.L,t.b,t.brightness)]),u=a(t.a,t.alpha,t.opacity,1),null!=t.opacity&&(u/=100)}else(Array.isArray(t)||r.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(t))&&(l=[t[0],t[1],t[2]],s="rgb",u=4===t.length?t[3]:1);else s="rgb",l=[t>>>16,(65280&t)>>>8,255&t];return{space:s,values:l,alpha:u}};var o={red:0,orange:60,yellow:120,green:180,blue:240,purple:300}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"color-name":62,defined:83,"is-plain-obj":260}],65:[function(t,e,r){"use strict";var n=t("color-parse"),i=t("color-space/hsl"),a=t("clamp");e.exports=function(t){var e,r=n(t);return r.space?((e=Array(3))[0]=a(r.values[0],0,255),e[1]=a(r.values[1],0,255),e[2]=a(r.values[2],0,255),"h"===r.space[0]&&(e=i.rgb(e)),e.push(a(r.alpha,0,1)),e):[]}},{clamp:59,"color-parse":64,"color-space/hsl":66}],66:[function(t,e,r){"use strict";var n=t("./rgb");e.exports={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e,r,n,i,a,o=t[0]/360,s=t[1]/100,l=t[2]/100;if(0===s)return[a=255*l,a,a];e=2*l-(r=l<.5?l*(1+s):l+s-l*s),i=[0,0,0];for(var u=0;u<3;u++)(n=o+1/3*-(u-1))<0?n++:n>1&&n--,a=6*n<1?e+6*(r-e)*n:2*n<1?r:3*n<2?e+(r-e)*(2/3-n)*6:e,i[u]=255*a;return i}},n.hsl=function(t){var e,r,n=t[0]/255,i=t[1]/255,a=t[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),l=s-o;return s===o?e=0:n===s?e=(i-a)/l:i===s?e=2+(a-n)/l:a===s&&(e=4+(n-i)/l),(e=Math.min(60*e,360))<0&&(e+=360),r=(o+s)/2,[e,100*(s===o?0:r<=.5?l/(s+o):l/(2-s-o)),100*r]}},{"./rgb":67}],67:[function(t,e,r){"use strict";e.exports={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]}},{}],68:[function(t,e,r){e.exports={jet:[{index:0,rgb:[0,0,131]},{index:.125,rgb:[0,60,170]},{index:.375,rgb:[5,255,255]},{index:.625,rgb:[255,255,0]},{index:.875,rgb:[250,0,0]},{index:1,rgb:[128,0,0]}],hsv:[{index:0,rgb:[255,0,0]},{index:.169,rgb:[253,255,2]},{index:.173,rgb:[247,255,2]},{index:.337,rgb:[0,252,4]},{index:.341,rgb:[0,252,10]},{index:.506,rgb:[1,249,255]},{index:.671,rgb:[2,0,253]},{index:.675,rgb:[8,0,253]},{index:.839,rgb:[255,0,251]},{index:.843,rgb:[255,0,245]},{index:1,rgb:[255,0,6]}],hot:[{index:0,rgb:[0,0,0]},{index:.3,rgb:[230,0,0]},{index:.6,rgb:[255,210,0]},{index:1,rgb:[255,255,255]}],cool:[{index:0,rgb:[0,255,255]},{index:1,rgb:[255,0,255]}],spring:[{index:0,rgb:[255,0,255]},{index:1,rgb:[255,255,0]}],summer:[{index:0,rgb:[0,128,102]},{index:1,rgb:[255,255,102]}],autumn:[{index:0,rgb:[255,0,0]},{index:1,rgb:[255,255,0]}],winter:[{index:0,rgb:[0,0,255]},{index:1,rgb:[0,255,128]}],bone:[{index:0,rgb:[0,0,0]},{index:.376,rgb:[84,84,116]},{index:.753,rgb:[169,200,200]},{index:1,rgb:[255,255,255]}],copper:[{index:0,rgb:[0,0,0]},{index:.804,rgb:[255,160,102]},{index:1,rgb:[255,199,127]}],greys:[{index:0,rgb:[0,0,0]},{index:1,rgb:[255,255,255]}],yignbu:[{index:0,rgb:[8,29,88]},{index:.125,rgb:[37,52,148]},{index:.25,rgb:[34,94,168]},{index:.375,rgb:[29,145,192]},{index:.5,rgb:[65,182,196]},{index:.625,rgb:[127,205,187]},{index:.75,rgb:[199,233,180]},{index:.875,rgb:[237,248,217]},{index:1,rgb:[255,255,217]}],greens:[{index:0,rgb:[0,68,27]},{index:.125,rgb:[0,109,44]},{index:.25,rgb:[35,139,69]},{index:.375,rgb:[65,171,93]},{index:.5,rgb:[116,196,118]},{index:.625,rgb:[161,217,155]},{index:.75,rgb:[199,233,192]},{index:.875,rgb:[229,245,224]},{index:1,rgb:[247,252,245]}],yiorrd:[{index:0,rgb:[128,0,38]},{index:.125,rgb:[189,0,38]},{index:.25,rgb:[227,26,28]},{index:.375,rgb:[252,78,42]},{index:.5,rgb:[253,141,60]},{index:.625,rgb:[254,178,76]},{index:.75,rgb:[254,217,118]},{index:.875,rgb:[255,237,160]},{index:1,rgb:[255,255,204]}],bluered:[{index:0,rgb:[0,0,255]},{index:1,rgb:[255,0,0]}],rdbu:[{index:0,rgb:[5,10,172]},{index:.35,rgb:[106,137,247]},{index:.5,rgb:[190,190,190]},{index:.6,rgb:[220,170,132]},{index:.7,rgb:[230,145,90]},{index:1,rgb:[178,10,28]}],picnic:[{index:0,rgb:[0,0,255]},{index:.1,rgb:[51,153,255]},{index:.2,rgb:[102,204,255]},{index:.3,rgb:[153,204,255]},{index:.4,rgb:[204,204,255]},{index:.5,rgb:[255,255,255]},{index:.6,rgb:[255,204,255]},{index:.7,rgb:[255,153,255]},{index:.8,rgb:[255,102,204]},{index:.9,rgb:[255,102,102]},{index:1,rgb:[255,0,0]}],rainbow:[{index:0,rgb:[150,0,90]},{index:.125,rgb:[0,0,200]},{index:.25,rgb:[0,25,255]},{index:.375,rgb:[0,152,255]},{index:.5,rgb:[44,255,150]},{index:.625,rgb:[151,255,0]},{index:.75,rgb:[255,234,0]},{index:.875,rgb:[255,111,0]},{index:1,rgb:[255,0,0]}],portland:[{index:0,rgb:[12,51,131]},{index:.25,rgb:[10,136,186]},{index:.5,rgb:[242,211,56]},{index:.75,rgb:[242,143,56]},{index:1,rgb:[217,30,30]}],blackbody:[{index:0,rgb:[0,0,0]},{index:.2,rgb:[230,0,0]},{index:.4,rgb:[230,210,0]},{index:.7,rgb:[255,255,255]},{index:1,rgb:[160,200,255]}],earth:[{index:0,rgb:[0,0,130]},{index:.1,rgb:[0,180,180]},{index:.2,rgb:[40,210,40]},{index:.4,rgb:[230,230,50]},{index:.6,rgb:[120,70,20]},{index:1,rgb:[255,255,255]}],electric:[{index:0,rgb:[0,0,0]},{index:.15,rgb:[30,0,100]},{index:.4,rgb:[120,0,100]},{index:.6,rgb:[160,90,0]},{index:.8,rgb:[230,200,0]},{index:1,rgb:[255,250,220]}],alpha:[{index:0,rgb:[255,255,255,0]},{index:1,rgb:[255,255,255,1]}],viridis:[{index:0,rgb:[68,1,84]},{index:.13,rgb:[71,44,122]},{index:.25,rgb:[59,81,139]},{index:.38,rgb:[44,113,142]},{index:.5,rgb:[33,144,141]},{index:.63,rgb:[39,173,129]},{index:.75,rgb:[92,200,99]},{index:.88,rgb:[170,220,50]},{index:1,rgb:[253,231,37]}],inferno:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[31,12,72]},{index:.25,rgb:[85,15,109]},{index:.38,rgb:[136,34,106]},{index:.5,rgb:[186,54,85]},{index:.63,rgb:[227,89,51]},{index:.75,rgb:[249,140,10]},{index:.88,rgb:[249,201,50]},{index:1,rgb:[252,255,164]}],magma:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[28,16,68]},{index:.25,rgb:[79,18,123]},{index:.38,rgb:[129,37,129]},{index:.5,rgb:[181,54,122]},{index:.63,rgb:[229,80,100]},{index:.75,rgb:[251,135,97]},{index:.88,rgb:[254,194,135]},{index:1,rgb:[252,253,191]}],plasma:[{index:0,rgb:[13,8,135]},{index:.13,rgb:[75,3,161]},{index:.25,rgb:[125,3,168]},{index:.38,rgb:[168,34,150]},{index:.5,rgb:[203,70,121]},{index:.63,rgb:[229,107,93]},{index:.75,rgb:[248,148,65]},{index:.88,rgb:[253,195,40]},{index:1,rgb:[240,249,33]}],warm:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[172,0,187]},{index:.25,rgb:[219,0,170]},{index:.38,rgb:[255,0,130]},{index:.5,rgb:[255,63,74]},{index:.63,rgb:[255,123,0]},{index:.75,rgb:[234,176,0]},{index:.88,rgb:[190,228,0]},{index:1,rgb:[147,255,0]}],cool:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[116,0,218]},{index:.25,rgb:[98,74,237]},{index:.38,rgb:[68,146,231]},{index:.5,rgb:[0,204,197]},{index:.63,rgb:[0,247,146]},{index:.75,rgb:[0,255,88]},{index:.88,rgb:[40,255,8]},{index:1,rgb:[147,255,0]}],"rainbow-soft":[{index:0,rgb:[125,0,179]},{index:.1,rgb:[199,0,180]},{index:.2,rgb:[255,0,121]},{index:.3,rgb:[255,108,0]},{index:.4,rgb:[222,194,0]},{index:.5,rgb:[150,255,0]},{index:.6,rgb:[0,255,55]},{index:.7,rgb:[0,246,150]},{index:.8,rgb:[50,167,222]},{index:.9,rgb:[103,51,235]},{index:1,rgb:[124,0,186]}],bathymetry:[{index:0,rgb:[40,26,44]},{index:.13,rgb:[59,49,90]},{index:.25,rgb:[64,76,139]},{index:.38,rgb:[63,110,151]},{index:.5,rgb:[72,142,158]},{index:.63,rgb:[85,174,163]},{index:.75,rgb:[120,206,163]},{index:.88,rgb:[187,230,172]},{index:1,rgb:[253,254,204]}],cdom:[{index:0,rgb:[47,15,62]},{index:.13,rgb:[87,23,86]},{index:.25,rgb:[130,28,99]},{index:.38,rgb:[171,41,96]},{index:.5,rgb:[206,67,86]},{index:.63,rgb:[230,106,84]},{index:.75,rgb:[242,149,103]},{index:.88,rgb:[249,193,135]},{index:1,rgb:[254,237,176]}],chlorophyll:[{index:0,rgb:[18,36,20]},{index:.13,rgb:[25,63,41]},{index:.25,rgb:[24,91,59]},{index:.38,rgb:[13,119,72]},{index:.5,rgb:[18,148,80]},{index:.63,rgb:[80,173,89]},{index:.75,rgb:[132,196,122]},{index:.88,rgb:[175,221,162]},{index:1,rgb:[215,249,208]}],density:[{index:0,rgb:[54,14,36]},{index:.13,rgb:[89,23,80]},{index:.25,rgb:[110,45,132]},{index:.38,rgb:[120,77,178]},{index:.5,rgb:[120,113,213]},{index:.63,rgb:[115,151,228]},{index:.75,rgb:[134,185,227]},{index:.88,rgb:[177,214,227]},{index:1,rgb:[230,241,241]}],"freesurface-blue":[{index:0,rgb:[30,4,110]},{index:.13,rgb:[47,14,176]},{index:.25,rgb:[41,45,236]},{index:.38,rgb:[25,99,212]},{index:.5,rgb:[68,131,200]},{index:.63,rgb:[114,156,197]},{index:.75,rgb:[157,181,203]},{index:.88,rgb:[200,208,216]},{index:1,rgb:[241,237,236]}],"freesurface-red":[{index:0,rgb:[60,9,18]},{index:.13,rgb:[100,17,27]},{index:.25,rgb:[142,20,29]},{index:.38,rgb:[177,43,27]},{index:.5,rgb:[192,87,63]},{index:.63,rgb:[205,125,105]},{index:.75,rgb:[216,162,148]},{index:.88,rgb:[227,199,193]},{index:1,rgb:[241,237,236]}],oxygen:[{index:0,rgb:[64,5,5]},{index:.13,rgb:[106,6,15]},{index:.25,rgb:[144,26,7]},{index:.38,rgb:[168,64,3]},{index:.5,rgb:[188,100,4]},{index:.63,rgb:[206,136,11]},{index:.75,rgb:[220,174,25]},{index:.88,rgb:[231,215,44]},{index:1,rgb:[248,254,105]}],par:[{index:0,rgb:[51,20,24]},{index:.13,rgb:[90,32,35]},{index:.25,rgb:[129,44,34]},{index:.38,rgb:[159,68,25]},{index:.5,rgb:[182,99,19]},{index:.63,rgb:[199,134,22]},{index:.75,rgb:[212,171,35]},{index:.88,rgb:[221,210,54]},{index:1,rgb:[225,253,75]}],phase:[{index:0,rgb:[145,105,18]},{index:.13,rgb:[184,71,38]},{index:.25,rgb:[186,58,115]},{index:.38,rgb:[160,71,185]},{index:.5,rgb:[110,97,218]},{index:.63,rgb:[50,123,164]},{index:.75,rgb:[31,131,110]},{index:.88,rgb:[77,129,34]},{index:1,rgb:[145,105,18]}],salinity:[{index:0,rgb:[42,24,108]},{index:.13,rgb:[33,50,162]},{index:.25,rgb:[15,90,145]},{index:.38,rgb:[40,118,137]},{index:.5,rgb:[59,146,135]},{index:.63,rgb:[79,175,126]},{index:.75,rgb:[120,203,104]},{index:.88,rgb:[193,221,100]},{index:1,rgb:[253,239,154]}],temperature:[{index:0,rgb:[4,35,51]},{index:.13,rgb:[23,51,122]},{index:.25,rgb:[85,59,157]},{index:.38,rgb:[129,79,143]},{index:.5,rgb:[175,95,130]},{index:.63,rgb:[222,112,101]},{index:.75,rgb:[249,146,66]},{index:.88,rgb:[249,196,65]},{index:1,rgb:[232,250,91]}],turbidity:[{index:0,rgb:[34,31,27]},{index:.13,rgb:[65,50,41]},{index:.25,rgb:[98,69,52]},{index:.38,rgb:[131,89,57]},{index:.5,rgb:[161,112,59]},{index:.63,rgb:[185,140,66]},{index:.75,rgb:[202,174,88]},{index:.88,rgb:[216,209,126]},{index:1,rgb:[233,246,171]}],"velocity-blue":[{index:0,rgb:[17,32,64]},{index:.13,rgb:[35,52,116]},{index:.25,rgb:[29,81,156]},{index:.38,rgb:[31,113,162]},{index:.5,rgb:[50,144,169]},{index:.63,rgb:[87,173,176]},{index:.75,rgb:[149,196,189]},{index:.88,rgb:[203,221,211]},{index:1,rgb:[254,251,230]}],"velocity-green":[{index:0,rgb:[23,35,19]},{index:.13,rgb:[24,64,38]},{index:.25,rgb:[11,95,45]},{index:.38,rgb:[39,123,35]},{index:.5,rgb:[95,146,12]},{index:.63,rgb:[152,165,18]},{index:.75,rgb:[201,186,69]},{index:.88,rgb:[233,216,137]},{index:1,rgb:[255,253,205]}],cubehelix:[{index:0,rgb:[0,0,0]},{index:.07,rgb:[22,5,59]},{index:.13,rgb:[60,4,105]},{index:.2,rgb:[109,1,135]},{index:.27,rgb:[161,0,147]},{index:.33,rgb:[210,2,142]},{index:.4,rgb:[251,11,123]},{index:.47,rgb:[255,29,97]},{index:.53,rgb:[255,54,69]},{index:.6,rgb:[255,85,46]},{index:.67,rgb:[255,120,34]},{index:.73,rgb:[255,157,37]},{index:.8,rgb:[241,191,57]},{index:.87,rgb:[224,220,93]},{index:.93,rgb:[218,241,142]},{index:1,rgb:[227,253,198]}]}},{}],69:[function(t,e,r){"use strict";var n=t("./colorScale"),i=t("lerp");function a(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}function o(t){for(var e,r="#",n=0;n<3;++n)r+=("00"+(e=(e=t[n]).toString(16))).substr(e.length);return r}function s(t){return"rgba("+t.join(",")+")"}e.exports=function(t){var e,r,l,u,c,f,h,d,p,g;t||(t={});d=(t.nshades||72)-1,h=t.format||"hex",(f=t.colormap)||(f="jet");if("string"==typeof f){if(f=f.toLowerCase(),!n[f])throw Error(f+" not a supported colorscale");c=n[f]}else{if(!Array.isArray(f))throw Error("unsupported colormap option",f);c=f.slice()}if(c.length>d)throw new Error(f+" map requires nshades to be at least size "+c.length);p=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:t.alpha.slice():"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1];e=c.map(function(t){return Math.round(t.index*d)}),p[0]=Math.min(Math.max(p[0],0),1),p[1]=Math.min(Math.max(p[1],0),1);var v=c.map(function(t,e){var r=c[e].index,n=c[e].rgb.slice();return 4===n.length&&n[3]>=0&&n[3]<=1?n:(n[3]=p[0]+(p[1]-p[0])*r,n)}),m=[];for(g=0;g0?-1:l(t,e,a)?-1:1:0===s?u>0?1:l(t,e,r)?1:-1:i(u-s)}var h=n(t,e,r);if(h>0)return o>0&&n(t,e,a)>0?1:-1;if(h<0)return o>0||n(t,e,a)>0?1:-1;var d=n(t,e,a);return d>0?1:l(t,e,r)?1:-1};var n=t("robust-orientation"),i=t("signum"),a=t("two-sum"),o=t("robust-product"),s=t("robust-sum");function l(t,e,r){var n=a(t[0],-e[0]),i=a(t[1],-e[1]),l=a(r[0],-e[0]),u=a(r[1],-e[1]),c=s(o(n,l),o(i,u));return c[c.length-1]>=0}},{"robust-orientation":321,"robust-product":322,"robust-sum":326,signum:327,"two-sum":347}],71:[function(t,e,r){e.exports=function(t,e){var r=t.length,a=t.length-e.length;if(a)return a;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||n(t[0],t[1])-n(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=n(t[0],t[1]),u=n(e[0],e[1]);return n(l,t[2])-n(u,e[2])||n(l+t[2],o)-n(u+e[2],s);case 4:var c=t[0],f=t[1],h=t[2],d=t[3],p=e[0],g=e[1],v=e[2],m=e[3];return c+f+h+d-(p+g+v+m)||n(c,f,h,d)-n(p,g,v,m,p)||n(c+f,c+h,c+d,f+h,f+d,h+d)-n(p+g,p+v,p+m,g+v,g+m,v+m)||n(c+f+h,c+f+d,c+h+d,f+h+d)-n(p+g+v,p+g+m,p+v+m,g+v+m);default:for(var y=t.slice().sort(i),b=e.slice().sort(i),x=0;xt[r][0]&&(r=n);return er?[[r],[e]]:[[e]]}},{}],75:[function(t,e,r){"use strict";e.exports=function(t){var e=n(t),r=e.length;if(r<=2)return[];for(var i=new Array(r),a=e[r-1],o=0;o=e[l]&&(s+=1);a[o]=s}}return t}(o,r)}};var n=t("incremental-convex-hull"),i=t("affine-hull")},{"affine-hull":14,"incremental-convex-hull":253}],77:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i,a){var o=i-1,s=i*i,l=o*o,u=(1+2*i)*l,c=i*l,f=s*(3-2*i),h=s*o;if(t.length){a||(a=new Array(t.length));for(var d=t.length-1;d>=0;--d)a[d]=u*t[d]+c*e[d]+f*r[d]+h*n[d];return a}return u*t+c*e+f*r+h*n},e.exports.derivative=function(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,u=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var c=t.length-1;c>=0;--c)a[c]=o*t[c]+s*e[c]+l*r[c]+u*n[c];return a}return o*t+s*e+l*r[c]+u*n}},{}],78:[function(t,e,r){"use strict";var n=t("./lib/thunk.js");function i(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}e.exports=function(t){var e=new i;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var a=0;a0)throw new Error("cwise: pre() block may not reference array args");if(a0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(a),e.shimArgs.push("scalar"+a);else if("index"===o){if(e.indexArgs.push(a),a0)throw new Error("cwise: pre() block may not reference array index");if(a0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(a),ar.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},{"./lib/thunk.js":80}],79:[function(t,e,r){"use strict";var n=t("uniq");function i(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],u=[],c=0,f=0;for(n=0;n0&&l.push("var "+u.join(",")),n=a-1;n>=0;--n)c=t[n],l.push(["for(i",n,"=0;i",n,"0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",c,"]"].join(""))),l.push("}")}return l.join("\n")}function a(t,e,r){for(var n=t.body,i=[],a=[],o=0;o0&&y.push("shape=SS.slice(0)"),t.indexArgs.length>0){var b=new Array(r);for(l=0;l0&&m.push("var "+y.join(",")),l=0;l3&&m.push(a(t.pre,t,s));var M=a(t.body,t,s),A=function(t){for(var e=0,r=t[0].length;e0,u=[],c=0;c0;){"].join("")),u.push(["if(j",c,"<",s,"){"].join("")),u.push(["s",e[c],"=j",c].join("")),u.push(["j",c,"=0"].join("")),u.push(["}else{s",e[c],"=",s].join("")),u.push(["j",c,"-=",s,"}"].join("")),l&&u.push(["index[",e[c],"]=j",c].join(""));for(c=0;c3&&m.push(a(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+m.join("\n")+"\n----------");var T=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",A,function(t){for(var e=new Array(t.length),r=!0,n=0;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}(s)].join("");return new Function(["function ",T,"(",v.join(","),"){",m.join("\n"),"} return ",T].join(""))()}},{uniq:350}],80:[function(t,e,r){"use strict";var n=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],u=[],c=0;c0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[c]))),u.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[c])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),c=0;ce?1:t>=e?0:NaN}function d(t){return null===t?NaN:+t}function p(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}t.ascending=h,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},t.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},t.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),i=n){r=i=n;break}for(;++an&&(r=n),i1)return o/(l-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(h);function m(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return h(t(e),r)}:t)},t.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,a<2&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],i=new Array(r<0?0:r);e=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r};var y=Math.abs;function b(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function x(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,i=[],a=function(t){var e=1;for(;t*e%1;)e*=10;return e}(y(r)),o=-1;if(t*=a,e*=a,(r*=a)<0)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=i.length)return r?r.call(n,a):e?a.sort(e):a;for(var l,u,c,f,h=-1,d=a.length,p=i[s++],g=new x;++h=i.length)return e;var n=[],o=a[r++];return e.forEach(function(e,i){n.push({key:e,values:t(i,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return i.push(t),n},n.sortKeys=function(t){return a[i.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new C;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(U,"\\$&")};var U=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,V={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function H(t){return V(t,X),t}var q=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},W=function(t,e){var r=t.matches||t[P(t,"matchesSelector")];return(W=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(q=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,W=Sizzle.matchesSelector),t.selection=function(){return t.select(i.documentElement)};var X=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return q(t,this)}}function Z(t){return"function"==typeof t?t:function(){return G(t,this)}}X.select=function(t){var e,r,n,i,a=[];t=Y(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),J.hasOwnProperty(r)?{space:J[r],local:t}:t}},X.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each($(r,e[r]));return this}return this.each($(e,r))},X.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,i=-1;if(e=r.classList){for(;++i=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},X.sort=function(t){t=function(t){arguments.length||(t=h);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var l=pt.get(e);function u(){var t=this[a];t&&(this.removeEventListener(e,t,t.$),delete this[a])}return l&&(e=l,s=vt),o?r?function(){var t=s(r,n(arguments));u.call(this),this.addEventListener(e,this[a]=t,t.$=i),t._=r}:u:r?I:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var i in this)if(r=i.match(n)){var a=this[i];this.removeEventListener(r[1],a,a.$),delete this[i]}}}t.selection.enter=ft,t.selection.enter.prototype=ht,ht.append=X.append,ht.empty=X.empty,ht.node=X.node,ht.call=X.call,ht.size=X.size,ht.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++s=n&&(n=e+1);!(o=s[n])&&++n0?1:t<0?-1:0}function Rt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function Pt(t){return t>1?0:t<-1?Tt:Math.acos(t)}function zt(t){return t>1?St:t<-1?-St:Math.asin(t)}function It(t){return((t=Math.exp(t))+1/t)/2}function Nt(t){return(t=Math.sin(t/2))*t}var Dt=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],u=e[2],c=s-i,f=l-a,h=c*c+f*f;if(h0&&(e=e.transition().duration(g)),e.call(w.event)}function E(){u&&u.domain(l.range().map(function(t){return(t-h.x)/h.k}).map(l.invert)),f&&f.domain(c.range().map(function(t){return(t-h.y)/h.k}).map(c.invert))}function S(t){v++||t({type:"zoomstart"})}function L(t){E(),t({type:"zoom",scale:h.k,translate:[h.x,h.y]})}function C(t){--v||(t({type:"zoomend"}),r=null)}function O(){var e=this,r=_.of(e,arguments),n=0,i=t.select(o(e)).on(y,function(){n=1,T(t.mouse(e),a),L(r)}).on(b,function(){i.on(y,null).on(b,null),s(n),C(r)}),a=M(t.mouse(e)),s=bt(e);fs.call(e),S(r)}function R(){var e,r=this,n=_.of(r,arguments),i={},a=0,o=".zoom-"+t.event.changedTouches[0].identifier,l="touchmove"+o,u="touchend"+o,c=[],f=t.select(r),d=bt(r);function p(){var n=t.touches(r);return e=h.k,n.forEach(function(t){t.identifier in i&&(i[t.identifier]=M(t))}),n}function g(){var e=t.event.target;t.select(e).on(l,v).on(u,y),c.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){m=d[0];var b=d[1],x=m[0]-b[0],_=m[1]-b[1];a=x*x+_*_}}function v(){var o,l,u,c,f=t.touches(r);fs.call(r);for(var h=0,d=f.length;h360?t-=360:t<0&&(t+=360),t<60?n+(i-n)*t/60:t<180?i:t<240?n+(i-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(i=r<=.5?r*(1+e):r+e-r*e),new ae(a(t+120),a(t),a(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Yt?e.l:(e=he((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Ht.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Vt(this.h,this.s,this.l/t)},Ht.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Vt(this.h,this.s,t*this.l)},Ht.rgb=function(){return qt(this.h,this.s,this.l)},t.hcl=Gt;var Wt=Gt.prototype=new Ut;function Xt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Yt(r,Math.cos(t*=Lt)*e,Math.sin(t)*e)}function Yt(t,e,r){return this instanceof Yt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Yt?new Yt(t.l,t.a,t.b):t instanceof Gt?Xt(t.h,t.c,t.l):he((t=ae(t)).r,t.g,t.b):new Yt(t,e,r)}Wt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Zt*(arguments.length?t:1)))},Wt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Zt*(arguments.length?t:1)))},Wt.rgb=function(){return Xt(this.h,this.c,this.l).rgb()},t.lab=Yt;var Zt=18,Qt=.95047,Jt=1,$t=1.08883,Kt=Yt.prototype=new Ut;function te(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return new ae(ie(3.2404542*(i=re(i)*Qt)-1.5371385*(n=re(n)*Jt)-.4985314*(a=re(a)*$t)),ie(-.969266*i+1.8760108*n+.041556*a),ie(.0556434*i-.2040259*n+1.0572252*a))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Ct,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ie(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ae(t,e,r){return this instanceof ae?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ae?new ae(t.r,t.g,t.b):ce(""+t,ae,qt):new ae(t,e,r)}function oe(t){return new ae(t>>16,t>>8&255,255&t)}function se(t){return oe(t)+""}Kt.brighter=function(t){return new Yt(Math.min(100,this.l+Zt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Yt(Math.max(0,this.l-Zt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ae;var le=ae.prototype=new Ut;function ue(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ce(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(pe(i[0]),pe(i[1]),pe(i[2]))}return(a=ge.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o|=o>>4,s=240&a,s|=s>>4,l=15&a,l|=l<<4):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function fe(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=l<.5?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(e0&&l<1?0:n),new Vt(n,i,l)}function he(t,e,r){var n=ne((.4124564*(t=de(t))+.3575761*(e=de(e))+.1804375*(r=de(r)))/Qt),i=ne((.2126729*t+.7151522*e+.072175*r)/Jt);return Yt(116*i-16,500*(n-i),200*(i-ne((.0193339*t+.119192*e+.9503041*r)/$t)))}function de(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function pe(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}le.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=i.call(o,u)}catch(t){return void s.error.call(o,t)}s.load.call(o,t)}else s.error.call(o,u)}return!this.XDomainRequest||"withCredentials"in u||!/^(http(s)?:)?\/\//.test(e)||(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=f:u.onreadystatechange=function(){u.readyState>3&&f()},u.onprogress=function(e){var r=t.event;t.event=e;try{s.progress.call(o,u)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return i=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),u.open(t,e,!0),null==r||"accept"in l||(l.accept=r+",*/*"),u.setRequestHeader)for(var a in l)u.setRequestHeader(a,l[a]);return null!=r&&u.overrideMimeType&&u.overrideMimeType(r),null!=c&&(u.responseType=c),null!=i&&o.on("error",i).on("load",function(t){i(null,t)}),s.beforesend.call(o,u),u.send(null==n?null:n),o},o.abort=function(){return u.abort(),o},t.rebind(o,s,"on"),null==a?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(a))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=me(O),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function i(t,r,n){arguments.length<3&&(n=r,r=null);var i=ye(t,e,null==r?a:o(r),n);return i.row=function(t){return arguments.length?i.response(null==(r=t)?a:o(t)):r},i}function a(t){return i.parse(t.responseText)}function o(t){return function(e){return i.parse(e.responseText,t)}}function s(e){return e.map(l).join(t)}function l(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,e){var r;return i.parseRows(t,function(t,n){if(r)return r(t,n-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(i(t),r)}:i})},i.parseRows=function(t,e){var r,i,a={},o={},s=[],l=t.length,u=0,c=0;function f(){if(u>=l)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Te,e)),_e=0):(_e=1,Me(Te))}function ke(){for(var t=Date.now(),e=be;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Ee(){for(var t,e=be,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Se(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Le[8+n/3]};var Ce=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Oe=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Se(e,r))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),r))))}});function Re(t){return t+""}var Pe=t.time={},ze=Date;function Ie(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Ie.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ne.setUTCDate.apply(this._,arguments)},setDay:function(){Ne.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ne.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ne.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ne.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ne.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ne.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ne.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ne.setTime.apply(this._,arguments)}};var Ne=Date.prototype;function De(t,e,r){function n(e){var r=t(e),n=a(r,1);return e-r1)for(;o68?1900:2e3),r+i[0].length):-1}function Qe(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function Je(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function $e(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ir(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=y(e)/60|0,i=y(e)%60;return r+Ve(n,"0",2)+Ve(i,"0",2)}function ar(t,e,r){Ue.lastIndex=0;var n=Ue.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(r-=s,r+s)),!((l+=s+1)>e));)s=i[o=(o+1)%i.length];return a.reverse().join(n)}:O;return function(e){var n=Ce.exec(e),i=n[1]||" ",s=n[2]||">",l=n[3]||"-",u=n[4]||"",c=n[5],f=+n[6],h=n[7],d=n[8],p=n[9],g=1,v="",m="",y=!1,b=!0;switch(d&&(d=+d.substring(1)),(c||"0"===i&&"="===s)&&(c=i="0",s="="),p){case"n":h=!0,p="g";break;case"%":g=100,m="%",p="f";break;case"p":g=100,m="%",p="r";break;case"b":case"o":case"x":case"X":"#"===u&&(v="0"+p.toLowerCase());case"c":b=!1;case"d":y=!0,d=0;break;case"s":g=-1,p="r"}"$"===u&&(v=a[0],m=a[1]),"r"!=p||d||(p="g"),null!=d&&("g"==p?d=Math.max(1,Math.min(21,d)):"e"!=p&&"f"!=p||(d=Math.max(0,Math.min(20,d)))),p=Oe.get(p)||Re;var x=c&&h;return function(e){var n=m;if(y&&e%1)return"";var a=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===l?"":l;if(g<0){var u=t.formatPrefix(e,d);e=u.scale(e),n=u.symbol+m}else e*=g;var _,w,M=(e=p(e,d)).lastIndexOf(".");if(M<0){var A=b?e.lastIndexOf("e"):-1;A<0?(_=e,w=""):(_=e.substring(0,A),w=e.substring(A))}else _=e.substring(0,M),w=r+e.substring(M+1);!c&&h&&(_=o(_,1/0));var T=v.length+_.length+w.length+(x?0:a.length),k=T"===s?k+a+e:"^"===s?k.substring(0,T>>=1)+a+e+k.substring(T):a+(x?e:k+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,i=e.time,a=e.periods,o=e.days,s=e.shortDays,l=e.months,u=e.shortMonths;function c(t){var e=t.length;function r(r){for(var n,i,a,o=[],s=-1,l=0;++s=u)return-1;if(37===(i=e.charCodeAt(s++))){if(o=e.charAt(s++),!(a=w[o in je?e.charAt(s++):o])||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}c.utc=function(t){var e=c(t);function r(t){try{var r=new(ze=Ie);return r._=t,e(r)}finally{ze=Date}}return r.parse=function(t){try{ze=Ie;var r=e.parse(t);return r&&r._}finally{ze=Date}},r.toString=e.toString,r},c.multi=c.utc.multi=or;var h=t.map(),d=He(o),p=qe(o),g=He(s),v=qe(s),m=He(l),y=qe(l),b=He(u),x=qe(u);a.forEach(function(t,e){h.set(t.toLowerCase(),e)});var _={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:c(r),d:function(t,e){return Ve(t.getDate(),e,2)},e:function(t,e){return Ve(t.getDate(),e,2)},H:function(t,e){return Ve(t.getHours(),e,2)},I:function(t,e){return Ve(t.getHours()%12||12,e,2)},j:function(t,e){return Ve(1+Pe.dayOfYear(t),e,3)},L:function(t,e){return Ve(t.getMilliseconds(),e,3)},m:function(t,e){return Ve(t.getMonth()+1,e,2)},M:function(t,e){return Ve(t.getMinutes(),e,2)},p:function(t){return a[+(t.getHours()>=12)]},S:function(t,e){return Ve(t.getSeconds(),e,2)},U:function(t,e){return Ve(Pe.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Ve(Pe.mondayOfYear(t),e,2)},x:c(n),X:c(i),y:function(t,e){return Ve(t.getFullYear()%100,e,2)},Y:function(t,e){return Ve(t.getFullYear()%1e4,e,4)},Z:ir,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){d.lastIndex=0;var n=d.exec(e.slice(r));return n?(t.w=p.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){b.lastIndex=0;var n=b.exec(e.slice(r));return n?(t.m=x.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){m.lastIndex=0;var n=m.exec(e.slice(r));return n?(t.m=y.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:$e,e:$e,H:tr,I:tr,j:Ke,L:nr,m:Je,M:er,p:function(t,e,r){var n=h.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:We,w:Ge,W:Xe,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:Ze,Y:Ye,Z:Qe,"%":ar};return c}(e)}};var sr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function lr(){}t.format=sr.numberFormat,t.geo={},lr.prototype={s:0,t:0,add:function(t){cr(t,this.t,ur),cr(ur.s,this.s,this),this.s?this.t+=ur.t:this.s=ur.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ur=new lr;function cr(t,e,r){var n=r.s=t+e,i=n-t,a=n-i;r.t=t-a+(e-i)}function fr(t,e){t&&dr.hasOwnProperty(t.type)&&dr[t.type](t,e)}t.geo.stream=function(t,e){t&&hr.hasOwnProperty(t.type)?hr[t.type](t,e):fr(t,e)};var hr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++n=0?1:-1,s=o*a,l=Math.cos(e),u=Math.sin(e),c=i*u,f=n*l+c*Math.cos(s),h=c*o*Math.sin(s);Sr.add(Math.atan2(h,f)),r=t,n=l,i=u}Lr.point=function(o,s){Lr.point=a,r=(t=o)*Lt,n=Math.cos(s=(e=s)*Lt/2+Tt/4),i=Math.sin(s)},Lr.lineEnd=function(){a(t,e)}}function Or(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Rr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Pr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function zr(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Ir(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Nr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Dr(t){return[Math.atan2(t[1],t[0]),zt(t[2])]}function Fr(t,e){return y(t[0]-e[0])Mt?i=90:u<-Mt&&(r=-90),f[0]=e,f[1]=n}};function d(t,a){c.push(f=[e=t,n=t]),ai&&(i=a)}function p(t,o){var s=Or([t*Lt,o*Lt]);if(l){var u=Pr(l,s),c=Pr([u[1],-u[0],0],u);Nr(c),c=Dr(c);var f=t-a,h=f>0?1:-1,p=c[0]*Ct*h,g=y(f)>180;if(g^(h*ai&&(i=v);else if(g^(h*a<(p=(p+360)%360-180)&&pi&&(i=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>a?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else d(t,o);l=s,a=t}function g(){h.point=p}function v(){f[0]=e,f[1]=n,h.point=d,l=null}function m(t,e){if(l){var r=t-a;u+=y(r)>180?r+(r>0?360:-360):r}else o=t,s=e;Lr.point(t,e),p(t,e)}function b(){Lr.lineStart()}function x(){m(o,s),Lr.lineEnd(),y(u)>Mt&&(e=-(n=180)),f[0]=e,f[1]=n,l=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function M(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=d[1]),_(d[0],g[1])>_(g[0],g[1])&&(g[0]=d[0])):s.push(g=d);for(var l,u,d,p=-1/0,g=(o=0,s[u=s.length-1]);o<=u;g=d,++o)d=s[o],(l=_(g[1],d[0]))>p&&(p=l,e=d[0],n=g[1])}return c=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,i]]}}(),t.geo.centroid=function(e){mr=yr=br=xr=_r=wr=Mr=Ar=Tr=kr=Er=0,t.geo.stream(e,jr);var r=Tr,n=kr,i=Er,a=r*r+n*n+i*i;return a=0;--s)i.point((f=c[s])[0],f[1]);else n(d.x,d.p.x,-1,i);d=d.p}c=(d=d.o).z,p=!p}while(!d.v);i.lineEnd()}}}function Yr(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n=0?1:-1,M=w*_,A=M>Tt,T=p*b;if(Sr.add(Math.atan2(T*w*Math.sin(M),g*x+T*Math.cos(M))),a+=A?_+w*kt:_,A^h>=r^m>=r){var k=Pr(Or(f),Or(t));Nr(k);var E=Pr(i,k);Nr(E);var S=(A^_>=0?-1:1)*zt(E[2]);(n>S||n===S&&(k[0]||k[1]))&&(o+=A^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(a<-Mt||a0){for(b||(o.polygonStart(),b=!0),o.lineStart();++a1&&2&e&&r.push(r.pop().concat(r.shift())),s.push(r.filter(Jr))}return c}}function Jr(t){return t.length>1}function $r(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:I,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-St-Mt:St-t[1])-((e=e.x)[0]<0?e[1]-St-Mt:St-e[1])}var tn=Qr(Wr,function(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Tt:-Tt,l=y(a-r);y(l-Tt)0?St:-St),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Tt&&(y(r-i)Mt?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}(r,n,a,o),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),e=0),t.point(r=a,n=o),i=s},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var i;if(null==t)i=r*St,n.point(-Tt,i),n.point(0,i),n.point(Tt,i),n.point(Tt,0),n.point(Tt,-i),n.point(0,-i),n.point(-Tt,-i),n.point(-Tt,0),n.point(-Tt,i);else if(y(t[0]-e[0])>Mt){var a=t[0]0)){if(a/=h,h<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=r-l,h||!(a<0)){if(a/=h,h<0){if(a>f)return;a>c&&(c=a)}else if(h>0){if(a0)){if(a/=d,d<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=n-u,d||!(a<0)){if(a/=d,d<0){if(a>f)return;a>c&&(c=a)}else if(d>0){if(a0&&(i.a={x:l+c*h,y:u+c*d}),f<1&&(i.b={x:l+f*h,y:u+f*d}),i}}}}}}var rn=1e9;function nn(e,r,n,i){return function(l){var u,c,f,h,d,p,g,v,m,y,b,x=l,_=$r(),w=en(e,r,n,i),M={point:k,lineStart:function(){M.point=E,c&&c.push(f=[]);y=!0,m=!1,g=v=NaN},lineEnd:function(){u&&(E(h,d),p&&m&&_.rejoin(),u.push(_.buffer()));M.point=k,m&&l.lineEnd()},polygonStart:function(){l=_,u=[],c=[],b=!0},polygonEnd:function(){l=x,u=t.merge(u);var r=function(t){for(var e=0,r=c.length,n=t[1],i=0;in&&Rt(u,a,t)>0&&++e:a[1]<=n&&Rt(u,a,t)<0&&--e,u=a;return 0!==e}([e,i]),n=b&&r,a=u.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),A(null,null,1,l),l.lineEnd()),a&&Xr(u,o,r,A,l),l.polygonEnd()),u=c=f=null}};function A(t,o,l,u){var c=0,f=0;if(null==t||(c=a(t,l))!==(f=a(o,l))||s(t,o)<0^l>0)do{u.point(0===c||3===c?e:n,c>1?i:r)}while((c=(c+l+4)%4)!==f);else u.point(o[0],o[1])}function T(t,a){return e<=t&&t<=n&&r<=a&&a<=i}function k(t,e){T(t,e)&&l.point(t,e)}function E(t,e){var r=T(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(c&&f.push([t,e]),y)h=t,d=e,p=r,y=!1,r&&(l.lineStart(),l.point(t,e));else if(r&&m)l.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(m||(l.lineStart(),l.point(n.a.x,n.a.y)),l.point(n.b.x,n.b.y),r||l.lineEnd(),b=!1):r&&(l.lineStart(),l.point(t,e),b=!1)}g=t,v=e,m=r}return M};function a(t,i){return y(t[0]-e)0?0:3:y(t[0]-n)0?2:1:y(t[1]-r)0?1:0:i>0?3:2}function o(t,e){return s(t.x,e.x)}function s(t,e){var r=a(t,1),n=a(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Tt/3,n=Ln(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Tt/180,r=t[1]*Tt/180):[e/Tt*180,r/Tt*180]},i}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,i=1+r*(2*n-r),a=Math.sqrt(i)/n;function o(t,e){var r=Math.sqrt(i-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),a-r*Math.cos(t)]}return o.invert=function(t,e){var r=a-e;return[Math.atan2(t,r)/n,zt((i-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),(i=a(t)).valid=!0,i},extent:function(s){return arguments.length?(a=nn(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,i,a=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};function u(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}return u.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&i<.234&&n>=-.425&&n<-.214?o:i>=.166&&i<.234&&n>=-.214&&n<-.115?s:a).invert(t)},u.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},u.precision=function(t){return arguments.length?(a.precision(t),o.precision(t),s.precision(t),u):a.precision()},u.scale=function(t){return arguments.length?(a.scale(t),o.scale(.35*t),s.scale(t),u.translate(a.translate())):a.scale()},u.translate=function(t){if(!arguments.length)return a.translate();var e=a.scale(),c=+t[0],f=+t[1];return r=a.translate(t).clipExtent([[c-.455*e,f-.238*e],[c+.455*e,f+.238*e]]).stream(l).point,n=o.translate([c-.307*e,f+.201*e]).clipExtent([[c-.425*e+Mt,f+.12*e+Mt],[c-.214*e-Mt,f+.234*e-Mt]]).stream(l).point,i=s.translate([c-.205*e,f+.212*e]).clipExtent([[c-.214*e+Mt,f+.166*e+Mt],[c-.115*e-Mt,f+.234*e-Mt]]).stream(l).point,u},u.scale(1070)};var sn,ln,un,cn,fn,hn,dn={point:I,lineStart:I,lineEnd:I,polygonStart:function(){ln=0,dn.lineStart=pn},polygonEnd:function(){dn.lineStart=dn.lineEnd=dn.point=I,sn+=y(ln/2)}};function pn(){var t,e,r,n;function i(t,e){ln+=n*t-r*e,r=t,n=e}dn.point=function(a,o){dn.point=i,t=r=a,e=n=o},dn.lineEnd=function(){i(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);ehn&&(hn=e)},lineStart:I,lineEnd:I,polygonStart:I,polygonEnd:I};function vn(){var t=mn(4.5),e=[],r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=mn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function i(t,n){e.push("M",t,",",n),r.point=a}function a(t,r){e.push("L",t,",",r)}function o(){r.point=n}function s(){e.push("Z")}return r}function mn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var yn,bn={point:xn,lineStart:_n,lineEnd:wn,polygonStart:function(){bn.lineStart=Mn},polygonEnd:function(){bn.point=xn,bn.lineStart=_n,bn.lineEnd=wn}};function xn(t,e){br+=t,xr+=e,++_r}function _n(){var t,e;function r(r,n){var i=r-t,a=n-e,o=Math.sqrt(i*i+a*a);wr+=o*(t+r)/2,Mr+=o*(e+n)/2,Ar+=o,xn(t=r,e=n)}bn.point=function(n,i){bn.point=r,xn(t=n,e=i)}}function wn(){bn.point=xn}function Mn(){var t,e,r,n;function i(t,e){var i=t-r,a=e-n,o=Math.sqrt(i*i+a*a);wr+=o*(r+t)/2,Mr+=o*(n+e)/2,Ar+=o,Tr+=(o=n*t-r*e)*(r+t),kr+=o*(n+e),Er+=3*o,xn(r=t,n=e)}bn.point=function(a,o){bn.point=i,xn(t=r=a,e=n=o)},bn.lineEnd=function(){i(t,e)}}function An(t){var e=4.5,r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:I};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,kt)}function i(e,n){t.moveTo(e,n),r.point=a}function a(e,r){t.lineTo(e,r)}function o(){r.point=n}function s(){t.closePath()}return r}function Tn(t){var e=.5,r=Math.cos(30*Lt),n=16;function i(e){return(n?function(e){var r,i,o,s,l,u,c,f,h,d,p,g,v={point:m,lineStart:y,lineEnd:x,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=y}};function m(r,n){r=t(r,n),e.point(r[0],r[1])}function y(){f=NaN,v.point=b,e.lineStart()}function b(r,i){var o=Or([r,i]),s=t(r,i);a(f,h,c,d,p,g,f=s[0],h=s[1],c=r,d=o[0],p=o[1],g=o[2],n,e),e.point(f,h)}function x(){v.point=m,e.lineEnd()}function _(){y(),v.point=w,v.lineEnd=M}function w(t,e){b(r=t,e),i=f,o=h,s=d,l=p,u=g,v.point=b}function M(){a(f,h,c,d,p,g,i,o,r,s,l,u,n,e),v.lineEnd=x,x()}return v}:function(e){return En(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function a(n,i,o,s,l,u,c,f,h,d,p,g,v,m){var b=c-n,x=f-i,_=b*b+x*x;if(_>4*e&&v--){var w=s+d,M=l+p,A=u+g,T=Math.sqrt(w*w+M*M+A*A),k=Math.asin(A/=T),E=y(y(A)-1)e||y((b*O+x*R)/_-.5)>.3||s*d+l*p+u*g0&&16,i):Math.sqrt(e)},i}function kn(t){this.stream=t}function En(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sn(t){return Ln(function(){return t})()}function Ln(e){var r,n,i,a,o,s,l=Tn(function(t,e){return[(t=r(t,e))[0]*u+a,o-t[1]*u]}),u=150,c=480,f=250,h=0,d=0,p=0,g=0,v=0,m=tn,b=O,x=null,_=null;function w(t){return[(t=i(t[0]*Lt,t[1]*Lt))[0]*u+a,o-t[1]*u]}function M(t){return(t=i.invert((t[0]-a)/u,(o-t[1])/u))&&[t[0]*Ct,t[1]*Ct]}function A(){i=Gr(n=Pn(p,g,v),r);var t=r(h,d);return a=c-t[0]*u,o=f+t[1]*u,T()}function T(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Cn(m(n,l(b(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(m=null==t?(x=t,tn):function(t){var e=Math.cos(t),r=e>0,n=y(e)>Mt;return Qr(i,function(t){var e,s,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(f,h){var d,p=[f,h],g=i(f,h),v=r?g?0:o(f,h):g?o(f+(f<0?Tt:-Tt),h):0;if(!e&&(u=l=g)&&t.lineStart(),g!==l&&(d=a(e,p),(Fr(e,d)||Fr(p,d))&&(p[0]+=Mt,p[1]+=Mt,g=i(p[0],p[1]))),g!==l)c=0,g?(t.lineStart(),d=a(p,e),t.point(d[0],d[1])):(d=a(e,p),t.point(d[0],d[1]),t.lineEnd()),e=d;else if(n&&e&&r^g){var m;v&s||!(m=a(p,e,!0))||(c=0,r?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||e&&Fr(e,p)||t.point(p[0],p[1]),e=p,l=g,s=v},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return c|(u&&l)<<1}}},Dn(t,6*Lt),r?[0,-t]:[-Tt,t-Tt]);function i(t,r){return Math.cos(t)*Math.cos(r)>e}function a(t,r,n){var i=[1,0,0],a=Pr(Or(t),Or(r)),o=Rr(a,a),s=a[0],l=o-s*s;if(!l)return!n&&t;var u=e*o/l,c=-e*s/l,f=Pr(i,a),h=Ir(i,u);zr(h,Ir(a,c));var d=f,p=Rr(h,d),g=Rr(d,d),v=p*p-g*(Rr(h,h)-1);if(!(v<0)){var m=Math.sqrt(v),b=Ir(d,(-p-m)/g);if(zr(b,h),b=Dr(b),!n)return b;var x,_=t[0],w=r[0],M=t[1],A=r[1];w<_&&(x=_,_=w,w=x);var T=w-_,k=y(T-Tt)0^b[1]<(y(b[0]-_)Tt^(_<=b[0]&&b[0]<=w)){var E=Ir(d,(-p+m)/g);return zr(E,h),[b,Dr(E)]}}}function o(e,n){var i=r?t:Tt-t,a=0;return e<-i?a|=1:e>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}}((x=+t)*Lt),T()):x},w.clipExtent=function(t){return arguments.length?(_=t,b=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):O,T()):_},w.scale=function(t){return arguments.length?(u=+t,A()):u},w.translate=function(t){return arguments.length?(c=+t[0],f=+t[1],A()):[c,f]},w.center=function(t){return arguments.length?(h=t[0]%360*Lt,d=t[1]%360*Lt,A()):[h*Ct,d*Ct]},w.rotate=function(t){return arguments.length?(p=t[0]%360*Lt,g=t[1]%360*Lt,v=t.length>2?t[2]%360*Lt:0,A()):[p*Ct,g*Ct,v*Ct]},t.rebind(w,l,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&M,A()}}function Cn(t){return En(t,function(e,r){t.point(e*Lt,r*Lt)})}function On(t,e){return[t,e]}function Rn(t,e){return[t>Tt?t-kt:t<-Tt?t+kt:t,e]}function Pn(t,e,r){return t?e||r?Gr(In(t),Nn(e,r)):In(t):e||r?Nn(e,r):Rn}function zn(t){return function(e,r){return[(e+=t)>Tt?e-kt:e<-Tt?e+kt:e,r]}}function In(t){var e=zn(t);return e.invert=zn(-t),e}function Nn(t,e){var r=Math.cos(t),n=Math.sin(t),i=Math.cos(e),a=Math.sin(e);function o(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*r+s*n;return[Math.atan2(l*i-c*a,s*r-u*n),zt(c*i+l*a)]}return o.invert=function(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*i-l*a;return[Math.atan2(l*i+u*a,s*r+c*n),zt(c*r-s*n)]},o}function Dn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=Fn(r,i),a=Fn(r,a),(o>0?ia)&&(i+=o*kt)):(i=t+o*kt,a=t-.5*l);for(var u,c=i;o>0?c>a:c2?t[2]*Lt:0),e.invert=function(e){return(e=t.invert(e[0]*Lt,e[1]*Lt))[0]*=Ct,e[1]*=Ct,e},e},Rn.invert=On,t.geo.circle=function(){var t,e,r=[0,0],n=6;function i(){var t="function"==typeof r?r.apply(this,arguments):r,n=Pn(-t[0]*Lt,-t[1]*Lt,0).invert,i=[];return e(null,null,1,{point:function(t,e){i.push(t=n(t,e)),t[0]*=Ct,t[1]*=Ct}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(r=t,i):r},i.angle=function(r){return arguments.length?(e=Dn((t=+r)*Lt,n*Lt),i):t},i.precision=function(r){return arguments.length?(e=Dn(t*Lt,(n=+r)*Lt),i):n},i.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Lt,i=t[1]*Lt,a=e[1]*Lt,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),u=Math.cos(i),c=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=u*c-l*f*s)*r),l*c+u*f*s)},t.geo.graticule=function(){var e,r,n,i,a,o,s,l,u,c,f,h,d=10,p=d,g=90,v=360,m=2.5;function b(){return{type:"MultiLineString",coordinates:x()}}function x(){return t.range(Math.ceil(i/g)*g,n,g).map(f).concat(t.range(Math.ceil(l/v)*v,s,v).map(h)).concat(t.range(Math.ceil(r/d)*d,e,d).filter(function(t){return y(t%g)>Mt}).map(u)).concat(t.range(Math.ceil(o/p)*p,a,p).filter(function(t){return y(t%v)>Mt}).map(c))}return b.lines=function(){return x().map(function(t){return{type:"LineString",coordinates:t}})},b.outline=function(){return{type:"Polygon",coordinates:[f(i).concat(h(s).slice(1),f(n).reverse().slice(1),h(l).reverse().slice(1))]}},b.extent=function(t){return arguments.length?b.majorExtent(t).minorExtent(t):b.minorExtent()},b.majorExtent=function(t){return arguments.length?(i=+t[0][0],n=+t[1][0],l=+t[0][1],s=+t[1][1],i>n&&(t=i,i=n,n=t),l>s&&(t=l,l=s,s=t),b.precision(m)):[[i,l],[n,s]]},b.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),o>a&&(t=o,o=a,a=t),b.precision(m)):[[r,o],[e,a]]},b.step=function(t){return arguments.length?b.majorStep(t).minorStep(t):b.minorStep()},b.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],b):[g,v]},b.minorStep=function(t){return arguments.length?(d=+t[0],p=+t[1],b):[d,p]},b.precision=function(t){return arguments.length?(m=+t,u=jn(o,a,90),c=Bn(r,e,m),f=jn(l,s,90),h=Bn(i,n,m),b):m},b.majorExtent([[-180,-90+Mt],[180,90-Mt]]).minorExtent([[-180,-80-Mt],[180,80+Mt]])},t.geo.greatArc=function(){var e,r,n=Un,i=Vn;function a(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}return a.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},a.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,a):n},a.target=function(t){return arguments.length?(i=t,r="function"==typeof t?null:t,a):i},a.precision=function(){return arguments.length?a:0},a},t.geo.interpolate=function(t,e){return r=t[0]*Lt,n=t[1]*Lt,i=e[0]*Lt,a=e[1]*Lt,o=Math.cos(n),s=Math.sin(n),l=Math.cos(a),u=Math.sin(a),c=o*Math.cos(r),f=o*Math.sin(r),h=l*Math.cos(i),d=l*Math.sin(i),p=2*Math.asin(Math.sqrt(Nt(a-n)+o*l*Nt(i-r))),g=1/Math.sin(p),(v=p?function(t){var e=Math.sin(t*=p)*g,r=Math.sin(p-t)*g,n=r*c+e*h,i=r*f+e*d,a=r*s+e*u;return[Math.atan2(i,n)*Ct,Math.atan2(a,Math.sqrt(n*n+i*i))*Ct]}:function(){return[r*Ct,n*Ct]}).distance=p,v;var r,n,i,a,o,s,l,u,c,f,h,d,p,g,v},t.geo.length=function(e){return yn=0,t.geo.stream(e,Hn),yn};var Hn={sphere:I,point:I,lineStart:function(){var t,e,r;function n(n,i){var a=Math.sin(i*=Lt),o=Math.cos(i),s=y((n*=Lt)-t),l=Math.cos(s);yn+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=r*a-e*o*l)*s),e*a+r*o*l),t=n,e=a,r=o}Hn.point=function(i,a){t=i*Lt,e=Math.sin(a*=Lt),r=Math.cos(a),Hn.point=n},Hn.lineEnd=function(){Hn.point=Hn.lineEnd=I}},lineEnd:I,polygonStart:I,polygonEnd:I};function qn(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}var Gn=qn(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sn(Gn)}).raw=Gn;var Wn=qn(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},O);function Xn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Tt/4+t/2)},i=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),a=r*Math.pow(n(t),i)/i;if(!i)return Qn;function o(t,e){a>0?e<-St+Mt&&(e=-St+Mt):e>St-Mt&&(e=St-Mt);var r=a/Math.pow(n(e),i);return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}return o.invert=function(t,e){var r=a-e,n=Ot(i)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/i,2*Math.atan(Math.pow(a/n,1/i))-St]},o}function Yn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),i=r/n+t;if(y(n)1&&Rt(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function ii(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sn(Kn)}).raw=Kn,ti.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=Jn(ti),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ti,t.geom={},t.geom.hull=function(t){var e=ei,r=ri;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,i=ve(e),a=ve(r),o=t.length,s=[],l=[];for(n=0;n=0;--n)d.push(t[s[u[n]][2]]);for(n=+f;nMt)s=s.L;else{if(!((i=a-wi(s,o))>Mt)){n>-Mt?(e=s.P,r=s):i>-Mt?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=mi(t);if(fi.insert(e,l),e||r){if(e===r)return Ei(e),r=mi(e.site),fi.insert(l,r),l.edge=r.edge=Ci(e.site,l.site),ki(e),void ki(r);if(r){Ei(e),Ei(r);var u=e.site,c=u.x,f=u.y,h=t.x-c,d=t.y-f,p=r.site,g=p.x-c,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+c,y:(h*b-g*y)/m+f};Oi(r.edge,u,p,x),l.edge=Ci(u,t,null,x),r.edge=Ci(t,p,null,x),ki(e),ki(r)}else l.edge=Ci(e.site,l.site)}}function _i(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-1/0;var s=(r=o.site).x,l=r.y,u=l-e;if(!u)return s;var c=s-n,f=1/a-1/u,h=c/u;return f?(-h+Math.sqrt(h*h-2*f*(c*c/(-2*u)-l+u/2+i-a/2)))/f+n:(n+s)/2}function wi(t,e){var r=t.N;if(r)return _i(r,e);var n=t.site;return n.y===e?n.x:1/0}function Mi(t){this.site=t,this.edges=[]}function Ai(t,e){return e.angle-t.angle}function Ti(){zi(this),this.x=this.y=this.arc=this.site=this.cy=null}function ki(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,i=t.site,a=r.site;if(n!==a){var o=i.x,s=i.y,l=n.x-o,u=n.y-s,c=a.x-o,f=2*(l*(v=a.y-s)-u*c);if(!(f>=-At)){var h=l*l+u*u,d=c*c+v*v,p=(v*h-u*d)/f,g=(l*d-c*h)/f,v=g+s,m=gi.pop()||new Ti;m.arc=t,m.site=i,m.x=p+o,m.y=v+Math.sqrt(p*p+g*g),m.cy=v,t.circle=m;for(var y=null,b=di._;b;)if(m.y=s)return;if(h>p){if(a){if(a.y>=u)return}else a={x:v,y:l};r={x:v,y:u}}else{if(a){if(a.y1)if(h>p){if(a){if(a.y>=u)return}else a={x:(l-i)/n,y:l};r={x:(u-i)/n,y:u}}else{if(a){if(a.y=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xMt||y(i-r)>Mt)&&(s.splice(o,0,new Ri((m=a.site,b=c,x=y(n-f)Mt?{x:f,y:y(e-f)Mt?{x:y(r-p)Mt?{x:h,y:y(e-h)Mt?{x:y(r-d)=r&&u.x<=i&&u.y>=n&&u.y<=o?[[r,o],[i,o],[i,n],[r,n]]:[]).point=t[s]}),e}function s(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/Mt)*Mt,y:Math.round(i(t,e)/Mt)*Mt,i:e}})}return o.links=function(t){return Fi(s(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fi(s(t)).cells.forEach(function(r,n){for(var i,a,o,s,l=r.site,u=r.edges.sort(Ai),c=-1,f=u.length,h=u[f-1].edge,d=h.l===l?h.r:h.l;++ca&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:Gi(r,n)})),a=Yi.lastIndex;return ag&&(g=l.x),l.y>v&&(v=l.y),u.push(l.x),c.push(l.y);else for(f=0;fg&&(g=x),_>v&&(v=_),u.push(x),c.push(_)}var w=g-d,M=v-p;function A(t,e,r,n,i,a,o,s){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var l=t.x,u=t.y;if(null!=l)if(y(l-r)+y(u-n)<.01)T(t,e,r,n,i,a,o,s);else{var c=t.point;t.x=t.y=t.point=null,T(t,c,l,u,i,a,o,s),T(t,e,r,n,i,a,o,s)}else t.x=r,t.y=n,t.point=e}else T(t,e,r,n,i,a,o,s)}function T(t,e,r,n,i,a,o,s){var l=.5*(i+o),u=.5*(a+s),c=r>=l,f=n>=u,h=f<<1|c;t.leaf=!1,c?i=l:o=l,f?a=u:s=u,A(t=t.nodes[h]||(t.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){A(k,t,+m(t,++f),+b(t,f),d,p,g,v)}}),e,r,n,i,a,o,s)}w>M?v=p+w:g=d+M;var k={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){A(k,t,+m(t,++f),+b(t,f),d,p,g,v)}};if(k.visit=function(t){!function t(e,r,n,i,a,o){if(!e(r,n,i,a,o)){var s=.5*(n+a),l=.5*(i+o),u=r.nodes;u[0]&&t(e,u[0],n,i,s,l),u[1]&&t(e,u[1],s,i,a,l),u[2]&&t(e,u[2],n,l,s,o),u[3]&&t(e,u[3],s,l,a,o)}}(t,k,d,p,g,v)},k.find=function(t){return function(t,e,r,n,i,a,o){var s,l=1/0;return function t(u,c,f,h,d){if(!(c>a||f>o||h=_)<<1|e>=x,M=w+4;w=0&&!(n=t.interpolators[i](e,r)););return n}function Qi(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function aa(t){return 1-Math.cos(t*St)}function oa(t){return Math.pow(2,10*(t-1))}function sa(t){return 1-Math.sqrt(1-t*t)}function la(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ua(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ca(t){var e,r,n,i=[t.a,t.b],a=[t.c,t.d],o=ha(i),s=fa(i,a),l=ha(((e=a)[0]+=(n=-s)*(r=i)[0],e[1]+=n*r[1],e))||0;i[0]*a[1]=0?t.slice(0,n):t,a=n>=0?t.slice(n+1):"in";return i=$i.get(i)||Ji,a=Ki.get(a)||O,e=a(i.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,i=e.c,a=e.l,o=r.h-n,s=r.c-i,l=r.l-a;isNaN(s)&&(s=0,i=isNaN(i)?r.c:i);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Xt(n+o*t,i+s*t,a+l*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,i=e.s,a=e.l,o=r.h-n,s=r.s-i,l=r.l-a;isNaN(s)&&(s=0,i=isNaN(i)?r.s:i);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return qt(n+o*t,i+s*t,a+l*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,i=e.a,a=e.b,o=r.l-n,s=r.a-i,l=r.b-a;return function(t){return te(n+o*t,i+s*t,a+l*t)+""}},t.interpolateRound=ua,t.transform=function(e){var r=i.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ca(e?e.matrix:da)})(e)},ca.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var da={a:1,b:0,c:0,d:1,e:0,f:0};function pa(t){return t.length?t.pop()+",":""}function ga(e,r){var n=[],i=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push("translate(",null,",",null,")");n.push({i:i-4,x:Gi(t[0],e[0])},{i:i-2,x:Gi(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,i),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(pa(r)+"rotate(",null,")")-2,x:Gi(t,e)})):e&&r.push(pa(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,i),function(t,e,r,n){t!==e?n.push({i:r.push(pa(r)+"skewX(",null,")")-2,x:Gi(t,e)}):e&&r.push(pa(r)+"skewX("+e+")")}(e.skew,r.skew,n,i),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(pa(r)+"scale(",null,",",null,")");n.push({i:i-4,x:Gi(t[0],e[0])},{i:i-2,x:Gi(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(pa(r)+"scale("+e+")")}(e.scale,r.scale,n,i),e=r=null,function(t){for(var e,r=-1,a=i.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:n=0})):t>0&&(l.start({type:"start",alpha:n=t}),e=Ae(s.tick)),s):n},s.start=function(){var t,e,r,n=m.length,l=y.length,c=u[0],p=u[1];for(t=0;t=0;)r.push(i[n])}function La(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++o=0;)o.push(c=u[l]),c.parent=a,c.depth=a.depth+1;r&&(a.value=0),a.children=u}else r&&(a.value=+r.call(n,a,a.depth)||0),delete a.children;return La(i,function(e){var n,i;t&&(n=e.children)&&n.sort(t),r&&(i=e.parent)&&(i.value+=e.value)}),s}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Sa(t,function(t){t.children&&(t.value=0)}),La(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var i=e.call(this,t,n);return function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,u=-1;for(n=e.value?n/e.value:0;++us&&(s=n),o.push(n)}for(r=0;ri&&(n=r,i=e);return n}function Ha(t){return t.reduce(qa,0)}function qa(t,e){return t+e[1]}function Ga(t,e){return Wa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Wa(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function Xa(e){return[t.min(e),t.max(e)]}function Ya(t,e){return t.value-e.value}function Za(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Qa(t,e){t._pack_next=e,e._pack_prev=t}function Ja(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function $a(t){if((e=t.children)&&(l=e.length)){var e,r,n,i,a,o,s,l,u=1/0,c=-1/0,f=1/0,h=-1/0;if(e.forEach(Ka),(r=e[0]).x=-r.r,r.y=0,b(r),l>1&&((n=e[1]).x=n.r,n.y=0,b(n),l>2))for(eo(r,n,i=e[2]),b(i),Za(r,i),r._pack_prev=i,Za(i,n),n=r._pack_next,a=3;a0)for(o=-1;++o=f[0]&&l<=f[1]&&((s=u[t.bisect(h,l,1,p)-1]).y+=g,s.push(a[o]));return u}return a.value=function(t){return arguments.length?(r=t,a):r},a.range=function(t){return arguments.length?(n=ve(t),a):n},a.bins=function(t){return arguments.length?(i="number"==typeof t?function(e){return Wa(e,t)}:ve(t),a):i},a.frequency=function(t){return arguments.length?(e=!!t,a):e},a},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Ya),n=0,i=[1,1];function a(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],u=i[1],c=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,La(s,function(t){t.r=+c(t.value)}),La(s,$a),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/u))/2;La(s,function(t){t.r+=f}),La(s,$a),La(s,function(t){t.r-=f})}return function t(e,r,n,i){var a=e.children;e.x=r+=i*e.x;e.y=n+=i*e.y;e.r*=i;if(a)for(var o=-1,s=a.length;++od.x&&(d=t),t.depth>p.depth&&(p=t)});var g=r(h,d)/2-h.x,v=n[0]/(d.x+r(d,h)/2+g),m=n[1]/(p.depth||1);Sa(c,function(t){t.x=(t.x+g)*v,t.y=t.depth*m})}return u}function o(t){var e=t.children,n=t.parent.children,i=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,i=t.children,a=i.length;for(;--a>=0;)(e=i[a]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var a=(e[0].z+e[e.length-1].z)/2;i?(t.z=i.z+r(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+r(t._,i._));t.parent.A=function(t,e,n){if(e){for(var i,a=t,o=t,s=e,l=a.parent.children[0],u=a.m,c=o.m,f=s.m,h=l.m;s=io(s),a=no(a),s&&a;)l=no(l),(o=io(o)).a=t,(i=s.z+f-a.z-u+r(s._,a._))>0&&(ao(oo(s,t,n),t,i),u+=i,c+=i),f+=s.m,u+=a.m,h+=l.m,c+=o.m;s&&!io(o)&&(o.t=s,o.m+=f-c),a&&!no(l)&&(l.t=a,l.m+=u-h,n=t)}return n}(t,i,t.parent.A||n[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function l(t){t.x*=n[0],t.y=t.depth*n[1]}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t)?l:null,a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null==(n=t)?null:l,a):i?n:null},Ea(a,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],i=!1;function a(a,o){var s,l=e.call(this,a,o),u=l[0],c=0;La(u,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=s?c+=r(e,s):0,e.y=0,s=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(u),h=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(u),d=f.x-r(f,h)/2,p=h.x+r(h,f)/2;return La(u,i?function(t){t.x=(t.x-u.x)*n[0],t.y=(u.y-t.y)*n[1]}:function(t){t.x=(t.x-d)/(p-d)*n[0],t.y=(1-(u.y?t.y/u.y:1))*n[1]}),l}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t),a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null!=(n=t),a):i?n:null},Ea(a,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,i=[1,1],a=null,o=so,s=!1,l="squarify",u=.5*(1+Math.sqrt(5));function c(t,e){for(var r,n,i=-1,a=t.length;++i0;)s.push(r=u[i-1]),s.area+=r.area,"squarify"!==l||(n=d(s,g))<=h?(u.pop(),h=n):(s.area-=s.pop().area,p(s,g,a,!1),g=Math.min(a.dx,a.dy),s.length=s.area=0,h=1/0);s.length&&(p(s,g,a,!0),s.length=s.area=0),e.forEach(f)}}function h(t){var e=t.children;if(e&&e.length){var r,n=o(t),i=e.slice(),a=[];for(c(i,n.dx*n.dy/t.value),a.area=0;r=i.pop();)a.push(r),a.area+=r.area,null!=r.z&&(p(a,r.z?n.dx:n.dy,n,!i.length),a.length=a.area=0);e.forEach(h)}}function d(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++oi&&(i=r));return e*=e,(n*=n)?Math.max(e*i*u/n,n/(e*a*u)):1/0}function p(t,e,r,i){var a,o=-1,s=t.length,l=r.x,u=r.y,c=e?n(t.area/e):0;if(e==r.dx){for((i||c>r.dy)&&(c=r.dy);++or.dx)&&(c=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,s=i?ma:va;return a=t(e,r,s,n),o=t(r,e,s,Zi),l}function l(t){return a(t)}l.invert=function(t){return o(t)};l.domain=function(t){return arguments.length?(e=t.map(Number),s()):e};l.range=function(t){return arguments.length?(r=t,s()):r};l.rangeRound=function(t){return l.range(t).interpolate(ua)};l.clamp=function(t){return arguments.length?(i=t,s()):i};l.interpolate=function(t){return arguments.length?(n=t,s()):n};l.ticks=function(t){return xo(e,t)};l.tickFormat=function(t,r){return _o(e,t,r)};l.nice=function(t){return yo(e,t),s()};l.copy=function(){return t(e,r,n,i)};return s()}([0,1],[0,1],Zi,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function Mo(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,i,a){function o(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function s(t){return i?Math.pow(n,t):-Math.pow(n,-t)}function l(t){return r(o(t))}l.invert=function(t){return s(r.invert(t))};l.domain=function(t){return arguments.length?(i=t[0]>=0,r.domain((a=t.map(Number)).map(o)),l):a};l.base=function(t){return arguments.length?(n=+t,r.domain(a.map(o)),l):n};l.nice=function(){var t=ho(a.map(o),i?Math:To);return r.domain(t),a=t.map(s),l};l.ticks=function(){var t=uo(a),e=[],r=t[0],l=t[1],u=Math.floor(o(r)),c=Math.ceil(o(l)),f=n%1?2:n;if(isFinite(c-u)){if(i){for(;u0;h--)e.push(s(u)*h);for(u=0;e[u]l;c--);e=e.slice(u,c)}return e};l.tickFormat=function(e,r){if(!arguments.length)return Ao;arguments.length<2?r=Ao:"function"!=typeof r&&(r=t.format(r));var i=Math.max(1,n*e/l.ticks().length);return function(t){var e=t/s(Math.round(o(t)));return e*n0?i[t-1]:r[0],tf?0:1;if(u=Et)return l(u,d)+(s?l(s,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,M,A,T,k=0,E=0,S=[];if((m=(+o.apply(this,arguments)||0)/2)&&(v=n===Ro?Math.sqrt(s*s+u*u):+n.apply(this,arguments),d||(E*=-1),u&&(E=zt(v/u*Math.sin(m))),s&&(k=zt(v/s*Math.sin(m)))),u){y=u*Math.cos(c+E),b=u*Math.sin(c+E),x=u*Math.cos(f-E),_=u*Math.sin(f-E);var L=Math.abs(f-c-2*E)<=Tt?0:1;if(E&&Fo(y,b,x,_)===d^L){var C=(c+f)/2;y=u*Math.cos(C),b=u*Math.sin(C),x=_=null}}else y=b=0;if(s){w=s*Math.cos(f-k),M=s*Math.sin(f-k),A=s*Math.cos(c+k),T=s*Math.sin(c+k);var O=Math.abs(c-f+2*k)<=Tt?0:1;if(k&&Fo(w,M,A,T)===1-d^O){var R=(c+f)/2;w=s*Math.cos(R),M=s*Math.sin(R),A=T=null}}else w=M=0;if(h>Mt&&(p=Math.min(Math.abs(u-s)/2,+r.apply(this,arguments)))>.001){g=s0?0:1}function jo(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,u=-s*a,c=t[0]+l,f=t[1]+u,h=e[0]+l,d=e[1]+u,p=(c+h)/2,g=(f+d)/2,v=h-c,m=d-f,y=v*v+m*m,b=r-n,x=c*d-h*f,_=(m<0?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,M=(-x*v-m*_)/y,A=(x*m+v*_)/y,T=(-x*v+m*_)/y,k=w-p,E=M-g,S=A-p,L=T-g;return k*k+E*E>S*S+L*L&&(w=A,M=T),[[w-l,M-u],[w*r/b,M*r/b]]}function Bo(t){var e=ei,r=ri,n=Wr,i=Vo,a=i.key,o=.7;function s(a){var s,l=[],u=[],c=-1,f=a.length,h=ve(e),d=ve(r);function p(){l.push("M",i(t(u),o))}for(;++c1&&i.push("H",n[0]);return i.join("")},"step-before":qo,"step-after":Go,basis:Yo,"basis-open":function(t){if(t.length<4)return Vo(t);var e,r=[],n=-1,i=t.length,a=[0],o=[0];for(;++n<3;)e=t[n],a.push(e[0]),o.push(e[1]);r.push(Zo($o,a)+","+Zo($o,o)),--n;for(;++n9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));s=-1;for(;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}(t))}});function Vo(t){return t.length>1?t.join("L"):t+"Z"}function Ho(t){return t.join("L")+"Z"}function qo(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var u=2;uTt)+",1 "+e}function l(t,e,r,n){return"Q 0,0 "+n}return a.radius=function(t){return arguments.length?(r=ve(t),a):r},a.source=function(e){return arguments.length?(t=ve(e),a):t},a.target=function(t){return arguments.length?(e=ve(t),a):e},a.startAngle=function(t){return arguments.length?(n=ve(t),a):n},a.endAngle=function(t){return arguments.length?(i=ve(t),a):i},a},t.svg.diagonal=function(){var t=Un,e=Vn,r=is;function n(n,i){var a=t.call(this,n,i),o=e.call(this,n,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(r))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=is,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-St;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=os,e=as;function r(r,n){return(ls.get(t.call(this,r,n))||ss)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var ls=t.map({circle:ss,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*cs)),r=e*cs;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/us),r=e*us/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/us),r=e*us/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=ls.keys();var us=Math.sqrt(3),cs=Math.tan(30*Lt);X.transition=function(t){for(var e,r,n=ps||++ms,i=xs(t),a=[],o=gs||{time:Date.now(),ease:ia,delay:0,duration:250},s=-1,l=this.length;++s0;)u[--h].call(t,o);if(a>=1)return f.event&&f.event.end.call(t,t.__data__,e),--c.count?delete c[n]:delete t[r],1}f||(a=i.time,o=Ae(function(t){var e=f.delay;if(o.t=e+a,e<=t)return h(t-e);o.c=h},0,a),f=c[n]={tween:new x,time:a,timer:o,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++c.count)}vs.call=X.call,vs.empty=X.empty,vs.node=X.node,vs.size=X.size,t.transition=function(e,r){return e&&e.transition?ps?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vs,vs.select=function(t){var e,r,n,i=this.id,a=this.namespace,o=[];t=Y(t);for(var s=-1,l=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function g(t){t.select(".extent").attr("y",l[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function v(){var f,v,m=this,y=t.select(t.event.target),b=n.of(m,arguments),x=t.select(m),_=y.datum(),w=!/^(n|s)$/.test(_)&&i,M=!/^(e|w)$/.test(_)&&a,A=y.classed("extent"),T=bt(m),k=t.mouse(m),E=t.select(o(m)).on("keydown.brush",function(){32==t.event.keyCode&&(A||(f=null,k[0]-=s[1],k[1]-=l[1],A=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==A&&(k[0]+=s[1],k[1]+=l[1],A=0,F())});if(t.event.changedTouches?E.on("touchmove.brush",C).on("touchend.brush",R):E.on("mousemove.brush",C).on("mouseup.brush",R),x.interrupt().selectAll("*").interrupt(),A)k[0]=s[0]-k[0],k[1]=l[0]-k[1];else if(_){var S=+/w$/.test(_),L=+/^n/.test(_);v=[s[1-S]-k[0],l[1-L]-k[1]],k[0]=s[S],k[1]=l[L]}else t.event.altKey&&(f=k.slice());function C(){var e=t.mouse(m),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),A||(t.event.altKey?(f||(f=[(s[0]+s[1])/2,(l[0]+l[1])/2]),k[0]=s[+(e[0]1?{floor:function(e){for(;s(e=t.floor(e));)e=Ps(e-1);return e},ceil:function(e){for(;s(e=t.ceil(e));)e=Ps(+e+1);return e}}:t))},i.ticks=function(t,e){var r=uo(i.domain()),n=null==t?a(r,10):"number"==typeof t?a(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],Ps(+r[1]+1),e<1?1:e)},i.tickFormat=function(){return n},i.copy=function(){return Rs(e.copy(),r,n)},mo(i,e)}function Ps(t){return new Date(t)}Ss.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Os:Cs,Os.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Os.toString=Cs.toString,Pe.second=De(function(t){return new ze(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),Pe.seconds=Pe.second.range,Pe.seconds.utc=Pe.second.utc.range,Pe.minute=De(function(t){return new ze(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),Pe.minutes=Pe.minute.range,Pe.minutes.utc=Pe.minute.utc.range,Pe.hour=De(function(t){var e=t.getTimezoneOffset()/60;return new ze(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),Pe.hours=Pe.hour.range,Pe.hours.utc=Pe.hour.utc.range,Pe.month=De(function(t){return(t=Pe.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),Pe.months=Pe.month.range,Pe.months.utc=Pe.month.utc.range;var zs=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Is=[[Pe.second,1],[Pe.second,5],[Pe.second,15],[Pe.second,30],[Pe.minute,1],[Pe.minute,5],[Pe.minute,15],[Pe.minute,30],[Pe.hour,1],[Pe.hour,3],[Pe.hour,6],[Pe.hour,12],[Pe.day,1],[Pe.day,2],[Pe.week,1],[Pe.month,1],[Pe.month,3],[Pe.year,1]],Ns=Ss.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Wr]]),Ds={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(Ps)},floor:O,ceil:O};Is.year=Pe.year,Pe.scale=function(){return Rs(t.scale.linear(),Is,Ns)};var Fs=Is.map(function(t){return[t[0].utc,t[1]]}),js=Ls.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Wr]]);function Bs(t){return JSON.parse(t.responseText)}function Us(t){var e=i.createRange();return e.selectNode(i.body),e.createContextualFragment(t.responseText)}Fs.year=Pe.year.utc,Pe.scale.utc=function(){return Rs(t.scale.linear(),Fs,js)},t.text=me(function(t){return t.responseText}),t.json=function(t,e){return ye(t,"application/json",Bs,e)},t.html=function(t,e){return ye(t,"text/html",Us,e)},t.xml=me(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],83:[function(t,e,r){e.exports=function(){for(var t=0;t=2)return!1;t[r]=n}return!0}):_.filter(function(t){for(var e=0;e<=s;++e){var r=m[t[e]];if(r<0)return!1;t[e]=r}return!0});if(1&s)for(var c=0;c<_.length;++c){var x=_[c],h=x[0];x[0]=x[1],x[1]=h}return _}},{"incremental-convex-hull":253,uniq:350}],85:[function(t,e,r){(function(t){var r=!1;if("undefined"!=typeof Float64Array){var n=new Float64Array(1),i=new Uint32Array(n.buffer);if(n[0]=1,r=!0,1072693248===i[1]){e.exports=function(t){return n[0]=t,[i[0],i[1]]},e.exports.pack=function(t,e){return i[0]=t,i[1]=e,n[0]},e.exports.lo=function(t){return n[0]=t,i[0]},e.exports.hi=function(t){return n[0]=t,i[1]}}else if(1072693248===i[0]){e.exports=function(t){return n[0]=t,[i[1],i[0]]},e.exports.pack=function(t,e){return i[1]=t,i[0]=e,n[0]},e.exports.lo=function(t){return n[0]=t,i[1]},e.exports.hi=function(t){return n[0]=t,i[0]}}else r=!1}if(!r){var a=new t(8);e.exports=function(t){return a.writeDoubleLE(t,0,!0),[a.readUInt32LE(0,!0),a.readUInt32LE(4,!0)]},e.exports.pack=function(t,e){return a.writeUInt32LE(t,0,!0),a.writeUInt32LE(e,4,!0),a.readDoubleLE(0,!0)},e.exports.lo=function(t){return a.writeDoubleLE(t,0,!0),a.readUInt32LE(0,!0)},e.exports.hi=function(t){return a.writeDoubleLE(t,0,!0),a.readUInt32LE(4,!0)}}e.exports.sign=function(t){return e.exports.hi(t)>>>31},e.exports.exponent=function(t){return(e.exports.hi(t)<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){return!(2146435072&e.exports.hi(t))}}).call(this,t("buffer").Buffer)},{buffer:49}],86:[function(t,e,r){e.exports=function(t){switch(t){case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"uint8":return Uint8Array;case"uint16":return Uint16Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;case"array":return Array;case"uint8_clamped":return Uint8ClampedArray}}},{}],87:[function(t,e,r){"use strict";e.exports=function(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return function(t,e){var r,n;for(r=new Array(t),n=0;n=r-1){h=l.length-1;var p=t-e[r-1];for(d=0;d=r-1)for(var c=s.length-1,f=(e[r-1],0);f=0;--r)if(t[--e])return!1;return!0},s.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(t0;--f)n.push(a(l[f-1],u[f-1],arguments[f])),i.push(0)}},s.push=function(t){var e=this.lastT(),r=this.dimension;if(!(t1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var d=a(u[h-1],c[h-1],arguments[h]);n.push(d),i.push((d-n[o++])*f)}}},s.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(a(o[l-1],s[l-1],arguments[l])),n.push(0)}},s.move=function(t){var e=this.lastT(),r=this.dimension;if(!(t<=e||arguments.length!==r+1)){var n=this._state,i=this._velocity,o=n.length-this.dimension,s=this.bounds,l=s[0],u=s[1],c=t-e,f=c>1e-6?1/c:0;this._time.push(t);for(var h=r;h>0;--h){var d=arguments[h];n.push(a(l[h-1],u[h-1],n[o++]+d)),i.push(d*f)}}},s.idle=function(t){var e=this.lastT();if(!(t=0;--f)n.push(a(l[f],u[f],n[o]+c*i[o])),i.push(0),o+=1}}},{"binary-search-bounds":36,"cubic-hermite":77}],93:[function(t,e,r){"use strict";e.exports=function(t){return new u(t||p,null)};var n=0,i=1;function a(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function o(t){return new a(t._color,t.key,t.value,t.left,t.right,t._count)}function s(t,e){return new a(t,e.key,e.value,e.left,e.right,e._count)}function l(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function u(t,e){this._compare=t,this.root=e}var c=u.prototype;function f(t,e){this.tree=t,this._stack=e}Object.defineProperty(c,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(c,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(c,"length",{get:function(){return this.root?this.root._count:0}}),c.insert=function(t,e){for(var r=this._compare,o=this.root,c=[],f=[];o;){var h=r(t,o.key);c.push(o),f.push(h),o=h<=0?o.left:o.right}c.push(new a(n,t,e,null,null,1));for(var d=c.length-2;d>=0;--d){o=c[d];f[d]<=0?c[d]=new a(o._color,o.key,o.value,c[d+1],o.right,o._count+1):c[d]=new a(o._color,o.key,o.value,o.left,c[d+1],o._count+1)}for(d=c.length-1;d>1;--d){var p=c[d-1];o=c[d];if(p._color===i||o._color===i)break;var g=c[d-2];if(g.left===p)if(p.left===o){if(!(v=g.right)||v._color!==n){if(g._color=n,g.left=p.right,p._color=i,p.right=g,c[d-2]=p,c[d-1]=o,l(g),l(p),d>=3)(m=c[d-3]).left===g?m.left=p:m.right=p;break}p._color=i,g.right=s(i,v),g._color=n,d-=1}else{if(!(v=g.right)||v._color!==n){if(p.right=o.left,g._color=n,g.left=o.right,o._color=i,o.left=p,o.right=g,c[d-2]=o,c[d-1]=p,l(g),l(p),l(o),d>=3)(m=c[d-3]).left===g?m.left=o:m.right=o;break}p._color=i,g.right=s(i,v),g._color=n,d-=1}else if(p.right===o){if(!(v=g.left)||v._color!==n){if(g._color=n,g.right=p.left,p._color=i,p.left=g,c[d-2]=p,c[d-1]=o,l(g),l(p),d>=3)(m=c[d-3]).right===g?m.right=p:m.left=p;break}p._color=i,g.left=s(i,v),g._color=n,d-=1}else{var v;if(!(v=g.left)||v._color!==n){var m;if(p.left=o.right,g._color=n,g.right=o.left,o._color=i,o.right=p,o.left=g,c[d-2]=o,c[d-1]=p,l(g),l(p),l(o),d>=3)(m=c[d-3]).right===g?m.right=o:m.left=o;break}p._color=i,g.left=s(i,v),g._color=n,d-=1}}return c[0]._color=i,new u(r,c[0])},c.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return function t(e,r){var n;if(r.left&&(n=t(e,r.left)))return n;return(n=e(r.key,r.value))||(r.right?t(e,r.right):void 0)}(t,this.root);case 2:return function t(e,r,n,i){if(r(e,i.key)<=0){var a;if(i.left&&(a=t(e,r,n,i.left)))return a;if(a=n(i.key,i.value))return a}if(i.right)return t(e,r,n,i.right)}(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return function t(e,r,n,i,a){var o,s=n(e,a.key),l=n(r,a.key);if(s<=0){if(a.left&&(o=t(e,r,n,i,a.left)))return o;if(l>0&&(o=i(a.key,a.value)))return o}if(l>0&&a.right)return t(e,r,n,i,a.right)}(e,r,this._compare,t,this.root)}},Object.defineProperty(c,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(c,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),c.at=function(t){if(t<0)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},c.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<=0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},c.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},c.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},c.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},c.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=i<=0?r.left:r.right}return new f(this,[])},c.remove=function(t){var e=this.find(t);return e?e.remove():this},c.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=n<=0?r.left:r.right}};var h=f.prototype;function d(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function p(t,e){return te?1:0}Object.defineProperty(h,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(h,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),h.clone=function(){return new f(this.tree,this._stack.slice())},h.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new a(r._color,r.key,r.value,r.left,r.right,r._count);for(var c=t.length-2;c>=0;--c){(r=t[c]).left===t[c+1]?e[c]=new a(r._color,r.key,r.value,e[c+1],r.right,r._count):e[c]=new a(r._color,r.key,r.value,r.left,e[c+1],r._count)}if((r=e[e.length-1]).left&&r.right){var f=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var h=e[f-1];e.push(new a(r._color,h.key,h.value,r.left,r.right,r._count)),e[f-1].key=r.key,e[f-1].value=r.value;for(c=e.length-2;c>=f;--c)r=e[c],e[c]=new a(r._color,r.key,r.value,r.left,e[c+1],r._count);e[f-1].left=e[f]}if((r=e[e.length-1])._color===n){var p=e[e.length-2];p.left===r?p.left=null:p.right===r&&(p.right=null),e.pop();for(c=0;c=0;--c){if(e=t[c],0===c)return void(e._color=i);if((r=t[c-1]).left===e){if((a=r.right).right&&a.right._color===n)return u=(a=r.right=o(a)).right=o(a.right),r.right=a.left,a.left=r,a.right=u,a._color=r._color,e._color=i,r._color=i,u._color=i,l(r),l(a),c>1&&((f=t[c-2]).left===r?f.left=a:f.right=a),void(t[c-1]=a);if(a.left&&a.left._color===n)return u=(a=r.right=o(a)).left=o(a.left),r.right=u.left,a.left=u.right,u.left=r,u.right=a,u._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(u),c>1&&((f=t[c-2]).left===r?f.left=u:f.right=u),void(t[c-1]=u);if(a._color===i){if(r._color===n)return r._color=i,void(r.right=s(n,a));r.right=s(n,a);continue}a=o(a),r.right=a.left,a.left=r,a._color=r._color,r._color=n,l(r),l(a),c>1&&((f=t[c-2]).left===r?f.left=a:f.right=a),t[c-1]=a,t[c]=r,c+11&&((f=t[c-2]).right===r?f.right=a:f.left=a),void(t[c-1]=a);if(a.right&&a.right._color===n)return u=(a=r.left=o(a)).right=o(a.right),r.left=u.right,a.right=u.left,u.right=r,u.left=a,u._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(u),c>1&&((f=t[c-2]).right===r?f.right=u:f.left=u),void(t[c-1]=u);if(a._color===i){if(r._color===n)return r._color=i,void(r.left=s(n,a));r.left=s(n,a);continue}var f;a=o(a),r.left=a.right,a.right=r,a._color=r._color,r._color=n,l(r),l(a),c>1&&((f=t[c-2]).right===r?f.right=a:f.left=a),t[c-1]=a,t[c]=r,c+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(h,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(h,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),h.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),h.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),n=e[e.length-1];r[r.length-1]=new a(n._color,n.key,t,n.left,n.right,n._count);for(var i=e.length-2;i>=0;--i)(n=e[i]).left===e[i+1]?r[i]=new a(n._color,n.key,n.value,r[i+1],n.right,n._count):r[i]=new a(n._color,n.key,n.value,n.left,r[i+1],n._count);return new u(this.tree._compare,r[0])},h.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],94:[function(t,e,r){var n=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],i=607/128,a=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function o(t){if(t<0)return Number("0/0");for(var e=a[0],r=a.length-1;r>0;--r)e+=a[r]/(t+r);var n=t+i+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}e.exports=function t(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*t(1-e));if(e>100)return Math.exp(o(e));e-=1;for(var r=n[0],i=1;i<9;i++)r+=n[i]/(e+i);var a=e+7+.5;return Math.sqrt(2*Math.PI)*Math.pow(a,e+.5)*Math.exp(-a)*r},e.exports.log=o},{}],95:[function(t,e,r){e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("must specify type string");if(e=e||{},"undefined"==typeof document&&!e.canvas)return null;var r=e.canvas||document.createElement("canvas");"number"==typeof e.width&&(r.width=e.width);"number"==typeof e.height&&(r.height=e.height);var n,i=e;try{var a=[t];0===t.indexOf("webgl")&&a.push("experimental-"+t);for(var o=0;o0?(d[c]=-1,p[c]=0):(d[c]=0,p[c]=1)}}var g=[0,0,0],v={model:l,view:l,projection:l};f.isOpaque=function(){return!0},f.isTransparent=function(){return!1},f.drawTransparent=function(t){};var m=[0,0,0],y=[0,0,0],b=[0,0,0];f.draw=function(t){t=t||v;for(var e=this.gl,r=t.model||l,n=t.view||l,i=t.projection||l,a=this.bounds,s=o(r,n,i,a),c=s.cubeEdges,f=s.axis,h=n[12],x=n[13],_=n[14],w=n[15],M=this.pixelRatio*(i[3]*h+i[7]*x+i[11]*_+i[15]*w)/e.drawingBufferHeight,A=0;A<3;++A)this.lastCubeProps.cubeEdges[A]=c[A],this.lastCubeProps.axis[A]=f[A];var T=d;for(A=0;A<3;++A)p(d[A],A,this.bounds,c,f);e=this.gl;var k,E=g;for(A=0;A<3;++A)this.backgroundEnable[A]?E[A]=f[A]:E[A]=0;this._background.draw(r,n,i,a,E,this.backgroundColor),this._lines.bind(r,n,i,this);for(A=0;A<3;++A){var S=[0,0,0];f[A]>0?S[A]=a[1][A]:S[A]=a[0][A];for(var L=0;L<2;++L){var C=(A+1+L)%3,O=(A+1+(1^L))%3;this.gridEnable[C]&&this._lines.drawGrid(C,O,this.bounds,S,this.gridColor[C],this.gridWidth[C]*this.pixelRatio)}for(L=0;L<2;++L){C=(A+1+L)%3,O=(A+1+(1^L))%3;this.zeroEnable[O]&&Math.min(a[0][O],a[1][O])<=0&&Math.max(a[0][O],a[1][O])>=0&&this._lines.drawZero(C,O,this.bounds,S,this.zeroLineColor[O],this.zeroLineWidth[O]*this.pixelRatio)}}for(A=0;A<3;++A){this.lineEnable[A]&&this._lines.drawAxisLine(A,this.bounds,T[A].primalOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio),this.lineMirror[A]&&this._lines.drawAxisLine(A,this.bounds,T[A].mirrorOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio);var R=u(m,T[A].primalMinor),P=u(y,T[A].mirrorMinor),z=this.lineTickLength;for(L=0;L<3;++L){var I=M/r[5*L];R[L]*=z[L]*I,P[L]*=z[L]*I}this.lineTickEnable[A]&&this._lines.drawAxisTicks(A,T[A].primalOffset,R,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio),this.lineTickMirror[A]&&this._lines.drawAxisTicks(A,T[A].mirrorOffset,P,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio)}this._lines.unbind(),this._text.bind(r,n,i,this.pixelRatio);var N,D;function F(t){(D=[0,0,0])[t]=1}function j(t,e,r){var n=(t+1)%3,i=(t+2)%3,a=e[n],o=e[i],s=r[n],l=r[i];a>0&&l>0?F(n):a>0&&l<0?F(n):a<0&&l>0?F(n):a<0&&l<0?F(n):o>0&&s>0?F(i):o>0&&s<0?F(i):o<0&&s>0?F(i):o<0&&s<0&&F(i)}for(A=0;A<3;++A){var B=T[A].primalMinor,U=T[A].mirrorMinor,V=u(b,T[A].primalOffset);for(L=0;L<3;++L)this.lineTickEnable[A]&&(V[L]+=M*B[L]*Math.max(this.lineTickLength[L],0)/r[5*L]);var H=[0,0,0];if(H[A]=1,this.tickEnable[A]){-3600===this.tickAngle[A]?(this.tickAngle[A]=0,this._tickAlign[A]="auto"):this._tickAlign[A]=-1,N=1,"auto"===(k=[this._tickAlign[A],.5,N])[0]?k[0]=0:k[0]=parseInt(""+k[0]),D=[0,0,0],j(A,B,U);for(L=0;L<3;++L)V[L]+=M*B[L]*this.tickPad[L]/r[5*L];this._text.drawTicks(A,this.tickSize[A],this.tickAngle[A],V,this.tickColor[A],H,D,k)}if(this.labelEnable[A]){N=0,D=[0,0,0],this.labels[A].length>4&&(F(A),N=1),"auto"===(k=[this._labelAlign[A],.5,N])[0]?k[0]=0:k[0]=parseInt(""+k[0]);for(L=0;L<3;++L)V[L]+=M*B[L]*this.labelPad[L]/r[5*L];V[A]+=.5*(a[0][A]+a[1][A]),this._text.drawLabel(A,this.labelSize[A],this._labelAngle[A],V,this.labelColor[A],[0,0,0],D,k)}}this._text.unbind()},f.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":97,"./lib/cube.js":98,"./lib/lines.js":99,"./lib/text.js":101,"./lib/ticks.js":102}],97:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=[],s=0,l=0;l<3;++l)for(var u=(l+1)%3,c=(l+2)%3,f=[0,0,0],h=[0,0,0],d=-1;d<=1;d+=2){r.push(s,s+2,s+1,s+1,s+2,s+3),f[l]=d,h[l]=d;for(var p=-1;p<=1;p+=2){f[u]=p;for(var g=-1;g<=1;g+=2)f[c]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),s+=1}var v=u;u=c,c=v}var m=n(t,new Float32Array(e)),y=n(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),b=i(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),x=a(t);return x.attributes.position.location=0,x.attributes.normal.location=1,new o(t,m,b,x)};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders").bg;function o(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}var s=o.prototype;s.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;s<3;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),this.vao.unbind(),l.disable(l.POLYGON_OFFSET_FILL)}},s.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":100,"gl-buffer":104,"gl-vao":167}],98:[function(t,e,r){"use strict";e.exports=function(t,e,r,a){i(s,e,t),i(s,r,s);for(var d=0,y=0;y<2;++y){c[2]=a[y][2];for(var b=0;b<2;++b){c[1]=a[b][1];for(var x=0;x<2;++x)c[0]=a[x][0],h(l[d],c,s),d+=1}}for(var _=-1,y=0;y<8;++y){for(var w=l[y][3],M=0;M<3;++M)u[y][M]=l[y][M]/w;w<0&&(_<0?_=y:u[y][2]E&&(_|=1<E&&(_|=1<u[y][1]&&(I=y));for(var N=-1,y=0;y<3;++y){var D=I^1<u[F][0]&&(F=D)}}var j=g;j[0]=j[1]=j[2]=0,j[n.log2(N^I)]=I&N,j[n.log2(I^F)]=I&F;var B=7^F;B===_||B===z?(B=7^N,j[n.log2(F^B)]=B&F):j[n.log2(N^B)]=B&N;for(var U=v,V=_,A=0;A<3;++A)U[A]=V&1< HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]),l=n(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]);r.text=function(t){return i(t,s,l,null,[{name:"position",type:"vec3"}])};var u=n(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]),c=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]);r.bg=function(t){return i(t,u,c,null,[{name:"position",type:"vec3"},{name:"normal",type:"vec3"}])}},{"gl-shader":148,glslify:249}],101:[function(t,e,r){(function(r){"use strict";e.exports=function(t,e,r,a,s,l){var c=n(t),f=i(t,[{buffer:c,size:3}]),h=o(t);h.attributes.position.location=0;var d=new u(t,h,c,f);return d.update(e,r,a,s,l),d};var n=t("gl-buffer"),i=t("gl-vao"),a=t("vectorize-text"),o=t("./shaders").text,s=window||r.global||{},l=s.__TEXT_CACHE||{};s.__TEXT_CACHE={};function u(t,e,r,n){this.gl=t,this.shader=e,this.buffer=r,this.vao=n,this.tickOffset=this.tickCount=this.labelOffset=this.labelCount=null}var c=u.prototype,f=[0,0];c.bind=function(t,e,r,n){this.vao.bind(),this.shader.bind();var i=this.shader.uniforms;i.model=t,i.view=e,i.projection=r,i.pixelScale=n,f[0]=this.gl.drawingBufferWidth,f[1]=this.gl.drawingBufferHeight,this.shader.uniforms.resolution=f},c.unbind=function(){this.vao.unbind()},c.update=function(t,e,r,n,i){this.gl;var o=[];function s(t,e,r,n){var i=l[r];i||(i=l[r]={});var s=i[e];s||(s=i[e]=function(t,e){try{return a(t,e)}catch(t){return console.warn("error vectorizing text:",t),{cells:[],positions:[]}}}(e,{triangles:!0,font:r,textAlign:"center",textBaseline:"middle"}));for(var u=(n||12)/12,c=s.positions,f=s.cells,h=0,d=f.length;h=0;--g){var v=c[p[g]];o.push(u*v[0],-u*v[1],t)}}for(var u=[0,0,0],c=[0,0,0],f=[0,0,0],h=[0,0,0],d=0;d<3;++d){f[d]=o.length/3|0,s(.5*(t[0][d]+t[1][d]),e[d],r),h[d]=(o.length/3|0)-f[d],u[d]=o.length/3|0;for(var p=0;p=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,u=o%a;o<0?(l=0|-Math.ceil(l),u=0|-u):(l=0|Math.floor(l),u|=0);var c=""+l;if(o<0&&(c="-"+c),i){for(var f=""+u;f.length=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r},r.equal=function(t,e){for(var r=0;r<3;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;nr)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function c(t,e){for(var r=n.malloc(t.length,e),i=t.length,a=0;a=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=u(this.gl,this.type,this.length,this.usage,t.data,e):this.length=u(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=n.malloc(t.size,r),l=a(s,t.shape);i.assign(l,t),this.length=u(this.gl,this.type,this.length,this.usage,e<0?s:s.subarray(0,t.size),e),n.free(s)}}else if(Array.isArray(t)){var f;f=this.type===this.gl.ELEMENT_ARRAY_BUFFER?c(t,"uint16"):c(t,"float32"),this.length=u(this.gl,this.type,this.length,this.usage,e<0?f:f.subarray(0,t.length),e),n.free(f)}else if("object"==typeof t&&"number"==typeof t.length)this.length=u(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");(t|=0)<=0&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=function(t,e,r,n){if(r=r||t.ARRAY_BUFFER,n=n||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(n!==t.DYNAMIC_DRAW&&n!==t.STATIC_DRAW&&n!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var i=t.createBuffer(),a=new s(t,r,i,0,n);return a.update(e),a}},{ndarray:285,"ndarray-ops":279,"typedarray-pool":348}],105:[function(t,e,r){"use strict";var n=t("gl-vec3"),i=(t("gl-vec4"),function(t,e){for(var r=0;r=e)return r-1;return r}),a=n.create(),o=n.create(),s=function(t,e,r){return tr?r:t},l=function(t,e,r,l){var u=t[0],c=t[1],f=t[2],h=r[0].length,d=r[1].length,p=r[2].length,g=i(r[0],u),v=i(r[1],c),m=i(r[2],f),y=g+1,b=v+1,x=m+1;if(l&&(g=s(g,0,h-1),y=s(y,0,h-1),v=s(v,0,d-1),b=s(b,0,d-1),m=s(m,0,p-1),x=s(x,0,p-1)),g<0||v<0||m<0||y>=h||b>=d||x>=p)return n.create();var _=(u-r[0][g])/(r[0][y]-r[0][g]),w=(c-r[1][v])/(r[1][b]-r[1][v]),M=(f-r[2][m])/(r[2][x]-r[2][m]);(_<0||_>1||isNaN(_))&&(_=0),(w<0||w>1||isNaN(w))&&(w=0),(M<0||M>1||isNaN(M))&&(M=0);var A=m*h*d,T=x*h*d,k=v*h,E=b*h,S=g,L=y,C=e[k+A+S],O=e[k+A+L],R=e[E+A+S],P=e[E+A+L],z=e[k+T+S],I=e[k+T+L],N=e[E+T+S],D=e[E+T+L],F=n.create();return n.lerp(F,C,O,_),n.lerp(a,R,P,_),n.lerp(F,F,a,w),n.lerp(a,z,I,_),n.lerp(o,N,D,_),n.lerp(a,a,o,w),n.lerp(F,F,a,M),F};e.exports=function(t,e){var r;r=t.positions?t.positions:function(t){for(var e=t[0],r=t[1],n=t[2],i=[],a=0;as&&(s=n.length(x)),b&&(y=Math.min(y,2*n.distance(g,_)/(n.length(v)+n.length(x)))),g=_,v=x,m.push(x)}var w=[u,f,d],M=[c,h,p];e&&(e[0]=w,e[1]=M),0===s&&(s=1);var A=1/s;isFinite(y)&&!isNaN(y)||(y=1),o.vectorScale=y;var T=function(t,e,r){var i=n.create();return void 0!==t&&n.set(i,t,e,r),i}(0,1,0),k=t.coneSize||.5;t.absoluteConeSize&&(k=t.absoluteConeSize*A),o.coneScale=k;b=0;for(var E=0;b1.0001)return null;v+=g[c]}if(Math.abs(v-1)>.001)return null;return[f,function(t,e){for(var r=[0,0,0],n=0;n=1},b.isTransparent=function(){return this.opacity<1},b.pickSlots=1,b.setPickBase=function(t){this.pickId=t},b.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=d.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},b.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||m,n=t.view||m,i=t.projection||m,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,vectorScale:this.vectorScale,coneScale:this.coneScale,coneOffset:this.coneOffset,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},b.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions[r[1]].slice(0,3);return{index:Math.floor(r[1]/48),position:n,dataCoordinate:n}},b.dispose=function(){this.texture.dispose(),this.triShader.dispose(),this.pickShader.dispose(),this.triangleVAO.dispose(),this.trianglePositions.dispose(),this.triangleVectors.dispose(),this.triangleColors.dispose(),this.triangleUVs.dispose(),this.triangleNormals.dispose(),this.triangleIds.dispose(),this.edgeVAO.dispose(),this.edgePositions.dispose(),this.edgeColors.dispose(),this.edgeUVs.dispose(),this.edgeIds.dispose(),this.pointVAO.dispose(),this.pointPositions.dispose(),this.pointColors.dispose(),this.pointUVs.dispose(),this.pointSizes.dispose(),this.pointIds.dispose(),this.contourVAO.dispose(),this.contourPositions.dispose()},e.exports=function(t,e){1===arguments.length&&(t=(e=t).gl);var r=e.triShader||function(t){var e=n(t,g.vertex,g.fragment,null,g.attributes);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.vector.location=5,e}(t),s=x(t),l=o(t,c(new Uint8Array([255,255,255,255]),[1,1,4]));l.generateMipmap(),l.minFilter=t.LINEAR_MIPMAP_LINEAR,l.magFilter=t.LINEAR;var u=i(t),f=i(t),h=i(t),d=i(t),p=i(t),v=i(t),m=a(t,[{buffer:u,type:t.FLOAT,size:4},{buffer:v,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:h,type:t.FLOAT,size:4},{buffer:d,type:t.FLOAT,size:2},{buffer:p,type:t.FLOAT,size:3},{buffer:f,type:t.FLOAT,size:3}]),b=i(t),_=i(t),w=i(t),M=i(t),A=a(t,[{buffer:b,type:t.FLOAT,size:3},{buffer:M,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:_,type:t.FLOAT,size:4},{buffer:w,type:t.FLOAT,size:2}]),T=i(t),k=i(t),E=i(t),S=i(t),L=i(t),C=a(t,[{buffer:T,type:t.FLOAT,size:3},{buffer:L,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:k,type:t.FLOAT,size:4},{buffer:E,type:t.FLOAT,size:2},{buffer:S,type:t.FLOAT,size:1}]),O=i(t),R=new y(t,l,r,null,null,s,null,null,u,f,v,h,d,p,m,b,M,_,w,A,T,L,k,E,S,C,O,a(t,[{buffer:O,type:t.FLOAT,size:3}]));return R.update(e),R}},{"./closest-point":106,"./shaders":108,colormap:69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-shader":148,"gl-texture2d":163,"gl-vao":167,ndarray:285,normals:287,"simplicial-complex-contour":329,"typedarray-pool":348}],108:[function(t,e,r){var n=t("glslify"),i=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec3"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec3"}]}},{glslify:249}],109:[function(t,e,r){e.exports={0:"NONE",1:"ONE",2:"LINE_LOOP",3:"LINE_STRIP",4:"TRIANGLES",5:"TRIANGLE_STRIP",6:"TRIANGLE_FAN",256:"DEPTH_BUFFER_BIT",512:"NEVER",513:"LESS",514:"EQUAL",515:"LEQUAL",516:"GREATER",517:"NOTEQUAL",518:"GEQUAL",519:"ALWAYS",768:"SRC_COLOR",769:"ONE_MINUS_SRC_COLOR",770:"SRC_ALPHA",771:"ONE_MINUS_SRC_ALPHA",772:"DST_ALPHA",773:"ONE_MINUS_DST_ALPHA",774:"DST_COLOR",775:"ONE_MINUS_DST_COLOR",776:"SRC_ALPHA_SATURATE",1024:"STENCIL_BUFFER_BIT",1028:"FRONT",1029:"BACK",1032:"FRONT_AND_BACK",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",2304:"CW",2305:"CCW",2849:"LINE_WIDTH",2884:"CULL_FACE",2885:"CULL_FACE_MODE",2886:"FRONT_FACE",2928:"DEPTH_RANGE",2929:"DEPTH_TEST",2930:"DEPTH_WRITEMASK",2931:"DEPTH_CLEAR_VALUE",2932:"DEPTH_FUNC",2960:"STENCIL_TEST",2961:"STENCIL_CLEAR_VALUE",2962:"STENCIL_FUNC",2963:"STENCIL_VALUE_MASK",2964:"STENCIL_FAIL",2965:"STENCIL_PASS_DEPTH_FAIL",2966:"STENCIL_PASS_DEPTH_PASS",2967:"STENCIL_REF",2968:"STENCIL_WRITEMASK",2978:"VIEWPORT",3024:"DITHER",3042:"BLEND",3088:"SCISSOR_BOX",3089:"SCISSOR_TEST",3106:"COLOR_CLEAR_VALUE",3107:"COLOR_WRITEMASK",3317:"UNPACK_ALIGNMENT",3333:"PACK_ALIGNMENT",3379:"MAX_TEXTURE_SIZE",3386:"MAX_VIEWPORT_DIMS",3408:"SUBPIXEL_BITS",3410:"RED_BITS",3411:"GREEN_BITS",3412:"BLUE_BITS",3413:"ALPHA_BITS",3414:"DEPTH_BITS",3415:"STENCIL_BITS",3553:"TEXTURE_2D",4352:"DONT_CARE",4353:"FASTEST",4354:"NICEST",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT",5386:"INVERT",5890:"TEXTURE",6401:"STENCIL_INDEX",6402:"DEPTH_COMPONENT",6406:"ALPHA",6407:"RGB",6408:"RGBA",6409:"LUMINANCE",6410:"LUMINANCE_ALPHA",7680:"KEEP",7681:"REPLACE",7682:"INCR",7683:"DECR",7936:"VENDOR",7937:"RENDERER",7938:"VERSION",9728:"NEAREST",9729:"LINEAR",9984:"NEAREST_MIPMAP_NEAREST",9985:"LINEAR_MIPMAP_NEAREST",9986:"NEAREST_MIPMAP_LINEAR",9987:"LINEAR_MIPMAP_LINEAR",10240:"TEXTURE_MAG_FILTER",10241:"TEXTURE_MIN_FILTER",10242:"TEXTURE_WRAP_S",10243:"TEXTURE_WRAP_T",10497:"REPEAT",10752:"POLYGON_OFFSET_UNITS",16384:"COLOR_BUFFER_BIT",32769:"CONSTANT_COLOR",32770:"ONE_MINUS_CONSTANT_COLOR",32771:"CONSTANT_ALPHA",32772:"ONE_MINUS_CONSTANT_ALPHA",32773:"BLEND_COLOR",32774:"FUNC_ADD",32777:"BLEND_EQUATION_RGB",32778:"FUNC_SUBTRACT",32779:"FUNC_REVERSE_SUBTRACT",32819:"UNSIGNED_SHORT_4_4_4_4",32820:"UNSIGNED_SHORT_5_5_5_1",32823:"POLYGON_OFFSET_FILL",32824:"POLYGON_OFFSET_FACTOR",32854:"RGBA4",32855:"RGB5_A1",32873:"TEXTURE_BINDING_2D",32926:"SAMPLE_ALPHA_TO_COVERAGE",32928:"SAMPLE_COVERAGE",32936:"SAMPLE_BUFFERS",32937:"SAMPLES",32938:"SAMPLE_COVERAGE_VALUE",32939:"SAMPLE_COVERAGE_INVERT",32968:"BLEND_DST_RGB",32969:"BLEND_SRC_RGB",32970:"BLEND_DST_ALPHA",32971:"BLEND_SRC_ALPHA",33071:"CLAMP_TO_EDGE",33170:"GENERATE_MIPMAP_HINT",33189:"DEPTH_COMPONENT16",33306:"DEPTH_STENCIL_ATTACHMENT",33635:"UNSIGNED_SHORT_5_6_5",33648:"MIRRORED_REPEAT",33901:"ALIASED_POINT_SIZE_RANGE",33902:"ALIASED_LINE_WIDTH_RANGE",33984:"TEXTURE0",33985:"TEXTURE1",33986:"TEXTURE2",33987:"TEXTURE3",33988:"TEXTURE4",33989:"TEXTURE5",33990:"TEXTURE6",33991:"TEXTURE7",33992:"TEXTURE8",33993:"TEXTURE9",33994:"TEXTURE10",33995:"TEXTURE11",33996:"TEXTURE12",33997:"TEXTURE13",33998:"TEXTURE14",33999:"TEXTURE15",34000:"TEXTURE16",34001:"TEXTURE17",34002:"TEXTURE18",34003:"TEXTURE19",34004:"TEXTURE20",34005:"TEXTURE21",34006:"TEXTURE22",34007:"TEXTURE23",34008:"TEXTURE24",34009:"TEXTURE25",34010:"TEXTURE26",34011:"TEXTURE27",34012:"TEXTURE28",34013:"TEXTURE29",34014:"TEXTURE30",34015:"TEXTURE31",34016:"ACTIVE_TEXTURE",34024:"MAX_RENDERBUFFER_SIZE",34041:"DEPTH_STENCIL",34055:"INCR_WRAP",34056:"DECR_WRAP",34067:"TEXTURE_CUBE_MAP",34068:"TEXTURE_BINDING_CUBE_MAP",34069:"TEXTURE_CUBE_MAP_POSITIVE_X",34070:"TEXTURE_CUBE_MAP_NEGATIVE_X",34071:"TEXTURE_CUBE_MAP_POSITIVE_Y",34072:"TEXTURE_CUBE_MAP_NEGATIVE_Y",34073:"TEXTURE_CUBE_MAP_POSITIVE_Z",34074:"TEXTURE_CUBE_MAP_NEGATIVE_Z",34076:"MAX_CUBE_MAP_TEXTURE_SIZE",34338:"VERTEX_ATTRIB_ARRAY_ENABLED",34339:"VERTEX_ATTRIB_ARRAY_SIZE",34340:"VERTEX_ATTRIB_ARRAY_STRIDE",34341:"VERTEX_ATTRIB_ARRAY_TYPE",34342:"CURRENT_VERTEX_ATTRIB",34373:"VERTEX_ATTRIB_ARRAY_POINTER",34466:"NUM_COMPRESSED_TEXTURE_FORMATS",34467:"COMPRESSED_TEXTURE_FORMATS",34660:"BUFFER_SIZE",34661:"BUFFER_USAGE",34816:"STENCIL_BACK_FUNC",34817:"STENCIL_BACK_FAIL",34818:"STENCIL_BACK_PASS_DEPTH_FAIL",34819:"STENCIL_BACK_PASS_DEPTH_PASS",34877:"BLEND_EQUATION_ALPHA",34921:"MAX_VERTEX_ATTRIBS",34922:"VERTEX_ATTRIB_ARRAY_NORMALIZED",34930:"MAX_TEXTURE_IMAGE_UNITS",34962:"ARRAY_BUFFER",34963:"ELEMENT_ARRAY_BUFFER",34964:"ARRAY_BUFFER_BINDING",34965:"ELEMENT_ARRAY_BUFFER_BINDING",34975:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",35040:"STREAM_DRAW",35044:"STATIC_DRAW",35048:"DYNAMIC_DRAW",35632:"FRAGMENT_SHADER",35633:"VERTEX_SHADER",35660:"MAX_VERTEX_TEXTURE_IMAGE_UNITS",35661:"MAX_COMBINED_TEXTURE_IMAGE_UNITS",35663:"SHADER_TYPE",35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",35712:"DELETE_STATUS",35713:"COMPILE_STATUS",35714:"LINK_STATUS",35715:"VALIDATE_STATUS",35716:"INFO_LOG_LENGTH",35717:"ATTACHED_SHADERS",35718:"ACTIVE_UNIFORMS",35719:"ACTIVE_UNIFORM_MAX_LENGTH",35720:"SHADER_SOURCE_LENGTH",35721:"ACTIVE_ATTRIBUTES",35722:"ACTIVE_ATTRIBUTE_MAX_LENGTH",35724:"SHADING_LANGUAGE_VERSION",35725:"CURRENT_PROGRAM",36003:"STENCIL_BACK_REF",36004:"STENCIL_BACK_VALUE_MASK",36005:"STENCIL_BACK_WRITEMASK",36006:"FRAMEBUFFER_BINDING",36007:"RENDERBUFFER_BINDING",36048:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36049:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36050:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36051:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36053:"FRAMEBUFFER_COMPLETE",36054:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36055:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36057:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36061:"FRAMEBUFFER_UNSUPPORTED",36064:"COLOR_ATTACHMENT0",36096:"DEPTH_ATTACHMENT",36128:"STENCIL_ATTACHMENT",36160:"FRAMEBUFFER",36161:"RENDERBUFFER",36162:"RENDERBUFFER_WIDTH",36163:"RENDERBUFFER_HEIGHT",36164:"RENDERBUFFER_INTERNAL_FORMAT",36168:"STENCIL_INDEX8",36176:"RENDERBUFFER_RED_SIZE",36177:"RENDERBUFFER_GREEN_SIZE",36178:"RENDERBUFFER_BLUE_SIZE",36179:"RENDERBUFFER_ALPHA_SIZE",36180:"RENDERBUFFER_DEPTH_SIZE",36181:"RENDERBUFFER_STENCIL_SIZE",36194:"RGB565",36336:"LOW_FLOAT",36337:"MEDIUM_FLOAT",36338:"HIGH_FLOAT",36339:"LOW_INT",36340:"MEDIUM_INT",36341:"HIGH_INT",36346:"SHADER_COMPILER",36347:"MAX_VERTEX_UNIFORM_VECTORS",36348:"MAX_VARYING_VECTORS",36349:"MAX_FRAGMENT_UNIFORM_VECTORS",37440:"UNPACK_FLIP_Y_WEBGL",37441:"UNPACK_PREMULTIPLY_ALPHA_WEBGL",37442:"CONTEXT_LOST_WEBGL",37443:"UNPACK_COLORSPACE_CONVERSION_WEBGL",37444:"BROWSER_DEFAULT_WEBGL"}},{}],110:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":109}],111:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=n(e),o=i(e,[{buffer:r,type:e.FLOAT,size:3,offset:0,stride:40},{buffer:r,type:e.FLOAT,size:4,offset:12,stride:40},{buffer:r,type:e.FLOAT,size:3,offset:28,stride:40}]),l=a(e);l.attributes.position.location=0,l.attributes.color.location=1,l.attributes.offset.location=2;var u=new s(e,r,o,l);return u.update(t),u};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders/index"),o=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function s(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}var l=s.prototype;function u(t,e){for(var r=0;r<3;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}l.isOpaque=function(){return this.opacity>=1},l.isTransparent=function(){return this.opacity<1},l.drawTransparent=l.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||o,i=r.projection=t.projection||o;r.model=t.model||o,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],s=n[13],l=n[14],u=n[15],c=this.pixelRatio*(i[3]*a+i[7]*s+i[11]*l+i[15]*u)/e.drawingBufferHeight;this.vao.bind();for(var f=0;f<3;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*c,this.lineCount[f]&&e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var c=function(){for(var t=new Array(3),e=0;e<3;++e){for(var r=[],n=1;n<=2;++n)for(var i=-1;i<=1;i+=2){var a=[0,0,0];a[(n+e)%3]=i,r.push(a)}t[e]=r}return t}();function f(t,e,r,n){for(var i=c[n],a=0;a0)(g=c.slice())[s]+=d[1][s],i.push(c[0],c[1],c[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),u(this.bounds,g),o+=2+f(i,g,p,s)}}this.lineCount[s]=o-this.lineOffset[s]}this.buffer.update(i)}},l.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":112,"gl-buffer":104,"gl-vao":167}],112:[function(t,e,r){"use strict";var n=t("glslify"),i=t("gl-shader"),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]);e.exports=function(t){return i(t,a,o,null,[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"offset",type:"vec3"}])}},{"gl-shader":148,glslify:249}],113:[function(t,e,r){"use strict";var n=t("gl-texture2d");e.exports=function(t,e,r,n){i||(i=t.FRAMEBUFFER_UNSUPPORTED,a=t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT,o=t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS,s=t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);var u=t.getExtension("WEBGL_draw_buffers");!l&&u&&function(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);l=new Array(r+1);for(var n=0;n<=r;++n){for(var i=new Array(r),a=0;ac||r<0||r>c)throw new Error("gl-fbo: Parameters are too large for FBO");var f=1;if("color"in(n=n||{})){if((f=Math.max(0|n.color,0))<0)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(f>1){if(!u)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(f>t.getParameter(u.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+f+" draw buffers")}}var h=t.UNSIGNED_BYTE,d=t.getExtension("OES_texture_float");if(n.float&&f>0){if(!d)throw new Error("gl-fbo: Context does not support floating point textures");h=t.FLOAT}else n.preferFloat&&f>0&&d&&(h=t.FLOAT);var g=!0;"depth"in n&&(g=!!n.depth);var v=!1;"stencil"in n&&(v=!!n.stencil);return new p(t,e,r,h,f,g,v,u)};var i,a,o,s,l=null;function u(t){return[t.getParameter(t.FRAMEBUFFER_BINDING),t.getParameter(t.RENDERBUFFER_BINDING),t.getParameter(t.TEXTURE_BINDING_2D)]}function c(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function f(t){switch(t){case i:throw new Error("gl-fbo: Framebuffer unsupported");case a:throw new Error("gl-fbo: Framebuffer incomplete attachment");case o:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case s:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function h(t,e,r,i,a,o){if(!i)return null;var s=n(t,e,r,a,i);return s.magFilter=t.NEAREST,s.minFilter=t.NEAREST,s.mipSamples=1,s.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_2D,s.handle,0),s}function d(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function p(t,e,r,n,i,a,o,s){this.gl=t,this._shape=[0|e,0|r],this._destroyed=!1,this._ext=s,this.color=new Array(i);for(var p=0;p1&&s.drawBuffersWEBGL(l[o]);var y=r.getExtension("WEBGL_depth_texture");y?p?t.depth=h(r,i,a,y.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g&&(t.depth=h(r,i,a,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):g&&p?t._depth_rb=d(r,i,a,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g?t._depth_rb=d(r,i,a,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):p&&(t._depth_rb=d(r,i,a,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){for(t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null),m=0;mi||r<0||r>i)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var a=u(n),o=0;o max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1540259130(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1540259130(pixelArcLength).xyz);\n}"]),l=[{name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return i(t,a,o,null,l)},r.createPickShader=function(t){return i(t,a,s,null,l)}},{"gl-shader":148,glslify:249}],116:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl||t.scene&&t.scene.gl,r=c(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var o=f(e);o.attributes.position.location=0,o.attributes.nextPosition.location=1,o.attributes.arcLength.location=2,o.attributes.lineWidth.location=3,o.attributes.color.location=4;for(var s=n(e),u=i(e,[{buffer:s,size:3,offset:0,stride:48},{buffer:s,size:3,offset:12,stride:48},{buffer:s,size:1,offset:24,stride:48},{buffer:s,size:1,offset:28,stride:48},{buffer:s,size:4,offset:32,stride:48}]),h=l(new Array(1024),[256,1,4]),d=0;d<1024;++d)h.data[d]=255;var p=a(e,h);p.wrap=e.REPEAT;var g=new v(e,r,o,s,u,p);return g.update(t),g};var n=t("gl-buffer"),i=t("gl-vao"),a=t("gl-texture2d"),o=t("glsl-read-float"),s=t("binary-search-bounds"),l=t("ndarray"),u=t("./lib/shaders"),c=u.createShader,f=u.createPickShader,h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function d(t,e){for(var r=0,n=0;n<3;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function p(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;r<3;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function g(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function v(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}var m=v.prototype;m.isTransparent=function(){return this.opacity<1},m.isOpaque=function(){return this.opacity>=1},m.pickSlots=1,m.setPickBase=function(t){this.pickId=t},m.drawTransparent=m.draw=function(t){if(this.vertexCount){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||h,view:t.view||h,projection:t.projection||h,clipBounds:p(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},m.drawPick=function(t){if(this.vertexCount){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||h,view:t.view||h,projection:t.projection||h,pickId:this.pickId,clipBounds:p(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},m.update=function(t){var e,r;this.dirty=!0;var n=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var i=[],a=[],o=[],u=0,c=0,f=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],h=t.position||t.positions;if(h){var p=t.color||t.colors||[0,0,0,1],g=t.lineWidth||1,v=!1;t:for(e=1;e0){for(var w=0;w<24;++w)i.push(i[i.length-12]);c+=2,v=!0}continue t}f[0][r]=Math.min(f[0][r],x[r],_[r]),f[1][r]=Math.max(f[1][r],x[r],_[r])}Array.isArray(p[0])?(m=p.length>e-1?p[e-1]:p.length>0?p[p.length-1]:[0,0,0,1],y=p.length>e?p[e]:p.length>0?p[p.length-1]:[0,0,0,1]):m=y=p,3===m.length&&(m=[m[0],m[1],m[2],1]),3===y.length&&(y=[y[0],y[1],y[2],1]),b=Array.isArray(g)?g.length>e-1?g[e-1]:g.length>0?g[g.length-1]:[0,0,0,1]:g;var M=u;if(u+=d(x,_),v){for(r=0;r<2;++r)i.push(x[0],x[1],x[2],_[0],_[1],_[2],M,b,m[0],m[1],m[2],m[3]);c+=2,v=!1}i.push(x[0],x[1],x[2],_[0],_[1],_[2],M,b,m[0],m[1],m[2],m[3],x[0],x[1],x[2],_[0],_[1],_[2],M,-b,m[0],m[1],m[2],m[3],_[0],_[1],_[2],x[0],x[1],x[2],u,-b,y[0],y[1],y[2],y[3],_[0],_[1],_[2],x[0],x[1],x[2],u,b,y[0],y[1],y[2],y[3]),c+=4}}if(this.buffer.update(i),a.push(u),o.push(h[h.length-1].slice()),this.bounds=f,this.vertexCount=c,this.points=o,this.arcLength=a,"dashes"in t){var A=t.dashes.slice();for(A.unshift(0),e=1;e max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),l=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]),u=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),c=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]),f=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]),h=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]),d=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]),p=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:l,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:c,fragment:f,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:h,fragment:f,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:d,fragment:p,attributes:[{name:"position",type:"vec3"}]}},{glslify:249}],139:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("normals"),l=t("gl-mat4/multiply"),u=t("gl-mat4/invert"),c=t("ndarray"),f=t("colormap"),h=t("simplicial-complex-contour"),d=t("typedarray-pool"),p=t("./lib/shaders"),g=t("./lib/closest-point"),v=p.meshShader,m=p.wireShader,y=p.pointShader,b=p.pickShader,x=p.pointPickShader,_=p.contourShader,w=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function M(t,e,r,n,i,a,o,s,l,u,c,f,h,d,p,g,v,m,y,b,x,_,M,A,T,k,E){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=c,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=u,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=p,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=b,this.pointColors=_,this.pointUVs=M,this.pointSizes=A,this.pointIds=x,this.pointVAO=T,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=k,this.contourVAO=E,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=w,this._view=w,this._projection=w,this._resolution=[1,1]}var A=M.prototype;function T(t){var e=n(t,y.vertex,y.fragment);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function k(t){var e=n(t,b.vertex,b.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e}function E(t){var e=n(t,x.vertex,x.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function S(t){var e=n(t,_.vertex,_.fragment);return e.attributes.position.location=0,e}A.isOpaque=function(){return this.opacity>=1},A.isTransparent=function(){return this.opacity<1},A.pickSlots=1,A.setPickBase=function(t){this.pickId=t},A.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=d.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},A.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||w,n=t.view||w,i=t.projection||w,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},A.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;a0&&0===C[e-1];)C.pop(),O.pop().dispose()}window.addEventListener("resize",B),F.update=function(t){e||(t=t||{},R=!0,P=!0)},F.add=function(t){e||(t.axes=T,S.push(t),L.push(-1),R=!0,P=!0,U())},F.remove=function(t){if(!e){var r=S.indexOf(t);r<0||(S.splice(r,1),L.pop(),R=!0,P=!0,U())}},F.dispose=function(){if(!e&&(e=!0,window.removeEventListener("resize",B),r.removeEventListener("webglcontextlost",q),F.mouseListener.enabled=!1,!F.contextLost)){T.dispose(),E.dispose();for(var t=0;tx.distance)continue;for(var c=0;c0){r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function v(t){return"boolean"!=typeof t||t}},{"./lib/shader":140,"3d-view-controls":10,"a-big-triangle":12,"gl-axes3d":96,"gl-axes3d/properties":103,"gl-fbo":113,"gl-mat4/perspective":128,"gl-select-static":147,"gl-spikes3d":156,"is-mobile":259,"mouse-change":270}],142:[function(t,e,r){e.exports=function(t,e,r,n){var i,a,o,s,l,u=e[0],c=e[1],f=e[2],h=e[3],d=r[0],p=r[1],g=r[2],v=r[3];(a=u*d+c*p+f*g+h*v)<0&&(a=-a,d=-d,p=-p,g=-g,v=-v);1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n);return t[0]=s*u+l*d,t[1]=s*c+l*p,t[2]=s*f+l*g,t[3]=s*h+l*v,t}},{}],143:[function(t,e,r){"use strict";e.exports=function(t){return t||0===t?t.toString():""}},{}],144:[function(t,e,r){"use strict";var n=t("vectorize-text");e.exports=function(t,e){var r=i[e];r||(r=i[e]={});if(t in r)return r[t];for(var a=n(t,{textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),o=n(t,{triangles:!0,textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),s=[[1/0,1/0],[-1/0,-1/0]],l=0;l max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),o=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),s=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]),l=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]),u=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]),c=[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:c},h={vertex:o,fragment:l,attributes:c},d={vertex:s,fragment:l,attributes:c},p={vertex:a,fragment:u,attributes:c},g={vertex:o,fragment:u,attributes:c},v={vertex:s,fragment:u,attributes:c};function m(t,e){var r=n(t,e),i=r.attributes;return i.position.location=0,i.color.location=1,i.glyph.location=2,i.id.location=3,r}r.createPerspective=function(t){return m(t,f)},r.createOrtho=function(t){return m(t,h)},r.createProject=function(t){return m(t,d)},r.createPickPerspective=function(t){return m(t,p)},r.createPickOrtho=function(t){return m(t,g)},r.createPickProject=function(t){return m(t,v)}},{"gl-shader":148,glslify:249}],146:[function(t,e,r){"use strict";var n=t("is-string-blank"),i=t("gl-buffer"),a=t("gl-vao"),o=t("typedarray-pool"),s=t("gl-mat4/multiply"),l=t("./lib/shaders"),u=t("./lib/glyphs"),c=t("./lib/get-simple-string"),f=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function h(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function d(t,e,r,n){return h(n,n),h(n,n),h(n,n)}function p(t,e){this.index=t,this.dataCoordinate=this.position=e}function g(t,e,r,n,i,a,o,s,l,u,c,f){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=a,this.glyphBuffer=o,this.idBuffer=s,this.vao=l,this.vertexCount=0,this.lineVertexCount=0,this.opacity=1,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[1,1,1],this.pickId=0,this.pickPerspectiveShader=u,this.pickOrthoShader=c,this.pickProjectShader=f,this.points=[],this._selectResult=new p(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.dirty=!0}e.exports=function(t){var e=t.gl,r=l.createPerspective(e),n=l.createOrtho(e),o=l.createProject(e),s=l.createPickPerspective(e),u=l.createPickOrtho(e),c=l.createPickProject(e),f=i(e),h=i(e),d=i(e),p=i(e),v=a(e,[{buffer:f,size:3,type:e.FLOAT},{buffer:h,size:4,type:e.FLOAT},{buffer:d,size:2,type:e.FLOAT},{buffer:p,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),m=new g(e,r,n,o,f,h,d,p,v,s,u,c);return m.update(t),m};var v=g.prototype;v.pickSlots=1,v.setPickBase=function(t){this.pickId=t},v.isTransparent=function(){if(this.opacity<1)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&this.projectOpacity[t]<1)return!0;return!1},v.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=1)return!0;return!1};var m=[0,0],y=[0,0,0],b=[0,0,0],x=[0,0,0,1],_=[0,0,0,1],w=f.slice(),M=[0,0,0],A=[[0,0,0],[0,0,0]];function T(t){return t[0]=t[1]=t[2]=0,t}function k(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function E(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function S(t,e,r,n,i){var a,o=e.axesProject,l=e.gl,u=t.uniforms,c=r.model||f,h=r.view||f,p=r.projection||f,g=e.axesBounds,v=function(t){for(var e=A,r=0;r<2;++r)for(var n=0;n<3;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}(e.clipBounds);a=e.axes&&e.axes.lastCubeProps?e.axes.lastCubeProps.axis:[1,1,1],m[0]=2/l.drawingBufferWidth,m[1]=2/l.drawingBufferHeight,t.bind(),u.view=h,u.projection=p,u.screenSize=m,u.highlightId=e.highlightId,u.highlightScale=e.highlightScale,u.clipBounds=v,u.pickGroup=e.pickId/255,u.pixelRatio=e.pixelRatio;for(var S=0;S<3;++S)if(o[S]&&e.projectOpacity[S]<1===n){u.scale=e.projectScale[S],u.opacity=e.projectOpacity[S];for(var L=w,C=0;C<16;++C)L[C]=0;for(C=0;C<4;++C)L[5*C]=1;L[5*S]=0,a[S]<0?L[12+S]=g[0][S]:L[12+S]=g[1][S],s(L,c,L),u.model=L;var O=(S+1)%3,R=(S+2)%3,P=T(y),z=T(b);P[O]=1,z[R]=1;var I=d(0,0,0,k(x,P)),N=d(0,0,0,k(_,z));if(Math.abs(I[1])>Math.abs(N[1])){var D=I;I=N,N=D,D=P,P=z,z=D;var F=O;O=R,R=F}I[0]<0&&(P[O]=-1),N[1]>0&&(z[R]=-1);var j=0,B=0;for(C=0;C<4;++C)j+=Math.pow(c[4*O+C],2),B+=Math.pow(c[4*R+C],2);P[O]/=Math.sqrt(j),z[R]/=Math.sqrt(B),u.axes[0]=P,u.axes[1]=z,u.fragClipBounds[0]=E(M,v[0],S,-1e8),u.fragClipBounds[1]=E(M,v[1],S,1e8),e.vao.draw(l.TRIANGLES,e.vertexCount),e.lineWidth>0&&(l.lineWidth(e.lineWidth),e.vao.draw(l.LINES,e.lineVertexCount,e.vertexCount))}}var L=[[-1e8,-1e8,-1e8],[1e8,1e8,1e8]];function C(t,e,r,n,i,a){var o=r.gl;if(r.vao.bind(),i===r.opacity<1||a){t.bind();var s=t.uniforms;s.model=n.model||f,s.view=n.view||f,s.projection=n.projection||f,m[0]=2/o.drawingBufferWidth,m[1]=2/o.drawingBufferHeight,s.screenSize=m,s.highlightId=r.highlightId,s.highlightScale=r.highlightScale,s.fragClipBounds=L,s.clipBounds=r.axes.bounds,s.opacity=r.opacity,s.pickGroup=r.pickId/255,s.pixelRatio=r.pixelRatio,r.vao.draw(o.TRIANGLES,r.vertexCount),r.lineWidth>0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount))}S(e,r,n,i),r.vao.unbind()}function O(t,e,r){var i;i=Array.isArray(t)?e=this.pointCount||e<0)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;i<3;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},v.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},v.update=function(t){if("perspective"in(t=t||{})&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t)if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{r=+t.projectOpacity;this.projectOpacity=[r,r,r]}"opacity"in t&&(this.opacity=t.opacity),this.dirty=!0;var n=t.position,i=t.font||"normal",a=t.alignment||[0,0],s=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0],u=t.glyph,c=t.color,f=t.size,h=t.angle,d=t.lineColor,p=-1,g=0,v=0,m=0;if(n.length){m=n.length;t:for(var y=0;y0){var L=0,C=g,R=[0,0,0,1],P=[0,0,0,1],z=Array.isArray(c)&&Array.isArray(c[0]),I=Array.isArray(d)&&Array.isArray(d[0]);t:for(y=0;y0?H[x]*=1-M[0][x]:a[x]<0&&(H[x]*=1+M[1][x]);var q=_.cells||[],G=_.positions||[];for(x=0;xthis.buffer.length){i.free(this.buffer);for(var n=this.buffer=i.mallocUint8(o(r*e*4)),a=0;ar)for(t=r;te)for(t=e;t=0){for(var M=0|w.type.charAt(w.type.length-1),A=new Array(M),T=0;T=0;)k+=1;_[y]=k}var E=new Array(r.length);function S(){h.program=o.program(d,h._vref,h._fref,x,_);for(var t=0;t=0){var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new n("","Invalid data type for attribute "+f+": "+h);o(t,e,d[0],i,p,a,f)}else{if(!(h.indexOf("mat")>=0))throw new n("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new n("","Invalid data type for attribute "+f+": "+h);s(t,e,d,i,p,a,f)}}}return a};var n=t("./GLError");function i(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}var a=i.prototype;function o(t,e,r,n,a,o,s){for(var l=["gl","v"],u=[],c=0;c4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+a+"fv(locations["+e+"],false,obj"+t+")"}throw new i("","Unknown uniform data type for "+name+": "+r)}var a=r.charCodeAt(r.length-1)-48;if(a<2||a>4)throw new i("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+a+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+a+"fv(locations["+e+"],obj"+t+")";default:throw new i("","Unrecognized data type for vector "+name+": "+r)}}}function u(e){for(var n=["return function updateProperty(obj){"],i=function t(e,r){if("object"!=typeof r)return[[e,r]];var n=[];for(var i in r){var a=r[i],o=e;parseInt(i)+""===i?o+="["+i+"]":o+="."+i,"object"==typeof a?n.push.apply(n,t(o,a)):n.push([o,a])}return n}("",e),a=0;a4)throw new i("","Invalid data type");return"b"===t.charAt(0)?o(r,!1):o(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(r<2||r>4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+t);return o(r*r,0)}throw new i("","Unknown uniform data type for "+name+": "+t)}}(r[c].type);var d}function f(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var u=1;u1)for(var l=0;l 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec4"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec4"}]}},{glslify:249}],159:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("normals"),l=t("gl-mat4/multiply"),u=t("gl-mat4/invert"),c=t("ndarray"),f=t("colormap"),h=t("simplicial-complex-contour"),d=t("typedarray-pool"),p=t("./shaders"),g=(t("./closest-point"),p.meshShader),v=p.pickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function y(t,e,r,n,i,a,o,s,l,u,c,f,h,d,p,g,v,y,b,x,_,w,M,A,T,k,E,S){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleVectors=u,this.triangleColors=f,this.triangleNormals=d,this.triangleUVs=h,this.triangleIds=c,this.triangleVAO=p,this.triangleCount=0,this.lineWidth=1,this.edgePositions=g,this.edgeColors=y,this.edgeUVs=b,this.edgeIds=v,this.edgeVAO=x,this.edgeCount=0,this.pointPositions=_,this.pointColors=M,this.pointUVs=A,this.pointSizes=T,this.pointIds=w,this.pointVAO=k,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=E,this.contourVAO=S,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!1,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this.tubeScale=1,this._model=m,this._view=m,this._projection=m,this._resolution=[1,1]}var b=y.prototype;function x(t){var e=n(t,v.vertex,v.fragment,null,v.attributes);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.vector.location=5,e}b.isOpaque=function(){return this.opacity>=1},b.isTransparent=function(){return this.opacity<1},b.pickSlots=1,b.setPickBase=function(t){this.pickId=t},b.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=d.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},b.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||m,n=t.view||m,i=t.projection||m,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,tubeScale:this.tubeScale,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},b.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions[r[1]].slice(0,3);return{index:e,position:n,intensity:this.intensity[r[1]],velocity:this.vectors[r[1]].slice(0,3),divergence:this.vectors[r[1]][3],dataCoordinate:n}},b.dispose=function(){this.texture.dispose(),this.triShader.dispose(),this.pickShader.dispose(),this.triangleVAO.dispose(),this.trianglePositions.dispose(),this.triangleVectors.dispose(),this.triangleColors.dispose(),this.triangleUVs.dispose(),this.triangleNormals.dispose(),this.triangleIds.dispose(),this.edgeVAO.dispose(),this.edgePositions.dispose(),this.edgeColors.dispose(),this.edgeUVs.dispose(),this.edgeIds.dispose(),this.pointVAO.dispose(),this.pointPositions.dispose(),this.pointColors.dispose(),this.pointUVs.dispose(),this.pointSizes.dispose(),this.pointIds.dispose(),this.contourVAO.dispose(),this.contourPositions.dispose()},e.exports=function(t,e){1===arguments.length&&(t=(e=t).gl);var r=e.triShader||function(t){var e=n(t,g.vertex,g.fragment,null,g.attributes);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.vector.location=5,e}(t),s=x(t),l=o(t,c(new Uint8Array([255,255,255,255]),[1,1,4]));l.generateMipmap(),l.minFilter=t.LINEAR_MIPMAP_LINEAR,l.magFilter=t.LINEAR;var u=i(t),f=i(t),h=i(t),d=i(t),p=i(t),v=i(t),m=a(t,[{buffer:u,type:t.FLOAT,size:4},{buffer:v,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:h,type:t.FLOAT,size:4},{buffer:d,type:t.FLOAT,size:2},{buffer:p,type:t.FLOAT,size:3},{buffer:f,type:t.FLOAT,size:4}]),b=i(t),_=i(t),w=i(t),M=i(t),A=a(t,[{buffer:b,type:t.FLOAT,size:3},{buffer:M,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:_,type:t.FLOAT,size:4},{buffer:w,type:t.FLOAT,size:2}]),T=i(t),k=i(t),E=i(t),S=i(t),L=i(t),C=a(t,[{buffer:T,type:t.FLOAT,size:3},{buffer:L,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:k,type:t.FLOAT,size:4},{buffer:E,type:t.FLOAT,size:2},{buffer:S,type:t.FLOAT,size:1}]),O=i(t),R=new y(t,l,r,null,null,s,null,null,u,f,v,h,d,p,m,b,M,_,w,A,T,L,k,E,S,C,O,a(t,[{buffer:O,type:t.FLOAT,size:3}]));return R.update(e),R}},{"./closest-point":157,"./shaders":158,colormap:69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-shader":148,"gl-texture2d":163,"gl-vao":167,ndarray:285,normals:287,"simplicial-complex-contour":329,"typedarray-pool":348}],160:[function(t,e,r){"use strict";var n=t("gl-vec3"),i=t("gl-vec4"),a=function(t,e,r,a){for(var o=0,s=0;so&&(o=c)}var f=t.map(function(t){return function(t,e,r,a){var o,s,l,u=t.points,c=t.velocities,f=t.divergences;n.set(n.create(),0,1,0),n.create(),n.create();n.create();for(var h=[],d=[],p=[],g=[],v=[],m=[],y=0,b=0,x=i.create(),_=i.create(),w=0;w0)for(M=0;M<8;M++){var A=(M+1)%8;h.push(g[M],v[M],v[A],v[A],g[A],g[M]),p.push(_,x,x,x,_,_),m.push(y,b,b,b,y,y),d.push([h.length-6,h.length-5,h.length-4],[h.length-3,h.length-2,h.length-1])}var T=g;g=v,v=T,T=_,_=x,x=T,T=y,y=b,b=T}return{positions:h,cells:d,vectors:p,vertexIntensity:m}}(t,r,a,o)}),h=[],d=[],p=[],g=[];for(s=0;se)return r-1}return r},u=n.create(),c=n.create(),f=function(t,e,r){return tr?r:t},h=function(t,e,r,i){var a=t[0],o=t[1],s=t[2],h=r[0].length,d=r[1].length,p=r[2].length,g=l(r[0],a),v=l(r[1],o),m=l(r[2],s),y=g+1,b=v+1,x=m+1;if(r[0][g]===a&&(y=g),r[1][v]===o&&(b=v),r[2][m]===s&&(x=m),i&&(g=f(g,0,h-1),y=f(y,0,h-1),v=f(v,0,d-1),b=f(b,0,d-1),m=f(m,0,p-1),x=f(x,0,p-1)),g<0||v<0||m<0||y>=h||b>=d||x>=p)return n.create();var _=(a-r[0][g])/(r[0][y]-r[0][g]),w=(o-r[1][v])/(r[1][b]-r[1][v]),M=(s-r[2][m])/(r[2][x]-r[2][m]);(_<0||_>1||isNaN(_))&&(_=0),(w<0||w>1||isNaN(w))&&(w=0),(M<0||M>1||isNaN(M))&&(M=0);var A=m*h*d,T=x*h*d,k=v*h,E=b*h,S=g,L=y,C=e[k+A+S],O=e[k+A+L],R=e[E+A+S],P=e[E+A+L],z=e[k+T+S],I=e[k+T+L],N=e[E+T+S],D=e[E+T+L],F=n.create();return n.lerp(F,C,O,_),n.lerp(u,R,P,_),n.lerp(F,F,u,w),n.lerp(u,z,I,_),n.lerp(c,N,D,_),n.lerp(u,u,c,w),n.lerp(F,F,u,M),F},d=function(t){var e=1/0;t.sort(function(t,e){return t-e});for(var r=1;r=f&&r<=g&&n>=h&&n<=v&&i>=p&&i<=m},b=10*n.distance(e[0],e[1])/i,x=b*b,_=1,w=0;n.create();r.length>=2&&(_=function(t){for(var e=[],r=[],n=[],i={},a={},o={},s=0;sw&&!isNaN(z)&&isFinite(z)&&(w=z),L.push(z),c.push({points:T,velocities:k,divergences:L});for(var O=0;O<100*i&&T.lengthx&&n.scale(R,R,b/Math.sqrt(P)),n.add(R,R,A),E=t.getVelocity(R),n.squaredDistance(S,R)-x>-1e-4*x){T.push(R),S=R,k.push(E);C=t.getDivergence(R,E);(z=n.length(C))>w&&!isNaN(z)&&isFinite(z)&&(w=z),L.push(z)}A=R}}for(M=0;M max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color \u2014 in vertex or in fragment\n vec4 surfaceColor = step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) + step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]),s=i(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]),l=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]);r.createShader=function(t){var e=n(t,a,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,a,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,s,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,s,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":148,glslify:249}],162:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=y(e),n=x(e),s=b(e),l=_(e),u=i(e),c=a(e,[{buffer:u,size:4,stride:w,offset:0},{buffer:u,size:3,stride:w,offset:16},{buffer:u,size:3,stride:w,offset:28}]),f=i(e),h=a(e,[{buffer:f,size:4,stride:20,offset:0},{buffer:f,size:1,stride:20,offset:16}]),d=i(e),p=a(e,[{buffer:d,size:2,type:e.FLOAT}]),g=o(e,1,E,e.RGBA,e.UNSIGNED_BYTE);g.minFilter=e.LINEAR,g.magFilter=e.LINEAR;var v=new S(e,[0,0],[[0,0,0],[0,0,0]],r,n,u,c,g,s,l,f,h,d,p),m={levels:[[],[],[]]};for(var M in t)m[M]=t[M];return m.colormap=m.colormap||"jet",v.update(m),v};var n=t("bit-twiddle"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("typedarray-pool"),l=t("colormap"),u=t("ndarray-ops"),c=t("ndarray-pack"),f=t("ndarray"),h=t("surface-nets"),d=t("gl-mat4/multiply"),p=t("gl-mat4/invert"),g=t("binary-search-bounds"),v=t("ndarray-gradient"),m=t("./lib/shaders"),y=m.createShader,b=m.createContourShader,x=m.createPickShader,_=m.createPickContourShader,w=40,M=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],A=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],T=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];function k(t,e,r,n,i){this.position=t,this.index=e,this.uv=r,this.level=n,this.dataCoordinate=i}!function(){for(var t=0;t<3;++t){var e=T[t],r=(t+2)%3;e[(t+1)%3+0]=1,e[r+3]=1,e[t+6]=1}}();var E=256;function S(t,e,r,n,i,a,o,l,u,c,h,d,p,g){this.gl=t,this.shape=e,this.bounds=r,this.intensityBounds=[],this._shader=n,this._pickShader=i,this._coordinateBuffer=a,this._vao=o,this._colorMap=l,this._contourShader=u,this._contourPickShader=c,this._contourBuffer=h,this._contourVAO=d,this._contourOffsets=[[],[],[]],this._contourCounts=[[],[],[]],this._vertexCount=0,this._pickResult=new k([0,0,0],[0,0],[0,0],[0,0,0],[0,0,0]),this._dynamicBuffer=p,this._dynamicVAO=g,this._dynamicOffsets=[0,0,0],this._dynamicCounts=[0,0,0],this.contourWidth=[1,1,1],this.contourLevels=[[1],[1],[1]],this.contourTint=[0,0,0],this.contourColor=[[.5,.5,.5,1],[.5,.5,.5,1],[.5,.5,.5,1]],this.showContour=!0,this.showSurface=!0,this.enableHighlight=[!0,!0,!0],this.highlightColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.highlightTint=[1,1,1],this.highlightLevel=[-1,-1,-1],this.enableDynamic=[!0,!0,!0],this.dynamicLevel=[NaN,NaN,NaN],this.dynamicColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.dynamicTint=[1,1,1],this.dynamicWidth=[1,1,1],this.axesBounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.surfaceProject=[!1,!1,!1],this.contourProject=[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],this.colorBounds=[!1,!1],this._field=[f(s.mallocFloat(1024),[0,0]),f(s.mallocFloat(1024),[0,0]),f(s.mallocFloat(1024),[0,0])],this.pickId=1,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.snapToData=!1,this.opacity=1,this.lightPosition=[10,1e4,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.vertexColor=0,this.dirty=!0}var L=S.prototype;L.isTransparent=function(){return this.opacity<1},L.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;t<3;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},L.pickSlots=1,L.setPickBase=function(t){this.pickId=t};var C=[0,0,0],O={showSurface:!1,showContour:!1,projections:[M.slice(),M.slice(),M.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]};function R(t,e){var r,n,i,a=e.axes&&e.axes.lastCubeProps.axis||C,o=e.showSurface,s=e.showContour;for(r=0;r<3;++r)for(o=o||e.surfaceProject[r],n=0;n<3;++n)s=s||e.contourProject[r][n];for(r=0;r<3;++r){var l=O.projections[r];for(n=0;n<16;++n)l[n]=0;for(n=0;n<4;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],d(l,t.model,l);var u=O.clipBounds[r];for(i=0;i<2;++i)for(n=0;n<3;++n)u[i][n]=t.clipBounds[i][n];u[0][r]=-1e8,u[1][r]=1e8}return O.showSurface=o,O.showContour=s,O}var P={model:M,view:M,projection:M,inverseModel:M.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1,vertexColor:0},z=M.slice(),I=[1,0,0,0,1,0,0,0,1];function N(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=P;n.model=t.model||M,n.view=t.view||M,n.projection=t.projection||M,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.contourColor=this.contourColor[0],n.inverseModel=p(n.inverseModel,n.model);for(var i=0;i<2;++i)for(var a=n.clipBounds[i],o=0;o<3;++o)a[o]=Math.min(Math.max(this.clipBounds[i][o],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=I,n.vertexColor=this.vertexColor;var s=z;for(d(s,n.view,n.model),d(s,n.projection,s),p(s,s),i=0;i<3;++i)n.eyePosition[i]=s[12+i]/s[15];var l=s[15];for(i=0;i<3;++i)l+=this.lightPosition[i]*s[4*i+3];for(i=0;i<3;++i){var u=s[12+i];for(o=0;o<3;++o)u+=s[4*o+i]*this.lightPosition[o];n.lightPosition[i]=u/l}var c=R(n,this);if(c.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;i<3;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=c.projections[i],this._shader.uniforms.clipBounds=c.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(c.showContour&&!e){var f=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,f.bind(),f.uniforms=n;var h=this._contourVAO;for(h.bind(),i=0;i<3;++i)for(f.uniforms.permutation=T[i],r.lineWidth(this.contourWidth[i]),o=0;o>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var u=r.position;u[0]=u[1]=u[2]=0;for(var c=0;c<2;++c)for(var f=c?a:1-a,h=0;h<2;++h)for(var d=i+c,p=s+h,v=f*(h?l:1-l),m=0;m<3;++m)u[m]+=this._field[m].get(d,p)*v;for(var y=this._pickResult.level,b=0;b<3;++b)if(y[b]=g.le(this.contourLevels[b],u[b]),y[b]<0)this.contourLevels[b].length>0&&(y[b]=0);else if(y[b]Math.abs(_-u[b])&&(y[b]+=1)}for(r.index[0]=a<.5?i:i+1,r.index[1]=l<.5?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;m<3;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},L.update=function(t){t=t||{},this.dirty=!0,"contourWidth"in t&&(this.contourWidth=j(t.contourWidth,Number)),"showContour"in t&&(this.showContour=j(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=j(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=U(t.contourColor)),"contourProject"in t&&(this.contourProject=j(t.contourProject,function(t){return j(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=U(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=j(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=j(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds),"vertexColor"in t&&(this.vertexColor=t.vertexColor?1:0);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var i=(e.shape[0]+2)*(e.shape[1]+2);i>this._field[2].data.length&&(s.freeFloat(this._field[2].data),this._field[2].data=s.mallocFloat(n.nextPow2(i))),this._field[2]=f(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),F(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;o<2;++o)this._field[2].size>this._field[o].data.length&&(s.freeFloat(this._field[o].data),this._field[o].data=s.mallocFloat(this._field[2].size)),this._field[o]=f(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var d=t.coords;if(!Array.isArray(d)||3!==d.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;o<2;++o){var p=d[o];for(x=0;x<2;++x)if(p.shape[x]!==a[x])throw new Error("gl-surface: coords have incorrect shape");F(this._field[o],p)}}else if(t.ticks){var g=t.ticks;if(!Array.isArray(g)||2!==g.length)throw new Error("gl-surface: invalid ticks");for(o=0;o<2;++o){var m=g[o];if((Array.isArray(m)||m.length)&&(m=f(m)),m.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var y=f(m.data,a);y.stride[o]=m.stride[0],y.stride[1^o]=0,F(this._field[o],y)}}else{for(o=0;o<2;++o){var b=[0,0];b[o]=1,this._field[o]=f(this._field[o].data,[a[0]+2,a[1]+2],b,0)}this._field[0].set(0,0,0);for(var x=0;x0){for(var Mt=0;Mt<5;++Mt)nt.pop();W-=1}continue t}nt.push(st[0],st[1],ct[0],ct[1],st[2]),W+=1}}ot.push(W)}this._contourOffsets[it]=at,this._contourCounts[it]=ot}var At=s.mallocFloat(nt.length);for(o=0;os||o[1]<0||o[1]>s)throw new Error("gl-texture2d: Invalid texture size");var l=p(o,e.stride.slice()),u=0;"float32"===r?u=t.FLOAT:"float64"===r?(u=t.FLOAT,l=!1,r="float32"):"uint8"===r?u=t.UNSIGNED_BYTE:(u=t.UNSIGNED_BYTE,l=!1,r="uint8");var f,d,v=0;if(2===o.length)v=t.LUMINANCE,o=[o[0],o[1],1],e=n(e.data,o,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==o.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===o[2])v=t.ALPHA;else if(2===o[2])v=t.LUMINANCE_ALPHA;else if(3===o[2])v=t.RGB;else{if(4!==o[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}}u!==t.FLOAT||t.getExtension("OES_texture_float")||(u=t.UNSIGNED_BYTE,l=!1);var m=e.size;if(l)f=0===e.offset&&e.data.length===m?e.data:e.data.subarray(e.offset,e.offset+m);else{var y=[o[2],o[2]*o[0],1];d=a.malloc(m,r);var b=n(d,o,y,0);"float32"!==r&&"float64"!==r||u!==t.UNSIGNED_BYTE?i.assign(b,e):c(b,e),f=d.subarray(0,m)}var x=g(t);t.texImage2D(t.TEXTURE_2D,0,v,o[0],o[1],0,v,u,f),l||a.free(d);return new h(t,x,o[0],o[1],v,u)}(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")};var o=null,s=null,l=null;function u(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement||"undefined"!=typeof ImageData&&t instanceof ImageData}var c=function(t,e){i.muls(t,e,255)};function f(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(e<0||e>i||r<0||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function h(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}var d=h.prototype;function p(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function g(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function v(t,e,r,n,i){var a=t.getParameter(t.MAX_TEXTURE_SIZE);if(e<0||e>a||r<0||r>a)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new h(t,o,e,r,n,i)}Object.defineProperties(d,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=this.gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;e<2;++e)if(l.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return f(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return f(this,t|=0,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t|=0,f(this,this._shape[0],t),t}}}),d.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},d.dispose=function(){this.gl.deleteTexture(this.handle)},d.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},d.setPixels=function(t,e,r,o){var s=this.gl;this.bind(),Array.isArray(e)?(o=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),o=o||0;var l=u(t)?t:t.raw;if(l){this._mipLevels.indexOf(o)<0?(s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,this.type,l),this._mipLevels.push(o)):s.texSubImage2D(s.TEXTURE_2D,o,e,r,this.format,this.type,l)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>o||r+t.shape[0]>this._shape[0]>>>o||e<0||r<0)throw new Error("gl-texture2d: Texture dimensions are out of bounds");!function(t,e,r,o,s,l,u,f){var h=f.dtype,d=f.shape.slice();if(d.length<2||d.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var g=0,v=0,m=p(d,f.stride.slice());"float32"===h?g=t.FLOAT:"float64"===h?(g=t.FLOAT,m=!1,h="float32"):"uint8"===h?g=t.UNSIGNED_BYTE:(g=t.UNSIGNED_BYTE,m=!1,h="uint8");if(2===d.length)v=t.LUMINANCE,d=[d[0],d[1],1],f=n(f.data,d,[f.stride[0],f.stride[1],1],f.offset);else{if(3!==d.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===d[2])v=t.ALPHA;else if(2===d[2])v=t.LUMINANCE_ALPHA;else if(3===d[2])v=t.RGB;else{if(4!==d[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}d[2]}v!==t.LUMINANCE&&v!==t.ALPHA||s!==t.LUMINANCE&&s!==t.ALPHA||(v=s);if(v!==s)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=f.size,b=u.indexOf(o)<0;b&&u.push(o);if(g===l&&m)0===f.offset&&f.data.length===y?b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,f.data):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,f.data):b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,f.data.subarray(f.offset,f.offset+y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,f.data.subarray(f.offset,f.offset+y));else{var x;x=l===t.FLOAT?a.mallocFloat32(y):a.mallocUint8(y);var _=n(x,d,[d[2],d[2]*d[0],1]);g===t.FLOAT&&l===t.UNSIGNED_BYTE?c(_,f):i.assign(_,f),b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,x.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,x.subarray(0,y)),l===t.FLOAT?a.freeFloat32(x):a.freeUint8(x)}}(s,e,r,o,this.format,this.type,this._mipLevels,t)}}},{ndarray:285,"ndarray-ops":279,"typedarray-pool":348}],164:[function(t,e,r){"use strict";e.exports=function(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;i1?0:Math.acos(s)};var n=t("./fromValues"),i=t("./normalize"),a=t("./dot")},{"./dot":179,"./fromValues":185,"./normalize":196}],170:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}},{}],171:[function(t,e,r){e.exports=function(t){var e=new Float32Array(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}},{}],172:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}},{}],173:[function(t,e,r){e.exports=function(){var t=new Float32Array(3);return t[0]=0,t[1]=0,t[2]=0,t}},{}],174:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}},{}],175:[function(t,e,r){e.exports=t("./distance")},{"./distance":176}],176:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}},{}],177:[function(t,e,r){e.exports=t("./divide")},{"./divide":178}],178:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}},{}],179:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}},{}],180:[function(t,e,r){e.exports=1e-6},{}],181:[function(t,e,r){e.exports=function(t,e){var r=t[0],i=t[1],a=t[2],o=e[0],s=e[1],l=e[2];return Math.abs(r-o)<=n*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-l)<=n*Math.max(1,Math.abs(a),Math.abs(l))};var n=t("./epsilon")},{"./epsilon":180}],182:[function(t,e,r){e.exports=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}},{}],183:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}},{}],184:[function(t,e,r){e.exports=function(t,e,r,i,a,o){var s,l;e||(e=3);r||(r=0);l=i?Math.min(i*e+r,t.length):t.length;for(s=r;s0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a);return t}},{}],197:[function(t,e,r){e.exports=function(t,e){e=e||1;var r=2*Math.random()*Math.PI,n=2*Math.random()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t}},{}],198:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[1],a=r[2],o=e[1]-i,s=e[2]-a,l=Math.sin(n),u=Math.cos(n);return t[0]=e[0],t[1]=i+o*u-s*l,t[2]=a+o*l+s*u,t}},{}],199:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[2],o=e[0]-i,s=e[2]-a,l=Math.sin(n),u=Math.cos(n);return t[0]=i+s*l+o*u,t[1]=e[1],t[2]=a+s*u-o*l,t}},{}],200:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[1],o=e[0]-i,s=e[1]-a,l=Math.sin(n),u=Math.cos(n);return t[0]=i+o*u-s*l,t[1]=a+o*l+s*u,t[2]=e[2],t}},{}],201:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}},{}],202:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}},{}],203:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}},{}],204:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}},{}],205:[function(t,e,r){e.exports=t("./squaredDistance")},{"./squaredDistance":207}],206:[function(t,e,r){e.exports=t("./squaredLength")},{"./squaredLength":208}],207:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}},{}],208:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}},{}],209:[function(t,e,r){e.exports=t("./subtract")},{"./subtract":210}],210:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}},{}],211:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}},{}],212:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t}},{}],213:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],u=r[3],c=u*n+s*a-l*i,f=u*i+l*n-o*a,h=u*a+o*i-s*n,d=-o*n-s*i-l*a;return t[0]=c*u+d*-o+f*-l-h*-s,t[1]=f*u+d*-s+h*-o-c*-l,t[2]=h*u+d*-l+c*-s-f*-o,t}},{}],214:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}},{}],215:[function(t,e,r){e.exports=function(t){var e=new Float32Array(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}},{}],216:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}},{}],217:[function(t,e,r){e.exports=function(){var t=new Float32Array(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}},{}],218:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+a*a)}},{}],219:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}},{}],220:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}},{}],221:[function(t,e,r){e.exports=function(t,e,r,n){var i=new Float32Array(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i}},{}],222:[function(t,e,r){e.exports={create:t("./create"),clone:t("./clone"),fromValues:t("./fromValues"),copy:t("./copy"),set:t("./set"),add:t("./add"),subtract:t("./subtract"),multiply:t("./multiply"),divide:t("./divide"),min:t("./min"),max:t("./max"),scale:t("./scale"),scaleAndAdd:t("./scaleAndAdd"),distance:t("./distance"),squaredDistance:t("./squaredDistance"),length:t("./length"),squaredLength:t("./squaredLength"),negate:t("./negate"),inverse:t("./inverse"),normalize:t("./normalize"),dot:t("./dot"),lerp:t("./lerp"),random:t("./random"),transformMat4:t("./transformMat4"),transformQuat:t("./transformQuat")}},{"./add":214,"./clone":215,"./copy":216,"./create":217,"./distance":218,"./divide":219,"./dot":220,"./fromValues":221,"./inverse":223,"./length":224,"./lerp":225,"./max":226,"./min":227,"./multiply":228,"./negate":229,"./normalize":230,"./random":231,"./scale":232,"./scaleAndAdd":233,"./set":234,"./squaredDistance":235,"./squaredLength":236,"./subtract":237,"./transformMat4":238,"./transformQuat":239}],223:[function(t,e,r){e.exports=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}},{}],224:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}},{}],225:[function(t,e,r){e.exports=function(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t[3]=s+n*(r[3]-s),t}},{}],226:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}},{}],227:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}},{}],228:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}},{}],229:[function(t,e,r){e.exports=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}},{}],230:[function(t,e,r){e.exports=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=a*o);return t}},{}],231:[function(t,e,r){var n=t("./normalize"),i=t("./scale");e.exports=function(t,e){return e=e||1,t[0]=Math.random(),t[1]=Math.random(),t[2]=Math.random(),t[3]=Math.random(),n(t,t),i(t,t,e),t}},{"./normalize":230,"./scale":232}],232:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}},{}],233:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}},{}],234:[function(t,e,r){e.exports=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}},{}],235:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a}},{}],236:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}},{}],237:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}},{}],238:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}},{}],239:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],u=r[3],c=u*n+s*a-l*i,f=u*i+l*n-o*a,h=u*a+o*i-s*n,d=-o*n-s*i-l*a;return t[0]=c*u+d*-o+f*-l-h*-s,t[1]=f*u+d*-s+h*-o-c*-l,t[2]=h*u+d*-l+c*-s-f*-o,t[3]=e[3],t}},{}],240:[function(t,e,r){e.exports=function(t,e,r,a){return n[0]=a,n[1]=r,n[2]=e,n[3]=t,i[0]};var n=new Uint8Array(4),i=new Float32Array(n.buffer)},{}],241:[function(t,e,r){var n=t("glsl-tokenizer"),i=t("atob-lite");e.exports=function(t){for(var e=Array.isArray(t)?t:n(t),r=0;r0)continue;r=t.slice(0,1).join("")}return D(r),O+=r.length,(E=E.slice(r.length)).length}}function q(){return/[^a-fA-F0-9]/.test(e)?(D(E.join("")),k=l,A):(E.push(e),r=e,A+1)}function G(){return"."===e?(E.push(e),k=g,r=e,A+1):/[eE]/.test(e)?(E.push(e),k=g,r=e,A+1):"x"===e&&1===E.length&&"0"===E[0]?(k=_,E.push(e),r=e,A+1):/[^\d]/.test(e)?(D(E.join("")),k=l,A):(E.push(e),r=e,A+1)}function W(){return"f"===e&&(E.push(e),r=e,A+=1),/[eE]/.test(e)?(E.push(e),r=e,A+1):"-"===e&&/[eE]/.test(r)?(E.push(e),r=e,A+1):/[^\d]/.test(e)?(D(E.join("")),k=l,A):(E.push(e),r=e,A+1)}function X(){if(/[^\d\w_]/.test(e)){var t=E.join("");return k=N.indexOf(t)>-1?y:I.indexOf(t)>-1?m:v,D(E.join("")),k=l,A}return E.push(e),r=e,A+1}};var n=t("./lib/literals"),i=t("./lib/operators"),a=t("./lib/builtins"),o=t("./lib/literals-300es"),s=t("./lib/builtins-300es"),l=999,u=9999,c=0,f=1,h=2,d=3,p=4,g=5,v=6,m=7,y=8,b=9,x=10,_=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":244,"./lib/builtins-300es":243,"./lib/literals":246,"./lib/literals-300es":245,"./lib/operators":247}],243:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":244}],244:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],245:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":246}],246:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],247:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],248:[function(t,e,r){var n=t("./index");e.exports=function(t,e){var r=n(e),i=[];return i=(i=i.concat(r(t))).concat(r(null))}},{"./index":242}],249:[function(t,e,r){e.exports=function(t){"string"==typeof t&&(t=[t]);for(var e=[].slice.call(arguments,1),r=[],n=0;n>1,c=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+t[e+f],f+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=n;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),a-=u}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,u=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*g}},{}],253:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(r<=i)throw new Error("Must input at least d+1 points");var o=t.slice(0,i+1),s=n.apply(void 0,o);if(0===s)throw new Error("Input not in general position");for(var l=new Array(i+1),c=0;c<=i;++c)l[c]=c;s<0&&(l[0]=1,l[1]=0);for(var f=new a(l,new Array(i+1),!1),h=f.adjacent,d=new Array(i+2),c=0;c<=i;++c){for(var p=l.slice(),g=0;g<=i;++g)g===c&&(p[g]=-1);var v=p[0];p[0]=p[1],p[1]=v;var m=new a(p,new Array(i+1),!0);h[c]=m,d[c]=m}d[i+1]=f;for(var c=0;c<=i;++c)for(var p=h[c].vertices,y=h[c].adjacent,g=0;g<=i;++g){var b=p[g];if(b<0)y[g]=f;else for(var x=0;x<=i;++x)h[x].vertices.indexOf(b)<0&&(y[g]=h[x])}for(var _=new u(i,o,d),w=!!e,c=i+1;c0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var i=new Function("test",e.join("")),a=n[t+1];return a||(a=n),i(a)}(t)),this.orient=a}var c=u.prototype;c.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){(t=o.pop()).vertices;for(var s=t.adjacent,l=0;l<=r;++l){var u=s[l];if(u.boundary&&!(u.lastVisited<=-n)){for(var c=u.vertices,f=0;f<=r;++f){var h=c[f];i[f]=h<0?e:a[h]}var d=this.orient();if(d>0)return u;u.lastVisited=-n,0===d&&o.push(u)}}}return null},c.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,u=s.adjacent,c=0;c<=n;++c)a[c]=i[l[c]];s.lastVisited=r;for(c=0;c<=n;++c){var f=u[c];if(!(f.lastVisited>=r)){var h=a[c];a[c]=t;var d=this.orient();if(a[c]=h,d<0){s=f;continue t}f.boundary?f.lastVisited=-r:f.lastVisited=r}}return}return s},c.addPeaks=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,l=this.tuple,u=this.interior,c=this.simplices,f=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,u.push(e);for(var h=[];f.length>0;){var d=(e=f.pop()).vertices,p=e.adjacent,g=d.indexOf(r);if(!(g<0))for(var v=0;v<=n;++v)if(v!==g){var m=p[v];if(m.boundary&&!(m.lastVisited>=r)){var y=m.vertices;if(m.lastVisited!==-r){for(var b=0,x=0;x<=n;++x)y[x]<0?(b=x,l[x]=t):l[x]=i[y[x]];if(this.orient()>0){y[b]=r,m.boundary=!1,u.push(m),f.push(m),m.lastVisited=r;continue}m.lastVisited=-r}var _=m.adjacent,w=d.slice(),M=p.slice(),A=new a(w,M,!0);c.push(A);var T=_.indexOf(e);if(!(T<0)){_[T]=A,M[g]=m,w[v]=-1,M[v]=e,p[v]=A,A.flip();for(x=0;x<=n;++x){var k=w[x];if(!(k<0||k===r)){for(var E=new Array(n-1),S=0,L=0;L<=n;++L){var C=w[L];C<0||L===x||(E[S++]=C)}h.push(new o(E,A,x))}}}}}}h.sort(s);for(v=0;v+1=0?o[l++]=s[c]:u=1&c;if(u===(1&t)){var f=o[0];o[0]=o[1],o[1]=f}e.push(o)}}return e}},{"robust-orientation":321,"simplicial-complex":331}],254:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=0,a=1;function o(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}e.exports=function(t){if(!t||0===t.length)return new b(null);return new b(y(t))};var s=o.prototype;function l(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function u(t,e){var r=y(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function c(t,e){var r=t.intervals([]);r.push(e),u(t,r)}function f(t,e){var r=t.intervals([]),n=r.indexOf(e);return n<0?i:(r.splice(n,1),u(t,r),a)}function h(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function p(t,e){for(var r=0;r>1],i=[],a=[],s=[];for(r=0;r3*(e+1)?c(this,t):this.left.insert(t):this.left=y([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?c(this,t):this.right.insert(t):this.right=y([t]);else{var r=n.ge(this.leftPoints,t,v),i=n.ge(this.rightPoints,t,m);this.leftPoints.splice(r,0,t),this.rightPoints.splice(i,0,t)}},s.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1)?f(this,t):2===(u=this.left.remove(t))?(this.left=null,this.count-=1,a):(u===a&&(this.count-=1),u):i;if(t[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(e-1)?f(this,t):2===(u=this.right.remove(t))?(this.right=null,this.count-=1,a):(u===a&&(this.count-=1),u):i;if(1===this.count)return this.leftPoints[0]===t?2:i;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var r=this,o=this.left;o.right;)r=o,o=o.right;if(r===this)o.right=this.right;else{var s=this.left,u=this.right;r.count-=o.count,r.right=o.left,o.left=s,o.right=u}l(this,o),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?l(this,this.left):l(this,this.right);return a}for(s=n.ge(this.leftPoints,t,v);sthis.mid){var r;if(this.right)if(r=this.right.queryPoint(t,e))return r;return d(this.rightPoints,t,e)}return p(this.leftPoints,e)},s.queryInterval=function(t,e,r){var n;if(tthis.mid&&this.right&&(n=this.right.queryInterval(t,e,r)))return n;return ethis.mid?d(this.rightPoints,t,r):p(this.leftPoints,r)};var x=b.prototype;x.insert=function(t){this.root?this.root.insert(t):this.root=new o(t[0],null,null,[t],[t])},x.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),e!==i}return!1},x.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},x.queryInterval=function(t,e,r){if(t<=e&&this.root)return this.root.queryInterval(t,e,r)},Object.defineProperty(x,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(x,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":36}],255:[function(t,e,r){"use strict";e.exports=function(t,e){e=e||new Array(t.length);for(var r=0;r13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],262:[function(t,e,r){e.exports=function(t,e,r){return t*(1-r)+e*r}},{}],263:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1<d[1][2]&&(m[0]=-m[0]),d[0][2]>d[2][0]&&(m[1]=-m[1]),d[1][0]>d[0][1]&&(m[2]=-m[2]),!0}},{"./normalize":265,"gl-mat4/clone":119,"gl-mat4/create":120,"gl-mat4/determinant":121,"gl-mat4/invert":125,"gl-mat4/transpose":135,"gl-vec3/cross":174,"gl-vec3/dot":179,"gl-vec3/length":189,"gl-vec3/normalize":196}],265:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;i<16;i++)t[i]=e[i]*n;return!0}},{}],266:[function(t,e,r){var n=t("gl-vec3/lerp"),i=t("mat4-recompose"),a=t("mat4-decompose"),o=t("gl-mat4/determinant"),s=t("quat-slerp"),l=f(),u=f(),c=f();function f(){return{translate:h(),scale:h(1),skew:h(),perspective:[0,0,0,1],quaternion:[0,0,0,1]}}function h(t){return[t||0,t||0,t||0]}e.exports=function(t,e,r,f){if(0===o(e)||0===o(r))return!1;var h=a(e,l.translate,l.scale,l.skew,l.perspective,l.quaternion),d=a(r,u.translate,u.scale,u.skew,u.perspective,u.quaternion);return!(!h||!d||(n(c.translate,l.translate,u.translate,f),n(c.skew,l.skew,u.skew,f),n(c.scale,l.scale,u.scale,f),n(c.perspective,l.perspective,u.perspective,f),s(c.quaternion,l.quaternion,u.quaternion,f),i(t,c.translate,c.scale,c.skew,c.perspective,c.quaternion),0))}},{"gl-mat4/determinant":121,"gl-vec3/lerp":190,"mat4-decompose":264,"mat4-recompose":267,"quat-slerp":308}],267:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":120,"gl-mat4/fromRotationTranslation":123,"gl-mat4/identity":124,"gl-mat4/multiply":127,"gl-mat4/scale":133,"gl-mat4/translate":134}],268:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=t("mat4-interpolate"),a=t("gl-mat4/invert"),o=t("gl-mat4/rotateX"),s=t("gl-mat4/rotateY"),l=t("gl-mat4/rotateZ"),u=t("gl-mat4/lookAt"),c=t("gl-mat4/translate"),f=(t("gl-mat4/scale"),t("gl-vec3/normalize")),h=[0,0,0];function d(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-1/0,1/0]}e.exports=function(t){return new d((t=t||{}).matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])};var p=d.prototype;p.recalcMatrix=function(t){var e=this._time,r=n.le(e,t),o=this.computedMatrix;if(!(r<0)){var s=this._components;if(r===e.length-1)for(var l=16*r,u=0;u<16;++u)o[u]=s[l++];else{var c=e[r+1]-e[r],h=(l=16*r,this.prevMatrix),d=!0;for(u=0;u<16;++u)h[u]=s[l++];var p=this.nextMatrix;for(u=0;u<16;++u)p[u]=s[l++],d=d&&h[u]===p[u];if(c<1e-6||d)for(u=0;u<16;++u)o[u]=h[u];else i(o,h,p,(t-e[r])/c)}var g=this.computedUp;g[0]=o[1],g[1]=o[5],g[2]=o[9],f(g,g);var v=this.computedInverse;a(v,o);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;var b=this.computedCenter,x=Math.exp(this.computedRadius[0]);for(u=0;u<3;++u)b[u]=m[u]-o[2+4*u]*x}},p.idle=function(t){if(!(t1&&n(t[o[c-2]],t[o[c-1]],u)<=0;)c-=1,o.pop();for(o.push(l),c=s.length;c>1&&n(t[s[c-2]],t[s[c-1]],u)>=0;)c-=1,s.pop();s.push(l)}for(var r=new Array(s.length+o.length-2),f=0,i=0,h=o.length;i0;--d)r[f++]=s[d];return r};var n=t("robust-orientation")[3]},{"robust-orientation":321}],270:[function(t,e,r){"use strict";e.exports=function(t,e){e||(e=t,t=window);var r=0,i=0,a=0,o={shift:!1,alt:!1,control:!1,meta:!1},s=!1;function l(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==o.alt,o.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==o.shift,o.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==o.control,o.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==o.meta,o.meta=!!t.metaKey),e}function u(t,s){var u=n.x(s),c=n.y(s);"buttons"in s&&(t=0|s.buttons),(t!==r||u!==i||c!==a||l(s))&&(r=0|t,i=u||0,a=c||0,e&&e(r,i,a,o))}function c(t){u(0,t)}function f(){(r||i||a||o.shift||o.alt||o.meta||o.control)&&(i=a=0,r=0,o.shift=o.alt=o.control=o.meta=!1,e&&e(0,0,0,o))}function h(t){l(t)&&e&&e(r,i,a,o)}function d(t){0===n.buttons(t)?u(0,t):u(r,t)}function p(t){u(r|n.buttons(t),t)}function g(t){u(r&~n.buttons(t),t)}function v(){s||(s=!0,t.addEventListener("mousemove",d),t.addEventListener("mousedown",p),t.addEventListener("mouseup",g),t.addEventListener("mouseleave",c),t.addEventListener("mouseenter",c),t.addEventListener("mouseout",c),t.addEventListener("mouseover",c),t.addEventListener("blur",f),t.addEventListener("keyup",h),t.addEventListener("keydown",h),t.addEventListener("keypress",h),t!==window&&(window.addEventListener("blur",f),window.addEventListener("keyup",h),window.addEventListener("keydown",h),window.addEventListener("keypress",h)))}v();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return s},set:function(e){e?v():s&&(s=!1,t.removeEventListener("mousemove",d),t.removeEventListener("mousedown",p),t.removeEventListener("mouseup",g),t.removeEventListener("mouseleave",c),t.removeEventListener("mouseenter",c),t.removeEventListener("mouseout",c),t.removeEventListener("mouseover",c),t.removeEventListener("blur",f),t.removeEventListener("keyup",h),t.removeEventListener("keydown",h),t.removeEventListener("keypress",h),t!==window&&(window.removeEventListener("blur",f),window.removeEventListener("keyup",h),window.removeEventListener("keydown",h),window.removeEventListener("keypress",h)))},enumerable:!0},buttons:{get:function(){return r},enumerable:!0},x:{get:function(){return i},enumerable:!0},y:{get:function(){return a},enumerable:!0},mods:{get:function(){return o},enumerable:!0}}),m};var n=t("mouse-event")},{"mouse-event":272}],271:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var i=t.clientX||0,a=t.clientY||0,o=(s=e,s===window||s===document||s===document.body?n:s.getBoundingClientRect());var s;return r[0]=i-o.left,r[1]=a-o.top,r}},{}],272:[function(t,e,r){"use strict";function n(t){return t.target||t.srcElement||window}r.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){if(2===(e=t.which))return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1< 0");"function"!=typeof t.vertex&&e("Must specify vertex creation function");"function"!=typeof t.cell&&e("Must specify cell creation function");"function"!=typeof t.phase&&e("Must specify phase function");for(var S=t.getters||[],L=new Array(k),C=0;C=0?L[C]=!0:L[C]=!1;return function(t,e,r,k,E,S){var L=S.length,C=E.length;if(C<2)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var O="extractContour"+E.join("_"),R=[],P=[],z=[],I=0;I0&&j.push(l(I,E[N-1])+"*"+s(E[N-1])),P.push(p(I,E[N])+"=("+j.join("-")+")|0")}for(var I=0;I=0;--I)B.push(s(E[I]));P.push(w+"=("+B.join("*")+")|0",x+"=mallocUint32("+w+")",b+"=mallocUint32("+w+")",M+"=0"),P.push(g(0)+"=0");for(var N=1;N<1<0;A=A-1&p)w.push(b+"["+M+"+"+m(A)+"]");w.push(y(0));for(var A=0;A=0;--e)G(e,0);for(var r=[],e=0;e0){",d(E[e]),"=1;");t(e-1,r|1<=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),a.push("1"),o.push("s["+l+"]-2"));var u=".lo("+a.join()+").hi("+o.join()+")";if(0===a.length&&(u=""),i>0){n.push("if(1");for(var l=0;l=0||e.indexOf(-(l+1))>=0||n.push("&&s[",l,"]>2");n.push("){grad",i,"(src.pick(",s.join(),")",u);for(var l=0;l=0||e.indexOf(-(l+1))>=0||n.push(",dst.pick(",s.join(),",",l,")",u);n.push(");")}for(var l=0;l1){dst.set(",s.join(),",",c,",0.5*(src.get(",h.join(),")-src.get(",d.join(),")))}else{dst.set(",s.join(),",",c,",0)};"):n.push("if(s[",c,"]>1){diff(",f,",src.pick(",h.join(),")",u,",src.pick(",d.join(),")",u,");}else{zero(",f,");};");break;case"mirror":0===i?n.push("dst.set(",s.join(),",",c,",0);"):n.push("zero(",f,");");break;case"wrap":var p=s.slice(),g=s.slice();e[l]<0?(p[c]="s["+c+"]-2",g[c]="0"):(p[c]="s["+c+"]-1",g[c]="1"),0===i?n.push("if(s[",c,"]>2){dst.set(",s.join(),",",c,",0.5*(src.get(",p.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",c,",0)};"):n.push("if(s[",c,"]>2){diff(",f,",src.pick(",p.join(),")",u,",src.pick(",g.join(),")",u,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}i>0&&n.push("};")}for(var s=0;s<1<>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in l){var e=l[t];r[t]=o({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var c=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=n({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=n({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=n({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=n({args:["array","array"],pre:i,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":78}],280:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var r=[],a=t,o=1;Array.isArray(a);)r.push(a.length),o*=a.length,a=a[0];return 0===r.length?n():(e||(e=n(new Float64Array(o),r)),i(e,t),e)}},{"./doConvert.js":281,ndarray:285}],281:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":78}],282:[function(t,e,r){"use strict";var n=t("typedarray-pool"),i=32;function a(t){switch(t){case"uint8":return[n.mallocUint8,n.freeUint8];case"uint16":return[n.mallocUint16,n.freeUint16];case"uint32":return[n.mallocUint32,n.freeUint32];case"int8":return[n.mallocInt8,n.freeInt8];case"int16":return[n.mallocInt16,n.freeInt16];case"int32":return[n.mallocInt32,n.freeInt32];case"float32":return[n.mallocFloat,n.freeFloat];case"float64":return[n.mallocDouble,n.freeDouble];default:return null}}function o(t){for(var e=[],r=0;r0?s.push(["d",p,"=s",p,"-d",f,"*n",f].join("")):s.push(["d",p,"=s",p].join("")),f=p),0!=(d=t.length-1-l)&&(h>0?s.push(["e",d,"=s",d,"-e",h,"*n",h,",f",d,"=",u[d],"-f",h,"*n",h].join("")):s.push(["e",d,"=s",d,",f",d,"=",u[d]].join("")),h=d)}r.push("var "+s.join(","));var g=["0","n0-1","data","offset"].concat(o(t.length));r.push(["if(n0<=",i,"){","insertionSort(",g.join(","),")}else{","quickSort(",g.join(","),")}"].join("")),r.push("}return "+n);var v=new Function("insertionSort","quickSort",r.join("\n")),m=function(t,e){var r=["'use strict'"],n=["ndarrayInsertionSort",t.join("d"),e].join(""),i=["left","right","data","offset"].concat(o(t.length)),s=a(e),l=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var u=[],c=1;c1){for(r.push("dptr=0;sptr=ptr"),c=t.length-1;c>=0;--c)0!==(d=t[c])&&r.push(["for(i",d,"=0;i",d,"b){break __l}"].join("")),c=t.length-1;c>=1;--c)r.push("sptr+=e"+c,"dptr+=f"+c,"}");for(r.push("dptr=cptr;sptr=cptr-s0"),c=t.length-1;c>=0;--c)0!==(d=t[c])&&r.push(["for(i",d,"=0;i",d,"=0;--c)0!==(d=t[c])&&r.push(["for(i",d,"=0;i",d,"scratch)){",h("cptr",f("cptr-s0")),"cptr-=s0","}",h("cptr","scratch"));return r.push("}"),t.length>1&&s&&r.push("free(scratch)"),r.push("} return "+n),s?new Function("malloc","free",r.join("\n"))(s[0],s[1]):new Function(r.join("\n"))()}(t,e),y=function(t,e,r){var n=["'use strict'"],s=["ndarrayQuickSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(o(t.length)),u=a(e),c=0;n.push(["function ",s,"(",l.join(","),"){"].join(""));var f=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var h=[],d=1;d=0;--a)0!==(o=t[a])&&n.push(["for(i",o,"=0;i",o,"1)for(a=0;a1?n.push("ptr_shift+=d"+o):n.push("ptr0+=d"+o),n.push("}"))}}function y(e,r,i,a){if(1===r.length)n.push("ptr0="+p(r[0]));else{for(var o=0;o1)for(o=0;o=1;--o)i&&n.push("pivot_ptr+=f"+o),r.length>1?n.push("ptr_shift+=e"+o):n.push("ptr0+=e"+o),n.push("}")}function b(){t.length>1&&u&&n.push("free(pivot1)","free(pivot2)")}function x(e,r){var i="el"+e,a="el"+r;if(t.length>1){var o="__l"+ ++c;y(o,[i,a],!1,["comp=",g("ptr0"),"-",g("ptr1"),"\n","if(comp>0){tmp0=",i,";",i,"=",a,";",a,"=tmp0;break ",o,"}\n","if(comp<0){break ",o,"}"].join(""))}else n.push(["if(",g(p(i)),">",g(p(a)),"){tmp0=",i,";",i,"=",a,";",a,"=tmp0}"].join(""))}function _(e,r){t.length>1?m([e,r],!1,v("ptr0",g("ptr1"))):n.push(v(p(e),g(p(r))))}function w(e,r,i){if(t.length>1){var a="__l"+ ++c;y(a,[r],!0,[e,"=",g("ptr0"),"-pivot",i,"[pivot_ptr]\n","if(",e,"!==0){break ",a,"}"].join(""))}else n.push([e,"=",g(p(r)),"-pivot",i].join(""))}function M(e,r){t.length>1?m([e,r],!1,["tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1","tmp")].join("")):n.push(["ptr0=",p(e),"\n","ptr1=",p(r),"\n","tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1","tmp")].join(""))}function A(e,r,i){t.length>1?(m([e,r,i],!1,["tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1",g("ptr2")),"\n",v("ptr2","tmp")].join("")),n.push("++"+r,"--"+i)):n.push(["ptr0=",p(e),"\n","ptr1=",p(r),"\n","ptr2=",p(i),"\n","++",r,"\n","--",i,"\n","tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1",g("ptr2")),"\n",v("ptr2","tmp")].join(""))}function T(t,e){M(t,e),n.push("--"+e)}function k(e,r,i){t.length>1?m([e,r],!0,[v("ptr0",g("ptr1")),"\n",v("ptr1",["pivot",i,"[pivot_ptr]"].join(""))].join("")):n.push(v(p(e),g(p(r))),v(p(r),"pivot"+i))}function E(e,r){n.push(["if((",r,"-",e,")<=",i,"){\n","insertionSort(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}else{\n",s,"(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}"].join(""))}function S(e,r,i){t.length>1?(n.push(["__l",++c,":while(true){"].join("")),m([e],!0,["if(",g("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",c,"}"].join("")),n.push(i,"}")):n.push(["while(",g(p(e)),"===pivot",r,"){",i,"}"].join(""))}return n.push("var "+f.join(",")),x(1,2),x(4,5),x(1,3),x(2,3),x(1,4),x(3,4),x(2,5),x(2,3),x(4,5),t.length>1?m(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",g("ptr1"),"\n","pivot2[pivot_ptr]=",g("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",g("ptr0"),"\n","y=",g("ptr2"),"\n","z=",g("ptr4"),"\n",v("ptr5","x"),"\n",v("ptr6","y"),"\n",v("ptr7","z")].join("")):n.push(["pivot1=",g(p("el2")),"\n","pivot2=",g(p("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",g(p("el1")),"\n","y=",g(p("el3")),"\n","z=",g(p("el5")),"\n",v(p("index1"),"x"),"\n",v(p("index3"),"y"),"\n",v(p("index5"),"z")].join("")),_("index2","left"),_("index4","right"),n.push("if(pivots_are_equal){"),n.push("for(k=less;k<=great;++k){"),w("comp","k",1),n.push("if(comp===0){continue}"),n.push("if(comp<0){"),n.push("if(k!==less){"),M("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),n.push("while(true){"),w("comp","great",1),n.push("if(comp>0){"),n.push("great--"),n.push("}else if(comp<0){"),A("k","less","great"),n.push("break"),n.push("}else{"),T("k","great"),n.push("break"),n.push("}"),n.push("}"),n.push("}"),n.push("}"),n.push("}else{"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1<0){"),n.push("if(k!==less){"),M("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2>0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp>0){"),n.push("if(--greatindex5){"),S("less",1,"++less"),S("great",2,"--great"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1===0){"),n.push("if(k!==less){"),M("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2===0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp===0){"),n.push("if(--great1&&u?new Function("insertionSort","malloc","free",n.join("\n"))(r,u[0],u[1]):new Function("insertionSort",n.join("\n"))(r)}(t,e,m);return v(m,y)}},{"typedarray-pool":348}],283:[function(t,e,r){"use strict";var n=t("./lib/compile_sort.js"),i={};e.exports=function(t){var e=t.order,r=t.dtype,a=[e,r].join(":"),o=i[a];return o||(i[a]=o=n(e,r)),o(t),t}},{"./lib/compile_sort.js":282}],284:[function(t,e,r){"use strict";var n=t("ndarray-linear-interpolate"),i=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=new Array(_inline_39_arg4_)}",args:[{name:"_inline_39_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_39_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_39_arg2_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_39_arg3_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_39_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_40_arg2_(this_warped,_inline_40_arg0_),_inline_40_arg1_=_inline_40_arg3_.apply(void 0,this_warped)}",args:[{name:"_inline_40_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_40_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_40_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_40_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_40_arg4_",lvalue:!1,rvalue:!1,count:0}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warpND",blockSize:64}),a=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_43_arg2_(this_warped,_inline_43_arg0_),_inline_43_arg1_=_inline_43_arg3_(_inline_43_arg4_,this_warped[0])}",args:[{name:"_inline_43_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_43_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_43_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_43_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_43_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp1D",blockSize:64}),o=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_46_arg2_(this_warped,_inline_46_arg0_),_inline_46_arg1_=_inline_46_arg3_(_inline_46_arg4_,this_warped[0],this_warped[1])}",args:[{name:"_inline_46_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_46_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_46_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_46_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_46_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp2D",blockSize:64}),s=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_49_arg2_(this_warped,_inline_49_arg0_),_inline_49_arg1_=_inline_49_arg3_(_inline_49_arg4_,this_warped[0],this_warped[1],this_warped[2])}",args:[{name:"_inline_49_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_49_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_49_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_49_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_49_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp3D",blockSize:64});e.exports=function(t,e,r){switch(e.shape.length){case 1:a(t,r,n.d1,e);break;case 2:o(t,r,n.d2,e);break;case 3:s(t,r,n.d3,e);break;default:i(t,r,n.bind(void 0,e),e.shape.length)}return t}},{"cwise/lib/wrapper":81,"ndarray-linear-interpolate":278}],285:[function(t,e,r){var n=t("iota-array"),i=t("is-buffer"),a="undefined"!=typeof Float64Array;function o(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,r=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+l.join(",")+",v){"),i?a.push("return this.data.set("+c+",v)}"):a.push("return this.data["+c+"]=v}"),a.push("proto.get=function "+r+"_get("+l.join(",")+"){"),i?a.push("return this.data.get("+c+")}"):a.push("return this.data["+c+"]}"),a.push("proto.index=function "+r+"_index(",l.join(),"){return "+c+"}"),a.push("proto.hi=function "+r+"_hi("+l.join(",")+"){return new "+r+"(this.data,"+o.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+o.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var d=o.map(function(t){return"a"+t+"=this.shape["+t+"]"}),p=o.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+p.join(","));for(var g=0;g=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");a.push("return new "+r+"(this.data,"+o.map(function(t){return"a"+t}).join(",")+","+o.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+l.join(",")+"){var "+o.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+o.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(g=0;g=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");return a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+o.map(function(t){return"shape["+t+"]"}).join(",")+","+o.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",a.join("\n"))(u[t],s)}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,r,n){if(void 0===t)return(0,u.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var o=e.length;if(void 0===r){r=new Array(o);for(var s=o-1,c=1;s>=0;--s)r[s]=c,c*=e[s]}if(void 0===n)for(n=0,s=0;s>>0;e.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-i:i;var r=n.hi(t),o=n.lo(t);e>t==t>0?o===a?(r+=1,o=0):o+=1:0===o?(o=a,r-=1):o-=1;return n.pack(o,r)}},{"double-bits":85}],287:[function(t,e,r){r.vertexNormals=function(t,e,r){for(var n=e.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa){var x=i[u],_=1/Math.sqrt(v*y);for(b=0;b<3;++b){var w=(b+1)%3,M=(b+2)%3;x[b]+=_*(m[w]*g[M]-m[M]*g[w])}}}for(o=0;oa)for(_=1/Math.sqrt(A),b=0;b<3;++b)x[b]*=_;else for(b=0;b<3;++b)x[b]=0}return i},r.faceNormals=function(t,e,r){for(var n=t.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa?1/Math.sqrt(d):0;for(u=0;u<3;++u)h[u]*=d;i[o]=h}return i}},{}],288:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i,a,o,s,l,u){var c=e+a+u;if(f>0){var f=Math.sqrt(c+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,u),f=Math.sqrt(2*h-c+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}},{}],289:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),c(r=[].slice.call(r,0,4),r);var i=new f(r,e,Math.log(n));i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up);return i};var n=t("filtered-vector"),i=t("gl-mat4/lookAt"),a=t("gl-mat4/fromQuat"),o=t("gl-mat4/invert"),s=t("./lib/quatFromFrame");function l(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function u(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function c(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=u(r,n,i,a);o>1e-6?(t[0]=r/o,t[1]=n/o,t[2]=i/o,t[3]=a/o):(t[0]=t[1]=t[2]=0,t[3]=1)}function f(t,e,r){this.radius=n([r]),this.center=n(e),this.rotation=n(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}var h=f.prototype;h.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},h.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;c(e,e);var r=this.computedMatrix;a(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;l<3;++l){for(var u=0,f=0;f<3;++f)u+=r[l+4*f]*i[f];r[12+l]=-u}},h.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r},h.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},h.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},h.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=i[1],o=i[5],s=i[9],u=l(a,o,s);a/=u,o/=u,s/=u;var c=i[0],f=i[4],h=i[8],d=c*a+f*o+h*s,p=l(c-=a*d,f-=o*d,h-=s*d);c/=p,f/=p,h/=p;var g=i[2],v=i[6],m=i[10],y=g*a+v*o+m*s,b=g*c+v*f+m*h,x=l(g-=y*a+b*c,v-=y*o+b*f,m-=y*s+b*h);g/=x,v/=x,m/=x;var _=c*e+a*r,w=f*e+o*r,M=h*e+s*r;this.center.move(t,_,w,M);var A=Math.exp(this.computedRadius[0]);A=Math.max(1e-4,A+n),this.radius.set(t,Math.log(A))},h.rotate=function(t,e,r,n){this.recalcMatrix(t),e=e||0,r=r||0;var i=this.computedMatrix,a=i[0],o=i[4],s=i[8],c=i[1],f=i[5],h=i[9],d=i[2],p=i[6],g=i[10],v=e*a+r*c,m=e*o+r*f,y=e*s+r*h,b=-(p*y-g*m),x=-(g*v-d*y),_=-(d*m-p*v),w=Math.sqrt(Math.max(0,1-Math.pow(b,2)-Math.pow(x,2)-Math.pow(_,2))),M=u(b,x,_,w);M>1e-6?(b/=M,x/=M,_/=M,w/=M):(b=x=_=0,w=1);var A=this.computedRotation,T=A[0],k=A[1],E=A[2],S=A[3],L=T*w+S*b+k*_-E*x,C=k*w+S*x+E*b-T*_,O=E*w+S*_+T*x-k*b,R=S*w-T*b-k*x-E*_;if(n){b=d,x=p,_=g;var P=Math.sin(n)/l(b,x,_);b*=P,x*=P,_*=P,R=R*(w=Math.cos(e))-(L=L*w+R*b+C*_-O*x)*b-(C=C*w+R*x+O*b-L*_)*x-(O=O*w+R*_+L*x-C*b)*_}var z=u(L,C,O,R);z>1e-6?(L/=z,C/=z,O/=z,R/=z):(L=C=O=0,R=1),this.rotation.set(t,L,C,O,R)},h.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var a=this.computedMatrix;i(a,e,r,n);var o=this.computedRotation;s(o,a[0],a[1],a[2],a[4],a[5],a[6],a[8],a[9],a[10]),c(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var l=0,u=0;u<3;++u)l+=Math.pow(r[u]-e[u],2);this.radius.set(t,.5*Math.log(Math.max(l,1e-6))),this.center.set(t,r[0],r[1],r[2])},h.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},h.setMatrix=function(t,e){var r=this.computedRotation;s(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),c(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;o(n,e);var i=n[15];if(Math.abs(i)>1e-6){var a=n[12]/i,l=n[13]/i,u=n[14]/i;this.recalcMatrix(t);var f=Math.exp(this.computedRadius[0]);this.center.set(t,a-n[2]*f,l-n[6]*f,u-n[10]*f),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},h.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},h.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},h.getDistanceLimits=function(t){var e=this.radius.bounds;return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},h.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},h.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":288,"filtered-vector":92,"gl-mat4/fromQuat":122,"gl-mat4/invert":125,"gl-mat4/lookAt":126}],290:[function(t,e,r){"use strict";var n=t("repeat-string");e.exports=function(t,e,r){return n(r="undefined"!=typeof r?r+"":" ",e)+t}},{"repeat-string":314}],291:[function(t,e,r){e.exports=function(t,e){e||(e=[0,""]),t=String(t);var r=parseFloat(t,10);return e[0]=r,e[1]=t.match(/[\d.\-\+]*\s*(.*)/)[1]||"",e}},{}],292:[function(t,e,r){"use strict";e.exports=function(t){var e=t.length;if(e0;--o)a=l[o],r=s[o],s[o]=s[a],s[a]=r,l[o]=l[r],l[r]=a,u=(u+r)*o;return n.freeUint32(l),n.freeUint32(s),u},r.unrank=function(t,e,r){switch(t){case 0:return r||[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}var n,i,a,o=1;for((r=r||new Array(t))[0]=0,a=1;a0;--a)e=e-(n=e/o|0)*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}},{"invert-permutation":255,"typedarray-pool":348}],294:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=0|e.length,i=t.length,a=[new Array(r),new Array(r)],o=0;o0){o=a[c][r][0],l=c;break}s=o[1^l];for(var f=0;f<2;++f)for(var h=a[f][r],d=0;d0&&(o=p,s=g,l=f)}return i?s:(o&&u(o,l),s)}function f(t,r){var i=a[r][t][0],o=[t];u(i,r);for(var s=i[1^r];;){for(;s!==t;)o.push(s),s=c(o[o.length-2],s,!1);if(a[0][t].length+a[1][t].length===0)break;var l=o[o.length-1],f=t,h=o[1],d=c(l,f,!0);if(n(e[l],e[f],e[h],e[d])<0)break;o.push(t),s=c(l,f)}return o}function h(t,e){return e[1]===e[e.length-1]}for(var o=0;o0;){a[0][o].length;var g=f(o,d);h(p,g)?p.push.apply(p,g):(p.length>0&&l.push(p),p=g)}p.length>0&&l.push(p)}return l};var n=t("compare-angle")},{"compare-angle":70}],295:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=n(t,e.length),i=new Array(e.length),a=new Array(e.length),o=[],s=0;s0;){var u=o.pop();i[u]=!1;for(var c=r[u],s=0;s0})).length,v=new Array(g),m=new Array(g),d=0;d0;){var j=D.pop(),B=L[j];l(B,function(t,e){return t-e});var U,V=B.length,H=F[j];if(0===H){var M=p[j];U=[M]}for(var d=0;d=0)&&(F[q]=1^H,D.push(q),0===H)){var M=p[q];N(M)||(M.reverse(),U.push(M))}}0===H&&r.push(U)}return r};var n=t("edges-to-adjacency-list"),i=t("planar-dual"),a=t("point-in-big-polygon"),o=t("two-product"),s=t("robust-sum"),l=t("uniq"),u=t("./lib/trim-leaves");function c(t,e){for(var r=new Array(t),n=0;n0&&e[i]===r[0]))return 1;a=t[i-1]}for(var s=1;a;){var l=a.key,u=n(r,l[0],l[1]);if(l[0][0]0))return 0;s=-1,a=a.right}else if(u>0)a=a.left;else{if(!(u<0))return 0;s=1,a=a.right}}return s}}(m.slabs,m.coordinates);return 0===a.length?y:function(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}(l(a),y)};var n=t("robust-orientation")[3],i=t("slab-decomposition"),a=t("interval-tree-1d"),o=t("binary-search-bounds");function s(){return!0}function l(t){for(var e={},r=0;r=-t},pointBetween:function(e,r,n){var i=e[1]-r[1],a=n[0]-r[0],o=e[0]-r[0],s=n[1]-r[1],l=o*a+i*s;return!(l-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-i>t&&(a-u)*(i-c)/(o-c)+u-n>t&&(s=!s),a=u,o=c}return s}};return e}},{}],301:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),i=1;i0})}function c(t,n){var i=t.seg,a=n.seg,o=i.start,s=i.end,u=a.start,c=a.end;r&&r.checkIntersection(i,a);var f=e.linesIntersect(o,s,u,c);if(!1===f){if(!e.pointsCollinear(o,s,u))return!1;if(e.pointsSame(o,c)||e.pointsSame(s,u))return!1;var h=e.pointsSame(o,u),d=e.pointsSame(s,c);if(h&&d)return n;var p=!h&&e.pointBetween(o,u,c),g=!d&&e.pointBetween(s,u,c);if(h)return g?l(n,s):l(t,c),n;p&&(d||(g?l(n,s):l(t,c)),l(n,o))}else 0===f.alongA&&(-1===f.alongB?l(t,u):0===f.alongB?l(t,f.pt):1===f.alongB&&l(t,c)),0===f.alongB&&(-1===f.alongA?l(n,o):0===f.alongA?l(n,f.pt):1===f.alongA&&l(n,s));return!1}for(var f=[];!a.isEmpty();){var h=a.getHead();if(r&&r.vert(h.pt[0]),h.isStart){r&&r.segmentNew(h.seg,h.primary);var d=u(h),p=d.before?d.before.ev:null,g=d.after?d.after.ev:null;function v(){if(p){var t=c(h,p);if(t)return t}return!!g&&c(h,g)}r&&r.tempStatus(h.seg,!!p&&p.seg,!!g&&g.seg);var m,y,b=v();if(b)t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below)&&(b.seg.myFill.above=!b.seg.myFill.above):b.seg.otherFill=h.seg.myFill,r&&r.segmentUpdate(b.seg),h.other.remove(),h.remove();if(a.getHead()!==h){r&&r.rewind(h.seg);continue}t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below,h.seg.myFill.below=g?g.seg.myFill.above:i,h.seg.myFill.above=y?!h.seg.myFill.below:h.seg.myFill.below):null===h.seg.otherFill&&(m=g?h.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:h.primary?o:i,h.seg.otherFill={above:m,below:m}),r&&r.status(h.seg,!!p&&p.seg,!!g&&g.seg),h.other.status=d.insert(n.node({ev:h}))}else{var x=h.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(s.exists(x.prev)&&s.exists(x.next)&&c(x.prev.ev,x.next.ev),r&&r.statusRemove(x.ev.seg),x.remove(),!h.primary){var _=h.seg.myFill;h.seg.myFill=h.seg.otherFill,h.seg.otherFill=_}f.push(h.seg)}a.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,i,a,o=t[t.length-1],l=0;l=u?(A=1,y=u+2*h+p):y=h*(A=-h/u)+p):(A=0,d>=0?(T=0,y=p):-d>=f?(T=1,y=f+2*d+p):y=d*(T=-d/f)+p);else if(T<0)T=0,h>=0?(A=0,y=p):-h>=u?(A=1,y=u+2*h+p):y=h*(A=-h/u)+p;else{var k=1/M;y=(A*=k)*(u*A+c*(T*=k)+2*h)+T*(c*A+f*T+2*d)+p}else A<0?(x=f+d)>(b=c+h)?(_=x-b)>=(w=u-2*c+f)?(A=1,T=0,y=u+2*h+p):y=(A=_/w)*(u*A+c*(T=1-A)+2*h)+T*(c*A+f*T+2*d)+p:(A=0,x<=0?(T=1,y=f+2*d+p):d>=0?(T=0,y=p):y=d*(T=-d/f)+p):T<0?(x=u+h)>(b=c+d)?(_=x-b)>=(w=u-2*c+f)?(T=1,A=0,y=f+2*d+p):y=(A=1-(T=_/w))*(u*A+c*T+2*h)+T*(c*A+f*T+2*d)+p:(T=0,x<=0?(A=1,y=u+2*h+p):h>=0?(A=0,y=p):y=h*(A=-h/u)+p):(_=f+d-c-h)<=0?(A=0,T=1,y=f+2*d+p):_>=(w=u-2*c+f)?(A=1,T=0,y=u+2*h+p):y=(A=_/w)*(u*A+c*(T=1-A)+2*h)+T*(c*A+f*T+2*d)+p;var E=1-A-T;for(l=0;l1)for(var r=1;r0){var u=t[r-1];if(0===n(s,u)&&a(u)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}},{"cell-orientation":56,"compare-cell":71,"compare-oriented-cell":72}],314:[function(t,e,r){"use strict";var n,i="";e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("expected a string");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;if(n!==t||"undefined"==typeof n)n=t,i="";else if(i.length>=r)return i.substr(0,r);for(;r>i.length&&e>1;)1&e&&(i+=t),e>>=1,t+=t;return i=(i+=t).substr(0,r)}},{}],315:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],316:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i],s=(r=a+o)-a,l=o-s;l&&(t[--n]=r,r=l)}for(var u=0,i=n;i>1;return["sum(",t(e.slice(0,r)),",",t(e.slice(r)),")"].join("")}(e);var n}function c(t){return new Function("sum","scale","prod","compress",["function robustDeterminant",t,"(m){return compress(",u(function(t){for(var e=new Array(t),r=0;r>1;return["sum(",u(t.slice(0,e)),",",u(t.slice(e)),")"].join("")}function c(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return c(e,t)}function f(t){if(2===t.length)return[["diff(",c(t[0][0],t[1][1]),",",c(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r0&&r.push(","),r.push("[");for(var o=0;o0&&r.push(","),o===i?r.push("+b[",a,"]"):r.push("+A[",a,"][",o,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var s=new Function("det",r.join(""));return s(t<6?n[t]:n)}var o=[function(){return[0]},function(t,e){return[[e[0]],[t[0][0]]]}];!function(){for(;o.length>1;return["sum(",u(t.slice(0,e)),",",u(t.slice(e)),")"].join("")}function c(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(a<=0)return o;n=i+a}else{if(!(i<0))return o;if(a>=0)return o;n=-(i+a)}var s=3.3306690738754716e-16*n;return o>=s||o<=-s?o:h(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],u=r[1]-n[1],c=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],p=a*u,g=o*l,v=o*s,m=i*u,y=i*l,b=a*s,x=c*(p-g)+f*(v-m)+h*(y-b),_=7.771561172376103e-16*((Math.abs(p)+Math.abs(g))*Math.abs(c)+(Math.abs(v)+Math.abs(m))*Math.abs(f)+(Math.abs(y)+Math.abs(b))*Math.abs(h));return x>_||-x>_?x:d(t,e,r,n)}];!function(){for(;p.length<=s;)p.push(f(p.length));for(var t=[],r=["slow"],n=0;n<=s;++n)t.push("a"+n),r.push("o"+n);var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(n=2;n<=s;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i0&&o>0||a<0&&o<0)return!1;var s=n(r,t,e),l=n(i,t,e);if(s>0&&l>0||s<0&&l<0)return!1;if(0===a&&0===o&&0===s&&0===l)return function(t,e,r,n){for(var i=0;i<2;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),u=r[i],c=n[i],f=Math.min(u,c),h=Math.max(u,c);if(h=n?(i=f,(l+=1)=n?(i=f,(l+=1)0?1:0}},{}],328:[function(t,e,r){"use strict";e.exports=function(t){return i(n(t))};var n=t("boundary-cells"),i=t("reduce-simplicial-complex")},{"boundary-cells":39,"reduce-simplicial-complex":313}],329:[function(t,e,r){"use strict";e.exports=function(t,e,r,s){r=r||0,"undefined"==typeof s&&(s=function(t){for(var e=t.length,r=0,n=0;n>1,v=E[2*m+1];","if(v===b){return m}","if(b0&&l.push(","),l.push("[");for(var n=0;n0&&l.push(","),l.push("B(C,E,c[",i[0],"],c[",i[1],"])")}l.push("]")}l.push(");")}}for(var a=t+1;a>1;--a){a>1,s=a(t[o],e);s<=0?(0===s&&(i=o),r=o+1):s>0&&(n=o-1)}return i}function c(t,e){for(var r=new Array(t.length),i=0,o=r.length;i=t.length||0!==a(t[v],s)););}return r}function f(t,e){if(e<0)return[];for(var r=[],i=(1<>>c&1&&u.push(i[c]);e.push(u)}return s(e)},r.skeleton=f,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function b(t){for(var e=m(t);;){var r=e,n=2*t+1,i=2*(t+1),a=t;if(n0;){var r=y(t);if(r>=0){var n=m(r);if(e0){var t=A[0];return v(0,E-1),E-=1,b(0),t}return-1}function w(t,e){var r=A[t];return u[r]===e?t:(u[r]=-1/0,x(t),_(),u[r]=e,x((E+=1)-1))}function M(t){if(!c[t]){c[t]=!0;var e=s[t],r=l[t];s[r]>=0&&(s[r]=e),l[e]>=0&&(l[e]=r),T[e]>=0&&w(T[e],g(e)),T[r]>=0&&w(T[r],g(r))}}for(var A=[],T=new Array(a),f=0;f>1;f>=0;--f)b(f);for(;;){var S=_();if(S<0||u[S]>r)break;M(S)}for(var L=[],f=0;f=0&&r>=0&&e!==r){var n=T[e],i=T[r];n!==i&&O.push([n,i])}}),i.unique(i.normalize(O)),{positions:L,edges:O}};var n=t("robust-orientation"),i=t("simplicial-complex")},{"robust-orientation":321,"simplicial-complex":333}],336:[function(t,e,r){"use strict";e.exports=function(t,e){var r,a,o,s;if(e[0][0]e[1][0]))return i(e,t);r=e[1],a=e[0]}if(t[0][0]t[1][0]))return-i(t,e);o=t[1],s=t[0]}var l=n(r,a,s),u=n(r,a,o);if(l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;if(l=n(s,o,a),u=n(s,o,r),l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;return a[0]-s[0]};var n=t("robust-orientation");function i(t,e){var r,i,a,o;if(e[0][0]e[1][0])){var s=Math.min(t[0][1],t[1][1]),l=Math.max(t[0][1],t[1][1]),u=Math.min(e[0][1],e[1][1]),c=Math.max(e[0][1],e[1][1]);return lc?s-c:l-c}r=e[1],i=e[0]}t[0][1]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=u(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=u(t.right,e))return l;t=t.left}}return r}function c(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function f(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}s.prototype.castUp=function(t){var e=n.le(this.coordinates,t[0]);if(e<0)return-1;this.slabs[e];var r=u(this.slabs[e],t),i=-1;if(r&&(i=r.value),this.coordinates[e]===t[0]){var s=null;if(r&&(s=r.key),e>0){var c=u(this.slabs[e-1],t);c&&(s?o(c.key,s)>0&&(s=c.key,i=c.value):(i=c.value,s=c.key))}var f=this.horizontal[e];if(f.length>0){var h=n.ge(f,t[1],l);if(h=f.length)return i;d=f[h]}}if(d.start)if(s){var p=a(s[0],s[1],[t[0],d.y]);s[0][0]>s[1][0]&&(p=-p),p>0&&(i=d.index)}else i=d.index;else d.y!==t[1]&&(i=d.index)}}}return i}},{"./lib/order-segments":336,"binary-search-bounds":36,"functional-red-black-tree":93,"robust-orientation":321}],338:[function(t,e,r){"use strict";var n=t("robust-dot-product"),i=t("robust-sum");function a(t,e){var r=i(n(t,e),[e[e.length-1]]);return r[r.length-1]}function o(t,e,r,n){var i=-e/(n-e);i<0?i=0:i>1&&(i=1);for(var a=1-i,o=t.length,s=new Array(o),l=0;l0||i>0&&c<0){var f=o(s,c,l,i);r.push(f),n.push(f.slice())}c<0?n.push(l.slice()):c>0?r.push(l.slice()):(r.push(l.slice()),n.push(l.slice())),i=c}return{positive:r,negative:n}},e.exports.positive=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&u<0)&&r.push(o(i,u,s,n)),u>=0&&r.push(s.slice()),n=u}return r},e.exports.negative=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&u<0)&&r.push(o(i,u,s,n)),u<=0&&r.push(s.slice()),n=u}return r}},{"robust-dot-product":318,"robust-sum":326}],339:[function(t,e,r){!function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function e(r){return function(r,n){var i,a,o,s,l,u,c,f,h,d=1,p=r.length,g="";for(a=0;a=0),s[8]){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,s[6]?parseInt(s[6]):0);break;case"e":i=s[7]?parseFloat(i).toExponential(s[7]):parseFloat(i).toExponential();break;case"f":i=s[7]?parseFloat(i).toFixed(s[7]):parseFloat(i);break;case"g":i=s[7]?String(Number(i.toPrecision(s[7]))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=s[7]?i.substring(0,s[7]):i;break;case"t":i=String(!!i),i=s[7]?i.substring(0,s[7]):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=s[7]?i.substring(0,s[7]):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=s[7]?i.substring(0,s[7]):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}t.json.test(s[8])?g+=i:(!t.number.test(s[8])||f&&!s[3]?h="":(h=f?"+":"-",i=i.toString().replace(t.sign,"")),u=s[4]?"0"===s[4]?"0":s[4].charAt(1):" ",c=s[6]-(h+i).length,l=s[6]&&c>0?u.repeat(c):"",g+=s[5]?h+i+l:"0"===u?h+l+i:l+h+i)}return g}(function(e){if(i[e])return i[e];var r,n=e,a=[],o=0;for(;n;){if(null!==(r=t.text.exec(n)))a.push(r[0]);else if(null!==(r=t.modulo.exec(n)))a.push("%");else{if(null===(r=t.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){o|=1;var s=[],l=r[2],u=[];if(null===(u=t.key.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(l=l.substring(u[0].length));)if(null!==(u=t.key_access.exec(l)))s.push(u[1]);else{if(null===(u=t.index_access.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}r[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");a.push(r)}n=n.substring(r[0].length)}return i[e]=a}(r),arguments)}function n(t,r){return e.apply(null,[t].concat(r||[]))}var i=Object.create(null);"undefined"!=typeof r&&(r.sprintf=e,r.vsprintf=n),"undefined"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}()},{}],340:[function(t,e,r){"use strict";e.exports=function(t){return t.split("").map(function(t){return t in n?n[t]:""}).join("")};var n={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],341:[function(t,e,r){"use strict";e.exports=function(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return function(t,e){for(var r=a(t,e),n=r.length,i=new Array(n),o=new Array(n),s=0;s c)|0 },"),"generic"===e&&a.push("getters:[0],");for(var s=[],l=[],u=0;u>>7){");for(var u=0;u<1<<(1<128&&u%128==0){f.length>0&&h.push("}}");var d="vExtra"+f.length;a.push("case ",u>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&u,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;bb)&&!(u&1<<_)!=!(u&1<0&&(T="+"+v[x]+"*c");var k=p[x].length/y*.5,E=.5+m[x]/y*.5;A.push("d"+x+"-"+E+"-"+k+"*("+p[x].join("+")+T+")/("+g[x].join("+")+")")}h.push("a.push([",A.join(),"]);","break;")}a.push("}},"),f.length>0&&h.push("}}");for(var S=[],u=0;u<1<1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=C(t,360),e=C(e,100),r=C(r,100),0===e)n=i=a=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;n=o(l,s,t+1/3),i=o(l,s,t),a=o(l,s,t-1/3)}return{r:255*n,g:255*i,b:255*a}}(e.h,l,c),f=!0,h="hsl"),e.hasOwnProperty("a")&&(a=e.a));var d,p,g;return a=L(a),{ok:f,format:e.format||h,r:o(255,s(i.r,0)),g:o(255,s(i.g,0)),b:o(255,s(i.b,0)),a:a}}(e);this._originalInput=e,this._r=c.r,this._g=c.g,this._b=c.b,this._a=c.a,this._roundA=a(100*this._a)/100,this._format=l.format||c.format,this._gradientType=l.gradientType,this._r<1&&(this._r=a(this._r)),this._g<1&&(this._g=a(this._g)),this._b<1&&(this._b=a(this._b)),this._ok=c.ok,this._tc_id=i++}function c(t,e,r){t=C(t,255),e=C(e,255),r=C(r,255);var n,i,a=s(t,e,r),l=o(t,e,r),u=(a+l)/2;if(a==l)n=i=0;else{var c=a-l;switch(i=u>.5?c/(2-a-l):c/(a+l),a){case t:n=(e-r)/c+(e>1)+720)%360;--e;)n.h=(n.h+i)%360,a.push(u(n));return a}function k(t,e){e=e||6;for(var r=u(t).toHsv(),n=r.h,i=r.s,a=r.v,o=[],s=1/e;e--;)o.push(u({h:n,s:i,v:a})),a=(a+s)%1;return o}u.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,i=this.toRgb();return e=i.r/255,r=i.g/255,n=i.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=L(t),this._roundA=a(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=c(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return h(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,i){var o=[P(a(t).toString(16)),P(a(e).toString(16)),P(a(r).toString(16)),P(I(n))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:a(this._r),g:a(this._g),b:a(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+a(this._r)+", "+a(this._g)+", "+a(this._b)+")":"rgba("+a(this._r)+", "+a(this._g)+", "+a(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:a(100*C(this._r,255))+"%",g:a(100*C(this._g,255))+"%",b:a(100*C(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+a(100*C(this._r,255))+"%, "+a(100*C(this._g,255))+"%, "+a(100*C(this._b,255))+"%)":"rgba("+a(100*C(this._r,255))+"%, "+a(100*C(this._g,255))+"%, "+a(100*C(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[h(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+d(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var i=u(t);r="#"+d(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return u(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(m,arguments)},brighten:function(){return this._applyModification(y,arguments)},darken:function(){return this._applyModification(b,arguments)},desaturate:function(){return this._applyModification(p,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(T,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(A,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(M,arguments)}},u.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:z(t[n]));t=r}return u(t,e)},u.equals=function(t,e){return!(!t||!e)&&u(t).toRgbString()==u(e).toRgbString()},u.random=function(){return u.fromRatio({r:l(),g:l(),b:l()})},u.mix=function(t,e,r){r=0===r?0:r||50;var n=u(t).toRgb(),i=u(e).toRgb(),a=r/100;return u({r:(i.r-n.r)*a+n.r,g:(i.g-n.g)*a+n.g,b:(i.b-n.b)*a+n.b,a:(i.a-n.a)*a+n.a})},u.readability=function(e,r){var n=u(e),i=u(r);return(t.max(n.getLuminance(),i.getLuminance())+.05)/(t.min(n.getLuminance(),i.getLuminance())+.05)},u.isReadable=function(t,e,r){var n,i,a=u.readability(t,e);switch(i=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},u.mostReadable=function(t,e,r){var n,i,a,o,s=null,l=0;i=(r=r||{}).includeFallbackColors,a=r.level,o=r.size;for(var c=0;cl&&(l=n,s=u(e[c]));return u.isReadable(t,s,{level:a,size:o})||!i?s:(r.includeFallbackColors=!1,u.mostReadable(t,["#fff","#000"],r))};var E=u.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=u.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(E);function L(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function C(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,s(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function O(t){return o(1,s(0,t))}function R(t){return parseInt(t,16)}function P(t){return 1==t.length?"0"+t:""+t}function z(t){return t<=1&&(t=100*t+"%"),t}function I(e){return t.round(255*parseFloat(e)).toString(16)}function N(t){return R(t)/255}var D,F,j,B=(F="[\\s|\\(]+("+(D="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+D+")[,|\\s]+("+D+")\\s*\\)?",j="[\\s|\\(]+("+D+")[,|\\s]+("+D+")[,|\\s]+("+D+")[,|\\s]+("+D+")\\s*\\)?",{CSS_UNIT:new RegExp(D),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+j),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+j),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+j),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function U(t){return!!B.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=u:window.tinycolor=u}(Math)},{}],343:[function(t,e,r){"use strict";var n=t("parse-unit");e.exports=o;var i=96;function a(t,e){var r=n(getComputedStyle(t).getPropertyValue(e));return r[0]*o(r[1],t)}function o(t,e){switch(e=e||document.body,t=(t||"px").trim().toLowerCase(),e!==window&&e!==document||(e=document.body),t){case"%":return e.clientHeight/100;case"ch":case"ex":return function(t,e){var r=document.createElement("div");r.style["font-size"]="128"+t,e.appendChild(r);var n=a(r,"font-size")/128;return e.removeChild(r),n}(t,e);case"em":return a(e,"font-size");case"rem":return a(document.body,"font-size");case"vw":return window.innerWidth/100;case"vh":return window.innerHeight/100;case"vmin":return Math.min(window.innerWidth,window.innerHeight)/100;case"vmax":return Math.max(window.innerWidth,window.innerHeight)/100;case"in":return i;case"cm":return i/2.54;case"mm":return i/25.4;case"pt":return i/72;case"pc":return i/6}return 1}},{"parse-unit":291}],344:[function(t,e,r){"use strict";e.exports=function(t){if(t<0)return[];if(0===t)return[[0]];for(var e=0|Math.round(a(t+1)),r=[],o=0;oMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,l=0;l<3;++l)a+=t[l]*t[l],o+=i[l]*t[l];for(l=0;l<3;++l)i[l]-=o/a*t[l];return s(i,i),i}function h(t,e,r,i,a,o,s,l){this.center=n(r),this.up=n(i),this.right=n(a),this.radius=n([o]),this.angle=n([s,l]),this.angle.bounds=[[-1/0,-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var u=0;u<16;++u)this.computedMatrix[u]=.5;this.recalcMatrix(0)}var d=h.prototype;d.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},d.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},d.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,n=0,i=0,a=0;a<3;++a)i+=e[a]*r[a],n+=e[a]*e[a];var l=Math.sqrt(n),c=0;for(a=0;a<3;++a)r[a]-=e[a]*i/n,c+=r[a]*r[a],e[a]/=l;var f=Math.sqrt(c);for(a=0;a<3;++a)r[a]/=f;var h=this.computedToward;o(h,e,r),s(h,h);var d=Math.exp(this.computedRadius[0]),p=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(p),m=Math.sin(p),y=Math.cos(g),b=Math.sin(g),x=this.computedCenter,_=v*y,w=m*y,M=b,A=-v*b,T=-m*b,k=y,E=this.computedEye,S=this.computedMatrix;for(a=0;a<3;++a){var L=_*r[a]+w*h[a]+M*e[a];S[4*a+1]=A*r[a]+T*h[a]+k*e[a],S[4*a+2]=L,S[4*a+3]=0}var C=S[1],O=S[5],R=S[9],P=S[2],z=S[6],I=S[10],N=O*I-R*z,D=R*P-C*I,F=C*z-O*P,j=u(N,D,F);N/=j,D/=j,F/=j,S[0]=N,S[4]=D,S[8]=F;for(a=0;a<3;++a)E[a]=x[a]+S[2+4*a]*d;for(a=0;a<3;++a){c=0;for(var B=0;B<3;++B)c+=S[a+4*B]*E[B];S[12+a]=-c}S[15]=1},d.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r};var p=[0,0,0];d.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;p[0]=i[2],p[1]=i[6],p[2]=i[10];for(var o=this.computedUp,s=this.computedRight,l=this.computedToward,u=0;u<3;++u)i[4*u]=o[u],i[4*u+1]=s[u],i[4*u+2]=l[u];a(i,i,n,p);for(u=0;u<3;++u)o[u]=i[4*u],s[u]=i[4*u+1];this.up.set(t,o[0],o[1],o[2]),this.right.set(t,s[0],s[1],s[2])}},d.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=(Math.exp(this.computedRadius[0]),i[1]),o=i[5],s=i[9],l=u(a,o,s);a/=l,o/=l,s/=l;var c=i[0],f=i[4],h=i[8],d=c*a+f*o+h*s,p=u(c-=a*d,f-=o*d,h-=s*d),g=(c/=p)*e+a*r,v=(f/=p)*e+o*r,m=(h/=p)*e+s*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+n),this.radius.set(t,Math.log(y))},d.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},d.setMatrix=function(t,e,r,n){var a=1;"number"==typeof r&&(a=0|r),(a<0||a>3)&&(a=1);var o=(a+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var s=e[a],l=e[a+4],f=e[a+8];if(n){var h=Math.abs(s),d=Math.abs(l),p=Math.abs(f),g=Math.max(h,d,p);h===g?(s=s<0?-1:1,l=f=0):p===g?(f=f<0?-1:1,s=l=0):(l=l<0?-1:1,s=f=0)}else{var v=u(s,l,f);s/=v,l/=v,f/=v}var m,y,b=e[o],x=e[o+4],_=e[o+8],w=b*s+x*l+_*f,M=u(b-=s*w,x-=l*w,_-=f*w),A=l*(_/=M)-f*(x/=M),T=f*(b/=M)-s*_,k=s*x-l*b,E=u(A,T,k);if(A/=E,T/=E,k/=E,this.center.jump(t,q,G,W),this.radius.idle(t),this.up.jump(t,s,l,f),this.right.jump(t,b,x,_),2===a){var S=e[1],L=e[5],C=e[9],O=S*b+L*x+C*_,R=S*A+L*T+C*k;m=N<0?-Math.PI/2:Math.PI/2,y=Math.atan2(R,O)}else{var P=e[2],z=e[6],I=e[10],N=P*s+z*l+I*f,D=P*b+z*x+I*_,F=P*A+z*T+I*k;m=Math.asin(c(N)),y=Math.atan2(F,D)}this.angle.jump(t,y,m),this.recalcMatrix(t);var j=e[2],B=e[6],U=e[10],V=this.computedMatrix;i(V,e);var H=V[15],q=V[12]/H,G=V[13]/H,W=V[14]/H,X=Math.exp(this.computedRadius[0]);this.center.jump(t,q-j*X,G-B*X,W-U*X)},d.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},d.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},d.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},d.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},d.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter;var i=(n=n||this.computedUp)[0],a=n[1],o=n[2],s=u(i,a,o);if(!(s<1e-6)){i/=s,a/=s,o/=s;var l=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],d=u(l,f,h);if(!(d<1e-6)){l/=d,f/=d,h/=d;var p=this.computedRight,g=p[0],v=p[1],m=p[2],y=i*g+a*v+o*m,b=u(g-=y*i,v-=y*a,m-=y*o);if(!(b<.01&&(b=u(g=a*h-o*f,v=o*l-i*h,m=i*f-a*l))<1e-6)){g/=b,v/=b,m/=b,this.up.set(t,i,a,o),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(d));var x=a*m-o*v,_=o*g-i*m,w=i*v-a*g,M=u(x,_,w),A=i*l+a*f+o*h,T=g*l+v*f+m*h,k=(x/=M)*l+(_/=M)*f+(w/=M)*h,E=Math.asin(c(A)),S=Math.atan2(k,T),L=this.angle._state,C=L[L.length-1],O=L[L.length-2];C%=2*Math.PI;var R=Math.abs(C+2*Math.PI-S),P=Math.abs(C-S),z=Math.abs(C-2*Math.PI-S);R0?r.pop():new ArrayBuffer(t)}function h(t){return new Uint8Array(f(t),0,t)}function d(t){return new Uint16Array(f(2*t),0,t)}function p(t){return new Uint32Array(f(4*t),0,t)}function g(t){return new Int8Array(f(t),0,t)}function v(t){return new Int16Array(f(2*t),0,t)}function m(t){return new Int32Array(f(4*t),0,t)}function y(t){return new Float32Array(f(4*t),0,t)}function b(t){return new Float64Array(f(8*t),0,t)}function x(t){return o?new Uint8ClampedArray(f(t),0,t):h(t)}function _(t){return new DataView(f(t),0,t)}function w(t){t=i.nextPow2(t);var e=i.log2(t),r=u[e];return r.length>0?r.pop():new n(t)}r.free=function(t){if(n.isBuffer(t))u[i.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|i.log2(e);l[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=function(t){c(t.buffer)},r.freeArrayBuffer=c,r.freeBuffer=function(t){u[i.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return f(t);switch(e){case"uint8":return h(t);case"uint16":return d(t);case"uint32":return p(t);case"int8":return g(t);case"int16":return v(t);case"int32":return m(t);case"float":case"float32":return y(t);case"double":case"float64":return b(t);case"uint8_clamped":return x(t);case"buffer":return w(t);case"data":case"dataview":return _(t);default:return null}return null},r.mallocArrayBuffer=f,r.mallocUint8=h,r.mallocUint16=d,r.mallocUint32=p,r.mallocInt8=g,r.mallocInt16=v,r.mallocInt32=m,r.mallocFloat32=r.mallocFloat=y,r.mallocFloat64=r.mallocDouble=b,r.mallocUint8Clamped=x,r.mallocDataView=_,r.mallocBuffer=w,r.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,l[t].length=0,u[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":37,buffer:49,dup:87}],349:[function(t,e,r){"use strict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var o=3*n;t.height=0?e[a]:i})},has___:{value:b(function(e){var n=y(e);return n?r in n:t.indexOf(e)>=0})},set___:{value:b(function(n,i){var a,o=y(n);return o?o[r]=i:(a=t.indexOf(n))>=0?e[a]=i:(a=t.length,e[a]=i,t[a]=n),this})},delete___:{value:b(function(n){var i,a,o=y(n);return o?r in o&&delete o[r]:!((i=t.indexOf(n))<0||(a=t.length-1,t[i]=void 0,e[i]=e[a],t[i]=t[a],t.length=a,e.length=a,0))})}})};g.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},delete:{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof r?function(){function n(){this instanceof g||x();var e,n=new r,i=void 0,a=!1;return e=t?function(t,e){return n.set(t,e),n.has(t)||(i||(i=new g),i.set(t,e)),this}:function(t,e){if(a)try{n.set(t,e)}catch(r){i||(i=new g),i.set___(t,e)}else n.set(t,e);return this},Object.create(g.prototype,{get___:{value:b(function(t,e){return i?n.has(t)?n.get(t):i.get___(t,e):n.get(t,e)})},has___:{value:b(function(t){return n.has(t)||!!i&&i.has___(t)})},set___:{value:b(e)},delete___:{value:b(function(t){var e=!!n.delete(t);return i&&i.delete___(t)||e})},permitHostObjects___:{value:b(function(t){if(t!==v)throw new Error("bogus call to permitHostObjects___");a=!0})}})}t&&"undefined"!=typeof Proxy&&(Proxy=void 0),n.prototype=g.prototype,e.exports=n,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=g)}function v(t){t.permitHostObjects___&&t.permitHostObjects___(v)}function m(t){return!(t.substr(0,l.length)==l&&"___"===t.substr(t.length-3))}function y(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[u];if(e&&e.key===t)return e;if(s(t)){e={key:t};try{return o(t,u,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(t){return}}}function b(t){return t.prototype=null,Object.freeze(t)}function x(){d||"undefined"==typeof console||(d=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}}()},{}],354:[function(t,e,r){var n=t("./hidden-store.js");e.exports=function(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:n(e,t)}}},{"./hidden-store.js":355}],355:[function(t,e,r){e.exports=function(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}},{}],356:[function(t,e,r){var n=t("./create-store.js");e.exports=function(){var t=n();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){return t(e).value=r,this},has:function(e){return"value"in t(e)},delete:function(e){return delete t(e).value}}}},{"./create-store.js":354}],357:[function(t,e,r){var n=t("get-canvas-context");e.exports=function(t){return n("webgl",t)}},{"get-canvas-context":95}],358:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array",{offset:[1],array:0},"scalar","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":78}],359:[function(t,e,r){"use strict";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t("./lib/zc-core")},{"./lib/zc-core":358}],360:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],361:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:i({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:i({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":534,"../../plots/cartesian/constants":550,"../../plots/font_attributes":571,"./arrow_paths":360}],362:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=i.getFromId(t,e.xref),n=i.getFromId(t,e.yref);e._extremes={},r&&s(e,r),n&&s(e,n)})}function s(t,e){var r,n=e._id,a=n.charAt(0),o=t[a],s=t["a"+a],l=t[a+"ref"],u=t["a"+a+"ref"],c=t["_"+a+"padplus"],f=t["_"+a+"padminus"],h={x:1,y:-1}[a]*t[a+"shift"],d=3*t.arrowsize*t.arrowwidth||0,p=d+h,g=d-h,v=3*t.startarrowsize*t.arrowwidth||0,m=v+h,y=v-h;if(u===l){var b=i.findExtremes(e,[e.r2c(o)],{ppadplus:p,ppadminus:g}),x=i.findExtremes(e,[e.r2c(s)],{ppadplus:Math.max(c,m),ppadminus:Math.max(f,y)});r={min:[b.min[0],x.min[0]],max:[b.max[0],x.max[0]]}}else m=s?m+s:m,y=s?y-s:y,r=i.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(c,p,m),ppadminus:Math.max(f,g,y)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([a,o],t)}},{"../../lib":498,"../../plots/cartesian/axes":544,"./draw":367}],363:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,i,a,o,l,u,c=t._fullLayout.annotations,f=[],h=[],d=[],p=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,s,l=o(t,e),u=l.on,c=l.off.concat(l.explicitOff),f={},h=t._fullLayout.annotations;if(!u.length&&!c.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var H=!1,q=["x","y"],G=0;G1)&&(K===$?((lt=tt.r2fraction(e["a"+J]))<0||lt>1)&&(H=!0):H=!0),W=tt._offset+tt.r2p(e[J]),Z=.5}else"x"===J?(Y=e[J],W=x.l+x.w*Y):(Y=1-e[J],W=x.t+x.h*Y),Z=e.showarrow?.5:Y;if(e.showarrow){st.head=W;var ut=e["a"+J];Q=rt*V(.5,e.xanchor)-nt*V(.5,e.yanchor),K===$?(st.tail=tt._offset+tt.r2p(ut),X=Q):(st.tail=W+ut,X=Q+ut),st.text=st.tail+Q;var ct=b["x"===J?"width":"height"];if("paper"===$&&(st.head=o.constrain(st.head,1,ct-1)),"pixel"===K){var ft=-Math.max(st.tail-3,st.text),ht=Math.min(st.tail+3,st.text)-ct;ft>0?(st.tail+=ft,st.text+=ft):ht>0&&(st.tail-=ht,st.text-=ht)}st.tail+=ot,st.head+=ot}else X=Q=it*V(Z,at),st.text=W+Q;st.text+=ot,Q+=ot,X+=ot,e["_"+J+"padplus"]=it/2+X,e["_"+J+"padminus"]=it/2-X,e["_"+J+"size"]=it,e["_"+J+"shift"]=Q}if(t._dragging||!H){var dt=0,pt=0;if("left"!==e.align&&(dt=(w-m)*("center"===e.align?.5:1)),"top"!==e.valign&&(pt=(R-y)*("middle"===e.valign?.5:1)),c)n.select("svg").attr({x:N+dt-1,y:N+pt}).call(u.setClipUrl,F?k:null);else{var gt=N+pt-p.top,vt=N+dt-p.left;U.call(f.positionText,vt,gt).call(u.setClipUrl,F?k:null)}j.select("rect").call(u.setRect,N,N,w,R),D.call(u.setRect,z/2,z/2,I-z,B-z),P.call(u.setTranslate,Math.round(E.x.text-I/2),Math.round(E.y.text-B/2)),C.attr({transform:"rotate("+S+","+E.x.text+","+E.y.text+")"});var mt,yt=function(r,n){L.selectAll(".annotation-arrow-g").remove();var c=E.x.head,f=E.y.head,h=E.x.tail+r,p=E.y.tail+n,m=E.x.text+r,y=E.y.text+n,b=o.rotationXYMatrix(S,m,y),w=o.apply2DTransform(b),k=o.apply2DTransform2(b),O=+D.attr("width"),R=+D.attr("height"),z=m-.5*O,I=z+O,N=y-.5*R,F=N+R,j=[[z,N,z,F],[z,F,I,F],[I,F,I,N],[I,N,z,N]].map(k);if(!j.reduce(function(t,e){return t^!!o.segmentsIntersect(c,f,c+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){j.forEach(function(t){var e=o.segmentsIntersect(h,p,c,f,t[0],t[1],t[2],t[3]);e&&(h=e.x,p=e.y)});var B=e.arrowwidth,U=e.arrowcolor,V=e.arrowside,H=L.append("g").style({opacity:l.opacity(U)}).classed("annotation-arrow-g",!0),q=H.append("path").attr("d","M"+h+","+p+"L"+c+","+f).style("stroke-width",B+"px").call(l.stroke,l.rgb(U));if(g(q,V,e),_.annotationPosition&&q.node().parentNode&&!a){var G=c,W=f;if(e.standoff){var X=Math.sqrt(Math.pow(c-h,2)+Math.pow(f-p,2));G+=e.standoff*(h-c)/X,W+=e.standoff*(p-f)/X}var Y,Z,Q=H.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(h-G)+","+(p-W),transform:"translate("+G+","+W+")"}).style("stroke-width",B+6+"px").call(l.stroke,"rgba(0,0,0,0)").call(l.fill,"rgba(0,0,0,0)");d.init({element:Q.node(),gd:t,prepFn:function(){var t=u.getTranslate(P);Y=t.x,Z=t.y,s&&s.autorange&&M(s._name+".autorange",!0),v&&v.autorange&&M(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(Y,Z),i=n[0]+t,a=n[1]+r;P.call(u.setTranslate,i,a),A("x",s?s.p2r(s.r2p(e.x)+t):e.x+t/x.w),A("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/x.h),e.axref===e.xref&&A("ax",s.p2r(s.r2p(e.ax)+t)),e.ayref===e.yref&&A("ay",v.p2r(v.r2p(e.ay)+r)),H.attr("transform","translate("+t+","+r+")"),C.attr({transform:"rotate("+S+","+i+","+a+")"})},doneFn:function(){i.call("relayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&yt(0,0),O)d.init({element:P.node(),gd:t,prepFn:function(){mt=C.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?A("ax",s.p2r(s.r2p(e.ax)+t)):A("ax",e.ax+t),e.ayref===e.yref?A("ay",v.p2r(v.r2p(e.ay)+r)):A("ay",e.ay+r),yt(t,r);else{if(a)return;var i,o;if(s)i=s.p2r(s.r2p(e.x)+t);else{var l=e._xsize/x.w,u=e.x+(e._xshift-e.xshift)/x.w-l/2;i=d.align(u+t/x.w,l,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var c=e._ysize/x.h,f=e.y-(e._yshift+e.yshift)/x.h-c/2;o=d.align(f-r/x.h,c,0,1,e.yanchor)}A("x",i),A("y",o),s&&v||(n=d.getCursor(s?.5:i,v?.5:o,e.xanchor,e.yanchor))}C.attr({transform:"translate("+t+","+r+")"+mt}),h(P,n)},doneFn:function(){h(P),i.call("relayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else P.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,m=f.backoff*d+r.standoff,y=h.backoff*p+r.startstandoff;if("line"===c.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},s={x:+t.attr("x2"),y:+t.attr("y2")};var b=o.x-s.x,x=o.y-s.y;if(u=(l=Math.atan2(x,b))+Math.PI,m&&y&&m+y>Math.sqrt(b*b+x*x))return void O();if(m){if(m*m>b*b+x*x)return void O();var _=m*Math.cos(l),w=m*Math.sin(l);s.x+=_,s.y+=w,t.attr({x2:s.x,y2:s.y})}if(y){if(y*y>b*b+x*x)return void O();var M=y*Math.cos(l),A=y*Math.sin(l);o.x-=M,o.y-=A,t.attr({x1:o.x,y1:o.y})}}else if("path"===c.nodeName){var T=c.getTotalLength(),k="";if(T1){u=!0;break}}u?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l._pdata=i(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*r[0],e.yaxis.r2l(l.y)*r[1],e.zaxis.r2l(l.z)*r[2]]),n(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":584,"../annotations/draw":367}],374:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var a=r.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return a?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}a.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},a.rgb=function(t){return a.tinyRGB(n(t))},a.opacity=function(t){return t?n(t).getAlpha():0},a.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},a.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var i=n(e||l).toRgb(),a=1===i.a?i:{r:255*(1-i.a)+i.r*i.a,g:255*(1-i.a)+i.g*i.a,b:255*(1-i.a)+i.b*i.a},o={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},a.contrast=function(t,e,r){var i=n(t);return 1!==i.getAlpha()&&(i=n(a.combine(t,l))),(i.isDark()?e?i.lighten(e):l:r?i.darken(r):s).toString()},a.stroke=function(t,e){var r=n(e);t.style({stroke:a.tinyRGB(r),"stroke-opacity":r.getAlpha()})},a.fill=function(t,e){var r=n(e);t.style({fill:a.tinyRGB(r),"fill-opacity":r.getAlpha()})},a.clean=function(t){if(t&&"object"==typeof t){var e,r,n,i,o=Object.keys(t);for(e=0;e0?E>=z:E<=z));S++)E>N&&E0?E>=z:E<=z));S++)E>L[0]&&E1){var at=Math.pow(10,Math.floor(Math.log(it)/Math.LN10));rt*=at*u.roundUp(it/at,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(tt.tick0=0)}tt.dtick=rt}tt.domain=[Q+X,Q+q-X],tt.setScale();var ot=u.ensureSingle(v._infolayer,"g",e,function(t){t.classed(A.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(A.cbbg,!0),t.append("g").classed(A.cbfills,!0),t.append("g").classed(A.cblines,!0),t.append("g").classed(A.cbaxis,!0).classed(A.crisp,!0),t.append("g").classed(A.cbtitleunshift,!0).append("g").classed(A.cbtitle,!0),t.append("rect").classed(A.cboutline,!0),t.select(".cbtitle").datum(0)})});ot.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var st=ot.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");tt._axislayer=ot.select(".cbaxis");var lt=0;if(-1!==["top","bottom"].indexOf(r.titleside)){var ut,ct=M.l+(r.x+G)*M.w,ft=tt.titlefont.size;ut="top"===r.titleside?(1-(Q+q-X))*M.h+M.t+3+.75*ft:(1-(Q+X))*M.h+M.t-3-.25*ft,mt(tt._id+"title",{attributes:{x:ct,y:ut,"text-anchor":"start"}})}var ht,dt,pt,gt=u.syncOrAsync([a.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.titleside)){var a=ot.select(".cbtitle"),o=a.select("text"),l=[-r.outlinewidth/2,r.outlinewidth/2],c=a.select(".h"+tt._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*m),c?(lt=h.bBox(c).height)>f&&(l[1]-=(lt-f)/2):o.node()&&!o.classed(A.jsPlaceholder)&&(lt=h.bBox(o.node()).height),lt){if(lt+=5,"top"===r.titleside)tt.domain[1]-=lt/M.h,l[1]*=-1;else{tt.domain[0]+=lt/M.h;var d=g.lineCount(o);l[1]+=(1-d)*f}a.attr("transform","translate("+l+")"),tt.setScale()}}ot.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(M.h*(1-tt.domain[1]))+")"),tt._axislayer.attr("transform","translate(0,"+Math.round(-M.t)+")");var p=ot.select(".cbfills").selectAll("rect.cbfill").data(O);p.enter().append("rect").classed(A.cbfill,!0).style("stroke","none"),p.exit().remove();var y=L.map(tt.c2p).map(Math.round).sort(function(t,e){return t-e});p.each(function(a,o){var s=[0===o?L[0]:(O[o]+O[o-1])/2,o===O.length-1?L[1]:(O[o]+O[o+1])/2].map(tt.c2p).map(Math.round);s[1]=u.constrain(s[1]+(s[1]>s[0])?1:-1,y[0],y[1]);var l=n.select(this).attr({x:Y,width:Math.max(U,2),y:n.min(s),height:Math.max(n.max(s)-n.min(s),2)});if(r.fillgradient)h.gradient(l,t,e,"vertical",r.fillgradient,"fill");else{var c=P(a).replace("e-","");l.attr("fill",i(c).toHexString())}});var b=ot.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?C:[]);return b.enter().append("path").classed(A.cbline,!0),b.exit().remove(),b.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round(tt.c2p(t))+r.line.width/2%1)+"h"+U).call(h.lineGroupStyle,r.line.width,R(t),r.line.dash)}),tt._axislayer.selectAll("g."+tt._id+"tick,path").remove(),tt._pos=Y+U+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),tt.side="right",u.syncOrAsync([function(){return s.doTicksSingle(t,tt,!0)},function(){if(-1===["top","bottom"].indexOf(r.titleside)){var e=tt.titlefont.size,i=tt._offset+tt._length/2,a=M.l+(tt.position||0)*M.w+("right"===tt.side?10+e*(tt.showticklabels?1:.5):-10-e*(tt.showticklabels?.5:0));mt("h"+tt._id+"title",{avoid:{selection:n.select(t).selectAll("g."+tt._id+"tick"),side:r.titleside,offsetLeft:M.l,offsetTop:0,maxShift:v.width},attributes:{x:a,y:i,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},a.previousPromises,function(){var n=U+r.outlinewidth/2+h.bBox(tt._axislayer.node()).width;if((F=st.select("text")).node()&&!F.classed(A.jsPlaceholder)){var i,o=st.select(".h"+tt._id+"title-math-group").node();i=o&&-1!==["top","bottom"].indexOf(r.titleside)?h.bBox(o).width:h.bBox(st.node()).right-Y-M.l,n=Math.max(n,i)}var s=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,l=J-$;ot.select(".cbbg").attr({x:Y-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:$-W,width:Math.max(s,2),height:Math.max(l+2*W,2)}).call(d.fill,r.bgcolor).call(d.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),ot.selectAll(".cboutline").attr({x:Y,y:$+r.ypad+("top"===r.titleside?lt:0),width:Math.max(U,2),height:Math.max(l-2*r.ypad-lt,2)}).call(d.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var u=({center:.5,right:1}[r.xanchor]||0)*s;ot.attr("transform","translate("+(M.l-u)+","+M.t+")");var c={},f=y[r.yanchor],p=b[r.yanchor];"pixels"===r.lenmode?(c.y=r.y,c.t=l*f,c.b=l*p):(c.t=c.b=0,c.yt=r.y+r.len*f,c.yb=r.y-r.len*p);var g=y[r.xanchor],v=b[r.xanchor];if("pixels"===r.thicknessmode)c.x=r.x,c.l=s*g,c.r=s*v;else{var m=s-U;c.l=m*g,c.r=m*v,c.xl=r.x-r.thickness*g,c.xr=r.x+r.thickness*v}a.autoMargin(t,e,c)}],t);if(gt&>.then&&(t._promises||[]).push(gt),t._context.edits.colorbarPosition)l.init({element:ot.node(),gd:t,prepFn:function(){ht=ot.attr("transform"),f(ot)},moveFn:function(t,e){ot.attr("transform",ht+" translate("+t+","+e+")"),dt=l.align(Z+t/M.w,V,0,1,r.xanchor),pt=l.align(Q-e/M.h,q,0,1,r.yanchor);var n=l.getCursor(dt,pt,r.xanchor,r.yanchor);f(ot,n)},doneFn:function(){f(ot),void 0!==dt&&void 0!==pt&&o.call("restyle",t,{"colorbar.x":dt,"colorbar.y":pt},k().index)}});return gt}function vt(t,e){return u.coerce(K,tt,w,t,e)}function mt(e,r){var n=k(),i="colorbar.title",a=n._module.colorbar.container;a&&(i=a+"."+i);var o={propContainer:tt,propName:i,traceIndex:n.index,placeholder:v._dfltTitle.colorbar,containerGroup:ot.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;ot.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,c(o,r||{}))}v._infolayer.selectAll("g."+e).remove()}function k(){var r,n,i=e.substr(2);for(r=0;r=0?i.Reds:i.Blues,s.reversescale?a(y):y),l.autocolorscale||f("autocolorscale",!1))}},{"../../lib":498,"./flip_scale":388,"./scales":395}],385:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":395}],386:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,u,c){var f,h=c.prefix,d=c.cLetter,p=h.slice(0,h.length-1),g=h?i.nestedProperty(t,p).get()||{}:t,v=h?i.nestedProperty(e,p).get()||{}:e,m=g[d+"min"],y=g[d+"max"],b=g.colorscale;u(h+d+"auto",!(n(m)&&n(y)&&m=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],389:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){if(e||(e=i),!t)return e;function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return"string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e}},{"./default_scale":385,"./is_valid_scale_array":393,"./scales":395}],390:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(i.isArrayOrTypedArray(o))for(var l=0;l4/3-s?o:s}},{}],397:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":498}],398:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),i=t("has-hover"),a=t("has-passive-events"),o=t("../../registry"),s=t("../../lib"),l=t("../../plots/cartesian/constants"),u=t("../../constants/interactions"),c=e.exports={};c.align=t("./align"),c.getCursor=t("./cursor");var f=t("./unhover");function h(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function d(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}c.unhover=f.wrapped,c.unhoverRaw=f.raw,c.init=function(t){var e,r,n,f,p,g,v,m,y=t.gd,b=1,x=u.DBLCLICKDELAY,_=t.element;y._mouseDownTime||(y._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=M,a?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=M,_.addEventListener("touchstart",M,{passive:!1})):_.ontouchstart=M;var w=t.clampFn||function(t,e,r){return Math.abs(t)x&&(b=Math.max(b-1,1)),y._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(b,g),!m){var r;try{r=new MouseEvent("click",e)}catch(t){var n=d(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(y),y._dragged=!1}else y._dragged=!1}},c.coverSlip=h},{"../../constants/interactions":477,"../../lib":498,"../../plots/cartesian/constants":550,"../../registry":597,"./align":396,"./cursor":397,"./unhover":399,"has-hover":250,"has-passive-events":251,"mouse-event-offset":271}],399:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=t("../../lib/throttle"),a=t("../../lib/get_graph_div"),o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,r){(t=a(t))._fullLayout&&i.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,r)},s.raw=function(t,e){var r=t._fullLayout,i=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&i&&t.emit("plotly_unhover",{event:e,points:i}))}},{"../../lib/events":489,"../../lib/get_graph_div":494,"../../lib/throttle":522,"../fx/constants":413}],400:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],401:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("tinycolor2"),o=t("../../registry"),s=t("../color"),l=t("../colorscale"),u=t("../../lib"),c=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../constants/alignment").LINE_SPACING,d=t("../../constants/interactions").DESELECTDIM,p=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){u.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,i){t.call(v.setPosition,e,r).call(v.setSize,n,i)},v.translatePoint=function(t,e,r,n){var a=r.c2p(t.x),o=n.c2p(t.y);return!!(i(a)&&i(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",a).attr("y",o):e.attr("transform","translate("+a+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var i=n.select(this);v.translatePoint(t,i,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,i,a){e.attr("display",r.isPtWithinRange(t,i)&&n.isPtWithinRange(t,a)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,i=e.yaxis;t.each(function(e){var a=e[0].trace,o=a.xcalendar,s=a.ycalendar,l="bar"===a.type?".bartext":".point,.textpoint";t.selectAll(l).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,i,o,s)})})}},v.crispRound=function(t,e,r){return e&&i(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,i){e.style("fill","none");var a=(((t||[])[0]||{}).trace||{}).line||{},o=r||a.width||0,l=i||a.dash||"";s.stroke(e,n||a.color),v.dashLine(e,l,o)},v.lineGroupStyle=function(t,e,r,i){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=i||a.dash||"";n.select(this).call(s.stroke,r||a.color).call(v.dashLine,l,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(s.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){n.select(this).call(s.fill,t[0].trace.fillcolor)})};var m=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(m).forEach(function(t){var e=m[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var y=v.symbolNames.length,b="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function x(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?b:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=y||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},M=n.format("~.1f"),A={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,i,o,l){for(var c=o.length,f=A[i],h=new Array(c),d=0;d=100,e.attr("d",x(c,l))}var f,h,d,p=!1;if(t.so)d=o.outlierwidth,h=o.outliercolor,f=a.outliercolor;else{var g=(o||{}).width;d=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,h="mlc"in t?t.mlcc=n.lineScale(t.mlc):u.isArrayOrTypedArray(o.color)?s.defaultLine:o.color,u.isArrayOrTypedArray(a.color)&&(f=s.defaultLine,p=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):a.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(s.stroke,f).style({"stroke-width":(d||1)+"px",fill:"none"});else{e.style("stroke-width",d+"px");var m=a.gradient,y=t.mgt;if(y?p=!0:y=m&&m.type,Array.isArray(y)&&(y=y[0],A[y]||(y=0)),y&&"none"!==y){var b=t.mgc;b?p=!0:b=m.color;var _=r.uid;p&&(_+="-"+t.i),v.gradient(e,i,_,y,[[0,b],[1,f]],"fill")}else s.fill(e,f);d&&s.stroke(e,h)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=p.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&u.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.marker||{},a=r.marker||{},s=n.marker||{},l=i.opacity,c=a.opacity,f=s.opacity,h=void 0!==c,p=void 0!==f;(u.isArrayOrTypedArray(l)||h||p)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?i.opacity:t.mo;return t.selected?h?c:e:p?f:d*e});var g=i.color,v=a.color,m=s.color;(v||m)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:m||e});var y=i.size,b=a.size,x=s.size,_=void 0!==b,w=void 0!==x;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||y/2;return t.selected?_?b/2:e:w?x/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.textfont||{},a=r.textfont||{},o=n.textfont||{},l=i.color,u=a.color,c=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||l;return t.selected?u||e:c||(u?e:s.addOpacity(e,d))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),i=e.marker||{},a=[];r.selectedOpacityFn&&a.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&a.push(function(t,e){s.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&a.push(function(t,e){var n=e.mx||i.symbol||0,a=r.selectedSizeFn(e);t.attr("d",x(v.symbolNumber(n),a)),e.mrc2=a}),a.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var i;if(e.selectedpoints){var a=v.makeSelectedTextStyleFns(e);i=a.selectedTextColorFn}t.each(function(t){var a=n.select(this),o=u.extractOption(t,e,"tx","text");if(o||0===o){var s=t.tp||e.textposition,l=E(t,e),f=i?i(t):t.tc||e.textfont.color;a.call(v.font,t.tf||e.textfont.family,l,f).text(o).call(c.convertToTspans,r).call(k,s,l,t.mrc)}else a.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var i=n.select(this),a=r.selectedTextColorFn(t),o=t.tp||e.textposition,l=E(t,e);s.fill(i,a),k(i,o,l,t.mrc2||t.mrc)})}};var S=.5;function L(t,e,r,i){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],u=Math.pow(a*a+o*o,S/2),c=Math.pow(s*s+l*l,S/2),f=(c*c*a-u*u*s)*i,h=(c*c*o-u*u*l)*i,d=3*c*(u+c),p=3*u*(u+c);return[[n.round(e[0]+(d&&f/d),2),n.round(e[1]+(d&&h/d),2)],[n.round(e[0]-(p&&f/p),2),n.round(e[1]-(p&&h/p),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],i=[];for(r=1;r=1e4&&(v.savedBBoxes={},R=0),r&&(v.savedBBoxes[r]=m),R++,u.extendFlat({},m)},v.setClipUrl=function(t,e){if(e){if(void 0===v.baseUrl){var r=n.select("base");r.size()&&r.attr("href")?v.baseUrl=window.location.href.split("#")[0]:v.baseUrl=""}t.attr("clip-path","url("+v.baseUrl+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||0,r=r||0,a=a.replace(/(\btranslate\(.*?\);?)/,"").trim(),a=(a+=" translate("+e+", "+r+")").trim(),t[i]("transform",a),a},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||1,r=r||1,a=a.replace(/(\bscale\(.*?\);?)/,"").trim(),a=(a+=" scale("+e+", "+r+")").trim(),t[i]("transform",a),a};var z=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(z,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var I=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,i=n.select(this),a=i.select("text");if(a.node()){var o=parseFloat(a.attr("x")||0),s=parseFloat(a.attr("y")||0),l=(i.attr("transform")||"").match(I);t=1===e&&1===r?[]:["translate("+o+","+s+")","scale("+e+","+r+")","translate("+-o+","+-s+")"],l&&t.push(l),i.attr("transform",t.join(" "))}})}},{"../../constants/alignment":474,"../../constants/interactions":477,"../../constants/xmlns_namespaces":479,"../../lib":498,"../../lib/svg_text_utils":521,"../../registry":597,"../../traces/scatter/make_bubble_size_func":636,"../../traces/scatter/subtypes":643,"../color":376,"../colorscale":391,"./symbol_defs":402,d3:82,"fast-isnumeric":91,tinycolor2:342}],402:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(-.309*t,2);return"M"+e+","+a+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(-.309*e,2),u=n.round(.118*e,2),c=n.round(.809*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+u+"L"+o+","+c+"L0,"+n.round(.382*e,2)+"L-"+o+","+c+"L-"+a+","+u+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:82}],403:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],404:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../registry"),a=t("../../plots/cartesian/axes"),o=t("./compute_error");function s(t,e,r,i){var s=e["error_"+i]||{},l=[];if(s.visible&&-1!==["linear","log"].indexOf(r.type)){for(var u=o(s),c=0;c0;t.each(function(t){var c,f=t[0].trace,h=f.error_x||{},d=f.error_y||{};f.ids&&(c=function(t){return t.id});var p=o.hasMarkers(f)&&f.marker.maxdisplayed>0;d.visible||h.visible||(t=[]);var g=n.select(this).selectAll("g.errorbar").data(t,c);if(g.exit().remove(),t.length){h.visible||g.selectAll("path.xerror").remove(),d.visible||g.selectAll("path.yerror").remove(),g.style("opacity",1);var v=g.enter().append("g").classed("errorbar",!0);u&&v.style("opacity",0).transition().duration(r.duration).style("opacity",1),a.setClipUrl(g,e.layerClipId),g.each(function(t){var e=n.select(this),a=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),i(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),i(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,s,l);if(!p||t.vis){var o,c=e.select("path.yerror");if(d.visible&&i(a.x)&&i(a.yh)&&i(a.ys)){var f=d.width;o="M"+(a.x-f)+","+a.yh+"h"+2*f+"m-"+f+",0V"+a.ys,a.noYS||(o+="m-"+f+",0h"+2*f),!c.size()?c=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):u&&(c=c.transition().duration(r.duration).ease(r.easing)),c.attr("d",o)}else c.remove();var g=e.select("path.xerror");if(h.visible&&i(a.y)&&i(a.xh)&&i(a.xs)){var v=(h.copy_ystyle?d:h).width;o="M"+a.xh+","+(a.y-v)+"v"+2*v+"m0,-"+v+"H"+a.xs,a.noXS||(o+="m0,-"+v+"v"+2*v),!g.size()?g=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):u&&(g=g.transition().duration(r.duration).ease(r.easing)),g.attr("d",o)}else g.remove()}})}})}},{"../../traces/scatter/subtypes":643,"../drawing":401,d3:82,"fast-isnumeric":91}],409:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":376,d3:82}],410:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":571}],411:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry");function a(t,e,r,i){i=i||n.identity,Array.isArray(t)&&(e[0][r]=i(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var s=0;s=0&&r.index-1&&o.length>b&&(o=b>3?o.substr(0,b-3)+"...":o.substr(0,b))}void 0!==t.zLabel?(void 0!==t.xLabel&&(u+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(u+="y: "+t.yLabel+"
"),u+=(u?"z: ":"")+t.zLabel):C&&t[i+"Label"]===A?u=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(u=t.yLabel):u=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(u+=(u?"
":"")+t.text),void 0!==t.extraText&&(u+=(u?"
":"")+t.extraText),""===u&&(""===o&&e.remove(),u=o);var x=e.select("text.nums").call(c.font,t.fontFamily||p,t.fontSize||g,t.fontColor||y).text(u).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),_=e.select("text.name"),T=0;o&&o!==u?(_.call(c.font,t.fontFamily||p,t.fontSize||g,v).text(o).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),T=_.node().getBoundingClientRect().width+2*M):(_.remove(),e.select("rect").remove()),e.select("path").style({fill:d,stroke:y});var k,O,R=x.node().getBoundingClientRect(),P=t.xa._offset+(t.x0+t.x1)/2,z=t.ya._offset+(t.y0+t.y1)/2,I=Math.abs(t.x1-t.x0),N=Math.abs(t.y1-t.y0),D=R.width+w+M+T;t.ty0=E-R.top,t.bx=R.width+2*M,t.by=R.height+2*M,t.anchor="start",t.txwidth=R.width,t.tx2width=T,t.offset=0,a?(t.pos=P,k=z+N/2+D<=L,O=z-N/2-D>=0,"top"!==t.idealAlign&&k||!O?k?(z+=N/2,t.anchor="start"):t.anchor="middle":(z-=N/2,t.anchor="end")):(t.pos=z,k=P+I/2+D<=S,O=P-I/2-D>=0,"left"!==t.idealAlign&&k||!O?k?(P+=I/2,t.anchor="start"):t.anchor="middle":(P-=I/2,t.anchor="end")),x.attr("text-anchor",t.anchor),T&&_.attr("text-anchor",t.anchor),e.attr("transform","translate("+P+","+z+")"+(a?"rotate("+m+")":""))}),N}function T(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var i="end"===t.anchor?-1:1,a=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],s=o*(w+M),u=s+o*(t.txwidth+M),f=0,h=t.offset;"middle"===t.anchor&&(s-=t.tx2width/2,u+=t.txwidth/2+M),e&&(h*=-_,f=t.offset*x),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(h-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(i*w+f)+","+(w+h)+"v"+(t.by/2-w)+"h"+i*t.bx+"v-"+t.by+"H"+(i*w+f)+"V"+(h-w)+"Z"),a.call(l.positionText,s+f,h+t.ty0-t.by/2+M),t.tx2width&&(r.select("text.name").call(l.positionText,u+o*M+f,h+t.ty0-t.by/2+M),r.select("rect").call(c.setRect,u+(o-1)*t.tx2width/2+f,h-t.by/2-1,t.tx2width,t.by+2))}})}function k(t,e){var r=t.index,n=t.trace||{},i=t.cd[0],a=t.cd[r]||{},s=Array.isArray(r)?function(t,e){return o.castOption(i,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(a,n,t,e)};function l(e,r,n){var i=s(r,n);i&&(t[e]=i)}if(l("hoverinfo","hi","hoverinfo"),l("bgcolor","hbg","hoverlabel.bgcolor"),l("borderColor","hbc","hoverlabel.bordercolor"),l("fontFamily","htf","hoverlabel.font.family"),l("fontSize","hts","hoverlabel.font.size"),l("fontColor","htc","hoverlabel.font.color"),l("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:d.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:d.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var u=d.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+u+" / -"+d.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+u,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var c=d.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+c+" / -"+d.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+c,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function E(t,e){var r,n,i=e.container,o=e.fullLayout,s=e.event,l=!!t.hLinePoint,u=!!t.vLinePoint;if(i.selectAll(".spikeline").remove(),u||l){var h=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(l){var d,p,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(d=s.pointerX,p=s.pointerY):(d=r._offset+g.x,p=n._offset+g.y);var v,m,y=a.readability(g.color,h)<1.5?f.contrast(h):g.color,b=n.spikemode,x=n.spikethickness,_=n.spikecolor||y,w=n._boundingBox,M=(w.left+w.right)/2w[0]._length||et<0||et>M[0]._length)return h.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+M[0]._offset,I="xval"in e?g.flat(l,e.xval):g.p2c(w,tt),N="yval"in e?g.flat(l,e.yval):g.p2c(M,et),!i(I[0])||!i(N[0]))return o.warn("Fx.hover failed",e,t),h.unhoverRaw(t,e)}var it=1/0;for(F=0;FX&&(Q.splice(0,X),it=Q[0].distance),y&&0!==Z&&0===Q.length){W.distance=Z,W.index=!1;var ut=B._module.hoverPoints(W,q,G,"closest",c._hoverlayer);if(ut&&(ut=ut.filter(function(t){return t.spikeDistance<=Z})),ut&&ut.length){var ct,ft=ut.filter(function(t){return t.xa.showspikes});if(ft.length){var ht=ft[0];i(ht.x0)&&i(ht.y0)&&(ct=vt(ht),(!$.vLinePoint||$.vLinePoint.spikeDistance>ct.spikeDistance)&&($.vLinePoint=ct))}var dt=ut.filter(function(t){return t.ya.showspikes});if(dt.length){var pt=dt[0];i(pt.x0)&&i(pt.y0)&&(ct=vt(pt),(!$.hLinePoint||$.hLinePoint.spikeDistance>ct.spikeDistance)&&($.hLinePoint=ct))}}}}function gt(t,e){for(var r,n=null,i=1/0,a=0;a1||Q.length>1)||"closest"===z&&K&&Q.length>1,Lt=f.combine(c.plot_bgcolor||f.background,c.paper_bgcolor),Ct={hovermode:z,rotateLabels:St,bgColor:Lt,container:c._hoverlayer,outerContainer:c._paperdiv,commonLabelOpts:c.hoverlabel,hoverdistance:c.hoverdistance},Ot=A(Q,Ct,t);if(function(t,e,r){var n,i,a,o,s,l,u,c=0,f=1,h=t.map(function(t,n){var i=t[e],a="x"===i._id.charAt(0),o=i.range;return!n&&o&&o[0]>o[1]!==a&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(a?b:1)/2,pmin:0,pmax:a?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function d(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(a<.01)){if(i<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var u=0;for(o=0;oe.pmax&&u++;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos>e.pmax-1&&(l.del=!0,u--);for(o=0;o=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos+l.dp+l.size>e.pmax&&(l.del=!0,u--)}}}for(;!n&&c<=t.length;){for(c++,n=!0,o=0;o.01&&v.pmin===m.pmin&&v.pmax===m.pmax){for(s=g.length-1;s>=0;s--)g[s].dp+=i;for(p.push.apply(p,g),h.splice(o+1,1),u=0,s=p.length-1;s>=0;s--)u+=p[s].dp;for(a=u/p.length,s=p.length-1;s>=0;s--)p[s].dp-=a;n=!1}else o++}h.forEach(d)}for(o=h.length-1;o>=0;o--){var y=h[o];for(s=y.length-1;s>=0;s--){var x=y[s],_=t[x.i];_.offset=x.dp,_.del=x.del}}}(Q,St?"xa":"ya",c),T(Ot,St),e.target&&e.target.tagName){var Rt=p.getComponentMethod("annotations","hasClickToShow")(t,kt);u(n.select(e.target),Rt?"pointer":"")}if(!e.target||a||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}(t,0,Tt))return;Tt&&t.emit("plotly_unhover",{event:e,points:Tt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:M,xvals:I,yvals:N})}(t,e,r,a)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0},i=n.select(e.container),a=e.outerContainer?n.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=A([r],o,e.gd);return T(s,o.rotateLabels),s.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0}}),i=n.select(e.container),a=e.outerContainer?n.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=A(r,o,e.gd),l=0;return s.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){h||d||p||"independent"===A("pattern")&&(h=!0),v._hasSubplotGrid=h;var b,x,_="top to bottom"===A("roworder"),w=h?.2:.1,M=h?.3:.1;g&&e._splomGridDflt&&(b=e._splomGridDflt.xside,x=e._splomGridDflt.yside),v._domains={x:c("x",A,w,b,y),y:c("y",A,M,x,m,_)}}else delete e.grid}function A(t,e){return n.coerce(r,v,l,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,i,a,o,s,l,c,h=t.grid||{},d=e._subplots,p=r._hasSubplotGrid,g=r.rows,v=r.columns,m="independent"===r.pattern,y=r._axisMap={};if(p){var b=h.subplots||[];l=r.subplots=new Array(g);var x=1;for(n=0;n=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],429:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes");e.exports={bgcolor:{valType:"color",editType:"legend"},bordercolor:{valType:"color",dflt:i.defaultLine,editType:"legend"},borderwidth:{valType:"number",min:0,dflt:0,editType:"legend"},font:n({editType:"legend"}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v",editType:"legend"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"],editType:"legend"},tracegroupgap:{valType:"number",min:0,dflt:10,editType:"legend"},x:{valType:"number",min:-2,max:3,dflt:1.02,editType:"legend"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left",editType:"legend"},y:{valType:"number",min:-2,max:3,dflt:1,editType:"legend"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"legend"},editType:"legend"}},{"../../plots/font_attributes":571,"../color/attributes":375}],430:[function(t,e,r){"use strict";e.exports={scrollBarWidth:6,scrollBarMinHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4,textOffsetX:40}},{}],431:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../../plot_api/plot_template"),o=t("./attributes"),s=t("../../plots/layout_attributes"),l=t("./helpers");e.exports=function(t,e,r){for(var u,c,f,h,d=t.legend||{},p=0,g=!1,v="normal",m=0;m1)){var b=a.newContainer(e,"legend");if(_("bgcolor",e.paper_bgcolor),_("bordercolor"),_("borderwidth"),i.coerceFont(_,"font",e.font),_("orientation"),"h"===b.orientation){var x=t.xaxis;x&&x.rangeslider&&x.rangeslider.visible?(u=0,f="left",c=1.1,h="bottom"):(u=0,f="left",c=-.1,h="top")}_("traceorder",v),l.isGrouped(e.legend)&&_("tracegroupgap"),_("x",u),_("xanchor",f),_("y",c),_("yanchor",h),i.noneOrAll(d,b,["x","y"])}function _(t,e){return i.coerce(d,b,o,t,e)}}},{"../../lib":498,"../../plot_api/plot_template":534,"../../plots/layout_attributes":587,"../../registry":597,"./attributes":429,"./helpers":435}],432:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib/events"),l=t("../dragelement"),u=t("../drawing"),c=t("../color"),f=t("../../lib/svg_text_utils"),h=t("./handle_click"),d=t("./constants"),p=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,m=g.FROM_TL,y=g.FROM_BR,b=t("./get_legend_data"),x=t("./style"),_=t("./helpers"),w=t("./anchor_utils"),M=p.DBLCLICKDELAY;function A(t,e,r,n,i){var a=r.data()[0][0].trace,o={event:i,node:r.node(),curveNumber:a.index,expandedIndex:a._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(a._group&&(o.group=a._group),"pie"===a.type&&(o.label=r.datum()[0].label),!1!==s.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){h(r,t,n)},M);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==s.triggerHandler(t,"plotly_legenddoubleclick",o)&&h(r,t,n)}}function T(t,e,r){var n=t.data()[0][0],a=e._fullLayout,s=n.trace,l=o.traceIs(s,"pie"),c=s.index,h=l?n.label:s.name,p=e._context.edits.legendText&&!l,g=i.ensureSingle(t,"text","legendtext");function m(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,i,a=t.select("g[class*=math-group]"),o=a.node(),s=e._fullLayout.legend.font.size*v;if(o){var l=u.bBox(o);n=l.height,i=l.width,u.setTranslate(a,0,n/4)}else{var c=t.select(".legendtext"),h=f.lineCount(c),p=c.node();n=s*h,i=p?u.bBox(p).width:0;var g=s*(.3+(1-h)/2);f.positionText(c,d.textOffsetX,g)}n=Math.max(n,16)+3,r.height=n,r.width=i}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(u.font,a.legend.font).text(p?k(h,r):h),f.positionText(g,d.textOffsetX,0),p?g.call(f.makeEditable,{gd:e,text:h}).call(m).on("edit",function(t){this.text(k(t,r)).call(m);var a=n.trace._fullInput||{},s={};if(o.hasTransform(a,"groupby")){var l=o.getTransformIndices(a,"groupby"),u=l[l.length-1],f=i.keyedContainer(a,"transforms["+u+"].styles","target","value.name");f.set(n.trace._group,t),s=f.constructUpdate()}else s.name=t;return o.call("restyle",e,s,c)}):m(g)}function k(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function E(t,e){var r,a=1,o=i.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(c.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimeM&&(a=Math.max(a-1,1)),A(e,r,t,a,n.event)}})}function S(t,e,r){var i=t._fullLayout,a=i.legend,o=a.borderwidth,s=_.isGrouped(a),l=0;if(a._width=0,a._height=0,_.isVertical(a))s&&e.each(function(t,e){u.setTranslate(this,0,e*a.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;u.setTranslate(this,o,5+o+a._height+r/2),a._height+=r,a._width=Math.max(a._width,n)}),a._width+=45+2*o,a._height+=10+2*o,s&&(a._height+=(a._lgroupsLength-1)*a.tracegroupgap),l=40;else if(s){for(var c=[a._width],f=e.data(),h=0,d=f.length;ho+w-M,r.each(function(t){var e=t[0],r=v?40+t[0].width:b;o+x+M+r>i._size.w&&(x=0,m+=y,a._height=a._height+y,y=0),u.setTranslate(this,o+x,5+o+e.height/2+m),a._width+=M+r,a._height=Math.max(a._height,e.height),x+=M+r,y=Math.max(e.height,y)}),a._width+=2*o,a._height+=10+2*o}a._width=Math.ceil(a._width),a._height=Math.ceil(a._height);var A=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");u.setRect(r,0,-e.height/2,(A?0:a._width)+l,e.height)})}function L(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");var n="top";w.isBottomAnchor(e)?n="bottom":w.isMiddleAnchor(e)&&(n="middle"),a.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*m[r],r:e._width*y[r],b:e._height*y[n],t:e._height*m[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var s=e.legend,f=e.showlegend&&b(t.calcdata,s),h=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void a.autoMargin(t,"legend");for(var p=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");a.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*m[r],r:e._width*y[r],b:0,t:0})}(t):L(t);var h=e._size,p=h.l+h.w*s.x,g=h.t+h.h*(1-s.y);w.isRightAnchor(s)?p-=s._width:w.isCenterAnchor(s)&&(p-=s._width/2),w.isBottomAnchor(s)?g-=s._height:w.isMiddleAnchor(s)&&(g-=s._height/2);var v=s._width,b=h.w;v>b?(p=h.l,v=b):(p+v>c&&(p=c-v),p<0&&(p=0),v=Math.min(c-p,s._width));var x,_,M,T,k=s._height,E=h.h;if(k>E?(g=h.t,k=E):(g+k>f&&(g=f-k),g<0&&(g=0),k=Math.min(f-g,s._height)),u.setTranslate(O,p,g),I.on(".drag",null),O.on("wheel",null),s._height<=k||t._context.staticPlot)P.attr({width:v-s.borderwidth,height:k-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),u.setTranslate(z,0,0),R.select("rect").attr({width:v-2*s.borderwidth,height:k-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth}),u.setClipUrl(z,r),u.setRect(I,0,0,0,0),delete s._scrollY;else{var F,j,B=Math.max(d.scrollBarMinHeight,k*k/s._height),U=k-B-2*d.scrollBarMargin,V=s._height-k,H=U/V,q=Math.min(s._scrollY||0,V);P.attr({width:v-2*s.borderwidth+d.scrollBarWidth+d.scrollBarMargin,height:k-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),R.select("rect").attr({width:v-2*s.borderwidth+d.scrollBarWidth+d.scrollBarMargin,height:k-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth+q}),u.setClipUrl(z,r),W(q,B,H),O.on("wheel",function(){W(q=i.constrain(s._scrollY+n.event.deltaY/U*V,0,V),B,H),0!==q&&q!==V&&n.event.preventDefault()});var G=n.behavior.drag().on("dragstart",function(){F=n.event.sourceEvent.clientY,j=q}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||W(q=i.constrain((t.clientY-F)/H+j,0,V),B,H)});I.call(G)}function W(e,r,n){s._scrollY=t._fullLayout.legend._scrollY=e,u.setTranslate(z,0,-e),u.setRect(I,v,d.scrollBarMargin+e*n,d.scrollBarWidth,r),R.select("rect").attr({y:s.borderwidth+e})}t._context.edits.legendPosition&&(O.classed("cursor-move",!0),l.init({element:O.node(),gd:t,prepFn:function(){var t=u.getTranslate(O);M=t.x,T=t.y},moveFn:function(t,e){var r=M+t,n=T+e;u.setTranslate(O,r,n),x=l.align(r,0,h.l,h.l+h.w,s.xanchor),_=l.align(n,0,h.t+h.h,h.t,s.yanchor)},doneFn:function(){void 0!==x&&void 0!==_&&o.call("relayout",t,{"legend.x":x,"legend.y":_})},clickFn:function(r,n){var i=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});i.size()>0&&A(t,O,i,r,n)}}))}],t)}}},{"../../constants/alignment":474,"../../constants/interactions":477,"../../lib":498,"../../lib/events":489,"../../lib/svg_text_utils":521,"../../plots/plots":589,"../../registry":597,"../color":376,"../dragelement":398,"../drawing":401,"./anchor_utils":428,"./constants":430,"./get_legend_data":433,"./handle_click":434,"./helpers":435,"./style":437,d3:82}],433:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("./helpers");e.exports=function(t,e){var r,a,o={},s=[],l=!1,u={},c=0;function f(t,r){if(""!==t&&i.isGrouped(e))-1===s.indexOf(t)?(s.push(t),l=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+c;s.push(n),o[n]=[[r]],c++}}for(r=0;rr[1])return r[1]}return i}function p(t){return t[0]}if(c||f||h){var g={},v={};if(c){g.mc=d("marker.color",p),g.mx=d("marker.symbol",p),g.mo=d("marker.opacity",a.mean,[.2,1]),g.mlc=d("marker.line.color",p),g.mlw=d("marker.line.width",a.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var m=d("marker.size",a.mean,[2,16]);g.ms=m,v.marker.size=m}h&&(v.line={width:d("line.width",p,[0,10])}),f&&(g.tx="Aa",g.tp=d("textposition",p),g.ts=10,g.tc=d("textfont.color",p),g.tf=d("textfont.family",p)),r=[a.minExtend(s,g)],(i=a.minExtend(u,v)).selectedpoints=null}var y=n.select(this).select("g.legendpoints"),b=y.selectAll("path.scatterpts").data(c?r:[]);b.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),b.exit().remove(),b.call(o.pointStyle,i,e),c&&(r[0].mrc=3);var x=y.selectAll("g.pointtext").data(f?r:[]);x.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),x.exit().remove(),x.selectAll("text").call(o.textPointStyle,i,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var i=e[r?"increasing":"decreasing"],a=i.line.width,o=n.select(this);o.style("stroke-width",a+"px").call(s.fill,i.fillcolor),a&&s.stroke(o,i.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var i=e[r?"increasing":"decreasing"],a=i.line.width,l=n.select(this);l.style("fill","none").call(o.dashLine,i.line.dash,a),a&&s.stroke(l,i.line.color)})})}},{"../../lib":498,"../../registry":597,"../../traces/pie/style_one":617,"../../traces/scatter/subtypes":643,"../color":376,"../drawing":401,d3:82}],438:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),s=t("../../../build/ploticon"),l=o._,u=e.exports={};function c(t,e){var r,i,o=e.currentTarget,s=o.getAttribute("data-attr"),l=o.getAttribute("data-val")||!0,u=t._fullLayout,c={},f=a.list(t,null,!0),h="on";if("zoom"===s){var d,p="in"===l?.5:2,g=(1+p)/2,v=(1-p)/2;for(i=0;i1?(_=["toggleHover"],w=["resetViews"]):f?(x=["zoomInGeo","zoomOutGeo"],_=["hoverClosestGeo"],w=["resetGeo"]):c?(_=["hoverClosest3d"],w=["resetCameraDefault3d","resetCameraLastSave3d"]):g?(_=["toggleHover"],w=["resetViewMapbox"]):_=d?["hoverClosestGl2d"]:h?["hoverClosestPie"]:["toggleHover"];u&&(_=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!u&&!d||m||(x=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==w[0]&&(w=["resetScale2d"]));c?M=["zoom3d","pan3d","orbitRotation","tableRotation"]:(u||d)&&!m||p?M=["zoom2d","pan2d"]:g||f?M=["pan2d"]:v&&(M=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),i=0,a=0;a0?h+u:u;return{ppad:u,ppadplus:c?p:g,ppadminus:c?g:p}}return{ppad:u}}function c(t,e,r,n,i){var s="category"===t.type?t.r2c:t.d2c;if(void 0!==e)return[s(e),s(r)];if(n){var l,u,c,f,h=1/0,d=-1/0,p=n.match(a.segmentRE);for("date"===t.type&&(s=o.decodeDate(s)),l=0;ld&&(d=f)));return d>=h?[h,d]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:I?H(r.xanchor)+r.x0:H(r.x0),cy:N?q(r.yanchor)-r.y0:q(r.y0),r:a}).style(i).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:I?H(r.xanchor)+r.x1:H(r.x1),cy:N?q(r.yanchor)-r.y1:q(r.y1),r:a}).style(i).classed("cursor-grab",!0),n}():e,Y={element:X.node(),gd:t,prepFn:function(n){I&&(_=H(r.xanchor));N&&(w=q(r.yanchor));"path"===r.type?O=r.path:(m=I?r.x0:H(r.x0),y=N?r.y0:q(r.y0),b=I?r.x1:H(r.x1),x=N?r.y1:q(r.y1));mx?(M=y,E="y0",A=x,S="y1"):(M=x,E="y1",A=y,S="y0");Z(n),$(d,r),function(t,e,r){var n=e.xref,i=e.yref,o=a.getFromId(r,n),l=a.getFromId(r,i),u="";"paper"===n||o.autorange||(u+=n);"paper"===i||l.autorange||(u+=i);t.call(s.setClipUrl,u?"clip"+r._fullLayout._uid+u:null)}(e,r,t),Y.moveFn="move"===R?Q:J},doneFn:function(){c(e),K(d),p(e,t,r),n.call("relayout",t,j.getUpdateObj())},clickFn:function(){K(d)}};function Z(t){if(D)R="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Y.element.getBoundingClientRect(),n=r.right-r.left,i=r.bottom-r.top,a=t.clientX-r.left,o=t.clientY-r.top,s=!F&&n>P&&i>z&&!t.shiftKey?u.getCursor(a/n,1-o/i):"move";c(e,s),R=s.split("-")[0]}}function Q(n,i){if("path"===r.type){var a=function(t){return t},o=a,s=a;I?B("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(H(t)+n)},U&&"date"===U.type&&(o=h.encodeDate(o))),N?B("yanchor",r.yanchor=W(w+i)):(s=function(t){return W(q(t)+i)},V&&"date"===V.type&&(s=h.encodeDate(s))),B("path",r.path=v(O,o,s))}else I?B("xanchor",r.xanchor=G(_+n)):(B("x0",r.x0=G(m+n)),B("x1",r.x1=G(b+n))),N?B("yanchor",r.yanchor=W(w+i)):(B("y0",r.y0=W(y+i)),B("y1",r.y1=W(x+i)));e.attr("d",g(t,r)),$(d,r)}function J(n,i){if(F){var a=function(t){return t},o=a,s=a;I?B("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(H(t)+n)},U&&"date"===U.type&&(o=h.encodeDate(o))),N?B("yanchor",r.yanchor=W(w+i)):(s=function(t){return W(q(t)+i)},V&&"date"===V.type&&(s=h.encodeDate(s))),B("path",r.path=v(O,o,s))}else if(D){if("resize-over-start-point"===R){var l=m+n,u=N?y-i:y+i;B("x0",r.x0=I?l:G(l)),B("y0",r.y0=N?u:W(u))}else if("resize-over-end-point"===R){var c=b+n,f=N?x-i:x+i;B("x1",r.x1=I?c:G(c)),B("y1",r.y1=N?f:W(f))}}else{var p=~R.indexOf("n")?M+i:M,j=~R.indexOf("s")?A+i:A,X=~R.indexOf("w")?T+n:T,Y=~R.indexOf("e")?k+n:k;~R.indexOf("n")&&N&&(p=M-i),~R.indexOf("s")&&N&&(j=A-i),(!N&&j-p>z||N&&p-j>z)&&(B(E,r[E]=N?p:W(p)),B(S,r[S]=N?j:W(j))),Y-X>P&&(B(L,r[L]=I?X:G(X)),B(C,r[C]=I?Y:G(Y)))}e.attr("d",g(t,r)),$(d,r)}function $(t,e){(I||N)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var a=H(I?e.xanchor:i.midRange(r?[e.x0,e.x1]:h.extractPathCoords(e.path,f.paramIsX))),o=q(N?e.yanchor:i.midRange(r?[e.y0,e.y1]:h.extractPathCoords(e.path,f.paramIsY)));if(a=h.roundPositionForSharpStrokeRendering(a,1),o=h.roundPositionForSharpStrokeRendering(o,1),I&&N){var s="M"+(a-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",s)}else if(I){var l="M"+(a-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",l)}else{var u="M"+(a-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",u)}}()}function K(t){t.selectAll(".visual-cue").remove()}u.init(Y),X.node().onmousemove=Z}(t,b,r,e,d)}}function p(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");t.call(s.setClipUrl,n?"clip"+e._fullLayout._uid+n:null)}function g(t,e){var r,n,o,s,l,u,c,d,p=e.type,g=a.getFromId(t,e.xref),v=a.getFromId(t,e.yref),m=t._fullLayout._size;if(g?(r=h.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return m.l+m.w*t},v?(o=h.shapePositionToRange(v),s=function(t){return v._offset+v.r2p(o(t,!0))}):s=function(t){return m.t+m.h*(1-t)},"path"===p)return g&&"date"===g.type&&(n=h.decodeDate(n)),v&&"date"===v.type&&(s=h.decodeDate(s)),function(t,e,r){var n=t.path,a=t.xsizemode,o=t.ysizemode,s=t.xanchor,l=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,u=t.charAt(0),c=f.paramIsX[u],h=f.paramIsY[u],d=f.numParams[u],p=t.substr(1).replace(f.paramRE,function(t){return c[n]?t="pixel"===a?e(s)+Number(t):e(t):h[n]&&(t="pixel"===o?r(l)-Number(t):r(t)),++n>d&&(t="X"),t});return n>d&&(p=p.replace(/[\s,]*X.*/,""),i.log("Ignoring extra params in segment "+t)),u+p})}(e,n,s);if("pixel"===e.xsizemode){var y=n(e.xanchor);l=y+e.x0,u=y+e.x1}else l=n(e.x0),u=n(e.x1);if("pixel"===e.ysizemode){var b=s(e.yanchor);c=b-e.y0,d=b-e.y1}else c=s(e.y0),d=s(e.y1);if("line"===p)return"M"+l+","+c+"L"+u+","+d;if("rect"===p)return"M"+l+","+c+"H"+u+"V"+d+"H"+l+"Z";var x=(l+u)/2,_=(c+d)/2,w=Math.abs(x-l),M=Math.abs(_-c),A="A"+w+","+M,T=x+w+","+_;return"M"+T+A+" 0 1,1 "+(x+","+(_-M))+A+" 0 0,1 "+T+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,i=t.charAt(0),a=f.paramIsX[i],o=f.paramIsY[i],s=f.numParams[i];return i+t.substr(1).replace(f.paramRE,function(t){return n>=s?t:(a[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var i=0;i0&&(s=s.transition().duration(e.transition.duration).ease(e.transition.easing)),s.attr("transform","translate("+(o-.5*f.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function S(t,e){var r=t._dims;return r.inputAreaStart+f.stepInset+(r.inputAreaLength-2*f.stepInset)*Math.min(1,Math.max(0,e))}function L(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-f.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*f.stepInset-2*r.inputAreaStart)))}function C(t,e,r){var n=r._dims,i=s.ensureSingle(t,"rect",f.railTouchRectClass,function(n){n.call(T,e,t,r).style("pointer-events","all")});i.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,f.tickOffset+r.ticklen+n.labelHeight)}).call(a.fill,r.bgcolor).attr("opacity",0),o.setTranslate(i,0,n.currentValueTotalHeight)}function O(t,e){var r=e._dims,n=r.inputAreaLength-2*f.railInset,i=s.ensureSingle(t,"rect",f.railRectClass);i.attr({width:n,height:f.railWidth,rx:f.railRadius,ry:f.railRadius,"shape-rendering":"crispEdges"}).call(a.stroke,e.bordercolor).call(a.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(i,f.railInset,.5*(r.inputAreaWidth-f.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[f.name],n=[],i=0;i0?[0]:[]);function s(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),i.autoMargin(t,v(e))}if(a.enter().append("g").classed(f.containerClassName,!0).style("cursor","ew-resize"),a.exit().each(function(){n.select(this).selectAll("g."+f.groupClassName).each(s)}).remove(),0!==r.length){var l=a.selectAll("g."+f.groupClassName).data(r,m);l.enter().append("g").classed(f.groupClassName,!0),l.exit().each(s).remove();for(var u=0;u0||h<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[y.side];e.attr("transform","translate("+g+")")}}}R.call(P),C&&(L?R.on(".opacity",null):(E=0,S=!0,R.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),R.call(c.makeEditable,{gd:t}).on("edit",function(e){void 0!==m?o.call("restyle",t,g,e,m):o.call("relayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(P)}).on("input",function(t){this.text(t||" ").call(c.positionText,b.x,b.y)}));return R.classed("js-placeholder",S),_}};var h=/ [XY][0-9]* /},{"../../constants/interactions":477,"../../lib":498,"../../lib/svg_text_utils":521,"../../plots/plots":589,"../../registry":597,"../color":376,"../drawing":401,d3:82,"fast-isnumeric":91}],468:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes"),l=t("../../plot_api/plot_template").templatedArray,u=l("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(l("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:u,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:a({},s,{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":490,"../../plot_api/edit_types":527,"../../plot_api/plot_template":534,"../../plots/font_attributes":571,"../../plots/pad_attributes":588,"../color/attributes":375}],469:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],470:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/array_container_defaults"),a=t("./attributes"),o=t("./constants").name,s=a.buttons;function l(t,e,r){function o(r,i){return n.coerce(t,e,a,r,i)}o("visible",i(t,e,{name:"buttons",handleItemDefaults:u}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function u(t,e){function r(r,i){return n.coerce(t,e,s,r,i)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){i(t,e,{name:o,handleItemDefaults:l})}},{"../../lib":498,"../../plots/array_container_defaults":540,"./attributes":468,"./constants":469}],471:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plots/plots"),a=t("../color"),o=t("../drawing"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../legend/anchor_utils"),c=t("../../plot_api/plot_template").arrayEditor,f=t("../../constants/alignment").LINE_SPACING,h=t("./constants"),d=t("./scrollbox");function p(t){return t._index}function g(t,e){return+t.attr(h.menuIndexAttrName)===e._index}function v(t,e,r,n,i,a,o,s){e.active=o,c(t.layout,h.name,e).applyUpdate("active",o),"buttons"===e.type?y(t,n,null,null,e):"dropdown"===e.type&&(i.attr(h.menuIndexAttrName,"-1"),m(t,n,i,a,e),s||y(t,n,i,a,e))}function m(t,e,r,n,i){var a=s.ensureSingle(e,"g",h.headerClassName,function(t){t.style("pointer-events","all")}),l=i._dims,u=i.active,c=i.buttons[u]||h.blankHeaderOpts,f={y:i.pad.t,yPad:0,x:i.pad.l,xPad:0,index:0},d={width:l.headerWidth,height:l.headerHeight};a.call(b,i,c,t).call(E,i,f,d),s.ensureSingle(e,"text",h.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,i.font).text(h.arrowSymbol[i.direction])}).attr({x:l.headerWidth-h.arrowOffsetX+i.pad.l,y:l.headerHeight/2+h.textOffsetY+i.pad.t}),a.on("click",function(){r.call(S,String(g(r,i)?-1:i._index)),y(t,e,r,n,i)}),a.on("mouseover",function(){a.call(M)}),a.on("mouseout",function(){a.call(A,i)}),o.setTranslate(e,l.lx,l.ly)}function y(t,e,r,a,o){r||(r=e).attr("pointer-events","all");var l=function(t){return-1==+t.attr(h.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,u="dropdown"===o.type?h.dropdownButtonClassName:h.buttonClassName,c=r.selectAll("g."+u).data(s.filterVisible(l)),f=c.enter().append("g").classed(u,!0),d=c.exit();"dropdown"===o.type?(f.attr("opacity","0").transition().attr("opacity","1"),d.transition().attr("opacity","0").remove()):d.remove();var p=0,g=0,m=o._dims,y=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(y?g=m.headerHeight+h.gapButtonHeader:p=m.headerWidth+h.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(g=-h.gapButtonHeader+h.gapButton-m.openHeight),"dropdown"===o.type&&"left"===o.direction&&(p=-h.gapButtonHeader+h.gapButton-m.openWidth);var x={x:m.lx+p+o.pad.l,y:m.ly+g+o.pad.t,yPad:h.gapButton,xPad:h.gapButton,index:0},_={l:x.x+o.borderwidth,t:x.y+o.borderwidth};c.each(function(s,l){var u=n.select(this);u.call(b,o,s,t).call(E,o,x),u.on("click",function(){n.event.defaultPrevented||(v(t,o,0,e,r,a,l),s.execute&&i.executeAPICommand(t,s.method,s.args),t.emit("plotly_buttonclicked",{menu:o,button:s,active:o.active}))}),u.on("mouseover",function(){u.call(M)}),u.on("mouseout",function(){u.call(A,o),c.call(w,o)})}),c.call(w,o),y?(_.w=Math.max(m.openWidth,m.headerWidth),_.h=x.y-_.t):(_.w=x.x-_.l,_.h=Math.max(m.openHeight,m.headerHeight)),_.direction=o.direction,a&&(c.size()?function(t,e,r,n,i,a){var o,s,l,u=i.direction,c="up"===u||"down"===u,f=i._dims,d=i.active;if(c)for(s=0,l=0;l0?[0]:[]);if(o.enter().append("g").classed(h.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+h.headerGroupClassName).each(a)}).remove(),0!==r.length){var l=o.selectAll("g."+h.headerGroupClassName).data(r,p);l.enter().append("g").classed(h.headerGroupClassName,!0);for(var u=s.ensureSingle(o,"g",h.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),c=0;cw,T=s.barLength+2*s.barPad,k=s.barWidth+2*s.barPad,E=p,S=v+m;S+k>u&&(S=u-k);var L=this.container.selectAll("rect.scrollbar-horizontal").data(A?[0]:[]);L.exit().on(".drag",null).remove(),L.enter().append("rect").classed("scrollbar-horizontal",!0).call(i.fill,s.barColor),A?(this.hbar=L.attr({rx:s.barRadius,ry:s.barRadius,x:E,y:S,width:T,height:k}),this._hbarXMin=E+T/2,this._hbarTranslateMax=w-T):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var C=m>M,O=s.barWidth+2*s.barPad,R=s.barLength+2*s.barPad,P=p+g,z=v;P+O>l&&(P=l-O);var I=this.container.selectAll("rect.scrollbar-vertical").data(C?[0]:[]);I.exit().on(".drag",null).remove(),I.enter().append("rect").classed("scrollbar-vertical",!0).call(i.fill,s.barColor),C?(this.vbar=I.attr({rx:s.barRadius,ry:s.barRadius,x:P,y:z,width:O,height:R}),this._vbarYMin=z+R/2,this._vbarTranslateMax=M-R):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var N=this.id,D=c-.5,F=C?f+O+.5:f+.5,j=h-.5,B=A?d+k+.5:d+.5,U=o._topdefs.selectAll("#"+N).data(A||C?[0]:[]);if(U.exit().remove(),U.enter().append("clipPath").attr("id",N).append("rect"),A||C?(this._clipRect=U.select("rect").attr({x:Math.floor(D),y:Math.floor(j),width:Math.ceil(F)-Math.floor(D),height:Math.ceil(B)-Math.floor(j)}),this.container.call(a.setClipUrl,N),this.bg.attr({x:p,y:v,width:g,height:m})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),A||C){var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(V);var H=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));A&&this.hbar.on(".drag",null).call(H),C&&this.vbar.on(".drag",null).call(H)}this.setTranslate(e,r)},s.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},s.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},s.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},s.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,i=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,i)-r)/(i-r)*(this.position.w-this._box.w)}if(this.vbar){var a=e+this._vbarYMin,s=a+this._vbarTranslateMax;e=(o.constrain(n.event.y,a,s)-a)/(s-a)*(this.position.h-this._box.h)}this.setTranslate(t,e)},s.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(a.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var i=t/r;this.hbar.call(a.setTranslate,t+i*this._hbarTranslateMax,e)}if(this.vbar){var s=e/n;this.vbar.call(a.setTranslate,t,e+s*this._vbarTranslateMax)}}},{"../../lib":498,"../color":376,"../drawing":401,d3:82}],474:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],475:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],476:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],477:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],478:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],479:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],480:[function(t,e,r){"use strict";r.version="1.42.5",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config");for(var n=t("./registry"),i=r.register=n.register,a=t("./plot_api"),o=Object.keys(a),s=0;ss-1e-15}function u(t,e){return a(e-t,s)}function c(t,e){if(l(e))return!0;var r,n;e[0](n=i(n,s))&&(n+=s);var a=i(t,s),o=a+s;return a>=r&&a<=n||o>=r&&o<=n}function f(t,e,r,n,i,a,u){i=i||0,a=a||0;var c,f,h,d,p,g=l([r,n]);function v(t,e){return[t*Math.cos(e)+i,a-t*Math.sin(e)]}g?(c=0,f=o,h=s):r=i&&t<=a);var i,a},pathArc:function(t,e,r,n,i){return f(null,t,e,r,n,i,0)},pathSector:function(t,e,r,n,i){return f(null,t,e,r,n,i,1)},pathAnnulus:function(t,e,r,n,i,a){return f(t,e,r,n,i,a,1)}}},{"./mod":505}],483:[function(t,e,r){"use strict";var n=Array.isArray,i="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},a="undefined"==typeof DataView?function(){}:DataView;function o(t){return i.isView(t)&&!(t instanceof a)}function s(t){return n(t)||o(t)}r.isTypedArray=o,r.isArrayOrTypedArray=s,r.isArray1D=function(t){return!s(t[0])},r.ensureArray=function(t,e){return n(t)||(t=[]),t.length=e,t},r.concat=function(){var t,e,r,i,a,o,s,l,u=[],c=!0,f=0;for(r=0;ri.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var i="number"==typeof t;!0!==n.strict&&i?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return i(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(c(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var i=n.regex||l(r);"string"==typeof t&&i.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!l(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var i=t.split("+"),a=0;a=n&&t<=i?t:c}if("string"!=typeof t&&"number"!=typeof t)return c;t=String(t);var u=_(e),m=t.charAt(0);!u||"G"!==m&&"g"!==m||(t=t.substr(1),e="");var w=u&&"chinese"===e.substr(0,7),M=t.match(w?b:y);if(!M)return c;var A=M[1],T=M[3]||"1",k=Number(M[5]||1),E=Number(M[7]||0),S=Number(M[9]||0),L=Number(M[11]||0);if(u){if(2===A.length)return c;var C;A=Number(A);try{var O=v.getComponentMethod("calendars","getCal")(e);if(w){var R="i"===T.charAt(T.length-1);T=parseInt(T,10),C=O.newDate(A,O.toMonthIndex(A,T,R),k)}else C=O.newDate(A,Number(T),k)}catch(t){return c}return C?(C.toJD()-g)*f+E*h+S*d+L*p:c}A=2===A.length?(Number(A)+2e3-x)%100+x:Number(A),T-=1;var P=new Date(Date.UTC(2e3,T,k,E,S));return P.setUTCFullYear(A),P.getUTCMonth()!==T?c:P.getUTCDate()!==k?c:P.getTime()+L*p},n=r.MIN_MS=r.dateTime2ms("-9999"),i=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==c};var M=90*f,A=3*h,T=5*d;function k(t,e,r,n,i){if((e||r||n||i)&&(t+=" "+w(e,2)+":"+w(r,2),(n||i)&&(t+=":"+w(n,2),i))){for(var a=4;i%10==0;)a-=1,i/=10;t+="."+w(i,a)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=i))return c;e||(e=0);var a,o,s,u,y,b,x=Math.floor(10*l(t+.05,1)),w=Math.round(t-x/10);if(_(r)){var E=Math.floor(w/f)+g,S=Math.floor(l(t,f));try{a=v.getComponentMethod("calendars","getCal")(r).fromJD(E).formatDate("yyyy-mm-dd")}catch(t){a=m("G%Y-%m-%d")(new Date(w))}if("-"===a.charAt(0))for(;a.length<11;)a="-0"+a.substr(1);else for(;a.length<10;)a="0"+a;o=e=n+f&&t<=i-f))return c;var e=Math.floor(10*l(t+.05,1)),r=new Date(Math.round(t-e/10));return k(a.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===c)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return s.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return s.error("unrecognized date",t),e;return t};var E=/%\d?f/g;function S(t,e,r,n){t=t.replace(E,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var i=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(i)}var L=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,i,a){if(i=_(i)&&i,!e)if("y"===r)e=a.year;else if("m"===r)e=a.month;else{if("d"!==r)return function(t,e){var r=l(t+.05,f),n=w(Math.floor(r/h),2)+":"+w(l(Math.floor(r/d),60),2);if("M"!==e){o(e)||(e=0);var i=(100+Math.min(l(t/p,60),L[e])).toFixed(e).substr(1);e>0&&(i=i.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+i}return n}(t,r)+"\n"+S(a.dayMonthYear,t,n,i);e=a.dayMonth+"\n"+a.year}return S(e,t,n,i)};var C=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=l(t,f);if(t=Math.round(t-n),r)try{var i=Math.round(t/f)+g,a=v.getComponentMethod("calendars","getCal")(r),o=a.fromJD(i);return e%12?a.add(o,e,"m"):a.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){s.error("invalid ms "+t+" in calendar "+r)}var u=new Date(t+C);return u.setUTCMonth(u.getUTCMonth()+e)+n-C},r.findExactDates=function(t,e){for(var r,n,i=0,a=0,s=0,l=0,u=_(e)&&v.getComponentMethod("calendars","getCal")(e),c=0;c1||g<0||g>1?null:{x:t+l*g,y:e+f*g}}function l(t,e,r,n,i){var a=n*t+i*e;if(a<0)return n*n+i*i;if(a>r){var o=n-t,s=i-e;return o*o+s*s}var l=n*e-i*t;return l*l/r}r.segmentsIntersect=s,r.segmentDistance=function(t,e,r,n,i,a,o,u){if(s(t,e,r,n,i,a,o,u))return 0;var c=r-t,f=n-e,h=o-i,d=u-a,p=c*c+f*f,g=h*h+d*d,v=Math.min(l(c,f,p,i-t,a-e),l(c,f,p,o-t,u-e),l(h,d,g,t-i,e-a),l(h,d,g,r-i,n-a));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,s){if(t===i&&s===a||(n={},i=t,a=s),n[r])return n[r];var l=t.getPointAtLength(o(r-s/2,e)),u=t.getPointAtLength(o(r+s/2,e)),c=Math.atan((u.y-l.y)/(u.x-l.x)),f=t.getPointAtLength(o(r,e)),h={x:(4*f.x+l.x+u.x)/6,y:(4*f.y+l.y+u.y)/6,theta:c};return n[r]=h,h},r.clearLocationCache=function(){i=null},r.getVisibleSegment=function(t,e,r){var n,i,a=e.left,o=e.right,s=e.top,l=e.bottom,u=0,c=t.getTotalLength(),f=c;function h(e){var r=t.getPointAtLength(e);0===e?n=r:e===c&&(i=r);var u=r.xo?r.x-o:0,f=r.yl?r.y-l:0;return Math.sqrt(u*u+f*f)}for(var d=h(u);d;){if((u+=d+r)>f)return;d=h(u)}for(d=h(f);d;){if(u>(f-=d+r))return;d=h(f)}return{min:u,max:f,len:f-u,total:c,isClosed:0===u&&f===c&&Math.abs(n.x-i.x)<.1&&Math.abs(n.y-i.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var i,a,o,s=(n=n||{}).pathLength||t.getTotalLength(),l=n.tolerance||.001,u=n.iterationLimit||30,c=t.getPointAtLength(0)[r]>t.getPointAtLength(s)[r]?-1:1,f=0,h=0,d=s;f0?d=i:h=i,f++}return a}},{"./mod":505}],494:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],495:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("color-normalize"),o=t("../components/colorscale"),s=t("../components/color/attributes").defaultLine,l=t("./array").isArrayOrTypedArray,u=a(s),c=1;function f(t,e){var r=t;return r[3]*=e,r}function h(t){if(n(t))return u;var e=a(t);return e.length?e:u}function d(t){return n(t)?t:c}e.exports={formatColor:function(t,e,r){var n,i,s,p,g,v=t.color,m=l(v),y=l(e),b=[];if(n=void 0!==t.colorscale?o.makeColorScaleFunc(o.extractScale(t.colorscale,t.cmin,t.cmax)):h,i=m?function(t,e){return void 0===t[e]?u:a(n(t[e]))}:h,s=y?function(t,e){return void 0===t[e]?c:d(t[e])}:d,m||y)for(var x=0;x/g,"")}(function(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(r/g,"\n"))))}},{"./svg_text_utils":521,"superscript-text":340}],497:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],498:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../constants/numerical"),o=a.FP_SAFE,s=a.BADNUM,l=e.exports={};l.nestedProperty=t("./nested_property"),l.keyedContainer=t("./keyed_container"),l.relativeAttr=t("./relative_attr"),l.isPlainObject=t("./is_plain_object"),l.toLogRange=t("./to_log_range"),l.relinkPrivateKeys=t("./relink_private");var u=t("./array");l.isTypedArray=u.isTypedArray,l.isArrayOrTypedArray=u.isArrayOrTypedArray,l.isArray1D=u.isArray1D,l.ensureArray=u.ensureArray,l.concat=u.concat;var c=t("./mod");l.mod=c.mod,l.modHalf=c.modHalf;var f=t("./coerce");l.valObjectMeta=f.valObjectMeta,l.coerce=f.coerce,l.coerce2=f.coerce2,l.coerceFont=f.coerceFont,l.coerceHoverinfo=f.coerceHoverinfo,l.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,l.validate=f.validate;var h=t("./dates");l.dateTime2ms=h.dateTime2ms,l.isDateTime=h.isDateTime,l.ms2DateTime=h.ms2DateTime,l.ms2DateTimeLocal=h.ms2DateTimeLocal,l.cleanDate=h.cleanDate,l.isJSDate=h.isJSDate,l.formatDate=h.formatDate,l.incrementMonth=h.incrementMonth,l.dateTick0=h.dateTick0,l.dfltRange=h.dfltRange,l.findExactDates=h.findExactDates,l.MIN_MS=h.MIN_MS,l.MAX_MS=h.MAX_MS;var d=t("./search");l.findBin=d.findBin,l.sorterAsc=d.sorterAsc,l.sorterDes=d.sorterDes,l.distinctVals=d.distinctVals,l.roundUp=d.roundUp,l.sort=d.sort,l.findIndexOfMin=d.findIndexOfMin;var p=t("./stats");l.aggNums=p.aggNums,l.len=p.len,l.mean=p.mean,l.midRange=p.midRange,l.variance=p.variance,l.stdev=p.stdev,l.interp=p.interp;var g=t("./matrix");l.init2dArray=g.init2dArray,l.transposeRagged=g.transposeRagged,l.dot=g.dot,l.translationMatrix=g.translationMatrix,l.rotationMatrix=g.rotationMatrix,l.rotationXYMatrix=g.rotationXYMatrix,l.apply2DTransform=g.apply2DTransform,l.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");l.deg2rad=v.deg2rad,l.rad2deg=v.rad2deg,l.angleDelta=v.angleDelta,l.angleDist=v.angleDist,l.isFullCircle=v.isFullCircle,l.isAngleInsideSector=v.isAngleInsideSector,l.isPtInsideSector=v.isPtInsideSector,l.pathArc=v.pathArc,l.pathSector=v.pathSector,l.pathAnnulus=v.pathAnnulus;var m=t("./geometry2d");l.segmentsIntersect=m.segmentsIntersect,l.segmentDistance=m.segmentDistance,l.getTextLocation=m.getTextLocation,l.clearLocationCache=m.clearLocationCache,l.getVisibleSegment=m.getVisibleSegment,l.findPointOnPath=m.findPointOnPath;var y=t("./extend");l.extendFlat=y.extendFlat,l.extendDeep=y.extendDeep,l.extendDeepAll=y.extendDeepAll,l.extendDeepNoArrays=y.extendDeepNoArrays;var b=t("./loggers");l.log=b.log,l.warn=b.warn,l.error=b.error;var x=t("./regex");l.counterRegex=x.counter;var _=t("./throttle");function w(t){var e={};for(var r in t)for(var n=t[r],i=0;io?s:i(t)?Number(t):s:s},l.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(i(t)&&t>=0&&t%1==0)},l.noop=t("./noop"),l.identity=t("./identity"),l.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},l.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},l.simpleMap=function(t,e,r,n){for(var i=t.length,a=new Array(i),o=0;o=Math.pow(2,r)?i>10?(l.warn("randstr failed uniqueness"),u):t(e,r,n,(i||0)+1):u},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,u=new Array(l),c=new Array(o);for(r=0;r=s&&(i-=s*Math.floor(i/s)),i<0?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*u[n];c[r]=a}return c},l.syncOrAsync=function(t,e,r){var n;function i(){return l.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(i).then(void 0,l.promiseError);return r&&r(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,r){if(t){var n,i=!1,a=!0;for(n=0;n1?i+o[1]:"";if(a&&(o.length>1||s.length>4||r))for(;n.test(s);)s=s.replace(n,"$1"+a+"$2");return s+l};var T=/%{([^\s%{}]*)}/g,k=/^\w*$/;l.templateString=function(t,e){var r={};return t.replace(T,function(t,n){return k.test(n)?e[n]||"":(r[n]=r[n]||l.nestedProperty(e,n).get,r[n]()||"")})};l.subplotSort=function(t,e){for(var r=Math.min(t.length,e.length)+1,n=0,i=0,a=0;a=48&&o<=57,u=s>=48&&s<=57;if(l&&(n=10*n+o-48),u&&(i=10*i+s-48),!l||!u){if(n!==i)return n-i;if(o!==s)return o-s}}return i-n};var E=2e9;l.seedPseudoRandom=function(){E=2e9},l.pseudoRandom=function(){var t=E;return E=(69069*E+1)%4294967296,Math.abs(E-t)<429496729?l.pseudoRandom():E/4294967296}},{"../constants/numerical":478,"./angles":482,"./array":483,"./clean_number":484,"./clear_responsive":486,"./coerce":487,"./dates":488,"./extend":490,"./filter_unique":491,"./filter_visible":492,"./geometry2d":493,"./get_graph_div":494,"./identity":497,"./is_plain_object":499,"./keyed_container":500,"./localize":501,"./loggers":502,"./make_trace_groups":503,"./matrix":504,"./mod":505,"./nested_property":506,"./noop":507,"./notifier":508,"./push_unique":511,"./regex":513,"./relative_attr":514,"./relink_private":515,"./search":516,"./stats":519,"./throttle":522,"./to_log_range":523,d3:82,"fast-isnumeric":91}],499:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],500:[function(t,e,r){"use strict";var n=t("./nested_property"),i=/^\w*$/;e.exports=function(t,e,r,a){var o,s,l;r=r||"name",a=a||"value";var u={};e&&e.length?(l=n(t,e),s=l.get()):s=t,e=e||"";var c={};if(s)for(o=0;o2)return u[e]=2|u[e],h.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],506:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,a,o,l=0,u=e.split(".");l/g),o=0;oa||u===i||us||e&&l(t))}:function(t,e){var l=t[0],u=t[1];if(l===i||la||u===i||us)return!1;var c,f,h,d,p,g=r.length,v=r[0][0],m=r[0][1],y=0;for(c=1;cMath.max(f,v)||u>Math.max(h,m)))if(uc||Math.abs(n(o,h))>i)return!0;return!1};a.filter=function(t,e){var r=[t[0]],n=0,i=0;function a(a){t.push(a);var s=r.length,l=n;r.splice(i+1);for(var u=l+1;u1&&a(t.pop());return{addPt:a,raw:t,filtered:r}}},{"../constants/numerical":478,"./matrix":504}],511:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ri.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function u(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var a,c,f=0,h=e.length,d=0,p=h>1?(e[h-1]-e[0])/(h-1):1;for(c=p>=0?r?o:s:r?u:l,t+=1e-9*p*(r?-1:1)*(p>=0?1:-1);f90&&i.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;se[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,u=r?Math.ceil:Math.floor;i0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||a;for(var r,n=1/0,i=0;ia.length)&&(o=a.length),n(e)||(e=!1),i(a[0])){for(l=new Array(o),s=0;st.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":483,"fast-isnumeric":91}],520:[function(t,e,r){"use strict";var n=t("color-normalize");e.exports=function(t){return t?n(t):[0,0,0,1]}},{"color-normalize":63}],521:[function(t,e,r){"use strict";var n=t("d3"),i=t("../lib"),a=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function s(t,e){return t.node().getBoundingClientRect()[e]}var l=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var E=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&E.match(l),C=n.select(t.node().parentNode);if(!C.empty()){var O=t.attr("class")?t.attr("class").split(" ")[0]:"text";return O+="-math",C.selectAll("svg."+O).remove(),C.selectAll("g."+O+"-group").remove(),t.style("display",null).attr({"data-unformatted":E,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),a={fontSize:r};!function(t,e,r){var a,o,s,l;MathJax.Hub.Queue(function(){return o=i.extendDeepAll({},MathJax.Hub.config),s=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(a=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+i.randstr({},64);return l=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(u,"\\lt ").replace(c,"\\gt ")),MathJax.Hub.Typeset(l.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(l.select(".MathJax_SVG").empty()||!l.select("svg").node())i.log("There was an error in the tex syntax.",t),r();else{var o=l.select("svg").node().getBoundingClientRect();r(l.select(".MathJax_SVG"),e,o)}if(l.remove(),"SVG"!==a)return MathJax.Hub.setRenderer(a)},function(){return void 0!==s&&(MathJax.Hub.processSectionDelay=s),MathJax.Hub.Config(o)})}(S[2],a,function(n,i,a){C.selectAll("svg."+O).remove(),C.selectAll("g."+O+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return R(),void e();var l=C.append("g").classed(O+"-group",!0).attr({"pointer-events":"none","data-unformatted":E,"data-math":"Y"});l.node().appendChild(o.node()),i&&i.node()&&o.node().insertBefore(i.node().cloneNode(!0),o.node().firstChild),o.attr({class:O,height:a.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=t.node().style.fill||"black";o.select("g").attr({fill:u,stroke:u});var c=s(o,"width"),f=s(o,"height"),h=+t.attr("x")-c*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],d=-(r||s(t,"height"))/4;"y"===O[0]?(l.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-c/2,d-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===O[0]?o.attr({x:t.attr("x"),y:d-f/2}):"a"===O[0]?o.attr({x:0,y:d}):o.attr({x:h,y:+t.attr("y")+d-f/2}),v&&v.call(t,l),e(l)})})):R(),t}function R(){C.empty()||(O=t.attr("class")+"-math",C.select("svg."+O).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(m," ");var r,s=!1,l=[],u=-1;function c(){u++;var e=document.createElementNS(a.svg,"tspan");n.select(e).attr({class:"line",dy:u*o+"em"}),t.appendChild(e),r=e;var i=l;if(l=[{node:e}],i.length>1)for(var s=1;s doesnt match end tag <"+t+">. Pretending it did match.",e),r=l[l.length-1].node}else i.log("Ignoring unexpected end tag .",e)}x.test(e)?c():(r=t,l=[{node:t}]);for(var C=e.split(y),O=0;O|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},h={sub:"0.3em",sup:"-0.6em"},d={sub:"-0.21em",sup:"0.42em"},p="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),m=/(\r\n?|\n)/g,y=/(<[^<>]*>)/,b=/<(\/?)([^ >]*)(\s+(.*))?>/i,x=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,M=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,A=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function T(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&L(n)}var k=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var E={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function L(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):E[e])||t})}function C(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),u=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-u.top+"px",left:a()-u.left+"px","z-index":1e3}),this}}r.convertEntities=L,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function i(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var a=i("x",e),o=i("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:a,y:o})})},r.makeEditable=function(t,e){var r=e.gd,i=e.delegate,a=n.dispatch("edit","input","cancel"),o=i||t;if(t.style({"pointer-events":i?"none":"all"}),1!==t.size())throw new Error("boo");function s(){!function(){var i=n.select(r).select(".svg-container"),o=i.append("div"),s=t.node().style,u=parseFloat(s.fontSize||12),c=e.text;void 0===c&&(c=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":s.fontFamily||"Arial","font-size":u,color:e.fill||s.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-u/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(c).call(C(t,i,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,i=n.select(this).attr("class");(e=i?"."+i.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),a.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),a.cancel.call(t,this.textContent)):(a.input.call(t,this.textContent),n.select(this).call(C(t,i,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(l)}(),t.style({opacity:0});var i,s=o.attr("class");(i=s?"."+s.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(i).style({opacity:0})}function l(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?s():o.on("click",s),n.rebind(t,a,"on")}},{"../constants/alignment":474,"../constants/xmlns_namespaces":479,"../lib":498,d3:82}],522:[function(t,e,r){"use strict";var n={};function i(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var a=n[t],o=Date.now();if(!a){for(var s in n)n[s].tsa.ts+e?l():a.timer=setTimeout(function(){l(),a.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)i(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],523:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":91}],524:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],525:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],526:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,i=n.layoutArrayContainers,a=n.layoutArrayRegexes,o=t.split("[")[0],s=0;s0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var n=(s.subplotsRegistry.cartesian||{}).attrRegex,a=(s.subplotsRegistry.gl3d||{}).attrRegex,l=Object.keys(t);for(e=0;e3?(k.x=1.02,k.xanchor="left"):k.x<-2&&(k.x=-.02,k.xanchor="right"),k.y>3?(k.y=1.02,k.yanchor="bottom"):k.y<-2&&(k.y=-.02,k.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=y(e);r;){if(r in t)return!0;r=y(r)}return!1};var b=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&o.warn("Full array edits are incompatible with other edits",f);var y=r[""][""];if(c(y))e.set(null);else{if(!Array.isArray(y))return o.warn("Unrecognized full array edit value",f,y),!0;e.set(y)}return!g&&(h(v,m),d(t),!0)}var b,x,_,w,M,A,T,k=Object.keys(r).map(Number).sort(s),E=e.get(),S=E||[],L=n(m,f).get(),C=[],O=-1,R=S.length;for(b=0;bS.length-(T?0:1))o.warn("index out of range",f,_);else if(void 0!==A)M.length>1&&o.warn("Insertion & removal are incompatible with edits to the same index.",f,_),c(A)?C.push(_):T?("add"===A&&(A={}),S.splice(_,0,A),L&&L.splice(_,0,{})):o.warn("Unrecognized full object edit value",f,_,A),-1===O&&(O=_);else for(x=0;x=0;b--)S.splice(C[b],1),L&&L.splice(C[b],1);if(S.length?E||e.set(S):e.set(null),g)return!1;if(h(v,m),p!==a){var P;if(-1===O)P=k;else{for(R=Math.max(S.length,R),P=[],b=0;b=O);b++)P.push(_);for(b=O;b=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||i<0&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function P(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),R(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&R(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function z(t,e,r,n,a){!function(t,e,r,n){var i=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var a in R(t,r,"indices"),e){if(!Array.isArray(e[a])||e[a].length!==r.length)throw new Error("attribute "+a+" must be an array of length equal to indices array length");if(i&&(!(a in n)||!Array.isArray(n[a])||n[a].length!==e[a].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var s=function(t,e,r,n){var a,s,l,u,c,f=o.isPlainObject(n),h=[];for(var d in Array.isArray(r)||(r=[r]),r=O(r,t.data.length-1),e)for(var p=0;p=0&&r=0&&r0&&"string"!=typeof L.parts[O];)O--;var R=L.parts[O],P=L.parts[O-1]+"."+R,z=L.parts.slice(0,O).join("."),I=o.nestedProperty(t.layout,z).get(),D=o.nestedProperty(s,z).get(),F=L.get();if(void 0!==C){y[S]=C,b[S]="reverse"===R?C:N(F);var j=c.getLayoutValObject(s,L.parts);if(j&&j.impliedEdits&&null!==C)for(var H in j.impliedEdits)x(o.relativeAttr(S,H),j.impliedEdits[H]);if(-1!==["width","height"].indexOf(S))if(C){x("autosize",null);var G="height"===S?"width":"height";x(G,s[G])}else s[S]=t._initialAutoSize[S];else if("autosize"===S)x("width",C?null:s.width),x("height",C?null:s.height);else if(P.match(B))E(P),o.nestedProperty(s,z+"._inputRange").set(null);else if(P.match(U)){E(P),o.nestedProperty(s,z+"._inputRange").set(null);var W=o.nestedProperty(s,z).get();W._inputDomain&&(W._input.domain=W._inputDomain.slice())}else P.match(V)&&o.nestedProperty(s,z+"._inputDomain").set(null);if("type"===R){var X=I,Y="linear"===D.type&&"log"===C,Z="log"===D.type&&"linear"===C;if(Y||Z){if(X&&X.range)if(D.autorange)Y&&(X.range=X.range[1]>X.range[0]?[1,2]:[2,1]);else{var Q=X.range[0],J=X.range[1];Y?(Q<=0&&J<=0&&x(z+".autorange",!0),Q<=0?Q=J/1e6:J<=0&&(J=Q/1e6),x(z+".range[0]",Math.log(Q)/Math.LN10),x(z+".range[1]",Math.log(J)/Math.LN10)):(x(z+".range[0]",Math.pow(10,Q)),x(z+".range[1]",Math.pow(10,J)))}else x(z+".autorange",!0);Array.isArray(s._subplots.polar)&&s._subplots.polar.length&&s[L.parts[0]]&&"radialaxis"===L.parts[1]&&delete s[L.parts[0]]._subplot.viewInitial["radialaxis.range"],u.getComponentMethod("annotations","convertCoords")(t,D,C,x),u.getComponentMethod("images","convertCoords")(t,D,C,x)}else x(z+".autorange",!0),x(z+".range",null);o.nestedProperty(s,z+"._inputRange").set(null)}else if(R.match(T)){var $=o.nestedProperty(s,S).get(),K=(C||{}).type;K&&"-"!==K||(K="linear"),u.getComponentMethod("annotations","convertCoords")(t,$,K,x),u.getComponentMethod("images","convertCoords")(t,$,K,x)}var tt=_.containerArrayMatch(S);if(tt){r=tt.array,n=tt.index;var et=tt.property,rt=(o.nestedProperty(a,r)||[])[n]||{},nt=j||{editType:"calc"};""!==n&&""===et&&(_.isAddVal(C)?b[S]=null:_.isRemoveVal(C)?b[S]=rt:o.warn("unrecognized full object value",e)),A.update(m,nt),h[r]||(h[r]={});var it=h[r][n];it||(it=h[r][n]={}),it[et]=C,delete e[S]}else"reverse"===R?(I.range?I.range.reverse():(x(z+".autorange",!0),I.range=[1,0]),D.autorange?m.calc=!0:m.plot=!0):(s._has("scatter-like")&&s._has("regl")&&"dragmode"===S&&("lasso"===C||"select"===C)&&"lasso"!==F&&"select"!==F?m.plot=!0:j?A.update(m,j):m.calc=!0,L.set(C))}}for(r in h){_.applyContainerArrayChanges(t,o.nestedProperty(a,r),h[r],m)||(m.plot=!0)}var at=s._axisConstraintGroups||[];for(M in k)for(n=0;n=i.length?i[0]:i[t]:i}function l(t){return Array.isArray(a)?t>=a.length?a[0]:a[t]:a}function u(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(a,c){function h(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,f.transition(t,e.frame.data,e.frame.layout,w.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function d(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&h()};e()}var p,g,v=0;function m(t){return Array.isArray(i)?v>=i.length?t.transitionOpts=i[v]:t.transitionOpts=i[0]:t.transitionOpts=i,v++,t}var y=[],b=null==e,x=Array.isArray(e);if(!b&&!x&&o.isPlainObject(e))y.push({type:"object",data:m(o.extendFlat({},e))});else if(b||-1!==["string","number"].indexOf(typeof e))for(p=0;p0&&AA)&&T.push(g);y=T}}y.length>0?function(e){if(0!==e.length){for(var i=0;i=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(c[g]||p[g]||{}).name,m=e[n].name,y=c[v]||p[v];v&&m&&"number"==typeof m&&y&&k<5&&(k++,o.warn('addFrames: overwriting frame "'+(c[v]||p[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===k&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),p[g]={name:g},d.push({frame:f.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:h+n})}d.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(i=d[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!i.name)for(;c[i.name="frame "+t._transitionData._counter++];);if(c[i.name]){for(a=0;a=0;r--)n=e[r],a.push({type:"delete",index:n}),s.unshift({type:"insert",index:n,value:i[n]});var u=f.modifyFrames,c=f.modifyFrames,h=[t,s],d=[t,a];return l&&l.add(t,u,h,c,d),f.modifyFrames(t,a)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return f.cleanPlot([],{},r,e),f.purge(t),s.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":376,"../components/colorbar/connect":378,"../components/drawing":401,"../constants/xmlns_namespaces":479,"../lib":498,"../lib/events":489,"../lib/queue":512,"../lib/svg_text_utils":521,"../plots/cartesian/axes":544,"../plots/cartesian/constants":550,"../plots/cartesian/graph_interact":554,"../plots/plots":589,"../plots/polar/legacy":592,"../registry":597,"./edit_types":527,"./helpers":528,"./manage_arrays":530,"./plot_config":532,"./plot_schema":533,"./subroutines":535,d3:82,"fast-isnumeric":91,"has-hover":250}],532:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],533:[function(t,e,r){"use strict";var n=t("../registry"),i=t("../lib"),a=t("../plots/attributes"),o=t("../plots/layout_attributes"),s=t("../plots/frame_attributes"),l=t("../plots/animation_attributes"),u=t("../plots/polar/legacy/area_attributes"),c=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),h=i.extendFlat,d=i.extendDeepAll,p=i.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",m=[g,v,"_arrayAttrRegexps","_deprecated"];function y(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(b(e[r]))r++;else if(r=a.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!b(o))return!1;t=a[i][o]}else t=a[i]}else t=a}}return t}function b(t){return t===Math.round(t)&&t>=0}function x(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):p(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(p(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=l.length)return!1;i=(r=(n.transformsRegistry[l[c].type]||{}).attributes)&&r[e[2]],s=3}else if("area"===t.type)i=u[o];else{var f=t._module;if(f||(f=(n.modules[t.type||a.type.dflt]||{})._module),!f)return!1;if(!(i=(r=f.attributes)&&r[o])){var h=f.basePlotModule;h&&h.attributes&&(i=h.attributes[o])}i||(i=a[o])}return y(i,e,s)},r.getLayoutValObject=function(t,e){return y(function(t,e){var r,i,a,s,l=t._basePlotModules;if(l){var u;for(r=0;r=i&&(r._input||{})._templateitemname;s&&(o=i);var l,u=e+"["+o+"]";function c(){l={},s&&(l[u]={},l[u][a]=s)}function f(t,e){s?n.nestedProperty(l[u],t).set(e):l[u+"."+t]=e}function h(){var t=l;return c(),t}return c(),{modifyBase:function(t,e){l[t]=e},modifyItem:f,getUpdateObj:h,applyUpdate:function(e,r){e&&f(e,r);var i=h();for(var a in i)n.nestedProperty(t,a).set(i[a])}}}},{"../lib":498,"../plots/attributes":541}],535:[function(t,e,r){"use strict";var n=t("d3"),i=t("../registry"),a=t("../plots/plots"),o=t("../lib"),s=t("../lib/clear_gl_canvases"),l=t("../components/color"),u=t("../components/drawing"),c=t("../components/titles"),f=t("../components/modebar"),h=t("../plots/cartesian/axes"),d=t("../constants/alignment"),p=t("../plots/cartesian/constraints"),g=p.enforce,v=p.clean,m=t("../plots/cartesian/autorange").doAutoRange;function y(t,e,r){for(var n=0;n=t[1]||i[1]<=t[0])&&(a[0]e[0]))return!0}return!1}function b(t){var e,i,a,s,c,p=t._fullLayout,g=p._size,v=g.p,m=h.list(t,"",!0);if(p._paperdiv.style({width:t._context.responsive&&p.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":p.width+"px",height:t._context.responsive&&p.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":p.height+"px"}).selectAll(".main-svg").call(u.setSize,p.width,p.height),t._context.setBackground(t,p.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!p._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function b(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-v-n:e._offset+e._length+v+n:g.t+g.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+v+n:e._offset-v-n:g.l+g.w*(t.position||0)+n%1}for(e=0;eM?c.push({code:"unused",traceType:y,templateCount:w,dataCount:M}):M>w&&c.push({code:"reused",traceType:y,templateCount:w,dataCount:M})}}else c.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var a=e[n],o=d(e,n,r);i(a)?(Array.isArray(e)&&!1===a._template&&a.templateitemname&&c.push({code:"missing",path:o,templateitemname:a.templateitemname}),t(a,o)):Array.isArray(a)&&p(a)&&t(a,o)}}({data:v,layout:h},""),c.length)return c.map(g)}},{"../lib":498,"../plots/attributes":541,"../plots/plots":589,"./plot_config":532,"./plot_schema":533,"./plot_template":534}],537:[function(t,e,r){"use strict";var n=t("./plot_api"),i=t("../lib"),a=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),s=t("../snapshot/svgtoimg"),l={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},u=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,c,f;function h(t){return!(t in e)||i.validate(e[t],l[t])}if(e=e||{},i.isPlainObject(t)?(r=t.data||[],c=t.layout||{},f=t.config||{}):(t=i.getGraphDiv(t),r=i.extendDeep([],t.data),c=i.extendDeep({},t.layout),f=t._context),!h("width")||!h("height"))throw new Error("Height and width should be pixel values.");if(!h("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var d={};function p(t,r){return i.coerce(e,d,l,t,r)}var g=p("format"),v=p("width"),m=p("height"),y=p("scale"),b=p("setBackground"),x=p("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=i.extendFlat({},c);v&&(w.width=v),m&&(w.height=m);var M=i.extendFlat({},f,{staticPlot:!0,setBackground:b}),A=a.getRedrawFunc(_);function T(){return new Promise(function(t){setTimeout(t,a.getDelay(_._fullLayout))})}function k(){return new Promise(function(t,e){var r=o(_,g,y),a=_._fullLayout.width,l=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(x?r:"data:image/svg+xml,"+encodeURIComponent(r));var u=document.createElement("canvas");u.id=i.randstr(),s({format:g,width:a,height:l,scale:y,canvas:u,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,M).then(A).then(T).then(k).then(function(e){t(function(t){return x?t.replace(u,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":498,"../snapshot/helpers":601,"../snapshot/svgtoimg":603,"../snapshot/tosvg":605,"./plot_api":531}],538:[function(t,e,r){"use strict";var n=t("../lib"),i=t("../plots/plots"),a=t("./plot_schema"),o=t("./plot_config"),s=n.isPlainObject,l=Array.isArray,u=n.isArrayOrTypedArray;function c(t,e,r,i,a,o){o=o||[];for(var f=Object.keys(t),h=0;hb.length&&i.push(d("unused",a,m.concat(b.length)));var A,T,k,E,S,L=b.length,C=Array.isArray(M);if(C&&(L=Math.min(L,M.length)),2===x.dimensions)for(T=0;Tb[T].length&&i.push(d("unused",a,m.concat(T,b[T].length)));var O=b[T].length;for(A=0;A<(C?Math.min(O,M[T].length):O);A++)k=C?M[T][A]:M,E=y[T][A],S=b[T][A],n.validate(E,k)?S!==E&&S!==+E&&i.push(d("dynamic",a,m.concat(T,A),E,S)):i.push(d("value",a,m.concat(T,A),E))}else i.push(d("array",a,m.concat(T),y[T]));else for(T=0;T1&&h.push(d("object","layout"))),i.supplyDefaults(p);for(var g=p._fullData,v=r.length,m=0;m0&&((x=T-o(v)-o(m))>k?_/x>E&&(y=v,b=m,E=_/x):_/T>E&&(y={val:v.val,pad:0},b={val:m.val,pad:0},E=_/T));if(h===d){var S=h-1,L=h+1;if(M)if(0===h)a=[0,1];else{var C=(h>0?f:c).reduce(function(t,e){return Math.max(t,o(e))},0),O=h/(1-Math.min(.5,C/T));a=h>0?[0,O]:[O,0]}else a=A?[Math.max(0,S),Math.max(1,L)]:[S,L]}else M?(y.val>=0&&(y={val:0,pad:0}),b.val<=0&&(b={val:0,pad:0})):A&&(y.val-E*o(y)<0&&(y={val:0,pad:0}),b.val<=0&&(b={val:1,pad:0})),E=(b.val-y.val)/(T-o(y)-o(b)),a=[y.val-E*o(y),b.val+E*o(b)];return p&&a.reverse(),i.simpleMap(a,e.l2r||Number)}function s(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function l(t,e){var r,n,i,a=e._id,o=t._fullData,s=t._fullLayout,l=[],f=[];function h(t,e){for(r=0;r=r&&(u.extrapad||!o)){s=!1;break}i(e,u.val)&&u.pad<=r&&(o||!u.extrapad)&&(t.splice(l,1),l--)}if(s){var c=a&&0===e;t.push({val:e,pad:c?0:r,extrapad:!c&&o})}}function h(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:o,makePadFn:s,doAutoRange:function(t,e){e._length||e.setScale();var r;e.autorange&&(e.range=o(t,e),e._r=e.range.slice(),e._rl=i.simpleMap(e._r,e.r2l),(r=e._input).range=e.range.slice(),r.autorange=e.autorange);if(e._anchorAxis&&e._anchorAxis.rangeslider){var n=e._anchorAxis.rangeslider[e._name];n&&"auto"===n.rangemode&&(n.range=o(t,e)),(r=e._anchorAxis._input).rangeslider[e._name]=i.extendFlat({},n)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var i,o,s,l,f,d,p,g,v,m=[],y=[],b=e.length,x=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,M=!1;function A(t){if(Array.isArray(t))return M=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var T=A((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),k=A((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),E=A(r.vpadplus||r.vpad),S=A(r.vpadminus||r.vpad);if(!M){if(g=1/0,v=-1/0,w)for(i=0;i0&&(g=o),o>v&&o-a&&(g=o),o>v&&o=O;i--)C(i);return{min:m,max:y}},concatExtremes:l}},{"../../constants/numerical":478,"../../lib":498,"fast-isnumeric":91}],544:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../../components/titles"),c=t("../../components/color"),f=t("../../components/drawing"),h=t("./layout_attributes"),d=t("./clean_ticks"),p=t("../../constants/numerical"),g=p.ONEAVGYEAR,v=p.ONEAVGMONTH,m=p.ONEDAY,y=p.ONEHOUR,b=p.ONEMIN,x=p.ONESEC,_=p.MINUS_SIGN,w=p.BADNUM,M=t("../../constants/alignment").MID_SHIFT,A=t("../../constants/alignment").LINE_SPACING,T=e.exports={};T.setConvert=t("./set_convert");var k=t("./axis_autotype"),E=t("./axis_ids");T.id2name=E.id2name,T.name2id=E.name2id,T.cleanId=E.cleanId,T.list=E.list,T.listIds=E.listIds,T.getFromId=E.getFromId,T.getFromTrace=E.getFromTrace;var S=t("./autorange");T.getAutoRange=S.getAutoRange,T.findExtremes=S.findExtremes,T.coerceRef=function(t,e,r,n,i,a){var o=n.charAt(n.length-1),l=r._fullLayout._subplots[o+"axis"],u=n+"ref",c={};return i||(i=l[0]||a),a||(a=i),c[u]={valType:"enumerated",values:l.concat(a?[a]:[]),dflt:i},s.coerce(t,e,c,u)},T.coercePosition=function(t,e,r,n,i,a){var o,l;if("paper"===n||"pixel"===n)o=s.ensureNumber,l=r(i,a);else{var u=T.getFromId(e,n);l=r(i,a=u.fraction2r(a)),o=u.cleanPos}t[i]=o(l)},T.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?s.ensureNumber:T.getFromId(e,r).cleanPos)(t)};var L=T.getDataConversions=function(t,e,r,n){var i,a="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(a)){if(i={type:k(n),_categories:[]},T.setConvert(i),"category"===i.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.saveRangeInitial=function(t,e){for(var r=T.list(t,"",!0),n=!1,i=0;i.3*h||c(n)||c(a))){var d=r.dtick/2;t+=t+d.8){var o=Number(r.substr(1));a.exactYears>.8&&o%12==0?t=T.tickIncrement(t,"M6","reverse")+1.5*m:a.exactMonths>.8?t=T.tickIncrement(t,"M1","reverse")+15.5*m:t-=m/2;var l=T.tickIncrement(t,r);if(l<=n)return l}return t}(b,t,y,u,a)),v=b,0;v<=c;)v=T.tickIncrement(v,y,!1,a),0;return{start:e.c2r(b,0,a),end:e.c2r(v,0,a),size:y,_dataSpan:c-u}},T.prepTicks=function(t){var e=s.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=s.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),T.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),B(t)},T.calcTicks=function(t){T.prepTicks(t);var e=s.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e,r,n=t.tickvals,i=t.ticktext,a=new Array(n.length),o=s.simpleMap(t.range,t.r2l),l=1.0001*o[0]-1e-4*o[1],u=1.0001*o[1]-1e-4*o[0],c=Math.min(l,u),f=Math.max(l,u),h=0;Array.isArray(i)||(i=[]);var d="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(r=0;rc&&e=n:u<=n)&&!(a.length>l||u===o);u=T.tickIncrement(u,t.dtick,i,t.calendar))o=u,a.push(u);Q(t)&&360===Math.abs(e[1]-e[0])&&a.pop(),t._tmax=a[a.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var c=new Array(a.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=m&&a<=10||e>=15*m)t._tickround="d";else if(e>=b&&a<=16||e>=y)t._tickround="M";else if(e>=x&&a<=19||e>=b)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(a,o)-20,t._tickround<0&&(t._tickround=4)}}else if(i(e)||"L"===e.charAt(0)){var s=t.range.map(t.r2d||Number);i(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var l=Math.max(Math.abs(s[0]),Math.abs(s[1])),u=Math.floor(Math.log(l)/Math.LN10+.01);Math.abs(u)>3&&(H(t.exponentformat)&&!q(u)?t._tickexponent=3*Math.round((u-1)/3):t._tickexponent=u)}else t._tickround=null}function U(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}T.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=s.dateTick0(t.calendar);var a=2*e;a>g?(e/=g,r=n(10),t.dtick="M"+12*j(e,r,R)):a>v?(e/=v,t.dtick="M"+j(e,1,P)):a>m?(t.dtick=j(e,m,I),t.tick0=s.dateTick0(t.calendar,!0)):a>y?t.dtick=j(e,y,P):a>b?t.dtick=j(e,b,z):a>x?t.dtick=j(e,x,z):(r=n(10),t.dtick=j(e,r,R))}else if("log"===t.type){t.tick0=0;var o=s.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var l=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/l,r=n(10),t.dtick="L"+j(e,r,R)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):Q(t)?(t.tick0=0,r=1,t.dtick=j(e,r,F)):(t.tick0=0,r=n(10),t.dtick=j(e,r,R));if(0===t.dtick&&(t.dtick=1),!i(t.dtick)&&"string"!=typeof t.dtick){var u=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(u)}},T.tickIncrement=function(t,e,r,a){var o=r?-1:1;if(i(e))return t+o*e;var l=e.charAt(0),u=o*Number(e.substr(1));if("M"===l)return s.incrementMonth(t,u,a);if("L"===l)return Math.log(Math.pow(10,t)+u)/Math.LN10;if("D"===l){var c="D2"===e?D:N,f=t+.01*o,h=s.roundUp(s.mod(f,1),c,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.r2l||Number,r=s.simpleMap(t.range,e),a=r[1]"+l,t._prevDateHead=l));e.text=u}(t,o,r,u):"log"===t.type?function(t,e,r,n,a){var o=t.dtick,l=e.x,u=t.tickformat,c="string"==typeof o&&o.charAt(0);"never"===a&&(a="");n&&"L"!==c&&(o="L3",c="L");if(u||"L"===c)e.text=G(Math.pow(10,l),t,a,n);else if(i(o)||"D"===c&&s.mod(l+.01,1)<.1){var f=Math.round(l),h=Math.abs(f),d=t.exponentformat;"power"===d||H(d)&&q(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+h+"",e.fontSize*=1.25):("e"===d||"E"===d)&&h>2?e.text="1"+d+(f>0?"+":_)+h:(e.text=G(Math.pow(10,l),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==c)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,s.mod(l,1)))),e.fontSize*=.75}if("D1"===t.dtick){var p=String(e.text).charAt(0);"0"!==p&&"1"!==p||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(l<0?.5:.25)))}}(t,o,0,u,n):"category"===t.type?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,o):Q(t)?function(t,e,r,n,i){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,i,n);else{var a=e.x/180;if(0===a)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,i=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/i),Math.round(r/i)]}(a);if(o[1]>=100)e.text=G(s.deg2rad(e.x),t,i,n);else{var l=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),l&&(e.text=_+e.text)}}}}(t,o,r,u,n):function(t,e,r,n,i){"never"===i?i="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide");e.text=G(e.x,t,i,n)}(t,o,0,u,n),t.tickprefix&&!d(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!d(t.showticksuffix)&&(o.text+=t.ticksuffix),o},T.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return T.hoverLabelText(t,e)+" - "+T.hoverLabelText(t,r);var n="log"===t.type&&e<=0,i=T.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+i:i};var V=["f","p","n","\u03bc","m","","k","M","G","T"];function H(t){return"SI"===t||"B"===t}function q(t){return t>14||t<-15}function G(t,e,r,n){var a=t<0,o=e._tickround,l=r||e.exponentformat||"B",u=e._tickexponent,c=T.getTickFormat(e),f=e.separatethousands;if(n){var h={exponentformat:l,dtick:"none"===e.showexponent?e.dtick:i(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};B(h),o=(Number(h._tickround)||0)+4,u=h._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return e._numFormat(c)(t).replace(/-/g,_);var d,p=Math.pow(10,-o)/2;if("none"===l&&(u=0),(t=Math.abs(t))"+d+"":"B"===l&&9===u?t+="B":H(l)&&(t+=V[u/3+5]));return a?_+t:t}function W(t,e){var r=t.l2p(e);return r>1&&r=0,a=c(t,e[1])<=0;return(r||i)&&(n||a)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(i)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},s=0;s2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":597,"./constants":550}],548:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var i,a=t.categoryarray,o=Array.isArray(a)&&a.length>0;o&&(i="array");var s,l=r("categoryorder",i);"array"===l&&(s=r("categoryarray")),o||"array"!==l||(l=e.categoryorder="trace"),"trace"===l?e._initialCategories=[]:"array"===l?e._initialCategories=s.slice():(s=function(t,e){var r,n,i,a=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;ns*b)||M)for(r=0;rP&&NO&&(O=N);d/=(O-C)/(2*R),C=c.l2r(C),O=c.l2r(O),c.range=c._input.range=E=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function z(t,e,r,n,i){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",i+"Z")}function I(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:u.background,stroke:u.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function N(t,e,r,n,i,a){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),D(t,e,i,a)}function D(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function j(t){E&&t.data&&t._context.showTips&&(s.notifier(s._(t,"Double-click to zoom back out"),"long"),E=!1)}function B(t){return"lasso"===t||"select"===t}function U(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,k)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function V(t,e){if(a){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function H(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,a,u,h,E,S){var D,q,G,W,X,Y,Z,Q,J,$,K,tt,et,rt,nt,it,at,ot,st,lt,ut,ct=t._fullLayout._zoomlayer,ft=E+S==="nsew",ht=1===(E+S).length;function dt(){if(D=e.xaxis,q=e.yaxis,J=D._length,$=q._length,Z=D._offset,Q=q._offset,(G={})[D._id]=D,(W={})[q._id]=q,E&&S)for(var r=e.overlays,n=0;n-1&&w(i,t,X,Y,e.id,kt),a.indexOf("event")>-1&&f.click(t,i,e.id);else if(1===r&&ht){var s=E?q:D,u="s"===E||"w"===S?0:1,c=s._name+".range["+u+"]",h=function(t,e){var r,i=t.range[e],a=Math.abs(i-t.range[1-e]);return"date"===t.type?i:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,i))):(r=Math.floor(Math.log(Math.abs(i))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,n.format("."+String(r)+"g")(i))}(s,u),d="left",p="middle";if(s.fixedrange)return;E?(p="n"===E?"top":"bottom","right"===s.side&&(d="right")):"e"===S&&(d="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(l.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(h),fill:s.tickfont?s.tickfont.color:"#444",horizontalAlign:d,verticalAlign:p}).on("edit",function(e){var r=s.d2r(e);void 0!==r&&o.call("relayout",t,c,r)})}}function Lt(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min(J,e+vt)),i=Math.max(0,Math.min($,r+mt)),a=Math.abs(n-vt),o=Math.abs(i-mt);function s(){wt="",yt.r=yt.l,yt.t=yt.b,At.attr("d","M0,0Z")}yt.l=Math.min(vt,n),yt.r=Math.max(vt,n),yt.t=Math.min(mt,i),yt.b=Math.max(mt,i),nt?a>k||o>k?(wt="xy",a/J>o/$?(o=a*$/J,mt>i?yt.t=mt-o:yt.b=mt+o):(a=o*J/$,vt>n?yt.l=vt-a:yt.r=vt+a),At.attr("d",U(yt))):s():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(zt);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var i,a=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=Nt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-o.left)/o.width,u=(o.bottom-e.clientY)/o.height;if(it){for(S||(l=.5),i=0;ig[1]-.01&&(e.domain=s),i.noneOrAll(t.domain,e.domain,s)}return r("layer"),e}},{"../../lib":498,"fast-isnumeric":91}],561:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var i=[t.r2l(t.range[0]),t.r2l(t.range[1])],a=i[0]+(i[1]-i[0])*r;t.range=t._input.range=[t.l2r(a+(i[0]-a)*e),t.l2r(a+(i[1]-a)*e)]}},{"../../constants/alignment":474}],562:[function(t,e,r){"use strict";var n=t("polybooljs"),i=t("../../registry"),a=t("../../components/color"),o=t("../../components/fx"),s=t("../../lib/polygon"),l=t("../../lib/throttle"),u=t("../../components/fx/helpers").makeEventData,c=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),h=t("../../plot_api/subroutines").redrawReglTraces,d=t("./constants"),p=d.MINSELECT,g=s.filter,v=s.tester;function m(t){return t._id}function y(t,e,r,n,i,a,o){var s,l,u,c,f,h,d,p,g,v=e._hoverdata,m=e._fullLayout.clickmode.indexOf("event")>-1,y=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,a);var b=function(t,e){var r,n,i=t[0],a=-1,o=[];for(n=0;n0?function(t,e){var r,n,i,a=[];for(i=0;i0&&a.push(r);if(1===a.length&&a[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(i=0;i1)return!1;if((i+=r.selectedpoints.length)>1)return!1}return 1===i}(s)&&(h=k(b))){for(o&&o.remove(),g=0;g0?"M"+i.join("M")+"Z":"M0,0Z",e.attr("d",n)}function k(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,i=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(i)>-1}function E(t,e,r){var n,a,o,s;if(r){var l=r.points||[];for(n=0;n-1&&y(e,k,i.xaxes,i.yaxes,i.subplot,i,q),"event"===r&&k.emit("plotly_selected",void 0);o.click(k,e)})},i.doneFn=function(){W.remove(),l.done(X).then(function(){l.clear(X),i.gd.emit("plotly_selected",x),h&&i.selectionDefs&&(h.subtract=H,i.selectionDefs.push(h),i.mergedPolygons.length=0,[].push.apply(i.mergedPolygons,f))})}},clearSelect:L,selectOnClick:y}},{"../../components/color":376,"../../components/fx":418,"../../components/fx/helpers":415,"../../lib/clear_gl_canvases":485,"../../lib/polygon":510,"../../lib/throttle":522,"../../plot_api/subroutines":535,"../../registry":597,"./axis_ids":547,"./constants":550,polybooljs:298}],563:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=a.cleanNumber,s=a.ms2DateTime,l=a.dateTime2ms,u=a.ensureNumber,c=t("../../constants/numerical"),f=c.FP_SAFE,h=c.BADNUM,d=c.LOG_CLIP,p=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function c(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-2*d*Math.abs(n-i))}return h}function m(e,r,n){var o=l(e,n||t.calendar);if(o===h){if(!i(e))return h;e=+e;var s=Math.floor(10*a.mod(e+.05,1)),u=Math.round(e-s/10);o=l(new Date(u))+s/10}return o}function y(e,r,n){return s(e,r,n||t.calendar)}function b(e){return t._categories[Math.round(e)]}function x(e){if(t._categoriesMap){var r=t._categoriesMap[e];if(void 0!==r)return r}if(i(e))return+e}function _(e){return i(e)?n.round(t._b+t._m*e,2):h}function w(e){return(e-t._b)/t._m}t.c2l="log"===t.type?c:u,t.l2c="log"===t.type?v:u,t.l2p=_,t.p2l=w,t.c2p="log"===t.type?function(t,e){return _(c(t,e))}:_,t.p2c="log"===t.type?function(t){return v(w(t))}:w,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=u,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=w,t.cleanPos=u):"log"===t.type?(t.d2r=t.d2l=function(t,e){return c(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=u,t.c2r=c,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(w(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=w,t.cleanPos=u):"date"===t.type?(t.d2r=t.r2d=a.identity,t.d2c=t.r2c=t.d2l=t.r2l=m,t.c2d=t.c2r=t.l2d=t.l2r=y,t.d2p=t.r2p=function(e,r,n){return t.l2p(m(e,0,n))},t.p2d=t.p2r=function(t,e,r){return y(w(t),e,r)},t.cleanPos=function(e){return a.cleanDate(e,h,t.calendar)}):"category"===t.type&&(t.d2c=t.d2l=function(e){if(null!=e){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return h},t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=x,t.r2c=function(e){var r=x(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=u,t.r2l=x,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(w(t))},t.r2p=t.d2p,t.p2r=w,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:u(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,s,l=a.nestedProperty(t,e).get();if(s=(s="date"===t.type?a.dfltRange(t.calendar):"y"===r?p.DFLTRANGEY:n.dfltRange||p.DFLTRANGEX).slice(),l&&2===l.length)for("date"===t.type&&(l[0]=a.cleanDate(l[0],h,t.calendar),l[1]=a.cleanDate(l[1],h,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!a.isDateTime(l[o],t.calendar)){t[e]=s;break}if(t.r2l(l[0])===t.r2l(l[1])){var u=a.constrain(t.r2l(l[0]),a.MIN_MS+1e3,a.MAX_MS-1e3);l[0]=t.l2r(u-1e3),l[1]=t.l2r(u+1e3);break}}else{if(!i(l[o])){if(!i(l[1-o])){t[e]=s;break}l[o]=l[1-o]*(o?10:.1)}if(l[o]<-f?l[o]=-f:l[o]>f&&(l[o]=f),l[0]===l[1]){var c=Math.max(1,Math.abs(1e-6*l[0]));l[0]-=c,l[1]+=c}}else a.nestedProperty(t,e).set(s)},t.setScale=function(n){var i=e._size;if(t._categories||(t._categories=[]),t._categoriesMap||(t._categoriesMap={}),t.overlaying){var a=g.getFromId({_fullLayout:e},t.overlaying);t.domain=a.domain}var o=n&&t._r?"_r":"range",s=t.calendar;t.cleanRange(o);var l=t.r2l(t[o][0],s),u=t.r2l(t[o][1],s);if("y"===r?(t._offset=i.t+(1-t.domain[1])*i.h,t._length=i.h*(t.domain[1]-t.domain[0]),t._m=t._length/(l-u),t._b=-t._m*u):(t._offset=i.l+t.domain[0]*i.w,t._length=i.w*(t.domain[1]-t.domain[0]),t._m=t._length/(u-l),t._b=-t._m*l),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,i,o,s,l=t.type,u="date"===l&&e[r+"calendar"];if(r in e){if(n=e[r],s=e._length||n.length,a.isTypedArray(n)&&("linear"===l||"log"===l)){if(s===n.length)return n;if(n.subarray)return n.subarray(0,s)}for(i=new Array(s),o=0;o rect").call(a.setTranslate,0,0).call(a.setScale,1,1),t.plot.call(a.setTranslate,e._offset,r._offset).call(a.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(a.setPointGroupScale,1,1),n.selectAll(".textpoint").call(a.setTextPointsScale,1,1),n.call(a.hideOutsideRangePoints,t)}function b(e,r){var n,s,l,c=g[e.xaxis._id],f=g[e.yaxis._id],h=[];if(c){s=(n=t._fullLayout[c.axisName])._r,l=c.to,h[0]=(s[0]*(1-r)+r*l[0]-s[0])/(s[1]-s[0])*e.xaxis._length;var d=s[1]-s[0],p=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[2]=e.xaxis._length*(1-r+r*p/d)}else h[0]=0,h[2]=e.xaxis._length;if(f){s=(n=t._fullLayout[f.axisName])._r,l=f.to,h[1]=(s[1]*(1-r)+r*l[1]-s[1])/(s[0]-s[1])*e.yaxis._length;var v=s[1]-s[0],m=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[3]=e.yaxis._length*(1-r+r*m/v)}else h[1]=0,h[3]=e.yaxis._length;!function(e,r){var n,a=[];for(a=[e._id,r._id],n=0;nr.duration?(function(){for(var e={},r=0;r0&&(i["_"+r+"axes"]||{})[e])return i;if((i[r+"axis"]||r)===e){if(o(i,r))return i;if((i[r]||[]).length||i[r+"0"])return i}}}(e,r,s);if(!l)return;if("histogram"===l.type&&s==={v:"y",h:"x"}[l.orientation||"v"])return void(t.type="linear");var u,c=s+"calendar",f=l[c];if(o(l,s)){var h=a(l),d=[];for(u=0;u0?".":"")+a;i.isPlainObject(o)?l(o,e,s,n+1):e(s,a,o)}})}r.manageCommandObserver=function(t,e,n,o){var s={},l=!0;e&&e._commandObserver&&(s=e._commandObserver),s.cache||(s.cache={}),s.lookupTable={};var u=r.hasSimpleAPICommandBindings(t,n,s.lookupTable);if(e&&e._commandObserver){if(u)return s;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,s}if(u){a(t,u,s.cache),s.check=function(){if(l){var e=a(t,u,s.cache);return e.changed&&o&&void 0!==s.lookupTable[e.value]&&(s.disable(),Promise.resolve(o({value:e.value,type:u.type,prop:u.prop,traces:u.traces,index:s.lookupTable[e.value]})).then(s.enable,s.enable)),e.changed}};for(var c=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;fMath.abs(e))u.rotate(a,0,0,-t*r*Math.PI*p.rotateSpeed/window.innerWidth);else{var o=-p.zoomSpeed*i*e/window.innerHeight*(a-u.lastT())/20;u.pan(a,0,0,f*(Math.exp(o)-1))}}},!0),p};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset"),l=t("has-passive-events")},{"3d-view":11,"has-passive-events":251,"mouse-change":270,"mouse-event-offset":271,"mouse-wheel":273,"right-now":315}],575:[function(t,e,r){"use strict";var n=t("../../plot_api/edit_types").overrideAll,i=t("../../components/fx/layout_attributes"),a=t("./scene"),o=t("../get_data").getSubplotData,s=t("../../lib"),l=t("../../constants/xmlns_namespaces");r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=r.attrRegex=s.counterRegex("scene"),r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.baseLayoutAttrOverrides=n({hoverlabel:i.hoverlabel},"plot","nested"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=e._subplots.gl3d,i=0;i1;o(t,e,r,{type:"gl3d",attributes:l,handleDefaults:u,fullLayout:e,font:e.font,fullData:r,getDfltFromLayout:function(e){if(!i)return n.validate(t[e],l[e])?t[e]:void 0},paper_bgcolor:e.paper_bgcolor,calendar:e.calendar})}},{"../../../components/color":376,"../../../lib":498,"../../../registry":597,"../../subplot_defaults":596,"./axis_defaults":578,"./layout_attributes":581}],581:[function(t,e,r){"use strict";var n=t("./axis_attributes"),i=t("../../domain").attributes,a=t("../../../lib/extend").extendFlat,o=t("../../../lib").counterRegex;function s(t,e,r){return{x:{valType:"number",dflt:t,editType:"camera"},y:{valType:"number",dflt:e,editType:"camera"},z:{valType:"number",dflt:r,editType:"camera"},editType:"camera"}}e.exports={_arrayAttrRegexps:[o("scene",".annotations",!0)],bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"plot"},camera:{up:a(s(0,0,1),{}),center:a(s(0,0,0),{}),eye:a(s(1.25,1.25,1.25),{}),editType:"camera"},domain:i({name:"scene",editType:"plot"}),aspectmode:{valType:"enumerated",values:["auto","cube","data","manual"],dflt:"auto",editType:"plot",impliedEdits:{"aspectratio.x":void 0,"aspectratio.y":void 0,"aspectratio.z":void 0}},aspectratio:{x:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},y:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},z:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},editType:"plot",impliedEdits:{aspectmode:"manual"}},xaxis:n,yaxis:n,zaxis:n,dragmode:{valType:"enumerated",values:["orbit","turntable","zoom","pan",!1],dflt:"turntable",editType:"plot"},hovermode:{valType:"enumerated",values:["closest",!1],dflt:"closest",editType:"modebar"},editType:"plot",_deprecated:{cameraposition:{valType:"info_array",editType:"camera"}}}},{"../../../lib":498,"../../../lib/extend":490,"../../domain":570,"./axis_attributes":577}],582:[function(t,e,r){"use strict";var n=t("../../../lib/str2rgbarray"),i=["xaxis","yaxis","zaxis"];function a(){this.enabled=[!0,!0,!0],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.drawSides=[!0,!0,!0],this.lineWidth=[1,1,1]}a.prototype.merge=function(t){for(var e=0;e<3;++e){var r=t[i[e]];r.visible?(this.enabled[e]=r.showspikes,this.colors[e]=n(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness):(this.enabled[e]=!1,this.drawSides[e]=!1)}},e.exports=function(t){var e=new a;return e.merge(t),e}},{"../../../lib/str2rgbarray":520}],583:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.axesOptions,r=t.glplot.axesPixels,l=t.fullSceneLayout,u=[[],[],[]],c=0;c<3;++c){var f=l[o[c]];if(f._length=(r[c].hi-r[c].lo)*r[c].pixelsPerDataUnit/t.dataScale[c],Math.abs(f._length)===1/0)u[c]=[];else{f._input_range=f.range.slice(),f.range[0]=r[c].lo/t.dataScale[c],f.range[1]=r[c].hi/t.dataScale[c],f._m=1/(t.dataScale[c]*r[c].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var d=f.nticks||i.constrain(f._length/40,4,9);n.autoTicks(f,Math.abs(f.range[1]-f.range[0])/d)}for(var p=n.calcTicks(f),g=0;g")}else v=u.textLabel;t.fullSceneLayout.hovermode&&f.loneHover({x:(.5+.5*p[0]/p[3])*i,y:(.5-.5*p[1]/p[3])*a,xLabel:w,yLabel:M,zLabel:A,text:v,name:l.name,color:f.castHoverOption(e,m,"bgcolor")||l.color,borderColor:f.castHoverOption(e,m,"bordercolor"),fontFamily:f.castHoverOption(e,m,"font.family"),fontSize:f.castHoverOption(e,m,"font.size"),fontColor:f.castHoverOption(e,m,"font.color")},{container:r,gd:t.graphDiv});var k={x:u.traceCoordinate[0],y:u.traceCoordinate[1],z:u.traceCoordinate[2],data:e._input,fullData:e,curveNumber:e.index,pointNumber:m};e._module.eventData&&(k=e._module.eventData(k,u,e,{},m)),f.appendArrayPointValue(k,e,m);var E={points:[k]};u.buttons&&u.distance<5?t.graphDiv.emit("plotly_click",E):t.graphDiv.emit("plotly_hover",E),o=E}else f.loneUnhover(r),t.graphDiv.emit("plotly_unhover",o);t.drawAnnotations(t)}.bind(null,t),t.traces={},!0}function x(t,e){var r=document.createElement("div"),n=t.container;this.graphDiv=t.graphDiv;var i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.top=i.style.left="0px",i.style.width=i.style.height="100%",i.style["z-index"]=20,i.style["pointer-events"]="none",r.appendChild(i),this.svgContainer=i,r.id=t.id,r.style.position="absolute",r.style.top=r.style.left="0px",r.style.width=r.style.height="100%",n.appendChild(r),this.fullLayout=e,this.id=t.id||"scene",this.fullSceneLayout=e[this.id],this.plotArgs=[[],{},{}],this.axesOptions=v(e[this.id]),this.spikeOptions=m(e[this.id]),this.container=r,this.staticMode=!!t.staticPlot,this.pixelRatio=t.plotGlPixelRatio||2,this.dataScale=[1,1,1],this.contourLevels=[[],[],[]],this.convertAnnotations=l.getComponentMethod("annotations3d","convert"),this.drawAnnotations=l.getComponentMethod("annotations3d","draw"),b(this)}var _=x.prototype;_.recoverContext=function(){var t=this,e=this.glplot.gl,r=this.glplot.canvas;this.glplot.dispose(),requestAnimationFrame(function n(){e.isContextLost()?requestAnimationFrame(n):b(t,t.fullLayout,r,e)?t.plot.apply(t,t.plotArgs):u.error("Catastrophic and unrecoverable WebGL error. Context lost.")})};var w=["xaxis","yaxis","zaxis"];function M(t,e,r){for(var n=t.fullSceneLayout,i=0;i<3;i++){var a=w[i],o=a.charAt(0),s=n[a],l=e[o],c=e[o+"calendar"],f=e["_"+o+"length"];if(u.isArrayOrTypedArray(l))for(var h,d=0;d<(f||l.length);d++)if(u.isArrayOrTypedArray(l[d]))for(var p=0;pg[1][a])g[0][a]=-1,g[1][a]=1;else{var S=g[1][a]-g[0][a];g[0][a]-=S/32,g[1][a]+=S/32}if("reversed"===s.autorange){var L=g[0][a];g[0][a]=g[1][a],g[1][a]=L}}else{var C=s.range;g[0][a]=s.r2l(C[0]),g[1][a]=s.r2l(C[1])}g[0][a]===g[1][a]&&(g[0][a]-=1,g[1][a]+=1),v[a]=g[1][a]-g[0][a],this.glplot.bounds[0][a]=g[0][a]*d[a],this.glplot.bounds[1][a]=g[1][a]*d[a]}var O=[1,1,1];for(a=0;a<3;++a){var R=m[l=(s=u[w[a]]).type];O[a]=Math.pow(R.acc,1/R.count)/d[a]}var P;if("auto"===u.aspectmode)P=Math.max.apply(null,O)/Math.min.apply(null,O)<=4?O:[1,1,1];else if("cube"===u.aspectmode)P=[1,1,1];else if("data"===u.aspectmode)P=O;else{if("manual"!==u.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var z=u.aspectratio;P=[z.x,z.y,z.z]}u.aspectratio.x=c.aspectratio.x=P[0],u.aspectratio.y=c.aspectratio.y=P[1],u.aspectratio.z=c.aspectratio.z=P[2],this.glplot.aspect=P;var I=u.domain||null,N=e._size||null;if(I&&N){var D=this.container.style;D.position="absolute",D.left=N.l+I.x[0]*N.w+"px",D.top=N.t+(1-I.y[1])*N.h+"px",D.width=N.w*(I.x[1]-I.x[0])+"px",D.height=N.h*(I.y[1]-I.y[0])+"px"}this.glplot.redraw()}},_.destroy=function(){this.glplot&&(this.camera.mouseListener.enabled=!1,this.container.removeEventListener("wheel",this.camera.wheelListener),this.camera=this.glplot.camera=null,this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null)},_.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),A(this.glplot.camera)},_.setCamera=function(t){var e;this.glplot.camera.lookAt.apply(this,[[(e=t).eye.x,e.eye.y,e.eye.z],[e.center.x,e.center.y,e.center.z],[e.up.x,e.up.y,e.up.z]])},_.saveCamera=function(t){var e=this.getCamera(),r=u.nestedProperty(t,this.id+".camera"),n=r.get(),i=!1;function a(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}if(void 0===n)i=!0;else for(var o=0;o<3;o++)for(var s=0;s<3;s++)if(!a(e,n,o,s)){i=!0;break}return i&&r.set(e),i},_.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},_.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(n),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,i=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var a=new Uint8Array(r*i*4);e.readPixels(0,0,r,i,e.RGBA,e.UNSIGNED_BYTE,a);for(var o=0,s=i-1;o=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}(t,o),s.text(o.text()&&c.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),i=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return i.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),i.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var b,x=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,i={};function o(t){for(var r=!0,a=0;a1&&P.length>1){for(a.getComponentMethod("grid","sizeDefaults")(u,s),o=0;o15&&P.length>15&&0===s.shapes.length&&0===s.images.length,s._hasCartesian=s._has("cartesian"),s._hasGeo=s._has("geo"),s._hasGL3D=s._has("gl3d"),s._hasGL2D=s._has("gl2d"),s._hasTernary=s._has("ternary"),s._hasPie=s._has("pie"),v.linkSubplots(h,s,c,i),v.cleanPlot(h,s,c,i),p(s,i),v.doAutoMargin(t);var F=f.list(t);for(o=0;o0){var f=1-2*s;n=Math.round(f*n),a=Math.round(f*a)}}var h=v.layoutAttributes.width.min,d=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-a)>1;(g||p)&&(p&&(r.width=n),g&&(r.height=a)),t._initialAutoSize||(t._initialAutoSize={width:n,height:a}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var i,o,s,u=a.componentsRegistry,c=e._basePlotModules,f=a.subplotsRegistry.cartesian;for(i in u)(s=u[i]).includeBasePlot&&s.includeBasePlot(t,e);for(var h in c.length||c.push(f),e._has("cartesian")&&(a.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[h].sort(l.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var l=void 0!==r.xl?r.xl:r.x,u=void 0!==r.xr?r.xr:r.x,c=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;i[e]={l:{val:l,size:r.l+o},r:{val:u,size:r.r+o},b:{val:f,size:r.b+o},t:{val:c,size:r.t+o}},a[e]=1}else delete i[e],delete a[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),T(e);var r=e._size,n=JSON.stringify(r),o=Math.max(e.margin.l||0,0),s=Math.max(e.margin.r||0,0),l=Math.max(e.margin.t||0,0),u=Math.max(e.margin.b||0,0),c=e._pushmargin,f=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var h in c)f[h]||delete c[h];for(var d in c.base={l:{val:0,size:o},r:{val:1,size:s},t:{val:1,size:l},b:{val:0,size:u}},c){var p=c[d].l||{},g=c[d].b||{},v=p.val,m=p.size,y=g.val,b=g.size;for(var x in c){if(i(m)&&c[x].r){var _=c[x].r.val,w=c[x].r.size;if(_>v){var M=(m*_+(w-e.width)*v)/(_-v),A=(w*(1-v)+(m-e.width)*(1-_))/(_-v);M>=0&&A>=0&&M+A>o+s&&(o=M,s=A)}}if(i(b)&&c[x].t){var k=c[x].t.val,E=c[x].t.size;if(k>y){var S=(b*k+(E-e.height)*y)/(k-y),L=(E*(1-y)+(b-e.height)*(1-k))/(k-y);S>=0&&L>=0&&S+L>u+l&&(u=S,l=L)}}}}}if(r.l=Math.round(o),r.r=Math.round(s),r.t=Math.round(l),r.b=Math.round(u),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,a.call("plot",t)},v.graphJson=function(t,e,r,n,i){(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var a=i?t._fullData:t.data,o=i?t._fullLayout:t.layout,s=(t._transitionData||{})._frames;function u(t){if("function"==typeof t)return null;if(l.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!l.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;i[e]=u(t[e])}return i}return Array.isArray(t)?t.map(u):l.isTypedArray(t)?l.simpleMap(t,l.identity):l.isJSDate(t)?l.ms2DateTimeLocal(+t):t}var c={data:(a||[]).map(function(t){var r=u(t);return e&&delete r.fit,r})};return e||(c.layout=u(o)),t.framework&&t.framework.isPolar&&(c=t.framework.getConfig()),s&&(c.frames=u(s)),"object"===n?c:JSON.stringify(c)},v.modifyFrames=function(t,e){var r,n,i,a=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){d=!0}),i.redraw&&t._transitionData._interruptCallbacks.push(function(){return a.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,s,u=0,c=0;function f(){return u++,function(){var r;c++,d||c!==u||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(i.redraw)return a.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var p=t._fullLayout._basePlotModules,g=!1;if(r)for(s=0;s=0;s--)if(o[s].enabled){r._indexToPoints=o[s]._indexToPoints;break}n&&n.calc&&(a=n.calc(t,r))}Array.isArray(a)&&a[0]||(a=[{x:c,y:c}]),a[0].t||(a[0].t={}),a[0].trace=r,p[e]=a}}for(y&&k(u),i=0;i=0?h.angularAxis.domain:n.extent(M),S=Math.abs(M[1]-M[0]);T&&!A&&(S=0);var L=E.slice();k&&A&&(L[1]+=S);var C=h.angularAxis.ticksCount||4;C>8&&(C=C/(C/8)+C%8),h.angularAxis.ticksStep&&(C=(L[1]-L[0])/C);var O=h.angularAxis.ticksStep||(L[1]-L[0])/(C*(h.minorTicks+1));w&&(O=Math.max(Math.round(O),1)),L[2]||(L[2]=O);var R=n.range.apply(this,L);if(R=R.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=n.scale.linear().domain(L.slice(0,2)).range("clockwise"===h.direction?[0,360]:[360,0]),c.layout.angularAxis.domain=s.domain(),c.layout.angularAxis.endPadding=k?S:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var P=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),z=this.appendChild(this.ownerDocument.importNode(P.documentElement,!0));t=n.select(z)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var I,N=t.select(".chart-group"),D={fill:"none",stroke:h.tickColor},F={"font-size":h.font.size,"font-family":h.font.family,fill:h.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+h.font.outlineColor}).join(",")};if(h.showLegend){I=t.select(".legend-group").attr({transform:"translate("+[b,h.margin.top]+")"}).style({display:"block"});var j=d.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:I,elements:j,reverseOrder:h.legend.reverseOrder})})();var B=I.node().getBBox();b=Math.min(h.width-B.width-h.margin.left-h.margin.right,h.height-h.margin.top-h.margin.bottom)/2,b=Math.max(10,b),_=[h.margin.left+b,h.margin.top+b],r.range([0,b]),c.layout.radialAxis.domain=r.domain(),I.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else I=t.select(".legend-group").style({display:"none"});t.attr({width:h.width,height:h.height}).style({opacity:h.opacity}),N.attr("transform","translate("+_+")").style({cursor:"crosshair"});var U=[(h.width-(h.margin.left+h.margin.right+2*b+(B?B.width:0)))/2,(h.height-(h.margin.top+h.margin.bottom+2*b))/2];if(U[0]=Math.max(0,U[0]),U[1]=Math.max(0,U[1]),t.select(".outer-group").attr("transform","translate("+U+")"),h.title){var V=t.select("g.title-group text").style(F).text(h.title),H=V.node().getBBox();V.attr({x:_[0]-H.width/2,y:_[1]-b-20})}var q=t.select(".radial.axis-group");if(h.radialAxis.gridLinesVisible){var G=q.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(D),G.attr("r",r),G.exit().remove()}q.select("circle.outside-circle").attr({r:b}).style(D);var W=t.select("circle.background-circle").attr({r:b}).style({fill:h.backgroundColor,stroke:h.stroke});function X(t,e){return s(t)%360+h.orientation}if(h.radialAxis.visible){var Y=n.svg.axis().scale(r).ticks(5).tickSize(5);q.call(Y).attr({transform:"rotate("+h.radialAxis.orientation+")"}),q.selectAll(".domain").style(D),q.selectAll("g>text").text(function(t,e){return this.textContent+h.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===h.radialAxis.tickOrientation?"rotate("+-h.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),q.selectAll("g>line").style({stroke:"black"})}var Z=t.select(".angular.axis-group").selectAll("g.angular-tick").data(R),Q=Z.enter().append("g").classed("angular-tick",!0);Z.attr({transform:function(t,e){return"rotate("+X(t)+")"}}).style({display:h.angularAxis.visible?"block":"none"}),Z.exit().remove(),Q.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(h.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(h.minorTicks+1)==0)}).style(D),Q.selectAll(".minor").style({stroke:h.minorTickColor}),Z.select("line.grid-line").attr({x1:h.tickLength?b-h.tickLength:0,x2:b}).style({display:h.angularAxis.gridLinesVisible?"block":"none"}),Q.append("text").classed("axis-text",!0).style(F);var J=Z.select("text.axis-text").attr({x:b+h.labelOffset,dy:a+"em",transform:function(t,e){var r=X(t),n=b+h.labelOffset,i=h.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:h.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(h.minorTicks+1)!=0?"":w?w[t]+h.angularAxis.ticksSuffix:t+h.angularAxis.ticksSuffix}).style(F);h.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(h.minorTicks+1)!=0?"":h.angularAxis.rewriteTicks(this.textContent,e)});var $=n.max(N.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));I.attr({transform:"translate("+[b+$,h.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(d);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),d[0]||K){var et=[];d.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=s,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=h.orientation,n.direction=h.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return i(o[r].defaultConfig(),t)});o[r]().config(n)()})}var it,at,ot=t.select(".guides-group"),st=t.select(".tooltips-group"),lt=o.tooltipPanel().config({container:st,fontSize:8})(),ut=o.tooltipPanel().config({container:st,fontSize:8})(),ct=o.tooltipPanel().config({container:st,hasTick:!0})();if(!A){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});N.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(W).angle;ft.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-h.orientation)%360;it=s.invert(n);var i=o.util.convertToCartesian(b+12,r+180);lt.text(o.util.round(it)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var ht=ot.select("circle").style({stroke:"grey",fill:"none"});N.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(W).radius;ht.attr({r:n}).style({opacity:.5}),at=r.invert(o.util.getMousePos(W).radius);var i=o.util.convertToCartesian(n,h.radialAxis.orientation);ut.text(o.util.round(at)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){ht.style({opacity:0}),ct.hide(),lt.hide(),ut.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var i=n.select(this),a=this.style.fill,s="black",l=this.style.opacity||1;if(i.attr({"data-opacity":l}),a&&"none"!==a){i.attr({"data-fill":a}),s=n.hsl(a).darker().toString(),i.style({fill:s,opacity:1});var u={t:o.util.round(e[0]),r:o.util.round(e[1])};A&&(u.t=w[e[0]]);var c="t: "+u.t+", r: "+u.r,f=this.getBoundingClientRect(),h=t.node().getBoundingClientRect(),d=[f.left+f.width/2-U[0]-h.left,f.top+f.height/2-U[1]-h.top];ct.config({color:s}).text(c),ct.move(d)}else a=this.style.stroke||"black",i.attr({"data-stroke":a}),s=n.hsl(a).darker().toString(),i.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ct.show()}).on("mouseout.tooltip",function(t,e){ct.hide();var r=n.select(this),i=r.attr("data-fill");i?r.style({fill:i,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(u),this},h.config=function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),i(l.data[e],o.Axis.defaultConfig().data[0]),i(l.data[e],t)}),i(l.layout,o.Axis.defaultConfig().layout),i(l.layout,e.layout),this},h.getLiveConfig=function(){return c},h.getinputConfig=function(){return u},h.radialScale=function(t){return r},h.angularScale=function(t){return s},h.svg=function(){return t},n.rebind(h,f,"on"),h},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var i=e||6,a=[],o=[];n.range(0,360+i,i).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],i=e[1],a={};return a.x=r,a.y=i,a.pos=e,a.angle=180*(Math.atan2(i,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+i*i),a},o.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;i0)){var l=n.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:c(s),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return p.fill(r,i,a)},"fill-opacity":0,stroke:function(t,e){return p.stroke(r,i,a)},"stroke-width":function(t,e){return p["stroke-width"](r,i,a)},"stroke-dasharray":function(t,e){return p["stroke-dasharray"](r,i,a)},opacity:function(t,e){return p.opacity(r,i,a)},display:function(t,e){return p.display(r,i,a)}})}};var f=e.angularScale.range(),h=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,d=n.svg.arc().startAngle(function(t){return-h/2}).endAngle(function(t){return h/2}).innerRadius(function(t){return e.radialScale(l+(t[2]||0))}).outerRadius(function(t){return e.radialScale(l+(t[2]||0))+e.radialScale(t[1])});u.arc=function(t,r,i){n.select(this).attr({class:"mark arc",d:d,transform:function(t,r){return"rotate("+(e.orientation+s(t[0])+90)+")"}})};var p={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,i){return r[t[i].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(p).each(u[e.geometryType]),v.exit().remove(),g.exit().remove()})}return a.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),i(t[r],o.PolyChart.defaultConfig()),i(t[r],e)}),this):t},a.getColorScale=function(){},n.rebind(a,e,"on"),a},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,a=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var a=i({},e.elements[r]);return a.name=t,a.color=[].concat(e.elements[r].color)[n],a})}),o=n.merge(a);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var s=e.container;("string"==typeof s||s.nodeName)&&(s=n.select(s));var l=o.map(function(t,e){return t.color}),u=e.fontSize,c=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=c?e.height:u*o.length,h=s.classed("legend-group",!0).selectAll("svg").data([0]),d=h.enter().append("svg").attr({width:300,height:f+u,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});d.append("g").classed("legend-axis",!0),d.append("g").classed("legend-marks",!0);var p=n.range(o.length),g=n.scale[c?"linear":"ordinal"]().domain(p).range(l),v=n.scale[c?"linear":"ordinal"]().domain(p)[c?"range":"rangePoints"]([0,f]);if(c){var m=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);m.enter().append("stop"),m.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var y=h.select(".legend-marks").selectAll("path.legend-mark").data(o);y.enter().append("path").classed("legend-mark",!0),y.attr({transform:function(t,e){return"translate("+[u/2,v(e)+u/2]+")"},d:function(t,e){var r,i,a,o=t.symbol;return a=3*(i=u),"line"===(r=o)?"M"+[[-i/2,-i/12],[i/2,-i/12],[i/2,i/12],[-i/2,i/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(a)():n.svg.symbol().type("square").size(a)()},fill:function(t,e){return g(e)}}),y.exit().remove()}var b=n.svg.axis().scale(v).orient("right"),x=h.select("g.legend-axis").attr({transform:"translate("+[c?e.colorBandWidth:u,u/2]+")"}).call(b);return x.selectAll(".domain").style({fill:"none",stroke:"none"}),x.selectAll("line").style({fill:"none",stroke:c?e.textColor:"none"}),x.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(i(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,a={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,u=function(){var n=(t=a.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:a.padding+l,dy:.3*+a.fontSize}),u};return u.text=function(i){var o=n.hsl(a.color).l,s=o>=.5?"#aaa":"white",c=o>=.5?"black":"white",f=i||"";e.style({fill:c,"font-size":a.fontSize+"px"}).text(f);var h=a.padding,d=e.node().getBBox(),p={fill:a.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[a.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),u},u.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),u},u.hide=function(){if(t)return t.style({display:"none"}),u},u.show=function(){if(t)return t.style({display:"block"}),u},u.config=function(t){return i(a,t),u},u},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=i({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var a=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=a.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var s=i({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var l=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],c={};n.entries(s.margin).forEach(function(t,e){c[u[l.indexOf(t.key)]]=t.value}),s.margin=c}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r}};return t}},{"../../../constants/alignment":474,"../../../lib":498,d3:82}],594:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../../lib"),a=t("../../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=i.extendDeepAll,u=e.exports={};u.framework=function(t){var e,r,i,a,c,f=new s;function h(r,s){return s&&(c=s),n.select(n.select(c).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?l(e,r):r,i||(i=o.Axis()),a=o.adapter.plotly().convert(e),i.config(a).render(c),t.data=e.data,t.layout=e.layout,u.fillLayout(t),e}return h.isPolar=!0,h.svg=function(){return i.svg()},h.getConfig=function(){return e},h.getLiveConfig=function(){return o.adapter.plotly().convert(i.getLiveConfig(),!0)},h.getLiveScales=function(){return{t:i.angularScale(),r:i.radialScale()}},h.setUndoPoint=function(){var t,n,i=this,a=o.util.cloneJson(e);t=a,n=r,f.add({undo:function(){n&&i(n)},redo:function(){i(t)}}),r=o.util.cloneJson(a)},h.undo=function(){f.undo()},h.redo=function(){f.redo()},h},u.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),i=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:a.background,_container:e,_paperdiv:r,_paper:i};t._fullLayout=l(o,t.layout)}},{"../../../components/color":376,"../../../lib":498,"./micropolar":593,"./undo_manager":595,d3:82}],595:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function i(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(i(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(i(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r-1&&(c[h[r]].title="");for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(l,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(l,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||h.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),h.node().setAttributeNS(s.xmlns,"xmlns",s.svg),h.node().setAttributeNS(s.xmlns,"xmlns:xlink",s.xlink),"svg"===e&&r&&(h.attr("width",r*p),h.attr("height",r*g),h.attr("viewBox","0 0 "+p+" "+g));var _=(new window.XMLSerializer).serializeToString(h.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(u,"'"),i.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":376,"../components/drawing":401,"../constants/xmlns_namespaces":479,"../lib":498,d3:82}],606:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),a=t("../mesh3d/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat,l={x:{valType:"data_array",editType:"calc+clearAxisTypes"},y:{valType:"data_array",editType:"calc+clearAxisTypes"},z:{valType:"data_array",editType:"calc+clearAxisTypes"},u:{valType:"data_array",editType:"calc"},v:{valType:"data_array",editType:"calc"},w:{valType:"data_array",editType:"calc"},sizemode:{valType:"enumerated",values:["scaled","absolute"],editType:"calc",dflt:"scaled"},sizeref:{valType:"number",editType:"calc",min:0},anchor:{valType:"enumerated",editType:"calc",values:["tip","tail","cm","center"],dflt:"cm"},text:{valType:"string",dflt:"",arrayOk:!0,editType:"calc"}};s(l,n("",{colorAttr:"u/v/w norm",showScaleDflt:!0,editTypeOverride:"calc"}),{colorbar:i});["opacity","lightposition","lighting"].forEach(function(t){l[t]=a[t]}),l.hoverinfo=s({},o.hoverinfo,{editType:"calc",flags:["x","y","z","u","v","w","norm","text","name"],dflt:"x+y+z+norm+text+name"}),l.transforms=void 0,e.exports=l},{"../../components/colorbar/attributes":377,"../../components/colorscale/attributes":383,"../../lib/extend":490,"../../plots/attributes":541,"../mesh3d/attributes":611}],607:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc");e.exports=function(t,e){for(var r=e.u,i=e.v,a=e.w,o=Math.min(e.x.length,e.y.length,e.z.length,r.length,i.length,a.length),s=-1/0,l=1/0,u=0;u0)c=a(t.alphahull,f);else{var d=["x","y","z"].indexOf(t.delaunayaxis);c=i(f.map(function(t){return[t[(d+1)%3],t[(d+2)%3]]}))}var p={positions:f,cells:c,lightPosition:[t.lightposition.x,t.lightposition.y,t.lightposition.z],ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,vertexNormalsEpsilon:t.lighting.vertexnormalsepsilon,faceNormalsEpsilon:t.lighting.facenormalsepsilon,opacity:t.opacity,contourEnable:t.contour.show,contourColor:l(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.vertexIntensityBounds=[t.cmin,t.cmax],p.colormap=s(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolor[0],p.vertexColors=h(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=h(t.facecolor)):(this.color=t.color,p.meshColor=l(t.color)),this.mesh.update(p)},f.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=function(t,e){var r=t.glplot.gl,i=n({gl:r}),a=new c(t,i,e.uid);return i._trace=a,a.update(e),t.glplot.add(i),a}},{"../../lib/gl_format_color":495,"../../lib/str2rgbarray":520,"../../plots/gl3d/zip3":586,"alpha-shape":16,"convex-hull":73,"delaunay-triangulate":84,"gl-mesh3d":139}],614:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}function u(t){var e=t.map(function(t){var e=l(t);return e&&i.isArrayOrTypedArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=u(["x","y","z"]),f=u(["i","j","k"]);c?(f&&f.forEach(function(t){for(var e=0;es&&T[v].gap;)v--;for(y=T[v].s,p=T.length-1;p>v;p--)T[p].s=y;for(;sk[c]&&c=0;i--){var a=t[i];if("scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}}}}},{}],626:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("./constants"),s=t("./subtypes"),l=t("./xy_defaults"),u=t("./stack_defaults"),c=t("./marker_defaults"),f=t("./line_defaults"),h=t("./line_shape_defaults"),d=t("./text_defaults"),p=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,i){return n.coerce(t,e,a,r,i)}var m=l(t,e,g,v);if(m||(e.visible=!1),e.visible){var y=u(t,e,g,v),b=!y&&mG!=(D=R[C][1])>=G&&(z=R[C-1][0],I=R[C][0],D-N&&(P=z+(I-z)*(G-N)/(D-N),U=Math.min(U,P),V=Math.max(V,P)));U=Math.max(U,0),V=Math.min(V,h._length);var W=s.defaultLine;return s.opacity(f.fillcolor)?W=f.fillcolor:s.opacity((f.line||{}).color)&&(W=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:U,x1:V,y0:G,y1:G,color:W}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":376,"../../components/fx":418,"../../lib":498,"../../registry":597,"./fill_hover_text":627,"./get_trace_color":629}],631:[function(t,e,r){"use strict";var n={},i=t("./subtypes");n.hasLines=i.hasLines,n.hasMarkers=i.hasMarkers,n.hasText=i.hasText,n.isBubble=i.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":556,"./arrays_to_calcdata":618,"./attributes":619,"./calc":620,"./cross_trace_calc":624,"./cross_trace_defaults":625,"./defaults":626,"./hover":630,"./marker_colorbar":637,"./plot":639,"./select":640,"./style":642,"./subtypes":643}],632:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s,l){var u=(t.marker||{}).color;(s("line.color",r),i(t,"line"))?a(t,e,o,s,{prefix:"line.",cLetter:"c",noScale:!0}):s("line.color",!n(u)&&u||r);s("line.width"),(l||{}).noDash||s("line.dash")}},{"../../components/colorscale/defaults":386,"../../components/colorscale/has_colorscale":390,"../../lib":498}],633:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),i=n.BADNUM,a=n.LOG_CLIP,o=a+.5,s=a-.5,l=t("../../lib"),u=l.segmentsIntersect,c=l.constrain,f=t("./constants");e.exports=function(t,e){var r,n,a,h,d,p,g,v,m,y,b,x,_,w,M,A,T,k,E=e.xaxis,S=e.yaxis,L="log"===E.type,C="log"===S.type,O=E._length,R=S._length,P=e.connectGaps,z=e.baseTolerance,I=e.shape,N="linear"===I,D=[],F=f.minTolerance,j=new Array(t.length),B=0;function U(e){var r=t[e];if(!r)return!1;var n=E.c2p(r.x),a=S.c2p(r.y);if(n===i){if(L&&(n=E.c2p(r.x,!0)),n===i)return!1;C&&a===i&&(n*=Math.abs(E._m*R*(E._m>0?o:s)/(S._m*O*(S._m>0?o:s)))),n*=1e3}if(a===i){if(C&&(a=S.c2p(r.y,!0)),a===i)return!1;a*=1e3}return[n,a]}function V(t,e,r,n){var i=r-t,a=n-e,o=.5-t,s=.5-e,l=i*i+a*a,u=i*o+a*s;if(u>0&&utt||t[1]rt)return[c(t[0],K,tt),c(t[1],et,rt)]}function at(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,i){var a=it(n),o=it(i),s=[];if(a&&o&&at(a,o))return s;a&&s.push(a),o&&s.push(o);var u=2*l.constrain((n[t]+i[t])/2,e,r)-((a||n)[t]+(o||i)[t]);u&&((a&&o?u>0==a[t]>o[t]?a:o:a||o)[t]+=u);return s}}function st(t){var e=t[0],r=t[1],n=e===j[B-1][0],i=r===j[B-1][1];if(!n||!i)if(B>1){var a=e===j[B-2][0],o=r===j[B-2][1];n&&(e===K||e===tt)&&a?o?B--:j[B-1]=t:i&&(r===et||r===rt)&&o?a?B--:j[B-1]=t:j[B++]=t}else j[B++]=t}function lt(t){j[B-1][0]!==t[0]&&j[B-1][1]!==t[1]&&st([X,Y]),st(t),Z=null,X=Y=0}function ut(t){if(T=t[0]/O,k=t[1]/R,G=t[0]tt?tt:0,W=t[1]rt?rt:0,G||W){if(B)if(Z){var e=J(Z,t);e.length>1&&(lt(e[0]),j[B++]=e[1])}else Q=J(j[B-1],t)[0],j[B++]=Q;else j[B++]=[G||t[0],W||t[1]];var r=j[B-1];G&&W&&(r[0]!==G||r[1]!==W)?(Z&&(X!==G&&Y!==W?st(X&&Y?(n=Z,a=(i=t)[0]-n[0],o=(i[1]-n[1])/a,(n[1]*i[0]-i[1]*n[0])/a>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[X||G,Y||W]):X&&Y&&st([X,Y])),st([G,W])):X-G&&Y-W&&st([G||X,W||Y]),Z=t,X=G,Y=W}else Z&<(J(Z,t)[0]),j[B++]=t;var n,i,a,o}for("linear"===I||"spline"===I?J=function(t,e){for(var r=[],n=0,i=0;i<4;i++){var a=nt[i],o=u(t[0],t[1],e[0],e[1],a[0],a[1],a[2],a[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&q(o,t)H(p,ct))break;a=p,(_=m[0]*v[0]+m[1]*v[1])>b?(b=_,h=p,g=!1):_=t.length||!p)break;ut(p),n=p}}else ut(h)}Z&&st([X||Z[0],Y||Z[1]]),D.push(j.slice(0,B))}return D}},{"../../constants/numerical":478,"../../lib":498,"./constants":623}],634:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],635:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var i,a,o,s,l,u={},c=!1,f=-1,h=0,d=-1;for(a=0;a=0?l=d:(l=d=h,h++),l0?Math.max(e,i):0}}},{"fast-isnumeric":91}],637:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],638:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l,u){var c=o.isBubble(t),f=(t.line||{}).color;(u=u||{},f&&(r=f),l("marker.symbol"),l("marker.opacity",c?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),u.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),u.noLine||(l("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:c?n.background:n.defaultLine),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",c?1:0)),c&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),u.gradient)&&("none"!==l("marker.gradient.type")&&l("marker.gradient.color"))}},{"../../components/color":376,"../../components/colorscale/defaults":386,"../../components/colorscale/has_colorscale":390,"./subtypes":643}],639:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../registry"),a=t("../../lib"),o=a.ensureSingle,s=a.identity,l=t("../../components/drawing"),u=t("./subtypes"),c=t("./line_points"),f=t("./link_traces"),h=t("../../lib/polygon").tester;function d(t,e,r,f,d,p,g){var v;!function(t,e,r,i,o){var s=r.xaxis,l=r.yaxis,c=n.extent(a.simpleMap(s.range,s.r2c)),f=n.extent(a.simpleMap(l.range,l.r2c)),h=i[0].trace;if(!u.hasMarkers(h))return;var d=h.marker.maxdisplayed;if(0===d)return;var p=i.filter(function(t){return t.x>=c[0]&&t.x<=c[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(p.length/d),v=0;o.forEach(function(t,r){var n=t[0].trace;u.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function y(t){return m?t.transition():t}var b=r.xaxis,x=r.yaxis,_=f[0].trace,w=_.line,M=n.select(p),A=o(M,"g","errorbars"),T=o(M,"g","lines"),k=o(M,"g","points"),E=o(M,"g","text");if(i.getComponentMethod("errorbars","plot")(A,r,g),!0===_.visible){var S,L;y(M).style("opacity",_.opacity);var C=_.fill.charAt(_.fill.length-1);"x"!==C&&"y"!==C&&(C=""),r.isRangePlot||(f[0].node3=M);var O="",R=[],P=_._prevtrace;P&&(O=P._prevRevpath||"",L=P._nextFill,R=P._polygons);var z,I,N,D,F,j,B,U,V,H="",q="",G=[],W=a.noop;if(S=_._ownFill,u.hasLines(_)||"none"!==_.fill){for(L&&L.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(N=l.steps(w.shape),D=l.steps(w.shape.split("").reverse().join(""))):N=D="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?l.smoothclosed(t.slice(1),w.smoothing):l.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return D(t.reverse())},G=c(f,{xaxis:b,yaxis:x,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),V=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)y(r.style("opacity",0).attr("d",z).call(l.lineGroupStyle)).style("opacity",1);else{var i=y(r);i.attr("d",z),l.singleLineStyle(f,i)}}}}}var X=T.selectAll(".js-line").data(G);y(X.exit()).style("opacity",0).remove(),X.each(W(!1)),X.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(l.lineGroupStyle).each(W(!0)),l.setClipUrl(X,r.layerClipId),G.length?(S?(S.datum(f),j&&U&&(C?("y"===C?j[1]=U[1]=x.c2p(0,!0):"x"===C&&(j[0]=U[0]=b.c2p(0,!0)),y(S).attr("d","M"+U+"L"+j+"L"+H.substr(1)).call(l.singleFillStyle)):y(S).attr("d",H+"Z").call(l.singleFillStyle))):L&&("tonext"===_.fill.substr(0,6)&&H&&O?("tonext"===_.fill?y(L).attr("d",H+"Z"+O+"Z").call(l.singleFillStyle):y(L).attr("d",H+"L"+O.substr(1)+"Z").call(l.singleFillStyle),_._polygons=_._polygons.concat(R)):(Z(L),_._polygons=null)),_._prevRevpath=q,_._prevPolygons=V):(S?Z(S):L&&Z(L),_._polygons=_._prevRevpath=_._prevPolygons=null),k.datum(f),E.datum(f),function(e,i,a){var o,c=a[0].trace,f=u.hasMarkers(c),h=u.hasText(c),d=tt(c),p=et,g=et;if(f||h){var v=s,_=c.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[b._id+x._id][_].stackgaps;c.marker.maxdisplayed||c._needsCull?v=w?J:Q:_&&!w&&(v=$),f&&(p=v),h&&(g=v)}var M,A=(o=e.selectAll("path.point").data(p,d)).enter().append("path").classed("point",!0);m&&A.call(l.pointStyle,c,t).call(l.translatePoints,b,x).style("opacity",0).transition().style("opacity",1),o.order(),f&&(M=l.makePointStyleFns(c)),o.each(function(e){var i=n.select(this),a=y(i);l.translatePoint(e,a,b,x)?(l.singlePointStyle(e,a,c,M,t),r.layerClipId&&l.hideOutsideRangePoint(e,a,b,x,c.xcalendar,c.ycalendar),c.customdata&&i.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):a.remove()}),m?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=i.selectAll("g").data(g,d)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),i=y(e.select("text"));l.translatePoint(t,i,b,x)?r.layerClipId&&l.hideOutsideRangePoint(t,e,b,x,c.xcalendar,c.ycalendar):e.remove()}),o.selectAll("text").call(l.textPointStyle,c,t).each(function(t){var e=b.c2p(t.x),r=x.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){y(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(k,E,f);var Y=!1===_.cliponaxis?null:r.layerClipId;l.setClipUrl(k,Y),l.setClipUrl(E,Y)}function Z(t){y(t).attr("d","M0,0Z")}function Q(t){return t.filter(function(t){return!t.gap&&t.vis})}function J(t){return t.filter(function(t){return t.vis})}function $(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,i,a,u){var c,h,p=!a,g=!!a&&a.duration>0,v=f(t,e,r);((c=i.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),c.order(),function(t,e,r){e.each(function(t){var e=o(n.select(this),"g","fills");l.setClipUrl(e,r.layerClipId);var i=t[0].trace,a=[];i._ownfill&&a.push("_ownFill"),i._nexttrace&&a.push("_nextFill");var u=e.selectAll("g").data(a,s);u.enter().append("g"),u.exit().each(function(t){i[t]=null}).remove(),u.order().each(function(t){i[t]=o(n.select(this),"path","js-fill")})})}(0,c,e),g)?(u&&(h=u()),n.transition().duration(a.duration).ease(a.easing).each("end",function(){h&&h()}).each("interrupt",function(){h&&h()}).each(function(){i.selectAll("g.trace").each(function(r,n){d(t,n,e,r,v,this,a)})})):c.each(function(r,n){d(t,n,e,r,v,this,a)});p&&c.exit().remove(),i.selectAll("path:not([d])").remove()}},{"../../components/drawing":401,"../../lib":498,"../../lib/polygon":510,"../../registry":597,"./line_points":633,"./link_traces":635,"./subtypes":643,d3:82}],640:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,i,a,o,s=t.cd,l=t.xaxis,u=t.yaxis,c=[],f=s[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r0){var h=i.c2l(c);i._lowerLogErrorBound||(i._lowerLogErrorBound=h),i._lowerErrorBound=Math.min(i._lowerLogErrorBound,h)}}else o[s]=[-l[0]*r,l[1]*r]}return o}e.exports=function(t,e,r){var n=[i(t.x,t.error_x,e[0],r.xaxis),i(t.y,t.error_y,e[1],r.yaxis),i(t.z,t.error_z,e[2],r.zaxis)],a=function(t){for(var e=0;e=0&&(d[1]+=1),h.indexOf("top")>=0&&(d[1]-=1),h.indexOf("left")>=0&&(d[0]-=1),h.indexOf("right")>=0&&(d[0]+=1),d)),r.textColor=c(e.textfont,1,L),r.textSize=b(e.textfont.size,L,l.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var z=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;n<3;++n){var I=e.projection[z[n]];(r.project[n]=I.show)&&(r.projectOpacity[n]=I.opacity,r.projectScale[n]=I.scale)}r.errorBounds=p(e,x,v);var N=function(t){for(var e=[0,0,0],r=[[0,0,0],[0,0,0],[0,0,0]],n=[1,1,1],i=0;i<3;i++){var a=t[i];a&&!1!==a.copy_zstyle&&!1!==t[2].visible&&(a=t[2]),a&&a.visible&&(e[i]=a.width/2,r[i]=u(a.color),n[i]=a.thickness)}return{capSize:e,color:r,lineWidth:n}}([e.error_x,e.error_y,e.error_z]);return r.errorColor=N.color,r.errorLineWidth=N.lineWidth,r.errorCapSize=N.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=u(e.surfacecolor),r}function _(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}v.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){var e=t.index=t.data.index;return t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),t.textLabel="",this.textLabels&&(Array.isArray(this.textLabels)?(this.textLabels[e]||0===this.textLabels[e])&&(t.textLabel=this.textLabels[e]):t.textLabel=this.textLabels),t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},v.update=function(t){var e,r,l,u,c=this.scene.glplot.gl,f=h.solid;this.data=t;var d=x(this.scene,t);"mode"in d&&(this.mode=d.mode),"lineDashes"in d&&d.lineDashes in h&&(f=h[d.lineDashes]),this.color=_(d.scatterColor)||_(d.lineColor),this.dataPoints=d.position,e={gl:c,position:d.position,color:d.lineColor,lineWidth:d.lineWidth||1,dashes:f[0],dashScale:f[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=n(e),this.linePlot._trace=this,this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var p=t.opacity;if(t.marker&&t.marker.opacity&&(p*=t.marker.opacity),r={gl:c,position:d.position,color:d.scatterColor,size:d.scatterSize,glyph:d.scatterMarker,opacity:p,orthographic:!0,lineWidth:d.scatterLineWidth,lineColor:d.scatterLineColor,project:d.project,projectScale:d.projectScale,projectOpacity:d.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=i(r),this.scatterPlot._trace=this,this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),u={gl:c,position:d.position,glyph:d.text,color:d.textColor,size:d.textSize,angle:d.textAngle,alignment:d.textOffset,font:d.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=t.hovertext||t.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(u):(this.textMarkers=i(u),this.textMarkers._trace=this,this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),l={gl:c,position:d.position,color:d.errorColor,error:d.errorBounds,lineWidth:d.errorLineWidth,capSize:d.errorCapSize,opacity:t.opacity},this.errorBars?d.errorBounds?this.errorBars.update(l):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):d.errorBounds&&(this.errorBars=a(l),this.errorBars._trace=this,this.scene.glplot.add(this.errorBars)),d.delaunayAxis>=0){var g=function(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],l=[];for(n=0;n=0&&f("surfacecolor",h||d);for(var p=["x","y","z"],g=0;g<3;++g){var v="projection."+p[g];f(v+".show")&&(f(v+".opacity"),f(v+".scale"))}var m=n.getComponentMethod("errorbars","supplyDefaults");m(t,e,r,{axis:"z"}),m(t,e,r,{axis:"y",inherit:"z"}),m(t,e,r,{axis:"x",inherit:"z"})}else e.visible=!1}},{"../../lib":498,"../../registry":597,"../scatter/line_defaults":632,"../scatter/marker_defaults":638,"../scatter/subtypes":643,"../scatter/text_defaults":644,"./attributes":646}],651:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl3d_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","showLegend"],n.meta={},e.exports=n},{"../../constants/gl3d_markers":476,"../../plots/gl3d":575,"../scatter/marker_colorbar":637,"./attributes":646,"./calc":647,"./convert":649,"./defaults":650}],652:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),a=t("../mesh3d/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat,l={x:{valType:"data_array",editType:"calc+clearAxisTypes"},y:{valType:"data_array",editType:"calc+clearAxisTypes"},z:{valType:"data_array",editType:"calc+clearAxisTypes"},u:{valType:"data_array",editType:"calc"},v:{valType:"data_array",editType:"calc"},w:{valType:"data_array",editType:"calc"},starts:{x:{valType:"data_array",editType:"calc"},y:{valType:"data_array",editType:"calc"},z:{valType:"data_array",editType:"calc"},editType:"calc"},maxdisplayed:{valType:"integer",min:0,dflt:1e3,editType:"calc"},sizeref:{valType:"number",editType:"calc",min:0,dflt:1},text:{valType:"string",dflt:"",editType:"calc"}};s(l,n("",{colorAttr:"u/v/w norm",showScaleDflt:!0,editTypeOverride:"calc"}),{colorbar:i});["opacity","lightposition","lighting"].forEach(function(t){l[t]=a[t]}),l.hoverinfo=s({},o.hoverinfo,{editType:"calc",flags:["x","y","z","u","v","w","norm","divergence","text","name"],dflt:"x+y+z+norm+text+name"}),l.transforms=void 0,e.exports=l},{"../../components/colorbar/attributes":377,"../../components/colorscale/attributes":383,"../../lib/extend":490,"../../plots/attributes":541,"../mesh3d/attributes":611}],653:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc");e.exports=function(t,e){var r,i,a,o,s=e.u,l=e.v,u=e.w,c=e.x,f=e.y,h=e.z,d=Math.min(c.length,f.length,h.length,s.length,l.length,u.length),p=0;e.starts&&(i=e.starts.x||[],a=e.starts.y||[],o=e.starts.z||[],p=Math.min(i.length,a.length,o.length));var g=0,v=1/0;for(r=0;r2?t.slice(1,e-1):2===e?[(t[0]+t[1])/2]:t}function d(t){var e=t.length;return 1===e?[.5,.5]:[t[1]-t[0],t[e-1]-t[e-2]]}function p(t,e){var r=t.fullSceneLayout,i=t.dataScale,u=e._len,c={};function p(t,e){var n=r[e],o=i[l[e]];return a.simpleMap(t,function(t){return n.d2l(t)*o})}c.vectors=s(p(e.u,"xaxis"),p(e.v,"yaxis"),p(e.w,"zaxis"),u);var g=f(e.x.slice(0,u)),v=f(e.y.slice(0,u)),m=f(e.z.slice(0,u));if(g.length*v.length*m.length>u)return{positions:[],cells:[]};var y=p(g,"xaxis"),b=p(v,"yaxis"),x=p(m,"zaxis");if(c.meshgrid=[y,b,x],e.starts){var _=e._slen;c.startingPositions=s(p(e.starts.x.slice(0,_),"xaxis"),p(e.starts.y.slice(0,_),"yaxis"),p(e.starts.z.slice(0,_),"zaxis"))}else{for(var w=b[0],M=h(y),A=h(x),T=new Array(M.length*A.length),k=0,E=0;E:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;margin-left:0px;margin-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var a in i){var o=a.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");n.addStyleRule(o,i[a])}},{"../src/lib":494}],2:[function(t,e,r){"use strict";e.exports={undo:{width:857.1,height:1e3,path:"m857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z",transform:"matrix(1 0 0 -1 0 850)"},home:{width:928.6,height:1e3,path:"m786 296v-267q0-15-11-26t-25-10h-214v214h-143v-214h-214q-15 0-25 10t-11 26v267q0 1 0 2t0 2l321 264 321-264q1-1 1-4z m124 39l-34-41q-5-5-12-6h-2q-7 0-12 3l-386 322-386-322q-7-4-13-4-7 2-12 7l-35 41q-4 5-3 13t6 12l401 334q18 15 42 15t43-15l136-114v109q0 8 5 13t13 5h107q8 0 13-5t5-13v-227l122-102q5-5 6-12t-4-13z",transform:"matrix(1 0 0 -1 0 850)"},"camera-retro":{width:1e3,height:1e3,path:"m518 386q0 8-5 13t-13 5q-37 0-63-27t-26-63q0-8 5-13t13-5 12 5 5 13q0 23 16 38t38 16q8 0 13 5t5 13z m125-73q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101z m-572-320h858v71h-858v-71z m643 320q0 89-62 152t-152 62-151-62-63-152 63-151 151-63 152 63 62 151z m-571 358h214v72h-214v-72z m-72-107h858v143h-462l-36-71h-360v-72z m929 143v-714q0-30-21-51t-50-21h-858q-29 0-50 21t-21 51v714q0 30 21 51t50 21h858q29 0 50-21t21-51z",transform:"matrix(1 0 0 -1 0 850)"},zoombox:{width:1e3,height:1e3,path:"m1000-25l-250 251c40 63 63 138 63 218 0 224-182 406-407 406-224 0-406-182-406-406s183-406 407-406c80 0 155 22 218 62l250-250 125 125z m-812 250l0 438 437 0 0-438-437 0z m62 375l313 0 0-312-313 0 0 312z",transform:"matrix(1 0 0 -1 0 850)"},pan:{width:1e3,height:1e3,path:"m1000 350l-187 188 0-125-250 0 0 250 125 0-188 187-187-187 125 0 0-250-250 0 0 125-188-188 186-187 0 125 252 0 0-250-125 0 187-188 188 188-125 0 0 250 250 0 0-126 187 188z",transform:"matrix(1 0 0 -1 0 850)"},zoom_plus:{width:875,height:1e3,path:"m1 787l0-875 875 0 0 875-875 0z m687-500l-187 0 0-187-125 0 0 187-188 0 0 125 188 0 0 187 125 0 0-187 187 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},zoom_minus:{width:875,height:1e3,path:"m0 788l0-876 875 0 0 876-875 0z m688-500l-500 0 0 125 500 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},autoscale:{width:1e3,height:1e3,path:"m250 850l-187 0-63 0 0-62 0-188 63 0 0 188 187 0 0 62z m688 0l-188 0 0-62 188 0 0-188 62 0 0 188 0 62-62 0z m-875-938l0 188-63 0 0-188 0-62 63 0 187 0 0 62-187 0z m875 188l0-188-188 0 0-62 188 0 62 0 0 62 0 188-62 0z m-125 188l-1 0-93-94-156 156 156 156 92-93 2 0 0 250-250 0 0-2 93-92-156-156-156 156 94 92 0 2-250 0 0-250 0 0 93 93 157-156-157-156-93 94 0 0 0-250 250 0 0 0-94 93 156 157 156-157-93-93 0 0 250 0 0 250z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_basic:{width:1500,height:1e3,path:"m375 725l0 0-375-375 375-374 0-1 1125 0 0 750-1125 0z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_compare:{width:1125,height:1e3,path:"m187 786l0 2-187-188 188-187 0 0 937 0 0 373-938 0z m0-499l0 1-187-188 188-188 0 0 937 0 0 376-938-1z",transform:"matrix(1 0 0 -1 0 850)"},plotlylogo:{width:1542,height:1e3,path:"m0-10h182v-140h-182v140z m228 146h183v-286h-183v286z m225 714h182v-1000h-182v1000z m225-285h182v-715h-182v715z m225 142h183v-857h-183v857z m231-428h182v-429h-182v429z m225-291h183v-138h-183v138z",transform:"matrix(1 0 0 -1 0 850)"},"z-axis":{width:1e3,height:1e3,path:"m833 5l-17 108v41l-130-65 130-66c0 0 0 38 0 39 0-1 36-14 39-25 4-15-6-22-16-30-15-12-39-16-56-20-90-22-187-23-279-23-261 0-341 34-353 59 3 60 228 110 228 110-140-8-351-35-351-116 0-120 293-142 474-142 155 0 477 22 477 142 0 50-74 79-163 96z m-374 94c-58-5-99-21-99-40 0-24 65-43 144-43 79 0 143 19 143 43 0 19-42 34-98 40v216h87l-132 135-133-135h88v-216z m167 515h-136v1c16 16 31 34 46 52l84 109v54h-230v-71h124v-1c-16-17-28-32-44-51l-89-114v-51h245v72z",transform:"matrix(1 0 0 -1 0 850)"},"3d_rotate":{width:1e3,height:1e3,path:"m922 660c-5 4-9 7-14 11-359 263-580-31-580-31l-102 28 58-400c0 1 1 1 2 2 118 108 351 249 351 249s-62 27-100 42c88 83 222 183 347 122 16-8 30-17 44-27-2 1-4 2-6 4z m36-329c0 0 64 229-88 296-62 27-124 14-175-11 157-78 225-208 249-266 8-19 11-31 11-31 2 5 6 15 11 32-5-13-8-20-8-20z m-775-239c70-31 117-50 198-32-121 80-199 346-199 346l-96-15-58-12c0 0 55-226 155-287z m603 133l-317-139c0 0 4-4 19-14 7-5 24-15 24-15s-177-147-389 4c235-287 536-112 536-112l31-22 100 299-4-1z m-298-153c6-4 14-9 24-15 0 0-17 10-24 15z",transform:"matrix(1 0 0 -1 0 850)"},camera:{width:1e3,height:1e3,path:"m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z m400 150h-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28l-31-94c-6-15-23-28-40-28h-120c-55 0-100-45-100-100v-450c0-55 45-100 100-100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250-250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35-35z",transform:"matrix(1 0 0 -1 0 850)"},movie:{width:1e3,height:1e3,path:"m938 413l-188-125c0 37-17 71-44 94 64 38 107 107 107 187 0 121-98 219-219 219-121 0-219-98-219-219 0-61 25-117 66-156h-115c30 33 49 76 49 125 0 103-84 187-187 187s-188-84-188-187c0-57 26-107 65-141-38-22-65-62-65-109v-250c0-70 56-126 125-126h500c69 0 125 56 125 126l188-126c34 0 62 28 62 63v375c0 35-28 63-62 63z m-750 0c-69 0-125 56-125 125s56 125 125 125 125-56 125-125-56-125-125-125z m406-1c-87 0-157 70-157 157 0 86 70 156 157 156s156-70 156-156-70-157-156-157z",transform:"matrix(1 0 0 -1 0 850)"},question:{width:857.1,height:1e3,path:"m500 82v107q0 8-5 13t-13 5h-107q-8 0-13-5t-5-13v-107q0-8 5-13t13-5h107q8 0 13 5t5 13z m143 375q0 49-31 91t-77 65-95 23q-136 0-207-119-9-14 4-24l74-55q4-4 10-4 9 0 14 7 30 38 48 51 19 14 48 14 27 0 48-15t21-33q0-21-11-34t-38-25q-35-16-65-48t-29-70v-20q0-8 5-13t13-5h107q8 0 13 5t5 13q0 10 12 27t30 28q18 10 28 16t25 19 25 27 16 34 7 45z m214-107q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z",transform:"matrix(1 0 0 -1 0 850)"},disk:{width:857.1,height:1e3,path:"m214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z",transform:"matrix(1 0 0 -1 0 850)"},lasso:{width:1031,height:1e3,path:"m1018 538c-36 207-290 336-568 286-277-48-473-256-436-463 10-57 36-108 76-151-13-66 11-137 68-183 34-28 75-41 114-42l-55-70 0 0c-2-1-3-2-4-3-10-14-8-34 5-45 14-11 34-8 45 4 1 1 2 3 2 5l0 0 113 140c16 11 31 24 45 40 4 3 6 7 8 11 48-3 100 0 151 9 278 48 473 255 436 462z m-624-379c-80 14-149 48-197 96 42 42 109 47 156 9 33-26 47-66 41-105z m-187-74c-19 16-33 37-39 60 50-32 109-55 174-68-42-25-95-24-135 8z m360 75c-34-7-69-9-102-8 8 62-16 128-68 170-73 59-175 54-244-5-9 20-16 40-20 61-28 159 121 317 333 354s407-60 434-217c28-159-121-318-333-355z",transform:"matrix(1 0 0 -1 0 850)"},selectbox:{width:1e3,height:1e3,path:"m0 850l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-285l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z",transform:"matrix(1 0 0 -1 0 850)"},spikeline:{width:1e3,height:1e3,path:"M512 409c0-57-46-104-103-104-57 0-104 47-104 104 0 57 47 103 104 103 57 0 103-46 103-103z m-327-39l92 0 0 92-92 0z m-185 0l92 0 0 92-92 0z m370-186l92 0 0 93-92 0z m0-184l92 0 0 92-92 0z",transform:"matrix(1.5 0 0 -1.5 0 850)"},newplotlylogo:{name:"newplotlylogo",svg:"plotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/cone")},{"../src/traces/cone":606}],4:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":476}],5:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./scatter3d"),t("./surface"),t("./mesh3d"),t("./cone"),t("./streamtube")]),e.exports=n},{"./cone":3,"./core":4,"./mesh3d":6,"./scatter3d":7,"./streamtube":8,"./surface":9}],6:[function(t,e,r){"use strict";e.exports=t("../src/traces/mesh3d")},{"../src/traces/mesh3d":611}],7:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatter3d")},{"../src/traces/scatter3d":647}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/streamtube")},{"../src/traces/streamtube":652}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/surface")},{"../src/traces/surface":657}],10:[function(t,e,r){"use strict";e.exports=function(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]);"zoomMin"in e&&(r[0]=e.zoomMin);"zoomMax"in e&&(r[1]=e.zoomMax);var u=i({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=0,h=t.clientWidth,d=t.clientHeight,p={view:u,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:u.modes,tick:function(){var e=n(),r=this.delay;u.idle(e-r),u.flush(e-(100+2*r));var i=e-2*r;u.recalcMatrix(i);for(var a=!0,o=u.computedMatrix,s=0;s<16;++s)a=a&&c[s]===o[s],c[s]=o[s];var l=t.clientWidth===h&&t.clientHeight===d;return h=t.clientWidth,d=t.clientHeight,a?!l:(f=Math.exp(u.computedRadius[0]),!0)},lookAt:function(t,e,r){u.lookAt(u.lastT(),t,e,r)},rotate:function(t,e,r){u.rotate(u.lastT(),t,e,r)},pan:function(t,e,r){u.pan(u.lastT(),t,e,r)},translate:function(t,e,r){u.translate(u.lastT(),t,e,r)}};Object.defineProperties(p,{matrix:{get:function(){return u.computedMatrix},set:function(t){return u.setMatrix(u.lastT(),t),u.computedMatrix},enumerable:!0},mode:{get:function(){return u.getMode()},set:function(t){return u.setMode(t),u.getMode()},enumerable:!0},center:{get:function(){return u.computedCenter},set:function(t){return u.lookAt(u.lastT(),t),u.computedCenter},enumerable:!0},eye:{get:function(){return u.computedEye},set:function(t){return u.lookAt(u.lastT(),null,t),u.computedEye},enumerable:!0},up:{get:function(){return u.computedUp},set:function(t){return u.lookAt(u.lastT(),null,null,t),u.computedUp},enumerable:!0},distance:{get:function(){return f},set:function(t){return u.setDistance(u.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return u.getDistanceLimits(r)},set:function(t){return u.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var g=0,v=0,m={shift:!1,control:!1,alt:!1,meta:!1};function y(e,r,i,a){var o=1/t.clientHeight,s=o*(r-g),l=o*(i-v),c=p.flipX?1:-1,h=p.flipY?1:-1,d=Math.PI*p.rotateSpeed,y=n();if(1&e)a.shift?u.rotate(y,0,0,-s*d):u.rotate(y,c*d*s,-h*d*l,0);else if(2&e)u.pan(y,-p.translateSpeed*s*f,p.translateSpeed*l*f,0);else if(4&e){var b=p.zoomSpeed*l/window.innerHeight*(y-u.lastT())*50;u.pan(y,0,0,f*(Math.exp(b)-1))}g=r,v=i,m=a}return a(t,y),t.addEventListener("touchstart",function(e){var r=s(e.changedTouches[0],t);y(0,r[0],r[1],m),y(1,r[0],r[1],m),e.preventDefault()},!!l&&{passive:!1}),t.addEventListener("touchmove",function(e){var r=s(e.changedTouches[0],t);y(1,r[0],r[1],m),e.preventDefault()},!!l&&{passive:!1}),t.addEventListener("touchend",function(e){s(e.changedTouches[0],t),y(0,g,v,m),e.preventDefault()},!!l&&{passive:!1}),o(t,function(t,e,r){var i=p.flipX?1:-1,a=p.flipY?1:-1,o=n();if(Math.abs(t)>Math.abs(e))u.rotate(o,0,0,-t*i*Math.PI*p.rotateSpeed/window.innerWidth);else{var s=p.zoomSpeed*a*e/window.innerHeight*(o-u.lastT())/100;u.pan(o,0,0,f*(Math.exp(s)-1))}},!0),p};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset"),l=t("has-passive-events")},{"3d-view":11,"has-passive-events":251,"mouse-change":270,"mouse-event-offset":271,"mouse-wheel":273,"right-now":315}],11:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).eye||[0,0,1],r=t.center||[0,0,0],s=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],u=t.mode||"turntable",c=n(),f=i(),h=a();return c.setDistanceLimits(l[0],l[1]),c.lookAt(0,e,r,s),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,s),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,s),new o({turntable:c,orbit:f,matrix:h},u)};var n=t("turntable-camera-controller"),i=t("orbit-camera-controller"),a=t("matrix-camera-controller");function o(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.turntable),this.modes=this._controllerNames,this.computedMatrix=this._active.computedMatrix,this.computedEye=this._active.computedEye,this.computedUp=this._active.computedUp,this.computedCenter=this._active.computedCenter,this.computedRadius=this._active.computedRadius}var s=o.prototype;[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]].forEach(function(t){for(var e=t[0],r=[],n=0;n0?n-4:n,f=0;f>16&255,s[l++]=e>>8&255,s[l++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,s[l++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,s[l++]=e>>8&255,s[l++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,a=[],o=0,s=r-i;os?s:o+16383));1===i?(e=t[r-1],a.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],a.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,a,o=[],s=e;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],20:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}},{"./lib/rationalize":30}],21:[function(t,e,r){"use strict";e.exports=function(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}},{}],22:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]),t[1].mul(e[0]))}},{"./lib/rationalize":30}],23:[function(t,e,r){"use strict";var n=t("./is-rat"),i=t("./lib/is-bn"),a=t("./lib/num-to-bn"),o=t("./lib/str-to-bn"),s=t("./lib/rationalize"),l=t("./div");e.exports=function t(e,r){if(n(e))return r?l(e,t(r)):[e[0].clone(),e[1].clone()];var u=0;var c,f;if(i(e))c=e.clone();else if("string"==typeof e)c=o(e);else{if(0===e)return[a(0),a(1)];if(e===Math.floor(e))c=a(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),u-=256;c=a(e)}}if(n(r))c.mul(r[1]),f=r[0].clone();else if(i(r))f=r.clone();else if("string"==typeof r)f=o(r);else if(r)if(r===Math.floor(r))f=a(r);else{for(;r!==Math.floor(r);)r*=Math.pow(2,256),u+=256;f=a(r)}else f=a(1);u>0?c=c.ushln(u):u<0&&(f=f.ushln(-u));return s(c,f)}},{"./div":22,"./is-rat":24,"./lib/is-bn":28,"./lib/num-to-bn":29,"./lib/rationalize":30,"./lib/str-to-bn":31}],24:[function(t,e,r){"use strict";var n=t("./lib/is-bn");e.exports=function(t){return Array.isArray(t)&&2===t.length&&n(t[0])&&n(t[1])}},{"./lib/is-bn":28}],25:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return t.cmp(new n(0))}},{"bn.js":38}],26:[function(t,e,r){"use strict";var n=t("./bn-sign");e.exports=function(t){var e=t.length,r=t.words,i=0;if(1===e)i=r[0];else if(2===e)i=r[0]+67108864*r[1];else for(var a=0;a20)return 52;return r+32}},{"bit-twiddle":37,"double-bits":85}],28:[function(t,e,r){"use strict";t("bn.js");e.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},{"bn.js":38}],29:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("double-bits");e.exports=function(t){var e=i.exponent(t);return e<52?new n(t):new n(t*Math.pow(2,52-e)).ushln(e-52)}},{"bn.js":38,"double-bits":85}],30:[function(t,e,r){"use strict";var n=t("./num-to-bn"),i=t("./bn-sign");e.exports=function(t,e){var r=i(t),a=i(e);if(0===r)return[n(0),n(1)];if(0===a)return[n(0),n(0)];a<0&&(t=t.neg(),e=e.neg());var o=t.gcd(e);if(o.cmpn(1))return[t.div(o),e.div(o)];return[t,e]}},{"./bn-sign":25,"./num-to-bn":29}],31:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return new n(t)}},{"bn.js":38}],32:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[0]),t[1].mul(e[1]))}},{"./lib/rationalize":30}],33:[function(t,e,r){"use strict";var n=t("./lib/bn-sign");e.exports=function(t){return n(t[0])*n(t[1])}},{"./lib/bn-sign":25}],34:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},{"./lib/rationalize":30}],35:[function(t,e,r){"use strict";var n=t("./lib/bn-to-num"),i=t("./lib/ctz");e.exports=function(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var a=e.abs().divmod(r.abs()),o=a.div,s=n(o),l=a.mod,u=e.negative!==r.negative?-1:1;if(0===l.cmpn(0))return u*s;if(s){var c=i(s)+4,f=n(l.ushln(c).divRound(r));return u*(s+f*Math.pow(2,-c))}var h=r.bitLength()-l.bitLength()+53,f=n(l.ushln(h).divRound(r));return h<1023?u*f*Math.pow(2,-h):(f*=Math.pow(2,-1023),u*f*Math.pow(2,1023-h))}},{"./lib/bn-to-num":26,"./lib/ctz":27}],36:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],37:[function(t,e,r){"use strict";function n(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}r.INT_BITS=32,r.INT_MAX=2147483647,r.INT_MIN=-1<<31,r.sign=function(t){return(t>0)-(t<0)},r.abs=function(t){var e=t>>31;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},r.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},r.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},r.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},r.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],38:[function(t,e,r){!function(e,r){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function a(t,e,r){if(a.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof e?e.exports=a:r.BN=a,a.BN=a,a.wordSize=26;try{o=t("buffer").Buffer}catch(t){}function s(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;a=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function l(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return i}a.isBN=function(t){return t instanceof a||null!==t&&"object"==typeof t&&t.constructor.wordSize===a.wordSize&&Array.isArray(t.words)},a.max=function(t,e){return t.cmp(e)>0?t:e},a.min=function(t,e){return t.cmp(e)<0?t:e},a.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if("le"===r)for(i=0,a=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},a.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=s(t,r,r+6),this.words[n]|=i<>>26-a&4194303,(a+=24)>=26&&(a-=26,n++);r+6!==e&&(i=s(t,e,r+6),this.words[n]|=i<>>26-a&4194303),this.strip()},a.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,o=a%n,s=Math.min(a,a-o)+r,u=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],a=0|e.words[0],o=i*a,s=67108863&o,l=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&l,h=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=h;d++){var p=u-d|0;c+=(o=(i=0|t.words[p])*(a=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,l=0|c}return 0!==l?r.words[u]=0|l:r.length--,r.strip()}a.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,a=0,o=0;o>>24-i&16777215)||o!==this.length-1?u[6-l.length]+l+r:l+r,(i+=2)>=26&&(i-=26,o--)}for(0!==a&&(r=a.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var h=c[t],d=f[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?g+r:u[h-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(t,e){return n("undefined"!=typeof o),this.toArrayLike(o,t,e)},a.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},a.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,"byte array longer than desired length"),n(a>0,"Requested array length <= 0"),this.strip();var o,s,l="le"===e,u=new t(a),c=this.clone();if(l){for(s=0;!c.isZero();s++)o=c.andln(255),c.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},a.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},a.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},a.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},a.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},a.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},a.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},a.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},a.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},a.prototype.notn=function(t){return this.clone().inotn(t)},a.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26;for(;0!==i&&a>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},a.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,g=d>>>13,v=0|o[2],m=8191&v,y=v>>>13,b=0|o[3],x=8191&b,_=b>>>13,w=0|o[4],A=8191&w,M=w>>>13,T=0|o[5],k=8191&T,E=T>>>13,S=0|o[6],L=8191&S,C=S>>>13,O=0|o[7],R=8191&O,P=O>>>13,z=0|o[8],I=8191&z,N=z>>>13,D=0|o[9],F=8191&D,j=D>>>13,B=0|s[0],U=8191&B,V=B>>>13,H=0|s[1],q=8191&H,G=H>>>13,X=0|s[2],W=8191&X,Y=X>>>13,Z=0|s[3],Q=8191&Z,$=Z>>>13,J=0|s[4],K=8191&J,tt=J>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],at=8191&it,ot=it>>>13,st=0|s[7],lt=8191&st,ut=st>>>13,ct=0|s[8],ft=8191&ct,ht=ct>>>13,dt=0|s[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(u+(n=Math.imul(f,U))|0)+((8191&(i=(i=Math.imul(f,V))+Math.imul(h,U)|0))<<13)|0;u=((a=Math.imul(h,V))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,U),i=(i=Math.imul(p,V))+Math.imul(g,U)|0,a=Math.imul(g,V);var mt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(h,q)|0))<<13)|0;u=((a=a+Math.imul(h,G)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,U),i=(i=Math.imul(m,V))+Math.imul(y,U)|0,a=Math.imul(y,V),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(g,q)|0,a=a+Math.imul(g,G)|0;var yt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,Y)|0)+Math.imul(h,W)|0))<<13)|0;u=((a=a+Math.imul(h,Y)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(x,U),i=(i=Math.imul(x,V))+Math.imul(_,U)|0,a=Math.imul(_,V),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,G)|0)+Math.imul(y,q)|0,a=a+Math.imul(y,G)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(g,W)|0,a=a+Math.imul(g,Y)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(h,Q)|0))<<13)|0;u=((a=a+Math.imul(h,$)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(A,U),i=(i=Math.imul(A,V))+Math.imul(M,U)|0,a=Math.imul(M,V),n=n+Math.imul(x,q)|0,i=(i=i+Math.imul(x,G)|0)+Math.imul(_,q)|0,a=a+Math.imul(_,G)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(y,W)|0,a=a+Math.imul(y,Y)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(g,Q)|0,a=a+Math.imul(g,$)|0;var xt=(u+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(h,K)|0))<<13)|0;u=((a=a+Math.imul(h,tt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(k,U),i=(i=Math.imul(k,V))+Math.imul(E,U)|0,a=Math.imul(E,V),n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(M,q)|0,a=a+Math.imul(M,G)|0,n=n+Math.imul(x,W)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(_,W)|0,a=a+Math.imul(_,Y)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,$)|0)+Math.imul(y,Q)|0,a=a+Math.imul(y,$)|0,n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(g,K)|0,a=a+Math.imul(g,tt)|0;var _t=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(h,rt)|0))<<13)|0;u=((a=a+Math.imul(h,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(L,U),i=(i=Math.imul(L,V))+Math.imul(C,U)|0,a=Math.imul(C,V),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(E,q)|0,a=a+Math.imul(E,G)|0,n=n+Math.imul(A,W)|0,i=(i=i+Math.imul(A,Y)|0)+Math.imul(M,W)|0,a=a+Math.imul(M,Y)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(_,Q)|0,a=a+Math.imul(_,$)|0,n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(y,K)|0,a=a+Math.imul(y,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(g,rt)|0,a=a+Math.imul(g,nt)|0;var wt=(u+(n=n+Math.imul(f,at)|0)|0)+((8191&(i=(i=i+Math.imul(f,ot)|0)+Math.imul(h,at)|0))<<13)|0;u=((a=a+Math.imul(h,ot)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(R,U),i=(i=Math.imul(R,V))+Math.imul(P,U)|0,a=Math.imul(P,V),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,G)|0)+Math.imul(C,q)|0,a=a+Math.imul(C,G)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,Y)|0)+Math.imul(E,W)|0,a=a+Math.imul(E,Y)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(M,Q)|0,a=a+Math.imul(M,$)|0,n=n+Math.imul(x,K)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(_,K)|0,a=a+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(y,rt)|0,a=a+Math.imul(y,nt)|0,n=n+Math.imul(p,at)|0,i=(i=i+Math.imul(p,ot)|0)+Math.imul(g,at)|0,a=a+Math.imul(g,ot)|0;var At=(u+(n=n+Math.imul(f,lt)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(h,lt)|0))<<13)|0;u=((a=a+Math.imul(h,ut)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(I,U),i=(i=Math.imul(I,V))+Math.imul(N,U)|0,a=Math.imul(N,V),n=n+Math.imul(R,q)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(P,q)|0,a=a+Math.imul(P,G)|0,n=n+Math.imul(L,W)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(C,W)|0,a=a+Math.imul(C,Y)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(E,Q)|0,a=a+Math.imul(E,$)|0,n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(M,K)|0,a=a+Math.imul(M,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(_,rt)|0,a=a+Math.imul(_,nt)|0,n=n+Math.imul(m,at)|0,i=(i=i+Math.imul(m,ot)|0)+Math.imul(y,at)|0,a=a+Math.imul(y,ot)|0,n=n+Math.imul(p,lt)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(g,lt)|0,a=a+Math.imul(g,ut)|0;var Mt=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ht)|0)+Math.imul(h,ft)|0))<<13)|0;u=((a=a+Math.imul(h,ht)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(F,U),i=(i=Math.imul(F,V))+Math.imul(j,U)|0,a=Math.imul(j,V),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,G)|0)+Math.imul(N,q)|0,a=a+Math.imul(N,G)|0,n=n+Math.imul(R,W)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(P,W)|0,a=a+Math.imul(P,Y)|0,n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,$)|0)+Math.imul(C,Q)|0,a=a+Math.imul(C,$)|0,n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(E,K)|0,a=a+Math.imul(E,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,nt)|0,n=n+Math.imul(x,at)|0,i=(i=i+Math.imul(x,ot)|0)+Math.imul(_,at)|0,a=a+Math.imul(_,ot)|0,n=n+Math.imul(m,lt)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(y,lt)|0,a=a+Math.imul(y,ut)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ht)|0)+Math.imul(g,ft)|0,a=a+Math.imul(g,ht)|0;var Tt=(u+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,gt)|0)+Math.imul(h,pt)|0))<<13)|0;u=((a=a+Math.imul(h,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(F,q),i=(i=Math.imul(F,G))+Math.imul(j,q)|0,a=Math.imul(j,G),n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(N,W)|0,a=a+Math.imul(N,Y)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(P,Q)|0,a=a+Math.imul(P,$)|0,n=n+Math.imul(L,K)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(C,K)|0,a=a+Math.imul(C,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(E,rt)|0,a=a+Math.imul(E,nt)|0,n=n+Math.imul(A,at)|0,i=(i=i+Math.imul(A,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,n=n+Math.imul(x,lt)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(_,lt)|0,a=a+Math.imul(_,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ht)|0)+Math.imul(y,ft)|0,a=a+Math.imul(y,ht)|0;var kt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((a=a+Math.imul(g,gt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(F,W),i=(i=Math.imul(F,Y))+Math.imul(j,W)|0,a=Math.imul(j,Y),n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(N,Q)|0,a=a+Math.imul(N,$)|0,n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(P,K)|0,a=a+Math.imul(P,tt)|0,n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(C,rt)|0,a=a+Math.imul(C,nt)|0,n=n+Math.imul(k,at)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(E,at)|0,a=a+Math.imul(E,ot)|0,n=n+Math.imul(A,lt)|0,i=(i=i+Math.imul(A,ut)|0)+Math.imul(M,lt)|0,a=a+Math.imul(M,ut)|0,n=n+Math.imul(x,ft)|0,i=(i=i+Math.imul(x,ht)|0)+Math.imul(_,ft)|0,a=a+Math.imul(_,ht)|0;var Et=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,gt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((a=a+Math.imul(y,gt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(F,Q),i=(i=Math.imul(F,$))+Math.imul(j,Q)|0,a=Math.imul(j,$),n=n+Math.imul(I,K)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(N,K)|0,a=a+Math.imul(N,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(P,rt)|0,a=a+Math.imul(P,nt)|0,n=n+Math.imul(L,at)|0,i=(i=i+Math.imul(L,ot)|0)+Math.imul(C,at)|0,a=a+Math.imul(C,ot)|0,n=n+Math.imul(k,lt)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(E,lt)|0,a=a+Math.imul(E,ut)|0,n=n+Math.imul(A,ft)|0,i=(i=i+Math.imul(A,ht)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ht)|0;var St=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,gt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((a=a+Math.imul(_,gt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(F,K),i=(i=Math.imul(F,tt))+Math.imul(j,K)|0,a=Math.imul(j,tt),n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(N,rt)|0,a=a+Math.imul(N,nt)|0,n=n+Math.imul(R,at)|0,i=(i=i+Math.imul(R,ot)|0)+Math.imul(P,at)|0,a=a+Math.imul(P,ot)|0,n=n+Math.imul(L,lt)|0,i=(i=i+Math.imul(L,ut)|0)+Math.imul(C,lt)|0,a=a+Math.imul(C,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ht)|0)+Math.imul(E,ft)|0,a=a+Math.imul(E,ht)|0;var Lt=(u+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,gt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((a=a+Math.imul(M,gt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(F,rt),i=(i=Math.imul(F,nt))+Math.imul(j,rt)|0,a=Math.imul(j,nt),n=n+Math.imul(I,at)|0,i=(i=i+Math.imul(I,ot)|0)+Math.imul(N,at)|0,a=a+Math.imul(N,ot)|0,n=n+Math.imul(R,lt)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(P,lt)|0,a=a+Math.imul(P,ut)|0,n=n+Math.imul(L,ft)|0,i=(i=i+Math.imul(L,ht)|0)+Math.imul(C,ft)|0,a=a+Math.imul(C,ht)|0;var Ct=(u+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,gt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((a=a+Math.imul(E,gt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(F,at),i=(i=Math.imul(F,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),n=n+Math.imul(I,lt)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(N,lt)|0,a=a+Math.imul(N,ut)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ht)|0)+Math.imul(P,ft)|0,a=a+Math.imul(P,ht)|0;var Ot=(u+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,gt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((a=a+Math.imul(C,gt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(F,lt),i=(i=Math.imul(F,ut))+Math.imul(j,lt)|0,a=Math.imul(j,ut),n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ht)|0)+Math.imul(N,ft)|0,a=a+Math.imul(N,ht)|0;var Rt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,gt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((a=a+Math.imul(P,gt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(F,ft),i=(i=Math.imul(F,ht))+Math.imul(j,ft)|0,a=Math.imul(j,ht);var Pt=(u+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,gt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((a=a+Math.imul(N,gt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var zt=(u+(n=Math.imul(F,pt))|0)+((8191&(i=(i=Math.imul(F,gt))+Math.imul(j,pt)|0))<<13)|0;return u=((a=Math.imul(j,gt))+(i>>>13)|0)+(zt>>>26)|0,zt&=67108863,l[0]=vt,l[1]=mt,l[2]=yt,l[3]=bt,l[4]=xt,l[5]=_t,l[6]=wt,l[7]=At,l[8]=Mt,l[9]=Tt,l[10]=kt,l[11]=Et,l[12]=St,l[13]=Lt,l[14]=Ct,l[15]=Ot,l[16]=Rt,l[17]=Pt,l[18]=zt,0!==u&&(l[19]=u,r.length++),r};function p(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(d=h),a.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?h(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,n=o,o=i}return 0!==n?r.words[a]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=a.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,i,a){for(var o=0;o>>=1)i++;return 1<>>=13,r[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=a>>>26,this.words[r]=67108863&a}return 0!==e&&(this.words[r]=e,this.length++),this},a.prototype.muln=function(t){return this.clone().imuln(t)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new a(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,u=0;u=0&&(0!==c||u>=i);u--){var f=0|this.words[u];this.words[u]=c<<26-a|f>>>a,c=f&s}return l&&0!==c&&(l.words[l.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},a.prototype.shln=function(t){return this.clone().ishln(t)},a.prototype.ushln=function(t){return this.clone().iushln(t)},a.prototype.shrn=function(t){return this.clone().ishrn(t)},a.prototype.ushrn=function(t){return this.clone().iushrn(t)},a.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},a.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(l/67108864|0),this.words[i+r]=67108863&a}for(;i>26,this.words[i+r]=67108863&a;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&a;return this.negative=1,this.strip()},a.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var s,l=n.length-i.length;if("mod"!==e){(s=new a(null)).length=l+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var h=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(h=Math.min(h/o|0,67108863),n._ishlnsubmul(i,h,f);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=h)}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},a.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(i=s.div.neg()),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new a(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new a(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new a(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,s},a.prototype.div=function(t){return this.divmod(t,"div",!1).div},a.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},a.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},a.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),a=r.cmp(n);return a<0||1===i&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},a.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},a.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},a.prototype.divn=function(t){return this.clone().idivn(t)},a.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new a(1),o=new a(0),s=new a(0),l=new a(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),f=e.clone();!e.isZero();){for(var h=0,d=1;0==(e.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(e.iushrn(h);h-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(c),o.isub(f)),i.iushrn(1),o.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(c),l.isub(f)),s.iushrn(1),l.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(s),o.isub(l)):(r.isub(e),s.isub(i),l.isub(o))}return{a:s,b:l,gcd:r.iushln(u)}},a.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new a(1),s=new a(0),l=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,c=1;0==(e.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(l),o.iushrn(1);for(var f=0,h=1;0==(r.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(s)):(r.isub(e),s.isub(o))}return(i=0===e.cmpn(1)?o:s).cmpn(0)<0&&i.iadd(t),i},a.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},a.prototype.invm=function(t){return this.egcd(t).a.umod(t)},a.prototype.isEven=function(){return 0==(1&this.words[0])},a.prototype.isOdd=function(){return 1==(1&this.words[0])},a.prototype.andln=function(t){return this.words[0]&t},a.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},a.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},a.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},a.prototype.gtn=function(t){return 1===this.cmpn(t)},a.prototype.gt=function(t){return 1===this.cmp(t)},a.prototype.gten=function(t){return this.cmpn(t)>=0},a.prototype.gte=function(t){return this.cmp(t)>=0},a.prototype.ltn=function(t){return-1===this.cmpn(t)},a.prototype.lt=function(t){return-1===this.cmp(t)},a.prototype.lten=function(t){return this.cmpn(t)<=0},a.prototype.lte=function(t){return this.cmp(t)<=0},a.prototype.eqn=function(t){return 0===this.cmpn(t)},a.prototype.eq=function(t){return 0===this.cmp(t)},a.red=function(t){return new w(t)},a.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},a.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(t){return this.red=t,this},a.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},a.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},a.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},a.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},a.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},a.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},a.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},a.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},a.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new a(e,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function x(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=a._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var t=new a(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(y,m),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=a}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},a._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new b;else if("p192"===t)e=new x;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return v[t]=e,e},w.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new a(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var s=new a(1).toRed(this),l=s.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new a(2*c*c).toRed(this);0!==this.pow(c,u).cmp(l);)c.redIAdd(l);for(var f=this.pow(c,i),h=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=o;0!==d.cmp(s);){for(var g=d,v=0;0!==g.cmp(s);v++)g=g.redSqr();n(v=0;n--){for(var u=e.words[n],c=l-1;c>=0;c--){var f=u>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==o?(o<<=1,o|=f,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[o]),s=0,o=0)):s=0}l=26}return i},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},a.mont=function(t){return new A(t)},i(A,w),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new a(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof e||e,this)},{buffer:47}],39:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i=t.length,a=0;for(e=0;e>>1;if(!(c<=0)){var f,h=i.mallocDouble(2*c*s),d=i.mallocInt32(s);if((s=l(t,c,h,d))>0){if(1===c&&n)a.init(s),f=a.sweepComplete(c,r,0,s,h,d,0,s,h,d);else{var p=i.mallocDouble(2*c*u),g=i.mallocInt32(u);(u=l(e,c,p,g))>0&&(a.init(s+u),f=1===c?a.sweepBipartite(c,r,0,s,h,d,0,u,p,g):o(c,r,n,s,h,d,u,p,g),i.free(p),i.free(g))}i.free(h),i.free(d)}return f}}}function c(t,e){n.push([t,e])}},{"./lib/intersect":42,"./lib/sweep":46,"typedarray-pool":347}],41:[function(t,e,r){"use strict";var n="d",i="ax",a="vv",o="fp",s="es",l="rs",u="re",c="rb",f="ri",h="rp",d="bs",p="be",g="bb",v="bi",m="bp",y="rv",b="Q",x=[n,i,a,l,u,c,f,d,p,g,v];function _(t){var e="bruteForce"+(t?"Full":"Partial"),r=[],_=x.slice();t||_.splice(3,0,o);var w=["function "+e+"("+_.join()+"){"];function A(e,o){var _=function(t,e,r){var o="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),_=["function ",o,"(",x.join(),"){","var ",s,"=2*",n,";"],w="for(var i="+l+","+h+"="+s+"*"+l+";i<"+u+";++i,"+h+"+="+s+"){var x0="+c+"["+i+"+"+h+"],x1="+c+"["+i+"+"+h+"+"+n+"],xi="+f+"[i];",A="for(var j="+d+","+m+"="+s+"*"+d+";j<"+p+";++j,"+m+"+="+s+"){var y0="+g+"["+i+"+"+m+"],"+(r?"y1="+g+"["+i+"+"+m+"+"+n+"],":"")+"yi="+v+"[j];";return t?_.push(w,b,":",A):_.push(A,b,":",w),r?_.push("if(y1"+p+"-"+d+"){"),t?(A(!0,!1),w.push("}else{"),A(!1,!1)):(w.push("if("+o+"){"),A(!0,!0),w.push("}else{"),A(!0,!1),w.push("}}else{if("+o+"){"),A(!1,!0),w.push("}else{"),A(!1,!1),w.push("}")),w.push("}}return "+e);var M=r.join("")+w.join("");return new Function(M)()}r.partial=_(!1),r.full=_(!0)},{}],42:[function(t,e,r){"use strict";e.exports=function(t,e,r,a,c,E,S,L,C){!function(t,e){var r=8*i.log2(e+1)*(t+1)|0,a=i.nextPow2(x*r);w.length0;){var z=(R-=1)*x,I=w[z],N=w[z+1],D=w[z+2],F=w[z+3],j=w[z+4],B=w[z+5],U=R*_,V=A[U],H=A[U+1],q=1&B,G=!!(16&B),X=c,W=E,Y=L,Z=C;if(q&&(X=L,W=C,Y=c,Z=E),!(2&B&&(D=v(t,I,N,D,X,W,H),N>=D)||4&B&&(N=m(t,I,N,D,X,W,V))>=D)){var Q=D-N,$=j-F;if(G){if(t*Q*(Q+$)=p0)&&!(p1>=hi)",["p0","p1"]),g=c("lo===p0",["p0"]),v=c("lo>>1,h=2*t,d=f,p=s[h*f+e];for(;u=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(c-1),A=h*d,M=0;Mr&&i[f+e]>u;--c,f-=o){for(var h=f,d=f+o,p=0;p=0&&i.push("lo=e[k+n]");t.indexOf("hi")>=0&&i.push("hi=e[k+o]");return r.push(n.replace("_",i.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],45:[function(t,e,r){"use strict";e.exports=function(t,e){e<=4*n?i(0,e-1,t):function t(e,r,f){var h=(r-e+1)/6|0,d=e+h,p=r-h,g=e+r>>1,v=g-h,m=g+h,y=d,b=v,x=g,_=m,w=p,A=e+1,M=r-1,T=0;u(y,b,f)&&(T=y,y=b,b=T);u(_,w,f)&&(T=_,_=w,w=T);u(y,x,f)&&(T=y,y=x,x=T);u(b,x,f)&&(T=b,b=x,x=T);u(y,_,f)&&(T=y,y=_,_=T);u(x,_,f)&&(T=x,x=_,_=T);u(b,w,f)&&(T=b,b=w,w=T);u(b,x,f)&&(T=b,b=x,x=T);u(_,w,f)&&(T=_,_=w,w=T);var k=f[2*b];var E=f[2*b+1];var S=f[2*_];var L=f[2*_+1];var C=2*y;var O=2*x;var R=2*w;var P=2*d;var z=2*g;var I=2*p;for(var N=0;N<2;++N){var D=f[C+N],F=f[O+N],j=f[R+N];f[P+N]=D,f[z+N]=F,f[I+N]=j}o(v,e,f);o(m,r,f);for(var B=A;B<=M;++B)if(c(B,k,E,f))B!==A&&a(B,A,f),++A;else if(!c(B,S,L,f))for(;;){if(c(M,S,L,f)){c(M,k,E,f)?(s(B,A,M,f),++A,--M):(a(B,M,f),--M);break}if(--Mt;){var u=r[l-2],c=r[l-1];if(ur[e+1])}function c(t,e,r,n){var i=n[t*=2];return i>>1;a(d,E);for(var S=0,L=0,A=0;A=o)p(u,c,L--,C=C-o|0);else if(C>=0)p(s,l,S--,C);else if(C<=-o){C=-C-o|0;for(var O=0;O>>1;a(d,S);for(var L=0,C=0,O=0,M=0;M>1==d[2*M+3]>>1&&(P=2,M+=1),R<0){for(var z=-(R>>1)-1,I=0;I>1)-1;0===P?p(s,l,L--,z):1===P?p(u,c,C--,z):2===P&&p(f,h,O--,z)}}},scanBipartite:function(t,e,r,n,i,u,c,f,h,v,m,y){var b=0,x=2*t,_=e,w=e+t,A=1,M=1;n?M=o:A=o;for(var T=i;T>>1;a(d,L);for(var C=0,T=0;T=o?(R=!n,k-=o):(R=!!n,k-=1),R)g(s,l,C++,k);else{var P=y[k],z=x*k,I=m[z+e+1],N=m[z+e+1+t];t:for(var D=0;D>>1;a(d,A);for(var M=0,b=0;b=o)s[M++]=x-o;else{var k=p[x-=1],E=v*x,S=h[E+e+1],L=h[E+e+1+t];t:for(var C=0;C=0;--C)if(s[C]===x){for(var z=C+1;z0&&s.length>a){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=o[e]=r,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(r=o[t]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,i=v(t,n),a=0;a=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,a=o;break}if(a<0)return this;0===a?r.shift():function(t,e){for(var r=e,n=r+1,i=t.length;n=0;a--)this.removeListener(t,e[a]);return this},o.prototype.listeners=function(t){return p(this,t,!0)},o.prototype.rawListeners=function(t){return p(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],49:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var a=2147483647;function o(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|d(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return f(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(B(t,ArrayBuffer)||t&&B(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||B(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:D(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var a,o=1,s=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var c=-1;for(a=r;as&&(r=s-l),a=r;a>=0;a--){for(var f=!0,h=0;hi&&(n=i):n=i;var a=e.length;n>a/2&&(n=a/2);for(var o=0;o>8,i=r%256,a.push(i),a.push(n);return a}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function M(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+f<=r)switch(f){case 1:u<128&&(c=u);break;case 2:128==(192&(a=t[i+1]))&&(l=(31&u)<<6|63&a)>127&&(c=l);break;case 3:a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&(l=(15&u)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(l=(15&u)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(c=l)}null===c?(c=65533,f=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=f}return function(t){var e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return M(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(B(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var a=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),l=Math.min(a,o),u=this.slice(n,i),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return x(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",a=e;ar)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,a){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,n,a){return e=+e,r>>>=0,a||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function z(t,e,r,n,a){return e=+e,r>>>=0,a||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],i=1,a=0;++a>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],i=1,a=0;++a=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*e)),a},s.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[e]=255&t;++a>>=0,r>>>=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,a=1;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=t/a&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return z(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return z(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--a)t[a+e]=this[a+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(a=e;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function B(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}},{"base64-js":19,ieee754:252}],50:[function(t,e,r){"use strict";var n=t("./lib/monotone"),i=t("./lib/triangulation"),a=t("./lib/delaunay"),o=t("./lib/filter");function s(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function l(t,e){return t[0]-e[0]||t[1]-e[1]}function u(t,e,r){return e in t?t[e]:r}e.exports=function(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var c=!!u(r,"delaunay",!0),f=!!u(r,"interior",!0),h=!!u(r,"exterior",!0),d=!!u(r,"infinity",!1);if(!f&&!h||0===t.length)return[];var p=n(t,e);if(c||f!==h||d){for(var g=i(t.length,function(t){return t.map(s).sort(l)}(e)),v=0;v0;){for(var c=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;p=0||(e.flip(s,c),i(t,e,r,f,s,h),i(t,e,r,s,h,f),i(t,e,r,h,c,f),i(t,e,r,c,f,h)))}}},{"binary-search-bounds":55,"robust-in-sphere":319}],52:[function(t,e,r){"use strict";var n,i=t("binary-search-bounds");function a(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function o(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}e.exports=function(t,e,r){var n=function(t,e){for(var r=t.cells(),n=r.length,i=0;i0||l.length>0;){for(;s.length>0;){var d=s.pop();if(u[d]!==-i){u[d]=i;c[d];for(var p=0;p<3;++p){var g=h[3*d+p];g>=0&&0===u[g]&&(f[3*d+p]?l.push(g):(s.push(g),u[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=function(t,e,r){for(var n=0,i=0;i1&&i(r[h[d-2]],r[h[d-1]],a)>0;)t.push([h[d-1],h[d-2],o]),d-=1;h.length=d,h.push(o);var p=c.upperIds;for(d=p.length;d>1&&i(r[p[d-2]],r[p[d-1]],a)<0;)t.push([p[d-2],p[d-1],o]),d-=1;p.length=d,p.push(o)}}function d(t,e){var r;return(r=t.a[0]m[0]&&i.push(new u(m,v,s,f),new u(v,m,o,f))}i.sort(c);for(var y=i[0].a[0]-(1+Math.abs(i[0].a[0]))*Math.pow(2,-52),b=[new l([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=i.length;f<_;++f){var w=i[f],A=w.type;A===a?h(x,b,t,w.a,w.idx):A===s?p(b,t,w):g(b,t,w)}return x}},{"binary-search-bounds":55,"robust-orientation":321}],54:[function(t,e,r){"use strict";var n=t("binary-search-bounds");function i(t,e){this.stars=t,this.edges=e}e.exports=function(t,e){for(var r=new Array(t),n=0;n=0}}(),a.removeTriangle=function(t,e,r){var n=this.stars;o(n[t],e,r),o(n[e],r,t),o(n[r],t,e)},a.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},a.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;n>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],56:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1,r=1;rr?r:t:te?e:t}},{}],60:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n;if(r){n=e;for(var i=new Array(e.length),a=0;ae[2]?1:0)}function m(t,e,r){if(0!==t.length){if(e)for(var n=0;n=0;--a){var b=e[c=(E=n[a])[0]],x=b[0],_=b[1],w=t[x],A=t[_];if((w[0]-A[0]||w[1]-A[1])<0){var M=x;x=_,_=M}b[0]=x;var T,k=b[1]=E[1];for(i&&(T=b[2]);a>0&&n[a-1][0]===c;){var E,S=(E=n[--a])[1];i?e.push([k,S,T]):e.push([k,S]),k=S}i?e.push([k,_,T]):e.push([k,_])}return h}(t,e,h,v,r));return m(e,y,r),!!y||(h.length>0||v.length>0)}},{"./lib/rat-seg-intersect":61,"big-rat":23,"big-rat/cmp":21,"big-rat/to-float":35,"box-intersect":40,nextafter:286,"rat-vec":310,"robust-segment-intersect":324,"union-find":348}],61:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var a=s(e,t),f=s(n,r),h=c(a,f);if(0===o(h))return null;var d=s(t,r),p=c(f,d),g=i(p,h),v=u(a,g);return l(t,v)};var n=t("big-rat/mul"),i=t("big-rat/div"),a=t("big-rat/sub"),o=t("big-rat/sign"),s=t("rat-vec/sub"),l=t("rat-vec/add"),u=t("rat-vec/muls");function c(t,e){return a(n(t[0],e[1]),n(t[1],e[0]))}},{"big-rat/div":22,"big-rat/mul":32,"big-rat/sign":33,"big-rat/sub":34,"rat-vec/add":309,"rat-vec/muls":311,"rat-vec/sub":312}],62:[function(t,e,r){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],63:[function(t,e,r){"use strict";var n=t("color-rgba"),i=t("clamp"),a=t("dtype");e.exports=function(t,e){"float"!==e&&e||(e="array"),"uint"===e&&(e="uint8"),"uint_clamped"===e&&(e="uint8_clamped");var r=new(a(e))(4),o="uint8"!==e&&"uint8_clamped"!==e;return t.length&&"string"!=typeof t||((t=n(t))[0]/=255,t[1]/=255,t[2]/=255),function(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||!!(Array.isArray(t)&&(t[0]>1||0===t[0])&&(t[1]>1||0===t[1])&&(t[2]>1||0===t[2])&&(!t[3]||t[3]>1))}(t)?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:255,o&&(r[0]/=255,r[1]/=255,r[2]/=255,r[3]/=255),r):(o?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:1):(r[0]=i(Math.floor(255*t[0]),0,255),r[1]=i(Math.floor(255*t[1]),0,255),r[2]=i(Math.floor(255*t[2]),0,255),r[3]=null==t[3]?255:i(Math.floor(255*t[3]),0,255)),r)}},{clamp:59,"color-rgba":65,dtype:86}],64:[function(t,e,r){(function(r){"use strict";var n=t("color-name"),i=t("is-plain-obj"),a=t("defined");e.exports=function(t){var e,s,l=[],u=1;if("string"==typeof t)if(n[t])l=n[t].slice(),s="rgb";else if("transparent"===t)u=0,s="rgb",l=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var c=t.slice(1),f=c.length,h=f<=4;u=1,h?(l=[parseInt(c[0]+c[0],16),parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16)],4===f&&(u=parseInt(c[3]+c[3],16)/255)):(l=[parseInt(c[0]+c[1],16),parseInt(c[2]+c[3],16),parseInt(c[4]+c[5],16)],8===f&&(u=parseInt(c[6]+c[7],16)/255)),l[0]||(l[0]=0),l[1]||(l[1]=0),l[2]||(l[2]=0),s="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var d=e[1],c=d.replace(/a$/,"");s=c;var f="cmyk"===c?4:"gray"===c?1:3;l=e[2].trim().split(/\s*,\s*/).map(function(t,e){if(/%$/.test(t))return e===f?parseFloat(t)/100:"rgb"===c?255*parseFloat(t)/100:parseFloat(t);if("h"===c[e]){if(/deg$/.test(t))return parseFloat(t);if(void 0!==o[t])return o[t]}return parseFloat(t)}),d===c&&l.push(1),u=void 0===l[f]?1:l[f],l=l.slice(0,f)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(l=t.match(/([0-9]+)/g).map(function(t){return parseFloat(t)}),s=t.match(/([a-z])/gi).join("").toLowerCase());else if(isNaN(t))if(i(t)){var p=a(t.r,t.red,t.R,null);null!==p?(s="rgb",l=[p,a(t.g,t.green,t.G),a(t.b,t.blue,t.B)]):(s="hsl",l=[a(t.h,t.hue,t.H),a(t.s,t.saturation,t.S),a(t.l,t.lightness,t.L,t.b,t.brightness)]),u=a(t.a,t.alpha,t.opacity,1),null!=t.opacity&&(u/=100)}else(Array.isArray(t)||r.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(t))&&(l=[t[0],t[1],t[2]],s="rgb",u=4===t.length?t[3]:1);else s="rgb",l=[t>>>16,(65280&t)>>>8,255&t];return{space:s,values:l,alpha:u}};var o={red:0,orange:60,yellow:120,green:180,blue:240,purple:300}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"color-name":62,defined:83,"is-plain-obj":260}],65:[function(t,e,r){"use strict";var n=t("color-parse"),i=t("color-space/hsl"),a=t("clamp");e.exports=function(t){var e,r=n(t);return r.space?((e=Array(3))[0]=a(r.values[0],0,255),e[1]=a(r.values[1],0,255),e[2]=a(r.values[2],0,255),"h"===r.space[0]&&(e=i.rgb(e)),e.push(a(r.alpha,0,1)),e):[]}},{clamp:59,"color-parse":64,"color-space/hsl":66}],66:[function(t,e,r){"use strict";var n=t("./rgb");e.exports={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e,r,n,i,a,o=t[0]/360,s=t[1]/100,l=t[2]/100;if(0===s)return[a=255*l,a,a];e=2*l-(r=l<.5?l*(1+s):l+s-l*s),i=[0,0,0];for(var u=0;u<3;u++)(n=o+1/3*-(u-1))<0?n++:n>1&&n--,a=6*n<1?e+6*(r-e)*n:2*n<1?r:3*n<2?e+(r-e)*(2/3-n)*6:e,i[u]=255*a;return i}},n.hsl=function(t){var e,r,n=t[0]/255,i=t[1]/255,a=t[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),l=s-o;return s===o?e=0:n===s?e=(i-a)/l:i===s?e=2+(a-n)/l:a===s&&(e=4+(n-i)/l),(e=Math.min(60*e,360))<0&&(e+=360),r=(o+s)/2,[e,100*(s===o?0:r<=.5?l/(s+o):l/(2-s-o)),100*r]}},{"./rgb":67}],67:[function(t,e,r){"use strict";e.exports={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]}},{}],68:[function(t,e,r){e.exports={jet:[{index:0,rgb:[0,0,131]},{index:.125,rgb:[0,60,170]},{index:.375,rgb:[5,255,255]},{index:.625,rgb:[255,255,0]},{index:.875,rgb:[250,0,0]},{index:1,rgb:[128,0,0]}],hsv:[{index:0,rgb:[255,0,0]},{index:.169,rgb:[253,255,2]},{index:.173,rgb:[247,255,2]},{index:.337,rgb:[0,252,4]},{index:.341,rgb:[0,252,10]},{index:.506,rgb:[1,249,255]},{index:.671,rgb:[2,0,253]},{index:.675,rgb:[8,0,253]},{index:.839,rgb:[255,0,251]},{index:.843,rgb:[255,0,245]},{index:1,rgb:[255,0,6]}],hot:[{index:0,rgb:[0,0,0]},{index:.3,rgb:[230,0,0]},{index:.6,rgb:[255,210,0]},{index:1,rgb:[255,255,255]}],cool:[{index:0,rgb:[0,255,255]},{index:1,rgb:[255,0,255]}],spring:[{index:0,rgb:[255,0,255]},{index:1,rgb:[255,255,0]}],summer:[{index:0,rgb:[0,128,102]},{index:1,rgb:[255,255,102]}],autumn:[{index:0,rgb:[255,0,0]},{index:1,rgb:[255,255,0]}],winter:[{index:0,rgb:[0,0,255]},{index:1,rgb:[0,255,128]}],bone:[{index:0,rgb:[0,0,0]},{index:.376,rgb:[84,84,116]},{index:.753,rgb:[169,200,200]},{index:1,rgb:[255,255,255]}],copper:[{index:0,rgb:[0,0,0]},{index:.804,rgb:[255,160,102]},{index:1,rgb:[255,199,127]}],greys:[{index:0,rgb:[0,0,0]},{index:1,rgb:[255,255,255]}],yignbu:[{index:0,rgb:[8,29,88]},{index:.125,rgb:[37,52,148]},{index:.25,rgb:[34,94,168]},{index:.375,rgb:[29,145,192]},{index:.5,rgb:[65,182,196]},{index:.625,rgb:[127,205,187]},{index:.75,rgb:[199,233,180]},{index:.875,rgb:[237,248,217]},{index:1,rgb:[255,255,217]}],greens:[{index:0,rgb:[0,68,27]},{index:.125,rgb:[0,109,44]},{index:.25,rgb:[35,139,69]},{index:.375,rgb:[65,171,93]},{index:.5,rgb:[116,196,118]},{index:.625,rgb:[161,217,155]},{index:.75,rgb:[199,233,192]},{index:.875,rgb:[229,245,224]},{index:1,rgb:[247,252,245]}],yiorrd:[{index:0,rgb:[128,0,38]},{index:.125,rgb:[189,0,38]},{index:.25,rgb:[227,26,28]},{index:.375,rgb:[252,78,42]},{index:.5,rgb:[253,141,60]},{index:.625,rgb:[254,178,76]},{index:.75,rgb:[254,217,118]},{index:.875,rgb:[255,237,160]},{index:1,rgb:[255,255,204]}],bluered:[{index:0,rgb:[0,0,255]},{index:1,rgb:[255,0,0]}],rdbu:[{index:0,rgb:[5,10,172]},{index:.35,rgb:[106,137,247]},{index:.5,rgb:[190,190,190]},{index:.6,rgb:[220,170,132]},{index:.7,rgb:[230,145,90]},{index:1,rgb:[178,10,28]}],picnic:[{index:0,rgb:[0,0,255]},{index:.1,rgb:[51,153,255]},{index:.2,rgb:[102,204,255]},{index:.3,rgb:[153,204,255]},{index:.4,rgb:[204,204,255]},{index:.5,rgb:[255,255,255]},{index:.6,rgb:[255,204,255]},{index:.7,rgb:[255,153,255]},{index:.8,rgb:[255,102,204]},{index:.9,rgb:[255,102,102]},{index:1,rgb:[255,0,0]}],rainbow:[{index:0,rgb:[150,0,90]},{index:.125,rgb:[0,0,200]},{index:.25,rgb:[0,25,255]},{index:.375,rgb:[0,152,255]},{index:.5,rgb:[44,255,150]},{index:.625,rgb:[151,255,0]},{index:.75,rgb:[255,234,0]},{index:.875,rgb:[255,111,0]},{index:1,rgb:[255,0,0]}],portland:[{index:0,rgb:[12,51,131]},{index:.25,rgb:[10,136,186]},{index:.5,rgb:[242,211,56]},{index:.75,rgb:[242,143,56]},{index:1,rgb:[217,30,30]}],blackbody:[{index:0,rgb:[0,0,0]},{index:.2,rgb:[230,0,0]},{index:.4,rgb:[230,210,0]},{index:.7,rgb:[255,255,255]},{index:1,rgb:[160,200,255]}],earth:[{index:0,rgb:[0,0,130]},{index:.1,rgb:[0,180,180]},{index:.2,rgb:[40,210,40]},{index:.4,rgb:[230,230,50]},{index:.6,rgb:[120,70,20]},{index:1,rgb:[255,255,255]}],electric:[{index:0,rgb:[0,0,0]},{index:.15,rgb:[30,0,100]},{index:.4,rgb:[120,0,100]},{index:.6,rgb:[160,90,0]},{index:.8,rgb:[230,200,0]},{index:1,rgb:[255,250,220]}],alpha:[{index:0,rgb:[255,255,255,0]},{index:1,rgb:[255,255,255,1]}],viridis:[{index:0,rgb:[68,1,84]},{index:.13,rgb:[71,44,122]},{index:.25,rgb:[59,81,139]},{index:.38,rgb:[44,113,142]},{index:.5,rgb:[33,144,141]},{index:.63,rgb:[39,173,129]},{index:.75,rgb:[92,200,99]},{index:.88,rgb:[170,220,50]},{index:1,rgb:[253,231,37]}],inferno:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[31,12,72]},{index:.25,rgb:[85,15,109]},{index:.38,rgb:[136,34,106]},{index:.5,rgb:[186,54,85]},{index:.63,rgb:[227,89,51]},{index:.75,rgb:[249,140,10]},{index:.88,rgb:[249,201,50]},{index:1,rgb:[252,255,164]}],magma:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[28,16,68]},{index:.25,rgb:[79,18,123]},{index:.38,rgb:[129,37,129]},{index:.5,rgb:[181,54,122]},{index:.63,rgb:[229,80,100]},{index:.75,rgb:[251,135,97]},{index:.88,rgb:[254,194,135]},{index:1,rgb:[252,253,191]}],plasma:[{index:0,rgb:[13,8,135]},{index:.13,rgb:[75,3,161]},{index:.25,rgb:[125,3,168]},{index:.38,rgb:[168,34,150]},{index:.5,rgb:[203,70,121]},{index:.63,rgb:[229,107,93]},{index:.75,rgb:[248,148,65]},{index:.88,rgb:[253,195,40]},{index:1,rgb:[240,249,33]}],warm:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[172,0,187]},{index:.25,rgb:[219,0,170]},{index:.38,rgb:[255,0,130]},{index:.5,rgb:[255,63,74]},{index:.63,rgb:[255,123,0]},{index:.75,rgb:[234,176,0]},{index:.88,rgb:[190,228,0]},{index:1,rgb:[147,255,0]}],cool:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[116,0,218]},{index:.25,rgb:[98,74,237]},{index:.38,rgb:[68,146,231]},{index:.5,rgb:[0,204,197]},{index:.63,rgb:[0,247,146]},{index:.75,rgb:[0,255,88]},{index:.88,rgb:[40,255,8]},{index:1,rgb:[147,255,0]}],"rainbow-soft":[{index:0,rgb:[125,0,179]},{index:.1,rgb:[199,0,180]},{index:.2,rgb:[255,0,121]},{index:.3,rgb:[255,108,0]},{index:.4,rgb:[222,194,0]},{index:.5,rgb:[150,255,0]},{index:.6,rgb:[0,255,55]},{index:.7,rgb:[0,246,150]},{index:.8,rgb:[50,167,222]},{index:.9,rgb:[103,51,235]},{index:1,rgb:[124,0,186]}],bathymetry:[{index:0,rgb:[40,26,44]},{index:.13,rgb:[59,49,90]},{index:.25,rgb:[64,76,139]},{index:.38,rgb:[63,110,151]},{index:.5,rgb:[72,142,158]},{index:.63,rgb:[85,174,163]},{index:.75,rgb:[120,206,163]},{index:.88,rgb:[187,230,172]},{index:1,rgb:[253,254,204]}],cdom:[{index:0,rgb:[47,15,62]},{index:.13,rgb:[87,23,86]},{index:.25,rgb:[130,28,99]},{index:.38,rgb:[171,41,96]},{index:.5,rgb:[206,67,86]},{index:.63,rgb:[230,106,84]},{index:.75,rgb:[242,149,103]},{index:.88,rgb:[249,193,135]},{index:1,rgb:[254,237,176]}],chlorophyll:[{index:0,rgb:[18,36,20]},{index:.13,rgb:[25,63,41]},{index:.25,rgb:[24,91,59]},{index:.38,rgb:[13,119,72]},{index:.5,rgb:[18,148,80]},{index:.63,rgb:[80,173,89]},{index:.75,rgb:[132,196,122]},{index:.88,rgb:[175,221,162]},{index:1,rgb:[215,249,208]}],density:[{index:0,rgb:[54,14,36]},{index:.13,rgb:[89,23,80]},{index:.25,rgb:[110,45,132]},{index:.38,rgb:[120,77,178]},{index:.5,rgb:[120,113,213]},{index:.63,rgb:[115,151,228]},{index:.75,rgb:[134,185,227]},{index:.88,rgb:[177,214,227]},{index:1,rgb:[230,241,241]}],"freesurface-blue":[{index:0,rgb:[30,4,110]},{index:.13,rgb:[47,14,176]},{index:.25,rgb:[41,45,236]},{index:.38,rgb:[25,99,212]},{index:.5,rgb:[68,131,200]},{index:.63,rgb:[114,156,197]},{index:.75,rgb:[157,181,203]},{index:.88,rgb:[200,208,216]},{index:1,rgb:[241,237,236]}],"freesurface-red":[{index:0,rgb:[60,9,18]},{index:.13,rgb:[100,17,27]},{index:.25,rgb:[142,20,29]},{index:.38,rgb:[177,43,27]},{index:.5,rgb:[192,87,63]},{index:.63,rgb:[205,125,105]},{index:.75,rgb:[216,162,148]},{index:.88,rgb:[227,199,193]},{index:1,rgb:[241,237,236]}],oxygen:[{index:0,rgb:[64,5,5]},{index:.13,rgb:[106,6,15]},{index:.25,rgb:[144,26,7]},{index:.38,rgb:[168,64,3]},{index:.5,rgb:[188,100,4]},{index:.63,rgb:[206,136,11]},{index:.75,rgb:[220,174,25]},{index:.88,rgb:[231,215,44]},{index:1,rgb:[248,254,105]}],par:[{index:0,rgb:[51,20,24]},{index:.13,rgb:[90,32,35]},{index:.25,rgb:[129,44,34]},{index:.38,rgb:[159,68,25]},{index:.5,rgb:[182,99,19]},{index:.63,rgb:[199,134,22]},{index:.75,rgb:[212,171,35]},{index:.88,rgb:[221,210,54]},{index:1,rgb:[225,253,75]}],phase:[{index:0,rgb:[145,105,18]},{index:.13,rgb:[184,71,38]},{index:.25,rgb:[186,58,115]},{index:.38,rgb:[160,71,185]},{index:.5,rgb:[110,97,218]},{index:.63,rgb:[50,123,164]},{index:.75,rgb:[31,131,110]},{index:.88,rgb:[77,129,34]},{index:1,rgb:[145,105,18]}],salinity:[{index:0,rgb:[42,24,108]},{index:.13,rgb:[33,50,162]},{index:.25,rgb:[15,90,145]},{index:.38,rgb:[40,118,137]},{index:.5,rgb:[59,146,135]},{index:.63,rgb:[79,175,126]},{index:.75,rgb:[120,203,104]},{index:.88,rgb:[193,221,100]},{index:1,rgb:[253,239,154]}],temperature:[{index:0,rgb:[4,35,51]},{index:.13,rgb:[23,51,122]},{index:.25,rgb:[85,59,157]},{index:.38,rgb:[129,79,143]},{index:.5,rgb:[175,95,130]},{index:.63,rgb:[222,112,101]},{index:.75,rgb:[249,146,66]},{index:.88,rgb:[249,196,65]},{index:1,rgb:[232,250,91]}],turbidity:[{index:0,rgb:[34,31,27]},{index:.13,rgb:[65,50,41]},{index:.25,rgb:[98,69,52]},{index:.38,rgb:[131,89,57]},{index:.5,rgb:[161,112,59]},{index:.63,rgb:[185,140,66]},{index:.75,rgb:[202,174,88]},{index:.88,rgb:[216,209,126]},{index:1,rgb:[233,246,171]}],"velocity-blue":[{index:0,rgb:[17,32,64]},{index:.13,rgb:[35,52,116]},{index:.25,rgb:[29,81,156]},{index:.38,rgb:[31,113,162]},{index:.5,rgb:[50,144,169]},{index:.63,rgb:[87,173,176]},{index:.75,rgb:[149,196,189]},{index:.88,rgb:[203,221,211]},{index:1,rgb:[254,251,230]}],"velocity-green":[{index:0,rgb:[23,35,19]},{index:.13,rgb:[24,64,38]},{index:.25,rgb:[11,95,45]},{index:.38,rgb:[39,123,35]},{index:.5,rgb:[95,146,12]},{index:.63,rgb:[152,165,18]},{index:.75,rgb:[201,186,69]},{index:.88,rgb:[233,216,137]},{index:1,rgb:[255,253,205]}],cubehelix:[{index:0,rgb:[0,0,0]},{index:.07,rgb:[22,5,59]},{index:.13,rgb:[60,4,105]},{index:.2,rgb:[109,1,135]},{index:.27,rgb:[161,0,147]},{index:.33,rgb:[210,2,142]},{index:.4,rgb:[251,11,123]},{index:.47,rgb:[255,29,97]},{index:.53,rgb:[255,54,69]},{index:.6,rgb:[255,85,46]},{index:.67,rgb:[255,120,34]},{index:.73,rgb:[255,157,37]},{index:.8,rgb:[241,191,57]},{index:.87,rgb:[224,220,93]},{index:.93,rgb:[218,241,142]},{index:1,rgb:[227,253,198]}]}},{}],69:[function(t,e,r){"use strict";var n=t("./colorScale"),i=t("lerp");function a(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}function o(t){for(var e,r="#",n=0;n<3;++n)r+=("00"+(e=(e=t[n]).toString(16))).substr(e.length);return r}function s(t){return"rgba("+t.join(",")+")"}e.exports=function(t){var e,r,l,u,c,f,h,d,p,g;t||(t={});d=(t.nshades||72)-1,h=t.format||"hex",(f=t.colormap)||(f="jet");if("string"==typeof f){if(f=f.toLowerCase(),!n[f])throw Error(f+" not a supported colorscale");c=n[f]}else{if(!Array.isArray(f))throw Error("unsupported colormap option",f);c=f.slice()}if(c.length>d)throw new Error(f+" map requires nshades to be at least size "+c.length);p=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:t.alpha.slice():"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1];e=c.map(function(t){return Math.round(t.index*d)}),p[0]=Math.min(Math.max(p[0],0),1),p[1]=Math.min(Math.max(p[1],0),1);var v=c.map(function(t,e){var r=c[e].index,n=c[e].rgb.slice();return 4===n.length&&n[3]>=0&&n[3]<=1?n:(n[3]=p[0]+(p[1]-p[0])*r,n)}),m=[];for(g=0;g0?-1:l(t,e,a)?-1:1:0===s?u>0?1:l(t,e,r)?1:-1:i(u-s)}var h=n(t,e,r);if(h>0)return o>0&&n(t,e,a)>0?1:-1;if(h<0)return o>0||n(t,e,a)>0?1:-1;var d=n(t,e,a);return d>0?1:l(t,e,r)?1:-1};var n=t("robust-orientation"),i=t("signum"),a=t("two-sum"),o=t("robust-product"),s=t("robust-sum");function l(t,e,r){var n=a(t[0],-e[0]),i=a(t[1],-e[1]),l=a(r[0],-e[0]),u=a(r[1],-e[1]),c=s(o(n,l),o(i,u));return c[c.length-1]>=0}},{"robust-orientation":321,"robust-product":322,"robust-sum":326,signum:327,"two-sum":346}],71:[function(t,e,r){e.exports=function(t,e){var r=t.length,a=t.length-e.length;if(a)return a;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||n(t[0],t[1])-n(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=n(t[0],t[1]),u=n(e[0],e[1]);return n(l,t[2])-n(u,e[2])||n(l+t[2],o)-n(u+e[2],s);case 4:var c=t[0],f=t[1],h=t[2],d=t[3],p=e[0],g=e[1],v=e[2],m=e[3];return c+f+h+d-(p+g+v+m)||n(c,f,h,d)-n(p,g,v,m,p)||n(c+f,c+h,c+d,f+h,f+d,h+d)-n(p+g,p+v,p+m,g+v,g+m,v+m)||n(c+f+h,c+f+d,c+h+d,f+h+d)-n(p+g+v,p+g+m,p+v+m,g+v+m);default:for(var y=t.slice().sort(i),b=e.slice().sort(i),x=0;xt[r][0]&&(r=n);return er?[[r],[e]]:[[e]]}},{}],75:[function(t,e,r){"use strict";e.exports=function(t){var e=n(t),r=e.length;if(r<=2)return[];for(var i=new Array(r),a=e[r-1],o=0;o=e[l]&&(s+=1);a[o]=s}}return t}(o,r)}};var n=t("incremental-convex-hull"),i=t("affine-hull")},{"affine-hull":14,"incremental-convex-hull":253}],77:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i,a){var o=i-1,s=i*i,l=o*o,u=(1+2*i)*l,c=i*l,f=s*(3-2*i),h=s*o;if(t.length){a||(a=new Array(t.length));for(var d=t.length-1;d>=0;--d)a[d]=u*t[d]+c*e[d]+f*r[d]+h*n[d];return a}return u*t+c*e+f*r+h*n},e.exports.derivative=function(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,u=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var c=t.length-1;c>=0;--c)a[c]=o*t[c]+s*e[c]+l*r[c]+u*n[c];return a}return o*t+s*e+l*r[c]+u*n}},{}],78:[function(t,e,r){"use strict";var n=t("./lib/thunk.js");function i(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}e.exports=function(t){var e=new i;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var a=0;a0)throw new Error("cwise: pre() block may not reference array args");if(a0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(a),e.shimArgs.push("scalar"+a);else if("index"===o){if(e.indexArgs.push(a),a0)throw new Error("cwise: pre() block may not reference array index");if(a0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(a),ar.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},{"./lib/thunk.js":80}],79:[function(t,e,r){"use strict";var n=t("uniq");function i(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],u=[],c=0,f=0;for(n=0;n0&&l.push("var "+u.join(",")),n=a-1;n>=0;--n)c=t[n],l.push(["for(i",n,"=0;i",n,"0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",c,"]"].join(""))),l.push("}")}return l.join("\n")}function a(t,e,r){for(var n=t.body,i=[],a=[],o=0;o0&&y.push("shape=SS.slice(0)"),t.indexArgs.length>0){var b=new Array(r);for(l=0;l0&&m.push("var "+y.join(",")),l=0;l3&&m.push(a(t.pre,t,s));var A=a(t.body,t,s),M=function(t){for(var e=0,r=t[0].length;e0,u=[],c=0;c0;){"].join("")),u.push(["if(j",c,"<",s,"){"].join("")),u.push(["s",e[c],"=j",c].join("")),u.push(["j",c,"=0"].join("")),u.push(["}else{s",e[c],"=",s].join("")),u.push(["j",c,"-=",s,"}"].join("")),l&&u.push(["index[",e[c],"]=j",c].join(""));for(c=0;c3&&m.push(a(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+m.join("\n")+"\n----------");var T=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",M,function(t){for(var e=new Array(t.length),r=!0,n=0;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}(s)].join("");return new Function(["function ",T,"(",v.join(","),"){",m.join("\n"),"} return ",T].join(""))()}},{uniq:349}],80:[function(t,e,r){"use strict";var n=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],u=[],c=0;c0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[c]))),u.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[c])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),c=0;ce?1:t>=e?0:NaN}function d(t){return null===t?NaN:+t}function p(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}t.ascending=h,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},t.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},t.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),i=n){r=i=n;break}for(;++an&&(r=n),i1)return o/(l-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(h);function m(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return h(t(e),r)}:t)},t.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,a<2&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],i=new Array(r<0?0:r);e=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r};var y=Math.abs;function b(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function x(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,i=[],a=function(t){var e=1;for(;t*e%1;)e*=10;return e}(y(r)),o=-1;if(t*=a,e*=a,(r*=a)<0)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=i.length)return r?r.call(n,a):e?a.sort(e):a;for(var l,u,c,f,h=-1,d=a.length,p=i[s++],g=new x;++h=i.length)return e;var n=[],o=a[r++];return e.forEach(function(e,i){n.push({key:e,values:t(i,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return i.push(t),n},n.sortKeys=function(t){return a[i.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new C;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(U,"\\$&")};var U=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,V={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function H(t){return V(t,W),t}var q=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},X=function(t,e){var r=t.matches||t[P(t,"matchesSelector")];return(X=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(q=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,X=Sizzle.matchesSelector),t.selection=function(){return t.select(i.documentElement)};var W=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return q(t,this)}}function Z(t){return"function"==typeof t?t:function(){return G(t,this)}}W.select=function(t){var e,r,n,i,a=[];t=Y(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),$.hasOwnProperty(r)?{space:$[r],local:t}:t}},W.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each(J(r,e[r]));return this}return this.each(J(e,r))},W.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,i=-1;if(e=r.classList){for(;++i=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},W.sort=function(t){t=function(t){arguments.length||(t=h);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var l=pt.get(e);function u(){var t=this[a];t&&(this.removeEventListener(e,t,t.$),delete this[a])}return l&&(e=l,s=vt),o?r?function(){var t=s(r,n(arguments));u.call(this),this.addEventListener(e,this[a]=t,t.$=i),t._=r}:u:r?I:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var i in this)if(r=i.match(n)){var a=this[i];this.removeEventListener(r[1],a,a.$),delete this[i]}}}t.selection.enter=ft,t.selection.enter.prototype=ht,ht.append=W.append,ht.empty=W.empty,ht.node=W.node,ht.call=W.call,ht.size=W.size,ht.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++s=n&&(n=e+1);!(o=s[n])&&++n0?1:t<0?-1:0}function Rt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function Pt(t){return t>1?0:t<-1?Tt:Math.acos(t)}function zt(t){return t>1?St:t<-1?-St:Math.asin(t)}function It(t){return((t=Math.exp(t))+1/t)/2}function Nt(t){return(t=Math.sin(t/2))*t}var Dt=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],u=e[2],c=s-i,f=l-a,h=c*c+f*f;if(h0&&(e=e.transition().duration(g)),e.call(w.event)}function E(){u&&u.domain(l.range().map(function(t){return(t-h.x)/h.k}).map(l.invert)),f&&f.domain(c.range().map(function(t){return(t-h.y)/h.k}).map(c.invert))}function S(t){v++||t({type:"zoomstart"})}function L(t){E(),t({type:"zoom",scale:h.k,translate:[h.x,h.y]})}function C(t){--v||(t({type:"zoomend"}),r=null)}function O(){var e=this,r=_.of(e,arguments),n=0,i=t.select(o(e)).on(y,function(){n=1,T(t.mouse(e),a),L(r)}).on(b,function(){i.on(y,null).on(b,null),s(n),C(r)}),a=A(t.mouse(e)),s=bt(e);fs.call(e),S(r)}function R(){var e,r=this,n=_.of(r,arguments),i={},a=0,o=".zoom-"+t.event.changedTouches[0].identifier,l="touchmove"+o,u="touchend"+o,c=[],f=t.select(r),d=bt(r);function p(){var n=t.touches(r);return e=h.k,n.forEach(function(t){t.identifier in i&&(i[t.identifier]=A(t))}),n}function g(){var e=t.event.target;t.select(e).on(l,v).on(u,y),c.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){m=d[0];var b=d[1],x=m[0]-b[0],_=m[1]-b[1];a=x*x+_*_}}function v(){var o,l,u,c,f=t.touches(r);fs.call(r);for(var h=0,d=f.length;h360?t-=360:t<0&&(t+=360),t<60?n+(i-n)*t/60:t<180?i:t<240?n+(i-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(i=r<=.5?r*(1+e):r+e-r*e),new ae(a(t+120),a(t),a(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Yt?e.l:(e=he((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}Ht.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Vt(this.h,this.s,this.l/t)},Ht.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Vt(this.h,this.s,t*this.l)},Ht.rgb=function(){return qt(this.h,this.s,this.l)},t.hcl=Gt;var Xt=Gt.prototype=new Ut;function Wt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Yt(r,Math.cos(t*=Lt)*e,Math.sin(t)*e)}function Yt(t,e,r){return this instanceof Yt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Yt?new Yt(t.l,t.a,t.b):t instanceof Gt?Wt(t.h,t.c,t.l):he((t=ae(t)).r,t.g,t.b):new Yt(t,e,r)}Xt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Zt*(arguments.length?t:1)))},Xt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Zt*(arguments.length?t:1)))},Xt.rgb=function(){return Wt(this.h,this.c,this.l).rgb()},t.lab=Yt;var Zt=18,Qt=.95047,$t=1,Jt=1.08883,Kt=Yt.prototype=new Ut;function te(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return new ae(ie(3.2404542*(i=re(i)*Qt)-1.5371385*(n=re(n)*$t)-.4985314*(a=re(a)*Jt)),ie(-.969266*i+1.8760108*n+.041556*a),ie(.0556434*i-.2040259*n+1.0572252*a))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Ct,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ie(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ae(t,e,r){return this instanceof ae?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ae?new ae(t.r,t.g,t.b):ce(""+t,ae,qt):new ae(t,e,r)}function oe(t){return new ae(t>>16,t>>8&255,255&t)}function se(t){return oe(t)+""}Kt.brighter=function(t){return new Yt(Math.min(100,this.l+Zt*(arguments.length?t:1)),this.a,this.b)},Kt.darker=function(t){return new Yt(Math.max(0,this.l-Zt*(arguments.length?t:1)),this.a,this.b)},Kt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ae;var le=ae.prototype=new Ut;function ue(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ce(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(pe(i[0]),pe(i[1]),pe(i[2]))}return(a=ge.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o|=o>>4,s=240&a,s|=s>>4,l=15&a,l|=l<<4):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function fe(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=l<.5?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(e0&&l<1?0:n),new Vt(n,i,l)}function he(t,e,r){var n=ne((.4124564*(t=de(t))+.3575761*(e=de(e))+.1804375*(r=de(r)))/Qt),i=ne((.2126729*t+.7151522*e+.072175*r)/$t);return Yt(116*i-16,500*(n-i),200*(i-ne((.0193339*t+.119192*e+.9503041*r)/Jt)))}function de(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function pe(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}le.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=i.call(o,u)}catch(t){return void s.error.call(o,t)}s.load.call(o,t)}else s.error.call(o,u)}return!this.XDomainRequest||"withCredentials"in u||!/^(http(s)?:)?\/\//.test(e)||(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=f:u.onreadystatechange=function(){u.readyState>3&&f()},u.onprogress=function(e){var r=t.event;t.event=e;try{s.progress.call(o,u)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return i=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),u.open(t,e,!0),null==r||"accept"in l||(l.accept=r+",*/*"),u.setRequestHeader)for(var a in l)u.setRequestHeader(a,l[a]);return null!=r&&u.overrideMimeType&&u.overrideMimeType(r),null!=c&&(u.responseType=c),null!=i&&o.on("error",i).on("load",function(t){i(null,t)}),s.beforesend.call(o,u),u.send(null==n?null:n),o},o.abort=function(){return u.abort(),o},t.rebind(o,s,"on"),null==a?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(a))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=me(O),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function i(t,r,n){arguments.length<3&&(n=r,r=null);var i=ye(t,e,null==r?a:o(r),n);return i.row=function(t){return arguments.length?i.response(null==(r=t)?a:o(t)):r},i}function a(t){return i.parse(t.responseText)}function o(t){return function(e){return i.parse(e.responseText,t)}}function s(e){return e.map(l).join(t)}function l(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,e){var r;return i.parseRows(t,function(t,n){if(r)return r(t,n-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(i(t),r)}:i})},i.parseRows=function(t,e){var r,i,a={},o={},s=[],l=t.length,u=0,c=0;function f(){if(u>=l)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Te,e)),_e=0):(_e=1,Ae(Te))}function ke(){for(var t=Date.now(),e=be;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Ee(){for(var t,e=be,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Se(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Le[8+n/3]};var Ce=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Oe=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Se(e,r))).toFixed(Math.max(0,Math.min(20,Se(e*(1+1e-15),r))))}});function Re(t){return t+""}var Pe=t.time={},ze=Date;function Ie(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Ie.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ne.setUTCDate.apply(this._,arguments)},setDay:function(){Ne.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ne.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ne.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ne.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ne.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ne.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ne.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ne.setTime.apply(this._,arguments)}};var Ne=Date.prototype;function De(t,e,r){function n(e){var r=t(e),n=a(r,1);return e-r1)for(;o68?1900:2e3),r+i[0].length):-1}function Qe(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function $e(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function Je(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ke(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){Be.lastIndex=0;var n=Be.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ir(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=y(e)/60|0,i=y(e)%60;return r+Ve(n,"0",2)+Ve(i,"0",2)}function ar(t,e,r){Ue.lastIndex=0;var n=Ue.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(r-=s,r+s)),!((l+=s+1)>e));)s=i[o=(o+1)%i.length];return a.reverse().join(n)}:O;return function(e){var n=Ce.exec(e),i=n[1]||" ",s=n[2]||">",l=n[3]||"-",u=n[4]||"",c=n[5],f=+n[6],h=n[7],d=n[8],p=n[9],g=1,v="",m="",y=!1,b=!0;switch(d&&(d=+d.substring(1)),(c||"0"===i&&"="===s)&&(c=i="0",s="="),p){case"n":h=!0,p="g";break;case"%":g=100,m="%",p="f";break;case"p":g=100,m="%",p="r";break;case"b":case"o":case"x":case"X":"#"===u&&(v="0"+p.toLowerCase());case"c":b=!1;case"d":y=!0,d=0;break;case"s":g=-1,p="r"}"$"===u&&(v=a[0],m=a[1]),"r"!=p||d||(p="g"),null!=d&&("g"==p?d=Math.max(1,Math.min(21,d)):"e"!=p&&"f"!=p||(d=Math.max(0,Math.min(20,d)))),p=Oe.get(p)||Re;var x=c&&h;return function(e){var n=m;if(y&&e%1)return"";var a=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===l?"":l;if(g<0){var u=t.formatPrefix(e,d);e=u.scale(e),n=u.symbol+m}else e*=g;var _,w,A=(e=p(e,d)).lastIndexOf(".");if(A<0){var M=b?e.lastIndexOf("e"):-1;M<0?(_=e,w=""):(_=e.substring(0,M),w=e.substring(M))}else _=e.substring(0,A),w=r+e.substring(A+1);!c&&h&&(_=o(_,1/0));var T=v.length+_.length+w.length+(x?0:a.length),k=T"===s?k+a+e:"^"===s?k.substring(0,T>>=1)+a+e+k.substring(T):a+(x?e:k+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,i=e.time,a=e.periods,o=e.days,s=e.shortDays,l=e.months,u=e.shortMonths;function c(t){var e=t.length;function r(r){for(var n,i,a,o=[],s=-1,l=0;++s=u)return-1;if(37===(i=e.charCodeAt(s++))){if(o=e.charAt(s++),!(a=w[o in je?e.charAt(s++):o])||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}c.utc=function(t){var e=c(t);function r(t){try{var r=new(ze=Ie);return r._=t,e(r)}finally{ze=Date}}return r.parse=function(t){try{ze=Ie;var r=e.parse(t);return r&&r._}finally{ze=Date}},r.toString=e.toString,r},c.multi=c.utc.multi=or;var h=t.map(),d=He(o),p=qe(o),g=He(s),v=qe(s),m=He(l),y=qe(l),b=He(u),x=qe(u);a.forEach(function(t,e){h.set(t.toLowerCase(),e)});var _={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:c(r),d:function(t,e){return Ve(t.getDate(),e,2)},e:function(t,e){return Ve(t.getDate(),e,2)},H:function(t,e){return Ve(t.getHours(),e,2)},I:function(t,e){return Ve(t.getHours()%12||12,e,2)},j:function(t,e){return Ve(1+Pe.dayOfYear(t),e,3)},L:function(t,e){return Ve(t.getMilliseconds(),e,3)},m:function(t,e){return Ve(t.getMonth()+1,e,2)},M:function(t,e){return Ve(t.getMinutes(),e,2)},p:function(t){return a[+(t.getHours()>=12)]},S:function(t,e){return Ve(t.getSeconds(),e,2)},U:function(t,e){return Ve(Pe.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Ve(Pe.mondayOfYear(t),e,2)},x:c(n),X:c(i),y:function(t,e){return Ve(t.getFullYear()%100,e,2)},Y:function(t,e){return Ve(t.getFullYear()%1e4,e,4)},Z:ir,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){d.lastIndex=0;var n=d.exec(e.slice(r));return n?(t.w=p.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){b.lastIndex=0;var n=b.exec(e.slice(r));return n?(t.m=x.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){m.lastIndex=0;var n=m.exec(e.slice(r));return n?(t.m=y.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:Je,e:Je,H:tr,I:tr,j:Ke,L:nr,m:$e,M:er,p:function(t,e,r){var n=h.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:Xe,w:Ge,W:We,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:Ze,Y:Ye,Z:Qe,"%":ar};return c}(e)}};var sr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function lr(){}t.format=sr.numberFormat,t.geo={},lr.prototype={s:0,t:0,add:function(t){cr(t,this.t,ur),cr(ur.s,this.s,this),this.s?this.t+=ur.t:this.s=ur.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ur=new lr;function cr(t,e,r){var n=r.s=t+e,i=n-t,a=n-i;r.t=t-a+(e-i)}function fr(t,e){t&&dr.hasOwnProperty(t.type)&&dr[t.type](t,e)}t.geo.stream=function(t,e){t&&hr.hasOwnProperty(t.type)?hr[t.type](t,e):fr(t,e)};var hr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++n=0?1:-1,s=o*a,l=Math.cos(e),u=Math.sin(e),c=i*u,f=n*l+c*Math.cos(s),h=c*o*Math.sin(s);Sr.add(Math.atan2(h,f)),r=t,n=l,i=u}Lr.point=function(o,s){Lr.point=a,r=(t=o)*Lt,n=Math.cos(s=(e=s)*Lt/2+Tt/4),i=Math.sin(s)},Lr.lineEnd=function(){a(t,e)}}function Or(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Rr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Pr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function zr(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Ir(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Nr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Dr(t){return[Math.atan2(t[1],t[0]),zt(t[2])]}function Fr(t,e){return y(t[0]-e[0])At?i=90:u<-At&&(r=-90),f[0]=e,f[1]=n}};function d(t,a){c.push(f=[e=t,n=t]),ai&&(i=a)}function p(t,o){var s=Or([t*Lt,o*Lt]);if(l){var u=Pr(l,s),c=Pr([u[1],-u[0],0],u);Nr(c),c=Dr(c);var f=t-a,h=f>0?1:-1,p=c[0]*Ct*h,g=y(f)>180;if(g^(h*ai&&(i=v);else if(g^(h*a<(p=(p+360)%360-180)&&pi&&(i=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>a?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else d(t,o);l=s,a=t}function g(){h.point=p}function v(){f[0]=e,f[1]=n,h.point=d,l=null}function m(t,e){if(l){var r=t-a;u+=y(r)>180?r+(r>0?360:-360):r}else o=t,s=e;Lr.point(t,e),p(t,e)}function b(){Lr.lineStart()}function x(){m(o,s),Lr.lineEnd(),y(u)>At&&(e=-(n=180)),f[0]=e,f[1]=n,l=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function A(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=d[1]),_(d[0],g[1])>_(g[0],g[1])&&(g[0]=d[0])):s.push(g=d);for(var l,u,d,p=-1/0,g=(o=0,s[u=s.length-1]);o<=u;g=d,++o)d=s[o],(l=_(g[1],d[0]))>p&&(p=l,e=d[0],n=g[1])}return c=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,i]]}}(),t.geo.centroid=function(e){mr=yr=br=xr=_r=wr=Ar=Mr=Tr=kr=Er=0,t.geo.stream(e,jr);var r=Tr,n=kr,i=Er,a=r*r+n*n+i*i;return a=0;--s)i.point((f=c[s])[0],f[1]);else n(d.x,d.p.x,-1,i);d=d.p}c=(d=d.o).z,p=!p}while(!d.v);i.lineEnd()}}}function Yr(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n=0?1:-1,A=w*_,M=A>Tt,T=p*b;if(Sr.add(Math.atan2(T*w*Math.sin(A),g*x+T*Math.cos(A))),a+=M?_+w*kt:_,M^h>=r^m>=r){var k=Pr(Or(f),Or(t));Nr(k);var E=Pr(i,k);Nr(E);var S=(M^_>=0?-1:1)*zt(E[2]);(n>S||n===S&&(k[0]||k[1]))&&(o+=M^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(a<-At||a0){for(b||(o.polygonStart(),b=!0),o.lineStart();++a1&&2&e&&r.push(r.pop().concat(r.shift())),s.push(r.filter($r))}return c}}function $r(t){return t.length>1}function Jr(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:I,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Kr(t,e){return((t=t.x)[0]<0?t[1]-St-At:St-t[1])-((e=e.x)[0]<0?e[1]-St-At:St-e[1])}var tn=Qr(Xr,function(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Tt:-Tt,l=y(a-r);y(l-Tt)0?St:-St),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Tt&&(y(r-i)At?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}(r,n,a,o),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),e=0),t.point(r=a,n=o),i=s},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var i;if(null==t)i=r*St,n.point(-Tt,i),n.point(0,i),n.point(Tt,i),n.point(Tt,0),n.point(Tt,-i),n.point(0,-i),n.point(-Tt,-i),n.point(-Tt,0),n.point(-Tt,i);else if(y(t[0]-e[0])>At){var a=t[0]0)){if(a/=h,h<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=r-l,h||!(a<0)){if(a/=h,h<0){if(a>f)return;a>c&&(c=a)}else if(h>0){if(a0)){if(a/=d,d<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=n-u,d||!(a<0)){if(a/=d,d<0){if(a>f)return;a>c&&(c=a)}else if(d>0){if(a0&&(i.a={x:l+c*h,y:u+c*d}),f<1&&(i.b={x:l+f*h,y:u+f*d}),i}}}}}}var rn=1e9;function nn(e,r,n,i){return function(l){var u,c,f,h,d,p,g,v,m,y,b,x=l,_=Jr(),w=en(e,r,n,i),A={point:k,lineStart:function(){A.point=E,c&&c.push(f=[]);y=!0,m=!1,g=v=NaN},lineEnd:function(){u&&(E(h,d),p&&m&&_.rejoin(),u.push(_.buffer()));A.point=k,m&&l.lineEnd()},polygonStart:function(){l=_,u=[],c=[],b=!0},polygonEnd:function(){l=x,u=t.merge(u);var r=function(t){for(var e=0,r=c.length,n=t[1],i=0;in&&Rt(u,a,t)>0&&++e:a[1]<=n&&Rt(u,a,t)<0&&--e,u=a;return 0!==e}([e,i]),n=b&&r,a=u.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),M(null,null,1,l),l.lineEnd()),a&&Wr(u,o,r,M,l),l.polygonEnd()),u=c=f=null}};function M(t,o,l,u){var c=0,f=0;if(null==t||(c=a(t,l))!==(f=a(o,l))||s(t,o)<0^l>0)do{u.point(0===c||3===c?e:n,c>1?i:r)}while((c=(c+l+4)%4)!==f);else u.point(o[0],o[1])}function T(t,a){return e<=t&&t<=n&&r<=a&&a<=i}function k(t,e){T(t,e)&&l.point(t,e)}function E(t,e){var r=T(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(c&&f.push([t,e]),y)h=t,d=e,p=r,y=!1,r&&(l.lineStart(),l.point(t,e));else if(r&&m)l.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(m||(l.lineStart(),l.point(n.a.x,n.a.y)),l.point(n.b.x,n.b.y),r||l.lineEnd(),b=!1):r&&(l.lineStart(),l.point(t,e),b=!1)}g=t,v=e,m=r}return A};function a(t,i){return y(t[0]-e)0?0:3:y(t[0]-n)0?2:1:y(t[1]-r)0?1:0:i>0?3:2}function o(t,e){return s(t.x,e.x)}function s(t,e){var r=a(t,1),n=a(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=Tt/3,n=Ln(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Tt/180,r=t[1]*Tt/180):[e/Tt*180,r/Tt*180]},i}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,i=1+r*(2*n-r),a=Math.sqrt(i)/n;function o(t,e){var r=Math.sqrt(i-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),a-r*Math.cos(t)]}return o.invert=function(t,e){var r=a-e;return[Math.atan2(t,r)/n,zt((i-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),(i=a(t)).valid=!0,i},extent:function(s){return arguments.length?(a=nn(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,i,a=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};function u(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}return u.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&i<.234&&n>=-.425&&n<-.214?o:i>=.166&&i<.234&&n>=-.214&&n<-.115?s:a).invert(t)},u.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},u.precision=function(t){return arguments.length?(a.precision(t),o.precision(t),s.precision(t),u):a.precision()},u.scale=function(t){return arguments.length?(a.scale(t),o.scale(.35*t),s.scale(t),u.translate(a.translate())):a.scale()},u.translate=function(t){if(!arguments.length)return a.translate();var e=a.scale(),c=+t[0],f=+t[1];return r=a.translate(t).clipExtent([[c-.455*e,f-.238*e],[c+.455*e,f+.238*e]]).stream(l).point,n=o.translate([c-.307*e,f+.201*e]).clipExtent([[c-.425*e+At,f+.12*e+At],[c-.214*e-At,f+.234*e-At]]).stream(l).point,i=s.translate([c-.205*e,f+.212*e]).clipExtent([[c-.214*e+At,f+.166*e+At],[c-.115*e-At,f+.234*e-At]]).stream(l).point,u},u.scale(1070)};var sn,ln,un,cn,fn,hn,dn={point:I,lineStart:I,lineEnd:I,polygonStart:function(){ln=0,dn.lineStart=pn},polygonEnd:function(){dn.lineStart=dn.lineEnd=dn.point=I,sn+=y(ln/2)}};function pn(){var t,e,r,n;function i(t,e){ln+=n*t-r*e,r=t,n=e}dn.point=function(a,o){dn.point=i,t=r=a,e=n=o},dn.lineEnd=function(){i(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);ehn&&(hn=e)},lineStart:I,lineEnd:I,polygonStart:I,polygonEnd:I};function vn(){var t=mn(4.5),e=[],r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=mn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function i(t,n){e.push("M",t,",",n),r.point=a}function a(t,r){e.push("L",t,",",r)}function o(){r.point=n}function s(){e.push("Z")}return r}function mn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var yn,bn={point:xn,lineStart:_n,lineEnd:wn,polygonStart:function(){bn.lineStart=An},polygonEnd:function(){bn.point=xn,bn.lineStart=_n,bn.lineEnd=wn}};function xn(t,e){br+=t,xr+=e,++_r}function _n(){var t,e;function r(r,n){var i=r-t,a=n-e,o=Math.sqrt(i*i+a*a);wr+=o*(t+r)/2,Ar+=o*(e+n)/2,Mr+=o,xn(t=r,e=n)}bn.point=function(n,i){bn.point=r,xn(t=n,e=i)}}function wn(){bn.point=xn}function An(){var t,e,r,n;function i(t,e){var i=t-r,a=e-n,o=Math.sqrt(i*i+a*a);wr+=o*(r+t)/2,Ar+=o*(n+e)/2,Mr+=o,Tr+=(o=n*t-r*e)*(r+t),kr+=o*(n+e),Er+=3*o,xn(r=t,n=e)}bn.point=function(a,o){bn.point=i,xn(t=r=a,e=n=o)},bn.lineEnd=function(){i(t,e)}}function Mn(t){var e=4.5,r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:I};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,kt)}function i(e,n){t.moveTo(e,n),r.point=a}function a(e,r){t.lineTo(e,r)}function o(){r.point=n}function s(){t.closePath()}return r}function Tn(t){var e=.5,r=Math.cos(30*Lt),n=16;function i(e){return(n?function(e){var r,i,o,s,l,u,c,f,h,d,p,g,v={point:m,lineStart:y,lineEnd:x,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=y}};function m(r,n){r=t(r,n),e.point(r[0],r[1])}function y(){f=NaN,v.point=b,e.lineStart()}function b(r,i){var o=Or([r,i]),s=t(r,i);a(f,h,c,d,p,g,f=s[0],h=s[1],c=r,d=o[0],p=o[1],g=o[2],n,e),e.point(f,h)}function x(){v.point=m,e.lineEnd()}function _(){y(),v.point=w,v.lineEnd=A}function w(t,e){b(r=t,e),i=f,o=h,s=d,l=p,u=g,v.point=b}function A(){a(f,h,c,d,p,g,i,o,r,s,l,u,n,e),v.lineEnd=x,x()}return v}:function(e){return En(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function a(n,i,o,s,l,u,c,f,h,d,p,g,v,m){var b=c-n,x=f-i,_=b*b+x*x;if(_>4*e&&v--){var w=s+d,A=l+p,M=u+g,T=Math.sqrt(w*w+A*A+M*M),k=Math.asin(M/=T),E=y(y(M)-1)e||y((b*O+x*R)/_-.5)>.3||s*d+l*p+u*g0&&16,i):Math.sqrt(e)},i}function kn(t){this.stream=t}function En(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Sn(t){return Ln(function(){return t})()}function Ln(e){var r,n,i,a,o,s,l=Tn(function(t,e){return[(t=r(t,e))[0]*u+a,o-t[1]*u]}),u=150,c=480,f=250,h=0,d=0,p=0,g=0,v=0,m=tn,b=O,x=null,_=null;function w(t){return[(t=i(t[0]*Lt,t[1]*Lt))[0]*u+a,o-t[1]*u]}function A(t){return(t=i.invert((t[0]-a)/u,(o-t[1])/u))&&[t[0]*Ct,t[1]*Ct]}function M(){i=Gr(n=Pn(p,g,v),r);var t=r(h,d);return a=c-t[0]*u,o=f+t[1]*u,T()}function T(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Cn(m(n,l(b(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(m=null==t?(x=t,tn):function(t){var e=Math.cos(t),r=e>0,n=y(e)>At;return Qr(i,function(t){var e,s,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(f,h){var d,p=[f,h],g=i(f,h),v=r?g?0:o(f,h):g?o(f+(f<0?Tt:-Tt),h):0;if(!e&&(u=l=g)&&t.lineStart(),g!==l&&(d=a(e,p),(Fr(e,d)||Fr(p,d))&&(p[0]+=At,p[1]+=At,g=i(p[0],p[1]))),g!==l)c=0,g?(t.lineStart(),d=a(p,e),t.point(d[0],d[1])):(d=a(e,p),t.point(d[0],d[1]),t.lineEnd()),e=d;else if(n&&e&&r^g){var m;v&s||!(m=a(p,e,!0))||(c=0,r?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||e&&Fr(e,p)||t.point(p[0],p[1]),e=p,l=g,s=v},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return c|(u&&l)<<1}}},Dn(t,6*Lt),r?[0,-t]:[-Tt,t-Tt]);function i(t,r){return Math.cos(t)*Math.cos(r)>e}function a(t,r,n){var i=[1,0,0],a=Pr(Or(t),Or(r)),o=Rr(a,a),s=a[0],l=o-s*s;if(!l)return!n&&t;var u=e*o/l,c=-e*s/l,f=Pr(i,a),h=Ir(i,u);zr(h,Ir(a,c));var d=f,p=Rr(h,d),g=Rr(d,d),v=p*p-g*(Rr(h,h)-1);if(!(v<0)){var m=Math.sqrt(v),b=Ir(d,(-p-m)/g);if(zr(b,h),b=Dr(b),!n)return b;var x,_=t[0],w=r[0],A=t[1],M=r[1];w<_&&(x=_,_=w,w=x);var T=w-_,k=y(T-Tt)0^b[1]<(y(b[0]-_)Tt^(_<=b[0]&&b[0]<=w)){var E=Ir(d,(-p+m)/g);return zr(E,h),[b,Dr(E)]}}}function o(e,n){var i=r?t:Tt-t,a=0;return e<-i?a|=1:e>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}}((x=+t)*Lt),T()):x},w.clipExtent=function(t){return arguments.length?(_=t,b=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):O,T()):_},w.scale=function(t){return arguments.length?(u=+t,M()):u},w.translate=function(t){return arguments.length?(c=+t[0],f=+t[1],M()):[c,f]},w.center=function(t){return arguments.length?(h=t[0]%360*Lt,d=t[1]%360*Lt,M()):[h*Ct,d*Ct]},w.rotate=function(t){return arguments.length?(p=t[0]%360*Lt,g=t[1]%360*Lt,v=t.length>2?t[2]%360*Lt:0,M()):[p*Ct,g*Ct,v*Ct]},t.rebind(w,l,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&A,M()}}function Cn(t){return En(t,function(e,r){t.point(e*Lt,r*Lt)})}function On(t,e){return[t,e]}function Rn(t,e){return[t>Tt?t-kt:t<-Tt?t+kt:t,e]}function Pn(t,e,r){return t?e||r?Gr(In(t),Nn(e,r)):In(t):e||r?Nn(e,r):Rn}function zn(t){return function(e,r){return[(e+=t)>Tt?e-kt:e<-Tt?e+kt:e,r]}}function In(t){var e=zn(t);return e.invert=zn(-t),e}function Nn(t,e){var r=Math.cos(t),n=Math.sin(t),i=Math.cos(e),a=Math.sin(e);function o(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*r+s*n;return[Math.atan2(l*i-c*a,s*r-u*n),zt(c*i+l*a)]}return o.invert=function(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*i-l*a;return[Math.atan2(l*i+u*a,s*r+c*n),zt(c*r-s*n)]},o}function Dn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=Fn(r,i),a=Fn(r,a),(o>0?ia)&&(i+=o*kt)):(i=t+o*kt,a=t-.5*l);for(var u,c=i;o>0?c>a:c2?t[2]*Lt:0),e.invert=function(e){return(e=t.invert(e[0]*Lt,e[1]*Lt))[0]*=Ct,e[1]*=Ct,e},e},Rn.invert=On,t.geo.circle=function(){var t,e,r=[0,0],n=6;function i(){var t="function"==typeof r?r.apply(this,arguments):r,n=Pn(-t[0]*Lt,-t[1]*Lt,0).invert,i=[];return e(null,null,1,{point:function(t,e){i.push(t=n(t,e)),t[0]*=Ct,t[1]*=Ct}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(r=t,i):r},i.angle=function(r){return arguments.length?(e=Dn((t=+r)*Lt,n*Lt),i):t},i.precision=function(r){return arguments.length?(e=Dn(t*Lt,(n=+r)*Lt),i):n},i.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Lt,i=t[1]*Lt,a=e[1]*Lt,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),u=Math.cos(i),c=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=u*c-l*f*s)*r),l*c+u*f*s)},t.geo.graticule=function(){var e,r,n,i,a,o,s,l,u,c,f,h,d=10,p=d,g=90,v=360,m=2.5;function b(){return{type:"MultiLineString",coordinates:x()}}function x(){return t.range(Math.ceil(i/g)*g,n,g).map(f).concat(t.range(Math.ceil(l/v)*v,s,v).map(h)).concat(t.range(Math.ceil(r/d)*d,e,d).filter(function(t){return y(t%g)>At}).map(u)).concat(t.range(Math.ceil(o/p)*p,a,p).filter(function(t){return y(t%v)>At}).map(c))}return b.lines=function(){return x().map(function(t){return{type:"LineString",coordinates:t}})},b.outline=function(){return{type:"Polygon",coordinates:[f(i).concat(h(s).slice(1),f(n).reverse().slice(1),h(l).reverse().slice(1))]}},b.extent=function(t){return arguments.length?b.majorExtent(t).minorExtent(t):b.minorExtent()},b.majorExtent=function(t){return arguments.length?(i=+t[0][0],n=+t[1][0],l=+t[0][1],s=+t[1][1],i>n&&(t=i,i=n,n=t),l>s&&(t=l,l=s,s=t),b.precision(m)):[[i,l],[n,s]]},b.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),o>a&&(t=o,o=a,a=t),b.precision(m)):[[r,o],[e,a]]},b.step=function(t){return arguments.length?b.majorStep(t).minorStep(t):b.minorStep()},b.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],b):[g,v]},b.minorStep=function(t){return arguments.length?(d=+t[0],p=+t[1],b):[d,p]},b.precision=function(t){return arguments.length?(m=+t,u=jn(o,a,90),c=Bn(r,e,m),f=jn(l,s,90),h=Bn(i,n,m),b):m},b.majorExtent([[-180,-90+At],[180,90-At]]).minorExtent([[-180,-80-At],[180,80+At]])},t.geo.greatArc=function(){var e,r,n=Un,i=Vn;function a(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}return a.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},a.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,a):n},a.target=function(t){return arguments.length?(i=t,r="function"==typeof t?null:t,a):i},a.precision=function(){return arguments.length?a:0},a},t.geo.interpolate=function(t,e){return r=t[0]*Lt,n=t[1]*Lt,i=e[0]*Lt,a=e[1]*Lt,o=Math.cos(n),s=Math.sin(n),l=Math.cos(a),u=Math.sin(a),c=o*Math.cos(r),f=o*Math.sin(r),h=l*Math.cos(i),d=l*Math.sin(i),p=2*Math.asin(Math.sqrt(Nt(a-n)+o*l*Nt(i-r))),g=1/Math.sin(p),(v=p?function(t){var e=Math.sin(t*=p)*g,r=Math.sin(p-t)*g,n=r*c+e*h,i=r*f+e*d,a=r*s+e*u;return[Math.atan2(i,n)*Ct,Math.atan2(a,Math.sqrt(n*n+i*i))*Ct]}:function(){return[r*Ct,n*Ct]}).distance=p,v;var r,n,i,a,o,s,l,u,c,f,h,d,p,g,v},t.geo.length=function(e){return yn=0,t.geo.stream(e,Hn),yn};var Hn={sphere:I,point:I,lineStart:function(){var t,e,r;function n(n,i){var a=Math.sin(i*=Lt),o=Math.cos(i),s=y((n*=Lt)-t),l=Math.cos(s);yn+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=r*a-e*o*l)*s),e*a+r*o*l),t=n,e=a,r=o}Hn.point=function(i,a){t=i*Lt,e=Math.sin(a*=Lt),r=Math.cos(a),Hn.point=n},Hn.lineEnd=function(){Hn.point=Hn.lineEnd=I}},lineEnd:I,polygonStart:I,polygonEnd:I};function qn(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}var Gn=qn(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Sn(Gn)}).raw=Gn;var Xn=qn(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},O);function Wn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Tt/4+t/2)},i=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),a=r*Math.pow(n(t),i)/i;if(!i)return Qn;function o(t,e){a>0?e<-St+At&&(e=-St+At):e>St-At&&(e=St-At);var r=a/Math.pow(n(e),i);return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}return o.invert=function(t,e){var r=a-e,n=Ot(i)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/i,2*Math.atan(Math.pow(a/n,1/i))-St]},o}function Yn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),i=r/n+t;if(y(n)1&&Rt(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function ii(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Sn(Kn)}).raw=Kn,ti.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-St]},(t.geo.transverseMercator=function(){var t=$n(ti),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ti,t.geom={},t.geom.hull=function(t){var e=ei,r=ri;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,i=ve(e),a=ve(r),o=t.length,s=[],l=[];for(n=0;n=0;--n)d.push(t[s[u[n]][2]]);for(n=+f;nAt)s=s.L;else{if(!((i=a-wi(s,o))>At)){n>-At?(e=s.P,r=s):i>-At?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=mi(t);if(fi.insert(e,l),e||r){if(e===r)return Ei(e),r=mi(e.site),fi.insert(l,r),l.edge=r.edge=Ci(e.site,l.site),ki(e),void ki(r);if(r){Ei(e),Ei(r);var u=e.site,c=u.x,f=u.y,h=t.x-c,d=t.y-f,p=r.site,g=p.x-c,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+c,y:(h*b-g*y)/m+f};Oi(r.edge,u,p,x),l.edge=Ci(u,t,null,x),r.edge=Ci(t,p,null,x),ki(e),ki(r)}else l.edge=Ci(e.site,l.site)}}function _i(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-1/0;var s=(r=o.site).x,l=r.y,u=l-e;if(!u)return s;var c=s-n,f=1/a-1/u,h=c/u;return f?(-h+Math.sqrt(h*h-2*f*(c*c/(-2*u)-l+u/2+i-a/2)))/f+n:(n+s)/2}function wi(t,e){var r=t.N;if(r)return _i(r,e);var n=t.site;return n.y===e?n.x:1/0}function Ai(t){this.site=t,this.edges=[]}function Mi(t,e){return e.angle-t.angle}function Ti(){zi(this),this.x=this.y=this.arc=this.site=this.cy=null}function ki(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,i=t.site,a=r.site;if(n!==a){var o=i.x,s=i.y,l=n.x-o,u=n.y-s,c=a.x-o,f=2*(l*(v=a.y-s)-u*c);if(!(f>=-Mt)){var h=l*l+u*u,d=c*c+v*v,p=(v*h-u*d)/f,g=(l*d-c*h)/f,v=g+s,m=gi.pop()||new Ti;m.arc=t,m.site=i,m.x=p+o,m.y=v+Math.sqrt(p*p+g*g),m.cy=v,t.circle=m;for(var y=null,b=di._;b;)if(m.y=s)return;if(h>p){if(a){if(a.y>=u)return}else a={x:v,y:l};r={x:v,y:u}}else{if(a){if(a.y1)if(h>p){if(a){if(a.y>=u)return}else a={x:(l-i)/n,y:l};r={x:(u-i)/n,y:u}}else{if(a){if(a.y=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xAt||y(i-r)>At)&&(s.splice(o,0,new Ri((m=a.site,b=c,x=y(n-f)At?{x:f,y:y(e-f)At?{x:y(r-p)At?{x:h,y:y(e-h)At?{x:y(r-d)=r&&u.x<=i&&u.y>=n&&u.y<=o?[[r,o],[i,o],[i,n],[r,n]]:[]).point=t[s]}),e}function s(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/At)*At,y:Math.round(i(t,e)/At)*At,i:e}})}return o.links=function(t){return Fi(s(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fi(s(t)).cells.forEach(function(r,n){for(var i,a,o,s,l=r.site,u=r.edges.sort(Mi),c=-1,f=u.length,h=u[f-1].edge,d=h.l===l?h.r:h.l;++ca&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:Gi(r,n)})),a=Yi.lastIndex;return ag&&(g=l.x),l.y>v&&(v=l.y),u.push(l.x),c.push(l.y);else for(f=0;fg&&(g=x),_>v&&(v=_),u.push(x),c.push(_)}var w=g-d,A=v-p;function M(t,e,r,n,i,a,o,s){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var l=t.x,u=t.y;if(null!=l)if(y(l-r)+y(u-n)<.01)T(t,e,r,n,i,a,o,s);else{var c=t.point;t.x=t.y=t.point=null,T(t,c,l,u,i,a,o,s),T(t,e,r,n,i,a,o,s)}else t.x=r,t.y=n,t.point=e}else T(t,e,r,n,i,a,o,s)}function T(t,e,r,n,i,a,o,s){var l=.5*(i+o),u=.5*(a+s),c=r>=l,f=n>=u,h=f<<1|c;t.leaf=!1,c?i=l:o=l,f?a=u:s=u,M(t=t.nodes[h]||(t.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(k,t,+m(t,++f),+b(t,f),d,p,g,v)}}),e,r,n,i,a,o,s)}w>A?v=p+w:g=d+A;var k={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(k,t,+m(t,++f),+b(t,f),d,p,g,v)}};if(k.visit=function(t){!function t(e,r,n,i,a,o){if(!e(r,n,i,a,o)){var s=.5*(n+a),l=.5*(i+o),u=r.nodes;u[0]&&t(e,u[0],n,i,s,l),u[1]&&t(e,u[1],s,i,a,l),u[2]&&t(e,u[2],n,l,s,o),u[3]&&t(e,u[3],s,l,a,o)}}(t,k,d,p,g,v)},k.find=function(t){return function(t,e,r,n,i,a,o){var s,l=1/0;return function t(u,c,f,h,d){if(!(c>a||f>o||h=_)<<1|e>=x,A=w+4;w=0&&!(n=t.interpolators[i](e,r)););return n}function Qi(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function aa(t){return 1-Math.cos(t*St)}function oa(t){return Math.pow(2,10*(t-1))}function sa(t){return 1-Math.sqrt(1-t*t)}function la(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ua(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ca(t){var e,r,n,i=[t.a,t.b],a=[t.c,t.d],o=ha(i),s=fa(i,a),l=ha(((e=a)[0]+=(n=-s)*(r=i)[0],e[1]+=n*r[1],e))||0;i[0]*a[1]=0?t.slice(0,n):t,a=n>=0?t.slice(n+1):"in";return i=Ji.get(i)||$i,a=Ki.get(a)||O,e=a(i.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,i=e.c,a=e.l,o=r.h-n,s=r.c-i,l=r.l-a;isNaN(s)&&(s=0,i=isNaN(i)?r.c:i);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Wt(n+o*t,i+s*t,a+l*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,i=e.s,a=e.l,o=r.h-n,s=r.s-i,l=r.l-a;isNaN(s)&&(s=0,i=isNaN(i)?r.s:i);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return qt(n+o*t,i+s*t,a+l*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,i=e.a,a=e.b,o=r.l-n,s=r.a-i,l=r.b-a;return function(t){return te(n+o*t,i+s*t,a+l*t)+""}},t.interpolateRound=ua,t.transform=function(e){var r=i.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ca(e?e.matrix:da)})(e)},ca.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var da={a:1,b:0,c:0,d:1,e:0,f:0};function pa(t){return t.length?t.pop()+",":""}function ga(e,r){var n=[],i=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push("translate(",null,",",null,")");n.push({i:i-4,x:Gi(t[0],e[0])},{i:i-2,x:Gi(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,i),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(pa(r)+"rotate(",null,")")-2,x:Gi(t,e)})):e&&r.push(pa(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,i),function(t,e,r,n){t!==e?n.push({i:r.push(pa(r)+"skewX(",null,")")-2,x:Gi(t,e)}):e&&r.push(pa(r)+"skewX("+e+")")}(e.skew,r.skew,n,i),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(pa(r)+"scale(",null,",",null,")");n.push({i:i-4,x:Gi(t[0],e[0])},{i:i-2,x:Gi(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(pa(r)+"scale("+e+")")}(e.scale,r.scale,n,i),e=r=null,function(t){for(var e,r=-1,a=i.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:n=0})):t>0&&(l.start({type:"start",alpha:n=t}),e=Me(s.tick)),s):n},s.start=function(){var t,e,r,n=m.length,l=y.length,c=u[0],p=u[1];for(t=0;t=0;)r.push(i[n])}function La(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++o=0;)o.push(c=u[l]),c.parent=a,c.depth=a.depth+1;r&&(a.value=0),a.children=u}else r&&(a.value=+r.call(n,a,a.depth)||0),delete a.children;return La(i,function(e){var n,i;t&&(n=e.children)&&n.sort(t),r&&(i=e.parent)&&(i.value+=e.value)}),s}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Sa(t,function(t){t.children&&(t.value=0)}),La(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var i=e.call(this,t,n);return function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,u=-1;for(n=e.value?n/e.value:0;++us&&(s=n),o.push(n)}for(r=0;ri&&(n=r,i=e);return n}function Ha(t){return t.reduce(qa,0)}function qa(t,e){return t+e[1]}function Ga(t,e){return Xa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Xa(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function Wa(e){return[t.min(e),t.max(e)]}function Ya(t,e){return t.value-e.value}function Za(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Qa(t,e){t._pack_next=e,e._pack_prev=t}function $a(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Ja(t){if((e=t.children)&&(l=e.length)){var e,r,n,i,a,o,s,l,u=1/0,c=-1/0,f=1/0,h=-1/0;if(e.forEach(Ka),(r=e[0]).x=-r.r,r.y=0,b(r),l>1&&((n=e[1]).x=n.r,n.y=0,b(n),l>2))for(eo(r,n,i=e[2]),b(i),Za(r,i),r._pack_prev=i,Za(i,n),n=r._pack_next,a=3;a0)for(o=-1;++o=f[0]&&l<=f[1]&&((s=u[t.bisect(h,l,1,p)-1]).y+=g,s.push(a[o]));return u}return a.value=function(t){return arguments.length?(r=t,a):r},a.range=function(t){return arguments.length?(n=ve(t),a):n},a.bins=function(t){return arguments.length?(i="number"==typeof t?function(e){return Xa(e,t)}:ve(t),a):i},a.frequency=function(t){return arguments.length?(e=!!t,a):e},a},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Ya),n=0,i=[1,1];function a(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],u=i[1],c=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,La(s,function(t){t.r=+c(t.value)}),La(s,Ja),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/u))/2;La(s,function(t){t.r+=f}),La(s,Ja),La(s,function(t){t.r-=f})}return function t(e,r,n,i){var a=e.children;e.x=r+=i*e.x;e.y=n+=i*e.y;e.r*=i;if(a)for(var o=-1,s=a.length;++od.x&&(d=t),t.depth>p.depth&&(p=t)});var g=r(h,d)/2-h.x,v=n[0]/(d.x+r(d,h)/2+g),m=n[1]/(p.depth||1);Sa(c,function(t){t.x=(t.x+g)*v,t.y=t.depth*m})}return u}function o(t){var e=t.children,n=t.parent.children,i=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,i=t.children,a=i.length;for(;--a>=0;)(e=i[a]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var a=(e[0].z+e[e.length-1].z)/2;i?(t.z=i.z+r(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+r(t._,i._));t.parent.A=function(t,e,n){if(e){for(var i,a=t,o=t,s=e,l=a.parent.children[0],u=a.m,c=o.m,f=s.m,h=l.m;s=io(s),a=no(a),s&&a;)l=no(l),(o=io(o)).a=t,(i=s.z+f-a.z-u+r(s._,a._))>0&&(ao(oo(s,t,n),t,i),u+=i,c+=i),f+=s.m,u+=a.m,h+=l.m,c+=o.m;s&&!io(o)&&(o.t=s,o.m+=f-c),a&&!no(l)&&(l.t=a,l.m+=u-h,n=t)}return n}(t,i,t.parent.A||n[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function l(t){t.x*=n[0],t.y=t.depth*n[1]}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t)?l:null,a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null==(n=t)?null:l,a):i?n:null},Ea(a,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],i=!1;function a(a,o){var s,l=e.call(this,a,o),u=l[0],c=0;La(u,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=s?c+=r(e,s):0,e.y=0,s=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(u),h=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(u),d=f.x-r(f,h)/2,p=h.x+r(h,f)/2;return La(u,i?function(t){t.x=(t.x-u.x)*n[0],t.y=(u.y-t.y)*n[1]}:function(t){t.x=(t.x-d)/(p-d)*n[0],t.y=(1-(u.y?t.y/u.y:1))*n[1]}),l}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t),a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null!=(n=t),a):i?n:null},Ea(a,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,i=[1,1],a=null,o=so,s=!1,l="squarify",u=.5*(1+Math.sqrt(5));function c(t,e){for(var r,n,i=-1,a=t.length;++i0;)s.push(r=u[i-1]),s.area+=r.area,"squarify"!==l||(n=d(s,g))<=h?(u.pop(),h=n):(s.area-=s.pop().area,p(s,g,a,!1),g=Math.min(a.dx,a.dy),s.length=s.area=0,h=1/0);s.length&&(p(s,g,a,!0),s.length=s.area=0),e.forEach(f)}}function h(t){var e=t.children;if(e&&e.length){var r,n=o(t),i=e.slice(),a=[];for(c(i,n.dx*n.dy/t.value),a.area=0;r=i.pop();)a.push(r),a.area+=r.area,null!=r.z&&(p(a,r.z?n.dx:n.dy,n,!i.length),a.length=a.area=0);e.forEach(h)}}function d(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++oi&&(i=r));return e*=e,(n*=n)?Math.max(e*i*u/n,n/(e*a*u)):1/0}function p(t,e,r,i){var a,o=-1,s=t.length,l=r.x,u=r.y,c=e?n(t.area/e):0;if(e==r.dx){for((i||c>r.dy)&&(c=r.dy);++or.dx)&&(c=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,s=i?ma:va;return a=t(e,r,s,n),o=t(r,e,s,Zi),l}function l(t){return a(t)}l.invert=function(t){return o(t)};l.domain=function(t){return arguments.length?(e=t.map(Number),s()):e};l.range=function(t){return arguments.length?(r=t,s()):r};l.rangeRound=function(t){return l.range(t).interpolate(ua)};l.clamp=function(t){return arguments.length?(i=t,s()):i};l.interpolate=function(t){return arguments.length?(n=t,s()):n};l.ticks=function(t){return xo(e,t)};l.tickFormat=function(t,r){return _o(e,t,r)};l.nice=function(t){return yo(e,t),s()};l.copy=function(){return t(e,r,n,i)};return s()}([0,1],[0,1],Zi,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function Ao(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,i,a){function o(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function s(t){return i?Math.pow(n,t):-Math.pow(n,-t)}function l(t){return r(o(t))}l.invert=function(t){return s(r.invert(t))};l.domain=function(t){return arguments.length?(i=t[0]>=0,r.domain((a=t.map(Number)).map(o)),l):a};l.base=function(t){return arguments.length?(n=+t,r.domain(a.map(o)),l):n};l.nice=function(){var t=ho(a.map(o),i?Math:To);return r.domain(t),a=t.map(s),l};l.ticks=function(){var t=uo(a),e=[],r=t[0],l=t[1],u=Math.floor(o(r)),c=Math.ceil(o(l)),f=n%1?2:n;if(isFinite(c-u)){if(i){for(;u0;h--)e.push(s(u)*h);for(u=0;e[u]l;c--);e=e.slice(u,c)}return e};l.tickFormat=function(e,r){if(!arguments.length)return Mo;arguments.length<2?r=Mo:"function"!=typeof r&&(r=t.format(r));var i=Math.max(1,n*e/l.ticks().length);return function(t){var e=t/s(Math.round(o(t)));return e*n0?i[t-1]:r[0],tf?0:1;if(u=Et)return l(u,d)+(s?l(s,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,A,M,T,k=0,E=0,S=[];if((m=(+o.apply(this,arguments)||0)/2)&&(v=n===Ro?Math.sqrt(s*s+u*u):+n.apply(this,arguments),d||(E*=-1),u&&(E=zt(v/u*Math.sin(m))),s&&(k=zt(v/s*Math.sin(m)))),u){y=u*Math.cos(c+E),b=u*Math.sin(c+E),x=u*Math.cos(f-E),_=u*Math.sin(f-E);var L=Math.abs(f-c-2*E)<=Tt?0:1;if(E&&Fo(y,b,x,_)===d^L){var C=(c+f)/2;y=u*Math.cos(C),b=u*Math.sin(C),x=_=null}}else y=b=0;if(s){w=s*Math.cos(f-k),A=s*Math.sin(f-k),M=s*Math.cos(c+k),T=s*Math.sin(c+k);var O=Math.abs(c-f+2*k)<=Tt?0:1;if(k&&Fo(w,A,M,T)===1-d^O){var R=(c+f)/2;w=s*Math.cos(R),A=s*Math.sin(R),M=T=null}}else w=A=0;if(h>At&&(p=Math.min(Math.abs(u-s)/2,+r.apply(this,arguments)))>.001){g=s0?0:1}function jo(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,u=-s*a,c=t[0]+l,f=t[1]+u,h=e[0]+l,d=e[1]+u,p=(c+h)/2,g=(f+d)/2,v=h-c,m=d-f,y=v*v+m*m,b=r-n,x=c*d-h*f,_=(m<0?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,A=(-x*v-m*_)/y,M=(x*m+v*_)/y,T=(-x*v+m*_)/y,k=w-p,E=A-g,S=M-p,L=T-g;return k*k+E*E>S*S+L*L&&(w=M,A=T),[[w-l,A-u],[w*r/b,A*r/b]]}function Bo(t){var e=ei,r=ri,n=Xr,i=Vo,a=i.key,o=.7;function s(a){var s,l=[],u=[],c=-1,f=a.length,h=ve(e),d=ve(r);function p(){l.push("M",i(t(u),o))}for(;++c1&&i.push("H",n[0]);return i.join("")},"step-before":qo,"step-after":Go,basis:Yo,"basis-open":function(t){if(t.length<4)return Vo(t);var e,r=[],n=-1,i=t.length,a=[0],o=[0];for(;++n<3;)e=t[n],a.push(e[0]),o.push(e[1]);r.push(Zo(Jo,a)+","+Zo(Jo,o)),--n;for(;++n9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));s=-1;for(;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}(t))}});function Vo(t){return t.length>1?t.join("L"):t+"Z"}function Ho(t){return t.join("L")+"Z"}function qo(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var u=2;uTt)+",1 "+e}function l(t,e,r,n){return"Q 0,0 "+n}return a.radius=function(t){return arguments.length?(r=ve(t),a):r},a.source=function(e){return arguments.length?(t=ve(e),a):t},a.target=function(t){return arguments.length?(e=ve(t),a):e},a.startAngle=function(t){return arguments.length?(n=ve(t),a):n},a.endAngle=function(t){return arguments.length?(i=ve(t),a):i},a},t.svg.diagonal=function(){var t=Un,e=Vn,r=is;function n(n,i){var a=t.call(this,n,i),o=e.call(this,n,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(r))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=is,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-St;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=os,e=as;function r(r,n){return(ls.get(t.call(this,r,n))||ss)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var ls=t.map({circle:ss,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*cs)),r=e*cs;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/us),r=e*us/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/us),r=e*us/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=ls.keys();var us=Math.sqrt(3),cs=Math.tan(30*Lt);W.transition=function(t){for(var e,r,n=ps||++ms,i=xs(t),a=[],o=gs||{time:Date.now(),ease:ia,delay:0,duration:250},s=-1,l=this.length;++s0;)u[--h].call(t,o);if(a>=1)return f.event&&f.event.end.call(t,t.__data__,e),--c.count?delete c[n]:delete t[r],1}f||(a=i.time,o=Me(function(t){var e=f.delay;if(o.t=e+a,e<=t)return h(t-e);o.c=h},0,a),f=c[n]={tween:new x,time:a,timer:o,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++c.count)}vs.call=W.call,vs.empty=W.empty,vs.node=W.node,vs.size=W.size,t.transition=function(e,r){return e&&e.transition?ps?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vs,vs.select=function(t){var e,r,n,i=this.id,a=this.namespace,o=[];t=Y(t);for(var s=-1,l=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function g(t){t.select(".extent").attr("y",l[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function v(){var f,v,m=this,y=t.select(t.event.target),b=n.of(m,arguments),x=t.select(m),_=y.datum(),w=!/^(n|s)$/.test(_)&&i,A=!/^(e|w)$/.test(_)&&a,M=y.classed("extent"),T=bt(m),k=t.mouse(m),E=t.select(o(m)).on("keydown.brush",function(){32==t.event.keyCode&&(M||(f=null,k[0]-=s[1],k[1]-=l[1],M=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==M&&(k[0]+=s[1],k[1]+=l[1],M=0,F())});if(t.event.changedTouches?E.on("touchmove.brush",C).on("touchend.brush",R):E.on("mousemove.brush",C).on("mouseup.brush",R),x.interrupt().selectAll("*").interrupt(),M)k[0]=s[0]-k[0],k[1]=l[0]-k[1];else if(_){var S=+/w$/.test(_),L=+/^n/.test(_);v=[s[1-S]-k[0],l[1-L]-k[1]],k[0]=s[S],k[1]=l[L]}else t.event.altKey&&(f=k.slice());function C(){var e=t.mouse(m),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),M||(t.event.altKey?(f||(f=[(s[0]+s[1])/2,(l[0]+l[1])/2]),k[0]=s[+(e[0]1?{floor:function(e){for(;s(e=t.floor(e));)e=Ps(e-1);return e},ceil:function(e){for(;s(e=t.ceil(e));)e=Ps(+e+1);return e}}:t))},i.ticks=function(t,e){var r=uo(i.domain()),n=null==t?a(r,10):"number"==typeof t?a(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],Ps(+r[1]+1),e<1?1:e)},i.tickFormat=function(){return n},i.copy=function(){return Rs(e.copy(),r,n)},mo(i,e)}function Ps(t){return new Date(t)}Ss.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Os:Cs,Os.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Os.toString=Cs.toString,Pe.second=De(function(t){return new ze(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),Pe.seconds=Pe.second.range,Pe.seconds.utc=Pe.second.utc.range,Pe.minute=De(function(t){return new ze(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),Pe.minutes=Pe.minute.range,Pe.minutes.utc=Pe.minute.utc.range,Pe.hour=De(function(t){var e=t.getTimezoneOffset()/60;return new ze(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),Pe.hours=Pe.hour.range,Pe.hours.utc=Pe.hour.utc.range,Pe.month=De(function(t){return(t=Pe.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),Pe.months=Pe.month.range,Pe.months.utc=Pe.month.utc.range;var zs=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Is=[[Pe.second,1],[Pe.second,5],[Pe.second,15],[Pe.second,30],[Pe.minute,1],[Pe.minute,5],[Pe.minute,15],[Pe.minute,30],[Pe.hour,1],[Pe.hour,3],[Pe.hour,6],[Pe.hour,12],[Pe.day,1],[Pe.day,2],[Pe.week,1],[Pe.month,1],[Pe.month,3],[Pe.year,1]],Ns=Ss.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Xr]]),Ds={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(Ps)},floor:O,ceil:O};Is.year=Pe.year,Pe.scale=function(){return Rs(t.scale.linear(),Is,Ns)};var Fs=Is.map(function(t){return[t[0].utc,t[1]]}),js=Ls.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Xr]]);function Bs(t){return JSON.parse(t.responseText)}function Us(t){var e=i.createRange();return e.selectNode(i.body),e.createContextualFragment(t.responseText)}Fs.year=Pe.year.utc,Pe.scale.utc=function(){return Rs(t.scale.linear(),Fs,js)},t.text=me(function(t){return t.responseText}),t.json=function(t,e){return ye(t,"application/json",Bs,e)},t.html=function(t,e){return ye(t,"text/html",Us,e)},t.xml=me(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],83:[function(t,e,r){e.exports=function(){for(var t=0;t=2)return!1;t[r]=n}return!0}):_.filter(function(t){for(var e=0;e<=s;++e){var r=m[t[e]];if(r<0)return!1;t[e]=r}return!0});if(1&s)for(var c=0;c<_.length;++c){var x=_[c],h=x[0];x[0]=x[1],x[1]=h}return _}},{"incremental-convex-hull":253,uniq:349}],85:[function(t,e,r){(function(t){var r=!1;if("undefined"!=typeof Float64Array){var n=new Float64Array(1),i=new Uint32Array(n.buffer);if(n[0]=1,r=!0,1072693248===i[1]){e.exports=function(t){return n[0]=t,[i[0],i[1]]},e.exports.pack=function(t,e){return i[0]=t,i[1]=e,n[0]},e.exports.lo=function(t){return n[0]=t,i[0]},e.exports.hi=function(t){return n[0]=t,i[1]}}else if(1072693248===i[0]){e.exports=function(t){return n[0]=t,[i[1],i[0]]},e.exports.pack=function(t,e){return i[1]=t,i[0]=e,n[0]},e.exports.lo=function(t){return n[0]=t,i[1]},e.exports.hi=function(t){return n[0]=t,i[0]}}else r=!1}if(!r){var a=new t(8);e.exports=function(t){return a.writeDoubleLE(t,0,!0),[a.readUInt32LE(0,!0),a.readUInt32LE(4,!0)]},e.exports.pack=function(t,e){return a.writeUInt32LE(t,0,!0),a.writeUInt32LE(e,4,!0),a.readDoubleLE(0,!0)},e.exports.lo=function(t){return a.writeDoubleLE(t,0,!0),a.readUInt32LE(0,!0)},e.exports.hi=function(t){return a.writeDoubleLE(t,0,!0),a.readUInt32LE(4,!0)}}e.exports.sign=function(t){return e.exports.hi(t)>>>31},e.exports.exponent=function(t){return(e.exports.hi(t)<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){return!(2146435072&e.exports.hi(t))}}).call(this,t("buffer").Buffer)},{buffer:49}],86:[function(t,e,r){e.exports=function(t){switch(t){case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"uint8":return Uint8Array;case"uint16":return Uint16Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;case"array":return Array;case"uint8_clamped":return Uint8ClampedArray}}},{}],87:[function(t,e,r){"use strict";e.exports=function(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return function(t,e){var r,n;for(r=new Array(t),n=0;n=r-1){h=l.length-1;var p=t-e[r-1];for(d=0;d=r-1)for(var c=s.length-1,f=(e[r-1],0);f=0;--r)if(t[--e])return!1;return!0},s.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(t0;--f)n.push(a(l[f-1],u[f-1],arguments[f])),i.push(0)}},s.push=function(t){var e=this.lastT(),r=this.dimension;if(!(t1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var d=a(u[h-1],c[h-1],arguments[h]);n.push(d),i.push((d-n[o++])*f)}}},s.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(a(o[l-1],s[l-1],arguments[l])),n.push(0)}},s.move=function(t){var e=this.lastT(),r=this.dimension;if(!(t<=e||arguments.length!==r+1)){var n=this._state,i=this._velocity,o=n.length-this.dimension,s=this.bounds,l=s[0],u=s[1],c=t-e,f=c>1e-6?1/c:0;this._time.push(t);for(var h=r;h>0;--h){var d=arguments[h];n.push(a(l[h-1],u[h-1],n[o++]+d)),i.push(d*f)}}},s.idle=function(t){var e=this.lastT();if(!(t=0;--f)n.push(a(l[f],u[f],n[o]+c*i[o])),i.push(0),o+=1}}},{"binary-search-bounds":36,"cubic-hermite":77}],93:[function(t,e,r){"use strict";e.exports=function(t){return new u(t||p,null)};var n=0,i=1;function a(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function o(t){return new a(t._color,t.key,t.value,t.left,t.right,t._count)}function s(t,e){return new a(t,e.key,e.value,e.left,e.right,e._count)}function l(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function u(t,e){this._compare=t,this.root=e}var c=u.prototype;function f(t,e){this.tree=t,this._stack=e}Object.defineProperty(c,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(c,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(c,"length",{get:function(){return this.root?this.root._count:0}}),c.insert=function(t,e){for(var r=this._compare,o=this.root,c=[],f=[];o;){var h=r(t,o.key);c.push(o),f.push(h),o=h<=0?o.left:o.right}c.push(new a(n,t,e,null,null,1));for(var d=c.length-2;d>=0;--d){o=c[d];f[d]<=0?c[d]=new a(o._color,o.key,o.value,c[d+1],o.right,o._count+1):c[d]=new a(o._color,o.key,o.value,o.left,c[d+1],o._count+1)}for(d=c.length-1;d>1;--d){var p=c[d-1];o=c[d];if(p._color===i||o._color===i)break;var g=c[d-2];if(g.left===p)if(p.left===o){if(!(v=g.right)||v._color!==n){if(g._color=n,g.left=p.right,p._color=i,p.right=g,c[d-2]=p,c[d-1]=o,l(g),l(p),d>=3)(m=c[d-3]).left===g?m.left=p:m.right=p;break}p._color=i,g.right=s(i,v),g._color=n,d-=1}else{if(!(v=g.right)||v._color!==n){if(p.right=o.left,g._color=n,g.left=o.right,o._color=i,o.left=p,o.right=g,c[d-2]=o,c[d-1]=p,l(g),l(p),l(o),d>=3)(m=c[d-3]).left===g?m.left=o:m.right=o;break}p._color=i,g.right=s(i,v),g._color=n,d-=1}else if(p.right===o){if(!(v=g.left)||v._color!==n){if(g._color=n,g.right=p.left,p._color=i,p.left=g,c[d-2]=p,c[d-1]=o,l(g),l(p),d>=3)(m=c[d-3]).right===g?m.right=p:m.left=p;break}p._color=i,g.left=s(i,v),g._color=n,d-=1}else{var v;if(!(v=g.left)||v._color!==n){var m;if(p.left=o.right,g._color=n,g.right=o.left,o._color=i,o.right=p,o.left=g,c[d-2]=o,c[d-1]=p,l(g),l(p),l(o),d>=3)(m=c[d-3]).right===g?m.right=o:m.left=o;break}p._color=i,g.left=s(i,v),g._color=n,d-=1}}return c[0]._color=i,new u(r,c[0])},c.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return function t(e,r){var n;if(r.left&&(n=t(e,r.left)))return n;return(n=e(r.key,r.value))||(r.right?t(e,r.right):void 0)}(t,this.root);case 2:return function t(e,r,n,i){if(r(e,i.key)<=0){var a;if(i.left&&(a=t(e,r,n,i.left)))return a;if(a=n(i.key,i.value))return a}if(i.right)return t(e,r,n,i.right)}(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return function t(e,r,n,i,a){var o,s=n(e,a.key),l=n(r,a.key);if(s<=0){if(a.left&&(o=t(e,r,n,i,a.left)))return o;if(l>0&&(o=i(a.key,a.value)))return o}if(l>0&&a.right)return t(e,r,n,i,a.right)}(e,r,this._compare,t,this.root)}},Object.defineProperty(c,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(c,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),c.at=function(t){if(t<0)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},c.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<=0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},c.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},c.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},c.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},c.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=i<=0?r.left:r.right}return new f(this,[])},c.remove=function(t){var e=this.find(t);return e?e.remove():this},c.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=n<=0?r.left:r.right}};var h=f.prototype;function d(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function p(t,e){return te?1:0}Object.defineProperty(h,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(h,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),h.clone=function(){return new f(this.tree,this._stack.slice())},h.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new a(r._color,r.key,r.value,r.left,r.right,r._count);for(var c=t.length-2;c>=0;--c){(r=t[c]).left===t[c+1]?e[c]=new a(r._color,r.key,r.value,e[c+1],r.right,r._count):e[c]=new a(r._color,r.key,r.value,r.left,e[c+1],r._count)}if((r=e[e.length-1]).left&&r.right){var f=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var h=e[f-1];e.push(new a(r._color,h.key,h.value,r.left,r.right,r._count)),e[f-1].key=r.key,e[f-1].value=r.value;for(c=e.length-2;c>=f;--c)r=e[c],e[c]=new a(r._color,r.key,r.value,r.left,e[c+1],r._count);e[f-1].left=e[f]}if((r=e[e.length-1])._color===n){var p=e[e.length-2];p.left===r?p.left=null:p.right===r&&(p.right=null),e.pop();for(c=0;c=0;--c){if(e=t[c],0===c)return void(e._color=i);if((r=t[c-1]).left===e){if((a=r.right).right&&a.right._color===n)return u=(a=r.right=o(a)).right=o(a.right),r.right=a.left,a.left=r,a.right=u,a._color=r._color,e._color=i,r._color=i,u._color=i,l(r),l(a),c>1&&((f=t[c-2]).left===r?f.left=a:f.right=a),void(t[c-1]=a);if(a.left&&a.left._color===n)return u=(a=r.right=o(a)).left=o(a.left),r.right=u.left,a.left=u.right,u.left=r,u.right=a,u._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(u),c>1&&((f=t[c-2]).left===r?f.left=u:f.right=u),void(t[c-1]=u);if(a._color===i){if(r._color===n)return r._color=i,void(r.right=s(n,a));r.right=s(n,a);continue}a=o(a),r.right=a.left,a.left=r,a._color=r._color,r._color=n,l(r),l(a),c>1&&((f=t[c-2]).left===r?f.left=a:f.right=a),t[c-1]=a,t[c]=r,c+11&&((f=t[c-2]).right===r?f.right=a:f.left=a),void(t[c-1]=a);if(a.right&&a.right._color===n)return u=(a=r.left=o(a)).right=o(a.right),r.left=u.right,a.right=u.left,u.right=r,u.left=a,u._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(u),c>1&&((f=t[c-2]).right===r?f.right=u:f.left=u),void(t[c-1]=u);if(a._color===i){if(r._color===n)return r._color=i,void(r.left=s(n,a));r.left=s(n,a);continue}var f;a=o(a),r.left=a.right,a.right=r,a._color=r._color,r._color=n,l(r),l(a),c>1&&((f=t[c-2]).right===r?f.right=a:f.left=a),t[c-1]=a,t[c]=r,c+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(h,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(h,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),h.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),h.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),n=e[e.length-1];r[r.length-1]=new a(n._color,n.key,t,n.left,n.right,n._count);for(var i=e.length-2;i>=0;--i)(n=e[i]).left===e[i+1]?r[i]=new a(n._color,n.key,n.value,r[i+1],n.right,n._count):r[i]=new a(n._color,n.key,n.value,n.left,r[i+1],n._count);return new u(this.tree._compare,r[0])},h.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],94:[function(t,e,r){var n=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],i=607/128,a=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function o(t){if(t<0)return Number("0/0");for(var e=a[0],r=a.length-1;r>0;--r)e+=a[r]/(t+r);var n=t+i+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}e.exports=function t(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*t(1-e));if(e>100)return Math.exp(o(e));e-=1;for(var r=n[0],i=1;i<9;i++)r+=n[i]/(e+i);var a=e+7+.5;return Math.sqrt(2*Math.PI)*Math.pow(a,e+.5)*Math.exp(-a)*r},e.exports.log=o},{}],95:[function(t,e,r){e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("must specify type string");if(e=e||{},"undefined"==typeof document&&!e.canvas)return null;var r=e.canvas||document.createElement("canvas");"number"==typeof e.width&&(r.width=e.width);"number"==typeof e.height&&(r.height=e.height);var n,i=e;try{var a=[t];0===t.indexOf("webgl")&&a.push("experimental-"+t);for(var o=0;o0?(d[c]=-1,p[c]=0):(d[c]=0,p[c]=1)}}var g=[0,0,0],v={model:l,view:l,projection:l};f.isOpaque=function(){return!0},f.isTransparent=function(){return!1},f.drawTransparent=function(t){};var m=[0,0,0],y=[0,0,0],b=[0,0,0];f.draw=function(t){t=t||v;for(var e=this.gl,r=t.model||l,n=t.view||l,i=t.projection||l,a=this.bounds,s=o(r,n,i,a),c=s.cubeEdges,f=s.axis,h=n[12],x=n[13],_=n[14],w=n[15],A=this.pixelRatio*(i[3]*h+i[7]*x+i[11]*_+i[15]*w)/e.drawingBufferHeight,M=0;M<3;++M)this.lastCubeProps.cubeEdges[M]=c[M],this.lastCubeProps.axis[M]=f[M];var T=d;for(M=0;M<3;++M)p(d[M],M,this.bounds,c,f);e=this.gl;var k,E=g;for(M=0;M<3;++M)this.backgroundEnable[M]?E[M]=f[M]:E[M]=0;this._background.draw(r,n,i,a,E,this.backgroundColor),this._lines.bind(r,n,i,this);for(M=0;M<3;++M){var S=[0,0,0];f[M]>0?S[M]=a[1][M]:S[M]=a[0][M];for(var L=0;L<2;++L){var C=(M+1+L)%3,O=(M+1+(1^L))%3;this.gridEnable[C]&&this._lines.drawGrid(C,O,this.bounds,S,this.gridColor[C],this.gridWidth[C]*this.pixelRatio)}for(L=0;L<2;++L){C=(M+1+L)%3,O=(M+1+(1^L))%3;this.zeroEnable[O]&&Math.min(a[0][O],a[1][O])<=0&&Math.max(a[0][O],a[1][O])>=0&&this._lines.drawZero(C,O,this.bounds,S,this.zeroLineColor[O],this.zeroLineWidth[O]*this.pixelRatio)}}for(M=0;M<3;++M){this.lineEnable[M]&&this._lines.drawAxisLine(M,this.bounds,T[M].primalOffset,this.lineColor[M],this.lineWidth[M]*this.pixelRatio),this.lineMirror[M]&&this._lines.drawAxisLine(M,this.bounds,T[M].mirrorOffset,this.lineColor[M],this.lineWidth[M]*this.pixelRatio);var R=u(m,T[M].primalMinor),P=u(y,T[M].mirrorMinor),z=this.lineTickLength;for(L=0;L<3;++L){var I=A/r[5*L];R[L]*=z[L]*I,P[L]*=z[L]*I}this.lineTickEnable[M]&&this._lines.drawAxisTicks(M,T[M].primalOffset,R,this.lineTickColor[M],this.lineTickWidth[M]*this.pixelRatio),this.lineTickMirror[M]&&this._lines.drawAxisTicks(M,T[M].mirrorOffset,P,this.lineTickColor[M],this.lineTickWidth[M]*this.pixelRatio)}this._lines.unbind(),this._text.bind(r,n,i,this.pixelRatio);var N,D;function F(t){(D=[0,0,0])[t]=1}function j(t,e,r){var n=(t+1)%3,i=(t+2)%3,a=e[n],o=e[i],s=r[n],l=r[i];a>0&&l>0?F(n):a>0&&l<0?F(n):a<0&&l>0?F(n):a<0&&l<0?F(n):o>0&&s>0?F(i):o>0&&s<0?F(i):o<0&&s>0?F(i):o<0&&s<0&&F(i)}for(M=0;M<3;++M){var B=T[M].primalMinor,U=T[M].mirrorMinor,V=u(b,T[M].primalOffset);for(L=0;L<3;++L)this.lineTickEnable[M]&&(V[L]+=A*B[L]*Math.max(this.lineTickLength[L],0)/r[5*L]);var H=[0,0,0];if(H[M]=1,this.tickEnable[M]){-3600===this.tickAngle[M]?(this.tickAngle[M]=0,this._tickAlign[M]="auto"):this._tickAlign[M]=-1,N=1,"auto"===(k=[this._tickAlign[M],.5,N])[0]?k[0]=0:k[0]=parseInt(""+k[0]),D=[0,0,0],j(M,B,U);for(L=0;L<3;++L)V[L]+=A*B[L]*this.tickPad[L]/r[5*L];this._text.drawTicks(M,this.tickSize[M],this.tickAngle[M],V,this.tickColor[M],H,D,k)}if(this.labelEnable[M]){N=0,D=[0,0,0],this.labels[M].length>4&&(F(M),N=1),"auto"===(k=[this.labelAlign[M],.5,N])[0]?k[0]=0:k[0]=parseInt(""+k[0]);for(L=0;L<3;++L)V[L]+=A*B[L]*this.labelPad[L]/r[5*L];V[M]+=.5*(a[0][M]+a[1][M]),this._text.drawLabel(M,this.labelSize[M],this.labelAngle[M],V,this.labelColor[M],[0,0,0],D,k)}}this._text.unbind()},f.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":97,"./lib/cube.js":98,"./lib/lines.js":99,"./lib/text.js":101,"./lib/ticks.js":102}],97:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=[],s=0,l=0;l<3;++l)for(var u=(l+1)%3,c=(l+2)%3,f=[0,0,0],h=[0,0,0],d=-1;d<=1;d+=2){r.push(s,s+2,s+1,s+1,s+2,s+3),f[l]=d,h[l]=d;for(var p=-1;p<=1;p+=2){f[u]=p;for(var g=-1;g<=1;g+=2)f[c]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),s+=1}var v=u;u=c,c=v}var m=n(t,new Float32Array(e)),y=n(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),b=i(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),x=a(t);return x.attributes.position.location=0,x.attributes.normal.location=1,new o(t,m,b,x)};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders").bg;function o(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}var s=o.prototype;s.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;s<3;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),this.vao.unbind(),l.disable(l.POLYGON_OFFSET_FILL)}},s.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":100,"gl-buffer":104,"gl-vao":167}],98:[function(t,e,r){"use strict";e.exports=function(t,e,r,a){i(s,e,t),i(s,r,s);for(var d=0,y=0;y<2;++y){c[2]=a[y][2];for(var b=0;b<2;++b){c[1]=a[b][1];for(var x=0;x<2;++x)c[0]=a[x][0],h(l[d],c,s),d+=1}}for(var _=-1,y=0;y<8;++y){for(var w=l[y][3],A=0;A<3;++A)u[y][A]=l[y][A]/w;w<0&&(_<0?_=y:u[y][2]E&&(_|=1<E&&(_|=1<u[y][1]&&(I=y));for(var N=-1,y=0;y<3;++y){var D=I^1<u[F][0]&&(F=D)}}var j=g;j[0]=j[1]=j[2]=0,j[n.log2(N^I)]=I&N,j[n.log2(I^F)]=I&F;var B=7^F;B===_||B===z?(B=7^N,j[n.log2(F^B)]=B&F):j[n.log2(N^B)]=B&N;for(var U=v,V=_,M=0;M<3;++M)U[M]=V&1< HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]),l=n(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]);r.text=function(t){return i(t,s,l,null,[{name:"position",type:"vec3"}])};var u=n(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]),c=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]);r.bg=function(t){return i(t,u,c,null,[{name:"position",type:"vec3"},{name:"normal",type:"vec3"}])}},{"gl-shader":148,glslify:249}],101:[function(t,e,r){(function(r){"use strict";e.exports=function(t,e,r,a,s,l){var c=n(t),f=i(t,[{buffer:c,size:3}]),h=o(t);h.attributes.position.location=0;var d=new u(t,h,c,f);return d.update(e,r,a,s,l),d};var n=t("gl-buffer"),i=t("gl-vao"),a=t("vectorize-text"),o=t("./shaders").text,s=window||r.global||{},l=s.__TEXT_CACHE||{};s.__TEXT_CACHE={};function u(t,e,r,n){this.gl=t,this.shader=e,this.buffer=r,this.vao=n,this.tickOffset=this.tickCount=this.labelOffset=this.labelCount=null}var c=u.prototype,f=[0,0];c.bind=function(t,e,r,n){this.vao.bind(),this.shader.bind();var i=this.shader.uniforms;i.model=t,i.view=e,i.projection=r,i.pixelScale=n,f[0]=this.gl.drawingBufferWidth,f[1]=this.gl.drawingBufferHeight,this.shader.uniforms.resolution=f},c.unbind=function(){this.vao.unbind()},c.update=function(t,e,r,n,i){var o=[];function s(t,e,r,n,i,s){var u=l[r];u||(u=l[r]={});var c=u[e];c||(c=u[e]=function(t,e){try{return a(t,e)}catch(e){return console.warn('error vectorizing text:"'+t+'" error:',e),{cells:[],positions:[]}}}(e,{triangles:!0,font:r,textAlign:"center",textBaseline:"middle",lineSpacing:i,styletags:s}));for(var f=(n||12)/12,h=c.positions,d=c.cells,p=0,g=d.length;p=0;--m){var y=h[v[m]];o.push(f*y[0],-f*y[1],t)}}for(var u=[0,0,0],c=[0,0,0],f=[0,0,0],h=[0,0,0],d={breaklines:!0,bolds:!0,italics:!0,subscripts:!0,superscripts:!0},p=0;p<3;++p){f[p]=o.length/3|0,s(.5*(t[0][p]+t[1][p]),e[p],r[p],12,1.25,d),h[p]=(o.length/3|0)-f[p],u[p]=o.length/3|0;for(var g=0;g=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,u=o%a;o<0?(l=0|-Math.ceil(l),u=0|-u):(l=0|Math.floor(l),u|=0);var c=""+l;if(o<0&&(c="-"+c),i){for(var f=""+u;f.length=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r},r.equal=function(t,e){for(var r=0;r<3;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;nr)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function c(t,e){for(var r=n.malloc(t.length,e),i=t.length,a=0;a=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=u(this.gl,this.type,this.length,this.usage,t.data,e):this.length=u(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=n.malloc(t.size,r),l=a(s,t.shape);i.assign(l,t),this.length=u(this.gl,this.type,this.length,this.usage,e<0?s:s.subarray(0,t.size),e),n.free(s)}}else if(Array.isArray(t)){var f;f=this.type===this.gl.ELEMENT_ARRAY_BUFFER?c(t,"uint16"):c(t,"float32"),this.length=u(this.gl,this.type,this.length,this.usage,e<0?f:f.subarray(0,t.length),e),n.free(f)}else if("object"==typeof t&&"number"==typeof t.length)this.length=u(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");(t|=0)<=0&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=function(t,e,r,n){if(r=r||t.ARRAY_BUFFER,n=n||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(n!==t.DYNAMIC_DRAW&&n!==t.STATIC_DRAW&&n!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var i=t.createBuffer(),a=new s(t,r,i,0,n);return a.update(e),a}},{ndarray:285,"ndarray-ops":279,"typedarray-pool":347}],105:[function(t,e,r){"use strict";var n=t("gl-vec3"),i=(t("gl-vec4"),function(t,e){for(var r=0;r=e)return r-1;return r}),a=n.create(),o=n.create(),s=function(t,e,r){return tr?r:t},l=function(t,e,r,l){var u=t[0],c=t[1],f=t[2],h=r[0].length,d=r[1].length,p=r[2].length,g=i(r[0],u),v=i(r[1],c),m=i(r[2],f),y=g+1,b=v+1,x=m+1;if(l&&(g=s(g,0,h-1),y=s(y,0,h-1),v=s(v,0,d-1),b=s(b,0,d-1),m=s(m,0,p-1),x=s(x,0,p-1)),g<0||v<0||m<0||y>=h||b>=d||x>=p)return n.create();var _=(u-r[0][g])/(r[0][y]-r[0][g]),w=(c-r[1][v])/(r[1][b]-r[1][v]),A=(f-r[2][m])/(r[2][x]-r[2][m]);(_<0||_>1||isNaN(_))&&(_=0),(w<0||w>1||isNaN(w))&&(w=0),(A<0||A>1||isNaN(A))&&(A=0);var M=m*h*d,T=x*h*d,k=v*h,E=b*h,S=g,L=y,C=e[k+M+S],O=e[k+M+L],R=e[E+M+S],P=e[E+M+L],z=e[k+T+S],I=e[k+T+L],N=e[E+T+S],D=e[E+T+L],F=n.create();return n.lerp(F,C,O,_),n.lerp(a,R,P,_),n.lerp(F,F,a,w),n.lerp(a,z,I,_),n.lerp(o,N,D,_),n.lerp(a,a,o,w),n.lerp(F,F,a,A),F};e.exports=function(t,e){var r;r=t.positions?t.positions:function(t){for(var e=t[0],r=t[1],n=t[2],i=[],a=0;as&&(s=n.length(x)),b&&(y=Math.min(y,2*n.distance(g,_)/(n.length(v)+n.length(x)))),g=_,v=x,m.push(x)}var w=[u,f,d],A=[c,h,p];e&&(e[0]=w,e[1]=A),0===s&&(s=1);var M=1/s;isFinite(y)&&!isNaN(y)||(y=1),o.vectorScale=y;var T=function(t,e,r){var i=n.create();return void 0!==t&&n.set(i,t,e,r),i}(0,1,0),k=t.coneSize||.5;t.absoluteConeSize&&(k=t.absoluteConeSize*M),o.coneScale=k;b=0;for(var E=0;b1.0001)return null;v+=g[c]}if(Math.abs(v-1)>.001)return null;return[f,function(t,e){for(var r=[0,0,0],n=0;n=1},b.isTransparent=function(){return this.opacity<1},b.pickSlots=1,b.setPickBase=function(t){this.pickId=t},b.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=d.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},b.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||m,n=t.view||m,i=t.projection||m,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,vectorScale:this.vectorScale,coneScale:this.coneScale,coneOffset:this.coneOffset,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},b.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions[r[1]].slice(0,3);return{index:Math.floor(r[1]/48),position:n,dataCoordinate:n}},b.dispose=function(){this.texture.dispose(),this.triShader.dispose(),this.pickShader.dispose(),this.triangleVAO.dispose(),this.trianglePositions.dispose(),this.triangleVectors.dispose(),this.triangleColors.dispose(),this.triangleUVs.dispose(),this.triangleNormals.dispose(),this.triangleIds.dispose(),this.edgeVAO.dispose(),this.edgePositions.dispose(),this.edgeColors.dispose(),this.edgeUVs.dispose(),this.edgeIds.dispose(),this.pointVAO.dispose(),this.pointPositions.dispose(),this.pointColors.dispose(),this.pointUVs.dispose(),this.pointSizes.dispose(),this.pointIds.dispose(),this.contourVAO.dispose(),this.contourPositions.dispose()},e.exports=function(t,e){1===arguments.length&&(t=(e=t).gl);var r=e.triShader||function(t){var e=n(t,g.vertex,g.fragment,null,g.attributes);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.vector.location=5,e}(t),s=x(t),l=o(t,c(new Uint8Array([255,255,255,255]),[1,1,4]));l.generateMipmap(),l.minFilter=t.LINEAR_MIPMAP_LINEAR,l.magFilter=t.LINEAR;var u=i(t),f=i(t),h=i(t),d=i(t),p=i(t),v=i(t),m=a(t,[{buffer:u,type:t.FLOAT,size:4},{buffer:v,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:h,type:t.FLOAT,size:4},{buffer:d,type:t.FLOAT,size:2},{buffer:p,type:t.FLOAT,size:3},{buffer:f,type:t.FLOAT,size:3}]),b=i(t),_=i(t),w=i(t),A=i(t),M=a(t,[{buffer:b,type:t.FLOAT,size:3},{buffer:A,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:_,type:t.FLOAT,size:4},{buffer:w,type:t.FLOAT,size:2}]),T=i(t),k=i(t),E=i(t),S=i(t),L=i(t),C=a(t,[{buffer:T,type:t.FLOAT,size:3},{buffer:L,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:k,type:t.FLOAT,size:4},{buffer:E,type:t.FLOAT,size:2},{buffer:S,type:t.FLOAT,size:1}]),O=i(t),R=new y(t,l,r,null,null,s,null,null,u,f,v,h,d,p,m,b,A,_,w,M,T,L,k,E,S,C,O,a(t,[{buffer:O,type:t.FLOAT,size:3}]));return R.update(e),R}},{"./closest-point":106,"./shaders":108,colormap:69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-shader":148,"gl-texture2d":163,"gl-vao":167,ndarray:285,normals:287,"simplicial-complex-contour":329,"typedarray-pool":347}],108:[function(t,e,r){var n=t("glslify"),i=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec3"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec3"}]}},{glslify:249}],109:[function(t,e,r){e.exports={0:"NONE",1:"ONE",2:"LINE_LOOP",3:"LINE_STRIP",4:"TRIANGLES",5:"TRIANGLE_STRIP",6:"TRIANGLE_FAN",256:"DEPTH_BUFFER_BIT",512:"NEVER",513:"LESS",514:"EQUAL",515:"LEQUAL",516:"GREATER",517:"NOTEQUAL",518:"GEQUAL",519:"ALWAYS",768:"SRC_COLOR",769:"ONE_MINUS_SRC_COLOR",770:"SRC_ALPHA",771:"ONE_MINUS_SRC_ALPHA",772:"DST_ALPHA",773:"ONE_MINUS_DST_ALPHA",774:"DST_COLOR",775:"ONE_MINUS_DST_COLOR",776:"SRC_ALPHA_SATURATE",1024:"STENCIL_BUFFER_BIT",1028:"FRONT",1029:"BACK",1032:"FRONT_AND_BACK",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",2304:"CW",2305:"CCW",2849:"LINE_WIDTH",2884:"CULL_FACE",2885:"CULL_FACE_MODE",2886:"FRONT_FACE",2928:"DEPTH_RANGE",2929:"DEPTH_TEST",2930:"DEPTH_WRITEMASK",2931:"DEPTH_CLEAR_VALUE",2932:"DEPTH_FUNC",2960:"STENCIL_TEST",2961:"STENCIL_CLEAR_VALUE",2962:"STENCIL_FUNC",2963:"STENCIL_VALUE_MASK",2964:"STENCIL_FAIL",2965:"STENCIL_PASS_DEPTH_FAIL",2966:"STENCIL_PASS_DEPTH_PASS",2967:"STENCIL_REF",2968:"STENCIL_WRITEMASK",2978:"VIEWPORT",3024:"DITHER",3042:"BLEND",3088:"SCISSOR_BOX",3089:"SCISSOR_TEST",3106:"COLOR_CLEAR_VALUE",3107:"COLOR_WRITEMASK",3317:"UNPACK_ALIGNMENT",3333:"PACK_ALIGNMENT",3379:"MAX_TEXTURE_SIZE",3386:"MAX_VIEWPORT_DIMS",3408:"SUBPIXEL_BITS",3410:"RED_BITS",3411:"GREEN_BITS",3412:"BLUE_BITS",3413:"ALPHA_BITS",3414:"DEPTH_BITS",3415:"STENCIL_BITS",3553:"TEXTURE_2D",4352:"DONT_CARE",4353:"FASTEST",4354:"NICEST",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT",5386:"INVERT",5890:"TEXTURE",6401:"STENCIL_INDEX",6402:"DEPTH_COMPONENT",6406:"ALPHA",6407:"RGB",6408:"RGBA",6409:"LUMINANCE",6410:"LUMINANCE_ALPHA",7680:"KEEP",7681:"REPLACE",7682:"INCR",7683:"DECR",7936:"VENDOR",7937:"RENDERER",7938:"VERSION",9728:"NEAREST",9729:"LINEAR",9984:"NEAREST_MIPMAP_NEAREST",9985:"LINEAR_MIPMAP_NEAREST",9986:"NEAREST_MIPMAP_LINEAR",9987:"LINEAR_MIPMAP_LINEAR",10240:"TEXTURE_MAG_FILTER",10241:"TEXTURE_MIN_FILTER",10242:"TEXTURE_WRAP_S",10243:"TEXTURE_WRAP_T",10497:"REPEAT",10752:"POLYGON_OFFSET_UNITS",16384:"COLOR_BUFFER_BIT",32769:"CONSTANT_COLOR",32770:"ONE_MINUS_CONSTANT_COLOR",32771:"CONSTANT_ALPHA",32772:"ONE_MINUS_CONSTANT_ALPHA",32773:"BLEND_COLOR",32774:"FUNC_ADD",32777:"BLEND_EQUATION_RGB",32778:"FUNC_SUBTRACT",32779:"FUNC_REVERSE_SUBTRACT",32819:"UNSIGNED_SHORT_4_4_4_4",32820:"UNSIGNED_SHORT_5_5_5_1",32823:"POLYGON_OFFSET_FILL",32824:"POLYGON_OFFSET_FACTOR",32854:"RGBA4",32855:"RGB5_A1",32873:"TEXTURE_BINDING_2D",32926:"SAMPLE_ALPHA_TO_COVERAGE",32928:"SAMPLE_COVERAGE",32936:"SAMPLE_BUFFERS",32937:"SAMPLES",32938:"SAMPLE_COVERAGE_VALUE",32939:"SAMPLE_COVERAGE_INVERT",32968:"BLEND_DST_RGB",32969:"BLEND_SRC_RGB",32970:"BLEND_DST_ALPHA",32971:"BLEND_SRC_ALPHA",33071:"CLAMP_TO_EDGE",33170:"GENERATE_MIPMAP_HINT",33189:"DEPTH_COMPONENT16",33306:"DEPTH_STENCIL_ATTACHMENT",33635:"UNSIGNED_SHORT_5_6_5",33648:"MIRRORED_REPEAT",33901:"ALIASED_POINT_SIZE_RANGE",33902:"ALIASED_LINE_WIDTH_RANGE",33984:"TEXTURE0",33985:"TEXTURE1",33986:"TEXTURE2",33987:"TEXTURE3",33988:"TEXTURE4",33989:"TEXTURE5",33990:"TEXTURE6",33991:"TEXTURE7",33992:"TEXTURE8",33993:"TEXTURE9",33994:"TEXTURE10",33995:"TEXTURE11",33996:"TEXTURE12",33997:"TEXTURE13",33998:"TEXTURE14",33999:"TEXTURE15",34000:"TEXTURE16",34001:"TEXTURE17",34002:"TEXTURE18",34003:"TEXTURE19",34004:"TEXTURE20",34005:"TEXTURE21",34006:"TEXTURE22",34007:"TEXTURE23",34008:"TEXTURE24",34009:"TEXTURE25",34010:"TEXTURE26",34011:"TEXTURE27",34012:"TEXTURE28",34013:"TEXTURE29",34014:"TEXTURE30",34015:"TEXTURE31",34016:"ACTIVE_TEXTURE",34024:"MAX_RENDERBUFFER_SIZE",34041:"DEPTH_STENCIL",34055:"INCR_WRAP",34056:"DECR_WRAP",34067:"TEXTURE_CUBE_MAP",34068:"TEXTURE_BINDING_CUBE_MAP",34069:"TEXTURE_CUBE_MAP_POSITIVE_X",34070:"TEXTURE_CUBE_MAP_NEGATIVE_X",34071:"TEXTURE_CUBE_MAP_POSITIVE_Y",34072:"TEXTURE_CUBE_MAP_NEGATIVE_Y",34073:"TEXTURE_CUBE_MAP_POSITIVE_Z",34074:"TEXTURE_CUBE_MAP_NEGATIVE_Z",34076:"MAX_CUBE_MAP_TEXTURE_SIZE",34338:"VERTEX_ATTRIB_ARRAY_ENABLED",34339:"VERTEX_ATTRIB_ARRAY_SIZE",34340:"VERTEX_ATTRIB_ARRAY_STRIDE",34341:"VERTEX_ATTRIB_ARRAY_TYPE",34342:"CURRENT_VERTEX_ATTRIB",34373:"VERTEX_ATTRIB_ARRAY_POINTER",34466:"NUM_COMPRESSED_TEXTURE_FORMATS",34467:"COMPRESSED_TEXTURE_FORMATS",34660:"BUFFER_SIZE",34661:"BUFFER_USAGE",34816:"STENCIL_BACK_FUNC",34817:"STENCIL_BACK_FAIL",34818:"STENCIL_BACK_PASS_DEPTH_FAIL",34819:"STENCIL_BACK_PASS_DEPTH_PASS",34877:"BLEND_EQUATION_ALPHA",34921:"MAX_VERTEX_ATTRIBS",34922:"VERTEX_ATTRIB_ARRAY_NORMALIZED",34930:"MAX_TEXTURE_IMAGE_UNITS",34962:"ARRAY_BUFFER",34963:"ELEMENT_ARRAY_BUFFER",34964:"ARRAY_BUFFER_BINDING",34965:"ELEMENT_ARRAY_BUFFER_BINDING",34975:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",35040:"STREAM_DRAW",35044:"STATIC_DRAW",35048:"DYNAMIC_DRAW",35632:"FRAGMENT_SHADER",35633:"VERTEX_SHADER",35660:"MAX_VERTEX_TEXTURE_IMAGE_UNITS",35661:"MAX_COMBINED_TEXTURE_IMAGE_UNITS",35663:"SHADER_TYPE",35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",35712:"DELETE_STATUS",35713:"COMPILE_STATUS",35714:"LINK_STATUS",35715:"VALIDATE_STATUS",35716:"INFO_LOG_LENGTH",35717:"ATTACHED_SHADERS",35718:"ACTIVE_UNIFORMS",35719:"ACTIVE_UNIFORM_MAX_LENGTH",35720:"SHADER_SOURCE_LENGTH",35721:"ACTIVE_ATTRIBUTES",35722:"ACTIVE_ATTRIBUTE_MAX_LENGTH",35724:"SHADING_LANGUAGE_VERSION",35725:"CURRENT_PROGRAM",36003:"STENCIL_BACK_REF",36004:"STENCIL_BACK_VALUE_MASK",36005:"STENCIL_BACK_WRITEMASK",36006:"FRAMEBUFFER_BINDING",36007:"RENDERBUFFER_BINDING",36048:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36049:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36050:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36051:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36053:"FRAMEBUFFER_COMPLETE",36054:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36055:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36057:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36061:"FRAMEBUFFER_UNSUPPORTED",36064:"COLOR_ATTACHMENT0",36096:"DEPTH_ATTACHMENT",36128:"STENCIL_ATTACHMENT",36160:"FRAMEBUFFER",36161:"RENDERBUFFER",36162:"RENDERBUFFER_WIDTH",36163:"RENDERBUFFER_HEIGHT",36164:"RENDERBUFFER_INTERNAL_FORMAT",36168:"STENCIL_INDEX8",36176:"RENDERBUFFER_RED_SIZE",36177:"RENDERBUFFER_GREEN_SIZE",36178:"RENDERBUFFER_BLUE_SIZE",36179:"RENDERBUFFER_ALPHA_SIZE",36180:"RENDERBUFFER_DEPTH_SIZE",36181:"RENDERBUFFER_STENCIL_SIZE",36194:"RGB565",36336:"LOW_FLOAT",36337:"MEDIUM_FLOAT",36338:"HIGH_FLOAT",36339:"LOW_INT",36340:"MEDIUM_INT",36341:"HIGH_INT",36346:"SHADER_COMPILER",36347:"MAX_VERTEX_UNIFORM_VECTORS",36348:"MAX_VARYING_VECTORS",36349:"MAX_FRAGMENT_UNIFORM_VECTORS",37440:"UNPACK_FLIP_Y_WEBGL",37441:"UNPACK_PREMULTIPLY_ALPHA_WEBGL",37442:"CONTEXT_LOST_WEBGL",37443:"UNPACK_COLORSPACE_CONVERSION_WEBGL",37444:"BROWSER_DEFAULT_WEBGL"}},{}],110:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":109}],111:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=n(e),o=i(e,[{buffer:r,type:e.FLOAT,size:3,offset:0,stride:40},{buffer:r,type:e.FLOAT,size:4,offset:12,stride:40},{buffer:r,type:e.FLOAT,size:3,offset:28,stride:40}]),l=a(e);l.attributes.position.location=0,l.attributes.color.location=1,l.attributes.offset.location=2;var u=new s(e,r,o,l);return u.update(t),u};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders/index"),o=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function s(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}var l=s.prototype;function u(t,e){for(var r=0;r<3;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}l.isOpaque=function(){return this.opacity>=1},l.isTransparent=function(){return this.opacity<1},l.drawTransparent=l.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||o,i=r.projection=t.projection||o;r.model=t.model||o,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],s=n[13],l=n[14],u=n[15],c=this.pixelRatio*(i[3]*a+i[7]*s+i[11]*l+i[15]*u)/e.drawingBufferHeight;this.vao.bind();for(var f=0;f<3;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*c,this.lineCount[f]&&e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var c=function(){for(var t=new Array(3),e=0;e<3;++e){for(var r=[],n=1;n<=2;++n)for(var i=-1;i<=1;i+=2){var a=[0,0,0];a[(n+e)%3]=i,r.push(a)}t[e]=r}return t}();function f(t,e,r,n){for(var i=c[n],a=0;a0)(g=c.slice())[s]+=d[1][s],i.push(c[0],c[1],c[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),u(this.bounds,g),o+=2+f(i,g,p,s)}}this.lineCount[s]=o-this.lineOffset[s]}this.buffer.update(i)}},l.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":112,"gl-buffer":104,"gl-vao":167}],112:[function(t,e,r){"use strict";var n=t("glslify"),i=t("gl-shader"),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]);e.exports=function(t){return i(t,a,o,null,[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"offset",type:"vec3"}])}},{"gl-shader":148,glslify:249}],113:[function(t,e,r){"use strict";var n=t("gl-texture2d");e.exports=function(t,e,r,n){i||(i=t.FRAMEBUFFER_UNSUPPORTED,a=t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT,o=t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS,s=t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);var u=t.getExtension("WEBGL_draw_buffers");!l&&u&&function(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);l=new Array(r+1);for(var n=0;n<=r;++n){for(var i=new Array(r),a=0;ac||r<0||r>c)throw new Error("gl-fbo: Parameters are too large for FBO");var f=1;if("color"in(n=n||{})){if((f=Math.max(0|n.color,0))<0)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(f>1){if(!u)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(f>t.getParameter(u.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+f+" draw buffers")}}var h=t.UNSIGNED_BYTE,d=t.getExtension("OES_texture_float");if(n.float&&f>0){if(!d)throw new Error("gl-fbo: Context does not support floating point textures");h=t.FLOAT}else n.preferFloat&&f>0&&d&&(h=t.FLOAT);var g=!0;"depth"in n&&(g=!!n.depth);var v=!1;"stencil"in n&&(v=!!n.stencil);return new p(t,e,r,h,f,g,v,u)};var i,a,o,s,l=null;function u(t){return[t.getParameter(t.FRAMEBUFFER_BINDING),t.getParameter(t.RENDERBUFFER_BINDING),t.getParameter(t.TEXTURE_BINDING_2D)]}function c(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function f(t){switch(t){case i:throw new Error("gl-fbo: Framebuffer unsupported");case a:throw new Error("gl-fbo: Framebuffer incomplete attachment");case o:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case s:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function h(t,e,r,i,a,o){if(!i)return null;var s=n(t,e,r,a,i);return s.magFilter=t.NEAREST,s.minFilter=t.NEAREST,s.mipSamples=1,s.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_2D,s.handle,0),s}function d(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function p(t,e,r,n,i,a,o,s){this.gl=t,this._shape=[0|e,0|r],this._destroyed=!1,this._ext=s,this.color=new Array(i);for(var p=0;p1&&s.drawBuffersWEBGL(l[o]);var y=r.getExtension("WEBGL_depth_texture");y?p?t.depth=h(r,i,a,y.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g&&(t.depth=h(r,i,a,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):g&&p?t._depth_rb=d(r,i,a,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g?t._depth_rb=d(r,i,a,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):p&&(t._depth_rb=d(r,i,a,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){for(t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null),m=0;mi||r<0||r>i)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var a=u(n),o=0;o max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1540259130(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1540259130(pixelArcLength).xyz);\n}"]),l=[{name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return i(t,a,o,null,l)},r.createPickShader=function(t){return i(t,a,s,null,l)}},{"gl-shader":148,glslify:249}],116:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl||t.scene&&t.scene.gl,r=c(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var o=f(e);o.attributes.position.location=0,o.attributes.nextPosition.location=1,o.attributes.arcLength.location=2,o.attributes.lineWidth.location=3,o.attributes.color.location=4;for(var s=n(e),u=i(e,[{buffer:s,size:3,offset:0,stride:48},{buffer:s,size:3,offset:12,stride:48},{buffer:s,size:1,offset:24,stride:48},{buffer:s,size:1,offset:28,stride:48},{buffer:s,size:4,offset:32,stride:48}]),h=l(new Array(1024),[256,1,4]),d=0;d<1024;++d)h.data[d]=255;var p=a(e,h);p.wrap=e.REPEAT;var g=new v(e,r,o,s,u,p);return g.update(t),g};var n=t("gl-buffer"),i=t("gl-vao"),a=t("gl-texture2d"),o=t("glsl-read-float"),s=t("binary-search-bounds"),l=t("ndarray"),u=t("./lib/shaders"),c=u.createShader,f=u.createPickShader,h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function d(t,e){for(var r=0,n=0;n<3;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function p(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;r<3;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function g(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function v(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}var m=v.prototype;m.isTransparent=function(){return this.opacity<1},m.isOpaque=function(){return this.opacity>=1},m.pickSlots=1,m.setPickBase=function(t){this.pickId=t},m.drawTransparent=m.draw=function(t){if(this.vertexCount){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||h,view:t.view||h,projection:t.projection||h,clipBounds:p(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},m.drawPick=function(t){if(this.vertexCount){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||h,view:t.view||h,projection:t.projection||h,pickId:this.pickId,clipBounds:p(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},m.update=function(t){var e,r;this.dirty=!0;var n=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var i=[],a=[],o=[],u=0,c=0,f=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],h=t.position||t.positions;if(h){var p=t.color||t.colors||[0,0,0,1],g=t.lineWidth||1,v=!1;t:for(e=1;e0){for(var w=0;w<24;++w)i.push(i[i.length-12]);c+=2,v=!0}continue t}f[0][r]=Math.min(f[0][r],x[r],_[r]),f[1][r]=Math.max(f[1][r],x[r],_[r])}Array.isArray(p[0])?(m=p.length>e-1?p[e-1]:p.length>0?p[p.length-1]:[0,0,0,1],y=p.length>e?p[e]:p.length>0?p[p.length-1]:[0,0,0,1]):m=y=p,3===m.length&&(m=[m[0],m[1],m[2],1]),3===y.length&&(y=[y[0],y[1],y[2],1]),b=Array.isArray(g)?g.length>e-1?g[e-1]:g.length>0?g[g.length-1]:[0,0,0,1]:g;var A=u;if(u+=d(x,_),v){for(r=0;r<2;++r)i.push(x[0],x[1],x[2],_[0],_[1],_[2],A,b,m[0],m[1],m[2],m[3]);c+=2,v=!1}i.push(x[0],x[1],x[2],_[0],_[1],_[2],A,b,m[0],m[1],m[2],m[3],x[0],x[1],x[2],_[0],_[1],_[2],A,-b,m[0],m[1],m[2],m[3],_[0],_[1],_[2],x[0],x[1],x[2],u,-b,y[0],y[1],y[2],y[3],_[0],_[1],_[2],x[0],x[1],x[2],u,b,y[0],y[1],y[2],y[3]),c+=4}}if(this.buffer.update(i),a.push(u),o.push(h[h.length-1].slice()),this.bounds=f,this.vertexCount=c,this.points=o,this.arcLength=a,"dashes"in t){var M=t.dashes.slice();for(M.unshift(0),e=1;e max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),l=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]),u=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),c=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]),f=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]),h=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]),d=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]),p=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:l,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:c,fragment:f,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:h,fragment:f,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:d,fragment:p,attributes:[{name:"position",type:"vec3"}]}},{glslify:249}],139:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("normals"),l=t("gl-mat4/multiply"),u=t("gl-mat4/invert"),c=t("ndarray"),f=t("colormap"),h=t("simplicial-complex-contour"),d=t("typedarray-pool"),p=t("./lib/shaders"),g=t("./lib/closest-point"),v=p.meshShader,m=p.wireShader,y=p.pointShader,b=p.pickShader,x=p.pointPickShader,_=p.contourShader,w=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function A(t,e,r,n,i,a,o,s,l,u,c,f,h,d,p,g,v,m,y,b,x,_,A,M,T,k,E){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=c,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=u,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=p,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=b,this.pointColors=_,this.pointUVs=A,this.pointSizes=M,this.pointIds=x,this.pointVAO=T,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=k,this.contourVAO=E,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=w,this._view=w,this._projection=w,this._resolution=[1,1]}var M=A.prototype;function T(t){var e=n(t,y.vertex,y.fragment);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function k(t){var e=n(t,b.vertex,b.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e}function E(t){var e=n(t,x.vertex,x.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function S(t){var e=n(t,_.vertex,_.fragment);return e.attributes.position.location=0,e}M.isOpaque=function(){return this.opacity>=1},M.isTransparent=function(){return this.opacity<1},M.pickSlots=1,M.setPickBase=function(t){this.pickId=t},M.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=d.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},M.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||w,n=t.view||w,i=t.projection||w,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},M.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;a0&&0===C[e-1];)C.pop(),O.pop().dispose()}window.addEventListener("resize",B),F.update=function(t){e||(t=t||{},R=!0,P=!0)},F.add=function(t){e||(t.axes=T,S.push(t),L.push(-1),R=!0,P=!0,U())},F.remove=function(t){if(!e){var r=S.indexOf(t);r<0||(S.splice(r,1),L.pop(),R=!0,P=!0,U())}},F.dispose=function(){if(!e&&(e=!0,window.removeEventListener("resize",B),r.removeEventListener("webglcontextlost",q),F.mouseListener.enabled=!1,!F.contextLost)){T.dispose(),E.dispose();for(var t=0;tx.distance)continue;for(var c=0;c0){r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function v(t){return"boolean"!=typeof t||t}},{"./lib/shader":140,"3d-view-controls":10,"a-big-triangle":12,"gl-axes3d":96,"gl-axes3d/properties":103,"gl-fbo":113,"gl-mat4/perspective":128,"gl-select-static":147,"gl-spikes3d":156,"is-mobile":259,"mouse-change":270}],142:[function(t,e,r){e.exports=function(t,e,r,n){var i,a,o,s,l,u=e[0],c=e[1],f=e[2],h=e[3],d=r[0],p=r[1],g=r[2],v=r[3];(a=u*d+c*p+f*g+h*v)<0&&(a=-a,d=-d,p=-p,g=-g,v=-v);1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n);return t[0]=s*u+l*d,t[1]=s*c+l*p,t[2]=s*f+l*g,t[3]=s*h+l*v,t}},{}],143:[function(t,e,r){"use strict";e.exports=function(t){return t||0===t?t.toString():""}},{}],144:[function(t,e,r){"use strict";var n=t("vectorize-text");e.exports=function(t,e){var r=i[e];r||(r=i[e]={});if(t in r)return r[t];var a={textAlign:"center",textBaseline:"middle",lineHeight:1,font:e,lineSpacing:1.25,styletags:{breaklines:!0,bolds:!0,italics:!0,subscripts:!0,superscripts:!0},triangles:!0},o=n(t,a);a.triangles=!1;for(var s=n(t,a),l=[[1/0,1/0],[-1/0,-1/0]],u=s.positions.length,c=0;c max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),o=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),s=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]),l=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]),u=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]),c=[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:c},h={vertex:o,fragment:l,attributes:c},d={vertex:s,fragment:l,attributes:c},p={vertex:a,fragment:u,attributes:c},g={vertex:o,fragment:u,attributes:c},v={vertex:s,fragment:u,attributes:c};function m(t,e){var r=n(t,e),i=r.attributes;return i.position.location=0,i.color.location=1,i.glyph.location=2,i.id.location=3,r}r.createPerspective=function(t){return m(t,f)},r.createOrtho=function(t){return m(t,h)},r.createProject=function(t){return m(t,d)},r.createPickPerspective=function(t){return m(t,p)},r.createPickOrtho=function(t){return m(t,g)},r.createPickProject=function(t){return m(t,v)}},{"gl-shader":148,glslify:249}],146:[function(t,e,r){"use strict";var n=t("is-string-blank"),i=t("gl-buffer"),a=t("gl-vao"),o=t("typedarray-pool"),s=t("gl-mat4/multiply"),l=t("./lib/shaders"),u=t("./lib/glyphs"),c=t("./lib/get-simple-string"),f=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function h(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function d(t,e,r,n){return h(n,n),h(n,n),h(n,n)}function p(t,e){this.index=t,this.dataCoordinate=this.position=e}e.exports=function(t){var e=t.gl,r=l.createPerspective(e),n=l.createOrtho(e),o=l.createProject(e),s=l.createPickPerspective(e),u=l.createPickOrtho(e),c=l.createPickProject(e),f=i(e),h=i(e),d=i(e),p=i(e),g=a(e,[{buffer:f,size:3,type:e.FLOAT},{buffer:h,size:4,type:e.FLOAT},{buffer:d,size:2,type:e.FLOAT},{buffer:p,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),v=new m(e,r,n,o,f,h,d,p,g,s,u,c);return v.update(t),v};var g=1;function v(t){return!0===t?g:t>g?g:t}function m(t,e,r,n,i,a,o,s,l,u,c,f){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=a,this.glyphBuffer=o,this.idBuffer=s,this.vao=l,this.vertexCount=0,this.lineVertexCount=0,this.opacity=g,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[g,g,g],this.pickId=0,this.pickPerspectiveShader=u,this.pickOrthoShader=c,this.pickProjectShader=f,this.points=[],this._selectResult=new p(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.dirty=!0}var y=m.prototype;y.pickSlots=1,y.setPickBase=function(t){this.pickId=t},y.isTransparent=function(){if(this.opacity=g)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=g)return!0;return!1};var b=[0,0],x=[0,0,0],_=[0,0,0],w=[0,0,0,1],A=[0,0,0,1],M=f.slice(),T=[0,0,0],k=[[0,0,0],[0,0,0]];function E(t){return t[0]=t[1]=t[2]=0,t}function S(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function L(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function C(t,e,r){var n,i=e.axesProject,a=e.gl,o=t.uniforms,l=r.model||f,u=r.view||f,c=r.projection||f,h=e.axesBounds,p=function(t){for(var e=k,r=0;r<2;++r)for(var n=0;n<3;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}(e.clipBounds);n=e.axes&&e.axes.lastCubeProps?e.axes.lastCubeProps.axis:[1,1,1],b[0]=2/a.drawingBufferWidth,b[1]=2/a.drawingBufferHeight,t.bind(),o.view=u,o.projection=c,o.screenSize=b,o.highlightId=e.highlightId,o.highlightScale=e.highlightScale,o.clipBounds=p,o.pickGroup=e.pickId/255,o.pixelRatio=e.pixelRatio;for(var g=0;g<3;++g)if(i[g]){o.scale=e.projectScale[g],o.opacity=e.projectOpacity[g];for(var v=M,m=0;m<16;++m)v[m]=0;for(m=0;m<4;++m)v[5*m]=1;v[5*g]=0,n[g]<0?v[12+g]=h[0][g]:v[12+g]=h[1][g],s(v,l,v),o.model=v;var y=(g+1)%3,C=(g+2)%3,O=E(x),R=E(_);O[y]=1,R[C]=1;var P=d(0,0,0,S(w,O)),z=d(0,0,0,S(A,R));if(Math.abs(P[1])>Math.abs(z[1])){var I=P;P=z,z=I,I=O,O=R,R=I;var N=y;y=C,C=N}P[0]<0&&(O[y]=-1),z[1]>0&&(R[C]=-1);var D=0,F=0;for(m=0;m<4;++m)D+=Math.pow(l[4*y+m],2),F+=Math.pow(l[4*C+m],2);O[y]/=Math.sqrt(D),R[C]/=Math.sqrt(F),o.axes[0]=O,o.axes[1]=R,o.fragClipBounds[0]=L(T,p[0],g,-1e8),o.fragClipBounds[1]=L(T,p[1],g,1e8),e.vao.bind(),e.vao.draw(a.TRIANGLES,e.vertexCount),e.lineWidth>0&&(a.lineWidth(e.lineWidth),e.vao.draw(a.LINES,e.lineVertexCount,e.vertexCount)),e.vao.unbind()}}var O=[[-1e8,-1e8,-1e8],[1e8,1e8,1e8]];function R(t,e,r,n,i,a){var o=r.gl;if((i===r.projectOpacity0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount)),r.vao.unbind()}}function P(t,e,r){var i;i=Array.isArray(t)?e=this.pointCount||e<0)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;i<3;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},y.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},y.update=function(t){if("perspective"in(t=t||{})&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t){if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{r=+t.projectOpacity;this.projectOpacity=[r,r,r]}for(var n=0;n<3;++n)this.projectOpacity[n]=v(this.projectOpacity[n])}"opacity"in t&&(this.opacity=v(t.opacity)),this.dirty=!0;var i,a,s=t.position,l=t.font||"normal",u=t.alignment||[0,0];if(2===u.length)i=u[0],a=u[1];else{i=[],a=[];for(n=0;n0){var R=0,z=b,I=[0,0,0,1],N=[0,0,0,1],D=Array.isArray(d)&&Array.isArray(d[0]),F=Array.isArray(m)&&Array.isArray(m[0]);t:for(n=0;n<_;++n){y+=1;for(w=s[n],A=0;A<3;++A){if(isNaN(w[A])||!isFinite(w[A]))continue t;f[A]=Math.max(f[A],w[A]),c[A]=Math.min(c[A],w[A])}M=(j=P(h,n,l)).mesh,T=j.lines,k=j.bounds;var j,B=j.visible;if(B)if(Array.isArray(d)){if(3===(U=D?n0?1-k[0][0]:X<0?1+k[1][0]:1,W*=W>0?1-k[0][1]:W<0?1+k[1][1]:1],Z=M.cells||[],Q=M.positions||[];for(A=0;Athis.buffer.length){i.free(this.buffer);for(var n=this.buffer=i.mallocUint8(o(r*e*4)),a=0;ar)for(t=r;te)for(t=e;t=0){for(var A=0|w.type.charAt(w.type.length-1),M=new Array(A),T=0;T=0;)k+=1;_[y]=k}var E=new Array(r.length);function S(){h.program=o.program(d,h._vref,h._fref,x,_);for(var t=0;t=0){var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new n("","Invalid data type for attribute "+f+": "+h);o(t,e,d[0],i,p,a,f)}else{if(!(h.indexOf("mat")>=0))throw new n("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new n("","Invalid data type for attribute "+f+": "+h);s(t,e,d,i,p,a,f)}}}return a};var n=t("./GLError");function i(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}var a=i.prototype;function o(t,e,r,n,a,o,s){for(var l=["gl","v"],u=[],c=0;c4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+a+"fv(locations["+e+"],false,obj"+t+")"}throw new i("","Unknown uniform data type for "+name+": "+r)}var a=r.charCodeAt(r.length-1)-48;if(a<2||a>4)throw new i("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+a+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+a+"fv(locations["+e+"],obj"+t+")";default:throw new i("","Unrecognized data type for vector "+name+": "+r)}}}function u(e){for(var n=["return function updateProperty(obj){"],i=function t(e,r){if("object"!=typeof r)return[[e,r]];var n=[];for(var i in r){var a=r[i],o=e;parseInt(i)+""===i?o+="["+i+"]":o+="."+i,"object"==typeof a?n.push.apply(n,t(o,a)):n.push([o,a])}return n}("",e),a=0;a4)throw new i("","Invalid data type");return"b"===t.charAt(0)?o(r,!1):o(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(r<2||r>4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+t);return o(r*r,0)}throw new i("","Unknown uniform data type for "+name+": "+t)}}(r[c].type);var d}function f(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var u=1;u1)for(var l=0;l 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec4"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec4"}]}},{glslify:249}],159:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("normals"),l=t("gl-mat4/multiply"),u=t("gl-mat4/invert"),c=t("ndarray"),f=t("colormap"),h=t("simplicial-complex-contour"),d=t("typedarray-pool"),p=t("./shaders"),g=(t("./closest-point"),p.meshShader),v=p.pickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function y(t,e,r,n,i,a,o,s,l,u,c,f,h,d,p,g,v,y,b,x,_,w,A,M,T,k,E,S){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleVectors=u,this.triangleColors=f,this.triangleNormals=d,this.triangleUVs=h,this.triangleIds=c,this.triangleVAO=p,this.triangleCount=0,this.lineWidth=1,this.edgePositions=g,this.edgeColors=y,this.edgeUVs=b,this.edgeIds=v,this.edgeVAO=x,this.edgeCount=0,this.pointPositions=_,this.pointColors=A,this.pointUVs=M,this.pointSizes=T,this.pointIds=w,this.pointVAO=k,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=E,this.contourVAO=S,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!1,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this.tubeScale=1,this._model=m,this._view=m,this._projection=m,this._resolution=[1,1]}var b=y.prototype;function x(t){var e=n(t,v.vertex,v.fragment,null,v.attributes);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.vector.location=5,e}b.isOpaque=function(){return this.opacity>=1},b.isTransparent=function(){return this.opacity<1},b.pickSlots=1,b.setPickBase=function(t){this.pickId=t},b.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=d.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},b.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||m,n=t.view||m,i=t.projection||m,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,tubeScale:this.tubeScale,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},b.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions[r[1]].slice(0,3);return{index:e,position:n,intensity:this.intensity[r[1]],velocity:this.vectors[r[1]].slice(0,3),divergence:this.vectors[r[1]][3],dataCoordinate:n}},b.dispose=function(){this.texture.dispose(),this.triShader.dispose(),this.pickShader.dispose(),this.triangleVAO.dispose(),this.trianglePositions.dispose(),this.triangleVectors.dispose(),this.triangleColors.dispose(),this.triangleUVs.dispose(),this.triangleNormals.dispose(),this.triangleIds.dispose(),this.edgeVAO.dispose(),this.edgePositions.dispose(),this.edgeColors.dispose(),this.edgeUVs.dispose(),this.edgeIds.dispose(),this.pointVAO.dispose(),this.pointPositions.dispose(),this.pointColors.dispose(),this.pointUVs.dispose(),this.pointSizes.dispose(),this.pointIds.dispose(),this.contourVAO.dispose(),this.contourPositions.dispose()},e.exports=function(t,e){1===arguments.length&&(t=(e=t).gl);var r=e.triShader||function(t){var e=n(t,g.vertex,g.fragment,null,g.attributes);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.vector.location=5,e}(t),s=x(t),l=o(t,c(new Uint8Array([255,255,255,255]),[1,1,4]));l.generateMipmap(),l.minFilter=t.LINEAR_MIPMAP_LINEAR,l.magFilter=t.LINEAR;var u=i(t),f=i(t),h=i(t),d=i(t),p=i(t),v=i(t),m=a(t,[{buffer:u,type:t.FLOAT,size:4},{buffer:v,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:h,type:t.FLOAT,size:4},{buffer:d,type:t.FLOAT,size:2},{buffer:p,type:t.FLOAT,size:3},{buffer:f,type:t.FLOAT,size:4}]),b=i(t),_=i(t),w=i(t),A=i(t),M=a(t,[{buffer:b,type:t.FLOAT,size:3},{buffer:A,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:_,type:t.FLOAT,size:4},{buffer:w,type:t.FLOAT,size:2}]),T=i(t),k=i(t),E=i(t),S=i(t),L=i(t),C=a(t,[{buffer:T,type:t.FLOAT,size:3},{buffer:L,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:k,type:t.FLOAT,size:4},{buffer:E,type:t.FLOAT,size:2},{buffer:S,type:t.FLOAT,size:1}]),O=i(t),R=new y(t,l,r,null,null,s,null,null,u,f,v,h,d,p,m,b,A,_,w,M,T,L,k,E,S,C,O,a(t,[{buffer:O,type:t.FLOAT,size:3}]));return R.update(e),R}},{"./closest-point":157,"./shaders":158,colormap:69,"gl-buffer":104,"gl-mat4/invert":125,"gl-mat4/multiply":127,"gl-shader":148,"gl-texture2d":163,"gl-vao":167,ndarray:285,normals:287,"simplicial-complex-contour":329,"typedarray-pool":347}],160:[function(t,e,r){"use strict";var n=t("gl-vec3"),i=t("gl-vec4"),a=function(t,e,r,a){for(var o=0,s=0;so&&(o=c)}var f=t.map(function(t){return function(t,e,r,a){var o,s,l,u=t.points,c=t.velocities,f=t.divergences;n.set(n.create(),0,1,0),n.create(),n.create();n.create();for(var h=[],d=[],p=[],g=[],v=[],m=[],y=0,b=0,x=i.create(),_=i.create(),w=0;w0)for(A=0;A<8;A++){var M=(A+1)%8;h.push(g[A],v[A],v[M],v[M],g[M],g[A]),p.push(_,x,x,x,_,_),m.push(y,b,b,b,y,y),d.push([h.length-6,h.length-5,h.length-4],[h.length-3,h.length-2,h.length-1])}var T=g;g=v,v=T,T=_,_=x,x=T,T=y,y=b,b=T}return{positions:h,cells:d,vectors:p,vertexIntensity:m}}(t,r,a,o)}),h=[],d=[],p=[],g=[];for(s=0;se)return r-1}return r},u=n.create(),c=n.create(),f=function(t,e,r){return tr?r:t},h=function(t,e,r,i){var a=t[0],o=t[1],s=t[2],h=r[0].length,d=r[1].length,p=r[2].length,g=l(r[0],a),v=l(r[1],o),m=l(r[2],s),y=g+1,b=v+1,x=m+1;if(r[0][g]===a&&(y=g),r[1][v]===o&&(b=v),r[2][m]===s&&(x=m),i&&(g=f(g,0,h-1),y=f(y,0,h-1),v=f(v,0,d-1),b=f(b,0,d-1),m=f(m,0,p-1),x=f(x,0,p-1)),g<0||v<0||m<0||y>=h||b>=d||x>=p)return n.create();var _=(a-r[0][g])/(r[0][y]-r[0][g]),w=(o-r[1][v])/(r[1][b]-r[1][v]),A=(s-r[2][m])/(r[2][x]-r[2][m]);(_<0||_>1||isNaN(_))&&(_=0),(w<0||w>1||isNaN(w))&&(w=0),(A<0||A>1||isNaN(A))&&(A=0);var M=m*h*d,T=x*h*d,k=v*h,E=b*h,S=g,L=y,C=e[k+M+S],O=e[k+M+L],R=e[E+M+S],P=e[E+M+L],z=e[k+T+S],I=e[k+T+L],N=e[E+T+S],D=e[E+T+L],F=n.create();return n.lerp(F,C,O,_),n.lerp(u,R,P,_),n.lerp(F,F,u,w),n.lerp(u,z,I,_),n.lerp(c,N,D,_),n.lerp(u,u,c,w),n.lerp(F,F,u,A),F},d=function(t){var e=1/0;t.sort(function(t,e){return t-e});for(var r=1;r=f&&r<=g&&n>=h&&n<=v&&i>=p&&i<=m},b=10*n.distance(e[0],e[1])/i,x=b*b,_=1,w=0;n.create();r.length>=2&&(_=function(t){for(var e=[],r=[],n=[],i={},a={},o={},s=0;sw&&!isNaN(z)&&isFinite(z)&&(w=z),L.push(z),c.push({points:T,velocities:k,divergences:L});for(var O=0;O<100*i&&T.lengthx&&n.scale(R,R,b/Math.sqrt(P)),n.add(R,R,M),E=t.getVelocity(R),n.squaredDistance(S,R)-x>-1e-4*x){T.push(R),S=R,k.push(E);C=t.getDivergence(R,E);(z=n.length(C))>w&&!isNaN(z)&&isFinite(z)&&(w=z),L.push(z)}M=R}}for(A=0;A max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color \u2014 in vertex or in fragment\n vec4 surfaceColor =\n step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) +\n step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]),s=i(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform vec3 objectOffset;\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n worldCoordinate = objectOffset + dataCoordinate;\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z += zOffset;\n\n gl_Position = clipPosition;\n value = f + objectOffset.z;\n kill = -1.0;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]),l=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]);r.createShader=function(t){var e=n(t,a,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,a,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,s,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,s,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":148,glslify:249}],162:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=y(e),n=x(e),s=b(e),l=_(e),u=i(e),c=a(e,[{buffer:u,size:4,stride:w,offset:0},{buffer:u,size:3,stride:w,offset:16},{buffer:u,size:3,stride:w,offset:28}]),f=i(e),h=a(e,[{buffer:f,size:4,stride:20,offset:0},{buffer:f,size:1,stride:20,offset:16}]),d=i(e),p=a(e,[{buffer:d,size:2,type:e.FLOAT}]),g=o(e,1,E,e.RGBA,e.UNSIGNED_BYTE);g.minFilter=e.LINEAR,g.magFilter=e.LINEAR;var v=new S(e,[0,0],[[0,0,0],[0,0,0]],r,n,u,c,g,s,l,f,h,d,p,[0,0,0]),m={levels:[[],[],[]]};for(var A in t)m[A]=t[A];return m.colormap=m.colormap||"jet",v.update(m),v};var n=t("bit-twiddle"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("typedarray-pool"),l=t("colormap"),u=t("ndarray-ops"),c=t("ndarray-pack"),f=t("ndarray"),h=t("surface-nets"),d=t("gl-mat4/multiply"),p=t("gl-mat4/invert"),g=t("binary-search-bounds"),v=t("ndarray-gradient"),m=t("./lib/shaders"),y=m.createShader,b=m.createContourShader,x=m.createPickShader,_=m.createPickContourShader,w=40,A=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],M=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],T=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];function k(t,e,r,n,i){this.position=t,this.index=e,this.uv=r,this.level=n,this.dataCoordinate=i}!function(){for(var t=0;t<3;++t){var e=T[t],r=(t+2)%3;e[(t+1)%3+0]=1,e[r+3]=1,e[t+6]=1}}();var E=256;function S(t,e,r,n,i,a,o,l,u,c,h,d,p,g,v){this.gl=t,this.shape=e,this.bounds=r,this.objectOffset=v,this.intensityBounds=[],this._shader=n,this._pickShader=i,this._coordinateBuffer=a,this._vao=o,this._colorMap=l,this._contourShader=u,this._contourPickShader=c,this._contourBuffer=h,this._contourVAO=d,this._contourOffsets=[[],[],[]],this._contourCounts=[[],[],[]],this._vertexCount=0,this._pickResult=new k([0,0,0],[0,0],[0,0],[0,0,0],[0,0,0]),this._dynamicBuffer=p,this._dynamicVAO=g,this._dynamicOffsets=[0,0,0],this._dynamicCounts=[0,0,0],this.contourWidth=[1,1,1],this.contourLevels=[[1],[1],[1]],this.contourTint=[0,0,0],this.contourColor=[[.5,.5,.5,1],[.5,.5,.5,1],[.5,.5,.5,1]],this.showContour=!0,this.showSurface=!0,this.enableHighlight=[!0,!0,!0],this.highlightColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.highlightTint=[1,1,1],this.highlightLevel=[-1,-1,-1],this.enableDynamic=[!0,!0,!0],this.dynamicLevel=[NaN,NaN,NaN],this.dynamicColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.dynamicTint=[1,1,1],this.dynamicWidth=[1,1,1],this.axesBounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.surfaceProject=[!1,!1,!1],this.contourProject=[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],this.colorBounds=[!1,!1],this._field=[f(s.mallocFloat(1024),[0,0]),f(s.mallocFloat(1024),[0,0]),f(s.mallocFloat(1024),[0,0])],this.pickId=1,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.snapToData=!1,this.opacity=1,this.lightPosition=[10,1e4,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.vertexColor=0,this.dirty=!0}var L=S.prototype;L.isTransparent=function(){return this.opacity<1},L.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;t<3;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},L.pickSlots=1,L.setPickBase=function(t){this.pickId=t};var C=[0,0,0],O={showSurface:!1,showContour:!1,projections:[A.slice(),A.slice(),A.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]};function R(t,e){var r,n,i,a=e.axes&&e.axes.lastCubeProps.axis||C,o=e.showSurface,s=e.showContour;for(r=0;r<3;++r)for(o=o||e.surfaceProject[r],n=0;n<3;++n)s=s||e.contourProject[r][n];for(r=0;r<3;++r){var l=O.projections[r];for(n=0;n<16;++n)l[n]=0;for(n=0;n<4;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],d(l,t.model,l);var u=O.clipBounds[r];for(i=0;i<2;++i)for(n=0;n<3;++n)u[i][n]=t.clipBounds[i][n];u[0][r]=-1e8,u[1][r]=1e8}return O.showSurface=o,O.showContour=s,O}var P={model:A,view:A,projection:A,inverseModel:A.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,objectOffset:[0,0,0],kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1,vertexColor:0},z=A.slice(),I=[1,0,0,0,1,0,0,0,1];function N(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=P;n.model=t.model||A,n.view=t.view||A,n.projection=t.projection||A,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.objectOffset=this.objectOffset,n.contourColor=this.contourColor[0],n.inverseModel=p(n.inverseModel,n.model);for(var i=0;i<2;++i)for(var a=n.clipBounds[i],o=0;o<3;++o)a[o]=Math.min(Math.max(this.clipBounds[i][o],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=I,n.vertexColor=this.vertexColor;var s=z;for(d(s,n.view,n.model),d(s,n.projection,s),p(s,s),i=0;i<3;++i)n.eyePosition[i]=s[12+i]/s[15];var l=s[15];for(i=0;i<3;++i)l+=this.lightPosition[i]*s[4*i+3];for(i=0;i<3;++i){var u=s[12+i];for(o=0;o<3;++o)u+=s[4*o+i]*this.lightPosition[o];n.lightPosition[i]=u/l}var c=R(n,this);if(c.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;i<3;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=c.projections[i],this._shader.uniforms.clipBounds=c.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(c.showContour&&!e){var f=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,f.bind(),f.uniforms=n;var h=this._contourVAO;for(h.bind(),i=0;i<3;++i)for(f.uniforms.permutation=T[i],r.lineWidth(this.contourWidth[i]),o=0;o>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var u=r.position;u[0]=u[1]=u[2]=0;for(var c=0;c<2;++c)for(var f=c?a:1-a,h=0;h<2;++h)for(var d=i+c,p=s+h,v=f*(h?l:1-l),m=0;m<3;++m)u[m]+=this._field[m].get(d,p)*v;for(var y=this._pickResult.level,b=0;b<3;++b)if(y[b]=g.le(this.contourLevels[b],u[b]),y[b]<0)this.contourLevels[b].length>0&&(y[b]=0);else if(y[b]Math.abs(_-u[b])&&(y[b]+=1)}for(r.index[0]=a<.5?i:i+1,r.index[1]=l<.5?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;m<3;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},L.padField=function(t,e){var r=e.shape.slice(),n=t.shape.slice();u.assign(t.lo(1,1).hi(r[0],r[1]),e),u.assign(t.lo(1).hi(r[0],1),e.hi(r[0],1)),u.assign(t.lo(1,n[1]-1).hi(r[0],1),e.lo(0,r[1]-1).hi(r[0],1)),u.assign(t.lo(0,1).hi(1,r[1]),e.hi(1)),u.assign(t.lo(n[0]-1,1).hi(1,r[1]),e.lo(r[0]-1)),t.set(0,0,e.get(0,0)),t.set(0,n[1]-1,e.get(0,r[1]-1)),t.set(n[0]-1,0,e.get(r[0]-1,0)),t.set(n[0]-1,n[1]-1,e.get(r[0]-1,r[1]-1))},L.update=function(t){t=t||{},this.objectOffset=t.objectOffset||this.objectOffset,this.dirty=!0,"contourWidth"in t&&(this.contourWidth=F(t.contourWidth,Number)),"showContour"in t&&(this.showContour=F(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=F(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=B(t.contourColor)),"contourProject"in t&&(this.contourProject=F(t.contourProject,function(t){return F(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=B(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=F(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=F(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds),"vertexColor"in t&&(this.vertexColor=t.vertexColor?1:0);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var i=(e.shape[0]+2)*(e.shape[1]+2);i>this._field[2].data.length&&(s.freeFloat(this._field[2].data),this._field[2].data=s.mallocFloat(n.nextPow2(i))),this._field[2]=f(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),this.padField(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;o<2;++o)this._field[2].size>this._field[o].data.length&&(s.freeFloat(this._field[o].data),this._field[o].data=s.mallocFloat(this._field[2].size)),this._field[o]=f(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var d=t.coords;if(!Array.isArray(d)||3!==d.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;o<2;++o){var p=d[o];for(x=0;x<2;++x)if(p.shape[x]!==a[x])throw new Error("gl-surface: coords have incorrect shape");this.padField(this._field[o],p)}}else if(t.ticks){var g=t.ticks;if(!Array.isArray(g)||2!==g.length)throw new Error("gl-surface: invalid ticks");for(o=0;o<2;++o){var m=g[o];if((Array.isArray(m)||m.length)&&(m=f(m)),m.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var y=f(m.data,a);y.stride[o]=m.stride[0],y.stride[1^o]=0,this.padField(this._field[o],y)}}else{for(o=0;o<2;++o){var b=[0,0];b[o]=1,this._field[o]=f(this._field[o].data,[a[0]+2,a[1]+2],b,0)}this._field[0].set(0,0,0);for(var x=0;x0){for(var wt=0;wt<5;++wt)rt.pop();G-=1}continue t}rt.push(ot[0],ot[1],ut[0],ut[1],ot[2]),G+=1}}at.push(G)}this._contourOffsets[nt]=it,this._contourCounts[nt]=at}var At=s.mallocFloat(rt.length);for(o=0;os||o[1]<0||o[1]>s)throw new Error("gl-texture2d: Invalid texture size");var l=p(o,e.stride.slice()),u=0;"float32"===r?u=t.FLOAT:"float64"===r?(u=t.FLOAT,l=!1,r="float32"):"uint8"===r?u=t.UNSIGNED_BYTE:(u=t.UNSIGNED_BYTE,l=!1,r="uint8");var f,d,v=0;if(2===o.length)v=t.LUMINANCE,o=[o[0],o[1],1],e=n(e.data,o,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==o.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===o[2])v=t.ALPHA;else if(2===o[2])v=t.LUMINANCE_ALPHA;else if(3===o[2])v=t.RGB;else{if(4!==o[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}}u!==t.FLOAT||t.getExtension("OES_texture_float")||(u=t.UNSIGNED_BYTE,l=!1);var m=e.size;if(l)f=0===e.offset&&e.data.length===m?e.data:e.data.subarray(e.offset,e.offset+m);else{var y=[o[2],o[2]*o[0],1];d=a.malloc(m,r);var b=n(d,o,y,0);"float32"!==r&&"float64"!==r||u!==t.UNSIGNED_BYTE?i.assign(b,e):c(b,e),f=d.subarray(0,m)}var x=g(t);t.texImage2D(t.TEXTURE_2D,0,v,o[0],o[1],0,v,u,f),l||a.free(d);return new h(t,x,o[0],o[1],v,u)}(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")};var o=null,s=null,l=null;function u(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement||"undefined"!=typeof ImageData&&t instanceof ImageData}var c=function(t,e){i.muls(t,e,255)};function f(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(e<0||e>i||r<0||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function h(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}var d=h.prototype;function p(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function g(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function v(t,e,r,n,i){var a=t.getParameter(t.MAX_TEXTURE_SIZE);if(e<0||e>a||r<0||r>a)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new h(t,o,e,r,n,i)}Object.defineProperties(d,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=this.gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;e<2;++e)if(l.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return f(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return f(this,t|=0,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t|=0,f(this,this._shape[0],t),t}}}),d.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},d.dispose=function(){this.gl.deleteTexture(this.handle)},d.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},d.setPixels=function(t,e,r,o){var s=this.gl;this.bind(),Array.isArray(e)?(o=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),o=o||0;var l=u(t)?t:t.raw;if(l){this._mipLevels.indexOf(o)<0?(s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,this.type,l),this._mipLevels.push(o)):s.texSubImage2D(s.TEXTURE_2D,o,e,r,this.format,this.type,l)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>o||r+t.shape[0]>this._shape[0]>>>o||e<0||r<0)throw new Error("gl-texture2d: Texture dimensions are out of bounds");!function(t,e,r,o,s,l,u,f){var h=f.dtype,d=f.shape.slice();if(d.length<2||d.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var g=0,v=0,m=p(d,f.stride.slice());"float32"===h?g=t.FLOAT:"float64"===h?(g=t.FLOAT,m=!1,h="float32"):"uint8"===h?g=t.UNSIGNED_BYTE:(g=t.UNSIGNED_BYTE,m=!1,h="uint8");if(2===d.length)v=t.LUMINANCE,d=[d[0],d[1],1],f=n(f.data,d,[f.stride[0],f.stride[1],1],f.offset);else{if(3!==d.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===d[2])v=t.ALPHA;else if(2===d[2])v=t.LUMINANCE_ALPHA;else if(3===d[2])v=t.RGB;else{if(4!==d[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}d[2]}v!==t.LUMINANCE&&v!==t.ALPHA||s!==t.LUMINANCE&&s!==t.ALPHA||(v=s);if(v!==s)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=f.size,b=u.indexOf(o)<0;b&&u.push(o);if(g===l&&m)0===f.offset&&f.data.length===y?b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,f.data):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,f.data):b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,f.data.subarray(f.offset,f.offset+y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,f.data.subarray(f.offset,f.offset+y));else{var x;x=l===t.FLOAT?a.mallocFloat32(y):a.mallocUint8(y);var _=n(x,d,[d[2],d[2]*d[0],1]);g===t.FLOAT&&l===t.UNSIGNED_BYTE?c(_,f):i.assign(_,f),b?t.texImage2D(t.TEXTURE_2D,o,s,d[0],d[1],0,s,l,x.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,d[0],d[1],s,l,x.subarray(0,y)),l===t.FLOAT?a.freeFloat32(x):a.freeUint8(x)}}(s,e,r,o,this.format,this.type,this._mipLevels,t)}}},{ndarray:285,"ndarray-ops":279,"typedarray-pool":347}],164:[function(t,e,r){"use strict";e.exports=function(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;i1?0:Math.acos(s)};var n=t("./fromValues"),i=t("./normalize"),a=t("./dot")},{"./dot":179,"./fromValues":185,"./normalize":196}],170:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}},{}],171:[function(t,e,r){e.exports=function(t){var e=new Float32Array(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}},{}],172:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}},{}],173:[function(t,e,r){e.exports=function(){var t=new Float32Array(3);return t[0]=0,t[1]=0,t[2]=0,t}},{}],174:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}},{}],175:[function(t,e,r){e.exports=t("./distance")},{"./distance":176}],176:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}},{}],177:[function(t,e,r){e.exports=t("./divide")},{"./divide":178}],178:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}},{}],179:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}},{}],180:[function(t,e,r){e.exports=1e-6},{}],181:[function(t,e,r){e.exports=function(t,e){var r=t[0],i=t[1],a=t[2],o=e[0],s=e[1],l=e[2];return Math.abs(r-o)<=n*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-l)<=n*Math.max(1,Math.abs(a),Math.abs(l))};var n=t("./epsilon")},{"./epsilon":180}],182:[function(t,e,r){e.exports=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}},{}],183:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}},{}],184:[function(t,e,r){e.exports=function(t,e,r,i,a,o){var s,l;e||(e=3);r||(r=0);l=i?Math.min(i*e+r,t.length):t.length;for(s=r;s0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a);return t}},{}],197:[function(t,e,r){e.exports=function(t,e){e=e||1;var r=2*Math.random()*Math.PI,n=2*Math.random()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t}},{}],198:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[1],a=r[2],o=e[1]-i,s=e[2]-a,l=Math.sin(n),u=Math.cos(n);return t[0]=e[0],t[1]=i+o*u-s*l,t[2]=a+o*l+s*u,t}},{}],199:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[2],o=e[0]-i,s=e[2]-a,l=Math.sin(n),u=Math.cos(n);return t[0]=i+s*l+o*u,t[1]=e[1],t[2]=a+s*u-o*l,t}},{}],200:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[1],o=e[0]-i,s=e[1]-a,l=Math.sin(n),u=Math.cos(n);return t[0]=i+o*u-s*l,t[1]=a+o*l+s*u,t[2]=e[2],t}},{}],201:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}},{}],202:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}},{}],203:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}},{}],204:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}},{}],205:[function(t,e,r){e.exports=t("./squaredDistance")},{"./squaredDistance":207}],206:[function(t,e,r){e.exports=t("./squaredLength")},{"./squaredLength":208}],207:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}},{}],208:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}},{}],209:[function(t,e,r){e.exports=t("./subtract")},{"./subtract":210}],210:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}},{}],211:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}},{}],212:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t}},{}],213:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],u=r[3],c=u*n+s*a-l*i,f=u*i+l*n-o*a,h=u*a+o*i-s*n,d=-o*n-s*i-l*a;return t[0]=c*u+d*-o+f*-l-h*-s,t[1]=f*u+d*-s+h*-o-c*-l,t[2]=h*u+d*-l+c*-s-f*-o,t}},{}],214:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}},{}],215:[function(t,e,r){e.exports=function(t){var e=new Float32Array(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}},{}],216:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}},{}],217:[function(t,e,r){e.exports=function(){var t=new Float32Array(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}},{}],218:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+a*a)}},{}],219:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}},{}],220:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}},{}],221:[function(t,e,r){e.exports=function(t,e,r,n){var i=new Float32Array(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i}},{}],222:[function(t,e,r){e.exports={create:t("./create"),clone:t("./clone"),fromValues:t("./fromValues"),copy:t("./copy"),set:t("./set"),add:t("./add"),subtract:t("./subtract"),multiply:t("./multiply"),divide:t("./divide"),min:t("./min"),max:t("./max"),scale:t("./scale"),scaleAndAdd:t("./scaleAndAdd"),distance:t("./distance"),squaredDistance:t("./squaredDistance"),length:t("./length"),squaredLength:t("./squaredLength"),negate:t("./negate"),inverse:t("./inverse"),normalize:t("./normalize"),dot:t("./dot"),lerp:t("./lerp"),random:t("./random"),transformMat4:t("./transformMat4"),transformQuat:t("./transformQuat")}},{"./add":214,"./clone":215,"./copy":216,"./create":217,"./distance":218,"./divide":219,"./dot":220,"./fromValues":221,"./inverse":223,"./length":224,"./lerp":225,"./max":226,"./min":227,"./multiply":228,"./negate":229,"./normalize":230,"./random":231,"./scale":232,"./scaleAndAdd":233,"./set":234,"./squaredDistance":235,"./squaredLength":236,"./subtract":237,"./transformMat4":238,"./transformQuat":239}],223:[function(t,e,r){e.exports=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}},{}],224:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}},{}],225:[function(t,e,r){e.exports=function(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t[3]=s+n*(r[3]-s),t}},{}],226:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}},{}],227:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}},{}],228:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}},{}],229:[function(t,e,r){e.exports=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}},{}],230:[function(t,e,r){e.exports=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=a*o);return t}},{}],231:[function(t,e,r){var n=t("./normalize"),i=t("./scale");e.exports=function(t,e){return e=e||1,t[0]=Math.random(),t[1]=Math.random(),t[2]=Math.random(),t[3]=Math.random(),n(t,t),i(t,t,e),t}},{"./normalize":230,"./scale":232}],232:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}},{}],233:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}},{}],234:[function(t,e,r){e.exports=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}},{}],235:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a}},{}],236:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}},{}],237:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}},{}],238:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}},{}],239:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],u=r[3],c=u*n+s*a-l*i,f=u*i+l*n-o*a,h=u*a+o*i-s*n,d=-o*n-s*i-l*a;return t[0]=c*u+d*-o+f*-l-h*-s,t[1]=f*u+d*-s+h*-o-c*-l,t[2]=h*u+d*-l+c*-s-f*-o,t[3]=e[3],t}},{}],240:[function(t,e,r){e.exports=function(t,e,r,a){return n[0]=a,n[1]=r,n[2]=e,n[3]=t,i[0]};var n=new Uint8Array(4),i=new Float32Array(n.buffer)},{}],241:[function(t,e,r){var n=t("glsl-tokenizer"),i=t("atob-lite");e.exports=function(t){for(var e=Array.isArray(t)?t:n(t),r=0;r0)continue;r=t.slice(0,1).join("")}return D(r),O+=r.length,(E=E.slice(r.length)).length}}function q(){return/[^a-fA-F0-9]/.test(e)?(D(E.join("")),k=l,M):(E.push(e),r=e,M+1)}function G(){return"."===e?(E.push(e),k=g,r=e,M+1):/[eE]/.test(e)?(E.push(e),k=g,r=e,M+1):"x"===e&&1===E.length&&"0"===E[0]?(k=_,E.push(e),r=e,M+1):/[^\d]/.test(e)?(D(E.join("")),k=l,M):(E.push(e),r=e,M+1)}function X(){return"f"===e&&(E.push(e),r=e,M+=1),/[eE]/.test(e)?(E.push(e),r=e,M+1):"-"===e&&/[eE]/.test(r)?(E.push(e),r=e,M+1):/[^\d]/.test(e)?(D(E.join("")),k=l,M):(E.push(e),r=e,M+1)}function W(){if(/[^\d\w_]/.test(e)){var t=E.join("");return k=N.indexOf(t)>-1?y:I.indexOf(t)>-1?m:v,D(E.join("")),k=l,M}return E.push(e),r=e,M+1}};var n=t("./lib/literals"),i=t("./lib/operators"),a=t("./lib/builtins"),o=t("./lib/literals-300es"),s=t("./lib/builtins-300es"),l=999,u=9999,c=0,f=1,h=2,d=3,p=4,g=5,v=6,m=7,y=8,b=9,x=10,_=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":244,"./lib/builtins-300es":243,"./lib/literals":246,"./lib/literals-300es":245,"./lib/operators":247}],243:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":244}],244:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],245:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":246}],246:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],247:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],248:[function(t,e,r){var n=t("./index");e.exports=function(t,e){var r=n(e),i=[];return i=(i=i.concat(r(t))).concat(r(null))}},{"./index":242}],249:[function(t,e,r){e.exports=function(t){"string"==typeof t&&(t=[t]);for(var e=[].slice.call(arguments,1),r=[],n=0;n>1,c=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+t[e+f],f+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=n;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),a-=u}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,u=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*g}},{}],253:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(r<=i)throw new Error("Must input at least d+1 points");var o=t.slice(0,i+1),s=n.apply(void 0,o);if(0===s)throw new Error("Input not in general position");for(var l=new Array(i+1),c=0;c<=i;++c)l[c]=c;s<0&&(l[0]=1,l[1]=0);for(var f=new a(l,new Array(i+1),!1),h=f.adjacent,d=new Array(i+2),c=0;c<=i;++c){for(var p=l.slice(),g=0;g<=i;++g)g===c&&(p[g]=-1);var v=p[0];p[0]=p[1],p[1]=v;var m=new a(p,new Array(i+1),!0);h[c]=m,d[c]=m}d[i+1]=f;for(var c=0;c<=i;++c)for(var p=h[c].vertices,y=h[c].adjacent,g=0;g<=i;++g){var b=p[g];if(b<0)y[g]=f;else for(var x=0;x<=i;++x)h[x].vertices.indexOf(b)<0&&(y[g]=h[x])}for(var _=new u(i,o,d),w=!!e,c=i+1;c0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var i=new Function("test",e.join("")),a=n[t+1];return a||(a=n),i(a)}(t)),this.orient=a}var c=u.prototype;c.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){(t=o.pop()).vertices;for(var s=t.adjacent,l=0;l<=r;++l){var u=s[l];if(u.boundary&&!(u.lastVisited<=-n)){for(var c=u.vertices,f=0;f<=r;++f){var h=c[f];i[f]=h<0?e:a[h]}var d=this.orient();if(d>0)return u;u.lastVisited=-n,0===d&&o.push(u)}}}return null},c.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,u=s.adjacent,c=0;c<=n;++c)a[c]=i[l[c]];s.lastVisited=r;for(c=0;c<=n;++c){var f=u[c];if(!(f.lastVisited>=r)){var h=a[c];a[c]=t;var d=this.orient();if(a[c]=h,d<0){s=f;continue t}f.boundary?f.lastVisited=-r:f.lastVisited=r}}return}return s},c.addPeaks=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,l=this.tuple,u=this.interior,c=this.simplices,f=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,u.push(e);for(var h=[];f.length>0;){var d=(e=f.pop()).vertices,p=e.adjacent,g=d.indexOf(r);if(!(g<0))for(var v=0;v<=n;++v)if(v!==g){var m=p[v];if(m.boundary&&!(m.lastVisited>=r)){var y=m.vertices;if(m.lastVisited!==-r){for(var b=0,x=0;x<=n;++x)y[x]<0?(b=x,l[x]=t):l[x]=i[y[x]];if(this.orient()>0){y[b]=r,m.boundary=!1,u.push(m),f.push(m),m.lastVisited=r;continue}m.lastVisited=-r}var _=m.adjacent,w=d.slice(),A=p.slice(),M=new a(w,A,!0);c.push(M);var T=_.indexOf(e);if(!(T<0)){_[T]=M,A[g]=m,w[v]=-1,A[v]=e,p[v]=M,M.flip();for(x=0;x<=n;++x){var k=w[x];if(!(k<0||k===r)){for(var E=new Array(n-1),S=0,L=0;L<=n;++L){var C=w[L];C<0||L===x||(E[S++]=C)}h.push(new o(E,M,x))}}}}}}h.sort(s);for(v=0;v+1=0?o[l++]=s[c]:u=1&c;if(u===(1&t)){var f=o[0];o[0]=o[1],o[1]=f}e.push(o)}}return e}},{"robust-orientation":321,"simplicial-complex":331}],254:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=0,a=1;function o(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}e.exports=function(t){if(!t||0===t.length)return new b(null);return new b(y(t))};var s=o.prototype;function l(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function u(t,e){var r=y(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function c(t,e){var r=t.intervals([]);r.push(e),u(t,r)}function f(t,e){var r=t.intervals([]),n=r.indexOf(e);return n<0?i:(r.splice(n,1),u(t,r),a)}function h(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function p(t,e){for(var r=0;r>1],i=[],a=[],s=[];for(r=0;r3*(e+1)?c(this,t):this.left.insert(t):this.left=y([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?c(this,t):this.right.insert(t):this.right=y([t]);else{var r=n.ge(this.leftPoints,t,v),i=n.ge(this.rightPoints,t,m);this.leftPoints.splice(r,0,t),this.rightPoints.splice(i,0,t)}},s.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1)?f(this,t):2===(u=this.left.remove(t))?(this.left=null,this.count-=1,a):(u===a&&(this.count-=1),u):i;if(t[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(e-1)?f(this,t):2===(u=this.right.remove(t))?(this.right=null,this.count-=1,a):(u===a&&(this.count-=1),u):i;if(1===this.count)return this.leftPoints[0]===t?2:i;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var r=this,o=this.left;o.right;)r=o,o=o.right;if(r===this)o.right=this.right;else{var s=this.left,u=this.right;r.count-=o.count,r.right=o.left,o.left=s,o.right=u}l(this,o),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?l(this,this.left):l(this,this.right);return a}for(s=n.ge(this.leftPoints,t,v);sthis.mid){var r;if(this.right)if(r=this.right.queryPoint(t,e))return r;return d(this.rightPoints,t,e)}return p(this.leftPoints,e)},s.queryInterval=function(t,e,r){var n;if(tthis.mid&&this.right&&(n=this.right.queryInterval(t,e,r)))return n;return ethis.mid?d(this.rightPoints,t,r):p(this.leftPoints,r)};var x=b.prototype;x.insert=function(t){this.root?this.root.insert(t):this.root=new o(t[0],null,null,[t],[t])},x.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),e!==i}return!1},x.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},x.queryInterval=function(t,e,r){if(t<=e&&this.root)return this.root.queryInterval(t,e,r)},Object.defineProperty(x,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(x,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":36}],255:[function(t,e,r){"use strict";e.exports=function(t,e){e=e||new Array(t.length);for(var r=0;r13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],262:[function(t,e,r){e.exports=function(t,e,r){return t*(1-r)+e*r}},{}],263:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1<d[1][2]&&(m[0]=-m[0]),d[0][2]>d[2][0]&&(m[1]=-m[1]),d[1][0]>d[0][1]&&(m[2]=-m[2]),!0}},{"./normalize":265,"gl-mat4/clone":119,"gl-mat4/create":120,"gl-mat4/determinant":121,"gl-mat4/invert":125,"gl-mat4/transpose":135,"gl-vec3/cross":174,"gl-vec3/dot":179,"gl-vec3/length":189,"gl-vec3/normalize":196}],265:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;i<16;i++)t[i]=e[i]*n;return!0}},{}],266:[function(t,e,r){var n=t("gl-vec3/lerp"),i=t("mat4-recompose"),a=t("mat4-decompose"),o=t("gl-mat4/determinant"),s=t("quat-slerp"),l=f(),u=f(),c=f();function f(){return{translate:h(),scale:h(1),skew:h(),perspective:[0,0,0,1],quaternion:[0,0,0,1]}}function h(t){return[t||0,t||0,t||0]}e.exports=function(t,e,r,f){if(0===o(e)||0===o(r))return!1;var h=a(e,l.translate,l.scale,l.skew,l.perspective,l.quaternion),d=a(r,u.translate,u.scale,u.skew,u.perspective,u.quaternion);return!(!h||!d||(n(c.translate,l.translate,u.translate,f),n(c.skew,l.skew,u.skew,f),n(c.scale,l.scale,u.scale,f),n(c.perspective,l.perspective,u.perspective,f),s(c.quaternion,l.quaternion,u.quaternion,f),i(t,c.translate,c.scale,c.skew,c.perspective,c.quaternion),0))}},{"gl-mat4/determinant":121,"gl-vec3/lerp":190,"mat4-decompose":264,"mat4-recompose":267,"quat-slerp":308}],267:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":120,"gl-mat4/fromRotationTranslation":123,"gl-mat4/identity":124,"gl-mat4/multiply":127,"gl-mat4/scale":133,"gl-mat4/translate":134}],268:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=t("mat4-interpolate"),a=t("gl-mat4/invert"),o=t("gl-mat4/rotateX"),s=t("gl-mat4/rotateY"),l=t("gl-mat4/rotateZ"),u=t("gl-mat4/lookAt"),c=t("gl-mat4/translate"),f=(t("gl-mat4/scale"),t("gl-vec3/normalize")),h=[0,0,0];function d(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-1/0,1/0]}e.exports=function(t){return new d((t=t||{}).matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])};var p=d.prototype;p.recalcMatrix=function(t){var e=this._time,r=n.le(e,t),o=this.computedMatrix;if(!(r<0)){var s=this._components;if(r===e.length-1)for(var l=16*r,u=0;u<16;++u)o[u]=s[l++];else{var c=e[r+1]-e[r],h=(l=16*r,this.prevMatrix),d=!0;for(u=0;u<16;++u)h[u]=s[l++];var p=this.nextMatrix;for(u=0;u<16;++u)p[u]=s[l++],d=d&&h[u]===p[u];if(c<1e-6||d)for(u=0;u<16;++u)o[u]=h[u];else i(o,h,p,(t-e[r])/c)}var g=this.computedUp;g[0]=o[1],g[1]=o[5],g[2]=o[9],f(g,g);var v=this.computedInverse;a(v,o);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;var b=this.computedCenter,x=Math.exp(this.computedRadius[0]);for(u=0;u<3;++u)b[u]=m[u]-o[2+4*u]*x}},p.idle=function(t){if(!(t1&&n(t[o[c-2]],t[o[c-1]],u)<=0;)c-=1,o.pop();for(o.push(l),c=s.length;c>1&&n(t[s[c-2]],t[s[c-1]],u)>=0;)c-=1,s.pop();s.push(l)}for(var r=new Array(s.length+o.length-2),f=0,i=0,h=o.length;i0;--d)r[f++]=s[d];return r};var n=t("robust-orientation")[3]},{"robust-orientation":321}],270:[function(t,e,r){"use strict";e.exports=function(t,e){e||(e=t,t=window);var r=0,i=0,a=0,o={shift:!1,alt:!1,control:!1,meta:!1},s=!1;function l(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==o.alt,o.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==o.shift,o.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==o.control,o.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==o.meta,o.meta=!!t.metaKey),e}function u(t,s){var u=n.x(s),c=n.y(s);"buttons"in s&&(t=0|s.buttons),(t!==r||u!==i||c!==a||l(s))&&(r=0|t,i=u||0,a=c||0,e&&e(r,i,a,o))}function c(t){u(0,t)}function f(){(r||i||a||o.shift||o.alt||o.meta||o.control)&&(i=a=0,r=0,o.shift=o.alt=o.control=o.meta=!1,e&&e(0,0,0,o))}function h(t){l(t)&&e&&e(r,i,a,o)}function d(t){0===n.buttons(t)?u(0,t):u(r,t)}function p(t){u(r|n.buttons(t),t)}function g(t){u(r&~n.buttons(t),t)}function v(){s||(s=!0,t.addEventListener("mousemove",d),t.addEventListener("mousedown",p),t.addEventListener("mouseup",g),t.addEventListener("mouseleave",c),t.addEventListener("mouseenter",c),t.addEventListener("mouseout",c),t.addEventListener("mouseover",c),t.addEventListener("blur",f),t.addEventListener("keyup",h),t.addEventListener("keydown",h),t.addEventListener("keypress",h),t!==window&&(window.addEventListener("blur",f),window.addEventListener("keyup",h),window.addEventListener("keydown",h),window.addEventListener("keypress",h)))}v();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return s},set:function(e){e?v():s&&(s=!1,t.removeEventListener("mousemove",d),t.removeEventListener("mousedown",p),t.removeEventListener("mouseup",g),t.removeEventListener("mouseleave",c),t.removeEventListener("mouseenter",c),t.removeEventListener("mouseout",c),t.removeEventListener("mouseover",c),t.removeEventListener("blur",f),t.removeEventListener("keyup",h),t.removeEventListener("keydown",h),t.removeEventListener("keypress",h),t!==window&&(window.removeEventListener("blur",f),window.removeEventListener("keyup",h),window.removeEventListener("keydown",h),window.removeEventListener("keypress",h)))},enumerable:!0},buttons:{get:function(){return r},enumerable:!0},x:{get:function(){return i},enumerable:!0},y:{get:function(){return a},enumerable:!0},mods:{get:function(){return o},enumerable:!0}}),m};var n=t("mouse-event")},{"mouse-event":272}],271:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var i=t.clientX||0,a=t.clientY||0,o=(s=e,s===window||s===document||s===document.body?n:s.getBoundingClientRect());var s;return r[0]=i-o.left,r[1]=a-o.top,r}},{}],272:[function(t,e,r){"use strict";function n(t){return t.target||t.srcElement||window}r.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){if(2===(e=t.which))return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1< 0");"function"!=typeof t.vertex&&e("Must specify vertex creation function");"function"!=typeof t.cell&&e("Must specify cell creation function");"function"!=typeof t.phase&&e("Must specify phase function");for(var S=t.getters||[],L=new Array(k),C=0;C=0?L[C]=!0:L[C]=!1;return function(t,e,r,k,E,S){var L=S.length,C=E.length;if(C<2)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var O="extractContour"+E.join("_"),R=[],P=[],z=[],I=0;I0&&j.push(l(I,E[N-1])+"*"+s(E[N-1])),P.push(p(I,E[N])+"=("+j.join("-")+")|0")}for(var I=0;I=0;--I)B.push(s(E[I]));P.push(w+"=("+B.join("*")+")|0",x+"=mallocUint32("+w+")",b+"=mallocUint32("+w+")",A+"=0"),P.push(g(0)+"=0");for(var N=1;N<1<0;M=M-1&p)w.push(b+"["+A+"+"+m(M)+"]");w.push(y(0));for(var M=0;M=0;--e)G(e,0);for(var r=[],e=0;e0){",d(E[e]),"=1;");t(e-1,r|1<=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),a.push("1"),o.push("s["+l+"]-2"));var u=".lo("+a.join()+").hi("+o.join()+")";if(0===a.length&&(u=""),i>0){n.push("if(1");for(var l=0;l=0||e.indexOf(-(l+1))>=0||n.push("&&s[",l,"]>2");n.push("){grad",i,"(src.pick(",s.join(),")",u);for(var l=0;l=0||e.indexOf(-(l+1))>=0||n.push(",dst.pick(",s.join(),",",l,")",u);n.push(");")}for(var l=0;l1){dst.set(",s.join(),",",c,",0.5*(src.get(",h.join(),")-src.get(",d.join(),")))}else{dst.set(",s.join(),",",c,",0)};"):n.push("if(s[",c,"]>1){diff(",f,",src.pick(",h.join(),")",u,",src.pick(",d.join(),")",u,");}else{zero(",f,");};");break;case"mirror":0===i?n.push("dst.set(",s.join(),",",c,",0);"):n.push("zero(",f,");");break;case"wrap":var p=s.slice(),g=s.slice();e[l]<0?(p[c]="s["+c+"]-2",g[c]="0"):(p[c]="s["+c+"]-1",g[c]="1"),0===i?n.push("if(s[",c,"]>2){dst.set(",s.join(),",",c,",0.5*(src.get(",p.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",c,",0)};"):n.push("if(s[",c,"]>2){diff(",f,",src.pick(",p.join(),")",u,",src.pick(",g.join(),")",u,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}i>0&&n.push("};")}for(var s=0;s<1<>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in l){var e=l[t];r[t]=o({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var c=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=n({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=n({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=n({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=n({args:["array","array"],pre:i,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":78}],280:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var r=[],a=t,o=1;Array.isArray(a);)r.push(a.length),o*=a.length,a=a[0];return 0===r.length?n():(e||(e=n(new Float64Array(o),r)),i(e,t),e)}},{"./doConvert.js":281,ndarray:285}],281:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":78}],282:[function(t,e,r){"use strict";var n=t("typedarray-pool"),i=32;function a(t){switch(t){case"uint8":return[n.mallocUint8,n.freeUint8];case"uint16":return[n.mallocUint16,n.freeUint16];case"uint32":return[n.mallocUint32,n.freeUint32];case"int8":return[n.mallocInt8,n.freeInt8];case"int16":return[n.mallocInt16,n.freeInt16];case"int32":return[n.mallocInt32,n.freeInt32];case"float32":return[n.mallocFloat,n.freeFloat];case"float64":return[n.mallocDouble,n.freeDouble];default:return null}}function o(t){for(var e=[],r=0;r0?s.push(["d",p,"=s",p,"-d",f,"*n",f].join("")):s.push(["d",p,"=s",p].join("")),f=p),0!=(d=t.length-1-l)&&(h>0?s.push(["e",d,"=s",d,"-e",h,"*n",h,",f",d,"=",u[d],"-f",h,"*n",h].join("")):s.push(["e",d,"=s",d,",f",d,"=",u[d]].join("")),h=d)}r.push("var "+s.join(","));var g=["0","n0-1","data","offset"].concat(o(t.length));r.push(["if(n0<=",i,"){","insertionSort(",g.join(","),")}else{","quickSort(",g.join(","),")}"].join("")),r.push("}return "+n);var v=new Function("insertionSort","quickSort",r.join("\n")),m=function(t,e){var r=["'use strict'"],n=["ndarrayInsertionSort",t.join("d"),e].join(""),i=["left","right","data","offset"].concat(o(t.length)),s=a(e),l=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var u=[],c=1;c1){for(r.push("dptr=0;sptr=ptr"),c=t.length-1;c>=0;--c)0!==(d=t[c])&&r.push(["for(i",d,"=0;i",d,"b){break __l}"].join("")),c=t.length-1;c>=1;--c)r.push("sptr+=e"+c,"dptr+=f"+c,"}");for(r.push("dptr=cptr;sptr=cptr-s0"),c=t.length-1;c>=0;--c)0!==(d=t[c])&&r.push(["for(i",d,"=0;i",d,"=0;--c)0!==(d=t[c])&&r.push(["for(i",d,"=0;i",d,"scratch)){",h("cptr",f("cptr-s0")),"cptr-=s0","}",h("cptr","scratch"));return r.push("}"),t.length>1&&s&&r.push("free(scratch)"),r.push("} return "+n),s?new Function("malloc","free",r.join("\n"))(s[0],s[1]):new Function(r.join("\n"))()}(t,e),y=function(t,e,r){var n=["'use strict'"],s=["ndarrayQuickSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(o(t.length)),u=a(e),c=0;n.push(["function ",s,"(",l.join(","),"){"].join(""));var f=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var h=[],d=1;d=0;--a)0!==(o=t[a])&&n.push(["for(i",o,"=0;i",o,"1)for(a=0;a1?n.push("ptr_shift+=d"+o):n.push("ptr0+=d"+o),n.push("}"))}}function y(e,r,i,a){if(1===r.length)n.push("ptr0="+p(r[0]));else{for(var o=0;o1)for(o=0;o=1;--o)i&&n.push("pivot_ptr+=f"+o),r.length>1?n.push("ptr_shift+=e"+o):n.push("ptr0+=e"+o),n.push("}")}function b(){t.length>1&&u&&n.push("free(pivot1)","free(pivot2)")}function x(e,r){var i="el"+e,a="el"+r;if(t.length>1){var o="__l"+ ++c;y(o,[i,a],!1,["comp=",g("ptr0"),"-",g("ptr1"),"\n","if(comp>0){tmp0=",i,";",i,"=",a,";",a,"=tmp0;break ",o,"}\n","if(comp<0){break ",o,"}"].join(""))}else n.push(["if(",g(p(i)),">",g(p(a)),"){tmp0=",i,";",i,"=",a,";",a,"=tmp0}"].join(""))}function _(e,r){t.length>1?m([e,r],!1,v("ptr0",g("ptr1"))):n.push(v(p(e),g(p(r))))}function w(e,r,i){if(t.length>1){var a="__l"+ ++c;y(a,[r],!0,[e,"=",g("ptr0"),"-pivot",i,"[pivot_ptr]\n","if(",e,"!==0){break ",a,"}"].join(""))}else n.push([e,"=",g(p(r)),"-pivot",i].join(""))}function A(e,r){t.length>1?m([e,r],!1,["tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1","tmp")].join("")):n.push(["ptr0=",p(e),"\n","ptr1=",p(r),"\n","tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1","tmp")].join(""))}function M(e,r,i){t.length>1?(m([e,r,i],!1,["tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1",g("ptr2")),"\n",v("ptr2","tmp")].join("")),n.push("++"+r,"--"+i)):n.push(["ptr0=",p(e),"\n","ptr1=",p(r),"\n","ptr2=",p(i),"\n","++",r,"\n","--",i,"\n","tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1",g("ptr2")),"\n",v("ptr2","tmp")].join(""))}function T(t,e){A(t,e),n.push("--"+e)}function k(e,r,i){t.length>1?m([e,r],!0,[v("ptr0",g("ptr1")),"\n",v("ptr1",["pivot",i,"[pivot_ptr]"].join(""))].join("")):n.push(v(p(e),g(p(r))),v(p(r),"pivot"+i))}function E(e,r){n.push(["if((",r,"-",e,")<=",i,"){\n","insertionSort(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}else{\n",s,"(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}"].join(""))}function S(e,r,i){t.length>1?(n.push(["__l",++c,":while(true){"].join("")),m([e],!0,["if(",g("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",c,"}"].join("")),n.push(i,"}")):n.push(["while(",g(p(e)),"===pivot",r,"){",i,"}"].join(""))}return n.push("var "+f.join(",")),x(1,2),x(4,5),x(1,3),x(2,3),x(1,4),x(3,4),x(2,5),x(2,3),x(4,5),t.length>1?m(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",g("ptr1"),"\n","pivot2[pivot_ptr]=",g("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",g("ptr0"),"\n","y=",g("ptr2"),"\n","z=",g("ptr4"),"\n",v("ptr5","x"),"\n",v("ptr6","y"),"\n",v("ptr7","z")].join("")):n.push(["pivot1=",g(p("el2")),"\n","pivot2=",g(p("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",g(p("el1")),"\n","y=",g(p("el3")),"\n","z=",g(p("el5")),"\n",v(p("index1"),"x"),"\n",v(p("index3"),"y"),"\n",v(p("index5"),"z")].join("")),_("index2","left"),_("index4","right"),n.push("if(pivots_are_equal){"),n.push("for(k=less;k<=great;++k){"),w("comp","k",1),n.push("if(comp===0){continue}"),n.push("if(comp<0){"),n.push("if(k!==less){"),A("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),n.push("while(true){"),w("comp","great",1),n.push("if(comp>0){"),n.push("great--"),n.push("}else if(comp<0){"),M("k","less","great"),n.push("break"),n.push("}else{"),T("k","great"),n.push("break"),n.push("}"),n.push("}"),n.push("}"),n.push("}"),n.push("}else{"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1<0){"),n.push("if(k!==less){"),A("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2>0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp>0){"),n.push("if(--greatindex5){"),S("less",1,"++less"),S("great",2,"--great"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1===0){"),n.push("if(k!==less){"),A("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2===0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp===0){"),n.push("if(--great1&&u?new Function("insertionSort","malloc","free",n.join("\n"))(r,u[0],u[1]):new Function("insertionSort",n.join("\n"))(r)}(t,e,m);return v(m,y)}},{"typedarray-pool":347}],283:[function(t,e,r){"use strict";var n=t("./lib/compile_sort.js"),i={};e.exports=function(t){var e=t.order,r=t.dtype,a=[e,r].join(":"),o=i[a];return o||(i[a]=o=n(e,r)),o(t),t}},{"./lib/compile_sort.js":282}],284:[function(t,e,r){"use strict";var n=t("ndarray-linear-interpolate"),i=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=new Array(_inline_39_arg4_)}",args:[{name:"_inline_39_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_39_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_39_arg2_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_39_arg3_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_39_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_40_arg2_(this_warped,_inline_40_arg0_),_inline_40_arg1_=_inline_40_arg3_.apply(void 0,this_warped)}",args:[{name:"_inline_40_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_40_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_40_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_40_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_40_arg4_",lvalue:!1,rvalue:!1,count:0}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warpND",blockSize:64}),a=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_43_arg2_(this_warped,_inline_43_arg0_),_inline_43_arg1_=_inline_43_arg3_(_inline_43_arg4_,this_warped[0])}",args:[{name:"_inline_43_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_43_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_43_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_43_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_43_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp1D",blockSize:64}),o=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_46_arg2_(this_warped,_inline_46_arg0_),_inline_46_arg1_=_inline_46_arg3_(_inline_46_arg4_,this_warped[0],this_warped[1])}",args:[{name:"_inline_46_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_46_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_46_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_46_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_46_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp2D",blockSize:64}),s=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_49_arg2_(this_warped,_inline_49_arg0_),_inline_49_arg1_=_inline_49_arg3_(_inline_49_arg4_,this_warped[0],this_warped[1],this_warped[2])}",args:[{name:"_inline_49_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_49_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_49_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_49_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_49_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp3D",blockSize:64});e.exports=function(t,e,r){switch(e.shape.length){case 1:a(t,r,n.d1,e);break;case 2:o(t,r,n.d2,e);break;case 3:s(t,r,n.d3,e);break;default:i(t,r,n.bind(void 0,e),e.shape.length)}return t}},{"cwise/lib/wrapper":81,"ndarray-linear-interpolate":278}],285:[function(t,e,r){var n=t("iota-array"),i=t("is-buffer"),a="undefined"!=typeof Float64Array;function o(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,r=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+l.join(",")+",v){"),i?a.push("return this.data.set("+c+",v)}"):a.push("return this.data["+c+"]=v}"),a.push("proto.get=function "+r+"_get("+l.join(",")+"){"),i?a.push("return this.data.get("+c+")}"):a.push("return this.data["+c+"]}"),a.push("proto.index=function "+r+"_index(",l.join(),"){return "+c+"}"),a.push("proto.hi=function "+r+"_hi("+l.join(",")+"){return new "+r+"(this.data,"+o.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+o.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var d=o.map(function(t){return"a"+t+"=this.shape["+t+"]"}),p=o.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+p.join(","));for(var g=0;g=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");a.push("return new "+r+"(this.data,"+o.map(function(t){return"a"+t}).join(",")+","+o.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+l.join(",")+"){var "+o.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+o.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(g=0;g=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");return a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+o.map(function(t){return"shape["+t+"]"}).join(",")+","+o.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",a.join("\n"))(u[t],s)}var u={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,r,n){if(void 0===t)return(0,u.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var o=e.length;if(void 0===r){r=new Array(o);for(var s=o-1,c=1;s>=0;--s)r[s]=c,c*=e[s]}if(void 0===n)for(n=0,s=0;s>>0;e.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-i:i;var r=n.hi(t),o=n.lo(t);e>t==t>0?o===a?(r+=1,o=0):o+=1:0===o?(o=a,r-=1):o-=1;return n.pack(o,r)}},{"double-bits":85}],287:[function(t,e,r){r.vertexNormals=function(t,e,r){for(var n=e.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa){var x=i[u],_=1/Math.sqrt(v*y);for(b=0;b<3;++b){var w=(b+1)%3,A=(b+2)%3;x[b]+=_*(m[w]*g[A]-m[A]*g[w])}}}for(o=0;oa)for(_=1/Math.sqrt(M),b=0;b<3;++b)x[b]*=_;else for(b=0;b<3;++b)x[b]=0}return i},r.faceNormals=function(t,e,r){for(var n=t.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa?1/Math.sqrt(d):0;for(u=0;u<3;++u)h[u]*=d;i[o]=h}return i}},{}],288:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i,a,o,s,l,u){var c=e+a+u;if(f>0){var f=Math.sqrt(c+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,u),f=Math.sqrt(2*h-c+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}},{}],289:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),c(r=[].slice.call(r,0,4),r);var i=new f(r,e,Math.log(n));i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up);return i};var n=t("filtered-vector"),i=t("gl-mat4/lookAt"),a=t("gl-mat4/fromQuat"),o=t("gl-mat4/invert"),s=t("./lib/quatFromFrame");function l(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function u(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function c(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=u(r,n,i,a);o>1e-6?(t[0]=r/o,t[1]=n/o,t[2]=i/o,t[3]=a/o):(t[0]=t[1]=t[2]=0,t[3]=1)}function f(t,e,r){this.radius=n([r]),this.center=n(e),this.rotation=n(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}var h=f.prototype;h.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},h.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;c(e,e);var r=this.computedMatrix;a(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;l<3;++l){for(var u=0,f=0;f<3;++f)u+=r[l+4*f]*i[f];r[12+l]=-u}},h.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r},h.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},h.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},h.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=i[1],o=i[5],s=i[9],u=l(a,o,s);a/=u,o/=u,s/=u;var c=i[0],f=i[4],h=i[8],d=c*a+f*o+h*s,p=l(c-=a*d,f-=o*d,h-=s*d);c/=p,f/=p,h/=p;var g=i[2],v=i[6],m=i[10],y=g*a+v*o+m*s,b=g*c+v*f+m*h,x=l(g-=y*a+b*c,v-=y*o+b*f,m-=y*s+b*h);g/=x,v/=x,m/=x;var _=c*e+a*r,w=f*e+o*r,A=h*e+s*r;this.center.move(t,_,w,A);var M=Math.exp(this.computedRadius[0]);M=Math.max(1e-4,M+n),this.radius.set(t,Math.log(M))},h.rotate=function(t,e,r,n){this.recalcMatrix(t),e=e||0,r=r||0;var i=this.computedMatrix,a=i[0],o=i[4],s=i[8],c=i[1],f=i[5],h=i[9],d=i[2],p=i[6],g=i[10],v=e*a+r*c,m=e*o+r*f,y=e*s+r*h,b=-(p*y-g*m),x=-(g*v-d*y),_=-(d*m-p*v),w=Math.sqrt(Math.max(0,1-Math.pow(b,2)-Math.pow(x,2)-Math.pow(_,2))),A=u(b,x,_,w);A>1e-6?(b/=A,x/=A,_/=A,w/=A):(b=x=_=0,w=1);var M=this.computedRotation,T=M[0],k=M[1],E=M[2],S=M[3],L=T*w+S*b+k*_-E*x,C=k*w+S*x+E*b-T*_,O=E*w+S*_+T*x-k*b,R=S*w-T*b-k*x-E*_;if(n){b=d,x=p,_=g;var P=Math.sin(n)/l(b,x,_);b*=P,x*=P,_*=P,R=R*(w=Math.cos(e))-(L=L*w+R*b+C*_-O*x)*b-(C=C*w+R*x+O*b-L*_)*x-(O=O*w+R*_+L*x-C*b)*_}var z=u(L,C,O,R);z>1e-6?(L/=z,C/=z,O/=z,R/=z):(L=C=O=0,R=1),this.rotation.set(t,L,C,O,R)},h.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var a=this.computedMatrix;i(a,e,r,n);var o=this.computedRotation;s(o,a[0],a[1],a[2],a[4],a[5],a[6],a[8],a[9],a[10]),c(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var l=0,u=0;u<3;++u)l+=Math.pow(r[u]-e[u],2);this.radius.set(t,.5*Math.log(Math.max(l,1e-6))),this.center.set(t,r[0],r[1],r[2])},h.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},h.setMatrix=function(t,e){var r=this.computedRotation;s(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),c(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;o(n,e);var i=n[15];if(Math.abs(i)>1e-6){var a=n[12]/i,l=n[13]/i,u=n[14]/i;this.recalcMatrix(t);var f=Math.exp(this.computedRadius[0]);this.center.set(t,a-n[2]*f,l-n[6]*f,u-n[10]*f),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},h.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},h.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},h.getDistanceLimits=function(t){var e=this.radius.bounds;return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},h.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},h.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":288,"filtered-vector":92,"gl-mat4/fromQuat":122,"gl-mat4/invert":125,"gl-mat4/lookAt":126}],290:[function(t,e,r){"use strict";var n=t("repeat-string");e.exports=function(t,e,r){return n(r="undefined"!=typeof r?r+"":" ",e)+t}},{"repeat-string":314}],291:[function(t,e,r){e.exports=function(t,e){e||(e=[0,""]),t=String(t);var r=parseFloat(t,10);return e[0]=r,e[1]=t.match(/[\d.\-\+]*\s*(.*)/)[1]||"",e}},{}],292:[function(t,e,r){"use strict";e.exports=function(t){var e=t.length;if(e0;--o)a=l[o],r=s[o],s[o]=s[a],s[a]=r,l[o]=l[r],l[r]=a,u=(u+r)*o;return n.freeUint32(l),n.freeUint32(s),u},r.unrank=function(t,e,r){switch(t){case 0:return r||[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}var n,i,a,o=1;for((r=r||new Array(t))[0]=0,a=1;a0;--a)e=e-(n=e/o|0)*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}},{"invert-permutation":255,"typedarray-pool":347}],294:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=0|e.length,i=t.length,a=[new Array(r),new Array(r)],o=0;o0){o=a[c][r][0],l=c;break}s=o[1^l];for(var f=0;f<2;++f)for(var h=a[f][r],d=0;d0&&(o=p,s=g,l=f)}return i?s:(o&&u(o,l),s)}function f(t,r){var i=a[r][t][0],o=[t];u(i,r);for(var s=i[1^r];;){for(;s!==t;)o.push(s),s=c(o[o.length-2],s,!1);if(a[0][t].length+a[1][t].length===0)break;var l=o[o.length-1],f=t,h=o[1],d=c(l,f,!0);if(n(e[l],e[f],e[h],e[d])<0)break;o.push(t),s=c(l,f)}return o}function h(t,e){return e[1]===e[e.length-1]}for(var o=0;o0;){a[0][o].length;var g=f(o,d);h(p,g)?p.push.apply(p,g):(p.length>0&&l.push(p),p=g)}p.length>0&&l.push(p)}return l};var n=t("compare-angle")},{"compare-angle":70}],295:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=n(t,e.length),i=new Array(e.length),a=new Array(e.length),o=[],s=0;s0;){var u=o.pop();i[u]=!1;for(var c=r[u],s=0;s0})).length,v=new Array(g),m=new Array(g),d=0;d0;){var j=D.pop(),B=L[j];l(B,function(t,e){return t-e});var U,V=B.length,H=F[j];if(0===H){var A=p[j];U=[A]}for(var d=0;d=0)&&(F[q]=1^H,D.push(q),0===H)){var A=p[q];N(A)||(A.reverse(),U.push(A))}}0===H&&r.push(U)}return r};var n=t("edges-to-adjacency-list"),i=t("planar-dual"),a=t("point-in-big-polygon"),o=t("two-product"),s=t("robust-sum"),l=t("uniq"),u=t("./lib/trim-leaves");function c(t,e){for(var r=new Array(t),n=0;n0&&e[i]===r[0]))return 1;a=t[i-1]}for(var s=1;a;){var l=a.key,u=n(r,l[0],l[1]);if(l[0][0]0))return 0;s=-1,a=a.right}else if(u>0)a=a.left;else{if(!(u<0))return 0;s=1,a=a.right}}return s}}(m.slabs,m.coordinates);return 0===a.length?y:function(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}(l(a),y)};var n=t("robust-orientation")[3],i=t("slab-decomposition"),a=t("interval-tree-1d"),o=t("binary-search-bounds");function s(){return!0}function l(t){for(var e={},r=0;r=-t},pointBetween:function(e,r,n){var i=e[1]-r[1],a=n[0]-r[0],o=e[0]-r[0],s=n[1]-r[1],l=o*a+i*s;return!(l-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-i>t&&(a-u)*(i-c)/(o-c)+u-n>t&&(s=!s),a=u,o=c}return s}};return e}},{}],301:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),i=1;i0})}function c(t,n){var i=t.seg,a=n.seg,o=i.start,s=i.end,u=a.start,c=a.end;r&&r.checkIntersection(i,a);var f=e.linesIntersect(o,s,u,c);if(!1===f){if(!e.pointsCollinear(o,s,u))return!1;if(e.pointsSame(o,c)||e.pointsSame(s,u))return!1;var h=e.pointsSame(o,u),d=e.pointsSame(s,c);if(h&&d)return n;var p=!h&&e.pointBetween(o,u,c),g=!d&&e.pointBetween(s,u,c);if(h)return g?l(n,s):l(t,c),n;p&&(d||(g?l(n,s):l(t,c)),l(n,o))}else 0===f.alongA&&(-1===f.alongB?l(t,u):0===f.alongB?l(t,f.pt):1===f.alongB&&l(t,c)),0===f.alongB&&(-1===f.alongA?l(n,o):0===f.alongA?l(n,f.pt):1===f.alongA&&l(n,s));return!1}for(var f=[];!a.isEmpty();){var h=a.getHead();if(r&&r.vert(h.pt[0]),h.isStart){r&&r.segmentNew(h.seg,h.primary);var d=u(h),p=d.before?d.before.ev:null,g=d.after?d.after.ev:null;function v(){if(p){var t=c(h,p);if(t)return t}return!!g&&c(h,g)}r&&r.tempStatus(h.seg,!!p&&p.seg,!!g&&g.seg);var m,y,b=v();if(b)t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below)&&(b.seg.myFill.above=!b.seg.myFill.above):b.seg.otherFill=h.seg.myFill,r&&r.segmentUpdate(b.seg),h.other.remove(),h.remove();if(a.getHead()!==h){r&&r.rewind(h.seg);continue}t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below,h.seg.myFill.below=g?g.seg.myFill.above:i,h.seg.myFill.above=y?!h.seg.myFill.below:h.seg.myFill.below):null===h.seg.otherFill&&(m=g?h.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:h.primary?o:i,h.seg.otherFill={above:m,below:m}),r&&r.status(h.seg,!!p&&p.seg,!!g&&g.seg),h.other.status=d.insert(n.node({ev:h}))}else{var x=h.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(s.exists(x.prev)&&s.exists(x.next)&&c(x.prev.ev,x.next.ev),r&&r.statusRemove(x.ev.seg),x.remove(),!h.primary){var _=h.seg.myFill;h.seg.myFill=h.seg.otherFill,h.seg.otherFill=_}f.push(h.seg)}a.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,i,a,o=t[t.length-1],l=0;l=u?(M=1,y=u+2*h+p):y=h*(M=-h/u)+p):(M=0,d>=0?(T=0,y=p):-d>=f?(T=1,y=f+2*d+p):y=d*(T=-d/f)+p);else if(T<0)T=0,h>=0?(M=0,y=p):-h>=u?(M=1,y=u+2*h+p):y=h*(M=-h/u)+p;else{var k=1/A;y=(M*=k)*(u*M+c*(T*=k)+2*h)+T*(c*M+f*T+2*d)+p}else M<0?(x=f+d)>(b=c+h)?(_=x-b)>=(w=u-2*c+f)?(M=1,T=0,y=u+2*h+p):y=(M=_/w)*(u*M+c*(T=1-M)+2*h)+T*(c*M+f*T+2*d)+p:(M=0,x<=0?(T=1,y=f+2*d+p):d>=0?(T=0,y=p):y=d*(T=-d/f)+p):T<0?(x=u+h)>(b=c+d)?(_=x-b)>=(w=u-2*c+f)?(T=1,M=0,y=f+2*d+p):y=(M=1-(T=_/w))*(u*M+c*T+2*h)+T*(c*M+f*T+2*d)+p:(T=0,x<=0?(M=1,y=u+2*h+p):h>=0?(M=0,y=p):y=h*(M=-h/u)+p):(_=f+d-c-h)<=0?(M=0,T=1,y=f+2*d+p):_>=(w=u-2*c+f)?(M=1,T=0,y=u+2*h+p):y=(M=_/w)*(u*M+c*(T=1-M)+2*h)+T*(c*M+f*T+2*d)+p;var E=1-M-T;for(l=0;l1)for(var r=1;r0){var u=t[r-1];if(0===n(s,u)&&a(u)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}},{"cell-orientation":56,"compare-cell":71,"compare-oriented-cell":72}],314:[function(t,e,r){"use strict";var n,i="";e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("expected a string");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;if(n!==t||"undefined"==typeof n)n=t,i="";else if(i.length>=r)return i.substr(0,r);for(;r>i.length&&e>1;)1&e&&(i+=t),e>>=1,t+=t;return i=(i+=t).substr(0,r)}},{}],315:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],316:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i],s=(r=a+o)-a,l=o-s;l&&(t[--n]=r,r=l)}for(var u=0,i=n;i>1;return["sum(",t(e.slice(0,r)),",",t(e.slice(r)),")"].join("")}(e);var n}function c(t){return new Function("sum","scale","prod","compress",["function robustDeterminant",t,"(m){return compress(",u(function(t){for(var e=new Array(t),r=0;r>1;return["sum(",u(t.slice(0,e)),",",u(t.slice(e)),")"].join("")}function c(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return c(e,t)}function f(t){if(2===t.length)return[["diff(",c(t[0][0],t[1][1]),",",c(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r0&&r.push(","),r.push("[");for(var o=0;o0&&r.push(","),o===i?r.push("+b[",a,"]"):r.push("+A[",a,"][",o,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var s=new Function("det",r.join(""));return s(t<6?n[t]:n)}var o=[function(){return[0]},function(t,e){return[[e[0]],[t[0][0]]]}];!function(){for(;o.length>1;return["sum(",u(t.slice(0,e)),",",u(t.slice(e)),")"].join("")}function c(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(a<=0)return o;n=i+a}else{if(!(i<0))return o;if(a>=0)return o;n=-(i+a)}var s=3.3306690738754716e-16*n;return o>=s||o<=-s?o:h(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],u=r[1]-n[1],c=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],p=a*u,g=o*l,v=o*s,m=i*u,y=i*l,b=a*s,x=c*(p-g)+f*(v-m)+h*(y-b),_=7.771561172376103e-16*((Math.abs(p)+Math.abs(g))*Math.abs(c)+(Math.abs(v)+Math.abs(m))*Math.abs(f)+(Math.abs(y)+Math.abs(b))*Math.abs(h));return x>_||-x>_?x:d(t,e,r,n)}];!function(){for(;p.length<=s;)p.push(f(p.length));for(var t=[],r=["slow"],n=0;n<=s;++n)t.push("a"+n),r.push("o"+n);var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(n=2;n<=s;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i0&&o>0||a<0&&o<0)return!1;var s=n(r,t,e),l=n(i,t,e);if(s>0&&l>0||s<0&&l<0)return!1;if(0===a&&0===o&&0===s&&0===l)return function(t,e,r,n){for(var i=0;i<2;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),u=r[i],c=n[i],f=Math.min(u,c),h=Math.max(u,c);if(h=n?(i=f,(l+=1)=n?(i=f,(l+=1)0?1:0}},{}],328:[function(t,e,r){"use strict";e.exports=function(t){return i(n(t))};var n=t("boundary-cells"),i=t("reduce-simplicial-complex")},{"boundary-cells":39,"reduce-simplicial-complex":313}],329:[function(t,e,r){"use strict";e.exports=function(t,e,r,s){r=r||0,"undefined"==typeof s&&(s=function(t){for(var e=t.length,r=0,n=0;n>1,v=E[2*m+1];","if(v===b){return m}","if(b0&&l.push(","),l.push("[");for(var n=0;n0&&l.push(","),l.push("B(C,E,c[",i[0],"],c[",i[1],"])")}l.push("]")}l.push(");")}}for(var a=t+1;a>1;--a){a>1,s=a(t[o],e);s<=0?(0===s&&(i=o),r=o+1):s>0&&(n=o-1)}return i}function c(t,e){for(var r=new Array(t.length),i=0,o=r.length;i=t.length||0!==a(t[v],s)););}return r}function f(t,e){if(e<0)return[];for(var r=[],i=(1<>>c&1&&u.push(i[c]);e.push(u)}return s(e)},r.skeleton=f,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function b(t){for(var e=m(t);;){var r=e,n=2*t+1,i=2*(t+1),a=t;if(n0;){var r=y(t);if(r>=0){var n=m(r);if(e0){var t=M[0];return v(0,E-1),E-=1,b(0),t}return-1}function w(t,e){var r=M[t];return u[r]===e?t:(u[r]=-1/0,x(t),_(),u[r]=e,x((E+=1)-1))}function A(t){if(!c[t]){c[t]=!0;var e=s[t],r=l[t];s[r]>=0&&(s[r]=e),l[e]>=0&&(l[e]=r),T[e]>=0&&w(T[e],g(e)),T[r]>=0&&w(T[r],g(r))}}for(var M=[],T=new Array(a),f=0;f>1;f>=0;--f)b(f);for(;;){var S=_();if(S<0||u[S]>r)break;A(S)}for(var L=[],f=0;f=0&&r>=0&&e!==r){var n=T[e],i=T[r];n!==i&&O.push([n,i])}}),i.unique(i.normalize(O)),{positions:L,edges:O}};var n=t("robust-orientation"),i=t("simplicial-complex")},{"robust-orientation":321,"simplicial-complex":333}],336:[function(t,e,r){"use strict";e.exports=function(t,e){var r,a,o,s;if(e[0][0]e[1][0]))return i(e,t);r=e[1],a=e[0]}if(t[0][0]t[1][0]))return-i(t,e);o=t[1],s=t[0]}var l=n(r,a,s),u=n(r,a,o);if(l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;if(l=n(s,o,a),u=n(s,o,r),l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;return a[0]-s[0]};var n=t("robust-orientation");function i(t,e){var r,i,a,o;if(e[0][0]e[1][0])){var s=Math.min(t[0][1],t[1][1]),l=Math.max(t[0][1],t[1][1]),u=Math.min(e[0][1],e[1][1]),c=Math.max(e[0][1],e[1][1]);return lc?s-c:l-c}r=e[1],i=e[0]}t[0][1]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=u(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=u(t.right,e))return l;t=t.left}}return r}function c(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function f(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}s.prototype.castUp=function(t){var e=n.le(this.coordinates,t[0]);if(e<0)return-1;this.slabs[e];var r=u(this.slabs[e],t),i=-1;if(r&&(i=r.value),this.coordinates[e]===t[0]){var s=null;if(r&&(s=r.key),e>0){var c=u(this.slabs[e-1],t);c&&(s?o(c.key,s)>0&&(s=c.key,i=c.value):(i=c.value,s=c.key))}var f=this.horizontal[e];if(f.length>0){var h=n.ge(f,t[1],l);if(h=f.length)return i;d=f[h]}}if(d.start)if(s){var p=a(s[0],s[1],[t[0],d.y]);s[0][0]>s[1][0]&&(p=-p),p>0&&(i=d.index)}else i=d.index;else d.y!==t[1]&&(i=d.index)}}}return i}},{"./lib/order-segments":336,"binary-search-bounds":36,"functional-red-black-tree":93,"robust-orientation":321}],338:[function(t,e,r){"use strict";var n=t("robust-dot-product"),i=t("robust-sum");function a(t,e){var r=i(n(t,e),[e[e.length-1]]);return r[r.length-1]}function o(t,e,r,n){var i=-e/(n-e);i<0?i=0:i>1&&(i=1);for(var a=1-i,o=t.length,s=new Array(o),l=0;l0||i>0&&c<0){var f=o(s,c,l,i);r.push(f),n.push(f.slice())}c<0?n.push(l.slice()):c>0?r.push(l.slice()):(r.push(l.slice()),n.push(l.slice())),i=c}return{positive:r,negative:n}},e.exports.positive=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&u<0)&&r.push(o(i,u,s,n)),u>=0&&r.push(s.slice()),n=u}return r},e.exports.negative=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&u<0)&&r.push(o(i,u,s,n)),u<=0&&r.push(s.slice()),n=u}return r}},{"robust-dot-product":318,"robust-sum":326}],339:[function(t,e,r){!function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function e(r){return function(r,n){var i,a,o,s,l,u,c,f,h,d=1,p=r.length,g="";for(a=0;a=0),s[8]){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,s[6]?parseInt(s[6]):0);break;case"e":i=s[7]?parseFloat(i).toExponential(s[7]):parseFloat(i).toExponential();break;case"f":i=s[7]?parseFloat(i).toFixed(s[7]):parseFloat(i);break;case"g":i=s[7]?String(Number(i.toPrecision(s[7]))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=s[7]?i.substring(0,s[7]):i;break;case"t":i=String(!!i),i=s[7]?i.substring(0,s[7]):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=s[7]?i.substring(0,s[7]):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=s[7]?i.substring(0,s[7]):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}t.json.test(s[8])?g+=i:(!t.number.test(s[8])||f&&!s[3]?h="":(h=f?"+":"-",i=i.toString().replace(t.sign,"")),u=s[4]?"0"===s[4]?"0":s[4].charAt(1):" ",c=s[6]-(h+i).length,l=s[6]&&c>0?u.repeat(c):"",g+=s[5]?h+i+l:"0"===u?h+l+i:l+h+i)}return g}(function(e){if(i[e])return i[e];var r,n=e,a=[],o=0;for(;n;){if(null!==(r=t.text.exec(n)))a.push(r[0]);else if(null!==(r=t.modulo.exec(n)))a.push("%");else{if(null===(r=t.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){o|=1;var s=[],l=r[2],u=[];if(null===(u=t.key.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(l=l.substring(u[0].length));)if(null!==(u=t.key_access.exec(l)))s.push(u[1]);else{if(null===(u=t.index_access.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}r[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");a.push(r)}n=n.substring(r[0].length)}return i[e]=a}(r),arguments)}function n(t,r){return e.apply(null,[t].concat(r||[]))}var i=Object.create(null);"undefined"!=typeof r&&(r.sprintf=e,r.vsprintf=n),"undefined"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}()},{}],340:[function(t,e,r){"use strict";e.exports=function(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return function(t,e){for(var r=a(t,e),n=r.length,i=new Array(n),o=new Array(n),s=0;s c)|0 },"),"generic"===e&&a.push("getters:[0],");for(var s=[],l=[],u=0;u>>7){");for(var u=0;u<1<<(1<128&&u%128==0){f.length>0&&h.push("}}");var d="vExtra"+f.length;a.push("case ",u>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&u,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;bb)&&!(u&1<<_)!=!(u&1<0&&(T="+"+v[x]+"*c");var k=p[x].length/y*.5,E=.5+m[x]/y*.5;M.push("d"+x+"-"+E+"-"+k+"*("+p[x].join("+")+T+")/("+g[x].join("+")+")")}h.push("a.push([",M.join(),"]);","break;")}a.push("}},"),f.length>0&&h.push("}}");for(var S=[],u=0;u<1<1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=C(t,360),e=C(e,100),r=C(r,100),0===e)n=i=a=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;n=o(l,s,t+1/3),i=o(l,s,t),a=o(l,s,t-1/3)}return{r:255*n,g:255*i,b:255*a}}(e.h,l,c),f=!0,h="hsl"),e.hasOwnProperty("a")&&(a=e.a));var d,p,g;return a=L(a),{ok:f,format:e.format||h,r:o(255,s(i.r,0)),g:o(255,s(i.g,0)),b:o(255,s(i.b,0)),a:a}}(e);this._originalInput=e,this._r=c.r,this._g=c.g,this._b=c.b,this._a=c.a,this._roundA=a(100*this._a)/100,this._format=l.format||c.format,this._gradientType=l.gradientType,this._r<1&&(this._r=a(this._r)),this._g<1&&(this._g=a(this._g)),this._b<1&&(this._b=a(this._b)),this._ok=c.ok,this._tc_id=i++}function c(t,e,r){t=C(t,255),e=C(e,255),r=C(r,255);var n,i,a=s(t,e,r),l=o(t,e,r),u=(a+l)/2;if(a==l)n=i=0;else{var c=a-l;switch(i=u>.5?c/(2-a-l):c/(a+l),a){case t:n=(e-r)/c+(e>1)+720)%360;--e;)n.h=(n.h+i)%360,a.push(u(n));return a}function k(t,e){e=e||6;for(var r=u(t).toHsv(),n=r.h,i=r.s,a=r.v,o=[],s=1/e;e--;)o.push(u({h:n,s:i,v:a})),a=(a+s)%1;return o}u.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,i=this.toRgb();return e=i.r/255,r=i.g/255,n=i.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=L(t),this._roundA=a(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=c(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return h(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,i){var o=[P(a(t).toString(16)),P(a(e).toString(16)),P(a(r).toString(16)),P(I(n))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:a(this._r),g:a(this._g),b:a(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+a(this._r)+", "+a(this._g)+", "+a(this._b)+")":"rgba("+a(this._r)+", "+a(this._g)+", "+a(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:a(100*C(this._r,255))+"%",g:a(100*C(this._g,255))+"%",b:a(100*C(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+a(100*C(this._r,255))+"%, "+a(100*C(this._g,255))+"%, "+a(100*C(this._b,255))+"%)":"rgba("+a(100*C(this._r,255))+"%, "+a(100*C(this._g,255))+"%, "+a(100*C(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(S[h(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+d(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var i=u(t);r="#"+d(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return u(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(m,arguments)},brighten:function(){return this._applyModification(y,arguments)},darken:function(){return this._applyModification(b,arguments)},desaturate:function(){return this._applyModification(p,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(T,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(M,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(A,arguments)}},u.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:z(t[n]));t=r}return u(t,e)},u.equals=function(t,e){return!(!t||!e)&&u(t).toRgbString()==u(e).toRgbString()},u.random=function(){return u.fromRatio({r:l(),g:l(),b:l()})},u.mix=function(t,e,r){r=0===r?0:r||50;var n=u(t).toRgb(),i=u(e).toRgb(),a=r/100;return u({r:(i.r-n.r)*a+n.r,g:(i.g-n.g)*a+n.g,b:(i.b-n.b)*a+n.b,a:(i.a-n.a)*a+n.a})},u.readability=function(e,r){var n=u(e),i=u(r);return(t.max(n.getLuminance(),i.getLuminance())+.05)/(t.min(n.getLuminance(),i.getLuminance())+.05)},u.isReadable=function(t,e,r){var n,i,a=u.readability(t,e);switch(i=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},u.mostReadable=function(t,e,r){var n,i,a,o,s=null,l=0;i=(r=r||{}).includeFallbackColors,a=r.level,o=r.size;for(var c=0;cl&&(l=n,s=u(e[c]));return u.isReadable(t,s,{level:a,size:o})||!i?s:(r.includeFallbackColors=!1,u.mostReadable(t,["#fff","#000"],r))};var E=u.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S=u.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(E);function L(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function C(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,s(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function O(t){return o(1,s(0,t))}function R(t){return parseInt(t,16)}function P(t){return 1==t.length?"0"+t:""+t}function z(t){return t<=1&&(t=100*t+"%"),t}function I(e){return t.round(255*parseFloat(e)).toString(16)}function N(t){return R(t)/255}var D,F,j,B=(F="[\\s|\\(]+("+(D="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+D+")[,|\\s]+("+D+")\\s*\\)?",j="[\\s|\\(]+("+D+")[,|\\s]+("+D+")[,|\\s]+("+D+")[,|\\s]+("+D+")\\s*\\)?",{CSS_UNIT:new RegExp(D),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+j),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+j),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+j),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function U(t){return!!B.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=u:window.tinycolor=u}(Math)},{}],342:[function(t,e,r){"use strict";var n=t("parse-unit");e.exports=o;var i=96;function a(t,e){var r=n(getComputedStyle(t).getPropertyValue(e));return r[0]*o(r[1],t)}function o(t,e){switch(e=e||document.body,t=(t||"px").trim().toLowerCase(),e!==window&&e!==document||(e=document.body),t){case"%":return e.clientHeight/100;case"ch":case"ex":return function(t,e){var r=document.createElement("div");r.style["font-size"]="128"+t,e.appendChild(r);var n=a(r,"font-size")/128;return e.removeChild(r),n}(t,e);case"em":return a(e,"font-size");case"rem":return a(document.body,"font-size");case"vw":return window.innerWidth/100;case"vh":return window.innerHeight/100;case"vmin":return Math.min(window.innerWidth,window.innerHeight)/100;case"vmax":return Math.max(window.innerWidth,window.innerHeight)/100;case"in":return i;case"cm":return i/2.54;case"mm":return i/25.4;case"pt":return i/72;case"pc":return i/6}return 1}},{"parse-unit":291}],343:[function(t,e,r){"use strict";e.exports=function(t){if(t<0)return[];if(0===t)return[[0]];for(var e=0|Math.round(a(t+1)),r=[],o=0;oMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,l=0;l<3;++l)a+=t[l]*t[l],o+=i[l]*t[l];for(l=0;l<3;++l)i[l]-=o/a*t[l];return s(i,i),i}function h(t,e,r,i,a,o,s,l){this.center=n(r),this.up=n(i),this.right=n(a),this.radius=n([o]),this.angle=n([s,l]),this.angle.bounds=[[-1/0,-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var u=0;u<16;++u)this.computedMatrix[u]=.5;this.recalcMatrix(0)}var d=h.prototype;d.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},d.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},d.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,n=0,i=0,a=0;a<3;++a)i+=e[a]*r[a],n+=e[a]*e[a];var l=Math.sqrt(n),c=0;for(a=0;a<3;++a)r[a]-=e[a]*i/n,c+=r[a]*r[a],e[a]/=l;var f=Math.sqrt(c);for(a=0;a<3;++a)r[a]/=f;var h=this.computedToward;o(h,e,r),s(h,h);var d=Math.exp(this.computedRadius[0]),p=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(p),m=Math.sin(p),y=Math.cos(g),b=Math.sin(g),x=this.computedCenter,_=v*y,w=m*y,A=b,M=-v*b,T=-m*b,k=y,E=this.computedEye,S=this.computedMatrix;for(a=0;a<3;++a){var L=_*r[a]+w*h[a]+A*e[a];S[4*a+1]=M*r[a]+T*h[a]+k*e[a],S[4*a+2]=L,S[4*a+3]=0}var C=S[1],O=S[5],R=S[9],P=S[2],z=S[6],I=S[10],N=O*I-R*z,D=R*P-C*I,F=C*z-O*P,j=u(N,D,F);N/=j,D/=j,F/=j,S[0]=N,S[4]=D,S[8]=F;for(a=0;a<3;++a)E[a]=x[a]+S[2+4*a]*d;for(a=0;a<3;++a){c=0;for(var B=0;B<3;++B)c+=S[a+4*B]*E[B];S[12+a]=-c}S[15]=1},d.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r};var p=[0,0,0];d.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;p[0]=i[2],p[1]=i[6],p[2]=i[10];for(var o=this.computedUp,s=this.computedRight,l=this.computedToward,u=0;u<3;++u)i[4*u]=o[u],i[4*u+1]=s[u],i[4*u+2]=l[u];a(i,i,n,p);for(u=0;u<3;++u)o[u]=i[4*u],s[u]=i[4*u+1];this.up.set(t,o[0],o[1],o[2]),this.right.set(t,s[0],s[1],s[2])}},d.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=(Math.exp(this.computedRadius[0]),i[1]),o=i[5],s=i[9],l=u(a,o,s);a/=l,o/=l,s/=l;var c=i[0],f=i[4],h=i[8],d=c*a+f*o+h*s,p=u(c-=a*d,f-=o*d,h-=s*d),g=(c/=p)*e+a*r,v=(f/=p)*e+o*r,m=(h/=p)*e+s*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+n),this.radius.set(t,Math.log(y))},d.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},d.setMatrix=function(t,e,r,n){var a=1;"number"==typeof r&&(a=0|r),(a<0||a>3)&&(a=1);var o=(a+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var s=e[a],l=e[a+4],f=e[a+8];if(n){var h=Math.abs(s),d=Math.abs(l),p=Math.abs(f),g=Math.max(h,d,p);h===g?(s=s<0?-1:1,l=f=0):p===g?(f=f<0?-1:1,s=l=0):(l=l<0?-1:1,s=f=0)}else{var v=u(s,l,f);s/=v,l/=v,f/=v}var m,y,b=e[o],x=e[o+4],_=e[o+8],w=b*s+x*l+_*f,A=u(b-=s*w,x-=l*w,_-=f*w),M=l*(_/=A)-f*(x/=A),T=f*(b/=A)-s*_,k=s*x-l*b,E=u(M,T,k);if(M/=E,T/=E,k/=E,this.center.jump(t,q,G,X),this.radius.idle(t),this.up.jump(t,s,l,f),this.right.jump(t,b,x,_),2===a){var S=e[1],L=e[5],C=e[9],O=S*b+L*x+C*_,R=S*M+L*T+C*k;m=N<0?-Math.PI/2:Math.PI/2,y=Math.atan2(R,O)}else{var P=e[2],z=e[6],I=e[10],N=P*s+z*l+I*f,D=P*b+z*x+I*_,F=P*M+z*T+I*k;m=Math.asin(c(N)),y=Math.atan2(F,D)}this.angle.jump(t,y,m),this.recalcMatrix(t);var j=e[2],B=e[6],U=e[10],V=this.computedMatrix;i(V,e);var H=V[15],q=V[12]/H,G=V[13]/H,X=V[14]/H,W=Math.exp(this.computedRadius[0]);this.center.jump(t,q-j*W,G-B*W,X-U*W)},d.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},d.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},d.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},d.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},d.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter;var i=(n=n||this.computedUp)[0],a=n[1],o=n[2],s=u(i,a,o);if(!(s<1e-6)){i/=s,a/=s,o/=s;var l=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],d=u(l,f,h);if(!(d<1e-6)){l/=d,f/=d,h/=d;var p=this.computedRight,g=p[0],v=p[1],m=p[2],y=i*g+a*v+o*m,b=u(g-=y*i,v-=y*a,m-=y*o);if(!(b<.01&&(b=u(g=a*h-o*f,v=o*l-i*h,m=i*f-a*l))<1e-6)){g/=b,v/=b,m/=b,this.up.set(t,i,a,o),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(d));var x=a*m-o*v,_=o*g-i*m,w=i*v-a*g,A=u(x,_,w),M=i*l+a*f+o*h,T=g*l+v*f+m*h,k=(x/=A)*l+(_/=A)*f+(w/=A)*h,E=Math.asin(c(M)),S=Math.atan2(k,T),L=this.angle._state,C=L[L.length-1],O=L[L.length-2];C%=2*Math.PI;var R=Math.abs(C+2*Math.PI-S),P=Math.abs(C-S),z=Math.abs(C-2*Math.PI-S);R0?r.pop():new ArrayBuffer(t)}function h(t){return new Uint8Array(f(t),0,t)}function d(t){return new Uint16Array(f(2*t),0,t)}function p(t){return new Uint32Array(f(4*t),0,t)}function g(t){return new Int8Array(f(t),0,t)}function v(t){return new Int16Array(f(2*t),0,t)}function m(t){return new Int32Array(f(4*t),0,t)}function y(t){return new Float32Array(f(4*t),0,t)}function b(t){return new Float64Array(f(8*t),0,t)}function x(t){return o?new Uint8ClampedArray(f(t),0,t):h(t)}function _(t){return new DataView(f(t),0,t)}function w(t){t=i.nextPow2(t);var e=i.log2(t),r=u[e];return r.length>0?r.pop():new n(t)}r.free=function(t){if(n.isBuffer(t))u[i.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|i.log2(e);l[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=function(t){c(t.buffer)},r.freeArrayBuffer=c,r.freeBuffer=function(t){u[i.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return f(t);switch(e){case"uint8":return h(t);case"uint16":return d(t);case"uint32":return p(t);case"int8":return g(t);case"int16":return v(t);case"int32":return m(t);case"float":case"float32":return y(t);case"double":case"float64":return b(t);case"uint8_clamped":return x(t);case"buffer":return w(t);case"data":case"dataview":return _(t);default:return null}return null},r.mallocArrayBuffer=f,r.mallocUint8=h,r.mallocUint16=d,r.mallocUint32=p,r.mallocInt8=g,r.mallocInt16=v,r.mallocInt32=m,r.mallocFloat32=r.mallocFloat=y,r.mallocFloat64=r.mallocDouble=b,r.mallocUint8Clamped=x,r.mallocDataView=_,r.mallocBuffer=w,r.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,l[t].length=0,u[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":37,buffer:49,dup:87}],348:[function(t,e,r){"use strict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e0&&(a=n.size),n.lineSpacing&&n.lineSpacing>0&&(o=n.lineSpacing),n.styletags&&n.styletags.breaklines&&(s.breaklines=!!n.styletags.breaklines),n.styletags&&n.styletags.bolds&&(s.bolds=!!n.styletags.bolds),n.styletags&&n.styletags.italics&&(s.italics=!!n.styletags.italics),n.styletags&&n.styletags.subscripts&&(s.subscripts=!!n.styletags.subscripts),n.styletags&&n.styletags.superscripts&&(s.superscripts=!!n.styletags.superscripts));return r.font=[n.fontStyle,n.fontVariant,n.fontWeight,a+"px",n.font].filter(function(t){return t}).join(" "),r.textAlign="start",r.textBaseline="alphabetic",r.direction="ltr",w(function(t,e,r,n,a,o){r=r.replace(/\n/g,""),r=!0===o.breaklines?r.replace(/\/g,"\n"):r.replace(/\/g," ");var s="",l=[];for(A=0;A-1?parseInt(t[1+a]):0,u=s>-1?parseInt(r[1+s]):0;l!==u&&(i=i.replace(n(),"?px "),k*=Math.pow(.75,u-l),i=i.replace("?px ",n())),T+=.25*L*(u-l)}if(!0===o.superscripts){var f=t.indexOf(p),d=r.indexOf(p),g=f>-1?parseInt(t[1+f]):0,v=d>-1?parseInt(r[1+d]):0;g!==v&&(i=i.replace(n(),"?px "),k*=Math.pow(.75,v-g),i=i.replace("?px ",n())),T-=.25*L*(v-g)}if(!0===o.bolds){var y=t.indexOf(c)>-1,b=r.indexOf(c)>-1;!y&&b&&(i=x?i.replace("italic ","italic bold "):"bold "+i),y&&!b&&(i=i.replace("bold ",""))}if(!0===o.italics){var x=t.indexOf(h)>-1,_=r.indexOf(h)>-1;!x&&_&&(i="italic "+i),x&&!_&&(i=i.replace("italic ",""))}e.font=i}for(A=0;A",a="",o=i.length,s=a.length,l=e[0]===p||e[0]===m,u=0,c=-s;u>-1&&-1!==(u=r.indexOf(i,u))&&-1!==(c=r.indexOf(a,u+o))&&!(c<=u);){for(var f=u;f=c)n[f]=null,r=r.substr(0,f)+" "+r.substr(f+1);else if(null!==n[f]){var h=n[f].indexOf(e[0]);-1===h?n[f]+=e:l&&(n[f]=n[f].substr(0,h+1)+(1+parseInt(n[f][h+1]))+n[f].substr(h+2))}var d=u+o,g=r.substr(d,c-d).indexOf(i);u=-1!==g?g:c+s}return n}function x(t,e){var r=n(t,128);return e?a(r.cells,r.positions,.25):{edges:r.cells,positions:r.positions}}function _(t,e,r,n){var i=x(t,n),a=function(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;l=0?e[a]:i})},has___:{value:b(function(e){var n=y(e);return n?r in n:t.indexOf(e)>=0})},set___:{value:b(function(n,i){var a,o=y(n);return o?o[r]=i:(a=t.indexOf(n))>=0?e[a]=i:(a=t.length,e[a]=i,t[a]=n),this})},delete___:{value:b(function(n){var i,a,o=y(n);return o?r in o&&delete o[r]:!((i=t.indexOf(n))<0||(a=t.length-1,t[i]=void 0,e[i]=e[a],t[i]=t[a],t.length=a,e.length=a,0))})}})};g.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},delete:{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof r?function(){function n(){this instanceof g||x();var e,n=new r,i=void 0,a=!1;return e=t?function(t,e){return n.set(t,e),n.has(t)||(i||(i=new g),i.set(t,e)),this}:function(t,e){if(a)try{n.set(t,e)}catch(r){i||(i=new g),i.set___(t,e)}else n.set(t,e);return this},Object.create(g.prototype,{get___:{value:b(function(t,e){return i?n.has(t)?n.get(t):i.get___(t,e):n.get(t,e)})},has___:{value:b(function(t){return n.has(t)||!!i&&i.has___(t)})},set___:{value:b(e)},delete___:{value:b(function(t){var e=!!n.delete(t);return i&&i.delete___(t)||e})},permitHostObjects___:{value:b(function(t){if(t!==v)throw new Error("bogus call to permitHostObjects___");a=!0})}})}t&&"undefined"!=typeof Proxy&&(Proxy=void 0),n.prototype=g.prototype,e.exports=n,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=g)}function v(t){t.permitHostObjects___&&t.permitHostObjects___(v)}function m(t){return!(t.substr(0,l.length)==l&&"___"===t.substr(t.length-3))}function y(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[u];if(e&&e.key===t)return e;if(s(t)){e={key:t};try{return o(t,u,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(t){return}}}function b(t){return t.prototype=null,Object.freeze(t)}function x(){d||"undefined"==typeof console||(d=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}}()},{}],353:[function(t,e,r){var n=t("./hidden-store.js");e.exports=function(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:n(e,t)}}},{"./hidden-store.js":354}],354:[function(t,e,r){e.exports=function(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}},{}],355:[function(t,e,r){var n=t("./create-store.js");e.exports=function(){var t=n();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){return t(e).value=r,this},has:function(e){return"value"in t(e)},delete:function(e){return delete t(e).value}}}},{"./create-store.js":353}],356:[function(t,e,r){var n=t("get-canvas-context");e.exports=function(t){return n("webgl",t)}},{"get-canvas-context":95}],357:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array",{offset:[1],array:0},"scalar","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":78}],358:[function(t,e,r){"use strict";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t("./lib/zc-core")},{"./lib/zc-core":357}],359:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],360:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:i({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:i({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":530,"../../plots/cartesian/constants":546,"../../plots/font_attributes":567,"./arrow_paths":359}],361:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=i.getFromId(t,e.xref),n=i.getFromId(t,e.yref);e._extremes={},r&&s(e,r),n&&s(e,n)})}function s(t,e){var r,n=e._id,a=n.charAt(0),o=t[a],s=t["a"+a],l=t[a+"ref"],u=t["a"+a+"ref"],c=t["_"+a+"padplus"],f=t["_"+a+"padminus"],h={x:1,y:-1}[a]*t[a+"shift"],d=3*t.arrowsize*t.arrowwidth||0,p=d+h,g=d-h,v=3*t.startarrowsize*t.arrowwidth||0,m=v+h,y=v-h;if(u===l){var b=i.findExtremes(e,[e.r2c(o)],{ppadplus:p,ppadminus:g}),x=i.findExtremes(e,[e.r2c(s)],{ppadplus:Math.max(c,m),ppadminus:Math.max(f,y)});r={min:[b.min[0],x.min[0]],max:[b.max[0],x.max[0]]}}else m=s?m+s:m,y=s?y-s:y,r=i.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(c,p,m),ppadminus:Math.max(f,g,y)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([a,o],t)}},{"../../lib":494,"../../plots/cartesian/axes":540,"./draw":366}],362:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,i,a,o,l,u,c=t._fullLayout.annotations,f=[],h=[],d=[],p=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,s,l=o(t,e),u=l.on,c=l.off.concat(l.explicitOff),f={},h=t._fullLayout.annotations;if(!u.length&&!c.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var H=!1,q=["x","y"],G=0;G1)&&(K===J?((lt=tt.r2fraction(e["a"+$]))<0||lt>1)&&(H=!0):H=!0),X=tt._offset+tt.r2p(e[$]),Z=.5}else"x"===$?(Y=e[$],X=x.l+x.w*Y):(Y=1-e[$],X=x.t+x.h*Y),Z=e.showarrow?.5:Y;if(e.showarrow){st.head=X;var ut=e["a"+$];Q=rt*V(.5,e.xanchor)-nt*V(.5,e.yanchor),K===J?(st.tail=tt._offset+tt.r2p(ut),W=Q):(st.tail=X+ut,W=Q+ut),st.text=st.tail+Q;var ct=b["x"===$?"width":"height"];if("paper"===J&&(st.head=o.constrain(st.head,1,ct-1)),"pixel"===K){var ft=-Math.max(st.tail-3,st.text),ht=Math.min(st.tail+3,st.text)-ct;ft>0?(st.tail+=ft,st.text+=ft):ht>0&&(st.tail-=ht,st.text-=ht)}st.tail+=ot,st.head+=ot}else W=Q=it*V(Z,at),st.text=X+Q;st.text+=ot,Q+=ot,W+=ot,e["_"+$+"padplus"]=it/2+W,e["_"+$+"padminus"]=it/2-W,e["_"+$+"size"]=it,e["_"+$+"shift"]=Q}if(t._dragging||!H){var dt=0,pt=0;if("left"!==e.align&&(dt=(w-m)*("center"===e.align?.5:1)),"top"!==e.valign&&(pt=(R-y)*("middle"===e.valign?.5:1)),c)n.select("svg").attr({x:N+dt-1,y:N+pt}).call(u.setClipUrl,F?k:null,t);else{var gt=N+pt-p.top,vt=N+dt-p.left;U.call(f.positionText,vt,gt).call(u.setClipUrl,F?k:null,t)}j.select("rect").call(u.setRect,N,N,w,R),D.call(u.setRect,z/2,z/2,I-z,B-z),P.call(u.setTranslate,Math.round(E.x.text-I/2),Math.round(E.y.text-B/2)),C.attr({transform:"rotate("+S+","+E.x.text+","+E.y.text+")"});var mt,yt=function(r,n){L.selectAll(".annotation-arrow-g").remove();var c=E.x.head,f=E.y.head,h=E.x.tail+r,p=E.y.tail+n,m=E.x.text+r,y=E.y.text+n,b=o.rotationXYMatrix(S,m,y),w=o.apply2DTransform(b),k=o.apply2DTransform2(b),O=+D.attr("width"),R=+D.attr("height"),z=m-.5*O,I=z+O,N=y-.5*R,F=N+R,j=[[z,N,z,F],[z,F,I,F],[I,F,I,N],[I,N,z,N]].map(k);if(!j.reduce(function(t,e){return t^!!o.segmentsIntersect(c,f,c+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){j.forEach(function(t){var e=o.segmentsIntersect(h,p,c,f,t[0],t[1],t[2],t[3]);e&&(h=e.x,p=e.y)});var B=e.arrowwidth,U=e.arrowcolor,V=e.arrowside,H=L.append("g").style({opacity:l.opacity(U)}).classed("annotation-arrow-g",!0),q=H.append("path").attr("d","M"+h+","+p+"L"+c+","+f).style("stroke-width",B+"px").call(l.stroke,l.rgb(U));if(g(q,V,e),_.annotationPosition&&q.node().parentNode&&!a){var G=c,X=f;if(e.standoff){var W=Math.sqrt(Math.pow(c-h,2)+Math.pow(f-p,2));G+=e.standoff*(h-c)/W,X+=e.standoff*(p-f)/W}var Y,Z,Q=H.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(h-G)+","+(p-X),transform:"translate("+G+","+X+")"}).style("stroke-width",B+6+"px").call(l.stroke,"rgba(0,0,0,0)").call(l.fill,"rgba(0,0,0,0)");d.init({element:Q.node(),gd:t,prepFn:function(){var t=u.getTranslate(P);Y=t.x,Z=t.y,s&&s.autorange&&A(s._name+".autorange",!0),v&&v.autorange&&A(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(Y,Z),i=n[0]+t,a=n[1]+r;P.call(u.setTranslate,i,a),M("x",s?s.p2r(s.r2p(e.x)+t):e.x+t/x.w),M("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/x.h),e.axref===e.xref&&M("ax",s.p2r(s.r2p(e.ax)+t)),e.ayref===e.yref&&M("ay",v.p2r(v.r2p(e.ay)+r)),H.attr("transform","translate("+t+","+r+")"),C.attr({transform:"rotate("+S+","+i+","+a+")"})},doneFn:function(){i.call("_guiRelayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&yt(0,0),O)d.init({element:P.node(),gd:t,prepFn:function(){mt=C.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?M("ax",s.p2r(s.r2p(e.ax)+t)):M("ax",e.ax+t),e.ayref===e.yref?M("ay",v.p2r(v.r2p(e.ay)+r)):M("ay",e.ay+r),yt(t,r);else{if(a)return;var i,o;if(s)i=s.p2r(s.r2p(e.x)+t);else{var l=e._xsize/x.w,u=e.x+(e._xshift-e.xshift)/x.w-l/2;i=d.align(u+t/x.w,l,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var c=e._ysize/x.h,f=e.y-(e._yshift+e.yshift)/x.h-c/2;o=d.align(f-r/x.h,c,0,1,e.yanchor)}M("x",i),M("y",o),s&&v||(n=d.getCursor(s?.5:i,v?.5:o,e.xanchor,e.yanchor))}C.attr({transform:"translate("+t+","+r+")"+mt}),h(P,n)},doneFn:function(){h(P),i.call("_guiRelayout",t,T());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else P.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,m=f.backoff*d+r.standoff,y=h.backoff*p+r.startstandoff;if("line"===c.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},s={x:+t.attr("x2"),y:+t.attr("y2")};var b=o.x-s.x,x=o.y-s.y;if(u=(l=Math.atan2(x,b))+Math.PI,m&&y&&m+y>Math.sqrt(b*b+x*x))return void O();if(m){if(m*m>b*b+x*x)return void O();var _=m*Math.cos(l),w=m*Math.sin(l);s.x+=_,s.y+=w,t.attr({x2:s.x,y2:s.y})}if(y){if(y*y>b*b+x*x)return void O();var A=y*Math.cos(l),M=y*Math.sin(l);o.x-=A,o.y-=M,t.attr({x1:o.x,y1:o.y})}}else if("path"===c.nodeName){var T=c.getTotalLength(),k="";if(T1){u=!0;break}}u?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l._pdata=i(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*r[0],e.yaxis.r2l(l.y)*r[1],e.zaxis.r2l(l.z)*r[2]]),n(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":580,"../annotations/draw":366}],373:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var a=r.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return a?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}a.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},a.rgb=function(t){return a.tinyRGB(n(t))},a.opacity=function(t){return t?n(t).getAlpha():0},a.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},a.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var i=n(e||l).toRgb(),a=1===i.a?i:{r:255*(1-i.a)+i.r*i.a,g:255*(1-i.a)+i.g*i.a,b:255*(1-i.a)+i.b*i.a},o={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},a.contrast=function(t,e,r){var i=n(t);return 1!==i.getAlpha()&&(i=n(a.combine(t,l))),(i.isDark()?e?i.lighten(e):l:r?i.darken(r):s).toString()},a.stroke=function(t,e){var r=n(e);t.style({stroke:a.tinyRGB(r),"stroke-opacity":r.getAlpha()})},a.fill=function(t,e){var r=n(e);t.style({fill:a.tinyRGB(r),"fill-opacity":r.getAlpha()})},a.clean=function(t){if(t&&"object"==typeof t){var e,r,n,i,o=Object.keys(t);for(e=0;e0?S>=I:S<=I));L++)S>D&&S0?S>=I:S<=I));L++)S>C[0]&&S1){var ot=Math.pow(10,Math.floor(Math.log(at)/Math.LN10));nt*=ot*u.roundUp(at/ot,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(et.tick0=0)}et.dtick=nt}et.domain=[$+Y,$+G-Y],et.setScale();var st=u.ensureSingle(v._infolayer,"g",e,function(t){t.classed(M.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(M.cbbg,!0),t.append("g").classed(M.cbfills,!0),t.append("g").classed(M.cblines,!0),t.append("g").classed(M.cbaxis,!0).classed(M.crisp,!0),t.append("g").classed(M.cbtitleunshift,!0).append("g").classed(M.cbtitle,!0),t.append("rect").classed(M.cboutline,!0),t.select(".cbtitle").datum(0)})});st.attr("transform","translate("+Math.round(A.l)+","+Math.round(A.t)+")");var lt=st.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(A.l)+",-"+Math.round(A.t)+")"),ut=st.select(".cbaxis"),ct=0;if(-1!==["top","bottom"].indexOf(r.title.side)){var ft,ht=A.l+(r.x+X)*A.w,dt=et.title.font.size;ft="top"===r.title.side?(1-($+G-Y))*A.h+A.t+3+.75*dt:(1-($+Y))*A.h+A.t-3-.25*dt,bt(et._id+"title",{attributes:{x:ht,y:ft,"text-anchor":"start"}})}var pt,gt,vt,mt=u.syncOrAsync([a.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.title.side)){var a=st.select(".cbtitle"),o=a.select("text"),l=[-r.outlinewidth/2,r.outlinewidth/2],c=a.select(".h"+et._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*m),c?(ct=h.bBox(c).height)>f&&(l[1]-=(ct-f)/2):o.node()&&!o.classed(M.jsPlaceholder)&&(ct=h.bBox(o.node()).height),ct){if(ct+=5,"top"===r.title.side)et.domain[1]-=ct/A.h,l[1]*=-1;else{et.domain[0]+=ct/A.h;var d=g.lineCount(o);l[1]+=(1-d)*f}a.attr("transform","translate("+l+")"),et.setScale()}}st.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(A.h*(1-et.domain[1]))+")"),ut.attr("transform","translate(0,"+Math.round(-A.t)+")");var p=st.select(".cbfills").selectAll("rect.cbfill").data(R);p.enter().append("rect").classed(M.cbfill,!0).style("stroke","none"),p.exit().remove();var y=C.map(et.c2p).map(Math.round).sort(function(t,e){return t-e});p.each(function(a,o){var s=[0===o?C[0]:(R[o]+R[o-1])/2,o===R.length-1?C[1]:(R[o]+R[o+1])/2].map(et.c2p).map(Math.round);s[1]=u.constrain(s[1]+(s[1]>s[0])?1:-1,y[0],y[1]);var l=n.select(this).attr({x:Z,width:Math.max(V,2),y:n.min(s),height:Math.max(n.max(s)-n.min(s),2)});if(r.fillgradient)h.gradient(l,t,e,"vertical",r.fillgradient,"fill");else{var c=z(a).replace("e-","");l.attr("fill",i(c).toHexString())}});var b=st.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?O:[]);return b.enter().append("path").classed(M.cbline,!0),b.exit().remove(),b.each(function(t){n.select(this).attr("d","M"+Z+","+(Math.round(et.c2p(t))+r.line.width/2%1)+"h"+V).call(h.lineGroupStyle,r.line.width,P(t),r.line.dash)}),ut.selectAll("g."+et._id+"tick,path").remove(),u.syncOrAsync([function(){var e=Z+V+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),n=s.calcTicks(et),i=s.makeTransFn(et),a=s.makeLabelFns(et,e),o=s.getTickSigns(et)[2];return s.drawTicks(t,et,{vals:"inside"===et.ticks?s.clipEnds(et,n):n,layer:ut,path:s.makeTickPath(et,e,o),transFn:i}),s.drawLabels(t,et,{vals:n,layer:ut,transFn:i,labelXFn:a.labelXFn,labelYFn:a.labelYFn,labelAnchorFn:a.labelAnchorFn})},function(){if(-1===["top","bottom"].indexOf(r.title.side)){var e=et.title.font.size,i=et._offset+et._length/2,a=A.l+(et.position||0)*A.w+("right"===et.side?10+e*(et.showticklabels?1:.5):-10-e*(et.showticklabels?.5:0));bt("h"+et._id+"title",{avoid:{selection:n.select(t).selectAll("g."+et._id+"tick"),side:r.title.side,offsetLeft:A.l,offsetTop:0,maxShift:v.width},attributes:{x:a,y:i,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},a.previousPromises,function(){var n=V+r.outlinewidth/2+h.bBox(ut.node()).width;if((j=lt.select("text")).node()&&!j.classed(M.jsPlaceholder)){var i,o=lt.select(".h"+et._id+"title-math-group").node();i=o&&-1!==["top","bottom"].indexOf(r.title.side)?h.bBox(o).width:h.bBox(lt.node()).right-Z-A.l,n=Math.max(n,i)}var s=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,l=J-K;st.select(".cbbg").attr({x:Z-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:K-W,width:Math.max(s,2),height:Math.max(l+2*W,2)}).call(d.fill,r.bgcolor).call(d.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),st.selectAll(".cboutline").attr({x:Z,y:K+r.ypad+("top"===r.title.side?ct:0),width:Math.max(V,2),height:Math.max(l-2*r.ypad-ct,2)}).call(d.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var u=({center:.5,right:1}[r.xanchor]||0)*s;st.attr("transform","translate("+(A.l-u)+","+A.t+")");var c={},f=y[r.yanchor],p=b[r.yanchor];"pixels"===r.lenmode?(c.y=r.y,c.t=l*f,c.b=l*p):(c.t=c.b=0,c.yt=r.y+r.len*f,c.yb=r.y-r.len*p);var g=y[r.xanchor],v=b[r.xanchor];if("pixels"===r.thicknessmode)c.x=r.x,c.l=s*g,c.r=s*v;else{var m=s-V;c.l=m*g,c.r=m*v,c.xl=r.x-r.thickness*g,c.xr=r.x+r.thickness*v}a.autoMargin(t,e,c)}],t);if(mt&&mt.then&&(t._promises||[]).push(mt),t._context.edits.colorbarPosition)l.init({element:st.node(),gd:t,prepFn:function(){pt=st.attr("transform"),f(st)},moveFn:function(t,e){st.attr("transform",pt+" translate("+t+","+e+")"),gt=l.align(Q+t/A.w,H,0,1,r.xanchor),vt=l.align($-e/A.h,G,0,1,r.yanchor);var n=l.getCursor(gt,vt,r.xanchor,r.yanchor);f(st,n)},doneFn:function(){if(f(st),void 0!==gt&&void 0!==vt){var e={};e[E("x")]=gt,e[E("y")]=vt,o.call("_guiRestyle",t,e,k().index)}}});return mt}function yt(t,e){return u.coerce(tt,et,w,t,e)}function bt(e,r){var n={propContainer:et,propName:E("title"),traceIndex:k().index,placeholder:v._dfltTitle.colorbar,containerGroup:st.select(".cbtitle")},i="h"===e.charAt(0)?e.substr(1):"h"+e;st.selectAll("."+i+",."+i+"-math-group").remove(),p.draw(t,e,c(n,r||{}))}v._infolayer.selectAll("g."+e).remove()}function k(){var r,n,i=e.substr(2);for(r=0;r=0?i.colorscale.sequential:i.colorscale.sequentialminus,l._colorscale=l.colorscale=p)}},{"../../lib":494}],384:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./helpers").hasColorscale;e.exports=function(t){function e(t,e){var r=t["_"+e];void 0!==r&&(t[e]=r)}function r(t,r){var i=r.container?n.nestedProperty(t,r.container).get():t;if(i){var a=i.zauto||i.cauto,o=r.min,s=r.max;(a||void 0===i[o])&&e(i,o),(a||void 0===i[s])&&e(i,s),i.autocolorscale&&e(i,"colorscale")}}for(var a=0;a=0;n--,i++){var a=t[n];r[i]=[1-a[0],a[1]]}return r}function c(t){var e={r:t[0],g:t[1],b:t[2],a:t[3]};return i(e).toRgbString()}e.exports={hasColorscale:function(t,e){var r=e?o.nestedProperty(t,e).get()||{}:t,n=r.color,i=!1;if(o.isArrayOrTypedArray(n))for(var s=0;s4/3-s?o:s}},{}],392:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":494}],393:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),i=t("has-hover"),a=t("has-passive-events"),o=t("../../registry"),s=t("../../lib"),l=t("../../plots/cartesian/constants"),u=t("../../constants/interactions"),c=e.exports={};c.align=t("./align"),c.getCursor=t("./cursor");var f=t("./unhover");function h(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function d(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}c.unhover=f.wrapped,c.unhoverRaw=f.raw,c.init=function(t){var e,r,n,f,p,g,v,m,y=t.gd,b=1,x=u.DBLCLICKDELAY,_=t.element;y._mouseDownTime||(y._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=A,a?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=A,_.addEventListener("touchstart",A,{passive:!1})):_.ontouchstart=A;var w=t.clampFn||function(t,e,r){return Math.abs(t)x&&(b=Math.max(b-1,1)),y._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(b,g),!m){var r;try{r=new MouseEvent("click",e)}catch(t){var n=d(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(y),y._dragged=!1}else y._dragged=!1}},c.coverSlip=h},{"../../constants/interactions":473,"../../lib":494,"../../plots/cartesian/constants":546,"../../registry":593,"./align":391,"./cursor":392,"./unhover":394,"has-hover":250,"has-passive-events":251,"mouse-event-offset":271}],394:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=t("../../lib/throttle"),a=t("../../lib/get_graph_div"),o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,r){(t=a(t))._fullLayout&&i.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,r)},s.raw=function(t,e){var r=t._fullLayout,i=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&i&&t.emit("plotly_unhover",{event:e,points:i}))}},{"../../lib/events":486,"../../lib/get_graph_div":491,"../../lib/throttle":518,"../fx/constants":408}],395:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],396:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("tinycolor2"),o=t("../../registry"),s=t("../color"),l=t("../colorscale"),u=t("../../lib"),c=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../constants/alignment").LINE_SPACING,d=t("../../constants/interactions").DESELECTDIM,p=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){u.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,i){t.call(v.setPosition,e,r).call(v.setSize,n,i)},v.translatePoint=function(t,e,r,n){var a=r.c2p(t.x),o=n.c2p(t.y);return!!(i(a)&&i(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",a).attr("y",o):e.attr("transform","translate("+a+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var i=n.select(this);v.translatePoint(t,i,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,i,a){e.attr("display",r.isPtWithinRange(t,i)&&n.isPtWithinRange(t,a)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,i=e.yaxis;t.each(function(e){var a=e[0].trace,o=a.xcalendar,s=a.ycalendar,l="bar"===a.type?".bartext":".point,.textpoint";t.selectAll(l).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,i,o,s)})})}},v.crispRound=function(t,e,r){return e&&i(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,i){e.style("fill","none");var a=(((t||[])[0]||{}).trace||{}).line||{},o=r||a.width||0,l=i||a.dash||"";s.stroke(e,n||a.color),v.dashLine(e,l,o)},v.lineGroupStyle=function(t,e,r,i){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=i||a.dash||"";n.select(this).call(s.stroke,r||a.color).call(v.dashLine,l,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(s.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){var e=n.select(this);t[0].trace&&e.call(s.fill,t[0].trace.fillcolor)})};var m=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(m).forEach(function(t){var e=m[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var y=v.symbolNames.length,b="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function x(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?b:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=y||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},A=n.format("~.1f"),M={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,i,o,l){for(var c=o.length,f=M[i],h=new Array(c),d=0;d=100,e.attr("d",x(c,l))}var f,h,d,p=!1;if(t.so)d=o.outlierwidth,h=o.outliercolor,f=a.outliercolor;else{var g=(o||{}).width;d=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,h="mlc"in t?t.mlcc=n.lineScale(t.mlc):u.isArrayOrTypedArray(o.color)?s.defaultLine:o.color,u.isArrayOrTypedArray(a.color)&&(f=s.defaultLine,p=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):a.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(s.stroke,f).style({"stroke-width":(d||1)+"px",fill:"none"});else{e.style("stroke-width",d+"px");var m=a.gradient,y=t.mgt;if(y?p=!0:y=m&&m.type,Array.isArray(y)&&(y=y[0],M[y]||(y=0)),y&&"none"!==y){var b=t.mgc;b?p=!0:b=m.color;var _=r.uid;p&&(_+="-"+t.i),v.gradient(e,i,_,y,[[0,b],[1,f]],"fill")}else s.fill(e,f);d&&s.stroke(e,h)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=p.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&u.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.marker||{},a=r.marker||{},s=n.marker||{},l=i.opacity,c=a.opacity,f=s.opacity,h=void 0!==c,p=void 0!==f;(u.isArrayOrTypedArray(l)||h||p)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?i.opacity:t.mo;return t.selected?h?c:e:p?f:d*e});var g=i.color,v=a.color,m=s.color;(v||m)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:m||e});var y=i.size,b=a.size,x=s.size,_=void 0!==b,w=void 0!==x;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||y/2;return t.selected?_?b/2:e:w?x/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.textfont||{},a=r.textfont||{},o=n.textfont||{},l=i.color,u=a.color,c=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||l;return t.selected?u||e:c||(u?e:s.addOpacity(e,d))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),i=e.marker||{},a=[];r.selectedOpacityFn&&a.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&a.push(function(t,e){s.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&a.push(function(t,e){var n=e.mx||i.symbol||0,a=r.selectedSizeFn(e);t.attr("d",x(v.symbolNumber(n),a)),e.mrc2=a}),a.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var i;if(e.selectedpoints){var a=v.makeSelectedTextStyleFns(e);i=a.selectedTextColorFn}t.each(function(t){var a=n.select(this),o=u.extractOption(t,e,"tx","text");if(o||0===o){var s=t.tp||e.textposition,l=E(t,e),f=i?i(t):t.tc||e.textfont.color;a.call(v.font,t.tf||e.textfont.family,l,f).text(o).call(c.convertToTspans,r).call(k,s,l,t.mrc)}else a.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var i=n.select(this),a=r.selectedTextColorFn(t),o=t.tp||e.textposition,l=E(t,e);s.fill(i,a),k(i,o,l,t.mrc2||t.mrc)})}};var S=.5;function L(t,e,r,i){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],u=Math.pow(a*a+o*o,S/2),c=Math.pow(s*s+l*l,S/2),f=(c*c*a-u*u*s)*i,h=(c*c*o-u*u*l)*i,d=3*c*(u+c),p=3*u*(u+c);return[[n.round(e[0]+(d&&f/d),2),n.round(e[1]+(d&&h/d),2)],[n.round(e[0]-(p&&f/p),2),n.round(e[1]-(p&&h/p),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],i=[];for(r=1;r=1e4&&(v.savedBBoxes={},R=0),r&&(v.savedBBoxes[r]=m),R++,u.extendFlat({},m)},v.setClipUrl=function(t,e,r){if(e){var n=r._context,i=n._exportedPlot?"":n._baseUrl||"";t.attr("clip-path","url("+i+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||0,r=r||0,a=a.replace(/(\btranslate\(.*?\);?)/,"").trim(),a=(a+=" translate("+e+", "+r+")").trim(),t[i]("transform",a),a},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||1,r=r||1,a=a.replace(/(\bscale\(.*?\);?)/,"").trim(),a=(a+=" scale("+e+", "+r+")").trim(),t[i]("transform",a),a};var z=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(z,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var I=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,i=n.select(this),a=i.select("text");if(a.node()){var o=parseFloat(a.attr("x")||0),s=parseFloat(a.attr("y")||0),l=(i.attr("transform")||"").match(I);t=1===e&&1===r?[]:["translate("+o+","+s+")","scale("+e+","+r+")","translate("+-o+","+-s+")"],l&&t.push(l),i.attr("transform",t.join(" "))}})}},{"../../constants/alignment":470,"../../constants/interactions":473,"../../constants/xmlns_namespaces":475,"../../lib":494,"../../lib/svg_text_utils":517,"../../registry":593,"../../traces/scatter/make_bubble_size_func":632,"../../traces/scatter/subtypes":639,"../color":375,"../colorscale":387,"./symbol_defs":397,d3:82,"fast-isnumeric":91,tinycolor2:341}],397:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(-.309*t,2);return"M"+e+","+a+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(-.309*e,2),u=n.round(.118*e,2),c=n.round(.809*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+u+"L"+o+","+c+"L0,"+n.round(.382*e,2)+"L-"+o+","+c+"L-"+a+","+u+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:82}],398:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],399:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../registry"),a=t("../../plots/cartesian/axes"),o=t("./compute_error");function s(t,e,r,i){var s=e["error_"+i]||{},l=[];if(s.visible&&-1!==["linear","log"].indexOf(r.type)){for(var u=o(s),c=0;c0;e.each(function(e){var f,h=e[0].trace,d=h.error_x||{},p=h.error_y||{};h.ids&&(f=function(t){return t.id});var g=o.hasMarkers(h)&&h.marker.maxdisplayed>0;p.visible||d.visible||(e=[]);var v=n.select(this).selectAll("g.errorbar").data(e,f);if(v.exit().remove(),e.length){d.visible||v.selectAll("path.xerror").remove(),p.visible||v.selectAll("path.yerror").remove(),v.style("opacity",1);var m=v.enter().append("g").classed("errorbar",!0);c&&m.style("opacity",0).transition().duration(s.duration).style("opacity",1),a.setClipUrl(v,r.layerClipId,t),v.each(function(t){var e=n.select(this),r=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),i(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),i(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,l,u);if(!g||t.vis){var a,o=e.select("path.yerror");if(p.visible&&i(r.x)&&i(r.yh)&&i(r.ys)){var f=p.width;a="M"+(r.x-f)+","+r.yh+"h"+2*f+"m-"+f+",0V"+r.ys,r.noYS||(a+="m-"+f+",0h"+2*f),!o.size()?o=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):c&&(o=o.transition().duration(s.duration).ease(s.easing)),o.attr("d",a)}else o.remove();var h=e.select("path.xerror");if(d.visible&&i(r.y)&&i(r.xh)&&i(r.xs)){var v=(d.copy_ystyle?p:d).width;a="M"+r.xh+","+(r.y-v)+"v"+2*v+"m0,-"+v+"H"+r.xs,r.noXS||(a+="m0,-"+v+"v"+2*v),!h.size()?h=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):c&&(h=h.transition().duration(s.duration).ease(s.easing)),h.attr("d",a)}else h.remove()}})}})}},{"../../traces/scatter/subtypes":639,"../drawing":396,d3:82,"fast-isnumeric":91}],404:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":375,d3:82}],405:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":567}],406:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry");function a(t,e,r,i){i=i||n.identity,Array.isArray(t)&&(e[0][r]=i(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var s=0;s=0&&r.indexw[0]._length||et<0||et>A[0]._length)return h.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+A[0]._offset,I="xval"in e?g.flat(l,e.xval):g.p2c(w,tt),N="yval"in e?g.flat(l,e.yval):g.p2c(A,et),!i(I[0])||!i(N[0]))return o.warn("Fx.hover failed",e,t),h.unhoverRaw(t,e)}var it=1/0;for(F=0;F<$.length;F++)if((j=$[F])&&j[0]&&j[0].trace&&!0===j[0].trace.visible&&(B=j[0].trace,-1===["carpet","contourcarpet"].indexOf(B._module.name))){if("splom"===B.type?U=l[V=0]:(U=g.getSubplot(B),V=l.indexOf(U)),H=z,X={cd:j,trace:B,xa:w[V],ya:A[V],maxHoverDistance:Y,maxSpikeDistance:Z,index:!1,distance:Math.min(it,Y),spikeDistance:1/0,xSpike:void 0,ySpike:void 0,color:f.defaultLine,name:B.name,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},c[U]&&(X.subplot=c[U]._subplot),c._splomScenes&&c._splomScenes[B.uid]&&(X.scene=c._splomScenes[B.uid]),W=Q.length,"array"===H){var at=e[F];"pointNumber"in at?(X.index=at.pointNumber,H="closest"):(H="","xval"in at&&(q=at.xval,H="x"),"yval"in at&&(G=at.yval,H=H?"closest":"y"))}else q=I[V],G=N[V];if(0!==Y)if(B._module&&B._module.hoverPoints){var ot=B._module.hoverPoints(X,q,G,H,c._hoverlayer);if(ot)for(var st,lt=0;ltW&&(Q.splice(0,W),it=Q[0].distance),y&&0!==Z&&0===Q.length){X.distance=Z,X.index=!1;var ut=B._module.hoverPoints(X,q,G,"closest",c._hoverlayer);if(ut&&(ut=ut.filter(function(t){return t.spikeDistance<=Z})),ut&&ut.length){var ct,ft=ut.filter(function(t){return t.xa.showspikes});if(ft.length){var ht=ft[0];i(ht.x0)&&i(ht.y0)&&(ct=vt(ht),(!J.vLinePoint||J.vLinePoint.spikeDistance>ct.spikeDistance)&&(J.vLinePoint=ct))}var dt=ut.filter(function(t){return t.ya.showspikes});if(dt.length){var pt=dt[0];i(pt.x0)&&i(pt.y0)&&(ct=vt(pt),(!J.hLinePoint||J.hLinePoint.spikeDistance>ct.spikeDistance)&&(J.hLinePoint=ct))}}}}function gt(t,e){for(var r,n=null,i=1/0,a=0;a1||Q.length>1)||"closest"===z&&K&&Q.length>1,Ot=f.combine(c.plot_bgcolor||f.background,c.paper_bgcolor),Rt={hovermode:z,rotateLabels:Ct,bgColor:Ot,container:c._hoverlayer,outerContainer:c._paperdiv,commonLabelOpts:c.hoverlabel,hoverdistance:c.hoverdistance},Pt=T(Q,Rt,t);if(function(t,e,r){var n,i,a,o,s,l,u,c=0,f=1,h=t.map(function(t,n){var i=t[e],a="x"===i._id.charAt(0),o=i.range;return!n&&o&&o[0]>o[1]!==a&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(a?b:1)/2,pmin:0,pmax:a?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function d(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(a<.01)){if(i<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var u=0;for(o=0;oe.pmax&&u++;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos>e.pmax-1&&(l.del=!0,u--);for(o=0;o=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos+l.dp+l.size>e.pmax&&(l.del=!0,u--)}}}for(;!n&&c<=t.length;){for(c++,n=!0,o=0;o.01&&v.pmin===m.pmin&&v.pmax===m.pmax){for(s=g.length-1;s>=0;s--)g[s].dp+=i;for(p.push.apply(p,g),h.splice(o+1,1),u=0,s=p.length-1;s>=0;s--)u+=p[s].dp;for(a=u/p.length,s=p.length-1;s>=0;s--)p[s].dp-=a;n=!1}else o++}h.forEach(d)}for(o=h.length-1;o>=0;o--){var y=h[o];for(s=y.length-1;s>=0;s--){var x=y[s],_=t[x.i];_.offset=x.dp,_.del=x.del}}}(Q,Ct?"xa":"ya",c),k(Pt,Ct),e.target&&e.target.tagName){var zt=p.getComponentMethod("annotations","hasClickToShow")(t,kt);u(n.select(e.target),zt?"pointer":"")}if(!e.target||a||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber)||String(i.pointNumbers)!==String(a.pointNumbers))return!0}return!1}(t,0,Tt))return;Tt&&t.emit("plotly_unhover",{event:e,points:Tt});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:A,xvals:I,yvals:N})}(t,e,r,a)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1},i=n.select(e.container),a=e.outerContainer?n.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=T([r],o,e.gd);return k(s,o.rotateLabels),s.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1}}),i=n.select(e.container),a=e.outerContainer?n.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=T(r,o,e.gd),l=0;return s.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5([\s\S]*)<\/extra>/;function T(t,e,r){var i=e.hovermode,a=e.rotateLabels,s=e.bgColor,u=e.container,h=e.outerContainer,d=e.commonLabelOpts||{},p=e.fontFamily||v.HOVERFONT,g=e.fontSize||v.HOVERFONTSIZE,y=t[0],b=y.xa,x=y.ya,_="y"===i?"yLabel":"xLabel",T=y[_],k=(String(T)||"").split(" ")[0],E=h.node().getBoundingClientRect(),S=E.top,L=E.width,C=E.height,O=void 0!==T&&y.distance<=e.hoverdistance&&("x"===i||"y"===i);if(O){var R,P,z=!0;for(R=0;R-1&&u.length>x&&(u=x>3?u.substr(0,x-3)+"...":u.substr(0,x))}void 0!==t.zLabel?(void 0!==t.xLabel&&(h+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(h+="y: "+t.yLabel+"
"),h+=(h?"z: ":"")+t.zLabel):O&&t[i+"Label"]===T?h=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(h=t.yLabel):h=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(h+=(h?"
":"")+t.text),void 0!==t.extraText&&(h+=(h?"
":"")+t.extraText),""===h&&(""===u&&e.remove(),h=u);var _=t.hovertemplate||!1,k=t.hovertemplateLabels||t,E=t.eventData[0]||{};_&&(h=(h=o.hovertemplateString(_,k,E)).replace(M,function(t,e){return u=e,""}));var R=e.select("text.nums").call(c.font,t.fontFamily||p,t.fontSize||g,t.fontColor||b).text(h).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),P=e.select("text.name"),z=0;u&&u!==h?(P.call(c.font,t.fontFamily||p,t.fontSize||g,y).text(u).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),z=P.node().getBoundingClientRect().width+2*A):(P.remove(),e.select("rect").remove()),e.select("path").style({fill:v,stroke:b});var I,N,D=R.node().getBoundingClientRect(),F=t.xa._offset+(t.x0+t.x1)/2,j=t.ya._offset+(t.y0+t.y1)/2,B=Math.abs(t.x1-t.x0),U=Math.abs(t.y1-t.y0),V=D.width+w+A+z;t.ty0=S-D.top,t.bx=D.width+2*A,t.by=D.height+2*A,t.anchor="start",t.txwidth=D.width,t.tx2width=z,t.offset=0,a?(t.pos=F,I=j+U/2+V<=C,N=j-U/2-V>=0,"top"!==t.idealAlign&&I||!N?I?(j+=U/2,t.anchor="start"):t.anchor="middle":(j-=U/2,t.anchor="end")):(t.pos=j,I=F+B/2+V<=L,N=F-B/2-V>=0,"left"!==t.idealAlign&&I||!N?I?(F+=B/2,t.anchor="start"):t.anchor="middle":(F-=B/2,t.anchor="end")),R.attr("text-anchor",t.anchor),z&&P.attr("text-anchor",t.anchor),e.attr("transform","translate("+F+","+j+")"+(a?"rotate("+m+")":""))}),D}function k(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var i="end"===t.anchor?-1:1,a=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],s=o*(w+A),u=s+o*(t.txwidth+A),f=0,h=t.offset;"middle"===t.anchor&&(s-=t.tx2width/2,u+=t.txwidth/2+A),e&&(h*=-_,f=t.offset*x),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(h-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(i*w+f)+","+(w+h)+"v"+(t.by/2-w)+"h"+i*t.bx+"v-"+t.by+"H"+(i*w+f)+"V"+(h-w)+"Z"),a.call(l.positionText,s+f,h+t.ty0-t.by/2+A),t.tx2width&&(r.select("text.name").call(l.positionText,u+o*A+f,h+t.ty0-t.by/2+A),r.select("rect").call(c.setRect,u+(o-1)*t.tx2width/2+f,h-t.by/2-1,t.tx2width,t.by+2))}})}function E(t,e){var r=t.index,n=t.trace||{},i=t.cd[0],a=t.cd[r]||{},s=Array.isArray(r)?function(t,e){return o.castOption(i,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(a,n,t,e)};function l(e,r,n){var i=s(r,n);i&&(t[e]=i)}if(l("hoverinfo","hi","hoverinfo"),l("bgcolor","hbg","hoverlabel.bgcolor"),l("borderColor","hbc","hoverlabel.bordercolor"),l("fontFamily","htf","hoverlabel.font.family"),l("fontSize","hts","hoverlabel.font.size"),l("fontColor","htc","hoverlabel.font.color"),l("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:d.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:d.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var u=d.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+u+" / -"+d.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+u,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var c=d.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+c+" / -"+d.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+c,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return f&&"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function S(t,e){var r,n,i=e.container,o=e.fullLayout,s=e.event,l=!!t.hLinePoint,u=!!t.vLinePoint;if(i.selectAll(".spikeline").remove(),u||l){var h=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(l){var d,p,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(d=s.pointerX,p=s.pointerY):(d=r._offset+g.x,p=n._offset+g.y);var v,m,y=a.readability(g.color,h)<1.5?f.contrast(h):g.color,b=n.spikemode,x=n.spikethickness,_=n.spikecolor||y,w=n._boundingBox,A=(w.left+w.right)/20){for(var n=[],i=0;i-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){h||d||p||"independent"===M("pattern")&&(h=!0),v._hasSubplotGrid=h;var b,x,_="top to bottom"===M("roworder"),w=h?.2:.1,A=h?.3:.1;g&&e._splomGridDflt&&(b=e._splomGridDflt.xside,x=e._splomGridDflt.yside),v._domains={x:c("x",M,w,b,y),y:c("y",M,A,x,m,_)}}else delete e.grid}function M(t,e){return n.coerce(r,v,l,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,i,a,o,s,l,c,h=t.grid||{},d=e._subplots,p=r._hasSubplotGrid,g=r.rows,v=r.columns,m="independent"===r.pattern,y=r._axisMap={};if(p){var b=h.subplots||[];l=r.subplots=new Array(g);var x=1;for(n=0;n1);if(!1!==b||d.uirevision){var x=a.newContainer(e,"legend");if(w("uirevision",e.uirevision),!1!==b){if(w("bgcolor",e.paper_bgcolor),w("bordercolor"),w("borderwidth"),i.coerceFont(w,"font",e.font),w("orientation"),"h"===x.orientation){var _=t.xaxis;n.getComponentMethod("rangeslider","isVisible")(_)?(u=0,f="left",c=1.1,h="bottom"):(u=0,f="left",c=-.1,h="top")}w("traceorder",v),l.isGrouped(e.legend)&&w("tracegroupgap"),w("x",u),w("xanchor",f),w("y",c),w("yanchor",h),w("valign"),i.noneOrAll(d,x,["x","y"])}}function w(t,e){return i.coerce(d,x,o,t,e)}}},{"../../lib":494,"../../plot_api/plot_template":530,"../../plots/layout_attributes":583,"../../registry":593,"./attributes":424,"./helpers":430}],427:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib/events"),l=t("../dragelement"),u=t("../drawing"),c=t("../color"),f=t("../../lib/svg_text_utils"),h=t("./handle_click"),d=t("./constants"),p=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,m=g.FROM_TL,y=g.FROM_BR,b=t("./get_legend_data"),x=t("./style"),_=t("./helpers"),w=p.DBLCLICKDELAY;function A(t,e,r,n,i){var a=r.data()[0][0].trace,o={event:i,node:r.node(),curveNumber:a.index,expandedIndex:a._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(a._group&&(o.group=a._group),"pie"===a.type&&(o.label=r.datum()[0].label),!1!==s.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){h(r,t,n)},w);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==s.triggerHandler(t,"plotly_legenddoubleclick",o)&&h(r,t,n)}}function M(t,e,r){var n=t.data()[0][0],a=e._fullLayout,s=n.trace,l=o.traceIs(s,"pie"),c=s.index,h=l?n.label:s.name,p=e._context.edits.legendText&&!l,g=i.ensureSingle(t,"text","legendtext");function m(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,i,a=t.select("g[class*=math-group]"),o=a.node(),s=e._fullLayout.legend.font.size*v;if(o){var l=u.bBox(o);n=l.height,i=l.width,u.setTranslate(a,0,n/4)}else{var c=t.select(".legendtext"),h=f.lineCount(c),p=c.node();n=s*h,i=p?u.bBox(p).width:0;var g=s*(.3+(1-h)/2);f.positionText(c,d.textOffsetX,g),r.lineHeight=s}n=Math.max(n,16)+3,r.height=n,r.width=i}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(u.font,a.legend.font).text(p?T(h,r):h),f.positionText(g,d.textOffsetX,0),p?g.call(f.makeEditable,{gd:e,text:h}).call(m).on("edit",function(t){this.text(T(t,r)).call(m);var a=n.trace._fullInput||{},s={};if(o.hasTransform(a,"groupby")){var l=o.getTransformIndices(a,"groupby"),u=l[l.length-1],f=i.keyedContainer(a,"transforms["+u+"].styles","target","value.name");f.set(n.trace._group,t),s=f.constructUpdate()}else s.name=t;return o.call("_guiRestyle",e,s,c)}):m(g)}function T(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function k(t,e){var r,a=1,o=i.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(c.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimew&&(a=Math.max(a-1,1)),A(e,r,t,a,n.event)}})}function E(t,e,r){var i=t._fullLayout,a=i.legend,o=a.borderwidth,s=_.isGrouped(a),l=0;if(a._width=0,a._height=0,_.isVertical(a))s&&e.each(function(t,e){u.setTranslate(this,0,e*a.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;u.setTranslate(this,o,5+o+a._height+r/2),a._height+=r,a._width=Math.max(a._width,n)}),a._width+=45+2*o,a._height+=10+2*o,s&&(a._height+=(a._lgroupsLength-1)*a.tracegroupgap),l=40;else if(s){for(var c=[a._width],f=e.data(),h=0,d=f.length;ho+w-A,r.each(function(t){var e=t[0],r=v?40+t[0].width:b;o+x+A+r>i._size.w&&(x=0,m+=y,a._height=a._height+y,y=0),u.setTranslate(this,o+x,5+o+e.height/2+m),a._width+=A+r,a._height=Math.max(a._height,e.height),x+=A+r,y=Math.max(e.height,y)}),a._width+=2*o,a._height+=10+2*o}a._width=Math.ceil(a._width),a._height=Math.ceil(a._height);var M=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");u.setRect(r,0,-e.height/2,(M?0:a._width)+l,e.height)})}function S(t){var e=t._fullLayout.legend,r="left";i.isRightAnchor(e)?r="right":i.isCenterAnchor(e)&&(r="center");var n="top";i.isBottomAnchor(e)?n="bottom":i.isMiddleAnchor(e)&&(n="middle"),a.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*m[r],r:e._width*y[r],b:e._height*y[n],t:e._height*m[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var s=e.legend,f=e.showlegend&&b(t.calcdata,s),h=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void a.autoMargin(t,"legend");for(var p=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";i.isRightAnchor(e)?r="right":i.isCenterAnchor(e)&&(r="center");a.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*m[r],r:e._width*y[r],b:0,t:0})}(t):S(t);var h=e._size,p=h.l+h.w*s.x,g=h.t+h.h*(1-s.y);i.isRightAnchor(s)?p-=s._width:i.isCenterAnchor(s)&&(p-=s._width/2),i.isBottomAnchor(s)?g-=s._height:i.isMiddleAnchor(s)&&(g-=s._height/2);var v=s._width,b=h.w;v>b?(p=h.l,v=b):(p+v>c&&(p=c-v),p<0&&(p=0),v=Math.min(c-p,s._width));var x,_,w,M,T=s._height,k=h.h;if(T>k?(g=h.t,T=k):(g+T>f&&(g=f-T),g<0&&(g=0),T=Math.min(f-g,s._height)),u.setTranslate(C,p,g),z.on(".drag",null),C.on("wheel",null),s._height<=T||t._context.staticPlot)R.attr({width:v-s.borderwidth,height:T-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),u.setTranslate(P,0,0),O.select("rect").attr({width:v-2*s.borderwidth,height:T-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth}),u.setClipUrl(P,r,t),u.setRect(z,0,0,0,0),delete s._scrollY;else{var D,F,j=Math.max(d.scrollBarMinHeight,T*T/s._height),B=T-j-2*d.scrollBarMargin,U=s._height-T,V=B/U,H=Math.min(s._scrollY||0,U);R.attr({width:v-2*s.borderwidth+d.scrollBarWidth+d.scrollBarMargin,height:T-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),O.select("rect").attr({width:v-2*s.borderwidth+d.scrollBarWidth+d.scrollBarMargin,height:T-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth+H}),u.setClipUrl(P,r,t),G(H,j,V),C.on("wheel",function(){G(H=i.constrain(s._scrollY+n.event.deltaY/B*U,0,U),j,V),0!==H&&H!==U&&n.event.preventDefault()});var q=n.behavior.drag().on("dragstart",function(){D=n.event.sourceEvent.clientY,F=H}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||G(H=i.constrain((t.clientY-D)/V+F,0,U),j,V)});z.call(q)}function G(e,r,n){s._scrollY=t._fullLayout.legend._scrollY=e,u.setTranslate(P,0,-e),u.setRect(z,v,d.scrollBarMargin+e*n,d.scrollBarWidth,r),O.select("rect").attr({y:s.borderwidth+e})}t._context.edits.legendPosition&&(C.classed("cursor-move",!0),l.init({element:C.node(),gd:t,prepFn:function(){var t=u.getTranslate(C);w=t.x,M=t.y},moveFn:function(t,e){var r=w+t,n=M+e;u.setTranslate(C,r,n),x=l.align(r,0,h.l,h.l+h.w,s.xanchor),_=l.align(n,0,h.t+h.h,h.t,s.yanchor)},doneFn:function(){void 0!==x&&void 0!==_&&o.call("_guiRelayout",t,{"legend.x":x,"legend.y":_})},clickFn:function(r,n){var i=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});i.size()>0&&A(t,C,i,r,n)}}))}],t)}}},{"../../constants/alignment":470,"../../constants/interactions":473,"../../lib":494,"../../lib/events":486,"../../lib/svg_text_utils":517,"../../plots/plots":585,"../../registry":593,"../color":375,"../dragelement":393,"../drawing":396,"./constants":425,"./get_legend_data":428,"./handle_click":429,"./helpers":430,"./style":432,d3:82}],428:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("./helpers");e.exports=function(t,e){var r,a,o={},s=[],l=!1,u={},c=0;function f(t,r){if(""!==t&&i.isGrouped(e))-1===s.indexOf(t)?(s.push(t),l=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+c;s.push(n),o[n]=[[r]],c++}}for(r=0;rr[1])return r[1]}return i}function p(t){return t[0]}if(c||f||h){var g={},v={};if(c){g.mc=d("marker.color",p),g.mx=d("marker.symbol",p),g.mo=d("marker.opacity",a.mean,[.2,1]),g.mlc=d("marker.line.color",p),g.mlw=d("marker.line.width",a.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var m=d("marker.size",a.mean,[2,16]);g.ms=m,v.marker.size=m}h&&(v.line={width:d("line.width",p,[0,10])}),f&&(g.tx="Aa",g.tp=d("textposition",p),g.ts=10,g.tc=d("textfont.color",p),g.tf=d("textfont.family",p)),r=[a.minExtend(s,g)],(i=a.minExtend(u,v)).selectedpoints=null}var y=n.select(this).select("g.legendpoints"),b=y.selectAll("path.scatterpts").data(c?r:[]);b.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),b.exit().remove(),b.call(o.pointStyle,i,e),c&&(r[0].mrc=3);var x=y.selectAll("g.pointtext").data(f?r:[]);x.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),x.exit().remove(),x.selectAll("text").call(o.textPointStyle,i,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var i=e[r?"increasing":"decreasing"],a=i.line.width,o=n.select(this);o.style("stroke-width",a+"px").call(s.fill,i.fillcolor),a&&s.stroke(o,i.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var i=e[r?"increasing":"decreasing"],a=i.line.width,l=n.select(this);l.style("fill","none").call(o.dashLine,i.line.dash,a),a&&s.stroke(l,i.line.color)})})}},{"../../lib":494,"../../registry":593,"../../traces/pie/style_one":613,"../../traces/scatter/subtypes":639,"../color":375,"../drawing":396,d3:82}],433:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),s=t("../../../build/ploticon"),l=o._,u=e.exports={};function c(t,e){var r,i,o=e.currentTarget,s=o.getAttribute("data-attr"),l=o.getAttribute("data-val")||!0,u=t._fullLayout,c={},f=a.list(t,null,!0),h="on";if("zoom"===s){var d,p="in"===l?.5:2,g=(1+p)/2,v=(1-p)/2;for(i=0;i1?(A=["toggleHover"],M=["resetViews"]):h?(w=["zoomInGeo","zoomOutGeo"],A=["hoverClosestGeo"],M=["resetGeo"]):f?(A=["hoverClosest3d"],M=["resetCameraDefault3d","resetCameraLastSave3d"]):v?(A=["toggleHover"],M=["resetViewMapbox"]):A=p?["hoverClosestGl2d"]:d?["hoverClosestPie"]:["toggleHover"];c&&(A=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!c&&!p||y||(w=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==M[0]&&(M=["resetScale2d"]));f?T=["zoom3d","pan3d","orbitRotation","tableRotation"]:(c||p)&&!y||g?T=["zoom2d","pan2d"]:v||h?T=["pan2d"]:m&&(T=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),i=0,a=0;a0?h+u:u;return{ppad:u,ppadplus:c?p:g,ppadminus:c?g:p}}return{ppad:u}}function c(t,e,r,n,i){var s="category"===t.type||"multicategory"===t.type?t.r2c:t.d2c;if(void 0!==e)return[s(e),s(r)];if(n){var l,u,c,f,h=1/0,d=-1/0,p=n.match(a.segmentRE);for("date"===t.type&&(s=o.decodeDate(s)),l=0;ld&&(d=f)));return d>=h?[h,d]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:I?H(r.xanchor)+r.x0:H(r.x0),cy:N?q(r.yanchor)-r.y0:q(r.y0),r:a}).style(i).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:I?H(r.xanchor)+r.x1:H(r.x1),cy:N?q(r.yanchor)-r.y1:q(r.y1),r:a}).style(i).classed("cursor-grab",!0),n}():e,Y={element:W.node(),gd:t,prepFn:function(n){I&&(_=H(r.xanchor));N&&(w=q(r.yanchor));"path"===r.type?O=r.path:(m=I?r.x0:H(r.x0),y=N?r.y0:q(r.y0),b=I?r.x1:H(r.x1),x=N?r.y1:q(r.y1));mx?(A=y,E="y0",M=x,S="y1"):(A=x,E="y1",M=y,S="y0");Z(n),J(d,r),function(t,e,r){var n=e.xref,i=e.yref,o=a.getFromId(r,n),l=a.getFromId(r,i),u="";"paper"===n||o.autorange||(u+=n);"paper"===i||l.autorange||(u+=i);s.setClipUrl(t,u?"clip"+r._fullLayout._uid+u:null,r)}(e,r,t),Y.moveFn="move"===R?Q:$},doneFn:function(){c(e),K(d),p(e,t,r),n.call("_guiRelayout",t,j.getUpdateObj())},clickFn:function(){K(d)}};function Z(t){if(D)R="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Y.element.getBoundingClientRect(),n=r.right-r.left,i=r.bottom-r.top,a=t.clientX-r.left,o=t.clientY-r.top,s=!F&&n>P&&i>z&&!t.shiftKey?u.getCursor(a/n,1-o/i):"move";c(e,s),R=s.split("-")[0]}}function Q(n,i){if("path"===r.type){var a=function(t){return t},o=a,s=a;I?B("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(H(t)+n)},U&&"date"===U.type&&(o=h.encodeDate(o))),N?B("yanchor",r.yanchor=X(w+i)):(s=function(t){return X(q(t)+i)},V&&"date"===V.type&&(s=h.encodeDate(s))),B("path",r.path=v(O,o,s))}else I?B("xanchor",r.xanchor=G(_+n)):(B("x0",r.x0=G(m+n)),B("x1",r.x1=G(b+n))),N?B("yanchor",r.yanchor=X(w+i)):(B("y0",r.y0=X(y+i)),B("y1",r.y1=X(x+i)));e.attr("d",g(t,r)),J(d,r)}function $(n,i){if(F){var a=function(t){return t},o=a,s=a;I?B("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(H(t)+n)},U&&"date"===U.type&&(o=h.encodeDate(o))),N?B("yanchor",r.yanchor=X(w+i)):(s=function(t){return X(q(t)+i)},V&&"date"===V.type&&(s=h.encodeDate(s))),B("path",r.path=v(O,o,s))}else if(D){if("resize-over-start-point"===R){var l=m+n,u=N?y-i:y+i;B("x0",r.x0=I?l:G(l)),B("y0",r.y0=N?u:X(u))}else if("resize-over-end-point"===R){var c=b+n,f=N?x-i:x+i;B("x1",r.x1=I?c:G(c)),B("y1",r.y1=N?f:X(f))}}else{var p=~R.indexOf("n")?A+i:A,j=~R.indexOf("s")?M+i:M,W=~R.indexOf("w")?T+n:T,Y=~R.indexOf("e")?k+n:k;~R.indexOf("n")&&N&&(p=A-i),~R.indexOf("s")&&N&&(j=M-i),(!N&&j-p>z||N&&p-j>z)&&(B(E,r[E]=N?p:X(p)),B(S,r[S]=N?j:X(j))),Y-W>P&&(B(L,r[L]=I?W:G(W)),B(C,r[C]=I?Y:G(Y)))}e.attr("d",g(t,r)),J(d,r)}function J(t,e){(I||N)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var a=H(I?e.xanchor:i.midRange(r?[e.x0,e.x1]:h.extractPathCoords(e.path,f.paramIsX))),o=q(N?e.yanchor:i.midRange(r?[e.y0,e.y1]:h.extractPathCoords(e.path,f.paramIsY)));if(a=h.roundPositionForSharpStrokeRendering(a,1),o=h.roundPositionForSharpStrokeRendering(o,1),I&&N){var s="M"+(a-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",s)}else if(I){var l="M"+(a-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",l)}else{var u="M"+(a-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",u)}}()}function K(t){t.selectAll(".visual-cue").remove()}u.init(Y),W.node().onmousemove=Z}(t,b,r,e,d)}}function p(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");s.setClipUrl(t,n?"clip"+e._fullLayout._uid+n:null,e)}function g(t,e){var r,n,o,s,l,u,c,d,p=e.type,g=a.getFromId(t,e.xref),v=a.getFromId(t,e.yref),m=t._fullLayout._size;if(g?(r=h.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return m.l+m.w*t},v?(o=h.shapePositionToRange(v),s=function(t){return v._offset+v.r2p(o(t,!0))}):s=function(t){return m.t+m.h*(1-t)},"path"===p)return g&&"date"===g.type&&(n=h.decodeDate(n)),v&&"date"===v.type&&(s=h.decodeDate(s)),function(t,e,r){var n=t.path,a=t.xsizemode,o=t.ysizemode,s=t.xanchor,l=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,u=t.charAt(0),c=f.paramIsX[u],h=f.paramIsY[u],d=f.numParams[u],p=t.substr(1).replace(f.paramRE,function(t){return c[n]?t="pixel"===a?e(s)+Number(t):e(t):h[n]&&(t="pixel"===o?r(l)-Number(t):r(t)),++n>d&&(t="X"),t});return n>d&&(p=p.replace(/[\s,]*X.*/,""),i.log("Ignoring extra params in segment "+t)),u+p})}(e,n,s);if("pixel"===e.xsizemode){var y=n(e.xanchor);l=y+e.x0,u=y+e.x1}else l=n(e.x0),u=n(e.x1);if("pixel"===e.ysizemode){var b=s(e.yanchor);c=b-e.y0,d=b-e.y1}else c=s(e.y0),d=s(e.y1);if("line"===p)return"M"+l+","+c+"L"+u+","+d;if("rect"===p)return"M"+l+","+c+"H"+u+"V"+d+"H"+l+"Z";var x=(l+u)/2,_=(c+d)/2,w=Math.abs(x-l),A=Math.abs(_-c),M="A"+w+","+A,T=x+w+","+_;return"M"+T+M+" 0 1,1 "+(x+","+(_-A))+M+" 0 0,1 "+T+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,i=t.charAt(0),a=f.paramIsX[i],o=f.paramIsY[i],s=f.numParams[i];return i+t.substr(1).replace(f.paramRE,function(t){return n>=s?t:(a[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var i=0;i0&&(s=s.transition().duration(e.transition.duration).ease(e.transition.easing)),s.attr("transform","translate("+(o-.5*c.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function E(t,e){var r=t._dims;return r.inputAreaStart+c.stepInset+(r.inputAreaLength-2*c.stepInset)*Math.min(1,Math.max(0,e))}function S(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-c.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*c.stepInset-2*r.inputAreaStart)))}function L(t,e,r){var n=r._dims,i=s.ensureSingle(t,"rect",c.railTouchRectClass,function(n){n.call(M,e,t,r).style("pointer-events","all")});i.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,c.tickOffset+r.ticklen+n.labelHeight)}).call(a.fill,r.bgcolor).attr("opacity",0),o.setTranslate(i,0,n.currentValueTotalHeight)}function C(t,e){var r=e._dims,n=r.inputAreaLength-2*c.railInset,i=s.ensureSingle(t,"rect",c.railRectClass);i.attr({width:n,height:c.railWidth,rx:c.railRadius,ry:c.railRadius,"shape-rendering":"crispEdges"}).call(a.stroke,e.bordercolor).call(a.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(i,c.railInset,.5*(r.inputAreaWidth-c.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[c.name],n=[],i=0;i0?[0]:[]);function s(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),i.autoMargin(t,g(e))}if(a.enter().append("g").classed(c.containerClassName,!0).style("cursor","ew-resize"),a.exit().each(function(){n.select(this).selectAll("g."+c.groupClassName).each(s)}).remove(),0!==r.length){var l=a.selectAll("g."+c.groupClassName).data(r,v);l.enter().append("g").classed(c.groupClassName,!0),l.exit().each(s).remove();for(var u=0;u0||h<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[y.side];e.attr("transform","translate("+g+")")}}}P.call(z),O&&(k?P.on(".opacity",null):(A=0,M=!0,P.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),P.call(c.makeEditable,{gd:t}).on("edit",function(e){void 0!==m?o.call("_guiRestyle",t,g,e,m):o.call("_guiRelayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(z)}).on("input",function(t){this.text(t||" ").call(c.positionText,b.x,b.y)}));return P.classed("js-placeholder",M),_}};var h=/ [XY][0-9]* /},{"../../constants/interactions":473,"../../lib":494,"../../lib/svg_text_utils":517,"../../plots/plots":585,"../../registry":593,"../color":375,"../drawing":396,d3:82,"fast-isnumeric":91}],464:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes"),l=t("../../plot_api/plot_template").templatedArray,u=l("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(l("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:u,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:a(s({editType:"arraydraw"}),{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":487,"../../plot_api/edit_types":523,"../../plot_api/plot_template":530,"../../plots/font_attributes":567,"../../plots/pad_attributes":584,"../color/attributes":374}],465:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],466:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/array_container_defaults"),a=t("./attributes"),o=t("./constants").name,s=a.buttons;function l(t,e,r){function o(r,i){return n.coerce(t,e,a,r,i)}o("visible",i(t,e,{name:"buttons",handleItemDefaults:u}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function u(t,e){function r(r,i){return n.coerce(t,e,s,r,i)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){i(t,e,{name:o,handleItemDefaults:l})}},{"../../lib":494,"../../plots/array_container_defaults":536,"./attributes":464,"./constants":465}],467:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plots/plots"),a=t("../color"),o=t("../drawing"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../../plot_api/plot_template").arrayEditor,c=t("../../constants/alignment").LINE_SPACING,f=t("./constants"),h=t("./scrollbox");function d(t){return t._index}function p(t,e){return+t.attr(f.menuIndexAttrName)===e._index}function g(t,e,r,n,i,a,o,s){e.active=o,u(t.layout,f.name,e).applyUpdate("active",o),"buttons"===e.type?m(t,n,null,null,e):"dropdown"===e.type&&(i.attr(f.menuIndexAttrName,"-1"),v(t,n,i,a,e),s||m(t,n,i,a,e))}function v(t,e,r,n,i){var a=s.ensureSingle(e,"g",f.headerClassName,function(t){t.style("pointer-events","all")}),l=i._dims,u=i.active,c=i.buttons[u]||f.blankHeaderOpts,h={y:i.pad.t,yPad:0,x:i.pad.l,xPad:0,index:0},d={width:l.headerWidth,height:l.headerHeight};a.call(y,i,c,t).call(k,i,h,d),s.ensureSingle(e,"text",f.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,i.font).text(f.arrowSymbol[i.direction])}).attr({x:l.headerWidth-f.arrowOffsetX+i.pad.l,y:l.headerHeight/2+f.textOffsetY+i.pad.t}),a.on("click",function(){r.call(E,String(p(r,i)?-1:i._index)),m(t,e,r,n,i)}),a.on("mouseover",function(){a.call(w)}),a.on("mouseout",function(){a.call(A,i)}),o.setTranslate(e,l.lx,l.ly)}function m(t,e,r,a,o){r||(r=e).attr("pointer-events","all");var l=function(t){return-1==+t.attr(f.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,u="dropdown"===o.type?f.dropdownButtonClassName:f.buttonClassName,c=r.selectAll("g."+u).data(s.filterVisible(l)),h=c.enter().append("g").classed(u,!0),d=c.exit();"dropdown"===o.type?(h.attr("opacity","0").transition().attr("opacity","1"),d.transition().attr("opacity","0").remove()):d.remove();var p=0,v=0,m=o._dims,b=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(b?v=m.headerHeight+f.gapButtonHeader:p=m.headerWidth+f.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(v=-f.gapButtonHeader+f.gapButton-m.openHeight),"dropdown"===o.type&&"left"===o.direction&&(p=-f.gapButtonHeader+f.gapButton-m.openWidth);var x={x:m.lx+p+o.pad.l,y:m.ly+v+o.pad.t,yPad:f.gapButton,xPad:f.gapButton,index:0},M={l:x.x+o.borderwidth,t:x.y+o.borderwidth};c.each(function(s,l){var u=n.select(this);u.call(y,o,s,t).call(k,o,x),u.on("click",function(){n.event.defaultPrevented||(g(t,o,0,e,r,a,l),s.execute&&i.executeAPICommand(t,s.method,s.args),t.emit("plotly_buttonclicked",{menu:o,button:s,active:o.active}))}),u.on("mouseover",function(){u.call(w)}),u.on("mouseout",function(){u.call(A,o),c.call(_,o)})}),c.call(_,o),b?(M.w=Math.max(m.openWidth,m.headerWidth),M.h=x.y-M.t):(M.w=x.x-M.l,M.h=Math.max(m.openHeight,m.headerHeight)),M.direction=o.direction,a&&(c.size()?function(t,e,r,n,i,a){var o,s,l,u=i.direction,c="up"===u||"down"===u,h=i._dims,d=i.active;if(c)for(s=0,l=0;l0?[0]:[]);if(o.enter().append("g").classed(f.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+f.headerGroupClassName).each(a)}).remove(),0!==r.length){var l=o.selectAll("g."+f.headerGroupClassName).data(r,d);l.enter().append("g").classed(f.headerGroupClassName,!0);for(var u=s.ensureSingle(o,"g",f.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),c=0;cw,T=s.barLength+2*s.barPad,k=s.barWidth+2*s.barPad,E=p,S=v+m;S+k>u&&(S=u-k);var L=this.container.selectAll("rect.scrollbar-horizontal").data(M?[0]:[]);L.exit().on(".drag",null).remove(),L.enter().append("rect").classed("scrollbar-horizontal",!0).call(i.fill,s.barColor),M?(this.hbar=L.attr({rx:s.barRadius,ry:s.barRadius,x:E,y:S,width:T,height:k}),this._hbarXMin=E+T/2,this._hbarTranslateMax=w-T):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var C=m>A,O=s.barWidth+2*s.barPad,R=s.barLength+2*s.barPad,P=p+g,z=v;P+O>l&&(P=l-O);var I=this.container.selectAll("rect.scrollbar-vertical").data(C?[0]:[]);I.exit().on(".drag",null).remove(),I.enter().append("rect").classed("scrollbar-vertical",!0).call(i.fill,s.barColor),C?(this.vbar=I.attr({rx:s.barRadius,ry:s.barRadius,x:P,y:z,width:O,height:R}),this._vbarYMin=z+R/2,this._vbarTranslateMax=A-R):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var N=this.id,D=c-.5,F=C?f+O+.5:f+.5,j=h-.5,B=M?d+k+.5:d+.5,U=o._topdefs.selectAll("#"+N).data(M||C?[0]:[]);if(U.exit().remove(),U.enter().append("clipPath").attr("id",N).append("rect"),M||C?(this._clipRect=U.select("rect").attr({x:Math.floor(D),y:Math.floor(j),width:Math.ceil(F)-Math.floor(D),height:Math.ceil(B)-Math.floor(j)}),this.container.call(a.setClipUrl,N,this.gd),this.bg.attr({x:p,y:v,width:g,height:m})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),M||C){var V=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(V);var H=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));M&&this.hbar.on(".drag",null).call(H),C&&this.vbar.on(".drag",null).call(H)}this.setTranslate(e,r)},s.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},s.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},s.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},s.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,i=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,i)-r)/(i-r)*(this.position.w-this._box.w)}if(this.vbar){var a=e+this._vbarYMin,s=a+this._vbarTranslateMax;e=(o.constrain(n.event.y,a,s)-a)/(s-a)*(this.position.h-this._box.h)}this.setTranslate(t,e)},s.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(a.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var i=t/r;this.hbar.call(a.setTranslate,t+i*this._hbarTranslateMax,e)}if(this.vbar){var s=e/n;this.vbar.call(a.setTranslate,t,e+s*this._vbarTranslateMax)}}},{"../../lib":494,"../color":375,"../drawing":396,d3:82}],470:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,CAP_SHIFT:.7,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],471:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],472:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],473:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],474:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],475:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],476:[function(t,e,r){"use strict";r.version="1.43.0",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config")();for(var n=t("./registry"),i=r.register=n.register,a=t("./plot_api"),o=Object.keys(a),s=0;s1/3&&t.x<2/3},r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isTopAnchor=function(t){return"top"===t.yanchor||"auto"===t.yanchor&&t.y>=2/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3}},{}],479:[function(t,e,r){"use strict";var n=t("./mod"),i=n.mod,a=n.modHalf,o=Math.PI,s=2*o;function l(t){return Math.abs(t[1]-t[0])>s-1e-15}function u(t,e){return a(e-t,s)}function c(t,e){if(l(e))return!0;var r,n;e[0](n=i(n,s))&&(n+=s);var a=i(t,s),o=a+s;return a>=r&&a<=n||o>=r&&o<=n}function f(t,e,r,n,i,a,u){i=i||0,a=a||0;var c,f,h,d,p,g=l([r,n]);function v(t,e){return[t*Math.cos(e)+i,a-t*Math.sin(e)]}g?(c=0,f=o,h=s):r=i&&t<=a);var i,a},pathArc:function(t,e,r,n,i){return f(null,t,e,r,n,i,0)},pathSector:function(t,e,r,n,i){return f(null,t,e,r,n,i,1)},pathAnnulus:function(t,e,r,n,i,a){return f(t,e,r,n,i,a,1)}}},{"./mod":501}],480:[function(t,e,r){"use strict";var n=Array.isArray,i="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},a="undefined"==typeof DataView?function(){}:DataView;function o(t){return i.isView(t)&&!(t instanceof a)}function s(t){return n(t)||o(t)}function l(t,e,r){if(s(t)){if(s(t[0])){for(var n=r,i=0;ii.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var i="number"==typeof t;!0!==n.strict&&i?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return i(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o.get(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(c(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var i=n.regex||u(r);"string"==typeof t&&i.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!u(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var i=t.split("+"),a=0;a=n&&t<=i?t:c}if("string"!=typeof t&&"number"!=typeof t)return c;t=String(t);var u=_(e),m=t.charAt(0);!u||"G"!==m&&"g"!==m||(t=t.substr(1),e="");var w=u&&"chinese"===e.substr(0,7),A=t.match(w?b:y);if(!A)return c;var M=A[1],T=A[3]||"1",k=Number(A[5]||1),E=Number(A[7]||0),S=Number(A[9]||0),L=Number(A[11]||0);if(u){if(2===M.length)return c;var C;M=Number(M);try{var O=v.getComponentMethod("calendars","getCal")(e);if(w){var R="i"===T.charAt(T.length-1);T=parseInt(T,10),C=O.newDate(M,O.toMonthIndex(M,T,R),k)}else C=O.newDate(M,Number(T),k)}catch(t){return c}return C?(C.toJD()-g)*f+E*h+S*d+L*p:c}M=2===M.length?(Number(M)+2e3-x)%100+x:Number(M),T-=1;var P=new Date(Date.UTC(2e3,T,k,E,S));return P.setUTCFullYear(M),P.getUTCMonth()!==T?c:P.getUTCDate()!==k?c:P.getTime()+L*p},n=r.MIN_MS=r.dateTime2ms("-9999"),i=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==c};var A=90*f,M=3*h,T=5*d;function k(t,e,r,n,i){if((e||r||n||i)&&(t+=" "+w(e,2)+":"+w(r,2),(n||i)&&(t+=":"+w(n,2),i))){for(var a=4;i%10==0;)a-=1,i/=10;t+="."+w(i,a)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=i))return c;e||(e=0);var a,o,s,u,y,b,x=Math.floor(10*l(t+.05,1)),w=Math.round(t-x/10);if(_(r)){var E=Math.floor(w/f)+g,S=Math.floor(l(t,f));try{a=v.getComponentMethod("calendars","getCal")(r).fromJD(E).formatDate("yyyy-mm-dd")}catch(t){a=m("G%Y-%m-%d")(new Date(w))}if("-"===a.charAt(0))for(;a.length<11;)a="-0"+a.substr(1);else for(;a.length<10;)a="0"+a;o=e=n+f&&t<=i-f))return c;var e=Math.floor(10*l(t+.05,1)),r=new Date(Math.round(t-e/10));return k(a.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===c)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return s.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return s.error("unrecognized date",t),e;return t};var E=/%\d?f/g;function S(t,e,r,n){t=t.replace(E,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var i=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(i)}var L=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,i,a){if(i=_(i)&&i,!e)if("y"===r)e=a.year;else if("m"===r)e=a.month;else{if("d"!==r)return function(t,e){var r=l(t+.05,f),n=w(Math.floor(r/h),2)+":"+w(l(Math.floor(r/d),60),2);if("M"!==e){o(e)||(e=0);var i=(100+Math.min(l(t/p,60),L[e])).toFixed(e).substr(1);e>0&&(i=i.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+i}return n}(t,r)+"\n"+S(a.dayMonthYear,t,n,i);e=a.dayMonth+"\n"+a.year}return S(e,t,n,i)};var C=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=l(t,f);if(t=Math.round(t-n),r)try{var i=Math.round(t/f)+g,a=v.getComponentMethod("calendars","getCal")(r),o=a.fromJD(i);return e%12?a.add(o,e,"m"):a.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){s.error("invalid ms "+t+" in calendar "+r)}var u=new Date(t+C);return u.setUTCMonth(u.getUTCMonth()+e)+n-C},r.findExactDates=function(t,e){for(var r,n,i=0,a=0,s=0,l=0,u=_(e)&&v.getComponentMethod("calendars","getCal")(e),c=0;c1||g<0||g>1?null:{x:t+l*g,y:e+f*g}}function l(t,e,r,n,i){var a=n*t+i*e;if(a<0)return n*n+i*i;if(a>r){var o=n-t,s=i-e;return o*o+s*s}var l=n*e-i*t;return l*l/r}r.segmentsIntersect=s,r.segmentDistance=function(t,e,r,n,i,a,o,u){if(s(t,e,r,n,i,a,o,u))return 0;var c=r-t,f=n-e,h=o-i,d=u-a,p=c*c+f*f,g=h*h+d*d,v=Math.min(l(c,f,p,i-t,a-e),l(c,f,p,o-t,u-e),l(h,d,g,t-i,e-a),l(h,d,g,r-i,n-a));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,s){if(t===i&&s===a||(n={},i=t,a=s),n[r])return n[r];var l=t.getPointAtLength(o(r-s/2,e)),u=t.getPointAtLength(o(r+s/2,e)),c=Math.atan((u.y-l.y)/(u.x-l.x)),f=t.getPointAtLength(o(r,e)),h={x:(4*f.x+l.x+u.x)/6,y:(4*f.y+l.y+u.y)/6,theta:c};return n[r]=h,h},r.clearLocationCache=function(){i=null},r.getVisibleSegment=function(t,e,r){var n,i,a=e.left,o=e.right,s=e.top,l=e.bottom,u=0,c=t.getTotalLength(),f=c;function h(e){var r=t.getPointAtLength(e);0===e?n=r:e===c&&(i=r);var u=r.xo?r.x-o:0,f=r.yl?r.y-l:0;return Math.sqrt(u*u+f*f)}for(var d=h(u);d;){if((u+=d+r)>f)return;d=h(u)}for(d=h(f);d;){if(u>(f-=d+r))return;d=h(f)}return{min:u,max:f,len:f-u,total:c,isClosed:0===u&&f===c&&Math.abs(n.x-i.x)<.1&&Math.abs(n.y-i.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var i,a,o,s=(n=n||{}).pathLength||t.getTotalLength(),l=n.tolerance||.001,u=n.iterationLimit||30,c=t.getPointAtLength(0)[r]>t.getPointAtLength(s)[r]?-1:1,f=0,h=0,d=s;f0?d=i:h=i,f++}return a}},{"./mod":501}],491:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],492:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("color-normalize"),o=t("../components/colorscale"),s=t("../components/color/attributes").defaultLine,l=t("./array").isArrayOrTypedArray,u=a(s),c=1;function f(t,e){var r=t;return r[3]*=e,r}function h(t){if(n(t))return u;var e=a(t);return e.length?e:u}function d(t){return n(t)?t:c}e.exports={formatColor:function(t,e,r){var n,i,s,p,g,v=t.color,m=l(v),y=l(e),b=[];if(n=void 0!==t.colorscale?o.makeColorScaleFunc(o.extractScale(t,{cLetter:"c"})):h,i=m?function(t,e){return void 0===t[e]?u:a(n(t[e]))}:h,s=y?function(t,e){return void 0===t[e]?c:d(t[e])}:d,m||y)for(var x=0;xo?s:i(t)?Number(t):s:s},l.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(i(t)&&t>=0&&t%1==0)},l.noop=t("./noop"),l.identity=t("./identity"),l.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},l.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},l.simpleMap=function(t,e,r,n){for(var i=t.length,a=new Array(i),o=0;o=Math.pow(2,r)?i>10?(l.warn("randstr failed uniqueness"),u):t(e,r,n,(i||0)+1):u},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,u=new Array(l),c=new Array(o);for(r=0;r=s&&(i-=s*Math.floor(i/s)),i<0?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*u[n];c[r]=a}return c},l.syncOrAsync=function(t,e,r){var n;function i(){return l.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(i).then(void 0,l.promiseError);return r&&r(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,r){if(t){var n,i=!1,a=!0;for(n=0;n1?i+o[1]:"";if(a&&(o.length>1||s.length>4||r))for(;n.test(s);)s=s.replace(n,"$1"+a+"$2");return s+l};var k=/%{([^\s%{}:]*)(:[^}]*)?}/g,E=/^\w*$/;l.templateString=function(t,e){var r={};return t.replace(k,function(t,n){return E.test(n)?e[n]||"":(r[n]=r[n]||l.nestedProperty(e,n).get,r[n]()||"")})};var S=/^:/,L=0;l.hovertemplateString=function(t,e){var r=arguments,i={};return t.replace(k,function(t,a,o){var s,u,c;for(c=2;c=48&&o<=57,u=s>=48&&s<=57;if(l&&(n=10*n+o-48),u&&(i=10*i+s-48),!l||!u){if(n!==i)return n-i;if(o!==s)return o-s}}return i-n};var C=2e9;l.seedPseudoRandom=function(){C=2e9},l.pseudoRandom=function(){var t=C;return C=(69069*C+1)%4294967296,Math.abs(C-t)<429496729?l.pseudoRandom():C/4294967296}},{"../constants/numerical":474,"./anchor_utils":478,"./angles":479,"./array":480,"./clean_number":481,"./clear_responsive":483,"./coerce":484,"./dates":485,"./extend":487,"./filter_unique":488,"./filter_visible":489,"./geometry2d":490,"./get_graph_div":491,"./identity":493,"./is_plain_object":495,"./keyed_container":496,"./localize":497,"./loggers":498,"./make_trace_groups":499,"./matrix":500,"./mod":501,"./nested_property":502,"./noop":503,"./notifier":504,"./push_unique":507,"./regex":509,"./relative_attr":510,"./relink_private":511,"./search":512,"./stats":515,"./throttle":518,"./to_log_range":519,d3:82,"fast-isnumeric":91}],495:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],496:[function(t,e,r){"use strict";var n=t("./nested_property"),i=/^\w*$/;e.exports=function(t,e,r,a){var o,s,l;r=r||"name",a=a||"value";var u={};e&&e.length?(l=n(t,e),s=l.get()):s=t,e=e||"";var c={};if(s)for(o=0;o2)return u[e]=2|u[e],h.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],502:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,a,o,l=0,u=e.split(".");l/g),o=0;oa||u===i||us||e&&l(t))}:function(t,e){var l=t[0],u=t[1];if(l===i||la||u===i||us)return!1;var c,f,h,d,p,g=r.length,v=r[0][0],m=r[0][1],y=0;for(c=1;cMath.max(f,v)||u>Math.max(h,m)))if(uc||Math.abs(n(o,h))>i)return!0;return!1};a.filter=function(t,e){var r=[t[0]],n=0,i=0;function a(a){t.push(a);var s=r.length,l=n;r.splice(i+1);for(var u=l+1;u1&&a(t.pop());return{addPt:a,raw:t,filtered:r}}},{"../constants/numerical":474,"./matrix":500}],507:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ri.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function u(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var a,c,f=0,h=e.length,d=0,p=h>1?(e[h-1]-e[0])/(h-1):1;for(c=p>=0?r?o:s:r?u:l,t+=1e-9*p*(r?-1:1)*(p>=0?1:-1);f90&&i.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;se[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,u=r?Math.ceil:Math.floor;i0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||a;for(var r,n=1/0,i=0;ia.length)&&(o=a.length),n(e)||(e=!1),i(a[0])){for(l=new Array(o),s=0;st.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":480,"fast-isnumeric":91}],516:[function(t,e,r){"use strict";var n=t("color-normalize");e.exports=function(t){return t?n(t):[0,0,0,1]}},{"color-normalize":63}],517:[function(t,e,r){"use strict";var n=t("d3"),i=t("../lib"),a=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function s(t,e){return t.node().getBoundingClientRect()[e]}var l=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var E=t.text(),S=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&E.match(l),C=n.select(t.node().parentNode);if(!C.empty()){var O=t.attr("class")?t.attr("class").split(" ")[0]:"text";return O+="-math",C.selectAll("svg."+O).remove(),C.selectAll("g."+O+"-group").remove(),t.style("display",null).attr({"data-unformatted":E,"data-math":"N"}),S?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),a={fontSize:r};!function(t,e,r){var a,o,s,l;MathJax.Hub.Queue(function(){return o=i.extendDeepAll({},MathJax.Hub.config),s=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(a=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+i.randstr({},64);return l=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(u,"\\lt ").replace(c,"\\gt ")),MathJax.Hub.Typeset(l.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(l.select(".MathJax_SVG").empty()||!l.select("svg").node())i.log("There was an error in the tex syntax.",t),r();else{var o=l.select("svg").node().getBoundingClientRect();r(l.select(".MathJax_SVG"),e,o)}if(l.remove(),"SVG"!==a)return MathJax.Hub.setRenderer(a)},function(){return void 0!==s&&(MathJax.Hub.processSectionDelay=s),MathJax.Hub.Config(o)})}(S[2],a,function(n,i,a){C.selectAll("svg."+O).remove(),C.selectAll("g."+O+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return R(),void e();var l=C.append("g").classed(O+"-group",!0).attr({"pointer-events":"none","data-unformatted":E,"data-math":"Y"});l.node().appendChild(o.node()),i&&i.node()&&o.node().insertBefore(i.node().cloneNode(!0),o.node().firstChild),o.attr({class:O,height:a.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=t.node().style.fill||"black";o.select("g").attr({fill:u,stroke:u});var c=s(o,"width"),f=s(o,"height"),h=+t.attr("x")-c*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],d=-(r||s(t,"height"))/4;"y"===O[0]?(l.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-c/2,d-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===O[0]?o.attr({x:t.attr("x"),y:d-f/2}):"a"===O[0]?o.attr({x:0,y:d}):o.attr({x:h,y:+t.attr("y")+d-f/2}),v&&v.call(t,l),e(l)})})):R(),t}function R(){C.empty()||(O=t.attr("class")+"-math",C.select("svg."+O).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(m," ");var r,s=!1,l=[],u=-1;function c(){u++;var e=document.createElementNS(a.svg,"tspan");n.select(e).attr({class:"line",dy:u*o+"em"}),t.appendChild(e),r=e;var i=l;if(l=[{node:e}],i.length>1)for(var s=1;s doesnt match end tag <"+t+">. Pretending it did match.",e),r=l[l.length-1].node}else i.log("Ignoring unexpected end tag .",e)}x.test(e)?c():(r=t,l=[{node:t}]);for(var C=e.split(y),O=0;O|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},h={sub:"0.3em",sup:"-0.6em"},d={sub:"-0.21em",sup:"0.42em"},p="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),m=/(\r\n?|\n)/g,y=/(<[^<>]*>)/,b=/<(\/?)([^ >]*)(\s+(.*))?>/i,x=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,A=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,M=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function T(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&L(n)}var k=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var E={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},S=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function L(t){return t.replace(S,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):E[e])||t})}function C(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),u=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-u.top+"px",left:a()-u.left+"px","z-index":1e3}),this}}r.convertEntities=L,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function i(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var a=i("x",e),o=i("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:a,y:o})})},r.makeEditable=function(t,e){var r=e.gd,i=e.delegate,a=n.dispatch("edit","input","cancel"),o=i||t;if(t.style({"pointer-events":i?"none":"all"}),1!==t.size())throw new Error("boo");function s(){!function(){var i=n.select(r).select(".svg-container"),o=i.append("div"),s=t.node().style,u=parseFloat(s.fontSize||12),c=e.text;void 0===c&&(c=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":s.fontFamily||"Arial","font-size":u,color:e.fill||s.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-u/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(c).call(C(t,i,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,i=n.select(this).attr("class");(e=i?"."+i.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),a.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),a.cancel.call(t,this.textContent)):(a.input.call(t,this.textContent),n.select(this).call(C(t,i,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(l)}(),t.style({opacity:0});var i,s=o.attr("class");(i=s?"."+s.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(i).style({opacity:0})}function l(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?s():o.on("click",s),n.rebind(t,a,"on")}},{"../constants/alignment":470,"../constants/xmlns_namespaces":475,"../lib":494,d3:82}],518:[function(t,e,r){"use strict";var n={};function i(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var a=n[t],o=Date.now();if(!a){for(var s in n)n[s].tsa.ts+e?l():a.timer=setTimeout(function(){l(),a.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)i(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],519:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":91}],520:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],521:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],522:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,i=n.layoutArrayContainers,a=n.layoutArrayRegexes,o=t.split("[")[0],s=0;s0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var a=(s.subplotsRegistry.cartesian||{}).attrRegex,l=(s.subplotsRegistry.polar||{}).attrRegex,c=(s.subplotsRegistry.ternary||{}).attrRegex,p=(s.subplotsRegistry.gl3d||{}).attrRegex,g=Object.keys(t);for(e=0;e3?(O.x=1.02,O.xanchor="left"):O.x<-2&&(O.x=-.02,O.xanchor="right"),O.y>3?(O.y=1.02,O.yanchor="bottom"):O.y<-2&&(O.y=-.02,O.yanchor="top")),d(t),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t.template&&t.template.layout&&r.cleanLayout(t.template.layout),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=b(e);r;){if(r in t)return!0;r=b(r)}return!1};var x=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&a.warn("Full array edits are incompatible with other edits",f);var y=r[""][""];if(u(y))e.set(null);else{if(!Array.isArray(y))return a.warn("Unrecognized full array edit value",f,y),!0;e.set(y)}return!g&&(h(v,m),d(t),!0)}var b,x,_,w,A,M,T,k,E=Object.keys(r).map(Number).sort(o),S=e.get(),L=S||[],C=c(m,f).get(),O=[],R=-1,P=L.length;for(b=0;bL.length-(T?0:1))a.warn("index out of range",f,_);else if(void 0!==M)A.length>1&&a.warn("Insertion & removal are incompatible with edits to the same index.",f,_),u(M)?O.push(_):T?("add"===M&&(M={}),L.splice(_,0,M),C&&C.splice(_,0,{})):a.warn("Unrecognized full object edit value",f,_,M),-1===R&&(R=_);else for(x=0;x=0;b--)L.splice(O[b],1),C&&C.splice(O[b],1);if(L.length?S||e.set(L):e.set(null),g)return!1;if(h(v,m),p!==i){var z;if(-1===R)z=E;else{for(P=Math.max(L.length,P),z=[],b=0;b=R);b++)z.push(_);for(b=R;b=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||i<0&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function z(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),P(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&P(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function I(t,e,r,n,a){!function(t,e,r,n){var i=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var a in P(t,r,"indices"),e){if(!Array.isArray(e[a])||e[a].length!==r.length)throw new Error("attribute "+a+" must be an array of length equal to indices array length");if(i&&(!(a in n)||!Array.isArray(n[a])||n[a].length!==e[a].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var l=function(t,e,r,n){var a,l,u,c,f,h=o.isPlainObject(n),d=[];for(var p in Array.isArray(r)||(r=[r]),r=R(r,t.data.length-1),e)for(var g=0;g-1?l(r,r.replace("titlefont","title.font")):r.indexOf("titleposition")>-1?l(r,r.replace("titleposition","title.position")):r.indexOf("titleside")>-1?l(r,r.replace("titleside","title.side")):r.indexOf("titleoffset")>-1&&l(r,r.replace("titleoffset","title.offset")):l(r,r.replace("title","title.text"));function l(e,r){t[r]=t[e],delete t[e]}}function H(t,e,r){if(t=o.getGraphDiv(t),A.clearPromiseQueue(t),t.framework&&t.framework.isPolar)return Promise.resolve(t);var n={};if("string"==typeof e)n[e]=r;else{if(!o.isPlainObject(e))return o.warn("Relayout fail.",e,r),Promise.reject();n=o.extendFlat({},e)}Object.keys(n).length&&(t.changed=!0);var i=Z(t,n),a=i.flags;a.calc&&(t.calcdata=void 0);var s=[h.previousPromises];a.layoutReplot?s.push(M.layoutReplot):Object.keys(n).length&&(q(t,a,i)||h.supplyDefaults(t),a.legend&&s.push(M.doLegend),a.layoutstyle&&s.push(M.layoutStyles),a.axrange&&G(s,i.rangesAltered),a.ticks&&s.push(M.doTicksRelayout),a.modebar&&s.push(M.doModeBar),a.camera&&s.push(M.doCamera),s.push(S)),s.push(h.rehover),u.add(t,H,[t,i.undoit],H,[t,i.redoit]);var l=o.syncOrAsync(s,t);return l&&l.then||(l=Promise.resolve(t)),l.then(function(){return t.emit("plotly_relayout",i.eventData),t})}function q(t,e,r){var n;if(!e.axrange)return!1;for(n in e)if("axrange"!==n&&e[n])return!1;for(n in r.rangesAltered){var i=p.id2name(n),a=t.layout[i],o=t._fullLayout[i];o.autorange=a.autorange,o.range=a.range.slice(),o.cleanRange()}return!0}function G(t,e){var r=e?function(t){var r={skipTitle:!0};for(var n in e)if(p.getFromId(t,n).automargin){r={};break}return p.draw(t,Object.keys(e),r)}:function(t){return p.draw(t,"redraw")};t.push(M.doAutoRangeAndConstraints,r,M.drawData,M.finalDraw)}r.plot=function(t,e,i,a){var s;if(t=o.getGraphDiv(t),l.init(t),o.isPlainObject(e)){var u=e;e=u.data,i=u.layout,a=u.config,s=u.frames}if(!1===l.triggerHandler(t,"plotly_beforeplot",[e,i,a]))return Promise.reject();e||i||o.isPlotDiv(t)||o.warn("Calling Plotly.plot as if redrawing but this container doesn't yet have a plot.",t),O(t,a),i||(i={}),n.select(t).classed("js-plotly-plot",!0),g.makeTester(),Array.isArray(t._promises)||(t._promises=[]);var f=0===(t.data||[]).length&&Array.isArray(e);if(Array.isArray(e)&&(A.cleanData(e),f?t.data=e:t.data.push.apply(t.data,e),t.empty=!1),t.layout&&!f||(t.layout=A.cleanLayout(i)),t._dragging&&!t._transitioning)return t._replotPending=!0,Promise.reject();t._replotPending=!1,h.supplyDefaults(t);var v=t._fullLayout,b=v._has("cartesian");if(!v._has("polar")&&e&&e[0]&&e[0].r)return o.log("Legacy polar charts are deprecated!"),function(t,e,r){var i=n.select(t).selectAll(".plot-container").data([0]);i.enter().insert("div",":first-child").classed("plot-container plotly",!0);var a=i.selectAll(".svg-container").data([0]);a.enter().append("div").classed("svg-container",!0).style("position","relative"),a.html(""),e&&(t.data=e);r&&(t.layout=r);d.manager.fillLayout(t),a.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=d.manager.framework(t),t.framework({data:t.data,layout:t.layout},a.node()),t.framework.setUndoPoint();var s=t.framework.svg(),l=1,u=t._fullLayout.title?t._fullLayout.title.text:"";""!==u&&u||(l=0);var c=function(){this.call(x.convertToTspans,t)},f=s.select(".title-group text").call(c);if(t._context.edits.titleText){var p=o._(t,"Click to enter Plot title");u&&u!==p||(l=.2,f.attr({"data-unformatted":p}).text(p).style({opacity:l}).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)}));var g=function(){this.call(x.makeEditable,{gd:t}).on("edit",function(e){t.framework({layout:{title:{text:e}}}),this.text(e).call(c),this.call(g)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};f.call(g)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),h.addLinks(t),Promise.resolve()}(t,e,i);v._replotting=!0,f&&st(t),t.framework!==st&&(t.framework=st,st(t)),g.initGradients(t),f&&p.saveShowSpikeInitial(t);var _=!t.calcdata||t.calcdata.length!==(t._fullData||[]).length;_&&h.doCalcdata(t);for(var w=0;w=0&&r=0&&r0&&"string"!=typeof P.parts[I];)I--;var N=P.parts[I],D=P.parts[I-1]+"."+N,B=P.parts.slice(0,I).join("."),U=s(t.layout,B).get(),H=s(l,B).get(),q=P.get();if(void 0!==z){M[R]=z,E[R]="reverse"===N?z:F(q);var G=f.getLayoutValObject(l,P.parts);if(G&&G.impliedEdits&&null!==z)for(var Z in G.impliedEdits)S(o.relativeAttr(R,Z),G.impliedEdits[Z]);if(-1!==["width","height"].indexOf(R))if(z){S("autosize",null);var $="height"===R?"width":"height";S($,l[$])}else l[R]=t._initialAutoSize[R];else if("autosize"===R)S("width",z?null:l.width),S("height",z?null:l.height);else if(D.match(X))O(D),s(l,B+"._inputRange").set(null);else if(D.match(W)){O(D),s(l,B+"._inputRange").set(null);var J=s(l,B).get();J._inputDomain&&(J._input.domain=J._inputDomain.slice())}else D.match(Y)&&s(l,B+"._inputDomain").set(null);if("type"===N){var K=U,tt="linear"===H.type&&"log"===z,et="log"===H.type&&"linear"===z;if(tt||et){if(K&&K.range)if(H.autorange)tt&&(K.range=K.range[1]>K.range[0]?[1,2]:[2,1]);else{var rt=K.range[0],nt=K.range[1];tt?(rt<=0&&nt<=0&&S(B+".autorange",!0),rt<=0?rt=nt/1e6:nt<=0&&(nt=rt/1e6),S(B+".range[0]",Math.log(rt)/Math.LN10),S(B+".range[1]",Math.log(nt)/Math.LN10)):(S(B+".range[0]",Math.pow(10,rt)),S(B+".range[1]",Math.pow(10,nt)))}else S(B+".autorange",!0);Array.isArray(l._subplots.polar)&&l._subplots.polar.length&&l[P.parts[0]]&&"radialaxis"===P.parts[1]&&delete l[P.parts[0]]._subplot.viewInitial["radialaxis.range"],c.getComponentMethod("annotations","convertCoords")(t,H,z,S),c.getComponentMethod("images","convertCoords")(t,H,z,S)}else S(B+".autorange",!0),S(B+".range",null);s(l,B+"._inputRange").set(null)}else if(N.match(k)){var it=s(l,R).get(),at=(z||{}).type;at&&"-"!==at||(at="linear"),c.getComponentMethod("annotations","convertCoords")(t,it,at,S),c.getComponentMethod("images","convertCoords")(t,it,at,S)}var ot=w.containerArrayMatch(R);if(ot){r=ot.array,n=ot.index;var st=ot.property,lt=G||{editType:"calc"};""!==n&&""===st&&(w.isAddVal(z)?E[R]=null:w.isRemoveVal(z)?E[R]=(s(a,r).get()||[])[n]:o.warn("unrecognized full object value",e)),T.update(_,lt),m[r]||(m[r]={});var ut=m[r][n];ut||(ut=m[r][n]={}),ut[st]=z,delete e[R]}else"reverse"===N?(U.range?U.range.reverse():(S(B+".autorange",!0),U.range=[1,0]),H.autorange?_.calc=!0:_.plot=!0):(l._has("scatter-like")&&l._has("regl")&&"dragmode"===R&&("lasso"===z||"select"===z)&&"lasso"!==q&&"select"!==q?_.plot=!0:G?T.update(_,G):_.calc=!0,P.set(z))}}for(r in m){w.applyContainerArrayChanges(t,h(a,r),m[r],_,h)||(_.plot=!0)}var ct=l._axisConstraintGroups||[];for(L in C)for(n=0;n1;)if(n.pop(),void 0!==(r=s(e,n.join(".")+".uirevision").get()))return r;return e.uirevision}function nt(t,e){for(var r=0;r=i.length?i[0]:i[t]:i}function l(t){return Array.isArray(a)?t>=a.length?a[0]:a[t]:a}function u(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(a,c){function f(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,h.transition(t,e.frame.data,e.frame.layout,A.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function d(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&f()};e()}var p,g,v=0;function m(t){return Array.isArray(i)?v>=i.length?t.transitionOpts=i[v]:t.transitionOpts=i[0]:t.transitionOpts=i,v++,t}var y=[],b=null==e,x=Array.isArray(e);if(!b&&!x&&o.isPlainObject(e))y.push({type:"object",data:m(o.extendFlat({},e))});else if(b||-1!==["string","number"].indexOf(typeof e))for(p=0;p0&&MM)&&T.push(g);y=T}}y.length>0?function(e){if(0!==e.length){for(var i=0;i=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(c[g]||p[g]||{}).name,m=e[n].name,y=c[v]||p[v];v&&m&&"number"==typeof m&&y&&E<5&&(E++,o.warn('addFrames: overwriting frame "'+(c[v]||p[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===E&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),p[g]={name:g},d.push({frame:h.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:f+n})}d.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(i=d[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!i.name)for(;c[i.name="frame "+t._transitionData._counter++];);if(c[i.name]){for(a=0;a=0;r--)n=e[r],a.push({type:"delete",index:n}),s.unshift({type:"insert",index:n,value:i[n]});var l=h.modifyFrames,c=h.modifyFrames,f=[t,s],d=[t,a];return u&&u.add(t,l,f,c,d),h.modifyFrames(t,a)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return h.cleanPlot([],{},r,e),h.purge(t),l.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":375,"../components/colorbar/connect":377,"../components/drawing":396,"../constants/xmlns_namespaces":475,"../lib":494,"../lib/events":486,"../lib/queue":508,"../lib/svg_text_utils":517,"../plots/cartesian/axes":540,"../plots/cartesian/constants":546,"../plots/cartesian/graph_interact":550,"../plots/plots":585,"../plots/polar/legacy":588,"../registry":593,"./edit_types":523,"./helpers":524,"./manage_arrays":526,"./plot_config":528,"./plot_schema":529,"./subroutines":531,d3:82,"fast-isnumeric":91,"has-hover":250}],528:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,showSendToCloud:!1,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,watermark:!1,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],529:[function(t,e,r){"use strict";var n=t("../registry"),i=t("../lib"),a=t("../plots/attributes"),o=t("../plots/layout_attributes"),s=t("../plots/frame_attributes"),l=t("../plots/animation_attributes"),u=t("../plots/polar/legacy/area_attributes"),c=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),h=i.extendFlat,d=i.extendDeepAll,p=i.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",m=[g,v,"_arrayAttrRegexps","_deprecated"];function y(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(b(e[r]))r++;else if(r=a.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!b(o))return!1;t=a[i][o]}else t=a[i]}else t=a}}return t}function b(t){return t===Math.round(t)&&t>=0}function x(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):p(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(p(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=l.length)return!1;i=(r=(n.transformsRegistry[l[c].type]||{}).attributes)&&r[e[2]],s=3}else if("area"===t.type)i=u[o];else{var f=t._module;if(f||(f=(n.modules[t.type||a.type.dflt]||{})._module),!f)return!1;if(!(i=(r=f.attributes)&&r[o])){var h=f.basePlotModule;h&&h.attributes&&(i=h.attributes[o])}i||(i=a[o])}return y(i,e,s)},r.getLayoutValObject=function(t,e){return y(function(t,e){var r,i,a,s,l=t._basePlotModules;if(l){var u;for(r=0;r=i&&(r._input||{})._templateitemname;s&&(o=i);var l,u=e+"["+o+"]";function c(){l={},s&&(l[u]={},l[u][a]=s)}function f(t,e){s?n.nestedProperty(l[u],t).set(e):l[u+"."+t]=e}function h(){var t=l;return c(),t}return c(),{modifyBase:function(t,e){l[t]=e},modifyItem:f,getUpdateObj:h,applyUpdate:function(e,r){e&&f(e,r);var i=h();for(var a in i)n.nestedProperty(t,a).set(i[a])}}}},{"../lib":494,"../plots/attributes":537}],531:[function(t,e,r){"use strict";var n=t("d3"),i=t("../registry"),a=t("../plots/plots"),o=t("../lib"),s=t("../lib/clear_gl_canvases"),l=t("../components/color"),u=t("../components/drawing"),c=t("../components/titles"),f=t("../components/modebar"),h=t("../plots/cartesian/axes"),d=t("../constants/alignment"),p=t("../plots/cartesian/constraints"),g=p.enforce,v=p.clean,m=t("../plots/cartesian/autorange").doAutoRange,y="start",b="middle",x="end";function _(t,e,r){for(var n=0;n=t[1]||i[1]<=t[0])&&(a[0]e[0]))return!0}return!1}function w(t){var e,i,a,s,c,p,g=t._fullLayout,v=g._size,m=v.p,y=h.list(t,"",!0);if(g._paperdiv.style({width:t._context.responsive&&g.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":g.width+"px",height:t._context.responsive&&g.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":g.height+"px"}).selectAll(".main-svg").call(u.setSize,g.width,g.height),t._context.setBackground(t,g.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!g._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function b(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-m-n:e._offset+e._length+m+n:v.t+v.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+m+n:e._offset-m-n:v.l+v.w*(t.position||0)+n%1}for(e=0;eA?c.push({code:"unused",traceType:y,templateCount:w,dataCount:A}):A>w&&c.push({code:"reused",traceType:y,templateCount:w,dataCount:A})}}else c.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var a=e[n],o=d(e,n,r);i(a)?(Array.isArray(e)&&!1===a._template&&a.templateitemname&&c.push({code:"missing",path:o,templateitemname:a.templateitemname}),t(a,o)):Array.isArray(a)&&p(a)&&t(a,o)}}({data:v,layout:h},""),c.length)return c.map(g)}},{"../lib":494,"../plots/attributes":537,"../plots/plots":585,"./plot_config":528,"./plot_schema":529,"./plot_template":530}],533:[function(t,e,r){"use strict";var n=t("./plot_api"),i=t("../lib"),a=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),s=t("../snapshot/svgtoimg"),l={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},u=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,c,f;function h(t){return!(t in e)||i.validate(e[t],l[t])}if(e=e||{},i.isPlainObject(t)?(r=t.data||[],c=t.layout||{},f=t.config||{}):(t=i.getGraphDiv(t),r=i.extendDeep([],t.data),c=i.extendDeep({},t.layout),f=t._context),!h("width")||!h("height"))throw new Error("Height and width should be pixel values.");if(!h("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var d={};function p(t,r){return i.coerce(e,d,l,t,r)}var g=p("format"),v=p("width"),m=p("height"),y=p("scale"),b=p("setBackground"),x=p("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=i.extendFlat({},c);v&&(w.width=v),m&&(w.height=m);var A=i.extendFlat({},f,{_exportedPlot:!0,staticPlot:!0,setBackground:b}),M=a.getRedrawFunc(_);function T(){return new Promise(function(t){setTimeout(t,a.getDelay(_._fullLayout))})}function k(){return new Promise(function(t,e){var r=o(_,g,y),a=_._fullLayout.width,l=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(x?r:"data:image/svg+xml,"+encodeURIComponent(r));var u=document.createElement("canvas");u.id=i.randstr(),s({format:g,width:a,height:l,scale:y,canvas:u,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,A).then(M).then(T).then(k).then(function(e){t(function(t){return x?t.replace(u,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":494,"../snapshot/helpers":597,"../snapshot/svgtoimg":599,"../snapshot/tosvg":601,"./plot_api":527}],534:[function(t,e,r){"use strict";var n=t("../lib"),i=t("../plots/plots"),a=t("./plot_schema"),o=t("./plot_config"),s=n.isPlainObject,l=Array.isArray,u=n.isArrayOrTypedArray;function c(t,e,r,i,a,o){o=o||[];for(var f=Object.keys(t),h=0;hb.length&&i.push(d("unused",a,m.concat(b.length)));var M,T,k,E,S,L=b.length,C=Array.isArray(A);if(C&&(L=Math.min(L,A.length)),2===x.dimensions)for(T=0;Tb[T].length&&i.push(d("unused",a,m.concat(T,b[T].length)));var O=b[T].length;for(M=0;M<(C?Math.min(O,A[T].length):O);M++)k=C?A[T][M]:A,E=y[T][M],S=b[T][M],n.validate(E,k)?S!==E&&S!==+E&&i.push(d("dynamic",a,m.concat(T,M),E,S)):i.push(d("value",a,m.concat(T,M),E))}else i.push(d("array",a,m.concat(T),y[T]));else for(T=0;T1&&h.push(d("object","layout"))),i.supplyDefaults(p);for(var g=p._fullData,v=r.length,m=0;m0&&((x=T-o(v)-o(m))>k?_/x>E&&(y=v,b=m,E=_/x):_/T>E&&(y={val:v.val,pad:0},b={val:m.val,pad:0},E=_/T));if(h===d){var S=h-1,L=h+1;if(A)if(0===h)a=[0,1];else{var C=(h>0?f:c).reduce(function(t,e){return Math.max(t,o(e))},0),O=h/(1-Math.min(.5,C/T));a=h>0?[0,O]:[O,0]}else a=M?[Math.max(0,S),Math.max(1,L)]:[S,L]}else A?(y.val>=0&&(y={val:0,pad:0}),b.val<=0&&(b={val:0,pad:0})):M&&(y.val-E*o(y)<0&&(y={val:0,pad:0}),b.val<=0&&(b={val:1,pad:0})),E=(b.val-y.val)/(T-o(y)-o(b)),a=[y.val-E*o(y),b.val+E*o(b)];return p&&a.reverse(),i.simpleMap(a,e.l2r||Number)}function l(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function u(t,e){var r,n,i,a=e._id,o=t._fullData,s=t._fullLayout,l=[],u=[];function h(t,e){for(r=0;r=r&&(u.extrapad||!o)){s=!1;break}i(e,u.val)&&u.pad<=r&&(o||!u.extrapad)&&(t.splice(l,1),l--)}if(s){var c=a&&0===e;t.push({val:e,pad:c?0:r,extrapad:!c&&o})}}function d(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:s,makePadFn:l,doAutoRange:function(t,e){if(e.autorange){e.range=s(t,e),e._r=e.range.slice(),e._rl=i.simpleMap(e._r,e.r2l);var r=e._input,n={};n[e._attr+".range"]=e.range,n[e._attr+".autorange"]=e.autorange,o.call("_storeDirectGUIEdit",t.layout,t._fullLayout._preGUI,n),r.range=e.range.slice(),r.autorange=e.autorange}var a=e._anchorAxis;if(a&&a.rangeslider){var l=a.rangeslider[e._name];l&&"auto"===l.rangemode&&(l.range=s(t,e)),a._input.rangeslider[e._name]=i.extendFlat({},l)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var i,o,s,l,u,h,p,g,v,m=[],y=[],b=e.length,x=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,A=!1;function M(t){if(Array.isArray(t))return A=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var T=M((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),k=M((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),E=M(r.vpadplus||r.vpad),S=M(r.vpadminus||r.vpad);if(!A){if(g=1/0,v=-1/0,w)for(i=0;i0&&(g=o),o>v&&o-a&&(g=o),o>v&&o=O;i--)C(i);return{min:m,max:y}},concatExtremes:u}},{"../../constants/numerical":474,"../../lib":494,"../../registry":593,"fast-isnumeric":91}],540:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../../components/titles"),c=t("../../components/color"),f=t("../../components/drawing"),h=t("./layout_attributes"),d=t("./clean_ticks"),p=t("../../constants/numerical"),g=p.ONEAVGYEAR,v=p.ONEAVGMONTH,m=p.ONEDAY,y=p.ONEHOUR,b=p.ONEMIN,x=p.ONESEC,_=p.MINUS_SIGN,w=p.BADNUM,A=t("../../constants/alignment").MID_SHIFT,M=t("../../constants/alignment").LINE_SPACING,T=e.exports={};T.setConvert=t("./set_convert");var k=t("./axis_autotype"),E=t("./axis_ids");T.id2name=E.id2name,T.name2id=E.name2id,T.cleanId=E.cleanId,T.list=E.list,T.listIds=E.listIds,T.getFromId=E.getFromId,T.getFromTrace=E.getFromTrace;var S=t("./autorange");T.getAutoRange=S.getAutoRange,T.findExtremes=S.findExtremes,T.coerceRef=function(t,e,r,n,i,a){var o=n.charAt(n.length-1),l=r._fullLayout._subplots[o+"axis"],u=n+"ref",c={};return i||(i=l[0]||a),a||(a=i),c[u]={valType:"enumerated",values:l.concat(a?[a]:[]),dflt:i},s.coerce(t,e,c,u)},T.coercePosition=function(t,e,r,n,i,a){var o,l;if("paper"===n||"pixel"===n)o=s.ensureNumber,l=r(i,a);else{var u=T.getFromId(e,n);l=r(i,a=u.fraction2r(a)),o=u.cleanPos}t[i]=o(l)},T.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?s.ensureNumber:T.getFromId(e,r).cleanPos)(t)};var L=T.getDataConversions=function(t,e,r,n){var i,a="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(a)){if(i={type:k(n),_categories:[]},T.setConvert(i),"category"===i.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.saveRangeInitial=function(t,e){for(var r=T.list(t,"",!0),n=!1,i=0;i.3*h||c(n)||c(a))){var d=r.dtick/2;t+=t+d.8){var o=Number(r.substr(1));a.exactYears>.8&&o%12==0?t=T.tickIncrement(t,"M6","reverse")+1.5*m:a.exactMonths>.8?t=T.tickIncrement(t,"M1","reverse")+15.5*m:t-=m/2;var l=T.tickIncrement(t,r);if(l<=n)return l}return t}(b,t,y,u,a)),v=b,0;v<=c;)v=T.tickIncrement(v,y,!1,a),0;return{start:e.c2r(b,0,a),end:e.c2r(v,0,a),size:y,_dataSpan:c-u}},T.prepTicks=function(t){var e=s.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type||"multicategory"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=s.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),T.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),B(t)},T.calcTicks=function(t){T.prepTicks(t);var e=s.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e=t.tickvals,r=t.ticktext,n=new Array(e.length),i=s.simpleMap(t.range,t.r2l),a=1.0001*i[0]-1e-4*i[1],o=1.0001*i[1]-1e-4*i[0],l=Math.min(a,o),u=Math.max(a,o),c=0;Array.isArray(r)||(r=[]);var f="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(var h=0;hl&&d=n:u<=n)&&!(a.length>l||u===o);u=T.tickIncrement(u,t.dtick,i,t.calendar))o=u,a.push(u);et(t)&&360===Math.abs(e[1]-e[0])&&a.pop(),t._tmax=a[a.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var c=new Array(a.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=m&&a<=10||e>=15*m)t._tickround="d";else if(e>=b&&a<=16||e>=y)t._tickround="M";else if(e>=x&&a<=19||e>=b)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(a,o)-20,t._tickround<0&&(t._tickround=4)}}else if(i(e)||"L"===e.charAt(0)){var s=t.range.map(t.r2d||Number);i(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var l=Math.max(Math.abs(s[0]),Math.abs(s[1])),u=Math.floor(Math.log(l)/Math.LN10+.01);Math.abs(u)>3&&(H(t.exponentformat)&&!q(u)?t._tickexponent=3*Math.round((u-1)/3):t._tickexponent=u)}else t._tickround=null}function U(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}T.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=s.dateTick0(t.calendar);var a=2*e;a>g?(e/=g,r=n(10),t.dtick="M"+12*j(e,r,R)):a>v?(e/=v,t.dtick="M"+j(e,1,P)):a>m?(t.dtick=j(e,m,I),t.tick0=s.dateTick0(t.calendar,!0)):a>y?t.dtick=j(e,y,P):a>b?t.dtick=j(e,b,z):a>x?t.dtick=j(e,x,z):(r=n(10),t.dtick=j(e,r,R))}else if("log"===t.type){t.tick0=0;var o=s.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var l=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/l,r=n(10),t.dtick="L"+j(e,r,R)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type||"multicategory"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):et(t)?(t.tick0=0,r=1,t.dtick=j(e,r,F)):(t.tick0=0,r=n(10),t.dtick=j(e,r,R));if(0===t.dtick&&(t.dtick=1),!i(t.dtick)&&"string"!=typeof t.dtick){var u=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(u)}},T.tickIncrement=function(t,e,r,a){var o=r?-1:1;if(i(e))return t+o*e;var l=e.charAt(0),u=o*Number(e.substr(1));if("M"===l)return s.incrementMonth(t,u,a);if("L"===l)return Math.log(Math.pow(10,t)+u)/Math.LN10;if("D"===l){var c="D2"===e?D:N,f=t+.01*o,h=s.roundUp(s.mod(f,1),c,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.r2l||Number,r=s.simpleMap(t.range,e),a=r[1]"+l,t._prevDateHead=l));e.text=u}(t,a,r,l):"log"===u?function(t,e,r,n,a){var o=t.dtick,l=e.x,u=t.tickformat,c="string"==typeof o&&o.charAt(0);"never"===a&&(a="");n&&"L"!==c&&(o="L3",c="L");if(u||"L"===c)e.text=G(Math.pow(10,l),t,a,n);else if(i(o)||"D"===c&&s.mod(l+.01,1)<.1){var f=Math.round(l),h=Math.abs(f),d=t.exponentformat;"power"===d||H(d)&&q(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+h+"",e.fontSize*=1.25):("e"===d||"E"===d)&&h>2?e.text="1"+d+(f>0?"+":_)+h:(e.text=G(Math.pow(10,l),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==c)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,s.mod(l,1)))),e.fontSize*=.75}if("D1"===t.dtick){var p=String(e.text).charAt(0);"0"!==p&&"1"!==p||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(l<0?.5:.25)))}}(t,a,0,l,p):"category"===u?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,a):"multicategory"===u?function(t,e,r){var n=Math.round(e.x),i=t._categories[n]||[],a=void 0===i[1]?"":String(i[1]),o=void 0===i[0]?"":String(i[0]);r?e.text=o+" - "+a:(e.text=a,e.text2=o)}(t,a,r):et(t)?function(t,e,r,n,i){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,i,n);else{var a=e.x/180;if(0===a)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,i=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/i),Math.round(r/i)]}(a);if(o[1]>=100)e.text=G(s.deg2rad(e.x),t,i,n);else{var l=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),l&&(e.text=_+e.text)}}}}(t,a,r,l,p):function(t,e,r,n,i){"never"===i?i="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide");e.text=G(e.x,t,i,n)}(t,a,0,l,p),t.tickprefix&&!d(t.showtickprefix)&&(a.text=t.tickprefix+a.text),t.ticksuffix&&!d(t.showticksuffix)&&(a.text+=t.ticksuffix),"boundaries"===t.tickson||t.showdividers){var g=function(e){var r=t.l2p(e);return r>=0&&r<=t._length?e:null};a.xbnd=[g(a.x-.5),g(a.x+t.dtick-.5)]}return a},T.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return T.hoverLabelText(t,e)+" - "+T.hoverLabelText(t,r);var n="log"===t.type&&e<=0,i=T.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+i:i};var V=["f","p","n","\u03bc","m","","k","M","G","T"];function H(t){return"SI"===t||"B"===t}function q(t){return t>14||t<-15}function G(t,e,r,n){var a=t<0,o=e._tickround,l=r||e.exponentformat||"B",u=e._tickexponent,c=T.getTickFormat(e),f=e.separatethousands;if(n){var h={exponentformat:l,dtick:"none"===e.showexponent?e.dtick:i(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};B(h),o=(Number(h._tickround)||0)+4,u=h._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return e._numFormat(c)(t).replace(/-/g,_);var d,p=Math.pow(10,-o)/2;if("none"===l&&(u=0),(t=Math.abs(t))"+d+"":"B"===l&&9===u?t+="B":H(l)&&(t+=V[u/3+5]));return a?_+t:t}function X(t,e){var r=t._id.charAt(0),n=t._tickAngles[e]||0,i=s.deg2rad(n),a=Math.sin(i),o=Math.cos(i),l=0,u=0;return t._selections[e].each(function(){var t=Z(this),e=f.bBox(t.node()),r=e.width,n=e.height;l=Math.max(l,o*r,a*n),u=Math.max(u,a*r,o*n)}),{x:u,y:l}[r]}function W(t){return[t.text,t.x,t.axInfo,t.font,t.fontSize,t.fontColor].join("_")}function Y(t,e){var r=t.l2p(e);return r>1&&r=0,a=c(t,e[1])<=0;return(r||i)&&(n||a)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(i)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},s=0;s2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":593,"./constants":546}],544:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var i,a=t.categoryarray,o=Array.isArray(a)&&a.length>0;o&&(i="array");var s,l=r("categoryorder",i);"array"===l&&(s=r("categoryarray")),o||"array"!==l||(l=e.categoryorder="trace"),"trace"===l?e._initialCategories=[]:"array"===l?e._initialCategories=s.slice():(s=function(t,e){var r,n,i,a=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;ns*b)||A)for(r=0;rP&&NO&&(O=N);d/=(O-C)/(2*R),C=c.l2r(C),O=c.l2r(O),c.range=c._input.range=E=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function z(t,e,r,n,i){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",i+"Z")}function I(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:u.background,stroke:u.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function N(t,e,r,n,i,a){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),D(t,e,i,a)}function D(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function j(t){E&&t.data&&t._context.showTips&&(s.notifier(s._(t,"Double-click to zoom back out"),"long"),E=!1)}function B(t){return"lasso"===t||"select"===t}function U(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,k)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function V(t,e){if(a){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function H(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,a,u,d,E,S){var D,q,G,X,W,Y,Z,Q,$,J,K,tt,et,rt,nt,it,at,ot,st,lt,ut,ct=t._fullLayout._zoomlayer,ft=E+S==="nsew",ht=1===(E+S).length;function dt(){if(D=e.xaxis,q=e.yaxis,$=D._length,J=q._length,Z=D._offset,Q=q._offset,(G={})[D._id]=D,(X={})[q._id]=q,E&&S)for(var r=e.overlays,n=0;n-1&&w(i,t,W,Y,e.id,kt),a.indexOf("event")>-1&&f.click(t,i,e.id);else if(1===r&&ht){var s=E?q:D,u="s"===E||"w"===S?0:1,c=s._name+".range["+u+"]",h=function(t,e){var r,i=t.range[e],a=Math.abs(i-t.range[1-e]);return"date"===t.type?i:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,i))):(r=Math.floor(Math.log(Math.abs(i))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,n.format("."+String(r)+"g")(i))}(s,u),d="left",p="middle";if(s.fixedrange)return;E?(p="n"===E?"top":"bottom","right"===s.side&&(d="right")):"e"===S&&(d="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(l.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(h),fill:s.tickfont?s.tickfont.color:"#444",horizontalAlign:d,verticalAlign:p}).on("edit",function(e){var r=s.d2r(e);void 0!==r&&o.call("_guiRelayout",t,c,r)})}}function Lt(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min($,e+vt)),i=Math.max(0,Math.min(J,r+mt)),a=Math.abs(n-vt),o=Math.abs(i-mt);function s(){wt="",yt.r=yt.l,yt.t=yt.b,Mt.attr("d","M0,0Z")}yt.l=Math.min(vt,n),yt.r=Math.max(vt,n),yt.t=Math.min(mt,i),yt.b=Math.max(mt,i),nt?a>k||o>k?(wt="xy",a/$>o/J?(o=a*J/$,mt>i?yt.t=mt-o:yt.b=mt+o):(a=o*$/J,vt>n?yt.l=vt-a:yt.r=vt+a),Mt.attr("d",U(yt))):s():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(zt);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var i,a=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=Nt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-o.left)/o.width,u=(o.bottom-e.clientY)/o.height;if(it){for(S||(l=.5),i=0;ig[1]-.01&&(e.domain=s),i.noneOrAll(t.domain,e.domain,s)}return r("layer"),e}},{"../../lib":494,"fast-isnumeric":91}],557:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var i=[t.r2l(t.range[0]),t.r2l(t.range[1])],a=i[0]+(i[1]-i[0])*r;t.range=t._input.range=[t.l2r(a+(i[0]-a)*e),t.l2r(a+(i[1]-a)*e)]}},{"../../constants/alignment":470}],558:[function(t,e,r){"use strict";var n=t("polybooljs"),i=t("../../registry"),a=t("../../components/color"),o=t("../../components/fx"),s=t("../../lib/polygon"),l=t("../../lib/throttle"),u=t("../../components/fx/helpers").makeEventData,c=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),h=t("../../plot_api/subroutines").redrawReglTraces,d=t("./constants"),p=d.MINSELECT,g=s.filter,v=s.tester;function m(t){return t._id}function y(t,e,r,n,i,a,o){var s,l,u,c,f,h,d,p,g,v=e._hoverdata,m=e._fullLayout.clickmode.indexOf("event")>-1,y=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,a);var b=function(t,e){var r,n,i=t[0],a=-1,o=[];for(n=0;n0?function(t,e){var r,n,i,a=[];for(i=0;i0&&a.push(r);if(1===a.length&&a[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(i=0;i1)return!1;if((i+=r.selectedpoints.length)>1)return!1}return 1===i}(s)&&(h=k(b))){for(o&&o.remove(),g=0;g0?"M"+i.join("M")+"Z":"M0,0Z",e.attr("d",n)}function k(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,i=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(i)>-1}function E(t,e,r){var n,a,o,s;for(n=0;n-1&&y(e,k,i.xaxes,i.yaxes,i.subplot,i,q),"event"===r&&k.emit("plotly_selected",void 0);o.click(k,e)})},i.doneFn=function(){X.remove(),l.done(W).then(function(){l.clear(W),i.gd.emit("plotly_selected",x),h&&i.selectionDefs&&(h.subtract=H,i.selectionDefs.push(h),i.mergedPolygons.length=0,[].push.apply(i.mergedPolygons,f))})}},clearSelect:L,selectOnClick:y}},{"../../components/color":375,"../../components/fx":414,"../../components/fx/helpers":410,"../../lib/clear_gl_canvases":482,"../../lib/polygon":506,"../../lib/throttle":518,"../../plot_api/subroutines":531,"../../registry":593,"./axis_ids":543,"./constants":546,polybooljs:298}],559:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=a.cleanNumber,s=a.ms2DateTime,l=a.dateTime2ms,u=a.ensureNumber,c=t("../../constants/numerical"),f=c.FP_SAFE,h=c.BADNUM,d=c.LOG_CLIP,p=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}function m(t){return null!=t}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function c(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-2*d*Math.abs(n-i))}return h}function y(e,r,n){var o=l(e,n||t.calendar);if(o===h){if(!i(e))return h;e=+e;var s=Math.floor(10*a.mod(e+.05,1)),u=Math.round(e-s/10);o=l(new Date(u))+s/10}return o}function b(e,r,n){return s(e,r,n||t.calendar)}function x(e){return t._categories[Math.round(e)]}function _(e){if(m(e)){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return h}function w(e){if(t._categoriesMap)return t._categoriesMap[e]}function A(t){var e=w(t);return void 0!==e?e:i(t)?+t:void 0}function M(e){return i(e)?n.round(t._b+t._m*e,2):h}function T(e){return(e-t._b)/t._m}t.c2l="log"===t.type?c:u,t.l2c="log"===t.type?v:u,t.l2p=M,t.p2l=T,t.c2p="log"===t.type?function(t,e){return M(c(t,e))}:M,t.p2c="log"===t.type?function(t){return v(T(t))}:T,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=u,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=T,t.cleanPos=u):"log"===t.type?(t.d2r=t.d2l=function(t,e){return c(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=u,t.c2r=c,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(T(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=T,t.cleanPos=u):"date"===t.type?(t.d2r=t.r2d=a.identity,t.d2c=t.r2c=t.d2l=t.r2l=y,t.c2d=t.c2r=t.l2d=t.l2r=b,t.d2p=t.r2p=function(e,r,n){return t.l2p(y(e,0,n))},t.p2d=t.p2r=function(t,e,r){return b(T(t),e,r)},t.cleanPos=function(e){return a.cleanDate(e,h,t.calendar)}):"category"===t.type?(t.d2c=t.d2l=_,t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=A,t.r2c=function(e){var r=A(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=u,t.r2l=A,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(T(t))},t.r2p=t.d2p,t.p2r=T,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:u(t)}):"multicategory"===t.type&&(t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=A,t.r2c=function(e){var r=A(e);return void 0!==r?r:t.fraction2r(.5)},t.r2c_just_indices=w,t.l2r=t.c2r=u,t.r2l=A,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(T(t))},t.r2p=t.d2p,t.p2r=T,t.cleanPos=function(t){return Array.isArray(t)||"string"==typeof t&&""!==t?t:u(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,s,l=a.nestedProperty(t,e).get();if(s=(s="date"===t.type?a.dfltRange(t.calendar):"y"===r?p.DFLTRANGEY:n.dfltRange||p.DFLTRANGEX).slice(),l&&2===l.length)for("date"===t.type&&(l[0]=a.cleanDate(l[0],h,t.calendar),l[1]=a.cleanDate(l[1],h,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!a.isDateTime(l[o],t.calendar)){t[e]=s;break}if(t.r2l(l[0])===t.r2l(l[1])){var u=a.constrain(t.r2l(l[0]),a.MIN_MS+1e3,a.MAX_MS-1e3);l[0]=t.l2r(u-1e3),l[1]=t.l2r(u+1e3);break}}else{if(!i(l[o])){if(!i(l[1-o])){t[e]=s;break}l[o]=l[1-o]*(o?10:.1)}if(l[o]<-f?l[o]=-f:l[o]>f&&(l[o]=f),l[0]===l[1]){var c=Math.max(1,Math.abs(1e-6*l[0]));l[0]-=c,l[1]+=c}}else a.nestedProperty(t,e).set(s)},t.setScale=function(n){var i=e._size;if(t.overlaying){var a=g.getFromId({_fullLayout:e},t.overlaying);t.domain=a.domain}var o=n&&t._r?"_r":"range",s=t.calendar;t.cleanRange(o);var l=t.r2l(t[o][0],s),u=t.r2l(t[o][1],s);if("y"===r?(t._offset=i.t+(1-t.domain[1])*i.h,t._length=i.h*(t.domain[1]-t.domain[0]),t._m=t._length/(l-u),t._b=-t._m*u):(t._offset=i.l+t.domain[0]*i.w,t._length=i.w*(t.domain[1]-t.domain[0]),t._m=t._length/(u-l),t._b=-t._m*l),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,i,o,s,l=t.type,u="date"===l&&e[r+"calendar"];if(r in e){if(n=e[r],s=e._length||a.minRowLength(n),a.isTypedArray(n)&&("linear"===l||"log"===l)){if(s===n.length)return n;if(n.subarray)return n.subarray(0,s)}if("multicategory"===l)return function(t,e){var r,n=new Array(e),i=new Array(e),o=[[0,{}],[0,{}]];if(a.isArrayOrTypedArray(t[0])&&a.isArrayOrTypedArray(t[1])){for(r=0;r rect").call(a.setTranslate,0,0).call(a.setScale,1,1),t.plot.call(a.setTranslate,e._offset,r._offset).call(a.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(a.setPointGroupScale,1,1),n.selectAll(".textpoint").call(a.setTextPointsScale,1,1),n.call(a.hideOutsideRangePoints,t)}function b(e,r){var n,s,l,c=g[e.xaxis._id],f=g[e.yaxis._id],h=[];if(c){s=(n=t._fullLayout[c.axisName])._r,l=c.to,h[0]=(s[0]*(1-r)+r*l[0]-s[0])/(s[1]-s[0])*e.xaxis._length;var d=s[1]-s[0],p=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[2]=e.xaxis._length*(1-r+r*p/d)}else h[0]=0,h[2]=e.xaxis._length;if(f){s=(n=t._fullLayout[f.axisName])._r,l=f.to,h[1]=(s[1]*(1-r)+r*l[1]-s[1])/(s[0]-s[1])*e.yaxis._length;var v=s[1]-s[0],m=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[3]=e.yaxis._length*(1-r+r*m/v)}else h[1]=0,h[3]=e.yaxis._length;!function(e,r){var n,a=[e._id,r._id];function s(e,r,i){for(n=0;nr.duration?(function(){for(var e={},r=0;r0&&(i["_"+r+"axes"]||{})[e])return i;if((i[r+"axis"]||r)===e){if(o(i,r))return i;if((i[r]||[]).length||i[r+"0"])return i}}}(e,r,s);if(!l)return;if("histogram"===l.type&&s==={v:"y",h:"x"}[l.orientation||"v"])return void(t.type="linear");var u,c=s+"calendar",f=l[c],h={noMultiCategory:!n(l,"cartesian")||n(l,"noMultiCategory")};if(o(l,s)){var d=a(l),p=[];for(u=0;u0?".":"")+a;i.isPlainObject(o)?l(o,e,s,n+1):e(s,a,o)}})}r.manageCommandObserver=function(t,e,n,o){var s={},l=!0;e&&e._commandObserver&&(s=e._commandObserver),s.cache||(s.cache={}),s.lookupTable={};var u=r.hasSimpleAPICommandBindings(t,n,s.lookupTable);if(e&&e._commandObserver){if(u)return s;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,s}if(u){a(t,u,s.cache),s.check=function(){if(l){var e=a(t,u,s.cache);return e.changed&&o&&void 0!==s.lookupTable[e.value]&&(s.disable(),Promise.resolve(o({value:e.value,type:u.type,prop:u.prop,traces:u.traces,index:s.lookupTable[e.value]})).then(s.enable,s.enable)),e.changed}};for(var c=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;fMath.abs(e))u.rotate(a,0,0,-t*r*Math.PI*p.rotateSpeed/window.innerWidth);else{var o=-p.zoomSpeed*i*e/window.innerHeight*(a-u.lastT())/20;u.pan(a,0,0,f*(Math.exp(o)-1))}}},!0),p};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset"),l=t("has-passive-events")},{"3d-view":11,"has-passive-events":251,"mouse-change":270,"mouse-event-offset":271,"mouse-wheel":273,"right-now":315}],571:[function(t,e,r){"use strict";var n=t("../../plot_api/edit_types").overrideAll,i=t("../../components/fx/layout_attributes"),a=t("./scene"),o=t("../get_data").getSubplotData,s=t("../../lib"),l=t("../../constants/xmlns_namespaces");r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=r.attrRegex=s.counterRegex("scene"),r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.baseLayoutAttrOverrides=n({hoverlabel:i.hoverlabel},"plot","nested"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=e._subplots.gl3d,i=0;i.999&&(d="turntable"):d="turntable"}else d="turntable";r("dragmode",d),r("hovermode",n.getDfltFromLayout("hovermode"))}e.exports=function(t,e,r){var i=e._basePlotModules.length>1;o(t,e,r,{type:"gl3d",attributes:l,handleDefaults:u,fullLayout:e,font:e.font,fullData:r,getDfltFromLayout:function(e){if(!i)return n.validate(t[e],l[e])?t[e]:void 0},paper_bgcolor:e.paper_bgcolor,calendar:e.calendar})}},{"../../../components/color":375,"../../../lib":494,"../../../registry":593,"../../subplot_defaults":592,"./axis_defaults":574,"./layout_attributes":577}],577:[function(t,e,r){"use strict";var n=t("./axis_attributes"),i=t("../../domain").attributes,a=t("../../../lib/extend").extendFlat,o=t("../../../lib").counterRegex;function s(t,e,r){return{x:{valType:"number",dflt:t,editType:"camera"},y:{valType:"number",dflt:e,editType:"camera"},z:{valType:"number",dflt:r,editType:"camera"},editType:"camera"}}e.exports={_arrayAttrRegexps:[o("scene",".annotations",!0)],bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"plot"},camera:{up:a(s(0,0,1),{}),center:a(s(0,0,0),{}),eye:a(s(1.25,1.25,1.25),{}),editType:"camera"},domain:i({name:"scene",editType:"plot"}),aspectmode:{valType:"enumerated",values:["auto","cube","data","manual"],dflt:"auto",editType:"plot",impliedEdits:{"aspectratio.x":void 0,"aspectratio.y":void 0,"aspectratio.z":void 0}},aspectratio:{x:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},y:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},z:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},editType:"plot",impliedEdits:{aspectmode:"manual"}},xaxis:n,yaxis:n,zaxis:n,dragmode:{valType:"enumerated",values:["orbit","turntable","zoom","pan",!1],editType:"plot"},hovermode:{valType:"enumerated",values:["closest",!1],dflt:"closest",editType:"modebar"},uirevision:{valType:"any",editType:"none"},editType:"plot",_deprecated:{cameraposition:{valType:"info_array",editType:"camera"}}}},{"../../../lib":494,"../../../lib/extend":487,"../../domain":566,"./axis_attributes":573}],578:[function(t,e,r){"use strict";var n=t("../../../lib/str2rgbarray"),i=["xaxis","yaxis","zaxis"];function a(){this.enabled=[!0,!0,!0],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.drawSides=[!0,!0,!0],this.lineWidth=[1,1,1]}a.prototype.merge=function(t){for(var e=0;e<3;++e){var r=t[i[e]];r.visible?(this.enabled[e]=r.showspikes,this.colors[e]=n(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness):(this.enabled[e]=!1,this.drawSides[e]=!1)}},e.exports=function(t){var e=new a;return e.merge(t),e}},{"../../../lib/str2rgbarray":516}],579:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.axesOptions,r=t.glplot.axesPixels,s=t.fullSceneLayout,l=[[],[],[]],u=0;u<3;++u){var c=s[a[u]];if(c._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(c._length)===1/0||isNaN(c._length))l[u]=[];else{c._input_range=c.range.slice(),c.range[0]=r[u].lo/t.dataScale[u],c.range[1]=r[u].hi/t.dataScale[u],c._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),c.range[0]===c.range[1]&&(c.range[0]-=1,c.range[1]+=1);var f=c.tickmode;if("auto"===c.tickmode){c.tickmode="linear";var h=c.nticks||i.constrain(c._length/40,4,9);n.autoTicks(c,Math.abs(c.range[1]-c.range[0])/h)}for(var d=n.calcTicks(c),p=0;p/g," "));l[u]=d,c.tickmode=f}}e.ticks=l;for(var u=0;u<3;++u){o[u]=.5*(t.glplot.bounds[0][u]+t.glplot.bounds[1][u]);for(var p=0;p<2;++p)e.bounds[p][u]=t.glplot.bounds[p][u]}t.contourLevels=function(t){for(var e=new Array(3),r=0;r<3;++r){for(var n=t[r],i=new Array(n.length),a=0;a")}else v=u.textLabel;t.fullSceneLayout.hovermode&&f.loneHover({x:(.5+.5*p[0]/p[3])*i,y:(.5-.5*p[1]/p[3])*a,xLabel:w,yLabel:A,zLabel:M,text:v,name:l.name,color:f.castHoverOption(e,m,"bgcolor")||l.color,borderColor:f.castHoverOption(e,m,"bordercolor"),fontFamily:f.castHoverOption(e,m,"font.family"),fontSize:f.castHoverOption(e,m,"font.size"),fontColor:f.castHoverOption(e,m,"font.color")},{container:r,gd:t.graphDiv});var k={x:u.traceCoordinate[0],y:u.traceCoordinate[1],z:u.traceCoordinate[2],data:e._input,fullData:e,curveNumber:e.index,pointNumber:m};e._module.eventData&&(k=e._module.eventData(k,u,e,{},m)),f.appendArrayPointValue(k,e,m);var E={points:[k]};u.buttons&&u.distance<5?t.graphDiv.emit("plotly_click",E):t.graphDiv.emit("plotly_hover",E),o=E}else f.loneUnhover(r),t.graphDiv.emit("plotly_unhover",o);t.drawAnnotations(t)}.bind(null,t),t.traces={},!0}function x(t,e){var r=document.createElement("div"),n=t.container;this.graphDiv=t.graphDiv;var i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.top=i.style.left="0px",i.style.width=i.style.height="100%",i.style["z-index"]=20,i.style["pointer-events"]="none",r.appendChild(i),this.svgContainer=i,r.id=t.id,r.style.position="absolute",r.style.top=r.style.left="0px",r.style.width=r.style.height="100%",n.appendChild(r),this.fullLayout=e,this.id=t.id||"scene",this.fullSceneLayout=e[this.id],this.plotArgs=[[],{},{}],this.axesOptions=v(e[this.id]),this.spikeOptions=m(e[this.id]),this.container=r,this.staticMode=!!t.staticPlot,this.pixelRatio=t.plotGlPixelRatio||2,this.dataScale=[1,1,1],this.contourLevels=[[],[],[]],this.convertAnnotations=l.getComponentMethod("annotations3d","convert"),this.drawAnnotations=l.getComponentMethod("annotations3d","draw"),b(this)}var _=x.prototype;_.recoverContext=function(){var t=this,e=this.glplot.gl,r=this.glplot.canvas;this.glplot.dispose(),requestAnimationFrame(function n(){e.isContextLost()?requestAnimationFrame(n):b(t,r,e)?t.plot.apply(t,t.plotArgs):u.error("Catastrophic and unrecoverable WebGL error. Context lost.")})};var w=["xaxis","yaxis","zaxis"];function A(t,e,r){for(var n=t.fullSceneLayout,i=0;i<3;i++){var a=w[i],o=a.charAt(0),s=n[a],l=e[o],c=e[o+"calendar"],f=e["_"+o+"length"];if(u.isArrayOrTypedArray(l))for(var h,d=0;d<(f||l.length);d++)if(u.isArrayOrTypedArray(l[d]))for(var p=0;pg[1][a])g[0][a]=-1,g[1][a]=1;else{var S=g[1][a]-g[0][a];g[0][a]-=S/32,g[1][a]+=S/32}if("reversed"===s.autorange){var L=g[0][a];g[0][a]=g[1][a],g[1][a]=L}}else{var C=s.range;g[0][a]=s.r2l(C[0]),g[1][a]=s.r2l(C[1])}g[0][a]===g[1][a]&&(g[0][a]-=1,g[1][a]+=1),v[a]=g[1][a]-g[0][a],this.glplot.bounds[0][a]=g[0][a]*d[a],this.glplot.bounds[1][a]=g[1][a]*d[a]}var O=[1,1,1];for(a=0;a<3;++a){var R=m[l=(s=u[w[a]]).type];O[a]=Math.pow(R.acc,1/R.count)/d[a]}var P;if("auto"===u.aspectmode)P=Math.max.apply(null,O)/Math.min.apply(null,O)<=4?O:[1,1,1];else if("cube"===u.aspectmode)P=[1,1,1];else if("data"===u.aspectmode)P=O;else{if("manual"!==u.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var z=u.aspectratio;P=[z.x,z.y,z.z]}u.aspectratio.x=c.aspectratio.x=P[0],u.aspectratio.y=c.aspectratio.y=P[1],u.aspectratio.z=c.aspectratio.z=P[2],this.glplot.aspect=P;var I=u.domain||null,N=e._size||null;if(I&&N){var D=this.container.style;D.position="absolute",D.left=N.l+I.x[0]*N.w+"px",D.top=N.t+(1-I.y[1])*N.h+"px",D.width=N.w*(I.x[1]-I.x[0])+"px",D.height=N.h*(I.y[1]-I.y[0])+"px"}this.glplot.redraw()}},_.destroy=function(){this.glplot&&(this.camera.mouseListener.enabled=!1,this.container.removeEventListener("wheel",this.camera.wheelListener),this.camera=this.glplot.camera=null,this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null)},_.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),M(this.glplot.camera)},_.setCamera=function(t){var e;this.glplot.camera.lookAt.apply(this,[[(e=t).eye.x,e.eye.y,e.eye.z],[e.center.x,e.center.y,e.center.z],[e.up.x,e.up.y,e.up.z]])},_.saveCamera=function(t){var e=this.getCamera(),r=u.nestedProperty(t,this.id+".camera"),n=r.get(),i=!1;function a(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}if(void 0===n)i=!0;else for(var o=0;o<3;o++)for(var s=0;s<3;s++)if(!a(e,n,o,s)){i=!0;break}if(i){r.set(e);var c=this.fullLayout;u.nestedProperty(c,this.id+".camera").set(e),l.call("_storeDirectGUIEdit",t,c._preGUI,e)}return i},_.updateFx=function(t,e){var r=this.camera;if(r)if("orbit"===t)r.mode="orbit",r.keyBindingMode="rotate";else if("turntable"===t){r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate";var n=this.graphDiv,i=n._fullLayout,a=this.fullSceneLayout.camera,o=a.up.x,s=a.up.y,c=a.up.z;if(c/Math.sqrt(o*o+s*s+c*c)>.999)return;var f=this.id+".camera.up",h={x:0,y:0,z:1},d={};d[f]=h;var p=n.layout;l.call("_storeDirectGUIEdit",p,i._preGUI,d),a.up=h,u.nestedProperty(p,f).set(h)}else r.keyBindingMode=t;this.fullSceneLayout.hovermode=e},_.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(n),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,i=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var a=new Uint8Array(r*i*4);e.readPixels(0,0,r,i,e.RGBA,e.UNSIGNED_BYTE,a);for(var o=0,s=i-1;o=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}(t,o),s.text(o.text()&&c.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),i=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return i.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),i.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var b,x=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,i={};function o(t){for(var r=!0,a=0;a1&&P.length>1){for(a.getComponentMethod("grid","sizeDefaults")(u,s),o=0;o15&&P.length>15&&0===s.shapes.length&&0===s.images.length,s._hasCartesian=s._has("cartesian"),s._hasGeo=s._has("geo"),s._hasGL3D=s._has("gl3d"),s._hasGL2D=s._has("gl2d"),s._hasTernary=s._has("ternary"),s._hasPie=s._has("pie"),v.linkSubplots(f,s,c,i),v.cleanPlot(f,s,c,i),p(s,i),s._preGUI||(s._preGUI={}),s._tracePreGUI||(s._tracePreGUI={});var F,j=s._tracePreGUI,B={};for(F in j)B[F]="old";for(o=0;o0){var f=1-2*s;n=Math.round(f*n),a=Math.round(f*a)}}var h=v.layoutAttributes.width.min,d=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-a)>1;(g||p)&&(p&&(r.width=n),g&&(r.height=a)),t._initialAutoSize||(t._initialAutoSize={width:n,height:a}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var i,o,s,u=a.componentsRegistry,c=e._basePlotModules,f=a.subplotsRegistry.cartesian;for(i in u)(s=u[i]).includeBasePlot&&s.includeBasePlot(t,e);for(var h in c.length||c.push(f),e._has("cartesian")&&(a.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[h].sort(l.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var l=void 0!==r.xl?r.xl:r.x,u=void 0!==r.xr?r.xr:r.x,c=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;i[e]={l:{val:l,size:r.l+o},r:{val:u,size:r.r+o},b:{val:f,size:r.b+o},t:{val:c,size:r.t+o}},a[e]=1}else delete i[e],delete a[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),k(e);var r=e._size,n=JSON.stringify(r),o=e.margin,s=o.l,l=o.r,u=o.t,c=o.b,f=e._pushmargin,h=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var d in f)h[d]||delete f[d];for(var p in f.base={l:{val:0,size:s},r:{val:1,size:l},t:{val:1,size:u},b:{val:0,size:c}},f){var g=f[p].l||{},v=f[p].b||{},m=g.val,y=g.size,b=v.val,x=v.size;for(var _ in f){if(i(y)&&f[_].r){var w=f[_].r.val,A=f[_].r.size;if(w>m){var M=(y*w+(A-e.width)*m)/(w-m),T=(A*(1-m)+(y-e.width)*(1-w))/(w-m);M>=0&&T>=0&&M+T>s+l&&(s=M,l=T)}}if(i(x)&&f[_].t){var E=f[_].t.val,S=f[_].t.size;if(E>b){var L=(x*E+(S-e.height)*b)/(E-b),C=(S*(1-b)+(x-e.height)*(1-E))/(E-b);L>=0&&C>=0&&L+C>c+u&&(c=L,u=C)}}}}}if(r.l=Math.round(s),r.r=Math.round(l),r.t=Math.round(u),r.b=Math.round(c),r.p=Math.round(o.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,a.call("plot",t)},v.graphJson=function(t,e,r,n,i){(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var a=i?t._fullData:t.data,o=i?t._fullLayout:t.layout,s=(t._transitionData||{})._frames;function u(t){if("function"==typeof t)return null;if(l.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!l.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;i[e]=u(t[e])}return i}return Array.isArray(t)?t.map(u):l.isTypedArray(t)?l.simpleMap(t,l.identity):l.isJSDate(t)?l.ms2DateTimeLocal(+t):t}var c={data:(a||[]).map(function(t){var r=u(t);return e&&delete r.fit,r})};return e||(c.layout=u(o)),t.framework&&t.framework.isPolar&&(c=t.framework.getConfig()),s&&(c.frames=u(s)),"object"===n?c:JSON.stringify(c)},v.modifyFrames=function(t,e){var r,n,i,a=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){d=!0}),i.redraw&&t._transitionData._interruptCallbacks.push(function(){return a.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,s,u=0,c=0;function f(){return u++,function(){var r;c++,d||c!==u||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(i.redraw)return a.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var p=t._fullLayout._basePlotModules,g=!1;if(r)for(s=0;s=0;s--)if(o[s].enabled){r._indexToPoints=o[s]._indexToPoints;break}n&&n.calc&&(a=n.calc(t,r))}Array.isArray(a)&&a[0]||(a=[{x:c,y:c}]),a[0].t||(a[0].t={}),a[0].trace=r,p[e]=a}}for(y&&E(u),i=0;i=0?h.angularAxis.domain:n.extent(A),S=Math.abs(A[1]-A[0]);T&&!M&&(S=0);var L=E.slice();k&&M&&(L[1]+=S);var C=h.angularAxis.ticksCount||4;C>8&&(C=C/(C/8)+C%8),h.angularAxis.ticksStep&&(C=(L[1]-L[0])/C);var O=h.angularAxis.ticksStep||(L[1]-L[0])/(C*(h.minorTicks+1));w&&(O=Math.max(Math.round(O),1)),L[2]||(L[2]=O);var R=n.range.apply(this,L);if(R=R.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=n.scale.linear().domain(L.slice(0,2)).range("clockwise"===h.direction?[0,360]:[360,0]),c.layout.angularAxis.domain=s.domain(),c.layout.angularAxis.endPadding=k?S:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var P=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),z=this.appendChild(this.ownerDocument.importNode(P.documentElement,!0));t=n.select(z)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var I,N=t.select(".chart-group"),D={fill:"none",stroke:h.tickColor},F={"font-size":h.font.size,"font-family":h.font.family,fill:h.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+h.font.outlineColor}).join(",")};if(h.showLegend){I=t.select(".legend-group").attr({transform:"translate("+[b,h.margin.top]+")"}).style({display:"block"});var j=d.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:I,elements:j,reverseOrder:h.legend.reverseOrder})})();var B=I.node().getBBox();b=Math.min(h.width-B.width-h.margin.left-h.margin.right,h.height-h.margin.top-h.margin.bottom)/2,b=Math.max(10,b),_=[h.margin.left+b,h.margin.top+b],r.range([0,b]),c.layout.radialAxis.domain=r.domain(),I.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else I=t.select(".legend-group").style({display:"none"});t.attr({width:h.width,height:h.height}).style({opacity:h.opacity}),N.attr("transform","translate("+_+")").style({cursor:"crosshair"});var U=[(h.width-(h.margin.left+h.margin.right+2*b+(B?B.width:0)))/2,(h.height-(h.margin.top+h.margin.bottom+2*b))/2];if(U[0]=Math.max(0,U[0]),U[1]=Math.max(0,U[1]),t.select(".outer-group").attr("transform","translate("+U+")"),h.title&&h.title.text){var V=t.select("g.title-group text").style(F).text(h.title.text),H=V.node().getBBox();V.attr({x:_[0]-H.width/2,y:_[1]-b-20})}var q=t.select(".radial.axis-group");if(h.radialAxis.gridLinesVisible){var G=q.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(D),G.attr("r",r),G.exit().remove()}q.select("circle.outside-circle").attr({r:b}).style(D);var X=t.select("circle.background-circle").attr({r:b}).style({fill:h.backgroundColor,stroke:h.stroke});function W(t,e){return s(t)%360+h.orientation}if(h.radialAxis.visible){var Y=n.svg.axis().scale(r).ticks(5).tickSize(5);q.call(Y).attr({transform:"rotate("+h.radialAxis.orientation+")"}),q.selectAll(".domain").style(D),q.selectAll("g>text").text(function(t,e){return this.textContent+h.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===h.radialAxis.tickOrientation?"rotate("+-h.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),q.selectAll("g>line").style({stroke:"black"})}var Z=t.select(".angular.axis-group").selectAll("g.angular-tick").data(R),Q=Z.enter().append("g").classed("angular-tick",!0);Z.attr({transform:function(t,e){return"rotate("+W(t)+")"}}).style({display:h.angularAxis.visible?"block":"none"}),Z.exit().remove(),Q.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(h.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(h.minorTicks+1)==0)}).style(D),Q.selectAll(".minor").style({stroke:h.minorTickColor}),Z.select("line.grid-line").attr({x1:h.tickLength?b-h.tickLength:0,x2:b}).style({display:h.angularAxis.gridLinesVisible?"block":"none"}),Q.append("text").classed("axis-text",!0).style(F);var $=Z.select("text.axis-text").attr({x:b+h.labelOffset,dy:a+"em",transform:function(t,e){var r=W(t),n=b+h.labelOffset,i=h.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:h.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(h.minorTicks+1)!=0?"":w?w[t]+h.angularAxis.ticksSuffix:t+h.angularAxis.ticksSuffix}).style(F);h.angularAxis.rewriteTicks&&$.text(function(t,e){return e%(h.minorTicks+1)!=0?"":h.angularAxis.rewriteTicks(this.textContent,e)});var J=n.max(N.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));I.attr({transform:"translate("+[b+J,h.margin.top]+")"});var K=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(d);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),d[0]||K){var et=[];d.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=s,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=h.orientation,n.direction=h.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return i(o[r].defaultConfig(),t)});o[r]().config(n)()})}var it,at,ot=t.select(".guides-group"),st=t.select(".tooltips-group"),lt=o.tooltipPanel().config({container:st,fontSize:8})(),ut=o.tooltipPanel().config({container:st,fontSize:8})(),ct=o.tooltipPanel().config({container:st,hasTick:!0})();if(!M){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});N.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(X).angle;ft.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-h.orientation)%360;it=s.invert(n);var i=o.util.convertToCartesian(b+12,r+180);lt.text(o.util.round(it)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var ht=ot.select("circle").style({stroke:"grey",fill:"none"});N.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(X).radius;ht.attr({r:n}).style({opacity:.5}),at=r.invert(o.util.getMousePos(X).radius);var i=o.util.convertToCartesian(n,h.radialAxis.orientation);ut.text(o.util.round(at)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){ht.style({opacity:0}),ct.hide(),lt.hide(),ut.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var i=n.select(this),a=this.style.fill,s="black",l=this.style.opacity||1;if(i.attr({"data-opacity":l}),a&&"none"!==a){i.attr({"data-fill":a}),s=n.hsl(a).darker().toString(),i.style({fill:s,opacity:1});var u={t:o.util.round(e[0]),r:o.util.round(e[1])};M&&(u.t=w[e[0]]);var c="t: "+u.t+", r: "+u.r,f=this.getBoundingClientRect(),h=t.node().getBoundingClientRect(),d=[f.left+f.width/2-U[0]-h.left,f.top+f.height/2-U[1]-h.top];ct.config({color:s}).text(c),ct.move(d)}else a=this.style.stroke||"black",i.attr({"data-stroke":a}),s=n.hsl(a).darker().toString(),i.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ct.show()}).on("mouseout.tooltip",function(t,e){ct.hide();var r=n.select(this),i=r.attr("data-fill");i?r.style({fill:i,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(u),this},h.config=function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),i(l.data[e],o.Axis.defaultConfig().data[0]),i(l.data[e],t)}),i(l.layout,o.Axis.defaultConfig().layout),i(l.layout,e.layout),this},h.getLiveConfig=function(){return c},h.getinputConfig=function(){return u},h.radialScale=function(t){return r},h.angularScale=function(t){return s},h.svg=function(){return t},n.rebind(h,f,"on"),h},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var i=e||6,a=[],o=[];n.range(0,360+i,i).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],i=e[1],a={};return a.x=r,a.y=i,a.pos=e,a.angle=180*(Math.atan2(i,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+i*i),a},o.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;i0)){var l=n.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:c(s),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return p.fill(r,i,a)},"fill-opacity":0,stroke:function(t,e){return p.stroke(r,i,a)},"stroke-width":function(t,e){return p["stroke-width"](r,i,a)},"stroke-dasharray":function(t,e){return p["stroke-dasharray"](r,i,a)},opacity:function(t,e){return p.opacity(r,i,a)},display:function(t,e){return p.display(r,i,a)}})}};var f=e.angularScale.range(),h=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,d=n.svg.arc().startAngle(function(t){return-h/2}).endAngle(function(t){return h/2}).innerRadius(function(t){return e.radialScale(l+(t[2]||0))}).outerRadius(function(t){return e.radialScale(l+(t[2]||0))+e.radialScale(t[1])});u.arc=function(t,r,i){n.select(this).attr({class:"mark arc",d:d,transform:function(t,r){return"rotate("+(e.orientation+s(t[0])+90)+")"}})};var p={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,i){return r[t[i].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(p).each(u[e.geometryType]),v.exit().remove(),g.exit().remove()})}return a.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),i(t[r],o.PolyChart.defaultConfig()),i(t[r],e)}),this):t},a.getColorScale=function(){},n.rebind(a,e,"on"),a},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,a=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var a=i({},e.elements[r]);return a.name=t,a.color=[].concat(e.elements[r].color)[n],a})}),o=n.merge(a);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var s=e.container;("string"==typeof s||s.nodeName)&&(s=n.select(s));var l=o.map(function(t,e){return t.color}),u=e.fontSize,c=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=c?e.height:u*o.length,h=s.classed("legend-group",!0).selectAll("svg").data([0]),d=h.enter().append("svg").attr({width:300,height:f+u,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});d.append("g").classed("legend-axis",!0),d.append("g").classed("legend-marks",!0);var p=n.range(o.length),g=n.scale[c?"linear":"ordinal"]().domain(p).range(l),v=n.scale[c?"linear":"ordinal"]().domain(p)[c?"range":"rangePoints"]([0,f]);if(c){var m=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);m.enter().append("stop"),m.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var y=h.select(".legend-marks").selectAll("path.legend-mark").data(o);y.enter().append("path").classed("legend-mark",!0),y.attr({transform:function(t,e){return"translate("+[u/2,v(e)+u/2]+")"},d:function(t,e){var r,i,a,o=t.symbol;return a=3*(i=u),"line"===(r=o)?"M"+[[-i/2,-i/12],[i/2,-i/12],[i/2,i/12],[-i/2,i/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(a)():n.svg.symbol().type("square").size(a)()},fill:function(t,e){return g(e)}}),y.exit().remove()}var b=n.svg.axis().scale(v).orient("right"),x=h.select("g.legend-axis").attr({transform:"translate("+[c?e.colorBandWidth:u,u/2]+")"}).call(b);return x.selectAll(".domain").style({fill:"none",stroke:"none"}),x.selectAll("line").style({fill:"none",stroke:c?e.textColor:"none"}),x.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(i(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,a={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,u=function(){var n=(t=a.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:a.padding+l,dy:.3*+a.fontSize}),u};return u.text=function(i){var o=n.hsl(a.color).l,s=o>=.5?"#aaa":"white",c=o>=.5?"black":"white",f=i||"";e.style({fill:c,"font-size":a.fontSize+"px"}).text(f);var h=a.padding,d=e.node().getBBox(),p={fill:a.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[a.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),u},u.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),u},u.hide=function(){if(t)return t.style({display:"none"}),u},u.show=function(){if(t)return t.style({display:"block"}),u},u.config=function(t){return i(a,t),u},u},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=i({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var a=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=a.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var s=i({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var l=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],c={};n.entries(s.margin).forEach(function(t,e){c[u[l.indexOf(t.key)]]=t.value}),s.margin=c}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r}};return t}},{"../../../constants/alignment":470,"../../../lib":494,d3:82}],590:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../../lib"),a=t("../../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=i.extendDeepAll,u=e.exports={};u.framework=function(t){var e,r,i,a,c,f=new s;function h(r,s){return s&&(c=s),n.select(n.select(c).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?l(e,r):r,i||(i=o.Axis()),a=o.adapter.plotly().convert(e),i.config(a).render(c),t.data=e.data,t.layout=e.layout,u.fillLayout(t),e}return h.isPolar=!0,h.svg=function(){return i.svg()},h.getConfig=function(){return e},h.getLiveConfig=function(){return o.adapter.plotly().convert(i.getLiveConfig(),!0)},h.getLiveScales=function(){return{t:i.angularScale(),r:i.radialScale()}},h.setUndoPoint=function(){var t,n,i=this,a=o.util.cloneJson(e);t=a,n=r,f.add({undo:function(){n&&i(n)},redo:function(){i(t)}}),r=o.util.cloneJson(a)},h.undo=function(){f.undo()},h.redo=function(){f.redo()},h},u.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),i=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:a.background,_container:e,_paperdiv:r,_paper:i};t._fullLayout=l(o,t.layout)}},{"../../../components/color":375,"../../../lib":494,"./micropolar":589,"./undo_manager":591,d3:82}],591:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function i(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(i(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(i(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r-1&&(c[h[r]].title={text:""});for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(l,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(l,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||h.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),h.node().setAttributeNS(s.xmlns,"xmlns",s.svg),h.node().setAttributeNS(s.xmlns,"xmlns:xlink",s.xlink),"svg"===e&&r&&(h.attr("width",r*p),h.attr("height",r*g),h.attr("viewBox","0 0 "+p+" "+g));var _=(new window.XMLSerializer).serializeToString(h.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(u,"'"),i.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":375,"../components/drawing":396,"../constants/xmlns_namespaces":475,"../lib":494,d3:82}],602:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),a=t("../mesh3d/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat,l={x:{valType:"data_array",editType:"calc+clearAxisTypes"},y:{valType:"data_array",editType:"calc+clearAxisTypes"},z:{valType:"data_array",editType:"calc+clearAxisTypes"},u:{valType:"data_array",editType:"calc"},v:{valType:"data_array",editType:"calc"},w:{valType:"data_array",editType:"calc"},sizemode:{valType:"enumerated",values:["scaled","absolute"],editType:"calc",dflt:"scaled"},sizeref:{valType:"number",editType:"calc",min:0},anchor:{valType:"enumerated",editType:"calc",values:["tip","tail","cm","center"],dflt:"cm"},text:{valType:"string",dflt:"",arrayOk:!0,editType:"calc"}};s(l,n("",{colorAttr:"u/v/w norm",showScaleDflt:!0,editTypeOverride:"calc"}),{colorbar:i});["opacity","lightposition","lighting"].forEach(function(t){l[t]=a[t]}),l.hoverinfo=s({},o.hoverinfo,{editType:"calc",flags:["x","y","z","u","v","w","norm","text","name"],dflt:"x+y+z+norm+text+name"}),l.transforms=void 0,e.exports=l},{"../../components/colorbar/attributes":376,"../../components/colorscale/attributes":382,"../../lib/extend":487,"../../plots/attributes":537,"../mesh3d/attributes":607}],603:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc");e.exports=function(t,e){for(var r=e.u,i=e.v,a=e.w,o=Math.min(e.x.length,e.y.length,e.z.length,r.length,i.length,a.length),s=-1/0,l=1/0,u=0;u0)c=a(t.alphahull,f);else{var d=["x","y","z"].indexOf(t.delaunayaxis);c=i(f.map(function(t){return[t[(d+1)%3],t[(d+2)%3]]}))}var p={positions:f,cells:c,lightPosition:[t.lightposition.x,t.lightposition.y,t.lightposition.z],ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,vertexNormalsEpsilon:t.lighting.vertexnormalsepsilon,faceNormalsEpsilon:t.lighting.facenormalsepsilon,opacity:t.opacity,contourEnable:t.contour.show,contourColor:l(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.vertexIntensityBounds=[t.cmin,t.cmax],p.colormap=s(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolor[0],p.vertexColors=h(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=h(t.facecolor)):(this.color=t.color,p.meshColor=l(t.color)),this.mesh.update(p)},f.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=function(t,e){var r=t.glplot.gl,i=n({gl:r}),a=new c(t,i,e.uid);return i._trace=a,a.update(e),t.glplot.add(i),a}},{"../../lib/gl_format_color":492,"../../lib/str2rgbarray":516,"../../plots/gl3d/zip3":582,"alpha-shape":16,"convex-hull":73,"delaunay-triangulate":84,"gl-mesh3d":139}],610:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}function u(t){var e=t.map(function(t){var e=l(t);return e&&i.isArrayOrTypedArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=u(["x","y","z"]),f=u(["i","j","k"]);c?(f&&f.forEach(function(t){for(var e=0;es&&T[v].gap;)v--;for(y=T[v].s,p=T.length-1;p>v;p--)T[p].s=y;for(;sk[c]&&c=0;i--){var a=t[i];if("scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}}}}},{}],622:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("./constants"),s=t("./subtypes"),l=t("./xy_defaults"),u=t("./stack_defaults"),c=t("./marker_defaults"),f=t("./line_defaults"),h=t("./line_shape_defaults"),d=t("./text_defaults"),p=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,i){return n.coerce(t,e,a,r,i)}var m=l(t,e,g,v);if(m||(e.visible=!1),e.visible){var y=u(t,e,g,v),b=!y&&mG!=(D=R[C][1])>=G&&(z=R[C-1][0],I=R[C][0],D-N&&(P=z+(I-z)*(G-N)/(D-N),U=Math.min(U,P),V=Math.max(V,P)));U=Math.max(U,0),V=Math.min(V,h._length);var X=s.defaultLine;return s.opacity(f.fillcolor)?X=f.fillcolor:s.opacity((f.line||{}).color)&&(X=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:U,x1:V,y0:G,y1:G,color:X,hovertemplate:"%{name}"}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":375,"../../components/fx":414,"../../lib":494,"../../registry":593,"./fill_hover_text":623,"./get_trace_color":625}],627:[function(t,e,r){"use strict";var n={},i=t("./subtypes");n.hasLines=i.hasLines,n.hasMarkers=i.hasMarkers,n.hasText=i.hasText,n.isBubble=i.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":552,"./arrays_to_calcdata":614,"./attributes":615,"./calc":616,"./cross_trace_calc":620,"./cross_trace_defaults":621,"./defaults":622,"./hover":626,"./marker_colorbar":633,"./plot":635,"./select":636,"./style":638,"./subtypes":639}],628:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s,l){var u=(t.marker||{}).color;(s("line.color",r),i(t,"line"))?a(t,e,o,s,{prefix:"line.",cLetter:"c",noScale:!0}):s("line.color",!n(u)&&u||r);s("line.width"),(l||{}).noDash||s("line.dash")}},{"../../components/colorscale/defaults":385,"../../components/colorscale/helpers":386,"../../lib":494}],629:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),i=n.BADNUM,a=n.LOG_CLIP,o=a+.5,s=a-.5,l=t("../../lib"),u=l.segmentsIntersect,c=l.constrain,f=t("./constants");e.exports=function(t,e){var r,n,a,h,d,p,g,v,m,y,b,x,_,w,A,M,T,k,E=e.xaxis,S=e.yaxis,L="log"===E.type,C="log"===S.type,O=E._length,R=S._length,P=e.connectGaps,z=e.baseTolerance,I=e.shape,N="linear"===I,D=[],F=f.minTolerance,j=new Array(t.length),B=0;function U(e){var r=t[e];if(!r)return!1;var n=E.c2p(r.x),a=S.c2p(r.y);if(n===i){if(L&&(n=E.c2p(r.x,!0)),n===i)return!1;C&&a===i&&(n*=Math.abs(E._m*R*(E._m>0?o:s)/(S._m*O*(S._m>0?o:s)))),n*=1e3}if(a===i){if(C&&(a=S.c2p(r.y,!0)),a===i)return!1;a*=1e3}return[n,a]}function V(t,e,r,n){var i=r-t,a=n-e,o=.5-t,s=.5-e,l=i*i+a*a,u=i*o+a*s;if(u>0&&utt||t[1]rt)return[c(t[0],K,tt),c(t[1],et,rt)]}function at(t,e){return t[0]===e[0]&&(t[0]===K||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,i){var a=it(n),o=it(i),s=[];if(a&&o&&at(a,o))return s;a&&s.push(a),o&&s.push(o);var u=2*l.constrain((n[t]+i[t])/2,e,r)-((a||n)[t]+(o||i)[t]);u&&((a&&o?u>0==a[t]>o[t]?a:o:a||o)[t]+=u);return s}}function st(t){var e=t[0],r=t[1],n=e===j[B-1][0],i=r===j[B-1][1];if(!n||!i)if(B>1){var a=e===j[B-2][0],o=r===j[B-2][1];n&&(e===K||e===tt)&&a?o?B--:j[B-1]=t:i&&(r===et||r===rt)&&o?a?B--:j[B-1]=t:j[B++]=t}else j[B++]=t}function lt(t){j[B-1][0]!==t[0]&&j[B-1][1]!==t[1]&&st([W,Y]),st(t),Z=null,W=Y=0}function ut(t){if(T=t[0]/O,k=t[1]/R,G=t[0]tt?tt:0,X=t[1]rt?rt:0,G||X){if(B)if(Z){var e=$(Z,t);e.length>1&&(lt(e[0]),j[B++]=e[1])}else Q=$(j[B-1],t)[0],j[B++]=Q;else j[B++]=[G||t[0],X||t[1]];var r=j[B-1];G&&X&&(r[0]!==G||r[1]!==X)?(Z&&(W!==G&&Y!==X?st(W&&Y?(n=Z,a=(i=t)[0]-n[0],o=(i[1]-n[1])/a,(n[1]*i[0]-i[1]*n[0])/a>0?[o>0?K:tt,rt]:[o>0?tt:K,et]):[W||G,Y||X]):W&&Y&&st([W,Y])),st([G,X])):W-G&&Y-X&&st([G||W,X||Y]),Z=t,W=G,Y=X}else Z&<($(Z,t)[0]),j[B++]=t;var n,i,a,o}for("linear"===I||"spline"===I?$=function(t,e){for(var r=[],n=0,i=0;i<4;i++){var a=nt[i],o=u(t[0],t[1],e[0],e[1],a[0],a[1],a[2],a[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&q(o,t)H(p,ct))break;a=p,(_=m[0]*v[0]+m[1]*v[1])>b?(b=_,h=p,g=!1):_=t.length||!p)break;ut(p),n=p}}else ut(h)}Z&&st([W||Z[0],Y||Z[1]]),D.push(j.slice(0,B))}return D}},{"../../constants/numerical":474,"../../lib":494,"./constants":619}],630:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],631:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var i,a,o,s,l,u={},c=!1,f=-1,h=0,d=-1;for(a=0;a=0?l=d:(l=d=h,h++),l0?Math.max(e,i):0}}},{"fast-isnumeric":91}],633:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],634:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l,u){var c=o.isBubble(t),f=(t.line||{}).color;(u=u||{},f&&(r=f),l("marker.symbol"),l("marker.opacity",c?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),u.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),u.noLine||(l("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:c?n.background:n.defaultLine),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",c?1:0)),c&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),u.gradient)&&("none"!==l("marker.gradient.type")&&l("marker.gradient.color"))}},{"../../components/color":375,"../../components/colorscale/defaults":385,"../../components/colorscale/helpers":386,"./subtypes":639}],635:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../registry"),a=t("../../lib"),o=a.ensureSingle,s=a.identity,l=t("../../components/drawing"),u=t("./subtypes"),c=t("./line_points"),f=t("./link_traces"),h=t("../../lib/polygon").tester;function d(t,e,r,f,d,p,g){var v;!function(t,e,r,i,o){var s=r.xaxis,l=r.yaxis,c=n.extent(a.simpleMap(s.range,s.r2c)),f=n.extent(a.simpleMap(l.range,l.r2c)),h=i[0].trace;if(!u.hasMarkers(h))return;var d=h.marker.maxdisplayed;if(0===d)return;var p=i.filter(function(t){return t.x>=c[0]&&t.x<=c[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(p.length/d),v=0;o.forEach(function(t,r){var n=t[0].trace;u.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function y(t){return m?t.transition():t}var b=r.xaxis,x=r.yaxis,_=f[0].trace,w=_.line,A=n.select(p),M=o(A,"g","errorbars"),T=o(A,"g","lines"),k=o(A,"g","points"),E=o(A,"g","text");if(i.getComponentMethod("errorbars","plot")(t,M,r,g),!0===_.visible){var S,L;y(A).style("opacity",_.opacity);var C=_.fill.charAt(_.fill.length-1);"x"!==C&&"y"!==C&&(C=""),r.isRangePlot||(f[0].node3=A);var O="",R=[],P=_._prevtrace;P&&(O=P._prevRevpath||"",L=P._nextFill,R=P._polygons);var z,I,N,D,F,j,B,U,V,H="",q="",G=[],X=a.noop;if(S=_._ownFill,u.hasLines(_)||"none"!==_.fill){for(L&&L.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(N=l.steps(w.shape),D=l.steps(w.shape.split("").reverse().join(""))):N=D="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?l.smoothclosed(t.slice(1),w.smoothing):l.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return D(t.reverse())},G=c(f,{xaxis:b,yaxis:x,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),V=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)y(r.style("opacity",0).attr("d",z).call(l.lineGroupStyle)).style("opacity",1);else{var i=y(r);i.attr("d",z),l.singleLineStyle(f,i)}}}}}var W=T.selectAll(".js-line").data(G);y(W.exit()).style("opacity",0).remove(),W.each(X(!1)),W.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(l.lineGroupStyle).each(X(!0)),l.setClipUrl(W,r.layerClipId,t),G.length?(S?(S.datum(f),j&&U&&(C?("y"===C?j[1]=U[1]=x.c2p(0,!0):"x"===C&&(j[0]=U[0]=b.c2p(0,!0)),y(S).attr("d","M"+U+"L"+j+"L"+H.substr(1)).call(l.singleFillStyle)):y(S).attr("d",H+"Z").call(l.singleFillStyle))):L&&("tonext"===_.fill.substr(0,6)&&H&&O?("tonext"===_.fill?y(L).attr("d",H+"Z"+O+"Z").call(l.singleFillStyle):y(L).attr("d",H+"L"+O.substr(1)+"Z").call(l.singleFillStyle),_._polygons=_._polygons.concat(R)):(Z(L),_._polygons=null)),_._prevRevpath=q,_._prevPolygons=V):(S?Z(S):L&&Z(L),_._polygons=_._prevRevpath=_._prevPolygons=null),k.datum(f),E.datum(f),function(e,i,a){var o,c=a[0].trace,f=u.hasMarkers(c),h=u.hasText(c),d=tt(c),p=et,g=et;if(f||h){var v=s,_=c.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[b._id+x._id][_].stackgaps;c.marker.maxdisplayed||c._needsCull?v=w?$:Q:_&&!w&&(v=J),f&&(p=v),h&&(g=v)}var A,M=(o=e.selectAll("path.point").data(p,d)).enter().append("path").classed("point",!0);m&&M.call(l.pointStyle,c,t).call(l.translatePoints,b,x).style("opacity",0).transition().style("opacity",1),o.order(),f&&(A=l.makePointStyleFns(c)),o.each(function(e){var i=n.select(this),a=y(i);l.translatePoint(e,a,b,x)?(l.singlePointStyle(e,a,c,A,t),r.layerClipId&&l.hideOutsideRangePoint(e,a,b,x,c.xcalendar,c.ycalendar),c.customdata&&i.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):a.remove()}),m?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=i.selectAll("g").data(g,d)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),i=y(e.select("text"));l.translatePoint(t,i,b,x)?r.layerClipId&&l.hideOutsideRangePoint(t,e,b,x,c.xcalendar,c.ycalendar):e.remove()}),o.selectAll("text").call(l.textPointStyle,c,t).each(function(t){var e=b.c2p(t.x),r=x.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){y(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(k,E,f);var Y=!1===_.cliponaxis?null:r.layerClipId;l.setClipUrl(k,Y,t),l.setClipUrl(E,Y,t)}function Z(t){y(t).attr("d","M0,0Z")}function Q(t){return t.filter(function(t){return!t.gap&&t.vis})}function $(t){return t.filter(function(t){return t.vis})}function J(t){return t.filter(function(t){return!t.gap})}function K(t){return t.id}function tt(t){if(t.ids)return K}function et(){return!1}}e.exports=function(t,e,r,i,a,u){var c,h,p=!a,g=!!a&&a.duration>0,v=f(t,e,r);((c=i.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),c.order(),function(t,e,r){e.each(function(e){var i=o(n.select(this),"g","fills");l.setClipUrl(i,r.layerClipId,t);var a=e[0].trace,u=[];a._ownfill&&u.push("_ownFill"),a._nexttrace&&u.push("_nextFill");var c=i.selectAll("g").data(u,s);c.enter().append("g"),c.exit().each(function(t){a[t]=null}).remove(),c.order().each(function(t){a[t]=o(n.select(this),"path","js-fill")})})}(t,c,e),g)?(u&&(h=u()),n.transition().duration(a.duration).ease(a.easing).each("end",function(){h&&h()}).each("interrupt",function(){h&&h()}).each(function(){i.selectAll("g.trace").each(function(r,n){d(t,n,e,r,v,this,a)})})):c.each(function(r,n){d(t,n,e,r,v,this,a)});p&&c.exit().remove(),i.selectAll("path:not([d])").remove()}},{"../../components/drawing":396,"../../lib":494,"../../lib/polygon":506,"../../registry":593,"./line_points":629,"./link_traces":631,"./subtypes":639,d3:82}],636:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,i,a,o,s=t.cd,l=t.xaxis,u=t.yaxis,c=[],f=s[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r0){var h=i.c2l(c);i._lowerLogErrorBound||(i._lowerLogErrorBound=h),i._lowerErrorBound=Math.min(i._lowerLogErrorBound,h)}}else o[s]=[-l[0]*r,l[1]*r]}return o}e.exports=function(t,e,r){var n=[i(t.x,t.error_x,e[0],r.xaxis),i(t.y,t.error_y,e[1],r.yaxis),i(t.z,t.error_z,e[2],r.zaxis)],a=function(t){for(var e=0;e-1?-1:t.indexOf("right")>-1?1:0}function y(t){return null==t?0:t.indexOf("top")>-1?-1:t.indexOf("bottom")>-1?1:0}function b(t,e){return e(4*t)}function x(t){return d[t]}function _(t,e,r,n,i){var a=null;if(l.isArrayOrTypedArray(t)){a=[];for(var o=0;o=0){var g=function(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],l=[];for(n=0;n=0&&f("surfacecolor",h||d);for(var p=["x","y","z"],g=0;g<3;++g){var v="projection."+p[g];f(v+".show")&&(f(v+".opacity"),f(v+".scale"))}var m=n.getComponentMethod("errorbars","supplyDefaults");m(t,e,r,{axis:"z"}),m(t,e,r,{axis:"y",inherit:"z"}),m(t,e,r,{axis:"x",inherit:"z"})}else e.visible=!1}},{"../../lib":494,"../../registry":593,"../scatter/line_defaults":628,"../scatter/marker_defaults":634,"../scatter/subtypes":639,"../scatter/text_defaults":640,"./attributes":642}],647:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl3d_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","showLegend"],n.meta={},e.exports=n},{"../../constants/gl3d_markers":472,"../../plots/gl3d":571,"../scatter/marker_colorbar":633,"./attributes":642,"./calc":643,"./convert":645,"./defaults":646}],648:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),a=t("../mesh3d/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat,l={x:{valType:"data_array",editType:"calc+clearAxisTypes"},y:{valType:"data_array",editType:"calc+clearAxisTypes"},z:{valType:"data_array",editType:"calc+clearAxisTypes"},u:{valType:"data_array",editType:"calc"},v:{valType:"data_array",editType:"calc"},w:{valType:"data_array",editType:"calc"},starts:{x:{valType:"data_array",editType:"calc"},y:{valType:"data_array",editType:"calc"},z:{valType:"data_array",editType:"calc"},editType:"calc"},maxdisplayed:{valType:"integer",min:0,dflt:1e3,editType:"calc"},sizeref:{valType:"number",editType:"calc",min:0,dflt:1},text:{valType:"string",dflt:"",editType:"calc"}};s(l,n("",{colorAttr:"u/v/w norm",showScaleDflt:!0,editTypeOverride:"calc"}),{colorbar:i});["opacity","lightposition","lighting"].forEach(function(t){l[t]=a[t]}),l.hoverinfo=s({},o.hoverinfo,{editType:"calc",flags:["x","y","z","u","v","w","norm","divergence","text","name"],dflt:"x+y+z+norm+text+name"}),l.transforms=void 0,e.exports=l},{"../../components/colorbar/attributes":376,"../../components/colorscale/attributes":382,"../../lib/extend":487,"../../plots/attributes":537,"../mesh3d/attributes":607}],649:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc");e.exports=function(t,e){var r,i,a,o,s=e.u,l=e.v,u=e.w,c=e.x,f=e.y,h=e.z,d=Math.min(c.length,f.length,h.length,s.length,l.length,u.length),p=0;e.starts&&(i=e.starts.x||[],a=e.starts.y||[],o=e.starts.z||[],p=Math.min(i.length,a.length,o.length));var g=0,v=1/0;for(r=0;r2?t.slice(1,e-1):2===e?[(t[0]+t[1])/2]:t}function d(t){var e=t.length;return 1===e?[.5,.5]:[t[1]-t[0],t[e-1]-t[e-2]]}function p(t,e){var r=t.fullSceneLayout,i=t.dataScale,u=e._len,c={};function p(t,e){var n=r[e],o=i[l[e]];return a.simpleMap(t,function(t){return n.d2l(t)*o})}c.vectors=s(p(e.u,"xaxis"),p(e.v,"yaxis"),p(e.w,"zaxis"),u);var g=f(e.x.slice(0,u)),v=f(e.y.slice(0,u)),m=f(e.z.slice(0,u));if(g.length*v.length*m.length>u)return{positions:[],cells:[]};var y=p(g,"xaxis"),b=p(v,"yaxis"),x=p(m,"zaxis");if(c.meshgrid=[y,b,x],e.starts){var _=e._slen;c.startingPositions=s(p(e.starts.x.slice(0,_),"xaxis"),p(e.starts.y.slice(0,_),"yaxis"),p(e.starts.z.slice(0,_),"zaxis"))}else{for(var w=b[0],A=h(y),M=h(x),T=new Array(A.length*M.length),k=0,E=0;E0){r=h[n];break}return r}function v(t,e){if(!(t<1||e<1)){for(var r=p(t),n=p(e),i=1,a=0;ab;)r--,r/=g(r),++r1?n:1},f.refineCoords=function(t){for(var e=this.dataScaleX,r=this.dataScaleY,n=t[0].shape[0],o=t[0].shape[1],s=0|Math.floor(t[0].shape[0]*e+1),l=0|Math.floor(t[0].shape[1]*r+1),u=1+n+1,c=1+o+1,f=i(new Float32Array(u*c),[u,c]),h=0;ha&&(this.minValues[e]=a),this.maxValues[e]:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", + "X:hover .modebar--hover .modebar-group": "opacity:1;", "X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;", "X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;", "X .modebar-btn svg": "position:relative;top:2px;", @@ -71,7 +71,7 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":162}],2:[function(_dereq_,module,exports){ +},{"../src/lib":160}],2:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -214,7 +214,7 @@ module.exports = { module.exports = _dereq_('../src/core'); -},{"../src/core":145}],4:[function(_dereq_,module,exports){ +},{"../src/core":142}],4:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -246,7 +246,7 @@ module.exports = Plotly; module.exports = _dereq_('../src/traces/scattermapbox'); -},{"../src/traces/scattermapbox":300}],6:[function(_dereq_,module,exports){ +},{"../src/traces/scattermapbox":298}],6:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -15135,7 +15135,7 @@ module.exports = templatedArray('annotation', { } }); -},{"../../plot_api/plot_template":196,"../../plots/cartesian/constants":212,"../../plots/font_attributes":233,"./arrow_paths":27}],29:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":194,"../../plots/cartesian/constants":210,"../../plots/font_attributes":231,"./arrow_paths":27}],29:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15224,7 +15224,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":162,"../../plots/cartesian/axes":206,"./draw":34}],30:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plots/cartesian/axes":204,"./draw":34}],30:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15363,7 +15363,7 @@ function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":162,"../../plot_api/plot_template":196,"../../registry":254}],31:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plot_api/plot_template":194,"../../registry":252}],31:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15443,7 +15443,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":162,"../color":43}],32:[function(_dereq_,module,exports){ +},{"../../lib":160,"../color":43}],32:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15506,7 +15506,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":185,"fast-isnumeric":9}],33:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":183,"fast-isnumeric":9}],33:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -15612,7 +15612,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":162,"../../plots/array_container_defaults":202,"../../plots/cartesian/axes":206,"./attributes":28,"./common_defaults":31}],34:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plots/array_container_defaults":200,"../../plots/cartesian/axes":204,"./attributes":28,"./common_defaults":31}],34:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16026,14 +16026,14 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { x: borderfull + xShift - 1, y: borderfull + yShift }) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; annText.call(svgTextUtils.positionText, textx, texty) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } annTextClip.select('rect').call(Drawing.setRect, borderfull, borderfull, @@ -16199,7 +16199,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }); }, doneFn: function() { - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -16282,7 +16282,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }, doneFn: function() { setCursor(annTextGroupInner); - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -16306,13 +16306,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { modifyBase(ya._name + '.autorange', true); } - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); }); } else annText.call(textLayout); } -},{"../../lib":162,"../../lib/setcursor":181,"../../lib/svg_text_utils":183,"../../plot_api/plot_template":196,"../../plots/cartesian/axes":206,"../../plots/plots":246,"../../registry":254,"../color":43,"../dragelement":65,"../drawing":68,"../fx":85,"./draw_arrow_head":35,"d3":7}],35:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../lib/setcursor":179,"../../lib/svg_text_utils":181,"../../plot_api/plot_template":194,"../../plots/cartesian/axes":204,"../../plots/plots":244,"../../registry":252,"../color":43,"../dragelement":61,"../drawing":64,"../fx":82,"./draw_arrow_head":35,"d3":7}],35:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16500,7 +16500,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":217,"./attributes":28,"./calc_autorange":29,"./click":30,"./convert_coords":32,"./defaults":33,"./draw":34}],37:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":215,"./attributes":28,"./calc_autorange":29,"./click":30,"./convert_coords":32,"./defaults":33,"./draw":34}],37:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16588,7 +16588,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../annotations/attributes":28}],38:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":187,"../../plot_api/plot_template":194,"../annotations/attributes":28}],38:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16653,7 +16653,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":162,"../../plots/cartesian/axes":206}],39:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plots/cartesian/axes":204}],39:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16729,7 +16729,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":162,"../../plots/array_container_defaults":202,"../../plots/cartesian/axes":206,"../annotations/common_defaults":31,"./attributes":37}],40:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plots/array_container_defaults":200,"../../plots/cartesian/axes":204,"../annotations/common_defaults":31,"./attributes":37}],40:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16781,7 +16781,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":236,"../annotations/draw":34}],41:[function(_dereq_,module,exports){ +},{"../../plots/gl3d/project":234,"../annotations/draw":34}],41:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -16829,7 +16829,7 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":162,"../../registry":254,"./attributes":37,"./convert":38,"./defaults":39,"./draw":40}],42:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../registry":252,"./attributes":37,"./convert":38,"./defaults":39,"./draw":40}],42:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17183,23 +17183,43 @@ module.exports = overrideAll({ exponentformat: axesAttrs.exponentformat, showexponent: axesAttrs.showexponent, title: { - valType: 'string', - - + text: { + valType: 'string', + + + }, + font: fontAttrs({ + + }), + side: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } }, - titlefont: fontAttrs({ - - }), - titleside: { - valType: 'enumerated', - values: ['right', 'top', 'bottom'], - - dflt: 'top', - + + _deprecated: { + title: { + valType: 'string', + + + }, + titlefont: fontAttrs({ + + }), + titleside: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":155,"../../plot_api/edit_types":189,"../../plots/cartesian/layout_attributes":219,"../../plots/font_attributes":233}],45:[function(_dereq_,module,exports){ +},{"../../lib/extend":153,"../../plot_api/edit_types":187,"../../plots/cartesian/layout_attributes":217,"../../plots/font_attributes":231}],45:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17208,10 +17228,10 @@ module.exports = overrideAll({ * LICENSE file in the root directory of this source tree. */ - 'use strict'; var drawColorbar = _dereq_('./draw'); +var flipScale = _dereq_('../colorscale/helpers').flipScale; /** * connectColorbar: create a colorbar from a trace, using its module to @@ -17251,12 +17271,16 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) { var cb = cd[0].t.cb = drawColorbar(gd, cbId); - cb.fillgradient(container.colorscale) + var scl = container.reversescale ? + flipScale(container.colorscale) : + container.colorscale; + + cb.fillgradient(scl) .zrange([container[moduleOpts.min], container[moduleOpts.max]]) .options(container.colorbar)(); }; -},{"./draw":48}],46:[function(_dereq_,module,exports){ +},{"../colorscale/helpers":54,"./draw":48}],46:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17346,12 +17370,12 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); - coerce('title', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'titlefont', layout.font); - coerce('titleside'); + coerce('title.text', layout._dfltTitle.colorbar); + Lib.coerceFont(coerce, 'title.font', layout.font); + coerce('title.side'); }; -},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/cartesian/tick_label_defaults":226,"../../plots/cartesian/tick_mark_defaults":227,"../../plots/cartesian/tick_value_defaults":228,"./attributes":44}],48:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plot_api/plot_template":194,"../../plots/cartesian/tick_label_defaults":224,"../../plots/cartesian/tick_mark_defaults":225,"../../plots/cartesian/tick_value_defaults":226,"./attributes":44}],48:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -17538,9 +17562,9 @@ module.exports = function draw(gd, id) { showticksuffix: opts.showticksuffix, ticksuffix: opts.ticksuffix, title: opts.title, - titlefont: opts.titlefont, showline: true, anchor: 'free', + side: 'right', position: 1 }, cbAxisOut = { @@ -17551,6 +17575,7 @@ module.exports = function draw(gd, id) { letter: 'y', font: fullLayout.font, noHover: true, + noTickson: true, calendar: fullLayout.calendar // not really necessary (yet?) }; @@ -17571,11 +17596,11 @@ module.exports = function draw(gd, id) { // save for other callers to access this axis component.axis = cbAxisOut; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { - cbAxisOut.titleside = opts.titleside; + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { + cbAxisOut.title.side = opts.title.side; cbAxisOut.titlex = opts.x + xpadFrac; cbAxisOut.titley = yBottomFrac + - (opts.titleside === 'top' ? lenFrac - ypadFrac : ypadFrac); + (opts.title.side === 'top' ? lenFrac - ypadFrac : ypadFrac); } if(opts.line.color && opts.tickmode === 'auto') { @@ -17635,17 +17660,18 @@ module.exports = function draw(gd, id) { Math.round(gs.l) + ',-' + Math.round(gs.t) + ')'); - cbAxisOut._axislayer = container.select('.cbaxis'); + var axisLayer = container.select('.cbaxis'); + var titleHeight = 0; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // draw the title so we know how much room it needs // when we squish the axis. This one only applies to // top or bottom titles, not right side. var x = gs.l + (opts.x + xpadFrac) * gs.w, - fontSize = cbAxisOut.titlefont.size, + fontSize = cbAxisOut.title.font.size, y; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; } @@ -17659,7 +17685,7 @@ module.exports = function draw(gd, id) { } function drawAxis() { - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // squish the axis top to make room for the title var titleGroup = container.select('.cbtitle'), titleText = titleGroup.select('text'), @@ -17690,7 +17716,7 @@ module.exports = function draw(gd, id) { // TODO: configurable titleHeight += 5; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; } @@ -17711,8 +17737,7 @@ module.exports = function draw(gd, id) { .attr('transform', 'translate(0,' + Math.round(gs.h * (1 - cbAxisOut.domain[1])) + ')'); - cbAxisOut._axislayer.attr('transform', 'translate(0,' + - Math.round(-gs.t) + ')'); + axisLayer.attr('transform', 'translate(0,' + Math.round(-gs.t) + ')'); var fills = container.select('.cbfills') .selectAll('rect.cbfill') @@ -17779,12 +17804,7 @@ module.exports = function draw(gd, id) { }); // force full redraw of labels and ticks - cbAxisOut._axislayer.selectAll('g.' + cbAxisOut._id + 'tick,path') - .remove(); - - cbAxisOut._pos = xLeft + thickPx + - (opts.outlinewidth||0) / 2 - (opts.ticks === 'outside' ? 1 : 0); - cbAxisOut.side = 'right'; + axisLayer.selectAll('g.' + cbAxisOut._id + 'tick,path').remove(); // separate out axis and title drawing, // so we don't need such complicated logic in Titles.draw @@ -17792,11 +17812,33 @@ module.exports = function draw(gd, id) { // this title call only handles side=right return Lib.syncOrAsync([ function() { - return Axes.doTicksSingle(gd, cbAxisOut, true); + var shift = xLeft + thickPx + + (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0); + + var vals = Axes.calcTicks(cbAxisOut); + var transFn = Axes.makeTransFn(cbAxisOut); + var labelFns = Axes.makeLabelFns(cbAxisOut, shift); + var tickSign = Axes.getTickSigns(cbAxisOut)[2]; + + Axes.drawTicks(gd, cbAxisOut, { + vals: cbAxisOut.ticks === 'inside' ? Axes.clipEnds(cbAxisOut, vals) : vals, + layer: axisLayer, + path: Axes.makeTickPath(cbAxisOut, shift, tickSign), + transFn: transFn + }); + + return Axes.drawLabels(gd, cbAxisOut, { + vals: vals, + layer: axisLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); }, function() { - if(['top', 'bottom'].indexOf(opts.titleside) === -1) { - var fontSize = cbAxisOut.titlefont.size, + if(['top', 'bottom'].indexOf(opts.title.side) === -1) { + var fontSize = cbAxisOut.title.font.size, y = cbAxisOut._offset + cbAxisOut._length / 2, x = gs.l + (cbAxisOut.position || 0) * gs.w + ((cbAxisOut.side === 'right') ? 10 + fontSize * ((cbAxisOut.showticklabels ? 1 : 0.5)) : @@ -17808,7 +17850,7 @@ module.exports = function draw(gd, id) { drawTitle('h' + cbAxisOut._id + 'title', { avoid: { selection: d3.select(gd).selectAll('g.' + cbAxisOut._id + 'tick'), - side: opts.titleside, + side: opts.title.side, offsetLeft: gs.l, offsetTop: 0, maxShift: fullLayout.width @@ -17821,15 +17863,10 @@ module.exports = function draw(gd, id) { } function drawTitle(titleClass, titleOpts) { - var trace = getTrace(); - var propName = 'colorbar.title'; - var containerName = trace._module.colorbar.container; - if(containerName) propName = containerName + '.' + propName; - var dfltTitleOpts = { propContainer: cbAxisOut, - propName: propName, - traceIndex: trace.index, + propName: getPropName('title'), + traceIndex: getTrace().index, placeholder: fullLayout._dfltTitle.colorbar, containerGroup: container.select('.cbtitle') }; @@ -17853,7 +17890,7 @@ module.exports = function draw(gd, id) { // TODO: why are we redrawing multiple times now with this? // I guess autoMargin doesn't like being post-promise? var innerWidth = thickPx + opts.outlinewidth / 2 + - Drawing.bBox(cbAxisOut._axislayer.node()).width; + Drawing.bBox(axisLayer.node()).width; titleEl = titleCont.select('text'); if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) { var mathJaxNode = titleCont @@ -17861,11 +17898,11 @@ module.exports = function draw(gd, id) { .node(), titleWidth; if(mathJaxNode && - ['top', 'bottom'].indexOf(opts.titleside) !== -1) { + ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; } else { - // note: the formula below works for all titlesides, + // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift // transform gets removed by Drawing.bBox @@ -17894,7 +17931,7 @@ module.exports = function draw(gd, id) { container.selectAll('.cboutline').attr({ x: xLeft, y: yTopPx + opts.ypad + - (opts.titleside === 'top' ? titleHeight : 0), + (opts.title.side === 'top' ? titleHeight : 0), width: Math.max(thickPx, 2), height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2) }) @@ -17981,11 +18018,10 @@ module.exports = function draw(gd, id) { setCursor(container); if(xf !== undefined && yf !== undefined) { - Registry.call('restyle', - gd, - {'colorbar.x': xf, 'colorbar.y': yf}, - getTrace().index - ); + var update = {}; + update[getPropName('x')] = xf; + update[getPropName('y')] = yf; + Registry.call('_guiRestyle', gd, update, getTrace().index); } } }); @@ -18003,6 +18039,14 @@ module.exports = function draw(gd, id) { } } + function getPropName(suffix) { + var trace = getTrace(); + var propName = 'colorbar.'; + var containerName = trace._module.colorbar.container; + if(containerName) propName = containerName + '.' + propName; + return propName + suffix; + } + // setter/getters for every item defined in opts Object.keys(opts).forEach(function(name) { component[name] = function(v) { @@ -18036,7 +18080,7 @@ module.exports = function draw(gd, id) { return component; }; -},{"../../constants/alignment":141,"../../lib":162,"../../lib/extend":155,"../../lib/setcursor":181,"../../lib/svg_text_utils":183,"../../plots/cartesian/axes":206,"../../plots/cartesian/axis_defaults":208,"../../plots/cartesian/layout_attributes":219,"../../plots/cartesian/position_defaults":222,"../../plots/plots":246,"../../registry":254,"../color":43,"../dragelement":65,"../drawing":68,"../titles":134,"./attributes":44,"./constants":46,"d3":7,"tinycolor2":26}],49:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../lib":160,"../../lib/extend":153,"../../lib/setcursor":179,"../../lib/svg_text_utils":181,"../../plots/cartesian/axes":204,"../../plots/cartesian/axis_defaults":206,"../../plots/cartesian/layout_attributes":217,"../../plots/cartesian/position_defaults":220,"../../plots/plots":244,"../../registry":252,"../color":43,"../dragelement":61,"../drawing":64,"../titles":131,"./attributes":44,"./constants":46,"d3":7,"tinycolor2":26}],49:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18055,7 +18099,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":162}],50:[function(_dereq_,module,exports){ +},{"../../lib":160}],50:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18066,7 +18110,7 @@ module.exports = function hasColorbar(container) { 'use strict'; -var palettes = _dereq_('./scales.js'); +var palettes = _dereq_('./scales.js').scales; var paletteStr = Object.keys(palettes); function code(s) { @@ -18213,7 +18257,7 @@ module.exports = function colorScaleAttrs(context, opts) { valType: 'boolean', dflt: false, - editType: 'calc', + editType: 'plot', }; @@ -18230,7 +18274,7 @@ module.exports = function colorScaleAttrs(context, opts) { return attrs; }; -},{"./scales.js":62}],51:[function(_dereq_,module,exports){ +},{"./scales.js":58}],51:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18239,49 +18283,19 @@ module.exports = function colorScaleAttrs(context, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); -var scales = _dereq_('./scales'); -var flipScale = _dereq_('./flip_scale'); - - -module.exports = function calc(trace, vals, containerStr, cLetter) { - var container = trace; - var inputContainer = trace._input; - var fullInputContainer = trace._fullInput; - - // set by traces with groupby transforms - var updateStyle = trace.updateStyle; - - function doUpdate(attr, inputVal, fullVal) { - if(fullVal === undefined) fullVal = inputVal; - - if(updateStyle) { - updateStyle(trace._input, containerStr ? (containerStr + '.' + attr) : attr, inputVal); - } - else { - inputContainer[attr] = inputVal; - } - - container[attr] = fullVal; - if(fullInputContainer && (trace !== trace._fullInput)) { - if(updateStyle) { - updateStyle(trace._fullInput, containerStr ? (containerStr + '.' + attr) : attr, fullVal); - } - else { - fullInputContainer[attr] = fullVal; - } - } - } +module.exports = function calc(gd, trace, opts) { + var fullLayout = gd._fullLayout; + var vals = opts.vals; + var containerStr = opts.containerStr; + var cLetter = opts.cLetter; - if(containerStr) { - container = Lib.nestedProperty(container, containerStr).get(); - inputContainer = Lib.nestedProperty(inputContainer, containerStr).get(); - fullInputContainer = Lib.nestedProperty(fullInputContainer, containerStr).get() || {}; - } + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() : + trace; var autoAttr = cLetter + 'auto'; var minAttr = cLetter + 'min'; @@ -18304,37 +18318,19 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { max += 0.5; } - doUpdate(minAttr, min); - doUpdate(maxAttr, max); - - /* - * If auto was explicitly false but min or max was missing, - * we filled in the missing piece here but later the trace does - * not look auto. - * Otherwise make sure the trace still looks auto as far as later - * changes are concerned. - */ - doUpdate(autoAttr, (auto !== false || (min === undefined && max === undefined))); + container['_' + minAttr] = container[minAttr] = min; + container['_' + maxAttr] = container[maxAttr] = max; if(container.autocolorscale) { - if(min * max < 0) scl = scales.RdBu; - else if(min >= 0) scl = scales.Reds; - else scl = scales.Blues; - - // reversescale is handled at the containerOut level - doUpdate('colorscale', scl, container.reversescale ? flipScale(scl) : scl); + if(min * max < 0) scl = fullLayout.colorscale.diverging; + else if(min >= 0) scl = fullLayout.colorscale.sequential; + else scl = fullLayout.colorscale.sequentialminus; - // We pushed a colorscale back to input, which will change the default autocolorscale next time - // to avoid spurious redraws from Plotly.react, update resulting autocolorscale now - // This is a conscious decision so that changing the data later does not unexpectedly - // give you a new colorscale - if(!inputContainer.autocolorscale) { - doUpdate('autocolorscale', false); - } + container._colorscale = container.colorscale = scl; } }; -},{"../../lib":162,"./flip_scale":55,"./scales":62}],52:[function(_dereq_,module,exports){ +},{"../../lib":160}],52:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18345,12 +18341,68 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { 'use strict'; -var scales = _dereq_('./scales'); +var Lib = _dereq_('../../lib'); +var hasColorscale = _dereq_('./helpers').hasColorscale; +module.exports = function crossTraceDefaults(fullData) { + function replace(cont, k) { + var val = cont['_' + k]; + if(val !== undefined) { + cont[k] = val; + } + } + + function relinkColorAtts(trace, cAttrs) { + var cont = cAttrs.container ? + Lib.nestedProperty(trace, cAttrs.container).get() : + trace; + + if(cont) { + var isAuto = cont.zauto || cont.cauto; + var minAttr = cAttrs.min; + var maxAttr = cAttrs.max; + + if(isAuto || cont[minAttr] === undefined) { + replace(cont, minAttr); + } + if(isAuto || cont[maxAttr] === undefined) { + replace(cont, maxAttr); + } + if(cont.autocolorscale) { + replace(cont, 'colorscale'); + } + } + } + + for(var i = 0; i < fullData.length; i++) { + var trace = fullData[i]; + var _module = trace._module; + + if(_module.colorbar) { + relinkColorAtts(trace, _module.colorbar); + } + + // TODO could generalize _module.colorscale and use it here? + + if(hasColorscale(trace, 'marker.line')) { + relinkColorAtts(trace, { + container: 'marker.line', + min: 'cmin', + max: 'cmax' + }); + } -module.exports = scales.RdBu; + if(hasColorscale(trace, 'line')) { + relinkColorAtts(trace, { + container: 'line', + min: 'cmin', + max: 'cmax' + }); + } + } +}; -},{"./scales":62}],53:[function(_dereq_,module,exports){ +},{"../../lib":160,"./helpers":54}],53:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18359,33 +18411,32 @@ module.exports = scales.RdBu; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); - var hasColorbar = _dereq_('../colorbar/has_colorbar'); var colorbarDefaults = _dereq_('../colorbar/defaults'); -var isValidScale = _dereq_('./is_valid_scale'); -var flipScale = _dereq_('./flip_scale'); +var isValidScale = _dereq_('./scales').isValid; -module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { - var prefix = opts.prefix, - cLetter = opts.cLetter, - containerStr = prefix.slice(0, prefix.length - 1), - containerIn = prefix ? - Lib.nestedProperty(traceIn, containerStr).get() || {} : - traceIn, - containerOut = prefix ? - Lib.nestedProperty(traceOut, containerStr).get() || {} : - traceOut, - minIn = containerIn[cLetter + 'min'], - maxIn = containerIn[cLetter + 'max'], - sclIn = containerIn.colorscale; +function npMaybe(cont, prefix) { + var containerStr = prefix.slice(0, prefix.length - 1); + return prefix ? + Lib.nestedProperty(cont, containerStr).get() || {} : + cont; +} +module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { + var prefix = opts.prefix; + var cLetter = opts.cLetter; + var containerIn = npMaybe(traceIn, prefix); + var containerOut = npMaybe(traceOut, prefix); + var template = npMaybe(traceOut._template || {}, prefix) || {}; + + var minIn = containerIn[cLetter + 'min']; + var maxIn = containerIn[cLetter + 'max']; var validMinMax = isNumeric(minIn) && isNumeric(maxIn) && (minIn < maxIn); coerce(prefix + cLetter + 'auto', !validMinMax); coerce(prefix + cLetter + 'min'); @@ -18393,19 +18444,17 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, // handles both the trace case (autocolorscale is false by default) and // the marker and marker.line case (autocolorscale is true by default) + var sclIn = containerIn.colorscale; + var sclTemplate = template.colorscale; var autoColorscaleDflt; if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn); + if(sclTemplate !== undefined) autoColorscaleDflt = !isValidScale(sclTemplate); coerce(prefix + 'autocolorscale', autoColorscaleDflt); - var sclOut = coerce(prefix + 'colorscale'); - - // reversescale is handled at the containerOut level - var reverseScale = coerce(prefix + 'reversescale'); - if(reverseScale) containerOut.colorscale = flipScale(sclOut); - // ... until Scatter.colorbar can handle marker line colorbars - if(prefix === 'marker.line.') return; + coerce(prefix + 'colorscale'); + coerce(prefix + 'reversescale'); - if(!opts.noScale) { + if(!opts.noScale && prefix !== 'marker.line.') { // handles both the trace case where the dflt is listed in attributes and // the marker case where the dflt is determined by hasColorbar var showScaleDflt; @@ -18416,109 +18465,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, } }; -},{"../../lib":162,"../colorbar/defaults":47,"../colorbar/has_colorbar":49,"./flip_scale":55,"./is_valid_scale":59,"fast-isnumeric":9}],54:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -/** - * Extract colorscale into numeric domain and color range. - * - * @param {array} scl colorscale array of arrays - * @param {number} cmin minimum color value (used to clamp scale) - * @param {number} cmax maximum color value (used to clamp scale) - */ -module.exports = function extractScale(scl, cmin, cmax) { - var N = scl.length, - domain = new Array(N), - range = new Array(N); - - for(var i = 0; i < N; i++) { - var si = scl[i]; - - domain[i] = cmin + si[0] * (cmax - cmin); - range[i] = si[1]; - } - - return { - domain: domain, - range: range - }; -}; - -},{}],55:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function flipScale(scl) { - var N = scl.length, - sclNew = new Array(N), - si; - - for(var i = N - 1, j = 0; i >= 0; i--, j++) { - si = scl[i]; - sclNew[j] = [1 - si[0], si[1]]; - } - - return sclNew; -}; - -},{}],56:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var defaultScale = _dereq_('./default_scale'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function getScale(scl, dflt) { - if(!dflt) dflt = defaultScale; - if(!scl) return dflt; - - function parseScale() { - try { - scl = scales[scl] || JSON.parse(scl); - } - catch(e) { - scl = dflt; - } - } - - if(typeof scl === 'string') { - parseScale(); - // occasionally scl is double-JSON encoded... - if(typeof scl === 'string') parseScale(); - } - - if(!isValidScaleArray(scl)) return dflt; - return scl; -}; - -},{"./default_scale":52,"./is_valid_scale_array":60,"./scales":62}],57:[function(_dereq_,module,exports){ +},{"../../lib":160,"../colorbar/defaults":47,"../colorbar/has_colorbar":49,"./scales":58,"fast-isnumeric":9}],54:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18529,11 +18476,16 @@ module.exports = function getScale(scl, dflt) { 'use strict'; +var d3 = _dereq_('d3'); +var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); + var Lib = _dereq_('../../lib'); -var isValidScale = _dereq_('./is_valid_scale'); +var Color = _dereq_('../color'); + +var isValidScale = _dereq_('./scales').isValid; -module.exports = function hasColorscale(trace, containerStr) { +function hasColorscale(trace, containerStr) { var container = containerStr ? Lib.nestedProperty(trace, containerStr).get() || {} : trace; @@ -18558,117 +18510,61 @@ module.exports = function hasColorscale(trace, containerStr) { Lib.isPlainObject(container.colorbar) ) ); -}; - -},{"../../lib":162,"./is_valid_scale":59,"fast-isnumeric":9}],58:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -exports.scales = _dereq_('./scales'); - -exports.defaultScale = _dereq_('./default_scale'); - -exports.attributes = _dereq_('./attributes'); - -exports.handleDefaults = _dereq_('./defaults'); - -exports.calc = _dereq_('./calc'); - -exports.hasColorscale = _dereq_('./has_colorscale'); - -exports.isValidScale = _dereq_('./is_valid_scale'); - -exports.getScale = _dereq_('./get_scale'); - -exports.flipScale = _dereq_('./flip_scale'); - -exports.extractScale = _dereq_('./extract_scale'); - -exports.makeColorScaleFunc = _dereq_('./make_color_scale_func'); - -},{"./attributes":50,"./calc":51,"./default_scale":52,"./defaults":53,"./extract_scale":54,"./flip_scale":55,"./get_scale":56,"./has_colorscale":57,"./is_valid_scale":59,"./make_color_scale_func":61,"./scales":62}],59:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function isValidScale(scl) { - if(scales[scl] !== undefined) return true; - else return isValidScaleArray(scl); -}; +} -},{"./is_valid_scale_array":60,"./scales":62}],60:[function(_dereq_,module,exports){ /** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var tinycolor = _dereq_('tinycolor2'); - - -module.exports = function isValidScaleArray(scl) { - var highestVal = 0; + * Extract colorscale into numeric domain and color range. + * + * @param {object} cont colorscale container (e.g. trace, marker) + * - colorscale {array of arrays} + * - cmin/zmin {number} + * - cmax/zmax {number} + * - reversescale {boolean} + * @param {object} opts + * - cLetter {string} 'c' (for cmin/cmax) or 'z' (for zmin/zmax) + * + * @return {object} + * - domain {array} + * - range {array} + */ +function extractScale(cont, opts) { + var cLetter = opts.cLetter; - if(!Array.isArray(scl) || scl.length < 2) return false; + var scl = cont.reversescale ? + flipScale(cont.colorscale) : + cont.colorscale; - if(!scl[0] || !scl[scl.length - 1]) return false; + // minimum color value (used to clamp scale) + var cmin = cont[cLetter + 'min']; + // maximum color value (used to clamp scale) + var cmax = cont[cLetter + 'max']; - if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + var N = scl.length; + var domain = new Array(N); + var range = new Array(N); - for(var i = 0; i < scl.length; i++) { + for(var i = 0; i < N; i++) { var si = scl[i]; - - if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { - return false; - } - - highestVal = +si[0]; + domain[i] = cmin + si[0] * (cmax - cmin); + range[i] = si[1]; } - return true; -}; - -},{"tinycolor2":26}],61:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; + return { + domain: domain, + range: range + }; +} -var d3 = _dereq_('d3'); -var tinycolor = _dereq_('tinycolor2'); -var isNumeric = _dereq_('fast-isnumeric'); +function flipScale(scl) { + var N = scl.length; + var sclNew = new Array(N); -var Color = _dereq_('../color'); + for(var i = N - 1, j = 0; i >= 0; i--, j++) { + var si = scl[i]; + sclNew[j] = [1 - si[0], si[1]]; + } + return sclNew; +} /** * General colorscale function generator. @@ -18683,7 +18579,7 @@ var Color = _dereq_('../color'); * * @return {function} */ -module.exports = function makeColorScaleFunc(specs, opts) { +function makeColorScaleFunc(specs, opts) { opts = opts || {}; var domain = specs.domain, @@ -18735,7 +18631,7 @@ module.exports = function makeColorScaleFunc(specs, opts) { sclFunc.range = function() { return range; }; return sclFunc; -}; +} function colorArray2rbga(colorArray) { var colorObj = { @@ -18748,7 +18644,14 @@ function colorArray2rbga(colorArray) { return tinycolor(colorObj).toRgbString(); } -},{"../color":43,"d3":7,"fast-isnumeric":9,"tinycolor2":26}],62:[function(_dereq_,module,exports){ +module.exports = { + hasColorscale: hasColorscale, + extractScale: extractScale, + flipScale: flipScale, + makeColorScaleFunc: makeColorScaleFunc +}; + +},{"../../lib":160,"../color":43,"./scales":58,"d3":7,"fast-isnumeric":9,"tinycolor2":26}],55:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18759,8 +18662,116 @@ function colorArray2rbga(colorArray) { 'use strict'; +var scales = _dereq_('./scales'); +var helpers = _dereq_('./helpers'); module.exports = { + moduleType: 'component', + name: 'colorscale', + + attributes: _dereq_('./attributes'), + layoutAttributes: _dereq_('./layout_attributes'), + + supplyLayoutDefaults: _dereq_('./layout_defaults'), + handleDefaults: _dereq_('./defaults'), + crossTraceDefaults: _dereq_('./cross_trace_defaults'), + + calc: _dereq_('./calc'), + + // ./scales.js is required in lib/coerce.js ; + // it needs to be a seperate module to avoid circular a dependency + scales: scales.scales, + defaultScale: scales.defaultScale, + getScale: scales.get, + isValidScale: scales.isValid, + + hasColorscale: helpers.hasColorscale, + flipScale: helpers.flipScale, + extractScale: helpers.extractScale, + makeColorScaleFunc: helpers.makeColorScaleFunc +}; + +},{"./attributes":50,"./calc":51,"./cross_trace_defaults":52,"./defaults":53,"./helpers":54,"./layout_attributes":56,"./layout_defaults":57,"./scales":58}],56:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var scales = _dereq_('./scales').scales; + +var msg = 'Note that `autocolorscale` must be true for this attribute to work.'; + +module.exports = { + editType: 'calc', + sequential: { + valType: 'colorscale', + dflt: scales.Reds, + + editType: 'calc', + + }, + sequentialminus: { + valType: 'colorscale', + dflt: scales.Blues, + + editType: 'calc', + + }, + diverging: { + valType: 'colorscale', + dflt: scales.RdBu, + + editType: 'calc', + + } +}; + +},{"./scales":58}],57:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var Lib = _dereq_('../../lib'); +var colorscaleAttrs = _dereq_('./layout_attributes'); +var Template = _dereq_('../../plot_api/plot_template'); + +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var colorscaleIn = layoutIn.colorscale; + var colorscaleOut = Template.newContainer(layoutOut, 'colorscale'); + function coerce(attr, dflt) { + return Lib.coerce(colorscaleIn, colorscaleOut, colorscaleAttrs, attr, dflt); + } + + coerce('sequential'); + coerce('sequentialminus'); + coerce('diverging'); +}; + +},{"../../lib":160,"../../plot_api/plot_template":194,"./layout_attributes":56}],58:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var tinycolor = _dereq_('tinycolor2'); + +var scales = { 'Greys': [ [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] ], @@ -18891,7 +18902,67 @@ module.exports = { ] }; -},{}],63:[function(_dereq_,module,exports){ +var defaultScale = scales.RdBu; + +function getScale(scl, dflt) { + if(!dflt) dflt = defaultScale; + if(!scl) return dflt; + + function parseScale() { + try { + scl = scales[scl] || JSON.parse(scl); + } catch(e) { + scl = dflt; + } + } + + if(typeof scl === 'string') { + parseScale(); + // occasionally scl is double-JSON encoded... + if(typeof scl === 'string') parseScale(); + } + + if(!isValidScaleArray(scl)) return dflt; + return scl; +} + + +function isValidScaleArray(scl) { + var highestVal = 0; + + if(!Array.isArray(scl) || scl.length < 2) return false; + + if(!scl[0] || !scl[scl.length - 1]) return false; + + if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + + for(var i = 0; i < scl.length; i++) { + var si = scl[i]; + + if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { + return false; + } + + highestVal = +si[0]; + } + + return true; +} + +function isValidScale(scl) { + if(scales[scl] !== undefined) return true; + else return isValidScaleArray(scl); +} + +module.exports = { + scales: scales, + defaultScale: defaultScale, + + get: getScale, + isValid: isValidScale +}; + +},{"tinycolor2":26}],59:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18924,7 +18995,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],64:[function(_dereq_,module,exports){ +},{}],60:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -18962,7 +19033,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":162}],65:[function(_dereq_,module,exports){ +},{"../../lib":160}],61:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19089,8 +19160,6 @@ dragElement.init = function init(options) { var clampFn = options.clampFn || _clampFn; function onStart(e) { - e.preventDefault(); - // make dragging and dragged into properties of gd // so that others can look at and modify them gd._dragged = false; @@ -19132,11 +19201,15 @@ dragElement.init = function init(options) { document.documentElement.style.cursor = window.getComputedStyle(element).cursor; } - document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onDone); - document.addEventListener('touchmove', onMove); document.addEventListener('touchend', onDone); + if(options.dragmode !== false) { + e.preventDefault(); + document.addEventListener('mousemove', onMove); + document.addEventListener('touchmove', onMove); + } + return; } @@ -19160,13 +19233,15 @@ dragElement.init = function init(options) { } function onDone(e) { - document.removeEventListener('mousemove', onMove); + if(options.dragmode !== false) { + e.preventDefault(); + document.removeEventListener('mousemove', onMove); + document.removeEventListener('touchmove', onMove); + } + document.removeEventListener('mouseup', onDone); - document.removeEventListener('touchmove', onMove); document.removeEventListener('touchend', onDone); - e.preventDefault(); - if(hasHover) { Lib.removeElement(dragCover); } @@ -19259,7 +19334,7 @@ function pointerOffset(e) { ); } -},{"../../constants/interactions":142,"../../lib":162,"../../plots/cartesian/constants":212,"../../registry":254,"./align":63,"./cursor":64,"./unhover":66,"has-hover":11,"has-passive-events":12,"mouse-event-offset":16}],66:[function(_dereq_,module,exports){ +},{"../../constants/interactions":139,"../../lib":160,"../../plots/cartesian/constants":210,"../../registry":252,"./align":59,"./cursor":60,"./unhover":62,"has-hover":11,"has-passive-events":12,"mouse-event-offset":16}],62:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19317,7 +19392,7 @@ unhover.raw = function unhoverRaw(gd, evt) { } }; -},{"../../lib/events":154,"../../lib/get_graph_div":160,"../../lib/throttle":184,"../fx/constants":80}],67:[function(_dereq_,module,exports){ +},{"../../lib/events":152,"../../lib/get_graph_div":158,"../../lib/throttle":182,"../fx/constants":76}],63:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19342,7 +19417,7 @@ exports.dash = { }; -},{}],68:[function(_dereq_,module,exports){ +},{}],64:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -19543,7 +19618,11 @@ drawing.fillGroupStyle = function(s) { s.style('stroke-width', 0) .each(function(d) { var shape = d3.select(this); - shape.call(Color.fill, d[0].trace.fillcolor); + // N.B. 'd' won't be a calcdata item when + // fill !== 'none' on a segment-less and marker-less trace + if(d[0].trace) { + shape.call(Color.fill, d[0].trace.fillcolor); + } }); }; @@ -19984,7 +20063,7 @@ drawing.tryColorscale = function(marker, prefix) { if(scl && Lib.isArrayOrTypedArray(colorArray)) { return Colorscale.makeColorScaleFunc( - Colorscale.extractScale(scl, cont.cmin, cont.cmax) + Colorscale.extractScale(cont, {cLetter: 'c'}) ); } } @@ -20345,32 +20424,28 @@ function nodeHash(node) { node.getAttribute('style'); } -/* - * make a robust clipPath url from a local id - * note! We'd better not be exporting from a page - * with a or the svg will not be portable! +/** + * Set clipPath URL in a way that work for all situations. + * + * In details, graphs on pages with HTML tags need to prepend + * the clip path ids with the page's base url EXCEPT during toImage exports. + * + * @param {d3 selection} s : node to add clip-path attribute + * @param {string} localId : local clip-path (w/o base url) id + * @param {DOM element || object} gd + * - context._baseUrl {string} + * - context._exportedPlot {boolean} */ -drawing.setClipUrl = function(s, localId) { +drawing.setClipUrl = function(s, localId, gd) { if(!localId) { s.attr('clip-path', null); return; } - if(drawing.baseUrl === undefined) { - var base = d3.select('base'); - - // Stash base url once and for all! - // We may have to stash this elsewhere when - // we'll try to support for child windows - // more info -> https://github.com/plotly/plotly.js/issues/702 - if(base.size() && base.attr('href')) { - drawing.baseUrl = window.location.href.split('#')[0]; - } else { - drawing.baseUrl = ''; - } - } + var context = gd._context; + var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - s.attr('clip-path', 'url(' + drawing.baseUrl + '#' + localId + ')'); + s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')'); }; drawing.getTranslate = function(element) { @@ -20502,7 +20577,7 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../constants/alignment":141,"../../constants/interactions":142,"../../constants/xmlns_namespaces":144,"../../lib":162,"../../lib/svg_text_utils":183,"../../registry":254,"../../traces/scatter/make_bubble_size_func":283,"../../traces/scatter/subtypes":290,"../color":43,"../colorscale":58,"./symbol_defs":69,"d3":7,"fast-isnumeric":9,"tinycolor2":26}],69:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../constants/interactions":139,"../../constants/xmlns_namespaces":141,"../../lib":160,"../../lib/svg_text_utils":181,"../../registry":252,"../../traces/scatter/make_bubble_size_func":281,"../../traces/scatter/subtypes":288,"../color":43,"../colorscale":55,"./symbol_defs":65,"d3":7,"fast-isnumeric":9,"tinycolor2":26}],65:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -20990,7 +21065,7 @@ module.exports = { } }; -},{"d3":7}],70:[function(_dereq_,module,exports){ +},{"d3":7}],66:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21105,7 +21180,7 @@ module.exports = { } }; -},{}],71:[function(_dereq_,module,exports){ +},{}],67:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21187,7 +21262,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max); } -},{"../../plots/cartesian/axes":206,"../../registry":254,"./compute_error":72,"fast-isnumeric":9}],72:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":204,"../../registry":252,"./compute_error":68,"fast-isnumeric":9}],68:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21291,7 +21366,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],73:[function(_dereq_,module,exports){ +},{}],69:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21367,7 +21442,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":162,"../../plot_api/plot_template":196,"../../registry":254,"./attributes":70,"fast-isnumeric":9}],74:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plot_api/plot_template":194,"../../registry":252,"./attributes":66,"fast-isnumeric":9}],70:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21436,7 +21511,7 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":162,"../../plot_api/edit_types":189,"./attributes":70,"./calc":71,"./compute_error":72,"./defaults":73,"./plot":75,"./style":76}],75:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plot_api/edit_types":187,"./attributes":66,"./calc":67,"./compute_error":68,"./defaults":69,"./plot":71,"./style":72}],71:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21454,7 +21529,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); var subTypes = _dereq_('../../traces/scatter/subtypes'); -module.exports = function plot(traces, plotinfo, transitionOpts) { +module.exports = function plot(gd, traces, plotinfo, transitionOpts) { var isNew; var xa = plotinfo.xaxis; @@ -21505,7 +21580,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { .style('opacity', 1); } - Drawing.setClipUrl(errorbars, plotinfo.layerClipId); + Drawing.setClipUrl(errorbars, plotinfo.layerClipId, gd); errorbars.each(function(d) { var errorbar = d3.select(this); @@ -21610,7 +21685,7 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":290,"../drawing":68,"d3":7,"fast-isnumeric":9}],76:[function(_dereq_,module,exports){ +},{"../../traces/scatter/subtypes":288,"../drawing":64,"d3":7,"fast-isnumeric":9}],72:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21647,7 +21722,7 @@ module.exports = function style(traces) { }); }; -},{"../color":43,"d3":7}],77:[function(_dereq_,module,exports){ +},{"../color":43,"d3":7}],73:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21693,7 +21768,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":233}],78:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":231}],74:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21730,6 +21805,8 @@ module.exports = function calc(gd) { fillFn(trace.hoverinfo, cd, 'hi', makeCoerceHoverInfo(trace)); + if(trace.hovertemplate) fillFn(trace.hovertemplate, cd, 'ht'); + if(!trace.hoverlabel) continue; fillFn(trace.hoverlabel.bgcolor, cd, 'hbg'); @@ -21749,7 +21826,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":162,"../../registry":254}],79:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../registry":252}],75:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21787,7 +21864,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":254,"./hover":83}],80:[function(_dereq_,module,exports){ +},{"../../registry":252,"./hover":79}],76:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21819,7 +21896,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],81:[function(_dereq_,module,exports){ +},{}],77:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -21842,7 +21919,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, layout.hoverlabel); }; -},{"../../lib":162,"./attributes":77,"./hoverlabel_defaults":84}],82:[function(_dereq_,module,exports){ +},{"../../lib":160,"./attributes":73,"./hoverlabel_defaults":80}],78:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22085,7 +22162,7 @@ function getPointData(val, pointNumber) { } } -},{"../../lib":162}],83:[function(_dereq_,module,exports){ +},{"../../lib":160}],79:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -22214,13 +22291,17 @@ exports.loneHover = function loneHover(hoverItem, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; var container3 = d3.select(opts.container); @@ -22234,7 +22315,6 @@ exports.loneHover = function loneHover(hoverItem, opts) { container: container3, outerContainer: outerContainer3 }; - var hoverLabel = createHoverText([pointData], fullOpts, opts.gd); alignHoverText(hoverLabel, fullOpts.rotateLabels); @@ -22268,13 +22348,17 @@ exports.multiHovers = function multiHovers(hoverItems, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; }); @@ -22750,7 +22834,14 @@ function _hover(gd, evt, subplot, noHoverEvent) { // other people and send it to the event for(itemnum = 0; itemnum < hoverData.length; itemnum++) { var pt = hoverData[itemnum]; - newhoverdata.push(helpers.makeEventData(pt, pt.trace, pt.cd)); + var eventData = helpers.makeEventData(pt, pt.trace, pt.cd); + + var ht = false; + if(pt.cd[pt.index] && pt.cd[pt.index].ht) ht = pt.cd[pt.index].ht; + hoverData[itemnum].hovertemplate = ht || pt.trace.hovertemplate || false; + hoverData[itemnum].eventData = [eventData]; + + newhoverdata.push(eventData); } gd._hoverdata = newhoverdata; @@ -22808,6 +22899,8 @@ function _hover(gd, evt, subplot, noHoverEvent) { }); } +var EXTRA_STRING_REGEX = /([\s\S]*)<\/extra>/; + function createHoverText(hoverData, opts, gd) { var hovermode = opts.hovermode; var rotateLabels = opts.rotateLabels; @@ -22851,11 +22944,13 @@ function createHoverText(hoverData, opts, gd) { if(allHaveZ && hoverData[i].zLabel === undefined) allHaveZ = false; traceHoverinfo = hoverData[i].hoverinfo || hoverData[i].trace.hoverinfo; - var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); - if(parts.indexOf('all') === -1 && - parts.indexOf(hovermode) === -1) { - showCommonLabel = false; - break; + if(traceHoverinfo) { + var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); + if(parts.indexOf('all') === -1 && + parts.indexOf(hovermode) === -1) { + showCommonLabel = false; + break; + } } } @@ -23038,6 +23133,19 @@ function createHoverText(hoverData, opts, gd) { text = name; } + // hovertemplate + var hovertemplate = d.hovertemplate || false; + var hovertemplateLabels = d.hovertemplateLabels || d; + var eventData = d.eventData[0] || {}; + if(hovertemplate) { + text = Lib.hovertemplateString(hovertemplate, hovertemplateLabels, eventData); + + text = text.replace(EXTRA_STRING_REGEX, function(match, extra) { + name = extra; // Assign name for secondary text label + return ''; // Remove from main text label + }); + } + // main label var tx = g.select('text.nums') .call(Drawing.font, @@ -23436,7 +23544,7 @@ function cleanPoint(d, hovermode) { var infomode = d.hoverinfo || d.trace.hoverinfo; - if(infomode !== 'all') { + if(infomode && infomode !== 'all') { infomode = Array.isArray(infomode) ? infomode : infomode.split('+'); if(infomode.indexOf('x') === -1) d.xLabel = undefined; if(infomode.indexOf('y') === -1) d.yLabel = undefined; @@ -23622,8 +23730,11 @@ function hoverChanged(gd, evt, oldhoverdata) { for(var i = oldhoverdata.length - 1; i >= 0; i--) { var oldPt = oldhoverdata[i]; var newPt = gd._hoverdata[i]; + if(oldPt.curveNumber !== newPt.curveNumber || - String(oldPt.pointNumber) !== String(newPt.pointNumber)) { + String(oldPt.pointNumber) !== String(newPt.pointNumber) || + String(oldPt.pointNumbers) !== String(newPt.pointNumbers) + ) { return true; } } @@ -23639,7 +23750,7 @@ function spikesChanged(gd, oldspikepoints) { return false; } -},{"../../lib":162,"../../lib/events":154,"../../lib/override_cursor":173,"../../lib/svg_text_utils":183,"../../plots/cartesian/axes":206,"../../registry":254,"../color":43,"../dragelement":65,"../drawing":68,"./constants":80,"./helpers":82,"d3":7,"fast-isnumeric":9,"tinycolor2":26}],84:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../lib/events":152,"../../lib/override_cursor":171,"../../lib/svg_text_utils":181,"../../plots/cartesian/axes":204,"../../registry":252,"../color":43,"../dragelement":61,"../drawing":64,"./constants":76,"./helpers":78,"d3":7,"fast-isnumeric":9,"tinycolor2":26}],80:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23661,7 +23772,49 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts Lib.coerceFont(coerce, 'hoverlabel.font', opts.font); }; -},{"../../lib":162}],85:[function(_dereq_,module,exports){ +},{"../../lib":160}],81:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function(opts, extra) { + opts = opts || {}; + extra = extra || {}; + + var descPart = extra.description ? ' ' + extra.description : ''; + var keys = extra.keys || []; + if(keys.length > 0) { + var quotedKeys = []; + for(var i = 0; i < keys.length; i++) { + quotedKeys[i] = '`' + keys[i] + '`'; + } + descPart = descPart + 'Finally, the template string has access to '; + if(keys.length === 1) { + descPart = 'variable ' + quotedKeys[0]; + } else { + descPart = 'variables ' + quotedKeys.slice(0, -1).join(', ') + ' and ' + quotedKeys.slice(-1) + '.'; + } + } + + var hovertemplate = { + valType: 'string', + + dflt: '', + arrayOk: true, + editType: 'none', + + }; + + return hovertemplate; +}; + +},{}],82:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23741,7 +23894,7 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":162,"../dragelement":65,"./attributes":77,"./calc":78,"./click":79,"./constants":80,"./defaults":81,"./helpers":82,"./hover":83,"./layout_attributes":86,"./layout_defaults":87,"./layout_global_defaults":88,"d3":7}],86:[function(_dereq_,module,exports){ +},{"../../lib":160,"../dragelement":61,"./attributes":73,"./calc":74,"./click":75,"./constants":76,"./defaults":77,"./helpers":78,"./hover":79,"./layout_attributes":83,"./layout_defaults":84,"./layout_global_defaults":85,"d3":7}],83:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23774,7 +23927,7 @@ module.exports = { dragmode: { valType: 'enumerated', - values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'], + values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable', false], dflt: 'zoom', editType: 'modebar', @@ -23836,7 +23989,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":233,"./constants":80}],87:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":231,"./constants":76}],84:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23909,7 +24062,7 @@ function isHoriz(fullData) { return out; } -},{"../../lib":162,"./layout_attributes":86}],88:[function(_dereq_,module,exports){ +},{"../../lib":160,"./layout_attributes":83}],85:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -23932,7 +24085,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":162,"./hoverlabel_defaults":84,"./layout_attributes":86}],89:[function(_dereq_,module,exports){ +},{"../../lib":160,"./hoverlabel_defaults":80,"./layout_attributes":83}],86:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24317,7 +24470,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":162,"../../lib/regex":177,"../../plot_api/plot_template":196,"../../plots/cartesian/constants":212,"../../plots/domain":232}],90:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../lib/regex":175,"../../plot_api/plot_template":194,"../../plots/cartesian/constants":210,"../../plots/domain":230}],87:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24452,7 +24605,7 @@ module.exports = templatedArray('image', { editType: 'arraydraw' }); -},{"../../plot_api/plot_template":196,"../../plots/cartesian/constants":212}],91:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":194,"../../plots/cartesian/constants":210}],88:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24535,7 +24688,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":185,"fast-isnumeric":9}],92:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":183,"fast-isnumeric":9}],89:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24596,7 +24749,7 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":162,"../../plots/array_container_defaults":202,"../../plots/cartesian/axes":206,"./attributes":90}],93:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plots/array_container_defaults":200,"../../plots/cartesian/axes":204,"./attributes":87}],90:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24767,9 +24920,10 @@ module.exports = function draw(gd) { yId = ya ? ya._id : '', clipAxes = xId + yId; - thisImage.call(Drawing.setClipUrl, clipAxes ? - ('clip' + fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + thisImage, + clipAxes ? ('clip' + fullLayout._uid + clipAxes) : null, + gd ); } @@ -24817,7 +24971,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":144,"../../plots/cartesian/axes":206,"../drawing":68,"d3":7}],94:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":141,"../../plots/cartesian/axes":204,"../drawing":64,"d3":7}],91:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24841,56 +24995,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":217,"./attributes":90,"./convert_coords":91,"./defaults":92,"./draw":93}],95:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - - -/** - * Determine the position anchor property of x/y xanchor/yanchor components. - * - * - values < 1/3 align the low side at that fraction, - * - values [1/3, 2/3] align the center at that fraction, - * - values > 2/3 align the right at that fraction. - */ - -exports.isRightAnchor = function isRightAnchor(opts) { - return ( - opts.xanchor === 'right' || - (opts.xanchor === 'auto' && opts.x >= 2 / 3) - ); -}; - -exports.isCenterAnchor = function isCenterAnchor(opts) { - return ( - opts.xanchor === 'center' || - (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) - ); -}; - -exports.isBottomAnchor = function isBottomAnchor(opts) { - return ( - opts.yanchor === 'bottom' || - (opts.yanchor === 'auto' && opts.y <= 1 / 3) - ); -}; - -exports.isMiddleAnchor = function isMiddleAnchor(opts) { - return ( - opts.yanchor === 'middle' || - (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) - ); -}; - -},{}],96:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":215,"./attributes":87,"./convert_coords":88,"./defaults":89,"./draw":90}],92:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -24988,11 +25093,25 @@ module.exports = { editType: 'legend', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + valign: { + valType: 'enumerated', + values: ['top', 'middle', 'bottom'], + dflt: 'middle', + + editType: 'legend', + }, editType: 'legend' }; -},{"../../plots/font_attributes":233,"../color/attributes":42}],97:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":231,"../color/attributes":42}],93:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25011,7 +25130,7 @@ module.exports = { textOffsetX: 40 }; -},{}],98:[function(_dereq_,module,exports){ +},{}],94:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25080,7 +25199,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { basePlotLayoutAttributes, 'showlegend', legendReallyHasATrace && legendTraceCount > 1); - if(showLegend === false) return; + if(showLegend === false && !containerIn.uirevision) return; var containerOut = Template.newContainer(layoutOut, 'legend'); @@ -25088,6 +25207,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); } + coerce('uirevision', layoutOut.uirevision); + + if(showLegend === false) return; + coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); @@ -25096,7 +25219,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('orientation'); if(containerOut.orientation === 'h') { var xaxis = layoutIn.xaxis; - if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { + if(Registry.getComponentMethod('rangeslider', 'isVisible')(xaxis)) { defaultX = 0; defaultXAnchor = 'left'; defaultY = 1.1; @@ -25117,10 +25240,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('xanchor', defaultXAnchor); coerce('y', defaultY); coerce('yanchor', defaultYAnchor); + coerce('valign'); Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); }; -},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/layout_attributes":237,"../../registry":254,"./attributes":96,"./helpers":102}],99:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plot_api/plot_template":194,"../../plots/layout_attributes":235,"../../registry":252,"./attributes":92,"./helpers":98}],95:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25153,7 +25277,6 @@ var FROM_BR = alignmentConstants.FROM_BR; var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); -var anchorUtils = _dereq_('./anchor_utils'); var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; @@ -25277,17 +25400,17 @@ module.exports = function draw(gd) { lx = gs.l + gs.w * opts.x, ly = gs.t + gs.h * (1 - opts.y); - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= opts._width; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= opts._height; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -25347,7 +25470,7 @@ module.exports = function draw(gd) { y: opts.borderwidth }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; @@ -25385,7 +25508,7 @@ module.exports = function draw(gd) { y: opts.borderwidth + scrollBoxY }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -25462,7 +25585,7 @@ module.exports = function draw(gd) { }, doneFn: function() { if(xf !== undefined && yf !== undefined) { - Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf}); + Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf}); } }, clickFn: function(numClicks, e) { @@ -25569,7 +25692,7 @@ function drawTexts(g, gd, maxLength) { update.name = newName; } - return Registry.call('restyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, traceIndex); }); } else { textLayout(textEl); @@ -25659,6 +25782,7 @@ function computeTextDimensions(g, gd) { // to avoid getBoundingClientRect var textY = lineHeight * (0.3 + (1 - textLines) / 2); svgTextUtils.positionText(text, constants.textOffsetX, textY); + legendItem.lineHeight = lineHeight; } height = Math.max(height, 16) + 3; @@ -25822,18 +25946,18 @@ function expandMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -25853,10 +25977,10 @@ function expandHorizontalMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } @@ -25871,7 +25995,7 @@ function expandHorizontalMargin(gd) { }); } -},{"../../constants/alignment":141,"../../constants/interactions":142,"../../lib":162,"../../lib/events":154,"../../lib/svg_text_utils":183,"../../plots/plots":246,"../../registry":254,"../color":43,"../dragelement":65,"../drawing":68,"./anchor_utils":95,"./constants":97,"./get_legend_data":100,"./handle_click":101,"./helpers":102,"./style":104,"d3":7}],100:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../constants/interactions":139,"../../lib":160,"../../lib/events":152,"../../lib/svg_text_utils":181,"../../plots/plots":244,"../../registry":252,"../color":43,"../dragelement":61,"../drawing":64,"./constants":93,"./get_legend_data":96,"./handle_click":97,"./helpers":98,"./style":100,"d3":7}],96:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -25977,7 +26101,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":254,"./helpers":102}],101:[function(_dereq_,module,exports){ +},{"../../registry":252,"./helpers":98}],97:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26091,7 +26215,7 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices); + Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices); } else { var hasLegendgroup = legendgroup && legendgroup.length; var traceIndicesInGroup = []; @@ -26197,11 +26321,11 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', gd, attrUpdate, attrIndices); + Registry.call('_guiRestyle', gd, attrUpdate, attrIndices); } }; -},{"../../lib":162,"../../registry":254}],102:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../registry":252}],98:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26225,7 +26349,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],103:[function(_dereq_,module,exports){ +},{}],99:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26249,7 +26373,7 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":96,"./defaults":98,"./draw":99,"./style":104}],104:[function(_dereq_,module,exports){ +},{"./attributes":92,"./defaults":94,"./draw":95,"./style":100}],100:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26277,6 +26401,19 @@ module.exports = function style(s, gd) { var layers = Lib.ensureSingle(traceGroup, 'g', 'layers'); layers.style('opacity', d[0].trace.opacity); + // Marker vertical alignment + var valign = gd._fullLayout.legend.valign; + var lineHeight = d[0].lineHeight; + var height = d[0].height; + + if(valign === 'middle' || !lineHeight || !height) { + layers.attr('transform', null); // this here is a fun d3 trick to unset DOM attributes + } else { + var factor = {top: 1, bottom: -1}[valign]; + var markerOffsetY = factor * (0.5 * (lineHeight - height + 3)); + layers.attr('transform', 'translate(0,' + markerOffsetY + ')'); + } + var fill = layers .selectAll('g.legendfill') .data([d]); @@ -26596,7 +26733,7 @@ module.exports = function style(s, gd) { } }; -},{"../../lib":162,"../../registry":254,"../../traces/pie/style_one":264,"../../traces/scatter/subtypes":290,"../color":43,"../drawing":68,"d3":7}],105:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../registry":252,"../../traces/pie/style_one":262,"../../traces/scatter/subtypes":288,"../color":43,"../drawing":64,"d3":7}],101:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -26860,7 +26997,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -26916,7 +27053,7 @@ function handleDrag3d(gd, ev) { var val2d = (val === 'pan') ? val : 'zoom'; layoutUpdate.dragmode = val2d; - Registry.call('relayout', gd, layoutUpdate); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.resetCameraDefault3d = { @@ -26955,7 +27092,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -26969,54 +27106,48 @@ modeBarButtons.hoverClosest3d = { click: handleHover3d }; -function handleHover3d(gd, ev) { +function getNextHover3d(gd, ev) { var button = ev.currentTarget; - var val = button._previousVal || false; - var layout = gd.layout; + var val = button._previousVal; var fullLayout = gd._fullLayout; var sceneIds = fullLayout._subplots.gl3d; var axes = ['xaxis', 'yaxis', 'zaxis']; - var spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor']; // initialize 'current spike' object to be stored in the DOM var currentSpikes = {}; - var axisSpikes = {}; var layoutUpdate = {}; if(val) { - layoutUpdate = Lib.extendDeep(layout, val); + layoutUpdate = val; button._previousVal = null; } else { - layoutUpdate = { - 'allaxes.showspikes': false - }; - for(var i = 0; i < sceneIds.length; i++) { - var sceneId = sceneIds[i], - sceneLayout = fullLayout[sceneId], - sceneSpikes = currentSpikes[sceneId] = {}; + var sceneId = sceneIds[i]; + var sceneLayout = fullLayout[sceneId]; - sceneSpikes.hovermode = sceneLayout.hovermode; - layoutUpdate[sceneId + '.hovermode'] = false; + var hovermodeAStr = sceneId + '.hovermode'; + currentSpikes[hovermodeAStr] = sceneLayout.hovermode; + layoutUpdate[hovermodeAStr] = false; // copy all the current spike attrs for(var j = 0; j < 3; j++) { var axis = axes[j]; - axisSpikes = sceneSpikes[axis] = {}; - - for(var k = 0; k < spikeAttrs.length; k++) { - var spikeAttr = spikeAttrs[k]; - axisSpikes[spikeAttr] = sceneLayout[axis][spikeAttr]; - } + var spikeAStr = sceneId + '.' + axis + '.showspikes'; + layoutUpdate[spikeAStr] = false; + currentSpikes[spikeAStr] = sceneLayout[axis].showspikes; } } - button._previousVal = Lib.extendDeep({}, currentSpikes); + button._previousVal = currentSpikes; } + return layoutUpdate; +} - Registry.call('relayout', gd, layoutUpdate); +function handleHover3d(gd, ev) { + var layoutUpdate = getNextHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.zoomInGeo = { @@ -27072,7 +27203,7 @@ function handleGeo(gd, ev) { var scale = geoLayout.projection.scale; var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; - Registry.call('relayout', gd, id + '.projection.scale', newScale); + Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); } else if(attr === 'reset') { resetView(gd, 'geo'); } @@ -27100,18 +27231,20 @@ modeBarButtons.hoverClosestPie = { click: toggleHover }; -function toggleHover(gd) { +function getNextHover(gd) { var fullLayout = gd._fullLayout; - var onHoverVal; + if(fullLayout.hovermode) return false; + if(fullLayout._has('cartesian')) { - onHoverVal = fullLayout._isHoriz ? 'y' : 'x'; + return fullLayout._isHoriz ? 'y' : 'x'; } - else onHoverVal = 'closest'; - - var newHover = gd._fullLayout.hovermode ? false : onHoverVal; + return 'closest'; +} - Registry.call('relayout', gd, 'hovermode', newHover); +function toggleHover(gd) { + var newHover = getNextHover(gd); + Registry.call('_guiRelayout', gd, 'hovermode', newHover); } // buttons when more then one plot types are present @@ -27125,12 +27258,10 @@ modeBarButtons.toggleHover = { icon: Icons.tooltip_basic, gravity: 'ne', click: function(gd, ev) { - toggleHover(gd); + var layoutUpdate = getNextHover3d(gd, ev); + layoutUpdate.hovermode = getNextHover(gd); - // the 3d hovermode update must come - // last so that layout.hovermode update does not - // override scene?.hovermode?.layout. - handleHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } }; @@ -27166,7 +27297,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } }; @@ -27213,10 +27344,10 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', gd, aObj); + Registry.call('_guiRelayout', gd, aObj); } -},{"../../../build/ploticon":2,"../../lib":162,"../../plots/cartesian/axis_ids":209,"../../plots/plots":246,"../../registry":254}],106:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":160,"../../plots/cartesian/axis_ids":207,"../../plots/plots":244,"../../registry":252}],102:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27230,7 +27361,7 @@ function resetView(gd, subplotType) { exports.manage = _dereq_('./manage'); -},{"./manage":107}],107:[function(_dereq_,module,exports){ +},{"./manage":103}],103:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27262,7 +27393,7 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar) { + if(!context.displayModeBar && !context.watermark) { if(modeBar) { modeBar.destroy(); delete fullLayout._modeBar; @@ -27290,11 +27421,15 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); } + else if(!context.displayModeBar && context.watermark) { + buttonGroups = []; + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, - context.modeBarButtonsToAdd + context.modeBarButtonsToAdd, + context.showSendToCloud ); } @@ -27303,7 +27438,7 @@ module.exports = function manageModeBar(gd) { }; // logic behind which buttons are displayed by default -function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { +function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; @@ -27334,7 +27469,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { } // buttons common to all plot types - addGroup(['toImage', 'sendDataToCloud']); + var commonGroup = ['toImage']; + if(showSendToCloud) commonGroup.push('sendDataToCloud'); + addGroup(commonGroup); var zoomGroup = []; var hoverGroup = []; @@ -27485,7 +27622,7 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":209,"../../registry":254,"../../traces/scatter/subtypes":290,"./buttons":105,"./modebar":108}],108:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axis_ids":207,"../../registry":252,"../../traces/scatter/subtypes":288,"./buttons":101,"./modebar":104}],104:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27568,11 +27705,16 @@ proto.update = function(graphInfo, buttons) { this.updateButtons(buttons); - if(context.displaylogo) { + if(context.watermark || context.displaylogo) { + var logoGroup = this.getLogo(); + if(context.watermark) { + logoGroup.className = logoGroup.className + ' watermark'; + } + if(fullLayout.modebar.orientation === 'v') { - this.element.prepend(this.getLogo()); + this.element.prepend(logoGroup); } else { - this.element.appendChild(this.getLogo()); + this.element.appendChild(logoGroup); } this.hasLogo = true; @@ -27831,7 +27973,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../../build/ploticon":2,"../../lib":162,"d3":7,"fast-isnumeric":9}],109:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":160,"d3":7,"fast-isnumeric":9}],105:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27967,7 +28109,7 @@ module.exports = { editType: 'plot' }; -},{"../../plot_api/plot_template":196,"../../plots/font_attributes":233,"../color/attributes":42}],110:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":194,"../../plots/font_attributes":231,"../color/attributes":42}],106:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -27996,7 +28138,7 @@ module.exports = { darkAmount: 10 }; -},{}],111:[function(_dereq_,module,exports){ +},{}],107:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28089,7 +28231,7 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/array_container_defaults":202,"../color":43,"./attributes":109,"./constants":110}],112:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plot_api/plot_template":194,"../../plots/array_container_defaults":200,"../color":43,"./attributes":105,"./constants":106}],108:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28109,7 +28251,6 @@ var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var alignmentConstants = _dereq_('../../constants/alignment'); var LINE_SPACING = alignmentConstants.LINE_SPACING; @@ -28161,7 +28302,7 @@ module.exports = function draw(gd) { button.on('click', function() { if(gd._dragged) return; - Registry.call('relayout', gd, update); + Registry.call('_guiRelayout', gd, update); }); button.on('mouseover', function() { @@ -28310,21 +28451,21 @@ function reposition(gd, buttons, opts, axName, selector) { var ly = graphSize.t + graphSize.h * (1 - opts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= width; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(opts)) { + if(Lib.isCenterAnchor(opts)) { lx -= width / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(opts)) { + if(Lib.isMiddleAnchor(opts)) { ly -= height / 2; yanchor = 'middle'; } @@ -28346,7 +28487,7 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', 'translate(' + lx + ',' + ly + ')'); } -},{"../../constants/alignment":141,"../../lib":162,"../../lib/svg_text_utils":183,"../../plots/cartesian/axis_ids":209,"../../plots/plots":246,"../../registry":254,"../color":43,"../drawing":68,"../legend/anchor_utils":95,"./constants":110,"./get_update_object":113,"d3":7}],113:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../lib":160,"../../lib/svg_text_utils":181,"../../plots/cartesian/axis_ids":207,"../../plots/plots":244,"../../registry":252,"../color":43,"../drawing":64,"./constants":106,"./get_update_object":109,"d3":7}],109:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28403,7 +28544,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":7}],114:[function(_dereq_,module,exports){ +},{"d3":7}],110:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28430,7 +28571,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":109,"./defaults":111,"./draw":112}],115:[function(_dereq_,module,exports){ +},{"./attributes":105,"./defaults":107,"./draw":108}],111:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28504,7 +28645,7 @@ module.exports = { editType: 'calc' }; -},{"../color/attributes":42}],116:[function(_dereq_,module,exports){ +},{"../color/attributes":42}],112:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28538,7 +28679,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":205,"../../plots/cartesian/axis_ids":209,"./constants":117}],117:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/autorange":203,"../../plots/cartesian/axis_ids":207,"./constants":113}],113:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28594,7 +28735,7 @@ module.exports = { extraPad: 15 }; -},{}],118:[function(_dereq_,module,exports){ +},{}],114:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28680,7 +28821,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/cartesian/axis_ids":209,"./attributes":115,"./oppaxis_attributes":121}],119:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plot_api/plot_template":194,"../../plots/cartesian/axis_ids":207,"./attributes":111,"./oppaxis_attributes":118}],115:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -28702,7 +28843,7 @@ var Color = _dereq_('../color'); var Titles = _dereq_('../titles'); var Cartesian = _dereq_('../../plots/cartesian'); -var Axes = _dereq_('../../plots/cartesian/axes'); +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); var dragElement = _dereq_('../dragelement'); var setCursor = _dereq_('../../lib/setcursor'); @@ -28710,8 +28851,13 @@ var setCursor = _dereq_('../../lib/setcursor'); var constants = _dereq_('./constants'); module.exports = function(gd) { - var fullLayout = gd._fullLayout, - rangeSliderData = makeRangeSliderData(fullLayout); + var fullLayout = gd._fullLayout; + var rangeSliderData = fullLayout._rangeSliderData; + for(var i = 0; i < rangeSliderData.length; i++) { + var opts = rangeSliderData[i][constants.name]; + // fullLayout._uid may not exist when we call makeData + opts._clipId = opts._id + '-' + fullLayout._uid; + } /* * @@ -28738,10 +28884,6 @@ module.exports = function(gd) { .selectAll('g.' + constants.containerClassName) .data(rangeSliderData, keyFunction); - rangeSliders.enter().append('g') - .classed(constants.containerClassName, true) - .attr('pointer-events', 'all'); - // remove exiting sliders and their corresponding clip paths rangeSliders.exit().each(function(axisOpts) { var opts = axisOpts[constants.name]; @@ -28751,48 +28893,51 @@ module.exports = function(gd) { // return early if no range slider is visible if(rangeSliderData.length === 0) return; + rangeSliders.enter().append('g') + .classed(constants.containerClassName, true) + .attr('pointer-events', 'all'); + // for all present range sliders rangeSliders.each(function(axisOpts) { - var rangeSlider = d3.select(this), - opts = axisOpts[constants.name], - oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)], - oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)]; + var rangeSlider = d3.select(this); + var opts = axisOpts[constants.name]; + var oppAxisOpts = fullLayout[axisIDs.id2name(axisOpts.anchor)]; + var oppAxisRangeOpts = opts[axisIDs.id2name(axisOpts.anchor)]; // update range // Expand slider range to the axis range - // TODO: what if the ranges are reversed? if(opts.range) { - var outRange = opts.range; - var axRange = axisOpts.range; + var rng = Lib.simpleMap(opts.range, axisOpts.r2l); + var axRng = Lib.simpleMap(axisOpts.range, axisOpts.r2l); + var newRng; + + if(axRng[0] < axRng[1]) { + newRng = [ + Math.min(rng[0], axRng[0]), + Math.max(rng[1], axRng[1]) + ]; + } else { + newRng = [ + Math.max(rng[0], axRng[0]), + Math.min(rng[1], axRng[1]) + ]; + } - outRange[0] = axisOpts.l2r(Math.min(axisOpts.r2l(outRange[0]), axisOpts.r2l(axRange[0]))); - outRange[1] = axisOpts.l2r(Math.max(axisOpts.r2l(outRange[1]), axisOpts.r2l(axRange[1]))); - opts._input.range = outRange.slice(); + opts.range = opts._input.range = Lib.simpleMap(newRng, axisOpts.l2r); } axisOpts.cleanRange('rangeslider.range'); - // update range slider dimensions var margin = fullLayout.margin; var graphSize = fullLayout._size; var domain = axisOpts.domain; - var tickHeight = (axisOpts._boundingBox || {}).height || 0; - - var oppBottom = Infinity; - var subplotData = Axes.getSubplots(gd, axisOpts); - for(var i = 0; i < subplotData.length; i++) { - var oppAxis = Axes.getFromId(gd, subplotData[i].substr(subplotData[i].indexOf('y'))); - oppBottom = Math.min(oppBottom, oppAxis.domain[0]); - } + var tickHeight = opts._tickHeight; - opts._id = constants.name + axisOpts._id; - opts._clipId = opts._id + '-' + fullLayout._uid; + var oppBottom = opts._oppBottom; opts._width = graphSize.w * (domain[1] - domain[0]); - opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; - opts._offsetShift = Math.floor(opts.borderwidth / 2); var x = Math.round(margin.l + (graphSize.w * domain[0])); @@ -28855,41 +29000,14 @@ module.exports = function(gd) { placeholder: fullLayout._dfltTitle.x, attributes: { x: axisOpts._offset + axisOpts._length / 2, - y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size, + y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.title.font.size, 'text-anchor': 'middle' } }); } - - // update margins - Plots.autoMargin(gd, opts._id, { - x: domain[0], - y: oppBottom, - l: 0, - r: 0, - t: 0, - b: opts._height + margin.b + tickHeight, - pad: constants.extraPad + opts._offsetShift * 2 - }); }); }; -function makeRangeSliderData(fullLayout) { - var axes = Axes.list({ _fullLayout: fullLayout }, 'x', true), - name = constants.name, - out = []; - - if(fullLayout._has('gl2d')) return out; - - for(var i = 0; i < axes.length; i++) { - var ax = axes[i]; - - if(ax[name] && ax[name].visible) out.push(ax); - } - - return out; -} - function setupDragElement(rangeSlider, gd, axisOpts, opts) { var slideBox = rangeSlider.select('rect.' + constants.slideBoxClassName).node(), grabAreaMin = rangeSlider.select('rect.' + constants.grabAreaMinClassName).node(), @@ -28969,7 +29087,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) { dataMax = clamp(opts.p2d(opts._pixelMax)); window.requestAnimationFrame(function() { - Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); + Registry.call('_guiRelayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); }); } @@ -29076,15 +29194,14 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) { } function drawRangePlot(rangeSlider, gd, axisOpts, opts) { - var subplotData = Axes.getSubplots(gd, axisOpts), - calcData = gd.calcdata; + var calcData = gd.calcdata; var rangePlots = rangeSlider.selectAll('g.' + constants.rangePlotClassName) - .data(subplotData, Lib.identity); + .data(axisOpts._subplotsWith, Lib.identity); rangePlots.enter().append('g') .attr('class', function(id) { return constants.rangePlotClassName + ' ' + id; }) - .call(Drawing.setClipUrl, opts._clipId); + .call(Drawing.setClipUrl, opts._clipId, gd); rangePlots.order(); @@ -29096,7 +29213,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var plotgroup = d3.select(this), isMainPlot = (i === 0); - var oppAxisOpts = Axes.getFromId(gd, id, 'y'), + var oppAxisOpts = axisIDs.getFromId(gd, id, 'y'), oppAxisName = oppAxisOpts._name, oppAxisRangeOpts = opts[oppAxisName]; @@ -29128,6 +29245,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var xa = mockFigure._fullLayout.xaxis; var ya = mockFigure._fullLayout[oppAxisName]; + xa.clearCalc(); + xa.setScale(); + ya.clearCalc(); + ya.setScale(); + var plotinfo = { id: id, plotgroup: plotgroup, @@ -29280,7 +29402,77 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":162,"../../lib/setcursor":181,"../../plots/cartesian":218,"../../plots/cartesian/axes":206,"../../plots/plots":246,"../../registry":254,"../color":43,"../dragelement":65,"../drawing":68,"../titles":134,"./constants":117,"d3":7}],120:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../lib/setcursor":179,"../../plots/cartesian":216,"../../plots/cartesian/axis_ids":207,"../../plots/plots":244,"../../registry":252,"../color":43,"../dragelement":61,"../drawing":64,"../titles":131,"./constants":113,"d3":7}],116:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); +var constants = _dereq_('./constants'); +var name = constants.name; + +function isVisible(ax) { + var rangeSlider = ax && ax[name]; + return rangeSlider && rangeSlider.visible; +} +exports.isVisible = isVisible; + +exports.makeData = function(fullLayout) { + var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true); + var margin = fullLayout.margin; + var rangeSliderData = []; + + if(!fullLayout._has('gl2d')) { + for(var i = 0; i < axes.length; i++) { + var ax = axes[i]; + + if(isVisible(ax)) { + rangeSliderData.push(ax); + + var opts = ax[name]; + opts._id = name + ax._id; + opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; + opts._offsetShift = Math.floor(opts.borderwidth / 2); + } + } + } + + fullLayout._rangeSliderData = rangeSliderData; +}; + +exports.autoMarginOpts = function(gd, ax) { + var opts = ax[name]; + + var oppBottom = Infinity; + var counterAxes = ax._counterAxes; + for(var j = 0; j < counterAxes.length; j++) { + var counterId = counterAxes[j]; + var oppAxis = axisIDs.getFromId(gd, counterId); + oppBottom = Math.min(oppBottom, oppAxis.domain[0]); + } + opts._oppBottom = oppBottom; + + var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0; + opts._tickHeight = tickHeight; + + return { + x: 0, + y: oppBottom, + l: 0, + r: 0, + t: 0, + b: opts._height + gd._fullLayout.margin.b + tickHeight, + pad: constants.extraPad + opts._offsetShift * 2 + }; +}; + +},{"../../plots/cartesian/axis_ids":207,"./constants":113}],117:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29294,6 +29486,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { var Lib = _dereq_('../../lib'); var attrs = _dereq_('./attributes'); var oppAxisAttrs = _dereq_('./oppaxis_attributes'); +var helpers = _dereq_('./helpers'); module.exports = { moduleType: 'component', @@ -29312,10 +29505,13 @@ module.exports = { layoutAttributes: _dereq_('./attributes'), handleDefaults: _dereq_('./defaults'), calcAutorange: _dereq_('./calc_autorange'), - draw: _dereq_('./draw') + draw: _dereq_('./draw'), + isVisible: helpers.isVisible, + makeData: helpers.makeData, + autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":162,"./attributes":115,"./calc_autorange":116,"./defaults":118,"./draw":119,"./oppaxis_attributes":121}],121:[function(_dereq_,module,exports){ +},{"../../lib":160,"./attributes":111,"./calc_autorange":112,"./defaults":114,"./draw":115,"./helpers":116,"./oppaxis_attributes":118}],118:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29353,7 +29549,7 @@ module.exports = { editType: 'calc' }; -},{}],122:[function(_dereq_,module,exports){ +},{}],119:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29489,7 +29685,7 @@ module.exports = templatedArray('shape', { editType: 'arraydraw' }); -},{"../../lib/extend":155,"../../plot_api/plot_template":196,"../../traces/scatter/attributes":266,"../annotations/attributes":28,"../drawing/attributes":67}],123:[function(_dereq_,module,exports){ +},{"../../lib/extend":153,"../../plot_api/plot_template":194,"../../traces/scatter/attributes":264,"../annotations/attributes":28,"../drawing/attributes":63}],120:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29498,7 +29694,6 @@ module.exports = templatedArray('shape', { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); @@ -29576,7 +29771,7 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { } function shapeBounds(ax, v0, v1, path, paramsToUse) { - var convertVal = (ax.type === 'category') ? ax.r2c : ax.d2c; + var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; if(!path) return; @@ -29607,7 +29802,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":162,"../../plots/cartesian/axes":206,"./constants":124,"./helpers":127}],124:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plots/cartesian/axes":204,"./constants":121,"./helpers":124}],121:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29671,7 +29866,7 @@ module.exports = { } }; -},{}],125:[function(_dereq_,module,exports){ +},{}],122:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29796,7 +29991,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":162,"../../plots/array_container_defaults":202,"../../plots/cartesian/axes":206,"./attributes":122,"./helpers":127}],126:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plots/array_container_defaults":200,"../../plots/cartesian/axes":204,"./attributes":119,"./helpers":124}],123:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -29919,9 +30114,10 @@ function setClipPath(shapePath, gd, shapeOptions) { // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 var clipAxes = (shapeOptions.xref + shapeOptions.yref).replace(/paper/g, ''); - shapePath.call(Drawing.setClipUrl, clipAxes ? - ('clip' + gd._fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } @@ -30105,7 +30301,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { // Don't rely on clipPath being activated during re-layout setClipPath(shapePath, gd, shapeOptions); - Registry.call('relayout', gd, editHelpers.getUpdateObj()); + Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj()); } function abortDrag() { @@ -30292,9 +30488,10 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(xref !== 'paper' && !xa.autorange) clipAxes += xref; if(yref !== 'paper' && !ya.autorange) clipAxes += yref; - shapePath.call(Drawing.setClipUrl, clipAxes ? - 'clip' + gd._fullLayout._uid + clipAxes : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } } @@ -30426,7 +30623,7 @@ function movePath(pathIn, moveX, moveY) { }); } -},{"../../lib":162,"../../lib/setcursor":181,"../../plot_api/plot_template":196,"../../plots/cartesian/axes":206,"../../registry":254,"../color":43,"../dragelement":65,"../drawing":68,"./constants":124,"./helpers":127}],127:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../lib/setcursor":179,"../../plot_api/plot_template":194,"../../plots/cartesian/axes":204,"../../registry":252,"../color":43,"../dragelement":61,"../drawing":64,"./constants":121,"./helpers":124}],124:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30551,7 +30748,7 @@ exports.roundPositionForSharpStrokeRendering = function(pos, strokeWidth) { return strokeWidthIsOdd ? posValAsInt + 0.5 : posValAsInt; }; -},{"../../lib":162,"./constants":124}],128:[function(_dereq_,module,exports){ +},{"../../lib":160,"./constants":121}],125:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30578,7 +30775,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":217,"./attributes":122,"./calc_autorange":123,"./defaults":125,"./draw":126}],129:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":215,"./attributes":119,"./calc_autorange":120,"./defaults":122,"./draw":123}],126:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30680,7 +30877,7 @@ module.exports = overrideAll(templatedArray('slider', { }, - pad: extendDeepAll({}, padAttrs, { + pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { }, {t: {dflt: 20}}), xanchor: { @@ -30821,7 +31018,7 @@ module.exports = overrideAll(templatedArray('slider', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":155,"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../../plots/animation_attributes":201,"../../plots/font_attributes":233,"../../plots/pad_attributes":245,"./constants":130}],130:[function(_dereq_,module,exports){ +},{"../../lib/extend":153,"../../plot_api/edit_types":187,"../../plot_api/plot_template":194,"../../plots/animation_attributes":199,"../../plots/font_attributes":231,"../../plots/pad_attributes":243,"./constants":127}],127:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -30915,7 +31112,7 @@ module.exports = { currentValueInset: 0, }; -},{}],131:[function(_dereq_,module,exports){ +},{}],128:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31032,7 +31229,7 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":162,"../../plots/array_container_defaults":202,"./attributes":129,"./constants":130}],132:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plots/array_container_defaults":200,"./attributes":126,"./constants":127}],129:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31050,7 +31247,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var constants = _dereq_('./constants'); @@ -31242,21 +31438,21 @@ function findDimensions(gd, sliderOpts) { dims.height = dims.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + dims.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(sliderOpts)) { + if(Lib.isRightAnchor(sliderOpts)) { dims.lx -= dims.outerLength; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(sliderOpts)) { + if(Lib.isCenterAnchor(sliderOpts)) { dims.lx -= dims.outerLength / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(sliderOpts)) { + if(Lib.isBottomAnchor(sliderOpts)) { dims.ly -= dims.height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(sliderOpts)) { + if(Lib.isMiddleAnchor(sliderOpts)) { dims.ly -= dims.height / 2; yanchor = 'middle'; } @@ -31663,7 +31859,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":141,"../../lib":162,"../../lib/svg_text_utils":183,"../../plot_api/plot_template":196,"../../plots/plots":246,"../color":43,"../drawing":68,"../legend/anchor_utils":95,"./constants":130,"d3":7}],133:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../lib":160,"../../lib/svg_text_utils":181,"../../plot_api/plot_template":194,"../../plots/plots":244,"../color":43,"../drawing":64,"./constants":127,"d3":7}],130:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31686,7 +31882,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":129,"./constants":130,"./defaults":131,"./draw":132}],134:[function(_dereq_,module,exports){ +},{"./attributes":126,"./constants":127,"./defaults":128,"./draw":129}],131:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -31756,19 +31952,21 @@ function draw(gd, titleClass, options) { var group = options.containerGroup; var fullLayout = gd._fullLayout; - var titlefont = cont.titlefont || {}; - var font = titlefont.family; - var fontSize = titlefont.size; - var fontColor = titlefont.color; var opacity = 1; var isplaceholder = false; - var txt = (cont.title || '').trim(); + var title = cont.title; + var txt = (title && title.text ? title.text : '').trim(); + + var font = title && title.font ? title.font : {}; + var fontFamily = font.family; + var fontSize = font.size; + var fontColor = font.color; // only make this title editable if we positively identify its property // as one that has editing enabled. var editAttr; - if(prop === 'title') editAttr = 'titleText'; + if(prop === 'title.text') editAttr = 'titleText'; else if(prop.indexOf('axis') !== -1) editAttr = 'axisTitleText'; else if(prop.indexOf('colorbar' !== -1)) editAttr = 'colorbarTitleText'; var editable = gd._context.edits[editAttr]; @@ -31826,7 +32024,7 @@ function draw(gd, titleClass, options) { titleEl.attr('transform', transformVal); titleEl.style({ - 'font-family': font, + 'font-family': fontFamily, 'font-size': d3.round(fontSize, 2) + 'px', fill: Color.rgb(fontColor), opacity: opacity * Color.opacity(fontColor), @@ -31926,9 +32124,9 @@ function draw(gd, titleClass, options) { el.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { if(traceIndex !== undefined) { - Registry.call('restyle', gd, prop, text, traceIndex); + Registry.call('_guiRestyle', gd, prop, text, traceIndex); } else { - Registry.call('relayout', gd, prop, text); + Registry.call('_guiRelayout', gd, prop, text); } }) .on('cancel', function() { @@ -31945,7 +32143,7 @@ function draw(gd, titleClass, options) { return group; } -},{"../../constants/interactions":142,"../../lib":162,"../../lib/svg_text_utils":183,"../../plots/plots":246,"../../registry":254,"../color":43,"../drawing":68,"d3":7,"fast-isnumeric":9}],135:[function(_dereq_,module,exports){ +},{"../../constants/interactions":139,"../../lib":160,"../../lib/svg_text_utils":181,"../../plots/plots":244,"../../registry":252,"../color":43,"../drawing":64,"d3":7,"fast-isnumeric":9}],132:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32074,7 +32272,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { }, - pad: extendFlat({}, padAttrs, { + pad: extendFlat(padAttrs({editType: 'arraydraw'}), { }), @@ -32103,7 +32301,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":155,"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../../plots/font_attributes":233,"../../plots/pad_attributes":245,"../color/attributes":42}],136:[function(_dereq_,module,exports){ +},{"../../lib/extend":153,"../../plot_api/edit_types":187,"../../plot_api/plot_template":194,"../../plots/font_attributes":231,"../../plots/pad_attributes":243,"../color/attributes":42}],133:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32184,7 +32382,7 @@ module.exports = { } }; -},{}],137:[function(_dereq_,module,exports){ +},{}],134:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32267,7 +32465,7 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":162,"../../plots/array_container_defaults":202,"./attributes":135,"./constants":136}],138:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../plots/array_container_defaults":200,"./attributes":132,"./constants":133}],135:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -32286,7 +32484,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var LINE_SPACING = _dereq_('../../constants/alignment').LINE_SPACING; @@ -32836,21 +33033,21 @@ function findDimensions(gd, menuOpts) { dims.ly = graphSize.t + graphSize.h * (1 - menuOpts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(menuOpts)) { + if(Lib.isRightAnchor(menuOpts)) { dims.lx -= paddedWidth; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(menuOpts)) { + if(Lib.isCenterAnchor(menuOpts)) { dims.lx -= paddedWidth / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(menuOpts)) { + if(Lib.isBottomAnchor(menuOpts)) { dims.ly -= paddedHeight; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(menuOpts)) { + if(Lib.isMiddleAnchor(menuOpts)) { dims.ly -= paddedHeight / 2; yanchor = 'middle'; } @@ -32917,9 +33114,9 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":141,"../../lib":162,"../../lib/svg_text_utils":183,"../../plot_api/plot_template":196,"../../plots/plots":246,"../color":43,"../drawing":68,"../legend/anchor_utils":95,"./constants":136,"./scrollbox":140,"d3":7}],139:[function(_dereq_,module,exports){ -arguments[4][133][0].apply(exports,arguments) -},{"./attributes":135,"./constants":136,"./defaults":137,"./draw":138,"dup":133}],140:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../lib":160,"../../lib/svg_text_utils":181,"../../plot_api/plot_template":194,"../../plots/plots":244,"../color":43,"../drawing":64,"./constants":133,"./scrollbox":137,"d3":7}],136:[function(_dereq_,module,exports){ +arguments[4][130][0].apply(exports,arguments) +},{"./attributes":132,"./constants":133,"./defaults":134,"./draw":135,"dup":130}],137:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33176,7 +33373,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { height: Math.ceil(clipB) - Math.floor(clipT) }); - this.container.call(Drawing.setClipUrl, clipId); + this.container.call(Drawing.setClipUrl, clipId, this.gd); this.bg.attr({ x: l, @@ -33390,7 +33587,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":162,"../color":43,"../drawing":68,"d3":7}],141:[function(_dereq_,module,exports){ +},{"../../lib":160,"../color":43,"../drawing":64,"d3":7}],138:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33434,12 +33631,17 @@ module.exports = { // multiple of fontSize to get the vertical offset between lines LINE_SPACING: 1.3, - // multiple of fontSize to shift from the baseline to the midline + // multiple of fontSize to shift from the baseline + // to the cap (captical letter) line // (to use when we don't calculate this shift from Drawing.bBox) - // To be precise this should be half the cap height (capital letter) - // of the font, and according to wikipedia: + // This is an approximation since in reality cap height can differ + // from font to font. However, according to Wikipedia // an "average" font might have a cap height of 70% of the em // https://en.wikipedia.org/wiki/Em_(typography)#History + CAP_SHIFT: 0.70, + + // half the cap height (distance between baseline and cap line) + // of an "average" font (for more info see above). MID_SHIFT: 0.35, OPPOSITE_SIDE: { @@ -33450,7 +33652,7 @@ module.exports = { } }; -},{}],142:[function(_dereq_,module,exports){ +},{}],139:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33477,7 +33679,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],143:[function(_dereq_,module,exports){ +},{}],140:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33542,7 +33744,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],144:[function(_dereq_,module,exports){ +},{}],141:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33566,7 +33768,7 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],145:[function(_dereq_,module,exports){ +},{}],142:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33578,7 +33780,7 @@ exports.svgAttrs = { 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.42.5'; +exports.version = '1.43.0'; // inject promise polyfill _dereq_('es6-promise').polyfill(); @@ -33587,7 +33789,7 @@ _dereq_('es6-promise').polyfill(); _dereq_('../build/plotcss'); // inject default MathJax config -_dereq_('./fonts/mathjax_config'); +_dereq_('./fonts/mathjax_config')(); // include registry module and expose register method var Registry = _dereq_('./registry'); @@ -33598,7 +33800,8 @@ var plotApi = _dereq_('./plot_api'); var methodNames = Object.keys(plotApi); for(var i = 0; i < methodNames.length; i++) { var name = methodNames[i]; - exports[name] = plotApi[name]; + // _ -> private API methods, but still registered for internal use + if(name.charAt(0) !== '_') exports[name] = plotApi[name]; register({ moduleType: 'apiMethod', name: name, @@ -33622,7 +33825,8 @@ register([ _dereq_('./components/rangeslider'), _dereq_('./components/rangeselector'), _dereq_('./components/grid'), - _dereq_('./components/errorbars') + _dereq_('./components/errorbars'), + _dereq_('./components/colorscale') ]); // locales en and en-US are required for default behavior @@ -33644,7 +33848,7 @@ exports.Queue = _dereq_('./lib/queue'); // export d3 used in the bundle exports.d3 = _dereq_('d3'); -},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":36,"./components/annotations3d":41,"./components/errorbars":74,"./components/fx":85,"./components/grid":89,"./components/images":94,"./components/legend":103,"./components/rangeselector":114,"./components/rangeslider":120,"./components/shapes":128,"./components/sliders":133,"./components/updatemenus":139,"./fonts/mathjax_config":146,"./lib/queue":176,"./locale-en":187,"./locale-en-us":186,"./plot_api":191,"./plot_api/plot_schema":195,"./plots/plots":246,"./registry":254,"./snapshot":259,"./traces/scatter":278,"d3":7,"es6-promise":8}],146:[function(_dereq_,module,exports){ +},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":36,"./components/annotations3d":41,"./components/colorscale":55,"./components/errorbars":70,"./components/fx":82,"./components/grid":86,"./components/images":91,"./components/legend":99,"./components/rangeselector":110,"./components/rangeslider":117,"./components/shapes":125,"./components/sliders":130,"./components/updatemenus":136,"./fonts/mathjax_config":143,"./lib/queue":174,"./locale-en":185,"./locale-en-us":184,"./plot_api":189,"./plot_api/plot_schema":193,"./plots/plots":244,"./registry":252,"./snapshot":257,"./traces/scatter":276,"d3":7,"es6-promise":8}],143:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33657,31 +33861,89 @@ exports.d3 = _dereq_('d3'); /* global MathJax:false */ +module.exports = function() { + if(typeof MathJax !== 'undefined') { + var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; + + if(globalConfig) { + MathJax.Hub.Config({ + messageStyle: 'none', + skipStartupTypeset: true, + displayAlign: 'left', + tex2jax: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + } + }); + MathJax.Hub.Configured(); + } + } +}; + +},{}],144:[function(_dereq_,module,exports){ /** - * Check and configure MathJax +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + + +/** + * Determine the position anchor property of x/y xanchor/yanchor components. + * + * - values < 1/3 align the low side at that fraction, + * - values [1/3, 2/3] align the center at that fraction, + * - values > 2/3 align the right at that fraction. */ -if(typeof MathJax !== 'undefined') { - exports.MathJax = true; - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } +exports.isLeftAnchor = function isLeftAnchor(opts) { + return ( + opts.xanchor === 'left' || + (opts.xanchor === 'auto' && opts.x <= 1 / 3) + ); +}; -} else { - exports.MathJax = false; -} +exports.isCenterAnchor = function isCenterAnchor(opts) { + return ( + opts.xanchor === 'center' || + (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) + ); +}; -},{}],147:[function(_dereq_,module,exports){ +exports.isRightAnchor = function isRightAnchor(opts) { + return ( + opts.xanchor === 'right' || + (opts.xanchor === 'auto' && opts.x >= 2 / 3) + ); +}; + +exports.isTopAnchor = function isTopAnchor(opts) { + return ( + opts.yanchor === 'top' || + (opts.yanchor === 'auto' && opts.y >= 2 / 3) + ); +}; + +exports.isMiddleAnchor = function isMiddleAnchor(opts) { + return ( + opts.yanchor === 'middle' || + (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) + ); +}; + +exports.isBottomAnchor = function isBottomAnchor(opts) { + return ( + opts.yanchor === 'bottom' || + (opts.yanchor === 'auto' && opts.y <= 1 / 3) + ); +}; + +},{}],145:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -33922,7 +34184,7 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":169}],148:[function(_dereq_,module,exports){ +},{"./mod":167}],146:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34058,7 +34320,30 @@ exports.concat = function() { return out; }; -},{}],149:[function(_dereq_,module,exports){ +exports.maxRowLength = function(z) { + return _rowLength(z, Math.max, 0); +}; + +exports.minRowLength = function(z) { + return _rowLength(z, Math.min, Infinity); +}; + +function _rowLength(z, fn, len0) { + if(isArrayOrTypedArray(z)) { + if(isArrayOrTypedArray(z[0])) { + var len = len0; + for(var i = 0; i < z.length; i++) { + len = fn(len, z[i].length); + } + return len; + } else { + return z.length; + } + } + return 0; +} + +},{}],147:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34091,7 +34376,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":143,"fast-isnumeric":9}],150:[function(_dereq_,module,exports){ +},{"../constants/numerical":140,"fast-isnumeric":9}],148:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34119,7 +34404,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],151:[function(_dereq_,module,exports){ +},{}],149:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34142,7 +34427,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],152:[function(_dereq_,module,exports){ +},{}],150:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -34151,18 +34436,17 @@ module.exports = function clearResponsive(gd) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); var baseTraceAttrs = _dereq_('../plots/attributes'); -var getColorscale = _dereq_('../components/colorscale/get_scale'); -var colorscaleNames = Object.keys(_dereq_('../components/colorscale/scales')); +var scales = _dereq_('../components/colorscale/scales'); +var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; + var nestedProperty = _dereq_('./nested_property'); var counterRegex = _dereq_('./regex').counter; -var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; var modHalf = _dereq_('./mod').modHalf; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -34280,7 +34564,7 @@ exports.valObjectMeta = { coerceFunction: function(v, propOut, dflt) { - propOut.set(getColorscale(v, dflt)); + propOut.set(scales.get(v, dflt)); } }, angle: { @@ -34614,7 +34898,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/get_scale":56,"../components/colorscale/scales":62,"../constants/interactions":142,"../plots/attributes":203,"./array":148,"./mod":169,"./nested_property":170,"./regex":177,"fast-isnumeric":9,"tinycolor2":26}],153:[function(_dereq_,module,exports){ +},{"../components/colorscale/scales":58,"../constants/interactions":139,"../plots/attributes":201,"./array":146,"./mod":167,"./nested_property":168,"./regex":175,"fast-isnumeric":9,"tinycolor2":26}],151:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35217,7 +35501,7 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":143,"../registry":254,"./loggers":166,"./mod":169,"d3":7,"fast-isnumeric":9}],154:[function(_dereq_,module,exports){ +},{"../constants/numerical":140,"../registry":252,"./loggers":164,"./mod":167,"d3":7,"fast-isnumeric":9}],152:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35391,7 +35675,7 @@ var Events = { module.exports = Events; -},{"events":6}],155:[function(_dereq_,module,exports){ +},{"events":6}],153:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35507,7 +35791,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":163}],156:[function(_dereq_,module,exports){ +},{"./is_plain_object.js":161}],154:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35558,7 +35842,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],157:[function(_dereq_,module,exports){ +},{}],155:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35605,7 +35889,7 @@ function isCalcData(cont) { ); } -},{}],158:[function(_dereq_,module,exports){ +},{}],156:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35722,7 +36006,7 @@ exports.makeBlank = function() { }; }; -},{"../constants/numerical":143}],159:[function(_dereq_,module,exports){ +},{"../constants/numerical":140}],157:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -35968,7 +36252,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":169}],160:[function(_dereq_,module,exports){ +},{"./mod":167}],158:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36006,7 +36290,7 @@ module.exports = function(gd) { return gd; // otherwise assume that gd is a DOM element }; -},{}],161:[function(_dereq_,module,exports){ +},{}],159:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36022,7 +36306,7 @@ module.exports = function(gd) { module.exports = function identity(d) { return d; }; -},{}],162:[function(_dereq_,module,exports){ +},{}],160:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -36056,6 +36340,8 @@ lib.isArrayOrTypedArray = arrayModule.isArrayOrTypedArray; lib.isArray1D = arrayModule.isArray1D; lib.ensureArray = arrayModule.ensureArray; lib.concat = arrayModule.concat; +lib.maxRowLength = arrayModule.maxRowLength; +lib.minRowLength = arrayModule.minRowLength; var modModule = _dereq_('./mod'); lib.mod = modModule.mod; @@ -36125,6 +36411,14 @@ lib.pathArc = anglesModule.pathArc; lib.pathSector = anglesModule.pathSector; lib.pathAnnulus = anglesModule.pathAnnulus; +var anchorUtils = _dereq_('./anchor_utils'); +lib.isLeftAnchor = anchorUtils.isLeftAnchor; +lib.isCenterAnchor = anchorUtils.isCenterAnchor; +lib.isRightAnchor = anchorUtils.isRightAnchor; +lib.isTopAnchor = anchorUtils.isTopAnchor; +lib.isMiddleAnchor = anchorUtils.isMiddleAnchor; +lib.isBottomAnchor = anchorUtils.isBottomAnchor; + var geom2dModule = _dereq_('./geometry2d'); lib.segmentsIntersect = geom2dModule.segmentsIntersect; lib.segmentDistance = geom2dModule.segmentDistance; @@ -36659,7 +36953,13 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) objOut[k] = v.slice(0, arrayLen); + else if(Array.isArray(v)) { + if(k === 'colorscale') { + objOut[k] = v.slice(); + } else { + objOut[k] = v.slice(0, arrayLen); + } + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -37004,10 +37304,10 @@ lib.numSeparate = function(value, separators, separatethousands) { return x1 + x2; }; -var TEMPLATE_STRING_REGEX = /%{([^\s%{}]*)}/g; +var TEMPLATE_STRING_REGEX = /%{([^\s%{}:]*)(:[^}]*)?}/g; var SIMPLE_PROPERTY_REGEX = /^\w*$/; -/* +/** * Substitute values from an object into a string * * Examples: @@ -37019,7 +37319,6 @@ var SIMPLE_PROPERTY_REGEX = /^\w*$/; * * @return {string} templated string */ - lib.templateString = function(string, obj) { // Not all that useful, but cache nestedProperty instantiation // just in case it speeds things up *slightly*: @@ -37034,6 +37333,67 @@ lib.templateString = function(string, obj) { }); }; +var TEMPLATE_STRING_FORMAT_SEPARATOR = /^:/; +var numberOfHoverTemplateWarnings = 0; +var maximumNumberOfHoverTemplateWarnings = 10; +/** + * Substitute values from an object into a string and optionally formats them using d3-format, + * or fallback to associated labels. + * + * Examples: + * Lib.templateString('name: %{trace}', {trace: 'asdf'}) --> 'name: asdf' + * Lib.templateString('name: %{trace[0].name}', {trace: [{name: 'asdf'}]}) --> 'name: asdf' + * Lib.templateString('price: %{y:$.2f}', {y: 1}) --> 'price: $1.00' + * + * @param {string} input string containing %{...:...} template strings + * @param {obj} data object containing fallback text when no formatting is specified, ex.: {yLabel: 'formattedYValue'} + * @param {obj} data objects containing substitution values + * + * @return {string} templated string + */ +lib.hovertemplateString = function(string, labels) { + var args = arguments; + // Not all that useful, but cache nestedProperty instantiation + // just in case it speeds things up *slightly*: + var getterCache = {}; + + return string.replace(TEMPLATE_STRING_REGEX, function(match, key, format) { + var obj, value, i; + for(i = 2; i < args.length; i++) { + obj = args[i]; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; + } + + if(value === undefined) { + if(numberOfHoverTemplateWarnings < maximumNumberOfHoverTemplateWarnings) { + lib.warn('Variable \'' + key + '\' in hovertemplate could not be found!'); + value = match; + } + + if(numberOfHoverTemplateWarnings === maximumNumberOfHoverTemplateWarnings) { + lib.warn('Too many hovertemplate warnings - additional warnings will be suppressed'); + } + numberOfHoverTemplateWarnings++; + } + + if(format) { + value = d3.format(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value); + } else { + if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + } + return value; + }); +}; + /* * alphanumeric string sort, tailored for subplot IDs like scene2, scene10, x10y13 etc */ @@ -37076,7 +37436,7 @@ lib.pseudoRandom = function() { return randSeed / 4294967296; }; -},{"../constants/numerical":143,"./angles":147,"./array":148,"./clean_number":149,"./clear_responsive":151,"./coerce":152,"./dates":153,"./extend":155,"./filter_unique":156,"./filter_visible":157,"./geometry2d":159,"./get_graph_div":160,"./identity":161,"./is_plain_object":163,"./keyed_container":164,"./localize":165,"./loggers":166,"./make_trace_groups":167,"./matrix":168,"./mod":169,"./nested_property":170,"./noop":171,"./notifier":172,"./push_unique":175,"./regex":177,"./relative_attr":178,"./relink_private":179,"./search":180,"./stats":182,"./throttle":184,"./to_log_range":185,"d3":7,"fast-isnumeric":9}],163:[function(_dereq_,module,exports){ +},{"../constants/numerical":140,"./anchor_utils":144,"./angles":145,"./array":146,"./clean_number":147,"./clear_responsive":149,"./coerce":150,"./dates":151,"./extend":153,"./filter_unique":154,"./filter_visible":155,"./geometry2d":157,"./get_graph_div":158,"./identity":159,"./is_plain_object":161,"./keyed_container":162,"./localize":163,"./loggers":164,"./make_trace_groups":165,"./matrix":166,"./mod":167,"./nested_property":168,"./noop":169,"./notifier":170,"./push_unique":173,"./regex":175,"./relative_attr":176,"./relink_private":177,"./search":178,"./stats":180,"./throttle":182,"./to_log_range":183,"d3":7,"fast-isnumeric":9}],161:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37105,7 +37465,7 @@ module.exports = function isPlainObject(obj) { ); }; -},{}],164:[function(_dereq_,module,exports){ +},{}],162:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37298,7 +37658,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":170}],165:[function(_dereq_,module,exports){ +},{"./nested_property":168}],163:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37354,7 +37714,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":254}],166:[function(_dereq_,module,exports){ +},{"../registry":252}],164:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37440,7 +37800,7 @@ function apply(f, args) { } } -},{"../plot_api/plot_config":194}],167:[function(_dereq_,module,exports){ +},{"../plot_api/plot_config":192}],165:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37477,7 +37837,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{}],168:[function(_dereq_,module,exports){ +},{}],166:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37587,7 +37947,7 @@ exports.apply2DTransform2 = function(transform) { }; }; -},{}],169:[function(_dereq_,module,exports){ +},{}],167:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37622,7 +37982,7 @@ module.exports = { modHalf: modHalf }; -},{}],170:[function(_dereq_,module,exports){ +},{}],168:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37869,7 +38229,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":148,"fast-isnumeric":9}],171:[function(_dereq_,module,exports){ +},{"./array":146,"fast-isnumeric":9}],169:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37885,7 +38245,7 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],172:[function(_dereq_,module,exports){ +},{}],170:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -37967,7 +38327,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":7,"fast-isnumeric":9}],173:[function(_dereq_,module,exports){ +},{"d3":7,"fast-isnumeric":9}],171:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38016,7 +38376,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":181}],174:[function(_dereq_,module,exports){ +},{"./setcursor":179}],172:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38269,7 +38629,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":143,"./matrix":168}],175:[function(_dereq_,module,exports){ +},{"../constants/numerical":140,"./matrix":166}],173:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38309,7 +38669,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],176:[function(_dereq_,module,exports){ +},{}],174:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38520,7 +38880,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":162,"../plot_api/plot_config":194}],177:[function(_dereq_,module,exports){ +},{"../lib":160,"../plot_api/plot_config":192}],175:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38539,16 +38899,18 @@ module.exports = queue; * @param {Optional(string)} tail: a fixed piece after the id * eg counterRegex('scene', '.annotations') for scene2.annotations etc. * @param {boolean} openEnded: if true, the string may continue past the match. + * @param {boolean} matchBeginning: if false, the string may start before the match. */ -exports.counter = function(head, tail, openEnded) { +exports.counter = function(head, tail, openEnded, matchBeginning) { var fullTail = (tail || '') + (openEnded ? '' : '$'); + var startWithPrefix = matchBeginning === false ? '' : '^'; if(head === 'xy') { - return new RegExp('^x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + 'x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); } - return new RegExp('^' + head + '([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],178:[function(_dereq_,module,exports){ +},{}],176:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38601,7 +38963,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],179:[function(_dereq_,module,exports){ +},{}],177:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38664,7 +39026,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":148,"./is_plain_object":163}],180:[function(_dereq_,module,exports){ +},{"./array":146,"./is_plain_object":161}],178:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38852,7 +39214,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"./identity":161,"./loggers":166,"fast-isnumeric":9}],181:[function(_dereq_,module,exports){ +},{"./identity":159,"./loggers":164,"fast-isnumeric":9}],179:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38875,7 +39237,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],182:[function(_dereq_,module,exports){ +},{}],180:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -38976,7 +39338,7 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":148,"fast-isnumeric":9}],183:[function(_dereq_,module,exports){ +},{"./array":146,"fast-isnumeric":9}],181:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39751,7 +40113,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":141,"../constants/xmlns_namespaces":144,"../lib":162,"d3":7}],184:[function(_dereq_,module,exports){ +},{"../constants/alignment":138,"../constants/xmlns_namespaces":141,"../lib":160,"d3":7}],182:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39855,7 +40217,7 @@ function _clearTimeout(cache) { } } -},{}],185:[function(_dereq_,module,exports){ +},{}],183:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39883,7 +40245,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":9}],186:[function(_dereq_,module,exports){ +},{"fast-isnumeric":9}],184:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39905,7 +40267,7 @@ module.exports = { } }; -},{}],187:[function(_dereq_,module,exports){ +},{}],185:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -39948,7 +40310,7 @@ module.exports = { } }; -},{}],188:[function(_dereq_,module,exports){ +},{}],186:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40006,7 +40368,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":254}],189:[function(_dereq_,module,exports){ +},{"../registry":252}],187:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40132,7 +40494,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":162}],190:[function(_dereq_,module,exports){ +},{"../lib":160}],188:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40188,6 +40550,8 @@ exports.cleanLayout = function(layout) { } var axisAttrRegex = (Plots.subplotsRegistry.cartesian || {}).attrRegex; + var polarAttrRegex = (Plots.subplotsRegistry.polar || {}).attrRegex; + var ternaryAttrRegex = (Plots.subplotsRegistry.ternary || {}).attrRegex; var sceneAttrRegex = (Plots.subplotsRegistry.gl3d || {}).attrRegex; var keys = Object.keys(layout); @@ -40226,6 +40590,24 @@ exports.cleanLayout = function(layout) { } delete ax.autotick; } + + cleanTitle(ax); + } + + // modifications for polar + else if(polarAttrRegex && polarAttrRegex.test(key)) { + var polar = layout[key]; + + cleanTitle(polar.radialaxis); + } + + // modifications for ternary + else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + var ternary = layout[key]; + + cleanTitle(ternary.aaxis); + cleanTitle(ternary.baxis); + cleanTitle(ternary.caxis); } // modifications for 3D scenes @@ -40249,11 +40631,16 @@ exports.cleanLayout = function(layout) { scene.camera = { eye: {x: eye[0], y: eye[1], z: eye[2]}, center: {x: center[0], y: center[1], z: center[2]}, - up: {x: mat[1], y: mat[5], z: mat[9]} + up: {x: 0, y: 0, z: 1} // we just ignore calculating camera z up in this case }; delete scene.cameraposition; } + + // clean axis titles + cleanTitle(scene.xaxis); + cleanTitle(scene.yaxis); + cleanTitle(scene.zaxis); } } @@ -40311,6 +40698,9 @@ exports.cleanLayout = function(layout) { } } + // clean plot title + cleanTitle(layout); + /* * Moved from rotate -> orbit for dragmode */ @@ -40320,6 +40710,11 @@ exports.cleanLayout = function(layout) { // supported, but new tinycolor does not because they're not valid css Color.clean(layout); + // clean the layout container in layout.template + if(layout.template && layout.template.layout) { + exports.cleanLayout(layout.template.layout); + } + return layout; }; @@ -40331,6 +40726,46 @@ function cleanAxRef(container, attr) { } } +/** + * Cleans up old title attribute structure (flat) in favor of the new one (nested). + * + * @param {Object} titleContainer - an object potentially including deprecated title attributes + */ +function cleanTitle(titleContainer) { + if(titleContainer) { + + // title -> title.text + // (although title used to be a string attribute, + // numbers are accepted as well) + if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') { + titleContainer.title = { + text: titleContainer.title + }; + } + + rewireAttr('titlefont', 'font'); + rewireAttr('titleposition', 'position'); + rewireAttr('titleside', 'side'); + rewireAttr('titleoffset', 'offset'); + } + + function rewireAttr(oldAttrName, newAttrName) { + var oldAttrSet = titleContainer[oldAttrName]; + var newAttrSet = titleContainer.title && titleContainer.title[newAttrName]; + + if(oldAttrSet && !newAttrSet) { + + // Ensure title object exists + if(!titleContainer.title) { + titleContainer.title = {}; + } + + titleContainer.title[newAttrName] = titleContainer[oldAttrName]; + delete titleContainer[oldAttrName]; + } + } +} + /* * cleanData: Make a few changes to the data for backward compatibility * before it gets used for anything. Modifies the data traces users provide. @@ -40534,6 +40969,13 @@ exports.cleanData = function(data) { delete trace.autobiny; delete trace.ybins; } + + cleanTitle(trace); + if(trace.colorbar) cleanTitle(trace.colorbar); + if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar); + if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar); + if(trace.aaxis) cleanTitle(trace.aaxis); + if(trace.baxis) cleanTitle(trace.baxis); } }; @@ -40574,11 +41016,14 @@ function commonPrefix(name1, name2, show1, show2) { function cleanTextPosition(textposition) { var posY = 'middle', posX = 'center'; - if(textposition.indexOf('top') !== -1) posY = 'top'; - else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; - if(textposition.indexOf('left') !== -1) posX = 'left'; - else if(textposition.indexOf('right') !== -1) posX = 'right'; + if(typeof textposition === 'string') { + if(textposition.indexOf('top') !== -1) posY = 'top'; + else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; + + if(textposition.indexOf('left') !== -1) posX = 'left'; + else if(textposition.indexOf('right') !== -1) posX = 'right'; + } return posY + ' ' + posX; } @@ -40754,7 +41199,7 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":43,"../lib":162,"../plots/cartesian/axis_ids":209,"../plots/plots":246,"../registry":254,"fast-isnumeric":9,"gl-mat4/fromQuat":10}],191:[function(_dereq_,module,exports){ +},{"../components/color":43,"../lib":160,"../plots/cartesian/axis_ids":207,"../plots/plots":244,"../registry":252,"fast-isnumeric":9,"gl-mat4/fromQuat":10}],189:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40773,6 +41218,10 @@ exports.restyle = main.restyle; exports.relayout = main.relayout; exports.redraw = main.redraw; exports.update = main.update; +exports._guiRestyle = main._guiRestyle; +exports._guiRelayout = main._guiRelayout; +exports._guiUpdate = main._guiUpdate; +exports._storeDirectGUIEdit = main._storeDirectGUIEdit; exports.react = main.react; exports.extendTraces = main.extendTraces; exports.prependTraces = main.prependTraces; @@ -40793,7 +41242,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":256,"./plot_api":193,"./template_api":198,"./to_image":199,"./validate":200}],192:[function(_dereq_,module,exports){ +},{"../snapshot/download":254,"./plot_api":191,"./template_api":196,"./to_image":197,"./validate":198}],190:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -40805,7 +41254,6 @@ exports.validateTemplate = templateApi.validateTemplate; 'use strict'; -var nestedProperty = _dereq_('../lib/nested_property'); var isPlainObject = _dereq_('../lib/is_plain_object'); var noop = _dereq_('../lib/noop'); var Loggers = _dereq_('../lib/loggers'); @@ -40862,11 +41310,15 @@ var isRemoveVal = exports.isRemoveVal = function isRemoveVal(val) { * the flags for which actions we're going to perform to display these (and * any other) changes. If we're already `recalc`ing, we don't need to redraw * individual items + * @param {function} _nestedProperty + * a (possibly modified for gui edits) nestedProperty constructor + * The modified version takes a 3rd argument, for a prefix to the attribute + * string necessary for storing GUI edits * * @returns {bool} `true` if it managed to complete drawing of the changes * `false` would mean the parent should replot. */ -exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags) { +exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags, _nestedProperty) { var componentType = np.astr, supplyComponentDefaults = Registry.getComponentMethod(componentType, 'supplyLayoutDefaults'), draw = Registry.getComponentMethod(componentType, 'draw'), @@ -40906,7 +41358,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, // redoing supplyDefaults // TODO: this assumes componentArray is in gd.layout - which will not be // true after we extend this to restyle - componentArrayFull = nestedProperty(fullLayout, componentType).get(); + componentArrayFull = _nestedProperty(fullLayout, componentType).get(); var deletes = [], firstIndexChange = -1, @@ -40917,7 +41369,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, objEdits, objKeys, objVal, - adding; + adding, prefix; // first make the add and edit changes for(i = 0; i < componentNums.length; i++) { @@ -40956,7 +41408,9 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, } else { for(j = 0; j < objKeys.length; j++) { - nestedProperty(componentArray[componentNum], objKeys[j]).set(objEdits[objKeys[j]]); + prefix = componentType + '[' + componentNum + '].'; + _nestedProperty(componentArray[componentNum], objKeys[j], prefix) + .set(objEdits[objKeys[j]]); } } } @@ -41007,7 +41461,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":163,"../lib/loggers":166,"../lib/nested_property":170,"../lib/noop":171,"../lib/search":180,"../registry":254,"./container_array_match":188}],193:[function(_dereq_,module,exports){ +},{"../lib/is_plain_object":161,"../lib/loggers":164,"../lib/noop":169,"../lib/search":178,"../registry":252,"./container_array_match":186}],191:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -41025,6 +41479,8 @@ var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); var Lib = _dereq_('../lib'); +var nestedProperty = Lib.nestedProperty; + var Events = _dereq_('../lib/events'); var Queue = _dereq_('../lib/queue'); @@ -41120,9 +41576,6 @@ exports.plot = function(gd, data, layout, config) { // so we can share cached text across tabs Drawing.makeTester(); - // clear stashed base url - delete Drawing.baseUrl; - // collect promises for any async actions during plotting // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all @@ -41167,7 +41620,7 @@ exports.plot = function(gd, data, layout, config) { // Legacy polar plots if(!fullLayout._has('polar') && data && data[0] && data[0].r) { Lib.log('Legacy polar charts are deprecated!'); - return plotPolar(gd, data, layout); + return plotLegacyPolar(gd, data, layout); } // so we don't try to re-call Plotly.plot from inside @@ -41343,8 +41796,7 @@ exports.plot = function(gd, data, layout, config) { return Lib.syncOrAsync([ Registry.getComponentMethod('shapes', 'calcAutorange'), Registry.getComponentMethod('annotations', 'calcAutorange'), - doAutoRangeAndConstraints, - Registry.getComponentMethod('rangeslider', 'calcAutorange') + doAutoRangeAndConstraints ], gd); } @@ -41356,11 +41808,16 @@ exports.plot = function(gd, data, layout, config) { // store initial ranges *after* enforcing constraints, otherwise // we will never look like we're at the initial ranges if(graphWasEmpty) Axes.saveRangeInitial(gd); + + // this one is different from shapes/annotations calcAutorange + // the others incorporate those components into ax._extremes, + // this one actually sets the ranges in rangesliders. + Registry.getComponentMethod('rangeslider', 'calcAutorange')(gd); } // draw ticks, titles, and calculate axis scaling (._b, ._m) function drawAxes() { - return Axes.doTicks(gd, graphWasEmpty ? '' : 'redraw'); + return Axes.draw(gd, graphWasEmpty ? '' : 'redraw'); } var seq = [ @@ -41429,7 +41886,16 @@ function opaqueSetBackground(gd, bgColor) { } function setPlotContext(gd, config) { - if(!gd._context) gd._context = Lib.extendDeep({}, defaultConfig); + if(!gd._context) { + gd._context = Lib.extendDeep({}, defaultConfig); + + // stash href, used to make robust clipPath URLs + var base = d3.select('base'); + gd._context._baseUrl = base.size() && base.attr('href') ? + window.location.href.split('#')[0] : + ''; + } + var context = gd._context; var i, keys, key; @@ -41475,6 +41941,9 @@ function setPlotContext(gd, config) { } } } + + // not part of the user-facing config options + context._exportedPlot = config._exportedPlot; } // staticPlot forces a bunch of others: @@ -41504,7 +41973,7 @@ function setPlotContext(gd, config) { context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0; } -function plotPolar(gd, data, layout) { +function plotLegacyPolar(gd, data, layout) { // build or reuse the container skeleton var plotContainer = d3.select(gd).selectAll('.plot-container') .data([0]); @@ -41545,7 +42014,7 @@ function plotPolar(gd, data, layout) { // editable title var opacity = 1; - var txt = gd._fullLayout.title; + var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; if(txt === '' || !txt) opacity = 0; var titleLayout = function() { @@ -41579,7 +42048,7 @@ function plotPolar(gd, data, layout) { var setContenteditable = function() { this.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { - gd.framework({layout: {title: text}}); + gd.framework({layout: {title: {text: text}}}); this.text(text) .call(titleLayout); this.call(setContenteditable); @@ -41852,7 +42321,7 @@ function getExtendProperties(gd, update, indices, maxPoints) { * instance that references the key and value for this particular trace. */ trace = gd.data[indices[j]]; - prop = Lib.nestedProperty(trace, key); + prop = nestedProperty(trace, key); /* * Target is the existing gd.data.trace.dataArray value like "x" or "marker.size" @@ -42323,7 +42792,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) { * If the array is too short, it will wrap around (useful for * style files that want to specify cyclical default values). */ -exports.restyle = function restyle(gd, astr, val, _traces) { +function restyle(gd, astr, val, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -42393,7 +42862,8 @@ exports.restyle = function restyle(gd, astr, val, _traces) { gd.emit('plotly_restyle', specs.eventData); return gd; }); -}; +} +exports.restyle = restyle; // for undo: undefined initial vals must be turned into nulls // so that we unset rather than ignore them @@ -42402,11 +42872,77 @@ function undefinedToNull(val) { return val; } +/** + * Factory function to wrap nestedProperty with GUI edits if necessary + * with GUI edits we add an optional prefix to the nestedProperty constructor + * to prepend to the attribute string in the preGUI store. + */ +function makeNP(preGUI, guiEditFlag) { + if(!guiEditFlag) return nestedProperty; + + return function(container, attr, prefix) { + var np = nestedProperty(container, attr); + var npSet = np.set; + np.set = function(val) { + var fullAttr = (prefix || '') + attr; + storeCurrent(fullAttr, np.get(), val, preGUI); + npSet(val); + }; + return np; + }; +} + +function storeCurrent(attr, val, newVal, preGUI) { + if(Array.isArray(val) || Array.isArray(newVal)) { + var arrayVal = Array.isArray(val) ? val : []; + var arrayNew = Array.isArray(newVal) ? newVal : []; + var maxLen = Math.max(arrayVal.length, arrayNew.length); + for(var i = 0; i < maxLen; i++) { + storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); + } + } + else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + var objVal = Lib.isPlainObject(val) ? val : {}; + var objNew = Lib.isPlainObject(newVal) ? newVal : {}; + var objBoth = Lib.extendFlat({}, objVal, objNew); + for(var key in objBoth) { + storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); + } + } + else if(preGUI[attr] === undefined) { + preGUI[attr] = undefinedToNull(val); + } +} + +/** + * storeDirectGUIEdit: for routines that skip restyle/relayout and mock it + * by emitting a plotly_restyle or plotly_relayout event, this routine + * keeps track of the initial state in _preGUI for use by uirevision + * Does *not* apply these changes to data/layout - that's the responsibility + * of the calling routine. + * + * @param {object} container: the input attributes container (eg `layout` or a `trace`) + * @param {object} preGUI: where original values should be stored, either + * `layout._preGUI` or `layout._tracePreGUI[uid]` + * @param {object} edits: the {attr: val} object as normally passed to `relayout` etc + */ +exports._storeDirectGUIEdit = function(container, preGUI, edits) { + for(var attr in edits) { + var np = nestedProperty(container, attr); + storeCurrent(attr, np.get(), edits[attr], preGUI); + } +}; + function _restyle(gd, aobj, traces) { - var fullLayout = gd._fullLayout, - fullData = gd._fullData, - data = gd.data, - i; + var fullLayout = gd._fullLayout; + var fullData = gd._fullData; + var data = gd.data; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var eventData = Lib.extendDeepAll({}, aobj); + var i; + + cleanDeprecatedAttributeKeys(aobj); // initialize flags var flags = editTypes.traceFlags(); @@ -42430,6 +42966,16 @@ function _restyle(gd, aobj, traces) { function rangeAttr(axName) { return 'LAYOUT' + axName + '.range'; } + function getFullTrace(traceIndex) { + // usually fullData maps 1:1 onto data, but with groupby transforms + // the fullData index can be greater. Take the *first* matching trace. + for(var j = traceIndex; j < fullData.length; j++) { + if(fullData[j]._input === data[traceIndex]) return fullData[j]; + } + // should never get here - and if we *do* it should cause an error + // later on undefined fullTrace is passed to nestedProperty. + } + // for attrs that interact (like scales & autoscales), save the // old vals before making the change // val=undefined will not set a value, just record what the value was. @@ -42445,9 +42991,11 @@ function _restyle(gd, aobj, traces) { var extraparam; if(attr.substr(0, 6) === 'LAYOUT') { - extraparam = Lib.nestedProperty(gd.layout, attr.replace('LAYOUT', '')); + extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', '')); } else { - extraparam = Lib.nestedProperty(data[traces[i]], attr); + var tracei = traces[i]; + var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid]; + extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr); } if(!(attr in undoit)) { @@ -42502,7 +43050,7 @@ function _restyle(gd, aobj, traces) { redoit[ai] = vi; if(ai.substr(0, 6) === 'LAYOUT') { - param = Lib.nestedProperty(gd.layout, ai.replace('LAYOUT', '')); + param = layoutNP(gd.layout, ai.replace('LAYOUT', '')); undoit[ai] = [undefinedToNull(param.get())]; // since we're allowing val to be an array, allow it here too, // even though that's meaningless @@ -42517,8 +43065,9 @@ function _restyle(gd, aobj, traces) { undoit[ai] = a0(); for(i = 0; i < traces.length; i++) { cont = data[traces[i]]; - contFull = fullData[traces[i]]; - param = Lib.nestedProperty(cont, ai); + contFull = getFullTrace(traces[i]); + var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid]; + param = makeNP(preGUI, guiEditFlag)(cont, ai); oldVal = param.get(); newVal = Array.isArray(vi) ? vi[i % vi.length] : vi; @@ -42528,7 +43077,7 @@ function _restyle(gd, aobj, traces) { var prefix = ai.substr(0, ai.length - finalPart.length - 1); var prefixDot = prefix ? prefix + '.' : ''; var innerContFull = prefix ? - Lib.nestedProperty(contFull, prefix).get() : contFull; + nestedProperty(contFull, prefix).get() : contFull; valObject = PlotSchema.getTraceValObject(contFull, param.parts); @@ -42575,14 +43124,14 @@ function _restyle(gd, aobj, traces) { Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo); if(oldVal === 'pie') { - Lib.nestedProperty(cont, 'marker.color') - .set(Lib.nestedProperty(cont, 'marker.colors').get()); + nestedProperty(cont, 'marker.color') + .set(nestedProperty(cont, 'marker.colors').get()); // super kludgy - but if all pies are gone we won't remove them otherwise fullLayout._pielayer.selectAll('g.trace').remove(); } else if(Registry.traceIs(cont, 'cartesian')) { - Lib.nestedProperty(cont, 'marker.colors') - .set(Lib.nestedProperty(cont, 'marker.color').get()); + nestedProperty(cont, 'marker.colors') + .set(nestedProperty(cont, 'marker.color').get()); } } @@ -42653,7 +43202,7 @@ function _restyle(gd, aobj, traces) { // swap hovermode if set to "compare x/y data" if(ai === 'orientationaxes') { - var hovermode = Lib.nestedProperty(gd.layout, 'hovermode'); + var hovermode = nestedProperty(gd.layout, 'hovermode'); if(hovermode.get() === 'x') { hovermode.set('y'); } else if(hovermode.get() === 'y') { @@ -42692,10 +43241,53 @@ function _restyle(gd, aobj, traces) { undoit: undoit, redoit: redoit, traces: traces, - eventData: Lib.extendDeepNoArrays([], [redoit, traces]) + eventData: Lib.extendDeepNoArrays([], [eventData, traces]) }; } +/** + * Converts deprecated attribute keys to + * the current API to ensure backwards compatibility. + * + * This is needed for the update mechanism to determine which + * subroutines to run based on the actual attribute + * definitions (that don't include the deprecated ones). + * + * E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'} + * and {titlefont: {...}} to {'title.font': {...}}. + * + * @param aobj + */ +function cleanDeprecatedAttributeKeys(aobj) { + var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false); + var colorbarRegex = /colorbar\.title$/; + var keys = Object.keys(aobj); + var i, key, value; + + for(i = 0; i < keys.length; i++) { + key = keys[i]; + value = aobj[key]; + + if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) && + (typeof value === 'string' || typeof value === 'number')) { + replace(key, key.replace('title', 'title.text')); + } else if(key.indexOf('titlefont') > -1) { + replace(key, key.replace('titlefont', 'title.font')); + } else if(key.indexOf('titleposition') > -1) { + replace(key, key.replace('titleposition', 'title.position')); + } else if(key.indexOf('titleside') > -1) { + replace(key, key.replace('titleside', 'title.side')); + } else if(key.indexOf('titleoffset') > -1) { + replace(key, key.replace('titleoffset', 'title.offset')); + } + } + + function replace(oldAttrStr, newAttrStr) { + aobj[newAttrStr] = aobj[oldAttrStr]; + delete aobj[oldAttrStr]; + } +} + /** * relayout: update layout attributes of an existing plot * @@ -42716,7 +43308,7 @@ function _restyle(gd, aobj, traces) { * attribute object `{astr1: val1, astr2: val2 ...}` * allows setting multiple attributes simultaneously */ -exports.relayout = function relayout(gd, astr, val) { +function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -42779,7 +43371,8 @@ exports.relayout = function relayout(gd, astr, val) { gd.emit('plotly_relayout', specs.eventData); return gd; }); -}; +} +exports.relayout = relayout; // Optimization mostly for large splom traces where // Plots.supplyDefaults can take > 100ms @@ -42807,13 +43400,24 @@ function addAxRangeSequence(seq, rangesAltered) { // N.B. leave as sequence of subroutines (for now) instead of // subroutine of its own so that finalDraw always gets // executed after drawData - var doTicks = rangesAltered ? - function(gd) { return Axes.doTicks(gd, Object.keys(rangesAltered), true); } : - function(gd) { return Axes.doTicks(gd, 'redraw'); }; + var drawAxes = rangesAltered ? + function(gd) { + var opts = {skipTitle: true}; + for(var id in rangesAltered) { + if(Axes.getFromId(gd, id).automargin) { + opts = {}; + break; + } + } + return Axes.draw(gd, Object.keys(rangesAltered), opts); + } : + function(gd) { + return Axes.draw(gd, 'redraw'); + }; seq.push( subroutines.doAutoRangeAndConstraints, - doTicks, + drawAxes, subroutines.drawData, subroutines.finalDraw ); @@ -42824,14 +43428,19 @@ var AX_AUTORANGE_RE = /^[xyz]axis[0-9]*\.autorange$/; var AX_DOMAIN_RE = /^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/; function _relayout(gd, aobj) { - var layout = gd.layout, - fullLayout = gd._fullLayout, - keys = Object.keys(aobj), - axes = Axes.list(gd), - arrayEdits = {}, - arrayStr, - i, - j; + var layout = gd.layout; + var fullLayout = gd._fullLayout; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var keys = Object.keys(aobj); + var axes = Axes.list(gd); + var eventData = Lib.extendDeepAll({}, aobj); + var arrayEdits = {}; + + var arrayStr, i, j; + + cleanDeprecatedAttributeKeys(aobj); + keys = Object.keys(aobj); // look for 'allaxes', split out into all axes // in case of 3D the axis are nested within a scene which is held in _id @@ -42871,7 +43480,7 @@ function _relayout(gd, aobj) { // via a parent) do not override with this auto-generated extra if(attr in aobj || helpers.hasParent(aobj, attr)) return; - var p = Lib.nestedProperty(layout, attr); + var p = layoutNP(layout, attr); if(!(attr in undoit)) { undoit[attr] = undefinedToNull(p.get()); } @@ -42896,7 +43505,7 @@ function _relayout(gd, aobj) { throw new Error('cannot set ' + ai + 'and a parent attribute simultaneously'); } - var p = Lib.nestedProperty(layout, ai); + var p = layoutNP(layout, ai); var vi = aobj[ai]; var plen = p.parts.length; // p.parts may end with an index integer if the property is an array @@ -42908,8 +43517,8 @@ function _relayout(gd, aobj) { var pleafPlus = p.parts[pend - 1] + '.' + pleaf; // trunk nodes (everything except the leaf) var ptrunk = p.parts.slice(0, pend).join('.'); - var parentIn = Lib.nestedProperty(gd.layout, ptrunk).get(); - var parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + var parentIn = nestedProperty(gd.layout, ptrunk).get(); + var parentFull = nestedProperty(fullLayout, ptrunk).get(); var vOld = p.get(); if(vi === undefined) continue; @@ -42954,12 +43563,12 @@ function _relayout(gd, aobj) { // check autorange vs range else if(pleafPlus.match(AX_RANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - var axFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + var axFull = nestedProperty(fullLayout, ptrunk).get(); if(axFull._inputDomain) { // if we're autoranging and this axis has a constrained domain, // reset it so we don't get locked into a shrunken size @@ -42967,7 +43576,7 @@ function _relayout(gd, aobj) { } } else if(pleafPlus.match(AX_DOMAIN_RE)) { - Lib.nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); + nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } // toggling axis type between log and linear: we need to convert @@ -43036,10 +43645,10 @@ function _relayout(gd, aobj) { doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleaf.match(AX_NAME_PATTERN)) { - var fullProp = Lib.nestedProperty(fullLayout, ai).get(), + var fullProp = nestedProperty(fullLayout, ai).get(), newType = (vi || {}).type; // This can potentially cause strange behavior if the autotype is not @@ -43061,8 +43670,6 @@ function _relayout(gd, aobj) { arrayStr = containerArrayMatch.array; i = containerArrayMatch.index; var propStr = containerArrayMatch.property; - var componentArray = Lib.nestedProperty(layout, arrayStr); - var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; if(i !== '' && propStr === '') { @@ -43072,7 +43679,7 @@ function _relayout(gd, aobj) { if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { - undoit[ai] = obji; + undoit[ai] = (nestedProperty(layout, arrayStr).get() || [])[i]; } else { Lib.warn('unrecognized full object value', aobj); } @@ -43116,7 +43723,7 @@ function _relayout(gd, aobj) { // now we've collected component edits - execute them all together for(arrayStr in arrayEdits) { var finished = manageArrays.applyContainerArrayChanges(gd, - Lib.nestedProperty(layout, arrayStr), arrayEdits[arrayStr], flags); + layoutNP(layout, arrayStr), arrayEdits[arrayStr], flags, layoutNP); if(!finished) flags.plot = true; } @@ -43159,7 +43766,7 @@ function _relayout(gd, aobj) { rangesAltered: rangesAltered, undoit: undoit, redoit: redoit, - eventData: Lib.extendDeep({}, redoit) + eventData: eventData }; } @@ -43194,7 +43801,7 @@ function updateAutosize(gd) { * integer or array of integers for the traces to alter (all if omitted) * */ -exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { +function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -43274,7 +43881,235 @@ exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { return gd; }); -}; +} +exports.update = update; + +/* + * internal-use-only restyle/relayout/update variants that record the initial + * values in (fullLayout|fullTrace)._preGUI so changes can be persisted across + * Plotly.react data updates, dependent on uirevision attributes + */ +function guiEdit(func) { + return function wrappedEdit(gd) { + gd._fullLayout._guiEditing = true; + var p = func.apply(null, arguments); + gd._fullLayout._guiEditing = false; + return p; + }; +} +exports._guiRestyle = guiEdit(restyle); +exports._guiRelayout = guiEdit(relayout); +exports._guiUpdate = guiEdit(update); + +// For connecting edited layout attributes to uirevision attrs +// If no `attr` we use `match[1] + '.uirevision'` +// Ordered by most common edits first, to minimize our search time +var layoutUIControlPatterns = [ + {pattern: /^hiddenlabels/, attr: 'legend.uirevision'}, + {pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/}, + + // showspikes and modes include those nested inside scenes + {pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'}, + {pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'}, + + {pattern: /^(scene\d*)\.camera/}, + {pattern: /^(geo\d*)\.(projection|center)/}, + {pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/}, + {pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/}, + {pattern: /^(polar\d*\.angularaxis)\.rotation/}, + {pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/}, + + {pattern: /^legend\.(x|y)$/, attr: 'editrevision'}, + {pattern: /^(shapes|annotations)/, attr: 'editrevision'}, + {pattern: /^title\.text$/, attr: 'editrevision'} +]; + +// same for trace attributes: if `attr` is given it's in layout, +// or with no `attr` we use `trace.uirevision` +var traceUIControlPatterns = [ + {pattern: /^selectedpoints$/, attr: 'selectionrevision'}, + // "visible" includes trace.transforms[i].styles[j].value.visible + {pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'}, + {pattern: /^dimensions\[\d+\]\.constraintrange/}, + + // below this you must be in editable: true mode + // TODO: I still put name and title with `trace.uirevision` + // reasonable or should these be `editrevision`? + // Also applies to axis titles up in the layout section + + // "name" also includes transform.styles + {pattern: /(^|value\.)name$/}, + // including nested colorbar attributes (ie marker.colorbar) + {pattern: /colorbar\.title\.text$/}, + {pattern: /colorbar\.(x|y)$/, attr: 'editrevision'} +]; + +function findUIPattern(key, patternSpecs) { + for(var i = 0; i < patternSpecs.length; i++) { + var spec = patternSpecs[i]; + var match = key.match(spec.pattern); + if(match) { + return {head: match[1], attr: spec.attr}; + } + } +} + +// We're finding the new uirevision before supplyDefaults, so do the +// inheritance manually. Note that only `undefined` inherits - other +// falsy values are returned. +function getNewRev(revAttr, container) { + var newRev = nestedProperty(container, revAttr).get(); + if(newRev !== undefined) return newRev; + + var parts = revAttr.split('.'); + parts.pop(); + while(parts.length > 1) { + parts.pop(); + newRev = nestedProperty(container, parts.join('.') + '.uirevision').get(); + if(newRev !== undefined) return newRev; + } + + return container.uirevision; +} + +function getFullTraceIndexFromUid(uid, fullData) { + for(var i = 0; i < fullData.length; i++) { + if(fullData[i]._fullInput.uid === uid) return i; + } + return -1; +} + +function getTraceIndexFromUid(uid, data, tracei) { + for(var i = 0; i < data.length; i++) { + if(data[i].uid === uid) return i; + } + // fall back on trace order, but only if user didn't provide a uid for that trace + return data[tracei].uid ? -1 : tracei; +} + +function valsMatch(v1, v2) { + var v1IsObj = Lib.isPlainObject(v1); + var v1IsArray = Array.isArray(v1); + if(v1IsObj || v1IsArray) { + return ( + (v1IsObj && Lib.isPlainObject(v2)) || + (v1IsArray && Array.isArray(v2)) + ) && JSON.stringify(v1) === JSON.stringify(v2); + } + return v1 === v2; +} + +function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { + var layoutPreGUI = oldFullLayout._preGUI; + var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal; + var bothInheritAutorange = []; + var newRangeAccepted = {}; + for(key in layoutPreGUI) { + match = findUIPattern(key, layoutUIControlPatterns); + if(match) { + revAttr = match.attr || (match.head + '.uirevision'); + oldRev = nestedProperty(oldFullLayout, revAttr).get(); + newRev = oldRev && getNewRev(revAttr, layout); + if(newRev && (newRev === oldRev)) { + preGUIVal = layoutPreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(layout, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + if(newVal === undefined && key.substr(key.length - 9) === 'autorange') { + bothInheritAutorange.push(key.substr(0, key.length - 10)); + } + newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key); + } + // if we got this far, the new value was accepted as the new starting + // point (either because it changed or revision changed) + // so remove it from _preGUI for next time. + delete layoutPreGUI[key]; + + if(key.substr(key.length - 8, 6) === 'range[') { + newRangeAccepted[key.substr(0, key.length - 9)] = 1; + } + } + + // Special logic for `autorange`, since it interacts with `range`: + // If the new figure's matching `range` was kept, and `autorange` + // wasn't supplied explicitly in either the original or the new figure, + // we shouldn't alter that - but we may just have done that, so fix it. + for(var i = 0; i < bothInheritAutorange.length; i++) { + var axAttr = bothInheritAutorange[i]; + if(newRangeAccepted[axAttr]) { + var newAx = nestedProperty(layout, axAttr).get(); + if(newAx) delete newAx.autorange; + } + } + + // Now traces - try to match them up by uid (in case we added/deleted in + // the middle), then fall back on index. + var allTracePreGUI = oldFullLayout._tracePreGUI; + for(var uid in allTracePreGUI) { + var tracePreGUI = allTracePreGUI[uid]; + var newTrace = null; + var fullInput; + for(key in tracePreGUI) { + // wait until we know we have preGUI values to look for traces + // but if we don't find both, stop looking at this uid + if(!newTrace) { + var fulli = getFullTraceIndexFromUid(uid, oldFullData); + if(fulli < 0) { + // Somehow we didn't even have this trace in oldFullData... + // I guess this could happen with `deleteTraces` or something + delete allTracePreGUI[uid]; + break; + } + var fullTrace = oldFullData[fulli]; + fullInput = fullTrace._fullInput; + + var newTracei = getTraceIndexFromUid(uid, data, fullInput.index); + if(newTracei < 0) { + // No match in new data + delete allTracePreGUI[uid]; + break; + } + newTrace = data[newTracei]; + } + + match = findUIPattern(key, traceUIControlPatterns); + if(match) { + if(match.attr) { + oldRev = nestedProperty(oldFullLayout, match.attr).get(); + newRev = oldRev && getNewRev(match.attr, layout); + } + else { + oldRev = fullInput.uirevision; + // inheritance for trace.uirevision is simple, just layout.uirevision + newRev = newTrace.uirevision; + if(newRev === undefined) newRev = layout.uirevision; + } + + if(newRev && newRev === oldRev) { + preGUIVal = tracePreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(newTrace, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + newNP.set(undefinedToNull(nestedProperty(fullInput, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); + } + delete tracePreGUI[key]; + } + } +} /** * Plotly.react: @@ -43338,6 +44173,8 @@ exports.react = function(gd, data, layout, config) { gd.layout = layout || {}; helpers.cleanLayout(gd.layout); + applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout); + // "true" skips updating calcdata and remapping arrays from calcTransforms, // which supplyDefaults usually does at the end, but we may need to NOT do // if the diff (which we haven't determined yet) says we'll recalc @@ -44392,7 +45229,7 @@ function makePlotFramework(gd) { gd.emit('plotly_framework'); } -},{"../components/color":43,"../components/colorbar/connect":45,"../components/drawing":68,"../constants/xmlns_namespaces":144,"../lib":162,"../lib/events":154,"../lib/queue":176,"../lib/svg_text_utils":183,"../plots/cartesian/axes":206,"../plots/cartesian/constants":212,"../plots/cartesian/graph_interact":216,"../plots/plots":246,"../plots/polar/legacy":249,"../registry":254,"./edit_types":189,"./helpers":190,"./manage_arrays":192,"./plot_config":194,"./plot_schema":195,"./subroutines":197,"d3":7,"fast-isnumeric":9,"has-hover":11}],194:[function(_dereq_,module,exports){ +},{"../components/color":43,"../components/colorbar/connect":45,"../components/drawing":64,"../constants/xmlns_namespaces":141,"../lib":160,"../lib/events":152,"../lib/queue":174,"../lib/svg_text_utils":181,"../plots/cartesian/axes":204,"../plots/cartesian/constants":210,"../plots/cartesian/graph_interact":214,"../plots/plots":244,"../plots/polar/legacy":247,"../registry":252,"./edit_types":187,"./helpers":188,"./manage_arrays":190,"./plot_config":192,"./plot_schema":193,"./subroutines":195,"d3":7,"fast-isnumeric":9,"has-hover":11}],192:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -44485,12 +45322,34 @@ module.exports = { */ showAxisRangeEntryBoxes: true, - // link to open this plot in plotly + /* + * Add a text link to open this plot in plotly? + * This link shows up in the bottom right corner of the plot, and works + * identically to the newer ModeBar button controlled by `showSendToCloud` + * unless `sendData: false` is used. + */ showLink: false, - // if we show a link, does it contain data or just link to a plotly file? + /* + * If we show a text link (`showLink: true`), does it contain data or just + * a reference to a plotly cloud file? This option should only be used on + * plot.ly or another plotly server, and is not supported by the newer + * ModeBar button `showSendToCloud`. + */ sendData: true, + /* + * Should we include a ModeBar button, labeled "Edit in Chart Studio", + * that sends this chart to plot.ly or another plotly server as specified + * by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0 + * this button was included by default, now it is opt-in using this flag. + * + * Note that this button can (depending on `plotlyServerURL`) send your data + * to an external server. However that server doesn't persist your data + * until you arrive at the Chart Studio and explicitly click "Save". + */ + showSendToCloud: false, + // text appearing in the sendData link linkText: 'Edit chart', @@ -44528,6 +45387,9 @@ module.exports = { // add the plotly logo on the end of the mode bar displaylogo: true, + // watermark the images with the company's logo + watermark: false, + // increase the pixel ratio for Gl plot images plotGlPixelRatio: 2, @@ -44594,7 +45456,7 @@ module.exports = { locales: {} }; -},{}],195:[function(_dereq_,module,exports){ +},{}],193:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45280,7 +46142,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":162,"../plots/animation_attributes":201,"../plots/attributes":203,"../plots/frame_attributes":234,"../plots/layout_attributes":237,"../plots/polar/legacy/area_attributes":247,"../plots/polar/legacy/axis_attributes":248,"../registry":254,"./edit_types":189}],196:[function(_dereq_,module,exports){ +},{"../lib":160,"../plots/animation_attributes":199,"../plots/attributes":201,"../plots/frame_attributes":232,"../plots/layout_attributes":235,"../plots/polar/legacy/area_attributes":245,"../plots/polar/legacy/axis_attributes":246,"../registry":252,"./edit_types":187}],194:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45594,7 +46456,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":162,"../plots/attributes":203}],197:[function(_dereq_,module,exports){ +},{"../lib":160,"../plots/attributes":201}],195:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -45624,6 +46486,10 @@ var enforceAxisConstraints = axisConstraints.enforce; var cleanAxisConstraints = axisConstraints.clean; var doAutoRange = _dereq_('../plots/cartesian/autorange').doAutoRange; +var SVG_TEXT_ANCHOR_START = 'start'; +var SVG_TEXT_ANCHOR_MIDDLE = 'middle'; +var SVG_TEXT_ANCHOR_END = 'end'; + exports.layoutStyles = function(gd) { return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd); }; @@ -45648,7 +46514,7 @@ function lsInner(gd) { var gs = fullLayout._size; var pad = gs.p; var axList = Axes.list(gd, '', true); - var i, subplot, plotinfo, xa, ya; + var i, subplot, plotinfo, ax, xa, ya; fullLayout._paperdiv.style({ width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px', @@ -45684,10 +46550,7 @@ function lsInner(gd) { // some preparation of axis position info for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - - // reset scale in case the margins have changed - ax.setScale(); + ax = axList[i]; var counterAx = ax._anchorAxis; @@ -45706,11 +46569,6 @@ function lsInner(gd) { ax._mainMirrorPosition = (ax.mirror && counterAx) ? getLinePosition(ax, counterAx, alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; - - // Figure out which subplot to draw ticks, labels, & axis lines on - // do this as a separate loop so we already have all the - // _mainAxis and _anchorAxis links set - ax._mainSubplot = findMainSubplot(ax, fullLayout); } // figure out which backgrounds we need to draw, @@ -45821,7 +46679,7 @@ function lsInner(gd) { layerClipId = null; } - Drawing.setClipUrl(plotinfo.plot, plotClipId); + Drawing.setClipUrl(plotinfo.plot, plotClipId, gd); // stash layer clipId value (null or same as clipId) // to DRY up Drawing.setClipUrl calls on trace-module and trace layers @@ -45951,48 +46809,6 @@ function lsInner(gd) { return gd._promises.length && Promise.all(gd._promises); } -function findMainSubplot(ax, fullLayout) { - var subplotList = fullLayout._subplots; - var ids = subplotList.cartesian.concat(subplotList.gl2d || []); - var mockGd = {_fullLayout: fullLayout}; - - var isX = ax._id.charAt(0) === 'x'; - var anchorAx = ax._mainAxis._anchorAxis; - var mainSubplotID = ''; - var nextBestMainSubplotID = ''; - var anchorID = ''; - - // First try the main ID with the anchor - if(anchorAx) { - anchorID = anchorAx._mainAxis._id; - mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); - } - - // Then look for a subplot with the counteraxis overlaying the anchor - // If that fails just use the first subplot including this axis - if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { - mainSubplotID = ''; - - for(var j = 0; j < ids.length; j++) { - var id = ids[j]; - var yIndex = id.indexOf('y'); - var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); - var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); - - if(idPart === ax._id) { - if(!nextBestMainSubplotID) nextBestMainSubplotID = id; - var counterAx = Axes.getFromId(mockGd, counterPart); - if(anchorID && counterAx.overlaying === anchorID) { - mainSubplotID = id; - break; - } - } - } - } - - return mainSubplotID || nextBestMainSubplotID; -} - function shouldShowLinesOrTicks(ax, subplot) { return (ax.ticks || ax.showline) && (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); @@ -46047,18 +46863,92 @@ function findCounterAxisLineWidth(ax, side, counterAx, axList) { exports.drawMainTitle = function(gd) { var fullLayout = gd._fullLayout; + var textAnchor = getMainTitleTextAnchor(fullLayout); + var dy = getMainTitleDy(fullLayout); + Titles.draw(gd, 'gtitle', { propContainer: fullLayout, - propName: 'title', + propName: 'title.text', placeholder: fullLayout._dfltTitle.plot, attributes: { - x: fullLayout.width / 2, - y: fullLayout._size.t / 2, - 'text-anchor': 'middle' + x: getMainTitleX(fullLayout, textAnchor), + y: getMainTitleY(fullLayout, dy), + 'text-anchor': textAnchor, + dy: dy } }); }; +function getMainTitleX(fullLayout, textAnchor) { + var title = fullLayout.title; + var gs = fullLayout._size; + var hPadShift = 0; + + if(textAnchor === SVG_TEXT_ANCHOR_START) { + hPadShift = title.pad.l; + } else if(textAnchor === SVG_TEXT_ANCHOR_END) { + hPadShift = -title.pad.r; + } + + switch(title.xref) { + case 'paper': + return gs.l + gs.w * title.x + hPadShift; + case 'container': + default: + return fullLayout.width * title.x + hPadShift; + } +} + +function getMainTitleY(fullLayout, dy) { + var title = fullLayout.title; + var gs = fullLayout._size; + var vPadShift = 0; + + if(dy === '0em' || !dy) { + vPadShift = -title.pad.b; + } else if(dy === alignmentConstants.CAP_SHIFT + 'em') { + vPadShift = title.pad.t; + } + + if(title.y === 'auto') { + return gs.t / 2; + } else { + switch(title.yref) { + case 'paper': + return gs.t + gs.h - gs.h * title.y + vPadShift; + case 'container': + default: + return fullLayout.height - fullLayout.height * title.y + vPadShift; + } + } +} + +function getMainTitleTextAnchor(fullLayout) { + var title = fullLayout.title; + + var textAnchor = SVG_TEXT_ANCHOR_MIDDLE; + if(Lib.isRightAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_END; + } else if(Lib.isLeftAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_START; + } + + return textAnchor; +} + +function getMainTitleDy(fullLayout) { + var title = fullLayout.title; + + var dy = '0em'; + if(Lib.isTopAnchor(title)) { + dy = alignmentConstants.CAP_SHIFT + 'em'; + } else if(Lib.isMiddleAnchor(title)) { + dy = alignmentConstants.MID_SHIFT + 'em'; + } + + return dy; +} + exports.doTraceStyle = function(gd) { var calcdata = gd.calcdata; var editStyleCalls = []; @@ -46136,7 +47026,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.doTicks(gd, 'redraw'); + Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -46271,6 +47161,8 @@ exports.doAutoRangeAndConstraints = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; cleanAxisConstraints(gd, ax); + // in case margins changed, update scale + ax.setScale(); doAutoRange(gd, ax); } @@ -46302,7 +47194,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('updatemenus', 'draw')(gd); }; -},{"../components/color":43,"../components/drawing":68,"../components/modebar":106,"../components/titles":134,"../constants/alignment":141,"../lib":162,"../lib/clear_gl_canvases":150,"../plots/cartesian/autorange":205,"../plots/cartesian/axes":206,"../plots/cartesian/constraints":214,"../plots/plots":246,"../registry":254,"d3":7}],198:[function(_dereq_,module,exports){ +},{"../components/color":43,"../components/drawing":64,"../components/modebar":102,"../components/titles":131,"../constants/alignment":138,"../lib":160,"../lib/clear_gl_canvases":148,"../plots/cartesian/autorange":203,"../plots/cartesian/axes":204,"../plots/cartesian/constraints":212,"../plots/plots":244,"../registry":252,"d3":7}],196:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46776,7 +47668,7 @@ function format(opts) { return opts; } -},{"../lib":162,"../plots/attributes":203,"../plots/plots":246,"./plot_config":194,"./plot_schema":195,"./plot_template":196}],199:[function(_dereq_,module,exports){ +},{"../lib":160,"../plots/attributes":201,"../plots/plots":244,"./plot_config":192,"./plot_schema":193,"./plot_template":194}],197:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -46896,6 +47788,7 @@ function toImage(gd, opts) { // extend config for static plot var configImage = Lib.extendFlat({}, config, { + _exportedPlot: true, staticPlot: true, setBackground: setBackground }); @@ -46966,7 +47859,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":162,"../snapshot/helpers":258,"../snapshot/svgtoimg":260,"../snapshot/tosvg":262,"./plot_api":193}],200:[function(_dereq_,module,exports){ +},{"../lib":160,"../snapshot/helpers":256,"../snapshot/svgtoimg":258,"../snapshot/tosvg":260,"./plot_api":191}],198:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47412,7 +48305,7 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":162,"../plots/plots":246,"./plot_config":194,"./plot_schema":195}],201:[function(_dereq_,module,exports){ +},{"../lib":160,"../plots/plots":244,"./plot_config":192,"./plot_schema":193}],199:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47514,7 +48407,7 @@ module.exports = { } }; -},{}],202:[function(_dereq_,module,exports){ +},{}],200:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47610,7 +48503,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":162,"../plot_api/plot_template":196}],203:[function(_dereq_,module,exports){ +},{"../lib":160,"../plot_api/plot_template":194}],201:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47732,10 +48625,16 @@ module.exports = { _isLinkedToArray: 'transform', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + } }; -},{"../components/fx/attributes":77}],204:[function(_dereq_,module,exports){ +},{"../components/fx/attributes":73}],202:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47764,7 +48663,7 @@ module.exports = { } }; -},{}],205:[function(_dereq_,module,exports){ +},{}],203:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -47779,6 +48678,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; +var Registry = _dereq_('../../registry'); module.exports = { getAutoRange: getAutoRange, @@ -48003,10 +48903,6 @@ function concatExtremes(gd, ax) { } function doAutoRange(gd, ax) { - if(!ax._length) ax.setScale(); - - var axIn; - if(ax.autorange) { ax.range = getAutoRange(gd, ax); @@ -48016,20 +48912,28 @@ function doAutoRange(gd, ax) { // doAutoRange will get called on fullLayout, // but we want to report its results back to layout - axIn = ax._input; + var axIn = ax._input; + + // before we edit _input, store preGUI values + var edits = {}; + edits[ax._attr + '.range'] = ax.range; + edits[ax._attr + '.autorange'] = ax.autorange; + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, edits); + axIn.range = ax.range.slice(); axIn.autorange = ax.autorange; } - if(ax._anchorAxis && ax._anchorAxis.rangeslider) { - var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name]; + var anchorAx = ax._anchorAxis; + + if(anchorAx && anchorAx.rangeslider) { + var axeRangeOpts = anchorAx.rangeslider[ax._name]; if(axeRangeOpts) { if(axeRangeOpts.rangemode === 'auto') { axeRangeOpts.range = getAutoRange(gd, ax); } } - axIn = ax._anchorAxis._input; - axIn.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); } } @@ -48247,7 +49151,7 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":143,"../../lib":162,"fast-isnumeric":9}],206:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":160,"../../registry":252,"fast-isnumeric":9}],204:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -48407,6 +49311,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t ax.d2c(targetArray[i]); } } + // TODO what to do for transforms? } else { ax = axes.getFromTrace(gd, trace, d2cTarget); } @@ -48447,7 +49352,7 @@ axes.counterLetter = function(id) { axes.minDtick = function(ax, newDiff, newFirst, allow) { // doesn't make sense to do forced min dTick on log or category axes, // and the plot itself may decide to cancel (ie non-grouped bars) - if(['log', 'category'].indexOf(ax.type) !== -1 || !allow) { + if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; } // undefined means there's nothing there yet @@ -48479,18 +49384,15 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // save a copy of the initial axis ranges in fullLayout // use them in mode bar and dblclick events axes.saveRangeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._rangeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.range[0] === ax._rangeInitial[0] && - ax.range[1] === ax._rangeInitial[1] - ) + var hasChanged = isNew || !( + ax.range[0] === ax._rangeInitial[0] && + ax.range[1] === ax._rangeInitial[1] ); if((isNew && ax.autorange === false) || (overwrite && hasChanged)) { @@ -48504,21 +49406,16 @@ axes.saveRangeInitial = function(gd, overwrite) { // save a copy of the initial spike visibility axes.saveShowSpikeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false, - allSpikesEnabled = 'on'; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; + var allSpikesEnabled = 'on'; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._showSpikeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.showspikes === ax._showspikes - ) - ); + var hasChanged = isNew || !(ax.showspikes === ax._showspikes); - if((isNew) || (overwrite && hasChanged)) { + if(isNew || (overwrite && hasChanged)) { ax._showSpikeInitial = ax.showspikes; hasOneAxisChanged = true; } @@ -48535,7 +49432,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { var dataMin = Lib.aggNums(Math.min, null, data); var dataMax = Lib.aggNums(Math.max, null, data); - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { return { start: dataMin - 0.5, end: dataMax + 0.5, @@ -48553,8 +49450,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { type: 'linear', range: [dataMin, dataMax] }; - } - else { + } else { dummyAx = { type: ax.type, range: Lib.simpleMap([dataMin, dataMax], ax.c2r, 0, calendar), @@ -48639,10 +49535,10 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { - var edgecount = 0, - midcount = 0, - intcount = 0, - blankCount = 0; + var edgecount = 0; + var midcount = 0; + var intcount = 0; + var blankCount = 0; function nearEdge(v) { // is a value within 1% of a bin edge? @@ -48733,14 +49629,14 @@ axes.prepTicks = function(ax) { // calculate max number of (auto) ticks to display based on plot size if(ax.tickmode === 'auto' || !ax.dtick) { - var nt = ax.nticks, - minPx; + var nt = ax.nticks; + var minPx; + if(!nt) { - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; nt = ax._length / minPx; - } - else { + } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; nt = Lib.constrain(ax._length / minPx, 4, 9) + 1; } @@ -48802,7 +49698,7 @@ axes.calcTicks = function calcTicks(ax) { // return the full set of tick vals var vals = []; - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { endTick = (axrev) ? Math.max(-0.5, endTick) : Math.min(ax._categories.length - 0.5, endTick); } @@ -48846,23 +49742,22 @@ axes.calcTicks = function calcTicks(ax) { }; function arrayTicks(ax) { - var vals = ax.tickvals, - text = ax.ticktext, - ticksOut = new Array(vals.length), - rng = Lib.simpleMap(ax.range, ax.r2l), - r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001, - r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001, - tickMin = Math.min(r0expanded, r1expanded), - tickMax = Math.max(r0expanded, r1expanded), - vali, - i, - j = 0; + var vals = ax.tickvals; + var text = ax.ticktext; + var ticksOut = new Array(vals.length); + var rng = Lib.simpleMap(ax.range, ax.r2l); + var r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001; + var r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001; + var tickMin = Math.min(r0expanded, r1expanded); + var tickMax = Math.max(r0expanded, r1expanded); + var j = 0; // without a text array, just format the given values as any other ticks // except with more precision to the numbers if(!Array.isArray(text)) text = []; // make sure showing ticks doesn't accidentally add new categories + // TODO multicategory, if we allow ticktext / tickvals var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; // array ticks on log axes always show the full number @@ -48871,8 +49766,8 @@ function arrayTicks(ax) { ax.dtick = 'L' + Math.pow(10, Math.floor(Math.min(ax.range[0], ax.range[1])) - 1); } - for(i = 0; i < vals.length; i++) { - vali = tickVal2l(vals[i]); + for(var i = 0; i < vals.length; i++) { + var vali = tickVal2l(vals[i]); if(vali > tickMin && vali < tickMax) { if(text[i] === undefined) ticksOut[j] = axes.tickText(ax, vali); else ticksOut[j] = tickTextObj(ax, vali, String(text[i])); @@ -48885,17 +49780,17 @@ function arrayTicks(ax) { return ticksOut; } -var roundBase10 = [2, 5, 10], - roundBase24 = [1, 2, 3, 6, 12], - roundBase60 = [1, 2, 5, 10, 15, 30], - // 2&3 day ticks are weird, but need something btwn 1&7 - roundDays = [1, 2, 3, 7, 14], - // approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) - // these don't have to be exact, just close enough to round to the right value - roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1], - roundLog2 = [-0.301, 0, 0.301, 0.699, 1], - // N.B. `thetaunit; 'radians' angular axes must be converted to degrees - roundAngles = [15, 30, 45, 90, 180]; +var roundBase10 = [2, 5, 10]; +var roundBase24 = [1, 2, 3, 6, 12]; +var roundBase60 = [1, 2, 5, 10, 15, 30]; +// 2&3 day ticks are weird, but need something btwn 1&7 +var roundDays = [1, 2, 3, 7, 14]; +// approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) +// these don't have to be exact, just close enough to round to the right value +var roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1]; +var roundLog2 = [-0.301, 0, 0.301, 0.699, 1]; +// N.B. `thetaunit; 'radians' angular axes must be converted to degrees +var roundAngles = [15, 30, 45, 90, 180]; function roundDTick(roughDTick, base, roundingSet) { return base * Lib.roundUp(roughDTick / base, roundingSet); @@ -48986,7 +49881,7 @@ axes.autoTicks = function(ax, roughDTick) { ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } } - else if(ax.type === 'category') { + else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); } @@ -49026,7 +49921,7 @@ function autoTickRound(ax) { dtick = 1; } - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { ax._tickround = null; } if(ax.type === 'date') { @@ -49118,36 +50013,34 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { // calculate the first tick on an axis axes.tickFirst = function(ax) { - var r2l = ax.r2l || Number, - rng = Lib.simpleMap(ax.range, r2l), - axrev = rng[1] < rng[0], - sRound = axrev ? Math.floor : Math.ceil, - // add a tiny extra bit to make sure we get ticks - // that may have been rounded out - r0 = rng[0] * 1.0001 - rng[1] * 0.0001, - dtick = ax.dtick, - tick0 = r2l(ax.tick0); + var r2l = ax.r2l || Number; + var rng = Lib.simpleMap(ax.range, r2l); + var axrev = rng[1] < rng[0]; + var sRound = axrev ? Math.floor : Math.ceil; + // add a tiny extra bit to make sure we get ticks + // that may have been rounded out + var r0 = rng[0] * 1.0001 - rng[1] * 0.0001; + var dtick = ax.dtick; + var tick0 = r2l(ax.tick0); if(isNumeric(dtick)) { var tmin = sRound((r0 - tick0) / dtick) * dtick + tick0; // make sure no ticks outside the category list - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { tmin = Lib.constrain(tmin, 0, ax._categories.length - 1); } return tmin; } - var tType = dtick.charAt(0), - dtNum = Number(dtick.substr(1)); + var tType = dtick.charAt(0); + var dtNum = Number(dtick.substr(1)); // Dates: months (or years) if(tType === 'M') { - var cnt = 0, - t0 = tick0, - t1, - mult, - newDTick; + var cnt = 0; + var t0 = tick0; + var t1, mult, newDTick; // This algorithm should work for *any* nonlinear (but close to linear!) // tick spacing. Limit to 10 iterations, for gregorian months it's normally <=3. @@ -49189,16 +50082,18 @@ axes.tickFirst = function(ax) { // hover is a (truthy) flag for whether to show numbers with a bit // more precision for hovertext axes.tickText = function(ax, x, hover) { - var out = tickTextObj(ax, x), - hideexp, - arrayMode = ax.tickmode === 'array', - extraPrecision = hover || arrayMode, - i, - tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; + var out = tickTextObj(ax, x); + var arrayMode = ax.tickmode === 'array'; + var extraPrecision = hover || arrayMode; + var axType = ax.type; + // TODO multicategory, if we allow ticktext / tickvals + var tickVal2l = axType === 'category' ? ax.d2l_noadd : ax.d2l; + var i; if(arrayMode && Array.isArray(ax.ticktext)) { - var rng = Lib.simpleMap(ax.range, ax.r2l), - minDiff = Math.abs(rng[1] - rng[0]) / 10000; + var rng = Lib.simpleMap(ax.range, ax.r2l); + var minDiff = Math.abs(rng[1] - rng[0]) / 10000; + for(i = 0; i < ax.ticktext.length; i++) { if(Math.abs(x - tickVal2l(ax.tickvals[i])) < minDiff) break; } @@ -49209,28 +50104,25 @@ axes.tickText = function(ax, x, hover) { } function isHidden(showAttr) { - var first_or_last; - if(showAttr === undefined) return true; if(hover) return showAttr === 'none'; - first_or_last = { + var firstOrLast = { first: ax._tmin, last: ax._tmax }[showAttr]; - return showAttr !== 'all' && x !== first_or_last; + return showAttr !== 'all' && x !== firstOrLast; } - if(hover) { - hideexp = 'never'; - } else { - hideexp = ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - } + var hideexp = hover ? + 'never' : + ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - if(ax.type === 'date') formatDate(ax, out, hover, extraPrecision); - else if(ax.type === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); - else if(ax.type === 'category') formatCategory(ax, out); + if(axType === 'date') formatDate(ax, out, hover, extraPrecision); + else if(axType === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); + else if(axType === 'category') formatCategory(ax, out); + else if(axType === 'multicategory') formatMultiCategory(ax, out, hover); else if(isAngular(ax)) formatAngle(ax, out, hover, extraPrecision, hideexp); else formatLinear(ax, out, hover, extraPrecision, hideexp); @@ -49238,6 +50130,20 @@ axes.tickText = function(ax, x, hover) { if(ax.tickprefix && !isHidden(ax.showtickprefix)) out.text = ax.tickprefix + out.text; if(ax.ticksuffix && !isHidden(ax.showticksuffix)) out.text += ax.ticksuffix; + // Setup ticks and grid lines boundaries + // at 1/2 a 'category' to the left/bottom + if(ax.tickson === 'boundaries' || ax.showdividers) { + var inbounds = function(v) { + var p = ax.l2p(v); + return p >= 0 && p <= ax._length ? v : null; + }; + + out.xbnd = [ + inbounds(out.x - 0.5), + inbounds(out.x + ax.dtick - 0.5) + ]; + } + return out; }; @@ -49287,8 +50193,8 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround, - fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); + var tr = ax._tickround; + var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); if(extraPrecision) { // second or sub-second precision: extra always shows max digits. @@ -49297,8 +50203,8 @@ function formatDate(ax, out, hover, extraPrecision) { else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr]; } - var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat), - headStr; + var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat); + var headStr; var splitIndex = dateStr.indexOf('\n'); if(splitIndex !== -1) { @@ -49415,6 +50321,22 @@ function formatCategory(ax, out) { out.text = String(tt); } +function formatMultiCategory(ax, out, hover) { + var v = Math.round(out.x); + var cats = ax._categories[v] || []; + var tt = cats[1] === undefined ? '' : String(cats[1]); + var tt2 = cats[0] === undefined ? '' : String(cats[0]); + + if(hover) { + // TODO is this what we want? + out.text = tt2 + ' - ' + tt; + } else { + // setup for secondary labels + out.text = tt; + out.text2 = tt2; + } +} + function formatLinear(ax, out, hover, extraPrecision, hideexp) { if(hideexp === 'never') { // If this is a hover label, then we must *never* hide the exponent @@ -49520,14 +50442,13 @@ function beyondSI(exponent) { } function numFormat(v, ax, fmtoverride, hover) { - // negative? - var isNeg = v < 0, - // max number of digits past decimal point to show - tickRound = ax._tickround, - exponentFormat = fmtoverride || ax.exponentformat || 'B', - exponent = ax._tickexponent, - tickformat = axes.getTickFormat(ax), - separatethousands = ax.separatethousands; + var isNeg = v < 0; + // max number of digits past decimal point to show + var tickRound = ax._tickround; + var exponentFormat = fmtoverride || ax.exponentformat || 'B'; + var exponent = ax._tickexponent; + var tickformat = axes.getTickFormat(ax); + var separatethousands = ax.separatethousands; // special case for hover: set exponent just for this value, and // add a couple more digits of precision over tick labels @@ -49700,6 +50621,9 @@ axes.getTickFormat = function(ax) { // as an array of items like 'xy', 'x2y', 'x2y2'... // sorted by x (x,x2,x3...) then y // optionally restrict to only subplots containing axis object ax +// +// NOTE: this is currently only used OUTSIDE plotly.js (toolpanel, webapp) +// ideally we get rid of it there (or just copy this there) and remove it here axes.getSubplots = function(gd, ax) { var subplotObj = gd._fullLayout._subplots; var allSubplots = subplotObj.cartesian.concat(subplotObj.gl2d || []); @@ -49718,18 +50642,20 @@ axes.getSubplots = function(gd, ax) { }; // find all subplots with axis 'ax' +// NOTE: this is only used in axes.getSubplots (only used outside plotly.js) and +// gl2d/convert (where it restricts axis subplots to only those with gl2d) axes.findSubplotsWithAxis = function(subplots, ax) { var axMatch = new RegExp( (ax._id.charAt(0) === 'x') ? ('^' + ax._id + 'y') : (ax._id + '$') ); - var subplotsWithAxis = []; + var subplotsWithAx = []; for(var i = 0; i < subplots.length; i++) { var sp = subplots[i]; - if(axMatch.test(sp)) subplotsWithAxis.push(sp); + if(axMatch.test(sp)) subplotsWithAx.push(sp); } - return subplotsWithAxis; + return subplotsWithAx; }; // makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings @@ -49782,24 +50708,25 @@ axes.makeClipPaths = function(gd) { * * @param {DOM element} gd : graph div * @param {string or array of strings} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update + * @param {object} opts: + * - @param {boolean} skipTitle : optional flag to skip axis title draw/update * - * Signature 1: Axes.doTicks(gd, 'redraw') + * Signature 1: Axes.draw(gd, 'redraw') * use this to clear and redraw all axes on graph * - * Signature 2: Axes.doTicks(gd, '') + * Signature 2: Axes.draw(gd, '') * use this to draw all axes on graph w/o the selectAll().remove() * of the 'redraw' signature * - * Signature 3: Axes.doTicks(gd, [axId, axId2, ...]) + * Signature 3: Axes.draw(gd, [axId, axId2, ...]) * where the items are axis id string, * use this to update multiple axes in one call * - * N.B doTicks updates: + * N.B draw updates: * - ax._r (stored range for use by zoom/pan) * - ax._rl (stored linearized range for use by zoom/pan) */ -axes.doTicks = function(gd, arg, skipTitle) { +axes.draw = function(gd, arg, opts) { var fullLayout = gd._fullLayout; if(arg === 'redraw') { @@ -49811,6 +50738,8 @@ axes.doTicks = function(gd, arg, skipTitle) { plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove(); if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); @@ -49820,13 +50749,13 @@ axes.doTicks = function(gd, arg, skipTitle) { var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; - Lib.syncOrAsync(axList.map(function(axid) { + return Lib.syncOrAsync(axList.map(function(axId) { return function() { - if(!axid) return; + if(!axId) return; - var axDone = axes.doTicksSingle(gd, axid, skipTitle); + var ax = axes.getFromId(gd, axId); + var axDone = axes.drawOne(gd, ax, opts); - var ax = axes.getFromId(gd, axid); ax._r = ax.range.slice(); ax._rl = Lib.simpleMap(ax._r, ax.r2l); @@ -49836,692 +50765,1077 @@ axes.doTicks = function(gd, arg, skipTitle) { }; /** - * Per-axis drawing routine! - * - * This routine draws axis ticks and much more (... grids, labels, title etc.) - * Supports multiple argument signatures. - * N.B. this thing is async in general (because of MathJax rendering) + * Draw one cartesian axis * - * @param {DOM element} gd : graph div - * @param {string or object} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * @return {promise} - * - * Signature 1: Axes.doTicks(gd, ax) - * where ax is an axis object as in fullLayout - * - * Signature 2: Axes.doTicks(gd, axId) - * where axId is a axis id string + * @param {DOM element} gd + * @param {object} ax (full) axis object + * @param {object} opts + * - @param {boolean} skipTitle (set to true to skip axis title draw call) */ -axes.doTicksSingle = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; - var independent = false; - var ax; +axes.drawOne = function(gd, ax, opts) { + opts = opts || {}; - if(Lib.isPlainObject(arg)) { - ax = arg; - independent = true; - } else { - ax = axes.getFromId(gd, arg); - } + var i, sp, plotinfo; - // set scaling to pixels ax.setScale(); - var axid = ax._id; - var axLetter = axid.charAt(0); - var counterLetter = axes.counterLetter(axid); + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var counterLetter = axes.counterLetter(axId); + var mainSubplot = ax._mainSubplot; + var mainLinePosition = ax._mainLinePosition; + var mainMirrorPosition = ax._mainMirrorPosition; + var mainPlotinfo = fullLayout._plots[mainSubplot]; + var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; + var subplotsWithAx = ax._subplotsWith; + var vals = ax._vals = axes.calcTicks(ax); - var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; - var tcls = axid + 'tick'; - var gcls = axid + 'grid'; - var zcls = axid + 'zl'; - var pad = (ax.linewidth || 1) / 2; - var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); - var labelShift = 0; - var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); - var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); - var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); - var sides, transfn, tickpathfn, subplots; - var tickLabels; - var i; - if(ax._counterangle && ax.ticks === 'outside') { - var caRad = ax._counterangle * Math.PI / 180; - labelStandoff = ax.ticklen * Math.cos(caRad) + 1; - labelShift = ax.ticklen * Math.sin(caRad); + // Add a couple of axis properties that should cause us to recreate + // elements. Used in d3 data function. + var axInfo = [ax.mirror, mainLinePosition, mainMirrorPosition].join('_'); + for(i = 0; i < vals.length; i++) { + vals[i].axInfo = axInfo; } - if(ax.showticklabels && (ax.ticks === 'outside' || ax.showline)) { - labelStandoff += 0.2 * ax.tickfont.size; - } + if(!ax.visible) return; - // positioning arguments for x vs y axes - if(axLetter === 'x') { - sides = ['bottom', 'top']; - transfn = ax._transfn || function(d) { - return 'translate(' + (ax._offset + ax.l2p(d.x)) + ',0)'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M0,' + shift + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len); - } - else return 'M0,' + shift + 'v' + len; - }; - } - else if(axLetter === 'y') { - sides = ['left', 'right']; - transfn = ax._transfn || function(d) { - return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M' + shift + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); - } - else return 'M' + shift + ',0h' + len; - }; - } - else if(isAngular(ax)) { - sides = ['left', 'right']; - transfn = ax._transfn; - tickpathfn = function(shift, len) { - return 'M' + shift + ',0h' + len; - }; - } - else { - Lib.warn('Unrecognized doTicks axis:', axid); - return; + // stash selections to avoid DOM queries e.g. + // - stash tickLabels selection, so that drawTitle can use it to scoot title + ax._selections = {}; + // stash tick angle (including the computed 'auto' values) per tick-label class + ax._tickAngles = {}; + + var transFn = axes.makeTransFn(ax); + var tickVals; + // We remove zero lines, grid lines, and inside ticks if they're within 1px of the end + // The key case here is removing zero lines when the axis bound is zero + var valsClipped; + + if(ax.tickson === 'boundaries') { + var boundaryVals = getBoundaryVals(ax, vals); + valsClipped = axes.clipEnds(ax, boundaryVals); + tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals; + } else { + valsClipped = axes.clipEnds(ax, vals); + tickVals = ax.ticks === 'inside' ? valsClipped : vals; } - var axside = ax.side || sides[0]; - // which direction do the side[0], side[1], and free ticks go? - // then we flip if outside XOR y axis - var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; - if((ax.ticks !== 'inside') === (axLetter === 'x')) { - ticksign = ticksign.map(function(v) { return -v; }); - } + var gridVals = ax._gridVals = valsClipped; + var dividerVals = getDividerVals(ax, vals); - if(!ax.visible) return; + if(!fullLayout._hasOnlyLargeSploms) { + // keep track of which subplots (by main conteraxis) we've already + // drawn grids for, so we don't overdraw overlaying subplots + var finishedGrids = {}; - if(ax._tickFilter) { - vals = vals.filter(ax._tickFilter); - } + for(i = 0; i < subplotsWithAx.length; i++) { + sp = subplotsWithAx[i]; + plotinfo = fullLayout._plots[sp]; - // Remove zero lines, grid lines, and inside ticks if they're within - // 1 pixel of the end. - // The key case here is removing zero lines when the axis bound is zero. - // Don't clip angular values. - var valsClipped = ax._valsClipped = isAngular(ax) ? - vals : - vals.filter(function(d) { return clipEnds(ax, d.x); }); + var counterAxis = plotinfo[counterLetter + 'axis']; + var mainCounterID = counterAxis._mainAxis._id; + if(finishedGrids[mainCounterID]) continue; + finishedGrids[mainCounterID] = 1; - function drawTicks(container, tickpath) { - var ticks = container.selectAll('path.' + tcls) - .data(ax.ticks === 'inside' ? valsClipped : vals, datafn); + var gridPath = axLetter === 'x' ? + 'M0,' + counterAxis._offset + 'v' + counterAxis._length : + 'M' + counterAxis._offset + ',0h' + counterAxis._length; - if(tickpath && ax.ticks) { - ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) - .classed('crisp', 1) - .call(Color.stroke, ax.tickcolor) - .style('stroke-width', tickWidth + 'px') - .attr('d', tickpath); - ticks.attr('transform', transfn); - ticks.exit().remove(); + axes.drawGrid(gd, ax, { + vals: gridVals, + counterAxis: counterAxis, + layer: plotinfo.gridlayer.select('.' + axId), + path: gridPath, + transFn: transFn + }); + axes.drawZeroLine(gd, ax, { + counterAxis: counterAxis, + layer: plotinfo.zerolinelayer, + path: gridPath, + transFn: transFn + }); } - else ticks.remove(); } - function drawLabels(container, position) { - // tick labels - for now just the main labels. - // TODO: mirror labels, esp for subplots - tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); + var tickSigns = axes.getTickSigns(ax); + var tickSubplots = []; - if(!isNumeric(position)) { - tickLabels.remove(); - drawAxTitle(); - return; - } - if(!ax.showticklabels) { - tickLabels.remove(); - drawAxTitle(); - calcBoundingBox(); - return; + if(ax.ticks) { + var mainTickPath = axes.makeTickPath(ax, mainLinePosition, tickSigns[2]); + var mirrorTickPath; + var fullTickPath; + if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { + mirrorTickPath = axes.makeTickPath(ax, mainMirrorPosition, tickSigns[3]); + fullTickPath = mainTickPath + mirrorTickPath; + } else { + mirrorTickPath = ''; + fullTickPath = mainTickPath; } - var labelx, labely, labelanchor, labelpos0, flipit; - if(axLetter === 'x') { - flipit = (axside === 'bottom') ? 1 : -1; - labelx = function(d) { return d.dx + labelShift * flipit; }; - labelpos0 = position + (labelStandoff + pad) * flipit; - labely = function(d) { - return d.dy + labelpos0 + d.fontSize * - ((axside === 'bottom') ? 1 : -0.2); - }; - labelanchor = function(angle) { - if(!isNumeric(angle) || angle === 0 || angle === 180) { - return 'middle'; - } - return (angle * flipit < 0) ? 'end' : 'start'; - }; - } - else if(axLetter === 'y') { - flipit = (axside === 'right') ? 1 : -1; - labely = function(d) { - return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit; - }; - labelx = function(d) { - return d.dx + position + (labelStandoff + pad + - ((Math.abs(ax.tickangle) === 90) ? d.fontSize / 2 : 0)) * flipit; - }; - labelanchor = function(angle) { - if(isNumeric(angle) && Math.abs(angle) === 90) { - return 'middle'; - } - return axside === 'right' ? 'start' : 'end'; + var tickPath; + if(ax.showdividers && ax.ticks === 'outside' && ax.tickson === 'boundaries') { + var dividerLookup = {}; + for(i = 0; i < dividerVals.length; i++) { + dividerLookup[dividerVals[i].x] = 1; + } + tickPath = function(d) { + return dividerLookup[d.x] ? mirrorTickPath : fullTickPath; }; + } else { + tickPath = fullTickPath; } - else if(isAngular(ax)) { - ax._labelShift = labelShift; - ax._labelStandoff = labelStandoff; - ax._pad = pad; - - labelx = ax._labelx; - labely = ax._labely; - labelanchor = ax._labelanchor; - } - - var maxFontSize = 0, - autoangle = 0, - labelsReady = []; - tickLabels.enter().append('g').classed(tcls, 1) - .append('text') - // only so tex has predictable alignment that we can - // alter later - .attr('text-anchor', 'middle') - .each(function(d) { - var thisLabel = d3.select(this), - newPromise = gd._promises.length; - thisLabel - .call(svgTextUtils.positionText, labelx(d), labely(d)) - .call(Drawing.font, d.font, d.fontSize, d.fontColor) - .text(d.text) - .call(svgTextUtils.convertToTspans, gd); - newPromise = gd._promises[newPromise]; - if(newPromise) { - // if we have an async label, we'll deal with that - // all here so take it out of gd._promises and - // instead position the label and promise this in - // labelsReady - labelsReady.push(gd._promises.pop().then(function() { - positionLabels(thisLabel, ax.tickangle); - })); - } - else { - // sync label: just position it now. - positionLabels(thisLabel, ax.tickangle); - } - }); - tickLabels.exit().remove(); - tickLabels.each(function(d) { - maxFontSize = Math.max(maxFontSize, d.fontSize); + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: mainAxLayer, + path: tickPath, + transFn: transFn }); - if(isAngular(ax)) { - tickLabels.each(function(d) { - d3.select(this).select('text') - .call(svgTextUtils.positionText, labelx(d), labely(d)); + tickSubplots = Object.keys(ax._linepositions || {}); + } + + for(i = 0; i < tickSubplots.length; i++) { + sp = tickSubplots[i]; + plotinfo = fullLayout._plots[sp]; + // [bottom or left, top or right], free and main are handled above + var linepositions = ax._linepositions[sp] || []; + var spTickPath = axes.makeTickPath(ax, linepositions[0], tickSigns[0]) + + axes.makeTickPath(ax, linepositions[1], tickSigns[1]); + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: plotinfo[axLetter + 'axislayer'], + path: spTickPath, + transFn: transFn + }); + } + + var seq = []; + + // tick labels - for now just the main labels. + // TODO: mirror labels, esp for subplots + + seq.push(function() { + var labelFns = axes.makeLabelFns(ax, mainLinePosition); + return axes.drawLabels(gd, ax, { + vals: vals, + layer: mainAxLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn, + }); + }); + + if(ax.type === 'multicategory') { + var labelLength = 0; + var pad = {x: 2, y: 10}[axLetter]; + var sgn = tickSigns[2] * (ax.ticks === 'inside' ? -1 : 1); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick') + pad; + labelLength += ax._tickAngles[axId + 'tick'] ? ax.tickfont.size * LINE_SPACING : 0; + var secondaryPosition = mainLinePosition + labelLength * sgn; + var secondaryLabelFns = axes.makeLabelFns(ax, secondaryPosition); + + return axes.drawLabels(gd, ax, { + vals: getSecondaryLabelVals(ax, vals), + layer: mainAxLayer, + cls: axId + 'tick2', + repositionOnUpdate: true, + secondary: true, + transFn: transFn, + labelXFn: secondaryLabelFns.labelXFn, + labelYFn: secondaryLabelFns.labelYFn, + labelAnchorFn: secondaryLabelFns.labelAnchorFn, }); - } + }); - // How much to shift a multi-line label to center it vertically. - function getAnchorHeight(lineCount, lineHeight, angle) { - var h = (lineCount - 1) * lineHeight; - if(axLetter === 'x') { - if(angle < -60 || 60 < angle) { - return -0.5 * h; - } else if(axside === 'top') { - return -h; - } - } else { - angle *= axside === 'left' ? 1 : -1; - if(angle < -30) { - return -h; - } else if(angle < 30) { - return -0.5 * h; - } - } - return 0; - } - - function positionLabels(s, angle) { - s.each(function(d) { - var anchor = labelanchor(angle, d); - var thisLabel = d3.select(this), - mathjaxGroup = thisLabel.select('.text-math-group'), - transform = transfn.call(thisLabel.node(), d) + - ((isNumeric(angle) && +angle !== 0) ? - (' rotate(' + angle + ',' + labelx(d) + ',' + - (labely(d) - d.fontSize / 2) + ')') : - ''); - var anchorHeight = getAnchorHeight( - svgTextUtils.lineCount(thisLabel), - LINE_SPACING * d.fontSize, - isNumeric(angle) ? +angle : 0); - if(anchorHeight) { - transform += ' translate(0, ' + anchorHeight + ')'; - } - if(mathjaxGroup.empty()) { - thisLabel.select('text').attr({ - transform: transform, - 'text-anchor': anchor - }); - } - else { - var mjShift = - Drawing.bBox(mathjaxGroup.node()).width * - {end: -0.5, start: 0.5}[anchor]; - mathjaxGroup.attr('transform', transform + - (mjShift ? 'translate(' + mjShift + ',0)' : '')); - } + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick2'); + ax._labelLength = labelLength; + + return drawDividers(gd, ax, { + vals: dividerVals, + layer: mainAxLayer, + path: axes.makeTickPath(ax, mainLinePosition, sgn, labelLength), + transFn: transFn }); - } + }); + } - // make sure all labels are correctly positioned at their base angle - // the positionLabels call above is only for newly drawn labels. - // do this without waiting, using the last calculated angle to - // minimize flicker, then do it again when we know all labels are - // there, putting back the prescribed angle to check for overlaps. - positionLabels(tickLabels, ax._lastangle || ax.tickangle); - - function allLabelsReady() { - return labelsReady.length && Promise.all(labelsReady); - } - - function fixLabelOverlaps() { - positionLabels(tickLabels, ax.tickangle); - - // check for auto-angling if x labels overlap - // don't auto-angle at all for log axes with - // base and digit format - if(axLetter === 'x' && !isNumeric(ax.tickangle) && - (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')) { - var lbbArray = []; - tickLabels.each(function(d) { - var s = d3.select(this), - thisLabel = s.select('.text-math-group'), - x = ax.l2p(d.x); - if(thisLabel.empty()) thisLabel = s.select('text'); - - var bb = Drawing.bBox(thisLabel.node()); - - lbbArray.push({ - // ignore about y, just deal with x overlaps - top: 0, - bottom: 10, - height: 10, - left: x - bb.width / 2, - // impose a 2px gap - right: x + bb.width / 2 + 2, - width: bb.width + 2 - }); - }); - for(i = 0; i < lbbArray.length - 1; i++) { - if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { - // any overlap at all - set 30 degrees - autoangle = 30; - break; - } - } - if(autoangle) { - var tickspacing = Math.abs( - (vals[vals.length - 1].x - vals[0].x) * ax._m - ) / (vals.length - 1); - if(tickspacing < maxFontSize * 2.5) { - autoangle = 90; - } - positionLabels(tickLabels, autoangle); - } - ax._lastangle = autoangle; - } + function extendRange(range, newRange) { + range[0] = Math.min(range[0], newRange[0]); + range[1] = Math.max(range[1], newRange[1]); + } - // update the axis title - // (so it can move out of the way if needed) - // TODO: separate out scoot so we don't need to do - // a full redraw of the title (mostly relevant for MathJax) - drawAxTitle(); - return axid + ' done'; - } + function calcBoundingBox() { + if(ax.showticklabels) { + var gdBB = gd.getBoundingClientRect(); + var bBox = mainAxLayer.node().getBoundingClientRect(); - function calcBoundingBox() { - if(ax.showticklabels) { - var gdBB = gd.getBoundingClientRect(); - var bBox = container.node().getBoundingClientRect(); + /* + * the way we're going to use this, the positioning that matters + * is relative to the origin of gd. This is important particularly + * if gd is scrollable, and may have been scrolled between the time + * we calculate this and the time we use it + */ - /* - * the way we're going to use this, the positioning that matters - * is relative to the origin of gd. This is important particularly - * if gd is scrollable, and may have been scrolled between the time - * we calculate this and the time we use it - */ + ax._boundingBox = { + width: bBox.width, + height: bBox.height, + left: bBox.left - gdBB.left, + right: bBox.right - gdBB.left, + top: bBox.top - gdBB.top, + bottom: bBox.bottom - gdBB.top + }; + } else { + var gs = fullLayout._size; + var pos; + + // set dummy bbox for ticklabel-less axes + + if(axLetter === 'x') { + pos = ax.anchor === 'free' ? + gs.t + gs.h * (1 - ax.position) : + gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); ax._boundingBox = { - width: bBox.width, - height: bBox.height, - left: bBox.left - gdBB.left, - right: bBox.right - gdBB.left, - top: bBox.top - gdBB.top, - bottom: bBox.bottom - gdBB.top + top: pos, + bottom: pos, + left: ax._offset, + right: ax._offset + ax._length, + width: ax._length, + height: 0 }; } else { - var gs = fullLayout._size; - var pos; - - // set dummy bbox for ticklabel-less axes + pos = ax.anchor === 'free' ? + gs.l + gs.w * ax.position : + gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - if(axLetter === 'x') { - pos = ax.anchor === 'free' ? - gs.t + gs.h * (1 - ax.position) : - gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); - - ax._boundingBox = { - top: pos, - bottom: pos, - left: ax._offset, - right: ax._offset + ax._length, - width: ax._length, - height: 0 - }; - } else { - pos = ax.anchor === 'free' ? - gs.l + gs.w * ax.position : - gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - - ax._boundingBox = { - left: pos, - right: pos, - bottom: ax._offset + ax._length, - top: ax._offset, - height: ax._length, - width: 0 - }; - } + ax._boundingBox = { + left: pos, + right: pos, + bottom: ax._offset + ax._length, + top: ax._offset, + height: ax._length, + width: 0 + }; } + } - /* - * for spikelines: what's the full domain of positions in the - * opposite direction that are associated with this axis? - * This means any axes that we make a subplot with, plus the - * position of the axis itself if it's free. - */ - if(subplots) { - var fullRange = ax._counterSpan = [Infinity, -Infinity]; - - for(i = 0; i < subplots.length; i++) { - var subplot = fullLayout._plots[subplots[i]]; - var counterAxis = subplot[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + /* + * for spikelines: what's the full domain of positions in the + * opposite direction that are associated with this axis? + * This means any axes that we make a subplot with, plus the + * position of the axis itself if it's free. + */ + if(subplotsWithAx) { + var fullRange = ax._counterSpan = [Infinity, -Infinity]; - extendRange(fullRange, [ - counterAxis._offset, - counterAxis._offset + counterAxis._length - ]); - } + for(var i = 0; i < subplotsWithAx.length; i++) { + var plotinfo = fullLayout._plots[subplotsWithAx[i]]; + var counterAxis = plotinfo[(axLetter === 'x') ? 'yaxis' : 'xaxis']; - if(ax.anchor === 'free') { - extendRange(fullRange, (axLetter === 'x') ? - [ax._boundingBox.bottom, ax._boundingBox.top] : - [ax._boundingBox.right, ax._boundingBox.left]); - } + extendRange(fullRange, [ + counterAxis._offset, + counterAxis._offset + counterAxis._length + ]); } - function extendRange(range, newRange) { - range[0] = Math.min(range[0], newRange[0]); - range[1] = Math.max(range[1], newRange[1]); + if(ax.anchor === 'free') { + extendRange(fullRange, (axLetter === 'x') ? + [ax._boundingBox.bottom, ax._boundingBox.top] : + [ax._boundingBox.right, ax._boundingBox.left]); } } + } - function doAutoMargins() { - var pushKey = ax._name + '.automargin'; - if(axLetter !== 'x' && axLetter !== 'y') { return; } - if(!ax.automargin) { - Plots.autoMargin(gd, pushKey); - return; - } + var hasRangeSlider = Registry.getComponentMethod('rangeslider', 'isVisible')(ax); + + function doAutoMargins() { + var push, rangeSliderPush; + + if(hasRangeSlider) { + rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); + } + Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); - var s = ax.side[0]; - var push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + var s = ax.side.charAt(0); + if(ax.automargin && (!hasRangeSlider || s !== 'b')) { + push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; if(axLetter === 'x') { push.y = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 't' ? 1 : 0]); + ax._anchorAxis.domain[s === 't' ? 1 : 0]); push[s] += ax._boundingBox.height; - } - else { + } else { push.x = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 'r' ? 1 : 0]); + ax._anchorAxis.domain[s === 'r' ? 1 : 0]); push[s] += ax._boundingBox.width; } - if(ax.title !== fullLayout._dfltTitle[axLetter]) { - push[s] += ax.titlefont.size; + if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { + push[s] += ax.title.font.size; } - - Plots.autoMargin(gd, pushKey, push); } - var done = Lib.syncOrAsync([ - allLabelsReady, - fixLabelOverlaps, - calcBoundingBox, - doAutoMargins - ]); - if(done && done.then) gd._promises.push(done); - return done; + Plots.autoMargin(gd, axAutoMarginID(ax), push); } - function drawAxTitle() { - if(skipTitle) return; + seq.push(calcBoundingBox, doAutoMargins); - // now this only applies to regular cartesian axes; colorbars and - // others ALWAYS call doTicks with skipTitle=true so they can - // configure their own titles. + if(!opts.skipTitle && + !(hasRangeSlider && ax._boundingBox && ax.side === 'bottom') + ) { + seq.push(function() { return drawTitle(gd, ax); }); + } - // rangeslider takes over a bottom title so drop it here - if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; + return Lib.syncOrAsync(seq); +}; - var avoid = { - selection: tickLabels, - side: ax.side - }; - var axLetter = axid.charAt(0); - var gs = gd._fullLayout._size; - var offsetBase = 1.5; - var fontSize = ax.titlefont.size; +function getBoundaryVals(ax, vals) { + var out = []; + var i; - var transform, counterAxis, x, y; + // boundaryVals are never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; - if(tickLabels.size()) { - var translation = Drawing.getTranslate(tickLabels.node().parentNode); - avoid.offsetLeft = translation.x; - avoid.offsetTop = translation.y; + if(vals.length) { + for(i = 0; i < vals.length; i++) { + _push(vals[i], 0); } + _push(vals[i - 1], 1); + } + + return out; +} - var titleStandoff = 10 + fontSize * offsetBase + - (ax.linewidth ? ax.linewidth - 1 : 0); +function getSecondaryLabelVals(ax, vals) { + var out = []; + var lookup = {}; - if(axLetter === 'x') { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + for(var i = 0; i < vals.length; i++) { + var d = vals[i]; + if(lookup[d.text2]) { + lookup[d.text2].push(d.x); + } else { + lookup[d.text2] = [d.x]; + } + } - x = ax._offset + ax._length / 2; + for(var k in lookup) { + out.push(tickTextObj(ax, Lib.interp(lookup[k], 0.5), k)); + } - if(ax.side === 'top') { - y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); - } - else { - y = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1.5 : 0.5); - } - y += counterAxis._offset; + return out; +} + +function getDividerVals(ax, vals) { + var out = []; + var i, current; - if(!avoid.side) avoid.side = 'bottom'; + // never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); } - else { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + }; - y = ax._offset + ax._length / 2; - if(ax.side === 'right') { - x = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1 : 0.5); - } - else { - x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + if(ax.showdividers && vals.length) { + for(i = 0; i < vals.length; i++) { + var d = vals[i]; + if(d.text2 !== current) { + _push(d, 0); } - x += counterAxis._offset; + current = d.text2; + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getLabelLevelSpan(ax, cls) { + var axLetter = ax._id.charAt(0); + var angle = ax._tickAngles[cls] || 0; + var rad = Lib.deg2rad(angle); + var sinA = Math.sin(rad); + var cosA = Math.cos(rad); + var maxX = 0; + var maxY = 0; + + // N.B. Drawing.bBox does not take into account rotate transforms + + ax._selections[cls].each(function() { + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + var w = bb.width; + var h = bb.height; + maxX = Math.max(maxX, cosA * w, sinA * h); + maxY = Math.max(maxY, sinA * w, cosA * h); + }); + + return {x: maxY, y: maxX}[axLetter]; +} + +/** + * Which direction do the 'ax.side' values, and free ticks go? + * + * @param {object} ax (full) axis object + * - {string} _id (starting with 'x' or 'y') + * - {string} side + * - {string} ticks + * @return {array} all entries are either -1 or 1 + * - [0]: sign for top/right ticks (i.e. negative SVG direction) + * - [1]: sign for bottom/left ticks (i.e. positive SVG direction) + * - [2]: sign for ticks corresponding to 'ax.side' + * - [3]: sign for ticks mirroring 'ax.side' + */ +axes.getTickSigns = function(ax) { + var axLetter = ax._id.charAt(0); + var sideOpposite = {x: 'top', y: 'right'}[axLetter]; + var main = ax.side === sideOpposite ? 1 : -1; + var out = [-1, 1, main, -main]; + // then we flip if outside XOR y axis + if((ax.ticks !== 'inside') === (axLetter === 'x')) { + out = out.map(function(v) { return -v; }); + } + return out; +}; + +/** + * Make axis translate transform function + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} _offset + * - {fn} l2p + * @return {fn} function of calcTicks items + */ +axes.makeTransFn = function(ax) { + var axLetter = ax._id.charAt(0); + var offset = ax._offset; + return axLetter === 'x' ? + function(d) { return 'translate(' + (offset + ax.l2p(d.x)) + ',0)'; } : + function(d) { return 'translate(0,' + (offset + ax.l2p(d.x)) + ')'; }; +}; + +/** + * Make axis tick path string + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} ticklen + * - {number} linewidth + * @param {number} shift along direction of ticklen + * @param {1 or -1} sng tick sign + * @param {number (optional)} len tick length + * @return {string} + */ +axes.makeTickPath = function(ax, shift, sgn, len) { + len = len !== undefined ? len : ax.ticklen; + + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + + return axLetter === 'x' ? + 'M0,' + (shift + pad * sgn) + 'v' + (len * sgn) : + 'M' + (shift + pad * sgn) + ',0h' + (len * sgn); +}; + +/** + * Make axis tick label x, y and anchor functions + * + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} ticklen + * - {string} side + * - {number} linewidth + * - {number} tickfont.size + * - {boolean} showline + * @param {number} shift + * @param {number} angle [in degrees] ... + * @return {object} + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + * - {number} labelStandoff + * - {number} labelShift + */ +axes.makeLabelFns = function(ax, shift, angle) { + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside'; + + var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0; + var labelShift = 0; + + if(angle && ax.ticks === 'outside') { + var rad = Lib.deg2rad(angle); + labelStandoff = ax.ticklen * Math.cos(rad) + 1; + labelShift = ax.ticklen * Math.sin(rad); + } - transform = {rotate: '-90', offset: 0}; - if(!avoid.side) avoid.side = 'left'; + if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) { + labelStandoff += 0.2 * ax.tickfont.size; + } + + // Used in polar angular label x/y functions + // TODO generalize makeLabelFns so that it just work for angular axes + var out = { + labelStandoff: labelStandoff, + labelShift: labelShift + }; + + var x0, y0, ff, flipIt; + if(axLetter === 'x') { + flipIt = ax.side === 'bottom' ? 1 : -1; + x0 = labelShift * flipIt; + y0 = shift + (labelStandoff + pad) * flipIt; + ff = ax.side === 'bottom' ? 1 : -0.2; + + out.labelXFn = function(d) { return d.dx + x0; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * ff; }; + out.labelAnchorFn = function(a) { + if(!isNumeric(a) || a === 0 || a === 180) { + return 'middle'; + } + return (a * flipIt < 0) ? 'end' : 'start'; + }; + } else if(axLetter === 'y') { + flipIt = ax.side === 'right' ? 1 : -1; + x0 = labelStandoff + pad; + y0 = -labelShift * flipIt; + ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0; + + out.labelXFn = function(d) { return d.dx + shift + (x0 + d.fontSize * ff) * flipIt; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; }; + out.labelAnchorFn = function(a) { + if(isNumeric(a) && Math.abs(a) === 90) { + return 'middle'; + } + return ax.side === 'right' ? 'start' : 'end'; + }; + } + + return out; +}; + +function tickDataFn(d) { + return [d.text, d.x, d.axInfo, d.font, d.fontSize, d.fontColor].join('_'); +} + +/** + * Draw axis ticks + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} linewidth + * - {string} tickcolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawTicks = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'tick'; + + var ticks = opts.layer.selectAll('path.' + cls) + .data(ax.ticks ? opts.vals : [], tickDataFn); + + ticks.exit().remove(); + + ticks.enter().append('path') + .classed(cls, 1) + .classed('ticks', 1) + .classed('crisp', opts.crisp !== false) + .call(Color.stroke, ax.tickcolor) + .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') + .attr('d', opts.path); + + ticks.attr('transform', opts.transFn); +}; + +/** + * Draw axis grid + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showgrid + * - {string} gridcolor + * - {string} gridwidth + * - {boolean} zeroline + * - {string} type + * - {string} dtick + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * optional - only required if this axis supports zero lines + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawGrid = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'grid'; + var vals = opts.vals; + var counterAx = opts.counterAxis; + if(ax.showgrid === false) { + vals = []; + } + else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + var isArrayMode = ax.tickmode === 'array'; + for(var i = 0; i < vals.length; i++) { + var xi = vals[i].x; + if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) { + vals = vals.slice(0, i).concat(vals.slice(i + 1)); + // In array mode you can in principle have multiple + // ticks at 0, so test them all. Otherwise once we found + // one we can stop. + if(isArrayMode) i--; + else break; + } } + } + + var grid = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); - Titles.draw(gd, axid + 'title', { - propContainer: ax, - propName: ax._name + '.title', - placeholder: fullLayout._dfltTitle[axLetter], - avoid: avoid, - transform: transform, - attributes: {x: x, y: y, 'text-anchor': 'middle'} + grid.exit().remove(); + + grid.enter().append('path') + .classed(cls, 1) + .classed('crisp', opts.crisp !== false); + + ax._gw = Drawing.crispRound(gd, ax.gridwidth, 1); + + grid.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.gridcolor || '#ddd') + .style('stroke-width', ax._gw + 'px'); + + if(typeof opts.path === 'function') grid.attr('d', opts.path); +}; + +/** + * Draw axis zero-line + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} zeroline + * - {number} zerolinewidth + * - {string} zerolinecolor + * - {number (optional)} _gridWidthCrispRound + * @param {object} opts + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawZeroLine = function(gd, ax, opts) { + opts = opts || opts; + + var cls = ax._id + 'zl'; + var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis); + + var zl = opts.layer.selectAll('path.' + cls) + .data(show ? [{x: 0, id: ax._id}] : []); + + zl.exit().remove(); + + zl.enter().append('path') + .classed(cls, 1) + .classed('zl', 1) + .classed('crisp', opts.crisp !== false) + .each(function() { + // use the fact that only one element can enter to trigger a sort. + // If several zerolines enter at the same time we will sort once per, + // but generally this should be a minimal overhead. + opts.layer.selectAll('path').sort(function(da, db) { + return axisIds.idSort(da.id, db.id); + }); }); - } - function drawGrid(plotinfo, counteraxis) { - if(fullLayout._hasOnlyLargeSploms) return; - - var gridcontainer = plotinfo.gridlayer.selectAll('.' + axid); - var zlcontainer = plotinfo.zerolinelayer; - var gridpath = ax._gridpath || ((axLetter === 'x' ? - ('M0,' + counteraxis._offset + 'v') : - ('M' + counteraxis._offset + ',0h') - ) + counteraxis._length); - var grid = gridcontainer.selectAll('path.' + gcls) - .data((ax.showgrid === false) ? [] : valsClipped, datafn); - grid.enter().append('path').classed(gcls, 1) - .classed('crisp', 1) - .attr('d', gridpath) + zl.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); +}; + +/** + * Draw axis tick labels + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showticklabels + * - {number} tickangle + * - {object (optional)} _selections + * - {object} (optional)} _tickAngles + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string (optional)} cls (node className) + * - {boolean} repositionOnUpdate (set to true to reposition update selection) + * - {boolean} secondary + * - {fn} transFn + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + */ +axes.drawLabels = function(gd, ax, opts) { + opts = opts || {}; + + var axId = ax._id; + var axLetter = axId.charAt(0); + var cls = opts.cls || axId + 'tick'; + var vals = opts.vals; + var labelXFn = opts.labelXFn; + var labelYFn = opts.labelYFn; + var labelAnchorFn = opts.labelAnchorFn; + var tickAngle = opts.secondary ? 0 : ax.tickangle; + var lastAngle = (ax._tickAngles || {})[cls]; + + var tickLabels = opts.layer.selectAll('g.' + cls) + .data(ax.showticklabels ? vals : [], tickDataFn); + + var labelsReady = []; + + tickLabels.enter().append('g') + .classed(cls, 1) + .append('text') + // only so tex has predictable alignment that we can + // alter later + .attr('text-anchor', 'middle') .each(function(d) { - if(ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - Math.abs(d.x) < ax.dtick / 100) { - d3.select(this).remove(); + var thisLabel = d3.select(this); + var newPromise = gd._promises.length; + + thisLabel + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)) + .call(Drawing.font, d.font, d.fontSize, d.fontColor) + .text(d.text) + .call(svgTextUtils.convertToTspans, gd); + + if(gd._promises[newPromise]) { + // if we have an async label, we'll deal with that + // all here so take it out of gd._promises and + // instead position the label and promise this in + // labelsReady + labelsReady.push(gd._promises.pop().then(function() { + positionLabels(thisLabel, tickAngle); + })); + } else { + // sync label: just position it now. + positionLabels(thisLabel, tickAngle); } }); - grid.attr('transform', transfn) - .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', gridWidth + 'px'); - if(typeof gridpath === 'function') grid.attr('d', gridpath); - grid.exit().remove(); - - // zero line - if(zlcontainer) { - var zlData = {x: 0, id: axid}; - var showZl = axes.shouldShowZeroLine(gd, ax, counteraxis); - var zl = zlcontainer.selectAll('path.' + zcls) - .data(showZl ? [zlData] : []); - zl.enter().append('path').classed(zcls, 1).classed('zl', 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function() { - // use the fact that only one element can enter to trigger a sort. - // If several zerolines enter at the same time we will sort once per, - // but generally this should be a minimal overhead. - zlcontainer.selectAll('path').sort(function(da, db) { - return axisIds.idSort(da.id, db.id); - }); - }); - zl.attr('transform', transfn) - .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', zeroLineWidth + 'px'); - zl.exit().remove(); - } + + tickLabels.exit().remove(); + + if(opts.repositionOnUpdate) { + tickLabels.each(function(d) { + d3.select(this).select('text') + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)); + }); } - if(independent) { - drawTicks(ax._axislayer, tickpathfn(ax._pos + pad * ticksign[2], ticksign[2] * ax.ticklen)); - if(ax._counteraxis) { - var fictionalPlotinfo = { - gridlayer: ax._gridlayer, - zerolinelayer: ax._zerolinelayer - }; - drawGrid(fictionalPlotinfo, ax._counteraxis); + // How much to shift a multi-line label to center it vertically. + function getAnchorHeight(lineCount, lineHeight, angle) { + var h = (lineCount - 1) * lineHeight; + if(axLetter === 'x') { + if(angle < -60 || 60 < angle) { + return -0.5 * h; + } else if(ax.side === 'top') { + return -h; + } + } else { + angle *= ax.side === 'left' ? 1 : -1; + if(angle < -30) { + return -h; + } else if(angle < 30) { + return -0.5 * h; + } } - return drawLabels(ax._axislayer, ax._pos); + return 0; } - else if(fullLayout._has('cartesian')) { - subplots = axes.getSubplots(gd, ax); - - // keep track of which subplots (by main conteraxis) we've already - // drawn grids for, so we don't overdraw overlaying subplots - var finishedGrids = {}; - subplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; - var counterAxis = plotinfo[counterLetter + 'axis']; + function positionLabels(s, angle) { + s.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + var anchor = labelAnchorFn(angle, d); + + var transform = opts.transFn.call(thisLabel.node(), d) + + ((isNumeric(angle) && +angle !== 0) ? + (' rotate(' + angle + ',' + labelXFn(d) + ',' + + (labelYFn(d) - d.fontSize / 2) + ')') : + ''); + + var anchorHeight = getAnchorHeight( + svgTextUtils.lineCount(thisLabel), + LINE_SPACING * d.fontSize, + isNumeric(angle) ? +angle : 0 + ); - var mainCounterID = counterAxis._mainAxis._id; - if(finishedGrids[mainCounterID]) return; - finishedGrids[mainCounterID] = 1; + if(anchorHeight) { + transform += ' translate(0, ' + anchorHeight + ')'; + } - drawGrid(plotinfo, counterAxis, subplot); + if(mathjaxGroup.empty()) { + thisLabel.select('text').attr({ + transform: transform, + 'text-anchor': anchor + }); + } else { + var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; + var mjShift = mjWidth * {end: -0.5, start: 0.5}[anchor]; + mathjaxGroup.attr('transform', transform + (mjShift ? 'translate(' + mjShift + ',0)' : '')); + } }); + } - var mainSubplot = ax._mainSubplot; - var mainPlotinfo = fullLayout._plots[mainSubplot]; - var tickSubplots = []; + // make sure all labels are correctly positioned at their base angle + // the positionLabels call above is only for newly drawn labels. + // do this without waiting, using the last calculated angle to + // minimize flicker, then do it again when we know all labels are + // there, putting back the prescribed angle to check for overlaps. + positionLabels(tickLabels, lastAngle || tickAngle); - if(ax.ticks) { - var mainSign = ticksign[2]; - var tickpath = tickpathfn(ax._mainLinePosition + pad * mainSign, mainSign * ax.ticklen); - if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { - tickpath += tickpathfn(ax._mainMirrorPosition - pad * mainSign, -mainSign * ax.ticklen); - } - drawTicks(mainPlotinfo[axLetter + 'axislayer'], tickpath); + function allLabelsReady() { + return labelsReady.length && Promise.all(labelsReady); + } - tickSubplots = Object.keys(ax._linepositions || {}); - } + function fixLabelOverlaps() { + positionLabels(tickLabels, tickAngle); - tickSubplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; + var autoangle = null; - var container = plotinfo[axLetter + 'axislayer']; + // check for auto-angling if x labels overlap + // don't auto-angle at all for log axes with + // base and digit format + if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) && + (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D') + ) { + autoangle = 0; - // [bottom or left, top or right] - // free and main are handled above - var linepositions = ax._linepositions[subplot] || []; + var maxFontSize = 0; + var lbbArray = []; + var i; + + tickLabels.each(function(d) { + maxFontSize = Math.max(maxFontSize, d.fontSize); + + var x = ax.l2p(d.x); + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + + lbbArray.push({ + // ignore about y, just deal with x overlaps + top: 0, + bottom: 10, + height: 10, + left: x - bb.width / 2, + // impose a 2px gap + right: x + bb.width / 2 + 2, + width: bb.width + 2 + }); + }); - function tickPathSide(sidei) { - var tsign = ticksign[sidei]; - return tickpathfn(linepositions[sidei] + pad * tsign, tsign * ax.ticklen); + if((ax.tickson === 'boundaries' || ax.showdividers) && !opts.secondary) { + var gap = 2; + if(ax.ticks) gap += ax.tickwidth / 2; + + // TODO should secondary labels also fall into this fix-overlap regime? + + for(i = 0; i < lbbArray.length; i++) { + var xbnd = vals[i].xbnd; + var lbb = lbbArray[i]; + if( + (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || + (xbnd[1] !== null && (ax.l2p(xbnd[1]) - lbb.right) < gap) + ) { + autoangle = 90; + break; + } + } + } else { + var vLen = vals.length; + var tickSpacing = Math.abs((vals[vLen - 1].x - vals[0].x) * ax._m) / (vLen - 1); + var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory'; + + // any overlap at all - set 30 degrees or 90 degrees + for(i = 0; i < lbbArray.length - 1; i++) { + if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { + autoangle = rotate90 ? 90 : 30; + break; + } + } } - drawTicks(container, tickPathSide(0) + tickPathSide(1)); - }); + if(autoangle) { + positionLabels(tickLabels, autoangle); + } + } - var mainContainer = mainPlotinfo[axLetter + 'axislayer']; + if(ax._tickAngles) { + ax._tickAngles[cls] = autoangle === null ? + (isNumeric(tickAngle) ? tickAngle : 0) : + autoangle; + } + } - return drawLabels(mainContainer, ax._mainLinePosition); + if(ax._selections) { + ax._selections[cls] = tickLabels; } + + var done = Lib.syncOrAsync([allLabelsReady, fixLabelOverlaps]); + if(done && done.then) gd._promises.push(done); + return done; }; +/** + * Draw axis dividers + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} showdividers + * - {number} dividerwidth + * - {string} dividercolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {fn} path + * - {fn} transFn + */ +function drawDividers(gd, ax, opts) { + var cls = ax._id + 'divider'; + var vals = opts.vals; + + var dividers = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + dividers.exit().remove(); + + dividers.enter().insert('path', ':first-child') + .classed(cls, 1) + .classed('crisp', 1) + .call(Color.stroke, ax.dividercolor) + .style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px'); + + dividers + .attr('transform', opts.transFn) + .attr('d', opts.path); +} + +function drawTitle(gd, ax) { + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var gs = fullLayout._size; + var fontSize = ax.title.font.size; + + var titleStandoff; + if(ax.type === 'multicategory') { + titleStandoff = ax._labelLength; + } else { + var offsetBase = 1.5; + titleStandoff = 10 + fontSize * offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); + } + + var transform, counterAxis, x, y; + + if(axLetter === 'x') { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + x = ax._offset + ax._length / 2; + + if(ax.side === 'top') { + y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); + } else { + y = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1.5 : 0.5); + } + y += counterAxis._offset; + } else { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + y = ax._offset + ax._length / 2; + + if(ax.side === 'right') { + x = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1 : 0.5); + } else { + x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + } + x += counterAxis._offset; + + transform = {rotate: '-90', offset: 0}; + } + + var avoid; + + if(ax.type !== 'multicategory') { + var tickLabels = ax._selections[ax._id + 'tick']; + + avoid = { + selection: tickLabels, + side: ax.side + }; + + if(tickLabels && tickLabels.node() && tickLabels.node().parentNode) { + var translation = Drawing.getTranslate(tickLabels.node().parentNode); + avoid.offsetLeft = translation.x; + avoid.offsetTop = translation.y; + } + } + + return Titles.draw(gd, axId + 'title', { + propContainer: ax, + propName: ax._name + '.title.text', + placeholder: fullLayout._dfltTitle[axLetter], + avoid: avoid, + transform: transform, + attributes: {x: x, y: y, 'text-anchor': 'middle'} + }); +} + axes.shouldShowZeroLine = function(gd, ax, counterAxis) { var rng = Lib.simpleMap(ax.range, ax.r2l); return ( (rng[0] * rng[1] <= 0) && ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - ax._valsClipped.length && + ax._gridVals.length && ( clipEnds(ax, 0) || !anyCounterAxLineAtZero(gd, ax, counterAxis, rng) || @@ -50530,6 +51844,10 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { ); }; +axes.clipEnds = function(ax, vals) { + return vals.filter(function(d) { return clipEnds(ax, d.x); }); +}; + function clipEnds(ax, l) { var p = ax.l2p(l); return (p > 1 && p < ax._length - 1); @@ -50605,6 +51923,12 @@ function hasBarsOrFill(gd, ax) { return false; } +function selectTickLabel(gTick) { + var s = d3.select(gTick); + var mj = s.select('.text-math-group'); + return mj.empty() ? s.select('text') : mj; +} + /** * Find all margin pushers for 2D axes and reserve them for later use * Both label and rangeslider automargin calculations happen later so @@ -50619,14 +51943,17 @@ axes.allowAutoMargin = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; if(ax.automargin) { - Plots.allowAutoMargin(gd, ax._name + '.automargin'); + Plots.allowAutoMargin(gd, axAutoMarginID(ax)); } - if(ax.rangeslider && ax.rangeslider.visible) { - Plots.allowAutoMargin(gd, 'rangeslider' + ax._id); + if(Registry.getComponentMethod('rangeslider', 'isVisible')(ax)) { + Plots.allowAutoMargin(gd, rangeSliderAutoMarginID(ax)); } } }; +function axAutoMarginID(ax) { return ax._id + '.automargin'; } +function rangeSliderAutoMarginID(ax) { return ax._id + '.rangeslider'; } + // swap all the presentation attributes of the axes showing these traces axes.swap = function(gd, traces) { var axGroups = makeAxisGroups(gd, traces); @@ -50682,11 +52009,10 @@ function mergeAxisGroups(intoSet, fromSet) { } function swapAxisGroup(gd, xIds, yIds) { - var i, - j, - xFullAxes = [], - yFullAxes = [], - layout = gd.layout; + var xFullAxes = []; + var yFullAxes = []; + var layout = gd.layout; + var i, j; for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i])); for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i])); @@ -50699,12 +52025,12 @@ function swapAxisGroup(gd, xIds, yIds) { var numericTypes = ['linear', 'log']; for(i = 0; i < allAxKeys.length; i++) { - var keyi = allAxKeys[i], - xVal = xFullAxes[0][keyi], - yVal = yFullAxes[0][keyi], - allEqual = true, - coerceLinearX = false, - coerceLinearY = false; + var keyi = allAxKeys[i]; + var xVal = xFullAxes[0][keyi]; + var yVal = yFullAxes[0][keyi]; + var allEqual = true; + var coerceLinearX = false; + var coerceLinearY = false; if(keyi.charAt(0) === '_' || typeof xVal === 'function' || noSwapAttrs.indexOf(keyi) !== -1) { continue; @@ -50750,17 +52076,18 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes, dfltTitle) { // in case the value is the default for either axis, // look at the first axis in each list and see if // this key's value is undefined - var np = Lib.nestedProperty, - xVal = np(layout[xFullAxes[0]._name], key).get(), - yVal = np(layout[yFullAxes[0]._name], key).get(), - i; + var np = Lib.nestedProperty; + var xVal = np(layout[xFullAxes[0]._name], key).get(); + var yVal = np(layout[yFullAxes[0]._name], key).get(); + var i; + if(key === 'title') { // special handling of placeholder titles - if(xVal === dfltTitle.x) { - xVal = dfltTitle.y; + if(xVal && xVal.text === dfltTitle.x) { + xVal.text = dfltTitle.y; } - if(yVal === dfltTitle.y) { - yVal = dfltTitle.x; + if(yVal && yVal.text === dfltTitle.y) { + yVal.text = dfltTitle.x; } } @@ -50776,7 +52103,7 @@ function isAngular(ax) { return ax._id === 'angularaxis'; } -},{"../../components/color":43,"../../components/drawing":68,"../../components/titles":134,"../../constants/alignment":141,"../../constants/numerical":143,"../../lib":162,"../../lib/svg_text_utils":183,"../../plots/plots":246,"../../registry":254,"./autorange":205,"./axis_autotype":207,"./axis_ids":209,"./clean_ticks":211,"./layout_attributes":219,"./set_convert":225,"d3":7,"fast-isnumeric":9}],207:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/drawing":64,"../../components/titles":131,"../../constants/alignment":138,"../../constants/numerical":140,"../../lib":160,"../../lib/svg_text_utils":181,"../../plots/plots":244,"../../registry":252,"./autorange":203,"./axis_autotype":205,"./axis_ids":207,"./clean_ticks":209,"./layout_attributes":217,"./set_convert":223,"d3":7,"fast-isnumeric":9}],205:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50793,7 +52120,10 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var BADNUM = _dereq_('../../constants/numerical').BADNUM; -module.exports = function autoType(array, calendar) { +module.exports = function autoType(array, calendar, opts) { + opts = opts || {}; + + if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory'; if(moreDates(array, calendar)) return 'date'; if(category(array)) return 'category'; if(linearOK(array)) return 'linear'; @@ -50861,7 +52191,14 @@ function category(a) { return curvecats > curvenums * 2; } -},{"../../constants/numerical":143,"../../lib":162,"fast-isnumeric":9}],208:[function(_dereq_,module,exports){ +// very-loose requirements for multicategory, +// trace modules that should never auto-type to multicategory +// should be declared with 'noMultiCategory' +function multiCategory(a) { + return Lib.isArrayOrTypedArray(a[0]) && Lib.isArrayOrTypedArray(a[1]); +} + +},{"../../constants/numerical":140,"../../lib":160,"fast-isnumeric":9}],206:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -50892,6 +52229,7 @@ var setConvert = _dereq_('./set_convert'); * outerTicks: boolean, should ticks default to outside? * showGrid: boolean, should gridlines be shown by default? * noHover: boolean, this axis doesn't support hover effects? + * noTickson: boolean, this axis doesn't support 'tickson' * data: the plot data, used to manage categories * bgColor: the plot background color, to calculate default gridline colors */ @@ -50932,8 +52270,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, // try to get default title from splom trace, fallback to graph-wide value var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter]; - coerce('title', dfltTitle); - Lib.coerceFont(coerce, 'titlefont', { + coerce('title.text', dfltTitle); + Lib.coerceFont(coerce, 'title.font', { family: font.family, size: Math.round(font.size * 1.2), color: dfltFontColor @@ -50953,10 +52291,29 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, if(options.automargin) coerce('automargin'); + var isMultiCategory = containerOut.type === 'multicategory'; + + if(!options.noTickson && + (containerOut.type === 'category' || isMultiCategory) && + (containerOut.ticks || containerOut.showgrid) + ) { + var ticksonDflt; + if(isMultiCategory) ticksonDflt = 'boundaries'; + coerce('tickson', ticksonDflt); + } + + if(isMultiCategory) { + var showDividers = coerce('showdividers'); + if(showDividers) { + coerce('dividercolor'); + coerce('dividerwidth'); + } + } + return containerOut; }; -},{"../../lib":162,"../../registry":254,"./category_order_defaults":210,"./layout_attributes":219,"./line_grid_defaults":221,"./set_convert":225,"./tick_label_defaults":226,"./tick_mark_defaults":227,"./tick_value_defaults":228}],209:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../registry":252,"./category_order_defaults":208,"./layout_attributes":217,"./line_grid_defaults":219,"./set_convert":223,"./tick_label_defaults":224,"./tick_mark_defaults":225,"./tick_value_defaults":226}],207:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51074,7 +52431,7 @@ exports.idSort = function(id1, id2) { return +(id1.substr(1) || 1) - +(id2.substr(1) || 1); }; -},{"../../registry":254,"./constants":212}],210:[function(_dereq_,module,exports){ +},{"../../registry":252,"./constants":210}],208:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51168,7 +52525,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],211:[function(_dereq_,module,exports){ +},{}],209:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51257,7 +52614,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":143,"../../lib":162,"fast-isnumeric":9}],212:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":160,"fast-isnumeric":9}],210:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51339,7 +52696,7 @@ module.exports = { } }; -},{"../../lib/regex":177}],213:[function(_dereq_,module,exports){ +},{"../../lib/regex":175}],211:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51493,7 +52850,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[scaleanchor] = 1; } -},{"../../lib":162,"./axis_ids":209}],214:[function(_dereq_,module,exports){ +},{"../../lib":160,"./axis_ids":207}],212:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51635,7 +52992,6 @@ exports.enforce = function enforceAxisConstraints(gd) { var getPad = makePadFn(ax); updateDomain(ax, factor); - ax.setScale(); var m = Math.abs(ax._m); var extremes = concatExtremes(gd, ax); var minArray = extremes.min; @@ -51702,9 +53058,10 @@ function updateDomain(ax, factor) { center + (inputDomain[0] - center) / factor, center + (inputDomain[1] - center) / factor ]; + ax.setScale(); } -},{"../../constants/alignment":141,"../../constants/numerical":143,"./autorange":205,"./axis_ids":209,"./scale_zoom":223}],215:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138,"../../constants/numerical":140,"./autorange":203,"./axis_ids":207,"./scale_zoom":221}],213:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -51726,6 +53083,7 @@ var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Fx = _dereq_('../../components/fx'); +var Axes = _dereq_('./axes'); var setCursor = _dereq_('../../lib/setcursor'); var dragElement = _dereq_('../../components/dragelement'); var FROM_TL = _dereq_('../../constants/alignment').FROM_TL; @@ -51734,7 +53092,6 @@ var redrawReglTraces = _dereq_('../../plot_api/subroutines').redrawReglTraces; var Plots = _dereq_('../plots'); -var doTicksSingle = _dereq_('./axes').doTicksSingle; var getFromId = _dereq_('./axis_ids').getFromId; var prepSelect = _dereq_('./select').prepSelect; var clearSelect = _dereq_('./select').clearSelect; @@ -51978,7 +53335,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { .on('edit', function(text) { var v = ax.d2r(text); if(v !== undefined) { - Registry.call('relayout', gd, attrStr, v); + Registry.call('_guiRelayout', gd, attrStr, v); } }); } @@ -52223,6 +53580,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { return; } + // prevent axis drawing from monkeying with margins until we're done + gd._fullLayout._replotting = true; + if(xActive === 'ew' || yActive === 'ns') { if(xActive) dragAxList(xaxes, dx); if(yActive) dragAxList(yaxes, dy); @@ -52326,8 +53686,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { updates = {}; for(i = 0; i < activeAxIds.length; i++) { var axId = activeAxIds[i]; - doTicksSingle(gd, axId, true); var ax = getFromId(gd, axId); + Axes.drawOne(gd, ax, {skipTitle: true}); updates[ax._name + '.range[0]'] = ax.range[0]; updates[ax._name + '.range[1]'] = ax.range[1]; } @@ -52419,7 +53779,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, attrs); } // dragTail - finish a drag event with a redraw @@ -52433,7 +53793,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // accumulated MathJax promises - wait for them before we relayout. Lib.syncOrAsync([ Plots.previousPromises, - function() { Registry.call('relayout', gd, updates); } + function() { + gd._fullLayout._replotting = false; + Registry.call('_guiRelayout', gd, updates); + } ], gd); } @@ -52891,7 +54254,7 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":43,"../../components/dragelement":65,"../../components/drawing":68,"../../components/fx":85,"../../constants/alignment":141,"../../lib":162,"../../lib/clear_gl_canvases":150,"../../lib/setcursor":181,"../../lib/svg_text_utils":183,"../../plot_api/subroutines":197,"../../registry":254,"../plots":246,"./axes":206,"./axis_ids":209,"./constants":212,"./scale_zoom":223,"./select":224,"d3":7,"has-passive-events":12,"tinycolor2":26}],216:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/dragelement":61,"../../components/drawing":64,"../../components/fx":82,"../../constants/alignment":138,"../../lib":160,"../../lib/clear_gl_canvases":148,"../../lib/setcursor":179,"../../lib/svg_text_utils":181,"../../plot_api/subroutines":195,"../../registry":252,"../plots":244,"./axes":204,"./axis_ids":207,"./constants":210,"./scale_zoom":221,"./select":222,"d3":7,"has-passive-events":12,"tinycolor2":26}],214:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53059,7 +54422,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":65,"../../components/fx":85,"../../lib/setcursor":181,"./constants":212,"./dragbox":215,"d3":7}],217:[function(_dereq_,module,exports){ +},{"../../components/dragelement":61,"../../components/fx":82,"../../lib/setcursor":179,"./constants":210,"./dragbox":213,"d3":7}],215:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53134,7 +54497,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":162,"../../registry":254}],218:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../registry":252}],216:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53399,7 +54762,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback // layers that allow `cliponaxis: false` if(className !== 'scatterlayer' && className !== 'barlayer') { - Drawing.setClipUrl(sel, plotinfo.layerClipId); + Drawing.setClipUrl(sel, plotinfo.layerClipId, gd); } }); @@ -53757,7 +55120,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":68,"../../constants/xmlns_namespaces":144,"../../lib":162,"../../registry":254,"../get_data":235,"../plots":246,"./attributes":204,"./axis_ids":209,"./constants":212,"./graph_interact":216,"./layout_attributes":219,"./layout_defaults":220,"./transition_axes":229,"d3":7}],219:[function(_dereq_,module,exports){ +},{"../../components/drawing":64,"../../constants/xmlns_namespaces":141,"../../lib":160,"../../registry":252,"../get_data":233,"../plots":244,"./attributes":202,"./axis_ids":207,"./constants":210,"./graph_interact":214,"./layout_attributes":217,"./layout_defaults":218,"./transition_axes":227,"d3":7}],217:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -53792,21 +55155,24 @@ module.exports = { }, title: { - valType: 'string', - - editType: 'ticks', - + text: { + valType: 'string', + + editType: 'ticks', + + }, + font: fontAttrs({ + editType: 'ticks', + + }), + editType: 'ticks' }, - titlefont: fontAttrs({ - editType: 'ticks', - - }), type: { valType: 'enumerated', // '-' means we haven't yet run autotype or couldn't find any data // it gets turned into linear in gd._fullLayout but not copied back // to gd.data like the others are. - values: ['-', 'linear', 'log', 'date', 'category'], + values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', editType: 'calc', @@ -53935,6 +55301,14 @@ module.exports = { editType: 'ticks', + }, + tickson: { + valType: 'enumerated', + values: ['labels', 'boundaries'], + + dflt: 'labels', + editType: 'ticks', + }, mirror: { valType: 'enumerated', @@ -54188,6 +55562,30 @@ module.exports = { editType: 'ticks', }, + + showdividers: { + valType: 'boolean', + dflt: true, + + editType: 'ticks', + + }, + dividercolor: { + valType: 'color', + dflt: colorAttrs.defaultLine, + + editType: 'ticks', + + }, + dividerwidth: { + valType: 'number', + dflt: 1, + + editType: 'ticks', + + }, + // TODO dividerlen: that would override "to label base" length? + // positioning attributes // anchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -54269,6 +55667,12 @@ module.exports = { editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'calc', @@ -54278,11 +55682,21 @@ module.exports = { editType: 'ticks', - } + }, + title: { + valType: 'string', + + editType: 'ticks', + + }, + titlefont: fontAttrs({ + editType: 'ticks', + + }) } }; -},{"../../components/color/attributes":42,"../../components/drawing/attributes":67,"../../lib/extend":155,"../../plot_api/plot_template":196,"../font_attributes":233,"./constants":212}],220:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":42,"../../components/drawing/attributes":63,"../../lib/extend":153,"../../plot_api/plot_template":194,"../font_attributes":231,"./constants":210}],218:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54441,9 +55855,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; }); axLayoutOut._annIndices = []; axLayoutOut._shapeIndices = []; + axLayoutOut._subplotsWith = []; + axLayoutOut._counterAxes = []; // set up some private properties - axLayoutOut._name = axName; + axLayoutOut._name = axLayoutOut._attr = axName; var id = axLayoutOut._id = name2id(axName); var overlayableAxes = getOverlayableAxes(axLetter, axName); @@ -54461,6 +55877,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id] }; + coerce('uirevision', layoutOut.uirevision); + handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions); handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut); @@ -54522,11 +55940,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var anchoredAxis = layoutOut[id2name(axLayoutOut.anchor)]; - var fixedRangeDflt = ( - anchoredAxis && - anchoredAxis.rangeslider && - anchoredAxis.rangeslider.visible - ); + var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis); coerce('fixedrange', fixedRangeDflt); } @@ -54551,7 +55965,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } }; -},{"../../components/color":43,"../../lib":162,"../../plot_api/plot_template":196,"../../registry":254,"../layout_attributes":237,"./axis_defaults":208,"./axis_ids":209,"./constraint_defaults":213,"./layout_attributes":219,"./position_defaults":222,"./type_defaults":230}],221:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../lib":160,"../../plot_api/plot_template":194,"../../registry":252,"../layout_attributes":235,"./axis_defaults":206,"./axis_ids":207,"./constraint_defaults":211,"./layout_attributes":217,"./position_defaults":220,"./type_defaults":228}],219:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54616,7 +56030,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":42,"../../lib":162,"tinycolor2":26}],222:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":42,"../../lib":160,"tinycolor2":26}],220:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54700,7 +56114,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":162,"fast-isnumeric":9}],223:[function(_dereq_,module,exports){ +},{"../../lib":160,"fast-isnumeric":9}],221:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -54728,7 +56142,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ]; }; -},{"../../constants/alignment":141}],224:[function(_dereq_,module,exports){ +},{"../../constants/alignment":138}],222:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55397,13 +56811,22 @@ function isOnlyOnePointSelected(searchTraces) { function updateSelectedState(gd, searchTraces, eventData) { var i, searchInfo, cd, trace; + // before anything else, update preGUI if necessary + for(i = 0; i < searchTraces.length; i++) { + var fullInputTrace = searchTraces[i].cd[0].trace._fullInput; + var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid]; + if(tracePreGUI.selectedpoints === undefined) { + tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null; + } + } + if(eventData) { var pts = eventData.points || []; for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; - trace.selectedpoints = []; - trace._input.selectedpoints = []; + trace._input.selectedpoints = trace._fullInput.selectedpoints = []; + if(trace._fullInput !== trace) trace.selectedpoints = []; } for(i = 0; i < pts.length; i++) { @@ -55413,10 +56836,14 @@ function updateSelectedState(gd, searchTraces, eventData) { if(pt.pointIndices) { [].push.apply(data.selectedpoints, pt.pointIndices); - [].push.apply(fullData.selectedpoints, pt.pointIndices); + if(trace._fullInput !== trace) { + [].push.apply(fullData.selectedpoints, pt.pointIndices); + } } else { data.selectedpoints.push(pt.pointIndex); - fullData.selectedpoints.push(pt.pointIndex); + if(trace._fullInput !== trace) { + fullData.selectedpoints.push(pt.pointIndex); + } } } } @@ -55425,6 +56852,9 @@ function updateSelectedState(gd, searchTraces, eventData) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; delete trace._input.selectedpoints; + if(trace._fullInput !== trace) { + delete trace._fullInput.selectedpoints; + } } } @@ -55502,7 +56932,7 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":43,"../../components/fx":85,"../../components/fx/helpers":82,"../../lib/clear_gl_canvases":150,"../../lib/polygon":174,"../../lib/throttle":184,"../../plot_api/subroutines":197,"../../registry":254,"./axis_ids":209,"./constants":212,"polybooljs":17}],225:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/fx":82,"../../components/fx/helpers":78,"../../lib/clear_gl_canvases":148,"../../lib/polygon":172,"../../lib/throttle":182,"../../plot_api/subroutines":195,"../../registry":252,"./axis_ids":207,"./constants":210,"polybooljs":17}],223:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -55535,6 +56965,10 @@ function fromLog(v) { return Math.pow(10, v); } +function isValidCategory(v) { + return v !== null && v !== undefined; +} + /** * Define the conversion functions for an axis data is used in 5 ways: * @@ -55628,7 +57062,7 @@ module.exports = function setConvert(ax, fullLayout) { * a disconnect between the array and the index returned */ function setCategoryIndex(v) { - if(v !== null && v !== undefined) { + if(isValidCategory(v)) { if(ax._categoriesMap === undefined) { ax._categoriesMap = {}; } @@ -55647,14 +57081,58 @@ module.exports = function setConvert(ax, fullLayout) { return BADNUM; } + function setMultiCategoryIndex(arrayIn, len) { + var arrayOut = new Array(len); + var i; + + // [ [arrayIn[0][i], arrayIn[1][i]], for i .. len ] + var tmp = new Array(len); + // [ [cnt, {$cat: index}], for j .. arrayIn.length ] + var seen = [[0, {}], [0, {}]]; + + if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) { + for(i = 0; i < len; i++) { + var v0 = arrayIn[0][i]; + var v1 = arrayIn[1][i]; + if(isValidCategory(v0) && isValidCategory(v1)) { + tmp[i] = [v0, v1]; + if(!(v0 in seen[0][1])) { + seen[0][1][v0] = seen[0][0]++; + } + if(!(v1 in seen[1][1])) { + seen[1][1][v1] = seen[1][0]++; + } + } + } + + tmp.sort(function(a, b) { + var ind0 = seen[0][1]; + var d = ind0[a[0]] - ind0[b[0]]; + if(d) return d; + + var ind1 = seen[1][1]; + return ind1[a[1]] - ind1[b[1]]; + }); + } + + for(i = 0; i < len; i++) { + arrayOut[i] = setCategoryIndex(tmp[i]); + } + + return arrayOut; + } + function getCategoryIndex(v) { - // d2l/d2c variant that that won't add categories but will also - // allow numbers to be mapped to the linearized axis positions if(ax._categoriesMap) { - var index = ax._categoriesMap[v]; - if(index !== undefined) return index; + return ax._categoriesMap[v]; } + } + function getCategoryPosition(v) { + // d2l/d2c variant that that won't add categories but will also + // allow numbers to be mapped to the linearized axis positions + var index = getCategoryIndex(v); + if(index !== undefined) return index; if(isNumeric(v)) return +v; } @@ -55740,15 +57218,15 @@ module.exports = function setConvert(ax, fullLayout) { ax.d2c = ax.d2l = setCategoryIndex; ax.r2d = ax.c2d = ax.l2d = getCategoryName; - ax.d2r = ax.d2l_noadd = getCategoryIndex; + ax.d2r = ax.d2l_noadd = getCategoryPosition; ax.r2c = function(v) { - var index = getCategoryIndex(v); + var index = getCategoryPosition(v); return index !== undefined ? index : ax.fraction2r(0.5); }; ax.l2r = ax.c2r = ensureNumber; - ax.r2l = getCategoryIndex; + ax.r2l = getCategoryPosition; ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; ax.p2d = function(px) { return getCategoryName(p2l(px)); }; @@ -55760,6 +57238,34 @@ module.exports = function setConvert(ax, fullLayout) { return ensureNumber(v); }; } + else if(ax.type === 'multicategory') { + // N.B. multicategory axes don't define d2c and d2l, + // as 'data-to-calcdata' conversion needs to take into + // account all data array items as in ax.makeCalcdata. + + ax.r2d = ax.c2d = ax.l2d = getCategoryName; + ax.d2r = ax.d2l_noadd = getCategoryPosition; + + ax.r2c = function(v) { + var index = getCategoryPosition(v); + return index !== undefined ? index : ax.fraction2r(0.5); + }; + + ax.r2c_just_indices = getCategoryIndex; + + ax.l2r = ax.c2r = ensureNumber; + ax.r2l = getCategoryPosition; + + ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; + ax.p2d = function(px) { return getCategoryName(p2l(px)); }; + ax.r2p = ax.d2p; + ax.p2r = p2l; + + ax.cleanPos = function(v) { + if(Array.isArray(v) || (typeof v === 'string' && v !== '')) return v; + return ensureNumber(v); + }; + } // find the range value at the specified (linear) fraction of the axis ax.fraction2r = function(v) { @@ -55853,11 +57359,6 @@ module.exports = function setConvert(ax, fullLayout) { ax.setScale = function(usePrivateRange) { var gs = fullLayout._size; - // TODO cleaner way to handle this case - if(!ax._categories) ax._categories = []; - // Add a map to optimize the performance of category collection - if(!ax._categoriesMap) ax._categoriesMap = {}; - // make sure we have a domain (pull it in from the axis // this one is overlaying if necessary) if(ax.overlaying) { @@ -55912,7 +57413,7 @@ module.exports = function setConvert(ax, fullLayout) { if(axLetter in trace) { arrayIn = trace[axLetter]; - len = trace._length || arrayIn.length; + len = trace._length || Lib.minRowLength(arrayIn); if(Lib.isTypedArray(arrayIn) && (axType === 'linear' || axType === 'log')) { if(len === arrayIn.length) { @@ -55922,6 +57423,10 @@ module.exports = function setConvert(ax, fullLayout) { } } + if(axType === 'multicategory') { + return setMultiCategoryIndex(arrayIn, len); + } + arrayOut = new Array(len); for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); @@ -55998,7 +57503,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":143,"../../lib":162,"./axis_ids":209,"./constants":212,"d3":7,"fast-isnumeric":9}],226:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":160,"./axis_ids":207,"./constants":210,"d3":7,"fast-isnumeric":9}],224:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56099,7 +57604,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../lib":162,"../array_container_defaults":202,"./layout_attributes":219}],227:[function(_dereq_,module,exports){ +},{"../../lib":160,"../array_container_defaults":200,"./layout_attributes":217}],225:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56132,7 +57637,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":162,"./layout_attributes":219}],228:[function(_dereq_,module,exports){ +},{"../../lib":160,"./layout_attributes":217}],226:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56141,22 +57646,18 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); - module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { var tickmode; if(containerIn.tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; - } - else { - var tickmodeDefault = - Array.isArray(containerIn.tickvals) ? 'array' : + } else { + var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : containerIn.dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); @@ -56171,15 +57672,14 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe containerIn.dtick, axType); containerOut.tick0 = cleanTicks.tick0( containerIn.tick0, axType, containerOut.calendar, dtick); - } - else { + } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto'; else coerce('ticktext'); } }; -},{"./clean_ticks":211}],229:[function(_dereq_,module,exports){ +},{"./clean_ticks":209}],227:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56301,14 +57801,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo } function ticksAndAnnotations(xa, ya) { - var activeAxIds = [], - i; - - activeAxIds = [xa._id, ya._id]; + var activeAxIds = [xa._id, ya._id]; + var i; - for(i = 0; i < activeAxIds.length; i++) { - Axes.doTicksSingle(gd, activeAxIds[i], true); - } + Axes.drawOne(gd, xa, {skipTitle: true}); + Axes.drawOne(gd, ya, {skipTitle: true}); function redrawObjs(objArray, method, shortCircuit) { for(i = 0; i < objArray.length; i++) { @@ -56507,7 +58004,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo return Promise.resolve(); }; -},{"../../components/drawing":68,"../../registry":254,"./axes":206,"./constants":212,"d3":7}],230:[function(_dereq_,module,exports){ +},{"../../components/drawing":64,"../../registry":252,"./axes":204,"./constants":210,"d3":7}],228:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -56518,7 +58015,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo 'use strict'; -var Registry = _dereq_('../../registry'); +var traceIs = _dereq_('../../registry').traceIs; var autoType = _dereq_('./axis_autotype'); /* @@ -56567,6 +58064,7 @@ function setAutoType(ax, data) { var calAttr = axLetter + 'calendar'; var calendar = d0[calAttr]; + var opts = {noMultiCategory: !traceIs(d0, 'cartesian') || traceIs(d0, 'noMultiCategory')}; var i; // check all boxes on this x axis to see @@ -56577,8 +58075,7 @@ function setAutoType(ax, data) { for(i = 0; i < data.length; i++) { var trace = data[i]; - if(!Registry.traceIs(trace, 'box-violin') || - (trace[axLetter + 'axis'] || axLetter) !== id) continue; + if(!traceIs(trace, 'box-violin') || (trace[axLetter + 'axis'] || axLetter) !== id) continue; if(trace[posLetter] !== undefined) boxPositions.push(trace[posLetter][0]); else if(trace.name !== undefined) boxPositions.push(trace.name); @@ -56587,7 +58084,7 @@ function setAutoType(ax, data) { if(trace[calAttr] !== calendar) calendar = undefined; } - ax.type = autoType(boxPositions, calendar); + ax.type = autoType(boxPositions, calendar, opts); } else if(d0.type === 'splom') { var dimensions = d0.dimensions; @@ -56595,13 +58092,13 @@ function setAutoType(ax, data) { for(i = 0; i < dimensions.length; i++) { var dim = dimensions[i]; if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) { - ax.type = autoType(dim.values, calendar); + ax.type = autoType(dim.values, calendar, opts); break; } } } else { - ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar); + ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -56632,9 +58129,9 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace), - isBox = Registry.traceIs(trace, 'box-violin'), - isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); + var posLetter = getBoxPosLetter(trace); + var isBox = traceIs(trace, 'box-violin'); + var isCandlestick = traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox && @@ -56645,7 +58142,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":254,"./axis_autotype":207}],231:[function(_dereq_,module,exports){ +},{"../../registry":252,"./axis_autotype":205}],229:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57069,7 +58566,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":162,"../registry":254}],232:[function(_dereq_,module,exports){ +},{"../lib":160,"../registry":252}],230:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57177,7 +58674,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { coerce('domain.y', dfltY); }; -},{"../lib/extend":155}],233:[function(_dereq_,module,exports){ +},{"../lib/extend":153}],231:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57242,7 +58739,7 @@ module.exports = function(opts) { return attrs; }; -},{}],234:[function(_dereq_,module,exports){ +},{}],232:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57288,7 +58785,7 @@ module.exports = { } }; -},{}],235:[function(_dereq_,module,exports){ +},{}],233:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57416,7 +58913,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":254,"./cartesian/constants":212}],236:[function(_dereq_,module,exports){ +},{"../registry":252,"./cartesian/constants":210}],234:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57450,7 +58947,7 @@ function project(camera, v) { module.exports = project; -},{}],237:[function(_dereq_,module,exports){ +},{}],235:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57463,6 +58960,9 @@ module.exports = project; var fontAttrs = _dereq_('./font_attributes'); var colorAttrs = _dereq_('../components/color/attributes'); +var colorscaleAttrs = _dereq_('../components/colorscale/layout_attributes'); +var padAttrs = _dereq_('./pad_attributes'); +var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', @@ -57475,15 +58975,71 @@ globalFont.color.dflt = colorAttrs.defaultLine; module.exports = { font: globalFont, title: { - valType: 'string', - - editType: 'layoutstyle', - + text: { + valType: 'string', + + editType: 'layoutstyle', + + }, + font: fontAttrs({ + editType: 'layoutstyle', + + }), + xref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + yref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + x: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.5, + + editType: 'layoutstyle', + + }, + y: { + valType: 'number', + min: 0, + max: 1, + dflt: 'auto', + + editType: 'layoutstyle', + + }, + xanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'left', 'center', 'right'], + + editType: 'layoutstyle', + + }, + yanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'top', 'middle', 'bottom'], + + editType: 'layoutstyle', + + }, + pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { + + }), + editType: 'layoutstyle' }, - titlefont: fontAttrs({ - editType: 'layoutstyle', - - }), autosize: { valType: 'boolean', @@ -57602,11 +59158,30 @@ module.exports = { editType: 'calc', }, + colorscale: colorscaleAttrs, datarevision: { valType: 'any', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editrevision: { + valType: 'any', + + editType: 'none', + + }, + selectionrevision: { + valType: 'any', + + editType: 'none', + }, template: { valType: 'any', @@ -57640,12 +59215,30 @@ module.exports = { editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'modebar' + }, + _deprecated: { + title: { + valType: 'string', + + editType: 'layoutstyle', + + }, + titlefont: fontAttrs({ + editType: 'layoutstyle', + + }) } }; -},{"../components/color/attributes":42,"./font_attributes":233}],238:[function(_dereq_,module,exports){ +},{"../components/color/attributes":42,"../components/colorscale/layout_attributes":56,"../lib/extend":153,"./font_attributes":231,"./pad_attributes":243}],236:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57688,7 +59281,7 @@ module.exports = { } }; -},{}],239:[function(_dereq_,module,exports){ +},{}],237:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57761,7 +59354,7 @@ module.exports = function convertTextOpts(textposition, iconSize) { return { anchor: anchor, offset: offset }; }; -},{"../../lib":162}],240:[function(_dereq_,module,exports){ +},{"../../lib":160}],238:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -57921,7 +59514,7 @@ exports.updateFx = function(gd) { } }; -},{"../../constants/xmlns_namespaces":144,"../../lib":162,"../../plots/get_data":235,"./constants":238,"./layout_attributes":242,"./layout_defaults":243,"./mapbox":244,"mapbox-gl":15}],241:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":141,"../../lib":160,"../../plots/get_data":233,"./constants":236,"./layout_attributes":240,"./layout_defaults":241,"./mapbox":242,"mapbox-gl":15}],239:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58141,7 +59734,7 @@ module.exports = function createMapboxLayer(mapbox, index, opts) { return mapboxLayer; }; -},{"../../lib":162,"./convert_text_opts":239}],242:[function(_dereq_,module,exports){ +},{"../../lib":160,"./convert_text_opts":237}],240:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58166,7 +59759,7 @@ var fontAttr = fontAttrs({ }); fontAttr.family.dflt = 'Open Sans Regular, Arial Unicode MS Regular'; -module.exports = overrideAll({ +var attrs = module.exports = overrideAll({ _arrayAttrRegexps: [Lib.counterRegex('mapbox', '.layers', true)], domain: domainAttrs({name: 'mapbox'}), @@ -58330,7 +59923,15 @@ module.exports = overrideAll({ }) }, 'plot', 'from-root'); -},{"../../components/color":43,"../../lib":162,"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../../traces/scatter/attributes":266,"../domain":232,"../font_attributes":233}],243:[function(_dereq_,module,exports){ +// set uirevision outside of overrideAll so it can be `editType: 'none'` +attrs.uirevision = { + valType: 'any', + + editType: 'none', + +}; + +},{"../../components/color":43,"../../lib":160,"../../plot_api/edit_types":187,"../../plot_api/plot_template":194,"../../traces/scatter/attributes":264,"../domain":230,"../font_attributes":231}],241:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58419,7 +60020,7 @@ function handleLayerDefaults(layerIn, layerOut) { } } -},{"../../lib":162,"../array_container_defaults":202,"../subplot_defaults":253,"./layout_attributes":242}],244:[function(_dereq_,module,exports){ +},{"../../lib":160,"../array_container_defaults":200,"../subplot_defaults":251,"./layout_attributes":240}],242:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58435,6 +60036,7 @@ var mapboxgl = _dereq_('mapbox-gl'); var Fx = _dereq_('../../components/fx'); var Lib = _dereq_('../../lib'); +var Registry = _dereq_('../../registry'); var dragElement = _dereq_('../../components/dragelement'); var prepSelect = _dereq_('../cartesian/select').prepSelect; var selectOnClick = _dereq_('../cartesian/select').selectOnClick; @@ -58559,22 +60161,22 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) { map.on('moveend', function(eventData) { if(!self.map) return; - var view = self.getView(); - - opts._input.center = opts.center = view.center; - opts._input.zoom = opts.zoom = view.zoom; - opts._input.bearing = opts.bearing = view.bearing; - opts._input.pitch = opts.pitch = view.pitch; - // 'moveend' gets triggered by map.setCenter, map.setZoom, // map.setBearing and map.setPitch. // - // Here, we make sure that 'plotly_relayout' is - // triggered here only when the 'moveend' originates from a + // Here, we make sure that state updates amd 'plotly_relayout' + // are triggered only when the 'moveend' originates from a // mouse target (filtering out API calls) to not // duplicate 'plotly_relayout' events. if(eventData.originalEvent || wheeling) { + var view = self.getView(); + + opts._input.center = opts.center = view.center; + opts._input.zoom = opts.zoom = view.zoom; + opts._input.bearing = opts.bearing = view.bearing; + opts._input.pitch = opts.pitch = view.pitch; + emitRelayoutFromView(view); } wheeling = false; @@ -58632,6 +60234,7 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) { for(var k in view) { evtData[id + '.' + k] = view[k]; } + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, evtData); gd.emit('plotly_relayout', evtData); } @@ -58728,8 +60331,8 @@ proto.updateData = function(calcData) { }; proto.updateLayout = function(fullLayout) { - var map = this.map, - opts = this.opts; + var map = this.map; + var opts = this.opts; map.setCenter(convertCenter(opts.center)); map.setZoom(opts.zoom); @@ -58983,7 +60586,7 @@ function convertCenter(center) { return [center.lon, center.lat]; } -},{"../../components/dragelement":65,"../../components/fx":85,"../../lib":162,"../cartesian/select":224,"./constants":238,"./layers":241,"./layout_attributes":242,"mapbox-gl":15}],245:[function(_dereq_,module,exports){ +},{"../../components/dragelement":61,"../../components/fx":82,"../../lib":160,"../../registry":252,"../cartesian/select":222,"./constants":236,"./layers":239,"./layout_attributes":240,"mapbox-gl":15}],243:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -58994,42 +60597,51 @@ function convertCenter(center) { 'use strict'; -// This is used exclusively by components inside component arrays, -// hence the 'arraydraw' editType. If this ever gets used elsewhere -// we could generalize it as a function ala font_attributes -module.exports = { - t: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - r: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - b: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - l: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - editType: 'arraydraw' +/** + * Creates a set of padding attributes. + * + * @param {object} opts + * @param {string} editType: + * the editType for all pieces of this padding definition + * + * @return {object} attributes object containing {t, r, b, l} as specified + */ +module.exports = function(opts) { + var editType = opts.editType; + return { + t: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + r: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + b: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + l: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + editType: editType + }; }; -},{}],246:[function(_dereq_,module,exports){ +},{}],244:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -59481,6 +61093,7 @@ plots.supplyDefaults = function(gd, opts) { for(i = 0; i < crossTraceDefaultsFuncs.length; i++) { crossTraceDefaultsFuncs[i](newFullData, newFullLayout); } + Registry.getComponentMethod('colorscale', 'crossTraceDefaults')(newFullData, newFullLayout); // turn on flag to optimize large splom-only graphs // mostly by omitting SVG layers during Cartesian.drawFramework @@ -59511,15 +61124,29 @@ plots.supplyDefaults = function(gd, opts) { // relink functions and _ attributes to promote consistency between plots relinkPrivateKeys(newFullLayout, oldFullLayout); - // TODO may return a promise - plots.doAutoMargin(gd); - - // set scale after auto margin routine - var axList = axisIDs.list(gd); - for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - ax.setScale(); + // For persisting GUI-driven changes in layout + // _preGUI and _tracePreGUI were already copied over in relinkPrivateKeys + if(!newFullLayout._preGUI) newFullLayout._preGUI = {}; + // track trace GUI changes by uid rather than by trace index + if(!newFullLayout._tracePreGUI) newFullLayout._tracePreGUI = {}; + var tracePreGUI = newFullLayout._tracePreGUI; + var uids = {}; + var uid; + for(uid in tracePreGUI) uids[uid] = 'old'; + for(i = 0; i < newFullData.length; i++) { + uid = newFullData[i]._fullInput.uid; + if(!uids[uid]) tracePreGUI[uid] = {}; + uids[uid] = 'new'; } + for(uid in uids) { + if(uids[uid] === 'old') delete tracePreGUI[uid]; + } + + // set up containers for margin calculations + initMargins(newFullLayout); + + // collect and do some initial calculations for rangesliders + Registry.getComponentMethod('rangeslider', 'makeData')(newFullLayout); // update object references in calcdata if(!skipUpdateCalc && oldCalcdata.length === newFullData.length) { @@ -59829,6 +61456,12 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa plotinfo.id = id; } + // add these axis ids to each others' subplot lists + xaxis._counterAxes.push(yaxis._id); + yaxis._counterAxes.push(xaxis._id); + xaxis._subplotsWith.push(id); + yaxis._subplotsWith.push(id); + // update x and y axis layout object refs plotinfo.xaxis = xaxis; plotinfo.yaxis = yaxis; @@ -59856,8 +61489,9 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // while we're at it, link overlaying axes to their main axes and // anchored axes to the axes they're anchored to var axList = axisIDs.list(mockGd, null, true); + var ax; for(i = 0; i < axList.length; i++) { - var ax = axList[i]; + ax = axList[i]; var mainAx = null; if(ax.overlaying) { @@ -59885,8 +61519,53 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa null : axisIDs.getFromId(mockGd, ax.anchor); } + + // finally, we can find the main subplot for each axis + // (on which the ticks & labels are drawn) + for(i = 0; i < axList.length; i++) { + ax = axList[i]; + ax._counterAxes.sort(axisIDs.idSort); + ax._subplotsWith.sort(Lib.subplotSort); + ax._mainSubplot = findMainSubplot(ax, newFullLayout); + } }; +function findMainSubplot(ax, fullLayout) { + var mockGd = {_fullLayout: fullLayout}; + + var isX = ax._id.charAt(0) === 'x'; + var anchorAx = ax._mainAxis._anchorAxis; + var mainSubplotID = ''; + var nextBestMainSubplotID = ''; + var anchorID = ''; + + // First try the main ID with the anchor + if(anchorAx) { + anchorID = anchorAx._mainAxis._id; + mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); + } + + // Then look for a subplot with the counteraxis overlaying the anchor + // If that fails just use the first subplot including this axis + if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { + mainSubplotID = ''; + + var counterIDs = ax._counterAxes; + for(var j = 0; j < counterIDs.length; j++) { + var counterPart = counterIDs[j]; + var id = isX ? (ax._id + counterPart) : (counterPart + ax._id); + if(!nextBestMainSubplotID) nextBestMainSubplotID = id; + var counterAx = axisIDs.getFromId(mockGd, counterPart); + if(anchorID && counterAx.overlaying === anchorID) { + mainSubplotID = id; + break; + } + } + } + + return mainSubplotID || nextBestMainSubplotID; +} + // This function clears any trace attributes with valType: color and // no set dflt filed in the plot schema. This is needed because groupby (which // is the only transform for which this currently applies) supplies parent @@ -60154,6 +61833,8 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac coerce('type'); coerce('name', layout._traceWord + ' ' + traceInIndex); + coerce('uirevision', layout.uirevision); + // we want even invisible traces to make their would-be subplots visible // so coerce the subplot id(s) now no matter what var _module = plots.getModule(traceOut); @@ -60227,7 +61908,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac if(_module) { _module.supplyDefaults(traceIn, traceOut, defaultColor, layout); - Lib.coerceHoverinfo(traceIn, traceOut, layout); + if(!traceOut.hovertemplate) Lib.coerceHoverinfo(traceIn, traceOut, layout); } if(!Registry.traceIs(traceOut, 'noOpacity')) coerce('opacity'); @@ -60356,14 +62037,25 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { var globalFont = Lib.coerceFont(coerce, 'font'); - coerce('title', layoutOut._dfltTitle.plot); + coerce('title.text', layoutOut._dfltTitle.plot); - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: globalFont.family, size: Math.round(globalFont.size * 1.4), color: globalFont.color }); + coerce('title.xref'); + coerce('title.yref'); + coerce('title.x'); + coerce('title.y'); + coerce('title.xanchor'); + coerce('title.yanchor'); + coerce('title.pad.t'); + coerce('title.pad.r'); + coerce('title.pad.b'); + coerce('title.pad.l'); + // Make sure that autosize is defaulted to *true* // on layouts with no set width and height for backward compatibly, // in particular https://plot.ly/javascript/responsive-fluid-layout/ @@ -60396,12 +62088,16 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('colorway'); coerce('datarevision'); + var uirevision = coerce('uirevision'); + coerce('editrevision', uirevision); + coerce('selectionrevision', uirevision); coerce('modebar.orientation'); coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); + coerce('modebar.uirevision', uirevision); Registry.getComponentMethod( 'calendars', @@ -60683,7 +62379,20 @@ plots.allowAutoMargin = function(gd, id) { gd._fullLayout._pushmarginIds[id] = 1; }; -function setupAutoMargin(fullLayout) { +function initMargins(fullLayout) { + var margin = fullLayout.margin; + + if(!fullLayout._size) { + var gs = fullLayout._size = { + l: Math.round(margin.l), + r: Math.round(margin.r), + t: Math.round(margin.t), + b: Math.round(margin.b), + p: Math.round(margin.pad) + }; + gs.w = Math.round(fullLayout.width) - gs.l - gs.r; + gs.h = Math.round(fullLayout.height) - gs.t - gs.b; + } if(!fullLayout._pushmargin) fullLayout._pushmargin = {}; if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {}; } @@ -60706,8 +62415,6 @@ function setupAutoMargin(fullLayout) { plots.autoMargin = function(gd, id, o) { var fullLayout = gd._fullLayout; - setupAutoMargin(fullLayout); - var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -60751,18 +62458,19 @@ plots.autoMargin = function(gd, id, o) { plots.doAutoMargin = function(gd) { var fullLayout = gd._fullLayout; if(!fullLayout._size) fullLayout._size = {}; - setupAutoMargin(fullLayout); + initMargins(fullLayout); - var gs = fullLayout._size, - oldmargins = JSON.stringify(gs); + var gs = fullLayout._size; + var oldmargins = JSON.stringify(gs); + var margin = fullLayout.margin; // adjust margins for outside components // fullLayout.margin is the requested margin, // fullLayout._size has margins and plotsize after adjustment - var ml = Math.max(fullLayout.margin.l || 0, 0); - var mr = Math.max(fullLayout.margin.r || 0, 0); - var mt = Math.max(fullLayout.margin.t || 0, 0); - var mb = Math.max(fullLayout.margin.b || 0, 0); + var ml = margin.l; + var mr = margin.r; + var mt = margin.t; + var mb = margin.b; var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -60832,7 +62540,7 @@ plots.doAutoMargin = function(gd) { gs.r = Math.round(mr); gs.t = Math.round(mt); gs.b = Math.round(mb); - gs.p = Math.round(fullLayout.margin.pad); + gs.p = Math.round(margin.pad); gs.w = Math.round(fullLayout.width) - gs.l - gs.r; gs.h = Math.round(fullLayout.height) - gs.t - gs.b; @@ -61713,7 +63421,7 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl subplot.traceHash = traceHash; }; -},{"../components/color":43,"../constants/numerical":143,"../lib":162,"../plot_api/plot_schema":195,"../plot_api/plot_template":196,"../plots/cartesian/axis_ids":209,"../registry":254,"./animation_attributes":201,"./attributes":203,"./command":231,"./font_attributes":233,"./frame_attributes":234,"./layout_attributes":237,"d3":7,"fast-isnumeric":9}],247:[function(_dereq_,module,exports){ +},{"../components/color":43,"../constants/numerical":140,"../lib":160,"../plot_api/plot_schema":193,"../plot_api/plot_template":194,"../plots/cartesian/axis_ids":207,"../registry":252,"./animation_attributes":199,"./attributes":201,"./command":229,"./font_attributes":231,"./frame_attributes":232,"./layout_attributes":235,"d3":7,"fast-isnumeric":9}],245:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61757,7 +63465,7 @@ module.exports = { } }; -},{"../../../lib/extend":155,"../../../traces/scatter/attributes":266}],248:[function(_dereq_,module,exports){ +},{"../../../lib/extend":153,"../../../traces/scatter/attributes":264}],246:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61879,7 +63587,7 @@ module.exports = overrideAll({ } }, 'plot', 'nested'); -},{"../../../lib/extend":155,"../../../plot_api/edit_types":189,"../../cartesian/layout_attributes":219}],249:[function(_dereq_,module,exports){ +},{"../../../lib/extend":153,"../../../plot_api/edit_types":187,"../../cartesian/layout_attributes":217}],247:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -61894,7 +63602,7 @@ var Polar = module.exports = _dereq_('./micropolar'); Polar.manager = _dereq_('./micropolar_manager'); -},{"./micropolar":250,"./micropolar_manager":251}],250:[function(_dereq_,module,exports){ +},{"./micropolar":248,"./micropolar_manager":249}],248:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -62112,8 +63820,8 @@ var µ = module.exports = { version: '0.2.2' }; centeringOffset[0] = Math.max(0, centeringOffset[0]); centeringOffset[1] = Math.max(0, centeringOffset[1]); svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title); + if (axisConfig.title && axisConfig.title.text) { + var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); var titleBBox = title.node().getBBox(); title.attr({ x: chartCenter[0] - titleBBox.width / 2, @@ -63314,7 +65022,7 @@ var µ = module.exports = { version: '0.2.2' }; return exports; }; -},{"../../../constants/alignment":141,"../../../lib":162,"d3":7}],251:[function(_dereq_,module,exports){ +},{"../../../constants/alignment":138,"../../../lib":160,"d3":7}],249:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63400,7 +65108,7 @@ manager.fillLayout = function(_gd) { _gd._fullLayout = extendDeepAll(dflts, _gd.layout); }; -},{"../../../components/color":43,"../../../lib":162,"./micropolar":250,"./undo_manager":252,"d3":7}],252:[function(_dereq_,module,exports){ +},{"../../../components/color":43,"../../../lib":160,"./micropolar":248,"./undo_manager":250,"d3":7}],250:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63466,7 +65174,7 @@ module.exports = function UndoManager() { }; }; -},{}],253:[function(_dereq_,module,exports){ +},{}],251:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63536,6 +65244,12 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o subplotLayoutOut = Template.newContainer(layoutOut, id, baseId); + // All subplot containers get a `uirevision` inheriting from the base. + // Currently all subplots containers have some user interaction + // attributes, but if we ever add one that doesn't, we would need an + // option to skip this step. + coerce('uirevision', layoutOut.uirevision); + var dfltDomains = {}; dfltDomains[partition] = [i / idsLength, (i + 1) / idsLength]; handleDomainDefaults(subplotLayoutOut, layoutOut, coerce, dfltDomains); @@ -63545,7 +65259,7 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o } }; -},{"../lib":162,"../plot_api/plot_template":196,"./domain":232}],254:[function(_dereq_,module,exports){ +},{"../lib":160,"../plot_api/plot_template":194,"./domain":230}],252:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -63987,7 +65701,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/extend":155,"./lib/is_plain_object":163,"./lib/loggers":166,"./lib/noop":171,"./lib/push_unique":175,"./plots/attributes":203,"./plots/layout_attributes":237}],255:[function(_dereq_,module,exports){ +},{"./lib/extend":153,"./lib/is_plain_object":161,"./lib/loggers":164,"./lib/noop":169,"./lib/push_unique":173,"./plots/attributes":201,"./plots/layout_attributes":235}],253:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64014,7 +65728,7 @@ function cloneLayoutOverride(tileClass) { autosize: true, width: 150, height: 150, - title: '', + title: {text: ''}, showlegend: false, margin: {l: 5, r: 5, t: 5, b: 5, pad: 0}, annotations: [] @@ -64023,7 +65737,7 @@ function cloneLayoutOverride(tileClass) { case 'thumbnail': override = { - title: '', + title: {text: ''}, hidesources: true, showlegend: false, borderwidth: 0, @@ -64071,7 +65785,7 @@ module.exports = function clonePlot(graphObj, options) { for(i = 0; i < keys.length; i++) { if(keyIsAxis(keys[i])) { - newLayout[keys[i]].title = ''; + newLayout[keys[i]].title = {text: ''}; } } @@ -64099,7 +65813,7 @@ module.exports = function clonePlot(graphObj, options) { var axesImageOverride = {}; if(options.tileClass === 'thumbnail') { axesImageOverride = { - title: '', + title: {text: ''}, showaxeslabels: false, showticklabels: false, linetickenable: false @@ -64161,7 +65875,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":162}],256:[function(_dereq_,module,exports){ +},{"../lib":160}],254:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64229,7 +65943,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":162,"../plot_api/to_image":199,"./filesaver":257}],257:[function(_dereq_,module,exports){ +},{"../lib":160,"../plot_api/to_image":197,"./filesaver":255}],255:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64301,7 +66015,7 @@ var fileSaver = function(url, name) { module.exports = fileSaver; -},{}],258:[function(_dereq_,module,exports){ +},{}],256:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64338,7 +66052,7 @@ exports.getRedrawFunc = function(gd) { }; }; -},{}],259:[function(_dereq_,module,exports){ +},{}],257:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64364,7 +66078,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":255,"./download":256,"./helpers":258,"./svgtoimg":260,"./toimage":261,"./tosvg":262}],260:[function(_dereq_,module,exports){ +},{"./cloneplot":253,"./download":254,"./helpers":256,"./svgtoimg":258,"./toimage":259,"./tosvg":260}],258:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64480,7 +66194,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":162,"events":6}],261:[function(_dereq_,module,exports){ +},{"../lib":160,"events":6}],259:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64559,7 +66273,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":162,"../registry":254,"./cloneplot":255,"./helpers":258,"./svgtoimg":260,"./tosvg":262,"events":6}],262:[function(_dereq_,module,exports){ +},{"../lib":160,"../registry":252,"./cloneplot":253,"./helpers":256,"./svgtoimg":258,"./tosvg":260,"events":6}],260:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64741,7 +66455,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":43,"../components/drawing":68,"../constants/xmlns_namespaces":144,"../lib":162,"d3":7}],263:[function(_dereq_,module,exports){ +},{"../components/color":43,"../components/drawing":64,"../constants/xmlns_namespaces":141,"../lib":160,"d3":7}],261:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64783,7 +66497,7 @@ exports.castOption = function castOption(item, indices) { else if(item) return item; }; -},{"../../lib":162}],264:[function(_dereq_,module,exports){ +},{"../../lib":160}],262:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64807,7 +66521,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":43,"./helpers":263}],265:[function(_dereq_,module,exports){ +},{"../../components/color":43,"./helpers":261}],263:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64859,7 +66573,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":162}],266:[function(_dereq_,module,exports){ +},{"../../lib":160}],264:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -64870,6 +66584,7 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -64981,6 +66696,9 @@ module.exports = { editType: 'style', }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), line: { color: { valType: 'color', @@ -65255,7 +66973,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":44,"../../components/colorscale/attributes":50,"../../components/drawing":68,"../../components/drawing/attributes":67,"../../lib/extend":155,"../../plots/font_attributes":233,"./constants":270}],267:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":44,"../../components/colorscale/attributes":50,"../../components/drawing":64,"../../components/drawing/attributes":63,"../../components/fx/hovertemplate_attributes":81,"../../lib/extend":153,"../../plots/font_attributes":231,"./constants":268}],265:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65345,7 +67063,7 @@ function calc(gd, trace) { } arraysToCalcdata(cd, trace); - calcColorscale(trace); + calcColorscale(gd, trace); calcSelection(cd, trace); if(stackGroupOpts) { @@ -65545,7 +67263,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":143,"../../lib":162,"../../plots/cartesian/axes":206,"./arrays_to_calcdata":265,"./calc_selection":268,"./colorscale_calc":269,"./subtypes":290,"fast-isnumeric":9}],268:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":160,"../../plots/cartesian/axes":204,"./arrays_to_calcdata":263,"./calc_selection":266,"./colorscale_calc":267,"./subtypes":288,"fast-isnumeric":9}],266:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65564,7 +67282,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":162}],269:[function(_dereq_,module,exports){ +},{"../../lib":160}],267:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65573,31 +67291,41 @@ module.exports = function calcSelection(cd, trace) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var subTypes = _dereq_('./subtypes'); - -module.exports = function calcMarkerColorscale(trace) { +module.exports = function calcMarkerColorscale(gd, trace) { if(subTypes.hasLines(trace) && hasColorscale(trace, 'line')) { - calcColorscale(trace, trace.line.color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } if(subTypes.hasMarkers(trace)) { if(hasColorscale(trace, 'marker')) { - calcColorscale(trace, trace.marker.color, 'marker', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - calcColorscale(trace, trace.marker.line.color, 'marker.line', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } } }; -},{"../../components/colorscale/calc":51,"../../components/colorscale/has_colorscale":57,"./subtypes":290}],270:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":51,"../../components/colorscale/helpers":54,"./subtypes":288}],268:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65621,10 +67349,12 @@ module.exports = { // number of viewport sizes away from the visible region // at which we clip all lines to the perimeter - maxScreensAway: 20 + maxScreensAway: 20, + + eventDataKeys: [] }; -},{}],271:[function(_dereq_,module,exports){ +},{}],269:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65807,7 +67537,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":267}],272:[function(_dereq_,module,exports){ +},{"./calc":265}],270:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65846,7 +67576,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],273:[function(_dereq_,module,exports){ +},{}],271:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65924,7 +67654,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout dfltHoverOn.push('fills'); } coerce('hoveron', dfltHoverOn.join('+') || 'points'); - + if(traceOut.hoveron !== 'fills') coerce('hovertemplate'); var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults'); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'}); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'}); @@ -65932,7 +67662,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":162,"../../registry":254,"./attributes":266,"./constants":270,"./fillcolor_defaults":275,"./line_defaults":279,"./line_shape_defaults":281,"./marker_defaults":285,"./stack_defaults":288,"./subtypes":290,"./text_defaults":291,"./xy_defaults":292}],274:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../registry":252,"./attributes":264,"./constants":268,"./fillcolor_defaults":273,"./line_defaults":277,"./line_shape_defaults":279,"./marker_defaults":283,"./stack_defaults":286,"./subtypes":288,"./text_defaults":289,"./xy_defaults":290}],272:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -65975,7 +67705,7 @@ function isValid(v) { return v || v === 0; } -},{"../../lib":162}],275:[function(_dereq_,module,exports){ +},{"../../lib":160}],273:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66013,7 +67743,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":43,"../../lib":162}],276:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../lib":160}],274:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66066,7 +67796,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":43,"./subtypes":290}],277:[function(_dereq_,module,exports){ +},{"../../components/color":43,"./subtypes":288}],275:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66162,7 +67892,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { y1: yc + rad, yLabelVal: yLabelVal, - spikeDistance: dxy(di) + spikeDistance: dxy(di), + hovertemplate: trace.hovertemplate }); fillHoverText(di, trace, pointData); @@ -66246,7 +67977,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { x1: xmax, y0: yAvg, y1: yAvg, - color: color + color: color, + hovertemplate: '%{name}' }); delete pointData.index; @@ -66261,7 +67993,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":43,"../../components/fx":85,"../../lib":162,"../../registry":254,"./fill_hover_text":274,"./get_trace_color":276}],278:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/fx":82,"../../lib":160,"../../registry":252,"./fill_hover_text":272,"./get_trace_color":274}],276:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66308,7 +68040,7 @@ Scatter.meta = { module.exports = Scatter; -},{"../../plots/cartesian":218,"./arrays_to_calcdata":265,"./attributes":266,"./calc":267,"./cross_trace_calc":271,"./cross_trace_defaults":272,"./defaults":273,"./hover":277,"./marker_colorbar":284,"./plot":286,"./select":287,"./style":289,"./subtypes":290}],279:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":216,"./arrays_to_calcdata":263,"./attributes":264,"./calc":265,"./cross_trace_calc":269,"./cross_trace_defaults":270,"./defaults":271,"./hover":275,"./marker_colorbar":282,"./plot":284,"./select":285,"./style":287,"./subtypes":288}],277:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66320,7 +68052,7 @@ module.exports = Scatter; 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) { @@ -66339,7 +68071,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57,"../../lib":162}],280:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54,"../../lib":160}],278:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66804,7 +68536,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":143,"../../lib":162,"./constants":270}],281:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":160,"./constants":268}],279:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66823,7 +68555,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],282:[function(_dereq_,module,exports){ +},{}],280:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66916,7 +68648,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],283:[function(_dereq_,module,exports){ +},{}],281:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66958,7 +68690,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":9}],284:[function(_dereq_,module,exports){ +},{"fast-isnumeric":9}],282:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66976,7 +68708,7 @@ module.exports = { max: 'cmax' }; -},{}],285:[function(_dereq_,module,exports){ +},{}],283:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -66985,11 +68717,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var subTypes = _dereq_('./subtypes'); @@ -67059,7 +68790,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57,"./subtypes":290}],286:[function(_dereq_,module,exports){ +},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54,"./subtypes":288}],284:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67150,7 +68881,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition function createFills(gd, traceJoin, plotinfo) { traceJoin.each(function(d) { var fills = ensureSingle(d3.select(this), 'g', 'fills'); - Drawing.setClipUrl(fills, plotinfo.layerClipId); + Drawing.setClipUrl(fills, plotinfo.layerClipId, gd); var trace = d[0].trace; @@ -67202,7 +68933,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition var text = ensureSingle(tr, 'g', 'text'); // error bars are at the bottom - Registry.getComponentMethod('errorbars', 'plot')(errorBarGroup, plotinfo, transitionOpts); + Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts); if(trace.visible !== true) return; @@ -67357,7 +69088,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.lineGroupStyle) .each(makeUpdate(true)); - Drawing.setClipUrl(lineJoin, plotinfo.layerClipId); + Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd); function clearFill(selection) { transition(selection).attr('d', 'M0,0Z'); @@ -67585,8 +69316,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = trace.cliponaxis === false; var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId; - Drawing.setClipUrl(points, clipUrl); - Drawing.setClipUrl(text, clipUrl); + Drawing.setClipUrl(points, clipUrl, gd); + Drawing.setClipUrl(text, clipUrl, gd); } function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { @@ -67631,7 +69362,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":68,"../../lib":162,"../../lib/polygon":174,"../../registry":254,"./line_points":280,"./link_traces":282,"./subtypes":290,"d3":7}],287:[function(_dereq_,module,exports){ +},{"../../components/drawing":64,"../../lib":160,"../../lib/polygon":172,"../../registry":252,"./line_points":278,"./link_traces":280,"./subtypes":288,"d3":7}],285:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67686,7 +69417,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":290}],288:[function(_dereq_,module,exports){ +},{"./subtypes":288}],286:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67792,7 +69523,7 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],289:[function(_dereq_,module,exports){ +},{}],287:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67864,7 +69595,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":68,"../../registry":254,"d3":7}],290:[function(_dereq_,module,exports){ +},{"../../components/drawing":64,"../../registry":252,"d3":7}],288:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67903,7 +69634,7 @@ module.exports = { } }; -},{"../../lib":162}],291:[function(_dereq_,module,exports){ +},{"../../lib":160}],289:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67933,7 +69664,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":162}],292:[function(_dereq_,module,exports){ +},{"../../lib":160}],290:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -67942,34 +69673,32 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var Lib = _dereq_('../../lib'); var Registry = _dereq_('../../registry'); - module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { - var len, - x = coerce('x'), - y = coerce('y'); + var x = coerce('x'); + var y = coerce('y'); + var len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); if(x) { + var xlen = Lib.minRowLength(x); if(y) { - len = Math.min(x.length, y.length); - } - else { - len = x.length; + len = Math.min(xlen, Lib.minRowLength(y)); + } else { + len = xlen; coerce('y0'); coerce('dy'); } - } - else { + } else { if(!y) return 0; - len = traceOut.y.length; + len = Lib.minRowLength(y); coerce('x0'); coerce('dx'); } @@ -67979,7 +69708,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../registry":254}],293:[function(_dereq_,module,exports){ +},{"../../lib":160,"../../registry":252}],291:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68078,7 +69807,7 @@ module.exports = overrideAll({ }) }, 'calc', 'nested'); -},{"../../components/colorscale/attributes":50,"../../components/drawing/attributes":67,"../../lib/extend":155,"../../plot_api/edit_types":189,"../../plots/attributes":203,"../scatter/attributes":266}],294:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":50,"../../components/drawing/attributes":63,"../../lib/extend":153,"../../plot_api/edit_types":187,"../../plots/attributes":201,"../scatter/attributes":264}],292:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68120,7 +69849,7 @@ module.exports = function calc(gd, trace) { } arraysToCalcdata(calcTrace, trace); - calcMarkerColorscale(trace); + calcMarkerColorscale(gd, trace); calcSelection(calcTrace, trace); if(len) { @@ -68135,7 +69864,7 @@ module.exports = function calc(gd, trace) { return calcTrace; }; -},{"../../constants/numerical":143,"../../lib":162,"../scatter/arrays_to_calcdata":265,"../scatter/calc_selection":268,"../scatter/colorscale_calc":269,"fast-isnumeric":9}],295:[function(_dereq_,module,exports){ +},{"../../constants/numerical":140,"../../lib":160,"../scatter/arrays_to_calcdata":263,"../scatter/calc_selection":266,"../scatter/colorscale_calc":267,"fast-isnumeric":9}],293:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68231,7 +69960,7 @@ module.exports = overrideAll({ }) }, 'calc', 'nested'); -},{"../../components/colorbar/attributes":44,"../../lib/extend":155,"../../plot_api/edit_types":189,"../../plots/attributes":203,"../../plots/mapbox/layout_attributes":242,"../scatter/attributes":266,"../scattergeo/attributes":293}],296:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":44,"../../lib/extend":153,"../../plot_api/edit_types":187,"../../plots/attributes":201,"../../plots/mapbox/layout_attributes":240,"../scatter/attributes":264,"../scattergeo/attributes":291}],294:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68392,7 +70121,7 @@ function makeCircleOpts(calcTrace) { if(arrayColor) { if(Colorscale.hasColorscale(trace, 'marker')) { colorFn = Colorscale.makeColorScaleFunc( - Colorscale.extractScale(marker.colorscale, marker.cmin, marker.cmax) + Colorscale.extractScale(marker, {cLetter: 'c'}) ); } else { colorFn = Lib.identity; @@ -68525,7 +70254,7 @@ function isBADNUM(lonlat) { return lonlat[0] === BADNUM; } -},{"../../components/colorscale":58,"../../components/drawing":68,"../../constants/numerical":143,"../../lib":162,"../../lib/geojson_utils":158,"../../plots/mapbox/convert_text_opts":239,"../scatter/make_bubble_size_func":283,"../scatter/subtypes":290,"fast-isnumeric":9}],297:[function(_dereq_,module,exports){ +},{"../../components/colorscale":55,"../../components/drawing":64,"../../constants/numerical":140,"../../lib":160,"../../lib/geojson_utils":156,"../../plots/mapbox/convert_text_opts":237,"../scatter/make_bubble_size_func":281,"../scatter/subtypes":288,"fast-isnumeric":9}],295:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68597,7 +70326,7 @@ function handleLonLatDefaults(traceIn, traceOut, coerce) { return len; } -},{"../../lib":162,"../scatter/fillcolor_defaults":275,"../scatter/line_defaults":279,"../scatter/marker_defaults":285,"../scatter/subtypes":290,"../scatter/text_defaults":291,"./attributes":295}],298:[function(_dereq_,module,exports){ +},{"../../lib":160,"../scatter/fillcolor_defaults":273,"../scatter/line_defaults":277,"../scatter/marker_defaults":283,"../scatter/subtypes":288,"../scatter/text_defaults":289,"./attributes":293}],296:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68617,7 +70346,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],299:[function(_dereq_,module,exports){ +},{}],297:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68720,7 +70449,7 @@ function getExtraText(trace, di, labels) { return text.join('
'); } -},{"../../components/fx":85,"../../constants/numerical":143,"../../lib":162,"../scatter/fill_hover_text":274,"../scatter/get_trace_color":276}],300:[function(_dereq_,module,exports){ +},{"../../components/fx":82,"../../constants/numerical":140,"../../lib":160,"../scatter/fill_hover_text":272,"../scatter/get_trace_color":274}],298:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68761,7 +70490,7 @@ ScatterMapbox.meta = { module.exports = ScatterMapbox; -},{"../../plots/mapbox":240,"../scatter/marker_colorbar":284,"../scattergeo/calc":294,"./attributes":295,"./defaults":297,"./event_data":298,"./hover":299,"./plot":301,"./select":302}],301:[function(_dereq_,module,exports){ +},{"../../plots/mapbox":238,"../scatter/marker_colorbar":282,"../scattergeo/calc":292,"./attributes":293,"./defaults":295,"./event_data":296,"./hover":297,"./plot":299,"./select":300}],299:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68873,7 +70602,7 @@ module.exports = function createScatterMapbox(subplot, calcTrace) { return scatterMapbox; }; -},{"./convert":296}],302:[function(_dereq_,module,exports){ +},{"./convert":294}],300:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -68928,5 +70657,5 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"../../constants/numerical":143,"../../lib":162,"../scatter/subtypes":290}]},{},[4])(4) +},{"../../constants/numerical":140,"../../lib":160,"../scatter/subtypes":288}]},{},[4])(4) }); diff --git a/dist/plotly-mapbox.min.js b/dist/plotly-mapbox.min.js index 601b57eba4f..ae4d8241e0b 100644 --- a/dist/plotly-mapbox.min.js +++ b/dist/plotly-mapbox.min.js @@ -1,7 +1,7 @@ /** -* plotly.js (mapbox - minified) v1.42.5 +* plotly.js (mapbox - minified) v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,n,r){function i(o,s){if(!n[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[o]={exports:{}};e[o][0].call(c.exports,function(t){return i(e[o][1][t]||t)},c,c.exports,t,e,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;oplotly-logomark"}}},{}],3:[function(t,e,n){"use strict";e.exports=t("../src/core")},{"../src/core":145}],4:[function(t,e,n){"use strict";var r=t("./core");r.register([t("./scattermapbox")]),e.exports=r},{"./core":3,"./scattermapbox":5}],5:[function(t,e,n){"use strict";e.exports=t("../src/traces/scattermapbox")},{"../src/traces/scattermapbox":300}],6:[function(t,e,n){var r=Object.create||function(t){var e=function(){};return e.prototype=t,new e},i=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return n},a=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var s,l=10;try{var u={};Object.defineProperty&&Object.defineProperty(u,"x",{value:0}),s=0===u.x}catch(t){s=!1}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,n,i){var a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]):(o=t._events=r(null),t._eventsCount=0),s){if("function"==typeof s?s=o[e]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),!s.warned&&(a=c(t))&&a>0&&s.length>a){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=o[e]=n,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(n=o[t]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=g(t,r),a=0;a=0;o--)if(n[o]===e||n[o].listener===e){s=n[o].listener,a=o;break}if(a<0)return this;0===a?n.shift():function(t,e){for(var n=e,r=n+1,i=t.length;r=0;a--)this.removeListener(t,e[a]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},o.prototype.listenerCount=m,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],7:[function(t,e,n){!function(){var t={version:"3.5.17"},n=[].slice,r=function(t){return n.call(t)},i=this.document;function a(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(i)try{r(i.documentElement.childNodes)[0].nodeType}catch(t){r=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),i)try{i.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var s=this.Element.prototype,l=s.setAttribute,u=s.setAttributeNS,c=this.CSSStyleDeclaration.prototype,f=c.setProperty;s.setAttribute=function(t,e){l.call(this,t,e+"")},s.setAttributeNS=function(t,e,n){u.call(this,t,e,n+"")},c.setProperty=function(t,e,n){f.call(this,t,e+"",n)}}function h(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function d(t){return!isNaN(t)}function m(t){return{left:function(e,n,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=e.length);r>>1;t(e[a],n)<0?r=a+1:i=a}return r},right:function(e,n,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=e.length);r>>1;t(e[a],n)>0?i=a:r=a+1}return r}}}t.ascending=h,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var n,r,i=-1,a=t.length;if(1===arguments.length){for(;++i=r){n=r;break}for(;++ir&&(n=r)}else{for(;++i=r){n=r;break}for(;++ir&&(n=r)}return n},t.max=function(t,e){var n,r,i=-1,a=t.length;if(1===arguments.length){for(;++i=r){n=r;break}for(;++in&&(n=r)}else{for(;++i=r){n=r;break}for(;++in&&(n=r)}return n},t.extent=function(t,e){var n,r,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=i=r;break}for(;++ar&&(n=r),i=r){n=i=r;break}for(;++ar&&(n=r),i1)return o/(l-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var g=m(h);function y(t){return t.length}t.bisectLeft=g.left,t.bisect=t.bisectRight=g.right,t.bisector=function(t){return m(1===t.length?function(e,n){return h(t(e),n)}:t)},t.shuffle=function(t,e,n){(a=arguments.length)<3&&(n=t.length,a<2&&(e=0));for(var r,i,a=n-e;a;)i=Math.random()*a--|0,r=t[a+e],t[a+e]=t[i+e],t[i+e]=r;return t},t.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},t.pairs=function(t){for(var e=0,n=t.length-1,r=t[0],i=new Array(n<0?0:n);e=0;)for(e=(r=t[i]).length;--e>=0;)n[--o]=r[e];return n};var v=Math.abs;function _(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function x(){this._=Object.create(null)}t.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n==1/0)throw new Error("infinite range");var r,i=[],a=function(t){var e=1;for(;t*e%1;)e*=10;return e}(v(n)),o=-1;if(t*=a,e*=a,(n*=a)<0)for(;(r=t+n*++o)>e;)i.push(r/a);else for(;(r=t+n*++o)=i.length)return n?n.call(r,a):e?a.sort(e):a;for(var l,u,c,f,h=-1,p=a.length,d=i[s++],m=new x;++h=i.length)return e;var r=[],o=a[n++];return e.forEach(function(e,i){r.push({key:e,values:t(i,n)})}),o?r.sort(function(t,e){return o(t.key,e.key)}):r}(o(t.map,e,0),0)},r.key=function(t){return i.push(t),r},r.sortKeys=function(t){return a[i.length-1]=t,r},r.sortValues=function(t){return e=t,r},r.rollup=function(t){return n=t,r},r},t.set=function(t){var e=new E;if(t)for(var n=0,r=t.length;n=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},t.event=null,t.requote=function(t){return t.replace(V,"\\$&")};var V=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]};function U(t){return q(t,$),t}var H=function(t,e){return e.querySelector(t)},Z=function(t,e){return e.querySelectorAll(t)},G=function(t,e){var n=t.matches||t[P(t,"matchesSelector")];return(G=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(H=function(t,e){return Sizzle(t,e)[0]||null},Z=Sizzle,G=Sizzle.matchesSelector),t.selection=function(){return t.select(i.documentElement)};var $=t.selection.prototype=[];function W(t){return"function"==typeof t?t:function(){return H(t,this)}}function X(t){return"function"==typeof t?t:function(){return Z(t,this)}}$.select=function(t){var e,n,r,i,a=[];t=W(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),J.hasOwnProperty(n)?{space:J[n],local:t}:t}},$.attr=function(e,n){if(arguments.length<2){if("string"==typeof e){var r=this.node();return(e=t.ns.qualify(e)).local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}for(n in e)this.each(K(n,e[n]));return this}return this.each(K(e,n))},$.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=et(t)).length,i=-1;if(e=n.classList){for(;++i=0;)(n=r[i])&&(a&&a!==n.nextSibling&&a.parentNode.insertBefore(n,a),a=n);return this},$.sort=function(t){t=function(t){arguments.length||(t=h);return function(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}}.apply(this,arguments);for(var e=-1,n=this.length;++e0&&(e=e.slice(0,o));var l=dt.get(e);function u(){var t=this[a];t&&(this.removeEventListener(e,t,t.$),delete this[a])}return l&&(e=l,s=gt),o?n?function(){var t=s(n,r(arguments));u.call(this),this.addEventListener(e,this[a]=t,t.$=i),t._=n}:u:n?O:function(){var n,r=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var i in this)if(n=i.match(r)){var a=this[i];this.removeEventListener(n[1],a,a.$),delete this[i]}}}t.selection.enter=ft,t.selection.enter.prototype=ht,ht.append=$.append,ht.empty=$.empty,ht.node=$.node,ht.call=$.call,ht.size=$.size,ht.select=function(t){for(var e,n,r,i,a,o=[],s=-1,l=this.length;++s=r&&(r=e+1);!(o=s[r])&&++r0?1:t<0?-1:0}function It(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function Pt(t){return t>1?0:t<-1?At:Math.acos(t)}function Dt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function Ot(t){return((t=Math.exp(t))+1/t)/2}function Rt(t){return(t=Math.sin(t/2))*t}var Ft=Math.SQRT2;t.interpolateZoom=function(t,e){var n,r,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],u=e[2],c=s-i,f=l-a,h=c*c+f*f;if(h0&&(e=e.transition().duration(m)),e.call(w.event)}function S(){u&&u.domain(l.range().map(function(t){return(t-h.x)/h.k}).map(l.invert)),f&&f.domain(c.range().map(function(t){return(t-h.y)/h.k}).map(c.invert))}function C(t){g++||t({type:"zoomstart"})}function z(t){S(),t({type:"zoom",scale:h.k,translate:[h.x,h.y]})}function E(t){--g||(t({type:"zoomend"}),n=null)}function L(){var e=this,n=b.of(e,arguments),r=0,i=t.select(o(e)).on(v,function(){r=1,A(t.mouse(e),a),z(n)}).on(_,function(){i.on(v,null).on(_,null),s(r),E(n)}),a=k(t.mouse(e)),s=_t(e);fs.call(e),C(n)}function I(){var e,n=this,r=b.of(n,arguments),i={},a=0,o=".zoom-"+t.event.changedTouches[0].identifier,l="touchmove"+o,u="touchend"+o,c=[],f=t.select(n),p=_t(n);function d(){var r=t.touches(n);return e=h.k,r.forEach(function(t){t.identifier in i&&(i[t.identifier]=k(t))}),r}function m(){var e=t.event.target;t.select(e).on(l,g).on(u,v),c.push(e);for(var r=t.event.changedTouches,o=0,f=r.length;o1){y=p[0];var _=p[1],x=y[0]-_[0],b=y[1]-_[1];a=x*x+b*b}}function g(){var o,l,u,c,f=t.touches(n);fs.call(n);for(var h=0,p=f.length;h360?t-=360:t<0&&(t+=360),t<60?r+(i-r)*t/60:t<180?i:t<240?r+(i-r)*(240-t)/60:r}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,r=2*(n=n<0?0:n>1?1:n)-(i=n<=.5?n*(1+e):n+e-n*e),new ae(a(t+120),a(t),a(t-120))}function Zt(e,n,r){return this instanceof Zt?(this.h=+e,this.c=+n,void(this.l=+r)):arguments.length<2?e instanceof Zt?new Zt(e.h,e.c,e.l):ee(e instanceof Wt?e.l:(e=he((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Zt(e,n,r)}Ut.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Ut.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Ut.rgb=function(){return Ht(this.h,this.s,this.l)},t.hcl=Zt;var Gt=Zt.prototype=new Vt;function $t(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Wt(n,Math.cos(t*=zt)*e,Math.sin(t)*e)}function Wt(t,e,n){return this instanceof Wt?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof Wt?new Wt(t.l,t.a,t.b):t instanceof Zt?$t(t.h,t.c,t.l):he((t=ae(t)).r,t.g,t.b):new Wt(t,e,n)}Gt.brighter=function(t){return new Zt(this.h,this.c,Math.min(100,this.l+Xt*(arguments.length?t:1)))},Gt.darker=function(t){return new Zt(this.h,this.c,Math.max(0,this.l-Xt*(arguments.length?t:1)))},Gt.rgb=function(){return $t(this.h,this.c,this.l).rgb()},t.lab=Wt;var Xt=18,Yt=.95047,Jt=1,Kt=1.08883,Qt=Wt.prototype=new Vt;function te(t,e,n){var r=(t+16)/116,i=r+e/500,a=r-n/200;return new ae(ie(3.2404542*(i=ne(i)*Yt)-1.5371385*(r=ne(r)*Jt)-.4985314*(a=ne(a)*Kt)),ie(-.969266*i+1.8760108*r+.041556*a),ie(.0556434*i-.2040259*r+1.0572252*a))}function ee(t,e,n){return t>0?new Zt(Math.atan2(n,e)*Et,Math.sqrt(e*e+n*n),t):new Zt(NaN,NaN,t)}function ne(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function re(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ie(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ae(t,e,n){return this instanceof ae?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof ae?new ae(t.r,t.g,t.b):ce(""+t,ae,Ht):new ae(t,e,n)}function oe(t){return new ae(t>>16,t>>8&255,255&t)}function se(t){return oe(t)+""}Qt.brighter=function(t){return new Wt(Math.min(100,this.l+Xt*(arguments.length?t:1)),this.a,this.b)},Qt.darker=function(t){return new Wt(Math.max(0,this.l-Xt*(arguments.length?t:1)),this.a,this.b)},Qt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ae;var le=ae.prototype=new Vt;function ue(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ce(t,e,n){var r,i,a,o=0,s=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return n(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(de(i[0]),de(i[1]),de(i[2]))}return(a=me.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o|=o>>4,s=240&a,s|=s>>4,l=15&a,l|=l<<4):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function fe(t,e,n){var r,i,a=Math.min(t/=255,e/=255,n/=255),o=Math.max(t,e,n),s=o-a,l=(o+a)/2;return s?(i=l<.5?s/(o+a):s/(2-o-a),r=t==o?(e-n)/s+(e0&&l<1?0:r),new qt(r,i,l)}function he(t,e,n){var r=re((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(n=pe(n)))/Yt),i=re((.2126729*t+.7151522*e+.072175*n)/Jt);return Wt(116*i-16,500*(r-i),200*(i-re((.0193339*t+.119192*e+.9503041*n)/Kt)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function de(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}le.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,n=this.g,r=this.b,i=30;return e||n||r?(e&&e=200&&e<300||304===e){try{t=i.call(o,u)}catch(t){return void s.error.call(o,t)}s.load.call(o,t)}else s.error.call(o,u)}return!this.XDomainRequest||"withCredentials"in u||!/^(http(s)?:)?\/\//.test(e)||(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=f:u.onreadystatechange=function(){u.readyState>3&&f()},u.onprogress=function(e){var n=t.event;t.event=e;try{s.progress.call(o,u)}finally{t.event=n}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(n=null==t?null:t+"",o):n},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return i=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(r(arguments)))}}),o.send=function(t,r,i){if(2===arguments.length&&"function"==typeof r&&(i=r,r=null),u.open(t,e,!0),null==n||"accept"in l||(l.accept=n+",*/*"),u.setRequestHeader)for(var a in l)u.setRequestHeader(a,l[a]);return null!=n&&u.overrideMimeType&&u.overrideMimeType(n),null!=c&&(u.responseType=c),null!=i&&o.on("error",i).on("load",function(t){i(null,t)}),s.beforesend.call(o,u),u.send(null==r?null:r),o},o.abort=function(){return u.abort(),o},t.rebind(o,s,"on"),null==a?o:o.get(function(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}(a))}me.forEach(function(t,e){me.set(t,oe(e))}),t.functor=ge,t.xhr=ye(L),t.dsv=function(t,e){var n=new RegExp('["'+t+"\n]"),r=t.charCodeAt(0);function i(t,n,r){arguments.length<3&&(r=n,n=null);var i=ve(t,e,null==n?a:o(n),r);return i.row=function(t){return arguments.length?i.response(null==(n=t)?a:o(t)):n},i}function a(t){return i.parse(t.responseText)}function o(t){return function(e){return i.parse(e.responseText,t)}}function s(e){return e.map(l).join(t)}function l(t){return n.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,e){var n;return i.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,n){return e(i(t),n)}:i})},i.parseRows=function(t,e){var n,i,a={},o={},s=[],l=t.length,u=0,c=0;function f(){if(u>=l)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var n=e;n++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Ae,e)),be=0):(be=1,ke(Ae))}function Me(){for(var t=Date.now(),e=_e;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Se(){for(var t,e=_e,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}});t.formatPrefix=function(e,n){var r=0;return(e=+e)&&(e<0&&(e*=-1),n&&(e=t.round(e,Ce(e,n))),r=1+Math.floor(1e-12+Math.log(e)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ze[8+r/3]};var Ee=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Le=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,n){return(e=t.round(e,Ce(e,n))).toFixed(Math.max(0,Math.min(20,Ce(e*(1+1e-15),n))))}});function Ie(t){return t+""}var Pe=t.time={},De=Date;function Oe(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Oe.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Re.setUTCDate.apply(this._,arguments)},setDay:function(){Re.setUTCDay.apply(this._,arguments)},setFullYear:function(){Re.setUTCFullYear.apply(this._,arguments)},setHours:function(){Re.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Re.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Re.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Re.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Re.setUTCSeconds.apply(this._,arguments)},setTime:function(){Re.setTime.apply(this._,arguments)}};var Re=Date.prototype;function Fe(t,e,n){function r(e){var n=t(e),r=a(n,1);return e-n1)for(;o68?1900:2e3),n+i[0].length):-1}function Ye(t,e,n){return/^[+-]\d{4}$/.test(e=e.slice(n,n+5))?(t.Z=-e,n+5):-1}function Je(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Ke(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Qe(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function tn(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function en(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function nn(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function rn(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function an(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=v(e)/60|0,i=v(e)%60;return n+qe(r,"0",2)+qe(i,"0",2)}function on(t,e,n){Ve.lastIndex=0;var r=Ve.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function sn(t){for(var e=t.length,n=-1;++n0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(n-=s,n+s)),!((l+=s+1)>e));)s=i[o=(o+1)%i.length];return a.reverse().join(r)}:L;return function(e){var r=Ee.exec(e),i=r[1]||" ",s=r[2]||">",l=r[3]||"-",u=r[4]||"",c=r[5],f=+r[6],h=r[7],p=r[8],d=r[9],m=1,g="",y="",v=!1,_=!0;switch(p&&(p=+p.substring(1)),(c||"0"===i&&"="===s)&&(c=i="0",s="="),d){case"n":h=!0,d="g";break;case"%":m=100,y="%",d="f";break;case"p":m=100,y="%",d="r";break;case"b":case"o":case"x":case"X":"#"===u&&(g="0"+d.toLowerCase());case"c":_=!1;case"d":v=!0,p=0;break;case"s":m=-1,d="r"}"$"===u&&(g=a[0],y=a[1]),"r"!=d||p||(d="g"),null!=p&&("g"==d?p=Math.max(1,Math.min(21,p)):"e"!=d&&"f"!=d||(p=Math.max(0,Math.min(20,p)))),d=Le.get(d)||Ie;var x=c&&h;return function(e){var r=y;if(v&&e%1)return"";var a=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===l?"":l;if(m<0){var u=t.formatPrefix(e,p);e=u.scale(e),r=u.symbol+y}else e*=m;var b,w,k=(e=d(e,p)).lastIndexOf(".");if(k<0){var T=_?e.lastIndexOf("e"):-1;T<0?(b=e,w=""):(b=e.substring(0,T),w=e.substring(T))}else b=e.substring(0,k),w=n+e.substring(k+1);!c&&h&&(b=o(b,1/0));var A=g.length+b.length+w.length+(x?0:a.length),M=A"===s?M+a+e:"^"===s?M.substring(0,A>>=1)+a+e+M.substring(A):a+(x?e:M+e))+r}}}(e),timeFormat:function(e){var n=e.dateTime,r=e.date,i=e.time,a=e.periods,o=e.days,s=e.shortDays,l=e.months,u=e.shortMonths;function c(t){var e=t.length;function n(n){for(var r,i,a,o=[],s=-1,l=0;++s=u)return-1;if(37===(i=e.charCodeAt(s++))){if(o=e.charAt(s++),!(a=w[o in Ne?e.charAt(s++):o])||(r=a(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}c.utc=function(t){var e=c(t);function n(t){try{var n=new(De=Oe);return n._=t,e(n)}finally{De=Date}}return n.parse=function(t){try{De=Oe;var n=e.parse(t);return n&&n._}finally{De=Date}},n.toString=e.toString,n},c.multi=c.utc.multi=sn;var h=t.map(),p=Ue(o),d=He(o),m=Ue(s),g=He(s),y=Ue(l),v=He(l),_=Ue(u),x=He(u);a.forEach(function(t,e){h.set(t.toLowerCase(),e)});var b={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:c(n),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+Pe.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return a[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(Pe.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(Pe.mondayOfYear(t),e,2)},x:c(r),X:c(i),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:an,"%":function(){return"%"}},w={a:function(t,e,n){m.lastIndex=0;var r=m.exec(e.slice(n));return r?(t.w=g.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){p.lastIndex=0;var r=p.exec(e.slice(n));return r?(t.w=d.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){_.lastIndex=0;var r=_.exec(e.slice(n));return r?(t.m=x.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){y.lastIndex=0;var r=y.exec(e.slice(n));return r?(t.m=v.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,e,n){return f(t,b.c.toString(),e,n)},d:Ke,e:Ke,H:tn,I:tn,j:Qe,L:rn,m:Je,M:en,p:function(t,e,n){var r=h.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)},S:nn,U:Ge,w:Ze,W:$e,x:function(t,e,n){return f(t,b.x.toString(),e,n)},X:function(t,e,n){return f(t,b.X.toString(),e,n)},y:Xe,Y:We,Z:Ye,"%":on};return c}(e)}};var ln=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function un(){}t.format=ln.numberFormat,t.geo={},un.prototype={s:0,t:0,add:function(t){fn(t,this.t,cn),fn(cn.s,this.s,this),this.s?this.t+=cn.t:this.s=cn.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cn=new un;function fn(t,e,n){var r=n.s=t+e,i=r-t,a=r-i;n.t=t-a+(e-i)}function hn(t,e){t&&dn.hasOwnProperty(t.type)&&dn[t.type](t,e)}t.geo.stream=function(t,e){t&&pn.hasOwnProperty(t.type)?pn[t.type](t,e):hn(t,e)};var pn={Feature:function(t,e){hn(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r=0?1:-1,s=o*a,l=Math.cos(e),u=Math.sin(e),c=i*u,f=r*l+c*Math.cos(s),h=c*o*Math.sin(s);zn.add(Math.atan2(h,f)),n=t,r=l,i=u}En.point=function(o,s){En.point=a,n=(t=o)*zt,r=Math.cos(s=(e=s)*zt/2+At/4),i=Math.sin(s)},En.lineEnd=function(){a(t,e)}}function In(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function Pn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Dn(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function On(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Rn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Fn(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Bn(t){return[Math.atan2(t[1],t[0]),Dt(t[2])]}function Nn(t,e){return v(t[0]-e[0])kt?i=90:u<-kt&&(n=-90),f[0]=e,f[1]=r}};function p(t,a){c.push(f=[e=t,r=t]),ai&&(i=a)}function d(t,o){var s=In([t*zt,o*zt]);if(l){var u=Dn(l,s),c=Dn([u[1],-u[0],0],u);Fn(c),c=Bn(c);var f=t-a,h=f>0?1:-1,d=c[0]*Et*h,m=v(f)>180;if(m^(h*ai&&(i=g);else if(m^(h*a<(d=(d+360)%360-180)&&di&&(i=o);m?tb(e,r)&&(r=t):b(t,r)>b(e,r)&&(e=t):r>=e?(tr&&(r=t)):t>a?b(e,t)>b(e,r)&&(r=t):b(t,r)>b(e,r)&&(e=t)}else p(t,o);l=s,a=t}function m(){h.point=d}function g(){f[0]=e,f[1]=r,h.point=p,l=null}function y(t,e){if(l){var n=t-a;u+=v(n)>180?n+(n>0?360:-360):n}else o=t,s=e;En.point(t,e),d(t,e)}function _(){En.lineStart()}function x(){y(o,s),En.lineEnd(),v(u)>kt&&(e=-(r=180)),f[0]=e,f[1]=r,l=null}function b(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tb(m[0],m[1])&&(m[1]=p[1]),b(p[0],m[1])>b(m[0],m[1])&&(m[0]=p[0])):s.push(m=p);for(var l,u,p,d=-1/0,m=(o=0,s[u=s.length-1]);o<=u;m=p,++o)p=s[o],(l=b(m[1],p[0]))>d&&(d=l,e=p[0],r=m[1])}return c=f=null,e===1/0||n===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,n],[r,i]]}}(),t.geo.centroid=function(e){vn=_n=xn=bn=wn=kn=Tn=An=Mn=Sn=Cn=0,t.geo.stream(e,jn);var n=Mn,r=Sn,i=Cn,a=n*n+r*r+i*i;return a=0;--s)i.point((f=c[s])[0],f[1]);else r(p.x,p.p.x,-1,i);p=p.p}c=(p=p.o).z,d=!d}while(!p.v);i.lineEnd()}}}function Xn(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r=0?1:-1,k=w*b,T=k>At,A=d*_;if(zn.add(Math.atan2(A*w*Math.sin(k),m*x+A*Math.cos(k))),a+=T?b+w*Mt:b,T^h>=n^y>=n){var M=Dn(In(f),In(t));Fn(M);var S=Dn(i,M);Fn(S);var C=(T^b>=0?-1:1)*Dt(S[2]);(r>C||r===C&&(M[0]||M[1]))&&(o+=T^b>=0?1:-1)}if(!g++)break;h=y,d=_,m=x,f=t}}return(a<-kt||a0){for(_||(o.polygonStart(),_=!0),o.lineStart();++a1&&2&e&&n.push(n.pop().concat(n.shift())),s.push(n.filter(Kn))}return c}}function Kn(t){return t.length>1}function Qn(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:O,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function tr(t,e){return((t=t.x)[0]<0?t[1]-Ct-kt:Ct-t[1])-((e=e.x)[0]<0?e[1]-Ct-kt:Ct-e[1])}var er=Jn($n,function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?At:-At,l=v(a-n);v(l-At)0?Ct:-Ct),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(a,r),e=0):i!==s&&l>=At&&(v(n-i)kt?Math.atan((Math.sin(e)*(a=Math.cos(r))*Math.sin(n)-Math.sin(r)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+r)/2}(n,r,a,o),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),e=0),t.point(n=a,r=o),i=s},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}},function(t,e,n,r){var i;if(null==t)i=n*Ct,r.point(-At,i),r.point(0,i),r.point(At,i),r.point(At,0),r.point(At,-i),r.point(0,-i),r.point(-At,-i),r.point(-At,0),r.point(-At,i);else if(v(t[0]-e[0])>kt){var a=t[0]0)){if(a/=h,h<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=n-l,h||!(a<0)){if(a/=h,h<0){if(a>f)return;a>c&&(c=a)}else if(h>0){if(a0)){if(a/=p,p<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=r-u,p||!(a<0)){if(a/=p,p<0){if(a>f)return;a>c&&(c=a)}else if(p>0){if(a0&&(i.a={x:l+c*h,y:u+c*p}),f<1&&(i.b={x:l+f*h,y:u+f*p}),i}}}}}}var rr=1e9;function ir(e,n,r,i){return function(l){var u,c,f,h,p,d,m,g,y,v,_,x=l,b=Qn(),w=nr(e,n,r,i),k={point:M,lineStart:function(){k.point=S,c&&c.push(f=[]);v=!0,y=!1,m=g=NaN},lineEnd:function(){u&&(S(h,p),d&&y&&b.rejoin(),u.push(b.buffer()));k.point=M,y&&l.lineEnd()},polygonStart:function(){l=b,u=[],c=[],_=!0},polygonEnd:function(){l=x,u=t.merge(u);var n=function(t){for(var e=0,n=c.length,r=t[1],i=0;ir&&It(u,a,t)>0&&++e:a[1]<=r&&It(u,a,t)<0&&--e,u=a;return 0!==e}([e,i]),r=_&&n,a=u.length;(r||a)&&(l.polygonStart(),r&&(l.lineStart(),T(null,null,1,l),l.lineEnd()),a&&Wn(u,o,n,T,l),l.polygonEnd()),u=c=f=null}};function T(t,o,l,u){var c=0,f=0;if(null==t||(c=a(t,l))!==(f=a(o,l))||s(t,o)<0^l>0)do{u.point(0===c||3===c?e:r,c>1?i:n)}while((c=(c+l+4)%4)!==f);else u.point(o[0],o[1])}function A(t,a){return e<=t&&t<=r&&n<=a&&a<=i}function M(t,e){A(t,e)&&l.point(t,e)}function S(t,e){var n=A(t=Math.max(-rr,Math.min(rr,t)),e=Math.max(-rr,Math.min(rr,e)));if(c&&f.push([t,e]),v)h=t,p=e,d=n,v=!1,n&&(l.lineStart(),l.point(t,e));else if(n&&y)l.point(t,e);else{var r={a:{x:m,y:g},b:{x:t,y:e}};w(r)?(y||(l.lineStart(),l.point(r.a.x,r.a.y)),l.point(r.b.x,r.b.y),n||l.lineEnd(),_=!1):n&&(l.lineStart(),l.point(t,e),_=!1)}m=t,g=e,y=n}return k};function a(t,i){return v(t[0]-e)0?0:3:v(t[0]-r)0?2:1:v(t[1]-n)0?1:0:i>0?3:2}function o(t,e){return s(t.x,e.x)}function s(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}}function ar(t){var e=0,n=At/3,r=zr(t),i=r(e,n);return i.parallels=function(t){return arguments.length?r(e=t[0]*At/180,n=t[1]*At/180):[e/At*180,n/At*180]},i}function or(t,e){var n=Math.sin(t),r=(n+Math.sin(e))/2,i=1+n*(2*r-n),a=Math.sqrt(i)/r;function o(t,e){var n=Math.sqrt(i-2*r*Math.sin(e))/r;return[n*Math.sin(t*=r),a-n*Math.cos(t)]}return o.invert=function(t,e){var n=a-e;return[Math.atan2(t,n)/r,Dt((i-(t*t+n*n)*r*r)/(2*r))]},o}t.geo.clipExtent=function(){var t,e,n,r,i,a,o={stream:function(t){return i&&(i.valid=!1),(i=a(t)).valid=!0,i},extent:function(s){return arguments.length?(a=ir(t=+s[0][0],e=+s[0][1],n=+s[1][0],r=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[n,r]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return ar(or)}).raw=or,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,n,r,i,a=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,n){e=[t,n]}};function u(t){var a=t[0],o=t[1];return e=null,n(a,o),e||(r(a,o),e)||i(a,o),e}return u.invert=function(t){var e=a.scale(),n=a.translate(),r=(t[0]-n[0])/e,i=(t[1]-n[1])/e;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?o:i>=.166&&i<.234&&r>=-.214&&r<-.115?s:a).invert(t)},u.stream=function(t){var e=a.stream(t),n=o.stream(t),r=s.stream(t);return{point:function(t,i){e.point(t,i),n.point(t,i),r.point(t,i)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},u.precision=function(t){return arguments.length?(a.precision(t),o.precision(t),s.precision(t),u):a.precision()},u.scale=function(t){return arguments.length?(a.scale(t),o.scale(.35*t),s.scale(t),u.translate(a.translate())):a.scale()},u.translate=function(t){if(!arguments.length)return a.translate();var e=a.scale(),c=+t[0],f=+t[1];return n=a.translate(t).clipExtent([[c-.455*e,f-.238*e],[c+.455*e,f+.238*e]]).stream(l).point,r=o.translate([c-.307*e,f+.201*e]).clipExtent([[c-.425*e+kt,f+.12*e+kt],[c-.214*e-kt,f+.234*e-kt]]).stream(l).point,i=s.translate([c-.205*e,f+.212*e]).clipExtent([[c-.214*e+kt,f+.166*e+kt],[c-.115*e-kt,f+.234*e-kt]]).stream(l).point,u},u.scale(1070)};var sr,lr,ur,cr,fr,hr,pr={point:O,lineStart:O,lineEnd:O,polygonStart:function(){lr=0,pr.lineStart=dr},polygonEnd:function(){pr.lineStart=pr.lineEnd=pr.point=O,sr+=v(lr/2)}};function dr(){var t,e,n,r;function i(t,e){lr+=r*t-n*e,n=t,r=e}pr.point=function(a,o){pr.point=i,t=n=a,e=r=o},pr.lineEnd=function(){i(t,e)}}var mr={point:function(t,e){tfr&&(fr=t);ehr&&(hr=e)},lineStart:O,lineEnd:O,polygonStart:O,polygonEnd:O};function gr(){var t=yr(4.5),e=[],n={point:r,lineStart:function(){n.point=i},lineEnd:o,polygonStart:function(){n.lineEnd=s},polygonEnd:function(){n.lineEnd=o,n.point=r},pointRadius:function(e){return t=yr(e),n},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function r(n,r){e.push("M",n,",",r,t)}function i(t,r){e.push("M",t,",",r),n.point=a}function a(t,n){e.push("L",t,",",n)}function o(){n.point=r}function s(){e.push("Z")}return n}function yr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var vr,_r={point:xr,lineStart:br,lineEnd:wr,polygonStart:function(){_r.lineStart=kr},polygonEnd:function(){_r.point=xr,_r.lineStart=br,_r.lineEnd=wr}};function xr(t,e){xn+=t,bn+=e,++wn}function br(){var t,e;function n(n,r){var i=n-t,a=r-e,o=Math.sqrt(i*i+a*a);kn+=o*(t+n)/2,Tn+=o*(e+r)/2,An+=o,xr(t=n,e=r)}_r.point=function(r,i){_r.point=n,xr(t=r,e=i)}}function wr(){_r.point=xr}function kr(){var t,e,n,r;function i(t,e){var i=t-n,a=e-r,o=Math.sqrt(i*i+a*a);kn+=o*(n+t)/2,Tn+=o*(r+e)/2,An+=o,Mn+=(o=r*t-n*e)*(n+t),Sn+=o*(r+e),Cn+=3*o,xr(n=t,r=e)}_r.point=function(a,o){_r.point=i,xr(t=n=a,e=r=o)},_r.lineEnd=function(){i(t,e)}}function Tr(t){var e=4.5,n={point:r,lineStart:function(){n.point=i},lineEnd:o,polygonStart:function(){n.lineEnd=s},polygonEnd:function(){n.lineEnd=o,n.point=r},pointRadius:function(t){return e=t,n},result:O};function r(n,r){t.moveTo(n+e,r),t.arc(n,r,e,0,Mt)}function i(e,r){t.moveTo(e,r),n.point=a}function a(e,n){t.lineTo(e,n)}function o(){n.point=r}function s(){t.closePath()}return n}function Ar(t){var e=.5,n=Math.cos(30*zt),r=16;function i(e){return(r?function(e){var n,i,o,s,l,u,c,f,h,p,d,m,g={point:y,lineStart:v,lineEnd:x,polygonStart:function(){e.polygonStart(),g.lineStart=b},polygonEnd:function(){e.polygonEnd(),g.lineStart=v}};function y(n,r){n=t(n,r),e.point(n[0],n[1])}function v(){f=NaN,g.point=_,e.lineStart()}function _(n,i){var o=In([n,i]),s=t(n,i);a(f,h,c,p,d,m,f=s[0],h=s[1],c=n,p=o[0],d=o[1],m=o[2],r,e),e.point(f,h)}function x(){g.point=y,e.lineEnd()}function b(){v(),g.point=w,g.lineEnd=k}function w(t,e){_(n=t,e),i=f,o=h,s=p,l=d,u=m,g.point=_}function k(){a(f,h,c,p,d,m,i,o,n,s,l,u,r,e),g.lineEnd=x,x()}return g}:function(e){return Sr(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})})(e)}function a(r,i,o,s,l,u,c,f,h,p,d,m,g,y){var _=c-r,x=f-i,b=_*_+x*x;if(b>4*e&&g--){var w=s+p,k=l+d,T=u+m,A=Math.sqrt(w*w+k*k+T*T),M=Math.asin(T/=A),S=v(v(T)-1)e||v((_*L+x*I)/b-.5)>.3||s*p+l*d+u*m0&&16,i):Math.sqrt(e)},i}function Mr(t){this.stream=t}function Sr(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Cr(t){return zr(function(){return t})()}function zr(e){var n,r,i,a,o,s,l=Ar(function(t,e){return[(t=n(t,e))[0]*u+a,o-t[1]*u]}),u=150,c=480,f=250,h=0,p=0,d=0,m=0,g=0,y=er,_=L,x=null,b=null;function w(t){return[(t=i(t[0]*zt,t[1]*zt))[0]*u+a,o-t[1]*u]}function k(t){return(t=i.invert((t[0]-a)/u,(o-t[1])/u))&&[t[0]*Et,t[1]*Et]}function T(){i=Gn(r=Pr(d,m,g),n);var t=n(h,p);return a=c-t[0]*u,o=f+t[1]*u,A()}function A(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Er(y(r,l(_(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(y=null==t?(x=t,er):function(t){var e=Math.cos(t),n=e>0,r=v(e)>kt;return Jn(i,function(t){var e,s,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(f,h){var p,d=[f,h],m=i(f,h),g=n?m?0:o(f,h):m?o(f+(f<0?At:-At),h):0;if(!e&&(u=l=m)&&t.lineStart(),m!==l&&(p=a(e,d),(Nn(e,p)||Nn(d,p))&&(d[0]+=kt,d[1]+=kt,m=i(d[0],d[1]))),m!==l)c=0,m?(t.lineStart(),p=a(d,e),t.point(p[0],p[1])):(p=a(e,d),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(r&&e&&n^m){var y;g&s||!(y=a(d,e,!0))||(c=0,n?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!m||e&&Nn(e,d)||t.point(d[0],d[1]),e=d,l=m,s=g},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return c|(u&&l)<<1}}},Fr(t,6*zt),n?[0,-t]:[-At,t-At]);function i(t,n){return Math.cos(t)*Math.cos(n)>e}function a(t,n,r){var i=[1,0,0],a=Dn(In(t),In(n)),o=Pn(a,a),s=a[0],l=o-s*s;if(!l)return!r&&t;var u=e*o/l,c=-e*s/l,f=Dn(i,a),h=Rn(i,u);On(h,Rn(a,c));var p=f,d=Pn(h,p),m=Pn(p,p),g=d*d-m*(Pn(h,h)-1);if(!(g<0)){var y=Math.sqrt(g),_=Rn(p,(-d-y)/m);if(On(_,h),_=Bn(_),!r)return _;var x,b=t[0],w=n[0],k=t[1],T=n[1];w0^_[1]<(v(_[0]-b)At^(b<=_[0]&&_[0]<=w)){var S=Rn(p,(-d+y)/m);return On(S,h),[_,Bn(S)]}}}function o(e,r){var i=n?t:At-t,a=0;return e<-i?a|=1:e>i&&(a|=2),r<-i?a|=4:r>i&&(a|=8),a}}((x=+t)*zt),A()):x},w.clipExtent=function(t){return arguments.length?(b=t,_=t?ir(t[0][0],t[0][1],t[1][0],t[1][1]):L,A()):b},w.scale=function(t){return arguments.length?(u=+t,T()):u},w.translate=function(t){return arguments.length?(c=+t[0],f=+t[1],T()):[c,f]},w.center=function(t){return arguments.length?(h=t[0]%360*zt,p=t[1]%360*zt,T()):[h*Et,p*Et]},w.rotate=function(t){return arguments.length?(d=t[0]%360*zt,m=t[1]%360*zt,g=t.length>2?t[2]%360*zt:0,T()):[d*Et,m*Et,g*Et]},t.rebind(w,l,"precision"),function(){return n=e.apply(this,arguments),w.invert=n.invert&&k,T()}}function Er(t){return Sr(t,function(e,n){t.point(e*zt,n*zt)})}function Lr(t,e){return[t,e]}function Ir(t,e){return[t>At?t-Mt:t<-At?t+Mt:t,e]}function Pr(t,e,n){return t?e||n?Gn(Or(t),Rr(e,n)):Or(t):e||n?Rr(e,n):Ir}function Dr(t){return function(e,n){return[(e+=t)>At?e-Mt:e<-At?e+Mt:e,n]}}function Or(t){var e=Dr(t);return e.invert=Dr(-t),e}function Rr(t,e){var n=Math.cos(t),r=Math.sin(t),i=Math.cos(e),a=Math.sin(e);function o(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*n+s*r;return[Math.atan2(l*i-c*a,s*n-u*r),Dt(c*i+l*a)]}return o.invert=function(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*i-l*a;return[Math.atan2(l*i+u*a,s*n+c*r),Dt(c*n-s*r)]},o}function Fr(t,e){var n=Math.cos(t),r=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=Br(n,i),a=Br(n,a),(o>0?ia)&&(i+=o*Mt)):(i=t+o*Mt,a=t-.5*l);for(var u,c=i;o>0?c>a:c2?t[2]*zt:0),e.invert=function(e){return(e=t.invert(e[0]*zt,e[1]*zt))[0]*=Et,e[1]*=Et,e},e},Ir.invert=Lr,t.geo.circle=function(){var t,e,n=[0,0],r=6;function i(){var t="function"==typeof n?n.apply(this,arguments):n,r=Pr(-t[0]*zt,-t[1]*zt,0).invert,i=[];return e(null,null,1,{point:function(t,e){i.push(t=r(t,e)),t[0]*=Et,t[1]*=Et}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(n=t,i):n},i.angle=function(n){return arguments.length?(e=Fr((t=+n)*zt,r*zt),i):t},i.precision=function(n){return arguments.length?(e=Fr(t*zt,(r=+n)*zt),i):r},i.angle(90)},t.geo.distance=function(t,e){var n,r=(e[0]-t[0])*zt,i=t[1]*zt,a=e[1]*zt,o=Math.sin(r),s=Math.cos(r),l=Math.sin(i),u=Math.cos(i),c=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((n=f*o)*n+(n=u*c-l*f*s)*n),l*c+u*f*s)},t.geo.graticule=function(){var e,n,r,i,a,o,s,l,u,c,f,h,p=10,d=p,m=90,g=360,y=2.5;function _(){return{type:"MultiLineString",coordinates:x()}}function x(){return t.range(Math.ceil(i/m)*m,r,m).map(f).concat(t.range(Math.ceil(l/g)*g,s,g).map(h)).concat(t.range(Math.ceil(n/p)*p,e,p).filter(function(t){return v(t%m)>kt}).map(u)).concat(t.range(Math.ceil(o/d)*d,a,d).filter(function(t){return v(t%g)>kt}).map(c))}return _.lines=function(){return x().map(function(t){return{type:"LineString",coordinates:t}})},_.outline=function(){return{type:"Polygon",coordinates:[f(i).concat(h(s).slice(1),f(r).reverse().slice(1),h(l).reverse().slice(1))]}},_.extent=function(t){return arguments.length?_.majorExtent(t).minorExtent(t):_.minorExtent()},_.majorExtent=function(t){return arguments.length?(i=+t[0][0],r=+t[1][0],l=+t[0][1],s=+t[1][1],i>r&&(t=i,i=r,r=t),l>s&&(t=l,l=s,s=t),_.precision(y)):[[i,l],[r,s]]},_.minorExtent=function(t){return arguments.length?(n=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],n>e&&(t=n,n=e,e=t),o>a&&(t=o,o=a,a=t),_.precision(y)):[[n,o],[e,a]]},_.step=function(t){return arguments.length?_.majorStep(t).minorStep(t):_.minorStep()},_.majorStep=function(t){return arguments.length?(m=+t[0],g=+t[1],_):[m,g]},_.minorStep=function(t){return arguments.length?(p=+t[0],d=+t[1],_):[p,d]},_.precision=function(t){return arguments.length?(y=+t,u=Nr(o,a,90),c=jr(n,e,y),f=Nr(l,s,90),h=jr(i,r,y),_):y},_.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,n,r=Vr,i=qr;function a(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||i.apply(this,arguments)]}}return a.distance=function(){return t.geo.distance(e||r.apply(this,arguments),n||i.apply(this,arguments))},a.source=function(t){return arguments.length?(r=t,e="function"==typeof t?null:t,a):r},a.target=function(t){return arguments.length?(i=t,n="function"==typeof t?null:t,a):i},a.precision=function(){return arguments.length?a:0},a},t.geo.interpolate=function(t,e){return n=t[0]*zt,r=t[1]*zt,i=e[0]*zt,a=e[1]*zt,o=Math.cos(r),s=Math.sin(r),l=Math.cos(a),u=Math.sin(a),c=o*Math.cos(n),f=o*Math.sin(n),h=l*Math.cos(i),p=l*Math.sin(i),d=2*Math.asin(Math.sqrt(Rt(a-r)+o*l*Rt(i-n))),m=1/Math.sin(d),(g=d?function(t){var e=Math.sin(t*=d)*m,n=Math.sin(d-t)*m,r=n*c+e*h,i=n*f+e*p,a=n*s+e*u;return[Math.atan2(i,r)*Et,Math.atan2(a,Math.sqrt(r*r+i*i))*Et]}:function(){return[n*Et,r*Et]}).distance=d,g;var n,r,i,a,o,s,l,u,c,f,h,p,d,m,g},t.geo.length=function(e){return vr=0,t.geo.stream(e,Ur),vr};var Ur={sphere:O,point:O,lineStart:function(){var t,e,n;function r(r,i){var a=Math.sin(i*=zt),o=Math.cos(i),s=v((r*=zt)-t),l=Math.cos(s);vr+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-e*o*l)*s),e*a+n*o*l),t=r,e=a,n=o}Ur.point=function(i,a){t=i*zt,e=Math.sin(a*=zt),n=Math.cos(a),Ur.point=r},Ur.lineEnd=function(){Ur.point=Ur.lineEnd=O}},lineEnd:O,polygonStart:O,polygonEnd:O};function Hr(t,e){function n(e,n){var r=Math.cos(e),i=Math.cos(n),a=t(r*i);return[a*i*Math.sin(e),a*Math.sin(n)]}return n.invert=function(t,n){var r=Math.sqrt(t*t+n*n),i=e(r),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,r*o),Math.asin(r&&n*a/r)]},n}var Zr=Hr(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Cr(Zr)}).raw=Zr;var Gr=Hr(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},L);function $r(t,e){var n=Math.cos(t),r=function(t){return Math.tan(At/4+t/2)},i=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(r(e)/r(t)),a=n*Math.pow(r(t),i)/i;if(!i)return Yr;function o(t,e){a>0?e<-Ct+kt&&(e=-Ct+kt):e>Ct-kt&&(e=Ct-kt);var n=a/Math.pow(r(e),i);return[n*Math.sin(i*t),a-n*Math.cos(i*t)]}return o.invert=function(t,e){var n=a-e,r=Lt(i)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/i,2*Math.atan(Math.pow(a/r,1/i))-Ct]},o}function Wr(t,e){var n=Math.cos(t),r=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),i=n/r+t;if(v(r)1&&It(t[n[r-2]],t[n[r-1]],t[i])<=0;)--r;n[r++]=i}return n.slice(0,r)}function ii(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Cr(Qr)}).raw=Qr,ti.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ct]},(t.geo.transverseMercator=function(){var t=Jr(ti),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):[(t=n())[0],t[1],t[2]-90]},n([0,0,90])}).raw=ti,t.geom={},t.geom.hull=function(t){var e=ei,n=ni;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,i=ge(e),a=ge(n),o=t.length,s=[],l=[];for(r=0;r=0;--r)p.push(t[s[u[r]][2]]);for(r=+f;rkt)s=s.L;else{if(!((i=a-wi(s,o))>kt)){r>-kt?(e=s.P,n=s):i>-kt?(e=s,n=s.N):e=n=s;break}if(!s.R){e=s;break}s=s.R}var l=yi(t);if(fi.insert(e,l),e||n){if(e===n)return Si(e),n=yi(e.site),fi.insert(l,n),l.edge=n.edge=Ei(e.site,l.site),Mi(e),void Mi(n);if(n){Si(e),Si(n);var u=e.site,c=u.x,f=u.y,h=t.x-c,p=t.y-f,d=n.site,m=d.x-c,g=d.y-f,y=2*(h*g-p*m),v=h*h+p*p,_=m*m+g*g,x={x:(g*v-p*_)/y+c,y:(h*_-m*v)/y+f};Li(n.edge,u,d,x),l.edge=Ei(u,t,null,x),n.edge=Ei(t,d,null,x),Mi(e),Mi(n)}else l.edge=Ei(e.site,l.site)}}function bi(t,e){var n=t.site,r=n.x,i=n.y,a=i-e;if(!a)return r;var o=t.P;if(!o)return-1/0;var s=(n=o.site).x,l=n.y,u=l-e;if(!u)return s;var c=s-r,f=1/a-1/u,h=c/u;return f?(-h+Math.sqrt(h*h-2*f*(c*c/(-2*u)-l+u/2+i-a/2)))/f+r:(r+s)/2}function wi(t,e){var n=t.N;if(n)return bi(n,e);var r=t.site;return r.y===e?r.x:1/0}function ki(t){this.site=t,this.edges=[]}function Ti(t,e){return e.angle-t.angle}function Ai(){Di(this),this.x=this.y=this.arc=this.site=this.cy=null}function Mi(t){var e=t.P,n=t.N;if(e&&n){var r=e.site,i=t.site,a=n.site;if(r!==a){var o=i.x,s=i.y,l=r.x-o,u=r.y-s,c=a.x-o,f=2*(l*(g=a.y-s)-u*c);if(!(f>=-Tt)){var h=l*l+u*u,p=c*c+g*g,d=(g*h-u*p)/f,m=(l*p-c*h)/f,g=m+s,y=mi.pop()||new Ai;y.arc=t,y.site=i,y.x=d+o,y.y=g+Math.sqrt(d*d+m*m),y.cy=g,t.circle=y;for(var v=null,_=pi._;_;)if(y.y<_.y||y.y===_.y&&y.x<=_.x){if(!_.L){v=_.P;break}_=_.L}else{if(!_.R){v=_;break}_=_.R}pi.insert(v,y),v||(hi=y)}}}}function Si(t){var e=t.circle;e&&(e.P||(hi=e.N),pi.remove(e),mi.push(e),Di(e),t.circle=null)}function Ci(t,e){var n=t.b;if(n)return!0;var r,i,a=t.a,o=e[0][0],s=e[1][0],l=e[0][1],u=e[1][1],c=t.l,f=t.r,h=c.x,p=c.y,d=f.x,m=f.y,g=(h+d)/2,y=(p+m)/2;if(m===p){if(g=s)return;if(h>d){if(a){if(a.y>=u)return}else a={x:g,y:l};n={x:g,y:u}}else{if(a){if(a.y1)if(h>d){if(a){if(a.y>=u)return}else a={x:(l-i)/r,y:l};n={x:(u-i)/r,y:u}}else{if(a){if(a.y=s)return}else a={x:o,y:r*o+i};n={x:s,y:r*s+i}}else{if(a){if(a.xkt||v(i-n)>kt)&&(s.splice(o,0,new Ii((y=a.site,_=c,x=v(r-f)kt?{x:f,y:v(e-f)kt?{x:v(n-d)kt?{x:h,y:v(e-h)kt?{x:v(n-p)=n&&u.x<=i&&u.y>=r&&u.y<=o?[[n,o],[i,o],[i,r],[n,r]]:[]).point=t[s]}),e}function s(t){return t.map(function(t,e){return{x:Math.round(r(t,e)/kt)*kt,y:Math.round(i(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Bi(s(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Bi(s(t)).cells.forEach(function(n,r){for(var i,a,o,s,l=n.site,u=n.edges.sort(Ti),c=-1,f=u.length,h=u[f-1].edge,p=h.l===l?h.r:h.l;++ca&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,l.push({i:o,x:Zi(n,r)})),a=Wi.lastIndex;return am&&(m=l.x),l.y>g&&(g=l.y),u.push(l.x),c.push(l.y);else for(f=0;fm&&(m=x),b>g&&(g=b),u.push(x),c.push(b)}var w=m-p,k=g-d;function T(t,e,n,r,i,a,o,s){if(!isNaN(n)&&!isNaN(r))if(t.leaf){var l=t.x,u=t.y;if(null!=l)if(v(l-n)+v(u-r)<.01)A(t,e,n,r,i,a,o,s);else{var c=t.point;t.x=t.y=t.point=null,A(t,c,l,u,i,a,o,s),A(t,e,n,r,i,a,o,s)}else t.x=n,t.y=r,t.point=e}else A(t,e,n,r,i,a,o,s)}function A(t,e,n,r,i,a,o,s){var l=.5*(i+o),u=.5*(a+s),c=n>=l,f=r>=u,h=f<<1|c;t.leaf=!1,c?i=l:o=l,f?a=u:s=u,T(t=t.nodes[h]||(t.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(M,t,+y(t,++f),+_(t,f),p,d,m,g)}}),e,n,r,i,a,o,s)}w>k?g=d+w:m=p+k;var M={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(M,t,+y(t,++f),+_(t,f),p,d,m,g)}};if(M.visit=function(t){!function t(e,n,r,i,a,o){if(!e(n,r,i,a,o)){var s=.5*(r+a),l=.5*(i+o),u=n.nodes;u[0]&&t(e,u[0],r,i,s,l),u[1]&&t(e,u[1],s,i,a,l),u[2]&&t(e,u[2],r,l,s,o),u[3]&&t(e,u[3],s,l,a,o)}}(t,M,p,d,m,g)},M.find=function(t){return function(t,e,n,r,i,a,o){var s,l=1/0;return function t(u,c,f,h,p){if(!(c>a||f>o||h=b)<<1|e>=x,k=w+4;w=0&&!(r=t.interpolators[i](e,n)););return r}function Yi(t,e){var n,r=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(n=0;n=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function aa(t){return 1-Math.cos(t*Ct)}function oa(t){return Math.pow(2,10*(t-1))}function sa(t){return 1-Math.sqrt(1-t*t)}function la(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ua(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function ca(t){var e,n,r,i=[t.a,t.b],a=[t.c,t.d],o=ha(i),s=fa(i,a),l=ha(((e=a)[0]+=(r=-s)*(n=i)[0],e[1]+=r*n[1],e))||0;i[0]*a[1]=0?t.slice(0,r):t,a=r>=0?t.slice(r+1):"in";return i=Ki.get(i)||Ji,a=Qi.get(a)||L,e=a(i.apply(null,n.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,n){e=t.hcl(e),n=t.hcl(n);var r=e.h,i=e.c,a=e.l,o=n.h-r,s=n.c-i,l=n.l-a;isNaN(s)&&(s=0,i=isNaN(i)?n.c:i);isNaN(o)?(o=0,r=isNaN(r)?n.h:r):o>180?o-=360:o<-180&&(o+=360);return function(t){return $t(r+o*t,i+s*t,a+l*t)+""}},t.interpolateHsl=function(e,n){e=t.hsl(e),n=t.hsl(n);var r=e.h,i=e.s,a=e.l,o=n.h-r,s=n.s-i,l=n.l-a;isNaN(s)&&(s=0,i=isNaN(i)?n.s:i);isNaN(o)?(o=0,r=isNaN(r)?n.h:r):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ht(r+o*t,i+s*t,a+l*t)+""}},t.interpolateLab=function(e,n){e=t.lab(e),n=t.lab(n);var r=e.l,i=e.a,a=e.b,o=n.l-r,s=n.a-i,l=n.b-a;return function(t){return te(r+o*t,i+s*t,a+l*t)+""}},t.interpolateRound=ua,t.transform=function(e){var n=i.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){n.setAttribute("transform",t);var e=n.transform.baseVal.consolidate()}return new ca(e?e.matrix:pa)})(e)},ca.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pa={a:1,b:0,c:0,d:1,e:0,f:0};function da(t){return t.length?t.pop()+",":""}function ma(e,n){var r=[],i=[];return e=t.transform(e),n=t.transform(n),function(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var i=n.push("translate(",null,",",null,")");r.push({i:i-4,x:Zi(t[0],e[0])},{i:i-2,x:Zi(t[1],e[1])})}else(e[0]||e[1])&&n.push("translate("+e+")")}(e.translate,n.translate,r,i),function(t,e,n,r){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(da(n)+"rotate(",null,")")-2,x:Zi(t,e)})):e&&n.push(da(n)+"rotate("+e+")")}(e.rotate,n.rotate,r,i),function(t,e,n,r){t!==e?r.push({i:n.push(da(n)+"skewX(",null,")")-2,x:Zi(t,e)}):e&&n.push(da(n)+"skewX("+e+")")}(e.skew,n.skew,r,i),function(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var i=n.push(da(n)+"scale(",null,",",null,")");r.push({i:i-4,x:Zi(t[0],e[0])},{i:i-2,x:Zi(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(da(n)+"scale("+e+")")}(e.scale,n.scale,r,i),e=n=null,function(t){for(var e,n=-1,a=i.length;++n0?r=t:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:r=0})):t>0&&(l.start({type:"start",alpha:r=t}),e=Te(s.tick)),s):r},s.start=function(){var t,e,n,r=y.length,l=v.length,c=u[0],d=u[1];for(t=0;t=0;)n.push(i[r])}function za(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++o=0;)o.push(c=u[l]),c.parent=a,c.depth=a.depth+1;n&&(a.value=0),a.children=u}else n&&(a.value=+n.call(r,a,a.depth)||0),delete a.children;return za(i,function(e){var r,i;t&&(r=e.children)&&r.sort(t),n&&(i=e.parent)&&(i.value+=e.value)}),s}return r.sort=function(e){return arguments.length?(t=e,r):t},r.children=function(t){return arguments.length?(e=t,r):e},r.value=function(t){return arguments.length?(n=t,r):n},r.revalue=function(t){return n&&(Ca(t,function(t){t.children&&(t.value=0)}),za(t,function(t){var e;t.children||(t.value=+n.call(r,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},r},t.layout.partition=function(){var e=t.layout.hierarchy(),n=[1,1];function r(t,r){var i=e.call(this,t,r);return function t(e,n,r,i){var a=e.children;if(e.x=n,e.y=e.depth*i,e.dx=r,e.dy=i,a&&(o=a.length)){var o,s,l,u=-1;for(r=e.value?r/e.value:0;++us&&(s=r),o.push(r)}for(n=0;ni&&(r=n,i=e);return r}function Ua(t){return t.reduce(Ha,0)}function Ha(t,e){return t+e[1]}function Za(t,e){return Ga(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Ga(t,e){for(var n=-1,r=+t[0],i=(t[1]-r)/e,a=[];++n<=e;)a[n]=i*n+r;return a}function $a(e){return[t.min(e),t.max(e)]}function Wa(t,e){return t.value-e.value}function Xa(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ya(t,e){t._pack_next=e,e._pack_prev=t}function Ja(t,e){var n=e.x-t.x,r=e.y-t.y,i=t.r+e.r;return.999*i*i>n*n+r*r}function Ka(t){if((e=t.children)&&(l=e.length)){var e,n,r,i,a,o,s,l,u=1/0,c=-1/0,f=1/0,h=-1/0;if(e.forEach(Qa),(n=e[0]).x=-n.r,n.y=0,_(n),l>1&&((r=e[1]).x=r.r,r.y=0,_(r),l>2))for(eo(n,r,i=e[2]),_(i),Xa(n,i),n._pack_prev=i,Xa(i,r),r=n._pack_next,a=3;a0)for(o=-1;++o=f[0]&&l<=f[1]&&((s=u[t.bisect(h,l,1,d)-1]).y+=m,s.push(a[o]));return u}return a.value=function(t){return arguments.length?(n=t,a):n},a.range=function(t){return arguments.length?(r=ge(t),a):r},a.bins=function(t){return arguments.length?(i="number"==typeof t?function(e){return Ga(e,t)}:ge(t),a):i},a.frequency=function(t){return arguments.length?(e=!!t,a):e},a},t.layout.pack=function(){var e,n=t.layout.hierarchy().sort(Wa),r=0,i=[1,1];function a(t,a){var o=n.call(this,t,a),s=o[0],l=i[0],u=i[1],c=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,za(s,function(t){t.r=+c(t.value)}),za(s,Ka),r){var f=r*(e?1:Math.max(2*s.r/l,2*s.r/u))/2;za(s,function(t){t.r+=f}),za(s,Ka),za(s,function(t){t.r-=f})}return function t(e,n,r,i){var a=e.children;e.x=n+=i*e.x;e.y=r+=i*e.y;e.r*=i;if(a)for(var o=-1,s=a.length;++op.x&&(p=t),t.depth>d.depth&&(d=t)});var m=n(h,p)/2-h.x,g=r[0]/(p.x+n(p,h)/2+m),y=r[1]/(d.depth||1);Ca(c,function(t){t.x=(t.x+m)*g,t.y=t.depth*y})}return u}function o(t){var e=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(e.length){!function(t){var e,n=0,r=0,i=t.children,a=i.length;for(;--a>=0;)(e=i[a]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}(t);var a=(e[0].z+e[e.length-1].z)/2;i?(t.z=i.z+n(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+n(t._,i._));t.parent.A=function(t,e,r){if(e){for(var i,a=t,o=t,s=e,l=a.parent.children[0],u=a.m,c=o.m,f=s.m,h=l.m;s=io(s),a=ro(a),s&&a;)l=ro(l),(o=io(o)).a=t,(i=s.z+f-a.z-u+n(s._,a._))>0&&(ao(oo(s,t,r),t,i),u+=i,c+=i),f+=s.m,u+=a.m,h+=l.m,c+=o.m;s&&!io(o)&&(o.t=s,o.m+=f-c),a&&!ro(l)&&(l.t=a,l.m+=u-h,r=t)}return r}(t,i,t.parent.A||r[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function l(t){t.x*=r[0],t.y=t.depth*r[1]}return a.separation=function(t){return arguments.length?(n=t,a):n},a.size=function(t){return arguments.length?(i=null==(r=t)?l:null,a):i?null:r},a.nodeSize=function(t){return arguments.length?(i=null==(r=t)?null:l,a):i?r:null},Sa(a,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),n=no,r=[1,1],i=!1;function a(a,o){var s,l=e.call(this,a,o),u=l[0],c=0;za(u,function(e){var r=e.children;r&&r.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(r),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(r)):(e.x=s?c+=n(e,s):0,e.y=0,s=e)});var f=function t(e){var n=e.children;return n&&n.length?t(n[0]):e}(u),h=function t(e){var n,r=e.children;return r&&(n=r.length)?t(r[n-1]):e}(u),p=f.x-n(f,h)/2,d=h.x+n(h,f)/2;return za(u,i?function(t){t.x=(t.x-u.x)*r[0],t.y=(u.y-t.y)*r[1]}:function(t){t.x=(t.x-p)/(d-p)*r[0],t.y=(1-(u.y?t.y/u.y:1))*r[1]}),l}return a.separation=function(t){return arguments.length?(n=t,a):n},a.size=function(t){return arguments.length?(i=null==(r=t),a):i?null:r},a.nodeSize=function(t){return arguments.length?(i=null!=(r=t),a):i?r:null},Sa(a,e)},t.layout.treemap=function(){var e,n=t.layout.hierarchy(),r=Math.round,i=[1,1],a=null,o=so,s=!1,l="squarify",u=.5*(1+Math.sqrt(5));function c(t,e){for(var n,r,i=-1,a=t.length;++i0;)s.push(n=u[i-1]),s.area+=n.area,"squarify"!==l||(r=p(s,m))<=h?(u.pop(),h=r):(s.area-=s.pop().area,d(s,m,a,!1),m=Math.min(a.dx,a.dy),s.length=s.area=0,h=1/0);s.length&&(d(s,m,a,!0),s.length=s.area=0),e.forEach(f)}}function h(t){var e=t.children;if(e&&e.length){var n,r=o(t),i=e.slice(),a=[];for(c(i,r.dx*r.dy/t.value),a.area=0;n=i.pop();)a.push(n),a.area+=n.area,null!=n.z&&(d(a,n.z?r.dx:r.dy,r,!i.length),a.length=a.area=0);e.forEach(h)}}function p(t,e){for(var n,r=t.area,i=0,a=1/0,o=-1,s=t.length;++oi&&(i=n));return e*=e,(r*=r)?Math.max(e*i*u/r,r/(e*a*u)):1/0}function d(t,e,n,i){var a,o=-1,s=t.length,l=n.x,u=n.y,c=e?r(t.area/e):0;if(e==n.dx){for((i||c>n.dy)&&(c=n.dy);++on.dx)&&(c=n.dx);++o1);return t+e*n*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var n=t.random.irwinHall(e);return function(){return n()/e}},irwinHall:function(t){return function(){for(var e=0,n=0;n2?go:fo,s=i?ya:ga;return a=t(e,n,s,r),o=t(n,e,s,Xi),l}function l(t){return a(t)}l.invert=function(t){return o(t)};l.domain=function(t){return arguments.length?(e=t.map(Number),s()):e};l.range=function(t){return arguments.length?(n=t,s()):n};l.rangeRound=function(t){return l.range(t).interpolate(ua)};l.clamp=function(t){return arguments.length?(i=t,s()):i};l.interpolate=function(t){return arguments.length?(r=t,s()):r};l.ticks=function(t){return xo(e,t)};l.tickFormat=function(t,n){return bo(e,t,n)};l.nice=function(t){return vo(e,t),s()};l.copy=function(){return t(e,n,r,i)};return s()}([0,1],[0,1],Xi,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(n,r,i,a){function o(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(r)}function s(t){return i?Math.pow(r,t):-Math.pow(r,-t)}function l(t){return n(o(t))}l.invert=function(t){return s(n.invert(t))};l.domain=function(t){return arguments.length?(i=t[0]>=0,n.domain((a=t.map(Number)).map(o)),l):a};l.base=function(t){return arguments.length?(r=+t,n.domain(a.map(o)),l):r};l.nice=function(){var t=ho(a.map(o),i?Math:Ao);return n.domain(t),a=t.map(s),l};l.ticks=function(){var t=uo(a),e=[],n=t[0],l=t[1],u=Math.floor(o(n)),c=Math.ceil(o(l)),f=r%1?2:r;if(isFinite(c-u)){if(i){for(;u0;h--)e.push(s(u)*h);for(u=0;e[u]l;c--);e=e.slice(u,c)}return e};l.tickFormat=function(e,n){if(!arguments.length)return To;arguments.length<2?n=To:"function"!=typeof n&&(n=t.format(n));var i=Math.max(1,r*e/l.ticks().length);return function(t){var e=t/s(Math.round(o(t)));return e*r0?i[t-1]:n[0],tf?0:1;if(u=St)return l(u,p)+(s?l(s,1-p):"")+"Z";var d,m,g,y,v,_,x,b,w,k,T,A,M=0,S=0,C=[];if((y=(+o.apply(this,arguments)||0)/2)&&(g=r===Io?Math.sqrt(s*s+u*u):+r.apply(this,arguments),p||(S*=-1),u&&(S=Dt(g/u*Math.sin(y))),s&&(M=Dt(g/s*Math.sin(y)))),u){v=u*Math.cos(c+S),_=u*Math.sin(c+S),x=u*Math.cos(f-S),b=u*Math.sin(f-S);var z=Math.abs(f-c-2*S)<=At?0:1;if(S&&Bo(v,_,x,b)===p^z){var E=(c+f)/2;v=u*Math.cos(E),_=u*Math.sin(E),x=b=null}}else v=_=0;if(s){w=s*Math.cos(f-M),k=s*Math.sin(f-M),T=s*Math.cos(c+M),A=s*Math.sin(c+M);var L=Math.abs(c-f+2*M)<=At?0:1;if(M&&Bo(w,k,T,A)===1-p^L){var I=(c+f)/2;w=s*Math.cos(I),k=s*Math.sin(I),T=A=null}}else w=k=0;if(h>kt&&(d=Math.min(Math.abs(u-s)/2,+n.apply(this,arguments)))>.001){m=s0?0:1}function No(t,e,n,r,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?r:-r)/Math.sqrt(a*a+o*o),l=s*o,u=-s*a,c=t[0]+l,f=t[1]+u,h=e[0]+l,p=e[1]+u,d=(c+h)/2,m=(f+p)/2,g=h-c,y=p-f,v=g*g+y*y,_=n-r,x=c*p-h*f,b=(y<0?-1:1)*Math.sqrt(Math.max(0,_*_*v-x*x)),w=(x*y-g*b)/v,k=(-x*g-y*b)/v,T=(x*y+g*b)/v,A=(-x*g+y*b)/v,M=w-d,S=k-m,C=T-d,z=A-m;return M*M+S*S>C*C+z*z&&(w=T,k=A),[[w-l,k-u],[w*n/_,k*n/_]]}function jo(t){var e=ei,n=ni,r=$n,i=qo,a=i.key,o=.7;function s(a){var s,l=[],u=[],c=-1,f=a.length,h=ge(e),p=ge(n);function d(){l.push("M",i(t(u),o))}for(;++c1&&i.push("H",r[0]);return i.join("")},"step-before":Ho,"step-after":Zo,basis:Wo,"basis-open":function(t){if(t.length<4)return qo(t);var e,n=[],r=-1,i=t.length,a=[0],o=[0];for(;++r<3;)e=t[r],a.push(e[0]),o.push(e[1]);n.push(Xo(Ko,a)+","+Xo(Ko,o)),--r;for(;++r9&&(i=3*e/Math.sqrt(i),o[s]=i*n,o[s+1]=i*r));s=-1;for(;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Uo(t){return t.join("L")+"Z"}function Ho(t){for(var e=0,n=t.length,r=t[0],i=[r[0],",",r[1]];++e1){s=e[1],a=t[l],l++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var u=2;uAt)+",1 "+e}function l(t,e,n,r){return"Q 0,0 "+r}return a.radius=function(t){return arguments.length?(n=ge(t),a):n},a.source=function(e){return arguments.length?(t=ge(e),a):t},a.target=function(t){return arguments.length?(e=ge(t),a):e},a.startAngle=function(t){return arguments.length?(r=ge(t),a):r},a.endAngle=function(t){return arguments.length?(i=ge(t),a):i},a},t.svg.diagonal=function(){var t=Vr,e=qr,n=is;function r(r,i){var a=t.call(this,r,i),o=e.call(this,r,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(n))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return r.source=function(e){return arguments.length?(t=ge(e),r):t},r.target=function(t){return arguments.length?(e=ge(t),r):e},r.projection=function(t){return arguments.length?(n=t,r):n},r},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),n=is,r=e.projection;return e.projection=function(t){return arguments.length?r(function(t){return function(){var e=t.apply(this,arguments),n=e[0],r=e[1]-Ct;return[n*Math.cos(r),n*Math.sin(r)]}}(n=t)):n},e},t.svg.symbol=function(){var t=os,e=as;function n(n,r){return(ls.get(t.call(this,n,r))||ss)(e.call(this,n,r))}return n.type=function(e){return arguments.length?(t=ge(e),n):t},n.size=function(t){return arguments.length?(e=ge(t),n):e},n};var ls=t.map({circle:ss,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*cs)),n=e*cs;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/us),n=e*us/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/us),n=e*us/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});t.svg.symbolTypes=ls.keys();var us=Math.sqrt(3),cs=Math.tan(30*zt);$.transition=function(t){for(var e,n,r=ds||++ys,i=xs(t),a=[],o=ms||{time:Date.now(),ease:ia,delay:0,duration:250},s=-1,l=this.length;++s0;)u[--h].call(t,o);if(a>=1)return f.event&&f.event.end.call(t,t.__data__,e),--c.count?delete c[r]:delete t[n],1}f||(a=i.time,o=Te(function(t){var e=f.delay;if(o.t=e+a,e<=t)return h(t-e);o.c=h},0,a),f=c[r]={tween:new x,time:a,timer:o,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++c.count)}gs.call=$.call,gs.empty=$.empty,gs.node=$.node,gs.size=$.size,t.transition=function(e,n){return e&&e.transition?ds?e.transition(n):e:t.selection().transition(e)},t.transition.prototype=gs,gs.select=function(t){var e,n,r,i=this.id,a=this.namespace,o=[];t=W(t);for(var s=-1,l=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function m(t){t.select(".extent").attr("y",l[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function g(){var f,g,y=this,v=t.select(t.event.target),_=r.of(y,arguments),x=t.select(y),b=v.datum(),w=!/^(n|s)$/.test(b)&&i,k=!/^(e|w)$/.test(b)&&a,T=v.classed("extent"),A=_t(y),M=t.mouse(y),S=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(T||(f=null,M[0]-=s[1],M[1]-=l[1],T=2),B())}).on("keyup.brush",function(){32==t.event.keyCode&&2==T&&(M[0]+=s[1],M[1]+=l[1],T=0,B())});if(t.event.changedTouches?S.on("touchmove.brush",E).on("touchend.brush",I):S.on("mousemove.brush",E).on("mouseup.brush",I),x.interrupt().selectAll("*").interrupt(),T)M[0]=s[0]-M[0],M[1]=l[0]-M[1];else if(b){var C=+/w$/.test(b),z=+/^n/.test(b);g=[s[1-C]-M[0],l[1-z]-M[1]],M[0]=s[C],M[1]=l[z]}else t.event.altKey&&(f=M.slice());function E(){var e=t.mouse(y),n=!1;g&&(e[0]+=g[0],e[1]+=g[1]),T||(t.event.altKey?(f||(f=[(s[0]+s[1])/2,(l[0]+l[1])/2]),M[0]=s[+(e[0]1?{floor:function(e){for(;s(e=t.floor(e));)e=Ps(e-1);return e},ceil:function(e){for(;s(e=t.ceil(e));)e=Ps(+e+1);return e}}:t))},i.ticks=function(t,e){var n=uo(i.domain()),r=null==t?a(n,10):"number"==typeof t?a(n,t):!t.range&&[{range:t},e];return r&&(t=r[0],e=r[1]),t.range(n[0],Ps(+n[1]+1),e<1?1:e)},i.tickFormat=function(){return r},i.copy=function(){return Is(e.copy(),n,r)},yo(i,e)}function Ps(t){return new Date(t)}Cs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ls:Es,Ls.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Ls.toString=Es.toString,Pe.second=Fe(function(t){return new De(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),Pe.seconds=Pe.second.range,Pe.seconds.utc=Pe.second.utc.range,Pe.minute=Fe(function(t){return new De(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),Pe.minutes=Pe.minute.range,Pe.minutes.utc=Pe.minute.utc.range,Pe.hour=Fe(function(t){var e=t.getTimezoneOffset()/60;return new De(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),Pe.hours=Pe.hour.range,Pe.hours.utc=Pe.hour.utc.range,Pe.month=Fe(function(t){return(t=Pe.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),Pe.months=Pe.month.range,Pe.months.utc=Pe.month.utc.range;var Ds=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Os=[[Pe.second,1],[Pe.second,5],[Pe.second,15],[Pe.second,30],[Pe.minute,1],[Pe.minute,5],[Pe.minute,15],[Pe.minute,30],[Pe.hour,1],[Pe.hour,3],[Pe.hour,6],[Pe.hour,12],[Pe.day,1],[Pe.day,2],[Pe.week,1],[Pe.month,1],[Pe.month,3],[Pe.year,1]],Rs=Cs.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",$n]]),Fs={range:function(e,n,r){return t.range(Math.ceil(e/r)*r,+n,r).map(Ps)},floor:L,ceil:L};Os.year=Pe.year,Pe.scale=function(){return Is(t.scale.linear(),Os,Rs)};var Bs=Os.map(function(t){return[t[0].utc,t[1]]}),Ns=zs.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",$n]]);function js(t){return JSON.parse(t.responseText)}function Vs(t){var e=i.createRange();return e.selectNode(i.body),e.createContextualFragment(t.responseText)}Bs.year=Pe.year.utc,Pe.scale.utc=function(){return Is(t.scale.linear(),Bs,Ns)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return ve(t,"application/json",js,e)},t.html=function(t,e){return ve(t,"text/html",Vs,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],8:[function(t,e,n){(function(r,i){!function(t,r){"object"==typeof n&&"undefined"!=typeof e?e.exports=r():t.ES6Promise=r()}(this,function(){"use strict";function e(t){return"function"==typeof t}var n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},a=0,o=void 0,s=void 0,l=function(t,e){m[a]=t,m[a+1]=e,2===(a+=2)&&(s?s(g):b())};var u="undefined"!=typeof window?window:void 0,c=u||{},f=c.MutationObserver||c.WebKitMutationObserver,h="undefined"==typeof self&&"undefined"!=typeof r&&"[object process]"==={}.toString.call(r),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(g,1)}}var m=new Array(1e3);function g(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],15:[function(t,e,n){(function(t){!function(t,r){"object"==typeof n&&"undefined"!=typeof e?e.exports=r():t.mapboxgl=r()}(this,function(){"use strict";var e,n,r;function i(t,i){if(e)if(n){var a="var sharedChunk = {}; ("+e+")(sharedChunk); ("+n+")(sharedChunk);",o={};e(o),(r=i(o)).workerUrl=window.URL.createObjectURL(new Blob([a],{type:"text/javascript"}))}else n=i;else e=i}return i(0,function(e){var n="undefined"!=typeof window?window:"undefined"!=typeof t?t:"undefined"!=typeof self?self:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t,e){return t(e={exports:{}},e.exports),e.exports}var a=o;function o(t,e,n,r){this.cx=3*t,this.bx=3*(n-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=r,this.p2x=n,this.p2y=r}o.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},o.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},o.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},o.prototype.solveCurveX=function(t,e){var n,r,i,a,o;for(void 0===e&&(e=1e-6),i=t,o=0;o<8;o++){if(a=this.sampleCurveX(i)-t,Math.abs(a)(r=1))return r;for(;na?n=i:r=i,i=.5*(r-n)+n}return i},o.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var s=function(t,e,n){this.column=t,this.row=e,this.zoom=n};s.prototype.clone=function(){return new s(this.column,this.row,this.zoom)},s.prototype.zoomTo=function(t){return this.clone()._zoomTo(t)},s.prototype.sub=function(t){return this.clone()._sub(t)},s.prototype._zoomTo=function(t){var e=Math.pow(2,t-this.zoom);return this.column*=e,this.row*=e,this.zoom=t,this},s.prototype._sub=function(t){return t=t.zoomTo(this.zoom),this.column-=t.column,this.row-=t.row,this};var l=u;function u(t,e){this.x=t,this.y=e}function c(t,e,n,r){var i=new a(t,e,n,r);return function(t){return i.solve(t)}}u.prototype={clone:function(){return new u(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),r=e*this.x-n*this.y,i=n*this.x+e*this.y;return this.x=r,this.y=i,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),i=e.x+n*(this.x-e.x)-r*(this.y-e.y),a=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=i,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},u.convert=function(t){return t instanceof u?t:Array.isArray(t)?new u(t[0],t[1]):t};var f=c(.25,.1,.25,1);function h(t,e,n){return Math.min(n,Math.max(e,t))}function p(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r(e.y-t.y)*(n.x-t.x)}function k(t){for(var e=0,n=0,r=t.length,i=r-1,a=void 0,o=void 0;n=200&&n.status<300&&n.response?e(null,{data:r,cacheControl:n.getResponseHeader("Cache-Control"),expires:n.getResponseHeader("Expires")}):e(new A(n.statusText,n.status,t.url))},n.send(),n};function C(t,e,n){n[t]=n[t]||[],n[t].push(e)}function z(t,e,n){if(n&&n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}var E=function(t,e){void 0===e&&(e={}),p(this,e),this.type=t},L=function(t){function e(e,n){void 0===n&&(n={}),t.call(this,"error",p({error:e},n))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(E),I=function(){};I.prototype.on=function(t,e){return this._listeners=this._listeners||{},C(t,e,this._listeners),this},I.prototype.off=function(t,e){return z(t,e,this._listeners),z(t,e,this._oneTimeListeners),this},I.prototype.once=function(t,e){return this._oneTimeListeners=this._oneTimeListeners||{},C(t,e,this._oneTimeListeners),this},I.prototype.fire=function(t){"string"==typeof t&&(t=new E(t,arguments[1]||{}));var e=t.type;if(this.listens(e)){t.target=this;for(var n=0,r=this._listeners&&this._listeners[e]?this._listeners[e].slice():[];n0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)},I.prototype.setEventedParent=function(t,e){return this._eventedParent=t,this._eventedParentData=e,this};var P={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},buffer:{type:"number",default:128,maximum:512,minimum:0},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},lineMetrics:{type:"boolean",default:!1}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_fill:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_circle:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_line:{"line-cap":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{butt:{},round:{},square:{}},default:"butt"},"line-join":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{bevel:{},round:{},miter:{}},default:"miter"},"line-miter-limit":{type:"number",default:2,function:"interpolated","zoom-function":!0,requires:[{"line-join":"miter"}]},"line-round-limit":{type:"number",default:1.05,function:"interpolated","zoom-function":!0,requires:[{"line-join":"round"}]},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_symbol:{"symbol-placement":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{point:{},line:{}},default:"point"},"symbol-spacing":{type:"number",default:250,minimum:1,function:"interpolated","zoom-function":!0,units:"pixels",requires:[{"symbol-placement":"line"}]},"symbol-avoid-edges":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1},"icon-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image"]},"icon-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image"]},"icon-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image","text-field"]},"icon-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"]},"icon-size":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,units:"factor of the original icon size",requires:["icon-image"]},"icon-text-fit":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"]},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",function:"interpolated","zoom-function":!0,requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}]},"icon-image":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,tokens:!0},"icon-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,"property-function":!0,units:"degrees",requires:["icon-image"]},"icon-padding":{type:"number",default:2,minimum:0,function:"interpolated","zoom-function":!0,units:"pixels",requires:["icon-image"]},"icon-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":"line"}]},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,requires:["icon-image"]},"icon-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"]},"icon-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"]},"text-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"]},"text-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"]},"text-field":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:"",tokens:!0},"text-font":{type:"array",value:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"]},"text-size":{type:"number",default:16,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-line-height":{type:"number",default:1.2,units:"ems",function:"interpolated","zoom-function":!0,requires:["text-field"]},"text-letter-spacing":{type:"number",default:0,units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-justify":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{left:{},center:{},right:{}},default:"center",requires:["text-field"]},"text-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field"]},"text-max-angle":{type:"number",default:45,units:"degrees",function:"interpolated","zoom-function":!0,requires:["text-field",{"symbol-placement":"line"}]},"text-rotate":{type:"number",default:0,period:360,units:"degrees",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,requires:["text-field"]},"text-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":"line"}]},"text-transform":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"]},"text-offset":{type:"array",value:"number",units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,length:2,default:[0,0],requires:["text-field"]},"text-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field"]},"text-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field"]},"text-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field","icon-image"]},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function_stop:{type:"array",minimum:0,maximum:22,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},expression_name:{type:"enum",values:{let:{group:"Variable binding"},var:{group:"Variable binding"},literal:{group:"Types"},array:{group:"Types"},at:{group:"Lookup"},case:{group:"Decision"},match:{group:"Decision"},coalesce:{group:"Decision"},step:{group:"Ramps, scales, curves"},interpolate:{group:"Ramps, scales, curves"},ln2:{group:"Math"},pi:{group:"Math"},e:{group:"Math"},typeof:{group:"Types"},string:{group:"Types"},number:{group:"Types"},boolean:{group:"Types"},object:{group:"Types"},collator:{group:"Types"},"to-string":{group:"Types"},"to-number":{group:"Types"},"to-boolean":{group:"Types"},"to-rgba":{group:"Color"},"to-color":{group:"Types"},rgb:{group:"Color"},rgba:{group:"Color"},get:{group:"Lookup"},has:{group:"Lookup"},length:{group:"Lookup"},properties:{group:"Feature data"},"geometry-type":{group:"Feature data"},id:{group:"Feature data"},zoom:{group:"Zoom"},"heatmap-density":{group:"Heatmap"},"line-progress":{group:"Heatmap"},"+":{group:"Math"},"*":{group:"Math"},"-":{group:"Math"},"/":{group:"Math"},"%":{group:"Math"},"^":{group:"Math"},sqrt:{group:"Math"},log10:{group:"Math"},ln:{group:"Math"},log2:{group:"Math"},sin:{group:"Math"},cos:{group:"Math"},tan:{group:"Math"},asin:{group:"Math"},acos:{group:"Math"},atan:{group:"Math"},min:{group:"Math"},max:{group:"Math"},round:{group:"Math"},abs:{group:"Math"},ceil:{group:"Math"},floor:{group:"Math"},"==":{group:"Decision"},"!=":{group:"Decision"},">":{group:"Decision"},"<":{group:"Decision"},">=":{group:"Decision"},"<=":{group:"Decision"},all:{group:"Decision"},any:{group:"Decision"},"!":{group:"Decision"},"is-supported-script":{group:"String"},upcase:{group:"String"},downcase:{group:"String"},concat:{group:"String"},"resolved-locale":{group:"String"}}},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},transition:!1,"zoom-function":!0,"property-function":!1,function:"piecewise-constant"},position:{type:"array",default:[1.15,210,30],length:3,value:"number",transition:!0,function:"interpolated","zoom-function":!0,"property-function":!1},color:{type:"color",default:"#ffffff",function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0},intensity:{type:"number",default:.5,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!0},"fill-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"fill-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"}]},"fill-outline-color":{type:"color",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}]},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"fill-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["fill-translate"]},"fill-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0}},paint_line:{"line-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"line-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"line-pattern"}]},"line-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"line-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["line-translate"]},"line-width":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-gap-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-offset":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-dasharray":{type:"array",value:"number",function:"piecewise-constant","zoom-function":!0,minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}]},"line-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"line-gradient":{type:"color",function:"interpolated","zoom-function":!1,"property-function":!1,transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}]}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-blur":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"circle-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["circle-translate"]},"circle-pitch-scale":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map"},"circle-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"viewport"},"circle-stroke-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-stroke-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"heatmap-weight":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!1},"heatmap-intensity":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],function:"interpolated","zoom-function":!1,"property-function":!1,transition:!1},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"]},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"]}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-hue-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,transition:!0,units:"degrees"},"raster-brightness-min":{type:"number",function:"interpolated","zoom-function":!0,default:0,minimum:0,maximum:1,transition:!0},"raster-brightness-max":{type:"number",function:"interpolated","zoom-function":!0,default:1,minimum:0,maximum:1,transition:!0},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-fade-duration":{type:"number",default:300,minimum:0,function:"interpolated","zoom-function":!0,transition:!1,units:"milliseconds"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,function:"interpolated","zoom-function":!0,transition:!1},"hillshade-illumination-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"viewport"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"hillshade-shadow-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",function:"interpolated","zoom-function":!0,transition:!0},"hillshade-accent-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0}},paint_background:{"background-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0,requires:[{"!":"background-pattern"}]},"background-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!1,default:1,minimum:0,maximum:1,transition:!0},"fill-extrusion-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-extrusion-pattern"}]},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"fill-extrusion-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"]},"fill-extrusion-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"fill-extrusion-height":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:0,minimum:0,units:"meters",transition:!0},"fill-extrusion-base":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"]}}},D=function(t,e,n,r){this.message=(t?t+": ":"")+n,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)};function O(t){var e=t.key,n=t.value;return n?[new D(e,n,"constants have been deprecated as of v8")]:[]}function R(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r":"value"===t.itemType.kind?"array":"array<"+e+">"}return t.kind}var J=[V,q,U,H,Z,G,X($)];function K(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&!K(t.itemType,e.itemType)&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(var n=0,r=J;n255?255:t}function i(t){return t<0?0:t>1?1:t}function a(t){return"%"===t[t.length-1]?r(parseFloat(t)/100*255):r(parseInt(t))}function o(t){return"%"===t[t.length-1]?i(parseFloat(t)/100):i(parseFloat(t))}function s(t,e,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?t+(e-t)*n*6:2*n<1?e:3*n<2?t+(e-t)*(2/3-n)*6:t}try{e.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in n)return n[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=i.indexOf("("),u=i.indexOf(")");if(-1!==l&&u+1===i.length){var c=i.substr(0,l),f=i.substr(l+1,u-(l+1)).split(","),h=1;switch(c){case"rgba":if(4!==f.length)return null;h=o(f.pop());case"rgb":return 3!==f.length?null:[a(f[0]),a(f[1]),a(f[2]),h];case"hsla":if(4!==f.length)return null;h=o(f.pop());case"hsl":if(3!==f.length)return null;var p=(parseFloat(f[0])%360+360)%360/360,d=o(f[1]),m=o(f[2]),g=m<=.5?m*(d+1):m+d-m*d,y=2*m-g;return[r(255*s(y,g,p+1/3)),r(255*s(y,g,p)),r(255*s(y,g,p-1/3)),h];default:return null}}return null}}catch(t){}}).parseCSSColor,tt=function(t,e,n,r){void 0===r&&(r=1),this.r=t,this.g=e,this.b=n,this.a=r};tt.parse=function(t){if(t){if(t instanceof tt)return t;if("string"==typeof t){var e=Q(t);if(e)return new tt(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3])}}},tt.prototype.toString=function(){var t=this.toArray(),e=t[0],n=t[1],r=t[2],i=t[3];return"rgba("+Math.round(e)+","+Math.round(n)+","+Math.round(r)+","+i+")"},tt.prototype.toArray=function(){var t=this.r,e=this.g,n=this.b,r=this.a;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*n/r,r]},tt.black=new tt(0,0,0,1),tt.white=new tt(1,1,1,1),tt.transparent=new tt(0,0,0,0);var et=function(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})};et.prototype.compare=function(t,e){return this.collator.compare(t,e)},et.prototype.resolvedLocale=function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale};var nt=function(t,e,n){this.type=W,this.locale=n,this.caseSensitive=t,this.diacriticSensitive=e};function rt(t,e,n,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:"Invalid rgba value ["+[t,e,n,r].join(", ")+"]: 'a' must be between 0 and 1.":"Invalid rgba value ["+("number"==typeof r?[t,e,n,r]:[t,e,n]).join(", ")+"]: 'r', 'g', and 'b' must be between 0 and 255."}function it(t){if(null===t)return V;if("string"==typeof t)return U;if("boolean"==typeof t)return H;if("number"==typeof t)return q;if(t instanceof tt)return Z;if(t instanceof et)return W;if(Array.isArray(t)){for(var e,n=t.length,r=0,i=t;r4)return e.error("Expected 1, 2, or 3 arguments, but found "+(t.length-1)+" instead.");var n,r;if(t.length>2){var i=t[1];if("string"!=typeof i||!(i in ut))return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=ut[i]}else n=$;if(t.length>3){if("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2]))return e.error('The length argument to "array" must be a positive integer literal',2);r=t[2]}var a=X(n,r),o=e.parse(t[t.length-1],t.length-1,$);return o?new ct(a,o):null},ct.prototype.evaluate=function(t){var e=this.input.evaluate(t);if(K(this.type,it(e)))throw new ot("Expected value to be of type "+Y(this.type)+", but found "+Y(it(e))+" instead.");return e},ct.prototype.eachChild=function(t){t(this.input)},ct.prototype.possibleOutputs=function(){return this.input.possibleOutputs()},ct.prototype.serialize=function(){var t=["array"],e=this.type.itemType;if("string"===e.kind||"number"===e.kind||"boolean"===e.kind){t.push(e.kind);var n=this.type.N;"number"==typeof n&&t.push(n)}return t.push(this.input.serialize()),t};var ft={"to-number":q,"to-color":Z},ht=function(t,e){this.type=t,this.args=e};ht.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");for(var n=t[0],r=ft[n],i=[],a=1;a4?"Invalid rbga value "+JSON.stringify(e)+": expected an array containing either three or four numeric values.":rt(e[0],e[1],e[2],e[3])))return new tt(e[0]/255,e[1]/255,e[2]/255,e[3]);throw new ot(n||"Could not parse color from value '"+("string"==typeof e?e:JSON.stringify(e))+"'")}for(var o=null,s=0,l=this.args;s=0)return!1;var n=!0;return t.eachChild(function(t){n&&!yt(t,e)&&(n=!1)}),n}mt.prototype.evaluate=function(t){return this._evaluate(t,this.args)},mt.prototype.eachChild=function(t){this.args.forEach(t)},mt.prototype.possibleOutputs=function(){return[void 0]},mt.prototype.serialize=function(){return[this.name].concat(this.args.map(function(t){return t.serialize()}))},mt.parse=function(t,e){var n=t[0],r=mt.definitions[n];if(!r)return e.error('Unknown expression "'+n+'". If you wanted a literal array, use ["literal", [...]].',0);for(var i=Array.isArray(r)?r[0]:r.type,a=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=a.filter(function(e){var n=e[0];return!Array.isArray(n)||n.length===t.length-1}),s=[],l=1;ln&&ee))throw new ot("Input is not a number.");a=o-1}}return Math.max(o-1,0)}_t.prototype.parse=function(t,e,n,r,i){return void 0===i&&(i={}),e?this.concat(e,n,r)._parse(t,i):this._parse(t,i)},_t.prototype._parse=function(t,e){if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var n=t[0];if("string"!=typeof n)return this.error("Expression name must be a string, but found "+typeof n+' instead. If you wanted a literal array, use ["literal", [...]].',0),null;var r=this.registry[n];if(r){var i=r.parse(t,this);if(!i)return null;if(this.expectedType){var a=this.expectedType,o=i.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind||"value"!==o.kind)if("array"===a.kind&&"value"===o.kind)e.omitTypeAnnotations||(i=new ct(a,i));else if("color"!==a.kind||"value"!==o.kind&&"string"!==o.kind){if(this.checkSubtype(this.expectedType,i.type))return null}else e.omitTypeAnnotations||(i=new ht(a,[i]));else e.omitTypeAnnotations||(i=new lt(a,[i]))}if(!(i instanceof at)&&function t(e){if(e instanceof vt)return t(e.boundExpression);if(e instanceof mt&&"error"===e.name)return!1;if(e instanceof nt)return!1;var n=e instanceof ht||e instanceof lt||e instanceof ct,r=!0;return e.eachChild(function(e){r=n?r&&t(e):r&&e instanceof at}),!!r&&(gt(e)&&yt(e,["zoom","heatmap-density","line-progress","is-supported-script"]))}(i)){var s=new dt;try{i=new at(i.type,i.evaluate(s))}catch(t){return this.error(t.message),null}}return i}return this.error('Unknown expression "'+n+'". If you wanted a literal array, use ["literal", [...]].',0)}return void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error("Expected an array, but found "+typeof t+" instead.")},_t.prototype.concat=function(t,e,n){var r="number"==typeof t?this.path.concat(t):this.path,i=n?this.scope.concat(n):this.scope;return new _t(this.registry,r,e||null,i,this.errors)},_t.prototype.error=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var r=""+this.key+e.map(function(t){return"["+t+"]"}).join("");this.errors.push(new N(r,t))},_t.prototype.checkSubtype=function(t,e){var n=K(t,e);return n&&this.error(n),n};var bt=function(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(var r=0,i=n;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);var f=e.parse(l,c,a);if(!f)return null;a=a||f.type,i.push([s,f])}return new bt(a,n,i)},bt.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;return r>=e[i-1]?n[i-1].evaluate(t):n[xt(e,r)].evaluate(t)},bt.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t};var kt=Object.freeze({number:wt,color:function(t,e,n){return new tt(wt(t.r,e.r,n),wt(t.g,e.g,n),wt(t.b,e.b,n),wt(t.a,e.a,n))},array:function(t,e,n){return t.map(function(t,r){return wt(t,e[r],n)})}}),Tt=function(t,e,n,r){this.type=t,this.interpolation=e,this.input=n,this.labels=[],this.outputs=[];for(var i=0,a=r;i1}))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:o}}if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(!(r=e.parse(r,2,q)))return null;var s=[],l=null;e.expectedType&&"value"!==e.expectedType.kind&&(l=e.expectedType);for(var u=0;u=c)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',h);var d=e.parse(f,p,l);if(!d)return null;l=l||d.type,s.push([c,d])}return"number"===l.kind||"color"===l.kind||"array"===l.kind&&"number"===l.itemType.kind&&"number"==typeof l.N?new Tt(l,n,r,s):e.error("Type "+Y(l)+" is not interpolatable.")},Tt.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;if(r>=e[i-1])return n[i-1].evaluate(t);var a=xt(e,r),o=e[a],s=e[a+1],l=Tt.interpolationFactor(this.interpolation,r,o,s),u=n[a].evaluate(t),c=n[a+1].evaluate(t);return kt[this.type.kind.toLowerCase()](u,c,l)},Tt.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e=n.length)throw new ot("Array index out of bounds: "+e+" > "+(n.length-1)+".");if(e!==Math.floor(e))throw new ot("Array index must be an integer, but found "+e+" instead.");return n[e]},Ct.prototype.eachChild=function(t){t(this.index),t(this.input)},Ct.prototype.possibleOutputs=function(){return[void 0]},Ct.prototype.serialize=function(){return["at",this.index.serialize(),this.input.serialize()]};var zt=function(t,e,n,r,i,a){this.inputType=t,this.type=e,this.input=n,this.cases=r,this.outputs=i,this.otherwise=a};zt.parse=function(t,e){if(t.length<5)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if(t.length%2!=1)return e.error("Expected an even number of arguments.");var n,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);for(var i={},a=[],o=2;oNumber.MAX_SAFE_INTEGER)return u.error("Branch labels must be integers no larger than "+Number.MAX_SAFE_INTEGER+".");if("number"==typeof h&&Math.floor(h)!==h)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,it(h)))return null}else n=it(h);if(void 0!==i[String(h)])return u.error("Branch labels must be unique.");i[String(h)]=a.length}var p=e.parse(l,o,r);if(!p)return null;r=r||p.type,a.push(p)}var d=e.parse(t[1],1,n);if(!d)return null;var m=e.parse(t[t.length-1],t.length-1,r);return m?new zt(n,r,d,i,a,m):null},zt.prototype.evaluate=function(t){var e=this.input.evaluate(t);return(this.outputs[this.cases[e]]||this.otherwise).evaluate(t)},zt.prototype.eachChild=function(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)},zt.prototype.possibleOutputs=function(){return(t=[]).concat.apply(t,this.outputs.map(function(t){return t.possibleOutputs()})).concat(this.otherwise.possibleOutputs());var t},zt.prototype.serialize=function(){for(var t=this,e=["match",this.input.serialize()],n=[],r={},i=0,a=Object.keys(this.cases).sort();ir.evaluate(t)}function qt(t,e){var n=e[0],r=e[1];return n.evaluate(t)<=r.evaluate(t)}function Ut(t,e){var n=e[0],r=e[1];return n.evaluate(t)>=r.evaluate(t)}function Ht(t){return{type:t}}function Zt(t){return{result:"success",value:t}}function Gt(t){return{result:"error",value:t}}mt.register(Rt,{error:[{kind:"error"},[U],function(t,e){var n=e[0];throw new ot(n.evaluate(t))}],typeof:[U,[$],function(t,e){return Y(it(e[0].evaluate(t)))}],"to-string":[U,[$],function(t,e){var n=e[0],r=typeof(n=n.evaluate(t));return null===n?"":"string"===r||"number"===r||"boolean"===r?String(n):n instanceof tt?n.toString():JSON.stringify(n)}],"to-boolean":[H,[$],function(t,e){var n=e[0];return Boolean(n.evaluate(t))}],"to-rgba":[X(q,4),[Z],function(t,e){return e[0].evaluate(t).toArray()}],rgb:[Z,[q,q,q],Ft],rgba:[Z,[q,q,q,q],Ft],has:{type:H,overloads:[[[U],function(t,e){return Bt(e[0].evaluate(t),t.properties())}],[[U,G],function(t,e){var n=e[0],r=e[1];return Bt(n.evaluate(t),r.evaluate(t))}]]},get:{type:$,overloads:[[[U],function(t,e){return Nt(e[0].evaluate(t),t.properties())}],[[U,G],function(t,e){var n=e[0],r=e[1];return Nt(n.evaluate(t),r.evaluate(t))}]]},properties:[G,[],function(t){return t.properties()}],"geometry-type":[U,[],function(t){return t.geometryType()}],id:[$,[],function(t){return t.id()}],zoom:[q,[],function(t){return t.globals.zoom}],"heatmap-density":[q,[],function(t){return t.globals.heatmapDensity||0}],"line-progress":[q,[],function(t){return t.globals.lineProgress||0}],"+":[q,Ht(q),function(t,e){for(var n=0,r=0,i=e;r":[H,[U,$],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],a=r.value;return typeof i==typeof a&&i>a}],"filter-id->":[H,[$],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>i}],"filter-<=":[H,[U,$],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],a=r.value;return typeof i==typeof a&&i<=a}],"filter-id-<=":[H,[$],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r<=i}],"filter->=":[H,[U,$],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],a=r.value;return typeof i==typeof a&&i>=a}],"filter-id->=":[H,[$],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>=i}],"filter-has":[H,[$],function(t,e){return e[0].value in t.properties()}],"filter-has-id":[H,[],function(t){return null!==t.id()}],"filter-type-in":[H,[X(U)],function(t,e){return e[0].value.indexOf(t.geometryType())>=0}],"filter-id-in":[H,[X($)],function(t,e){return e[0].value.indexOf(t.id())>=0}],"filter-in-small":[H,[U,X($)],function(t,e){var n=e[0];return e[1].value.indexOf(t.properties()[n.value])>=0}],"filter-in-large":[H,[U,X($)],function(t,e){var n=e[0],r=e[1];return function(t,e,n,r){for(;n<=r;){var i=n+r>>1;if(e[i]===t)return!0;e[i]>t?r=i-1:n=i+1}return!1}(t.properties()[n.value],r.value,0,r.value.length-1)}],">":{type:H,overloads:[[[q,q],Vt],[[U,U],Vt],[[U,U,W],function(t,e){var n=e[0],r=e[1];return e[2].evaluate(t).compare(n.evaluate(t),r.evaluate(t))>0}]]},"<":{type:H,overloads:[[[q,q],jt],[[U,U],jt],[[U,U,W],function(t,e){var n=e[0],r=e[1];return e[2].evaluate(t).compare(n.evaluate(t),r.evaluate(t))<0}]]},">=":{type:H,overloads:[[[q,q],Ut],[[U,U],Ut],[[U,U,W],function(t,e){var n=e[0],r=e[1];return e[2].evaluate(t).compare(n.evaluate(t),r.evaluate(t))>=0}]]},"<=":{type:H,overloads:[[[q,q],qt],[[U,U],qt],[[U,U,W],function(t,e){var n=e[0],r=e[1];return e[2].evaluate(t).compare(n.evaluate(t),r.evaluate(t))<=0}]]},all:{type:H,overloads:[[[H,H],function(t,e){var n=e[0],r=e[1];return n.evaluate(t)&&r.evaluate(t)}],[Ht(H),function(t,e){for(var n=0,r=e;nQt?Math.pow(t,1/3):t/Kt+Yt}function re(t){return t>Jt?t*t*t:Kt*(t-Yt)}function ie(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function ae(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function oe(t){var e=ae(t.r),n=ae(t.g),r=ae(t.b),i=ne((.4124564*e+.3575761*n+.1804375*r)/$t),a=ne((.2126729*e+.7151522*n+.072175*r)/Wt);return{l:116*a-16,a:500*(i-a),b:200*(a-ne((.0193339*e+.119192*n+.9503041*r)/Xt)),alpha:t.a}}function se(t){var e=(t.l+16)/116,n=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=Wt*re(e),n=$t*re(n),r=Xt*re(r),new tt(ie(3.2404542*n-1.5371385*e-.4985314*r),ie(-.969266*n+1.8760108*e+.041556*r),ie(.0556434*n-.2040259*e+1.0572252*r),t.alpha)}var le={forward:oe,reverse:se,interpolate:function(t,e,n){return{l:wt(t.l,e.l,n),a:wt(t.a,e.a,n),b:wt(t.b,e.b,n),alpha:wt(t.alpha,e.alpha,n)}}},ue={forward:function(t){var e=oe(t),n=e.l,r=e.a,i=e.b,a=Math.atan2(i,r)*ee;return{h:a<0?a+360:a,c:Math.sqrt(r*r+i*i),l:n,alpha:t.a}},reverse:function(t){var e=t.h*te,n=t.c;return se({l:t.l,a:Math.cos(e)*n,b:Math.sin(e)*n,alpha:t.alpha})},interpolate:function(t,e,n){return{h:function(t,e,n){var r=e-t;return t+n*(r>180||r<-180?r-360*Math.round(r/360):r)}(t.h,e.h,n),c:wt(t.c,e.c,n),l:wt(t.l,e.l,n),alpha:wt(t.alpha,e.alpha,n)}}},ce=Object.freeze({lab:le,hcl:ue});function fe(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function he(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function pe(t){return t}function de(t,e,n){return void 0!==t?t:void 0!==e?e:void 0!==n?n:void 0}function me(t,e,n,r,i){return de(typeof n===i?r[n]:void 0,t.default,e.default)}function ge(t,e,n){if("number"!==fe(n))return de(t.default,e.default);var r=t.stops.length;if(1===r)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[r-1][0])return t.stops[r-1][1];var i=_e(t.stops,n);return t.stops[i][1]}function ye(t,e,n){var r=void 0!==t.base?t.base:1;if("number"!==fe(n))return de(t.default,e.default);var i=t.stops.length;if(1===i)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[i-1][0])return t.stops[i-1][1];var a=_e(t.stops,n),o=function(t,e,n,r){var i=r-n,a=t-n;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}(n,r,t.stops[a][0],t.stops[a+1][0]),s=t.stops[a][1],l=t.stops[a+1][1],u=kt[e.type]||pe;if(t.colorSpace&&"rgb"!==t.colorSpace){var c=ce[t.colorSpace];u=function(t,e){return c.reverse(c.interpolate(c.forward(t),c.forward(e),o))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=s.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==n&&void 0!==r)return u(n,r,o)}}:u(s,l,o)}function ve(t,e,n){return"color"===e.type?n=tt.parse(n):fe(n)===e.type||"enum"===e.type&&e.values[n]||(n=void 0),de(n,t.default,e.default)}function _e(t,e){for(var n,r,i=0,a=t.length-1,o=0;i<=a;){if(n=t[o=Math.floor((i+a)/2)][0],r=t[o+1][0],e===n||e>n&&ee&&(a=o-1)}return Math.max(o-1,0)}var xe=function(t,e){var n;this.expression=t,this._warningHistory={},this._defaultValue="color"===(n=e).type&&he(n.default)?new tt(0,0,0,0):"color"===n.type?tt.parse(n.default)||null:void 0===n.default?null:n.default,"enum"===e.type&&(this._enumValues=e.values)};function be(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Rt}function we(t,e){var n=new _t(Rt,[],function(t){var e={color:Z,string:U,number:q,enum:U,boolean:H};return"array"===t.type?X(e[t.value]||$,t.length):e[t.type]||null}(e)),r=n.parse(t);return r?Zt(new xe(r,e)):Gt(n.errors)}xe.prototype.evaluateWithoutErrorHandling=function(t,e){return this._evaluator||(this._evaluator=new dt),this._evaluator.globals=t,this._evaluator.feature=e,this.expression.evaluate(this._evaluator)},xe.prototype.evaluate=function(t,e){this._evaluator||(this._evaluator=new dt),this._evaluator.globals=t,this._evaluator.feature=e;try{var n=this.expression.evaluate(this._evaluator);if(null==n)return this._defaultValue;if(this._enumValues&&!(n in this._enumValues))throw new ot("Expected value to be one of "+Object.keys(this._enumValues).map(function(t){return JSON.stringify(t)}).join(", ")+", but found "+JSON.stringify(n)+" instead.");return n}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}};var ke=function(t,e){this.kind=t,this._styleExpression=e};ke.prototype.evaluateWithoutErrorHandling=function(t,e){return this._styleExpression.evaluateWithoutErrorHandling(t,e)},ke.prototype.evaluate=function(t,e){return this._styleExpression.evaluate(t,e)};var Te=function(t,e,n){this.kind=t,this.zoomStops=n.labels,this._styleExpression=e,n instanceof Tt&&(this._interpolationType=n.interpolation)};function Ae(t,e){if("error"===(t=we(t,e)).result)return t;var n=t.value.expression,r=gt(n);if(!r&&!e["property-function"])return Gt([new N("","property expressions not supported")]);var i=yt(n,["zoom"]);if(!i&&!1===e["zoom-function"])return Gt([new N("","zoom expressions not supported")]);var a=function t(e){var n=null;if(e instanceof St)n=t(e.result);else if(e instanceof Mt)for(var r=0,i=e.args;rr.maximum?[new D(e,n,n+" is greater than the maximum value "+r.maximum)]:[]}function Le(t){var e,n,r,i=t.valueSpec,a=F(t.value.type),o={},s="categorical"!==a&&void 0===t.value.property,l=!s,u="array"===fe(t.value.stops)&&"array"===fe(t.value.stops[0])&&"object"===fe(t.value.stops[0][0]),c=Ce({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===a)return[new D(t.key,t.value,'identity function may not have a "stops" property')];var e=[],n=t.value;return e=e.concat(ze({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),"array"===fe(n)&&0===n.length&&e.push(new D(t.key,n,"array must have at least one stop")),e},default:function(t){return Ke({key:t.key,value:t.value,valueSpec:i,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===a&&s&&c.push(new D(t.key,t.value,'missing required property "property"')),"identity"===a||t.value.stops||c.push(new D(t.key,t.value,'missing required property "stops"')),"exponential"===a&&"piecewise-constant"===t.valueSpec.function&&c.push(new D(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!t.valueSpec["property-function"]?c.push(new D(t.key,t.value,"property functions not supported")):s&&!t.valueSpec["zoom-function"]&&"heatmap-color"!==t.objectKey&&"line-gradient"!==t.objectKey&&c.push(new D(t.key,t.value,"zoom functions not supported"))),"categorical"!==a&&!u||void 0!==t.value.property||c.push(new D(t.key,t.value,'"property" property is required')),c;function f(t){var e=[],a=t.value,s=t.key;if("array"!==fe(a))return[new D(s,a,"array expected, "+fe(a)+" found")];if(2!==a.length)return[new D(s,a,"array length 2 expected, length "+a.length+" found")];if(u){if("object"!==fe(a[0]))return[new D(s,a,"object expected, "+fe(a[0])+" found")];if(void 0===a[0].zoom)return[new D(s,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new D(s,a,"object stop key must have value")];if(r&&r>F(a[0].zoom))return[new D(s,a[0].zoom,"stop zoom values must appear in ascending order")];F(a[0].zoom)!==r&&(r=F(a[0].zoom),n=void 0,o={}),e=e.concat(Ce({key:s+"[0]",value:a[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Ee,value:h}}))}else e=e.concat(h({key:s+"[0]",value:a[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},a));return e.concat(Ke({key:s+"[1]",value:a[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function h(t,r){var s=fe(t.value),l=F(t.value),u=null!==t.value?t.value:r;if(e){if(s!==e)return[new D(t.key,u,s+" stop domain type must match previous stop domain type "+e)]}else e=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new D(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==a){var c="number expected, "+s+" found";return i["property-function"]&&void 0===a&&(c+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new D(t.key,u,c)]}return"categorical"!==a||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==a&&"number"===s&&void 0!==n&&l=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3===t.length&&(Array.isArray(t[1])||Array.isArray(t[2]));case"any":case"all":for(var e=0,n=t.slice(1);ee?1:0}function Be(t){if(!t)return!0;var e,n=t[0];return t.length<=1?"any"!==n:"=="===n?Ne(t[1],t[2],"=="):"!="===n?qe(Ne(t[1],t[2],"==")):"<"===n||">"===n||"<="===n||">="===n?Ne(t[1],t[2],n):"any"===n?(e=t.slice(1),["any"].concat(e.map(Be))):"all"===n?["all"].concat(t.slice(1).map(Be)):"none"===n?["all"].concat(t.slice(1).map(Be).map(qe)):"in"===n?je(t[1],t.slice(2)):"!in"===n?qe(je(t[1],t.slice(2))):"has"===n?Ve(t[1]):"!has"!==n||qe(Ve(t[1]))}function Ne(t,e,n){switch(t){case"$type":return["filter-type-"+n,e];case"$id":return["filter-id-"+n,e];default:return["filter-"+n,t,e]}}function je(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(function(t){return typeof t!=typeof e[0]})?["filter-in-large",t,["literal",e.sort(Fe)]]:["filter-in-small",t,["literal",e]]}}function Ve(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function qe(t){return["!",t]}function Ue(t){return De(B(t.value))?Ie(R({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):function t(e){var n=e.value,r=e.key;if("array"!==fe(n))return[new D(r,n,"array expected, "+fe(n)+" found")];var i,a=e.styleSpec,o=[];if(n.length<1)return[new D(r,n,"filter array must have at least 1 element")];switch(o=o.concat(Pe({key:r+"[0]",value:n[0],valueSpec:a.filter_operator,style:e.style,styleSpec:e.styleSpec})),F(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===F(n[1])&&o.push(new D(r,n,'"$type" cannot be use with operator "'+n[0]+'"'));case"==":case"!=":3!==n.length&&o.push(new D(r,n,'filter array for operator "'+n[0]+'" must have 3 elements'));case"in":case"!in":n.length>=2&&"string"!==(i=fe(n[1]))&&o.push(new D(r+"[1]",n[1],"string expected, "+i+" found"));for(var s=2;s=u[h+0]&&r>=u[h+1]?(o[f]=!0,a.push(l[f])):o[f]=!1}}},fn.prototype._forEachCell=function(t,e,n,r,i,a,o){for(var s=this._convertToCellCoord(t),l=this._convertToCellCoord(e),u=this._convertToCellCoord(n),c=this._convertToCellCoord(r),f=s;f<=u;f++)for(var h=l;h<=c;h++){var p=this.d*h+f;if(i.call(this,t,e,n,r,p,a,o))return}},fn.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},fn.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=cn+this.cells.length+1+1,n=0,r=0;r=0)){var f=t[c];u[c]=pn[l].shallow.indexOf(c)>=0?f:gn(f,e)}t instanceof Error&&(u.message=t.message)}return{name:l,properties:u}}throw new Error("can't serialize object of type "+typeof t)}function yn(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof hn)return t;if(Array.isArray(t))return t.map(function(t){return yn(t)});if("object"==typeof t){var e=t,n=e.name,r=e.properties;if(!n)throw new Error("can't deserialize object of anonymous class");var i=pn[n].klass;if(!i)throw new Error("can't deserialize unregistered class "+n);if(i.deserialize)return i.deserialize(r._serialized);for(var a=Object.create(i.prototype),o=0,s=Object.keys(r);o=0?r[l]:yn(r[l])}return a}throw new Error("can't deserialize object of type "+typeof t)}var vn=function(){this.first=!0};vn.prototype.update=function(t,e){var n=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=e):this.lastFloorZoom=128&&t<=255},Arabic:function(t){return t>=1536&&t<=1791},"Arabic Supplement":function(t){return t>=1872&&t<=1919},"Arabic Extended-A":function(t){return t>=2208&&t<=2303},"Hangul Jamo":function(t){return t>=4352&&t<=4607},"Unified Canadian Aboriginal Syllabics":function(t){return t>=5120&&t<=5759},Khmer:function(t){return t>=6016&&t<=6143},"Unified Canadian Aboriginal Syllabics Extended":function(t){return t>=6320&&t<=6399},"General Punctuation":function(t){return t>=8192&&t<=8303},"Letterlike Symbols":function(t){return t>=8448&&t<=8527},"Number Forms":function(t){return t>=8528&&t<=8591},"Miscellaneous Technical":function(t){return t>=8960&&t<=9215},"Control Pictures":function(t){return t>=9216&&t<=9279},"Optical Character Recognition":function(t){return t>=9280&&t<=9311},"Enclosed Alphanumerics":function(t){return t>=9312&&t<=9471},"Geometric Shapes":function(t){return t>=9632&&t<=9727},"Miscellaneous Symbols":function(t){return t>=9728&&t<=9983},"Miscellaneous Symbols and Arrows":function(t){return t>=11008&&t<=11263},"CJK Radicals Supplement":function(t){return t>=11904&&t<=12031},"Kangxi Radicals":function(t){return t>=12032&&t<=12255},"Ideographic Description Characters":function(t){return t>=12272&&t<=12287},"CJK Symbols and Punctuation":function(t){return t>=12288&&t<=12351},Hiragana:function(t){return t>=12352&&t<=12447},Katakana:function(t){return t>=12448&&t<=12543},Bopomofo:function(t){return t>=12544&&t<=12591},"Hangul Compatibility Jamo":function(t){return t>=12592&&t<=12687},Kanbun:function(t){return t>=12688&&t<=12703},"Bopomofo Extended":function(t){return t>=12704&&t<=12735},"CJK Strokes":function(t){return t>=12736&&t<=12783},"Katakana Phonetic Extensions":function(t){return t>=12784&&t<=12799},"Enclosed CJK Letters and Months":function(t){return t>=12800&&t<=13055},"CJK Compatibility":function(t){return t>=13056&&t<=13311},"CJK Unified Ideographs Extension A":function(t){return t>=13312&&t<=19903},"Yijing Hexagram Symbols":function(t){return t>=19904&&t<=19967},"CJK Unified Ideographs":function(t){return t>=19968&&t<=40959},"Yi Syllables":function(t){return t>=40960&&t<=42127},"Yi Radicals":function(t){return t>=42128&&t<=42191},"Hangul Jamo Extended-A":function(t){return t>=43360&&t<=43391},"Hangul Syllables":function(t){return t>=44032&&t<=55215},"Hangul Jamo Extended-B":function(t){return t>=55216&&t<=55295},"Private Use Area":function(t){return t>=57344&&t<=63743},"CJK Compatibility Ideographs":function(t){return t>=63744&&t<=64255},"Arabic Presentation Forms-A":function(t){return t>=64336&&t<=65023},"Vertical Forms":function(t){return t>=65040&&t<=65055},"CJK Compatibility Forms":function(t){return t>=65072&&t<=65103},"Small Form Variants":function(t){return t>=65104&&t<=65135},"Arabic Presentation Forms-B":function(t){return t>=65136&&t<=65279},"Halfwidth and Fullwidth Forms":function(t){return t>=65280&&t<=65519}};function xn(t){for(var e=0,n=t;e=65097&&t<=65103)||_n["CJK Compatibility Ideographs"](t)||_n["CJK Compatibility"](t)||_n["CJK Radicals Supplement"](t)||_n["CJK Strokes"](t)||!(!_n["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||_n["CJK Unified Ideographs Extension A"](t)||_n["CJK Unified Ideographs"](t)||_n["Enclosed CJK Letters and Months"](t)||_n["Hangul Compatibility Jamo"](t)||_n["Hangul Jamo Extended-A"](t)||_n["Hangul Jamo Extended-B"](t)||_n["Hangul Jamo"](t)||_n["Hangul Syllables"](t)||_n.Hiragana(t)||_n["Ideographic Description Characters"](t)||_n.Kanbun(t)||_n["Kangxi Radicals"](t)||_n["Katakana Phonetic Extensions"](t)||_n.Katakana(t)&&12540!==t||!(!_n["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!_n["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||_n["Unified Canadian Aboriginal Syllabics"](t)||_n["Unified Canadian Aboriginal Syllabics Extended"](t)||_n["Vertical Forms"](t)||_n["Yijing Hexagram Symbols"](t)||_n["Yi Syllables"](t)||_n["Yi Radicals"](t)))}function kn(t){return!(wn(t)||function(t){return!!(_n["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||_n["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||_n["Letterlike Symbols"](t)||_n["Number Forms"](t)||_n["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||_n["Control Pictures"](t)&&9251!==t||_n["Optical Character Recognition"](t)||_n["Enclosed Alphanumerics"](t)||_n["Geometric Shapes"](t)||_n["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||_n["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||_n["CJK Symbols and Punctuation"](t)||_n.Katakana(t)||_n["Private Use Area"](t)||_n["CJK Compatibility Forms"](t)||_n["Small Form Variants"](t)||_n["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Tn(t,e){return!(!e&&(t>=1424&&t<=2303||_n["Arabic Presentation Forms-A"](t)||_n["Arabic Presentation Forms-B"](t))||t>=2304&&t<=3583||t>=3840&&t<=4255||_n.Khmer(t))}var An,Mn=!1,Sn=null,Cn=!1,zn=new I,En={applyArabicShaping:null,processBidirectionalText:null,isLoaded:function(){return Cn||null!=En.applyArabicShaping}},Ln=function(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new vn,this.transition={})};Ln.prototype.isSupportedScript=function(t){return function(t,e){for(var n=0,r=t;nthis.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(e=1)return 1;var e=i*i,n=e*i;return 4*(i<.5?n:3*(i-e)+n-.75)}())}return n};var Rn=function(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)};Rn.prototype.possiblyEvaluate=function(t){for(var e=new Nn(this._properties),n=0,r=Object.keys(this._values);nr.zoomHistory.lastIntegerZoom?{from:t,to:e,fromScale:2,toScale:1,t:a+(1-a)*o}:{from:n,to:e,fromScale:.5,toScale:1,t:1-(1-o)*a}},qn.prototype.interpolate=function(t){return t};var Un=function(t){this.specification=t};Un.prototype.possiblyEvaluate=function(t,e){return!!t.expression.evaluate(e)},Un.prototype.interpolate=function(){return!1};var Hn=function(t){for(var e in this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},t){var n=t[e],r=this.defaultPropertyValues[e]=new In(n,void 0),i=this.defaultTransitionablePropertyValues[e]=new Pn(n);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}};dn("DataDrivenProperty",Vn),dn("DataConstantProperty",jn),dn("CrossFadedProperty",qn),dn("ColorRampProperty",Un);var Zn=function(t){function e(e,n){for(var r in t.call(this),this.id=e.id,this.metadata=e.metadata,this.type=e.type,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,this.visibility="visible","background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),this._featureFilter=function(){return!0},n.layout&&(this._unevaluatedLayout=new Fn(n.layout)),this._transitionablePaint=new Dn(n.paint),e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(var i in e.layout)this.setLayoutProperty(i,e.layout[i],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getLayoutProperty=function(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)},e.prototype.setLayoutProperty=function(t,e,n){if(null!=e){var r="layers."+this.id+".layout."+t;if(this._validate(sn,r,t,e,n))return}"visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility="none"===e?e:"visible"},e.prototype.getPaintProperty=function(t){return g(t,"-transition")?this._transitionablePaint.getTransition(t.slice(0,-"-transition".length)):this._transitionablePaint.getValue(t)},e.prototype.setPaintProperty=function(t,e,n){if(null!=e){var r="layers."+this.id+".paint."+t;if(this._validate(on,r,t,e,n))return}g(t,"-transition")?this._transitionablePaint.setTransition(t.slice(0,-"-transition".length),e||void 0):this._transitionablePaint.setValue(t,e)},e.prototype.isHidden=function(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility},e.prototype.updateTransitions=function(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)},e.prototype.hasTransition=function(){return this._transitioningPaint.hasTransition()},e.prototype.recalculate=function(t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t)),this.paint=this._transitioningPaint.possiblyEvaluate(t)},e.prototype.serialize=function(){var t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return"none"===this.visibility&&(t.layout=t.layout||{},t.layout.visibility="none"),v(t,function(t,e){return!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)})},e.prototype._validate=function(t,e,n,r,i){return(!i||!1!==i.validate)&&ln(this,t.call(rn,{key:e,layerType:this.type,objectKey:n,value:r,styleSpec:P,style:{glyphs:!0,sprite:!0}}))},e.prototype.hasOffscreenPass=function(){return!1},e.prototype.resize=function(){},e}(I),Gn={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},$n=function(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8},Wn=function(){this.isTransferred=!1,this.capacity=-1,this.resize(0)};function Xn(t,e){void 0===e&&(e=1);var n=0,r=0;return{members:t.map(function(t){var i,a=(i=t.type,Gn[i].BYTES_PER_ELEMENT),o=n=Yn(n,Math.max(e,a)),s=t.components||1;return r=Math.max(r,a),n+=a*s,{name:t.name,type:t.type,components:s,offset:o}}),size:Yn(n,Math.max(r,e)),alignment:e}}function Yn(t,e){return Math.ceil(t/e)*e}Wn.serialize=function(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}},Wn.deserialize=function(t){var e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e},Wn.prototype._trim=function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())},Wn.prototype.clear=function(){this.length=0},Wn.prototype.resize=function(t){this.reserve(t),this.length=t},Wn.prototype.reserve=function(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}},Wn.prototype._refreshViews=function(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")};var Jn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;this.resize(n+1);var r=2*n;return this.int16[r+0]=t,this.int16[r+1]=e,n},e}(Wn);Jn.prototype.bytesPerElement=4,dn("StructArrayLayout2i4",Jn);var Kn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;this.resize(i+1);var a=4*i;return this.int16[a+0]=t,this.int16[a+1]=e,this.int16[a+2]=n,this.int16[a+3]=r,i},e}(Wn);Kn.prototype.bytesPerElement=8,dn("StructArrayLayout4i8",Kn);var Qn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a){var o=this.length;this.resize(o+1);var s=6*o;return this.int16[s+0]=t,this.int16[s+1]=e,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=i,this.int16[s+5]=a,o},e}(Wn);Qn.prototype.bytesPerElement=12,dn("StructArrayLayout2i4i12",Qn);var tr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a,o,s){var l=this.length;this.resize(l+1);var u=6*l,c=12*l;return this.int16[u+0]=t,this.int16[u+1]=e,this.int16[u+2]=n,this.int16[u+3]=r,this.uint8[c+8]=i,this.uint8[c+9]=a,this.uint8[c+10]=o,this.uint8[c+11]=s,l},e}(Wn);tr.prototype.bytesPerElement=12,dn("StructArrayLayout4i4ub12",tr);var er=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a,o,s){var l=this.length;this.resize(l+1);var u=8*l;return this.int16[u+0]=t,this.int16[u+1]=e,this.int16[u+2]=n,this.int16[u+3]=r,this.uint16[u+4]=i,this.uint16[u+5]=a,this.uint16[u+6]=o,this.uint16[u+7]=s,l},e}(Wn);er.prototype.bytesPerElement=16,dn("StructArrayLayout4i4ui16",er);var nr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;this.resize(r+1);var i=3*r;return this.float32[i+0]=t,this.float32[i+1]=e,this.float32[i+2]=n,r},e}(Wn);nr.prototype.bytesPerElement=12,dn("StructArrayLayout3f12",nr);var rr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;this.resize(e+1);var n=1*e;return this.uint32[n+0]=t,e},e}(Wn);rr.prototype.bytesPerElement=4,dn("StructArrayLayout1ul4",rr);var ir=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a,o,s,l,u,c){var f=this.length;this.resize(f+1);var h=12*f,p=6*f;return this.int16[h+0]=t,this.int16[h+1]=e,this.int16[h+2]=n,this.int16[h+3]=r,this.int16[h+4]=i,this.int16[h+5]=a,this.uint32[p+3]=o,this.uint16[h+8]=s,this.uint16[h+9]=l,this.int16[h+10]=u,this.int16[h+11]=c,f},e}(Wn);ir.prototype.bytesPerElement=24,dn("StructArrayLayout6i1ul2ui2i24",ir);var ar=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a){var o=this.length;this.resize(o+1);var s=6*o;return this.int16[s+0]=t,this.int16[s+1]=e,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=i,this.int16[s+5]=a,o},e}(Wn);ar.prototype.bytesPerElement=12,dn("StructArrayLayout2i2i2i12",ar);var or=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;this.resize(n+1);var r=4*n;return this.uint8[r+0]=t,this.uint8[r+1]=e,n},e}(Wn);or.prototype.bytesPerElement=4,dn("StructArrayLayout2ub4",or);var sr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a,o,s,l,u,c,f,h,p){var d=this.length;this.resize(d+1);var m=20*d,g=10*d,y=40*d;return this.int16[m+0]=t,this.int16[m+1]=e,this.uint16[m+2]=n,this.uint16[m+3]=r,this.uint32[g+2]=i,this.uint32[g+3]=a,this.uint32[g+4]=o,this.uint16[m+10]=s,this.uint16[m+11]=l,this.uint16[m+12]=u,this.float32[g+7]=c,this.float32[g+8]=f,this.uint8[y+36]=h,this.uint8[y+37]=p,d},e}(Wn);sr.prototype.bytesPerElement=40,dn("StructArrayLayout2i2ui3ul3ui2f2ub40",sr);var lr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;this.resize(e+1);var n=1*e;return this.float32[n+0]=t,e},e}(Wn);lr.prototype.bytesPerElement=4,dn("StructArrayLayout1f4",lr);var ur=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;this.resize(r+1);var i=3*r;return this.int16[i+0]=t,this.int16[i+1]=e,this.int16[i+2]=n,r},e}(Wn);ur.prototype.bytesPerElement=6,dn("StructArrayLayout3i6",ur);var cr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;this.resize(r+1);var i=2*r,a=4*r;return this.uint32[i+0]=t,this.uint16[a+2]=e,this.uint16[a+3]=n,r},e}(Wn);cr.prototype.bytesPerElement=8,dn("StructArrayLayout1ul2ui8",cr);var fr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;this.resize(r+1);var i=3*r;return this.uint16[i+0]=t,this.uint16[i+1]=e,this.uint16[i+2]=n,r},e}(Wn);fr.prototype.bytesPerElement=6,dn("StructArrayLayout3ui6",fr);var hr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;this.resize(n+1);var r=2*n;return this.uint16[r+0]=t,this.uint16[r+1]=e,n},e}(Wn);hr.prototype.bytesPerElement=4,dn("StructArrayLayout2ui4",hr);var pr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;this.resize(n+1);var r=2*n;return this.float32[r+0]=t,this.float32[r+1]=e,n},e}(Wn);pr.prototype.bytesPerElement=8,dn("StructArrayLayout2f8",pr);var dr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;this.resize(i+1);var a=4*i;return this.float32[a+0]=t,this.float32[a+1]=e,this.float32[a+2]=n,this.float32[a+3]=r,i},e}(Wn);dr.prototype.bytesPerElement=16,dn("StructArrayLayout4f16",dr);var mr=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={anchorPointX:{configurable:!0},anchorPointY:{configurable:!0},x1:{configurable:!0},y1:{configurable:!0},x2:{configurable:!0},y2:{configurable:!0},featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0},radius:{configurable:!0},signedDistanceFromAnchor:{configurable:!0},anchorPoint:{configurable:!0}};return n.anchorPointX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorPointX.set=function(t){this._structArray.int16[this._pos2+0]=t},n.anchorPointY.get=function(){return this._structArray.int16[this._pos2+1]},n.anchorPointY.set=function(t){this._structArray.int16[this._pos2+1]=t},n.x1.get=function(){return this._structArray.int16[this._pos2+2]},n.x1.set=function(t){this._structArray.int16[this._pos2+2]=t},n.y1.get=function(){return this._structArray.int16[this._pos2+3]},n.y1.set=function(t){this._structArray.int16[this._pos2+3]=t},n.x2.get=function(){return this._structArray.int16[this._pos2+4]},n.x2.set=function(t){this._structArray.int16[this._pos2+4]=t},n.y2.get=function(){return this._structArray.int16[this._pos2+5]},n.y2.set=function(t){this._structArray.int16[this._pos2+5]=t},n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.featureIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+8]},n.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+8]=t},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+9]},n.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+9]=t},n.radius.get=function(){return this._structArray.int16[this._pos2+10]},n.radius.set=function(t){this._structArray.int16[this._pos2+10]=t},n.signedDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+11]},n.signedDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+11]=t},n.anchorPoint.get=function(){return new l(this.anchorPointX,this.anchorPointY)},Object.defineProperties(e.prototype,n),e}($n);mr.prototype.size=24;var gr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new mr(this,t)},e}(ir);dn("CollisionBoxArray",gr);var yr=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={anchorX:{configurable:!0},anchorY:{configurable:!0},glyphStartIndex:{configurable:!0},numGlyphs:{configurable:!0},vertexStartIndex:{configurable:!0},lineStartIndex:{configurable:!0},lineLength:{configurable:!0},segment:{configurable:!0},lowerSize:{configurable:!0},upperSize:{configurable:!0},lineOffsetX:{configurable:!0},lineOffsetY:{configurable:!0},writingMode:{configurable:!0},hidden:{configurable:!0}};return n.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorX.set=function(t){this._structArray.int16[this._pos2+0]=t},n.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},n.anchorY.set=function(t){this._structArray.int16[this._pos2+1]=t},n.glyphStartIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.glyphStartIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},n.numGlyphs.get=function(){return this._structArray.uint16[this._pos2+3]},n.numGlyphs.set=function(t){this._structArray.uint16[this._pos2+3]=t},n.vertexStartIndex.get=function(){return this._structArray.uint32[this._pos4+2]},n.vertexStartIndex.set=function(t){this._structArray.uint32[this._pos4+2]=t},n.lineStartIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.lineStartIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},n.lineLength.get=function(){return this._structArray.uint32[this._pos4+4]},n.lineLength.set=function(t){this._structArray.uint32[this._pos4+4]=t},n.segment.get=function(){return this._structArray.uint16[this._pos2+10]},n.segment.set=function(t){this._structArray.uint16[this._pos2+10]=t},n.lowerSize.get=function(){return this._structArray.uint16[this._pos2+11]},n.lowerSize.set=function(t){this._structArray.uint16[this._pos2+11]=t},n.upperSize.get=function(){return this._structArray.uint16[this._pos2+12]},n.upperSize.set=function(t){this._structArray.uint16[this._pos2+12]=t},n.lineOffsetX.get=function(){return this._structArray.float32[this._pos4+7]},n.lineOffsetX.set=function(t){this._structArray.float32[this._pos4+7]=t},n.lineOffsetY.get=function(){return this._structArray.float32[this._pos4+8]},n.lineOffsetY.set=function(t){this._structArray.float32[this._pos4+8]=t},n.writingMode.get=function(){return this._structArray.uint8[this._pos1+36]},n.writingMode.set=function(t){this._structArray.uint8[this._pos1+36]=t},n.hidden.get=function(){return this._structArray.uint8[this._pos1+37]},n.hidden.set=function(t){this._structArray.uint8[this._pos1+37]=t},Object.defineProperties(e.prototype,n),e}($n);yr.prototype.size=40;var vr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new yr(this,t)},e}(sr);dn("PlacedSymbolArray",vr);var _r=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={offsetX:{configurable:!0}};return n.offsetX.get=function(){return this._structArray.float32[this._pos4+0]},n.offsetX.set=function(t){this._structArray.float32[this._pos4+0]=t},Object.defineProperties(e.prototype,n),e}($n);_r.prototype.size=4;var xr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getoffsetX=function(t){return this.float32[1*t+0]},e.prototype.get=function(t){return new _r(this,t)},e}(lr);dn("GlyphOffsetArray",xr);var br=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={x:{configurable:!0},y:{configurable:!0},tileUnitDistanceFromAnchor:{configurable:!0}};return n.x.get=function(){return this._structArray.int16[this._pos2+0]},n.x.set=function(t){this._structArray.int16[this._pos2+0]=t},n.y.get=function(){return this._structArray.int16[this._pos2+1]},n.y.set=function(t){this._structArray.int16[this._pos2+1]=t},n.tileUnitDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+2]},n.tileUnitDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+2]=t},Object.defineProperties(e.prototype,n),e}($n);br.prototype.size=6;var wr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getx=function(t){return this.int16[3*t+0]},e.prototype.gety=function(t){return this.int16[3*t+1]},e.prototype.gettileUnitDistanceFromAnchor=function(t){return this.int16[3*t+2]},e.prototype.get=function(t){return new br(this,t)},e}(ur);dn("SymbolLineVertexArray",wr);var kr=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0}};return n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+0]},n.featureIndex.set=function(t){this._structArray.uint32[this._pos4+0]=t},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+3]},n.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+3]=t},Object.defineProperties(e.prototype,n),e}($n);kr.prototype.size=8;var Tr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new kr(this,t)},e}(cr);dn("FeatureIndexArray",Tr);var Ar=Xn([{name:"a_pos",components:2,type:"Int16"}],4).members,Mr=function(t){void 0===t&&(t=[]),this.segments=t};Mr.prototype.prepareSegment=function(t,e,n){var r=this.segments[this.segments.length-1];return t>Mr.MAX_VERTEX_ARRAY_LENGTH&&b("Max vertices per segment is "+Mr.MAX_VERTEX_ARRAY_LENGTH+": bucket requested "+t),(!r||r.vertexLength+t>Mr.MAX_VERTEX_ARRAY_LENGTH)&&(r={vertexOffset:e.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},this.segments.push(r)),r},Mr.prototype.get=function(){return this.segments},Mr.prototype.destroy=function(){for(var t=0,e=this.segments;tRr.max||o.yRr.max)&&b("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return n}function Br(t,e,n,r,i){t.emplaceBack(2*e+(r+1)/2,2*n+(i+1)/2)}var Nr=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(function(t){return t.id}),this.index=t.index,this.layoutVertexArray=new Jn,this.indexArray=new fr,this.segments=new Mr,this.programConfigurations=new Pr(Ar,t.layers,t.zoom)};function jr(t,e,n){for(var r=0;r=3)for(var s=0;s1){if(Hr(t,e))return!0;for(var r=0;r1?t.distSqr(n):t.distSqr(n.sub(e)._mult(i)._add(e))}function Wr(t,e){for(var n,r,i,a=!1,o=0;oe.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(a=!a);return a}function Xr(t,e){for(var n=!1,r=0,i=t.length-1;re.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function Yr(t,e,n){var r=e.paint.get(t).value;return"constant"===r.kind?r.value:n.programConfigurations.get(e.id).binders[t].statistics.max}function Jr(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Kr(t,e,n,r,i){if(!e[0]&&!e[1])return t;var a=l.convert(e);"viewport"===n&&a._rotate(-r);for(var o=[],s=0;s=Or||l<0||l>=Or)){var u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray),c=u.vertexLength;Br(this.layoutVertexArray,s,l,-1,-1),Br(this.layoutVertexArray,s,l,1,-1),Br(this.layoutVertexArray,s,l,1,1),Br(this.layoutVertexArray,s,l,-1,1),this.indexArray.emplaceBack(c,c+1,c+2),this.indexArray.emplaceBack(c,c+3,c+2),u.vertexLength+=4,u.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t)},dn("CircleBucket",Nr,{omit:["layers"]});var Qr={paint:new Hn({"circle-radius":new Vn(P.paint_circle["circle-radius"]),"circle-color":new Vn(P.paint_circle["circle-color"]),"circle-blur":new Vn(P.paint_circle["circle-blur"]),"circle-opacity":new Vn(P.paint_circle["circle-opacity"]),"circle-translate":new jn(P.paint_circle["circle-translate"]),"circle-translate-anchor":new jn(P.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new jn(P.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new jn(P.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Vn(P.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Vn(P.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Vn(P.paint_circle["circle-stroke-opacity"])})},ti=i(function(t,e){var n;t.exports=((n=new Float32Array(3))[0]=0,n[1]=0,n[2]=0,function(){var t=new Float32Array(4);t[0]=0,t[1]=0,t[2]=0,t[3]=0}(),{vec3:{transformMat3:function(t,e,n){var r=e[0],i=e[1],a=e[2];return t[0]=r*n[0]+i*n[3]+a*n[6],t[1]=r*n[1]+i*n[4]+a*n[7],t[2]=r*n[2]+i*n[5]+a*n[8],t}},vec4:{transformMat4:function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,t}},mat2:{create:function(){var t=new Float32Array(4);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},rotate:function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(n),l=Math.cos(n);return t[0]=r*l+a*s,t[1]=i*l+o*s,t[2]=r*-s+a*l,t[3]=i*-s+o*l,t},scale:function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=n[0],l=n[1];return t[0]=r*s,t[1]=i*s,t[2]=a*l,t[3]=o*l,t}},mat3:{create:function(){var t=new Float32Array(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fromRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=-n,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}},mat4:{create:function(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},translate:function(t,e,n){var r,i,a,o,s,l,u,c,f,h,p,d,m=n[0],g=n[1],y=n[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*y+e[12],t[13]=e[1]*m+e[5]*g+e[9]*y+e[13],t[14]=e[2]*m+e[6]*g+e[10]*y+e[14],t[15]=e[3]*m+e[7]*g+e[11]*y+e[15]):(r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=e[8],h=e[9],p=e[10],d=e[11],t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=u,t[7]=c,t[8]=f,t[9]=h,t[10]=p,t[11]=d,t[12]=r*m+s*g+f*y+e[12],t[13]=i*m+l*g+h*y+e[13],t[14]=a*m+u*g+p*y+e[14],t[15]=o*m+c*g+d*y+e[15]),t},scale:function(t,e,n){var r=n[0],i=n[1],a=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},multiply:function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=e[8],h=e[9],p=e[10],d=e[11],m=e[12],g=e[13],y=e[14],v=e[15],_=n[0],x=n[1],b=n[2],w=n[3];return t[0]=_*r+x*s+b*f+w*m,t[1]=_*i+x*l+b*h+w*g,t[2]=_*a+x*u+b*p+w*y,t[3]=_*o+x*c+b*d+w*v,_=n[4],x=n[5],b=n[6],w=n[7],t[4]=_*r+x*s+b*f+w*m,t[5]=_*i+x*l+b*h+w*g,t[6]=_*a+x*u+b*p+w*y,t[7]=_*o+x*c+b*d+w*v,_=n[8],x=n[9],b=n[10],w=n[11],t[8]=_*r+x*s+b*f+w*m,t[9]=_*i+x*l+b*h+w*g,t[10]=_*a+x*u+b*p+w*y,t[11]=_*o+x*c+b*d+w*v,_=n[12],x=n[13],b=n[14],w=n[15],t[12]=_*r+x*s+b*f+w*m,t[13]=_*i+x*l+b*h+w*g,t[14]=_*a+x*u+b*p+w*y,t[15]=_*o+x*c+b*d+w*v,t},perspective:function(t,e,n,r,i){var a=1/Math.tan(e/2),o=1/(r-i);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+r)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*r*o,t[15]=0,t},rotateX:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),a=e[4],o=e[5],s=e[6],l=e[7],u=e[8],c=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+u*r,t[5]=o*i+c*r,t[6]=s*i+f*r,t[7]=l*i+h*r,t[8]=u*i-a*r,t[9]=c*i-o*r,t[10]=f*i-s*r,t[11]=h*i-l*r,t},rotateZ:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),a=e[0],o=e[1],s=e[2],l=e[3],u=e[4],c=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+u*r,t[1]=o*i+c*r,t[2]=s*i+f*r,t[3]=l*i+h*r,t[4]=u*i-a*r,t[5]=c*i-o*r,t[6]=f*i-s*r,t[7]=h*i-l*r,t},invert:function(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],u=e[7],c=e[8],f=e[9],h=e[10],p=e[11],d=e[12],m=e[13],g=e[14],y=e[15],v=n*s-r*o,_=n*l-i*o,x=n*u-a*o,b=r*l-i*s,w=r*u-a*s,k=i*u-a*l,T=c*m-f*d,A=c*g-h*d,M=c*y-p*d,S=f*g-h*m,C=f*y-p*m,z=h*y-p*g,E=v*z-_*C+x*S+b*M-w*A+k*T;return E?(E=1/E,t[0]=(s*z-l*C+u*S)*E,t[1]=(i*C-r*z-a*S)*E,t[2]=(m*k-g*w+y*b)*E,t[3]=(h*w-f*k-p*b)*E,t[4]=(l*M-o*z-u*A)*E,t[5]=(n*z-i*M+a*A)*E,t[6]=(g*x-d*k-y*_)*E,t[7]=(c*k-h*x+p*_)*E,t[8]=(o*C-s*M+u*T)*E,t[9]=(r*M-n*C-a*T)*E,t[10]=(d*w-m*x+y*v)*E,t[11]=(f*x-c*w-p*v)*E,t[12]=(s*A-o*S-l*T)*E,t[13]=(n*S-r*A+i*T)*E,t[14]=(m*_-d*b-g*v)*E,t[15]=(c*b-f*_+h*v)*E,t):null},ortho:function(t,e,n,r,i,a,o){var s=1/(e-n),l=1/(r-i),u=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*l,t[14]=(o+a)*u,t[15]=1,t}}})}),ei=(ti.vec3,ti.vec4),ni=(ti.mat2,ti.mat3,ti.mat4),ri=function(t){function e(e){t.call(this,e,Qr)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createBucket=function(t){return new Nr(t)},e.prototype.queryRadius=function(t){var e=t;return Yr("circle-radius",this,e)+Yr("circle-stroke-width",this,e)+Jr(this.paint.get("circle-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,i,a,o){for(var s=Kr(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),i.angle,a),l=this.paint.get("circle-radius").evaluate(e)+this.paint.get("circle-stroke-width").evaluate(e),u="map"===this.paint.get("circle-pitch-alignment"),c=u?s:function(t,e,n){return s.map(function(t){return t.map(function(t){return ii(t,e,n)})})}(0,o,i),f=u?l*a:l,h=0,p=n;ht.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=t.data,s=e.data,l=0;l80*n){r=a=t[0],i=o=t[1];for(var d=n;da&&(a=s),l>o&&(o=l);u=0!==(u=Math.max(a-r,o-i))?1/u:0}return wi(h,p,n,r,i,u),p}function xi(t,e,n,r,i){var a,o;if(i===Vi(t,e,n,r)>0)for(a=e;a=e;a-=r)o=Bi(a,t[a],t[a+1],o);return o&&Di(o,o.next)&&(Ni(o),o=o.next),o}function bi(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Di(r,r.next)&&0!==Pi(r.prev,r,r.next))r=r.next;else{if(Ni(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function wi(t,e,n,r,i,a,o){if(t){!o&&a&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=zi(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,a,o,s,l,u=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,u*=2}while(o>1)}(i)}(t,r,i,a);for(var s,l,u=t;t.prev!==t.next;)if(s=t.prev,l=t.next,a?Ti(t,r,i,a):ki(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Ni(t),t=l.next,u=l.next;else if((t=l)===u){o?1===o?wi(t=Ai(t,e,n),e,n,r,i,a,2):2===o&&Mi(t,e,n,r,i,a):wi(bi(t),e,n,r,i,a,1);break}}}function ki(t){var e=t.prev,n=t,r=t.next;if(Pi(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Li(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Pi(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Ti(t,e,n,r){var i=t.prev,a=t,o=t.next;if(Pi(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,c=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,f=zi(s,l,e,n,r),h=zi(u,c,e,n,r),p=t.prevZ,d=t.nextZ;p&&p.z>=f&&d&&d.z<=h;){if(p!==t.prev&&p!==t.next&&Li(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Pi(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,d!==t.prev&&d!==t.next&&Li(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Pi(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;p&&p.z>=f;){if(p!==t.prev&&p!==t.next&&Li(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Pi(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;d&&d.z<=h;){if(d!==t.prev&&d!==t.next&&Li(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Pi(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Ai(t,e,n){var r=t;do{var i=r.prev,a=r.next.next;!Di(i,a)&&Oi(i,r,r.next,a)&&Ri(i,a)&&Ri(a,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(a.i/n),Ni(r),Ni(r.next),r=t=a),r=r.next}while(r!==t);return r}function Mi(t,e,n,r,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Ii(o,s)){var l=Fi(o,s);return o=bi(o,o.next),l=bi(l,l.next),wi(o,e,n,r,i,a),void wi(l,e,n,r,i,a)}s=s.next}o=o.next}while(o!==t)}function Si(t,e){return t.x-e.x}function Ci(t,e){if(e=function(t,e){var n,r=e,i=t.x,a=t.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x=r.x&&r.x>=c&&i!==r.x&&Li(an.x)&&Ri(r,t)&&(n=r,h=l),r=r.next;return n}(t,e)){var n=Fi(e,t);bi(n,n.next)}}function zi(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ei(t){var e=t,n=t;do{e.x=0&&(t-o)*(r-s)-(n-o)*(e-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function Ii(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Oi(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&Ri(t,e)&&Ri(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Pi(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Di(t,e){return t.x===e.x&&t.y===e.y}function Oi(t,e,n,r){return!!(Di(t,e)&&Di(n,r)||Di(t,r)&&Di(n,e))||Pi(t,e,n)>0!=Pi(t,e,r)>0&&Pi(n,r,t)>0!=Pi(n,r,e)>0}function Ri(t,e){return Pi(t.prev,t,t.next)<0?Pi(t,e,t.next)>=0&&Pi(t,t.prev,e)>=0:Pi(t,e,t.prev)<0||Pi(t,t.next,e)<0}function Fi(t,e){var n=new ji(t.i,t.x,t.y),r=new ji(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Bi(t,e,n,r){var i=new ji(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ni(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ji(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Vi(t,e,n,r){for(var i=0,a=e,o=n-r;a0&&(r+=t[i-1].length,n.holes.push(r))}return n},yi.default=vi;var qi=Hi,Ui=Hi;function Hi(t,e,n,r,i){!function t(e,n,r,i,a){for(;i>r;){if(i-r>600){var o=i-r+1,s=n-r+1,l=Math.log(o),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(o-u)/o)*(s-o/2<0?-1:1);t(e,n,Math.max(r,Math.floor(n-s*u/o+c)),Math.min(i,Math.floor(n+(o-s)*u/o+c)),a)}var f=e[n],h=r,p=i;for(Zi(e,r,n),a(e[i],f)>0&&Zi(e,r,i);h0;)p--}0===a(e[r],f)?Zi(e,r,p):Zi(e,++p,i),p<=n&&(r=p+1),n<=p&&(i=p-1)}}(t,e,n||0,r||t.length-1,i||Gi)}function Zi(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Gi(t,e){return te?1:0}function $i(t,e){var n=t.length;if(n<=1)return[t];for(var r,i,a=[],o=0;o1)for(var l=0;lOr)||t.y===e.y&&(t.y<0||t.y>Or)}function ra(t){return t.every(function(t){return t.x<0})||t.every(function(t){return t.x>Or})||t.every(function(t){return t.y<0})||t.every(function(t){return t.y>Or})}ea.prototype.populate=function(t,e){for(var n=0,r=t;n=1){var m=f[p-1];if(!na(d,m)){l.vertexLength+4>Mr.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));var g=d.sub(m)._perp()._unit(),y=m.dist(d);h+y>32768&&(h=0),ta(this.layoutVertexArray,d.x,d.y,g.x,g.y,0,0,h),ta(this.layoutVertexArray,d.x,d.y,g.x,g.y,0,1,h),h+=y,ta(this.layoutVertexArray,m.x,m.y,g.x,g.y,0,0,h),ta(this.layoutVertexArray,m.x,m.y,g.x,g.y,0,1,h);var v=l.vertexLength;this.indexArray.emplaceBack(v,v+1,v+2),this.indexArray.emplaceBack(v+1,v+2,v+3),l.vertexLength+=4,l.primitiveLength+=2}}}}l.vertexLength+a>Mr.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(a,this.layoutVertexArray,this.indexArray));for(var _=[],x=[],b=l.vertexLength,w=0,k=i;w>3}if(i--,1===r||2===r)a+=t.readSVarint(),o+=t.readSVarint(),1===r&&(e&&s.push(e),e=[]),e.push(new l(a,o));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&s.push(e),s},la.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,n=1,r=0,i=0,a=0,o=1/0,s=-1/0,l=1/0,u=-1/0;t.pos>3}if(r--,1===n||2===n)(i+=t.readSVarint())s&&(s=i),(a+=t.readSVarint())u&&(u=a);else if(7!==n)throw new Error("unknown command "+n)}return[o,l,s,u]},la.prototype.toGeoJSON=function(t,e,n){var r,i,a=this.extent*Math.pow(2,n),o=this.extent*t,s=this.extent*e,l=this.loadGeometry(),u=la.types[this.type];function c(t){for(var e=0;e>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(n))}function da(t,e,n){if(3===t){var r=new fa(n,n.readVarint()+n.pos);r.length&&(e[r.name]=r)}}ha.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new sa(this._pbf,e,this.extent,this._keys,this._values)};var ma={VectorTile:function(t,e){this.layers=t.readFields(da,{},e)},VectorTileFeature:sa,VectorTileLayer:fa},ga=ma.VectorTileFeature.types,ya=63,va=Math.cos(Math.PI/180*37.5),_a=.5,xa=Math.pow(2,14)/_a;function ba(t,e,n,r,i,a,o){t.emplaceBack(e.x,e.y,r?1:0,i?1:-1,Math.round(ya*n.x)+128,Math.round(ya*n.y)+128,1+(0===a?0:a<0?-1:1)|(o*_a&63)<<2,o*_a>>6)}var wa=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(function(t){return t.id}),this.index=t.index,this.layoutVertexArray=new tr,this.indexArray=new fr,this.programConfigurations=new Pr(oa,t.layers,t.zoom),this.segments=new Mr};function ka(t,e){return(t/e.tileTotal*(e.end-e.start)+e.start)*(xa-1)}wa.prototype.populate=function(t,e){for(var n=0,r=t;n=2&&t[l-1].equals(t[l-2]);)l--;for(var u=0;uu){var C=p.dist(_);if(C>2*c){var z=p.sub(p.sub(_)._mult(c/C)._round());this.distance+=z.dist(_),this.addCurrentVertex(z,this.distance,b.mult(1),0,0,!1,h,o),_=z}}var E=_&&x,L=E?n:x?g:y;if(E&&"round"===L&&(Mi&&(L="bevel"),"bevel"===L&&(M>2&&(L="flipbevel"),M100)T=w.clone().mult(-1);else{var I=b.x*w.y-b.y*w.x>0?-1:1,P=M*b.add(w).mag()/b.sub(w).mag();T._perp()._mult(P*I)}this.addCurrentVertex(p,this.distance,T,0,0,!1,h,o),this.addCurrentVertex(p,this.distance,T.mult(-1),0,0,!1,h,o)}else if("bevel"===L||"fakeround"===L){var D=b.x*w.y-b.y*w.x>0,O=-Math.sqrt(M*M-1);if(D?(m=0,d=O):(d=0,m=O),v||this.addCurrentVertex(p,this.distance,b,d,m,!1,h,o),"fakeround"===L){for(var R=Math.floor(8*(.5-(A-.5))),F=void 0,B=0;B=0;N--)F=b.mult((N+1)/(R+1))._add(w)._unit(),this.addPieSliceVertex(p,this.distance,F,D,h,o)}x&&this.addCurrentVertex(p,this.distance,w,-d,-m,!1,h,o)}else"butt"===L?(v||this.addCurrentVertex(p,this.distance,b,0,0,!1,h,o),x&&this.addCurrentVertex(p,this.distance,w,0,0,!1,h,o)):"square"===L?(v||(this.addCurrentVertex(p,this.distance,b,1,1,!1,h,o),this.e1=this.e2=-1),x&&this.addCurrentVertex(p,this.distance,w,-1,-1,!1,h,o)):"round"===L&&(v||(this.addCurrentVertex(p,this.distance,b,0,0,!1,h,o),this.addCurrentVertex(p,this.distance,b,1,1,!0,h,o),this.e1=this.e2=-1),x&&(this.addCurrentVertex(p,this.distance,w,-1,-1,!0,h,o),this.addCurrentVertex(p,this.distance,w,0,0,!1,h,o)));if(S&&k2*c){var V=p.add(x.sub(p)._mult(c/j)._round());this.distance+=V.dist(p),this.addCurrentVertex(V,this.distance,w.mult(1),0,0,!1,h,o),p=V}}v=!1}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e)}},wa.prototype.addCurrentVertex=function(t,e,n,r,i,a,o,s){var l,u=this.layoutVertexArray,c=this.indexArray;s&&(e=ka(e,s)),l=n.clone(),r&&l._sub(n.perp()._mult(r)),ba(u,t,l,a,!1,r,e),this.e3=o.vertexLength++,this.e1>=0&&this.e2>=0&&(c.emplaceBack(this.e1,this.e2,this.e3),o.primitiveLength++),this.e1=this.e2,this.e2=this.e3,l=n.mult(-1),i&&l._sub(n.perp()._mult(i)),ba(u,t,l,a,!0,-i,e),this.e3=o.vertexLength++,this.e1>=0&&this.e2>=0&&(c.emplaceBack(this.e1,this.e2,this.e3),o.primitiveLength++),this.e1=this.e2,this.e2=this.e3,e>xa/2&&!s&&(this.distance=0,this.addCurrentVertex(t,this.distance,n,r,i,a,o))},wa.prototype.addPieSliceVertex=function(t,e,n,r,i,a){n=n.mult(r?-1:1);var o=this.layoutVertexArray,s=this.indexArray;a&&(e=ka(e,a)),ba(o,t,n,!1,r,0,e),this.e3=i.vertexLength++,this.e1>=0&&this.e2>=0&&(s.emplaceBack(this.e1,this.e2,this.e3),i.primitiveLength++),r?this.e2=this.e3:this.e1=this.e3},dn("LineBucket",wa,{omit:["layers"]});var Ta=new Hn({"line-cap":new jn(P.layout_line["line-cap"]),"line-join":new Vn(P.layout_line["line-join"]),"line-miter-limit":new jn(P.layout_line["line-miter-limit"]),"line-round-limit":new jn(P.layout_line["line-round-limit"])}),Aa={paint:new Hn({"line-opacity":new Vn(P.paint_line["line-opacity"]),"line-color":new Vn(P.paint_line["line-color"]),"line-translate":new jn(P.paint_line["line-translate"]),"line-translate-anchor":new jn(P.paint_line["line-translate-anchor"]),"line-width":new Vn(P.paint_line["line-width"]),"line-gap-width":new Vn(P.paint_line["line-gap-width"]),"line-offset":new Vn(P.paint_line["line-offset"]),"line-blur":new Vn(P.paint_line["line-blur"]),"line-dasharray":new qn(P.paint_line["line-dasharray"]),"line-pattern":new qn(P.paint_line["line-pattern"]),"line-gradient":new Un(P.paint_line["line-gradient"])}),layout:Ta},Ma=new(function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.possiblyEvaluate=function(e,n){return n=new Ln(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,zoomHistory:n.zoomHistory,transition:n.transition}),t.prototype.possiblyEvaluate.call(this,e,n)},e.prototype.evaluate=function(e,n,r){return n=p({},n,{zoom:Math.floor(n.zoom)}),t.prototype.evaluate.call(this,e,n,r)},e}(Vn))(Aa.paint.properties["line-width"].specification);Ma.useIntegerZoom=!0;var Sa=function(t){function e(e){t.call(this,e,Aa)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setPaintProperty=function(e,n,r){t.prototype.setPaintProperty.call(this,e,n,r),"line-gradient"===e&&this._updateGradient()},e.prototype._updateGradient=function(){var t=this._transitionablePaint._values["line-gradient"].value.expression;this.gradient=hi(t,"lineProgress"),this.gradientTexture=null},e.prototype.recalculate=function(e){t.prototype.recalculate.call(this,e),this.paint._values["line-floorwidth"]=Ma.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)},e.prototype.createBucket=function(t){return new wa(t)},e.prototype.queryRadius=function(t){var e=t,n=Ca(Yr("line-width",this,e),Yr("line-gap-width",this,e)),r=Yr("line-offset",this,e);return n/2+Math.abs(r)+Jr(this.paint.get("line-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,i,a){var o=Kr(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),i.angle,a),s=a/2*Ca(this.paint.get("line-width").evaluate(e),this.paint.get("line-gap-width").evaluate(e)),u=this.paint.get("line-offset").evaluate(e);return u&&(n=function(t,e){for(var n=[],r=new l(0,0),i=0;i0?e+2*t:t}var za=Xn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"}]),Ea=Xn([{name:"a_projected_pos",components:3,type:"Float32"}],4),La=(Xn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4),Xn([{name:"a_placed",components:2,type:"Uint8"}],4)),Ia=(Xn([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"},{type:"Int16",name:"radius"},{type:"Int16",name:"signedDistanceFromAnchor"}]),Xn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4)),Pa=Xn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);function Da(t,e,n){var r=e.layout.get("text-transform").evaluate(n);return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),En.applyArabicShaping&&(t=En.applyArabicShaping(t)),t}Xn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"hidden"}]),Xn([{type:"Float32",name:"offsetX"}]),Xn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Oa={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42"},Ra=function(t){function e(e,n,r,i){t.call(this,e,n),this.angle=r,void 0!==i&&(this.segment=i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.clone=function(){return new e(this.x,this.y,this.angle,this.segment)},e}(l);function Fa(t,e){var n=e.expression;if("constant"===n.kind)return{functionType:"constant",layoutSize:n.evaluate(new Ln(t+1))};if("source"===n.kind)return{functionType:"source"};for(var r=n.zoomStops,i=0;i0)&&("constant"!==i.value.kind||i.value.value.length>0),l="constant"!==o.value.kind||o.value.value&&o.value.value.length>0;if(this.features=[],s||l){for(var u=e.iconDependencies,c=e.glyphDependencies,f=new Ln(this.zoom),h=0,p=t;h=0;s--)a[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:i},s>0&&(i+=e[s-1].dist(e[s]));for(var l=0;l0;this.addCollisionDebugVertices(s,l,u,c,f?this.collisionCircle:this.collisionBox,o.anchorPoint,n,f)}}}},Ha.prototype.deserializeCollisionBoxes=function(t,e,n,r,i){for(var a={},o=e;o0},Ha.prototype.hasIconData=function(){return this.icon.segments.get().length>0},Ha.prototype.hasCollisionBoxData=function(){return this.collisionBox.segments.get().length>0},Ha.prototype.hasCollisionCircleData=function(){return this.collisionCircle.segments.get().length>0},Ha.prototype.sortFeatures=function(t){var e=this;if(this.sortFeaturesByY&&this.sortedAngle!==t&&(this.sortedAngle=t,!(this.text.segments.get().length>1||this.icon.segments.get().length>1))){for(var n=[],r=0;ri.maxh||t>i.maxw||n<=i.maxh&&t<=i.maxw&&(o=i.maxw*i.maxh-t*n)a.free)){if(n===a.h)return this.allocShelf(s,t,n,r);n>a.h||nc)&&(f=2*Math.max(t,c)),(ll)&&(u=2*Math.max(n,l)),this.resize(f,u),this.packOne(t,n,r)):null},t.prototype.allocFreebin=function(t,e,n,r){var i=this.freebins.splice(t,1)[0];return i.id=r,i.w=e,i.h=n,i.refcount=0,this.bins[r]=i,this.ref(i),i},t.prototype.allocShelf=function(t,e,n,r){var i=this.shelves[t].alloc(e,n,r);return this.bins[r]=i,this.ref(i),i},t.prototype.shrink=function(){if(this.shelves.length>0){for(var t=0,e=0,n=0;nthis.free||e>this.h)return null;var r=this.x;return this.x+=t,this.free-=t,new function(t,e,n,r,i,a,o){this.id=t,this.x=e,this.y=n,this.w=r,this.h=i,this.maxw=a||r,this.maxh=o||i,this.refcount=0}(n,r,this.y,t,e,t,this.h)},e.prototype.resize=function(t){return this.free+=t-this.w,this.w=t,!0},t}()}),Qa=function(t,e){var n=e.pixelRatio;this.paddedRect=t,this.pixelRatio=n},to={tl:{configurable:!0},br:{configurable:!0},displaySize:{configurable:!0}};to.tl.get=function(){return[this.paddedRect.x+1,this.paddedRect.y+1]},to.br.get=function(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]},to.displaySize.get=function(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]},Object.defineProperties(Qa.prototype,to);var eo=function(t){var e=new ci({width:0,height:0}),n={},r=new Ka(0,0,{autoResize:!0});for(var i in t){var a=t[i],o=r.packOne(a.data.width+2,a.data.height+2);e.resize({width:r.w,height:r.h}),ci.copy(a.data,e,{x:0,y:0},{x:o.x+1,y:o.y+1},a.data),n[i]=new Qa(o,a)}r.shrink(),e.resize({width:r.w,height:r.h}),this.image=e,this.positions=n};dn("ImagePosition",Qa),dn("ImageAtlas",eo);var no=function(t,e,n,r,i){var a,o,s=8*i-r-1,l=(1<>1,c=-7,f=n?i-1:0,h=n?-1:1,p=t[e+f];for(f+=h,a=p&(1<<-c)-1,p>>=-c,c+=s;c>0;a=256*a+t[e+f],f+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=r;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,r),a-=u}return(p?-1:1)*o*Math.pow(2,a-r)},ro=function(t,e,n,r,i,a){var o,s,l,u=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:a-1,d=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[n+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[n+p]=255&o,p+=d,o/=256,u-=8);t[n+p-d]|=128*m},io=ao;function ao(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}function oo(t){return t.type===ao.Bytes?t.readVarint()+t.pos:t.pos+1}function so(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function lo(t,e,n){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=t;i--)n.buf[i+r]=n.buf[i]}function uo(t,e){for(var n=0;n>>8,t[n+2]=e>>>16,t[n+3]=e>>>24}function bo(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}ao.Varint=0,ao.Fixed64=1,ao.Bytes=2,ao.Fixed32=5,ao.prototype={destroy:function(){this.buf=null},readFields:function(t,e,n){for(n=n||this.length;this.pos>3,a=this.pos;this.type=7&r,t(i,e,this),this.pos===a&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=_o(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=bo(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=_o(this.buf,this.pos)+4294967296*_o(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=_o(this.buf,this.pos)+4294967296*bo(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=no(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=no(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,n,r=this.buf;return e=127&(n=r[this.pos++]),n<128?e:(e|=(127&(n=r[this.pos++]))<<7,n<128?e:(e|=(127&(n=r[this.pos++]))<<14,n<128?e:(e|=(127&(n=r[this.pos++]))<<21,n<128?e:function(t,e,n){var r,i,a=n.buf;if(r=(112&(i=a[n.pos++]))>>4,i<128)return so(t,r,e);if(r|=(127&(i=a[n.pos++]))<<3,i<128)return so(t,r,e);if(r|=(127&(i=a[n.pos++]))<<10,i<128)return so(t,r,e);if(r|=(127&(i=a[n.pos++]))<<17,i<128)return so(t,r,e);if(r|=(127&(i=a[n.pos++]))<<24,i<128)return so(t,r,e);if(r|=(1&(i=a[n.pos++]))<<31,i<128)return so(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(n=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=function(t,e,n){for(var r="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(a=t[i+1]))&&(u=(31&l)<<6|63&a)<=127&&(u=null):3===c?(a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&((u=(15&l)<<12|(63&a)<<6|63&o)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((u=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){var n=oo(this);for(t=t||[];this.pos127;);else if(e===ao.Bytes)this.pos=this.readVarint()+this.pos;else if(e===ao.Fixed32)this.pos+=4;else{if(e!==ao.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var n,r;if(t>=0?(n=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(n=~(-t%4294967296))?n=n+1|0:(n=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos]=127&t}(n,0,e),function(t,e){var n=(7&t)<<4;e.buf[e.pos++]|=n|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,n){for(var r,i,a=0;a55295&&r<57344){if(!i){r>56319||a+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):i=r;continue}if(r<56320){t[n++]=239,t[n++]=191,t[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(t[n++]=239,t[n++]=191,t[n++]=189,i=null);r<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:(r<65536?t[n++]=r>>12|224:(t[n++]=r>>18|240,t[n++]=r>>12&63|128),t[n++]=r>>6&63|128),t[n++]=63&r|128)}return n}(this.buf,t,this.pos);var n=this.pos-e;n>=128&&lo(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),ro(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ro(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var n=0;n=128&&lo(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,n){this.writeTag(t,ao.Bytes),this.writeRawMessage(e,n)},writePackedVarint:function(t,e){this.writeMessage(t,uo,e)},writePackedSVarint:function(t,e){this.writeMessage(t,co,e)},writePackedBoolean:function(t,e){this.writeMessage(t,po,e)},writePackedFloat:function(t,e){this.writeMessage(t,fo,e)},writePackedDouble:function(t,e){this.writeMessage(t,ho,e)},writePackedFixed32:function(t,e){this.writeMessage(t,mo,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,go,e)},writePackedFixed64:function(t,e){this.writeMessage(t,yo,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,vo,e)},writeBytesField:function(t,e){this.writeTag(t,ao.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,ao.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,ao.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,ao.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,ao.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,ao.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,ao.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,ao.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,ao.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,ao.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var wo=3;function ko(t,e,n){1===t&&n.readMessage(To,e)}function To(t,e,n){if(3===t){var r=n.readMessage(Ao,{}),i=r.id,a=r.bitmap,o=r.width,s=r.height,l=r.left,u=r.top,c=r.advance;e.push({id:i,bitmap:new ui({width:o+2*wo,height:s+2*wo},a),metrics:{width:o,height:s,left:l,top:u,advance:c}})}}function Ao(t,e,n){1===t?e.id=n.readVarint():2===t?e.bitmap=n.readBytes():3===t?e.width=n.readVarint():4===t?e.height=n.readVarint():5===t?e.left=n.readSVarint():6===t?e.top=n.readSVarint():7===t&&(e.advance=n.readVarint())}var Mo=wo,So=function(t,e,n){this.target=t,this.parent=e,this.mapId=n,this.callbacks={},this.callbackID=0,m(["receive"],this),this.target.addEventListener("message",this.receive,!1)};So.prototype.send=function(t,e,n,r){var i=n?this.mapId+":"+this.callbackID++:null;n&&(this.callbacks[i]=n);var a=[];this.target.postMessage({targetMapId:r,sourceMapId:this.mapId,type:t,id:String(i),data:gn(e,a)},a)},So.prototype.receive=function(t){var e,n=this,r=t.data,i=r.id;if(!r.targetMapId||this.mapId===r.targetMapId){var a=function(t,e){var r=[];n.target.postMessage({sourceMapId:n.mapId,type:"",id:String(i),error:t?gn(t):null,data:gn(e,r)},r)};if(""===r.type)e=this.callbacks[r.id],delete this.callbacks[r.id],e&&r.error?e(yn(r.error)):e&&e(null,yn(r.data));else if(void 0!==r.id&&this.parent[r.type])this.parent[r.type](r.sourceMapId,yn(r.data),a);else if(void 0!==r.id&&this.parent.getWorkerSource){var o=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,o[0],o[1])[o[2]](yn(r.data),a)}else this.parent[r.type](yn(r.data))}},So.prototype.remove=function(){this.target.removeEventListener("message",this.receive,!1)};var Co=r(i(function(t,e){!function(t){function e(t,e,r){var i=n(256*t,256*(e=Math.pow(2,r)-e-1),r),a=n(256*(t+1),256*(e+1),r);return i[0]+","+i[1]+","+a[0]+","+a[1]}function n(t,e,n){var r=2*Math.PI*6378137/256/Math.pow(2,n);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}t.getURL=function(t,n,r,i,a,o){return o=o||{},t+"?"+["bbox="+e(r,i,a),"format="+(o.format||"image/png"),"service="+(o.service||"WMS"),"version="+(o.version||"1.1.1"),"request="+(o.request||"GetMap"),"srs="+(o.srs||"EPSG:3857"),"width="+(o.width||256),"height="+(o.height||256),"layers="+n].join("&")},t.getTileBBox=e,t.getMercCoords=n,Object.defineProperty(t,"__esModule",{value:!0})}(e)})),zo=function(t,e,n){this.z=t,this.x=e,this.y=n,this.key=Io(0,t,e,n)};zo.prototype.equals=function(t){return this.z===t.z&&this.x===t.x&&this.y===t.y},zo.prototype.url=function(t,e){var n=Co.getTileBBox(this.x,this.y,this.z),r=function(t,e,n){for(var r,i="",a=t;a>0;a--)i+=(e&(r=1<this.canonical.z?new Lo(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Lo(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)},Lo.prototype.isChildOf=function(t){var e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e},Lo.prototype.children=function(t){if(this.overscaledZ>=t)return[new Lo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var e=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new Lo(e,this.wrap,e,n,r),new Lo(e,this.wrap,e,n+1,r),new Lo(e,this.wrap,e,n,r+1),new Lo(e,this.wrap,e,n+1,r+1)]},Lo.prototype.isLessThan=function(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=this.dim+this.border||e<-this.border||e>=this.dim+this.border)throw new RangeError("out of range source coordinates for DEM data");return(e+this.border)*this.stride+(t+this.border)},dn("Level",Po);var Do=function(t,e,n){this.uid=t,this.scale=e||1,this.level=n||new Po(256,512),this.loaded=!!n};Do.prototype.loadFromImage=function(t,e){if(t.height!==t.width)throw new RangeError("DEM tiles must be square");if(e&&"mapbox"!==e&&"terrarium"!==e)return b('"'+e+'" is not a valid encoding type. Valid types include "mapbox" and "terrarium".');var n=this.level=new Po(t.width,t.width/2),r=t.data;this._unpackData(n,r,e||"mapbox");for(var i=0;i=0&&l[3]>=0&&this.grid.insert(a,l[0],l[1],l[2],l[3])}},Bo.prototype.loadVTLayers=function(){return this.vtLayers||(this.vtLayers=new ma.VectorTile(new io(this.rawTileData)).layers,this.sourceLayerCoder=new Oo(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers},Bo.prototype.query=function(t,e){var n=this;this.loadVTLayers();for(var r=t.params||{},i=Or/t.tileSize/t.scale,a=Re(r.filter),o=t.queryGeometry,s=t.queryPadding*i,l=1/0,u=1/0,c=-1/0,f=-1/0,h=0;h=0)return!0;return!1}(a,l)){var u=this.sourceLayerCoder.decode(n),c=this.vtLayers[u].feature(r);if(i(new Ln(this.tileID.overscaledZ),c))for(var f=0;f=200&&n.status<300&&n.response){var r;try{r=JSON.parse(n.response)}catch(t){return e(t)}e(null,r)}else 401===n.status&&t.url.match(/mapbox.com/)?e(new A(n.statusText+": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens",n.status,t.url)):e(new A(n.statusText,n.status,t.url))},n.send(),n},e.getImage=function(t,e){return S(t,function(t,n){if(t)e(t);else if(n){var r=new self.Image,i=self.URL||self.webkitURL;r.onload=function(){e(null,r),i.revokeObjectURL(r.src)};var a=new self.Blob([new Uint8Array(n.data)],{type:"image/png"});r.cacheControl=n.cacheControl,r.expires=n.expires,r.src=n.data.byteLength?i.createObjectURL(a):"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII="}})},e.ResourceType=T,e.RGBAImage=ci,e.default$2=Ka,e.ImagePosition=Qa,e.getArrayBuffer=S,e.default$3=function(t){return new io(t).readFields(ko,[])},e.default$4=_n,e.asyncAll=function(t,e,n){if(!t.length)return n(null,[]);var r=t.length,i=new Array(t.length),a=null;t.forEach(function(t,o){e(t,function(t,e){t&&(a=t),i[o]=e,0==--r&&n(a,i)})})},e.AlphaImage=ui,e.default$5=P,e.endsWith=g,e.extend=p,e.sphericalToCartesian=function(t){var e=t[0],n=t[1],r=t[2];return n+=90,n*=Math.PI/180,r*=Math.PI/180,{x:e*Math.cos(n)*Math.sin(r),y:e*Math.sin(n)*Math.sin(r),z:e*Math.cos(r)}},e.Evented=I,e.validateStyle=rn,e.validateLight=an,e.emitValidationErrors=ln,e.default$6=tt,e.number=wt,e.Properties=Hn,e.Transitionable=Dn,e.Transitioning=Rn,e.PossiblyEvaluated=Nn,e.DataConstantProperty=jn,e.warnOnce=b,e.uniqueId=function(){return d++},e.default$7=So,e.pick=function(t,e){for(var n={},r=0;r@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,function(t,n,r,i){var a=r||i;return e[n]=!a||a.toLowerCase(),""}),e["max-age"]){var n=parseInt(e["max-age"],10);isNaN(n)?delete e["max-age"]:e["max-age"]=n}return e},e.default$11=Bo,e.default$12=Ro,e.default$13=Re,e.default$14=Ha,e.CollisionBoxArray=gr,e.default$15=Mr,e.TriangleIndexArray=fr,e.default$16=Ln,e.default$17=s,e.keysDifference=function(t,e){var n=[];for(var r in t)r in e||n.push(r);return n},e.default$18=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.mat4=ni,e.vec4=ei,e.getSizeData=Fa,e.evaluateSizeForFeature=function(t,e,n){var r=e;return"source"===t.functionType?n.lowerSize/10:"composite"===t.functionType?wt(n.lowerSize/10,n.upperSize/10,r.uSizeT):r.uSize},e.evaluateSizeForZoom=function(t,e,n){if("constant"===t.functionType)return{uSizeT:0,uSize:t.layoutSize};if("source"===t.functionType)return{uSizeT:0,uSize:0};if("camera"===t.functionType){var r=t.propertyValue,i=t.zoomRange,a=t.sizeRange,o=h(Se(r,n.specification).interpolationFactor(e,i.min,i.max),0,1);return{uSizeT:0,uSize:a.min+o*(a.max-a.min)}}var s=t.propertyValue,l=t.zoomRange;return{uSizeT:h(Se(s,n.specification).interpolationFactor(e,l.min,l.max),0,1),uSize:0}},e.addDynamicAttributes=Va,e.default$19=Ga,e.WritingMode=jo,e.multiPolygonIntersectsBufferedPoint=jr,e.multiPolygonIntersectsMultiPolygon=Vr,e.multiPolygonIntersectsBufferedMultiLine=qr,e.polygonIntersectsPolygon=function(t,e){for(var n=0;n-n/2;){if(--o<0)return!1;s-=t[o].dist(a),a=t[o]}s+=t[o].dist(t[o+1]),o++;for(var l=[],u=0;sr;)u-=l.shift().angleDelta;if(u>i)return!1;o++,s+=f.dist(h)}return!0}function a(e,n,r,a,o,s,l,u,c){var f=a?.6*s*l:0,h=Math.max(a?a.right-a.left:0,o?o.right-o.left:0),p=0===e[0].x||e[0].x===c||0===e[0].y||e[0].y===c;return n-h*l=0&&T=0&&A=0&&g+h<=p){var M=new t.default$25(T,A,w,v);M._round(),o&&!i(n,M,l,o,s)||y.push(M)}}m+=b}return c||y.length||u||(y=e(n,m/2,a,o,s,l,u,!0,f)),y}(e,p?n/2*u%n:(h/2+2*s)*l*u%n,n,f,r,h*l,p,!1,c)}r.prototype.replace=function(t){this._layerConfigs={},this._layers={},this.update(t,[])},r.prototype.update=function(e,r){for(var i=this,a=0,o=e;a0&&(m=Math.max(10*s,m),this._addLineCollisionCircles(t,e,n,n.segment,g,m,r,i,a,c))}else t.emplaceBack(n.x,n.y,p,f,d,h,r,i,a,0,0);this.boxEndIndex=t.length};s.prototype._addLineCollisionCircles=function(t,e,n,r,i,a,o,s,l,u){var c=a/2,f=Math.floor(i/c),h=1+.4*Math.log(u)/Math.LN2,p=Math.floor(f*h/2),d=-a/2,m=n,g=r+1,y=d,v=-i/2,_=v-i/4;do{if(--g<0){if(y>v)return;g=0;break}y-=e[g].dist(m),m=e[g]}while(y>_);for(var x=e[g].dist(e[g+1]),b=-p;bi&&(k+=w-i),!(k=e.length)return;x=e[g].dist(e[g+1])}var T=k-y,A=e[g],M=e[g+1].sub(A)._unit()._mult(T)._add(A)._round(),S=Math.abs(k-d)0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)}function f(t,e){return te?1:0}function h(e,n,r){void 0===n&&(n=1),void 0===r&&(r=!1);for(var i=1/0,a=1/0,o=-1/0,s=-1/0,u=e[0],c=0;co)&&(o=f.x),(!c||f.y>s)&&(s=f.y)}var h=o-i,m=s-a,g=Math.min(h,m),y=g/2,v=new l(null,p);if(0===g)return new t.default$1(i,a);for(var _=i;_b.d||!b.d)&&(b=k,r&&console.log("found best %d after %d probes",Math.round(1e4*k.d)/1e4,w)),k.max-b.d<=n||(y=k.h/2,v.push(new d(k.p.x-y,k.p.y-y,y,e)),v.push(new d(k.p.x+y,k.p.y-y,y,e)),v.push(new d(k.p.x-y,k.p.y+y,y,e)),v.push(new d(k.p.x+y,k.p.y+y,y,e)),w+=4)}return r&&(console.log("num probes: "+w),console.log("best distance: "+b.d)),b.p}function p(t,e){return e.max-t.max}function d(e,n,r,i){this.p=new t.default$1(e,n),this.h=r,this.d=function(e,n){for(var r=!1,i=1/0,a=0;ae.y!=f.y>e.y&&e.x<(f.x-c.x)*(e.y-c.y)/(f.y-c.y)+c.x&&(r=!r),i=Math.min(i,t.distToSegmentSquared(e,c,f))}return(r?1:-1)*Math.sqrt(i)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}function m(e,n,r,i,a,o){e.createArrays(),e.symbolInstances=[];var s=512*e.overscaling;e.tilePixelRatio=t.default$8/s,e.compareText={},e.iconsNeedLinear=!1;var l=e.layers[0].layout,u=e.layers[0]._unevaluatedLayout._values,c={};if("composite"===e.textSizeData.functionType){var f=e.textSizeData.zoomRange,h=f.min,p=f.max;c.compositeTextSizes=[u["text-size"].possiblyEvaluate(new t.default$16(h)),u["text-size"].possiblyEvaluate(new t.default$16(p))]}if("composite"===e.iconSizeData.functionType){var d=e.iconSizeData.zoomRange,m=d.min,y=d.max;c.compositeIconSizes=[u["icon-size"].possiblyEvaluate(new t.default$16(m)),u["icon-size"].possiblyEvaluate(new t.default$16(y))]}c.layoutTextSize=u["text-size"].possiblyEvaluate(new t.default$16(e.zoom+1)),c.layoutIconSize=u["icon-size"].possiblyEvaluate(new t.default$16(e.zoom+1)),c.textMaxSize=u["text-size"].possiblyEvaluate(new t.default$16(18));for(var v=24*l.get("text-line-height"),_="map"===l.get("text-rotation-alignment")&&"line"===l.get("symbol-placement"),x=l.get("text-keep-upright"),b=0,w=e.features;b=t.default$8||c.y<0||c.y>=t.default$8||e.symbolInstances.push(function(e,n,r,i,a,l,u,c,f,h,p,d,m,g,v,_,x,b,w,k,T){var A,M,S=e.addToLineVertexArray(n,r),C=0,z=0,E=0,L=i.horizontal?i.horizontal.text:"",I=[];i.horizontal&&(A=new s(u,r,n,c,f,h,i.horizontal,p,d,m,e.overscaling),z+=y(e,n,i.horizontal,l,m,w,g,S,i.vertical?t.WritingMode.horizontal:t.WritingMode.horizontalOnly,I,k,T),i.vertical&&(E+=y(e,n,i.vertical,l,m,w,g,S,t.WritingMode.vertical,I,k,T)));var P=A?A.boxStartIndex:e.collisionBoxArray.length,D=A?A.boxEndIndex:e.collisionBoxArray.length;if(a){var O=function(e,n,r,i,a,o){var s,l,u,c,f=n.image,h=r.layout,p=n.top-1/f.pixelRatio,d=n.left-1/f.pixelRatio,m=n.bottom+1/f.pixelRatio,g=n.right+1/f.pixelRatio;if("none"!==h.get("icon-text-fit")&&a){var y=g-d,v=m-p,_=h.get("text-size").evaluate(o)/24,x=a.left*_,b=a.right*_,w=a.top*_,k=b-x,T=a.bottom*_-w,A=h.get("icon-text-fit-padding")[0],M=h.get("icon-text-fit-padding")[1],S=h.get("icon-text-fit-padding")[2],C=h.get("icon-text-fit-padding")[3],z="width"===h.get("icon-text-fit")?.5*(T-v):0,E="height"===h.get("icon-text-fit")?.5*(k-y):0,L="width"===h.get("icon-text-fit")||"both"===h.get("icon-text-fit")?k:y,I="height"===h.get("icon-text-fit")||"both"===h.get("icon-text-fit")?T:v;s=new t.default$1(x+E-C,w+z-A),l=new t.default$1(x+E+M+L,w+z-A),u=new t.default$1(x+E+M+L,w+z+S+I),c=new t.default$1(x+E-C,w+z+S+I)}else s=new t.default$1(d,p),l=new t.default$1(g,p),u=new t.default$1(g,m),c=new t.default$1(d,m);var P=r.layout.get("icon-rotate").evaluate(o)*Math.PI/180;if(P){var D=Math.sin(P),O=Math.cos(P),R=[O,-D,D,O];s._matMult(R),l._matMult(R),c._matMult(R),u._matMult(R)}return[{tl:s,tr:l,bl:c,br:u,tex:f.paddedRect,writingMode:void 0,glyphOffset:[0,0]}]}(0,a,l,0,i.horizontal,w);M=new s(u,r,n,c,f,h,a,v,_,!1,e.overscaling),C=4*O.length;var R=e.iconSizeData,F=null;"source"===R.functionType?F=[10*l.layout.get("icon-size").evaluate(w)]:"composite"===R.functionType&&(F=[10*T.compositeIconSizes[0].evaluate(w),10*T.compositeIconSizes[1].evaluate(w)]),e.addSymbols(e.icon,O,F,b,x,w,!1,n,S.lineStartIndex,S.lineLength)}var B=M?M.boxStartIndex:e.collisionBoxArray.length,N=M?M.boxEndIndex:e.collisionBoxArray.length;return e.glyphOffsetArray.length>=t.default$14.MAX_GLYPHS&&t.warnOnce("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),{key:L,textBoxStartIndex:P,textBoxEndIndex:D,iconBoxStartIndex:B,iconBoxEndIndex:N,textOffset:g,iconOffset:b,anchor:n,line:r,featureIndex:c,feature:w,numGlyphVertices:z,numVerticalGlyphVertices:E,numIconVertices:C,textOpacityState:new o,iconOpacityState:new o,isDuplicate:!1,placedTextSymbolIndices:I,crossTileID:0}}(e,c,a,r,i,e.layers[0],e.collisionBoxArray,n.index,n.sourceLayerIndex,e.index,x,T,S,m,w,A,C,g,n,l,u))};if("line"===d.get("symbol-placement"))for(var L=0,I=function(e,n,r,i,a){for(var o=[],s=0;s=i&&h.x>=i||(f.x>=i?f=new t.default$1(i,f.y+(h.y-f.y)*((i-f.x)/(h.x-f.x)))._round():h.x>=i&&(h=new t.default$1(i,f.y+(h.y-f.y)*((i-f.x)/(h.x-f.x)))._round()),f.y>=a&&h.y>=a||(f.y>=a?f=new t.default$1(f.x+(h.x-f.x)*((a-f.y)/(h.y-f.y)),a)._round():h.y>=a&&(h=new t.default$1(f.x+(h.x-f.x)*((a-f.y)/(h.y-f.y)),a)._round()),u&&f.equals(u[u.length-1])||(u=[f],o.push(u)),u.push(h)))))}return o}(n.geometry,0,0,t.default$8,t.default$8);L=0;o--)if(r.dist(a[o])0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,a=e[i];if(n(r,a)>=0)break;e[t]=a,t=i}e[t]=r},_down:function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=s,t=a}e[t]=i}},l.default=u;var _=function(e){var n=new t.AlphaImage({width:0,height:0}),r={},i=new t.default$2(0,0,{autoResize:!0});for(var a in e){var o=e[a],s=r[a]={};for(var l in o){var u=o[+l];if(u&&0!==u.bitmap.width&&0!==u.bitmap.height){var c=i.packOne(u.bitmap.width+2,u.bitmap.height+2);n.resize({width:i.w,height:i.h}),t.AlphaImage.copy(u.bitmap,n,{x:0,y:0},{x:c.x+1,y:c.y+1},u.bitmap),s[l]={rect:c,metrics:u.metrics}}}}i.shrink(),n.resize({width:i.w,height:i.h}),this.image=n,this.positions=r};t.register("GlyphAtlas",_);var x=function(e){this.tileID=new t.OverscaledTileID(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming};function b(e,n){for(var r=new t.default$16(n),i=0,a=e;i=M.maxzoom||"none"!==M.visibility&&(b(A,a.zoom),(f[M.id]=M.createBucket({index:s.bucketLayerIDs.length,layers:A,zoom:a.zoom,pixelRatio:a.pixelRatio,overscaling:a.overscaling,collisionBoxArray:a.collisionBoxArray,sourceLayerIndex:y})).populate(v,h),s.bucketLayerIDs.push(A.map(function(t){return t.id})))}}}var S=t.mapObject(h.glyphDependencies,function(t){return Object.keys(t).map(Number)});Object.keys(S).length?r.send("getGlyphs",{uid:this.uid,stacks:S},function(t,e){l||(l=t,u=e,z.call(a))}):u={};var C=Object.keys(h.iconDependencies);function z(){if(l)return i(l);if(u&&c){var e=new _(u),n=new t.default$28(c);for(var r in f){var a=f[r];a instanceof t.default$14&&(b(a.layers,this.zoom),m(a,u,e.positions,c,n.positions,this.showCollisionBoxes))}this.status="done",i(null,{buckets:t.values(f).filter(function(t){return!t.isEmpty()}),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,iconAtlasImage:n.image})}}C.length?r.send("getImages",{icons:C},function(t,e){l||(l=t,c=e,z.call(a))}):c={},z.call(this)};var w=function(t){return!(!performance||!performance.getEntriesByName)&&performance.getEntriesByName(t)};function k(e,n){var r=t.getArrayBuffer(e.request,function(e,r){e?n(e):r&&n(null,{vectorTile:new t.default$29.VectorTile(new t.default$30(r.data)),rawData:r.data,cacheControl:r.cacheControl,expires:r.expires})});return function(){r.abort(),n()}}var T=function(t,e,n){this.actor=t,this.layerIndex=e,this.loadVectorData=n||k,this.loading={},this.loaded={}};T.prototype.loadTile=function(e,n){var r=this,i=e.uid;this.loading||(this.loading={});var a=this.loading[i]=new x(e);a.abort=this.loadVectorData(e,function(o,s){if(delete r.loading[i],o||!s)return n(o);var l=s.rawData,u={};s.expires&&(u.expires=s.expires),s.cacheControl&&(u.cacheControl=s.cacheControl);var c={};if(e.request&&e.request.collectResourceTiming){var f=w(e.request.url);f&&(c.resourceTiming=JSON.parse(JSON.stringify(f)))}a.vectorTile=s.vectorTile,a.parse(s.vectorTile,r.layerIndex,r.actor,function(e,r){if(e||!r)return n(e);n(null,t.extend({rawTileData:l.slice(0)},r,u,c))}),r.loaded=r.loaded||{},r.loaded[i]=a})},T.prototype.reloadTile=function(t,e){var n=this.loaded,r=t.uid,i=this;if(n&&n[r]){var a=n[r];a.showCollisionBoxes=t.showCollisionBoxes;var o=function(t,n){var r=a.reloadCallback;r&&(delete a.reloadCallback,a.parse(a.vectorTile,i.layerIndex,i.actor,r)),e(t,n)};"parsing"===a.status?a.reloadCallback=o:"done"===a.status&&a.parse(a.vectorTile,this.layerIndex,this.actor,o)}},T.prototype.abortTile=function(t,e){var n=this.loading,r=t.uid;n&&n[r]&&n[r].abort&&(n[r].abort(),delete n[r]),e()},T.prototype.removeTile=function(t,e){var n=this.loaded,r=t.uid;n&&n[r]&&delete n[r],e()};var A=function(){this.loading={},this.loaded={}};A.prototype.loadTile=function(e,n){var r=e.uid,i=e.encoding,a=new t.default$31(r);this.loading[r]=a,a.loadFromImage(e.rawImageData,i),delete this.loading[r],this.loaded=this.loaded||{},this.loaded[r]=a,n(null,a)},A.prototype.removeTile=function(t){var e=this.loaded,n=t.uid;e&&e[n]&&delete e[n]};var M={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:6356752.3142};function S(t){var e=0;if(t&&t.length>0){e+=Math.abs(C(t[0]));for(var n=1;n2){for(o=0;o=0}(t)===e?t:t.reverse()}var D=t.default$29.VectorTileFeature.prototype.toGeoJSON,O=function(e){this._feature=e,this.extent=t.default$8,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))};O.prototype.loadGeometry=function(){if(1===this._feature.type){for(var e=[],n=0,r=this._feature.geometry;n>31}function Y(t,e){for(var n=t.loadGeometry(),r=t.type,i=0,a=0,o=n.length,s=0;si;){if(a-i>600){var s=a-i+1,l=r-i+1,u=Math.log(s),c=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*c*(s-c)/s)*(l-s/2<0?-1:1);t(e,n,r,Math.max(i,Math.floor(r-l*c/s+f)),Math.min(a,Math.floor(r+(s-l)*c/s+f)),o)}var h=n[2*r+o],p=i,d=a;for(Q(e,n,i,r),n[2*a+o]>h&&Q(e,n,i,a);ph;)d--}n[2*i+o]===h?Q(e,n,i,d):Q(e,n,++d,a),d<=r&&(i=d+1),r<=d&&(a=d-1)}}(e,n,s,i,a,o%2),t(e,n,r,i,s-1,o+1),t(e,n,r,s+1,a,o+1)}};function Q(t,e,n,r){tt(t,n,r),tt(e,2*n,2*r),tt(e,2*n+1,2*r+1)}function tt(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function et(t,e,n,r){var i=t-n,a=e-r;return i*i+a*a}var nt=function(t,e,n,r,i){return new rt(t,e,n,r,i)};function rt(t,e,n,r,i){e=e||it,n=n||at,i=i||Array,this.nodeSize=r||64,this.points=t,this.ids=new i(t.length),this.coords=new i(2*t.length);for(var a=0;a=n&&s<=i&&l>=r&&l<=a&&c.push(t[d]);else{var m=Math.floor((p+h)/2);s=e[2*m],l=e[2*m+1],s>=n&&s<=i&&l>=r&&l<=a&&c.push(t[m]);var g=(f+1)%2;(0===f?n<=s:r<=l)&&(u.push(p),u.push(m-1),u.push(g)),(0===f?i>=s:a>=l)&&(u.push(m+1),u.push(h),u.push(g))}}return c}(this.ids,this.coords,t,e,n,r,this.nodeSize)},within:function(t,e,n){return function(t,e,n,r,i,a){for(var o=[0,t.length-1,0],s=[],l=i*i;o.length;){var u=o.pop(),c=o.pop(),f=o.pop();if(c-f<=a)for(var h=f;h<=c;h++)et(e[2*h],e[2*h+1],n,r)<=l&&s.push(t[h]);else{var p=Math.floor((f+c)/2),d=e[2*p],m=e[2*p+1];et(d,m,n,r)<=l&&s.push(t[p]);var g=(u+1)%2;(0===u?n-i<=d:r-i<=m)&&(o.push(f),o.push(p-1),o.push(g)),(0===u?n+i>=d:r+i>=m)&&(o.push(p+1),o.push(c),o.push(g))}}return s}(this.ids,this.coords,t,e,n,this.nodeSize)}};function ot(t){this.options=pt(Object.create(this.options),t),this.trees=new Array(this.options.maxZoom+1)}function st(t,e,n,r,i){return{x:t,y:e,zoom:1/0,id:r,properties:i,parentId:-1,numPoints:n}}function lt(t,e){var n=t.geometry.coordinates;return{x:ft(n[0]),y:ht(n[1]),zoom:1/0,id:e,parentId:-1}}function ut(t){return{type:"Feature",properties:ct(t),geometry:{type:"Point",coordinates:[(r=t.x,360*(r-.5)),(e=t.y,n=(180-360*e)*Math.PI/180,360*Math.atan(Math.exp(n))/Math.PI-90)]}};var e,n,r}function ct(t){var e=t.numPoints,n=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return pt(pt({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:n})}function ft(t){return t/360+.5}function ht(t){var e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function pt(t,e){for(var n in e)t[n]=e[n];return t}function dt(t){return t.x}function mt(t){return t.y}function gt(t,e,n,r,i,a){var o=i-n,s=a-r;if(0!==o||0!==s){var l=((t-n)*o+(e-r)*s)/(o*o+s*s);l>1?(n=i,r=a):l>0&&(n+=o*l,r+=s*l)}return(o=t-n)*o+(s=e-r)*s}function yt(t,e,n,r){var i={id:t||null,type:e,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,n=t.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)vt(t,e);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r0&&(o+=r?(i*u-l*a)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-a,2))),i=l,a=u}var c=e.length-3;e[2]=1,function t(e,n,r,i){for(var a,o=i,s=e[n],l=e[n+1],u=e[r],c=e[r+1],f=n+3;fo&&(a=f,o=h)}o>i&&(a-n>3&&t(e,n,a,i),e[a+2]=o,r-a>3&&t(e,a,r,i))}(e,0,c,n),e[c+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function wt(t,e,n,r){for(var i=0;i1?1:n}function At(t,e,n,r,i,a,o,s){if(r/=e,a>=(n/=e)&&o<=r)return t;if(a>r||o=n&&d<=r)l.push(c);else if(!(p>r||d=n&&o<=r&&(e.push(t[a]),e.push(t[a+1]),e.push(t[a+2]))}}function St(t,e,n,r,i,a,o){for(var s,l,u=Ct(t),c=0===i?Lt:It,f=t.start,h=0;h=n&&(l=c(u,p,d,g,y,n),o&&(u.start=f+s*l)):v>r?_<=r&&(l=c(u,p,d,g,y,r),o&&(u.start=f+s*l)):Et(u,p,d,m),_=n&&(l=c(u,p,d,g,y,n),x=!0),_>r&&v<=r&&(l=c(u,p,d,g,y,r),x=!0),!a&&x&&(o&&(u.end=f+s*l),e.push(u),u=Ct(t)),o&&(f+=s)}var b=t.length-3;p=t[b],d=t[b+1],m=t[b+2],(v=0===i?p:d)>=n&&v<=r&&Et(u,p,d,m),b=u.length-3,a&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&Et(u,u[0],u[1],u[2]),u.length&&e.push(u)}function Ct(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function zt(t,e,n,r,i,a){for(var o=0;oo.maxX&&(o.maxX=c),f>o.maxY&&(o.maxY=f)}return o}function Bt(t,e,n,r){var i=e.geometry,a=e.type,o=[];if("Point"===a||"MultiPoint"===a)for(var s=0;s0&&e.size<(i?o:r))n.numPoints+=e.length/3;else{for(var s=[],l=0;lo)&&(n.numSimplified++,s.push(e[l]),s.push(e[l+1])),n.numPoints++;i&&function(t,e){for(var n=0,r=0,i=t.length,a=i-2;r0===e)for(r=0,i=t.length;r24)throw new Error("maxZoom should be in the 0-24 range");var r=function(t,e){var n=[];if("FeatureCollection"===t.type)for(var r=0;r=this.options.minZoom;i--){var a=+Date.now();this.trees[i+1]=nt(r,dt,mt,this.options.nodeSize,Float32Array),r=this._cluster(r,i),e&&console.log("z%d: %d clusters in %dms",i,r.length,+Date.now()-a)}return this.trees[this.options.minZoom]=nt(r,dt,mt,this.options.nodeSize,Float32Array),e&&console.timeEnd("total time"),this},getClusters:function(t,e){for(var n=this.trees[this._limitZoom(e)],r=n.range(ft(t[0]),ht(t[3]),ft(t[2]),ht(t[1])),i=[],a=0;a1&&console.time("creation"),h=this.tiles[f]=Ft(t,e,n,r,l),this.tileCoords.push({z:e,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,n,r,h.numFeatures,h.numPoints,h.numSimplified),console.timeEnd("creation"));var p="z"+e;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(h.source=t,i){if(e===l.maxZoom||e===i)continue;var d=1<1&&console.time("clipping");var m,g,y,v,_,x,b=.5*l.buffer/l.extent,w=.5-b,k=.5+b,T=1+b;m=g=y=v=null,_=At(t,c,n-b,n+k,0,h.minX,h.maxX,l),x=At(t,c,n+w,n+T,0,h.minX,h.maxX,l),t=null,_&&(m=At(_,c,r-b,r+k,1,h.minY,h.maxY,l),g=At(_,c,r+w,r+T,1,h.minY,h.maxY,l),_=null),x&&(y=At(x,c,r-b,r+k,1,h.minY,h.maxY,l),v=At(x,c,r+w,r+T,1,h.minY,h.maxY,l),x=null),u>1&&console.timeEnd("clipping"),s.push(m||[],e+1,2*n,2*r),s.push(g||[],e+1,2*n,2*r+1),s.push(y||[],e+1,2*n+1,2*r),s.push(v||[],e+1,2*n+1,2*r+1)}}},jt.prototype.getTile=function(t,e,n){var r=this.options,i=r.extent,a=r.debug;if(t<0||t>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",t,e,n);for(var l,u=t,c=e,f=n;!l&&u>0;)u--,c=Math.floor(c/2),f=Math.floor(f/2),l=this.tiles[Vt(u,c,f)];return l&&l.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,c,f),a>1&&console.time("drilling down"),this.splitTile(l.source,u,c,f,t,e,n),a>1&&console.timeEnd("drilling down"),this.tiles[s]?Ot(this.tiles[s],i):null):null};var Ut=function(e){function n(t,n,r){e.call(this,t,n,qt),r&&(this.loadGeoJSON=r)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.loadData=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),this._pendingCallback=e,this._pendingLoadDataParams=t,this._state&&"Idle"!==this._state?this._state="NeedsLoadData":(this._state="Coalescing",this._loadData())},n.prototype._loadData=function(){var t=this;if(this._pendingCallback&&this._pendingLoadDataParams){var e=this._pendingCallback,n=this._pendingLoadDataParams;delete this._pendingCallback,delete this._pendingLoadDataParams,this.loadGeoJSON(n,function(r,i){if(r||!i)return e(r);if("object"!=typeof i)return e(new Error("Input data is not a valid GeoJSON object."));!function t(e,n){switch(e&&e.type||null){case"FeatureCollection":return e.features=e.features.map(L(t,n)),e;case"Feature":return e.geometry=t(e.geometry,n),e;case"Polygon":case"MultiPolygon":return function(t,e){return"Polygon"===t.type?t.coordinates=I(t.coordinates,e):"MultiPolygon"===t.type&&(t.coordinates=t.coordinates.map(L(I,e))),t}(e,n);default:return e}}(i,!0);try{t._geoJSONIndex=n.cluster?function(t){return new ot(t)}(n.superclusterOptions).load(i.features):new jt(i,n.geojsonVtOptions)}catch(r){return e(r)}t.loaded={};var a={};if(n.request&&n.request.collectResourceTiming){var o=w(n.request.url);o&&(a.resourceTiming={},a.resourceTiming[n.source]=JSON.parse(JSON.stringify(o)))}e(null,a)})}},n.prototype.coalesce=function(){"Coalescing"===this._state?this._state="Idle":"NeedsLoadData"===this._state&&(this._state="Coalescing",this._loadData())},n.prototype.reloadTile=function(t,n){var r=this.loaded,i=t.uid;return r&&r[i]?e.prototype.reloadTile.call(this,t,n):this.loadTile(t,n)},n.prototype.loadGeoJSON=function(e,n){if(e.request)t.getJSON(e.request,n);else{if("string"!=typeof e.data)return n(new Error("Input data is not a valid GeoJSON object."));try{return n(null,JSON.parse(e.data))}catch(t){return n(new Error("Input data is not a valid GeoJSON object."))}}},n.prototype.removeSource=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),e()},n}(T),Ht=function(e){var n=this;this.self=e,this.actor=new t.default$7(e,this),this.layerIndexes={},this.workerSourceTypes={vector:T,geojson:Ut},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=function(t,e){if(n.workerSourceTypes[t])throw new Error('Worker source with name "'+t+'" already registered.');n.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=function(e){if(t.plugin.isLoaded())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText}};return Ht.prototype.setLayers=function(t,e,n){this.getLayerIndex(t).replace(e),n()},Ht.prototype.updateLayers=function(t,e,n){this.getLayerIndex(t).update(e.layers,e.removedIds),n()},Ht.prototype.loadTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).loadTile(e,n)},Ht.prototype.loadDEMTile=function(t,e,n){this.getDEMWorkerSource(t,e.source).loadTile(e,n)},Ht.prototype.reloadTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).reloadTile(e,n)},Ht.prototype.abortTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).abortTile(e,n)},Ht.prototype.removeTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).removeTile(e,n)},Ht.prototype.removeDEMTile=function(t,e){this.getDEMWorkerSource(t,e.source).removeTile(e)},Ht.prototype.removeSource=function(t,e,n){if(this.workerSources[t]&&this.workerSources[t][e.type]&&this.workerSources[t][e.type][e.source]){var r=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==r.removeSource?r.removeSource(e,n):n()}},Ht.prototype.loadWorkerSource=function(t,e,n){try{this.self.importScripts(e.url),n()}catch(t){n(t.toString())}},Ht.prototype.loadRTLTextPlugin=function(e,n,r){try{t.plugin.isLoaded()||(this.self.importScripts(n),r(t.plugin.isLoaded()?null:new Error("RTL Text Plugin failed to import scripts from "+n)))}catch(t){r(t.toString())}},Ht.prototype.getLayerIndex=function(t){var e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new r),e},Ht.prototype.getWorkerSource=function(t,e,n){var r=this;if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][n]){var i={send:function(e,n,i){r.actor.send(e,n,i,t)}};this.workerSources[t][e][n]=new this.workerSourceTypes[e](i,this.getLayerIndex(t))}return this.workerSources[t][e][n]},Ht.prototype.getDEMWorkerSource=function(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new A),this.demWorkerSources[t][e]},"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&new Ht(self),Ht}),i(0,function(t){var e=t.createCommonjsModule(function(t){function e(t){return!!("undefined"!=typeof window&&"undefined"!=typeof document&&Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray&&Function.prototype&&Function.prototype.bind&&Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions&&"JSON"in window&&"parse"in JSON&&"stringify"in JSON&&function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,n=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(n);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()&&"Uint8ClampedArray"in window&&function(t){return void 0===n[t]&&(n[t]=function(t){var n=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,n.probablySupportsContext?n.probablySupportsContext("webgl",r)||n.probablySupportsContext("experimental-webgl",r):n.supportsContext?n.supportsContext("webgl",r)||n.supportsContext("experimental-webgl",r):n.getContext("webgl",r)||n.getContext("experimental-webgl",r)}(t)),n[t]}(t&&t.failIfMajorPerformanceCaveat))}t.exports?t.exports=e:window&&(window.mapboxgl=window.mapboxgl||{},window.mapboxgl.supported=e);var n={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0}}),n=t.default.performance&&t.default.performance.now?t.default.performance.now.bind(t.default.performance):Date.now.bind(Date),r=t.default.requestAnimationFrame||t.default.mozRequestAnimationFrame||t.default.webkitRequestAnimationFrame||t.default.msRequestAnimationFrame,i=t.default.cancelAnimationFrame||t.default.mozCancelAnimationFrame||t.default.webkitCancelAnimationFrame||t.default.msCancelAnimationFrame,a={now:n,frame:function(t){return r(t)},cancelFrame:function(t){return i(t)},getImageData:function(e){var n=t.default.document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return n.width=e.width,n.height=e.height,r.drawImage(e,0,0,e.width,e.height),r.getImageData(0,0,e.width,e.height)},hardwareConcurrency:t.default.navigator.hardwareConcurrency||4,get devicePixelRatio(){return t.default.devicePixelRatio},supportsWebp:!1};if(t.default.document){var o=t.default.document.createElement("img");o.onload=function(){a.supportsWebp=!0},o.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="}var s={create:function(e,n,r){var i=t.default.document.createElement(e);return n&&(i.className=n),r&&r.appendChild(i),i},createNS:function(e,n){return t.default.document.createElementNS(e,n)}},l=t.default.document?t.default.document.documentElement.style:null;function u(t){if(!l)return null;for(var e=0;e=0?0:e.button},s.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};var g={API_URL:"https://api.mapbox.com",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null},y="See https://www.mapbox.com/api-documentation/#access-tokens";function v(t,e){var n=A(g.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,"/"!==n.path&&(t.path=""+n.path+t.path),!g.REQUIRE_ACCESS_TOKEN)return M(t);if(!(e=e||g.ACCESS_TOKEN))throw new Error("An API access token is required to use Mapbox GL. "+y);if("s"===e[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+y);return t.params.push("access_token="+e),M(t)}function _(t){return 0===t.indexOf("mapbox:")}var x=function(t,e){if(!_(t))return t;var n=A(t);return n.path="/v4/"+n.authority+".json",n.params.push("secure"),v(n,e)},b=function(t,e,n,r){var i=A(t);return _(t)?(i.path="/styles/v1"+i.path+"/sprite"+e+n,v(i,r)):(i.path+=""+e+n,M(i))},w=/(\.(png|jpg)\d*)(?=$)/,k=function(t,e,n){if(!e||!_(e))return t;var r=A(t),i=a.devicePixelRatio>=2||512===n?"@2x":"",o=a.supportsWebp?".webp":"$1";return r.path=r.path.replace(w,""+i+o),function(t){for(var e=0;e=0?1.2:1))}function R(t,e,n,r,i,a,o){for(var s=0;s65535)e(new Error("glyphs > 65535 not supported"));else{var l=a.requests[s];l||(l=a.requests[s]=[],B.loadGlyphRange(n,s,r.url,r.requestTransform,function(t,e){if(e)for(var n in e)a.glyphs[+n]=e[+n];for(var r=0,i=l;rthis.height)return t.warnOnce("LineAtlas out of space"),null;for(var a=0,o=0;o90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")};Z.prototype.wrap=function(){return new Z(t.wrap(this.lng,-180,180),this.lat)},Z.prototype.toArray=function(){return[this.lng,this.lat]},Z.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},Z.prototype.toBounds=function(t){var e=360*t/40075017,n=e/Math.cos(Math.PI/180*this.lat);return new G(new Z(this.lng-n,this.lat-e),new Z(this.lng+n,this.lat+e))},Z.convert=function(t){if(t instanceof Z)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Z(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Z(Number(t.lng),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, or an array of [, ]")};var G=function(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))};G.prototype.setNorthEast=function(t){return this._ne=t instanceof Z?new Z(t.lng,t.lat):Z.convert(t),this},G.prototype.setSouthWest=function(t){return this._sw=t instanceof Z?new Z(t.lng,t.lat):Z.convert(t),this},G.prototype.extend=function(t){var e,n,r=this._sw,i=this._ne;if(t instanceof Z)e=t,n=t;else{if(!(t instanceof G))return Array.isArray(t)?t.every(Array.isArray)?this.extend(G.convert(t)):this.extend(Z.convert(t)):this;if(e=t._sw,n=t._ne,!e||!n)return this}return r||i?(r.lng=Math.min(e.lng,r.lng),r.lat=Math.min(e.lat,r.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Z(e.lng,e.lat),this._ne=new Z(n.lng,n.lat)),this},G.prototype.getCenter=function(){return new Z((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},G.prototype.getSouthWest=function(){return this._sw},G.prototype.getNorthEast=function(){return this._ne},G.prototype.getNorthWest=function(){return new Z(this.getWest(),this.getNorth())},G.prototype.getSouthEast=function(){return new Z(this.getEast(),this.getSouth())},G.prototype.getWest=function(){return this._sw.lng},G.prototype.getSouth=function(){return this._sw.lat},G.prototype.getEast=function(){return this._ne.lng},G.prototype.getNorth=function(){return this._ne.lat},G.prototype.toArray=function(){return[this._sw.toArray(),this._ne.toArray()]},G.prototype.toString=function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"},G.prototype.isEmpty=function(){return!(this._sw&&this._ne)},G.convert=function(t){return!t||t instanceof G?t:new G(t)};var $=function(t,e,n){this.bounds=G.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=n||24};$.prototype.validateBounds=function(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]},$.prototype.contains=function(t){var e=Math.floor(this.lngX(this.bounds.getWest(),t.z)),n=Math.floor(this.latY(this.bounds.getNorth(),t.z)),r=Math.ceil(this.lngX(this.bounds.getEast(),t.z)),i=Math.ceil(this.latY(this.bounds.getSouth(),t.z));return t.x>=e&&t.x=n&&t.y0&&(l[new t.OverscaledTileID(e.overscaledZ,a,n.z,i,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,n.z,o,n.y-1).key]={backfilled:!1}),n.y+10&&(r.resourceTiming=e._resourceTiming,e._resourceTiming=[]),e.fire(new t.Event("data",r))}})},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.setData=function(e){var n=this;return this._data=e,this.fire(new t.Event("dataloading",{dataType:"source"})),this._updateWorkerData(function(e){if(e)return n.fire(new t.ErrorEvent(e));var r={dataType:"source",sourceDataType:"content"};n._collectResourceTiming&&n._resourceTiming&&n._resourceTiming.length>0&&(r.resourceTiming=n._resourceTiming,n._resourceTiming=[]),n.fire(new t.Event("data",r))}),this},n.prototype._updateWorkerData=function(e){var n,r,i=this,a=t.extend({},this.workerOptions),o=this._data;"string"==typeof o?(a.request=this.map._transformRequest((n=o,(r=t.default.document.createElement("a")).href=n,r.href),t.ResourceType.Source),a.request.collectResourceTiming=this._collectResourceTiming):a.data=JSON.stringify(o),this.workerID=this.dispatcher.send(this.type+"."+a.source+".loadData",a,function(t,n){i._removed||n&&n.abandoned||(i._loaded=!0,n&&n.resourceTiming&&n.resourceTiming[i.id]&&(i._resourceTiming=n.resourceTiming[i.id].slice(0)),i.dispatcher.send(i.type+"."+a.source+".coalesce",null,null,i.workerID),e(t))},this.workerID)},n.prototype.loadTile=function(t,e){var n=this,r=void 0===t.workerID?"loadTile":"reloadTile",i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes};t.workerID=this.dispatcher.send(r,i,function(i,a){return t.unloadVectorData(),t.aborted?e(null):i?e(i):(t.loadVectorData(a,n.map.painter,"reloadTile"===r),e(null))},this.workerID)},n.prototype.abortTile=function(t){t.aborted=!0},n.prototype.unloadTile=function(t){t.unloadVectorData(),this.dispatcher.send("removeTile",{uid:t.uid,type:this.type,source:this.id},null,t.workerID)},n.prototype.onRemove=function(){this._removed=!0,this.dispatcher.send("removeSource",{type:this.type,source:this.id},null,this.workerID)},n.prototype.serialize=function(){return t.extend({},this._options,{type:this.type,data:this._data})},n.prototype.hasTransition=function(){return!1},n}(t.Evented),K=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Q=function(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null};Q.prototype.bind=function(t,e,n,r,i,a,o,s){this.context=t;for(var l=this.boundPaintVertexBuffers.length!==r.length,u=0;!l&&u>s.z,u=new t.default$1(s.x*l,s.y*l),c=new t.default$1(u.x+l,u.y+l),f=this.segments.prepareSegment(4,r,i);r.emplaceBack(u.x,u.y,u.x,u.y),r.emplaceBack(c.x,u.y,c.x,u.y),r.emplaceBack(u.x,c.y,u.x,c.y),r.emplaceBack(c.x,c.y,c.x,c.y);var h=f.vertexLength;i.emplaceBack(h,h+1,h+2),i.emplaceBack(h+1,h+2,h+3),f.vertexLength+=4,f.primitiveLength+=2}this.maskedBoundsBuffer=n.createVertexBuffer(r,K.members),this.maskedIndexBuffer=n.createIndexBuffer(i)}},st.prototype.hasData=function(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state},st.prototype.setExpiryData=function(e){var n=this.expirationTime;if(e.cacheControl){var r=t.parseCacheControl(e.cacheControl);r["max-age"]&&(this.expirationTime=Date.now()+1e3*r["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){var i=Date.now(),a=!1;if(this.expirationTime>i)a=!1;else if(n)if(this.expirationTimethis.max){var o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this},lt.prototype.has=function(t){return t.wrapped().key in this.data},lt.prototype.getAndRemove=function(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null},lt.prototype._getAndRemoveByKey=function(t){var e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value},lt.prototype.get=function(t){return this.has(t)?this.data[t.wrapped().key][0].value:null},lt.prototype.remove=function(t,e){if(!this.has(t))return this;var n=t.wrapped().key,r=void 0===e?0:this.data[n].indexOf(e),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this},lt.prototype.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this};var ut=function(t,e,n){this.context=t;var r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(n),this.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};ut.prototype.unbindVAO=function(){this.context.extVertexArrayObject&&this.context.bindVertexArrayOES.set(null)},ut.prototype.bind=function(){this.context.bindElementBuffer.set(this.buffer)},ut.prototype.updateData=function(t){var e=this.context.gl;this.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)},ut.prototype.destroy=function(){var t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)};var ct={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},ft=function(t,e,n,r){this.length=e.length,this.attributes=n,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;var i=t.gl;this.buffer=i.createBuffer(),t.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};ft.prototype.bind=function(){this.context.bindVertexBuffer.set(this.buffer)},ft.prototype.updateData=function(t){var e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)},ft.prototype.enableAttributes=function(t,e){for(var n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,n,r),t.neighboringTiles&&t.neighboringTiles[a]&&(t.neighboringTiles[a].backfilled=!0)))}},n.prototype.getTile=function(t){return this.getTileByID(t.key)},n.prototype.getTileByID=function(t){return this._tiles[t]},n.prototype.getZoom=function(t){return t.zoom+t.scaleZoom(t.tileSize/this._source.tileSize)},n.prototype._findLoadedChildren=function(t,e,n){var r=!1;for(var i in this._tiles){var a=this._tiles[i];if(!(n[i]||!a.hasData()||a.tileID.overscaledZ<=t.overscaledZ||a.tileID.overscaledZ>e)){var o=Math.pow(2,a.tileID.canonical.z-t.canonical.z);if(Math.floor(a.tileID.canonical.x/o)===t.canonical.x&&Math.floor(a.tileID.canonical.y/o)===t.canonical.y)for(n[i]=a.tileID,r=!0;a&&a.tileID.overscaledZ-1>t.overscaledZ;){var s=a.tileID.scaledTo(a.tileID.overscaledZ-1);if(!s)break;(a=this._tiles[s.key])&&a.hasData()&&(delete n[i],n[s.key]=s)}}}return r},n.prototype.findLoadedParent=function(t,e,n){for(var r=t.overscaledZ-1;r>=e;r--){var i=t.scaledTo(r);if(!i)return;var a=String(i.key),o=this._tiles[a];if(o&&o.hasData())return n[a]=i,o;if(this._cache.has(i))return n[a]=i,this._cache.get(i)}},n.prototype.updateCacheSize=function(t){var e=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),n=Math.floor(5*e),r="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(r)},n.prototype.handleWrapJump=function(t){var e=(t-(void 0===this._prevLng?t:this._prevLng))/360,n=Math.round(e);if(this._prevLng=t,n){var r={};for(var i in this._tiles){var a=this._tiles[i];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+n),r[a.tileID.key]=a}for(var o in this._tiles=r,this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(var s in this._tiles){var l=this._tiles[s];this._setTileReloadTimer(s,l)}}},n.prototype.update=function(e){var r=this;if(this.transform=e,this._sourceLoaded&&!this._paused){var i;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(function(e){return new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)}):(i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}),this._source.hasTile&&(i=i.filter(function(t){return r._source.hasTile(t)}))):i=[];var o,s=(this._source.roundZoom?Math.round:Math.floor)(this.getZoom(e)),l=Math.max(s-n.maxOverzooming,this._source.minzoom),u=Math.max(s+n.maxUnderzooming,this._source.minzoom),c=this._updateRetainedTiles(i,s),f={};if(Xt(this._source.type))for(var h=Object.keys(c),p=0;p=a.now())){r._findLoadedChildren(m,u,c)&&(c[d]=m);var y=r.findLoadedParent(m,l,f);y&&r._addTile(y.tileID)}}for(o in f)c[o]||(r._coveredTiles[o]=!0);for(o in f)c[o]=f[o];for(var v=t.keysDifference(this._tiles,c),_=0;_this._source.maxzoom){var h=l.children(this._source.maxzoom)[0],p=this.getTile(h);p&&p.hasData()?r[h.key]=h:f=!1}else{this._findLoadedChildren(l,o,r);for(var d=l.children(this._source.maxzoom),m=0;m=a;--g){var y=l.scaledTo(g);if(i[y.key])break;if(i[y.key]=!0,!(u=this.getTile(y))&&c&&(u=this._addTile(y)),u&&(r[y.key]=y,c=u.wasRequested(),u.hasData()))break}}}return r},n.prototype._addTile=function(e){var n=this._tiles[e.key];if(n)return n;(n=this._cache.getAndRemove(e))&&(this._setTileReloadTimer(e.key,n),n.tileID=e);var r=Boolean(n);return r||(n=new st(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,this._tileLoaded.bind(this,n,e.key,n.state))),n?(n.uses++,this._tiles[e.key]=n,r||this._source.fire(new t.Event("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n):null},n.prototype._setTileReloadTimer=function(t,e){var n=this;t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);var r=e.getExpiryTimeout();r&&(this._timers[t]=setTimeout(function(){n._reloadTile(t,"expired"),delete n._timers[t]},r))},n.prototype._removeTile=function(t){var e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))},n.prototype.clearTiles=function(){for(var t in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(t);this._cache.reset()},n.prototype.tilesIn=function(e,n){for(var r=[],i=this.getIds(),a=1/0,o=1/0,s=-1/0,l=-1/0,u=e[0].zoom,c=0;c=0&&y[1].y+g>=0){for(var v=[],_=0;_=a.now())return!0}return!1},n}(t.Evented);function Wt(e,n){var r=n.zoomTo(e.canonical.z);return new t.default$1((r.column-(e.canonical.x+e.wrap*Math.pow(2,e.canonical.z)))*t.default$8,(r.row-e.canonical.y)*t.default$8)}function Xt(t){return"raster"===t||"image"===t||"video"===t}function Yt(){return new t.default.Worker(Cr.workerUrl)}$t.maxOverzooming=10,$t.maxUnderzooming=3;var Jt,Kt=function(){this.active={}};function Qt(e,n){var r={};for(var i in e)"ref"!==i&&(r[i]=e[i]);return t.default$18.forEach(function(t){t in n&&(r[t]=n[t])}),r}function te(t){t=t.slice();for(var e=Object.create(null),n=0;nthis.width||r<0||e>this.height)return!i&&[];var a=[];if(t<=0&&e<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(var o=0;o0:a},ue.prototype._queryCircle=function(t,e,n,r){var i=t-n,a=t+n,o=e-n,s=e+n;if(a<0||i>this.width||s<0||o>this.height)return!r&&[];var l=[],u={hitTest:r,circle:{x:t,y:e,radius:n},seenUids:{box:{},circle:{}}};return this._forEachCell(i,o,a,s,this._queryCellCircle,l,u),r?l.length>0:l},ue.prototype.query=function(t,e,n,r){return this._query(t,e,n,r,!1)},ue.prototype.hitTest=function(t,e,n,r){return this._query(t,e,n,r,!0)},ue.prototype.hitTestCircle=function(t,e,n){return this._queryCircle(t,e,n,!0)},ue.prototype._queryCell=function(t,e,n,r,i,a,o){var s=o.seenUids,l=this.boxCells[i];if(null!==l)for(var u=this.bboxes,c=0,f=l;c=u[p+0]&&r>=u[p+1]){if(o.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[h],x1:u[p],y1:u[p+1],x2:u[p+2],y2:u[p+3]})}}}var d=this.circleCells[i];if(null!==d)for(var m=this.circles,g=0,y=d;go*o+s*s},ue.prototype._circleAndRectCollide=function(t,e,n,r,i,a,o){var s=(a-r)/2,l=Math.abs(t-(r+s));if(l>s+n)return!1;var u=(o-i)/2,c=Math.abs(e-(i+u));if(c>u+n)return!1;if(l<=s||c<=u)return!0;var f=l-s,h=c-u;return f*f+h*h<=n*n};var ce=t.default$19.layout;function fe(e,n,r,i,a){var o=t.mat4.identity(new Float32Array(16));return n?(t.mat4.identity(o),t.mat4.scale(o,o,[1/a,1/a,1]),r||t.mat4.rotateZ(o,o,i.angle)):(t.mat4.scale(o,o,[i.width/2,-i.height/2,1]),t.mat4.translate(o,o,[1,-1,0]),t.mat4.multiply(o,o,e)),o}function he(e,n,r,i,a){var o=t.mat4.identity(new Float32Array(16));return n?(t.mat4.multiply(o,o,e),t.mat4.scale(o,o,[a,a,1]),r||t.mat4.rotateZ(o,o,-i.angle)):(t.mat4.scale(o,o,[1,-1,1]),t.mat4.translate(o,o,[-1,-1,0]),t.mat4.scale(o,o,[2/i.width,2/i.height,1])),o}function pe(e,n){var r=[e.x,e.y,0,1];ke(r,r,n);var i=r[3];return{point:new t.default$1(r[0]/i,r[1]/i),signedDistanceFromCamera:i}}function de(t,e){var n=t[0]/t[3],r=t[1]/t[3];return n>=-e[0]&&n<=e[0]&&r>=-e[1]&&r<=e[1]}function me(e,n,r,i,a,o,s,l){var u=i?e.textSizeData:e.iconSizeData,c=t.evaluateSizeForZoom(u,r.transform.zoom,ce.properties[i?"text-size":"icon-size"]),f=[256/r.width*2+1,256/r.height*2+1],h=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;h.clear();for(var p=e.lineVertexArray,d=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,m=r.transform.width/r.transform.height,g=!1,y=0;yMath.abs(r.x-n.x)*i?{useVertical:!0}:(e===t.WritingMode.vertical?n.yr.x)?{needsFlipping:!0}:null}function ve(e,n,r,i,a,o,s,l,u,c,f,h,p,d){var m,g=n/24,y=e.lineOffsetX*n,v=e.lineOffsetY*n;if(e.numGlyphs>1){var _=e.glyphStartIndex+e.numGlyphs,x=e.lineStartIndex,b=e.lineStartIndex+e.lineLength,w=ge(g,l,y,v,r,f,h,e,u,o,p,!1);if(!w)return{notEnoughRoom:!0};var k=pe(w.first.point,s).point,T=pe(w.last.point,s).point;if(i&&!r){var A=ye(e.writingMode,k,T,d);if(A)return A}m=[w.first];for(var M=e.glyphStartIndex+1;M<_-1;M++)m.push(xe(g*l.getoffsetX(M),y,v,r,f,h,e.segment,x,b,u,o,p,!1));m.push(w.last)}else{if(i&&!r){var S=pe(h,a).point,C=e.lineStartIndex+e.segment+1,z=new t.default$1(u.getx(C),u.gety(C)),E=pe(z,a),L=E.signedDistanceFromCamera>0?E.point:_e(h,z,S,1,a),I=ye(e.writingMode,S,L,d);if(I)return I}var P=xe(g*l.getoffsetX(e.glyphStartIndex),y,v,r,f,h,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,u,o,p,!1);if(!P)return{notEnoughRoom:!0};m=[P]}for(var D=0,O=m;D0?1:-1,g=0;i&&(m*=-1,g=Math.PI),m<0&&(g+=Math.PI);for(var y=m>0?l+s:l+s+1,v=y,_=a,x=a,b=0,w=0,k=Math.abs(d);b+w<=k;){if((y+=m)=u)return null;if(x=_,void 0===(_=h[y])){var T=new t.default$1(c.getx(y),c.gety(y)),A=pe(T,f);if(A.signedDistanceFromCamera>0)_=h[y]=A.point;else{var M=y-m;_=_e(0===b?o:new t.default$1(c.getx(M),c.gety(M)),T,x,k-b+1,f)}}b+=w,w=x.dist(_)}var S=(k-b)/w,C=_.sub(x),z=C.mult(S)._add(x);return z._add(C._unit()._perp()._mult(r*m)),{point:z,angle:g+Math.atan2(_.y-x.y,_.x-x.x),tileDistance:p?{prevTileDistance:y-m===v?0:c.gettileUnitDistanceFromAnchor(y-m),lastSegmentViewportDistance:k-b}:null}}var be=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function we(t,e){for(var n=0;nM)Ae(e,S,!1);else{var I=this.projectPoint(c,C,z),P=E*k;if(d.length>0){var D=I.x-d[d.length-4],O=I.y-d[d.length-3];if(P*P*2>D*D+O*O&&S+8-A&&R=this.screenRightBoundary||r<100||e>this.screenBottomBoundary};var Se=t.default$19.layout,Ce=function(t,e,n,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&n?1:0,this.placed=n};Ce.prototype.isHidden=function(){return 0===this.opacity&&!this.placed};var ze=function(t,e,n,r,i){this.text=new Ce(t?t.text:null,e,n,i),this.icon=new Ce(t?t.icon:null,e,r,i)};ze.prototype.isHidden=function(){return this.text.isHidden()&&this.icon.isHidden()};var Ee=function(t,e,n){this.text=t,this.icon=e,this.skipFade=n},Le=function(t,e){this.transform=t.clone(),this.collisionIndex=new Te(this.transform),this.placements={},this.opacities={},this.stale=!1,this.fadeDuration=e,this.retainedQueryData={}};function Ie(t,e,n){t.emplaceBack(e?1:0,n?1:0),t.emplaceBack(e?1:0,n?1:0),t.emplaceBack(e?1:0,n?1:0),t.emplaceBack(e?1:0,n?1:0)}Le.prototype.placeLayerTile=function(e,n,r,i){var a=n.getBucket(e),o=n.latestFeatureIndex;if(a&&o&&e.id===a.layerIds[0]){var s=n.collisionBoxArray,l=a.layers[0].layout,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),c=n.tileSize/t.default$8,f=this.transform.calculatePosMatrix(n.tileID.toUnwrapped()),h=fe(f,"map"===l.get("text-pitch-alignment"),"map"===l.get("text-rotation-alignment"),this.transform,Me(n,1,this.transform.zoom)),p=fe(f,"map"===l.get("icon-pitch-alignment"),"map"===l.get("icon-rotation-alignment"),this.transform,Me(n,1,this.transform.zoom));this.retainedQueryData[a.bucketInstanceId]=new function(t,e,n,r,i){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=n,this.bucketIndex=r,this.tileID=i}(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,n.tileID),this.placeLayerBucket(a,f,h,p,u,c,r,i,s)}},Le.prototype.placeLayerBucket=function(e,n,r,i,a,o,s,l,u){for(var c=e.layers[0].layout,f=t.evaluateSizeForZoom(e.textSizeData,this.transform.zoom,Se.properties["text-size"]),h=!e.hasTextData()||c.get("text-optional"),p=!e.hasIconData()||c.get("icon-optional"),d=0,m=e.symbolInstances;d0,_=_&&x.offscreen);var A=g.collisionArrays.textCircles;if(A){var M=e.text.placedSymbolArray.get(g.placedTextSymbolIndices[0]),S=t.evaluateSizeForFeature(e.textSizeData,f,M);b=this.collisionIndex.placeCollisionCircles(A,c.get("text-allow-overlap"),a,o,g.key,M,e.lineVertexArray,e.glyphOffsetArray,S,n,r,s,"map"===c.get("text-pitch-alignment")),y=c.get("text-allow-overlap")||b.circles.length>0,_=_&&b.offscreen}g.collisionArrays.iconFeatureIndex&&(T=g.collisionArrays.iconFeatureIndex),g.collisionArrays.iconBox&&(v=(w=this.collisionIndex.placeCollisionBox(g.collisionArrays.iconBox,c.get("icon-allow-overlap"),o,n)).box.length>0,_=_&&w.offscreen),h||p?p?h||(v=v&&y):y=v&&y:v=y=v&&y,y&&x&&this.collisionIndex.insertCollisionBox(x.box,c.get("text-ignore-placement"),e.bucketInstanceId,k),v&&w&&this.collisionIndex.insertCollisionBox(w.box,c.get("icon-ignore-placement"),e.bucketInstanceId,T),y&&b&&this.collisionIndex.insertCollisionCircles(b.circles,c.get("text-ignore-placement"),e.bucketInstanceId,k),this.placements[g.crossTileID]=new Ee(y,v,_||e.justReloaded),l[g.crossTileID]=!0}}e.justReloaded=!1},Le.prototype.commit=function(t,e){this.commitTime=e;var n=!1,r=t&&0!==this.fadeDuration?(this.commitTime-t.commitTime)/this.fadeDuration:1,i=t?t.opacities:{};for(var a in this.placements){var o=this.placements[a],s=i[a];s?(this.opacities[a]=new ze(s,r,o.text,o.icon),n=n||o.text!==s.text.placed||o.icon!==s.icon.placed):(this.opacities[a]=new ze(null,r,o.text,o.icon,o.skipFade),n=n||o.text||o.icon)}for(var l in i){var u=i[l];if(!this.opacities[l]){var c=new ze(u,r,!1,!1);c.isHidden()||(this.opacities[l]=c,n=n||u.text.placed||u.icon.placed)}}n?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)},Le.prototype.updateLayerOpacities=function(t,e){for(var n={},r=0,i=e;r0||s.numVerticalGlyphVertices>0,f=s.numIconVertices>0;if(c){for(var h=je(u.text),p=(s.numGlyphVertices+s.numVerticalGlyphVertices)/4,d=0;dt},Le.prototype.setStale=function(){this.stale=!0};var Pe=Math.pow(2,25),De=Math.pow(2,24),Oe=Math.pow(2,17),Re=Math.pow(2,16),Fe=Math.pow(2,9),Be=Math.pow(2,8),Ne=Math.pow(2,1);function je(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;var e=t.placed?1:0,n=Math.floor(127*t.opacity);return n*Pe+e*De+n*Oe+e*Re+n*Fe+e*Be+n*Ne+e}var Ve=function(){this._currentTileIndex=0,this._seenCrossTileIDs={}};Ve.prototype.continuePlacement=function(t,e,n,r,i){for(;this._currentTileIndex2};this._currentPlacementIndex>=0;){var s=e[t[r._currentPlacementIndex]],l=r.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){if(r._inProgressLayer||(r._inProgressLayer=new Ve),r._inProgressLayer.continuePlacement(n[s.source],r.placement,r._showCollisionBoxes,s,o))return;delete r._inProgressLayer}r._currentPlacementIndex--}this._done=!0},qe.prototype.commit=function(t,e){return this.placement.commit(t,e),this.placement};var Ue=512/t.default$8/2,He=function(t,e,n){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(var r=0,i=e;rt.overscaledZ)for(var l in s){var u=s[l];u.tileID.isChildOf(t)&&u.findMatches(e.symbolInstances,t,a)}else{var c=s[t.scaledTo(Number(o)).key];c&&c.findMatches(e.symbolInstances,t,a)}}for(var f=0,h=e.symbolInstances;f1?"@2x":"";function u(){if(s)r(s);else if(i&&o){var e=a.getImageData(o),n={};for(var l in i){var u=i[l],c=u.width,f=u.height,h=u.x,p=u.y,d=u.sdf,m=u.pixelRatio,g=new t.RGBAImage({width:c,height:f});t.RGBAImage.copy(e,g,{x:h,y:p},{x:0,y:0},{width:c,height:f}),n[l]={data:g,pixelRatio:m,sdf:d}}r(null,n)}}t.getJSON(n(b(e,l,".json"),t.ResourceType.SpriteJSON),function(t,e){s||(s=t,i=e,u())}),t.getImage(n(b(e,l,".png"),t.ResourceType.SpriteImage),function(t,e){s||(s=t,o=e,u())})}(e.sprite,this.map._transformRequest,function(e,n){if(e)r.fire(new t.ErrorEvent(e));else if(n)for(var i in n)r.imageManager.addImage(i,n[i]);r.imageManager.setLoaded(!0),r.fire(new t.Event("data",{dataType:"style"}))}):this.imageManager.setLoaded(!0),this.glyphManager.setURL(e.glyphs);var o=te(this.stylesheet.layers);this._order=o.map(function(t){return t.id}),this._layers={};for(var s=0,l=o;s0)throw new Error("Unimplemented: "+i.map(function(t){return t.command}).join(", ")+".");return r.forEach(function(t){"setTransition"!==t.command&&n[t.command].apply(n,t.args)}),this.stylesheet=e,!0},n.prototype.addImage=function(e,n){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(e,n),this.fire(new t.Event("data",{dataType:"style"}))},n.prototype.getImage=function(t){return this.imageManager.getImage(t)},n.prototype.removeImage=function(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(e),this.fire(new t.Event("data",{dataType:"style"}))},n.prototype.addSource=function(e,n,r){var i=this;if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error("There is already a source with this ID");if(!n.type)throw new Error("The type property must be defined, but the only the following properties were given: "+Object.keys(n).join(", ")+".");if(!(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(t.validateStyle.source,"sources."+e,n,null,r))){this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);var a=this.sourceCaches[e]=new $t(e,n,this.dispatcher);a.style=this,a.setEventedParent(this,function(){return{isSourceLoaded:i.loaded(),source:a.serialize(),sourceId:e}}),a.onAdd(this.map),this._changed=!0}},n.prototype.removeSource=function(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(var n in this._layers)if(this._layers[n].source===e)return this.fire(new t.ErrorEvent(new Error('Source "'+e+'" cannot be removed while layer "'+n+'" is using it.')));var r=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],r.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),r.setEventedParent(null),r.clearTiles(),r.onRemove&&r.onRemove(this.map),this._changed=!0},n.prototype.setGeoJSONSourceData=function(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0},n.prototype.getSource=function(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()},n.prototype.addLayer=function(e,n,r){this._checkLoaded();var i=e.id;if(this.getLayer(i))this.fire(new t.ErrorEvent(new Error('Layer with id "'+i+'" already exists on this map')));else if("object"==typeof e.source&&(this.addSource(i,e.source),e=t.clone(e),e=t.extend(e,{source:i})),!this._validate(t.validateStyle.layer,"layers."+i,e,{arrayIndex:-1},r)){var a=t.default$22(e);this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}});var o=n?this._order.indexOf(n):this._order.length;if(n&&-1===o)this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.')));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source){var s=this._removedLayers[i];delete this._removedLayers[i],s.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause())}this._updateLayer(a)}}},n.prototype.moveLayer=function(e,n){if(this._checkLoaded(),this._changed=!0,this._layers[e]){if(e!==n){var r=this._order.indexOf(e);this._order.splice(r,1);var i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.'))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be moved.")))},n.prototype.removeLayer=function(e){this._checkLoaded();var n=this._layers[e];if(n){n.setEventedParent(null);var r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e]}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be removed.")))},n.prototype.getLayer=function(t){return this._layers[t]},n.prototype.setLayerZoomRange=function(e,n,r){this._checkLoaded();var i=this.getLayer(e);i?i.minzoom===n&&i.maxzoom===r||(null!=n&&(i.minzoom=n),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot have zoom extent.")))},n.prototype.setFilter=function(e,n){this._checkLoaded();var r=this.getLayer(e);if(r){if(!t.default$10(r.filter,n))return null==n?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(t.validateStyle.filter,"layers."+r.id+".filter",n)||(r.filter=t.clone(n),this._updateLayer(r)))}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be filtered.")))},n.prototype.getFilter=function(e){return t.clone(this.getLayer(e).filter)},n.prototype.setLayoutProperty=function(e,n,r){this._checkLoaded();var i=this.getLayer(e);i?t.default$10(i.getLayoutProperty(n),r)||(i.setLayoutProperty(n,r),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getLayoutProperty=function(t,e){return this.getLayer(t).getLayoutProperty(e)},n.prototype.setPaintProperty=function(e,n,r){this._checkLoaded();var i=this.getLayer(e);if(i){if(!t.default$10(i.getPaintProperty(n),r)){var a=i._transitionablePaint._values[n].value.isDataDriven();i.setPaintProperty(n,r),(i._transitionablePaint._values[n].value.isDataDriven()||a)&&this._updateLayer(i),this._changed=!0,this._updatedPaintProps[e]=!0}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getPaintProperty=function(t,e){return this.getLayer(t).getPaintProperty(e)},n.prototype.getTransition=function(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)},n.prototype.serialize=function(){var e=this;return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:t.mapObject(this.sourceCaches,function(t){return t.serialize()}),layers:this._order.map(function(t){return e._layers[t].serialize()})},function(t){return void 0!==t})},n.prototype._updateLayer=function(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0},n.prototype._flattenRenderedFeatures=function(t){for(var e=[],n=this._order.length-1;n>=0;n--)for(var r=this._order[n],i=0,a=t;i 0.5) {\n gl_FragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha;\n }\n\n if (v_notUsed > 0.5) {\n // This box not used, fade it out\n gl_FragColor *= .1;\n }\n}",vertexSource:"attribute vec2 a_pos;\nattribute vec2 a_anchor_pos;\nattribute vec2 a_extrude;\nattribute vec2 a_placed;\n\nuniform mat4 u_matrix;\nuniform vec2 u_extrude_scale;\nuniform float u_camera_to_center_distance;\n\nvarying float v_placed;\nvarying float v_notUsed;\n\nvoid main() {\n vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n highp float collision_perspective_ratio = clamp(\n 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),\n 0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles\n 4.0);\n\n gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n gl_Position.xy += a_extrude * u_extrude_scale * gl_Position.w * collision_perspective_ratio;\n\n v_placed = a_placed.x;\n v_notUsed = a_placed.y;\n}\n"},collisionCircle:{fragmentSource:"uniform float u_overscale_factor;\n\nvarying float v_placed;\nvarying float v_notUsed;\nvarying float v_radius;\nvarying vec2 v_extrude;\nvarying vec2 v_extrude_scale;\n\nvoid main() {\n float alpha = 0.5;\n\n // Red = collision, hide label\n vec4 color = vec4(1.0, 0.0, 0.0, 1.0) * alpha;\n\n // Blue = no collision, label is showing\n if (v_placed > 0.5) {\n color = vec4(0.0, 0.0, 1.0, 0.5) * alpha;\n }\n\n if (v_notUsed > 0.5) {\n // This box not used, fade it out\n color *= .2;\n }\n\n float extrude_scale_length = length(v_extrude_scale);\n float extrude_length = length(v_extrude) * extrude_scale_length;\n float stroke_width = 15.0 * extrude_scale_length / u_overscale_factor;\n float radius = v_radius * extrude_scale_length;\n\n float distance_to_edge = abs(extrude_length - radius);\n float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge);\n\n gl_FragColor = opacity_t * color;\n}\n",vertexSource:"attribute vec2 a_pos;\nattribute vec2 a_anchor_pos;\nattribute vec2 a_extrude;\nattribute vec2 a_placed;\n\nuniform mat4 u_matrix;\nuniform vec2 u_extrude_scale;\nuniform float u_camera_to_center_distance;\n\nvarying float v_placed;\nvarying float v_notUsed;\nvarying float v_radius;\n\nvarying vec2 v_extrude;\nvarying vec2 v_extrude_scale;\n\nvoid main() {\n vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n highp float collision_perspective_ratio = clamp(\n 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),\n 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles\n 4.0);\n\n gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n\n highp float padding_factor = 1.2; // Pad the vertices slightly to make room for anti-alias blur\n gl_Position.xy += a_extrude * u_extrude_scale * padding_factor * gl_Position.w * collision_perspective_ratio;\n\n v_placed = a_placed.x;\n v_notUsed = a_placed.y;\n v_radius = abs(a_extrude.y); // We don't pitch the circles, so both units of the extrusion vector are equal in magnitude to the radius\n\n v_extrude = a_extrude * padding_factor;\n v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio;\n}\n"},debug:{fragmentSource:"uniform highp vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n}\n"},fill:{fragmentSource:"#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float opacity\n\n gl_FragColor = color * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n}\n"},fillOutline:{fragmentSource:"#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_pos;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = 1.0 - smoothstep(0.0, 1.0, dist);\n gl_FragColor = outline_color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\nuniform vec2 u_world;\n\nvarying vec2 v_pos;\n\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},fillOutlinePattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n // find distance to outline for alpha interpolation\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = 1.0 - smoothstep(0.0, 1.0, dist);\n\n\n gl_FragColor = mix(color1, color2, u_mix) * alpha * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_world;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);\n\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},fillPattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n gl_FragColor = mix(color1, color2, u_mix) * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);\n}\n"},fillExtrusion:{fragmentSource:"varying vec4 v_color;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define highp vec4 color\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n #pragma mapbox: initialize highp vec4 color\n\n gl_FragColor = v_color;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec3 u_lightcolor;\nuniform lowp vec3 u_lightpos;\nuniform lowp float u_lightintensity;\n\nattribute vec2 a_pos;\nattribute vec4 a_normal_ed;\n\nvarying vec4 v_color;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\n#pragma mapbox: define highp vec4 color\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n #pragma mapbox: initialize highp vec4 color\n\n vec3 normal = a_normal_ed.xyz;\n\n base = max(0.0, base);\n height = max(0.0, height);\n\n float t = mod(normal.x, 2.0);\n\n gl_Position = u_matrix * vec4(a_pos, t > 0.0 ? height : base, 1);\n\n // Relative luminance (how dark/bright is the surface color?)\n float colorvalue = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722;\n\n v_color = vec4(0.0, 0.0, 0.0, 1.0);\n\n // Add slight ambient lighting so no extrusions are totally black\n vec4 ambientlight = vec4(0.03, 0.03, 0.03, 1.0);\n color += ambientlight;\n\n // Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray\n float directional = clamp(dot(normal / 16384.0, u_lightpos), 0.0, 1.0);\n\n // Adjust directional so that\n // the range of values for highlight/shading is narrower\n // with lower light intensity\n // and with lighter/brighter surface colors\n directional = mix((1.0 - u_lightintensity), max((1.0 - colorvalue + u_lightintensity), 1.0), directional);\n\n // Add gradient along z axis of side surfaces\n if (normal.y != 0.0) {\n directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0);\n }\n\n // Assign final color based on surface + ambient light color, diffuse light directional, and light color\n // with lower bounds adjusted to hue of light\n // so that shading is tinted with the complementary (opposite) color to the light color\n v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0);\n v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0);\n v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0);\n}\n"},fillExtrusionPattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec4 v_lighting;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n vec4 mixedColor = mix(color1, color2, u_mix);\n\n gl_FragColor = mixedColor * v_lighting;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\nuniform float u_height_factor;\n\nuniform vec3 u_lightcolor;\nuniform lowp vec3 u_lightpos;\nuniform lowp float u_lightintensity;\n\nattribute vec2 a_pos;\nattribute vec4 a_normal_ed;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec4 v_lighting;\nvarying float v_directional;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n\n vec3 normal = a_normal_ed.xyz;\n float edgedistance = a_normal_ed.w;\n\n base = max(0.0, base);\n height = max(0.0, height);\n\n float t = mod(normal.x, 2.0);\n float z = t > 0.0 ? height : base;\n\n gl_Position = u_matrix * vec4(a_pos, z, 1);\n\n vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0\n ? a_pos // extrusion top\n : vec2(edgedistance, z * u_height_factor); // extrusion side\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, pos);\n\n v_lighting = vec4(0.0, 0.0, 0.0, 1.0);\n float directional = clamp(dot(normal / 16383.0, u_lightpos), 0.0, 1.0);\n directional = mix((1.0 - u_lightintensity), max((0.5 + u_lightintensity), 1.0), directional);\n\n if (normal.y != 0.0) {\n directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0);\n }\n\n v_lighting.rgb += clamp(directional * u_lightcolor, mix(vec3(0.0), vec3(0.3), 1.0 - u_lightcolor), vec3(1.0));\n}\n"},extrusionTexture:{fragmentSource:"uniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\n\nvoid main() {\n gl_FragColor = texture2D(u_image, v_pos) * u_opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(0.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_world;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1);\n\n v_pos.x = a_pos.x;\n v_pos.y = 1.0 - a_pos.y;\n}\n"},hillshadePrepare:{fragmentSource:"#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D u_image;\nvarying vec2 v_pos;\nuniform vec2 u_dimension;\nuniform float u_zoom;\nuniform float u_maxzoom;\n\nfloat getElevation(vec2 coord, float bias) {\n // Convert encoded elevation value to meters\n vec4 data = texture2D(u_image, coord) * 255.0;\n return (data.r + data.g * 256.0 + data.b * 256.0 * 256.0) / 4.0;\n}\n\nvoid main() {\n vec2 epsilon = 1.0 / u_dimension;\n\n // queried pixels:\n // +-----------+\n // | | | |\n // | a | b | c |\n // | | | |\n // +-----------+\n // | | | |\n // | d | e | f |\n // | | | |\n // +-----------+\n // | | | |\n // | g | h | i |\n // | | | |\n // +-----------+\n\n float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0);\n float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0);\n float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0);\n float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0);\n float e = getElevation(v_pos, 0.0);\n float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0);\n float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0);\n float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0);\n float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0);\n\n // here we divide the x and y slopes by 8 * pixel size\n // where pixel size (aka meters/pixel) is:\n // circumference of the world / (pixels per tile * number of tiles)\n // which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom))\n // which can be reduced to: pow(2, 19.25619978527 - u_zoom)\n // we want to vertically exaggerate the hillshading though, because otherwise\n // it is barely noticeable at low zooms. to do this, we multiply this by some\n // scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value\n // Here we use a=0.3 which works out to the expression below. see \n // nickidlugash's awesome breakdown for more info\n // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556\n float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;\n\n vec2 deriv = vec2(\n (c + f + f + i) - (a + d + d + g),\n (g + h + h + i) - (a + b + b + c)\n ) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom);\n\n gl_FragColor = clamp(vec4(\n deriv.x / 2.0 + 0.5,\n deriv.y / 2.0 + 0.5,\n 1.0,\n 1.0), 0.0, 1.0);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = (a_texture_pos / 8192.0) / 2.0 + 0.25;\n}\n"},hillshade:{fragmentSource:"uniform sampler2D u_image;\nvarying vec2 v_pos;\n\nuniform vec2 u_latrange;\nuniform vec2 u_light;\nuniform vec4 u_shadow;\nuniform vec4 u_highlight;\nuniform vec4 u_accent;\n\n#define PI 3.141592653589793\n\nvoid main() {\n vec4 pixel = texture2D(u_image, v_pos);\n\n vec2 deriv = ((pixel.rg * 2.0) - 1.0);\n\n // We divide the slope by a scale factor based on the cosin of the pixel's approximate latitude\n // to account for mercator projection distortion. see #4807 for details\n float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_pos.y) + u_latrange[1]));\n // We also multiply the slope by an arbitrary z-factor of 1.25\n float slope = atan(1.25 * length(deriv) / scaleFactor);\n float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0);\n\n float intensity = u_light.x;\n // We add PI to make this property match the global light object, which adds PI/2 to the light's azimuthal\n // position property to account for 0deg corresponding to north/the top of the viewport in the style spec\n // and the original shader was written to accept (-illuminationDirection - 90) as the azimuthal.\n float azimuth = u_light.y + PI;\n\n // We scale the slope exponentially based on intensity, using a calculation similar to\n // the exponential interpolation function in the style spec:\n // https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/expression/definitions/interpolate.js#L217-L228\n // so that higher intensity values create more opaque hillshading.\n float base = 1.875 - intensity * 1.75;\n float maxValue = 0.5 * PI;\n float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope;\n\n // The accent color is calculated with the cosine of the slope while the shade color is calculated with the sine\n // so that the accent color's rate of change eases in while the shade color's eases out.\n float accent = cos(scaledSlope);\n // We multiply both the accent and shade color by a clamped intensity value\n // so that intensities >= 0.5 do not additionally affect the color values\n // while intensity values < 0.5 make the overall color more transparent.\n vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0);\n float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0);\n vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0);\n gl_FragColor = accent_color * (1.0 - shade_color.a) + shade_color;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = a_texture_pos / 8192.0;\n}\n"},line:{fragmentSource:"#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_width2;\nvarying vec2 v_normal;\nvarying float v_gamma_scale;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_gamma_scale;\nvarying highp float v_linesofar;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n\n v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_width2 = vec2(outset, inset);\n}\n"},lineGradient:{fragmentSource:"\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nuniform sampler2D u_image;\n\nvarying vec2 v_width2;\nvarying vec2 v_normal;\nvarying float v_gamma_scale;\nvarying highp float v_lineprogress;\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n // For gradient lines, v_lineprogress is the ratio along the entire line,\n // scaled to [0, 2^15), and the gradient ramp is stored in a texture.\n vec4 color = texture2D(u_image, vec2(v_lineprogress, 0.5));\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"\n// the attribute conveying progress along a line is scaled to [0, 2^15)\n#define MAX_LINE_DISTANCE 32767.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_gamma_scale;\nvarying highp float v_lineprogress;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n\n v_lineprogress = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_width2 = vec2(outset, inset);\n}\n"},linePattern:{fragmentSource:"uniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_fade;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n float x_a = mod(v_linesofar / u_pattern_size_a.x, 1.0);\n float x_b = mod(v_linesofar / u_pattern_size_b.x, 1.0);\n\n // v_normal.y is 0 at the midpoint of the line, -1 at the lower edge, 1 at the upper edge\n // we clamp the line width outset to be between 0 and half the pattern height plus padding (2.0)\n // to ensure we don't sample outside the designated symbol on the sprite sheet.\n // 0.5 is added to shift the component to be bounded between 0 and 1 for interpolation of\n // the texture coordinate\n float y_a = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (u_pattern_size_a.y + 2.0) / 2.0) / u_pattern_size_a.y);\n float y_b = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (u_pattern_size_b.y + 2.0) / 2.0) / u_pattern_size_b.y);\n vec2 pos_a = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, vec2(x_a, y_a));\n vec2 pos_b = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, vec2(x_b, y_b));\n\n vec4 color = mix(texture2D(u_image, pos_a), texture2D(u_image, pos_b), u_fade);\n\n gl_FragColor = color * alpha * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_linesofar = a_linesofar;\n v_width2 = vec2(outset, inset);\n}\n"},lineSDF:{fragmentSource:"\nuniform sampler2D u_image;\nuniform float u_sdfgamma;\nuniform float u_mix;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float width\n #pragma mapbox: initialize lowp float floorwidth\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n float sdfdist_a = texture2D(u_image, v_tex_a).a;\n float sdfdist_b = texture2D(u_image, v_tex_b).a;\n float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix);\n alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist);\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_patternscale_a;\nuniform float u_tex_y_a;\nuniform vec2 u_patternscale_b;\nuniform float u_tex_y_b;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n #pragma mapbox: initialize lowp float floorwidth\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist =outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a);\n v_tex_b = vec2(a_linesofar * u_patternscale_b.x / floorwidth, normal.y * u_patternscale_b.y + u_tex_y_b);\n\n v_width2 = vec2(outset, inset);\n}\n"},raster:{fragmentSource:"uniform float u_fade_t;\nuniform float u_opacity;\nuniform sampler2D u_image0;\nuniform sampler2D u_image1;\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nuniform float u_brightness_low;\nuniform float u_brightness_high;\n\nuniform float u_saturation_factor;\nuniform float u_contrast_factor;\nuniform vec3 u_spin_weights;\n\nvoid main() {\n\n // read and cross-fade colors from the main and parent tiles\n vec4 color0 = texture2D(u_image0, v_pos0);\n vec4 color1 = texture2D(u_image1, v_pos1);\n if (color0.a > 0.0) {\n color0.rgb = color0.rgb / color0.a;\n }\n if (color1.a > 0.0) {\n color1.rgb = color1.rgb / color1.a;\n }\n vec4 color = mix(color0, color1, u_fade_t);\n color.a *= u_opacity;\n vec3 rgb = color.rgb;\n\n // spin\n rgb = vec3(\n dot(rgb, u_spin_weights.xyz),\n dot(rgb, u_spin_weights.zxy),\n dot(rgb, u_spin_weights.yzx));\n\n // saturation\n float average = (color.r + color.g + color.b) / 3.0;\n rgb += (average - rgb) * u_saturation_factor;\n\n // contrast\n rgb = (rgb - 0.5) * u_contrast_factor + 0.5;\n\n // brightness\n vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);\n vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);\n\n gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_tl_parent;\nuniform float u_scale_parent;\nuniform float u_buffer_scale;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n // We are using Int16 for texture position coordinates to give us enough precision for\n // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer\n // as an arbitrarily high number to preserve adequate precision when rendering.\n // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates,\n // so math for modifying either is consistent.\n v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5;\n v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;\n}\n"},symbolIcon:{fragmentSource:"uniform sampler2D u_texture;\n\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_tex;\nvarying float v_fade_opacity;\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n lowp float alpha = opacity * v_fade_opacity;\n gl_FragColor = texture2D(u_texture, v_tex) * alpha;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"const float PI = 3.141592653589793;\n\nattribute vec4 a_pos_offset;\nattribute vec4 a_data;\nattribute vec3 a_projected_pos;\nattribute float a_fade_opacity;\n\nuniform bool u_is_size_zoom_constant;\nuniform bool u_is_size_feature_constant;\nuniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function\nuniform highp float u_size; // used when size is both zoom and feature constant\nuniform highp float u_camera_to_center_distance;\nuniform highp float u_pitch;\nuniform bool u_rotate_symbol;\nuniform highp float u_aspect_ratio;\nuniform float u_fade_change;\n\n#pragma mapbox: define lowp float opacity\n\nuniform mat4 u_matrix;\nuniform mat4 u_label_plane_matrix;\nuniform mat4 u_gl_coord_matrix;\n\nuniform bool u_is_text;\nuniform bool u_pitch_with_map;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_tex;\nvarying float v_fade_opacity;\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 a_pos = a_pos_offset.xy;\n vec2 a_offset = a_pos_offset.zw;\n\n vec2 a_tex = a_data.xy;\n vec2 a_size = a_data.zw;\n\n highp float segment_angle = -a_projected_pos[2];\n\n float size;\n if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = mix(a_size[0], a_size[1], u_size_t) / 10.0;\n } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = a_size[0] / 10.0;\n } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {\n size = u_size;\n } else {\n size = u_size;\n }\n\n vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n // See comments in symbol_sdf.vertex\n highp float distance_ratio = u_pitch_with_map ?\n camera_to_anchor_distance / u_camera_to_center_distance :\n u_camera_to_center_distance / camera_to_anchor_distance;\n highp float perspective_ratio = clamp(\n 0.5 + 0.5 * distance_ratio,\n 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles\n 4.0);\n\n size *= perspective_ratio;\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n highp float symbol_rotation = 0.0;\n if (u_rotate_symbol) {\n // See comments in symbol_sdf.vertex\n vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);\n\n vec2 a = projectedPoint.xy / projectedPoint.w;\n vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;\n\n symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);\n }\n\n highp float angle_sin = sin(segment_angle + symbol_rotation);\n highp float angle_cos = cos(segment_angle + symbol_rotation);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);\n gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);\n\n v_tex = a_tex / u_texsize;\n vec2 fade_opacity = unpack_opacity(a_fade_opacity);\n float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;\n v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));\n}\n"},symbolSDF:{fragmentSource:"#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105/DEVICE_PIXEL_RATIO\n\nuniform bool u_is_halo;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n\nuniform sampler2D u_texture;\nuniform highp float u_gamma_scale;\nuniform bool u_is_text;\n\nvarying vec2 v_data0;\nvarying vec3 v_data1;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 fill_color\n #pragma mapbox: initialize highp vec4 halo_color\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float halo_width\n #pragma mapbox: initialize lowp float halo_blur\n\n vec2 tex = v_data0.xy;\n float gamma_scale = v_data1.x;\n float size = v_data1.y;\n float fade_opacity = v_data1[2];\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n lowp vec4 color = fill_color;\n highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);\n lowp float buff = (256.0 - 64.0) / 256.0;\n if (u_is_halo) {\n color = halo_color;\n gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);\n buff = (6.0 - halo_width / fontScale) / SDF_PX;\n }\n\n lowp float dist = texture2D(u_texture, tex).a;\n highp float gamma_scaled = gamma * gamma_scale;\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = color * (alpha * opacity * fade_opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"const float PI = 3.141592653589793;\n\nattribute vec4 a_pos_offset;\nattribute vec4 a_data;\nattribute vec3 a_projected_pos;\nattribute float a_fade_opacity;\n\n// contents of a_size vary based on the type of property value\n// used for {text,icon}-size.\n// For constants, a_size is disabled.\n// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.\n// For composite functions:\n// [ text-size(lowerZoomStop, feature),\n// text-size(upperZoomStop, feature) ]\nuniform bool u_is_size_zoom_constant;\nuniform bool u_is_size_feature_constant;\nuniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function\nuniform highp float u_size; // used when size is both zoom and feature constant\n\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n\nuniform mat4 u_matrix;\nuniform mat4 u_label_plane_matrix;\nuniform mat4 u_gl_coord_matrix;\n\nuniform bool u_is_text;\nuniform bool u_pitch_with_map;\nuniform highp float u_pitch;\nuniform bool u_rotate_symbol;\nuniform highp float u_aspect_ratio;\nuniform highp float u_camera_to_center_distance;\nuniform float u_fade_change;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_data0;\nvarying vec3 v_data1;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 fill_color\n #pragma mapbox: initialize highp vec4 halo_color\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float halo_width\n #pragma mapbox: initialize lowp float halo_blur\n\n vec2 a_pos = a_pos_offset.xy;\n vec2 a_offset = a_pos_offset.zw;\n\n vec2 a_tex = a_data.xy;\n vec2 a_size = a_data.zw;\n\n highp float segment_angle = -a_projected_pos[2];\n float size;\n\n if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = mix(a_size[0], a_size[1], u_size_t) / 10.0;\n } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = a_size[0] / 10.0;\n } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {\n size = u_size;\n } else {\n size = u_size;\n }\n\n vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n // If the label is pitched with the map, layout is done in pitched space,\n // which makes labels in the distance smaller relative to viewport space.\n // We counteract part of that effect by multiplying by the perspective ratio.\n // If the label isn't pitched with the map, we do layout in viewport space,\n // which makes labels in the distance larger relative to the features around\n // them. We counteract part of that effect by dividing by the perspective ratio.\n highp float distance_ratio = u_pitch_with_map ?\n camera_to_anchor_distance / u_camera_to_center_distance :\n u_camera_to_center_distance / camera_to_anchor_distance;\n highp float perspective_ratio = clamp(\n 0.5 + 0.5 * distance_ratio,\n 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles\n 4.0);\n\n size *= perspective_ratio;\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n highp float symbol_rotation = 0.0;\n if (u_rotate_symbol) {\n // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units\n // To figure out that angle in projected space, we draw a short horizontal line in tile\n // space, project it, and measure its angle in projected space.\n vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);\n\n vec2 a = projectedPoint.xy / projectedPoint.w;\n vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;\n\n symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);\n }\n\n highp float angle_sin = sin(segment_angle + symbol_rotation);\n highp float angle_cos = cos(segment_angle + symbol_rotation);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);\n gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);\n float gamma_scale = gl_Position.w;\n\n vec2 tex = a_tex / u_texsize;\n vec2 fade_opacity = unpack_opacity(a_fade_opacity);\n float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;\n float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));\n\n v_data0 = vec2(tex.x, tex.y);\n v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity);\n}\n"}},tn=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,en=function(t){var e=Qe[t],n={};e.fragmentSource=e.fragmentSource.replace(tn,function(t,e,r,i,a){return n[a]=!0,"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nvarying "+r+" "+i+" "+a+";\n#else\nuniform "+r+" "+i+" u_"+a+";\n#endif\n":"\n#ifdef HAS_UNIFORM_u_"+a+"\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n"}),e.vertexSource=e.vertexSource.replace(tn,function(t,e,r,i,a){var o="float"===i?"vec2":"vec4";return n[a]?"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float a_"+a+"_t;\nattribute "+r+" "+o+" a_"+a+";\nvarying "+r+" "+i+" "+a+";\n#else\nuniform "+r+" "+i+" u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+a+" = unpack_mix_"+o+"(a_"+a+", a_"+a+"_t);\n#else\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n":"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float a_"+a+"_t;\nattribute "+r+" "+o+" a_"+a+";\n#else\nuniform "+r+" "+i+" u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+r+" "+i+" "+a+" = unpack_mix_"+o+"(a_"+a+", a_"+a+"_t);\n#else\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n"})};for(var nn in Qe)en(nn);var rn=Qe,an=function(t,e,n,r){var i=t.gl;this.program=i.createProgram();var o=n.defines().concat("#define DEVICE_PIXEL_RATIO "+a.devicePixelRatio.toFixed(1));r&&o.push("#define OVERDRAW_INSPECTOR;");var s=o.concat(rn.prelude.fragmentSource,e.fragmentSource).join("\n"),l=o.concat(rn.prelude.vertexSource,e.vertexSource).join("\n"),u=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(u,s),i.compileShader(u),i.attachShader(this.program,u);var c=i.createShader(i.VERTEX_SHADER);i.shaderSource(c,l),i.compileShader(c),i.attachShader(this.program,c);for(var f=n.layoutAttributes||[],h=0;h>16,s>>16),r.uniform2f(n.uniforms.u_pixel_coord_lower,65535&o,65535&s)};function vn(t,e,n,r,i){if(!mn(n.paint.get("fill-pattern"),t))for(var a=!0,o=0,s=r;o0){var l=a.now(),u=(l-e.timeAdded)/s,c=n?(l-n.timeAdded)/s:-1,f=r.getSource(),h=o.coveringZoomLevel({tileSize:f.tileSize,roundZoom:f.roundZoom}),p=!n||Math.abs(n.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),d=p&&e.refreshedUponExpiration?1:t.clamp(p?u:1-c,0,1);return e.refreshedUponExpiration&&u>=1&&(e.refreshedUponExpiration=!1),n?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}function zn(e,n,r){var i=e.context,o=i.gl;i.lineWidth.set(1*a.devicePixelRatio);var s=r.posMatrix,l=e.useProgram("debug");i.setDepthMode(Ut.disabled),i.setStencilMode(Ht.disabled),i.setColorMode(e.colorModeForRenderPass()),o.uniformMatrix4fv(l.uniforms.u_matrix,!1,s),o.uniform4f(l.uniforms.u_color,1,0,0,1),e.debugVAO.bind(i,l,e.debugBuffer,[]),o.drawArrays(o.LINE_STRIP,0,e.debugBuffer.length);for(var u=function(t,e,n,r){r=r||1;var i,a,o,s,l,u,c,f,h=[];for(i=0,a=t.length;i":[24,[4,18,20,9,4,0]],"?":[18,[3,16,3,17,4,19,5,20,7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,12,9,10,9,7,-1,-1,9,2,8,1,9,0,10,1,9,2]],"@":[27,[18,13,17,15,15,16,12,16,10,15,9,14,8,11,8,8,9,6,11,5,14,5,16,6,17,8,-1,-1,12,16,10,14,9,11,9,8,10,6,11,5,-1,-1,18,16,17,8,17,6,19,5,21,5,23,7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,21,9,20,7,19,5,17,4,15,3,12,3,9,4,6,5,4,7,2,9,1,12,0,15,0,18,1,20,2,21,3,-1,-1,19,16,18,8,18,6,19,5]],A:[18,[9,21,1,0,-1,-1,9,21,17,0,-1,-1,4,7,14,7]],B:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,-1,-1,4,11,13,11,16,10,17,9,18,7,18,4,17,2,16,1,13,0,4,0]],C:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5]],D:[21,[4,21,4,0,-1,-1,4,21,11,21,14,20,16,18,17,16,18,13,18,8,17,5,16,3,14,1,11,0,4,0]],E:[19,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11,-1,-1,4,0,17,0]],F:[18,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11]],G:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,18,8,-1,-1,13,8,18,8]],H:[22,[4,21,4,0,-1,-1,18,21,18,0,-1,-1,4,11,18,11]],I:[8,[4,21,4,0]],J:[16,[12,21,12,5,11,2,10,1,8,0,6,0,4,1,3,2,2,5,2,7]],K:[21,[4,21,4,0,-1,-1,18,21,4,7,-1,-1,9,12,18,0]],L:[17,[4,21,4,0,-1,-1,4,0,16,0]],M:[24,[4,21,4,0,-1,-1,4,21,12,0,-1,-1,20,21,12,0,-1,-1,20,21,20,0]],N:[22,[4,21,4,0,-1,-1,4,21,18,0,-1,-1,18,21,18,0]],O:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21]],P:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,10,4,10]],Q:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21,-1,-1,12,4,18,-2]],R:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,4,11,-1,-1,11,11,18,0]],S:[20,[17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3]],T:[16,[8,21,8,0,-1,-1,1,21,15,21]],U:[22,[4,21,4,6,5,3,7,1,10,0,12,0,15,1,17,3,18,6,18,21]],V:[18,[1,21,9,0,-1,-1,17,21,9,0]],W:[24,[2,21,7,0,-1,-1,12,21,7,0,-1,-1,12,21,17,0,-1,-1,22,21,17,0]],X:[20,[3,21,17,0,-1,-1,17,21,3,0]],Y:[18,[1,21,9,11,9,0,-1,-1,17,21,9,11]],Z:[20,[17,21,3,0,-1,-1,3,21,17,21,-1,-1,3,0,17,0]],"[":[14,[4,25,4,-7,-1,-1,5,25,5,-7,-1,-1,4,25,11,25,-1,-1,4,-7,11,-7]],"\\":[14,[0,21,14,-3]],"]":[14,[9,25,9,-7,-1,-1,10,25,10,-7,-1,-1,3,25,10,25,-1,-1,3,-7,10,-7]],"^":[16,[6,15,8,18,10,15,-1,-1,3,12,8,17,13,12,-1,-1,8,17,8,0]],_:[16,[0,-2,16,-2]],"`":[10,[6,21,5,20,4,18,4,16,5,15,6,16,5,17]],a:[19,[15,14,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],b:[19,[4,21,4,0,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],c:[18,[15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],d:[19,[15,21,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],e:[18,[3,8,15,8,15,10,14,12,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],f:[12,[10,21,8,21,6,20,5,17,5,0,-1,-1,2,14,9,14]],g:[19,[15,14,15,-2,14,-5,13,-6,11,-7,8,-7,6,-6,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],h:[19,[4,21,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],i:[8,[3,21,4,20,5,21,4,22,3,21,-1,-1,4,14,4,0]],j:[10,[5,21,6,20,7,21,6,22,5,21,-1,-1,6,14,6,-3,5,-6,3,-7,1,-7]],k:[17,[4,21,4,0,-1,-1,14,14,4,4,-1,-1,8,8,15,0]],l:[8,[4,21,4,0]],m:[30,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0,-1,-1,15,10,18,13,20,14,23,14,25,13,26,10,26,0]],n:[19,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],o:[19,[8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3,16,6,16,8,15,11,13,13,11,14,8,14]],p:[19,[4,14,4,-7,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],q:[19,[15,14,15,-7,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],r:[13,[4,14,4,0,-1,-1,4,8,5,11,7,13,9,14,12,14]],s:[17,[14,11,13,13,10,14,7,14,4,13,3,11,4,9,6,8,11,7,13,6,14,4,14,3,13,1,10,0,7,0,4,1,3,3]],t:[12,[5,21,5,4,6,1,8,0,10,0,-1,-1,2,14,9,14]],u:[19,[4,14,4,4,5,1,7,0,10,0,12,1,15,4,-1,-1,15,14,15,0]],v:[16,[2,14,8,0,-1,-1,14,14,8,0]],w:[22,[3,14,7,0,-1,-1,11,14,7,0,-1,-1,11,14,15,0,-1,-1,19,14,15,0]],x:[17,[3,14,14,0,-1,-1,14,14,3,0]],y:[16,[2,14,8,0,-1,-1,14,14,8,0,6,-4,4,-6,2,-7,1,-7]],z:[17,[14,14,3,0,-1,-1,3,14,14,14,-1,-1,3,0,14,0]],"{":[14,[9,25,7,24,6,23,5,21,5,19,6,17,7,16,8,14,8,12,6,10,-1,-1,7,24,6,22,6,20,7,18,8,17,9,15,9,13,8,11,4,9,8,7,9,5,9,3,8,1,7,0,6,-2,6,-4,7,-6,-1,-1,6,8,8,6,8,4,7,2,6,1,5,-1,5,-3,6,-5,7,-6,9,-7]],"|":[8,[4,25,4,-7]],"}":[14,[5,25,7,24,8,23,9,21,9,19,8,17,7,16,6,14,6,12,8,10,-1,-1,7,24,8,22,8,20,7,18,6,17,5,15,5,13,6,11,10,9,6,7,5,5,5,3,6,1,7,0,8,-2,8,-4,7,-6,-1,-1,8,8,6,6,6,4,7,2,8,1,9,-1,9,-3,8,-5,7,-6,5,-7]],"~":[24,[3,6,3,8,4,11,6,12,8,12,10,11,14,8,16,7,18,7,20,8,21,10,-1,-1,3,8,4,10,6,11,8,11,10,10,14,7,16,6,18,6,20,7,21,10,21,12]]},Ln={symbol:function(t,e,n,r){if("translucent"===t.renderPass){var i=t.context;i.setStencilMode(Ht.disabled),i.setColorMode(t.colorModeForRenderPass()),0!==n.paint.get("icon-opacity").constantOr(1)&&cn(t,e,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright")),0!==n.paint.get("text-opacity").constantOr(1)&&cn(t,e,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright")),e.map.showCollisionBoxes&&function(t,e,n,r){sn(t,e,n,r,!1),sn(t,e,n,r,!0)}(t,e,n,r)}},circle:function(t,e,n,r){if("translucent"===t.renderPass){var i=n.paint.get("circle-opacity"),a=n.paint.get("circle-stroke-width"),o=n.paint.get("circle-stroke-opacity");if(0!==i.constantOr(1)||0!==a.constantOr(1)&&0!==o.constantOr(1)){var s=t.context,l=s.gl;s.setDepthMode(t.depthModeForSublayer(0,Ut.ReadOnly)),s.setStencilMode(Ht.disabled),s.setColorMode(t.colorModeForRenderPass());for(var u=!0,c=0;c0?1-1/(1.001-i):-i),s.uniform1f(u.uniforms.u_contrast_factor,(a=n.paint.get("raster-contrast"))>0?1/(1-a):1+a),s.uniform3fv(u.uniforms.u_spin_weights,function(t){t*=Math.PI/180;var e=Math.sin(t),n=Math.cos(t);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}(n.paint.get("raster-hue-rotate"))),s.uniform1f(u.uniforms.u_buffer_scale,1),s.uniform1i(u.uniforms.u_image0,0),s.uniform1i(u.uniforms.u_image1,1);for(var c=r.length&&r[0].overscaledZ,f=0,h=r;fe.row){var n=t;t=e,e=n}return{x0:t.column,y0:t.row,x1:e.column,y1:e.row,dx:e.column-t.column,dy:e.row-t.row}}function Dn(t,e,n,r,i){var a=Math.max(n,Math.floor(e.y0)),o=Math.min(r,Math.ceil(e.y1));if(t.x0===e.x0&&t.y0===e.y0?t.x0+e.dy/t.dy*t.dx0,f=e.dx<0,h=a;hl.dy&&(o=s,s=l,l=o),s.dy>u.dy&&(o=s,s=u,u=o),l.dy>u.dy&&(o=l,l=u,u=o),s.dy&&Dn(u,s,r,i,a),l.dy&&Dn(u,l,r,i,a)}In.prototype.resize=function(t,e){var n=this.context.gl;if(this.width=t*a.devicePixelRatio,this.height=e*a.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(var r=0,i=this.style._order;r=0;this.currentLayer--){var y=r.style._layers[s[r.currentLayer]];y.source!==(m&&m.id)&&(g=[],(m=r.style.sourceCaches[y.source])&&(r.clearStencil(),g=m.getVisibleCoordinates(),m.getSource().isTileClipped&&r._renderTileClippingMasks(g))),r.renderLayer(r,m,y,g)}this.renderPass="translucent";var v,_=[];for(this.currentLayer=0,this.currentLayer;this.currentLayer0?e.pop():null},In.prototype._createProgramCached=function(t,e){this.cache=this.cache||{};var n=""+t+(e.cacheKey||"")+(this._showOverdrawInspector?"/overdraw":"");return this.cache[n]||(this.cache[n]=new an(this.context,rn[t],e,this._showOverdrawInspector)),this.cache[n]},In.prototype.useProgram=function(t,e){var n=this._createProgramCached(t,e||this.emptyProgramConfiguration);return this.context.program.set(n.program),n};var Rn=t.default$20.vec4,Fn=t.default$20.mat4,Bn=t.default$20.mat2,Nn=function(t,e,n){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=t||0,this._maxZoom=e||22,this.latRange=[-85.05113,85.05113],this.width=0,this.height=0,this._center=new Z(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._posMatrixCache={},this._alignedPosMatrixCache={}},jn={minZoom:{configurable:!0},maxZoom:{configurable:!0},renderWorldCopies:{configurable:!0},worldSize:{configurable:!0},centerPoint:{configurable:!0},size:{configurable:!0},bearing:{configurable:!0},pitch:{configurable:!0},fov:{configurable:!0},zoom:{configurable:!0},center:{configurable:!0},unmodified:{configurable:!0},x:{configurable:!0},y:{configurable:!0},point:{configurable:!0}};Nn.prototype.clone=function(){var t=new Nn(this._minZoom,this._maxZoom,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._calcMatrices(),t},jn.minZoom.get=function(){return this._minZoom},jn.minZoom.set=function(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},jn.maxZoom.get=function(){return this._maxZoom},jn.maxZoom.set=function(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},jn.renderWorldCopies.get=function(){return this._renderWorldCopies},jn.renderWorldCopies.set=function(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t},jn.worldSize.get=function(){return this.tileSize*this.scale},jn.centerPoint.get=function(){return this.size._div(2)},jn.size.get=function(){return new t.default$1(this.width,this.height)},jn.bearing.get=function(){return-this.angle/Math.PI*180},jn.bearing.set=function(e){var n=-t.wrap(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=Bn.create(),Bn.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},jn.pitch.get=function(){return this._pitch/Math.PI*180},jn.pitch.set=function(e){var n=t.clamp(e,0,60)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())},jn.fov.get=function(){return this._fov/Math.PI*180},jn.fov.set=function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())},jn.zoom.get=function(){return this._zoom},jn.zoom.set=function(t){var e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._constrain(),this._calcMatrices())},jn.center.get=function(){return this._center},jn.center.set=function(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())},Nn.prototype.coveringZoomLevel=function(t){return(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize))},Nn.prototype.getVisibleUnwrappedCoordinates=function(e){var n=this.pointCoordinate(new t.default$1(0,0),0),r=this.pointCoordinate(new t.default$1(this.width,0),0),i=Math.floor(n.column),a=Math.floor(r.column),o=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies)for(var s=i;s<=a;s++)0!==s&&o.push(new t.UnwrappedTileID(s,e));return o},Nn.prototype.coveringTiles=function(e){var n=this.coveringZoomLevel(e),r=n;if(void 0!==e.minzoom&&ne.maxzoom&&(n=e.maxzoom);var i=this.pointCoordinate(this.centerPoint,n),a=new t.default$1(i.column-.5,i.row-.5);return function(e,n,r,i){void 0===i&&(i=!0);var a=1<=0&&l<=a)for(u=n;uo&&(i=o-m)}if(this.lngRange){var g=this.x,y=u.x/2;g-yl&&(r=l-y)}void 0===r&&void 0===i||(this.center=this.unproject(new t.default$1(void 0!==r?r:this.x,void 0!==i?i:this.y))),this._unmodified=c,this._constraining=!1}},Nn.prototype._calcMatrices=function(){if(this.height){this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height;var t=this._fov/2,e=Math.PI/2+this._pitch,n=Math.sin(t)*this.cameraToCenterDistance/Math.sin(Math.PI-e-t),r=this.x,i=this.y,a=1.01*(Math.cos(Math.PI/2-this._pitch)*n+this.cameraToCenterDistance),o=new Float64Array(16);Fn.perspective(o,this._fov,this.width/this.height,1,a),Fn.scale(o,o,[1,-1,1]),Fn.translate(o,o,[0,0,-this.cameraToCenterDistance]),Fn.rotateX(o,o,this._pitch),Fn.rotateZ(o,o,this.angle),Fn.translate(o,o,[-r,-i,0]);var s=this.worldSize/(2*Math.PI*6378137*Math.abs(Math.cos(this.center.lat*(Math.PI/180))));Fn.scale(o,o,[1,1,s,1]),this.projMatrix=o;var l=this.width%2/2,u=this.height%2/2,c=Math.cos(this.angle),f=Math.sin(this.angle),h=r-Math.round(r)+c*l+f*u,p=i-Math.round(i)+c*u+f*l,d=new Float64Array(o);if(Fn.translate(d,d,[h>.5?h-1:h,p>.5?p-1:p,0]),this.alignedProjMatrix=d,o=Fn.create(),Fn.scale(o,o,[this.width/2,-this.height/2,1]),Fn.translate(o,o,[1,-1,0]),this.pixelMatrix=Fn.multiply(new Float64Array(16),o,this.projMatrix),!(o=Fn.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={}}},Nn.prototype.maxPitchScaleFactor=function(){if(!this.pixelMatrixInverse)return 1;var e=this.pointCoordinate(new t.default$1(0,0)).zoomTo(this.zoom),n=[e.column*this.tileSize,e.row*this.tileSize,0,1];return Rn.transformMat4(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance},Object.defineProperties(Nn.prototype,jn);var Vn=function(){var e,n,r,i;t.bindAll(["_onHashChange","_updateHash"],this),this._updateHash=(e=this._updateHashUnthrottled.bind(this),300,n=!1,r=0,i=function(){r=0,n&&(e(),r=setTimeout(i,300),n=!1)},function(){return n=!0,r||i(),r})};Vn.prototype.addTo=function(e){return this._map=e,t.default.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this},Vn.prototype.remove=function(){return t.default.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this},Vn.prototype.getHashString=function(t){var e=this._map.getCenter(),n=Math.round(100*this._map.getZoom())/100,r=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.pow(10,r),a=Math.round(e.lng*i)/i,o=Math.round(e.lat*i)/i,s=this._map.getBearing(),l=this._map.getPitch(),u="";return u+=t?"#/"+a+"/"+o+"/"+n:"#"+n+"/"+o+"/"+a,(s||l)&&(u+="/"+Math.round(10*s)/10),l&&(u+="/"+Math.round(l)),u},Vn.prototype._onHashChange=function(){var e=t.default.location.hash.replace("#","").split("/");return e.length>=3&&(this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:+(e[3]||0),pitch:+(e[4]||0)}),!0)},Vn.prototype._updateHashUnthrottled=function(){var e=this.getHashString();t.default.history.replaceState(t.default.history.state,"",e)};var qn=function(e){function n(n,r,i,a){void 0===a&&(a={});var o=s.mousePos(r.getCanvasContainer(),i),l=r.unproject(o);e.call(this,n,t.extend({point:o,lngLat:l,originalEvent:i},a)),this._defaultPrevented=!1,this.target=r}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var r={defaultPrevented:{configurable:!0}};return n.prototype.preventDefault=function(){this._defaultPrevented=!0},r.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(n.prototype,r),n}(t.Event),Un=function(e){function n(n,r,i){var a=s.touchPos(r.getCanvasContainer(),i),o=a.map(function(t){return r.unproject(t)}),l=a.reduce(function(t,e,n,r){return t.add(e.div(r.length))},new t.default$1(0,0)),u=r.unproject(l);e.call(this,n,{points:a,point:l,lngLats:o,lngLat:u,originalEvent:i}),this._defaultPrevented=!1}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var r={defaultPrevented:{configurable:!0}};return n.prototype.preventDefault=function(){this._defaultPrevented=!0},r.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(n.prototype,r),n}(t.Event),Hn=function(t){function e(e,n,r){t.call(this,e,{originalEvent:r}),this._defaultPrevented=!1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={defaultPrevented:{configurable:!0}};return e.prototype.preventDefault=function(){this._defaultPrevented=!0},n.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(e.prototype,n),e}(t.Event),Zn=function(e){this._map=e,this._el=e.getCanvasContainer(),this._delta=0,t.bindAll(["_onWheel","_onTimeout","_onScrollFrame","_onScrollFinished"],this)};Zn.prototype.isEnabled=function(){return!!this._enabled},Zn.prototype.isActive=function(){return!!this._active},Zn.prototype.enable=function(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)},Zn.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Zn.prototype.onWheel=function(e){if(this.isEnabled()){var n=e.deltaMode===t.default.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,r=a.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%4.000244140625==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this.isActive()||this._start(e)),e.preventDefault()}},Zn.prototype._onTimeout=function(t){this._type="wheel",this._delta-=this._lastValue,this.isActive()||this._start(t)},Zn.prototype._start=function(e){if(this._delta){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),this._active=!0,this._map.fire(new t.Event("movestart",{originalEvent:e})),this._map.fire(new t.Event("zoomstart",{originalEvent:e})),this._finishTimeout&&clearTimeout(this._finishTimeout);var n=s.mousePos(this._el,e);this._around=Z.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(n)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame))}},Zn.prototype._onScrollFrame=function(){var e=this;if(this._frameId=null,this.isActive()){var n=this._map.transform;if(0!==this._delta){var r="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?1/450:.01,i=2/(1+Math.exp(-Math.abs(this._delta*r)));this._delta<0&&0!==i&&(i=1/i);var o="number"==typeof this._targetZoom?n.zoomScale(this._targetZoom):n.scale;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(o*i))),"wheel"===this._type&&(this._startZoom=n.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}var s=!1;if("wheel"===this._type){var l=Math.min((a.now()-this._lastWheelEventTime)/200,1),u=this._easing(l);n.zoom=t.number(this._startZoom,this._targetZoom,u),l<1?this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame)):s=!0}else n.zoom=this._targetZoom,s=!0;n.setLocationAtPoint(this._around,this._aroundPoint),this._map.fire(new t.Event("move",{originalEvent:this._lastWheelEvent})),this._map.fire(new t.Event("zoom",{originalEvent:this._lastWheelEvent})),s&&(this._active=!1,this._finishTimeout=setTimeout(function(){e._map.fire(new t.Event("zoomend",{originalEvent:e._lastWheelEvent})),e._map.fire(new t.Event("moveend",{originalEvent:e._lastWheelEvent})),delete e._targetZoom},200))}},Zn.prototype._smoothOutEasing=function(e){var n=t.ease;if(this._prevEase){var r=this._prevEase,i=(a.now()-r.start)/r.duration,o=r.easing(i+.01)-r.easing(i),s=.27/Math.sqrt(o*o+1e-4)*.01,l=Math.sqrt(.0729-s*s);n=t.bezier(s,l,.25,1)}return this._prevEase={start:a.now(),duration:e,easing:n},n};var Gn=function(e){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),t.bindAll(["_onMouseMove","_onMouseUp","_onKeyDown"],this)};Gn.prototype.isEnabled=function(){return!!this._enabled},Gn.prototype.isActive=function(){return!!this._active},Gn.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Gn.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Gn.prototype.onMouseDown=function(e){this.isEnabled()&&e.shiftKey&&0===e.button&&(t.default.document.addEventListener("mousemove",this._onMouseMove,!1),t.default.document.addEventListener("keydown",this._onKeyDown,!1),t.default.document.addEventListener("mouseup",this._onMouseUp,!1),s.disableDrag(),this._startPos=s.mousePos(this._el,e),this._active=!0)},Gn.prototype._onMouseMove=function(t){var e=this._startPos,n=s.mousePos(this._el,t);this._box||(this._box=s.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));var r=Math.min(e.x,n.x),i=Math.max(e.x,n.x),a=Math.min(e.y,n.y),o=Math.max(e.y,n.y);s.setTransform(this._box,"translate("+r+"px,"+a+"px)"),this._box.style.width=i-r+"px",this._box.style.height=o-a+"px"},Gn.prototype._onMouseUp=function(e){if(0===e.button){var n=this._startPos,r=s.mousePos(this._el,e),i=(new G).extend(this._map.unproject(n)).extend(this._map.unproject(r));this._finish(),s.suppressClick(),n.x===r.x&&n.y===r.y?this._fireEvent("boxzoomcancel",e):this._map.fitBounds(i,{linear:!0}).fire(new t.Event("boxzoomend",{originalEvent:e,boxZoomBounds:i}))}},Gn.prototype._onKeyDown=function(t){27===t.keyCode&&(this._finish(),this._fireEvent("boxzoomcancel",t))},Gn.prototype._finish=function(){this._active=!1,t.default.document.removeEventListener("mousemove",this._onMouseMove,!1),t.default.document.removeEventListener("keydown",this._onKeyDown,!1),t.default.document.removeEventListener("mouseup",this._onMouseUp,!1),this._container.classList.remove("mapboxgl-crosshair"),this._box&&(s.remove(this._box),this._box=null),s.enableDrag()},Gn.prototype._fireEvent=function(e,n){return this._map.fire(new t.Event(e,{originalEvent:n}))};var $n=t.bezier(0,0,.25,1),Wn=function(e,n){this._map=e,this._el=n.element||e.getCanvasContainer(),this._state="disabled",this._button=n.button||"right",this._bearingSnap=n.bearingSnap||0,this._pitchWithRotate=!1!==n.pitchWithRotate,t.bindAll(["_onMouseMove","_onMouseUp","_onBlur","_onDragFrame"],this)};Wn.prototype.isEnabled=function(){return"disabled"!==this._state},Wn.prototype.isActive=function(){return"active"===this._state},Wn.prototype.enable=function(){this.isEnabled()||(this._state="enabled")},Wn.prototype.disable=function(){if(this.isEnabled())switch(this._state){case"active":this._state="disabled",this._unbind(),this._deactivate(),this._fireEvent("rotateend"),this._pitchWithRotate&&this._fireEvent("pitchend"),this._fireEvent("moveend");break;case"pending":this._state="disabled",this._unbind();break;default:this._state="disabled"}},Wn.prototype.onMouseDown=function(e){if("enabled"===this._state){if("right"===this._button){if(this._eventButton=s.mouseButton(e),this._eventButton!==(e.ctrlKey?0:2))return}else{if(e.ctrlKey||0!==s.mouseButton(e))return;this._eventButton=0}s.disableDrag(),t.default.document.addEventListener("mousemove",this._onMouseMove,{capture:!0}),t.default.document.addEventListener("mouseup",this._onMouseUp),t.default.addEventListener("blur",this._onBlur),this._state="pending",this._inertia=[[a.now(),this._map.getBearing()]],this._previousPos=s.mousePos(this._el,e),this._center=this._map.transform.centerPoint,e.preventDefault()}},Wn.prototype._onMouseMove=function(t){this._lastMoveEvent=t,this._pos=s.mousePos(this._el,t),"pending"===this._state&&(this._state="active",this._fireEvent("rotatestart",t),this._fireEvent("movestart",t),this._pitchWithRotate&&this._fireEvent("pitchstart",t)),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onDragFrame))},Wn.prototype._onDragFrame=function(){this._frameId=null;var t=this._lastMoveEvent;if(t){var e=this._map.transform,n=this._previousPos,r=this._pos,i=.8*(n.x-r.x),o=-.5*(n.y-r.y),s=e.bearing-i,l=e.pitch-o,u=this._inertia,c=u[u.length-1];this._drainInertiaBuffer(),u.push([a.now(),this._map._normalizeBearing(s,c[1])]),e.bearing=s,this._pitchWithRotate&&(this._fireEvent("pitch",t),e.pitch=l),this._fireEvent("rotate",t),this._fireEvent("move",t),delete this._lastMoveEvent,this._previousPos=this._pos}},Wn.prototype._onMouseUp=function(t){if(s.mouseButton(t)===this._eventButton)switch(this._state){case"active":this._state="enabled",s.suppressClick(),this._unbind(),this._deactivate(),this._inertialRotate(t);break;case"pending":this._state="enabled",this._unbind()}},Wn.prototype._onBlur=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._fireEvent("rotateend",t),this._pitchWithRotate&&this._fireEvent("pitchend",t),this._fireEvent("moveend",t);break;case"pending":this._state="enabled",this._unbind()}},Wn.prototype._unbind=function(){t.default.document.removeEventListener("mousemove",this._onMouseMove,{capture:!0}),t.default.document.removeEventListener("mouseup",this._onMouseUp),t.default.removeEventListener("blur",this._onBlur),s.enableDrag()},Wn.prototype._deactivate=function(){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._lastMoveEvent,delete this._previousPos},Wn.prototype._inertialRotate=function(t){var e=this;this._fireEvent("rotateend",t),this._drainInertiaBuffer();var n=this._map,r=n.getBearing(),i=this._inertia,a=function(){Math.abs(r)180&&(p=180);var d=p/180;u+=f*p*(d/2),Math.abs(n._normalizeBearing(u,0))0&&e-t[0][0]>160;)t.shift()};var Xn=t.bezier(0,0,.3,1),Yn=function(e){this._map=e,this._el=e.getCanvasContainer(),this._state="disabled",t.bindAll(["_onMove","_onMouseUp","_onTouchEnd","_onBlur","_onDragFrame"],this)};Yn.prototype.isEnabled=function(){return"disabled"!==this._state},Yn.prototype.isActive=function(){return"active"===this._state},Yn.prototype.enable=function(){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-drag-pan"),this._state="enabled")},Yn.prototype.disable=function(){if(this.isEnabled())switch(this._el.classList.remove("mapboxgl-touch-drag-pan"),this._state){case"active":this._state="disabled",this._unbind(),this._deactivate(),this._fireEvent("dragend"),this._fireEvent("moveend");break;case"pending":this._state="disabled",this._unbind();break;default:this._state="disabled"}},Yn.prototype.onMouseDown=function(e){"enabled"===this._state&&(e.ctrlKey||0!==s.mouseButton(e)||(s.addEventListener(t.default.document,"mousemove",this._onMove,{capture:!0}),s.addEventListener(t.default.document,"mouseup",this._onMouseUp),this._start(e)))},Yn.prototype.onTouchStart=function(e){"enabled"===this._state&&(e.touches.length>1||(s.addEventListener(t.default.document,"touchmove",this._onMove,{capture:!0,passive:!1}),s.addEventListener(t.default.document,"touchend",this._onTouchEnd),this._start(e)))},Yn.prototype._start=function(e){t.default.addEventListener("blur",this._onBlur),this._state="pending",this._previousPos=s.mousePos(this._el,e),this._inertia=[[a.now(),this._previousPos]]},Yn.prototype._onMove=function(t){this._lastMoveEvent=t,t.preventDefault(),this._pos=s.mousePos(this._el,t),this._drainInertiaBuffer(),this._inertia.push([a.now(),this._pos]),"pending"===this._state&&(this._state="active",this._fireEvent("dragstart",t),this._fireEvent("movestart",t)),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onDragFrame))},Yn.prototype._onDragFrame=function(){this._frameId=null;var t=this._lastMoveEvent;if(t){var e=this._map.transform;e.setLocationAtPoint(e.pointLocation(this._previousPos),this._pos),this._fireEvent("drag",t),this._fireEvent("move",t),this._previousPos=this._pos,delete this._lastMoveEvent}},Yn.prototype._onMouseUp=function(t){if(0===s.mouseButton(t))switch(this._state){case"active":this._state="enabled",s.suppressClick(),this._unbind(),this._deactivate(),this._inertialPan(t);break;case"pending":this._state="enabled",this._unbind()}},Yn.prototype._onTouchEnd=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._inertialPan(t);break;case"pending":this._state="enabled",this._unbind()}},Yn.prototype._onBlur=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._fireEvent("dragend",t),this._fireEvent("moveend",t);break;case"pending":this._state="enabled",this._unbind()}},Yn.prototype._unbind=function(){s.removeEventListener(t.default.document,"touchmove",this._onMove,{capture:!0,passive:!1}),s.removeEventListener(t.default.document,"touchend",this._onTouchEnd),s.removeEventListener(t.default.document,"mousemove",this._onMove,{capture:!0}),s.removeEventListener(t.default.document,"mouseup",this._onMouseUp),s.removeEventListener(t.default,"blur",this._onBlur)},Yn.prototype._deactivate=function(){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._lastMoveEvent,delete this._previousPos,delete this._pos},Yn.prototype._inertialPan=function(t){this._fireEvent("dragend",t),this._drainInertiaBuffer();var e=this._inertia;if(e.length<2)this._fireEvent("moveend",t);else{var n=e[e.length-1],r=e[0],i=n[1].sub(r[1]),a=(n[0]-r[0])/1e3;if(0===a||n[1].equals(r[1]))this._fireEvent("moveend",t);else{var o=i.mult(.3/a),s=o.mag();s>1400&&(s=1400,o._unit()._mult(s));var l=s/750,u=o.mult(-l/2);this._map.panBy(u,{duration:1e3*l,easing:Xn,noMoveStart:!0},{originalEvent:t})}}},Yn.prototype._fireEvent=function(e,n){return this._map.fire(new t.Event(e,n?{originalEvent:n}:{}))},Yn.prototype._drainInertiaBuffer=function(){for(var t=this._inertia,e=a.now();t.length>0&&e-t[0][0]>160;)t.shift()};var Jn=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onKeyDown"],this)};function Kn(t){return t*(2-t)}Jn.prototype.isEnabled=function(){return!!this._enabled},Jn.prototype.enable=function(){this.isEnabled()||(this._el.addEventListener("keydown",this._onKeyDown,!1),this._enabled=!0)},Jn.prototype.disable=function(){this.isEnabled()&&(this._el.removeEventListener("keydown",this._onKeyDown),this._enabled=!1)},Jn.prototype._onKeyDown=function(t){if(!(t.altKey||t.ctrlKey||t.metaKey)){var e=0,n=0,r=0,i=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?n=-1:(t.preventDefault(),i=-1);break;case 39:t.shiftKey?n=1:(t.preventDefault(),i=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?r=-1:(a=1,t.preventDefault());break;default:return}var o=this._map,s=o.getZoom(),l={duration:300,delayEndEvents:500,easing:Kn,zoom:e?Math.round(s)+e*(t.shiftKey?2:1):s,bearing:o.getBearing()+15*n,pitch:o.getPitch()+10*r,offset:[100*-i,100*-a],center:o.getCenter()};o.easeTo(l,{originalEvent:t})}};var Qn=function(e){this._map=e,t.bindAll(["_onDblClick","_onZoomEnd"],this)};Qn.prototype.isEnabled=function(){return!!this._enabled},Qn.prototype.isActive=function(){return!!this._active},Qn.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Qn.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Qn.prototype.onTouchStart=function(t){var e=this;this.isEnabled()&&(t.points.length>1||(this._tapped?(clearTimeout(this._tapped),this._tapped=null,this._zoom(t)):this._tapped=setTimeout(function(){e._tapped=null},300)))},Qn.prototype.onDblClick=function(t){this.isEnabled()&&(t.originalEvent.preventDefault(),this._zoom(t))},Qn.prototype._zoom=function(t){this._active=!0,this._map.on("zoomend",this._onZoomEnd),this._map.zoomTo(this._map.getZoom()+(t.originalEvent.shiftKey?-1:1),{around:t.lngLat},t)},Qn.prototype._onZoomEnd=function(){this._active=!1,this._map.off("zoomend",this._onZoomEnd)};var tr=t.bezier(0,0,.15,1),er=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onMove","_onEnd","_onTouchFrame"],this)};er.prototype.isEnabled=function(){return!!this._enabled},er.prototype.enable=function(t){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-zoom-rotate"),this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)},er.prototype.disable=function(){this.isEnabled()&&(this._el.classList.remove("mapboxgl-touch-zoom-rotate"),this._enabled=!1)},er.prototype.disableRotation=function(){this._rotationDisabled=!0},er.prototype.enableRotation=function(){this._rotationDisabled=!1},er.prototype.onStart=function(e){if(this.isEnabled()&&2===e.touches.length){var n=s.mousePos(this._el,e.touches[0]),r=s.mousePos(this._el,e.touches[1]);this._startVec=n.sub(r),this._gestureIntent=void 0,this._inertia=[],s.addEventListener(t.default.document,"touchmove",this._onMove,{passive:!1}),s.addEventListener(t.default.document,"touchend",this._onEnd)}},er.prototype._getTouchEventData=function(t){var e=s.mousePos(this._el,t.touches[0]),n=s.mousePos(this._el,t.touches[1]),r=e.sub(n);return{vec:r,center:e.add(n).div(2),scale:r.mag()/this._startVec.mag(),bearing:this._rotationDisabled?0:180*r.angleWith(this._startVec)/Math.PI}},er.prototype._onMove=function(e){if(2===e.touches.length){var n=this._getTouchEventData(e),r=n.vec,i=n.scale,a=n.bearing;if(!this._gestureIntent){var o=Math.abs(1-i)>.15;Math.abs(a)>10?this._gestureIntent="rotate":o&&(this._gestureIntent="zoom"),this._gestureIntent&&(this._map.fire(new t.Event(this._gestureIntent+"start",{originalEvent:e})),this._map.fire(new t.Event("movestart",{originalEvent:e})),this._startVec=r)}this._lastTouchEvent=e,this._frameId||(this._frameId=this._map._requestRenderFrame(this._onTouchFrame)),e.preventDefault()}},er.prototype._onTouchFrame=function(){this._frameId=null;var e=this._gestureIntent;if(e){var n=this._map.transform;this._startScale||(this._startScale=n.scale,this._startBearing=n.bearing);var r=this._getTouchEventData(this._lastTouchEvent),i=r.center,o=r.bearing,s=r.scale,l=n.pointLocation(i),u=n.locationPoint(l);"rotate"===e&&(n.bearing=this._startBearing+o),n.zoom=n.scaleZoom(this._startScale*s),n.setLocationAtPoint(l,u),this._map.fire(new t.Event(e,{originalEvent:this._lastTouchEvent})),this._map.fire(new t.Event("move",{originalEvent:this._lastTouchEvent})),this._drainInertiaBuffer(),this._inertia.push([a.now(),s,i])}},er.prototype._onEnd=function(e){s.removeEventListener(t.default.document,"touchmove",this._onMove,{passive:!1}),s.removeEventListener(t.default.document,"touchend",this._onEnd);var n=this._gestureIntent,r=this._startScale;if(this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._gestureIntent,delete this._startScale,delete this._startBearing,delete this._lastTouchEvent,n){this._map.fire(new t.Event(n+"end",{originalEvent:e})),this._drainInertiaBuffer();var i=this._inertia,a=this._map;if(i.length<2)a.snapToNorth({},{originalEvent:e});else{var o=i[i.length-1],l=i[0],u=a.transform.scaleZoom(r*o[1]),c=a.transform.scaleZoom(r*l[1]),f=u-c,h=(o[0]-l[0])/1e3,p=o[2];if(0!==h&&u!==c){var d=.15*f/h;Math.abs(d)>2.5&&(d=d>0?2.5:-2.5);var m=1e3*Math.abs(d/(12*.15)),g=u+d*m/2e3;g<0&&(g=0),a.easeTo({zoom:g,duration:m,easing:tr,around:this._aroundCenter?a.getCenter():a.unproject(p),noMoveStart:!0},{originalEvent:e})}else a.snapToNorth({},{originalEvent:e})}}},er.prototype._drainInertiaBuffer=function(){for(var t=this._inertia,e=a.now();t.length>2&&e-t[0][0]>160;)t.shift()};var nr={scrollZoom:Zn,boxZoom:Gn,dragRotate:Wn,dragPan:Yn,keyboard:Jn,doubleClickZoom:Qn,touchZoomRotate:er},rr=function(e){function n(n,r){e.call(this),this._moving=!1,this._zooming=!1,this.transform=n,this._bearingSnap=r.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.getCenter=function(){return this.transform.center},n.prototype.setCenter=function(t,e){return this.jumpTo({center:t},e)},n.prototype.panBy=function(e,n,r){return e=t.default$1.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},n),r)},n.prototype.panTo=function(e,n,r){return this.easeTo(t.extend({center:e},n),r)},n.prototype.getZoom=function(){return this.transform.zoom},n.prototype.setZoom=function(t,e){return this.jumpTo({zoom:t},e),this},n.prototype.zoomTo=function(e,n,r){return this.easeTo(t.extend({zoom:e},n),r)},n.prototype.zoomIn=function(t,e){return this.zoomTo(this.getZoom()+1,t,e),this},n.prototype.zoomOut=function(t,e){return this.zoomTo(this.getZoom()-1,t,e),this},n.prototype.getBearing=function(){return this.transform.bearing},n.prototype.setBearing=function(t,e){return this.jumpTo({bearing:t},e),this},n.prototype.rotateTo=function(e,n,r){return this.easeTo(t.extend({bearing:e},n),r)},n.prototype.resetNorth=function(e,n){return this.rotateTo(0,t.extend({duration:1e3},e),n),this},n.prototype.snapToNorth=function(t,e){return Math.abs(this.getBearing())e?1:0}),["bottom","left","right","top"]))return t.warnOnce("options.padding must be a positive number, or an Object with keys 'bottom', 'left', 'right', 'top'"),this;e=G.convert(e);var a=[(n.padding.left-n.padding.right)/2,(n.padding.top-n.padding.bottom)/2],o=Math.min(n.padding.right,n.padding.left),s=Math.min(n.padding.top,n.padding.bottom);n.offset=[n.offset[0]+a[0],n.offset[1]+a[1]];var l=t.default$1.convert(n.offset),u=this.transform,c=u.project(e.getNorthWest()),f=u.project(e.getSouthEast()),h=f.sub(c),p=(u.width-2*o-2*Math.abs(l.x))/h.x,d=(u.height-2*s-2*Math.abs(l.y))/h.y;return d<0||p<0?(t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset."),this):(n.center=u.unproject(c.add(f).div(2)),n.zoom=Math.min(u.scaleZoom(u.scale*Math.min(p,d)),n.maxZoom),n.bearing=0,n.linear?this.easeTo(n,r):this.flyTo(n,r))},n.prototype.jumpTo=function(e,n){this.stop();var r=this.transform,i=!1,a=!1,o=!1;return"zoom"in e&&r.zoom!==+e.zoom&&(i=!0,r.zoom=+e.zoom),void 0!==e.center&&(r.center=Z.convert(e.center)),"bearing"in e&&r.bearing!==+e.bearing&&(a=!0,r.bearing=+e.bearing),"pitch"in e&&r.pitch!==+e.pitch&&(o=!0,r.pitch=+e.pitch),this.fire(new t.Event("movestart",n)).fire(new t.Event("move",n)),i&&this.fire(new t.Event("zoomstart",n)).fire(new t.Event("zoom",n)).fire(new t.Event("zoomend",n)),a&&this.fire(new t.Event("rotatestart",n)).fire(new t.Event("rotate",n)).fire(new t.Event("rotateend",n)),o&&this.fire(new t.Event("pitchstart",n)).fire(new t.Event("pitch",n)).fire(new t.Event("pitchend",n)),this.fire(new t.Event("moveend",n))},n.prototype.easeTo=function(e,n){var r=this;this.stop(),!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate&&(e.duration=0);var i=this.transform,a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l="zoom"in e?+e.zoom:a,u="bearing"in e?this._normalizeBearing(e.bearing,o):o,c="pitch"in e?+e.pitch:s,f=i.centerPoint.add(t.default$1.convert(e.offset)),h=i.pointLocation(f),p=Z.convert(e.center||h);this._normalizeCenter(p);var d,m,g=i.project(h),y=i.project(p).sub(g),v=i.zoomScale(l-a);return e.around&&(d=Z.convert(e.around),m=i.locationPoint(d)),this._zooming=l!==a,this._rotating=o!==u,this._pitching=c!==s,this._prepareEase(n,e.noMoveStart),clearTimeout(this._easeEndTimeoutID),this._ease(function(e){if(r._zooming&&(i.zoom=t.number(a,l,e)),r._rotating&&(i.bearing=t.number(o,u,e)),r._pitching&&(i.pitch=t.number(s,c,e)),d)i.setLocationAtPoint(d,m);else{var h=i.zoomScale(i.zoom-a),p=l>a?Math.min(2,v):Math.max(.5,v),_=Math.pow(p,1-e),x=i.unproject(g.add(y.mult(e*_)).mult(h));i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,f)}r._fireMoveEvents(n)},function(){e.delayEndEvents?r._easeEndTimeoutID=setTimeout(function(){return r._afterEase(n)},e.delayEndEvents):r._afterEase(n)},e),this},n.prototype._prepareEase=function(e,n){this._moving=!0,n||this.fire(new t.Event("movestart",e)),this._zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&this.fire(new t.Event("pitchstart",e))},n.prototype._fireMoveEvents=function(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))},n.prototype._afterEase=function(e){var n=this._zooming,r=this._rotating,i=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,n&&this.fire(new t.Event("zoomend",e)),r&&this.fire(new t.Event("rotateend",e)),i&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))},n.prototype.flyTo=function(e,n){var r=this;this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);var i=this.transform,a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l="zoom"in e?t.clamp(+e.zoom,i.minZoom,i.maxZoom):a,u="bearing"in e?this._normalizeBearing(e.bearing,o):o,c="pitch"in e?+e.pitch:s,f=i.zoomScale(l-a),h=i.centerPoint.add(t.default$1.convert(e.offset)),p=i.pointLocation(h),d=Z.convert(e.center||p);this._normalizeCenter(d);var m=i.project(p),g=i.project(d).sub(m),y=e.curve,v=Math.max(i.width,i.height),_=v/f,x=g.mag();if("minZoom"in e){var b=t.clamp(Math.min(e.minZoom,a,l),i.minZoom,i.maxZoom),w=v/i.zoomScale(b-a);y=Math.sqrt(w/x*2)}var k=y*y;function T(t){var e=(_*_-v*v+(t?-1:1)*k*k*x*x)/(2*(t?_:v)*k*x);return Math.log(Math.sqrt(e*e+1)-e)}function A(t){return(Math.exp(t)-Math.exp(-t))/2}function M(t){return(Math.exp(t)+Math.exp(-t))/2}var S=T(0),C=function(t){return M(S)/M(S+y*t)},z=function(t){return v*((M(S)*(A(e=S+y*t)/M(e))-A(S))/k)/x;var e},E=(T(1)-S)/y;if(Math.abs(x)<1e-6||!isFinite(E)){if(Math.abs(v-_)<1e-6)return this.easeTo(e,n);var L=_e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==u,this._pitching=c!==s,this._prepareEase(n,!1),this._ease(function(e){var l=e*E,f=1/C(l);i.zoom=a+i.scaleZoom(f),r._rotating&&(i.bearing=t.number(o,u,e)),r._pitching&&(i.pitch=t.number(s,c,e));var p=i.unproject(m.add(g.mult(z(l))).mult(f));i.setLocationAtPoint(i.renderWorldCopies?p.wrap():p,h),r._fireMoveEvents(n)},function(){return r._afterEase(n)},e),this},n.prototype.isEasing=function(){return!!this._easeFrameId},n.prototype.stop=function(){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){var t=this._onEaseEnd;delete this._onEaseEnd,t.call(this)}return this},n.prototype._ease=function(t,e,n){!1===n.animate||0===n.duration?(t(1),e()):(this._easeStart=a.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))},n.prototype._renderFrameCallback=function(){var t=Math.min((a.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},n.prototype._normalizeBearing=function(e,n){e=t.wrap(e,-180,180);var r=Math.abs(e-n);return Math.abs(e-360-n)180?-360:n<-180?360:0}},n}(t.Evented),ir=function(e){void 0===e&&(e={}),this.options=e,t.bindAll(["_updateEditLink","_updateData","_updateCompact"],this)};ir.prototype.getDefaultPosition=function(){return"bottom-right"},ir.prototype.onAdd=function(t){var e=this.options&&this.options.compact;return this._map=t,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),e&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container},ir.prototype.onRemove=function(){s.remove(this._container),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0},ir.prototype._updateEditLink=function(){var t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));var e=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:g.ACCESS_TOKEN}];if(t){var n=e.reduce(function(t,n,r){return n.value&&(t+=n.key+"="+n.value+(r=0)return!1;return!0})).length?(this._container.innerHTML=t.join(" | "),this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null}},ir.prototype._updateCompact=function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact")};var ar=function(){t.bindAll(["_updateLogo"],this)};ar.prototype.onAdd=function(t){this._map=t,this._container=s.create("div","mapboxgl-ctrl");var e=s.create("a","mapboxgl-ctrl-logo");return e.target="_blank",e.href="https://www.mapbox.com/",e.setAttribute("aria-label","Mapbox logo"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._container},ar.prototype.onRemove=function(){s.remove(this._container),this._map.off("sourcedata",this._updateLogo)},ar.prototype.getDefaultPosition=function(){return"bottom-left"},ar.prototype._updateLogo=function(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")},ar.prototype._logoRequired=function(){if(this._map.style){var t=this._map.style.sourceCaches;for(var e in t)if(t[e].getSource().mapbox_logo)return!0;return!1}};var or=function(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1};or.prototype.add=function(t){var e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e},or.prototype.remove=function(t){for(var e=this._currentlyRunning,n=0,r=e?this._queue.concat(e):this._queue;ne.maxZoom)throw new Error("maxZoom must be greater than minZoom");var r=new Nn(e.minZoom,e.maxZoom,e.renderWorldCopies);n.call(this,r,e),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new or;var i=e.transformRequest;if(this._transformRequest=i?function(t,e){return i(t,e)||{url:t}}:function(t){return{url:t}},"string"==typeof e.container){var a=t.default.document.getElementById(e.container);if(!a)throw new Error("Container '"+e.container+"' not found.");this._container=a}else{if(!(e.container instanceof lr))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_contextLost","_contextRestored","_update","_render","_onData","_onDataLoading"],this),this._setupContainer(),this._setupPainter(),this.on("move",this._update.bind(this,!1)),this.on("zoom",this._update.bind(this,!0)),void 0!==t.default&&(t.default.addEventListener("online",this._onWindowOnline,!1),t.default.addEventListener("resize",this._onWindowResize,!1)),function(t,e){var n=t.getCanvasContainer(),r=null,i=!1;for(var a in nr)t[a]=new nr[a](t,e),e.interactive&&e[a]&&t[a].enable(e[a]);s.addEventListener(n,"mouseout",function(e){t.fire(new qn("mouseout",t,e))}),s.addEventListener(n,"mousedown",function(n){i=!0;var r=new qn("mousedown",t,n);t.fire(r),r.defaultPrevented||(e.interactive&&!t.doubleClickZoom.isActive()&&t.stop(),t.boxZoom.onMouseDown(n),t.boxZoom.isActive()||t.dragPan.isActive()||t.dragRotate.onMouseDown(n),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onMouseDown(n))}),s.addEventListener(n,"mouseup",function(e){var n=t.dragRotate.isActive();r&&!n&&t.fire(new qn("contextmenu",t,r)),r=null,i=!1,t.fire(new qn("mouseup",t,e))}),s.addEventListener(n,"mousemove",function(e){if(!t.dragPan.isActive()&&!t.dragRotate.isActive()){for(var r=e.toElement||e.target;r&&r!==n;)r=r.parentNode;r===n&&t.fire(new qn("mousemove",t,e))}}),s.addEventListener(n,"mouseover",function(e){for(var r=e.toElement||e.target;r&&r!==n;)r=r.parentNode;r===n&&t.fire(new qn("mouseover",t,e))}),s.addEventListener(n,"touchstart",function(n){var r=new Un("touchstart",t,n);t.fire(r),r.defaultPrevented||(e.interactive&&t.stop(),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onTouchStart(n),t.touchZoomRotate.onStart(n),t.doubleClickZoom.onTouchStart(r))},{passive:!1}),s.addEventListener(n,"touchmove",function(e){t.fire(new Un("touchmove",t,e))},{passive:!1}),s.addEventListener(n,"touchend",function(e){t.fire(new Un("touchend",t,e))}),s.addEventListener(n,"touchcancel",function(e){t.fire(new Un("touchcancel",t,e))}),s.addEventListener(n,"click",function(e){t.fire(new qn("click",t,e))}),s.addEventListener(n,"dblclick",function(e){var n=new qn("dblclick",t,e);t.fire(n),n.defaultPrevented||t.doubleClickZoom.onDblClick(n)}),s.addEventListener(n,"contextmenu",function(e){var n=t.dragRotate.isActive();i||n?i&&(r=e):t.fire(new qn("contextmenu",t,e)),e.preventDefault()}),s.addEventListener(n,"wheel",function(e){var n=new Hn("wheel",t,e);t.fire(n),n.defaultPrevented||t.scrollZoom.onWheel(e)},{passive:!1})}(this,e),this._hash=e.hash&&(new Vn).addTo(this),this._hash&&this._hash._onHashChange()||this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),this.resize(),e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new ir),this.addControl(new ar,e.logoPosition),this.on("style.load",function(){this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",this._onData),this.on("dataloading",this._onDataLoading)}n&&(r.__proto__=n),r.prototype=Object.create(n&&n.prototype),r.prototype.constructor=r;var i={showTileBoundaries:{configurable:!0},showCollisionBoxes:{configurable:!0},showOverdrawInspector:{configurable:!0},repaint:{configurable:!0},vertices:{configurable:!0}};return r.prototype.addControl=function(t,e){void 0===e&&t.getDefaultPosition&&(e=t.getDefaultPosition()),void 0===e&&(e="top-right");var n=t.onAdd(this),r=this._controlPositions[e];return-1!==e.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this},r.prototype.removeControl=function(t){return t.onRemove(this),this},r.prototype.resize=function(e){var n=this._containerDimensions(),r=n[0],i=n[1];return this._resizeCanvas(r,i),this.transform.resize(r,i),this.painter.resize(r,i),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)).fire(new t.Event("resize",e)).fire(new t.Event("moveend",e))},r.prototype.getBounds=function(){var e=new G(this.transform.pointLocation(new t.default$1(0,this.transform.height)),this.transform.pointLocation(new t.default$1(this.transform.width,0)));return(this.transform.angle||this.transform.pitch)&&(e.extend(this.transform.pointLocation(new t.default$1(this.transform.size.x,0))),e.extend(this.transform.pointLocation(new t.default$1(0,this.transform.size.y)))),e},r.prototype.getMaxBounds=function(){return this.transform.latRange&&2===this.transform.latRange.length&&this.transform.lngRange&&2===this.transform.lngRange.length?new G([this.transform.lngRange[0],this.transform.latRange[0]],[this.transform.lngRange[1],this.transform.latRange[1]]):null},r.prototype.setMaxBounds=function(t){if(t){var e=G.convert(t);this.transform.lngRange=[e.getWest(),e.getEast()],this.transform.latRange=[e.getSouth(),e.getNorth()],this.transform._constrain(),this._update()}else null==t&&(this.transform.lngRange=null,this.transform.latRange=null,this._update());return this},r.prototype.setMinZoom=function(t){if((t=null==t?0:t)>=0&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")},r.prototype.getRenderWorldCopies=function(){return this.transform.renderWorldCopies},r.prototype.setRenderWorldCopies=function(t){return this.transform.renderWorldCopies=t,this._update(),this},r.prototype.getMaxZoom=function(){return this.transform.maxZoom},r.prototype.project=function(t){return this.transform.locationPoint(Z.convert(t))},r.prototype.unproject=function(e){return this.transform.pointLocation(t.default$1.convert(e))},r.prototype.isMoving=function(){return this._moving||this.dragPan.isActive()||this.dragRotate.isActive()||this.scrollZoom.isActive()},r.prototype.isZooming=function(){return this._zooming||this.scrollZoom.isActive()},r.prototype.isRotating=function(){return this._rotating||this.dragRotate.isActive()},r.prototype.on=function(t,e,r){var i,a=this;if(void 0===r)return n.prototype.on.call(this,t,e);var o=function(){if("mouseenter"===t||"mouseover"===t){var n=!1;return{layer:e,listener:r,delegates:{mousemove:function(i){var o=a.getLayer(e)?a.queryRenderedFeatures(i.point,{layers:[e]}):[];o.length?n||(n=!0,r.call(a,new qn(t,a,i.originalEvent,{features:o}))):n=!1},mouseout:function(){n=!1}}}}if("mouseleave"===t||"mouseout"===t){var o=!1;return{layer:e,listener:r,delegates:{mousemove:function(n){(a.getLayer(e)?a.queryRenderedFeatures(n.point,{layers:[e]}):[]).length?o=!0:o&&(o=!1,r.call(a,new qn(t,a,n.originalEvent)))},mouseout:function(e){o&&(o=!1,r.call(a,new qn(t,a,e.originalEvent)))}}}}return{layer:e,listener:r,delegates:(i={},i[t]=function(t){var n=a.getLayer(e)?a.queryRenderedFeatures(t.point,{layers:[e]}):[];n.length&&(t.features=n,r.call(a,t),delete t.features)},i)}}();for(var s in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(o),o.delegates)a.on(s,o.delegates[s]);return this},r.prototype.off=function(t,e,r){if(void 0===r)return n.prototype.off.call(this,t,e);if(this._delegatedListeners&&this._delegatedListeners[t])for(var i=this._delegatedListeners[t],a=0;a180;){var o=n.locationPoint(t);if(o.x>=0&&o.y>=0&&o.x<=n.width&&o.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t}pr.prototype._rotateCompassArrow=function(){var t="rotate("+this._map.transform.angle*(180/Math.PI)+"deg)";this._compassArrow.style.transform=t},pr.prototype.onAdd=function(t){return this._map=t,this.options.showCompass&&(this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Wn(t,{button:"left",element:this._compass}),this._handler.enable()),this._container},pr.prototype.onRemove=function(){s.remove(this._container),this.options.showCompass&&(this._map.off("rotate",this._rotateCompassArrow),this._handler.disable(),delete this._handler),delete this._map},pr.prototype._createButton=function(t,e,n){var r=s.create("button",t,this._container);return r.type="button",r.setAttribute("aria-label",e),r.addEventListener("click",n),r};var mr={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function gr(t,e,n){var r=t.classList;for(var i in mr)r.remove("mapboxgl-"+n+"-anchor-"+i);r.add("mapboxgl-"+n+"-anchor-"+e)}var yr=function(e){if((arguments[0]instanceof t.default.HTMLElement||2===arguments.length)&&(e=t.extend({element:e},arguments[1])),t.bindAll(["_update","_onMapClick"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",e&&e.element)this._element=e.element,this._offset=t.default$1.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=s.create("div");var n=s.createNS("http://www.w3.org/2000/svg","svg");n.setAttributeNS(null,"height","41px"),n.setAttributeNS(null,"width","27px"),n.setAttributeNS(null,"viewBox","0 0 27 41");var r=s.createNS("http://www.w3.org/2000/svg","g");r.setAttributeNS(null,"stroke","none"),r.setAttributeNS(null,"stroke-width","1"),r.setAttributeNS(null,"fill","none"),r.setAttributeNS(null,"fill-rule","evenodd");var i=s.createNS("http://www.w3.org/2000/svg","g");i.setAttributeNS(null,"fill-rule","nonzero");var a=s.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");for(var o=0,l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];o5280?Tr(e,u,h/5280,"mi"):Tr(e,u,h,"ft")}else n&&"nautical"===n.unit?Tr(e,u,f/1852,"nm"):Tr(e,u,f,"m")}function Tr(t,e,n,r){var i,a,o,s=(i=n,(a=Math.pow(10,(""+Math.floor(i)).length-1))*(o=(o=i/a)>=10?10:o>=5?5:o>=3?3:o>=2?2:1)),l=s/n;"m"===r&&s>=1e3&&(s/=1e3,r="km"),t.style.width=e*l+"px",t.innerHTML=s+r}wr.prototype.getDefaultPosition=function(){return"bottom-left"},wr.prototype._onMove=function(){kr(this._map,this._container,this.options)},wr.prototype.onAdd=function(t){return this._map=t,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container},wr.prototype.onRemove=function(){s.remove(this._container),this._map.off("move",this._onMove),this._map=void 0},wr.prototype.setUnit=function(t){this.options.unit=t,kr(this._map,this._container,this.options)};var Ar=function(){this._fullscreen=!1,t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.default.document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in t.default.document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in t.default.document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in t.default.document&&(this._fullscreenchange="MSFullscreenChange"),this._className="mapboxgl-ctrl"};Ar.prototype.onAdd=function(e){return this._map=e,this._mapContainer=this._map.getContainer(),this._container=s.create("div",this._className+" mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._container.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._container},Ar.prototype.onRemove=function(){s.remove(this._container),this._map=null,t.default.document.removeEventListener(this._fullscreenchange,this._changeIcon)},Ar.prototype._checkFullscreenSupport=function(){return!!(t.default.document.fullscreenEnabled||t.default.document.mozFullScreenEnabled||t.default.document.msFullscreenEnabled||t.default.document.webkitFullscreenEnabled)},Ar.prototype._setupUI=function(){var e=this._fullscreenButton=s.create("button",this._className+"-icon "+this._className+"-fullscreen",this._container);e.setAttribute("aria-label","Toggle fullscreen"),e.type="button",this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.default.document.addEventListener(this._fullscreenchange,this._changeIcon)},Ar.prototype._isFullscreen=function(){return this._fullscreen},Ar.prototype._changeIcon=function(){(t.default.document.fullscreenElement||t.default.document.mozFullScreenElement||t.default.document.webkitFullscreenElement||t.default.document.msFullscreenElement)===this._mapContainer!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(this._className+"-shrink"),this._fullscreenButton.classList.toggle(this._className+"-fullscreen"))},Ar.prototype._onClickFullscreen=function(){this._isFullscreen()?t.default.document.exitFullscreen?t.default.document.exitFullscreen():t.default.document.mozCancelFullScreen?t.default.document.mozCancelFullScreen():t.default.document.msExitFullscreen?t.default.document.msExitFullscreen():t.default.document.webkitCancelFullScreen&&t.default.document.webkitCancelFullScreen():this._mapContainer.requestFullscreen?this._mapContainer.requestFullscreen():this._mapContainer.mozRequestFullScreen?this._mapContainer.mozRequestFullScreen():this._mapContainer.msRequestFullscreen?this._mapContainer.msRequestFullscreen():this._mapContainer.webkitRequestFullscreen&&this._mapContainer.webkitRequestFullscreen()};var Mr={closeButton:!0,closeOnClick:!0},Sr=function(e){function n(n){e.call(this),this.options=t.extend(Object.create(Mr),n),t.bindAll(["_update","_onClickClose"],this)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.addTo=function(e){return this._map=e,this._map.on("move",this._update),this.options.closeOnClick&&this._map.on("click",this._onClickClose),this._update(),this.fire(new t.Event("open")),this},n.prototype.isOpen=function(){return!!this._map},n.prototype.remove=function(){return this._content&&s.remove(this._content),this._container&&(s.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("click",this._onClickClose),delete this._map),this.fire(new t.Event("close")),this},n.prototype.getLngLat=function(){return this._lngLat},n.prototype.setLngLat=function(t){return this._lngLat=Z.convert(t),this._pos=null,this._update(),this},n.prototype.setText=function(e){return this.setDOMContent(t.default.document.createTextNode(e))},n.prototype.setHTML=function(e){var n,r=t.default.document.createDocumentFragment(),i=t.default.document.createElement("body");for(i.innerHTML=e;n=i.firstChild;)r.appendChild(n);return this.setDOMContent(r)},n.prototype.setDOMContent=function(t){return this._createContent(),this._content.appendChild(t),this._update(),this},n.prototype._createContent=function(){this._content&&s.remove(this._content),this._content=s.create("div","mapboxgl-popup-content",this._container),this.options.closeButton&&(this._closeButton=s.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClickClose))},n.prototype._update=function(){if(this._map&&this._lngLat&&this._content){this._container||(this._container=s.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=s.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this._map.transform.renderWorldCopies&&(this._lngLat=dr(this._lngLat,this._pos,this._map.transform));var e=this._pos=this._map.project(this._lngLat),n=this.options.anchor,r=function e(n){if(n){if("number"==typeof n){var r=Math.round(Math.sqrt(.5*Math.pow(n,2)));return{center:new t.default$1(0,0),top:new t.default$1(0,n),"top-left":new t.default$1(r,r),"top-right":new t.default$1(-r,r),bottom:new t.default$1(0,-n),"bottom-left":new t.default$1(r,-r),"bottom-right":new t.default$1(-r,-r),left:new t.default$1(n,0),right:new t.default$1(-n,0)}}if(n instanceof t.default$1||Array.isArray(n)){var i=t.default$1.convert(n);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.default$1.convert(n.center||[0,0]),top:t.default$1.convert(n.top||[0,0]),"top-left":t.default$1.convert(n["top-left"]||[0,0]),"top-right":t.default$1.convert(n["top-right"]||[0,0]),bottom:t.default$1.convert(n.bottom||[0,0]),"bottom-left":t.default$1.convert(n["bottom-left"]||[0,0]),"bottom-right":t.default$1.convert(n["bottom-right"]||[0,0]),left:t.default$1.convert(n.left||[0,0]),right:t.default$1.convert(n.right||[0,0])}}return e(new t.default$1(0,0))}(this.options.offset);if(!n){var i,a=this._container.offsetWidth,o=this._container.offsetHeight;i=e.y+r.bottom.ythis._map.transform.height-o?["bottom"]:[],e.xthis._map.transform.width-a/2&&i.push("right"),n=0===i.length?"bottom":i.join("-")}var l=e.add(r[n]).round();s.setTransform(this._container,mr[n]+" translate("+l.x+"px,"+l.y+"px)"),gr(this._container,n,"popup")}},n.prototype._onClickClose=function(){this.remove()},n}(t.Evented),Cr={version:"0.45.0",supported:e,workerCount:Math.max(Math.floor(a.hardwareConcurrency/2),1),setRTLTextPlugin:t.setRTLTextPlugin,Map:cr,NavigationControl:pr,GeolocateControl:xr,AttributionControl:ir,ScaleControl:wr,FullscreenControl:Ar,Popup:Sr,Marker:yr,Style:Je,LngLat:Z,LngLatBounds:G,Point:t.default$1,Evented:t.Evented,config:g,get accessToken(){return g.ACCESS_TOKEN},set accessToken(t){g.ACCESS_TOKEN=t},workerUrl:""};return Cr}),r})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],16:[function(t,e,n){var r={left:0,top:0};e.exports=function(t,e,n){e=e||t.currentTarget||t.srcElement,Array.isArray(n)||(n=[0,0]);var i=t.clientX||0,a=t.clientY||0,o=(s=e,s===window||s===document||s===document.body?r:s.getBoundingClientRect());var s;return n[0]=i-o.left,n[1]=a-o.top,n}},{}],17:[function(t,e,n){var r,i=t("./lib/build-log"),a=t("./lib/epsilon"),o=t("./lib/intersecter"),s=t("./lib/segment-chainer"),l=t("./lib/segment-selector"),u=t("./lib/geojson"),c=!1,f=a();function h(t,e,n){var i=r.segments(t),a=r.segments(e),o=n(r.combine(i,a));return r.polygon(o)}r={buildLog:function(t){return!0===t?c=i():!1===t&&(c=!1),!1!==c&&c.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,c);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,c).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:l.union(t.combined,c),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:l.intersect(t.combined,c),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:l.difference(t.combined,c),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:l.differenceRev(t.combined,c),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:l.xor(t.combined,c),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:s(t.segments,f,c),inverted:t.inverted}},polygonFromGeoJSON:function(t){return u.toPolygon(r,t)},polygonToGeoJSON:function(t){return u.fromPolygon(r,f,t)},union:function(t,e){return h(t,e,r.selectUnion)},intersect:function(t,e){return h(t,e,r.selectIntersect)},difference:function(t,e){return h(t,e,r.selectDifference)},differenceRev:function(t,e){return h(t,e,r.selectDifferenceRev)},xor:function(t,e){return h(t,e,r.selectXor)}},"object"==typeof window&&(window.PolyBool=r),e.exports=r},{"./lib/build-log":18,"./lib/epsilon":19,"./lib/geojson":20,"./lib/intersecter":21,"./lib/segment-chainer":23,"./lib/segment-selector":24}],18:[function(t,e,n){e.exports=function(){var t,e=0,n=!1;function r(e,n){return t.list.push({type:e,data:n?JSON.parse(JSON.stringify(n)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return r("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return r("div_seg",{seg:t,pt:e}),r("chop",{seg:t,pt:e})},statusRemove:function(t){return r("pop_seg",{seg:t})},segmentUpdate:function(t){return r("seg_update",{seg:t})},segmentNew:function(t,e){return r("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return r("rem_seg",{seg:t})},tempStatus:function(t,e,n){return r("temp_status",{seg:t,above:e,below:n})},rewind:function(t){return r("rewind",{seg:t})},status:function(t,e,n){return r("status",{seg:t,above:e,below:n})},vert:function(e){return e===n?t:(n=e,r("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),r("log",{txt:t})},reset:function(){return r("reset")},selected:function(t){return r("selected",{segs:t})},chainStart:function(t){return r("chain_start",{seg:t})},chainRemoveHead:function(t,e){return r("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return r("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return r("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return r("chain_match",{index:t})},chainClose:function(t){return r("chain_close",{index:t})},chainAddHead:function(t,e){return r("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return r("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return r("chain_con",{index1:t,index2:e})},chainReverse:function(t){return r("chain_rev",{index:t})},chainJoin:function(t,e){return r("chain_join",{index1:t,index2:e})},done:function(){return r("done")}}}},{}],19:[function(t,e,n){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,n,r){var i=n[0],a=n[1],o=r[0],s=r[1],l=e[0];return(o-i)*(e[1]-a)-(s-a)*(l-i)>=-t},pointBetween:function(e,n,r){var i=e[1]-n[1],a=r[0]-n[0],o=e[0]-n[0],s=r[1]-n[1],l=o*a+i*s;return!(l-t)},pointsSameX:function(e,n){return Math.abs(e[0]-n[0])t!=o-i>t&&(a-u)*(i-c)/(o-c)+u-r>t&&(s=!s),a=u,o=c}return s}};return e}},{}],20:[function(t,e,n){var r={toPolygon:function(t,e){function n(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function n(e){var n=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[n]})}for(var r=n(e[0]),i=1;i0})}function c(t,r){var i=t.seg,a=r.seg,o=i.start,s=i.end,u=a.start,c=a.end;n&&n.checkIntersection(i,a);var f=e.linesIntersect(o,s,u,c);if(!1===f){if(!e.pointsCollinear(o,s,u))return!1;if(e.pointsSame(o,c)||e.pointsSame(s,u))return!1;var h=e.pointsSame(o,u),p=e.pointsSame(s,c);if(h&&p)return r;var d=!h&&e.pointBetween(o,u,c),m=!p&&e.pointBetween(s,u,c);if(h)return m?l(r,s):l(t,c),r;d&&(p||(m?l(r,s):l(t,c)),l(r,o))}else 0===f.alongA&&(-1===f.alongB?l(t,u):0===f.alongB?l(t,f.pt):1===f.alongB&&l(t,c)),0===f.alongB&&(-1===f.alongA?l(r,o):0===f.alongA?l(r,f.pt):1===f.alongA&&l(r,s));return!1}for(var f=[];!a.isEmpty();){var h=a.getHead();if(n&&n.vert(h.pt[0]),h.isStart){n&&n.segmentNew(h.seg,h.primary);var p=u(h),d=p.before?p.before.ev:null,m=p.after?p.after.ev:null;function g(){if(d){var t=c(h,d);if(t)return t}return!!m&&c(h,m)}n&&n.tempStatus(h.seg,!!d&&d.seg,!!m&&m.seg);var y,v,_=g();if(_)t?(v=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below)&&(_.seg.myFill.above=!_.seg.myFill.above):_.seg.otherFill=h.seg.myFill,n&&n.segmentUpdate(_.seg),h.other.remove(),h.remove();if(a.getHead()!==h){n&&n.rewind(h.seg);continue}t?(v=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below,h.seg.myFill.below=m?m.seg.myFill.above:i,h.seg.myFill.above=v?!h.seg.myFill.below:h.seg.myFill.below):null===h.seg.otherFill&&(y=m?h.primary===m.primary?m.seg.otherFill.above:m.seg.myFill.above:h.primary?o:i,h.seg.otherFill={above:y,below:y}),n&&n.status(h.seg,!!d&&d.seg,!!m&&m.seg),h.other.status=p.insert(r.node({ev:h}))}else{var x=h.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(s.exists(x.prev)&&s.exists(x.next)&&c(x.prev.ev,x.next.ev),n&&n.statusRemove(x.ev.seg),x.remove(),!h.primary){var b=h.seg.myFill;h.seg.myFill=h.seg.otherFill,h.seg.otherFill=b}f.push(h.seg)}a.getHead().remove()}return n&&n.done(),f}return t?{addRegion:function(t){for(var r,i,a,o=t[t.length-1],l=0;l1)for(var n=1;n1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}if(t=E(t,360),e=E(e,100),n=E(n,100),0===e)r=i=a=n;else{var s=n<.5?n*(1+e):n+e-n*e,l=2*n-s;r=o(l,s,t+1/3),i=o(l,s,t),a=o(l,s,t-1/3)}return{r:255*r,g:255*i,b:255*a}}(e.h,l,c),f=!0,h="hsl"),e.hasOwnProperty("a")&&(a=e.a));var p,d,m;return a=z(a),{ok:f,format:e.format||h,r:o(255,s(i.r,0)),g:o(255,s(i.g,0)),b:o(255,s(i.b,0)),a:a}}(e);this._originalInput=e,this._r=c.r,this._g=c.g,this._b=c.b,this._a=c.a,this._roundA=a(100*this._a)/100,this._format=l.format||c.format,this._gradientType=l.gradientType,this._r<1&&(this._r=a(this._r)),this._g<1&&(this._g=a(this._g)),this._b<1&&(this._b=a(this._b)),this._ok=c.ok,this._tc_id=i++}function c(t,e,n){t=E(t,255),e=E(e,255),n=E(n,255);var r,i,a=s(t,e,n),l=o(t,e,n),u=(a+l)/2;if(a==l)r=i=0;else{var c=a-l;switch(i=u>.5?c/(2-a-l):c/(a+l),a){case t:r=(e-n)/c+(e>1)+720)%360;--e;)r.h=(r.h+i)%360,a.push(u(r));return a}function M(t,e){e=e||6;for(var n=u(t).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/e;e--;)o.push(u({h:r,s:i,v:a})),a=(a+s)%1;return o}u.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,n,r,i=this.toRgb();return e=i.r/255,n=i.g/255,r=i.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))},setAlpha:function(t){return this._a=z(t),this._roundA=a(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=a(360*t.h),n=a(100*t.s),r=a(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=c(this._r,this._g,this._b),e=a(360*t.h),n=a(100*t.s),r=a(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return h(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,n,r,i){var o=[P(a(t).toString(16)),P(a(e).toString(16)),P(a(n).toString(16)),P(O(r))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:a(this._r),g:a(this._g),b:a(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+a(this._r)+", "+a(this._g)+", "+a(this._b)+")":"rgba("+a(this._r)+", "+a(this._g)+", "+a(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:a(100*E(this._r,255))+"%",g:a(100*E(this._g,255))+"%",b:a(100*E(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+a(100*E(this._r,255))+"%, "+a(100*E(this._g,255))+"%, "+a(100*E(this._b,255))+"%)":"rgba("+a(100*E(this._r,255))+"%, "+a(100*E(this._g,255))+"%, "+a(100*E(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(C[h(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),n=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var i=u(t);n="#"+p(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0;return e||!r||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return u(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(_,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(m,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(A,arguments)},complement:function(){return this._applyCombination(b,arguments)},monochromatic:function(){return this._applyCombination(M,arguments)},splitcomplement:function(){return this._applyCombination(T,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},u.fromRatio=function(t,e){if("object"==typeof t){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]="a"===r?t[r]:D(t[r]));t=n}return u(t,e)},u.equals=function(t,e){return!(!t||!e)&&u(t).toRgbString()==u(e).toRgbString()},u.random=function(){return u.fromRatio({r:l(),g:l(),b:l()})},u.mix=function(t,e,n){n=0===n?0:n||50;var r=u(t).toRgb(),i=u(e).toRgb(),a=n/100;return u({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},u.readability=function(e,n){var r=u(e),i=u(n);return(t.max(r.getLuminance(),i.getLuminance())+.05)/(t.min(r.getLuminance(),i.getLuminance())+.05)},u.isReadable=function(t,e,n){var r,i,a=u.readability(t,e);switch(i=!1,(r=function(t){var e,n;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==n&&"large"!==n&&(n="small");return{level:e,size:n}}(n)).level+r.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},u.mostReadable=function(t,e,n){var r,i,a,o,s=null,l=0;i=(n=n||{}).includeFallbackColors,a=n.level,o=n.size;for(var c=0;cl&&(l=r,s=u(e[c]));return u.isReadable(t,s,{level:a,size:o})||!i?s:(n.includeFallbackColors=!1,u.mostReadable(t,["#fff","#000"],n))};var S=u.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},C=u.hexNames=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}(S);function z(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function E(e,n){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(n,s(0,parseFloat(e))),r&&(e=parseInt(e*n,10)/100),t.abs(e-n)<1e-6?1:e%n/parseFloat(n)}function L(t){return o(1,s(0,t))}function I(t){return parseInt(t,16)}function P(t){return 1==t.length?"0"+t:""+t}function D(t){return t<=1&&(t=100*t+"%"),t}function O(e){return t.round(255*parseFloat(e)).toString(16)}function R(t){return I(t)/255}var F,B,N,j=(B="[\\s|\\(]+("+(F="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",N="[\\s|\\(]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",{CSS_UNIT:new RegExp(F),rgb:new RegExp("rgb"+B),rgba:new RegExp("rgba"+N),hsl:new RegExp("hsl"+B),hsla:new RegExp("hsla"+N),hsv:new RegExp("hsv"+B),hsva:new RegExp("hsva"+N),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function V(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=u:window.tinycolor=u}(Math)},{}],27:[function(t,e,n){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],28:[function(t,e,n){"use strict";var r=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:i({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:r.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:r.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:i({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":196,"../../plots/cartesian/constants":212,"../../plots/font_attributes":233,"./arrow_paths":27}],29:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("./draw").draw;function o(t){var e=t._fullLayout;r.filterVisible(e.annotations).forEach(function(e){var n=i.getFromId(t,e.xref),r=i.getFromId(t,e.yref);e._extremes={},n&&s(e,n),r&&s(e,r)})}function s(t,e){var n,r=e._id,a=r.charAt(0),o=t[a],s=t["a"+a],l=t[a+"ref"],u=t["a"+a+"ref"],c=t["_"+a+"padplus"],f=t["_"+a+"padminus"],h={x:1,y:-1}[a]*t[a+"shift"],p=3*t.arrowsize*t.arrowwidth||0,d=p+h,m=p-h,g=3*t.startarrowsize*t.arrowwidth||0,y=g+h,v=g-h;if(u===l){var _=i.findExtremes(e,[e.r2c(o)],{ppadplus:d,ppadminus:m}),x=i.findExtremes(e,[e.r2c(s)],{ppadplus:Math.max(c,y),ppadminus:Math.max(f,v)});n={min:[_.min[0],x.min[0]],max:[_.max[0],x.max[0]]}}else y=s?y+s:y,v=s?v-s:v,n=i.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(c,d,y),ppadminus:Math.max(f,m,v)});t._extremes[r]=n}e.exports=function(t){var e=t._fullLayout;if(r.filterVisible(e.annotations).length&&t._fullData.length)return r.syncOrAsync([a,o],t)}},{"../../lib":162,"../../plots/cartesian/axes":206,"./draw":34}],30:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../registry"),a=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var n,r,i,a,o,l,u,c=t._fullLayout.annotations,f=[],h=[],p=[],d=(e||[]).length;for(n=0;n0||n.explicitOff.length>0},onClick:function(t,e){var n,s,l=o(t,e),u=l.on,c=l.off.concat(l.explicitOff),f={},h=t._fullLayout.annotations;if(!u.length&&!c.length)return;for(n=0;n2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var U=!1,H=["x","y"],Z=0;Z1)&&(Q===K?((lt=tt.r2fraction(e["a"+J]))<0||lt>1)&&(U=!0):U=!0),G=tt._offset+tt.r2p(e[J]),X=.5}else"x"===J?(W=e[J],G=x.l+x.w*W):(W=1-e[J],G=x.t+x.h*W),X=e.showarrow?.5:W;if(e.showarrow){st.head=G;var ut=e["a"+J];Y=nt*q(.5,e.xanchor)-rt*q(.5,e.yanchor),Q===K?(st.tail=tt._offset+tt.r2p(ut),$=Y):(st.tail=G+ut,$=Y+ut),st.text=st.tail+Y;var ct=_["x"===J?"width":"height"];if("paper"===K&&(st.head=o.constrain(st.head,1,ct-1)),"pixel"===Q){var ft=-Math.max(st.tail-3,st.text),ht=Math.min(st.tail+3,st.text)-ct;ft>0?(st.tail+=ft,st.text+=ft):ht>0&&(st.tail-=ht,st.text-=ht)}st.tail+=ot,st.head+=ot}else $=Y=it*q(X,at),st.text=G+Y;st.text+=ot,Y+=ot,$+=ot,e["_"+J+"padplus"]=it/2+$,e["_"+J+"padminus"]=it/2-$,e["_"+J+"size"]=it,e["_"+J+"shift"]=Y}if(t._dragging||!U){var pt=0,dt=0;if("left"!==e.align&&(pt=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(dt=(I-v)*("middle"===e.valign?.5:1)),c)r.select("svg").attr({x:R+pt-1,y:R+dt}).call(u.setClipUrl,B?M:null);else{var mt=R+dt-d.top,gt=R+pt-d.left;V.call(f.positionText,gt,mt).call(u.setClipUrl,B?M:null)}N.select("rect").call(u.setRect,R,R,w,I),F.call(u.setRect,D/2,D/2,O-D,j-D),P.call(u.setTranslate,Math.round(S.x.text-O/2),Math.round(S.y.text-j/2)),E.attr({transform:"rotate("+C+","+S.x.text+","+S.y.text+")"});var yt,vt=function(n,r){z.selectAll(".annotation-arrow-g").remove();var c=S.x.head,f=S.y.head,h=S.x.tail+n,d=S.y.tail+r,y=S.x.text+n,v=S.y.text+r,_=o.rotationXYMatrix(C,y,v),w=o.apply2DTransform(_),M=o.apply2DTransform2(_),L=+F.attr("width"),I=+F.attr("height"),D=y-.5*L,O=D+L,R=v-.5*I,B=R+I,N=[[D,R,D,B],[D,B,O,B],[O,B,O,R],[O,R,D,R]].map(M);if(!N.reduce(function(t,e){return t^!!o.segmentsIntersect(c,f,c+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){N.forEach(function(t){var e=o.segmentsIntersect(h,d,c,f,t[0],t[1],t[2],t[3]);e&&(h=e.x,d=e.y)});var j=e.arrowwidth,V=e.arrowcolor,q=e.arrowside,U=z.append("g").style({opacity:l.opacity(V)}).classed("annotation-arrow-g",!0),H=U.append("path").attr("d","M"+h+","+d+"L"+c+","+f).style("stroke-width",j+"px").call(l.stroke,l.rgb(V));if(m(H,q,e),b.annotationPosition&&H.node().parentNode&&!a){var Z=c,G=f;if(e.standoff){var $=Math.sqrt(Math.pow(c-h,2)+Math.pow(f-d,2));Z+=e.standoff*(h-c)/$,G+=e.standoff*(d-f)/$}var W,X,Y=U.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(h-Z)+","+(d-G),transform:"translate("+Z+","+G+")"}).style("stroke-width",j+6+"px").call(l.stroke,"rgba(0,0,0,0)").call(l.fill,"rgba(0,0,0,0)");p.init({element:Y.node(),gd:t,prepFn:function(){var t=u.getTranslate(P);W=t.x,X=t.y,s&&s.autorange&&k(s._name+".autorange",!0),g&&g.autorange&&k(g._name+".autorange",!0)},moveFn:function(t,n){var r=w(W,X),i=r[0]+t,a=r[1]+n;P.call(u.setTranslate,i,a),T("x",s?s.p2r(s.r2p(e.x)+t):e.x+t/x.w),T("y",g?g.p2r(g.r2p(e.y)+n):e.y-n/x.h),e.axref===e.xref&&T("ax",s.p2r(s.r2p(e.ax)+t)),e.ayref===e.yref&&T("ay",g.p2r(g.r2p(e.ay)+n)),U.attr("transform","translate("+t+","+n+")"),E.attr({transform:"rotate("+C+","+i+","+a+")"})},doneFn:function(){i.call("relayout",t,A());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&vt(0,0),L)p.init({element:P.node(),gd:t,prepFn:function(){yt=E.attr("transform")},moveFn:function(t,n){var r="pointer";if(e.showarrow)e.axref===e.xref?T("ax",s.p2r(s.r2p(e.ax)+t)):T("ax",e.ax+t),e.ayref===e.yref?T("ay",g.p2r(g.r2p(e.ay)+n)):T("ay",e.ay+n),vt(t,n);else{if(a)return;var i,o;if(s)i=s.p2r(s.r2p(e.x)+t);else{var l=e._xsize/x.w,u=e.x+(e._xshift-e.xshift)/x.w-l/2;i=p.align(u+t/x.w,l,0,1,e.xanchor)}if(g)o=g.p2r(g.r2p(e.y)+n);else{var c=e._ysize/x.h,f=e.y-(e._yshift+e.yshift)/x.h-c/2;o=p.align(f-n/x.h,c,0,1,e.yanchor)}T("x",i),T("y",o),s&&g||(r=p.getCursor(s?.5:i,g?.5:o,e.xanchor,e.yanchor))}E.attr({transform:"translate("+t+","+n+")"+yt}),h(P,r)},doneFn:function(){h(P),i.call("relayout",t,A());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else P.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var n=0;n=0,g=e.indexOf("end")>=0,y=f.backoff*p+n.standoff,v=h.backoff*d+n.startstandoff;if("line"===c.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},s={x:+t.attr("x2"),y:+t.attr("y2")};var _=o.x-s.x,x=o.y-s.y;if(u=(l=Math.atan2(x,_))+Math.PI,y&&v&&y+v>Math.sqrt(_*_+x*x))return void L();if(y){if(y*y>_*_+x*x)return void L();var b=y*Math.cos(l),w=y*Math.sin(l);s.x+=b,s.y+=w,t.attr({x2:s.x,y2:s.y})}if(v){if(v*v>_*_+x*x)return void L();var k=v*Math.cos(l),T=v*Math.sin(l);o.x-=k,o.y-=T,t.attr({x1:o.x,y1:o.y})}}else if("path"===c.nodeName){var A=c.getTotalLength(),M="";if(A1){u=!0;break}}u?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l._pdata=i(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*n[0],e.yaxis.r2l(l.y)*n[1],e.zaxis.r2l(l.z)*n[2]]),r(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":236,"../annotations/draw":34}],41:[function(t,e,n){"use strict";var r=t("../../registry"),i=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var n=r.subplotsRegistry.gl3d;if(!n)return;for(var a=n.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)r[o]>1&&(r[o]=1);else if(r[o]>=1)return t}var s=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return a?"rgba("+s+", "+r[3]+")":"rgb("+s+")"}a.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},a.rgb=function(t){return a.tinyRGB(r(t))},a.opacity=function(t){return t?r(t).getAlpha():0},a.addOpacity=function(t,e){var n=r(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},a.combine=function(t,e){var n=r(t).toRgb();if(1===n.a)return r(t).toRgbString();var i=r(e||l).toRgb(),a=1===i.a?i:{r:255*(1-i.a)+i.r*i.a,g:255*(1-i.a)+i.g*i.a,b:255*(1-i.a)+i.b*i.a},o={r:a.r*(1-n.a)+n.r*n.a,g:a.g*(1-n.a)+n.g*n.a,b:a.b*(1-n.a)+n.b*n.a};return r(o).toRgbString()},a.contrast=function(t,e,n){var i=r(t);return 1!==i.getAlpha()&&(i=r(a.combine(t,l))),(i.isDark()?e?i.lighten(e):l:n?i.darken(n):s).toString()},a.stroke=function(t,e){var n=r(e);t.style({stroke:a.tinyRGB(n),"stroke-opacity":n.getAlpha()})},a.fill=function(t,e){var n=r(e);t.style({fill:a.tinyRGB(n),"fill-opacity":n.getAlpha()})},a.clean=function(t){if(t&&"object"==typeof t){var e,n,r,i,o=Object.keys(t);for(e=0;e0?S>=D:S<=D));C++)S>R&&S0?S>=D:S<=D));C++)S>z[0]&&S1){var at=Math.pow(10,Math.floor(Math.log(it)/Math.LN10));nt*=at*u.roundUp(it/at,[2,5,10]),(Math.abs(n.levels.start)/n.levels.size+1e-6)%1<2e-6&&(tt.tick0=0)}tt.dtick=nt}tt.domain=[Y+$,Y+H-$],tt.setScale();var ot=u.ensureSingle(g._infolayer,"g",e,function(t){t.classed(T.colorbar,!0).each(function(){var t=r.select(this);t.append("rect").classed(T.cbbg,!0),t.append("g").classed(T.cbfills,!0),t.append("g").classed(T.cblines,!0),t.append("g").classed(T.cbaxis,!0).classed(T.crisp,!0),t.append("g").classed(T.cbtitleunshift,!0).append("g").classed(T.cbtitle,!0),t.append("rect").classed(T.cboutline,!0),t.select(".cbtitle").datum(0)})});ot.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var st=ot.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")");tt._axislayer=ot.select(".cbaxis");var lt=0;if(-1!==["top","bottom"].indexOf(n.titleside)){var ut,ct=k.l+(n.x+Z)*k.w,ft=tt.titlefont.size;ut="top"===n.titleside?(1-(Y+H-$))*k.h+k.t+3+.75*ft:(1-(Y+$))*k.h+k.t-3-.25*ft,yt(tt._id+"title",{attributes:{x:ct,y:ut,"text-anchor":"start"}})}var ht,pt,dt,mt=u.syncOrAsync([a.previousPromises,function(){if(-1!==["top","bottom"].indexOf(n.titleside)){var a=ot.select(".cbtitle"),o=a.select("text"),l=[-n.outlinewidth/2,n.outlinewidth/2],c=a.select(".h"+tt._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),c?(lt=h.bBox(c).height)>f&&(l[1]-=(lt-f)/2):o.node()&&!o.classed(T.jsPlaceholder)&&(lt=h.bBox(o.node()).height),lt){if(lt+=5,"top"===n.titleside)tt.domain[1]-=lt/k.h,l[1]*=-1;else{tt.domain[0]+=lt/k.h;var p=m.lineCount(o);l[1]+=(1-p)*f}a.attr("transform","translate("+l+")"),tt.setScale()}}ot.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-tt.domain[1]))+")"),tt._axislayer.attr("transform","translate(0,"+Math.round(-k.t)+")");var d=ot.select(".cbfills").selectAll("rect.cbfill").data(L);d.enter().append("rect").classed(T.cbfill,!0).style("stroke","none"),d.exit().remove();var v=z.map(tt.c2p).map(Math.round).sort(function(t,e){return t-e});d.each(function(a,o){var s=[0===o?z[0]:(L[o]+L[o-1])/2,o===L.length-1?z[1]:(L[o]+L[o+1])/2].map(tt.c2p).map(Math.round);s[1]=u.constrain(s[1]+(s[1]>s[0])?1:-1,v[0],v[1]);var l=r.select(this).attr({x:W,width:Math.max(V,2),y:r.min(s),height:Math.max(r.max(s)-r.min(s),2)});if(n.fillgradient)h.gradient(l,t,e,"vertical",n.fillgradient,"fill");else{var c=P(a).replace("e-","");l.attr("fill",i(c).toHexString())}});var _=ot.select(".cblines").selectAll("path.cbline").data(n.line.color&&n.line.width?E:[]);return _.enter().append("path").classed(T.cbline,!0),_.exit().remove(),_.each(function(t){r.select(this).attr("d","M"+W+","+(Math.round(tt.c2p(t))+n.line.width/2%1)+"h"+V).call(h.lineGroupStyle,n.line.width,I(t),n.line.dash)}),tt._axislayer.selectAll("g."+tt._id+"tick,path").remove(),tt._pos=W+V+(n.outlinewidth||0)/2-("outside"===n.ticks?1:0),tt.side="right",u.syncOrAsync([function(){return s.doTicksSingle(t,tt,!0)},function(){if(-1===["top","bottom"].indexOf(n.titleside)){var e=tt.titlefont.size,i=tt._offset+tt._length/2,a=k.l+(tt.position||0)*k.w+("right"===tt.side?10+e*(tt.showticklabels?1:.5):-10-e*(tt.showticklabels?.5:0));yt("h"+tt._id+"title",{avoid:{selection:r.select(t).selectAll("g."+tt._id+"tick"),side:n.titleside,offsetLeft:k.l,offsetTop:0,maxShift:g.width},attributes:{x:a,y:i,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},a.previousPromises,function(){var r=V+n.outlinewidth/2+h.bBox(tt._axislayer.node()).width;if((B=st.select("text")).node()&&!B.classed(T.jsPlaceholder)){var i,o=st.select(".h"+tt._id+"title-math-group").node();i=o&&-1!==["top","bottom"].indexOf(n.titleside)?h.bBox(o).width:h.bBox(st.node()).right-W-k.l,r=Math.max(r,i)}var s=2*n.xpad+r+n.borderwidth+n.outlinewidth/2,l=J-K;ot.select(".cbbg").attr({x:W-n.xpad-(n.borderwidth+n.outlinewidth)/2,y:K-G,width:Math.max(s,2),height:Math.max(l+2*G,2)}).call(p.fill,n.bgcolor).call(p.stroke,n.bordercolor).style({"stroke-width":n.borderwidth}),ot.selectAll(".cboutline").attr({x:W,y:K+n.ypad+("top"===n.titleside?lt:0),width:Math.max(V,2),height:Math.max(l-2*n.ypad-lt,2)}).call(p.stroke,n.outlinecolor).style({fill:"None","stroke-width":n.outlinewidth});var u=({center:.5,right:1}[n.xanchor]||0)*s;ot.attr("transform","translate("+(k.l-u)+","+k.t+")");var c={},f=v[n.yanchor],d=_[n.yanchor];"pixels"===n.lenmode?(c.y=n.y,c.t=l*f,c.b=l*d):(c.t=c.b=0,c.yt=n.y+n.len*f,c.yb=n.y-n.len*d);var m=v[n.xanchor],g=_[n.xanchor];if("pixels"===n.thicknessmode)c.x=n.x,c.l=s*m,c.r=s*g;else{var y=s-V;c.l=y*m,c.r=y*g,c.xl=n.x-n.thickness*m,c.xr=n.x+n.thickness*g}a.autoMargin(t,e,c)}],t);if(mt&&mt.then&&(t._promises||[]).push(mt),t._context.edits.colorbarPosition)l.init({element:ot.node(),gd:t,prepFn:function(){ht=ot.attr("transform"),f(ot)},moveFn:function(t,e){ot.attr("transform",ht+" translate("+t+","+e+")"),pt=l.align(X+t/k.w,q,0,1,n.xanchor),dt=l.align(Y-e/k.h,H,0,1,n.yanchor);var r=l.getCursor(pt,dt,n.xanchor,n.yanchor);f(ot,r)},doneFn:function(){f(ot),void 0!==pt&&void 0!==dt&&o.call("restyle",t,{"colorbar.x":pt,"colorbar.y":dt},M().index)}});return mt}function gt(t,e){return u.coerce(Q,tt,w,t,e)}function yt(e,n){var r=M(),i="colorbar.title",a=r._module.colorbar.container;a&&(i=a+"."+i);var o={propContainer:tt,propName:i,traceIndex:r.index,placeholder:g._dfltTitle.colorbar,containerGroup:ot.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;ot.selectAll("."+s+",."+s+"-math-group").remove(),d.draw(t,e,c(o,n||{}))}g._infolayer.selectAll("g."+e).remove()}function M(){var n,r,i=e.substr(2);for(n=0;n=0?i.Reds:i.Blues,s.reversescale?a(v):v),l.autocolorscale||f("autocolorscale",!1))}},{"../../lib":162,"./flip_scale":55,"./scales":62}],52:[function(t,e,n){"use strict";var r=t("./scales");e.exports=r.RdBu},{"./scales":62}],53:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,n,u,c){var f,h=c.prefix,p=c.cLetter,d=h.slice(0,h.length-1),m=h?i.nestedProperty(t,d).get()||{}:t,g=h?i.nestedProperty(e,d).get()||{}:e,y=m[p+"min"],v=m[p+"max"],_=m.colorscale;u(h+p+"auto",!(r(y)&&r(v)&&y=0;i--,a++)e=t[i],r[a]=[1-e[0],e[1]];return r}},{}],56:[function(t,e,n){"use strict";var r=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){if(e||(e=i),!t)return e;function n(){try{t=r[t]||JSON.parse(t)}catch(n){t=e}}return"string"==typeof t&&(n(),"string"==typeof t&&n()),a(t)?t:e}},{"./default_scale":52,"./is_valid_scale_array":60,"./scales":62}],57:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var n=e?i.nestedProperty(t,e).get()||{}:t,o=n.color,s=!1;if(i.isArrayOrTypedArray(o))for(var l=0;l4/3-s?o:s}},{}],64:[function(t,e,n){"use strict";var r=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,a){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:r.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":162}],65:[function(t,e,n){"use strict";var r=t("mouse-event-offset"),i=t("has-hover"),a=t("has-passive-events"),o=t("../../registry"),s=t("../../lib"),l=t("../../plots/cartesian/constants"),u=t("../../constants/interactions"),c=e.exports={};c.align=t("./align"),c.getCursor=t("./cursor");var f=t("./unhover");function h(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return r(t.changedTouches?t.changedTouches[0]:t,document.body)}c.unhover=f.wrapped,c.unhoverRaw=f.raw,c.init=function(t){var e,n,r,f,d,m,g,y,v=t.gd,_=1,x=u.DBLCLICKDELAY,b=t.element;v._mouseDownTime||(v._mouseDownTime=0),b.style.pointerEvents="all",b.onmousedown=k,a?(b._ontouchstart&&b.removeEventListener("touchstart",b._ontouchstart),b._ontouchstart=k,b.addEventListener("touchstart",k,{passive:!1})):b.ontouchstart=k;var w=t.clampFn||function(t,e,n){return Math.abs(t)x&&(_=Math.max(_-1,1)),v._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(_,m),!y){var n;try{n=new MouseEvent("click",e)}catch(t){var r=p(e);(n=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,r[0],r[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}g.dispatchEvent(n)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(v),v._dragged=!1}else v._dragged=!1}},c.coverSlip=h},{"../../constants/interactions":142,"../../lib":162,"../../plots/cartesian/constants":212,"../../registry":254,"./align":63,"./cursor":64,"./unhover":66,"has-hover":11,"has-passive-events":12,"mouse-event-offset":16}],66:[function(t,e,n){"use strict";var r=t("../../lib/events"),i=t("../../lib/throttle"),a=t("../../lib/get_graph_div"),o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,n){(t=a(t))._fullLayout&&i.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,n)},s.raw=function(t,e){var n=t._fullLayout,i=t._hoverdata;e||(e={}),e.target&&!1===r.triggerHandler(t,"plotly_beforehover",e)||(n._hoverlayer.selectAll("g").remove(),n._hoverlayer.selectAll("line").remove(),n._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&i&&t.emit("plotly_unhover",{event:e,points:i}))}},{"../../lib/events":154,"../../lib/get_graph_div":160,"../../lib/throttle":184,"../fx/constants":80}],67:[function(t,e,n){"use strict";n.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],68:[function(t,e,n){"use strict";var r=t("d3"),i=t("fast-isnumeric"),a=t("tinycolor2"),o=t("../../registry"),s=t("../color"),l=t("../colorscale"),u=t("../../lib"),c=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,d=t("../../traces/scatter/subtypes"),m=t("../../traces/scatter/make_bubble_size_func"),g=e.exports={};g.font=function(t,e,n,r){u.isPlainObject(e)&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(s.fill,r)},g.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},g.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},g.setRect=function(t,e,n,r,i){t.call(g.setPosition,e,n).call(g.setSize,r,i)},g.translatePoint=function(t,e,n,r){var a=n.c2p(t.x),o=r.c2p(t.y);return!!(i(a)&&i(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",a).attr("y",o):e.attr("transform","translate("+a+","+o+")"),!0)},g.translatePoints=function(t,e,n){t.each(function(t){var i=r.select(this);g.translatePoint(t,i,e,n)})},g.hideOutsideRangePoint=function(t,e,n,r,i,a){e.attr("display",n.isPtWithinRange(t,i)&&r.isPtWithinRange(t,a)?null:"none")},g.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var n=e.xaxis,i=e.yaxis;t.each(function(e){var a=e[0].trace,o=a.xcalendar,s=a.ycalendar,l="bar"===a.type?".bartext":".point,.textpoint";t.selectAll(l).each(function(t){g.hideOutsideRangePoint(t,r.select(this),n,i,o,s)})})}},g.crispRound=function(t,e,n){return e&&i(e)?t._context.staticPlot?e:e<1?1:Math.round(e):n||0},g.singleLineStyle=function(t,e,n,r,i){e.style("fill","none");var a=(((t||[])[0]||{}).trace||{}).line||{},o=n||a.width||0,l=i||a.dash||"";s.stroke(e,r||a.color),g.dashLine(e,l,o)},g.lineGroupStyle=function(t,e,n,i){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=i||a.dash||"";r.select(this).call(s.stroke,n||a.color).call(g.dashLine,l,o)})},g.dashLine=function(t,e,n){n=+n||0,e=g.dashStyle(e,n),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},g.dashStyle=function(t,e){e=+e||1;var n=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=n+"px,"+n+"px":"dash"===t?t=3*n+"px,"+3*n+"px":"longdash"===t?t=5*n+"px,"+5*n+"px":"dashdot"===t?t=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===t&&(t=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t},g.singleFillStyle=function(t){var e=(((r.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(s.fill,e)},g.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){r.select(this).call(s.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");g.symbolNames=[],g.symbolFuncs=[],g.symbolNeedLines={},g.symbolNoDot={},g.symbolNoFill={},g.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];g.symbolList=g.symbolList.concat([e.n,t,e.n+100,t+"-open"]),g.symbolNames[e.n]=t,g.symbolFuncs[e.n]=e.f,e.needLine&&(g.symbolNeedLines[e.n]=!0),e.noDot?g.symbolNoDot[e.n]=!0:g.symbolList=g.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(g.symbolNoFill[e.n]=!0)});var v=g.symbolNames.length,_="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function x(t,e){var n=t%100;return g.symbolFuncs[n](e)+(t>=200?_:"")}g.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=g.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))};var b={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=r.format("~.1f"),T={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:b},horizontalreversed:{node:"linearGradient",attrs:b,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};g.gradient=function(t,e,n,i,o,l){for(var c=o.length,f=T[i],h=new Array(c),p=0;p=100,e.attr("d",x(c,l))}var f,h,p,d=!1;if(t.so)p=o.outlierwidth,h=o.outliercolor,f=a.outliercolor;else{var m=(o||{}).width;p=(t.mlw+1||m+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,h="mlc"in t?t.mlcc=r.lineScale(t.mlc):u.isArrayOrTypedArray(o.color)?s.defaultLine:o.color,u.isArrayOrTypedArray(a.color)&&(f=s.defaultLine,d=!0),f="mc"in t?t.mcc=r.markerScale(t.mc):a.color||"rgba(0,0,0,0)",r.selectedColorFn&&(f=r.selectedColorFn(t))}if(t.om)e.call(s.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var y=a.gradient,v=t.mgt;if(v?d=!0:v=y&&y.type,Array.isArray(v)&&(v=v[0],T[v]||(v=0)),v&&"none"!==v){var _=t.mgc;_?d=!0:_=y.color;var b=n.uid;d&&(b+="-"+t.i),g.gradient(e,i,b,v,[[0,_],[1,f]],"fill")}else s.fill(e,f);p&&s.stroke(e,h)}},g.makePointStyleFns=function(t){var e={},n=t.marker;return e.markerScale=g.tryColorscale(n,""),e.lineScale=g.tryColorscale(n,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=d.isBubble(t)?m(t):function(){return(n.size||6)/2}),t.selectedpoints&&u.extendFlat(e,g.makeSelectedPointStyleFns(t)),e},g.makeSelectedPointStyleFns=function(t){var e={},n=t.selected||{},r=t.unselected||{},i=t.marker||{},a=n.marker||{},s=r.marker||{},l=i.opacity,c=a.opacity,f=s.opacity,h=void 0!==c,d=void 0!==f;(u.isArrayOrTypedArray(l)||h||d)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?i.opacity:t.mo;return t.selected?h?c:e:d?f:p*e});var m=i.color,g=a.color,y=s.color;(g||y)&&(e.selectedColorFn=function(t){var e=t.mcc||m;return t.selected?g||e:y||e});var v=i.size,_=a.size,x=s.size,b=void 0!==_,w=void 0!==x;return o.traceIs(t,"symbols")&&(b||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||v/2;return t.selected?b?_/2:e:w?x/2:e}),e},g.makeSelectedTextStyleFns=function(t){var e={},n=t.selected||{},r=t.unselected||{},i=t.textfont||{},a=n.textfont||{},o=r.textfont||{},l=i.color,u=a.color,c=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||l;return t.selected?u||e:c||(u?e:s.addOpacity(e,p))},e},g.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var n=g.makeSelectedPointStyleFns(e),i=e.marker||{},a=[];n.selectedOpacityFn&&a.push(function(t,e){t.style("opacity",n.selectedOpacityFn(e))}),n.selectedColorFn&&a.push(function(t,e){s.fill(t,n.selectedColorFn(e))}),n.selectedSizeFn&&a.push(function(t,e){var r=e.mx||i.symbol||0,a=n.selectedSizeFn(e);t.attr("d",x(g.symbolNumber(r),a)),e.mrc2=a}),a.length&&t.each(function(t){for(var e=r.select(this),n=0;n0?n:0}g.textPointStyle=function(t,e,n){if(t.size()){var i;if(e.selectedpoints){var a=g.makeSelectedTextStyleFns(e);i=a.selectedTextColorFn}t.each(function(t){var a=r.select(this),o=u.extractOption(t,e,"tx","text");if(o||0===o){var s=t.tp||e.textposition,l=S(t,e),f=i?i(t):t.tc||e.textfont.color;a.call(g.font,t.tf||e.textfont.family,l,f).text(o).call(c.convertToTspans,n).call(M,s,l,t.mrc)}else a.remove()})}},g.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var n=g.makeSelectedTextStyleFns(e);t.each(function(t){var i=r.select(this),a=n.selectedTextColorFn(t),o=t.tp||e.textposition,l=S(t,e);s.fill(i,a),M(i,o,l,t.mrc2||t.mrc)})}};var C=.5;function z(t,e,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=n[0]-e[0],l=n[1]-e[1],u=Math.pow(a*a+o*o,C/2),c=Math.pow(s*s+l*l,C/2),f=(c*c*a-u*u*s)*i,h=(c*c*o-u*u*l)*i,p=3*c*(u+c),d=3*u*(u+c);return[[r.round(e[0]+(p&&f/p),2),r.round(e[1]+(p&&h/p),2)],[r.round(e[0]-(d&&f/d),2),r.round(e[1]-(d&&h/d),2)]]}g.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,r="M"+t[0],i=[];for(n=1;n=1e4&&(g.savedBBoxes={},I=0),n&&(g.savedBBoxes[n]=y),I++,u.extendFlat({},y)},g.setClipUrl=function(t,e){if(e){if(void 0===g.baseUrl){var n=r.select("base");n.size()&&n.attr("href")?g.baseUrl=window.location.href.split("#")[0]:g.baseUrl=""}t.attr("clip-path","url("+g.baseUrl+"#"+e+")")}else t.attr("clip-path",null)},g.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,n){return[e,n].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},g.setTranslate=function(t,e,n){var r=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[r]("transform")||"";return e=e||0,n=n||0,a=a.replace(/(\btranslate\(.*?\);?)/,"").trim(),a=(a+=" translate("+e+", "+n+")").trim(),t[i]("transform",a),a},g.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,n){return[e,n].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},g.setScale=function(t,e,n){var r=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[r]("transform")||"";return e=e||1,n=n||1,a=a.replace(/(\bscale\(.*?\);?)/,"").trim(),a=(a+=" scale("+e+", "+n+")").trim(),t[i]("transform",a),a};var D=/\s*sc.*/;g.setPointGroupScale=function(t,e,n){if(e=e||1,n=n||1,t){var r=1===e&&1===n?"":" scale("+e+","+n+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(D,"");t=(t+=r).trim(),this.setAttribute("transform",t)})}};var O=/translate\([^)]*\)\s*$/;g.setTextPointsScale=function(t,e,n){t&&t.each(function(){var t,i=r.select(this),a=i.select("text");if(a.node()){var o=parseFloat(a.attr("x")||0),s=parseFloat(a.attr("y")||0),l=(i.attr("transform")||"").match(O);t=1===e&&1===n?[]:["translate("+o+","+s+")","scale("+e+","+n+")","translate("+-o+","+-s+")"],l&&t.push(l),i.attr("transform",t.join(" "))}})}},{"../../constants/alignment":141,"../../constants/interactions":142,"../../constants/xmlns_namespaces":144,"../../lib":162,"../../lib/svg_text_utils":183,"../../registry":254,"../../traces/scatter/make_bubble_size_func":283,"../../traces/scatter/subtypes":290,"../color":43,"../colorscale":58,"./symbol_defs":69,d3:7,"fast-isnumeric":9,tinycolor2:26}],69:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+n+i+a+i+a+o+a+o+n+o+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+e+","+r.round(t/2,2)+"H"+e+"L0,-"+r.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+r.round(t/2,2)+"H"+e+"L0,"+r.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M"+r.round(t/2,2)+",-"+e+"V"+e+"L-"+r.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+r.round(t/2,2)+",-"+e+"V"+e+"L"+r.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),i=r.round(-t,2),a=r.round(-.309*t,2);return"M"+e+","+a+"L"+n+","+r.round(.809*t,2)+"H-"+n+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),i=r.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+n+"V"+n+"L0,"+e+"L-"+i+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),i=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+i+"H"+n+"L"+e+",0L"+n+",-"+i+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),i=r.round(.951*e,2),a=r.round(.363*e,2),o=r.round(.588*e,2),s=r.round(-e,2),l=r.round(-.309*e,2),u=r.round(.118*e,2),c=r.round(.809*e,2);return"M"+n+","+l+"H"+i+"L"+a+","+u+"L"+o+","+c+"L0,"+r.round(.382*e,2)+"L-"+o+","+c+"L-"+a+","+u+"L-"+i+","+l+"H-"+n+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),i=r.round(.76*t,2);return"M-"+i+",0l-"+n+",-"+e+"h"+i+"l"+n+",-"+e+"l"+n+","+e+"h"+i+"l-"+n+","+e+"l"+n+","+e+"h-"+i+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),i=r.round(1.6*t,2),a=r.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+n+o+e+","+n+o+"0,-"+i+o+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),i=r.round(1.6*t,2),a=r.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+n+o+"-"+e+",-"+n+o+"0,"+i+o+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),i="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),i="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),i=r.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),i=r.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),i=r.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),i=r.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:7}],70:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],71:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),i=t("../../registry"),a=t("../../plots/cartesian/axes"),o=t("./compute_error");function s(t,e,n,i){var s=e["error_"+i]||{},l=[];if(s.visible&&-1!==["linear","log"].indexOf(n.type)){for(var u=o(s),c=0;c0;t.each(function(t){var c,f=t[0].trace,h=f.error_x||{},p=f.error_y||{};f.ids&&(c=function(t){return t.id});var d=o.hasMarkers(f)&&f.marker.maxdisplayed>0;p.visible||h.visible||(t=[]);var m=r.select(this).selectAll("g.errorbar").data(t,c);if(m.exit().remove(),t.length){h.visible||m.selectAll("path.xerror").remove(),p.visible||m.selectAll("path.yerror").remove(),m.style("opacity",1);var g=m.enter().append("g").classed("errorbar",!0);u&&g.style("opacity",0).transition().duration(n.duration).style("opacity",1),a.setClipUrl(m,e.layerClipId),m.each(function(t){var e=r.select(this),a=function(t,e,n){var r={x:e.c2p(t.x),y:n.c2p(t.y)};void 0!==t.yh&&(r.yh=n.c2p(t.yh),r.ys=n.c2p(t.ys),i(r.ys)||(r.noYS=!0,r.ys=n.c2p(t.ys,!0)));void 0!==t.xh&&(r.xh=e.c2p(t.xh),r.xs=e.c2p(t.xs),i(r.xs)||(r.noXS=!0,r.xs=e.c2p(t.xs,!0)));return r}(t,s,l);if(!d||t.vis){var o,c=e.select("path.yerror");if(p.visible&&i(a.x)&&i(a.yh)&&i(a.ys)){var f=p.width;o="M"+(a.x-f)+","+a.yh+"h"+2*f+"m-"+f+",0V"+a.ys,a.noYS||(o+="m-"+f+",0h"+2*f),!c.size()?c=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):u&&(c=c.transition().duration(n.duration).ease(n.easing)),c.attr("d",o)}else c.remove();var m=e.select("path.xerror");if(h.visible&&i(a.y)&&i(a.xh)&&i(a.xs)){var g=(h.copy_ystyle?p:h).width;o="M"+a.xh+","+(a.y-g)+"v"+2*g+"m0,-"+g+"H"+a.xs,a.noXS||(o+="m0,-"+g+"v"+2*g),!m.size()?m=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):u&&(m=m.transition().duration(n.duration).ease(n.easing)),m.attr("d",o)}else m.remove()}})}})}},{"../../traces/scatter/subtypes":290,"../drawing":68,d3:7,"fast-isnumeric":9}],76:[function(t,e,n){"use strict";var r=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},a=e.error_x||{},o=r.select(this);o.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(i.stroke,n.color),a.copy_ystyle&&(a=n),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":43,d3:7}],77:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:r({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":233}],78:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../registry");function a(t,e,n,i){i=i||r.identity,Array.isArray(t)&&(e[0][n]=i(t))}e.exports=function(t){var e=t.calcdata,n=t._fullLayout;function o(t){return function(e){return r.coerceHoverinfo({hoverinfo:e},{_module:t._module},n)}}for(var s=0;s=0&&n.index-1&&o.length>_&&(o=_>3?o.substr(0,_-3)+"...":o.substr(0,_))}void 0!==t.zLabel?(void 0!==t.xLabel&&(u+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(u+="y: "+t.yLabel+"
"),u+=(u?"z: ":"")+t.zLabel):E&&t[i+"Label"]===T?u=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(u=t.yLabel):u=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(u+=(u?"
":"")+t.text),void 0!==t.extraText&&(u+=(u?"
":"")+t.extraText),""===u&&(""===o&&e.remove(),u=o);var x=e.select("text.nums").call(c.font,t.fontFamily||d,t.fontSize||m,t.fontColor||v).text(u).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,n),b=e.select("text.name"),A=0;o&&o!==u?(b.call(c.font,t.fontFamily||d,t.fontSize||m,g).text(o).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,n),A=b.node().getBoundingClientRect().width+2*k):(b.remove(),e.select("rect").remove()),e.select("path").style({fill:p,stroke:v});var M,L,I=x.node().getBoundingClientRect(),P=t.xa._offset+(t.x0+t.x1)/2,D=t.ya._offset+(t.y0+t.y1)/2,O=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),F=I.width+w+k+A;t.ty0=S-I.top,t.bx=I.width+2*k,t.by=I.height+2*k,t.anchor="start",t.txwidth=I.width,t.tx2width=A,t.offset=0,a?(t.pos=P,M=D+R/2+F<=z,L=D-R/2-F>=0,"top"!==t.idealAlign&&M||!L?M?(D+=R/2,t.anchor="start"):t.anchor="middle":(D-=R/2,t.anchor="end")):(t.pos=D,M=P+O/2+F<=C,L=P-O/2-F>=0,"left"!==t.idealAlign&&M||!L?M?(P+=O/2,t.anchor="start"):t.anchor="middle":(P-=O/2,t.anchor="end")),x.attr("text-anchor",t.anchor),A&&b.attr("text-anchor",t.anchor),e.attr("transform","translate("+P+","+D+")"+(a?"rotate("+y+")":""))}),R}function A(t,e){t.each(function(t){var n=r.select(this);if(t.del)n.remove();else{var i="end"===t.anchor?-1:1,a=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],s=o*(w+k),u=s+o*(t.txwidth+k),f=0,h=t.offset;"middle"===t.anchor&&(s-=t.tx2width/2,u+=t.txwidth/2+k),e&&(h*=-b,f=t.offset*x),n.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(h-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(i*w+f)+","+(w+h)+"v"+(t.by/2-w)+"h"+i*t.bx+"v-"+t.by+"H"+(i*w+f)+"V"+(h-w)+"Z"),a.call(l.positionText,s+f,h+t.ty0-t.by/2+k),t.tx2width&&(n.select("text.name").call(l.positionText,u+o*k+f,h+t.ty0-t.by/2+k),n.select("rect").call(c.setRect,u+(o-1)*t.tx2width/2+f,h-t.by/2-1,t.tx2width,t.by+2))}})}function M(t,e){var n=t.index,r=t.trace||{},i=t.cd[0],a=t.cd[n]||{},s=Array.isArray(n)?function(t,e){return o.castOption(i,n,t)||o.extractOption({},r,"",e)}:function(t,e){return o.extractOption(a,r,t,e)};function l(e,n,r){var i=s(n,r);i&&(t[e]=i)}if(l("hoverinfo","hi","hoverinfo"),l("bgcolor","hbg","hoverlabel.bgcolor"),l("borderColor","hbc","hoverlabel.bordercolor"),l("fontFamily","htf","hoverlabel.font.family"),l("fontSize","hts","hoverlabel.font.size"),l("fontColor","htc","hoverlabel.font.color"),l("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var u=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+u+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+u,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var c=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+c+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+c,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function S(t,e){var n,r,i=e.container,o=e.fullLayout,s=e.event,l=!!t.hLinePoint,u=!!t.vLinePoint;if(i.selectAll(".spikeline").remove(),u||l){var h=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(l){var p,d,m=t.hLinePoint;n=m&&m.xa,"cursor"===(r=m&&m.ya).spikesnap?(p=s.pointerX,d=s.pointerY):(p=n._offset+m.x,d=r._offset+m.y);var g,y,v=a.readability(m.color,h)<1.5?f.contrast(h):m.color,_=r.spikemode,x=r.spikethickness,b=r.spikecolor||v,w=r._boundingBox,k=(w.left+w.right)/2w[0]._length||et<0||et>k[0]._length)return h.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,O="xval"in e?m.flat(l,e.xval):m.p2c(w,tt),R="yval"in e?m.flat(l,e.yval):m.p2c(k,et),!i(O[0])||!i(R[0]))return o.warn("Fx.hover failed",e,t),h.unhoverRaw(t,e)}var it=1/0;for(B=0;B$&&(Y.splice(0,$),it=Y[0].distance),v&&0!==X&&0===Y.length){G.distance=X,G.index=!1;var ut=j._module.hoverPoints(G,H,Z,"closest",c._hoverlayer);if(ut&&(ut=ut.filter(function(t){return t.spikeDistance<=X})),ut&&ut.length){var ct,ft=ut.filter(function(t){return t.xa.showspikes});if(ft.length){var ht=ft[0];i(ht.x0)&&i(ht.y0)&&(ct=gt(ht),(!K.vLinePoint||K.vLinePoint.spikeDistance>ct.spikeDistance)&&(K.vLinePoint=ct))}var pt=ut.filter(function(t){return t.ya.showspikes});if(pt.length){var dt=pt[0];i(dt.x0)&&i(dt.y0)&&(ct=gt(dt),(!K.hLinePoint||K.hLinePoint.spikeDistance>ct.spikeDistance)&&(K.hLinePoint=ct))}}}}function mt(t,e){for(var n,r=null,i=1/0,a=0;a1||Y.length>1)||"closest"===D&&Q&&Y.length>1,zt=f.combine(c.plot_bgcolor||f.background,c.paper_bgcolor),Et={hovermode:D,rotateLabels:Ct,bgColor:zt,container:c._hoverlayer,outerContainer:c._paperdiv,commonLabelOpts:c.hoverlabel,hoverdistance:c.hoverdistance},Lt=T(Y,Et,t);if(function(t,e,n){var r,i,a,o,s,l,u,c=0,f=1,h=t.map(function(t,r){var i=t[e],a="x"===i._id.charAt(0),o=i.range;return!r&&o&&o[0]>o[1]!==a&&(f=-1),[{i:r,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(a?_:1)/2,pmin:0,pmax:a?n.width:n.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],n=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=n.pos+n.dp+n.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;r=!1}if(!(a<.01)){if(i<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=a;r=!1}if(r){var u=0;for(o=0;oe.pmax&&u++;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos>e.pmax-1&&(l.del=!0,u--);for(o=0;o=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos+l.dp+l.size>e.pmax&&(l.del=!0,u--)}}}for(;!r&&c<=t.length;){for(c++,r=!0,o=0;o.01&&g.pmin===y.pmin&&g.pmax===y.pmax){for(s=m.length-1;s>=0;s--)m[s].dp+=i;for(d.push.apply(d,m),h.splice(o+1,1),u=0,s=d.length-1;s>=0;s--)u+=d[s].dp;for(a=u/d.length,s=d.length-1;s>=0;s--)d[s].dp-=a;r=!1}else o++}h.forEach(p)}for(o=h.length-1;o>=0;o--){var v=h[o];for(s=v.length-1;s>=0;s--){var x=v[s],b=t[x.i];b.offset=x.dp,b.del=x.del}}}(Y,Ct?"xa":"ya",c),A(Lt,Ct),e.target&&e.target.tagName){var It=d.getComponentMethod("annotations","hasClickToShow")(t,Mt);u(r.select(e.target),It?"pointer":"")}if(!e.target||a||!function(t,e,n){if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var i=n[r],a=t._hoverdata[r];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}(t,0,At))return;At&&t.emit("plotly_unhover",{event:e,points:At});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:O,yvals:R})}(t,e,n,a)})},n.loneHover=function(t,e){var n={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0},i=r.select(e.container),a=e.outerContainer?r.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=T([n],o,e.gd);return A(s,o.rotateLabels),s.node()},n.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var n=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0}}),i=r.select(e.container),a=e.outerContainer?r.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=T(n,o,e.gd),l=0;return s.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5-1?o="closest":(e._isHoriz=function(t){for(var e=!0,n=0;n1){h||p||d||"independent"===T("pattern")&&(h=!0),g._hasSubplotGrid=h;var _,x,b="top to bottom"===T("roworder"),w=h?.2:.1,k=h?.3:.1;m&&e._splomGridDflt&&(_=e._splomGridDflt.xside,x=e._splomGridDflt.yside),g._domains={x:c("x",T,w,_,v),y:c("y",T,k,x,y,b)}}else delete e.grid}function T(t,e){return r.coerce(n,g,l,t,e)}},contentDefaults:function(t,e){var n=e.grid;if(n&&n._domains){var r,i,a,o,s,l,c,h=t.grid||{},p=e._subplots,d=n._hasSubplotGrid,m=n.rows,g=n.columns,y="independent"===n.pattern,v=n._axisMap={};if(d){var _=h.subplots||[];l=n.subplots=new Array(m);var x=1;for(r=0;r=2/3},n.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],96:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),i=t("../color/attributes");e.exports={bgcolor:{valType:"color",editType:"legend"},bordercolor:{valType:"color",dflt:i.defaultLine,editType:"legend"},borderwidth:{valType:"number",min:0,dflt:0,editType:"legend"},font:r({editType:"legend"}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v",editType:"legend"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"],editType:"legend"},tracegroupgap:{valType:"number",min:0,dflt:10,editType:"legend"},x:{valType:"number",min:-2,max:3,dflt:1.02,editType:"legend"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left",editType:"legend"},y:{valType:"number",min:-2,max:3,dflt:1,editType:"legend"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"legend"},editType:"legend"}},{"../../plots/font_attributes":233,"../color/attributes":42}],97:[function(t,e,n){"use strict";e.exports={scrollBarWidth:6,scrollBarMinHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4,textOffsetX:40}},{}],98:[function(t,e,n){"use strict";var r=t("../../registry"),i=t("../../lib"),a=t("../../plot_api/plot_template"),o=t("./attributes"),s=t("../../plots/layout_attributes"),l=t("./helpers");e.exports=function(t,e,n){for(var u,c,f,h,p=t.legend||{},d=0,m=!1,g="normal",y=0;y1)){var _=a.newContainer(e,"legend");if(b("bgcolor",e.paper_bgcolor),b("bordercolor"),b("borderwidth"),i.coerceFont(b,"font",e.font),b("orientation"),"h"===_.orientation){var x=t.xaxis;x&&x.rangeslider&&x.rangeslider.visible?(u=0,f="left",c=1.1,h="bottom"):(u=0,f="left",c=-.1,h="top")}b("traceorder",g),l.isGrouped(e.legend)&&b("tracegroupgap"),b("x",u),b("xanchor",f),b("y",c),b("yanchor",h),i.noneOrAll(p,_,["x","y"])}function b(t,e){return i.coerce(p,_,o,t,e)}}},{"../../lib":162,"../../plot_api/plot_template":196,"../../plots/layout_attributes":237,"../../registry":254,"./attributes":96,"./helpers":102}],99:[function(t,e,n){"use strict";var r=t("d3"),i=t("../../lib"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib/events"),l=t("../dragelement"),u=t("../drawing"),c=t("../color"),f=t("../../lib/svg_text_utils"),h=t("./handle_click"),p=t("./constants"),d=t("../../constants/interactions"),m=t("../../constants/alignment"),g=m.LINE_SPACING,y=m.FROM_TL,v=m.FROM_BR,_=t("./get_legend_data"),x=t("./style"),b=t("./helpers"),w=t("./anchor_utils"),k=d.DBLCLICKDELAY;function T(t,e,n,r,i){var a=n.data()[0][0].trace,o={event:i,node:n.node(),curveNumber:a.index,expandedIndex:a._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(a._group&&(o.group=a._group),"pie"===a.type&&(o.label=n.datum()[0].label),!1!==s.triggerHandler(t,"plotly_legendclick",o))if(1===r)e._clickTimeout=setTimeout(function(){h(n,t,r)},k);else if(2===r){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==s.triggerHandler(t,"plotly_legenddoubleclick",o)&&h(n,t,r)}}function A(t,e,n){var r=t.data()[0][0],a=e._fullLayout,s=r.trace,l=o.traceIs(s,"pie"),c=s.index,h=l?r.label:s.name,d=e._context.edits.legendText&&!l,m=i.ensureSingle(t,"text","legendtext");function y(n){f.convertToTspans(n,e,function(){!function(t,e){var n=t.data()[0][0];if(!n.trace.showlegend)return void t.remove();var r,i,a=t.select("g[class*=math-group]"),o=a.node(),s=e._fullLayout.legend.font.size*g;if(o){var l=u.bBox(o);r=l.height,i=l.width,u.setTranslate(a,0,r/4)}else{var c=t.select(".legendtext"),h=f.lineCount(c),d=c.node();r=s*h,i=d?u.bBox(d).width:0;var m=s*(.3+(1-h)/2);f.positionText(c,p.textOffsetX,m)}r=Math.max(r,16)+3,n.height=r,n.width=i}(t,e)})}m.attr("text-anchor","start").classed("user-select-none",!0).call(u.font,a.legend.font).text(d?M(h,n):h),f.positionText(m,p.textOffsetX,0),d?m.call(f.makeEditable,{gd:e,text:h}).call(y).on("edit",function(t){this.text(M(t,n)).call(y);var a=r.trace._fullInput||{},s={};if(o.hasTransform(a,"groupby")){var l=o.getTransformIndices(a,"groupby"),u=l[l.length-1],f=i.keyedContainer(a,"transforms["+u+"].styles","target","value.name");f.set(r.trace._group,t),s=f.constructUpdate()}else s.name=t;return o.call("restyle",e,s,c)}):y(m)}function M(t,e){var n=Math.max(4,e);if(t&&t.trim().length>=n/2)return t;for(var r=n-(t=t||"").length;r>0;r--)t+=" ";return t}function S(t,e){var n,a=1,o=i.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(c.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(n=(new Date).getTime())-e._legendMouseDownTimek&&(a=Math.max(a-1,1)),T(e,n,t,a,r.event)}})}function C(t,e,n){var i=t._fullLayout,a=i.legend,o=a.borderwidth,s=b.isGrouped(a),l=0;if(a._width=0,a._height=0,b.isVertical(a))s&&e.each(function(t,e){u.setTranslate(this,0,e*a.tracegroupgap)}),n.each(function(t){var e=t[0],n=e.height,r=e.width;u.setTranslate(this,o,5+o+a._height+n/2),a._height+=n,a._width=Math.max(a._width,r)}),a._width+=45+2*o,a._height+=10+2*o,s&&(a._height+=(a._lgroupsLength-1)*a.tracegroupgap),l=40;else if(s){for(var c=[a._width],f=e.data(),h=0,p=f.length;ho+w-k,n.each(function(t){var e=t[0],n=g?40+t[0].width:_;o+x+k+n>i._size.w&&(x=0,y+=v,a._height=a._height+v,v=0),u.setTranslate(this,o+x,5+o+e.height/2+y),a._width+=k+n,a._height=Math.max(a._height,e.height),x+=k+n,v=Math.max(e.height,v)}),a._width+=2*o,a._height+=10+2*o}a._width=Math.ceil(a._width),a._height=Math.ceil(a._height);var T=t._context.edits.legendText||t._context.edits.legendPosition;n.each(function(t){var e=t[0],n=r.select(this).select(".legendtoggle");u.setRect(n,0,-e.height/2,(T?0:a._width)+l,e.height)})}function z(t){var e=t._fullLayout.legend,n="left";w.isRightAnchor(e)?n="right":w.isCenterAnchor(e)&&(n="center");var r="top";w.isBottomAnchor(e)?r="bottom":w.isMiddleAnchor(e)&&(r="middle"),a.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[n],r:e._width*v[n],b:e._height*v[r],t:e._height*y[r]})}e.exports=function(t){var e=t._fullLayout,n="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var s=e.legend,f=e.showlegend&&_(t.calcdata,s),h=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+n).remove(),void a.autoMargin(t,"legend");for(var d=0,m=0;mf?function(t){var e=t._fullLayout.legend,n="left";w.isRightAnchor(e)?n="right":w.isCenterAnchor(e)&&(n="center");a.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[n],r:e._width*v[n],b:0,t:0})}(t):z(t);var h=e._size,d=h.l+h.w*s.x,m=h.t+h.h*(1-s.y);w.isRightAnchor(s)?d-=s._width:w.isCenterAnchor(s)&&(d-=s._width/2),w.isBottomAnchor(s)?m-=s._height:w.isMiddleAnchor(s)&&(m-=s._height/2);var g=s._width,_=h.w;g>_?(d=h.l,g=_):(d+g>c&&(d=c-g),d<0&&(d=0),g=Math.min(c-d,s._width));var x,b,k,A,M=s._height,S=h.h;if(M>S?(m=h.t,M=S):(m+M>f&&(m=f-M),m<0&&(m=0),M=Math.min(f-m,s._height)),u.setTranslate(L,d,m),O.on(".drag",null),L.on("wheel",null),s._height<=M||t._context.staticPlot)P.attr({width:g-s.borderwidth,height:M-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),u.setTranslate(D,0,0),I.select("rect").attr({width:g-2*s.borderwidth,height:M-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth}),u.setClipUrl(D,n),u.setRect(O,0,0,0,0),delete s._scrollY;else{var B,N,j=Math.max(p.scrollBarMinHeight,M*M/s._height),V=M-j-2*p.scrollBarMargin,q=s._height-M,U=V/q,H=Math.min(s._scrollY||0,q);P.attr({width:g-2*s.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:M-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),I.select("rect").attr({width:g-2*s.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:M-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth+H}),u.setClipUrl(D,n),G(H,j,U),L.on("wheel",function(){G(H=i.constrain(s._scrollY+r.event.deltaY/V*q,0,q),j,U),0!==H&&H!==q&&r.event.preventDefault()});var Z=r.behavior.drag().on("dragstart",function(){B=r.event.sourceEvent.clientY,N=H}).on("drag",function(){var t=r.event.sourceEvent;2===t.buttons||t.ctrlKey||G(H=i.constrain((t.clientY-B)/U+N,0,q),j,U)});O.call(Z)}function G(e,n,r){s._scrollY=t._fullLayout.legend._scrollY=e,u.setTranslate(D,0,-e),u.setRect(O,g,p.scrollBarMargin+e*r,p.scrollBarWidth,n),I.select("rect").attr({y:s.borderwidth+e})}t._context.edits.legendPosition&&(L.classed("cursor-move",!0),l.init({element:L.node(),gd:t,prepFn:function(){var t=u.getTranslate(L);k=t.x,A=t.y},moveFn:function(t,e){var n=k+t,r=A+e;u.setTranslate(L,n,r),x=l.align(n,0,h.l,h.l+h.w,s.xanchor),b=l.align(r,0,h.t+h.h,h.t,s.yanchor)},doneFn:function(){void 0!==x&&void 0!==b&&o.call("relayout",t,{"legend.x":x,"legend.y":b})},clickFn:function(n,r){var i=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return r.clientX>=t.left&&r.clientX<=t.right&&r.clientY>=t.top&&r.clientY<=t.bottom});i.size()>0&&T(t,L,i,n,r)}}))}],t)}}},{"../../constants/alignment":141,"../../constants/interactions":142,"../../lib":162,"../../lib/events":154,"../../lib/svg_text_utils":183,"../../plots/plots":246,"../../registry":254,"../color":43,"../dragelement":65,"../drawing":68,"./anchor_utils":95,"./constants":97,"./get_legend_data":100,"./handle_click":101,"./helpers":102,"./style":104,d3:7}],100:[function(t,e,n){"use strict";var r=t("../../registry"),i=t("./helpers");e.exports=function(t,e){var n,a,o={},s=[],l=!1,u={},c=0;function f(t,n){if(""!==t&&i.isGrouped(e))-1===s.indexOf(t)?(s.push(t),l=!0,o[t]=[[n]]):o[t].push([n]);else{var r="~~i"+c;s.push(r),o[r]=[[n]],c++}}for(n=0;nn[1])return n[1]}return i}function d(t){return t[0]}if(c||f||h){var m={},g={};if(c){m.mc=p("marker.color",d),m.mx=p("marker.symbol",d),m.mo=p("marker.opacity",a.mean,[.2,1]),m.mlc=p("marker.line.color",d),m.mlw=p("marker.line.width",a.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=p("marker.size",a.mean,[2,16]);m.ms=y,g.marker.size=y}h&&(g.line={width:p("line.width",d,[0,10])}),f&&(m.tx="Aa",m.tp=p("textposition",d),m.ts=10,m.tc=p("textfont.color",d),m.tf=p("textfont.family",d)),n=[a.minExtend(s,m)],(i=a.minExtend(u,g)).selectedpoints=null}var v=r.select(this).select("g.legendpoints"),_=v.selectAll("path.scatterpts").data(c?n:[]);_.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),_.exit().remove(),_.call(o.pointStyle,i,e),c&&(n[0].mrc=3);var x=v.selectAll("g.pointtext").data(f?n:[]);x.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),x.exit().remove(),x.selectAll("text").call(o.textPointStyle,i,e)}).each(function(t){var e=t[0].trace,n=r.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);n.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),n.exit().remove(),n.each(function(t,n){var i=e[n?"increasing":"decreasing"],a=i.line.width,o=r.select(this);o.style("stroke-width",a+"px").call(s.fill,i.fillcolor),a&&s.stroke(o,i.line.color)})}).each(function(t){var e=t[0].trace,n=r.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);n.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),n.exit().remove(),n.each(function(t,n){var i=e[n?"increasing":"decreasing"],a=i.line.width,l=r.select(this);l.style("fill","none").call(o.dashLine,i.line.dash,a),a&&s.stroke(l,i.line.color)})})}},{"../../lib":162,"../../registry":254,"../../traces/pie/style_one":264,"../../traces/scatter/subtypes":290,"../color":43,"../drawing":68,d3:7}],105:[function(t,e,n){"use strict";var r=t("../../registry"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),s=t("../../../build/ploticon"),l=o._,u=e.exports={};function c(t,e){var n,i,o=e.currentTarget,s=o.getAttribute("data-attr"),l=o.getAttribute("data-val")||!0,u=t._fullLayout,c={},f=a.list(t,null,!0),h="on";if("zoom"===s){var p,d="in"===l?.5:2,m=(1+d)/2,g=(1-d)/2;for(i=0;i1?(b=["toggleHover"],w=["resetViews"]):f?(x=["zoomInGeo","zoomOutGeo"],b=["hoverClosestGeo"],w=["resetGeo"]):c?(b=["hoverClosest3d"],w=["resetCameraDefault3d","resetCameraLastSave3d"]):m?(b=["toggleHover"],w=["resetViewMapbox"]):b=p?["hoverClosestGl2d"]:h?["hoverClosestPie"]:["toggleHover"];u&&(b=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!u&&!p||y||(x=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==w[0]&&(w=["resetScale2d"]));c?k=["zoom3d","pan3d","orbitRotation","tableRotation"]:(u||p)&&!y||d?k=["zoom2d","pan2d"]:m||f?k=["pan2d"]:g&&(k=["zoom2d"]);(function(t){for(var e=!1,n=0;n0)){var m=function(t,e,n){for(var r=n.filter(function(n){return e[n].anchor===t._id}),i=0,a=0;a0?h+u:u;return{ppad:u,ppadplus:c?d:m,ppadminus:c?m:d}}return{ppad:u}}function c(t,e,n,r,i){var s="category"===t.type?t.r2c:t.d2c;if(void 0!==e)return[s(e),s(n)];if(r){var l,u,c,f,h=1/0,p=-1/0,d=r.match(a.segmentRE);for("date"===t.type&&(s=o.decodeDate(s)),l=0;lp&&(p=f)));return p>=h?[h,p]:void 0}}e.exports=function(t){var e=t._fullLayout,n=r.filterVisible(e.shapes);if(n.length&&t._fullData.length)for(var o=0;o10?t/2:10;return r.append("circle").attr({"data-line-point":"start-point",cx:O?U(n.xanchor)+n.x0:U(n.x0),cy:R?H(n.yanchor)-n.y0:H(n.y0),r:a}).style(i).classed("cursor-grab",!0),r.append("circle").attr({"data-line-point":"end-point",cx:O?U(n.xanchor)+n.x1:U(n.x1),cy:R?H(n.yanchor)-n.y1:H(n.y1),r:a}).style(i).classed("cursor-grab",!0),r}():e,W={element:$.node(),gd:t,prepFn:function(r){O&&(b=U(n.xanchor));R&&(w=H(n.yanchor));"path"===n.type?L=n.path:(y=O?n.x0:U(n.x0),v=R?n.y0:H(n.y0),_=O?n.x1:U(n.x1),x=R?n.y1:H(n.y1));y<_?(A=y,z="x0",M=_,E="x1"):(A=_,z="x1",M=y,E="x0");!R&&vx?(k=v,S="y0",T=x,C="y1"):(k=x,S="y1",T=v,C="y0");X(r),K(p,n),function(t,e,n){var r=e.xref,i=e.yref,o=a.getFromId(n,r),l=a.getFromId(n,i),u="";"paper"===r||o.autorange||(u+=r);"paper"===i||l.autorange||(u+=i);t.call(s.setClipUrl,u?"clip"+n._fullLayout._uid+u:null)}(e,n,t),W.moveFn="move"===I?Y:J},doneFn:function(){c(e),Q(p),d(e,t,n),r.call("relayout",t,N.getUpdateObj())},clickFn:function(){Q(p)}};function X(t){if(F)I="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var n=W.element.getBoundingClientRect(),r=n.right-n.left,i=n.bottom-n.top,a=t.clientX-n.left,o=t.clientY-n.top,s=!B&&r>P&&i>D&&!t.shiftKey?u.getCursor(a/r,1-o/i):"move";c(e,s),I=s.split("-")[0]}}function Y(r,i){if("path"===n.type){var a=function(t){return t},o=a,s=a;O?j("xanchor",n.xanchor=Z(b+r)):(o=function(t){return Z(U(t)+r)},V&&"date"===V.type&&(o=h.encodeDate(o))),R?j("yanchor",n.yanchor=G(w+i)):(s=function(t){return G(H(t)+i)},q&&"date"===q.type&&(s=h.encodeDate(s))),j("path",n.path=g(L,o,s))}else O?j("xanchor",n.xanchor=Z(b+r)):(j("x0",n.x0=Z(y+r)),j("x1",n.x1=Z(_+r))),R?j("yanchor",n.yanchor=G(w+i)):(j("y0",n.y0=G(v+i)),j("y1",n.y1=G(x+i)));e.attr("d",m(t,n)),K(p,n)}function J(r,i){if(B){var a=function(t){return t},o=a,s=a;O?j("xanchor",n.xanchor=Z(b+r)):(o=function(t){return Z(U(t)+r)},V&&"date"===V.type&&(o=h.encodeDate(o))),R?j("yanchor",n.yanchor=G(w+i)):(s=function(t){return G(H(t)+i)},q&&"date"===q.type&&(s=h.encodeDate(s))),j("path",n.path=g(L,o,s))}else if(F){if("resize-over-start-point"===I){var l=y+r,u=R?v-i:v+i;j("x0",n.x0=O?l:Z(l)),j("y0",n.y0=R?u:G(u))}else if("resize-over-end-point"===I){var c=_+r,f=R?x-i:x+i;j("x1",n.x1=O?c:Z(c)),j("y1",n.y1=R?f:G(f))}}else{var d=~I.indexOf("n")?k+i:k,N=~I.indexOf("s")?T+i:T,$=~I.indexOf("w")?A+r:A,W=~I.indexOf("e")?M+r:M;~I.indexOf("n")&&R&&(d=k-i),~I.indexOf("s")&&R&&(N=T-i),(!R&&N-d>D||R&&d-N>D)&&(j(S,n[S]=R?d:G(d)),j(C,n[C]=R?N:G(N))),W-$>P&&(j(z,n[z]=O?$:Z($)),j(E,n[E]=O?W:Z(W)))}e.attr("d",m(t,n)),K(p,n)}function K(t,e){(O||R)&&function(){var n="path"!==e.type,r=t.selectAll(".visual-cue").data([0]);r.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var a=U(O?e.xanchor:i.midRange(n?[e.x0,e.x1]:h.extractPathCoords(e.path,f.paramIsX))),o=H(R?e.yanchor:i.midRange(n?[e.y0,e.y1]:h.extractPathCoords(e.path,f.paramIsY)));if(a=h.roundPositionForSharpStrokeRendering(a,1),o=h.roundPositionForSharpStrokeRendering(o,1),O&&R){var s="M"+(a-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";r.attr("d",s)}else if(O){var l="M"+(a-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";r.attr("d",l)}else{var u="M"+(a-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";r.attr("d",u)}}()}function Q(t){t.selectAll(".visual-cue").remove()}u.init(W),$.node().onmousemove=X}(t,_,n,e,p)}}function d(t,e,n){var r=(n.xref+n.yref).replace(/paper/g,"");t.call(s.setClipUrl,r?"clip"+e._fullLayout._uid+r:null)}function m(t,e){var n,r,o,s,l,u,c,p,d=e.type,m=a.getFromId(t,e.xref),g=a.getFromId(t,e.yref),y=t._fullLayout._size;if(m?(n=h.shapePositionToRange(m),r=function(t){return m._offset+m.r2p(n(t,!0))}):r=function(t){return y.l+y.w*t},g?(o=h.shapePositionToRange(g),s=function(t){return g._offset+g.r2p(o(t,!0))}):s=function(t){return y.t+y.h*(1-t)},"path"===d)return m&&"date"===m.type&&(r=h.decodeDate(r)),g&&"date"===g.type&&(s=h.decodeDate(s)),function(t,e,n){var r=t.path,a=t.xsizemode,o=t.ysizemode,s=t.xanchor,l=t.yanchor;return r.replace(f.segmentRE,function(t){var r=0,u=t.charAt(0),c=f.paramIsX[u],h=f.paramIsY[u],p=f.numParams[u],d=t.substr(1).replace(f.paramRE,function(t){return c[r]?t="pixel"===a?e(s)+Number(t):e(t):h[r]&&(t="pixel"===o?n(l)-Number(t):n(t)),++r>p&&(t="X"),t});return r>p&&(d=d.replace(/[\s,]*X.*/,""),i.log("Ignoring extra params in segment "+t)),u+d})}(e,r,s);if("pixel"===e.xsizemode){var v=r(e.xanchor);l=v+e.x0,u=v+e.x1}else l=r(e.x0),u=r(e.x1);if("pixel"===e.ysizemode){var _=s(e.yanchor);c=_-e.y0,p=_-e.y1}else c=s(e.y0),p=s(e.y1);if("line"===d)return"M"+l+","+c+"L"+u+","+p;if("rect"===d)return"M"+l+","+c+"H"+u+"V"+p+"H"+l+"Z";var x=(l+u)/2,b=(c+p)/2,w=Math.abs(x-l),k=Math.abs(b-c),T="A"+w+","+k,A=x+w+","+b;return"M"+A+T+" 0 1,1 "+(x+","+(b-k))+T+" 0 0,1 "+A+"Z"}function g(t,e,n){return t.replace(f.segmentRE,function(t){var r=0,i=t.charAt(0),a=f.paramIsX[i],o=f.paramIsY[i],s=f.numParams[i];return i+t.substr(1).replace(f.paramRE,function(t){return r>=s?t:(a[r]?t=e(t):o[r]&&(t=n(t)),r++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var n in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var r=e._plots[n].shapelayer;r&&r.selectAll("path").remove()}for(var i=0;i0&&(s=s.transition().duration(e.transition.duration).ease(e.transition.easing)),s.attr("transform","translate("+(o-.5*f.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function C(t,e){var n=t._dims;return n.inputAreaStart+f.stepInset+(n.inputAreaLength-2*f.stepInset)*Math.min(1,Math.max(0,e))}function z(t,e){var n=t._dims;return Math.min(1,Math.max(0,(e-f.stepInset-n.inputAreaStart)/(n.inputAreaLength-2*f.stepInset-2*n.inputAreaStart)))}function E(t,e,n){var r=n._dims,i=s.ensureSingle(t,"rect",f.railTouchRectClass,function(r){r.call(A,e,t,n).style("pointer-events","all")});i.attr({width:r.inputAreaLength,height:Math.max(r.inputAreaWidth,f.tickOffset+n.ticklen+r.labelHeight)}).call(a.fill,n.bgcolor).attr("opacity",0),o.setTranslate(i,0,r.currentValueTotalHeight)}function L(t,e){var n=e._dims,r=n.inputAreaLength-2*f.railInset,i=s.ensureSingle(t,"rect",f.railRectClass);i.attr({width:r,height:f.railWidth,rx:f.railRadius,ry:f.railRadius,"shape-rendering":"crispEdges"}).call(a.stroke,e.bordercolor).call(a.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(i,f.railInset,.5*(n.inputAreaWidth-f.railWidth)+n.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,n=function(t,e){for(var n=t[f.name],r=[],i=0;i0?[0]:[]);function s(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),i.autoMargin(t,g(e))}if(a.enter().append("g").classed(f.containerClassName,!0).style("cursor","ew-resize"),a.exit().each(function(){r.select(this).selectAll("g."+f.groupClassName).each(s)}).remove(),0!==n.length){var l=a.selectAll("g."+f.groupClassName).data(n,y);l.enter().append("g").classed(f.groupClassName,!0),l.exit().each(s).remove();for(var u=0;u0||h<0){var m={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[v.side];e.attr("transform","translate("+m+")")}}}I.call(P),E&&(z?I.on(".opacity",null):(S=0,C=!0,I.text(g).on("mouseover.opacity",function(){r.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),I.call(c.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("restyle",t,m,e,y):o.call("relayout",t,m,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(P)}).on("input",function(t){this.text(t||" ").call(c.positionText,_.x,_.y)}));return I.classed("js-placeholder",C),b}};var h=/ [XY][0-9]* /},{"../../constants/interactions":142,"../../lib":162,"../../lib/svg_text_utils":183,"../../plots/plots":246,"../../registry":254,"../color":43,"../drawing":68,d3:7,"fast-isnumeric":9}],135:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes"),l=t("../../plot_api/plot_template").templatedArray,u=l("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(l("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:u,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:a({},s,{}),font:r({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":155,"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../../plots/font_attributes":233,"../../plots/pad_attributes":245,"../color/attributes":42}],136:[function(t,e,n){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],137:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../plots/array_container_defaults"),a=t("./attributes"),o=t("./constants").name,s=a.buttons;function l(t,e,n){function o(n,i){return r.coerce(t,e,a,n,i)}o("visible",i(t,e,{name:"buttons",handleItemDefaults:u}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),r.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),r.coerceFont(o,"font",n.font),o("bgcolor",n.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function u(t,e){function n(n,i){return r.coerce(t,e,s,n,i)}n("visible","skip"===t.method||Array.isArray(t.args))&&(n("method"),n("args"),n("label"),n("execute"))}e.exports=function(t,e){i(t,e,{name:o,handleItemDefaults:l})}},{"../../lib":162,"../../plots/array_container_defaults":202,"./attributes":135,"./constants":136}],138:[function(t,e,n){"use strict";var r=t("d3"),i=t("../../plots/plots"),a=t("../color"),o=t("../drawing"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../legend/anchor_utils"),c=t("../../plot_api/plot_template").arrayEditor,f=t("../../constants/alignment").LINE_SPACING,h=t("./constants"),p=t("./scrollbox");function d(t){return t._index}function m(t,e){return+t.attr(h.menuIndexAttrName)===e._index}function g(t,e,n,r,i,a,o,s){e.active=o,c(t.layout,h.name,e).applyUpdate("active",o),"buttons"===e.type?v(t,r,null,null,e):"dropdown"===e.type&&(i.attr(h.menuIndexAttrName,"-1"),y(t,r,i,a,e),s||v(t,r,i,a,e))}function y(t,e,n,r,i){var a=s.ensureSingle(e,"g",h.headerClassName,function(t){t.style("pointer-events","all")}),l=i._dims,u=i.active,c=i.buttons[u]||h.blankHeaderOpts,f={y:i.pad.t,yPad:0,x:i.pad.l,xPad:0,index:0},p={width:l.headerWidth,height:l.headerHeight};a.call(_,i,c,t).call(S,i,f,p),s.ensureSingle(e,"text",h.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,i.font).text(h.arrowSymbol[i.direction])}).attr({x:l.headerWidth-h.arrowOffsetX+i.pad.l,y:l.headerHeight/2+h.textOffsetY+i.pad.t}),a.on("click",function(){n.call(C,String(m(n,i)?-1:i._index)),v(t,e,n,r,i)}),a.on("mouseover",function(){a.call(k)}),a.on("mouseout",function(){a.call(T,i)}),o.setTranslate(e,l.lx,l.ly)}function v(t,e,n,a,o){n||(n=e).attr("pointer-events","all");var l=function(t){return-1==+t.attr(h.menuIndexAttrName)}(n)&&"buttons"!==o.type?[]:o.buttons,u="dropdown"===o.type?h.dropdownButtonClassName:h.buttonClassName,c=n.selectAll("g."+u).data(s.filterVisible(l)),f=c.enter().append("g").classed(u,!0),p=c.exit();"dropdown"===o.type?(f.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var d=0,m=0,y=o._dims,v=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(v?m=y.headerHeight+h.gapButtonHeader:d=y.headerWidth+h.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(m=-h.gapButtonHeader+h.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(d=-h.gapButtonHeader+h.gapButton-y.openWidth);var x={x:y.lx+d+o.pad.l,y:y.ly+m+o.pad.t,yPad:h.gapButton,xPad:h.gapButton,index:0},b={l:x.x+o.borderwidth,t:x.y+o.borderwidth};c.each(function(s,l){var u=r.select(this);u.call(_,o,s,t).call(S,o,x),u.on("click",function(){r.event.defaultPrevented||(g(t,o,0,e,n,a,l),s.execute&&i.executeAPICommand(t,s.method,s.args),t.emit("plotly_buttonclicked",{menu:o,button:s,active:o.active}))}),u.on("mouseover",function(){u.call(k)}),u.on("mouseout",function(){u.call(T,o),c.call(w,o)})}),c.call(w,o),v?(b.w=Math.max(y.openWidth,y.headerWidth),b.h=x.y-b.t):(b.w=x.x-b.l,b.h=Math.max(y.openHeight,y.headerHeight)),b.direction=o.direction,a&&(c.size()?function(t,e,n,r,i,a){var o,s,l,u=i.direction,c="up"===u||"down"===u,f=i._dims,p=i.active;if(c)for(s=0,l=0;l0?[0]:[]);if(o.enter().append("g").classed(h.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){r.select(this).selectAll("g."+h.headerGroupClassName).each(a)}).remove(),0!==n.length){var l=o.selectAll("g."+h.headerGroupClassName).data(n,d);l.enter().append("g").classed(h.headerGroupClassName,!0);for(var u=s.ensureSingle(o,"g",h.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),c=0;cw,A=s.barLength+2*s.barPad,M=s.barWidth+2*s.barPad,S=d,C=g+y;C+M>u&&(C=u-M);var z=this.container.selectAll("rect.scrollbar-horizontal").data(T?[0]:[]);z.exit().on(".drag",null).remove(),z.enter().append("rect").classed("scrollbar-horizontal",!0).call(i.fill,s.barColor),T?(this.hbar=z.attr({rx:s.barRadius,ry:s.barRadius,x:S,y:C,width:A,height:M}),this._hbarXMin=S+A/2,this._hbarTranslateMax=w-A):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var E=y>k,L=s.barWidth+2*s.barPad,I=s.barLength+2*s.barPad,P=d+m,D=g;P+L>l&&(P=l-L);var O=this.container.selectAll("rect.scrollbar-vertical").data(E?[0]:[]);O.exit().on(".drag",null).remove(),O.enter().append("rect").classed("scrollbar-vertical",!0).call(i.fill,s.barColor),E?(this.vbar=O.attr({rx:s.barRadius,ry:s.barRadius,x:P,y:D,width:L,height:I}),this._vbarYMin=D+I/2,this._vbarTranslateMax=k-I):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var R=this.id,F=c-.5,B=E?f+L+.5:f+.5,N=h-.5,j=T?p+M+.5:p+.5,V=o._topdefs.selectAll("#"+R).data(T||E?[0]:[]);if(V.exit().remove(),V.enter().append("clipPath").attr("id",R).append("rect"),T||E?(this._clipRect=V.select("rect").attr({x:Math.floor(F),y:Math.floor(N),width:Math.ceil(B)-Math.floor(F),height:Math.ceil(j)-Math.floor(N)}),this.container.call(a.setClipUrl,R),this.bg.attr({x:d,y:g,width:m,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),T||E){var q=r.behavior.drag().on("dragstart",function(){r.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var U=r.behavior.drag().on("dragstart",function(){r.event.sourceEvent.preventDefault(),r.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));T&&this.hbar.on(".drag",null).call(U),E&&this.vbar.on(".drag",null).call(U)}this.setTranslate(e,n)},s.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},s.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=r.event.dx),this.vbar&&(e-=r.event.dy),this.setTranslate(t,e)},s.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=r.event.deltaY),this.vbar&&(e+=r.event.deltaY),this.setTranslate(t,e)},s.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var n=t+this._hbarXMin,i=n+this._hbarTranslateMax;t=(o.constrain(r.event.x,n,i)-n)/(i-n)*(this.position.w-this._box.w)}if(this.vbar){var a=e+this._vbarYMin,s=a+this._vbarTranslateMax;e=(o.constrain(r.event.y,a,s)-a)/(s-a)*(this.position.h-this._box.h)}this.setTranslate(t,e)},s.prototype.setTranslate=function(t,e){var n=this.position.w-this._box.w,r=this.position.h-this._box.h;if(t=o.constrain(t||0,0,n),e=o.constrain(e||0,0,r),this.translateX=t,this.translateY=e,this.container.call(a.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var i=t/n;this.hbar.call(a.setTranslate,t+i*this._hbarTranslateMax,e)}if(this.vbar){var s=e/r;this.vbar.call(a.setTranslate,t,e+s*this._vbarTranslateMax)}}},{"../../lib":162,"../color":43,"../drawing":68,d3:7}],141:[function(t,e,n){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],142:[function(t,e,n){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],143:[function(t,e,n){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],144:[function(t,e,n){"use strict";n.xmlns="http://www.w3.org/2000/xmlns/",n.svg="http://www.w3.org/2000/svg",n.xlink="http://www.w3.org/1999/xlink",n.svgAttrs={xmlns:n.svg,"xmlns:xlink":n.xlink}},{}],145:[function(t,e,n){"use strict";n.version="1.42.5",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config");for(var r=t("./registry"),i=n.register=r.register,a=t("./plot_api"),o=Object.keys(a),s=0;ss-1e-15}function u(t,e){return a(e-t,s)}function c(t,e){if(l(e))return!0;var n,r;e[0](r=i(r,s))&&(r+=s);var a=i(t,s),o=a+s;return a>=n&&a<=r||o>=n&&o<=r}function f(t,e,n,r,i,a,u){i=i||0,a=a||0;var c,f,h,p,d,m=l([n,r]);function g(t,e){return[t*Math.cos(e)+i,a-t*Math.sin(e)]}m?(c=0,f=o,h=s):n=i&&t<=a);var i,a},pathArc:function(t,e,n,r,i){return f(null,t,e,n,r,i,0)},pathSector:function(t,e,n,r,i){return f(null,t,e,n,r,i,1)},pathAnnulus:function(t,e,n,r,i,a){return f(t,e,n,r,i,a,1)}}},{"./mod":169}],148:[function(t,e,n){"use strict";var r=Array.isArray,i="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},a="undefined"==typeof DataView?function(){}:DataView;function o(t){return i.isView(t)&&!(t instanceof a)}function s(t){return r(t)||o(t)}n.isTypedArray=o,n.isArrayOrTypedArray=s,n.isArray1D=function(t){return!s(t[0])},n.ensureArray=function(t,e){return r(t)||(t=[]),t.length=e,t},n.concat=function(){var t,e,n,i,a,o,s,l,u=[],c=!0,f=0;for(n=0;ni.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,i){t%1||!r(t)||void 0!==i.min&&ti.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var i="number"==typeof t;!0!==r.strict&&i?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){i(t).isValid()?e.set(t):e.set(n)}},colorlist:{coerceFunction:function(t,e,n){Array.isArray(t)&&t.length&&t.every(function(t){return i(t).isValid()})?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(o(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?e.set(c(+t,360)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n,r){var i=r.regex||l(n);"string"==typeof t&&i.test(t)?e.set(t):e.set(n)},validateFunction:function(t,e){var n=e.dflt;return t===n||"string"==typeof t&&!!l(n).test(t)}},flaglist:{coerceFunction:function(t,e,n,r){if("string"==typeof t)if(-1===(r.extras||[]).indexOf(t)){for(var i=t.split("+"),a=0;a=r&&t<=i?t:c}if("string"!=typeof t&&"number"!=typeof t)return c;t=String(t);var u=b(e),y=t.charAt(0);!u||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=u&&"chinese"===e.substr(0,7),k=t.match(w?_:v);if(!k)return c;var T=k[1],A=k[3]||"1",M=Number(k[5]||1),S=Number(k[7]||0),C=Number(k[9]||0),z=Number(k[11]||0);if(u){if(2===T.length)return c;var E;T=Number(T);try{var L=g.getComponentMethod("calendars","getCal")(e);if(w){var I="i"===A.charAt(A.length-1);A=parseInt(A,10),E=L.newDate(T,L.toMonthIndex(T,A,I),M)}else E=L.newDate(T,Number(A),M)}catch(t){return c}return E?(E.toJD()-m)*f+S*h+C*p+z*d:c}T=2===T.length?(Number(T)+2e3-x)%100+x:Number(T),A-=1;var P=new Date(Date.UTC(2e3,A,M,S,C));return P.setUTCFullYear(T),P.getUTCMonth()!==A?c:P.getUTCDate()!==M?c:P.getTime()+z*d},r=n.MIN_MS=n.dateTime2ms("-9999"),i=n.MAX_MS=n.dateTime2ms("9999-12-31 23:59:59.9999"),n.isDateTime=function(t,e){return n.dateTime2ms(t,e)!==c};var k=90*f,T=3*h,A=5*p;function M(t,e,n,r,i){if((e||n||r||i)&&(t+=" "+w(e,2)+":"+w(n,2),(r||i)&&(t+=":"+w(r,2),i))){for(var a=4;i%10==0;)a-=1,i/=10;t+="."+w(i,a)}return t}n.ms2DateTime=function(t,e,n){if("number"!=typeof t||!(t>=r&&t<=i))return c;e||(e=0);var a,o,s,u,v,_,x=Math.floor(10*l(t+.05,1)),w=Math.round(t-x/10);if(b(n)){var S=Math.floor(w/f)+m,C=Math.floor(l(t,f));try{a=g.getComponentMethod("calendars","getCal")(n).fromJD(S).formatDate("yyyy-mm-dd")}catch(t){a=y("G%Y-%m-%d")(new Date(w))}if("-"===a.charAt(0))for(;a.length<11;)a="-0"+a.substr(1);else for(;a.length<10;)a="0"+a;o=e=r+f&&t<=i-f))return c;var e=Math.floor(10*l(t+.05,1)),n=new Date(Math.round(t-e/10));return M(a.time.format("%Y-%m-%d")(n),n.getHours(),n.getMinutes(),n.getSeconds(),10*n.getUTCMilliseconds()+e)},n.cleanDate=function(t,e,r){if(t===c)return e;if(n.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(b(r))return s.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=n.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!n.isDateTime(t,r))return s.error("unrecognized date",t),e;return t};var S=/%\d?f/g;function C(t,e,n,r){t=t.replace(S,function(t){var n=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(n).substr(2).replace(/0+$/,"")||"0"});var i=new Date(Math.floor(e+.05));if(b(r))try{t=g.getComponentMethod("calendars","worldCalFmt")(t,e,r)}catch(t){return"Invalid"}return n(t)(i)}var z=[59,59.9,59.99,59.999,59.9999];n.formatDate=function(t,e,n,r,i,a){if(i=b(i)&&i,!e)if("y"===n)e=a.year;else if("m"===n)e=a.month;else{if("d"!==n)return function(t,e){var n=l(t+.05,f),r=w(Math.floor(n/h),2)+":"+w(l(Math.floor(n/p),60),2);if("M"!==e){o(e)||(e=0);var i=(100+Math.min(l(t/d,60),z[e])).toFixed(e).substr(1);e>0&&(i=i.replace(/0+$/,"").replace(/[\.]$/,"")),r+=":"+i}return r}(t,n)+"\n"+C(a.dayMonthYear,t,r,i);e=a.dayMonth+"\n"+a.year}return C(e,t,r,i)};var E=3*f;n.incrementMonth=function(t,e,n){n=b(n)&&n;var r=l(t,f);if(t=Math.round(t-r),n)try{var i=Math.round(t/f)+m,a=g.getComponentMethod("calendars","getCal")(n),o=a.fromJD(i);return e%12?a.add(o,e,"m"):a.add(o,e/12,"y"),(o.toJD()-m)*f+r}catch(e){s.error("invalid ms "+t+" in calendar "+n)}var u=new Date(t+E);return u.setUTCMonth(u.getUTCMonth()+e)+r-E},n.findExactDates=function(t,e){for(var n,r,i=0,a=0,s=0,l=0,u=b(e)&&g.getComponentMethod("calendars","getCal")(e),c=0;c0&&(n.push(i),i=[])}return i.length>0&&n.push(i),n},n.makeLine=function(t){return 1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}},n.makePolygon=function(t){if(1===t.length)return{type:"Polygon",coordinates:t};for(var e=new Array(t.length),n=0;n1||m<0||m>1?null:{x:t+l*m,y:e+f*m}}function l(t,e,n,r,i){var a=r*t+i*e;if(a<0)return r*r+i*i;if(a>n){var o=r-t,s=i-e;return o*o+s*s}var l=r*e-i*t;return l*l/n}n.segmentsIntersect=s,n.segmentDistance=function(t,e,n,r,i,a,o,u){if(s(t,e,n,r,i,a,o,u))return 0;var c=n-t,f=r-e,h=o-i,p=u-a,d=c*c+f*f,m=h*h+p*p,g=Math.min(l(c,f,d,i-t,a-e),l(c,f,d,o-t,u-e),l(h,p,m,t-i,e-a),l(h,p,m,n-i,r-a));return Math.sqrt(g)},n.getTextLocation=function(t,e,n,s){if(t===i&&s===a||(r={},i=t,a=s),r[n])return r[n];var l=t.getPointAtLength(o(n-s/2,e)),u=t.getPointAtLength(o(n+s/2,e)),c=Math.atan((u.y-l.y)/(u.x-l.x)),f=t.getPointAtLength(o(n,e)),h={x:(4*f.x+l.x+u.x)/6,y:(4*f.y+l.y+u.y)/6,theta:c};return r[n]=h,h},n.clearLocationCache=function(){i=null},n.getVisibleSegment=function(t,e,n){var r,i,a=e.left,o=e.right,s=e.top,l=e.bottom,u=0,c=t.getTotalLength(),f=c;function h(e){var n=t.getPointAtLength(e);0===e?r=n:e===c&&(i=n);var u=n.xo?n.x-o:0,f=n.yl?n.y-l:0;return Math.sqrt(u*u+f*f)}for(var p=h(u);p;){if((u+=p+n)>f)return;p=h(u)}for(p=h(f);p;){if(u>(f-=p+n))return;p=h(f)}return{min:u,max:f,len:f-u,total:c,isClosed:0===u&&f===c&&Math.abs(r.x-i.x)<.1&&Math.abs(r.y-i.y)<.1}},n.findPointOnPath=function(t,e,n,r){for(var i,a,o,s=(r=r||{}).pathLength||t.getTotalLength(),l=r.tolerance||.001,u=r.iterationLimit||30,c=t.getPointAtLength(0)[n]>t.getPointAtLength(s)[n]?-1:1,f=0,h=0,p=s;f0?p=i:h=i,f++}return a}},{"./mod":169}],160:[function(t,e,n){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],161:[function(t,e,n){"use strict";e.exports=function(t){return t}},{}],162:[function(t,e,n){"use strict";var r=t("d3"),i=t("fast-isnumeric"),a=t("../constants/numerical"),o=a.FP_SAFE,s=a.BADNUM,l=e.exports={};l.nestedProperty=t("./nested_property"),l.keyedContainer=t("./keyed_container"),l.relativeAttr=t("./relative_attr"),l.isPlainObject=t("./is_plain_object"),l.toLogRange=t("./to_log_range"),l.relinkPrivateKeys=t("./relink_private");var u=t("./array");l.isTypedArray=u.isTypedArray,l.isArrayOrTypedArray=u.isArrayOrTypedArray,l.isArray1D=u.isArray1D,l.ensureArray=u.ensureArray,l.concat=u.concat;var c=t("./mod");l.mod=c.mod,l.modHalf=c.modHalf;var f=t("./coerce");l.valObjectMeta=f.valObjectMeta,l.coerce=f.coerce,l.coerce2=f.coerce2,l.coerceFont=f.coerceFont,l.coerceHoverinfo=f.coerceHoverinfo,l.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,l.validate=f.validate;var h=t("./dates");l.dateTime2ms=h.dateTime2ms,l.isDateTime=h.isDateTime,l.ms2DateTime=h.ms2DateTime,l.ms2DateTimeLocal=h.ms2DateTimeLocal,l.cleanDate=h.cleanDate,l.isJSDate=h.isJSDate,l.formatDate=h.formatDate,l.incrementMonth=h.incrementMonth,l.dateTick0=h.dateTick0,l.dfltRange=h.dfltRange,l.findExactDates=h.findExactDates,l.MIN_MS=h.MIN_MS,l.MAX_MS=h.MAX_MS;var p=t("./search");l.findBin=p.findBin,l.sorterAsc=p.sorterAsc,l.sorterDes=p.sorterDes,l.distinctVals=p.distinctVals,l.roundUp=p.roundUp,l.sort=p.sort,l.findIndexOfMin=p.findIndexOfMin;var d=t("./stats");l.aggNums=d.aggNums,l.len=d.len,l.mean=d.mean,l.midRange=d.midRange,l.variance=d.variance,l.stdev=d.stdev,l.interp=d.interp;var m=t("./matrix");l.init2dArray=m.init2dArray,l.transposeRagged=m.transposeRagged,l.dot=m.dot,l.translationMatrix=m.translationMatrix,l.rotationMatrix=m.rotationMatrix,l.rotationXYMatrix=m.rotationXYMatrix,l.apply2DTransform=m.apply2DTransform,l.apply2DTransform2=m.apply2DTransform2;var g=t("./angles");l.deg2rad=g.deg2rad,l.rad2deg=g.rad2deg,l.angleDelta=g.angleDelta,l.angleDist=g.angleDist,l.isFullCircle=g.isFullCircle,l.isAngleInsideSector=g.isAngleInsideSector,l.isPtInsideSector=g.isPtInsideSector,l.pathArc=g.pathArc,l.pathSector=g.pathSector,l.pathAnnulus=g.pathAnnulus;var y=t("./geometry2d");l.segmentsIntersect=y.segmentsIntersect,l.segmentDistance=y.segmentDistance,l.getTextLocation=y.getTextLocation,l.clearLocationCache=y.clearLocationCache,l.getVisibleSegment=y.getVisibleSegment,l.findPointOnPath=y.findPointOnPath;var v=t("./extend");l.extendFlat=v.extendFlat,l.extendDeep=v.extendDeep,l.extendDeepAll=v.extendDeepAll,l.extendDeepNoArrays=v.extendDeepNoArrays;var _=t("./loggers");l.log=_.log,l.warn=_.warn,l.error=_.error;var x=t("./regex");l.counterRegex=x.counter;var b=t("./throttle");function w(t){var e={};for(var n in t)for(var r=t[n],i=0;io?s:i(t)?Number(t):s:s},l.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(i(t)&&t>=0&&t%1==0)},l.noop=t("./noop"),l.identity=t("./identity"),l.repeat=function(t,e){for(var n=new Array(e),r=0;rn?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},l.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},l.simpleMap=function(t,e,n,r){for(var i=t.length,a=new Array(i),o=0;o=Math.pow(2,n)?i>10?(l.warn("randstr failed uniqueness"),u):t(e,n,r,(i||0)+1):u},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={optionList:[],_newoption:function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)}};return n["_"+e]=t,n},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var n,r,i,a,o=t.length,s=2*o,l=2*e-1,u=new Array(l),c=new Array(o);for(n=0;n=s&&(i-=s*Math.floor(i/s)),i<0?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*u[r];c[n]=a}return c},l.syncOrAsync=function(t,e,n){var r;function i(){return l.syncOrAsync(t,e,n)}for(;t.length;)if((r=(0,t.splice(0,1)[0])(e))&&r.then)return r.then(i).then(void 0,l.promiseError);return n&&n(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,n){if(t){var r,i=!1,a=!0;for(r=0;r1?i+o[1]:"";if(a&&(o.length>1||s.length>4||n))for(;r.test(s);)s=s.replace(r,"$1"+a+"$2");return s+l};var A=/%{([^\s%{}]*)}/g,M=/^\w*$/;l.templateString=function(t,e){var n={};return t.replace(A,function(t,r){return M.test(r)?e[r]||"":(n[r]=n[r]||l.nestedProperty(e,r).get,n[r]()||"")})};l.subplotSort=function(t,e){for(var n=Math.min(t.length,e.length)+1,r=0,i=0,a=0;a=48&&o<=57,u=s>=48&&s<=57;if(l&&(r=10*r+o-48),u&&(i=10*i+s-48),!l||!u){if(r!==i)return r-i;if(o!==s)return o-s}}return i-r};var S=2e9;l.seedPseudoRandom=function(){S=2e9},l.pseudoRandom=function(){var t=S;return S=(69069*S+1)%4294967296,Math.abs(S-t)<429496729?l.pseudoRandom():S/4294967296}},{"../constants/numerical":143,"./angles":147,"./array":148,"./clean_number":149,"./clear_responsive":151,"./coerce":152,"./dates":153,"./extend":155,"./filter_unique":156,"./filter_visible":157,"./geometry2d":159,"./get_graph_div":160,"./identity":161,"./is_plain_object":163,"./keyed_container":164,"./localize":165,"./loggers":166,"./make_trace_groups":167,"./matrix":168,"./mod":169,"./nested_property":170,"./noop":171,"./notifier":172,"./push_unique":175,"./regex":177,"./relative_attr":178,"./relink_private":179,"./search":180,"./stats":182,"./throttle":184,"./to_log_range":185,d3:7,"fast-isnumeric":9}],163:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],164:[function(t,e,n){"use strict";var r=t("./nested_property"),i=/^\w*$/;e.exports=function(t,e,n,a){var o,s,l;n=n||"name",a=a||"value";var u={};e&&e.length?(l=r(t,e),s=l.get()):s=t,e=e||"";var c={};if(s)for(o=0;o2)return u[e]=2|u[e],h.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],170:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),i=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(r(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,a,o,l=0,u=e.split(".");l/g),o=0;oa||u===i||us||e&&l(t))}:function(t,e){var l=t[0],u=t[1];if(l===i||la||u===i||us)return!1;var c,f,h,p,d,m=n.length,g=n[0][0],y=n[0][1],v=0;for(c=1;cMath.max(f,g)||u>Math.max(h,y)))if(uc||Math.abs(r(o,h))>i)return!0;return!1};a.filter=function(t,e){var n=[t[0]],r=0,i=0;function a(a){t.push(a);var s=n.length,l=r;n.splice(i+1);for(var u=l+1;u1&&a(t.pop());return{addPt:a,raw:t,filtered:n}}},{"../constants/numerical":143,"./matrix":168}],175:[function(t,e,n){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var n,r=e.toString();for(n=0;ni.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,n;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;ne}function u(t,e){return t>=e}n.findBin=function(t,e,n){if(r(e.start))return n?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var a,c,f=0,h=e.length,p=0,d=h>1?(e[h-1]-e[0])/(h-1):1;for(c=d>=0?n?o:s:n?u:l,t+=1e-9*d*(n?-1:1)*(d>=0?1:-1);f90&&i.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,i=e[r]-e[0]||1,a=i/(r||1)/1e4,o=[e[0]],s=0;se[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},n.roundUp=function(t,e,n){for(var r,i=0,a=e.length-1,o=0,s=n?0:1,l=n?1:0,u=n?Math.ceil:Math.floor;i0&&(r=1),n&&r)return t.sort(e)}return r?t:t.reverse()},n.findIndexOfMin=function(t,e){e=e||a;for(var n,r=1/0,i=0;ia.length)&&(o=a.length),r(e)||(e=!1),i(a[0])){for(l=new Array(o),s=0;st.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"./array":148,"fast-isnumeric":9}],183:[function(t,e,n){"use strict";var r=t("d3"),i=t("../lib"),a=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function s(t,e){return t.node().getBoundingClientRect()[e]}var l=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;n.convertToTspans=function(t,e,g){var S=t.text(),C=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&S.match(l),E=r.select(t.node().parentNode);if(!E.empty()){var L=t.attr("class")?t.attr("class").split(" ")[0]:"text";return L+="-math",E.selectAll("svg."+L).remove(),E.selectAll("g."+L+"-group").remove(),t.style("display",null).attr({"data-unformatted":S,"data-math":"N"}),C?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var n=parseInt(t.node().style.fontSize,10),a={fontSize:n};!function(t,e,n){var a,o,s,l;MathJax.Hub.Queue(function(){return o=i.extendDeepAll({},MathJax.Hub.config),s=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(a=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var n="math-output-"+i.randstr({},64);return l=r.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(u,"\\lt ").replace(c,"\\gt ")),MathJax.Hub.Typeset(l.node())},function(){var e=r.select("body").select("#MathJax_SVG_glyphs");if(l.select(".MathJax_SVG").empty()||!l.select("svg").node())i.log("There was an error in the tex syntax.",t),n();else{var o=l.select("svg").node().getBoundingClientRect();n(l.select(".MathJax_SVG"),e,o)}if(l.remove(),"SVG"!==a)return MathJax.Hub.setRenderer(a)},function(){return void 0!==s&&(MathJax.Hub.processSectionDelay=s),MathJax.Hub.Config(o)})}(C[2],a,function(r,i,a){E.selectAll("svg."+L).remove(),E.selectAll("g."+L+"-group").remove();var o=r&&r.select("svg");if(!o||!o.node())return I(),void e();var l=E.append("g").classed(L+"-group",!0).attr({"pointer-events":"none","data-unformatted":S,"data-math":"Y"});l.node().appendChild(o.node()),i&&i.node()&&o.node().insertBefore(i.node().cloneNode(!0),o.node().firstChild),o.attr({class:L,height:a.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=t.node().style.fill||"black";o.select("g").attr({fill:u,stroke:u});var c=s(o,"width"),f=s(o,"height"),h=+t.attr("x")-c*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(n||s(t,"height"))/4;"y"===L[0]?(l.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-c/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===L[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===L[0]?o.attr({x:0,y:p}):o.attr({x:h,y:+t.attr("y")+p-f/2}),g&&g.call(t,l),e(l)})})):I(),t}function I(){E.empty()||(L=t.attr("class")+"-math",E.select("svg."+L).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var n,s=!1,l=[],u=-1;function c(){u++;var e=document.createElementNS(a.svg,"tspan");r.select(e).attr({class:"line",dy:u*o+"em"}),t.appendChild(e),n=e;var i=l;if(l=[{node:e}],i.length>1)for(var s=1;s doesnt match end tag <"+t+">. Pretending it did match.",e),n=l[l.length-1].node}else i.log("Ignoring unexpected end tag .",e)}x.test(e)?c():(n=t,l=[{node:t}]);for(var E=e.split(v),L=0;L|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},h={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},d="\u200b",m=["http:","https:","mailto:","",void 0,":"],g=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,v=/(<[^<>]*>)/,_=/<(\/?)([^ >]*)(\s+(.*))?>/i,x=//i,b=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,T=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function A(t,e){if(!t)return null;var n=t.match(e),r=n&&(n[3]||n[4]);return r&&z(r)}var M=/(^|;)\s*color:/;n.plainText=function(t){return(t||"").replace(g," ")};var S={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},C=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function z(t){return t.replace(C,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var n=String.fromCharCode;return t<=65535?n(t):n(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):S[e])||t})}function E(t,e,n){var r,i,a,o=n.horizontalAlign,s=n.verticalAlign||"top",l=t.node().getBoundingClientRect(),u=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-r.height}:"middle"===s?function(){return l.top+(l.height-r.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-r.width}:"center"===o?function(){return l.left+(l.width-r.width)/2}:function(){return l.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:i()-u.top+"px",left:a()-u.left+"px","z-index":1e3}),this}}n.convertEntities=z,n.lineCount=function(t){return t.selectAll("tspan.line").size()||1},n.positionText=function(t,e,n){return t.each(function(){var t=r.select(this);function i(e,n){return void 0===n?null===(n=t.attr(e))&&(t.attr(e,0),n=0):t.attr(e,n),n}var a=i("x",e),o=i("y",n);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:a,y:o})})},n.makeEditable=function(t,e){var n=e.gd,i=e.delegate,a=r.dispatch("edit","input","cancel"),o=i||t;if(t.style({"pointer-events":i?"none":"all"}),1!==t.size())throw new Error("boo");function s(){!function(){var i=r.select(n).select(".svg-container"),o=i.append("div"),s=t.node().style,u=parseFloat(s.fontSize||12),c=e.text;void 0===c&&(c=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":s.fontFamily||"Arial","font-size":u,color:e.fill||s.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-u/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(c).call(E(t,i,e)).on("blur",function(){n._editing=!1,t.text(this.textContent).style({opacity:1});var e,i=r.select(this).attr("class");(e=i?"."+i.split(" ")[0]+"-math-group":"[class*=-math-group]")&&r.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;r.select(this).transition().duration(0).remove(),r.select(document).on("mouseup",null),a.edit.call(t,o)}).on("focus",function(){var t=this;n._editing=!0,r.select(document).on("mouseup",function(){if(r.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===r.event.which?(n._editing=!1,t.style({opacity:1}),r.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),a.cancel.call(t,this.textContent)):(a.input.call(t,this.textContent),r.select(this).call(E(t,i,e)))}).on("keydown",function(){13===r.event.which&&this.blur()}).call(l)}(),t.style({opacity:0});var i,s=o.attr("class");(i=s?"."+s.split(" ")[0]+"-math-group":"[class*=-math-group]")&&r.select(t.node().parentNode).select(i).style({opacity:0})}function l(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}return e.immediate?s():o.on("click",s),r.rebind(t,a,"on")}},{"../constants/alignment":141,"../constants/xmlns_namespaces":144,"../lib":162,d3:7}],184:[function(t,e,n){"use strict";var r={};function i(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}n.throttle=function(t,e,n){var a=r[t],o=Date.now();if(!a){for(var s in r)r[s].tsa.ts+e?l():a.timer=setTimeout(function(){l(),a.timer=null},e)},n.done=function(t){var e=r[t];return e&&e.timer?new Promise(function(t){var n=e.onDone;e.onDone=function(){n&&n(),t(),e.onDone=null}}):Promise.resolve()},n.clear=function(t){if(t)i(r[t]),delete r[t];else for(var e in r)n.clear(e)}},{}],185:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var n=Math.log(Math.min(e[0],e[1]))/Math.LN10;return r(n)||(n=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),n}},{"fast-isnumeric":9}],186:[function(t,e,n){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],187:[function(t,e,n){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],188:[function(t,e,n){"use strict";var r=t("../registry");e.exports=function(t){for(var e,n,i=r.layoutArrayContainers,a=r.layoutArrayRegexes,o=t.split("[")[0],s=0;s0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},n.cleanLayout=function(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var r=(s.subplotsRegistry.cartesian||{}).attrRegex,a=(s.subplotsRegistry.gl3d||{}).attrRegex,l=Object.keys(t);for(e=0;e3?(M.x=1.02,M.xanchor="left"):M.x<-2&&(M.x=-.02,M.xanchor="right"),M.y>3?(M.y=1.02,M.yanchor="bottom"):M.y<-2&&(M.y=-.02,M.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t},n.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}n.hasParent=function(t,e){for(var n=v(e);n;){if(n in t)return!0;n=v(n)}return!1};var _=["x","y","z"];n.clearAxisTypes=function(t,e,n){for(var r=0;r1&&o.warn("Full array edits are incompatible with other edits",f);var v=n[""][""];if(c(v))e.set(null);else{if(!Array.isArray(v))return o.warn("Unrecognized full array edit value",f,v),!0;e.set(v)}return!m&&(h(g,y),p(t),!0)}var _,x,b,w,k,T,A,M=Object.keys(n).map(Number).sort(s),S=e.get(),C=S||[],z=r(y,f).get(),E=[],L=-1,I=C.length;for(_=0;_C.length-(A?0:1))o.warn("index out of range",f,b);else if(void 0!==T)k.length>1&&o.warn("Insertion & removal are incompatible with edits to the same index.",f,b),c(T)?E.push(b):A?("add"===T&&(T={}),C.splice(b,0,T),z&&z.splice(b,0,{})):o.warn("Unrecognized full object edit value",f,b,T),-1===L&&(L=b);else for(x=0;x=0;_--)C.splice(E[_],1),z&&z.splice(E[_],1);if(C.length?S||e.set(C):e.set(null),m)return!1;if(h(g,y),d!==a){var P;if(-1===L)P=M;else{for(I=Math.max(C.length,I),P=[],_=0;_=L);_++)P.push(b);for(_=L;_=t.data.length||i<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(i,r+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||i<0&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+n+" must be unique.")}}function P(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),I(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&I(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function D(t,e,n,r,a){!function(t,e,n,r){var i=o.isPlainObject(r);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof n)throw new Error("indices must be an integer or array of integers");for(var a in I(t,n,"indices"),e){if(!Array.isArray(e[a])||e[a].length!==n.length)throw new Error("attribute "+a+" must be an array of length equal to indices array length");if(i&&(!(a in r)||!Array.isArray(r[a])||r[a].length!==e[a].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,n,r);for(var s=function(t,e,n,r){var a,s,l,u,c,f=o.isPlainObject(r),h=[];for(var p in Array.isArray(n)||(n=[n]),n=L(n,t.data.length-1),e)for(var d=0;d=0&&n=0&&n0&&"string"!=typeof z.parts[L];)L--;var I=z.parts[L],P=z.parts[L-1]+"."+I,D=z.parts.slice(0,L).join("."),O=o.nestedProperty(t.layout,D).get(),F=o.nestedProperty(s,D).get(),B=z.get();if(void 0!==E){v[C]=E,_[C]="reverse"===I?E:R(B);var N=c.getLayoutValObject(s,z.parts);if(N&&N.impliedEdits&&null!==E)for(var U in N.impliedEdits)x(o.relativeAttr(C,U),N.impliedEdits[U]);if(-1!==["width","height"].indexOf(C))if(E){x("autosize",null);var Z="height"===C?"width":"height";x(Z,s[Z])}else s[C]=t._initialAutoSize[C];else if("autosize"===C)x("width",E?null:s.width),x("height",E?null:s.height);else if(P.match(j))S(P),o.nestedProperty(s,D+"._inputRange").set(null);else if(P.match(V)){S(P),o.nestedProperty(s,D+"._inputRange").set(null);var G=o.nestedProperty(s,D).get();G._inputDomain&&(G._input.domain=G._inputDomain.slice())}else P.match(q)&&o.nestedProperty(s,D+"._inputDomain").set(null);if("type"===I){var $=O,W="linear"===F.type&&"log"===E,X="log"===F.type&&"linear"===E;if(W||X){if($&&$.range)if(F.autorange)W&&($.range=$.range[1]>$.range[0]?[1,2]:[2,1]);else{var Y=$.range[0],J=$.range[1];W?(Y<=0&&J<=0&&x(D+".autorange",!0),Y<=0?Y=J/1e6:J<=0&&(J=Y/1e6),x(D+".range[0]",Math.log(Y)/Math.LN10),x(D+".range[1]",Math.log(J)/Math.LN10)):(x(D+".range[0]",Math.pow(10,Y)),x(D+".range[1]",Math.pow(10,J)))}else x(D+".autorange",!0);Array.isArray(s._subplots.polar)&&s._subplots.polar.length&&s[z.parts[0]]&&"radialaxis"===z.parts[1]&&delete s[z.parts[0]]._subplot.viewInitial["radialaxis.range"],u.getComponentMethod("annotations","convertCoords")(t,F,E,x),u.getComponentMethod("images","convertCoords")(t,F,E,x)}else x(D+".autorange",!0),x(D+".range",null);o.nestedProperty(s,D+"._inputRange").set(null)}else if(I.match(A)){var K=o.nestedProperty(s,C).get(),Q=(E||{}).type;Q&&"-"!==Q||(Q="linear"),u.getComponentMethod("annotations","convertCoords")(t,K,Q,x),u.getComponentMethod("images","convertCoords")(t,K,Q,x)}var tt=b.containerArrayMatch(C);if(tt){n=tt.array,r=tt.index;var et=tt.property,nt=(o.nestedProperty(a,n)||[])[r]||{},rt=N||{editType:"calc"};""!==r&&""===et&&(b.isAddVal(E)?_[C]=null:b.isRemoveVal(E)?_[C]=nt:o.warn("unrecognized full object value",e)),T.update(y,rt),h[n]||(h[n]={});var it=h[n][r];it||(it=h[n][r]={}),it[et]=E,delete e[C]}else"reverse"===I?(O.range?O.range.reverse():(x(D+".autorange",!0),O.range=[1,0]),F.autorange?y.calc=!0:y.plot=!0):(s._has("scatter-like")&&s._has("regl")&&"dragmode"===C&&("lasso"===E||"select"===E)&&"lasso"!==B&&"select"!==B?y.plot=!0:N?T.update(y,N):y.calc=!0,z.set(E))}}for(n in h){b.applyContainerArrayChanges(t,o.nestedProperty(a,n),h[n],y)||(y.plot=!0)}var at=s._axisConstraintGroups||[];for(k in M)for(r=0;r=i.length?i[0]:i[t]:i}function l(t){return Array.isArray(a)?t>=a.length?a[0]:a[t]:a}function u(t,e){var n=0;return function(){if(t&&++n===e)return t()}}return void 0===r._frameWaitingCnt&&(r._frameWaitingCnt=0),new Promise(function(a,c){function h(){r._currentFrame&&r._currentFrame.onComplete&&r._currentFrame.onComplete();var e=r._currentFrame=r._frameQueue.shift();if(e){var n=e.name?e.name.toString():null;t._fullLayout._currentFrame=n,r._lastFrameAt=Date.now(),r._timeToNext=e.frameOpts.duration,f.transition(t,e.frame.data,e.frame.layout,w.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:n,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(r._animationRaf),r._animationRaf=null}function p(){t.emit("plotly_animating"),r._lastFrameAt=-1/0,r._timeToNext=0,r._runningTransitions=0,r._currentFrame=null;var e=function(){r._animationRaf=window.requestAnimationFrame(e),Date.now()-r._lastFrameAt>r._timeToNext&&h()};e()}var d,m,g=0;function y(t){return Array.isArray(i)?g>=i.length?t.transitionOpts=i[g]:t.transitionOpts=i[0]:t.transitionOpts=i,g++,t}var v=[],_=null==e,x=Array.isArray(e);if(!_&&!x&&o.isPlainObject(e))v.push({type:"object",data:y(o.extendFlat({},e))});else if(_||-1!==["string","number"].indexOf(typeof e))for(d=0;d0&&TT)&&A.push(m);v=A}}v.length>0?function(e){if(0!==e.length){for(var i=0;i=0;r--)if(o.isPlainObject(e[r])){var m=e[r].name,g=(c[m]||d[m]||{}).name,y=e[r].name,v=c[g]||d[g];g&&y&&"number"==typeof y&&v&&M<5&&(M++,o.warn('addFrames: overwriting frame "'+(c[g]||d[g]).name+'" with a frame whose name of type "number" also equates to "'+g+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===M&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),d[m]={name:m},p.push({frame:f.supplyFrameDefaults(e[r]),index:n&&void 0!==n[r]&&null!==n[r]?n[r]:h+r})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;r--){if("number"==typeof(i=p[r].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!i.name)for(;c[i.name="frame "+t._transitionData._counter++];);if(c[i.name]){for(a=0;a=0;n--)r=e[n],a.push({type:"delete",index:r}),s.unshift({type:"insert",index:r,value:i[r]});var u=f.modifyFrames,c=f.modifyFrames,h=[t,s],p=[t,a];return l&&l.add(t,u,h,c,p),f.modifyFrames(t,a)},n.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},n=t._fullData||[];return f.cleanPlot([],{},n,e),f.purge(t),s.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":43,"../components/colorbar/connect":45,"../components/drawing":68,"../constants/xmlns_namespaces":144,"../lib":162,"../lib/events":154,"../lib/queue":176,"../lib/svg_text_utils":183,"../plots/cartesian/axes":206,"../plots/cartesian/constants":212,"../plots/cartesian/graph_interact":216,"../plots/plots":246,"../plots/polar/legacy":249,"../registry":254,"./edit_types":189,"./helpers":190,"./manage_arrays":192,"./plot_config":194,"./plot_schema":195,"./subroutines":197,d3:7,"fast-isnumeric":9,"has-hover":11}],194:[function(t,e,n){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],195:[function(t,e,n){"use strict";var r=t("../registry"),i=t("../lib"),a=t("../plots/attributes"),o=t("../plots/layout_attributes"),s=t("../plots/frame_attributes"),l=t("../plots/animation_attributes"),u=t("../plots/polar/legacy/area_attributes"),c=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),h=i.extendFlat,p=i.extendDeepAll,d=i.isPlainObject,m="_isSubplotObj",g="_isLinkedToArray",y=[m,g,"_arrayAttrRegexps","_deprecated"];function v(t,e,n){if(!t)return!1;if(t._isLinkedToArray)if(_(e[n]))n++;else if(n=a.length)return!1;if(2===t.dimensions){if(n++,e.length===n)return t;var o=e[n];if(!_(o))return!1;t=a[i][o]}else t=a[i]}else t=a}}return t}function _(t){return t===Math.round(t)&&t>=0}function x(t){return function(t){n.crawl(t,function(t,e,r){n.isValObject(t)?"data_array"===t.valType?(t.role="data",r[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(r[e+"src"]={valType:"string",editType:"none"}):d(t)&&(t.role="object")})}(t),function(t){n.crawl(t,function(t,e,n){if(!t)return;var r=t[g];if(!r)return;delete t[g],n[e]={items:{}},n[e].items[r]=t,n[e].role="object"})}(t),function(t){!function t(e){for(var n in e)if(d(e[n]))t(e[n]);else if(Array.isArray(e[n]))for(var r=0;r=l.length)return!1;i=(n=(r.transformsRegistry[l[c].type]||{}).attributes)&&n[e[2]],s=3}else if("area"===t.type)i=u[o];else{var f=t._module;if(f||(f=(r.modules[t.type||a.type.dflt]||{})._module),!f)return!1;if(!(i=(n=f.attributes)&&n[o])){var h=f.basePlotModule;h&&h.attributes&&(i=h.attributes[o])}i||(i=a[o])}return v(i,e,s)},n.getLayoutValObject=function(t,e){return v(function(t,e){var n,i,a,s,l=t._basePlotModules;if(l){var u;for(n=0;n=i&&(n._input||{})._templateitemname;s&&(o=i);var l,u=e+"["+o+"]";function c(){l={},s&&(l[u]={},l[u][a]=s)}function f(t,e){s?r.nestedProperty(l[u],t).set(e):l[u+"."+t]=e}function h(){var t=l;return c(),t}return c(),{modifyBase:function(t,e){l[t]=e},modifyItem:f,getUpdateObj:h,applyUpdate:function(e,n){e&&f(e,n);var i=h();for(var a in i)r.nestedProperty(t,a).set(i[a])}}}},{"../lib":162,"../plots/attributes":203}],197:[function(t,e,n){"use strict";var r=t("d3"),i=t("../registry"),a=t("../plots/plots"),o=t("../lib"),s=t("../lib/clear_gl_canvases"),l=t("../components/color"),u=t("../components/drawing"),c=t("../components/titles"),f=t("../components/modebar"),h=t("../plots/cartesian/axes"),p=t("../constants/alignment"),d=t("../plots/cartesian/constraints"),m=d.enforce,g=d.clean,y=t("../plots/cartesian/autorange").doAutoRange;function v(t,e,n){for(var r=0;r=t[1]||i[1]<=t[0])&&(a[0]e[0]))return!0}return!1}function _(t){var e,i,a,s,c,d=t._fullLayout,m=d._size,g=m.p,y=h.list(t,"",!0);if(d._paperdiv.style({width:t._context.responsive&&d.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":d.width+"px",height:t._context.responsive&&d.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":d.height+"px"}).selectAll(".main-svg").call(u.setSize,d.width,d.height),t._context.setBackground(t,d.paper_bgcolor),n.drawMainTitle(t),f.manage(t),!d._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function _(t,e,n){var r=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===n?e._offset-g-r:e._offset+e._length+g+r:m.t+m.h*(1-(t.position||0))+r%1:e?"right"===n?e._offset+e._length+g+r:e._offset-g-r:m.l+m.w*(t.position||0)+r%1}for(e=0;ek?c.push({code:"unused",traceType:v,templateCount:w,dataCount:k}):k>w&&c.push({code:"reused",traceType:v,templateCount:w,dataCount:k})}}else c.push({code:"data"});if(function t(e,n){for(var r in e)if("_"!==r.charAt(0)){var a=e[r],o=p(e,r,n);i(a)?(Array.isArray(e)&&!1===a._template&&a.templateitemname&&c.push({code:"missing",path:o,templateitemname:a.templateitemname}),t(a,o)):Array.isArray(a)&&d(a)&&t(a,o)}}({data:g,layout:h},""),c.length)return c.map(m)}},{"../lib":162,"../plots/attributes":203,"../plots/plots":246,"./plot_config":194,"./plot_schema":195,"./plot_template":196}],199:[function(t,e,n){"use strict";var r=t("./plot_api"),i=t("../lib"),a=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),s=t("../snapshot/svgtoimg"),l={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},u=/^data:image\/\w+;base64,/;e.exports=function(t,e){var n,c,f;function h(t){return!(t in e)||i.validate(e[t],l[t])}if(e=e||{},i.isPlainObject(t)?(n=t.data||[],c=t.layout||{},f=t.config||{}):(t=i.getGraphDiv(t),n=i.extendDeep([],t.data),c=i.extendDeep({},t.layout),f=t._context),!h("width")||!h("height"))throw new Error("Height and width should be pixel values.");if(!h("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function d(t,n){return i.coerce(e,p,l,t,n)}var m=d("format"),g=d("width"),y=d("height"),v=d("scale"),_=d("setBackground"),x=d("imageDataOnly"),b=document.createElement("div");b.style.position="absolute",b.style.left="-5000px",document.body.appendChild(b);var w=i.extendFlat({},c);g&&(w.width=g),y&&(w.height=y);var k=i.extendFlat({},f,{staticPlot:!0,setBackground:_}),T=a.getRedrawFunc(b);function A(){return new Promise(function(t){setTimeout(t,a.getDelay(b._fullLayout))})}function M(){return new Promise(function(t,e){var n=o(b,m,v),a=b._fullLayout.width,l=b._fullLayout.height;if(r.purge(b),document.body.removeChild(b),"svg"===m)return t(x?n:"data:image/svg+xml,"+encodeURIComponent(n));var u=document.createElement("canvas");u.id=i.randstr(),s({format:m,width:a,height:l,scale:v,canvas:u,svg:n,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){r.plot(b,n,w,k).then(T).then(A).then(M).then(function(e){t(function(t){return x?t.replace(u,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":162,"../snapshot/helpers":258,"../snapshot/svgtoimg":260,"../snapshot/tosvg":262,"./plot_api":193}],200:[function(t,e,n){"use strict";var r=t("../lib"),i=t("../plots/plots"),a=t("./plot_schema"),o=t("./plot_config"),s=r.isPlainObject,l=Array.isArray,u=r.isArrayOrTypedArray;function c(t,e,n,i,a,o){o=o||[];for(var f=Object.keys(t),h=0;h_.length&&i.push(p("unused",a,y.concat(_.length)));var T,A,M,S,C,z=_.length,E=Array.isArray(k);if(E&&(z=Math.min(z,k.length)),2===x.dimensions)for(A=0;A_[A].length&&i.push(p("unused",a,y.concat(A,_[A].length)));var L=_[A].length;for(T=0;T<(E?Math.min(L,k[A].length):L);T++)M=E?k[A][T]:k,S=v[A][T],C=_[A][T],r.validate(S,M)?C!==S&&C!==+S&&i.push(p("dynamic",a,y.concat(A,T),S,C)):i.push(p("value",a,y.concat(A,T),S))}else i.push(p("array",a,y.concat(A),v[A]));else for(A=0;A1&&h.push(p("object","layout"))),i.supplyDefaults(d);for(var m=d._fullData,g=n.length,y=0;y0&&((x=A-o(g)-o(y))>M?b/x>S&&(v=g,_=y,S=b/x):b/A>S&&(v={val:g.val,pad:0},_={val:y.val,pad:0},S=b/A));if(h===p){var C=h-1,z=h+1;if(k)if(0===h)a=[0,1];else{var E=(h>0?f:c).reduce(function(t,e){return Math.max(t,o(e))},0),L=h/(1-Math.min(.5,E/A));a=h>0?[0,L]:[L,0]}else a=T?[Math.max(0,C),Math.max(1,z)]:[C,z]}else k?(v.val>=0&&(v={val:0,pad:0}),_.val<=0&&(_={val:0,pad:0})):T&&(v.val-S*o(v)<0&&(v={val:0,pad:0}),_.val<=0&&(_={val:1,pad:0})),S=(_.val-v.val)/(A-o(v)-o(_)),a=[v.val-S*o(v),_.val+S*o(_)];return d&&a.reverse(),i.simpleMap(a,e.l2r||Number)}function s(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function l(t,e){var n,r,i,a=e._id,o=t._fullData,s=t._fullLayout,l=[],f=[];function h(t,e){for(n=0;n=n&&(u.extrapad||!o)){s=!1;break}i(e,u.val)&&u.pad<=n&&(o||!u.extrapad)&&(t.splice(l,1),l--)}if(s){var c=a&&0===e;t.push({val:e,pad:c?0:n,extrapad:!c&&o})}}function h(t){return r(t)&&Math.abs(t)=e}e.exports={getAutoRange:o,makePadFn:s,doAutoRange:function(t,e){e._length||e.setScale();var n;e.autorange&&(e.range=o(t,e),e._r=e.range.slice(),e._rl=i.simpleMap(e._r,e.r2l),(n=e._input).range=e.range.slice(),n.autorange=e.autorange);if(e._anchorAxis&&e._anchorAxis.rangeslider){var r=e._anchorAxis.rangeslider[e._name];r&&"auto"===r.rangemode&&(r.range=o(t,e)),(n=e._anchorAxis._input).rangeslider[e._name]=i.extendFlat({},r)}},findExtremes:function(t,e,n){n||(n={});t._m||t.setScale();var i,o,s,l,f,p,d,m,g,y=[],v=[],_=e.length,x=n.padded||!1,b=n.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function T(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var A=T((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),M=T((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),S=T(n.vpadplus||n.vpad),C=T(n.vpadminus||n.vpad);if(!k){if(m=1/0,g=-1/0,w)for(i=0;i<_;i++)(o=e[i])0&&(m=o),o>g&&o-a&&(m=o),o>g&&o=L;i--)E(i);return{min:y,max:v}},concatExtremes:l}},{"../../constants/numerical":143,"../../lib":162,"fast-isnumeric":9}],206:[function(t,e,n){"use strict";var r=t("d3"),i=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../../components/titles"),c=t("../../components/color"),f=t("../../components/drawing"),h=t("./layout_attributes"),p=t("./clean_ticks"),d=t("../../constants/numerical"),m=d.ONEAVGYEAR,g=d.ONEAVGMONTH,y=d.ONEDAY,v=d.ONEHOUR,_=d.ONEMIN,x=d.ONESEC,b=d.MINUS_SIGN,w=d.BADNUM,k=t("../../constants/alignment").MID_SHIFT,T=t("../../constants/alignment").LINE_SPACING,A=e.exports={};A.setConvert=t("./set_convert");var M=t("./axis_autotype"),S=t("./axis_ids");A.id2name=S.id2name,A.name2id=S.name2id,A.cleanId=S.cleanId,A.list=S.list,A.listIds=S.listIds,A.getFromId=S.getFromId,A.getFromTrace=S.getFromTrace;var C=t("./autorange");A.getAutoRange=C.getAutoRange,A.findExtremes=C.findExtremes,A.coerceRef=function(t,e,n,r,i,a){var o=r.charAt(r.length-1),l=n._fullLayout._subplots[o+"axis"],u=r+"ref",c={};return i||(i=l[0]||a),a||(a=i),c[u]={valType:"enumerated",values:l.concat(a?[a]:[]),dflt:i},s.coerce(t,e,c,u)},A.coercePosition=function(t,e,n,r,i,a){var o,l;if("paper"===r||"pixel"===r)o=s.ensureNumber,l=n(i,a);else{var u=A.getFromId(e,r);l=n(i,a=u.fraction2r(a)),o=u.cleanPos}t[i]=o(l)},A.cleanPosition=function(t,e,n){return("paper"===n||"pixel"===n?s.ensureNumber:A.getFromId(e,n).cleanPos)(t)};var z=A.getDataConversions=function(t,e,n,r){var i,a="x"===n||"y"===n||"z"===n?n:r;if(Array.isArray(a)){if(i={type:M(r),_categories:[]},A.setConvert(i),"category"===i.type)for(var o=0;o2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},A.saveRangeInitial=function(t,e){for(var n=A.list(t,"",!0),r=!1,i=0;i.3*h||c(r)||c(a))){var p=n.dtick/2;t+=t+p.8){var o=Number(n.substr(1));a.exactYears>.8&&o%12==0?t=A.tickIncrement(t,"M6","reverse")+1.5*y:a.exactMonths>.8?t=A.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var l=A.tickIncrement(t,n);if(l<=r)return l}return t}(_,t,v,u,a)),g=_,0;g<=c;)g=A.tickIncrement(g,v,!1,a),0;return{start:e.c2r(_,0,a),end:e.c2r(g,0,a),size:v,_dataSpan:c-u}},A.prepTicks=function(t){var e=s.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var n,r=t.nticks;r||("category"===t.type?(n=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/n):(n="y"===t._id.charAt(0)?40:80,r=s.constrain(t._length/n,4,9)+1),"radialaxis"===t._name&&(r*=2)),"array"===t.tickmode&&(r*=100),A.autoTicks(t,Math.abs(e[1]-e[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},A.calcTicks=function(t){A.prepTicks(t);var e=s.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e,n,r=t.tickvals,i=t.ticktext,a=new Array(r.length),o=s.simpleMap(t.range,t.r2l),l=1.0001*o[0]-1e-4*o[1],u=1.0001*o[1]-1e-4*o[0],c=Math.min(l,u),f=Math.max(l,u),h=0;Array.isArray(i)||(i=[]);var p="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(n=0;nc&&e=r:u<=r)&&!(a.length>l||u===o);u=A.tickIncrement(u,t.dtick,i,t.calendar))o=u,a.push(u);Y(t)&&360===Math.abs(e[1]-e[0])&&a.pop(),t._tmax=a[a.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var c=new Array(a.length),f=0;f10||"01-01"!==r.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&a<=10||e>=15*y)t._tickround="d";else if(e>=_&&a<=16||e>=v)t._tickround="M";else if(e>=x&&a<=19||e>=_)t._tickround="S";else{var o=t.l2r(n+e).replace(/^-/,"").length;t._tickround=Math.max(a,o)-20,t._tickround<0&&(t._tickround=4)}}else if(i(e)||"L"===e.charAt(0)){var s=t.range.map(t.r2d||Number);i(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var l=Math.max(Math.abs(s[0]),Math.abs(s[1])),u=Math.floor(Math.log(l)/Math.LN10+.01);Math.abs(u)>3&&(U(t.exponentformat)&&!H(u)?t._tickexponent=3*Math.round((u-1)/3):t._tickexponent=u)}else t._tickround=null}function V(t,e,n){var r=t.tickfont||{};return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}A.autoTicks=function(t,e){var n;function r(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=s.dateTick0(t.calendar);var a=2*e;a>m?(e/=m,n=r(10),t.dtick="M"+12*N(e,n,I)):a>g?(e/=g,t.dtick="M"+N(e,1,P)):a>y?(t.dtick=N(e,y,O),t.tick0=s.dateTick0(t.calendar,!0)):a>v?t.dtick=N(e,v,P):a>_?t.dtick=N(e,_,D):a>x?t.dtick=N(e,x,D):(n=r(10),t.dtick=N(e,n,I))}else if("log"===t.type){t.tick0=0;var o=s.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var l=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/l,n=r(10),t.dtick="L"+N(e,n,I)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):Y(t)?(t.tick0=0,n=1,t.dtick=N(e,n,B)):(t.tick0=0,n=r(10),t.dtick=N(e,n,I));if(0===t.dtick&&(t.dtick=1),!i(t.dtick)&&"string"!=typeof t.dtick){var u=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(u)}},A.tickIncrement=function(t,e,n,a){var o=n?-1:1;if(i(e))return t+o*e;var l=e.charAt(0),u=o*Number(e.substr(1));if("M"===l)return s.incrementMonth(t,u,a);if("L"===l)return Math.log(Math.pow(10,t)+u)/Math.LN10;if("D"===l){var c="D2"===e?F:R,f=t+.01*o,h=s.roundUp(s.mod(f,1),c,n);return Math.floor(f)+Math.log(r.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(e)},A.tickFirst=function(t){var e=t.r2l||Number,n=s.simpleMap(t.range,e),a=n[1]"+l,t._prevDateHead=l));e.text=u}(t,o,n,u):"log"===t.type?function(t,e,n,r,a){var o=t.dtick,l=e.x,u=t.tickformat,c="string"==typeof o&&o.charAt(0);"never"===a&&(a="");r&&"L"!==c&&(o="L3",c="L");if(u||"L"===c)e.text=Z(Math.pow(10,l),t,a,r);else if(i(o)||"D"===c&&s.mod(l+.01,1)<.1){var f=Math.round(l),h=Math.abs(f),p=t.exponentformat;"power"===p||U(p)&&H(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":b)+h+"",e.fontSize*=1.25):("e"===p||"E"===p)&&h>2?e.text="1"+p+(f>0?"+":b)+h:(e.text=Z(Math.pow(10,l),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==c)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,s.mod(l,1)))),e.fontSize*=.75}if("D1"===t.dtick){var d=String(e.text).charAt(0);"0"!==d&&"1"!==d||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(l<0?.5:.25)))}}(t,o,0,u,r):"category"===t.type?function(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n="");e.text=String(n)}(t,o):Y(t)?function(t,e,n,r,i){if("radians"!==t.thetaunit||n)e.text=Z(e.x,t,i,r);else{var a=e.x/180;if(0===a)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var n=function(t){var n=1;for(;!e(Math.round(t*n)/n,t);)n*=10;return n}(t),r=t*n,i=Math.abs(function t(n,r){return e(r,0)?n:t(r,n%r)}(r,n));return[Math.round(r/i),Math.round(n/i)]}(a);if(o[1]>=100)e.text=Z(s.deg2rad(e.x),t,i,r);else{var l=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),l&&(e.text=b+e.text)}}}}(t,o,n,u,r):function(t,e,n,r,i){"never"===i?i="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide");e.text=Z(e.x,t,i,r)}(t,o,0,u,r),t.tickprefix&&!p(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!p(t.showticksuffix)&&(o.text+=t.ticksuffix),o},A.hoverLabelText=function(t,e,n){if(n!==w&&n!==e)return A.hoverLabelText(t,e)+" - "+A.hoverLabelText(t,n);var r="log"===t.type&&e<=0,i=A.tickText(t,t.c2l(r?-e:e),"hover").text;return r?0===e?"0":b+i:i};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function U(t){return"SI"===t||"B"===t}function H(t){return t>14||t<-15}function Z(t,e,n,r){var a=t<0,o=e._tickround,l=n||e.exponentformat||"B",u=e._tickexponent,c=A.getTickFormat(e),f=e.separatethousands;if(r){var h={exponentformat:l,dtick:"none"===e.showexponent?e.dtick:i(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(h),o=(Number(h._tickround)||0)+4,u=h._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return e._numFormat(c)(t).replace(/-/g,b);var p,d=Math.pow(10,-o)/2;if("none"===l&&(u=0),(t=Math.abs(t))"+p+"":"B"===l&&9===u?t+="B":U(l)&&(t+=q[u/3+5]));return a?b+t:t}function G(t,e){var n=t.l2p(e);return n>1&&n=0,a=c(t,e[1])<=0;return(n||i)&&(r||a)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(i)))){n=r;break}break;case"log":for(e=0;e1)for(r=1;r2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),n=0,r=0,o={},s=0;s2*n}(t)?"category":function(t){if(!t)return!1;for(var e=0;er?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":254,"./constants":212}],210:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){if("category"===e.type){var i,a=t.categoryarray,o=Array.isArray(a)&&a.length>0;o&&(i="array");var s,l=n("categoryorder",i);"array"===l&&(s=n("categoryarray")),o||"array"!==l||(l=e.categoryorder="trace"),"trace"===l?e._initialCategories=[]:"array"===l?e._initialCategories=s.slice():(s=function(t,e){var n,r,i,a=e.dataAttr||t._id.charAt(0),o={};if(e.axData)n=e.axData;else for(n=[],r=0;rs*_)||k)for(n=0;nP&&RL&&(L=R);p/=(L-E)/(2*I),E=c.l2r(E),L=c.l2r(L),c.range=c._input.range=S=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function D(t,e,n,r,i){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+n+", "+r+")").attr("d",i+"Z")}function O(t,e,n){return t.append("path").attr("class","zoombox-corners").style({fill:u.background,stroke:u.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+n+")").attr("d","M0,0Z")}function R(t,e,n,r,i,a){t.attr("d",r+"M"+n.l+","+n.t+"v"+n.h+"h"+n.w+"v-"+n.h+"h-"+n.w+"Z"),F(t,e,i,a)}function F(t,e,n,r){n||(t.transition().style("fill",r>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function B(t){r.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function N(t){S&&t.data&&t._context.showTips&&(s.notifier(s._(t,"Double-click to zoom back out"),"long"),S=!1)}function j(t){return"lasso"===t||"select"===t}function V(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,M)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(a){var n=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(n,t._onwheel),t._onwheel=e,t.addEventListener(n,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function U(t){var e=[];for(var n in t)e.push(t[n]);return e}e.exports={makeDragBox:function(t,e,n,a,u,h,S,C){var F,H,Z,G,$,W,X,Y,J,K,Q,tt,et,nt,rt,it,at,ot,st,lt,ut,ct=t._fullLayout._zoomlayer,ft=S+C==="nsew",ht=1===(S+C).length;function pt(){if(F=e.xaxis,H=e.yaxis,J=F._length,K=H._length,X=F._offset,Y=H._offset,(Z={})[F._id]=F,(G={})[H._id]=H,S&&C)for(var n=e.overlays,r=0;r-1&&w(i,t,$,W,e.id,Mt),a.indexOf("event")>-1&&f.click(t,i,e.id);else if(1===n&&ht){var s=S?H:F,u="s"===S||"w"===C?0:1,c=s._name+".range["+u+"]",h=function(t,e){var n,i=t.range[e],a=Math.abs(i-t.range[1-e]);return"date"===t.type?i:"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,r.format("."+n+"g")(Math.pow(10,i))):(n=Math.floor(Math.log(Math.abs(i))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,r.format("."+String(n)+"g")(i))}(s,u),p="left",d="middle";if(s.fixedrange)return;S?(d="n"===S?"top":"bottom","right"===s.side&&(p="right")):"e"===C&&(p="right"),t._context.showAxisRangeEntryBoxes&&r.select(mt).call(l.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(h),fill:s.tickfont?s.tickfont.color:"#444",horizontalAlign:p,verticalAlign:d}).on("edit",function(e){var n=s.d2r(e);void 0!==n&&o.call("relayout",t,c,n)})}}function zt(e,n){if(t._transitioningWithDuration)return!1;var r=Math.max(0,Math.min(J,e+gt)),i=Math.max(0,Math.min(K,n+yt)),a=Math.abs(r-gt),o=Math.abs(i-yt);function s(){wt="",vt.r=vt.l,vt.t=vt.b,Tt.attr("d","M0,0Z")}vt.l=Math.min(gt,r),vt.r=Math.max(gt,r),vt.t=Math.min(yt,i),vt.b=Math.max(yt,i),rt?a>M||o>M?(wt="xy",a/J>o/K?(o=a*K/J,yt>i?vt.t=yt-o:vt.b=yt+o):(a=o*J/K,gt>r?vt.l=gt-a:vt.r=gt+a),Tt.attr("d",V(vt))):s():!et||o10||n.scrollWidth-n.clientWidth>10)){clearTimeout(Dt);var r=-e.deltaY;if(isFinite(r)||(r=e.wheelDelta/10),isFinite(r)){var i,a=Math.exp(-Math.min(Math.max(r,-20),20)/200),o=Rt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-o.left)/o.width,u=(o.bottom-e.clientY)/o.height;if(it){for(C||(l=.5),i=0;i<$.length;i++)c($[i],l,a);Pt[2]*=a,Pt[0]+=Pt[2]*l*(1/a-1)}if(at){for(S||(u=.5),i=0;im[1]-.01&&(e.domain=s),i.noneOrAll(t.domain,e.domain,s)}return n("layer"),e}},{"../../lib":162,"fast-isnumeric":9}],223:[function(t,e,n){"use strict";var r=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,n){void 0===n&&(n=r[t.constraintoward||"center"]);var i=[t.r2l(t.range[0]),t.r2l(t.range[1])],a=i[0]+(i[1]-i[0])*n;t.range=t._input.range=[t.l2r(a+(i[0]-a)*e),t.l2r(a+(i[1]-a)*e)]}},{"../../constants/alignment":141}],224:[function(t,e,n){"use strict";var r=t("polybooljs"),i=t("../../registry"),a=t("../../components/color"),o=t("../../components/fx"),s=t("../../lib/polygon"),l=t("../../lib/throttle"),u=t("../../components/fx/helpers").makeEventData,c=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),h=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),d=p.MINSELECT,m=s.filter,g=s.tester;function y(t){return t._id}function v(t,e,n,r,i,a,o){var s,l,u,c,f,h,p,d,m,g=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,v=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(g)){w(t,e,a);var _=function(t,e){var n,r,i=t[0],a=-1,o=[];for(r=0;r0?function(t,e){var n,r,i,a=[];for(i=0;i0&&a.push(n);if(1===a.length&&a[0]===e.searchInfo&&(r=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(i=0;i1)return!1;if((i+=n.selectedpoints.length)>1)return!1}return 1===i}(s)&&(h=M(_))){for(o&&o.remove(),m=0;m0?"M"+i.join("M")+"Z":"M0,0Z",e.attr("d",r)}function M(t){var e=t.searchInfo.cd[0].trace,n=t.pointNumber,r=t.pointNumbers,i=r.length>0?r[0]:n;return!!e.selectedpoints&&e.selectedpoints.indexOf(i)>-1}function S(t,e,n){var r,a,o,s;if(n){var l=n.points||[];for(r=0;r-1&&v(e,M,i.xaxes,i.yaxes,i.subplot,i,H),"event"===n&&M.emit("plotly_selected",void 0);o.click(M,e)})},i.doneFn=function(){G.remove(),l.done($).then(function(){l.clear($),i.gd.emit("plotly_selected",x),h&&i.selectionDefs&&(h.subtract=U,i.selectionDefs.push(h),i.mergedPolygons.length=0,[].push.apply(i.mergedPolygons,f))})}},clearSelect:z,selectOnClick:v}},{"../../components/color":43,"../../components/fx":85,"../../components/fx/helpers":82,"../../lib/clear_gl_canvases":150,"../../lib/polygon":174,"../../lib/throttle":184,"../../plot_api/subroutines":197,"../../registry":254,"./axis_ids":209,"./constants":212,polybooljs:17}],225:[function(t,e,n){"use strict";var r=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=a.cleanNumber,s=a.ms2DateTime,l=a.dateTime2ms,u=a.ensureNumber,c=t("../../constants/numerical"),f=c.FP_SAFE,h=c.BADNUM,p=c.LOG_CLIP,d=t("./constants"),m=t("./axis_ids");function g(t){return Math.pow(10,t)}e.exports=function(t,e){e=e||{};var n=(t._id||"x").charAt(0);function c(e,n){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&n&&t.range&&2===t.range.length){var r=t.range[0],i=t.range[1];return.5*(r+i-2*p*Math.abs(r-i))}return h}function y(e,n,r){var o=l(e,r||t.calendar);if(o===h){if(!i(e))return h;e=+e;var s=Math.floor(10*a.mod(e+.05,1)),u=Math.round(e-s/10);o=l(new Date(u))+s/10}return o}function v(e,n,r){return s(e,n,r||t.calendar)}function _(e){return t._categories[Math.round(e)]}function x(e){if(t._categoriesMap){var n=t._categoriesMap[e];if(void 0!==n)return n}if(i(e))return+e}function b(e){return i(e)?r.round(t._b+t._m*e,2):h}function w(e){return(e-t._b)/t._m}t.c2l="log"===t.type?c:u,t.l2c="log"===t.type?g:u,t.l2p=b,t.p2l=w,t.c2p="log"===t.type?function(t,e){return b(c(t,e))}:b,t.p2c="log"===t.type?function(t){return g(w(t))}:w,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=u,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=w,t.cleanPos=u):"log"===t.type?(t.d2r=t.d2l=function(t,e){return c(o(t),e)},t.r2d=t.r2c=function(t){return g(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=u,t.c2r=c,t.l2d=g,t.d2p=function(e,n){return t.l2p(t.d2r(e,n))},t.p2d=function(t){return g(w(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=w,t.cleanPos=u):"date"===t.type?(t.d2r=t.r2d=a.identity,t.d2c=t.r2c=t.d2l=t.r2l=y,t.c2d=t.c2r=t.l2d=t.l2r=v,t.d2p=t.r2p=function(e,n,r){return t.l2p(y(e,0,r))},t.p2d=t.p2r=function(t,e,n){return v(w(t),e,n)},t.cleanPos=function(e){return a.cleanDate(e,h,t.calendar)}):"category"===t.type&&(t.d2c=t.d2l=function(e){if(null!=e){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var n=t._categories.length-1;return t._categoriesMap[e]=n,n}return h},t.r2d=t.c2d=t.l2d=_,t.d2r=t.d2l_noadd=x,t.r2c=function(e){var n=x(e);return void 0!==n?n:t.fraction2r(.5)},t.l2r=t.c2r=u,t.r2l=x,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return _(w(t))},t.r2p=t.d2p,t.p2r=w,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:u(t)}),t.fraction2r=function(e){var n=t.r2l(t.range[0]),r=t.r2l(t.range[1]);return t.l2r(n+e*(r-n))},t.r2fraction=function(e){var n=t.r2l(t.range[0]),r=t.r2l(t.range[1]);return(t.r2l(e)-n)/(r-n)},t.cleanRange=function(e,r){r||(r={}),e||(e="range");var o,s,l=a.nestedProperty(t,e).get();if(s=(s="date"===t.type?a.dfltRange(t.calendar):"y"===n?d.DFLTRANGEY:r.dfltRange||d.DFLTRANGEX).slice(),l&&2===l.length)for("date"===t.type&&(l[0]=a.cleanDate(l[0],h,t.calendar),l[1]=a.cleanDate(l[1],h,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!a.isDateTime(l[o],t.calendar)){t[e]=s;break}if(t.r2l(l[0])===t.r2l(l[1])){var u=a.constrain(t.r2l(l[0]),a.MIN_MS+1e3,a.MAX_MS-1e3);l[0]=t.l2r(u-1e3),l[1]=t.l2r(u+1e3);break}}else{if(!i(l[o])){if(!i(l[1-o])){t[e]=s;break}l[o]=l[1-o]*(o?10:.1)}if(l[o]<-f?l[o]=-f:l[o]>f&&(l[o]=f),l[0]===l[1]){var c=Math.max(1,Math.abs(1e-6*l[0]));l[0]-=c,l[1]+=c}}else a.nestedProperty(t,e).set(s)},t.setScale=function(r){var i=e._size;if(t._categories||(t._categories=[]),t._categoriesMap||(t._categoriesMap={}),t.overlaying){var a=m.getFromId({_fullLayout:e},t.overlaying);t.domain=a.domain}var o=r&&t._r?"_r":"range",s=t.calendar;t.cleanRange(o);var l=t.r2l(t[o][0],s),u=t.r2l(t[o][1],s);if("y"===n?(t._offset=i.t+(1-t.domain[1])*i.h,t._length=i.h*(t.domain[1]-t.domain[0]),t._m=t._length/(l-u),t._b=-t._m*u):(t._offset=i.l+t.domain[0]*i.w,t._length=i.w*(t.domain[1]-t.domain[0]),t._m=t._length/(u-l),t._b=-t._m*l),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,n){var r,i,o,s,l=t.type,u="date"===l&&e[n+"calendar"];if(n in e){if(r=e[n],s=e._length||r.length,a.isTypedArray(r)&&("linear"===l||"log"===l)){if(s===r.length)return r;if(r.subarray)return r.subarray(0,s)}for(i=new Array(s),o=0;o rect").call(a.setTranslate,0,0).call(a.setScale,1,1),t.plot.call(a.setTranslate,e._offset,n._offset).call(a.setScale,1,1);var r=t.plot.selectAll(".scatterlayer .trace");r.selectAll(".point").call(a.setPointGroupScale,1,1),r.selectAll(".textpoint").call(a.setTextPointsScale,1,1),r.call(a.hideOutsideRangePoints,t)}function _(e,n){var r,s,l,c=m[e.xaxis._id],f=m[e.yaxis._id],h=[];if(c){s=(r=t._fullLayout[c.axisName])._r,l=c.to,h[0]=(s[0]*(1-n)+n*l[0]-s[0])/(s[1]-s[0])*e.xaxis._length;var p=s[1]-s[0],d=l[1]-l[0];r.range[0]=s[0]*(1-n)+n*l[0],r.range[1]=s[1]*(1-n)+n*l[1],h[2]=e.xaxis._length*(1-n+n*d/p)}else h[0]=0,h[2]=e.xaxis._length;if(f){s=(r=t._fullLayout[f.axisName])._r,l=f.to,h[1]=(s[1]*(1-n)+n*l[1]-s[1])/(s[0]-s[1])*e.yaxis._length;var g=s[1]-s[0],y=l[1]-l[0];r.range[0]=s[0]*(1-n)+n*l[0],r.range[1]=s[1]*(1-n)+n*l[1],h[3]=e.yaxis._length*(1-n+n*y/g)}else h[1]=0,h[3]=e.yaxis._length;!function(e,n){var r,a=[];for(a=[e._id,n._id],r=0;rn.duration?(function(){for(var e={},n=0;n0&&(i["_"+n+"axes"]||{})[e])return i;if((i[n+"axis"]||n)===e){if(o(i,n))return i;if((i[n]||[]).length||i[n+"0"])return i}}}(e,n,s);if(!l)return;if("histogram"===l.type&&s==={v:"y",h:"x"}[l.orientation||"v"])return void(t.type="linear");var u,c=s+"calendar",f=l[c];if(o(l,s)){var h=a(l),p=[];for(u=0;u0?".":"")+a;i.isPlainObject(o)?l(o,e,s,r+1):e(s,a,o)}})}n.manageCommandObserver=function(t,e,r,o){var s={},l=!0;e&&e._commandObserver&&(s=e._commandObserver),s.cache||(s.cache={}),s.lookupTable={};var u=n.hasSimpleAPICommandBindings(t,r,s.lookupTable);if(e&&e._commandObserver){if(u)return s;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,s}if(u){a(t,u,s.cache),s.check=function(){if(l){var e=a(t,u,s.cache);return e.changed&&o&&void 0!==s.lookupTable[e.value]&&(s.disable(),Promise.resolve(o({value:e.value,type:u.type,prop:u.prop,traces:u.traces,index:s.lookupTable[e.value]})).then(s.enable,s.enable)),e.changed}};for(var c=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;f0)}function l(t){var e={},n={};switch(t.type){case"circle":r.extendFlat(n,{"circle-radius":t.circle.radius,"circle-color":t.color,"circle-opacity":t.opacity});break;case"line":r.extendFlat(n,{"line-width":t.line.width,"line-color":t.color,"line-opacity":t.opacity});break;case"fill":r.extendFlat(n,{"fill-color":t.color,"fill-outline-color":t.fill.outlinecolor,"fill-opacity":t.opacity});break;case"symbol":var a=t.symbol,o=i(a.textposition,a.iconsize);r.extendFlat(e,{"icon-image":a.icon+"-15","icon-size":a.iconsize/10,"text-field":a.text,"text-size":a.textfont.size,"text-anchor":o.anchor,"text-offset":o.offset}),r.extendFlat(n,{"icon-color":t.color,"text-color":a.textfont.color,"text-opacity":t.opacity})}return{layout:e,paint:n}}o.update=function(t){this.visible?this.needsNewSource(t)?(this.removeLayer(),this.updateSource(t),this.updateLayer(t)):this.needsNewLayer(t)?this.updateLayer(t):this.updateStyle(t):(this.updateSource(t),this.updateLayer(t)),this.visible=s(t)},o.needsNewSource=function(t){return this.sourceType!==t.sourcetype||this.source!==t.source||this.layerType!==t.type},o.needsNewLayer=function(t){return this.layerType!==t.type||this.below!==t.below},o.updateSource=function(t){var e=this.map;if(e.getSource(this.idSource)&&e.removeSource(this.idSource),this.sourceType=t.sourcetype,this.source=t.source,s(t)){var n=function(t){var e,n=t.sourcetype,r=t.source,i={type:n};"geojson"===n?e="data":"vector"===n&&(e="string"==typeof r?"url":"tiles");return i[e]=r,i}(t);e.addSource(this.idSource,n)}},o.updateLayer=function(t){var e=this.map,n=l(t);this.removeLayer(),this.layerType=t.type,s(t)&&e.addLayer({id:this.idLayer,source:this.idSource,"source-layer":t.sourcelayer||"",type:t.type,layout:n.layout,paint:n.paint},t.below)},o.updateStyle=function(t){if(s(t)){var e=l(t);this.mapbox.setOptions(this.idLayer,"setLayoutProperty",e.layout),this.mapbox.setOptions(this.idLayer,"setPaintProperty",e.paint)}},o.removeLayer=function(){var t=this.map;t.getLayer(this.idLayer)&&t.removeLayer(this.idLayer)},o.dispose=function(){var t=this.map;t.removeLayer(this.idLayer),t.removeSource(this.idSource)},e.exports=function(t,e,n){var r=new a(t,e);return r.update(n),r}},{"../../lib":162,"./convert_text_opts":239}],242:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../components/color").defaultLine,a=t("../domain").attributes,o=t("../font_attributes"),s=t("../../traces/scatter/attributes").textposition,l=t("../../plot_api/edit_types").overrideAll,u=t("../../plot_api/plot_template").templatedArray,c=o({});c.family.dflt="Open Sans Regular, Arial Unicode MS Regular",e.exports=l({_arrayAttrRegexps:[r.counterRegex("mapbox",".layers",!0)],domain:a({name:"mapbox"}),accesstoken:{valType:"string",noBlank:!0,strict:!0},style:{valType:"any",values:["basic","streets","outdoors","light","dark","satellite","satellite-streets"],dflt:"basic"},center:{lon:{valType:"number",dflt:0},lat:{valType:"number",dflt:0}},zoom:{valType:"number",dflt:1},bearing:{valType:"number",dflt:0},pitch:{valType:"number",dflt:0},layers:u("layer",{visible:{valType:"boolean",dflt:!0},sourcetype:{valType:"enumerated",values:["geojson","vector"],dflt:"geojson"},source:{valType:"any"},sourcelayer:{valType:"string",dflt:""},type:{valType:"enumerated",values:["circle","line","fill","symbol"],dflt:"circle"},below:{valType:"string",dflt:""},color:{valType:"color",dflt:i},opacity:{valType:"number",min:0,max:1,dflt:1},circle:{radius:{valType:"number",dflt:15}},line:{width:{valType:"number",dflt:2}},fill:{outlinecolor:{valType:"color",dflt:i}},symbol:{icon:{valType:"string",dflt:"marker"},iconsize:{valType:"number",dflt:10},text:{valType:"string",dflt:""},textfont:c,textposition:r.extendFlat({},s,{arrayOk:!1})}})},"plot","from-root")},{"../../components/color":43,"../../lib":162,"../../plot_api/edit_types":189,"../../plot_api/plot_template":196,"../../traces/scatter/attributes":266,"../domain":232,"../font_attributes":233}],243:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../subplot_defaults"),a=t("../array_container_defaults"),o=t("./layout_attributes");function s(t,e,n,r){n("accesstoken",r.accessToken),n("style"),n("center.lon"),n("center.lat"),n("zoom"),n("bearing"),n("pitch"),a(t,e,{name:"layers",handleItemDefaults:l}),e._input=t}function l(t,e){function n(n,i){return r.coerce(t,e,o.layers,n,i)}if(n("visible")){var i=n("sourcetype");n("source"),"vector"===i&&n("sourcelayer");var a=n("type");n("below"),n("color"),n("opacity"),"circle"===a&&n("circle.radius"),"line"===a&&n("line.width"),"fill"===a&&n("fill.outlinecolor"),"symbol"===a&&(n("symbol.icon"),n("symbol.iconsize"),n("symbol.text"),r.coerceFont(n,"symbol.textfont"),n("symbol.textposition"))}}e.exports=function(t,e,n){i(t,e,n,{type:"mapbox",attributes:o,handleDefaults:s,partition:"y",accessToken:e._mapboxAccessToken})}},{"../../lib":162,"../array_container_defaults":202,"../subplot_defaults":253,"./layout_attributes":242}],244:[function(t,e,n){"use strict";var r=t("mapbox-gl"),i=t("../../components/fx"),a=t("../../lib"),o=t("../../components/dragelement"),s=t("../cartesian/select").prepSelect,l=t("../cartesian/select").selectOnClick,u=t("./constants"),c=t("./layout_attributes"),f=t("./layers");function h(t){this.id=t.id,this.gd=t.gd,this.container=t.container,this.isStatic=t.staticPlot;var e=t.fullLayout;this.uid=e._uid+"-"+this.id,this.opts=e[this.id],this.div=null,this.xaxis=null,this.yaxis=null,this.createFramework(e),this.map=null,this.accessToken=null,this.styleObj=null,this.traceHash={},this.layerList=[]}var p=h.prototype;function d(t){var e=c.style.values,n=c.style.dflt,r={};return a.isPlainObject(t)?(r.id=t.id,r.style=t):"string"==typeof t?(r.id=t,r.style=-1!==e.indexOf(t)?m(t):t):(r.id=n,r.style=m(n)),r.transition={duration:0,delay:0},r}function m(t){return u.styleUrlPrefix+t+"-"+u.styleUrlSuffix}function g(t){return[t.lon,t.lat]}e.exports=function(t){return new h(t)},p.plot=function(t,e,n){var r,i=this,a=i.opts=e[this.id];i.map&&a.accesstoken!==i.accessToken&&(i.map.remove(),i.map=null,i.styleObj=null,i.traceHash=[],i.layerList={}),r=i.map?new Promise(function(n,r){i.updateMap(t,e,n,r)}):new Promise(function(n,r){i.createMap(t,e,n,r)}),n.push(r)},p.createMap=function(t,e,n,a){var o=this,s=o.gd,c=o.opts,f=o.styleObj=d(c.style);o.accessToken=c.accesstoken;var h=o.map=new r.Map({container:o.div,style:f.style,center:g(c.center),zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,interactive:!o.isStatic,preserveDrawingBuffer:o.isStatic,doubleClickZoom:!1,boxZoom:!1}),p=u.controlContainerClassName,m=o.div.getElementsByClassName(p)[0];if(o.div.removeChild(m),h._canvas.style.left="0px",h._canvas.style.top="0px",o.rejectOnError(a),h.once("load",function(){o.updateData(t),o.updateLayout(e),o.resolveOnRender(n)}),!o.isStatic){var y=!1;h.on("moveend",function(t){if(o.map){var e=o.getView();c._input.center=c.center=e.center,c._input.zoom=c.zoom=e.zoom,c._input.bearing=c.bearing=e.bearing,c._input.pitch=c.pitch=e.pitch,(t.originalEvent||y)&&_(e),y=!1}}),h.on("wheel",function(){y=!0}),h.on("mousemove",function(t){var e=o.div.getBoundingClientRect();t.clientX=t.point.x+e.left,t.clientY=t.point.y+e.top,t.target.getBoundingClientRect=function(){return e},o.xaxis.p2c=function(){return t.lngLat.lng},o.yaxis.p2c=function(){return t.lngLat.lat},i.hover(s,t,o.id)}),h.on("dragstart",v),h.on("zoomstart",v),h.on("dblclick",function(){s.emit("plotly_doubleclick",null);var t=o.viewInitial;h.setCenter(g(t.center)),h.setZoom(t.zoom),h.setBearing(t.bearing),h.setPitch(t.pitch);var e=o.getView();c._input.center=c.center=e.center,c._input.zoom=c.zoom=e.zoom,c._input.bearing=c.bearing=e.bearing,c._input.pitch=c.pitch=e.pitch,_(e)}),o.clearSelect=function(){s._fullLayout._zoomlayer.selectAll(".select-outline").remove()},o.onClickInPanFn=function(t){return function(e){var n=s._fullLayout.clickmode;n.indexOf("select")>-1&&l(e.originalEvent,s,[o.xaxis],[o.yaxis],o.id,t),n.indexOf("event")>-1&&i.click(s,e.originalEvent)}}}function v(){i.loneUnhover(e._toppaper)}function _(t){var e=o.id,n={};for(var r in t)n[e+"."+r]=t[r];s.emit("plotly_relayout",n)}},p.updateMap=function(t,e,n,r){var i=this,a=i.map;i.rejectOnError(r);var o=d(i.opts.style);i.styleObj.id!==o.id?(i.styleObj=o,a.setStyle(o.style),a.once("styledata",function(){i.traceHash={},i.updateData(t),i.updateLayout(e),i.resolveOnRender(n)})):(i.updateData(t),i.updateLayout(e),i.resolveOnRender(n))},p.updateData=function(t){var e,n,r,i,a=this.traceHash;for(r=0;r=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),n.attr(a);var o=n.select(".js-link-to-tool"),s=n.select(".js-link-spacer"),c=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var n=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)n.on("click",function(){g.sendDataToCloud(t)});else{var r=window.location.pathname.split("/"),i=window.location.search;n.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+r[2].split(".")[0]+"/"+r[1]+i})}}(t,o),s.text(o.text()&&c.text()?" - ":"")}},g.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,n=r.select(t).append("div").attr("id","hiddenform").style("display","none"),i=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return i.append("input").attr({type:"text",name:"data"}).node().value=g.graphJson(t,!1,"keepdata"),i.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1};var _,x=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],b=["year","month","dayMonth","dayMonthYear"];function w(t,e){var n=t._context.locale,r=!1,i={};function o(t){for(var n=!0,a=0;a1&&P.length>1){for(a.getComponentMethod("grid","sizeDefaults")(u,s),o=0;o15&&P.length>15&&0===s.shapes.length&&0===s.images.length,s._hasCartesian=s._has("cartesian"),s._hasGeo=s._has("geo"),s._hasGL3D=s._has("gl3d"),s._hasGL2D=s._has("gl2d"),s._hasTernary=s._has("ternary"),s._hasPie=s._has("pie"),g.linkSubplots(h,s,c,i),g.cleanPlot(h,s,c,i),d(s,i),g.doAutoMargin(t);var B=f.list(t);for(o=0;o0){var f=1-2*s;r=Math.round(f*r),a=Math.round(f*a)}}var h=g.layoutAttributes.width.min,p=g.layoutAttributes.height.min;r1,m=!e.height&&Math.abs(n.height-a)>1;(m||d)&&(d&&(n.width=r),m&&(n.height=a)),t._initialAutoSize||(t._initialAutoSize={width:r,height:a}),g.sanitizeMargins(n)},g.supplyLayoutModuleDefaults=function(t,e,n,r){var i,o,s,u=a.componentsRegistry,c=e._basePlotModules,f=a.subplotsRegistry.cartesian;for(i in u)(s=u[i]).includeBasePlot&&s.includeBasePlot(t,e);for(var h in c.length||c.push(f),e._has("cartesian")&&(a.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[h].sort(l.subplotSort);for(o=0;o.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0);var l=void 0!==n.xl?n.xl:n.x,u=void 0!==n.xr?n.xr:n.x,c=void 0!==n.yt?n.yt:n.y,f=void 0!==n.yb?n.yb:n.y;i[e]={l:{val:l,size:n.l+o},r:{val:u,size:n.r+o},b:{val:f,size:n.b+o},t:{val:c,size:n.t+o}},a[e]=1}else delete i[e],delete a[e];r._replotting||g.doAutoMargin(t)}},g.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),A(e);var n=e._size,r=JSON.stringify(n),o=Math.max(e.margin.l||0,0),s=Math.max(e.margin.r||0,0),l=Math.max(e.margin.t||0,0),u=Math.max(e.margin.b||0,0),c=e._pushmargin,f=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var h in c)f[h]||delete c[h];for(var p in c.base={l:{val:0,size:o},r:{val:1,size:s},t:{val:1,size:l},b:{val:0,size:u}},c){var d=c[p].l||{},m=c[p].b||{},g=d.val,y=d.size,v=m.val,_=m.size;for(var x in c){if(i(y)&&c[x].r){var b=c[x].r.val,w=c[x].r.size;if(b>g){var k=(y*b+(w-e.width)*g)/(b-g),T=(w*(1-g)+(y-e.width)*(1-b))/(b-g);k>=0&&T>=0&&k+T>o+s&&(o=k,s=T)}}if(i(_)&&c[x].t){var M=c[x].t.val,S=c[x].t.size;if(M>v){var C=(_*M+(S-e.height)*v)/(M-v),z=(S*(1-v)+(_-e.height)*(1-M))/(M-v);C>=0&&z>=0&&C+z>u+l&&(u=C,l=z)}}}}}if(n.l=Math.round(o),n.r=Math.round(s),n.t=Math.round(l),n.b=Math.round(u),n.p=Math.round(e.margin.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,!e._replotting&&"{}"!==r&&r!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,a.call("plot",t)},g.graphJson=function(t,e,n,r,i){(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&g.supplyDefaults(t);var a=i?t._fullData:t.data,o=i?t._fullLayout:t.layout,s=(t._transitionData||{})._frames;function u(t){if("function"==typeof t)return null;if(l.isPlainObject(t)){var e,r,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if("string"==typeof(r=t[e+"src"])&&r.indexOf(":")>0&&!l.isPlainObject(t.stream))continue}else if("keepall"!==n&&"string"==typeof(r=t[e+"src"])&&r.indexOf(":")>0)continue;i[e]=u(t[e])}return i}return Array.isArray(t)?t.map(u):l.isTypedArray(t)?l.simpleMap(t,l.identity):l.isJSDate(t)?l.ms2DateTimeLocal(+t):t}var c={data:(a||[]).map(function(t){var n=u(t);return e&&delete n.fit,n})};return e||(c.layout=u(o)),t.framework&&t.framework.isPolar&&(c=t.framework.getConfig()),s&&(c.frames=u(s)),"object"===r?c:JSON.stringify(c)},g.modifyFrames=function(t,e){var n,r,i,a=t._transitionData._frames,o=t._transitionData._frameHash;for(n=0;n0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),i.redraw&&t._transitionData._interruptCallbacks.push(function(){return a.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var r,s,u=0,c=0;function f(){return u++,function(){var n;c++,p||c!==u||(n=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(i.redraw)return a.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(n)))}}var d=t._fullLayout._basePlotModules,m=!1;if(n)for(s=0;s=0;s--)if(o[s].enabled){n._indexToPoints=o[s]._indexToPoints;break}r&&r.calc&&(a=r.calc(t,n))}Array.isArray(a)&&a[0]||(a=[{x:c,y:c}]),a[0].t||(a[0].t={}),a[0].trace=n,d[e]=a}}for(v&&M(u),i=0;i=0?h.angularAxis.domain:r.extent(k),C=Math.abs(k[1]-k[0]);A&&!T&&(C=0);var z=S.slice();M&&T&&(z[1]+=C);var E=h.angularAxis.ticksCount||4;E>8&&(E=E/(E/8)+E%8),h.angularAxis.ticksStep&&(E=(z[1]-z[0])/E);var L=h.angularAxis.ticksStep||(z[1]-z[0])/(E*(h.minorTicks+1));w&&(L=Math.max(Math.round(L),1)),z[2]||(z[2]=L);var I=r.range.apply(this,z);if(I=I.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=r.scale.linear().domain(z.slice(0,2)).range("clockwise"===h.direction?[0,360]:[360,0]),c.layout.angularAxis.domain=s.domain(),c.layout.angularAxis.endPadding=M?C:0,"undefined"==typeof(t=r.select(this).select("svg.chart-root"))||t.empty()){var P=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),D=this.appendChild(this.ownerDocument.importNode(P.documentElement,!0));t=r.select(D)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var O,R=t.select(".chart-group"),F={fill:"none",stroke:h.tickColor},B={"font-size":h.font.size,"font-family":h.font.family,fill:h.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+h.font.outlineColor}).join(",")};if(h.showLegend){O=t.select(".legend-group").attr({transform:"translate("+[_,h.margin.top]+")"}).style({display:"block"});var N=p.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:O,elements:N,reverseOrder:h.legend.reverseOrder})})();var j=O.node().getBBox();_=Math.min(h.width-j.width-h.margin.left-h.margin.right,h.height-h.margin.top-h.margin.bottom)/2,_=Math.max(10,_),b=[h.margin.left+_,h.margin.top+_],n.range([0,_]),c.layout.radialAxis.domain=n.domain(),O.attr("transform","translate("+[b[0]+_,b[1]-_]+")")}else O=t.select(".legend-group").style({display:"none"});t.attr({width:h.width,height:h.height}).style({opacity:h.opacity}),R.attr("transform","translate("+b+")").style({cursor:"crosshair"});var V=[(h.width-(h.margin.left+h.margin.right+2*_+(j?j.width:0)))/2,(h.height-(h.margin.top+h.margin.bottom+2*_))/2];if(V[0]=Math.max(0,V[0]),V[1]=Math.max(0,V[1]),t.select(".outer-group").attr("transform","translate("+V+")"),h.title){var q=t.select("g.title-group text").style(B).text(h.title),U=q.node().getBBox();q.attr({x:b[0]-U.width/2,y:b[1]-_-20})}var H=t.select(".radial.axis-group");if(h.radialAxis.gridLinesVisible){var Z=H.selectAll("circle.grid-circle").data(n.ticks(5));Z.enter().append("circle").attr({class:"grid-circle"}).style(F),Z.attr("r",n),Z.exit().remove()}H.select("circle.outside-circle").attr({r:_}).style(F);var G=t.select("circle.background-circle").attr({r:_}).style({fill:h.backgroundColor,stroke:h.stroke});function $(t,e){return s(t)%360+h.orientation}if(h.radialAxis.visible){var W=r.svg.axis().scale(n).ticks(5).tickSize(5);H.call(W).attr({transform:"rotate("+h.radialAxis.orientation+")"}),H.selectAll(".domain").style(F),H.selectAll("g>text").text(function(t,e){return this.textContent+h.radialAxis.ticksSuffix}).style(B).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===h.radialAxis.tickOrientation?"rotate("+-h.radialAxis.orientation+") translate("+[0,B["font-size"]]+")":"translate("+[0,B["font-size"]]+")"}}),H.selectAll("g>line").style({stroke:"black"})}var X=t.select(".angular.axis-group").selectAll("g.angular-tick").data(I),Y=X.enter().append("g").classed("angular-tick",!0);X.attr({transform:function(t,e){return"rotate("+$(t)+")"}}).style({display:h.angularAxis.visible?"block":"none"}),X.exit().remove(),Y.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(h.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(h.minorTicks+1)==0)}).style(F),Y.selectAll(".minor").style({stroke:h.minorTickColor}),X.select("line.grid-line").attr({x1:h.tickLength?_-h.tickLength:0,x2:_}).style({display:h.angularAxis.gridLinesVisible?"block":"none"}),Y.append("text").classed("axis-text",!0).style(B);var J=X.select("text.axis-text").attr({x:_+h.labelOffset,dy:a+"em",transform:function(t,e){var n=$(t),r=_+h.labelOffset,i=h.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-n+" "+r+" 0)":"radial"==i?n<270&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(n<=180&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:h.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(h.minorTicks+1)!=0?"":w?w[t]+h.angularAxis.ticksSuffix:t+h.angularAxis.ticksSuffix}).style(B);h.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(h.minorTicks+1)!=0?"":h.angularAxis.rewriteTicks(this.textContent,e)});var K=r.max(R.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));O.attr({transform:"translate("+[_+K,h.margin.top]+")"});var Q=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||Q){var et=[];p.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=tt.filter(function(t,n){return n==e}),r.geometry=t.geometry,r.orientation=h.orientation,r.direction=h.direction,r.index=e,et.push({data:t,geometryConfig:r})});var nt=r.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),rt=[];nt.forEach(function(t,e){"unstacked"===t.key?rt=rt.concat(t.values.map(function(t,e){return[t]})):rt.push(t.values)}),rt.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return i(o[n].defaultConfig(),t)});o[n]().config(r)()})}var it,at,ot=t.select(".guides-group"),st=t.select(".tooltips-group"),lt=o.tooltipPanel().config({container:st,fontSize:8})(),ut=o.tooltipPanel().config({container:st,fontSize:8})(),ct=o.tooltipPanel().config({container:st,hasTick:!0})();if(!T){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});R.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos(G).angle;ft.attr({x2:-_,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-h.orientation)%360;it=s.invert(r);var i=o.util.convertToCartesian(_+12,n+180);lt.text(o.util.round(it)).move([i[0]+b[0],i[1]+b[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var ht=ot.select("circle").style({stroke:"grey",fill:"none"});R.on("mousemove.radial-guide",function(t,e){var r=o.util.getMousePos(G).radius;ht.attr({r:r}).style({opacity:.5}),at=n.invert(o.util.getMousePos(G).radius);var i=o.util.convertToCartesian(r,h.radialAxis.orientation);ut.text(o.util.round(at)).move([i[0]+b[0],i[1]+b[1]])}).on("mouseout.radial-guide",function(t,e){ht.style({opacity:0}),ct.hide(),lt.hide(),ut.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,n){var i=r.select(this),a=this.style.fill,s="black",l=this.style.opacity||1;if(i.attr({"data-opacity":l}),a&&"none"!==a){i.attr({"data-fill":a}),s=r.hsl(a).darker().toString(),i.style({fill:s,opacity:1});var u={t:o.util.round(e[0]),r:o.util.round(e[1])};T&&(u.t=w[e[0]]);var c="t: "+u.t+", r: "+u.r,f=this.getBoundingClientRect(),h=t.node().getBoundingClientRect(),p=[f.left+f.width/2-V[0]-h.left,f.top+f.height/2-V[1]-h.top];ct.config({color:s}).text(c),ct.move(p)}else a=this.style.stroke||"black",i.attr({"data-stroke":a}),s=r.hsl(a).darker().toString(),i.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=r.event.which)return!1;r.select(this).attr("data-fill")&&ct.show()}).on("mouseout.tooltip",function(t,e){ct.hide();var n=r.select(this),i=n.attr("data-fill");i?n.style({fill:i,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})})}(u),this},h.config=function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),i(l.data[e],o.Axis.defaultConfig().data[0]),i(l.data[e],t)}),i(l.layout,o.Axis.defaultConfig().layout),i(l.layout,e.layout),this},h.getLiveConfig=function(){return c},h.getinputConfig=function(){return u},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return t},r.rebind(h,f,"on"),h},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:r.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6;return r.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180;return[e,t(r)]})},o.util.dataFromEquation=function(t,e,n){var i=e||6,a=[],o=[];r.range(0,360+i,i).forEach(function(e,n){var r=e*Math.PI/180,i=t(r);a.push(e),o.push(i)});var s={t:a,r:o};return n&&(s.name=n),s},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return r.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return r.zip(t,e).map(function(t,e){return r.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return-2===n},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180;return[t*Math.cos(n),t*Math.sin(n)]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=r.mouse(t.node()),n=e[0],i=e[1],a={};return a.x=n,a.y=i,a.pos=e,a.angle=180*(Math.atan2(i,n)+Math.PI)/Math.PI,a.radius=Math.sqrt(n*n+i*i),a},o.util.duplicatesCount=function(t){for(var e,n={},r={},i=0,a=t.length;i0)){var l=r.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:c(s),transform:function(t,n){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return d.fill(n,i,a)},"fill-opacity":0,stroke:function(t,e){return d.stroke(n,i,a)},"stroke-width":function(t,e){return d["stroke-width"](n,i,a)},"stroke-dasharray":function(t,e){return d["stroke-dasharray"](n,i,a)},opacity:function(t,e){return d.opacity(n,i,a)},display:function(t,e){return d.display(n,i,a)}})}};var f=e.angularScale.range(),h=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=r.svg.arc().startAngle(function(t){return-h/2}).endAngle(function(t){return h/2}).innerRadius(function(t){return e.radialScale(l+(t[2]||0))}).outerRadius(function(t){return e.radialScale(l+(t[2]||0))+e.radialScale(t[1])});u.arc=function(t,n,i){r.select(this).attr({class:"mark arc",d:p,transform:function(t,n){return"rotate("+(e.orientation+s(t[0])+90)+")"}})};var d={fill:function(e,n,r){return t[r].data.color},stroke:function(e,n,r){return t[r].data.strokeColor},"stroke-width":function(e,n,r){return t[r].data.strokeSize+"px"},"stroke-dasharray":function(e,r,i){return n[t[i].data.strokeDash]},opacity:function(e,n,r){return t[r].data.opacity},display:function(e,n,r){return"undefined"==typeof t[r].data.visible||t[r].data.visible?"block":"none"}},m=r.select(this).selectAll("g.layer").data(o);m.enter().append("g").attr({class:"layer"});var g=m.selectAll("path.mark").data(function(t,e){return t});g.enter().append("path").attr({class:"mark"}),g.style(d).each(u[e.geometryType]),g.exit().remove(),m.exit().remove()})}return a.config=function(e){return arguments.length?(e.forEach(function(e,n){t[n]||(t[n]={}),i(t[n],o.PolyChart.defaultConfig()),i(t[n],e)}),this):t},a.getColorScale=function(){},r.rebind(a,e,"on"),a},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:r.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=r.dispatch("hover");function n(){var e=t.legendConfig,a=t.data.map(function(t,n){return[].concat(t).map(function(t,r){var a=i({},e.elements[n]);return a.name=t,a.color=[].concat(e.elements[n].color)[r],a})}),o=r.merge(a);o=o.filter(function(t,n){return e.elements[n]&&(e.elements[n].visibleInLegend||"undefined"==typeof e.elements[n].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var s=e.container;("string"==typeof s||s.nodeName)&&(s=r.select(s));var l=o.map(function(t,e){return t.color}),u=e.fontSize,c=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=c?e.height:u*o.length,h=s.classed("legend-group",!0).selectAll("svg").data([0]),p=h.enter().append("svg").attr({width:300,height:f+u,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var d=r.range(o.length),m=r.scale[c?"linear":"ordinal"]().domain(d).range(l),g=r.scale[c?"linear":"ordinal"]().domain(d)[c?"range":"rangePoints"]([0,f]);if(c){var y=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var v=h.select(".legend-marks").selectAll("path.legend-mark").data(o);v.enter().append("path").classed("legend-mark",!0),v.attr({transform:function(t,e){return"translate("+[u/2,g(e)+u/2]+")"},d:function(t,e){var n,i,a,o=t.symbol;return a=3*(i=u),"line"===(n=o)?"M"+[[-i/2,-i/12],[i/2,-i/12],[i/2,i/12],[-i/2,i/12]]+"Z":-1!=r.svg.symbolTypes.indexOf(n)?r.svg.symbol().type(n).size(a)():r.svg.symbol().type("square").size(a)()},fill:function(t,e){return m(e)}}),v.exit().remove()}var _=r.svg.axis().scale(g).orient("right"),x=h.select("g.legend-axis").attr({transform:"translate("+[c?e.colorBandWidth:u,u/2]+")"}).call(_);return x.selectAll(".domain").style({fill:"none",stroke:"none"}),x.selectAll("line").style({fill:"none",stroke:c?e.textColor:"none"}),x.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),n}return n.config=function(e){return arguments.length?(i(t,e),this):t},r.rebind(n,e,"on"),n},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,n,a={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,u=function(){var r=(t=a.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return n=r.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=r.append("text").attr({dx:a.padding+l,dy:.3*+a.fontSize}),u};return u.text=function(i){var o=r.hsl(a.color).l,s=o>=.5?"#aaa":"white",c=o>=.5?"black":"white",f=i||"";e.style({fill:c,"font-size":a.fontSize+"px"}).text(f);var h=a.padding,p=e.node().getBBox(),d={fill:a.color,stroke:s,"stroke-width":"2px"},m=p.width+2*h+l,g=p.height+2*h;return n.attr({d:"M"+[[l,-g/2],[l,-g/4],[a.hasTick?0:l,0],[l,g/4],[l,g/2],[m,g/2],[m,-g/2]].join("L")+"Z"}).style(d),t.attr({transform:"translate("+[l,-g/2+2*h]+")"}),t.style({display:"block"}),u},u.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),u},u.hide=function(){if(t)return t.style({display:"none"}),u},u.show=function(){if(t)return t.style({display:"block"}),u},u.config=function(t){return i(a,t),u},u},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=i({},t);return[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]].forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",!0===r.dotVisible?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var a=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var r=a.indexOf(t.geometry);-1!=r&&(n.data[e].groupId=r)})}if(t.layout){var s=i({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var l=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],c={};r.entries(s.margin).forEach(function(t,e){c[u[l.indexOf(t.key)]]=t.value}),s.margin=c}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),n.layout=s}return n}};return t}},{"../../../constants/alignment":141,"../../../lib":162,d3:7}],251:[function(t,e,n){"use strict";var r=t("d3"),i=t("../../../lib"),a=t("../../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=i.extendDeepAll,u=e.exports={};u.framework=function(t){var e,n,i,a,c,f=new s;function h(n,s){return s&&(c=s),r.select(r.select(c).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?l(e,n):n,i||(i=o.Axis()),a=o.adapter.plotly().convert(e),i.config(a).render(c),t.data=e.data,t.layout=e.layout,u.fillLayout(t),e}return h.isPolar=!0,h.svg=function(){return i.svg()},h.getConfig=function(){return e},h.getLiveConfig=function(){return o.adapter.plotly().convert(i.getLiveConfig(),!0)},h.getLiveScales=function(){return{t:i.angularScale(),r:i.radialScale()}},h.setUndoPoint=function(){var t,r,i=this,a=o.util.cloneJson(e);t=a,r=n,f.add({undo:function(){r&&i(r)},redo:function(){i(t)}}),n=o.util.cloneJson(a)},h.undo=function(){f.undo()},h.redo=function(){f.redo()},h},u.fillLayout=function(t){var e=r.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),i=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:a.background,_container:e,_paperdiv:n,_paper:i};t._fullLayout=l(o,t.layout)}},{"../../../components/color":43,"../../../lib":162,"./micropolar":250,"./undo_manager":252,d3:7}],252:[function(t,e,n){"use strict";e.exports=function(){var t,e=[],n=-1,r=!1;function i(t,e){return t?(r=!0,t[e](),r=!1,this):this}return{add:function(t){return r?this:(e.splice(n+1,e.length-n),e.push(t),n=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var r=e[n];return r?(i(r,"undo"),n-=1,t&&t(r.undo),this):this},redo:function(){var r=e[n+1];return r?(i(r,"redo"),n+=1,t&&t(r.redo),this):this},clear:function(){e=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return n-1&&(c[h[n]].title="");for(n=0;npath, .legendlines>path, .cbfill").each(function(){var t=r.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(l,"TOBESTRIPPED"));var n=this.style.stroke;n&&-1!==n.indexOf("url(")&&t.style("stroke",n.replace(l,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||h.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),h.node().setAttributeNS(s.xmlns,"xmlns",s.svg),h.node().setAttributeNS(s.xmlns,"xmlns:xlink",s.xlink),"svg"===e&&n&&(h.attr("width",n*d),h.attr("height",n*m),h.attr("viewBox","0 0 "+d+" "+m));var b=(new window.XMLSerializer).serializeToString(h.node());return b=function(t){var e=r.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),n}(b),b=(b=b.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(u,"'"),i.isIE()&&(b=(b=(b=b.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),b}},{"../components/color":43,"../components/drawing":68,"../constants/xmlns_namespaces":144,"../lib":162,d3:7}],263:[function(t,e,n){"use strict";var r=t("../../lib");n.formatPiePercent=function(t,e){var n=(100*t).toPrecision(3);return-1!==n.lastIndexOf(".")&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)+"%"},n.formatPieValue=function(t,e){var n=t.toPrecision(10);return-1!==n.lastIndexOf(".")&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)},n.getFirstFilled=function(t,e){if(Array.isArray(t))for(var n=0;ns&&A[g].gap;)g--;for(v=A[g].s,d=A.length-1;d>g;d--)A[d].s=v;for(;sM[c]&&c=0;i--){var a=t[i];if("scatter"===a.type&&a.xaxis===n.xaxis&&a.yaxis===n.yaxis){a.opacity=void 0;break}}}}}},{}],273:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("./constants"),s=t("./subtypes"),l=t("./xy_defaults"),u=t("./stack_defaults"),c=t("./marker_defaults"),f=t("./line_defaults"),h=t("./line_shape_defaults"),p=t("./text_defaults"),d=t("./fillcolor_defaults");e.exports=function(t,e,n,m){function g(n,i){return r.coerce(t,e,a,n,i)}var y=l(t,e,m,g);if(y||(e.visible=!1),e.visible){var v=u(t,e,m,g),_=!v&&yZ!=(F=I[E][1])>=Z&&(D=I[E-1][0],O=I[E][0],F-R&&(P=D+(O-D)*(Z-R)/(F-R),V=Math.min(V,P),q=Math.max(q,P)));V=Math.max(V,0),q=Math.min(q,h._length);var G=s.defaultLine;return s.opacity(f.fillcolor)?G=f.fillcolor:s.opacity((f.line||{}).color)&&(G=f.line.color),r.extendFlat(t,{distance:t.maxHoverDistance,x0:V,x1:q,y0:Z,y1:Z,color:G}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":43,"../../components/fx":85,"../../lib":162,"../../registry":254,"./fill_hover_text":274,"./get_trace_color":276}],278:[function(t,e,n){"use strict";var r={},i=t("./subtypes");r.hasLines=i.hasLines,r.hasMarkers=i.hasMarkers,r.hasText=i.hasText,r.isBubble=i.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.crossTraceDefaults=t("./cross_trace_defaults"),r.calc=t("./calc").calc,r.crossTraceCalc=t("./cross_trace_calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./marker_colorbar"),r.style=t("./style").style,r.styleOnSelect=t("./style").styleOnSelect,r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.animatable=!0,r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],r.meta={},e.exports=r},{"../../plots/cartesian":218,"./arrays_to_calcdata":265,"./attributes":266,"./calc":267,"./cross_trace_calc":271,"./cross_trace_defaults":272,"./defaults":273,"./hover":277,"./marker_colorbar":284,"./plot":286,"./select":287,"./style":289,"./subtypes":290}],279:[function(t,e,n){"use strict";var r=t("../../lib").isArrayOrTypedArray,i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,s,l){var u=(t.marker||{}).color;(s("line.color",n),i(t,"line"))?a(t,e,o,s,{prefix:"line.",cLetter:"c",noScale:!0}):s("line.color",!r(u)&&u||n);s("line.width"),(l||{}).noDash||s("line.dash")}},{"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57,"../../lib":162}],280:[function(t,e,n){"use strict";var r=t("../../constants/numerical"),i=r.BADNUM,a=r.LOG_CLIP,o=a+.5,s=a-.5,l=t("../../lib"),u=l.segmentsIntersect,c=l.constrain,f=t("./constants");e.exports=function(t,e){var n,r,a,h,p,d,m,g,y,v,_,x,b,w,k,T,A,M,S=e.xaxis,C=e.yaxis,z="log"===S.type,E="log"===C.type,L=S._length,I=C._length,P=e.connectGaps,D=e.baseTolerance,O=e.shape,R="linear"===O,F=[],B=f.minTolerance,N=new Array(t.length),j=0;function V(e){var n=t[e];if(!n)return!1;var r=S.c2p(n.x),a=C.c2p(n.y);if(r===i){if(z&&(r=S.c2p(n.x,!0)),r===i)return!1;E&&a===i&&(r*=Math.abs(S._m*I*(S._m>0?o:s)/(C._m*L*(C._m>0?o:s)))),r*=1e3}if(a===i){if(E&&(a=C.c2p(n.y,!0)),a===i)return!1;a*=1e3}return[r,a]}function q(t,e,n,r){var i=n-t,a=r-e,o=.5-t,s=.5-e,l=i*i+a*a,u=i*o+a*s;if(u>0&&utt||t[1]nt)return[c(t[0],Q,tt),c(t[1],et,nt)]}function at(t,e){return t[0]===e[0]&&(t[0]===Q||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===nt)||void 0)}function ot(t,e,n){return function(r,i){var a=it(r),o=it(i),s=[];if(a&&o&&at(a,o))return s;a&&s.push(a),o&&s.push(o);var u=2*l.constrain((r[t]+i[t])/2,e,n)-((a||r)[t]+(o||i)[t]);u&&((a&&o?u>0==a[t]>o[t]?a:o:a||o)[t]+=u);return s}}function st(t){var e=t[0],n=t[1],r=e===N[j-1][0],i=n===N[j-1][1];if(!r||!i)if(j>1){var a=e===N[j-2][0],o=n===N[j-2][1];r&&(e===Q||e===tt)&&a?o?j--:N[j-1]=t:i&&(n===et||n===nt)&&o?a?j--:N[j-1]=t:N[j++]=t}else N[j++]=t}function lt(t){N[j-1][0]!==t[0]&&N[j-1][1]!==t[1]&&st([$,W]),st(t),X=null,$=W=0}function ut(t){if(A=t[0]/L,M=t[1]/I,Z=t[0]tt?tt:0,G=t[1]nt?nt:0,Z||G){if(j)if(X){var e=J(X,t);e.length>1&&(lt(e[0]),N[j++]=e[1])}else Y=J(N[j-1],t)[0],N[j++]=Y;else N[j++]=[Z||t[0],G||t[1]];var n=N[j-1];Z&&G&&(n[0]!==Z||n[1]!==G)?(X&&($!==Z&&W!==G?st($&&W?(r=X,a=(i=t)[0]-r[0],o=(i[1]-r[1])/a,(r[1]*i[0]-i[1]*r[0])/a>0?[o>0?Q:tt,nt]:[o>0?tt:Q,et]):[$||Z,W||G]):$&&W&&st([$,W])),st([Z,G])):$-Z&&W-G&&st([Z||$,G||W]),X=t,$=Z,W=G}else X&<(J(X,t)[0]),N[j++]=t;var r,i,a,o}for("linear"===O||"spline"===O?J=function(t,e){for(var n=[],r=0,i=0;i<4;i++){var a=rt[i],o=u(t[0],t[1],e[0],e[1],a[0],a[1],a[2],a[3]);o&&(!r||Math.abs(o.x-n[0][0])>1||Math.abs(o.y-n[0][1])>1)&&(o=[o.x,o.y],r&&H(o,t)U(d,ct))break;a=d,(b=y[0]*g[0]+y[1]*g[1])>_?(_=b,h=d,m=!1):b=t.length||!d)break;ut(d),r=d}}else ut(h)}X&&st([$||X[0],W||X[1]]),F.push(N.slice(0,j))}return F}},{"../../constants/numerical":143,"../../lib":162,"./constants":270}],281:[function(t,e,n){"use strict";e.exports=function(t,e,n){"spline"===n("line.shape")&&n("line.smoothing")}},{}],282:[function(t,e,n){"use strict";var r={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,n){var i,a,o,s,l,u={},c=!1,f=-1,h=0,p=-1;for(a=0;a=0?l=p:(l=p=h,h++),l0?Math.max(e,i):0}}},{"fast-isnumeric":9}],284:[function(t,e,n){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],285:[function(t,e,n){"use strict";var r=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,n,s,l,u){var c=o.isBubble(t),f=(t.line||{}).color;(u=u||{},f&&(n=f),l("marker.symbol"),l("marker.opacity",c?.7:1),l("marker.size"),l("marker.color",n),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),u.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),u.noLine||(l("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:c?r.background:r.defaultLine),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",c?1:0)),c&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),u.gradient)&&("none"!==l("marker.gradient.type")&&l("marker.gradient.color"))}},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/has_colorscale":57,"./subtypes":290}],286:[function(t,e,n){"use strict";var r=t("d3"),i=t("../../registry"),a=t("../../lib"),o=a.ensureSingle,s=a.identity,l=t("../../components/drawing"),u=t("./subtypes"),c=t("./line_points"),f=t("./link_traces"),h=t("../../lib/polygon").tester;function p(t,e,n,f,p,d,m){var g;!function(t,e,n,i,o){var s=n.xaxis,l=n.yaxis,c=r.extent(a.simpleMap(s.range,s.r2c)),f=r.extent(a.simpleMap(l.range,l.r2c)),h=i[0].trace;if(!u.hasMarkers(h))return;var p=h.marker.maxdisplayed;if(0===p)return;var d=i.filter(function(t){return t.x>=c[0]&&t.x<=c[1]&&t.y>=f[0]&&t.y<=f[1]}),m=Math.ceil(d.length/p),g=0;o.forEach(function(t,n){var r=t[0].trace;u.hasMarkers(r)&&r.marker.maxdisplayed>0&&n0;function v(t){return y?t.transition():t}var _=n.xaxis,x=n.yaxis,b=f[0].trace,w=b.line,k=r.select(d),T=o(k,"g","errorbars"),A=o(k,"g","lines"),M=o(k,"g","points"),S=o(k,"g","text");if(i.getComponentMethod("errorbars","plot")(T,n,m),!0===b.visible){var C,z;v(k).style("opacity",b.opacity);var E=b.fill.charAt(b.fill.length-1);"x"!==E&&"y"!==E&&(E=""),n.isRangePlot||(f[0].node3=k);var L="",I=[],P=b._prevtrace;P&&(L=P._prevRevpath||"",z=P._nextFill,I=P._polygons);var D,O,R,F,B,N,j,V,q,U="",H="",Z=[],G=a.noop;if(C=b._ownFill,u.hasLines(b)||"none"!==b.fill){for(z&&z.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(R=l.steps(w.shape),F=l.steps(w.shape.split("").reverse().join(""))):R=F="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?l.smoothclosed(t.slice(1),w.smoothing):l.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},B=function(t){return F(t.reverse())},Z=c(f,{xaxis:_,yaxis:x,connectGaps:b.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=b._polygons=new Array(Z.length),g=0;g1){var n=r.select(this);if(n.datum(f),t)v(n.style("opacity",0).attr("d",D).call(l.lineGroupStyle)).style("opacity",1);else{var i=v(n);i.attr("d",D),l.singleLineStyle(f,i)}}}}}var $=A.selectAll(".js-line").data(Z);v($.exit()).style("opacity",0).remove(),$.each(G(!1)),$.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(l.lineGroupStyle).each(G(!0)),l.setClipUrl($,n.layerClipId),Z.length?(C?(C.datum(f),N&&V&&(E?("y"===E?N[1]=V[1]=x.c2p(0,!0):"x"===E&&(N[0]=V[0]=_.c2p(0,!0)),v(C).attr("d","M"+V+"L"+N+"L"+U.substr(1)).call(l.singleFillStyle)):v(C).attr("d",U+"Z").call(l.singleFillStyle))):z&&("tonext"===b.fill.substr(0,6)&&U&&L?("tonext"===b.fill?v(z).attr("d",U+"Z"+L+"Z").call(l.singleFillStyle):v(z).attr("d",U+"L"+L.substr(1)+"Z").call(l.singleFillStyle),b._polygons=b._polygons.concat(I)):(X(z),b._polygons=null)),b._prevRevpath=H,b._prevPolygons=q):(C?X(C):z&&X(z),b._polygons=b._prevRevpath=b._prevPolygons=null),M.datum(f),S.datum(f),function(e,i,a){var o,c=a[0].trace,f=u.hasMarkers(c),h=u.hasText(c),p=tt(c),d=et,m=et;if(f||h){var g=s,b=c.stackgroup,w=b&&"infer zero"===t._fullLayout._scatterStackOpts[_._id+x._id][b].stackgaps;c.marker.maxdisplayed||c._needsCull?g=w?J:Y:b&&!w&&(g=K),f&&(d=g),h&&(m=g)}var k,T=(o=e.selectAll("path.point").data(d,p)).enter().append("path").classed("point",!0);y&&T.call(l.pointStyle,c,t).call(l.translatePoints,_,x).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=l.makePointStyleFns(c)),o.each(function(e){var i=r.select(this),a=v(i);l.translatePoint(e,a,_,x)?(l.singlePointStyle(e,a,c,k,t),n.layerClipId&&l.hideOutsideRangePoint(e,a,_,x,c.xcalendar,c.ycalendar),c.customdata&&i.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):a.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=i.selectAll("g").data(m,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=r.select(this),i=v(e.select("text"));l.translatePoint(t,i,_,x)?n.layerClipId&&l.hideOutsideRangePoint(t,e,_,x,c.xcalendar,c.ycalendar):e.remove()}),o.selectAll("text").call(l.textPointStyle,c,t).each(function(t){var e=_.c2p(t.x),n=x.c2p(t.y);r.select(this).selectAll("tspan.line").each(function(){v(r.select(this)).attr({x:e,y:n})})}),o.exit().remove()}(M,S,f);var W=!1===b.cliponaxis?null:n.layerClipId;l.setClipUrl(M,W),l.setClipUrl(S,W)}function X(t){v(t).attr("d","M0,0Z")}function Y(t){return t.filter(function(t){return!t.gap&&t.vis})}function J(t){return t.filter(function(t){return t.vis})}function K(t){return t.filter(function(t){return!t.gap})}function Q(t){return t.id}function tt(t){if(t.ids)return Q}function et(){return!1}}e.exports=function(t,e,n,i,a,u){var c,h,d=!a,m=!!a&&a.duration>0,g=f(t,e,n);((c=i.selectAll("g.trace").data(g,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),c.order(),function(t,e,n){e.each(function(t){var e=o(r.select(this),"g","fills");l.setClipUrl(e,n.layerClipId);var i=t[0].trace,a=[];i._ownfill&&a.push("_ownFill"),i._nexttrace&&a.push("_nextFill");var u=e.selectAll("g").data(a,s);u.enter().append("g"),u.exit().each(function(t){i[t]=null}).remove(),u.order().each(function(t){i[t]=o(r.select(this),"path","js-fill")})})}(0,c,e),m)?(u&&(h=u()),r.transition().duration(a.duration).ease(a.easing).each("end",function(){h&&h()}).each("interrupt",function(){h&&h()}).each(function(){i.selectAll("g.trace").each(function(n,r){p(t,r,e,n,g,this,a)})})):c.each(function(n,r){p(t,r,e,n,g,this,a)});d&&c.exit().remove(),i.selectAll("path:not([d])").remove()}},{"../../components/drawing":68,"../../lib":162,"../../lib/polygon":174,"../../registry":254,"./line_points":280,"./link_traces":282,"./subtypes":290,d3:7}],287:[function(t,e,n){"use strict";var r=t("./subtypes");e.exports=function(t,e){var n,i,a,o,s=t.cd,l=t.xaxis,u=t.yaxis,c=[],f=s[0].trace;if(!r.hasMarkers(f)&&!r.hasText(f))return[];if(!1===e)for(n=0;n=0?Math.floor((e+180)/360):Math.ceil((e-180)/360)),d=e-p;if(r.getClosest(l,function(t){var e=t.lonlat;if(e[0]===s)return 1/0;var r=i.modHalf(e[0],360),a=e[1],o=h.project([r,a]),l=o.x-c.c2p([d,a]),u=o.y-f.c2p([r,n]),p=Math.max(3,t.mrc||0);return Math.max(Math.sqrt(l*l+u*u)-p,1-3/p)},t),!1!==t.index){var m=l[t.index],g=m.lonlat,y=[i.modHalf(g[0],360)+p,g[1]],v=c.c2p(y),_=f.c2p(y),x=m.mrc||1;return t.x0=v-x,t.x1=v+x,t.y0=_-x,t.y1=_+x,t.color=a(u,m),t.extraText=function(t,e,n){var r=(e.hi||t.hoverinfo).split("+"),i=-1!==r.indexOf("all"),a=-1!==r.indexOf("lon"),s=-1!==r.indexOf("lat"),l=e.lonlat,u=[];function c(t){return t+"\xb0"}i||a&&s?u.push("("+c(l[0])+", "+c(l[1])+")"):a?u.push(n.lon+c(l[0])):s&&u.push(n.lat+c(l[1]));(i||-1!==r.indexOf("text"))&&o(e,t,u);return u.join("
")}(u,m,l[0].t.labels),[t]}}},{"../../components/fx":85,"../../constants/numerical":143,"../../lib":162,"../scatter/fill_hover_text":274,"../scatter/get_trace_color":276}],300:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../scatter/marker_colorbar"),r.calc=t("../scattergeo/calc"),r.plot=t("./plot"),r.hoverPoints=t("./hover"),r.eventData=t("./event_data"),r.selectPoints=t("./select"),r.style=function(t,e){e&&e[0].trace._glTrace.update(e)},r.moduleType="trace",r.name="scattermapbox",r.basePlotModule=t("../../plots/mapbox"),r.categories=["mapbox","gl","symbols","showLegend","scatterlike"],r.meta={},e.exports=r},{"../../plots/mapbox":240,"../scatter/marker_colorbar":284,"../scattergeo/calc":294,"./attributes":295,"./defaults":297,"./event_data":298,"./hover":299,"./plot":301,"./select":302}],301:[function(t,e,n){"use strict";var r=t("./convert");function i(t,e){this.subplot=t,this.uid=e,this.sourceIds={fill:e+"-source-fill",line:e+"-source-line",circle:e+"-source-circle",symbol:e+"-source-symbol"},this.layerIds={fill:e+"-layer-fill",line:e+"-layer-line",circle:e+"-layer-circle",symbol:e+"-layer-symbol"},this.order=["fill","line","circle","symbol"]}var a=i.prototype;a.addSource=function(t,e){this.subplot.map.addSource(this.sourceIds[t],{type:"geojson",data:e.geojson})},a.setSourceData=function(t,e){this.subplot.map.getSource(this.sourceIds[t]).setData(e.geojson)},a.addLayer=function(t,e){this.subplot.map.addLayer({type:t,id:this.layerIds[t],source:this.sourceIds[t],layout:e.layout,paint:e.paint})},a.update=function(t){for(var e=this.subplot,n=r(t),i=0;i:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;margin-left:0px;margin-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var a in i){var o=a.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");r.addStyleRule(o,i[a])}},{"../src/lib":160}],2:[function(t,e,n){"use strict";e.exports={undo:{width:857.1,height:1e3,path:"m857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z",transform:"matrix(1 0 0 -1 0 850)"},home:{width:928.6,height:1e3,path:"m786 296v-267q0-15-11-26t-25-10h-214v214h-143v-214h-214q-15 0-25 10t-11 26v267q0 1 0 2t0 2l321 264 321-264q1-1 1-4z m124 39l-34-41q-5-5-12-6h-2q-7 0-12 3l-386 322-386-322q-7-4-13-4-7 2-12 7l-35 41q-4 5-3 13t6 12l401 334q18 15 42 15t43-15l136-114v109q0 8 5 13t13 5h107q8 0 13-5t5-13v-227l122-102q5-5 6-12t-4-13z",transform:"matrix(1 0 0 -1 0 850)"},"camera-retro":{width:1e3,height:1e3,path:"m518 386q0 8-5 13t-13 5q-37 0-63-27t-26-63q0-8 5-13t13-5 12 5 5 13q0 23 16 38t38 16q8 0 13 5t5 13z m125-73q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101z m-572-320h858v71h-858v-71z m643 320q0 89-62 152t-152 62-151-62-63-152 63-151 151-63 152 63 62 151z m-571 358h214v72h-214v-72z m-72-107h858v143h-462l-36-71h-360v-72z m929 143v-714q0-30-21-51t-50-21h-858q-29 0-50 21t-21 51v714q0 30 21 51t50 21h858q29 0 50-21t21-51z",transform:"matrix(1 0 0 -1 0 850)"},zoombox:{width:1e3,height:1e3,path:"m1000-25l-250 251c40 63 63 138 63 218 0 224-182 406-407 406-224 0-406-182-406-406s183-406 407-406c80 0 155 22 218 62l250-250 125 125z m-812 250l0 438 437 0 0-438-437 0z m62 375l313 0 0-312-313 0 0 312z",transform:"matrix(1 0 0 -1 0 850)"},pan:{width:1e3,height:1e3,path:"m1000 350l-187 188 0-125-250 0 0 250 125 0-188 187-187-187 125 0 0-250-250 0 0 125-188-188 186-187 0 125 252 0 0-250-125 0 187-188 188 188-125 0 0 250 250 0 0-126 187 188z",transform:"matrix(1 0 0 -1 0 850)"},zoom_plus:{width:875,height:1e3,path:"m1 787l0-875 875 0 0 875-875 0z m687-500l-187 0 0-187-125 0 0 187-188 0 0 125 188 0 0 187 125 0 0-187 187 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},zoom_minus:{width:875,height:1e3,path:"m0 788l0-876 875 0 0 876-875 0z m688-500l-500 0 0 125 500 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},autoscale:{width:1e3,height:1e3,path:"m250 850l-187 0-63 0 0-62 0-188 63 0 0 188 187 0 0 62z m688 0l-188 0 0-62 188 0 0-188 62 0 0 188 0 62-62 0z m-875-938l0 188-63 0 0-188 0-62 63 0 187 0 0 62-187 0z m875 188l0-188-188 0 0-62 188 0 62 0 0 62 0 188-62 0z m-125 188l-1 0-93-94-156 156 156 156 92-93 2 0 0 250-250 0 0-2 93-92-156-156-156 156 94 92 0 2-250 0 0-250 0 0 93 93 157-156-157-156-93 94 0 0 0-250 250 0 0 0-94 93 156 157 156-157-93-93 0 0 250 0 0 250z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_basic:{width:1500,height:1e3,path:"m375 725l0 0-375-375 375-374 0-1 1125 0 0 750-1125 0z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_compare:{width:1125,height:1e3,path:"m187 786l0 2-187-188 188-187 0 0 937 0 0 373-938 0z m0-499l0 1-187-188 188-188 0 0 937 0 0 376-938-1z",transform:"matrix(1 0 0 -1 0 850)"},plotlylogo:{width:1542,height:1e3,path:"m0-10h182v-140h-182v140z m228 146h183v-286h-183v286z m225 714h182v-1000h-182v1000z m225-285h182v-715h-182v715z m225 142h183v-857h-183v857z m231-428h182v-429h-182v429z m225-291h183v-138h-183v138z",transform:"matrix(1 0 0 -1 0 850)"},"z-axis":{width:1e3,height:1e3,path:"m833 5l-17 108v41l-130-65 130-66c0 0 0 38 0 39 0-1 36-14 39-25 4-15-6-22-16-30-15-12-39-16-56-20-90-22-187-23-279-23-261 0-341 34-353 59 3 60 228 110 228 110-140-8-351-35-351-116 0-120 293-142 474-142 155 0 477 22 477 142 0 50-74 79-163 96z m-374 94c-58-5-99-21-99-40 0-24 65-43 144-43 79 0 143 19 143 43 0 19-42 34-98 40v216h87l-132 135-133-135h88v-216z m167 515h-136v1c16 16 31 34 46 52l84 109v54h-230v-71h124v-1c-16-17-28-32-44-51l-89-114v-51h245v72z",transform:"matrix(1 0 0 -1 0 850)"},"3d_rotate":{width:1e3,height:1e3,path:"m922 660c-5 4-9 7-14 11-359 263-580-31-580-31l-102 28 58-400c0 1 1 1 2 2 118 108 351 249 351 249s-62 27-100 42c88 83 222 183 347 122 16-8 30-17 44-27-2 1-4 2-6 4z m36-329c0 0 64 229-88 296-62 27-124 14-175-11 157-78 225-208 249-266 8-19 11-31 11-31 2 5 6 15 11 32-5-13-8-20-8-20z m-775-239c70-31 117-50 198-32-121 80-199 346-199 346l-96-15-58-12c0 0 55-226 155-287z m603 133l-317-139c0 0 4-4 19-14 7-5 24-15 24-15s-177-147-389 4c235-287 536-112 536-112l31-22 100 299-4-1z m-298-153c6-4 14-9 24-15 0 0-17 10-24 15z",transform:"matrix(1 0 0 -1 0 850)"},camera:{width:1e3,height:1e3,path:"m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z m400 150h-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28l-31-94c-6-15-23-28-40-28h-120c-55 0-100-45-100-100v-450c0-55 45-100 100-100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250-250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35-35z",transform:"matrix(1 0 0 -1 0 850)"},movie:{width:1e3,height:1e3,path:"m938 413l-188-125c0 37-17 71-44 94 64 38 107 107 107 187 0 121-98 219-219 219-121 0-219-98-219-219 0-61 25-117 66-156h-115c30 33 49 76 49 125 0 103-84 187-187 187s-188-84-188-187c0-57 26-107 65-141-38-22-65-62-65-109v-250c0-70 56-126 125-126h500c69 0 125 56 125 126l188-126c34 0 62 28 62 63v375c0 35-28 63-62 63z m-750 0c-69 0-125 56-125 125s56 125 125 125 125-56 125-125-56-125-125-125z m406-1c-87 0-157 70-157 157 0 86 70 156 157 156s156-70 156-156-70-157-156-157z",transform:"matrix(1 0 0 -1 0 850)"},question:{width:857.1,height:1e3,path:"m500 82v107q0 8-5 13t-13 5h-107q-8 0-13-5t-5-13v-107q0-8 5-13t13-5h107q8 0 13 5t5 13z m143 375q0 49-31 91t-77 65-95 23q-136 0-207-119-9-14 4-24l74-55q4-4 10-4 9 0 14 7 30 38 48 51 19 14 48 14 27 0 48-15t21-33q0-21-11-34t-38-25q-35-16-65-48t-29-70v-20q0-8 5-13t13-5h107q8 0 13 5t5 13q0 10 12 27t30 28q18 10 28 16t25 19 25 27 16 34 7 45z m214-107q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z",transform:"matrix(1 0 0 -1 0 850)"},disk:{width:857.1,height:1e3,path:"m214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z",transform:"matrix(1 0 0 -1 0 850)"},lasso:{width:1031,height:1e3,path:"m1018 538c-36 207-290 336-568 286-277-48-473-256-436-463 10-57 36-108 76-151-13-66 11-137 68-183 34-28 75-41 114-42l-55-70 0 0c-2-1-3-2-4-3-10-14-8-34 5-45 14-11 34-8 45 4 1 1 2 3 2 5l0 0 113 140c16 11 31 24 45 40 4 3 6 7 8 11 48-3 100 0 151 9 278 48 473 255 436 462z m-624-379c-80 14-149 48-197 96 42 42 109 47 156 9 33-26 47-66 41-105z m-187-74c-19 16-33 37-39 60 50-32 109-55 174-68-42-25-95-24-135 8z m360 75c-34-7-69-9-102-8 8 62-16 128-68 170-73 59-175 54-244-5-9 20-16 40-20 61-28 159 121 317 333 354s407-60 434-217c28-159-121-318-333-355z",transform:"matrix(1 0 0 -1 0 850)"},selectbox:{width:1e3,height:1e3,path:"m0 850l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-285l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z",transform:"matrix(1 0 0 -1 0 850)"},spikeline:{width:1e3,height:1e3,path:"M512 409c0-57-46-104-103-104-57 0-104 47-104 104 0 57 47 103 104 103 57 0 103-46 103-103z m-327-39l92 0 0 92-92 0z m-185 0l92 0 0 92-92 0z m370-186l92 0 0 93-92 0z m0-184l92 0 0 92-92 0z",transform:"matrix(1.5 0 0 -1.5 0 850)"},newplotlylogo:{name:"newplotlylogo",svg:"plotly-logomark"}}},{}],3:[function(t,e,n){"use strict";e.exports=t("../src/core")},{"../src/core":142}],4:[function(t,e,n){"use strict";var r=t("./core");r.register([t("./scattermapbox")]),e.exports=r},{"./core":3,"./scattermapbox":5}],5:[function(t,e,n){"use strict";e.exports=t("../src/traces/scattermapbox")},{"../src/traces/scattermapbox":298}],6:[function(t,e,n){var r=Object.create||function(t){var e=function(){};return e.prototype=t,new e},i=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return n},a=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var s,l=10;try{var u={};Object.defineProperty&&Object.defineProperty(u,"x",{value:0}),s=0===u.x}catch(t){s=!1}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,n,i){var a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]):(o=t._events=r(null),t._eventsCount=0),s){if("function"==typeof s?s=o[e]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),!s.warned&&(a=c(t))&&a>0&&s.length>a){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=o[e]=n,++t._eventsCount;return t}function p(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(n=o[t]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=g(t,r),a=0;a=0;o--)if(n[o]===e||n[o].listener===e){s=n[o].listener,a=o;break}if(a<0)return this;0===a?n.shift():function(t,e){for(var n=e,r=n+1,i=t.length;r=0;a--)this.removeListener(t,e[a]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},o.prototype.listenerCount=m,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],7:[function(t,e,n){!function(){var t={version:"3.5.17"},n=[].slice,r=function(t){return n.call(t)},i=this.document;function a(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(i)try{r(i.documentElement.childNodes)[0].nodeType}catch(t){r=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),i)try{i.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var s=this.Element.prototype,l=s.setAttribute,u=s.setAttributeNS,c=this.CSSStyleDeclaration.prototype,f=c.setProperty;s.setAttribute=function(t,e){l.call(this,t,e+"")},s.setAttributeNS=function(t,e,n){u.call(this,t,e,n+"")},c.setProperty=function(t,e,n){f.call(this,t,e+"",n)}}function p(t,e){return te?1:t>=e?0:NaN}function h(t){return null===t?NaN:+t}function d(t){return!isNaN(t)}function m(t){return{left:function(e,n,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=e.length);r>>1;t(e[a],n)<0?r=a+1:i=a}return r},right:function(e,n,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=e.length);r>>1;t(e[a],n)>0?i=a:r=a+1}return r}}}t.ascending=p,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var n,r,i=-1,a=t.length;if(1===arguments.length){for(;++i=r){n=r;break}for(;++ir&&(n=r)}else{for(;++i=r){n=r;break}for(;++ir&&(n=r)}return n},t.max=function(t,e){var n,r,i=-1,a=t.length;if(1===arguments.length){for(;++i=r){n=r;break}for(;++in&&(n=r)}else{for(;++i=r){n=r;break}for(;++in&&(n=r)}return n},t.extent=function(t,e){var n,r,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=i=r;break}for(;++ar&&(n=r),i=r){n=i=r;break}for(;++ar&&(n=r),i1)return o/(l-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var g=m(p);function y(t){return t.length}t.bisectLeft=g.left,t.bisect=t.bisectRight=g.right,t.bisector=function(t){return m(1===t.length?function(e,n){return p(t(e),n)}:t)},t.shuffle=function(t,e,n){(a=arguments.length)<3&&(n=t.length,a<2&&(e=0));for(var r,i,a=n-e;a;)i=Math.random()*a--|0,r=t[a+e],t[a+e]=t[i+e],t[i+e]=r;return t},t.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},t.pairs=function(t){for(var e=0,n=t.length-1,r=t[0],i=new Array(n<0?0:n);e=0;)for(e=(r=t[i]).length;--e>=0;)n[--o]=r[e];return n};var v=Math.abs;function _(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function x(){this._=Object.create(null)}t.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n==1/0)throw new Error("infinite range");var r,i=[],a=function(t){var e=1;for(;t*e%1;)e*=10;return e}(v(n)),o=-1;if(t*=a,e*=a,(n*=a)<0)for(;(r=t+n*++o)>e;)i.push(r/a);else for(;(r=t+n*++o)=i.length)return n?n.call(r,a):e?a.sort(e):a;for(var l,u,c,f,p=-1,h=a.length,d=i[s++],m=new x;++p=i.length)return e;var r=[],o=a[n++];return e.forEach(function(e,i){r.push({key:e,values:t(i,n)})}),o?r.sort(function(t,e){return o(t.key,e.key)}):r}(o(t.map,e,0),0)},r.key=function(t){return i.push(t),r},r.sortKeys=function(t){return a[i.length-1]=t,r},r.sortValues=function(t){return e=t,r},r.rollup=function(t){return n=t,r},r},t.set=function(t){var e=new L;if(t)for(var n=0,r=t.length;n=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},t.event=null,t.requote=function(t){return t.replace(V,"\\$&")};var V=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,q={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]};function U(t){return q(t,$),t}var H=function(t,e){return e.querySelector(t)},Z=function(t,e){return e.querySelectorAll(t)},G=function(t,e){var n=t.matches||t[P(t,"matchesSelector")];return(G=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(H=function(t,e){return Sizzle(t,e)[0]||null},Z=Sizzle,G=Sizzle.matchesSelector),t.selection=function(){return t.select(i.documentElement)};var $=t.selection.prototype=[];function W(t){return"function"==typeof t?t:function(){return H(t,this)}}function X(t){return"function"==typeof t?t:function(){return Z(t,this)}}$.select=function(t){var e,n,r,i,a=[];t=W(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),J.hasOwnProperty(n)?{space:J[n],local:t}:t}},$.attr=function(e,n){if(arguments.length<2){if("string"==typeof e){var r=this.node();return(e=t.ns.qualify(e)).local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}for(n in e)this.each(K(n,e[n]));return this}return this.each(K(e,n))},$.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=et(t)).length,i=-1;if(e=n.classList){for(;++i=0;)(n=r[i])&&(a&&a!==n.nextSibling&&a.parentNode.insertBefore(n,a),a=n);return this},$.sort=function(t){t=function(t){arguments.length||(t=p);return function(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}}.apply(this,arguments);for(var e=-1,n=this.length;++e0&&(e=e.slice(0,o));var l=dt.get(e);function u(){var t=this[a];t&&(this.removeEventListener(e,t,t.$),delete this[a])}return l&&(e=l,s=gt),o?n?function(){var t=s(n,r(arguments));u.call(this),this.addEventListener(e,this[a]=t,t.$=i),t._=n}:u:n?O:function(){var n,r=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var i in this)if(n=i.match(r)){var a=this[i];this.removeEventListener(n[1],a,a.$),delete this[i]}}}t.selection.enter=ft,t.selection.enter.prototype=pt,pt.append=$.append,pt.empty=$.empty,pt.node=$.node,pt.call=$.call,pt.size=$.size,pt.select=function(t){for(var e,n,r,i,a,o=[],s=-1,l=this.length;++s=r&&(r=e+1);!(o=s[r])&&++r0?1:t<0?-1:0}function It(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function Pt(t){return t>1?0:t<-1?At:Math.acos(t)}function Dt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function Ot(t){return((t=Math.exp(t))+1/t)/2}function Rt(t){return(t=Math.sin(t/2))*t}var Ft=Math.SQRT2;t.interpolateZoom=function(t,e){var n,r,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],u=e[2],c=s-i,f=l-a,p=c*c+f*f;if(p0&&(e=e.transition().duration(m)),e.call(w.event)}function S(){u&&u.domain(l.range().map(function(t){return(t-p.x)/p.k}).map(l.invert)),f&&f.domain(c.range().map(function(t){return(t-p.y)/p.k}).map(c.invert))}function C(t){g++||t({type:"zoomstart"})}function z(t){S(),t({type:"zoom",scale:p.k,translate:[p.x,p.y]})}function L(t){--g||(t({type:"zoomend"}),n=null)}function E(){var e=this,n=b.of(e,arguments),r=0,i=t.select(o(e)).on(v,function(){r=1,A(t.mouse(e),a),z(n)}).on(_,function(){i.on(v,null).on(_,null),s(r),L(n)}),a=k(t.mouse(e)),s=_t(e);fs.call(e),C(n)}function I(){var e,n=this,r=b.of(n,arguments),i={},a=0,o=".zoom-"+t.event.changedTouches[0].identifier,l="touchmove"+o,u="touchend"+o,c=[],f=t.select(n),h=_t(n);function d(){var r=t.touches(n);return e=p.k,r.forEach(function(t){t.identifier in i&&(i[t.identifier]=k(t))}),r}function m(){var e=t.event.target;t.select(e).on(l,g).on(u,v),c.push(e);for(var r=t.event.changedTouches,o=0,f=r.length;o1){y=h[0];var _=h[1],x=y[0]-_[0],b=y[1]-_[1];a=x*x+b*b}}function g(){var o,l,u,c,f=t.touches(n);fs.call(n);for(var p=0,h=f.length;p360?t-=360:t<0&&(t+=360),t<60?r+(i-r)*t/60:t<180?i:t<240?r+(i-r)*(240-t)/60:r}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,r=2*(n=n<0?0:n>1?1:n)-(i=n<=.5?n*(1+e):n+e-n*e),new ae(a(t+120),a(t),a(t-120))}function Zt(e,n,r){return this instanceof Zt?(this.h=+e,this.c=+n,void(this.l=+r)):arguments.length<2?e instanceof Zt?new Zt(e.h,e.c,e.l):ee(e instanceof Wt?e.l:(e=pe((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Zt(e,n,r)}Ut.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,this.l/t)},Ut.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new qt(this.h,this.s,t*this.l)},Ut.rgb=function(){return Ht(this.h,this.s,this.l)},t.hcl=Zt;var Gt=Zt.prototype=new Vt;function $t(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Wt(n,Math.cos(t*=zt)*e,Math.sin(t)*e)}function Wt(t,e,n){return this instanceof Wt?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof Wt?new Wt(t.l,t.a,t.b):t instanceof Zt?$t(t.h,t.c,t.l):pe((t=ae(t)).r,t.g,t.b):new Wt(t,e,n)}Gt.brighter=function(t){return new Zt(this.h,this.c,Math.min(100,this.l+Xt*(arguments.length?t:1)))},Gt.darker=function(t){return new Zt(this.h,this.c,Math.max(0,this.l-Xt*(arguments.length?t:1)))},Gt.rgb=function(){return $t(this.h,this.c,this.l).rgb()},t.lab=Wt;var Xt=18,Yt=.95047,Jt=1,Kt=1.08883,Qt=Wt.prototype=new Vt;function te(t,e,n){var r=(t+16)/116,i=r+e/500,a=r-n/200;return new ae(ie(3.2404542*(i=ne(i)*Yt)-1.5371385*(r=ne(r)*Jt)-.4985314*(a=ne(a)*Kt)),ie(-.969266*i+1.8760108*r+.041556*a),ie(.0556434*i-.2040259*r+1.0572252*a))}function ee(t,e,n){return t>0?new Zt(Math.atan2(n,e)*Lt,Math.sqrt(e*e+n*n),t):new Zt(NaN,NaN,t)}function ne(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function re(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ie(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ae(t,e,n){return this instanceof ae?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof ae?new ae(t.r,t.g,t.b):ce(""+t,ae,Ht):new ae(t,e,n)}function oe(t){return new ae(t>>16,t>>8&255,255&t)}function se(t){return oe(t)+""}Qt.brighter=function(t){return new Wt(Math.min(100,this.l+Xt*(arguments.length?t:1)),this.a,this.b)},Qt.darker=function(t){return new Wt(Math.max(0,this.l-Xt*(arguments.length?t:1)),this.a,this.b)},Qt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ae;var le=ae.prototype=new Vt;function ue(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ce(t,e,n){var r,i,a,o=0,s=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return n(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(de(i[0]),de(i[1]),de(i[2]))}return(a=me.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o|=o>>4,s=240&a,s|=s>>4,l=15&a,l|=l<<4):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function fe(t,e,n){var r,i,a=Math.min(t/=255,e/=255,n/=255),o=Math.max(t,e,n),s=o-a,l=(o+a)/2;return s?(i=l<.5?s/(o+a):s/(2-o-a),r=t==o?(e-n)/s+(e0&&l<1?0:r),new qt(r,i,l)}function pe(t,e,n){var r=re((.4124564*(t=he(t))+.3575761*(e=he(e))+.1804375*(n=he(n)))/Yt),i=re((.2126729*t+.7151522*e+.072175*n)/Jt);return Wt(116*i-16,500*(r-i),200*(i-re((.0193339*t+.119192*e+.9503041*n)/Kt)))}function he(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function de(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}le.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,n=this.g,r=this.b,i=30;return e||n||r?(e&&e=200&&e<300||304===e){try{t=i.call(o,u)}catch(t){return void s.error.call(o,t)}s.load.call(o,t)}else s.error.call(o,u)}return!this.XDomainRequest||"withCredentials"in u||!/^(http(s)?:)?\/\//.test(e)||(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=f:u.onreadystatechange=function(){u.readyState>3&&f()},u.onprogress=function(e){var n=t.event;t.event=e;try{s.progress.call(o,u)}finally{t.event=n}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(n=null==t?null:t+"",o):n},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return i=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(r(arguments)))}}),o.send=function(t,r,i){if(2===arguments.length&&"function"==typeof r&&(i=r,r=null),u.open(t,e,!0),null==n||"accept"in l||(l.accept=n+",*/*"),u.setRequestHeader)for(var a in l)u.setRequestHeader(a,l[a]);return null!=n&&u.overrideMimeType&&u.overrideMimeType(n),null!=c&&(u.responseType=c),null!=i&&o.on("error",i).on("load",function(t){i(null,t)}),s.beforesend.call(o,u),u.send(null==r?null:r),o},o.abort=function(){return u.abort(),o},t.rebind(o,s,"on"),null==a?o:o.get(function(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}(a))}me.forEach(function(t,e){me.set(t,oe(e))}),t.functor=ge,t.xhr=ye(E),t.dsv=function(t,e){var n=new RegExp('["'+t+"\n]"),r=t.charCodeAt(0);function i(t,n,r){arguments.length<3&&(r=n,n=null);var i=ve(t,e,null==n?a:o(n),r);return i.row=function(t){return arguments.length?i.response(null==(n=t)?a:o(t)):n},i}function a(t){return i.parse(t.responseText)}function o(t){return function(e){return i.parse(e.responseText,t)}}function s(e){return e.map(l).join(t)}function l(t){return n.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,e){var n;return i.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,n){return e(i(t),n)}:i})},i.parseRows=function(t,e){var n,i,a={},o={},s=[],l=t.length,u=0,c=0;function f(){if(u>=l)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var n=e;n++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Ae,e)),be=0):(be=1,ke(Ae))}function Me(){for(var t=Date.now(),e=_e;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Se(){for(var t,e=_e,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}});t.formatPrefix=function(e,n){var r=0;return(e=+e)&&(e<0&&(e*=-1),n&&(e=t.round(e,Ce(e,n))),r=1+Math.floor(1e-12+Math.log(e)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ze[8+r/3]};var Le=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Ee=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,n){return(e=t.round(e,Ce(e,n))).toFixed(Math.max(0,Math.min(20,Ce(e*(1+1e-15),n))))}});function Ie(t){return t+""}var Pe=t.time={},De=Date;function Oe(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Oe.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Re.setUTCDate.apply(this._,arguments)},setDay:function(){Re.setUTCDay.apply(this._,arguments)},setFullYear:function(){Re.setUTCFullYear.apply(this._,arguments)},setHours:function(){Re.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Re.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Re.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Re.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Re.setUTCSeconds.apply(this._,arguments)},setTime:function(){Re.setTime.apply(this._,arguments)}};var Re=Date.prototype;function Fe(t,e,n){function r(e){var n=t(e),r=a(n,1);return e-n1)for(;o68?1900:2e3),n+i[0].length):-1}function Ye(t,e,n){return/^[+-]\d{4}$/.test(e=e.slice(n,n+5))?(t.Z=-e,n+5):-1}function Je(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Ke(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Qe(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function tn(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function en(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function nn(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function rn(t,e,n){je.lastIndex=0;var r=je.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function an(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=v(e)/60|0,i=v(e)%60;return n+qe(r,"0",2)+qe(i,"0",2)}function on(t,e,n){Ve.lastIndex=0;var r=Ve.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function sn(t){for(var e=t.length,n=-1;++n0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(n-=s,n+s)),!((l+=s+1)>e));)s=i[o=(o+1)%i.length];return a.reverse().join(r)}:E;return function(e){var r=Le.exec(e),i=r[1]||" ",s=r[2]||">",l=r[3]||"-",u=r[4]||"",c=r[5],f=+r[6],p=r[7],h=r[8],d=r[9],m=1,g="",y="",v=!1,_=!0;switch(h&&(h=+h.substring(1)),(c||"0"===i&&"="===s)&&(c=i="0",s="="),d){case"n":p=!0,d="g";break;case"%":m=100,y="%",d="f";break;case"p":m=100,y="%",d="r";break;case"b":case"o":case"x":case"X":"#"===u&&(g="0"+d.toLowerCase());case"c":_=!1;case"d":v=!0,h=0;break;case"s":m=-1,d="r"}"$"===u&&(g=a[0],y=a[1]),"r"!=d||h||(d="g"),null!=h&&("g"==d?h=Math.max(1,Math.min(21,h)):"e"!=d&&"f"!=d||(h=Math.max(0,Math.min(20,h)))),d=Ee.get(d)||Ie;var x=c&&p;return function(e){var r=y;if(v&&e%1)return"";var a=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===l?"":l;if(m<0){var u=t.formatPrefix(e,h);e=u.scale(e),r=u.symbol+y}else e*=m;var b,w,k=(e=d(e,h)).lastIndexOf(".");if(k<0){var T=_?e.lastIndexOf("e"):-1;T<0?(b=e,w=""):(b=e.substring(0,T),w=e.substring(T))}else b=e.substring(0,k),w=n+e.substring(k+1);!c&&p&&(b=o(b,1/0));var A=g.length+b.length+w.length+(x?0:a.length),M=A"===s?M+a+e:"^"===s?M.substring(0,A>>=1)+a+e+M.substring(A):a+(x?e:M+e))+r}}}(e),timeFormat:function(e){var n=e.dateTime,r=e.date,i=e.time,a=e.periods,o=e.days,s=e.shortDays,l=e.months,u=e.shortMonths;function c(t){var e=t.length;function n(n){for(var r,i,a,o=[],s=-1,l=0;++s=u)return-1;if(37===(i=e.charCodeAt(s++))){if(o=e.charAt(s++),!(a=w[o in Ne?e.charAt(s++):o])||(r=a(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}c.utc=function(t){var e=c(t);function n(t){try{var n=new(De=Oe);return n._=t,e(n)}finally{De=Date}}return n.parse=function(t){try{De=Oe;var n=e.parse(t);return n&&n._}finally{De=Date}},n.toString=e.toString,n},c.multi=c.utc.multi=sn;var p=t.map(),h=Ue(o),d=He(o),m=Ue(s),g=He(s),y=Ue(l),v=He(l),_=Ue(u),x=He(u);a.forEach(function(t,e){p.set(t.toLowerCase(),e)});var b={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:c(n),d:function(t,e){return qe(t.getDate(),e,2)},e:function(t,e){return qe(t.getDate(),e,2)},H:function(t,e){return qe(t.getHours(),e,2)},I:function(t,e){return qe(t.getHours()%12||12,e,2)},j:function(t,e){return qe(1+Pe.dayOfYear(t),e,3)},L:function(t,e){return qe(t.getMilliseconds(),e,3)},m:function(t,e){return qe(t.getMonth()+1,e,2)},M:function(t,e){return qe(t.getMinutes(),e,2)},p:function(t){return a[+(t.getHours()>=12)]},S:function(t,e){return qe(t.getSeconds(),e,2)},U:function(t,e){return qe(Pe.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return qe(Pe.mondayOfYear(t),e,2)},x:c(r),X:c(i),y:function(t,e){return qe(t.getFullYear()%100,e,2)},Y:function(t,e){return qe(t.getFullYear()%1e4,e,4)},Z:an,"%":function(){return"%"}},w={a:function(t,e,n){m.lastIndex=0;var r=m.exec(e.slice(n));return r?(t.w=g.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){h.lastIndex=0;var r=h.exec(e.slice(n));return r?(t.w=d.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){_.lastIndex=0;var r=_.exec(e.slice(n));return r?(t.m=x.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){y.lastIndex=0;var r=y.exec(e.slice(n));return r?(t.m=v.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,e,n){return f(t,b.c.toString(),e,n)},d:Ke,e:Ke,H:tn,I:tn,j:Qe,L:rn,m:Je,M:en,p:function(t,e,n){var r=p.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)},S:nn,U:Ge,w:Ze,W:$e,x:function(t,e,n){return f(t,b.x.toString(),e,n)},X:function(t,e,n){return f(t,b.X.toString(),e,n)},y:Xe,Y:We,Z:Ye,"%":on};return c}(e)}};var ln=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function un(){}t.format=ln.numberFormat,t.geo={},un.prototype={s:0,t:0,add:function(t){fn(t,this.t,cn),fn(cn.s,this.s,this),this.s?this.t+=cn.t:this.s=cn.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cn=new un;function fn(t,e,n){var r=n.s=t+e,i=r-t,a=r-i;n.t=t-a+(e-i)}function pn(t,e){t&&dn.hasOwnProperty(t.type)&&dn[t.type](t,e)}t.geo.stream=function(t,e){t&&hn.hasOwnProperty(t.type)?hn[t.type](t,e):pn(t,e)};var hn={Feature:function(t,e){pn(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r=0?1:-1,s=o*a,l=Math.cos(e),u=Math.sin(e),c=i*u,f=r*l+c*Math.cos(s),p=c*o*Math.sin(s);zn.add(Math.atan2(p,f)),n=t,r=l,i=u}Ln.point=function(o,s){Ln.point=a,n=(t=o)*zt,r=Math.cos(s=(e=s)*zt/2+At/4),i=Math.sin(s)},Ln.lineEnd=function(){a(t,e)}}function In(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function Pn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Dn(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function On(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Rn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Fn(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Bn(t){return[Math.atan2(t[1],t[0]),Dt(t[2])]}function Nn(t,e){return v(t[0]-e[0])kt?i=90:u<-kt&&(n=-90),f[0]=e,f[1]=r}};function h(t,a){c.push(f=[e=t,r=t]),ai&&(i=a)}function d(t,o){var s=In([t*zt,o*zt]);if(l){var u=Dn(l,s),c=Dn([u[1],-u[0],0],u);Fn(c),c=Bn(c);var f=t-a,p=f>0?1:-1,d=c[0]*Lt*p,m=v(f)>180;if(m^(p*ai&&(i=g);else if(m^(p*a<(d=(d+360)%360-180)&&di&&(i=o);m?tb(e,r)&&(r=t):b(t,r)>b(e,r)&&(e=t):r>=e?(tr&&(r=t)):t>a?b(e,t)>b(e,r)&&(r=t):b(t,r)>b(e,r)&&(e=t)}else h(t,o);l=s,a=t}function m(){p.point=d}function g(){f[0]=e,f[1]=r,p.point=h,l=null}function y(t,e){if(l){var n=t-a;u+=v(n)>180?n+(n>0?360:-360):n}else o=t,s=e;Ln.point(t,e),d(t,e)}function _(){Ln.lineStart()}function x(){y(o,s),Ln.lineEnd(),v(u)>kt&&(e=-(r=180)),f[0]=e,f[1]=r,l=null}function b(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tb(m[0],m[1])&&(m[1]=h[1]),b(h[0],m[1])>b(m[0],m[1])&&(m[0]=h[0])):s.push(m=h);for(var l,u,h,d=-1/0,m=(o=0,s[u=s.length-1]);o<=u;m=h,++o)h=s[o],(l=b(m[1],h[0]))>d&&(d=l,e=h[0],r=m[1])}return c=f=null,e===1/0||n===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,n],[r,i]]}}(),t.geo.centroid=function(e){vn=_n=xn=bn=wn=kn=Tn=An=Mn=Sn=Cn=0,t.geo.stream(e,jn);var n=Mn,r=Sn,i=Cn,a=n*n+r*r+i*i;return a=0;--s)i.point((f=c[s])[0],f[1]);else r(h.x,h.p.x,-1,i);h=h.p}c=(h=h.o).z,d=!d}while(!h.v);i.lineEnd()}}}function Xn(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r=0?1:-1,k=w*b,T=k>At,A=d*_;if(zn.add(Math.atan2(A*w*Math.sin(k),m*x+A*Math.cos(k))),a+=T?b+w*Mt:b,T^p>=n^y>=n){var M=Dn(In(f),In(t));Fn(M);var S=Dn(i,M);Fn(S);var C=(T^b>=0?-1:1)*Dt(S[2]);(r>C||r===C&&(M[0]||M[1]))&&(o+=T^b>=0?1:-1)}if(!g++)break;p=y,d=_,m=x,f=t}}return(a<-kt||a0){for(_||(o.polygonStart(),_=!0),o.lineStart();++a1&&2&e&&n.push(n.pop().concat(n.shift())),s.push(n.filter(Kn))}return c}}function Kn(t){return t.length>1}function Qn(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:O,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function tr(t,e){return((t=t.x)[0]<0?t[1]-Ct-kt:Ct-t[1])-((e=e.x)[0]<0?e[1]-Ct-kt:Ct-e[1])}var er=Jn($n,function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?At:-At,l=v(a-n);v(l-At)0?Ct:-Ct),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(a,r),e=0):i!==s&&l>=At&&(v(n-i)kt?Math.atan((Math.sin(e)*(a=Math.cos(r))*Math.sin(n)-Math.sin(r)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+r)/2}(n,r,a,o),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),e=0),t.point(n=a,r=o),i=s},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}},function(t,e,n,r){var i;if(null==t)i=n*Ct,r.point(-At,i),r.point(0,i),r.point(At,i),r.point(At,0),r.point(At,-i),r.point(0,-i),r.point(-At,-i),r.point(-At,0),r.point(-At,i);else if(v(t[0]-e[0])>kt){var a=t[0]0)){if(a/=p,p<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=n-l,p||!(a<0)){if(a/=p,p<0){if(a>f)return;a>c&&(c=a)}else if(p>0){if(a0)){if(a/=h,h<0){if(a0){if(a>f)return;a>c&&(c=a)}if(a=r-u,h||!(a<0)){if(a/=h,h<0){if(a>f)return;a>c&&(c=a)}else if(h>0){if(a0&&(i.a={x:l+c*p,y:u+c*h}),f<1&&(i.b={x:l+f*p,y:u+f*h}),i}}}}}}var rr=1e9;function ir(e,n,r,i){return function(l){var u,c,f,p,h,d,m,g,y,v,_,x=l,b=Qn(),w=nr(e,n,r,i),k={point:M,lineStart:function(){k.point=S,c&&c.push(f=[]);v=!0,y=!1,m=g=NaN},lineEnd:function(){u&&(S(p,h),d&&y&&b.rejoin(),u.push(b.buffer()));k.point=M,y&&l.lineEnd()},polygonStart:function(){l=b,u=[],c=[],_=!0},polygonEnd:function(){l=x,u=t.merge(u);var n=function(t){for(var e=0,n=c.length,r=t[1],i=0;ir&&It(u,a,t)>0&&++e:a[1]<=r&&It(u,a,t)<0&&--e,u=a;return 0!==e}([e,i]),r=_&&n,a=u.length;(r||a)&&(l.polygonStart(),r&&(l.lineStart(),T(null,null,1,l),l.lineEnd()),a&&Wn(u,o,n,T,l),l.polygonEnd()),u=c=f=null}};function T(t,o,l,u){var c=0,f=0;if(null==t||(c=a(t,l))!==(f=a(o,l))||s(t,o)<0^l>0)do{u.point(0===c||3===c?e:r,c>1?i:n)}while((c=(c+l+4)%4)!==f);else u.point(o[0],o[1])}function A(t,a){return e<=t&&t<=r&&n<=a&&a<=i}function M(t,e){A(t,e)&&l.point(t,e)}function S(t,e){var n=A(t=Math.max(-rr,Math.min(rr,t)),e=Math.max(-rr,Math.min(rr,e)));if(c&&f.push([t,e]),v)p=t,h=e,d=n,v=!1,n&&(l.lineStart(),l.point(t,e));else if(n&&y)l.point(t,e);else{var r={a:{x:m,y:g},b:{x:t,y:e}};w(r)?(y||(l.lineStart(),l.point(r.a.x,r.a.y)),l.point(r.b.x,r.b.y),n||l.lineEnd(),_=!1):n&&(l.lineStart(),l.point(t,e),_=!1)}m=t,g=e,y=n}return k};function a(t,i){return v(t[0]-e)0?0:3:v(t[0]-r)0?2:1:v(t[1]-n)0?1:0:i>0?3:2}function o(t,e){return s(t.x,e.x)}function s(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}}function ar(t){var e=0,n=At/3,r=zr(t),i=r(e,n);return i.parallels=function(t){return arguments.length?r(e=t[0]*At/180,n=t[1]*At/180):[e/At*180,n/At*180]},i}function or(t,e){var n=Math.sin(t),r=(n+Math.sin(e))/2,i=1+n*(2*r-n),a=Math.sqrt(i)/r;function o(t,e){var n=Math.sqrt(i-2*r*Math.sin(e))/r;return[n*Math.sin(t*=r),a-n*Math.cos(t)]}return o.invert=function(t,e){var n=a-e;return[Math.atan2(t,n)/r,Dt((i-(t*t+n*n)*r*r)/(2*r))]},o}t.geo.clipExtent=function(){var t,e,n,r,i,a,o={stream:function(t){return i&&(i.valid=!1),(i=a(t)).valid=!0,i},extent:function(s){return arguments.length?(a=ir(t=+s[0][0],e=+s[0][1],n=+s[1][0],r=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[n,r]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return ar(or)}).raw=or,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,n,r,i,a=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,n){e=[t,n]}};function u(t){var a=t[0],o=t[1];return e=null,n(a,o),e||(r(a,o),e)||i(a,o),e}return u.invert=function(t){var e=a.scale(),n=a.translate(),r=(t[0]-n[0])/e,i=(t[1]-n[1])/e;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?o:i>=.166&&i<.234&&r>=-.214&&r<-.115?s:a).invert(t)},u.stream=function(t){var e=a.stream(t),n=o.stream(t),r=s.stream(t);return{point:function(t,i){e.point(t,i),n.point(t,i),r.point(t,i)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},u.precision=function(t){return arguments.length?(a.precision(t),o.precision(t),s.precision(t),u):a.precision()},u.scale=function(t){return arguments.length?(a.scale(t),o.scale(.35*t),s.scale(t),u.translate(a.translate())):a.scale()},u.translate=function(t){if(!arguments.length)return a.translate();var e=a.scale(),c=+t[0],f=+t[1];return n=a.translate(t).clipExtent([[c-.455*e,f-.238*e],[c+.455*e,f+.238*e]]).stream(l).point,r=o.translate([c-.307*e,f+.201*e]).clipExtent([[c-.425*e+kt,f+.12*e+kt],[c-.214*e-kt,f+.234*e-kt]]).stream(l).point,i=s.translate([c-.205*e,f+.212*e]).clipExtent([[c-.214*e+kt,f+.166*e+kt],[c-.115*e-kt,f+.234*e-kt]]).stream(l).point,u},u.scale(1070)};var sr,lr,ur,cr,fr,pr,hr={point:O,lineStart:O,lineEnd:O,polygonStart:function(){lr=0,hr.lineStart=dr},polygonEnd:function(){hr.lineStart=hr.lineEnd=hr.point=O,sr+=v(lr/2)}};function dr(){var t,e,n,r;function i(t,e){lr+=r*t-n*e,n=t,r=e}hr.point=function(a,o){hr.point=i,t=n=a,e=r=o},hr.lineEnd=function(){i(t,e)}}var mr={point:function(t,e){tfr&&(fr=t);epr&&(pr=e)},lineStart:O,lineEnd:O,polygonStart:O,polygonEnd:O};function gr(){var t=yr(4.5),e=[],n={point:r,lineStart:function(){n.point=i},lineEnd:o,polygonStart:function(){n.lineEnd=s},polygonEnd:function(){n.lineEnd=o,n.point=r},pointRadius:function(e){return t=yr(e),n},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function r(n,r){e.push("M",n,",",r,t)}function i(t,r){e.push("M",t,",",r),n.point=a}function a(t,n){e.push("L",t,",",n)}function o(){n.point=r}function s(){e.push("Z")}return n}function yr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var vr,_r={point:xr,lineStart:br,lineEnd:wr,polygonStart:function(){_r.lineStart=kr},polygonEnd:function(){_r.point=xr,_r.lineStart=br,_r.lineEnd=wr}};function xr(t,e){xn+=t,bn+=e,++wn}function br(){var t,e;function n(n,r){var i=n-t,a=r-e,o=Math.sqrt(i*i+a*a);kn+=o*(t+n)/2,Tn+=o*(e+r)/2,An+=o,xr(t=n,e=r)}_r.point=function(r,i){_r.point=n,xr(t=r,e=i)}}function wr(){_r.point=xr}function kr(){var t,e,n,r;function i(t,e){var i=t-n,a=e-r,o=Math.sqrt(i*i+a*a);kn+=o*(n+t)/2,Tn+=o*(r+e)/2,An+=o,Mn+=(o=r*t-n*e)*(n+t),Sn+=o*(r+e),Cn+=3*o,xr(n=t,r=e)}_r.point=function(a,o){_r.point=i,xr(t=n=a,e=r=o)},_r.lineEnd=function(){i(t,e)}}function Tr(t){var e=4.5,n={point:r,lineStart:function(){n.point=i},lineEnd:o,polygonStart:function(){n.lineEnd=s},polygonEnd:function(){n.lineEnd=o,n.point=r},pointRadius:function(t){return e=t,n},result:O};function r(n,r){t.moveTo(n+e,r),t.arc(n,r,e,0,Mt)}function i(e,r){t.moveTo(e,r),n.point=a}function a(e,n){t.lineTo(e,n)}function o(){n.point=r}function s(){t.closePath()}return n}function Ar(t){var e=.5,n=Math.cos(30*zt),r=16;function i(e){return(r?function(e){var n,i,o,s,l,u,c,f,p,h,d,m,g={point:y,lineStart:v,lineEnd:x,polygonStart:function(){e.polygonStart(),g.lineStart=b},polygonEnd:function(){e.polygonEnd(),g.lineStart=v}};function y(n,r){n=t(n,r),e.point(n[0],n[1])}function v(){f=NaN,g.point=_,e.lineStart()}function _(n,i){var o=In([n,i]),s=t(n,i);a(f,p,c,h,d,m,f=s[0],p=s[1],c=n,h=o[0],d=o[1],m=o[2],r,e),e.point(f,p)}function x(){g.point=y,e.lineEnd()}function b(){v(),g.point=w,g.lineEnd=k}function w(t,e){_(n=t,e),i=f,o=p,s=h,l=d,u=m,g.point=_}function k(){a(f,p,c,h,d,m,i,o,n,s,l,u,r,e),g.lineEnd=x,x()}return g}:function(e){return Sr(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})})(e)}function a(r,i,o,s,l,u,c,f,p,h,d,m,g,y){var _=c-r,x=f-i,b=_*_+x*x;if(b>4*e&&g--){var w=s+h,k=l+d,T=u+m,A=Math.sqrt(w*w+k*k+T*T),M=Math.asin(T/=A),S=v(v(T)-1)e||v((_*E+x*I)/b-.5)>.3||s*h+l*d+u*m0&&16,i):Math.sqrt(e)},i}function Mr(t){this.stream=t}function Sr(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Cr(t){return zr(function(){return t})()}function zr(e){var n,r,i,a,o,s,l=Ar(function(t,e){return[(t=n(t,e))[0]*u+a,o-t[1]*u]}),u=150,c=480,f=250,p=0,h=0,d=0,m=0,g=0,y=er,_=E,x=null,b=null;function w(t){return[(t=i(t[0]*zt,t[1]*zt))[0]*u+a,o-t[1]*u]}function k(t){return(t=i.invert((t[0]-a)/u,(o-t[1])/u))&&[t[0]*Lt,t[1]*Lt]}function T(){i=Gn(r=Pr(d,m,g),n);var t=n(p,h);return a=c-t[0]*u,o=f+t[1]*u,A()}function A(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Lr(y(r,l(_(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(y=null==t?(x=t,er):function(t){var e=Math.cos(t),n=e>0,r=v(e)>kt;return Jn(i,function(t){var e,s,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(f,p){var h,d=[f,p],m=i(f,p),g=n?m?0:o(f,p):m?o(f+(f<0?At:-At),p):0;if(!e&&(u=l=m)&&t.lineStart(),m!==l&&(h=a(e,d),(Nn(e,h)||Nn(d,h))&&(d[0]+=kt,d[1]+=kt,m=i(d[0],d[1]))),m!==l)c=0,m?(t.lineStart(),h=a(d,e),t.point(h[0],h[1])):(h=a(e,d),t.point(h[0],h[1]),t.lineEnd()),e=h;else if(r&&e&&n^m){var y;g&s||!(y=a(d,e,!0))||(c=0,n?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!m||e&&Nn(e,d)||t.point(d[0],d[1]),e=d,l=m,s=g},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return c|(u&&l)<<1}}},Fr(t,6*zt),n?[0,-t]:[-At,t-At]);function i(t,n){return Math.cos(t)*Math.cos(n)>e}function a(t,n,r){var i=[1,0,0],a=Dn(In(t),In(n)),o=Pn(a,a),s=a[0],l=o-s*s;if(!l)return!r&&t;var u=e*o/l,c=-e*s/l,f=Dn(i,a),p=Rn(i,u);On(p,Rn(a,c));var h=f,d=Pn(p,h),m=Pn(h,h),g=d*d-m*(Pn(p,p)-1);if(!(g<0)){var y=Math.sqrt(g),_=Rn(h,(-d-y)/m);if(On(_,p),_=Bn(_),!r)return _;var x,b=t[0],w=n[0],k=t[1],T=n[1];w0^_[1]<(v(_[0]-b)At^(b<=_[0]&&_[0]<=w)){var S=Rn(h,(-d+y)/m);return On(S,p),[_,Bn(S)]}}}function o(e,r){var i=n?t:At-t,a=0;return e<-i?a|=1:e>i&&(a|=2),r<-i?a|=4:r>i&&(a|=8),a}}((x=+t)*zt),A()):x},w.clipExtent=function(t){return arguments.length?(b=t,_=t?ir(t[0][0],t[0][1],t[1][0],t[1][1]):E,A()):b},w.scale=function(t){return arguments.length?(u=+t,T()):u},w.translate=function(t){return arguments.length?(c=+t[0],f=+t[1],T()):[c,f]},w.center=function(t){return arguments.length?(p=t[0]%360*zt,h=t[1]%360*zt,T()):[p*Lt,h*Lt]},w.rotate=function(t){return arguments.length?(d=t[0]%360*zt,m=t[1]%360*zt,g=t.length>2?t[2]%360*zt:0,T()):[d*Lt,m*Lt,g*Lt]},t.rebind(w,l,"precision"),function(){return n=e.apply(this,arguments),w.invert=n.invert&&k,T()}}function Lr(t){return Sr(t,function(e,n){t.point(e*zt,n*zt)})}function Er(t,e){return[t,e]}function Ir(t,e){return[t>At?t-Mt:t<-At?t+Mt:t,e]}function Pr(t,e,n){return t?e||n?Gn(Or(t),Rr(e,n)):Or(t):e||n?Rr(e,n):Ir}function Dr(t){return function(e,n){return[(e+=t)>At?e-Mt:e<-At?e+Mt:e,n]}}function Or(t){var e=Dr(t);return e.invert=Dr(-t),e}function Rr(t,e){var n=Math.cos(t),r=Math.sin(t),i=Math.cos(e),a=Math.sin(e);function o(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*n+s*r;return[Math.atan2(l*i-c*a,s*n-u*r),Dt(c*i+l*a)]}return o.invert=function(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,u=Math.sin(e),c=u*i-l*a;return[Math.atan2(l*i+u*a,s*n+c*r),Dt(c*n-s*r)]},o}function Fr(t,e){var n=Math.cos(t),r=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=Br(n,i),a=Br(n,a),(o>0?ia)&&(i+=o*Mt)):(i=t+o*Mt,a=t-.5*l);for(var u,c=i;o>0?c>a:c2?t[2]*zt:0),e.invert=function(e){return(e=t.invert(e[0]*zt,e[1]*zt))[0]*=Lt,e[1]*=Lt,e},e},Ir.invert=Er,t.geo.circle=function(){var t,e,n=[0,0],r=6;function i(){var t="function"==typeof n?n.apply(this,arguments):n,r=Pr(-t[0]*zt,-t[1]*zt,0).invert,i=[];return e(null,null,1,{point:function(t,e){i.push(t=r(t,e)),t[0]*=Lt,t[1]*=Lt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(n=t,i):n},i.angle=function(n){return arguments.length?(e=Fr((t=+n)*zt,r*zt),i):t},i.precision=function(n){return arguments.length?(e=Fr(t*zt,(r=+n)*zt),i):r},i.angle(90)},t.geo.distance=function(t,e){var n,r=(e[0]-t[0])*zt,i=t[1]*zt,a=e[1]*zt,o=Math.sin(r),s=Math.cos(r),l=Math.sin(i),u=Math.cos(i),c=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((n=f*o)*n+(n=u*c-l*f*s)*n),l*c+u*f*s)},t.geo.graticule=function(){var e,n,r,i,a,o,s,l,u,c,f,p,h=10,d=h,m=90,g=360,y=2.5;function _(){return{type:"MultiLineString",coordinates:x()}}function x(){return t.range(Math.ceil(i/m)*m,r,m).map(f).concat(t.range(Math.ceil(l/g)*g,s,g).map(p)).concat(t.range(Math.ceil(n/h)*h,e,h).filter(function(t){return v(t%m)>kt}).map(u)).concat(t.range(Math.ceil(o/d)*d,a,d).filter(function(t){return v(t%g)>kt}).map(c))}return _.lines=function(){return x().map(function(t){return{type:"LineString",coordinates:t}})},_.outline=function(){return{type:"Polygon",coordinates:[f(i).concat(p(s).slice(1),f(r).reverse().slice(1),p(l).reverse().slice(1))]}},_.extent=function(t){return arguments.length?_.majorExtent(t).minorExtent(t):_.minorExtent()},_.majorExtent=function(t){return arguments.length?(i=+t[0][0],r=+t[1][0],l=+t[0][1],s=+t[1][1],i>r&&(t=i,i=r,r=t),l>s&&(t=l,l=s,s=t),_.precision(y)):[[i,l],[r,s]]},_.minorExtent=function(t){return arguments.length?(n=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],n>e&&(t=n,n=e,e=t),o>a&&(t=o,o=a,a=t),_.precision(y)):[[n,o],[e,a]]},_.step=function(t){return arguments.length?_.majorStep(t).minorStep(t):_.minorStep()},_.majorStep=function(t){return arguments.length?(m=+t[0],g=+t[1],_):[m,g]},_.minorStep=function(t){return arguments.length?(h=+t[0],d=+t[1],_):[h,d]},_.precision=function(t){return arguments.length?(y=+t,u=Nr(o,a,90),c=jr(n,e,y),f=Nr(l,s,90),p=jr(i,r,y),_):y},_.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,n,r=Vr,i=qr;function a(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||i.apply(this,arguments)]}}return a.distance=function(){return t.geo.distance(e||r.apply(this,arguments),n||i.apply(this,arguments))},a.source=function(t){return arguments.length?(r=t,e="function"==typeof t?null:t,a):r},a.target=function(t){return arguments.length?(i=t,n="function"==typeof t?null:t,a):i},a.precision=function(){return arguments.length?a:0},a},t.geo.interpolate=function(t,e){return n=t[0]*zt,r=t[1]*zt,i=e[0]*zt,a=e[1]*zt,o=Math.cos(r),s=Math.sin(r),l=Math.cos(a),u=Math.sin(a),c=o*Math.cos(n),f=o*Math.sin(n),p=l*Math.cos(i),h=l*Math.sin(i),d=2*Math.asin(Math.sqrt(Rt(a-r)+o*l*Rt(i-n))),m=1/Math.sin(d),(g=d?function(t){var e=Math.sin(t*=d)*m,n=Math.sin(d-t)*m,r=n*c+e*p,i=n*f+e*h,a=n*s+e*u;return[Math.atan2(i,r)*Lt,Math.atan2(a,Math.sqrt(r*r+i*i))*Lt]}:function(){return[n*Lt,r*Lt]}).distance=d,g;var n,r,i,a,o,s,l,u,c,f,p,h,d,m,g},t.geo.length=function(e){return vr=0,t.geo.stream(e,Ur),vr};var Ur={sphere:O,point:O,lineStart:function(){var t,e,n;function r(r,i){var a=Math.sin(i*=zt),o=Math.cos(i),s=v((r*=zt)-t),l=Math.cos(s);vr+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-e*o*l)*s),e*a+n*o*l),t=r,e=a,n=o}Ur.point=function(i,a){t=i*zt,e=Math.sin(a*=zt),n=Math.cos(a),Ur.point=r},Ur.lineEnd=function(){Ur.point=Ur.lineEnd=O}},lineEnd:O,polygonStart:O,polygonEnd:O};function Hr(t,e){function n(e,n){var r=Math.cos(e),i=Math.cos(n),a=t(r*i);return[a*i*Math.sin(e),a*Math.sin(n)]}return n.invert=function(t,n){var r=Math.sqrt(t*t+n*n),i=e(r),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,r*o),Math.asin(r&&n*a/r)]},n}var Zr=Hr(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Cr(Zr)}).raw=Zr;var Gr=Hr(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},E);function $r(t,e){var n=Math.cos(t),r=function(t){return Math.tan(At/4+t/2)},i=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(r(e)/r(t)),a=n*Math.pow(r(t),i)/i;if(!i)return Yr;function o(t,e){a>0?e<-Ct+kt&&(e=-Ct+kt):e>Ct-kt&&(e=Ct-kt);var n=a/Math.pow(r(e),i);return[n*Math.sin(i*t),a-n*Math.cos(i*t)]}return o.invert=function(t,e){var n=a-e,r=Et(i)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/i,2*Math.atan(Math.pow(a/r,1/i))-Ct]},o}function Wr(t,e){var n=Math.cos(t),r=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),i=n/r+t;if(v(r)1&&It(t[n[r-2]],t[n[r-1]],t[i])<=0;)--r;n[r++]=i}return n.slice(0,r)}function ii(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Cr(Qr)}).raw=Qr,ti.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ct]},(t.geo.transverseMercator=function(){var t=Jr(ti),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):[(t=n())[0],t[1],t[2]-90]},n([0,0,90])}).raw=ti,t.geom={},t.geom.hull=function(t){var e=ei,n=ni;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,i=ge(e),a=ge(n),o=t.length,s=[],l=[];for(r=0;r=0;--r)h.push(t[s[u[r]][2]]);for(r=+f;rkt)s=s.L;else{if(!((i=a-wi(s,o))>kt)){r>-kt?(e=s.P,n=s):i>-kt?(e=s,n=s.N):e=n=s;break}if(!s.R){e=s;break}s=s.R}var l=yi(t);if(fi.insert(e,l),e||n){if(e===n)return Si(e),n=yi(e.site),fi.insert(l,n),l.edge=n.edge=Li(e.site,l.site),Mi(e),void Mi(n);if(n){Si(e),Si(n);var u=e.site,c=u.x,f=u.y,p=t.x-c,h=t.y-f,d=n.site,m=d.x-c,g=d.y-f,y=2*(p*g-h*m),v=p*p+h*h,_=m*m+g*g,x={x:(g*v-h*_)/y+c,y:(p*_-m*v)/y+f};Ei(n.edge,u,d,x),l.edge=Li(u,t,null,x),n.edge=Li(t,d,null,x),Mi(e),Mi(n)}else l.edge=Li(e.site,l.site)}}function bi(t,e){var n=t.site,r=n.x,i=n.y,a=i-e;if(!a)return r;var o=t.P;if(!o)return-1/0;var s=(n=o.site).x,l=n.y,u=l-e;if(!u)return s;var c=s-r,f=1/a-1/u,p=c/u;return f?(-p+Math.sqrt(p*p-2*f*(c*c/(-2*u)-l+u/2+i-a/2)))/f+r:(r+s)/2}function wi(t,e){var n=t.N;if(n)return bi(n,e);var r=t.site;return r.y===e?r.x:1/0}function ki(t){this.site=t,this.edges=[]}function Ti(t,e){return e.angle-t.angle}function Ai(){Di(this),this.x=this.y=this.arc=this.site=this.cy=null}function Mi(t){var e=t.P,n=t.N;if(e&&n){var r=e.site,i=t.site,a=n.site;if(r!==a){var o=i.x,s=i.y,l=r.x-o,u=r.y-s,c=a.x-o,f=2*(l*(g=a.y-s)-u*c);if(!(f>=-Tt)){var p=l*l+u*u,h=c*c+g*g,d=(g*p-u*h)/f,m=(l*h-c*p)/f,g=m+s,y=mi.pop()||new Ai;y.arc=t,y.site=i,y.x=d+o,y.y=g+Math.sqrt(d*d+m*m),y.cy=g,t.circle=y;for(var v=null,_=hi._;_;)if(y.y<_.y||y.y===_.y&&y.x<=_.x){if(!_.L){v=_.P;break}_=_.L}else{if(!_.R){v=_;break}_=_.R}hi.insert(v,y),v||(pi=y)}}}}function Si(t){var e=t.circle;e&&(e.P||(pi=e.N),hi.remove(e),mi.push(e),Di(e),t.circle=null)}function Ci(t,e){var n=t.b;if(n)return!0;var r,i,a=t.a,o=e[0][0],s=e[1][0],l=e[0][1],u=e[1][1],c=t.l,f=t.r,p=c.x,h=c.y,d=f.x,m=f.y,g=(p+d)/2,y=(h+m)/2;if(m===h){if(g=s)return;if(p>d){if(a){if(a.y>=u)return}else a={x:g,y:l};n={x:g,y:u}}else{if(a){if(a.y1)if(p>d){if(a){if(a.y>=u)return}else a={x:(l-i)/r,y:l};n={x:(u-i)/r,y:u}}else{if(a){if(a.y=s)return}else a={x:o,y:r*o+i};n={x:s,y:r*s+i}}else{if(a){if(a.xkt||v(i-n)>kt)&&(s.splice(o,0,new Ii((y=a.site,_=c,x=v(r-f)kt?{x:f,y:v(e-f)kt?{x:v(n-d)kt?{x:p,y:v(e-p)kt?{x:v(n-h)=n&&u.x<=i&&u.y>=r&&u.y<=o?[[n,o],[i,o],[i,r],[n,r]]:[]).point=t[s]}),e}function s(t){return t.map(function(t,e){return{x:Math.round(r(t,e)/kt)*kt,y:Math.round(i(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Bi(s(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Bi(s(t)).cells.forEach(function(n,r){for(var i,a,o,s,l=n.site,u=n.edges.sort(Ti),c=-1,f=u.length,p=u[f-1].edge,h=p.l===l?p.r:p.l;++ca&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,l.push({i:o,x:Zi(n,r)})),a=Wi.lastIndex;return am&&(m=l.x),l.y>g&&(g=l.y),u.push(l.x),c.push(l.y);else for(f=0;fm&&(m=x),b>g&&(g=b),u.push(x),c.push(b)}var w=m-h,k=g-d;function T(t,e,n,r,i,a,o,s){if(!isNaN(n)&&!isNaN(r))if(t.leaf){var l=t.x,u=t.y;if(null!=l)if(v(l-n)+v(u-r)<.01)A(t,e,n,r,i,a,o,s);else{var c=t.point;t.x=t.y=t.point=null,A(t,c,l,u,i,a,o,s),A(t,e,n,r,i,a,o,s)}else t.x=n,t.y=r,t.point=e}else A(t,e,n,r,i,a,o,s)}function A(t,e,n,r,i,a,o,s){var l=.5*(i+o),u=.5*(a+s),c=n>=l,f=r>=u,p=f<<1|c;t.leaf=!1,c?i=l:o=l,f?a=u:s=u,T(t=t.nodes[p]||(t.nodes[p]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(M,t,+y(t,++f),+_(t,f),h,d,m,g)}}),e,n,r,i,a,o,s)}w>k?g=d+w:m=h+k;var M={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){T(M,t,+y(t,++f),+_(t,f),h,d,m,g)}};if(M.visit=function(t){!function t(e,n,r,i,a,o){if(!e(n,r,i,a,o)){var s=.5*(r+a),l=.5*(i+o),u=n.nodes;u[0]&&t(e,u[0],r,i,s,l),u[1]&&t(e,u[1],s,i,a,l),u[2]&&t(e,u[2],r,l,s,o),u[3]&&t(e,u[3],s,l,a,o)}}(t,M,h,d,m,g)},M.find=function(t){return function(t,e,n,r,i,a,o){var s,l=1/0;return function t(u,c,f,p,h){if(!(c>a||f>o||p=b)<<1|e>=x,k=w+4;w=0&&!(r=t.interpolators[i](e,n)););return r}function Yi(t,e){var n,r=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(n=0;n=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function aa(t){return 1-Math.cos(t*Ct)}function oa(t){return Math.pow(2,10*(t-1))}function sa(t){return 1-Math.sqrt(1-t*t)}function la(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ua(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function ca(t){var e,n,r,i=[t.a,t.b],a=[t.c,t.d],o=pa(i),s=fa(i,a),l=pa(((e=a)[0]+=(r=-s)*(n=i)[0],e[1]+=r*n[1],e))||0;i[0]*a[1]=0?t.slice(0,r):t,a=r>=0?t.slice(r+1):"in";return i=Ki.get(i)||Ji,a=Qi.get(a)||E,e=a(i.apply(null,n.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,n){e=t.hcl(e),n=t.hcl(n);var r=e.h,i=e.c,a=e.l,o=n.h-r,s=n.c-i,l=n.l-a;isNaN(s)&&(s=0,i=isNaN(i)?n.c:i);isNaN(o)?(o=0,r=isNaN(r)?n.h:r):o>180?o-=360:o<-180&&(o+=360);return function(t){return $t(r+o*t,i+s*t,a+l*t)+""}},t.interpolateHsl=function(e,n){e=t.hsl(e),n=t.hsl(n);var r=e.h,i=e.s,a=e.l,o=n.h-r,s=n.s-i,l=n.l-a;isNaN(s)&&(s=0,i=isNaN(i)?n.s:i);isNaN(o)?(o=0,r=isNaN(r)?n.h:r):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ht(r+o*t,i+s*t,a+l*t)+""}},t.interpolateLab=function(e,n){e=t.lab(e),n=t.lab(n);var r=e.l,i=e.a,a=e.b,o=n.l-r,s=n.a-i,l=n.b-a;return function(t){return te(r+o*t,i+s*t,a+l*t)+""}},t.interpolateRound=ua,t.transform=function(e){var n=i.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){n.setAttribute("transform",t);var e=n.transform.baseVal.consolidate()}return new ca(e?e.matrix:ha)})(e)},ca.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var ha={a:1,b:0,c:0,d:1,e:0,f:0};function da(t){return t.length?t.pop()+",":""}function ma(e,n){var r=[],i=[];return e=t.transform(e),n=t.transform(n),function(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var i=n.push("translate(",null,",",null,")");r.push({i:i-4,x:Zi(t[0],e[0])},{i:i-2,x:Zi(t[1],e[1])})}else(e[0]||e[1])&&n.push("translate("+e+")")}(e.translate,n.translate,r,i),function(t,e,n,r){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(da(n)+"rotate(",null,")")-2,x:Zi(t,e)})):e&&n.push(da(n)+"rotate("+e+")")}(e.rotate,n.rotate,r,i),function(t,e,n,r){t!==e?r.push({i:n.push(da(n)+"skewX(",null,")")-2,x:Zi(t,e)}):e&&n.push(da(n)+"skewX("+e+")")}(e.skew,n.skew,r,i),function(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var i=n.push(da(n)+"scale(",null,",",null,")");r.push({i:i-4,x:Zi(t[0],e[0])},{i:i-2,x:Zi(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(da(n)+"scale("+e+")")}(e.scale,n.scale,r,i),e=n=null,function(t){for(var e,n=-1,a=i.length;++n0?r=t:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:r=0})):t>0&&(l.start({type:"start",alpha:r=t}),e=Te(s.tick)),s):r},s.start=function(){var t,e,n,r=y.length,l=v.length,c=u[0],d=u[1];for(t=0;t=0;)n.push(i[r])}function za(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++o=0;)o.push(c=u[l]),c.parent=a,c.depth=a.depth+1;n&&(a.value=0),a.children=u}else n&&(a.value=+n.call(r,a,a.depth)||0),delete a.children;return za(i,function(e){var r,i;t&&(r=e.children)&&r.sort(t),n&&(i=e.parent)&&(i.value+=e.value)}),s}return r.sort=function(e){return arguments.length?(t=e,r):t},r.children=function(t){return arguments.length?(e=t,r):e},r.value=function(t){return arguments.length?(n=t,r):n},r.revalue=function(t){return n&&(Ca(t,function(t){t.children&&(t.value=0)}),za(t,function(t){var e;t.children||(t.value=+n.call(r,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},r},t.layout.partition=function(){var e=t.layout.hierarchy(),n=[1,1];function r(t,r){var i=e.call(this,t,r);return function t(e,n,r,i){var a=e.children;if(e.x=n,e.y=e.depth*i,e.dx=r,e.dy=i,a&&(o=a.length)){var o,s,l,u=-1;for(r=e.value?r/e.value:0;++us&&(s=r),o.push(r)}for(n=0;ni&&(r=n,i=e);return r}function Ua(t){return t.reduce(Ha,0)}function Ha(t,e){return t+e[1]}function Za(t,e){return Ga(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Ga(t,e){for(var n=-1,r=+t[0],i=(t[1]-r)/e,a=[];++n<=e;)a[n]=i*n+r;return a}function $a(e){return[t.min(e),t.max(e)]}function Wa(t,e){return t.value-e.value}function Xa(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ya(t,e){t._pack_next=e,e._pack_prev=t}function Ja(t,e){var n=e.x-t.x,r=e.y-t.y,i=t.r+e.r;return.999*i*i>n*n+r*r}function Ka(t){if((e=t.children)&&(l=e.length)){var e,n,r,i,a,o,s,l,u=1/0,c=-1/0,f=1/0,p=-1/0;if(e.forEach(Qa),(n=e[0]).x=-n.r,n.y=0,_(n),l>1&&((r=e[1]).x=r.r,r.y=0,_(r),l>2))for(eo(n,r,i=e[2]),_(i),Xa(n,i),n._pack_prev=i,Xa(i,r),r=n._pack_next,a=3;a0)for(o=-1;++o=f[0]&&l<=f[1]&&((s=u[t.bisect(p,l,1,d)-1]).y+=m,s.push(a[o]));return u}return a.value=function(t){return arguments.length?(n=t,a):n},a.range=function(t){return arguments.length?(r=ge(t),a):r},a.bins=function(t){return arguments.length?(i="number"==typeof t?function(e){return Ga(e,t)}:ge(t),a):i},a.frequency=function(t){return arguments.length?(e=!!t,a):e},a},t.layout.pack=function(){var e,n=t.layout.hierarchy().sort(Wa),r=0,i=[1,1];function a(t,a){var o=n.call(this,t,a),s=o[0],l=i[0],u=i[1],c=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,za(s,function(t){t.r=+c(t.value)}),za(s,Ka),r){var f=r*(e?1:Math.max(2*s.r/l,2*s.r/u))/2;za(s,function(t){t.r+=f}),za(s,Ka),za(s,function(t){t.r-=f})}return function t(e,n,r,i){var a=e.children;e.x=n+=i*e.x;e.y=r+=i*e.y;e.r*=i;if(a)for(var o=-1,s=a.length;++oh.x&&(h=t),t.depth>d.depth&&(d=t)});var m=n(p,h)/2-p.x,g=r[0]/(h.x+n(h,p)/2+m),y=r[1]/(d.depth||1);Ca(c,function(t){t.x=(t.x+m)*g,t.y=t.depth*y})}return u}function o(t){var e=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(e.length){!function(t){var e,n=0,r=0,i=t.children,a=i.length;for(;--a>=0;)(e=i[a]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}(t);var a=(e[0].z+e[e.length-1].z)/2;i?(t.z=i.z+n(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+n(t._,i._));t.parent.A=function(t,e,r){if(e){for(var i,a=t,o=t,s=e,l=a.parent.children[0],u=a.m,c=o.m,f=s.m,p=l.m;s=io(s),a=ro(a),s&&a;)l=ro(l),(o=io(o)).a=t,(i=s.z+f-a.z-u+n(s._,a._))>0&&(ao(oo(s,t,r),t,i),u+=i,c+=i),f+=s.m,u+=a.m,p+=l.m,c+=o.m;s&&!io(o)&&(o.t=s,o.m+=f-c),a&&!ro(l)&&(l.t=a,l.m+=u-p,r=t)}return r}(t,i,t.parent.A||r[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function l(t){t.x*=r[0],t.y=t.depth*r[1]}return a.separation=function(t){return arguments.length?(n=t,a):n},a.size=function(t){return arguments.length?(i=null==(r=t)?l:null,a):i?null:r},a.nodeSize=function(t){return arguments.length?(i=null==(r=t)?null:l,a):i?r:null},Sa(a,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),n=no,r=[1,1],i=!1;function a(a,o){var s,l=e.call(this,a,o),u=l[0],c=0;za(u,function(e){var r=e.children;r&&r.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(r),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(r)):(e.x=s?c+=n(e,s):0,e.y=0,s=e)});var f=function t(e){var n=e.children;return n&&n.length?t(n[0]):e}(u),p=function t(e){var n,r=e.children;return r&&(n=r.length)?t(r[n-1]):e}(u),h=f.x-n(f,p)/2,d=p.x+n(p,f)/2;return za(u,i?function(t){t.x=(t.x-u.x)*r[0],t.y=(u.y-t.y)*r[1]}:function(t){t.x=(t.x-h)/(d-h)*r[0],t.y=(1-(u.y?t.y/u.y:1))*r[1]}),l}return a.separation=function(t){return arguments.length?(n=t,a):n},a.size=function(t){return arguments.length?(i=null==(r=t),a):i?null:r},a.nodeSize=function(t){return arguments.length?(i=null!=(r=t),a):i?r:null},Sa(a,e)},t.layout.treemap=function(){var e,n=t.layout.hierarchy(),r=Math.round,i=[1,1],a=null,o=so,s=!1,l="squarify",u=.5*(1+Math.sqrt(5));function c(t,e){for(var n,r,i=-1,a=t.length;++i0;)s.push(n=u[i-1]),s.area+=n.area,"squarify"!==l||(r=h(s,m))<=p?(u.pop(),p=r):(s.area-=s.pop().area,d(s,m,a,!1),m=Math.min(a.dx,a.dy),s.length=s.area=0,p=1/0);s.length&&(d(s,m,a,!0),s.length=s.area=0),e.forEach(f)}}function p(t){var e=t.children;if(e&&e.length){var n,r=o(t),i=e.slice(),a=[];for(c(i,r.dx*r.dy/t.value),a.area=0;n=i.pop();)a.push(n),a.area+=n.area,null!=n.z&&(d(a,n.z?r.dx:r.dy,r,!i.length),a.length=a.area=0);e.forEach(p)}}function h(t,e){for(var n,r=t.area,i=0,a=1/0,o=-1,s=t.length;++oi&&(i=n));return e*=e,(r*=r)?Math.max(e*i*u/r,r/(e*a*u)):1/0}function d(t,e,n,i){var a,o=-1,s=t.length,l=n.x,u=n.y,c=e?r(t.area/e):0;if(e==n.dx){for((i||c>n.dy)&&(c=n.dy);++on.dx)&&(c=n.dx);++o1);return t+e*n*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var n=t.random.irwinHall(e);return function(){return n()/e}},irwinHall:function(t){return function(){for(var e=0,n=0;n2?go:fo,s=i?ya:ga;return a=t(e,n,s,r),o=t(n,e,s,Xi),l}function l(t){return a(t)}l.invert=function(t){return o(t)};l.domain=function(t){return arguments.length?(e=t.map(Number),s()):e};l.range=function(t){return arguments.length?(n=t,s()):n};l.rangeRound=function(t){return l.range(t).interpolate(ua)};l.clamp=function(t){return arguments.length?(i=t,s()):i};l.interpolate=function(t){return arguments.length?(r=t,s()):r};l.ticks=function(t){return xo(e,t)};l.tickFormat=function(t,n){return bo(e,t,n)};l.nice=function(t){return vo(e,t),s()};l.copy=function(){return t(e,n,r,i)};return s()}([0,1],[0,1],Xi,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(n,r,i,a){function o(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(r)}function s(t){return i?Math.pow(r,t):-Math.pow(r,-t)}function l(t){return n(o(t))}l.invert=function(t){return s(n.invert(t))};l.domain=function(t){return arguments.length?(i=t[0]>=0,n.domain((a=t.map(Number)).map(o)),l):a};l.base=function(t){return arguments.length?(r=+t,n.domain(a.map(o)),l):r};l.nice=function(){var t=po(a.map(o),i?Math:Ao);return n.domain(t),a=t.map(s),l};l.ticks=function(){var t=uo(a),e=[],n=t[0],l=t[1],u=Math.floor(o(n)),c=Math.ceil(o(l)),f=r%1?2:r;if(isFinite(c-u)){if(i){for(;u0;p--)e.push(s(u)*p);for(u=0;e[u]l;c--);e=e.slice(u,c)}return e};l.tickFormat=function(e,n){if(!arguments.length)return To;arguments.length<2?n=To:"function"!=typeof n&&(n=t.format(n));var i=Math.max(1,r*e/l.ticks().length);return function(t){var e=t/s(Math.round(o(t)));return e*r0?i[t-1]:n[0],tf?0:1;if(u=St)return l(u,h)+(s?l(s,1-h):"")+"Z";var d,m,g,y,v,_,x,b,w,k,T,A,M=0,S=0,C=[];if((y=(+o.apply(this,arguments)||0)/2)&&(g=r===Io?Math.sqrt(s*s+u*u):+r.apply(this,arguments),h||(S*=-1),u&&(S=Dt(g/u*Math.sin(y))),s&&(M=Dt(g/s*Math.sin(y)))),u){v=u*Math.cos(c+S),_=u*Math.sin(c+S),x=u*Math.cos(f-S),b=u*Math.sin(f-S);var z=Math.abs(f-c-2*S)<=At?0:1;if(S&&Bo(v,_,x,b)===h^z){var L=(c+f)/2;v=u*Math.cos(L),_=u*Math.sin(L),x=b=null}}else v=_=0;if(s){w=s*Math.cos(f-M),k=s*Math.sin(f-M),T=s*Math.cos(c+M),A=s*Math.sin(c+M);var E=Math.abs(c-f+2*M)<=At?0:1;if(M&&Bo(w,k,T,A)===1-h^E){var I=(c+f)/2;w=s*Math.cos(I),k=s*Math.sin(I),T=A=null}}else w=k=0;if(p>kt&&(d=Math.min(Math.abs(u-s)/2,+n.apply(this,arguments)))>.001){m=s0?0:1}function No(t,e,n,r,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?r:-r)/Math.sqrt(a*a+o*o),l=s*o,u=-s*a,c=t[0]+l,f=t[1]+u,p=e[0]+l,h=e[1]+u,d=(c+p)/2,m=(f+h)/2,g=p-c,y=h-f,v=g*g+y*y,_=n-r,x=c*h-p*f,b=(y<0?-1:1)*Math.sqrt(Math.max(0,_*_*v-x*x)),w=(x*y-g*b)/v,k=(-x*g-y*b)/v,T=(x*y+g*b)/v,A=(-x*g+y*b)/v,M=w-d,S=k-m,C=T-d,z=A-m;return M*M+S*S>C*C+z*z&&(w=T,k=A),[[w-l,k-u],[w*n/_,k*n/_]]}function jo(t){var e=ei,n=ni,r=$n,i=qo,a=i.key,o=.7;function s(a){var s,l=[],u=[],c=-1,f=a.length,p=ge(e),h=ge(n);function d(){l.push("M",i(t(u),o))}for(;++c1&&i.push("H",r[0]);return i.join("")},"step-before":Ho,"step-after":Zo,basis:Wo,"basis-open":function(t){if(t.length<4)return qo(t);var e,n=[],r=-1,i=t.length,a=[0],o=[0];for(;++r<3;)e=t[r],a.push(e[0]),o.push(e[1]);n.push(Xo(Ko,a)+","+Xo(Ko,o)),--r;for(;++r9&&(i=3*e/Math.sqrt(i),o[s]=i*n,o[s+1]=i*r));s=-1;for(;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}(t))}});function qo(t){return t.length>1?t.join("L"):t+"Z"}function Uo(t){return t.join("L")+"Z"}function Ho(t){for(var e=0,n=t.length,r=t[0],i=[r[0],",",r[1]];++e1){s=e[1],a=t[l],l++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var u=2;uAt)+",1 "+e}function l(t,e,n,r){return"Q 0,0 "+r}return a.radius=function(t){return arguments.length?(n=ge(t),a):n},a.source=function(e){return arguments.length?(t=ge(e),a):t},a.target=function(t){return arguments.length?(e=ge(t),a):e},a.startAngle=function(t){return arguments.length?(r=ge(t),a):r},a.endAngle=function(t){return arguments.length?(i=ge(t),a):i},a},t.svg.diagonal=function(){var t=Vr,e=qr,n=is;function r(r,i){var a=t.call(this,r,i),o=e.call(this,r,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(n))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return r.source=function(e){return arguments.length?(t=ge(e),r):t},r.target=function(t){return arguments.length?(e=ge(t),r):e},r.projection=function(t){return arguments.length?(n=t,r):n},r},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),n=is,r=e.projection;return e.projection=function(t){return arguments.length?r(function(t){return function(){var e=t.apply(this,arguments),n=e[0],r=e[1]-Ct;return[n*Math.cos(r),n*Math.sin(r)]}}(n=t)):n},e},t.svg.symbol=function(){var t=os,e=as;function n(n,r){return(ls.get(t.call(this,n,r))||ss)(e.call(this,n,r))}return n.type=function(e){return arguments.length?(t=ge(e),n):t},n.size=function(t){return arguments.length?(e=ge(t),n):e},n};var ls=t.map({circle:ss,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*cs)),n=e*cs;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/us),n=e*us/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/us),n=e*us/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});t.svg.symbolTypes=ls.keys();var us=Math.sqrt(3),cs=Math.tan(30*zt);$.transition=function(t){for(var e,n,r=ds||++ys,i=xs(t),a=[],o=ms||{time:Date.now(),ease:ia,delay:0,duration:250},s=-1,l=this.length;++s0;)u[--p].call(t,o);if(a>=1)return f.event&&f.event.end.call(t,t.__data__,e),--c.count?delete c[r]:delete t[n],1}f||(a=i.time,o=Te(function(t){var e=f.delay;if(o.t=e+a,e<=t)return p(t-e);o.c=p},0,a),f=c[r]={tween:new x,time:a,timer:o,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++c.count)}gs.call=$.call,gs.empty=$.empty,gs.node=$.node,gs.size=$.size,t.transition=function(e,n){return e&&e.transition?ds?e.transition(n):e:t.selection().transition(e)},t.transition.prototype=gs,gs.select=function(t){var e,n,r,i=this.id,a=this.namespace,o=[];t=W(t);for(var s=-1,l=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function m(t){t.select(".extent").attr("y",l[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function g(){var f,g,y=this,v=t.select(t.event.target),_=r.of(y,arguments),x=t.select(y),b=v.datum(),w=!/^(n|s)$/.test(b)&&i,k=!/^(e|w)$/.test(b)&&a,T=v.classed("extent"),A=_t(y),M=t.mouse(y),S=t.select(o(y)).on("keydown.brush",function(){32==t.event.keyCode&&(T||(f=null,M[0]-=s[1],M[1]-=l[1],T=2),B())}).on("keyup.brush",function(){32==t.event.keyCode&&2==T&&(M[0]+=s[1],M[1]+=l[1],T=0,B())});if(t.event.changedTouches?S.on("touchmove.brush",L).on("touchend.brush",I):S.on("mousemove.brush",L).on("mouseup.brush",I),x.interrupt().selectAll("*").interrupt(),T)M[0]=s[0]-M[0],M[1]=l[0]-M[1];else if(b){var C=+/w$/.test(b),z=+/^n/.test(b);g=[s[1-C]-M[0],l[1-z]-M[1]],M[0]=s[C],M[1]=l[z]}else t.event.altKey&&(f=M.slice());function L(){var e=t.mouse(y),n=!1;g&&(e[0]+=g[0],e[1]+=g[1]),T||(t.event.altKey?(f||(f=[(s[0]+s[1])/2,(l[0]+l[1])/2]),M[0]=s[+(e[0]1?{floor:function(e){for(;s(e=t.floor(e));)e=Ps(e-1);return e},ceil:function(e){for(;s(e=t.ceil(e));)e=Ps(+e+1);return e}}:t))},i.ticks=function(t,e){var n=uo(i.domain()),r=null==t?a(n,10):"number"==typeof t?a(n,t):!t.range&&[{range:t},e];return r&&(t=r[0],e=r[1]),t.range(n[0],Ps(+n[1]+1),e<1?1:e)},i.tickFormat=function(){return r},i.copy=function(){return Is(e.copy(),n,r)},yo(i,e)}function Ps(t){return new Date(t)}Cs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Es:Ls,Es.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Es.toString=Ls.toString,Pe.second=Fe(function(t){return new De(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),Pe.seconds=Pe.second.range,Pe.seconds.utc=Pe.second.utc.range,Pe.minute=Fe(function(t){return new De(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),Pe.minutes=Pe.minute.range,Pe.minutes.utc=Pe.minute.utc.range,Pe.hour=Fe(function(t){var e=t.getTimezoneOffset()/60;return new De(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),Pe.hours=Pe.hour.range,Pe.hours.utc=Pe.hour.utc.range,Pe.month=Fe(function(t){return(t=Pe.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),Pe.months=Pe.month.range,Pe.months.utc=Pe.month.utc.range;var Ds=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Os=[[Pe.second,1],[Pe.second,5],[Pe.second,15],[Pe.second,30],[Pe.minute,1],[Pe.minute,5],[Pe.minute,15],[Pe.minute,30],[Pe.hour,1],[Pe.hour,3],[Pe.hour,6],[Pe.hour,12],[Pe.day,1],[Pe.day,2],[Pe.week,1],[Pe.month,1],[Pe.month,3],[Pe.year,1]],Rs=Cs.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",$n]]),Fs={range:function(e,n,r){return t.range(Math.ceil(e/r)*r,+n,r).map(Ps)},floor:E,ceil:E};Os.year=Pe.year,Pe.scale=function(){return Is(t.scale.linear(),Os,Rs)};var Bs=Os.map(function(t){return[t[0].utc,t[1]]}),Ns=zs.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",$n]]);function js(t){return JSON.parse(t.responseText)}function Vs(t){var e=i.createRange();return e.selectNode(i.body),e.createContextualFragment(t.responseText)}Bs.year=Pe.year.utc,Pe.scale.utc=function(){return Is(t.scale.linear(),Bs,Ns)},t.text=ye(function(t){return t.responseText}),t.json=function(t,e){return ve(t,"application/json",js,e)},t.html=function(t,e){return ve(t,"text/html",Vs,e)},t.xml=ye(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],8:[function(t,e,n){(function(r,i){!function(t,r){"object"==typeof n&&"undefined"!=typeof e?e.exports=r():t.ES6Promise=r()}(this,function(){"use strict";function e(t){return"function"==typeof t}var n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},a=0,o=void 0,s=void 0,l=function(t,e){m[a]=t,m[a+1]=e,2===(a+=2)&&(s?s(g):b())};var u="undefined"!=typeof window?window:void 0,c=u||{},f=c.MutationObserver||c.WebKitMutationObserver,p="undefined"==typeof self&&"undefined"!=typeof r&&"[object process]"==={}.toString.call(r),h="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(g,1)}}var m=new Array(1e3);function g(){for(var t=0;t13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],15:[function(t,e,n){(function(t){!function(t,r){"object"==typeof n&&"undefined"!=typeof e?e.exports=r():t.mapboxgl=r()}(this,function(){"use strict";var e,n,r;function i(t,i){if(e)if(n){var a="var sharedChunk = {}; ("+e+")(sharedChunk); ("+n+")(sharedChunk);",o={};e(o),(r=i(o)).workerUrl=window.URL.createObjectURL(new Blob([a],{type:"text/javascript"}))}else n=i;else e=i}return i(0,function(e){var n="undefined"!=typeof window?window:"undefined"!=typeof t?t:"undefined"!=typeof self?self:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t,e){return t(e={exports:{}},e.exports),e.exports}var a=o;function o(t,e,n,r){this.cx=3*t,this.bx=3*(n-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=r,this.p2x=n,this.p2y=r}o.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},o.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},o.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},o.prototype.solveCurveX=function(t,e){var n,r,i,a,o;for(void 0===e&&(e=1e-6),i=t,o=0;o<8;o++){if(a=this.sampleCurveX(i)-t,Math.abs(a)(r=1))return r;for(;na?n=i:r=i,i=.5*(r-n)+n}return i},o.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var s=function(t,e,n){this.column=t,this.row=e,this.zoom=n};s.prototype.clone=function(){return new s(this.column,this.row,this.zoom)},s.prototype.zoomTo=function(t){return this.clone()._zoomTo(t)},s.prototype.sub=function(t){return this.clone()._sub(t)},s.prototype._zoomTo=function(t){var e=Math.pow(2,t-this.zoom);return this.column*=e,this.row*=e,this.zoom=t,this},s.prototype._sub=function(t){return t=t.zoomTo(this.zoom),this.column-=t.column,this.row-=t.row,this};var l=u;function u(t,e){this.x=t,this.y=e}function c(t,e,n,r){var i=new a(t,e,n,r);return function(t){return i.solve(t)}}u.prototype={clone:function(){return new u(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),r=e*this.x-n*this.y,i=n*this.x+e*this.y;return this.x=r,this.y=i,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),i=e.x+n*(this.x-e.x)-r*(this.y-e.y),a=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=i,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},u.convert=function(t){return t instanceof u?t:Array.isArray(t)?new u(t[0],t[1]):t};var f=c(.25,.1,.25,1);function p(t,e,n){return Math.min(n,Math.max(e,t))}function h(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r(e.y-t.y)*(n.x-t.x)}function k(t){for(var e=0,n=0,r=t.length,i=r-1,a=void 0,o=void 0;n=200&&n.status<300&&n.response?e(null,{data:r,cacheControl:n.getResponseHeader("Cache-Control"),expires:n.getResponseHeader("Expires")}):e(new A(n.statusText,n.status,t.url))},n.send(),n};function C(t,e,n){n[t]=n[t]||[],n[t].push(e)}function z(t,e,n){if(n&&n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}var L=function(t,e){void 0===e&&(e={}),h(this,e),this.type=t},E=function(t){function e(e,n){void 0===n&&(n={}),t.call(this,"error",h({error:e},n))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(L),I=function(){};I.prototype.on=function(t,e){return this._listeners=this._listeners||{},C(t,e,this._listeners),this},I.prototype.off=function(t,e){return z(t,e,this._listeners),z(t,e,this._oneTimeListeners),this},I.prototype.once=function(t,e){return this._oneTimeListeners=this._oneTimeListeners||{},C(t,e,this._oneTimeListeners),this},I.prototype.fire=function(t){"string"==typeof t&&(t=new L(t,arguments[1]||{}));var e=t.type;if(this.listens(e)){t.target=this;for(var n=0,r=this._listeners&&this._listeners[e]?this._listeners[e].slice():[];n0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)},I.prototype.setEventedParent=function(t,e){return this._eventedParent=t,this._eventedParentData=e,this};var P={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},buffer:{type:"number",default:128,maximum:512,minimum:0},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},lineMetrics:{type:"boolean",default:!1}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_fill:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_circle:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_line:{"line-cap":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{butt:{},round:{},square:{}},default:"butt"},"line-join":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{bevel:{},round:{},miter:{}},default:"miter"},"line-miter-limit":{type:"number",default:2,function:"interpolated","zoom-function":!0,requires:[{"line-join":"miter"}]},"line-round-limit":{type:"number",default:1.05,function:"interpolated","zoom-function":!0,requires:[{"line-join":"round"}]},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_symbol:{"symbol-placement":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{point:{},line:{}},default:"point"},"symbol-spacing":{type:"number",default:250,minimum:1,function:"interpolated","zoom-function":!0,units:"pixels",requires:[{"symbol-placement":"line"}]},"symbol-avoid-edges":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1},"icon-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image"]},"icon-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image"]},"icon-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image","text-field"]},"icon-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"]},"icon-size":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,units:"factor of the original icon size",requires:["icon-image"]},"icon-text-fit":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"]},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",function:"interpolated","zoom-function":!0,requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}]},"icon-image":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,tokens:!0},"icon-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,"property-function":!0,units:"degrees",requires:["icon-image"]},"icon-padding":{type:"number",default:2,minimum:0,function:"interpolated","zoom-function":!0,units:"pixels",requires:["icon-image"]},"icon-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":"line"}]},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,requires:["icon-image"]},"icon-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"]},"icon-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"]},"text-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"]},"text-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"]},"text-field":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:"",tokens:!0},"text-font":{type:"array",value:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"]},"text-size":{type:"number",default:16,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-line-height":{type:"number",default:1.2,units:"ems",function:"interpolated","zoom-function":!0,requires:["text-field"]},"text-letter-spacing":{type:"number",default:0,units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-justify":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{left:{},center:{},right:{}},default:"center",requires:["text-field"]},"text-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field"]},"text-max-angle":{type:"number",default:45,units:"degrees",function:"interpolated","zoom-function":!0,requires:["text-field",{"symbol-placement":"line"}]},"text-rotate":{type:"number",default:0,period:360,units:"degrees",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,requires:["text-field"]},"text-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":"line"}]},"text-transform":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"]},"text-offset":{type:"array",value:"number",units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,length:2,default:[0,0],requires:["text-field"]},"text-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field"]},"text-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field"]},"text-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field","icon-image"]},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function_stop:{type:"array",minimum:0,maximum:22,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},expression_name:{type:"enum",values:{let:{group:"Variable binding"},var:{group:"Variable binding"},literal:{group:"Types"},array:{group:"Types"},at:{group:"Lookup"},case:{group:"Decision"},match:{group:"Decision"},coalesce:{group:"Decision"},step:{group:"Ramps, scales, curves"},interpolate:{group:"Ramps, scales, curves"},ln2:{group:"Math"},pi:{group:"Math"},e:{group:"Math"},typeof:{group:"Types"},string:{group:"Types"},number:{group:"Types"},boolean:{group:"Types"},object:{group:"Types"},collator:{group:"Types"},"to-string":{group:"Types"},"to-number":{group:"Types"},"to-boolean":{group:"Types"},"to-rgba":{group:"Color"},"to-color":{group:"Types"},rgb:{group:"Color"},rgba:{group:"Color"},get:{group:"Lookup"},has:{group:"Lookup"},length:{group:"Lookup"},properties:{group:"Feature data"},"geometry-type":{group:"Feature data"},id:{group:"Feature data"},zoom:{group:"Zoom"},"heatmap-density":{group:"Heatmap"},"line-progress":{group:"Heatmap"},"+":{group:"Math"},"*":{group:"Math"},"-":{group:"Math"},"/":{group:"Math"},"%":{group:"Math"},"^":{group:"Math"},sqrt:{group:"Math"},log10:{group:"Math"},ln:{group:"Math"},log2:{group:"Math"},sin:{group:"Math"},cos:{group:"Math"},tan:{group:"Math"},asin:{group:"Math"},acos:{group:"Math"},atan:{group:"Math"},min:{group:"Math"},max:{group:"Math"},round:{group:"Math"},abs:{group:"Math"},ceil:{group:"Math"},floor:{group:"Math"},"==":{group:"Decision"},"!=":{group:"Decision"},">":{group:"Decision"},"<":{group:"Decision"},">=":{group:"Decision"},"<=":{group:"Decision"},all:{group:"Decision"},any:{group:"Decision"},"!":{group:"Decision"},"is-supported-script":{group:"String"},upcase:{group:"String"},downcase:{group:"String"},concat:{group:"String"},"resolved-locale":{group:"String"}}},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},transition:!1,"zoom-function":!0,"property-function":!1,function:"piecewise-constant"},position:{type:"array",default:[1.15,210,30],length:3,value:"number",transition:!0,function:"interpolated","zoom-function":!0,"property-function":!1},color:{type:"color",default:"#ffffff",function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0},intensity:{type:"number",default:.5,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!0},"fill-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"fill-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"}]},"fill-outline-color":{type:"color",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}]},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"fill-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["fill-translate"]},"fill-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0}},paint_line:{"line-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"line-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"line-pattern"}]},"line-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"line-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["line-translate"]},"line-width":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-gap-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-offset":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-dasharray":{type:"array",value:"number",function:"piecewise-constant","zoom-function":!0,minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}]},"line-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"line-gradient":{type:"color",function:"interpolated","zoom-function":!1,"property-function":!1,transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}]}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-blur":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"circle-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["circle-translate"]},"circle-pitch-scale":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map"},"circle-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"viewport"},"circle-stroke-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-stroke-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"heatmap-weight":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!1},"heatmap-intensity":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],function:"interpolated","zoom-function":!1,"property-function":!1,transition:!1},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"]},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"]}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-hue-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,transition:!0,units:"degrees"},"raster-brightness-min":{type:"number",function:"interpolated","zoom-function":!0,default:0,minimum:0,maximum:1,transition:!0},"raster-brightness-max":{type:"number",function:"interpolated","zoom-function":!0,default:1,minimum:0,maximum:1,transition:!0},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-fade-duration":{type:"number",default:300,minimum:0,function:"interpolated","zoom-function":!0,transition:!1,units:"milliseconds"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,function:"interpolated","zoom-function":!0,transition:!1},"hillshade-illumination-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"viewport"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"hillshade-shadow-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",function:"interpolated","zoom-function":!0,transition:!0},"hillshade-accent-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0}},paint_background:{"background-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0,requires:[{"!":"background-pattern"}]},"background-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!1,default:1,minimum:0,maximum:1,transition:!0},"fill-extrusion-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-extrusion-pattern"}]},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"fill-extrusion-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"]},"fill-extrusion-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"fill-extrusion-height":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:0,minimum:0,units:"meters",transition:!0},"fill-extrusion-base":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"]}}},D=function(t,e,n,r){this.message=(t?t+": ":"")+n,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)};function O(t){var e=t.key,n=t.value;return n?[new D(e,n,"constants have been deprecated as of v8")]:[]}function R(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r":"value"===t.itemType.kind?"array":"array<"+e+">"}return t.kind}var J=[V,q,U,H,Z,G,X($)];function K(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&!K(t.itemType,e.itemType)&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(var n=0,r=J;n255?255:t}function i(t){return t<0?0:t>1?1:t}function a(t){return"%"===t[t.length-1]?r(parseFloat(t)/100*255):r(parseInt(t))}function o(t){return"%"===t[t.length-1]?i(parseFloat(t)/100):i(parseFloat(t))}function s(t,e,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?t+(e-t)*n*6:2*n<1?e:3*n<2?t+(e-t)*(2/3-n)*6:t}try{e.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in n)return n[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=i.indexOf("("),u=i.indexOf(")");if(-1!==l&&u+1===i.length){var c=i.substr(0,l),f=i.substr(l+1,u-(l+1)).split(","),p=1;switch(c){case"rgba":if(4!==f.length)return null;p=o(f.pop());case"rgb":return 3!==f.length?null:[a(f[0]),a(f[1]),a(f[2]),p];case"hsla":if(4!==f.length)return null;p=o(f.pop());case"hsl":if(3!==f.length)return null;var h=(parseFloat(f[0])%360+360)%360/360,d=o(f[1]),m=o(f[2]),g=m<=.5?m*(d+1):m+d-m*d,y=2*m-g;return[r(255*s(y,g,h+1/3)),r(255*s(y,g,h)),r(255*s(y,g,h-1/3)),p];default:return null}}return null}}catch(t){}}).parseCSSColor,tt=function(t,e,n,r){void 0===r&&(r=1),this.r=t,this.g=e,this.b=n,this.a=r};tt.parse=function(t){if(t){if(t instanceof tt)return t;if("string"==typeof t){var e=Q(t);if(e)return new tt(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3])}}},tt.prototype.toString=function(){var t=this.toArray(),e=t[0],n=t[1],r=t[2],i=t[3];return"rgba("+Math.round(e)+","+Math.round(n)+","+Math.round(r)+","+i+")"},tt.prototype.toArray=function(){var t=this.r,e=this.g,n=this.b,r=this.a;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*n/r,r]},tt.black=new tt(0,0,0,1),tt.white=new tt(1,1,1,1),tt.transparent=new tt(0,0,0,0);var et=function(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})};et.prototype.compare=function(t,e){return this.collator.compare(t,e)},et.prototype.resolvedLocale=function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale};var nt=function(t,e,n){this.type=W,this.locale=n,this.caseSensitive=t,this.diacriticSensitive=e};function rt(t,e,n,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:"Invalid rgba value ["+[t,e,n,r].join(", ")+"]: 'a' must be between 0 and 1.":"Invalid rgba value ["+("number"==typeof r?[t,e,n,r]:[t,e,n]).join(", ")+"]: 'r', 'g', and 'b' must be between 0 and 255."}function it(t){if(null===t)return V;if("string"==typeof t)return U;if("boolean"==typeof t)return H;if("number"==typeof t)return q;if(t instanceof tt)return Z;if(t instanceof et)return W;if(Array.isArray(t)){for(var e,n=t.length,r=0,i=t;r4)return e.error("Expected 1, 2, or 3 arguments, but found "+(t.length-1)+" instead.");var n,r;if(t.length>2){var i=t[1];if("string"!=typeof i||!(i in ut))return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=ut[i]}else n=$;if(t.length>3){if("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2]))return e.error('The length argument to "array" must be a positive integer literal',2);r=t[2]}var a=X(n,r),o=e.parse(t[t.length-1],t.length-1,$);return o?new ct(a,o):null},ct.prototype.evaluate=function(t){var e=this.input.evaluate(t);if(K(this.type,it(e)))throw new ot("Expected value to be of type "+Y(this.type)+", but found "+Y(it(e))+" instead.");return e},ct.prototype.eachChild=function(t){t(this.input)},ct.prototype.possibleOutputs=function(){return this.input.possibleOutputs()},ct.prototype.serialize=function(){var t=["array"],e=this.type.itemType;if("string"===e.kind||"number"===e.kind||"boolean"===e.kind){t.push(e.kind);var n=this.type.N;"number"==typeof n&&t.push(n)}return t.push(this.input.serialize()),t};var ft={"to-number":q,"to-color":Z},pt=function(t,e){this.type=t,this.args=e};pt.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");for(var n=t[0],r=ft[n],i=[],a=1;a4?"Invalid rbga value "+JSON.stringify(e)+": expected an array containing either three or four numeric values.":rt(e[0],e[1],e[2],e[3])))return new tt(e[0]/255,e[1]/255,e[2]/255,e[3]);throw new ot(n||"Could not parse color from value '"+("string"==typeof e?e:JSON.stringify(e))+"'")}for(var o=null,s=0,l=this.args;s=0)return!1;var n=!0;return t.eachChild(function(t){n&&!yt(t,e)&&(n=!1)}),n}mt.prototype.evaluate=function(t){return this._evaluate(t,this.args)},mt.prototype.eachChild=function(t){this.args.forEach(t)},mt.prototype.possibleOutputs=function(){return[void 0]},mt.prototype.serialize=function(){return[this.name].concat(this.args.map(function(t){return t.serialize()}))},mt.parse=function(t,e){var n=t[0],r=mt.definitions[n];if(!r)return e.error('Unknown expression "'+n+'". If you wanted a literal array, use ["literal", [...]].',0);for(var i=Array.isArray(r)?r[0]:r.type,a=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=a.filter(function(e){var n=e[0];return!Array.isArray(n)||n.length===t.length-1}),s=[],l=1;ln&&ee))throw new ot("Input is not a number.");a=o-1}}return Math.max(o-1,0)}_t.prototype.parse=function(t,e,n,r,i){return void 0===i&&(i={}),e?this.concat(e,n,r)._parse(t,i):this._parse(t,i)},_t.prototype._parse=function(t,e){if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var n=t[0];if("string"!=typeof n)return this.error("Expression name must be a string, but found "+typeof n+' instead. If you wanted a literal array, use ["literal", [...]].',0),null;var r=this.registry[n];if(r){var i=r.parse(t,this);if(!i)return null;if(this.expectedType){var a=this.expectedType,o=i.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind||"value"!==o.kind)if("array"===a.kind&&"value"===o.kind)e.omitTypeAnnotations||(i=new ct(a,i));else if("color"!==a.kind||"value"!==o.kind&&"string"!==o.kind){if(this.checkSubtype(this.expectedType,i.type))return null}else e.omitTypeAnnotations||(i=new pt(a,[i]));else e.omitTypeAnnotations||(i=new lt(a,[i]))}if(!(i instanceof at)&&function t(e){if(e instanceof vt)return t(e.boundExpression);if(e instanceof mt&&"error"===e.name)return!1;if(e instanceof nt)return!1;var n=e instanceof pt||e instanceof lt||e instanceof ct,r=!0;return e.eachChild(function(e){r=n?r&&t(e):r&&e instanceof at}),!!r&&(gt(e)&&yt(e,["zoom","heatmap-density","line-progress","is-supported-script"]))}(i)){var s=new dt;try{i=new at(i.type,i.evaluate(s))}catch(t){return this.error(t.message),null}}return i}return this.error('Unknown expression "'+n+'". If you wanted a literal array, use ["literal", [...]].',0)}return void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error("Expected an array, but found "+typeof t+" instead.")},_t.prototype.concat=function(t,e,n){var r="number"==typeof t?this.path.concat(t):this.path,i=n?this.scope.concat(n):this.scope;return new _t(this.registry,r,e||null,i,this.errors)},_t.prototype.error=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var r=""+this.key+e.map(function(t){return"["+t+"]"}).join("");this.errors.push(new N(r,t))},_t.prototype.checkSubtype=function(t,e){var n=K(t,e);return n&&this.error(n),n};var bt=function(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(var r=0,i=n;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);var f=e.parse(l,c,a);if(!f)return null;a=a||f.type,i.push([s,f])}return new bt(a,n,i)},bt.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;return r>=e[i-1]?n[i-1].evaluate(t):n[xt(e,r)].evaluate(t)},bt.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t};var kt=Object.freeze({number:wt,color:function(t,e,n){return new tt(wt(t.r,e.r,n),wt(t.g,e.g,n),wt(t.b,e.b,n),wt(t.a,e.a,n))},array:function(t,e,n){return t.map(function(t,r){return wt(t,e[r],n)})}}),Tt=function(t,e,n,r){this.type=t,this.interpolation=e,this.input=n,this.labels=[],this.outputs=[];for(var i=0,a=r;i1}))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:o}}if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(!(r=e.parse(r,2,q)))return null;var s=[],l=null;e.expectedType&&"value"!==e.expectedType.kind&&(l=e.expectedType);for(var u=0;u=c)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',p);var d=e.parse(f,h,l);if(!d)return null;l=l||d.type,s.push([c,d])}return"number"===l.kind||"color"===l.kind||"array"===l.kind&&"number"===l.itemType.kind&&"number"==typeof l.N?new Tt(l,n,r,s):e.error("Type "+Y(l)+" is not interpolatable.")},Tt.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;if(r>=e[i-1])return n[i-1].evaluate(t);var a=xt(e,r),o=e[a],s=e[a+1],l=Tt.interpolationFactor(this.interpolation,r,o,s),u=n[a].evaluate(t),c=n[a+1].evaluate(t);return kt[this.type.kind.toLowerCase()](u,c,l)},Tt.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e=n.length)throw new ot("Array index out of bounds: "+e+" > "+(n.length-1)+".");if(e!==Math.floor(e))throw new ot("Array index must be an integer, but found "+e+" instead.");return n[e]},Ct.prototype.eachChild=function(t){t(this.index),t(this.input)},Ct.prototype.possibleOutputs=function(){return[void 0]},Ct.prototype.serialize=function(){return["at",this.index.serialize(),this.input.serialize()]};var zt=function(t,e,n,r,i,a){this.inputType=t,this.type=e,this.input=n,this.cases=r,this.outputs=i,this.otherwise=a};zt.parse=function(t,e){if(t.length<5)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if(t.length%2!=1)return e.error("Expected an even number of arguments.");var n,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);for(var i={},a=[],o=2;oNumber.MAX_SAFE_INTEGER)return u.error("Branch labels must be integers no larger than "+Number.MAX_SAFE_INTEGER+".");if("number"==typeof p&&Math.floor(p)!==p)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,it(p)))return null}else n=it(p);if(void 0!==i[String(p)])return u.error("Branch labels must be unique.");i[String(p)]=a.length}var h=e.parse(l,o,r);if(!h)return null;r=r||h.type,a.push(h)}var d=e.parse(t[1],1,n);if(!d)return null;var m=e.parse(t[t.length-1],t.length-1,r);return m?new zt(n,r,d,i,a,m):null},zt.prototype.evaluate=function(t){var e=this.input.evaluate(t);return(this.outputs[this.cases[e]]||this.otherwise).evaluate(t)},zt.prototype.eachChild=function(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)},zt.prototype.possibleOutputs=function(){return(t=[]).concat.apply(t,this.outputs.map(function(t){return t.possibleOutputs()})).concat(this.otherwise.possibleOutputs());var t},zt.prototype.serialize=function(){for(var t=this,e=["match",this.input.serialize()],n=[],r={},i=0,a=Object.keys(this.cases).sort();ir.evaluate(t)}function qt(t,e){var n=e[0],r=e[1];return n.evaluate(t)<=r.evaluate(t)}function Ut(t,e){var n=e[0],r=e[1];return n.evaluate(t)>=r.evaluate(t)}function Ht(t){return{type:t}}function Zt(t){return{result:"success",value:t}}function Gt(t){return{result:"error",value:t}}mt.register(Rt,{error:[{kind:"error"},[U],function(t,e){var n=e[0];throw new ot(n.evaluate(t))}],typeof:[U,[$],function(t,e){return Y(it(e[0].evaluate(t)))}],"to-string":[U,[$],function(t,e){var n=e[0],r=typeof(n=n.evaluate(t));return null===n?"":"string"===r||"number"===r||"boolean"===r?String(n):n instanceof tt?n.toString():JSON.stringify(n)}],"to-boolean":[H,[$],function(t,e){var n=e[0];return Boolean(n.evaluate(t))}],"to-rgba":[X(q,4),[Z],function(t,e){return e[0].evaluate(t).toArray()}],rgb:[Z,[q,q,q],Ft],rgba:[Z,[q,q,q,q],Ft],has:{type:H,overloads:[[[U],function(t,e){return Bt(e[0].evaluate(t),t.properties())}],[[U,G],function(t,e){var n=e[0],r=e[1];return Bt(n.evaluate(t),r.evaluate(t))}]]},get:{type:$,overloads:[[[U],function(t,e){return Nt(e[0].evaluate(t),t.properties())}],[[U,G],function(t,e){var n=e[0],r=e[1];return Nt(n.evaluate(t),r.evaluate(t))}]]},properties:[G,[],function(t){return t.properties()}],"geometry-type":[U,[],function(t){return t.geometryType()}],id:[$,[],function(t){return t.id()}],zoom:[q,[],function(t){return t.globals.zoom}],"heatmap-density":[q,[],function(t){return t.globals.heatmapDensity||0}],"line-progress":[q,[],function(t){return t.globals.lineProgress||0}],"+":[q,Ht(q),function(t,e){for(var n=0,r=0,i=e;r":[H,[U,$],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],a=r.value;return typeof i==typeof a&&i>a}],"filter-id->":[H,[$],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>i}],"filter-<=":[H,[U,$],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],a=r.value;return typeof i==typeof a&&i<=a}],"filter-id-<=":[H,[$],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r<=i}],"filter->=":[H,[U,$],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],a=r.value;return typeof i==typeof a&&i>=a}],"filter-id->=":[H,[$],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>=i}],"filter-has":[H,[$],function(t,e){return e[0].value in t.properties()}],"filter-has-id":[H,[],function(t){return null!==t.id()}],"filter-type-in":[H,[X(U)],function(t,e){return e[0].value.indexOf(t.geometryType())>=0}],"filter-id-in":[H,[X($)],function(t,e){return e[0].value.indexOf(t.id())>=0}],"filter-in-small":[H,[U,X($)],function(t,e){var n=e[0];return e[1].value.indexOf(t.properties()[n.value])>=0}],"filter-in-large":[H,[U,X($)],function(t,e){var n=e[0],r=e[1];return function(t,e,n,r){for(;n<=r;){var i=n+r>>1;if(e[i]===t)return!0;e[i]>t?r=i-1:n=i+1}return!1}(t.properties()[n.value],r.value,0,r.value.length-1)}],">":{type:H,overloads:[[[q,q],Vt],[[U,U],Vt],[[U,U,W],function(t,e){var n=e[0],r=e[1];return e[2].evaluate(t).compare(n.evaluate(t),r.evaluate(t))>0}]]},"<":{type:H,overloads:[[[q,q],jt],[[U,U],jt],[[U,U,W],function(t,e){var n=e[0],r=e[1];return e[2].evaluate(t).compare(n.evaluate(t),r.evaluate(t))<0}]]},">=":{type:H,overloads:[[[q,q],Ut],[[U,U],Ut],[[U,U,W],function(t,e){var n=e[0],r=e[1];return e[2].evaluate(t).compare(n.evaluate(t),r.evaluate(t))>=0}]]},"<=":{type:H,overloads:[[[q,q],qt],[[U,U],qt],[[U,U,W],function(t,e){var n=e[0],r=e[1];return e[2].evaluate(t).compare(n.evaluate(t),r.evaluate(t))<=0}]]},all:{type:H,overloads:[[[H,H],function(t,e){var n=e[0],r=e[1];return n.evaluate(t)&&r.evaluate(t)}],[Ht(H),function(t,e){for(var n=0,r=e;nQt?Math.pow(t,1/3):t/Kt+Yt}function re(t){return t>Jt?t*t*t:Kt*(t-Yt)}function ie(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function ae(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function oe(t){var e=ae(t.r),n=ae(t.g),r=ae(t.b),i=ne((.4124564*e+.3575761*n+.1804375*r)/$t),a=ne((.2126729*e+.7151522*n+.072175*r)/Wt);return{l:116*a-16,a:500*(i-a),b:200*(a-ne((.0193339*e+.119192*n+.9503041*r)/Xt)),alpha:t.a}}function se(t){var e=(t.l+16)/116,n=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=Wt*re(e),n=$t*re(n),r=Xt*re(r),new tt(ie(3.2404542*n-1.5371385*e-.4985314*r),ie(-.969266*n+1.8760108*e+.041556*r),ie(.0556434*n-.2040259*e+1.0572252*r),t.alpha)}var le={forward:oe,reverse:se,interpolate:function(t,e,n){return{l:wt(t.l,e.l,n),a:wt(t.a,e.a,n),b:wt(t.b,e.b,n),alpha:wt(t.alpha,e.alpha,n)}}},ue={forward:function(t){var e=oe(t),n=e.l,r=e.a,i=e.b,a=Math.atan2(i,r)*ee;return{h:a<0?a+360:a,c:Math.sqrt(r*r+i*i),l:n,alpha:t.a}},reverse:function(t){var e=t.h*te,n=t.c;return se({l:t.l,a:Math.cos(e)*n,b:Math.sin(e)*n,alpha:t.alpha})},interpolate:function(t,e,n){return{h:function(t,e,n){var r=e-t;return t+n*(r>180||r<-180?r-360*Math.round(r/360):r)}(t.h,e.h,n),c:wt(t.c,e.c,n),l:wt(t.l,e.l,n),alpha:wt(t.alpha,e.alpha,n)}}},ce=Object.freeze({lab:le,hcl:ue});function fe(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function pe(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function he(t){return t}function de(t,e,n){return void 0!==t?t:void 0!==e?e:void 0!==n?n:void 0}function me(t,e,n,r,i){return de(typeof n===i?r[n]:void 0,t.default,e.default)}function ge(t,e,n){if("number"!==fe(n))return de(t.default,e.default);var r=t.stops.length;if(1===r)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[r-1][0])return t.stops[r-1][1];var i=_e(t.stops,n);return t.stops[i][1]}function ye(t,e,n){var r=void 0!==t.base?t.base:1;if("number"!==fe(n))return de(t.default,e.default);var i=t.stops.length;if(1===i)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[i-1][0])return t.stops[i-1][1];var a=_e(t.stops,n),o=function(t,e,n,r){var i=r-n,a=t-n;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}(n,r,t.stops[a][0],t.stops[a+1][0]),s=t.stops[a][1],l=t.stops[a+1][1],u=kt[e.type]||he;if(t.colorSpace&&"rgb"!==t.colorSpace){var c=ce[t.colorSpace];u=function(t,e){return c.reverse(c.interpolate(c.forward(t),c.forward(e),o))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=s.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==n&&void 0!==r)return u(n,r,o)}}:u(s,l,o)}function ve(t,e,n){return"color"===e.type?n=tt.parse(n):fe(n)===e.type||"enum"===e.type&&e.values[n]||(n=void 0),de(n,t.default,e.default)}function _e(t,e){for(var n,r,i=0,a=t.length-1,o=0;i<=a;){if(n=t[o=Math.floor((i+a)/2)][0],r=t[o+1][0],e===n||e>n&&ee&&(a=o-1)}return Math.max(o-1,0)}var xe=function(t,e){var n;this.expression=t,this._warningHistory={},this._defaultValue="color"===(n=e).type&&pe(n.default)?new tt(0,0,0,0):"color"===n.type?tt.parse(n.default)||null:void 0===n.default?null:n.default,"enum"===e.type&&(this._enumValues=e.values)};function be(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Rt}function we(t,e){var n=new _t(Rt,[],function(t){var e={color:Z,string:U,number:q,enum:U,boolean:H};return"array"===t.type?X(e[t.value]||$,t.length):e[t.type]||null}(e)),r=n.parse(t);return r?Zt(new xe(r,e)):Gt(n.errors)}xe.prototype.evaluateWithoutErrorHandling=function(t,e){return this._evaluator||(this._evaluator=new dt),this._evaluator.globals=t,this._evaluator.feature=e,this.expression.evaluate(this._evaluator)},xe.prototype.evaluate=function(t,e){this._evaluator||(this._evaluator=new dt),this._evaluator.globals=t,this._evaluator.feature=e;try{var n=this.expression.evaluate(this._evaluator);if(null==n)return this._defaultValue;if(this._enumValues&&!(n in this._enumValues))throw new ot("Expected value to be one of "+Object.keys(this._enumValues).map(function(t){return JSON.stringify(t)}).join(", ")+", but found "+JSON.stringify(n)+" instead.");return n}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}};var ke=function(t,e){this.kind=t,this._styleExpression=e};ke.prototype.evaluateWithoutErrorHandling=function(t,e){return this._styleExpression.evaluateWithoutErrorHandling(t,e)},ke.prototype.evaluate=function(t,e){return this._styleExpression.evaluate(t,e)};var Te=function(t,e,n){this.kind=t,this.zoomStops=n.labels,this._styleExpression=e,n instanceof Tt&&(this._interpolationType=n.interpolation)};function Ae(t,e){if("error"===(t=we(t,e)).result)return t;var n=t.value.expression,r=gt(n);if(!r&&!e["property-function"])return Gt([new N("","property expressions not supported")]);var i=yt(n,["zoom"]);if(!i&&!1===e["zoom-function"])return Gt([new N("","zoom expressions not supported")]);var a=function t(e){var n=null;if(e instanceof St)n=t(e.result);else if(e instanceof Mt)for(var r=0,i=e.args;rr.maximum?[new D(e,n,n+" is greater than the maximum value "+r.maximum)]:[]}function Ee(t){var e,n,r,i=t.valueSpec,a=F(t.value.type),o={},s="categorical"!==a&&void 0===t.value.property,l=!s,u="array"===fe(t.value.stops)&&"array"===fe(t.value.stops[0])&&"object"===fe(t.value.stops[0][0]),c=Ce({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===a)return[new D(t.key,t.value,'identity function may not have a "stops" property')];var e=[],n=t.value;return e=e.concat(ze({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),"array"===fe(n)&&0===n.length&&e.push(new D(t.key,n,"array must have at least one stop")),e},default:function(t){return Ke({key:t.key,value:t.value,valueSpec:i,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===a&&s&&c.push(new D(t.key,t.value,'missing required property "property"')),"identity"===a||t.value.stops||c.push(new D(t.key,t.value,'missing required property "stops"')),"exponential"===a&&"piecewise-constant"===t.valueSpec.function&&c.push(new D(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!t.valueSpec["property-function"]?c.push(new D(t.key,t.value,"property functions not supported")):s&&!t.valueSpec["zoom-function"]&&"heatmap-color"!==t.objectKey&&"line-gradient"!==t.objectKey&&c.push(new D(t.key,t.value,"zoom functions not supported"))),"categorical"!==a&&!u||void 0!==t.value.property||c.push(new D(t.key,t.value,'"property" property is required')),c;function f(t){var e=[],a=t.value,s=t.key;if("array"!==fe(a))return[new D(s,a,"array expected, "+fe(a)+" found")];if(2!==a.length)return[new D(s,a,"array length 2 expected, length "+a.length+" found")];if(u){if("object"!==fe(a[0]))return[new D(s,a,"object expected, "+fe(a[0])+" found")];if(void 0===a[0].zoom)return[new D(s,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new D(s,a,"object stop key must have value")];if(r&&r>F(a[0].zoom))return[new D(s,a[0].zoom,"stop zoom values must appear in ascending order")];F(a[0].zoom)!==r&&(r=F(a[0].zoom),n=void 0,o={}),e=e.concat(Ce({key:s+"[0]",value:a[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Le,value:p}}))}else e=e.concat(p({key:s+"[0]",value:a[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},a));return e.concat(Ke({key:s+"[1]",value:a[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function p(t,r){var s=fe(t.value),l=F(t.value),u=null!==t.value?t.value:r;if(e){if(s!==e)return[new D(t.key,u,s+" stop domain type must match previous stop domain type "+e)]}else e=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new D(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==a){var c="number expected, "+s+" found";return i["property-function"]&&void 0===a&&(c+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new D(t.key,u,c)]}return"categorical"!==a||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==a&&"number"===s&&void 0!==n&&l=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3===t.length&&(Array.isArray(t[1])||Array.isArray(t[2]));case"any":case"all":for(var e=0,n=t.slice(1);ee?1:0}function Be(t){if(!t)return!0;var e,n=t[0];return t.length<=1?"any"!==n:"=="===n?Ne(t[1],t[2],"=="):"!="===n?qe(Ne(t[1],t[2],"==")):"<"===n||">"===n||"<="===n||">="===n?Ne(t[1],t[2],n):"any"===n?(e=t.slice(1),["any"].concat(e.map(Be))):"all"===n?["all"].concat(t.slice(1).map(Be)):"none"===n?["all"].concat(t.slice(1).map(Be).map(qe)):"in"===n?je(t[1],t.slice(2)):"!in"===n?qe(je(t[1],t.slice(2))):"has"===n?Ve(t[1]):"!has"!==n||qe(Ve(t[1]))}function Ne(t,e,n){switch(t){case"$type":return["filter-type-"+n,e];case"$id":return["filter-id-"+n,e];default:return["filter-"+n,t,e]}}function je(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(function(t){return typeof t!=typeof e[0]})?["filter-in-large",t,["literal",e.sort(Fe)]]:["filter-in-small",t,["literal",e]]}}function Ve(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function qe(t){return["!",t]}function Ue(t){return De(B(t.value))?Ie(R({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):function t(e){var n=e.value,r=e.key;if("array"!==fe(n))return[new D(r,n,"array expected, "+fe(n)+" found")];var i,a=e.styleSpec,o=[];if(n.length<1)return[new D(r,n,"filter array must have at least 1 element")];switch(o=o.concat(Pe({key:r+"[0]",value:n[0],valueSpec:a.filter_operator,style:e.style,styleSpec:e.styleSpec})),F(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===F(n[1])&&o.push(new D(r,n,'"$type" cannot be use with operator "'+n[0]+'"'));case"==":case"!=":3!==n.length&&o.push(new D(r,n,'filter array for operator "'+n[0]+'" must have 3 elements'));case"in":case"!in":n.length>=2&&"string"!==(i=fe(n[1]))&&o.push(new D(r+"[1]",n[1],"string expected, "+i+" found"));for(var s=2;s=u[p+0]&&r>=u[p+1]?(o[f]=!0,a.push(l[f])):o[f]=!1}}},fn.prototype._forEachCell=function(t,e,n,r,i,a,o){for(var s=this._convertToCellCoord(t),l=this._convertToCellCoord(e),u=this._convertToCellCoord(n),c=this._convertToCellCoord(r),f=s;f<=u;f++)for(var p=l;p<=c;p++){var h=this.d*p+f;if(i.call(this,t,e,n,r,h,a,o))return}},fn.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},fn.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=cn+this.cells.length+1+1,n=0,r=0;r=0)){var f=t[c];u[c]=hn[l].shallow.indexOf(c)>=0?f:gn(f,e)}t instanceof Error&&(u.message=t.message)}return{name:l,properties:u}}throw new Error("can't serialize object of type "+typeof t)}function yn(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof pn)return t;if(Array.isArray(t))return t.map(function(t){return yn(t)});if("object"==typeof t){var e=t,n=e.name,r=e.properties;if(!n)throw new Error("can't deserialize object of anonymous class");var i=hn[n].klass;if(!i)throw new Error("can't deserialize unregistered class "+n);if(i.deserialize)return i.deserialize(r._serialized);for(var a=Object.create(i.prototype),o=0,s=Object.keys(r);o=0?r[l]:yn(r[l])}return a}throw new Error("can't deserialize object of type "+typeof t)}var vn=function(){this.first=!0};vn.prototype.update=function(t,e){var n=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=e):this.lastFloorZoom=128&&t<=255},Arabic:function(t){return t>=1536&&t<=1791},"Arabic Supplement":function(t){return t>=1872&&t<=1919},"Arabic Extended-A":function(t){return t>=2208&&t<=2303},"Hangul Jamo":function(t){return t>=4352&&t<=4607},"Unified Canadian Aboriginal Syllabics":function(t){return t>=5120&&t<=5759},Khmer:function(t){return t>=6016&&t<=6143},"Unified Canadian Aboriginal Syllabics Extended":function(t){return t>=6320&&t<=6399},"General Punctuation":function(t){return t>=8192&&t<=8303},"Letterlike Symbols":function(t){return t>=8448&&t<=8527},"Number Forms":function(t){return t>=8528&&t<=8591},"Miscellaneous Technical":function(t){return t>=8960&&t<=9215},"Control Pictures":function(t){return t>=9216&&t<=9279},"Optical Character Recognition":function(t){return t>=9280&&t<=9311},"Enclosed Alphanumerics":function(t){return t>=9312&&t<=9471},"Geometric Shapes":function(t){return t>=9632&&t<=9727},"Miscellaneous Symbols":function(t){return t>=9728&&t<=9983},"Miscellaneous Symbols and Arrows":function(t){return t>=11008&&t<=11263},"CJK Radicals Supplement":function(t){return t>=11904&&t<=12031},"Kangxi Radicals":function(t){return t>=12032&&t<=12255},"Ideographic Description Characters":function(t){return t>=12272&&t<=12287},"CJK Symbols and Punctuation":function(t){return t>=12288&&t<=12351},Hiragana:function(t){return t>=12352&&t<=12447},Katakana:function(t){return t>=12448&&t<=12543},Bopomofo:function(t){return t>=12544&&t<=12591},"Hangul Compatibility Jamo":function(t){return t>=12592&&t<=12687},Kanbun:function(t){return t>=12688&&t<=12703},"Bopomofo Extended":function(t){return t>=12704&&t<=12735},"CJK Strokes":function(t){return t>=12736&&t<=12783},"Katakana Phonetic Extensions":function(t){return t>=12784&&t<=12799},"Enclosed CJK Letters and Months":function(t){return t>=12800&&t<=13055},"CJK Compatibility":function(t){return t>=13056&&t<=13311},"CJK Unified Ideographs Extension A":function(t){return t>=13312&&t<=19903},"Yijing Hexagram Symbols":function(t){return t>=19904&&t<=19967},"CJK Unified Ideographs":function(t){return t>=19968&&t<=40959},"Yi Syllables":function(t){return t>=40960&&t<=42127},"Yi Radicals":function(t){return t>=42128&&t<=42191},"Hangul Jamo Extended-A":function(t){return t>=43360&&t<=43391},"Hangul Syllables":function(t){return t>=44032&&t<=55215},"Hangul Jamo Extended-B":function(t){return t>=55216&&t<=55295},"Private Use Area":function(t){return t>=57344&&t<=63743},"CJK Compatibility Ideographs":function(t){return t>=63744&&t<=64255},"Arabic Presentation Forms-A":function(t){return t>=64336&&t<=65023},"Vertical Forms":function(t){return t>=65040&&t<=65055},"CJK Compatibility Forms":function(t){return t>=65072&&t<=65103},"Small Form Variants":function(t){return t>=65104&&t<=65135},"Arabic Presentation Forms-B":function(t){return t>=65136&&t<=65279},"Halfwidth and Fullwidth Forms":function(t){return t>=65280&&t<=65519}};function xn(t){for(var e=0,n=t;e=65097&&t<=65103)||_n["CJK Compatibility Ideographs"](t)||_n["CJK Compatibility"](t)||_n["CJK Radicals Supplement"](t)||_n["CJK Strokes"](t)||!(!_n["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||_n["CJK Unified Ideographs Extension A"](t)||_n["CJK Unified Ideographs"](t)||_n["Enclosed CJK Letters and Months"](t)||_n["Hangul Compatibility Jamo"](t)||_n["Hangul Jamo Extended-A"](t)||_n["Hangul Jamo Extended-B"](t)||_n["Hangul Jamo"](t)||_n["Hangul Syllables"](t)||_n.Hiragana(t)||_n["Ideographic Description Characters"](t)||_n.Kanbun(t)||_n["Kangxi Radicals"](t)||_n["Katakana Phonetic Extensions"](t)||_n.Katakana(t)&&12540!==t||!(!_n["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!_n["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||_n["Unified Canadian Aboriginal Syllabics"](t)||_n["Unified Canadian Aboriginal Syllabics Extended"](t)||_n["Vertical Forms"](t)||_n["Yijing Hexagram Symbols"](t)||_n["Yi Syllables"](t)||_n["Yi Radicals"](t)))}function kn(t){return!(wn(t)||function(t){return!!(_n["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||_n["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||_n["Letterlike Symbols"](t)||_n["Number Forms"](t)||_n["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||_n["Control Pictures"](t)&&9251!==t||_n["Optical Character Recognition"](t)||_n["Enclosed Alphanumerics"](t)||_n["Geometric Shapes"](t)||_n["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||_n["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||_n["CJK Symbols and Punctuation"](t)||_n.Katakana(t)||_n["Private Use Area"](t)||_n["CJK Compatibility Forms"](t)||_n["Small Form Variants"](t)||_n["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Tn(t,e){return!(!e&&(t>=1424&&t<=2303||_n["Arabic Presentation Forms-A"](t)||_n["Arabic Presentation Forms-B"](t))||t>=2304&&t<=3583||t>=3840&&t<=4255||_n.Khmer(t))}var An,Mn=!1,Sn=null,Cn=!1,zn=new I,Ln={applyArabicShaping:null,processBidirectionalText:null,isLoaded:function(){return Cn||null!=Ln.applyArabicShaping}},En=function(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new vn,this.transition={})};En.prototype.isSupportedScript=function(t){return function(t,e){for(var n=0,r=t;nthis.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(e=1)return 1;var e=i*i,n=e*i;return 4*(i<.5?n:3*(i-e)+n-.75)}())}return n};var Rn=function(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)};Rn.prototype.possiblyEvaluate=function(t){for(var e=new Nn(this._properties),n=0,r=Object.keys(this._values);nr.zoomHistory.lastIntegerZoom?{from:t,to:e,fromScale:2,toScale:1,t:a+(1-a)*o}:{from:n,to:e,fromScale:.5,toScale:1,t:1-(1-o)*a}},qn.prototype.interpolate=function(t){return t};var Un=function(t){this.specification=t};Un.prototype.possiblyEvaluate=function(t,e){return!!t.expression.evaluate(e)},Un.prototype.interpolate=function(){return!1};var Hn=function(t){for(var e in this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},t){var n=t[e],r=this.defaultPropertyValues[e]=new In(n,void 0),i=this.defaultTransitionablePropertyValues[e]=new Pn(n);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}};dn("DataDrivenProperty",Vn),dn("DataConstantProperty",jn),dn("CrossFadedProperty",qn),dn("ColorRampProperty",Un);var Zn=function(t){function e(e,n){for(var r in t.call(this),this.id=e.id,this.metadata=e.metadata,this.type=e.type,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,this.visibility="visible","background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),this._featureFilter=function(){return!0},n.layout&&(this._unevaluatedLayout=new Fn(n.layout)),this._transitionablePaint=new Dn(n.paint),e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(var i in e.layout)this.setLayoutProperty(i,e.layout[i],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getLayoutProperty=function(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)},e.prototype.setLayoutProperty=function(t,e,n){if(null!=e){var r="layers."+this.id+".layout."+t;if(this._validate(sn,r,t,e,n))return}"visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility="none"===e?e:"visible"},e.prototype.getPaintProperty=function(t){return g(t,"-transition")?this._transitionablePaint.getTransition(t.slice(0,-"-transition".length)):this._transitionablePaint.getValue(t)},e.prototype.setPaintProperty=function(t,e,n){if(null!=e){var r="layers."+this.id+".paint."+t;if(this._validate(on,r,t,e,n))return}g(t,"-transition")?this._transitionablePaint.setTransition(t.slice(0,-"-transition".length),e||void 0):this._transitionablePaint.setValue(t,e)},e.prototype.isHidden=function(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility},e.prototype.updateTransitions=function(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)},e.prototype.hasTransition=function(){return this._transitioningPaint.hasTransition()},e.prototype.recalculate=function(t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t)),this.paint=this._transitioningPaint.possiblyEvaluate(t)},e.prototype.serialize=function(){var t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return"none"===this.visibility&&(t.layout=t.layout||{},t.layout.visibility="none"),v(t,function(t,e){return!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)})},e.prototype._validate=function(t,e,n,r,i){return(!i||!1!==i.validate)&&ln(this,t.call(rn,{key:e,layerType:this.type,objectKey:n,value:r,styleSpec:P,style:{glyphs:!0,sprite:!0}}))},e.prototype.hasOffscreenPass=function(){return!1},e.prototype.resize=function(){},e}(I),Gn={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},$n=function(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8},Wn=function(){this.isTransferred=!1,this.capacity=-1,this.resize(0)};function Xn(t,e){void 0===e&&(e=1);var n=0,r=0;return{members:t.map(function(t){var i,a=(i=t.type,Gn[i].BYTES_PER_ELEMENT),o=n=Yn(n,Math.max(e,a)),s=t.components||1;return r=Math.max(r,a),n+=a*s,{name:t.name,type:t.type,components:s,offset:o}}),size:Yn(n,Math.max(r,e)),alignment:e}}function Yn(t,e){return Math.ceil(t/e)*e}Wn.serialize=function(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}},Wn.deserialize=function(t){var e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e},Wn.prototype._trim=function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())},Wn.prototype.clear=function(){this.length=0},Wn.prototype.resize=function(t){this.reserve(t),this.length=t},Wn.prototype.reserve=function(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}},Wn.prototype._refreshViews=function(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")};var Jn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;this.resize(n+1);var r=2*n;return this.int16[r+0]=t,this.int16[r+1]=e,n},e}(Wn);Jn.prototype.bytesPerElement=4,dn("StructArrayLayout2i4",Jn);var Kn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;this.resize(i+1);var a=4*i;return this.int16[a+0]=t,this.int16[a+1]=e,this.int16[a+2]=n,this.int16[a+3]=r,i},e}(Wn);Kn.prototype.bytesPerElement=8,dn("StructArrayLayout4i8",Kn);var Qn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a){var o=this.length;this.resize(o+1);var s=6*o;return this.int16[s+0]=t,this.int16[s+1]=e,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=i,this.int16[s+5]=a,o},e}(Wn);Qn.prototype.bytesPerElement=12,dn("StructArrayLayout2i4i12",Qn);var tr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a,o,s){var l=this.length;this.resize(l+1);var u=6*l,c=12*l;return this.int16[u+0]=t,this.int16[u+1]=e,this.int16[u+2]=n,this.int16[u+3]=r,this.uint8[c+8]=i,this.uint8[c+9]=a,this.uint8[c+10]=o,this.uint8[c+11]=s,l},e}(Wn);tr.prototype.bytesPerElement=12,dn("StructArrayLayout4i4ub12",tr);var er=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a,o,s){var l=this.length;this.resize(l+1);var u=8*l;return this.int16[u+0]=t,this.int16[u+1]=e,this.int16[u+2]=n,this.int16[u+3]=r,this.uint16[u+4]=i,this.uint16[u+5]=a,this.uint16[u+6]=o,this.uint16[u+7]=s,l},e}(Wn);er.prototype.bytesPerElement=16,dn("StructArrayLayout4i4ui16",er);var nr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;this.resize(r+1);var i=3*r;return this.float32[i+0]=t,this.float32[i+1]=e,this.float32[i+2]=n,r},e}(Wn);nr.prototype.bytesPerElement=12,dn("StructArrayLayout3f12",nr);var rr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;this.resize(e+1);var n=1*e;return this.uint32[n+0]=t,e},e}(Wn);rr.prototype.bytesPerElement=4,dn("StructArrayLayout1ul4",rr);var ir=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a,o,s,l,u,c){var f=this.length;this.resize(f+1);var p=12*f,h=6*f;return this.int16[p+0]=t,this.int16[p+1]=e,this.int16[p+2]=n,this.int16[p+3]=r,this.int16[p+4]=i,this.int16[p+5]=a,this.uint32[h+3]=o,this.uint16[p+8]=s,this.uint16[p+9]=l,this.int16[p+10]=u,this.int16[p+11]=c,f},e}(Wn);ir.prototype.bytesPerElement=24,dn("StructArrayLayout6i1ul2ui2i24",ir);var ar=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a){var o=this.length;this.resize(o+1);var s=6*o;return this.int16[s+0]=t,this.int16[s+1]=e,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=i,this.int16[s+5]=a,o},e}(Wn);ar.prototype.bytesPerElement=12,dn("StructArrayLayout2i2i2i12",ar);var or=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;this.resize(n+1);var r=4*n;return this.uint8[r+0]=t,this.uint8[r+1]=e,n},e}(Wn);or.prototype.bytesPerElement=4,dn("StructArrayLayout2ub4",or);var sr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,a,o,s,l,u,c,f,p,h){var d=this.length;this.resize(d+1);var m=20*d,g=10*d,y=40*d;return this.int16[m+0]=t,this.int16[m+1]=e,this.uint16[m+2]=n,this.uint16[m+3]=r,this.uint32[g+2]=i,this.uint32[g+3]=a,this.uint32[g+4]=o,this.uint16[m+10]=s,this.uint16[m+11]=l,this.uint16[m+12]=u,this.float32[g+7]=c,this.float32[g+8]=f,this.uint8[y+36]=p,this.uint8[y+37]=h,d},e}(Wn);sr.prototype.bytesPerElement=40,dn("StructArrayLayout2i2ui3ul3ui2f2ub40",sr);var lr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;this.resize(e+1);var n=1*e;return this.float32[n+0]=t,e},e}(Wn);lr.prototype.bytesPerElement=4,dn("StructArrayLayout1f4",lr);var ur=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;this.resize(r+1);var i=3*r;return this.int16[i+0]=t,this.int16[i+1]=e,this.int16[i+2]=n,r},e}(Wn);ur.prototype.bytesPerElement=6,dn("StructArrayLayout3i6",ur);var cr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;this.resize(r+1);var i=2*r,a=4*r;return this.uint32[i+0]=t,this.uint16[a+2]=e,this.uint16[a+3]=n,r},e}(Wn);cr.prototype.bytesPerElement=8,dn("StructArrayLayout1ul2ui8",cr);var fr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;this.resize(r+1);var i=3*r;return this.uint16[i+0]=t,this.uint16[i+1]=e,this.uint16[i+2]=n,r},e}(Wn);fr.prototype.bytesPerElement=6,dn("StructArrayLayout3ui6",fr);var pr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;this.resize(n+1);var r=2*n;return this.uint16[r+0]=t,this.uint16[r+1]=e,n},e}(Wn);pr.prototype.bytesPerElement=4,dn("StructArrayLayout2ui4",pr);var hr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;this.resize(n+1);var r=2*n;return this.float32[r+0]=t,this.float32[r+1]=e,n},e}(Wn);hr.prototype.bytesPerElement=8,dn("StructArrayLayout2f8",hr);var dr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;this.resize(i+1);var a=4*i;return this.float32[a+0]=t,this.float32[a+1]=e,this.float32[a+2]=n,this.float32[a+3]=r,i},e}(Wn);dr.prototype.bytesPerElement=16,dn("StructArrayLayout4f16",dr);var mr=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={anchorPointX:{configurable:!0},anchorPointY:{configurable:!0},x1:{configurable:!0},y1:{configurable:!0},x2:{configurable:!0},y2:{configurable:!0},featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0},radius:{configurable:!0},signedDistanceFromAnchor:{configurable:!0},anchorPoint:{configurable:!0}};return n.anchorPointX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorPointX.set=function(t){this._structArray.int16[this._pos2+0]=t},n.anchorPointY.get=function(){return this._structArray.int16[this._pos2+1]},n.anchorPointY.set=function(t){this._structArray.int16[this._pos2+1]=t},n.x1.get=function(){return this._structArray.int16[this._pos2+2]},n.x1.set=function(t){this._structArray.int16[this._pos2+2]=t},n.y1.get=function(){return this._structArray.int16[this._pos2+3]},n.y1.set=function(t){this._structArray.int16[this._pos2+3]=t},n.x2.get=function(){return this._structArray.int16[this._pos2+4]},n.x2.set=function(t){this._structArray.int16[this._pos2+4]=t},n.y2.get=function(){return this._structArray.int16[this._pos2+5]},n.y2.set=function(t){this._structArray.int16[this._pos2+5]=t},n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.featureIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+8]},n.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+8]=t},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+9]},n.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+9]=t},n.radius.get=function(){return this._structArray.int16[this._pos2+10]},n.radius.set=function(t){this._structArray.int16[this._pos2+10]=t},n.signedDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+11]},n.signedDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+11]=t},n.anchorPoint.get=function(){return new l(this.anchorPointX,this.anchorPointY)},Object.defineProperties(e.prototype,n),e}($n);mr.prototype.size=24;var gr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new mr(this,t)},e}(ir);dn("CollisionBoxArray",gr);var yr=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={anchorX:{configurable:!0},anchorY:{configurable:!0},glyphStartIndex:{configurable:!0},numGlyphs:{configurable:!0},vertexStartIndex:{configurable:!0},lineStartIndex:{configurable:!0},lineLength:{configurable:!0},segment:{configurable:!0},lowerSize:{configurable:!0},upperSize:{configurable:!0},lineOffsetX:{configurable:!0},lineOffsetY:{configurable:!0},writingMode:{configurable:!0},hidden:{configurable:!0}};return n.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorX.set=function(t){this._structArray.int16[this._pos2+0]=t},n.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},n.anchorY.set=function(t){this._structArray.int16[this._pos2+1]=t},n.glyphStartIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.glyphStartIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},n.numGlyphs.get=function(){return this._structArray.uint16[this._pos2+3]},n.numGlyphs.set=function(t){this._structArray.uint16[this._pos2+3]=t},n.vertexStartIndex.get=function(){return this._structArray.uint32[this._pos4+2]},n.vertexStartIndex.set=function(t){this._structArray.uint32[this._pos4+2]=t},n.lineStartIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.lineStartIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},n.lineLength.get=function(){return this._structArray.uint32[this._pos4+4]},n.lineLength.set=function(t){this._structArray.uint32[this._pos4+4]=t},n.segment.get=function(){return this._structArray.uint16[this._pos2+10]},n.segment.set=function(t){this._structArray.uint16[this._pos2+10]=t},n.lowerSize.get=function(){return this._structArray.uint16[this._pos2+11]},n.lowerSize.set=function(t){this._structArray.uint16[this._pos2+11]=t},n.upperSize.get=function(){return this._structArray.uint16[this._pos2+12]},n.upperSize.set=function(t){this._structArray.uint16[this._pos2+12]=t},n.lineOffsetX.get=function(){return this._structArray.float32[this._pos4+7]},n.lineOffsetX.set=function(t){this._structArray.float32[this._pos4+7]=t},n.lineOffsetY.get=function(){return this._structArray.float32[this._pos4+8]},n.lineOffsetY.set=function(t){this._structArray.float32[this._pos4+8]=t},n.writingMode.get=function(){return this._structArray.uint8[this._pos1+36]},n.writingMode.set=function(t){this._structArray.uint8[this._pos1+36]=t},n.hidden.get=function(){return this._structArray.uint8[this._pos1+37]},n.hidden.set=function(t){this._structArray.uint8[this._pos1+37]=t},Object.defineProperties(e.prototype,n),e}($n);yr.prototype.size=40;var vr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new yr(this,t)},e}(sr);dn("PlacedSymbolArray",vr);var _r=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={offsetX:{configurable:!0}};return n.offsetX.get=function(){return this._structArray.float32[this._pos4+0]},n.offsetX.set=function(t){this._structArray.float32[this._pos4+0]=t},Object.defineProperties(e.prototype,n),e}($n);_r.prototype.size=4;var xr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getoffsetX=function(t){return this.float32[1*t+0]},e.prototype.get=function(t){return new _r(this,t)},e}(lr);dn("GlyphOffsetArray",xr);var br=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={x:{configurable:!0},y:{configurable:!0},tileUnitDistanceFromAnchor:{configurable:!0}};return n.x.get=function(){return this._structArray.int16[this._pos2+0]},n.x.set=function(t){this._structArray.int16[this._pos2+0]=t},n.y.get=function(){return this._structArray.int16[this._pos2+1]},n.y.set=function(t){this._structArray.int16[this._pos2+1]=t},n.tileUnitDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+2]},n.tileUnitDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+2]=t},Object.defineProperties(e.prototype,n),e}($n);br.prototype.size=6;var wr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getx=function(t){return this.int16[3*t+0]},e.prototype.gety=function(t){return this.int16[3*t+1]},e.prototype.gettileUnitDistanceFromAnchor=function(t){return this.int16[3*t+2]},e.prototype.get=function(t){return new br(this,t)},e}(ur);dn("SymbolLineVertexArray",wr);var kr=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0}};return n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+0]},n.featureIndex.set=function(t){this._structArray.uint32[this._pos4+0]=t},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+3]},n.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+3]=t},Object.defineProperties(e.prototype,n),e}($n);kr.prototype.size=8;var Tr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new kr(this,t)},e}(cr);dn("FeatureIndexArray",Tr);var Ar=Xn([{name:"a_pos",components:2,type:"Int16"}],4).members,Mr=function(t){void 0===t&&(t=[]),this.segments=t};Mr.prototype.prepareSegment=function(t,e,n){var r=this.segments[this.segments.length-1];return t>Mr.MAX_VERTEX_ARRAY_LENGTH&&b("Max vertices per segment is "+Mr.MAX_VERTEX_ARRAY_LENGTH+": bucket requested "+t),(!r||r.vertexLength+t>Mr.MAX_VERTEX_ARRAY_LENGTH)&&(r={vertexOffset:e.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},this.segments.push(r)),r},Mr.prototype.get=function(){return this.segments},Mr.prototype.destroy=function(){for(var t=0,e=this.segments;tRr.max||o.yRr.max)&&b("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return n}function Br(t,e,n,r,i){t.emplaceBack(2*e+(r+1)/2,2*n+(i+1)/2)}var Nr=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(function(t){return t.id}),this.index=t.index,this.layoutVertexArray=new Jn,this.indexArray=new fr,this.segments=new Mr,this.programConfigurations=new Pr(Ar,t.layers,t.zoom)};function jr(t,e,n){for(var r=0;r=3)for(var s=0;s1){if(Hr(t,e))return!0;for(var r=0;r1?t.distSqr(n):t.distSqr(n.sub(e)._mult(i)._add(e))}function Wr(t,e){for(var n,r,i,a=!1,o=0;oe.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(a=!a);return a}function Xr(t,e){for(var n=!1,r=0,i=t.length-1;re.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function Yr(t,e,n){var r=e.paint.get(t).value;return"constant"===r.kind?r.value:n.programConfigurations.get(e.id).binders[t].statistics.max}function Jr(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Kr(t,e,n,r,i){if(!e[0]&&!e[1])return t;var a=l.convert(e);"viewport"===n&&a._rotate(-r);for(var o=[],s=0;s=Or||l<0||l>=Or)){var u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray),c=u.vertexLength;Br(this.layoutVertexArray,s,l,-1,-1),Br(this.layoutVertexArray,s,l,1,-1),Br(this.layoutVertexArray,s,l,1,1),Br(this.layoutVertexArray,s,l,-1,1),this.indexArray.emplaceBack(c,c+1,c+2),this.indexArray.emplaceBack(c,c+3,c+2),u.vertexLength+=4,u.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t)},dn("CircleBucket",Nr,{omit:["layers"]});var Qr={paint:new Hn({"circle-radius":new Vn(P.paint_circle["circle-radius"]),"circle-color":new Vn(P.paint_circle["circle-color"]),"circle-blur":new Vn(P.paint_circle["circle-blur"]),"circle-opacity":new Vn(P.paint_circle["circle-opacity"]),"circle-translate":new jn(P.paint_circle["circle-translate"]),"circle-translate-anchor":new jn(P.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new jn(P.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new jn(P.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Vn(P.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Vn(P.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Vn(P.paint_circle["circle-stroke-opacity"])})},ti=i(function(t,e){var n;t.exports=((n=new Float32Array(3))[0]=0,n[1]=0,n[2]=0,function(){var t=new Float32Array(4);t[0]=0,t[1]=0,t[2]=0,t[3]=0}(),{vec3:{transformMat3:function(t,e,n){var r=e[0],i=e[1],a=e[2];return t[0]=r*n[0]+i*n[3]+a*n[6],t[1]=r*n[1]+i*n[4]+a*n[7],t[2]=r*n[2]+i*n[5]+a*n[8],t}},vec4:{transformMat4:function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,t}},mat2:{create:function(){var t=new Float32Array(4);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},rotate:function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(n),l=Math.cos(n);return t[0]=r*l+a*s,t[1]=i*l+o*s,t[2]=r*-s+a*l,t[3]=i*-s+o*l,t},scale:function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=n[0],l=n[1];return t[0]=r*s,t[1]=i*s,t[2]=a*l,t[3]=o*l,t}},mat3:{create:function(){var t=new Float32Array(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fromRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=-n,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}},mat4:{create:function(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},translate:function(t,e,n){var r,i,a,o,s,l,u,c,f,p,h,d,m=n[0],g=n[1],y=n[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*y+e[12],t[13]=e[1]*m+e[5]*g+e[9]*y+e[13],t[14]=e[2]*m+e[6]*g+e[10]*y+e[14],t[15]=e[3]*m+e[7]*g+e[11]*y+e[15]):(r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=e[8],p=e[9],h=e[10],d=e[11],t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=u,t[7]=c,t[8]=f,t[9]=p,t[10]=h,t[11]=d,t[12]=r*m+s*g+f*y+e[12],t[13]=i*m+l*g+p*y+e[13],t[14]=a*m+u*g+h*y+e[14],t[15]=o*m+c*g+d*y+e[15]),t},scale:function(t,e,n){var r=n[0],i=n[1],a=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},multiply:function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],f=e[8],p=e[9],h=e[10],d=e[11],m=e[12],g=e[13],y=e[14],v=e[15],_=n[0],x=n[1],b=n[2],w=n[3];return t[0]=_*r+x*s+b*f+w*m,t[1]=_*i+x*l+b*p+w*g,t[2]=_*a+x*u+b*h+w*y,t[3]=_*o+x*c+b*d+w*v,_=n[4],x=n[5],b=n[6],w=n[7],t[4]=_*r+x*s+b*f+w*m,t[5]=_*i+x*l+b*p+w*g,t[6]=_*a+x*u+b*h+w*y,t[7]=_*o+x*c+b*d+w*v,_=n[8],x=n[9],b=n[10],w=n[11],t[8]=_*r+x*s+b*f+w*m,t[9]=_*i+x*l+b*p+w*g,t[10]=_*a+x*u+b*h+w*y,t[11]=_*o+x*c+b*d+w*v,_=n[12],x=n[13],b=n[14],w=n[15],t[12]=_*r+x*s+b*f+w*m,t[13]=_*i+x*l+b*p+w*g,t[14]=_*a+x*u+b*h+w*y,t[15]=_*o+x*c+b*d+w*v,t},perspective:function(t,e,n,r,i){var a=1/Math.tan(e/2),o=1/(r-i);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+r)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*r*o,t[15]=0,t},rotateX:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),a=e[4],o=e[5],s=e[6],l=e[7],u=e[8],c=e[9],f=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+u*r,t[5]=o*i+c*r,t[6]=s*i+f*r,t[7]=l*i+p*r,t[8]=u*i-a*r,t[9]=c*i-o*r,t[10]=f*i-s*r,t[11]=p*i-l*r,t},rotateZ:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),a=e[0],o=e[1],s=e[2],l=e[3],u=e[4],c=e[5],f=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+u*r,t[1]=o*i+c*r,t[2]=s*i+f*r,t[3]=l*i+p*r,t[4]=u*i-a*r,t[5]=c*i-o*r,t[6]=f*i-s*r,t[7]=p*i-l*r,t},invert:function(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],u=e[7],c=e[8],f=e[9],p=e[10],h=e[11],d=e[12],m=e[13],g=e[14],y=e[15],v=n*s-r*o,_=n*l-i*o,x=n*u-a*o,b=r*l-i*s,w=r*u-a*s,k=i*u-a*l,T=c*m-f*d,A=c*g-p*d,M=c*y-h*d,S=f*g-p*m,C=f*y-h*m,z=p*y-h*g,L=v*z-_*C+x*S+b*M-w*A+k*T;return L?(L=1/L,t[0]=(s*z-l*C+u*S)*L,t[1]=(i*C-r*z-a*S)*L,t[2]=(m*k-g*w+y*b)*L,t[3]=(p*w-f*k-h*b)*L,t[4]=(l*M-o*z-u*A)*L,t[5]=(n*z-i*M+a*A)*L,t[6]=(g*x-d*k-y*_)*L,t[7]=(c*k-p*x+h*_)*L,t[8]=(o*C-s*M+u*T)*L,t[9]=(r*M-n*C-a*T)*L,t[10]=(d*w-m*x+y*v)*L,t[11]=(f*x-c*w-h*v)*L,t[12]=(s*A-o*S-l*T)*L,t[13]=(n*S-r*A+i*T)*L,t[14]=(m*_-d*b-g*v)*L,t[15]=(c*b-f*_+p*v)*L,t):null},ortho:function(t,e,n,r,i,a,o){var s=1/(e-n),l=1/(r-i),u=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*l,t[14]=(o+a)*u,t[15]=1,t}}})}),ei=(ti.vec3,ti.vec4),ni=(ti.mat2,ti.mat3,ti.mat4),ri=function(t){function e(e){t.call(this,e,Qr)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createBucket=function(t){return new Nr(t)},e.prototype.queryRadius=function(t){var e=t;return Yr("circle-radius",this,e)+Yr("circle-stroke-width",this,e)+Jr(this.paint.get("circle-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,i,a,o){for(var s=Kr(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),i.angle,a),l=this.paint.get("circle-radius").evaluate(e)+this.paint.get("circle-stroke-width").evaluate(e),u="map"===this.paint.get("circle-pitch-alignment"),c=u?s:function(t,e,n){return s.map(function(t){return t.map(function(t){return ii(t,e,n)})})}(0,o,i),f=u?l*a:l,p=0,h=n;pt.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=t.data,s=e.data,l=0;l80*n){r=a=t[0],i=o=t[1];for(var d=n;da&&(a=s),l>o&&(o=l);u=0!==(u=Math.max(a-r,o-i))?1/u:0}return wi(p,h,n,r,i,u),h}function xi(t,e,n,r,i){var a,o;if(i===Vi(t,e,n,r)>0)for(a=e;a=e;a-=r)o=Bi(a,t[a],t[a+1],o);return o&&Di(o,o.next)&&(Ni(o),o=o.next),o}function bi(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Di(r,r.next)&&0!==Pi(r.prev,r,r.next))r=r.next;else{if(Ni(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function wi(t,e,n,r,i,a,o){if(t){!o&&a&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=zi(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,a,o,s,l,u=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,u*=2}while(o>1)}(i)}(t,r,i,a);for(var s,l,u=t;t.prev!==t.next;)if(s=t.prev,l=t.next,a?Ti(t,r,i,a):ki(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Ni(t),t=l.next,u=l.next;else if((t=l)===u){o?1===o?wi(t=Ai(t,e,n),e,n,r,i,a,2):2===o&&Mi(t,e,n,r,i,a):wi(bi(t),e,n,r,i,a,1);break}}}function ki(t){var e=t.prev,n=t,r=t.next;if(Pi(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Ei(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Pi(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Ti(t,e,n,r){var i=t.prev,a=t,o=t.next;if(Pi(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,c=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,f=zi(s,l,e,n,r),p=zi(u,c,e,n,r),h=t.prevZ,d=t.nextZ;h&&h.z>=f&&d&&d.z<=p;){if(h!==t.prev&&h!==t.next&&Ei(i.x,i.y,a.x,a.y,o.x,o.y,h.x,h.y)&&Pi(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,d!==t.prev&&d!==t.next&&Ei(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Pi(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;h&&h.z>=f;){if(h!==t.prev&&h!==t.next&&Ei(i.x,i.y,a.x,a.y,o.x,o.y,h.x,h.y)&&Pi(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&Ei(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Pi(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Ai(t,e,n){var r=t;do{var i=r.prev,a=r.next.next;!Di(i,a)&&Oi(i,r,r.next,a)&&Ri(i,a)&&Ri(a,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(a.i/n),Ni(r),Ni(r.next),r=t=a),r=r.next}while(r!==t);return r}function Mi(t,e,n,r,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Ii(o,s)){var l=Fi(o,s);return o=bi(o,o.next),l=bi(l,l.next),wi(o,e,n,r,i,a),void wi(l,e,n,r,i,a)}s=s.next}o=o.next}while(o!==t)}function Si(t,e){return t.x-e.x}function Ci(t,e){if(e=function(t,e){var n,r=e,i=t.x,a=t.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x=r.x&&r.x>=c&&i!==r.x&&Ei(an.x)&&Ri(r,t)&&(n=r,p=l),r=r.next;return n}(t,e)){var n=Fi(e,t);bi(n,n.next)}}function zi(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Li(t){var e=t,n=t;do{e.x=0&&(t-o)*(r-s)-(n-o)*(e-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function Ii(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Oi(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&Ri(t,e)&&Ri(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Pi(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Di(t,e){return t.x===e.x&&t.y===e.y}function Oi(t,e,n,r){return!!(Di(t,e)&&Di(n,r)||Di(t,r)&&Di(n,e))||Pi(t,e,n)>0!=Pi(t,e,r)>0&&Pi(n,r,t)>0!=Pi(n,r,e)>0}function Ri(t,e){return Pi(t.prev,t,t.next)<0?Pi(t,e,t.next)>=0&&Pi(t,t.prev,e)>=0:Pi(t,e,t.prev)<0||Pi(t,t.next,e)<0}function Fi(t,e){var n=new ji(t.i,t.x,t.y),r=new ji(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Bi(t,e,n,r){var i=new ji(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ni(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ji(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Vi(t,e,n,r){for(var i=0,a=e,o=n-r;a0&&(r+=t[i-1].length,n.holes.push(r))}return n},yi.default=vi;var qi=Hi,Ui=Hi;function Hi(t,e,n,r,i){!function t(e,n,r,i,a){for(;i>r;){if(i-r>600){var o=i-r+1,s=n-r+1,l=Math.log(o),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(o-u)/o)*(s-o/2<0?-1:1);t(e,n,Math.max(r,Math.floor(n-s*u/o+c)),Math.min(i,Math.floor(n+(o-s)*u/o+c)),a)}var f=e[n],p=r,h=i;for(Zi(e,r,n),a(e[i],f)>0&&Zi(e,r,i);p0;)h--}0===a(e[r],f)?Zi(e,r,h):Zi(e,++h,i),h<=n&&(r=h+1),n<=h&&(i=h-1)}}(t,e,n||0,r||t.length-1,i||Gi)}function Zi(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Gi(t,e){return te?1:0}function $i(t,e){var n=t.length;if(n<=1)return[t];for(var r,i,a=[],o=0;o1)for(var l=0;lOr)||t.y===e.y&&(t.y<0||t.y>Or)}function ra(t){return t.every(function(t){return t.x<0})||t.every(function(t){return t.x>Or})||t.every(function(t){return t.y<0})||t.every(function(t){return t.y>Or})}ea.prototype.populate=function(t,e){for(var n=0,r=t;n=1){var m=f[h-1];if(!na(d,m)){l.vertexLength+4>Mr.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));var g=d.sub(m)._perp()._unit(),y=m.dist(d);p+y>32768&&(p=0),ta(this.layoutVertexArray,d.x,d.y,g.x,g.y,0,0,p),ta(this.layoutVertexArray,d.x,d.y,g.x,g.y,0,1,p),p+=y,ta(this.layoutVertexArray,m.x,m.y,g.x,g.y,0,0,p),ta(this.layoutVertexArray,m.x,m.y,g.x,g.y,0,1,p);var v=l.vertexLength;this.indexArray.emplaceBack(v,v+1,v+2),this.indexArray.emplaceBack(v+1,v+2,v+3),l.vertexLength+=4,l.primitiveLength+=2}}}}l.vertexLength+a>Mr.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(a,this.layoutVertexArray,this.indexArray));for(var _=[],x=[],b=l.vertexLength,w=0,k=i;w>3}if(i--,1===r||2===r)a+=t.readSVarint(),o+=t.readSVarint(),1===r&&(e&&s.push(e),e=[]),e.push(new l(a,o));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&s.push(e),s},la.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,n=1,r=0,i=0,a=0,o=1/0,s=-1/0,l=1/0,u=-1/0;t.pos>3}if(r--,1===n||2===n)(i+=t.readSVarint())s&&(s=i),(a+=t.readSVarint())u&&(u=a);else if(7!==n)throw new Error("unknown command "+n)}return[o,l,s,u]},la.prototype.toGeoJSON=function(t,e,n){var r,i,a=this.extent*Math.pow(2,n),o=this.extent*t,s=this.extent*e,l=this.loadGeometry(),u=la.types[this.type];function c(t){for(var e=0;e>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(n))}function da(t,e,n){if(3===t){var r=new fa(n,n.readVarint()+n.pos);r.length&&(e[r.name]=r)}}pa.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new sa(this._pbf,e,this.extent,this._keys,this._values)};var ma={VectorTile:function(t,e){this.layers=t.readFields(da,{},e)},VectorTileFeature:sa,VectorTileLayer:fa},ga=ma.VectorTileFeature.types,ya=63,va=Math.cos(Math.PI/180*37.5),_a=.5,xa=Math.pow(2,14)/_a;function ba(t,e,n,r,i,a,o){t.emplaceBack(e.x,e.y,r?1:0,i?1:-1,Math.round(ya*n.x)+128,Math.round(ya*n.y)+128,1+(0===a?0:a<0?-1:1)|(o*_a&63)<<2,o*_a>>6)}var wa=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(function(t){return t.id}),this.index=t.index,this.layoutVertexArray=new tr,this.indexArray=new fr,this.programConfigurations=new Pr(oa,t.layers,t.zoom),this.segments=new Mr};function ka(t,e){return(t/e.tileTotal*(e.end-e.start)+e.start)*(xa-1)}wa.prototype.populate=function(t,e){for(var n=0,r=t;n=2&&t[l-1].equals(t[l-2]);)l--;for(var u=0;uu){var C=h.dist(_);if(C>2*c){var z=h.sub(h.sub(_)._mult(c/C)._round());this.distance+=z.dist(_),this.addCurrentVertex(z,this.distance,b.mult(1),0,0,!1,p,o),_=z}}var L=_&&x,E=L?n:x?g:y;if(L&&"round"===E&&(Mi&&(E="bevel"),"bevel"===E&&(M>2&&(E="flipbevel"),M100)T=w.clone().mult(-1);else{var I=b.x*w.y-b.y*w.x>0?-1:1,P=M*b.add(w).mag()/b.sub(w).mag();T._perp()._mult(P*I)}this.addCurrentVertex(h,this.distance,T,0,0,!1,p,o),this.addCurrentVertex(h,this.distance,T.mult(-1),0,0,!1,p,o)}else if("bevel"===E||"fakeround"===E){var D=b.x*w.y-b.y*w.x>0,O=-Math.sqrt(M*M-1);if(D?(m=0,d=O):(d=0,m=O),v||this.addCurrentVertex(h,this.distance,b,d,m,!1,p,o),"fakeround"===E){for(var R=Math.floor(8*(.5-(A-.5))),F=void 0,B=0;B=0;N--)F=b.mult((N+1)/(R+1))._add(w)._unit(),this.addPieSliceVertex(h,this.distance,F,D,p,o)}x&&this.addCurrentVertex(h,this.distance,w,-d,-m,!1,p,o)}else"butt"===E?(v||this.addCurrentVertex(h,this.distance,b,0,0,!1,p,o),x&&this.addCurrentVertex(h,this.distance,w,0,0,!1,p,o)):"square"===E?(v||(this.addCurrentVertex(h,this.distance,b,1,1,!1,p,o),this.e1=this.e2=-1),x&&this.addCurrentVertex(h,this.distance,w,-1,-1,!1,p,o)):"round"===E&&(v||(this.addCurrentVertex(h,this.distance,b,0,0,!1,p,o),this.addCurrentVertex(h,this.distance,b,1,1,!0,p,o),this.e1=this.e2=-1),x&&(this.addCurrentVertex(h,this.distance,w,-1,-1,!0,p,o),this.addCurrentVertex(h,this.distance,w,0,0,!1,p,o)));if(S&&k2*c){var V=h.add(x.sub(h)._mult(c/j)._round());this.distance+=V.dist(h),this.addCurrentVertex(V,this.distance,w.mult(1),0,0,!1,p,o),h=V}}v=!1}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e)}},wa.prototype.addCurrentVertex=function(t,e,n,r,i,a,o,s){var l,u=this.layoutVertexArray,c=this.indexArray;s&&(e=ka(e,s)),l=n.clone(),r&&l._sub(n.perp()._mult(r)),ba(u,t,l,a,!1,r,e),this.e3=o.vertexLength++,this.e1>=0&&this.e2>=0&&(c.emplaceBack(this.e1,this.e2,this.e3),o.primitiveLength++),this.e1=this.e2,this.e2=this.e3,l=n.mult(-1),i&&l._sub(n.perp()._mult(i)),ba(u,t,l,a,!0,-i,e),this.e3=o.vertexLength++,this.e1>=0&&this.e2>=0&&(c.emplaceBack(this.e1,this.e2,this.e3),o.primitiveLength++),this.e1=this.e2,this.e2=this.e3,e>xa/2&&!s&&(this.distance=0,this.addCurrentVertex(t,this.distance,n,r,i,a,o))},wa.prototype.addPieSliceVertex=function(t,e,n,r,i,a){n=n.mult(r?-1:1);var o=this.layoutVertexArray,s=this.indexArray;a&&(e=ka(e,a)),ba(o,t,n,!1,r,0,e),this.e3=i.vertexLength++,this.e1>=0&&this.e2>=0&&(s.emplaceBack(this.e1,this.e2,this.e3),i.primitiveLength++),r?this.e2=this.e3:this.e1=this.e3},dn("LineBucket",wa,{omit:["layers"]});var Ta=new Hn({"line-cap":new jn(P.layout_line["line-cap"]),"line-join":new Vn(P.layout_line["line-join"]),"line-miter-limit":new jn(P.layout_line["line-miter-limit"]),"line-round-limit":new jn(P.layout_line["line-round-limit"])}),Aa={paint:new Hn({"line-opacity":new Vn(P.paint_line["line-opacity"]),"line-color":new Vn(P.paint_line["line-color"]),"line-translate":new jn(P.paint_line["line-translate"]),"line-translate-anchor":new jn(P.paint_line["line-translate-anchor"]),"line-width":new Vn(P.paint_line["line-width"]),"line-gap-width":new Vn(P.paint_line["line-gap-width"]),"line-offset":new Vn(P.paint_line["line-offset"]),"line-blur":new Vn(P.paint_line["line-blur"]),"line-dasharray":new qn(P.paint_line["line-dasharray"]),"line-pattern":new qn(P.paint_line["line-pattern"]),"line-gradient":new Un(P.paint_line["line-gradient"])}),layout:Ta},Ma=new(function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.possiblyEvaluate=function(e,n){return n=new En(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,zoomHistory:n.zoomHistory,transition:n.transition}),t.prototype.possiblyEvaluate.call(this,e,n)},e.prototype.evaluate=function(e,n,r){return n=h({},n,{zoom:Math.floor(n.zoom)}),t.prototype.evaluate.call(this,e,n,r)},e}(Vn))(Aa.paint.properties["line-width"].specification);Ma.useIntegerZoom=!0;var Sa=function(t){function e(e){t.call(this,e,Aa)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setPaintProperty=function(e,n,r){t.prototype.setPaintProperty.call(this,e,n,r),"line-gradient"===e&&this._updateGradient()},e.prototype._updateGradient=function(){var t=this._transitionablePaint._values["line-gradient"].value.expression;this.gradient=pi(t,"lineProgress"),this.gradientTexture=null},e.prototype.recalculate=function(e){t.prototype.recalculate.call(this,e),this.paint._values["line-floorwidth"]=Ma.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)},e.prototype.createBucket=function(t){return new wa(t)},e.prototype.queryRadius=function(t){var e=t,n=Ca(Yr("line-width",this,e),Yr("line-gap-width",this,e)),r=Yr("line-offset",this,e);return n/2+Math.abs(r)+Jr(this.paint.get("line-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,i,a){var o=Kr(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),i.angle,a),s=a/2*Ca(this.paint.get("line-width").evaluate(e),this.paint.get("line-gap-width").evaluate(e)),u=this.paint.get("line-offset").evaluate(e);return u&&(n=function(t,e){for(var n=[],r=new l(0,0),i=0;i0?e+2*t:t}var za=Xn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"}]),La=Xn([{name:"a_projected_pos",components:3,type:"Float32"}],4),Ea=(Xn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4),Xn([{name:"a_placed",components:2,type:"Uint8"}],4)),Ia=(Xn([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"},{type:"Int16",name:"radius"},{type:"Int16",name:"signedDistanceFromAnchor"}]),Xn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4)),Pa=Xn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);function Da(t,e,n){var r=e.layout.get("text-transform").evaluate(n);return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),Ln.applyArabicShaping&&(t=Ln.applyArabicShaping(t)),t}Xn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"hidden"}]),Xn([{type:"Float32",name:"offsetX"}]),Xn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Oa={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42"},Ra=function(t){function e(e,n,r,i){t.call(this,e,n),this.angle=r,void 0!==i&&(this.segment=i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.clone=function(){return new e(this.x,this.y,this.angle,this.segment)},e}(l);function Fa(t,e){var n=e.expression;if("constant"===n.kind)return{functionType:"constant",layoutSize:n.evaluate(new En(t+1))};if("source"===n.kind)return{functionType:"source"};for(var r=n.zoomStops,i=0;i0)&&("constant"!==i.value.kind||i.value.value.length>0),l="constant"!==o.value.kind||o.value.value&&o.value.value.length>0;if(this.features=[],s||l){for(var u=e.iconDependencies,c=e.glyphDependencies,f=new En(this.zoom),p=0,h=t;p=0;s--)a[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:i},s>0&&(i+=e[s-1].dist(e[s]));for(var l=0;l0;this.addCollisionDebugVertices(s,l,u,c,f?this.collisionCircle:this.collisionBox,o.anchorPoint,n,f)}}}},Ha.prototype.deserializeCollisionBoxes=function(t,e,n,r,i){for(var a={},o=e;o0},Ha.prototype.hasIconData=function(){return this.icon.segments.get().length>0},Ha.prototype.hasCollisionBoxData=function(){return this.collisionBox.segments.get().length>0},Ha.prototype.hasCollisionCircleData=function(){return this.collisionCircle.segments.get().length>0},Ha.prototype.sortFeatures=function(t){var e=this;if(this.sortFeaturesByY&&this.sortedAngle!==t&&(this.sortedAngle=t,!(this.text.segments.get().length>1||this.icon.segments.get().length>1))){for(var n=[],r=0;ri.maxh||t>i.maxw||n<=i.maxh&&t<=i.maxw&&(o=i.maxw*i.maxh-t*n)a.free)){if(n===a.h)return this.allocShelf(s,t,n,r);n>a.h||nc)&&(f=2*Math.max(t,c)),(ll)&&(u=2*Math.max(n,l)),this.resize(f,u),this.packOne(t,n,r)):null},t.prototype.allocFreebin=function(t,e,n,r){var i=this.freebins.splice(t,1)[0];return i.id=r,i.w=e,i.h=n,i.refcount=0,this.bins[r]=i,this.ref(i),i},t.prototype.allocShelf=function(t,e,n,r){var i=this.shelves[t].alloc(e,n,r);return this.bins[r]=i,this.ref(i),i},t.prototype.shrink=function(){if(this.shelves.length>0){for(var t=0,e=0,n=0;nthis.free||e>this.h)return null;var r=this.x;return this.x+=t,this.free-=t,new function(t,e,n,r,i,a,o){this.id=t,this.x=e,this.y=n,this.w=r,this.h=i,this.maxw=a||r,this.maxh=o||i,this.refcount=0}(n,r,this.y,t,e,t,this.h)},e.prototype.resize=function(t){return this.free+=t-this.w,this.w=t,!0},t}()}),Qa=function(t,e){var n=e.pixelRatio;this.paddedRect=t,this.pixelRatio=n},to={tl:{configurable:!0},br:{configurable:!0},displaySize:{configurable:!0}};to.tl.get=function(){return[this.paddedRect.x+1,this.paddedRect.y+1]},to.br.get=function(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]},to.displaySize.get=function(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]},Object.defineProperties(Qa.prototype,to);var eo=function(t){var e=new ci({width:0,height:0}),n={},r=new Ka(0,0,{autoResize:!0});for(var i in t){var a=t[i],o=r.packOne(a.data.width+2,a.data.height+2);e.resize({width:r.w,height:r.h}),ci.copy(a.data,e,{x:0,y:0},{x:o.x+1,y:o.y+1},a.data),n[i]=new Qa(o,a)}r.shrink(),e.resize({width:r.w,height:r.h}),this.image=e,this.positions=n};dn("ImagePosition",Qa),dn("ImageAtlas",eo);var no=function(t,e,n,r,i){var a,o,s=8*i-r-1,l=(1<>1,c=-7,f=n?i-1:0,p=n?-1:1,h=t[e+f];for(f+=p,a=h&(1<<-c)-1,h>>=-c,c+=s;c>0;a=256*a+t[e+f],f+=p,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=r;c>0;o=256*o+t[e+f],f+=p,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(h?-1:1);o+=Math.pow(2,r),a-=u}return(h?-1:1)*o*Math.pow(2,a-r)},ro=function(t,e,n,r,i,a){var o,s,l,u=8*a-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:a-1,d=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?p/l:p*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[n+h]=255&s,h+=d,s/=256,i-=8);for(o=o<0;t[n+h]=255&o,h+=d,o/=256,u-=8);t[n+h-d]|=128*m},io=ao;function ao(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}function oo(t){return t.type===ao.Bytes?t.readVarint()+t.pos:t.pos+1}function so(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function lo(t,e,n){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=t;i--)n.buf[i+r]=n.buf[i]}function uo(t,e){for(var n=0;n>>8,t[n+2]=e>>>16,t[n+3]=e>>>24}function bo(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}ao.Varint=0,ao.Fixed64=1,ao.Bytes=2,ao.Fixed32=5,ao.prototype={destroy:function(){this.buf=null},readFields:function(t,e,n){for(n=n||this.length;this.pos>3,a=this.pos;this.type=7&r,t(i,e,this),this.pos===a&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=_o(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=bo(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=_o(this.buf,this.pos)+4294967296*_o(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=_o(this.buf,this.pos)+4294967296*bo(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=no(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=no(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,n,r=this.buf;return e=127&(n=r[this.pos++]),n<128?e:(e|=(127&(n=r[this.pos++]))<<7,n<128?e:(e|=(127&(n=r[this.pos++]))<<14,n<128?e:(e|=(127&(n=r[this.pos++]))<<21,n<128?e:function(t,e,n){var r,i,a=n.buf;if(r=(112&(i=a[n.pos++]))>>4,i<128)return so(t,r,e);if(r|=(127&(i=a[n.pos++]))<<3,i<128)return so(t,r,e);if(r|=(127&(i=a[n.pos++]))<<10,i<128)return so(t,r,e);if(r|=(127&(i=a[n.pos++]))<<17,i<128)return so(t,r,e);if(r|=(127&(i=a[n.pos++]))<<24,i<128)return so(t,r,e);if(r|=(1&(i=a[n.pos++]))<<31,i<128)return so(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(n=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=function(t,e,n){for(var r="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(a=t[i+1]))&&(u=(31&l)<<6|63&a)<=127&&(u=null):3===c?(a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&((u=(15&l)<<12|(63&a)<<6|63&o)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((u=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){var n=oo(this);for(t=t||[];this.pos127;);else if(e===ao.Bytes)this.pos=this.readVarint()+this.pos;else if(e===ao.Fixed32)this.pos+=4;else{if(e!==ao.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var n,r;if(t>=0?(n=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(n=~(-t%4294967296))?n=n+1|0:(n=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos]=127&t}(n,0,e),function(t,e){var n=(7&t)<<4;e.buf[e.pos++]|=n|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,n){for(var r,i,a=0;a55295&&r<57344){if(!i){r>56319||a+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):i=r;continue}if(r<56320){t[n++]=239,t[n++]=191,t[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(t[n++]=239,t[n++]=191,t[n++]=189,i=null);r<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:(r<65536?t[n++]=r>>12|224:(t[n++]=r>>18|240,t[n++]=r>>12&63|128),t[n++]=r>>6&63|128),t[n++]=63&r|128)}return n}(this.buf,t,this.pos);var n=this.pos-e;n>=128&&lo(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),ro(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ro(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var n=0;n=128&&lo(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,n){this.writeTag(t,ao.Bytes),this.writeRawMessage(e,n)},writePackedVarint:function(t,e){this.writeMessage(t,uo,e)},writePackedSVarint:function(t,e){this.writeMessage(t,co,e)},writePackedBoolean:function(t,e){this.writeMessage(t,ho,e)},writePackedFloat:function(t,e){this.writeMessage(t,fo,e)},writePackedDouble:function(t,e){this.writeMessage(t,po,e)},writePackedFixed32:function(t,e){this.writeMessage(t,mo,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,go,e)},writePackedFixed64:function(t,e){this.writeMessage(t,yo,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,vo,e)},writeBytesField:function(t,e){this.writeTag(t,ao.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,ao.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,ao.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,ao.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,ao.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,ao.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,ao.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,ao.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,ao.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,ao.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var wo=3;function ko(t,e,n){1===t&&n.readMessage(To,e)}function To(t,e,n){if(3===t){var r=n.readMessage(Ao,{}),i=r.id,a=r.bitmap,o=r.width,s=r.height,l=r.left,u=r.top,c=r.advance;e.push({id:i,bitmap:new ui({width:o+2*wo,height:s+2*wo},a),metrics:{width:o,height:s,left:l,top:u,advance:c}})}}function Ao(t,e,n){1===t?e.id=n.readVarint():2===t?e.bitmap=n.readBytes():3===t?e.width=n.readVarint():4===t?e.height=n.readVarint():5===t?e.left=n.readSVarint():6===t?e.top=n.readSVarint():7===t&&(e.advance=n.readVarint())}var Mo=wo,So=function(t,e,n){this.target=t,this.parent=e,this.mapId=n,this.callbacks={},this.callbackID=0,m(["receive"],this),this.target.addEventListener("message",this.receive,!1)};So.prototype.send=function(t,e,n,r){var i=n?this.mapId+":"+this.callbackID++:null;n&&(this.callbacks[i]=n);var a=[];this.target.postMessage({targetMapId:r,sourceMapId:this.mapId,type:t,id:String(i),data:gn(e,a)},a)},So.prototype.receive=function(t){var e,n=this,r=t.data,i=r.id;if(!r.targetMapId||this.mapId===r.targetMapId){var a=function(t,e){var r=[];n.target.postMessage({sourceMapId:n.mapId,type:"",id:String(i),error:t?gn(t):null,data:gn(e,r)},r)};if(""===r.type)e=this.callbacks[r.id],delete this.callbacks[r.id],e&&r.error?e(yn(r.error)):e&&e(null,yn(r.data));else if(void 0!==r.id&&this.parent[r.type])this.parent[r.type](r.sourceMapId,yn(r.data),a);else if(void 0!==r.id&&this.parent.getWorkerSource){var o=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,o[0],o[1])[o[2]](yn(r.data),a)}else this.parent[r.type](yn(r.data))}},So.prototype.remove=function(){this.target.removeEventListener("message",this.receive,!1)};var Co=r(i(function(t,e){!function(t){function e(t,e,r){var i=n(256*t,256*(e=Math.pow(2,r)-e-1),r),a=n(256*(t+1),256*(e+1),r);return i[0]+","+i[1]+","+a[0]+","+a[1]}function n(t,e,n){var r=2*Math.PI*6378137/256/Math.pow(2,n);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}t.getURL=function(t,n,r,i,a,o){return o=o||{},t+"?"+["bbox="+e(r,i,a),"format="+(o.format||"image/png"),"service="+(o.service||"WMS"),"version="+(o.version||"1.1.1"),"request="+(o.request||"GetMap"),"srs="+(o.srs||"EPSG:3857"),"width="+(o.width||256),"height="+(o.height||256),"layers="+n].join("&")},t.getTileBBox=e,t.getMercCoords=n,Object.defineProperty(t,"__esModule",{value:!0})}(e)})),zo=function(t,e,n){this.z=t,this.x=e,this.y=n,this.key=Io(0,t,e,n)};zo.prototype.equals=function(t){return this.z===t.z&&this.x===t.x&&this.y===t.y},zo.prototype.url=function(t,e){var n=Co.getTileBBox(this.x,this.y,this.z),r=function(t,e,n){for(var r,i="",a=t;a>0;a--)i+=(e&(r=1<this.canonical.z?new Eo(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Eo(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)},Eo.prototype.isChildOf=function(t){var e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e},Eo.prototype.children=function(t){if(this.overscaledZ>=t)return[new Eo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var e=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new Eo(e,this.wrap,e,n,r),new Eo(e,this.wrap,e,n+1,r),new Eo(e,this.wrap,e,n,r+1),new Eo(e,this.wrap,e,n+1,r+1)]},Eo.prototype.isLessThan=function(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=this.dim+this.border||e<-this.border||e>=this.dim+this.border)throw new RangeError("out of range source coordinates for DEM data");return(e+this.border)*this.stride+(t+this.border)},dn("Level",Po);var Do=function(t,e,n){this.uid=t,this.scale=e||1,this.level=n||new Po(256,512),this.loaded=!!n};Do.prototype.loadFromImage=function(t,e){if(t.height!==t.width)throw new RangeError("DEM tiles must be square");if(e&&"mapbox"!==e&&"terrarium"!==e)return b('"'+e+'" is not a valid encoding type. Valid types include "mapbox" and "terrarium".');var n=this.level=new Po(t.width,t.width/2),r=t.data;this._unpackData(n,r,e||"mapbox");for(var i=0;i=0&&l[3]>=0&&this.grid.insert(a,l[0],l[1],l[2],l[3])}},Bo.prototype.loadVTLayers=function(){return this.vtLayers||(this.vtLayers=new ma.VectorTile(new io(this.rawTileData)).layers,this.sourceLayerCoder=new Oo(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers},Bo.prototype.query=function(t,e){var n=this;this.loadVTLayers();for(var r=t.params||{},i=Or/t.tileSize/t.scale,a=Re(r.filter),o=t.queryGeometry,s=t.queryPadding*i,l=1/0,u=1/0,c=-1/0,f=-1/0,p=0;p=0)return!0;return!1}(a,l)){var u=this.sourceLayerCoder.decode(n),c=this.vtLayers[u].feature(r);if(i(new En(this.tileID.overscaledZ),c))for(var f=0;f=200&&n.status<300&&n.response){var r;try{r=JSON.parse(n.response)}catch(t){return e(t)}e(null,r)}else 401===n.status&&t.url.match(/mapbox.com/)?e(new A(n.statusText+": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens",n.status,t.url)):e(new A(n.statusText,n.status,t.url))},n.send(),n},e.getImage=function(t,e){return S(t,function(t,n){if(t)e(t);else if(n){var r=new self.Image,i=self.URL||self.webkitURL;r.onload=function(){e(null,r),i.revokeObjectURL(r.src)};var a=new self.Blob([new Uint8Array(n.data)],{type:"image/png"});r.cacheControl=n.cacheControl,r.expires=n.expires,r.src=n.data.byteLength?i.createObjectURL(a):"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII="}})},e.ResourceType=T,e.RGBAImage=ci,e.default$2=Ka,e.ImagePosition=Qa,e.getArrayBuffer=S,e.default$3=function(t){return new io(t).readFields(ko,[])},e.default$4=_n,e.asyncAll=function(t,e,n){if(!t.length)return n(null,[]);var r=t.length,i=new Array(t.length),a=null;t.forEach(function(t,o){e(t,function(t,e){t&&(a=t),i[o]=e,0==--r&&n(a,i)})})},e.AlphaImage=ui,e.default$5=P,e.endsWith=g,e.extend=h,e.sphericalToCartesian=function(t){var e=t[0],n=t[1],r=t[2];return n+=90,n*=Math.PI/180,r*=Math.PI/180,{x:e*Math.cos(n)*Math.sin(r),y:e*Math.sin(n)*Math.sin(r),z:e*Math.cos(r)}},e.Evented=I,e.validateStyle=rn,e.validateLight=an,e.emitValidationErrors=ln,e.default$6=tt,e.number=wt,e.Properties=Hn,e.Transitionable=Dn,e.Transitioning=Rn,e.PossiblyEvaluated=Nn,e.DataConstantProperty=jn,e.warnOnce=b,e.uniqueId=function(){return d++},e.default$7=So,e.pick=function(t,e){for(var n={},r=0;r@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,function(t,n,r,i){var a=r||i;return e[n]=!a||a.toLowerCase(),""}),e["max-age"]){var n=parseInt(e["max-age"],10);isNaN(n)?delete e["max-age"]:e["max-age"]=n}return e},e.default$11=Bo,e.default$12=Ro,e.default$13=Re,e.default$14=Ha,e.CollisionBoxArray=gr,e.default$15=Mr,e.TriangleIndexArray=fr,e.default$16=En,e.default$17=s,e.keysDifference=function(t,e){var n=[];for(var r in t)r in e||n.push(r);return n},e.default$18=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.mat4=ni,e.vec4=ei,e.getSizeData=Fa,e.evaluateSizeForFeature=function(t,e,n){var r=e;return"source"===t.functionType?n.lowerSize/10:"composite"===t.functionType?wt(n.lowerSize/10,n.upperSize/10,r.uSizeT):r.uSize},e.evaluateSizeForZoom=function(t,e,n){if("constant"===t.functionType)return{uSizeT:0,uSize:t.layoutSize};if("source"===t.functionType)return{uSizeT:0,uSize:0};if("camera"===t.functionType){var r=t.propertyValue,i=t.zoomRange,a=t.sizeRange,o=p(Se(r,n.specification).interpolationFactor(e,i.min,i.max),0,1);return{uSizeT:0,uSize:a.min+o*(a.max-a.min)}}var s=t.propertyValue,l=t.zoomRange;return{uSizeT:p(Se(s,n.specification).interpolationFactor(e,l.min,l.max),0,1),uSize:0}},e.addDynamicAttributes=Va,e.default$19=Ga,e.WritingMode=jo,e.multiPolygonIntersectsBufferedPoint=jr,e.multiPolygonIntersectsMultiPolygon=Vr,e.multiPolygonIntersectsBufferedMultiLine=qr,e.polygonIntersectsPolygon=function(t,e){for(var n=0;n-n/2;){if(--o<0)return!1;s-=t[o].dist(a),a=t[o]}s+=t[o].dist(t[o+1]),o++;for(var l=[],u=0;sr;)u-=l.shift().angleDelta;if(u>i)return!1;o++,s+=f.dist(p)}return!0}function a(e,n,r,a,o,s,l,u,c){var f=a?.6*s*l:0,p=Math.max(a?a.right-a.left:0,o?o.right-o.left:0),h=0===e[0].x||e[0].x===c||0===e[0].y||e[0].y===c;return n-p*l=0&&T=0&&A=0&&g+p<=h){var M=new t.default$25(T,A,w,v);M._round(),o&&!i(n,M,l,o,s)||y.push(M)}}m+=b}return c||y.length||u||(y=e(n,m/2,a,o,s,l,u,!0,f)),y}(e,h?n/2*u%n:(p/2+2*s)*l*u%n,n,f,r,p*l,h,!1,c)}r.prototype.replace=function(t){this._layerConfigs={},this._layers={},this.update(t,[])},r.prototype.update=function(e,r){for(var i=this,a=0,o=e;a0&&(m=Math.max(10*s,m),this._addLineCollisionCircles(t,e,n,n.segment,g,m,r,i,a,c))}else t.emplaceBack(n.x,n.y,h,f,d,p,r,i,a,0,0);this.boxEndIndex=t.length};s.prototype._addLineCollisionCircles=function(t,e,n,r,i,a,o,s,l,u){var c=a/2,f=Math.floor(i/c),p=1+.4*Math.log(u)/Math.LN2,h=Math.floor(f*p/2),d=-a/2,m=n,g=r+1,y=d,v=-i/2,_=v-i/4;do{if(--g<0){if(y>v)return;g=0;break}y-=e[g].dist(m),m=e[g]}while(y>_);for(var x=e[g].dist(e[g+1]),b=-h;bi&&(k+=w-i),!(k=e.length)return;x=e[g].dist(e[g+1])}var T=k-y,A=e[g],M=e[g+1].sub(A)._unit()._mult(T)._add(A)._round(),S=Math.abs(k-d)0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)}function f(t,e){return te?1:0}function p(e,n,r){void 0===n&&(n=1),void 0===r&&(r=!1);for(var i=1/0,a=1/0,o=-1/0,s=-1/0,u=e[0],c=0;co)&&(o=f.x),(!c||f.y>s)&&(s=f.y)}var p=o-i,m=s-a,g=Math.min(p,m),y=g/2,v=new l(null,h);if(0===g)return new t.default$1(i,a);for(var _=i;_b.d||!b.d)&&(b=k,r&&console.log("found best %d after %d probes",Math.round(1e4*k.d)/1e4,w)),k.max-b.d<=n||(y=k.h/2,v.push(new d(k.p.x-y,k.p.y-y,y,e)),v.push(new d(k.p.x+y,k.p.y-y,y,e)),v.push(new d(k.p.x-y,k.p.y+y,y,e)),v.push(new d(k.p.x+y,k.p.y+y,y,e)),w+=4)}return r&&(console.log("num probes: "+w),console.log("best distance: "+b.d)),b.p}function h(t,e){return e.max-t.max}function d(e,n,r,i){this.p=new t.default$1(e,n),this.h=r,this.d=function(e,n){for(var r=!1,i=1/0,a=0;ae.y!=f.y>e.y&&e.x<(f.x-c.x)*(e.y-c.y)/(f.y-c.y)+c.x&&(r=!r),i=Math.min(i,t.distToSegmentSquared(e,c,f))}return(r?1:-1)*Math.sqrt(i)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}function m(e,n,r,i,a,o){e.createArrays(),e.symbolInstances=[];var s=512*e.overscaling;e.tilePixelRatio=t.default$8/s,e.compareText={},e.iconsNeedLinear=!1;var l=e.layers[0].layout,u=e.layers[0]._unevaluatedLayout._values,c={};if("composite"===e.textSizeData.functionType){var f=e.textSizeData.zoomRange,p=f.min,h=f.max;c.compositeTextSizes=[u["text-size"].possiblyEvaluate(new t.default$16(p)),u["text-size"].possiblyEvaluate(new t.default$16(h))]}if("composite"===e.iconSizeData.functionType){var d=e.iconSizeData.zoomRange,m=d.min,y=d.max;c.compositeIconSizes=[u["icon-size"].possiblyEvaluate(new t.default$16(m)),u["icon-size"].possiblyEvaluate(new t.default$16(y))]}c.layoutTextSize=u["text-size"].possiblyEvaluate(new t.default$16(e.zoom+1)),c.layoutIconSize=u["icon-size"].possiblyEvaluate(new t.default$16(e.zoom+1)),c.textMaxSize=u["text-size"].possiblyEvaluate(new t.default$16(18));for(var v=24*l.get("text-line-height"),_="map"===l.get("text-rotation-alignment")&&"line"===l.get("symbol-placement"),x=l.get("text-keep-upright"),b=0,w=e.features;b=t.default$8||c.y<0||c.y>=t.default$8||e.symbolInstances.push(function(e,n,r,i,a,l,u,c,f,p,h,d,m,g,v,_,x,b,w,k,T){var A,M,S=e.addToLineVertexArray(n,r),C=0,z=0,L=0,E=i.horizontal?i.horizontal.text:"",I=[];i.horizontal&&(A=new s(u,r,n,c,f,p,i.horizontal,h,d,m,e.overscaling),z+=y(e,n,i.horizontal,l,m,w,g,S,i.vertical?t.WritingMode.horizontal:t.WritingMode.horizontalOnly,I,k,T),i.vertical&&(L+=y(e,n,i.vertical,l,m,w,g,S,t.WritingMode.vertical,I,k,T)));var P=A?A.boxStartIndex:e.collisionBoxArray.length,D=A?A.boxEndIndex:e.collisionBoxArray.length;if(a){var O=function(e,n,r,i,a,o){var s,l,u,c,f=n.image,p=r.layout,h=n.top-1/f.pixelRatio,d=n.left-1/f.pixelRatio,m=n.bottom+1/f.pixelRatio,g=n.right+1/f.pixelRatio;if("none"!==p.get("icon-text-fit")&&a){var y=g-d,v=m-h,_=p.get("text-size").evaluate(o)/24,x=a.left*_,b=a.right*_,w=a.top*_,k=b-x,T=a.bottom*_-w,A=p.get("icon-text-fit-padding")[0],M=p.get("icon-text-fit-padding")[1],S=p.get("icon-text-fit-padding")[2],C=p.get("icon-text-fit-padding")[3],z="width"===p.get("icon-text-fit")?.5*(T-v):0,L="height"===p.get("icon-text-fit")?.5*(k-y):0,E="width"===p.get("icon-text-fit")||"both"===p.get("icon-text-fit")?k:y,I="height"===p.get("icon-text-fit")||"both"===p.get("icon-text-fit")?T:v;s=new t.default$1(x+L-C,w+z-A),l=new t.default$1(x+L+M+E,w+z-A),u=new t.default$1(x+L+M+E,w+z+S+I),c=new t.default$1(x+L-C,w+z+S+I)}else s=new t.default$1(d,h),l=new t.default$1(g,h),u=new t.default$1(g,m),c=new t.default$1(d,m);var P=r.layout.get("icon-rotate").evaluate(o)*Math.PI/180;if(P){var D=Math.sin(P),O=Math.cos(P),R=[O,-D,D,O];s._matMult(R),l._matMult(R),c._matMult(R),u._matMult(R)}return[{tl:s,tr:l,bl:c,br:u,tex:f.paddedRect,writingMode:void 0,glyphOffset:[0,0]}]}(0,a,l,0,i.horizontal,w);M=new s(u,r,n,c,f,p,a,v,_,!1,e.overscaling),C=4*O.length;var R=e.iconSizeData,F=null;"source"===R.functionType?F=[10*l.layout.get("icon-size").evaluate(w)]:"composite"===R.functionType&&(F=[10*T.compositeIconSizes[0].evaluate(w),10*T.compositeIconSizes[1].evaluate(w)]),e.addSymbols(e.icon,O,F,b,x,w,!1,n,S.lineStartIndex,S.lineLength)}var B=M?M.boxStartIndex:e.collisionBoxArray.length,N=M?M.boxEndIndex:e.collisionBoxArray.length;return e.glyphOffsetArray.length>=t.default$14.MAX_GLYPHS&&t.warnOnce("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),{key:E,textBoxStartIndex:P,textBoxEndIndex:D,iconBoxStartIndex:B,iconBoxEndIndex:N,textOffset:g,iconOffset:b,anchor:n,line:r,featureIndex:c,feature:w,numGlyphVertices:z,numVerticalGlyphVertices:L,numIconVertices:C,textOpacityState:new o,iconOpacityState:new o,isDuplicate:!1,placedTextSymbolIndices:I,crossTileID:0}}(e,c,a,r,i,e.layers[0],e.collisionBoxArray,n.index,n.sourceLayerIndex,e.index,x,T,S,m,w,A,C,g,n,l,u))};if("line"===d.get("symbol-placement"))for(var E=0,I=function(e,n,r,i,a){for(var o=[],s=0;s=i&&p.x>=i||(f.x>=i?f=new t.default$1(i,f.y+(p.y-f.y)*((i-f.x)/(p.x-f.x)))._round():p.x>=i&&(p=new t.default$1(i,f.y+(p.y-f.y)*((i-f.x)/(p.x-f.x)))._round()),f.y>=a&&p.y>=a||(f.y>=a?f=new t.default$1(f.x+(p.x-f.x)*((a-f.y)/(p.y-f.y)),a)._round():p.y>=a&&(p=new t.default$1(f.x+(p.x-f.x)*((a-f.y)/(p.y-f.y)),a)._round()),u&&f.equals(u[u.length-1])||(u=[f],o.push(u)),u.push(p)))))}return o}(n.geometry,0,0,t.default$8,t.default$8);E=0;o--)if(r.dist(a[o])0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,a=e[i];if(n(r,a)>=0)break;e[t]=a,t=i}e[t]=r},_down:function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=s,t=a}e[t]=i}},l.default=u;var _=function(e){var n=new t.AlphaImage({width:0,height:0}),r={},i=new t.default$2(0,0,{autoResize:!0});for(var a in e){var o=e[a],s=r[a]={};for(var l in o){var u=o[+l];if(u&&0!==u.bitmap.width&&0!==u.bitmap.height){var c=i.packOne(u.bitmap.width+2,u.bitmap.height+2);n.resize({width:i.w,height:i.h}),t.AlphaImage.copy(u.bitmap,n,{x:0,y:0},{x:c.x+1,y:c.y+1},u.bitmap),s[l]={rect:c,metrics:u.metrics}}}}i.shrink(),n.resize({width:i.w,height:i.h}),this.image=n,this.positions=r};t.register("GlyphAtlas",_);var x=function(e){this.tileID=new t.OverscaledTileID(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming};function b(e,n){for(var r=new t.default$16(n),i=0,a=e;i=M.maxzoom||"none"!==M.visibility&&(b(A,a.zoom),(f[M.id]=M.createBucket({index:s.bucketLayerIDs.length,layers:A,zoom:a.zoom,pixelRatio:a.pixelRatio,overscaling:a.overscaling,collisionBoxArray:a.collisionBoxArray,sourceLayerIndex:y})).populate(v,p),s.bucketLayerIDs.push(A.map(function(t){return t.id})))}}}var S=t.mapObject(p.glyphDependencies,function(t){return Object.keys(t).map(Number)});Object.keys(S).length?r.send("getGlyphs",{uid:this.uid,stacks:S},function(t,e){l||(l=t,u=e,z.call(a))}):u={};var C=Object.keys(p.iconDependencies);function z(){if(l)return i(l);if(u&&c){var e=new _(u),n=new t.default$28(c);for(var r in f){var a=f[r];a instanceof t.default$14&&(b(a.layers,this.zoom),m(a,u,e.positions,c,n.positions,this.showCollisionBoxes))}this.status="done",i(null,{buckets:t.values(f).filter(function(t){return!t.isEmpty()}),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,iconAtlasImage:n.image})}}C.length?r.send("getImages",{icons:C},function(t,e){l||(l=t,c=e,z.call(a))}):c={},z.call(this)};var w=function(t){return!(!performance||!performance.getEntriesByName)&&performance.getEntriesByName(t)};function k(e,n){var r=t.getArrayBuffer(e.request,function(e,r){e?n(e):r&&n(null,{vectorTile:new t.default$29.VectorTile(new t.default$30(r.data)),rawData:r.data,cacheControl:r.cacheControl,expires:r.expires})});return function(){r.abort(),n()}}var T=function(t,e,n){this.actor=t,this.layerIndex=e,this.loadVectorData=n||k,this.loading={},this.loaded={}};T.prototype.loadTile=function(e,n){var r=this,i=e.uid;this.loading||(this.loading={});var a=this.loading[i]=new x(e);a.abort=this.loadVectorData(e,function(o,s){if(delete r.loading[i],o||!s)return n(o);var l=s.rawData,u={};s.expires&&(u.expires=s.expires),s.cacheControl&&(u.cacheControl=s.cacheControl);var c={};if(e.request&&e.request.collectResourceTiming){var f=w(e.request.url);f&&(c.resourceTiming=JSON.parse(JSON.stringify(f)))}a.vectorTile=s.vectorTile,a.parse(s.vectorTile,r.layerIndex,r.actor,function(e,r){if(e||!r)return n(e);n(null,t.extend({rawTileData:l.slice(0)},r,u,c))}),r.loaded=r.loaded||{},r.loaded[i]=a})},T.prototype.reloadTile=function(t,e){var n=this.loaded,r=t.uid,i=this;if(n&&n[r]){var a=n[r];a.showCollisionBoxes=t.showCollisionBoxes;var o=function(t,n){var r=a.reloadCallback;r&&(delete a.reloadCallback,a.parse(a.vectorTile,i.layerIndex,i.actor,r)),e(t,n)};"parsing"===a.status?a.reloadCallback=o:"done"===a.status&&a.parse(a.vectorTile,this.layerIndex,this.actor,o)}},T.prototype.abortTile=function(t,e){var n=this.loading,r=t.uid;n&&n[r]&&n[r].abort&&(n[r].abort(),delete n[r]),e()},T.prototype.removeTile=function(t,e){var n=this.loaded,r=t.uid;n&&n[r]&&delete n[r],e()};var A=function(){this.loading={},this.loaded={}};A.prototype.loadTile=function(e,n){var r=e.uid,i=e.encoding,a=new t.default$31(r);this.loading[r]=a,a.loadFromImage(e.rawImageData,i),delete this.loading[r],this.loaded=this.loaded||{},this.loaded[r]=a,n(null,a)},A.prototype.removeTile=function(t){var e=this.loaded,n=t.uid;e&&e[n]&&delete e[n]};var M={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:6356752.3142};function S(t){var e=0;if(t&&t.length>0){e+=Math.abs(C(t[0]));for(var n=1;n2){for(o=0;o=0}(t)===e?t:t.reverse()}var D=t.default$29.VectorTileFeature.prototype.toGeoJSON,O=function(e){this._feature=e,this.extent=t.default$8,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))};O.prototype.loadGeometry=function(){if(1===this._feature.type){for(var e=[],n=0,r=this._feature.geometry;n>31}function Y(t,e){for(var n=t.loadGeometry(),r=t.type,i=0,a=0,o=n.length,s=0;si;){if(a-i>600){var s=a-i+1,l=r-i+1,u=Math.log(s),c=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*c*(s-c)/s)*(l-s/2<0?-1:1);t(e,n,r,Math.max(i,Math.floor(r-l*c/s+f)),Math.min(a,Math.floor(r+(s-l)*c/s+f)),o)}var p=n[2*r+o],h=i,d=a;for(Q(e,n,i,r),n[2*a+o]>p&&Q(e,n,i,a);hp;)d--}n[2*i+o]===p?Q(e,n,i,d):Q(e,n,++d,a),d<=r&&(i=d+1),r<=d&&(a=d-1)}}(e,n,s,i,a,o%2),t(e,n,r,i,s-1,o+1),t(e,n,r,s+1,a,o+1)}};function Q(t,e,n,r){tt(t,n,r),tt(e,2*n,2*r),tt(e,2*n+1,2*r+1)}function tt(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function et(t,e,n,r){var i=t-n,a=e-r;return i*i+a*a}var nt=function(t,e,n,r,i){return new rt(t,e,n,r,i)};function rt(t,e,n,r,i){e=e||it,n=n||at,i=i||Array,this.nodeSize=r||64,this.points=t,this.ids=new i(t.length),this.coords=new i(2*t.length);for(var a=0;a=n&&s<=i&&l>=r&&l<=a&&c.push(t[d]);else{var m=Math.floor((h+p)/2);s=e[2*m],l=e[2*m+1],s>=n&&s<=i&&l>=r&&l<=a&&c.push(t[m]);var g=(f+1)%2;(0===f?n<=s:r<=l)&&(u.push(h),u.push(m-1),u.push(g)),(0===f?i>=s:a>=l)&&(u.push(m+1),u.push(p),u.push(g))}}return c}(this.ids,this.coords,t,e,n,r,this.nodeSize)},within:function(t,e,n){return function(t,e,n,r,i,a){for(var o=[0,t.length-1,0],s=[],l=i*i;o.length;){var u=o.pop(),c=o.pop(),f=o.pop();if(c-f<=a)for(var p=f;p<=c;p++)et(e[2*p],e[2*p+1],n,r)<=l&&s.push(t[p]);else{var h=Math.floor((f+c)/2),d=e[2*h],m=e[2*h+1];et(d,m,n,r)<=l&&s.push(t[h]);var g=(u+1)%2;(0===u?n-i<=d:r-i<=m)&&(o.push(f),o.push(h-1),o.push(g)),(0===u?n+i>=d:r+i>=m)&&(o.push(h+1),o.push(c),o.push(g))}}return s}(this.ids,this.coords,t,e,n,this.nodeSize)}};function ot(t){this.options=ht(Object.create(this.options),t),this.trees=new Array(this.options.maxZoom+1)}function st(t,e,n,r,i){return{x:t,y:e,zoom:1/0,id:r,properties:i,parentId:-1,numPoints:n}}function lt(t,e){var n=t.geometry.coordinates;return{x:ft(n[0]),y:pt(n[1]),zoom:1/0,id:e,parentId:-1}}function ut(t){return{type:"Feature",properties:ct(t),geometry:{type:"Point",coordinates:[(r=t.x,360*(r-.5)),(e=t.y,n=(180-360*e)*Math.PI/180,360*Math.atan(Math.exp(n))/Math.PI-90)]}};var e,n,r}function ct(t){var e=t.numPoints,n=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return ht(ht({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:n})}function ft(t){return t/360+.5}function pt(t){var e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function ht(t,e){for(var n in e)t[n]=e[n];return t}function dt(t){return t.x}function mt(t){return t.y}function gt(t,e,n,r,i,a){var o=i-n,s=a-r;if(0!==o||0!==s){var l=((t-n)*o+(e-r)*s)/(o*o+s*s);l>1?(n=i,r=a):l>0&&(n+=o*l,r+=s*l)}return(o=t-n)*o+(s=e-r)*s}function yt(t,e,n,r){var i={id:t||null,type:e,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,n=t.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)vt(t,e);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r0&&(o+=r?(i*u-l*a)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-a,2))),i=l,a=u}var c=e.length-3;e[2]=1,function t(e,n,r,i){for(var a,o=i,s=e[n],l=e[n+1],u=e[r],c=e[r+1],f=n+3;fo&&(a=f,o=p)}o>i&&(a-n>3&&t(e,n,a,i),e[a+2]=o,r-a>3&&t(e,a,r,i))}(e,0,c,n),e[c+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function wt(t,e,n,r){for(var i=0;i1?1:n}function At(t,e,n,r,i,a,o,s){if(r/=e,a>=(n/=e)&&o<=r)return t;if(a>r||o=n&&d<=r)l.push(c);else if(!(h>r||d=n&&o<=r&&(e.push(t[a]),e.push(t[a+1]),e.push(t[a+2]))}}function St(t,e,n,r,i,a,o){for(var s,l,u=Ct(t),c=0===i?Et:It,f=t.start,p=0;p=n&&(l=c(u,h,d,g,y,n),o&&(u.start=f+s*l)):v>r?_<=r&&(l=c(u,h,d,g,y,r),o&&(u.start=f+s*l)):Lt(u,h,d,m),_=n&&(l=c(u,h,d,g,y,n),x=!0),_>r&&v<=r&&(l=c(u,h,d,g,y,r),x=!0),!a&&x&&(o&&(u.end=f+s*l),e.push(u),u=Ct(t)),o&&(f+=s)}var b=t.length-3;h=t[b],d=t[b+1],m=t[b+2],(v=0===i?h:d)>=n&&v<=r&&Lt(u,h,d,m),b=u.length-3,a&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&Lt(u,u[0],u[1],u[2]),u.length&&e.push(u)}function Ct(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function zt(t,e,n,r,i,a){for(var o=0;oo.maxX&&(o.maxX=c),f>o.maxY&&(o.maxY=f)}return o}function Bt(t,e,n,r){var i=e.geometry,a=e.type,o=[];if("Point"===a||"MultiPoint"===a)for(var s=0;s0&&e.size<(i?o:r))n.numPoints+=e.length/3;else{for(var s=[],l=0;lo)&&(n.numSimplified++,s.push(e[l]),s.push(e[l+1])),n.numPoints++;i&&function(t,e){for(var n=0,r=0,i=t.length,a=i-2;r0===e)for(r=0,i=t.length;r24)throw new Error("maxZoom should be in the 0-24 range");var r=function(t,e){var n=[];if("FeatureCollection"===t.type)for(var r=0;r=this.options.minZoom;i--){var a=+Date.now();this.trees[i+1]=nt(r,dt,mt,this.options.nodeSize,Float32Array),r=this._cluster(r,i),e&&console.log("z%d: %d clusters in %dms",i,r.length,+Date.now()-a)}return this.trees[this.options.minZoom]=nt(r,dt,mt,this.options.nodeSize,Float32Array),e&&console.timeEnd("total time"),this},getClusters:function(t,e){for(var n=this.trees[this._limitZoom(e)],r=n.range(ft(t[0]),pt(t[3]),ft(t[2]),pt(t[1])),i=[],a=0;a1&&console.time("creation"),p=this.tiles[f]=Ft(t,e,n,r,l),this.tileCoords.push({z:e,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,n,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var h="z"+e;this.stats[h]=(this.stats[h]||0)+1,this.total++}if(p.source=t,i){if(e===l.maxZoom||e===i)continue;var d=1<1&&console.time("clipping");var m,g,y,v,_,x,b=.5*l.buffer/l.extent,w=.5-b,k=.5+b,T=1+b;m=g=y=v=null,_=At(t,c,n-b,n+k,0,p.minX,p.maxX,l),x=At(t,c,n+w,n+T,0,p.minX,p.maxX,l),t=null,_&&(m=At(_,c,r-b,r+k,1,p.minY,p.maxY,l),g=At(_,c,r+w,r+T,1,p.minY,p.maxY,l),_=null),x&&(y=At(x,c,r-b,r+k,1,p.minY,p.maxY,l),v=At(x,c,r+w,r+T,1,p.minY,p.maxY,l),x=null),u>1&&console.timeEnd("clipping"),s.push(m||[],e+1,2*n,2*r),s.push(g||[],e+1,2*n,2*r+1),s.push(y||[],e+1,2*n+1,2*r),s.push(v||[],e+1,2*n+1,2*r+1)}}},jt.prototype.getTile=function(t,e,n){var r=this.options,i=r.extent,a=r.debug;if(t<0||t>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",t,e,n);for(var l,u=t,c=e,f=n;!l&&u>0;)u--,c=Math.floor(c/2),f=Math.floor(f/2),l=this.tiles[Vt(u,c,f)];return l&&l.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,c,f),a>1&&console.time("drilling down"),this.splitTile(l.source,u,c,f,t,e,n),a>1&&console.timeEnd("drilling down"),this.tiles[s]?Ot(this.tiles[s],i):null):null};var Ut=function(e){function n(t,n,r){e.call(this,t,n,qt),r&&(this.loadGeoJSON=r)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.loadData=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),this._pendingCallback=e,this._pendingLoadDataParams=t,this._state&&"Idle"!==this._state?this._state="NeedsLoadData":(this._state="Coalescing",this._loadData())},n.prototype._loadData=function(){var t=this;if(this._pendingCallback&&this._pendingLoadDataParams){var e=this._pendingCallback,n=this._pendingLoadDataParams;delete this._pendingCallback,delete this._pendingLoadDataParams,this.loadGeoJSON(n,function(r,i){if(r||!i)return e(r);if("object"!=typeof i)return e(new Error("Input data is not a valid GeoJSON object."));!function t(e,n){switch(e&&e.type||null){case"FeatureCollection":return e.features=e.features.map(E(t,n)),e;case"Feature":return e.geometry=t(e.geometry,n),e;case"Polygon":case"MultiPolygon":return function(t,e){return"Polygon"===t.type?t.coordinates=I(t.coordinates,e):"MultiPolygon"===t.type&&(t.coordinates=t.coordinates.map(E(I,e))),t}(e,n);default:return e}}(i,!0);try{t._geoJSONIndex=n.cluster?function(t){return new ot(t)}(n.superclusterOptions).load(i.features):new jt(i,n.geojsonVtOptions)}catch(r){return e(r)}t.loaded={};var a={};if(n.request&&n.request.collectResourceTiming){var o=w(n.request.url);o&&(a.resourceTiming={},a.resourceTiming[n.source]=JSON.parse(JSON.stringify(o)))}e(null,a)})}},n.prototype.coalesce=function(){"Coalescing"===this._state?this._state="Idle":"NeedsLoadData"===this._state&&(this._state="Coalescing",this._loadData())},n.prototype.reloadTile=function(t,n){var r=this.loaded,i=t.uid;return r&&r[i]?e.prototype.reloadTile.call(this,t,n):this.loadTile(t,n)},n.prototype.loadGeoJSON=function(e,n){if(e.request)t.getJSON(e.request,n);else{if("string"!=typeof e.data)return n(new Error("Input data is not a valid GeoJSON object."));try{return n(null,JSON.parse(e.data))}catch(t){return n(new Error("Input data is not a valid GeoJSON object."))}}},n.prototype.removeSource=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),e()},n}(T),Ht=function(e){var n=this;this.self=e,this.actor=new t.default$7(e,this),this.layerIndexes={},this.workerSourceTypes={vector:T,geojson:Ut},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=function(t,e){if(n.workerSourceTypes[t])throw new Error('Worker source with name "'+t+'" already registered.');n.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=function(e){if(t.plugin.isLoaded())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText}};return Ht.prototype.setLayers=function(t,e,n){this.getLayerIndex(t).replace(e),n()},Ht.prototype.updateLayers=function(t,e,n){this.getLayerIndex(t).update(e.layers,e.removedIds),n()},Ht.prototype.loadTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).loadTile(e,n)},Ht.prototype.loadDEMTile=function(t,e,n){this.getDEMWorkerSource(t,e.source).loadTile(e,n)},Ht.prototype.reloadTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).reloadTile(e,n)},Ht.prototype.abortTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).abortTile(e,n)},Ht.prototype.removeTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).removeTile(e,n)},Ht.prototype.removeDEMTile=function(t,e){this.getDEMWorkerSource(t,e.source).removeTile(e)},Ht.prototype.removeSource=function(t,e,n){if(this.workerSources[t]&&this.workerSources[t][e.type]&&this.workerSources[t][e.type][e.source]){var r=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==r.removeSource?r.removeSource(e,n):n()}},Ht.prototype.loadWorkerSource=function(t,e,n){try{this.self.importScripts(e.url),n()}catch(t){n(t.toString())}},Ht.prototype.loadRTLTextPlugin=function(e,n,r){try{t.plugin.isLoaded()||(this.self.importScripts(n),r(t.plugin.isLoaded()?null:new Error("RTL Text Plugin failed to import scripts from "+n)))}catch(t){r(t.toString())}},Ht.prototype.getLayerIndex=function(t){var e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new r),e},Ht.prototype.getWorkerSource=function(t,e,n){var r=this;if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][n]){var i={send:function(e,n,i){r.actor.send(e,n,i,t)}};this.workerSources[t][e][n]=new this.workerSourceTypes[e](i,this.getLayerIndex(t))}return this.workerSources[t][e][n]},Ht.prototype.getDEMWorkerSource=function(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new A),this.demWorkerSources[t][e]},"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&new Ht(self),Ht}),i(0,function(t){var e=t.createCommonjsModule(function(t){function e(t){return!!("undefined"!=typeof window&&"undefined"!=typeof document&&Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray&&Function.prototype&&Function.prototype.bind&&Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions&&"JSON"in window&&"parse"in JSON&&"stringify"in JSON&&function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,n=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(n);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()&&"Uint8ClampedArray"in window&&function(t){return void 0===n[t]&&(n[t]=function(t){var n=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,n.probablySupportsContext?n.probablySupportsContext("webgl",r)||n.probablySupportsContext("experimental-webgl",r):n.supportsContext?n.supportsContext("webgl",r)||n.supportsContext("experimental-webgl",r):n.getContext("webgl",r)||n.getContext("experimental-webgl",r)}(t)),n[t]}(t&&t.failIfMajorPerformanceCaveat))}t.exports?t.exports=e:window&&(window.mapboxgl=window.mapboxgl||{},window.mapboxgl.supported=e);var n={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0}}),n=t.default.performance&&t.default.performance.now?t.default.performance.now.bind(t.default.performance):Date.now.bind(Date),r=t.default.requestAnimationFrame||t.default.mozRequestAnimationFrame||t.default.webkitRequestAnimationFrame||t.default.msRequestAnimationFrame,i=t.default.cancelAnimationFrame||t.default.mozCancelAnimationFrame||t.default.webkitCancelAnimationFrame||t.default.msCancelAnimationFrame,a={now:n,frame:function(t){return r(t)},cancelFrame:function(t){return i(t)},getImageData:function(e){var n=t.default.document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return n.width=e.width,n.height=e.height,r.drawImage(e,0,0,e.width,e.height),r.getImageData(0,0,e.width,e.height)},hardwareConcurrency:t.default.navigator.hardwareConcurrency||4,get devicePixelRatio(){return t.default.devicePixelRatio},supportsWebp:!1};if(t.default.document){var o=t.default.document.createElement("img");o.onload=function(){a.supportsWebp=!0},o.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="}var s={create:function(e,n,r){var i=t.default.document.createElement(e);return n&&(i.className=n),r&&r.appendChild(i),i},createNS:function(e,n){return t.default.document.createElementNS(e,n)}},l=t.default.document?t.default.document.documentElement.style:null;function u(t){if(!l)return null;for(var e=0;e=0?0:e.button},s.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};var g={API_URL:"https://api.mapbox.com",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null},y="See https://www.mapbox.com/api-documentation/#access-tokens";function v(t,e){var n=A(g.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,"/"!==n.path&&(t.path=""+n.path+t.path),!g.REQUIRE_ACCESS_TOKEN)return M(t);if(!(e=e||g.ACCESS_TOKEN))throw new Error("An API access token is required to use Mapbox GL. "+y);if("s"===e[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+y);return t.params.push("access_token="+e),M(t)}function _(t){return 0===t.indexOf("mapbox:")}var x=function(t,e){if(!_(t))return t;var n=A(t);return n.path="/v4/"+n.authority+".json",n.params.push("secure"),v(n,e)},b=function(t,e,n,r){var i=A(t);return _(t)?(i.path="/styles/v1"+i.path+"/sprite"+e+n,v(i,r)):(i.path+=""+e+n,M(i))},w=/(\.(png|jpg)\d*)(?=$)/,k=function(t,e,n){if(!e||!_(e))return t;var r=A(t),i=a.devicePixelRatio>=2||512===n?"@2x":"",o=a.supportsWebp?".webp":"$1";return r.path=r.path.replace(w,""+i+o),function(t){for(var e=0;e=0?1.2:1))}function R(t,e,n,r,i,a,o){for(var s=0;s65535)e(new Error("glyphs > 65535 not supported"));else{var l=a.requests[s];l||(l=a.requests[s]=[],B.loadGlyphRange(n,s,r.url,r.requestTransform,function(t,e){if(e)for(var n in e)a.glyphs[+n]=e[+n];for(var r=0,i=l;rthis.height)return t.warnOnce("LineAtlas out of space"),null;for(var a=0,o=0;o90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")};Z.prototype.wrap=function(){return new Z(t.wrap(this.lng,-180,180),this.lat)},Z.prototype.toArray=function(){return[this.lng,this.lat]},Z.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},Z.prototype.toBounds=function(t){var e=360*t/40075017,n=e/Math.cos(Math.PI/180*this.lat);return new G(new Z(this.lng-n,this.lat-e),new Z(this.lng+n,this.lat+e))},Z.convert=function(t){if(t instanceof Z)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Z(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Z(Number(t.lng),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, or an array of [, ]")};var G=function(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))};G.prototype.setNorthEast=function(t){return this._ne=t instanceof Z?new Z(t.lng,t.lat):Z.convert(t),this},G.prototype.setSouthWest=function(t){return this._sw=t instanceof Z?new Z(t.lng,t.lat):Z.convert(t),this},G.prototype.extend=function(t){var e,n,r=this._sw,i=this._ne;if(t instanceof Z)e=t,n=t;else{if(!(t instanceof G))return Array.isArray(t)?t.every(Array.isArray)?this.extend(G.convert(t)):this.extend(Z.convert(t)):this;if(e=t._sw,n=t._ne,!e||!n)return this}return r||i?(r.lng=Math.min(e.lng,r.lng),r.lat=Math.min(e.lat,r.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Z(e.lng,e.lat),this._ne=new Z(n.lng,n.lat)),this},G.prototype.getCenter=function(){return new Z((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},G.prototype.getSouthWest=function(){return this._sw},G.prototype.getNorthEast=function(){return this._ne},G.prototype.getNorthWest=function(){return new Z(this.getWest(),this.getNorth())},G.prototype.getSouthEast=function(){return new Z(this.getEast(),this.getSouth())},G.prototype.getWest=function(){return this._sw.lng},G.prototype.getSouth=function(){return this._sw.lat},G.prototype.getEast=function(){return this._ne.lng},G.prototype.getNorth=function(){return this._ne.lat},G.prototype.toArray=function(){return[this._sw.toArray(),this._ne.toArray()]},G.prototype.toString=function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"},G.prototype.isEmpty=function(){return!(this._sw&&this._ne)},G.convert=function(t){return!t||t instanceof G?t:new G(t)};var $=function(t,e,n){this.bounds=G.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=n||24};$.prototype.validateBounds=function(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]},$.prototype.contains=function(t){var e=Math.floor(this.lngX(this.bounds.getWest(),t.z)),n=Math.floor(this.latY(this.bounds.getNorth(),t.z)),r=Math.ceil(this.lngX(this.bounds.getEast(),t.z)),i=Math.ceil(this.latY(this.bounds.getSouth(),t.z));return t.x>=e&&t.x=n&&t.y0&&(l[new t.OverscaledTileID(e.overscaledZ,a,n.z,i,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,n.z,o,n.y-1).key]={backfilled:!1}),n.y+10&&(r.resourceTiming=e._resourceTiming,e._resourceTiming=[]),e.fire(new t.Event("data",r))}})},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.setData=function(e){var n=this;return this._data=e,this.fire(new t.Event("dataloading",{dataType:"source"})),this._updateWorkerData(function(e){if(e)return n.fire(new t.ErrorEvent(e));var r={dataType:"source",sourceDataType:"content"};n._collectResourceTiming&&n._resourceTiming&&n._resourceTiming.length>0&&(r.resourceTiming=n._resourceTiming,n._resourceTiming=[]),n.fire(new t.Event("data",r))}),this},n.prototype._updateWorkerData=function(e){var n,r,i=this,a=t.extend({},this.workerOptions),o=this._data;"string"==typeof o?(a.request=this.map._transformRequest((n=o,(r=t.default.document.createElement("a")).href=n,r.href),t.ResourceType.Source),a.request.collectResourceTiming=this._collectResourceTiming):a.data=JSON.stringify(o),this.workerID=this.dispatcher.send(this.type+"."+a.source+".loadData",a,function(t,n){i._removed||n&&n.abandoned||(i._loaded=!0,n&&n.resourceTiming&&n.resourceTiming[i.id]&&(i._resourceTiming=n.resourceTiming[i.id].slice(0)),i.dispatcher.send(i.type+"."+a.source+".coalesce",null,null,i.workerID),e(t))},this.workerID)},n.prototype.loadTile=function(t,e){var n=this,r=void 0===t.workerID?"loadTile":"reloadTile",i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes};t.workerID=this.dispatcher.send(r,i,function(i,a){return t.unloadVectorData(),t.aborted?e(null):i?e(i):(t.loadVectorData(a,n.map.painter,"reloadTile"===r),e(null))},this.workerID)},n.prototype.abortTile=function(t){t.aborted=!0},n.prototype.unloadTile=function(t){t.unloadVectorData(),this.dispatcher.send("removeTile",{uid:t.uid,type:this.type,source:this.id},null,t.workerID)},n.prototype.onRemove=function(){this._removed=!0,this.dispatcher.send("removeSource",{type:this.type,source:this.id},null,this.workerID)},n.prototype.serialize=function(){return t.extend({},this._options,{type:this.type,data:this._data})},n.prototype.hasTransition=function(){return!1},n}(t.Evented),K=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Q=function(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null};Q.prototype.bind=function(t,e,n,r,i,a,o,s){this.context=t;for(var l=this.boundPaintVertexBuffers.length!==r.length,u=0;!l&&u>s.z,u=new t.default$1(s.x*l,s.y*l),c=new t.default$1(u.x+l,u.y+l),f=this.segments.prepareSegment(4,r,i);r.emplaceBack(u.x,u.y,u.x,u.y),r.emplaceBack(c.x,u.y,c.x,u.y),r.emplaceBack(u.x,c.y,u.x,c.y),r.emplaceBack(c.x,c.y,c.x,c.y);var p=f.vertexLength;i.emplaceBack(p,p+1,p+2),i.emplaceBack(p+1,p+2,p+3),f.vertexLength+=4,f.primitiveLength+=2}this.maskedBoundsBuffer=n.createVertexBuffer(r,K.members),this.maskedIndexBuffer=n.createIndexBuffer(i)}},st.prototype.hasData=function(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state},st.prototype.setExpiryData=function(e){var n=this.expirationTime;if(e.cacheControl){var r=t.parseCacheControl(e.cacheControl);r["max-age"]&&(this.expirationTime=Date.now()+1e3*r["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){var i=Date.now(),a=!1;if(this.expirationTime>i)a=!1;else if(n)if(this.expirationTimethis.max){var o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this},lt.prototype.has=function(t){return t.wrapped().key in this.data},lt.prototype.getAndRemove=function(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null},lt.prototype._getAndRemoveByKey=function(t){var e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value},lt.prototype.get=function(t){return this.has(t)?this.data[t.wrapped().key][0].value:null},lt.prototype.remove=function(t,e){if(!this.has(t))return this;var n=t.wrapped().key,r=void 0===e?0:this.data[n].indexOf(e),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this},lt.prototype.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this};var ut=function(t,e,n){this.context=t;var r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(n),this.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};ut.prototype.unbindVAO=function(){this.context.extVertexArrayObject&&this.context.bindVertexArrayOES.set(null)},ut.prototype.bind=function(){this.context.bindElementBuffer.set(this.buffer)},ut.prototype.updateData=function(t){var e=this.context.gl;this.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)},ut.prototype.destroy=function(){var t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)};var ct={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},ft=function(t,e,n,r){this.length=e.length,this.attributes=n,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;var i=t.gl;this.buffer=i.createBuffer(),t.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};ft.prototype.bind=function(){this.context.bindVertexBuffer.set(this.buffer)},ft.prototype.updateData=function(t){var e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)},ft.prototype.enableAttributes=function(t,e){for(var n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,n,r),t.neighboringTiles&&t.neighboringTiles[a]&&(t.neighboringTiles[a].backfilled=!0)))}},n.prototype.getTile=function(t){return this.getTileByID(t.key)},n.prototype.getTileByID=function(t){return this._tiles[t]},n.prototype.getZoom=function(t){return t.zoom+t.scaleZoom(t.tileSize/this._source.tileSize)},n.prototype._findLoadedChildren=function(t,e,n){var r=!1;for(var i in this._tiles){var a=this._tiles[i];if(!(n[i]||!a.hasData()||a.tileID.overscaledZ<=t.overscaledZ||a.tileID.overscaledZ>e)){var o=Math.pow(2,a.tileID.canonical.z-t.canonical.z);if(Math.floor(a.tileID.canonical.x/o)===t.canonical.x&&Math.floor(a.tileID.canonical.y/o)===t.canonical.y)for(n[i]=a.tileID,r=!0;a&&a.tileID.overscaledZ-1>t.overscaledZ;){var s=a.tileID.scaledTo(a.tileID.overscaledZ-1);if(!s)break;(a=this._tiles[s.key])&&a.hasData()&&(delete n[i],n[s.key]=s)}}}return r},n.prototype.findLoadedParent=function(t,e,n){for(var r=t.overscaledZ-1;r>=e;r--){var i=t.scaledTo(r);if(!i)return;var a=String(i.key),o=this._tiles[a];if(o&&o.hasData())return n[a]=i,o;if(this._cache.has(i))return n[a]=i,this._cache.get(i)}},n.prototype.updateCacheSize=function(t){var e=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),n=Math.floor(5*e),r="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(r)},n.prototype.handleWrapJump=function(t){var e=(t-(void 0===this._prevLng?t:this._prevLng))/360,n=Math.round(e);if(this._prevLng=t,n){var r={};for(var i in this._tiles){var a=this._tiles[i];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+n),r[a.tileID.key]=a}for(var o in this._tiles=r,this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(var s in this._tiles){var l=this._tiles[s];this._setTileReloadTimer(s,l)}}},n.prototype.update=function(e){var r=this;if(this.transform=e,this._sourceLoaded&&!this._paused){var i;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(function(e){return new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)}):(i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}),this._source.hasTile&&(i=i.filter(function(t){return r._source.hasTile(t)}))):i=[];var o,s=(this._source.roundZoom?Math.round:Math.floor)(this.getZoom(e)),l=Math.max(s-n.maxOverzooming,this._source.minzoom),u=Math.max(s+n.maxUnderzooming,this._source.minzoom),c=this._updateRetainedTiles(i,s),f={};if(Xt(this._source.type))for(var p=Object.keys(c),h=0;h=a.now())){r._findLoadedChildren(m,u,c)&&(c[d]=m);var y=r.findLoadedParent(m,l,f);y&&r._addTile(y.tileID)}}for(o in f)c[o]||(r._coveredTiles[o]=!0);for(o in f)c[o]=f[o];for(var v=t.keysDifference(this._tiles,c),_=0;_this._source.maxzoom){var p=l.children(this._source.maxzoom)[0],h=this.getTile(p);h&&h.hasData()?r[p.key]=p:f=!1}else{this._findLoadedChildren(l,o,r);for(var d=l.children(this._source.maxzoom),m=0;m=a;--g){var y=l.scaledTo(g);if(i[y.key])break;if(i[y.key]=!0,!(u=this.getTile(y))&&c&&(u=this._addTile(y)),u&&(r[y.key]=y,c=u.wasRequested(),u.hasData()))break}}}return r},n.prototype._addTile=function(e){var n=this._tiles[e.key];if(n)return n;(n=this._cache.getAndRemove(e))&&(this._setTileReloadTimer(e.key,n),n.tileID=e);var r=Boolean(n);return r||(n=new st(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,this._tileLoaded.bind(this,n,e.key,n.state))),n?(n.uses++,this._tiles[e.key]=n,r||this._source.fire(new t.Event("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n):null},n.prototype._setTileReloadTimer=function(t,e){var n=this;t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);var r=e.getExpiryTimeout();r&&(this._timers[t]=setTimeout(function(){n._reloadTile(t,"expired"),delete n._timers[t]},r))},n.prototype._removeTile=function(t){var e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))},n.prototype.clearTiles=function(){for(var t in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(t);this._cache.reset()},n.prototype.tilesIn=function(e,n){for(var r=[],i=this.getIds(),a=1/0,o=1/0,s=-1/0,l=-1/0,u=e[0].zoom,c=0;c=0&&y[1].y+g>=0){for(var v=[],_=0;_=a.now())return!0}return!1},n}(t.Evented);function Wt(e,n){var r=n.zoomTo(e.canonical.z);return new t.default$1((r.column-(e.canonical.x+e.wrap*Math.pow(2,e.canonical.z)))*t.default$8,(r.row-e.canonical.y)*t.default$8)}function Xt(t){return"raster"===t||"image"===t||"video"===t}function Yt(){return new t.default.Worker(Cr.workerUrl)}$t.maxOverzooming=10,$t.maxUnderzooming=3;var Jt,Kt=function(){this.active={}};function Qt(e,n){var r={};for(var i in e)"ref"!==i&&(r[i]=e[i]);return t.default$18.forEach(function(t){t in n&&(r[t]=n[t])}),r}function te(t){t=t.slice();for(var e=Object.create(null),n=0;nthis.width||r<0||e>this.height)return!i&&[];var a=[];if(t<=0&&e<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(var o=0;o0:a},ue.prototype._queryCircle=function(t,e,n,r){var i=t-n,a=t+n,o=e-n,s=e+n;if(a<0||i>this.width||s<0||o>this.height)return!r&&[];var l=[],u={hitTest:r,circle:{x:t,y:e,radius:n},seenUids:{box:{},circle:{}}};return this._forEachCell(i,o,a,s,this._queryCellCircle,l,u),r?l.length>0:l},ue.prototype.query=function(t,e,n,r){return this._query(t,e,n,r,!1)},ue.prototype.hitTest=function(t,e,n,r){return this._query(t,e,n,r,!0)},ue.prototype.hitTestCircle=function(t,e,n){return this._queryCircle(t,e,n,!0)},ue.prototype._queryCell=function(t,e,n,r,i,a,o){var s=o.seenUids,l=this.boxCells[i];if(null!==l)for(var u=this.bboxes,c=0,f=l;c=u[h+0]&&r>=u[h+1]){if(o.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:u[h],y1:u[h+1],x2:u[h+2],y2:u[h+3]})}}}var d=this.circleCells[i];if(null!==d)for(var m=this.circles,g=0,y=d;go*o+s*s},ue.prototype._circleAndRectCollide=function(t,e,n,r,i,a,o){var s=(a-r)/2,l=Math.abs(t-(r+s));if(l>s+n)return!1;var u=(o-i)/2,c=Math.abs(e-(i+u));if(c>u+n)return!1;if(l<=s||c<=u)return!0;var f=l-s,p=c-u;return f*f+p*p<=n*n};var ce=t.default$19.layout;function fe(e,n,r,i,a){var o=t.mat4.identity(new Float32Array(16));return n?(t.mat4.identity(o),t.mat4.scale(o,o,[1/a,1/a,1]),r||t.mat4.rotateZ(o,o,i.angle)):(t.mat4.scale(o,o,[i.width/2,-i.height/2,1]),t.mat4.translate(o,o,[1,-1,0]),t.mat4.multiply(o,o,e)),o}function pe(e,n,r,i,a){var o=t.mat4.identity(new Float32Array(16));return n?(t.mat4.multiply(o,o,e),t.mat4.scale(o,o,[a,a,1]),r||t.mat4.rotateZ(o,o,-i.angle)):(t.mat4.scale(o,o,[1,-1,1]),t.mat4.translate(o,o,[-1,-1,0]),t.mat4.scale(o,o,[2/i.width,2/i.height,1])),o}function he(e,n){var r=[e.x,e.y,0,1];ke(r,r,n);var i=r[3];return{point:new t.default$1(r[0]/i,r[1]/i),signedDistanceFromCamera:i}}function de(t,e){var n=t[0]/t[3],r=t[1]/t[3];return n>=-e[0]&&n<=e[0]&&r>=-e[1]&&r<=e[1]}function me(e,n,r,i,a,o,s,l){var u=i?e.textSizeData:e.iconSizeData,c=t.evaluateSizeForZoom(u,r.transform.zoom,ce.properties[i?"text-size":"icon-size"]),f=[256/r.width*2+1,256/r.height*2+1],p=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;p.clear();for(var h=e.lineVertexArray,d=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,m=r.transform.width/r.transform.height,g=!1,y=0;yMath.abs(r.x-n.x)*i?{useVertical:!0}:(e===t.WritingMode.vertical?n.yr.x)?{needsFlipping:!0}:null}function ve(e,n,r,i,a,o,s,l,u,c,f,p,h,d){var m,g=n/24,y=e.lineOffsetX*n,v=e.lineOffsetY*n;if(e.numGlyphs>1){var _=e.glyphStartIndex+e.numGlyphs,x=e.lineStartIndex,b=e.lineStartIndex+e.lineLength,w=ge(g,l,y,v,r,f,p,e,u,o,h,!1);if(!w)return{notEnoughRoom:!0};var k=he(w.first.point,s).point,T=he(w.last.point,s).point;if(i&&!r){var A=ye(e.writingMode,k,T,d);if(A)return A}m=[w.first];for(var M=e.glyphStartIndex+1;M<_-1;M++)m.push(xe(g*l.getoffsetX(M),y,v,r,f,p,e.segment,x,b,u,o,h,!1));m.push(w.last)}else{if(i&&!r){var S=he(p,a).point,C=e.lineStartIndex+e.segment+1,z=new t.default$1(u.getx(C),u.gety(C)),L=he(z,a),E=L.signedDistanceFromCamera>0?L.point:_e(p,z,S,1,a),I=ye(e.writingMode,S,E,d);if(I)return I}var P=xe(g*l.getoffsetX(e.glyphStartIndex),y,v,r,f,p,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,u,o,h,!1);if(!P)return{notEnoughRoom:!0};m=[P]}for(var D=0,O=m;D0?1:-1,g=0;i&&(m*=-1,g=Math.PI),m<0&&(g+=Math.PI);for(var y=m>0?l+s:l+s+1,v=y,_=a,x=a,b=0,w=0,k=Math.abs(d);b+w<=k;){if((y+=m)=u)return null;if(x=_,void 0===(_=p[y])){var T=new t.default$1(c.getx(y),c.gety(y)),A=he(T,f);if(A.signedDistanceFromCamera>0)_=p[y]=A.point;else{var M=y-m;_=_e(0===b?o:new t.default$1(c.getx(M),c.gety(M)),T,x,k-b+1,f)}}b+=w,w=x.dist(_)}var S=(k-b)/w,C=_.sub(x),z=C.mult(S)._add(x);return z._add(C._unit()._perp()._mult(r*m)),{point:z,angle:g+Math.atan2(_.y-x.y,_.x-x.x),tileDistance:h?{prevTileDistance:y-m===v?0:c.gettileUnitDistanceFromAnchor(y-m),lastSegmentViewportDistance:k-b}:null}}var be=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function we(t,e){for(var n=0;nM)Ae(e,S,!1);else{var I=this.projectPoint(c,C,z),P=L*k;if(d.length>0){var D=I.x-d[d.length-4],O=I.y-d[d.length-3];if(P*P*2>D*D+O*O&&S+8-A&&R=this.screenRightBoundary||r<100||e>this.screenBottomBoundary};var Se=t.default$19.layout,Ce=function(t,e,n,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&n?1:0,this.placed=n};Ce.prototype.isHidden=function(){return 0===this.opacity&&!this.placed};var ze=function(t,e,n,r,i){this.text=new Ce(t?t.text:null,e,n,i),this.icon=new Ce(t?t.icon:null,e,r,i)};ze.prototype.isHidden=function(){return this.text.isHidden()&&this.icon.isHidden()};var Le=function(t,e,n){this.text=t,this.icon=e,this.skipFade=n},Ee=function(t,e){this.transform=t.clone(),this.collisionIndex=new Te(this.transform),this.placements={},this.opacities={},this.stale=!1,this.fadeDuration=e,this.retainedQueryData={}};function Ie(t,e,n){t.emplaceBack(e?1:0,n?1:0),t.emplaceBack(e?1:0,n?1:0),t.emplaceBack(e?1:0,n?1:0),t.emplaceBack(e?1:0,n?1:0)}Ee.prototype.placeLayerTile=function(e,n,r,i){var a=n.getBucket(e),o=n.latestFeatureIndex;if(a&&o&&e.id===a.layerIds[0]){var s=n.collisionBoxArray,l=a.layers[0].layout,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),c=n.tileSize/t.default$8,f=this.transform.calculatePosMatrix(n.tileID.toUnwrapped()),p=fe(f,"map"===l.get("text-pitch-alignment"),"map"===l.get("text-rotation-alignment"),this.transform,Me(n,1,this.transform.zoom)),h=fe(f,"map"===l.get("icon-pitch-alignment"),"map"===l.get("icon-rotation-alignment"),this.transform,Me(n,1,this.transform.zoom));this.retainedQueryData[a.bucketInstanceId]=new function(t,e,n,r,i){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=n,this.bucketIndex=r,this.tileID=i}(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,n.tileID),this.placeLayerBucket(a,f,p,h,u,c,r,i,s)}},Ee.prototype.placeLayerBucket=function(e,n,r,i,a,o,s,l,u){for(var c=e.layers[0].layout,f=t.evaluateSizeForZoom(e.textSizeData,this.transform.zoom,Se.properties["text-size"]),p=!e.hasTextData()||c.get("text-optional"),h=!e.hasIconData()||c.get("icon-optional"),d=0,m=e.symbolInstances;d0,_=_&&x.offscreen);var A=g.collisionArrays.textCircles;if(A){var M=e.text.placedSymbolArray.get(g.placedTextSymbolIndices[0]),S=t.evaluateSizeForFeature(e.textSizeData,f,M);b=this.collisionIndex.placeCollisionCircles(A,c.get("text-allow-overlap"),a,o,g.key,M,e.lineVertexArray,e.glyphOffsetArray,S,n,r,s,"map"===c.get("text-pitch-alignment")),y=c.get("text-allow-overlap")||b.circles.length>0,_=_&&b.offscreen}g.collisionArrays.iconFeatureIndex&&(T=g.collisionArrays.iconFeatureIndex),g.collisionArrays.iconBox&&(v=(w=this.collisionIndex.placeCollisionBox(g.collisionArrays.iconBox,c.get("icon-allow-overlap"),o,n)).box.length>0,_=_&&w.offscreen),p||h?h?p||(v=v&&y):y=v&&y:v=y=v&&y,y&&x&&this.collisionIndex.insertCollisionBox(x.box,c.get("text-ignore-placement"),e.bucketInstanceId,k),v&&w&&this.collisionIndex.insertCollisionBox(w.box,c.get("icon-ignore-placement"),e.bucketInstanceId,T),y&&b&&this.collisionIndex.insertCollisionCircles(b.circles,c.get("text-ignore-placement"),e.bucketInstanceId,k),this.placements[g.crossTileID]=new Le(y,v,_||e.justReloaded),l[g.crossTileID]=!0}}e.justReloaded=!1},Ee.prototype.commit=function(t,e){this.commitTime=e;var n=!1,r=t&&0!==this.fadeDuration?(this.commitTime-t.commitTime)/this.fadeDuration:1,i=t?t.opacities:{};for(var a in this.placements){var o=this.placements[a],s=i[a];s?(this.opacities[a]=new ze(s,r,o.text,o.icon),n=n||o.text!==s.text.placed||o.icon!==s.icon.placed):(this.opacities[a]=new ze(null,r,o.text,o.icon,o.skipFade),n=n||o.text||o.icon)}for(var l in i){var u=i[l];if(!this.opacities[l]){var c=new ze(u,r,!1,!1);c.isHidden()||(this.opacities[l]=c,n=n||u.text.placed||u.icon.placed)}}n?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)},Ee.prototype.updateLayerOpacities=function(t,e){for(var n={},r=0,i=e;r0||s.numVerticalGlyphVertices>0,f=s.numIconVertices>0;if(c){for(var p=je(u.text),h=(s.numGlyphVertices+s.numVerticalGlyphVertices)/4,d=0;dt},Ee.prototype.setStale=function(){this.stale=!0};var Pe=Math.pow(2,25),De=Math.pow(2,24),Oe=Math.pow(2,17),Re=Math.pow(2,16),Fe=Math.pow(2,9),Be=Math.pow(2,8),Ne=Math.pow(2,1);function je(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;var e=t.placed?1:0,n=Math.floor(127*t.opacity);return n*Pe+e*De+n*Oe+e*Re+n*Fe+e*Be+n*Ne+e}var Ve=function(){this._currentTileIndex=0,this._seenCrossTileIDs={}};Ve.prototype.continuePlacement=function(t,e,n,r,i){for(;this._currentTileIndex2};this._currentPlacementIndex>=0;){var s=e[t[r._currentPlacementIndex]],l=r.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){if(r._inProgressLayer||(r._inProgressLayer=new Ve),r._inProgressLayer.continuePlacement(n[s.source],r.placement,r._showCollisionBoxes,s,o))return;delete r._inProgressLayer}r._currentPlacementIndex--}this._done=!0},qe.prototype.commit=function(t,e){return this.placement.commit(t,e),this.placement};var Ue=512/t.default$8/2,He=function(t,e,n){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(var r=0,i=e;rt.overscaledZ)for(var l in s){var u=s[l];u.tileID.isChildOf(t)&&u.findMatches(e.symbolInstances,t,a)}else{var c=s[t.scaledTo(Number(o)).key];c&&c.findMatches(e.symbolInstances,t,a)}}for(var f=0,p=e.symbolInstances;f1?"@2x":"";function u(){if(s)r(s);else if(i&&o){var e=a.getImageData(o),n={};for(var l in i){var u=i[l],c=u.width,f=u.height,p=u.x,h=u.y,d=u.sdf,m=u.pixelRatio,g=new t.RGBAImage({width:c,height:f});t.RGBAImage.copy(e,g,{x:p,y:h},{x:0,y:0},{width:c,height:f}),n[l]={data:g,pixelRatio:m,sdf:d}}r(null,n)}}t.getJSON(n(b(e,l,".json"),t.ResourceType.SpriteJSON),function(t,e){s||(s=t,i=e,u())}),t.getImage(n(b(e,l,".png"),t.ResourceType.SpriteImage),function(t,e){s||(s=t,o=e,u())})}(e.sprite,this.map._transformRequest,function(e,n){if(e)r.fire(new t.ErrorEvent(e));else if(n)for(var i in n)r.imageManager.addImage(i,n[i]);r.imageManager.setLoaded(!0),r.fire(new t.Event("data",{dataType:"style"}))}):this.imageManager.setLoaded(!0),this.glyphManager.setURL(e.glyphs);var o=te(this.stylesheet.layers);this._order=o.map(function(t){return t.id}),this._layers={};for(var s=0,l=o;s0)throw new Error("Unimplemented: "+i.map(function(t){return t.command}).join(", ")+".");return r.forEach(function(t){"setTransition"!==t.command&&n[t.command].apply(n,t.args)}),this.stylesheet=e,!0},n.prototype.addImage=function(e,n){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(e,n),this.fire(new t.Event("data",{dataType:"style"}))},n.prototype.getImage=function(t){return this.imageManager.getImage(t)},n.prototype.removeImage=function(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(e),this.fire(new t.Event("data",{dataType:"style"}))},n.prototype.addSource=function(e,n,r){var i=this;if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error("There is already a source with this ID");if(!n.type)throw new Error("The type property must be defined, but the only the following properties were given: "+Object.keys(n).join(", ")+".");if(!(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(t.validateStyle.source,"sources."+e,n,null,r))){this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);var a=this.sourceCaches[e]=new $t(e,n,this.dispatcher);a.style=this,a.setEventedParent(this,function(){return{isSourceLoaded:i.loaded(),source:a.serialize(),sourceId:e}}),a.onAdd(this.map),this._changed=!0}},n.prototype.removeSource=function(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(var n in this._layers)if(this._layers[n].source===e)return this.fire(new t.ErrorEvent(new Error('Source "'+e+'" cannot be removed while layer "'+n+'" is using it.')));var r=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],r.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),r.setEventedParent(null),r.clearTiles(),r.onRemove&&r.onRemove(this.map),this._changed=!0},n.prototype.setGeoJSONSourceData=function(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0},n.prototype.getSource=function(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()},n.prototype.addLayer=function(e,n,r){this._checkLoaded();var i=e.id;if(this.getLayer(i))this.fire(new t.ErrorEvent(new Error('Layer with id "'+i+'" already exists on this map')));else if("object"==typeof e.source&&(this.addSource(i,e.source),e=t.clone(e),e=t.extend(e,{source:i})),!this._validate(t.validateStyle.layer,"layers."+i,e,{arrayIndex:-1},r)){var a=t.default$22(e);this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}});var o=n?this._order.indexOf(n):this._order.length;if(n&&-1===o)this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.')));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source){var s=this._removedLayers[i];delete this._removedLayers[i],s.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause())}this._updateLayer(a)}}},n.prototype.moveLayer=function(e,n){if(this._checkLoaded(),this._changed=!0,this._layers[e]){if(e!==n){var r=this._order.indexOf(e);this._order.splice(r,1);var i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.'))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be moved.")))},n.prototype.removeLayer=function(e){this._checkLoaded();var n=this._layers[e];if(n){n.setEventedParent(null);var r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e]}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be removed.")))},n.prototype.getLayer=function(t){return this._layers[t]},n.prototype.setLayerZoomRange=function(e,n,r){this._checkLoaded();var i=this.getLayer(e);i?i.minzoom===n&&i.maxzoom===r||(null!=n&&(i.minzoom=n),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot have zoom extent.")))},n.prototype.setFilter=function(e,n){this._checkLoaded();var r=this.getLayer(e);if(r){if(!t.default$10(r.filter,n))return null==n?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(t.validateStyle.filter,"layers."+r.id+".filter",n)||(r.filter=t.clone(n),this._updateLayer(r)))}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be filtered.")))},n.prototype.getFilter=function(e){return t.clone(this.getLayer(e).filter)},n.prototype.setLayoutProperty=function(e,n,r){this._checkLoaded();var i=this.getLayer(e);i?t.default$10(i.getLayoutProperty(n),r)||(i.setLayoutProperty(n,r),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getLayoutProperty=function(t,e){return this.getLayer(t).getLayoutProperty(e)},n.prototype.setPaintProperty=function(e,n,r){this._checkLoaded();var i=this.getLayer(e);if(i){if(!t.default$10(i.getPaintProperty(n),r)){var a=i._transitionablePaint._values[n].value.isDataDriven();i.setPaintProperty(n,r),(i._transitionablePaint._values[n].value.isDataDriven()||a)&&this._updateLayer(i),this._changed=!0,this._updatedPaintProps[e]=!0}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getPaintProperty=function(t,e){return this.getLayer(t).getPaintProperty(e)},n.prototype.getTransition=function(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)},n.prototype.serialize=function(){var e=this;return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:t.mapObject(this.sourceCaches,function(t){return t.serialize()}),layers:this._order.map(function(t){return e._layers[t].serialize()})},function(t){return void 0!==t})},n.prototype._updateLayer=function(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0},n.prototype._flattenRenderedFeatures=function(t){for(var e=[],n=this._order.length-1;n>=0;n--)for(var r=this._order[n],i=0,a=t;i 0.5) {\n gl_FragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha;\n }\n\n if (v_notUsed > 0.5) {\n // This box not used, fade it out\n gl_FragColor *= .1;\n }\n}",vertexSource:"attribute vec2 a_pos;\nattribute vec2 a_anchor_pos;\nattribute vec2 a_extrude;\nattribute vec2 a_placed;\n\nuniform mat4 u_matrix;\nuniform vec2 u_extrude_scale;\nuniform float u_camera_to_center_distance;\n\nvarying float v_placed;\nvarying float v_notUsed;\n\nvoid main() {\n vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n highp float collision_perspective_ratio = clamp(\n 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),\n 0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles\n 4.0);\n\n gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n gl_Position.xy += a_extrude * u_extrude_scale * gl_Position.w * collision_perspective_ratio;\n\n v_placed = a_placed.x;\n v_notUsed = a_placed.y;\n}\n"},collisionCircle:{fragmentSource:"uniform float u_overscale_factor;\n\nvarying float v_placed;\nvarying float v_notUsed;\nvarying float v_radius;\nvarying vec2 v_extrude;\nvarying vec2 v_extrude_scale;\n\nvoid main() {\n float alpha = 0.5;\n\n // Red = collision, hide label\n vec4 color = vec4(1.0, 0.0, 0.0, 1.0) * alpha;\n\n // Blue = no collision, label is showing\n if (v_placed > 0.5) {\n color = vec4(0.0, 0.0, 1.0, 0.5) * alpha;\n }\n\n if (v_notUsed > 0.5) {\n // This box not used, fade it out\n color *= .2;\n }\n\n float extrude_scale_length = length(v_extrude_scale);\n float extrude_length = length(v_extrude) * extrude_scale_length;\n float stroke_width = 15.0 * extrude_scale_length / u_overscale_factor;\n float radius = v_radius * extrude_scale_length;\n\n float distance_to_edge = abs(extrude_length - radius);\n float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge);\n\n gl_FragColor = opacity_t * color;\n}\n",vertexSource:"attribute vec2 a_pos;\nattribute vec2 a_anchor_pos;\nattribute vec2 a_extrude;\nattribute vec2 a_placed;\n\nuniform mat4 u_matrix;\nuniform vec2 u_extrude_scale;\nuniform float u_camera_to_center_distance;\n\nvarying float v_placed;\nvarying float v_notUsed;\nvarying float v_radius;\n\nvarying vec2 v_extrude;\nvarying vec2 v_extrude_scale;\n\nvoid main() {\n vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n highp float collision_perspective_ratio = clamp(\n 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),\n 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles\n 4.0);\n\n gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n\n highp float padding_factor = 1.2; // Pad the vertices slightly to make room for anti-alias blur\n gl_Position.xy += a_extrude * u_extrude_scale * padding_factor * gl_Position.w * collision_perspective_ratio;\n\n v_placed = a_placed.x;\n v_notUsed = a_placed.y;\n v_radius = abs(a_extrude.y); // We don't pitch the circles, so both units of the extrusion vector are equal in magnitude to the radius\n\n v_extrude = a_extrude * padding_factor;\n v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio;\n}\n"},debug:{fragmentSource:"uniform highp vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n}\n"},fill:{fragmentSource:"#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float opacity\n\n gl_FragColor = color * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n}\n"},fillOutline:{fragmentSource:"#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_pos;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = 1.0 - smoothstep(0.0, 1.0, dist);\n gl_FragColor = outline_color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\nuniform vec2 u_world;\n\nvarying vec2 v_pos;\n\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},fillOutlinePattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n // find distance to outline for alpha interpolation\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = 1.0 - smoothstep(0.0, 1.0, dist);\n\n\n gl_FragColor = mix(color1, color2, u_mix) * alpha * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_world;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);\n\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},fillPattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n gl_FragColor = mix(color1, color2, u_mix) * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);\n}\n"},fillExtrusion:{fragmentSource:"varying vec4 v_color;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define highp vec4 color\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n #pragma mapbox: initialize highp vec4 color\n\n gl_FragColor = v_color;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec3 u_lightcolor;\nuniform lowp vec3 u_lightpos;\nuniform lowp float u_lightintensity;\n\nattribute vec2 a_pos;\nattribute vec4 a_normal_ed;\n\nvarying vec4 v_color;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\n#pragma mapbox: define highp vec4 color\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n #pragma mapbox: initialize highp vec4 color\n\n vec3 normal = a_normal_ed.xyz;\n\n base = max(0.0, base);\n height = max(0.0, height);\n\n float t = mod(normal.x, 2.0);\n\n gl_Position = u_matrix * vec4(a_pos, t > 0.0 ? height : base, 1);\n\n // Relative luminance (how dark/bright is the surface color?)\n float colorvalue = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722;\n\n v_color = vec4(0.0, 0.0, 0.0, 1.0);\n\n // Add slight ambient lighting so no extrusions are totally black\n vec4 ambientlight = vec4(0.03, 0.03, 0.03, 1.0);\n color += ambientlight;\n\n // Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray\n float directional = clamp(dot(normal / 16384.0, u_lightpos), 0.0, 1.0);\n\n // Adjust directional so that\n // the range of values for highlight/shading is narrower\n // with lower light intensity\n // and with lighter/brighter surface colors\n directional = mix((1.0 - u_lightintensity), max((1.0 - colorvalue + u_lightintensity), 1.0), directional);\n\n // Add gradient along z axis of side surfaces\n if (normal.y != 0.0) {\n directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0);\n }\n\n // Assign final color based on surface + ambient light color, diffuse light directional, and light color\n // with lower bounds adjusted to hue of light\n // so that shading is tinted with the complementary (opposite) color to the light color\n v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0);\n v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0);\n v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0);\n}\n"},fillExtrusionPattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec4 v_lighting;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n vec4 mixedColor = mix(color1, color2, u_mix);\n\n gl_FragColor = mixedColor * v_lighting;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\nuniform float u_height_factor;\n\nuniform vec3 u_lightcolor;\nuniform lowp vec3 u_lightpos;\nuniform lowp float u_lightintensity;\n\nattribute vec2 a_pos;\nattribute vec4 a_normal_ed;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec4 v_lighting;\nvarying float v_directional;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n\n vec3 normal = a_normal_ed.xyz;\n float edgedistance = a_normal_ed.w;\n\n base = max(0.0, base);\n height = max(0.0, height);\n\n float t = mod(normal.x, 2.0);\n float z = t > 0.0 ? height : base;\n\n gl_Position = u_matrix * vec4(a_pos, z, 1);\n\n vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0\n ? a_pos // extrusion top\n : vec2(edgedistance, z * u_height_factor); // extrusion side\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, pos);\n\n v_lighting = vec4(0.0, 0.0, 0.0, 1.0);\n float directional = clamp(dot(normal / 16383.0, u_lightpos), 0.0, 1.0);\n directional = mix((1.0 - u_lightintensity), max((0.5 + u_lightintensity), 1.0), directional);\n\n if (normal.y != 0.0) {\n directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0);\n }\n\n v_lighting.rgb += clamp(directional * u_lightcolor, mix(vec3(0.0), vec3(0.3), 1.0 - u_lightcolor), vec3(1.0));\n}\n"},extrusionTexture:{fragmentSource:"uniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\n\nvoid main() {\n gl_FragColor = texture2D(u_image, v_pos) * u_opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(0.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_world;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1);\n\n v_pos.x = a_pos.x;\n v_pos.y = 1.0 - a_pos.y;\n}\n"},hillshadePrepare:{fragmentSource:"#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D u_image;\nvarying vec2 v_pos;\nuniform vec2 u_dimension;\nuniform float u_zoom;\nuniform float u_maxzoom;\n\nfloat getElevation(vec2 coord, float bias) {\n // Convert encoded elevation value to meters\n vec4 data = texture2D(u_image, coord) * 255.0;\n return (data.r + data.g * 256.0 + data.b * 256.0 * 256.0) / 4.0;\n}\n\nvoid main() {\n vec2 epsilon = 1.0 / u_dimension;\n\n // queried pixels:\n // +-----------+\n // | | | |\n // | a | b | c |\n // | | | |\n // +-----------+\n // | | | |\n // | d | e | f |\n // | | | |\n // +-----------+\n // | | | |\n // | g | h | i |\n // | | | |\n // +-----------+\n\n float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0);\n float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0);\n float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0);\n float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0);\n float e = getElevation(v_pos, 0.0);\n float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0);\n float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0);\n float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0);\n float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0);\n\n // here we divide the x and y slopes by 8 * pixel size\n // where pixel size (aka meters/pixel) is:\n // circumference of the world / (pixels per tile * number of tiles)\n // which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom))\n // which can be reduced to: pow(2, 19.25619978527 - u_zoom)\n // we want to vertically exaggerate the hillshading though, because otherwise\n // it is barely noticeable at low zooms. to do this, we multiply this by some\n // scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value\n // Here we use a=0.3 which works out to the expression below. see \n // nickidlugash's awesome breakdown for more info\n // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556\n float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;\n\n vec2 deriv = vec2(\n (c + f + f + i) - (a + d + d + g),\n (g + h + h + i) - (a + b + b + c)\n ) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom);\n\n gl_FragColor = clamp(vec4(\n deriv.x / 2.0 + 0.5,\n deriv.y / 2.0 + 0.5,\n 1.0,\n 1.0), 0.0, 1.0);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = (a_texture_pos / 8192.0) / 2.0 + 0.25;\n}\n"},hillshade:{fragmentSource:"uniform sampler2D u_image;\nvarying vec2 v_pos;\n\nuniform vec2 u_latrange;\nuniform vec2 u_light;\nuniform vec4 u_shadow;\nuniform vec4 u_highlight;\nuniform vec4 u_accent;\n\n#define PI 3.141592653589793\n\nvoid main() {\n vec4 pixel = texture2D(u_image, v_pos);\n\n vec2 deriv = ((pixel.rg * 2.0) - 1.0);\n\n // We divide the slope by a scale factor based on the cosin of the pixel's approximate latitude\n // to account for mercator projection distortion. see #4807 for details\n float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_pos.y) + u_latrange[1]));\n // We also multiply the slope by an arbitrary z-factor of 1.25\n float slope = atan(1.25 * length(deriv) / scaleFactor);\n float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0);\n\n float intensity = u_light.x;\n // We add PI to make this property match the global light object, which adds PI/2 to the light's azimuthal\n // position property to account for 0deg corresponding to north/the top of the viewport in the style spec\n // and the original shader was written to accept (-illuminationDirection - 90) as the azimuthal.\n float azimuth = u_light.y + PI;\n\n // We scale the slope exponentially based on intensity, using a calculation similar to\n // the exponential interpolation function in the style spec:\n // https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/expression/definitions/interpolate.js#L217-L228\n // so that higher intensity values create more opaque hillshading.\n float base = 1.875 - intensity * 1.75;\n float maxValue = 0.5 * PI;\n float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope;\n\n // The accent color is calculated with the cosine of the slope while the shade color is calculated with the sine\n // so that the accent color's rate of change eases in while the shade color's eases out.\n float accent = cos(scaledSlope);\n // We multiply both the accent and shade color by a clamped intensity value\n // so that intensities >= 0.5 do not additionally affect the color values\n // while intensity values < 0.5 make the overall color more transparent.\n vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0);\n float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0);\n vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0);\n gl_FragColor = accent_color * (1.0 - shade_color.a) + shade_color;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = a_texture_pos / 8192.0;\n}\n"},line:{fragmentSource:"#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_width2;\nvarying vec2 v_normal;\nvarying float v_gamma_scale;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_gamma_scale;\nvarying highp float v_linesofar;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n\n v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_width2 = vec2(outset, inset);\n}\n"},lineGradient:{fragmentSource:"\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nuniform sampler2D u_image;\n\nvarying vec2 v_width2;\nvarying vec2 v_normal;\nvarying float v_gamma_scale;\nvarying highp float v_lineprogress;\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n // For gradient lines, v_lineprogress is the ratio along the entire line,\n // scaled to [0, 2^15), and the gradient ramp is stored in a texture.\n vec4 color = texture2D(u_image, vec2(v_lineprogress, 0.5));\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"\n// the attribute conveying progress along a line is scaled to [0, 2^15)\n#define MAX_LINE_DISTANCE 32767.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_gamma_scale;\nvarying highp float v_lineprogress;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n\n v_lineprogress = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_width2 = vec2(outset, inset);\n}\n"},linePattern:{fragmentSource:"uniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_fade;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n float x_a = mod(v_linesofar / u_pattern_size_a.x, 1.0);\n float x_b = mod(v_linesofar / u_pattern_size_b.x, 1.0);\n\n // v_normal.y is 0 at the midpoint of the line, -1 at the lower edge, 1 at the upper edge\n // we clamp the line width outset to be between 0 and half the pattern height plus padding (2.0)\n // to ensure we don't sample outside the designated symbol on the sprite sheet.\n // 0.5 is added to shift the component to be bounded between 0 and 1 for interpolation of\n // the texture coordinate\n float y_a = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (u_pattern_size_a.y + 2.0) / 2.0) / u_pattern_size_a.y);\n float y_b = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (u_pattern_size_b.y + 2.0) / 2.0) / u_pattern_size_b.y);\n vec2 pos_a = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, vec2(x_a, y_a));\n vec2 pos_b = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, vec2(x_b, y_b));\n\n vec4 color = mix(texture2D(u_image, pos_a), texture2D(u_image, pos_b), u_fade);\n\n gl_FragColor = color * alpha * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_linesofar = a_linesofar;\n v_width2 = vec2(outset, inset);\n}\n"},lineSDF:{fragmentSource:"\nuniform sampler2D u_image;\nuniform float u_sdfgamma;\nuniform float u_mix;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float width\n #pragma mapbox: initialize lowp float floorwidth\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n float sdfdist_a = texture2D(u_image, v_tex_a).a;\n float sdfdist_b = texture2D(u_image, v_tex_b).a;\n float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix);\n alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist);\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_patternscale_a;\nuniform float u_tex_y_a;\nuniform vec2 u_patternscale_b;\nuniform float u_tex_y_b;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n #pragma mapbox: initialize lowp float floorwidth\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist =outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a);\n v_tex_b = vec2(a_linesofar * u_patternscale_b.x / floorwidth, normal.y * u_patternscale_b.y + u_tex_y_b);\n\n v_width2 = vec2(outset, inset);\n}\n"},raster:{fragmentSource:"uniform float u_fade_t;\nuniform float u_opacity;\nuniform sampler2D u_image0;\nuniform sampler2D u_image1;\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nuniform float u_brightness_low;\nuniform float u_brightness_high;\n\nuniform float u_saturation_factor;\nuniform float u_contrast_factor;\nuniform vec3 u_spin_weights;\n\nvoid main() {\n\n // read and cross-fade colors from the main and parent tiles\n vec4 color0 = texture2D(u_image0, v_pos0);\n vec4 color1 = texture2D(u_image1, v_pos1);\n if (color0.a > 0.0) {\n color0.rgb = color0.rgb / color0.a;\n }\n if (color1.a > 0.0) {\n color1.rgb = color1.rgb / color1.a;\n }\n vec4 color = mix(color0, color1, u_fade_t);\n color.a *= u_opacity;\n vec3 rgb = color.rgb;\n\n // spin\n rgb = vec3(\n dot(rgb, u_spin_weights.xyz),\n dot(rgb, u_spin_weights.zxy),\n dot(rgb, u_spin_weights.yzx));\n\n // saturation\n float average = (color.r + color.g + color.b) / 3.0;\n rgb += (average - rgb) * u_saturation_factor;\n\n // contrast\n rgb = (rgb - 0.5) * u_contrast_factor + 0.5;\n\n // brightness\n vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);\n vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);\n\n gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_tl_parent;\nuniform float u_scale_parent;\nuniform float u_buffer_scale;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n // We are using Int16 for texture position coordinates to give us enough precision for\n // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer\n // as an arbitrarily high number to preserve adequate precision when rendering.\n // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates,\n // so math for modifying either is consistent.\n v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5;\n v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;\n}\n"},symbolIcon:{fragmentSource:"uniform sampler2D u_texture;\n\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_tex;\nvarying float v_fade_opacity;\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n lowp float alpha = opacity * v_fade_opacity;\n gl_FragColor = texture2D(u_texture, v_tex) * alpha;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"const float PI = 3.141592653589793;\n\nattribute vec4 a_pos_offset;\nattribute vec4 a_data;\nattribute vec3 a_projected_pos;\nattribute float a_fade_opacity;\n\nuniform bool u_is_size_zoom_constant;\nuniform bool u_is_size_feature_constant;\nuniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function\nuniform highp float u_size; // used when size is both zoom and feature constant\nuniform highp float u_camera_to_center_distance;\nuniform highp float u_pitch;\nuniform bool u_rotate_symbol;\nuniform highp float u_aspect_ratio;\nuniform float u_fade_change;\n\n#pragma mapbox: define lowp float opacity\n\nuniform mat4 u_matrix;\nuniform mat4 u_label_plane_matrix;\nuniform mat4 u_gl_coord_matrix;\n\nuniform bool u_is_text;\nuniform bool u_pitch_with_map;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_tex;\nvarying float v_fade_opacity;\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 a_pos = a_pos_offset.xy;\n vec2 a_offset = a_pos_offset.zw;\n\n vec2 a_tex = a_data.xy;\n vec2 a_size = a_data.zw;\n\n highp float segment_angle = -a_projected_pos[2];\n\n float size;\n if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = mix(a_size[0], a_size[1], u_size_t) / 10.0;\n } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = a_size[0] / 10.0;\n } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {\n size = u_size;\n } else {\n size = u_size;\n }\n\n vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n // See comments in symbol_sdf.vertex\n highp float distance_ratio = u_pitch_with_map ?\n camera_to_anchor_distance / u_camera_to_center_distance :\n u_camera_to_center_distance / camera_to_anchor_distance;\n highp float perspective_ratio = clamp(\n 0.5 + 0.5 * distance_ratio,\n 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles\n 4.0);\n\n size *= perspective_ratio;\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n highp float symbol_rotation = 0.0;\n if (u_rotate_symbol) {\n // See comments in symbol_sdf.vertex\n vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);\n\n vec2 a = projectedPoint.xy / projectedPoint.w;\n vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;\n\n symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);\n }\n\n highp float angle_sin = sin(segment_angle + symbol_rotation);\n highp float angle_cos = cos(segment_angle + symbol_rotation);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);\n gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);\n\n v_tex = a_tex / u_texsize;\n vec2 fade_opacity = unpack_opacity(a_fade_opacity);\n float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;\n v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));\n}\n"},symbolSDF:{fragmentSource:"#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105/DEVICE_PIXEL_RATIO\n\nuniform bool u_is_halo;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n\nuniform sampler2D u_texture;\nuniform highp float u_gamma_scale;\nuniform bool u_is_text;\n\nvarying vec2 v_data0;\nvarying vec3 v_data1;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 fill_color\n #pragma mapbox: initialize highp vec4 halo_color\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float halo_width\n #pragma mapbox: initialize lowp float halo_blur\n\n vec2 tex = v_data0.xy;\n float gamma_scale = v_data1.x;\n float size = v_data1.y;\n float fade_opacity = v_data1[2];\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n lowp vec4 color = fill_color;\n highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);\n lowp float buff = (256.0 - 64.0) / 256.0;\n if (u_is_halo) {\n color = halo_color;\n gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);\n buff = (6.0 - halo_width / fontScale) / SDF_PX;\n }\n\n lowp float dist = texture2D(u_texture, tex).a;\n highp float gamma_scaled = gamma * gamma_scale;\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = color * (alpha * opacity * fade_opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"const float PI = 3.141592653589793;\n\nattribute vec4 a_pos_offset;\nattribute vec4 a_data;\nattribute vec3 a_projected_pos;\nattribute float a_fade_opacity;\n\n// contents of a_size vary based on the type of property value\n// used for {text,icon}-size.\n// For constants, a_size is disabled.\n// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.\n// For composite functions:\n// [ text-size(lowerZoomStop, feature),\n// text-size(upperZoomStop, feature) ]\nuniform bool u_is_size_zoom_constant;\nuniform bool u_is_size_feature_constant;\nuniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function\nuniform highp float u_size; // used when size is both zoom and feature constant\n\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n\nuniform mat4 u_matrix;\nuniform mat4 u_label_plane_matrix;\nuniform mat4 u_gl_coord_matrix;\n\nuniform bool u_is_text;\nuniform bool u_pitch_with_map;\nuniform highp float u_pitch;\nuniform bool u_rotate_symbol;\nuniform highp float u_aspect_ratio;\nuniform highp float u_camera_to_center_distance;\nuniform float u_fade_change;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_data0;\nvarying vec3 v_data1;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 fill_color\n #pragma mapbox: initialize highp vec4 halo_color\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float halo_width\n #pragma mapbox: initialize lowp float halo_blur\n\n vec2 a_pos = a_pos_offset.xy;\n vec2 a_offset = a_pos_offset.zw;\n\n vec2 a_tex = a_data.xy;\n vec2 a_size = a_data.zw;\n\n highp float segment_angle = -a_projected_pos[2];\n float size;\n\n if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = mix(a_size[0], a_size[1], u_size_t) / 10.0;\n } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = a_size[0] / 10.0;\n } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {\n size = u_size;\n } else {\n size = u_size;\n }\n\n vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n // If the label is pitched with the map, layout is done in pitched space,\n // which makes labels in the distance smaller relative to viewport space.\n // We counteract part of that effect by multiplying by the perspective ratio.\n // If the label isn't pitched with the map, we do layout in viewport space,\n // which makes labels in the distance larger relative to the features around\n // them. We counteract part of that effect by dividing by the perspective ratio.\n highp float distance_ratio = u_pitch_with_map ?\n camera_to_anchor_distance / u_camera_to_center_distance :\n u_camera_to_center_distance / camera_to_anchor_distance;\n highp float perspective_ratio = clamp(\n 0.5 + 0.5 * distance_ratio,\n 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles\n 4.0);\n\n size *= perspective_ratio;\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n highp float symbol_rotation = 0.0;\n if (u_rotate_symbol) {\n // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units\n // To figure out that angle in projected space, we draw a short horizontal line in tile\n // space, project it, and measure its angle in projected space.\n vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);\n\n vec2 a = projectedPoint.xy / projectedPoint.w;\n vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;\n\n symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);\n }\n\n highp float angle_sin = sin(segment_angle + symbol_rotation);\n highp float angle_cos = cos(segment_angle + symbol_rotation);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);\n gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);\n float gamma_scale = gl_Position.w;\n\n vec2 tex = a_tex / u_texsize;\n vec2 fade_opacity = unpack_opacity(a_fade_opacity);\n float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;\n float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));\n\n v_data0 = vec2(tex.x, tex.y);\n v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity);\n}\n"}},tn=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,en=function(t){var e=Qe[t],n={};e.fragmentSource=e.fragmentSource.replace(tn,function(t,e,r,i,a){return n[a]=!0,"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nvarying "+r+" "+i+" "+a+";\n#else\nuniform "+r+" "+i+" u_"+a+";\n#endif\n":"\n#ifdef HAS_UNIFORM_u_"+a+"\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n"}),e.vertexSource=e.vertexSource.replace(tn,function(t,e,r,i,a){var o="float"===i?"vec2":"vec4";return n[a]?"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float a_"+a+"_t;\nattribute "+r+" "+o+" a_"+a+";\nvarying "+r+" "+i+" "+a+";\n#else\nuniform "+r+" "+i+" u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+a+" = unpack_mix_"+o+"(a_"+a+", a_"+a+"_t);\n#else\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n":"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float a_"+a+"_t;\nattribute "+r+" "+o+" a_"+a+";\n#else\nuniform "+r+" "+i+" u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+r+" "+i+" "+a+" = unpack_mix_"+o+"(a_"+a+", a_"+a+"_t);\n#else\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n"})};for(var nn in Qe)en(nn);var rn=Qe,an=function(t,e,n,r){var i=t.gl;this.program=i.createProgram();var o=n.defines().concat("#define DEVICE_PIXEL_RATIO "+a.devicePixelRatio.toFixed(1));r&&o.push("#define OVERDRAW_INSPECTOR;");var s=o.concat(rn.prelude.fragmentSource,e.fragmentSource).join("\n"),l=o.concat(rn.prelude.vertexSource,e.vertexSource).join("\n"),u=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(u,s),i.compileShader(u),i.attachShader(this.program,u);var c=i.createShader(i.VERTEX_SHADER);i.shaderSource(c,l),i.compileShader(c),i.attachShader(this.program,c);for(var f=n.layoutAttributes||[],p=0;p>16,s>>16),r.uniform2f(n.uniforms.u_pixel_coord_lower,65535&o,65535&s)};function vn(t,e,n,r,i){if(!mn(n.paint.get("fill-pattern"),t))for(var a=!0,o=0,s=r;o0){var l=a.now(),u=(l-e.timeAdded)/s,c=n?(l-n.timeAdded)/s:-1,f=r.getSource(),p=o.coveringZoomLevel({tileSize:f.tileSize,roundZoom:f.roundZoom}),h=!n||Math.abs(n.tileID.overscaledZ-p)>Math.abs(e.tileID.overscaledZ-p),d=h&&e.refreshedUponExpiration?1:t.clamp(h?u:1-c,0,1);return e.refreshedUponExpiration&&u>=1&&(e.refreshedUponExpiration=!1),n?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}function zn(e,n,r){var i=e.context,o=i.gl;i.lineWidth.set(1*a.devicePixelRatio);var s=r.posMatrix,l=e.useProgram("debug");i.setDepthMode(Ut.disabled),i.setStencilMode(Ht.disabled),i.setColorMode(e.colorModeForRenderPass()),o.uniformMatrix4fv(l.uniforms.u_matrix,!1,s),o.uniform4f(l.uniforms.u_color,1,0,0,1),e.debugVAO.bind(i,l,e.debugBuffer,[]),o.drawArrays(o.LINE_STRIP,0,e.debugBuffer.length);for(var u=function(t,e,n,r){r=r||1;var i,a,o,s,l,u,c,f,p=[];for(i=0,a=t.length;i":[24,[4,18,20,9,4,0]],"?":[18,[3,16,3,17,4,19,5,20,7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,12,9,10,9,7,-1,-1,9,2,8,1,9,0,10,1,9,2]],"@":[27,[18,13,17,15,15,16,12,16,10,15,9,14,8,11,8,8,9,6,11,5,14,5,16,6,17,8,-1,-1,12,16,10,14,9,11,9,8,10,6,11,5,-1,-1,18,16,17,8,17,6,19,5,21,5,23,7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,21,9,20,7,19,5,17,4,15,3,12,3,9,4,6,5,4,7,2,9,1,12,0,15,0,18,1,20,2,21,3,-1,-1,19,16,18,8,18,6,19,5]],A:[18,[9,21,1,0,-1,-1,9,21,17,0,-1,-1,4,7,14,7]],B:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,-1,-1,4,11,13,11,16,10,17,9,18,7,18,4,17,2,16,1,13,0,4,0]],C:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5]],D:[21,[4,21,4,0,-1,-1,4,21,11,21,14,20,16,18,17,16,18,13,18,8,17,5,16,3,14,1,11,0,4,0]],E:[19,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11,-1,-1,4,0,17,0]],F:[18,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11]],G:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,18,8,-1,-1,13,8,18,8]],H:[22,[4,21,4,0,-1,-1,18,21,18,0,-1,-1,4,11,18,11]],I:[8,[4,21,4,0]],J:[16,[12,21,12,5,11,2,10,1,8,0,6,0,4,1,3,2,2,5,2,7]],K:[21,[4,21,4,0,-1,-1,18,21,4,7,-1,-1,9,12,18,0]],L:[17,[4,21,4,0,-1,-1,4,0,16,0]],M:[24,[4,21,4,0,-1,-1,4,21,12,0,-1,-1,20,21,12,0,-1,-1,20,21,20,0]],N:[22,[4,21,4,0,-1,-1,4,21,18,0,-1,-1,18,21,18,0]],O:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21]],P:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,10,4,10]],Q:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21,-1,-1,12,4,18,-2]],R:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,4,11,-1,-1,11,11,18,0]],S:[20,[17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3]],T:[16,[8,21,8,0,-1,-1,1,21,15,21]],U:[22,[4,21,4,6,5,3,7,1,10,0,12,0,15,1,17,3,18,6,18,21]],V:[18,[1,21,9,0,-1,-1,17,21,9,0]],W:[24,[2,21,7,0,-1,-1,12,21,7,0,-1,-1,12,21,17,0,-1,-1,22,21,17,0]],X:[20,[3,21,17,0,-1,-1,17,21,3,0]],Y:[18,[1,21,9,11,9,0,-1,-1,17,21,9,11]],Z:[20,[17,21,3,0,-1,-1,3,21,17,21,-1,-1,3,0,17,0]],"[":[14,[4,25,4,-7,-1,-1,5,25,5,-7,-1,-1,4,25,11,25,-1,-1,4,-7,11,-7]],"\\":[14,[0,21,14,-3]],"]":[14,[9,25,9,-7,-1,-1,10,25,10,-7,-1,-1,3,25,10,25,-1,-1,3,-7,10,-7]],"^":[16,[6,15,8,18,10,15,-1,-1,3,12,8,17,13,12,-1,-1,8,17,8,0]],_:[16,[0,-2,16,-2]],"`":[10,[6,21,5,20,4,18,4,16,5,15,6,16,5,17]],a:[19,[15,14,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],b:[19,[4,21,4,0,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],c:[18,[15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],d:[19,[15,21,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],e:[18,[3,8,15,8,15,10,14,12,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],f:[12,[10,21,8,21,6,20,5,17,5,0,-1,-1,2,14,9,14]],g:[19,[15,14,15,-2,14,-5,13,-6,11,-7,8,-7,6,-6,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],h:[19,[4,21,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],i:[8,[3,21,4,20,5,21,4,22,3,21,-1,-1,4,14,4,0]],j:[10,[5,21,6,20,7,21,6,22,5,21,-1,-1,6,14,6,-3,5,-6,3,-7,1,-7]],k:[17,[4,21,4,0,-1,-1,14,14,4,4,-1,-1,8,8,15,0]],l:[8,[4,21,4,0]],m:[30,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0,-1,-1,15,10,18,13,20,14,23,14,25,13,26,10,26,0]],n:[19,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],o:[19,[8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3,16,6,16,8,15,11,13,13,11,14,8,14]],p:[19,[4,14,4,-7,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],q:[19,[15,14,15,-7,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],r:[13,[4,14,4,0,-1,-1,4,8,5,11,7,13,9,14,12,14]],s:[17,[14,11,13,13,10,14,7,14,4,13,3,11,4,9,6,8,11,7,13,6,14,4,14,3,13,1,10,0,7,0,4,1,3,3]],t:[12,[5,21,5,4,6,1,8,0,10,0,-1,-1,2,14,9,14]],u:[19,[4,14,4,4,5,1,7,0,10,0,12,1,15,4,-1,-1,15,14,15,0]],v:[16,[2,14,8,0,-1,-1,14,14,8,0]],w:[22,[3,14,7,0,-1,-1,11,14,7,0,-1,-1,11,14,15,0,-1,-1,19,14,15,0]],x:[17,[3,14,14,0,-1,-1,14,14,3,0]],y:[16,[2,14,8,0,-1,-1,14,14,8,0,6,-4,4,-6,2,-7,1,-7]],z:[17,[14,14,3,0,-1,-1,3,14,14,14,-1,-1,3,0,14,0]],"{":[14,[9,25,7,24,6,23,5,21,5,19,6,17,7,16,8,14,8,12,6,10,-1,-1,7,24,6,22,6,20,7,18,8,17,9,15,9,13,8,11,4,9,8,7,9,5,9,3,8,1,7,0,6,-2,6,-4,7,-6,-1,-1,6,8,8,6,8,4,7,2,6,1,5,-1,5,-3,6,-5,7,-6,9,-7]],"|":[8,[4,25,4,-7]],"}":[14,[5,25,7,24,8,23,9,21,9,19,8,17,7,16,6,14,6,12,8,10,-1,-1,7,24,8,22,8,20,7,18,6,17,5,15,5,13,6,11,10,9,6,7,5,5,5,3,6,1,7,0,8,-2,8,-4,7,-6,-1,-1,8,8,6,6,6,4,7,2,8,1,9,-1,9,-3,8,-5,7,-6,5,-7]],"~":[24,[3,6,3,8,4,11,6,12,8,12,10,11,14,8,16,7,18,7,20,8,21,10,-1,-1,3,8,4,10,6,11,8,11,10,10,14,7,16,6,18,6,20,7,21,10,21,12]]},En={symbol:function(t,e,n,r){if("translucent"===t.renderPass){var i=t.context;i.setStencilMode(Ht.disabled),i.setColorMode(t.colorModeForRenderPass()),0!==n.paint.get("icon-opacity").constantOr(1)&&cn(t,e,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright")),0!==n.paint.get("text-opacity").constantOr(1)&&cn(t,e,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright")),e.map.showCollisionBoxes&&function(t,e,n,r){sn(t,e,n,r,!1),sn(t,e,n,r,!0)}(t,e,n,r)}},circle:function(t,e,n,r){if("translucent"===t.renderPass){var i=n.paint.get("circle-opacity"),a=n.paint.get("circle-stroke-width"),o=n.paint.get("circle-stroke-opacity");if(0!==i.constantOr(1)||0!==a.constantOr(1)&&0!==o.constantOr(1)){var s=t.context,l=s.gl;s.setDepthMode(t.depthModeForSublayer(0,Ut.ReadOnly)),s.setStencilMode(Ht.disabled),s.setColorMode(t.colorModeForRenderPass());for(var u=!0,c=0;c0?1-1/(1.001-i):-i),s.uniform1f(u.uniforms.u_contrast_factor,(a=n.paint.get("raster-contrast"))>0?1/(1-a):1+a),s.uniform3fv(u.uniforms.u_spin_weights,function(t){t*=Math.PI/180;var e=Math.sin(t),n=Math.cos(t);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}(n.paint.get("raster-hue-rotate"))),s.uniform1f(u.uniforms.u_buffer_scale,1),s.uniform1i(u.uniforms.u_image0,0),s.uniform1i(u.uniforms.u_image1,1);for(var c=r.length&&r[0].overscaledZ,f=0,p=r;fe.row){var n=t;t=e,e=n}return{x0:t.column,y0:t.row,x1:e.column,y1:e.row,dx:e.column-t.column,dy:e.row-t.row}}function Dn(t,e,n,r,i){var a=Math.max(n,Math.floor(e.y0)),o=Math.min(r,Math.ceil(e.y1));if(t.x0===e.x0&&t.y0===e.y0?t.x0+e.dy/t.dy*t.dx0,f=e.dx<0,p=a;pl.dy&&(o=s,s=l,l=o),s.dy>u.dy&&(o=s,s=u,u=o),l.dy>u.dy&&(o=l,l=u,u=o),s.dy&&Dn(u,s,r,i,a),l.dy&&Dn(u,l,r,i,a)}In.prototype.resize=function(t,e){var n=this.context.gl;if(this.width=t*a.devicePixelRatio,this.height=e*a.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(var r=0,i=this.style._order;r=0;this.currentLayer--){var y=r.style._layers[s[r.currentLayer]];y.source!==(m&&m.id)&&(g=[],(m=r.style.sourceCaches[y.source])&&(r.clearStencil(),g=m.getVisibleCoordinates(),m.getSource().isTileClipped&&r._renderTileClippingMasks(g))),r.renderLayer(r,m,y,g)}this.renderPass="translucent";var v,_=[];for(this.currentLayer=0,this.currentLayer;this.currentLayer0?e.pop():null},In.prototype._createProgramCached=function(t,e){this.cache=this.cache||{};var n=""+t+(e.cacheKey||"")+(this._showOverdrawInspector?"/overdraw":"");return this.cache[n]||(this.cache[n]=new an(this.context,rn[t],e,this._showOverdrawInspector)),this.cache[n]},In.prototype.useProgram=function(t,e){var n=this._createProgramCached(t,e||this.emptyProgramConfiguration);return this.context.program.set(n.program),n};var Rn=t.default$20.vec4,Fn=t.default$20.mat4,Bn=t.default$20.mat2,Nn=function(t,e,n){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=t||0,this._maxZoom=e||22,this.latRange=[-85.05113,85.05113],this.width=0,this.height=0,this._center=new Z(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._posMatrixCache={},this._alignedPosMatrixCache={}},jn={minZoom:{configurable:!0},maxZoom:{configurable:!0},renderWorldCopies:{configurable:!0},worldSize:{configurable:!0},centerPoint:{configurable:!0},size:{configurable:!0},bearing:{configurable:!0},pitch:{configurable:!0},fov:{configurable:!0},zoom:{configurable:!0},center:{configurable:!0},unmodified:{configurable:!0},x:{configurable:!0},y:{configurable:!0},point:{configurable:!0}};Nn.prototype.clone=function(){var t=new Nn(this._minZoom,this._maxZoom,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._calcMatrices(),t},jn.minZoom.get=function(){return this._minZoom},jn.minZoom.set=function(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},jn.maxZoom.get=function(){return this._maxZoom},jn.maxZoom.set=function(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},jn.renderWorldCopies.get=function(){return this._renderWorldCopies},jn.renderWorldCopies.set=function(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t},jn.worldSize.get=function(){return this.tileSize*this.scale},jn.centerPoint.get=function(){return this.size._div(2)},jn.size.get=function(){return new t.default$1(this.width,this.height)},jn.bearing.get=function(){return-this.angle/Math.PI*180},jn.bearing.set=function(e){var n=-t.wrap(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=Bn.create(),Bn.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},jn.pitch.get=function(){return this._pitch/Math.PI*180},jn.pitch.set=function(e){var n=t.clamp(e,0,60)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())},jn.fov.get=function(){return this._fov/Math.PI*180},jn.fov.set=function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())},jn.zoom.get=function(){return this._zoom},jn.zoom.set=function(t){var e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._constrain(),this._calcMatrices())},jn.center.get=function(){return this._center},jn.center.set=function(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())},Nn.prototype.coveringZoomLevel=function(t){return(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize))},Nn.prototype.getVisibleUnwrappedCoordinates=function(e){var n=this.pointCoordinate(new t.default$1(0,0),0),r=this.pointCoordinate(new t.default$1(this.width,0),0),i=Math.floor(n.column),a=Math.floor(r.column),o=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies)for(var s=i;s<=a;s++)0!==s&&o.push(new t.UnwrappedTileID(s,e));return o},Nn.prototype.coveringTiles=function(e){var n=this.coveringZoomLevel(e),r=n;if(void 0!==e.minzoom&&ne.maxzoom&&(n=e.maxzoom);var i=this.pointCoordinate(this.centerPoint,n),a=new t.default$1(i.column-.5,i.row-.5);return function(e,n,r,i){void 0===i&&(i=!0);var a=1<=0&&l<=a)for(u=n;uo&&(i=o-m)}if(this.lngRange){var g=this.x,y=u.x/2;g-yl&&(r=l-y)}void 0===r&&void 0===i||(this.center=this.unproject(new t.default$1(void 0!==r?r:this.x,void 0!==i?i:this.y))),this._unmodified=c,this._constraining=!1}},Nn.prototype._calcMatrices=function(){if(this.height){this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height;var t=this._fov/2,e=Math.PI/2+this._pitch,n=Math.sin(t)*this.cameraToCenterDistance/Math.sin(Math.PI-e-t),r=this.x,i=this.y,a=1.01*(Math.cos(Math.PI/2-this._pitch)*n+this.cameraToCenterDistance),o=new Float64Array(16);Fn.perspective(o,this._fov,this.width/this.height,1,a),Fn.scale(o,o,[1,-1,1]),Fn.translate(o,o,[0,0,-this.cameraToCenterDistance]),Fn.rotateX(o,o,this._pitch),Fn.rotateZ(o,o,this.angle),Fn.translate(o,o,[-r,-i,0]);var s=this.worldSize/(2*Math.PI*6378137*Math.abs(Math.cos(this.center.lat*(Math.PI/180))));Fn.scale(o,o,[1,1,s,1]),this.projMatrix=o;var l=this.width%2/2,u=this.height%2/2,c=Math.cos(this.angle),f=Math.sin(this.angle),p=r-Math.round(r)+c*l+f*u,h=i-Math.round(i)+c*u+f*l,d=new Float64Array(o);if(Fn.translate(d,d,[p>.5?p-1:p,h>.5?h-1:h,0]),this.alignedProjMatrix=d,o=Fn.create(),Fn.scale(o,o,[this.width/2,-this.height/2,1]),Fn.translate(o,o,[1,-1,0]),this.pixelMatrix=Fn.multiply(new Float64Array(16),o,this.projMatrix),!(o=Fn.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={}}},Nn.prototype.maxPitchScaleFactor=function(){if(!this.pixelMatrixInverse)return 1;var e=this.pointCoordinate(new t.default$1(0,0)).zoomTo(this.zoom),n=[e.column*this.tileSize,e.row*this.tileSize,0,1];return Rn.transformMat4(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance},Object.defineProperties(Nn.prototype,jn);var Vn=function(){var e,n,r,i;t.bindAll(["_onHashChange","_updateHash"],this),this._updateHash=(e=this._updateHashUnthrottled.bind(this),300,n=!1,r=0,i=function(){r=0,n&&(e(),r=setTimeout(i,300),n=!1)},function(){return n=!0,r||i(),r})};Vn.prototype.addTo=function(e){return this._map=e,t.default.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this},Vn.prototype.remove=function(){return t.default.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this},Vn.prototype.getHashString=function(t){var e=this._map.getCenter(),n=Math.round(100*this._map.getZoom())/100,r=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.pow(10,r),a=Math.round(e.lng*i)/i,o=Math.round(e.lat*i)/i,s=this._map.getBearing(),l=this._map.getPitch(),u="";return u+=t?"#/"+a+"/"+o+"/"+n:"#"+n+"/"+o+"/"+a,(s||l)&&(u+="/"+Math.round(10*s)/10),l&&(u+="/"+Math.round(l)),u},Vn.prototype._onHashChange=function(){var e=t.default.location.hash.replace("#","").split("/");return e.length>=3&&(this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:+(e[3]||0),pitch:+(e[4]||0)}),!0)},Vn.prototype._updateHashUnthrottled=function(){var e=this.getHashString();t.default.history.replaceState(t.default.history.state,"",e)};var qn=function(e){function n(n,r,i,a){void 0===a&&(a={});var o=s.mousePos(r.getCanvasContainer(),i),l=r.unproject(o);e.call(this,n,t.extend({point:o,lngLat:l,originalEvent:i},a)),this._defaultPrevented=!1,this.target=r}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var r={defaultPrevented:{configurable:!0}};return n.prototype.preventDefault=function(){this._defaultPrevented=!0},r.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(n.prototype,r),n}(t.Event),Un=function(e){function n(n,r,i){var a=s.touchPos(r.getCanvasContainer(),i),o=a.map(function(t){return r.unproject(t)}),l=a.reduce(function(t,e,n,r){return t.add(e.div(r.length))},new t.default$1(0,0)),u=r.unproject(l);e.call(this,n,{points:a,point:l,lngLats:o,lngLat:u,originalEvent:i}),this._defaultPrevented=!1}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var r={defaultPrevented:{configurable:!0}};return n.prototype.preventDefault=function(){this._defaultPrevented=!0},r.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(n.prototype,r),n}(t.Event),Hn=function(t){function e(e,n,r){t.call(this,e,{originalEvent:r}),this._defaultPrevented=!1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={defaultPrevented:{configurable:!0}};return e.prototype.preventDefault=function(){this._defaultPrevented=!0},n.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(e.prototype,n),e}(t.Event),Zn=function(e){this._map=e,this._el=e.getCanvasContainer(),this._delta=0,t.bindAll(["_onWheel","_onTimeout","_onScrollFrame","_onScrollFinished"],this)};Zn.prototype.isEnabled=function(){return!!this._enabled},Zn.prototype.isActive=function(){return!!this._active},Zn.prototype.enable=function(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)},Zn.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Zn.prototype.onWheel=function(e){if(this.isEnabled()){var n=e.deltaMode===t.default.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,r=a.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%4.000244140625==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this.isActive()||this._start(e)),e.preventDefault()}},Zn.prototype._onTimeout=function(t){this._type="wheel",this._delta-=this._lastValue,this.isActive()||this._start(t)},Zn.prototype._start=function(e){if(this._delta){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),this._active=!0,this._map.fire(new t.Event("movestart",{originalEvent:e})),this._map.fire(new t.Event("zoomstart",{originalEvent:e})),this._finishTimeout&&clearTimeout(this._finishTimeout);var n=s.mousePos(this._el,e);this._around=Z.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(n)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame))}},Zn.prototype._onScrollFrame=function(){var e=this;if(this._frameId=null,this.isActive()){var n=this._map.transform;if(0!==this._delta){var r="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?1/450:.01,i=2/(1+Math.exp(-Math.abs(this._delta*r)));this._delta<0&&0!==i&&(i=1/i);var o="number"==typeof this._targetZoom?n.zoomScale(this._targetZoom):n.scale;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(o*i))),"wheel"===this._type&&(this._startZoom=n.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}var s=!1;if("wheel"===this._type){var l=Math.min((a.now()-this._lastWheelEventTime)/200,1),u=this._easing(l);n.zoom=t.number(this._startZoom,this._targetZoom,u),l<1?this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame)):s=!0}else n.zoom=this._targetZoom,s=!0;n.setLocationAtPoint(this._around,this._aroundPoint),this._map.fire(new t.Event("move",{originalEvent:this._lastWheelEvent})),this._map.fire(new t.Event("zoom",{originalEvent:this._lastWheelEvent})),s&&(this._active=!1,this._finishTimeout=setTimeout(function(){e._map.fire(new t.Event("zoomend",{originalEvent:e._lastWheelEvent})),e._map.fire(new t.Event("moveend",{originalEvent:e._lastWheelEvent})),delete e._targetZoom},200))}},Zn.prototype._smoothOutEasing=function(e){var n=t.ease;if(this._prevEase){var r=this._prevEase,i=(a.now()-r.start)/r.duration,o=r.easing(i+.01)-r.easing(i),s=.27/Math.sqrt(o*o+1e-4)*.01,l=Math.sqrt(.0729-s*s);n=t.bezier(s,l,.25,1)}return this._prevEase={start:a.now(),duration:e,easing:n},n};var Gn=function(e){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),t.bindAll(["_onMouseMove","_onMouseUp","_onKeyDown"],this)};Gn.prototype.isEnabled=function(){return!!this._enabled},Gn.prototype.isActive=function(){return!!this._active},Gn.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Gn.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Gn.prototype.onMouseDown=function(e){this.isEnabled()&&e.shiftKey&&0===e.button&&(t.default.document.addEventListener("mousemove",this._onMouseMove,!1),t.default.document.addEventListener("keydown",this._onKeyDown,!1),t.default.document.addEventListener("mouseup",this._onMouseUp,!1),s.disableDrag(),this._startPos=s.mousePos(this._el,e),this._active=!0)},Gn.prototype._onMouseMove=function(t){var e=this._startPos,n=s.mousePos(this._el,t);this._box||(this._box=s.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));var r=Math.min(e.x,n.x),i=Math.max(e.x,n.x),a=Math.min(e.y,n.y),o=Math.max(e.y,n.y);s.setTransform(this._box,"translate("+r+"px,"+a+"px)"),this._box.style.width=i-r+"px",this._box.style.height=o-a+"px"},Gn.prototype._onMouseUp=function(e){if(0===e.button){var n=this._startPos,r=s.mousePos(this._el,e),i=(new G).extend(this._map.unproject(n)).extend(this._map.unproject(r));this._finish(),s.suppressClick(),n.x===r.x&&n.y===r.y?this._fireEvent("boxzoomcancel",e):this._map.fitBounds(i,{linear:!0}).fire(new t.Event("boxzoomend",{originalEvent:e,boxZoomBounds:i}))}},Gn.prototype._onKeyDown=function(t){27===t.keyCode&&(this._finish(),this._fireEvent("boxzoomcancel",t))},Gn.prototype._finish=function(){this._active=!1,t.default.document.removeEventListener("mousemove",this._onMouseMove,!1),t.default.document.removeEventListener("keydown",this._onKeyDown,!1),t.default.document.removeEventListener("mouseup",this._onMouseUp,!1),this._container.classList.remove("mapboxgl-crosshair"),this._box&&(s.remove(this._box),this._box=null),s.enableDrag()},Gn.prototype._fireEvent=function(e,n){return this._map.fire(new t.Event(e,{originalEvent:n}))};var $n=t.bezier(0,0,.25,1),Wn=function(e,n){this._map=e,this._el=n.element||e.getCanvasContainer(),this._state="disabled",this._button=n.button||"right",this._bearingSnap=n.bearingSnap||0,this._pitchWithRotate=!1!==n.pitchWithRotate,t.bindAll(["_onMouseMove","_onMouseUp","_onBlur","_onDragFrame"],this)};Wn.prototype.isEnabled=function(){return"disabled"!==this._state},Wn.prototype.isActive=function(){return"active"===this._state},Wn.prototype.enable=function(){this.isEnabled()||(this._state="enabled")},Wn.prototype.disable=function(){if(this.isEnabled())switch(this._state){case"active":this._state="disabled",this._unbind(),this._deactivate(),this._fireEvent("rotateend"),this._pitchWithRotate&&this._fireEvent("pitchend"),this._fireEvent("moveend");break;case"pending":this._state="disabled",this._unbind();break;default:this._state="disabled"}},Wn.prototype.onMouseDown=function(e){if("enabled"===this._state){if("right"===this._button){if(this._eventButton=s.mouseButton(e),this._eventButton!==(e.ctrlKey?0:2))return}else{if(e.ctrlKey||0!==s.mouseButton(e))return;this._eventButton=0}s.disableDrag(),t.default.document.addEventListener("mousemove",this._onMouseMove,{capture:!0}),t.default.document.addEventListener("mouseup",this._onMouseUp),t.default.addEventListener("blur",this._onBlur),this._state="pending",this._inertia=[[a.now(),this._map.getBearing()]],this._previousPos=s.mousePos(this._el,e),this._center=this._map.transform.centerPoint,e.preventDefault()}},Wn.prototype._onMouseMove=function(t){this._lastMoveEvent=t,this._pos=s.mousePos(this._el,t),"pending"===this._state&&(this._state="active",this._fireEvent("rotatestart",t),this._fireEvent("movestart",t),this._pitchWithRotate&&this._fireEvent("pitchstart",t)),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onDragFrame))},Wn.prototype._onDragFrame=function(){this._frameId=null;var t=this._lastMoveEvent;if(t){var e=this._map.transform,n=this._previousPos,r=this._pos,i=.8*(n.x-r.x),o=-.5*(n.y-r.y),s=e.bearing-i,l=e.pitch-o,u=this._inertia,c=u[u.length-1];this._drainInertiaBuffer(),u.push([a.now(),this._map._normalizeBearing(s,c[1])]),e.bearing=s,this._pitchWithRotate&&(this._fireEvent("pitch",t),e.pitch=l),this._fireEvent("rotate",t),this._fireEvent("move",t),delete this._lastMoveEvent,this._previousPos=this._pos}},Wn.prototype._onMouseUp=function(t){if(s.mouseButton(t)===this._eventButton)switch(this._state){case"active":this._state="enabled",s.suppressClick(),this._unbind(),this._deactivate(),this._inertialRotate(t);break;case"pending":this._state="enabled",this._unbind()}},Wn.prototype._onBlur=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._fireEvent("rotateend",t),this._pitchWithRotate&&this._fireEvent("pitchend",t),this._fireEvent("moveend",t);break;case"pending":this._state="enabled",this._unbind()}},Wn.prototype._unbind=function(){t.default.document.removeEventListener("mousemove",this._onMouseMove,{capture:!0}),t.default.document.removeEventListener("mouseup",this._onMouseUp),t.default.removeEventListener("blur",this._onBlur),s.enableDrag()},Wn.prototype._deactivate=function(){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._lastMoveEvent,delete this._previousPos},Wn.prototype._inertialRotate=function(t){var e=this;this._fireEvent("rotateend",t),this._drainInertiaBuffer();var n=this._map,r=n.getBearing(),i=this._inertia,a=function(){Math.abs(r)180&&(h=180);var d=h/180;u+=f*h*(d/2),Math.abs(n._normalizeBearing(u,0))0&&e-t[0][0]>160;)t.shift()};var Xn=t.bezier(0,0,.3,1),Yn=function(e){this._map=e,this._el=e.getCanvasContainer(),this._state="disabled",t.bindAll(["_onMove","_onMouseUp","_onTouchEnd","_onBlur","_onDragFrame"],this)};Yn.prototype.isEnabled=function(){return"disabled"!==this._state},Yn.prototype.isActive=function(){return"active"===this._state},Yn.prototype.enable=function(){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-drag-pan"),this._state="enabled")},Yn.prototype.disable=function(){if(this.isEnabled())switch(this._el.classList.remove("mapboxgl-touch-drag-pan"),this._state){case"active":this._state="disabled",this._unbind(),this._deactivate(),this._fireEvent("dragend"),this._fireEvent("moveend");break;case"pending":this._state="disabled",this._unbind();break;default:this._state="disabled"}},Yn.prototype.onMouseDown=function(e){"enabled"===this._state&&(e.ctrlKey||0!==s.mouseButton(e)||(s.addEventListener(t.default.document,"mousemove",this._onMove,{capture:!0}),s.addEventListener(t.default.document,"mouseup",this._onMouseUp),this._start(e)))},Yn.prototype.onTouchStart=function(e){"enabled"===this._state&&(e.touches.length>1||(s.addEventListener(t.default.document,"touchmove",this._onMove,{capture:!0,passive:!1}),s.addEventListener(t.default.document,"touchend",this._onTouchEnd),this._start(e)))},Yn.prototype._start=function(e){t.default.addEventListener("blur",this._onBlur),this._state="pending",this._previousPos=s.mousePos(this._el,e),this._inertia=[[a.now(),this._previousPos]]},Yn.prototype._onMove=function(t){this._lastMoveEvent=t,t.preventDefault(),this._pos=s.mousePos(this._el,t),this._drainInertiaBuffer(),this._inertia.push([a.now(),this._pos]),"pending"===this._state&&(this._state="active",this._fireEvent("dragstart",t),this._fireEvent("movestart",t)),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onDragFrame))},Yn.prototype._onDragFrame=function(){this._frameId=null;var t=this._lastMoveEvent;if(t){var e=this._map.transform;e.setLocationAtPoint(e.pointLocation(this._previousPos),this._pos),this._fireEvent("drag",t),this._fireEvent("move",t),this._previousPos=this._pos,delete this._lastMoveEvent}},Yn.prototype._onMouseUp=function(t){if(0===s.mouseButton(t))switch(this._state){case"active":this._state="enabled",s.suppressClick(),this._unbind(),this._deactivate(),this._inertialPan(t);break;case"pending":this._state="enabled",this._unbind()}},Yn.prototype._onTouchEnd=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._inertialPan(t);break;case"pending":this._state="enabled",this._unbind()}},Yn.prototype._onBlur=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._fireEvent("dragend",t),this._fireEvent("moveend",t);break;case"pending":this._state="enabled",this._unbind()}},Yn.prototype._unbind=function(){s.removeEventListener(t.default.document,"touchmove",this._onMove,{capture:!0,passive:!1}),s.removeEventListener(t.default.document,"touchend",this._onTouchEnd),s.removeEventListener(t.default.document,"mousemove",this._onMove,{capture:!0}),s.removeEventListener(t.default.document,"mouseup",this._onMouseUp),s.removeEventListener(t.default,"blur",this._onBlur)},Yn.prototype._deactivate=function(){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._lastMoveEvent,delete this._previousPos,delete this._pos},Yn.prototype._inertialPan=function(t){this._fireEvent("dragend",t),this._drainInertiaBuffer();var e=this._inertia;if(e.length<2)this._fireEvent("moveend",t);else{var n=e[e.length-1],r=e[0],i=n[1].sub(r[1]),a=(n[0]-r[0])/1e3;if(0===a||n[1].equals(r[1]))this._fireEvent("moveend",t);else{var o=i.mult(.3/a),s=o.mag();s>1400&&(s=1400,o._unit()._mult(s));var l=s/750,u=o.mult(-l/2);this._map.panBy(u,{duration:1e3*l,easing:Xn,noMoveStart:!0},{originalEvent:t})}}},Yn.prototype._fireEvent=function(e,n){return this._map.fire(new t.Event(e,n?{originalEvent:n}:{}))},Yn.prototype._drainInertiaBuffer=function(){for(var t=this._inertia,e=a.now();t.length>0&&e-t[0][0]>160;)t.shift()};var Jn=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onKeyDown"],this)};function Kn(t){return t*(2-t)}Jn.prototype.isEnabled=function(){return!!this._enabled},Jn.prototype.enable=function(){this.isEnabled()||(this._el.addEventListener("keydown",this._onKeyDown,!1),this._enabled=!0)},Jn.prototype.disable=function(){this.isEnabled()&&(this._el.removeEventListener("keydown",this._onKeyDown),this._enabled=!1)},Jn.prototype._onKeyDown=function(t){if(!(t.altKey||t.ctrlKey||t.metaKey)){var e=0,n=0,r=0,i=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?n=-1:(t.preventDefault(),i=-1);break;case 39:t.shiftKey?n=1:(t.preventDefault(),i=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?r=-1:(a=1,t.preventDefault());break;default:return}var o=this._map,s=o.getZoom(),l={duration:300,delayEndEvents:500,easing:Kn,zoom:e?Math.round(s)+e*(t.shiftKey?2:1):s,bearing:o.getBearing()+15*n,pitch:o.getPitch()+10*r,offset:[100*-i,100*-a],center:o.getCenter()};o.easeTo(l,{originalEvent:t})}};var Qn=function(e){this._map=e,t.bindAll(["_onDblClick","_onZoomEnd"],this)};Qn.prototype.isEnabled=function(){return!!this._enabled},Qn.prototype.isActive=function(){return!!this._active},Qn.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Qn.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Qn.prototype.onTouchStart=function(t){var e=this;this.isEnabled()&&(t.points.length>1||(this._tapped?(clearTimeout(this._tapped),this._tapped=null,this._zoom(t)):this._tapped=setTimeout(function(){e._tapped=null},300)))},Qn.prototype.onDblClick=function(t){this.isEnabled()&&(t.originalEvent.preventDefault(),this._zoom(t))},Qn.prototype._zoom=function(t){this._active=!0,this._map.on("zoomend",this._onZoomEnd),this._map.zoomTo(this._map.getZoom()+(t.originalEvent.shiftKey?-1:1),{around:t.lngLat},t)},Qn.prototype._onZoomEnd=function(){this._active=!1,this._map.off("zoomend",this._onZoomEnd)};var tr=t.bezier(0,0,.15,1),er=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onMove","_onEnd","_onTouchFrame"],this)};er.prototype.isEnabled=function(){return!!this._enabled},er.prototype.enable=function(t){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-zoom-rotate"),this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)},er.prototype.disable=function(){this.isEnabled()&&(this._el.classList.remove("mapboxgl-touch-zoom-rotate"),this._enabled=!1)},er.prototype.disableRotation=function(){this._rotationDisabled=!0},er.prototype.enableRotation=function(){this._rotationDisabled=!1},er.prototype.onStart=function(e){if(this.isEnabled()&&2===e.touches.length){var n=s.mousePos(this._el,e.touches[0]),r=s.mousePos(this._el,e.touches[1]);this._startVec=n.sub(r),this._gestureIntent=void 0,this._inertia=[],s.addEventListener(t.default.document,"touchmove",this._onMove,{passive:!1}),s.addEventListener(t.default.document,"touchend",this._onEnd)}},er.prototype._getTouchEventData=function(t){var e=s.mousePos(this._el,t.touches[0]),n=s.mousePos(this._el,t.touches[1]),r=e.sub(n);return{vec:r,center:e.add(n).div(2),scale:r.mag()/this._startVec.mag(),bearing:this._rotationDisabled?0:180*r.angleWith(this._startVec)/Math.PI}},er.prototype._onMove=function(e){if(2===e.touches.length){var n=this._getTouchEventData(e),r=n.vec,i=n.scale,a=n.bearing;if(!this._gestureIntent){var o=Math.abs(1-i)>.15;Math.abs(a)>10?this._gestureIntent="rotate":o&&(this._gestureIntent="zoom"),this._gestureIntent&&(this._map.fire(new t.Event(this._gestureIntent+"start",{originalEvent:e})),this._map.fire(new t.Event("movestart",{originalEvent:e})),this._startVec=r)}this._lastTouchEvent=e,this._frameId||(this._frameId=this._map._requestRenderFrame(this._onTouchFrame)),e.preventDefault()}},er.prototype._onTouchFrame=function(){this._frameId=null;var e=this._gestureIntent;if(e){var n=this._map.transform;this._startScale||(this._startScale=n.scale,this._startBearing=n.bearing);var r=this._getTouchEventData(this._lastTouchEvent),i=r.center,o=r.bearing,s=r.scale,l=n.pointLocation(i),u=n.locationPoint(l);"rotate"===e&&(n.bearing=this._startBearing+o),n.zoom=n.scaleZoom(this._startScale*s),n.setLocationAtPoint(l,u),this._map.fire(new t.Event(e,{originalEvent:this._lastTouchEvent})),this._map.fire(new t.Event("move",{originalEvent:this._lastTouchEvent})),this._drainInertiaBuffer(),this._inertia.push([a.now(),s,i])}},er.prototype._onEnd=function(e){s.removeEventListener(t.default.document,"touchmove",this._onMove,{passive:!1}),s.removeEventListener(t.default.document,"touchend",this._onEnd);var n=this._gestureIntent,r=this._startScale;if(this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._gestureIntent,delete this._startScale,delete this._startBearing,delete this._lastTouchEvent,n){this._map.fire(new t.Event(n+"end",{originalEvent:e})),this._drainInertiaBuffer();var i=this._inertia,a=this._map;if(i.length<2)a.snapToNorth({},{originalEvent:e});else{var o=i[i.length-1],l=i[0],u=a.transform.scaleZoom(r*o[1]),c=a.transform.scaleZoom(r*l[1]),f=u-c,p=(o[0]-l[0])/1e3,h=o[2];if(0!==p&&u!==c){var d=.15*f/p;Math.abs(d)>2.5&&(d=d>0?2.5:-2.5);var m=1e3*Math.abs(d/(12*.15)),g=u+d*m/2e3;g<0&&(g=0),a.easeTo({zoom:g,duration:m,easing:tr,around:this._aroundCenter?a.getCenter():a.unproject(h),noMoveStart:!0},{originalEvent:e})}else a.snapToNorth({},{originalEvent:e})}}},er.prototype._drainInertiaBuffer=function(){for(var t=this._inertia,e=a.now();t.length>2&&e-t[0][0]>160;)t.shift()};var nr={scrollZoom:Zn,boxZoom:Gn,dragRotate:Wn,dragPan:Yn,keyboard:Jn,doubleClickZoom:Qn,touchZoomRotate:er},rr=function(e){function n(n,r){e.call(this),this._moving=!1,this._zooming=!1,this.transform=n,this._bearingSnap=r.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.getCenter=function(){return this.transform.center},n.prototype.setCenter=function(t,e){return this.jumpTo({center:t},e)},n.prototype.panBy=function(e,n,r){return e=t.default$1.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},n),r)},n.prototype.panTo=function(e,n,r){return this.easeTo(t.extend({center:e},n),r)},n.prototype.getZoom=function(){return this.transform.zoom},n.prototype.setZoom=function(t,e){return this.jumpTo({zoom:t},e),this},n.prototype.zoomTo=function(e,n,r){return this.easeTo(t.extend({zoom:e},n),r)},n.prototype.zoomIn=function(t,e){return this.zoomTo(this.getZoom()+1,t,e),this},n.prototype.zoomOut=function(t,e){return this.zoomTo(this.getZoom()-1,t,e),this},n.prototype.getBearing=function(){return this.transform.bearing},n.prototype.setBearing=function(t,e){return this.jumpTo({bearing:t},e),this},n.prototype.rotateTo=function(e,n,r){return this.easeTo(t.extend({bearing:e},n),r)},n.prototype.resetNorth=function(e,n){return this.rotateTo(0,t.extend({duration:1e3},e),n),this},n.prototype.snapToNorth=function(t,e){return Math.abs(this.getBearing())e?1:0}),["bottom","left","right","top"]))return t.warnOnce("options.padding must be a positive number, or an Object with keys 'bottom', 'left', 'right', 'top'"),this;e=G.convert(e);var a=[(n.padding.left-n.padding.right)/2,(n.padding.top-n.padding.bottom)/2],o=Math.min(n.padding.right,n.padding.left),s=Math.min(n.padding.top,n.padding.bottom);n.offset=[n.offset[0]+a[0],n.offset[1]+a[1]];var l=t.default$1.convert(n.offset),u=this.transform,c=u.project(e.getNorthWest()),f=u.project(e.getSouthEast()),p=f.sub(c),h=(u.width-2*o-2*Math.abs(l.x))/p.x,d=(u.height-2*s-2*Math.abs(l.y))/p.y;return d<0||h<0?(t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset."),this):(n.center=u.unproject(c.add(f).div(2)),n.zoom=Math.min(u.scaleZoom(u.scale*Math.min(h,d)),n.maxZoom),n.bearing=0,n.linear?this.easeTo(n,r):this.flyTo(n,r))},n.prototype.jumpTo=function(e,n){this.stop();var r=this.transform,i=!1,a=!1,o=!1;return"zoom"in e&&r.zoom!==+e.zoom&&(i=!0,r.zoom=+e.zoom),void 0!==e.center&&(r.center=Z.convert(e.center)),"bearing"in e&&r.bearing!==+e.bearing&&(a=!0,r.bearing=+e.bearing),"pitch"in e&&r.pitch!==+e.pitch&&(o=!0,r.pitch=+e.pitch),this.fire(new t.Event("movestart",n)).fire(new t.Event("move",n)),i&&this.fire(new t.Event("zoomstart",n)).fire(new t.Event("zoom",n)).fire(new t.Event("zoomend",n)),a&&this.fire(new t.Event("rotatestart",n)).fire(new t.Event("rotate",n)).fire(new t.Event("rotateend",n)),o&&this.fire(new t.Event("pitchstart",n)).fire(new t.Event("pitch",n)).fire(new t.Event("pitchend",n)),this.fire(new t.Event("moveend",n))},n.prototype.easeTo=function(e,n){var r=this;this.stop(),!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate&&(e.duration=0);var i=this.transform,a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l="zoom"in e?+e.zoom:a,u="bearing"in e?this._normalizeBearing(e.bearing,o):o,c="pitch"in e?+e.pitch:s,f=i.centerPoint.add(t.default$1.convert(e.offset)),p=i.pointLocation(f),h=Z.convert(e.center||p);this._normalizeCenter(h);var d,m,g=i.project(p),y=i.project(h).sub(g),v=i.zoomScale(l-a);return e.around&&(d=Z.convert(e.around),m=i.locationPoint(d)),this._zooming=l!==a,this._rotating=o!==u,this._pitching=c!==s,this._prepareEase(n,e.noMoveStart),clearTimeout(this._easeEndTimeoutID),this._ease(function(e){if(r._zooming&&(i.zoom=t.number(a,l,e)),r._rotating&&(i.bearing=t.number(o,u,e)),r._pitching&&(i.pitch=t.number(s,c,e)),d)i.setLocationAtPoint(d,m);else{var p=i.zoomScale(i.zoom-a),h=l>a?Math.min(2,v):Math.max(.5,v),_=Math.pow(h,1-e),x=i.unproject(g.add(y.mult(e*_)).mult(p));i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,f)}r._fireMoveEvents(n)},function(){e.delayEndEvents?r._easeEndTimeoutID=setTimeout(function(){return r._afterEase(n)},e.delayEndEvents):r._afterEase(n)},e),this},n.prototype._prepareEase=function(e,n){this._moving=!0,n||this.fire(new t.Event("movestart",e)),this._zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&this.fire(new t.Event("pitchstart",e))},n.prototype._fireMoveEvents=function(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))},n.prototype._afterEase=function(e){var n=this._zooming,r=this._rotating,i=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,n&&this.fire(new t.Event("zoomend",e)),r&&this.fire(new t.Event("rotateend",e)),i&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))},n.prototype.flyTo=function(e,n){var r=this;this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);var i=this.transform,a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l="zoom"in e?t.clamp(+e.zoom,i.minZoom,i.maxZoom):a,u="bearing"in e?this._normalizeBearing(e.bearing,o):o,c="pitch"in e?+e.pitch:s,f=i.zoomScale(l-a),p=i.centerPoint.add(t.default$1.convert(e.offset)),h=i.pointLocation(p),d=Z.convert(e.center||h);this._normalizeCenter(d);var m=i.project(h),g=i.project(d).sub(m),y=e.curve,v=Math.max(i.width,i.height),_=v/f,x=g.mag();if("minZoom"in e){var b=t.clamp(Math.min(e.minZoom,a,l),i.minZoom,i.maxZoom),w=v/i.zoomScale(b-a);y=Math.sqrt(w/x*2)}var k=y*y;function T(t){var e=(_*_-v*v+(t?-1:1)*k*k*x*x)/(2*(t?_:v)*k*x);return Math.log(Math.sqrt(e*e+1)-e)}function A(t){return(Math.exp(t)-Math.exp(-t))/2}function M(t){return(Math.exp(t)+Math.exp(-t))/2}var S=T(0),C=function(t){return M(S)/M(S+y*t)},z=function(t){return v*((M(S)*(A(e=S+y*t)/M(e))-A(S))/k)/x;var e},L=(T(1)-S)/y;if(Math.abs(x)<1e-6||!isFinite(L)){if(Math.abs(v-_)<1e-6)return this.easeTo(e,n);var E=_e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==u,this._pitching=c!==s,this._prepareEase(n,!1),this._ease(function(e){var l=e*L,f=1/C(l);i.zoom=a+i.scaleZoom(f),r._rotating&&(i.bearing=t.number(o,u,e)),r._pitching&&(i.pitch=t.number(s,c,e));var h=i.unproject(m.add(g.mult(z(l))).mult(f));i.setLocationAtPoint(i.renderWorldCopies?h.wrap():h,p),r._fireMoveEvents(n)},function(){return r._afterEase(n)},e),this},n.prototype.isEasing=function(){return!!this._easeFrameId},n.prototype.stop=function(){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){var t=this._onEaseEnd;delete this._onEaseEnd,t.call(this)}return this},n.prototype._ease=function(t,e,n){!1===n.animate||0===n.duration?(t(1),e()):(this._easeStart=a.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))},n.prototype._renderFrameCallback=function(){var t=Math.min((a.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},n.prototype._normalizeBearing=function(e,n){e=t.wrap(e,-180,180);var r=Math.abs(e-n);return Math.abs(e-360-n)180?-360:n<-180?360:0}},n}(t.Evented),ir=function(e){void 0===e&&(e={}),this.options=e,t.bindAll(["_updateEditLink","_updateData","_updateCompact"],this)};ir.prototype.getDefaultPosition=function(){return"bottom-right"},ir.prototype.onAdd=function(t){var e=this.options&&this.options.compact;return this._map=t,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),e&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container},ir.prototype.onRemove=function(){s.remove(this._container),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0},ir.prototype._updateEditLink=function(){var t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));var e=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:g.ACCESS_TOKEN}];if(t){var n=e.reduce(function(t,n,r){return n.value&&(t+=n.key+"="+n.value+(r=0)return!1;return!0})).length?(this._container.innerHTML=t.join(" | "),this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null}},ir.prototype._updateCompact=function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact")};var ar=function(){t.bindAll(["_updateLogo"],this)};ar.prototype.onAdd=function(t){this._map=t,this._container=s.create("div","mapboxgl-ctrl");var e=s.create("a","mapboxgl-ctrl-logo");return e.target="_blank",e.href="https://www.mapbox.com/",e.setAttribute("aria-label","Mapbox logo"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._container},ar.prototype.onRemove=function(){s.remove(this._container),this._map.off("sourcedata",this._updateLogo)},ar.prototype.getDefaultPosition=function(){return"bottom-left"},ar.prototype._updateLogo=function(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")},ar.prototype._logoRequired=function(){if(this._map.style){var t=this._map.style.sourceCaches;for(var e in t)if(t[e].getSource().mapbox_logo)return!0;return!1}};var or=function(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1};or.prototype.add=function(t){var e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e},or.prototype.remove=function(t){for(var e=this._currentlyRunning,n=0,r=e?this._queue.concat(e):this._queue;ne.maxZoom)throw new Error("maxZoom must be greater than minZoom");var r=new Nn(e.minZoom,e.maxZoom,e.renderWorldCopies);n.call(this,r,e),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new or;var i=e.transformRequest;if(this._transformRequest=i?function(t,e){return i(t,e)||{url:t}}:function(t){return{url:t}},"string"==typeof e.container){var a=t.default.document.getElementById(e.container);if(!a)throw new Error("Container '"+e.container+"' not found.");this._container=a}else{if(!(e.container instanceof lr))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_contextLost","_contextRestored","_update","_render","_onData","_onDataLoading"],this),this._setupContainer(),this._setupPainter(),this.on("move",this._update.bind(this,!1)),this.on("zoom",this._update.bind(this,!0)),void 0!==t.default&&(t.default.addEventListener("online",this._onWindowOnline,!1),t.default.addEventListener("resize",this._onWindowResize,!1)),function(t,e){var n=t.getCanvasContainer(),r=null,i=!1;for(var a in nr)t[a]=new nr[a](t,e),e.interactive&&e[a]&&t[a].enable(e[a]);s.addEventListener(n,"mouseout",function(e){t.fire(new qn("mouseout",t,e))}),s.addEventListener(n,"mousedown",function(n){i=!0;var r=new qn("mousedown",t,n);t.fire(r),r.defaultPrevented||(e.interactive&&!t.doubleClickZoom.isActive()&&t.stop(),t.boxZoom.onMouseDown(n),t.boxZoom.isActive()||t.dragPan.isActive()||t.dragRotate.onMouseDown(n),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onMouseDown(n))}),s.addEventListener(n,"mouseup",function(e){var n=t.dragRotate.isActive();r&&!n&&t.fire(new qn("contextmenu",t,r)),r=null,i=!1,t.fire(new qn("mouseup",t,e))}),s.addEventListener(n,"mousemove",function(e){if(!t.dragPan.isActive()&&!t.dragRotate.isActive()){for(var r=e.toElement||e.target;r&&r!==n;)r=r.parentNode;r===n&&t.fire(new qn("mousemove",t,e))}}),s.addEventListener(n,"mouseover",function(e){for(var r=e.toElement||e.target;r&&r!==n;)r=r.parentNode;r===n&&t.fire(new qn("mouseover",t,e))}),s.addEventListener(n,"touchstart",function(n){var r=new Un("touchstart",t,n);t.fire(r),r.defaultPrevented||(e.interactive&&t.stop(),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onTouchStart(n),t.touchZoomRotate.onStart(n),t.doubleClickZoom.onTouchStart(r))},{passive:!1}),s.addEventListener(n,"touchmove",function(e){t.fire(new Un("touchmove",t,e))},{passive:!1}),s.addEventListener(n,"touchend",function(e){t.fire(new Un("touchend",t,e))}),s.addEventListener(n,"touchcancel",function(e){t.fire(new Un("touchcancel",t,e))}),s.addEventListener(n,"click",function(e){t.fire(new qn("click",t,e))}),s.addEventListener(n,"dblclick",function(e){var n=new qn("dblclick",t,e);t.fire(n),n.defaultPrevented||t.doubleClickZoom.onDblClick(n)}),s.addEventListener(n,"contextmenu",function(e){var n=t.dragRotate.isActive();i||n?i&&(r=e):t.fire(new qn("contextmenu",t,e)),e.preventDefault()}),s.addEventListener(n,"wheel",function(e){var n=new Hn("wheel",t,e);t.fire(n),n.defaultPrevented||t.scrollZoom.onWheel(e)},{passive:!1})}(this,e),this._hash=e.hash&&(new Vn).addTo(this),this._hash&&this._hash._onHashChange()||this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),this.resize(),e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new ir),this.addControl(new ar,e.logoPosition),this.on("style.load",function(){this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",this._onData),this.on("dataloading",this._onDataLoading)}n&&(r.__proto__=n),r.prototype=Object.create(n&&n.prototype),r.prototype.constructor=r;var i={showTileBoundaries:{configurable:!0},showCollisionBoxes:{configurable:!0},showOverdrawInspector:{configurable:!0},repaint:{configurable:!0},vertices:{configurable:!0}};return r.prototype.addControl=function(t,e){void 0===e&&t.getDefaultPosition&&(e=t.getDefaultPosition()),void 0===e&&(e="top-right");var n=t.onAdd(this),r=this._controlPositions[e];return-1!==e.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this},r.prototype.removeControl=function(t){return t.onRemove(this),this},r.prototype.resize=function(e){var n=this._containerDimensions(),r=n[0],i=n[1];return this._resizeCanvas(r,i),this.transform.resize(r,i),this.painter.resize(r,i),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)).fire(new t.Event("resize",e)).fire(new t.Event("moveend",e))},r.prototype.getBounds=function(){var e=new G(this.transform.pointLocation(new t.default$1(0,this.transform.height)),this.transform.pointLocation(new t.default$1(this.transform.width,0)));return(this.transform.angle||this.transform.pitch)&&(e.extend(this.transform.pointLocation(new t.default$1(this.transform.size.x,0))),e.extend(this.transform.pointLocation(new t.default$1(0,this.transform.size.y)))),e},r.prototype.getMaxBounds=function(){return this.transform.latRange&&2===this.transform.latRange.length&&this.transform.lngRange&&2===this.transform.lngRange.length?new G([this.transform.lngRange[0],this.transform.latRange[0]],[this.transform.lngRange[1],this.transform.latRange[1]]):null},r.prototype.setMaxBounds=function(t){if(t){var e=G.convert(t);this.transform.lngRange=[e.getWest(),e.getEast()],this.transform.latRange=[e.getSouth(),e.getNorth()],this.transform._constrain(),this._update()}else null==t&&(this.transform.lngRange=null,this.transform.latRange=null,this._update());return this},r.prototype.setMinZoom=function(t){if((t=null==t?0:t)>=0&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")},r.prototype.getRenderWorldCopies=function(){return this.transform.renderWorldCopies},r.prototype.setRenderWorldCopies=function(t){return this.transform.renderWorldCopies=t,this._update(),this},r.prototype.getMaxZoom=function(){return this.transform.maxZoom},r.prototype.project=function(t){return this.transform.locationPoint(Z.convert(t))},r.prototype.unproject=function(e){return this.transform.pointLocation(t.default$1.convert(e))},r.prototype.isMoving=function(){return this._moving||this.dragPan.isActive()||this.dragRotate.isActive()||this.scrollZoom.isActive()},r.prototype.isZooming=function(){return this._zooming||this.scrollZoom.isActive()},r.prototype.isRotating=function(){return this._rotating||this.dragRotate.isActive()},r.prototype.on=function(t,e,r){var i,a=this;if(void 0===r)return n.prototype.on.call(this,t,e);var o=function(){if("mouseenter"===t||"mouseover"===t){var n=!1;return{layer:e,listener:r,delegates:{mousemove:function(i){var o=a.getLayer(e)?a.queryRenderedFeatures(i.point,{layers:[e]}):[];o.length?n||(n=!0,r.call(a,new qn(t,a,i.originalEvent,{features:o}))):n=!1},mouseout:function(){n=!1}}}}if("mouseleave"===t||"mouseout"===t){var o=!1;return{layer:e,listener:r,delegates:{mousemove:function(n){(a.getLayer(e)?a.queryRenderedFeatures(n.point,{layers:[e]}):[]).length?o=!0:o&&(o=!1,r.call(a,new qn(t,a,n.originalEvent)))},mouseout:function(e){o&&(o=!1,r.call(a,new qn(t,a,e.originalEvent)))}}}}return{layer:e,listener:r,delegates:(i={},i[t]=function(t){var n=a.getLayer(e)?a.queryRenderedFeatures(t.point,{layers:[e]}):[];n.length&&(t.features=n,r.call(a,t),delete t.features)},i)}}();for(var s in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(o),o.delegates)a.on(s,o.delegates[s]);return this},r.prototype.off=function(t,e,r){if(void 0===r)return n.prototype.off.call(this,t,e);if(this._delegatedListeners&&this._delegatedListeners[t])for(var i=this._delegatedListeners[t],a=0;a180;){var o=n.locationPoint(t);if(o.x>=0&&o.y>=0&&o.x<=n.width&&o.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t}hr.prototype._rotateCompassArrow=function(){var t="rotate("+this._map.transform.angle*(180/Math.PI)+"deg)";this._compassArrow.style.transform=t},hr.prototype.onAdd=function(t){return this._map=t,this.options.showCompass&&(this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Wn(t,{button:"left",element:this._compass}),this._handler.enable()),this._container},hr.prototype.onRemove=function(){s.remove(this._container),this.options.showCompass&&(this._map.off("rotate",this._rotateCompassArrow),this._handler.disable(),delete this._handler),delete this._map},hr.prototype._createButton=function(t,e,n){var r=s.create("button",t,this._container);return r.type="button",r.setAttribute("aria-label",e),r.addEventListener("click",n),r};var mr={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function gr(t,e,n){var r=t.classList;for(var i in mr)r.remove("mapboxgl-"+n+"-anchor-"+i);r.add("mapboxgl-"+n+"-anchor-"+e)}var yr=function(e){if((arguments[0]instanceof t.default.HTMLElement||2===arguments.length)&&(e=t.extend({element:e},arguments[1])),t.bindAll(["_update","_onMapClick"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",e&&e.element)this._element=e.element,this._offset=t.default$1.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=s.create("div");var n=s.createNS("http://www.w3.org/2000/svg","svg");n.setAttributeNS(null,"height","41px"),n.setAttributeNS(null,"width","27px"),n.setAttributeNS(null,"viewBox","0 0 27 41");var r=s.createNS("http://www.w3.org/2000/svg","g");r.setAttributeNS(null,"stroke","none"),r.setAttributeNS(null,"stroke-width","1"),r.setAttributeNS(null,"fill","none"),r.setAttributeNS(null,"fill-rule","evenodd");var i=s.createNS("http://www.w3.org/2000/svg","g");i.setAttributeNS(null,"fill-rule","nonzero");var a=s.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");for(var o=0,l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];o5280?Tr(e,u,p/5280,"mi"):Tr(e,u,p,"ft")}else n&&"nautical"===n.unit?Tr(e,u,f/1852,"nm"):Tr(e,u,f,"m")}function Tr(t,e,n,r){var i,a,o,s=(i=n,(a=Math.pow(10,(""+Math.floor(i)).length-1))*(o=(o=i/a)>=10?10:o>=5?5:o>=3?3:o>=2?2:1)),l=s/n;"m"===r&&s>=1e3&&(s/=1e3,r="km"),t.style.width=e*l+"px",t.innerHTML=s+r}wr.prototype.getDefaultPosition=function(){return"bottom-left"},wr.prototype._onMove=function(){kr(this._map,this._container,this.options)},wr.prototype.onAdd=function(t){return this._map=t,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container},wr.prototype.onRemove=function(){s.remove(this._container),this._map.off("move",this._onMove),this._map=void 0},wr.prototype.setUnit=function(t){this.options.unit=t,kr(this._map,this._container,this.options)};var Ar=function(){this._fullscreen=!1,t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.default.document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in t.default.document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in t.default.document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in t.default.document&&(this._fullscreenchange="MSFullscreenChange"),this._className="mapboxgl-ctrl"};Ar.prototype.onAdd=function(e){return this._map=e,this._mapContainer=this._map.getContainer(),this._container=s.create("div",this._className+" mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._container.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._container},Ar.prototype.onRemove=function(){s.remove(this._container),this._map=null,t.default.document.removeEventListener(this._fullscreenchange,this._changeIcon)},Ar.prototype._checkFullscreenSupport=function(){return!!(t.default.document.fullscreenEnabled||t.default.document.mozFullScreenEnabled||t.default.document.msFullscreenEnabled||t.default.document.webkitFullscreenEnabled)},Ar.prototype._setupUI=function(){var e=this._fullscreenButton=s.create("button",this._className+"-icon "+this._className+"-fullscreen",this._container);e.setAttribute("aria-label","Toggle fullscreen"),e.type="button",this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.default.document.addEventListener(this._fullscreenchange,this._changeIcon)},Ar.prototype._isFullscreen=function(){return this._fullscreen},Ar.prototype._changeIcon=function(){(t.default.document.fullscreenElement||t.default.document.mozFullScreenElement||t.default.document.webkitFullscreenElement||t.default.document.msFullscreenElement)===this._mapContainer!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(this._className+"-shrink"),this._fullscreenButton.classList.toggle(this._className+"-fullscreen"))},Ar.prototype._onClickFullscreen=function(){this._isFullscreen()?t.default.document.exitFullscreen?t.default.document.exitFullscreen():t.default.document.mozCancelFullScreen?t.default.document.mozCancelFullScreen():t.default.document.msExitFullscreen?t.default.document.msExitFullscreen():t.default.document.webkitCancelFullScreen&&t.default.document.webkitCancelFullScreen():this._mapContainer.requestFullscreen?this._mapContainer.requestFullscreen():this._mapContainer.mozRequestFullScreen?this._mapContainer.mozRequestFullScreen():this._mapContainer.msRequestFullscreen?this._mapContainer.msRequestFullscreen():this._mapContainer.webkitRequestFullscreen&&this._mapContainer.webkitRequestFullscreen()};var Mr={closeButton:!0,closeOnClick:!0},Sr=function(e){function n(n){e.call(this),this.options=t.extend(Object.create(Mr),n),t.bindAll(["_update","_onClickClose"],this)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.addTo=function(e){return this._map=e,this._map.on("move",this._update),this.options.closeOnClick&&this._map.on("click",this._onClickClose),this._update(),this.fire(new t.Event("open")),this},n.prototype.isOpen=function(){return!!this._map},n.prototype.remove=function(){return this._content&&s.remove(this._content),this._container&&(s.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("click",this._onClickClose),delete this._map),this.fire(new t.Event("close")),this},n.prototype.getLngLat=function(){return this._lngLat},n.prototype.setLngLat=function(t){return this._lngLat=Z.convert(t),this._pos=null,this._update(),this},n.prototype.setText=function(e){return this.setDOMContent(t.default.document.createTextNode(e))},n.prototype.setHTML=function(e){var n,r=t.default.document.createDocumentFragment(),i=t.default.document.createElement("body");for(i.innerHTML=e;n=i.firstChild;)r.appendChild(n);return this.setDOMContent(r)},n.prototype.setDOMContent=function(t){return this._createContent(),this._content.appendChild(t),this._update(),this},n.prototype._createContent=function(){this._content&&s.remove(this._content),this._content=s.create("div","mapboxgl-popup-content",this._container),this.options.closeButton&&(this._closeButton=s.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClickClose))},n.prototype._update=function(){if(this._map&&this._lngLat&&this._content){this._container||(this._container=s.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=s.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this._map.transform.renderWorldCopies&&(this._lngLat=dr(this._lngLat,this._pos,this._map.transform));var e=this._pos=this._map.project(this._lngLat),n=this.options.anchor,r=function e(n){if(n){if("number"==typeof n){var r=Math.round(Math.sqrt(.5*Math.pow(n,2)));return{center:new t.default$1(0,0),top:new t.default$1(0,n),"top-left":new t.default$1(r,r),"top-right":new t.default$1(-r,r),bottom:new t.default$1(0,-n),"bottom-left":new t.default$1(r,-r),"bottom-right":new t.default$1(-r,-r),left:new t.default$1(n,0),right:new t.default$1(-n,0)}}if(n instanceof t.default$1||Array.isArray(n)){var i=t.default$1.convert(n);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.default$1.convert(n.center||[0,0]),top:t.default$1.convert(n.top||[0,0]),"top-left":t.default$1.convert(n["top-left"]||[0,0]),"top-right":t.default$1.convert(n["top-right"]||[0,0]),bottom:t.default$1.convert(n.bottom||[0,0]),"bottom-left":t.default$1.convert(n["bottom-left"]||[0,0]),"bottom-right":t.default$1.convert(n["bottom-right"]||[0,0]),left:t.default$1.convert(n.left||[0,0]),right:t.default$1.convert(n.right||[0,0])}}return e(new t.default$1(0,0))}(this.options.offset);if(!n){var i,a=this._container.offsetWidth,o=this._container.offsetHeight;i=e.y+r.bottom.ythis._map.transform.height-o?["bottom"]:[],e.x
this._map.transform.width-a/2&&i.push("right"),n=0===i.length?"bottom":i.join("-")}var l=e.add(r[n]).round();s.setTransform(this._container,mr[n]+" translate("+l.x+"px,"+l.y+"px)"),gr(this._container,n,"popup")}},n.prototype._onClickClose=function(){this.remove()},n}(t.Evented),Cr={version:"0.45.0",supported:e,workerCount:Math.max(Math.floor(a.hardwareConcurrency/2),1),setRTLTextPlugin:t.setRTLTextPlugin,Map:cr,NavigationControl:hr,GeolocateControl:xr,AttributionControl:ir,ScaleControl:wr,FullscreenControl:Ar,Popup:Sr,Marker:yr,Style:Je,LngLat:Z,LngLatBounds:G,Point:t.default$1,Evented:t.Evented,config:g,get accessToken(){return g.ACCESS_TOKEN},set accessToken(t){g.ACCESS_TOKEN=t},workerUrl:""};return Cr}),r})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],16:[function(t,e,n){var r={left:0,top:0};e.exports=function(t,e,n){e=e||t.currentTarget||t.srcElement,Array.isArray(n)||(n=[0,0]);var i=t.clientX||0,a=t.clientY||0,o=(s=e,s===window||s===document||s===document.body?r:s.getBoundingClientRect());var s;return n[0]=i-o.left,n[1]=a-o.top,n}},{}],17:[function(t,e,n){var r,i=t("./lib/build-log"),a=t("./lib/epsilon"),o=t("./lib/intersecter"),s=t("./lib/segment-chainer"),l=t("./lib/segment-selector"),u=t("./lib/geojson"),c=!1,f=a();function p(t,e,n){var i=r.segments(t),a=r.segments(e),o=n(r.combine(i,a));return r.polygon(o)}r={buildLog:function(t){return!0===t?c=i():!1===t&&(c=!1),!1!==c&&c.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=o(!0,f,c);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:o(!1,f,c).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:l.union(t.combined,c),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:l.intersect(t.combined,c),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:l.difference(t.combined,c),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:l.differenceRev(t.combined,c),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:l.xor(t.combined,c),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:s(t.segments,f,c),inverted:t.inverted}},polygonFromGeoJSON:function(t){return u.toPolygon(r,t)},polygonToGeoJSON:function(t){return u.fromPolygon(r,f,t)},union:function(t,e){return p(t,e,r.selectUnion)},intersect:function(t,e){return p(t,e,r.selectIntersect)},difference:function(t,e){return p(t,e,r.selectDifference)},differenceRev:function(t,e){return p(t,e,r.selectDifferenceRev)},xor:function(t,e){return p(t,e,r.selectXor)}},"object"==typeof window&&(window.PolyBool=r),e.exports=r},{"./lib/build-log":18,"./lib/epsilon":19,"./lib/geojson":20,"./lib/intersecter":21,"./lib/segment-chainer":23,"./lib/segment-selector":24}],18:[function(t,e,n){e.exports=function(){var t,e=0,n=!1;function r(e,n){return t.list.push({type:e,data:n?JSON.parse(JSON.stringify(n)):void 0}),t}return t={list:[],segmentId:function(){return e++},checkIntersection:function(t,e){return r("check",{seg1:t,seg2:e})},segmentChop:function(t,e){return r("div_seg",{seg:t,pt:e}),r("chop",{seg:t,pt:e})},statusRemove:function(t){return r("pop_seg",{seg:t})},segmentUpdate:function(t){return r("seg_update",{seg:t})},segmentNew:function(t,e){return r("new_seg",{seg:t,primary:e})},segmentRemove:function(t){return r("rem_seg",{seg:t})},tempStatus:function(t,e,n){return r("temp_status",{seg:t,above:e,below:n})},rewind:function(t){return r("rewind",{seg:t})},status:function(t,e,n){return r("status",{seg:t,above:e,below:n})},vert:function(e){return e===n?t:(n=e,r("vert",{x:e}))},log:function(t){return"string"!=typeof t&&(t=JSON.stringify(t,!1," ")),r("log",{txt:t})},reset:function(){return r("reset")},selected:function(t){return r("selected",{segs:t})},chainStart:function(t){return r("chain_start",{seg:t})},chainRemoveHead:function(t,e){return r("chain_rem_head",{index:t,pt:e})},chainRemoveTail:function(t,e){return r("chain_rem_tail",{index:t,pt:e})},chainNew:function(t,e){return r("chain_new",{pt1:t,pt2:e})},chainMatch:function(t){return r("chain_match",{index:t})},chainClose:function(t){return r("chain_close",{index:t})},chainAddHead:function(t,e){return r("chain_add_head",{index:t,pt:e})},chainAddTail:function(t,e){return r("chain_add_tail",{index:t,pt:e})},chainConnect:function(t,e){return r("chain_con",{index1:t,index2:e})},chainReverse:function(t){return r("chain_rev",{index:t})},chainJoin:function(t,e){return r("chain_join",{index1:t,index2:e})},done:function(){return r("done")}}}},{}],19:[function(t,e,n){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,n,r){var i=n[0],a=n[1],o=r[0],s=r[1],l=e[0];return(o-i)*(e[1]-a)-(s-a)*(l-i)>=-t},pointBetween:function(e,n,r){var i=e[1]-n[1],a=r[0]-n[0],o=e[0]-n[0],s=r[1]-n[1],l=o*a+i*s;return!(l-t)},pointsSameX:function(e,n){return Math.abs(e[0]-n[0])t!=o-i>t&&(a-u)*(i-c)/(o-c)+u-r>t&&(s=!s),a=u,o=c}return s}};return e}},{}],20:[function(t,e,n){var r={toPolygon:function(t,e){function n(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function n(e){var n=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[n]})}for(var r=n(e[0]),i=1;i0})}function c(t,r){var i=t.seg,a=r.seg,o=i.start,s=i.end,u=a.start,c=a.end;n&&n.checkIntersection(i,a);var f=e.linesIntersect(o,s,u,c);if(!1===f){if(!e.pointsCollinear(o,s,u))return!1;if(e.pointsSame(o,c)||e.pointsSame(s,u))return!1;var p=e.pointsSame(o,u),h=e.pointsSame(s,c);if(p&&h)return r;var d=!p&&e.pointBetween(o,u,c),m=!h&&e.pointBetween(s,u,c);if(p)return m?l(r,s):l(t,c),r;d&&(h||(m?l(r,s):l(t,c)),l(r,o))}else 0===f.alongA&&(-1===f.alongB?l(t,u):0===f.alongB?l(t,f.pt):1===f.alongB&&l(t,c)),0===f.alongB&&(-1===f.alongA?l(r,o):0===f.alongA?l(r,f.pt):1===f.alongA&&l(r,s));return!1}for(var f=[];!a.isEmpty();){var p=a.getHead();if(n&&n.vert(p.pt[0]),p.isStart){n&&n.segmentNew(p.seg,p.primary);var h=u(p),d=h.before?h.before.ev:null,m=h.after?h.after.ev:null;function g(){if(d){var t=c(p,d);if(t)return t}return!!m&&c(p,m)}n&&n.tempStatus(p.seg,!!d&&d.seg,!!m&&m.seg);var y,v,_=g();if(_)t?(v=null===p.seg.myFill.below||p.seg.myFill.above!==p.seg.myFill.below)&&(_.seg.myFill.above=!_.seg.myFill.above):_.seg.otherFill=p.seg.myFill,n&&n.segmentUpdate(_.seg),p.other.remove(),p.remove();if(a.getHead()!==p){n&&n.rewind(p.seg);continue}t?(v=null===p.seg.myFill.below||p.seg.myFill.above!==p.seg.myFill.below,p.seg.myFill.below=m?m.seg.myFill.above:i,p.seg.myFill.above=v?!p.seg.myFill.below:p.seg.myFill.below):null===p.seg.otherFill&&(y=m?p.primary===m.primary?m.seg.otherFill.above:m.seg.myFill.above:p.primary?o:i,p.seg.otherFill={above:y,below:y}),n&&n.status(p.seg,!!d&&d.seg,!!m&&m.seg),p.other.status=h.insert(r.node({ev:p}))}else{var x=p.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(s.exists(x.prev)&&s.exists(x.next)&&c(x.prev.ev,x.next.ev),n&&n.statusRemove(x.ev.seg),x.remove(),!p.primary){var b=p.seg.myFill;p.seg.myFill=p.seg.otherFill,p.seg.otherFill=b}f.push(p.seg)}a.getHead().remove()}return n&&n.done(),f}return t?{addRegion:function(t){for(var r,i,a,o=t[t.length-1],l=0;l1)for(var n=1;n1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}if(t=L(t,360),e=L(e,100),n=L(n,100),0===e)r=i=a=n;else{var s=n<.5?n*(1+e):n+e-n*e,l=2*n-s;r=o(l,s,t+1/3),i=o(l,s,t),a=o(l,s,t-1/3)}return{r:255*r,g:255*i,b:255*a}}(e.h,l,c),f=!0,p="hsl"),e.hasOwnProperty("a")&&(a=e.a));var h,d,m;return a=z(a),{ok:f,format:e.format||p,r:o(255,s(i.r,0)),g:o(255,s(i.g,0)),b:o(255,s(i.b,0)),a:a}}(e);this._originalInput=e,this._r=c.r,this._g=c.g,this._b=c.b,this._a=c.a,this._roundA=a(100*this._a)/100,this._format=l.format||c.format,this._gradientType=l.gradientType,this._r<1&&(this._r=a(this._r)),this._g<1&&(this._g=a(this._g)),this._b<1&&(this._b=a(this._b)),this._ok=c.ok,this._tc_id=i++}function c(t,e,n){t=L(t,255),e=L(e,255),n=L(n,255);var r,i,a=s(t,e,n),l=o(t,e,n),u=(a+l)/2;if(a==l)r=i=0;else{var c=a-l;switch(i=u>.5?c/(2-a-l):c/(a+l),a){case t:r=(e-n)/c+(e>1)+720)%360;--e;)r.h=(r.h+i)%360,a.push(u(r));return a}function M(t,e){e=e||6;for(var n=u(t).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/e;e--;)o.push(u({h:r,s:i,v:a})),a=(a+s)%1;return o}u.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,n,r,i=this.toRgb();return e=i.r/255,n=i.g/255,r=i.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))},setAlpha:function(t){return this._a=z(t),this._roundA=a(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=a(360*t.h),n=a(100*t.s),r=a(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=c(this._r,this._g,this._b),e=a(360*t.h),n=a(100*t.s),r=a(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return p(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,n,r,i){var o=[P(a(t).toString(16)),P(a(e).toString(16)),P(a(n).toString(16)),P(O(r))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:a(this._r),g:a(this._g),b:a(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+a(this._r)+", "+a(this._g)+", "+a(this._b)+")":"rgba("+a(this._r)+", "+a(this._g)+", "+a(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:a(100*L(this._r,255))+"%",g:a(100*L(this._g,255))+"%",b:a(100*L(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+a(100*L(this._r,255))+"%, "+a(100*L(this._g,255))+"%, "+a(100*L(this._b,255))+"%)":"rgba("+a(100*L(this._r,255))+"%, "+a(100*L(this._g,255))+"%, "+a(100*L(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(C[p(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+h(this._r,this._g,this._b,this._a),n=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var i=u(t);n="#"+h(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0;return e||!r||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return u(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(_,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(m,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(A,arguments)},complement:function(){return this._applyCombination(b,arguments)},monochromatic:function(){return this._applyCombination(M,arguments)},splitcomplement:function(){return this._applyCombination(T,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},u.fromRatio=function(t,e){if("object"==typeof t){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]="a"===r?t[r]:D(t[r]));t=n}return u(t,e)},u.equals=function(t,e){return!(!t||!e)&&u(t).toRgbString()==u(e).toRgbString()},u.random=function(){return u.fromRatio({r:l(),g:l(),b:l()})},u.mix=function(t,e,n){n=0===n?0:n||50;var r=u(t).toRgb(),i=u(e).toRgb(),a=n/100;return u({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},u.readability=function(e,n){var r=u(e),i=u(n);return(t.max(r.getLuminance(),i.getLuminance())+.05)/(t.min(r.getLuminance(),i.getLuminance())+.05)},u.isReadable=function(t,e,n){var r,i,a=u.readability(t,e);switch(i=!1,(r=function(t){var e,n;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==n&&"large"!==n&&(n="small");return{level:e,size:n}}(n)).level+r.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},u.mostReadable=function(t,e,n){var r,i,a,o,s=null,l=0;i=(n=n||{}).includeFallbackColors,a=n.level,o=n.size;for(var c=0;cl&&(l=r,s=u(e[c]));return u.isReadable(t,s,{level:a,size:o})||!i?s:(n.includeFallbackColors=!1,u.mostReadable(t,["#fff","#000"],n))};var S=u.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},C=u.hexNames=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}(S);function z(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function L(e,n){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(n,s(0,parseFloat(e))),r&&(e=parseInt(e*n,10)/100),t.abs(e-n)<1e-6?1:e%n/parseFloat(n)}function E(t){return o(1,s(0,t))}function I(t){return parseInt(t,16)}function P(t){return 1==t.length?"0"+t:""+t}function D(t){return t<=1&&(t=100*t+"%"),t}function O(e){return t.round(255*parseFloat(e)).toString(16)}function R(t){return I(t)/255}var F,B,N,j=(B="[\\s|\\(]+("+(F="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",N="[\\s|\\(]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",{CSS_UNIT:new RegExp(F),rgb:new RegExp("rgb"+B),rgba:new RegExp("rgba"+N),hsl:new RegExp("hsl"+B),hsla:new RegExp("hsla"+N),hsv:new RegExp("hsv"+B),hsva:new RegExp("hsva"+N),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function V(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=u:window.tinycolor=u}(Math)},{}],27:[function(t,e,n){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],28:[function(t,e,n){"use strict";var r=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:i({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:r.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:r.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:i({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":194,"../../plots/cartesian/constants":210,"../../plots/font_attributes":231,"./arrow_paths":27}],29:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("./draw").draw;function o(t){var e=t._fullLayout;r.filterVisible(e.annotations).forEach(function(e){var n=i.getFromId(t,e.xref),r=i.getFromId(t,e.yref);e._extremes={},n&&s(e,n),r&&s(e,r)})}function s(t,e){var n,r=e._id,a=r.charAt(0),o=t[a],s=t["a"+a],l=t[a+"ref"],u=t["a"+a+"ref"],c=t["_"+a+"padplus"],f=t["_"+a+"padminus"],p={x:1,y:-1}[a]*t[a+"shift"],h=3*t.arrowsize*t.arrowwidth||0,d=h+p,m=h-p,g=3*t.startarrowsize*t.arrowwidth||0,y=g+p,v=g-p;if(u===l){var _=i.findExtremes(e,[e.r2c(o)],{ppadplus:d,ppadminus:m}),x=i.findExtremes(e,[e.r2c(s)],{ppadplus:Math.max(c,y),ppadminus:Math.max(f,v)});n={min:[_.min[0],x.min[0]],max:[_.max[0],x.max[0]]}}else y=s?y+s:y,v=s?v-s:v,n=i.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(c,d,y),ppadminus:Math.max(f,m,v)});t._extremes[r]=n}e.exports=function(t){var e=t._fullLayout;if(r.filterVisible(e.annotations).length&&t._fullData.length)return r.syncOrAsync([a,o],t)}},{"../../lib":160,"../../plots/cartesian/axes":204,"./draw":34}],30:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../registry"),a=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var n,r,i,a,o,l,u,c=t._fullLayout.annotations,f=[],p=[],h=[],d=(e||[]).length;for(n=0;n0||n.explicitOff.length>0},onClick:function(t,e){var n,s,l=o(t,e),u=l.on,c=l.off.concat(l.explicitOff),f={},p=t._fullLayout.annotations;if(!u.length&&!c.length)return;for(n=0;n2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var U=!1,H=["x","y"],Z=0;Z1)&&(Q===K?((lt=tt.r2fraction(e["a"+J]))<0||lt>1)&&(U=!0):U=!0),G=tt._offset+tt.r2p(e[J]),X=.5}else"x"===J?(W=e[J],G=x.l+x.w*W):(W=1-e[J],G=x.t+x.h*W),X=e.showarrow?.5:W;if(e.showarrow){st.head=G;var ut=e["a"+J];Y=nt*q(.5,e.xanchor)-rt*q(.5,e.yanchor),Q===K?(st.tail=tt._offset+tt.r2p(ut),$=Y):(st.tail=G+ut,$=Y+ut),st.text=st.tail+Y;var ct=_["x"===J?"width":"height"];if("paper"===K&&(st.head=o.constrain(st.head,1,ct-1)),"pixel"===Q){var ft=-Math.max(st.tail-3,st.text),pt=Math.min(st.tail+3,st.text)-ct;ft>0?(st.tail+=ft,st.text+=ft):pt>0&&(st.tail-=pt,st.text-=pt)}st.tail+=ot,st.head+=ot}else $=Y=it*q(X,at),st.text=G+Y;st.text+=ot,Y+=ot,$+=ot,e["_"+J+"padplus"]=it/2+$,e["_"+J+"padminus"]=it/2-$,e["_"+J+"size"]=it,e["_"+J+"shift"]=Y}if(t._dragging||!U){var ht=0,dt=0;if("left"!==e.align&&(ht=(w-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(dt=(I-v)*("middle"===e.valign?.5:1)),c)r.select("svg").attr({x:R+ht-1,y:R+dt}).call(u.setClipUrl,B?M:null,t);else{var mt=R+dt-d.top,gt=R+ht-d.left;V.call(f.positionText,gt,mt).call(u.setClipUrl,B?M:null,t)}N.select("rect").call(u.setRect,R,R,w,I),F.call(u.setRect,D/2,D/2,O-D,j-D),P.call(u.setTranslate,Math.round(S.x.text-O/2),Math.round(S.y.text-j/2)),L.attr({transform:"rotate("+C+","+S.x.text+","+S.y.text+")"});var yt,vt=function(n,r){z.selectAll(".annotation-arrow-g").remove();var c=S.x.head,f=S.y.head,p=S.x.tail+n,d=S.y.tail+r,y=S.x.text+n,v=S.y.text+r,_=o.rotationXYMatrix(C,y,v),w=o.apply2DTransform(_),M=o.apply2DTransform2(_),E=+F.attr("width"),I=+F.attr("height"),D=y-.5*E,O=D+E,R=v-.5*I,B=R+I,N=[[D,R,D,B],[D,B,O,B],[O,B,O,R],[O,R,D,R]].map(M);if(!N.reduce(function(t,e){return t^!!o.segmentsIntersect(c,f,c+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){N.forEach(function(t){var e=o.segmentsIntersect(p,d,c,f,t[0],t[1],t[2],t[3]);e&&(p=e.x,d=e.y)});var j=e.arrowwidth,V=e.arrowcolor,q=e.arrowside,U=z.append("g").style({opacity:l.opacity(V)}).classed("annotation-arrow-g",!0),H=U.append("path").attr("d","M"+p+","+d+"L"+c+","+f).style("stroke-width",j+"px").call(l.stroke,l.rgb(V));if(m(H,q,e),b.annotationPosition&&H.node().parentNode&&!a){var Z=c,G=f;if(e.standoff){var $=Math.sqrt(Math.pow(c-p,2)+Math.pow(f-d,2));Z+=e.standoff*(p-c)/$,G+=e.standoff*(d-f)/$}var W,X,Y=U.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(p-Z)+","+(d-G),transform:"translate("+Z+","+G+")"}).style("stroke-width",j+6+"px").call(l.stroke,"rgba(0,0,0,0)").call(l.fill,"rgba(0,0,0,0)");h.init({element:Y.node(),gd:t,prepFn:function(){var t=u.getTranslate(P);W=t.x,X=t.y,s&&s.autorange&&k(s._name+".autorange",!0),g&&g.autorange&&k(g._name+".autorange",!0)},moveFn:function(t,n){var r=w(W,X),i=r[0]+t,a=r[1]+n;P.call(u.setTranslate,i,a),T("x",s?s.p2r(s.r2p(e.x)+t):e.x+t/x.w),T("y",g?g.p2r(g.r2p(e.y)+n):e.y-n/x.h),e.axref===e.xref&&T("ax",s.p2r(s.r2p(e.ax)+t)),e.ayref===e.yref&&T("ay",g.p2r(g.r2p(e.ay)+n)),U.attr("transform","translate("+t+","+n+")"),L.attr({transform:"rotate("+C+","+i+","+a+")"})},doneFn:function(){i.call("_guiRelayout",t,A());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&vt(0,0),E)h.init({element:P.node(),gd:t,prepFn:function(){yt=L.attr("transform")},moveFn:function(t,n){var r="pointer";if(e.showarrow)e.axref===e.xref?T("ax",s.p2r(s.r2p(e.ax)+t)):T("ax",e.ax+t),e.ayref===e.yref?T("ay",g.p2r(g.r2p(e.ay)+n)):T("ay",e.ay+n),vt(t,n);else{if(a)return;var i,o;if(s)i=s.p2r(s.r2p(e.x)+t);else{var l=e._xsize/x.w,u=e.x+(e._xshift-e.xshift)/x.w-l/2;i=h.align(u+t/x.w,l,0,1,e.xanchor)}if(g)o=g.p2r(g.r2p(e.y)+n);else{var c=e._ysize/x.h,f=e.y-(e._yshift+e.yshift)/x.h-c/2;o=h.align(f-n/x.h,c,0,1,e.yanchor)}T("x",i),T("y",o),s&&g||(r=h.getCursor(s?.5:i,g?.5:o,e.xanchor,e.yanchor))}L.attr({transform:"translate("+t+","+n+")"+yt}),p(P,r)},doneFn:function(){p(P),i.call("_guiRelayout",t,A());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else P.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var n=0;n=0,g=e.indexOf("end")>=0,y=f.backoff*h+n.standoff,v=p.backoff*d+n.startstandoff;if("line"===c.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},s={x:+t.attr("x2"),y:+t.attr("y2")};var _=o.x-s.x,x=o.y-s.y;if(u=(l=Math.atan2(x,_))+Math.PI,y&&v&&y+v>Math.sqrt(_*_+x*x))return void E();if(y){if(y*y>_*_+x*x)return void E();var b=y*Math.cos(l),w=y*Math.sin(l);s.x+=b,s.y+=w,t.attr({x2:s.x,y2:s.y})}if(v){if(v*v>_*_+x*x)return void E();var k=v*Math.cos(l),T=v*Math.sin(l);o.x-=k,o.y-=T,t.attr({x1:o.x,y1:o.y})}}else if("path"===c.nodeName){var A=c.getTotalLength(),M="";if(A1){u=!0;break}}u?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l._pdata=i(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*n[0],e.yaxis.r2l(l.y)*n[1],e.zaxis.r2l(l.z)*n[2]]),r(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":234,"../annotations/draw":34}],41:[function(t,e,n){"use strict";var r=t("../../registry"),i=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var n=r.subplotsRegistry.gl3d;if(!n)return;for(var a=n.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)r[o]>1&&(r[o]=1);else if(r[o]>=1)return t}var s=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return a?"rgba("+s+", "+r[3]+")":"rgb("+s+")"}a.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},a.rgb=function(t){return a.tinyRGB(r(t))},a.opacity=function(t){return t?r(t).getAlpha():0},a.addOpacity=function(t,e){var n=r(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},a.combine=function(t,e){var n=r(t).toRgb();if(1===n.a)return r(t).toRgbString();var i=r(e||l).toRgb(),a=1===i.a?i:{r:255*(1-i.a)+i.r*i.a,g:255*(1-i.a)+i.g*i.a,b:255*(1-i.a)+i.b*i.a},o={r:a.r*(1-n.a)+n.r*n.a,g:a.g*(1-n.a)+n.g*n.a,b:a.b*(1-n.a)+n.b*n.a};return r(o).toRgbString()},a.contrast=function(t,e,n){var i=r(t);return 1!==i.getAlpha()&&(i=r(a.combine(t,l))),(i.isDark()?e?i.lighten(e):l:n?i.darken(n):s).toString()},a.stroke=function(t,e){var n=r(e);t.style({stroke:a.tinyRGB(n),"stroke-opacity":n.getAlpha()})},a.fill=function(t,e){var n=r(e);t.style({fill:a.tinyRGB(n),"fill-opacity":n.getAlpha()})},a.clean=function(t){if(t&&"object"==typeof t){var e,n,r,i,o=Object.keys(t);for(e=0;e0?C>=O:C<=O));z++)C>F&&C0?C>=O:C<=O));z++)C>L[0]&&C1){var ot=Math.pow(10,Math.floor(Math.log(at)/Math.LN10));rt*=ot*u.roundUp(at/ot,[2,5,10]),(Math.abs(n.levels.start)/n.levels.size+1e-6)%1<2e-6&&(et.tick0=0)}et.dtick=rt}et.domain=[J+W,J+Z-W],et.setScale();var st=u.ensureSingle(g._infolayer,"g",e,function(t){t.classed(T.colorbar,!0).each(function(){var t=r.select(this);t.append("rect").classed(T.cbbg,!0),t.append("g").classed(T.cbfills,!0),t.append("g").classed(T.cblines,!0),t.append("g").classed(T.cbaxis,!0).classed(T.crisp,!0),t.append("g").classed(T.cbtitleunshift,!0).append("g").classed(T.cbtitle,!0),t.append("rect").classed(T.cboutline,!0),t.select(".cbtitle").datum(0)})});st.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var lt=st.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")"),ut=st.select(".cbaxis"),ct=0;if(-1!==["top","bottom"].indexOf(n.title.side)){var ft,pt=k.l+(n.x+G)*k.w,ht=et.title.font.size;ft="top"===n.title.side?(1-(J+Z-W))*k.h+k.t+3+.75*ht:(1-(J+W))*k.h+k.t-3-.25*ht,_t(et._id+"title",{attributes:{x:pt,y:ft,"text-anchor":"start"}})}var dt,mt,gt,yt=u.syncOrAsync([a.previousPromises,function(){if(-1!==["top","bottom"].indexOf(n.title.side)){var a=st.select(".cbtitle"),o=a.select("text"),l=[-n.outlinewidth/2,n.outlinewidth/2],c=a.select(".h"+et._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*y),c?(ct=p.bBox(c).height)>f&&(l[1]-=(ct-f)/2):o.node()&&!o.classed(T.jsPlaceholder)&&(ct=p.bBox(o.node()).height),ct){if(ct+=5,"top"===n.title.side)et.domain[1]-=ct/k.h,l[1]*=-1;else{et.domain[0]+=ct/k.h;var h=m.lineCount(o);l[1]+=(1-h)*f}a.attr("transform","translate("+l+")"),et.setScale()}}st.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-et.domain[1]))+")"),ut.attr("transform","translate(0,"+Math.round(-k.t)+")");var d=st.select(".cbfills").selectAll("rect.cbfill").data(I);d.enter().append("rect").classed(T.cbfill,!0).style("stroke","none"),d.exit().remove();var v=L.map(et.c2p).map(Math.round).sort(function(t,e){return t-e});d.each(function(a,o){var s=[0===o?L[0]:(I[o]+I[o-1])/2,o===I.length-1?L[1]:(I[o]+I[o+1])/2].map(et.c2p).map(Math.round);s[1]=u.constrain(s[1]+(s[1]>s[0])?1:-1,v[0],v[1]);var l=r.select(this).attr({x:X,width:Math.max(q,2),y:r.min(s),height:Math.max(r.max(s)-r.min(s),2)});if(n.fillgradient)p.gradient(l,t,e,"vertical",n.fillgradient,"fill");else{var c=D(a).replace("e-","");l.attr("fill",i(c).toHexString())}});var _=st.select(".cblines").selectAll("path.cbline").data(n.line.color&&n.line.width?E:[]);return _.enter().append("path").classed(T.cbline,!0),_.exit().remove(),_.each(function(t){r.select(this).attr("d","M"+X+","+(Math.round(et.c2p(t))+n.line.width/2%1)+"h"+q).call(p.lineGroupStyle,n.line.width,P(t),n.line.dash)}),ut.selectAll("g."+et._id+"tick,path").remove(),u.syncOrAsync([function(){var e=X+q+(n.outlinewidth||0)/2-("outside"===n.ticks?1:0),r=s.calcTicks(et),i=s.makeTransFn(et),a=s.makeLabelFns(et,e),o=s.getTickSigns(et)[2];return s.drawTicks(t,et,{vals:"inside"===et.ticks?s.clipEnds(et,r):r,layer:ut,path:s.makeTickPath(et,e,o),transFn:i}),s.drawLabels(t,et,{vals:r,layer:ut,transFn:i,labelXFn:a.labelXFn,labelYFn:a.labelYFn,labelAnchorFn:a.labelAnchorFn})},function(){if(-1===["top","bottom"].indexOf(n.title.side)){var e=et.title.font.size,i=et._offset+et._length/2,a=k.l+(et.position||0)*k.w+("right"===et.side?10+e*(et.showticklabels?1:.5):-10-e*(et.showticklabels?.5:0));_t("h"+et._id+"title",{avoid:{selection:r.select(t).selectAll("g."+et._id+"tick"),side:n.title.side,offsetLeft:k.l,offsetTop:0,maxShift:g.width},attributes:{x:a,y:i,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},a.previousPromises,function(){var r=q+n.outlinewidth/2+p.bBox(ut.node()).width;if((N=lt.select("text")).node()&&!N.classed(T.jsPlaceholder)){var i,o=lt.select(".h"+et._id+"title-math-group").node();i=o&&-1!==["top","bottom"].indexOf(n.title.side)?p.bBox(o).width:p.bBox(lt.node()).right-X-k.l,r=Math.max(r,i)}var s=2*n.xpad+r+n.borderwidth+n.outlinewidth/2,l=K-Q;st.select(".cbbg").attr({x:X-n.xpad-(n.borderwidth+n.outlinewidth)/2,y:Q-$,width:Math.max(s,2),height:Math.max(l+2*$,2)}).call(h.fill,n.bgcolor).call(h.stroke,n.bordercolor).style({"stroke-width":n.borderwidth}),st.selectAll(".cboutline").attr({x:X,y:Q+n.ypad+("top"===n.title.side?ct:0),width:Math.max(q,2),height:Math.max(l-2*n.ypad-ct,2)}).call(h.stroke,n.outlinecolor).style({fill:"None","stroke-width":n.outlinewidth});var u=({center:.5,right:1}[n.xanchor]||0)*s;st.attr("transform","translate("+(k.l-u)+","+k.t+")");var c={},f=v[n.yanchor],d=_[n.yanchor];"pixels"===n.lenmode?(c.y=n.y,c.t=l*f,c.b=l*d):(c.t=c.b=0,c.yt=n.y+n.len*f,c.yb=n.y-n.len*d);var m=v[n.xanchor],g=_[n.xanchor];if("pixels"===n.thicknessmode)c.x=n.x,c.l=s*m,c.r=s*g;else{var y=s-q;c.l=y*m,c.r=y*g,c.xl=n.x-n.thickness*m,c.xr=n.x+n.thickness*g}a.autoMargin(t,e,c)}],t);if(yt&&yt.then&&(t._promises||[]).push(yt),t._context.edits.colorbarPosition)l.init({element:st.node(),gd:t,prepFn:function(){dt=st.attr("transform"),f(st)},moveFn:function(t,e){st.attr("transform",dt+" translate("+t+","+e+")"),mt=l.align(Y+t/k.w,U,0,1,n.xanchor),gt=l.align(J-e/k.h,Z,0,1,n.yanchor);var r=l.getCursor(mt,gt,n.xanchor,n.yanchor);f(st,r)},doneFn:function(){if(f(st),void 0!==mt&&void 0!==gt){var e={};e[S("x")]=mt,e[S("y")]=gt,o.call("_guiRestyle",t,e,M().index)}}});return yt}function vt(t,e){return u.coerce(tt,et,w,t,e)}function _t(e,n){var r={propContainer:et,propName:S("title"),traceIndex:M().index,placeholder:g._dfltTitle.colorbar,containerGroup:st.select(".cbtitle")},i="h"===e.charAt(0)?e.substr(1):"h"+e;st.selectAll("."+i+",."+i+"-math-group").remove(),d.draw(t,e,c(r,n||{}))}g._infolayer.selectAll("g."+e).remove()}function M(){var n,r,i=e.substr(2);for(n=0;n=0?i.colorscale.sequential:i.colorscale.sequentialminus,l._colorscale=l.colorscale=d)}},{"../../lib":160}],52:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("./helpers").hasColorscale;e.exports=function(t){function e(t,e){var n=t["_"+e];void 0!==n&&(t[e]=n)}function n(t,n){var i=n.container?r.nestedProperty(t,n.container).get():t;if(i){var a=i.zauto||i.cauto,o=n.min,s=n.max;(a||void 0===i[o])&&e(i,o),(a||void 0===i[s])&&e(i,s),i.autocolorscale&&e(i,"colorscale")}}for(var a=0;a=0;r--,i++){var a=t[r];n[i]=[1-a[0],a[1]]}return n}function c(t){var e={r:t[0],g:t[1],b:t[2],a:t[3]};return i(e).toRgbString()}e.exports={hasColorscale:function(t,e){var n=e?o.nestedProperty(t,e).get()||{}:t,r=n.color,i=!1;if(o.isArrayOrTypedArray(r))for(var s=0;s4/3-s?o:s}},{}],60:[function(t,e,n){"use strict";var r=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,a){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:r.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":160}],61:[function(t,e,n){"use strict";var r=t("mouse-event-offset"),i=t("has-hover"),a=t("has-passive-events"),o=t("../../registry"),s=t("../../lib"),l=t("../../plots/cartesian/constants"),u=t("../../constants/interactions"),c=e.exports={};c.align=t("./align"),c.getCursor=t("./cursor");var f=t("./unhover");function p(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function h(t){return r(t.changedTouches?t.changedTouches[0]:t,document.body)}c.unhover=f.wrapped,c.unhoverRaw=f.raw,c.init=function(t){var e,n,r,f,d,m,g,y,v=t.gd,_=1,x=u.DBLCLICKDELAY,b=t.element;v._mouseDownTime||(v._mouseDownTime=0),b.style.pointerEvents="all",b.onmousedown=k,a?(b._ontouchstart&&b.removeEventListener("touchstart",b._ontouchstart),b._ontouchstart=k,b.addEventListener("touchstart",k,{passive:!1})):b.ontouchstart=k;var w=t.clampFn||function(t,e,n){return Math.abs(t)x&&(_=Math.max(_-1,1)),v._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(_,m),!y){var n;try{n=new MouseEvent("click",e)}catch(t){var r=h(e);(n=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,r[0],r[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}g.dispatchEvent(n)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(v),v._dragged=!1}else v._dragged=!1}},c.coverSlip=p},{"../../constants/interactions":139,"../../lib":160,"../../plots/cartesian/constants":210,"../../registry":252,"./align":59,"./cursor":60,"./unhover":62,"has-hover":11,"has-passive-events":12,"mouse-event-offset":16}],62:[function(t,e,n){"use strict";var r=t("../../lib/events"),i=t("../../lib/throttle"),a=t("../../lib/get_graph_div"),o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,n){(t=a(t))._fullLayout&&i.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,n)},s.raw=function(t,e){var n=t._fullLayout,i=t._hoverdata;e||(e={}),e.target&&!1===r.triggerHandler(t,"plotly_beforehover",e)||(n._hoverlayer.selectAll("g").remove(),n._hoverlayer.selectAll("line").remove(),n._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&i&&t.emit("plotly_unhover",{event:e,points:i}))}},{"../../lib/events":152,"../../lib/get_graph_div":158,"../../lib/throttle":182,"../fx/constants":76}],63:[function(t,e,n){"use strict";n.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],64:[function(t,e,n){"use strict";var r=t("d3"),i=t("fast-isnumeric"),a=t("tinycolor2"),o=t("../../registry"),s=t("../color"),l=t("../colorscale"),u=t("../../lib"),c=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),p=t("../../constants/alignment").LINE_SPACING,h=t("../../constants/interactions").DESELECTDIM,d=t("../../traces/scatter/subtypes"),m=t("../../traces/scatter/make_bubble_size_func"),g=e.exports={};g.font=function(t,e,n,r){u.isPlainObject(e)&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(s.fill,r)},g.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},g.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},g.setRect=function(t,e,n,r,i){t.call(g.setPosition,e,n).call(g.setSize,r,i)},g.translatePoint=function(t,e,n,r){var a=n.c2p(t.x),o=r.c2p(t.y);return!!(i(a)&&i(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",a).attr("y",o):e.attr("transform","translate("+a+","+o+")"),!0)},g.translatePoints=function(t,e,n){t.each(function(t){var i=r.select(this);g.translatePoint(t,i,e,n)})},g.hideOutsideRangePoint=function(t,e,n,r,i,a){e.attr("display",n.isPtWithinRange(t,i)&&r.isPtWithinRange(t,a)?null:"none")},g.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var n=e.xaxis,i=e.yaxis;t.each(function(e){var a=e[0].trace,o=a.xcalendar,s=a.ycalendar,l="bar"===a.type?".bartext":".point,.textpoint";t.selectAll(l).each(function(t){g.hideOutsideRangePoint(t,r.select(this),n,i,o,s)})})}},g.crispRound=function(t,e,n){return e&&i(e)?t._context.staticPlot?e:e<1?1:Math.round(e):n||0},g.singleLineStyle=function(t,e,n,r,i){e.style("fill","none");var a=(((t||[])[0]||{}).trace||{}).line||{},o=n||a.width||0,l=i||a.dash||"";s.stroke(e,r||a.color),g.dashLine(e,l,o)},g.lineGroupStyle=function(t,e,n,i){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=i||a.dash||"";r.select(this).call(s.stroke,n||a.color).call(g.dashLine,l,o)})},g.dashLine=function(t,e,n){n=+n||0,e=g.dashStyle(e,n),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},g.dashStyle=function(t,e){e=+e||1;var n=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=n+"px,"+n+"px":"dash"===t?t=3*n+"px,"+3*n+"px":"longdash"===t?t=5*n+"px,"+5*n+"px":"dashdot"===t?t=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===t&&(t=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t},g.singleFillStyle=function(t){var e=(((r.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(s.fill,e)},g.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){var e=r.select(this);t[0].trace&&e.call(s.fill,t[0].trace.fillcolor)})};var y=t("./symbol_defs");g.symbolNames=[],g.symbolFuncs=[],g.symbolNeedLines={},g.symbolNoDot={},g.symbolNoFill={},g.symbolList=[],Object.keys(y).forEach(function(t){var e=y[t];g.symbolList=g.symbolList.concat([e.n,t,e.n+100,t+"-open"]),g.symbolNames[e.n]=t,g.symbolFuncs[e.n]=e.f,e.needLine&&(g.symbolNeedLines[e.n]=!0),e.noDot?g.symbolNoDot[e.n]=!0:g.symbolList=g.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(g.symbolNoFill[e.n]=!0)});var v=g.symbolNames.length,_="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function x(t,e){var n=t%100;return g.symbolFuncs[n](e)+(t>=200?_:"")}g.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=g.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))};var b={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=r.format("~.1f"),T={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:b},horizontalreversed:{node:"linearGradient",attrs:b,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};g.gradient=function(t,e,n,i,o,l){for(var c=o.length,f=T[i],p=new Array(c),h=0;h=100,e.attr("d",x(c,l))}var f,p,h,d=!1;if(t.so)h=o.outlierwidth,p=o.outliercolor,f=a.outliercolor;else{var m=(o||{}).width;h=(t.mlw+1||m+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,p="mlc"in t?t.mlcc=r.lineScale(t.mlc):u.isArrayOrTypedArray(o.color)?s.defaultLine:o.color,u.isArrayOrTypedArray(a.color)&&(f=s.defaultLine,d=!0),f="mc"in t?t.mcc=r.markerScale(t.mc):a.color||"rgba(0,0,0,0)",r.selectedColorFn&&(f=r.selectedColorFn(t))}if(t.om)e.call(s.stroke,f).style({"stroke-width":(h||1)+"px",fill:"none"});else{e.style("stroke-width",h+"px");var y=a.gradient,v=t.mgt;if(v?d=!0:v=y&&y.type,Array.isArray(v)&&(v=v[0],T[v]||(v=0)),v&&"none"!==v){var _=t.mgc;_?d=!0:_=y.color;var b=n.uid;d&&(b+="-"+t.i),g.gradient(e,i,b,v,[[0,_],[1,f]],"fill")}else s.fill(e,f);h&&s.stroke(e,p)}},g.makePointStyleFns=function(t){var e={},n=t.marker;return e.markerScale=g.tryColorscale(n,""),e.lineScale=g.tryColorscale(n,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=d.isBubble(t)?m(t):function(){return(n.size||6)/2}),t.selectedpoints&&u.extendFlat(e,g.makeSelectedPointStyleFns(t)),e},g.makeSelectedPointStyleFns=function(t){var e={},n=t.selected||{},r=t.unselected||{},i=t.marker||{},a=n.marker||{},s=r.marker||{},l=i.opacity,c=a.opacity,f=s.opacity,p=void 0!==c,d=void 0!==f;(u.isArrayOrTypedArray(l)||p||d)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?i.opacity:t.mo;return t.selected?p?c:e:d?f:h*e});var m=i.color,g=a.color,y=s.color;(g||y)&&(e.selectedColorFn=function(t){var e=t.mcc||m;return t.selected?g||e:y||e});var v=i.size,_=a.size,x=s.size,b=void 0!==_,w=void 0!==x;return o.traceIs(t,"symbols")&&(b||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||v/2;return t.selected?b?_/2:e:w?x/2:e}),e},g.makeSelectedTextStyleFns=function(t){var e={},n=t.selected||{},r=t.unselected||{},i=t.textfont||{},a=n.textfont||{},o=r.textfont||{},l=i.color,u=a.color,c=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||l;return t.selected?u||e:c||(u?e:s.addOpacity(e,h))},e},g.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var n=g.makeSelectedPointStyleFns(e),i=e.marker||{},a=[];n.selectedOpacityFn&&a.push(function(t,e){t.style("opacity",n.selectedOpacityFn(e))}),n.selectedColorFn&&a.push(function(t,e){s.fill(t,n.selectedColorFn(e))}),n.selectedSizeFn&&a.push(function(t,e){var r=e.mx||i.symbol||0,a=n.selectedSizeFn(e);t.attr("d",x(g.symbolNumber(r),a)),e.mrc2=a}),a.length&&t.each(function(t){for(var e=r.select(this),n=0;n0?n:0}g.textPointStyle=function(t,e,n){if(t.size()){var i;if(e.selectedpoints){var a=g.makeSelectedTextStyleFns(e);i=a.selectedTextColorFn}t.each(function(t){var a=r.select(this),o=u.extractOption(t,e,"tx","text");if(o||0===o){var s=t.tp||e.textposition,l=S(t,e),f=i?i(t):t.tc||e.textfont.color;a.call(g.font,t.tf||e.textfont.family,l,f).text(o).call(c.convertToTspans,n).call(M,s,l,t.mrc)}else a.remove()})}},g.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var n=g.makeSelectedTextStyleFns(e);t.each(function(t){var i=r.select(this),a=n.selectedTextColorFn(t),o=t.tp||e.textposition,l=S(t,e);s.fill(i,a),M(i,o,l,t.mrc2||t.mrc)})}};var C=.5;function z(t,e,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=n[0]-e[0],l=n[1]-e[1],u=Math.pow(a*a+o*o,C/2),c=Math.pow(s*s+l*l,C/2),f=(c*c*a-u*u*s)*i,p=(c*c*o-u*u*l)*i,h=3*c*(u+c),d=3*u*(u+c);return[[r.round(e[0]+(h&&f/h),2),r.round(e[1]+(h&&p/h),2)],[r.round(e[0]-(d&&f/d),2),r.round(e[1]-(d&&p/d),2)]]}g.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,r="M"+t[0],i=[];for(n=1;n=1e4&&(g.savedBBoxes={},I=0),n&&(g.savedBBoxes[n]=y),I++,u.extendFlat({},y)},g.setClipUrl=function(t,e,n){if(e){var r=n._context,i=r._exportedPlot?"":r._baseUrl||"";t.attr("clip-path","url("+i+"#"+e+")")}else t.attr("clip-path",null)},g.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,n){return[e,n].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},g.setTranslate=function(t,e,n){var r=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[r]("transform")||"";return e=e||0,n=n||0,a=a.replace(/(\btranslate\(.*?\);?)/,"").trim(),a=(a+=" translate("+e+", "+n+")").trim(),t[i]("transform",a),a},g.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,n){return[e,n].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},g.setScale=function(t,e,n){var r=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[r]("transform")||"";return e=e||1,n=n||1,a=a.replace(/(\bscale\(.*?\);?)/,"").trim(),a=(a+=" scale("+e+", "+n+")").trim(),t[i]("transform",a),a};var D=/\s*sc.*/;g.setPointGroupScale=function(t,e,n){if(e=e||1,n=n||1,t){var r=1===e&&1===n?"":" scale("+e+","+n+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(D,"");t=(t+=r).trim(),this.setAttribute("transform",t)})}};var O=/translate\([^)]*\)\s*$/;g.setTextPointsScale=function(t,e,n){t&&t.each(function(){var t,i=r.select(this),a=i.select("text");if(a.node()){var o=parseFloat(a.attr("x")||0),s=parseFloat(a.attr("y")||0),l=(i.attr("transform")||"").match(O);t=1===e&&1===n?[]:["translate("+o+","+s+")","scale("+e+","+n+")","translate("+-o+","+-s+")"],l&&t.push(l),i.attr("transform",t.join(" "))}})}},{"../../constants/alignment":138,"../../constants/interactions":139,"../../constants/xmlns_namespaces":141,"../../lib":160,"../../lib/svg_text_utils":181,"../../registry":252,"../../traces/scatter/make_bubble_size_func":281,"../../traces/scatter/subtypes":288,"../color":43,"../colorscale":55,"./symbol_defs":65,d3:7,"fast-isnumeric":9,tinycolor2:26}],65:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+n+i+a+i+a+o+a+o+n+o+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+e+","+r.round(t/2,2)+"H"+e+"L0,-"+r.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+r.round(t/2,2)+"H"+e+"L0,"+r.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M"+r.round(t/2,2)+",-"+e+"V"+e+"L-"+r.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2);return"M-"+r.round(t/2,2)+",-"+e+"V"+e+"L"+r.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),i=r.round(-t,2),a=r.round(-.309*t,2);return"M"+e+","+a+"L"+n+","+r.round(.809*t,2)+"H-"+n+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),i=r.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+n+"V"+n+"L0,"+e+"L-"+i+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),i=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+i+"H"+n+"L"+e+",0L"+n+",-"+i+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),i=r.round(.951*e,2),a=r.round(.363*e,2),o=r.round(.588*e,2),s=r.round(-e,2),l=r.round(-.309*e,2),u=r.round(.118*e,2),c=r.round(.809*e,2);return"M"+n+","+l+"H"+i+"L"+a+","+u+"L"+o+","+c+"L0,"+r.round(.382*e,2)+"L-"+o+","+c+"L-"+a+","+u+"L-"+i+","+l+"H-"+n+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),i=r.round(.76*t,2);return"M-"+i+",0l-"+n+",-"+e+"h"+i+"l"+n+",-"+e+"l"+n+","+e+"h"+i+"l-"+n+","+e+"l"+n+","+e+"h-"+i+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),i=r.round(1.6*t,2),a=r.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+n+o+e+","+n+o+"0,-"+i+o+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),i=r.round(1.6*t,2),a=r.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+n+o+"-"+e+",-"+n+o+"0,"+i+o+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),i="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),i="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),i=r.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),i=r.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),i=r.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),i=r.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:7}],66:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],67:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),i=t("../../registry"),a=t("../../plots/cartesian/axes"),o=t("./compute_error");function s(t,e,n,i){var s=e["error_"+i]||{},l=[];if(s.visible&&-1!==["linear","log"].indexOf(n.type)){for(var u=o(s),c=0;c0;e.each(function(e){var f,p=e[0].trace,h=p.error_x||{},d=p.error_y||{};p.ids&&(f=function(t){return t.id});var m=o.hasMarkers(p)&&p.marker.maxdisplayed>0;d.visible||h.visible||(e=[]);var g=r.select(this).selectAll("g.errorbar").data(e,f);if(g.exit().remove(),e.length){h.visible||g.selectAll("path.xerror").remove(),d.visible||g.selectAll("path.yerror").remove(),g.style("opacity",1);var y=g.enter().append("g").classed("errorbar",!0);c&&y.style("opacity",0).transition().duration(s.duration).style("opacity",1),a.setClipUrl(g,n.layerClipId,t),g.each(function(t){var e=r.select(this),n=function(t,e,n){var r={x:e.c2p(t.x),y:n.c2p(t.y)};void 0!==t.yh&&(r.yh=n.c2p(t.yh),r.ys=n.c2p(t.ys),i(r.ys)||(r.noYS=!0,r.ys=n.c2p(t.ys,!0)));void 0!==t.xh&&(r.xh=e.c2p(t.xh),r.xs=e.c2p(t.xs),i(r.xs)||(r.noXS=!0,r.xs=e.c2p(t.xs,!0)));return r}(t,l,u);if(!m||t.vis){var a,o=e.select("path.yerror");if(d.visible&&i(n.x)&&i(n.yh)&&i(n.ys)){var f=d.width;a="M"+(n.x-f)+","+n.yh+"h"+2*f+"m-"+f+",0V"+n.ys,n.noYS||(a+="m-"+f+",0h"+2*f),!o.size()?o=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):c&&(o=o.transition().duration(s.duration).ease(s.easing)),o.attr("d",a)}else o.remove();var p=e.select("path.xerror");if(h.visible&&i(n.y)&&i(n.xh)&&i(n.xs)){var g=(h.copy_ystyle?d:h).width;a="M"+n.xh+","+(n.y-g)+"v"+2*g+"m0,-"+g+"H"+n.xs,n.noXS||(a+="m0,-"+g+"v"+2*g),!p.size()?p=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):c&&(p=p.transition().duration(s.duration).ease(s.easing)),p.attr("d",a)}else p.remove()}})}})}},{"../../traces/scatter/subtypes":288,"../drawing":64,d3:7,"fast-isnumeric":9}],72:[function(t,e,n){"use strict";var r=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},a=e.error_x||{},o=r.select(this);o.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(i.stroke,n.color),a.copy_ystyle&&(a=n),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":43,d3:7}],73:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:r({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":231}],74:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../registry");function a(t,e,n,i){i=i||r.identity,Array.isArray(t)&&(e[0][n]=i(t))}e.exports=function(t){var e=t.calcdata,n=t._fullLayout;function o(t){return function(e){return r.coerceHoverinfo({hoverinfo:e},{_module:t._module},n)}}for(var s=0;s=0&&n.indexw[0]._length||et<0||et>k[0]._length)return p.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,O="xval"in e?m.flat(l,e.xval):m.p2c(w,tt),R="yval"in e?m.flat(l,e.yval):m.p2c(k,et),!i(O[0])||!i(R[0]))return o.warn("Fx.hover failed",e,t),p.unhoverRaw(t,e)}var it=1/0;for(B=0;B$&&(Y.splice(0,$),it=Y[0].distance),v&&0!==X&&0===Y.length){G.distance=X,G.index=!1;var ut=j._module.hoverPoints(G,H,Z,"closest",c._hoverlayer);if(ut&&(ut=ut.filter(function(t){return t.spikeDistance<=X})),ut&&ut.length){var ct,ft=ut.filter(function(t){return t.xa.showspikes});if(ft.length){var pt=ft[0];i(pt.x0)&&i(pt.y0)&&(ct=gt(pt),(!K.vLinePoint||K.vLinePoint.spikeDistance>ct.spikeDistance)&&(K.vLinePoint=ct))}var ht=ut.filter(function(t){return t.ya.showspikes});if(ht.length){var dt=ht[0];i(dt.x0)&&i(dt.y0)&&(ct=gt(dt),(!K.hLinePoint||K.hLinePoint.spikeDistance>ct.spikeDistance)&&(K.hLinePoint=ct))}}}}function mt(t,e){for(var n,r=null,i=1/0,a=0;a1||Y.length>1)||"closest"===D&&Q&&Y.length>1,Et=f.combine(c.plot_bgcolor||f.background,c.paper_bgcolor),It={hovermode:D,rotateLabels:Lt,bgColor:Et,container:c._hoverlayer,outerContainer:c._paperdiv,commonLabelOpts:c.hoverlabel,hoverdistance:c.hoverdistance},Pt=A(Y,It,t);if(function(t,e,n){var r,i,a,o,s,l,u,c=0,f=1,p=t.map(function(t,r){var i=t[e],a="x"===i._id.charAt(0),o=i.range;return!r&&o&&o[0]>o[1]!==a&&(f=-1),[{i:r,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(a?_:1)/2,pmin:0,pmax:a?n.width:n.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function h(t){var e=t[0],n=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=n.pos+n.dp+n.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;r=!1}if(!(a<.01)){if(i<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=a;r=!1}if(r){var u=0;for(o=0;oe.pmax&&u++;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos>e.pmax-1&&(l.del=!0,u--);for(o=0;o=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(u<=0);o--)(l=t[o]).pos+l.dp+l.size>e.pmax&&(l.del=!0,u--)}}}for(;!r&&c<=t.length;){for(c++,r=!0,o=0;o.01&&g.pmin===y.pmin&&g.pmax===y.pmax){for(s=m.length-1;s>=0;s--)m[s].dp+=i;for(d.push.apply(d,m),p.splice(o+1,1),u=0,s=d.length-1;s>=0;s--)u+=d[s].dp;for(a=u/d.length,s=d.length-1;s>=0;s--)d[s].dp-=a;r=!1}else o++}p.forEach(h)}for(o=p.length-1;o>=0;o--){var v=p[o];for(s=v.length-1;s>=0;s--){var x=v[s],b=t[x.i];b.offset=x.dp,b.del=x.del}}}(Y,Lt?"xa":"ya",c),M(Pt,Lt),e.target&&e.target.tagName){var Dt=d.getComponentMethod("annotations","hasClickToShow")(t,Mt);u(r.select(e.target),Dt?"pointer":"")}if(!e.target||a||!function(t,e,n){if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var i=n[r],a=t._hoverdata[r];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber)||String(i.pointNumbers)!==String(a.pointNumbers))return!0}return!1}(t,0,At))return;At&&t.emit("plotly_unhover",{event:e,points:At});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:O,yvals:R})}(t,e,n,a)})},n.loneHover=function(t,e){var n={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1},i=r.select(e.container),a=e.outerContainer?r.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=A([n],o,e.gd);return M(s,o.rotateLabels),s.node()},n.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var n=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1}}),i=r.select(e.container),a=e.outerContainer?r.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=A(n,o,e.gd),l=0;return s.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5([\s\S]*)<\/extra>/;function A(t,e,n){var i=e.hovermode,a=e.rotateLabels,s=e.bgColor,u=e.container,p=e.outerContainer,h=e.commonLabelOpts||{},d=e.fontFamily||g.HOVERFONT,m=e.fontSize||g.HOVERFONTSIZE,v=t[0],_=v.xa,x=v.ya,b="y"===i?"yLabel":"xLabel",A=v[b],M=(String(A)||"").split(" ")[0],S=p.node().getBoundingClientRect(),C=S.top,z=S.width,L=S.height,E=void 0!==A&&v.distance<=e.hoverdistance&&("x"===i||"y"===i);if(E){var I,P,D=!0;for(I=0;I-1&&u.length>x&&(u=x>3?u.substr(0,x-3)+"...":u.substr(0,x))}void 0!==t.zLabel?(void 0!==t.xLabel&&(p+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(p+="y: "+t.yLabel+"
"),p+=(p?"z: ":"")+t.zLabel):E&&t[i+"Label"]===A?p=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(p=t.yLabel):p=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(p+=(p?"
":"")+t.text),void 0!==t.extraText&&(p+=(p?"
":"")+t.extraText),""===p&&(""===u&&e.remove(),p=u);var b=t.hovertemplate||!1,M=t.hovertemplateLabels||t,S=t.eventData[0]||{};b&&(p=(p=o.hovertemplateString(b,M,S)).replace(T,function(t,e){return u=e,""}));var I=e.select("text.nums").call(c.font,t.fontFamily||d,t.fontSize||m,t.fontColor||_).text(p).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,n),P=e.select("text.name"),D=0;u&&u!==p?(P.call(c.font,t.fontFamily||d,t.fontSize||m,v).text(u).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,n),D=P.node().getBoundingClientRect().width+2*k):(P.remove(),e.select("rect").remove()),e.select("path").style({fill:g,stroke:_});var O,R,F=I.node().getBoundingClientRect(),B=t.xa._offset+(t.x0+t.x1)/2,N=t.ya._offset+(t.y0+t.y1)/2,j=Math.abs(t.x1-t.x0),V=Math.abs(t.y1-t.y0),q=F.width+w+k+D;t.ty0=C-F.top,t.bx=F.width+2*k,t.by=F.height+2*k,t.anchor="start",t.txwidth=F.width,t.tx2width=D,t.offset=0,a?(t.pos=B,O=N+V/2+q<=L,R=N-V/2-q>=0,"top"!==t.idealAlign&&O||!R?O?(N+=V/2,t.anchor="start"):t.anchor="middle":(N-=V/2,t.anchor="end")):(t.pos=N,O=B+j/2+q<=z,R=B-j/2-q>=0,"left"!==t.idealAlign&&O||!R?O?(B+=j/2,t.anchor="start"):t.anchor="middle":(B-=j/2,t.anchor="end")),I.attr("text-anchor",t.anchor),D&&P.attr("text-anchor",t.anchor),e.attr("transform","translate("+B+","+N+")"+(a?"rotate("+y+")":""))}),F}function M(t,e){t.each(function(t){var n=r.select(this);if(t.del)n.remove();else{var i="end"===t.anchor?-1:1,a=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],s=o*(w+k),u=s+o*(t.txwidth+k),f=0,p=t.offset;"middle"===t.anchor&&(s-=t.tx2width/2,u+=t.txwidth/2+k),e&&(p*=-b,f=t.offset*x),n.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(p-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(i*w+f)+","+(w+p)+"v"+(t.by/2-w)+"h"+i*t.bx+"v-"+t.by+"H"+(i*w+f)+"V"+(p-w)+"Z"),a.call(l.positionText,s+f,p+t.ty0-t.by/2+k),t.tx2width&&(n.select("text.name").call(l.positionText,u+o*k+f,p+t.ty0-t.by/2+k),n.select("rect").call(c.setRect,u+(o-1)*t.tx2width/2+f,p-t.by/2-1,t.tx2width,t.by+2))}})}function S(t,e){var n=t.index,r=t.trace||{},i=t.cd[0],a=t.cd[n]||{},s=Array.isArray(n)?function(t,e){return o.castOption(i,n,t)||o.extractOption({},r,"",e)}:function(t,e){return o.extractOption(a,r,t,e)};function l(e,n,r){var i=s(n,r);i&&(t[e]=i)}if(l("hoverinfo","hi","hoverinfo"),l("bgcolor","hbg","hoverlabel.bgcolor"),l("borderColor","hbc","hoverlabel.bordercolor"),l("fontFamily","htf","hoverlabel.font.family"),l("fontSize","hts","hoverlabel.font.size"),l("fontColor","htc","hoverlabel.font.color"),l("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:h.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:h.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var u=h.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+u+" / -"+h.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+u,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var c=h.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+c+" / -"+h.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+c,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return f&&"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function C(t,e){var n,r,i=e.container,o=e.fullLayout,s=e.event,l=!!t.hLinePoint,u=!!t.vLinePoint;if(i.selectAll(".spikeline").remove(),u||l){var p=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(l){var h,d,m=t.hLinePoint;n=m&&m.xa,"cursor"===(r=m&&m.ya).spikesnap?(h=s.pointerX,d=s.pointerY):(h=n._offset+m.x,d=r._offset+m.y);var g,y,v=a.readability(m.color,p)<1.5?f.contrast(p):m.color,_=r.spikemode,x=r.spikethickness,b=r.spikecolor||v,w=r._boundingBox,k=(w.left+w.right)/20){for(var r=[],i=0;i-1?o="closest":(e._isHoriz=function(t){for(var e=!0,n=0;n1){p||h||d||"independent"===T("pattern")&&(p=!0),g._hasSubplotGrid=p;var _,x,b="top to bottom"===T("roworder"),w=p?.2:.1,k=p?.3:.1;m&&e._splomGridDflt&&(_=e._splomGridDflt.xside,x=e._splomGridDflt.yside),g._domains={x:c("x",T,w,_,v),y:c("y",T,k,x,y,b)}}else delete e.grid}function T(t,e){return r.coerce(n,g,l,t,e)}},contentDefaults:function(t,e){var n=e.grid;if(n&&n._domains){var r,i,a,o,s,l,c,p=t.grid||{},h=e._subplots,d=n._hasSubplotGrid,m=n.rows,g=n.columns,y="independent"===n.pattern,v=n._axisMap={};if(d){var _=p.subplots||[];l=n.subplots=new Array(m);var x=1;for(r=0;r1);if(!1!==_||h.uirevision){var x=a.newContainer(e,"legend");if(w("uirevision",e.uirevision),!1!==_){if(w("bgcolor",e.paper_bgcolor),w("bordercolor"),w("borderwidth"),i.coerceFont(w,"font",e.font),w("orientation"),"h"===x.orientation){var b=t.xaxis;r.getComponentMethod("rangeslider","isVisible")(b)?(u=0,f="left",c=1.1,p="bottom"):(u=0,f="left",c=-.1,p="top")}w("traceorder",g),l.isGrouped(e.legend)&&w("tracegroupgap"),w("x",u),w("xanchor",f),w("y",c),w("yanchor",p),w("valign"),i.noneOrAll(h,x,["x","y"])}}function w(t,e){return i.coerce(h,x,o,t,e)}}},{"../../lib":160,"../../plot_api/plot_template":194,"../../plots/layout_attributes":235,"../../registry":252,"./attributes":92,"./helpers":98}],95:[function(t,e,n){"use strict";var r=t("d3"),i=t("../../lib"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib/events"),l=t("../dragelement"),u=t("../drawing"),c=t("../color"),f=t("../../lib/svg_text_utils"),p=t("./handle_click"),h=t("./constants"),d=t("../../constants/interactions"),m=t("../../constants/alignment"),g=m.LINE_SPACING,y=m.FROM_TL,v=m.FROM_BR,_=t("./get_legend_data"),x=t("./style"),b=t("./helpers"),w=d.DBLCLICKDELAY;function k(t,e,n,r,i){var a=n.data()[0][0].trace,o={event:i,node:n.node(),curveNumber:a.index,expandedIndex:a._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(a._group&&(o.group=a._group),"pie"===a.type&&(o.label=n.datum()[0].label),!1!==s.triggerHandler(t,"plotly_legendclick",o))if(1===r)e._clickTimeout=setTimeout(function(){p(n,t,r)},w);else if(2===r){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==s.triggerHandler(t,"plotly_legenddoubleclick",o)&&p(n,t,r)}}function T(t,e,n){var r=t.data()[0][0],a=e._fullLayout,s=r.trace,l=o.traceIs(s,"pie"),c=s.index,p=l?r.label:s.name,d=e._context.edits.legendText&&!l,m=i.ensureSingle(t,"text","legendtext");function y(n){f.convertToTspans(n,e,function(){!function(t,e){var n=t.data()[0][0];if(!n.trace.showlegend)return void t.remove();var r,i,a=t.select("g[class*=math-group]"),o=a.node(),s=e._fullLayout.legend.font.size*g;if(o){var l=u.bBox(o);r=l.height,i=l.width,u.setTranslate(a,0,r/4)}else{var c=t.select(".legendtext"),p=f.lineCount(c),d=c.node();r=s*p,i=d?u.bBox(d).width:0;var m=s*(.3+(1-p)/2);f.positionText(c,h.textOffsetX,m),n.lineHeight=s}r=Math.max(r,16)+3,n.height=r,n.width=i}(t,e)})}m.attr("text-anchor","start").classed("user-select-none",!0).call(u.font,a.legend.font).text(d?A(p,n):p),f.positionText(m,h.textOffsetX,0),d?m.call(f.makeEditable,{gd:e,text:p}).call(y).on("edit",function(t){this.text(A(t,n)).call(y);var a=r.trace._fullInput||{},s={};if(o.hasTransform(a,"groupby")){var l=o.getTransformIndices(a,"groupby"),u=l[l.length-1],f=i.keyedContainer(a,"transforms["+u+"].styles","target","value.name");f.set(r.trace._group,t),s=f.constructUpdate()}else s.name=t;return o.call("_guiRestyle",e,s,c)}):y(m)}function A(t,e){var n=Math.max(4,e);if(t&&t.trim().length>=n/2)return t;for(var r=n-(t=t||"").length;r>0;r--)t+=" ";return t}function M(t,e){var n,a=1,o=i.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(c.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(n=(new Date).getTime())-e._legendMouseDownTimew&&(a=Math.max(a-1,1)),k(e,n,t,a,r.event)}})}function S(t,e,n){var i=t._fullLayout,a=i.legend,o=a.borderwidth,s=b.isGrouped(a),l=0;if(a._width=0,a._height=0,b.isVertical(a))s&&e.each(function(t,e){u.setTranslate(this,0,e*a.tracegroupgap)}),n.each(function(t){var e=t[0],n=e.height,r=e.width;u.setTranslate(this,o,5+o+a._height+n/2),a._height+=n,a._width=Math.max(a._width,r)}),a._width+=45+2*o,a._height+=10+2*o,s&&(a._height+=(a._lgroupsLength-1)*a.tracegroupgap),l=40;else if(s){for(var c=[a._width],f=e.data(),p=0,h=f.length;po+w-k,n.each(function(t){var e=t[0],n=g?40+t[0].width:_;o+x+k+n>i._size.w&&(x=0,y+=v,a._height=a._height+v,v=0),u.setTranslate(this,o+x,5+o+e.height/2+y),a._width+=k+n,a._height=Math.max(a._height,e.height),x+=k+n,v=Math.max(e.height,v)}),a._width+=2*o,a._height+=10+2*o}a._width=Math.ceil(a._width),a._height=Math.ceil(a._height);var T=t._context.edits.legendText||t._context.edits.legendPosition;n.each(function(t){var e=t[0],n=r.select(this).select(".legendtoggle");u.setRect(n,0,-e.height/2,(T?0:a._width)+l,e.height)})}function C(t){var e=t._fullLayout.legend,n="left";i.isRightAnchor(e)?n="right":i.isCenterAnchor(e)&&(n="center");var r="top";i.isBottomAnchor(e)?r="bottom":i.isMiddleAnchor(e)&&(r="middle"),a.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*y[n],r:e._width*v[n],b:e._height*v[r],t:e._height*y[r]})}e.exports=function(t){var e=t._fullLayout,n="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var s=e.legend,f=e.showlegend&&_(t.calcdata,s),p=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+n).remove(),void a.autoMargin(t,"legend");for(var d=0,m=0;mf?function(t){var e=t._fullLayout.legend,n="left";i.isRightAnchor(e)?n="right":i.isCenterAnchor(e)&&(n="center");a.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*y[n],r:e._width*v[n],b:0,t:0})}(t):C(t);var p=e._size,d=p.l+p.w*s.x,m=p.t+p.h*(1-s.y);i.isRightAnchor(s)?d-=s._width:i.isCenterAnchor(s)&&(d-=s._width/2),i.isBottomAnchor(s)?m-=s._height:i.isMiddleAnchor(s)&&(m-=s._height/2);var g=s._width,_=p.w;g>_?(d=p.l,g=_):(d+g>c&&(d=c-g),d<0&&(d=0),g=Math.min(c-d,s._width));var x,b,w,T,A=s._height,M=p.h;if(A>M?(m=p.t,A=M):(m+A>f&&(m=f-A),m<0&&(m=0),A=Math.min(f-m,s._height)),u.setTranslate(L,d,m),D.on(".drag",null),L.on("wheel",null),s._height<=A||t._context.staticPlot)I.attr({width:g-s.borderwidth,height:A-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),u.setTranslate(P,0,0),E.select("rect").attr({width:g-2*s.borderwidth,height:A-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth}),u.setClipUrl(P,n,t),u.setRect(D,0,0,0,0),delete s._scrollY;else{var F,B,N=Math.max(h.scrollBarMinHeight,A*A/s._height),j=A-N-2*h.scrollBarMargin,V=s._height-A,q=j/V,U=Math.min(s._scrollY||0,V);I.attr({width:g-2*s.borderwidth+h.scrollBarWidth+h.scrollBarMargin,height:A-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),E.select("rect").attr({width:g-2*s.borderwidth+h.scrollBarWidth+h.scrollBarMargin,height:A-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth+U}),u.setClipUrl(P,n,t),Z(U,N,q),L.on("wheel",function(){Z(U=i.constrain(s._scrollY+r.event.deltaY/j*V,0,V),N,q),0!==U&&U!==V&&r.event.preventDefault()});var H=r.behavior.drag().on("dragstart",function(){F=r.event.sourceEvent.clientY,B=U}).on("drag",function(){var t=r.event.sourceEvent;2===t.buttons||t.ctrlKey||Z(U=i.constrain((t.clientY-F)/q+B,0,V),N,q)});D.call(H)}function Z(e,n,r){s._scrollY=t._fullLayout.legend._scrollY=e,u.setTranslate(P,0,-e),u.setRect(D,g,h.scrollBarMargin+e*r,h.scrollBarWidth,n),E.select("rect").attr({y:s.borderwidth+e})}t._context.edits.legendPosition&&(L.classed("cursor-move",!0),l.init({element:L.node(),gd:t,prepFn:function(){var t=u.getTranslate(L);w=t.x,T=t.y},moveFn:function(t,e){var n=w+t,r=T+e;u.setTranslate(L,n,r),x=l.align(n,0,p.l,p.l+p.w,s.xanchor),b=l.align(r,0,p.t+p.h,p.t,s.yanchor)},doneFn:function(){void 0!==x&&void 0!==b&&o.call("_guiRelayout",t,{"legend.x":x,"legend.y":b})},clickFn:function(n,r){var i=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return r.clientX>=t.left&&r.clientX<=t.right&&r.clientY>=t.top&&r.clientY<=t.bottom});i.size()>0&&k(t,L,i,n,r)}}))}],t)}}},{"../../constants/alignment":138,"../../constants/interactions":139,"../../lib":160,"../../lib/events":152,"../../lib/svg_text_utils":181,"../../plots/plots":244,"../../registry":252,"../color":43,"../dragelement":61,"../drawing":64,"./constants":93,"./get_legend_data":96,"./handle_click":97,"./helpers":98,"./style":100,d3:7}],96:[function(t,e,n){"use strict";var r=t("../../registry"),i=t("./helpers");e.exports=function(t,e){var n,a,o={},s=[],l=!1,u={},c=0;function f(t,n){if(""!==t&&i.isGrouped(e))-1===s.indexOf(t)?(s.push(t),l=!0,o[t]=[[n]]):o[t].push([n]);else{var r="~~i"+c;s.push(r),o[r]=[[n]],c++}}for(n=0;nn[1])return n[1]}return i}function d(t){return t[0]}if(c||f||p){var m={},g={};if(c){m.mc=h("marker.color",d),m.mx=h("marker.symbol",d),m.mo=h("marker.opacity",a.mean,[.2,1]),m.mlc=h("marker.line.color",d),m.mlw=h("marker.line.width",a.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var y=h("marker.size",a.mean,[2,16]);m.ms=y,g.marker.size=y}p&&(g.line={width:h("line.width",d,[0,10])}),f&&(m.tx="Aa",m.tp=h("textposition",d),m.ts=10,m.tc=h("textfont.color",d),m.tf=h("textfont.family",d)),n=[a.minExtend(s,m)],(i=a.minExtend(u,g)).selectedpoints=null}var v=r.select(this).select("g.legendpoints"),_=v.selectAll("path.scatterpts").data(c?n:[]);_.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),_.exit().remove(),_.call(o.pointStyle,i,e),c&&(n[0].mrc=3);var x=v.selectAll("g.pointtext").data(f?n:[]);x.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),x.exit().remove(),x.selectAll("text").call(o.textPointStyle,i,e)}).each(function(t){var e=t[0].trace,n=r.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);n.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),n.exit().remove(),n.each(function(t,n){var i=e[n?"increasing":"decreasing"],a=i.line.width,o=r.select(this);o.style("stroke-width",a+"px").call(s.fill,i.fillcolor),a&&s.stroke(o,i.line.color)})}).each(function(t){var e=t[0].trace,n=r.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);n.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),n.exit().remove(),n.each(function(t,n){var i=e[n?"increasing":"decreasing"],a=i.line.width,l=r.select(this);l.style("fill","none").call(o.dashLine,i.line.dash,a),a&&s.stroke(l,i.line.color)})})}},{"../../lib":160,"../../registry":252,"../../traces/pie/style_one":262,"../../traces/scatter/subtypes":288,"../color":43,"../drawing":64,d3:7}],101:[function(t,e,n){"use strict";var r=t("../../registry"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),s=t("../../../build/ploticon"),l=o._,u=e.exports={};function c(t,e){var n,i,o=e.currentTarget,s=o.getAttribute("data-attr"),l=o.getAttribute("data-val")||!0,u=t._fullLayout,c={},f=a.list(t,null,!0),p="on";if("zoom"===s){var h,d="in"===l?.5:2,m=(1+d)/2,g=(1-d)/2;for(i=0;i1?(k=["toggleHover"],T=["resetViews"]):p?(w=["zoomInGeo","zoomOutGeo"],k=["hoverClosestGeo"],T=["resetGeo"]):f?(k=["hoverClosest3d"],T=["resetCameraDefault3d","resetCameraLastSave3d"]):g?(k=["toggleHover"],T=["resetViewMapbox"]):k=d?["hoverClosestGl2d"]:h?["hoverClosestPie"]:["toggleHover"];c&&(k=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!c&&!d||v||(w=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==T[0]&&(T=["resetScale2d"]));f?A=["zoom3d","pan3d","orbitRotation","tableRotation"]:(c||d)&&!v||m?A=["zoom2d","pan2d"]:g||p?A=["pan2d"]:y&&(A=["zoom2d"]);(function(t){for(var e=!1,n=0;n0)){var m=function(t,e,n){for(var r=n.filter(function(n){return e[n].anchor===t._id}),i=0,a=0;a0?p+u:u;return{ppad:u,ppadplus:c?d:m,ppadminus:c?m:d}}return{ppad:u}}function c(t,e,n,r,i){var s="category"===t.type||"multicategory"===t.type?t.r2c:t.d2c;if(void 0!==e)return[s(e),s(n)];if(r){var l,u,c,f,p=1/0,h=-1/0,d=r.match(a.segmentRE);for("date"===t.type&&(s=o.decodeDate(s)),l=0;lh&&(h=f)));return h>=p?[p,h]:void 0}}e.exports=function(t){var e=t._fullLayout,n=r.filterVisible(e.shapes);if(n.length&&t._fullData.length)for(var o=0;o10?t/2:10;return r.append("circle").attr({"data-line-point":"start-point",cx:O?U(n.xanchor)+n.x0:U(n.x0),cy:R?H(n.yanchor)-n.y0:H(n.y0),r:a}).style(i).classed("cursor-grab",!0),r.append("circle").attr({"data-line-point":"end-point",cx:O?U(n.xanchor)+n.x1:U(n.x1),cy:R?H(n.yanchor)-n.y1:H(n.y1),r:a}).style(i).classed("cursor-grab",!0),r}():e,W={element:$.node(),gd:t,prepFn:function(r){O&&(b=U(n.xanchor));R&&(w=H(n.yanchor));"path"===n.type?E=n.path:(y=O?n.x0:U(n.x0),v=R?n.y0:H(n.y0),_=O?n.x1:U(n.x1),x=R?n.y1:H(n.y1));y<_?(A=y,z="x0",M=_,L="x1"):(A=_,z="x1",M=y,L="x0");!R&&vx?(k=v,S="y0",T=x,C="y1"):(k=x,S="y1",T=v,C="y0");X(r),K(h,n),function(t,e,n){var r=e.xref,i=e.yref,o=a.getFromId(n,r),l=a.getFromId(n,i),u="";"paper"===r||o.autorange||(u+=r);"paper"===i||l.autorange||(u+=i);s.setClipUrl(t,u?"clip"+n._fullLayout._uid+u:null,n)}(e,n,t),W.moveFn="move"===I?Y:J},doneFn:function(){c(e),Q(h),d(e,t,n),r.call("_guiRelayout",t,N.getUpdateObj())},clickFn:function(){Q(h)}};function X(t){if(F)I="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var n=W.element.getBoundingClientRect(),r=n.right-n.left,i=n.bottom-n.top,a=t.clientX-n.left,o=t.clientY-n.top,s=!B&&r>P&&i>D&&!t.shiftKey?u.getCursor(a/r,1-o/i):"move";c(e,s),I=s.split("-")[0]}}function Y(r,i){if("path"===n.type){var a=function(t){return t},o=a,s=a;O?j("xanchor",n.xanchor=Z(b+r)):(o=function(t){return Z(U(t)+r)},V&&"date"===V.type&&(o=p.encodeDate(o))),R?j("yanchor",n.yanchor=G(w+i)):(s=function(t){return G(H(t)+i)},q&&"date"===q.type&&(s=p.encodeDate(s))),j("path",n.path=g(E,o,s))}else O?j("xanchor",n.xanchor=Z(b+r)):(j("x0",n.x0=Z(y+r)),j("x1",n.x1=Z(_+r))),R?j("yanchor",n.yanchor=G(w+i)):(j("y0",n.y0=G(v+i)),j("y1",n.y1=G(x+i)));e.attr("d",m(t,n)),K(h,n)}function J(r,i){if(B){var a=function(t){return t},o=a,s=a;O?j("xanchor",n.xanchor=Z(b+r)):(o=function(t){return Z(U(t)+r)},V&&"date"===V.type&&(o=p.encodeDate(o))),R?j("yanchor",n.yanchor=G(w+i)):(s=function(t){return G(H(t)+i)},q&&"date"===q.type&&(s=p.encodeDate(s))),j("path",n.path=g(E,o,s))}else if(F){if("resize-over-start-point"===I){var l=y+r,u=R?v-i:v+i;j("x0",n.x0=O?l:Z(l)),j("y0",n.y0=R?u:G(u))}else if("resize-over-end-point"===I){var c=_+r,f=R?x-i:x+i;j("x1",n.x1=O?c:Z(c)),j("y1",n.y1=R?f:G(f))}}else{var d=~I.indexOf("n")?k+i:k,N=~I.indexOf("s")?T+i:T,$=~I.indexOf("w")?A+r:A,W=~I.indexOf("e")?M+r:M;~I.indexOf("n")&&R&&(d=k-i),~I.indexOf("s")&&R&&(N=T-i),(!R&&N-d>D||R&&d-N>D)&&(j(S,n[S]=R?d:G(d)),j(C,n[C]=R?N:G(N))),W-$>P&&(j(z,n[z]=O?$:Z($)),j(L,n[L]=O?W:Z(W)))}e.attr("d",m(t,n)),K(h,n)}function K(t,e){(O||R)&&function(){var n="path"!==e.type,r=t.selectAll(".visual-cue").data([0]);r.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var a=U(O?e.xanchor:i.midRange(n?[e.x0,e.x1]:p.extractPathCoords(e.path,f.paramIsX))),o=H(R?e.yanchor:i.midRange(n?[e.y0,e.y1]:p.extractPathCoords(e.path,f.paramIsY)));if(a=p.roundPositionForSharpStrokeRendering(a,1),o=p.roundPositionForSharpStrokeRendering(o,1),O&&R){var s="M"+(a-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";r.attr("d",s)}else if(O){var l="M"+(a-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";r.attr("d",l)}else{var u="M"+(a-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";r.attr("d",u)}}()}function Q(t){t.selectAll(".visual-cue").remove()}u.init(W),$.node().onmousemove=X}(t,_,n,e,h)}}function d(t,e,n){var r=(n.xref+n.yref).replace(/paper/g,"");s.setClipUrl(t,r?"clip"+e._fullLayout._uid+r:null,e)}function m(t,e){var n,r,o,s,l,u,c,h,d=e.type,m=a.getFromId(t,e.xref),g=a.getFromId(t,e.yref),y=t._fullLayout._size;if(m?(n=p.shapePositionToRange(m),r=function(t){return m._offset+m.r2p(n(t,!0))}):r=function(t){return y.l+y.w*t},g?(o=p.shapePositionToRange(g),s=function(t){return g._offset+g.r2p(o(t,!0))}):s=function(t){return y.t+y.h*(1-t)},"path"===d)return m&&"date"===m.type&&(r=p.decodeDate(r)),g&&"date"===g.type&&(s=p.decodeDate(s)),function(t,e,n){var r=t.path,a=t.xsizemode,o=t.ysizemode,s=t.xanchor,l=t.yanchor;return r.replace(f.segmentRE,function(t){var r=0,u=t.charAt(0),c=f.paramIsX[u],p=f.paramIsY[u],h=f.numParams[u],d=t.substr(1).replace(f.paramRE,function(t){return c[r]?t="pixel"===a?e(s)+Number(t):e(t):p[r]&&(t="pixel"===o?n(l)-Number(t):n(t)),++r>h&&(t="X"),t});return r>h&&(d=d.replace(/[\s,]*X.*/,""),i.log("Ignoring extra params in segment "+t)),u+d})}(e,r,s);if("pixel"===e.xsizemode){var v=r(e.xanchor);l=v+e.x0,u=v+e.x1}else l=r(e.x0),u=r(e.x1);if("pixel"===e.ysizemode){var _=s(e.yanchor);c=_-e.y0,h=_-e.y1}else c=s(e.y0),h=s(e.y1);if("line"===d)return"M"+l+","+c+"L"+u+","+h;if("rect"===d)return"M"+l+","+c+"H"+u+"V"+h+"H"+l+"Z";var x=(l+u)/2,b=(c+h)/2,w=Math.abs(x-l),k=Math.abs(b-c),T="A"+w+","+k,A=x+w+","+b;return"M"+A+T+" 0 1,1 "+(x+","+(b-k))+T+" 0 0,1 "+A+"Z"}function g(t,e,n){return t.replace(f.segmentRE,function(t){var r=0,i=t.charAt(0),a=f.paramIsX[i],o=f.paramIsY[i],s=f.numParams[i];return i+t.substr(1).replace(f.paramRE,function(t){return r>=s?t:(a[r]?t=e(t):o[r]&&(t=n(t)),r++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var n in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var r=e._plots[n].shapelayer;r&&r.selectAll("path").remove()}for(var i=0;i0&&(s=s.transition().duration(e.transition.duration).ease(e.transition.easing)),s.attr("transform","translate("+(o-.5*c.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function S(t,e){var n=t._dims;return n.inputAreaStart+c.stepInset+(n.inputAreaLength-2*c.stepInset)*Math.min(1,Math.max(0,e))}function C(t,e){var n=t._dims;return Math.min(1,Math.max(0,(e-c.stepInset-n.inputAreaStart)/(n.inputAreaLength-2*c.stepInset-2*n.inputAreaStart)))}function z(t,e,n){var r=n._dims,i=s.ensureSingle(t,"rect",c.railTouchRectClass,function(r){r.call(T,e,t,n).style("pointer-events","all")});i.attr({width:r.inputAreaLength,height:Math.max(r.inputAreaWidth,c.tickOffset+n.ticklen+r.labelHeight)}).call(a.fill,n.bgcolor).attr("opacity",0),o.setTranslate(i,0,r.currentValueTotalHeight)}function L(t,e){var n=e._dims,r=n.inputAreaLength-2*c.railInset,i=s.ensureSingle(t,"rect",c.railRectClass);i.attr({width:r,height:c.railWidth,rx:c.railRadius,ry:c.railRadius,"shape-rendering":"crispEdges"}).call(a.stroke,e.bordercolor).call(a.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(i,c.railInset,.5*(n.inputAreaWidth-c.railWidth)+n.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,n=function(t,e){for(var n=t[c.name],r=[],i=0;i0?[0]:[]);function s(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),i.autoMargin(t,m(e))}if(a.enter().append("g").classed(c.containerClassName,!0).style("cursor","ew-resize"),a.exit().each(function(){r.select(this).selectAll("g."+c.groupClassName).each(s)}).remove(),0!==n.length){var l=a.selectAll("g."+c.groupClassName).data(n,g);l.enter().append("g").classed(c.groupClassName,!0),l.exit().each(s).remove();for(var u=0;u0||p<0){var m={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[v.side];e.attr("transform","translate("+m+")")}}}P.call(D),E&&(M?P.on(".opacity",null):(k=0,T=!0,P.text(g).on("mouseover.opacity",function(){r.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),P.call(c.makeEditable,{gd:t}).on("edit",function(e){void 0!==y?o.call("_guiRestyle",t,m,e,y):o.call("_guiRelayout",t,m,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(D)}).on("input",function(t){this.text(t||" ").call(c.positionText,_.x,_.y)}));return P.classed("js-placeholder",T),b}};var p=/ [XY][0-9]* /},{"../../constants/interactions":139,"../../lib":160,"../../lib/svg_text_utils":181,"../../plots/plots":244,"../../registry":252,"../color":43,"../drawing":64,d3:7,"fast-isnumeric":9}],132:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes"),l=t("../../plot_api/plot_template").templatedArray,u=l("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(l("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:u,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:a(s({editType:"arraydraw"}),{}),font:r({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":153,"../../plot_api/edit_types":187,"../../plot_api/plot_template":194,"../../plots/font_attributes":231,"../../plots/pad_attributes":243,"../color/attributes":42}],133:[function(t,e,n){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],134:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../plots/array_container_defaults"),a=t("./attributes"),o=t("./constants").name,s=a.buttons;function l(t,e,n){function o(n,i){return r.coerce(t,e,a,n,i)}o("visible",i(t,e,{name:"buttons",handleItemDefaults:u}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),r.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),r.coerceFont(o,"font",n.font),o("bgcolor",n.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function u(t,e){function n(n,i){return r.coerce(t,e,s,n,i)}n("visible","skip"===t.method||Array.isArray(t.args))&&(n("method"),n("args"),n("label"),n("execute"))}e.exports=function(t,e){i(t,e,{name:o,handleItemDefaults:l})}},{"../../lib":160,"../../plots/array_container_defaults":200,"./attributes":132,"./constants":133}],135:[function(t,e,n){"use strict";var r=t("d3"),i=t("../../plots/plots"),a=t("../color"),o=t("../drawing"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../../plot_api/plot_template").arrayEditor,c=t("../../constants/alignment").LINE_SPACING,f=t("./constants"),p=t("./scrollbox");function h(t){return t._index}function d(t,e){return+t.attr(f.menuIndexAttrName)===e._index}function m(t,e,n,r,i,a,o,s){e.active=o,u(t.layout,f.name,e).applyUpdate("active",o),"buttons"===e.type?y(t,r,null,null,e):"dropdown"===e.type&&(i.attr(f.menuIndexAttrName,"-1"),g(t,r,i,a,e),s||y(t,r,i,a,e))}function g(t,e,n,r,i){var a=s.ensureSingle(e,"g",f.headerClassName,function(t){t.style("pointer-events","all")}),l=i._dims,u=i.active,c=i.buttons[u]||f.blankHeaderOpts,p={y:i.pad.t,yPad:0,x:i.pad.l,xPad:0,index:0},h={width:l.headerWidth,height:l.headerHeight};a.call(v,i,c,t).call(M,i,p,h),s.ensureSingle(e,"text",f.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,i.font).text(f.arrowSymbol[i.direction])}).attr({x:l.headerWidth-f.arrowOffsetX+i.pad.l,y:l.headerHeight/2+f.textOffsetY+i.pad.t}),a.on("click",function(){n.call(S,String(d(n,i)?-1:i._index)),y(t,e,n,r,i)}),a.on("mouseover",function(){a.call(w)}),a.on("mouseout",function(){a.call(k,i)}),o.setTranslate(e,l.lx,l.ly)}function y(t,e,n,a,o){n||(n=e).attr("pointer-events","all");var l=function(t){return-1==+t.attr(f.menuIndexAttrName)}(n)&&"buttons"!==o.type?[]:o.buttons,u="dropdown"===o.type?f.dropdownButtonClassName:f.buttonClassName,c=n.selectAll("g."+u).data(s.filterVisible(l)),p=c.enter().append("g").classed(u,!0),h=c.exit();"dropdown"===o.type?(p.attr("opacity","0").transition().attr("opacity","1"),h.transition().attr("opacity","0").remove()):h.remove();var d=0,g=0,y=o._dims,_=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(_?g=y.headerHeight+f.gapButtonHeader:d=y.headerWidth+f.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(g=-f.gapButtonHeader+f.gapButton-y.openHeight),"dropdown"===o.type&&"left"===o.direction&&(d=-f.gapButtonHeader+f.gapButton-y.openWidth);var x={x:y.lx+d+o.pad.l,y:y.ly+g+o.pad.t,yPad:f.gapButton,xPad:f.gapButton,index:0},T={l:x.x+o.borderwidth,t:x.y+o.borderwidth};c.each(function(s,l){var u=r.select(this);u.call(v,o,s,t).call(M,o,x),u.on("click",function(){r.event.defaultPrevented||(m(t,o,0,e,n,a,l),s.execute&&i.executeAPICommand(t,s.method,s.args),t.emit("plotly_buttonclicked",{menu:o,button:s,active:o.active}))}),u.on("mouseover",function(){u.call(w)}),u.on("mouseout",function(){u.call(k,o),c.call(b,o)})}),c.call(b,o),_?(T.w=Math.max(y.openWidth,y.headerWidth),T.h=x.y-T.t):(T.w=x.x-T.l,T.h=Math.max(y.openHeight,y.headerHeight)),T.direction=o.direction,a&&(c.size()?function(t,e,n,r,i,a){var o,s,l,u=i.direction,c="up"===u||"down"===u,p=i._dims,h=i.active;if(c)for(s=0,l=0;l0?[0]:[]);if(o.enter().append("g").classed(f.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){r.select(this).selectAll("g."+f.headerGroupClassName).each(a)}).remove(),0!==n.length){var l=o.selectAll("g."+f.headerGroupClassName).data(n,h);l.enter().append("g").classed(f.headerGroupClassName,!0);for(var u=s.ensureSingle(o,"g",f.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),c=0;cw,A=s.barLength+2*s.barPad,M=s.barWidth+2*s.barPad,S=d,C=g+y;C+M>u&&(C=u-M);var z=this.container.selectAll("rect.scrollbar-horizontal").data(T?[0]:[]);z.exit().on(".drag",null).remove(),z.enter().append("rect").classed("scrollbar-horizontal",!0).call(i.fill,s.barColor),T?(this.hbar=z.attr({rx:s.barRadius,ry:s.barRadius,x:S,y:C,width:A,height:M}),this._hbarXMin=S+A/2,this._hbarTranslateMax=w-A):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var L=y>k,E=s.barWidth+2*s.barPad,I=s.barLength+2*s.barPad,P=d+m,D=g;P+E>l&&(P=l-E);var O=this.container.selectAll("rect.scrollbar-vertical").data(L?[0]:[]);O.exit().on(".drag",null).remove(),O.enter().append("rect").classed("scrollbar-vertical",!0).call(i.fill,s.barColor),L?(this.vbar=O.attr({rx:s.barRadius,ry:s.barRadius,x:P,y:D,width:E,height:I}),this._vbarYMin=D+I/2,this._vbarTranslateMax=k-I):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var R=this.id,F=c-.5,B=L?f+E+.5:f+.5,N=p-.5,j=T?h+M+.5:h+.5,V=o._topdefs.selectAll("#"+R).data(T||L?[0]:[]);if(V.exit().remove(),V.enter().append("clipPath").attr("id",R).append("rect"),T||L?(this._clipRect=V.select("rect").attr({x:Math.floor(F),y:Math.floor(N),width:Math.ceil(B)-Math.floor(F),height:Math.ceil(j)-Math.floor(N)}),this.container.call(a.setClipUrl,R,this.gd),this.bg.attr({x:d,y:g,width:m,height:y})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),T||L){var q=r.behavior.drag().on("dragstart",function(){r.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(q);var U=r.behavior.drag().on("dragstart",function(){r.event.sourceEvent.preventDefault(),r.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));T&&this.hbar.on(".drag",null).call(U),L&&this.vbar.on(".drag",null).call(U)}this.setTranslate(e,n)},s.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},s.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=r.event.dx),this.vbar&&(e-=r.event.dy),this.setTranslate(t,e)},s.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=r.event.deltaY),this.vbar&&(e+=r.event.deltaY),this.setTranslate(t,e)},s.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var n=t+this._hbarXMin,i=n+this._hbarTranslateMax;t=(o.constrain(r.event.x,n,i)-n)/(i-n)*(this.position.w-this._box.w)}if(this.vbar){var a=e+this._vbarYMin,s=a+this._vbarTranslateMax;e=(o.constrain(r.event.y,a,s)-a)/(s-a)*(this.position.h-this._box.h)}this.setTranslate(t,e)},s.prototype.setTranslate=function(t,e){var n=this.position.w-this._box.w,r=this.position.h-this._box.h;if(t=o.constrain(t||0,0,n),e=o.constrain(e||0,0,r),this.translateX=t,this.translateY=e,this.container.call(a.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var i=t/n;this.hbar.call(a.setTranslate,t+i*this._hbarTranslateMax,e)}if(this.vbar){var s=e/r;this.vbar.call(a.setTranslate,t,e+s*this._vbarTranslateMax)}}},{"../../lib":160,"../color":43,"../drawing":64,d3:7}],138:[function(t,e,n){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,CAP_SHIFT:.7,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],139:[function(t,e,n){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],140:[function(t,e,n){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],141:[function(t,e,n){"use strict";n.xmlns="http://www.w3.org/2000/xmlns/",n.svg="http://www.w3.org/2000/svg",n.xlink="http://www.w3.org/1999/xlink",n.svgAttrs={xmlns:n.svg,"xmlns:xlink":n.xlink}},{}],142:[function(t,e,n){"use strict";n.version="1.43.0",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config")();for(var r=t("./registry"),i=n.register=r.register,a=t("./plot_api"),o=Object.keys(a),s=0;s1/3&&t.x<2/3},n.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},n.isTopAnchor=function(t){return"top"===t.yanchor||"auto"===t.yanchor&&t.y>=2/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3}},{}],145:[function(t,e,n){"use strict";var r=t("./mod"),i=r.mod,a=r.modHalf,o=Math.PI,s=2*o;function l(t){return Math.abs(t[1]-t[0])>s-1e-15}function u(t,e){return a(e-t,s)}function c(t,e){if(l(e))return!0;var n,r;e[0](r=i(r,s))&&(r+=s);var a=i(t,s),o=a+s;return a>=n&&a<=r||o>=n&&o<=r}function f(t,e,n,r,i,a,u){i=i||0,a=a||0;var c,f,p,h,d,m=l([n,r]);function g(t,e){return[t*Math.cos(e)+i,a-t*Math.sin(e)]}m?(c=0,f=o,p=s):n=i&&t<=a);var i,a},pathArc:function(t,e,n,r,i){return f(null,t,e,n,r,i,0)},pathSector:function(t,e,n,r,i){return f(null,t,e,n,r,i,1)},pathAnnulus:function(t,e,n,r,i,a){return f(t,e,n,r,i,a,1)}}},{"./mod":167}],146:[function(t,e,n){"use strict";var r=Array.isArray,i="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},a="undefined"==typeof DataView?function(){}:DataView;function o(t){return i.isView(t)&&!(t instanceof a)}function s(t){return r(t)||o(t)}function l(t,e,n){if(s(t)){if(s(t[0])){for(var r=n,i=0;ii.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,i){t%1||!r(t)||void 0!==i.min&&ti.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var i="number"==typeof t;!0!==r.strict&&i?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){i(t).isValid()?e.set(t):e.set(n)}},colorlist:{coerceFunction:function(t,e,n){Array.isArray(t)&&t.length&&t.every(function(t){return i(t).isValid()})?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(o.get(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?e.set(c(+t,360)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n,r){var i=r.regex||u(n);"string"==typeof t&&i.test(t)?e.set(t):e.set(n)},validateFunction:function(t,e){var n=e.dflt;return t===n||"string"==typeof t&&!!u(n).test(t)}},flaglist:{coerceFunction:function(t,e,n,r){if("string"==typeof t)if(-1===(r.extras||[]).indexOf(t)){for(var i=t.split("+"),a=0;a=r&&t<=i?t:c}if("string"!=typeof t&&"number"!=typeof t)return c;t=String(t);var u=b(e),y=t.charAt(0);!u||"G"!==y&&"g"!==y||(t=t.substr(1),e="");var w=u&&"chinese"===e.substr(0,7),k=t.match(w?_:v);if(!k)return c;var T=k[1],A=k[3]||"1",M=Number(k[5]||1),S=Number(k[7]||0),C=Number(k[9]||0),z=Number(k[11]||0);if(u){if(2===T.length)return c;var L;T=Number(T);try{var E=g.getComponentMethod("calendars","getCal")(e);if(w){var I="i"===A.charAt(A.length-1);A=parseInt(A,10),L=E.newDate(T,E.toMonthIndex(T,A,I),M)}else L=E.newDate(T,Number(A),M)}catch(t){return c}return L?(L.toJD()-m)*f+S*p+C*h+z*d:c}T=2===T.length?(Number(T)+2e3-x)%100+x:Number(T),A-=1;var P=new Date(Date.UTC(2e3,A,M,S,C));return P.setUTCFullYear(T),P.getUTCMonth()!==A?c:P.getUTCDate()!==M?c:P.getTime()+z*d},r=n.MIN_MS=n.dateTime2ms("-9999"),i=n.MAX_MS=n.dateTime2ms("9999-12-31 23:59:59.9999"),n.isDateTime=function(t,e){return n.dateTime2ms(t,e)!==c};var k=90*f,T=3*p,A=5*h;function M(t,e,n,r,i){if((e||n||r||i)&&(t+=" "+w(e,2)+":"+w(n,2),(r||i)&&(t+=":"+w(r,2),i))){for(var a=4;i%10==0;)a-=1,i/=10;t+="."+w(i,a)}return t}n.ms2DateTime=function(t,e,n){if("number"!=typeof t||!(t>=r&&t<=i))return c;e||(e=0);var a,o,s,u,v,_,x=Math.floor(10*l(t+.05,1)),w=Math.round(t-x/10);if(b(n)){var S=Math.floor(w/f)+m,C=Math.floor(l(t,f));try{a=g.getComponentMethod("calendars","getCal")(n).fromJD(S).formatDate("yyyy-mm-dd")}catch(t){a=y("G%Y-%m-%d")(new Date(w))}if("-"===a.charAt(0))for(;a.length<11;)a="-0"+a.substr(1);else for(;a.length<10;)a="0"+a;o=e=r+f&&t<=i-f))return c;var e=Math.floor(10*l(t+.05,1)),n=new Date(Math.round(t-e/10));return M(a.time.format("%Y-%m-%d")(n),n.getHours(),n.getMinutes(),n.getSeconds(),10*n.getUTCMilliseconds()+e)},n.cleanDate=function(t,e,r){if(t===c)return e;if(n.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(b(r))return s.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=n.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!n.isDateTime(t,r))return s.error("unrecognized date",t),e;return t};var S=/%\d?f/g;function C(t,e,n,r){t=t.replace(S,function(t){var n=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(n).substr(2).replace(/0+$/,"")||"0"});var i=new Date(Math.floor(e+.05));if(b(r))try{t=g.getComponentMethod("calendars","worldCalFmt")(t,e,r)}catch(t){return"Invalid"}return n(t)(i)}var z=[59,59.9,59.99,59.999,59.9999];n.formatDate=function(t,e,n,r,i,a){if(i=b(i)&&i,!e)if("y"===n)e=a.year;else if("m"===n)e=a.month;else{if("d"!==n)return function(t,e){var n=l(t+.05,f),r=w(Math.floor(n/p),2)+":"+w(l(Math.floor(n/h),60),2);if("M"!==e){o(e)||(e=0);var i=(100+Math.min(l(t/d,60),z[e])).toFixed(e).substr(1);e>0&&(i=i.replace(/0+$/,"").replace(/[\.]$/,"")),r+=":"+i}return r}(t,n)+"\n"+C(a.dayMonthYear,t,r,i);e=a.dayMonth+"\n"+a.year}return C(e,t,r,i)};var L=3*f;n.incrementMonth=function(t,e,n){n=b(n)&&n;var r=l(t,f);if(t=Math.round(t-r),n)try{var i=Math.round(t/f)+m,a=g.getComponentMethod("calendars","getCal")(n),o=a.fromJD(i);return e%12?a.add(o,e,"m"):a.add(o,e/12,"y"),(o.toJD()-m)*f+r}catch(e){s.error("invalid ms "+t+" in calendar "+n)}var u=new Date(t+L);return u.setUTCMonth(u.getUTCMonth()+e)+r-L},n.findExactDates=function(t,e){for(var n,r,i=0,a=0,s=0,l=0,u=b(e)&&g.getComponentMethod("calendars","getCal")(e),c=0;c0&&(n.push(i),i=[])}return i.length>0&&n.push(i),n},n.makeLine=function(t){return 1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}},n.makePolygon=function(t){if(1===t.length)return{type:"Polygon",coordinates:t};for(var e=new Array(t.length),n=0;n1||m<0||m>1?null:{x:t+l*m,y:e+f*m}}function l(t,e,n,r,i){var a=r*t+i*e;if(a<0)return r*r+i*i;if(a>n){var o=r-t,s=i-e;return o*o+s*s}var l=r*e-i*t;return l*l/n}n.segmentsIntersect=s,n.segmentDistance=function(t,e,n,r,i,a,o,u){if(s(t,e,n,r,i,a,o,u))return 0;var c=n-t,f=r-e,p=o-i,h=u-a,d=c*c+f*f,m=p*p+h*h,g=Math.min(l(c,f,d,i-t,a-e),l(c,f,d,o-t,u-e),l(p,h,m,t-i,e-a),l(p,h,m,n-i,r-a));return Math.sqrt(g)},n.getTextLocation=function(t,e,n,s){if(t===i&&s===a||(r={},i=t,a=s),r[n])return r[n];var l=t.getPointAtLength(o(n-s/2,e)),u=t.getPointAtLength(o(n+s/2,e)),c=Math.atan((u.y-l.y)/(u.x-l.x)),f=t.getPointAtLength(o(n,e)),p={x:(4*f.x+l.x+u.x)/6,y:(4*f.y+l.y+u.y)/6,theta:c};return r[n]=p,p},n.clearLocationCache=function(){i=null},n.getVisibleSegment=function(t,e,n){var r,i,a=e.left,o=e.right,s=e.top,l=e.bottom,u=0,c=t.getTotalLength(),f=c;function p(e){var n=t.getPointAtLength(e);0===e?r=n:e===c&&(i=n);var u=n.xo?n.x-o:0,f=n.yl?n.y-l:0;return Math.sqrt(u*u+f*f)}for(var h=p(u);h;){if((u+=h+n)>f)return;h=p(u)}for(h=p(f);h;){if(u>(f-=h+n))return;h=p(f)}return{min:u,max:f,len:f-u,total:c,isClosed:0===u&&f===c&&Math.abs(r.x-i.x)<.1&&Math.abs(r.y-i.y)<.1}},n.findPointOnPath=function(t,e,n,r){for(var i,a,o,s=(r=r||{}).pathLength||t.getTotalLength(),l=r.tolerance||.001,u=r.iterationLimit||30,c=t.getPointAtLength(0)[n]>t.getPointAtLength(s)[n]?-1:1,f=0,p=0,h=s;f0?h=i:p=i,f++}return a}},{"./mod":167}],158:[function(t,e,n){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],159:[function(t,e,n){"use strict";e.exports=function(t){return t}},{}],160:[function(t,e,n){"use strict";var r=t("d3"),i=t("fast-isnumeric"),a=t("../constants/numerical"),o=a.FP_SAFE,s=a.BADNUM,l=e.exports={};l.nestedProperty=t("./nested_property"),l.keyedContainer=t("./keyed_container"),l.relativeAttr=t("./relative_attr"),l.isPlainObject=t("./is_plain_object"),l.toLogRange=t("./to_log_range"),l.relinkPrivateKeys=t("./relink_private");var u=t("./array");l.isTypedArray=u.isTypedArray,l.isArrayOrTypedArray=u.isArrayOrTypedArray,l.isArray1D=u.isArray1D,l.ensureArray=u.ensureArray,l.concat=u.concat,l.maxRowLength=u.maxRowLength,l.minRowLength=u.minRowLength;var c=t("./mod");l.mod=c.mod,l.modHalf=c.modHalf;var f=t("./coerce");l.valObjectMeta=f.valObjectMeta,l.coerce=f.coerce,l.coerce2=f.coerce2,l.coerceFont=f.coerceFont,l.coerceHoverinfo=f.coerceHoverinfo,l.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,l.validate=f.validate;var p=t("./dates");l.dateTime2ms=p.dateTime2ms,l.isDateTime=p.isDateTime,l.ms2DateTime=p.ms2DateTime,l.ms2DateTimeLocal=p.ms2DateTimeLocal,l.cleanDate=p.cleanDate,l.isJSDate=p.isJSDate,l.formatDate=p.formatDate,l.incrementMonth=p.incrementMonth,l.dateTick0=p.dateTick0,l.dfltRange=p.dfltRange,l.findExactDates=p.findExactDates,l.MIN_MS=p.MIN_MS,l.MAX_MS=p.MAX_MS;var h=t("./search");l.findBin=h.findBin,l.sorterAsc=h.sorterAsc,l.sorterDes=h.sorterDes,l.distinctVals=h.distinctVals,l.roundUp=h.roundUp,l.sort=h.sort,l.findIndexOfMin=h.findIndexOfMin;var d=t("./stats");l.aggNums=d.aggNums,l.len=d.len,l.mean=d.mean,l.midRange=d.midRange,l.variance=d.variance,l.stdev=d.stdev,l.interp=d.interp;var m=t("./matrix");l.init2dArray=m.init2dArray,l.transposeRagged=m.transposeRagged,l.dot=m.dot,l.translationMatrix=m.translationMatrix,l.rotationMatrix=m.rotationMatrix,l.rotationXYMatrix=m.rotationXYMatrix,l.apply2DTransform=m.apply2DTransform,l.apply2DTransform2=m.apply2DTransform2;var g=t("./angles");l.deg2rad=g.deg2rad,l.rad2deg=g.rad2deg,l.angleDelta=g.angleDelta,l.angleDist=g.angleDist,l.isFullCircle=g.isFullCircle,l.isAngleInsideSector=g.isAngleInsideSector,l.isPtInsideSector=g.isPtInsideSector,l.pathArc=g.pathArc,l.pathSector=g.pathSector,l.pathAnnulus=g.pathAnnulus;var y=t("./anchor_utils");l.isLeftAnchor=y.isLeftAnchor,l.isCenterAnchor=y.isCenterAnchor,l.isRightAnchor=y.isRightAnchor,l.isTopAnchor=y.isTopAnchor,l.isMiddleAnchor=y.isMiddleAnchor,l.isBottomAnchor=y.isBottomAnchor;var v=t("./geometry2d");l.segmentsIntersect=v.segmentsIntersect,l.segmentDistance=v.segmentDistance,l.getTextLocation=v.getTextLocation,l.clearLocationCache=v.clearLocationCache,l.getVisibleSegment=v.getVisibleSegment,l.findPointOnPath=v.findPointOnPath;var _=t("./extend");l.extendFlat=_.extendFlat,l.extendDeep=_.extendDeep,l.extendDeepAll=_.extendDeepAll,l.extendDeepNoArrays=_.extendDeepNoArrays;var x=t("./loggers");l.log=x.log,l.warn=x.warn,l.error=x.error;var b=t("./regex");l.counterRegex=b.counter;var w=t("./throttle");function k(t){var e={};for(var n in t)for(var r=t[n],i=0;io?s:i(t)?Number(t):s:s},l.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(i(t)&&t>=0&&t%1==0)},l.noop=t("./noop"),l.identity=t("./identity"),l.repeat=function(t,e){for(var n=new Array(e),r=0;rn?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},l.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},l.simpleMap=function(t,e,n,r){for(var i=t.length,a=new Array(i),o=0;o=Math.pow(2,n)?i>10?(l.warn("randstr failed uniqueness"),u):t(e,n,r,(i||0)+1):u},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={optionList:[],_newoption:function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)}};return n["_"+e]=t,n},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var n,r,i,a,o=t.length,s=2*o,l=2*e-1,u=new Array(l),c=new Array(o);for(n=0;n=s&&(i-=s*Math.floor(i/s)),i<0?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*u[r];c[n]=a}return c},l.syncOrAsync=function(t,e,n){var r;function i(){return l.syncOrAsync(t,e,n)}for(;t.length;)if((r=(0,t.splice(0,1)[0])(e))&&r.then)return r.then(i).then(void 0,l.promiseError);return n&&n(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,n){if(t){var r,i=!1,a=!0;for(r=0;r1?i+o[1]:"";if(a&&(o.length>1||s.length>4||n))for(;r.test(s);)s=s.replace(r,"$1"+a+"$2");return s+l};var M=/%{([^\s%{}:]*)(:[^}]*)?}/g,S=/^\w*$/;l.templateString=function(t,e){var n={};return t.replace(M,function(t,r){return S.test(r)?e[r]||"":(n[r]=n[r]||l.nestedProperty(e,r).get,n[r]()||"")})};var C=/^:/,z=0;l.hovertemplateString=function(t,e){var n=arguments,i={};return t.replace(M,function(t,a,o){var s,u,c;for(c=2;c=48&&o<=57,u=s>=48&&s<=57;if(l&&(r=10*r+o-48),u&&(i=10*i+s-48),!l||!u){if(r!==i)return r-i;if(o!==s)return o-s}}return i-r};var L=2e9;l.seedPseudoRandom=function(){L=2e9},l.pseudoRandom=function(){var t=L;return L=(69069*L+1)%4294967296,Math.abs(L-t)<429496729?l.pseudoRandom():L/4294967296}},{"../constants/numerical":140,"./anchor_utils":144,"./angles":145,"./array":146,"./clean_number":147,"./clear_responsive":149,"./coerce":150,"./dates":151,"./extend":153,"./filter_unique":154,"./filter_visible":155,"./geometry2d":157,"./get_graph_div":158,"./identity":159,"./is_plain_object":161,"./keyed_container":162,"./localize":163,"./loggers":164,"./make_trace_groups":165,"./matrix":166,"./mod":167,"./nested_property":168,"./noop":169,"./notifier":170,"./push_unique":173,"./regex":175,"./relative_attr":176,"./relink_private":177,"./search":178,"./stats":180,"./throttle":182,"./to_log_range":183,d3:7,"fast-isnumeric":9}],161:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],162:[function(t,e,n){"use strict";var r=t("./nested_property"),i=/^\w*$/;e.exports=function(t,e,n,a){var o,s,l;n=n||"name",a=a||"value";var u={};e&&e.length?(l=r(t,e),s=l.get()):s=t,e=e||"";var c={};if(s)for(o=0;o2)return u[e]=2|u[e],p.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],168:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),i=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(r(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,a,o,l=0,u=e.split(".");l/g),o=0;oa||u===i||us||e&&l(t))}:function(t,e){var l=t[0],u=t[1];if(l===i||la||u===i||us)return!1;var c,f,p,h,d,m=n.length,g=n[0][0],y=n[0][1],v=0;for(c=1;cMath.max(f,g)||u>Math.max(p,y)))if(uc||Math.abs(r(o,p))>i)return!0;return!1};a.filter=function(t,e){var n=[t[0]],r=0,i=0;function a(a){t.push(a);var s=n.length,l=r;n.splice(i+1);for(var u=l+1;u1&&a(t.pop());return{addPt:a,raw:t,filtered:n}}},{"../constants/numerical":140,"./matrix":166}],173:[function(t,e,n){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var n,r=e.toString();for(n=0;ni.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,n;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;ne}function u(t,e){return t>=e}n.findBin=function(t,e,n){if(r(e.start))return n?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var a,c,f=0,p=e.length,h=0,d=p>1?(e[p-1]-e[0])/(p-1):1;for(c=d>=0?n?o:s:n?u:l,t+=1e-9*d*(n?-1:1)*(d>=0?1:-1);f90&&i.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,i=e[r]-e[0]||1,a=i/(r||1)/1e4,o=[e[0]],s=0;se[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},n.roundUp=function(t,e,n){for(var r,i=0,a=e.length-1,o=0,s=n?0:1,l=n?1:0,u=n?Math.ceil:Math.floor;i0&&(r=1),n&&r)return t.sort(e)}return r?t:t.reverse()},n.findIndexOfMin=function(t,e){e=e||a;for(var n,r=1/0,i=0;ia.length)&&(o=a.length),r(e)||(e=!1),i(a[0])){for(l=new Array(o),s=0;st.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"./array":146,"fast-isnumeric":9}],181:[function(t,e,n){"use strict";var r=t("d3"),i=t("../lib"),a=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function s(t,e){return t.node().getBoundingClientRect()[e]}var l=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;n.convertToTspans=function(t,e,g){var S=t.text(),C=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&S.match(l),L=r.select(t.node().parentNode);if(!L.empty()){var E=t.attr("class")?t.attr("class").split(" ")[0]:"text";return E+="-math",L.selectAll("svg."+E).remove(),L.selectAll("g."+E+"-group").remove(),t.style("display",null).attr({"data-unformatted":S,"data-math":"N"}),C?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var n=parseInt(t.node().style.fontSize,10),a={fontSize:n};!function(t,e,n){var a,o,s,l;MathJax.Hub.Queue(function(){return o=i.extendDeepAll({},MathJax.Hub.config),s=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(a=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var n="math-output-"+i.randstr({},64);return l=r.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(u,"\\lt ").replace(c,"\\gt ")),MathJax.Hub.Typeset(l.node())},function(){var e=r.select("body").select("#MathJax_SVG_glyphs");if(l.select(".MathJax_SVG").empty()||!l.select("svg").node())i.log("There was an error in the tex syntax.",t),n();else{var o=l.select("svg").node().getBoundingClientRect();n(l.select(".MathJax_SVG"),e,o)}if(l.remove(),"SVG"!==a)return MathJax.Hub.setRenderer(a)},function(){return void 0!==s&&(MathJax.Hub.processSectionDelay=s),MathJax.Hub.Config(o)})}(C[2],a,function(r,i,a){L.selectAll("svg."+E).remove(),L.selectAll("g."+E+"-group").remove();var o=r&&r.select("svg");if(!o||!o.node())return I(),void e();var l=L.append("g").classed(E+"-group",!0).attr({"pointer-events":"none","data-unformatted":S,"data-math":"Y"});l.node().appendChild(o.node()),i&&i.node()&&o.node().insertBefore(i.node().cloneNode(!0),o.node().firstChild),o.attr({class:E,height:a.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=t.node().style.fill||"black";o.select("g").attr({fill:u,stroke:u});var c=s(o,"width"),f=s(o,"height"),p=+t.attr("x")-c*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],h=-(n||s(t,"height"))/4;"y"===E[0]?(l.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-c/2,h-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===E[0]?o.attr({x:t.attr("x"),y:h-f/2}):"a"===E[0]?o.attr({x:0,y:h}):o.attr({x:p,y:+t.attr("y")+h-f/2}),g&&g.call(t,l),e(l)})})):I(),t}function I(){L.empty()||(E=t.attr("class")+"-math",L.select("svg."+E).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(y," ");var n,s=!1,l=[],u=-1;function c(){u++;var e=document.createElementNS(a.svg,"tspan");r.select(e).attr({class:"line",dy:u*o+"em"}),t.appendChild(e),n=e;var i=l;if(l=[{node:e}],i.length>1)for(var s=1;s doesnt match end tag <"+t+">. Pretending it did match.",e),n=l[l.length-1].node}else i.log("Ignoring unexpected end tag .",e)}x.test(e)?c():(n=t,l=[{node:t}]);for(var L=e.split(v),E=0;E|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},p={sub:"0.3em",sup:"-0.6em"},h={sub:"-0.21em",sup:"0.42em"},d="\u200b",m=["http:","https:","mailto:","",void 0,":"],g=new RegExp("]*)?/?>","g"),y=/(\r\n?|\n)/g,v=/(<[^<>]*>)/,_=/<(\/?)([^ >]*)(\s+(.*))?>/i,x=//i,b=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,T=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function A(t,e){if(!t)return null;var n=t.match(e),r=n&&(n[3]||n[4]);return r&&z(r)}var M=/(^|;)\s*color:/;n.plainText=function(t){return(t||"").replace(g," ")};var S={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},C=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function z(t){return t.replace(C,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var n=String.fromCharCode;return t<=65535?n(t):n(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):S[e])||t})}function L(t,e,n){var r,i,a,o=n.horizontalAlign,s=n.verticalAlign||"top",l=t.node().getBoundingClientRect(),u=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-r.height}:"middle"===s?function(){return l.top+(l.height-r.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-r.width}:"center"===o?function(){return l.left+(l.width-r.width)/2}:function(){return l.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:i()-u.top+"px",left:a()-u.left+"px","z-index":1e3}),this}}n.convertEntities=z,n.lineCount=function(t){return t.selectAll("tspan.line").size()||1},n.positionText=function(t,e,n){return t.each(function(){var t=r.select(this);function i(e,n){return void 0===n?null===(n=t.attr(e))&&(t.attr(e,0),n=0):t.attr(e,n),n}var a=i("x",e),o=i("y",n);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:a,y:o})})},n.makeEditable=function(t,e){var n=e.gd,i=e.delegate,a=r.dispatch("edit","input","cancel"),o=i||t;if(t.style({"pointer-events":i?"none":"all"}),1!==t.size())throw new Error("boo");function s(){!function(){var i=r.select(n).select(".svg-container"),o=i.append("div"),s=t.node().style,u=parseFloat(s.fontSize||12),c=e.text;void 0===c&&(c=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":s.fontFamily||"Arial","font-size":u,color:e.fill||s.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-u/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(c).call(L(t,i,e)).on("blur",function(){n._editing=!1,t.text(this.textContent).style({opacity:1});var e,i=r.select(this).attr("class");(e=i?"."+i.split(" ")[0]+"-math-group":"[class*=-math-group]")&&r.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;r.select(this).transition().duration(0).remove(),r.select(document).on("mouseup",null),a.edit.call(t,o)}).on("focus",function(){var t=this;n._editing=!0,r.select(document).on("mouseup",function(){if(r.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===r.event.which?(n._editing=!1,t.style({opacity:1}),r.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),a.cancel.call(t,this.textContent)):(a.input.call(t,this.textContent),r.select(this).call(L(t,i,e)))}).on("keydown",function(){13===r.event.which&&this.blur()}).call(l)}(),t.style({opacity:0});var i,s=o.attr("class");(i=s?"."+s.split(" ")[0]+"-math-group":"[class*=-math-group]")&&r.select(t.node().parentNode).select(i).style({opacity:0})}function l(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}return e.immediate?s():o.on("click",s),r.rebind(t,a,"on")}},{"../constants/alignment":138,"../constants/xmlns_namespaces":141,"../lib":160,d3:7}],182:[function(t,e,n){"use strict";var r={};function i(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}n.throttle=function(t,e,n){var a=r[t],o=Date.now();if(!a){for(var s in r)r[s].tsa.ts+e?l():a.timer=setTimeout(function(){l(),a.timer=null},e)},n.done=function(t){var e=r[t];return e&&e.timer?new Promise(function(t){var n=e.onDone;e.onDone=function(){n&&n(),t(),e.onDone=null}}):Promise.resolve()},n.clear=function(t){if(t)i(r[t]),delete r[t];else for(var e in r)n.clear(e)}},{}],183:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var n=Math.log(Math.min(e[0],e[1]))/Math.LN10;return r(n)||(n=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),n}},{"fast-isnumeric":9}],184:[function(t,e,n){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],185:[function(t,e,n){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],186:[function(t,e,n){"use strict";var r=t("../registry");e.exports=function(t){for(var e,n,i=r.layoutArrayContainers,a=r.layoutArrayRegexes,o=t.split("[")[0],s=0;s0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},n.cleanLayout=function(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var a=(s.subplotsRegistry.cartesian||{}).attrRegex,l=(s.subplotsRegistry.polar||{}).attrRegex,c=(s.subplotsRegistry.ternary||{}).attrRegex,d=(s.subplotsRegistry.gl3d||{}).attrRegex,m=Object.keys(t);for(e=0;e3?(E.x=1.02,E.xanchor="left"):E.x<-2&&(E.x=-.02,E.xanchor="right"),E.y>3?(E.y=1.02,E.yanchor="bottom"):E.y<-2&&(E.y=-.02,E.yanchor="top")),h(t),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t.template&&t.template.layout&&n.cleanLayout(t.template.layout),t},n.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}n.hasParent=function(t,e){for(var n=_(e);n;){if(n in t)return!0;n=_(n)}return!1};var x=["x","y","z"];n.clearAxisTypes=function(t,e,n){for(var r=0;r1&&a.warn("Full array edits are incompatible with other edits",f);var v=n[""][""];if(u(v))e.set(null);else{if(!Array.isArray(v))return a.warn("Unrecognized full array edit value",f,v),!0;e.set(v)}return!m&&(p(g,y),h(t),!0)}var _,x,b,w,k,T,A,M,S=Object.keys(n).map(Number).sort(o),C=e.get(),z=C||[],L=c(y,f).get(),E=[],I=-1,P=z.length;for(_=0;_z.length-(A?0:1))a.warn("index out of range",f,b);else if(void 0!==T)k.length>1&&a.warn("Insertion & removal are incompatible with edits to the same index.",f,b),u(T)?E.push(b):A?("add"===T&&(T={}),z.splice(b,0,T),L&&L.splice(b,0,{})):a.warn("Unrecognized full object edit value",f,b,T),-1===I&&(I=b);else for(x=0;x=0;_--)z.splice(E[_],1),L&&L.splice(E[_],1);if(z.length?C||e.set(z):e.set(null),m)return!1;if(p(g,y),d!==i){var D;if(-1===I)D=S;else{for(P=Math.max(z.length,P),D=[],_=0;_=I);_++)D.push(b);for(_=I;_=t.data.length||i<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(i,r+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||i<0&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+n+" must be unique.")}}function D(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),P(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&P(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function O(t,e,n,r,a){!function(t,e,n,r){var i=o.isPlainObject(r);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof n)throw new Error("indices must be an integer or array of integers");for(var a in P(t,n,"indices"),e){if(!Array.isArray(e[a])||e[a].length!==n.length)throw new Error("attribute "+a+" must be an array of length equal to indices array length");if(i&&(!(a in r)||!Array.isArray(r[a])||r[a].length!==e[a].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,n,r);for(var l=function(t,e,n,r){var a,l,u,c,f,p=o.isPlainObject(r),h=[];for(var d in Array.isArray(n)||(n=[n]),n=I(n,t.data.length-1),e)for(var m=0;m-1?l(n,n.replace("titlefont","title.font")):n.indexOf("titleposition")>-1?l(n,n.replace("titleposition","title.position")):n.indexOf("titleside")>-1?l(n,n.replace("titleside","title.side")):n.indexOf("titleoffset")>-1&&l(n,n.replace("titleoffset","title.offset")):l(n,n.replace("title","title.text"));function l(e,n){t[n]=t[e],delete t[e]}}function U(t,e,n){if(t=o.getGraphDiv(t),k.clearPromiseQueue(t),t.framework&&t.framework.isPolar)return Promise.resolve(t);var r={};if("string"==typeof e)r[e]=n;else{if(!o.isPlainObject(e))return o.warn("Relayout fail.",e,n),Promise.reject();r=o.extendFlat({},e)}Object.keys(r).length&&(t.changed=!0);var i=X(t,r),a=i.flags;a.calc&&(t.calcdata=void 0);var s=[p.previousPromises];a.layoutReplot?s.push(T.layoutReplot):Object.keys(r).length&&(H(t,a,i)||p.supplyDefaults(t),a.legend&&s.push(T.doLegend),a.layoutstyle&&s.push(T.layoutStyles),a.axrange&&Z(s,i.rangesAltered),a.ticks&&s.push(T.doTicksRelayout),a.modebar&&s.push(T.doModeBar),a.camera&&s.push(T.doCamera),s.push(C)),s.push(p.rehover),u.add(t,U,[t,i.undoit],U,[t,i.redoit]);var l=o.syncOrAsync(s,t);return l&&l.then||(l=Promise.resolve(t)),l.then(function(){return t.emit("plotly_relayout",i.eventData),t})}function H(t,e,n){var r;if(!e.axrange)return!1;for(r in e)if("axrange"!==r&&e[r])return!1;for(r in n.rangesAltered){var i=d.id2name(r),a=t.layout[i],o=t._fullLayout[i];o.autorange=a.autorange,o.range=a.range.slice(),o.cleanRange()}return!0}function Z(t,e){var n=e?function(t){var n={skipTitle:!0};for(var r in e)if(d.getFromId(t,r).automargin){n={};break}return d.draw(t,Object.keys(e),n)}:function(t){return d.draw(t,"redraw")};t.push(T.doAutoRangeAndConstraints,n,T.drawData,T.finalDraw)}n.plot=function(t,e,i,a){var s;if(t=o.getGraphDiv(t),l.init(t),o.isPlainObject(e)){var u=e;e=u.data,i=u.layout,a=u.config,s=u.frames}if(!1===l.triggerHandler(t,"plotly_beforeplot",[e,i,a]))return Promise.reject();e||i||o.isPlotDiv(t)||o.warn("Calling Plotly.plot as if redrawing but this container doesn't yet have a plot.",t),E(t,a),i||(i={}),r.select(t).classed("js-plotly-plot",!0),m.makeTester(),Array.isArray(t._promises)||(t._promises=[]);var f=0===(t.data||[]).length&&Array.isArray(e);if(Array.isArray(e)&&(k.cleanData(e),f?t.data=e:t.data.push.apply(t.data,e),t.empty=!1),t.layout&&!f||(t.layout=k.cleanLayout(i)),t._dragging&&!t._transitioning)return t._replotPending=!0,Promise.reject();t._replotPending=!1,p.supplyDefaults(t);var g=t._fullLayout,_=g._has("cartesian");if(!g._has("polar")&&e&&e[0]&&e[0].r)return o.log("Legacy polar charts are deprecated!"),function(t,e,n){var i=r.select(t).selectAll(".plot-container").data([0]);i.enter().insert("div",":first-child").classed("plot-container plotly",!0);var a=i.selectAll(".svg-container").data([0]);a.enter().append("div").classed("svg-container",!0).style("position","relative"),a.html(""),e&&(t.data=e);n&&(t.layout=n);h.manager.fillLayout(t),a.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=h.manager.framework(t),t.framework({data:t.data,layout:t.layout},a.node()),t.framework.setUndoPoint();var s=t.framework.svg(),l=1,u=t._fullLayout.title?t._fullLayout.title.text:"";""!==u&&u||(l=0);var c=function(){this.call(x.convertToTspans,t)},f=s.select(".title-group text").call(c);if(t._context.edits.titleText){var d=o._(t,"Click to enter Plot title");u&&u!==d||(l=.2,f.attr({"data-unformatted":d}).text(d).style({opacity:l}).on("mouseover.opacity",function(){r.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(1e3).style("opacity",0)}));var m=function(){this.call(x.makeEditable,{gd:t}).on("edit",function(e){t.framework({layout:{title:{text:e}}}),this.text(e).call(c),this.call(m)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};f.call(m)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),p.addLinks(t),Promise.resolve()}(t,e,i);g._replotting=!0,f&&st(t),t.framework!==st&&(t.framework=st,st(t)),m.initGradients(t),f&&d.saveShowSpikeInitial(t);var b=!t.calcdata||t.calcdata.length!==(t._fullData||[]).length;b&&p.doCalcdata(t);for(var w=0;w=0&&n=0&&n0&&"string"!=typeof P.parts[O];)O--;var R=P.parts[O],F=P.parts[O-1]+"."+R,j=P.parts.slice(0,O).join("."),V=s(t.layout,j).get(),U=s(l,j).get(),H=P.get();if(void 0!==D){T[I]=D,S[I]="reverse"===R?D:B(H);var Z=f.getLayoutValObject(l,P.parts);if(Z&&Z.impliedEdits&&null!==D)for(var X in Z.impliedEdits)C(o.relativeAttr(I,X),Z.impliedEdits[X]);if(-1!==["width","height"].indexOf(I))if(D){C("autosize",null);var J="height"===I?"width":"height";C(J,l[J])}else l[I]=t._initialAutoSize[I];else if("autosize"===I)C("width",D?null:l.width),C("height",D?null:l.height);else if(F.match(G))E(F),s(l,j+"._inputRange").set(null);else if(F.match($)){E(F),s(l,j+"._inputRange").set(null);var K=s(l,j).get();K._inputDomain&&(K._input.domain=K._inputDomain.slice())}else F.match(W)&&s(l,j+"._inputDomain").set(null);if("type"===R){var Q=V,tt="linear"===U.type&&"log"===D,et="log"===U.type&&"linear"===D;if(tt||et){if(Q&&Q.range)if(U.autorange)tt&&(Q.range=Q.range[1]>Q.range[0]?[1,2]:[2,1]);else{var nt=Q.range[0],rt=Q.range[1];tt?(nt<=0&&rt<=0&&C(j+".autorange",!0),nt<=0?nt=rt/1e6:rt<=0&&(rt=nt/1e6),C(j+".range[0]",Math.log(nt)/Math.LN10),C(j+".range[1]",Math.log(rt)/Math.LN10)):(C(j+".range[0]",Math.pow(10,nt)),C(j+".range[1]",Math.pow(10,rt)))}else C(j+".autorange",!0);Array.isArray(l._subplots.polar)&&l._subplots.polar.length&&l[P.parts[0]]&&"radialaxis"===P.parts[1]&&delete l[P.parts[0]]._subplot.viewInitial["radialaxis.range"],c.getComponentMethod("annotations","convertCoords")(t,U,D,C),c.getComponentMethod("images","convertCoords")(t,U,D,C)}else C(j+".autorange",!0),C(j+".range",null);s(l,j+"._inputRange").set(null)}else if(R.match(M)){var it=s(l,I).get(),at=(D||{}).type;at&&"-"!==at||(at="linear"),c.getComponentMethod("annotations","convertCoords")(t,it,at,C),c.getComponentMethod("images","convertCoords")(t,it,at,C)}var ot=w.containerArrayMatch(I);if(ot){n=ot.array,r=ot.index;var st=ot.property,lt=Z||{editType:"calc"};""!==r&&""===st&&(w.isAddVal(D)?S[I]=null:w.isRemoveVal(D)?S[I]=(s(a,n).get()||[])[r]:o.warn("unrecognized full object value",e)),A.update(b,lt),y[n]||(y[n]={});var ut=y[n][r];ut||(ut=y[n][r]={}),ut[st]=D,delete e[I]}else"reverse"===R?(V.range?V.range.reverse():(C(j+".autorange",!0),V.range=[1,0]),U.autorange?b.calc=!0:b.plot=!0):(l._has("scatter-like")&&l._has("regl")&&"dragmode"===I&&("lasso"===D||"select"===D)&&"lasso"!==H&&"select"!==H?b.plot=!0:Z?A.update(b,Z):b.calc=!0,P.set(D))}}for(n in y){w.applyContainerArrayChanges(t,p(a,n),y[n],b,p)||(b.plot=!0)}var ct=l._axisConstraintGroups||[];for(z in L)for(r=0;r1;)if(r.pop(),void 0!==(n=s(e,r.join(".")+".uirevision").get()))return n;return e.uirevision}function rt(t,e){for(var n=0;n=i.length?i[0]:i[t]:i}function l(t){return Array.isArray(a)?t>=a.length?a[0]:a[t]:a}function u(t,e){var n=0;return function(){if(t&&++n===e)return t()}}return void 0===r._frameWaitingCnt&&(r._frameWaitingCnt=0),new Promise(function(a,c){function f(){r._currentFrame&&r._currentFrame.onComplete&&r._currentFrame.onComplete();var e=r._currentFrame=r._frameQueue.shift();if(e){var n=e.name?e.name.toString():null;t._fullLayout._currentFrame=n,r._lastFrameAt=Date.now(),r._timeToNext=e.frameOpts.duration,p.transition(t,e.frame.data,e.frame.layout,k.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:n,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(r._animationRaf),r._animationRaf=null}function h(){t.emit("plotly_animating"),r._lastFrameAt=-1/0,r._timeToNext=0,r._runningTransitions=0,r._currentFrame=null;var e=function(){r._animationRaf=window.requestAnimationFrame(e),Date.now()-r._lastFrameAt>r._timeToNext&&f()};e()}var d,m,g=0;function y(t){return Array.isArray(i)?g>=i.length?t.transitionOpts=i[g]:t.transitionOpts=i[0]:t.transitionOpts=i,g++,t}var v=[],_=null==e,x=Array.isArray(e);if(!_&&!x&&o.isPlainObject(e))v.push({type:"object",data:y(o.extendFlat({},e))});else if(_||-1!==["string","number"].indexOf(typeof e))for(d=0;d0&&TT)&&A.push(m);v=A}}v.length>0?function(e){if(0!==e.length){for(var i=0;i=0;r--)if(o.isPlainObject(e[r])){var m=e[r].name,g=(c[m]||d[m]||{}).name,y=e[r].name,v=c[g]||d[g];g&&y&&"number"==typeof y&&v&&S<5&&(S++,o.warn('addFrames: overwriting frame "'+(c[g]||d[g]).name+'" with a frame whose name of type "number" also equates to "'+g+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===S&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),d[m]={name:m},h.push({frame:p.supplyFrameDefaults(e[r]),index:n&&void 0!==n[r]&&null!==n[r]?n[r]:f+r})}h.sort(function(t,e){return t.index>e.index?-1:t.index=0;r--){if("number"==typeof(i=h[r].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!i.name)for(;c[i.name="frame "+t._transitionData._counter++];);if(c[i.name]){for(a=0;a=0;n--)r=e[n],a.push({type:"delete",index:r}),s.unshift({type:"insert",index:r,value:i[r]});var l=p.modifyFrames,c=p.modifyFrames,f=[t,s],h=[t,a];return u&&u.add(t,l,f,c,h),p.modifyFrames(t,a)},n.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},n=t._fullData||[];return p.cleanPlot([],{},n,e),p.purge(t),l.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":43,"../components/colorbar/connect":45,"../components/drawing":64,"../constants/xmlns_namespaces":141,"../lib":160,"../lib/events":152,"../lib/queue":174,"../lib/svg_text_utils":181,"../plots/cartesian/axes":204,"../plots/cartesian/constants":210,"../plots/cartesian/graph_interact":214,"../plots/plots":244,"../plots/polar/legacy":247,"../registry":252,"./edit_types":187,"./helpers":188,"./manage_arrays":190,"./plot_config":192,"./plot_schema":193,"./subroutines":195,d3:7,"fast-isnumeric":9,"has-hover":11}],192:[function(t,e,n){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,showSendToCloud:!1,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,watermark:!1,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],193:[function(t,e,n){"use strict";var r=t("../registry"),i=t("../lib"),a=t("../plots/attributes"),o=t("../plots/layout_attributes"),s=t("../plots/frame_attributes"),l=t("../plots/animation_attributes"),u=t("../plots/polar/legacy/area_attributes"),c=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),p=i.extendFlat,h=i.extendDeepAll,d=i.isPlainObject,m="_isSubplotObj",g="_isLinkedToArray",y=[m,g,"_arrayAttrRegexps","_deprecated"];function v(t,e,n){if(!t)return!1;if(t._isLinkedToArray)if(_(e[n]))n++;else if(n=a.length)return!1;if(2===t.dimensions){if(n++,e.length===n)return t;var o=e[n];if(!_(o))return!1;t=a[i][o]}else t=a[i]}else t=a}}return t}function _(t){return t===Math.round(t)&&t>=0}function x(t){return function(t){n.crawl(t,function(t,e,r){n.isValObject(t)?"data_array"===t.valType?(t.role="data",r[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(r[e+"src"]={valType:"string",editType:"none"}):d(t)&&(t.role="object")})}(t),function(t){n.crawl(t,function(t,e,n){if(!t)return;var r=t[g];if(!r)return;delete t[g],n[e]={items:{}},n[e].items[r]=t,n[e].role="object"})}(t),function(t){!function t(e){for(var n in e)if(d(e[n]))t(e[n]);else if(Array.isArray(e[n]))for(var r=0;r=l.length)return!1;i=(n=(r.transformsRegistry[l[c].type]||{}).attributes)&&n[e[2]],s=3}else if("area"===t.type)i=u[o];else{var f=t._module;if(f||(f=(r.modules[t.type||a.type.dflt]||{})._module),!f)return!1;if(!(i=(n=f.attributes)&&n[o])){var p=f.basePlotModule;p&&p.attributes&&(i=p.attributes[o])}i||(i=a[o])}return v(i,e,s)},n.getLayoutValObject=function(t,e){return v(function(t,e){var n,i,a,s,l=t._basePlotModules;if(l){var u;for(n=0;n=i&&(n._input||{})._templateitemname;s&&(o=i);var l,u=e+"["+o+"]";function c(){l={},s&&(l[u]={},l[u][a]=s)}function f(t,e){s?r.nestedProperty(l[u],t).set(e):l[u+"."+t]=e}function p(){var t=l;return c(),t}return c(),{modifyBase:function(t,e){l[t]=e},modifyItem:f,getUpdateObj:p,applyUpdate:function(e,n){e&&f(e,n);var i=p();for(var a in i)r.nestedProperty(t,a).set(i[a])}}}},{"../lib":160,"../plots/attributes":201}],195:[function(t,e,n){"use strict";var r=t("d3"),i=t("../registry"),a=t("../plots/plots"),o=t("../lib"),s=t("../lib/clear_gl_canvases"),l=t("../components/color"),u=t("../components/drawing"),c=t("../components/titles"),f=t("../components/modebar"),p=t("../plots/cartesian/axes"),h=t("../constants/alignment"),d=t("../plots/cartesian/constraints"),m=d.enforce,g=d.clean,y=t("../plots/cartesian/autorange").doAutoRange,v="start",_="middle",x="end";function b(t,e,n){for(var r=0;r=t[1]||i[1]<=t[0])&&(a[0]e[0]))return!0}return!1}function w(t){var e,i,a,s,c,d,m=t._fullLayout,g=m._size,y=g.p,v=p.list(t,"",!0);if(m._paperdiv.style({width:t._context.responsive&&m.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":m.width+"px",height:t._context.responsive&&m.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":m.height+"px"}).selectAll(".main-svg").call(u.setSize,m.width,m.height),t._context.setBackground(t,m.paper_bgcolor),n.drawMainTitle(t),f.manage(t),!m._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function _(t,e,n){var r=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===n?e._offset-y-r:e._offset+e._length+y+r:g.t+g.h*(1-(t.position||0))+r%1:e?"right"===n?e._offset+e._length+y+r:e._offset-y-r:g.l+g.w*(t.position||0)+r%1}for(e=0;ek?c.push({code:"unused",traceType:v,templateCount:w,dataCount:k}):k>w&&c.push({code:"reused",traceType:v,templateCount:w,dataCount:k})}}else c.push({code:"data"});if(function t(e,n){for(var r in e)if("_"!==r.charAt(0)){var a=e[r],o=h(e,r,n);i(a)?(Array.isArray(e)&&!1===a._template&&a.templateitemname&&c.push({code:"missing",path:o,templateitemname:a.templateitemname}),t(a,o)):Array.isArray(a)&&d(a)&&t(a,o)}}({data:g,layout:p},""),c.length)return c.map(m)}},{"../lib":160,"../plots/attributes":201,"../plots/plots":244,"./plot_config":192,"./plot_schema":193,"./plot_template":194}],197:[function(t,e,n){"use strict";var r=t("./plot_api"),i=t("../lib"),a=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),s=t("../snapshot/svgtoimg"),l={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},u=/^data:image\/\w+;base64,/;e.exports=function(t,e){var n,c,f;function p(t){return!(t in e)||i.validate(e[t],l[t])}if(e=e||{},i.isPlainObject(t)?(n=t.data||[],c=t.layout||{},f=t.config||{}):(t=i.getGraphDiv(t),n=i.extendDeep([],t.data),c=i.extendDeep({},t.layout),f=t._context),!p("width")||!p("height"))throw new Error("Height and width should be pixel values.");if(!p("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var h={};function d(t,n){return i.coerce(e,h,l,t,n)}var m=d("format"),g=d("width"),y=d("height"),v=d("scale"),_=d("setBackground"),x=d("imageDataOnly"),b=document.createElement("div");b.style.position="absolute",b.style.left="-5000px",document.body.appendChild(b);var w=i.extendFlat({},c);g&&(w.width=g),y&&(w.height=y);var k=i.extendFlat({},f,{_exportedPlot:!0,staticPlot:!0,setBackground:_}),T=a.getRedrawFunc(b);function A(){return new Promise(function(t){setTimeout(t,a.getDelay(b._fullLayout))})}function M(){return new Promise(function(t,e){var n=o(b,m,v),a=b._fullLayout.width,l=b._fullLayout.height;if(r.purge(b),document.body.removeChild(b),"svg"===m)return t(x?n:"data:image/svg+xml,"+encodeURIComponent(n));var u=document.createElement("canvas");u.id=i.randstr(),s({format:m,width:a,height:l,scale:v,canvas:u,svg:n,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){r.plot(b,n,w,k).then(T).then(A).then(M).then(function(e){t(function(t){return x?t.replace(u,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":160,"../snapshot/helpers":256,"../snapshot/svgtoimg":258,"../snapshot/tosvg":260,"./plot_api":191}],198:[function(t,e,n){"use strict";var r=t("../lib"),i=t("../plots/plots"),a=t("./plot_schema"),o=t("./plot_config"),s=r.isPlainObject,l=Array.isArray,u=r.isArrayOrTypedArray;function c(t,e,n,i,a,o){o=o||[];for(var f=Object.keys(t),p=0;p_.length&&i.push(h("unused",a,y.concat(_.length)));var T,A,M,S,C,z=_.length,L=Array.isArray(k);if(L&&(z=Math.min(z,k.length)),2===x.dimensions)for(A=0;A_[A].length&&i.push(h("unused",a,y.concat(A,_[A].length)));var E=_[A].length;for(T=0;T<(L?Math.min(E,k[A].length):E);T++)M=L?k[A][T]:k,S=v[A][T],C=_[A][T],r.validate(S,M)?C!==S&&C!==+S&&i.push(h("dynamic",a,y.concat(A,T),S,C)):i.push(h("value",a,y.concat(A,T),S))}else i.push(h("array",a,y.concat(A),v[A]));else for(A=0;A1&&p.push(h("object","layout"))),i.supplyDefaults(d);for(var m=d._fullData,g=n.length,y=0;y0&&((x=A-o(g)-o(y))>M?b/x>S&&(v=g,_=y,S=b/x):b/A>S&&(v={val:g.val,pad:0},_={val:y.val,pad:0},S=b/A));if(p===h){var C=p-1,z=p+1;if(k)if(0===p)a=[0,1];else{var L=(p>0?f:c).reduce(function(t,e){return Math.max(t,o(e))},0),E=p/(1-Math.min(.5,L/A));a=p>0?[0,E]:[E,0]}else a=T?[Math.max(0,C),Math.max(1,z)]:[C,z]}else k?(v.val>=0&&(v={val:0,pad:0}),_.val<=0&&(_={val:0,pad:0})):T&&(v.val-S*o(v)<0&&(v={val:0,pad:0}),_.val<=0&&(_={val:1,pad:0})),S=(_.val-v.val)/(A-o(v)-o(_)),a=[v.val-S*o(v),_.val+S*o(_)];return d&&a.reverse(),i.simpleMap(a,e.l2r||Number)}function l(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function u(t,e){var n,r,i,a=e._id,o=t._fullData,s=t._fullLayout,l=[],u=[];function p(t,e){for(n=0;n=n&&(u.extrapad||!o)){s=!1;break}i(e,u.val)&&u.pad<=n&&(o||!u.extrapad)&&(t.splice(l,1),l--)}if(s){var c=a&&0===e;t.push({val:e,pad:c?0:n,extrapad:!c&&o})}}function h(t){return r(t)&&Math.abs(t)=e}e.exports={getAutoRange:s,makePadFn:l,doAutoRange:function(t,e){if(e.autorange){e.range=s(t,e),e._r=e.range.slice(),e._rl=i.simpleMap(e._r,e.r2l);var n=e._input,r={};r[e._attr+".range"]=e.range,r[e._attr+".autorange"]=e.autorange,o.call("_storeDirectGUIEdit",t.layout,t._fullLayout._preGUI,r),n.range=e.range.slice(),n.autorange=e.autorange}var a=e._anchorAxis;if(a&&a.rangeslider){var l=a.rangeslider[e._name];l&&"auto"===l.rangemode&&(l.range=s(t,e)),a._input.rangeslider[e._name]=i.extendFlat({},l)}},findExtremes:function(t,e,n){n||(n={});t._m||t.setScale();var i,o,s,l,u,p,d,m,g,y=[],v=[],_=e.length,x=n.padded||!1,b=n.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function T(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var A=T((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),M=T((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),S=T(n.vpadplus||n.vpad),C=T(n.vpadminus||n.vpad);if(!k){if(m=1/0,g=-1/0,w)for(i=0;i<_;i++)(o=e[i])0&&(m=o),o>g&&o-a&&(m=o),o>g&&o=E;i--)L(i);return{min:y,max:v}},concatExtremes:u}},{"../../constants/numerical":140,"../../lib":160,"../../registry":252,"fast-isnumeric":9}],204:[function(t,e,n){"use strict";var r=t("d3"),i=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),u=t("../../components/titles"),c=t("../../components/color"),f=t("../../components/drawing"),p=t("./layout_attributes"),h=t("./clean_ticks"),d=t("../../constants/numerical"),m=d.ONEAVGYEAR,g=d.ONEAVGMONTH,y=d.ONEDAY,v=d.ONEHOUR,_=d.ONEMIN,x=d.ONESEC,b=d.MINUS_SIGN,w=d.BADNUM,k=t("../../constants/alignment").MID_SHIFT,T=t("../../constants/alignment").LINE_SPACING,A=e.exports={};A.setConvert=t("./set_convert");var M=t("./axis_autotype"),S=t("./axis_ids");A.id2name=S.id2name,A.name2id=S.name2id,A.cleanId=S.cleanId,A.list=S.list,A.listIds=S.listIds,A.getFromId=S.getFromId,A.getFromTrace=S.getFromTrace;var C=t("./autorange");A.getAutoRange=C.getAutoRange,A.findExtremes=C.findExtremes,A.coerceRef=function(t,e,n,r,i,a){var o=r.charAt(r.length-1),l=n._fullLayout._subplots[o+"axis"],u=r+"ref",c={};return i||(i=l[0]||a),a||(a=i),c[u]={valType:"enumerated",values:l.concat(a?[a]:[]),dflt:i},s.coerce(t,e,c,u)},A.coercePosition=function(t,e,n,r,i,a){var o,l;if("paper"===r||"pixel"===r)o=s.ensureNumber,l=n(i,a);else{var u=A.getFromId(e,r);l=n(i,a=u.fraction2r(a)),o=u.cleanPos}t[i]=o(l)},A.cleanPosition=function(t,e,n){return("paper"===n||"pixel"===n?s.ensureNumber:A.getFromId(e,n).cleanPos)(t)};var z=A.getDataConversions=function(t,e,n,r){var i,a="x"===n||"y"===n||"z"===n?n:r;if(Array.isArray(a)){if(i={type:M(r),_categories:[]},A.setConvert(i),"category"===i.type)for(var o=0;o2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},A.saveRangeInitial=function(t,e){for(var n=A.list(t,"",!0),r=!1,i=0;i.3*p||c(r)||c(a))){var h=n.dtick/2;t+=t+h.8){var o=Number(n.substr(1));a.exactYears>.8&&o%12==0?t=A.tickIncrement(t,"M6","reverse")+1.5*y:a.exactMonths>.8?t=A.tickIncrement(t,"M1","reverse")+15.5*y:t-=y/2;var l=A.tickIncrement(t,n);if(l<=r)return l}return t}(_,t,v,u,a)),g=_,0;g<=c;)g=A.tickIncrement(g,v,!1,a),0;return{start:e.c2r(_,0,a),end:e.c2r(g,0,a),size:v,_dataSpan:c-u}},A.prepTicks=function(t){var e=s.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var n,r=t.nticks;r||("category"===t.type||"multicategory"===t.type?(n=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/n):(n="y"===t._id.charAt(0)?40:80,r=s.constrain(t._length/n,4,9)+1),"radialaxis"===t._name&&(r*=2)),"array"===t.tickmode&&(r*=100),A.autoTicks(t,Math.abs(e[1]-e[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},A.calcTicks=function(t){A.prepTicks(t);var e=s.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e=t.tickvals,n=t.ticktext,r=new Array(e.length),i=s.simpleMap(t.range,t.r2l),a=1.0001*i[0]-1e-4*i[1],o=1.0001*i[1]-1e-4*i[0],l=Math.min(a,o),u=Math.max(a,o),c=0;Array.isArray(n)||(n=[]);var f="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(var p=0;pl&&h=r:u<=r)&&!(a.length>l||u===o);u=A.tickIncrement(u,t.dtick,i,t.calendar))o=u,a.push(u);et(t)&&360===Math.abs(e[1]-e[0])&&a.pop(),t._tmax=a[a.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var c=new Array(a.length),f=0;f10||"01-01"!==r.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=y&&a<=10||e>=15*y)t._tickround="d";else if(e>=_&&a<=16||e>=v)t._tickround="M";else if(e>=x&&a<=19||e>=_)t._tickround="S";else{var o=t.l2r(n+e).replace(/^-/,"").length;t._tickround=Math.max(a,o)-20,t._tickround<0&&(t._tickround=4)}}else if(i(e)||"L"===e.charAt(0)){var s=t.range.map(t.r2d||Number);i(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var l=Math.max(Math.abs(s[0]),Math.abs(s[1])),u=Math.floor(Math.log(l)/Math.LN10+.01);Math.abs(u)>3&&(U(t.exponentformat)&&!H(u)?t._tickexponent=3*Math.round((u-1)/3):t._tickexponent=u)}else t._tickround=null}function V(t,e,n){var r=t.tickfont||{};return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}A.autoTicks=function(t,e){var n;function r(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=s.dateTick0(t.calendar);var a=2*e;a>m?(e/=m,n=r(10),t.dtick="M"+12*N(e,n,I)):a>g?(e/=g,t.dtick="M"+N(e,1,P)):a>y?(t.dtick=N(e,y,O),t.tick0=s.dateTick0(t.calendar,!0)):a>v?t.dtick=N(e,v,P):a>_?t.dtick=N(e,_,D):a>x?t.dtick=N(e,x,D):(n=r(10),t.dtick=N(e,n,I))}else if("log"===t.type){t.tick0=0;var o=s.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var l=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/l,n=r(10),t.dtick="L"+N(e,n,I)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type||"multicategory"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):et(t)?(t.tick0=0,n=1,t.dtick=N(e,n,B)):(t.tick0=0,n=r(10),t.dtick=N(e,n,I));if(0===t.dtick&&(t.dtick=1),!i(t.dtick)&&"string"!=typeof t.dtick){var u=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(u)}},A.tickIncrement=function(t,e,n,a){var o=n?-1:1;if(i(e))return t+o*e;var l=e.charAt(0),u=o*Number(e.substr(1));if("M"===l)return s.incrementMonth(t,u,a);if("L"===l)return Math.log(Math.pow(10,t)+u)/Math.LN10;if("D"===l){var c="D2"===e?F:R,f=t+.01*o,p=s.roundUp(s.mod(f,1),c,n);return Math.floor(f)+Math.log(r.round(Math.pow(10,p),1))/Math.LN10}throw"unrecognized dtick "+String(e)},A.tickFirst=function(t){var e=t.r2l||Number,n=s.simpleMap(t.range,e),a=n[1]"+l,t._prevDateHead=l));e.text=u}(t,a,n,l):"log"===u?function(t,e,n,r,a){var o=t.dtick,l=e.x,u=t.tickformat,c="string"==typeof o&&o.charAt(0);"never"===a&&(a="");r&&"L"!==c&&(o="L3",c="L");if(u||"L"===c)e.text=Z(Math.pow(10,l),t,a,r);else if(i(o)||"D"===c&&s.mod(l+.01,1)<.1){var f=Math.round(l),p=Math.abs(f),h=t.exponentformat;"power"===h||U(h)&&H(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":b)+p+"",e.fontSize*=1.25):("e"===h||"E"===h)&&p>2?e.text="1"+h+(f>0?"+":b)+p:(e.text=Z(Math.pow(10,l),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==c)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,s.mod(l,1)))),e.fontSize*=.75}if("D1"===t.dtick){var d=String(e.text).charAt(0);"0"!==d&&"1"!==d||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(l<0?.5:.25)))}}(t,a,0,l,d):"category"===u?function(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n="");e.text=String(n)}(t,a):"multicategory"===u?function(t,e,n){var r=Math.round(e.x),i=t._categories[r]||[],a=void 0===i[1]?"":String(i[1]),o=void 0===i[0]?"":String(i[0]);n?e.text=o+" - "+a:(e.text=a,e.text2=o)}(t,a,n):et(t)?function(t,e,n,r,i){if("radians"!==t.thetaunit||n)e.text=Z(e.x,t,i,r);else{var a=e.x/180;if(0===a)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var n=function(t){var n=1;for(;!e(Math.round(t*n)/n,t);)n*=10;return n}(t),r=t*n,i=Math.abs(function t(n,r){return e(r,0)?n:t(r,n%r)}(r,n));return[Math.round(r/i),Math.round(n/i)]}(a);if(o[1]>=100)e.text=Z(s.deg2rad(e.x),t,i,r);else{var l=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),l&&(e.text=b+e.text)}}}}(t,a,n,l,d):function(t,e,n,r,i){"never"===i?i="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide");e.text=Z(e.x,t,i,r)}(t,a,0,l,d),t.tickprefix&&!h(t.showtickprefix)&&(a.text=t.tickprefix+a.text),t.ticksuffix&&!h(t.showticksuffix)&&(a.text+=t.ticksuffix),"boundaries"===t.tickson||t.showdividers){var m=function(e){var n=t.l2p(e);return n>=0&&n<=t._length?e:null};a.xbnd=[m(a.x-.5),m(a.x+t.dtick-.5)]}return a},A.hoverLabelText=function(t,e,n){if(n!==w&&n!==e)return A.hoverLabelText(t,e)+" - "+A.hoverLabelText(t,n);var r="log"===t.type&&e<=0,i=A.tickText(t,t.c2l(r?-e:e),"hover").text;return r?0===e?"0":b+i:i};var q=["f","p","n","\u03bc","m","","k","M","G","T"];function U(t){return"SI"===t||"B"===t}function H(t){return t>14||t<-15}function Z(t,e,n,r){var a=t<0,o=e._tickround,l=n||e.exponentformat||"B",u=e._tickexponent,c=A.getTickFormat(e),f=e.separatethousands;if(r){var p={exponentformat:l,dtick:"none"===e.showexponent?e.dtick:i(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(p),o=(Number(p._tickround)||0)+4,u=p._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return e._numFormat(c)(t).replace(/-/g,b);var h,d=Math.pow(10,-o)/2;if("none"===l&&(u=0),(t=Math.abs(t))"+h+"":"B"===l&&9===u?t+="B":U(l)&&(t+=q[u/3+5]));return a?b+t:t}function G(t,e){var n=t._id.charAt(0),r=t._tickAngles[e]||0,i=s.deg2rad(r),a=Math.sin(i),o=Math.cos(i),l=0,u=0;return t._selections[e].each(function(){var t=X(this),e=f.bBox(t.node()),n=e.width,r=e.height;l=Math.max(l,o*n,a*r),u=Math.max(u,a*n,o*r)}),{x:u,y:l}[n]}function $(t){return[t.text,t.x,t.axInfo,t.font,t.fontSize,t.fontColor].join("_")}function W(t,e){var n=t.l2p(e);return n>1&&n=0,a=c(t,e[1])<=0;return(n||i)&&(r||a)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(i)))){n=r;break}break;case"log":for(e=0;e1)for(r=1;r2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),n=0,r=0,o={},s=0;s2*n}(t)?"category":function(t){if(!t)return!1;for(var e=0;er?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":252,"./constants":210}],208:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){if("category"===e.type){var i,a=t.categoryarray,o=Array.isArray(a)&&a.length>0;o&&(i="array");var s,l=n("categoryorder",i);"array"===l&&(s=n("categoryarray")),o||"array"!==l||(l=e.categoryorder="trace"),"trace"===l?e._initialCategories=[]:"array"===l?e._initialCategories=s.slice():(s=function(t,e){var n,r,i,a=e.dataAttr||t._id.charAt(0),o={};if(e.axData)n=e.axData;else for(n=[],r=0;rs*_)||k)for(n=0;nP&&RE&&(E=R);h/=(E-L)/(2*I),L=c.l2r(L),E=c.l2r(E),c.range=c._input.range=S=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function D(t,e,n,r,i){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+n+", "+r+")").attr("d",i+"Z")}function O(t,e,n){return t.append("path").attr("class","zoombox-corners").style({fill:u.background,stroke:u.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+n+")").attr("d","M0,0Z")}function R(t,e,n,r,i,a){t.attr("d",r+"M"+n.l+","+n.t+"v"+n.h+"h"+n.w+"v-"+n.h+"h-"+n.w+"Z"),F(t,e,i,a)}function F(t,e,n,r){n||(t.transition().style("fill",r>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function B(t){r.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function N(t){S&&t.data&&t._context.showTips&&(s.notifier(s._(t,"Double-click to zoom back out"),"long"),S=!1)}function j(t){return"lasso"===t||"select"===t}function V(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,M)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function q(t,e){if(a){var n=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(n,t._onwheel),t._onwheel=e,t.addEventListener(n,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function U(t){var e=[];for(var n in t)e.push(t[n]);return e}e.exports={makeDragBox:function(t,e,n,a,u,h,S,C){var F,H,Z,G,$,W,X,Y,J,K,Q,tt,et,nt,rt,it,at,ot,st,lt,ut,ct=t._fullLayout._zoomlayer,ft=S+C==="nsew",pt=1===(S+C).length;function ht(){if(F=e.xaxis,H=e.yaxis,J=F._length,K=H._length,X=F._offset,Y=H._offset,(Z={})[F._id]=F,(G={})[H._id]=H,S&&C)for(var n=e.overlays,r=0;r-1&&w(i,t,$,W,e.id,Mt),a.indexOf("event")>-1&&f.click(t,i,e.id);else if(1===n&&pt){var s=S?H:F,u="s"===S||"w"===C?0:1,c=s._name+".range["+u+"]",p=function(t,e){var n,i=t.range[e],a=Math.abs(i-t.range[1-e]);return"date"===t.type?i:"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,r.format("."+n+"g")(Math.pow(10,i))):(n=Math.floor(Math.log(Math.abs(i))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,r.format("."+String(n)+"g")(i))}(s,u),h="left",d="middle";if(s.fixedrange)return;S?(d="n"===S?"top":"bottom","right"===s.side&&(h="right")):"e"===C&&(h="right"),t._context.showAxisRangeEntryBoxes&&r.select(mt).call(l.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(p),fill:s.tickfont?s.tickfont.color:"#444",horizontalAlign:h,verticalAlign:d}).on("edit",function(e){var n=s.d2r(e);void 0!==n&&o.call("_guiRelayout",t,c,n)})}}function zt(e,n){if(t._transitioningWithDuration)return!1;var r=Math.max(0,Math.min(J,e+gt)),i=Math.max(0,Math.min(K,n+yt)),a=Math.abs(r-gt),o=Math.abs(i-yt);function s(){wt="",vt.r=vt.l,vt.t=vt.b,Tt.attr("d","M0,0Z")}vt.l=Math.min(gt,r),vt.r=Math.max(gt,r),vt.t=Math.min(yt,i),vt.b=Math.max(yt,i),rt?a>M||o>M?(wt="xy",a/J>o/K?(o=a*K/J,yt>i?vt.t=yt-o:vt.b=yt+o):(a=o*J/K,gt>r?vt.l=gt-a:vt.r=gt+a),Tt.attr("d",V(vt))):s():!et||o10||n.scrollWidth-n.clientWidth>10)){clearTimeout(Dt);var r=-e.deltaY;if(isFinite(r)||(r=e.wheelDelta/10),isFinite(r)){var i,a=Math.exp(-Math.min(Math.max(r,-20),20)/200),o=Rt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-o.left)/o.width,u=(o.bottom-e.clientY)/o.height;if(it){for(C||(l=.5),i=0;i<$.length;i++)c($[i],l,a);Pt[2]*=a,Pt[0]+=Pt[2]*l*(1/a-1)}if(at){for(S||(u=.5),i=0;im[1]-.01&&(e.domain=s),i.noneOrAll(t.domain,e.domain,s)}return n("layer"),e}},{"../../lib":160,"fast-isnumeric":9}],221:[function(t,e,n){"use strict";var r=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,n){void 0===n&&(n=r[t.constraintoward||"center"]);var i=[t.r2l(t.range[0]),t.r2l(t.range[1])],a=i[0]+(i[1]-i[0])*n;t.range=t._input.range=[t.l2r(a+(i[0]-a)*e),t.l2r(a+(i[1]-a)*e)]}},{"../../constants/alignment":138}],222:[function(t,e,n){"use strict";var r=t("polybooljs"),i=t("../../registry"),a=t("../../components/color"),o=t("../../components/fx"),s=t("../../lib/polygon"),l=t("../../lib/throttle"),u=t("../../components/fx/helpers").makeEventData,c=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),p=t("../../plot_api/subroutines").redrawReglTraces,h=t("./constants"),d=h.MINSELECT,m=s.filter,g=s.tester;function y(t){return t._id}function v(t,e,n,r,i,a,o){var s,l,u,c,f,p,h,d,m,g=e._hoverdata,y=e._fullLayout.clickmode.indexOf("event")>-1,v=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(g)){w(t,e,a);var _=function(t,e){var n,r,i=t[0],a=-1,o=[];for(r=0;r0?function(t,e){var n,r,i,a=[];for(i=0;i0&&a.push(n);if(1===a.length&&a[0]===e.searchInfo&&(r=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(i=0;i1)return!1;if((i+=n.selectedpoints.length)>1)return!1}return 1===i}(s)&&(p=M(_))){for(o&&o.remove(),m=0;m0?"M"+i.join("M")+"Z":"M0,0Z",e.attr("d",r)}function M(t){var e=t.searchInfo.cd[0].trace,n=t.pointNumber,r=t.pointNumbers,i=r.length>0?r[0]:n;return!!e.selectedpoints&&e.selectedpoints.indexOf(i)>-1}function S(t,e,n){var r,a,o,s;for(r=0;r-1&&v(e,M,i.xaxes,i.yaxes,i.subplot,i,H),"event"===n&&M.emit("plotly_selected",void 0);o.click(M,e)})},i.doneFn=function(){G.remove(),l.done($).then(function(){l.clear($),i.gd.emit("plotly_selected",x),p&&i.selectionDefs&&(p.subtract=U,i.selectionDefs.push(p),i.mergedPolygons.length=0,[].push.apply(i.mergedPolygons,f))})}},clearSelect:z,selectOnClick:v}},{"../../components/color":43,"../../components/fx":82,"../../components/fx/helpers":78,"../../lib/clear_gl_canvases":148,"../../lib/polygon":172,"../../lib/throttle":182,"../../plot_api/subroutines":195,"../../registry":252,"./axis_ids":207,"./constants":210,polybooljs:17}],223:[function(t,e,n){"use strict";var r=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=a.cleanNumber,s=a.ms2DateTime,l=a.dateTime2ms,u=a.ensureNumber,c=t("../../constants/numerical"),f=c.FP_SAFE,p=c.BADNUM,h=c.LOG_CLIP,d=t("./constants"),m=t("./axis_ids");function g(t){return Math.pow(10,t)}function y(t){return null!=t}e.exports=function(t,e){e=e||{};var n=(t._id||"x").charAt(0);function c(e,n){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&n&&t.range&&2===t.range.length){var r=t.range[0],i=t.range[1];return.5*(r+i-2*h*Math.abs(r-i))}return p}function v(e,n,r){var o=l(e,r||t.calendar);if(o===p){if(!i(e))return p;e=+e;var s=Math.floor(10*a.mod(e+.05,1)),u=Math.round(e-s/10);o=l(new Date(u))+s/10}return o}function _(e,n,r){return s(e,n,r||t.calendar)}function x(e){return t._categories[Math.round(e)]}function b(e){if(y(e)){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var n=t._categories.length-1;return t._categoriesMap[e]=n,n}return p}function w(e){if(t._categoriesMap)return t._categoriesMap[e]}function k(t){var e=w(t);return void 0!==e?e:i(t)?+t:void 0}function T(e){return i(e)?r.round(t._b+t._m*e,2):p}function A(e){return(e-t._b)/t._m}t.c2l="log"===t.type?c:u,t.l2c="log"===t.type?g:u,t.l2p=T,t.p2l=A,t.c2p="log"===t.type?function(t,e){return T(c(t,e))}:T,t.p2c="log"===t.type?function(t){return g(A(t))}:A,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=u,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=A,t.cleanPos=u):"log"===t.type?(t.d2r=t.d2l=function(t,e){return c(o(t),e)},t.r2d=t.r2c=function(t){return g(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=u,t.c2r=c,t.l2d=g,t.d2p=function(e,n){return t.l2p(t.d2r(e,n))},t.p2d=function(t){return g(A(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=A,t.cleanPos=u):"date"===t.type?(t.d2r=t.r2d=a.identity,t.d2c=t.r2c=t.d2l=t.r2l=v,t.c2d=t.c2r=t.l2d=t.l2r=_,t.d2p=t.r2p=function(e,n,r){return t.l2p(v(e,0,r))},t.p2d=t.p2r=function(t,e,n){return _(A(t),e,n)},t.cleanPos=function(e){return a.cleanDate(e,p,t.calendar)}):"category"===t.type?(t.d2c=t.d2l=b,t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var n=k(e);return void 0!==n?n:t.fraction2r(.5)},t.l2r=t.c2r=u,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(A(t))},t.r2p=t.d2p,t.p2r=A,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:u(t)}):"multicategory"===t.type&&(t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var n=k(e);return void 0!==n?n:t.fraction2r(.5)},t.r2c_just_indices=w,t.l2r=t.c2r=u,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(A(t))},t.r2p=t.d2p,t.p2r=A,t.cleanPos=function(t){return Array.isArray(t)||"string"==typeof t&&""!==t?t:u(t)}),t.fraction2r=function(e){var n=t.r2l(t.range[0]),r=t.r2l(t.range[1]);return t.l2r(n+e*(r-n))},t.r2fraction=function(e){var n=t.r2l(t.range[0]),r=t.r2l(t.range[1]);return(t.r2l(e)-n)/(r-n)},t.cleanRange=function(e,r){r||(r={}),e||(e="range");var o,s,l=a.nestedProperty(t,e).get();if(s=(s="date"===t.type?a.dfltRange(t.calendar):"y"===n?d.DFLTRANGEY:r.dfltRange||d.DFLTRANGEX).slice(),l&&2===l.length)for("date"===t.type&&(l[0]=a.cleanDate(l[0],p,t.calendar),l[1]=a.cleanDate(l[1],p,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!a.isDateTime(l[o],t.calendar)){t[e]=s;break}if(t.r2l(l[0])===t.r2l(l[1])){var u=a.constrain(t.r2l(l[0]),a.MIN_MS+1e3,a.MAX_MS-1e3);l[0]=t.l2r(u-1e3),l[1]=t.l2r(u+1e3);break}}else{if(!i(l[o])){if(!i(l[1-o])){t[e]=s;break}l[o]=l[1-o]*(o?10:.1)}if(l[o]<-f?l[o]=-f:l[o]>f&&(l[o]=f),l[0]===l[1]){var c=Math.max(1,Math.abs(1e-6*l[0]));l[0]-=c,l[1]+=c}}else a.nestedProperty(t,e).set(s)},t.setScale=function(r){var i=e._size;if(t.overlaying){var a=m.getFromId({_fullLayout:e},t.overlaying);t.domain=a.domain}var o=r&&t._r?"_r":"range",s=t.calendar;t.cleanRange(o);var l=t.r2l(t[o][0],s),u=t.r2l(t[o][1],s);if("y"===n?(t._offset=i.t+(1-t.domain[1])*i.h,t._length=i.h*(t.domain[1]-t.domain[0]),t._m=t._length/(l-u),t._b=-t._m*u):(t._offset=i.l+t.domain[0]*i.w,t._length=i.w*(t.domain[1]-t.domain[0]),t._m=t._length/(u-l),t._b=-t._m*l),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,n){var r,i,o,s,l=t.type,u="date"===l&&e[n+"calendar"];if(n in e){if(r=e[n],s=e._length||a.minRowLength(r),a.isTypedArray(r)&&("linear"===l||"log"===l)){if(s===r.length)return r;if(r.subarray)return r.subarray(0,s)}if("multicategory"===l)return function(t,e){var n,r=new Array(e),i=new Array(e),o=[[0,{}],[0,{}]];if(a.isArrayOrTypedArray(t[0])&&a.isArrayOrTypedArray(t[1])){for(n=0;n rect").call(a.setTranslate,0,0).call(a.setScale,1,1),t.plot.call(a.setTranslate,e._offset,n._offset).call(a.setScale,1,1);var r=t.plot.selectAll(".scatterlayer .trace");r.selectAll(".point").call(a.setPointGroupScale,1,1),r.selectAll(".textpoint").call(a.setTextPointsScale,1,1),r.call(a.hideOutsideRangePoints,t)}function _(e,n){var r,s,l,c=m[e.xaxis._id],f=m[e.yaxis._id],p=[];if(c){s=(r=t._fullLayout[c.axisName])._r,l=c.to,p[0]=(s[0]*(1-n)+n*l[0]-s[0])/(s[1]-s[0])*e.xaxis._length;var h=s[1]-s[0],d=l[1]-l[0];r.range[0]=s[0]*(1-n)+n*l[0],r.range[1]=s[1]*(1-n)+n*l[1],p[2]=e.xaxis._length*(1-n+n*d/h)}else p[0]=0,p[2]=e.xaxis._length;if(f){s=(r=t._fullLayout[f.axisName])._r,l=f.to,p[1]=(s[1]*(1-n)+n*l[1]-s[1])/(s[0]-s[1])*e.yaxis._length;var g=s[1]-s[0],y=l[1]-l[0];r.range[0]=s[0]*(1-n)+n*l[0],r.range[1]=s[1]*(1-n)+n*l[1],p[3]=e.yaxis._length*(1-n+n*y/g)}else p[1]=0,p[3]=e.yaxis._length;!function(e,n){var r,a=[e._id,n._id];function s(e,n,i){for(r=0;rn.duration?(function(){for(var e={},n=0;n0&&(i["_"+n+"axes"]||{})[e])return i;if((i[n+"axis"]||n)===e){if(o(i,n))return i;if((i[n]||[]).length||i[n+"0"])return i}}}(e,n,s);if(!l)return;if("histogram"===l.type&&s==={v:"y",h:"x"}[l.orientation||"v"])return void(t.type="linear");var u,c=s+"calendar",f=l[c],p={noMultiCategory:!r(l,"cartesian")||r(l,"noMultiCategory")};if(o(l,s)){var h=a(l),d=[];for(u=0;u0?".":"")+a;i.isPlainObject(o)?l(o,e,s,r+1):e(s,a,o)}})}n.manageCommandObserver=function(t,e,r,o){var s={},l=!0;e&&e._commandObserver&&(s=e._commandObserver),s.cache||(s.cache={}),s.lookupTable={};var u=n.hasSimpleAPICommandBindings(t,r,s.lookupTable);if(e&&e._commandObserver){if(u)return s;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,s}if(u){a(t,u,s.cache),s.check=function(){if(l){var e=a(t,u,s.cache);return e.changed&&o&&void 0!==s.lookupTable[e.value]&&(s.disable(),Promise.resolve(o({value:e.value,type:u.type,prop:u.prop,traces:u.traces,index:s.lookupTable[e.value]})).then(s.enable,s.enable)),e.changed}};for(var c=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;f0)}function l(t){var e={},n={};switch(t.type){case"circle":r.extendFlat(n,{"circle-radius":t.circle.radius,"circle-color":t.color,"circle-opacity":t.opacity});break;case"line":r.extendFlat(n,{"line-width":t.line.width,"line-color":t.color,"line-opacity":t.opacity});break;case"fill":r.extendFlat(n,{"fill-color":t.color,"fill-outline-color":t.fill.outlinecolor,"fill-opacity":t.opacity});break;case"symbol":var a=t.symbol,o=i(a.textposition,a.iconsize);r.extendFlat(e,{"icon-image":a.icon+"-15","icon-size":a.iconsize/10,"text-field":a.text,"text-size":a.textfont.size,"text-anchor":o.anchor,"text-offset":o.offset}),r.extendFlat(n,{"icon-color":t.color,"text-color":a.textfont.color,"text-opacity":t.opacity})}return{layout:e,paint:n}}o.update=function(t){this.visible?this.needsNewSource(t)?(this.removeLayer(),this.updateSource(t),this.updateLayer(t)):this.needsNewLayer(t)?this.updateLayer(t):this.updateStyle(t):(this.updateSource(t),this.updateLayer(t)),this.visible=s(t)},o.needsNewSource=function(t){return this.sourceType!==t.sourcetype||this.source!==t.source||this.layerType!==t.type},o.needsNewLayer=function(t){return this.layerType!==t.type||this.below!==t.below},o.updateSource=function(t){var e=this.map;if(e.getSource(this.idSource)&&e.removeSource(this.idSource),this.sourceType=t.sourcetype,this.source=t.source,s(t)){var n=function(t){var e,n=t.sourcetype,r=t.source,i={type:n};"geojson"===n?e="data":"vector"===n&&(e="string"==typeof r?"url":"tiles");return i[e]=r,i}(t);e.addSource(this.idSource,n)}},o.updateLayer=function(t){var e=this.map,n=l(t);this.removeLayer(),this.layerType=t.type,s(t)&&e.addLayer({id:this.idLayer,source:this.idSource,"source-layer":t.sourcelayer||"",type:t.type,layout:n.layout,paint:n.paint},t.below)},o.updateStyle=function(t){if(s(t)){var e=l(t);this.mapbox.setOptions(this.idLayer,"setLayoutProperty",e.layout),this.mapbox.setOptions(this.idLayer,"setPaintProperty",e.paint)}},o.removeLayer=function(){var t=this.map;t.getLayer(this.idLayer)&&t.removeLayer(this.idLayer)},o.dispose=function(){var t=this.map;t.removeLayer(this.idLayer),t.removeSource(this.idSource)},e.exports=function(t,e,n){var r=new a(t,e);return r.update(n),r}},{"../../lib":160,"./convert_text_opts":237}],240:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../components/color").defaultLine,a=t("../domain").attributes,o=t("../font_attributes"),s=t("../../traces/scatter/attributes").textposition,l=t("../../plot_api/edit_types").overrideAll,u=t("../../plot_api/plot_template").templatedArray,c=o({});c.family.dflt="Open Sans Regular, Arial Unicode MS Regular",(e.exports=l({_arrayAttrRegexps:[r.counterRegex("mapbox",".layers",!0)],domain:a({name:"mapbox"}),accesstoken:{valType:"string",noBlank:!0,strict:!0},style:{valType:"any",values:["basic","streets","outdoors","light","dark","satellite","satellite-streets"],dflt:"basic"},center:{lon:{valType:"number",dflt:0},lat:{valType:"number",dflt:0}},zoom:{valType:"number",dflt:1},bearing:{valType:"number",dflt:0},pitch:{valType:"number",dflt:0},layers:u("layer",{visible:{valType:"boolean",dflt:!0},sourcetype:{valType:"enumerated",values:["geojson","vector"],dflt:"geojson"},source:{valType:"any"},sourcelayer:{valType:"string",dflt:""},type:{valType:"enumerated",values:["circle","line","fill","symbol"],dflt:"circle"},below:{valType:"string",dflt:""},color:{valType:"color",dflt:i},opacity:{valType:"number",min:0,max:1,dflt:1},circle:{radius:{valType:"number",dflt:15}},line:{width:{valType:"number",dflt:2}},fill:{outlinecolor:{valType:"color",dflt:i}},symbol:{icon:{valType:"string",dflt:"marker"},iconsize:{valType:"number",dflt:10},text:{valType:"string",dflt:""},textfont:c,textposition:r.extendFlat({},s,{arrayOk:!1})}})},"plot","from-root")).uirevision={valType:"any",editType:"none"}},{"../../components/color":43,"../../lib":160,"../../plot_api/edit_types":187,"../../plot_api/plot_template":194,"../../traces/scatter/attributes":264,"../domain":230,"../font_attributes":231}],241:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../subplot_defaults"),a=t("../array_container_defaults"),o=t("./layout_attributes");function s(t,e,n,r){n("accesstoken",r.accessToken),n("style"),n("center.lon"),n("center.lat"),n("zoom"),n("bearing"),n("pitch"),a(t,e,{name:"layers",handleItemDefaults:l}),e._input=t}function l(t,e){function n(n,i){return r.coerce(t,e,o.layers,n,i)}if(n("visible")){var i=n("sourcetype");n("source"),"vector"===i&&n("sourcelayer");var a=n("type");n("below"),n("color"),n("opacity"),"circle"===a&&n("circle.radius"),"line"===a&&n("line.width"),"fill"===a&&n("fill.outlinecolor"),"symbol"===a&&(n("symbol.icon"),n("symbol.iconsize"),n("symbol.text"),r.coerceFont(n,"symbol.textfont"),n("symbol.textposition"))}}e.exports=function(t,e,n){i(t,e,n,{type:"mapbox",attributes:o,handleDefaults:s,partition:"y",accessToken:e._mapboxAccessToken})}},{"../../lib":160,"../array_container_defaults":200,"../subplot_defaults":251,"./layout_attributes":240}],242:[function(t,e,n){"use strict";var r=t("mapbox-gl"),i=t("../../components/fx"),a=t("../../lib"),o=t("../../registry"),s=t("../../components/dragelement"),l=t("../cartesian/select").prepSelect,u=t("../cartesian/select").selectOnClick,c=t("./constants"),f=t("./layout_attributes"),p=t("./layers");function h(t){this.id=t.id,this.gd=t.gd,this.container=t.container,this.isStatic=t.staticPlot;var e=t.fullLayout;this.uid=e._uid+"-"+this.id,this.opts=e[this.id],this.div=null,this.xaxis=null,this.yaxis=null,this.createFramework(e),this.map=null,this.accessToken=null,this.styleObj=null,this.traceHash={},this.layerList=[]}var d=h.prototype;function m(t){var e=f.style.values,n=f.style.dflt,r={};return a.isPlainObject(t)?(r.id=t.id,r.style=t):"string"==typeof t?(r.id=t,r.style=-1!==e.indexOf(t)?g(t):t):(r.id=n,r.style=g(n)),r.transition={duration:0,delay:0},r}function g(t){return c.styleUrlPrefix+t+"-"+c.styleUrlSuffix}function y(t){return[t.lon,t.lat]}e.exports=function(t){return new h(t)},d.plot=function(t,e,n){var r,i=this,a=i.opts=e[this.id];i.map&&a.accesstoken!==i.accessToken&&(i.map.remove(),i.map=null,i.styleObj=null,i.traceHash=[],i.layerList={}),r=i.map?new Promise(function(n,r){i.updateMap(t,e,n,r)}):new Promise(function(n,r){i.createMap(t,e,n,r)}),n.push(r)},d.createMap=function(t,e,n,a){var s=this,l=s.gd,f=s.opts,p=s.styleObj=m(f.style);s.accessToken=f.accesstoken;var h=s.map=new r.Map({container:s.div,style:p.style,center:y(f.center),zoom:f.zoom,bearing:f.bearing,pitch:f.pitch,interactive:!s.isStatic,preserveDrawingBuffer:s.isStatic,doubleClickZoom:!1,boxZoom:!1}),d=c.controlContainerClassName,g=s.div.getElementsByClassName(d)[0];if(s.div.removeChild(g),h._canvas.style.left="0px",h._canvas.style.top="0px",s.rejectOnError(a),h.once("load",function(){s.updateData(t),s.updateLayout(e),s.resolveOnRender(n)}),!s.isStatic){var v=!1;h.on("moveend",function(t){if(s.map){if(t.originalEvent||v){var e=s.getView();f._input.center=f.center=e.center,f._input.zoom=f.zoom=e.zoom,f._input.bearing=f.bearing=e.bearing,f._input.pitch=f.pitch=e.pitch,x(e)}v=!1}}),h.on("wheel",function(){v=!0}),h.on("mousemove",function(t){var e=s.div.getBoundingClientRect();t.clientX=t.point.x+e.left,t.clientY=t.point.y+e.top,t.target.getBoundingClientRect=function(){return e},s.xaxis.p2c=function(){return t.lngLat.lng},s.yaxis.p2c=function(){return t.lngLat.lat},i.hover(l,t,s.id)}),h.on("dragstart",_),h.on("zoomstart",_),h.on("dblclick",function(){l.emit("plotly_doubleclick",null);var t=s.viewInitial;h.setCenter(y(t.center)),h.setZoom(t.zoom),h.setBearing(t.bearing),h.setPitch(t.pitch);var e=s.getView();f._input.center=f.center=e.center,f._input.zoom=f.zoom=e.zoom,f._input.bearing=f.bearing=e.bearing,f._input.pitch=f.pitch=e.pitch,x(e)}),s.clearSelect=function(){l._fullLayout._zoomlayer.selectAll(".select-outline").remove()},s.onClickInPanFn=function(t){return function(e){var n=l._fullLayout.clickmode;n.indexOf("select")>-1&&u(e.originalEvent,l,[s.xaxis],[s.yaxis],s.id,t),n.indexOf("event")>-1&&i.click(l,e.originalEvent)}}}function _(){i.loneUnhover(e._toppaper)}function x(t){var e=s.id,n={};for(var r in t)n[e+"."+r]=t[r];o.call("_storeDirectGUIEdit",l.layout,l._fullLayout._preGUI,n),l.emit("plotly_relayout",n)}},d.updateMap=function(t,e,n,r){var i=this,a=i.map;i.rejectOnError(r);var o=m(i.opts.style);i.styleObj.id!==o.id?(i.styleObj=o,a.setStyle(o.style),a.once("styledata",function(){i.traceHash={},i.updateData(t),i.updateLayout(e),i.resolveOnRender(n)})):(i.updateData(t),i.updateLayout(e),i.resolveOnRender(n))},d.updateData=function(t){var e,n,r,i,a=this.traceHash;for(r=0;r=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),n.attr(a);var o=n.select(".js-link-to-tool"),s=n.select(".js-link-spacer"),c=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var n=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)n.on("click",function(){g.sendDataToCloud(t)});else{var r=window.location.pathname.split("/"),i=window.location.search;n.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+r[2].split(".")[0]+"/"+r[1]+i})}}(t,o),s.text(o.text()&&c.text()?" - ":"")}},g.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,n=r.select(t).append("div").attr("id","hiddenform").style("display","none"),i=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return i.append("input").attr({type:"text",name:"data"}).node().value=g.graphJson(t,!1,"keepdata"),i.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1};var _,x=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],b=["year","month","dayMonth","dayMonthYear"];function w(t,e){var n=t._context.locale,r=!1,i={};function o(t){for(var n=!0,a=0;a1&&P.length>1){for(a.getComponentMethod("grid","sizeDefaults")(u,s),o=0;o15&&P.length>15&&0===s.shapes.length&&0===s.images.length,s._hasCartesian=s._has("cartesian"),s._hasGeo=s._has("geo"),s._hasGL3D=s._has("gl3d"),s._hasGL2D=s._has("gl2d"),s._hasTernary=s._has("ternary"),s._hasPie=s._has("pie"),g.linkSubplots(f,s,c,i),g.cleanPlot(f,s,c,i),d(s,i),s._preGUI||(s._preGUI={}),s._tracePreGUI||(s._tracePreGUI={});var B,N=s._tracePreGUI,j={};for(B in N)j[B]="old";for(o=0;o0){var f=1-2*s;r=Math.round(f*r),a=Math.round(f*a)}}var p=g.layoutAttributes.width.min,h=g.layoutAttributes.height.min;r1,m=!e.height&&Math.abs(n.height-a)>1;(m||d)&&(d&&(n.width=r),m&&(n.height=a)),t._initialAutoSize||(t._initialAutoSize={width:r,height:a}),g.sanitizeMargins(n)},g.supplyLayoutModuleDefaults=function(t,e,n,r){var i,o,s,u=a.componentsRegistry,c=e._basePlotModules,f=a.subplotsRegistry.cartesian;for(i in u)(s=u[i]).includeBasePlot&&s.includeBasePlot(t,e);for(var p in c.length||c.push(f),e._has("cartesian")&&(a.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[p].sort(l.subplotSort);for(o=0;o.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0);var l=void 0!==n.xl?n.xl:n.x,u=void 0!==n.xr?n.xr:n.x,c=void 0!==n.yt?n.yt:n.y,f=void 0!==n.yb?n.yb:n.y;i[e]={l:{val:l,size:n.l+o},r:{val:u,size:n.r+o},b:{val:f,size:n.b+o},t:{val:c,size:n.t+o}},a[e]=1}else delete i[e],delete a[e];r._replotting||g.doAutoMargin(t)}},g.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),M(e);var n=e._size,r=JSON.stringify(n),o=e.margin,s=o.l,l=o.r,u=o.t,c=o.b,f=e._pushmargin,p=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var h in f)p[h]||delete f[h];for(var d in f.base={l:{val:0,size:s},r:{val:1,size:l},t:{val:1,size:u},b:{val:0,size:c}},f){var m=f[d].l||{},g=f[d].b||{},y=m.val,v=m.size,_=g.val,x=g.size;for(var b in f){if(i(v)&&f[b].r){var w=f[b].r.val,k=f[b].r.size;if(w>y){var T=(v*w+(k-e.width)*y)/(w-y),A=(k*(1-y)+(v-e.width)*(1-w))/(w-y);T>=0&&A>=0&&T+A>s+l&&(s=T,l=A)}}if(i(x)&&f[b].t){var S=f[b].t.val,C=f[b].t.size;if(S>_){var z=(x*S+(C-e.height)*_)/(S-_),L=(C*(1-_)+(x-e.height)*(1-S))/(S-_);z>=0&&L>=0&&z+L>c+u&&(c=z,u=L)}}}}}if(n.l=Math.round(s),n.r=Math.round(l),n.t=Math.round(u),n.b=Math.round(c),n.p=Math.round(o.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,!e._replotting&&"{}"!==r&&r!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,a.call("plot",t)},g.graphJson=function(t,e,n,r,i){(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&g.supplyDefaults(t);var a=i?t._fullData:t.data,o=i?t._fullLayout:t.layout,s=(t._transitionData||{})._frames;function u(t){if("function"==typeof t)return null;if(l.isPlainObject(t)){var e,r,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if("string"==typeof(r=t[e+"src"])&&r.indexOf(":")>0&&!l.isPlainObject(t.stream))continue}else if("keepall"!==n&&"string"==typeof(r=t[e+"src"])&&r.indexOf(":")>0)continue;i[e]=u(t[e])}return i}return Array.isArray(t)?t.map(u):l.isTypedArray(t)?l.simpleMap(t,l.identity):l.isJSDate(t)?l.ms2DateTimeLocal(+t):t}var c={data:(a||[]).map(function(t){var n=u(t);return e&&delete n.fit,n})};return e||(c.layout=u(o)),t.framework&&t.framework.isPolar&&(c=t.framework.getConfig()),s&&(c.frames=u(s)),"object"===r?c:JSON.stringify(c)},g.modifyFrames=function(t,e){var n,r,i,a=t._transitionData._frames,o=t._transitionData._frameHash;for(n=0;n0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){h=!0}),i.redraw&&t._transitionData._interruptCallbacks.push(function(){return a.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var r,s,u=0,c=0;function f(){return u++,function(){var n;c++,h||c!==u||(n=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(i.redraw)return a.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(n)))}}var d=t._fullLayout._basePlotModules,m=!1;if(n)for(s=0;s=0;s--)if(o[s].enabled){n._indexToPoints=o[s]._indexToPoints;break}r&&r.calc&&(a=r.calc(t,n))}Array.isArray(a)&&a[0]||(a=[{x:c,y:c}]),a[0].t||(a[0].t={}),a[0].trace=n,d[e]=a}}for(v&&S(u),i=0;i=0?p.angularAxis.domain:r.extent(k),C=Math.abs(k[1]-k[0]);A&&!T&&(C=0);var z=S.slice();M&&T&&(z[1]+=C);var L=p.angularAxis.ticksCount||4;L>8&&(L=L/(L/8)+L%8),p.angularAxis.ticksStep&&(L=(z[1]-z[0])/L);var E=p.angularAxis.ticksStep||(z[1]-z[0])/(L*(p.minorTicks+1));w&&(E=Math.max(Math.round(E),1)),z[2]||(z[2]=E);var I=r.range.apply(this,z);if(I=I.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=r.scale.linear().domain(z.slice(0,2)).range("clockwise"===p.direction?[0,360]:[360,0]),c.layout.angularAxis.domain=s.domain(),c.layout.angularAxis.endPadding=M?C:0,"undefined"==typeof(t=r.select(this).select("svg.chart-root"))||t.empty()){var P=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),D=this.appendChild(this.ownerDocument.importNode(P.documentElement,!0));t=r.select(D)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var O,R=t.select(".chart-group"),F={fill:"none",stroke:p.tickColor},B={"font-size":p.font.size,"font-family":p.font.family,fill:p.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+p.font.outlineColor}).join(",")};if(p.showLegend){O=t.select(".legend-group").attr({transform:"translate("+[_,p.margin.top]+")"}).style({display:"block"});var N=h.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:h.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:O,elements:N,reverseOrder:p.legend.reverseOrder})})();var j=O.node().getBBox();_=Math.min(p.width-j.width-p.margin.left-p.margin.right,p.height-p.margin.top-p.margin.bottom)/2,_=Math.max(10,_),b=[p.margin.left+_,p.margin.top+_],n.range([0,_]),c.layout.radialAxis.domain=n.domain(),O.attr("transform","translate("+[b[0]+_,b[1]-_]+")")}else O=t.select(".legend-group").style({display:"none"});t.attr({width:p.width,height:p.height}).style({opacity:p.opacity}),R.attr("transform","translate("+b+")").style({cursor:"crosshair"});var V=[(p.width-(p.margin.left+p.margin.right+2*_+(j?j.width:0)))/2,(p.height-(p.margin.top+p.margin.bottom+2*_))/2];if(V[0]=Math.max(0,V[0]),V[1]=Math.max(0,V[1]),t.select(".outer-group").attr("transform","translate("+V+")"),p.title&&p.title.text){var q=t.select("g.title-group text").style(B).text(p.title.text),U=q.node().getBBox();q.attr({x:b[0]-U.width/2,y:b[1]-_-20})}var H=t.select(".radial.axis-group");if(p.radialAxis.gridLinesVisible){var Z=H.selectAll("circle.grid-circle").data(n.ticks(5));Z.enter().append("circle").attr({class:"grid-circle"}).style(F),Z.attr("r",n),Z.exit().remove()}H.select("circle.outside-circle").attr({r:_}).style(F);var G=t.select("circle.background-circle").attr({r:_}).style({fill:p.backgroundColor,stroke:p.stroke});function $(t,e){return s(t)%360+p.orientation}if(p.radialAxis.visible){var W=r.svg.axis().scale(n).ticks(5).tickSize(5);H.call(W).attr({transform:"rotate("+p.radialAxis.orientation+")"}),H.selectAll(".domain").style(F),H.selectAll("g>text").text(function(t,e){return this.textContent+p.radialAxis.ticksSuffix}).style(B).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===p.radialAxis.tickOrientation?"rotate("+-p.radialAxis.orientation+") translate("+[0,B["font-size"]]+")":"translate("+[0,B["font-size"]]+")"}}),H.selectAll("g>line").style({stroke:"black"})}var X=t.select(".angular.axis-group").selectAll("g.angular-tick").data(I),Y=X.enter().append("g").classed("angular-tick",!0);X.attr({transform:function(t,e){return"rotate("+$(t)+")"}}).style({display:p.angularAxis.visible?"block":"none"}),X.exit().remove(),Y.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(p.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(p.minorTicks+1)==0)}).style(F),Y.selectAll(".minor").style({stroke:p.minorTickColor}),X.select("line.grid-line").attr({x1:p.tickLength?_-p.tickLength:0,x2:_}).style({display:p.angularAxis.gridLinesVisible?"block":"none"}),Y.append("text").classed("axis-text",!0).style(B);var J=X.select("text.axis-text").attr({x:_+p.labelOffset,dy:a+"em",transform:function(t,e){var n=$(t),r=_+p.labelOffset,i=p.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-n+" "+r+" 0)":"radial"==i?n<270&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(n<=180&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:p.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(p.minorTicks+1)!=0?"":w?w[t]+p.angularAxis.ticksSuffix:t+p.angularAxis.ticksSuffix}).style(B);p.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(p.minorTicks+1)!=0?"":p.angularAxis.rewriteTicks(this.textContent,e)});var K=r.max(R.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));O.attr({transform:"translate("+[_+K,p.margin.top]+")"});var Q=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(h);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),h[0]||Q){var et=[];h.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=tt.filter(function(t,n){return n==e}),r.geometry=t.geometry,r.orientation=p.orientation,r.direction=p.direction,r.index=e,et.push({data:t,geometryConfig:r})});var nt=r.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),rt=[];nt.forEach(function(t,e){"unstacked"===t.key?rt=rt.concat(t.values.map(function(t,e){return[t]})):rt.push(t.values)}),rt.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return i(o[n].defaultConfig(),t)});o[n]().config(r)()})}var it,at,ot=t.select(".guides-group"),st=t.select(".tooltips-group"),lt=o.tooltipPanel().config({container:st,fontSize:8})(),ut=o.tooltipPanel().config({container:st,fontSize:8})(),ct=o.tooltipPanel().config({container:st,hasTick:!0})();if(!T){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});R.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos(G).angle;ft.attr({x2:-_,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-p.orientation)%360;it=s.invert(r);var i=o.util.convertToCartesian(_+12,n+180);lt.text(o.util.round(it)).move([i[0]+b[0],i[1]+b[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var pt=ot.select("circle").style({stroke:"grey",fill:"none"});R.on("mousemove.radial-guide",function(t,e){var r=o.util.getMousePos(G).radius;pt.attr({r:r}).style({opacity:.5}),at=n.invert(o.util.getMousePos(G).radius);var i=o.util.convertToCartesian(r,p.radialAxis.orientation);ut.text(o.util.round(at)).move([i[0]+b[0],i[1]+b[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ct.hide(),lt.hide(),ut.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,n){var i=r.select(this),a=this.style.fill,s="black",l=this.style.opacity||1;if(i.attr({"data-opacity":l}),a&&"none"!==a){i.attr({"data-fill":a}),s=r.hsl(a).darker().toString(),i.style({fill:s,opacity:1});var u={t:o.util.round(e[0]),r:o.util.round(e[1])};T&&(u.t=w[e[0]]);var c="t: "+u.t+", r: "+u.r,f=this.getBoundingClientRect(),p=t.node().getBoundingClientRect(),h=[f.left+f.width/2-V[0]-p.left,f.top+f.height/2-V[1]-p.top];ct.config({color:s}).text(c),ct.move(h)}else a=this.style.stroke||"black",i.attr({"data-stroke":a}),s=r.hsl(a).darker().toString(),i.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=r.event.which)return!1;r.select(this).attr("data-fill")&&ct.show()}).on("mouseout.tooltip",function(t,e){ct.hide();var n=r.select(this),i=n.attr("data-fill");i?n.style({fill:i,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})})}(u),this},p.config=function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),i(l.data[e],o.Axis.defaultConfig().data[0]),i(l.data[e],t)}),i(l.layout,o.Axis.defaultConfig().layout),i(l.layout,e.layout),this},p.getLiveConfig=function(){return c},p.getinputConfig=function(){return u},p.radialScale=function(t){return n},p.angularScale=function(t){return s},p.svg=function(){return t},r.rebind(p,f,"on"),p},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:r.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6;return r.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180;return[e,t(r)]})},o.util.dataFromEquation=function(t,e,n){var i=e||6,a=[],o=[];r.range(0,360+i,i).forEach(function(e,n){var r=e*Math.PI/180,i=t(r);a.push(e),o.push(i)});var s={t:a,r:o};return n&&(s.name=n),s},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return r.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return r.zip(t,e).map(function(t,e){return r.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return-2===n},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180;return[t*Math.cos(n),t*Math.sin(n)]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=r.mouse(t.node()),n=e[0],i=e[1],a={};return a.x=n,a.y=i,a.pos=e,a.angle=180*(Math.atan2(i,n)+Math.PI)/Math.PI,a.radius=Math.sqrt(n*n+i*i),a},o.util.duplicatesCount=function(t){for(var e,n={},r={},i=0,a=t.length;i0)){var l=r.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:c(s),transform:function(t,n){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return d.fill(n,i,a)},"fill-opacity":0,stroke:function(t,e){return d.stroke(n,i,a)},"stroke-width":function(t,e){return d["stroke-width"](n,i,a)},"stroke-dasharray":function(t,e){return d["stroke-dasharray"](n,i,a)},opacity:function(t,e){return d.opacity(n,i,a)},display:function(t,e){return d.display(n,i,a)}})}};var f=e.angularScale.range(),p=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,h=r.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(t){return e.radialScale(l+(t[2]||0))}).outerRadius(function(t){return e.radialScale(l+(t[2]||0))+e.radialScale(t[1])});u.arc=function(t,n,i){r.select(this).attr({class:"mark arc",d:h,transform:function(t,n){return"rotate("+(e.orientation+s(t[0])+90)+")"}})};var d={fill:function(e,n,r){return t[r].data.color},stroke:function(e,n,r){return t[r].data.strokeColor},"stroke-width":function(e,n,r){return t[r].data.strokeSize+"px"},"stroke-dasharray":function(e,r,i){return n[t[i].data.strokeDash]},opacity:function(e,n,r){return t[r].data.opacity},display:function(e,n,r){return"undefined"==typeof t[r].data.visible||t[r].data.visible?"block":"none"}},m=r.select(this).selectAll("g.layer").data(o);m.enter().append("g").attr({class:"layer"});var g=m.selectAll("path.mark").data(function(t,e){return t});g.enter().append("path").attr({class:"mark"}),g.style(d).each(u[e.geometryType]),g.exit().remove(),m.exit().remove()})}return a.config=function(e){return arguments.length?(e.forEach(function(e,n){t[n]||(t[n]={}),i(t[n],o.PolyChart.defaultConfig()),i(t[n],e)}),this):t},a.getColorScale=function(){},r.rebind(a,e,"on"),a},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:r.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=r.dispatch("hover");function n(){var e=t.legendConfig,a=t.data.map(function(t,n){return[].concat(t).map(function(t,r){var a=i({},e.elements[n]);return a.name=t,a.color=[].concat(e.elements[n].color)[r],a})}),o=r.merge(a);o=o.filter(function(t,n){return e.elements[n]&&(e.elements[n].visibleInLegend||"undefined"==typeof e.elements[n].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var s=e.container;("string"==typeof s||s.nodeName)&&(s=r.select(s));var l=o.map(function(t,e){return t.color}),u=e.fontSize,c=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=c?e.height:u*o.length,p=s.classed("legend-group",!0).selectAll("svg").data([0]),h=p.enter().append("svg").attr({width:300,height:f+u,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});h.append("g").classed("legend-axis",!0),h.append("g").classed("legend-marks",!0);var d=r.range(o.length),m=r.scale[c?"linear":"ordinal"]().domain(d).range(l),g=r.scale[c?"linear":"ordinal"]().domain(d)[c?"range":"rangePoints"]([0,f]);if(c){var y=p.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);y.enter().append("stop"),y.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),p.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var v=p.select(".legend-marks").selectAll("path.legend-mark").data(o);v.enter().append("path").classed("legend-mark",!0),v.attr({transform:function(t,e){return"translate("+[u/2,g(e)+u/2]+")"},d:function(t,e){var n,i,a,o=t.symbol;return a=3*(i=u),"line"===(n=o)?"M"+[[-i/2,-i/12],[i/2,-i/12],[i/2,i/12],[-i/2,i/12]]+"Z":-1!=r.svg.symbolTypes.indexOf(n)?r.svg.symbol().type(n).size(a)():r.svg.symbol().type("square").size(a)()},fill:function(t,e){return m(e)}}),v.exit().remove()}var _=r.svg.axis().scale(g).orient("right"),x=p.select("g.legend-axis").attr({transform:"translate("+[c?e.colorBandWidth:u,u/2]+")"}).call(_);return x.selectAll(".domain").style({fill:"none",stroke:"none"}),x.selectAll("line").style({fill:"none",stroke:c?e.textColor:"none"}),x.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),n}return n.config=function(e){return arguments.length?(i(t,e),this):t},r.rebind(n,e,"on"),n},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,n,a={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,u=function(){var r=(t=a.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return n=r.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=r.append("text").attr({dx:a.padding+l,dy:.3*+a.fontSize}),u};return u.text=function(i){var o=r.hsl(a.color).l,s=o>=.5?"#aaa":"white",c=o>=.5?"black":"white",f=i||"";e.style({fill:c,"font-size":a.fontSize+"px"}).text(f);var p=a.padding,h=e.node().getBBox(),d={fill:a.color,stroke:s,"stroke-width":"2px"},m=h.width+2*p+l,g=h.height+2*p;return n.attr({d:"M"+[[l,-g/2],[l,-g/4],[a.hasTick?0:l,0],[l,g/4],[l,g/2],[m,g/2],[m,-g/2]].join("L")+"Z"}).style(d),t.attr({transform:"translate("+[l,-g/2+2*p]+")"}),t.style({display:"block"}),u},u.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),u},u.hide=function(){if(t)return t.style({display:"none"}),u},u.show=function(){if(t)return t.style({display:"block"}),u},u.config=function(t){return i(a,t),u},u},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=i({},t);return[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]].forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",!0===r.dotVisible?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var a=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var r=a.indexOf(t.geometry);-1!=r&&(n.data[e].groupId=r)})}if(t.layout){var s=i({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var l=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],c={};r.entries(s.margin).forEach(function(t,e){c[u[l.indexOf(t.key)]]=t.value}),s.margin=c}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),n.layout=s}return n}};return t}},{"../../../constants/alignment":138,"../../../lib":160,d3:7}],249:[function(t,e,n){"use strict";var r=t("d3"),i=t("../../../lib"),a=t("../../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=i.extendDeepAll,u=e.exports={};u.framework=function(t){var e,n,i,a,c,f=new s;function p(n,s){return s&&(c=s),r.select(r.select(c).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?l(e,n):n,i||(i=o.Axis()),a=o.adapter.plotly().convert(e),i.config(a).render(c),t.data=e.data,t.layout=e.layout,u.fillLayout(t),e}return p.isPolar=!0,p.svg=function(){return i.svg()},p.getConfig=function(){return e},p.getLiveConfig=function(){return o.adapter.plotly().convert(i.getLiveConfig(),!0)},p.getLiveScales=function(){return{t:i.angularScale(),r:i.radialScale()}},p.setUndoPoint=function(){var t,r,i=this,a=o.util.cloneJson(e);t=a,r=n,f.add({undo:function(){r&&i(r)},redo:function(){i(t)}}),n=o.util.cloneJson(a)},p.undo=function(){f.undo()},p.redo=function(){f.redo()},p},u.fillLayout=function(t){var e=r.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),i=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:a.background,_container:e,_paperdiv:n,_paper:i};t._fullLayout=l(o,t.layout)}},{"../../../components/color":43,"../../../lib":160,"./micropolar":248,"./undo_manager":250,d3:7}],250:[function(t,e,n){"use strict";e.exports=function(){var t,e=[],n=-1,r=!1;function i(t,e){return t?(r=!0,t[e](),r=!1,this):this}return{add:function(t){return r?this:(e.splice(n+1,e.length-n),e.push(t),n=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var r=e[n];return r?(i(r,"undo"),n-=1,t&&t(r.undo),this):this},redo:function(){var r=e[n+1];return r?(i(r,"redo"),n+=1,t&&t(r.redo),this):this},clear:function(){e=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return n-1&&(c[p[n]].title={text:""});for(n=0;npath, .legendlines>path, .cbfill").each(function(){var t=r.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(l,"TOBESTRIPPED"));var n=this.style.stroke;n&&-1!==n.indexOf("url(")&&t.style("stroke",n.replace(l,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||p.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),p.node().setAttributeNS(s.xmlns,"xmlns",s.svg),p.node().setAttributeNS(s.xmlns,"xmlns:xlink",s.xlink),"svg"===e&&n&&(p.attr("width",n*d),p.attr("height",n*m),p.attr("viewBox","0 0 "+d+" "+m));var b=(new window.XMLSerializer).serializeToString(p.node());return b=function(t){var e=r.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),n}(b),b=(b=b.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(u,"'"),i.isIE()&&(b=(b=(b=b.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),b}},{"../components/color":43,"../components/drawing":64,"../constants/xmlns_namespaces":141,"../lib":160,d3:7}],261:[function(t,e,n){"use strict";var r=t("../../lib");n.formatPiePercent=function(t,e){var n=(100*t).toPrecision(3);return-1!==n.lastIndexOf(".")&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)+"%"},n.formatPieValue=function(t,e){var n=t.toPrecision(10);return-1!==n.lastIndexOf(".")&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)},n.getFirstFilled=function(t,e){if(Array.isArray(t))for(var n=0;ns&&A[g].gap;)g--;for(v=A[g].s,d=A.length-1;d>g;d--)A[d].s=v;for(;sM[c]&&c=0;i--){var a=t[i];if("scatter"===a.type&&a.xaxis===n.xaxis&&a.yaxis===n.yaxis){a.opacity=void 0;break}}}}}},{}],271:[function(t,e,n){"use strict";var r=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("./constants"),s=t("./subtypes"),l=t("./xy_defaults"),u=t("./stack_defaults"),c=t("./marker_defaults"),f=t("./line_defaults"),p=t("./line_shape_defaults"),h=t("./text_defaults"),d=t("./fillcolor_defaults");e.exports=function(t,e,n,m){function g(n,i){return r.coerce(t,e,a,n,i)}var y=l(t,e,m,g);if(y||(e.visible=!1),e.visible){var v=u(t,e,m,g),_=!v&&yZ!=(F=I[L][1])>=Z&&(D=I[L-1][0],O=I[L][0],F-R&&(P=D+(O-D)*(Z-R)/(F-R),V=Math.min(V,P),q=Math.max(q,P)));V=Math.max(V,0),q=Math.min(q,p._length);var G=s.defaultLine;return s.opacity(f.fillcolor)?G=f.fillcolor:s.opacity((f.line||{}).color)&&(G=f.line.color),r.extendFlat(t,{distance:t.maxHoverDistance,x0:V,x1:q,y0:Z,y1:Z,color:G,hovertemplate:"%{name}"}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":43,"../../components/fx":82,"../../lib":160,"../../registry":252,"./fill_hover_text":272,"./get_trace_color":274}],276:[function(t,e,n){"use strict";var r={},i=t("./subtypes");r.hasLines=i.hasLines,r.hasMarkers=i.hasMarkers,r.hasText=i.hasText,r.isBubble=i.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.crossTraceDefaults=t("./cross_trace_defaults"),r.calc=t("./calc").calc,r.crossTraceCalc=t("./cross_trace_calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./marker_colorbar"),r.style=t("./style").style,r.styleOnSelect=t("./style").styleOnSelect,r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.animatable=!0,r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],r.meta={},e.exports=r},{"../../plots/cartesian":216,"./arrays_to_calcdata":263,"./attributes":264,"./calc":265,"./cross_trace_calc":269,"./cross_trace_defaults":270,"./defaults":271,"./hover":275,"./marker_colorbar":282,"./plot":284,"./select":285,"./style":287,"./subtypes":288}],277:[function(t,e,n){"use strict";var r=t("../../lib").isArrayOrTypedArray,i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,s,l){var u=(t.marker||{}).color;(s("line.color",n),i(t,"line"))?a(t,e,o,s,{prefix:"line.",cLetter:"c",noScale:!0}):s("line.color",!r(u)&&u||n);s("line.width"),(l||{}).noDash||s("line.dash")}},{"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54,"../../lib":160}],278:[function(t,e,n){"use strict";var r=t("../../constants/numerical"),i=r.BADNUM,a=r.LOG_CLIP,o=a+.5,s=a-.5,l=t("../../lib"),u=l.segmentsIntersect,c=l.constrain,f=t("./constants");e.exports=function(t,e){var n,r,a,p,h,d,m,g,y,v,_,x,b,w,k,T,A,M,S=e.xaxis,C=e.yaxis,z="log"===S.type,L="log"===C.type,E=S._length,I=C._length,P=e.connectGaps,D=e.baseTolerance,O=e.shape,R="linear"===O,F=[],B=f.minTolerance,N=new Array(t.length),j=0;function V(e){var n=t[e];if(!n)return!1;var r=S.c2p(n.x),a=C.c2p(n.y);if(r===i){if(z&&(r=S.c2p(n.x,!0)),r===i)return!1;L&&a===i&&(r*=Math.abs(S._m*I*(S._m>0?o:s)/(C._m*E*(C._m>0?o:s)))),r*=1e3}if(a===i){if(L&&(a=C.c2p(n.y,!0)),a===i)return!1;a*=1e3}return[r,a]}function q(t,e,n,r){var i=n-t,a=r-e,o=.5-t,s=.5-e,l=i*i+a*a,u=i*o+a*s;if(u>0&&utt||t[1]nt)return[c(t[0],Q,tt),c(t[1],et,nt)]}function at(t,e){return t[0]===e[0]&&(t[0]===Q||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===nt)||void 0)}function ot(t,e,n){return function(r,i){var a=it(r),o=it(i),s=[];if(a&&o&&at(a,o))return s;a&&s.push(a),o&&s.push(o);var u=2*l.constrain((r[t]+i[t])/2,e,n)-((a||r)[t]+(o||i)[t]);u&&((a&&o?u>0==a[t]>o[t]?a:o:a||o)[t]+=u);return s}}function st(t){var e=t[0],n=t[1],r=e===N[j-1][0],i=n===N[j-1][1];if(!r||!i)if(j>1){var a=e===N[j-2][0],o=n===N[j-2][1];r&&(e===Q||e===tt)&&a?o?j--:N[j-1]=t:i&&(n===et||n===nt)&&o?a?j--:N[j-1]=t:N[j++]=t}else N[j++]=t}function lt(t){N[j-1][0]!==t[0]&&N[j-1][1]!==t[1]&&st([$,W]),st(t),X=null,$=W=0}function ut(t){if(A=t[0]/E,M=t[1]/I,Z=t[0]tt?tt:0,G=t[1]nt?nt:0,Z||G){if(j)if(X){var e=J(X,t);e.length>1&&(lt(e[0]),N[j++]=e[1])}else Y=J(N[j-1],t)[0],N[j++]=Y;else N[j++]=[Z||t[0],G||t[1]];var n=N[j-1];Z&&G&&(n[0]!==Z||n[1]!==G)?(X&&($!==Z&&W!==G?st($&&W?(r=X,a=(i=t)[0]-r[0],o=(i[1]-r[1])/a,(r[1]*i[0]-i[1]*r[0])/a>0?[o>0?Q:tt,nt]:[o>0?tt:Q,et]):[$||Z,W||G]):$&&W&&st([$,W])),st([Z,G])):$-Z&&W-G&&st([Z||$,G||W]),X=t,$=Z,W=G}else X&<(J(X,t)[0]),N[j++]=t;var r,i,a,o}for("linear"===O||"spline"===O?J=function(t,e){for(var n=[],r=0,i=0;i<4;i++){var a=rt[i],o=u(t[0],t[1],e[0],e[1],a[0],a[1],a[2],a[3]);o&&(!r||Math.abs(o.x-n[0][0])>1||Math.abs(o.y-n[0][1])>1)&&(o=[o.x,o.y],r&&H(o,t)U(d,ct))break;a=d,(b=y[0]*g[0]+y[1]*g[1])>_?(_=b,p=d,m=!1):b=t.length||!d)break;ut(d),r=d}}else ut(p)}X&&st([$||X[0],W||X[1]]),F.push(N.slice(0,j))}return F}},{"../../constants/numerical":140,"../../lib":160,"./constants":268}],279:[function(t,e,n){"use strict";e.exports=function(t,e,n){"spline"===n("line.shape")&&n("line.smoothing")}},{}],280:[function(t,e,n){"use strict";var r={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,n){var i,a,o,s,l,u={},c=!1,f=-1,p=0,h=-1;for(a=0;a=0?l=h:(l=h=p,p++),l0?Math.max(e,i):0}}},{"fast-isnumeric":9}],282:[function(t,e,n){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],283:[function(t,e,n){"use strict";var r=t("../../components/color"),i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,n,s,l,u){var c=o.isBubble(t),f=(t.line||{}).color;(u=u||{},f&&(n=f),l("marker.symbol"),l("marker.opacity",c?.7:1),l("marker.size"),l("marker.color",n),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),u.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),u.noLine||(l("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:c?r.background:r.defaultLine),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",c?1:0)),c&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),u.gradient)&&("none"!==l("marker.gradient.type")&&l("marker.gradient.color"))}},{"../../components/color":43,"../../components/colorscale/defaults":53,"../../components/colorscale/helpers":54,"./subtypes":288}],284:[function(t,e,n){"use strict";var r=t("d3"),i=t("../../registry"),a=t("../../lib"),o=a.ensureSingle,s=a.identity,l=t("../../components/drawing"),u=t("./subtypes"),c=t("./line_points"),f=t("./link_traces"),p=t("../../lib/polygon").tester;function h(t,e,n,f,h,d,m){var g;!function(t,e,n,i,o){var s=n.xaxis,l=n.yaxis,c=r.extent(a.simpleMap(s.range,s.r2c)),f=r.extent(a.simpleMap(l.range,l.r2c)),p=i[0].trace;if(!u.hasMarkers(p))return;var h=p.marker.maxdisplayed;if(0===h)return;var d=i.filter(function(t){return t.x>=c[0]&&t.x<=c[1]&&t.y>=f[0]&&t.y<=f[1]}),m=Math.ceil(d.length/h),g=0;o.forEach(function(t,n){var r=t[0].trace;u.hasMarkers(r)&&r.marker.maxdisplayed>0&&n0;function v(t){return y?t.transition():t}var _=n.xaxis,x=n.yaxis,b=f[0].trace,w=b.line,k=r.select(d),T=o(k,"g","errorbars"),A=o(k,"g","lines"),M=o(k,"g","points"),S=o(k,"g","text");if(i.getComponentMethod("errorbars","plot")(t,T,n,m),!0===b.visible){var C,z;v(k).style("opacity",b.opacity);var L=b.fill.charAt(b.fill.length-1);"x"!==L&&"y"!==L&&(L=""),n.isRangePlot||(f[0].node3=k);var E="",I=[],P=b._prevtrace;P&&(E=P._prevRevpath||"",z=P._nextFill,I=P._polygons);var D,O,R,F,B,N,j,V,q,U="",H="",Z=[],G=a.noop;if(C=b._ownFill,u.hasLines(b)||"none"!==b.fill){for(z&&z.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(R=l.steps(w.shape),F=l.steps(w.shape.split("").reverse().join(""))):R=F="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?l.smoothclosed(t.slice(1),w.smoothing):l.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},B=function(t){return F(t.reverse())},Z=c(f,{xaxis:_,yaxis:x,connectGaps:b.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),q=b._polygons=new Array(Z.length),g=0;g1){var n=r.select(this);if(n.datum(f),t)v(n.style("opacity",0).attr("d",D).call(l.lineGroupStyle)).style("opacity",1);else{var i=v(n);i.attr("d",D),l.singleLineStyle(f,i)}}}}}var $=A.selectAll(".js-line").data(Z);v($.exit()).style("opacity",0).remove(),$.each(G(!1)),$.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(l.lineGroupStyle).each(G(!0)),l.setClipUrl($,n.layerClipId,t),Z.length?(C?(C.datum(f),N&&V&&(L?("y"===L?N[1]=V[1]=x.c2p(0,!0):"x"===L&&(N[0]=V[0]=_.c2p(0,!0)),v(C).attr("d","M"+V+"L"+N+"L"+U.substr(1)).call(l.singleFillStyle)):v(C).attr("d",U+"Z").call(l.singleFillStyle))):z&&("tonext"===b.fill.substr(0,6)&&U&&E?("tonext"===b.fill?v(z).attr("d",U+"Z"+E+"Z").call(l.singleFillStyle):v(z).attr("d",U+"L"+E.substr(1)+"Z").call(l.singleFillStyle),b._polygons=b._polygons.concat(I)):(X(z),b._polygons=null)),b._prevRevpath=H,b._prevPolygons=q):(C?X(C):z&&X(z),b._polygons=b._prevRevpath=b._prevPolygons=null),M.datum(f),S.datum(f),function(e,i,a){var o,c=a[0].trace,f=u.hasMarkers(c),p=u.hasText(c),h=tt(c),d=et,m=et;if(f||p){var g=s,b=c.stackgroup,w=b&&"infer zero"===t._fullLayout._scatterStackOpts[_._id+x._id][b].stackgaps;c.marker.maxdisplayed||c._needsCull?g=w?J:Y:b&&!w&&(g=K),f&&(d=g),p&&(m=g)}var k,T=(o=e.selectAll("path.point").data(d,h)).enter().append("path").classed("point",!0);y&&T.call(l.pointStyle,c,t).call(l.translatePoints,_,x).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=l.makePointStyleFns(c)),o.each(function(e){var i=r.select(this),a=v(i);l.translatePoint(e,a,_,x)?(l.singlePointStyle(e,a,c,k,t),n.layerClipId&&l.hideOutsideRangePoint(e,a,_,x,c.xcalendar,c.ycalendar),c.customdata&&i.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):a.remove()}),y?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=i.selectAll("g").data(m,h)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=r.select(this),i=v(e.select("text"));l.translatePoint(t,i,_,x)?n.layerClipId&&l.hideOutsideRangePoint(t,e,_,x,c.xcalendar,c.ycalendar):e.remove()}),o.selectAll("text").call(l.textPointStyle,c,t).each(function(t){var e=_.c2p(t.x),n=x.c2p(t.y);r.select(this).selectAll("tspan.line").each(function(){v(r.select(this)).attr({x:e,y:n})})}),o.exit().remove()}(M,S,f);var W=!1===b.cliponaxis?null:n.layerClipId;l.setClipUrl(M,W,t),l.setClipUrl(S,W,t)}function X(t){v(t).attr("d","M0,0Z")}function Y(t){return t.filter(function(t){return!t.gap&&t.vis})}function J(t){return t.filter(function(t){return t.vis})}function K(t){return t.filter(function(t){return!t.gap})}function Q(t){return t.id}function tt(t){if(t.ids)return Q}function et(){return!1}}e.exports=function(t,e,n,i,a,u){var c,p,d=!a,m=!!a&&a.duration>0,g=f(t,e,n);((c=i.selectAll("g.trace").data(g,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),c.order(),function(t,e,n){e.each(function(e){var i=o(r.select(this),"g","fills");l.setClipUrl(i,n.layerClipId,t);var a=e[0].trace,u=[];a._ownfill&&u.push("_ownFill"),a._nexttrace&&u.push("_nextFill");var c=i.selectAll("g").data(u,s);c.enter().append("g"),c.exit().each(function(t){a[t]=null}).remove(),c.order().each(function(t){a[t]=o(r.select(this),"path","js-fill")})})}(t,c,e),m)?(u&&(p=u()),r.transition().duration(a.duration).ease(a.easing).each("end",function(){p&&p()}).each("interrupt",function(){p&&p()}).each(function(){i.selectAll("g.trace").each(function(n,r){h(t,r,e,n,g,this,a)})})):c.each(function(n,r){h(t,r,e,n,g,this,a)});d&&c.exit().remove(),i.selectAll("path:not([d])").remove()}},{"../../components/drawing":64,"../../lib":160,"../../lib/polygon":172,"../../registry":252,"./line_points":278,"./link_traces":280,"./subtypes":288,d3:7}],285:[function(t,e,n){"use strict";var r=t("./subtypes");e.exports=function(t,e){var n,i,a,o,s=t.cd,l=t.xaxis,u=t.yaxis,c=[],f=s[0].trace;if(!r.hasMarkers(f)&&!r.hasText(f))return[];if(!1===e)for(n=0;n=0?Math.floor((e+180)/360):Math.ceil((e-180)/360)),d=e-h;if(r.getClosest(l,function(t){var e=t.lonlat;if(e[0]===s)return 1/0;var r=i.modHalf(e[0],360),a=e[1],o=p.project([r,a]),l=o.x-c.c2p([d,a]),u=o.y-f.c2p([r,n]),h=Math.max(3,t.mrc||0);return Math.max(Math.sqrt(l*l+u*u)-h,1-3/h)},t),!1!==t.index){var m=l[t.index],g=m.lonlat,y=[i.modHalf(g[0],360)+h,g[1]],v=c.c2p(y),_=f.c2p(y),x=m.mrc||1;return t.x0=v-x,t.x1=v+x,t.y0=_-x,t.y1=_+x,t.color=a(u,m),t.extraText=function(t,e,n){var r=(e.hi||t.hoverinfo).split("+"),i=-1!==r.indexOf("all"),a=-1!==r.indexOf("lon"),s=-1!==r.indexOf("lat"),l=e.lonlat,u=[];function c(t){return t+"\xb0"}i||a&&s?u.push("("+c(l[0])+", "+c(l[1])+")"):a?u.push(n.lon+c(l[0])):s&&u.push(n.lat+c(l[1]));(i||-1!==r.indexOf("text"))&&o(e,t,u);return u.join("
")}(u,m,l[0].t.labels),[t]}}},{"../../components/fx":82,"../../constants/numerical":140,"../../lib":160,"../scatter/fill_hover_text":272,"../scatter/get_trace_color":274}],298:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../scatter/marker_colorbar"),r.calc=t("../scattergeo/calc"),r.plot=t("./plot"),r.hoverPoints=t("./hover"),r.eventData=t("./event_data"),r.selectPoints=t("./select"),r.style=function(t,e){e&&e[0].trace._glTrace.update(e)},r.moduleType="trace",r.name="scattermapbox",r.basePlotModule=t("../../plots/mapbox"),r.categories=["mapbox","gl","symbols","showLegend","scatterlike"],r.meta={},e.exports=r},{"../../plots/mapbox":238,"../scatter/marker_colorbar":282,"../scattergeo/calc":292,"./attributes":293,"./defaults":295,"./event_data":296,"./hover":297,"./plot":299,"./select":300}],299:[function(t,e,n){"use strict";var r=t("./convert");function i(t,e){this.subplot=t,this.uid=e,this.sourceIds={fill:e+"-source-fill",line:e+"-source-line",circle:e+"-source-circle",symbol:e+"-source-symbol"},this.layerIds={fill:e+"-layer-fill",line:e+"-layer-line",circle:e+"-layer-circle",symbol:e+"-layer-symbol"},this.order=["fill","line","circle","symbol"]}var a=i.prototype;a.addSource=function(t,e){this.subplot.map.addSource(this.sourceIds[t],{type:"geojson",data:e.geojson})},a.setSourceData=function(t,e){this.subplot.map.getSource(this.sourceIds[t]).setData(e.geojson)},a.addLayer=function(t,e){this.subplot.map.addLayer({type:t,id:this.layerIds[t],source:this.sourceIds[t],layout:e.layout,paint:e.paint})},a.update=function(t){for(var e=this.subplot,n=r(t),i=0;i:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", + "X:hover .modebar--hover .modebar-group": "opacity:1;", "X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;", "X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;", "X .modebar-btn svg": "position:relative;top:2px;", @@ -71,7 +71,7 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":696}],2:[function(_dereq_,module,exports){ +},{"../src/lib":692}],2:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -214,7 +214,7 @@ module.exports = { module.exports = _dereq_('../src/transforms/aggregate'); -},{"../src/transforms/aggregate":1155}],4:[function(_dereq_,module,exports){ +},{"../src/transforms/aggregate":1152}],4:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -227,7 +227,7 @@ module.exports = _dereq_('../src/transforms/aggregate'); module.exports = _dereq_('../src/traces/bar'); -},{"../src/traces/bar":843}],5:[function(_dereq_,module,exports){ +},{"../src/traces/bar":840}],5:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -240,7 +240,7 @@ module.exports = _dereq_('../src/traces/bar'); module.exports = _dereq_('../src/traces/barpolar'); -},{"../src/traces/barpolar":855}],6:[function(_dereq_,module,exports){ +},{"../src/traces/barpolar":852}],6:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -253,7 +253,7 @@ module.exports = _dereq_('../src/traces/barpolar'); module.exports = _dereq_('../src/traces/box'); -},{"../src/traces/box":865}],7:[function(_dereq_,module,exports){ +},{"../src/traces/box":862}],7:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -266,7 +266,7 @@ module.exports = _dereq_('../src/traces/box'); module.exports = _dereq_('../src/components/calendars'); -},{"../src/components/calendars":568}],8:[function(_dereq_,module,exports){ +},{"../src/components/calendars":567}],8:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -279,7 +279,7 @@ module.exports = _dereq_('../src/components/calendars'); module.exports = _dereq_('../src/traces/candlestick'); -},{"../src/traces/candlestick":874}],9:[function(_dereq_,module,exports){ +},{"../src/traces/candlestick":871}],9:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -292,7 +292,7 @@ module.exports = _dereq_('../src/traces/candlestick'); module.exports = _dereq_('../src/traces/carpet'); -},{"../src/traces/carpet":893}],10:[function(_dereq_,module,exports){ +},{"../src/traces/carpet":890}],10:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -305,7 +305,7 @@ module.exports = _dereq_('../src/traces/carpet'); module.exports = _dereq_('../src/traces/choropleth'); -},{"../src/traces/choropleth":907}],11:[function(_dereq_,module,exports){ +},{"../src/traces/choropleth":904}],11:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -318,7 +318,7 @@ module.exports = _dereq_('../src/traces/choropleth'); module.exports = _dereq_('../src/traces/cone'); -},{"../src/traces/cone":915}],12:[function(_dereq_,module,exports){ +},{"../src/traces/cone":912}],12:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -331,7 +331,7 @@ module.exports = _dereq_('../src/traces/cone'); module.exports = _dereq_('../src/traces/contour'); -},{"../src/traces/contour":930}],13:[function(_dereq_,module,exports){ +},{"../src/traces/contour":927}],13:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -344,7 +344,7 @@ module.exports = _dereq_('../src/traces/contour'); module.exports = _dereq_('../src/traces/contourcarpet'); -},{"../src/traces/contourcarpet":941}],14:[function(_dereq_,module,exports){ +},{"../src/traces/contourcarpet":938}],14:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -357,7 +357,7 @@ module.exports = _dereq_('../src/traces/contourcarpet'); module.exports = _dereq_('../src/core'); -},{"../src/core":675}],15:[function(_dereq_,module,exports){ +},{"../src/core":671}],15:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -370,7 +370,7 @@ module.exports = _dereq_('../src/core'); module.exports = _dereq_('../src/transforms/filter'); -},{"../src/transforms/filter":1156}],16:[function(_dereq_,module,exports){ +},{"../src/transforms/filter":1153}],16:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -383,7 +383,7 @@ module.exports = _dereq_('../src/transforms/filter'); module.exports = _dereq_('../src/transforms/groupby'); -},{"../src/transforms/groupby":1157}],17:[function(_dereq_,module,exports){ +},{"../src/transforms/groupby":1154}],17:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -396,7 +396,7 @@ module.exports = _dereq_('../src/transforms/groupby'); module.exports = _dereq_('../src/traces/heatmap'); -},{"../src/traces/heatmap":953}],18:[function(_dereq_,module,exports){ +},{"../src/traces/heatmap":950}],18:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -409,7 +409,7 @@ module.exports = _dereq_('../src/traces/heatmap'); module.exports = _dereq_('../src/traces/heatmapgl'); -},{"../src/traces/heatmapgl":963}],19:[function(_dereq_,module,exports){ +},{"../src/traces/heatmapgl":959}],19:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -422,7 +422,7 @@ module.exports = _dereq_('../src/traces/heatmapgl'); module.exports = _dereq_('../src/traces/histogram'); -},{"../src/traces/histogram":974}],20:[function(_dereq_,module,exports){ +},{"../src/traces/histogram":971}],20:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -435,7 +435,7 @@ module.exports = _dereq_('../src/traces/histogram'); module.exports = _dereq_('../src/traces/histogram2d'); -},{"../src/traces/histogram2d":981}],21:[function(_dereq_,module,exports){ +},{"../src/traces/histogram2d":978}],21:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -448,7 +448,7 @@ module.exports = _dereq_('../src/traces/histogram2d'); module.exports = _dereq_('../src/traces/histogram2dcontour'); -},{"../src/traces/histogram2dcontour":985}],22:[function(_dereq_,module,exports){ +},{"../src/traces/histogram2dcontour":982}],22:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -545,7 +545,7 @@ module.exports = Plotly; module.exports = _dereq_('../src/traces/mesh3d'); -},{"../src/traces/mesh3d":990}],24:[function(_dereq_,module,exports){ +},{"../src/traces/mesh3d":987}],24:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -558,7 +558,7 @@ module.exports = _dereq_('../src/traces/mesh3d'); module.exports = _dereq_('../src/traces/ohlc'); -},{"../src/traces/ohlc":995}],25:[function(_dereq_,module,exports){ +},{"../src/traces/ohlc":992}],25:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -571,7 +571,7 @@ module.exports = _dereq_('../src/traces/ohlc'); module.exports = _dereq_('../src/traces/parcats'); -},{"../src/traces/parcats":1004}],26:[function(_dereq_,module,exports){ +},{"../src/traces/parcats":1001}],26:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -584,7 +584,7 @@ module.exports = _dereq_('../src/traces/parcats'); module.exports = _dereq_('../src/traces/parcoords'); -},{"../src/traces/parcoords":1013}],27:[function(_dereq_,module,exports){ +},{"../src/traces/parcoords":1010}],27:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -597,7 +597,7 @@ module.exports = _dereq_('../src/traces/parcoords'); module.exports = _dereq_('../src/traces/pie'); -},{"../src/traces/pie":1024}],28:[function(_dereq_,module,exports){ +},{"../src/traces/pie":1021}],28:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -610,7 +610,7 @@ module.exports = _dereq_('../src/traces/pie'); module.exports = _dereq_('../src/traces/pointcloud'); -},{"../src/traces/pointcloud":1033}],29:[function(_dereq_,module,exports){ +},{"../src/traces/pointcloud":1030}],29:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -623,7 +623,7 @@ module.exports = _dereq_('../src/traces/pointcloud'); module.exports = _dereq_('../src/traces/sankey'); -},{"../src/traces/sankey":1039}],30:[function(_dereq_,module,exports){ +},{"../src/traces/sankey":1036}],30:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -636,7 +636,7 @@ module.exports = _dereq_('../src/traces/sankey'); module.exports = _dereq_('../src/traces/scatter3d'); -},{"../src/traces/scatter3d":1075}],31:[function(_dereq_,module,exports){ +},{"../src/traces/scatter3d":1072}],31:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -649,7 +649,7 @@ module.exports = _dereq_('../src/traces/scatter3d'); module.exports = _dereq_('../src/traces/scattercarpet'); -},{"../src/traces/scattercarpet":1081}],32:[function(_dereq_,module,exports){ +},{"../src/traces/scattercarpet":1078}],32:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -662,7 +662,7 @@ module.exports = _dereq_('../src/traces/scattercarpet'); module.exports = _dereq_('../src/traces/scattergeo'); -},{"../src/traces/scattergeo":1088}],33:[function(_dereq_,module,exports){ +},{"../src/traces/scattergeo":1085}],33:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -675,7 +675,7 @@ module.exports = _dereq_('../src/traces/scattergeo'); module.exports = _dereq_('../src/traces/scattergl'); -},{"../src/traces/scattergl":1096}],34:[function(_dereq_,module,exports){ +},{"../src/traces/scattergl":1093}],34:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -688,7 +688,7 @@ module.exports = _dereq_('../src/traces/scattergl'); module.exports = _dereq_('../src/traces/scattermapbox'); -},{"../src/traces/scattermapbox":1102}],35:[function(_dereq_,module,exports){ +},{"../src/traces/scattermapbox":1099}],35:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -701,7 +701,7 @@ module.exports = _dereq_('../src/traces/scattermapbox'); module.exports = _dereq_('../src/traces/scatterpolar'); -},{"../src/traces/scatterpolar":1109}],36:[function(_dereq_,module,exports){ +},{"../src/traces/scatterpolar":1106}],36:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -714,7 +714,7 @@ module.exports = _dereq_('../src/traces/scatterpolar'); module.exports = _dereq_('../src/traces/scatterpolargl'); -},{"../src/traces/scatterpolargl":1113}],37:[function(_dereq_,module,exports){ +},{"../src/traces/scatterpolargl":1110}],37:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -727,7 +727,7 @@ module.exports = _dereq_('../src/traces/scatterpolargl'); module.exports = _dereq_('../src/traces/scatterternary'); -},{"../src/traces/scatterternary":1119}],38:[function(_dereq_,module,exports){ +},{"../src/traces/scatterternary":1116}],38:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -740,7 +740,7 @@ module.exports = _dereq_('../src/traces/scatterternary'); module.exports = _dereq_('../src/transforms/sort'); -},{"../src/transforms/sort":1159}],39:[function(_dereq_,module,exports){ +},{"../src/transforms/sort":1156}],39:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -753,7 +753,7 @@ module.exports = _dereq_('../src/transforms/sort'); module.exports = _dereq_('../src/traces/splom'); -},{"../src/traces/splom":1124}],40:[function(_dereq_,module,exports){ +},{"../src/traces/splom":1121}],40:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -766,7 +766,7 @@ module.exports = _dereq_('../src/traces/splom'); module.exports = _dereq_('../src/traces/streamtube'); -},{"../src/traces/streamtube":1129}],41:[function(_dereq_,module,exports){ +},{"../src/traces/streamtube":1126}],41:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -779,7 +779,7 @@ module.exports = _dereq_('../src/traces/streamtube'); module.exports = _dereq_('../src/traces/surface'); -},{"../src/traces/surface":1134}],42:[function(_dereq_,module,exports){ +},{"../src/traces/surface":1131}],42:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -792,7 +792,7 @@ module.exports = _dereq_('../src/traces/surface'); module.exports = _dereq_('../src/traces/table'); -},{"../src/traces/table":1142}],43:[function(_dereq_,module,exports){ +},{"../src/traces/table":1139}],43:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -805,7 +805,7 @@ module.exports = _dereq_('../src/traces/table'); module.exports = _dereq_('../src/traces/violin'); -},{"../src/traces/violin":1150}],44:[function(_dereq_,module,exports){ +},{"../src/traces/violin":1147}],44:[function(_dereq_,module,exports){ 'use strict' module.exports = createCamera @@ -1166,7 +1166,7 @@ function createViewController(options) { matrix: matrix }, mode) } -},{"matrix-camera-controller":416,"orbit-camera-controller":439,"turntable-camera-controller":519}],46:[function(_dereq_,module,exports){ +},{"matrix-camera-controller":416,"orbit-camera-controller":439,"turntable-camera-controller":518}],46:[function(_dereq_,module,exports){ // https://github.com/d3/d3-sankey Version 0.5.1. Copyright 2018 Mike Bostock. (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, _dereq_('d3-array'), _dereq_('d3-collection'), _dereq_('d3-interpolate')) : @@ -1520,7 +1520,7 @@ function createABigTriangle(gl) { module.exports = createABigTriangle -},{"gl-buffer":230,"gl-vao":310,"weak-map":529}],48:[function(_dereq_,module,exports){ +},{"gl-buffer":230,"gl-vao":310,"weak-map":528}],48:[function(_dereq_,module,exports){ module.exports = absolutize @@ -7415,7 +7415,7 @@ function boxIntersectWrapper(arg0, arg1, arg2) { throw new Error('box-intersect: Invalid arguments') } } -},{"./lib/intersect":86,"./lib/sweep":90,"typedarray-pool":522}],85:[function(_dereq_,module,exports){ +},{"./lib/intersect":86,"./lib/sweep":90,"typedarray-pool":521}],85:[function(_dereq_,module,exports){ 'use strict' var DIMENSION = 'd' @@ -8055,7 +8055,7 @@ function boxIntersectIter( } } } -},{"./brute":85,"./median":87,"./partition":88,"./sweep":90,"bit-twiddle":80,"typedarray-pool":522}],87:[function(_dereq_,module,exports){ +},{"./brute":85,"./median":87,"./partition":88,"./sweep":90,"bit-twiddle":80,"typedarray-pool":521}],87:[function(_dereq_,module,exports){ 'use strict' module.exports = findMedian @@ -8891,7 +8891,7 @@ red_loop: } } } -},{"./sort":89,"bit-twiddle":80,"typedarray-pool":522}],91:[function(_dereq_,module,exports){ +},{"./sort":89,"bit-twiddle":80,"typedarray-pool":521}],91:[function(_dereq_,module,exports){ },{}],92:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. @@ -9467,7 +9467,7 @@ function typedArraySupport () { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } return arr.foo() === 42 } catch (e) { return false @@ -12424,7 +12424,7 @@ function cleanPSLG (points, edges, colors) { return modified } -},{"./lib/rat-seg-intersect":105,"big-rat":66,"big-rat/cmp":64,"big-rat/to-float":78,"box-intersect":84,"nextafter":434,"rat-vec":469,"robust-segment-intersect":489,"union-find":523}],105:[function(_dereq_,module,exports){ +},{"./lib/rat-seg-intersect":105,"big-rat":66,"big-rat/cmp":64,"big-rat/to-float":78,"box-intersect":84,"nextafter":434,"rat-vec":469,"robust-segment-intersect":489,"union-find":522}],105:[function(_dereq_,module,exports){ 'use strict' module.exports = solveIntersection @@ -13406,7 +13406,7 @@ function compareAngle(a, b, c, d) { } } } -},{"robust-orientation":486,"robust-product":487,"robust-sum":491,"signum":492,"two-sum":521}],116:[function(_dereq_,module,exports){ +},{"robust-orientation":486,"robust-product":487,"robust-sum":491,"signum":492,"two-sum":520}],116:[function(_dereq_,module,exports){ module.exports = compareCells var min = Math.min @@ -14047,7 +14047,7 @@ function parseLineHeight(value) { return value } -},{"./lib/util":128,"css-font-stretch-keywords":124,"css-font-style-keywords":125,"css-font-weight-keywords":126,"css-global-keywords":131,"css-system-font-keywords":132,"string-split-by":505,"unquote":525}],130:[function(_dereq_,module,exports){ +},{"./lib/util":128,"css-font-stretch-keywords":124,"css-font-style-keywords":125,"css-font-weight-keywords":126,"css-global-keywords":131,"css-system-font-keywords":132,"string-split-by":505,"unquote":524}],130:[function(_dereq_,module,exports){ 'use strict' var pick = _dereq_('pick-by-alias') @@ -14679,7 +14679,7 @@ function generateCWiseOp(proc, typesig) { } module.exports = generateCWiseOp -},{"uniq":524}],136:[function(_dereq_,module,exports){ +},{"uniq":523}],136:[function(_dereq_,module,exports){ "use strict" // The function below is called when constructing a cwise function object, and does the following: @@ -27873,7 +27873,7 @@ function triangulate(points, includePointAtInfinity) { return hull } -},{"incremental-convex-hull":396,"uniq":524}],151:[function(_dereq_,module,exports){ +},{"incremental-convex-hull":396,"uniq":523}],151:[function(_dereq_,module,exports){ 'use strict' @@ -28835,7 +28835,7 @@ function edgeToAdjacency(edges, numVertices) { } return adj } -},{"uniq":524}],158:[function(_dereq_,module,exports){ +},{"uniq":523}],158:[function(_dereq_,module,exports){ // Inspired by Google Closure: // http://closure-library.googlecode.com/svn/docs/ // closure_goog_array_array.js.html#goog.array.clear @@ -32954,1632 +32954,1646 @@ function getCanvasContext (type, opts) { } },{}],222:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createAxes - -var createText = _dereq_('./lib/text.js') -var createLines = _dereq_('./lib/lines.js') -var createBackground = _dereq_('./lib/background.js') -var getCubeProperties = _dereq_('./lib/cube.js') -var Ticks = _dereq_('./lib/ticks.js') - -var identity = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1]) - -function copyVec3(a, b) { - a[0] = b[0] - a[1] = b[1] - a[2] = b[2] - return a -} - -function Axes(gl) { - this.gl = gl - - this.pixelRatio = 1 - - this.bounds = [ [-10, -10, -10], - [ 10, 10, 10] ] - this.ticks = [ [], [], [] ] - this.autoTicks = true - this.tickSpacing = [ 1, 1, 1 ] - - this.tickEnable = [ true, true, true ] - this.tickFont = [ 'sans-serif', 'sans-serif', 'sans-serif' ] - this.tickSize = [ 12, 12, 12 ] - this.tickAngle = [ 0, 0, 0 ] - this._tickAlign = [ 'auto', 'auto', 'auto' ] - this.tickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - this.tickPad = [ 10, 10, 10 ] - - this.lastCubeProps = { - cubeEdges: [0,0,0], - axis: [0,0,0] - } - - this.labels = [ 'x', 'y', 'z' ] - this.labelEnable = [ true, true, true ] - this.labelFont = 'sans-serif' - this.labelSize = [ 20, 20, 20 ] - this._labelAngle = [ 0, 0, 0 ] - this._labelAlign = [ 'auto', 'auto', 'auto' ] - this.labelColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - this.labelPad = [ 10, 10, 10 ] - - this.lineEnable = [ true, true, true ] - this.lineMirror = [ false, false, false ] - this.lineWidth = [ 1, 1, 1 ] - this.lineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - - this.lineTickEnable = [ true, true, true ] - this.lineTickMirror = [ false, false, false ] - this.lineTickLength = [ 0, 0, 0 ] - this.lineTickWidth = [ 1, 1, 1 ] - this.lineTickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - - this.gridEnable = [ true, true, true ] - this.gridWidth = [ 1, 1, 1 ] - this.gridColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - - this.zeroEnable = [ true, true, true ] - this.zeroLineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - this.zeroLineWidth = [ 2, 2, 2 ] - - this.backgroundEnable = [ false, false, false ] - this.backgroundColor = [ [0.8, 0.8, 0.8, 0.5], - [0.8, 0.8, 0.8, 0.5], - [0.8, 0.8, 0.8, 0.5] ] - - this._firstInit = true - this._text = null - this._lines = null - this._background = createBackground(gl) -} - -var proto = Axes.prototype - -proto.update = function(options) { - options = options || {} - - //Option parsing helper functions - function parseOption(nest, cons, name) { - if(name in options) { - var opt = options[name] - var prev = this[name] - var next - if(nest ? (Array.isArray(opt) && Array.isArray(opt[0])) : - Array.isArray(opt) ) { - this[name] = next = [ cons(opt[0]), cons(opt[1]), cons(opt[2]) ] - } else { - this[name] = next = [ cons(opt), cons(opt), cons(opt) ] - } - for(var i=0; i<3; ++i) { - if(next[i] !== prev[i]) { - return true - } - } - } - return false - } - - var NUMBER = parseOption.bind(this, false, Number) - var BOOLEAN = parseOption.bind(this, false, Boolean) - var STRING = parseOption.bind(this, false, String) - var COLOR = parseOption.bind(this, true, function(v) { - if(Array.isArray(v)) { - if(v.length === 3) { - return [ +v[0], +v[1], +v[2], 1.0 ] - } else if(v.length === 4) { - return [ +v[0], +v[1], +v[2], +v[3] ] - } - } - return [ 0, 0, 0, 1 ] - }) - - //Tick marks and bounds - var nextTicks - var ticksUpdate = false - var boundsChanged = false - if('bounds' in options) { - var bounds = options.bounds -i_loop: - for(var i=0; i<2; ++i) { - for(var j=0; j<3; ++j) { - if(bounds[i][j] !== this.bounds[i][j]) { - boundsChanged = true - } - this.bounds[i][j] = bounds[i][j] - } - } - } - if('ticks' in options) { - nextTicks = options.ticks - ticksUpdate = true - this.autoTicks = false - for(var i=0; i<3; ++i) { - this.tickSpacing[i] = 0.0 - } - } else if(NUMBER('tickSpacing')) { - this.autoTicks = true - boundsChanged = true - } - - if(this._firstInit) { - if(!('ticks' in options || 'tickSpacing' in options)) { - this.autoTicks = true - } - - //Force tick recomputation on first update - boundsChanged = true - ticksUpdate = true - this._firstInit = false - } - - if(boundsChanged && this.autoTicks) { - nextTicks = Ticks.create(this.bounds, this.tickSpacing) - ticksUpdate = true - } - - //Compare next ticks to previous ticks, only update if needed - if(ticksUpdate) { - for(var i=0; i<3; ++i) { - nextTicks[i].sort(function(a,b) { - return a.x-b.x - }) - } - if(Ticks.equal(nextTicks, this.ticks)) { - ticksUpdate = false - } else { - this.ticks = nextTicks - } - } - - //Parse tick properties - BOOLEAN('tickEnable') - if(STRING('tickFont')) { - ticksUpdate = true //If font changes, must rebuild vbo - } - NUMBER('tickSize') - NUMBER('tickAngle') - NUMBER('tickPad') - COLOR('tickColor') - - //Axis labels - var labelUpdate = STRING('labels') - if(STRING('labelFont')) { - labelUpdate = true - } - BOOLEAN('labelEnable') - NUMBER('labelSize') - NUMBER('labelPad') - COLOR('labelColor') - - //Axis lines - BOOLEAN('lineEnable') - BOOLEAN('lineMirror') - NUMBER('lineWidth') - COLOR('lineColor') - - //Axis line ticks - BOOLEAN('lineTickEnable') - BOOLEAN('lineTickMirror') - NUMBER('lineTickLength') - NUMBER('lineTickWidth') - COLOR('lineTickColor') - - //Grid lines - BOOLEAN('gridEnable') - NUMBER('gridWidth') - COLOR('gridColor') - - //Zero line - BOOLEAN('zeroEnable') - COLOR('zeroLineColor') - NUMBER('zeroLineWidth') - - //Background - BOOLEAN('backgroundEnable') - COLOR('backgroundColor') - - //Update text if necessary - if(!this._text) { - this._text = createText( - this.gl, - this.bounds, - this.labels, - this.labelFont, - this.ticks, - this.tickFont) - } else if(this._text && (labelUpdate || ticksUpdate)) { - this._text.update( - this.bounds, - this.labels, - this.labelFont, - this.ticks, - this.tickFont) - } - - //Update lines if necessary - if(this._lines && ticksUpdate) { - this._lines.dispose() - this._lines = null - } - if(!this._lines) { - this._lines = createLines(this.gl, this.bounds, this.ticks) - } -} - -function OffsetInfo() { - this.primalOffset = [0,0,0] - this.primalMinor = [0,0,0] - this.mirrorOffset = [0,0,0] - this.mirrorMinor = [0,0,0] -} - -var LINE_OFFSET = [ new OffsetInfo(), new OffsetInfo(), new OffsetInfo() ] - -function computeLineOffset(result, i, bounds, cubeEdges, cubeAxis) { - var primalOffset = result.primalOffset - var primalMinor = result.primalMinor - var dualOffset = result.mirrorOffset - var dualMinor = result.mirrorMinor - var e = cubeEdges[i] - - //Calculate offsets - for(var j=0; j<3; ++j) { - if(i === j) { - continue - } - var a = primalOffset, - b = dualOffset, - c = primalMinor, - d = dualMinor - if(e & (1< 0) { - c[j] = -1 - d[j] = 0 - } else { - c[j] = 0 - d[j] = +1 - } - } -} - -var CUBE_ENABLE = [0,0,0] -var DEFAULT_PARAMS = { - model: identity, - view: identity, - projection: identity -} - -proto.isOpaque = function() { - return true -} - -proto.isTransparent = function() { - return false -} - -proto.drawTransparent = function(params) {} - -var ALIGN_OPTION_AUTO = 0 // i.e. as defined in the shader the text would rotate to stay upwards range: [-90,90] - -var PRIMAL_MINOR = [0,0,0] -var MIRROR_MINOR = [0,0,0] -var PRIMAL_OFFSET = [0,0,0] - -proto.draw = function(params) { - params = params || DEFAULT_PARAMS - - var gl = this.gl - - //Geometry for camera and axes - var model = params.model || identity - var view = params.view || identity - var projection = params.projection || identity - var bounds = this.bounds - - //Unpack axis info - var cubeParams = getCubeProperties(model, view, projection, bounds) - var cubeEdges = cubeParams.cubeEdges - var cubeAxis = cubeParams.axis - - var cx = view[12] - var cy = view[13] - var cz = view[14] - var cw = view[15] - - var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight - - for(var i=0; i<3; ++i) { - this.lastCubeProps.cubeEdges[i] = cubeEdges[i] - this.lastCubeProps.axis[i] = cubeAxis[i] - } - - //Compute axis info - var lineOffset = LINE_OFFSET - for(var i=0; i<3; ++i) { - computeLineOffset( - LINE_OFFSET[i], - i, - this.bounds, - cubeEdges, - cubeAxis) - } - - //Set up state parameters - var gl = this.gl - - //Draw background first - var cubeEnable = CUBE_ENABLE - for(var i=0; i<3; ++i) { - if(this.backgroundEnable[i]) { - cubeEnable[i] = cubeAxis[i] - } else { - cubeEnable[i] = 0 - } - } - - this._background.draw( - model, - view, - projection, - bounds, - cubeEnable, - this.backgroundColor) - - //Draw lines - this._lines.bind( - model, - view, - projection, - this) - - //First draw grid lines and zero lines - for(var i=0; i<3; ++i) { - var x = [0,0,0] - if(cubeAxis[i] > 0) { - x[i] = bounds[1][i] - } else { - x[i] = bounds[0][i] - } - - //Draw grid lines - for(var j=0; j<2; ++j) { - var u = (i + 1 + j) % 3 - var v = (i + 1 + (j^1)) % 3 - if(this.gridEnable[u]) { - this._lines.drawGrid(u, v, this.bounds, x, this.gridColor[u], this.gridWidth[u]*this.pixelRatio) - } - } - - //Draw zero lines (need to do this AFTER all grid lines are drawn) - for(var j=0; j<2; ++j) { - var u = (i + 1 + j) % 3 - var v = (i + 1 + (j^1)) % 3 - if(this.zeroEnable[v]) { - //Check if zero line in bounds - if(Math.min(bounds[0][v], bounds[1][v]) <= 0 && Math.max(bounds[0][v], bounds[1][v]) >= 0) { - this._lines.drawZero(u, v, this.bounds, x, this.zeroLineColor[v], this.zeroLineWidth[v]*this.pixelRatio) - } - } - } - } - - //Then draw axis lines and tick marks - for(var i=0; i<3; ++i) { - - //Draw axis lines - if(this.lineEnable[i]) { - this._lines.drawAxisLine(i, this.bounds, lineOffset[i].primalOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) - } - if(this.lineMirror[i]) { - this._lines.drawAxisLine(i, this.bounds, lineOffset[i].mirrorOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) - } - - //Compute minor axes - var primalMinor = copyVec3(PRIMAL_MINOR, lineOffset[i].primalMinor) - var mirrorMinor = copyVec3(MIRROR_MINOR, lineOffset[i].mirrorMinor) - var tickLength = this.lineTickLength - var op = 0 - for(var j=0; j<3; ++j) { - var scaleFactor = pixelScaleF / model[5*j] - primalMinor[j] *= tickLength[j] * scaleFactor - mirrorMinor[j] *= tickLength[j] * scaleFactor - } - - //Draw axis line ticks - if(this.lineTickEnable[i]) { - this._lines.drawAxisTicks(i, lineOffset[i].primalOffset, primalMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) - } - if(this.lineTickMirror[i]) { - this._lines.drawAxisTicks(i, lineOffset[i].mirrorOffset, mirrorMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) - } - } - this._lines.unbind() - - //Draw text sprites - this._text.bind( - model, - view, - projection, - this.pixelRatio) - - var alignOpt // options in shader are from this list {-1, 0, 1, 2, 3, ..., n} - // -1: backward compatible - // 0: raw data - // 1: auto align, free angles - // 2: auto align, horizontal or vertical - //3-n: auto align, round to n directions e.g. 12 -> round to angles with 30-degree steps - - var hv_ratio = 0.5 // can have an effect on the ratio between horizontals and verticals when using option 2 - - var enableAlign - var alignDir - - function alignTo(i) { - alignDir = [0,0,0] - alignDir[i] = 1 - } - - function solveTickAlignments(i, minor, major) { - - var i1 = (i + 1) % 3 - var i2 = (i + 2) % 3 - - var A = minor[i1] - var B = minor[i2] - var C = major[i1] - var D = major[i2] - - if ((A > 0) && (D > 0)) { alignTo(i1); return; } - else if ((A > 0) && (D < 0)) { alignTo(i1); return; } - else if ((A < 0) && (D > 0)) { alignTo(i1); return; } - else if ((A < 0) && (D < 0)) { alignTo(i1); return; } - else if ((B > 0) && (C > 0)) { alignTo(i2); return; } - else if ((B > 0) && (C < 0)) { alignTo(i2); return; } - else if ((B < 0) && (C > 0)) { alignTo(i2); return; } - else if ((B < 0) && (C < 0)) { alignTo(i2); return; } - } - - for(var i=0; i<3; ++i) { - - var minor = lineOffset[i].primalMinor - var major = lineOffset[i].mirrorMinor - - var offset = copyVec3(PRIMAL_OFFSET, lineOffset[i].primalOffset) - - for(var j=0; j<3; ++j) { - if(this.lineTickEnable[i]) { - offset[j] += pixelScaleF * minor[j] * Math.max(this.lineTickLength[j], 0) / model[5*j] - } - } - - var axis = [0,0,0] - axis[i] = 1 - - //Draw tick text - if(this.tickEnable[i]) { - - if(this.tickAngle[i] === -3600) { - this.tickAngle[i] = 0 - this._tickAlign[i] = 'auto' - } else { - this._tickAlign[i] = -1 - } - - enableAlign = 1; - - alignOpt = [this._tickAlign[i], hv_ratio, enableAlign] - if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO - else alignOpt[0] = parseInt('' + alignOpt[0]) - - alignDir = [0,0,0] - solveTickAlignments(i, minor, major) - - //Add tick padding - for(var j=0; j<3; ++j) { - offset[j] += pixelScaleF * minor[j] * this.tickPad[j] / model[5*j] - } - - //Draw axis - this._text.drawTicks( - i, - this.tickSize[i], - this.tickAngle[i], - offset, - this.tickColor[i], - axis, - alignDir, - alignOpt) - } - - //Draw labels - if(this.labelEnable[i]) { - - enableAlign = 0 - alignDir = [0,0,0] - if(this.labels[i].length > 4) { // for large label axis enable alignDir to axis - alignTo(i) - enableAlign = 1 - } - - alignOpt = [this._labelAlign[i], hv_ratio, enableAlign] - if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO - else alignOpt[0] = parseInt('' + alignOpt[0]) - - //Add label padding - for(var j=0; j<3; ++j) { - offset[j] += pixelScaleF * minor[j] * this.labelPad[j] / model[5*j] - } - offset[i] += 0.5 * (bounds[0][i] + bounds[1][i]) - - //Draw axis - this._text.drawLabel( - i, - this.labelSize[i], - this._labelAngle[i], - offset, - this.labelColor[i], - [0,0,0], - alignDir, - alignOpt) - } - } - - this._text.unbind() -} - -proto.dispose = function() { - this._text.dispose() - this._lines.dispose() - this._background.dispose() - this._lines = null - this._text = null - this._background = null - this.gl = null -} - -function createAxes(gl, options) { - var axes = new Axes(gl) - axes.update(options) - return axes -} +'use strict' + +module.exports = createAxes + +var createText = _dereq_('./lib/text.js') +var createLines = _dereq_('./lib/lines.js') +var createBackground = _dereq_('./lib/background.js') +var getCubeProperties = _dereq_('./lib/cube.js') +var Ticks = _dereq_('./lib/ticks.js') + +var identity = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1]) + +function copyVec3(a, b) { + a[0] = b[0] + a[1] = b[1] + a[2] = b[2] + return a +} + +function Axes(gl) { + this.gl = gl + + this.pixelRatio = 1 + + this.bounds = [ [-10, -10, -10], + [ 10, 10, 10] ] + this.ticks = [ [], [], [] ] + this.autoTicks = true + this.tickSpacing = [ 1, 1, 1 ] + + this.tickEnable = [ true, true, true ] + this.tickFont = [ 'sans-serif', 'sans-serif', 'sans-serif' ] + this.tickSize = [ 12, 12, 12 ] + this.tickAngle = [ 0, 0, 0 ] + this._tickAlign = [ 'auto', 'auto', 'auto' ] + this.tickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + this.tickPad = [ 10, 10, 10 ] + + this.lastCubeProps = { + cubeEdges: [0,0,0], + axis: [0,0,0] + } + + this.labels = [ 'x', 'y', 'z' ] + this.labelEnable = [ true, true, true ] + this.labelFont = 'sans-serif' + this.labelSize = [ 20, 20, 20 ] + this.labelAngle = [ 0, 0, 0 ] + this.labelAlign = [ 'auto', 'auto', 'auto' ] + this.labelColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + this.labelPad = [ 10, 10, 10 ] + + this.lineEnable = [ true, true, true ] + this.lineMirror = [ false, false, false ] + this.lineWidth = [ 1, 1, 1 ] + this.lineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + + this.lineTickEnable = [ true, true, true ] + this.lineTickMirror = [ false, false, false ] + this.lineTickLength = [ 0, 0, 0 ] + this.lineTickWidth = [ 1, 1, 1 ] + this.lineTickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + + this.gridEnable = [ true, true, true ] + this.gridWidth = [ 1, 1, 1 ] + this.gridColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + + this.zeroEnable = [ true, true, true ] + this.zeroLineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + this.zeroLineWidth = [ 2, 2, 2 ] + + this.backgroundEnable = [ false, false, false ] + this.backgroundColor = [ [0.8, 0.8, 0.8, 0.5], + [0.8, 0.8, 0.8, 0.5], + [0.8, 0.8, 0.8, 0.5] ] + + this._firstInit = true + this._text = null + this._lines = null + this._background = createBackground(gl) +} + +var proto = Axes.prototype + +proto.update = function(options) { + options = options || {} + + //Option parsing helper functions + function parseOption(nest, cons, name) { + if(name in options) { + var opt = options[name] + var prev = this[name] + var next + if(nest ? (Array.isArray(opt) && Array.isArray(opt[0])) : + Array.isArray(opt) ) { + this[name] = next = [ cons(opt[0]), cons(opt[1]), cons(opt[2]) ] + } else { + this[name] = next = [ cons(opt), cons(opt), cons(opt) ] + } + for(var i=0; i<3; ++i) { + if(next[i] !== prev[i]) { + return true + } + } + } + return false + } + + var NUMBER = parseOption.bind(this, false, Number) + var BOOLEAN = parseOption.bind(this, false, Boolean) + var STRING = parseOption.bind(this, false, String) + var COLOR = parseOption.bind(this, true, function(v) { + if(Array.isArray(v)) { + if(v.length === 3) { + return [ +v[0], +v[1], +v[2], 1.0 ] + } else if(v.length === 4) { + return [ +v[0], +v[1], +v[2], +v[3] ] + } + } + return [ 0, 0, 0, 1 ] + }) + + //Tick marks and bounds + var nextTicks + var ticksUpdate = false + var boundsChanged = false + if('bounds' in options) { + var bounds = options.bounds +i_loop: + for(var i=0; i<2; ++i) { + for(var j=0; j<3; ++j) { + if(bounds[i][j] !== this.bounds[i][j]) { + boundsChanged = true + } + this.bounds[i][j] = bounds[i][j] + } + } + } + if('ticks' in options) { + nextTicks = options.ticks + ticksUpdate = true + this.autoTicks = false + for(var i=0; i<3; ++i) { + this.tickSpacing[i] = 0.0 + } + } else if(NUMBER('tickSpacing')) { + this.autoTicks = true + boundsChanged = true + } + + if(this._firstInit) { + if(!('ticks' in options || 'tickSpacing' in options)) { + this.autoTicks = true + } + + //Force tick recomputation on first update + boundsChanged = true + ticksUpdate = true + this._firstInit = false + } + + if(boundsChanged && this.autoTicks) { + nextTicks = Ticks.create(this.bounds, this.tickSpacing) + ticksUpdate = true + } + + //Compare next ticks to previous ticks, only update if needed + if(ticksUpdate) { + for(var i=0; i<3; ++i) { + nextTicks[i].sort(function(a,b) { + return a.x-b.x + }) + } + if(Ticks.equal(nextTicks, this.ticks)) { + ticksUpdate = false + } else { + this.ticks = nextTicks + } + } + + //Parse tick properties + BOOLEAN('tickEnable') + if(STRING('tickFont')) { + ticksUpdate = true //If font changes, must rebuild vbo + } + NUMBER('tickSize') + NUMBER('tickAngle') + NUMBER('tickPad') + COLOR('tickColor') + + //Axis labels + var labelUpdate = STRING('labels') + if(STRING('labelFont')) { + labelUpdate = true + } + BOOLEAN('labelEnable') + NUMBER('labelSize') + NUMBER('labelPad') + COLOR('labelColor') + + //Axis lines + BOOLEAN('lineEnable') + BOOLEAN('lineMirror') + NUMBER('lineWidth') + COLOR('lineColor') + + //Axis line ticks + BOOLEAN('lineTickEnable') + BOOLEAN('lineTickMirror') + NUMBER('lineTickLength') + NUMBER('lineTickWidth') + COLOR('lineTickColor') + + //Grid lines + BOOLEAN('gridEnable') + NUMBER('gridWidth') + COLOR('gridColor') + + //Zero line + BOOLEAN('zeroEnable') + COLOR('zeroLineColor') + NUMBER('zeroLineWidth') + + //Background + BOOLEAN('backgroundEnable') + COLOR('backgroundColor') + + //Update text if necessary + if(!this._text) { + this._text = createText( + this.gl, + this.bounds, + this.labels, + this.labelFont, + this.ticks, + this.tickFont) + } else if(this._text && (labelUpdate || ticksUpdate)) { + this._text.update( + this.bounds, + this.labels, + this.labelFont, + this.ticks, + this.tickFont) + } + + //Update lines if necessary + if(this._lines && ticksUpdate) { + this._lines.dispose() + this._lines = null + } + if(!this._lines) { + this._lines = createLines(this.gl, this.bounds, this.ticks) + } +} + +function OffsetInfo() { + this.primalOffset = [0,0,0] + this.primalMinor = [0,0,0] + this.mirrorOffset = [0,0,0] + this.mirrorMinor = [0,0,0] +} + +var LINE_OFFSET = [ new OffsetInfo(), new OffsetInfo(), new OffsetInfo() ] + +function computeLineOffset(result, i, bounds, cubeEdges, cubeAxis) { + var primalOffset = result.primalOffset + var primalMinor = result.primalMinor + var dualOffset = result.mirrorOffset + var dualMinor = result.mirrorMinor + var e = cubeEdges[i] + + //Calculate offsets + for(var j=0; j<3; ++j) { + if(i === j) { + continue + } + var a = primalOffset, + b = dualOffset, + c = primalMinor, + d = dualMinor + if(e & (1< 0) { + c[j] = -1 + d[j] = 0 + } else { + c[j] = 0 + d[j] = +1 + } + } +} + +var CUBE_ENABLE = [0,0,0] +var DEFAULT_PARAMS = { + model: identity, + view: identity, + projection: identity +} + +proto.isOpaque = function() { + return true +} + +proto.isTransparent = function() { + return false +} + +proto.drawTransparent = function(params) {} + +var ALIGN_OPTION_AUTO = 0 // i.e. as defined in the shader the text would rotate to stay upwards range: [-90,90] + +var PRIMAL_MINOR = [0,0,0] +var MIRROR_MINOR = [0,0,0] +var PRIMAL_OFFSET = [0,0,0] + +proto.draw = function(params) { + params = params || DEFAULT_PARAMS + + var gl = this.gl + + //Geometry for camera and axes + var model = params.model || identity + var view = params.view || identity + var projection = params.projection || identity + var bounds = this.bounds + + //Unpack axis info + var cubeParams = getCubeProperties(model, view, projection, bounds) + var cubeEdges = cubeParams.cubeEdges + var cubeAxis = cubeParams.axis + + var cx = view[12] + var cy = view[13] + var cz = view[14] + var cw = view[15] + + var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight + + for(var i=0; i<3; ++i) { + this.lastCubeProps.cubeEdges[i] = cubeEdges[i] + this.lastCubeProps.axis[i] = cubeAxis[i] + } + + //Compute axis info + var lineOffset = LINE_OFFSET + for(var i=0; i<3; ++i) { + computeLineOffset( + LINE_OFFSET[i], + i, + this.bounds, + cubeEdges, + cubeAxis) + } + + //Set up state parameters + var gl = this.gl + + //Draw background first + var cubeEnable = CUBE_ENABLE + for(var i=0; i<3; ++i) { + if(this.backgroundEnable[i]) { + cubeEnable[i] = cubeAxis[i] + } else { + cubeEnable[i] = 0 + } + } + + this._background.draw( + model, + view, + projection, + bounds, + cubeEnable, + this.backgroundColor) + + //Draw lines + this._lines.bind( + model, + view, + projection, + this) + + //First draw grid lines and zero lines + for(var i=0; i<3; ++i) { + var x = [0,0,0] + if(cubeAxis[i] > 0) { + x[i] = bounds[1][i] + } else { + x[i] = bounds[0][i] + } + + //Draw grid lines + for(var j=0; j<2; ++j) { + var u = (i + 1 + j) % 3 + var v = (i + 1 + (j^1)) % 3 + if(this.gridEnable[u]) { + this._lines.drawGrid(u, v, this.bounds, x, this.gridColor[u], this.gridWidth[u]*this.pixelRatio) + } + } + + //Draw zero lines (need to do this AFTER all grid lines are drawn) + for(var j=0; j<2; ++j) { + var u = (i + 1 + j) % 3 + var v = (i + 1 + (j^1)) % 3 + if(this.zeroEnable[v]) { + //Check if zero line in bounds + if(Math.min(bounds[0][v], bounds[1][v]) <= 0 && Math.max(bounds[0][v], bounds[1][v]) >= 0) { + this._lines.drawZero(u, v, this.bounds, x, this.zeroLineColor[v], this.zeroLineWidth[v]*this.pixelRatio) + } + } + } + } + + //Then draw axis lines and tick marks + for(var i=0; i<3; ++i) { + + //Draw axis lines + if(this.lineEnable[i]) { + this._lines.drawAxisLine(i, this.bounds, lineOffset[i].primalOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) + } + if(this.lineMirror[i]) { + this._lines.drawAxisLine(i, this.bounds, lineOffset[i].mirrorOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) + } + + //Compute minor axes + var primalMinor = copyVec3(PRIMAL_MINOR, lineOffset[i].primalMinor) + var mirrorMinor = copyVec3(MIRROR_MINOR, lineOffset[i].mirrorMinor) + var tickLength = this.lineTickLength + var op = 0 + for(var j=0; j<3; ++j) { + var scaleFactor = pixelScaleF / model[5*j] + primalMinor[j] *= tickLength[j] * scaleFactor + mirrorMinor[j] *= tickLength[j] * scaleFactor + } + + //Draw axis line ticks + if(this.lineTickEnable[i]) { + this._lines.drawAxisTicks(i, lineOffset[i].primalOffset, primalMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) + } + if(this.lineTickMirror[i]) { + this._lines.drawAxisTicks(i, lineOffset[i].mirrorOffset, mirrorMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) + } + } + this._lines.unbind() + + //Draw text sprites + this._text.bind( + model, + view, + projection, + this.pixelRatio) + + var alignOpt // options in shader are from this list {-1, 0, 1, 2, 3, ..., n} + // -1: backward compatible + // 0: raw data + // 1: auto align, free angles + // 2: auto align, horizontal or vertical + //3-n: auto align, round to n directions e.g. 12 -> round to angles with 30-degree steps + + var hv_ratio = 0.5 // can have an effect on the ratio between horizontals and verticals when using option 2 + + var enableAlign + var alignDir + + function alignTo(i) { + alignDir = [0,0,0] + alignDir[i] = 1 + } + + function solveTickAlignments(i, minor, major) { + + var i1 = (i + 1) % 3 + var i2 = (i + 2) % 3 + + var A = minor[i1] + var B = minor[i2] + var C = major[i1] + var D = major[i2] + + if ((A > 0) && (D > 0)) { alignTo(i1); return; } + else if ((A > 0) && (D < 0)) { alignTo(i1); return; } + else if ((A < 0) && (D > 0)) { alignTo(i1); return; } + else if ((A < 0) && (D < 0)) { alignTo(i1); return; } + else if ((B > 0) && (C > 0)) { alignTo(i2); return; } + else if ((B > 0) && (C < 0)) { alignTo(i2); return; } + else if ((B < 0) && (C > 0)) { alignTo(i2); return; } + else if ((B < 0) && (C < 0)) { alignTo(i2); return; } + } + + for(var i=0; i<3; ++i) { + + var minor = lineOffset[i].primalMinor + var major = lineOffset[i].mirrorMinor + + var offset = copyVec3(PRIMAL_OFFSET, lineOffset[i].primalOffset) + + for(var j=0; j<3; ++j) { + if(this.lineTickEnable[i]) { + offset[j] += pixelScaleF * minor[j] * Math.max(this.lineTickLength[j], 0) / model[5*j] + } + } + + var axis = [0,0,0] + axis[i] = 1 + + //Draw tick text + if(this.tickEnable[i]) { + + if(this.tickAngle[i] === -3600) { + this.tickAngle[i] = 0 + this._tickAlign[i] = 'auto' + } else { + this._tickAlign[i] = -1 + } + + enableAlign = 1; + + alignOpt = [this._tickAlign[i], hv_ratio, enableAlign] + if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO + else alignOpt[0] = parseInt('' + alignOpt[0]) + + alignDir = [0,0,0] + solveTickAlignments(i, minor, major) + + //Add tick padding + for(var j=0; j<3; ++j) { + offset[j] += pixelScaleF * minor[j] * this.tickPad[j] / model[5*j] + } + + //Draw axis + this._text.drawTicks( + i, + this.tickSize[i], + this.tickAngle[i], + offset, + this.tickColor[i], + axis, + alignDir, + alignOpt) + } + + //Draw labels + if(this.labelEnable[i]) { + + enableAlign = 0 + alignDir = [0,0,0] + if(this.labels[i].length > 4) { // for large label axis enable alignDir to axis + alignTo(i) + enableAlign = 1 + } + + alignOpt = [this.labelAlign[i], hv_ratio, enableAlign] + if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO + else alignOpt[0] = parseInt('' + alignOpt[0]) + + //Add label padding + for(var j=0; j<3; ++j) { + offset[j] += pixelScaleF * minor[j] * this.labelPad[j] / model[5*j] + } + offset[i] += 0.5 * (bounds[0][i] + bounds[1][i]) + + //Draw axis + this._text.drawLabel( + i, + this.labelSize[i], + this.labelAngle[i], + offset, + this.labelColor[i], + [0,0,0], + alignDir, + alignOpt) + } + } + + this._text.unbind() +} + +proto.dispose = function() { + this._text.dispose() + this._lines.dispose() + this._background.dispose() + this._lines = null + this._text = null + this._background = null + this.gl = null +} + +function createAxes(gl, options) { + var axes = new Axes(gl) + axes.update(options) + return axes +} },{"./lib/background.js":223,"./lib/cube.js":224,"./lib/lines.js":225,"./lib/text.js":227,"./lib/ticks.js":228}],223:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createBackgroundCube - -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createShader = _dereq_('./shaders').bg - -function BackgroundCube(gl, buffer, vao, shader) { - this.gl = gl - this.buffer = buffer - this.vao = vao - this.shader = shader -} - -var proto = BackgroundCube.prototype - -proto.draw = function(model, view, projection, bounds, enable, colors) { - var needsBG = false - for(var i=0; i<3; ++i) { - needsBG = needsBG || enable[i] - } - if(!needsBG) { - return - } - - var gl = this.gl - - gl.enable(gl.POLYGON_OFFSET_FILL) - gl.polygonOffset(1, 2) - - this.shader.bind() - this.shader.uniforms = { - model: model, - view: view, - projection: projection, - bounds: bounds, - enable: enable, - colors: colors - } - this.vao.bind() - this.vao.draw(this.gl.TRIANGLES, 36) - this.vao.unbind() - - gl.disable(gl.POLYGON_OFFSET_FILL) -} - -proto.dispose = function() { - this.vao.dispose() - this.buffer.dispose() - this.shader.dispose() -} - -function createBackgroundCube(gl) { - //Create cube vertices - var vertices = [] - var indices = [] - var ptr = 0 - for(var d=0; d<3; ++d) { - var u = (d+1) % 3 - var v = (d+2) % 3 - var x = [0,0,0] - var c = [0,0,0] - for(var s=-1; s<=1; s+=2) { - indices.push(ptr, ptr+2, ptr+1, - ptr+1, ptr+2, ptr+3) - x[d] = s - c[d] = s - for(var i=-1; i<=1; i+=2) { - x[u] = i - for(var j=-1; j<=1; j+=2) { - x[v] = j - vertices.push(x[0], x[1], x[2], - c[0], c[1], c[2]) - ptr += 1 - } - } - //Swap u and v - var tt = u - u = v - v = tt - } - } - - //Allocate buffer and vertex array - var buffer = createBuffer(gl, new Float32Array(vertices)) - var elements = createBuffer(gl, new Uint16Array(indices), gl.ELEMENT_ARRAY_BUFFER) - var vao = createVAO(gl, [ - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 0, - stride: 24 - }, - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 12, - stride: 24 - } - ], elements) - - //Create shader object - var shader = createShader(gl) - shader.attributes.position.location = 0 - shader.attributes.normal.location = 1 - - return new BackgroundCube(gl, buffer, vao, shader) -} +'use strict' + +module.exports = createBackgroundCube + +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createShader = _dereq_('./shaders').bg + +function BackgroundCube(gl, buffer, vao, shader) { + this.gl = gl + this.buffer = buffer + this.vao = vao + this.shader = shader +} + +var proto = BackgroundCube.prototype + +proto.draw = function(model, view, projection, bounds, enable, colors) { + var needsBG = false + for(var i=0; i<3; ++i) { + needsBG = needsBG || enable[i] + } + if(!needsBG) { + return + } + + var gl = this.gl + + gl.enable(gl.POLYGON_OFFSET_FILL) + gl.polygonOffset(1, 2) + + this.shader.bind() + this.shader.uniforms = { + model: model, + view: view, + projection: projection, + bounds: bounds, + enable: enable, + colors: colors + } + this.vao.bind() + this.vao.draw(this.gl.TRIANGLES, 36) + this.vao.unbind() + + gl.disable(gl.POLYGON_OFFSET_FILL) +} + +proto.dispose = function() { + this.vao.dispose() + this.buffer.dispose() + this.shader.dispose() +} + +function createBackgroundCube(gl) { + //Create cube vertices + var vertices = [] + var indices = [] + var ptr = 0 + for(var d=0; d<3; ++d) { + var u = (d+1) % 3 + var v = (d+2) % 3 + var x = [0,0,0] + var c = [0,0,0] + for(var s=-1; s<=1; s+=2) { + indices.push(ptr, ptr+2, ptr+1, + ptr+1, ptr+2, ptr+3) + x[d] = s + c[d] = s + for(var i=-1; i<=1; i+=2) { + x[u] = i + for(var j=-1; j<=1; j+=2) { + x[v] = j + vertices.push(x[0], x[1], x[2], + c[0], c[1], c[2]) + ptr += 1 + } + } + //Swap u and v + var tt = u + u = v + v = tt + } + } + + //Allocate buffer and vertex array + var buffer = createBuffer(gl, new Float32Array(vertices)) + var elements = createBuffer(gl, new Uint16Array(indices), gl.ELEMENT_ARRAY_BUFFER) + var vao = createVAO(gl, [ + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 0, + stride: 24 + }, + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 12, + stride: 24 + } + ], elements) + + //Create shader object + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.normal.location = 1 + + return new BackgroundCube(gl, buffer, vao, shader) +} },{"./shaders":226,"gl-buffer":230,"gl-vao":310}],224:[function(_dereq_,module,exports){ -"use strict" - -module.exports = getCubeEdges - -var bits = _dereq_('bit-twiddle') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var splitPoly = _dereq_('split-polygon') -var orient = _dereq_('robust-orientation') - -var mvp = new Array(16) -var imvp = new Array(16) -var pCubeVerts = new Array(8) -var cubeVerts = new Array(8) -var x = new Array(3) -var zero3 = [0,0,0] - -;(function() { - for(var i=0; i<8; ++i) { - pCubeVerts[i] =[1,1,1,1] - cubeVerts[i] = [1,1,1] - } -})() - - -function transformHg(result, x, mat) { - for(var i=0; i<4; ++i) { - result[i] = mat[12+i] - for(var j=0; j<3; ++j) { - result[i] += x[j]*mat[4*j+i] - } - } -} - -var FRUSTUM_PLANES = [ - [ 0, 0, 1, 0, 0], - [ 0, 0,-1, 1, 0], - [ 0,-1, 0, 1, 0], - [ 0, 1, 0, 1, 0], - [-1, 0, 0, 1, 0], - [ 1, 0, 0, 1, 0] -] - -function polygonArea(p) { - for(var i=0; i o0) { - closest |= 1< o0) { - closest |= 1< cubeVerts[i][1]) { - bottom = i - } - } - - //Find left/right neighbors of bottom vertex - var left = -1 - for(var i=0; i<3; ++i) { - var idx = bottom ^ (1< cubeVerts[right][0]) { - right = idx - } - } - - //Determine edge axis coordinates - var cubeEdges = CUBE_EDGES - cubeEdges[0] = cubeEdges[1] = cubeEdges[2] = 0 - cubeEdges[bits.log2(left^bottom)] = bottom&left - cubeEdges[bits.log2(bottom^right)] = bottom&right - var top = right ^ 7 - if(top === closest || top === farthest) { - top = left ^ 7 - cubeEdges[bits.log2(right^top)] = top&right - } else { - cubeEdges[bits.log2(left^top)] = top&left - } - - //Determine visible faces - var axis = CUBE_AXIS - var cutCorner = closest - for(var d=0; d<3; ++d) { - if(cutCorner & (1< o0) { + closest |= 1< o0) { + closest |= 1< cubeVerts[i][1]) { + bottom = i + } + } + + //Find left/right neighbors of bottom vertex + var left = -1 + for(var i=0; i<3; ++i) { + var idx = bottom ^ (1< cubeVerts[right][0]) { + right = idx + } + } + + //Determine edge axis coordinates + var cubeEdges = CUBE_EDGES + cubeEdges[0] = cubeEdges[1] = cubeEdges[2] = 0 + cubeEdges[bits.log2(left^bottom)] = bottom&left + cubeEdges[bits.log2(bottom^right)] = bottom&right + var top = right ^ 7 + if(top === closest || top === farthest) { + top = left ^ 7 + cubeEdges[bits.log2(right^top)] = top&right + } else { + cubeEdges[bits.log2(left^top)] = top&left + } + + //Determine visible faces + var axis = CUBE_AXIS + var cutCorner = closest + for(var d=0; d<3; ++d) { + if(cutCorner & (1< HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]) -var textFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]) -exports.text = function(gl) { - return createShader(gl, textVert, textFrag, null, [ - {name: 'position', type: 'vec3'} - ]) -} - -var bgVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]) -var bgFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]) -exports.bg = function(gl) { - return createShader(gl, bgVert, bgFrag, null, [ - {name: 'position', type: 'vec3'}, - {name: 'normal', type: 'vec3'} - ]) -} +'use strict' + +var glslify = _dereq_('glslify') +var createShader = _dereq_('gl-shader') + +var lineVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\nuniform vec3 offset, majorAxis, minorAxis, screenAxis;\nuniform float lineWidth;\nuniform vec2 screenShape;\n\nvec3 project(vec3 p) {\n vec4 pp = projection * view * model * vec4(p, 1.0);\n return pp.xyz / max(pp.w, 0.0001);\n}\n\nvoid main() {\n vec3 major = position.x * majorAxis;\n vec3 minor = position.y * minorAxis;\n\n vec3 vPosition = major + minor + offset;\n vec3 pPosition = project(vPosition);\n vec3 offset = project(vPosition + screenAxis * position.z);\n\n vec2 screen = normalize((offset - pPosition).xy * screenShape) / screenShape;\n\n gl_Position = vec4(pPosition + vec3(0.5 * screen * lineWidth, 0), 1.0);\n}\n"]) +var lineFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]) +exports.line = function(gl) { + return createShader(gl, lineVert, lineFrag, null, [ + {name: 'position', type: 'vec3'} + ]) +} + +var textVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\nuniform vec3 offset, axis, alignDir, alignOpt;\nuniform float scale, angle, pixelScale;\nuniform vec2 resolution;\n\nvec3 project(vec3 p) {\n vec4 pp = projection * view * model * vec4(p, 1.0);\n return pp.xyz / max(pp.w, 0.0001);\n}\n\nfloat computeViewAngle(vec3 a, vec3 b) {\n vec3 A = project(a);\n vec3 B = project(b);\n\n return atan(\n (B.y - A.y) * resolution.y,\n (B.x - A.x) * resolution.x\n );\n}\n\nconst float PI = 3.141592;\nconst float TWO_PI = 2.0 * PI;\nconst float HALF_PI = 0.5 * PI;\nconst float ONE_AND_HALF_PI = 1.5 * PI;\n\nint option = int(floor(alignOpt.x + 0.001));\nfloat hv_ratio = alignOpt.y;\nbool enableAlign = (alignOpt.z != 0.0);\n\nfloat mod_angle(float a) {\n return mod(a, PI);\n}\n\nfloat positive_angle(float a) {\n return mod_angle((a < 0.0) ?\n a + TWO_PI :\n a\n );\n}\n\nfloat look_upwards(float a) {\n float b = positive_angle(a);\n return ((b > HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]) +var textFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]) +exports.text = function(gl) { + return createShader(gl, textVert, textFrag, null, [ + {name: 'position', type: 'vec3'} + ]) +} + +var bgVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]) +var bgFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]) +exports.bg = function(gl) { + return createShader(gl, bgVert, bgFrag, null, [ + {name: 'position', type: 'vec3'}, + {name: 'normal', type: 'vec3'} + ]) +} },{"gl-shader":288,"glslify":392}],227:[function(_dereq_,module,exports){ (function (process){ -"use strict" - -module.exports = createTextSprites - -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var vectorizeText = _dereq_('vectorize-text') -var createShader = _dereq_('./shaders').text - -var globals = window || process.global || {} -var __TEXT_CACHE = globals.__TEXT_CACHE || {} -globals.__TEXT_CACHE = {} - -//Vertex buffer format for text is: -// -/// [x,y,z] = Spatial coordinate -// - -var VERTEX_SIZE = 3 -var VERTEX_STRIDE = VERTEX_SIZE * 4 - -function TextSprites( - gl, - shader, - buffer, - vao) { - this.gl = gl - this.shader = shader - this.buffer = buffer - this.vao = vao - this.tickOffset = - this.tickCount = - this.labelOffset = - this.labelCount = null -} - -var proto = TextSprites.prototype - -//Bind textures for rendering -var SHAPE = [0,0] -proto.bind = function(model, view, projection, pixelScale) { - this.vao.bind() - this.shader.bind() - var uniforms = this.shader.uniforms - uniforms.model = model - uniforms.view = view - uniforms.projection = projection - uniforms.pixelScale = pixelScale - SHAPE[0] = this.gl.drawingBufferWidth - SHAPE[1] = this.gl.drawingBufferHeight - this.shader.uniforms.resolution = SHAPE -} - -proto.unbind = function() { - this.vao.unbind() -} - -proto.update = function(bounds, labels, labelFont, ticks, tickFont) { - var gl = this.gl - var data = [] - - function addItem(t, text, font, size) { - var fontcache = __TEXT_CACHE[font] - if(!fontcache) { - fontcache = __TEXT_CACHE[font] = {} - } - var mesh = fontcache[text] - if(!mesh) { - mesh = fontcache[text] = tryVectorizeText(text, { - triangles: true, - font: font, - textAlign: 'center', - textBaseline: 'middle' - }) - } - var scale = (size || 12) / 12 - var positions = mesh.positions - var cells = mesh.cells - var lo = [ Infinity, Infinity] - var hi = [-Infinity,-Infinity] - for(var i=0, nc=cells.length; i=0; --j) { - var p = positions[c[j]] - data.push(scale*p[0], -scale*p[1], t) - } - } - } - - //Generate sprites for all 3 axes, store data in texture atlases - var tickOffset = [0,0,0] - var tickCount = [0,0,0] - var labelOffset = [0,0,0] - var labelCount = [0,0,0] - for(var d=0; d<3; ++d) { - - //Generate label - labelOffset[d] = (data.length/VERTEX_SIZE)|0 - addItem(0.5*(bounds[0][d]+bounds[1][d]), labels[d], labelFont) - labelCount[d] = ((data.length/VERTEX_SIZE)|0) - labelOffset[d] - - //Generate sprites for tick marks - tickOffset[d] = (data.length/VERTEX_SIZE)|0 - for(var i=0; i=0; --j) { + var p = positions[c[j]] + data.push(scale*p[0], -scale*p[1], t) + } + } + } + + //Generate sprites for all 3 axes, store data in texture atlases + var tickOffset = [0,0,0] + var tickCount = [0,0,0] + var labelOffset = [0,0,0] + var labelCount = [0,0,0] + var lineSpacing = 1.25 + var styletags = { + breaklines:true, + bolds: true, + italics: true, + subscripts:true, + superscripts:true + } + for(var d=0; d<3; ++d) { + + //Generate label + labelOffset[d] = (data.length/VERTEX_SIZE)|0 + addItem( + 0.5*(bounds[0][d]+bounds[1][d]), + labels[d], + labelFont[d], + 12, // labelFontSize + lineSpacing, + styletags + ) + labelCount[d] = ((data.length/VERTEX_SIZE)|0) - labelOffset[d] + + //Generate sprites for tick marks + tickOffset[d] = (data.length/VERTEX_SIZE)|0 + for(var i=0; i= 0) { - sigFigs = stepStr.length - u - 1 - } - var shift = Math.pow(10, sigFigs) - var x = Math.round(spacing * i * shift) - var xstr = x + "" - if(xstr.indexOf("e") >= 0) { - return xstr - } - var xi = x / shift, xf = x % shift - if(x < 0) { - xi = -Math.ceil(xi)|0 - xf = (-xf)|0 - } else { - xi = Math.floor(xi)|0 - xf = xf|0 - } - var xis = "" + xi - if(x < 0) { - xis = "-" + xis - } - if(sigFigs) { - var xs = "" + xf - while(xs.length < sigFigs) { - xs = "0" + xs - } - return xis + "." + xs - } else { - return xis - } -} - -function defaultTicks(bounds, tickSpacing) { - var array = [] - for(var d=0; d<3; ++d) { - var ticks = [] - var m = 0.5*(bounds[0][d]+bounds[1][d]) - for(var t=0; t*tickSpacing[d]<=bounds[1][d]; ++t) { - ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) - } - for(var t=-1; t*tickSpacing[d]>=bounds[0][d]; --t) { - ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) - } - array.push(ticks) - } - return array -} - -function ticksEqual(ticksA, ticksB) { - for(var i=0; i<3; ++i) { - if(ticksA[i].length !== ticksB[i].length) { - return false - } - for(var j=0; j= 0) { + sigFigs = stepStr.length - u - 1 + } + var shift = Math.pow(10, sigFigs) + var x = Math.round(spacing * i * shift) + var xstr = x + "" + if(xstr.indexOf("e") >= 0) { + return xstr + } + var xi = x / shift, xf = x % shift + if(x < 0) { + xi = -Math.ceil(xi)|0 + xf = (-xf)|0 + } else { + xi = Math.floor(xi)|0 + xf = xf|0 + } + var xis = "" + xi + if(x < 0) { + xis = "-" + xis + } + if(sigFigs) { + var xs = "" + xf + while(xs.length < sigFigs) { + xs = "0" + xs + } + return xis + "." + xs + } else { + return xis + } +} + +function defaultTicks(bounds, tickSpacing) { + var array = [] + for(var d=0; d<3; ++d) { + var ticks = [] + var m = 0.5*(bounds[0][d]+bounds[1][d]) + for(var t=0; t*tickSpacing[d]<=bounds[1][d]; ++t) { + ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) + } + for(var t=-1; t*tickSpacing[d]>=bounds[0][d]; --t) { + ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) + } + array.push(ticks) + } + return array +} + +function ticksEqual(ticksA, ticksB) { + for(var i=0; i<3; ++i) { + if(ticksA[i].length !== ticksB[i].length) { + return false + } + for(var j=0; j= v) { - return i-1; - } - } - return i; -}; - -var tmp = V.create(); -var tmp2 = V.create(); - -var clamp = function(v, min, max) { - return v < min ? min : (v > max ? max : v); -}; - -var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { - var x = point[0]; - var y = point[1]; - var z = point[2]; - - var w = meshgrid[0].length; - var h = meshgrid[1].length; - var d = meshgrid[2].length; - - // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). - // The nearest smaller value index for x is the index x0 such that - // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. - var x0 = findLastSmallerIndex(meshgrid[0], x); - var y0 = findLastSmallerIndex(meshgrid[1], y); - var z0 = findLastSmallerIndex(meshgrid[2], z); - - // Get the nearest larger meshgrid value indices. - // From the above "nearest smaller value", we know that - // meshgrid[0][x0] < x - // meshgrid[0][x0+1] >= x - var x1 = x0 + 1; - var y1 = y0 + 1; - var z1 = z0 + 1; - - if (clampOverflow) { - x0 = clamp(x0, 0, w-1); - x1 = clamp(x1, 0, w-1); - y0 = clamp(y0, 0, h-1); - y1 = clamp(y1, 0, h-1); - z0 = clamp(z0, 0, d-1); - z1 = clamp(z1, 0, d-1); - } - - // Reject points outside the meshgrid, return a zero vector. - if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { - return V.create(); - } - - // Normalize point coordinates to 0..1 scaling factor between x0 and x1. - var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); - var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); - var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); - - if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; - if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; - if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; - - var z0off = z0*w*h; - var z1off = z1*w*h; - - var y0off = y0*w; - var y1off = y1*w; - - var x0off = x0; - var x1off = x1; - - // Sample data array around the (x,y,z) point. - // vZYX = array[zZoff + yYoff + xXoff] - var v000 = array[y0off + z0off + x0off]; - var v001 = array[y0off + z0off + x1off]; - var v010 = array[y1off + z0off + x0off]; - var v011 = array[y1off + z0off + x1off]; - var v100 = array[y0off + z1off + x0off]; - var v101 = array[y0off + z1off + x1off]; - var v110 = array[y1off + z1off + x0off]; - var v111 = array[y1off + z1off + x1off]; - - var result = V.create(); - - // Average samples according to distance to point. - V.lerp(result, v000, v001, xf); - V.lerp(tmp, v010, v011, xf); - V.lerp(result, result, tmp, yf); - V.lerp(tmp, v100, v101, xf); - V.lerp(tmp2, v110, v111, xf); - V.lerp(tmp, tmp, tmp2, yf); - V.lerp(result, result, tmp, zf); - - return result; -}; - -var getOrthogonalVector = function(dst, v) { - // Return up-vector for only-z vector. - if (v[0] === 0 && v[1] === 0) { - V.set(dst, 0, 1, 0); - } else { - // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0). - // From the above if-statement we have ||a|| > 0 U ||b|| > 0. - // Assign z = 0, x = -b, y = a: - // a*-b + b*a + c*0 = -ba + ba + 0 = 0 - V.set(dst, -v[1], v[0], 0); - } - return dst; -}; - -module.exports = function(vectorfield, bounds) { - var positions; - if (vectorfield.positions) { - positions = vectorfield.positions; - } else { - positions = createPositionsForMeshgrid(vectorfield.meshgrid); - } - var meshgrid = vectorfield.meshgrid; - var vectors = vectorfield.vectors; - var geo = { - positions: [], - vertexIntensity: [], - vertexIntensityBounds: vectorfield.vertexIntensityBounds, - vertexNormals: [], - vectors: [], - cells: [], - coneOffset: vectorfield.coneOffset, - colormap: vectorfield.colormap - }; - - if (vectorfield.positions.length === 0) { - if (bounds) { - bounds[0] = [0,0,0]; - bounds[1] = [0,0,0]; - } - return geo; - } - - // Compute bounding box for the dataset. - // Compute maximum velocity for the dataset to use for scaling the cones. - var maxNorm = 0; - var minX = 1/0, maxX = -1/0; - var minY = 1/0, maxY = -1/0; - var minZ = 1/0, maxZ = -1/0; - var p2 = null; - var u2 = null; - var positionVectors = []; - var vectorScale = 1/0; - for (var i = 0; i < positions.length; i++) { - var p = positions[i]; - minX = Math.min(p[0], minX); - maxX = Math.max(p[0], maxX); - minY = Math.min(p[1], minY); - maxY = Math.max(p[1], maxY); - minZ = Math.min(p[2], minZ); - maxZ = Math.max(p[2], maxZ); - var u; - if (meshgrid) { - u = sampleMeshgrid(p, vectors, meshgrid, true); - } else { - u = vectors[i]; - } - if (V.length(u) > maxNorm) { - maxNorm = V.length(u); - } - if (i) { - // Find vector scale [w/ units of time] using "successive" positions - // (not "adjacent" with would be O(n^2)), - // - // The vector scale corresponds to the minimum "time" to travel across two - // two adjacent positions at the average velocity of those two adjacent positions - vectorScale = Math.min(vectorScale, - 2 * V.distance(p2, p) / (V.length(u2) + V.length(u)) - ); - } - p2 = p; - u2 = u; - positionVectors.push(u); - } - var minV = [minX, minY, minZ]; - var maxV = [maxX, maxY, maxZ]; - if (bounds) { - bounds[0] = minV; - bounds[1] = maxV; - } - if (maxNorm === 0) { - maxNorm = 1; - } - - // Inverted max norm would map vector with norm maxNorm to 1 coord space units in length - var invertedMaxNorm = 1 / maxNorm; - - if (!isFinite(vectorScale) || isNaN(vectorScale)) { - vectorScale = 1.0; - } - geo.vectorScale = vectorScale; - - var nml = vec3(0,1,0); - - var coneScale = vectorfield.coneSize || 0.5; - - if (vectorfield.absoluteConeSize) { - coneScale = vectorfield.absoluteConeSize * invertedMaxNorm; - } - - geo.coneScale = coneScale; - - // Build the cone model. - for (var i = 0, j = 0; i < positions.length; i++) { - var p = positions[i]; - var x = p[0], y = p[1], z = p[2]; - var d = positionVectors[i]; - var intensity = V.length(d) * invertedMaxNorm; - for (var k = 0, l = 8; k < l; k++) { - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - - geo.vertexIntensity.push(intensity, intensity, intensity); - geo.vertexIntensity.push(intensity, intensity, intensity); - - geo.vertexNormals.push(nml, nml, nml); - geo.vertexNormals.push(nml, nml, nml); - - var m = geo.positions.length; - geo.cells.push([m-6, m-5, m-4], [m-3, m-2, m-1]); - } - } - - return geo; -}; - -module.exports.createConeMesh = _dereq_('./lib/conemesh'); +},{"ndarray":433,"ndarray-ops":427,"typedarray-pool":521}],231:[function(_dereq_,module,exports){ +"use strict"; + +var V = _dereq_('gl-vec3'); +var V4 = _dereq_('gl-vec4'); + +var vec3 = function(x, y, z) { + var v = V.create(); + if (x !== undefined) { + V.set(v, x, y, z); + } + return v; +} + +var createPositionsForMeshgrid = function(meshgrid) { + var xs = meshgrid[0], ys = meshgrid[1], zs = meshgrid[2]; + var positions = []; + for (var z=0; z= v) { + return i-1; + } + } + return i; +}; + +var tmp = V.create(); +var tmp2 = V.create(); + +var clamp = function(v, min, max) { + return v < min ? min : (v > max ? max : v); +}; + +var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { + var x = point[0]; + var y = point[1]; + var z = point[2]; + + var w = meshgrid[0].length; + var h = meshgrid[1].length; + var d = meshgrid[2].length; + + // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). + // The nearest smaller value index for x is the index x0 such that + // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. + var x0 = findLastSmallerIndex(meshgrid[0], x); + var y0 = findLastSmallerIndex(meshgrid[1], y); + var z0 = findLastSmallerIndex(meshgrid[2], z); + + // Get the nearest larger meshgrid value indices. + // From the above "nearest smaller value", we know that + // meshgrid[0][x0] < x + // meshgrid[0][x0+1] >= x + var x1 = x0 + 1; + var y1 = y0 + 1; + var z1 = z0 + 1; + + if (clampOverflow) { + x0 = clamp(x0, 0, w-1); + x1 = clamp(x1, 0, w-1); + y0 = clamp(y0, 0, h-1); + y1 = clamp(y1, 0, h-1); + z0 = clamp(z0, 0, d-1); + z1 = clamp(z1, 0, d-1); + } + + // Reject points outside the meshgrid, return a zero vector. + if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { + return V.create(); + } + + // Normalize point coordinates to 0..1 scaling factor between x0 and x1. + var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); + var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); + var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); + + if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; + if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; + if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; + + var z0off = z0*w*h; + var z1off = z1*w*h; + + var y0off = y0*w; + var y1off = y1*w; + + var x0off = x0; + var x1off = x1; + + // Sample data array around the (x,y,z) point. + // vZYX = array[zZoff + yYoff + xXoff] + var v000 = array[y0off + z0off + x0off]; + var v001 = array[y0off + z0off + x1off]; + var v010 = array[y1off + z0off + x0off]; + var v011 = array[y1off + z0off + x1off]; + var v100 = array[y0off + z1off + x0off]; + var v101 = array[y0off + z1off + x1off]; + var v110 = array[y1off + z1off + x0off]; + var v111 = array[y1off + z1off + x1off]; + + var result = V.create(); + + // Average samples according to distance to point. + V.lerp(result, v000, v001, xf); + V.lerp(tmp, v010, v011, xf); + V.lerp(result, result, tmp, yf); + V.lerp(tmp, v100, v101, xf); + V.lerp(tmp2, v110, v111, xf); + V.lerp(tmp, tmp, tmp2, yf); + V.lerp(result, result, tmp, zf); + + return result; +}; + +var getOrthogonalVector = function(dst, v) { + // Return up-vector for only-z vector. + if (v[0] === 0 && v[1] === 0) { + V.set(dst, 0, 1, 0); + } else { + // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0). + // From the above if-statement we have ||a|| > 0 U ||b|| > 0. + // Assign z = 0, x = -b, y = a: + // a*-b + b*a + c*0 = -ba + ba + 0 = 0 + V.set(dst, -v[1], v[0], 0); + } + return dst; +}; + +module.exports = function(vectorfield, bounds) { + var positions; + if (vectorfield.positions) { + positions = vectorfield.positions; + } else { + positions = createPositionsForMeshgrid(vectorfield.meshgrid); + } + var meshgrid = vectorfield.meshgrid; + var vectors = vectorfield.vectors; + var geo = { + positions: [], + vertexIntensity: [], + vertexIntensityBounds: vectorfield.vertexIntensityBounds, + vertexNormals: [], + vectors: [], + cells: [], + coneOffset: vectorfield.coneOffset, + colormap: vectorfield.colormap + }; + + if (vectorfield.positions.length === 0) { + if (bounds) { + bounds[0] = [0,0,0]; + bounds[1] = [0,0,0]; + } + return geo; + } + + // Compute bounding box for the dataset. + // Compute maximum velocity for the dataset to use for scaling the cones. + var maxNorm = 0; + var minX = 1/0, maxX = -1/0; + var minY = 1/0, maxY = -1/0; + var minZ = 1/0, maxZ = -1/0; + var p2 = null; + var u2 = null; + var positionVectors = []; + var vectorScale = 1/0; + for (var i = 0; i < positions.length; i++) { + var p = positions[i]; + minX = Math.min(p[0], minX); + maxX = Math.max(p[0], maxX); + minY = Math.min(p[1], minY); + maxY = Math.max(p[1], maxY); + minZ = Math.min(p[2], minZ); + maxZ = Math.max(p[2], maxZ); + var u; + if (meshgrid) { + u = sampleMeshgrid(p, vectors, meshgrid, true); + } else { + u = vectors[i]; + } + if (V.length(u) > maxNorm) { + maxNorm = V.length(u); + } + if (i) { + // Find vector scale [w/ units of time] using "successive" positions + // (not "adjacent" with would be O(n^2)), + // + // The vector scale corresponds to the minimum "time" to travel across two + // two adjacent positions at the average velocity of those two adjacent positions + vectorScale = Math.min(vectorScale, + 2 * V.distance(p2, p) / (V.length(u2) + V.length(u)) + ); + } + p2 = p; + u2 = u; + positionVectors.push(u); + } + var minV = [minX, minY, minZ]; + var maxV = [maxX, maxY, maxZ]; + if (bounds) { + bounds[0] = minV; + bounds[1] = maxV; + } + if (maxNorm === 0) { + maxNorm = 1; + } + + // Inverted max norm would map vector with norm maxNorm to 1 coord space units in length + var invertedMaxNorm = 1 / maxNorm; + + if (!isFinite(vectorScale) || isNaN(vectorScale)) { + vectorScale = 1.0; + } + geo.vectorScale = vectorScale; + + var nml = vec3(0,1,0); + + var coneScale = vectorfield.coneSize || 0.5; + + if (vectorfield.absoluteConeSize) { + coneScale = vectorfield.absoluteConeSize * invertedMaxNorm; + } + + geo.coneScale = coneScale; + + // Build the cone model. + for (var i = 0, j = 0; i < positions.length; i++) { + var p = positions[i]; + var x = p[0], y = p[1], z = p[2]; + var d = positionVectors[i]; + var intensity = V.length(d) * invertedMaxNorm; + for (var k = 0, l = 8; k < l; k++) { + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + + geo.vertexIntensity.push(intensity, intensity, intensity); + geo.vertexIntensity.push(intensity, intensity, intensity); + + geo.vertexNormals.push(nml, nml, nml); + geo.vertexNormals.push(nml, nml, nml); + + var m = geo.positions.length; + geo.cells.push([m-6, m-5, m-4], [m-3, m-2, m-1]); + } + } + + return geo; +}; + +module.exports.createConeMesh = _dereq_('./lib/conemesh'); },{"./lib/conemesh":233,"gl-vec3":329,"gl-vec4":365}],232:[function(_dereq_,module,exports){ -'use strict' - -var barycentric = _dereq_('barycentric') -var closestPointToTriangle = _dereq_('polytope-closest-point/lib/closest_point_2d.js') - -module.exports = closestPointToPickLocation - -function xformMatrix(m, v) { - var out = [0,0,0,0] - for(var i=0; i<4; ++i) { - for(var j=0; j<4; ++j) { - out[j] += m[4*i + j] * v[i] - } - } - return out -} - -function projectVertex(v, model, view, projection, resolution) { - var p = xformMatrix(projection, - xformMatrix(view, - xformMatrix(model, [v[0], v[1], v[2], 1]))) - for(var i=0; i<3; ++i) { - p[i] /= p[3] - } - return [ 0.5 * resolution[0] * (1.0+p[0]), 0.5 * resolution[1] * (1.0-p[1]) ] -} - -function barycentricCoord(simplex, point) { - if(simplex.length === 2) { - var d0 = 0.0 - var d1 = 0.0 - for(var i=0; i<2; ++i) { - d0 += Math.pow(point[i] - simplex[0][i], 2) - d1 += Math.pow(point[i] - simplex[1][i], 2) - } - d0 = Math.sqrt(d0) - d1 = Math.sqrt(d1) - if(d0+d1 < 1e-6) { - return [1,0] - } - return [d1/(d0+d1),d0/(d1+d0)] - } else if(simplex.length === 3) { - var closestPoint = [0,0] - closestPointToTriangle(simplex[0], simplex[1], simplex[2], point, closestPoint) - return barycentric(simplex, closestPoint) - } - return [] -} - -function interpolate(simplex, weights) { - var result = [0,0,0] - for(var i=0; i 1.0001) { - return null - } - s += weights[i] - } - if(Math.abs(s - 1.0) > 0.001) { - return null - } - return [closestIndex, interpolate(simplex, weights), weights] +'use strict' + +var barycentric = _dereq_('barycentric') +var closestPointToTriangle = _dereq_('polytope-closest-point/lib/closest_point_2d.js') + +module.exports = closestPointToPickLocation + +function xformMatrix(m, v) { + var out = [0,0,0,0] + for(var i=0; i<4; ++i) { + for(var j=0; j<4; ++j) { + out[j] += m[4*i + j] * v[i] + } + } + return out +} + +function projectVertex(v, model, view, projection, resolution) { + var p = xformMatrix(projection, + xformMatrix(view, + xformMatrix(model, [v[0], v[1], v[2], 1]))) + for(var i=0; i<3; ++i) { + p[i] /= p[3] + } + return [ 0.5 * resolution[0] * (1.0+p[0]), 0.5 * resolution[1] * (1.0-p[1]) ] +} + +function barycentricCoord(simplex, point) { + if(simplex.length === 2) { + var d0 = 0.0 + var d1 = 0.0 + for(var i=0; i<2; ++i) { + d0 += Math.pow(point[i] - simplex[0][i], 2) + d1 += Math.pow(point[i] - simplex[1][i], 2) + } + d0 = Math.sqrt(d0) + d1 = Math.sqrt(d1) + if(d0+d1 < 1e-6) { + return [1,0] + } + return [d1/(d0+d1),d0/(d1+d0)] + } else if(simplex.length === 3) { + var closestPoint = [0,0] + closestPointToTriangle(simplex[0], simplex[1], simplex[2], point, closestPoint) + return barycentric(simplex, closestPoint) + } + return [] +} + +function interpolate(simplex, weights) { + var result = [0,0,0] + for(var i=0; i 1.0001) { + return null + } + s += weights[i] + } + if(Math.abs(s - 1.0) > 0.001) { + return null + } + return [closestIndex, interpolate(simplex, weights), weights] } },{"barycentric":61,"polytope-closest-point/lib/closest_point_2d.js":464}],233:[function(_dereq_,module,exports){ -'use strict' - -var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small -var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var normals = _dereq_('normals') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var ndarray = _dereq_('ndarray') -var colormap = _dereq_('colormap') -var getContour = _dereq_('simplicial-complex-contour') -var pool = _dereq_('typedarray-pool') -var shaders = _dereq_('./shaders') -var closestPoint = _dereq_('./closest-point') - -var meshShader = shaders.meshShader -var pickShader = shaders.pickShader - -var identityMatrix = [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - -function SimplicialMesh(gl - , texture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) { - - this.gl = gl - this.cells = [] - this.positions = [] - this.intensity = [] - this.texture = texture - this.dirty = true - - this.triShader = triShader - this.lineShader = lineShader - this.pointShader = pointShader - this.pickShader = pickShader - this.pointPickShader = pointPickShader - this.contourShader = contourShader - - this.trianglePositions = trianglePositions - this.triangleVectors = triangleVectors - this.triangleColors = triangleColors - this.triangleNormals = triangleNormals - this.triangleUVs = triangleUVs - this.triangleIds = triangleIds - this.triangleVAO = triangleVAO - this.triangleCount = 0 - - this.lineWidth = 1 - this.edgePositions = edgePositions - this.edgeColors = edgeColors - this.edgeUVs = edgeUVs - this.edgeIds = edgeIds - this.edgeVAO = edgeVAO - this.edgeCount = 0 - - this.pointPositions = pointPositions - this.pointColors = pointColors - this.pointUVs = pointUVs - this.pointSizes = pointSizes - this.pointIds = pointIds - this.pointVAO = pointVAO - this.pointCount = 0 - - this.contourLineWidth = 1 - this.contourPositions = contourPositions - this.contourVAO = contourVAO - this.contourCount = 0 - this.contourColor = [0,0,0] - this.contourEnable = true - - this.pickId = 1 - this.bounds = [ - [ Infinity, Infinity, Infinity], - [-Infinity,-Infinity,-Infinity] ] - this.clipBounds = [ - [-Infinity,-Infinity,-Infinity], - [ Infinity, Infinity, Infinity] ] - - this.lightPosition = [1e5, 1e5, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - - this.opacity = 1.0 - - this.coneScale = 2.0 - this.vectorScale = 1.0 - this.coneOffset = 1.0 / 4.0; - - this._model = identityMatrix - this._view = identityMatrix - this._projection = identityMatrix - this._resolution = [1,1] -} - -var proto = SimplicialMesh.prototype - -proto.isOpaque = function() { - return this.opacity >= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.pickSlots = 1 - -proto.setPickBase = function(id) { - this.pickId = id -} - -function genColormap(param) { - var colors = colormap({ - colormap: param - , nshades: 256 - , format: 'rgba' - }) - - var result = new Uint8Array(256*4) - for(var i=0; i<256; ++i) { - var c = colors[i] - for(var j=0; j<3; ++j) { - result[4*i+j] = c[j] - } - result[4*i+3] = c[3]*255 - } - - return ndarray(result, [256,256,4], [4,0,1]) -} - -function unpackIntensity(cells, numVerts, cellIntensity) { - var result = new Array(numVerts) - for(var i=0; i 0) { - var shader = this.triShader - shader.bind() - shader.uniforms = uniforms - - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0 && this.lineWidth > 0) { - var shader = this.lineShader - shader.bind() - shader.uniforms = uniforms - - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } - - if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { - var shader = this.contourShader - shader.bind() - shader.uniforms = uniforms - - this.contourVAO.bind() - gl.drawArrays(gl.LINES, 0, this.contourCount) - this.contourVAO.unbind() - } -} - -proto.drawPick = function(params) { - params = params || {} - - var gl = this.gl - - var model = params.model || identityMatrix - var view = params.view || identityMatrix - var projection = params.projection || identityMatrix - - var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] - for(var i=0; i<3; ++i) { - clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) - clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) - } - - //Save camera parameters - this._model = [].slice.call(model) - this._view = [].slice.call(view) - this._projection = [].slice.call(projection) - this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - - var uniforms = { - model: model, - view: view, - projection: projection, - clipBounds: clipBounds, - - vectorScale: this.vectorScale, - coneScale: this.coneScale, - coneOffset: this.coneOffset, - - pickId: this.pickId / 255.0, - } - - var shader = this.pickShader - shader.bind() - shader.uniforms = uniforms - - if(this.triangleCount > 0) { - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0) { - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointPickShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } -} - - -proto.pick = function(pickData) { - if(!pickData) { - return null - } - if(pickData.id !== this.pickId) { - return null - } - - var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] - var cell = this.cells[cellId] - var pos = this.positions[cell[1]].slice(0, 3) - - return { - // corresponding to input indices - index: Math.floor(cell[1] / 48), - position: pos, - dataCoordinate: pos - } -} - - -proto.dispose = function() { - this.texture.dispose() - - this.triShader.dispose() - // this.lineShader.dispose() - // this.pointShader.dispose() - this.pickShader.dispose() - // this.pointPickShader.dispose() - - this.triangleVAO.dispose() - this.trianglePositions.dispose() - this.triangleVectors.dispose() - this.triangleColors.dispose() - this.triangleUVs.dispose() - this.triangleNormals.dispose() - this.triangleIds.dispose() - - this.edgeVAO.dispose() - this.edgePositions.dispose() - this.edgeColors.dispose() - this.edgeUVs.dispose() - this.edgeIds.dispose() - - this.pointVAO.dispose() - this.pointPositions.dispose() - this.pointColors.dispose() - this.pointUVs.dispose() - this.pointSizes.dispose() - this.pointIds.dispose() - - this.contourVAO.dispose() - this.contourPositions.dispose() - // this.contourShader.dispose() -} - -function createMeshShader(gl) { - // need to pass meshShader attributes manually, - // to make this work on etpinard's Ubuntu Thinkpad - var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.vector.location = 5 - return shader -} - -function createWireShader(gl) { - var shader = createShader(gl, wireShader.vertex, wireShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - return shader -} - -function createPointShader(gl) { - var shader = createShader(gl, pointShader.vertex, pointShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.pointSize.location = 4 - return shader -} - -function createPickShader(gl) { - var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.vector.location = 5 - return shader -} - -function createPointPickShader(gl) { - var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.pointSize.location = 4 - return shader -} - -function createContourShader(gl) { - var shader = createShader(gl, contourShader.vertex, contourShader.fragment) - shader.attributes.position.location = 0 - return shader -} - -function createSimplicialMesh(gl, params) { - if (arguments.length === 1) { - params = gl; - gl = params.gl; - } - - var triShader = params.triShader || createMeshShader(gl) - var lineShader = null; //createWireShader(gl) - var pointShader = null; //createPointShader(gl) - var pickShader = createPickShader(gl) - var pointPickShader = null; //createPointPickShader(gl) - var contourShader = null; //createContourShader(gl) - - var meshTexture = createTexture(gl, - ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) - meshTexture.generateMipmap() - meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR - meshTexture.magFilter = gl.LINEAR - - var trianglePositions = createBuffer(gl) - var triangleVectors = createBuffer(gl) - var triangleColors = createBuffer(gl) - var triangleUVs = createBuffer(gl) - var triangleNormals = createBuffer(gl) - var triangleIds = createBuffer(gl) - var triangleVAO = createVAO(gl, [ - { buffer: trianglePositions, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: triangleColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: triangleNormals, - type: gl.FLOAT, - size: 3 - }, - { buffer: triangleVectors, - type: gl.FLOAT, - size: 3 - } - ]) - - var edgePositions = createBuffer(gl) - var edgeColors = createBuffer(gl) - var edgeUVs = createBuffer(gl) - var edgeIds = createBuffer(gl) - var edgeVAO = createVAO(gl, [ - { buffer: edgePositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: edgeIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: edgeColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: edgeUVs, - type: gl.FLOAT, - size: 2 - } - ]) - - var pointPositions = createBuffer(gl) - var pointColors = createBuffer(gl) - var pointUVs = createBuffer(gl) - var pointSizes = createBuffer(gl) - var pointIds = createBuffer(gl) - var pointVAO = createVAO(gl, [ - { buffer: pointPositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: pointIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: pointColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: pointUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: pointSizes, - type: gl.FLOAT, - size: 1 - } - ]) - - var contourPositions = createBuffer(gl) - var contourVAO = createVAO(gl, [ - { buffer: contourPositions, - type: gl.FLOAT, - size: 3 - }]) - - var mesh = new SimplicialMesh(gl - , meshTexture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) - - mesh.update(params) - - return mesh -} - -module.exports = createSimplicialMesh - -},{"./closest-point":232,"./shaders":234,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"normals":436,"simplicial-complex-contour":494,"typedarray-pool":522}],234:[function(_dereq_,module,exports){ -var glslify = _dereq_('glslify') - -var triVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]) -var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) -var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) - -exports.meshShader = { - vertex: triVertSrc, - fragment: triFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'normal', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'}, - {name: 'vector', type: 'vec3'} - ] -} -exports.pickShader = { - vertex: pickVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'id', type: 'vec4'}, - {name: 'vector', type: 'vec3'} - ] -} +'use strict' + +var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small +var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; + +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var normals = _dereq_('normals') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var ndarray = _dereq_('ndarray') +var colormap = _dereq_('colormap') +var getContour = _dereq_('simplicial-complex-contour') +var pool = _dereq_('typedarray-pool') +var shaders = _dereq_('./shaders') +var closestPoint = _dereq_('./closest-point') + +var meshShader = shaders.meshShader +var pickShader = shaders.pickShader + +var identityMatrix = [ + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +function SimplicialMesh(gl + , texture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) { + + this.gl = gl + this.cells = [] + this.positions = [] + this.intensity = [] + this.texture = texture + this.dirty = true + + this.triShader = triShader + this.lineShader = lineShader + this.pointShader = pointShader + this.pickShader = pickShader + this.pointPickShader = pointPickShader + this.contourShader = contourShader + + this.trianglePositions = trianglePositions + this.triangleVectors = triangleVectors + this.triangleColors = triangleColors + this.triangleNormals = triangleNormals + this.triangleUVs = triangleUVs + this.triangleIds = triangleIds + this.triangleVAO = triangleVAO + this.triangleCount = 0 + + this.lineWidth = 1 + this.edgePositions = edgePositions + this.edgeColors = edgeColors + this.edgeUVs = edgeUVs + this.edgeIds = edgeIds + this.edgeVAO = edgeVAO + this.edgeCount = 0 + + this.pointPositions = pointPositions + this.pointColors = pointColors + this.pointUVs = pointUVs + this.pointSizes = pointSizes + this.pointIds = pointIds + this.pointVAO = pointVAO + this.pointCount = 0 + + this.contourLineWidth = 1 + this.contourPositions = contourPositions + this.contourVAO = contourVAO + this.contourCount = 0 + this.contourColor = [0,0,0] + this.contourEnable = true + + this.pickId = 1 + this.bounds = [ + [ Infinity, Infinity, Infinity], + [-Infinity,-Infinity,-Infinity] ] + this.clipBounds = [ + [-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity] ] + + this.lightPosition = [1e5, 1e5, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + + this.opacity = 1.0 + + this.coneScale = 2.0 + this.vectorScale = 1.0 + this.coneOffset = 1.0 / 4.0; + + this._model = identityMatrix + this._view = identityMatrix + this._projection = identityMatrix + this._resolution = [1,1] +} + +var proto = SimplicialMesh.prototype + +proto.isOpaque = function() { + return this.opacity >= 1 +} + +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.pickSlots = 1 + +proto.setPickBase = function(id) { + this.pickId = id +} + +function genColormap(param) { + var colors = colormap({ + colormap: param + , nshades: 256 + , format: 'rgba' + }) + + var result = new Uint8Array(256*4) + for(var i=0; i<256; ++i) { + var c = colors[i] + for(var j=0; j<3; ++j) { + result[4*i+j] = c[j] + } + result[4*i+3] = c[3]*255 + } + + return ndarray(result, [256,256,4], [4,0,1]) +} + +function unpackIntensity(cells, numVerts, cellIntensity) { + var result = new Array(numVerts) + for(var i=0; i 0) { + var shader = this.triShader + shader.bind() + shader.uniforms = uniforms + + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0 && this.lineWidth > 0) { + var shader = this.lineShader + shader.bind() + shader.uniforms = uniforms + + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } + + if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { + var shader = this.contourShader + shader.bind() + shader.uniforms = uniforms + + this.contourVAO.bind() + gl.drawArrays(gl.LINES, 0, this.contourCount) + this.contourVAO.unbind() + } +} + +proto.drawPick = function(params) { + params = params || {} + + var gl = this.gl + + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix + + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } + + //Save camera parameters + this._model = [].slice.call(model) + this._view = [].slice.call(view) + this._projection = [].slice.call(projection) + this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] + + var uniforms = { + model: model, + view: view, + projection: projection, + clipBounds: clipBounds, + + vectorScale: this.vectorScale, + coneScale: this.coneScale, + coneOffset: this.coneOffset, + + pickId: this.pickId / 255.0, + } + + var shader = this.pickShader + shader.bind() + shader.uniforms = uniforms + + if(this.triangleCount > 0) { + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0) { + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointPickShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } +} + + +proto.pick = function(pickData) { + if(!pickData) { + return null + } + if(pickData.id !== this.pickId) { + return null + } + + var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] + var cell = this.cells[cellId] + var pos = this.positions[cell[1]].slice(0, 3) + + return { + // corresponding to input indices + index: Math.floor(cell[1] / 48), + position: pos, + dataCoordinate: pos + } +} + + +proto.dispose = function() { + this.texture.dispose() + + this.triShader.dispose() + // this.lineShader.dispose() + // this.pointShader.dispose() + this.pickShader.dispose() + // this.pointPickShader.dispose() + + this.triangleVAO.dispose() + this.trianglePositions.dispose() + this.triangleVectors.dispose() + this.triangleColors.dispose() + this.triangleUVs.dispose() + this.triangleNormals.dispose() + this.triangleIds.dispose() + + this.edgeVAO.dispose() + this.edgePositions.dispose() + this.edgeColors.dispose() + this.edgeUVs.dispose() + this.edgeIds.dispose() + + this.pointVAO.dispose() + this.pointPositions.dispose() + this.pointColors.dispose() + this.pointUVs.dispose() + this.pointSizes.dispose() + this.pointIds.dispose() + + this.contourVAO.dispose() + this.contourPositions.dispose() + // this.contourShader.dispose() +} + +function createMeshShader(gl) { + // need to pass meshShader attributes manually, + // to make this work on etpinard's Ubuntu Thinkpad + var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.vector.location = 5 + return shader +} + +function createWireShader(gl) { + var shader = createShader(gl, wireShader.vertex, wireShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + return shader +} + +function createPointShader(gl) { + var shader = createShader(gl, pointShader.vertex, pointShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.pointSize.location = 4 + return shader +} + +function createPickShader(gl) { + var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.vector.location = 5 + return shader +} + +function createPointPickShader(gl) { + var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.pointSize.location = 4 + return shader +} + +function createContourShader(gl) { + var shader = createShader(gl, contourShader.vertex, contourShader.fragment) + shader.attributes.position.location = 0 + return shader +} + +function createSimplicialMesh(gl, params) { + if (arguments.length === 1) { + params = gl; + gl = params.gl; + } + + var triShader = params.triShader || createMeshShader(gl) + var lineShader = null; //createWireShader(gl) + var pointShader = null; //createPointShader(gl) + var pickShader = createPickShader(gl) + var pointPickShader = null; //createPointPickShader(gl) + var contourShader = null; //createContourShader(gl) + + var meshTexture = createTexture(gl, + ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) + meshTexture.generateMipmap() + meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR + meshTexture.magFilter = gl.LINEAR + + var trianglePositions = createBuffer(gl) + var triangleVectors = createBuffer(gl) + var triangleColors = createBuffer(gl) + var triangleUVs = createBuffer(gl) + var triangleNormals = createBuffer(gl) + var triangleIds = createBuffer(gl) + var triangleVAO = createVAO(gl, [ + { buffer: trianglePositions, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: triangleColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: triangleNormals, + type: gl.FLOAT, + size: 3 + }, + { buffer: triangleVectors, + type: gl.FLOAT, + size: 3 + } + ]) + + var edgePositions = createBuffer(gl) + var edgeColors = createBuffer(gl) + var edgeUVs = createBuffer(gl) + var edgeIds = createBuffer(gl) + var edgeVAO = createVAO(gl, [ + { buffer: edgePositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: edgeIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: edgeColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: edgeUVs, + type: gl.FLOAT, + size: 2 + } + ]) + + var pointPositions = createBuffer(gl) + var pointColors = createBuffer(gl) + var pointUVs = createBuffer(gl) + var pointSizes = createBuffer(gl) + var pointIds = createBuffer(gl) + var pointVAO = createVAO(gl, [ + { buffer: pointPositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: pointIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: pointColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: pointUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: pointSizes, + type: gl.FLOAT, + size: 1 + } + ]) + + var contourPositions = createBuffer(gl) + var contourVAO = createVAO(gl, [ + { buffer: contourPositions, + type: gl.FLOAT, + size: 3 + }]) + + var mesh = new SimplicialMesh(gl + , meshTexture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) + + mesh.update(params) + + return mesh +} + +module.exports = createSimplicialMesh + +},{"./closest-point":232,"./shaders":234,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"normals":436,"simplicial-complex-contour":494,"typedarray-pool":521}],234:[function(_dereq_,module,exports){ +var glslify = _dereq_('glslify') + +var triVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]) +var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) +var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) + +exports.meshShader = { + vertex: triVertSrc, + fragment: triFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'normal', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'}, + {name: 'vector', type: 'vec3'} + ] +} +exports.pickShader = { + vertex: pickVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'id', type: 'vec4'}, + {name: 'vector', type: 'vec3'} + ] +} },{"glslify":392}],235:[function(_dereq_,module,exports){ module.exports = { @@ -36477,259 +36491,259 @@ module.exports = function lookupConstant (number) { } },{"./1.0/numbers":235}],237:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createErrorBars - -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createShader = _dereq_('./shaders/index') - -var IDENTITY = [1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - -function ErrorBars(gl, buffer, vao, shader) { - this.gl = gl - this.shader = shader - this.buffer = buffer - this.vao = vao - this.pixelRatio = 1 - this.bounds = [[ Infinity, Infinity, Infinity], [-Infinity,-Infinity,-Infinity]] - this.clipBounds = [[-Infinity,-Infinity,-Infinity], [ Infinity, Infinity, Infinity]] - this.lineWidth = [1,1,1] - this.capSize = [10,10,10] - this.lineCount = [0,0,0] - this.lineOffset = [0,0,0] - this.opacity = 1 -} - -var proto = ErrorBars.prototype - -proto.isOpaque = function() { - return this.opacity >= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.drawTransparent = proto.draw = function(cameraParams) { - var gl = this.gl - var uniforms = this.shader.uniforms - - this.shader.bind() - var view = uniforms.view = cameraParams.view || IDENTITY - var projection = uniforms.projection = cameraParams.projection || IDENTITY - uniforms.model = cameraParams.model || IDENTITY - uniforms.clipBounds = this.clipBounds - uniforms.opacity = this.opacity - - - var cx = view[12] - var cy = view[13] - var cz = view[14] - var cw = view[15] - var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight - - this.vao.bind() - for(var i=0; i<3; ++i) { - gl.lineWidth(this.lineWidth[i]) - uniforms.capSize = this.capSize[i] * pixelScaleF - if (this.lineCount[i]) { - gl.drawArrays(gl.LINES, this.lineOffset[i], this.lineCount[i]) - } - } - this.vao.unbind() -} - -function updateBounds(bounds, point) { - for(var i=0; i<3; ++i) { - bounds[0][i] = Math.min(bounds[0][i], point[i]) - bounds[1][i] = Math.max(bounds[1][i], point[i]) - } -} - -var FACE_TABLE = (function(){ - var table = new Array(3) - for(var d=0; d<3; ++d) { - var row = [] - for(var j=1; j<=2; ++j) { - for(var s=-1; s<=1; s+=2) { - var u = (j+d) % 3 - var y = [0,0,0] - y[u] = s - row.push(y) - } - } - table[d] = row - } - return table -})() - - -function emitFace(verts, x, c, d) { - var offsets = FACE_TABLE[d] - for(var i=0; i 0) { - var x = p.slice() - x[j] += e[1][j] - verts.push(p[0], p[1], p[2], - c[0], c[1], c[2], c[3], - 0, 0, 0, - x[0], x[1], x[2], - c[0], c[1], c[2], c[3], - 0, 0, 0) - updateBounds(this.bounds, x) - vertexCount += 2 + emitFace(verts, x, c, j) - } - } - this.lineCount[j] = vertexCount - this.lineOffset[j] - } - this.buffer.update(verts) - } -} - -proto.dispose = function() { - this.shader.dispose() - this.buffer.dispose() - this.vao.dispose() -} - -function createErrorBars(options) { - var gl = options.gl - var buffer = createBuffer(gl) - var vao = createVAO(gl, [ - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 0, - stride: 40 - }, - { - buffer: buffer, - type: gl.FLOAT, - size: 4, - offset: 12, - stride: 40 - }, - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 28, - stride: 40 - } - ]) - - var shader = createShader(gl) - shader.attributes.position.location = 0 - shader.attributes.color.location = 1 - shader.attributes.offset.location = 2 - - var result = new ErrorBars(gl, buffer, vao, shader) - result.update(options) - return result -} +'use strict' + +module.exports = createErrorBars + +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createShader = _dereq_('./shaders/index') + +var IDENTITY = [1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +function ErrorBars(gl, buffer, vao, shader) { + this.gl = gl + this.shader = shader + this.buffer = buffer + this.vao = vao + this.pixelRatio = 1 + this.bounds = [[ Infinity, Infinity, Infinity], [-Infinity,-Infinity,-Infinity]] + this.clipBounds = [[-Infinity,-Infinity,-Infinity], [ Infinity, Infinity, Infinity]] + this.lineWidth = [1,1,1] + this.capSize = [10,10,10] + this.lineCount = [0,0,0] + this.lineOffset = [0,0,0] + this.opacity = 1 +} + +var proto = ErrorBars.prototype + +proto.isOpaque = function() { + return this.opacity >= 1 +} + +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.drawTransparent = proto.draw = function(cameraParams) { + var gl = this.gl + var uniforms = this.shader.uniforms + + this.shader.bind() + var view = uniforms.view = cameraParams.view || IDENTITY + var projection = uniforms.projection = cameraParams.projection || IDENTITY + uniforms.model = cameraParams.model || IDENTITY + uniforms.clipBounds = this.clipBounds + uniforms.opacity = this.opacity + + + var cx = view[12] + var cy = view[13] + var cz = view[14] + var cw = view[15] + var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight + + this.vao.bind() + for(var i=0; i<3; ++i) { + gl.lineWidth(this.lineWidth[i]) + uniforms.capSize = this.capSize[i] * pixelScaleF + if (this.lineCount[i]) { + gl.drawArrays(gl.LINES, this.lineOffset[i], this.lineCount[i]) + } + } + this.vao.unbind() +} + +function updateBounds(bounds, point) { + for(var i=0; i<3; ++i) { + bounds[0][i] = Math.min(bounds[0][i], point[i]) + bounds[1][i] = Math.max(bounds[1][i], point[i]) + } +} + +var FACE_TABLE = (function(){ + var table = new Array(3) + for(var d=0; d<3; ++d) { + var row = [] + for(var j=1; j<=2; ++j) { + for(var s=-1; s<=1; s+=2) { + var u = (j+d) % 3 + var y = [0,0,0] + y[u] = s + row.push(y) + } + } + table[d] = row + } + return table +})() + + +function emitFace(verts, x, c, d) { + var offsets = FACE_TABLE[d] + for(var i=0; i 0) { + var x = p.slice() + x[j] += e[1][j] + verts.push(p[0], p[1], p[2], + c[0], c[1], c[2], c[3], + 0, 0, 0, + x[0], x[1], x[2], + c[0], c[1], c[2], c[3], + 0, 0, 0) + updateBounds(this.bounds, x) + vertexCount += 2 + emitFace(verts, x, c, j) + } + } + this.lineCount[j] = vertexCount - this.lineOffset[j] + } + this.buffer.update(verts) + } +} + +proto.dispose = function() { + this.shader.dispose() + this.buffer.dispose() + this.vao.dispose() +} + +function createErrorBars(options) { + var gl = options.gl + var buffer = createBuffer(gl) + var vao = createVAO(gl, [ + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 0, + stride: 40 + }, + { + buffer: buffer, + type: gl.FLOAT, + size: 4, + offset: 12, + stride: 40 + }, + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 28, + stride: 40 + } + ]) + + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.color.location = 1 + shader.attributes.offset.location = 2 + + var result = new ErrorBars(gl, buffer, vao, shader) + result.update(options) + return result +} },{"./shaders/index":238,"gl-buffer":230,"gl-vao":310}],238:[function(_dereq_,module,exports){ -'use strict' - -var glslify = _dereq_('glslify') -var createShader = _dereq_('gl-shader') - -var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]) -var fragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]) - -module.exports = function(gl) { - return createShader(gl, vertSrc, fragSrc, null, [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'offset', type: 'vec3'} - ]) -} +'use strict' + +var glslify = _dereq_('glslify') +var createShader = _dereq_('gl-shader') + +var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]) +var fragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]) + +module.exports = function(gl) { + return createShader(gl, vertSrc, fragSrc, null, [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'offset', type: 'vec3'} + ]) +} },{"gl-shader":288,"glslify":392}],239:[function(_dereq_,module,exports){ 'use strict' @@ -37571,7 +37585,7 @@ function createHeatmap2D (plot, options) { return heatmap } -},{"./lib/shaders":242,"binary-search-bounds":243,"gl-buffer":230,"gl-shader":288,"iota-array":399,"typedarray-pool":522}],242:[function(_dereq_,module,exports){ +},{"./lib/shaders":242,"binary-search-bounds":243,"gl-buffer":230,"gl-shader":288,"iota-array":399,"typedarray-pool":521}],242:[function(_dereq_,module,exports){ 'use strict' var glslify = _dereq_('glslify') @@ -37591,7 +37605,7 @@ var createShader = _dereq_('gl-shader') var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvec4 project(vec3 p) {\n return projection * view * model * vec4(p, 1.0);\n}\n\nvoid main() {\n vec4 startPoint = project(position);\n vec4 endPoint = project(nextPosition);\n\n vec2 A = startPoint.xy / startPoint.w;\n vec2 B = endPoint.xy / endPoint.w;\n\n float clipAngle = atan(\n (B.y - A.y) * screenShape.y,\n (B.x - A.x) * screenShape.x\n );\n\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(\n sin(clipAngle),\n -cos(clipAngle)\n ) / screenShape;\n\n gl_Position = vec4(startPoint.xy + startPoint.w * offset, startPoint.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n"]) var forwardFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]) -var pickFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1540259130(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1540259130(pixelArcLength).xyz);\n}"]) +var pickFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1604150559(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1604150559(pixelArcLength).xyz);\n}"]) var ATTRIBUTES = [ {name: 'position', type: 'vec3'}, @@ -38856,8890 +38870,8987 @@ function invert(out, M) { },{"gl-mat2/invert":246,"gl-mat3/invert":247,"gl-mat4/invert":254}],266:[function(_dereq_,module,exports){ arguments[4][232][0].apply(exports,arguments) },{"barycentric":61,"dup":232,"polytope-closest-point/lib/closest_point_2d.js":464}],267:[function(_dereq_,module,exports){ -var glslify = _dereq_('glslify') - -var triVertSrc = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}\n"]) -var triFragSrc = glslify(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nvec3 normals(vec3 pos) {\n vec3 fdx = dFdx(pos);\n vec3 fdy = dFdy(pos);\n return normalize(cross(fdx, fdy));\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]) -var edgeVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]) -var edgeFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) -var pointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]) -var pointFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) -var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) -var pickPointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]) -var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]) -var contourFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]) - -exports.meshShader = { - vertex: triVertSrc, - fragment: triFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'normal', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'} - ] -} -exports.wireShader = { - vertex: edgeVertSrc, - fragment: edgeFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'} - ] -} -exports.pointShader = { - vertex: pointVertSrc, - fragment: pointFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'}, - {name: 'pointSize', type: 'float'} - ] -} -exports.pickShader = { - vertex: pickVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'id', type: 'vec4'} - ] -} -exports.pointPickShader = { - vertex: pickPointVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'pointSize', type: 'float'}, - {name: 'id', type: 'vec4'} - ] -} -exports.contourShader = { - vertex: contourVertSrc, - fragment: contourFragSrc, - attributes: [ - {name: 'position', type: 'vec3'} - ] -} +var glslify = _dereq_('glslify') + +var triVertSrc = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}\n"]) +var triFragSrc = glslify(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nvec3 normals(vec3 pos) {\n vec3 fdx = dFdx(pos);\n vec3 fdy = dFdy(pos);\n return normalize(cross(fdx, fdy));\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]) +var edgeVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]) +var edgeFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) +var pointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]) +var pointFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) +var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) +var pickPointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]) +var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]) +var contourFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]) + +exports.meshShader = { + vertex: triVertSrc, + fragment: triFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'normal', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'} + ] +} +exports.wireShader = { + vertex: edgeVertSrc, + fragment: edgeFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'} + ] +} +exports.pointShader = { + vertex: pointVertSrc, + fragment: pointFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'}, + {name: 'pointSize', type: 'float'} + ] +} +exports.pickShader = { + vertex: pickVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'id', type: 'vec4'} + ] +} +exports.pointPickShader = { + vertex: pickPointVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'pointSize', type: 'float'}, + {name: 'id', type: 'vec4'} + ] +} +exports.contourShader = { + vertex: contourVertSrc, + fragment: contourFragSrc, + attributes: [ + {name: 'position', type: 'vec3'} + ] +} },{"glslify":392}],268:[function(_dereq_,module,exports){ +'use strict' + +var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small +var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; + +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var normals = _dereq_('normals') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var ndarray = _dereq_('ndarray') +var colormap = _dereq_('colormap') +var getContour = _dereq_('simplicial-complex-contour') +var pool = _dereq_('typedarray-pool') +var shaders = _dereq_('./lib/shaders') +var closestPoint = _dereq_('./lib/closest-point') + +var meshShader = shaders.meshShader +var wireShader = shaders.wireShader +var pointShader = shaders.pointShader +var pickShader = shaders.pickShader +var pointPickShader = shaders.pointPickShader +var contourShader = shaders.contourShader + +var identityMatrix = [ + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + + +function SimplicialMesh(gl + , texture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) { + + this.gl = gl + this.cells = [] + this.positions = [] + this.intensity = [] + this.texture = texture + this.dirty = true + + this.triShader = triShader + this.lineShader = lineShader + this.pointShader = pointShader + this.pickShader = pickShader + this.pointPickShader = pointPickShader + this.contourShader = contourShader + + this.trianglePositions = trianglePositions + this.triangleColors = triangleColors + this.triangleNormals = triangleNormals + this.triangleUVs = triangleUVs + this.triangleIds = triangleIds + this.triangleVAO = triangleVAO + this.triangleCount = 0 + + this.lineWidth = 1 + this.edgePositions = edgePositions + this.edgeColors = edgeColors + this.edgeUVs = edgeUVs + this.edgeIds = edgeIds + this.edgeVAO = edgeVAO + this.edgeCount = 0 + + this.pointPositions = pointPositions + this.pointColors = pointColors + this.pointUVs = pointUVs + this.pointSizes = pointSizes + this.pointIds = pointIds + this.pointVAO = pointVAO + this.pointCount = 0 + + this.contourLineWidth = 1 + this.contourPositions = contourPositions + this.contourVAO = contourVAO + this.contourCount = 0 + this.contourColor = [0,0,0] + this.contourEnable = true + + this.pickId = 1 + this.bounds = [ + [ Infinity, Infinity, Infinity], + [-Infinity,-Infinity,-Infinity] ] + this.clipBounds = [ + [-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity] ] + + this.lightPosition = [1e5, 1e5, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + + this.opacity = 1.0 + + this._model = identityMatrix + this._view = identityMatrix + this._projection = identityMatrix + this._resolution = [1,1] +} + +var proto = SimplicialMesh.prototype + +proto.isOpaque = function() { + return this.opacity >= 1 +} + +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.pickSlots = 1 + +proto.setPickBase = function(id) { + this.pickId = id +} + +function genColormap(param) { + var colors = colormap({ + colormap: param + , nshades: 256 + , format: 'rgba' + }) + + var result = new Uint8Array(256*4) + for(var i=0; i<256; ++i) { + var c = colors[i] + for(var j=0; j<3; ++j) { + result[4*i+j] = c[j] + } + result[4*i+3] = c[3]*255 + } + + return ndarray(result, [256,256,4], [4,0,1]) +} + +function unpackIntensity(cells, numVerts, cellIntensity) { + var result = new Array(numVerts) + for(var i=0; i 0) { + var shader = this.triShader + shader.bind() + shader.uniforms = uniforms + + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0 && this.lineWidth > 0) { + var shader = this.lineShader + shader.bind() + shader.uniforms = uniforms + + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } + + if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { + var shader = this.contourShader + shader.bind() + shader.uniforms = uniforms + + this.contourVAO.bind() + gl.drawArrays(gl.LINES, 0, this.contourCount) + this.contourVAO.unbind() + } +} + +proto.drawPick = function(params) { + params = params || {} + + var gl = this.gl + + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix + + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } + + //Save camera parameters + this._model = [].slice.call(model) + this._view = [].slice.call(view) + this._projection = [].slice.call(projection) + this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] + + var uniforms = { + model: model, + view: view, + projection: projection, + clipBounds: clipBounds, + pickId: this.pickId / 255.0, + } + + var shader = this.pickShader + shader.bind() + shader.uniforms = uniforms + + if(this.triangleCount > 0) { + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0) { + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointPickShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } +} + + +proto.pick = function(pickData) { + if(!pickData) { + return null + } + if(pickData.id !== this.pickId) { + return null + } + + var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] + var cell = this.cells[cellId] + var positions = this.positions + + var simplex = new Array(cell.length) + for(var i=0; i tickOffset[start]) { + shader.uniforms.dataAxis = DATA_AXIS + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = textColor[axis] + shader.uniforms.angle = textAngle[axis] + gl.drawArrays( + gl.TRIANGLES, + tickOffset[start], + tickOffset[end] - tickOffset[start]) + } + } + if(labelEnable[axis] && labelCount) { + SCREEN_OFFSET[axis^1] -= screenScale * pixelRatio * labelPad[axis] + shader.uniforms.dataAxis = ZERO_2 + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = labelColor[axis] + shader.uniforms.angle = labelAngle[axis] + gl.drawArrays( + gl.TRIANGLES, + labelOffset, + labelCount) + } + + SCREEN_OFFSET[axis^1] = screenScale * viewBox[2+(axis^1)] - 1.0 + if(tickEnable[axis+2]) { + SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * tickPad[axis+2] + if(start < end && tickOffset[end] > tickOffset[start]) { + shader.uniforms.dataAxis = DATA_AXIS + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = textColor[axis+2] + shader.uniforms.angle = textAngle[axis+2] + gl.drawArrays( + gl.TRIANGLES, + tickOffset[start], + tickOffset[end] - tickOffset[start]) + } + } + if(labelEnable[axis+2] && labelCount) { + SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * labelPad[axis+2] + shader.uniforms.dataAxis = ZERO_2 + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = labelColor[axis+2] + shader.uniforms.angle = labelAngle[axis+2] + gl.drawArrays( + gl.TRIANGLES, + labelOffset, + labelCount) + } + + } +})() + +proto.drawTitle = (function() { + var DATA_AXIS = [0,0] + var SCREEN_OFFSET = [0,0] + + return function() { + var plot = this.plot + var shader = this.shader + var gl = plot.gl + var screenBox = plot.screenBox + var titleCenter = plot.titleCenter + var titleAngle = plot.titleAngle + var titleColor = plot.titleColor + var pixelRatio = plot.pixelRatio + + if(!this.titleCount) { + return + } + + for(var i=0; i<2; ++i) { + SCREEN_OFFSET[i] = 2.0 * (titleCenter[i]*pixelRatio - screenBox[i]) / + (screenBox[2+i] - screenBox[i]) - 1 + } + + shader.bind() + shader.uniforms.dataAxis = DATA_AXIS + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.angle = titleAngle + shader.uniforms.color = titleColor + + gl.drawArrays(gl.TRIANGLES, this.titleOffset, this.titleCount) + } +})() + +proto.bind = (function() { + var DATA_SHIFT = [0,0] + var DATA_SCALE = [0,0] + var TEXT_SCALE = [0,0] + + return function() { + var plot = this.plot + var shader = this.shader + var bounds = plot._tickBounds + var dataBox = plot.dataBox + var screenBox = plot.screenBox + var viewBox = plot.viewBox + + shader.bind() + + //Set up coordinate scaling uniforms + for(var i=0; i<2; ++i) { + + var lo = bounds[i] + var hi = bounds[i+2] + var boundScale = hi - lo + var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) + var dataWidth = (dataBox[i+2] - dataBox[i]) + + var viewLo = viewBox[i] + var viewHi = viewBox[i+2] + var viewScale = viewHi - viewLo + var screenLo = screenBox[i] + var screenHi = screenBox[i+2] + var screenScale = screenHi - screenLo + + DATA_SCALE[i] = 2.0 * boundScale / dataWidth * viewScale / screenScale + DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth * viewScale / screenScale + } + + TEXT_SCALE[1] = 2.0 * plot.pixelRatio / (screenBox[3] - screenBox[1]) + TEXT_SCALE[0] = TEXT_SCALE[1] * (screenBox[3] - screenBox[1]) / (screenBox[2] - screenBox[0]) + + shader.uniforms.dataScale = DATA_SCALE + shader.uniforms.dataShift = DATA_SHIFT + shader.uniforms.textScale = TEXT_SCALE + + //Set attributes + this.vbo.bind() + shader.attributes.textCoordinate.pointer() + } +})() + +proto.update = function(options) { + var vertices = [] + var axesTicks = options.ticks + var bounds = options.bounds + var i, j, k, data, scale, dimension + + for(dimension=0; dimension<2; ++dimension) { + var offsets = [Math.floor(vertices.length/3)], tickX = [-Infinity] + + //Copy vertices over to buffer + var ticks = axesTicks[dimension] + for(i=0; i= 0)) { + continue + } + + var zeroIntercept = screenBox[i] - + dataBox[i] * (screenBox[i+2] - screenBox[i]) / (dataBox[i+2] - dataBox[i]) + + if(i === 0) { + line.drawLine( + zeroIntercept, screenBox[1], zeroIntercept, screenBox[3], + zeroLineWidth[i], + zeroLineColor[i]) + } else { + line.drawLine( + screenBox[0], zeroIntercept, screenBox[2], zeroIntercept, + zeroLineWidth[i], + zeroLineColor[i]) + } + } + } + + //Draw traces + for(var i=0; i=0; --i) { + this.objects[i].dispose() + } + this.objects.length = 0 + for(var i=this.overlays.length-1; i>=0; --i) { + this.overlays[i].dispose() + } + this.overlays.length = 0 + + this.gl = null +} + +proto.addObject = function(object) { + if(this.objects.indexOf(object) < 0) { + this.objects.push(object) + this.setDirty() + } +} + +proto.removeObject = function(object) { + var objects = this.objects + for(var i=0; i 0) { + var base = Math.round(Math.pow(10, y)) + return Math.ceil(x/base) * base + } + return Math.ceil(x) +} + +function defaultBool(x) { + if(typeof x === 'boolean') { + return x + } + return true +} + +function createScene(options) { + options = options || {} + + var stopped = false + + var pixelRatio = options.pixelRatio || parseFloat(window.devicePixelRatio) + + var canvas = options.canvas + if(!canvas) { + canvas = document.createElement('canvas') + if(options.container) { + var container = options.container + container.appendChild(canvas) + } else { + document.body.appendChild(canvas) + } + } + + var gl = options.gl + if(!gl) { + gl = getContext(canvas, + options.glOptions || { + premultipliedAlpha: true, + antialias: true, + preserveDrawingBuffer: isMobile + }) + } + if(!gl) { + throw new Error('webgl not supported') + } + + //Initial bounds + var bounds = options.bounds || [[-10,-10,-10], [10,10,10]] + + //Create selection + var selection = new MouseSelect() + + //Accumulation buffer + var accumBuffer = createFBO(gl, + [gl.drawingBufferWidth, gl.drawingBufferHeight], { + preferFloat: !isMobile + }) + + var accumShader = createShader(gl) + + //Create a camera + var cameraOptions = options.camera || { + eye: [2,0,0], + center: [0,0,0], + up: [0,1,0], + zoomMin: 0.1, + zoomMax: 100, + mode: 'turntable' + } + + //Create axes + var axesOptions = options.axes || {} + var axes = createAxes(gl, axesOptions) + axes.enable = !axesOptions.disable + + //Create spikes + var spikeOptions = options.spikes || {} + var spikes = createSpikes(gl, spikeOptions) + + //Object list is empty initially + var objects = [] + var pickBufferIds = [] + var pickBufferCount = [] + var pickBuffers = [] + + //Dirty flag, skip redraw if scene static + var dirty = true + var pickDirty = true + + var projection = new Array(16) + var model = new Array(16) + + var cameraParams = { + view: null, + projection: projection, + model: model + } + + var pickDirty = true + + var viewShape = [ gl.drawingBufferWidth, gl.drawingBufferHeight ] + + //Create scene object + var scene = { + gl: gl, + contextLost: false, + pixelRatio: options.pixelRatio || parseFloat(window.devicePixelRatio), + canvas: canvas, + selection: selection, + camera: createCamera(canvas, cameraOptions), + axes: axes, + axesPixels: null, + spikes: spikes, + bounds: bounds, + objects: objects, + shape: viewShape, + aspect: options.aspectRatio || [1,1,1], + pickRadius: options.pickRadius || 10, + zNear: options.zNear || 0.01, + zFar: options.zFar || 1000, + fovy: options.fovy || Math.PI/4, + clearColor: options.clearColor || [0,0,0,0], + autoResize: defaultBool(options.autoResize), + autoBounds: defaultBool(options.autoBounds), + autoScale: !!options.autoScale, + autoCenter: defaultBool(options.autoCenter), + clipToBounds: defaultBool(options.clipToBounds), + snapToData: !!options.snapToData, + onselect: options.onselect || null, + onrender: options.onrender || null, + onclick: options.onclick || null, + cameraParams: cameraParams, + oncontextloss: null, + mouseListener: null + } + + var pickShape = [ (gl.drawingBufferWidth/scene.pixelRatio)|0, (gl.drawingBufferHeight/scene.pixelRatio)|0 ] + + function resizeListener() { + if(stopped) { + return + } + if(!scene.autoResize) { + return + } + var parent = canvas.parentNode + var width = 1 + var height = 1 + if(parent && parent !== document.body) { + width = parent.clientWidth + height = parent.clientHeight + } else { + width = window.innerWidth + height = window.innerHeight + } + var nextWidth = Math.ceil(width * scene.pixelRatio)|0 + var nextHeight = Math.ceil(height * scene.pixelRatio)|0 + if(nextWidth !== canvas.width || nextHeight !== canvas.height) { + canvas.width = nextWidth + canvas.height = nextHeight + var style = canvas.style + style.position = style.position || 'absolute' + style.left = '0px' + style.top = '0px' + style.width = width + 'px' + style.height = height + 'px' + dirty = true + } + } + if(scene.autoResize) { + resizeListener() + } + window.addEventListener('resize', resizeListener) + + function reallocPickIds() { + var numObjs = objects.length + var numPick = pickBuffers.length + for(var i=0; i 0 && pickBufferCount[numPick-1] === 0) { + pickBufferCount.pop() + pickBuffers.pop().dispose() + } + } + + scene.update = function(options) { + if(stopped) { + return + } + options = options || {} + dirty = true + pickDirty = true + } + + scene.add = function(obj) { + if(stopped) { + return + } + obj.axes = axes + objects.push(obj) + pickBufferIds.push(-1) + dirty = true + pickDirty = true + reallocPickIds() + } + + scene.remove = function(obj) { + if(stopped) { + return + } + var idx = objects.indexOf(obj) + if(idx < 0) { + return + } + objects.splice(idx, 1) + pickBufferIds.pop() + dirty = true + pickDirty = true + reallocPickIds() + } + + scene.dispose = function() { + if(stopped) { + return + } + + stopped = true + + window.removeEventListener('resize', resizeListener) + canvas.removeEventListener('webglcontextlost', checkContextLoss) + scene.mouseListener.enabled = false + + if(scene.contextLost) { + return + } + + //Destroy objects + axes.dispose() + spikes.dispose() + for(var i=0; i selection.distance) { + continue + } + for(var j=0; j 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]) +exports.pickVertex = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]) +exports.pickFragment = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"]) + +},{"glslify":392}],279:[function(_dereq_,module,exports){ 'use strict' -var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small -var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var normals = _dereq_('normals') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var ndarray = _dereq_('ndarray') -var colormap = _dereq_('colormap') -var getContour = _dereq_('simplicial-complex-contour') -var pool = _dereq_('typedarray-pool') -var shaders = _dereq_('./lib/shaders') -var closestPoint = _dereq_('./lib/closest-point') - -var meshShader = shaders.meshShader -var wireShader = shaders.wireShader -var pointShader = shaders.pointShader -var pickShader = shaders.pickShader -var pointPickShader = shaders.pointPickShader -var contourShader = shaders.contourShader - -var identityMatrix = [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - - -function SimplicialMesh(gl - , texture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) { - - this.gl = gl - this.cells = [] - this.positions = [] - this.intensity = [] - this.texture = texture - this.dirty = true - - this.triShader = triShader - this.lineShader = lineShader - this.pointShader = pointShader - this.pickShader = pickShader - this.pointPickShader = pointPickShader - this.contourShader = contourShader - - this.trianglePositions = trianglePositions - this.triangleColors = triangleColors - this.triangleNormals = triangleNormals - this.triangleUVs = triangleUVs - this.triangleIds = triangleIds - this.triangleVAO = triangleVAO - this.triangleCount = 0 - - this.lineWidth = 1 - this.edgePositions = edgePositions - this.edgeColors = edgeColors - this.edgeUVs = edgeUVs - this.edgeIds = edgeIds - this.edgeVAO = edgeVAO - this.edgeCount = 0 - - this.pointPositions = pointPositions - this.pointColors = pointColors - this.pointUVs = pointUVs - this.pointSizes = pointSizes - this.pointIds = pointIds - this.pointVAO = pointVAO - this.pointCount = 0 - - this.contourLineWidth = 1 - this.contourPositions = contourPositions - this.contourVAO = contourVAO - this.contourCount = 0 - this.contourColor = [0,0,0] - this.contourEnable = true - - this.pickId = 1 - this.bounds = [ - [ Infinity, Infinity, Infinity], - [-Infinity,-Infinity,-Infinity] ] - this.clipBounds = [ - [-Infinity,-Infinity,-Infinity], - [ Infinity, Infinity, Infinity] ] - - this.lightPosition = [1e5, 1e5, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - - this.opacity = 1.0 - - this._model = identityMatrix - this._view = identityMatrix - this._projection = identityMatrix - this._resolution = [1,1] -} +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') -var proto = SimplicialMesh.prototype +var pool = _dereq_('typedarray-pool') -proto.isOpaque = function() { - return this.opacity >= 1 -} +var SHADERS = _dereq_('./lib/shader') + +module.exports = createPointcloud2D -proto.isTransparent = function() { - return this.opacity < 1 +function Pointcloud2D(plot, offsetBuffer, pickBuffer, shader, pickShader) { + this.plot = plot + this.offsetBuffer = offsetBuffer + this.pickBuffer = pickBuffer + this.shader = shader + this.pickShader = pickShader + this.sizeMin = 0.5 + this.sizeMinCap = 2 + this.sizeMax = 20 + this.areaRatio = 1.0 + this.pointCount = 0 + this.color = [1, 0, 0, 1] + this.borderColor = [0, 0, 0, 1] + this.blend = false + this.pickOffset = 0 + this.points = null } -proto.pickSlots = 1 +var proto = Pointcloud2D.prototype -proto.setPickBase = function(id) { - this.pickId = id +proto.dispose = function() { + this.shader.dispose() + this.pickShader.dispose() + this.offsetBuffer.dispose() + this.pickBuffer.dispose() + this.plot.removeObject(this) } -function genColormap(param) { - var colors = colormap({ - colormap: param - , nshades: 256 - , format: 'rgba' - }) +proto.update = function(options) { - var result = new Uint8Array(256*4) - for(var i=0; i<256; ++i) { - var c = colors[i] - for(var j=0; j<3; ++j) { - result[4*i+j] = c[j] - } - result[4*i+3] = c[3]*255 - } + var i - return ndarray(result, [256,256,4], [4,0,1]) -} + options = options || {} -function unpackIntensity(cells, numVerts, cellIntensity) { - var result = new Array(numVerts) - for(var i=0; i>> 1 + var dataStraightThrough = options.positions instanceof Float32Array + var idStraightThrough = options.idToIndex instanceof Int32Array && options.idToIndex.length >= pointCount // permit larger to help reuse - this.dirty = true + var data = options.positions + var packed = dataStraightThrough ? data : pool.mallocFloat32(data.length) + var packedId = idStraightThrough ? options.idToIndex : pool.mallocInt32(pointCount) - if('contourEnable' in params) { - this.contourEnable = params.contourEnable - } - if('contourColor' in params) { - this.contourColor = params.contourColor - } - if('lineWidth' in params) { - this.lineWidth = params.lineWidth - } - if('lightPosition' in params) { - this.lightPosition = params.lightPosition - } - if('opacity' in params) { - this.opacity = params.opacity - } - if('ambient' in params) { - this.ambientLight = params.ambient - } - if('diffuse' in params) { - this.diffuseLight = params.diffuse - } - if('specular' in params) { - this.specularLight = params.specular - } - if('roughness' in params) { - this.roughness = params.roughness - } - if('fresnel' in params) { - this.fresnel = params.fresnel + if(!dataStraightThrough) { + packed.set(data) } - if(params.texture) { - this.texture.dispose() - this.texture = createTexture(gl, params.texture) - } else if (params.colormap) { - this.texture.shape = [256,256] - this.texture.minFilter = gl.LINEAR_MIPMAP_LINEAR - this.texture.magFilter = gl.LINEAR - this.texture.setPixels(genColormap(params.colormap)) - this.texture.generateMipmap() + if(!idStraightThrough) { + packed.set(data) + for(i = 0; i < pointCount; i++) { + packedId[i] = i + } } - var cells = params.cells - var positions = params.positions + this.points = data - if(!positions || !cells) { - return - } + this.offsetBuffer.update(packed) + this.pickBuffer.update(packedId) - var tPos = [] - var tCol = [] - var tNor = [] - var tUVs = [] - var tIds = [] - - var ePos = [] - var eCol = [] - var eUVs = [] - var eIds = [] - - var pPos = [] - var pCol = [] - var pUVs = [] - var pSiz = [] - var pIds = [] - - //Save geometry data for picking calculations - this.cells = cells - this.positions = positions - - //Compute normals - var vertexNormals = params.vertexNormals - var cellNormals = params.cellNormals - var vertexNormalsEpsilon = params.vertexNormalsEpsilon === void(0) ? DEFAULT_VERTEX_NORMALS_EPSILON : params.vertexNormalsEpsilon - var faceNormalsEpsilon = params.faceNormalsEpsilon === void(0) ? DEFAULT_FACE_NORMALS_EPSILON : params.faceNormalsEpsilon - if(params.useFacetNormals && !cellNormals) { - cellNormals = normals.faceNormals(cells, positions, faceNormalsEpsilon) + if(!dataStraightThrough) { + pool.free(packed) } - if(!cellNormals && !vertexNormals) { - vertexNormals = normals.vertexNormals(cells, positions, vertexNormalsEpsilon) - } - - //Compute colors - var vertexColors = params.vertexColors - var cellColors = params.cellColors - var meshColor = params.meshColor || [1,1,1,1] - - //UVs - var vertexUVs = params.vertexUVs - var vertexIntensity = params.vertexIntensity - var cellUVs = params.cellUVs - var cellIntensity = params.cellIntensity - - var intensityLo = Infinity - var intensityHi = -Infinity - if(!vertexUVs && !cellUVs) { - if(vertexIntensity) { - if(params.vertexIntensityBounds) { - intensityLo = +params.vertexIntensityBounds[0] - intensityHi = +params.vertexIntensityBounds[1] - } else { - for(var i=0; i>> 1 + var i + for(i = 0; i < length; i++) { + var x = points[i * 2] + var y = points[i * 2 + 1] + if(x >= dataBox[0] && x <= dataBox[2] && y >= dataBox[1] && y <= dataBox[3]) + visiblePointCountEstimate++ } + return visiblePointCountEstimate +} - if(this.triangleCount > 0) { - var shader = this.triShader - shader.bind() - shader.uniforms = uniforms - - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } +proto.unifiedDraw = (function() { + var MATRIX = [1, 0, 0, + 0, 1, 0, + 0, 0, 1] + var PICK_VEC4 = [0, 0, 0, 0] +return function(pickOffset) { + var pick = pickOffset !== void(0) - if(this.edgeCount > 0 && this.lineWidth > 0) { - var shader = this.lineShader - shader.bind() - shader.uniforms = uniforms + var shader = pick ? this.pickShader : this.shader + var gl = this.plot.gl + var dataBox = this.plot.dataBox - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() + if(this.pointCount === 0) { + return pickOffset } - if(this.pointCount > 0) { - var shader = this.pointShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } + var dataX = dataBox[2] - dataBox[0] + var dataY = dataBox[3] - dataBox[1] - if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { - var shader = this.contourShader - shader.bind() - shader.uniforms = uniforms + var visiblePointCountEstimate = count(this.points, dataBox) + var basicPointSize = this.plot.pickPixelRatio * Math.max(Math.min(this.sizeMinCap, this.sizeMin), Math.min(this.sizeMax, this.sizeMax / Math.pow(visiblePointCountEstimate, 0.33333))) - this.contourVAO.bind() - gl.drawArrays(gl.LINES, 0, this.contourCount) - this.contourVAO.unbind() - } -} + MATRIX[0] = 2.0 / dataX + MATRIX[4] = 2.0 / dataY + MATRIX[6] = -2.0 * dataBox[0] / dataX - 1.0 + MATRIX[7] = -2.0 * dataBox[1] / dataY - 1.0 -proto.drawPick = function(params) { - params = params || {} + this.offsetBuffer.bind() - var gl = this.gl + shader.bind() + shader.attributes.position.pointer() + shader.uniforms.matrix = MATRIX + shader.uniforms.color = this.color + shader.uniforms.borderColor = this.borderColor + shader.uniforms.pointCloud = basicPointSize < 5 + shader.uniforms.pointSize = basicPointSize + shader.uniforms.centerFraction = Math.min(1, Math.max(0, Math.sqrt(1 - this.areaRatio))) - var model = params.model || identityMatrix - var view = params.view || identityMatrix - var projection = params.projection || identityMatrix + if(pick) { - var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] - for(var i=0; i<3; ++i) { - clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) - clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) - } + PICK_VEC4[0] = ( pickOffset & 0xff) + PICK_VEC4[1] = ((pickOffset >> 8) & 0xff) + PICK_VEC4[2] = ((pickOffset >> 16) & 0xff) + PICK_VEC4[3] = ((pickOffset >> 24) & 0xff) - //Save camera parameters - this._model = [].slice.call(model) - this._view = [].slice.call(view) - this._projection = [].slice.call(projection) - this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - - var uniforms = { - model: model, - view: view, - projection: projection, - clipBounds: clipBounds, - pickId: this.pickId / 255.0, + this.pickBuffer.bind() + shader.attributes.pickId.pointer(gl.UNSIGNED_BYTE) + shader.uniforms.pickOffset = PICK_VEC4 + this.pickOffset = pickOffset } - var shader = this.pickShader - shader.bind() - shader.uniforms = uniforms + // Worth switching these off, but we can't make assumptions about other + // renderers, so let's restore it after each draw + var blend = gl.getParameter(gl.BLEND) + var dither = gl.getParameter(gl.DITHER) - if(this.triangleCount > 0) { - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } + if(blend && !this.blend) + gl.disable(gl.BLEND) + if(dither) + gl.disable(gl.DITHER) - if(this.edgeCount > 0) { - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } + gl.drawArrays(gl.POINTS, 0, this.pointCount) - if(this.pointCount > 0) { - var shader = this.pointPickShader - shader.bind() - shader.uniforms = uniforms + if(blend && !this.blend) + gl.enable(gl.BLEND) + if(dither) + gl.enable(gl.DITHER) - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } + return pickOffset + this.pointCount } +})() +proto.draw = proto.unifiedDraw +proto.drawPick = proto.unifiedDraw -proto.pick = function(pickData) { - if(!pickData) { - return null - } - if(pickData.id !== this.pickId) { - return null - } - - var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] - var cell = this.cells[cellId] - var positions = this.positions - - var simplex = new Array(cell.length) - for(var i=0; i= pickOffset + pointCount) { return null } - - var weights = data[2] - var interpIntensity = 0.0 - for(var i=0; i tickOffset[start]) { - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = textColor[axis] - shader.uniforms.angle = textAngle[axis] - gl.drawArrays( - gl.TRIANGLES, - tickOffset[start], - tickOffset[end] - tickOffset[start]) - } - } - if(labelEnable[axis] && labelCount) { - SCREEN_OFFSET[axis^1] -= screenScale * pixelRatio * labelPad[axis] - shader.uniforms.dataAxis = ZERO_2 - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = labelColor[axis] - shader.uniforms.angle = labelAngle[axis] - gl.drawArrays( - gl.TRIANGLES, - labelOffset, - labelCount) - } - - SCREEN_OFFSET[axis^1] = screenScale * viewBox[2+(axis^1)] - 1.0 - if(tickEnable[axis+2]) { - SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * tickPad[axis+2] - if(start < end && tickOffset[end] > tickOffset[start]) { - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = textColor[axis+2] - shader.uniforms.angle = textAngle[axis+2] - gl.drawArrays( - gl.TRIANGLES, - tickOffset[start], - tickOffset[end] - tickOffset[start]) - } - } - if(labelEnable[axis+2] && labelCount) { - SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * labelPad[axis+2] - shader.uniforms.dataAxis = ZERO_2 - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = labelColor[axis+2] - shader.uniforms.angle = labelAngle[axis+2] - gl.drawArrays( - gl.TRIANGLES, - labelOffset, - labelCount) - } - - } -})() - -proto.drawTitle = (function() { - var DATA_AXIS = [0,0] - var SCREEN_OFFSET = [0,0] - - return function() { - var plot = this.plot - var shader = this.shader - var gl = plot.gl - var screenBox = plot.screenBox - var titleCenter = plot.titleCenter - var titleAngle = plot.titleAngle - var titleColor = plot.titleColor - var pixelRatio = plot.pixelRatio - - if(!this.titleCount) { - return - } - - for(var i=0; i<2; ++i) { - SCREEN_OFFSET[i] = 2.0 * (titleCenter[i]*pixelRatio - screenBox[i]) / - (screenBox[2+i] - screenBox[i]) - 1 - } - - shader.bind() - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.angle = titleAngle - shader.uniforms.color = titleColor - - gl.drawArrays(gl.TRIANGLES, this.titleOffset, this.titleCount) - } -})() - -proto.bind = (function() { - var DATA_SHIFT = [0,0] - var DATA_SCALE = [0,0] - var TEXT_SCALE = [0,0] - - return function() { - var plot = this.plot - var shader = this.shader - var bounds = plot._tickBounds - var dataBox = plot.dataBox - var screenBox = plot.screenBox - var viewBox = plot.viewBox - - shader.bind() - - //Set up coordinate scaling uniforms - for(var i=0; i<2; ++i) { - - var lo = bounds[i] - var hi = bounds[i+2] - var boundScale = hi - lo - var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) - var dataWidth = (dataBox[i+2] - dataBox[i]) - - var viewLo = viewBox[i] - var viewHi = viewBox[i+2] - var viewScale = viewHi - viewLo - var screenLo = screenBox[i] - var screenHi = screenBox[i+2] - var screenScale = screenHi - screenLo - - DATA_SCALE[i] = 2.0 * boundScale / dataWidth * viewScale / screenScale - DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth * viewScale / screenScale - } - - TEXT_SCALE[1] = 2.0 * plot.pixelRatio / (screenBox[3] - screenBox[1]) - TEXT_SCALE[0] = TEXT_SCALE[1] * (screenBox[3] - screenBox[1]) / (screenBox[2] - screenBox[0]) - - shader.uniforms.dataScale = DATA_SCALE - shader.uniforms.dataShift = DATA_SHIFT - shader.uniforms.textScale = TEXT_SCALE - - //Set attributes - this.vbo.bind() - shader.attributes.textCoordinate.pointer() - } -})() - -proto.update = function(options) { - var vertices = [] - var axesTicks = options.ticks - var bounds = options.bounds - var i, j, k, data, scale, dimension - - for(dimension=0; dimension<2; ++dimension) { - var offsets = [Math.floor(vertices.length/3)], tickX = [-Infinity] - - //Copy vertices over to buffer - var ticks = axesTicks[dimension] - for(i=0; i 0.000001) { + // standard case (slerp) + omega = Math.acos(cosom) + sinom = Math.sin(omega) + scale0 = Math.sin((1.0 - t) * omega) / sinom + scale1 = Math.sin(t * omega) / sinom + } else { + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + scale0 = 1.0 - t + scale1 = t + } + // calculate final values + out[0] = scale0 * ax + scale1 * bx + out[1] = scale0 * ay + scale1 * by + out[2] = scale0 * az + scale1 * bz + out[3] = scale0 * aw + scale1 * bw + + return out +} + +},{}],281:[function(_dereq_,module,exports){ +'use strict'; + +module.exports = function(a){ + return (!a && a !== 0) ? '' : a.toString(); +} + +},{}],282:[function(_dereq_,module,exports){ +"use strict" + +var vectorizeText = _dereq_("vectorize-text") + +module.exports = getGlyph + +var GLYPH_CACHE = {} + +function getGlyph(symbol, font) { + var fontCache = GLYPH_CACHE[font] + if(!fontCache) { + fontCache = GLYPH_CACHE[font] = {} + } + if(symbol in fontCache) { + return fontCache[symbol] + } + + var config = { + textAlign: "center", + textBaseline: "middle", + lineHeight: 1.0, + font: font, + lineSpacing: 1.25, + styletags: { + breaklines:true, + bolds: true, + italics: true, + subscripts:true, + superscripts:true + } + } + + //Get line and triangle meshes for glyph + config.triangles = true; + var triSymbol = vectorizeText(symbol, config) + config.triangles = false; + var lineSymbol = vectorizeText(symbol, config) + + //Calculate bounding box + var bounds = [[Infinity,Infinity], [-Infinity,-Infinity]] + var n = lineSymbol.positions.length + for(var i = 0; i < n; ++i) { + var p = lineSymbol.positions[i] + for(var j=0; j<2; ++j) { + bounds[0][j] = Math.min(bounds[0][j], p[j]) + bounds[1][j] = Math.max(bounds[1][j], p[j]) + } + } + + //Save cached symbol + return fontCache[symbol] = [triSymbol, lineSymbol, bounds] +} +},{"vectorize-text":526}],283:[function(_dereq_,module,exports){ +var createShaderWrapper = _dereq_('gl-shader') +var glslify = _dereq_('glslify') + +var perspectiveVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) +var orthographicVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) +var projectionVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]) +var drawFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]) + +var ATTRIBUTES = [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'glyph', type: 'vec2'}, + {name: 'id', type: 'vec4'} +] + +var perspective = { + vertex: perspectiveVertSrc, + fragment: drawFragSrc, + attributes: ATTRIBUTES + }, + ortho = { + vertex: orthographicVertSrc, + fragment: drawFragSrc, + attributes: ATTRIBUTES + }, + project = { + vertex: projectionVertSrc, + fragment: drawFragSrc, + attributes: ATTRIBUTES + }, + pickPerspective = { + vertex: perspectiveVertSrc, + fragment: pickFragSrc, + attributes: ATTRIBUTES + }, + pickOrtho = { + vertex: orthographicVertSrc, + fragment: pickFragSrc, + attributes: ATTRIBUTES + }, + pickProject = { + vertex: projectionVertSrc, + fragment: pickFragSrc, + attributes: ATTRIBUTES + } + +function createShader(gl, src) { + var shader = createShaderWrapper(gl, src) + var attr = shader.attributes + attr.position.location = 0 + attr.color.location = 1 + attr.glyph.location = 2 + attr.id.location = 3 + return shader +} + +exports.createPerspective = function(gl) { + return createShader(gl, perspective) +} +exports.createOrtho = function(gl) { + return createShader(gl, ortho) +} +exports.createProject = function(gl) { + return createShader(gl, project) +} +exports.createPickPerspective = function(gl) { + return createShader(gl, pickPerspective) +} +exports.createPickOrtho = function(gl) { + return createShader(gl, pickOrtho) +} +exports.createPickProject = function(gl) { + return createShader(gl, pickProject) +} + +},{"gl-shader":288,"glslify":392}],284:[function(_dereq_,module,exports){ +'use strict' + +var isAllBlank = _dereq_('is-string-blank') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var pool = _dereq_('typedarray-pool') +var mat4mult = _dereq_('gl-mat4/multiply') +var shaders = _dereq_('./lib/shaders') +var getGlyph = _dereq_('./lib/glyphs') +var getSimpleString = _dereq_('./lib/get-simple-string') + +var IDENTITY = [1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +module.exports = createPointCloud + +function transformMat4(x, m) { + var x0 = x[0] + var x1 = x[1] + var x2 = x[2] + var x3 = x[3] + x[0] = m[0] * x0 + m[4] * x1 + m[8] * x2 + m[12] * x3 + x[1] = m[1] * x0 + m[5] * x1 + m[9] * x2 + m[13] * x3 + x[2] = m[2] * x0 + m[6] * x1 + m[10] * x2 + m[14] * x3 + x[3] = m[3] * x0 + m[7] * x1 + m[11] * x2 + m[15] * x3 + return x +} + +function project(p, v, m, x) { + transformMat4(x, x, m) + transformMat4(x, x, v) + return transformMat4(x, x, p) +} + +function clampVec(v) { + var result = new Array(3) + for(var i=0; i<3; ++i) { + result[i] = Math.min(Math.max(v[i], -1e8), 1e8) + } + return result +} + +function ScatterPlotPickResult(index, position) { + this.index = index + this.dataCoordinate = this.position = position +} + +var MAX_OPACITY = 1 + +function fixOpacity(a) { + if(a === true) return MAX_OPACITY + if(a > MAX_OPACITY) return MAX_OPACITY + return a +} + +function PointCloud( + gl, + shader, + orthoShader, + projectShader, + pointBuffer, + colorBuffer, + glyphBuffer, + idBuffer, + vao, + pickPerspectiveShader, + pickOrthoShader, + pickProjectShader) { + + this.gl = gl + + this.pixelRatio = 1 + + this.shader = shader + this.orthoShader = orthoShader + this.projectShader = projectShader + + this.pointBuffer = pointBuffer + this.colorBuffer = colorBuffer + this.glyphBuffer = glyphBuffer + this.idBuffer = idBuffer + this.vao = vao + this.vertexCount = 0 + this.lineVertexCount = 0 + + this.opacity = MAX_OPACITY + + this.lineWidth = 0 + this.projectScale = [2.0/3.0, 2.0/3.0, 2.0/3.0] + this.projectOpacity = [MAX_OPACITY, MAX_OPACITY, MAX_OPACITY] + + this.pickId = 0 + this.pickPerspectiveShader = pickPerspectiveShader + this.pickOrthoShader = pickOrthoShader + this.pickProjectShader = pickProjectShader + this.points = [] + + this._selectResult = new ScatterPlotPickResult(0, [0,0,0]) + + this.useOrtho = true + this.bounds = [[ Infinity,Infinity,Infinity], + [-Infinity,-Infinity,-Infinity]] + + //Axes projections + this.axesProject = [ true, true, true ] + this.axesBounds = [[-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity]] + + this.highlightId = [1,1,1,1] + this.highlightScale = 2 + + this.clipBounds = [[-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity]] + + this.dirty = true +} + +var proto = PointCloud.prototype + +proto.pickSlots = 1 + +proto.setPickBase = function(pickBase) { + this.pickId = pickBase +} + +proto.isTransparent = function() { + if(this.opacity < MAX_OPACITY) { + return true + } + for(var i=0; i<3; ++i) { + if(this.axesProject[i] && this.projectOpacity[i] < MAX_OPACITY) { + return true + } + } + return false +} + +proto.isOpaque = function() { + if(this.opacity >= MAX_OPACITY) { + return true + } + for(var i=0; i<3; ++i) { + if(this.axesProject[i] && this.projectOpacity[i] >= MAX_OPACITY) { + return true + } + } + return false +} + +var VIEW_SHAPE = [0,0] +var U_VEC = [0,0,0] +var V_VEC = [0,0,0] +var MU_VEC = [0,0,0,1] +var MV_VEC = [0,0,0,1] +var SCRATCH_MATRIX = IDENTITY.slice() +var SCRATCH_VEC = [0,0,0] +var CLIP_BOUNDS = [[0,0,0], [0,0,0]] + +function zeroVec(a) { + a[0] = a[1] = a[2] = 0 + return a +} + +function augment(hg, af) { + hg[0] = af[0] + hg[1] = af[1] + hg[2] = af[2] + hg[3] = 1 + return hg +} + +function setComponent(out, v, i, x) { + out[0] = v[0] + out[1] = v[1] + out[2] = v[2] + out[i] = x + return out +} + +function getClipBounds(bounds) { + var result = CLIP_BOUNDS + for(var i=0; i<2; ++i) { + for(var j=0; j<3; ++j) { + result[i][j] = Math.max(Math.min(bounds[i][j], 1e8), -1e8) + } + } + return result +} + +function drawProject(shader, points, camera) { + var axesProject = points.axesProject + + var gl = points.gl + var uniforms = shader.uniforms + var model = camera.model || IDENTITY + var view = camera.view || IDENTITY + var projection = camera.projection || IDENTITY + var bounds = points.axesBounds + var clipBounds = getClipBounds(points.clipBounds) + + var cubeAxis + if(points.axes && points.axes.lastCubeProps) { + cubeAxis = points.axes.lastCubeProps.axis + } else { + cubeAxis = [1,1,1] + } + + VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth + VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight + + shader.bind() + uniforms.view = view + uniforms.projection = projection + uniforms.screenSize = VIEW_SHAPE + uniforms.highlightId = points.highlightId + uniforms.highlightScale = points.highlightScale + uniforms.clipBounds = clipBounds + uniforms.pickGroup = points.pickId / 255.0 + uniforms.pixelRatio = points.pixelRatio + + for(var i=0; i<3; ++i) { + if(!axesProject[i]) { + continue + } + + uniforms.scale = points.projectScale[i] + uniforms.opacity = points.projectOpacity[i] + + //Project model matrix + var pmodel = SCRATCH_MATRIX + for(var j=0; j<16; ++j) { + pmodel[j] = 0 + } + for(var j=0; j<4; ++j) { + pmodel[5*j] = 1 + } + pmodel[5*i] = 0 + if(cubeAxis[i] < 0) { + pmodel[12+i] = bounds[0][i] + } else { + pmodel[12+i] = bounds[1][i] + } + mat4mult(pmodel, model, pmodel) + uniforms.model = pmodel + + //Compute initial axes + var u = (i+1)%3 + var v = (i+2)%3 + var du = zeroVec(U_VEC) + var dv = zeroVec(V_VEC) + du[u] = 1 + dv[v] = 1 + + //Align orientation relative to viewer + var mdu = project(projection, view, model, augment(MU_VEC, du)) + var mdv = project(projection, view, model, augment(MV_VEC, dv)) + if(Math.abs(mdu[1]) > Math.abs(mdv[1])) { + var tmp = mdu + mdu = mdv + mdv = tmp + tmp = du + du = dv + dv = tmp + var t = u + u = v + v = t + } + if(mdu[0] < 0) { + du[u] = -1 + } + if(mdv[1] > 0) { + dv[v] = -1 + } + var su = 0.0 + var sv = 0.0 + for(var j=0; j<4; ++j) { + su += Math.pow(model[4*u+j], 2) + sv += Math.pow(model[4*v+j], 2) + } + du[u] /= Math.sqrt(su) + dv[v] /= Math.sqrt(sv) + uniforms.axes[0] = du + uniforms.axes[1] = dv + + //Update fragment clip bounds + uniforms.fragClipBounds[0] = setComponent(SCRATCH_VEC, clipBounds[0], i, -1e8) + uniforms.fragClipBounds[1] = setComponent(SCRATCH_VEC, clipBounds[1], i, 1e8) + + points.vao.bind() + + //Draw interior + points.vao.draw(gl.TRIANGLES, points.vertexCount) + + //Draw edges + if(points.lineWidth > 0) { + gl.lineWidth(points.lineWidth) + points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) + } + + points.vao.unbind() + } +} + + +var NEG_INFINITY3 = [-1e8, -1e8, -1e8] +var POS_INFINITY3 = [1e8, 1e8, 1e8] +var CLIP_GROUP = [NEG_INFINITY3, POS_INFINITY3] + +function drawFull(shader, pshader, points, camera, transparent, forceDraw) { + var gl = points.gl + + + + if(transparent === (points.projectOpacity < MAX_OPACITY) || forceDraw) { + drawProject(pshader, points, camera) + } + + if(transparent === (points.opacity < MAX_OPACITY) || forceDraw) { + + shader.bind() + var uniforms = shader.uniforms + + uniforms.model = camera.model || IDENTITY + uniforms.view = camera.view || IDENTITY + uniforms.projection = camera.projection || IDENTITY + + VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth + VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight + uniforms.screenSize = VIEW_SHAPE + + uniforms.highlightId = points.highlightId + uniforms.highlightScale = points.highlightScale + + uniforms.fragClipBounds = CLIP_GROUP + uniforms.clipBounds = points.axes.bounds + + uniforms.opacity = points.opacity + uniforms.pickGroup = points.pickId / 255.0 + + uniforms.pixelRatio = points.pixelRatio + + points.vao.bind() + + //Draw interior + points.vao.draw(gl.TRIANGLES, points.vertexCount) + + //Draw edges + if(points.lineWidth > 0) { + gl.lineWidth(points.lineWidth) + points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) + } + + points.vao.unbind() + } + + +} + +proto.draw = function(camera) { + var shader = this.useOrtho ? this.orthoShader : this.shader + drawFull(shader, this.projectShader, this, camera, false, false) +} + +proto.drawTransparent = function(camera) { + var shader = this.useOrtho ? this.orthoShader : this.shader + drawFull(shader, this.projectShader, this, camera, true, false) +} + +proto.drawPick = function(camera) { + var shader = this.useOrtho ? this.pickOrthoShader : this.pickPerspectiveShader + drawFull(shader, this.pickProjectShader, this, camera, true, true) +} + +proto.pick = function(selected) { + if(!selected) { + return null + } + if(selected.id !== this.pickId) { + return null + } + var x = selected.value[2] + (selected.value[1]<<8) + (selected.value[0]<<16) + if(x >= this.pointCount || x < 0) { + return null + } + + //Unpack result + var coord = this.points[x] + var result = this._selectResult + result.index = x + for(var i=0; i<3; ++i) { + result.position[i] = result.dataCoordinate[i] = coord[i] + } + return result +} + +proto.highlight = function(selection) { + if(!selection) { + this.highlightId = [1,1,1,1] + } else { + var pointId = selection.index + var a0 = pointId &0xff + var a1 = (pointId>>8) &0xff + var a2 = (pointId>>16)&0xff + this.highlightId = [a0/255.0, a1/255.0, a2/255.0, 0] + } +} + +function get_glyphData(glyphs, index, font) { + var str + + // use the data if presented in an array + if(Array.isArray(glyphs)) { + if(index < glyphs.length) { + str = glyphs[index] + } else { + str = undefined + } + } else { + str = glyphs + } + + str = getSimpleString(str) // this would handle undefined cases + + var visible = true + if(isAllBlank(str)) { + str = '▼' // Note: this special character may have minimum number of surfaces + visible = false + } + + var glyph = getGlyph(str, font) + + return { mesh:glyph[0], + lines:glyph[1], + bounds:glyph[2], + visible:visible }; +} + + + +proto.update = function(options) { + + options = options || {} + + if('perspective' in options) { + this.useOrtho = !options.perspective + } + if('orthographic' in options) { + this.useOrtho = !!options.orthographic + } + if('lineWidth' in options) { + this.lineWidth = options.lineWidth + } + if('project' in options) { + if(Array.isArray(options.project)) { + this.axesProject = options.project + } else { + var v = !!options.project + this.axesProject = [v,v,v] + } + } + if('projectScale' in options) { + if(Array.isArray(options.projectScale)) { + this.projectScale = options.projectScale.slice() + } else { + var s = +options.projectScale + this.projectScale = [s,s,s] + } + } + if('projectOpacity' in options) { + if(Array.isArray(options.projectOpacity)) { + this.projectOpacity = options.projectOpacity.slice() + } else { + var s = +options.projectOpacity + this.projectOpacity = [s,s,s] + } + for(var i=0; i<3; ++i) { + this.projectOpacity[i] = fixOpacity(this.projectOpacity[i]); + } + } + if('opacity' in options) { + this.opacity = fixOpacity(options.opacity) + } + + //Set dirty flag + this.dirty = true + + //Create new buffers + var points = options.position + + //Text font + var font = options.font || 'normal' + var alignment = options.alignment || [0,0] + + var alignmentX; + var alignmentY; + if (alignment.length === 2) { + alignmentX = alignment[0] + alignmentY = alignment[1] + } else { + alignmentX = [] + alignmentY = [] + for (var i = 0; i < alignment.length; ++i) { + alignmentX[i] = alignment[i][0] + alignmentY[i] = alignment[i][1] + } + } + + //Bounds + var lowerBound = [ Infinity, Infinity, Infinity] + var upperBound = [-Infinity,-Infinity,-Infinity] + + //Unpack options + var glyphs = options.glyph + var colors = options.color + var sizes = options.size + var angles = options.angle + var lineColors = options.lineColor + + //Picking geometry + var pickCounter = -1 + + //First do pass to compute buffer sizes + var triVertexCount = 0 + var lineVertexCount = 0 + + var numPoints = 0; + + if(points.length) { + + //Count number of points and buffer size + numPoints = points.length + + count_loop: + for(var i=0; i 0) { + var triOffset = 0 + var lineOffset = triVertexCount + var color = [0,0,0,1] + var lineColor = [0,0,0,1] + + var isColorArray = Array.isArray(colors) && Array.isArray(colors[0]) + var isLineColorArray = Array.isArray(lineColors) && Array.isArray(lineColors[0]) + + fill_loop: + for(var i=0; i 0) ? (1 - glyphBounds[0][0]) : + (textOffsetX < 0) ? (1 + glyphBounds[1][0]) : 1; + + textOffsetY *= (textOffsetY > 0) ? (1 - glyphBounds[0][1]) : + (textOffsetY < 0) ? (1 + glyphBounds[1][1]) : 1; + + var textOffset = [textOffsetX, textOffsetY] + + //Write out inner marker + var cells = glyphMesh.cells || [] + var verts = glyphMesh.positions || [] + + for(var j=0; j= 0)) { - continue - } - - var zeroIntercept = screenBox[i] - - dataBox[i] * (screenBox[i+2] - screenBox[i]) / (dataBox[i+2] - dataBox[i]) - - if(i === 0) { - line.drawLine( - zeroIntercept, screenBox[1], zeroIntercept, screenBox[3], - zeroLineWidth[i], - zeroLineColor[i]) - } else { - line.drawLine( - screenBox[0], zeroIntercept, screenBox[2], zeroIntercept, - zeroLineWidth[i], - zeroLineColor[i]) - } - } - } - - //Draw traces - for(var i=0; i=0; --i) { - this.objects[i].dispose() - } - this.objects.length = 0 - for(var i=this.overlays.length-1; i>=0; --i) { - this.overlays[i].dispose() - } - this.overlays.length = 0 - - this.gl = null -} - -proto.addObject = function(object) { - if(this.objects.indexOf(object) < 0) { - this.objects.push(object) - this.setDirty() - } -} - -proto.removeObject = function(object) { - var objects = this.objects - for(var i=0; i 0) { - var base = Math.round(Math.pow(10, y)) - return Math.ceil(x/base) * base - } - return Math.ceil(x) -} - -function defaultBool(x) { - if(typeof x === 'boolean') { - return x - } - return true -} - -function createScene(options) { - options = options || {} - - var stopped = false - - var pixelRatio = options.pixelRatio || parseFloat(window.devicePixelRatio) - - var canvas = options.canvas - if(!canvas) { - canvas = document.createElement('canvas') - if(options.container) { - var container = options.container - container.appendChild(canvas) - } else { - document.body.appendChild(canvas) - } - } - - var gl = options.gl - if(!gl) { - gl = getContext(canvas, - options.glOptions || { - premultipliedAlpha: true, - antialias: true, - preserveDrawingBuffer: isMobile - }) - } - if(!gl) { - throw new Error('webgl not supported') - } - - //Initial bounds - var bounds = options.bounds || [[-10,-10,-10], [10,10,10]] - - //Create selection - var selection = new MouseSelect() - - //Accumulation buffer - var accumBuffer = createFBO(gl, - [gl.drawingBufferWidth, gl.drawingBufferHeight], { - preferFloat: !isMobile - }) - - var accumShader = createShader(gl) - - //Create a camera - var cameraOptions = options.camera || { - eye: [2,0,0], - center: [0,0,0], - up: [0,1,0], - zoomMin: 0.1, - zoomMax: 100, - mode: 'turntable' - } - - //Create axes - var axesOptions = options.axes || {} - var axes = createAxes(gl, axesOptions) - axes.enable = !axesOptions.disable - - //Create spikes - var spikeOptions = options.spikes || {} - var spikes = createSpikes(gl, spikeOptions) - - //Object list is empty initially - var objects = [] - var pickBufferIds = [] - var pickBufferCount = [] - var pickBuffers = [] - - //Dirty flag, skip redraw if scene static - var dirty = true - var pickDirty = true - - var projection = new Array(16) - var model = new Array(16) - - var cameraParams = { - view: null, - projection: projection, - model: model - } - - var pickDirty = true - - var viewShape = [ gl.drawingBufferWidth, gl.drawingBufferHeight ] - - //Create scene object - var scene = { - gl: gl, - contextLost: false, - pixelRatio: options.pixelRatio || parseFloat(window.devicePixelRatio), - canvas: canvas, - selection: selection, - camera: createCamera(canvas, cameraOptions), - axes: axes, - axesPixels: null, - spikes: spikes, - bounds: bounds, - objects: objects, - shape: viewShape, - aspect: options.aspectRatio || [1,1,1], - pickRadius: options.pickRadius || 10, - zNear: options.zNear || 0.01, - zFar: options.zFar || 1000, - fovy: options.fovy || Math.PI/4, - clearColor: options.clearColor || [0,0,0,0], - autoResize: defaultBool(options.autoResize), - autoBounds: defaultBool(options.autoBounds), - autoScale: !!options.autoScale, - autoCenter: defaultBool(options.autoCenter), - clipToBounds: defaultBool(options.clipToBounds), - snapToData: !!options.snapToData, - onselect: options.onselect || null, - onrender: options.onrender || null, - onclick: options.onclick || null, - cameraParams: cameraParams, - oncontextloss: null, - mouseListener: null - } - - var pickShape = [ (gl.drawingBufferWidth/scene.pixelRatio)|0, (gl.drawingBufferHeight/scene.pixelRatio)|0 ] - - function resizeListener() { - if(stopped) { - return - } - if(!scene.autoResize) { - return - } - var parent = canvas.parentNode - var width = 1 - var height = 1 - if(parent && parent !== document.body) { - width = parent.clientWidth - height = parent.clientHeight - } else { - width = window.innerWidth - height = window.innerHeight - } - var nextWidth = Math.ceil(width * scene.pixelRatio)|0 - var nextHeight = Math.ceil(height * scene.pixelRatio)|0 - if(nextWidth !== canvas.width || nextHeight !== canvas.height) { - canvas.width = nextWidth - canvas.height = nextHeight - var style = canvas.style - style.position = style.position || 'absolute' - style.left = '0px' - style.top = '0px' - style.width = width + 'px' - style.height = height + 'px' - dirty = true - } - } - if(scene.autoResize) { - resizeListener() - } - window.addEventListener('resize', resizeListener) - - function reallocPickIds() { - var numObjs = objects.length - var numPick = pickBuffers.length - for(var i=0; i 0 && pickBufferCount[numPick-1] === 0) { - pickBufferCount.pop() - pickBuffers.pop().dispose() - } - } - - scene.update = function(options) { - if(stopped) { - return - } - options = options || {} - dirty = true - pickDirty = true - } - - scene.add = function(obj) { - if(stopped) { - return - } - obj.axes = axes - objects.push(obj) - pickBufferIds.push(-1) - dirty = true - pickDirty = true - reallocPickIds() - } - - scene.remove = function(obj) { - if(stopped) { - return - } - var idx = objects.indexOf(obj) - if(idx < 0) { - return - } - objects.splice(idx, 1) - pickBufferIds.pop() - dirty = true - pickDirty = true - reallocPickIds() - } - - scene.dispose = function() { - if(stopped) { - return - } - - stopped = true - - window.removeEventListener('resize', resizeListener) - canvas.removeEventListener('webglcontextlost', checkContextLoss) - scene.mouseListener.enabled = false - - if(scene.contextLost) { - return - } - - //Destroy objects - axes.dispose() - spikes.dispose() - for(var i=0; i selection.distance) { - continue - } - for(var j=0; j 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]) -exports.pickVertex = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]) -exports.pickFragment = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"]) +exports.boxVertex = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n"]) +exports.boxFragment = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"]) -},{"glslify":392}],279:[function(_dereq_,module,exports){ +},{"glslify":392}],286:[function(_dereq_,module,exports){ 'use strict' var createShader = _dereq_('gl-shader') var createBuffer = _dereq_('gl-buffer') -var pool = _dereq_('typedarray-pool') +var SHADERS = _dereq_('./lib/shaders') -var SHADERS = _dereq_('./lib/shader') +module.exports = createSelectBox -module.exports = createPointcloud2D +function SelectBox(plot, boxBuffer, boxShader) { + this.plot = plot + this.boxBuffer = boxBuffer + this.boxShader = boxShader -function Pointcloud2D(plot, offsetBuffer, pickBuffer, shader, pickShader) { - this.plot = plot - this.offsetBuffer = offsetBuffer - this.pickBuffer = pickBuffer - this.shader = shader - this.pickShader = pickShader - this.sizeMin = 0.5 - this.sizeMinCap = 2 - this.sizeMax = 20 - this.areaRatio = 1.0 - this.pointCount = 0 - this.color = [1, 0, 0, 1] - this.borderColor = [0, 0, 0, 1] - this.blend = false - this.pickOffset = 0 - this.points = null -} + this.enabled = true -var proto = Pointcloud2D.prototype + this.selectBox = [Infinity,Infinity,-Infinity,-Infinity] -proto.dispose = function() { - this.shader.dispose() - this.pickShader.dispose() - this.offsetBuffer.dispose() - this.pickBuffer.dispose() - this.plot.removeObject(this) + this.borderColor = [0,0,0,1] + this.innerFill = false + this.innerColor = [0,0,0,0.25] + this.outerFill = true + this.outerColor = [0,0,0,0.5] + this.borderWidth = 10 } -proto.update = function(options) { - - var i - - options = options || {} +var proto = SelectBox.prototype - function dflt(opt, value) { - if(opt in options) { - return options[opt] - } - return value +proto.draw = function() { + if(!this.enabled) { + return } - this.sizeMin = dflt('sizeMin', 0.5) - // this.sizeMinCap = dflt('sizeMinCap', 2) - this.sizeMax = dflt('sizeMax', 20) - this.color = dflt('color', [1, 0, 0, 1]).slice() - this.areaRatio = dflt('areaRatio', 1) - this.borderColor = dflt('borderColor', [0, 0, 0, 1]).slice() - this.blend = dflt('blend', false) + var plot = this.plot + var selectBox = this.selectBox + var lineWidth = this.borderWidth - //Update point data + var innerFill = this.innerFill + var innerColor = this.innerColor + var outerFill = this.outerFill + var outerColor = this.outerColor + var borderColor = this.borderColor - // Attempt straight-through processing (STP) to avoid allocation and copy - // TODO eventually abstract out STP logic, maybe into `pool` or a layer above - var pointCount = options.positions.length >>> 1 - var dataStraightThrough = options.positions instanceof Float32Array - var idStraightThrough = options.idToIndex instanceof Int32Array && options.idToIndex.length >= pointCount // permit larger to help reuse + var boxes = plot.box + var screenBox = plot.screenBox + var dataBox = plot.dataBox + var viewBox = plot.viewBox + var pixelRatio = plot.pixelRatio - var data = options.positions - var packed = dataStraightThrough ? data : pool.mallocFloat32(data.length) - var packedId = idStraightThrough ? options.idToIndex : pool.mallocInt32(pointCount) + //Map select box into pixel coordinates + var loX = (selectBox[0]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] + var loY = (selectBox[1]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] + var hiX = (selectBox[2]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] + var hiY = (selectBox[3]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] - if(!dataStraightThrough) { - packed.set(data) - } + loX = Math.max(loX, viewBox[0]) + loY = Math.max(loY, viewBox[1]) + hiX = Math.min(hiX, viewBox[2]) + hiY = Math.min(hiY, viewBox[3]) - if(!idStraightThrough) { - packed.set(data) - for(i = 0; i < pointCount; i++) { - packedId[i] = i - } + if(hiX < loX || hiY < loY) { + return } - this.points = data + boxes.bind() - this.offsetBuffer.update(packed) - this.pickBuffer.update(packedId) + //Draw box + var screenWidth = screenBox[2] - screenBox[0] + var screenHeight = screenBox[3] - screenBox[1] - if(!dataStraightThrough) { - pool.free(packed) + if(this.outerFill) { + boxes.drawBox(0, 0, screenWidth, loY, outerColor) + boxes.drawBox(0, loY, loX, hiY, outerColor) + boxes.drawBox(0, hiY, screenWidth, screenHeight, outerColor) + boxes.drawBox(hiX, loY, screenWidth, hiY, outerColor) } - if(!idStraightThrough) { - pool.free(packedId) + if(this.innerFill) { + boxes.drawBox(loX, loY, hiX, hiY, innerColor) } - this.pointCount = pointCount - this.pickOffset = 0 -} + //Draw border + if(lineWidth > 0) { -function count(points, dataBox) { - var visiblePointCountEstimate = 0 - var length = points.length >>> 1 - var i - for(i = 0; i < length; i++) { - var x = points[i * 2] - var y = points[i * 2 + 1] - if(x >= dataBox[0] && x <= dataBox[2] && y >= dataBox[1] && y <= dataBox[3]) - visiblePointCountEstimate++ + //Draw border + var w = lineWidth * pixelRatio + boxes.drawBox(loX-w, loY-w, hiX+w, loY+w, borderColor) + boxes.drawBox(loX-w, hiY-w, hiX+w, hiY+w, borderColor) + boxes.drawBox(loX-w, loY-w, loX+w, hiY+w, borderColor) + boxes.drawBox(hiX-w, loY-w, hiX+w, hiY+w, borderColor) } - return visiblePointCountEstimate } -proto.unifiedDraw = (function() { - var MATRIX = [1, 0, 0, - 0, 1, 0, - 0, 0, 1] - var PICK_VEC4 = [0, 0, 0, 0] -return function(pickOffset) { - var pick = pickOffset !== void(0) - - var shader = pick ? this.pickShader : this.shader - var gl = this.plot.gl - var dataBox = this.plot.dataBox - - if(this.pointCount === 0) { - return pickOffset - } - - var dataX = dataBox[2] - dataBox[0] - var dataY = dataBox[3] - dataBox[1] - - var visiblePointCountEstimate = count(this.points, dataBox) - var basicPointSize = this.plot.pickPixelRatio * Math.max(Math.min(this.sizeMinCap, this.sizeMin), Math.min(this.sizeMax, this.sizeMax / Math.pow(visiblePointCountEstimate, 0.33333))) - - MATRIX[0] = 2.0 / dataX - MATRIX[4] = 2.0 / dataY - MATRIX[6] = -2.0 * dataBox[0] / dataX - 1.0 - MATRIX[7] = -2.0 * dataBox[1] / dataY - 1.0 - - this.offsetBuffer.bind() - - shader.bind() - shader.attributes.position.pointer() - shader.uniforms.matrix = MATRIX - shader.uniforms.color = this.color - shader.uniforms.borderColor = this.borderColor - shader.uniforms.pointCloud = basicPointSize < 5 - shader.uniforms.pointSize = basicPointSize - shader.uniforms.centerFraction = Math.min(1, Math.max(0, Math.sqrt(1 - this.areaRatio))) - - if(pick) { - - PICK_VEC4[0] = ( pickOffset & 0xff) - PICK_VEC4[1] = ((pickOffset >> 8) & 0xff) - PICK_VEC4[2] = ((pickOffset >> 16) & 0xff) - PICK_VEC4[3] = ((pickOffset >> 24) & 0xff) - - this.pickBuffer.bind() - shader.attributes.pickId.pointer(gl.UNSIGNED_BYTE) - shader.uniforms.pickOffset = PICK_VEC4 - this.pickOffset = pickOffset - } - - // Worth switching these off, but we can't make assumptions about other - // renderers, so let's restore it after each draw - var blend = gl.getParameter(gl.BLEND) - var dither = gl.getParameter(gl.DITHER) - - if(blend && !this.blend) - gl.disable(gl.BLEND) - if(dither) - gl.disable(gl.DITHER) - - gl.drawArrays(gl.POINTS, 0, this.pointCount) - - if(blend && !this.blend) - gl.enable(gl.BLEND) - if(dither) - gl.enable(gl.DITHER) +proto.update = function(options) { + options = options || {} - return pickOffset + this.pointCount + this.innerFill = !!options.innerFill + this.outerFill = !!options.outerFill + this.innerColor = (options.innerColor || [0,0,0,0.5]).slice() + this.outerColor = (options.outerColor || [0,0,0,0.5]).slice() + this.borderColor = (options.borderColor || [0,0,0,1]).slice() + this.borderWidth = options.borderWidth || 0 + this.selectBox = (options.selectBox || this.selectBox).slice() } -})() - -proto.draw = proto.unifiedDraw -proto.drawPick = proto.unifiedDraw -proto.pick = function(x, y, value) { - var pickOffset = this.pickOffset - var pointCount = this.pointCount - if(value < pickOffset || value >= pickOffset + pointCount) { - return null - } - var pointId = value - pickOffset - var points = this.points - return { - object: this, - pointId: pointId, - dataCoord: [points[2 * pointId], points[2 * pointId + 1] ] - } +proto.dispose = function() { + this.boxBuffer.dispose() + this.boxShader.dispose() + this.plot.removeOverlay(this) } -function createPointcloud2D(plot, options) { +function createSelectBox(plot, options) { var gl = plot.gl - var buffer = createBuffer(gl) - var pickBuffer = createBuffer(gl) - var shader = createShader(gl, SHADERS.pointVertex, SHADERS.pointFragment) - var pickShader = createShader(gl, SHADERS.pickVertex, SHADERS.pickFragment) - - var result = new Pointcloud2D(plot, buffer, pickBuffer, shader, pickShader) - result.update(options) - - //Register with plot - plot.addObject(result) - - return result + var buffer = createBuffer(gl, [ + 0, 0, + 0, 1, + 1, 0, + 1, 1 ]) + var shader = createShader(gl, SHADERS.boxVertex, SHADERS.boxFragment) + var selectBox = new SelectBox(plot, buffer, shader) + selectBox.update(options) + plot.addOverlay(selectBox) + return selectBox } -},{"./lib/shader":278,"gl-buffer":230,"gl-shader":288,"typedarray-pool":522}],280:[function(_dereq_,module,exports){ -module.exports = slerp +},{"./lib/shaders":285,"gl-buffer":230,"gl-shader":288}],287:[function(_dereq_,module,exports){ +'use strict' + +module.exports = createSelectBuffer + +var createFBO = _dereq_('gl-fbo') +var pool = _dereq_('typedarray-pool') +var ndarray = _dereq_('ndarray') + +var nextPow2 = _dereq_('bit-twiddle').nextPow2 + +var selectRange = _dereq_('cwise/lib/wrapper')({"args":["array",{"offset":[0,0,1],"array":0},{"offset":[0,0,2],"array":0},{"offset":[0,0,3],"array":0},"scalar","scalar","index"],"pre":{"body":"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}","args":[],"thisVars":["this_closestD2","this_closestX","this_closestY"],"localVars":[]},"body":{"body":"{if(_inline_34_arg0_<255||_inline_34_arg1_<255||_inline_34_arg2_<255||_inline_34_arg3_<255){var _inline_34_l=_inline_34_arg4_-_inline_34_arg6_[0],_inline_34_a=_inline_34_arg5_-_inline_34_arg6_[1],_inline_34_f=_inline_34_l*_inline_34_l+_inline_34_a*_inline_34_a;_inline_34_f this.buffer.length) { + pool.free(this.buffer) + var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) + for(var i=0; i oldAttribCount) { + for(i = oldAttribCount; i < newAttribCount; i++) { + this.gl.enableVertexAttribArray(i) + } + } else if(oldAttribCount > newAttribCount) { + for(i = newAttribCount; i < oldAttribCount; i++) { + this.gl.disableVertexAttribArray(i) + } + } + + this.gl.lastAttribCount = newAttribCount + + this.gl.useProgram(this.program) +} + +proto.dispose = function() { + + // disabling vertex attributes so new shader starts with zero + // and it's also useful if all shaders are disposed but the + // gl context is reused for subsequent replotting + var oldAttribCount = this.gl.lastAttribCount + for (var i = 0; i < oldAttribCount; i++) { + this.gl.disableVertexAttribArray(i) + } + this.gl.lastAttribCount = 0 + + if(this._fref) { + this._fref.dispose() + } + if(this._vref) { + this._vref.dispose() + } + this.attributes = + this.types = + this.vertShader = + this.fragShader = + this.program = + this._relink = + this._fref = + this._vref = null +} + +function compareAttributes(a, b) { + if(a.name < b.name) { + return -1 + } + return 1 +} + +//Update export hook for glslify-live +proto.update = function( + vertSource + , fragSource + , uniforms + , attributes) { + + //If only one object passed, assume glslify style output + if(!fragSource || arguments.length === 1) { + var obj = vertSource + vertSource = obj.vertex + fragSource = obj.fragment + uniforms = obj.uniforms + attributes = obj.attributes + } + + var wrapper = this + var gl = wrapper.gl + + //Compile vertex and fragment shaders + var pvref = wrapper._vref + wrapper._vref = shaderCache.shader(gl, gl.VERTEX_SHADER, vertSource) + if(pvref) { + pvref.dispose() + } + wrapper.vertShader = wrapper._vref.shader + var pfref = this._fref + wrapper._fref = shaderCache.shader(gl, gl.FRAGMENT_SHADER, fragSource) + if(pfref) { + pfref.dispose() + } + wrapper.fragShader = wrapper._fref.shader + + //If uniforms/attributes is not specified, use RT reflection + if(!uniforms || !attributes) { + + //Create initial test program + var testProgram = gl.createProgram() + gl.attachShader(testProgram, wrapper.fragShader) + gl.attachShader(testProgram, wrapper.vertShader) + gl.linkProgram(testProgram) + if(!gl.getProgramParameter(testProgram, gl.LINK_STATUS)) { + var errLog = gl.getProgramInfoLog(testProgram) + throw new GLError(errLog, 'Error linking program:' + errLog) + } + + //Load data from runtime + uniforms = uniforms || runtime.uniforms(gl, testProgram) + attributes = attributes || runtime.attributes(gl, testProgram) + + //Release test program + gl.deleteProgram(testProgram) + } + + //Sort attributes lexicographically + // overrides undefined WebGL behavior for attribute locations + attributes = attributes.slice() + attributes.sort(compareAttributes) + + //Convert attribute types, read out locations + var attributeUnpacked = [] + var attributeNames = [] + var attributeLocations = [] + var i + for(i=0; i= 0) { + var size = attr.type.charAt(attr.type.length-1)|0 + var locVector = new Array(size) + for(var j=0; j= 0) { + curLocation += 1 + } + attributeLocations[i] = curLocation + } + } + + //Rebuild program and recompute all uniform locations + var uniformLocations = new Array(uniforms.length) + function relink() { + wrapper.program = shaderCache.program( + gl + , wrapper._vref + , wrapper._fref + , attributeNames + , attributeLocations) -/** - * Performs a spherical linear interpolation between two quat - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @param {Number} t interpolation amount between the two inputs - * @returns {quat} out - */ -function slerp (out, a, b, t) { - // benchmarks: - // http://jsperf.com/quaternion-slerp-implementations + for(var i=0; i 0.000001) { - // standard case (slerp) - omega = Math.acos(cosom) - sinom = Math.sin(omega) - scale0 = Math.sin((1.0 - t) * omega) / sinom - scale1 = Math.sin(t * omega) / sinom - } else { - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - scale0 = 1.0 - t - scale1 = t + //Generate type info + wrapper.types = { + uniforms: makeReflect(uniforms), + attributes: makeReflect(attributes) } - // calculate final values - out[0] = scale0 * ax + scale1 * bx - out[1] = scale0 * ay + scale1 * by - out[2] = scale0 * az + scale1 * bz - out[3] = scale0 * aw + scale1 * bw - return out + //Generate attribute wrappers + wrapper.attributes = createAttributeWrapper( + gl + , wrapper + , attributeUnpacked + , attributeLocations) + + //Generate uniform wrappers + Object.defineProperty(wrapper, 'uniforms', createUniformWrapper( + gl + , wrapper + , uniforms + , uniformLocations)) } -},{}],281:[function(_dereq_,module,exports){ -'use strict'; +//Compiles and links a shader program with the given attribute and vertex list +function createShader( + gl + , vertSource + , fragSource + , uniforms + , attributes) { -module.exports = function(a){ - return (!a && a !== 0) ? '' : a.toString(); + var shader = new Shader(gl) + + shader.update( + vertSource + , fragSource + , uniforms + , attributes) + + return shader } -},{}],282:[function(_dereq_,module,exports){ -"use strict" +module.exports = createShader -var vectorizeText = _dereq_("vectorize-text") +},{"./lib/GLError":289,"./lib/create-attributes":290,"./lib/create-uniforms":291,"./lib/reflect":292,"./lib/runtime-reflect":293,"./lib/shader-cache":294}],289:[function(_dereq_,module,exports){ +function GLError (rawError, shortMessage, longMessage) { + this.shortMessage = shortMessage || '' + this.longMessage = longMessage || '' + this.rawError = rawError || '' + this.message = + 'gl-shader: ' + (shortMessage || rawError || '') + + (longMessage ? '\n'+longMessage : '') + this.stack = (new Error()).stack +} +GLError.prototype = new Error +GLError.prototype.name = 'GLError' +GLError.prototype.constructor = GLError +module.exports = GLError -module.exports = getGlyph +},{}],290:[function(_dereq_,module,exports){ +'use strict' -var GLYPH_CACHE = {} +module.exports = createAttributeWrapper -function getGlyph(symbol, font) { - var fontCache = GLYPH_CACHE[font] - if(!fontCache) { - fontCache = GLYPH_CACHE[font] = {} +var GLError = _dereq_("./GLError") + +function ShaderAttribute( + gl + , wrapper + , index + , locations + , dimension + , constFunc) { + this._gl = gl + this._wrapper = wrapper + this._index = index + this._locations = locations + this._dimension = dimension + this._constFunc = constFunc +} + +var proto = ShaderAttribute.prototype + +proto.pointer = function setAttribPointer( + type + , normalized + , stride + , offset) { + + var self = this + var gl = self._gl + var location = self._locations[self._index] + + gl.vertexAttribPointer( + location + , self._dimension + , type || gl.FLOAT + , !!normalized + , stride || 0 + , offset || 0) + gl.enableVertexAttribArray(location) +} + +proto.set = function(x0, x1, x2, x3) { + return this._constFunc(this._locations[this._index], x0, x1, x2, x3) +} + +Object.defineProperty(proto, 'location', { + get: function() { + return this._locations[this._index] } - if(symbol in fontCache) { - return fontCache[symbol] + , set: function(v) { + if(v !== this._locations[this._index]) { + this._locations[this._index] = v|0 + this._wrapper.program = null + } + return v|0 } +}) - //Get line and triangle meshes for glyph - var lineSymbol = vectorizeText(symbol, { - textAlign: "center", - textBaseline: "middle", - lineHeight: 1.0, - font: font - }) - var triSymbol = vectorizeText(symbol, { - triangles: true, - textAlign: "center", - textBaseline: "middle", - lineHeight: 1.0, - font: font - }) +//Adds a vector attribute to obj +function addVectorAttribute( + gl + , wrapper + , index + , locations + , dimension + , obj + , name) { - //Calculate bounding box - var bounds = [[Infinity,Infinity], [-Infinity,-Infinity]] - for(var i=0; i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) -var orthographicVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) -var projectionVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]) -var drawFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]) +//Create shims for attributes +function createAttributeWrapper( + gl + , wrapper + , attributes + , locations) { -var ATTRIBUTES = [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'glyph', type: 'vec2'}, - {name: 'id', type: 'vec4'} -] + var obj = {} + for(var i=0, n=attributes.length; i= 0) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) + } + addVectorAttribute( + gl + , wrapper + , locs[0] + , locations + , d + , obj + , name) + } else if(type.indexOf('mat') >= 0) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) + } + addMatrixAttribute( + gl + , wrapper + , locs + , locations + , d + , obj + , name) + } else { + throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) + } + break + } } + return obj +} -function createShader(gl, src) { - var shader = createShaderWrapper(gl, src) - var attr = shader.attributes - attr.position.location = 0 - attr.color.location = 1 - attr.glyph.location = 2 - attr.id.location = 3 - return shader +},{"./GLError":289}],291:[function(_dereq_,module,exports){ +'use strict' + +var coallesceUniforms = _dereq_('./reflect') +var GLError = _dereq_("./GLError") + +module.exports = createUniformWrapper + +//Binds a function and returns a value +function identity(x) { + var c = new Function('y', 'return function(){return y}') + return c(x) } -exports.createPerspective = function(gl) { - return createShader(gl, perspective) +function makeVector(length, fill) { + var result = new Array(length) + for(var i=0; i 4) { + throw new GLError('', 'Invalid data type') + } + switch(type.charAt(0)) { + case 'b': + case 'i': + return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' + case 'v': + return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' + default: + throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) + } + } else if(type.indexOf('mat') === 0 && type.length === 4) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) + } + return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' + } else { + throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) + } + break + } + } + + function enumerateIndices(prefix, type) { + if(typeof type !== 'object') { + return [ [prefix, type] ] + } + var indices = [] + for(var id in type) { + var prop = type[id] + var tprefix = prefix + if(parseInt(id) + '' === id) { + tprefix += '[' + id + ']' + } else { + tprefix += '.' + id + } + if(typeof prop === 'object') { + indices.push.apply(indices, enumerateIndices(tprefix, prop)) + } else { + indices.push([tprefix, prop]) + } + } + return indices + } + + function makeSetter(type) { + var code = [ 'return function updateProperty(obj){' ] + var indices = enumerateIndices('', type) + for(var i=0; i 4) { + throw new GLError('', 'Invalid data type') + } + if(type.charAt(0) === 'b') { + return makeVector(d, false) + } + return makeVector(d, 0) + } else if(type.indexOf('mat') === 0 && type.length === 4) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) + } + return makeVector(d*d, 0) + } else { + throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) + } + break + } + } + + function storeProperty(obj, prop, type) { + if(typeof type === 'object') { + var child = processObject(type) + Object.defineProperty(obj, prop, { + get: identity(child), + set: makeSetter(type), + enumerable: true, + configurable: false + }) + } else { + if(locations[type]) { + Object.defineProperty(obj, prop, { + get: makeGetter(type), + set: makeSetter(type), + enumerable: true, + configurable: false + }) + } else { + obj[prop] = defaultValue(uniforms[type].type) + } + } + } + + function processObject(obj) { + var result + if(Array.isArray(obj)) { + result = new Array(obj.length) + for(var i=0; i 1) { + if(!(x[0] in o)) { + o[x[0]] = [] + } + o = o[x[0]] + for(var k=1; k 1) { + for(var j=0; j= 1) { - return true - } - for(var i=0; i<3; ++i) { - if(this.axesProject[i] && this.projectOpacity[i] >= 1) { - return true - } - } return false } -var VIEW_SHAPE = [0,0] -var U_VEC = [0,0,0] -var V_VEC = [0,0,0] -var MU_VEC = [0,0,0,1] -var MV_VEC = [0,0,0,1] -var SCRATCH_MATRIX = IDENTITY.slice() -var SCRATCH_VEC = [0,0,0] -var CLIP_BOUNDS = [[0,0,0], [0,0,0]] +proto.drawTransparent = function(camera) {} -function zeroVec(a) { - a[0] = a[1] = a[2] = 0 - return a -} +proto.draw = function(camera) { + var gl = this.gl + var vao = this.vao + var shader = this.shader -function augment(hg, af) { - hg[0] = af[0] - hg[1] = af[1] - hg[2] = af[2] - hg[3] = 1 - return hg -} + vao.bind() + shader.bind() -function setComponent(out, v, i, x) { - out[0] = v[0] - out[1] = v[1] - out[2] = v[2] - out[i] = x - return out -} + var model = camera.model || identity + var view = camera.view || identity + var projection = camera.projection || identity -function getClipBounds(bounds) { - var result = CLIP_BOUNDS - for(var i=0; i<2; ++i) { - for(var j=0; j<3; ++j) { - result[i][j] = Math.max(Math.min(bounds[i][j], 1e8), -1e8) - } + var axis + if(this.axes) { + axis = this.axes.lastCubeProps.axis } - return result -} - -function drawProject(shader, points, camera, transparent, forceDraw) { - var axesProject = points.axesProject - - var gl = points.gl - var uniforms = shader.uniforms - var model = camera.model || IDENTITY - var view = camera.view || IDENTITY - var projection = camera.projection || IDENTITY - var bounds = points.axesBounds - var clipBounds = getClipBounds(points.clipBounds) - var cubeAxis - if(points.axes && points.axes.lastCubeProps) { - cubeAxis = points.axes.lastCubeProps.axis - } else { - cubeAxis = [1,1,1] + var outerFace = OUTER_FACE + var innerFace = INNER_FACE + for(var i=0; i<3; ++i) { + if(axis && axis[i] < 0) { + outerFace[i] = this.bounds[0][i] + innerFace[i] = this.bounds[1][i] + } else { + outerFace[i] = this.bounds[1][i] + innerFace[i] = this.bounds[0][i] + } } - VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth - VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight + SHAPE[0] = gl.drawingBufferWidth + SHAPE[1] = gl.drawingBufferHeight - shader.bind() - uniforms.view = view - uniforms.projection = projection - uniforms.screenSize = VIEW_SHAPE - uniforms.highlightId = points.highlightId - uniforms.highlightScale = points.highlightScale - uniforms.clipBounds = clipBounds - uniforms.pickGroup = points.pickId / 255.0 - uniforms.pixelRatio = points.pixelRatio + shader.uniforms.model = model + shader.uniforms.view = view + shader.uniforms.projection = projection + shader.uniforms.coordinates = [this.position, outerFace, innerFace] + shader.uniforms.colors = this.colors + shader.uniforms.screenShape = SHAPE for(var i=0; i<3; ++i) { - if(!axesProject[i]) { - continue - } - if((points.projectOpacity[i] < 1) !== transparent) { - continue + shader.uniforms.lineWidth = this.lineWidth[i] * this.pixelRatio + if(this.enabled[i]) { + vao.draw(gl.TRIANGLES, 6, 6*i) + if(this.drawSides[i]) { + vao.draw(gl.TRIANGLES, 12, 18+12*i) + } } + } - uniforms.scale = points.projectScale[i] - uniforms.opacity = points.projectOpacity[i] + vao.unbind() +} - //Project model matrix - var pmodel = SCRATCH_MATRIX - for(var j=0; j<16; ++j) { - pmodel[j] = 0 - } - for(var j=0; j<4; ++j) { - pmodel[5*j] = 1 - } - pmodel[5*i] = 0 - if(cubeAxis[i] < 0) { - pmodel[12+i] = bounds[0][i] - } else { - pmodel[12+i] = bounds[1][i] - } - mat4mult(pmodel, model, pmodel) - uniforms.model = pmodel +proto.update = function(options) { + if(!options) { + return + } + if("bounds" in options) { + this.bounds = options.bounds + } + if("position" in options) { + this.position = options.position + } + if("lineWidth" in options) { + this.lineWidth = options.lineWidth + } + if("colors" in options) { + this.colors = options.colors + } + if("enabled" in options) { + this.enabled = options.enabled + } + if("drawSides" in options) { + this.drawSides = options.drawSides + } +} - //Compute initial axes - var u = (i+1)%3 - var v = (i+2)%3 - var du = zeroVec(U_VEC) - var dv = zeroVec(V_VEC) - du[u] = 1 - dv[v] = 1 +proto.dispose = function() { + this.vao.dispose() + this.buffer.dispose() + this.shader.dispose() +} - //Align orientation relative to viewer - var mdu = project(projection, view, model, augment(MU_VEC, du)) - var mdv = project(projection, view, model, augment(MV_VEC, dv)) - if(Math.abs(mdu[1]) > Math.abs(mdv[1])) { - var tmp = mdu - mdu = mdv - mdv = tmp - tmp = du - du = dv - dv = tmp - var t = u - u = v - v = t - } - if(mdu[0] < 0) { - du[u] = -1 - } - if(mdv[1] > 0) { - dv[v] = -1 - } - var su = 0.0 - var sv = 0.0 - for(var j=0; j<4; ++j) { - su += Math.pow(model[4*u+j], 2) - sv += Math.pow(model[4*v+j], 2) - } - du[u] /= Math.sqrt(su) - dv[v] /= Math.sqrt(sv) - uniforms.axes[0] = du - uniforms.axes[1] = dv - //Update fragment clip bounds - uniforms.fragClipBounds[0] = setComponent(SCRATCH_VEC, clipBounds[0], i, -1e8) - uniforms.fragClipBounds[1] = setComponent(SCRATCH_VEC, clipBounds[1], i, 1e8) - //Draw interior - points.vao.draw(gl.TRIANGLES, points.vertexCount) +function createSpikes(gl, options) { + //Create buffers + var data = [ ] - //Draw edges - if(points.lineWidth > 0) { - gl.lineWidth(points.lineWidth) - points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) - } + function line(x,y,z,i,l,h) { + var row = [x,y,z, 0,0,0, 1] + row[i+3] = 1 + row[i] = l + data.push.apply(data, row) + row[6] = -1 + data.push.apply(data, row) + row[i] = h + data.push.apply(data, row) + data.push.apply(data, row) + row[6] = 1 + data.push.apply(data, row) + row[i] = l + data.push.apply(data, row) } -} - -var NEG_INFINITY3 = [-1e8, -1e8, -1e8] -var POS_INFINITY3 = [1e8, 1e8, 1e8] -var CLIP_GROUP = [NEG_INFINITY3, POS_INFINITY3] + line(0,0,0, 0, 0, 1) + line(0,0,0, 1, 0, 1) + line(0,0,0, 2, 0, 1) -function drawFull(shader, pshader, points, camera, transparent, forceDraw) { - var gl = points.gl + line(1,0,0, 1, -1,1) + line(1,0,0, 2, -1,1) - points.vao.bind() + line(0,1,0, 0, -1,1) + line(0,1,0, 2, -1,1) - if(transparent === (points.opacity < 1) || forceDraw) { - shader.bind() - var uniforms = shader.uniforms + line(0,0,1, 0, -1,1) + line(0,0,1, 1, -1,1) - uniforms.model = camera.model || IDENTITY - uniforms.view = camera.view || IDENTITY - uniforms.projection = camera.projection || IDENTITY + var buffer = createBuffer(gl, data) + var vao = createVAO(gl, [{ + type: gl.FLOAT, + buffer: buffer, + size: 3, + offset: 0, + stride: 28 + }, { + type: gl.FLOAT, + buffer: buffer, + size: 3, + offset: 12, + stride: 28 + }, { + type: gl.FLOAT, + buffer: buffer, + size: 1, + offset: 24, + stride: 28 + }]) + + //Create shader + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.color.location = 1 + shader.attributes.weight.location = 2 - VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth - VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight - uniforms.screenSize = VIEW_SHAPE + //Create spike object + var spikes = new AxisSpikes(gl, buffer, vao, shader) - uniforms.highlightId = points.highlightId - uniforms.highlightScale = points.highlightScale + //Set parameters + spikes.update(options) - uniforms.fragClipBounds = CLIP_GROUP - uniforms.clipBounds = points.axes.bounds + //Return resulting object + return spikes +} - uniforms.opacity = points.opacity - uniforms.pickGroup = points.pickId / 255.0 +},{"./shaders/index":296,"gl-buffer":230,"gl-vao":310}],298:[function(_dereq_,module,exports){ +arguments[4][232][0].apply(exports,arguments) +},{"barycentric":61,"dup":232,"polytope-closest-point/lib/closest_point_2d.js":464}],299:[function(_dereq_,module,exports){ +var glslify = _dereq_('glslify') - uniforms.pixelRatio = points.pixelRatio +var triVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]) +var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) +var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) + +exports.meshShader = { + vertex: triVertSrc, + fragment: triFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'normal', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'}, + {name: 'vector', type: 'vec4'} + ] +} +exports.pickShader = { + vertex: pickVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'id', type: 'vec4'}, + {name: 'vector', type: 'vec4'} + ] +} - //Draw interior - points.vao.draw(gl.TRIANGLES, points.vertexCount) +},{"glslify":392}],300:[function(_dereq_,module,exports){ +'use strict' - //Draw edges - if(points.lineWidth > 0) { - gl.lineWidth(points.lineWidth) - points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) - } - } +var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small +var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - drawProject(pshader, points, camera, transparent, forceDraw) +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var normals = _dereq_('normals') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var ndarray = _dereq_('ndarray') +var colormap = _dereq_('colormap') +var getContour = _dereq_('simplicial-complex-contour') +var pool = _dereq_('typedarray-pool') +var shaders = _dereq_('./shaders') +var closestPoint = _dereq_('./closest-point') + +var meshShader = shaders.meshShader +var pickShader = shaders.pickShader + +var identityMatrix = [ + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +function SimplicialMesh(gl + , texture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) { + + this.gl = gl + this.cells = [] + this.positions = [] + this.intensity = [] + this.texture = texture + this.dirty = true + + this.triShader = triShader + this.lineShader = lineShader + this.pointShader = pointShader + this.pickShader = pickShader + this.pointPickShader = pointPickShader + this.contourShader = contourShader + + this.trianglePositions = trianglePositions + this.triangleVectors = triangleVectors + this.triangleColors = triangleColors + this.triangleNormals = triangleNormals + this.triangleUVs = triangleUVs + this.triangleIds = triangleIds + this.triangleVAO = triangleVAO + this.triangleCount = 0 + + this.lineWidth = 1 + this.edgePositions = edgePositions + this.edgeColors = edgeColors + this.edgeUVs = edgeUVs + this.edgeIds = edgeIds + this.edgeVAO = edgeVAO + this.edgeCount = 0 + + this.pointPositions = pointPositions + this.pointColors = pointColors + this.pointUVs = pointUVs + this.pointSizes = pointSizes + this.pointIds = pointIds + this.pointVAO = pointVAO + this.pointCount = 0 + + this.contourLineWidth = 1 + this.contourPositions = contourPositions + this.contourVAO = contourVAO + this.contourCount = 0 + this.contourColor = [0,0,0] + this.contourEnable = false + + this.pickId = 1 + this.bounds = [ + [ Infinity, Infinity, Infinity], + [-Infinity,-Infinity,-Infinity] ] + this.clipBounds = [ + [-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity] ] + + this.lightPosition = [1e5, 1e5, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + + this.opacity = 1.0 + + this.tubeScale = 1.0 + + this._model = identityMatrix + this._view = identityMatrix + this._projection = identityMatrix + this._resolution = [1,1] +} + +var proto = SimplicialMesh.prototype - points.vao.unbind() +proto.isOpaque = function() { + return this.opacity >= 1 } -proto.draw = function(camera) { - var shader = this.useOrtho ? this.orthoShader : this.shader - drawFull(shader, this.projectShader, this, camera, false, false) +proto.isTransparent = function() { + return this.opacity < 1 } -proto.drawTransparent = function(camera) { - var shader = this.useOrtho ? this.orthoShader : this.shader - drawFull(shader, this.projectShader, this, camera, true, false) -} +proto.pickSlots = 1 -proto.drawPick = function(camera) { - var shader = this.useOrtho ? this.pickOrthoShader : this.pickPerspectiveShader - drawFull(shader, this.pickProjectShader, this, camera, false, true) +proto.setPickBase = function(id) { + this.pickId = id } -proto.pick = function(selected) { - if(!selected) { - return null +function genColormap(param) { + var colors = colormap({ + colormap: param + , nshades: 256 + , format: 'rgba' + }) + + var result = new Uint8Array(256*4) + for(var i=0; i<256; ++i) { + var c = colors[i] + for(var j=0; j<3; ++j) { + result[4*i+j] = c[j] + } + result[4*i+3] = c[3]*255 } - if(selected.id !== this.pickId) { - return null + + return ndarray(result, [256,256,4], [4,0,1]) +} + +function unpackIntensity(cells, numVerts, cellIntensity) { + var result = new Array(numVerts) + for(var i=0; i= this.pointCount || x < 0) { - return null + var numCells = cells.length + for(var i=0; i>8) &0xff - var a2 = (pointId>>16)&0xff - this.highlightId = [a0/255.0, a1/255.0, a2/255.0, 0] + if(!selection || !this.contourEnable) { + this.contourCount = 0 + return } -} - -function get_glyphData(glyphs, index, font) { - var str - - // use the data if presented in an array - if(Array.isArray(glyphs)) { - if(index < glyphs.length) { - str = glyphs[index] - } else { - str = undefined + var level = getContour(this.cells, this.intensity, selection.intensity) + var cells = level.cells + var vertexIds = level.vertexIds + var vertexWeights = level.vertexWeights + var numCells = cells.length + var result = pool.mallocFloat32(2 * 3 * numCells) + var ptr = 0 + for(var i=0; i 0) { - var triOffset = 0 - var lineOffset = triVertexCount - var color = [0,0,0,1] - var lineColor = [0,0,0,1] + pIds.push(i) - var isColorArray = Array.isArray(colors) && Array.isArray(colors[0]) - var isLineColorArray = Array.isArray(lineColors) && Array.isArray(lineColors[0]) + pointCount += 1 + break - fill_loop: - for(var i=0; i 0) { - textOffset[j] *= (1-glyphBounds[0][j]) - } else if(alignment[j] < 0) { - textOffset[j] *= (1+glyphBounds[1][j]) - } - } + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } - //Write out inner marker - var cells = glyphMesh.cells || [] - var verts = glyphMesh.positions || [] + var uniforms = { + model: model, + view: view, + projection: projection, - for(var j=0; j 0) { + var shader = this.triShader + shader.bind() + shader.uniforms = uniforms + + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + if(this.edgeCount > 0 && this.lineWidth > 0) { + var shader = this.lineShader + shader.bind() + shader.uniforms = uniforms + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() } - //Update bounds - this.bounds = [lowerBound, upperBound] + if(this.pointCount > 0) { + var shader = this.pointShader + shader.bind() + shader.uniforms = uniforms - //Save points - this.points = points + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } - //Save number of points - this.pointCount = points.length + if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { + var shader = this.contourShader + shader.bind() + shader.uniforms = uniforms - //Update vertex counts - this.vertexCount = triVertexCount - this.lineVertexCount = lineVertexCount + this.contourVAO.bind() + gl.drawArrays(gl.LINES, 0, this.contourCount) + this.contourVAO.unbind() + } +} - this.pointBuffer.update(positionArray) - this.colorBuffer.update(colorArray) - this.glyphBuffer.update(glyphArray) - //this.idBuffer.update(new Uint32Array(idArray)) - this.idBuffer.update(idArray) +proto.drawPick = function(params) { + params = params || {} - pool.free(positionArray) - pool.free(colorArray) - pool.free(glyphArray) - pool.free(idArray) + var gl = this.gl + + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix + + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } + + //Save camera parameters + this._model = [].slice.call(model) + this._view = [].slice.call(view) + this._projection = [].slice.call(projection) + this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] + + var uniforms = { + model: model, + view: view, + projection: projection, + clipBounds: clipBounds, + + tubeScale: this.tubeScale, + + pickId: this.pickId / 255.0, + } + + var shader = this.pickShader + shader.bind() + shader.uniforms = uniforms + + if(this.triangleCount > 0) { + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0) { + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointPickShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } +} + + +proto.pick = function(pickData) { + if(!pickData) { + return null + } + if(pickData.id !== this.pickId) { + return null + } + + var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] + var cell = this.cells[cellId] + + var pos = this.positions[cell[1]].slice(0, 3) + var intensity = this.intensity[cell[1]] + var velocity = this.vectors[cell[1]].slice(0, 3) + var divergence = this.vectors[cell[1]][3] + + return { + index: cellId, + position: pos, + intensity: intensity, + velocity: velocity, + divergence: divergence, + dataCoordinate: pos + } } + proto.dispose = function() { - //Shaders - this.shader.dispose() - this.orthoShader.dispose() - this.pickPerspectiveShader.dispose() - this.pickOrthoShader.dispose() + this.texture.dispose() + + this.triShader.dispose() + // this.lineShader.dispose() + // this.pointShader.dispose() + this.pickShader.dispose() + // this.pointPickShader.dispose() + + this.triangleVAO.dispose() + this.trianglePositions.dispose() + this.triangleVectors.dispose() + this.triangleColors.dispose() + this.triangleUVs.dispose() + this.triangleNormals.dispose() + this.triangleIds.dispose() + + this.edgeVAO.dispose() + this.edgePositions.dispose() + this.edgeColors.dispose() + this.edgeUVs.dispose() + this.edgeIds.dispose() + + this.pointVAO.dispose() + this.pointPositions.dispose() + this.pointColors.dispose() + this.pointUVs.dispose() + this.pointSizes.dispose() + this.pointIds.dispose() + + this.contourVAO.dispose() + this.contourPositions.dispose() + // this.contourShader.dispose() +} + +function createMeshShader(gl) { + var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.vector.location = 5 + return shader +} - //Vertex array - this.vao.dispose() +function createWireShader(gl) { + var shader = createShader(gl, wireShader.vertex, wireShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + return shader +} - //Buffers - this.pointBuffer.dispose() - this.colorBuffer.dispose() - this.glyphBuffer.dispose() - this.idBuffer.dispose() +function createPointShader(gl) { + var shader = createShader(gl, pointShader.vertex, pointShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.pointSize.location = 4 + return shader } -function createPointCloud(options) { - var gl = options.gl +function createPickShader(gl) { + var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.vector.location = 5 + return shader +} - var shader = shaders.createPerspective(gl) - var orthoShader = shaders.createOrtho(gl) - var projectShader = shaders.createProject(gl) - var pickPerspectiveShader = shaders.createPickPerspective(gl) - var pickOrthoShader = shaders.createPickOrtho(gl) - var pickProjectShader = shaders.createPickProject(gl) +function createPointPickShader(gl) { + var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.pointSize.location = 4 + return shader +} - var pointBuffer = createBuffer(gl) - var colorBuffer = createBuffer(gl) - var glyphBuffer = createBuffer(gl) - var idBuffer = createBuffer(gl) - var vao = createVAO(gl, [ - { - buffer: pointBuffer, - size: 3, - type: gl.FLOAT - }, - { - buffer: colorBuffer, +function createContourShader(gl) { + var shader = createShader(gl, contourShader.vertex, contourShader.fragment) + shader.attributes.position.location = 0 + return shader +} + +function createSimplicialMesh(gl, params) { + if (arguments.length === 1) { + params = gl; + gl = params.gl; + } + + var triShader = params.triShader || createMeshShader(gl) + var lineShader = null; //createWireShader(gl) + var pointShader = null; //createPointShader(gl) + var pickShader = createPickShader(gl) + var pointPickShader = null; //createPointPickShader(gl) + var contourShader = null; //createContourShader(gl) + + var meshTexture = createTexture(gl, + ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) + meshTexture.generateMipmap() + meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR + meshTexture.magFilter = gl.LINEAR + + var trianglePositions = createBuffer(gl) + var triangleVectors = createBuffer(gl) + var triangleColors = createBuffer(gl) + var triangleUVs = createBuffer(gl) + var triangleNormals = createBuffer(gl) + var triangleIds = createBuffer(gl) + var triangleVAO = createVAO(gl, [ + { buffer: trianglePositions, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleIds, + type: gl.UNSIGNED_BYTE, size: 4, - type: gl.FLOAT + normalized: true }, - { - buffer: glyphBuffer, - size: 2, - type: gl.FLOAT + { buffer: triangleColors, + type: gl.FLOAT, + size: 4 }, - { - buffer: idBuffer, + { buffer: triangleUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: triangleNormals, + type: gl.FLOAT, + size: 3 + }, + { buffer: triangleVectors, + type: gl.FLOAT, + size: 4 + } + ]) + + var edgePositions = createBuffer(gl) + var edgeColors = createBuffer(gl) + var edgeUVs = createBuffer(gl) + var edgeIds = createBuffer(gl) + var edgeVAO = createVAO(gl, [ + { buffer: edgePositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: edgeIds, + type: gl.UNSIGNED_BYTE, size: 4, + normalized: true + }, + { buffer: edgeColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: edgeUVs, + type: gl.FLOAT, + size: 2 + } + ]) + + var pointPositions = createBuffer(gl) + var pointColors = createBuffer(gl) + var pointUVs = createBuffer(gl) + var pointSizes = createBuffer(gl) + var pointIds = createBuffer(gl) + var pointVAO = createVAO(gl, [ + { buffer: pointPositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: pointIds, type: gl.UNSIGNED_BYTE, + size: 4, normalized: true + }, + { buffer: pointColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: pointUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: pointSizes, + type: gl.FLOAT, + size: 1 } ]) - var pointCloud = new PointCloud( - gl, - shader, - orthoShader, - projectShader, - pointBuffer, - colorBuffer, - glyphBuffer, - idBuffer, - vao, - pickPerspectiveShader, - pickOrthoShader, - pickProjectShader) + var contourPositions = createBuffer(gl) + var contourVAO = createVAO(gl, [ + { buffer: contourPositions, + type: gl.FLOAT, + size: 3 + }]) + + var mesh = new SimplicialMesh(gl + , meshTexture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) + + mesh.update(params) + + return mesh +} + +module.exports = createSimplicialMesh + +},{"./closest-point":298,"./shaders":299,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"normals":436,"simplicial-complex-contour":494,"typedarray-pool":521}],301:[function(_dereq_,module,exports){ +"use strict"; - pointCloud.update(options) +var vec3 = _dereq_('gl-vec3'); +var vec4 = _dereq_('gl-vec4'); + +var streamToTube = function(stream, maxDivergence, minDistance, maxNorm) { + var points = stream.points; + var velocities = stream.velocities; + var divergences = stream.divergences; + + var p, fwd, r, u, v, up; + up = vec3.set(vec3.create(), 0, 1, 0); + u = vec3.create(); + v = vec3.create(); + var p2 = vec3.create(); + + var verts = []; + var faces = []; + var vectors = []; + var previousVerts = []; + var currentVerts = []; + var intensities = []; + var previousIntensity = 0; + var currentIntensity = 0; + var currentVector = vec4.create(); + var previousVector = vec4.create(); + + var facets = 8; + + for (var i = 0; i < points.length; i++) { + p = points[i]; + fwd = velocities[i]; + r = divergences[i]; + if (maxDivergence === 0) { + r = minDistance * 0.05; + } + currentIntensity = vec3.length(fwd) / maxNorm; + currentVector = vec4.create(); + vec3.copy(currentVector, fwd); + currentVector[3] = r; + + for (var a = 0; a < facets; a++) { + currentVerts[a] = [p[0], p[1], p[2], a]; + } + if (previousVerts.length > 0) { + for (var a = 0; a < facets; a++) { + var a1 = (a+1) % facets; + verts.push( + previousVerts[a], + currentVerts[a], + currentVerts[a1], + + currentVerts[a1], + previousVerts[a1], + previousVerts[a] + ); + vectors.push( + previousVector, + currentVector, + currentVector, + + currentVector, + previousVector, + previousVector + ); + intensities.push( + previousIntensity, + currentIntensity, + currentIntensity, + + currentIntensity, + previousIntensity, + previousIntensity + ); + faces.push( + [verts.length-6, verts.length-5, verts.length-4], + [verts.length-3, verts.length-2, verts.length-1] + ); + } + } + var tmp = previousVerts; + previousVerts = currentVerts; + currentVerts = tmp; + tmp = previousVector; + previousVector = currentVector; + currentVector = tmp; + tmp = previousIntensity; + previousIntensity = currentIntensity; + currentIntensity = tmp; + } + return { + positions: verts, + cells: faces, + vectors: vectors, + vertexIntensity: intensities + }; - return pointCloud -} +}; -},{"./lib/get-simple-string":281,"./lib/glyphs":282,"./lib/shaders":283,"gl-buffer":230,"gl-mat4/multiply":256,"gl-vao":310,"is-string-blank":406,"typedarray-pool":522}],285:[function(_dereq_,module,exports){ -'use strict' - -var glslify = _dereq_('glslify') - -exports.boxVertex = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n"]) -exports.boxFragment = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"]) +var createTubes = function(streams, colormap, maxDivergence, minDistance) { -},{"glslify":392}],286:[function(_dereq_,module,exports){ -'use strict' - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') - -var SHADERS = _dereq_('./lib/shaders') - -module.exports = createSelectBox - -function SelectBox(plot, boxBuffer, boxShader) { - this.plot = plot - this.boxBuffer = boxBuffer - this.boxShader = boxShader - - this.enabled = true - - this.selectBox = [Infinity,Infinity,-Infinity,-Infinity] - - this.borderColor = [0,0,0,1] - this.innerFill = false - this.innerColor = [0,0,0,0.25] - this.outerFill = true - this.outerColor = [0,0,0,0.5] - this.borderWidth = 10 -} - -var proto = SelectBox.prototype - -proto.draw = function() { - if(!this.enabled) { - return - } - - var plot = this.plot - var selectBox = this.selectBox - var lineWidth = this.borderWidth - - var innerFill = this.innerFill - var innerColor = this.innerColor - var outerFill = this.outerFill - var outerColor = this.outerColor - var borderColor = this.borderColor - - var boxes = plot.box - var screenBox = plot.screenBox - var dataBox = plot.dataBox - var viewBox = plot.viewBox - var pixelRatio = plot.pixelRatio - - //Map select box into pixel coordinates - var loX = (selectBox[0]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] - var loY = (selectBox[1]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] - var hiX = (selectBox[2]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] - var hiY = (selectBox[3]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] - - loX = Math.max(loX, viewBox[0]) - loY = Math.max(loY, viewBox[1]) - hiX = Math.min(hiX, viewBox[2]) - hiY = Math.min(hiY, viewBox[3]) - - if(hiX < loX || hiY < loY) { - return - } - - boxes.bind() - - //Draw box - var screenWidth = screenBox[2] - screenBox[0] - var screenHeight = screenBox[3] - screenBox[1] - - if(this.outerFill) { - boxes.drawBox(0, 0, screenWidth, loY, outerColor) - boxes.drawBox(0, loY, loX, hiY, outerColor) - boxes.drawBox(0, hiY, screenWidth, screenHeight, outerColor) - boxes.drawBox(hiX, loY, screenWidth, hiY, outerColor) - } - - if(this.innerFill) { - boxes.drawBox(loX, loY, hiX, hiY, innerColor) - } - - //Draw border - if(lineWidth > 0) { - - //Draw border - var w = lineWidth * pixelRatio - boxes.drawBox(loX-w, loY-w, hiX+w, loY+w, borderColor) - boxes.drawBox(loX-w, hiY-w, hiX+w, hiY+w, borderColor) - boxes.drawBox(loX-w, loY-w, loX+w, hiY+w, borderColor) - boxes.drawBox(hiX-w, loY-w, hiX+w, hiY+w, borderColor) - } -} - -proto.update = function(options) { - options = options || {} - - this.innerFill = !!options.innerFill - this.outerFill = !!options.outerFill - this.innerColor = (options.innerColor || [0,0,0,0.5]).slice() - this.outerColor = (options.outerColor || [0,0,0,0.5]).slice() - this.borderColor = (options.borderColor || [0,0,0,1]).slice() - this.borderWidth = options.borderWidth || 0 - this.selectBox = (options.selectBox || this.selectBox).slice() -} - -proto.dispose = function() { - this.boxBuffer.dispose() - this.boxShader.dispose() - this.plot.removeOverlay(this) -} - -function createSelectBox(plot, options) { - var gl = plot.gl - var buffer = createBuffer(gl, [ - 0, 0, - 0, 1, - 1, 0, - 1, 1 ]) - var shader = createShader(gl, SHADERS.boxVertex, SHADERS.boxFragment) - var selectBox = new SelectBox(plot, buffer, shader) - selectBox.update(options) - plot.addOverlay(selectBox) - return selectBox -} + var maxNorm = 0; + for (var i=0; i maxNorm) { + maxNorm = norm; + } + } + } + + var tubes = streams.map(function(s) { + return streamToTube(s, maxDivergence, minDistance, maxNorm); + }); + + var positions = []; + var cells = []; + var vectors = []; + var vertexIntensity = []; + for (var i=0; i < tubes.length; i++) { + var tube = tubes[i]; + var offset = positions.length; + positions = positions.concat(tube.positions); + vectors = vectors.concat(tube.vectors); + vertexIntensity = vertexIntensity.concat(tube.vertexIntensity); + for (var j=0; j v) return i-1; + } + return i; +}; + +var tmp = vec3.create(); +var tmp2 = vec3.create(); + +var clamp = function(v, min, max) { + return v < min ? min : (v > max ? max : v); +}; + +var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { + var x = point[0]; + var y = point[1]; + var z = point[2]; + + var w = meshgrid[0].length; + var h = meshgrid[1].length; + var d = meshgrid[2].length; + + // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). + // The nearest smaller value index for x is the index x0 such that + // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. + var x0 = findLastSmallerIndex(meshgrid[0], x); + var y0 = findLastSmallerIndex(meshgrid[1], y); + var z0 = findLastSmallerIndex(meshgrid[2], z); + + // Get the nearest larger meshgrid value indices. + // From the above "nearest smaller value", we know that + // meshgrid[0][x0] < x + // meshgrid[0][x0+1] >= x + var x1 = x0 + 1; + var y1 = y0 + 1; + var z1 = z0 + 1; + + if (meshgrid[0][x0] === x) x1 = x0; + if (meshgrid[1][y0] === y) y1 = y0; + if (meshgrid[2][z0] === z) z1 = z0; + + if (clampOverflow) { + x0 = clamp(x0, 0, w-1); + x1 = clamp(x1, 0, w-1); + y0 = clamp(y0, 0, h-1); + y1 = clamp(y1, 0, h-1); + z0 = clamp(z0, 0, d-1); + z1 = clamp(z1, 0, d-1); + } + + // Reject points outside the meshgrid, return a zero vector. + if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { + return vec3.create(); + } + + // Normalize point coordinates to 0..1 scaling factor between x0 and x1. + var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); + var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); + var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); + + if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; + if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; + if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; + + var z0off = z0*w*h; + var z1off = z1*w*h; + + var y0off = y0*w; + var y1off = y1*w; + + var x0off = x0; + var x1off = x1; + + // Sample data array around the (x,y,z) point. + // vZYX = array[zZoff + yYoff + xXoff] + var v000 = array[y0off + z0off + x0off]; + var v001 = array[y0off + z0off + x1off]; + var v010 = array[y1off + z0off + x0off]; + var v011 = array[y1off + z0off + x1off]; + var v100 = array[y0off + z1off + x0off]; + var v101 = array[y0off + z1off + x1off]; + var v110 = array[y1off + z1off + x0off]; + var v111 = array[y1off + z1off + x1off]; + + var result = vec3.create(); + + // Average samples according to distance to point. + vec3.lerp(result, v000, v001, xf); + vec3.lerp(tmp, v010, v011, xf); + vec3.lerp(result, result, tmp, yf); + vec3.lerp(tmp, v100, v101, xf); + vec3.lerp(tmp2, v110, v111, xf); + vec3.lerp(tmp, tmp, tmp2, yf); + vec3.lerp(result, result, tmp, zf); + + return result; +}; + + +var vabs = function(dst, v) { + var x = v[0]; + var y = v[1]; + var z = v[2]; + dst[0] = x >= 0 ? x : -x; + dst[1] = y >= 0 ? y : -y; + dst[2] = z >= 0 ? z : -z; + return dst; +}; + +var findMinSeparation = function(xs) { + var minSeparation = 1/0; + xs.sort(function(a, b) { return a - b; }); + for (var i=1; i= minX && x <= maxX && + y >= minY && y <= maxY && + z >= minZ && z <= maxZ + ); + }; - this._readCallback = function() { - if(!self.gl) { - return - } - fbo.bind() - gl.readPixels(0,0,fbo.shape[0],fbo.shape[1],gl.RGBA,gl.UNSIGNED_BYTE,self.buffer) - self._readTimeout = null - } -} + var boundsSize = vec3.distance(bounds[0], bounds[1]); + var maxStepSize = 10 * boundsSize / maxLength; + var maxStepSizeSq = maxStepSize * maxStepSize; -var proto = SelectBuffer.prototype + var minDistance = 1; + var maxDivergence = 0; // For component-wise divergence vec3.create(); + var tmp = vec3.create(); -Object.defineProperty(proto, 'shape', { - get: function() { - if(!this.gl) { - return [0,0] - } - return this.fbo.shape.slice() - }, - set: function(v) { - if(!this.gl) { - return - } - this.fbo.shape = v - var c = this.fbo.shape[0] - var r = this.fbo.shape[1] - if(r*c*4 > this.buffer.length) { - pool.free(this.buffer) - var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) - for(var i=0; i= 2) { + minDistance = calculateMinPositionDistance(positions); + } -proto.begin = function() { - var gl = this.gl - var shape = this.shape - if(!gl) { - return - } + for (var i = 0; i < positions.length; i++) { + var p = vec3.create(); + vec3.copy(p, positions[i]); - this.fbo.bind() - gl.clearColor(1,1,1,1) - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) -} + var stream = [p]; + var velocities = []; + var v = vectorField.getVelocity(p); + var op = p; + velocities.push(v); -proto.end = function() { - var gl = this.gl - if(!gl) { - return - } - gl.bindFramebuffer(gl.FRAMEBUFFER, null) - if(!this._readTimeout) { - clearTimeout(this._readTimeout) - } - this._readTimeout = setTimeout(this._readCallback, 1) -} + var divergences = []; -proto.query = function(x, y, radius) { - if(!this.gl) { - return null - } + var dv = vectorField.getDivergence(p, v); + var dvLength = vec3.length(dv); + if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { + maxDivergence = dvLength; + } + // In case we need to do component-wise divergence visualization + // vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); + divergences.push(dvLength); + + streams.push({points: stream, velocities: velocities, divergences: divergences}); + + var j = 0; + + while (j < maxLength * 100 && stream.length < maxLength && inBounds(bounds, p)) { + j++; + var np = vec3.clone(v); + var sqLen = vec3.squaredLength(np); + if (sqLen === 0) { + break; + } else if (sqLen > maxStepSizeSq) { + vec3.scale(np, np, maxStepSize / Math.sqrt(sqLen)); + } + vec3.add(np, np, p); + + v = vectorField.getVelocity(np); + + if (vec3.squaredDistance(op, np) - maxStepSizeSq > -0.0001 * maxStepSizeSq) { + stream.push(np); + op = np; + velocities.push(v); + var dv = vectorField.getDivergence(np, v); + var dvLength = vec3.length(dv); + if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { + maxDivergence = dvLength; + } + // In case we need to do component-wise divergence visualization + //vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); + divergences.push(dvLength); + } - var shape = this.fbo.shape.slice() + p = np; + } + } - x = x|0 - y = y|0 - if(typeof radius !== 'number') { - radius = 1.0 - } + // Replace NaNs and Infinities with non-NaN, finite maxDivergence + for (var i=0; i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color — in vertex or in fragment\n vec4 surfaceColor =\n step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) +\n step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]) +var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform vec3 objectOffset;\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n worldCoordinate = objectOffset + dataCoordinate;\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z += zOffset;\n\n gl_Position = clipPosition;\n value = f + objectOffset.z;\n kill = -1.0;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]) +var pickSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]) -proto.dispose = function() { - if(!this.gl) { - return - } - this.fbo.dispose() - pool.free(this.buffer) - this.gl = null - if(this._readTimeout) { - clearTimeout(this._readTimeout) - } +exports.createShader = function (gl) { + var shader = createShader(gl, vertSrc, fragSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'vec3'}, + {name: 'normal', type: 'vec3'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + shader.attributes.normal.location = 2 + return shader } - -function createSelectBuffer(gl, shape) { - var fbo = createFBO(gl, shape) - var buffer = pool.mallocUint8(shape[0]*shape[1]*4) - return new SelectBuffer(gl, fbo, buffer) +exports.createPickShader = function (gl) { + var shader = createShader(gl, vertSrc, pickSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'vec3'}, + {name: 'normal', type: 'vec3'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + shader.attributes.normal.location = 2 + return shader +} +exports.createContourShader = function (gl) { + var shader = createShader(gl, contourVertSrc, fragSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'float'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + return shader +} +exports.createPickContourShader = function (gl) { + var shader = createShader(gl, contourVertSrc, pickSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'float'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + return shader } -},{"bit-twiddle":80,"cwise/lib/wrapper":137,"gl-fbo":239,"ndarray":433,"typedarray-pool":522}],288:[function(_dereq_,module,exports){ +},{"gl-shader":288,"glslify":392}],303:[function(_dereq_,module,exports){ 'use strict' -var createUniformWrapper = _dereq_('./lib/create-uniforms') -var createAttributeWrapper = _dereq_('./lib/create-attributes') -var makeReflect = _dereq_('./lib/reflect') -var shaderCache = _dereq_('./lib/shader-cache') -var runtime = _dereq_('./lib/runtime-reflect') -var GLError = _dereq_("./lib/GLError") +module.exports = createSurfacePlot -//Shader object -function Shader(gl) { - this.gl = gl - this.gl.lastAttribCount = 0 // fixme where else should we store info, safe but not nice on the gl object +var bits = _dereq_('bit-twiddle') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var pool = _dereq_('typedarray-pool') +var colormap = _dereq_('colormap') +var ops = _dereq_('ndarray-ops') +var pack = _dereq_('ndarray-pack') +var ndarray = _dereq_('ndarray') +var surfaceNets = _dereq_('surface-nets') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var bsearch = _dereq_('binary-search-bounds') +var gradient = _dereq_('ndarray-gradient') +var shaders = _dereq_('./lib/shaders') - //Default initialize these to null - this._vref = - this._fref = - this._relink = - this.vertShader = - this.fragShader = - this.program = - this.attributes = - this.uniforms = - this.types = null -} +var createShader = shaders.createShader +var createContourShader = shaders.createContourShader +var createPickShader = shaders.createPickShader +var createPickContourShader = shaders.createPickContourShader -var proto = Shader.prototype +var SURFACE_VERTEX_SIZE = 4 * (4 + 3 + 3) -proto.bind = function() { - if(!this.program) { - this._relink() - } +var IDENTITY = [ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 ] + +var QUAD = [ + [0, 0], + [0, 1], + [1, 0], + [1, 1], + [1, 0], + [0, 1] +] - // ensuring that we have the right number of enabled vertex attributes - var i - var newAttribCount = this.gl.getProgramParameter(this.program, this.gl.ACTIVE_ATTRIBUTES) // more robust approach - //var newAttribCount = Object.keys(this.attributes).length // avoids the probably immaterial introspection slowdown - var oldAttribCount = this.gl.lastAttribCount - if(newAttribCount > oldAttribCount) { - for(i = oldAttribCount; i < newAttribCount; i++) { - this.gl.enableVertexAttribArray(i) - } - } else if(oldAttribCount > newAttribCount) { - for(i = newAttribCount; i < oldAttribCount; i++) { - this.gl.disableVertexAttribArray(i) - } +var PERMUTATIONS = [ + [0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0] +] + +;(function () { + for (var i = 0; i < 3; ++i) { + var p = PERMUTATIONS[i] + var u = (i + 1) % 3 + var v = (i + 2) % 3 + p[u + 0] = 1 + p[v + 3] = 1 + p[i + 6] = 1 } +})() - this.gl.lastAttribCount = newAttribCount +function SurfacePickResult (position, index, uv, level, dataCoordinate) { + this.position = position + this.index = index + this.uv = uv + this.level = level + this.dataCoordinate = dataCoordinate +} - this.gl.useProgram(this.program) +var N_COLORS = 256 + +function genColormap (name) { + var x = pack([colormap({ + colormap: name, + nshades: N_COLORS, + format: 'rgba' + }).map(function (c) { + return [c[0], c[1], c[2], 255 * c[3]] + })]) + ops.divseq(x, 255.0) + return x } -proto.dispose = function() { +function SurfacePlot ( + gl, + shape, + bounds, + shader, + pickShader, + coordinates, + vao, + colorMap, + contourShader, + contourPickShader, + contourBuffer, + contourVAO, + dynamicBuffer, + dynamicVAO, + objectOffset) { + this.gl = gl + this.shape = shape + this.bounds = bounds + this.objectOffset = objectOffset + this.intensityBounds = [] + + this._shader = shader + this._pickShader = pickShader + this._coordinateBuffer = coordinates + this._vao = vao + this._colorMap = colorMap + + this._contourShader = contourShader + this._contourPickShader = contourPickShader + this._contourBuffer = contourBuffer + this._contourVAO = contourVAO + this._contourOffsets = [[], [], []] + this._contourCounts = [[], [], []] + this._vertexCount = 0 + + this._pickResult = new SurfacePickResult([0, 0, 0], [0, 0], [0, 0], [0, 0, 0], [0, 0, 0]) + + this._dynamicBuffer = dynamicBuffer + this._dynamicVAO = dynamicVAO + this._dynamicOffsets = [0, 0, 0] + this._dynamicCounts = [0, 0, 0] + + this.contourWidth = [ 1, 1, 1 ] + this.contourLevels = [[1], [1], [1]] + this.contourTint = [0, 0, 0] + this.contourColor = [[0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1]] + + this.showContour = true + this.showSurface = true + + this.enableHighlight = [true, true, true] + this.highlightColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]] + this.highlightTint = [ 1, 1, 1 ] + this.highlightLevel = [-1, -1, -1] + + // Dynamic contour options + this.enableDynamic = [ true, true, true ] + this.dynamicLevel = [ NaN, NaN, NaN ] + this.dynamicColor = [ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1] ] + this.dynamicTint = [ 1, 1, 1 ] + this.dynamicWidth = [ 1, 1, 1 ] + + this.axesBounds = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]] + this.surfaceProject = [ false, false, false ] + this.contourProject = [[ false, false, false ], + [ false, false, false ], + [ false, false, false ]] + + this.colorBounds = [ false, false ] + + // Store xyz fields, need this for picking + this._field = [ + ndarray(pool.mallocFloat(1024), [0, 0]), + ndarray(pool.mallocFloat(1024), [0, 0]), + ndarray(pool.mallocFloat(1024), [0, 0]) ] + + this.pickId = 1 + this.clipBounds = [[-Infinity, -Infinity, -Infinity], [Infinity, Infinity, Infinity]] + + this.snapToData = false + + this.opacity = 1.0 + + this.lightPosition = [10, 10000, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + this.vertexColor = 0 - // disabling vertex attributes so new shader starts with zero - // and it's also useful if all shaders are disposed but the - // gl context is reused for subsequent replotting - var oldAttribCount = this.gl.lastAttribCount - for (var i = 0; i < oldAttribCount; i++) { - this.gl.disableVertexAttribArray(i) - } - this.gl.lastAttribCount = 0 + this.dirty = true +} - if(this._fref) { - this._fref.dispose() +var proto = SurfacePlot.prototype + +proto.isTransparent = function () { + return this.opacity < 1 +} + +proto.isOpaque = function () { + if (this.opacity >= 1) { + return true } - if(this._vref) { - this._vref.dispose() + for (var i = 0; i < 3; ++i) { + if (this._contourCounts[i].length > 0 || this._dynamicCounts[i] > 0) { + return true + } } - this.attributes = - this.types = - this.vertShader = - this.fragShader = - this.program = - this._relink = - this._fref = - this._vref = null + return false } -function compareAttributes(a, b) { - if(a.name < b.name) { - return -1 - } - return 1 +proto.pickSlots = 1 + +proto.setPickBase = function (id) { + this.pickId = id } -//Update export hook for glslify-live -proto.update = function( - vertSource - , fragSource - , uniforms - , attributes) { +var ZERO_VEC = [0, 0, 0] - //If only one object passed, assume glslify style output - if(!fragSource || arguments.length === 1) { - var obj = vertSource - vertSource = obj.vertex - fragSource = obj.fragment - uniforms = obj.uniforms - attributes = obj.attributes - } +var PROJECT_DATA = { + showSurface: false, + showContour: false, + projections: [IDENTITY.slice(), IDENTITY.slice(), IDENTITY.slice()], + clipBounds: [ + [[0, 0, 0], [0, 0, 0]], + [[0, 0, 0], [0, 0, 0]], + [[0, 0, 0], [0, 0, 0]]] +} - var wrapper = this - var gl = wrapper.gl +function computeProjectionData (camera, obj) { + var i, j, k - //Compile vertex and fragment shaders - var pvref = wrapper._vref - wrapper._vref = shaderCache.shader(gl, gl.VERTEX_SHADER, vertSource) - if(pvref) { - pvref.dispose() - } - wrapper.vertShader = wrapper._vref.shader - var pfref = this._fref - wrapper._fref = shaderCache.shader(gl, gl.FRAGMENT_SHADER, fragSource) - if(pfref) { - pfref.dispose() - } - wrapper.fragShader = wrapper._fref.shader + // Compute cube properties + var cubeAxis = (obj.axes && obj.axes.lastCubeProps.axis) || ZERO_VEC - //If uniforms/attributes is not specified, use RT reflection - if(!uniforms || !attributes) { + var showSurface = obj.showSurface + var showContour = obj.showContour - //Create initial test program - var testProgram = gl.createProgram() - gl.attachShader(testProgram, wrapper.fragShader) - gl.attachShader(testProgram, wrapper.vertShader) - gl.linkProgram(testProgram) - if(!gl.getProgramParameter(testProgram, gl.LINK_STATUS)) { - var errLog = gl.getProgramInfoLog(testProgram) - throw new GLError(errLog, 'Error linking program:' + errLog) + for (i = 0; i < 3; ++i) { + showSurface = showSurface || obj.surfaceProject[i] + for (j = 0; j < 3; ++j) { + showContour = showContour || obj.contourProject[i][j] } + } - //Load data from runtime - uniforms = uniforms || runtime.uniforms(gl, testProgram) - attributes = attributes || runtime.attributes(gl, testProgram) + for (i = 0; i < 3; ++i) { + // Construct projection onto axis + var axisSquish = PROJECT_DATA.projections[i] + for (j = 0; j < 16; ++j) { + axisSquish[j] = 0 + } + for (j = 0; j < 4; ++j) { + axisSquish[5 * j] = 1 + } + axisSquish[5 * i] = 0 + axisSquish[12 + i] = obj.axesBounds[+(cubeAxis[i] > 0)][i] + multiply(axisSquish, camera.model, axisSquish) - //Release test program - gl.deleteProgram(testProgram) - } + var nclipBounds = PROJECT_DATA.clipBounds[i] + for (k = 0; k < 2; ++k) { + for (j = 0; j < 3; ++j) { + nclipBounds[k][j] = camera.clipBounds[k][j] + } + } + nclipBounds[0][i] = -1e8 + nclipBounds[1][i] = 1e8 + } + + PROJECT_DATA.showSurface = showSurface + PROJECT_DATA.showContour = showContour + + return PROJECT_DATA +} + +var UNIFORMS = { + model: IDENTITY, + view: IDENTITY, + projection: IDENTITY, + inverseModel: IDENTITY.slice(), + lowerBound: [0, 0, 0], + upperBound: [0, 0, 0], + colorMap: 0, + clipBounds: [[0, 0, 0], [0, 0, 0]], + height: 0.0, + contourTint: 0, + contourColor: [0, 0, 0, 1], + permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], + zOffset: -1e-4, + objectOffset: [0, 0, 0], + kambient: 1, + kdiffuse: 1, + kspecular: 1, + lightPosition: [1000, 1000, 1000], + eyePosition: [0, 0, 0], + roughness: 1, + fresnel: 1, + opacity: 1, + vertexColor: 0 +} + +var MATRIX_INVERSE = IDENTITY.slice() +var DEFAULT_PERM = [1, 0, 0, 0, 1, 0, 0, 0, 1] + +function drawCore (params, transparent) { + params = params || {} + var gl = this.gl - //Sort attributes lexicographically - // overrides undefined WebGL behavior for attribute locations - attributes = attributes.slice() - attributes.sort(compareAttributes) + gl.disable(gl.CULL_FACE) - //Convert attribute types, read out locations - var attributeUnpacked = [] - var attributeNames = [] - var attributeLocations = [] - var i - for(i=0; i= 0) { - var size = attr.type.charAt(attr.type.length-1)|0 - var locVector = new Array(size) - for(var j=0; j= 0) { - curLocation += 1 - } - attributeLocations[i] = curLocation + var uniforms = UNIFORMS + uniforms.model = params.model || IDENTITY + uniforms.view = params.view || IDENTITY + uniforms.projection = params.projection || IDENTITY + uniforms.lowerBound = [this.bounds[0][0], this.bounds[0][1], this.colorBounds[0] || this.bounds[0][2]] + uniforms.upperBound = [this.bounds[1][0], this.bounds[1][1], this.colorBounds[1] || this.bounds[1][2]] + uniforms.objectOffset = this.objectOffset + uniforms.contourColor = this.contourColor[0] + + uniforms.inverseModel = invert(uniforms.inverseModel, uniforms.model) + + for (var i = 0; i < 2; ++i) { + var clipClamped = uniforms.clipBounds[i] + for (var j = 0; j < 3; ++j) { + clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) } } - //Rebuild program and recompute all uniform locations - var uniformLocations = new Array(uniforms.length) - function relink() { - wrapper.program = shaderCache.program( - gl - , wrapper._vref - , wrapper._fref - , attributeNames - , attributeLocations) + uniforms.kambient = this.ambientLight + uniforms.kdiffuse = this.diffuseLight + uniforms.kspecular = this.specularLight - for(var i=0; i= 0) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) - } - addVectorAttribute( - gl - , wrapper - , locs[0] - , locations - , d - , obj - , name) - } else if(type.indexOf('mat') >= 0) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) - } - addMatrixAttribute( - gl - , wrapper - , locs - , locations - , d - , obj - , name) - } else { - throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) - } - break + // Compute uv coordinate + var x = shape[0] * (selection.value[0] + (selection.value[2] >> 4) / 16.0) / 255.0 + var ix = Math.floor(x) + var fx = x - ix + + var y = shape[1] * (selection.value[1] + (selection.value[2] & 15) / 16.0) / 255.0 + var iy = Math.floor(y) + var fy = y - iy + + ix += 1 + iy += 1 + + // Compute xyz coordinate + var pos = result.position + pos[0] = pos[1] = pos[2] = 0 + for (var dx = 0; dx < 2; ++dx) { + var s = dx ? fx : 1.0 - fx + for (var dy = 0; dy < 2; ++dy) { + var t = dy ? fy : 1.0 - fy + + var r = ix + dx + var c = iy + dy + var w = s * t + + for (var i = 0; i < 3; ++i) { + pos[i] += this._field[i].get(r, c) * w + } } } - return obj -} - -},{"./GLError":289}],291:[function(_dereq_,module,exports){ -'use strict' -var coallesceUniforms = _dereq_('./reflect') -var GLError = _dereq_("./GLError") + // Find closest level + var levelIndex = this._pickResult.level + for (var j = 0; j < 3; ++j) { + levelIndex[j] = bsearch.le(this.contourLevels[j], pos[j]) + if (levelIndex[j] < 0) { + if (this.contourLevels[j].length > 0) { + levelIndex[j] = 0 + } + } else if (levelIndex[j] < this.contourLevels[j].length - 1) { + var a = this.contourLevels[j][levelIndex[j]] + var b = this.contourLevels[j][levelIndex[j] + 1] + if (Math.abs(a - pos[j]) > Math.abs(b - pos[j])) { + levelIndex[j] += 1 + } + } + } -module.exports = createUniformWrapper + result.index[0] = fx < 0.5 ? ix : (ix + 1) + result.index[1] = fy < 0.5 ? iy : (iy + 1) -//Binds a function and returns a value -function identity(x) { - var c = new Function('y', 'return function(){return y}') - return c(x) -} + result.uv[0] = x / shape[0] + result.uv[1] = y / shape[1] -function makeVector(length, fill) { - var result = new Array(length) - for(var i=0; i 4) { - throw new GLError('', 'Invalid data type') - } - switch(type.charAt(0)) { - case 'b': - case 'i': - return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' - case 'v': - return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' - default: - throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) - } - } else if(type.indexOf('mat') === 0 && type.length === 4) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) - } - return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' - } else { - throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) - } - break - } + // Edges + ops.assign(dstField.lo(1).hi(srcShape[0], 1), + srcField.hi(srcShape[0], 1)) + ops.assign(dstField.lo(1, dstShape[1] - 1).hi(srcShape[0], 1), + srcField.lo(0, srcShape[1] - 1).hi(srcShape[0], 1)) + ops.assign(dstField.lo(0, 1).hi(1, srcShape[1]), + srcField.hi(1)) + ops.assign(dstField.lo(dstShape[0] - 1, 1).hi(1, srcShape[1]), + srcField.lo(srcShape[0] - 1)) + // Corners + dstField.set(0, 0, srcField.get(0, 0)) + dstField.set(0, dstShape[1] - 1, srcField.get(0, srcShape[1] - 1)) + dstField.set(dstShape[0] - 1, 0, srcField.get(srcShape[0] - 1, 0)) + dstField.set(dstShape[0] - 1, dstShape[1] - 1, srcField.get(srcShape[0] - 1, srcShape[1] - 1)) +} + +function handleArray (param, ctor) { + if (Array.isArray(param)) { + return [ ctor(param[0]), ctor(param[1]), ctor(param[2]) ] } + return [ ctor(param), ctor(param), ctor(param) ] +} - function enumerateIndices(prefix, type) { - if(typeof type !== 'object') { - return [ [prefix, type] ] - } - var indices = [] - for(var id in type) { - var prop = type[id] - var tprefix = prefix - if(parseInt(id) + '' === id) { - tprefix += '[' + id + ']' - } else { - tprefix += '.' + id - } - if(typeof prop === 'object') { - indices.push.apply(indices, enumerateIndices(tprefix, prop)) - } else { - indices.push([tprefix, prop]) - } +function toColor (x) { + if (Array.isArray(x)) { + if (x.length === 3) { + return [x[0], x[1], x[2], 1] } - return indices + return [x[0], x[1], x[2], x[3]] } + return [0, 0, 0, 1] +} - function makeSetter(type) { - var code = [ 'return function updateProperty(obj){' ] - var indices = enumerateIndices('', type) - for(var i=0; i 4) { - throw new GLError('', 'Invalid data type') - } - if(type.charAt(0) === 'b') { - return makeVector(d, false) - } - return makeVector(d, 0) - } else if(type.indexOf('mat') === 0 && type.length === 4) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) - } - return makeVector(d*d, 0) - } else { - throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) - } - break - } +proto.update = function (params) { + params = params || {} + + this.objectOffset = params.objectOffset || this.objectOffset + + this.dirty = true + + if ('contourWidth' in params) { + this.contourWidth = handleArray(params.contourWidth, Number) + } + if ('showContour' in params) { + this.showContour = handleArray(params.showContour, Boolean) + } + if ('showSurface' in params) { + this.showSurface = !!params.showSurface + } + if ('contourTint' in params) { + this.contourTint = handleArray(params.contourTint, Boolean) + } + if ('contourColor' in params) { + this.contourColor = handleColor(params.contourColor) + } + if ('contourProject' in params) { + this.contourProject = handleArray(params.contourProject, function (x) { + return handleArray(x, Boolean) + }) + } + if ('surfaceProject' in params) { + this.surfaceProject = params.surfaceProject + } + if ('dynamicColor' in params) { + this.dynamicColor = handleColor(params.dynamicColor) + } + if ('dynamicTint' in params) { + this.dynamicTint = handleArray(params.dynamicTint, Number) + } + if ('dynamicWidth' in params) { + this.dynamicWidth = handleArray(params.dynamicWidth, Number) + } + if ('opacity' in params) { + this.opacity = params.opacity + } + if ('colorBounds' in params) { + this.colorBounds = params.colorBounds + } + if ('vertexColor' in params) { + this.vertexColor = params.vertexColor ? 1 : 0; } - function storeProperty(obj, prop, type) { - if(typeof type === 'object') { - var child = processObject(type) - Object.defineProperty(obj, prop, { - get: identity(child), - set: makeSetter(type), - enumerable: true, - configurable: false - }) + var field = params.field || (params.coords && params.coords[2]) || null + var levelsChanged = false + + if (!field) { + if (this._field[2].shape[0] || this._field[2].shape[2]) { + field = this._field[2].lo(1, 1).hi(this._field[2].shape[0] - 2, this._field[2].shape[1] - 2) } else { - if(locations[type]) { - Object.defineProperty(obj, prop, { - get: makeGetter(type), - set: makeSetter(type), - enumerable: true, - configurable: false - }) - } else { - obj[prop] = defaultValue(uniforms[type].type) - } + field = this._field[2].hi(0, 0) } } - function processObject(obj) { - var result - if(Array.isArray(obj)) { - result = new Array(obj.length) - for(var i=0; i this._field[2].data.length) { + pool.freeFloat(this._field[2].data) + this._field[2].data = pool.mallocFloat(bits.nextPow2(fsize)) } - return result - } - //Return data - var coallesced = coallesceUniforms(uniforms, true) - return { - get: identity(processObject(coallesced)), - set: makeSetter(coallesced), - enumerable: true, - configurable: true - } -} + // Pad field + this._field[2] = ndarray(this._field[2].data, [field.shape[0] + 2, field.shape[1] + 2]) + this.padField(this._field[2], field) -},{"./GLError":289,"./reflect":292}],292:[function(_dereq_,module,exports){ -'use strict' + // Save shape of field + this.shape = field.shape.slice() + var shape = this.shape -module.exports = makeReflectTypes + // Resize coordinate fields if necessary + for (var i = 0; i < 2; ++i) { + if (this._field[2].size > this._field[i].data.length) { + pool.freeFloat(this._field[i].data) + this._field[i].data = pool.mallocFloat(this._field[2].size) + } + this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2]) + } -//Construct type info for reflection. -// -// This iterates over the flattened list of uniform type values and smashes them into a JSON object. -// -// The leaves of the resulting object are either indices or type strings representing primitive glslify types -function makeReflectTypes(uniforms, useIndex) { - var obj = {} - for(var i=0; i 1) { - if(!(x[0] in o)) { - o[x[0]] = [] - } - o = o[x[0]] - for(var k=1; k 1) { - for(var j=0; j 0) { + // If we already added first edge, pop off verts + for (var l = 0; l < 5; ++l) { + contourVerts.pop() + } + vertexCount -= 1 + } + continue edge_loop + } + } + } + levelCounts.push(vertexCount) + } + + // Store results + this._contourOffsets[dim] = levelOffsets + this._contourCounts[dim] = levelCounts -function compileShader(gl, type, src) { - var shader = gl.createShader(type) - gl.shaderSource(shader, src) - gl.compileShader(shader) - if(!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - var errLog = gl.getShaderInfoLog(shader) - try { - var fmt = formatCompilerError(errLog, src, type); - } catch (e){ - console.warn('Failed to format compiler error: ' + e); - throw new GLError(errLog, 'Error compiling shader:\n' + errLog) } - throw new GLError(errLog, fmt.short, fmt.long) - } - return shader -} -proto.getShaderReference = function(type, src) { - var gl = this.gl - var shaders = this.shaders[(type === gl.FRAGMENT_SHADER)|0] - var shader = shaders[src] - if(!shader || !gl.isShader(shader.shader)) { - var shaderObj = compileShader(gl, type, src) - shader = shaders[src] = new ShaderReference( - SHADER_COUNTER++, - src, - type, - shaderObj, - [], - 1, - this) - } else { - shader.count += 1 + var floatBuffer = pool.mallocFloat(contourVerts.length) + for (i = 0; i < contourVerts.length; ++i) { + floatBuffer[i] = contourVerts[i] + } + this._contourBuffer.update(floatBuffer) + pool.freeFloat(floatBuffer) } - return shader -} -function linkProgram(gl, vshader, fshader, attribs, locations) { - var program = gl.createProgram() - gl.attachShader(program, vshader) - gl.attachShader(program, fshader) - for(var i=0; i 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]) -var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) -var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) - -exports.meshShader = { - vertex: triVertSrc, - fragment: triFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'normal', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'}, - {name: 'vector', type: 'vec4'} - ] -} -exports.pickShader = { - vertex: pickVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'id', type: 'vec4'}, - {name: 'vector', type: 'vec4'} - ] -} + var dynamicBuffer = createBuffer(gl) + var dynamicVAO = createVAO(gl, [ + { + buffer: dynamicBuffer, + size: 2, + type: gl.FLOAT + }]) -},{"glslify":392}],300:[function(_dereq_,module,exports){ -'use strict' - -var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small -var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var normals = _dereq_('normals') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var ndarray = _dereq_('ndarray') -var colormap = _dereq_('colormap') -var getContour = _dereq_('simplicial-complex-contour') -var pool = _dereq_('typedarray-pool') -var shaders = _dereq_('./shaders') -var closestPoint = _dereq_('./closest-point') - -var meshShader = shaders.meshShader -var pickShader = shaders.pickShader - -var identityMatrix = [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - -function SimplicialMesh(gl - , texture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) { - - this.gl = gl - this.cells = [] - this.positions = [] - this.intensity = [] - this.texture = texture - this.dirty = true - - this.triShader = triShader - this.lineShader = lineShader - this.pointShader = pointShader - this.pickShader = pickShader - this.pointPickShader = pointPickShader - this.contourShader = contourShader - - this.trianglePositions = trianglePositions - this.triangleVectors = triangleVectors - this.triangleColors = triangleColors - this.triangleNormals = triangleNormals - this.triangleUVs = triangleUVs - this.triangleIds = triangleIds - this.triangleVAO = triangleVAO - this.triangleCount = 0 - - this.lineWidth = 1 - this.edgePositions = edgePositions - this.edgeColors = edgeColors - this.edgeUVs = edgeUVs - this.edgeIds = edgeIds - this.edgeVAO = edgeVAO - this.edgeCount = 0 - - this.pointPositions = pointPositions - this.pointColors = pointColors - this.pointUVs = pointUVs - this.pointSizes = pointSizes - this.pointIds = pointIds - this.pointVAO = pointVAO - this.pointCount = 0 - - this.contourLineWidth = 1 - this.contourPositions = contourPositions - this.contourVAO = contourVAO - this.contourCount = 0 - this.contourColor = [0,0,0] - this.contourEnable = false - - this.pickId = 1 - this.bounds = [ - [ Infinity, Infinity, Infinity], - [-Infinity,-Infinity,-Infinity] ] - this.clipBounds = [ - [-Infinity,-Infinity,-Infinity], - [ Infinity, Infinity, Infinity] ] - - this.lightPosition = [1e5, 1e5, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - - this.opacity = 1.0 - - this.tubeScale = 1.0 - - this._model = identityMatrix - this._view = identityMatrix - this._projection = identityMatrix - this._resolution = [1,1] -} - -var proto = SimplicialMesh.prototype - -proto.isOpaque = function() { - return this.opacity >= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.pickSlots = 1 - -proto.setPickBase = function(id) { - this.pickId = id -} - -function genColormap(param) { - var colors = colormap({ - colormap: param - , nshades: 256 - , format: 'rgba' - }) - - var result = new Uint8Array(256*4) - for(var i=0; i<256; ++i) { - var c = colors[i] - for(var j=0; j<3; ++j) { - result[4*i+j] = c[j] - } - result[4*i+3] = c[3]*255 - } - - return ndarray(result, [256,256,4], [4,0,1]) -} - -function unpackIntensity(cells, numVerts, cellIntensity) { - var result = new Array(numVerts) - for(var i=0; i 0) { - var shader = this.triShader - shader.bind() - shader.uniforms = uniforms - - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0 && this.lineWidth > 0) { - var shader = this.lineShader - shader.bind() - shader.uniforms = uniforms - - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } - - if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { - var shader = this.contourShader - shader.bind() - shader.uniforms = uniforms - - this.contourVAO.bind() - gl.drawArrays(gl.LINES, 0, this.contourCount) - this.contourVAO.unbind() - } -} - -proto.drawPick = function(params) { - params = params || {} - - var gl = this.gl - - var model = params.model || identityMatrix - var view = params.view || identityMatrix - var projection = params.projection || identityMatrix - - var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] - for(var i=0; i<3; ++i) { - clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) - clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) - } - - //Save camera parameters - this._model = [].slice.call(model) - this._view = [].slice.call(view) - this._projection = [].slice.call(projection) - this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - - var uniforms = { - model: model, - view: view, - projection: projection, - clipBounds: clipBounds, - - tubeScale: this.tubeScale, - - pickId: this.pickId / 255.0, - } - - var shader = this.pickShader - shader.bind() - shader.uniforms = uniforms - - if(this.triangleCount > 0) { - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0) { - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointPickShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } -} - - -proto.pick = function(pickData) { - if(!pickData) { - return null - } - if(pickData.id !== this.pickId) { - return null - } - - var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] - var cell = this.cells[cellId] - - var pos = this.positions[cell[1]].slice(0, 3) - var intensity = this.intensity[cell[1]] - var velocity = this.vectors[cell[1]].slice(0, 3) - var divergence = this.vectors[cell[1]][3] - - return { - index: cellId, - position: pos, - intensity: intensity, - velocity: velocity, - divergence: divergence, - dataCoordinate: pos - } -} - - -proto.dispose = function() { - this.texture.dispose() - - this.triShader.dispose() - // this.lineShader.dispose() - // this.pointShader.dispose() - this.pickShader.dispose() - // this.pointPickShader.dispose() - - this.triangleVAO.dispose() - this.trianglePositions.dispose() - this.triangleVectors.dispose() - this.triangleColors.dispose() - this.triangleUVs.dispose() - this.triangleNormals.dispose() - this.triangleIds.dispose() - - this.edgeVAO.dispose() - this.edgePositions.dispose() - this.edgeColors.dispose() - this.edgeUVs.dispose() - this.edgeIds.dispose() - - this.pointVAO.dispose() - this.pointPositions.dispose() - this.pointColors.dispose() - this.pointUVs.dispose() - this.pointSizes.dispose() - this.pointIds.dispose() - - this.contourVAO.dispose() - this.contourPositions.dispose() - // this.contourShader.dispose() -} - -function createMeshShader(gl) { - var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.vector.location = 5 - return shader -} - -function createWireShader(gl) { - var shader = createShader(gl, wireShader.vertex, wireShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - return shader -} - -function createPointShader(gl) { - var shader = createShader(gl, pointShader.vertex, pointShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.pointSize.location = 4 - return shader -} - -function createPickShader(gl) { - var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.vector.location = 5 - return shader -} - -function createPointPickShader(gl) { - var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.pointSize.location = 4 - return shader -} - -function createContourShader(gl) { - var shader = createShader(gl, contourShader.vertex, contourShader.fragment) - shader.attributes.position.location = 0 - return shader -} - -function createSimplicialMesh(gl, params) { - if (arguments.length === 1) { - params = gl; - gl = params.gl; - } - - var triShader = params.triShader || createMeshShader(gl) - var lineShader = null; //createWireShader(gl) - var pointShader = null; //createPointShader(gl) - var pickShader = createPickShader(gl) - var pointPickShader = null; //createPointPickShader(gl) - var contourShader = null; //createContourShader(gl) - - var meshTexture = createTexture(gl, - ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) - meshTexture.generateMipmap() - meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR - meshTexture.magFilter = gl.LINEAR - - var trianglePositions = createBuffer(gl) - var triangleVectors = createBuffer(gl) - var triangleColors = createBuffer(gl) - var triangleUVs = createBuffer(gl) - var triangleNormals = createBuffer(gl) - var triangleIds = createBuffer(gl) - var triangleVAO = createVAO(gl, [ - { buffer: trianglePositions, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: triangleColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: triangleNormals, - type: gl.FLOAT, - size: 3 - }, - { buffer: triangleVectors, - type: gl.FLOAT, - size: 4 - } - ]) - - var edgePositions = createBuffer(gl) - var edgeColors = createBuffer(gl) - var edgeUVs = createBuffer(gl) - var edgeIds = createBuffer(gl) - var edgeVAO = createVAO(gl, [ - { buffer: edgePositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: edgeIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: edgeColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: edgeUVs, - type: gl.FLOAT, - size: 2 - } - ]) - - var pointPositions = createBuffer(gl) - var pointColors = createBuffer(gl) - var pointUVs = createBuffer(gl) - var pointSizes = createBuffer(gl) - var pointIds = createBuffer(gl) - var pointVAO = createVAO(gl, [ - { buffer: pointPositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: pointIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: pointColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: pointUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: pointSizes, - type: gl.FLOAT, - size: 1 - } - ]) - - var contourPositions = createBuffer(gl) - var contourVAO = createVAO(gl, [ - { buffer: contourPositions, - type: gl.FLOAT, - size: 3 - }]) - - var mesh = new SimplicialMesh(gl - , meshTexture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) - - mesh.update(params) - - return mesh -} - -module.exports = createSimplicialMesh - -},{"./closest-point":298,"./shaders":299,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"normals":436,"simplicial-complex-contour":494,"typedarray-pool":522}],301:[function(_dereq_,module,exports){ -"use strict"; - -var vec3 = _dereq_('gl-vec3'); -var vec4 = _dereq_('gl-vec4'); - -var streamToTube = function(stream, maxDivergence, minDistance, maxNorm) { - var points = stream.points; - var velocities = stream.velocities; - var divergences = stream.divergences; - - var p, fwd, r, u, v, up; - up = vec3.set(vec3.create(), 0, 1, 0); - u = vec3.create(); - v = vec3.create(); - var p2 = vec3.create(); - - var verts = []; - var faces = []; - var vectors = []; - var previousVerts = []; - var currentVerts = []; - var intensities = []; - var previousIntensity = 0; - var currentIntensity = 0; - var currentVector = vec4.create(); - var previousVector = vec4.create(); - - var facets = 8; - - for (var i = 0; i < points.length; i++) { - p = points[i]; - fwd = velocities[i]; - r = divergences[i]; - if (maxDivergence === 0) { - r = minDistance * 0.05; - } - currentIntensity = vec3.length(fwd) / maxNorm; - currentVector = vec4.create(); - vec3.copy(currentVector, fwd); - currentVector[3] = r; - - for (var a = 0; a < facets; a++) { - currentVerts[a] = [p[0], p[1], p[2], a]; - } - if (previousVerts.length > 0) { - for (var a = 0; a < facets; a++) { - var a1 = (a+1) % facets; - verts.push( - previousVerts[a], - currentVerts[a], - currentVerts[a1], - - currentVerts[a1], - previousVerts[a1], - previousVerts[a] - ); - vectors.push( - previousVector, - currentVector, - currentVector, - - currentVector, - previousVector, - previousVector - ); - intensities.push( - previousIntensity, - currentIntensity, - currentIntensity, - - currentIntensity, - previousIntensity, - previousIntensity - ); - faces.push( - [verts.length-6, verts.length-5, verts.length-4], - [verts.length-3, verts.length-2, verts.length-1] - ); - } - } - var tmp = previousVerts; - previousVerts = currentVerts; - currentVerts = tmp; - tmp = previousVector; - previousVector = currentVector; - currentVector = tmp; - tmp = previousIntensity; - previousIntensity = currentIntensity; - currentIntensity = tmp; - } - return { - positions: verts, - cells: faces, - vectors: vectors, - vertexIntensity: intensities - }; - -}; - -var createTubes = function(streams, colormap, maxDivergence, minDistance) { - - var maxNorm = 0; - for (var i=0; i maxNorm) { - maxNorm = norm; - } - } - } - - var tubes = streams.map(function(s) { - return streamToTube(s, maxDivergence, minDistance, maxNorm); - }); - - var positions = []; - var cells = []; - var vectors = []; - var vertexIntensity = []; - for (var i=0; i < tubes.length; i++) { - var tube = tubes[i]; - var offset = positions.length; - positions = positions.concat(tube.positions); - vectors = vectors.concat(tube.vectors); - vertexIntensity = vertexIntensity.concat(tube.vertexIntensity); - for (var j=0; j v) return i-1; - } - return i; -}; - -var tmp = vec3.create(); -var tmp2 = vec3.create(); - -var clamp = function(v, min, max) { - return v < min ? min : (v > max ? max : v); -}; - -var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { - var x = point[0]; - var y = point[1]; - var z = point[2]; - - var w = meshgrid[0].length; - var h = meshgrid[1].length; - var d = meshgrid[2].length; - - // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). - // The nearest smaller value index for x is the index x0 such that - // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. - var x0 = findLastSmallerIndex(meshgrid[0], x); - var y0 = findLastSmallerIndex(meshgrid[1], y); - var z0 = findLastSmallerIndex(meshgrid[2], z); - - // Get the nearest larger meshgrid value indices. - // From the above "nearest smaller value", we know that - // meshgrid[0][x0] < x - // meshgrid[0][x0+1] >= x - var x1 = x0 + 1; - var y1 = y0 + 1; - var z1 = z0 + 1; - - if (meshgrid[0][x0] === x) x1 = x0; - if (meshgrid[1][y0] === y) y1 = y0; - if (meshgrid[2][z0] === z) z1 = z0; - - if (clampOverflow) { - x0 = clamp(x0, 0, w-1); - x1 = clamp(x1, 0, w-1); - y0 = clamp(y0, 0, h-1); - y1 = clamp(y1, 0, h-1); - z0 = clamp(z0, 0, d-1); - z1 = clamp(z1, 0, d-1); - } - - // Reject points outside the meshgrid, return a zero vector. - if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { - return vec3.create(); - } - - // Normalize point coordinates to 0..1 scaling factor between x0 and x1. - var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); - var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); - var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); - - if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; - if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; - if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; - - var z0off = z0*w*h; - var z1off = z1*w*h; - - var y0off = y0*w; - var y1off = y1*w; - - var x0off = x0; - var x1off = x1; - - // Sample data array around the (x,y,z) point. - // vZYX = array[zZoff + yYoff + xXoff] - var v000 = array[y0off + z0off + x0off]; - var v001 = array[y0off + z0off + x1off]; - var v010 = array[y1off + z0off + x0off]; - var v011 = array[y1off + z0off + x1off]; - var v100 = array[y0off + z1off + x0off]; - var v101 = array[y0off + z1off + x1off]; - var v110 = array[y1off + z1off + x0off]; - var v111 = array[y1off + z1off + x1off]; - - var result = vec3.create(); - - // Average samples according to distance to point. - vec3.lerp(result, v000, v001, xf); - vec3.lerp(tmp, v010, v011, xf); - vec3.lerp(result, result, tmp, yf); - vec3.lerp(tmp, v100, v101, xf); - vec3.lerp(tmp2, v110, v111, xf); - vec3.lerp(tmp, tmp, tmp2, yf); - vec3.lerp(result, result, tmp, zf); - - return result; -}; - - -var vabs = function(dst, v) { - var x = v[0]; - var y = v[1]; - var z = v[2]; - dst[0] = x >= 0 ? x : -x; - dst[1] = y >= 0 ? y : -y; - dst[2] = z >= 0 ? z : -z; - return dst; -}; - -var findMinSeparation = function(xs) { - var minSeparation = 1/0; - xs.sort(function(a, b) { return a - b; }); - for (var i=1; i= minX && x <= maxX && - y >= minY && y <= maxY && - z >= minZ && z <= maxZ - ); - }; - - var boundsSize = vec3.distance(bounds[0], bounds[1]); - var maxStepSize = 10 * boundsSize / maxLength; - var maxStepSizeSq = maxStepSize * maxStepSize; - - var minDistance = 1; - var maxDivergence = 0; // For component-wise divergence vec3.create(); - var tmp = vec3.create(); - - if (positions.length >= 2) { - minDistance = calculateMinPositionDistance(positions); - } - - for (var i = 0; i < positions.length; i++) { - var p = vec3.create(); - vec3.copy(p, positions[i]); - - var stream = [p]; - var velocities = []; - var v = vectorField.getVelocity(p); - var op = p; - velocities.push(v); - - var divergences = []; - - var dv = vectorField.getDivergence(p, v); - var dvLength = vec3.length(dv); - if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { - maxDivergence = dvLength; - } - // In case we need to do component-wise divergence visualization - // vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); - divergences.push(dvLength); - - streams.push({points: stream, velocities: velocities, divergences: divergences}); - - var j = 0; - - while (j < maxLength * 100 && stream.length < maxLength && inBounds(bounds, p)) { - j++; - var np = vec3.clone(v); - var sqLen = vec3.squaredLength(np); - if (sqLen === 0) { - break; - } else if (sqLen > maxStepSizeSq) { - vec3.scale(np, np, maxStepSize / Math.sqrt(sqLen)); - } - vec3.add(np, np, p); - - v = vectorField.getVelocity(np); - - if (vec3.squaredDistance(op, np) - maxStepSizeSq > -0.0001 * maxStepSizeSq) { - stream.push(np); - op = np; - velocities.push(v); - var dv = vectorField.getDivergence(np, v); - var dvLength = vec3.length(dv); - if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { - maxDivergence = dvLength; - } - // In case we need to do component-wise divergence visualization - //vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); - divergences.push(dvLength); - } - - p = np; - } - } - - // Replace NaNs and Infinities with non-NaN, finite maxDivergence - for (var i=0; i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color — in vertex or in fragment\n vec4 surfaceColor = step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) + step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]) -var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]) -var pickSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]) - -exports.createShader = function (gl) { - var shader = createShader(gl, vertSrc, fragSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'vec3'}, - {name: 'normal', type: 'vec3'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - shader.attributes.normal.location = 2 - return shader -} -exports.createPickShader = function (gl) { - var shader = createShader(gl, vertSrc, pickSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'vec3'}, - {name: 'normal', type: 'vec3'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - shader.attributes.normal.location = 2 - return shader -} -exports.createContourShader = function (gl) { - var shader = createShader(gl, contourVertSrc, fragSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'float'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - return shader -} -exports.createPickContourShader = function (gl) { - var shader = createShader(gl, contourVertSrc, pickSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'float'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - return shader -} + var surface = new SurfacePlot( + gl, + [0, 0], // shape + [[0, 0, 0], [0, 0, 0]], // bounds + shader, + pickShader, + coordinateBuffer, + vao, + cmap, + contourShader, + contourPickShader, + contourBuffer, + contourVAO, + dynamicBuffer, + dynamicVAO, + [0, 0, 0] // objectOffset + ) -},{"gl-shader":288,"glslify":392}],303:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createSurfacePlot - -var bits = _dereq_('bit-twiddle') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var pool = _dereq_('typedarray-pool') -var colormap = _dereq_('colormap') -var ops = _dereq_('ndarray-ops') -var pack = _dereq_('ndarray-pack') -var ndarray = _dereq_('ndarray') -var surfaceNets = _dereq_('surface-nets') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var bsearch = _dereq_('binary-search-bounds') -var gradient = _dereq_('ndarray-gradient') -var shaders = _dereq_('./lib/shaders') - -var createShader = shaders.createShader -var createContourShader = shaders.createContourShader -var createPickShader = shaders.createPickShader -var createPickContourShader = shaders.createPickContourShader - -var SURFACE_VERTEX_SIZE = 4 * (4 + 3 + 3) - -var IDENTITY = [ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 ] - -var QUAD = [ - [0, 0], - [0, 1], - [1, 0], - [1, 1], - [1, 0], - [0, 1] -] - -var PERMUTATIONS = [ - [0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0] -] - -;(function () { - for (var i = 0; i < 3; ++i) { - var p = PERMUTATIONS[i] - var u = (i + 1) % 3 - var v = (i + 2) % 3 - p[u + 0] = 1 - p[v + 3] = 1 - p[i + 6] = 1 - } -})() - -function SurfacePickResult (position, index, uv, level, dataCoordinate) { - this.position = position - this.index = index - this.uv = uv - this.level = level - this.dataCoordinate = dataCoordinate -} - -var N_COLORS = 256 - -function genColormap (name) { - var x = pack([colormap({ - colormap: name, - nshades: N_COLORS, - format: 'rgba' - }).map(function (c) { - return [c[0], c[1], c[2], 255 * c[3]] - })]) - ops.divseq(x, 255.0) - return x -} - -function SurfacePlot ( - gl, - shape, - bounds, - shader, - pickShader, - coordinates, - vao, - colorMap, - contourShader, - contourPickShader, - contourBuffer, - contourVAO, - dynamicBuffer, - dynamicVAO) { - this.gl = gl - this.shape = shape - this.bounds = bounds - this.intensityBounds = []; - - this._shader = shader - this._pickShader = pickShader - this._coordinateBuffer = coordinates - this._vao = vao - this._colorMap = colorMap - - this._contourShader = contourShader - this._contourPickShader = contourPickShader - this._contourBuffer = contourBuffer - this._contourVAO = contourVAO - this._contourOffsets = [[], [], []] - this._contourCounts = [[], [], []] - this._vertexCount = 0 - - this._pickResult = new SurfacePickResult([0, 0, 0], [0, 0], [0, 0], [0, 0, 0], [0, 0, 0]) - - this._dynamicBuffer = dynamicBuffer - this._dynamicVAO = dynamicVAO - this._dynamicOffsets = [0, 0, 0] - this._dynamicCounts = [0, 0, 0] - - this.contourWidth = [ 1, 1, 1 ] - this.contourLevels = [[1], [1], [1]] - this.contourTint = [0, 0, 0] - this.contourColor = [[0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1]] - - this.showContour = true - this.showSurface = true - - this.enableHighlight = [true, true, true] - this.highlightColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]] - this.highlightTint = [ 1, 1, 1 ] - this.highlightLevel = [-1, -1, -1] - - // Dynamic contour options - this.enableDynamic = [ true, true, true ] - this.dynamicLevel = [ NaN, NaN, NaN ] - this.dynamicColor = [ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1] ] - this.dynamicTint = [ 1, 1, 1 ] - this.dynamicWidth = [ 1, 1, 1 ] - - this.axesBounds = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]] - this.surfaceProject = [ false, false, false ] - this.contourProject = [[ false, false, false ], - [ false, false, false ], - [ false, false, false ]] - - this.colorBounds = [ false, false ] - - // Store xyz fields, need this for picking - this._field = [ - ndarray(pool.mallocFloat(1024), [0, 0]), - ndarray(pool.mallocFloat(1024), [0, 0]), - ndarray(pool.mallocFloat(1024), [0, 0]) ] - - this.pickId = 1 - this.clipBounds = [[-Infinity, -Infinity, -Infinity], [Infinity, Infinity, Infinity]] - - this.snapToData = false - - this.opacity = 1.0 - - this.lightPosition = [10, 10000, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - this.vertexColor = 0; - - this.dirty = true -} - -var proto = SurfacePlot.prototype - -proto.isTransparent = function () { - return this.opacity < 1 -} - -proto.isOpaque = function () { - if (this.opacity >= 1) { - return true - } - for (var i = 0; i < 3; ++i) { - if (this._contourCounts[i].length > 0 || this._dynamicCounts[i] > 0) { - return true - } - } - return false -} - -proto.pickSlots = 1 - -proto.setPickBase = function (id) { - this.pickId = id -} - -var ZERO_VEC = [0, 0, 0] - -var PROJECT_DATA = { - showSurface: false, - showContour: false, - projections: [IDENTITY.slice(), IDENTITY.slice(), IDENTITY.slice()], - clipBounds: [ - [[0, 0, 0], [0, 0, 0]], - [[0, 0, 0], [0, 0, 0]], - [[0, 0, 0], [0, 0, 0]]] -} - -function computeProjectionData (camera, obj) { - var i, j, k - - // Compute cube properties - var cubeAxis = (obj.axes && obj.axes.lastCubeProps.axis) || ZERO_VEC - - var showSurface = obj.showSurface - var showContour = obj.showContour - - for (i = 0; i < 3; ++i) { - showSurface = showSurface || obj.surfaceProject[i] - for (j = 0; j < 3; ++j) { - showContour = showContour || obj.contourProject[i][j] - } - } - - for (i = 0; i < 3; ++i) { - // Construct projection onto axis - var axisSquish = PROJECT_DATA.projections[i] - for (j = 0; j < 16; ++j) { - axisSquish[j] = 0 - } - for (j = 0; j < 4; ++j) { - axisSquish[5 * j] = 1 - } - axisSquish[5 * i] = 0 - axisSquish[12 + i] = obj.axesBounds[+(cubeAxis[i] > 0)][i] - multiply(axisSquish, camera.model, axisSquish) - - var nclipBounds = PROJECT_DATA.clipBounds[i] - for (k = 0; k < 2; ++k) { - for (j = 0; j < 3; ++j) { - nclipBounds[k][j] = camera.clipBounds[k][j] - } - } - nclipBounds[0][i] = -1e8 - nclipBounds[1][i] = 1e8 - } - - PROJECT_DATA.showSurface = showSurface - PROJECT_DATA.showContour = showContour - - return PROJECT_DATA -} - -var UNIFORMS = { - model: IDENTITY, - view: IDENTITY, - projection: IDENTITY, - inverseModel: IDENTITY.slice(), - lowerBound: [0, 0, 0], - upperBound: [0, 0, 0], - colorMap: 0, - clipBounds: [[0, 0, 0], [0, 0, 0]], - height: 0.0, - contourTint: 0, - contourColor: [0, 0, 0, 1], - permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], - zOffset: -1e-4, - kambient: 1, - kdiffuse: 1, - kspecular: 1, - lightPosition: [1000, 1000, 1000], - eyePosition: [0, 0, 0], - roughness: 1, - fresnel: 1, - opacity: 1, - vertexColor: 0 -} - -var MATRIX_INVERSE = IDENTITY.slice() -var DEFAULT_PERM = [1, 0, 0, 0, 1, 0, 0, 0, 1] - -function drawCore (params, transparent) { - params = params || {} - var gl = this.gl - - gl.disable(gl.CULL_FACE) - - this._colorMap.bind(0) - - var uniforms = UNIFORMS - uniforms.model = params.model || IDENTITY - uniforms.view = params.view || IDENTITY - uniforms.projection = params.projection || IDENTITY - uniforms.lowerBound = [this.bounds[0][0], this.bounds[0][1], this.colorBounds[0] || this.bounds[0][2]] - uniforms.upperBound = [this.bounds[1][0], this.bounds[1][1], this.colorBounds[1] || this.bounds[1][2]] - uniforms.contourColor = this.contourColor[0] - - uniforms.inverseModel = invert(uniforms.inverseModel, uniforms.model) - - for (var i = 0; i < 2; ++i) { - var clipClamped = uniforms.clipBounds[i] - for (var j = 0; j < 3; ++j) { - clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) - } - } - - uniforms.kambient = this.ambientLight - uniforms.kdiffuse = this.diffuseLight - uniforms.kspecular = this.specularLight - - uniforms.roughness = this.roughness - uniforms.fresnel = this.fresnel - uniforms.opacity = this.opacity - - uniforms.height = 0.0 - uniforms.permutation = DEFAULT_PERM - - uniforms.vertexColor = this.vertexColor - - // Compute camera matrix inverse - var invCameraMatrix = MATRIX_INVERSE - multiply(invCameraMatrix, uniforms.view, uniforms.model) - multiply(invCameraMatrix, uniforms.projection, invCameraMatrix) - invert(invCameraMatrix, invCameraMatrix) - - for (i = 0; i < 3; ++i) { - uniforms.eyePosition[i] = invCameraMatrix[12 + i] / invCameraMatrix[15] - } - - var w = invCameraMatrix[15] - for (i = 0; i < 3; ++i) { - w += this.lightPosition[i] * invCameraMatrix[4 * i + 3] - } - for (i = 0; i < 3; ++i) { - var s = invCameraMatrix[12 + i] - for (j = 0; j < 3; ++j) { - s += invCameraMatrix[4 * j + i] * this.lightPosition[j] - } - uniforms.lightPosition[i] = s / w - } - - var projectData = computeProjectionData(uniforms, this) - - if (projectData.showSurface && (transparent === (this.opacity < 1))) { - // Set up uniforms - this._shader.bind() - this._shader.uniforms = uniforms - - // Draw it - this._vao.bind() - - if (this.showSurface && this._vertexCount) { - this._vao.draw(gl.TRIANGLES, this._vertexCount) - } - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - if (!this.surfaceProject[i] || !this.vertexCount) { - continue - } - this._shader.uniforms.model = projectData.projections[i] - this._shader.uniforms.clipBounds = projectData.clipBounds[i] - this._vao.draw(gl.TRIANGLES, this._vertexCount) - } - - this._vao.unbind() - } - - if (projectData.showContour && !transparent) { - var shader = this._contourShader - - // Don't apply lighting to contours - uniforms.kambient = 1.0 - uniforms.kdiffuse = 0.0 - uniforms.kspecular = 0.0 - uniforms.opacity = 1.0 - - shader.bind() - shader.uniforms = uniforms - - // Draw contour lines - var vao = this._contourVAO - vao.bind() - - // Draw contour levels - for (i = 0; i < 3; ++i) { - shader.uniforms.permutation = PERMUTATIONS[i] - gl.lineWidth(this.contourWidth[i]) - - for (j = 0; j < this.contourLevels[i].length; ++j) { - if (j === this.highlightLevel[i]) { - shader.uniforms.contourColor = this.highlightColor[i] - shader.uniforms.contourTint = this.highlightTint[i] - } else if (j === 0 || (j - 1) === this.highlightLevel[i]) { - shader.uniforms.contourColor = this.contourColor[i] - shader.uniforms.contourTint = this.contourTint[i] - } - if (!this._contourCounts[i][j]) { - continue - } - shader.uniforms.height = this.contourLevels[i][j] - vao.draw(gl.LINES, this._contourCounts[i][j], this._contourOffsets[i][j]) - } - } - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - shader.uniforms.model = projectData.projections[i] - shader.uniforms.clipBounds = projectData.clipBounds[i] - for (j = 0; j < 3; ++j) { - if (!this.contourProject[i][j]) { - continue - } - shader.uniforms.permutation = PERMUTATIONS[j] - gl.lineWidth(this.contourWidth[j]) - for (var k = 0; k < this.contourLevels[j].length; ++k) { - if (k === this.highlightLevel[j]) { - shader.uniforms.contourColor = this.highlightColor[j] - shader.uniforms.contourTint = this.highlightTint[j] - } else if (k === 0 || (k - 1) === this.highlightLevel[j]) { - shader.uniforms.contourColor = this.contourColor[j] - shader.uniforms.contourTint = this.contourTint[j] - } - shader.uniforms.height = this.contourLevels[j][k] - vao.draw(gl.LINES, this._contourCounts[j][k], this._contourOffsets[j][k]) - } - } - } - vao.unbind() - - // Draw dynamic contours - vao = this._dynamicVAO - vao.bind() - - // Draw contour levels - for (i = 0; i < 3; ++i) { - if (this._dynamicCounts[i] === 0) { - continue - } - - shader.uniforms.model = uniforms.model - shader.uniforms.clipBounds = uniforms.clipBounds - shader.uniforms.permutation = PERMUTATIONS[i] - gl.lineWidth(this.dynamicWidth[i]) - - shader.uniforms.contourColor = this.dynamicColor[i] - shader.uniforms.contourTint = this.dynamicTint[i] - shader.uniforms.height = this.dynamicLevel[i] - vao.draw(gl.LINES, this._dynamicCounts[i], this._dynamicOffsets[i]) - - for (j = 0; j < 3; ++j) { - if (!this.contourProject[j][i]) { - continue - } - - shader.uniforms.model = projectData.projections[j] - shader.uniforms.clipBounds = projectData.clipBounds[j] - vao.draw(gl.LINES, this._dynamicCounts[i], this._dynamicOffsets[i]) - } - } - - vao.unbind() - } -} - -proto.draw = function (params) { - return drawCore.call(this, params, false) -} - -proto.drawTransparent = function (params) { - return drawCore.call(this, params, true) -} - -var PICK_UNIFORMS = { - model: IDENTITY, - view: IDENTITY, - projection: IDENTITY, - inverseModel: IDENTITY, - clipBounds: [[0, 0, 0], [0, 0, 0]], - height: 0.0, - shape: [0, 0], - pickId: 0, - lowerBound: [0, 0, 0], - upperBound: [0, 0, 0], - zOffset: 0.0, - permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], - lightPosition: [0, 0, 0], - eyePosition: [0, 0, 0] -} - -proto.drawPick = function (params) { - params = params || {} - var gl = this.gl - gl.disable(gl.CULL_FACE) - - var uniforms = PICK_UNIFORMS - uniforms.model = params.model || IDENTITY - uniforms.view = params.view || IDENTITY - uniforms.projection = params.projection || IDENTITY - uniforms.shape = this._field[2].shape - uniforms.pickId = this.pickId / 255.0 - uniforms.lowerBound = this.bounds[0] - uniforms.upperBound = this.bounds[1] - uniforms.permutation = DEFAULT_PERM - - for (var i = 0; i < 2; ++i) { - var clipClamped = uniforms.clipBounds[i] - for (var j = 0; j < 3; ++j) { - clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) - } - } - - var projectData = computeProjectionData(uniforms, this) - - if (projectData.showSurface) { - // Set up uniforms - this._pickShader.bind() - this._pickShader.uniforms = uniforms - - // Draw it - this._vao.bind() - this._vao.draw(gl.TRIANGLES, this._vertexCount) - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - if (!this.surfaceProject[i]) { - continue - } - this._pickShader.uniforms.model = projectData.projections[i] - this._pickShader.uniforms.clipBounds = projectData.clipBounds[i] - this._vao.draw(gl.TRIANGLES, this._vertexCount) - } - - this._vao.unbind() - } - - if (projectData.showContour) { - var shader = this._contourPickShader - - shader.bind() - shader.uniforms = uniforms - - var vao = this._contourVAO - vao.bind() - - for (j = 0; j < 3; ++j) { - gl.lineWidth(this.contourWidth[j]) - shader.uniforms.permutation = PERMUTATIONS[j] - for (i = 0; i < this.contourLevels[j].length; ++i) { - if (this._contourCounts[j][i]) { - shader.uniforms.height = this.contourLevels[j][i] - vao.draw(gl.LINES, this._contourCounts[j][i], this._contourOffsets[j][i]) - } - } - } - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - shader.uniforms.model = projectData.projections[i] - shader.uniforms.clipBounds = projectData.clipBounds[i] - - for (j = 0; j < 3; ++j) { - if (!this.contourProject[i][j]) { - continue - } - - shader.uniforms.permutation = PERMUTATIONS[j] - gl.lineWidth(this.contourWidth[j]) - for (var k = 0; k < this.contourLevels[j].length; ++k) { - if (this._contourCounts[j][k]) { - shader.uniforms.height = this.contourLevels[j][k] - vao.draw(gl.LINES, this._contourCounts[j][k], this._contourOffsets[j][k]) - } - } - } - } - - vao.unbind() - } -} - -proto.pick = function (selection) { - if (!selection) { - return null - } - - if (selection.id !== this.pickId) { - return null - } - - var shape = this._field[2].shape - - var result = this._pickResult - - // Compute uv coordinate - var x = shape[0] * (selection.value[0] + (selection.value[2] >> 4) / 16.0) / 255.0 - var ix = Math.floor(x) - var fx = x - ix - - var y = shape[1] * (selection.value[1] + (selection.value[2] & 15) / 16.0) / 255.0 - var iy = Math.floor(y) - var fy = y - iy - - ix += 1 - iy += 1 - - // Compute xyz coordinate - var pos = result.position - pos[0] = pos[1] = pos[2] = 0 - for (var dx = 0; dx < 2; ++dx) { - var s = dx ? fx : 1.0 - fx - for (var dy = 0; dy < 2; ++dy) { - var t = dy ? fy : 1.0 - fy - - var r = ix + dx - var c = iy + dy - var w = s * t - - for (var i = 0; i < 3; ++i) { - pos[i] += this._field[i].get(r, c) * w - } - } - } - - // Find closest level - var levelIndex = this._pickResult.level - for (var j = 0; j < 3; ++j) { - levelIndex[j] = bsearch.le(this.contourLevels[j], pos[j]) - if (levelIndex[j] < 0) { - if (this.contourLevels[j].length > 0) { - levelIndex[j] = 0 - } - } else if (levelIndex[j] < this.contourLevels[j].length - 1) { - var a = this.contourLevels[j][levelIndex[j]] - var b = this.contourLevels[j][levelIndex[j] + 1] - if (Math.abs(a - pos[j]) > Math.abs(b - pos[j])) { - levelIndex[j] += 1 - } - } - } - - result.index[0] = fx < 0.5 ? ix : (ix + 1) - result.index[1] = fy < 0.5 ? iy : (iy + 1) - - result.uv[0] = x / shape[0] - result.uv[1] = y / shape[1] - - for (i = 0; i < 3; ++i) { - result.dataCoordinate[i] = this._field[i].get(result.index[0], result.index[1]) - } - - return result -} - -function padField (nfield, field) { - var shape = field.shape.slice() - var nshape = nfield.shape.slice() - - // Center - ops.assign(nfield.lo(1, 1).hi(shape[0], shape[1]), field) - - // Edges - ops.assign(nfield.lo(1).hi(shape[0], 1), - field.hi(shape[0], 1)) - ops.assign(nfield.lo(1, nshape[1] - 1).hi(shape[0], 1), - field.lo(0, shape[1] - 1).hi(shape[0], 1)) - ops.assign(nfield.lo(0, 1).hi(1, shape[1]), - field.hi(1)) - ops.assign(nfield.lo(nshape[0] - 1, 1).hi(1, shape[1]), - field.lo(shape[0] - 1)) - // Corners - nfield.set(0, 0, field.get(0, 0)) - nfield.set(0, nshape[1] - 1, field.get(0, shape[1] - 1)) - nfield.set(nshape[0] - 1, 0, field.get(shape[0] - 1, 0)) - nfield.set(nshape[0] - 1, nshape[1] - 1, field.get(shape[0] - 1, shape[1] - 1)) -} - -function handleArray (param, ctor) { - if (Array.isArray(param)) { - return [ ctor(param[0]), ctor(param[1]), ctor(param[2]) ] - } - return [ ctor(param), ctor(param), ctor(param) ] -} - -function toColor (x) { - if (Array.isArray(x)) { - if (x.length === 3) { - return [x[0], x[1], x[2], 1] - } - return [x[0], x[1], x[2], x[3]] - } - return [0, 0, 0, 1] -} - -function handleColor (param) { - if (Array.isArray(param)) { - if (Array.isArray(param)) { - return [ - toColor(param[0]), - toColor(param[1]), - toColor(param[2]) ] - } else { - var c = toColor(param) - return [ - c.slice(), - c.slice(), - c.slice() ] - } - } -} - -proto.update = function (params) { - params = params || {} - - this.dirty = true - - if ('contourWidth' in params) { - this.contourWidth = handleArray(params.contourWidth, Number) - } - if ('showContour' in params) { - this.showContour = handleArray(params.showContour, Boolean) - } - if ('showSurface' in params) { - this.showSurface = !!params.showSurface - } - if ('contourTint' in params) { - this.contourTint = handleArray(params.contourTint, Boolean) - } - if ('contourColor' in params) { - this.contourColor = handleColor(params.contourColor) - } - if ('contourProject' in params) { - this.contourProject = handleArray(params.contourProject, function (x) { - return handleArray(x, Boolean) - }) - } - if ('surfaceProject' in params) { - this.surfaceProject = params.surfaceProject - } - if ('dynamicColor' in params) { - this.dynamicColor = handleColor(params.dynamicColor) - } - if ('dynamicTint' in params) { - this.dynamicTint = handleArray(params.dynamicTint, Number) - } - if ('dynamicWidth' in params) { - this.dynamicWidth = handleArray(params.dynamicWidth, Number) - } - if ('opacity' in params) { - this.opacity = params.opacity - } - if ('colorBounds' in params) { - this.colorBounds = params.colorBounds - } - if ('vertexColor' in params) { - this.vertexColor = params.vertexColor ? 1 : 0; - } - - var field = params.field || (params.coords && params.coords[2]) || null - var levelsChanged = false - - if (!field) { - if (this._field[2].shape[0] || this._field[2].shape[2]) { - field = this._field[2].lo(1, 1).hi(this._field[2].shape[0] - 2, this._field[2].shape[1] - 2) - } else { - field = this._field[2].hi(0, 0) - } - } - - // Update field - if ('field' in params || 'coords' in params) { - var fsize = (field.shape[0] + 2) * (field.shape[1] + 2) - - // Resize if necessary - if (fsize > this._field[2].data.length) { - pool.freeFloat(this._field[2].data) - this._field[2].data = pool.mallocFloat(bits.nextPow2(fsize)) - } - - // Pad field - this._field[2] = ndarray(this._field[2].data, [field.shape[0] + 2, field.shape[1] + 2]) - padField(this._field[2], field) - - // Save shape of field - this.shape = field.shape.slice() - var shape = this.shape - - // Resize coordinate fields if necessary - for (var i = 0; i < 2; ++i) { - if (this._field[2].size > this._field[i].data.length) { - pool.freeFloat(this._field[i].data) - this._field[i].data = pool.mallocFloat(this._field[2].size) - } - this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2]) - } - - // Generate x/y coordinates - if (params.coords) { - var coords = params.coords - if (!Array.isArray(coords) || coords.length !== 3) { - throw new Error('gl-surface: invalid coordinates for x/y') - } - for (i = 0; i < 2; ++i) { - var coord = coords[i] - for (j = 0; j < 2; ++j) { - if (coord.shape[j] !== shape[j]) { - throw new Error('gl-surface: coords have incorrect shape') - } - } - padField(this._field[i], coord) - } - } else if (params.ticks) { - var ticks = params.ticks - if (!Array.isArray(ticks) || ticks.length !== 2) { - throw new Error('gl-surface: invalid ticks') - } - for (i = 0; i < 2; ++i) { - var tick = ticks[i] - if (Array.isArray(tick) || tick.length) { - tick = ndarray(tick) - } - if (tick.shape[0] !== shape[i]) { - throw new Error('gl-surface: invalid tick length') - } - // Make a copy view of the tick array - var tick2 = ndarray(tick.data, shape) - tick2.stride[i] = tick.stride[0] - tick2.stride[i ^ 1] = 0 - - // Fill in field array - padField(this._field[i], tick2) - } - } else { - for (i = 0; i < 2; ++i) { - var offset = [0, 0] - offset[i] = 1 - this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2], offset, 0) - } - this._field[0].set(0, 0, 0) - for (var j = 0; j < shape[0]; ++j) { - this._field[0].set(j + 1, 0, j) - } - this._field[0].set(shape[0] + 1, 0, shape[0] - 1) - this._field[1].set(0, 0, 0) - for (j = 0; j < shape[1]; ++j) { - this._field[1].set(0, j + 1, j) - } - this._field[1].set(0, shape[1] + 1, shape[1] - 1) - } - - // Save shape - var fields = this._field - - // Compute surface normals - var dfields = ndarray(pool.mallocFloat(fields[2].size * 3 * 2), [3, shape[0] + 2, shape[1] + 2, 2]) - for (i = 0; i < 3; ++i) { - gradient(dfields.pick(i), fields[i], 'mirror') - } - var normals = ndarray(pool.mallocFloat(fields[2].size * 3), [shape[0] + 2, shape[1] + 2, 3]) - for (i = 0; i < shape[0] + 2; ++i) { - for (j = 0; j < shape[1] + 2; ++j) { - var dxdu = dfields.get(0, i, j, 0) - var dxdv = dfields.get(0, i, j, 1) - var dydu = dfields.get(1, i, j, 0) - var dydv = dfields.get(1, i, j, 1) - var dzdu = dfields.get(2, i, j, 0) - var dzdv = dfields.get(2, i, j, 1) - - var nx = dydu * dzdv - dydv * dzdu - var ny = dzdu * dxdv - dzdv * dxdu - var nz = dxdu * dydv - dxdv * dydu - - var nl = Math.sqrt(nx * nx + ny * ny + nz * nz) - if (nl < 1e-8) { - nl = Math.max(Math.abs(nx), Math.abs(ny), Math.abs(nz)) - if (nl < 1e-8) { - nz = 1.0 - ny = nx = 0.0 - nl = 1.0 - } else { - nl = 1.0 / nl - } - } else { - nl = 1.0 / Math.sqrt(nl) - } - - normals.set(i, j, 0, nx * nl) - normals.set(i, j, 1, ny * nl) - normals.set(i, j, 2, nz * nl) - } - } - pool.free(dfields.data) - - // Initialize surface - var lo = [ Infinity, Infinity, Infinity ] - var hi = [ -Infinity, -Infinity, -Infinity ] - var lo_intensity = Infinity - var hi_intensity = -Infinity - var count = (shape[0] - 1) * (shape[1] - 1) * 6 - var tverts = pool.mallocFloat(bits.nextPow2(10 * count)) - var tptr = 0 - var vertexCount = 0 - for (i = 0; i < shape[0] - 1; ++i) { - j_loop: - for (j = 0; j < shape[1] - 1; ++j) { - // Test for NaNs - for (var dx = 0; dx < 2; ++dx) { - for (var dy = 0; dy < 2; ++dy) { - for (var k = 0; k < 3; ++k) { - var f = this._field[k].get(1 + i + dx, 1 + j + dy) - if (isNaN(f) || !isFinite(f)) { - continue j_loop - } - } - } - } - for (k = 0; k < 6; ++k) { - var r = i + QUAD[k][0] - var c = j + QUAD[k][1] - - var tx = this._field[0].get(r + 1, c + 1) - var ty = this._field[1].get(r + 1, c + 1) - f = this._field[2].get(r + 1, c + 1) - var vf = f - nx = normals.get(r + 1, c + 1, 0) - ny = normals.get(r + 1, c + 1, 1) - nz = normals.get(r + 1, c + 1, 2) - - if (params.intensity) { - vf = params.intensity.get(r, c) - } - - tverts[tptr++] = r - tverts[tptr++] = c - tverts[tptr++] = tx - tverts[tptr++] = ty - tverts[tptr++] = f - tverts[tptr++] = 0 - tverts[tptr++] = vf - tverts[tptr++] = nx - tverts[tptr++] = ny - tverts[tptr++] = nz - - lo[0] = Math.min(lo[0], tx) - lo[1] = Math.min(lo[1], ty) - lo[2] = Math.min(lo[2], f) - lo_intensity = Math.min(lo_intensity, vf) - - hi[0] = Math.max(hi[0], tx) - hi[1] = Math.max(hi[1], ty) - hi[2] = Math.max(hi[2], f) - hi_intensity = Math.max(hi_intensity, vf) - - vertexCount += 1 - } - } - } - - if (params.intensityBounds) { - lo_intensity = +params.intensityBounds[0] - hi_intensity = +params.intensityBounds[1] - } - - // Scale all vertex intensities - for (i = 6; i < tptr; i += 10) { - tverts[i] = (tverts[i] - lo_intensity) / (hi_intensity - lo_intensity) - } - - this._vertexCount = vertexCount - this._coordinateBuffer.update(tverts.subarray(0, tptr)) - pool.freeFloat(tverts) - pool.free(normals.data) - - // Update bounds - this.bounds = [lo, hi] - - // Save intensity - this.intensity = params.intensity || this._field[2] - - if(this.intensityBounds[0] !== lo_intensity || this.intensityBounds[1] !== hi_intensity) { - levelsChanged = true - } - - // Save intensity bound - this.intensityBounds = [lo_intensity, hi_intensity] - } - - // Update level crossings - if ('levels' in params) { - var levels = params.levels - if (!Array.isArray(levels[0])) { - levels = [ [], [], levels ] - } else { - levels = levels.slice() - } - for (i = 0; i < 3; ++i) { - levels[i] = levels[i].slice() - levels.sort(function (a, b) { - return a - b - }) - } - change_test: - for (i = 0; i < 3; ++i) { - if (levels[i].length !== this.contourLevels[i].length) { - levelsChanged = true - break - } - for (j = 0; j < levels[i].length; ++j) { - if (levels[i][j] !== this.contourLevels[i][j]) { - levelsChanged = true - break change_test - } - } - } - this.contourLevels = levels - } - - if (levelsChanged) { - fields = this._field - shape = this.shape - - // Update contour lines - var contourVerts = [] - - for (var dim = 0; dim < 3; ++dim) { - levels = this.contourLevels[dim] - var levelOffsets = [] - var levelCounts = [] - - var parts = [0, 0, 0] - - for (i = 0; i < levels.length; ++i) { - var graph = surfaceNets(this._field[dim], levels[i]) - levelOffsets.push((contourVerts.length / 5) | 0) - vertexCount = 0 - - edge_loop: - for (j = 0; j < graph.cells.length; ++j) { - var e = graph.cells[j] - for (k = 0; k < 2; ++k) { - var p = graph.positions[e[k]] - - var x = p[0] - var ix = Math.floor(x) | 0 - var fx = x - ix - - var y = p[1] - var iy = Math.floor(y) | 0 - var fy = y - iy - - var hole = false - dd_loop: - for (var dd = 0; dd < 3; ++dd) { - parts[dd] = 0.0 - var iu = (dim + dd + 1) % 3 - for (dx = 0; dx < 2; ++dx) { - var s = dx ? fx : 1.0 - fx - r = Math.min(Math.max(ix + dx, 0), shape[0]) | 0 - for (dy = 0; dy < 2; ++dy) { - var t = dy ? fy : 1.0 - fy - c = Math.min(Math.max(iy + dy, 0), shape[1]) | 0 - - if (dd < 2) { - f = this._field[iu].get(r, c) - } else { - f = (this.intensity.get(r, c) - this.intensityBounds[0]) / (this.intensityBounds[1] - this.intensityBounds[0]) - } - if (!isFinite(f) || isNaN(f)) { - hole = true - break dd_loop - } - - var w = s * t - parts[dd] += w * f - } - } - } - - if (!hole) { - contourVerts.push(parts[0], parts[1], p[0], p[1], parts[2]) - vertexCount += 1 - } else { - if (k > 0) { - // If we already added first edge, pop off verts - for (var l = 0; l < 5; ++l) { - contourVerts.pop() - } - vertexCount -= 1 - } - continue edge_loop - } - } - } - levelCounts.push(vertexCount) - } - - // Store results - this._contourOffsets[dim] = levelOffsets - this._contourCounts[dim] = levelCounts - } - - var floatBuffer = pool.mallocFloat(contourVerts.length) - for (i = 0; i < contourVerts.length; ++i) { - floatBuffer[i] = contourVerts[i] - } - this._contourBuffer.update(floatBuffer) - pool.freeFloat(floatBuffer) - } - - if (params.colormap) { - this._colorMap.setPixels(genColormap(params.colormap)) - } -} - -proto.dispose = function () { - this._shader.dispose() - this._vao.dispose() - this._coordinateBuffer.dispose() - this._colorMap.dispose() - this._contourBuffer.dispose() - this._contourVAO.dispose() - this._contourShader.dispose() - this._contourPickShader.dispose() - this._dynamicBuffer.dispose() - this._dynamicVAO.dispose() - for (var i = 0; i < 3; ++i) { - pool.freeFloat(this._field[i].data) - } -} - -proto.highlight = function (selection) { - if (!selection) { - this._dynamicCounts = [0, 0, 0] - this.dyanamicLevel = [NaN, NaN, NaN] - this.highlightLevel = [-1, -1, -1] - return - } - - for (var i = 0; i < 3; ++i) { - if (this.enableHighlight[i]) { - this.highlightLevel[i] = selection.level[i] - } else { - this.highlightLevel[i] = -1 - } - } - - var levels - if (this.snapToData) { - levels = selection.dataCoordinate - } else { - levels = selection.position - } - if ((!this.enableDynamic[0] || levels[0] === this.dynamicLevel[0]) && - (!this.enableDynamic[1] || levels[1] === this.dynamicLevel[1]) && - (!this.enableDynamic[2] || levels[2] === this.dynamicLevel[2])) { - return - } - - var vertexCount = 0 - var shape = this.shape - var scratchBuffer = pool.mallocFloat(12 * shape[0] * shape[1]) - - for (var d = 0; d < 3; ++d) { - if (!this.enableDynamic[d]) { - this.dynamicLevel[d] = NaN - this._dynamicCounts[d] = 0 - continue - } - - this.dynamicLevel[d] = levels[d] - - var u = (d + 1) % 3 - var v = (d + 2) % 3 - - var f = this._field[d] - var g = this._field[u] - var h = this._field[v] - var intensity = this.intensity - - var graph = surfaceNets(f, levels[d]) - var edges = graph.cells - var positions = graph.positions - - this._dynamicOffsets[d] = vertexCount - - for (i = 0; i < edges.length; ++i) { - var e = edges[i] - for (var j = 0; j < 2; ++j) { - var p = positions[e[j]] - - var x = +p[0] - var ix = x | 0 - var jx = Math.min(ix + 1, shape[0]) | 0 - var fx = x - ix - var hx = 1.0 - fx - - var y = +p[1] - var iy = y | 0 - var jy = Math.min(iy + 1, shape[1]) | 0 - var fy = y - iy - var hy = 1.0 - fy - - var w00 = hx * hy - var w01 = hx * fy - var w10 = fx * hy - var w11 = fx * fy - - var cu = w00 * g.get(ix, iy) + - w01 * g.get(ix, jy) + - w10 * g.get(jx, iy) + - w11 * g.get(jx, jy) - - var cv = w00 * h.get(ix, iy) + - w01 * h.get(ix, jy) + - w10 * h.get(jx, iy) + - w11 * h.get(jx, jy) - - if (isNaN(cu) || isNaN(cv)) { - if (j) { - vertexCount -= 1 - } - break - } - - scratchBuffer[2 * vertexCount + 0] = cu - scratchBuffer[2 * vertexCount + 1] = cv - - vertexCount += 1 - } - } - - this._dynamicCounts[d] = vertexCount - this._dynamicOffsets[d] - } - - this._dynamicBuffer.update(scratchBuffer.subarray(0, 2 * vertexCount)) - pool.freeFloat(scratchBuffer) -} - -function createSurfacePlot (params) { - var gl = params.gl - var shader = createShader(gl) - var pickShader = createPickShader(gl) - var contourShader = createContourShader(gl) - var contourPickShader = createPickContourShader(gl) - - var coordinateBuffer = createBuffer(gl) - var vao = createVAO(gl, [ - { buffer: coordinateBuffer, - size: 4, - stride: SURFACE_VERTEX_SIZE, - offset: 0 - }, - { buffer: coordinateBuffer, - size: 3, - stride: SURFACE_VERTEX_SIZE, - offset: 16 - }, - { - buffer: coordinateBuffer, - size: 3, - stride: SURFACE_VERTEX_SIZE, - offset: 28 - } - ]) - - var contourBuffer = createBuffer(gl) - var contourVAO = createVAO(gl, [ - { - buffer: contourBuffer, - size: 4, - stride: 20, - offset: 0 - }, - { - buffer: contourBuffer, - size: 1, - stride: 20, - offset: 16 - } - ]) - - var dynamicBuffer = createBuffer(gl) - var dynamicVAO = createVAO(gl, [ - { - buffer: dynamicBuffer, - size: 2, - type: gl.FLOAT - }]) - - var cmap = createTexture(gl, 1, N_COLORS, gl.RGBA, gl.UNSIGNED_BYTE) - cmap.minFilter = gl.LINEAR - cmap.magFilter = gl.LINEAR - - var surface = new SurfacePlot( - gl, - [0, 0], - [[0, 0, 0], [0, 0, 0]], - shader, - pickShader, - coordinateBuffer, - vao, - cmap, - contourShader, - contourPickShader, - contourBuffer, - contourVAO, - dynamicBuffer, - dynamicVAO - ) - - var nparams = { - levels: [[], [], []] - } - for (var id in params) { - nparams[id] = params[id] - } - nparams.colormap = nparams.colormap || 'jet' - - surface.update(nparams) - - return surface -} + var nparams = { + levels: [[], [], []] + } + for (var id in params) { + nparams[id] = params[id] + } + nparams.colormap = nparams.colormap || 'jet' + + surface.update(nparams) + + return surface +} -},{"./lib/shaders":302,"binary-search-bounds":79,"bit-twiddle":80,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"ndarray-gradient":424,"ndarray-ops":427,"ndarray-pack":428,"surface-nets":508,"typedarray-pool":522}],304:[function(_dereq_,module,exports){ +},{"./lib/shaders":302,"binary-search-bounds":79,"bit-twiddle":80,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"ndarray-gradient":424,"ndarray-ops":427,"ndarray-pack":428,"surface-nets":507,"typedarray-pool":521}],304:[function(_dereq_,module,exports){ 'use strict' var Font = _dereq_('css-font') @@ -48467,7 +48578,7 @@ function isRegl (o) { module.exports = GlText -},{"bit-twiddle":80,"color-normalize":108,"css-font":127,"detect-kerning":151,"es6-weak-map":209,"flatten-vertex-data":216,"font-atlas":217,"font-measure":218,"gl-util/context":306,"is-plain-obj":405,"object-assign":437,"parse-rect":442,"parse-unit":444,"pick-by-alias":448,"regl":478,"to-px":516,"typedarray-pool":522}],305:[function(_dereq_,module,exports){ +},{"bit-twiddle":80,"color-normalize":108,"css-font":127,"detect-kerning":151,"es6-weak-map":209,"flatten-vertex-data":216,"font-atlas":217,"font-measure":218,"gl-util/context":306,"is-plain-obj":405,"object-assign":437,"parse-rect":442,"parse-unit":444,"pick-by-alias":448,"regl":478,"to-px":515,"typedarray-pool":521}],305:[function(_dereq_,module,exports){ 'use strict' var ndarray = _dereq_('ndarray') @@ -49030,7 +49141,7 @@ function createTexture2D(gl) { throw new Error('gl-texture2d: Invalid arguments for texture2d constructor') } -},{"ndarray":433,"ndarray-ops":427,"typedarray-pool":522}],306:[function(_dereq_,module,exports){ +},{"ndarray":433,"ndarray-ops":427,"typedarray-pool":521}],306:[function(_dereq_,module,exports){ /** @module gl-util/context */ 'use strict' @@ -53709,7 +53820,7 @@ function mouseWheelListen(element, callback, noScroll) { return listener } -},{"to-px":516}],422:[function(_dereq_,module,exports){ +},{"to-px":515}],422:[function(_dereq_,module,exports){ "use strict" var pool = _dereq_("typedarray-pool") @@ -54125,7 +54236,7 @@ function createSurfaceExtractor(args) { order, typesig) } -},{"typedarray-pool":522}],423:[function(_dereq_,module,exports){ +},{"typedarray-pool":521}],423:[function(_dereq_,module,exports){ "use strict" @@ -55794,7 +55905,7 @@ function compileSort(order, dtype) { } module.exports = compileSort -},{"typedarray-pool":522}],431:[function(_dereq_,module,exports){ +},{"typedarray-pool":521}],431:[function(_dereq_,module,exports){ "use strict" var compile = _dereq_("./lib/compile_sort.js") @@ -57491,7 +57602,7 @@ function permutationSign(p) { return sgn } } -},{"typedarray-pool":522}],447:[function(_dereq_,module,exports){ +},{"typedarray-pool":521}],447:[function(_dereq_,module,exports){ "use strict" var pool = _dereq_("typedarray-pool") @@ -57578,7 +57689,7 @@ function unrank(n, r, p) { exports.rank = rank exports.unrank = unrank -},{"invert-permutation":398,"typedarray-pool":522}],448:[function(_dereq_,module,exports){ +},{"invert-permutation":398,"typedarray-pool":521}],448:[function(_dereq_,module,exports){ 'use strict' @@ -58049,7 +58160,7 @@ function planarGraphToPolyline(edges, positions) { return result } -},{"./lib/trim-leaves":450,"edges-to-adjacency-list":157,"planar-dual":449,"point-in-big-polygon":455,"robust-sum":491,"two-product":520,"uniq":524}],452:[function(_dereq_,module,exports){ +},{"./lib/trim-leaves":450,"edges-to-adjacency-list":157,"planar-dual":449,"point-in-big-polygon":455,"robust-sum":491,"two-product":519,"uniq":523}],452:[function(_dereq_,module,exports){ 'use strict' module.exports = _dereq_('./quad') @@ -61222,7 +61333,7 @@ function Error2D (regl, options) { meshBuffer.destroy() } } -},{"array-bounds":53,"color-normalize":108,"flatten-vertex-data":216,"object-assign":437,"pick-by-alias":448,"to-float32":515,"update-diff":526}],474:[function(_dereq_,module,exports){ +},{"array-bounds":53,"color-normalize":108,"flatten-vertex-data":216,"object-assign":437,"pick-by-alias":448,"to-float32":514,"update-diff":525}],474:[function(_dereq_,module,exports){ 'use strict' @@ -61951,254 +62062,1016 @@ Line2D.prototype.destroy = function () { return this } -},{"array-bounds":53,"array-normalize":54,"color-normalize":108,"earcut":156,"es6-weak-map":209,"flatten-vertex-data":216,"glslify":392,"object-assign":437,"parse-rect":442,"pick-by-alias":448,"to-float32":515}],475:[function(_dereq_,module,exports){ +},{"array-bounds":53,"array-normalize":54,"color-normalize":108,"earcut":156,"es6-weak-map":209,"flatten-vertex-data":216,"glslify":392,"object-assign":437,"parse-rect":442,"pick-by-alias":448,"to-float32":514}],475:[function(_dereq_,module,exports){ +'use strict'; + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance"); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} + +var rgba = _dereq_('color-normalize'); + +var getBounds = _dereq_('array-bounds'); + +var colorId = _dereq_('color-id'); + +var cluster = _dereq_('point-cluster'); + +var extend = _dereq_('object-assign'); + +var glslify = _dereq_('glslify'); + +var pick = _dereq_('pick-by-alias'); + +var updateDiff = _dereq_('update-diff'); + +var flatten = _dereq_('flatten-vertex-data'); + +var ie = _dereq_('is-iexplorer'); + +var f32 = _dereq_('to-float32'); + +var parseRect = _dereq_('parse-rect'); + +var scatter = Scatter; + +function Scatter(regl, options) { + var _this = this; + + if (!(this instanceof Scatter)) return new Scatter(regl, options); + + if (typeof regl === 'function') { + if (!options) options = {}; + options.regl = regl; + } else { + options = regl; + regl = null; + } + + if (options && options.length) options.positions = options; + regl = options.regl; // persistent variables + + var gl = regl._gl, + paletteTexture, + palette = [], + paletteIds = {}, + // state + groups = [], + // textures for marker keys + markerTextures = [null], + markerCache = [null]; + var maxColors = 255, + maxSize = 100; // direct color buffer mode + // IE does not support palette anyways + + this.tooManyColors = ie; // texture with color palette + + paletteTexture = regl.texture({ + data: new Uint8Array(maxColors * 4), + width: maxColors, + height: 1, + type: 'uint8', + format: 'rgba', + wrapS: 'clamp', + wrapT: 'clamp', + mag: 'nearest', + min: 'nearest' + }); + extend(this, { + regl: regl, + gl: gl, + groups: groups, + markerCache: markerCache, + markerTextures: markerTextures, + palette: palette, + paletteIds: paletteIds, + paletteTexture: paletteTexture, + maxColors: maxColors, + maxSize: maxSize, + canvas: gl.canvas + }); + this.update(options); // common shader options + + var shaderOptions = { + uniforms: { + pixelRatio: regl.context('pixelRatio'), + palette: paletteTexture, + paletteSize: function paletteSize(ctx, prop) { + return [_this.tooManyColors ? 0 : maxColors, paletteTexture.height]; + }, + scale: regl.prop('scale'), + scaleFract: regl.prop('scaleFract'), + translate: regl.prop('translate'), + translateFract: regl.prop('translateFract'), + opacity: regl.prop('opacity'), + marker: regl.prop('markerTexture') + }, + attributes: { + // FIXME: optimize these parts + x: function x(ctx, prop) { + return prop.xAttr || { + buffer: prop.positionBuffer, + stride: 8, + offset: 0 + }; + }, + y: function y(ctx, prop) { + return prop.yAttr || { + buffer: prop.positionBuffer, + stride: 8, + offset: 4 + }; + }, + xFract: function xFract(ctx, prop) { + return prop.xAttr ? { + constant: [0, 0] + } : { + buffer: prop.positionFractBuffer, + stride: 8, + offset: 0 + }; + }, + yFract: function yFract(ctx, prop) { + return prop.yAttr ? { + constant: [0, 0] + } : { + buffer: prop.positionFractBuffer, + stride: 8, + offset: 4 + }; + }, + size: function size(ctx, prop) { + return prop.size.length ? { + buffer: prop.sizeBuffer, + stride: 2, + offset: 0 + } : { + constant: [Math.round(prop.size * 255 / _this.maxSize)] + }; + }, + borderSize: function borderSize(ctx, prop) { + return prop.borderSize.length ? { + buffer: prop.sizeBuffer, + stride: 2, + offset: 1 + } : { + constant: [Math.round(prop.borderSize * 255 / _this.maxSize)] + }; + }, + colorId: function colorId(ctx, prop) { + return prop.color.length ? { + buffer: prop.colorBuffer, + stride: _this.tooManyColors ? 8 : 4, + offset: 0 + } : { + constant: _this.tooManyColors ? palette.slice(prop.color * 4, prop.color * 4 + 4) : [prop.color] + }; + }, + borderColorId: function borderColorId(ctx, prop) { + return prop.borderColor.length ? { + buffer: prop.colorBuffer, + stride: _this.tooManyColors ? 8 : 4, + offset: _this.tooManyColors ? 4 : 2 + } : { + constant: _this.tooManyColors ? palette.slice(prop.borderColor * 4, prop.borderColor * 4 + 4) : [prop.borderColor] + }; + }, + isActive: function isActive(ctx, prop) { + return prop.activation === true ? { + constant: [1] + } : prop.activation ? prop.activation : { + constant: [0] + }; + } + }, + blend: { + enable: true, + color: [0, 0, 0, 1], + // photoshop blending + func: { + srcRGB: 'src alpha', + dstRGB: 'one minus src alpha', + srcAlpha: 'one minus dst alpha', + dstAlpha: 'one' + } + }, + scissor: { + enable: true, + box: regl.prop('viewport') + }, + viewport: regl.prop('viewport'), + stencil: { + enable: false + }, + depth: { + enable: false + }, + elements: regl.prop('elements'), + count: regl.prop('count'), + offset: regl.prop('offset'), + primitive: 'points' // draw sdf-marker + + }; + var markerOptions = extend({}, shaderOptions); + markerOptions.frag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragWidth, fragBorderColorLevel, fragColorLevel;\n\nuniform sampler2D marker;\nuniform float pixelRatio, opacity;\n\nfloat smoothStep(float x, float y) {\n return 1.0 / (1.0 + exp(50.0*(x - y)));\n}\n\nvoid main() {\n float dist = texture2D(marker, gl_PointCoord).r, delta = fragWidth;\n\n // max-distance alpha\n if (dist < 0.003) discard;\n\n // null-border case\n if (fragBorderColorLevel == fragColorLevel || fragBorderColor.a == 0.) {\n float colorAmt = smoothstep(.5 - delta, .5 + delta, dist);\n gl_FragColor = vec4(fragColor.rgb, colorAmt * fragColor.a * opacity);\n }\n else {\n float borderColorAmt = smoothstep(fragBorderColorLevel - delta, fragBorderColorLevel + delta, dist);\n float colorAmt = smoothstep(fragColorLevel - delta, fragColorLevel + delta, dist);\n\n vec4 color = fragBorderColor;\n color.a *= borderColorAmt;\n color = mix(color, fragColor, colorAmt);\n color.a *= opacity;\n\n gl_FragColor = color;\n }\n\n}\n"]); + markerOptions.vert = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract, paletteSize;\nuniform float pixelRatio;\nuniform sampler2D palette;\n\nconst float maxSize = 100.;\nconst float borderLevel = .5;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragPointSize, fragBorderRadius, fragWidth, fragBorderColorLevel, fragColorLevel;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = 2. * size * pixelRatio;\n fragPointSize = size * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragColor = color;\n fragBorderColor = borderColor;\n fragWidth = 1. / gl_PointSize;\n\n fragBorderColorLevel = clamp(borderLevel - borderLevel * borderSize / size, 0., 1.);\n fragColorLevel = clamp(borderLevel + (1. - borderLevel) * borderSize / size, 0., 1.);\n}"]); + this.drawMarker = regl(markerOptions); // draw circle + + var circleOptions = extend({}, shaderOptions); + circleOptions.frag = glslify(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\n\nuniform float opacity;\nvarying float fragBorderRadius, fragWidth;\n\nfloat smoothStep(float edge0, float edge1, float x) {\n\tfloat t;\n\tt = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n\treturn t * t * (3.0 - 2.0 * t);\n}\n\nvoid main() {\n\tfloat radius, alpha = 1.0, delta = fragWidth;\n\n\tradius = length(2.0 * gl_PointCoord.xy - 1.0);\n\n\tif (radius > 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]); + circleOptions.vert = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]); // polyfill IE + + if (ie) { + circleOptions.frag = circleOptions.frag.replace('smoothstep', 'smoothStep'); + markerOptions.frag = markerOptions.frag.replace('smoothstep', 'smoothStep'); + } + + this.drawCircle = regl(circleOptions); +} // single pass defaults + + +Scatter.defaults = { + color: 'black', + borderColor: 'transparent', + borderSize: 0, + size: 12, + opacity: 1, + marker: undefined, + viewport: null, + range: null, + pixelSize: null, + count: 0, + offset: 0, + bounds: null, + positions: [], + snap: 1e4 // update & redraw + +}; + +Scatter.prototype.render = function () { + if (arguments.length) { + this.update.apply(this, arguments); + } + + this.draw(); + return this; +}; // draw all groups or only indicated ones + + +Scatter.prototype.draw = function () { + var _this2 = this; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var groups = this.groups; // if directly array passed - treat as passes + + if (args.length === 1 && Array.isArray(args[0]) && (args[0][0] === null || Array.isArray(args[0][0]))) { + args = args[0]; + } // FIXME: remove once https://github.com/regl-project/regl/issues/474 resolved + + + this.regl._refresh(); + + if (args.length) { + for (var i = 0; i < args.length; i++) { + this.drawItem(i, args[i]); + } + } // draw all passes + else { + groups.forEach(function (group, i) { + _this2.drawItem(i); + }); + } + + return this; +}; // draw specific scatter group + + +Scatter.prototype.drawItem = function (id, els) { + var groups = this.groups; + var group = groups[id]; // debug viewport + // let { viewport } = group + // gl.enable(gl.SCISSOR_TEST); + // gl.scissor(viewport.x, viewport.y, viewport.width, viewport.height); + // gl.clearColor(0, 0, 0, .5); + // gl.clear(gl.COLOR_BUFFER_BIT); + + if (typeof els === 'number') { + id = els; + group = groups[els]; + els = null; + } + + if (!(group && group.count && group.opacity)) return; // draw circles + + if (group.activation[0]) { + // TODO: optimize this performance by making groups and regl.this props + this.drawCircle(this.getMarkerDrawOptions(0, group, els)); + } // draw all other available markers + + + var batch = []; + + for (var i = 1; i < group.activation.length; i++) { + if (!group.activation[i] || group.activation[i] !== true && !group.activation[i].data.length) continue; + batch.push.apply(batch, _toConsumableArray(this.getMarkerDrawOptions(i, group, els))); + } + + if (batch.length) { + this.drawMarker(batch); + } +}; // get options for the marker ids + + +Scatter.prototype.getMarkerDrawOptions = function (markerId, group, elements) { + var range = group.range, + tree = group.tree, + viewport = group.viewport, + activation = group.activation, + selectionBuffer = group.selectionBuffer, + count = group.count; + var regl = this.regl; // direct points + + if (!tree) { + // if elements array - draw unclustered points + if (elements) { + return [extend({}, group, { + markerTexture: this.markerTextures[markerId], + activation: activation[markerId], + count: elements.length, + elements: elements, + offset: 0 + })]; + } + + return [extend({}, group, { + markerTexture: this.markerTextures[markerId], + activation: activation[markerId], + offset: 0 + })]; + } // clustered points + + + var batch = []; + var lod = tree.range(range, { + lod: true, + px: [(range[2] - range[0]) / viewport.width, (range[3] - range[1]) / viewport.height] + }); // enable elements by using selection buffer + + if (elements) { + var markerActivation = activation[markerId]; + var mask = markerActivation.data; + var data = new Uint8Array(count); + + for (var i = 0; i < elements.length; i++) { + var id = elements[i]; + data[id] = mask ? mask[id] : 1; + } + + selectionBuffer.subdata(data); + } + + for (var l = lod.length; l--;) { + var _lod$l = _slicedToArray(lod[l], 2), + from = _lod$l[0], + to = _lod$l[1]; + + batch.push(extend({}, group, { + markerTexture: this.markerTextures[markerId], + activation: elements ? selectionBuffer : activation[markerId], + offset: from, + count: to - from + })); + } + + return batch; +}; // update groups options + + +Scatter.prototype.update = function () { + var _this3 = this; + + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + if (!args.length) return; // passes are as single array + + if (args.length === 1 && Array.isArray(args[0])) args = args[0]; + var groups = this.groups, + gl = this.gl, + regl = this.regl, + maxSize = this.maxSize, + maxColors = this.maxColors, + palette = this.palette; + this.groups = groups = args.map(function (options, i) { + var group = groups[i]; + if (options === undefined) return group; + if (options === null) options = { + positions: null + };else if (typeof options === 'function') options = { + ondraw: options + };else if (typeof options[0] === 'number') options = { + positions: options // copy options to avoid mutation & handle aliases + + }; + options = pick(options, { + positions: 'positions data points', + snap: 'snap cluster lod tree', + size: 'sizes size radius', + borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', + color: 'colors color fill fill-color fillColor', + borderColor: 'borderColors borderColor stroke stroke-color strokeColor', + marker: 'markers marker shape', + range: 'range dataBox databox', + viewport: 'viewport viewPort viewBox viewbox', + opacity: 'opacity alpha transparency', + bounds: 'bound bounds boundaries limits', + tooManyColors: 'tooManyColors palette paletteMode optimizePalette enablePalette' + }); + if (options.positions === null) options.positions = []; + if (options.tooManyColors != null) _this3.tooManyColors = options.tooManyColors; + + if (!group) { + groups[i] = group = { + id: i, + scale: null, + translate: null, + scaleFract: null, + translateFract: null, + // buffers for active markers + activation: [], + // buffer for filtered markers + selectionBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'stream', + type: 'uint8' + }), + // buffers with data: it is faster to switch them per-pass + // than provide one congregate buffer + sizeBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'uint8' + }), + colorBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'uint8' + }), + positionBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'float' + }), + positionFractBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'float' + }) + }; + options = extend({}, Scatter.defaults, options); + } // force update triggers + + + if (options.positions && !('marker' in options)) { + options.marker = group.marker; + delete group.marker; + } // updating markers cause recalculating snapping + + + if (options.marker && !('positions' in options)) { + options.positions = group.positions; + delete group.positions; + } // global count of points + + + var hasSize = 0, + hasColor = 0; + updateDiff(group, options, [{ + snap: true, + size: function size(s, group) { + if (s == null) s = Scatter.defaults.size; + hasSize += s && s.length ? 1 : 0; + return s; + }, + borderSize: function borderSize(s, group) { + if (s == null) s = Scatter.defaults.borderSize; + hasSize += s && s.length ? 1 : 0; + return s; + }, + opacity: parseFloat, + // add colors to palette, save references + color: function color(c, group) { + if (c == null) c = Scatter.defaults.color; + c = _this3.updateColor(c); + hasColor++; + return c; + }, + borderColor: function borderColor(c, group) { + if (c == null) c = Scatter.defaults.borderColor; + c = _this3.updateColor(c); + hasColor++; + return c; + }, + bounds: function bounds(_bounds, group, options) { + if (!('range' in options)) options.range = null; + return _bounds; + }, + positions: function positions(_positions, group, options) { + var snap = group.snap; + var positionBuffer = group.positionBuffer, + positionFractBuffer = group.positionFractBuffer, + selectionBuffer = group.selectionBuffer; // separate buffers for x/y coordinates + + if (_positions.x || _positions.y) { + if (_positions.x.length) { + group.xAttr = { + buffer: regl.buffer(_positions.x), + offset: 0, + stride: 4, + count: _positions.x.length + }; + } else { + group.xAttr = { + buffer: _positions.x.buffer, + offset: _positions.x.offset * 4 || 0, + stride: (_positions.x.stride || 1) * 4, + count: _positions.x.count + }; + } + + if (_positions.y.length) { + group.yAttr = { + buffer: regl.buffer(_positions.y), + offset: 0, + stride: 4, + count: _positions.y.length + }; + } else { + group.yAttr = { + buffer: _positions.y.buffer, + offset: _positions.y.offset * 4 || 0, + stride: (_positions.y.stride || 1) * 4, + count: _positions.y.count + }; + } + + group.count = Math.max(group.xAttr.count, group.yAttr.count); + return _positions; + } + + _positions = flatten(_positions, 'float64'); + var count = group.count = Math.floor(_positions.length / 2); + var bounds = group.bounds = count ? getBounds(_positions, 2) : null; // if range is not provided updated - recalc it + + if (!options.range && !group.range) { + delete group.range; + options.range = bounds; + } // reset marker + + + if (!options.marker && !group.marker) { + delete group.marker; + options.marker = null; + } // build cluster tree if required + + + if (snap && (snap === true || count > snap)) { + group.tree = cluster(_positions, { + bounds: bounds + }); + } // existing tree instance + else if (snap && snap.length) { + group.tree = snap; + } + + if (group.tree) { + var opts = { + primitive: 'points', + usage: 'static', + data: group.tree, + type: 'uint32' + }; + if (group.elements) group.elements(opts);else group.elements = regl.elements(opts); + } // update position buffers + + + positionBuffer({ + data: f32.float(_positions), + usage: 'dynamic' + }); + positionFractBuffer({ + data: f32.fract(_positions), + usage: 'dynamic' + }); // expand selectionBuffer + + selectionBuffer({ + data: new Uint8Array(count), + type: 'uint8', + usage: 'stream' + }); + return _positions; + } + }, { + // create marker ids corresponding to known marker textures + marker: function marker(markers, group, options) { + var activation = group.activation; // reset marker elements + + activation.forEach(function (buffer) { + return buffer && buffer.destroy && buffer.destroy(); + }); + activation.length = 0; // single sdf marker + + if (!markers || typeof markers[0] === 'number') { + var id = _this3.addMarker(markers); + + activation[id] = true; + } // per-point markers use mask buffers to enable markers in vert shader + else { + var markerMasks = []; + + for (var _i = 0, l = Math.min(markers.length, group.count); _i < l; _i++) { + var _id = _this3.addMarker(markers[_i]); + + if (!markerMasks[_id]) markerMasks[_id] = new Uint8Array(group.count); // enable marker by default + + markerMasks[_id][_i] = 1; + } + + for (var _id2 = 0; _id2 < markerMasks.length; _id2++) { + if (!markerMasks[_id2]) continue; + var opts = { + data: markerMasks[_id2], + type: 'uint8', + usage: 'static' + }; + + if (!activation[_id2]) { + activation[_id2] = regl.buffer(opts); + } else { + activation[_id2](opts); + } + + activation[_id2].data = markerMasks[_id2]; + } + } + + return markers; + }, + range: function range(_range, group, options) { + var bounds = group.bounds; // FIXME: why do we need this? + + if (!bounds) return; + if (!_range) _range = bounds; + group.scale = [1 / (_range[2] - _range[0]), 1 / (_range[3] - _range[1])]; + group.translate = [-_range[0], -_range[1]]; + group.scaleFract = f32.fract(group.scale); + group.translateFract = f32.fract(group.translate); + return _range; + }, + viewport: function viewport(vp) { + var rect = parseRect(vp || [gl.drawingBufferWidth, gl.drawingBufferHeight]); // normalize viewport to the canvas coordinates + // rect.y = gl.drawingBufferHeight - rect.height - rect.y + + return rect; + } + }]); // update size buffer, if needed + + if (hasSize) { + var _group = group, + count = _group.count, + size = _group.size, + borderSize = _group.borderSize, + sizeBuffer = _group.sizeBuffer; + var sizes = new Uint8Array(count * 2); + + if (size.length || borderSize.length) { + for (var _i2 = 0; _i2 < count; _i2++) { + // we downscale size to allow for fractions + sizes[_i2 * 2] = Math.round((size[_i2] == null ? size : size[_i2]) * 255 / maxSize); + sizes[_i2 * 2 + 1] = Math.round((borderSize[_i2] == null ? borderSize : borderSize[_i2]) * 255 / maxSize); + } + } + + sizeBuffer({ + data: sizes, + usage: 'dynamic' + }); + } // update color buffer if needed + + + if (hasColor) { + var _group2 = group, + _count = _group2.count, + color = _group2.color, + borderColor = _group2.borderColor, + colorBuffer = _group2.colorBuffer; + var colors; // if too many colors - put colors to buffer directly + + if (_this3.tooManyColors) { + if (color.length || borderColor.length) { + colors = new Uint8Array(_count * 8); + + for (var _i3 = 0; _i3 < _count; _i3++) { + var _colorId = color[_i3]; + colors[_i3 * 8] = palette[_colorId * 4]; + colors[_i3 * 8 + 1] = palette[_colorId * 4 + 1]; + colors[_i3 * 8 + 2] = palette[_colorId * 4 + 2]; + colors[_i3 * 8 + 3] = palette[_colorId * 4 + 3]; + var borderColorId = borderColor[_i3]; + colors[_i3 * 8 + 4] = palette[borderColorId * 4]; + colors[_i3 * 8 + 5] = palette[borderColorId * 4 + 1]; + colors[_i3 * 8 + 6] = palette[borderColorId * 4 + 2]; + colors[_i3 * 8 + 7] = palette[borderColorId * 4 + 3]; + } + } + } // if limited amount of colors - keep palette color picking + // that saves significant memory + else { + if (color.length || borderColor.length) { + // we need slight data increase by 2 due to vec4 borderId in shader + colors = new Uint8Array(_count * 4 + 2); + + for (var _i4 = 0; _i4 < _count; _i4++) { + // put color coords in palette texture + if (color[_i4] != null) { + colors[_i4 * 4] = color[_i4] % maxColors; + colors[_i4 * 4 + 1] = Math.floor(color[_i4] / maxColors); + } + + if (borderColor[_i4] != null) { + colors[_i4 * 4 + 2] = borderColor[_i4] % maxColors; + colors[_i4 * 4 + 3] = Math.floor(borderColor[_i4] / maxColors); + } + } + } + } + + colorBuffer({ + data: colors || new Uint8Array(0), + type: 'uint8', + usage: 'dynamic' + }); + } + + return group; + }); +}; // get (and create) marker texture id + + +Scatter.prototype.addMarker = function (sdf) { + var markerTextures = this.markerTextures, + regl = this.regl, + markerCache = this.markerCache; + var pos = sdf == null ? 0 : markerCache.indexOf(sdf); + if (pos >= 0) return pos; // convert sdf to 0..255 range + + var distArr; + + if (sdf instanceof Uint8Array || sdf instanceof Uint8ClampedArray) { + distArr = sdf; + } else { + distArr = new Uint8Array(sdf.length); + + for (var i = 0, l = sdf.length; i < l; i++) { + distArr[i] = sdf[i] * 255; + } + } + + var radius = Math.floor(Math.sqrt(distArr.length)); + pos = markerTextures.length; + markerCache.push(sdf); + markerTextures.push(regl.texture({ + channels: 1, + data: distArr, + radius: radius, + mag: 'linear', + min: 'linear' + })); + return pos; +}; // register color to palette, return it's index or list of indexes + + +Scatter.prototype.updateColor = function (colors) { + var paletteIds = this.paletteIds, + palette = this.palette, + maxColors = this.maxColors; + + if (!Array.isArray(colors)) { + colors = [colors]; + } + + var idx = []; // if color groups - flatten them + + if (typeof colors[0] === 'number') { + var grouped = []; + + if (Array.isArray(colors)) { + for (var i = 0; i < colors.length; i += 4) { + grouped.push(colors.slice(i, i + 4)); + } + } else { + for (var _i5 = 0; _i5 < colors.length; _i5 += 4) { + grouped.push(colors.subarray(_i5, _i5 + 4)); + } + } + + colors = grouped; + } + + for (var _i6 = 0; _i6 < colors.length; _i6++) { + var color = colors[_i6]; + color = rgba(color, 'uint8'); + var id = colorId(color, false); // if new color - save it + + if (paletteIds[id] == null) { + var pos = palette.length; + paletteIds[id] = Math.floor(pos / 4); + palette[pos] = color[0]; + palette[pos + 1] = color[1]; + palette[pos + 2] = color[2]; + palette[pos + 3] = color[3]; + } + + idx[_i6] = paletteIds[id]; + } // detect if too many colors in palette + + + if (!this.tooManyColors && palette.length > maxColors * 4) this.tooManyColors = true; // limit max color + + this.updatePalette(palette); // keep static index for single-color property + + return idx.length === 1 ? idx[0] : idx; +}; + +Scatter.prototype.updatePalette = function (palette) { + if (this.tooManyColors) return; + var maxColors = this.maxColors, + paletteTexture = this.paletteTexture; + var requiredHeight = Math.ceil(palette.length * .25 / maxColors); // pad data + + if (requiredHeight > 1) { + palette = palette.slice(); + + for (var i = palette.length * .25 % maxColors; i < requiredHeight * maxColors; i++) { + palette.push(0, 0, 0, 0); + } + } // ensure height + + + if (paletteTexture.height < requiredHeight) { + paletteTexture.resize(maxColors, requiredHeight); + } // update full data + + + paletteTexture.subimage({ + width: Math.min(palette.length * .25, maxColors), + height: requiredHeight, + data: palette + }, 0, 0); +}; // remove unused stuff + + +Scatter.prototype.destroy = function () { + this.groups.forEach(function (group) { + group.sizeBuffer.destroy(); + group.positionBuffer.destroy(); + group.positionFractBuffer.destroy(); + group.colorBuffer.destroy(); + group.activation.forEach(function (b) { + return b && b.destroy && b.destroy(); + }); + group.selectionBuffer.destroy(); + if (group.elements) group.elements.destroy(); + }); + this.groups.length = 0; + this.paletteTexture.destroy(); + this.markerTextures.forEach(function (txt) { + return txt && txt.destroy && txt.destroy(); + }); + return this; +}; + +var extend$1 = _dereq_('object-assign'); + +var reglScatter2d = function reglScatter2d(regl, options) { + var scatter$$1 = new scatter(regl, options); + var render = scatter$$1.render.bind(scatter$$1); // expose API + + extend$1(render, { + render: render, + update: scatter$$1.update.bind(scatter$$1), + draw: scatter$$1.draw.bind(scatter$$1), + destroy: scatter$$1.destroy.bind(scatter$$1), + regl: scatter$$1.regl, + gl: scatter$$1.gl, + canvas: scatter$$1.gl.canvas, + groups: scatter$$1.groups, + markers: scatter$$1.markerCache, + palette: scatter$$1.palette + }); + return render; +}; + +module.exports = reglScatter2d; + +},{"array-bounds":53,"color-id":106,"color-normalize":108,"flatten-vertex-data":216,"glslify":476,"is-iexplorer":402,"object-assign":437,"parse-rect":442,"pick-by-alias":448,"point-cluster":452,"to-float32":514,"update-diff":525}],476:[function(_dereq_,module,exports){ +arguments[4][392][0].apply(exports,arguments) +},{"dup":392}],477:[function(_dereq_,module,exports){ 'use strict' -var Scatter = _dereq_('./scatter') -var extend = _dereq_('object-assign') -module.exports = function (regl, options) { - var scatter = new Scatter(regl, options) - - var render = scatter.render.bind(scatter) - - // expose API - extend(render, { - render: render, - update: scatter.update.bind(scatter), - draw: scatter.draw.bind(scatter), - destroy: scatter.destroy.bind(scatter), - regl: scatter.regl, - gl: scatter.gl, - canvas: scatter.gl.canvas, - groups: scatter.groups, - markers: scatter.markerCache, - palette: scatter.palette - }) - - return render -} -},{"./scatter":476,"object-assign":437}],476:[function(_dereq_,module,exports){ -'use strict' - -var rgba = _dereq_('color-normalize') -var getBounds = _dereq_('array-bounds') -var colorId = _dereq_('color-id') -var cluster = _dereq_('point-cluster') -var extend = _dereq_('object-assign') -var glslify = _dereq_('glslify') +var createScatter = _dereq_('regl-scatter2d') var pick = _dereq_('pick-by-alias') -var updateDiff = _dereq_('update-diff') +var getBounds = _dereq_('array-bounds') +var raf = _dereq_('raf') +var arrRange = _dereq_('array-range') +var rect = _dereq_('parse-rect') var flatten = _dereq_('flatten-vertex-data') -var ie = _dereq_('is-iexplorer') -var f32 = _dereq_('to-float32') -var parseRect = _dereq_('parse-rect') -module.exports = Scatter +module.exports = SPLOM -function Scatter (regl, options) { - var this$1 = this; +// @constructor +function SPLOM (regl, options) { + if (!(this instanceof SPLOM)) { return new SPLOM(regl, options) } - if (!(this instanceof Scatter)) { return new Scatter(regl, options) } + // render passes + this.traces = [] - if (typeof regl === 'function') { - if (!options) { options = {} } - options.regl = regl - } - else { - options = regl - regl = null - } - - if (options && options.length) { options.positions = options } + // passes for scatter, combined across traces + this.passes = {} - regl = options.regl - - // persistent variables - var gl = regl._gl, paletteTexture, palette = [], paletteIds = {}, - - // state - groups = [], + this.regl = regl - // textures for marker keys - markerTextures = [null], - markerCache = [null] + // main scatter drawing instance + this.scatter = createScatter(regl) - var maxColors = 255, maxSize = 100 - - // direct color buffer mode - // IE does not support palette anyways - this.tooManyColors = ie - - // texture with color palette - paletteTexture = regl.texture({ - data: new Uint8Array(maxColors * 4), - width: maxColors, - height: 1, - type: 'uint8', - format: 'rgba', - wrapS: 'clamp', - wrapT: 'clamp', - mag: 'nearest', - min: 'nearest' - }) - - extend(this, { - regl: regl, - gl: gl, - groups: groups, - markerCache: markerCache, - markerTextures: markerTextures, - palette: palette, - paletteIds: paletteIds, - paletteTexture: paletteTexture, - maxColors: maxColors, - maxSize: maxSize, - canvas: gl.canvas - }) - - this.update(options) - - // common shader options - var shaderOptions = { - uniforms: { - pixelRatio: regl.context('pixelRatio'), - palette: paletteTexture, - paletteSize: function (ctx, prop) { return [this$1.tooManyColors ? 0 : maxColors, paletteTexture.height]; }, - scale: regl.prop('scale'), - scaleFract: regl.prop('scaleFract'), - translate: regl.prop('translate'), - translateFract: regl.prop('translateFract'), - opacity: regl.prop('opacity'), - marker: regl.prop('markerTexture'), - }, - - attributes: { - // FIXME: optimize these parts - x: function (ctx, prop) { return prop.xAttr || { - buffer: prop.positionBuffer, - stride: 8, - offset: 0 - }; }, - y: function (ctx, prop) { return prop.yAttr || { - buffer: prop.positionBuffer, - stride: 8, - offset: 4 - }; }, - xFract: function (ctx, prop) { return prop.xAttr ? { constant: [0, 0] } : { - buffer: prop.positionFractBuffer, - stride: 8, - offset: 0 - }; }, - yFract: function (ctx, prop) { return prop.yAttr ? { constant: [0, 0] } : { - buffer: prop.positionFractBuffer, - stride: 8, - offset: 4 - }; }, - size: function (ctx, prop) { return prop.size.length ? { - buffer: prop.sizeBuffer, - stride: 2, - offset: 0 - } : { - constant: [ Math.round(prop.size * 255 / this$1.maxSize) ] - }; }, - borderSize: function (ctx, prop) { return prop.borderSize.length ? { - buffer: prop.sizeBuffer, - stride: 2, - offset: 1 - } : { - constant: [ Math.round(prop.borderSize * 255 / this$1.maxSize) ] - }; }, - colorId: function (ctx, prop) { return prop.color.length ? { - buffer: prop.colorBuffer, - stride: this$1.tooManyColors ? 8 : 4, - offset: 0 - } : { - constant: this$1.tooManyColors ? palette.slice(prop.color * 4, prop.color * 4 + 4) : [ prop.color ] - }; }, - borderColorId: function (ctx, prop) { return prop.borderColor.length ? { - buffer: prop.colorBuffer, - stride: this$1.tooManyColors ? 8 : 4, - offset: this$1.tooManyColors ? 4 : 2 - } : { - constant: this$1.tooManyColors ? palette.slice(prop.borderColor * 4, prop.borderColor * 4 + 4) : [ prop.borderColor ] - }; }, - isActive: function (ctx, prop) { return prop.activation === true ? { constant: [1] } : prop.activation ? prop.activation : { constant: [0] }; } - }, - - blend: { - enable: true, - color: [0,0,0,1], - - // photoshop blending - func: { - srcRGB: 'src alpha', - dstRGB: 'one minus src alpha', - srcAlpha: 'one minus dst alpha', - dstAlpha: 'one' - } - }, - - scissor: { - enable: true, - box: regl.prop('viewport') - }, - viewport: regl.prop('viewport'), - - stencil: {enable: false}, - depth: {enable: false}, - - elements: regl.prop('elements'), - count: regl.prop('count'), - offset: regl.prop('offset'), - - primitive: 'points' - } - - // draw sdf-marker - var markerOptions = extend({}, shaderOptions) - markerOptions.frag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragWidth, fragBorderColorLevel, fragColorLevel;\n\nuniform sampler2D marker;\nuniform float pixelRatio, opacity;\n\nfloat smoothStep(float x, float y) {\n return 1.0 / (1.0 + exp(50.0*(x - y)));\n}\n\nvoid main() {\n float dist = texture2D(marker, gl_PointCoord).r, delta = fragWidth;\n\n // max-distance alpha\n if (dist < 0.003) discard;\n\n // null-border case\n if (fragBorderColorLevel == fragColorLevel || fragBorderColor.a == 0.) {\n float colorAmt = smoothstep(.5 - delta, .5 + delta, dist);\n gl_FragColor = vec4(fragColor.rgb, colorAmt * fragColor.a * opacity);\n }\n else {\n float borderColorAmt = smoothstep(fragBorderColorLevel - delta, fragBorderColorLevel + delta, dist);\n float colorAmt = smoothstep(fragColorLevel - delta, fragColorLevel + delta, dist);\n\n vec4 color = fragBorderColor;\n color.a *= borderColorAmt;\n color = mix(color, fragColor, colorAmt);\n color.a *= opacity;\n\n gl_FragColor = color;\n }\n\n}\n"]) - markerOptions.vert = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract, paletteSize;\nuniform float pixelRatio;\nuniform sampler2D palette;\n\nconst float maxSize = 100.;\nconst float borderLevel = .5;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragPointSize, fragBorderRadius,\n fragWidth, fragBorderColorLevel, fragColorLevel;\n\nvec2 paletteCoord(float id) {\n return vec2(\n (mod(id, paletteSize.x) + .5) / paletteSize.x,\n (floor(id / paletteSize.x) + .5) / paletteSize.y\n );\n}\nvec2 paletteCoord(vec2 id) {\n return vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n );\n}\nvec4 getColor(vec4 id) {\n // zero-palette means we deal with direct buffer\n if (paletteSize.x == 0.) return id / 255.;\n return texture2D(palette, paletteCoord(id.xy));\n}\n\nvoid main() {\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = 2. * size * pixelRatio;\n fragPointSize = size * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragColor = color;\n fragBorderColor = borderColor;\n fragWidth = 1. / gl_PointSize;\n\n fragBorderColorLevel = clamp(borderLevel - borderLevel * borderSize / size, 0., 1.);\n fragColorLevel = clamp(borderLevel + (1. - borderLevel) * borderSize / size, 0., 1.);\n}\n"]) - - this.drawMarker = regl(markerOptions) - - // draw circle - var circleOptions = extend({}, shaderOptions) - circleOptions.frag = glslify(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\n\nuniform float opacity;\nvarying float fragBorderRadius, fragWidth;\n\nfloat smoothStep(float edge0, float edge1, float x) {\n\tfloat t;\n\tt = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n\treturn t * t * (3.0 - 2.0 * t);\n}\n\nvoid main() {\n\tfloat radius, alpha = 1.0, delta = fragWidth;\n\n\tradius = length(2.0 * gl_PointCoord.xy - 1.0);\n\n\tif (radius > 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]) - circleOptions.vert = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nvec2 paletteCoord(float id) {\n return vec2(\n (mod(id, paletteSize.x) + .5) / paletteSize.x,\n (floor(id / paletteSize.x) + .5) / paletteSize.y\n );\n}\nvec2 paletteCoord(vec2 id) {\n return vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n );\n}\n\nvec4 getColor(vec4 id) {\n // zero-palette means we deal with direct buffer\n if (paletteSize.x == 0.) return id / 255.;\n return texture2D(palette, paletteCoord(id.xy));\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]) - - // polyfill IE - if (ie) { - circleOptions.frag = circleOptions.frag.replace('smoothstep', 'smoothStep') - markerOptions.frag = markerOptions.frag.replace('smoothstep', 'smoothStep') - } - - this.drawCircle = regl(circleOptions) -} - -// single pass defaults -Scatter.defaults = { - color: 'black', - borderColor: 'transparent', - borderSize: 0, - size: 12, - opacity: 1, - marker: undefined, - viewport: null, - range: null, - pixelSize: null, - count: 0, - offset: 0, - bounds: null, - positions: [], - snap: 1e4 + this.canvas = this.scatter.canvas } -// update & redraw -Scatter.prototype.render = function () { +// update & draw passes once per frame +SPLOM.prototype.render = function () { + var this$1 = this; var ref; var args = [], len = arguments.length; @@ -62207,1281 +63080,536 @@ Scatter.prototype.render = function () { (ref = this).update.apply(ref, args) } - this.draw() + if (this.regl.attributes.preserveDrawingBuffer) { return this.draw() } + + // make sure draw is not called more often than once a frame + if (this.dirty) { + if (this.planned == null) { + this.planned = raf(function () { + this$1.draw() + this$1.dirty = true + this$1.planned = null + }) + } + } + else { + this.draw() + this.dirty = true + raf(function () { + this$1.dirty = false + }) + } return this } -// draw all groups or only indicated ones -Scatter.prototype.draw = function () { +// update passes +SPLOM.prototype.update = function () { var this$1 = this; + var ref; + var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - var ref = this; - var groups = ref.groups; + while ( len-- ) args[ len ] = arguments[ len ]; + if (!args.length) { return } - // if directly array passed - treat as passes - if (args.length === 1 && Array.isArray(args[0]) && (args[0][0] === null || Array.isArray(args[0][0]))) { - args = args[0] + for (var i = 0; i < args.length; i++) { + this$1.updateItem(i, args[i]) } - // FIXME: remove once https://github.com/regl-project/regl/issues/474 resolved - this.regl._refresh() + // remove nulled passes + this.traces = this.traces.filter(Boolean) - if (args.length) { - for (var i = 0; i < args.length; i++) { - this$1.drawItem(i, args[i]) + // FIXME: update passes independently + var passes = [] + var offset = 0 + for (var i$1 = 0; i$1 < this.traces.length; i$1++) { + var trace = this$1.traces[i$1] + var tracePasses = this$1.traces[i$1].passes + for (var j = 0; j < tracePasses.length; j++) { + passes.push(this$1.passes[tracePasses[j]]) } + // save offset of passes + trace.passOffset = offset + offset += trace.passes.length } - // draw all passes - else { - groups.forEach(function (group, i) { - this$1.drawItem(i) - }) - } + + (ref = this.scatter).update.apply(ref, passes) return this } -// draw specific scatter group -Scatter.prototype.drawItem = function (id, els) { + +// update trace by index, not supposed to be called directly +SPLOM.prototype.updateItem = function (i, options) { var this$1 = this; var ref = this; - var groups = ref.groups; - var group = groups[id] - - // debug viewport - // let { viewport } = group - // gl.enable(gl.SCISSOR_TEST); - // gl.scissor(viewport.x, viewport.y, viewport.width, viewport.height); - // gl.clearColor(0, 0, 0, .5); - // gl.clear(gl.COLOR_BUFFER_BIT); - - if (typeof els === 'number') { - id = els - group = groups[els] - els = null - } - - if (!(group && group.count && group.opacity)) { return } + var regl = ref.regl; - // draw circles - if (group.activation[0]) { - // TODO: optimize this performance by making groups and regl.this props - this.drawCircle(this.getMarkerDrawOptions(0, group, els)) + // remove pass if null + if (options === null) { + this.traces[i] = null + return this } - // draw all other available markers - var batch = [] + if (!options) { return this } + + var o = pick(options, { + data: 'data items columns rows values dimensions samples x', + snap: 'snap cluster', + size: 'sizes size radius', + color: 'colors color fill fill-color fillColor', + opacity: 'opacity alpha transparency opaque', + borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', + borderColor: 'borderColors borderColor bordercolor stroke stroke-color strokeColor', + marker: 'markers marker shape', + range: 'range ranges databox dataBox', + viewport: 'viewport viewBox viewbox', + domain: 'domain domains area areas', + padding: 'pad padding paddings pads margin margins', + transpose: 'transpose transposed', + diagonal: 'diagonal diag showDiagonal', + upper: 'upper up top upperhalf upperHalf showupperhalf showUpper showUpperHalf', + lower: 'lower low bottom lowerhalf lowerHalf showlowerhalf showLowerHalf showLower' + }) - for (var i = 1; i < group.activation.length; i++) { - if (!group.activation[i] || (group.activation[i] !== true && !group.activation[i].data.length)) { continue } + // we provide regl buffer per-trace, since trace data can be changed + var trace = (this.traces[i] || (this.traces[i] = { + id: i, + buffer: regl.buffer({ + usage: 'dynamic', + type: 'float', + data: new Uint8Array() + }), + color: 'black', + marker: null, + size: 12, + borderColor: 'transparent', + borderSize: 1, + viewport: rect([regl._gl.drawingBufferWidth, regl._gl.drawingBufferHeight]), + padding: [0, 0, 0, 0], + opacity: 1, + diagonal: true, + upper: true, + lower: true + })) - batch.push.apply(batch, this$1.getMarkerDrawOptions(i, group, els)) - } - if (batch.length) { - this.drawMarker(batch) + // save styles + if (o.color != null) { + trace.color = o.color } -} + if (o.size != null) { + trace.size = o.size + } + if (o.marker != null) { + trace.marker = o.marker + } + if (o.borderColor != null) { + trace.borderColor = o.borderColor + } + if (o.borderSize != null) { + trace.borderSize = o.borderSize + } + if (o.opacity != null) { + trace.opacity = o.opacity + } + if (o.viewport) { + trace.viewport = rect(o.viewport) + } + if (o.diagonal != null) { trace.diagonal = o.diagonal } + if (o.upper != null) { trace.upper = o.upper } + if (o.lower != null) { trace.lower = o.lower } -// get options for the marker ids -Scatter.prototype.getMarkerDrawOptions = function(markerId, group, elements) { - var this$1 = this; + // put flattened data into buffer + if (o.data) { + trace.buffer(flatten(o.data)) + trace.columns = o.data.length + trace.count = o.data[0].length - var range = group.range; - var tree = group.tree; - var viewport = group.viewport; - var activation = group.activation; - var selectionBuffer = group.selectionBuffer; - var count = group.count; - var ref = this; - var regl = ref.regl; + // detect bounds per-column + trace.bounds = [] - // direct points - if (!tree) { - // if elements array - draw unclustered points - if (elements) { - return [extend({}, group, { - markerTexture: this.markerTextures[markerId], - activation: activation[markerId], - count: elements.length, - elements: elements, - offset: 0 - })] + for (var i$1 = 0; i$1 < trace.columns; i$1++) { + trace.bounds[i$1] = getBounds(o.data[i$1], 1) } - - return [ extend({}, group, { - markerTexture: this.markerTextures[markerId], - activation: activation[markerId], - offset: 0 - }) ] } - // clustered points - var batch = [] - - var lod = tree.range(range, { lod: true, px: [ - (range[2] - range[0]) / viewport.width, - (range[3] - range[1]) / viewport.height - ]}) - - // enable elements by using selection buffer - if (elements) { - var markerActivation = activation[markerId] - var mask = markerActivation.data - var data = new Uint8Array(count) - for (var i = 0; i < elements.length; i++) { - var id = elements[i] - data[id] = mask ? mask[id] : 1 - } - selectionBuffer.subdata(data) + // add proper range updating markers + var multirange + if (o.range) { + trace.range = o.range + multirange = trace.range && typeof trace.range[0] !== 'number' } - for (var l = lod.length; l--;) { - var ref$1 = lod[l]; - var from = ref$1[0]; - var to = ref$1[1]; - - batch.push(extend({}, group, { - markerTexture: this$1.markerTextures[markerId], - activation: elements ? selectionBuffer : activation[markerId], - offset: from, - count: to - from - })) + if (o.domain) { + trace.domain = o.domain } - - return batch -} - -// update groups options -Scatter.prototype.update = function () { - var this$1 = this; - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - if (!args.length) { return } - - // passes are as single array - if (args.length === 1 && Array.isArray(args[0])) { args = args[0] } - - var ref = this; - var groups = ref.groups; - var gl = ref.gl; - var regl = ref.regl; - var maxSize = ref.maxSize; - var maxColors = ref.maxColors; - var palette = ref.palette; - - this.groups = groups = args.map(function (options, i) { - var group = groups[i] - - if (options === undefined) { return group } - - if (options === null) { options = { positions: null } } - else if (typeof options === 'function') { options = { ondraw: options } } - else if (typeof options[0] === 'number') { options = { positions: options } } - - // copy options to avoid mutation & handle aliases - options = pick(options, { - positions: 'positions data points', - snap: 'snap cluster lod tree', - size: 'sizes size radius', - borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', - color: 'colors color fill fill-color fillColor', - borderColor: 'borderColors borderColor stroke stroke-color strokeColor', - marker: 'markers marker shape', - range: 'range dataBox databox', - viewport: 'viewport viewPort viewBox viewbox', - opacity: 'opacity alpha transparency', - bounds: 'bound bounds boundaries limits' - }) - - if (options.positions === null) { options.positions = [] } - - if (!group) { - groups[i] = group = { - id: i, - scale: null, - translate: null, - scaleFract: null, - translateFract: null, - - // buffers for active markers - activation: [], - - // buffer for filtered markers - selectionBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'stream', - type: 'uint8' - }), - - // buffers with data: it is faster to switch them per-pass - // than provide one congregate buffer - sizeBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'uint8' - }), - colorBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'uint8' - }), - positionBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'float' - }), - positionFractBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'float' - }) - } - options = extend({}, Scatter.defaults, options) + var multipadding = false + if (o.padding != null) { + // multiple paddings + if (Array.isArray(o.padding) && o.padding.length === trace.columns && typeof o.padding[o.padding.length - 1] === 'number') { + trace.padding = o.padding.map(getPad) + multipadding = true } - - // force update triggers - if (options.positions && !('marker' in options)) { - options.marker = group.marker - delete group.marker - } - - // updating markers cause recalculating snapping - if (options.marker && !('positions' in options)) { - options.positions = group.positions - delete group.positions + // single padding + else { + trace.padding = getPad(o.padding) } + } - // global count of points - var hasSize = 0, hasColor = 0 - - updateDiff(group, options, [{ - snap: true, - size: function (s, group) { - if (s == null) { s = Scatter.defaults.size } - hasSize += s && s.length ? 1 : 0 - return s - }, - borderSize: function (s, group) { - if (s == null) { s = Scatter.defaults.borderSize } - hasSize += s && s.length ? 1 : 0 - return s - }, - opacity: parseFloat, - - // add colors to palette, save references - color: function (c, group) { - if (c == null) { c = Scatter.defaults.color } - c = this$1.updateColor(c) - hasColor++ - return c - }, - borderColor: function (c, group) { - if (c == null) { c = Scatter.defaults.borderColor } - c = this$1.updateColor(c) - hasColor++ - return c - }, - - bounds: function (bounds, group, options) { - if (!('range' in options)) { options.range = null } - return bounds - }, - - positions: function (positions, group, options) { - var snap = group.snap; - var positionBuffer = group.positionBuffer; - var positionFractBuffer = group.positionFractBuffer; - var selectionBuffer = group.selectionBuffer; - - // separate buffers for x/y coordinates - if (positions.x || positions.y) { - if (positions.x.length) { - group.xAttr = { - buffer: regl.buffer(positions.x), - offset: 0, - stride: 4, - count: positions.x.length - } - } - else { - group.xAttr = { - buffer: positions.x.buffer, - offset: positions.x.offset * 4 || 0, - stride: (positions.x.stride || 1) * 4, - count: positions.x.count - } - } - if (positions.y.length) { - group.yAttr = { - buffer: regl.buffer(positions.y), - offset: 0, - stride: 4, - count: positions.y.length - } - } - else { - group.yAttr = { - buffer: positions.y.buffer, - offset: positions.y.offset * 4 || 0, - stride: (positions.y.stride || 1) * 4, - count: positions.y.count - } - } - group.count = Math.max(group.xAttr.count, group.yAttr.count) - - return positions - } + // create passes + var m = trace.columns + var n = trace.count - positions = flatten(positions, 'float64') + var w = trace.viewport.width + var h = trace.viewport.height + var left = trace.viewport.x + var top = trace.viewport.y + var iw = w / m + var ih = h / m - var count = group.count = Math.floor(positions.length / 2) - var bounds = group.bounds = count ? getBounds(positions, 2) : null + trace.passes = [] - // if range is not provided updated - recalc it - if (!options.range && !group.range) { - delete group.range - options.range = bounds - } + for (var i$2 = 0; i$2 < m; i$2++) { + for (var j = 0; j < m; j++) { + if (!trace.diagonal && j === i$2) { continue } + if (!trace.upper && i$2 > j) { continue } + if (!trace.lower && i$2 < j) { continue } - // reset marker - if (!options.marker && !group.marker) { - delete group.marker; - options.marker = null; - } + var key = passId(trace.id, i$2, j) - // build cluster tree if required - if (snap && (snap === true || count > snap)) { - group.tree = cluster(positions, { bounds: bounds }) - } - // existing tree instance - else if (snap && snap.length) { - group.tree = snap - } + var pass = this$1.passes[key] || (this$1.passes[key] = {}) - if (group.tree) { - var opts = { - primitive: 'points', - usage: 'static', - data: group.tree, - type: 'uint32' + if (o.data) { + if (o.transpose) { + pass.positions = { + x: {buffer: trace.buffer, offset: j, count: n, stride: m}, + y: {buffer: trace.buffer, offset: i$2, count: n, stride: m} } - if (group.elements) { group.elements(opts) } - else { group.elements = regl.elements(opts) } - } - - // update position buffers - positionBuffer({ - data: f32.float(positions), - usage: 'dynamic' - }) - positionFractBuffer({ - data: f32.fract(positions), - usage: 'dynamic' - }) - - // expand selectionBuffer - selectionBuffer({ - data: new Uint8Array(count), - type: 'uint8', - usage: 'stream' - }) - - return positions - } - }, { - // create marker ids corresponding to known marker textures - marker: function (markers, group, options) { - var activation = group.activation; - - // reset marker elements - activation.forEach(function (buffer) { return buffer && buffer.destroy && buffer.destroy(); }) - activation.length = 0 - - // single sdf marker - if (!markers || typeof markers[0] === 'number') { - var id = this$1.addMarker(markers) - activation[id] = true } - - // per-point markers use mask buffers to enable markers in vert shader else { - var markerMasks = [] - - for (var i = 0, l = Math.min(markers.length, group.count); i < l; i++) { - var id$1 = this$1.addMarker(markers[i]) - - if (!markerMasks[id$1]) { markerMasks[id$1] = new Uint8Array(group.count) } - - // enable marker by default - markerMasks[id$1][i] = 1 - } - - for (var id$2 = 0; id$2 < markerMasks.length; id$2++) { - if (!markerMasks[id$2]) { continue } - - var opts = { - data: markerMasks[id$2], - type: 'uint8', - usage: 'static' - } - if (!activation[id$2]) { - activation[id$2] = regl.buffer(opts) - } - else { - activation[id$2](opts) - } - - activation[id$2].data = markerMasks[id$2] + pass.positions = { + x: {buffer: trace.buffer, offset: j * n, count: n}, + y: {buffer: trace.buffer, offset: i$2 * n, count: n} } } - return markers - }, - - range: function (range, group, options) { - var bounds = group.bounds - - // FIXME: why do we need this? - if (!bounds) { return } - if (!range) { range = bounds } - - group.scale = [1 / (range[2] - range[0]), 1 / (range[3] - range[1])] - group.translate = [-range[0], -range[1]] - - group.scaleFract = f32.fract(group.scale) - group.translateFract = f32.fract(group.translate) - - return range - }, - - viewport: function (vp) { - var rect = parseRect(vp || [ - gl.drawingBufferWidth, - gl.drawingBufferHeight - ]) - - // normalize viewport to the canvas coordinates - // rect.y = gl.drawingBufferHeight - rect.height - rect.y - - return rect - } - }]) - - // update size buffer, if needed - if (hasSize) { - var count = group.count; - var size = group.size; - var borderSize = group.borderSize; - var sizeBuffer = group.sizeBuffer; - - var sizes = new Uint8Array(count*2) - if (size.length || borderSize.length) { - for (var i$1 = 0; i$1 < count; i$1++) { - // we downscale size to allow for fractions - sizes[i$1*2] = Math.round((size[i$1] == null ? size : size[i$1]) * 255 / maxSize) - sizes[i$1*2 + 1] = Math.round((borderSize[i$1] == null ? borderSize : borderSize[i$1]) * 255 / maxSize) - } + pass.bounds = getBox(trace.bounds, i$2, j) } - sizeBuffer({ - data: sizes, - usage: 'dynamic' - }) - } - // update color buffer if needed - if (hasColor) { - var count$1 = group.count; - var color = group.color; - var borderColor = group.borderColor; - var colorBuffer = group.colorBuffer; - var colors - - // if too many colors - put colors to buffer directly - if (this$1.tooManyColors) { - if (color.length || borderColor.length) { - colors = new Uint8Array(count$1 * 8) - for (var i$2 = 0; i$2 < count$1; i$2++) { - var colorId = color[i$2] - colors[i$2*8] = palette[colorId*4] - colors[i$2*8 + 1] = palette[colorId*4 + 1] - colors[i$2*8 + 2] = palette[colorId*4 + 2] - colors[i$2*8 + 3] = palette[colorId*4 + 3] - - var borderColorId = borderColor[i$2] - colors[i$2*8 + 4] = palette[borderColorId*4] - colors[i$2*8 + 5] = palette[borderColorId*4 + 1] - colors[i$2*8 + 6] = palette[borderColorId*4 + 2] - colors[i$2*8 + 7] = palette[borderColorId*4 + 3] - } + if (o.domain || o.viewport || o.data) { + var pad = multipadding ? getBox(trace.padding, i$2, j) : trace.padding + if (trace.domain) { + var ref$1 = getBox(trace.domain, i$2, j); + var lox = ref$1[0]; + var loy = ref$1[1]; + var hix = ref$1[2]; + var hiy = ref$1[3]; + + pass.viewport = [ + left + lox * w + pad[0], + top + loy * h + pad[1], + left + hix * w - pad[2], + top + hiy * h - pad[3] + ] } - } - - // if limited amount of colors - keep palette color picking - // that saves significant memory - else { - if (color.length || borderColor.length) { - // we need slight data increase by 2 due to vec4 borderId in shader - colors = new Uint8Array(count$1 * 4 + 2) - for (var i$3 = 0; i$3 < count$1; i$3++) { - // put color coords in palette texture - if (color[i$3] != null) { - colors[i$3*4] = color[i$3] % maxColors - colors[i$3*4 + 1] = Math.floor(color[i$3] / maxColors) - } - if (borderColor[i$3] != null) { - colors[i$3*4 + 2] = borderColor[i$3] % maxColors - colors[i$3*4 + 3] = Math.floor(borderColor[i$3] / maxColors) - } - } + // consider auto-domain equipartial + else { + pass.viewport = [ + left + j * iw + iw * pad[0], + top + i$2 * ih + ih * pad[1], + left + (j + 1) * iw - iw * pad[2], + top + (i$2 + 1) * ih - ih * pad[3] + ] } } - colorBuffer({ - data: colors || new Uint8Array(0), - type: 'uint8', - usage: 'dynamic' - }) - } + if (o.color) { pass.color = trace.color } + if (o.size) { pass.size = trace.size } + if (o.marker) { pass.marker = trace.marker } + if (o.borderSize) { pass.borderSize = trace.borderSize } + if (o.borderColor) { pass.borderColor = trace.borderColor } + if (o.opacity) { pass.opacity = trace.opacity } - return group - }) -} - - -// get (and create) marker texture id -Scatter.prototype.addMarker = function (sdf) { - var ref = this; - var markerTextures = ref.markerTextures; - var regl = ref.regl; - var markerCache = ref.markerCache; - - var pos = sdf == null ? 0 : markerCache.indexOf(sdf) - - if (pos >= 0) { return pos } + if (o.range) { + pass.range = multirange ? getBox(trace.range, i$2, j) : trace.range || pass.bounds + } - // convert sdf to 0..255 range - var distArr - if (sdf instanceof Uint8Array || sdf instanceof Uint8ClampedArray) { - distArr = sdf - } - else { - distArr = new Uint8Array(sdf.length) - for (var i = 0, l = sdf.length; i < l; i++) { - distArr[i] = sdf[i] * 255 + trace.passes.push(key) } } - var radius = Math.floor(Math.sqrt(distArr.length)) - - pos = markerTextures.length - - markerCache.push(sdf) - markerTextures.push(regl.texture({ - channels: 1, - data: distArr, - radius: radius, - mag: 'linear', - min: 'linear' - })) - - return pos + return this } -// register color to palette, return it's index or list of indexes -Scatter.prototype.updateColor = function (colors) { - var ref = this; - var paletteIds = ref.paletteIds; - var palette = ref.palette; - var maxColors = ref.maxColors; - if (!Array.isArray(colors)) { - colors = [colors] +// draw all or passed passes +SPLOM.prototype.draw = function () { + var this$1 = this; + var ref$2; + + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + if (!args.length) { + this.scatter.draw() } - - var idx = [] - - // if color groups - flatten them - if (typeof colors[0] === 'number') { - var grouped = [] - - if (Array.isArray(colors)) { - for (var i = 0; i < colors.length; i+=4) { - grouped.push(colors.slice(i, i+4)) + else { + var idx = [] + for (var i = 0; i < args.length; i++) { + // draw(0, 2, 5) - draw traces + if (typeof args[i] === 'number' ) { + var ref = this$1.traces[args[i]]; + var passes = ref.passes; + var passOffset = ref.passOffset; + idx.push.apply(idx, arrRange(passOffset, passOffset + passes.length)) } - } - else { - for (var i$1 = 0; i$1 < colors.length; i$1+=4) { - grouped.push(colors.subarray(i$1, i$1+4)) + // draw([0, 1, 2 ...], [3, 4, 5]) - draw points + else if (args[i].length) { + var els = args[i] + var ref$1 = this$1.traces[i]; + var passes$1 = ref$1.passes; + var passOffset$1 = ref$1.passOffset; + passes$1 = passes$1.map(function (passId, i) { + idx[passOffset$1 + i] = els + }) } } - - colors = grouped + (ref$2 = this.scatter).draw.apply(ref$2, idx) } - for (var i$2 = 0; i$2 < colors.length; i$2++) { - var color = colors[i$2] + return this +} - color = rgba(color, 'uint8') - var id = colorId(color, false) +// dispose resources +SPLOM.prototype.destroy = function () { + this.traces.forEach(function (trace) { + if (trace.buffer && trace.buffer.destroy) { trace.buffer.destroy() } + }) + this.traces = null + this.passes = null - // if new color - save it - if (paletteIds[id] == null) { - var pos = palette.length - paletteIds[id] = Math.floor(pos / 4) - palette[pos] = color[0] - palette[pos+1] = color[1] - palette[pos+2] = color[2] - palette[pos+3] = color[3] - } + this.scatter.destroy() - idx[i$2] = paletteIds[id] - } + return this +} - // detect if too many colors in palette - if (!this.tooManyColors && palette.length > maxColors * maxColors * 4) { this.tooManyColors = true } - // limit max color - this.updatePalette(palette) +// return pass corresponding to trace i- j- square +function passId (trace, i, j) { + var id = (trace.id != null ? trace.id : trace) + var n = i + var m = j + var key = id << 16 | (n & 0xff) << 8 | m & 0xff - // keep static index for single-color property - return idx.length === 1 ? idx[0] : idx + return key } -Scatter.prototype.updatePalette = function (palette) { - if (this.tooManyColors) { return } - - var ref = this; - var maxColors = ref.maxColors; - var paletteTexture = ref.paletteTexture; - var requiredHeight = Math.ceil(palette.length * .25 / maxColors) +// return bounding box corresponding to a pass +function getBox (items, i, j) { + var ilox, iloy, ihix, ihiy, jlox, jloy, jhix, jhiy + var iitem = items[i], jitem = items[j] - // pad data - if (requiredHeight > 1) { - palette = palette.slice() - for (var i = (palette.length * .25) % maxColors; i < requiredHeight * maxColors; i++) { - palette.push(0, 0, 0, 0) - } + if (iitem.length > 2) { + ilox = iitem[0] + ihix = iitem[2] + iloy = iitem[1] + ihiy = iitem[3] + } + else if (iitem.length) { + ilox = iloy = iitem[0] + ihix = ihiy = iitem[1] + } + else { + ilox = iitem.x + iloy = iitem.y + ihix = iitem.x + iitem.width + ihiy = iitem.y + iitem.height } - // ensure height - if (paletteTexture.height < requiredHeight) { - paletteTexture.resize(maxColors, requiredHeight) + if (jitem.length > 2) { + jlox = jitem[0] + jhix = jitem[2] + jloy = jitem[1] + jhiy = jitem[3] + } + else if (jitem.length) { + jlox = jloy = jitem[0] + jhix = jhiy = jitem[1] + } + else { + jlox = jitem.x + jloy = jitem.y + jhix = jitem.x + jitem.width + jhiy = jitem.y + jitem.height } - // update full data - paletteTexture.subimage({ - width: Math.min(palette.length * .25, maxColors), - height: requiredHeight, - data: palette - }, 0, 0) + return [ jlox, iloy, jhix, ihiy ] } -// remove unused stuff -Scatter.prototype.destroy = function () { - this.groups.forEach(function (group) { - group.sizeBuffer.destroy() - group.positionBuffer.destroy() - group.positionFractBuffer.destroy() - group.colorBuffer.destroy() - group.activation.forEach(function (b) { return b && b.destroy && b.destroy(); }) - group.selectionBuffer.destroy() - - if (group.elements) { group.elements.destroy() } - }) - this.groups.length = 0 - - this.paletteTexture.destroy() - - this.markerTextures.forEach(function (txt) { return txt && txt.destroy && txt.destroy(); }) - return this +function getPad (arg) { + if (typeof arg === 'number') { return [arg, arg, arg, arg] } + else if (arg.length === 2) { return [arg[0], arg[1], arg[0], arg[1]] } + else { + var box = rect(arg) + return [box.x, box.y, box.x + box.width, box.y + box.height] + } } -},{"array-bounds":53,"color-id":106,"color-normalize":108,"flatten-vertex-data":216,"glslify":392,"is-iexplorer":402,"object-assign":437,"parse-rect":442,"pick-by-alias":448,"point-cluster":452,"to-float32":515,"update-diff":526}],477:[function(_dereq_,module,exports){ -'use strict' - - -var createScatter = _dereq_('regl-scatter2d/scatter') -var pick = _dereq_('pick-by-alias') -var getBounds = _dereq_('array-bounds') -var raf = _dereq_('raf') -var arrRange = _dereq_('array-range') -var rect = _dereq_('parse-rect') -var flatten = _dereq_('flatten-vertex-data') - - -module.exports = SPLOM - - -// @constructor -function SPLOM (regl, options) { - if (!(this instanceof SPLOM)) { return new SPLOM(regl, options) } - - // render passes - this.traces = [] - - // passes for scatter, combined across traces - this.passes = {} - - this.regl = regl - - // main scatter drawing instance - this.scatter = createScatter(regl) - - this.canvas = this.scatter.canvas -} - - -// update & draw passes once per frame -SPLOM.prototype.render = function () { - var this$1 = this; - var ref; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (args.length) { - (ref = this).update.apply(ref, args) - } - - if (this.regl.attributes.preserveDrawingBuffer) { return this.draw() } - - // make sure draw is not called more often than once a frame - if (this.dirty) { - if (this.planned == null) { - this.planned = raf(function () { - this$1.draw() - this$1.dirty = true - this$1.planned = null - }) - } - } - else { - this.draw() - this.dirty = true - raf(function () { - this$1.dirty = false - }) - } - - return this -} - - -// update passes -SPLOM.prototype.update = function () { - var this$1 = this; - var ref; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (!args.length) { return } - - for (var i = 0; i < args.length; i++) { - this$1.updateItem(i, args[i]) - } - - // remove nulled passes - this.traces = this.traces.filter(Boolean) - - // FIXME: update passes independently - var passes = [] - var offset = 0 - for (var i$1 = 0; i$1 < this.traces.length; i$1++) { - var trace = this$1.traces[i$1] - var tracePasses = this$1.traces[i$1].passes - for (var j = 0; j < tracePasses.length; j++) { - passes.push(this$1.passes[tracePasses[j]]) - } - // save offset of passes - trace.passOffset = offset - offset += trace.passes.length - } - - (ref = this.scatter).update.apply(ref, passes) - - return this -} - - -// update trace by index, not supposed to be called directly -SPLOM.prototype.updateItem = function (i, options) { - var this$1 = this; - - var ref = this; - var regl = ref.regl; - - // remove pass if null - if (options === null) { - this.traces[i] = null - return this - } - - if (!options) { return this } - - var o = pick(options, { - data: 'data items columns rows values dimensions samples x', - snap: 'snap cluster', - size: 'sizes size radius', - color: 'colors color fill fill-color fillColor', - opacity: 'opacity alpha transparency opaque', - borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', - borderColor: 'borderColors borderColor bordercolor stroke stroke-color strokeColor', - marker: 'markers marker shape', - range: 'range ranges databox dataBox', - viewport: 'viewport viewBox viewbox', - domain: 'domain domains area areas', - padding: 'pad padding paddings pads margin margins', - transpose: 'transpose transposed', - diagonal: 'diagonal diag showDiagonal', - upper: 'upper up top upperhalf upperHalf showupperhalf showUpper showUpperHalf', - lower: 'lower low bottom lowerhalf lowerHalf showlowerhalf showLowerHalf showLower' - }) - - // we provide regl buffer per-trace, since trace data can be changed - var trace = (this.traces[i] || (this.traces[i] = { - id: i, - buffer: regl.buffer({ - usage: 'dynamic', - type: 'float', - data: new Uint8Array() - }), - color: 'black', - marker: null, - size: 12, - borderColor: 'transparent', - borderSize: 1, - viewport: rect([regl._gl.drawingBufferWidth, regl._gl.drawingBufferHeight]), - padding: [0, 0, 0, 0], - opacity: 1, - diagonal: true, - upper: true, - lower: true - })) - - - // save styles - if (o.color != null) { - trace.color = o.color - } - if (o.size != null) { - trace.size = o.size - } - if (o.marker != null) { - trace.marker = o.marker - } - if (o.borderColor != null) { - trace.borderColor = o.borderColor - } - if (o.borderSize != null) { - trace.borderSize = o.borderSize - } - if (o.opacity != null) { - trace.opacity = o.opacity - } - if (o.viewport) { - trace.viewport = rect(o.viewport) - } - if (o.diagonal != null) { trace.diagonal = o.diagonal } - if (o.upper != null) { trace.upper = o.upper } - if (o.lower != null) { trace.lower = o.lower } - - // put flattened data into buffer - if (o.data) { - trace.buffer(flatten(o.data)) - trace.columns = o.data.length - trace.count = o.data[0].length - - // detect bounds per-column - trace.bounds = [] - - for (var i$1 = 0; i$1 < trace.columns; i$1++) { - trace.bounds[i$1] = getBounds(o.data[i$1], 1) - } - } - - // add proper range updating markers - var multirange - if (o.range) { - trace.range = o.range - multirange = trace.range && typeof trace.range[0] !== 'number' - } - - if (o.domain) { - trace.domain = o.domain - } - var multipadding = false - if (o.padding != null) { - // multiple paddings - if (Array.isArray(o.padding) && o.padding.length === trace.columns && typeof o.padding[o.padding.length - 1] === 'number') { - trace.padding = o.padding.map(getPad) - multipadding = true - } - // single padding - else { - trace.padding = getPad(o.padding) - } - } - - // create passes - var m = trace.columns - var n = trace.count - - var w = trace.viewport.width - var h = trace.viewport.height - var left = trace.viewport.x - var top = trace.viewport.y - var iw = w / m - var ih = h / m - - trace.passes = [] - - for (var i$2 = 0; i$2 < m; i$2++) { - for (var j = 0; j < m; j++) { - if (!trace.diagonal && j === i$2) { continue } - if (!trace.upper && i$2 > j) { continue } - if (!trace.lower && i$2 < j) { continue } - - var key = passId(trace.id, i$2, j) - - var pass = this$1.passes[key] || (this$1.passes[key] = {}) - - if (o.data) { - if (o.transpose) { - pass.positions = { - x: {buffer: trace.buffer, offset: j, count: n, stride: m}, - y: {buffer: trace.buffer, offset: i$2, count: n, stride: m} - } - } - else { - pass.positions = { - x: {buffer: trace.buffer, offset: j * n, count: n}, - y: {buffer: trace.buffer, offset: i$2 * n, count: n} - } - } - - pass.bounds = getBox(trace.bounds, i$2, j) - } - - if (o.domain || o.viewport || o.data) { - var pad = multipadding ? getBox(trace.padding, i$2, j) : trace.padding - if (trace.domain) { - var ref$1 = getBox(trace.domain, i$2, j); - var lox = ref$1[0]; - var loy = ref$1[1]; - var hix = ref$1[2]; - var hiy = ref$1[3]; - - pass.viewport = [ - left + lox * w + pad[0], - top + loy * h + pad[1], - left + hix * w - pad[2], - top + hiy * h - pad[3] - ] - } - // consider auto-domain equipartial - else { - pass.viewport = [ - left + j * iw + iw * pad[0], - top + i$2 * ih + ih * pad[1], - left + (j + 1) * iw - iw * pad[2], - top + (i$2 + 1) * ih - ih * pad[3] - ] - } - } - - if (o.color) { pass.color = trace.color } - if (o.size) { pass.size = trace.size } - if (o.marker) { pass.marker = trace.marker } - if (o.borderSize) { pass.borderSize = trace.borderSize } - if (o.borderColor) { pass.borderColor = trace.borderColor } - if (o.opacity) { pass.opacity = trace.opacity } - - if (o.range) { - pass.range = multirange ? getBox(trace.range, i$2, j) : trace.range || pass.bounds - } - - trace.passes.push(key) - } - } - - return this -} - - -// draw all or passed passes -SPLOM.prototype.draw = function () { - var this$1 = this; - var ref$2; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (!args.length) { - this.scatter.draw() - } - else { - var idx = [] - for (var i = 0; i < args.length; i++) { - // draw(0, 2, 5) - draw traces - if (typeof args[i] === 'number' ) { - var ref = this$1.traces[args[i]]; - var passes = ref.passes; - var passOffset = ref.passOffset; - idx.push.apply(idx, arrRange(passOffset, passOffset + passes.length)) - } - // draw([0, 1, 2 ...], [3, 4, 5]) - draw points - else if (args[i].length) { - var els = args[i] - var ref$1 = this$1.traces[i]; - var passes$1 = ref$1.passes; - var passOffset$1 = ref$1.passOffset; - passes$1 = passes$1.map(function (passId, i) { - idx[passOffset$1 + i] = els - }) - } - } - (ref$2 = this.scatter).draw.apply(ref$2, idx) - } - - return this -} - - -// dispose resources -SPLOM.prototype.destroy = function () { - this.traces.forEach(function (trace) { - if (trace.buffer && trace.buffer.destroy) { trace.buffer.destroy() } - }) - this.traces = null - this.passes = null - - this.scatter.destroy() - - return this -} - - -// return pass corresponding to trace i- j- square -function passId (trace, i, j) { - var id = (trace.id != null ? trace.id : trace) - var n = i - var m = j - var key = id << 16 | (n & 0xff) << 8 | m & 0xff - - return key -} - - -// return bounding box corresponding to a pass -function getBox (items, i, j) { - var ilox, iloy, ihix, ihiy, jlox, jloy, jhix, jhiy - var iitem = items[i], jitem = items[j] - - if (iitem.length > 2) { - ilox = iitem[0] - ihix = iitem[2] - iloy = iitem[1] - ihiy = iitem[3] - } - else if (iitem.length) { - ilox = iloy = iitem[0] - ihix = ihiy = iitem[1] - } - else { - ilox = iitem.x - iloy = iitem.y - ihix = iitem.x + iitem.width - ihiy = iitem.y + iitem.height - } - - if (jitem.length > 2) { - jlox = jitem[0] - jhix = jitem[2] - jloy = jitem[1] - jhiy = jitem[3] - } - else if (jitem.length) { - jlox = jloy = jitem[0] - jhix = jhiy = jitem[1] - } - else { - jlox = jitem.x - jloy = jitem.y - jhix = jitem.x + jitem.width - jhiy = jitem.y + jitem.height - } - - return [ jlox, iloy, jhix, ihiy ] -} - - -function getPad (arg) { - if (typeof arg === 'number') { return [arg, arg, arg, arg] } - else if (arg.length === 2) { return [arg[0], arg[1], arg[0], arg[1]] } - else { - var box = rect(arg) - return [box.x, box.y, box.x + box.width, box.y + box.height] - } -} - -},{"array-bounds":53,"array-range":55,"flatten-vertex-data":216,"parse-rect":442,"pick-by-alias":448,"raf":467,"regl-scatter2d/scatter":476}],478:[function(_dereq_,module,exports){ -(function(pa,W){"object"===typeof exports&&"undefined"!==typeof module?module.exports=W():"function"===typeof define&&define.amd?define(W):pa.createREGL=W()})(this,function(){function pa(a,b){this.id=Ab++;this.type=a;this.data=b}function W(a){if(0===a.length)return[];var b=a.charAt(0),c=a.charAt(a.length-1);if(1>>=b;c=(255>>=c;b|=c;c=(15>>=c;b|=c;c=(3>>c>>1}function cb(){function a(a){a:{for(var b=16;268435456>=b;b*=16)if(a<=b){a=b;break a}a=0}b=c[bb(a)>>2];return 0>2].push(a)}var c=O(8,function(){return[]});return{alloc:a,free:b,allocType:function(b,c){var d=null;switch(b){case 5120:d=new Int8Array(a(c),0,c);break;case 5121:d=new Uint8Array(a(c),0,c);break;case 5122:d=new Int16Array(a(2*c),0,c);break;case 5123:d=new Uint16Array(a(2*c),0,c);break;case 5124:d=new Int32Array(a(4*c),0,c);break;case 5125:d=new Uint32Array(a(4*c),0,c);break;case 5126:d=new Float32Array(a(4*c),0,c);break;default:return null}return d.length!==c?d.subarray(0, -c):d},freeType:function(a){b(a.buffer)}}}function ka(a){return!!a&&"object"===typeof a&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&"number"===typeof a.offset&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||P(a.data))}function db(a,b,c,e,f,d){for(var n=0;ne&&(e=d.buffer.byteLength,5123===k?e>>=1:5125===k&&(e>>=2));d.vertCount=e;e=g;0>g&&(e=4,g=d.buffer.dimension,1===g&&(e=0),2===g&&(e=1),3===g&&(e=4));d.primType=e}function n(a){e.elementsCount--;delete k[a.id];a.buffer.destroy();a.buffer=null}var k={},r=0,p={uint8:5121,uint16:5123};b.oes_element_index_uint&&(p.uint32=5125);f.prototype.bind=function(){this.buffer.bind()};var u=[];return{create:function(a,b){function l(a){if(a)if("number"===typeof a)g(a),h.primType=4,h.vertCount=a|0, -h.type=5121;else{var b=null,c=35044,e=-1,f=-1,m=0,k=0;if(Array.isArray(a)||P(a)||ka(a))b=a;else if("data"in a&&(b=a.data),"usage"in a&&(c=jb[a.usage]),"primitive"in a&&(e=Sa[a.primitive]),"count"in a&&(f=a.count|0),"type"in a&&(k=p[a.type]),"length"in a)m=a.length|0;else if(m=f,5123===k||5122===k)m*=2;else if(5125===k||5124===k)m*=4;d(h,b,c,e,f,m,k)}else g(),h.primType=4,h.vertCount=0,h.type=5121;return l}var g=c.create(null,34963,!0),h=new f(g._buffer);e.elementsCount++;l(a);l._reglType="elements"; -l._elements=h;l.subdata=function(a,b){g.subdata(a,b);return l};l.destroy=function(){n(h)};return l},createStream:function(a){var b=u.pop();b||(b=new f(c.create(null,34963,!0,!1)._buffer));d(b,a,35040,-1,-1,0,0);return b},destroyStream:function(a){u.push(a)},getElements:function(a){return"function"===typeof a&&a._elements instanceof f?a._elements:null},clear:function(){R(k).forEach(n)}}}function kb(a){for(var b=z.allocType(5123,a.length),c=0;c>>31<<15,d=(e<<1>>>24)-127,e=e>>13&1023;b[c]=-24>d?f:-14>d?f+(e+1024>>-14-d):15>=d,c.height>>=d,C(c,e[d]),a.mipmask|=1<b;++b)a.images[b]=null;return a}function ib(a){for(var b=a.images,c=0;cb){for(var c=0;c=--this.refCount&&w(this)}});n.profile&&(d.getTotalTextureSize=function(){var a=0;Object.keys(Z).forEach(function(b){a+=Z[b].stats.size});return a});return{create2D:function(b,c){function e(a,b){var c=f.texInfo;v.call(c);var d=x();"number"===typeof a?"number"===typeof b?t(d,a|0,b|0):t(d,a|0,a|0):a?(N(c,a),B(d,a)):t(d,1,1);c.genMipmaps&&(d.mipmask=(d.width<<1)-1);f.mipmask=d.mipmask;r(f,d);f.internalformat=d.internalformat; -e.width=d.width;e.height=d.height;T(f);X(d,3553);Q(c,3553);Ba();ib(d);n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d.width,d.height,c.genMipmaps,!1));e.format=O[f.internalformat];e.type=ba[f.type];e.mag=oa[c.magFilter];e.min=Aa[c.minFilter];e.wrapS=ia[c.wrapS];e.wrapT=ia[c.wrapT];return e}var f=new E(3553);Z[f.id]=f;d.textureCount++;e(b,c);e.subimage=function(a,b,c,d){b|=0;c|=0;d|=0;var q=g();r(q,f);q.width=0;q.height=0;C(q,a);q.width=q.width||(f.width>>d)-b;q.height=q.height||(f.height>>d)- -c;T(f);l(q,3553,b,c,d);Ba();h(q);return e};e.resize=function(b,c){var d=b|0,g=c|0||d;if(d===f.width&&g===f.height)return e;e.width=f.width=d;e.height=f.height=g;T(f);for(var q,y=f.channels,G=f.type,H=0;f.mipmask>>H;++H){var ea=d>>H,fa=g>>H;if(!ea||!fa)break;q=z.zero.allocType(G,ea*fa*y);a.texImage2D(3553,H,f.format,ea,fa,0,f.format,f.type,q);q&&z.zero.freeType(q)}Ba();n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d,g,!1,!1));return e};e._reglType="texture2d";e._texture=f;n.profile&&(e.stats= -f.stats);e.destroy=function(){f.decRef()};return e},createCube:function(b,c,e,f,k,m){function A(a,b,c,d,e,J){var I,da=w.texInfo;v.call(da);for(I=0;6>I;++I)q[I]=x();if("number"===typeof a||!a)for(a=a|0||1,I=0;6>I;++I)t(q[I],a,a);else if("object"===typeof a)if(b)B(q[0],a),B(q[1],b),B(q[2],c),B(q[3],d),B(q[4],e),B(q[5],J);else if(N(da,a),p(w,a),"faces"in a)for(a=a.faces,I=0;6>I;++I)r(q[I],w),B(q[I],a[I]);else for(I=0;6>I;++I)B(q[I],a);r(w,q[0]);w.mipmask=da.genMipmaps?(q[0].width<<1)-1:q[0].mipmask; -w.internalformat=q[0].internalformat;A.width=q[0].width;A.height=q[0].height;T(w);for(I=0;6>I;++I)X(q[I],34069+I);Q(da,34067);Ba();n.profile&&(w.stats.size=Ja(w.internalformat,w.type,A.width,A.height,da.genMipmaps,!0));A.format=O[w.internalformat];A.type=ba[w.type];A.mag=oa[da.magFilter];A.min=Aa[da.minFilter];A.wrapS=ia[da.wrapS];A.wrapT=ia[da.wrapT];for(I=0;6>I;++I)ib(q[I]);return A}var w=new E(34067);Z[w.id]=w;d.cubeCount++;var q=Array(6);A(b,c,e,f,k,m);A.subimage=function(a,b,c,q,d){c|=0;q|=0; -d|=0;var e=g();r(e,w);e.width=0;e.height=0;C(e,b);e.width=e.width||(w.width>>d)-c;e.height=e.height||(w.height>>d)-q;T(w);l(e,34069+a,c,q,d);Ba();h(e);return A};A.resize=function(b){b|=0;if(b!==w.width){A.width=w.width=b;A.height=w.height=b;T(w);for(var c=0;6>c;++c)for(var q=0;w.mipmask>>q;++q)a.texImage2D(34069+c,q,w.format,b>>q,b>>q,0,w.format,w.type,null);Ba();n.profile&&(w.stats.size=Ja(w.internalformat,w.type,A.width,A.height,!1,!0));return A}};A._reglType="textureCube";A._texture=w;n.profile&& -(A.stats=w.stats);A.destroy=function(){w.decRef()};return A},clear:function(){for(var b=0;bc;++c)if(0!==(b.mipmask&1<>c,b.height>>c,0,b.internalformat,b.type,null); -else for(var e=0;6>e;++e)a.texImage2D(34069+e,c,b.internalformat,b.width>>c,b.height>>c,0,b.internalformat,b.type,null);Q(b.texInfo,b.target)})}}}function Ob(a,b,c,e,f,d){function n(a,b,c){this.target=a;this.texture=b;this.renderbuffer=c;var e=a=0;b?(a=b.width,e=b.height):c&&(a=c.width,e=c.height);this.width=a;this.height=e}function k(a){a&&(a.texture&&a.texture._texture.decRef(),a.renderbuffer&&a.renderbuffer._renderbuffer.decRef())}function r(a,b,c){a&&(a.texture?a.texture._texture.refCount+=1: -a.renderbuffer._renderbuffer.refCount+=1)}function p(b,c){c&&(c.texture?a.framebufferTexture2D(36160,b,c.target,c.texture._texture.texture,0):a.framebufferRenderbuffer(36160,b,36161,c.renderbuffer._renderbuffer.renderbuffer))}function u(a){var b=3553,c=null,e=null,d=a;"object"===typeof a&&(d=a.data,"target"in a&&(b=a.target|0));a=d._reglType;"texture2d"===a?c=d:"textureCube"===a?c=d:"renderbuffer"===a&&(e=d,b=36161);return new n(b,c,e)}function m(a,b,c,d,g){if(c)return a=e.create2D({width:a,height:b, -format:d,type:g}),a._texture.refCount=0,new n(3553,a,null);a=f.create({width:a,height:b,format:d});a._renderbuffer.refCount=0;return new n(36161,null,a)}function C(a){return a&&(a.texture||a.renderbuffer)}function l(a,b,c){a&&(a.texture?a.texture.resize(b,c):a.renderbuffer&&a.renderbuffer.resize(b,c))}function g(){this.id=N++;Q[this.id]=this;this.framebuffer=a.createFramebuffer();this.height=this.width=0;this.colorAttachments=[];this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment= -null}function h(a){a.colorAttachments.forEach(k);k(a.depthAttachment);k(a.stencilAttachment);k(a.depthStencilAttachment)}function qa(b){a.deleteFramebuffer(b.framebuffer);b.framebuffer=null;d.framebufferCount--;delete Q[b.id]}function t(b){var e;a.bindFramebuffer(36160,b.framebuffer);var d=b.colorAttachments;for(e=0;ed;++d){for(k=0;ka;++a)c[a].resize(d);b.width=b.height=d;return b},_reglType:"framebufferCube",destroy:function(){c.forEach(function(a){a.destroy()})}})},clear:function(){R(Q).forEach(qa)},restore:function(){R(Q).forEach(function(b){b.framebuffer=a.createFramebuffer();t(b)})}})}function ub(){this.w=this.z=this.y=this.x=this.state=0;this.buffer=null;this.size=0;this.normalized=!1;this.type=5126;this.divisor=this.stride=this.offset= -0}function Pb(a,b,c,e){a=c.maxAttributes;b=Array(a);for(c=0;ca&&(a=b.stats.uniformsCount)});return a},c.getMaxAttributesCount=function(){var a= -0;C.forEach(function(b){b.stats.attributesCount>a&&(a=b.stats.attributesCount)});return a});return{clear:function(){var b=a.deleteShader.bind(a);R(p).forEach(b);p={};R(u).forEach(b);u={};C.forEach(function(b){a.deleteProgram(b.program)});C.length=0;m={};c.shaderCount=0},program:function(a,b,d){var e=m[b];e||(e=m[b]={});var f=e[a];f||(f=new k(b,a),c.shaderCount++,r(f,d),e[a]=f,C.push(f));return f},restore:function(){p={};u={};for(var a=0;a>>=b;c=(255>>=c;b|=c;c=(15>>=c;b|=c;c=(3>>c>>1}function cb(){function a(a){a:{for(var b=16;268435456>=b;b*=16)if(a<=b){a=b;break a}a=0}b=c[bb(a)>>2];return 0>2].push(a)}var c=J(8,function(){return[]});return{alloc:a,free:b,allocType:function(b,c){var d=null;switch(b){case 5120:d=new Int8Array(a(c),0,c);break;case 5121:d=new Uint8Array(a(c),0,c);break;case 5122:d=new Int16Array(a(2*c),0,c);break;case 5123:d=new Uint16Array(a(2*c),0,c);break;case 5124:d=new Int32Array(a(4*c),0,c);break;case 5125:d=new Uint32Array(a(4*c),0,c);break;case 5126:d=new Float32Array(a(4*c),0,c);break;default:return null}return d.length!== +c?d.subarray(0,c):d},freeType:function(a){b(a.buffer)}}}function ma(a){return!!a&&"object"===typeof a&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&"number"===typeof a.offset&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||M(a.data))}function db(a,b,c,e,g,d){for(var n=0;nd&&(d=e.buffer.byteLength,5123===f?d>>=1:5125===f&&(d>>=2));e.vertCount=d;d=h;0>h&&(d=4,h=e.buffer.dimension,1===h&&(d=0),2===h&&(d=1),3===h&&(d=4));e.primType=d}function n(a){e.elementsCount--;delete f[a.id];a.buffer.destroy();a.buffer=null}var f={},r=0,q={uint8:5121,uint16:5123};b.oes_element_index_uint&&(q.uint32=5125);g.prototype.bind=function(){this.buffer.bind()};var t=[];return{create:function(a,b){function k(a){if(a)if("number"===typeof a)h(a),l.primType=4,l.vertCount=a|0, +l.type=5121;else{var b=null,c=35044,e=-1,g=-1,f=0,m=0;if(Array.isArray(a)||M(a)||ma(a))b=a;else if("data"in a&&(b=a.data),"usage"in a&&(c=jb[a.usage]),"primitive"in a&&(e=Sa[a.primitive]),"count"in a&&(g=a.count|0),"type"in a&&(m=q[a.type]),"length"in a)f=a.length|0;else if(f=g,5123===m||5122===m)f*=2;else if(5125===m||5124===m)f*=4;d(l,b,c,e,g,f,m)}else h(),l.primType=4,l.vertCount=0,l.type=5121;return k}var h=c.create(null,34963,!0),l=new g(h._buffer);e.elementsCount++;k(a);k._reglType="elements"; +k._elements=l;k.subdata=function(a,b){h.subdata(a,b);return k};k.destroy=function(){n(l)};return k},createStream:function(a){var b=t.pop();b||(b=new g(c.create(null,34963,!0,!1)._buffer));d(b,a,35040,-1,-1,0,0);return b},destroyStream:function(a){t.push(a)},getElements:function(a){return"function"===typeof a&&a._elements instanceof g?a._elements:null},clear:function(){S(f).forEach(n)}}}function kb(a){for(var b=x.allocType(5123,a.length),c=0;c>>31<<15,d=(e<<1>>>24)-127,e=e>>13&1023;b[c]=-24>d?g:-14>d?g+(e+1024>>-14-d):15>=e,c.height>>=e,C(c,d[e]),a.mipmask|=1<b;++b)a.images[b]=null;return a}function ib(a){for(var b=a.images,c=0;cb){for(var c=0;c=--this.refCount&&A(this)}});n.profile&&(d.getTotalTextureSize=function(){var a=0;Object.keys(X).forEach(function(b){a+=X[b].stats.size});return a});return{create2D:function(b,c){function e(a,b){var c=f.texInfo;y.call(c);var d=D();"number"===typeof a?"number"===typeof b?v(d,a|0,b|0):v(d,a|0,a|0):a?(O(c,a),N(d,a)):v(d,1,1);c.genMipmaps&&(d.mipmask=(d.width<<1)-1);f.mipmask=d.mipmask;r(f,d);f.internalformat=d.internalformat; +e.width=d.width;e.height=d.height;T(f);B(d,3553);R(c,3553);Aa();ib(d);n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d.width,d.height,c.genMipmaps,!1));e.format=J[f.internalformat];e.type=da[f.type];e.mag=oa[c.magFilter];e.min=za[c.minFilter];e.wrapS=ka[c.wrapS];e.wrapT=ka[c.wrapT];return e}var f=new F(3553);X[f.id]=f;d.textureCount++;e(b,c);e.subimage=function(a,b,c,d){b|=0;c|=0;d|=0;var p=h();r(p,f);p.width=0;p.height=0;C(p,a);p.width=p.width||(f.width>>d)-b;p.height=p.height||(f.height>>d)- +c;T(f);k(p,3553,b,c,d);Aa();l(p);return e};e.resize=function(b,c){var d=b|0,h=c|0||d;if(d===f.width&&h===f.height)return e;e.width=f.width=d;e.height=f.height=h;T(f);for(var p,w=f.channels,z=f.type,I=0;f.mipmask>>I;++I){var fa=d>>I,ga=h>>I;if(!fa||!ga)break;p=x.zero.allocType(z,fa*ga*w);a.texImage2D(3553,I,f.format,fa,ga,0,f.format,f.type,p);p&&x.zero.freeType(p)}Aa();n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d,h,!1,!1));return e};e._reglType="texture2d";e._texture=f;n.profile&&(e.stats= +f.stats);e.destroy=function(){f.decRef()};return e},createCube:function(b,c,e,f,g,ua){function A(a,b,c,d,e,f){var H,Y=m.texInfo;y.call(Y);for(H=0;6>H;++H)p[H]=D();if("number"===typeof a||!a)for(a=a|0||1,H=0;6>H;++H)v(p[H],a,a);else if("object"===typeof a)if(b)N(p[0],a),N(p[1],b),N(p[2],c),N(p[3],d),N(p[4],e),N(p[5],f);else if(O(Y,a),q(m,a),"faces"in a)for(a=a.faces,H=0;6>H;++H)r(p[H],m),N(p[H],a[H]);else for(H=0;6>H;++H)N(p[H],a);r(m,p[0]);m.mipmask=Y.genMipmaps?(p[0].width<<1)-1:p[0].mipmask;m.internalformat= +p[0].internalformat;A.width=p[0].width;A.height=p[0].height;T(m);for(H=0;6>H;++H)B(p[H],34069+H);R(Y,34067);Aa();n.profile&&(m.stats.size=Ja(m.internalformat,m.type,A.width,A.height,Y.genMipmaps,!0));A.format=J[m.internalformat];A.type=da[m.type];A.mag=oa[Y.magFilter];A.min=za[Y.minFilter];A.wrapS=ka[Y.wrapS];A.wrapT=ka[Y.wrapT];for(H=0;6>H;++H)ib(p[H]);return A}var m=new F(34067);X[m.id]=m;d.cubeCount++;var p=Array(6);A(b,c,e,f,g,ua);A.subimage=function(a,b,c,p,d){c|=0;p|=0;d|=0;var e=h();r(e,m); +e.width=0;e.height=0;C(e,b);e.width=e.width||(m.width>>d)-c;e.height=e.height||(m.height>>d)-p;T(m);k(e,34069+a,c,p,d);Aa();l(e);return A};A.resize=function(b){b|=0;if(b!==m.width){A.width=m.width=b;A.height=m.height=b;T(m);for(var c=0;6>c;++c)for(var p=0;m.mipmask>>p;++p)a.texImage2D(34069+c,p,m.format,b>>p,b>>p,0,m.format,m.type,null);Aa();n.profile&&(m.stats.size=Ja(m.internalformat,m.type,A.width,A.height,!1,!0));return A}};A._reglType="textureCube";A._texture=m;n.profile&&(A.stats=m.stats);A.destroy= +function(){m.decRef()};return A},clear:function(){for(var b=0;bc;++c)if(0!==(b.mipmask&1<> +c,b.height>>c,0,b.internalformat,b.type,null);else for(var d=0;6>d;++d)a.texImage2D(34069+d,c,b.internalformat,b.width>>c,b.height>>c,0,b.internalformat,b.type,null);R(b.texInfo,b.target)})}}}function Ob(a,b,c,e,g,d){function n(a,b,c){this.target=a;this.texture=b;this.renderbuffer=c;var d=a=0;b?(a=b.width,d=b.height):c&&(a=c.width,d=c.height);this.width=a;this.height=d}function f(a){a&&(a.texture&&a.texture._texture.decRef(),a.renderbuffer&&a.renderbuffer._renderbuffer.decRef())}function r(a,b,c){a&& +(a.texture?a.texture._texture.refCount+=1:a.renderbuffer._renderbuffer.refCount+=1)}function q(b,c){c&&(c.texture?a.framebufferTexture2D(36160,b,c.target,c.texture._texture.texture,0):a.framebufferRenderbuffer(36160,b,36161,c.renderbuffer._renderbuffer.renderbuffer))}function t(a){var b=3553,c=null,d=null,e=a;"object"===typeof a&&(e=a.data,"target"in a&&(b=a.target|0));a=e._reglType;"texture2d"===a?c=e:"textureCube"===a?c=e:"renderbuffer"===a&&(d=e,b=36161);return new n(b,c,d)}function m(a,b,c,d, +f){if(c)return a=e.create2D({width:a,height:b,format:d,type:f}),a._texture.refCount=0,new n(3553,a,null);a=g.create({width:a,height:b,format:d});a._renderbuffer.refCount=0;return new n(36161,null,a)}function C(a){return a&&(a.texture||a.renderbuffer)}function k(a,b,c){a&&(a.texture?a.texture.resize(b,c):a.renderbuffer&&a.renderbuffer.resize(b,c),a.width=b,a.height=c)}function h(){this.id=O++;R[this.id]=this;this.framebuffer=a.createFramebuffer();this.height=this.width=0;this.colorAttachments=[];this.depthStencilAttachment= +this.stencilAttachment=this.depthAttachment=null}function l(a){a.colorAttachments.forEach(f);f(a.depthAttachment);f(a.stencilAttachment);f(a.depthStencilAttachment)}function u(b){a.deleteFramebuffer(b.framebuffer);b.framebuffer=null;d.framebufferCount--;delete R[b.id]}function v(b){var d;a.bindFramebuffer(36160,b.framebuffer);var e=b.colorAttachments;for(d=0;dd;++d){for(m=0;ma;++a)c[a].resize(d);b.width=b.height=d;return b},_reglType:"framebufferCube",destroy:function(){c.forEach(function(a){a.destroy()})}})},clear:function(){S(R).forEach(u)},restore:function(){B.cur=null;B.next=null;B.dirty=!0;S(R).forEach(function(b){b.framebuffer=a.createFramebuffer();v(b)})}})}function ub(){this.w=this.z=this.y= +this.x=this.state=0;this.buffer=null;this.size=0;this.normalized=!1;this.type=5126;this.divisor=this.stride=this.offset=0}function Pb(a,b,c,e){a=c.maxAttributes;b=Array(a);for(c=0;c +a&&(a=b.stats.uniformsCount)});return a},c.getMaxAttributesCount=function(){var a=0;C.forEach(function(b){b.stats.attributesCount>a&&(a=b.stats.attributesCount)});return a});return{clear:function(){var b=a.deleteShader.bind(a);S(q).forEach(b);q={};S(t).forEach(b);t={};C.forEach(function(b){a.deleteProgram(b.program)});C.length=0;m={};c.shaderCount=0},program:function(a,b,d){var e=m[b];e||(e=m[b]={});var g=e[a];g||(g=new f(b,a),c.shaderCount++,r(g,d),e[a]=g,C.push(g));return g},restore:function(){q= +{};t={};for(var a=0;a"+b+"?"+e+".constant["+b+"]:0;"}).join(""),"}}else{", -"if(",f,"(",e,".buffer)){",h,"=",g,".createStream(",34962,",",e,".buffer);","}else{",h,"=",g,".getBuffer(",e,".buffer);","}",k,'="type" in ',e,"?",q.glTypes,"[",e,".type]:",h,".dtype;",y.normalized,"=!!",e,".normalized;");d("size");d("offset");d("stride");d("divisor");c("}}");c.exit("if(",y.isStream,"){",g,".destroyStream(",h,");","}");return y})});return g}function M(a){var b=a["static"],c=a.dynamic,d={};Object.keys(b).forEach(function(a){var c=b[a];d[a]=x(function(a,b){return"number"===typeof c|| -"boolean"===typeof c?""+c:a.link(c)})});Object.keys(c).forEach(function(a){var b=c[a];d[a]=K(b,function(a,c){return a.invoke(c,b)})});return d}function w(a,b,c,d,e){var f=z(a,e),g=D(a,f,e),l=N(a,e),k=Q(a,e),m=P(a,e),xa=g.viewport;xa&&(k.viewport=xa);xa=h("scissor.box");(g=g[xa])&&(k[xa]=g);g=0>1)",u],");")}function b(){c(ba,".drawArraysInstancedANGLE(",[p,r,t,u],");")}n?B?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")):b()}function g(){function a(){c(l+".drawElements("+[p,t,C,r+"<<(("+C+"-5121)>>1)"]+");")}function b(){c(l+".drawArrays("+[p,r,t]+");")}n?B?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")): -b()}var h=a.shared,l=h.gl,k=h.draw,m=d.draw,n=function(){var e=m.elements,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(k,".","elements");e&&f("if("+e+")"+l+".bindBuffer(34963,"+e+".buffer.buffer);");return e}(),p=e("primitive"),r=e("offset"),t=function(){var e=m.count,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(k,".","count");return e}();if("number"===typeof t){if(0===t)return}else c("if(",t,"){"),c.exit("}");var u, -ba;ga&&(u=e("instances"),ba=a.instancing);var C=n+".type",B=m.elements&&wa(m.elements);ga&&("number"!==typeof u||0<=u)?"string"===typeof u?(c("if(",u,">0){"),f(),c("}else if(",u,"<0){"),g(),c("}")):f():g()}function ca(a,b,c,d,e){b=B();e=b.proc("body",e);ga&&(b.instancing=e.def(b.shared.extensions,".angle_instanced_arrays"));a(b,e,c,d);return b.compile().body}function W(a,b,c,d){ya(a,b);U(a,b,c,d.attributes,function(){return!0});Y(a,b,c,d.uniforms,function(){return!0});S(a,b,b,c)}function ba(a,b){var c= -a.proc("draw",1);ya(a,c);A(a,c,b.context);L(a,c,b.framebuffer);V(a,c,b);R(a,c,b.state);F(a,c,b,!1,!0);var d=b.shader.progVar.append(a,c);c(a.shared.gl,".useProgram(",d,".program);");if(b.shader.program)W(a,c,b,b.shader.program);else{var e=a.global.def("{}"),f=c.def(d,".id"),g=c.def(e,"[",f,"]");c(a.cond(g).then(g,".call(this,a0);")["else"](g,"=",e,"[",f,"]=",a.link(function(c){return ca(W,a,b,c,1)}),"(",d,");",g,".call(this,a0);"))}0=--this.refCount&&n(this)};f.profile&&(e.getTotalRenderbufferSize=function(){var a=0;Object.keys(u).forEach(function(b){a+=u[b].stats.size});return a});return{create:function(b,c){function l(b,c){var d=0,e=0,m=32854;"object"===typeof b&&b?("shape"in b?(e=b.shape,d=e[0]|0,e=e[1]|0):("radius"in b&&(d=e=b.radius|0),"width"in b&&(d=b.width|0),"height"in b&&(e=b.height|0)),"format"in b&&(m=k[b.format])): -"number"===typeof b?(d=b|0,e="number"===typeof c?c|0:d):b||(d=e=1);if(d!==g.width||e!==g.height||m!==g.format)return l.width=g.width=d,l.height=g.height=e,g.format=m,a.bindRenderbuffer(36161,g.renderbuffer),a.renderbufferStorage(36161,m,d,e),f.profile&&(g.stats.size=M[g.format]*g.width*g.height),l.format=r[g.format],l}var g=new d(a.createRenderbuffer());u[g.id]=g;e.renderbufferCount++;l(b,c);l.resize=function(b,c){var d=b|0,e=c|0||d;if(d===g.width&&e===g.height)return l;l.width=g.width=d;l.height= -g.height=e;a.bindRenderbuffer(36161,g.renderbuffer);a.renderbufferStorage(36161,g.format,d,e);f.profile&&(g.stats.size=M[g.format]*g.width*g.height);return l};l._reglType="renderbuffer";l._renderbuffer=g;f.profile&&(l.stats=g.stats);l.destroy=function(){g.decRef()};return l},clear:function(){R(u).forEach(n)},restore:function(){R(u).forEach(function(b){b.renderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,b.renderbuffer);a.renderbufferStorage(36161,b.format,b.width,b.height)});a.bindRenderbuffer(36161, -null)}}},Wa=[];Wa[6408]=4;Wa[6407]=3;var Na=[];Na[5121]=1;Na[5126]=4;Na[36193]=2;var Da=["x","y","z","w"],Ub="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),Ga={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771, -"one minus constant alpha":32772,"src alpha saturate":776},Xa={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Pa={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},wb={cw:2304,ccw:2305},xb=new aa(!1,!1,!1,function(){}),Xb=function(a,b){function c(){this.endQueryIndex=this.startQueryIndex=-1;this.sum=0;this.stats= -null}function e(a,b,d){var e=k.pop()||new c;e.startQueryIndex=a;e.endQueryIndex=b;e.sum=0;e.stats=d;r.push(e)}var f=b.ext_disjoint_timer_query;if(!f)return null;var d=[],n=[],k=[],r=[],p=[],u=[];return{beginQuery:function(a){var b=d.pop()||f.createQueryEXT();f.beginQueryEXT(35007,b);n.push(b);e(n.length-1,n.length,a)},endQuery:function(){f.endQueryEXT(35007)},pushScopeStats:e,update:function(){var a,b;a=n.length;if(0!==a){u.length=Math.max(u.length,a+1);p.length=Math.max(p.length,a+1);p[0]=0;var c= -u[0]=0;for(b=a=0;b=F.length&&e()}var c=yb(F,a);F[c]=b}}}function p(){var a=S.viewport,b=S.scissor_box;a[0]=a[1]=b[0]=b[1]=0;N.viewportWidth=N.framebufferWidth=N.drawingBufferWidth=a[2]=b[2]=l.drawingBufferWidth;N.viewportHeight=N.framebufferHeight=N.drawingBufferHeight=a[3]=b[3]=l.drawingBufferHeight}function u(){N.tick+=1;N.time=v();p();V.procs.poll()}function m(){p();V.procs.refresh();x&&x.update()}function v(){return(zb()-O)/1E3}a=Eb(a);if(!a)return null;var l=a.gl,g=l.getContextAttributes(); -l.isContextLost();var h=Fb(l,a);if(!h)return null;var z=Bb(),t={bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},B=h.extensions,x=Xb(l,B),O=zb(),K=l.drawingBufferWidth,P=l.drawingBufferHeight,N={tick:0,time:0,viewportWidth:K,viewportHeight:P,framebufferWidth:K,framebufferHeight:P,drawingBufferWidth:K,drawingBufferHeight:P,pixelRatio:a.pixelRatio},Q=Vb(l,B),K=Pb(l,B,Q,z),E=Gb(l,t,a,K),T=Hb(l,B,E,t),R=Qb(l,z,t,a),w=Kb(l, -B,Q,function(){V.procs.poll()},N,t,a),A=Wb(l,B,Q,t,a),L=Ob(l,B,Q,w,A,t),V=Tb(l,z,B,Q,E,T,w,L,{},K,R,{elements:null,primitive:4,count:-1,offset:0,instances:-1},N,x,a),z=Rb(l,L,V.procs.poll,N,g,B,Q),S=V.next,M=l.canvas,F=[],U=[],Y=[],W=[a.onDestroy],ca=null;M&&(M.addEventListener("webglcontextlost",f,!1),M.addEventListener("webglcontextrestored",d,!1));var aa=L.setFBO=n({framebuffer:ja.define.call(null,1,"framebuffer")});m();g=D(n,{clear:function(a){if("framebuffer"in a)if(a.framebuffer&&"framebufferCube"=== -a.framebuffer_reglType)for(var b=0;6>b;++b)aa(D({framebuffer:a.framebuffer.faces[b]},a),k);else aa(a,k);else k(null,a)},prop:ja.define.bind(null,1),context:ja.define.bind(null,2),"this":ja.define.bind(null,3),draw:n({}),buffer:function(a){return E.create(a,34962,!1,!1)},elements:function(a){return T.create(a,!1)},texture:w.create2D,cube:w.createCube,renderbuffer:A.create,framebuffer:L.create,framebufferCube:L.createCube,attributes:g,frame:r,on:function(a,b){var c;switch(a){case "frame":return r(b); -case "lost":c=U;break;case "restore":c=Y;break;case "destroy":c=W}c.push(b);return{cancel:function(){for(var a=0;a"+b+"?"+e+".constant["+b+"]:0;"}).join(""),"}}else{", +"if(",f,"(",e,".buffer)){",z,"=",g,".createStream(",34962,",",e,".buffer);","}else{",z,"=",g,".getBuffer(",e,".buffer);","}",k,'="type" in ',e,"?",p.glTypes,"[",e,".type]:",z,".dtype;",w.normalized,"=!!",e,".normalized;");d("size");d("offset");d("stride");d("divisor");c("}}");c.exit("if(",w.isStream,"){",g,".destroyStream(",z,");","}");return w})});return f}function M(a){var b=a["static"],c=a.dynamic,d={};Object.keys(b).forEach(function(a){var c=b[a];d[a]=D(function(a,b){return"number"===typeof c|| +"boolean"===typeof c?""+c:a.link(c)})});Object.keys(c).forEach(function(a){var b=c[a];d[a]=P(b,function(a,c){return a.invoke(c,b)})});return d}function A(a,b,c,d,e){var f=y(a,e),g=x(a,f,e),h=O(a,e),k=R(a,e),m=E(a,e),ba=g.viewport;ba&&(k.viewport=ba);ba=l("scissor.box");(g=g[ba])&&(k[ba]=g);g=0>1)",v],");")}function b(){c(u,".drawArraysInstancedANGLE(",[q,r,t,v],");")}n?da?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")):b()}function g(){function a(){c(k+".drawElements("+[q,t,C,r+"<<(("+C+"-5121)>>1)"]+");")}function b(){c(k+".drawArrays("+[q,r,t]+");")}n?da?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")): +b()}var h=a.shared,k=h.gl,m=h.draw,l=d.draw,n=function(){var e=l.elements,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(m,".","elements");e&&f("if("+e+")"+k+".bindBuffer(34963,"+e+".buffer.buffer);");return e}(),q=e("primitive"),r=e("offset"),t=function(){var e=l.count,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(m,".","count");return e}();if("number"===typeof t){if(0===t)return}else c("if(",t,"){"),c.exit("}");var v, +u;ea&&(v=e("instances"),u=a.instancing);var C=n+".type",da=l.elements&&va(l.elements);ea&&("number"!==typeof v||0<=v)?"string"===typeof v?(c("if(",v,">0){"),f(),c("}else if(",v,"<0){"),g(),c("}")):f():g()}function ca(a,b,c,d,e){b=N();e=b.proc("body",e);ea&&(b.instancing=e.def(b.shared.extensions,".angle_instanced_arrays"));a(b,e,c,d);return b.compile().body}function L(a,b,c,d){wa(a,b);U(a,b,c,d.attributes,function(){return!0});W(a,b,c,d.uniforms,function(){return!0});S(a,b,b,c)}function da(a,b){var c= +a.proc("draw",1);wa(a,c);ua(a,c,b.context);K(a,c,b.framebuffer);V(a,c,b);Q(a,c,b.state);G(a,c,b,!1,!0);var d=b.shader.progVar.append(a,c);c(a.shared.gl,".useProgram(",d,".program);");if(b.shader.program)L(a,c,b,b.shader.program);else{var e=a.global.def("{}"),f=c.def(d,".id"),g=c.def(e,"[",f,"]");c(a.cond(g).then(g,".call(this,a0);")["else"](g,"=",e,"[",f,"]=",a.link(function(c){return ca(L,a,b,c,1)}),"(",d,");",g,".call(this,a0);"))}0=--this.refCount&&n(this)};g.profile&&(e.getTotalRenderbufferSize=function(){var a=0;Object.keys(t).forEach(function(b){a+=t[b].stats.size});return a});return{create:function(b,c){function k(b,c){var d=0,e=0,m=32854; +"object"===typeof b&&b?("shape"in b?(e=b.shape,d=e[0]|0,e=e[1]|0):("radius"in b&&(d=e=b.radius|0),"width"in b&&(d=b.width|0),"height"in b&&(e=b.height|0)),"format"in b&&(m=f[b.format])):"number"===typeof b?(d=b|0,e="number"===typeof c?c|0:d):b||(d=e=1);if(d!==h.width||e!==h.height||m!==h.format)return k.width=h.width=d,k.height=h.height=e,h.format=m,a.bindRenderbuffer(36161,h.renderbuffer),a.renderbufferStorage(36161,m,d,e),g.profile&&(h.stats.size=Q[h.format]*h.width*h.height),k.format=r[h.format], +k}var h=new d(a.createRenderbuffer());t[h.id]=h;e.renderbufferCount++;k(b,c);k.resize=function(b,c){var d=b|0,e=c|0||d;if(d===h.width&&e===h.height)return k;k.width=h.width=d;k.height=h.height=e;a.bindRenderbuffer(36161,h.renderbuffer);a.renderbufferStorage(36161,h.format,d,e);g.profile&&(h.stats.size=Q[h.format]*h.width*h.height);return k};k._reglType="renderbuffer";k._renderbuffer=h;g.profile&&(k.stats=h.stats);k.destroy=function(){h.decRef()};return k},clear:function(){S(t).forEach(n)},restore:function(){S(t).forEach(function(b){b.renderbuffer= +a.createRenderbuffer();a.bindRenderbuffer(36161,b.renderbuffer);a.renderbufferStorage(36161,b.format,b.width,b.height)});a.bindRenderbuffer(36161,null)}}},Wa=[];Wa[6408]=4;Wa[6407]=3;var Na=[];Na[5121]=1;Na[5126]=4;Na[36193]=2;var Da=["x","y","z","w"],Ub="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),Ga={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771, +"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Xa={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Pa={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056, +invert:5386},wb={cw:2304,ccw:2305},xb=new Z(!1,!1,!1,function(){}),Xb=function(a,b){function c(){this.endQueryIndex=this.startQueryIndex=-1;this.sum=0;this.stats=null}function e(a,b,d){var e=n.pop()||new c;e.startQueryIndex=a;e.endQueryIndex=b;e.sum=0;e.stats=d;f.push(e)}if(!b.ext_disjoint_timer_query)return null;var g=[],d=[],n=[],f=[],r=[],q=[];return{beginQuery:function(a){var c=g.pop()||b.ext_disjoint_timer_query.createQueryEXT();b.ext_disjoint_timer_query.beginQueryEXT(35007,c);d.push(c);e(d.length- +1,d.length,a)},endQuery:function(){b.ext_disjoint_timer_query.endQueryEXT(35007)},pushScopeStats:e,update:function(){var a,c;a=d.length;if(0!==a){q.length=Math.max(q.length,a+1);r.length=Math.max(r.length,a+1);r[0]=0;var e=q[0]=0;for(c=a=0;c=G.length&&e()}var c=yb(G,a);G[c]=b}}}function q(){var a=S.viewport,b=S.scissor_box;a[0]=a[1]=b[0]=b[1]=0;O.viewportWidth= +O.framebufferWidth=O.drawingBufferWidth=a[2]=b[2]=k.drawingBufferWidth;O.viewportHeight=O.framebufferHeight=O.drawingBufferHeight=a[3]=b[3]=k.drawingBufferHeight}function t(){O.tick+=1;O.time=y();q();V.procs.poll()}function m(){q();V.procs.refresh();B&&B.update()}function y(){return(zb()-D)/1E3}a=Eb(a);if(!a)return null;var k=a.gl,h=k.getContextAttributes();k.isContextLost();var l=Fb(k,a);if(!l)return null;var u=Bb(),v={bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0, +cubeCount:0,renderbufferCount:0,maxTextureUnits:0},x=l.extensions,B=Xb(k,x),D=zb(),J=k.drawingBufferWidth,P=k.drawingBufferHeight,O={tick:0,time:0,viewportWidth:J,viewportHeight:P,framebufferWidth:J,framebufferHeight:P,drawingBufferWidth:J,drawingBufferHeight:P,pixelRatio:a.pixelRatio},R=Vb(k,x),J=Pb(k,x,R,u),F=Gb(k,v,a,J),T=Hb(k,x,F,v),Q=Qb(k,u,v,a),A=Kb(k,x,R,function(){V.procs.poll()},O,v,a),M=Wb(k,x,R,v,a),K=Ob(k,x,R,A,M,v),V=Tb(k,u,x,R,F,T,A,K,{},J,Q,{elements:null,primitive:4,count:-1,offset:0, +instances:-1},O,B,a),u=Rb(k,K,V.procs.poll,O,h,x,R),S=V.next,L=k.canvas,G=[],U=[],W=[],Z=[a.onDestroy],ca=null;L&&(L.addEventListener("webglcontextlost",g,!1),L.addEventListener("webglcontextrestored",d,!1));var aa=K.setFBO=n({framebuffer:la.define.call(null,1,"framebuffer")});m();h=E(n,{clear:function(a){if("framebuffer"in a)if(a.framebuffer&&"framebufferCube"===a.framebuffer_reglType)for(var b=0;6>b;++b)aa(E({framebuffer:a.framebuffer.faces[b]},a),f);else aa(a,f);else f(null,a)},prop:la.define.bind(null, +1),context:la.define.bind(null,2),"this":la.define.bind(null,3),draw:n({}),buffer:function(a){return F.create(a,34962,!1,!1)},elements:function(a){return T.create(a,!1)},texture:A.create2D,cube:A.createCube,renderbuffer:M.create,framebuffer:K.create,framebufferCube:K.createCube,attributes:h,frame:r,on:function(a,b){var c;switch(a){case "frame":return r(b);case "lost":c=U;break;case "restore":c=W;break;case "destroy":c=Z}c.push(b);return{cancel:function(){for(var a=0;a0) { - shapeX += 0.02 - } - } - - var data = new Float32Array(bufferSize) - var ptr = 0 - var xOffset = -0.5 * shapeX - for(var i=0; i0) { + shapeX += 0.02 + } + } + + var data = new Float32Array(bufferSize) + var ptr = 0 + var xOffset = -0.5 * shapeX + for(var i=0; i" + var clsTag = "" + + var nOPN = opnTag.length + var nCLS = clsTag.length + + var isRecursive = (TAG_CHR[0] === CHR_super0) || + (TAG_CHR[0] === CHR_sub0); + + var a = 0 + var b = -nCLS + while (a > -1) { + a = str.indexOf(opnTag, a) + if(a === -1) break + + b = str.indexOf(clsTag, a + nOPN) + if(b === -1) break + + if(b <= a) break + + for(var i = a; i < b + nCLS; ++i){ + if((i < a + nOPN) || (i >= b)) { + map[i] = null + str = str.substr(0, i) + " " + str.substr(i + 1) + } else { + if(map[i] !== null) { + var pos = map[i].indexOf(TAG_CHR[0]) + if(pos === -1) { + map[i] += TAG_CHR + } else { // i.e. to handle multiple sub/super-scripts + if(isRecursive) { + // i.e to increase the sub/sup number + map[i] = map[i].substr(0, pos + 1) + (1 + parseInt(map[i][pos + 1])) + map[i].substr(pos + 2) + } + } + } + } + } + + var start = a + nOPN + var remainingStr = str.substr(start, b - start) + + var c = remainingStr.indexOf(opnTag) + if(c !== -1) a = c + else a = b + nCLS + } + + return map +} + function transformPositions(positions, options, size) { var align = options.textAlign || "start" var baseline = options.textBaseline || "alphabetic" @@ -70151,27 +70303,169 @@ function transformPositions(positions, options, size) { }) } -function getPixels(canvas, context, str, size) { - var width = Math.ceil(context.measureText(str).width + 2*size)|0 - if(width > 8192) { - throw new Error("vectorize-text: String too long (sorry, this will get fixed later)") +function getPixels(canvas, context, rawString, fontSize, lineSpacing, styletags) { + + rawString = rawString.replace(/\n/g, '') // don't accept \n in the input + + if(styletags.breaklines === true) { + rawString = rawString.replace(/\/g, '\n') // replace
tags with \n in the string + } else { + rawString = rawString.replace(/\/g, ' ') // don't accept
tags in the input and replace with space in this case } - var height = 3 * size - if(canvas.height < height) { - canvas.height = height + + var activeStyle = "" + var map = [] + for(j = 0; j < rawString.length; ++j) { + map[j] = activeStyle + } + + if(styletags.bolds === true) map = parseTag(TAG_bold, CHR_bold, rawString, map) + if(styletags.italics === true) map = parseTag(TAG_italic, CHR_italic, rawString, map) + if(styletags.superscripts === true) map = parseTag(TAG_super, CHR_super, rawString, map) + if(styletags.subscripts === true) map = parseTag(TAG_sub, CHR_sub, rawString, map) + + var allStyles = [] + var plainText = "" + for(j = 0; j < rawString.length; ++j) { + if(map[j] !== null) { + plainText += rawString[j] + allStyles.push(map[j]) + } + } + + var allTexts = plainText.split('\n') + + var numberOfLines = allTexts.length + var lineHeight = Math.round(lineSpacing * fontSize) + var offsetX = fontSize + var offsetY = fontSize * 2 + var maxWidth = 0 + var minHeight = numberOfLines * lineHeight + offsetY + + if(canvas.height < minHeight) { + canvas.height = minHeight } context.fillStyle = "#000" context.fillRect(0, 0, canvas.width, canvas.height) context.fillStyle = "#fff" - context.fillText(str, size, 2*size) + var i, j, xPos, yPos, zPos + var nDone = 0 - //Cut pixels from image - var pixelData = context.getImageData(0, 0, width, height) - var pixels = ndarray(pixelData.data, [height, width, 4]) + for(i = 0; i < numberOfLines; ++i) { + + var txt = allTexts[i] + '\n' + xPos = 0 + yPos = i * lineHeight + zPos = fontSize + + var buffer = "" + function writeBuffer() { + if(buffer !== "") { + var delta = context.measureText(buffer).width + + context.fillText(buffer, offsetX + xPos, offsetY + yPos) + xPos += delta + } + } + + function changeStyle(oldStyle, newStyle) { + + function getTextFontSize() { + return "" + Math.round(zPos) + "px "; + } + + var ctxFont = "" + context.font; + + if(styletags.subscripts === true) { + var oldIndex_Sub = oldStyle.indexOf(CHR_sub0); + var newIndex_Sub = newStyle.indexOf(CHR_sub0); + + var oldSub = (oldIndex_Sub > -1) ? parseInt(oldStyle[1 + oldIndex_Sub]) : 0; + var newSub = (newIndex_Sub > -1) ? parseInt(newStyle[1 + newIndex_Sub]) : 0; + + if(oldSub !== newSub) { + ctxFont = ctxFont.replace(getTextFontSize(), "?px ") + zPos *= Math.pow(0.75, (newSub - oldSub)) + ctxFont = ctxFont.replace("?px ", getTextFontSize()) + } + yPos += 0.25 * lineHeight * (newSub - oldSub); + } + + if(styletags.superscripts === true) { + var oldIndex_Super = oldStyle.indexOf(CHR_super0); + var newIndex_Super = newStyle.indexOf(CHR_super0); + + var oldSuper = (oldIndex_Super > -1) ? parseInt(oldStyle[1 + oldIndex_Super]) : 0; + var newSuper = (newIndex_Super > -1) ? parseInt(newStyle[1 + newIndex_Super]) : 0; + + if(oldSuper !== newSuper) { + ctxFont = ctxFont.replace(getTextFontSize(), "?px ") + zPos *= Math.pow(0.75, (newSuper - oldSuper)) + ctxFont = ctxFont.replace("?px ", getTextFontSize()) + } + yPos -= 0.25 * lineHeight * (newSuper - oldSuper); + } + + if(styletags.bolds === true) { + var wasBold = (oldStyle.indexOf(CHR_bold) > -1) + var is_Bold = (newStyle.indexOf(CHR_bold) > -1) + + if(!wasBold && is_Bold) { + if(wasItalic) { + ctxFont = ctxFont.replace("italic ", "italic bold ") + } else { + ctxFont = "bold " + ctxFont + } + } + if(wasBold && !is_Bold) { + ctxFont = ctxFont.replace("bold ", '') + } + } + + if(styletags.italics === true) { + var wasItalic = (oldStyle.indexOf(CHR_italic) > -1) + var is_Italic = (newStyle.indexOf(CHR_italic) > -1) + + if(!wasItalic && is_Italic) { + ctxFont = "italic " + ctxFont + } + if(wasItalic && !is_Italic) { + ctxFont = ctxFont.replace("italic ", '') + } + } + + context.font = ctxFont + } + + for(j = 0; j < txt.length; ++j) { + var style = (j + nDone < allStyles.length) ? allStyles[j + nDone] : allStyles[allStyles.length - 1] + if(activeStyle === style) { + buffer += txt[j] + } else { + writeBuffer() + buffer = txt[j] + + if(style !== undefined) { + changeStyle(activeStyle, style) + activeStyle = style + } + } + } + writeBuffer() + + nDone += txt.length - return pixels.pick(-1,-1,0).transpose(1,0) + var width = Math.round(xPos + 2 * offsetX) | 0 + if(maxWidth < width) maxWidth = width + } + + //Cut pixels from image + var xCut = maxWidth + var yCut = offsetY + lineHeight * numberOfLines + var pixels = ndarray(context.getImageData(0, 0, xCut, yCut).data, [yCut, xCut, 4]) + return pixels.pick(-1, -1, 0).transpose(1, 0) } function getContour(pixels, doSimplify) { @@ -70258,20 +70552,65 @@ function processPixels(pixels, options, size) { } function vectorizeText(str, canvas, context, options) { - var size = options.size || 64 - var family = options.font || "normal" - context.font = size + "px " + family + var size = 64 + var lineSpacing = 1.25 + var styletags = { + breaklines: false, + bolds: false, + italics: false, + subscripts: false, + superscripts: false + } + + if(options) { + + if(options.size && + options.size > 0) size = + options.size + + if(options.lineSpacing && + options.lineSpacing > 0) lineSpacing = + options.lineSpacing + + if(options.styletags && + options.styletags.breaklines) styletags.breaklines = + options.styletags.breaklines ? true : false + + if(options.styletags && + options.styletags.bolds) styletags.bolds = + options.styletags.bolds ? true : false + + if(options.styletags && + options.styletags.italics) styletags.italics = + options.styletags.italics ? true : false + + if(options.styletags && + options.styletags.subscripts) styletags.subscripts = + options.styletags.subscripts ? true : false + + if(options.styletags && + options.styletags.superscripts) styletags.superscripts = + options.styletags.superscripts ? true : false + } + + context.font = [ + options.fontStyle, + options.fontVariant, + options.fontWeight, + size + "px", + options.font + ].filter(function(d) {return d}).join(" ") context.textAlign = "start" context.textBaseline = "alphabetic" context.direction = "ltr" - var pixels = getPixels(canvas, context, str, size) + var pixels = getPixels(canvas, context, str, size, lineSpacing, styletags) return processPixels(pixels, options, size) } -},{"cdt2d":94,"clean-pslg":104,"ndarray":433,"planar-graph-to-polyline":451,"simplify-planar-graph":500,"surface-nets":508}],529:[function(_dereq_,module,exports){ +},{"cdt2d":94,"clean-pslg":104,"ndarray":433,"planar-graph-to-polyline":451,"simplify-planar-graph":500,"surface-nets":507}],528:[function(_dereq_,module,exports){ // Copyright (C) 2011 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -70958,7 +71297,7 @@ function vectorizeText(str, canvas, context, options) { } })(); -},{}],530:[function(_dereq_,module,exports){ +},{}],529:[function(_dereq_,module,exports){ var hiddenStore = _dereq_('./hidden-store.js'); module.exports = createStore; @@ -70979,7 +71318,7 @@ function createStore() { }; } -},{"./hidden-store.js":531}],531:[function(_dereq_,module,exports){ +},{"./hidden-store.js":530}],530:[function(_dereq_,module,exports){ module.exports = hiddenStore; function hiddenStore(obj, key) { @@ -70997,7 +71336,7 @@ function hiddenStore(obj, key) { return store; } -},{}],532:[function(_dereq_,module,exports){ +},{}],531:[function(_dereq_,module,exports){ // Original - @Gozola. // https://gist.github.com/Gozala/1269991 // This is a reimplemented version (with a few bug fixes). @@ -71028,14 +71367,14 @@ function weakMap() { } } -},{"./create-store.js":530}],533:[function(_dereq_,module,exports){ +},{"./create-store.js":529}],532:[function(_dereq_,module,exports){ var getContext = _dereq_('get-canvas-context') module.exports = function getWebGLContext (opt) { return getContext('webgl', opt) } -},{"get-canvas-context":221}],534:[function(_dereq_,module,exports){ +},{"get-canvas-context":221}],533:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -71768,7 +72107,7 @@ function toSolar(yearOrDate, monthOrResult, day, isIntercalaryOrResult, result) } -},{"../main":548,"object-assign":437}],535:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],534:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -71952,7 +72291,7 @@ assign(CopticCalendar.prototype, { main.calendars.coptic = CopticCalendar; -},{"../main":548,"object-assign":437}],536:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],535:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -72180,7 +72519,7 @@ var centuries = { main.calendars.discworld = DiscworldCalendar; -},{"../main":548,"object-assign":437}],537:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],536:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -72364,7 +72703,7 @@ assign(EthiopianCalendar.prototype, { main.calendars.ethiopian = EthiopianCalendar; -},{"../main":548,"object-assign":437}],538:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],537:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -72638,7 +72977,7 @@ function mod(a, b) { main.calendars.hebrew = HebrewCalendar; -},{"../main":548,"object-assign":437}],539:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],538:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -72819,7 +73158,7 @@ assign(IslamicCalendar.prototype, { main.calendars.islamic = IslamicCalendar; -},{"../main":548,"object-assign":437}],540:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],539:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -73002,7 +73341,7 @@ assign(JulianCalendar.prototype, { main.calendars.julian = JulianCalendar; -},{"../main":548,"object-assign":437}],541:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],540:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -73297,7 +73636,7 @@ function amod(a, b) { main.calendars.mayan = MayanCalendar; -},{"../main":548,"object-assign":437}],542:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],541:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -73477,7 +73816,7 @@ assign(NanakshahiCalendar.prototype, { main.calendars.nanakshahi = NanakshahiCalendar; -},{"../main":548,"object-assign":437}],543:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],542:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -73900,7 +74239,7 @@ assign(NepaliCalendar.prototype, { main.calendars.nepali = NepaliCalendar; -},{"../main":548,"object-assign":437}],544:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],543:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -74090,7 +74429,7 @@ main.calendars.persian = PersianCalendar; main.calendars.jalali = PersianCalendar; -},{"../main":548,"object-assign":437}],545:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],544:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -74276,7 +74615,7 @@ assign(TaiwanCalendar.prototype, { main.calendars.taiwan = TaiwanCalendar; -},{"../main":548,"object-assign":437}],546:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],545:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -74462,7 +74801,7 @@ assign(ThaiCalendar.prototype, { main.calendars.thai = ThaiCalendar; -},{"../main":548,"object-assign":437}],547:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],546:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -74827,7 +75166,7 @@ var ummalqura_dat = [ 79990]; -},{"../main":548,"object-assign":437}],548:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],547:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -75732,7 +76071,7 @@ _exports.baseCalendar = BaseCalendar; _exports.calendars.gregorian = GregorianCalendar; -},{"object-assign":437}],549:[function(_dereq_,module,exports){ +},{"object-assign":437}],548:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -76234,7 +76573,7 @@ assign(main.baseCalendar.prototype, { }); -},{"./main":548,"object-assign":437}],550:[function(_dereq_,module,exports){ +},{"./main":547,"object-assign":437}],549:[function(_dereq_,module,exports){ module.exports = _dereq_('cwise-compiler')({ args: ['array', { offset: [1], @@ -76286,7 +76625,7 @@ module.exports = _dereq_('cwise-compiler')({ funcName: 'zeroCrossings' }) -},{"cwise-compiler":134}],551:[function(_dereq_,module,exports){ +},{"cwise-compiler":134}],550:[function(_dereq_,module,exports){ "use strict" module.exports = findZeroCrossings @@ -76299,7 +76638,7 @@ function findZeroCrossings(array, level) { core(array.hi(array.shape[0]-1), cross, level) return cross } -},{"./lib/zc-core":550}],552:[function(_dereq_,module,exports){ +},{"./lib/zc-core":549}],551:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76370,7 +76709,7 @@ module.exports = [ } ]; -},{}],553:[function(_dereq_,module,exports){ +},{}],552:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76917,7 +77256,7 @@ module.exports = templatedArray('annotation', { } }); -},{"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750,"../../plots/font_attributes":771,"./arrow_paths":552}],554:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746,"../../plots/font_attributes":767,"./arrow_paths":551}],553:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77006,7 +77345,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"./draw":559}],555:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"./draw":558}],554:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77145,7 +77484,7 @@ function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":696,"../../plot_api/plot_template":734,"../../registry":827}],556:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../registry":823}],555:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77225,7 +77564,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":696,"../color":570}],557:[function(_dereq_,module,exports){ +},{"../../lib":692,"../color":569}],556:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77288,7 +77627,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":722,"fast-isnumeric":214}],558:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":718,"fast-isnumeric":214}],557:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77394,7 +77733,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/cartesian/axes":744,"./attributes":553,"./common_defaults":556}],559:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/cartesian/axes":740,"./attributes":552,"./common_defaults":555}],558:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77808,14 +78147,14 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { x: borderfull + xShift - 1, y: borderfull + yShift }) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; annText.call(svgTextUtils.positionText, textx, texty) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } annTextClip.select('rect').call(Drawing.setRect, borderfull, borderfull, @@ -77981,7 +78320,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }); }, doneFn: function() { - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -78064,7 +78403,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }, doneFn: function() { setCursor(annTextGroupInner); - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -78088,13 +78427,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { modifyBase(ya._name + '.autorange', true); } - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); }); } else annText.call(textLayout); } -},{"../../lib":696,"../../lib/setcursor":716,"../../lib/svg_text_utils":720,"../../plot_api/plot_template":734,"../../plots/cartesian/axes":744,"../../plots/plots":808,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"../fx":612,"./draw_arrow_head":560,"d3":148}],560:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/setcursor":712,"../../lib/svg_text_utils":716,"../../plot_api/plot_template":730,"../../plots/cartesian/axes":740,"../../plots/plots":804,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"../fx":608,"./draw_arrow_head":559,"d3":148}],559:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78248,7 +78587,7 @@ module.exports = function drawArrowHead(el3, ends, options) { if(doEnd) drawhead(headStyle, end, endRot, scale); }; -},{"../color":570,"./arrow_paths":552,"d3":148}],561:[function(_dereq_,module,exports){ +},{"../color":569,"./arrow_paths":551,"d3":148}],560:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78282,7 +78621,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":755,"./attributes":553,"./calc_autorange":554,"./click":555,"./convert_coords":557,"./defaults":558,"./draw":559}],562:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":751,"./attributes":552,"./calc_autorange":553,"./click":554,"./convert_coords":556,"./defaults":557,"./draw":558}],561:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78380,7 +78719,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../annotations/attributes":553}],563:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../annotations/attributes":552}],562:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78445,7 +78784,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":696,"../../plots/cartesian/axes":744}],564:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740}],563:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78521,7 +78860,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/cartesian/axes":744,"../annotations/common_defaults":556,"./attributes":562}],565:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/cartesian/axes":740,"../annotations/common_defaults":555,"./attributes":561}],564:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78573,7 +78912,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":796,"../annotations/draw":559}],566:[function(_dereq_,module,exports){ +},{"../../plots/gl3d/project":792,"../annotations/draw":558}],565:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78621,7 +78960,7 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":696,"../../registry":827,"./attributes":562,"./convert":563,"./defaults":564,"./draw":565}],567:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"./attributes":561,"./convert":562,"./defaults":563,"./draw":564}],566:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78654,7 +78993,7 @@ _dereq_('world-calendars/dist/calendars/taiwan'); _dereq_('world-calendars/dist/calendars/thai'); _dereq_('world-calendars/dist/calendars/ummalqura'); -},{"world-calendars/dist/calendars/chinese":534,"world-calendars/dist/calendars/coptic":535,"world-calendars/dist/calendars/discworld":536,"world-calendars/dist/calendars/ethiopian":537,"world-calendars/dist/calendars/hebrew":538,"world-calendars/dist/calendars/islamic":539,"world-calendars/dist/calendars/julian":540,"world-calendars/dist/calendars/mayan":541,"world-calendars/dist/calendars/nanakshahi":542,"world-calendars/dist/calendars/nepali":543,"world-calendars/dist/calendars/persian":544,"world-calendars/dist/calendars/taiwan":545,"world-calendars/dist/calendars/thai":546,"world-calendars/dist/calendars/ummalqura":547,"world-calendars/dist/main":548,"world-calendars/dist/plus":549}],568:[function(_dereq_,module,exports){ +},{"world-calendars/dist/calendars/chinese":533,"world-calendars/dist/calendars/coptic":534,"world-calendars/dist/calendars/discworld":535,"world-calendars/dist/calendars/ethiopian":536,"world-calendars/dist/calendars/hebrew":537,"world-calendars/dist/calendars/islamic":538,"world-calendars/dist/calendars/julian":539,"world-calendars/dist/calendars/mayan":540,"world-calendars/dist/calendars/nanakshahi":541,"world-calendars/dist/calendars/nepali":542,"world-calendars/dist/calendars/persian":543,"world-calendars/dist/calendars/taiwan":544,"world-calendars/dist/calendars/thai":545,"world-calendars/dist/calendars/ummalqura":546,"world-calendars/dist/main":547,"world-calendars/dist/plus":548}],567:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78928,7 +79267,7 @@ module.exports = { worldCalFmt: worldCalFmt }; -},{"../../constants/numerical":673,"../../lib":696,"./calendars":567}],569:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"./calendars":566}],568:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78968,7 +79307,7 @@ exports.borderLine = '#BEC8D9'; // gives back exactly lightLine if the other colors are defaults. exports.lightFraction = 100 * (0xe - 0x4) / (0xf - 0x4); -},{}],570:[function(_dereq_,module,exports){ +},{}],569:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79139,7 +79478,7 @@ function cleanOne(val) { return 'rgb(' + rgbStr + ')'; } -},{"./attributes":569,"fast-isnumeric":214,"tinycolor2":514}],571:[function(_dereq_,module,exports){ +},{"./attributes":568,"fast-isnumeric":214,"tinycolor2":513}],570:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79317,26 +79656,61 @@ module.exports = overrideAll({ exponentformat: axesAttrs.exponentformat, showexponent: axesAttrs.showexponent, title: { - valType: 'string', - role: 'info', - description: 'Sets the title of the color bar.' + text: { + valType: 'string', + role: 'info', + description: [ + 'Sets the title of the color bar.', + 'Note that before the existence of `title.text`, the title\'s', + 'contents used to be defined as the `title` attribute itself.', + 'This behavior has been deprecated.' + ].join(' ') + }, + font: fontAttrs({ + description: [ + 'Sets this color bar\'s title font.', + 'Note that the title\'s font used to be set', + 'by the now deprecated `titlefont` attribute.' + ].join(' ') + }), + side: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + role: 'style', + dflt: 'top', + description: [ + 'Determines the location of color bar\'s title', + 'with respect to the color bar.', + 'Note that the title\'s location used to be set', + 'by the now deprecated `titleside` attribute.' + ].join(' ') + } }, - titlefont: fontAttrs({ - description: 'Sets this color bar\'s title font.' - }), - titleside: { - valType: 'enumerated', - values: ['right', 'top', 'bottom'], - role: 'style', - dflt: 'top', - description: [ - 'Determines the location of the colorbar title', - 'with respect to the color bar.' - ].join(' ') + + _deprecated: { + title: { + valType: 'string', + role: 'info', + description: [ + 'Deprecated in favor of color bar\'s `title.text`.', + 'Note that value of color bar\'s `title` is no longer a simple', + '*string* but a set of sub-attributes.' + ].join(' ') + }, + titlefont: fontAttrs({ + description: 'Deprecated in favor of color bar\'s `title.font`.' + }), + titleside: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + role: 'style', + dflt: 'top', + description: 'Deprecated in favor of color bar\'s `title.side`.' + } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/cartesian/layout_attributes":757,"../../plots/font_attributes":771}],572:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/cartesian/layout_attributes":753,"../../plots/font_attributes":767}],571:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79345,10 +79719,10 @@ module.exports = overrideAll({ * LICENSE file in the root directory of this source tree. */ - 'use strict'; var drawColorbar = _dereq_('./draw'); +var flipScale = _dereq_('../colorscale/helpers').flipScale; /** * connectColorbar: create a colorbar from a trace, using its module to @@ -79388,12 +79762,16 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) { var cb = cd[0].t.cb = drawColorbar(gd, cbId); - cb.fillgradient(container.colorscale) + var scl = container.reversescale ? + flipScale(container.colorscale) : + container.colorscale; + + cb.fillgradient(scl) .zrange([container[moduleOpts.min], container[moduleOpts.max]]) .options(container.colorbar)(); }; -},{"./draw":575}],573:[function(_dereq_,module,exports){ +},{"../colorscale/helpers":580,"./draw":574}],572:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79421,7 +79799,7 @@ module.exports = { } }; -},{}],574:[function(_dereq_,module,exports){ +},{}],573:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79483,12 +79861,12 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); - coerce('title', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'titlefont', layout.font); - coerce('titleside'); + coerce('title.text', layout._dfltTitle.colorbar); + Lib.coerceFont(coerce, 'title.font', layout.font); + coerce('title.side'); }; -},{"../../lib":696,"../../plot_api/plot_template":734,"../../plots/cartesian/tick_label_defaults":764,"../../plots/cartesian/tick_mark_defaults":765,"../../plots/cartesian/tick_value_defaults":766,"./attributes":571}],575:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../plots/cartesian/tick_label_defaults":760,"../../plots/cartesian/tick_mark_defaults":761,"../../plots/cartesian/tick_value_defaults":762,"./attributes":570}],574:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79675,9 +80053,9 @@ module.exports = function draw(gd, id) { showticksuffix: opts.showticksuffix, ticksuffix: opts.ticksuffix, title: opts.title, - titlefont: opts.titlefont, showline: true, anchor: 'free', + side: 'right', position: 1 }, cbAxisOut = { @@ -79688,6 +80066,7 @@ module.exports = function draw(gd, id) { letter: 'y', font: fullLayout.font, noHover: true, + noTickson: true, calendar: fullLayout.calendar // not really necessary (yet?) }; @@ -79708,11 +80087,11 @@ module.exports = function draw(gd, id) { // save for other callers to access this axis component.axis = cbAxisOut; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { - cbAxisOut.titleside = opts.titleside; + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { + cbAxisOut.title.side = opts.title.side; cbAxisOut.titlex = opts.x + xpadFrac; cbAxisOut.titley = yBottomFrac + - (opts.titleside === 'top' ? lenFrac - ypadFrac : ypadFrac); + (opts.title.side === 'top' ? lenFrac - ypadFrac : ypadFrac); } if(opts.line.color && opts.tickmode === 'auto') { @@ -79772,17 +80151,18 @@ module.exports = function draw(gd, id) { Math.round(gs.l) + ',-' + Math.round(gs.t) + ')'); - cbAxisOut._axislayer = container.select('.cbaxis'); + var axisLayer = container.select('.cbaxis'); + var titleHeight = 0; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // draw the title so we know how much room it needs // when we squish the axis. This one only applies to // top or bottom titles, not right side. var x = gs.l + (opts.x + xpadFrac) * gs.w, - fontSize = cbAxisOut.titlefont.size, + fontSize = cbAxisOut.title.font.size, y; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; } @@ -79796,7 +80176,7 @@ module.exports = function draw(gd, id) { } function drawAxis() { - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // squish the axis top to make room for the title var titleGroup = container.select('.cbtitle'), titleText = titleGroup.select('text'), @@ -79827,7 +80207,7 @@ module.exports = function draw(gd, id) { // TODO: configurable titleHeight += 5; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; } @@ -79848,8 +80228,7 @@ module.exports = function draw(gd, id) { .attr('transform', 'translate(0,' + Math.round(gs.h * (1 - cbAxisOut.domain[1])) + ')'); - cbAxisOut._axislayer.attr('transform', 'translate(0,' + - Math.round(-gs.t) + ')'); + axisLayer.attr('transform', 'translate(0,' + Math.round(-gs.t) + ')'); var fills = container.select('.cbfills') .selectAll('rect.cbfill') @@ -79916,12 +80295,7 @@ module.exports = function draw(gd, id) { }); // force full redraw of labels and ticks - cbAxisOut._axislayer.selectAll('g.' + cbAxisOut._id + 'tick,path') - .remove(); - - cbAxisOut._pos = xLeft + thickPx + - (opts.outlinewidth||0) / 2 - (opts.ticks === 'outside' ? 1 : 0); - cbAxisOut.side = 'right'; + axisLayer.selectAll('g.' + cbAxisOut._id + 'tick,path').remove(); // separate out axis and title drawing, // so we don't need such complicated logic in Titles.draw @@ -79929,11 +80303,33 @@ module.exports = function draw(gd, id) { // this title call only handles side=right return Lib.syncOrAsync([ function() { - return Axes.doTicksSingle(gd, cbAxisOut, true); + var shift = xLeft + thickPx + + (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0); + + var vals = Axes.calcTicks(cbAxisOut); + var transFn = Axes.makeTransFn(cbAxisOut); + var labelFns = Axes.makeLabelFns(cbAxisOut, shift); + var tickSign = Axes.getTickSigns(cbAxisOut)[2]; + + Axes.drawTicks(gd, cbAxisOut, { + vals: cbAxisOut.ticks === 'inside' ? Axes.clipEnds(cbAxisOut, vals) : vals, + layer: axisLayer, + path: Axes.makeTickPath(cbAxisOut, shift, tickSign), + transFn: transFn + }); + + return Axes.drawLabels(gd, cbAxisOut, { + vals: vals, + layer: axisLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); }, function() { - if(['top', 'bottom'].indexOf(opts.titleside) === -1) { - var fontSize = cbAxisOut.titlefont.size, + if(['top', 'bottom'].indexOf(opts.title.side) === -1) { + var fontSize = cbAxisOut.title.font.size, y = cbAxisOut._offset + cbAxisOut._length / 2, x = gs.l + (cbAxisOut.position || 0) * gs.w + ((cbAxisOut.side === 'right') ? 10 + fontSize * ((cbAxisOut.showticklabels ? 1 : 0.5)) : @@ -79945,7 +80341,7 @@ module.exports = function draw(gd, id) { drawTitle('h' + cbAxisOut._id + 'title', { avoid: { selection: d3.select(gd).selectAll('g.' + cbAxisOut._id + 'tick'), - side: opts.titleside, + side: opts.title.side, offsetLeft: gs.l, offsetTop: 0, maxShift: fullLayout.width @@ -79958,15 +80354,10 @@ module.exports = function draw(gd, id) { } function drawTitle(titleClass, titleOpts) { - var trace = getTrace(); - var propName = 'colorbar.title'; - var containerName = trace._module.colorbar.container; - if(containerName) propName = containerName + '.' + propName; - var dfltTitleOpts = { propContainer: cbAxisOut, - propName: propName, - traceIndex: trace.index, + propName: getPropName('title'), + traceIndex: getTrace().index, placeholder: fullLayout._dfltTitle.colorbar, containerGroup: container.select('.cbtitle') }; @@ -79990,7 +80381,7 @@ module.exports = function draw(gd, id) { // TODO: why are we redrawing multiple times now with this? // I guess autoMargin doesn't like being post-promise? var innerWidth = thickPx + opts.outlinewidth / 2 + - Drawing.bBox(cbAxisOut._axislayer.node()).width; + Drawing.bBox(axisLayer.node()).width; titleEl = titleCont.select('text'); if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) { var mathJaxNode = titleCont @@ -79998,11 +80389,11 @@ module.exports = function draw(gd, id) { .node(), titleWidth; if(mathJaxNode && - ['top', 'bottom'].indexOf(opts.titleside) !== -1) { + ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; } else { - // note: the formula below works for all titlesides, + // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift // transform gets removed by Drawing.bBox @@ -80031,7 +80422,7 @@ module.exports = function draw(gd, id) { container.selectAll('.cboutline').attr({ x: xLeft, y: yTopPx + opts.ypad + - (opts.titleside === 'top' ? titleHeight : 0), + (opts.title.side === 'top' ? titleHeight : 0), width: Math.max(thickPx, 2), height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2) }) @@ -80118,11 +80509,10 @@ module.exports = function draw(gd, id) { setCursor(container); if(xf !== undefined && yf !== undefined) { - Registry.call('restyle', - gd, - {'colorbar.x': xf, 'colorbar.y': yf}, - getTrace().index - ); + var update = {}; + update[getPropName('x')] = xf; + update[getPropName('y')] = yf; + Registry.call('_guiRestyle', gd, update, getTrace().index); } } }); @@ -80140,6 +80530,14 @@ module.exports = function draw(gd, id) { } } + function getPropName(suffix) { + var trace = getTrace(); + var propName = 'colorbar.'; + var containerName = trace._module.colorbar.container; + if(containerName) propName = containerName + '.' + propName; + return propName + suffix; + } + // setter/getters for every item defined in opts Object.keys(opts).forEach(function(name) { component[name] = function(v) { @@ -80173,7 +80571,7 @@ module.exports = function draw(gd, id) { return component; }; -},{"../../constants/alignment":668,"../../lib":696,"../../lib/extend":685,"../../lib/setcursor":716,"../../lib/svg_text_utils":720,"../../plots/cartesian/axes":744,"../../plots/cartesian/axis_defaults":746,"../../plots/cartesian/layout_attributes":757,"../../plots/cartesian/position_defaults":760,"../../plots/plots":808,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"../titles":661,"./attributes":571,"./constants":573,"d3":148,"tinycolor2":514}],576:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../lib":692,"../../lib/extend":682,"../../lib/setcursor":712,"../../lib/svg_text_utils":716,"../../plots/cartesian/axes":740,"../../plots/cartesian/axis_defaults":742,"../../plots/cartesian/layout_attributes":753,"../../plots/cartesian/position_defaults":756,"../../plots/plots":804,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"../titles":657,"./attributes":570,"./constants":572,"d3":148,"tinycolor2":513}],575:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80192,7 +80590,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":696}],577:[function(_dereq_,module,exports){ +},{"../../lib":692}],576:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80203,7 +80601,7 @@ module.exports = function hasColorbar(container) { 'use strict'; -var palettes = _dereq_('./scales.js'); +var palettes = _dereq_('./scales.js').scales; var paletteStr = Object.keys(palettes); function code(s) { @@ -80392,7 +80790,7 @@ module.exports = function colorScaleAttrs(context, opts) { valType: 'boolean', role: 'style', dflt: false, - editType: 'calc', + editType: 'plot', description: [ 'Reverses the color mapping if true.', effectDesc, @@ -80417,7 +80815,7 @@ module.exports = function colorScaleAttrs(context, opts) { return attrs; }; -},{"./scales.js":589}],578:[function(_dereq_,module,exports){ +},{"./scales.js":584}],577:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80426,49 +80824,19 @@ module.exports = function colorScaleAttrs(context, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); -var scales = _dereq_('./scales'); -var flipScale = _dereq_('./flip_scale'); - - -module.exports = function calc(trace, vals, containerStr, cLetter) { - var container = trace; - var inputContainer = trace._input; - var fullInputContainer = trace._fullInput; - - // set by traces with groupby transforms - var updateStyle = trace.updateStyle; - - function doUpdate(attr, inputVal, fullVal) { - if(fullVal === undefined) fullVal = inputVal; - - if(updateStyle) { - updateStyle(trace._input, containerStr ? (containerStr + '.' + attr) : attr, inputVal); - } - else { - inputContainer[attr] = inputVal; - } - - container[attr] = fullVal; - if(fullInputContainer && (trace !== trace._fullInput)) { - if(updateStyle) { - updateStyle(trace._fullInput, containerStr ? (containerStr + '.' + attr) : attr, fullVal); - } - else { - fullInputContainer[attr] = fullVal; - } - } - } +module.exports = function calc(gd, trace, opts) { + var fullLayout = gd._fullLayout; + var vals = opts.vals; + var containerStr = opts.containerStr; + var cLetter = opts.cLetter; - if(containerStr) { - container = Lib.nestedProperty(container, containerStr).get(); - inputContainer = Lib.nestedProperty(inputContainer, containerStr).get(); - fullInputContainer = Lib.nestedProperty(fullInputContainer, containerStr).get() || {}; - } + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() : + trace; var autoAttr = cLetter + 'auto'; var minAttr = cLetter + 'min'; @@ -80491,37 +80859,19 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { max += 0.5; } - doUpdate(minAttr, min); - doUpdate(maxAttr, max); - - /* - * If auto was explicitly false but min or max was missing, - * we filled in the missing piece here but later the trace does - * not look auto. - * Otherwise make sure the trace still looks auto as far as later - * changes are concerned. - */ - doUpdate(autoAttr, (auto !== false || (min === undefined && max === undefined))); + container['_' + minAttr] = container[minAttr] = min; + container['_' + maxAttr] = container[maxAttr] = max; if(container.autocolorscale) { - if(min * max < 0) scl = scales.RdBu; - else if(min >= 0) scl = scales.Reds; - else scl = scales.Blues; + if(min * max < 0) scl = fullLayout.colorscale.diverging; + else if(min >= 0) scl = fullLayout.colorscale.sequential; + else scl = fullLayout.colorscale.sequentialminus; - // reversescale is handled at the containerOut level - doUpdate('colorscale', scl, container.reversescale ? flipScale(scl) : scl); - - // We pushed a colorscale back to input, which will change the default autocolorscale next time - // to avoid spurious redraws from Plotly.react, update resulting autocolorscale now - // This is a conscious decision so that changing the data later does not unexpectedly - // give you a new colorscale - if(!inputContainer.autocolorscale) { - doUpdate('autocolorscale', false); - } + container._colorscale = container.colorscale = scl; } }; -},{"../../lib":696,"./flip_scale":582,"./scales":589}],579:[function(_dereq_,module,exports){ +},{"../../lib":692}],578:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80532,12 +80882,68 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { 'use strict'; -var scales = _dereq_('./scales'); +var Lib = _dereq_('../../lib'); +var hasColorscale = _dereq_('./helpers').hasColorscale; + +module.exports = function crossTraceDefaults(fullData) { + function replace(cont, k) { + var val = cont['_' + k]; + if(val !== undefined) { + cont[k] = val; + } + } + + function relinkColorAtts(trace, cAttrs) { + var cont = cAttrs.container ? + Lib.nestedProperty(trace, cAttrs.container).get() : + trace; + if(cont) { + var isAuto = cont.zauto || cont.cauto; + var minAttr = cAttrs.min; + var maxAttr = cAttrs.max; + + if(isAuto || cont[minAttr] === undefined) { + replace(cont, minAttr); + } + if(isAuto || cont[maxAttr] === undefined) { + replace(cont, maxAttr); + } + if(cont.autocolorscale) { + replace(cont, 'colorscale'); + } + } + } + + for(var i = 0; i < fullData.length; i++) { + var trace = fullData[i]; + var _module = trace._module; + + if(_module.colorbar) { + relinkColorAtts(trace, _module.colorbar); + } -module.exports = scales.RdBu; + // TODO could generalize _module.colorscale and use it here? -},{"./scales":589}],580:[function(_dereq_,module,exports){ + if(hasColorscale(trace, 'marker.line')) { + relinkColorAtts(trace, { + container: 'marker.line', + min: 'cmin', + max: 'cmax' + }); + } + + if(hasColorscale(trace, 'line')) { + relinkColorAtts(trace, { + container: 'line', + min: 'cmin', + max: 'cmax' + }); + } + } +}; + +},{"../../lib":692,"./helpers":580}],579:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80546,33 +80952,32 @@ module.exports = scales.RdBu; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); - var hasColorbar = _dereq_('../colorbar/has_colorbar'); var colorbarDefaults = _dereq_('../colorbar/defaults'); -var isValidScale = _dereq_('./is_valid_scale'); -var flipScale = _dereq_('./flip_scale'); +var isValidScale = _dereq_('./scales').isValid; + +function npMaybe(cont, prefix) { + var containerStr = prefix.slice(0, prefix.length - 1); + return prefix ? + Lib.nestedProperty(cont, containerStr).get() || {} : + cont; +} module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { - var prefix = opts.prefix, - cLetter = opts.cLetter, - containerStr = prefix.slice(0, prefix.length - 1), - containerIn = prefix ? - Lib.nestedProperty(traceIn, containerStr).get() || {} : - traceIn, - containerOut = prefix ? - Lib.nestedProperty(traceOut, containerStr).get() || {} : - traceOut, - minIn = containerIn[cLetter + 'min'], - maxIn = containerIn[cLetter + 'max'], - sclIn = containerIn.colorscale; + var prefix = opts.prefix; + var cLetter = opts.cLetter; + var containerIn = npMaybe(traceIn, prefix); + var containerOut = npMaybe(traceOut, prefix); + var template = npMaybe(traceOut._template || {}, prefix) || {}; + var minIn = containerIn[cLetter + 'min']; + var maxIn = containerIn[cLetter + 'max']; var validMinMax = isNumeric(minIn) && isNumeric(maxIn) && (minIn < maxIn); coerce(prefix + cLetter + 'auto', !validMinMax); coerce(prefix + cLetter + 'min'); @@ -80580,19 +80985,17 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, // handles both the trace case (autocolorscale is false by default) and // the marker and marker.line case (autocolorscale is true by default) + var sclIn = containerIn.colorscale; + var sclTemplate = template.colorscale; var autoColorscaleDflt; if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn); + if(sclTemplate !== undefined) autoColorscaleDflt = !isValidScale(sclTemplate); coerce(prefix + 'autocolorscale', autoColorscaleDflt); - var sclOut = coerce(prefix + 'colorscale'); - - // reversescale is handled at the containerOut level - var reverseScale = coerce(prefix + 'reversescale'); - if(reverseScale) containerOut.colorscale = flipScale(sclOut); - // ... until Scatter.colorbar can handle marker line colorbars - if(prefix === 'marker.line.') return; + coerce(prefix + 'colorscale'); + coerce(prefix + 'reversescale'); - if(!opts.noScale) { + if(!opts.noScale && prefix !== 'marker.line.') { // handles both the trace case where the dflt is listed in attributes and // the marker case where the dflt is determined by hasColorbar var showScaleDflt; @@ -80603,109 +81006,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, } }; -},{"../../lib":696,"../colorbar/defaults":574,"../colorbar/has_colorbar":576,"./flip_scale":582,"./is_valid_scale":586,"fast-isnumeric":214}],581:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -/** - * Extract colorscale into numeric domain and color range. - * - * @param {array} scl colorscale array of arrays - * @param {number} cmin minimum color value (used to clamp scale) - * @param {number} cmax maximum color value (used to clamp scale) - */ -module.exports = function extractScale(scl, cmin, cmax) { - var N = scl.length, - domain = new Array(N), - range = new Array(N); - - for(var i = 0; i < N; i++) { - var si = scl[i]; - - domain[i] = cmin + si[0] * (cmax - cmin); - range[i] = si[1]; - } - - return { - domain: domain, - range: range - }; -}; - -},{}],582:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function flipScale(scl) { - var N = scl.length, - sclNew = new Array(N), - si; - - for(var i = N - 1, j = 0; i >= 0; i--, j++) { - si = scl[i]; - sclNew[j] = [1 - si[0], si[1]]; - } - - return sclNew; -}; - -},{}],583:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var defaultScale = _dereq_('./default_scale'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function getScale(scl, dflt) { - if(!dflt) dflt = defaultScale; - if(!scl) return dflt; - - function parseScale() { - try { - scl = scales[scl] || JSON.parse(scl); - } - catch(e) { - scl = dflt; - } - } - - if(typeof scl === 'string') { - parseScale(); - // occasionally scl is double-JSON encoded... - if(typeof scl === 'string') parseScale(); - } - - if(!isValidScaleArray(scl)) return dflt; - return scl; -}; - -},{"./default_scale":579,"./is_valid_scale_array":587,"./scales":589}],584:[function(_dereq_,module,exports){ +},{"../../lib":692,"../colorbar/defaults":573,"../colorbar/has_colorbar":575,"./scales":584,"fast-isnumeric":214}],580:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80716,11 +81017,16 @@ module.exports = function getScale(scl, dflt) { 'use strict'; +var d3 = _dereq_('d3'); +var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); + var Lib = _dereq_('../../lib'); -var isValidScale = _dereq_('./is_valid_scale'); +var Color = _dereq_('../color'); -module.exports = function hasColorscale(trace, containerStr) { +var isValidScale = _dereq_('./scales').isValid; + +function hasColorscale(trace, containerStr) { var container = containerStr ? Lib.nestedProperty(trace, containerStr).get() || {} : trace; @@ -80745,117 +81051,61 @@ module.exports = function hasColorscale(trace, containerStr) { Lib.isPlainObject(container.colorbar) ) ); -}; - -},{"../../lib":696,"./is_valid_scale":586,"fast-isnumeric":214}],585:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -exports.scales = _dereq_('./scales'); - -exports.defaultScale = _dereq_('./default_scale'); - -exports.attributes = _dereq_('./attributes'); - -exports.handleDefaults = _dereq_('./defaults'); - -exports.calc = _dereq_('./calc'); - -exports.hasColorscale = _dereq_('./has_colorscale'); - -exports.isValidScale = _dereq_('./is_valid_scale'); - -exports.getScale = _dereq_('./get_scale'); - -exports.flipScale = _dereq_('./flip_scale'); - -exports.extractScale = _dereq_('./extract_scale'); - -exports.makeColorScaleFunc = _dereq_('./make_color_scale_func'); - -},{"./attributes":577,"./calc":578,"./default_scale":579,"./defaults":580,"./extract_scale":581,"./flip_scale":582,"./get_scale":583,"./has_colorscale":584,"./is_valid_scale":586,"./make_color_scale_func":588,"./scales":589}],586:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function isValidScale(scl) { - if(scales[scl] !== undefined) return true; - else return isValidScaleArray(scl); -}; +} -},{"./is_valid_scale_array":587,"./scales":589}],587:[function(_dereq_,module,exports){ /** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var tinycolor = _dereq_('tinycolor2'); - - -module.exports = function isValidScaleArray(scl) { - var highestVal = 0; + * Extract colorscale into numeric domain and color range. + * + * @param {object} cont colorscale container (e.g. trace, marker) + * - colorscale {array of arrays} + * - cmin/zmin {number} + * - cmax/zmax {number} + * - reversescale {boolean} + * @param {object} opts + * - cLetter {string} 'c' (for cmin/cmax) or 'z' (for zmin/zmax) + * + * @return {object} + * - domain {array} + * - range {array} + */ +function extractScale(cont, opts) { + var cLetter = opts.cLetter; - if(!Array.isArray(scl) || scl.length < 2) return false; + var scl = cont.reversescale ? + flipScale(cont.colorscale) : + cont.colorscale; - if(!scl[0] || !scl[scl.length - 1]) return false; + // minimum color value (used to clamp scale) + var cmin = cont[cLetter + 'min']; + // maximum color value (used to clamp scale) + var cmax = cont[cLetter + 'max']; - if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + var N = scl.length; + var domain = new Array(N); + var range = new Array(N); - for(var i = 0; i < scl.length; i++) { + for(var i = 0; i < N; i++) { var si = scl[i]; - - if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { - return false; - } - - highestVal = +si[0]; + domain[i] = cmin + si[0] * (cmax - cmin); + range[i] = si[1]; } - return true; -}; - -},{"tinycolor2":514}],588:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; + return { + domain: domain, + range: range + }; +} -var d3 = _dereq_('d3'); -var tinycolor = _dereq_('tinycolor2'); -var isNumeric = _dereq_('fast-isnumeric'); +function flipScale(scl) { + var N = scl.length; + var sclNew = new Array(N); -var Color = _dereq_('../color'); + for(var i = N - 1, j = 0; i >= 0; i--, j++) { + var si = scl[i]; + sclNew[j] = [1 - si[0], si[1]]; + } + return sclNew; +} /** * General colorscale function generator. @@ -80870,7 +81120,7 @@ var Color = _dereq_('../color'); * * @return {function} */ -module.exports = function makeColorScaleFunc(specs, opts) { +function makeColorScaleFunc(specs, opts) { opts = opts || {}; var domain = specs.domain, @@ -80922,7 +81172,7 @@ module.exports = function makeColorScaleFunc(specs, opts) { sclFunc.range = function() { return range; }; return sclFunc; -}; +} function colorArray2rbga(colorArray) { var colorObj = { @@ -80935,7 +81185,14 @@ function colorArray2rbga(colorArray) { return tinycolor(colorObj).toRgbString(); } -},{"../color":570,"d3":148,"fast-isnumeric":214,"tinycolor2":514}],589:[function(_dereq_,module,exports){ +module.exports = { + hasColorscale: hasColorscale, + extractScale: extractScale, + flipScale: flipScale, + makeColorScaleFunc: makeColorScaleFunc +}; + +},{"../../lib":692,"../color":569,"./scales":584,"d3":148,"fast-isnumeric":214,"tinycolor2":513}],581:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80946,8 +81203,125 @@ function colorArray2rbga(colorArray) { 'use strict'; +var scales = _dereq_('./scales'); +var helpers = _dereq_('./helpers'); module.exports = { + moduleType: 'component', + name: 'colorscale', + + attributes: _dereq_('./attributes'), + layoutAttributes: _dereq_('./layout_attributes'), + + supplyLayoutDefaults: _dereq_('./layout_defaults'), + handleDefaults: _dereq_('./defaults'), + crossTraceDefaults: _dereq_('./cross_trace_defaults'), + + calc: _dereq_('./calc'), + + // ./scales.js is required in lib/coerce.js ; + // it needs to be a seperate module to avoid circular a dependency + scales: scales.scales, + defaultScale: scales.defaultScale, + getScale: scales.get, + isValidScale: scales.isValid, + + hasColorscale: helpers.hasColorscale, + flipScale: helpers.flipScale, + extractScale: helpers.extractScale, + makeColorScaleFunc: helpers.makeColorScaleFunc +}; + +},{"./attributes":576,"./calc":577,"./cross_trace_defaults":578,"./defaults":579,"./helpers":580,"./layout_attributes":582,"./layout_defaults":583,"./scales":584}],582:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var scales = _dereq_('./scales').scales; + +var msg = 'Note that `autocolorscale` must be true for this attribute to work.'; + +module.exports = { + editType: 'calc', + sequential: { + valType: 'colorscale', + dflt: scales.Reds, + role: 'style', + editType: 'calc', + description: [ + 'Sets the default sequential colorscale for positive values.', + msg + ].join(' ') + }, + sequentialminus: { + valType: 'colorscale', + dflt: scales.Blues, + role: 'style', + editType: 'calc', + description: [ + 'Sets the default sequential colorscale for negative values.', + msg + ].join(' ') + }, + diverging: { + valType: 'colorscale', + dflt: scales.RdBu, + role: 'style', + editType: 'calc', + description: [ + 'Sets the default diverging colorscale.', + msg + ].join(' ') + } +}; + +},{"./scales":584}],583:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var Lib = _dereq_('../../lib'); +var colorscaleAttrs = _dereq_('./layout_attributes'); +var Template = _dereq_('../../plot_api/plot_template'); + +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var colorscaleIn = layoutIn.colorscale; + var colorscaleOut = Template.newContainer(layoutOut, 'colorscale'); + function coerce(attr, dflt) { + return Lib.coerce(colorscaleIn, colorscaleOut, colorscaleAttrs, attr, dflt); + } + + coerce('sequential'); + coerce('sequentialminus'); + coerce('diverging'); +}; + +},{"../../lib":692,"../../plot_api/plot_template":730,"./layout_attributes":582}],584:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var tinycolor = _dereq_('tinycolor2'); + +var scales = { 'Greys': [ [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] ], @@ -81078,7 +81452,67 @@ module.exports = { ] }; -},{}],590:[function(_dereq_,module,exports){ +var defaultScale = scales.RdBu; + +function getScale(scl, dflt) { + if(!dflt) dflt = defaultScale; + if(!scl) return dflt; + + function parseScale() { + try { + scl = scales[scl] || JSON.parse(scl); + } catch(e) { + scl = dflt; + } + } + + if(typeof scl === 'string') { + parseScale(); + // occasionally scl is double-JSON encoded... + if(typeof scl === 'string') parseScale(); + } + + if(!isValidScaleArray(scl)) return dflt; + return scl; +} + + +function isValidScaleArray(scl) { + var highestVal = 0; + + if(!Array.isArray(scl) || scl.length < 2) return false; + + if(!scl[0] || !scl[scl.length - 1]) return false; + + if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + + for(var i = 0; i < scl.length; i++) { + var si = scl[i]; + + if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { + return false; + } + + highestVal = +si[0]; + } + + return true; +} + +function isValidScale(scl) { + if(scales[scl] !== undefined) return true; + else return isValidScaleArray(scl); +} + +module.exports = { + scales: scales, + defaultScale: defaultScale, + + get: getScale, + isValid: isValidScale +}; + +},{"tinycolor2":513}],585:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81111,7 +81545,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],591:[function(_dereq_,module,exports){ +},{}],586:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81149,7 +81583,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":696}],592:[function(_dereq_,module,exports){ +},{"../../lib":692}],587:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81276,8 +81710,6 @@ dragElement.init = function init(options) { var clampFn = options.clampFn || _clampFn; function onStart(e) { - e.preventDefault(); - // make dragging and dragged into properties of gd // so that others can look at and modify them gd._dragged = false; @@ -81319,11 +81751,15 @@ dragElement.init = function init(options) { document.documentElement.style.cursor = window.getComputedStyle(element).cursor; } - document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onDone); - document.addEventListener('touchmove', onMove); document.addEventListener('touchend', onDone); + if(options.dragmode !== false) { + e.preventDefault(); + document.addEventListener('mousemove', onMove); + document.addEventListener('touchmove', onMove); + } + return; } @@ -81347,13 +81783,15 @@ dragElement.init = function init(options) { } function onDone(e) { - document.removeEventListener('mousemove', onMove); + if(options.dragmode !== false) { + e.preventDefault(); + document.removeEventListener('mousemove', onMove); + document.removeEventListener('touchmove', onMove); + } + document.removeEventListener('mouseup', onDone); - document.removeEventListener('touchmove', onMove); document.removeEventListener('touchend', onDone); - e.preventDefault(); - if(hasHover) { Lib.removeElement(dragCover); } @@ -81446,7 +81884,7 @@ function pointerOffset(e) { ); } -},{"../../constants/interactions":672,"../../lib":696,"../../plots/cartesian/constants":750,"../../registry":827,"./align":590,"./cursor":591,"./unhover":593,"has-hover":393,"has-passive-events":394,"mouse-event-offset":419}],593:[function(_dereq_,module,exports){ +},{"../../constants/interactions":668,"../../lib":692,"../../plots/cartesian/constants":746,"../../registry":823,"./align":585,"./cursor":586,"./unhover":588,"has-hover":393,"has-passive-events":394,"mouse-event-offset":419}],588:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81504,7 +81942,7 @@ unhover.raw = function unhoverRaw(gd, evt) { } }; -},{"../../lib/events":684,"../../lib/get_graph_div":691,"../../lib/throttle":721,"../fx/constants":607}],594:[function(_dereq_,module,exports){ +},{"../../lib/events":681,"../../lib/get_graph_div":688,"../../lib/throttle":717,"../fx/constants":602}],589:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81533,7 +81971,7 @@ exports.dash = { ].join(' ') }; -},{}],595:[function(_dereq_,module,exports){ +},{}],590:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81734,7 +82172,11 @@ drawing.fillGroupStyle = function(s) { s.style('stroke-width', 0) .each(function(d) { var shape = d3.select(this); - shape.call(Color.fill, d[0].trace.fillcolor); + // N.B. 'd' won't be a calcdata item when + // fill !== 'none' on a segment-less and marker-less trace + if(d[0].trace) { + shape.call(Color.fill, d[0].trace.fillcolor); + } }); }; @@ -82175,7 +82617,7 @@ drawing.tryColorscale = function(marker, prefix) { if(scl && Lib.isArrayOrTypedArray(colorArray)) { return Colorscale.makeColorScaleFunc( - Colorscale.extractScale(scl, cont.cmin, cont.cmax) + Colorscale.extractScale(cont, {cLetter: 'c'}) ); } } @@ -82536,32 +82978,28 @@ function nodeHash(node) { node.getAttribute('style'); } -/* - * make a robust clipPath url from a local id - * note! We'd better not be exporting from a page - * with a or the svg will not be portable! +/** + * Set clipPath URL in a way that work for all situations. + * + * In details, graphs on pages with HTML tags need to prepend + * the clip path ids with the page's base url EXCEPT during toImage exports. + * + * @param {d3 selection} s : node to add clip-path attribute + * @param {string} localId : local clip-path (w/o base url) id + * @param {DOM element || object} gd + * - context._baseUrl {string} + * - context._exportedPlot {boolean} */ -drawing.setClipUrl = function(s, localId) { +drawing.setClipUrl = function(s, localId, gd) { if(!localId) { s.attr('clip-path', null); return; } - if(drawing.baseUrl === undefined) { - var base = d3.select('base'); - - // Stash base url once and for all! - // We may have to stash this elsewhere when - // we'll try to support for child windows - // more info -> https://github.com/plotly/plotly.js/issues/702 - if(base.size() && base.attr('href')) { - drawing.baseUrl = window.location.href.split('#')[0]; - } else { - drawing.baseUrl = ''; - } - } + var context = gd._context; + var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - s.attr('clip-path', 'url(' + drawing.baseUrl + '#' + localId + ')'); + s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')'); }; drawing.getTranslate = function(element) { @@ -82693,7 +83131,7 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../constants/alignment":668,"../../constants/interactions":672,"../../constants/xmlns_namespaces":674,"../../lib":696,"../../lib/svg_text_utils":720,"../../registry":827,"../../traces/scatter/make_bubble_size_func":1060,"../../traces/scatter/subtypes":1067,"../color":570,"../colorscale":585,"./symbol_defs":596,"d3":148,"fast-isnumeric":214,"tinycolor2":514}],596:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../constants/interactions":668,"../../constants/xmlns_namespaces":670,"../../lib":692,"../../lib/svg_text_utils":716,"../../registry":823,"../../traces/scatter/make_bubble_size_func":1057,"../../traces/scatter/subtypes":1064,"../color":569,"../colorscale":581,"./symbol_defs":591,"d3":148,"fast-isnumeric":214,"tinycolor2":513}],591:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83181,7 +83619,7 @@ module.exports = { } }; -},{"d3":148}],597:[function(_dereq_,module,exports){ +},{"d3":148}],592:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83339,7 +83777,7 @@ module.exports = { } }; -},{}],598:[function(_dereq_,module,exports){ +},{}],593:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83421,7 +83859,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max); } -},{"../../plots/cartesian/axes":744,"../../registry":827,"./compute_error":599,"fast-isnumeric":214}],599:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../../registry":823,"./compute_error":594,"fast-isnumeric":214}],594:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83525,7 +83963,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],600:[function(_dereq_,module,exports){ +},{}],595:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83601,7 +84039,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":696,"../../plot_api/plot_template":734,"../../registry":827,"./attributes":597,"fast-isnumeric":214}],601:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../registry":823,"./attributes":592,"fast-isnumeric":214}],596:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83670,7 +84108,7 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":696,"../../plot_api/edit_types":727,"./attributes":597,"./calc":598,"./compute_error":599,"./defaults":600,"./plot":602,"./style":603}],602:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/edit_types":723,"./attributes":592,"./calc":593,"./compute_error":594,"./defaults":595,"./plot":597,"./style":598}],597:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83688,7 +84126,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); var subTypes = _dereq_('../../traces/scatter/subtypes'); -module.exports = function plot(traces, plotinfo, transitionOpts) { +module.exports = function plot(gd, traces, plotinfo, transitionOpts) { var isNew; var xa = plotinfo.xaxis; @@ -83739,7 +84177,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { .style('opacity', 1); } - Drawing.setClipUrl(errorbars, plotinfo.layerClipId); + Drawing.setClipUrl(errorbars, plotinfo.layerClipId, gd); errorbars.each(function(d) { var errorbar = d3.select(this); @@ -83844,7 +84282,7 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":1067,"../drawing":595,"d3":148,"fast-isnumeric":214}],603:[function(_dereq_,module,exports){ +},{"../../traces/scatter/subtypes":1064,"../drawing":590,"d3":148,"fast-isnumeric":214}],598:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83881,7 +84319,7 @@ module.exports = function style(traces) { }); }; -},{"../color":570,"d3":148}],604:[function(_dereq_,module,exports){ +},{"../color":569,"d3":148}],599:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83938,7 +84376,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":771}],605:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":767}],600:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83975,6 +84413,8 @@ module.exports = function calc(gd) { fillFn(trace.hoverinfo, cd, 'hi', makeCoerceHoverInfo(trace)); + if(trace.hovertemplate) fillFn(trace.hovertemplate, cd, 'ht'); + if(!trace.hoverlabel) continue; fillFn(trace.hoverlabel.bgcolor, cd, 'hbg'); @@ -83994,7 +84434,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":696,"../../registry":827}],606:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],601:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84032,7 +84472,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":827,"./hover":610}],607:[function(_dereq_,module,exports){ +},{"../../registry":823,"./hover":605}],602:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84064,7 +84504,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],608:[function(_dereq_,module,exports){ +},{}],603:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84087,7 +84527,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, layout.hoverlabel); }; -},{"../../lib":696,"./attributes":604,"./hoverlabel_defaults":611}],609:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":599,"./hoverlabel_defaults":606}],604:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84330,7 +84770,7 @@ function getPointData(val, pointNumber) { } } -},{"../../lib":696}],610:[function(_dereq_,module,exports){ +},{"../../lib":692}],605:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84459,13 +84899,17 @@ exports.loneHover = function loneHover(hoverItem, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; var container3 = d3.select(opts.container); @@ -84479,7 +84923,6 @@ exports.loneHover = function loneHover(hoverItem, opts) { container: container3, outerContainer: outerContainer3 }; - var hoverLabel = createHoverText([pointData], fullOpts, opts.gd); alignHoverText(hoverLabel, fullOpts.rotateLabels); @@ -84513,13 +84956,17 @@ exports.multiHovers = function multiHovers(hoverItems, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; }); @@ -84995,7 +85442,14 @@ function _hover(gd, evt, subplot, noHoverEvent) { // other people and send it to the event for(itemnum = 0; itemnum < hoverData.length; itemnum++) { var pt = hoverData[itemnum]; - newhoverdata.push(helpers.makeEventData(pt, pt.trace, pt.cd)); + var eventData = helpers.makeEventData(pt, pt.trace, pt.cd); + + var ht = false; + if(pt.cd[pt.index] && pt.cd[pt.index].ht) ht = pt.cd[pt.index].ht; + hoverData[itemnum].hovertemplate = ht || pt.trace.hovertemplate || false; + hoverData[itemnum].eventData = [eventData]; + + newhoverdata.push(eventData); } gd._hoverdata = newhoverdata; @@ -85053,6 +85507,8 @@ function _hover(gd, evt, subplot, noHoverEvent) { }); } +var EXTRA_STRING_REGEX = /([\s\S]*)<\/extra>/; + function createHoverText(hoverData, opts, gd) { var hovermode = opts.hovermode; var rotateLabels = opts.rotateLabels; @@ -85096,11 +85552,13 @@ function createHoverText(hoverData, opts, gd) { if(allHaveZ && hoverData[i].zLabel === undefined) allHaveZ = false; traceHoverinfo = hoverData[i].hoverinfo || hoverData[i].trace.hoverinfo; - var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); - if(parts.indexOf('all') === -1 && - parts.indexOf(hovermode) === -1) { - showCommonLabel = false; - break; + if(traceHoverinfo) { + var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); + if(parts.indexOf('all') === -1 && + parts.indexOf(hovermode) === -1) { + showCommonLabel = false; + break; + } } } @@ -85283,6 +85741,19 @@ function createHoverText(hoverData, opts, gd) { text = name; } + // hovertemplate + var hovertemplate = d.hovertemplate || false; + var hovertemplateLabels = d.hovertemplateLabels || d; + var eventData = d.eventData[0] || {}; + if(hovertemplate) { + text = Lib.hovertemplateString(hovertemplate, hovertemplateLabels, eventData); + + text = text.replace(EXTRA_STRING_REGEX, function(match, extra) { + name = extra; // Assign name for secondary text label + return ''; // Remove from main text label + }); + } + // main label var tx = g.select('text.nums') .call(Drawing.font, @@ -85681,7 +86152,7 @@ function cleanPoint(d, hovermode) { var infomode = d.hoverinfo || d.trace.hoverinfo; - if(infomode !== 'all') { + if(infomode && infomode !== 'all') { infomode = Array.isArray(infomode) ? infomode : infomode.split('+'); if(infomode.indexOf('x') === -1) d.xLabel = undefined; if(infomode.indexOf('y') === -1) d.yLabel = undefined; @@ -85867,8 +86338,11 @@ function hoverChanged(gd, evt, oldhoverdata) { for(var i = oldhoverdata.length - 1; i >= 0; i--) { var oldPt = oldhoverdata[i]; var newPt = gd._hoverdata[i]; + if(oldPt.curveNumber !== newPt.curveNumber || - String(oldPt.pointNumber) !== String(newPt.pointNumber)) { + String(oldPt.pointNumber) !== String(newPt.pointNumber) || + String(oldPt.pointNumbers) !== String(newPt.pointNumbers) + ) { return true; } } @@ -85884,7 +86358,7 @@ function spikesChanged(gd, oldspikepoints) { return false; } -},{"../../lib":696,"../../lib/events":684,"../../lib/override_cursor":707,"../../lib/svg_text_utils":720,"../../plots/cartesian/axes":744,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"./constants":607,"./helpers":609,"d3":148,"fast-isnumeric":214,"tinycolor2":514}],611:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/events":681,"../../lib/override_cursor":703,"../../lib/svg_text_utils":716,"../../plots/cartesian/axes":740,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"./constants":602,"./helpers":604,"d3":148,"fast-isnumeric":214,"tinycolor2":513}],606:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85906,7 +86380,59 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts Lib.coerceFont(coerce, 'hoverlabel.font', opts.font); }; -},{"../../lib":696}],612:[function(_dereq_,module,exports){ +},{"../../lib":692}],607:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function(opts, extra) { + opts = opts || {}; + extra = extra || {}; + + var descPart = extra.description ? ' ' + extra.description : ''; + var keys = extra.keys || []; + if(keys.length > 0) { + var quotedKeys = []; + for(var i = 0; i < keys.length; i++) { + quotedKeys[i] = '`' + keys[i] + '`'; + } + descPart = descPart + 'Finally, the template string has access to '; + if(keys.length === 1) { + descPart = 'variable ' + quotedKeys[0]; + } else { + descPart = 'variables ' + quotedKeys.slice(0, -1).join(', ') + ' and ' + quotedKeys.slice(-1) + '.'; + } + } + + var hovertemplate = { + valType: 'string', + role: 'info', + dflt: '', + arrayOk: true, + editType: 'none', + description: [ + 'Template string used for rendering the information that appear on hover box.', + 'Note that this will override `hoverinfo`.', + 'Variables are inserted using %{variable}, for example "y: %{y}".', + 'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".', + 'See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax.', + 'The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data.', + 'Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.', + descPart, + 'Anything contained in tag `` is displayed in the secondary box, for example "{fullData.name}".' + ].join(' ') + }; + + return hovertemplate; +}; + +},{}],608:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85986,7 +86512,7 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":696,"../dragelement":592,"./attributes":604,"./calc":605,"./click":606,"./constants":607,"./defaults":608,"./helpers":609,"./hover":610,"./layout_attributes":613,"./layout_defaults":614,"./layout_global_defaults":615,"d3":148}],613:[function(_dereq_,module,exports){ +},{"../../lib":692,"../dragelement":587,"./attributes":599,"./calc":600,"./click":601,"./constants":602,"./defaults":603,"./helpers":604,"./hover":605,"./layout_attributes":609,"./layout_defaults":610,"./layout_global_defaults":611,"d3":148}],609:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86033,7 +86559,7 @@ module.exports = { dragmode: { valType: 'enumerated', role: 'info', - values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'], + values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable', false], dflt: 'zoom', editType: 'modebar', description: [ @@ -86137,7 +86663,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":771,"./constants":607}],614:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":767,"./constants":602}],610:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86210,7 +86736,7 @@ function isHoriz(fullData) { return out; } -},{"../../lib":696,"./layout_attributes":613}],615:[function(_dereq_,module,exports){ +},{"../../lib":692,"./layout_attributes":609}],611:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86233,7 +86759,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":696,"./hoverlabel_defaults":611,"./layout_attributes":613}],616:[function(_dereq_,module,exports){ +},{"../../lib":692,"./hoverlabel_defaults":606,"./layout_attributes":609}],612:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86676,7 +87202,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":696,"../../lib/regex":712,"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750,"../../plots/domain":770}],617:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/regex":708,"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746,"../../plots/domain":766}],613:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86858,7 +87384,7 @@ module.exports = templatedArray('image', { editType: 'arraydraw' }); -},{"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750}],618:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746}],614:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86941,7 +87467,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":722,"fast-isnumeric":214}],619:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":718,"fast-isnumeric":214}],615:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87002,7 +87528,7 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/cartesian/axes":744,"./attributes":617}],620:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/cartesian/axes":740,"./attributes":613}],616:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87173,9 +87699,10 @@ module.exports = function draw(gd) { yId = ya ? ya._id : '', clipAxes = xId + yId; - thisImage.call(Drawing.setClipUrl, clipAxes ? - ('clip' + fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + thisImage, + clipAxes ? ('clip' + fullLayout._uid + clipAxes) : null, + gd ); } @@ -87223,7 +87750,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":674,"../../plots/cartesian/axes":744,"../drawing":595,"d3":148}],621:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":670,"../../plots/cartesian/axes":740,"../drawing":590,"d3":148}],617:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87247,56 +87774,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":755,"./attributes":617,"./convert_coords":618,"./defaults":619,"./draw":620}],622:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - - -/** - * Determine the position anchor property of x/y xanchor/yanchor components. - * - * - values < 1/3 align the low side at that fraction, - * - values [1/3, 2/3] align the center at that fraction, - * - values > 2/3 align the right at that fraction. - */ - -exports.isRightAnchor = function isRightAnchor(opts) { - return ( - opts.xanchor === 'right' || - (opts.xanchor === 'auto' && opts.x >= 2 / 3) - ); -}; - -exports.isCenterAnchor = function isCenterAnchor(opts) { - return ( - opts.xanchor === 'center' || - (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) - ); -}; - -exports.isBottomAnchor = function isBottomAnchor(opts) { - return ( - opts.yanchor === 'bottom' || - (opts.yanchor === 'auto' && opts.y <= 1 / 3) - ); -}; - -exports.isMiddleAnchor = function isMiddleAnchor(opts) { - return ( - opts.yanchor === 'middle' || - (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) - ); -}; - -},{}],623:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":751,"./attributes":613,"./convert_coords":614,"./defaults":615,"./draw":616}],618:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87419,10 +87897,29 @@ module.exports = { 'or *bottom* of the legend.' ].join(' ') }, + uirevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of legend-driven changes in trace and pie label', + 'visibility. Defaults to `layout.uirevision`.' + ].join(' ') + }, + valign: { + valType: 'enumerated', + values: ['top', 'middle', 'bottom'], + dflt: 'middle', + role: 'style', + editType: 'legend', + description: [ + 'Sets the vertical alignment of the symbols with respect to their associated text.', + ].join(' ') + }, editType: 'legend' }; -},{"../../plots/font_attributes":771,"../color/attributes":569}],624:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":767,"../color/attributes":568}],619:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87441,7 +87938,7 @@ module.exports = { textOffsetX: 40 }; -},{}],625:[function(_dereq_,module,exports){ +},{}],620:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87510,7 +88007,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { basePlotLayoutAttributes, 'showlegend', legendReallyHasATrace && legendTraceCount > 1); - if(showLegend === false) return; + if(showLegend === false && !containerIn.uirevision) return; var containerOut = Template.newContainer(layoutOut, 'legend'); @@ -87518,6 +88015,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); } + coerce('uirevision', layoutOut.uirevision); + + if(showLegend === false) return; + coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); @@ -87526,7 +88027,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('orientation'); if(containerOut.orientation === 'h') { var xaxis = layoutIn.xaxis; - if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { + if(Registry.getComponentMethod('rangeslider', 'isVisible')(xaxis)) { defaultX = 0; defaultXAnchor = 'left'; defaultY = 1.1; @@ -87547,10 +88048,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('xanchor', defaultXAnchor); coerce('y', defaultY); coerce('yanchor', defaultYAnchor); + coerce('valign'); Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); }; -},{"../../lib":696,"../../plot_api/plot_template":734,"../../plots/layout_attributes":799,"../../registry":827,"./attributes":623,"./helpers":629}],626:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../plots/layout_attributes":795,"../../registry":823,"./attributes":618,"./helpers":624}],621:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87583,7 +88085,6 @@ var FROM_BR = alignmentConstants.FROM_BR; var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); -var anchorUtils = _dereq_('./anchor_utils'); var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; @@ -87707,17 +88208,17 @@ module.exports = function draw(gd) { lx = gs.l + gs.w * opts.x, ly = gs.t + gs.h * (1 - opts.y); - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= opts._width; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= opts._height; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -87777,7 +88278,7 @@ module.exports = function draw(gd) { y: opts.borderwidth }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; @@ -87815,7 +88316,7 @@ module.exports = function draw(gd) { y: opts.borderwidth + scrollBoxY }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -87892,7 +88393,7 @@ module.exports = function draw(gd) { }, doneFn: function() { if(xf !== undefined && yf !== undefined) { - Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf}); + Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf}); } }, clickFn: function(numClicks, e) { @@ -87999,7 +88500,7 @@ function drawTexts(g, gd, maxLength) { update.name = newName; } - return Registry.call('restyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, traceIndex); }); } else { textLayout(textEl); @@ -88089,6 +88590,7 @@ function computeTextDimensions(g, gd) { // to avoid getBoundingClientRect var textY = lineHeight * (0.3 + (1 - textLines) / 2); svgTextUtils.positionText(text, constants.textOffsetX, textY); + legendItem.lineHeight = lineHeight; } height = Math.max(height, 16) + 3; @@ -88252,18 +88754,18 @@ function expandMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -88283,10 +88785,10 @@ function expandHorizontalMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } @@ -88301,7 +88803,7 @@ function expandHorizontalMargin(gd) { }); } -},{"../../constants/alignment":668,"../../constants/interactions":672,"../../lib":696,"../../lib/events":684,"../../lib/svg_text_utils":720,"../../plots/plots":808,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"./anchor_utils":622,"./constants":624,"./get_legend_data":627,"./handle_click":628,"./helpers":629,"./style":631,"d3":148}],627:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../constants/interactions":668,"../../lib":692,"../../lib/events":681,"../../lib/svg_text_utils":716,"../../plots/plots":804,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"./constants":619,"./get_legend_data":622,"./handle_click":623,"./helpers":624,"./style":626,"d3":148}],622:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88407,7 +88909,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":827,"./helpers":629}],628:[function(_dereq_,module,exports){ +},{"../../registry":823,"./helpers":624}],623:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88521,7 +89023,7 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices); + Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices); } else { var hasLegendgroup = legendgroup && legendgroup.length; var traceIndicesInGroup = []; @@ -88627,11 +89129,11 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', gd, attrUpdate, attrIndices); + Registry.call('_guiRestyle', gd, attrUpdate, attrIndices); } }; -},{"../../lib":696,"../../registry":827}],629:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],624:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88655,7 +89157,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],630:[function(_dereq_,module,exports){ +},{}],625:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88679,7 +89181,7 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":623,"./defaults":625,"./draw":626,"./style":631}],631:[function(_dereq_,module,exports){ +},{"./attributes":618,"./defaults":620,"./draw":621,"./style":626}],626:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88707,6 +89209,19 @@ module.exports = function style(s, gd) { var layers = Lib.ensureSingle(traceGroup, 'g', 'layers'); layers.style('opacity', d[0].trace.opacity); + // Marker vertical alignment + var valign = gd._fullLayout.legend.valign; + var lineHeight = d[0].lineHeight; + var height = d[0].height; + + if(valign === 'middle' || !lineHeight || !height) { + layers.attr('transform', null); // this here is a fun d3 trick to unset DOM attributes + } else { + var factor = {top: 1, bottom: -1}[valign]; + var markerOffsetY = factor * (0.5 * (lineHeight - height + 3)); + layers.attr('transform', 'translate(0,' + markerOffsetY + ')'); + } + var fill = layers .selectAll('g.legendfill') .data([d]); @@ -89026,7 +89541,7 @@ module.exports = function style(s, gd) { } }; -},{"../../lib":696,"../../registry":827,"../../traces/pie/style_one":1029,"../../traces/scatter/subtypes":1067,"../color":570,"../drawing":595,"d3":148}],632:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"../../traces/pie/style_one":1026,"../../traces/scatter/subtypes":1064,"../color":569,"../drawing":590,"d3":148}],627:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89290,7 +89805,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -89346,7 +89861,7 @@ function handleDrag3d(gd, ev) { var val2d = (val === 'pan') ? val : 'zoom'; layoutUpdate.dragmode = val2d; - Registry.call('relayout', gd, layoutUpdate); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.resetCameraDefault3d = { @@ -89385,7 +89900,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -89399,54 +89914,48 @@ modeBarButtons.hoverClosest3d = { click: handleHover3d }; -function handleHover3d(gd, ev) { +function getNextHover3d(gd, ev) { var button = ev.currentTarget; - var val = button._previousVal || false; - var layout = gd.layout; + var val = button._previousVal; var fullLayout = gd._fullLayout; var sceneIds = fullLayout._subplots.gl3d; var axes = ['xaxis', 'yaxis', 'zaxis']; - var spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor']; // initialize 'current spike' object to be stored in the DOM var currentSpikes = {}; - var axisSpikes = {}; var layoutUpdate = {}; if(val) { - layoutUpdate = Lib.extendDeep(layout, val); + layoutUpdate = val; button._previousVal = null; } else { - layoutUpdate = { - 'allaxes.showspikes': false - }; - for(var i = 0; i < sceneIds.length; i++) { - var sceneId = sceneIds[i], - sceneLayout = fullLayout[sceneId], - sceneSpikes = currentSpikes[sceneId] = {}; + var sceneId = sceneIds[i]; + var sceneLayout = fullLayout[sceneId]; - sceneSpikes.hovermode = sceneLayout.hovermode; - layoutUpdate[sceneId + '.hovermode'] = false; + var hovermodeAStr = sceneId + '.hovermode'; + currentSpikes[hovermodeAStr] = sceneLayout.hovermode; + layoutUpdate[hovermodeAStr] = false; // copy all the current spike attrs for(var j = 0; j < 3; j++) { var axis = axes[j]; - axisSpikes = sceneSpikes[axis] = {}; - - for(var k = 0; k < spikeAttrs.length; k++) { - var spikeAttr = spikeAttrs[k]; - axisSpikes[spikeAttr] = sceneLayout[axis][spikeAttr]; - } + var spikeAStr = sceneId + '.' + axis + '.showspikes'; + layoutUpdate[spikeAStr] = false; + currentSpikes[spikeAStr] = sceneLayout[axis].showspikes; } } - button._previousVal = Lib.extendDeep({}, currentSpikes); + button._previousVal = currentSpikes; } + return layoutUpdate; +} - Registry.call('relayout', gd, layoutUpdate); +function handleHover3d(gd, ev) { + var layoutUpdate = getNextHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.zoomInGeo = { @@ -89502,7 +90011,7 @@ function handleGeo(gd, ev) { var scale = geoLayout.projection.scale; var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; - Registry.call('relayout', gd, id + '.projection.scale', newScale); + Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); } else if(attr === 'reset') { resetView(gd, 'geo'); } @@ -89530,18 +90039,20 @@ modeBarButtons.hoverClosestPie = { click: toggleHover }; -function toggleHover(gd) { +function getNextHover(gd) { var fullLayout = gd._fullLayout; - var onHoverVal; + if(fullLayout.hovermode) return false; + if(fullLayout._has('cartesian')) { - onHoverVal = fullLayout._isHoriz ? 'y' : 'x'; + return fullLayout._isHoriz ? 'y' : 'x'; } - else onHoverVal = 'closest'; - - var newHover = gd._fullLayout.hovermode ? false : onHoverVal; + return 'closest'; +} - Registry.call('relayout', gd, 'hovermode', newHover); +function toggleHover(gd) { + var newHover = getNextHover(gd); + Registry.call('_guiRelayout', gd, 'hovermode', newHover); } // buttons when more then one plot types are present @@ -89555,12 +90066,10 @@ modeBarButtons.toggleHover = { icon: Icons.tooltip_basic, gravity: 'ne', click: function(gd, ev) { - toggleHover(gd); + var layoutUpdate = getNextHover3d(gd, ev); + layoutUpdate.hovermode = getNextHover(gd); - // the 3d hovermode update must come - // last so that layout.hovermode update does not - // override scene?.hovermode?.layout. - handleHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } }; @@ -89596,7 +90105,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } }; @@ -89643,10 +90152,10 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', gd, aObj); + Registry.call('_guiRelayout', gd, aObj); } -},{"../../../build/ploticon":2,"../../lib":696,"../../plots/cartesian/axis_ids":747,"../../plots/plots":808,"../../registry":827}],633:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":692,"../../plots/cartesian/axis_ids":743,"../../plots/plots":804,"../../registry":823}],628:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89660,7 +90169,7 @@ function resetView(gd, subplotType) { exports.manage = _dereq_('./manage'); -},{"./manage":634}],634:[function(_dereq_,module,exports){ +},{"./manage":629}],629:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89692,7 +90201,7 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar) { + if(!context.displayModeBar && !context.watermark) { if(modeBar) { modeBar.destroy(); delete fullLayout._modeBar; @@ -89720,11 +90229,15 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); } + else if(!context.displayModeBar && context.watermark) { + buttonGroups = []; + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, - context.modeBarButtonsToAdd + context.modeBarButtonsToAdd, + context.showSendToCloud ); } @@ -89733,7 +90246,7 @@ module.exports = function manageModeBar(gd) { }; // logic behind which buttons are displayed by default -function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { +function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; @@ -89764,7 +90277,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { } // buttons common to all plot types - addGroup(['toImage', 'sendDataToCloud']); + var commonGroup = ['toImage']; + if(showSendToCloud) commonGroup.push('sendDataToCloud'); + addGroup(commonGroup); var zoomGroup = []; var hoverGroup = []; @@ -89915,7 +90430,7 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":747,"../../registry":827,"../../traces/scatter/subtypes":1067,"./buttons":632,"./modebar":635}],635:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axis_ids":743,"../../registry":823,"../../traces/scatter/subtypes":1064,"./buttons":627,"./modebar":630}],630:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89998,11 +90513,16 @@ proto.update = function(graphInfo, buttons) { this.updateButtons(buttons); - if(context.displaylogo) { + if(context.watermark || context.displaylogo) { + var logoGroup = this.getLogo(); + if(context.watermark) { + logoGroup.className = logoGroup.className + ' watermark'; + } + if(fullLayout.modebar.orientation === 'v') { - this.element.prepend(this.getLogo()); + this.element.prepend(logoGroup); } else { - this.element.appendChild(this.getLogo()); + this.element.appendChild(logoGroup); } this.hasLogo = true; @@ -90261,7 +90781,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../../build/ploticon":2,"../../lib":696,"d3":148,"fast-isnumeric":214}],636:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":692,"d3":148,"fast-isnumeric":214}],631:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90429,7 +90949,7 @@ module.exports = { editType: 'plot' }; -},{"../../plot_api/plot_template":734,"../../plots/font_attributes":771,"../color/attributes":569}],637:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":730,"../../plots/font_attributes":767,"../color/attributes":568}],632:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90458,7 +90978,7 @@ module.exports = { darkAmount: 10 }; -},{}],638:[function(_dereq_,module,exports){ +},{}],633:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90551,7 +91071,7 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":696,"../../plot_api/plot_template":734,"../../plots/array_container_defaults":740,"../color":570,"./attributes":636,"./constants":637}],639:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../plots/array_container_defaults":736,"../color":569,"./attributes":631,"./constants":632}],634:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90571,7 +91091,6 @@ var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var alignmentConstants = _dereq_('../../constants/alignment'); var LINE_SPACING = alignmentConstants.LINE_SPACING; @@ -90623,7 +91142,7 @@ module.exports = function draw(gd) { button.on('click', function() { if(gd._dragged) return; - Registry.call('relayout', gd, update); + Registry.call('_guiRelayout', gd, update); }); button.on('mouseover', function() { @@ -90772,21 +91291,21 @@ function reposition(gd, buttons, opts, axName, selector) { var ly = graphSize.t + graphSize.h * (1 - opts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= width; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(opts)) { + if(Lib.isCenterAnchor(opts)) { lx -= width / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(opts)) { + if(Lib.isMiddleAnchor(opts)) { ly -= height / 2; yanchor = 'middle'; } @@ -90808,7 +91327,7 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', 'translate(' + lx + ',' + ly + ')'); } -},{"../../constants/alignment":668,"../../lib":696,"../../lib/svg_text_utils":720,"../../plots/cartesian/axis_ids":747,"../../plots/plots":808,"../../registry":827,"../color":570,"../drawing":595,"../legend/anchor_utils":622,"./constants":637,"./get_update_object":640,"d3":148}],640:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../lib":692,"../../lib/svg_text_utils":716,"../../plots/cartesian/axis_ids":743,"../../plots/plots":804,"../../registry":823,"../color":569,"../drawing":590,"./constants":632,"./get_update_object":635,"d3":148}],635:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90865,7 +91384,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":148}],641:[function(_dereq_,module,exports){ +},{"d3":148}],636:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90892,7 +91411,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":636,"./defaults":638,"./draw":639}],642:[function(_dereq_,module,exports){ +},{"./attributes":631,"./defaults":633,"./draw":634}],637:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90987,7 +91506,7 @@ module.exports = { editType: 'calc' }; -},{"../color/attributes":569}],643:[function(_dereq_,module,exports){ +},{"../color/attributes":568}],638:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91021,7 +91540,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":743,"../../plots/cartesian/axis_ids":747,"./constants":644}],644:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/autorange":739,"../../plots/cartesian/axis_ids":743,"./constants":639}],639:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91077,7 +91596,7 @@ module.exports = { extraPad: 15 }; -},{}],645:[function(_dereq_,module,exports){ +},{}],640:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91163,7 +91682,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":696,"../../plot_api/plot_template":734,"../../plots/cartesian/axis_ids":747,"./attributes":642,"./oppaxis_attributes":648}],646:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../plots/cartesian/axis_ids":743,"./attributes":637,"./oppaxis_attributes":644}],641:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91185,7 +91704,7 @@ var Color = _dereq_('../color'); var Titles = _dereq_('../titles'); var Cartesian = _dereq_('../../plots/cartesian'); -var Axes = _dereq_('../../plots/cartesian/axes'); +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); var dragElement = _dereq_('../dragelement'); var setCursor = _dereq_('../../lib/setcursor'); @@ -91193,8 +91712,13 @@ var setCursor = _dereq_('../../lib/setcursor'); var constants = _dereq_('./constants'); module.exports = function(gd) { - var fullLayout = gd._fullLayout, - rangeSliderData = makeRangeSliderData(fullLayout); + var fullLayout = gd._fullLayout; + var rangeSliderData = fullLayout._rangeSliderData; + for(var i = 0; i < rangeSliderData.length; i++) { + var opts = rangeSliderData[i][constants.name]; + // fullLayout._uid may not exist when we call makeData + opts._clipId = opts._id + '-' + fullLayout._uid; + } /* * @@ -91221,10 +91745,6 @@ module.exports = function(gd) { .selectAll('g.' + constants.containerClassName) .data(rangeSliderData, keyFunction); - rangeSliders.enter().append('g') - .classed(constants.containerClassName, true) - .attr('pointer-events', 'all'); - // remove exiting sliders and their corresponding clip paths rangeSliders.exit().each(function(axisOpts) { var opts = axisOpts[constants.name]; @@ -91234,48 +91754,51 @@ module.exports = function(gd) { // return early if no range slider is visible if(rangeSliderData.length === 0) return; + rangeSliders.enter().append('g') + .classed(constants.containerClassName, true) + .attr('pointer-events', 'all'); + // for all present range sliders rangeSliders.each(function(axisOpts) { - var rangeSlider = d3.select(this), - opts = axisOpts[constants.name], - oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)], - oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)]; + var rangeSlider = d3.select(this); + var opts = axisOpts[constants.name]; + var oppAxisOpts = fullLayout[axisIDs.id2name(axisOpts.anchor)]; + var oppAxisRangeOpts = opts[axisIDs.id2name(axisOpts.anchor)]; // update range // Expand slider range to the axis range - // TODO: what if the ranges are reversed? if(opts.range) { - var outRange = opts.range; - var axRange = axisOpts.range; + var rng = Lib.simpleMap(opts.range, axisOpts.r2l); + var axRng = Lib.simpleMap(axisOpts.range, axisOpts.r2l); + var newRng; + + if(axRng[0] < axRng[1]) { + newRng = [ + Math.min(rng[0], axRng[0]), + Math.max(rng[1], axRng[1]) + ]; + } else { + newRng = [ + Math.max(rng[0], axRng[0]), + Math.min(rng[1], axRng[1]) + ]; + } - outRange[0] = axisOpts.l2r(Math.min(axisOpts.r2l(outRange[0]), axisOpts.r2l(axRange[0]))); - outRange[1] = axisOpts.l2r(Math.max(axisOpts.r2l(outRange[1]), axisOpts.r2l(axRange[1]))); - opts._input.range = outRange.slice(); + opts.range = opts._input.range = Lib.simpleMap(newRng, axisOpts.l2r); } axisOpts.cleanRange('rangeslider.range'); - // update range slider dimensions var margin = fullLayout.margin; var graphSize = fullLayout._size; var domain = axisOpts.domain; - var tickHeight = (axisOpts._boundingBox || {}).height || 0; + var tickHeight = opts._tickHeight; - var oppBottom = Infinity; - var subplotData = Axes.getSubplots(gd, axisOpts); - for(var i = 0; i < subplotData.length; i++) { - var oppAxis = Axes.getFromId(gd, subplotData[i].substr(subplotData[i].indexOf('y'))); - oppBottom = Math.min(oppBottom, oppAxis.domain[0]); - } - - opts._id = constants.name + axisOpts._id; - opts._clipId = opts._id + '-' + fullLayout._uid; + var oppBottom = opts._oppBottom; opts._width = graphSize.w * (domain[1] - domain[0]); - opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; - opts._offsetShift = Math.floor(opts.borderwidth / 2); var x = Math.round(margin.l + (graphSize.w * domain[0])); @@ -91338,41 +91861,14 @@ module.exports = function(gd) { placeholder: fullLayout._dfltTitle.x, attributes: { x: axisOpts._offset + axisOpts._length / 2, - y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size, + y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.title.font.size, 'text-anchor': 'middle' } }); } - - // update margins - Plots.autoMargin(gd, opts._id, { - x: domain[0], - y: oppBottom, - l: 0, - r: 0, - t: 0, - b: opts._height + margin.b + tickHeight, - pad: constants.extraPad + opts._offsetShift * 2 - }); }); }; -function makeRangeSliderData(fullLayout) { - var axes = Axes.list({ _fullLayout: fullLayout }, 'x', true), - name = constants.name, - out = []; - - if(fullLayout._has('gl2d')) return out; - - for(var i = 0; i < axes.length; i++) { - var ax = axes[i]; - - if(ax[name] && ax[name].visible) out.push(ax); - } - - return out; -} - function setupDragElement(rangeSlider, gd, axisOpts, opts) { var slideBox = rangeSlider.select('rect.' + constants.slideBoxClassName).node(), grabAreaMin = rangeSlider.select('rect.' + constants.grabAreaMinClassName).node(), @@ -91452,7 +91948,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) { dataMax = clamp(opts.p2d(opts._pixelMax)); window.requestAnimationFrame(function() { - Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); + Registry.call('_guiRelayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); }); } @@ -91559,15 +92055,14 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) { } function drawRangePlot(rangeSlider, gd, axisOpts, opts) { - var subplotData = Axes.getSubplots(gd, axisOpts), - calcData = gd.calcdata; + var calcData = gd.calcdata; var rangePlots = rangeSlider.selectAll('g.' + constants.rangePlotClassName) - .data(subplotData, Lib.identity); + .data(axisOpts._subplotsWith, Lib.identity); rangePlots.enter().append('g') .attr('class', function(id) { return constants.rangePlotClassName + ' ' + id; }) - .call(Drawing.setClipUrl, opts._clipId); + .call(Drawing.setClipUrl, opts._clipId, gd); rangePlots.order(); @@ -91579,7 +92074,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var plotgroup = d3.select(this), isMainPlot = (i === 0); - var oppAxisOpts = Axes.getFromId(gd, id, 'y'), + var oppAxisOpts = axisIDs.getFromId(gd, id, 'y'), oppAxisName = oppAxisOpts._name, oppAxisRangeOpts = opts[oppAxisName]; @@ -91611,6 +92106,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var xa = mockFigure._fullLayout.xaxis; var ya = mockFigure._fullLayout[oppAxisName]; + xa.clearCalc(); + xa.setScale(); + ya.clearCalc(); + ya.setScale(); + var plotinfo = { id: id, plotgroup: plotgroup, @@ -91763,7 +92263,77 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":696,"../../lib/setcursor":716,"../../plots/cartesian":756,"../../plots/cartesian/axes":744,"../../plots/plots":808,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"../titles":661,"./constants":644,"d3":148}],647:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/setcursor":712,"../../plots/cartesian":752,"../../plots/cartesian/axis_ids":743,"../../plots/plots":804,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"../titles":657,"./constants":639,"d3":148}],642:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); +var constants = _dereq_('./constants'); +var name = constants.name; + +function isVisible(ax) { + var rangeSlider = ax && ax[name]; + return rangeSlider && rangeSlider.visible; +} +exports.isVisible = isVisible; + +exports.makeData = function(fullLayout) { + var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true); + var margin = fullLayout.margin; + var rangeSliderData = []; + + if(!fullLayout._has('gl2d')) { + for(var i = 0; i < axes.length; i++) { + var ax = axes[i]; + + if(isVisible(ax)) { + rangeSliderData.push(ax); + + var opts = ax[name]; + opts._id = name + ax._id; + opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; + opts._offsetShift = Math.floor(opts.borderwidth / 2); + } + } + } + + fullLayout._rangeSliderData = rangeSliderData; +}; + +exports.autoMarginOpts = function(gd, ax) { + var opts = ax[name]; + + var oppBottom = Infinity; + var counterAxes = ax._counterAxes; + for(var j = 0; j < counterAxes.length; j++) { + var counterId = counterAxes[j]; + var oppAxis = axisIDs.getFromId(gd, counterId); + oppBottom = Math.min(oppBottom, oppAxis.domain[0]); + } + opts._oppBottom = oppBottom; + + var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0; + opts._tickHeight = tickHeight; + + return { + x: 0, + y: oppBottom, + l: 0, + r: 0, + t: 0, + b: opts._height + gd._fullLayout.margin.b + tickHeight, + pad: constants.extraPad + opts._offsetShift * 2 + }; +}; + +},{"../../plots/cartesian/axis_ids":743,"./constants":639}],643:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91777,6 +92347,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { var Lib = _dereq_('../../lib'); var attrs = _dereq_('./attributes'); var oppAxisAttrs = _dereq_('./oppaxis_attributes'); +var helpers = _dereq_('./helpers'); module.exports = { moduleType: 'component', @@ -91795,10 +92366,13 @@ module.exports = { layoutAttributes: _dereq_('./attributes'), handleDefaults: _dereq_('./defaults'), calcAutorange: _dereq_('./calc_autorange'), - draw: _dereq_('./draw') + draw: _dereq_('./draw'), + isVisible: helpers.isVisible, + makeData: helpers.makeData, + autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":696,"./attributes":642,"./calc_autorange":643,"./defaults":645,"./draw":646,"./oppaxis_attributes":648}],648:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":637,"./calc_autorange":638,"./defaults":640,"./draw":641,"./helpers":642,"./oppaxis_attributes":644}],644:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91845,7 +92419,7 @@ module.exports = { editType: 'calc' }; -},{}],649:[function(_dereq_,module,exports){ +},{}],645:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92089,7 +92663,7 @@ module.exports = templatedArray('shape', { editType: 'arraydraw' }); -},{"../../lib/extend":685,"../../plot_api/plot_template":734,"../../traces/scatter/attributes":1043,"../annotations/attributes":553,"../drawing/attributes":594}],650:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plot_api/plot_template":730,"../../traces/scatter/attributes":1040,"../annotations/attributes":552,"../drawing/attributes":589}],646:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92098,7 +92672,6 @@ module.exports = templatedArray('shape', { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); @@ -92176,7 +92749,7 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { } function shapeBounds(ax, v0, v1, path, paramsToUse) { - var convertVal = (ax.type === 'category') ? ax.r2c : ax.d2c; + var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; if(!path) return; @@ -92207,7 +92780,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"./constants":651,"./helpers":654}],651:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"./constants":647,"./helpers":650}],647:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92271,7 +92844,7 @@ module.exports = { } }; -},{}],652:[function(_dereq_,module,exports){ +},{}],648:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92396,7 +92969,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/cartesian/axes":744,"./attributes":649,"./helpers":654}],653:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/cartesian/axes":740,"./attributes":645,"./helpers":650}],649:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92519,9 +93092,10 @@ function setClipPath(shapePath, gd, shapeOptions) { // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 var clipAxes = (shapeOptions.xref + shapeOptions.yref).replace(/paper/g, ''); - shapePath.call(Drawing.setClipUrl, clipAxes ? - ('clip' + gd._fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } @@ -92705,7 +93279,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { // Don't rely on clipPath being activated during re-layout setClipPath(shapePath, gd, shapeOptions); - Registry.call('relayout', gd, editHelpers.getUpdateObj()); + Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj()); } function abortDrag() { @@ -92892,9 +93466,10 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(xref !== 'paper' && !xa.autorange) clipAxes += xref; if(yref !== 'paper' && !ya.autorange) clipAxes += yref; - shapePath.call(Drawing.setClipUrl, clipAxes ? - 'clip' + gd._fullLayout._uid + clipAxes : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } } @@ -93026,7 +93601,7 @@ function movePath(pathIn, moveX, moveY) { }); } -},{"../../lib":696,"../../lib/setcursor":716,"../../plot_api/plot_template":734,"../../plots/cartesian/axes":744,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"./constants":651,"./helpers":654}],654:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/setcursor":712,"../../plot_api/plot_template":730,"../../plots/cartesian/axes":740,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"./constants":647,"./helpers":650}],650:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93151,7 +93726,7 @@ exports.roundPositionForSharpStrokeRendering = function(pos, strokeWidth) { return strokeWidthIsOdd ? posValAsInt + 0.5 : posValAsInt; }; -},{"../../lib":696,"./constants":651}],655:[function(_dereq_,module,exports){ +},{"../../lib":692,"./constants":647}],651:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93178,7 +93753,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":755,"./attributes":649,"./calc_autorange":650,"./defaults":652,"./draw":653}],656:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":751,"./attributes":645,"./calc_autorange":646,"./defaults":648,"./draw":649}],652:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93314,7 +93889,7 @@ module.exports = overrideAll(templatedArray('slider', { role: 'style', description: 'Sets the x position (in normalized coordinates) of the slider.' }, - pad: extendDeepAll({}, padAttrs, { + pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { description: 'Set the padding of the slider component along each side.' }, {t: {dflt: 20}}), xanchor: { @@ -93473,7 +94048,7 @@ module.exports = overrideAll(templatedArray('slider', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../../plots/animation_attributes":739,"../../plots/font_attributes":771,"../../plots/pad_attributes":807,"./constants":657}],657:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../../plots/animation_attributes":735,"../../plots/font_attributes":767,"../../plots/pad_attributes":803,"./constants":653}],653:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93567,7 +94142,7 @@ module.exports = { currentValueInset: 0, }; -},{}],658:[function(_dereq_,module,exports){ +},{}],654:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93684,7 +94259,7 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"./attributes":656,"./constants":657}],659:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"./attributes":652,"./constants":653}],655:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93702,7 +94277,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var constants = _dereq_('./constants'); @@ -93894,21 +94468,21 @@ function findDimensions(gd, sliderOpts) { dims.height = dims.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + dims.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(sliderOpts)) { + if(Lib.isRightAnchor(sliderOpts)) { dims.lx -= dims.outerLength; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(sliderOpts)) { + if(Lib.isCenterAnchor(sliderOpts)) { dims.lx -= dims.outerLength / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(sliderOpts)) { + if(Lib.isBottomAnchor(sliderOpts)) { dims.ly -= dims.height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(sliderOpts)) { + if(Lib.isMiddleAnchor(sliderOpts)) { dims.ly -= dims.height / 2; yanchor = 'middle'; } @@ -94315,7 +94889,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":668,"../../lib":696,"../../lib/svg_text_utils":720,"../../plot_api/plot_template":734,"../../plots/plots":808,"../color":570,"../drawing":595,"../legend/anchor_utils":622,"./constants":657,"d3":148}],660:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../lib":692,"../../lib/svg_text_utils":716,"../../plot_api/plot_template":730,"../../plots/plots":804,"../color":569,"../drawing":590,"./constants":653,"d3":148}],656:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94338,7 +94912,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":656,"./constants":657,"./defaults":658,"./draw":659}],661:[function(_dereq_,module,exports){ +},{"./attributes":652,"./constants":653,"./defaults":654,"./draw":655}],657:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94408,19 +94982,21 @@ function draw(gd, titleClass, options) { var group = options.containerGroup; var fullLayout = gd._fullLayout; - var titlefont = cont.titlefont || {}; - var font = titlefont.family; - var fontSize = titlefont.size; - var fontColor = titlefont.color; var opacity = 1; var isplaceholder = false; - var txt = (cont.title || '').trim(); + var title = cont.title; + var txt = (title && title.text ? title.text : '').trim(); + + var font = title && title.font ? title.font : {}; + var fontFamily = font.family; + var fontSize = font.size; + var fontColor = font.color; // only make this title editable if we positively identify its property // as one that has editing enabled. var editAttr; - if(prop === 'title') editAttr = 'titleText'; + if(prop === 'title.text') editAttr = 'titleText'; else if(prop.indexOf('axis') !== -1) editAttr = 'axisTitleText'; else if(prop.indexOf('colorbar' !== -1)) editAttr = 'colorbarTitleText'; var editable = gd._context.edits[editAttr]; @@ -94478,7 +95054,7 @@ function draw(gd, titleClass, options) { titleEl.attr('transform', transformVal); titleEl.style({ - 'font-family': font, + 'font-family': fontFamily, 'font-size': d3.round(fontSize, 2) + 'px', fill: Color.rgb(fontColor), opacity: opacity * Color.opacity(fontColor), @@ -94578,9 +95154,9 @@ function draw(gd, titleClass, options) { el.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { if(traceIndex !== undefined) { - Registry.call('restyle', gd, prop, text, traceIndex); + Registry.call('_guiRestyle', gd, prop, text, traceIndex); } else { - Registry.call('relayout', gd, prop, text); + Registry.call('_guiRelayout', gd, prop, text); } }) .on('cancel', function() { @@ -94597,7 +95173,7 @@ function draw(gd, titleClass, options) { return group; } -},{"../../constants/interactions":672,"../../lib":696,"../../lib/svg_text_utils":720,"../../plots/plots":808,"../../registry":827,"../color":570,"../drawing":595,"d3":148,"fast-isnumeric":214}],662:[function(_dereq_,module,exports){ +},{"../../constants/interactions":668,"../../lib":692,"../../lib/svg_text_utils":716,"../../plots/plots":804,"../../registry":823,"../color":569,"../drawing":590,"d3":148,"fast-isnumeric":214}],658:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94762,7 +95338,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { ].join(' ') }, - pad: extendFlat({}, padAttrs, { + pad: extendFlat(padAttrs({editType: 'arraydraw'}), { description: 'Sets the padding around the buttons or dropdown menu.' }), @@ -94791,7 +95367,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../../plots/font_attributes":771,"../../plots/pad_attributes":807,"../color/attributes":569}],663:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../../plots/font_attributes":767,"../../plots/pad_attributes":803,"../color/attributes":568}],659:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94872,7 +95448,7 @@ module.exports = { } }; -},{}],664:[function(_dereq_,module,exports){ +},{}],660:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94955,7 +95531,7 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"./attributes":662,"./constants":663}],665:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"./attributes":658,"./constants":659}],661:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94974,7 +95550,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var LINE_SPACING = _dereq_('../../constants/alignment').LINE_SPACING; @@ -95524,21 +96099,21 @@ function findDimensions(gd, menuOpts) { dims.ly = graphSize.t + graphSize.h * (1 - menuOpts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(menuOpts)) { + if(Lib.isRightAnchor(menuOpts)) { dims.lx -= paddedWidth; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(menuOpts)) { + if(Lib.isCenterAnchor(menuOpts)) { dims.lx -= paddedWidth / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(menuOpts)) { + if(Lib.isBottomAnchor(menuOpts)) { dims.ly -= paddedHeight; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(menuOpts)) { + if(Lib.isMiddleAnchor(menuOpts)) { dims.ly -= paddedHeight / 2; yanchor = 'middle'; } @@ -95605,9 +96180,9 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":668,"../../lib":696,"../../lib/svg_text_utils":720,"../../plot_api/plot_template":734,"../../plots/plots":808,"../color":570,"../drawing":595,"../legend/anchor_utils":622,"./constants":663,"./scrollbox":667,"d3":148}],666:[function(_dereq_,module,exports){ -arguments[4][660][0].apply(exports,arguments) -},{"./attributes":662,"./constants":663,"./defaults":664,"./draw":665,"dup":660}],667:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../lib":692,"../../lib/svg_text_utils":716,"../../plot_api/plot_template":730,"../../plots/plots":804,"../color":569,"../drawing":590,"./constants":659,"./scrollbox":663,"d3":148}],662:[function(_dereq_,module,exports){ +arguments[4][656][0].apply(exports,arguments) +},{"./attributes":658,"./constants":659,"./defaults":660,"./draw":661,"dup":656}],663:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95864,7 +96439,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { height: Math.ceil(clipB) - Math.floor(clipT) }); - this.container.call(Drawing.setClipUrl, clipId); + this.container.call(Drawing.setClipUrl, clipId, this.gd); this.bg.attr({ x: l, @@ -96078,7 +96653,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":696,"../color":570,"../drawing":595,"d3":148}],668:[function(_dereq_,module,exports){ +},{"../../lib":692,"../color":569,"../drawing":590,"d3":148}],664:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96122,12 +96697,17 @@ module.exports = { // multiple of fontSize to get the vertical offset between lines LINE_SPACING: 1.3, - // multiple of fontSize to shift from the baseline to the midline + // multiple of fontSize to shift from the baseline + // to the cap (captical letter) line // (to use when we don't calculate this shift from Drawing.bBox) - // To be precise this should be half the cap height (capital letter) - // of the font, and according to wikipedia: + // This is an approximation since in reality cap height can differ + // from font to font. However, according to Wikipedia // an "average" font might have a cap height of 70% of the em // https://en.wikipedia.org/wiki/Em_(typography)#History + CAP_SHIFT: 0.70, + + // half the cap height (distance between baseline and cap line) + // of an "average" font (for more info see above). MID_SHIFT: 0.35, OPPOSITE_SIDE: { @@ -96138,7 +96718,7 @@ module.exports = { } }; -},{}],669:[function(_dereq_,module,exports){ +},{}],665:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96176,7 +96756,7 @@ module.exports = { } }; -},{}],670:[function(_dereq_,module,exports){ +},{}],666:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96197,7 +96777,7 @@ module.exports = { longdashdot: [[0.5, 0.7, 0.8, 1], 10] }; -},{}],671:[function(_dereq_,module,exports){ +},{}],667:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96220,7 +96800,7 @@ module.exports = { x: '❌' }; -},{}],672:[function(_dereq_,module,exports){ +},{}],668:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96247,7 +96827,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],673:[function(_dereq_,module,exports){ +},{}],669:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96312,7 +96892,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],674:[function(_dereq_,module,exports){ +},{}],670:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96336,7 +96916,7 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],675:[function(_dereq_,module,exports){ +},{}],671:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96348,7 +96928,7 @@ exports.svgAttrs = { 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.42.5'; +exports.version = '1.43.0'; // inject promise polyfill _dereq_('es6-promise').polyfill(); @@ -96357,7 +96937,7 @@ _dereq_('es6-promise').polyfill(); _dereq_('../build/plotcss'); // inject default MathJax config -_dereq_('./fonts/mathjax_config'); +_dereq_('./fonts/mathjax_config')(); // include registry module and expose register method var Registry = _dereq_('./registry'); @@ -96368,7 +96948,8 @@ var plotApi = _dereq_('./plot_api'); var methodNames = Object.keys(plotApi); for(var i = 0; i < methodNames.length; i++) { var name = methodNames[i]; - exports[name] = plotApi[name]; + // _ -> private API methods, but still registered for internal use + if(name.charAt(0) !== '_') exports[name] = plotApi[name]; register({ moduleType: 'apiMethod', name: name, @@ -96392,7 +96973,8 @@ register([ _dereq_('./components/rangeslider'), _dereq_('./components/rangeselector'), _dereq_('./components/grid'), - _dereq_('./components/errorbars') + _dereq_('./components/errorbars'), + _dereq_('./components/colorscale') ]); // locales en and en-US are required for default behavior @@ -96414,7 +96996,7 @@ exports.Queue = _dereq_('./lib/queue'); // export d3 used in the bundle exports.d3 = _dereq_('d3'); -},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":561,"./components/annotations3d":566,"./components/errorbars":601,"./components/fx":612,"./components/grid":616,"./components/images":621,"./components/legend":630,"./components/rangeselector":641,"./components/rangeslider":647,"./components/shapes":655,"./components/sliders":660,"./components/updatemenus":666,"./fonts/mathjax_config":676,"./lib/queue":711,"./locale-en":725,"./locale-en-us":724,"./plot_api":729,"./plot_api/plot_schema":733,"./plots/plots":808,"./registry":827,"./snapshot":832,"./traces/scatter":1055,"d3":148,"es6-promise":203}],676:[function(_dereq_,module,exports){ +},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":560,"./components/annotations3d":565,"./components/colorscale":581,"./components/errorbars":596,"./components/fx":608,"./components/grid":612,"./components/images":617,"./components/legend":625,"./components/rangeselector":636,"./components/rangeslider":643,"./components/shapes":651,"./components/sliders":656,"./components/updatemenus":662,"./fonts/mathjax_config":672,"./lib/queue":707,"./locale-en":721,"./locale-en-us":720,"./plot_api":725,"./plot_api/plot_schema":729,"./plots/plots":804,"./registry":823,"./snapshot":828,"./traces/scatter":1052,"d3":148,"es6-promise":203}],672:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96427,31 +97009,89 @@ exports.d3 = _dereq_('d3'); /* global MathJax:false */ +module.exports = function() { + if(typeof MathJax !== 'undefined') { + var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; + + if(globalConfig) { + MathJax.Hub.Config({ + messageStyle: 'none', + skipStartupTypeset: true, + displayAlign: 'left', + tex2jax: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + } + }); + MathJax.Hub.Configured(); + } + } +}; + +},{}],673:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + + /** - * Check and configure MathJax + * Determine the position anchor property of x/y xanchor/yanchor components. + * + * - values < 1/3 align the low side at that fraction, + * - values [1/3, 2/3] align the center at that fraction, + * - values > 2/3 align the right at that fraction. */ -if(typeof MathJax !== 'undefined') { - exports.MathJax = true; - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } +exports.isLeftAnchor = function isLeftAnchor(opts) { + return ( + opts.xanchor === 'left' || + (opts.xanchor === 'auto' && opts.x <= 1 / 3) + ); +}; -} else { - exports.MathJax = false; -} +exports.isCenterAnchor = function isCenterAnchor(opts) { + return ( + opts.xanchor === 'center' || + (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) + ); +}; + +exports.isRightAnchor = function isRightAnchor(opts) { + return ( + opts.xanchor === 'right' || + (opts.xanchor === 'auto' && opts.x >= 2 / 3) + ); +}; + +exports.isTopAnchor = function isTopAnchor(opts) { + return ( + opts.yanchor === 'top' || + (opts.yanchor === 'auto' && opts.y >= 2 / 3) + ); +}; + +exports.isMiddleAnchor = function isMiddleAnchor(opts) { + return ( + opts.yanchor === 'middle' || + (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) + ); +}; + +exports.isBottomAnchor = function isBottomAnchor(opts) { + return ( + opts.yanchor === 'bottom' || + (opts.yanchor === 'auto' && opts.y <= 1 / 3) + ); +}; -},{}],677:[function(_dereq_,module,exports){ +},{}],674:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96692,7 +97332,7 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":703}],678:[function(_dereq_,module,exports){ +},{"./mod":699}],675:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96828,7 +97468,30 @@ exports.concat = function() { return out; }; -},{}],679:[function(_dereq_,module,exports){ +exports.maxRowLength = function(z) { + return _rowLength(z, Math.max, 0); +}; + +exports.minRowLength = function(z) { + return _rowLength(z, Math.min, Infinity); +}; + +function _rowLength(z, fn, len0) { + if(isArrayOrTypedArray(z)) { + if(isArrayOrTypedArray(z[0])) { + var len = len0; + for(var i = 0; i < z.length; i++) { + len = fn(len, z[i].length); + } + return len; + } else { + return z.length; + } + } + return 0; +} + +},{}],676:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96861,7 +97524,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":673,"fast-isnumeric":214}],680:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"fast-isnumeric":214}],677:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96889,7 +97552,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],681:[function(_dereq_,module,exports){ +},{}],678:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96912,7 +97575,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],682:[function(_dereq_,module,exports){ +},{}],679:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96921,18 +97584,17 @@ module.exports = function clearResponsive(gd) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); var baseTraceAttrs = _dereq_('../plots/attributes'); -var getColorscale = _dereq_('../components/colorscale/get_scale'); -var colorscaleNames = Object.keys(_dereq_('../components/colorscale/scales')); +var scales = _dereq_('../components/colorscale/scales'); +var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; + var nestedProperty = _dereq_('./nested_property'); var counterRegex = _dereq_('./regex').counter; -var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; var modHalf = _dereq_('./mod').modHalf; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -97080,7 +97742,7 @@ exports.valObjectMeta = { colorscale: { description: [ 'A Plotly colorscale either picked by a name:', - '(any of', colorscaleNames.join(', '), ')', + '(any of', Object.keys(scales.scales).join(', '), ')', 'customized as an {array} of 2-element {arrays} where', 'the first element is the normalized color level value', '(starting at *0* and ending at *1*),', @@ -97089,7 +97751,7 @@ exports.valObjectMeta = { requiredOpts: [], otherOpts: ['dflt'], coerceFunction: function(v, propOut, dflt) { - propOut.set(getColorscale(v, dflt)); + propOut.set(scales.get(v, dflt)); } }, angle: { @@ -97437,7 +98099,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/get_scale":583,"../components/colorscale/scales":589,"../constants/interactions":672,"../plots/attributes":741,"./array":678,"./mod":703,"./nested_property":704,"./regex":712,"fast-isnumeric":214,"tinycolor2":514}],683:[function(_dereq_,module,exports){ +},{"../components/colorscale/scales":584,"../constants/interactions":668,"../plots/attributes":737,"./array":675,"./mod":699,"./nested_property":700,"./regex":708,"fast-isnumeric":214,"tinycolor2":513}],680:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98040,7 +98702,7 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":673,"../registry":827,"./loggers":700,"./mod":703,"d3":148,"fast-isnumeric":214}],684:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"../registry":823,"./loggers":696,"./mod":699,"d3":148,"fast-isnumeric":214}],681:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98214,7 +98876,7 @@ var Events = { module.exports = Events; -},{"events":92}],685:[function(_dereq_,module,exports){ +},{"events":92}],682:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98330,7 +98992,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":697}],686:[function(_dereq_,module,exports){ +},{"./is_plain_object.js":693}],683:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98381,7 +99043,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],687:[function(_dereq_,module,exports){ +},{}],684:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98428,7 +99090,7 @@ function isCalcData(cont) { ); } -},{}],688:[function(_dereq_,module,exports){ +},{}],685:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98492,7 +99154,7 @@ function countryNameToISO3(countryName) { return false; } -},{"../lib":696,"country-regex":122}],689:[function(_dereq_,module,exports){ +},{"../lib":692,"country-regex":122}],686:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98609,7 +99271,7 @@ exports.makeBlank = function() { }; }; -},{"../constants/numerical":673}],690:[function(_dereq_,module,exports){ +},{"../constants/numerical":669}],687:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98855,7 +99517,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":703}],691:[function(_dereq_,module,exports){ +},{"./mod":699}],688:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98893,7 +99555,7 @@ module.exports = function(gd) { return gd; // otherwise assume that gd is a DOM element }; -},{}],692:[function(_dereq_,module,exports){ +},{}],689:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98944,11 +99606,7 @@ function formatColor(containerIn, opacityIn, len) { if(containerIn.colorscale !== undefined) { sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - containerIn.colorscale, - containerIn.cmin, - containerIn.cmax - ) + Colorscale.extractScale(containerIn, {cLetter: 'c'}) ); } else { @@ -99001,7 +99659,7 @@ module.exports = { parseColorScale: parseColorScale }; -},{"../components/color/attributes":569,"../components/colorscale":585,"./array":678,"color-normalize":108,"fast-isnumeric":214,"tinycolor2":514}],693:[function(_dereq_,module,exports){ +},{"../components/color/attributes":568,"../components/colorscale":581,"./array":675,"color-normalize":108,"fast-isnumeric":214,"tinycolor2":513}],690:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99037,54 +99695,7 @@ module.exports = { unwrap: function(d) {return d[0];} }; -},{"./identity":695}],694:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var toSuperScript = _dereq_('superscript-text'); -var fixEntities = _dereq_('./svg_text_utils').convertEntities; - -function fixSuperScript(x) { - var idx = 0; - - while((idx = x.indexOf('', idx)) >= 0) { - var nidx = x.indexOf('', idx); - if(nidx < idx) break; - - x = x.slice(0, idx) + toSuperScript(x.slice(idx + 5, nidx)) + x.slice(nidx + 6); - } - - return x; -} - -function fixBR(x) { - return x.replace(/\/g, '\n'); -} - -function stripTags(x) { - return x.replace(/\<.*\>/g, ''); -} - -function convertHTMLToUnicode(html) { - return '' + - fixEntities( - stripTags( - fixSuperScript( - fixBR( - html)))); -} - -module.exports = convertHTMLToUnicode; - -},{"./svg_text_utils":720,"superscript-text":507}],695:[function(_dereq_,module,exports){ +},{"./identity":691}],691:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99100,7 +99711,7 @@ module.exports = convertHTMLToUnicode; module.exports = function identity(d) { return d; }; -},{}],696:[function(_dereq_,module,exports){ +},{}],692:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99134,6 +99745,8 @@ lib.isArrayOrTypedArray = arrayModule.isArrayOrTypedArray; lib.isArray1D = arrayModule.isArray1D; lib.ensureArray = arrayModule.ensureArray; lib.concat = arrayModule.concat; +lib.maxRowLength = arrayModule.maxRowLength; +lib.minRowLength = arrayModule.minRowLength; var modModule = _dereq_('./mod'); lib.mod = modModule.mod; @@ -99203,6 +99816,14 @@ lib.pathArc = anglesModule.pathArc; lib.pathSector = anglesModule.pathSector; lib.pathAnnulus = anglesModule.pathAnnulus; +var anchorUtils = _dereq_('./anchor_utils'); +lib.isLeftAnchor = anchorUtils.isLeftAnchor; +lib.isCenterAnchor = anchorUtils.isCenterAnchor; +lib.isRightAnchor = anchorUtils.isRightAnchor; +lib.isTopAnchor = anchorUtils.isTopAnchor; +lib.isMiddleAnchor = anchorUtils.isMiddleAnchor; +lib.isBottomAnchor = anchorUtils.isBottomAnchor; + var geom2dModule = _dereq_('./geometry2d'); lib.segmentsIntersect = geom2dModule.segmentsIntersect; lib.segmentDistance = geom2dModule.segmentDistance; @@ -99737,7 +100358,13 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) objOut[k] = v.slice(0, arrayLen); + else if(Array.isArray(v)) { + if(k === 'colorscale') { + objOut[k] = v.slice(); + } else { + objOut[k] = v.slice(0, arrayLen); + } + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -100082,10 +100709,10 @@ lib.numSeparate = function(value, separators, separatethousands) { return x1 + x2; }; -var TEMPLATE_STRING_REGEX = /%{([^\s%{}]*)}/g; +var TEMPLATE_STRING_REGEX = /%{([^\s%{}:]*)(:[^}]*)?}/g; var SIMPLE_PROPERTY_REGEX = /^\w*$/; -/* +/** * Substitute values from an object into a string * * Examples: @@ -100097,7 +100724,6 @@ var SIMPLE_PROPERTY_REGEX = /^\w*$/; * * @return {string} templated string */ - lib.templateString = function(string, obj) { // Not all that useful, but cache nestedProperty instantiation // just in case it speeds things up *slightly*: @@ -100112,6 +100738,67 @@ lib.templateString = function(string, obj) { }); }; +var TEMPLATE_STRING_FORMAT_SEPARATOR = /^:/; +var numberOfHoverTemplateWarnings = 0; +var maximumNumberOfHoverTemplateWarnings = 10; +/** + * Substitute values from an object into a string and optionally formats them using d3-format, + * or fallback to associated labels. + * + * Examples: + * Lib.templateString('name: %{trace}', {trace: 'asdf'}) --> 'name: asdf' + * Lib.templateString('name: %{trace[0].name}', {trace: [{name: 'asdf'}]}) --> 'name: asdf' + * Lib.templateString('price: %{y:$.2f}', {y: 1}) --> 'price: $1.00' + * + * @param {string} input string containing %{...:...} template strings + * @param {obj} data object containing fallback text when no formatting is specified, ex.: {yLabel: 'formattedYValue'} + * @param {obj} data objects containing substitution values + * + * @return {string} templated string + */ +lib.hovertemplateString = function(string, labels) { + var args = arguments; + // Not all that useful, but cache nestedProperty instantiation + // just in case it speeds things up *slightly*: + var getterCache = {}; + + return string.replace(TEMPLATE_STRING_REGEX, function(match, key, format) { + var obj, value, i; + for(i = 2; i < args.length; i++) { + obj = args[i]; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; + } + + if(value === undefined) { + if(numberOfHoverTemplateWarnings < maximumNumberOfHoverTemplateWarnings) { + lib.warn('Variable \'' + key + '\' in hovertemplate could not be found!'); + value = match; + } + + if(numberOfHoverTemplateWarnings === maximumNumberOfHoverTemplateWarnings) { + lib.warn('Too many hovertemplate warnings - additional warnings will be suppressed'); + } + numberOfHoverTemplateWarnings++; + } + + if(format) { + value = d3.format(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value); + } else { + if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + } + return value; + }); +}; + /* * alphanumeric string sort, tailored for subplot IDs like scene2, scene10, x10y13 etc */ @@ -100154,7 +100841,7 @@ lib.pseudoRandom = function() { return randSeed / 4294967296; }; -},{"../constants/numerical":673,"./angles":677,"./array":678,"./clean_number":679,"./clear_responsive":681,"./coerce":682,"./dates":683,"./extend":685,"./filter_unique":686,"./filter_visible":687,"./geometry2d":690,"./get_graph_div":691,"./identity":695,"./is_plain_object":697,"./keyed_container":698,"./localize":699,"./loggers":700,"./make_trace_groups":701,"./matrix":702,"./mod":703,"./nested_property":704,"./noop":705,"./notifier":706,"./push_unique":710,"./regex":712,"./relative_attr":713,"./relink_private":714,"./search":715,"./stats":718,"./throttle":721,"./to_log_range":722,"d3":148,"fast-isnumeric":214}],697:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"./anchor_utils":673,"./angles":674,"./array":675,"./clean_number":676,"./clear_responsive":678,"./coerce":679,"./dates":680,"./extend":682,"./filter_unique":683,"./filter_visible":684,"./geometry2d":687,"./get_graph_div":688,"./identity":691,"./is_plain_object":693,"./keyed_container":694,"./localize":695,"./loggers":696,"./make_trace_groups":697,"./matrix":698,"./mod":699,"./nested_property":700,"./noop":701,"./notifier":702,"./push_unique":706,"./regex":708,"./relative_attr":709,"./relink_private":710,"./search":711,"./stats":714,"./throttle":717,"./to_log_range":718,"d3":148,"fast-isnumeric":214}],693:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100183,7 +100870,7 @@ module.exports = function isPlainObject(obj) { ); }; -},{}],698:[function(_dereq_,module,exports){ +},{}],694:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100376,7 +101063,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":704}],699:[function(_dereq_,module,exports){ +},{"./nested_property":700}],695:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100432,7 +101119,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":827}],700:[function(_dereq_,module,exports){ +},{"../registry":823}],696:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100518,7 +101205,7 @@ function apply(f, args) { } } -},{"../plot_api/plot_config":732}],701:[function(_dereq_,module,exports){ +},{"../plot_api/plot_config":728}],697:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100555,7 +101242,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{}],702:[function(_dereq_,module,exports){ +},{}],698:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100665,7 +101352,7 @@ exports.apply2DTransform2 = function(transform) { }; }; -},{}],703:[function(_dereq_,module,exports){ +},{}],699:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100700,7 +101387,7 @@ module.exports = { modHalf: modHalf }; -},{}],704:[function(_dereq_,module,exports){ +},{}],700:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100947,7 +101634,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":678,"fast-isnumeric":214}],705:[function(_dereq_,module,exports){ +},{"./array":675,"fast-isnumeric":214}],701:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100963,7 +101650,7 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],706:[function(_dereq_,module,exports){ +},{}],702:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101045,7 +101732,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":148,"fast-isnumeric":214}],707:[function(_dereq_,module,exports){ +},{"d3":148,"fast-isnumeric":214}],703:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101094,7 +101781,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":716}],708:[function(_dereq_,module,exports){ +},{"./setcursor":712}],704:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101347,7 +102034,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":673,"./matrix":702}],709:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"./matrix":698}],705:[function(_dereq_,module,exports){ (function (global){ /** * Copyright 2012-2018, Plotly, Inc. @@ -101419,7 +102106,7 @@ module.exports = function prepareRegl(gd, extensions) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./show_no_webgl_msg":717,"regl":478}],710:[function(_dereq_,module,exports){ +},{"./show_no_webgl_msg":713,"regl":478}],706:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101459,7 +102146,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],711:[function(_dereq_,module,exports){ +},{}],707:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101670,7 +102357,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":696,"../plot_api/plot_config":732}],712:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/plot_config":728}],708:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101689,16 +102376,18 @@ module.exports = queue; * @param {Optional(string)} tail: a fixed piece after the id * eg counterRegex('scene', '.annotations') for scene2.annotations etc. * @param {boolean} openEnded: if true, the string may continue past the match. + * @param {boolean} matchBeginning: if false, the string may start before the match. */ -exports.counter = function(head, tail, openEnded) { +exports.counter = function(head, tail, openEnded, matchBeginning) { var fullTail = (tail || '') + (openEnded ? '' : '$'); + var startWithPrefix = matchBeginning === false ? '' : '^'; if(head === 'xy') { - return new RegExp('^x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + 'x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); } - return new RegExp('^' + head + '([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],713:[function(_dereq_,module,exports){ +},{}],709:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101751,7 +102440,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],714:[function(_dereq_,module,exports){ +},{}],710:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101814,7 +102503,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":678,"./is_plain_object":697}],715:[function(_dereq_,module,exports){ +},{"./array":675,"./is_plain_object":693}],711:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102002,7 +102691,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"./identity":695,"./loggers":700,"fast-isnumeric":214}],716:[function(_dereq_,module,exports){ +},{"./identity":691,"./loggers":696,"fast-isnumeric":214}],712:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102025,7 +102714,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],717:[function(_dereq_,module,exports){ +},{}],713:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102089,7 +102778,7 @@ module.exports = function showNoWebGlMsg(scene) { return false; }; -},{"../components/color":570}],718:[function(_dereq_,module,exports){ +},{"../components/color":569}],714:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102190,7 +102879,7 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":678,"fast-isnumeric":214}],719:[function(_dereq_,module,exports){ +},{"./array":675,"fast-isnumeric":214}],715:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102211,7 +102900,7 @@ function str2RgbaArray(color) { module.exports = str2RgbaArray; -},{"color-normalize":108}],720:[function(_dereq_,module,exports){ +},{"color-normalize":108}],716:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102986,7 +103675,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":668,"../constants/xmlns_namespaces":674,"../lib":696,"d3":148}],721:[function(_dereq_,module,exports){ +},{"../constants/alignment":664,"../constants/xmlns_namespaces":670,"../lib":692,"d3":148}],717:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103090,7 +103779,7 @@ function _clearTimeout(cache) { } } -},{}],722:[function(_dereq_,module,exports){ +},{}],718:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103118,7 +103807,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":214}],723:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214}],719:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103154,7 +103843,7 @@ topojsonUtils.getTopojsonFeatures = function(trace, topojson) { return topojsonFeature(topojson, obj).features; }; -},{"../plots/geo/constants":773,"topojson-client":517}],724:[function(_dereq_,module,exports){ +},{"../plots/geo/constants":769,"topojson-client":516}],720:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103176,7 +103865,7 @@ module.exports = { } }; -},{}],725:[function(_dereq_,module,exports){ +},{}],721:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103219,7 +103908,7 @@ module.exports = { } }; -},{}],726:[function(_dereq_,module,exports){ +},{}],722:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103277,7 +103966,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":827}],727:[function(_dereq_,module,exports){ +},{"../registry":823}],723:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103427,7 +104116,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":696}],728:[function(_dereq_,module,exports){ +},{"../lib":692}],724:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103483,6 +104172,8 @@ exports.cleanLayout = function(layout) { } var axisAttrRegex = (Plots.subplotsRegistry.cartesian || {}).attrRegex; + var polarAttrRegex = (Plots.subplotsRegistry.polar || {}).attrRegex; + var ternaryAttrRegex = (Plots.subplotsRegistry.ternary || {}).attrRegex; var sceneAttrRegex = (Plots.subplotsRegistry.gl3d || {}).attrRegex; var keys = Object.keys(layout); @@ -103521,6 +104212,24 @@ exports.cleanLayout = function(layout) { } delete ax.autotick; } + + cleanTitle(ax); + } + + // modifications for polar + else if(polarAttrRegex && polarAttrRegex.test(key)) { + var polar = layout[key]; + + cleanTitle(polar.radialaxis); + } + + // modifications for ternary + else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + var ternary = layout[key]; + + cleanTitle(ternary.aaxis); + cleanTitle(ternary.baxis); + cleanTitle(ternary.caxis); } // modifications for 3D scenes @@ -103544,11 +104253,16 @@ exports.cleanLayout = function(layout) { scene.camera = { eye: {x: eye[0], y: eye[1], z: eye[2]}, center: {x: center[0], y: center[1], z: center[2]}, - up: {x: mat[1], y: mat[5], z: mat[9]} + up: {x: 0, y: 0, z: 1} // we just ignore calculating camera z up in this case }; delete scene.cameraposition; } + + // clean axis titles + cleanTitle(scene.xaxis); + cleanTitle(scene.yaxis); + cleanTitle(scene.zaxis); } } @@ -103606,6 +104320,9 @@ exports.cleanLayout = function(layout) { } } + // clean plot title + cleanTitle(layout); + /* * Moved from rotate -> orbit for dragmode */ @@ -103615,6 +104332,11 @@ exports.cleanLayout = function(layout) { // supported, but new tinycolor does not because they're not valid css Color.clean(layout); + // clean the layout container in layout.template + if(layout.template && layout.template.layout) { + exports.cleanLayout(layout.template.layout); + } + return layout; }; @@ -103626,6 +104348,46 @@ function cleanAxRef(container, attr) { } } +/** + * Cleans up old title attribute structure (flat) in favor of the new one (nested). + * + * @param {Object} titleContainer - an object potentially including deprecated title attributes + */ +function cleanTitle(titleContainer) { + if(titleContainer) { + + // title -> title.text + // (although title used to be a string attribute, + // numbers are accepted as well) + if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') { + titleContainer.title = { + text: titleContainer.title + }; + } + + rewireAttr('titlefont', 'font'); + rewireAttr('titleposition', 'position'); + rewireAttr('titleside', 'side'); + rewireAttr('titleoffset', 'offset'); + } + + function rewireAttr(oldAttrName, newAttrName) { + var oldAttrSet = titleContainer[oldAttrName]; + var newAttrSet = titleContainer.title && titleContainer.title[newAttrName]; + + if(oldAttrSet && !newAttrSet) { + + // Ensure title object exists + if(!titleContainer.title) { + titleContainer.title = {}; + } + + titleContainer.title[newAttrName] = titleContainer[oldAttrName]; + delete titleContainer[oldAttrName]; + } + } +} + /* * cleanData: Make a few changes to the data for backward compatibility * before it gets used for anything. Modifies the data traces users provide. @@ -103829,6 +104591,13 @@ exports.cleanData = function(data) { delete trace.autobiny; delete trace.ybins; } + + cleanTitle(trace); + if(trace.colorbar) cleanTitle(trace.colorbar); + if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar); + if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar); + if(trace.aaxis) cleanTitle(trace.aaxis); + if(trace.baxis) cleanTitle(trace.baxis); } }; @@ -103869,11 +104638,14 @@ function commonPrefix(name1, name2, show1, show2) { function cleanTextPosition(textposition) { var posY = 'middle', posX = 'center'; - if(textposition.indexOf('top') !== -1) posY = 'top'; - else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; - if(textposition.indexOf('left') !== -1) posX = 'left'; - else if(textposition.indexOf('right') !== -1) posX = 'right'; + if(typeof textposition === 'string') { + if(textposition.indexOf('top') !== -1) posY = 'top'; + else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; + + if(textposition.indexOf('left') !== -1) posX = 'left'; + else if(textposition.indexOf('right') !== -1) posX = 'right'; + } return posY + ' ' + posX; } @@ -104049,7 +104821,7 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":570,"../lib":696,"../plots/cartesian/axis_ids":747,"../plots/plots":808,"../registry":827,"fast-isnumeric":214,"gl-mat4/fromQuat":251}],729:[function(_dereq_,module,exports){ +},{"../components/color":569,"../lib":692,"../plots/cartesian/axis_ids":743,"../plots/plots":804,"../registry":823,"fast-isnumeric":214,"gl-mat4/fromQuat":251}],725:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104068,6 +104840,10 @@ exports.restyle = main.restyle; exports.relayout = main.relayout; exports.redraw = main.redraw; exports.update = main.update; +exports._guiRestyle = main._guiRestyle; +exports._guiRelayout = main._guiRelayout; +exports._guiUpdate = main._guiUpdate; +exports._storeDirectGUIEdit = main._storeDirectGUIEdit; exports.react = main.react; exports.extendTraces = main.extendTraces; exports.prependTraces = main.prependTraces; @@ -104088,7 +104864,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":829,"./plot_api":731,"./template_api":736,"./to_image":737,"./validate":738}],730:[function(_dereq_,module,exports){ +},{"../snapshot/download":825,"./plot_api":727,"./template_api":732,"./to_image":733,"./validate":734}],726:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104100,7 +104876,6 @@ exports.validateTemplate = templateApi.validateTemplate; 'use strict'; -var nestedProperty = _dereq_('../lib/nested_property'); var isPlainObject = _dereq_('../lib/is_plain_object'); var noop = _dereq_('../lib/noop'); var Loggers = _dereq_('../lib/loggers'); @@ -104157,11 +104932,15 @@ var isRemoveVal = exports.isRemoveVal = function isRemoveVal(val) { * the flags for which actions we're going to perform to display these (and * any other) changes. If we're already `recalc`ing, we don't need to redraw * individual items + * @param {function} _nestedProperty + * a (possibly modified for gui edits) nestedProperty constructor + * The modified version takes a 3rd argument, for a prefix to the attribute + * string necessary for storing GUI edits * * @returns {bool} `true` if it managed to complete drawing of the changes * `false` would mean the parent should replot. */ -exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags) { +exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags, _nestedProperty) { var componentType = np.astr, supplyComponentDefaults = Registry.getComponentMethod(componentType, 'supplyLayoutDefaults'), draw = Registry.getComponentMethod(componentType, 'draw'), @@ -104201,7 +104980,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, // redoing supplyDefaults // TODO: this assumes componentArray is in gd.layout - which will not be // true after we extend this to restyle - componentArrayFull = nestedProperty(fullLayout, componentType).get(); + componentArrayFull = _nestedProperty(fullLayout, componentType).get(); var deletes = [], firstIndexChange = -1, @@ -104212,7 +104991,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, objEdits, objKeys, objVal, - adding; + adding, prefix; // first make the add and edit changes for(i = 0; i < componentNums.length; i++) { @@ -104251,7 +105030,9 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, } else { for(j = 0; j < objKeys.length; j++) { - nestedProperty(componentArray[componentNum], objKeys[j]).set(objEdits[objKeys[j]]); + prefix = componentType + '[' + componentNum + '].'; + _nestedProperty(componentArray[componentNum], objKeys[j], prefix) + .set(objEdits[objKeys[j]]); } } } @@ -104302,7 +105083,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":697,"../lib/loggers":700,"../lib/nested_property":704,"../lib/noop":705,"../lib/search":715,"../registry":827,"./container_array_match":726}],731:[function(_dereq_,module,exports){ +},{"../lib/is_plain_object":693,"../lib/loggers":696,"../lib/noop":701,"../lib/search":711,"../registry":823,"./container_array_match":722}],727:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -104320,6 +105101,8 @@ var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); var Lib = _dereq_('../lib'); +var nestedProperty = Lib.nestedProperty; + var Events = _dereq_('../lib/events'); var Queue = _dereq_('../lib/queue'); @@ -104415,9 +105198,6 @@ exports.plot = function(gd, data, layout, config) { // so we can share cached text across tabs Drawing.makeTester(); - // clear stashed base url - delete Drawing.baseUrl; - // collect promises for any async actions during plotting // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all @@ -104462,7 +105242,7 @@ exports.plot = function(gd, data, layout, config) { // Legacy polar plots if(!fullLayout._has('polar') && data && data[0] && data[0].r) { Lib.log('Legacy polar charts are deprecated!'); - return plotPolar(gd, data, layout); + return plotLegacyPolar(gd, data, layout); } // so we don't try to re-call Plotly.plot from inside @@ -104638,8 +105418,7 @@ exports.plot = function(gd, data, layout, config) { return Lib.syncOrAsync([ Registry.getComponentMethod('shapes', 'calcAutorange'), Registry.getComponentMethod('annotations', 'calcAutorange'), - doAutoRangeAndConstraints, - Registry.getComponentMethod('rangeslider', 'calcAutorange') + doAutoRangeAndConstraints ], gd); } @@ -104651,11 +105430,16 @@ exports.plot = function(gd, data, layout, config) { // store initial ranges *after* enforcing constraints, otherwise // we will never look like we're at the initial ranges if(graphWasEmpty) Axes.saveRangeInitial(gd); + + // this one is different from shapes/annotations calcAutorange + // the others incorporate those components into ax._extremes, + // this one actually sets the ranges in rangesliders. + Registry.getComponentMethod('rangeslider', 'calcAutorange')(gd); } // draw ticks, titles, and calculate axis scaling (._b, ._m) function drawAxes() { - return Axes.doTicks(gd, graphWasEmpty ? '' : 'redraw'); + return Axes.draw(gd, graphWasEmpty ? '' : 'redraw'); } var seq = [ @@ -104724,7 +105508,16 @@ function opaqueSetBackground(gd, bgColor) { } function setPlotContext(gd, config) { - if(!gd._context) gd._context = Lib.extendDeep({}, defaultConfig); + if(!gd._context) { + gd._context = Lib.extendDeep({}, defaultConfig); + + // stash href, used to make robust clipPath URLs + var base = d3.select('base'); + gd._context._baseUrl = base.size() && base.attr('href') ? + window.location.href.split('#')[0] : + ''; + } + var context = gd._context; var i, keys, key; @@ -104770,6 +105563,9 @@ function setPlotContext(gd, config) { } } } + + // not part of the user-facing config options + context._exportedPlot = config._exportedPlot; } // staticPlot forces a bunch of others: @@ -104799,7 +105595,7 @@ function setPlotContext(gd, config) { context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0; } -function plotPolar(gd, data, layout) { +function plotLegacyPolar(gd, data, layout) { // build or reuse the container skeleton var plotContainer = d3.select(gd).selectAll('.plot-container') .data([0]); @@ -104840,7 +105636,7 @@ function plotPolar(gd, data, layout) { // editable title var opacity = 1; - var txt = gd._fullLayout.title; + var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; if(txt === '' || !txt) opacity = 0; var titleLayout = function() { @@ -104874,7 +105670,7 @@ function plotPolar(gd, data, layout) { var setContenteditable = function() { this.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { - gd.framework({layout: {title: text}}); + gd.framework({layout: {title: {text: text}}}); this.text(text) .call(titleLayout); this.call(setContenteditable); @@ -105147,7 +105943,7 @@ function getExtendProperties(gd, update, indices, maxPoints) { * instance that references the key and value for this particular trace. */ trace = gd.data[indices[j]]; - prop = Lib.nestedProperty(trace, key); + prop = nestedProperty(trace, key); /* * Target is the existing gd.data.trace.dataArray value like "x" or "marker.size" @@ -105618,7 +106414,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) { * If the array is too short, it will wrap around (useful for * style files that want to specify cyclical default values). */ -exports.restyle = function restyle(gd, astr, val, _traces) { +function restyle(gd, astr, val, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -105688,7 +106484,8 @@ exports.restyle = function restyle(gd, astr, val, _traces) { gd.emit('plotly_restyle', specs.eventData); return gd; }); -}; +} +exports.restyle = restyle; // for undo: undefined initial vals must be turned into nulls // so that we unset rather than ignore them @@ -105697,11 +106494,77 @@ function undefinedToNull(val) { return val; } +/** + * Factory function to wrap nestedProperty with GUI edits if necessary + * with GUI edits we add an optional prefix to the nestedProperty constructor + * to prepend to the attribute string in the preGUI store. + */ +function makeNP(preGUI, guiEditFlag) { + if(!guiEditFlag) return nestedProperty; + + return function(container, attr, prefix) { + var np = nestedProperty(container, attr); + var npSet = np.set; + np.set = function(val) { + var fullAttr = (prefix || '') + attr; + storeCurrent(fullAttr, np.get(), val, preGUI); + npSet(val); + }; + return np; + }; +} + +function storeCurrent(attr, val, newVal, preGUI) { + if(Array.isArray(val) || Array.isArray(newVal)) { + var arrayVal = Array.isArray(val) ? val : []; + var arrayNew = Array.isArray(newVal) ? newVal : []; + var maxLen = Math.max(arrayVal.length, arrayNew.length); + for(var i = 0; i < maxLen; i++) { + storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); + } + } + else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + var objVal = Lib.isPlainObject(val) ? val : {}; + var objNew = Lib.isPlainObject(newVal) ? newVal : {}; + var objBoth = Lib.extendFlat({}, objVal, objNew); + for(var key in objBoth) { + storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); + } + } + else if(preGUI[attr] === undefined) { + preGUI[attr] = undefinedToNull(val); + } +} + +/** + * storeDirectGUIEdit: for routines that skip restyle/relayout and mock it + * by emitting a plotly_restyle or plotly_relayout event, this routine + * keeps track of the initial state in _preGUI for use by uirevision + * Does *not* apply these changes to data/layout - that's the responsibility + * of the calling routine. + * + * @param {object} container: the input attributes container (eg `layout` or a `trace`) + * @param {object} preGUI: where original values should be stored, either + * `layout._preGUI` or `layout._tracePreGUI[uid]` + * @param {object} edits: the {attr: val} object as normally passed to `relayout` etc + */ +exports._storeDirectGUIEdit = function(container, preGUI, edits) { + for(var attr in edits) { + var np = nestedProperty(container, attr); + storeCurrent(attr, np.get(), edits[attr], preGUI); + } +}; + function _restyle(gd, aobj, traces) { - var fullLayout = gd._fullLayout, - fullData = gd._fullData, - data = gd.data, - i; + var fullLayout = gd._fullLayout; + var fullData = gd._fullData; + var data = gd.data; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var eventData = Lib.extendDeepAll({}, aobj); + var i; + + cleanDeprecatedAttributeKeys(aobj); // initialize flags var flags = editTypes.traceFlags(); @@ -105725,6 +106588,16 @@ function _restyle(gd, aobj, traces) { function rangeAttr(axName) { return 'LAYOUT' + axName + '.range'; } + function getFullTrace(traceIndex) { + // usually fullData maps 1:1 onto data, but with groupby transforms + // the fullData index can be greater. Take the *first* matching trace. + for(var j = traceIndex; j < fullData.length; j++) { + if(fullData[j]._input === data[traceIndex]) return fullData[j]; + } + // should never get here - and if we *do* it should cause an error + // later on undefined fullTrace is passed to nestedProperty. + } + // for attrs that interact (like scales & autoscales), save the // old vals before making the change // val=undefined will not set a value, just record what the value was. @@ -105740,9 +106613,11 @@ function _restyle(gd, aobj, traces) { var extraparam; if(attr.substr(0, 6) === 'LAYOUT') { - extraparam = Lib.nestedProperty(gd.layout, attr.replace('LAYOUT', '')); + extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', '')); } else { - extraparam = Lib.nestedProperty(data[traces[i]], attr); + var tracei = traces[i]; + var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid]; + extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr); } if(!(attr in undoit)) { @@ -105797,7 +106672,7 @@ function _restyle(gd, aobj, traces) { redoit[ai] = vi; if(ai.substr(0, 6) === 'LAYOUT') { - param = Lib.nestedProperty(gd.layout, ai.replace('LAYOUT', '')); + param = layoutNP(gd.layout, ai.replace('LAYOUT', '')); undoit[ai] = [undefinedToNull(param.get())]; // since we're allowing val to be an array, allow it here too, // even though that's meaningless @@ -105812,8 +106687,9 @@ function _restyle(gd, aobj, traces) { undoit[ai] = a0(); for(i = 0; i < traces.length; i++) { cont = data[traces[i]]; - contFull = fullData[traces[i]]; - param = Lib.nestedProperty(cont, ai); + contFull = getFullTrace(traces[i]); + var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid]; + param = makeNP(preGUI, guiEditFlag)(cont, ai); oldVal = param.get(); newVal = Array.isArray(vi) ? vi[i % vi.length] : vi; @@ -105823,7 +106699,7 @@ function _restyle(gd, aobj, traces) { var prefix = ai.substr(0, ai.length - finalPart.length - 1); var prefixDot = prefix ? prefix + '.' : ''; var innerContFull = prefix ? - Lib.nestedProperty(contFull, prefix).get() : contFull; + nestedProperty(contFull, prefix).get() : contFull; valObject = PlotSchema.getTraceValObject(contFull, param.parts); @@ -105870,14 +106746,14 @@ function _restyle(gd, aobj, traces) { Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo); if(oldVal === 'pie') { - Lib.nestedProperty(cont, 'marker.color') - .set(Lib.nestedProperty(cont, 'marker.colors').get()); + nestedProperty(cont, 'marker.color') + .set(nestedProperty(cont, 'marker.colors').get()); // super kludgy - but if all pies are gone we won't remove them otherwise fullLayout._pielayer.selectAll('g.trace').remove(); } else if(Registry.traceIs(cont, 'cartesian')) { - Lib.nestedProperty(cont, 'marker.colors') - .set(Lib.nestedProperty(cont, 'marker.color').get()); + nestedProperty(cont, 'marker.colors') + .set(nestedProperty(cont, 'marker.color').get()); } } @@ -105948,7 +106824,7 @@ function _restyle(gd, aobj, traces) { // swap hovermode if set to "compare x/y data" if(ai === 'orientationaxes') { - var hovermode = Lib.nestedProperty(gd.layout, 'hovermode'); + var hovermode = nestedProperty(gd.layout, 'hovermode'); if(hovermode.get() === 'x') { hovermode.set('y'); } else if(hovermode.get() === 'y') { @@ -105987,10 +106863,53 @@ function _restyle(gd, aobj, traces) { undoit: undoit, redoit: redoit, traces: traces, - eventData: Lib.extendDeepNoArrays([], [redoit, traces]) + eventData: Lib.extendDeepNoArrays([], [eventData, traces]) }; } +/** + * Converts deprecated attribute keys to + * the current API to ensure backwards compatibility. + * + * This is needed for the update mechanism to determine which + * subroutines to run based on the actual attribute + * definitions (that don't include the deprecated ones). + * + * E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'} + * and {titlefont: {...}} to {'title.font': {...}}. + * + * @param aobj + */ +function cleanDeprecatedAttributeKeys(aobj) { + var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false); + var colorbarRegex = /colorbar\.title$/; + var keys = Object.keys(aobj); + var i, key, value; + + for(i = 0; i < keys.length; i++) { + key = keys[i]; + value = aobj[key]; + + if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) && + (typeof value === 'string' || typeof value === 'number')) { + replace(key, key.replace('title', 'title.text')); + } else if(key.indexOf('titlefont') > -1) { + replace(key, key.replace('titlefont', 'title.font')); + } else if(key.indexOf('titleposition') > -1) { + replace(key, key.replace('titleposition', 'title.position')); + } else if(key.indexOf('titleside') > -1) { + replace(key, key.replace('titleside', 'title.side')); + } else if(key.indexOf('titleoffset') > -1) { + replace(key, key.replace('titleoffset', 'title.offset')); + } + } + + function replace(oldAttrStr, newAttrStr) { + aobj[newAttrStr] = aobj[oldAttrStr]; + delete aobj[oldAttrStr]; + } +} + /** * relayout: update layout attributes of an existing plot * @@ -106011,7 +106930,7 @@ function _restyle(gd, aobj, traces) { * attribute object `{astr1: val1, astr2: val2 ...}` * allows setting multiple attributes simultaneously */ -exports.relayout = function relayout(gd, astr, val) { +function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -106074,7 +106993,8 @@ exports.relayout = function relayout(gd, astr, val) { gd.emit('plotly_relayout', specs.eventData); return gd; }); -}; +} +exports.relayout = relayout; // Optimization mostly for large splom traces where // Plots.supplyDefaults can take > 100ms @@ -106102,13 +107022,24 @@ function addAxRangeSequence(seq, rangesAltered) { // N.B. leave as sequence of subroutines (for now) instead of // subroutine of its own so that finalDraw always gets // executed after drawData - var doTicks = rangesAltered ? - function(gd) { return Axes.doTicks(gd, Object.keys(rangesAltered), true); } : - function(gd) { return Axes.doTicks(gd, 'redraw'); }; + var drawAxes = rangesAltered ? + function(gd) { + var opts = {skipTitle: true}; + for(var id in rangesAltered) { + if(Axes.getFromId(gd, id).automargin) { + opts = {}; + break; + } + } + return Axes.draw(gd, Object.keys(rangesAltered), opts); + } : + function(gd) { + return Axes.draw(gd, 'redraw'); + }; seq.push( subroutines.doAutoRangeAndConstraints, - doTicks, + drawAxes, subroutines.drawData, subroutines.finalDraw ); @@ -106119,14 +107050,19 @@ var AX_AUTORANGE_RE = /^[xyz]axis[0-9]*\.autorange$/; var AX_DOMAIN_RE = /^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/; function _relayout(gd, aobj) { - var layout = gd.layout, - fullLayout = gd._fullLayout, - keys = Object.keys(aobj), - axes = Axes.list(gd), - arrayEdits = {}, - arrayStr, - i, - j; + var layout = gd.layout; + var fullLayout = gd._fullLayout; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var keys = Object.keys(aobj); + var axes = Axes.list(gd); + var eventData = Lib.extendDeepAll({}, aobj); + var arrayEdits = {}; + + var arrayStr, i, j; + + cleanDeprecatedAttributeKeys(aobj); + keys = Object.keys(aobj); // look for 'allaxes', split out into all axes // in case of 3D the axis are nested within a scene which is held in _id @@ -106166,7 +107102,7 @@ function _relayout(gd, aobj) { // via a parent) do not override with this auto-generated extra if(attr in aobj || helpers.hasParent(aobj, attr)) return; - var p = Lib.nestedProperty(layout, attr); + var p = layoutNP(layout, attr); if(!(attr in undoit)) { undoit[attr] = undefinedToNull(p.get()); } @@ -106191,7 +107127,7 @@ function _relayout(gd, aobj) { throw new Error('cannot set ' + ai + 'and a parent attribute simultaneously'); } - var p = Lib.nestedProperty(layout, ai); + var p = layoutNP(layout, ai); var vi = aobj[ai]; var plen = p.parts.length; // p.parts may end with an index integer if the property is an array @@ -106203,8 +107139,8 @@ function _relayout(gd, aobj) { var pleafPlus = p.parts[pend - 1] + '.' + pleaf; // trunk nodes (everything except the leaf) var ptrunk = p.parts.slice(0, pend).join('.'); - var parentIn = Lib.nestedProperty(gd.layout, ptrunk).get(); - var parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + var parentIn = nestedProperty(gd.layout, ptrunk).get(); + var parentFull = nestedProperty(fullLayout, ptrunk).get(); var vOld = p.get(); if(vi === undefined) continue; @@ -106249,12 +107185,12 @@ function _relayout(gd, aobj) { // check autorange vs range else if(pleafPlus.match(AX_RANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - var axFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + var axFull = nestedProperty(fullLayout, ptrunk).get(); if(axFull._inputDomain) { // if we're autoranging and this axis has a constrained domain, // reset it so we don't get locked into a shrunken size @@ -106262,7 +107198,7 @@ function _relayout(gd, aobj) { } } else if(pleafPlus.match(AX_DOMAIN_RE)) { - Lib.nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); + nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } // toggling axis type between log and linear: we need to convert @@ -106331,10 +107267,10 @@ function _relayout(gd, aobj) { doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleaf.match(AX_NAME_PATTERN)) { - var fullProp = Lib.nestedProperty(fullLayout, ai).get(), + var fullProp = nestedProperty(fullLayout, ai).get(), newType = (vi || {}).type; // This can potentially cause strange behavior if the autotype is not @@ -106356,8 +107292,6 @@ function _relayout(gd, aobj) { arrayStr = containerArrayMatch.array; i = containerArrayMatch.index; var propStr = containerArrayMatch.property; - var componentArray = Lib.nestedProperty(layout, arrayStr); - var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; if(i !== '' && propStr === '') { @@ -106367,7 +107301,7 @@ function _relayout(gd, aobj) { if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { - undoit[ai] = obji; + undoit[ai] = (nestedProperty(layout, arrayStr).get() || [])[i]; } else { Lib.warn('unrecognized full object value', aobj); } @@ -106411,7 +107345,7 @@ function _relayout(gd, aobj) { // now we've collected component edits - execute them all together for(arrayStr in arrayEdits) { var finished = manageArrays.applyContainerArrayChanges(gd, - Lib.nestedProperty(layout, arrayStr), arrayEdits[arrayStr], flags); + layoutNP(layout, arrayStr), arrayEdits[arrayStr], flags, layoutNP); if(!finished) flags.plot = true; } @@ -106454,7 +107388,7 @@ function _relayout(gd, aobj) { rangesAltered: rangesAltered, undoit: undoit, redoit: redoit, - eventData: Lib.extendDeep({}, redoit) + eventData: eventData }; } @@ -106489,7 +107423,7 @@ function updateAutosize(gd) { * integer or array of integers for the traces to alter (all if omitted) * */ -exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { +function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -106569,7 +107503,235 @@ exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { return gd; }); -}; +} +exports.update = update; + +/* + * internal-use-only restyle/relayout/update variants that record the initial + * values in (fullLayout|fullTrace)._preGUI so changes can be persisted across + * Plotly.react data updates, dependent on uirevision attributes + */ +function guiEdit(func) { + return function wrappedEdit(gd) { + gd._fullLayout._guiEditing = true; + var p = func.apply(null, arguments); + gd._fullLayout._guiEditing = false; + return p; + }; +} +exports._guiRestyle = guiEdit(restyle); +exports._guiRelayout = guiEdit(relayout); +exports._guiUpdate = guiEdit(update); + +// For connecting edited layout attributes to uirevision attrs +// If no `attr` we use `match[1] + '.uirevision'` +// Ordered by most common edits first, to minimize our search time +var layoutUIControlPatterns = [ + {pattern: /^hiddenlabels/, attr: 'legend.uirevision'}, + {pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/}, + + // showspikes and modes include those nested inside scenes + {pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'}, + {pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'}, + + {pattern: /^(scene\d*)\.camera/}, + {pattern: /^(geo\d*)\.(projection|center)/}, + {pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/}, + {pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/}, + {pattern: /^(polar\d*\.angularaxis)\.rotation/}, + {pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/}, + + {pattern: /^legend\.(x|y)$/, attr: 'editrevision'}, + {pattern: /^(shapes|annotations)/, attr: 'editrevision'}, + {pattern: /^title\.text$/, attr: 'editrevision'} +]; + +// same for trace attributes: if `attr` is given it's in layout, +// or with no `attr` we use `trace.uirevision` +var traceUIControlPatterns = [ + {pattern: /^selectedpoints$/, attr: 'selectionrevision'}, + // "visible" includes trace.transforms[i].styles[j].value.visible + {pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'}, + {pattern: /^dimensions\[\d+\]\.constraintrange/}, + + // below this you must be in editable: true mode + // TODO: I still put name and title with `trace.uirevision` + // reasonable or should these be `editrevision`? + // Also applies to axis titles up in the layout section + + // "name" also includes transform.styles + {pattern: /(^|value\.)name$/}, + // including nested colorbar attributes (ie marker.colorbar) + {pattern: /colorbar\.title\.text$/}, + {pattern: /colorbar\.(x|y)$/, attr: 'editrevision'} +]; + +function findUIPattern(key, patternSpecs) { + for(var i = 0; i < patternSpecs.length; i++) { + var spec = patternSpecs[i]; + var match = key.match(spec.pattern); + if(match) { + return {head: match[1], attr: spec.attr}; + } + } +} + +// We're finding the new uirevision before supplyDefaults, so do the +// inheritance manually. Note that only `undefined` inherits - other +// falsy values are returned. +function getNewRev(revAttr, container) { + var newRev = nestedProperty(container, revAttr).get(); + if(newRev !== undefined) return newRev; + + var parts = revAttr.split('.'); + parts.pop(); + while(parts.length > 1) { + parts.pop(); + newRev = nestedProperty(container, parts.join('.') + '.uirevision').get(); + if(newRev !== undefined) return newRev; + } + + return container.uirevision; +} + +function getFullTraceIndexFromUid(uid, fullData) { + for(var i = 0; i < fullData.length; i++) { + if(fullData[i]._fullInput.uid === uid) return i; + } + return -1; +} + +function getTraceIndexFromUid(uid, data, tracei) { + for(var i = 0; i < data.length; i++) { + if(data[i].uid === uid) return i; + } + // fall back on trace order, but only if user didn't provide a uid for that trace + return data[tracei].uid ? -1 : tracei; +} + +function valsMatch(v1, v2) { + var v1IsObj = Lib.isPlainObject(v1); + var v1IsArray = Array.isArray(v1); + if(v1IsObj || v1IsArray) { + return ( + (v1IsObj && Lib.isPlainObject(v2)) || + (v1IsArray && Array.isArray(v2)) + ) && JSON.stringify(v1) === JSON.stringify(v2); + } + return v1 === v2; +} + +function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { + var layoutPreGUI = oldFullLayout._preGUI; + var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal; + var bothInheritAutorange = []; + var newRangeAccepted = {}; + for(key in layoutPreGUI) { + match = findUIPattern(key, layoutUIControlPatterns); + if(match) { + revAttr = match.attr || (match.head + '.uirevision'); + oldRev = nestedProperty(oldFullLayout, revAttr).get(); + newRev = oldRev && getNewRev(revAttr, layout); + if(newRev && (newRev === oldRev)) { + preGUIVal = layoutPreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(layout, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + if(newVal === undefined && key.substr(key.length - 9) === 'autorange') { + bothInheritAutorange.push(key.substr(0, key.length - 10)); + } + newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key); + } + // if we got this far, the new value was accepted as the new starting + // point (either because it changed or revision changed) + // so remove it from _preGUI for next time. + delete layoutPreGUI[key]; + + if(key.substr(key.length - 8, 6) === 'range[') { + newRangeAccepted[key.substr(0, key.length - 9)] = 1; + } + } + + // Special logic for `autorange`, since it interacts with `range`: + // If the new figure's matching `range` was kept, and `autorange` + // wasn't supplied explicitly in either the original or the new figure, + // we shouldn't alter that - but we may just have done that, so fix it. + for(var i = 0; i < bothInheritAutorange.length; i++) { + var axAttr = bothInheritAutorange[i]; + if(newRangeAccepted[axAttr]) { + var newAx = nestedProperty(layout, axAttr).get(); + if(newAx) delete newAx.autorange; + } + } + + // Now traces - try to match them up by uid (in case we added/deleted in + // the middle), then fall back on index. + var allTracePreGUI = oldFullLayout._tracePreGUI; + for(var uid in allTracePreGUI) { + var tracePreGUI = allTracePreGUI[uid]; + var newTrace = null; + var fullInput; + for(key in tracePreGUI) { + // wait until we know we have preGUI values to look for traces + // but if we don't find both, stop looking at this uid + if(!newTrace) { + var fulli = getFullTraceIndexFromUid(uid, oldFullData); + if(fulli < 0) { + // Somehow we didn't even have this trace in oldFullData... + // I guess this could happen with `deleteTraces` or something + delete allTracePreGUI[uid]; + break; + } + var fullTrace = oldFullData[fulli]; + fullInput = fullTrace._fullInput; + + var newTracei = getTraceIndexFromUid(uid, data, fullInput.index); + if(newTracei < 0) { + // No match in new data + delete allTracePreGUI[uid]; + break; + } + newTrace = data[newTracei]; + } + + match = findUIPattern(key, traceUIControlPatterns); + if(match) { + if(match.attr) { + oldRev = nestedProperty(oldFullLayout, match.attr).get(); + newRev = oldRev && getNewRev(match.attr, layout); + } + else { + oldRev = fullInput.uirevision; + // inheritance for trace.uirevision is simple, just layout.uirevision + newRev = newTrace.uirevision; + if(newRev === undefined) newRev = layout.uirevision; + } + + if(newRev && newRev === oldRev) { + preGUIVal = tracePreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(newTrace, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + newNP.set(undefinedToNull(nestedProperty(fullInput, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); + } + delete tracePreGUI[key]; + } + } +} /** * Plotly.react: @@ -106633,6 +107795,8 @@ exports.react = function(gd, data, layout, config) { gd.layout = layout || {}; helpers.cleanLayout(gd.layout); + applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout); + // "true" skips updating calcdata and remapping arrays from calcTransforms, // which supplyDefaults usually does at the end, but we may need to NOT do // if the diff (which we haven't determined yet) says we'll recalc @@ -107687,7 +108851,7 @@ function makePlotFramework(gd) { gd.emit('plotly_framework'); } -},{"../components/color":570,"../components/colorbar/connect":572,"../components/drawing":595,"../constants/xmlns_namespaces":674,"../lib":696,"../lib/events":684,"../lib/queue":711,"../lib/svg_text_utils":720,"../plots/cartesian/axes":744,"../plots/cartesian/constants":750,"../plots/cartesian/graph_interact":754,"../plots/plots":808,"../plots/polar/legacy":816,"../registry":827,"./edit_types":727,"./helpers":728,"./manage_arrays":730,"./plot_config":732,"./plot_schema":733,"./subroutines":735,"d3":148,"fast-isnumeric":214,"has-hover":393}],732:[function(_dereq_,module,exports){ +},{"../components/color":569,"../components/colorbar/connect":571,"../components/drawing":590,"../constants/xmlns_namespaces":670,"../lib":692,"../lib/events":681,"../lib/queue":707,"../lib/svg_text_utils":716,"../plots/cartesian/axes":740,"../plots/cartesian/constants":746,"../plots/cartesian/graph_interact":750,"../plots/plots":804,"../plots/polar/legacy":812,"../registry":823,"./edit_types":723,"./helpers":724,"./manage_arrays":726,"./plot_config":728,"./plot_schema":729,"./subroutines":731,"d3":148,"fast-isnumeric":214,"has-hover":393}],728:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107780,12 +108944,34 @@ module.exports = { */ showAxisRangeEntryBoxes: true, - // link to open this plot in plotly + /* + * Add a text link to open this plot in plotly? + * This link shows up in the bottom right corner of the plot, and works + * identically to the newer ModeBar button controlled by `showSendToCloud` + * unless `sendData: false` is used. + */ showLink: false, - // if we show a link, does it contain data or just link to a plotly file? + /* + * If we show a text link (`showLink: true`), does it contain data or just + * a reference to a plotly cloud file? This option should only be used on + * plot.ly or another plotly server, and is not supported by the newer + * ModeBar button `showSendToCloud`. + */ sendData: true, + /* + * Should we include a ModeBar button, labeled "Edit in Chart Studio", + * that sends this chart to plot.ly or another plotly server as specified + * by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0 + * this button was included by default, now it is opt-in using this flag. + * + * Note that this button can (depending on `plotlyServerURL`) send your data + * to an external server. However that server doesn't persist your data + * until you arrive at the Chart Studio and explicitly click "Save". + */ + showSendToCloud: false, + // text appearing in the sendData link linkText: 'Edit chart', @@ -107823,6 +109009,9 @@ module.exports = { // add the plotly logo on the end of the mode bar displaylogo: true, + // watermark the images with the company's logo + watermark: false, + // increase the pixel ratio for Gl plot images plotGlPixelRatio: 2, @@ -107889,7 +109078,7 @@ module.exports = { locales: {} }; -},{}],733:[function(_dereq_,module,exports){ +},{}],729:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108593,7 +109782,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":696,"../plots/animation_attributes":739,"../plots/attributes":741,"../plots/frame_attributes":772,"../plots/layout_attributes":799,"../plots/polar/legacy/area_attributes":814,"../plots/polar/legacy/axis_attributes":815,"../registry":827,"./edit_types":727}],734:[function(_dereq_,module,exports){ +},{"../lib":692,"../plots/animation_attributes":735,"../plots/attributes":737,"../plots/frame_attributes":768,"../plots/layout_attributes":795,"../plots/polar/legacy/area_attributes":810,"../plots/polar/legacy/axis_attributes":811,"../registry":823,"./edit_types":723}],730:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108923,7 +110112,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":696,"../plots/attributes":741}],735:[function(_dereq_,module,exports){ +},{"../lib":692,"../plots/attributes":737}],731:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108953,6 +110142,10 @@ var enforceAxisConstraints = axisConstraints.enforce; var cleanAxisConstraints = axisConstraints.clean; var doAutoRange = _dereq_('../plots/cartesian/autorange').doAutoRange; +var SVG_TEXT_ANCHOR_START = 'start'; +var SVG_TEXT_ANCHOR_MIDDLE = 'middle'; +var SVG_TEXT_ANCHOR_END = 'end'; + exports.layoutStyles = function(gd) { return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd); }; @@ -108977,7 +110170,7 @@ function lsInner(gd) { var gs = fullLayout._size; var pad = gs.p; var axList = Axes.list(gd, '', true); - var i, subplot, plotinfo, xa, ya; + var i, subplot, plotinfo, ax, xa, ya; fullLayout._paperdiv.style({ width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px', @@ -109013,10 +110206,7 @@ function lsInner(gd) { // some preparation of axis position info for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - - // reset scale in case the margins have changed - ax.setScale(); + ax = axList[i]; var counterAx = ax._anchorAxis; @@ -109035,11 +110225,6 @@ function lsInner(gd) { ax._mainMirrorPosition = (ax.mirror && counterAx) ? getLinePosition(ax, counterAx, alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; - - // Figure out which subplot to draw ticks, labels, & axis lines on - // do this as a separate loop so we already have all the - // _mainAxis and _anchorAxis links set - ax._mainSubplot = findMainSubplot(ax, fullLayout); } // figure out which backgrounds we need to draw, @@ -109150,7 +110335,7 @@ function lsInner(gd) { layerClipId = null; } - Drawing.setClipUrl(plotinfo.plot, plotClipId); + Drawing.setClipUrl(plotinfo.plot, plotClipId, gd); // stash layer clipId value (null or same as clipId) // to DRY up Drawing.setClipUrl calls on trace-module and trace layers @@ -109280,48 +110465,6 @@ function lsInner(gd) { return gd._promises.length && Promise.all(gd._promises); } -function findMainSubplot(ax, fullLayout) { - var subplotList = fullLayout._subplots; - var ids = subplotList.cartesian.concat(subplotList.gl2d || []); - var mockGd = {_fullLayout: fullLayout}; - - var isX = ax._id.charAt(0) === 'x'; - var anchorAx = ax._mainAxis._anchorAxis; - var mainSubplotID = ''; - var nextBestMainSubplotID = ''; - var anchorID = ''; - - // First try the main ID with the anchor - if(anchorAx) { - anchorID = anchorAx._mainAxis._id; - mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); - } - - // Then look for a subplot with the counteraxis overlaying the anchor - // If that fails just use the first subplot including this axis - if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { - mainSubplotID = ''; - - for(var j = 0; j < ids.length; j++) { - var id = ids[j]; - var yIndex = id.indexOf('y'); - var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); - var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); - - if(idPart === ax._id) { - if(!nextBestMainSubplotID) nextBestMainSubplotID = id; - var counterAx = Axes.getFromId(mockGd, counterPart); - if(anchorID && counterAx.overlaying === anchorID) { - mainSubplotID = id; - break; - } - } - } - } - - return mainSubplotID || nextBestMainSubplotID; -} - function shouldShowLinesOrTicks(ax, subplot) { return (ax.ticks || ax.showline) && (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); @@ -109376,18 +110519,92 @@ function findCounterAxisLineWidth(ax, side, counterAx, axList) { exports.drawMainTitle = function(gd) { var fullLayout = gd._fullLayout; + var textAnchor = getMainTitleTextAnchor(fullLayout); + var dy = getMainTitleDy(fullLayout); + Titles.draw(gd, 'gtitle', { propContainer: fullLayout, - propName: 'title', + propName: 'title.text', placeholder: fullLayout._dfltTitle.plot, attributes: { - x: fullLayout.width / 2, - y: fullLayout._size.t / 2, - 'text-anchor': 'middle' + x: getMainTitleX(fullLayout, textAnchor), + y: getMainTitleY(fullLayout, dy), + 'text-anchor': textAnchor, + dy: dy } }); }; +function getMainTitleX(fullLayout, textAnchor) { + var title = fullLayout.title; + var gs = fullLayout._size; + var hPadShift = 0; + + if(textAnchor === SVG_TEXT_ANCHOR_START) { + hPadShift = title.pad.l; + } else if(textAnchor === SVG_TEXT_ANCHOR_END) { + hPadShift = -title.pad.r; + } + + switch(title.xref) { + case 'paper': + return gs.l + gs.w * title.x + hPadShift; + case 'container': + default: + return fullLayout.width * title.x + hPadShift; + } +} + +function getMainTitleY(fullLayout, dy) { + var title = fullLayout.title; + var gs = fullLayout._size; + var vPadShift = 0; + + if(dy === '0em' || !dy) { + vPadShift = -title.pad.b; + } else if(dy === alignmentConstants.CAP_SHIFT + 'em') { + vPadShift = title.pad.t; + } + + if(title.y === 'auto') { + return gs.t / 2; + } else { + switch(title.yref) { + case 'paper': + return gs.t + gs.h - gs.h * title.y + vPadShift; + case 'container': + default: + return fullLayout.height - fullLayout.height * title.y + vPadShift; + } + } +} + +function getMainTitleTextAnchor(fullLayout) { + var title = fullLayout.title; + + var textAnchor = SVG_TEXT_ANCHOR_MIDDLE; + if(Lib.isRightAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_END; + } else if(Lib.isLeftAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_START; + } + + return textAnchor; +} + +function getMainTitleDy(fullLayout) { + var title = fullLayout.title; + + var dy = '0em'; + if(Lib.isTopAnchor(title)) { + dy = alignmentConstants.CAP_SHIFT + 'em'; + } else if(Lib.isMiddleAnchor(title)) { + dy = alignmentConstants.MID_SHIFT + 'em'; + } + + return dy; +} + exports.doTraceStyle = function(gd) { var calcdata = gd.calcdata; var editStyleCalls = []; @@ -109465,7 +110682,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.doTicks(gd, 'redraw'); + Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -109600,6 +110817,8 @@ exports.doAutoRangeAndConstraints = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; cleanAxisConstraints(gd, ax); + // in case margins changed, update scale + ax.setScale(); doAutoRange(gd, ax); } @@ -109631,7 +110850,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('updatemenus', 'draw')(gd); }; -},{"../components/color":570,"../components/drawing":595,"../components/modebar":633,"../components/titles":661,"../constants/alignment":668,"../lib":696,"../lib/clear_gl_canvases":680,"../plots/cartesian/autorange":743,"../plots/cartesian/axes":744,"../plots/cartesian/constraints":752,"../plots/plots":808,"../registry":827,"d3":148}],736:[function(_dereq_,module,exports){ +},{"../components/color":569,"../components/drawing":590,"../components/modebar":628,"../components/titles":657,"../constants/alignment":664,"../lib":692,"../lib/clear_gl_canvases":677,"../plots/cartesian/autorange":739,"../plots/cartesian/axes":740,"../plots/cartesian/constraints":748,"../plots/plots":804,"../registry":823,"d3":148}],732:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110105,7 +111324,7 @@ function format(opts) { return opts; } -},{"../lib":696,"../plots/attributes":741,"../plots/plots":808,"./plot_config":732,"./plot_schema":733,"./plot_template":734}],737:[function(_dereq_,module,exports){ +},{"../lib":692,"../plots/attributes":737,"../plots/plots":804,"./plot_config":728,"./plot_schema":729,"./plot_template":730}],733:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110245,6 +111464,7 @@ function toImage(gd, opts) { // extend config for static plot var configImage = Lib.extendFlat({}, config, { + _exportedPlot: true, staticPlot: true, setBackground: setBackground }); @@ -110315,7 +111535,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":696,"../snapshot/helpers":831,"../snapshot/svgtoimg":833,"../snapshot/tosvg":835,"./plot_api":731}],738:[function(_dereq_,module,exports){ +},{"../lib":692,"../snapshot/helpers":827,"../snapshot/svgtoimg":829,"../snapshot/tosvg":831,"./plot_api":727}],734:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110761,7 +111981,7 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":696,"../plots/plots":808,"./plot_config":732,"./plot_schema":733}],739:[function(_dereq_,module,exports){ +},{"../lib":692,"../plots/plots":804,"./plot_config":728,"./plot_schema":729}],735:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110885,7 +112105,7 @@ module.exports = { } }; -},{}],740:[function(_dereq_,module,exports){ +},{}],736:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110981,7 +112201,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":696,"../plot_api/plot_template":734}],741:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/plot_template":730}],737:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -111148,10 +112368,32 @@ module.exports = { 'An array of operations that manipulate the trace data,', 'for example filtering or sorting the data arrays.' ].join(' ') + }, + uirevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of some user-driven changes to the trace:', + '`constraintrange` in `parcoords` traces, as well as some', + '`editable: true` modifications such as `name` and `colorbar.title`.', + 'Defaults to `layout.uirevision`.', + 'Note that other user-driven trace attribute changes are controlled', + 'by `layout` attributes:', + '`trace.visible` is controlled by `layout.legend.uirevision`,', + '`selectedpoints` is controlled by `layout.selectionrevision`,', + 'and `colorbar.(x|y)` (accessible with `config: {editable: true}`)', + 'is controlled by `layout.editrevision`.', + 'Trace changes are tracked by `uid`, which only falls back on trace', + 'index if no `uid` is provided. So if your app can add/remove traces', + 'before the end of the `data` array, such that the same trace has a', + 'different index, you can still preserve user-driven changes if you', + 'give each trace a `uid` that stays with it as it moves.' + ].join(' ') } }; -},{"../components/fx/attributes":604}],742:[function(_dereq_,module,exports){ +},{"../components/fx/attributes":599}],738:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -111192,7 +112434,7 @@ module.exports = { } }; -},{}],743:[function(_dereq_,module,exports){ +},{}],739:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -111207,6 +112449,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; +var Registry = _dereq_('../../registry'); module.exports = { getAutoRange: getAutoRange, @@ -111431,10 +112674,6 @@ function concatExtremes(gd, ax) { } function doAutoRange(gd, ax) { - if(!ax._length) ax.setScale(); - - var axIn; - if(ax.autorange) { ax.range = getAutoRange(gd, ax); @@ -111444,20 +112683,28 @@ function doAutoRange(gd, ax) { // doAutoRange will get called on fullLayout, // but we want to report its results back to layout - axIn = ax._input; + var axIn = ax._input; + + // before we edit _input, store preGUI values + var edits = {}; + edits[ax._attr + '.range'] = ax.range; + edits[ax._attr + '.autorange'] = ax.autorange; + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, edits); + axIn.range = ax.range.slice(); axIn.autorange = ax.autorange; } - if(ax._anchorAxis && ax._anchorAxis.rangeslider) { - var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name]; + var anchorAx = ax._anchorAxis; + + if(anchorAx && anchorAx.rangeslider) { + var axeRangeOpts = anchorAx.rangeslider[ax._name]; if(axeRangeOpts) { if(axeRangeOpts.rangemode === 'auto') { axeRangeOpts.range = getAutoRange(gd, ax); } } - axIn = ax._anchorAxis._input; - axIn.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); } } @@ -111675,7 +112922,7 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":673,"../../lib":696,"fast-isnumeric":214}],744:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../registry":823,"fast-isnumeric":214}],740:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -111835,6 +113082,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t ax.d2c(targetArray[i]); } } + // TODO what to do for transforms? } else { ax = axes.getFromTrace(gd, trace, d2cTarget); } @@ -111875,7 +113123,7 @@ axes.counterLetter = function(id) { axes.minDtick = function(ax, newDiff, newFirst, allow) { // doesn't make sense to do forced min dTick on log or category axes, // and the plot itself may decide to cancel (ie non-grouped bars) - if(['log', 'category'].indexOf(ax.type) !== -1 || !allow) { + if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; } // undefined means there's nothing there yet @@ -111907,18 +113155,15 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // save a copy of the initial axis ranges in fullLayout // use them in mode bar and dblclick events axes.saveRangeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._rangeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.range[0] === ax._rangeInitial[0] && - ax.range[1] === ax._rangeInitial[1] - ) + var hasChanged = isNew || !( + ax.range[0] === ax._rangeInitial[0] && + ax.range[1] === ax._rangeInitial[1] ); if((isNew && ax.autorange === false) || (overwrite && hasChanged)) { @@ -111932,21 +113177,16 @@ axes.saveRangeInitial = function(gd, overwrite) { // save a copy of the initial spike visibility axes.saveShowSpikeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false, - allSpikesEnabled = 'on'; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; + var allSpikesEnabled = 'on'; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._showSpikeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.showspikes === ax._showspikes - ) - ); + var hasChanged = isNew || !(ax.showspikes === ax._showspikes); - if((isNew) || (overwrite && hasChanged)) { + if(isNew || (overwrite && hasChanged)) { ax._showSpikeInitial = ax.showspikes; hasOneAxisChanged = true; } @@ -111963,7 +113203,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { var dataMin = Lib.aggNums(Math.min, null, data); var dataMax = Lib.aggNums(Math.max, null, data); - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { return { start: dataMin - 0.5, end: dataMax + 0.5, @@ -111981,8 +113221,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { type: 'linear', range: [dataMin, dataMax] }; - } - else { + } else { dummyAx = { type: ax.type, range: Lib.simpleMap([dataMin, dataMax], ax.c2r, 0, calendar), @@ -112067,10 +113306,10 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { - var edgecount = 0, - midcount = 0, - intcount = 0, - blankCount = 0; + var edgecount = 0; + var midcount = 0; + var intcount = 0; + var blankCount = 0; function nearEdge(v) { // is a value within 1% of a bin edge? @@ -112161,14 +113400,14 @@ axes.prepTicks = function(ax) { // calculate max number of (auto) ticks to display based on plot size if(ax.tickmode === 'auto' || !ax.dtick) { - var nt = ax.nticks, - minPx; + var nt = ax.nticks; + var minPx; + if(!nt) { - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; nt = ax._length / minPx; - } - else { + } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; nt = Lib.constrain(ax._length / minPx, 4, 9) + 1; } @@ -112230,7 +113469,7 @@ axes.calcTicks = function calcTicks(ax) { // return the full set of tick vals var vals = []; - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { endTick = (axrev) ? Math.max(-0.5, endTick) : Math.min(ax._categories.length - 0.5, endTick); } @@ -112274,23 +113513,22 @@ axes.calcTicks = function calcTicks(ax) { }; function arrayTicks(ax) { - var vals = ax.tickvals, - text = ax.ticktext, - ticksOut = new Array(vals.length), - rng = Lib.simpleMap(ax.range, ax.r2l), - r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001, - r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001, - tickMin = Math.min(r0expanded, r1expanded), - tickMax = Math.max(r0expanded, r1expanded), - vali, - i, - j = 0; + var vals = ax.tickvals; + var text = ax.ticktext; + var ticksOut = new Array(vals.length); + var rng = Lib.simpleMap(ax.range, ax.r2l); + var r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001; + var r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001; + var tickMin = Math.min(r0expanded, r1expanded); + var tickMax = Math.max(r0expanded, r1expanded); + var j = 0; // without a text array, just format the given values as any other ticks // except with more precision to the numbers if(!Array.isArray(text)) text = []; // make sure showing ticks doesn't accidentally add new categories + // TODO multicategory, if we allow ticktext / tickvals var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; // array ticks on log axes always show the full number @@ -112299,8 +113537,8 @@ function arrayTicks(ax) { ax.dtick = 'L' + Math.pow(10, Math.floor(Math.min(ax.range[0], ax.range[1])) - 1); } - for(i = 0; i < vals.length; i++) { - vali = tickVal2l(vals[i]); + for(var i = 0; i < vals.length; i++) { + var vali = tickVal2l(vals[i]); if(vali > tickMin && vali < tickMax) { if(text[i] === undefined) ticksOut[j] = axes.tickText(ax, vali); else ticksOut[j] = tickTextObj(ax, vali, String(text[i])); @@ -112313,17 +113551,17 @@ function arrayTicks(ax) { return ticksOut; } -var roundBase10 = [2, 5, 10], - roundBase24 = [1, 2, 3, 6, 12], - roundBase60 = [1, 2, 5, 10, 15, 30], - // 2&3 day ticks are weird, but need something btwn 1&7 - roundDays = [1, 2, 3, 7, 14], - // approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) - // these don't have to be exact, just close enough to round to the right value - roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1], - roundLog2 = [-0.301, 0, 0.301, 0.699, 1], - // N.B. `thetaunit; 'radians' angular axes must be converted to degrees - roundAngles = [15, 30, 45, 90, 180]; +var roundBase10 = [2, 5, 10]; +var roundBase24 = [1, 2, 3, 6, 12]; +var roundBase60 = [1, 2, 5, 10, 15, 30]; +// 2&3 day ticks are weird, but need something btwn 1&7 +var roundDays = [1, 2, 3, 7, 14]; +// approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) +// these don't have to be exact, just close enough to round to the right value +var roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1]; +var roundLog2 = [-0.301, 0, 0.301, 0.699, 1]; +// N.B. `thetaunit; 'radians' angular axes must be converted to degrees +var roundAngles = [15, 30, 45, 90, 180]; function roundDTick(roughDTick, base, roundingSet) { return base * Lib.roundUp(roughDTick / base, roundingSet); @@ -112414,7 +113652,7 @@ axes.autoTicks = function(ax, roughDTick) { ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } } - else if(ax.type === 'category') { + else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); } @@ -112454,7 +113692,7 @@ function autoTickRound(ax) { dtick = 1; } - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { ax._tickround = null; } if(ax.type === 'date') { @@ -112546,36 +113784,34 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { // calculate the first tick on an axis axes.tickFirst = function(ax) { - var r2l = ax.r2l || Number, - rng = Lib.simpleMap(ax.range, r2l), - axrev = rng[1] < rng[0], - sRound = axrev ? Math.floor : Math.ceil, - // add a tiny extra bit to make sure we get ticks - // that may have been rounded out - r0 = rng[0] * 1.0001 - rng[1] * 0.0001, - dtick = ax.dtick, - tick0 = r2l(ax.tick0); + var r2l = ax.r2l || Number; + var rng = Lib.simpleMap(ax.range, r2l); + var axrev = rng[1] < rng[0]; + var sRound = axrev ? Math.floor : Math.ceil; + // add a tiny extra bit to make sure we get ticks + // that may have been rounded out + var r0 = rng[0] * 1.0001 - rng[1] * 0.0001; + var dtick = ax.dtick; + var tick0 = r2l(ax.tick0); if(isNumeric(dtick)) { var tmin = sRound((r0 - tick0) / dtick) * dtick + tick0; // make sure no ticks outside the category list - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { tmin = Lib.constrain(tmin, 0, ax._categories.length - 1); } return tmin; } - var tType = dtick.charAt(0), - dtNum = Number(dtick.substr(1)); + var tType = dtick.charAt(0); + var dtNum = Number(dtick.substr(1)); // Dates: months (or years) if(tType === 'M') { - var cnt = 0, - t0 = tick0, - t1, - mult, - newDTick; + var cnt = 0; + var t0 = tick0; + var t1, mult, newDTick; // This algorithm should work for *any* nonlinear (but close to linear!) // tick spacing. Limit to 10 iterations, for gregorian months it's normally <=3. @@ -112617,16 +113853,18 @@ axes.tickFirst = function(ax) { // hover is a (truthy) flag for whether to show numbers with a bit // more precision for hovertext axes.tickText = function(ax, x, hover) { - var out = tickTextObj(ax, x), - hideexp, - arrayMode = ax.tickmode === 'array', - extraPrecision = hover || arrayMode, - i, - tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; + var out = tickTextObj(ax, x); + var arrayMode = ax.tickmode === 'array'; + var extraPrecision = hover || arrayMode; + var axType = ax.type; + // TODO multicategory, if we allow ticktext / tickvals + var tickVal2l = axType === 'category' ? ax.d2l_noadd : ax.d2l; + var i; if(arrayMode && Array.isArray(ax.ticktext)) { - var rng = Lib.simpleMap(ax.range, ax.r2l), - minDiff = Math.abs(rng[1] - rng[0]) / 10000; + var rng = Lib.simpleMap(ax.range, ax.r2l); + var minDiff = Math.abs(rng[1] - rng[0]) / 10000; + for(i = 0; i < ax.ticktext.length; i++) { if(Math.abs(x - tickVal2l(ax.tickvals[i])) < minDiff) break; } @@ -112637,28 +113875,25 @@ axes.tickText = function(ax, x, hover) { } function isHidden(showAttr) { - var first_or_last; - if(showAttr === undefined) return true; if(hover) return showAttr === 'none'; - first_or_last = { + var firstOrLast = { first: ax._tmin, last: ax._tmax }[showAttr]; - return showAttr !== 'all' && x !== first_or_last; + return showAttr !== 'all' && x !== firstOrLast; } - if(hover) { - hideexp = 'never'; - } else { - hideexp = ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - } + var hideexp = hover ? + 'never' : + ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - if(ax.type === 'date') formatDate(ax, out, hover, extraPrecision); - else if(ax.type === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); - else if(ax.type === 'category') formatCategory(ax, out); + if(axType === 'date') formatDate(ax, out, hover, extraPrecision); + else if(axType === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); + else if(axType === 'category') formatCategory(ax, out); + else if(axType === 'multicategory') formatMultiCategory(ax, out, hover); else if(isAngular(ax)) formatAngle(ax, out, hover, extraPrecision, hideexp); else formatLinear(ax, out, hover, extraPrecision, hideexp); @@ -112666,6 +113901,20 @@ axes.tickText = function(ax, x, hover) { if(ax.tickprefix && !isHidden(ax.showtickprefix)) out.text = ax.tickprefix + out.text; if(ax.ticksuffix && !isHidden(ax.showticksuffix)) out.text += ax.ticksuffix; + // Setup ticks and grid lines boundaries + // at 1/2 a 'category' to the left/bottom + if(ax.tickson === 'boundaries' || ax.showdividers) { + var inbounds = function(v) { + var p = ax.l2p(v); + return p >= 0 && p <= ax._length ? v : null; + }; + + out.xbnd = [ + inbounds(out.x - 0.5), + inbounds(out.x + ax.dtick - 0.5) + ]; + } + return out; }; @@ -112715,8 +113964,8 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround, - fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); + var tr = ax._tickround; + var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); if(extraPrecision) { // second or sub-second precision: extra always shows max digits. @@ -112725,8 +113974,8 @@ function formatDate(ax, out, hover, extraPrecision) { else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr]; } - var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat), - headStr; + var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat); + var headStr; var splitIndex = dateStr.indexOf('\n'); if(splitIndex !== -1) { @@ -112843,6 +114092,22 @@ function formatCategory(ax, out) { out.text = String(tt); } +function formatMultiCategory(ax, out, hover) { + var v = Math.round(out.x); + var cats = ax._categories[v] || []; + var tt = cats[1] === undefined ? '' : String(cats[1]); + var tt2 = cats[0] === undefined ? '' : String(cats[0]); + + if(hover) { + // TODO is this what we want? + out.text = tt2 + ' - ' + tt; + } else { + // setup for secondary labels + out.text = tt; + out.text2 = tt2; + } +} + function formatLinear(ax, out, hover, extraPrecision, hideexp) { if(hideexp === 'never') { // If this is a hover label, then we must *never* hide the exponent @@ -112948,14 +114213,13 @@ function beyondSI(exponent) { } function numFormat(v, ax, fmtoverride, hover) { - // negative? - var isNeg = v < 0, - // max number of digits past decimal point to show - tickRound = ax._tickround, - exponentFormat = fmtoverride || ax.exponentformat || 'B', - exponent = ax._tickexponent, - tickformat = axes.getTickFormat(ax), - separatethousands = ax.separatethousands; + var isNeg = v < 0; + // max number of digits past decimal point to show + var tickRound = ax._tickround; + var exponentFormat = fmtoverride || ax.exponentformat || 'B'; + var exponent = ax._tickexponent; + var tickformat = axes.getTickFormat(ax); + var separatethousands = ax.separatethousands; // special case for hover: set exponent just for this value, and // add a couple more digits of precision over tick labels @@ -113128,6 +114392,9 @@ axes.getTickFormat = function(ax) { // as an array of items like 'xy', 'x2y', 'x2y2'... // sorted by x (x,x2,x3...) then y // optionally restrict to only subplots containing axis object ax +// +// NOTE: this is currently only used OUTSIDE plotly.js (toolpanel, webapp) +// ideally we get rid of it there (or just copy this there) and remove it here axes.getSubplots = function(gd, ax) { var subplotObj = gd._fullLayout._subplots; var allSubplots = subplotObj.cartesian.concat(subplotObj.gl2d || []); @@ -113146,18 +114413,20 @@ axes.getSubplots = function(gd, ax) { }; // find all subplots with axis 'ax' +// NOTE: this is only used in axes.getSubplots (only used outside plotly.js) and +// gl2d/convert (where it restricts axis subplots to only those with gl2d) axes.findSubplotsWithAxis = function(subplots, ax) { var axMatch = new RegExp( (ax._id.charAt(0) === 'x') ? ('^' + ax._id + 'y') : (ax._id + '$') ); - var subplotsWithAxis = []; + var subplotsWithAx = []; for(var i = 0; i < subplots.length; i++) { var sp = subplots[i]; - if(axMatch.test(sp)) subplotsWithAxis.push(sp); + if(axMatch.test(sp)) subplotsWithAx.push(sp); } - return subplotsWithAxis; + return subplotsWithAx; }; // makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings @@ -113210,24 +114479,25 @@ axes.makeClipPaths = function(gd) { * * @param {DOM element} gd : graph div * @param {string or array of strings} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update + * @param {object} opts: + * - @param {boolean} skipTitle : optional flag to skip axis title draw/update * - * Signature 1: Axes.doTicks(gd, 'redraw') + * Signature 1: Axes.draw(gd, 'redraw') * use this to clear and redraw all axes on graph * - * Signature 2: Axes.doTicks(gd, '') + * Signature 2: Axes.draw(gd, '') * use this to draw all axes on graph w/o the selectAll().remove() * of the 'redraw' signature * - * Signature 3: Axes.doTicks(gd, [axId, axId2, ...]) + * Signature 3: Axes.draw(gd, [axId, axId2, ...]) * where the items are axis id string, * use this to update multiple axes in one call * - * N.B doTicks updates: + * N.B draw updates: * - ax._r (stored range for use by zoom/pan) * - ax._rl (stored linearized range for use by zoom/pan) */ -axes.doTicks = function(gd, arg, skipTitle) { +axes.draw = function(gd, arg, opts) { var fullLayout = gd._fullLayout; if(arg === 'redraw') { @@ -113239,6 +114509,8 @@ axes.doTicks = function(gd, arg, skipTitle) { plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove(); if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); @@ -113248,13 +114520,13 @@ axes.doTicks = function(gd, arg, skipTitle) { var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; - Lib.syncOrAsync(axList.map(function(axid) { + return Lib.syncOrAsync(axList.map(function(axId) { return function() { - if(!axid) return; + if(!axId) return; - var axDone = axes.doTicksSingle(gd, axid, skipTitle); + var ax = axes.getFromId(gd, axId); + var axDone = axes.drawOne(gd, ax, opts); - var ax = axes.getFromId(gd, axid); ax._r = ax.range.slice(); ax._rl = Lib.simpleMap(ax._r, ax.r2l); @@ -113264,692 +114536,1077 @@ axes.doTicks = function(gd, arg, skipTitle) { }; /** - * Per-axis drawing routine! - * - * This routine draws axis ticks and much more (... grids, labels, title etc.) - * Supports multiple argument signatures. - * N.B. this thing is async in general (because of MathJax rendering) - * - * @param {DOM element} gd : graph div - * @param {string or object} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * @return {promise} - * - * Signature 1: Axes.doTicks(gd, ax) - * where ax is an axis object as in fullLayout + * Draw one cartesian axis * - * Signature 2: Axes.doTicks(gd, axId) - * where axId is a axis id string + * @param {DOM element} gd + * @param {object} ax (full) axis object + * @param {object} opts + * - @param {boolean} skipTitle (set to true to skip axis title draw call) */ -axes.doTicksSingle = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; - var independent = false; - var ax; +axes.drawOne = function(gd, ax, opts) { + opts = opts || {}; - if(Lib.isPlainObject(arg)) { - ax = arg; - independent = true; - } else { - ax = axes.getFromId(gd, arg); - } + var i, sp, plotinfo; - // set scaling to pixels ax.setScale(); - var axid = ax._id; - var axLetter = axid.charAt(0); - var counterLetter = axes.counterLetter(axid); + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var counterLetter = axes.counterLetter(axId); + var mainSubplot = ax._mainSubplot; + var mainLinePosition = ax._mainLinePosition; + var mainMirrorPosition = ax._mainMirrorPosition; + var mainPlotinfo = fullLayout._plots[mainSubplot]; + var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; + var subplotsWithAx = ax._subplotsWith; + var vals = ax._vals = axes.calcTicks(ax); - var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; - var tcls = axid + 'tick'; - var gcls = axid + 'grid'; - var zcls = axid + 'zl'; - var pad = (ax.linewidth || 1) / 2; - var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); - var labelShift = 0; - var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); - var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); - var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); - var sides, transfn, tickpathfn, subplots; - var tickLabels; - var i; - if(ax._counterangle && ax.ticks === 'outside') { - var caRad = ax._counterangle * Math.PI / 180; - labelStandoff = ax.ticklen * Math.cos(caRad) + 1; - labelShift = ax.ticklen * Math.sin(caRad); + // Add a couple of axis properties that should cause us to recreate + // elements. Used in d3 data function. + var axInfo = [ax.mirror, mainLinePosition, mainMirrorPosition].join('_'); + for(i = 0; i < vals.length; i++) { + vals[i].axInfo = axInfo; } - if(ax.showticklabels && (ax.ticks === 'outside' || ax.showline)) { - labelStandoff += 0.2 * ax.tickfont.size; - } + if(!ax.visible) return; - // positioning arguments for x vs y axes - if(axLetter === 'x') { - sides = ['bottom', 'top']; - transfn = ax._transfn || function(d) { - return 'translate(' + (ax._offset + ax.l2p(d.x)) + ',0)'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M0,' + shift + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len); - } - else return 'M0,' + shift + 'v' + len; - }; - } - else if(axLetter === 'y') { - sides = ['left', 'right']; - transfn = ax._transfn || function(d) { - return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M' + shift + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); - } - else return 'M' + shift + ',0h' + len; - }; - } - else if(isAngular(ax)) { - sides = ['left', 'right']; - transfn = ax._transfn; - tickpathfn = function(shift, len) { - return 'M' + shift + ',0h' + len; - }; - } - else { - Lib.warn('Unrecognized doTicks axis:', axid); - return; + // stash selections to avoid DOM queries e.g. + // - stash tickLabels selection, so that drawTitle can use it to scoot title + ax._selections = {}; + // stash tick angle (including the computed 'auto' values) per tick-label class + ax._tickAngles = {}; + + var transFn = axes.makeTransFn(ax); + var tickVals; + // We remove zero lines, grid lines, and inside ticks if they're within 1px of the end + // The key case here is removing zero lines when the axis bound is zero + var valsClipped; + + if(ax.tickson === 'boundaries') { + var boundaryVals = getBoundaryVals(ax, vals); + valsClipped = axes.clipEnds(ax, boundaryVals); + tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals; + } else { + valsClipped = axes.clipEnds(ax, vals); + tickVals = ax.ticks === 'inside' ? valsClipped : vals; } - var axside = ax.side || sides[0]; - // which direction do the side[0], side[1], and free ticks go? - // then we flip if outside XOR y axis - var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; - if((ax.ticks !== 'inside') === (axLetter === 'x')) { - ticksign = ticksign.map(function(v) { return -v; }); - } + var gridVals = ax._gridVals = valsClipped; + var dividerVals = getDividerVals(ax, vals); - if(!ax.visible) return; + if(!fullLayout._hasOnlyLargeSploms) { + // keep track of which subplots (by main conteraxis) we've already + // drawn grids for, so we don't overdraw overlaying subplots + var finishedGrids = {}; - if(ax._tickFilter) { - vals = vals.filter(ax._tickFilter); - } + for(i = 0; i < subplotsWithAx.length; i++) { + sp = subplotsWithAx[i]; + plotinfo = fullLayout._plots[sp]; - // Remove zero lines, grid lines, and inside ticks if they're within - // 1 pixel of the end. - // The key case here is removing zero lines when the axis bound is zero. - // Don't clip angular values. - var valsClipped = ax._valsClipped = isAngular(ax) ? - vals : - vals.filter(function(d) { return clipEnds(ax, d.x); }); + var counterAxis = plotinfo[counterLetter + 'axis']; + var mainCounterID = counterAxis._mainAxis._id; + if(finishedGrids[mainCounterID]) continue; + finishedGrids[mainCounterID] = 1; - function drawTicks(container, tickpath) { - var ticks = container.selectAll('path.' + tcls) - .data(ax.ticks === 'inside' ? valsClipped : vals, datafn); + var gridPath = axLetter === 'x' ? + 'M0,' + counterAxis._offset + 'v' + counterAxis._length : + 'M' + counterAxis._offset + ',0h' + counterAxis._length; - if(tickpath && ax.ticks) { - ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) - .classed('crisp', 1) - .call(Color.stroke, ax.tickcolor) - .style('stroke-width', tickWidth + 'px') - .attr('d', tickpath); - ticks.attr('transform', transfn); - ticks.exit().remove(); + axes.drawGrid(gd, ax, { + vals: gridVals, + counterAxis: counterAxis, + layer: plotinfo.gridlayer.select('.' + axId), + path: gridPath, + transFn: transFn + }); + axes.drawZeroLine(gd, ax, { + counterAxis: counterAxis, + layer: plotinfo.zerolinelayer, + path: gridPath, + transFn: transFn + }); } - else ticks.remove(); } - function drawLabels(container, position) { - // tick labels - for now just the main labels. - // TODO: mirror labels, esp for subplots - tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); + var tickSigns = axes.getTickSigns(ax); + var tickSubplots = []; - if(!isNumeric(position)) { - tickLabels.remove(); - drawAxTitle(); - return; - } - if(!ax.showticklabels) { - tickLabels.remove(); - drawAxTitle(); - calcBoundingBox(); - return; + if(ax.ticks) { + var mainTickPath = axes.makeTickPath(ax, mainLinePosition, tickSigns[2]); + var mirrorTickPath; + var fullTickPath; + if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { + mirrorTickPath = axes.makeTickPath(ax, mainMirrorPosition, tickSigns[3]); + fullTickPath = mainTickPath + mirrorTickPath; + } else { + mirrorTickPath = ''; + fullTickPath = mainTickPath; } - var labelx, labely, labelanchor, labelpos0, flipit; - if(axLetter === 'x') { - flipit = (axside === 'bottom') ? 1 : -1; - labelx = function(d) { return d.dx + labelShift * flipit; }; - labelpos0 = position + (labelStandoff + pad) * flipit; - labely = function(d) { - return d.dy + labelpos0 + d.fontSize * - ((axside === 'bottom') ? 1 : -0.2); - }; - labelanchor = function(angle) { - if(!isNumeric(angle) || angle === 0 || angle === 180) { - return 'middle'; - } - return (angle * flipit < 0) ? 'end' : 'start'; - }; - } - else if(axLetter === 'y') { - flipit = (axside === 'right') ? 1 : -1; - labely = function(d) { - return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit; - }; - labelx = function(d) { - return d.dx + position + (labelStandoff + pad + - ((Math.abs(ax.tickangle) === 90) ? d.fontSize / 2 : 0)) * flipit; - }; - labelanchor = function(angle) { - if(isNumeric(angle) && Math.abs(angle) === 90) { - return 'middle'; - } - return axside === 'right' ? 'start' : 'end'; + var tickPath; + if(ax.showdividers && ax.ticks === 'outside' && ax.tickson === 'boundaries') { + var dividerLookup = {}; + for(i = 0; i < dividerVals.length; i++) { + dividerLookup[dividerVals[i].x] = 1; + } + tickPath = function(d) { + return dividerLookup[d.x] ? mirrorTickPath : fullTickPath; }; + } else { + tickPath = fullTickPath; } - else if(isAngular(ax)) { - ax._labelShift = labelShift; - ax._labelStandoff = labelStandoff; - ax._pad = pad; - - labelx = ax._labelx; - labely = ax._labely; - labelanchor = ax._labelanchor; - } - - var maxFontSize = 0, - autoangle = 0, - labelsReady = []; - tickLabels.enter().append('g').classed(tcls, 1) - .append('text') - // only so tex has predictable alignment that we can - // alter later - .attr('text-anchor', 'middle') - .each(function(d) { - var thisLabel = d3.select(this), - newPromise = gd._promises.length; - thisLabel - .call(svgTextUtils.positionText, labelx(d), labely(d)) - .call(Drawing.font, d.font, d.fontSize, d.fontColor) - .text(d.text) - .call(svgTextUtils.convertToTspans, gd); - newPromise = gd._promises[newPromise]; - if(newPromise) { - // if we have an async label, we'll deal with that - // all here so take it out of gd._promises and - // instead position the label and promise this in - // labelsReady - labelsReady.push(gd._promises.pop().then(function() { - positionLabels(thisLabel, ax.tickangle); - })); - } - else { - // sync label: just position it now. - positionLabels(thisLabel, ax.tickangle); - } - }); - tickLabels.exit().remove(); - tickLabels.each(function(d) { - maxFontSize = Math.max(maxFontSize, d.fontSize); + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: mainAxLayer, + path: tickPath, + transFn: transFn }); - if(isAngular(ax)) { - tickLabels.each(function(d) { - d3.select(this).select('text') - .call(svgTextUtils.positionText, labelx(d), labely(d)); + tickSubplots = Object.keys(ax._linepositions || {}); + } + + for(i = 0; i < tickSubplots.length; i++) { + sp = tickSubplots[i]; + plotinfo = fullLayout._plots[sp]; + // [bottom or left, top or right], free and main are handled above + var linepositions = ax._linepositions[sp] || []; + var spTickPath = axes.makeTickPath(ax, linepositions[0], tickSigns[0]) + + axes.makeTickPath(ax, linepositions[1], tickSigns[1]); + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: plotinfo[axLetter + 'axislayer'], + path: spTickPath, + transFn: transFn + }); + } + + var seq = []; + + // tick labels - for now just the main labels. + // TODO: mirror labels, esp for subplots + + seq.push(function() { + var labelFns = axes.makeLabelFns(ax, mainLinePosition); + return axes.drawLabels(gd, ax, { + vals: vals, + layer: mainAxLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn, + }); + }); + + if(ax.type === 'multicategory') { + var labelLength = 0; + var pad = {x: 2, y: 10}[axLetter]; + var sgn = tickSigns[2] * (ax.ticks === 'inside' ? -1 : 1); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick') + pad; + labelLength += ax._tickAngles[axId + 'tick'] ? ax.tickfont.size * LINE_SPACING : 0; + var secondaryPosition = mainLinePosition + labelLength * sgn; + var secondaryLabelFns = axes.makeLabelFns(ax, secondaryPosition); + + return axes.drawLabels(gd, ax, { + vals: getSecondaryLabelVals(ax, vals), + layer: mainAxLayer, + cls: axId + 'tick2', + repositionOnUpdate: true, + secondary: true, + transFn: transFn, + labelXFn: secondaryLabelFns.labelXFn, + labelYFn: secondaryLabelFns.labelYFn, + labelAnchorFn: secondaryLabelFns.labelAnchorFn, }); - } + }); - // How much to shift a multi-line label to center it vertically. - function getAnchorHeight(lineCount, lineHeight, angle) { - var h = (lineCount - 1) * lineHeight; - if(axLetter === 'x') { - if(angle < -60 || 60 < angle) { - return -0.5 * h; - } else if(axside === 'top') { - return -h; - } - } else { - angle *= axside === 'left' ? 1 : -1; - if(angle < -30) { - return -h; - } else if(angle < 30) { - return -0.5 * h; - } - } - return 0; - } - - function positionLabels(s, angle) { - s.each(function(d) { - var anchor = labelanchor(angle, d); - var thisLabel = d3.select(this), - mathjaxGroup = thisLabel.select('.text-math-group'), - transform = transfn.call(thisLabel.node(), d) + - ((isNumeric(angle) && +angle !== 0) ? - (' rotate(' + angle + ',' + labelx(d) + ',' + - (labely(d) - d.fontSize / 2) + ')') : - ''); - var anchorHeight = getAnchorHeight( - svgTextUtils.lineCount(thisLabel), - LINE_SPACING * d.fontSize, - isNumeric(angle) ? +angle : 0); - if(anchorHeight) { - transform += ' translate(0, ' + anchorHeight + ')'; - } - if(mathjaxGroup.empty()) { - thisLabel.select('text').attr({ - transform: transform, - 'text-anchor': anchor - }); - } - else { - var mjShift = - Drawing.bBox(mathjaxGroup.node()).width * - {end: -0.5, start: 0.5}[anchor]; - mathjaxGroup.attr('transform', transform + - (mjShift ? 'translate(' + mjShift + ',0)' : '')); - } + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick2'); + ax._labelLength = labelLength; + + return drawDividers(gd, ax, { + vals: dividerVals, + layer: mainAxLayer, + path: axes.makeTickPath(ax, mainLinePosition, sgn, labelLength), + transFn: transFn }); - } + }); + } - // make sure all labels are correctly positioned at their base angle - // the positionLabels call above is only for newly drawn labels. - // do this without waiting, using the last calculated angle to - // minimize flicker, then do it again when we know all labels are - // there, putting back the prescribed angle to check for overlaps. - positionLabels(tickLabels, ax._lastangle || ax.tickangle); - - function allLabelsReady() { - return labelsReady.length && Promise.all(labelsReady); - } - - function fixLabelOverlaps() { - positionLabels(tickLabels, ax.tickangle); - - // check for auto-angling if x labels overlap - // don't auto-angle at all for log axes with - // base and digit format - if(axLetter === 'x' && !isNumeric(ax.tickangle) && - (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')) { - var lbbArray = []; - tickLabels.each(function(d) { - var s = d3.select(this), - thisLabel = s.select('.text-math-group'), - x = ax.l2p(d.x); - if(thisLabel.empty()) thisLabel = s.select('text'); - - var bb = Drawing.bBox(thisLabel.node()); - - lbbArray.push({ - // ignore about y, just deal with x overlaps - top: 0, - bottom: 10, - height: 10, - left: x - bb.width / 2, - // impose a 2px gap - right: x + bb.width / 2 + 2, - width: bb.width + 2 - }); - }); - for(i = 0; i < lbbArray.length - 1; i++) { - if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { - // any overlap at all - set 30 degrees - autoangle = 30; - break; - } - } - if(autoangle) { - var tickspacing = Math.abs( - (vals[vals.length - 1].x - vals[0].x) * ax._m - ) / (vals.length - 1); - if(tickspacing < maxFontSize * 2.5) { - autoangle = 90; - } - positionLabels(tickLabels, autoangle); - } - ax._lastangle = autoangle; - } + function extendRange(range, newRange) { + range[0] = Math.min(range[0], newRange[0]); + range[1] = Math.max(range[1], newRange[1]); + } - // update the axis title - // (so it can move out of the way if needed) - // TODO: separate out scoot so we don't need to do - // a full redraw of the title (mostly relevant for MathJax) - drawAxTitle(); - return axid + ' done'; - } + function calcBoundingBox() { + if(ax.showticklabels) { + var gdBB = gd.getBoundingClientRect(); + var bBox = mainAxLayer.node().getBoundingClientRect(); - function calcBoundingBox() { - if(ax.showticklabels) { - var gdBB = gd.getBoundingClientRect(); - var bBox = container.node().getBoundingClientRect(); + /* + * the way we're going to use this, the positioning that matters + * is relative to the origin of gd. This is important particularly + * if gd is scrollable, and may have been scrolled between the time + * we calculate this and the time we use it + */ - /* - * the way we're going to use this, the positioning that matters - * is relative to the origin of gd. This is important particularly - * if gd is scrollable, and may have been scrolled between the time - * we calculate this and the time we use it - */ + ax._boundingBox = { + width: bBox.width, + height: bBox.height, + left: bBox.left - gdBB.left, + right: bBox.right - gdBB.left, + top: bBox.top - gdBB.top, + bottom: bBox.bottom - gdBB.top + }; + } else { + var gs = fullLayout._size; + var pos; + + // set dummy bbox for ticklabel-less axes + + if(axLetter === 'x') { + pos = ax.anchor === 'free' ? + gs.t + gs.h * (1 - ax.position) : + gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); ax._boundingBox = { - width: bBox.width, - height: bBox.height, - left: bBox.left - gdBB.left, - right: bBox.right - gdBB.left, - top: bBox.top - gdBB.top, - bottom: bBox.bottom - gdBB.top + top: pos, + bottom: pos, + left: ax._offset, + right: ax._offset + ax._length, + width: ax._length, + height: 0 }; } else { - var gs = fullLayout._size; - var pos; + pos = ax.anchor === 'free' ? + gs.l + gs.w * ax.position : + gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - // set dummy bbox for ticklabel-less axes - - if(axLetter === 'x') { - pos = ax.anchor === 'free' ? - gs.t + gs.h * (1 - ax.position) : - gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); - - ax._boundingBox = { - top: pos, - bottom: pos, - left: ax._offset, - right: ax._offset + ax._length, - width: ax._length, - height: 0 - }; - } else { - pos = ax.anchor === 'free' ? - gs.l + gs.w * ax.position : - gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - - ax._boundingBox = { - left: pos, - right: pos, - bottom: ax._offset + ax._length, - top: ax._offset, - height: ax._length, - width: 0 - }; - } + ax._boundingBox = { + left: pos, + right: pos, + bottom: ax._offset + ax._length, + top: ax._offset, + height: ax._length, + width: 0 + }; } + } - /* - * for spikelines: what's the full domain of positions in the - * opposite direction that are associated with this axis? - * This means any axes that we make a subplot with, plus the - * position of the axis itself if it's free. - */ - if(subplots) { - var fullRange = ax._counterSpan = [Infinity, -Infinity]; - - for(i = 0; i < subplots.length; i++) { - var subplot = fullLayout._plots[subplots[i]]; - var counterAxis = subplot[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + /* + * for spikelines: what's the full domain of positions in the + * opposite direction that are associated with this axis? + * This means any axes that we make a subplot with, plus the + * position of the axis itself if it's free. + */ + if(subplotsWithAx) { + var fullRange = ax._counterSpan = [Infinity, -Infinity]; - extendRange(fullRange, [ - counterAxis._offset, - counterAxis._offset + counterAxis._length - ]); - } + for(var i = 0; i < subplotsWithAx.length; i++) { + var plotinfo = fullLayout._plots[subplotsWithAx[i]]; + var counterAxis = plotinfo[(axLetter === 'x') ? 'yaxis' : 'xaxis']; - if(ax.anchor === 'free') { - extendRange(fullRange, (axLetter === 'x') ? - [ax._boundingBox.bottom, ax._boundingBox.top] : - [ax._boundingBox.right, ax._boundingBox.left]); - } + extendRange(fullRange, [ + counterAxis._offset, + counterAxis._offset + counterAxis._length + ]); } - function extendRange(range, newRange) { - range[0] = Math.min(range[0], newRange[0]); - range[1] = Math.max(range[1], newRange[1]); + if(ax.anchor === 'free') { + extendRange(fullRange, (axLetter === 'x') ? + [ax._boundingBox.bottom, ax._boundingBox.top] : + [ax._boundingBox.right, ax._boundingBox.left]); } } + } - function doAutoMargins() { - var pushKey = ax._name + '.automargin'; - if(axLetter !== 'x' && axLetter !== 'y') { return; } - if(!ax.automargin) { - Plots.autoMargin(gd, pushKey); - return; - } + var hasRangeSlider = Registry.getComponentMethod('rangeslider', 'isVisible')(ax); - var s = ax.side[0]; - var push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + function doAutoMargins() { + var push, rangeSliderPush; + + if(hasRangeSlider) { + rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); + } + Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); + + var s = ax.side.charAt(0); + if(ax.automargin && (!hasRangeSlider || s !== 'b')) { + push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; if(axLetter === 'x') { push.y = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 't' ? 1 : 0]); + ax._anchorAxis.domain[s === 't' ? 1 : 0]); push[s] += ax._boundingBox.height; - } - else { + } else { push.x = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 'r' ? 1 : 0]); + ax._anchorAxis.domain[s === 'r' ? 1 : 0]); push[s] += ax._boundingBox.width; } - if(ax.title !== fullLayout._dfltTitle[axLetter]) { - push[s] += ax.titlefont.size; + if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { + push[s] += ax.title.font.size; } - - Plots.autoMargin(gd, pushKey, push); } - var done = Lib.syncOrAsync([ - allLabelsReady, - fixLabelOverlaps, - calcBoundingBox, - doAutoMargins - ]); - if(done && done.then) gd._promises.push(done); - return done; + Plots.autoMargin(gd, axAutoMarginID(ax), push); } - function drawAxTitle() { - if(skipTitle) return; + seq.push(calcBoundingBox, doAutoMargins); - // now this only applies to regular cartesian axes; colorbars and - // others ALWAYS call doTicks with skipTitle=true so they can - // configure their own titles. + if(!opts.skipTitle && + !(hasRangeSlider && ax._boundingBox && ax.side === 'bottom') + ) { + seq.push(function() { return drawTitle(gd, ax); }); + } - // rangeslider takes over a bottom title so drop it here - if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; + return Lib.syncOrAsync(seq); +}; - var avoid = { - selection: tickLabels, - side: ax.side - }; - var axLetter = axid.charAt(0); - var gs = gd._fullLayout._size; - var offsetBase = 1.5; - var fontSize = ax.titlefont.size; +function getBoundaryVals(ax, vals) { + var out = []; + var i; - var transform, counterAxis, x, y; + // boundaryVals are never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; - if(tickLabels.size()) { - var translation = Drawing.getTranslate(tickLabels.node().parentNode); - avoid.offsetLeft = translation.x; - avoid.offsetTop = translation.y; + if(vals.length) { + for(i = 0; i < vals.length; i++) { + _push(vals[i], 0); } + _push(vals[i - 1], 1); + } - var titleStandoff = 10 + fontSize * offsetBase + - (ax.linewidth ? ax.linewidth - 1 : 0); + return out; +} - if(axLetter === 'x') { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : - axisIds.getFromId(gd, ax.anchor); +function getSecondaryLabelVals(ax, vals) { + var out = []; + var lookup = {}; - x = ax._offset + ax._length / 2; + for(var i = 0; i < vals.length; i++) { + var d = vals[i]; + if(lookup[d.text2]) { + lookup[d.text2].push(d.x); + } else { + lookup[d.text2] = [d.x]; + } + } - if(ax.side === 'top') { - y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); - } - else { - y = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1.5 : 0.5); - } - y += counterAxis._offset; + for(var k in lookup) { + out.push(tickTextObj(ax, Lib.interp(lookup[k], 0.5), k)); + } + + return out; +} - if(!avoid.side) avoid.side = 'bottom'; +function getDividerVals(ax, vals) { + var out = []; + var i, current; + + // never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); } - else { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + }; - y = ax._offset + ax._length / 2; - if(ax.side === 'right') { - x = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1 : 0.5); - } - else { - x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + if(ax.showdividers && vals.length) { + for(i = 0; i < vals.length; i++) { + var d = vals[i]; + if(d.text2 !== current) { + _push(d, 0); } - x += counterAxis._offset; + current = d.text2; + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getLabelLevelSpan(ax, cls) { + var axLetter = ax._id.charAt(0); + var angle = ax._tickAngles[cls] || 0; + var rad = Lib.deg2rad(angle); + var sinA = Math.sin(rad); + var cosA = Math.cos(rad); + var maxX = 0; + var maxY = 0; + + // N.B. Drawing.bBox does not take into account rotate transforms + + ax._selections[cls].each(function() { + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + var w = bb.width; + var h = bb.height; + maxX = Math.max(maxX, cosA * w, sinA * h); + maxY = Math.max(maxY, sinA * w, cosA * h); + }); + + return {x: maxY, y: maxX}[axLetter]; +} + +/** + * Which direction do the 'ax.side' values, and free ticks go? + * + * @param {object} ax (full) axis object + * - {string} _id (starting with 'x' or 'y') + * - {string} side + * - {string} ticks + * @return {array} all entries are either -1 or 1 + * - [0]: sign for top/right ticks (i.e. negative SVG direction) + * - [1]: sign for bottom/left ticks (i.e. positive SVG direction) + * - [2]: sign for ticks corresponding to 'ax.side' + * - [3]: sign for ticks mirroring 'ax.side' + */ +axes.getTickSigns = function(ax) { + var axLetter = ax._id.charAt(0); + var sideOpposite = {x: 'top', y: 'right'}[axLetter]; + var main = ax.side === sideOpposite ? 1 : -1; + var out = [-1, 1, main, -main]; + // then we flip if outside XOR y axis + if((ax.ticks !== 'inside') === (axLetter === 'x')) { + out = out.map(function(v) { return -v; }); + } + return out; +}; + +/** + * Make axis translate transform function + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} _offset + * - {fn} l2p + * @return {fn} function of calcTicks items + */ +axes.makeTransFn = function(ax) { + var axLetter = ax._id.charAt(0); + var offset = ax._offset; + return axLetter === 'x' ? + function(d) { return 'translate(' + (offset + ax.l2p(d.x)) + ',0)'; } : + function(d) { return 'translate(0,' + (offset + ax.l2p(d.x)) + ')'; }; +}; - transform = {rotate: '-90', offset: 0}; - if(!avoid.side) avoid.side = 'left'; +/** + * Make axis tick path string + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} ticklen + * - {number} linewidth + * @param {number} shift along direction of ticklen + * @param {1 or -1} sng tick sign + * @param {number (optional)} len tick length + * @return {string} + */ +axes.makeTickPath = function(ax, shift, sgn, len) { + len = len !== undefined ? len : ax.ticklen; + + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + + return axLetter === 'x' ? + 'M0,' + (shift + pad * sgn) + 'v' + (len * sgn) : + 'M' + (shift + pad * sgn) + ',0h' + (len * sgn); +}; + +/** + * Make axis tick label x, y and anchor functions + * + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} ticklen + * - {string} side + * - {number} linewidth + * - {number} tickfont.size + * - {boolean} showline + * @param {number} shift + * @param {number} angle [in degrees] ... + * @return {object} + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + * - {number} labelStandoff + * - {number} labelShift + */ +axes.makeLabelFns = function(ax, shift, angle) { + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside'; + + var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0; + var labelShift = 0; + + if(angle && ax.ticks === 'outside') { + var rad = Lib.deg2rad(angle); + labelStandoff = ax.ticklen * Math.cos(rad) + 1; + labelShift = ax.ticklen * Math.sin(rad); + } + + if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) { + labelStandoff += 0.2 * ax.tickfont.size; + } + + // Used in polar angular label x/y functions + // TODO generalize makeLabelFns so that it just work for angular axes + var out = { + labelStandoff: labelStandoff, + labelShift: labelShift + }; + + var x0, y0, ff, flipIt; + if(axLetter === 'x') { + flipIt = ax.side === 'bottom' ? 1 : -1; + x0 = labelShift * flipIt; + y0 = shift + (labelStandoff + pad) * flipIt; + ff = ax.side === 'bottom' ? 1 : -0.2; + + out.labelXFn = function(d) { return d.dx + x0; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * ff; }; + out.labelAnchorFn = function(a) { + if(!isNumeric(a) || a === 0 || a === 180) { + return 'middle'; + } + return (a * flipIt < 0) ? 'end' : 'start'; + }; + } else if(axLetter === 'y') { + flipIt = ax.side === 'right' ? 1 : -1; + x0 = labelStandoff + pad; + y0 = -labelShift * flipIt; + ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0; + + out.labelXFn = function(d) { return d.dx + shift + (x0 + d.fontSize * ff) * flipIt; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; }; + out.labelAnchorFn = function(a) { + if(isNumeric(a) && Math.abs(a) === 90) { + return 'middle'; + } + return ax.side === 'right' ? 'start' : 'end'; + }; + } + + return out; +}; + +function tickDataFn(d) { + return [d.text, d.x, d.axInfo, d.font, d.fontSize, d.fontColor].join('_'); +} + +/** + * Draw axis ticks + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} linewidth + * - {string} tickcolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawTicks = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'tick'; + + var ticks = opts.layer.selectAll('path.' + cls) + .data(ax.ticks ? opts.vals : [], tickDataFn); + + ticks.exit().remove(); + + ticks.enter().append('path') + .classed(cls, 1) + .classed('ticks', 1) + .classed('crisp', opts.crisp !== false) + .call(Color.stroke, ax.tickcolor) + .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') + .attr('d', opts.path); + + ticks.attr('transform', opts.transFn); +}; + +/** + * Draw axis grid + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showgrid + * - {string} gridcolor + * - {string} gridwidth + * - {boolean} zeroline + * - {string} type + * - {string} dtick + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * optional - only required if this axis supports zero lines + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawGrid = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'grid'; + var vals = opts.vals; + var counterAx = opts.counterAxis; + if(ax.showgrid === false) { + vals = []; + } + else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + var isArrayMode = ax.tickmode === 'array'; + for(var i = 0; i < vals.length; i++) { + var xi = vals[i].x; + if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) { + vals = vals.slice(0, i).concat(vals.slice(i + 1)); + // In array mode you can in principle have multiple + // ticks at 0, so test them all. Otherwise once we found + // one we can stop. + if(isArrayMode) i--; + else break; + } } + } + + var grid = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + grid.exit().remove(); + + grid.enter().append('path') + .classed(cls, 1) + .classed('crisp', opts.crisp !== false); + + ax._gw = Drawing.crispRound(gd, ax.gridwidth, 1); + + grid.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.gridcolor || '#ddd') + .style('stroke-width', ax._gw + 'px'); + + if(typeof opts.path === 'function') grid.attr('d', opts.path); +}; - Titles.draw(gd, axid + 'title', { - propContainer: ax, - propName: ax._name + '.title', - placeholder: fullLayout._dfltTitle[axLetter], - avoid: avoid, - transform: transform, - attributes: {x: x, y: y, 'text-anchor': 'middle'} +/** + * Draw axis zero-line + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} zeroline + * - {number} zerolinewidth + * - {string} zerolinecolor + * - {number (optional)} _gridWidthCrispRound + * @param {object} opts + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawZeroLine = function(gd, ax, opts) { + opts = opts || opts; + + var cls = ax._id + 'zl'; + var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis); + + var zl = opts.layer.selectAll('path.' + cls) + .data(show ? [{x: 0, id: ax._id}] : []); + + zl.exit().remove(); + + zl.enter().append('path') + .classed(cls, 1) + .classed('zl', 1) + .classed('crisp', opts.crisp !== false) + .each(function() { + // use the fact that only one element can enter to trigger a sort. + // If several zerolines enter at the same time we will sort once per, + // but generally this should be a minimal overhead. + opts.layer.selectAll('path').sort(function(da, db) { + return axisIds.idSort(da.id, db.id); + }); }); - } - function drawGrid(plotinfo, counteraxis) { - if(fullLayout._hasOnlyLargeSploms) return; - - var gridcontainer = plotinfo.gridlayer.selectAll('.' + axid); - var zlcontainer = plotinfo.zerolinelayer; - var gridpath = ax._gridpath || ((axLetter === 'x' ? - ('M0,' + counteraxis._offset + 'v') : - ('M' + counteraxis._offset + ',0h') - ) + counteraxis._length); - var grid = gridcontainer.selectAll('path.' + gcls) - .data((ax.showgrid === false) ? [] : valsClipped, datafn); - grid.enter().append('path').classed(gcls, 1) - .classed('crisp', 1) - .attr('d', gridpath) + zl.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); +}; + +/** + * Draw axis tick labels + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showticklabels + * - {number} tickangle + * - {object (optional)} _selections + * - {object} (optional)} _tickAngles + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string (optional)} cls (node className) + * - {boolean} repositionOnUpdate (set to true to reposition update selection) + * - {boolean} secondary + * - {fn} transFn + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + */ +axes.drawLabels = function(gd, ax, opts) { + opts = opts || {}; + + var axId = ax._id; + var axLetter = axId.charAt(0); + var cls = opts.cls || axId + 'tick'; + var vals = opts.vals; + var labelXFn = opts.labelXFn; + var labelYFn = opts.labelYFn; + var labelAnchorFn = opts.labelAnchorFn; + var tickAngle = opts.secondary ? 0 : ax.tickangle; + var lastAngle = (ax._tickAngles || {})[cls]; + + var tickLabels = opts.layer.selectAll('g.' + cls) + .data(ax.showticklabels ? vals : [], tickDataFn); + + var labelsReady = []; + + tickLabels.enter().append('g') + .classed(cls, 1) + .append('text') + // only so tex has predictable alignment that we can + // alter later + .attr('text-anchor', 'middle') .each(function(d) { - if(ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - Math.abs(d.x) < ax.dtick / 100) { - d3.select(this).remove(); + var thisLabel = d3.select(this); + var newPromise = gd._promises.length; + + thisLabel + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)) + .call(Drawing.font, d.font, d.fontSize, d.fontColor) + .text(d.text) + .call(svgTextUtils.convertToTspans, gd); + + if(gd._promises[newPromise]) { + // if we have an async label, we'll deal with that + // all here so take it out of gd._promises and + // instead position the label and promise this in + // labelsReady + labelsReady.push(gd._promises.pop().then(function() { + positionLabels(thisLabel, tickAngle); + })); + } else { + // sync label: just position it now. + positionLabels(thisLabel, tickAngle); } }); - grid.attr('transform', transfn) - .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', gridWidth + 'px'); - if(typeof gridpath === 'function') grid.attr('d', gridpath); - grid.exit().remove(); - - // zero line - if(zlcontainer) { - var zlData = {x: 0, id: axid}; - var showZl = axes.shouldShowZeroLine(gd, ax, counteraxis); - var zl = zlcontainer.selectAll('path.' + zcls) - .data(showZl ? [zlData] : []); - zl.enter().append('path').classed(zcls, 1).classed('zl', 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function() { - // use the fact that only one element can enter to trigger a sort. - // If several zerolines enter at the same time we will sort once per, - // but generally this should be a minimal overhead. - zlcontainer.selectAll('path').sort(function(da, db) { - return axisIds.idSort(da.id, db.id); - }); - }); - zl.attr('transform', transfn) - .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', zeroLineWidth + 'px'); - zl.exit().remove(); - } + + tickLabels.exit().remove(); + + if(opts.repositionOnUpdate) { + tickLabels.each(function(d) { + d3.select(this).select('text') + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)); + }); } - if(independent) { - drawTicks(ax._axislayer, tickpathfn(ax._pos + pad * ticksign[2], ticksign[2] * ax.ticklen)); - if(ax._counteraxis) { - var fictionalPlotinfo = { - gridlayer: ax._gridlayer, - zerolinelayer: ax._zerolinelayer - }; - drawGrid(fictionalPlotinfo, ax._counteraxis); + // How much to shift a multi-line label to center it vertically. + function getAnchorHeight(lineCount, lineHeight, angle) { + var h = (lineCount - 1) * lineHeight; + if(axLetter === 'x') { + if(angle < -60 || 60 < angle) { + return -0.5 * h; + } else if(ax.side === 'top') { + return -h; + } + } else { + angle *= ax.side === 'left' ? 1 : -1; + if(angle < -30) { + return -h; + } else if(angle < 30) { + return -0.5 * h; + } } - return drawLabels(ax._axislayer, ax._pos); + return 0; } - else if(fullLayout._has('cartesian')) { - subplots = axes.getSubplots(gd, ax); - // keep track of which subplots (by main conteraxis) we've already - // drawn grids for, so we don't overdraw overlaying subplots - var finishedGrids = {}; - - subplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; - var counterAxis = plotinfo[counterLetter + 'axis']; + function positionLabels(s, angle) { + s.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + var anchor = labelAnchorFn(angle, d); + + var transform = opts.transFn.call(thisLabel.node(), d) + + ((isNumeric(angle) && +angle !== 0) ? + (' rotate(' + angle + ',' + labelXFn(d) + ',' + + (labelYFn(d) - d.fontSize / 2) + ')') : + ''); + + var anchorHeight = getAnchorHeight( + svgTextUtils.lineCount(thisLabel), + LINE_SPACING * d.fontSize, + isNumeric(angle) ? +angle : 0 + ); - var mainCounterID = counterAxis._mainAxis._id; - if(finishedGrids[mainCounterID]) return; - finishedGrids[mainCounterID] = 1; + if(anchorHeight) { + transform += ' translate(0, ' + anchorHeight + ')'; + } - drawGrid(plotinfo, counterAxis, subplot); + if(mathjaxGroup.empty()) { + thisLabel.select('text').attr({ + transform: transform, + 'text-anchor': anchor + }); + } else { + var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; + var mjShift = mjWidth * {end: -0.5, start: 0.5}[anchor]; + mathjaxGroup.attr('transform', transform + (mjShift ? 'translate(' + mjShift + ',0)' : '')); + } }); + } - var mainSubplot = ax._mainSubplot; - var mainPlotinfo = fullLayout._plots[mainSubplot]; - var tickSubplots = []; + // make sure all labels are correctly positioned at their base angle + // the positionLabels call above is only for newly drawn labels. + // do this without waiting, using the last calculated angle to + // minimize flicker, then do it again when we know all labels are + // there, putting back the prescribed angle to check for overlaps. + positionLabels(tickLabels, lastAngle || tickAngle); - if(ax.ticks) { - var mainSign = ticksign[2]; - var tickpath = tickpathfn(ax._mainLinePosition + pad * mainSign, mainSign * ax.ticklen); - if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { - tickpath += tickpathfn(ax._mainMirrorPosition - pad * mainSign, -mainSign * ax.ticklen); - } - drawTicks(mainPlotinfo[axLetter + 'axislayer'], tickpath); + function allLabelsReady() { + return labelsReady.length && Promise.all(labelsReady); + } - tickSubplots = Object.keys(ax._linepositions || {}); - } + function fixLabelOverlaps() { + positionLabels(tickLabels, tickAngle); + + var autoangle = null; + + // check for auto-angling if x labels overlap + // don't auto-angle at all for log axes with + // base and digit format + if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) && + (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D') + ) { + autoangle = 0; - tickSubplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; + var maxFontSize = 0; + var lbbArray = []; + var i; - var container = plotinfo[axLetter + 'axislayer']; + tickLabels.each(function(d) { + maxFontSize = Math.max(maxFontSize, d.fontSize); + + var x = ax.l2p(d.x); + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + + lbbArray.push({ + // ignore about y, just deal with x overlaps + top: 0, + bottom: 10, + height: 10, + left: x - bb.width / 2, + // impose a 2px gap + right: x + bb.width / 2 + 2, + width: bb.width + 2 + }); + }); + + if((ax.tickson === 'boundaries' || ax.showdividers) && !opts.secondary) { + var gap = 2; + if(ax.ticks) gap += ax.tickwidth / 2; - // [bottom or left, top or right] - // free and main are handled above - var linepositions = ax._linepositions[subplot] || []; + // TODO should secondary labels also fall into this fix-overlap regime? - function tickPathSide(sidei) { - var tsign = ticksign[sidei]; - return tickpathfn(linepositions[sidei] + pad * tsign, tsign * ax.ticklen); + for(i = 0; i < lbbArray.length; i++) { + var xbnd = vals[i].xbnd; + var lbb = lbbArray[i]; + if( + (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || + (xbnd[1] !== null && (ax.l2p(xbnd[1]) - lbb.right) < gap) + ) { + autoangle = 90; + break; + } + } + } else { + var vLen = vals.length; + var tickSpacing = Math.abs((vals[vLen - 1].x - vals[0].x) * ax._m) / (vLen - 1); + var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory'; + + // any overlap at all - set 30 degrees or 90 degrees + for(i = 0; i < lbbArray.length - 1; i++) { + if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { + autoangle = rotate90 ? 90 : 30; + break; + } + } } - drawTicks(container, tickPathSide(0) + tickPathSide(1)); - }); + if(autoangle) { + positionLabels(tickLabels, autoangle); + } + } - var mainContainer = mainPlotinfo[axLetter + 'axislayer']; + if(ax._tickAngles) { + ax._tickAngles[cls] = autoangle === null ? + (isNumeric(tickAngle) ? tickAngle : 0) : + autoangle; + } + } - return drawLabels(mainContainer, ax._mainLinePosition); + if(ax._selections) { + ax._selections[cls] = tickLabels; } + + var done = Lib.syncOrAsync([allLabelsReady, fixLabelOverlaps]); + if(done && done.then) gd._promises.push(done); + return done; }; +/** + * Draw axis dividers + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} showdividers + * - {number} dividerwidth + * - {string} dividercolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {fn} path + * - {fn} transFn + */ +function drawDividers(gd, ax, opts) { + var cls = ax._id + 'divider'; + var vals = opts.vals; + + var dividers = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + dividers.exit().remove(); + + dividers.enter().insert('path', ':first-child') + .classed(cls, 1) + .classed('crisp', 1) + .call(Color.stroke, ax.dividercolor) + .style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px'); + + dividers + .attr('transform', opts.transFn) + .attr('d', opts.path); +} + +function drawTitle(gd, ax) { + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var gs = fullLayout._size; + var fontSize = ax.title.font.size; + + var titleStandoff; + if(ax.type === 'multicategory') { + titleStandoff = ax._labelLength; + } else { + var offsetBase = 1.5; + titleStandoff = 10 + fontSize * offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); + } + + var transform, counterAxis, x, y; + + if(axLetter === 'x') { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + x = ax._offset + ax._length / 2; + + if(ax.side === 'top') { + y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); + } else { + y = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1.5 : 0.5); + } + y += counterAxis._offset; + } else { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + y = ax._offset + ax._length / 2; + + if(ax.side === 'right') { + x = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1 : 0.5); + } else { + x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + } + x += counterAxis._offset; + + transform = {rotate: '-90', offset: 0}; + } + + var avoid; + + if(ax.type !== 'multicategory') { + var tickLabels = ax._selections[ax._id + 'tick']; + + avoid = { + selection: tickLabels, + side: ax.side + }; + + if(tickLabels && tickLabels.node() && tickLabels.node().parentNode) { + var translation = Drawing.getTranslate(tickLabels.node().parentNode); + avoid.offsetLeft = translation.x; + avoid.offsetTop = translation.y; + } + } + + return Titles.draw(gd, axId + 'title', { + propContainer: ax, + propName: ax._name + '.title.text', + placeholder: fullLayout._dfltTitle[axLetter], + avoid: avoid, + transform: transform, + attributes: {x: x, y: y, 'text-anchor': 'middle'} + }); +} + axes.shouldShowZeroLine = function(gd, ax, counterAxis) { var rng = Lib.simpleMap(ax.range, ax.r2l); return ( (rng[0] * rng[1] <= 0) && ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - ax._valsClipped.length && + ax._gridVals.length && ( clipEnds(ax, 0) || !anyCounterAxLineAtZero(gd, ax, counterAxis, rng) || @@ -113958,6 +115615,10 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { ); }; +axes.clipEnds = function(ax, vals) { + return vals.filter(function(d) { return clipEnds(ax, d.x); }); +}; + function clipEnds(ax, l) { var p = ax.l2p(l); return (p > 1 && p < ax._length - 1); @@ -114033,6 +115694,12 @@ function hasBarsOrFill(gd, ax) { return false; } +function selectTickLabel(gTick) { + var s = d3.select(gTick); + var mj = s.select('.text-math-group'); + return mj.empty() ? s.select('text') : mj; +} + /** * Find all margin pushers for 2D axes and reserve them for later use * Both label and rangeslider automargin calculations happen later so @@ -114047,14 +115714,17 @@ axes.allowAutoMargin = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; if(ax.automargin) { - Plots.allowAutoMargin(gd, ax._name + '.automargin'); + Plots.allowAutoMargin(gd, axAutoMarginID(ax)); } - if(ax.rangeslider && ax.rangeslider.visible) { - Plots.allowAutoMargin(gd, 'rangeslider' + ax._id); + if(Registry.getComponentMethod('rangeslider', 'isVisible')(ax)) { + Plots.allowAutoMargin(gd, rangeSliderAutoMarginID(ax)); } } }; +function axAutoMarginID(ax) { return ax._id + '.automargin'; } +function rangeSliderAutoMarginID(ax) { return ax._id + '.rangeslider'; } + // swap all the presentation attributes of the axes showing these traces axes.swap = function(gd, traces) { var axGroups = makeAxisGroups(gd, traces); @@ -114110,11 +115780,10 @@ function mergeAxisGroups(intoSet, fromSet) { } function swapAxisGroup(gd, xIds, yIds) { - var i, - j, - xFullAxes = [], - yFullAxes = [], - layout = gd.layout; + var xFullAxes = []; + var yFullAxes = []; + var layout = gd.layout; + var i, j; for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i])); for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i])); @@ -114127,12 +115796,12 @@ function swapAxisGroup(gd, xIds, yIds) { var numericTypes = ['linear', 'log']; for(i = 0; i < allAxKeys.length; i++) { - var keyi = allAxKeys[i], - xVal = xFullAxes[0][keyi], - yVal = yFullAxes[0][keyi], - allEqual = true, - coerceLinearX = false, - coerceLinearY = false; + var keyi = allAxKeys[i]; + var xVal = xFullAxes[0][keyi]; + var yVal = yFullAxes[0][keyi]; + var allEqual = true; + var coerceLinearX = false; + var coerceLinearY = false; if(keyi.charAt(0) === '_' || typeof xVal === 'function' || noSwapAttrs.indexOf(keyi) !== -1) { continue; @@ -114178,17 +115847,18 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes, dfltTitle) { // in case the value is the default for either axis, // look at the first axis in each list and see if // this key's value is undefined - var np = Lib.nestedProperty, - xVal = np(layout[xFullAxes[0]._name], key).get(), - yVal = np(layout[yFullAxes[0]._name], key).get(), - i; + var np = Lib.nestedProperty; + var xVal = np(layout[xFullAxes[0]._name], key).get(); + var yVal = np(layout[yFullAxes[0]._name], key).get(); + var i; + if(key === 'title') { // special handling of placeholder titles - if(xVal === dfltTitle.x) { - xVal = dfltTitle.y; + if(xVal && xVal.text === dfltTitle.x) { + xVal.text = dfltTitle.y; } - if(yVal === dfltTitle.y) { - yVal = dfltTitle.x; + if(yVal && yVal.text === dfltTitle.y) { + yVal.text = dfltTitle.x; } } @@ -114204,7 +115874,7 @@ function isAngular(ax) { return ax._id === 'angularaxis'; } -},{"../../components/color":570,"../../components/drawing":595,"../../components/titles":661,"../../constants/alignment":668,"../../constants/numerical":673,"../../lib":696,"../../lib/svg_text_utils":720,"../../plots/plots":808,"../../registry":827,"./autorange":743,"./axis_autotype":745,"./axis_ids":747,"./clean_ticks":749,"./layout_attributes":757,"./set_convert":763,"d3":148,"fast-isnumeric":214}],745:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../components/titles":657,"../../constants/alignment":664,"../../constants/numerical":669,"../../lib":692,"../../lib/svg_text_utils":716,"../../plots/plots":804,"../../registry":823,"./autorange":739,"./axis_autotype":741,"./axis_ids":743,"./clean_ticks":745,"./layout_attributes":753,"./set_convert":759,"d3":148,"fast-isnumeric":214}],741:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -114221,7 +115891,10 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var BADNUM = _dereq_('../../constants/numerical').BADNUM; -module.exports = function autoType(array, calendar) { +module.exports = function autoType(array, calendar, opts) { + opts = opts || {}; + + if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory'; if(moreDates(array, calendar)) return 'date'; if(category(array)) return 'category'; if(linearOK(array)) return 'linear'; @@ -114289,7 +115962,14 @@ function category(a) { return curvecats > curvenums * 2; } -},{"../../constants/numerical":673,"../../lib":696,"fast-isnumeric":214}],746:[function(_dereq_,module,exports){ +// very-loose requirements for multicategory, +// trace modules that should never auto-type to multicategory +// should be declared with 'noMultiCategory' +function multiCategory(a) { + return Lib.isArrayOrTypedArray(a[0]) && Lib.isArrayOrTypedArray(a[1]); +} + +},{"../../constants/numerical":669,"../../lib":692,"fast-isnumeric":214}],742:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -114320,6 +116000,7 @@ var setConvert = _dereq_('./set_convert'); * outerTicks: boolean, should ticks default to outside? * showGrid: boolean, should gridlines be shown by default? * noHover: boolean, this axis doesn't support hover effects? + * noTickson: boolean, this axis doesn't support 'tickson' * data: the plot data, used to manage categories * bgColor: the plot background color, to calculate default gridline colors */ @@ -114360,8 +116041,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, // try to get default title from splom trace, fallback to graph-wide value var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter]; - coerce('title', dfltTitle); - Lib.coerceFont(coerce, 'titlefont', { + coerce('title.text', dfltTitle); + Lib.coerceFont(coerce, 'title.font', { family: font.family, size: Math.round(font.size * 1.2), color: dfltFontColor @@ -114381,10 +116062,29 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, if(options.automargin) coerce('automargin'); + var isMultiCategory = containerOut.type === 'multicategory'; + + if(!options.noTickson && + (containerOut.type === 'category' || isMultiCategory) && + (containerOut.ticks || containerOut.showgrid) + ) { + var ticksonDflt; + if(isMultiCategory) ticksonDflt = 'boundaries'; + coerce('tickson', ticksonDflt); + } + + if(isMultiCategory) { + var showDividers = coerce('showdividers'); + if(showDividers) { + coerce('dividercolor'); + coerce('dividerwidth'); + } + } + return containerOut; }; -},{"../../lib":696,"../../registry":827,"./category_order_defaults":748,"./layout_attributes":757,"./line_grid_defaults":759,"./set_convert":763,"./tick_label_defaults":764,"./tick_mark_defaults":765,"./tick_value_defaults":766}],747:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"./category_order_defaults":744,"./layout_attributes":753,"./line_grid_defaults":755,"./set_convert":759,"./tick_label_defaults":760,"./tick_mark_defaults":761,"./tick_value_defaults":762}],743:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -114502,7 +116202,7 @@ exports.idSort = function(id1, id2) { return +(id1.substr(1) || 1) - +(id2.substr(1) || 1); }; -},{"../../registry":827,"./constants":750}],748:[function(_dereq_,module,exports){ +},{"../../registry":823,"./constants":746}],744:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -114596,7 +116296,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],749:[function(_dereq_,module,exports){ +},{}],745:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -114685,7 +116385,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":673,"../../lib":696,"fast-isnumeric":214}],750:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"fast-isnumeric":214}],746:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -114767,7 +116467,7 @@ module.exports = { } }; -},{"../../lib/regex":712}],751:[function(_dereq_,module,exports){ +},{"../../lib/regex":708}],747:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -114921,7 +116621,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[scaleanchor] = 1; } -},{"../../lib":696,"./axis_ids":747}],752:[function(_dereq_,module,exports){ +},{"../../lib":692,"./axis_ids":743}],748:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -115063,7 +116763,6 @@ exports.enforce = function enforceAxisConstraints(gd) { var getPad = makePadFn(ax); updateDomain(ax, factor); - ax.setScale(); var m = Math.abs(ax._m); var extremes = concatExtremes(gd, ax); var minArray = extremes.min; @@ -115130,9 +116829,10 @@ function updateDomain(ax, factor) { center + (inputDomain[0] - center) / factor, center + (inputDomain[1] - center) / factor ]; + ax.setScale(); } -},{"../../constants/alignment":668,"../../constants/numerical":673,"./autorange":743,"./axis_ids":747,"./scale_zoom":761}],753:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../constants/numerical":669,"./autorange":739,"./axis_ids":743,"./scale_zoom":757}],749:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -115154,6 +116854,7 @@ var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Fx = _dereq_('../../components/fx'); +var Axes = _dereq_('./axes'); var setCursor = _dereq_('../../lib/setcursor'); var dragElement = _dereq_('../../components/dragelement'); var FROM_TL = _dereq_('../../constants/alignment').FROM_TL; @@ -115162,7 +116863,6 @@ var redrawReglTraces = _dereq_('../../plot_api/subroutines').redrawReglTraces; var Plots = _dereq_('../plots'); -var doTicksSingle = _dereq_('./axes').doTicksSingle; var getFromId = _dereq_('./axis_ids').getFromId; var prepSelect = _dereq_('./select').prepSelect; var clearSelect = _dereq_('./select').clearSelect; @@ -115406,7 +117106,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { .on('edit', function(text) { var v = ax.d2r(text); if(v !== undefined) { - Registry.call('relayout', gd, attrStr, v); + Registry.call('_guiRelayout', gd, attrStr, v); } }); } @@ -115651,6 +117351,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { return; } + // prevent axis drawing from monkeying with margins until we're done + gd._fullLayout._replotting = true; + if(xActive === 'ew' || yActive === 'ns') { if(xActive) dragAxList(xaxes, dx); if(yActive) dragAxList(yaxes, dy); @@ -115754,8 +117457,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { updates = {}; for(i = 0; i < activeAxIds.length; i++) { var axId = activeAxIds[i]; - doTicksSingle(gd, axId, true); var ax = getFromId(gd, axId); + Axes.drawOne(gd, ax, {skipTitle: true}); updates[ax._name + '.range[0]'] = ax.range[0]; updates[ax._name + '.range[1]'] = ax.range[1]; } @@ -115847,7 +117550,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, attrs); } // dragTail - finish a drag event with a redraw @@ -115861,7 +117564,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // accumulated MathJax promises - wait for them before we relayout. Lib.syncOrAsync([ Plots.previousPromises, - function() { Registry.call('relayout', gd, updates); } + function() { + gd._fullLayout._replotting = false; + Registry.call('_guiRelayout', gd, updates); + } ], gd); } @@ -116319,7 +118025,7 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../constants/alignment":668,"../../lib":696,"../../lib/clear_gl_canvases":680,"../../lib/setcursor":716,"../../lib/svg_text_utils":720,"../../plot_api/subroutines":735,"../../registry":827,"../plots":808,"./axes":744,"./axis_ids":747,"./constants":750,"./scale_zoom":761,"./select":762,"d3":148,"has-passive-events":394,"tinycolor2":514}],754:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../constants/alignment":664,"../../lib":692,"../../lib/clear_gl_canvases":677,"../../lib/setcursor":712,"../../lib/svg_text_utils":716,"../../plot_api/subroutines":731,"../../registry":823,"../plots":804,"./axes":740,"./axis_ids":743,"./constants":746,"./scale_zoom":757,"./select":758,"d3":148,"has-passive-events":394,"tinycolor2":513}],750:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -116487,7 +118193,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":592,"../../components/fx":612,"../../lib/setcursor":716,"./constants":750,"./dragbox":753,"d3":148}],755:[function(_dereq_,module,exports){ +},{"../../components/dragelement":587,"../../components/fx":608,"../../lib/setcursor":712,"./constants":746,"./dragbox":749,"d3":148}],751:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -116562,7 +118268,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":696,"../../registry":827}],756:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],752:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -116827,7 +118533,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback // layers that allow `cliponaxis: false` if(className !== 'scatterlayer' && className !== 'barlayer') { - Drawing.setClipUrl(sel, plotinfo.layerClipId); + Drawing.setClipUrl(sel, plotinfo.layerClipId, gd); } }); @@ -117185,7 +118891,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":595,"../../constants/xmlns_namespaces":674,"../../lib":696,"../../registry":827,"../get_data":781,"../plots":808,"./attributes":742,"./axis_ids":747,"./constants":750,"./graph_interact":754,"./layout_attributes":757,"./layout_defaults":758,"./transition_axes":767,"d3":148}],757:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../constants/xmlns_namespaces":670,"../../lib":692,"../../registry":823,"../get_data":777,"../plots":804,"./attributes":738,"./axis_ids":743,"./constants":746,"./graph_interact":750,"./layout_attributes":753,"./layout_defaults":754,"./transition_axes":763,"d3":148}],753:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -117229,23 +118935,33 @@ module.exports = { ].join(' ') }, title: { - valType: 'string', - role: 'info', - editType: 'ticks', - description: 'Sets the title of this axis.' + text: { + valType: 'string', + role: 'info', + editType: 'ticks', + description: [ + 'Sets the title of this axis.', + 'Note that before the existence of `title.text`, the title\'s', + 'contents used to be defined as the `title` attribute itself.', + 'This behavior has been deprecated.' + ].join(' ') + }, + font: fontAttrs({ + editType: 'ticks', + description: [ + 'Sets this axis\' title font.', + 'Note that the title\'s font used to be customized', + 'by the now deprecated `titlefont` attribute.' + ].join(' ') + }), + editType: 'ticks' }, - titlefont: fontAttrs({ - editType: 'ticks', - description: [ - 'Sets this axis\' title font.' - ].join(' ') - }), type: { valType: 'enumerated', // '-' means we haven't yet run autotype or couldn't find any data // it gets turned into linear in gd._fullLayout but not copied back // to gd.data like the others are. - values: ['-', 'linear', 'log', 'date', 'category'], + values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', role: 'info', editType: 'calc', @@ -117492,6 +119208,20 @@ module.exports = { 'the axis lines.' ].join(' ') }, + tickson: { + valType: 'enumerated', + values: ['labels', 'boundaries'], + role: 'info', + dflt: 'labels', + editType: 'ticks', + description: [ + 'Determines where ticks and grid lines are drawn with respect to their', + 'corresponding tick labels.', + 'Only has an effect for axes of `type` *category* or *multicategory*.', + 'When set to *boundaries*, ticks and grid lines are drawn half a category', + 'to the left/bottom of labels.' + ].join(' ') + }, mirror: { valType: 'enumerated', values: [true, 'ticks', false, 'all', 'allticks'], @@ -117830,6 +119560,40 @@ module.exports = { editType: 'ticks', description: 'Sets the width (in px) of the zero line.' }, + + showdividers: { + valType: 'boolean', + dflt: true, + role: 'style', + editType: 'ticks', + description: [ + 'Determines whether or not a dividers are drawn', + 'between the category levels of this axis.', + 'Only has an effect on *multicategory* axes.' + ].join(' ') + }, + dividercolor: { + valType: 'color', + dflt: colorAttrs.defaultLine, + role: 'style', + editType: 'ticks', + description: [ + 'Sets the color of the dividers', + 'Only has an effect on *multicategory* axes.' + ].join(' ') + }, + dividerwidth: { + valType: 'number', + dflt: 1, + role: 'style', + editType: 'ticks', + description: [ + 'Sets the width (in px) of the dividers', + 'Only has an effect on *multicategory* axes.' + ].join(' ') + }, + // TODO dividerlen: that would override "to label base" length? + // positioning attributes // anchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -117954,6 +119718,16 @@ module.exports = { 'Used with `categoryorder`.' ].join(' ') }, + uirevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in axis `range`,', + '`autorange`, and `title` if in `editable: true` configuration.', + 'Defaults to `layout.uirevision`.' + ].join(' ') + }, editType: 'calc', _deprecated: { @@ -117966,11 +119740,27 @@ module.exports = { 'Set `tickmode` to *auto* for old `autotick` *true* behavior.', 'Set `tickmode` to *linear* for `autotick` *false*.' ].join(' ') - } + }, + title: { + valType: 'string', + role: 'info', + editType: 'ticks', + description: [ + 'Value of `title` is no longer a simple *string* but a set of sub-attributes.', + 'To set the axis\' title, please use `title.text` now.' + ].join(' ') + }, + titlefont: fontAttrs({ + editType: 'ticks', + description: [ + 'Former `titlefont` is now the sub-attribute `font` of `title`.', + 'To customize title font properties, please use `title.font` now.' + ].join(' ') + }) } }; -},{"../../components/color/attributes":569,"../../components/drawing/attributes":594,"../../lib/extend":685,"../../plot_api/plot_template":734,"../font_attributes":771,"./constants":750}],758:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../components/drawing/attributes":589,"../../lib/extend":682,"../../plot_api/plot_template":730,"../font_attributes":767,"./constants":746}],754:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -118129,9 +119919,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; }); axLayoutOut._annIndices = []; axLayoutOut._shapeIndices = []; + axLayoutOut._subplotsWith = []; + axLayoutOut._counterAxes = []; // set up some private properties - axLayoutOut._name = axName; + axLayoutOut._name = axLayoutOut._attr = axName; var id = axLayoutOut._id = name2id(axName); var overlayableAxes = getOverlayableAxes(axLetter, axName); @@ -118149,6 +119941,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id] }; + coerce('uirevision', layoutOut.uirevision); + handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions); handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut); @@ -118210,11 +120004,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var anchoredAxis = layoutOut[id2name(axLayoutOut.anchor)]; - var fixedRangeDflt = ( - anchoredAxis && - anchoredAxis.rangeslider && - anchoredAxis.rangeslider.visible - ); + var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis); coerce('fixedrange', fixedRangeDflt); } @@ -118239,7 +120029,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } }; -},{"../../components/color":570,"../../lib":696,"../../plot_api/plot_template":734,"../../registry":827,"../layout_attributes":799,"./axis_defaults":746,"./axis_ids":747,"./constraint_defaults":751,"./layout_attributes":757,"./position_defaults":760,"./type_defaults":768}],759:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../plot_api/plot_template":730,"../../registry":823,"../layout_attributes":795,"./axis_defaults":742,"./axis_ids":743,"./constraint_defaults":747,"./layout_attributes":753,"./position_defaults":756,"./type_defaults":764}],755:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -118304,7 +120094,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":569,"../../lib":696,"tinycolor2":514}],760:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../lib":692,"tinycolor2":513}],756:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -118388,7 +120178,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":696,"fast-isnumeric":214}],761:[function(_dereq_,module,exports){ +},{"../../lib":692,"fast-isnumeric":214}],757:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -118416,7 +120206,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ]; }; -},{"../../constants/alignment":668}],762:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664}],758:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119085,13 +120875,22 @@ function isOnlyOnePointSelected(searchTraces) { function updateSelectedState(gd, searchTraces, eventData) { var i, searchInfo, cd, trace; + // before anything else, update preGUI if necessary + for(i = 0; i < searchTraces.length; i++) { + var fullInputTrace = searchTraces[i].cd[0].trace._fullInput; + var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid]; + if(tracePreGUI.selectedpoints === undefined) { + tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null; + } + } + if(eventData) { var pts = eventData.points || []; for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; - trace.selectedpoints = []; - trace._input.selectedpoints = []; + trace._input.selectedpoints = trace._fullInput.selectedpoints = []; + if(trace._fullInput !== trace) trace.selectedpoints = []; } for(i = 0; i < pts.length; i++) { @@ -119101,10 +120900,14 @@ function updateSelectedState(gd, searchTraces, eventData) { if(pt.pointIndices) { [].push.apply(data.selectedpoints, pt.pointIndices); - [].push.apply(fullData.selectedpoints, pt.pointIndices); + if(trace._fullInput !== trace) { + [].push.apply(fullData.selectedpoints, pt.pointIndices); + } } else { data.selectedpoints.push(pt.pointIndex); - fullData.selectedpoints.push(pt.pointIndex); + if(trace._fullInput !== trace) { + fullData.selectedpoints.push(pt.pointIndex); + } } } } @@ -119113,6 +120916,9 @@ function updateSelectedState(gd, searchTraces, eventData) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; delete trace._input.selectedpoints; + if(trace._fullInput !== trace) { + delete trace._fullInput.selectedpoints; + } } } @@ -119190,7 +120996,7 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":570,"../../components/fx":612,"../../components/fx/helpers":609,"../../lib/clear_gl_canvases":680,"../../lib/polygon":708,"../../lib/throttle":721,"../../plot_api/subroutines":735,"../../registry":827,"./axis_ids":747,"./constants":750,"polybooljs":456}],763:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../components/fx/helpers":604,"../../lib/clear_gl_canvases":677,"../../lib/polygon":704,"../../lib/throttle":717,"../../plot_api/subroutines":731,"../../registry":823,"./axis_ids":743,"./constants":746,"polybooljs":456}],759:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119223,6 +121029,10 @@ function fromLog(v) { return Math.pow(10, v); } +function isValidCategory(v) { + return v !== null && v !== undefined; +} + /** * Define the conversion functions for an axis data is used in 5 ways: * @@ -119316,7 +121126,7 @@ module.exports = function setConvert(ax, fullLayout) { * a disconnect between the array and the index returned */ function setCategoryIndex(v) { - if(v !== null && v !== undefined) { + if(isValidCategory(v)) { if(ax._categoriesMap === undefined) { ax._categoriesMap = {}; } @@ -119335,14 +121145,58 @@ module.exports = function setConvert(ax, fullLayout) { return BADNUM; } + function setMultiCategoryIndex(arrayIn, len) { + var arrayOut = new Array(len); + var i; + + // [ [arrayIn[0][i], arrayIn[1][i]], for i .. len ] + var tmp = new Array(len); + // [ [cnt, {$cat: index}], for j .. arrayIn.length ] + var seen = [[0, {}], [0, {}]]; + + if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) { + for(i = 0; i < len; i++) { + var v0 = arrayIn[0][i]; + var v1 = arrayIn[1][i]; + if(isValidCategory(v0) && isValidCategory(v1)) { + tmp[i] = [v0, v1]; + if(!(v0 in seen[0][1])) { + seen[0][1][v0] = seen[0][0]++; + } + if(!(v1 in seen[1][1])) { + seen[1][1][v1] = seen[1][0]++; + } + } + } + + tmp.sort(function(a, b) { + var ind0 = seen[0][1]; + var d = ind0[a[0]] - ind0[b[0]]; + if(d) return d; + + var ind1 = seen[1][1]; + return ind1[a[1]] - ind1[b[1]]; + }); + } + + for(i = 0; i < len; i++) { + arrayOut[i] = setCategoryIndex(tmp[i]); + } + + return arrayOut; + } + function getCategoryIndex(v) { - // d2l/d2c variant that that won't add categories but will also - // allow numbers to be mapped to the linearized axis positions if(ax._categoriesMap) { - var index = ax._categoriesMap[v]; - if(index !== undefined) return index; + return ax._categoriesMap[v]; } + } + function getCategoryPosition(v) { + // d2l/d2c variant that that won't add categories but will also + // allow numbers to be mapped to the linearized axis positions + var index = getCategoryIndex(v); + if(index !== undefined) return index; if(isNumeric(v)) return +v; } @@ -119428,15 +121282,15 @@ module.exports = function setConvert(ax, fullLayout) { ax.d2c = ax.d2l = setCategoryIndex; ax.r2d = ax.c2d = ax.l2d = getCategoryName; - ax.d2r = ax.d2l_noadd = getCategoryIndex; + ax.d2r = ax.d2l_noadd = getCategoryPosition; ax.r2c = function(v) { - var index = getCategoryIndex(v); + var index = getCategoryPosition(v); return index !== undefined ? index : ax.fraction2r(0.5); }; ax.l2r = ax.c2r = ensureNumber; - ax.r2l = getCategoryIndex; + ax.r2l = getCategoryPosition; ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; ax.p2d = function(px) { return getCategoryName(p2l(px)); }; @@ -119448,6 +121302,34 @@ module.exports = function setConvert(ax, fullLayout) { return ensureNumber(v); }; } + else if(ax.type === 'multicategory') { + // N.B. multicategory axes don't define d2c and d2l, + // as 'data-to-calcdata' conversion needs to take into + // account all data array items as in ax.makeCalcdata. + + ax.r2d = ax.c2d = ax.l2d = getCategoryName; + ax.d2r = ax.d2l_noadd = getCategoryPosition; + + ax.r2c = function(v) { + var index = getCategoryPosition(v); + return index !== undefined ? index : ax.fraction2r(0.5); + }; + + ax.r2c_just_indices = getCategoryIndex; + + ax.l2r = ax.c2r = ensureNumber; + ax.r2l = getCategoryPosition; + + ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; + ax.p2d = function(px) { return getCategoryName(p2l(px)); }; + ax.r2p = ax.d2p; + ax.p2r = p2l; + + ax.cleanPos = function(v) { + if(Array.isArray(v) || (typeof v === 'string' && v !== '')) return v; + return ensureNumber(v); + }; + } // find the range value at the specified (linear) fraction of the axis ax.fraction2r = function(v) { @@ -119541,11 +121423,6 @@ module.exports = function setConvert(ax, fullLayout) { ax.setScale = function(usePrivateRange) { var gs = fullLayout._size; - // TODO cleaner way to handle this case - if(!ax._categories) ax._categories = []; - // Add a map to optimize the performance of category collection - if(!ax._categoriesMap) ax._categoriesMap = {}; - // make sure we have a domain (pull it in from the axis // this one is overlaying if necessary) if(ax.overlaying) { @@ -119600,7 +121477,7 @@ module.exports = function setConvert(ax, fullLayout) { if(axLetter in trace) { arrayIn = trace[axLetter]; - len = trace._length || arrayIn.length; + len = trace._length || Lib.minRowLength(arrayIn); if(Lib.isTypedArray(arrayIn) && (axType === 'linear' || axType === 'log')) { if(len === arrayIn.length) { @@ -119610,6 +121487,10 @@ module.exports = function setConvert(ax, fullLayout) { } } + if(axType === 'multicategory') { + return setMultiCategoryIndex(arrayIn, len); + } + arrayOut = new Array(len); for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); @@ -119686,7 +121567,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":673,"../../lib":696,"./axis_ids":747,"./constants":750,"d3":148,"fast-isnumeric":214}],764:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"./axis_ids":743,"./constants":746,"d3":148,"fast-isnumeric":214}],760:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119787,7 +121668,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../lib":696,"../array_container_defaults":740,"./layout_attributes":757}],765:[function(_dereq_,module,exports){ +},{"../../lib":692,"../array_container_defaults":736,"./layout_attributes":753}],761:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119820,7 +121701,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":696,"./layout_attributes":757}],766:[function(_dereq_,module,exports){ +},{"../../lib":692,"./layout_attributes":753}],762:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119829,22 +121710,18 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); - module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { var tickmode; if(containerIn.tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; - } - else { - var tickmodeDefault = - Array.isArray(containerIn.tickvals) ? 'array' : + } else { + var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : containerIn.dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); @@ -119859,15 +121736,14 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe containerIn.dtick, axType); containerOut.tick0 = cleanTicks.tick0( containerIn.tick0, axType, containerOut.calendar, dtick); - } - else { + } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto'; else coerce('ticktext'); } }; -},{"./clean_ticks":749}],767:[function(_dereq_,module,exports){ +},{"./clean_ticks":745}],763:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119989,14 +121865,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo } function ticksAndAnnotations(xa, ya) { - var activeAxIds = [], - i; - - activeAxIds = [xa._id, ya._id]; + var activeAxIds = [xa._id, ya._id]; + var i; - for(i = 0; i < activeAxIds.length; i++) { - Axes.doTicksSingle(gd, activeAxIds[i], true); - } + Axes.drawOne(gd, xa, {skipTitle: true}); + Axes.drawOne(gd, ya, {skipTitle: true}); function redrawObjs(objArray, method, shortCircuit) { for(i = 0; i < objArray.length; i++) { @@ -120195,7 +122068,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo return Promise.resolve(); }; -},{"../../components/drawing":595,"../../registry":827,"./axes":744,"./constants":750,"d3":148}],768:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../registry":823,"./axes":740,"./constants":746,"d3":148}],764:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -120206,7 +122079,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo 'use strict'; -var Registry = _dereq_('../../registry'); +var traceIs = _dereq_('../../registry').traceIs; var autoType = _dereq_('./axis_autotype'); /* @@ -120255,6 +122128,7 @@ function setAutoType(ax, data) { var calAttr = axLetter + 'calendar'; var calendar = d0[calAttr]; + var opts = {noMultiCategory: !traceIs(d0, 'cartesian') || traceIs(d0, 'noMultiCategory')}; var i; // check all boxes on this x axis to see @@ -120265,8 +122139,7 @@ function setAutoType(ax, data) { for(i = 0; i < data.length; i++) { var trace = data[i]; - if(!Registry.traceIs(trace, 'box-violin') || - (trace[axLetter + 'axis'] || axLetter) !== id) continue; + if(!traceIs(trace, 'box-violin') || (trace[axLetter + 'axis'] || axLetter) !== id) continue; if(trace[posLetter] !== undefined) boxPositions.push(trace[posLetter][0]); else if(trace.name !== undefined) boxPositions.push(trace.name); @@ -120275,7 +122148,7 @@ function setAutoType(ax, data) { if(trace[calAttr] !== calendar) calendar = undefined; } - ax.type = autoType(boxPositions, calendar); + ax.type = autoType(boxPositions, calendar, opts); } else if(d0.type === 'splom') { var dimensions = d0.dimensions; @@ -120283,13 +122156,13 @@ function setAutoType(ax, data) { for(i = 0; i < dimensions.length; i++) { var dim = dimensions[i]; if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) { - ax.type = autoType(dim.values, calendar); + ax.type = autoType(dim.values, calendar, opts); break; } } } else { - ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar); + ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -120320,9 +122193,9 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace), - isBox = Registry.traceIs(trace, 'box-violin'), - isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); + var posLetter = getBoxPosLetter(trace); + var isBox = traceIs(trace, 'box-violin'); + var isCandlestick = traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox && @@ -120333,7 +122206,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":827,"./axis_autotype":745}],769:[function(_dereq_,module,exports){ +},{"../../registry":823,"./axis_autotype":741}],765:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -120757,7 +122630,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":696,"../registry":827}],770:[function(_dereq_,module,exports){ +},{"../lib":692,"../registry":823}],766:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -120891,7 +122764,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { coerce('domain.y', dfltY); }; -},{"../lib/extend":685}],771:[function(_dereq_,module,exports){ +},{"../lib/extend":682}],767:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -120967,7 +122840,7 @@ module.exports = function(opts) { return attrs; }; -},{}],772:[function(_dereq_,module,exports){ +},{}],768:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -121029,7 +122902,7 @@ module.exports = { } }; -},{}],773:[function(_dereq_,module,exports){ +},{}],769:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -121204,7 +123077,7 @@ exports.layerNameToAdjective = { frame: 'frame' }; -},{}],774:[function(_dereq_,module,exports){ +},{}],770:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -121574,7 +123447,7 @@ proto.updateFx = function(fullLayout, geoLayout) { updateObj[_this.id + '.' + k] = viewInitial[k]; } - Registry.call('relayout', gd, updateObj); + Registry.call('_guiRelayout', gd, updateObj); gd.emit('plotly_doubleclick', null); } @@ -121677,7 +123550,8 @@ proto.updateFx = function(fullLayout, geoLayout) { proto.makeFramework = function() { var _this = this; - var fullLayout = _this.graphDiv._fullLayout; + var gd = _this.graphDiv; + var fullLayout = gd._fullLayout; var clipId = 'clip' + fullLayout._uid + _this.id; _this.clipDef = fullLayout._clips.append('clipPath') @@ -121687,7 +123561,7 @@ proto.makeFramework = function() { _this.framework = d3.select(_this.container).append('g') .attr('class', 'geo ' + _this.id) - .call(Drawing.setClipUrl, clipId); + .call(Drawing.setClipUrl, clipId, gd); // sane lonlat to px _this.project = function(v) { @@ -121913,7 +123787,7 @@ function makeRangeBox(lon, lat) { }; } -},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../lib":696,"../../lib/topojson_utils":723,"../../registry":827,"../cartesian/axes":744,"../cartesian/select":762,"../plots":808,"./constants":773,"./projections":779,"./zoom":780,"d3":148,"topojson-client":517}],775:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../lib":692,"../../lib/topojson_utils":719,"../../registry":823,"../cartesian/axes":740,"../cartesian/select":758,"../plots":804,"./constants":769,"./projections":775,"./zoom":776,"d3":148,"topojson-client":516}],771:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122005,7 +123879,7 @@ exports.updateFx = function(gd) { } }; -},{"../../lib":696,"../../plots/get_data":781,"./geo":774,"./layout/attributes":776,"./layout/defaults":777,"./layout/layout_attributes":778}],776:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/get_data":777,"./geo":770,"./layout/attributes":772,"./layout/defaults":773,"./layout/layout_attributes":774}],772:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122034,7 +123908,7 @@ module.exports = { } }; -},{}],777:[function(_dereq_,module,exports){ +},{}],773:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122198,7 +124072,7 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce) { coerce('bgcolor'); } -},{"../../subplot_defaults":822,"../constants":773,"./layout_attributes":778}],778:[function(_dereq_,module,exports){ +},{"../../subplot_defaults":818,"../constants":769,"./layout_attributes":774}],774:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122266,7 +124140,7 @@ var geoAxesAttrs = { } }; -module.exports = overrideAll({ +var attrs = module.exports = overrideAll({ domain: domainAttrs({name: 'geo'}, { description: [ 'Note that geo subplots are constrained by domain.', @@ -122513,7 +124387,18 @@ module.exports = overrideAll({ lataxis: geoAxesAttrs }, 'plot', 'from-root'); -},{"../../../components/color/attributes":569,"../../../plot_api/edit_types":727,"../../domain":770,"../constants":773}],779:[function(_dereq_,module,exports){ +// set uirevision outside of overrideAll so it can be `editType: 'none'` +attrs.uirevision = { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in the view', + '(projection and center). Defaults to `layout.uirevision`.' + ].join(' ') +}; + +},{"../../../components/color/attributes":568,"../../../plot_api/edit_types":723,"../../domain":766,"../constants":769}],775:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122959,7 +124844,7 @@ function addProjectionsToD3(d3) { module.exports = addProjectionsToD3; -},{}],780:[function(_dereq_,module,exports){ +},{}],776:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122973,6 +124858,7 @@ module.exports = addProjectionsToD3; var d3 = _dereq_('d3'); var Lib = _dereq_('../../lib'); +var Registry = _dereq_('../../registry'); var radians = Math.PI / 180; var degrees = 180 / Math.PI; @@ -123009,8 +124895,10 @@ function initZoom(geo, projection) { function sync(geo, projection, cb) { var id = geo.id; var gd = geo.graphDiv; - var userOpts = gd.layout[id]; - var fullOpts = gd._fullLayout[id]; + var layout = gd.layout; + var userOpts = layout[id]; + var fullLayout = gd._fullLayout; + var fullOpts = fullLayout[id]; var eventData = {}; @@ -123026,6 +124914,7 @@ function sync(geo, projection, cb) { cb(set); set('projection.scale', projection.scale() / geo.fitScale); + Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, eventData); gd.emit('plotly_relayout', eventData); } @@ -123433,7 +125322,7 @@ function d3_eventDispatch(target) { return dispatch; } -},{"../../lib":696,"d3":148}],781:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"d3":148}],777:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -123561,7 +125450,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":827,"./cartesian/constants":750}],782:[function(_dereq_,module,exports){ +},{"../registry":823,"./cartesian/constants":746}],778:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -123863,7 +125752,7 @@ function createCamera(scene) { return result; } -},{"../cartesian/constants":750,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421}],783:[function(_dereq_,module,exports){ +},{"../cartesian/constants":746,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421}],779:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -123877,7 +125766,6 @@ function createCamera(scene) { var Axes = _dereq_('../cartesian/axes'); -var convertHTMLToUnicode = _dereq_('../../lib/html2unicode'); var str2RGBArray = _dereq_('../../lib/str2rgbarray'); function Axes2DOptions(scene) { @@ -123980,14 +125868,14 @@ proto.merge = function(options) { // '_name' is e.g. xaxis, xaxis2, yaxis, yaxis4 ... ax = options[this.scene[axisName]._name]; - axTitle = ax.title === this.scene.fullLayout._dfltTitle[axisLetter] ? '' : ax.title; + axTitle = ax.title.text === this.scene.fullLayout._dfltTitle[axisLetter] ? '' : ax.title.text; for(j = 0; j <= 2; j += 2) { this.labelEnable[i + j] = false; - this.labels[i + j] = convertHTMLToUnicode(axTitle); - this.labelColor[i + j] = str2RGBArray(ax.titlefont.color); - this.labelFont[i + j] = ax.titlefont.family; - this.labelSize[i + j] = ax.titlefont.size; + this.labels[i + j] = axTitle; + this.labelColor[i + j] = str2RGBArray(ax.title.font.color); + this.labelFont[i + j] = ax.title.font.family; + this.labelSize[i + j] = ax.title.font.size; this.labelPad[i + j] = this.getLabelPad(axisName, ax); this.tickEnable[i + j] = false; @@ -124075,7 +125963,7 @@ proto.hasAxisInAltrPos = function(axisName, ax) { proto.getLabelPad = function(axisName, ax) { var offsetBase = 1.5, - fontSize = ax.titlefont.size, + fontSize = ax.title.font.size, showticklabels = ax.showticklabels; if(axisName === 'xaxis') { @@ -124109,7 +125997,7 @@ function createAxes2D(scene) { module.exports = createAxes2D; -},{"../../lib/html2unicode":694,"../../lib/str2rgbarray":719,"../cartesian/axes":744}],784:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":715,"../cartesian/axes":740}],780:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124260,7 +126148,7 @@ exports.updateFx = function(gd) { } }; -},{"../../components/fx/layout_attributes":613,"../../constants/xmlns_namespaces":674,"../../plot_api/edit_types":727,"../cartesian":756,"../cartesian/attributes":742,"../cartesian/constants":750,"../get_data":781,"../layout_attributes":799,"./scene2d":785}],785:[function(_dereq_,module,exports){ +},{"../../components/fx/layout_attributes":609,"../../constants/xmlns_namespaces":670,"../../plot_api/edit_types":723,"../cartesian":752,"../cartesian/attributes":738,"../cartesian/constants":746,"../get_data":777,"../layout_attributes":795,"./scene2d":781}],781:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124283,7 +126171,6 @@ var getContext = _dereq_('webgl-context'); var createOptions = _dereq_('./convert'); var createCamera = _dereq_('./camera'); -var convertHTMLToUnicode = _dereq_('../../lib/html2unicode'); var showNoWebGlMsg = _dereq_('../../lib/show_no_webgl_msg'); var axisConstraints = _dereq_('../cartesian/constraints'); var enforceAxisConstraints = axisConstraints.enforce; @@ -124542,7 +126429,7 @@ proto.computeTickMarks = function() { for(var j = 0; j < 2; ++j) { for(var i = 0; i < nextTicks[j].length; ++i) { // coercing tick value (may not be a string) to a string - nextTicks[j][i].text = convertHTMLToUnicode(nextTicks[j][i].text + ''); + nextTicks[j][i].text = nextTicks[j][i].text + ''; } } @@ -124576,27 +126463,31 @@ proto.updateRefs = function(newFullLayout) { }; proto.relayoutCallback = function() { - var graphDiv = this.graphDiv, - xaxis = this.xaxis, - yaxis = this.yaxis, - layout = graphDiv.layout; + var graphDiv = this.graphDiv; + var xaxis = this.xaxis; + var yaxis = this.yaxis; + var layout = graphDiv.layout; - // update user layout - layout.xaxis.autorange = xaxis.autorange; - layout.xaxis.range = xaxis.range.slice(0); - layout.yaxis.autorange = yaxis.autorange; - layout.yaxis.range = yaxis.range.slice(0); + // make a meaningful value to be passed on to possible 'plotly_relayout' subscriber(s) + var update = {}; + var xrange = update[xaxis._name + '.range'] = xaxis.range.slice(); + var yrange = update[yaxis._name + '.range'] = yaxis.range.slice(); + update[xaxis._name + '.autorange'] = xaxis.autorange; + update[yaxis._name + '.autorange'] = yaxis.autorange; - // make a meaningful value to be passed on to the possible 'plotly_relayout' subscriber(s) - // scene.camera has no many useful projection or scale information - // helps determine which one is the latest input (if async) - var update = { - lastInputTime: this.camera.lastInputTime - }; + Registry.call('_storeDirectGUIEdit', graphDiv.layout, graphDiv._fullLayout._preGUI, update); - update[xaxis._name] = xaxis.range.slice(0); - update[yaxis._name] = yaxis.range.slice(0); + // update the input layout + var xaIn = layout[xaxis._name]; + xaIn.range = xrange; + xaIn.autorange = xaxis.autorange; + var yaIn = layout[yaxis._name]; + yaIn.range = yrange; + yaIn.autorange = yaxis.autorange; + + // lastInputTime helps determine which one is the latest input (if async) + update.lastInputTime = this.camera.lastInputTime; graphDiv.emit('plotly_relayout', update); }; @@ -124982,7 +126873,7 @@ proto.hoverFormatter = function(axisName, val) { return Axes.tickText(axis, axis.c2l(val), 'hover').text; }; -},{"../../components/fx":612,"../../lib/html2unicode":694,"../../lib/show_no_webgl_msg":717,"../../plots/cartesian/axes":744,"../../registry":827,"../cartesian/autorange":743,"../cartesian/constants":750,"../cartesian/constraints":752,"./camera":782,"./convert":783,"gl-plot2d":275,"gl-select-box":286,"gl-spikes2d":295,"webgl-context":533}],786:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../lib/show_no_webgl_msg":713,"../../plots/cartesian/axes":740,"../../registry":823,"../cartesian/autorange":739,"../cartesian/constants":746,"../cartesian/constraints":748,"./camera":778,"./convert":779,"gl-plot2d":275,"gl-select-box":286,"gl-spikes2d":295,"webgl-context":532}],782:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125256,7 +127147,7 @@ function createCamera(element, options) { return camera; } -},{"3d-view":45,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421,"right-now":480}],787:[function(_dereq_,module,exports){ +},{"3d-view":45,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421,"right-now":480}],783:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125398,7 +127289,7 @@ exports.updateFx = function(gd) { } }; -},{"../../components/fx/layout_attributes":613,"../../constants/xmlns_namespaces":674,"../../lib":696,"../../plot_api/edit_types":727,"../get_data":781,"./layout/attributes":788,"./layout/defaults":792,"./layout/layout_attributes":793,"./scene":797}],788:[function(_dereq_,module,exports){ +},{"../../components/fx/layout_attributes":609,"../../constants/xmlns_namespaces":670,"../../lib":692,"../../plot_api/edit_types":723,"../get_data":777,"./layout/attributes":784,"./layout/defaults":788,"./layout/layout_attributes":789,"./scene":793}],784:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125427,7 +127318,7 @@ module.exports = { } }; -},{}],789:[function(_dereq_,module,exports){ +},{}],785:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125443,7 +127334,6 @@ var axesAttrs = _dereq_('../../cartesian/layout_attributes'); var extendFlat = _dereq_('../../../lib/extend').extendFlat; var overrideAll = _dereq_('../../../plot_api/edit_types').overrideAll; - module.exports = overrideAll({ visible: axesAttrs.visible, showspikes: { @@ -125503,8 +127393,9 @@ module.exports = overrideAll({ categoryorder: axesAttrs.categoryorder, categoryarray: axesAttrs.categoryarray, title: axesAttrs.title, - titlefont: axesAttrs.titlefont, - type: axesAttrs.type, + type: extendFlat({}, axesAttrs.type, { + values: ['-', 'linear', 'log', 'date', 'category'] + }), autorange: axesAttrs.autorange, rangemode: axesAttrs.rangemode, range: axesAttrs.range, @@ -125543,10 +127434,14 @@ module.exports = overrideAll({ gridwidth: axesAttrs.gridwidth, zeroline: axesAttrs.zeroline, zerolinecolor: axesAttrs.zerolinecolor, - zerolinewidth: axesAttrs.zerolinewidth + zerolinewidth: axesAttrs.zerolinewidth, + _deprecated: { + title: axesAttrs._deprecated.title, + titlefont: axesAttrs._deprecated.titlefont + } }, 'plot', 'from-root'); -},{"../../../components/color":570,"../../../lib/extend":685,"../../../plot_api/edit_types":727,"../../cartesian/layout_attributes":757}],790:[function(_dereq_,module,exports){ +},{"../../../components/color":569,"../../../lib/extend":682,"../../../plot_api/edit_types":723,"../../cartesian/layout_attributes":753}],786:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125599,13 +127494,14 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) { letter: axName[0], data: options.data, showGrid: true, + noTickson: true, bgColor: options.bgColor, calendar: options.calendar }, options.fullLayout); coerce('gridcolor', colorMix(containerOut.color, options.bgColor, gridLightness).toRgbString()); - coerce('title', axName[0]); // shouldn't this be on-par with 2D? + coerce('title.text', axName[0]); // shouldn't this be on-par with 2D? containerOut.setScale = Lib.noop; @@ -125620,7 +127516,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) { } }; -},{"../../../lib":696,"../../../plot_api/plot_template":734,"../../cartesian/axis_defaults":746,"../../cartesian/type_defaults":768,"./axis_attributes":789,"tinycolor2":514}],791:[function(_dereq_,module,exports){ +},{"../../../lib":692,"../../../plot_api/plot_template":730,"../../cartesian/axis_defaults":742,"../../cartesian/type_defaults":764,"./axis_attributes":785,"tinycolor2":513}],787:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125632,7 +127528,6 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) { 'use strict'; -var convertHTMLToUnicode = _dereq_('../../../lib/html2unicode'); var str2RgbaArray = _dereq_('../../../lib/str2rgbarray'); var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis']; @@ -125707,11 +127602,11 @@ proto.merge = function(sceneLayout) { } // Axes labels - opts.labels[i] = convertHTMLToUnicode(axes.title); - if('titlefont' in axes) { - if(axes.titlefont.color) opts.labelColor[i] = str2RgbaArray(axes.titlefont.color); - if(axes.titlefont.family) opts.labelFont[i] = axes.titlefont.family; - if(axes.titlefont.size) opts.labelSize[i] = axes.titlefont.size; + opts.labels[i] = axes.title.text; + if('font' in axes.title) { + if(axes.title.font.color) opts.labelColor[i] = str2RgbaArray(axes.title.font.color); + if(axes.title.font.family) opts.labelFont[i] = axes.title.font.family; + if(axes.title.font.size) opts.labelSize[i] = axes.title.font.size; } // Lines @@ -125783,7 +127678,7 @@ function createAxesOptions(plotlyOptions) { module.exports = createAxesOptions; -},{"../../../lib/html2unicode":694,"../../../lib/str2rgbarray":719}],792:[function(_dereq_,module,exports){ +},{"../../../lib/str2rgbarray":715}],788:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125896,11 +127791,36 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) { sceneLayoutIn, sceneLayoutOut, opts ); - coerce('dragmode', opts.getDfltFromLayout('dragmode')); + var dragmode = opts.getDfltFromLayout('dragmode'); + + if(dragmode !== false) { + if(!dragmode) { + + dragmode = 'orbit'; + + if(sceneLayoutIn.camera && + sceneLayoutIn.camera.up) { + + var x = sceneLayoutIn.camera.up.x; + var y = sceneLayoutIn.camera.up.y; + var z = sceneLayoutIn.camera.up.z; + + if(!x || !y || !z) { + dragmode = 'turntable'; + } else if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) { + dragmode = 'turntable'; + } + } else { + dragmode = 'turntable'; + } + } + } + + coerce('dragmode', dragmode); coerce('hovermode', opts.getDfltFromLayout('hovermode')); } -},{"../../../components/color":570,"../../../lib":696,"../../../registry":827,"../../subplot_defaults":822,"./axis_defaults":790,"./layout_attributes":793}],793:[function(_dereq_,module,exports){ +},{"../../../components/color":569,"../../../lib":692,"../../../registry":823,"../../subplot_defaults":818,"./axis_defaults":786,"./layout_attributes":789}],789:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126043,7 +127963,6 @@ module.exports = { valType: 'enumerated', role: 'info', values: ['orbit', 'turntable', 'zoom', 'pan', false], - dflt: 'turntable', editType: 'plot', description: [ 'Determines the mode of drag interactions for this scene.' @@ -126059,6 +127978,15 @@ module.exports = { 'Determines the mode of hover interactions for this scene.' ].join(' ') }, + uirevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in camera attributes.', + 'Defaults to `layout.uirevision`.' + ].join(' ') + }, editType: 'plot', _deprecated: { @@ -126071,7 +127999,7 @@ module.exports = { } }; -},{"../../../lib":696,"../../../lib/extend":685,"../../domain":770,"./axis_attributes":789}],794:[function(_dereq_,module,exports){ +},{"../../../lib":692,"../../../lib/extend":682,"../../domain":766,"./axis_attributes":785}],790:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126123,7 +128051,7 @@ function createSpikeOptions(layout) { module.exports = createSpikeOptions; -},{"../../../lib/str2rgbarray":719}],795:[function(_dereq_,module,exports){ +},{"../../../lib/str2rgbarray":715}],791:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126141,7 +128069,6 @@ module.exports = computeTickMarks; var Axes = _dereq_('../../cartesian/axes'); var Lib = _dereq_('../../../lib'); -var convertHTMLToUnicode = _dereq_('../../../lib/html2unicode'); var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis']; @@ -126173,7 +128100,8 @@ function computeTickMarks(scene) { axes._length = (glRange[i].hi - glRange[i].lo) * glRange[i].pixelsPerDataUnit / scene.dataScale[i]; - if(Math.abs(axes._length) === Infinity) { + if(Math.abs(axes._length) === Infinity || + isNaN(axes._length)) { ticks[i] = []; } else { axes._input_range = axes.range.slice(); @@ -126198,7 +128126,11 @@ function computeTickMarks(scene) { var dataTicks = Axes.calcTicks(axes); for(var j = 0; j < dataTicks.length; ++j) { dataTicks[j].x = dataTicks[j].x * scene.dataScale[i]; - dataTicks[j].text = convertHTMLToUnicode(dataTicks[j].text); + + if(axes.type === 'date') { + dataTicks[j].text = + dataTicks[j].text.replace(/\/g, ' '); + } } ticks[i] = dataTicks; @@ -126220,7 +128152,7 @@ function computeTickMarks(scene) { scene.contourLevels = contourLevelsFromTicks(ticks); } -},{"../../../lib":696,"../../../lib/html2unicode":694,"../../cartesian/axes":744}],796:[function(_dereq_,module,exports){ +},{"../../../lib":692,"../../cartesian/axes":740}],792:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126254,7 +128186,7 @@ function project(camera, v) { module.exports = project; -},{}],797:[function(_dereq_,module,exports){ +},{}],793:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126426,7 +128358,7 @@ function render(scene) { scene.drawAnnotations(scene); } -function initializeGLPlot(scene, fullLayout, canvas, gl) { +function initializeGLPlot(scene, canvas, gl) { var gd = scene.graphDiv; var glplotOptions = { @@ -126575,7 +128507,7 @@ function Scene(options, fullLayout) { this.convertAnnotations = Registry.getComponentMethod('annotations3d', 'convert'); this.drawAnnotations = Registry.getComponentMethod('annotations3d', 'draw'); - if(!initializeGLPlot(this, fullLayout)) return; // todo check the necessity for this line + if(!initializeGLPlot(this)) return; // todo check the necessity for this line } var proto = Scene.prototype; @@ -126591,7 +128523,7 @@ proto.recoverContext = function() { requestAnimationFrame(tryRecover); return; } - if(!initializeGLPlot(scene, scene.fullLayout, canvas, gl)) { + if(!initializeGLPlot(scene, canvas, gl)) { Lib.error('Catastrophic and unrecoverable WebGL error. Context lost.'); return; } @@ -126958,10 +128890,10 @@ proto.setCamera = function setCamera(cameraData) { // save camera to user layout (i.e. gd.layout) proto.saveCamera = function saveCamera(layout) { - var cameraData = this.getCamera(), - cameraNestedProp = Lib.nestedProperty(layout, this.id + '.camera'), - cameraDataLastSave = cameraNestedProp.get(), - hasChanged = false; + var cameraData = this.getCamera(); + var cameraNestedProp = Lib.nestedProperty(layout, this.id + '.camera'); + var cameraDataLastSave = cameraNestedProp.get(); + var hasChanged = false; function same(x, y, i, j) { var vectors = ['up', 'center', 'eye'], @@ -126981,7 +128913,14 @@ proto.saveCamera = function saveCamera(layout) { } } - if(hasChanged) cameraNestedProp.set(cameraData); + if(hasChanged) { + cameraNestedProp.set(cameraData); + + var fullLayout = this.fullLayout; + var cameraFullNP = Lib.nestedProperty(fullLayout, this.id + '.camera'); + cameraFullNP.set(cameraData); + Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, cameraData); + } return hasChanged; }; @@ -127000,6 +128939,26 @@ proto.updateFx = function(dragmode, hovermode) { camera.mode = 'turntable'; camera.keyBindingMode = 'rotate'; + // The setter for camera.mode animates the transition to z-up, + // but only if we *don't* explicitly set z-up earlier via the + // relayout. So push `up` back to layout & fullLayout manually now. + var gd = this.graphDiv; + var fullLayout = gd._fullLayout; + var fullCamera = this.fullSceneLayout.camera; + var x = fullCamera.up.x; + var y = fullCamera.up.y; + var z = fullCamera.up.z; + // only push `up` back to (full)layout if it's going to change + if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) return; + + var attr = this.id + '.camera.up'; + var zUp = {x: 0, y: 0, z: 1}; + var edits = {}; + edits[attr] = zUp; + var layout = gd.layout; + Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, edits); + fullCamera.up = zUp; + Lib.nestedProperty(layout, attr).set(zUp); } else { // none rotation modes [pan or zoom] @@ -127076,7 +129035,7 @@ proto.setConvert = function() { module.exports = Scene; -},{"../../components/fx":612,"../../lib":696,"../../lib/show_no_webgl_msg":717,"../../lib/str2rgbarray":719,"../../plots/cartesian/axes":744,"../../registry":827,"./camera":786,"./layout/convert":791,"./layout/spikes":794,"./layout/tick_marks":795,"./project":796,"gl-plot3d":277,"has-passive-events":394,"webgl-context":533}],798:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../lib":692,"../../lib/show_no_webgl_msg":713,"../../lib/str2rgbarray":715,"../../plots/cartesian/axes":740,"../../registry":823,"./camera":782,"./layout/convert":787,"./layout/spikes":790,"./layout/tick_marks":791,"./project":792,"gl-plot3d":277,"has-passive-events":394,"webgl-context":532}],794:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -127097,7 +129056,7 @@ module.exports = function zip3(x, y, z, len) { return result; }; -},{}],799:[function(_dereq_,module,exports){ +},{}],795:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -127110,6 +129069,9 @@ module.exports = function zip3(x, y, z, len) { var fontAttrs = _dereq_('./font_attributes'); var colorAttrs = _dereq_('../components/color/attributes'); +var colorscaleAttrs = _dereq_('../components/colorscale/layout_attributes'); +var padAttrs = _dereq_('./pad_attributes'); +var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', @@ -127126,17 +129088,117 @@ globalFont.color.dflt = colorAttrs.defaultLine; module.exports = { font: globalFont, title: { - valType: 'string', - role: 'info', - editType: 'layoutstyle', - description: [ - 'Sets the plot\'s title.' - ].join(' ') + text: { + valType: 'string', + role: 'info', + editType: 'layoutstyle', + description: [ + 'Sets the plot\'s title.', + 'Note that before the existence of `title.text`, the title\'s', + 'contents used to be defined as the `title` attribute itself.', + 'This behavior has been deprecated.' + ].join(' ') + }, + font: fontAttrs({ + editType: 'layoutstyle', + description: [ + 'Sets the title font.', + 'Note that the title\'s font used to be customized', + 'by the now deprecated `titlefont` attribute.' + ].join(' ') + }), + xref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + role: 'info', + editType: 'layoutstyle', + description: [ + 'Sets the container `x` refers to.', + '*container* spans the entire `width` of the plot.', + '*paper* refers to the width of the plotting area only.' + ].join(' ') + }, + yref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + role: 'info', + editType: 'layoutstyle', + description: [ + 'Sets the container `y` refers to.', + '*container* spans the entire `height` of the plot.', + '*paper* refers to the height of the plotting area only.' + ].join(' ') + }, + x: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.5, + role: 'style', + editType: 'layoutstyle', + description: [ + 'Sets the x position with respect to `xref` in normalized', + 'coordinates from *0* (left) to *1* (right).' + ].join(' ') + }, + y: { + valType: 'number', + min: 0, + max: 1, + dflt: 'auto', + role: 'style', + editType: 'layoutstyle', + description: [ + 'Sets the y position with respect to `yref` in normalized', + 'coordinates from *0* (bottom) to *1* (top).', + '*auto* places the baseline of the title onto the', + 'vertical center of the top margin.' + ].join(' ') + }, + xanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'left', 'center', 'right'], + role: 'info', + editType: 'layoutstyle', + description: [ + 'Sets the title\'s horizontal alignment with respect to its x position.', + '*left* means that the title starts at x,', + '*right* means that the title ends at x', + 'and *center* means that the title\'s center is at x.', + '*auto* divides `xref` by three and calculates the `xanchor`', + 'value automatically based on the value of `x`.' + ].join(' ') + }, + yanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'top', 'middle', 'bottom'], + role: 'info', + editType: 'layoutstyle', + description: [ + 'Sets the title\'s vertical alignment with respect to its y position.', + '*top* means that the title\'s cap line is at y,', + '*bottom* means that the title\'s baseline is at y', + 'and *middle* means that the title\'s midline is at y.', + '*auto* divides `yref` by three and calculates the `yanchor`', + 'value automatically based on the value of `y`.' + ].join(' ') + }, + pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { + description: [ + 'Sets the padding of the title.', + 'Each padding value only applies when the corresponding', + '`xanchor`/`yanchor` value is set accordingly. E.g. for left', + 'padding to take effect, `xanchor` must be set to *left*.', + 'The same rule applies if `xanchor`/`yanchor` is determined automatically.', + 'Padding is muted if the respective anchor value is *middle*/*center*.' + ].join(' ') + }), + editType: 'layoutstyle' }, - titlefont: fontAttrs({ - editType: 'layoutstyle', - description: 'Sets the title font.' - }), autosize: { valType: 'boolean', role: 'info', @@ -127288,6 +129350,7 @@ module.exports = { editType: 'calc', description: 'Sets the default trace colors.' }, + colorscale: colorscaleAttrs, datarevision: { valType: 'any', role: 'info', @@ -127302,6 +129365,47 @@ module.exports = { 'different identity from its predecessor contains new data.' ].join(' ') }, + uirevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Used to allow user interactions with the plot to persist after', + '`Plotly.react` calls that are unaware of these interactions.', + 'If `uirevision` is omitted, or if it is given and it changed from', + 'the previous `Plotly.react` call, the exact new figure is used.', + 'If `uirevision` is truthy and did NOT change, any attribute', + 'that has been affected by user interactions and did not receive a', + 'different value in the new figure will keep the interaction value.', + '`layout.uirevision` attribute serves as the default for', + '`uirevision` attributes in various sub-containers. For finer', + 'control you can set these sub-attributes directly. For example,', + 'if your app separately controls the data on the x and y axes you', + 'might set `xaxis.uirevision=*time*` and `yaxis.uirevision=*cost*`.', + 'Then if only the y data is changed, you can update', + '`yaxis.uirevision=*quantity*` and the y axis range will reset but', + 'the x axis range will retain any user-driven zoom.' + ].join(' ') + }, + editrevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in `editable: true`', + 'configuration, other than trace names and axis titles.', + 'Defaults to `layout.uirevision`.' + ].join(' ') + }, + selectionrevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in selected points', + 'from all traces.' + ].join(' ') + }, template: { valType: 'any', role: 'info', @@ -127352,11 +129456,39 @@ module.exports = { editType: 'modebar', description: 'Sets the color of the active or hovered on icons in the modebar.' }, + uirevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes related to the modebar,', + 'including `hovermode`, `dragmode`, and `showspikes` at both the', + 'root level and inside subplots. Defaults to `layout.uirevision`.' + ].join(' ') + }, editType: 'modebar' + }, + _deprecated: { + title: { + valType: 'string', + role: 'info', + editType: 'layoutstyle', + description: [ + 'Value of `title` is no longer a simple *string* but a set of sub-attributes.', + 'To set the contents of the title, please use `title.text` now.' + ].join(' ') + }, + titlefont: fontAttrs({ + editType: 'layoutstyle', + description: [ + 'Former `titlefont` is now the sub-attribute `font` of `title`.', + 'To customize title font properties, please use `title.font` now.' + ].join(' ') + }) } }; -},{"../components/color/attributes":569,"./font_attributes":771}],800:[function(_dereq_,module,exports){ +},{"../components/color/attributes":568,"../components/colorscale/layout_attributes":582,"../lib/extend":682,"./font_attributes":767,"./pad_attributes":803}],796:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -127399,7 +129531,7 @@ module.exports = { } }; -},{}],801:[function(_dereq_,module,exports){ +},{}],797:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -127472,7 +129604,7 @@ module.exports = function convertTextOpts(textposition, iconSize) { return { anchor: anchor, offset: offset }; }; -},{"../../lib":696}],802:[function(_dereq_,module,exports){ +},{"../../lib":692}],798:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -127637,7 +129769,7 @@ exports.updateFx = function(gd) { } }; -},{"../../constants/xmlns_namespaces":674,"../../lib":696,"../../plots/get_data":781,"./constants":800,"./layout_attributes":804,"./layout_defaults":805,"./mapbox":806,"mapbox-gl":409}],803:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":670,"../../lib":692,"../../plots/get_data":777,"./constants":796,"./layout_attributes":800,"./layout_defaults":801,"./mapbox":802,"mapbox-gl":409}],799:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -127857,7 +129989,7 @@ module.exports = function createMapboxLayer(mapbox, index, opts) { return mapboxLayer; }; -},{"../../lib":696,"./convert_text_opts":801}],804:[function(_dereq_,module,exports){ +},{"../../lib":692,"./convert_text_opts":797}],800:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -127885,7 +130017,7 @@ var fontAttr = fontAttrs({ }); fontAttr.family.dflt = 'Open Sans Regular, Arial Unicode MS Regular'; -module.exports = overrideAll({ +var attrs = module.exports = overrideAll({ _arrayAttrRegexps: [Lib.counterRegex('mapbox', '.layers', true)], domain: domainAttrs({name: 'mapbox'}), @@ -128106,7 +130238,18 @@ module.exports = overrideAll({ }) }, 'plot', 'from-root'); -},{"../../components/color":570,"../../lib":696,"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../../traces/scatter/attributes":1043,"../domain":770,"../font_attributes":771}],805:[function(_dereq_,module,exports){ +// set uirevision outside of overrideAll so it can be `editType: 'none'` +attrs.uirevision = { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in the view:', + '`center`, `zoom`, `bearing`, `pitch`. Defaults to `layout.uirevision`.' + ].join(' ') +}; + +},{"../../components/color":569,"../../lib":692,"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../../traces/scatter/attributes":1040,"../domain":766,"../font_attributes":767}],801:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -128195,7 +130338,7 @@ function handleLayerDefaults(layerIn, layerOut) { } } -},{"../../lib":696,"../array_container_defaults":740,"../subplot_defaults":822,"./layout_attributes":804}],806:[function(_dereq_,module,exports){ +},{"../../lib":692,"../array_container_defaults":736,"../subplot_defaults":818,"./layout_attributes":800}],802:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -128211,6 +130354,7 @@ var mapboxgl = _dereq_('mapbox-gl'); var Fx = _dereq_('../../components/fx'); var Lib = _dereq_('../../lib'); +var Registry = _dereq_('../../registry'); var dragElement = _dereq_('../../components/dragelement'); var prepSelect = _dereq_('../cartesian/select').prepSelect; var selectOnClick = _dereq_('../cartesian/select').selectOnClick; @@ -128335,22 +130479,22 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) { map.on('moveend', function(eventData) { if(!self.map) return; - var view = self.getView(); - - opts._input.center = opts.center = view.center; - opts._input.zoom = opts.zoom = view.zoom; - opts._input.bearing = opts.bearing = view.bearing; - opts._input.pitch = opts.pitch = view.pitch; - // 'moveend' gets triggered by map.setCenter, map.setZoom, // map.setBearing and map.setPitch. // - // Here, we make sure that 'plotly_relayout' is - // triggered here only when the 'moveend' originates from a + // Here, we make sure that state updates amd 'plotly_relayout' + // are triggered only when the 'moveend' originates from a // mouse target (filtering out API calls) to not // duplicate 'plotly_relayout' events. if(eventData.originalEvent || wheeling) { + var view = self.getView(); + + opts._input.center = opts.center = view.center; + opts._input.zoom = opts.zoom = view.zoom; + opts._input.bearing = opts.bearing = view.bearing; + opts._input.pitch = opts.pitch = view.pitch; + emitRelayoutFromView(view); } wheeling = false; @@ -128408,6 +130552,7 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) { for(var k in view) { evtData[id + '.' + k] = view[k]; } + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, evtData); gd.emit('plotly_relayout', evtData); } @@ -128504,8 +130649,8 @@ proto.updateData = function(calcData) { }; proto.updateLayout = function(fullLayout) { - var map = this.map, - opts = this.opts; + var map = this.map; + var opts = this.opts; map.setCenter(convertCenter(opts.center)); map.setZoom(opts.zoom); @@ -128759,7 +130904,7 @@ function convertCenter(center) { return [center.lon, center.lat]; } -},{"../../components/dragelement":592,"../../components/fx":612,"../../lib":696,"../cartesian/select":762,"./constants":800,"./layers":803,"./layout_attributes":804,"mapbox-gl":409}],807:[function(_dereq_,module,exports){ +},{"../../components/dragelement":587,"../../components/fx":608,"../../lib":692,"../../registry":823,"../cartesian/select":758,"./constants":796,"./layers":799,"./layout_attributes":800,"mapbox-gl":409}],803:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -128770,42 +130915,51 @@ function convertCenter(center) { 'use strict'; -// This is used exclusively by components inside component arrays, -// hence the 'arraydraw' editType. If this ever gets used elsewhere -// we could generalize it as a function ala font_attributes -module.exports = { - t: { - valType: 'number', - dflt: 0, - role: 'style', - editType: 'arraydraw', - description: 'The amount of padding (in px) along the top of the component.' - }, - r: { - valType: 'number', - dflt: 0, - role: 'style', - editType: 'arraydraw', - description: 'The amount of padding (in px) on the right side of the component.' - }, - b: { - valType: 'number', - dflt: 0, - role: 'style', - editType: 'arraydraw', - description: 'The amount of padding (in px) along the bottom of the component.' - }, - l: { - valType: 'number', - dflt: 0, - role: 'style', - editType: 'arraydraw', - description: 'The amount of padding (in px) on the left side of the component.' - }, - editType: 'arraydraw' +/** + * Creates a set of padding attributes. + * + * @param {object} opts + * @param {string} editType: + * the editType for all pieces of this padding definition + * + * @return {object} attributes object containing {t, r, b, l} as specified + */ +module.exports = function(opts) { + var editType = opts.editType; + return { + t: { + valType: 'number', + dflt: 0, + role: 'style', + editType: editType, + description: 'The amount of padding (in px) along the top of the component.' + }, + r: { + valType: 'number', + dflt: 0, + role: 'style', + editType: editType, + description: 'The amount of padding (in px) on the right side of the component.' + }, + b: { + valType: 'number', + dflt: 0, + role: 'style', + editType: editType, + description: 'The amount of padding (in px) along the bottom of the component.' + }, + l: { + valType: 'number', + dflt: 0, + role: 'style', + editType: editType, + description: 'The amount of padding (in px) on the left side of the component.' + }, + editType: editType + }; }; -},{}],808:[function(_dereq_,module,exports){ +},{}],804:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -129257,6 +131411,7 @@ plots.supplyDefaults = function(gd, opts) { for(i = 0; i < crossTraceDefaultsFuncs.length; i++) { crossTraceDefaultsFuncs[i](newFullData, newFullLayout); } + Registry.getComponentMethod('colorscale', 'crossTraceDefaults')(newFullData, newFullLayout); // turn on flag to optimize large splom-only graphs // mostly by omitting SVG layers during Cartesian.drawFramework @@ -129287,16 +131442,30 @@ plots.supplyDefaults = function(gd, opts) { // relink functions and _ attributes to promote consistency between plots relinkPrivateKeys(newFullLayout, oldFullLayout); - // TODO may return a promise - plots.doAutoMargin(gd); - - // set scale after auto margin routine - var axList = axisIDs.list(gd); - for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - ax.setScale(); + // For persisting GUI-driven changes in layout + // _preGUI and _tracePreGUI were already copied over in relinkPrivateKeys + if(!newFullLayout._preGUI) newFullLayout._preGUI = {}; + // track trace GUI changes by uid rather than by trace index + if(!newFullLayout._tracePreGUI) newFullLayout._tracePreGUI = {}; + var tracePreGUI = newFullLayout._tracePreGUI; + var uids = {}; + var uid; + for(uid in tracePreGUI) uids[uid] = 'old'; + for(i = 0; i < newFullData.length; i++) { + uid = newFullData[i]._fullInput.uid; + if(!uids[uid]) tracePreGUI[uid] = {}; + uids[uid] = 'new'; + } + for(uid in uids) { + if(uids[uid] === 'old') delete tracePreGUI[uid]; } + // set up containers for margin calculations + initMargins(newFullLayout); + + // collect and do some initial calculations for rangesliders + Registry.getComponentMethod('rangeslider', 'makeData')(newFullLayout); + // update object references in calcdata if(!skipUpdateCalc && oldCalcdata.length === newFullData.length) { plots.supplyDefaultsUpdateCalc(oldCalcdata, newFullData); @@ -129605,6 +131774,12 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa plotinfo.id = id; } + // add these axis ids to each others' subplot lists + xaxis._counterAxes.push(yaxis._id); + yaxis._counterAxes.push(xaxis._id); + xaxis._subplotsWith.push(id); + yaxis._subplotsWith.push(id); + // update x and y axis layout object refs plotinfo.xaxis = xaxis; plotinfo.yaxis = yaxis; @@ -129632,8 +131807,9 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // while we're at it, link overlaying axes to their main axes and // anchored axes to the axes they're anchored to var axList = axisIDs.list(mockGd, null, true); + var ax; for(i = 0; i < axList.length; i++) { - var ax = axList[i]; + ax = axList[i]; var mainAx = null; if(ax.overlaying) { @@ -129661,8 +131837,53 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa null : axisIDs.getFromId(mockGd, ax.anchor); } + + // finally, we can find the main subplot for each axis + // (on which the ticks & labels are drawn) + for(i = 0; i < axList.length; i++) { + ax = axList[i]; + ax._counterAxes.sort(axisIDs.idSort); + ax._subplotsWith.sort(Lib.subplotSort); + ax._mainSubplot = findMainSubplot(ax, newFullLayout); + } }; +function findMainSubplot(ax, fullLayout) { + var mockGd = {_fullLayout: fullLayout}; + + var isX = ax._id.charAt(0) === 'x'; + var anchorAx = ax._mainAxis._anchorAxis; + var mainSubplotID = ''; + var nextBestMainSubplotID = ''; + var anchorID = ''; + + // First try the main ID with the anchor + if(anchorAx) { + anchorID = anchorAx._mainAxis._id; + mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); + } + + // Then look for a subplot with the counteraxis overlaying the anchor + // If that fails just use the first subplot including this axis + if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { + mainSubplotID = ''; + + var counterIDs = ax._counterAxes; + for(var j = 0; j < counterIDs.length; j++) { + var counterPart = counterIDs[j]; + var id = isX ? (ax._id + counterPart) : (counterPart + ax._id); + if(!nextBestMainSubplotID) nextBestMainSubplotID = id; + var counterAx = axisIDs.getFromId(mockGd, counterPart); + if(anchorID && counterAx.overlaying === anchorID) { + mainSubplotID = id; + break; + } + } + } + + return mainSubplotID || nextBestMainSubplotID; +} + // This function clears any trace attributes with valType: color and // no set dflt filed in the plot schema. This is needed because groupby (which // is the only transform for which this currently applies) supplies parent @@ -129930,6 +132151,8 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac coerce('type'); coerce('name', layout._traceWord + ' ' + traceInIndex); + coerce('uirevision', layout.uirevision); + // we want even invisible traces to make their would-be subplots visible // so coerce the subplot id(s) now no matter what var _module = plots.getModule(traceOut); @@ -130003,7 +132226,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac if(_module) { _module.supplyDefaults(traceIn, traceOut, defaultColor, layout); - Lib.coerceHoverinfo(traceIn, traceOut, layout); + if(!traceOut.hovertemplate) Lib.coerceHoverinfo(traceIn, traceOut, layout); } if(!Registry.traceIs(traceOut, 'noOpacity')) coerce('opacity'); @@ -130132,14 +132355,25 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { var globalFont = Lib.coerceFont(coerce, 'font'); - coerce('title', layoutOut._dfltTitle.plot); + coerce('title.text', layoutOut._dfltTitle.plot); - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: globalFont.family, size: Math.round(globalFont.size * 1.4), color: globalFont.color }); + coerce('title.xref'); + coerce('title.yref'); + coerce('title.x'); + coerce('title.y'); + coerce('title.xanchor'); + coerce('title.yanchor'); + coerce('title.pad.t'); + coerce('title.pad.r'); + coerce('title.pad.b'); + coerce('title.pad.l'); + // Make sure that autosize is defaulted to *true* // on layouts with no set width and height for backward compatibly, // in particular https://plot.ly/javascript/responsive-fluid-layout/ @@ -130172,12 +132406,16 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('colorway'); coerce('datarevision'); + var uirevision = coerce('uirevision'); + coerce('editrevision', uirevision); + coerce('selectionrevision', uirevision); coerce('modebar.orientation'); coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); + coerce('modebar.uirevision', uirevision); Registry.getComponentMethod( 'calendars', @@ -130459,7 +132697,20 @@ plots.allowAutoMargin = function(gd, id) { gd._fullLayout._pushmarginIds[id] = 1; }; -function setupAutoMargin(fullLayout) { +function initMargins(fullLayout) { + var margin = fullLayout.margin; + + if(!fullLayout._size) { + var gs = fullLayout._size = { + l: Math.round(margin.l), + r: Math.round(margin.r), + t: Math.round(margin.t), + b: Math.round(margin.b), + p: Math.round(margin.pad) + }; + gs.w = Math.round(fullLayout.width) - gs.l - gs.r; + gs.h = Math.round(fullLayout.height) - gs.t - gs.b; + } if(!fullLayout._pushmargin) fullLayout._pushmargin = {}; if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {}; } @@ -130482,8 +132733,6 @@ function setupAutoMargin(fullLayout) { plots.autoMargin = function(gd, id, o) { var fullLayout = gd._fullLayout; - setupAutoMargin(fullLayout); - var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -130527,18 +132776,19 @@ plots.autoMargin = function(gd, id, o) { plots.doAutoMargin = function(gd) { var fullLayout = gd._fullLayout; if(!fullLayout._size) fullLayout._size = {}; - setupAutoMargin(fullLayout); + initMargins(fullLayout); - var gs = fullLayout._size, - oldmargins = JSON.stringify(gs); + var gs = fullLayout._size; + var oldmargins = JSON.stringify(gs); + var margin = fullLayout.margin; // adjust margins for outside components // fullLayout.margin is the requested margin, // fullLayout._size has margins and plotsize after adjustment - var ml = Math.max(fullLayout.margin.l || 0, 0); - var mr = Math.max(fullLayout.margin.r || 0, 0); - var mt = Math.max(fullLayout.margin.t || 0, 0); - var mb = Math.max(fullLayout.margin.b || 0, 0); + var ml = margin.l; + var mr = margin.r; + var mt = margin.t; + var mb = margin.b; var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -130608,7 +132858,7 @@ plots.doAutoMargin = function(gd) { gs.r = Math.round(mr); gs.t = Math.round(mt); gs.b = Math.round(mb); - gs.p = Math.round(fullLayout.margin.pad); + gs.p = Math.round(margin.pad); gs.w = Math.round(fullLayout.width) - gs.l - gs.r; gs.h = Math.round(fullLayout.height) - gs.t - gs.b; @@ -131489,7 +133739,7 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl subplot.traceHash = traceHash; }; -},{"../components/color":570,"../constants/numerical":673,"../lib":696,"../plot_api/plot_schema":733,"../plot_api/plot_template":734,"../plots/cartesian/axis_ids":747,"../registry":827,"./animation_attributes":739,"./attributes":741,"./command":769,"./font_attributes":771,"./frame_attributes":772,"./layout_attributes":799,"d3":148,"fast-isnumeric":214}],809:[function(_dereq_,module,exports){ +},{"../components/color":569,"../constants/numerical":669,"../lib":692,"../plot_api/plot_schema":729,"../plot_api/plot_template":730,"../plots/cartesian/axis_ids":743,"../registry":823,"./animation_attributes":735,"./attributes":737,"./command":765,"./font_attributes":767,"./frame_attributes":768,"./layout_attributes":795,"d3":148,"fast-isnumeric":214}],805:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -131534,7 +133784,7 @@ module.exports = { OFFEDGE: 20 }; -},{}],810:[function(_dereq_,module,exports){ +},{}],806:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -131829,7 +134079,7 @@ module.exports = { pathPolygonAnnulus: pathPolygonAnnulus }; -},{"../../lib":696,"../../lib/polygon":708}],811:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/polygon":704}],807:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -131923,7 +134173,7 @@ module.exports = { toSVG: _dereq_('../cartesian').toSVG }; -},{"../../lib":696,"../cartesian":756,"../get_data":781,"./constants":809,"./layout_attributes":812,"./layout_defaults":813,"./polar":820}],812:[function(_dereq_,module,exports){ +},{"../../lib":692,"../cartesian":752,"../get_data":777,"./constants":805,"./layout_attributes":808,"./layout_defaults":809,"./polar":816}],808:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -131983,7 +134233,9 @@ var axisTickAttrs = overrideAll({ var radialAxisAttrs = { visible: extendFlat({}, axesAttrs.visible, {dflt: true}), - type: axesAttrs.type, + type: extendFlat({}, axesAttrs.type, { + values: ['-', 'linear', 'log', 'date', 'category'] + }), autorange: extendFlat({}, axesAttrs.autorange, {editType: 'plot'}), rangemode: { @@ -132038,15 +134290,33 @@ var radialAxisAttrs = { }, - title: extendFlat({}, axesAttrs.title, {editType: 'plot', dflt: ''}), - titlefont: overrideAll(axesAttrs.titlefont, 'plot', 'from-root'), + title: overrideAll(axesAttrs.title, 'plot', 'from-root'), // might need a 'titleside' and even 'titledirection' down the road hoverformat: axesAttrs.hoverformat, - editType: 'calc' + uirevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in axis `range`,', + '`autorange`, `angle`, and `title` if in `editable: true` configuration.', + 'Defaults to `polar.uirevision`.' + ].join(' ') + }, + + editType: 'calc', + + _deprecated: { + title: axesAttrs._deprecated.title, + titlefont: axesAttrs._deprecated.titlefont + } }; +// radial title is not gui-editable, so it needs dflt: '', similar to carpet axes. +radialAxisAttrs.title.text.dflt = ''; + extendFlat( radialAxisAttrs, @@ -132141,6 +134411,16 @@ var angularAxisAttrs = { hoverformat: axesAttrs.hoverformat, + uirevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in axis `rotation`.', + 'Defaults to `polar.uirevision`.' + ].join(' ') + }, + editType: 'calc' }; @@ -132220,10 +134500,21 @@ module.exports = { // TODO maybe? // annotations: + uirevision: { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in axis attributes,', + 'if not overridden in the individual axes.', + 'Defaults to `layout.uirevision`.' + ].join(' ') + }, + editType: 'calc' }; -},{"../../components/color/attributes":569,"../../lib":696,"../../plot_api/edit_types":727,"../cartesian/layout_attributes":757,"../domain":770}],813:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../lib":692,"../../plot_api/edit_types":723,"../cartesian/layout_attributes":753,"../domain":766}],809:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -132279,6 +134570,7 @@ function handleDefaults(contIn, contOut, coerce, opts) { var axIn = contIn[axName]; var axOut = Template.newContainer(contOut, axName); axOut._id = axOut._name = axName; + axOut._attr = opts.id + '.' + axName; axOut._traceIndices = subplotData.map(function(t) { return t._expandedIndex; }); var dataAttr = constants.axisName2dataArray[axName]; @@ -132292,6 +134584,8 @@ function handleDefaults(contIn, contOut, coerce, opts) { var visible = coerceAxis('visible'); setConvert(axOut, contOut, layoutOut); + coerceAxis('uirevision', contOut.uirevision); + var dfltColor; var dfltFontColor; @@ -132326,8 +134620,8 @@ function handleDefaults(contIn, contOut, coerce, opts) { coerceAxis('side'); coerceAxis('angle', sector[0]); - coerceAxis('title'); - Lib.coerceFont(coerceAxis, 'titlefont', { + coerceAxis('title.text'); + Lib.coerceFont(coerceAxis, 'title.font', { family: opts.font.family, size: Math.round(opts.font.size * 1.2), color: dfltFontColor @@ -132453,7 +134747,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { }); }; -},{"../../components/color":570,"../../lib":696,"../../plot_api/plot_template":734,"../cartesian/axis_autotype":745,"../cartesian/category_order_defaults":748,"../cartesian/line_grid_defaults":759,"../cartesian/tick_label_defaults":764,"../cartesian/tick_mark_defaults":765,"../cartesian/tick_value_defaults":766,"../get_data":781,"../subplot_defaults":822,"./constants":809,"./layout_attributes":812,"./set_convert":821}],814:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../plot_api/plot_template":730,"../cartesian/axis_autotype":741,"../cartesian/category_order_defaults":744,"../cartesian/line_grid_defaults":755,"../cartesian/tick_label_defaults":760,"../cartesian/tick_mark_defaults":761,"../cartesian/tick_value_defaults":762,"../get_data":777,"../subplot_defaults":818,"./constants":805,"./layout_attributes":808,"./set_convert":817}],810:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -132517,7 +134811,7 @@ module.exports = { } }; -},{"../../../lib/extend":685,"../../../traces/scatter/attributes":1043}],815:[function(_dereq_,module,exports){ +},{"../../../lib/extend":682,"../../../traces/scatter/attributes":1040}],811:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -132686,7 +134980,7 @@ module.exports = overrideAll({ } }, 'plot', 'nested'); -},{"../../../lib/extend":685,"../../../plot_api/edit_types":727,"../../cartesian/layout_attributes":757}],816:[function(_dereq_,module,exports){ +},{"../../../lib/extend":682,"../../../plot_api/edit_types":723,"../../cartesian/layout_attributes":753}],812:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -132701,7 +134995,7 @@ var Polar = module.exports = _dereq_('./micropolar'); Polar.manager = _dereq_('./micropolar_manager'); -},{"./micropolar":817,"./micropolar_manager":818}],817:[function(_dereq_,module,exports){ +},{"./micropolar":813,"./micropolar_manager":814}],813:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -132919,8 +135213,8 @@ var µ = module.exports = { version: '0.2.2' }; centeringOffset[0] = Math.max(0, centeringOffset[0]); centeringOffset[1] = Math.max(0, centeringOffset[1]); svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title); + if (axisConfig.title && axisConfig.title.text) { + var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); var titleBBox = title.node().getBBox(); title.attr({ x: chartCenter[0] - titleBBox.width / 2, @@ -134121,7 +136415,7 @@ var µ = module.exports = { version: '0.2.2' }; return exports; }; -},{"../../../constants/alignment":668,"../../../lib":696,"d3":148}],818:[function(_dereq_,module,exports){ +},{"../../../constants/alignment":664,"../../../lib":692,"d3":148}],814:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -134207,7 +136501,7 @@ manager.fillLayout = function(_gd) { _gd._fullLayout = extendDeepAll(dflts, _gd.layout); }; -},{"../../../components/color":570,"../../../lib":696,"./micropolar":817,"./undo_manager":819,"d3":148}],819:[function(_dereq_,module,exports){ +},{"../../../components/color":569,"../../../lib":692,"./micropolar":813,"./undo_manager":815,"d3":148}],815:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -134273,7 +136567,7 @@ module.exports = function UndoManager() { }; }; -},{}],820:[function(_dereq_,module,exports){ +},{}],816:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -134292,10 +136586,10 @@ var Lib = _dereq_('../../lib'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Plots = _dereq_('../plots'); +var Axes = _dereq_('../../plots/cartesian/axes'); var setConvertCartesian = _dereq_('../cartesian/set_convert'); var setConvertPolar = _dereq_('./set_convert'); var doAutoRange = _dereq_('../cartesian/autorange').doAutoRange; -var doTicksSingle = _dereq_('../cartesian/axes').doTicksSingle; var dragBox = _dereq_('../cartesian/dragbox'); var dragElement = _dereq_('../../components/dragelement'); var Fx = _dereq_('../../components/fx'); @@ -134341,7 +136635,7 @@ function Polar(gd, id) { .attr('class', id); // unfortunately, we have to keep track of some axis tick settings - // so that we don't have to call doTicksSingle with its special redraw flag + // as polar subplots do not implement the 'ticks' editType this.radialTickLayout = null; this.angularTickLayout = null; } @@ -134417,11 +136711,9 @@ proto.updateLayers = function(fullLayout, polarLayout) { break; case 'radial-grid': sel.style('fill', 'none'); - sel.append('g').classed('x', 1); break; case 'angular-grid': sel.style('fill', 'none'); - sel.append('g').classed('angularaxis', 1); break; case 'radial-line': sel.append('line').style('fill', 'none'); @@ -134443,14 +136735,15 @@ proto.updateLayers = function(fullLayout, polarLayout) { * * - this.radialAxis * extends polarLayout.radialaxis, adds mocked 'domain' and - * few other keys in order to reuse Cartesian doAutoRange and doTicksSingle, + * few other keys in order to reuse Cartesian doAutoRange and the Axes + * drawing routines. * used for calcdata -> geometric conversions (aka c2g) during the plot step * + setGeometry setups ax.c2g for given ax.range * + setScale setups ax._m,ax._b for given ax.range * * - this.angularAxis * extends polarLayout.angularaxis, adds mocked 'range' and 'domain' and - * a few other keys in order to reuse Cartesian doTicksSingle, + * a few other keys in order to reuse the Axes drawing routines. * used for calcdata -> geometric conversions (aka c2g) during the plot step * + setGeometry setups ax.c2g given ax.rotation, ax.direction & ax._categories, * and mocks ax.range @@ -134523,8 +136816,6 @@ proto.updateLayout = function(fullLayout, polarLayout) { var cyy = _this.cyy = cy - yOffset2; _this.radialAxis = _this.mockAxis(fullLayout, polarLayout, radialLayout, { - _axislayer: layers['radial-axis'], - _gridlayer: layers['radial-grid'], // make this an 'x' axis to make positioning (especially rotation) easier _id: 'x', // convert to 'x' axis equivalent @@ -134537,8 +136828,6 @@ proto.updateLayout = function(fullLayout, polarLayout) { }); _this.angularAxis = _this.mockAxis(fullLayout, polarLayout, angularLayout, { - _axislayer: layers['angular-axis'], - _gridlayer: layers['angular-grid'], side: 'right', // to get auto nticks right domain: [0, Math.PI], @@ -134571,28 +136860,19 @@ proto.updateLayout = function(fullLayout, polarLayout) { layers.frontplot .attr('transform', strTranslate(xOffset2, yOffset2)) - .call(Drawing.setClipUrl, _this._hasClipOnAxisFalse ? null : _this.clipIds.forTraces); + .call(Drawing.setClipUrl, _this._hasClipOnAxisFalse ? null : _this.clipIds.forTraces, _this.gd); layers.bg .attr('d', dPath) .attr('transform', strTranslate(cx, cy)) .call(Color.fill, polarLayout.bgcolor); - - // remove crispEdges - all the off-square angles in polar plots - // make these counterproductive. - _this.framework.selectAll('.crisp').classed('crisp', 0); }; proto.mockAxis = function(fullLayout, polarLayout, axLayout, opts) { var commonOpts = { // to get _boundingBox computation right when showticklabels is false anchor: 'free', - position: 0, - _pos: 0, - // dummy truthy value to make doTicksSingle draw the grid - _counteraxis: true, - // don't use automargins routine for labels - automargin: false + position: 0 }; var ax = Lib.extendFlat(commonOpts, axLayout, opts); @@ -134668,18 +136948,18 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) { // rotate auto tick labels by 180 if in quadrant II and III to make them // readable from left-to-right // - // TODO try moving deeper in doTicksSingle for better results? + // TODO try moving deeper in Axes.drawLabels for better results? if(ax.tickangle === 'auto' && (a0 > 90 && a0 <= 270)) { ax.tickangle = 180; } // easier to set rotate angle with custom translate function - ax._transfn = function(d) { + var transFn = function(d) { return 'translate(' + (ax.l2p(d.x) + innerRadius) + ',0)'; }; // set special grid path function - ax._gridpath = function(d) { + var gridPathFn = function(d) { return _this.pathArc(ax.r2p(d.x) + innerRadius); }; @@ -134691,7 +136971,36 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) { if(hasRoomForIt) { ax.setScale(); - doTicksSingle(gd, ax, true); + + var vals = Axes.calcTicks(ax); + var valsClipped = Axes.clipEnds(ax, vals); + var labelFns = Axes.makeLabelFns(ax, 0); + var tickSign = Axes.getTickSigns(ax)[2]; + + Axes.drawTicks(gd, ax, { + vals: vals, + layer: layers['radial-axis'], + path: Axes.makeTickPath(ax, 0, tickSign), + transFn: transFn, + crisp: false + }); + + Axes.drawGrid(gd, ax, { + vals: valsClipped, + layer: layers['radial-grid'], + path: gridPathFn, + transFn: Lib.noop, + crisp: false + }); + + Axes.drawLabels(gd, ax, { + vals: vals, + layer: layers['radial-axis'], + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); } // stash 'actual' radial axis angle for drag handlers (in degrees) @@ -134699,21 +137008,20 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) { rad2deg(snapToVertexAngle(deg2rad(radialLayout.angle), _this.vangles)) : radialLayout.angle; - var trans = strTranslate(cx, cy) + strRotate(-angle); + var tLayer = strTranslate(cx, cy); + var tLayer2 = tLayer + strRotate(-angle); updateElement( layers['radial-axis'], hasRoomForIt && (radialLayout.showticklabels || radialLayout.ticks), - {transform: trans} + {transform: tLayer2} ); - // move all grid paths to about circle center, - // undo individual grid lines translations updateElement( layers['radial-grid'], hasRoomForIt && radialLayout.showgrid, - {transform: strTranslate(cx, cy)} - ).selectAll('path').attr('transform', null); + {transform: tLayer} + ); updateElement( layers['radial-line'].select('line'), @@ -134723,7 +137031,7 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) { y1: 0, x2: radius, y2: 0, - transform: trans + transform: tLayer2 } ) .attr('stroke-width', radialLayout.linewidth) @@ -134745,9 +137053,13 @@ proto.updateRadialAxisTitle = function(fullLayout, polarLayout, _angle) { var sina = Math.sin(angleRad); var pad = 0; + + // Hint: no need to check if there is in fact a title.text set + // because if plot is editable, pad needs to be calculated anyways + // to properly show placeholder text when title is empty. if(radialLayout.title) { var h = Drawing.bBox(_this.layers['radial-axis'].node()).height; - var ts = radialLayout.titlefont.size; + var ts = radialLayout.title.font.size; pad = radialLayout.side === 'counterclockwise' ? -h - ts * 0.4 : h + ts * 0.8; @@ -134780,6 +137092,7 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { _this.fillViewInitialKey('angularaxis.rotation', angularLayout.rotation); ax.setGeometry(); + ax.setScale(); // 't'ick to 'g'eometric radians is used all over the place here var t2g = function(d) { return ax.t2g(d.x); }; @@ -134790,34 +137103,20 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { ax.dtick = rad2deg(ax.dtick); } - // Use tickval filter for category axes instead of tweaking - // the range w.r.t sector, so that sectors that cross 360 can - // show all their ticks. - if(ax.type === 'category') { - ax._tickFilter = function(d) { - return Lib.isAngleInsideSector(t2g(d), _this.sectorInRad); - }; - } - - ax._transfn = function(d) { - var sel = d3.select(this); - var hasElement = sel && sel.node(); + var _transFn = function(rad) { + return strTranslate(cx + radius * Math.cos(rad), cy - radius * Math.sin(rad)); + }; - // don't translate grid lines - if(hasElement && sel.classed('angularaxisgrid')) return ''; + var transFn = function(d) { + return _transFn(t2g(d)); + }; + var transFn2 = function(d) { var rad = t2g(d); - var out = strTranslate(cx + radius * Math.cos(rad), cy - radius * Math.sin(rad)); - - // must also rotate ticks, but don't rotate labels - if(hasElement && sel.classed('ticks')) { - out += strRotate(-rad2deg(rad)); - } - - return out; + return _transFn(rad) + strRotate(-rad2deg(rad)); }; - ax._gridpath = function(d) { + var gridPathFn = function(d) { var rad = t2g(d); var cosRad = Math.cos(rad); var sinRad = Math.sin(rad); @@ -134825,12 +137124,14 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { 'L' + [cx + radius * cosRad, cy - radius * sinRad]; }; + var out = Axes.makeLabelFns(ax, 0); + var labelStandoff = out.labelStandoff; + var labelShift = out.labelShift; var offset4fontsize = (angularLayout.ticks !== 'outside' ? 0.7 : 0.5); + var pad = (ax.linewidth || 1) / 2; - ax._labelx = function(d) { + var labelXFn = function(d) { var rad = t2g(d); - var labelStandoff = ax._labelStandoff; - var pad = ax._pad; var offset4tx = signSin(rad) === 0 ? 0 : @@ -134840,11 +137141,8 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { return offset4tx + offset4tick; }; - ax._labely = function(d) { + var labelYFn = function(d) { var rad = t2g(d); - var labelStandoff = ax._labelStandoff; - var labelShift = ax._labelShift; - var pad = ax._pad; var offset4tx = d.dy + d.fontSize * MID_SHIFT - labelShift; var offset4tick = -Math.sin(rad) * (labelStandoff + pad + offset4fontsize * d.fontSize); @@ -134852,7 +137150,8 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { return offset4tx + offset4tick; }; - ax._labelanchor = function(angle, d) { + // TODO maybe switch angle, d ordering ?? + var labelAnchorFn = function(angle, d) { var rad = t2g(d); return signSin(rad) === 0 ? (signCos(rad) > 0 ? 'start' : 'end') : @@ -134865,14 +137164,13 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { _this.angularTickLayout = newTickLayout; } - ax.setScale(); - doTicksSingle(gd, ax, true); + var vals = Axes.calcTicks(ax); // angle of polygon vertices in geometric radians (null means circles) // TODO what to do when ax.period > ax._categories ?? var vangles; if(polarLayout.gridshape === 'linear') { - vangles = ax._vals.map(t2g); + vangles = vals.map(t2g); // ax._vals should be always ordered, make them // always turn counterclockwise for convenience here @@ -134884,6 +137182,45 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { } _this.vangles = vangles; + // Use tickval filter for category axes instead of tweaking + // the range w.r.t sector, so that sectors that cross 360 can + // show all their ticks. + if(ax.type === 'category') { + vals = vals.filter(function(d) { + return Lib.isAngleInsideSector(t2g(d), _this.sectorInRad); + }); + } + + if(ax.visible) { + var tickSign = ax.ticks === 'inside' ? -1 : 1; + + Axes.drawTicks(gd, ax, { + vals: vals, + layer: layers['angular-axis'], + path: 'M' + (tickSign * pad) + ',0h' + (tickSign * ax.ticklen), + transFn: transFn2, + crisp: false + }); + + Axes.drawGrid(gd, ax, { + vals: vals, + layer: layers['angular-grid'], + path: gridPathFn, + transFn: Lib.noop, + crisp: false + }); + + Axes.drawLabels(gd, ax, { + vals: vals, + layer: layers['angular-axis'], + repositionOnUpdate: true, + transFn: transFn, + labelXFn: labelXFn, + labelYFn: labelYFn, + labelAnchorFn: labelAnchorFn + }); + } + // TODO maybe two arcs is better here? // maybe split style attributes between inner and outer angular axes? @@ -135140,7 +137477,7 @@ proto.updateMainDrag = function(fullLayout) { rl[0] + (r0 - innerRadius) * m, rl[0] + (r1 - innerRadius) * m ]; - Registry.call('relayout', gd, _this.id + '.radialaxis.range', newRng); + Registry.call('_guiRelayout', gd, _this.id + '.radialaxis.range', newRng); } function zoomClick(numClicks, evt) { @@ -135156,7 +137493,7 @@ proto.updateMainDrag = function(fullLayout) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, updateObj); + Registry.call('_guiRelayout', gd, updateObj); } if(clickMode.indexOf('select') > -1 && numClicks === 1) { @@ -135283,9 +137620,9 @@ proto.updateRadialDrag = function(fullLayout, polarLayout, rngIndex) { function doneFn() { if(angle1 !== null) { - Registry.call('relayout', gd, _this.id + '.radialaxis.angle', angle1); + Registry.call('_guiRelayout', gd, _this.id + '.radialaxis.angle', angle1); } else if(rprime !== null) { - Registry.call('relayout', gd, _this.id + '.radialaxis.range[' + rngIndex + ']', rprime); + Registry.call('_guiRelayout', gd, _this.id + '.radialaxis.range[' + rngIndex + ']', rprime); } } @@ -135320,29 +137657,25 @@ proto.updateRadialDrag = function(fullLayout, polarLayout, rngIndex) { return; } + var fullLayoutNow = gd._fullLayout; + var polarLayoutNow = fullLayoutNow[_this.id]; + // update radial range -> update c2g -> update _m,_b radialAxis.range[rngIndex] = rprime; radialAxis._rl[rngIndex] = rprime; - radialAxis.setGeometry(); - radialAxis.setScale(); + _this.updateRadialAxis(fullLayoutNow, polarLayoutNow); _this.xaxis.setRange(); _this.xaxis.setScale(); _this.yaxis.setRange(); _this.yaxis.setScale(); - doTicksSingle(gd, radialAxis, true); - layers['radial-grid'] - .attr('transform', strTranslate(cx, cy)) - .selectAll('path').attr('transform', null); - var hasRegl = false; for(var traceType in _this.traceHash) { var moduleCalcData = _this.traceHash[traceType]; var moduleCalcDataVisible = Lib.filterVisible(moduleCalcData); var _module = moduleCalcData[0][0].trace._module; - var polarLayoutNow = gd._fullLayout[_this.id]; _module.plot(gd, _this, moduleCalcDataVisible, polarLayoutNow); if(Registry.traceIs(traceType, 'gl') && moduleCalcDataVisible.length) hasRegl = true; } @@ -135416,6 +137749,7 @@ proto.updateAngularDrag = function(fullLayout) { function moveFn(dx, dy) { var fullLayoutNow = _this.gd._fullLayout; var polarLayoutNow = fullLayoutNow[_this.id]; + var x1 = x0 + dx; var y1 = y0 + dy; var a1 = xy2a(x1, y1); @@ -135434,7 +137768,6 @@ proto.updateAngularDrag = function(fullLayout) { layers.bg.attr('transform', trans); layers['radial-grid'].attr('transform', trans); - layers['angular-line'].select('path').attr('transform', trans); layers['radial-axis'].attr('transform', trans2); layers['radial-line'].select('line').attr('transform', trans2); _this.updateRadialAxisTitle(fullLayoutNow, polarLayoutNow, rrot1); @@ -135460,10 +137793,7 @@ proto.updateAngularDrag = function(fullLayout) { // update rotation -> range -> _m,_b angularAxis.rotation = Lib.modHalf(rot1, 360); - angularAxis.setGeometry(); - angularAxis.setScale(); - - doTicksSingle(gd, angularAxis, true); + _this.updateAngularAxis(fullLayoutNow, polarLayoutNow); if(_this._hasClipOnAxisFalse && !Lib.isFullCircle(_this.sectorInRad)) { scatterTraces.call(Drawing.hideOutsideRangePoints, _this); @@ -135497,7 +137827,7 @@ proto.updateAngularDrag = function(fullLayout) { updateObj[_this.id + '.radialaxis.angle'] = rrot1; } - Registry.call('relayout', gd, updateObj); + Registry.call('_guiRelayout', gd, updateObj); } dragOpts.prepFn = function(evt, startX, startY) { @@ -135669,7 +137999,7 @@ function signSin(v) { return sign(Math.sin(v)); } -},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../components/titles":661,"../../constants/alignment":668,"../../lib":696,"../../lib/clear_gl_canvases":680,"../../lib/setcursor":716,"../../plot_api/subroutines":735,"../../registry":827,"../cartesian/autorange":743,"../cartesian/axes":744,"../cartesian/dragbox":753,"../cartesian/select":762,"../cartesian/set_convert":763,"../plots":808,"./constants":809,"./helpers":810,"./set_convert":821,"d3":148,"tinycolor2":514}],821:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../components/titles":657,"../../constants/alignment":664,"../../lib":692,"../../lib/clear_gl_canvases":677,"../../lib/setcursor":712,"../../plot_api/subroutines":731,"../../plots/cartesian/axes":740,"../../registry":823,"../cartesian/autorange":739,"../cartesian/dragbox":749,"../cartesian/select":758,"../cartesian/set_convert":759,"../plots":804,"./constants":805,"./helpers":806,"./set_convert":817,"d3":148,"tinycolor2":513}],817:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -135861,7 +138191,7 @@ function setConvertAngular(ax, polarLayout) { }; } -},{"../../lib":696,"../cartesian/set_convert":763}],822:[function(_dereq_,module,exports){ +},{"../../lib":692,"../cartesian/set_convert":759}],818:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -135931,6 +138261,12 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o subplotLayoutOut = Template.newContainer(layoutOut, id, baseId); + // All subplot containers get a `uirevision` inheriting from the base. + // Currently all subplots containers have some user interaction + // attributes, but if we ever add one that doesn't, we would need an + // option to skip this step. + coerce('uirevision', layoutOut.uirevision); + var dfltDomains = {}; dfltDomains[partition] = [i / idsLength, (i + 1) / idsLength]; handleDomainDefaults(subplotLayoutOut, layoutOut, coerce, dfltDomains); @@ -135940,7 +138276,7 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o } }; -},{"../lib":696,"../plot_api/plot_template":734,"./domain":770}],823:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/plot_template":730,"./domain":766}],819:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136029,7 +138365,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../lib":696,"../../plots/get_data":781,"./layout_attributes":824,"./layout_defaults":825,"./ternary":826}],824:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/get_data":777,"./layout_attributes":820,"./layout_defaults":821,"./ternary":822}],820:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136049,7 +138385,6 @@ var extendFlat = _dereq_('../../lib/extend').extendFlat; var ternaryAxesAttrs = { title: axesAttrs.title, - titlefont: axesAttrs.titlefont, color: axesAttrs.color, // ticks tickmode: axesAttrs.tickmode, @@ -136095,10 +138430,14 @@ var ternaryAxesAttrs = { 'values of the other two axes. The full view corresponds to', 'all the minima set to zero.' ].join(' ') + }, + _deprecated: { + title: axesAttrs._deprecated.title, + titlefont: axesAttrs._deprecated.titlefont } }; -module.exports = overrideAll({ +var attrs = module.exports = overrideAll({ domain: domainAttrs({name: 'ternary'}), bgcolor: { @@ -136122,7 +138461,30 @@ module.exports = overrideAll({ caxis: ternaryAxesAttrs }, 'plot', 'from-root'); -},{"../../components/color/attributes":569,"../../lib/extend":685,"../../plot_api/edit_types":727,"../cartesian/layout_attributes":757,"../domain":770}],825:[function(_dereq_,module,exports){ +// set uirevisions outside of `overrideAll` so we can get `editType: none` +attrs.uirevision = { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in axis `min` and `title`,', + 'if not overridden in the individual axes.', + 'Defaults to `layout.uirevision`.' + ].join(' ') +}; + +attrs.aaxis.uirevision = attrs.baxis.uirevision = attrs.caxis.uirevision = { + valType: 'any', + role: 'info', + editType: 'none', + description: [ + 'Controls persistence of user-driven changes in axis `min`,', + 'and `title` if in `editable: true` configuration.', + 'Defaults to `ternary.uirevision`.' + ].join(' ') +}; + +},{"../../components/color/attributes":568,"../../lib/extend":682,"../../plot_api/edit_types":723,"../cartesian/layout_attributes":753,"../domain":766}],821:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136171,7 +138533,7 @@ function handleTernaryDefaults(ternaryLayoutIn, ternaryLayoutOut, coerce, option containerOut = Template.newContainer(ternaryLayoutOut, axName); containerOut._name = axName; - handleAxisDefaults(containerIn, containerOut, options); + handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut); } // if the min values contradict each other, set them all to default (0) @@ -136190,13 +138552,15 @@ function handleTernaryDefaults(ternaryLayoutIn, ternaryLayoutOut, coerce, option } } -function handleAxisDefaults(containerIn, containerOut, options) { +function handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut) { var axAttrs = layoutAttributes[containerOut._name]; function coerce(attr, dflt) { return Lib.coerce(containerIn, containerOut, axAttrs, attr, dflt); } + coerce('uirevision', ternaryLayoutOut.uirevision); + containerOut.type = 'linear'; // no other types allowed for ternary var dfltColor = coerce('color'); @@ -136208,10 +138572,10 @@ function handleAxisDefaults(containerIn, containerOut, options) { letterUpper = axName.charAt(0).toUpperCase(), dfltTitle = 'Component ' + letterUpper; - var title = coerce('title', dfltTitle); + var title = coerce('title.text', dfltTitle); containerOut._hovertitle = title === dfltTitle ? title : letterUpper; - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: options.font.family, size: Math.round(options.font.size * 1.2), color: dfltFontColor @@ -136252,7 +138616,7 @@ function handleAxisDefaults(containerIn, containerOut, options) { coerce('layer'); } -},{"../../components/color":570,"../../lib":696,"../../plot_api/plot_template":734,"../cartesian/line_grid_defaults":759,"../cartesian/tick_label_defaults":764,"../cartesian/tick_mark_defaults":765,"../cartesian/tick_value_defaults":766,"../subplot_defaults":822,"./layout_attributes":824}],826:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../plot_api/plot_template":730,"../cartesian/line_grid_defaults":755,"../cartesian/tick_label_defaults":760,"../cartesian/tick_mark_defaults":761,"../cartesian/tick_value_defaults":762,"../subplot_defaults":818,"./layout_attributes":820}],822:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136332,6 +138696,7 @@ proto.plot = function(ternaryCalcData, fullLayout) { proto.makeFramework = function(fullLayout) { var _this = this; + var gd = _this.graphDiv; var ternaryLayout = fullLayout[_this.id]; var clipId = _this.clipId = 'clip' + _this.layoutId + _this.id; @@ -136351,8 +138716,8 @@ proto.makeFramework = function(fullLayout) { _this.plotContainer = Lib.ensureSingle(_this.container, 'g', _this.id); _this.updateLayers(ternaryLayout); - Drawing.setClipUrl(_this.layers.backplot, clipId); - Drawing.setClipUrl(_this.layers.grids, clipId); + Drawing.setClipUrl(_this.layers.backplot, clipId, gd); + Drawing.setClipUrl(_this.layers.grids, clipId, gd); }; proto.updateLayers = function(ternaryLayout) { @@ -136413,9 +138778,6 @@ proto.updateLayers = function(ternaryLayout) { } else if(d === 'grids') { grids.forEach(function(d) { layers[d] = s.append('g').classed('grid ' + d, true); - - var fictID = (d === 'bgrid') ? 'x' : 'y'; - layers[d].append('g').classed(fictID, true); }); } }); @@ -136505,23 +138867,16 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { // fictitious angles and domain, but then rotate and translate // it into place at the end var aaxis = _this.aaxis = extendFlat({}, ternaryLayout.aaxis, { - visible: true, range: [amin, sum - bmin - cmin], side: 'left', - _counterangle: 30, // tickangle = 'auto' means 0 anyway for a y axis, need to coerce to 0 here // so we can shift by 30. tickangle: (+ternaryLayout.aaxis.tickangle || 0) - 30, domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h], - _axislayer: _this.layers.aaxis, - _gridlayer: _this.layers.agrid, anchor: 'free', position: 0, - _pos: 0, // _this.xaxis.domain[0] * graphSize.w, _id: 'y', - _length: w, - _gridpath: 'M0,0l' + h + ',-' + (w / 2), - automargin: false // don't use automargins routine for labels + _length: w }); setConvert(aaxis, _this.graphDiv._fullLayout); aaxis.setScale(); @@ -136529,45 +138884,28 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { // baxis goes across the bottom (backward). We can set it up as an x axis // without any enclosing transformation. var baxis = _this.baxis = extendFlat({}, ternaryLayout.baxis, { - visible: true, range: [sum - amin - cmin, bmin], side: 'bottom', - _counterangle: 30, domain: _this.xaxis.domain, - _axislayer: _this.layers.baxis, - _gridlayer: _this.layers.bgrid, - _counteraxis: _this.aaxis, anchor: 'free', position: 0, - _pos: 0, // (1 - yDomain0) * graphSize.h, _id: 'x', - _length: w, - _gridpath: 'M0,0l-' + (w / 2) + ',-' + h, - automargin: false // don't use automargins routine for labels + _length: w }); setConvert(baxis, _this.graphDiv._fullLayout); baxis.setScale(); - aaxis._counteraxis = baxis; // caxis goes down the right side. Set it up as a y axis, with // post-transformation similar to aaxis var caxis = _this.caxis = extendFlat({}, ternaryLayout.caxis, { - visible: true, range: [sum - amin - bmin, cmin], side: 'right', - _counterangle: 30, tickangle: (+ternaryLayout.caxis.tickangle || 0) + 30, domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h], - _axislayer: _this.layers.caxis, - _gridlayer: _this.layers.cgrid, - _counteraxis: _this.baxis, anchor: 'free', position: 0, - _pos: 0, // _this.xaxis.domain[1] * graphSize.w, _id: 'y', - _length: w, - _gridpath: 'M0,0l-' + h + ',' + (w / 2), - automargin: false // don't use automargins routine for labels + _length: w }); setConvert(caxis, _this.graphDiv._fullLayout); caxis.setScale(); @@ -136605,10 +138943,6 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { _this.drawAxes(true); - // remove crispEdges - all the off-square angles in ternary plots - // make these counterproductive. - _this.plotContainer.selectAll('.crisp').classed('crisp', false); - _this.layers.aline.select('path') .attr('d', aaxis.showline ? 'M' + x0 + ',' + (y0 + h) + 'l' + (w / 2) + ',-' + h : 'M0,0') @@ -136631,7 +138965,8 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { Drawing.setClipUrl( _this.layers.frontplot, - _this._hasClipOnAxisFalse ? null : _this.clipId + _this._hasClipOnAxisFalse ? null : _this.clipId, + _this.graphDiv ); }; @@ -136643,80 +138978,122 @@ proto.drawAxes = function(doTitles) { var aaxis = _this.aaxis; var baxis = _this.baxis; var caxis = _this.caxis; - var newTickLayout; - newTickLayout = strTickLayout(aaxis); - if(_this.aTickLayout !== newTickLayout) { - layers.aaxis.selectAll('.ytick').remove(); - _this.aTickLayout = newTickLayout; - } - - newTickLayout = strTickLayout(baxis); - if(_this.bTickLayout !== newTickLayout) { - layers.baxis.selectAll('.xtick').remove(); - _this.bTickLayout = newTickLayout; - } - - newTickLayout = strTickLayout(caxis); - if(_this.cTickLayout !== newTickLayout) { - layers.caxis.selectAll('.ytick').remove(); - _this.cTickLayout = newTickLayout; - } - - // 3rd arg true below skips titles, so we can configure them - // correctly later on. - Axes.doTicksSingle(gd, aaxis, true); - Axes.doTicksSingle(gd, baxis, true); - Axes.doTicksSingle(gd, caxis, true); + _this.drawAx(aaxis); + _this.drawAx(baxis); + _this.drawAx(caxis); if(doTitles) { var apad = Math.max(aaxis.showticklabels ? aaxis.tickfont.size / 2 : 0, (caxis.showticklabels ? caxis.tickfont.size * 0.75 : 0) + (caxis.ticks === 'outside' ? caxis.ticklen * 0.87 : 0)); - _this.layers['a-title'] = Titles.draw(gd, 'a' + titlesuffix, { + var bpad = (baxis.showticklabels ? baxis.tickfont.size : 0) + + (baxis.ticks === 'outside' ? baxis.ticklen : 0) + 3; + + layers['a-title'] = Titles.draw(gd, 'a' + titlesuffix, { propContainer: aaxis, propName: _this.id + '.aaxis.title', placeholder: _(gd, 'Click to enter Component A title'), attributes: { x: _this.x0 + _this.w / 2, - y: _this.y0 - aaxis.titlefont.size / 3 - apad, + y: _this.y0 - aaxis.title.font.size / 3 - apad, 'text-anchor': 'middle' } }); - - - var bpad = (baxis.showticklabels ? baxis.tickfont.size : 0) + - (baxis.ticks === 'outside' ? baxis.ticklen : 0) + 3; - - _this.layers['b-title'] = Titles.draw(gd, 'b' + titlesuffix, { + layers['b-title'] = Titles.draw(gd, 'b' + titlesuffix, { propContainer: baxis, propName: _this.id + '.baxis.title', placeholder: _(gd, 'Click to enter Component B title'), attributes: { x: _this.x0 - bpad, - y: _this.y0 + _this.h + baxis.titlefont.size * 0.83 + bpad, + y: _this.y0 + _this.h + baxis.title.font.size * 0.83 + bpad, 'text-anchor': 'middle' } }); - - _this.layers['c-title'] = Titles.draw(gd, 'c' + titlesuffix, { + layers['c-title'] = Titles.draw(gd, 'c' + titlesuffix, { propContainer: caxis, propName: _this.id + '.caxis.title', placeholder: _(gd, 'Click to enter Component C title'), attributes: { x: _this.x0 + _this.w + bpad, - y: _this.y0 + _this.h + caxis.titlefont.size * 0.83 + bpad, + y: _this.y0 + _this.h + caxis.title.font.size * 0.83 + bpad, 'text-anchor': 'middle' } }); } }; +proto.drawAx = function(ax) { + var _this = this; + var gd = _this.graphDiv; + var axName = ax._name; + var axLetter = axName.charAt(0); + var axId = ax._id; + var axLayer = _this.layers[axName]; + var counterAngle = 30; + + var stashKey = axLetter + 'tickLayout'; + var newTickLayout = strTickLayout(ax); + if(_this[stashKey] !== newTickLayout) { + axLayer.selectAll('.' + axId + 'tick').remove(); + _this[stashKey] = newTickLayout; + } + + ax.setScale(); + + var vals = Axes.calcTicks(ax); + var valsClipped = Axes.clipEnds(ax, vals); + var transFn = Axes.makeTransFn(ax); + var tickSign = Axes.getTickSigns(ax)[2]; + + var caRad = Lib.deg2rad(counterAngle); + var pad = tickSign * (ax.linewidth || 1) / 2; + var len = tickSign * ax.ticklen; + var w = _this.w; + var h = _this.h; + + var tickPath = axLetter === 'b' ? + 'M0,' + pad + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len) : + 'M' + pad + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); + + var gridPath = { + a: 'M0,0l' + h + ',-' + (w / 2), + b: 'M0,0l-' + (w / 2) + ',-' + h, + c: 'M0,0l-' + h + ',' + (w / 2) + }[axLetter]; + + Axes.drawTicks(gd, ax, { + vals: ax.ticks === 'inside' ? valsClipped : vals, + layer: axLayer, + path: tickPath, + transFn: transFn, + crisp: false + }); + + Axes.drawGrid(gd, ax, { + vals: valsClipped, + layer: _this.layers[axLetter + 'grid'], + path: gridPath, + transFn: transFn, + crisp: false + }); + + var labelFns = Axes.makeLabelFns(ax, 0, counterAngle); + + Axes.drawLabels(gd, ax, { + vals: vals, + layer: axLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); +}; + function strTickLayout(axLayout) { return axLayout.ticks + String(axLayout.ticklen) + String(axLayout.showticklabels); } - // hard coded paths for zoom corners // uses the same sizing as cartesian, length is MINZOOM/2, width is 3px var CLEN = constants.MINZOOM / 2 + 0.87; @@ -136782,18 +139159,22 @@ proto.initInteractions = function() { var x0, y0, mins0, span0, mins, lum, path0, dimmed, zb, corners; + function makeUpdate(_mins) { + var attrs = {}; + attrs[_this.id + '.aaxis.min'] = _mins.a; + attrs[_this.id + '.baxis.min'] = _mins.b; + attrs[_this.id + '.caxis.min'] = _mins.c; + return attrs; + } + function clickZoomPan(numClicks, evt) { var clickMode = gd._fullLayout.clickmode; removeZoombox(gd); if(numClicks === 2) { - var attrs = {}; - attrs[_this.id + '.aaxis.min'] = 0; - attrs[_this.id + '.baxis.min'] = 0; - attrs[_this.id + '.caxis.min'] = 0; gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, makeUpdate({a: 0, b: 0, c: 0})); } if(clickMode.indexOf('select') > -1 && numClicks === 1) { @@ -136897,12 +139278,7 @@ proto.initInteractions = function() { if(mins === mins0) return; - var attrs = {}; - attrs[_this.id + '.aaxis.min'] = mins.a; - attrs[_this.id + '.baxis.min'] = mins.b; - attrs[_this.id + '.caxis.min'] = mins.c; - - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, makeUpdate(mins)); if(SHOWZOOMOUTTIP && gd.data && gd._context.showTips) { Lib.notifier(_(gd, 'Double-click to zoom back out'), 'long'); @@ -136966,7 +139342,6 @@ proto.initInteractions = function() { _this.caxis.range = [_this.sum - mins.a - mins.b, mins.c]; _this.drawAxes(false); - _this.plotContainer.selectAll('.crisp').classed('crisp', false); if(_this._hasClipOnAxisFalse) { _this.plotContainer @@ -136976,12 +139351,7 @@ proto.initInteractions = function() { } function dragDone() { - var attrs = {}; - attrs[_this.id + '.aaxis.min'] = mins.a; - attrs[_this.id + '.baxis.min'] = mins.b; - attrs[_this.id + '.caxis.min'] = mins.c; - - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, makeUpdate(mins)); } // finally, set up hover and click @@ -137008,7 +139378,7 @@ function removeZoombox(gd) { .remove(); } -},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../components/titles":661,"../../lib":696,"../../lib/extend":685,"../../registry":827,"../cartesian/axes":744,"../cartesian/constants":750,"../cartesian/select":762,"../cartesian/set_convert":763,"../plots":808,"d3":148,"tinycolor2":514}],827:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../components/titles":657,"../../lib":692,"../../lib/extend":682,"../../registry":823,"../cartesian/axes":740,"../cartesian/constants":746,"../cartesian/select":758,"../cartesian/set_convert":759,"../plots":804,"d3":148,"tinycolor2":513}],823:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137450,7 +139820,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/extend":685,"./lib/is_plain_object":697,"./lib/loggers":700,"./lib/noop":705,"./lib/push_unique":710,"./plots/attributes":741,"./plots/layout_attributes":799}],828:[function(_dereq_,module,exports){ +},{"./lib/extend":682,"./lib/is_plain_object":693,"./lib/loggers":696,"./lib/noop":701,"./lib/push_unique":706,"./plots/attributes":737,"./plots/layout_attributes":795}],824:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137477,7 +139847,7 @@ function cloneLayoutOverride(tileClass) { autosize: true, width: 150, height: 150, - title: '', + title: {text: ''}, showlegend: false, margin: {l: 5, r: 5, t: 5, b: 5, pad: 0}, annotations: [] @@ -137486,7 +139856,7 @@ function cloneLayoutOverride(tileClass) { case 'thumbnail': override = { - title: '', + title: {text: ''}, hidesources: true, showlegend: false, borderwidth: 0, @@ -137534,7 +139904,7 @@ module.exports = function clonePlot(graphObj, options) { for(i = 0; i < keys.length; i++) { if(keyIsAxis(keys[i])) { - newLayout[keys[i]].title = ''; + newLayout[keys[i]].title = {text: ''}; } } @@ -137562,7 +139932,7 @@ module.exports = function clonePlot(graphObj, options) { var axesImageOverride = {}; if(options.tileClass === 'thumbnail') { axesImageOverride = { - title: '', + title: {text: ''}, showaxeslabels: false, showticklabels: false, linetickenable: false @@ -137624,7 +139994,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":696}],829:[function(_dereq_,module,exports){ +},{"../lib":692}],825:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137692,7 +140062,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":696,"../plot_api/to_image":737,"./filesaver":830}],830:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/to_image":733,"./filesaver":826}],826:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137764,7 +140134,7 @@ var fileSaver = function(url, name) { module.exports = fileSaver; -},{}],831:[function(_dereq_,module,exports){ +},{}],827:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137801,7 +140171,7 @@ exports.getRedrawFunc = function(gd) { }; }; -},{}],832:[function(_dereq_,module,exports){ +},{}],828:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137827,7 +140197,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":828,"./download":829,"./helpers":831,"./svgtoimg":833,"./toimage":834,"./tosvg":835}],833:[function(_dereq_,module,exports){ +},{"./cloneplot":824,"./download":825,"./helpers":827,"./svgtoimg":829,"./toimage":830,"./tosvg":831}],829:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137943,7 +140313,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":696,"events":92}],834:[function(_dereq_,module,exports){ +},{"../lib":692,"events":92}],830:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138022,7 +140392,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":696,"../registry":827,"./cloneplot":828,"./helpers":831,"./svgtoimg":833,"./tosvg":835,"events":92}],835:[function(_dereq_,module,exports){ +},{"../lib":692,"../registry":823,"./cloneplot":824,"./helpers":827,"./svgtoimg":829,"./tosvg":831,"events":92}],831:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138204,7 +140574,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":570,"../components/drawing":595,"../constants/xmlns_namespaces":674,"../lib":696,"d3":148}],836:[function(_dereq_,module,exports){ +},{"../components/color":569,"../components/drawing":590,"../constants/xmlns_namespaces":670,"../lib":692,"d3":148}],832:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138239,7 +140609,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":696}],837:[function(_dereq_,module,exports){ +},{"../../lib":692}],833:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138251,9 +140621,11 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); +var constants = _dereq_('./constants.js'); var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -138302,6 +140674,9 @@ module.exports = { text: scatterAttrs.text, hovertext: scatterAttrs.hovertext, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), textposition: { valType: 'enumerated', @@ -138444,7 +140819,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/font_attributes":771,"../scatter/attributes":1043}],838:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plots/font_attributes":767,"../scatter/attributes":1040,"./constants.js":835}],834:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138456,7 +140831,7 @@ module.exports = { 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var arraysToCalcdata = _dereq_('./arrays_to_calcdata'); var calcSelection = _dereq_('../scatter/calc_selection'); @@ -138489,10 +140864,18 @@ module.exports = function calc(gd, trace) { // auto-z and autocolorscale if applicable if(hasColorscale(trace, 'marker')) { - colorscaleCalc(trace, trace.marker.color, 'marker', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - colorscaleCalc(trace, trace.marker.line.color, 'marker.line', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } arraysToCalcdata(cd, trace); @@ -138501,7 +140884,23 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"../../plots/cartesian/axes":744,"../scatter/calc_selection":1045,"./arrays_to_calcdata":836}],839:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"../../plots/cartesian/axes":740,"../scatter/calc_selection":1042,"./arrays_to_calcdata":832}],835:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + eventDataKeys: [] +}; + +},{}],836:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138630,9 +141029,14 @@ function initBase(gd, pa, sa, calcTraces) { // time. But included here for completeness. var scalendar = trace.orientation === 'h' ? trace.xcalendar : trace.ycalendar; + // 'base' on categorical axes makes no sense + var d2c = sa.type === 'category' || sa.type === 'multicategory' ? + function() { return null; } : + sa.d2c; + if(isArrayOrTypedArray(base)) { for(j = 0; j < Math.min(base.length, cd.length); j++) { - b = sa.d2c(base[j], 0, scalendar); + b = d2c(base[j], 0, scalendar); if(isNumeric(b)) { cd[j].b = +b; cd[j].hasB = 1; @@ -138643,7 +141047,7 @@ function initBase(gd, pa, sa, calcTraces) { cd[j].b = 0; } } else { - b = sa.d2c(base, 0, scalendar); + b = d2c(base, 0, scalendar); var hasBase = isNumeric(b); b = hasBase ? b : 0; for(j = 0; j < cd.length; j++) { @@ -139222,7 +141626,7 @@ module.exports = { setGroupPositions: setGroupPositions }; -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axes":744,"../../registry":827,"./sieve.js":848,"fast-isnumeric":214}],840:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axes":740,"../../registry":823,"./sieve.js":845,"fast-isnumeric":214}],837:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139262,6 +141666,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); + coerce('hovertemplate'); var textPosition = coerce('textposition'); @@ -139302,7 +141707,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/color":570,"../../lib":696,"../../registry":827,"../bar/style_defaults":850,"../scatter/xy_defaults":1069,"./attributes":837}],841:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../registry":823,"../bar/style_defaults":847,"../scatter/xy_defaults":1066,"./attributes":833}],838:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139371,7 +141776,7 @@ exports.getValue = function(arrayOrScalar, index) { return value; }; -},{"fast-isnumeric":214,"tinycolor2":514}],842:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214,"tinycolor2":513}],839:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139511,6 +141916,7 @@ function hoverPoints(pointData, xval, yval, hovermode) { fillHoverText(di, trace, pointData); Registry.getComponentMethod('errorbars', 'hoverInfo')(di, trace, pointData); + pointData.hovertemplate = trace.hovertemplate; return [pointData]; } @@ -139528,7 +141934,7 @@ module.exports = { getTraceColor: getTraceColor }; -},{"../../components/color":570,"../../components/fx":612,"../../registry":827,"../scatter/fill_hover_text":1051}],843:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../registry":823,"../scatter/fill_hover_text":1048}],840:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139571,7 +141977,7 @@ Bar.meta = { module.exports = Bar; -},{"../../plots/cartesian":756,"../scatter/marker_colorbar":1061,"./arrays_to_calcdata":836,"./attributes":837,"./calc":838,"./cross_trace_calc":839,"./defaults":840,"./hover":842,"./layout_attributes":844,"./layout_defaults":845,"./plot":846,"./select":847,"./style":849}],844:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../scatter/marker_colorbar":1058,"./arrays_to_calcdata":832,"./attributes":833,"./calc":834,"./cross_trace_calc":836,"./defaults":837,"./hover":839,"./layout_attributes":841,"./layout_defaults":842,"./plot":843,"./select":844,"./style":846}],841:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139640,7 +142046,7 @@ module.exports = { } }; -},{}],845:[function(_dereq_,module,exports){ +},{}],842:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139698,7 +142104,7 @@ module.exports = function(layoutIn, layoutOut, fullData) { coerce('bargroupgap'); }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../../registry":827,"./layout_attributes":844}],846:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../../registry":823,"./layout_attributes":841}],843:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139825,7 +142231,7 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { .style('vector-effect', 'non-scaling-stroke') .attr('d', 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z') - .call(Drawing.setClipUrl, plotinfo.layerClipId); + .call(Drawing.setClipUrl, plotinfo.layerClipId, gd); appendBarText(gd, bar, cd, i, x0, x1, y0, y1); @@ -139837,11 +142243,11 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { // lastly, clip points groups of `cliponaxis !== false` traces // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = cd0.trace.cliponaxis === false; - Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId); + Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId, gd); }); // error bars are on the top - Registry.getComponentMethod('errorbars', 'plot')(bartraces, plotinfo); + Registry.getComponentMethod('errorbars', 'plot')(gd, bartraces, plotinfo); }; function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) { @@ -140138,7 +142544,7 @@ function getTextPosition(trace, index) { return helpers.coerceEnumerated(attributeTextPosition, value); } -},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../lib/svg_text_utils":720,"../../registry":827,"./attributes":837,"./helpers":841,"./style":849,"d3":148,"fast-isnumeric":214}],847:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../lib/svg_text_utils":716,"../../registry":823,"./attributes":833,"./helpers":838,"./style":846,"d3":148,"fast-isnumeric":214}],844:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140181,7 +142587,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],848:[function(_dereq_,module,exports){ +},{}],845:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140290,7 +142696,7 @@ Sieve.prototype.getLabel = function getLabel(position, value) { return prefix + label; }; -},{"../../constants/numerical":673,"../../lib":696}],849:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692}],846:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140464,7 +142870,7 @@ module.exports = { getBarColor: getBarColor }; -},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../registry":827,"./attributes":837,"./helpers":841,"d3":148}],850:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../registry":823,"./attributes":833,"./helpers":838,"d3":148}],847:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140473,11 +142879,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout) { @@ -140503,7 +142908,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, default coerce('unselected.marker.color'); }; -},{"../../components/color":570,"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584}],851:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580}],848:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140583,7 +142988,7 @@ module.exports = { // error_y }; -},{"../../lib/extend":685,"../bar/attributes":837,"../scatterpolar/attributes":1105}],852:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../bar/attributes":833,"../scatterpolar/attributes":1102}],849:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140594,7 +142999,7 @@ module.exports = { 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var arraysToCalcdata = _dereq_('../bar/arrays_to_calcdata'); var setGroupPositions = _dereq_('../bar/cross_trace_calc').setGroupPositions; @@ -140639,10 +143044,18 @@ function calc(gd, trace) { } if(hasColorscale(trace, 'marker')) { - colorscaleCalc(trace, trace.marker.color, 'marker', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - colorscaleCalc(trace, trace.marker.line.color, 'marker.line', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } arraysToCalcdata(cd, trace); @@ -140686,7 +143099,7 @@ module.exports = { crossTraceCalc: crossTraceCalc }; -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../registry":827,"../bar/arrays_to_calcdata":836,"../bar/cross_trace_calc":839,"../scatter/calc_selection":1045}],853:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"../../lib":692,"../../registry":823,"../bar/arrays_to_calcdata":832,"../bar/cross_trace_calc":836,"../scatter/calc_selection":1042}],850:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140744,7 +143157,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../bar/style_defaults":850,"../scatterpolar/defaults":1107,"./attributes":851}],854:[function(_dereq_,module,exports){ +},{"../../lib":692,"../bar/style_defaults":847,"../scatterpolar/defaults":1104,"./attributes":848}],851:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140818,7 +143231,7 @@ module.exports = function hoverPoints(pointData, xval, yval) { return [pointData]; }; -},{"../../components/fx":612,"../../lib":696,"../../plots/polar/helpers":810,"../bar/hover":842,"../scatter/fill_hover_text":1051,"../scatterpolar/hover":1108}],855:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../lib":692,"../../plots/polar/helpers":806,"../bar/hover":839,"../scatter/fill_hover_text":1048,"../scatterpolar/hover":1105}],852:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140861,7 +143274,7 @@ module.exports = { } }; -},{"../../plots/polar":811,"../bar/select":847,"../bar/style":849,"../scatter/marker_colorbar":1061,"./attributes":851,"./calc":852,"./defaults":853,"./hover":854,"./layout_attributes":856,"./layout_defaults":857,"./plot":858}],856:[function(_dereq_,module,exports){ +},{"../../plots/polar":807,"../bar/select":844,"../bar/style":846,"../scatter/marker_colorbar":1058,"./attributes":848,"./calc":849,"./defaults":850,"./hover":851,"./layout_attributes":853,"./layout_defaults":854,"./plot":855}],853:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140903,7 +143316,7 @@ module.exports = { } }; -},{}],857:[function(_dereq_,module,exports){ +},{}],854:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140938,7 +143351,7 @@ module.exports = function(layoutIn, layoutOut, fullData) { } }; -},{"../../lib":696,"./layout_attributes":856}],858:[function(_dereq_,module,exports){ +},{"../../lib":692,"./layout_attributes":853}],855:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141010,7 +143423,11 @@ module.exports = function plot(gd, subplot, cdbar) { }); // clip plotGroup, when trace layer isn't clipped - Drawing.setClipUrl(plotGroup, subplot._hasClipOnAxisFalse ? subplot.clipIds.forTraces : null); + Drawing.setClipUrl( + plotGroup, + subplot._hasClipOnAxisFalse ? subplot.clipIds.forTraces : null, + gd + ); }); }; @@ -141042,7 +143459,7 @@ function makePathFn(subplot) { }; } -},{"../../components/drawing":595,"../../lib":696,"../../plots/polar/helpers":810,"d3":148,"fast-isnumeric":214}],859:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../../plots/polar/helpers":806,"d3":148,"fast-isnumeric":214}],856:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141303,7 +143720,7 @@ module.exports = { } }; -},{"../../components/color/attributes":569,"../../lib/extend":685,"../scatter/attributes":1043}],860:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../lib/extend":682,"../scatter/attributes":1040}],857:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141484,7 +143901,10 @@ function getPos(trace, posLetter, posAxis, val, num) { pos0 = num; } - var pos0c = posAxis.d2c(pos0, 0, trace[posLetter + 'calendar']); + var pos0c = posAxis.type === 'multicategory' ? + posAxis.r2c_just_indices(pos0) : + posAxis.d2c(pos0, 0, trace[posLetter + 'calendar']); + return val.map(function() { return pos0c; }); } @@ -141539,7 +143959,7 @@ function sortByVal(a, b) { return a.v - b.v; } function extractVal(o) { return o.v; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"fast-isnumeric":214}],861:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"fast-isnumeric":214}],858:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141655,7 +144075,7 @@ module.exports = { setPositionOffset: setPositionOffset }; -},{"../../lib":696,"../../plots/cartesian/axes":744}],862:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740}],859:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141703,16 +144123,15 @@ function handleSampleDefaults(traceIn, traceOut, coerce, layout) { if(y && y.length) { defaultOrientation = 'v'; if(hasX) { - len = Math.min(x.length, y.length); - } - else { + len = Math.min(Lib.minRowLength(x), Lib.minRowLength(y)); + } else { coerce('x0'); - len = y.length; + len = Lib.minRowLength(y); } } else if(hasX) { defaultOrientation = 'h'; coerce('y0'); - len = x.length; + len = Lib.minRowLength(x); } else { traceOut.visible = false; return; @@ -141773,7 +144192,7 @@ module.exports = { handlePointsDefaults: handlePointsDefaults }; -},{"../../components/color":570,"../../lib":696,"../../registry":827,"./attributes":859}],863:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../registry":823,"./attributes":856}],860:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141799,7 +144218,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],864:[function(_dereq_,module,exports){ +},{}],861:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142062,7 +144481,7 @@ module.exports = { hoverOnPoints: hoverOnPoints }; -},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051}],865:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048}],862:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142111,7 +144530,7 @@ Box.meta = { module.exports = Box; -},{"../../plots/cartesian":756,"./attributes":859,"./calc":860,"./cross_trace_calc":861,"./defaults":862,"./event_data":863,"./hover":864,"./layout_attributes":866,"./layout_defaults":867,"./plot":868,"./select":869,"./style":870}],866:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":856,"./calc":857,"./cross_trace_calc":858,"./defaults":859,"./event_data":860,"./hover":861,"./layout_attributes":863,"./layout_defaults":864,"./plot":865,"./select":866,"./style":867}],863:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142165,7 +144584,7 @@ module.exports = { } }; -},{}],867:[function(_dereq_,module,exports){ +},{}],864:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142208,7 +144627,7 @@ module.exports = { _supply: _supply }; -},{"../../lib":696,"../../registry":827,"./layout_attributes":866}],868:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"./layout_attributes":863}],865:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142548,7 +144967,7 @@ module.exports = { plotBoxMean: plotBoxMean }; -},{"../../components/drawing":595,"../../lib":696,"d3":148}],869:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"d3":148}],866:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142597,7 +145016,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],870:[function(_dereq_,module,exports){ +},{}],867:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142671,7 +145090,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/color":570,"../../components/drawing":595,"d3":148}],871:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"d3":148}],868:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142729,7 +145148,7 @@ module.exports = { hoverlabel: OHLCattrs.hoverlabel, }; -},{"../../lib":696,"../box/attributes":859,"../ohlc/attributes":991}],872:[function(_dereq_,module,exports){ +},{"../../lib":692,"../box/attributes":856,"../ohlc/attributes":988}],869:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142779,7 +145198,7 @@ function ptFunc(o, h, l, c) { }; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"../ohlc/calc":992}],873:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../ohlc/calc":989}],870:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142824,7 +145243,7 @@ function handleDirection(traceIn, traceOut, coerce, direction) { coerce(direction + '.fillcolor', Color.addOpacity(lineColor, 0.5)); } -},{"../../components/color":570,"../../lib":696,"../ohlc/ohlc_defaults":996,"./attributes":871}],874:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../ohlc/ohlc_defaults":993,"./attributes":868}],871:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142869,7 +145288,7 @@ module.exports = { selectPoints: _dereq_('../ohlc/select') }; -},{"../../plots/cartesian":756,"../box/cross_trace_calc":861,"../box/layout_attributes":866,"../box/layout_defaults":867,"../box/plot":868,"../box/style":870,"../ohlc/hover":994,"../ohlc/select":998,"./attributes":871,"./calc":872,"./defaults":873}],875:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../box/cross_trace_calc":858,"../box/layout_attributes":863,"../box/layout_defaults":864,"../box/plot":865,"../box/style":867,"../ohlc/hover":991,"../ohlc/select":995,"./attributes":868,"./calc":869,"./defaults":870}],872:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142933,7 +145352,7 @@ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) { }); } -},{"../../plot_api/plot_template":734,"./axis_defaults":880}],876:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":730,"./axis_defaults":877}],873:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142980,7 +145399,7 @@ function minMax(a, depth) { return [min, max]; } -},{"../../lib":696}],877:[function(_dereq_,module,exports){ +},{"../../lib":692}],874:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143113,7 +145532,7 @@ module.exports = { transforms: undefined }; -},{"../../components/color/attributes":569,"../../plots/font_attributes":771,"./axis_attributes":879}],878:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../plots/font_attributes":767,"./axis_attributes":876}],875:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143220,7 +145639,7 @@ module.exports = function(carpet, carpetcd, a, b) { return segments; }; -},{"../../lib":696}],879:[function(_dereq_,module,exports){ +},{"../../lib":692}],876:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143257,26 +145676,39 @@ module.exports = { editType: 'calc' }, title: { - valType: 'string', - role: 'info', - editType: 'calc', - description: 'Sets the title of this axis.' - }, - titlefont: fontAttrs({ - editType: 'calc', - description: [ - 'Sets this axis\' title font.' - ].join(' ') - }), - titleoffset: { - valType: 'number', - role: 'info', - dflt: 10, + text: { + valType: 'string', + dflt: '', + role: 'info', + editType: 'calc', + description: [ + 'Sets the title of this axis.', + 'Note that before the existence of `title.text`, the title\'s', + 'contents used to be defined as the `title` attribute itself.', + 'This behavior has been deprecated.' + ].join(' ') + }, + font: fontAttrs({ + editType: 'calc', + description: [ + 'Sets this axis\' title font.', + 'Note that the title\'s font used to be set', + 'by the now deprecated `titlefont` attribute.' + ].join(' ') + }), + offset: { + valType: 'number', + role: 'info', + dflt: 10, + editType: 'calc', + description: [ + 'An additional amount by which to offset the title from the tick', + 'labels, given in pixels.', + 'Note that this used to be set', + 'by the now deprecated `titleoffset` attribute.' + ].join(' '), + }, editType: 'calc', - description: [ - 'An additional amount by which to offset the title from the tick', - 'labels, given in pixels' - ].join(' '), }, type: { valType: 'enumerated', @@ -143717,10 +146149,35 @@ module.exports = { editType: 'calc', description: 'The stride between grid lines along the axis' }, + + _deprecated: { + title: { + valType: 'string', + role: 'info', + editType: 'calc', + description: [ + 'Deprecated in favor of `title.text`.', + 'Note that value of `title` is no longer a simple', + '*string* but a set of sub-attributes.' + ].join(' ') + }, + titlefont: fontAttrs({ + editType: 'calc', + description: 'Deprecated in favor of `title.font`.' + }), + titleoffset: { + valType: 'number', + role: 'info', + dflt: 10, + editType: 'calc', + description: 'Deprecated in favor of `title.offset`.' + } + }, + editType: 'calc' }; -},{"../../components/color/attributes":569,"../../plot_api/edit_types":727,"../../plots/cartesian/layout_attributes":757,"../../plots/font_attributes":771}],880:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../plot_api/edit_types":723,"../../plots/cartesian/layout_attributes":753,"../../plots/font_attributes":767}],877:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143836,14 +146293,15 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options) // inherit from global font color in case that was provided. var dfltFontColor = (dfltColor === containerIn.color) ? dfltColor : font.color; - coerce('title'); - Lib.coerceFont(coerce, 'titlefont', { - family: font.family, - size: Math.round(font.size * 1.2), - color: dfltFontColor - }); - - coerce('titleoffset'); + var title = coerce('title.text'); + if(title) { + Lib.coerceFont(coerce, 'title.font', { + family: font.family, + size: Math.round(font.size * 1.2), + color: dfltFontColor + }); + coerce('title.offset'); + } coerce('tickangle'); @@ -143926,11 +146384,6 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options) // but no, we *actually* want to coerce this. coerce('tickmode'); - if(!containerOut.title || (containerOut.title && containerOut.title.length === 0)) { - delete containerOut.titlefont; - delete containerOut.titleoffset; - } - return containerOut; }; @@ -143948,7 +146401,7 @@ function setAutoType(ax, data) { ax.type = autoType(data, calendar); } -},{"../../components/color":570,"../../lib":696,"../../plots/cartesian/axis_autotype":745,"../../plots/cartesian/category_order_defaults":748,"../../plots/cartesian/set_convert":763,"../../plots/cartesian/tick_label_defaults":764,"../../plots/cartesian/tick_value_defaults":766,"../../registry":827,"./attributes":877}],881:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../plots/cartesian/axis_autotype":741,"../../plots/cartesian/category_order_defaults":744,"../../plots/cartesian/set_convert":759,"../../plots/cartesian/tick_label_defaults":760,"../../plots/cartesian/tick_value_defaults":762,"../../registry":823,"./attributes":874}],878:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144058,7 +146511,7 @@ module.exports = function calc(gd, trace) { return [t]; }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../heatmap/clean_2d_array":947,"../heatmap/convert_column_xyz":949,"./array_minmax":876,"./calc_clippath":882,"./calc_gridlines":883,"./calc_labels":884,"./cheater_basis":886,"./set_convert":899,"./smooth_fill_2d_array":900}],882:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../heatmap/clean_2d_array":944,"../heatmap/convert_column_xyz":946,"./array_minmax":873,"./calc_clippath":879,"./calc_gridlines":880,"./calc_labels":881,"./cheater_basis":883,"./set_convert":896,"./smooth_fill_2d_array":897}],879:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144110,7 +146563,7 @@ module.exports = function makeClipPath(xctrl, yctrl, aax, bax) { return segments; }; -},{}],883:[function(_dereq_,module,exports){ +},{}],880:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144453,7 +146906,7 @@ module.exports = function calcGridlines(trace, axisLetter, crossAxisLetter) { } }; -},{"../../lib/extend":685,"../../plots/cartesian/axes":744}],884:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plots/cartesian/axes":740}],881:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144514,7 +146967,7 @@ module.exports = function calcLabels(trace, axis) { } }; -},{"../../lib/extend":685,"../../plots/cartesian/axes":744}],885:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plots/cartesian/axes":740}],882:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144556,7 +147009,7 @@ module.exports = function makeControlPoints(p0, p1, p2, smoothness) { ]]; }; -},{}],886:[function(_dereq_,module,exports){ +},{}],883:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144624,7 +147077,7 @@ module.exports = function(a, b, cheaterslope) { return data; }; -},{"../../lib":696}],887:[function(_dereq_,module,exports){ +},{"../../lib":692}],884:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144976,7 +147429,7 @@ module.exports = function computeControlPoints(xe, ye, x, y, asmoothing, bsmooth return [xe, ye]; }; -},{"../../lib":696,"./catmull_rom":885}],888:[function(_dereq_,module,exports){ +},{"../../lib":692,"./catmull_rom":882}],885:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144992,7 +147445,7 @@ module.exports = { RELATIVE_CULL_TOLERANCE: 1e-6 }; -},{}],889:[function(_dereq_,module,exports){ +},{}],886:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145144,7 +147597,7 @@ module.exports = function(arrays, asmoothing, bsmoothing) { } }; -},{}],890:[function(_dereq_,module,exports){ +},{}],887:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145272,7 +147725,7 @@ module.exports = function(arrays, asmoothing, bsmoothing) { }; -},{}],891:[function(_dereq_,module,exports){ +},{}],888:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145423,7 +147876,7 @@ module.exports = function(arrays, na, nb, asmoothing, bsmoothing) { }; -},{}],892:[function(_dereq_,module,exports){ +},{}],889:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145482,7 +147935,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, dfltColor, fullLayou } }; -},{"../../components/color/attributes":569,"../../lib":696,"./ab_defaults":875,"./attributes":877,"./xy_defaults":901}],893:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../lib":692,"./ab_defaults":872,"./attributes":874,"./xy_defaults":898}],890:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145506,7 +147959,7 @@ Carpet.isContainer = true; // so carpet traces get `calc` before other traces Carpet.moduleType = 'trace'; Carpet.name = 'carpet'; Carpet.basePlotModule = _dereq_('../../plots/cartesian'); -Carpet.categories = ['cartesian', 'svg', 'carpet', 'carpetAxis', 'notLegendIsolatable']; +Carpet.categories = ['cartesian', 'svg', 'carpet', 'carpetAxis', 'notLegendIsolatable', 'noMultiCategory']; Carpet.meta = { description: [ 'The data describing carpet axis layout is set in `y` and (optionally)', @@ -145521,7 +147974,7 @@ Carpet.meta = { module.exports = Carpet; -},{"../../plots/cartesian":756,"./attributes":877,"./calc":881,"./defaults":892,"./plot":898}],894:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":874,"./calc":878,"./defaults":889,"./plot":895}],891:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145557,7 +148010,7 @@ module.exports = function(gd, trace) { return firstAxis; }; -},{}],895:[function(_dereq_,module,exports){ +},{}],892:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145588,7 +148041,7 @@ module.exports = function makePath(xp, yp, isBicubic) { return path.join(isBicubic ? '' : 'L'); }; -},{}],896:[function(_dereq_,module,exports){ +},{}],893:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145625,7 +148078,7 @@ module.exports = function mapArray(out, data, func) { return out; }; -},{"../../lib":696}],897:[function(_dereq_,module,exports){ +},{"../../lib":692}],894:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145667,7 +148120,7 @@ module.exports = function orientText(trace, xaxis, yaxis, xy, dxy, refDxy) { }; }; -},{}],898:[function(_dereq_,module,exports){ +},{}],895:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145867,7 +148320,7 @@ var midShift = ((1 - alignmentConstants.MID_SHIFT) / lineSpacing) + 1; function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientation, labelClass) { var data = []; - if(axis.title) data.push(axis.title); + if(axis.title.text) data.push(axis.title.text); var titleJoin = layer.selectAll('text.' + labelClass).data(data); var offset = labelOrientation.maxExtent; @@ -145883,8 +148336,8 @@ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientat } // In addition to the size of the labels, add on some extra padding: - var titleSize = axis.titlefont.size; - offset += titleSize + axis.titleoffset; + var titleSize = axis.title.font.size; + offset += titleSize + axis.title.offset; var labelNorm = labelOrientation.angle + (labelOrientation.flip < 0 ? 180 : 0); var angleDiff = (labelNorm - orientation.angle + 450) % 360; @@ -145892,7 +148345,7 @@ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientat var el = d3.select(this); - el.text(axis.title || '') + el.text(axis.title.text) .call(svgTextUtils.convertToTspans, gd); if(reverseTitle) { @@ -145906,13 +148359,13 @@ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientat ) .classed('user-select-none', true) .attr('text-anchor', 'middle') - .call(Drawing.font, axis.titlefont); + .call(Drawing.font, axis.title.font); }); titleJoin.exit().remove(); } -},{"../../components/drawing":595,"../../constants/alignment":668,"../../lib":696,"../../lib/svg_text_utils":720,"./makepath":895,"./map_1d_array":896,"./orient_text":897,"d3":148}],899:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../constants/alignment":664,"../../lib":692,"../../lib/svg_text_utils":716,"./makepath":892,"./map_1d_array":893,"./orient_text":894,"d3":148}],896:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146195,7 +148648,7 @@ module.exports = function setConvert(trace) { }; }; -},{"../../lib/search":715,"./compute_control_points":887,"./constants":888,"./create_i_derivative_evaluator":889,"./create_j_derivative_evaluator":890,"./create_spline_evaluator":891}],900:[function(_dereq_,module,exports){ +},{"../../lib/search":711,"./compute_control_points":884,"./constants":885,"./create_i_derivative_evaluator":886,"./create_j_derivative_evaluator":887,"./create_spline_evaluator":888}],897:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146418,7 +148871,7 @@ module.exports = function smoothFill2dArray(data, a, b) { return data; }; -},{"../../lib":696}],901:[function(_dereq_,module,exports){ +},{"../../lib":692}],898:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146453,7 +148906,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, coerce) { return true; }; -},{"../../lib":696}],902:[function(_dereq_,module,exports){ +},{"../../lib":692}],899:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146538,7 +148991,7 @@ module.exports = extendFlat({ {colorbar: colorbarAttrs} ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../scattergeo/attributes":1083}],903:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../scattergeo/attributes":1080}],900:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146571,13 +149024,17 @@ module.exports = function calc(gd, trace) { } arraysToCalcdata(calcTrace, trace); - colorscaleCalc(trace, trace.z, '', 'z'); + colorscaleCalc(gd, trace, { + vals: trace.z, + containerStr: '', + cLetter: 'z' + }); calcSelection(calcTrace, trace); return calcTrace; }; -},{"../../components/colorscale/calc":578,"../../constants/numerical":673,"../scatter/arrays_to_calcdata":1042,"../scatter/calc_selection":1045,"fast-isnumeric":214}],904:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../constants/numerical":669,"../scatter/arrays_to_calcdata":1039,"../scatter/calc_selection":1042,"fast-isnumeric":214}],901:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146622,7 +149079,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"./attributes":902}],905:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"./attributes":899}],902:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146641,7 +149098,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],906:[function(_dereq_,module,exports){ +},{}],903:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146731,7 +149188,7 @@ function makeHoverInfo(pointData, trace, pt, axis) { pointData.extraText = text.join('
'); } -},{"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051,"./attributes":902}],907:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048,"./attributes":899}],904:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146771,7 +149228,7 @@ Choropleth.meta = { module.exports = Choropleth; -},{"../../plots/geo":775,"../heatmap/colorbar":948,"./attributes":902,"./calc":903,"./defaults":904,"./event_data":905,"./hover":906,"./plot":908,"./select":909,"./style":910}],908:[function(_dereq_,module,exports){ +},{"../../plots/geo":771,"../heatmap/colorbar":945,"./attributes":899,"./calc":900,"./defaults":901,"./event_data":902,"./hover":903,"./plot":905,"./select":906,"./style":907}],905:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146939,7 +149396,7 @@ function feature2polygons(feature) { return polygons; } -},{"../../lib":696,"../../lib/geo_location_utils":688,"../../lib/polygon":708,"../../lib/topojson_utils":723,"./style":910,"d3":148}],909:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/geo_location_utils":685,"../../lib/polygon":704,"../../lib/topojson_utils":719,"./style":907,"d3":148}],906:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146988,7 +149445,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],910:[function(_dereq_,module,exports){ +},{}],907:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147016,11 +149473,7 @@ function styleTrace(gd, calcTrace) { var markerLine = marker.line || {}; var sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - trace.colorscale, - trace.zmin, - trace.zmax - ) + Colorscale.extractScale(trace, {cLetter: 'z'}) ); locs.each(function(d) { @@ -147050,7 +149503,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/color":570,"../../components/colorscale":585,"../../components/drawing":595,"d3":148}],911:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/colorscale":581,"../../components/drawing":590,"d3":148}],908:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147237,7 +149690,7 @@ attrs.transforms = undefined; module.exports = attrs; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../mesh3d/attributes":986}],912:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../mesh3d/attributes":983}],909:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147274,10 +149727,14 @@ module.exports = function calc(gd, trace) { trace._len = len; trace._normMax = normMax; - colorscaleCalc(trace, [normMin, normMax], '', 'c'); + colorscaleCalc(gd, trace, { + vals: [normMin, normMax], + containerStr: '', + cLetter: 'c' + }); }; -},{"../../components/colorscale/calc":578}],913:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577}],910:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147422,7 +149879,7 @@ function createConeTrace(scene, data) { module.exports = createConeTrace; -},{"../../lib":696,"../../lib/gl_format_color":692,"../../plots/gl3d/zip3":798,"gl-cone3d":231}],914:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gl_format_color":689,"../../plots/gl3d/zip3":794,"gl-cone3d":231}],911:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147482,7 +149939,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"./attributes":911}],915:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"./attributes":908}],912:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147521,7 +149978,7 @@ module.exports = { } }; -},{"../../plots/gl3d":787,"./attributes":911,"./calc":912,"./convert":913,"./defaults":914}],916:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":783,"./attributes":908,"./calc":909,"./convert":910,"./defaults":911}],913:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147781,7 +150238,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../components/drawing/attributes":594,"../../constants/filter_ops":669,"../../lib/extend":685,"../../plots/font_attributes":771,"../heatmap/attributes":945,"../scatter/attributes":1043}],917:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../components/drawing/attributes":589,"../../constants/filter_ops":665,"../../lib/extend":682,"../../plots/font_attributes":767,"../heatmap/attributes":942,"../scatter/attributes":1040}],914:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147805,7 +150262,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../heatmap/calc":946,"./set_contours":935}],918:[function(_dereq_,module,exports){ +},{"../heatmap/calc":943,"./set_contours":932}],915:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147872,7 +150329,7 @@ module.exports = function(pathinfo, operation, perimeter, trace) { } }; -},{}],919:[function(_dereq_,module,exports){ +},{}],916:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147923,7 +150380,7 @@ module.exports = function colorbar(gd, cd) { .options(trace.colorbar)(); }; -},{"../../components/colorbar/draw":575,"./end_plus":927,"./make_color_map":932}],920:[function(_dereq_,module,exports){ +},{"../../components/colorbar/draw":574,"./end_plus":924,"./make_color_map":929}],917:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148001,7 +150458,7 @@ module.exports = { } }; -},{}],921:[function(_dereq_,module,exports){ +},{}],918:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148096,7 +150553,7 @@ function handleConstraintValueDefaults(coerce, contours) { } } -},{"../../components/color":570,"../../constants/filter_ops":669,"./label_defaults":931,"fast-isnumeric":214}],922:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../constants/filter_ops":665,"./label_defaults":928,"fast-isnumeric":214}],919:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148175,7 +150632,7 @@ function makeInequalitySettings(operation) { }; } -},{"../../constants/filter_ops":669,"fast-isnumeric":214}],923:[function(_dereq_,module,exports){ +},{"../../constants/filter_ops":665,"fast-isnumeric":214}],920:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148204,7 +150661,7 @@ module.exports = function handleContourDefaults(traceIn, traceOut, coerce, coerc if(autoContour || !contourSize) coerce('ncontours'); }; -},{}],924:[function(_dereq_,module,exports){ +},{}],921:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148292,7 +150749,7 @@ function copyPathinfo(pi) { }); } -},{"../../lib":696}],925:[function(_dereq_,module,exports){ +},{"../../lib":692}],922:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148341,7 +150798,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../lib":696,"../heatmap/xyz_defaults":960,"./attributes":916,"./constraint_defaults":921,"./contours_defaults":923,"./style_defaults":937}],926:[function(_dereq_,module,exports){ +},{"../../lib":692,"../heatmap/xyz_defaults":956,"./attributes":913,"./constraint_defaults":918,"./contours_defaults":920,"./style_defaults":934}],923:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148405,7 +150862,7 @@ module.exports = function emptyPathinfo(contours, plotinfo, cd0) { return pathinfo; }; -},{"../../lib":696,"./constraint_mapping":922,"./end_plus":927}],927:[function(_dereq_,module,exports){ +},{"../../lib":692,"./constraint_mapping":919,"./end_plus":924}],924:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148425,7 +150882,7 @@ module.exports = function endPlus(contours) { return contours.end + contours.size / 1e6; }; -},{}],928:[function(_dereq_,module,exports){ +},{}],925:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148725,7 +151182,7 @@ function getInterpPx(pi, loc, step) { } } -},{"../../lib":696,"./constants":920}],929:[function(_dereq_,module,exports){ +},{"../../lib":692,"./constants":917}],926:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148761,7 +151218,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return hoverData; }; -},{"../../components/color":570,"../heatmap/hover":952}],930:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../heatmap/hover":949}],927:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148802,7 +151259,7 @@ Contour.meta = { module.exports = Contour; -},{"../../plots/cartesian":756,"./attributes":916,"./calc":917,"./colorbar":919,"./defaults":925,"./hover":929,"./plot":934,"./style":936}],931:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":913,"./calc":914,"./colorbar":916,"./defaults":922,"./hover":926,"./plot":931,"./style":933}],928:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148832,7 +151289,7 @@ module.exports = function handleLabelDefaults(coerce, layout, lineColor, opts) { if(opts.hasHover !== false) coerce('zhoverformat'); }; -},{"../../lib":696}],932:[function(_dereq_,module,exports){ +},{"../../lib":692}],929:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148861,11 +151318,13 @@ module.exports = function makeColorMap(trace) { nc = 1; } - var scl = trace.colorscale, - len = scl.length; + var scl = trace.reversescale ? + Colorscale.flipScale(trace.colorscale) : + trace.colorscale; - var domain = new Array(len), - range = new Array(len); + var len = scl.length; + var domain = new Array(len); + var range = new Array(len); var si, i; @@ -148916,7 +151375,7 @@ module.exports = function makeColorMap(trace) { }); }; -},{"../../components/colorscale":585,"./end_plus":927,"d3":148}],933:[function(_dereq_,module,exports){ +},{"../../components/colorscale":581,"./end_plus":924,"d3":148}],930:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149008,7 +151467,7 @@ function getMarchingIndex(val, corners) { return (mi === 15) ? 0 : mi; } -},{"./constants":920}],934:[function(_dereq_,module,exports){ +},{"./constants":917}],931:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149040,7 +151499,6 @@ var costConstants = constants.LABELOPTIMIZER; exports.plot = function plot(gd, plotinfo, cdcontours, contourLayer) { var xa = plotinfo.xaxis; var ya = plotinfo.yaxis; - var fullLayout = gd._fullLayout; Lib.makeTraceGroups(contourLayer, cdcontours, 'contour').each(function(cd) { var plotGroup = d3.select(this); @@ -149089,7 +151547,7 @@ exports.plot = function plot(gd, plotinfo, cdcontours, contourLayer) { makeBackground(plotGroup, perimeter, contours); makeFills(plotGroup, fillPathinfo, perimeter, contours); makeLinesAndLabels(plotGroup, pathinfo, gd, cd0, contours, perimeter); - clipGaps(plotGroup, plotinfo, fullLayout._clips, cd0, perimeter); + clipGaps(plotGroup, plotinfo, gd, cd0, perimeter); }); }; @@ -149241,8 +151699,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) { // In this case we'll remove the lines after making the labels. var linegroup = exports.createLines(lineContainer, showLines || showLabels, pathinfo); - var lineClip = exports.createLineClip(lineContainer, clipLinesForLabels, - gd._fullLayout._clips, cd0.trace.uid); + var lineClip = exports.createLineClip(lineContainer, clipLinesForLabels, gd, cd0.trace.uid); var labelGroup = plotgroup.selectAll('g.contourlabels') .data(showLabels ? [0] : []); @@ -149266,17 +151723,37 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) { .attr('data-notex', 1) .call(Drawing.font, contours.labelfont); - var xLen = pathinfo[0].xaxis._length; - var yLen = pathinfo[0].yaxis._length; + var xa = pathinfo[0].xaxis; + var ya = pathinfo[0].yaxis; + var xLen = xa._length; + var yLen = ya._length; + var xRng = xa.range; + var yRng = ya.range; + var x0 = Math.max(perimeter[0][0], 0); + var x1 = Math.min(perimeter[2][0], xLen); + var y0 = Math.max(perimeter[0][1], 0); + var y1 = Math.min(perimeter[2][1], yLen); // visible bounds of the contour trace (and the midpoints, to // help with cost calculations) - var bounds = { - left: Math.max(perimeter[0][0], 0), - right: Math.min(perimeter[2][0], xLen), - top: Math.max(perimeter[0][1], 0), - bottom: Math.min(perimeter[2][1], yLen) - }; + var bounds = {}; + + if(xRng[0] < xRng[1]) { + bounds.left = x0; + bounds.right = x1; + } else { + bounds.left = x1; + bounds.right = x0; + } + + if(yRng[0] < yRng[1]) { + bounds.top = y0; + bounds.bottom = y1; + } else { + bounds.top = y1; + bounds.bottom = y0; + } + bounds.middle = (bounds.top + bounds.bottom) / 2; bounds.center = (bounds.left + bounds.right) / 2; @@ -149364,7 +151841,8 @@ exports.createLines = function(lineContainer, makeLines, pathinfo) { return linegroup; }; -exports.createLineClip = function(lineContainer, clipLinesForLabels, clips, uid) { +exports.createLineClip = function(lineContainer, clipLinesForLabels, gd, uid) { + var clips = gd._fullLayout._clips; var clipId = clipLinesForLabels ? ('clipline' + uid) : null; var lineClip = clips.selectAll('#' + clipId) @@ -149375,7 +151853,7 @@ exports.createLineClip = function(lineContainer, clipLinesForLabels, clips, uid) .classed('contourlineclip', true) .attr('id', clipId); - Drawing.setClipUrl(lineContainer, clipId); + Drawing.setClipUrl(lineContainer, clipId, gd); return lineClip; }; @@ -149606,7 +152084,8 @@ exports.drawLabels = function(labelGroup, labelData, gd, lineClip, labelClipPath } }; -function clipGaps(plotGroup, plotinfo, clips, cd0, perimeter) { +function clipGaps(plotGroup, plotinfo, gd, cd0, perimeter) { + var clips = gd._fullLayout._clips; var clipId = 'clip' + cd0.trace.uid; var clipPath = clips.selectAll('#' + clipId) @@ -149645,7 +152124,7 @@ function clipGaps(plotGroup, plotinfo, clips, cd0, perimeter) { } else clipId = null; - plotGroup.call(Drawing.setClipUrl, clipId); + Drawing.setClipUrl(plotGroup, clipId, gd); } function makeClipMask(cd0) { @@ -149668,7 +152147,7 @@ function makeClipMask(cd0) { return z; } -},{"../../components/drawing":595,"../../lib":696,"../../lib/svg_text_utils":720,"../../plots/cartesian/axes":744,"../../plots/cartesian/set_convert":763,"../heatmap/plot":957,"./close_boundaries":918,"./constants":920,"./convert_to_constraints":924,"./empty_pathinfo":926,"./find_all_paths":928,"./make_crossings":933,"d3":148}],935:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../../lib/svg_text_utils":716,"../../plots/cartesian/axes":740,"../../plots/cartesian/set_convert":759,"../heatmap/plot":953,"./close_boundaries":915,"./constants":917,"./convert_to_constraints":921,"./empty_pathinfo":923,"./find_all_paths":925,"./make_crossings":930,"d3":148}],932:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149772,7 +152251,7 @@ function autoContours(start, end, ncontours) { return dummyAx; } -},{"../../lib":696,"../../plots/cartesian/axes":744}],936:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740}],933:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149854,7 +152333,7 @@ module.exports = function style(gd) { heatmapStyle(gd); }; -},{"../../components/drawing":595,"../heatmap/style":958,"./make_color_map":932,"d3":148}],937:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../heatmap/style":954,"./make_color_map":929,"d3":148}],934:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149899,7 +152378,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, layout, handleLabelDefaults(coerce, layout, lineColor, opts); }; -},{"../../components/colorscale/defaults":580,"./label_defaults":931}],938:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"./label_defaults":928}],935:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150003,7 +152482,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../contour/attributes":916,"../heatmap/attributes":945,"../scatter/attributes":1043}],939:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../contour/attributes":913,"../heatmap/attributes":942,"../scatter/attributes":1040}],936:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150015,11 +152494,10 @@ module.exports = extendFlat({ 'use strict'; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); -var isArray1D = _dereq_('../../lib').isArray1D; +var Lib = _dereq_('../../lib'); var convertColumnData = _dereq_('../heatmap/convert_column_xyz'); var clean2dArray = _dereq_('../heatmap/clean_2d_array'); -var maxRowLength = _dereq_('../heatmap/max_row_length'); var interp2d = _dereq_('../heatmap/interp2d'); var findEmpties = _dereq_('../heatmap/find_empties'); var makeBoundArray = _dereq_('../heatmap/make_bound_array'); @@ -150076,7 +152554,7 @@ function heatmappishCalc(gd, trace) { aax._minDtick = 0; bax._minDtick = 0; - if(isArray1D(trace.z)) convertColumnData(trace, aax, bax, 'a', 'b', ['z']); + if(Lib.isArray1D(trace.z)) convertColumnData(trace, aax, bax, 'a', 'b', ['z']); a = trace._a = trace._a || trace.a; b = trace._b = trace._b || trace.b; @@ -150093,7 +152571,7 @@ function heatmappishCalc(gd, trace) { interp2d(z, trace._emptypoints); // create arrays of brick boundaries, to be used by autorange and heatmap.plot - var xlen = maxRowLength(z), + var xlen = Lib.maxRowLength(z), xIn = trace.xtype === 'scaled' ? '' : a, xArray = makeBoundArray(trace, xIn, a0, da, xlen, aax), yIn = trace.ytype === 'scaled' ? '' : b, @@ -150107,13 +152585,17 @@ function heatmappishCalc(gd, trace) { if(trace.contours.type === 'levels' && trace.contours.coloring !== 'none') { // auto-z and autocolorscale if applicable - colorscaleCalc(trace, z, '', 'z'); + colorscaleCalc(gd, trace, { + vals: z, + containerStr: '', + cLetter: 'z' + }); } return [cd0]; } -},{"../../components/colorscale/calc":578,"../../lib":696,"../carpet/lookup_carpetid":894,"../contour/set_contours":935,"../heatmap/clean_2d_array":947,"../heatmap/convert_column_xyz":949,"../heatmap/find_empties":951,"../heatmap/interp2d":954,"../heatmap/make_bound_array":955,"../heatmap/max_row_length":956,"./defaults":940}],940:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../lib":692,"../carpet/lookup_carpetid":891,"../contour/set_contours":932,"../heatmap/clean_2d_array":944,"../heatmap/convert_column_xyz":946,"../heatmap/find_empties":948,"../heatmap/interp2d":951,"../heatmap/make_bound_array":952,"./defaults":937}],937:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150183,7 +152665,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../lib":696,"../contour/constraint_defaults":921,"../contour/contours_defaults":923,"../contour/style_defaults":937,"../heatmap/xyz_defaults":960,"./attributes":938}],941:[function(_dereq_,module,exports){ +},{"../../lib":692,"../contour/constraint_defaults":918,"../contour/contours_defaults":920,"../contour/style_defaults":934,"../heatmap/xyz_defaults":956,"./attributes":935}],938:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150219,7 +152701,7 @@ ContourCarpet.meta = { module.exports = ContourCarpet; -},{"../../plots/cartesian":756,"../contour/colorbar":919,"../contour/style":936,"./attributes":938,"./calc":939,"./defaults":940,"./plot":944}],942:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../contour/colorbar":916,"../contour/style":933,"./attributes":935,"./calc":936,"./defaults":937,"./plot":941}],939:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150353,7 +152835,7 @@ module.exports = function joinAllPaths(trace, pi, perimeter, ab2p, carpet, carpe return fullpath; }; -},{"../../components/drawing":595,"../../lib":696,"../carpet/axis_aligned_line":878}],943:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../carpet/axis_aligned_line":875}],940:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150390,7 +152872,7 @@ module.exports = function mapPathinfo(pathinfo, map) { } }; -},{}],944:[function(_dereq_,module,exports){ +},{}],941:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150506,7 +152988,7 @@ module.exports = function plot(gd, plotinfo, cdcontours, contourcarpetLayer) { makeLinesAndLabels(plotGroup, pathinfo, gd, cd0, contours, plotinfo, carpet); // Clip the boundary of the plot - Drawing.setClipUrl(plotGroup, carpet._clipPathId); + Drawing.setClipUrl(plotGroup, carpet._clipPathId, gd); }); }; @@ -150522,8 +153004,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, plotinfo, ca // In this case we'll remove the lines after making the labels. var linegroup = contourPlot.createLines(lineContainer, showLines || showLabels, pathinfo); - var lineClip = contourPlot.createLineClip(lineContainer, clipLinesForLabels, - gd._fullLayout._defs, cd0.trace.uid); + var lineClip = contourPlot.createLineClip(lineContainer, clipLinesForLabels, gd, cd0.trace.uid); var labelGroup = plotgroup.selectAll('g.contourlabels') .data(showLabels ? [0] : []); @@ -150725,7 +153206,7 @@ function makeFills(trace, plotgroup, xa, ya, pathinfo, perimeter, ab2p, carpet, }); } -},{"../../components/drawing":595,"../../lib":696,"../carpet/lookup_carpetid":894,"../carpet/makepath":895,"../carpet/map_1d_array":896,"../contour/close_boundaries":918,"../contour/constants":920,"../contour/convert_to_constraints":924,"../contour/empty_pathinfo":926,"../contour/find_all_paths":928,"../contour/make_crossings":933,"../contour/plot":934,"./join_all_paths":942,"./map_pathinfo":943,"d3":148}],945:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../carpet/lookup_carpetid":891,"../carpet/makepath":892,"../carpet/map_1d_array":893,"../contour/close_boundaries":915,"../contour/constants":917,"../contour/convert_to_constraints":921,"../contour/empty_pathinfo":923,"../contour/find_all_paths":925,"../contour/make_crossings":930,"../contour/plot":931,"./join_all_paths":939,"./map_pathinfo":940,"d3":148}],942:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150848,7 +153329,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../scatter/attributes":1043}],946:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../scatter/attributes":1040}],943:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150867,7 +153348,6 @@ var Axes = _dereq_('../../plots/cartesian/axes'); var histogram2dCalc = _dereq_('../histogram2d/calc'); var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var convertColumnData = _dereq_('./convert_column_xyz'); -var maxRowLength = _dereq_('./max_row_length'); var clean2dArray = _dereq_('./clean_2d_array'); var interp2d = _dereq_('./interp2d'); var findEmpties = _dereq_('./find_empties'); @@ -150967,7 +153447,7 @@ module.exports = function calc(gd, trace) { } // create arrays of brick boundaries, to be used by autorange and heatmap.plot - var xlen = maxRowLength(z); + var xlen = Lib.maxRowLength(z); var xIn = trace.xtype === 'scaled' ? '' : x; var xArray = makeBoundArray(trace, xIn, x0, dx, xlen, xa); var yIn = trace.ytype === 'scaled' ? '' : y; @@ -150997,7 +153477,11 @@ module.exports = function calc(gd, trace) { // auto-z and autocolorscale if applicable if(!isContour || trace.contours.type !== 'constraint') { - colorscaleCalc(trace, z, '', 'z'); + colorscaleCalc(gd, trace, { + vals: z, + containerStr: '', + cLetter: 'z' + }); } if(isContour && trace.contours && trace.contours.coloring === 'heatmap') { @@ -151013,7 +153497,7 @@ module.exports = function calc(gd, trace) { return [cd0]; }; -},{"../../components/colorscale/calc":578,"../../lib":696,"../../plots/cartesian/axes":744,"../../registry":827,"../histogram2d/calc":977,"./clean_2d_array":947,"./convert_column_xyz":949,"./find_empties":951,"./interp2d":954,"./make_bound_array":955,"./max_row_length":956}],947:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../lib":692,"../../plots/cartesian/axes":740,"../../registry":823,"../histogram2d/calc":974,"./clean_2d_array":944,"./convert_column_xyz":946,"./find_empties":948,"./interp2d":951,"./make_bound_array":952}],944:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151058,7 +153542,7 @@ module.exports = function clean2dArray(zOld, transpose) { return zNew; }; -},{"fast-isnumeric":214}],948:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214}],945:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151074,7 +153558,7 @@ module.exports = { max: 'zmax' }; -},{}],949:[function(_dereq_,module,exports){ +},{}],946:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151091,43 +153575,36 @@ var BADNUM = _dereq_('../../constants/numerical').BADNUM; module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, arrayVarNames) { var colLen = trace._length; - var col1 = trace[var1Name].slice(0, colLen); - var col2 = trace[var2Name].slice(0, colLen); + var col1 = ax1.makeCalcdata(trace, var1Name); + var col2 = ax2.makeCalcdata(trace, var2Name); var textCol = trace.text; var hasColumnText = (textCol !== undefined && Lib.isArray1D(textCol)); - var col1Calendar = trace[var1Name + 'calendar']; - var col2Calendar = trace[var2Name + 'calendar']; - - var i, j, arrayVar, newArray, arrayVarName; - - for(i = 0; i < colLen; i++) { - col1[i] = ax1.d2c(col1[i], 0, col1Calendar); - col2[i] = ax2.d2c(col2[i], 0, col2Calendar); - } + var i, j; - var col1dv = Lib.distinctVals(col1), - col1vals = col1dv.vals, - col2dv = Lib.distinctVals(col2), - col2vals = col2dv.vals, - newArrays = []; + var col1dv = Lib.distinctVals(col1); + var col1vals = col1dv.vals; + var col2dv = Lib.distinctVals(col2); + var col2vals = col2dv.vals; + var newArrays = []; + var text; for(i = 0; i < arrayVarNames.length; i++) { newArrays[i] = Lib.init2dArray(col2vals.length, col1vals.length); } - var i1, i2, text; - - if(hasColumnText) text = Lib.init2dArray(col2vals.length, col1vals.length); + if(hasColumnText) { + text = Lib.init2dArray(col2vals.length, col1vals.length); + } for(i = 0; i < colLen; i++) { if(col1[i] !== BADNUM && col2[i] !== BADNUM) { - i1 = Lib.findBin(col1[i] + col1dv.minDiff / 2, col1vals); - i2 = Lib.findBin(col2[i] + col2dv.minDiff / 2, col2vals); + var i1 = Lib.findBin(col1[i] + col1dv.minDiff / 2, col1vals); + var i2 = Lib.findBin(col2[i] + col2dv.minDiff / 2, col2vals); for(j = 0; j < arrayVarNames.length; j++) { - arrayVarName = arrayVarNames[j]; - arrayVar = trace[arrayVarName]; - newArray = newArrays[j]; + var arrayVarName = arrayVarNames[j]; + var arrayVar = trace[arrayVarName]; + var newArray = newArrays[j]; newArray[i2][i1] = arrayVar[i]; } @@ -151143,7 +153620,7 @@ module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, if(hasColumnText) trace._text = text; }; -},{"../../constants/numerical":673,"../../lib":696}],950:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692}],947:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151183,7 +153660,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}); }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"./attributes":945,"./style_defaults":959,"./xyz_defaults":960}],951:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"./attributes":942,"./style_defaults":955,"./xyz_defaults":956}],948:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151194,7 +153671,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout 'use strict'; -var maxRowLength = _dereq_('./max_row_length'); +var maxRowLength = _dereq_('../../lib').maxRowLength; /* Return a list of empty points in 2D array z * each empty point z[i][j] gives an array [i, j, neighborCount] @@ -151289,7 +153766,7 @@ module.exports = function findEmpties(z) { return empties.sort(function(a, b) { return b[2] - a[2]; }); }; -},{"./max_row_length":956}],952:[function(_dereq_,module,exports){ +},{"../../lib":692}],949:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151418,7 +153895,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay })]; }; -},{"../../components/fx":612,"../../lib":696,"../../plots/cartesian/axes":744}],953:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../lib":692,"../../plots/cartesian/axes":740}],950:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151473,7 +153950,7 @@ Heatmap.meta = { module.exports = Heatmap; -},{"../../plots/cartesian":756,"./attributes":945,"./calc":946,"./colorbar":948,"./defaults":950,"./hover":952,"./plot":957,"./style":958}],954:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":942,"./calc":943,"./colorbar":945,"./defaults":947,"./hover":949,"./plot":953,"./style":954}],951:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151608,7 +154085,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { return maxFractionalChange; } -},{"../../lib":696}],955:[function(_dereq_,module,exports){ +},{"../../lib":692}],952:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151678,10 +154155,15 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, var calendar = trace[ax._id.charAt(0) + 'calendar']; - if(isHist || ax.type === 'category') v0 = ax.r2c(v0In, 0, calendar) || 0; - else if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) v0 = arrayIn[0]; - else if(v0In === undefined) v0 = 0; - else v0 = ax.d2c(v0In, 0, calendar); + if(isHist || ax.type === 'category' || ax.type === 'multicategory') { + v0 = ax.r2c(v0In, 0, calendar) || 0; + } else if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) { + v0 = arrayIn[0]; + } else if(v0In === undefined) { + v0 = 0; + } else { + v0 = ax.d2c(v0In, 0, calendar); + } for(i = (isContour || isGL2D) ? 0 : -0.5; i < numbricks; i++) { arrayOut.push(v0 + dv * i); @@ -151691,29 +154173,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, return arrayOut; }; -},{"../../lib":696,"../../registry":827}],956:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function maxRowLength(z) { - var len = 0; - - for(var i = 0; i < z.length; i++) { - len = Math.max(len, z[i].length); - } - - return len; -}; - -},{}],957:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],953:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151733,8 +154193,6 @@ var Lib = _dereq_('../../lib'); var Colorscale = _dereq_('../../components/colorscale'); var xmlnsNamespaces = _dereq_('../../constants/xmlns_namespaces'); -var maxRowLength = _dereq_('./max_row_length'); - module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { var xa = plotinfo.xaxis; var ya = plotinfo.yaxis; @@ -151754,7 +154212,7 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { // get z dims var m = z.length; - var n = maxRowLength(z); + var n = Lib.maxRowLength(z); var xrev = false; var yrev = false; @@ -151859,11 +154317,7 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { var context = canvas.getContext('2d'); var sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - trace.colorscale, - trace.zmin, - trace.zmax - ), + Colorscale.extractScale(trace, {cLetter: 'z'}), { noNumericCheck: true, returnArray: true } ); @@ -152134,7 +154588,7 @@ function putColor(pixels, pxIndex, c) { pixels[pxIndex + 3] = Math.round(c[3] * 255); } -},{"../../components/colorscale":585,"../../constants/xmlns_namespaces":674,"../../lib":696,"../../registry":827,"./max_row_length":956,"d3":148,"tinycolor2":514}],958:[function(_dereq_,module,exports){ +},{"../../components/colorscale":581,"../../constants/xmlns_namespaces":670,"../../lib":692,"../../registry":823,"d3":148,"tinycolor2":513}],954:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152155,7 +154609,7 @@ module.exports = function style(gd) { }); }; -},{"d3":148}],959:[function(_dereq_,module,exports){ +},{"d3":148}],955:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152178,7 +154632,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { coerce('zhoverformat'); }; -},{}],960:[function(_dereq_,module,exports){ +},{}],956:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152187,7 +154641,6 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -152207,10 +154660,13 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x x = coerce(xName); y = coerce(yName); + var xlen = Lib.minRowLength(x); + var ylen = Lib.minRowLength(y); + // column z must be accompanied by xName and yName arrays - if(!(x && x.length && y && y.length)) return 0; + if(xlen === 0 || ylen === 0) return 0; - traceOut._length = Math.min(x.length, y.length, z.length); + traceOut._length = Math.min(xlen, ylen, z.length); } else { x = coordDefaults(xName, coerce); @@ -152231,10 +154687,8 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x }; function coordDefaults(coordStr, coerce) { - var coord = coerce(coordStr), - coordType = coord ? - coerce(coordStr + 'type', 'array') : - 'scaled'; + var coord = coerce(coordStr); + var coordType = coord ? coerce(coordStr + 'type', 'array') : 'scaled'; if(coordType === 'scaled') { coerce(coordStr + '0'); @@ -152276,7 +154730,7 @@ function isValidZ(z) { return (allRowsAreArrays && oneRowIsFilled && hasOneNumber); } -},{"../../lib":696,"../../registry":827,"fast-isnumeric":214}],961:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"fast-isnumeric":214}],957:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152319,7 +154773,7 @@ extendFlat( module.exports = overrideAll(attrs, 'calc', 'nested'); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/edit_types":727,"../heatmap/attributes":945}],962:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/edit_types":723,"../heatmap/attributes":942}],958:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152461,7 +154915,7 @@ function createHeatmap(scene, fullTrace, calcTrace) { module.exports = createHeatmap; -},{"../../lib/str2rgbarray":719,"../../plots/cartesian/axes":744,"gl-heatmap2d":241}],963:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":715,"../../plots/cartesian/axes":740,"gl-heatmap2d":241}],959:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152494,7 +154948,7 @@ HeatmapGl.meta = { module.exports = HeatmapGl; -},{"../../plots/gl2d":784,"../heatmap/calc":946,"../heatmap/colorbar":948,"../heatmap/defaults":950,"./attributes":961,"./convert":962}],964:[function(_dereq_,module,exports){ +},{"../../plots/gl2d":780,"../heatmap/calc":943,"../heatmap/colorbar":945,"../heatmap/defaults":947,"./attributes":957,"./convert":958}],960:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152506,7 +154960,9 @@ module.exports = HeatmapGl; 'use strict'; var barAttrs = _dereq_('../bar/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var makeBinAttrs = _dereq_('./bin_attributes'); +var constants = _dereq_('./constants'); module.exports = { x: { @@ -152669,11 +155125,6 @@ module.exports = { dflt: null, role: 'style', editType: 'calc', - impliedEdits: { - 'ybins.start': undefined, - 'ybins.end': undefined, - 'ybins.size': undefined - }, description: [ 'Obsolete: since v1.42 each bin attribute is auto-determined', 'separately and `autobiny` is not needed. However, we accept', @@ -152682,6 +155133,10 @@ module.exports = { ].join(' ') }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), + marker: barAttrs.marker, selected: barAttrs.selected, @@ -152692,7 +155147,7 @@ module.exports = { } }; -},{"../bar/attributes":837,"./bin_attributes":966}],965:[function(_dereq_,module,exports){ +},{"../../components/fx/hovertemplate_attributes":607,"../bar/attributes":833,"./bin_attributes":962,"./constants":966}],961:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152718,7 +155173,7 @@ module.exports = function doAvg(size, counts) { return total; }; -},{}],966:[function(_dereq_,module,exports){ +},{}],962:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152794,7 +155249,7 @@ module.exports = function makeBinAttrs(axLetter, match) { }; }; -},{}],967:[function(_dereq_,module,exports){ +},{}],963:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152870,7 +155325,7 @@ module.exports = { } }; -},{"fast-isnumeric":214}],968:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214}],964:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153048,7 +155503,7 @@ function dateParts(v, pa, calendar) { return parts; } -},{"../../constants/numerical":673,"../../plots/cartesian/axes":744}],969:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../plots/cartesian/axes":740}],965:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153302,16 +155757,18 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { var isFirstVisible = true; for(i = 0; i < traces.length; i++) { tracei = traces[i]; - pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData); - allPos = Lib.concat(allPos, pos0); - delete tracei._autoBinFinished; - if(trace.visible === true) { - if(isFirstVisible) { - isFirstVisible = false; - } - else { - delete tracei._autoBin; - tracei._autoBinFinished = 1; + if(tracei.visible) { + pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData); + allPos = Lib.concat(allPos, pos0); + delete tracei._autoBinFinished; + if(trace.visible === true) { + if(isFirstVisible) { + isFirstVisible = false; + } + else { + delete tracei._autoBin; + tracei._autoBinFinished = 1; + } } } } @@ -153321,7 +155778,8 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { // Edge case: single-valued histogram overlaying others // Use them all together to calculate the bin size for the single-valued one - if(isOverlay && newBinSpec._dataSpan === 0 && pa.type !== 'category') { + if(isOverlay && newBinSpec._dataSpan === 0 && + pa.type !== 'category' && pa.type !== 'multicategory') { // Several single-valued histograms! Stop infinite recursion, // just return an extra flag that tells handleSingleValueOverlays // to sort out this trace too @@ -153378,7 +155836,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { Lib.aggNums(Math.min, null, pos0); var dummyAx = { - type: pa.type === 'category' ? 'linear' : pa.type, + type: (pa.type === 'category' || pa.type === 'multicategory') ? 'linear' : pa.type, r2l: pa.r2l, dtick: binOpts.size, tick0: mainStart, @@ -153578,7 +156036,23 @@ function cdf(size, direction, currentBin) { } } -},{"../../lib":696,"../../plots/cartesian/axes":744,"../bar/arrays_to_calcdata":836,"./average":965,"./bin_functions":967,"./bin_label_vals":968,"./norm_functions":975,"fast-isnumeric":214}],970:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../bar/arrays_to_calcdata":832,"./average":961,"./bin_functions":963,"./bin_label_vals":964,"./norm_functions":972,"fast-isnumeric":214}],966:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + eventDataKeys: ['binNumber'] +}; + +},{}],967:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153692,7 +156166,7 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) { } }; -},{"../../lib":696,"./attributes":964}],971:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":960}],968:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153731,7 +156205,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var sampleLetter = orientation === 'v' ? 'x' : 'y'; var aggLetter = orientation === 'v' ? 'y' : 'x'; - var len = (x && y) ? Math.min(x.length && y.length) : (traceOut[sampleLetter] || []).length; + var len = (x && y) ? + Math.min(Lib.minRowLength(x) && Lib.minRowLength(y)) : + Lib.minRowLength(traceOut[sampleLetter] || []); if(!len) { traceOut.visible = false; @@ -153751,6 +156227,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout // autobin(x|y) are only included here to appease Plotly.validate coerce('autobin' + sampleLetter); + coerce('hovertemplate'); + handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout); // override defaultColor for error bars with defaultLine @@ -153761,7 +156239,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/color":570,"../../lib":696,"../../registry":827,"../bar/style_defaults":850,"./attributes":964}],972:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../registry":823,"../bar/style_defaults":847,"./attributes":960}],969:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153807,7 +156285,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],973:[function(_dereq_,module,exports){ +},{}],970:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153837,10 +156315,12 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { pointData[posLetter + 'Label'] = hoverLabelText(pointData[posLetter + 'a'], di.ph0, di.ph1); } + if(trace.hovermplate) pointData.hovertemplate = trace.hovertemplate; + return pts; }; -},{"../../plots/cartesian/axes":744,"../bar/hover":842}],974:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../bar/hover":839}],971:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153900,7 +156380,7 @@ Histogram.meta = { module.exports = Histogram; -},{"../../plots/cartesian":756,"../bar/cross_trace_calc":839,"../bar/layout_attributes":844,"../bar/layout_defaults":845,"../bar/plot":846,"../bar/select":847,"../bar/style":849,"../scatter/marker_colorbar":1061,"./attributes":964,"./calc":969,"./cross_trace_defaults":970,"./defaults":971,"./event_data":972,"./hover":973}],975:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../bar/cross_trace_calc":836,"../bar/layout_attributes":841,"../bar/layout_defaults":842,"../bar/plot":843,"../bar/select":844,"../bar/style":846,"../scatter/marker_colorbar":1058,"./attributes":960,"./calc":965,"./cross_trace_defaults":967,"./defaults":968,"./event_data":969,"./hover":970}],972:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153935,7 +156415,7 @@ module.exports = { } }; -},{}],976:[function(_dereq_,module,exports){ +},{}],973:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153994,7 +156474,7 @@ module.exports = extendFlat( { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../heatmap/attributes":945,"../histogram/attributes":964,"../histogram/bin_attributes":966}],977:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../heatmap/attributes":942,"../histogram/attributes":960,"../histogram/bin_attributes":962}],974:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154259,7 +156739,7 @@ function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) { return out; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"../histogram/average":965,"../histogram/bin_functions":967,"../histogram/bin_label_vals":968,"../histogram/norm_functions":975}],978:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../histogram/average":961,"../histogram/bin_functions":963,"../histogram/bin_label_vals":964,"../histogram/norm_functions":972}],975:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154354,7 +156834,7 @@ function cleanBins(trace, binDirection, fullLayout, autoBins) { } } -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axis_ids":747,"./attributes":976,"fast-isnumeric":214}],979:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axis_ids":743,"./attributes":973,"fast-isnumeric":214}],976:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154388,7 +156868,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout ); }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"../heatmap/style_defaults":959,"./attributes":976,"./sample_defaults":982}],980:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"../heatmap/style_defaults":955,"./attributes":973,"./sample_defaults":979}],977:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154422,7 +156902,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return pts; }; -},{"../../plots/cartesian/axes":744,"../heatmap/hover":952}],981:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../heatmap/hover":949}],978:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154465,7 +156945,7 @@ Histogram2D.meta = { module.exports = Histogram2D; -},{"../../plots/cartesian":756,"../heatmap/calc":946,"../heatmap/colorbar":948,"../heatmap/plot":957,"../heatmap/style":958,"../histogram/event_data":972,"./attributes":976,"./cross_trace_defaults":978,"./defaults":979,"./hover":980}],982:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../heatmap/calc":943,"../heatmap/colorbar":945,"../heatmap/plot":953,"../heatmap/style":954,"../histogram/event_data":969,"./attributes":973,"./cross_trace_defaults":975,"./defaults":976,"./hover":977}],979:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154474,24 +156954,26 @@ module.exports = Histogram2D; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Registry = _dereq_('../../registry'); +var Lib = _dereq_('../../lib'); module.exports = function handleSampleDefaults(traceIn, traceOut, coerce, layout) { var x = coerce('x'); var y = coerce('y'); + var xlen = Lib.minRowLength(x); + var ylen = Lib.minRowLength(y); // we could try to accept x0 and dx, etc... // but that's a pretty weird use case. // for now require both x and y explicitly specified. - if(!(x && x.length && y && y.length)) { + if(!xlen || !ylen) { traceOut.visible = false; return; } - traceOut._length = Math.min(x.length, y.length); + traceOut._length = Math.min(xlen, ylen); var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); @@ -154508,7 +156990,7 @@ module.exports = function handleSampleDefaults(traceIn, traceOut, coerce, layout coerce('autobiny'); }; -},{"../../registry":827}],983:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],980:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154554,7 +157036,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../contour/attributes":916,"../histogram2d/attributes":976}],984:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../contour/attributes":913,"../histogram2d/attributes":973}],981:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154590,7 +157072,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleStyleDefaults(traceIn, traceOut, coerce, layout); }; -},{"../../lib":696,"../contour/contours_defaults":923,"../contour/style_defaults":937,"../histogram2d/sample_defaults":982,"./attributes":983}],985:[function(_dereq_,module,exports){ +},{"../../lib":692,"../contour/contours_defaults":920,"../contour/style_defaults":934,"../histogram2d/sample_defaults":979,"./attributes":980}],982:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154632,7 +157114,7 @@ Histogram2dContour.meta = { module.exports = Histogram2dContour; -},{"../../plots/cartesian":756,"../contour/calc":917,"../contour/colorbar":919,"../contour/hover":929,"../contour/plot":934,"../contour/style":936,"../histogram2d/cross_trace_defaults":978,"./attributes":983,"./defaults":984}],986:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../contour/calc":914,"../contour/colorbar":916,"../contour/hover":926,"../contour/plot":931,"../contour/style":933,"../histogram2d/cross_trace_defaults":975,"./attributes":980,"./defaults":981}],983:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154867,7 +157349,7 @@ colorscaleAttrs('', { hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {editType: 'calc'}) }); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../surface/attributes":1130}],987:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../surface/attributes":1127}],984:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154882,11 +157364,15 @@ var colorscaleCalc = _dereq_('../../components/colorscale/calc'); module.exports = function calc(gd, trace) { if(trace.intensity) { - colorscaleCalc(trace, trace.intensity, '', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.intensity, + containerStr: '', + cLetter: 'c' + }); } }; -},{"../../components/colorscale/calc":578}],988:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577}],985:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155037,7 +157523,7 @@ function createMesh3DTrace(scene, data) { module.exports = createMesh3DTrace; -},{"../../lib/gl_format_color":692,"../../lib/str2rgbarray":719,"../../plots/gl3d/zip3":798,"alpha-shape":52,"convex-hull":118,"delaunay-triangulate":150,"gl-mesh3d":268}],989:[function(_dereq_,module,exports){ +},{"../../lib/gl_format_color":689,"../../lib/str2rgbarray":715,"../../plots/gl3d/zip3":794,"alpha-shape":52,"convex-hull":118,"delaunay-triangulate":150,"gl-mesh3d":268}],986:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155133,7 +157619,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"../../registry":827,"./attributes":986}],990:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"../../registry":823,"./attributes":983}],987:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155173,7 +157659,7 @@ Mesh3D.meta = { module.exports = Mesh3D; -},{"../../plots/gl3d":787,"./attributes":986,"./calc":987,"./convert":988,"./defaults":989}],991:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":783,"./attributes":983,"./calc":984,"./convert":985,"./defaults":986}],988:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155308,7 +157794,7 @@ module.exports = { }), }; -},{"../../components/drawing/attributes":594,"../../components/fx/attributes":604,"../../lib":696,"../scatter/attributes":1043}],992:[function(_dereq_,module,exports){ +},{"../../components/drawing/attributes":589,"../../components/fx/attributes":599,"../../lib":692,"../scatter/attributes":1040}],989:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155403,7 +157889,7 @@ function calcCommon(gd, trace, x, ya, ptFunc) { } } - trace._extremes[ya._id] = Axes.findExtremes(ya, l.concat(h), {padded: true}); + trace._extremes[ya._id] = Axes.findExtremes(ya, Lib.concat(l, h), {padded: true}); if(cd.length) { cd[0].t = { @@ -155473,7 +157959,7 @@ module.exports = { calcCommon: calcCommon }; -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axes":744}],993:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axes":740}],990:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155518,7 +158004,7 @@ function handleDirection(traceIn, traceOut, coerce, direction) { coerce(direction + '.line.dash', traceOut.line.dash); } -},{"../../lib":696,"./attributes":991,"./ohlc_defaults":996}],994:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":988,"./ohlc_defaults":993}],991:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155720,7 +158206,7 @@ module.exports = { hoverOnPoints: hoverOnPoints }; -},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051}],995:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048}],992:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155761,7 +158247,7 @@ module.exports = { selectPoints: _dereq_('./select') }; -},{"../../plots/cartesian":756,"./attributes":991,"./calc":992,"./defaults":993,"./hover":994,"./plot":997,"./select":998,"./style":999}],996:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":988,"./calc":989,"./defaults":990,"./hover":991,"./plot":994,"./select":995,"./style":996}],993:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155770,11 +158256,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Registry = _dereq_('../../registry'); - +var Lib = _dereq_('../../lib'); module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) { var x = coerce('x'); @@ -155791,15 +158276,13 @@ module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) { if(!(open && high && low && close)) return; var len = Math.min(open.length, high.length, low.length, close.length); - - if(x) len = Math.min(len, x.length); - + if(x) len = Math.min(len, Lib.minRowLength(x)); traceOut._length = len; return len; }; -},{"../../registry":827}],997:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],994:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155855,7 +158338,7 @@ module.exports = function plot(gd, plotinfo, cdOHLC, ohlcLayer) { }); }; -},{"../../lib":696,"d3":148}],998:[function(_dereq_,module,exports){ +},{"../../lib":692,"d3":148}],995:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155900,7 +158383,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],999:[function(_dereq_,module,exports){ +},{}],996:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -155937,7 +158420,7 @@ module.exports = function style(gd, cd) { }); }; -},{"../../components/color":570,"../../components/drawing":595,"d3":148}],1000:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"d3":148}],997:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -156142,7 +158625,7 @@ module.exports = { showlegend: undefined }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../../plots/domain":770,"../../plots/font_attributes":771,"../scatter/attributes":1043}],1001:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../../plots/domain":766,"../../plots/font_attributes":767,"../scatter/attributes":1040}],998:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -156178,7 +158661,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../plots/get_data":781,"./plot":1006}],1002:[function(_dereq_,module,exports){ +},{"../../plots/get_data":777,"./plot":1003}],999:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -156192,7 +158675,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) // Requirements // ============ var wrap = _dereq_('../../lib/gup').wrap; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var filterUnique = _dereq_('../../lib/filter_unique.js'); var Drawing = _dereq_('../../components/drawing'); @@ -156254,7 +158737,11 @@ module.exports = function calc(gd, trace) { // Process colorscale if(line) { if(hasColorscale(trace, 'line')) { - colorscaleCalc(trace, trace.line.color, 'line', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } markerColorscale = Drawing.tryColorscale(line); } else { @@ -156685,7 +159172,7 @@ function isRangePermutation(inds) { return true; } -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"../../components/drawing":595,"../../lib":696,"../../lib/filter_unique.js":686,"../../lib/gup":693}],1003:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"../../components/drawing":590,"../../lib":692,"../../lib/filter_unique.js":683,"../../lib/gup":690}],1000:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -156697,7 +159184,7 @@ function isRangePermutation(inds) { 'use strict'; var Lib = _dereq_('../../lib'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var handleDomainDefaults = _dereq_('../../plots/domain').defaults; var handleArrayContainerDefaults = _dereq_('../../plots/array_container_defaults'); @@ -156806,7 +159293,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceFont(coerce, 'tickfont', categoryfontDefault); }; -},{"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/domain":770,"../parcoords/merge_length":1015,"./attributes":1000}],1004:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/domain":766,"../parcoords/merge_length":1012,"./attributes":997}],1001:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -156841,7 +159328,7 @@ Parcats.meta = { module.exports = Parcats; -},{"./attributes":1000,"./base_plot":1001,"./calc":1002,"./defaults":1003,"./plot":1006}],1005:[function(_dereq_,module,exports){ +},{"./attributes":997,"./base_plot":998,"./calc":999,"./defaults":1000,"./plot":1003}],1002:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -158926,7 +161413,7 @@ function createDimensionViewModel(parcatsViewModel, dimensionModel) { * The parent trace's view model */ -},{"../../components/drawing":595,"../../components/fx":612,"../../lib":696,"../../lib/svg_text_utils":720,"../../plot_api/plot_api":731,"d3":148,"tinycolor2":514}],1006:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../components/fx":608,"../../lib":692,"../../lib/svg_text_utils":716,"../../plot_api/plot_api":727,"d3":148,"tinycolor2":513}],1003:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -158970,7 +161457,7 @@ module.exports = function plot(graphDiv, parcatsModels, transitionOpts, makeOnCo ); }; -},{"./parcats":1005}],1007:[function(_dereq_,module,exports){ +},{"./parcats":1002}],1004:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159100,7 +161587,7 @@ module.exports = { }) }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/plot_template":734,"../../plots/cartesian/layout_attributes":757,"../../plots/domain":770,"../../plots/font_attributes":771}],1008:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/plot_template":730,"../../plots/cartesian/layout_attributes":753,"../../plots/domain":766,"../../plots/font_attributes":767}],1005:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159632,7 +162119,7 @@ module.exports = { cleanRanges: cleanRanges }; -},{"../../lib":696,"../../lib/gup":693,"./constants":1011,"d3":148}],1009:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gup":690,"./constants":1008,"d3":148}],1006:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159701,7 +162188,7 @@ exports.toSVG = function(gd) { }, 60); }; -},{"../../constants/xmlns_namespaces":674,"../../plots/get_data":781,"./plot":1017,"d3":148}],1010:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":670,"../../plots/get_data":777,"./plot":1014,"d3":148}],1007:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159712,7 +162199,7 @@ exports.toSVG = function(gd) { 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var Lib = _dereq_('../../lib'); var wrap = _dereq_('../../lib/gup').wrap; @@ -159723,7 +162210,11 @@ module.exports = function calc(gd, trace) { var cscale = cs ? trace.line.colorscale : [[0, trace.line.color], [1, trace.line.color]]; if(hasColorscale(trace, 'line')) { - calcColorscale(trace, color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: color, + containerStr: 'line', + cLetter: 'c' + }); } return wrap({ @@ -159740,7 +162231,7 @@ function constHalf(len) { return out; } -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../lib/gup":693}],1011:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"../../lib":692,"../../lib/gup":690}],1008:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159801,7 +162292,7 @@ module.exports = { } }; -},{}],1012:[function(_dereq_,module,exports){ +},{}],1009:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159813,7 +162304,7 @@ module.exports = { 'use strict'; var Lib = _dereq_('../../lib'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var handleDomainDefaults = _dereq_('../../plots/domain').defaults; var handleArrayContainerDefaults = _dereq_('../../plots/array_container_defaults'); @@ -159907,7 +162398,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceFont(coerce, 'rangefont', fontDflt); }; -},{"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/domain":770,"./attributes":1007,"./axisbrush":1008,"./constants":1011,"./merge_length":1015}],1013:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/domain":766,"./attributes":1004,"./axisbrush":1005,"./constants":1008,"./merge_length":1012}],1010:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159944,7 +162435,7 @@ Parcoords.meta = { module.exports = Parcoords; -},{"./attributes":1007,"./base_plot":1009,"./calc":1010,"./defaults":1012,"./plot":1017}],1014:[function(_dereq_,module,exports){ +},{"./attributes":1004,"./base_plot":1006,"./calc":1007,"./defaults":1009,"./plot":1014}],1011:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160476,7 +162967,7 @@ module.exports = function(canvasGL, d) { }; }; -},{"../../lib":696,"glslify":392}],1015:[function(_dereq_,module,exports){ +},{"../../lib":692,"glslify":392}],1012:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160514,7 +163005,7 @@ module.exports = function(traceOut, dimensions, dataAttr, len) { return len; }; -},{}],1016:[function(_dereq_,module,exports){ +},{}],1013:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160525,16 +163016,20 @@ module.exports = function(traceOut, dimensions, dataAttr, len) { 'use strict'; -var lineLayerMaker = _dereq_('./lines'); -var c = _dereq_('./constants'); -var Lib = _dereq_('../../lib'); var d3 = _dereq_('d3'); + +var Lib = _dereq_('../../lib'); var Drawing = _dereq_('../../components/drawing'); +var Colorscale = _dereq_('../../components/colorscale'); + var gup = _dereq_('../../lib/gup'); var keyFun = gup.keyFun; var repeat = gup.repeat; var unwrap = gup.unwrap; + +var c = _dereq_('./constants'); var brush = _dereq_('./axisbrush'); +var lineLayerMaker = _dereq_('./lines'); function visible(dimension) { return !('visible' in dimension) || dimension.visible; } @@ -160646,8 +163141,8 @@ function model(layout, d, i) { var cd0 = unwrap(d), trace = cd0.trace, lineColor = cd0.lineColor, - cscale = cd0.cscale, line = trace.line, + cscale = line.reversescale ? Colorscale.flipScale(cd0.cscale) : cd0.cscale, domain = trace.domain, dimensions = trace.dimensions, width = layout.width, @@ -161169,7 +163664,7 @@ module.exports = function(root, svg, parcoordsLineLayers, styledData, layout, ca brush.ensureAxisBrush(axisOverlays); }; -},{"../../components/drawing":595,"../../lib":696,"../../lib/gup":693,"./axisbrush":1008,"./constants":1011,"./lines":1014,"d3":148}],1017:[function(_dereq_,module,exports){ +},{"../../components/colorscale":581,"../../components/drawing":590,"../../lib":692,"../../lib/gup":690,"./axisbrush":1005,"./constants":1008,"./lines":1011,"d3":148}],1014:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161194,12 +163689,17 @@ module.exports = function plot(gd, cdparcoords) { var gdDimensions = {}; var gdDimensionsOriginalOrder = {}; + var fullIndices = {}; + var inputIndices = {}; var size = fullLayout._size; cdparcoords.forEach(function(d, i) { - gdDimensions[i] = gd.data[i].dimensions; - gdDimensionsOriginalOrder[i] = gd.data[i].dimensions.slice(); + var trace = d[0].trace; + fullIndices[i] = trace.index; + var iIn = inputIndices[i] = trace._fullInput.index; + gdDimensions[i] = gd.data[iIn].dimensions; + gdDimensionsOriginalOrder[i] = gd.data[iIn].dimensions.slice(); }); var filterChanged = function(i, originalDimensionIndex, newRanges) { @@ -161209,21 +163709,36 @@ module.exports = function plot(gd, cdparcoords) { var gdDimension = gdDimensionsOriginalOrder[i][originalDimensionIndex]; var newConstraints = newRanges.map(function(r) { return r.slice(); }); + + // Store constraint range in preGUI + // This one doesn't work if it's stored in pieces in _storeDirectGUIEdit + // because it's an array of variable dimensionality. So store the whole + // thing at once manually. + var aStr = 'dimensions[' + originalDimensionIndex + '].constraintrange'; + var preGUI = fullLayout._tracePreGUI[gd._fullData[fullIndices[i]]._fullInput.uid]; + if(preGUI[aStr] === undefined) { + var initialVal = gdDimension.constraintrange; + preGUI[aStr] = initialVal || null; + } + + var fullDimension = gd._fullData[fullIndices[i]].dimensions[originalDimensionIndex]; + if(!newConstraints.length) { delete gdDimension.constraintrange; + delete fullDimension.constraintrange; newConstraints = null; } else { if(newConstraints.length === 1) newConstraints = newConstraints[0]; gdDimension.constraintrange = newConstraints; + fullDimension.constraintrange = newConstraints.slice(); // wrap in another array for restyle event data newConstraints = [newConstraints]; } var restyleData = {}; - var aStr = 'dimensions[' + originalDimensionIndex + '].constraintrange'; restyleData[aStr] = newConstraints; - gd.emit('plotly_restyle', [restyleData, [i]]); + gd.emit('plotly_restyle', [restyleData, [inputIndices[i]]]); }; var hover = function(eventData) { @@ -161275,7 +163790,17 @@ module.exports = function plot(gd, cdparcoords) { gdDimensions[i].splice(gdDimensionsOriginalOrder[i].indexOf(d), 0, d); // insert at original index }); - gd.emit('plotly_restyle'); + // TODO: we can't really store this part of the interaction state + // directly as below, since it incudes data arrays. If we want to + // persist column order we may have to do something special for this + // case to just store the order itself. + // Registry.call('_storeDirectGUIEdit', + // gd.data[inputIndices[i]], + // fullLayout._tracePreGUI[gd._fullData[fullIndices[i]]._fullInput.uid], + // {dimensions: gdDimensions[i]} + // ); + + gd.emit('plotly_restyle', [{dimensions: [gdDimensions[i]]}, [inputIndices[i]]]); }; parcoords( @@ -161301,7 +163826,7 @@ module.exports = function plot(gd, cdparcoords) { }); }; -},{"../../lib/prepare_regl":709,"./parcoords":1016}],1018:[function(_dereq_,module,exports){ +},{"../../lib/prepare_regl":705,"./parcoords":1013}],1015:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161315,6 +163840,7 @@ module.exports = function plot(gd, cdparcoords) { var colorAttrs = _dereq_('../../components/color/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); var plotAttrs = _dereq_('../../plots/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var domainAttrs = _dereq_('../../plots/domain').attributes; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -161463,6 +163989,9 @@ module.exports = { hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { flags: ['label', 'text', 'value', 'percent', 'name'] }), + hovertemplate: hovertemplateAttrs({}, { + keys: ['label', 'color', 'value', 'percent', 'text'] + }), textposition: { valType: 'enumerated', role: 'info', @@ -161485,31 +164014,44 @@ module.exports = { }), title: { - valType: 'string', - dflt: '', - role: 'info', - editType: 'calc', - description: [ - 'Sets the title of the pie chart.', - 'If it is empty, no title is displayed.' - ].join(' ') - }, - titleposition: { - valType: 'enumerated', - values: [ - 'top left', 'top center', 'top right', - 'middle center', - 'bottom left', 'bottom center', 'bottom right' - ], - role: 'info', - editType: 'calc', - description: [ - 'Specifies the location of the `title`.', - ].join(' ') + text: { + valType: 'string', + dflt: '', + role: 'info', + editType: 'calc', + description: [ + 'Sets the title of the pie chart.', + 'If it is empty, no title is displayed.', + 'Note that before the existence of `title.text`, the title\'s', + 'contents used to be defined as the `title` attribute itself.', + 'This behavior has been deprecated.' + ].join(' ') + }, + font: extendFlat({}, textFontAttrs, { + description: [ + 'Sets the font used for `title`.', + 'Note that the title\'s font used to be set', + 'by the now deprecated `titlefont` attribute.' + ].join(' ') + }), + position: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + role: 'info', + editType: 'calc', + description: [ + 'Specifies the location of the `title`.', + 'Note that the title\'s position used to be set', + 'by the now deprecated `titleposition` attribute.' + ].join(' ') + }, + + editType: 'calc' }, - titlefont: extendFlat({}, textFontAttrs, { - description: 'Sets the font used for `title`.' - }), // position and shape domain: domainAttrs({name: 'pie', trace: true, editType: 'calc'}), @@ -161583,10 +164125,38 @@ module.exports = { 'to pull all slices apart from each other equally', 'or an array to highlight one or more slices.' ].join(' ') + }, + + _deprecated: { + title: { + valType: 'string', + dflt: '', + role: 'info', + editType: 'calc', + description: [ + 'Deprecated in favor of `title.text`.', + 'Note that value of `title` is no longer a simple', + '*string* but a set of sub-attributes.' + ].join(' ') + }, + titlefont: extendFlat({}, textFontAttrs, { + description: 'Deprecated in favor of `title.font`.' + }), + titleposition: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + role: 'info', + editType: 'calc', + description: 'Deprecated in favor of `title.position`.' + } } }; -},{"../../components/color/attributes":569,"../../lib/extend":685,"../../plots/attributes":741,"../../plots/domain":770,"../../plots/font_attributes":771}],1019:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plots/attributes":737,"../../plots/domain":766,"../../plots/font_attributes":767}],1016:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161618,7 +164188,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../plots/get_data":781,"../../registry":827}],1020:[function(_dereq_,module,exports){ +},{"../../plots/get_data":777,"../../registry":823}],1017:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161809,7 +164379,7 @@ function generateExtendedColors(colorList) { return pieColors; } -},{"../../components/color":570,"../../lib":696,"./helpers":1023,"fast-isnumeric":214,"tinycolor2":514}],1021:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"./helpers":1020,"fast-isnumeric":214,"tinycolor2":513}],1018:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161863,6 +164433,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var textData = coerce('text'); var textInfo = coerce('textinfo', Array.isArray(textData) ? 'text+percent' : 'percent'); coerce('hovertext'); + coerce('hovertemplate'); if(textInfo && textInfo !== 'none') { var textPosition = coerce('textposition'), @@ -161888,11 +164459,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleDomainDefaults(traceOut, layout, coerce); var hole = coerce('hole'); - var title = coerce('title'); + var title = coerce('title.text'); if(title) { - var titlePosition = coerce('titleposition', hole ? 'middle center' : 'top center'); - if(!hole && titlePosition === 'middle center') traceOut.titleposition = 'top center'; - coerceFont(coerce, 'titlefont', layout.font); + var titlePosition = coerce('title.position', hole ? 'middle center' : 'top center'); + if(!hole && titlePosition === 'middle center') traceOut.title.position = 'top center'; + coerceFont(coerce, 'title.font', layout.font); } coerce('sort'); @@ -161902,7 +164473,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('pull'); }; -},{"../../lib":696,"../../plots/domain":770,"./attributes":1018}],1022:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/domain":766,"./attributes":1015}],1019:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161929,6 +164500,8 @@ module.exports = function eventData(pt, trace) { label: pt.label, color: pt.color, value: pt.v, + percent: pt.percent, + text: pt.text, // pt.v (and pt.i below) for backward compatibility v: pt.v @@ -161945,7 +164518,7 @@ module.exports = function eventData(pt, trace) { return out; }; -},{"../../components/fx/helpers":609}],1023:[function(_dereq_,module,exports){ +},{"../../components/fx/helpers":604}],1020:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161987,7 +164560,7 @@ exports.castOption = function castOption(item, indices) { else if(item) return item; }; -},{"../../lib":696}],1024:[function(_dereq_,module,exports){ +},{"../../lib":692}],1021:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162027,7 +164600,7 @@ Pie.meta = { module.exports = Pie; -},{"./attributes":1018,"./base_plot":1019,"./calc":1020,"./defaults":1021,"./layout_attributes":1025,"./layout_defaults":1026,"./plot":1027,"./style":1028,"./style_one":1029}],1025:[function(_dereq_,module,exports){ +},{"./attributes":1015,"./base_plot":1016,"./calc":1017,"./defaults":1018,"./layout_attributes":1022,"./layout_defaults":1023,"./plot":1024,"./style":1025,"./style_one":1026}],1022:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162077,7 +164650,7 @@ module.exports = { } }; -},{}],1026:[function(_dereq_,module,exports){ +},{}],1023:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162101,7 +164674,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { coerce('extendpiecolors'); }; -},{"../../lib":696,"./layout_attributes":1025}],1027:[function(_dereq_,module,exports){ +},{"../../lib":692,"./layout_attributes":1022}],1024:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162203,20 +164776,25 @@ module.exports = function plot(gd, cdpie) { // in case we dragged over the pie from another subplot, // or if hover is turned off - if(hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo) { + if(trace2.hovertemplate || (hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo)) { var rInscribed = getInscribedRadiusFraction(pt, cd0); var hoverCenterX = cx + pt.pxmid[0] * (1 - rInscribed); var hoverCenterY = cy + pt.pxmid[1] * (1 - rInscribed); var separators = fullLayout.separators; var thisText = []; - if(hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); - if(hoverinfo.indexOf('text') !== -1) { - var texti = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); + pt.text = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('text') !== -1) { + var texti = pt.text; if(texti) thisText.push(texti); } - if(hoverinfo.indexOf('value') !== -1) thisText.push(helpers.formatPieValue(pt.v, separators)); - if(hoverinfo.indexOf('percent') !== -1) thisText.push(helpers.formatPiePercent(pt.v / cd0.vTotal, separators)); + pt.value = pt.v; + pt.valueLabel = helpers.formatPieValue(pt.v, separators); + if(hoverinfo && hoverinfo.indexOf('value') !== -1) thisText.push(pt.valueLabel); + pt.percent = pt.v / cd0.vTotal; + pt.percentLabel = helpers.formatPiePercent(pt.percent, separators); + if(hoverinfo && hoverinfo.indexOf('percent') !== -1) thisText.push(pt.percentLabel); var hoverLabel = trace.hoverlabel; var hoverFont = hoverLabel.font; @@ -162226,13 +164804,18 @@ module.exports = function plot(gd, cdpie) { x1: hoverCenterX + rInscribed * cd0.r, y: hoverCenterY, text: thisText.join('
'), - name: hoverinfo.indexOf('name') !== -1 ? trace2.name : undefined, + name: (trace2.hovertemplate || hoverinfo.indexOf('name') !== -1) ? trace2.name : undefined, idealAlign: pt.pxmid[0] < 0 ? 'left' : 'right', color: helpers.castOption(hoverLabel.bgcolor, pt.pts) || pt.color, borderColor: helpers.castOption(hoverLabel.bordercolor, pt.pts), fontFamily: helpers.castOption(hoverFont.family, pt.pts), fontSize: helpers.castOption(hoverFont.size, pt.pts), - fontColor: helpers.castOption(hoverFont.color, pt.pts) + fontColor: helpers.castOption(hoverFont.color, pt.pts), + + trace: trace2, + hovertemplate: helpers.castOption(trace2.hovertemplate, pt.pts), + hovertemplateLabels: pt, + eventData: [eventData(pt, trace2)] }, { container: fullLayout2._hoverlayer.node(), outerContainer: fullLayout2._paper.node(), @@ -162416,7 +164999,7 @@ module.exports = function plot(gd, cdpie) { // add the title var titleTextGroup = d3.select(this).selectAll('g.titletext') - .data(trace.title ? [0] : []); + .data(trace.title.text ? [0] : []); titleTextGroup.enter().append('g') .classed('titletext', true); @@ -162428,18 +165011,18 @@ module.exports = function plot(gd, cdpie) { s.attr('data-notex', 1); }); - titleText.text(trace.title) + titleText.text(trace.title.text) .attr({ 'class': 'titletext', transform: '', 'text-anchor': 'middle', }) - .call(Drawing.font, trace.titlefont) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var transform; - if(trace.titleposition === 'middle center') { + if(trace.title.position === 'middle center') { transform = positionTitleInside(cd0); } else { transform = positionTitleOutside(cd0, fullLayout._size); @@ -162567,11 +165150,11 @@ function prerenderTitles(cdpie, gd) { cd0 = cdpie[i][0]; trace = cd0.trace; - if(trace.title) { + if(trace.title.text) { var dummyTitle = Drawing.tester.append('text') .attr('data-notex', 1) - .text(trace.title) - .call(Drawing.font, trace.titlefont) + .text(trace.title.text) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var bBox = Drawing.bBox(dummyTitle.node(), true); cd0.titleBox = { @@ -162673,7 +165256,7 @@ function positionTitleInside(cd0) { y: cd0.cy, scale: cd0.trace.hole * cd0.r * 2 / textDiameter, tx: 0, - ty: - cd0.titleBox.height / 2 + cd0.trace.titlefont.size + ty: - cd0.titleBox.height / 2 + cd0.trace.title.font.size }; } @@ -162696,25 +165279,25 @@ function positionTitleOutside(cd0, plotSize) { // we reason below as if the baseline is the top middle point of the text box. // so we must add the font size to approximate the y-coord. of the top. // note that this correction must happen after scaling. - translate.ty += trace.titlefont.size; + translate.ty += trace.title.font.size; maxPull = getMaxPull(trace); - if(trace.titleposition.indexOf('top') !== -1) { + if(trace.title.position.indexOf('top') !== -1) { topMiddle.y -= (1 + maxPull) * cd0.r; translate.ty -= cd0.titleBox.height; } - else if(trace.titleposition.indexOf('bottom') !== -1) { + else if(trace.title.position.indexOf('bottom') !== -1) { topMiddle.y += (1 + maxPull) * cd0.r; } - if(trace.titleposition.indexOf('left') !== -1) { + if(trace.title.position.indexOf('left') !== -1) { // we start the text at the left edge of the pie maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x -= (1 + maxPull) * cd0.r; translate.tx += cd0.titleBox.width / 2; - } else if(trace.titleposition.indexOf('center') !== -1) { + } else if(trace.title.position.indexOf('center') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); - } else if(trace.titleposition.indexOf('right') !== -1) { + } else if(trace.title.position.indexOf('right') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x += (1 + maxPull) * cd0.r; translate.tx -= cd0.titleBox.width / 2; @@ -162868,7 +165451,7 @@ function scalePies(cdpie, plotSize) { pieBoxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); pieBoxHeight = plotSize.h * (trace.domain.y[1] - trace.domain.y[0]); // leave some space for the title, if it will be displayed outside - if(trace.title && trace.titleposition !== 'middle center') { + if(trace.title.text && trace.title.position !== 'middle center') { pieBoxHeight -= getTitleSpace(cd0, plotSize); } @@ -162878,7 +165461,7 @@ function scalePies(cdpie, plotSize) { cd0.cx = plotSize.l + plotSize.w * (trace.domain.x[1] + trace.domain.x[0]) / 2; cd0.cy = plotSize.t + plotSize.h * (1 - trace.domain.y[0]) - pieBoxHeight / 2; - if(trace.title && trace.titleposition.indexOf('bottom') !== -1) { + if(trace.title.text && trace.title.position.indexOf('bottom') !== -1) { cd0.cy -= getTitleSpace(cd0, plotSize); } @@ -162957,7 +165540,7 @@ function setCoords(cd) { } } -},{"../../components/color":570,"../../components/drawing":595,"../../components/fx":612,"../../lib":696,"../../lib/svg_text_utils":720,"./event_data":1022,"./helpers":1023,"d3":148}],1028:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../components/fx":608,"../../lib":692,"../../lib/svg_text_utils":716,"./event_data":1019,"./helpers":1020,"d3":148}],1025:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162986,7 +165569,7 @@ module.exports = function style(gd) { }); }; -},{"./style_one":1029,"d3":148}],1029:[function(_dereq_,module,exports){ +},{"./style_one":1026,"d3":148}],1026:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163010,7 +165593,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":570,"./helpers":1023}],1030:[function(_dereq_,module,exports){ +},{"../../components/color":569,"./helpers":1020}],1027:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163158,7 +165741,7 @@ module.exports = { transforms: undefined }; -},{"../scatter/attributes":1043}],1031:[function(_dereq_,module,exports){ +},{"../scatter/attributes":1040}],1028:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163375,7 +165958,7 @@ function createPointcloud(scene, data) { module.exports = createPointcloud; -},{"../../lib/str2rgbarray":719,"../../plots/cartesian/autorange":743,"../scatter/get_trace_color":1053,"gl-pointcloud2d":279}],1032:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":715,"../../plots/cartesian/autorange":739,"../scatter/get_trace_color":1050,"gl-pointcloud2d":279}],1029:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163423,7 +166006,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor) { traceOut._length = null; }; -},{"../../lib":696,"./attributes":1030}],1033:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":1027}],1030:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163456,7 +166039,7 @@ pointcloud.meta = { module.exports = pointcloud; -},{"../../plots/gl2d":784,"../scatter3d/calc":1071,"./attributes":1030,"./convert":1031,"./defaults":1032}],1034:[function(_dereq_,module,exports){ +},{"../../plots/gl2d":780,"../scatter3d/calc":1068,"./attributes":1027,"./convert":1028,"./defaults":1029}],1031:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163472,6 +166055,7 @@ var plotAttrs = _dereq_('../../plots/attributes'); var colorAttrs = _dereq_('../../components/color/attributes'); var fxAttrs = _dereq_('../../components/fx/attributes'); var domainAttrs = _dereq_('../../plots/domain').attributes; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var extendFlat = _dereq_('../../lib/extend').extendFlat; var overrideAll = _dereq_('../../plot_api/edit_types').overrideAll; @@ -163605,6 +166189,10 @@ var attrs = module.exports = overrideAll({ ].join(' ') }, hoverlabel: fxAttrs.hoverlabel, // needs editType override, + hovertemplate: hovertemplateAttrs({}, { + description: 'Variables `sourceLinks` and `targetLinks` are arrays of link objects.', + keys: ['value', 'label'] + }), description: 'The nodes of the Sankey plot.' }, @@ -163675,12 +166263,16 @@ var attrs = module.exports = overrideAll({ ].join(' ') }, hoverlabel: fxAttrs.hoverlabel, // needs editType override, + hovertemplate: hovertemplateAttrs({}, { + description: 'Variables `source` and `target` are node objects.', + keys: ['value', 'label'] + }), description: 'The links of the Sankey plot.' } }, 'calc', 'nested'); attrs.transforms = undefined; -},{"../../components/color/attributes":569,"../../components/fx/attributes":604,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../../plots/domain":770,"../../plots/font_attributes":771}],1035:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../components/fx/attributes":599,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../../plots/domain":766,"../../plots/font_attributes":767}],1032:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163718,7 +166310,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../components/fx/layout_attributes":613,"../../plot_api/edit_types":727,"../../plots/get_data":781,"./plot":1040}],1036:[function(_dereq_,module,exports){ +},{"../../components/fx/layout_attributes":609,"../../plot_api/edit_types":723,"../../plots/get_data":777,"./plot":1037}],1033:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163775,7 +166367,7 @@ module.exports = function calc(gd, trace) { }); }; -},{"../../lib":696,"../../lib/gup":693,"strongly-connected-components":506}],1037:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gup":690,"strongly-connected-components":506}],1034:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163810,7 +166402,7 @@ module.exports = { } }; -},{}],1038:[function(_dereq_,module,exports){ +},{}],1035:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163848,6 +166440,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerceNode('line.width'); coerceNode('hoverinfo', traceIn.hoverinfo); handleHoverLabelDefaults(nodeIn, nodeOut, coerceNode, hoverlabelDefault); + coerceNode('hovertemplate'); var colors = layout.colorway; @@ -163870,6 +166463,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerceLink('line.width'); coerceLink('hoverinfo', traceIn.hoverinfo); handleHoverLabelDefaults(linkIn, linkOut, coerceLink, hoverlabelDefault); + coerceLink('hovertemplate'); var defaultLinkColor = tinycolor(layout.paper_bgcolor).getLuminance() < 0.333 ? 'rgba(255, 255, 255, 0.6)' : @@ -163891,7 +166485,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/color":570,"../../components/fx/hoverlabel_defaults":611,"../../lib":696,"../../plot_api/plot_template":734,"../../plots/domain":770,"./attributes":1034,"tinycolor2":514}],1039:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx/hoverlabel_defaults":606,"../../lib":692,"../../plot_api/plot_template":730,"../../plots/domain":766,"./attributes":1031,"tinycolor2":513}],1036:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163923,7 +166517,7 @@ Plot.meta = { module.exports = Plot; -},{"./attributes":1034,"./base_plot":1035,"./calc":1036,"./defaults":1038,"./plot":1040}],1040:[function(_dereq_,module,exports){ +},{"./attributes":1031,"./base_plot":1032,"./calc":1033,"./defaults":1035,"./plot":1037}],1037:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164059,6 +166653,7 @@ module.exports = function plot(gd, calcData) { if(gd._fullLayout.hovermode === false) return; d3.select(element).call(linkHoveredStyle.bind(0, d, sankey, true)); if(d.link.trace.link.hoverinfo !== 'skip') { + d.link.fullData = d.link.trace; gd.emit('plotly_hover', { event: d3.event, points: [d.link] @@ -164081,10 +166676,13 @@ module.exports = function plot(gd, calcData) { var hoverCenterX = boundingBox.left + boundingBox.width / 2; var hoverCenterY = boundingBox.top + boundingBox.height / 2; + var hovertemplateLabels = {valueLabel: d3.format(d.valueFormat)(d.link.value) + d.valueSuffix}; + d.link.fullData = d.link.trace; + var tooltip = Fx.loneHover({ x: hoverCenterX - rootBBox.left, y: hoverCenterY - rootBBox.top, - name: d3.format(d.valueFormat)(d.link.value) + d.valueSuffix, + name: hovertemplateLabels.valueLabel, text: [ d.link.label || '', sourceLabel + d.link.source.label, @@ -164095,7 +166693,11 @@ module.exports = function plot(gd, calcData) { fontFamily: castHoverOption(obj, 'font.family'), fontSize: castHoverOption(obj, 'font.size'), fontColor: castHoverOption(obj, 'font.color'), - idealAlign: d3.event.x < hoverCenterX ? 'right' : 'left' + idealAlign: d3.event.x < hoverCenterX ? 'right' : 'left', + + hovertemplate: obj.hovertemplate, + hovertemplateLabels: hovertemplateLabels, + eventData: [d.link] }, { container: fullLayout._hoverlayer.node(), outerContainer: fullLayout._paper.node(), @@ -164110,6 +166712,7 @@ module.exports = function plot(gd, calcData) { if(gd._fullLayout.hovermode === false) return; d3.select(element).call(linkNonHoveredStyle.bind(0, d, sankey, true)); if(d.link.trace.link.hoverinfo !== 'skip') { + d.link.fullData = d.link.trace; gd.emit('plotly_unhover', { event: d3.event, points: [d.link] @@ -164131,6 +166734,7 @@ module.exports = function plot(gd, calcData) { if(gd._fullLayout.hovermode === false) return; d3.select(element).call(nodeHoveredStyle, d, sankey); if(d.node.trace.node.hoverinfo !== 'skip') { + d.node.fullData = d.node.trace; gd.emit('plotly_hover', { event: d3.event, points: [d.node] @@ -164150,6 +166754,9 @@ module.exports = function plot(gd, calcData) { var hoverCenterX1 = boundingBox.right + 2 - rootBBox.left; var hoverCenterY = boundingBox.top + boundingBox.height / 4 - rootBBox.top; + var hovertemplateLabels = {valueLabel: d3.format(d.valueFormat)(d.node.value) + d.valueSuffix}; + d.node.fullData = d.node.trace; + var tooltip = Fx.loneHover({ x0: hoverCenterX0, x1: hoverCenterX1, @@ -164165,7 +166772,11 @@ module.exports = function plot(gd, calcData) { fontFamily: castHoverOption(obj, 'font.family'), fontSize: castHoverOption(obj, 'font.size'), fontColor: castHoverOption(obj, 'font.color'), - idealAlign: 'left' + idealAlign: 'left', + + hovertemplate: obj.hovertemplate, + hovertemplateLabels: hovertemplateLabels, + eventData: [d.node] }, { container: fullLayout._hoverlayer.node(), outerContainer: fullLayout._paper.node(), @@ -164180,6 +166791,7 @@ module.exports = function plot(gd, calcData) { if(gd._fullLayout.hovermode === false) return; d3.select(element).call(nodeNonHoveredStyle, d, sankey); if(d.node.trace.node.hoverinfo !== 'skip') { + d.node.fullData = d.node.trace; gd.emit('plotly_unhover', { event: d3.event, points: [d.node] @@ -164219,7 +166831,7 @@ module.exports = function plot(gd, calcData) { ); }; -},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"./constants":1037,"./render":1041,"d3":148}],1041:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"./constants":1034,"./render":1038,"d3":148}],1038:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164892,7 +167504,7 @@ module.exports = function(svg, styledData, layout, callbacks) { .style('fill', nodeTextColor); }; -},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../lib/gup":693,"./constants":1037,"@plotly/d3-sankey":46,"d3":148,"d3-force":144,"tinycolor2":514}],1042:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../lib/gup":690,"./constants":1034,"@plotly/d3-sankey":46,"d3":148,"d3-force":144,"tinycolor2":513}],1039:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164944,7 +167556,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":696}],1043:[function(_dereq_,module,exports){ +},{"../../lib":692}],1040:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164955,6 +167567,7 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -165150,6 +167763,9 @@ module.exports = { 'or text, then the default is *fills*, otherwise it is *points*.' ].join(' ') }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), line: { color: { valType: 'color', @@ -165509,7 +168125,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../components/drawing":595,"../../components/drawing/attributes":594,"../../lib/extend":685,"../../plots/font_attributes":771,"./constants":1047}],1044:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../components/drawing":590,"../../components/drawing/attributes":589,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plots/font_attributes":767,"./constants":1044}],1041:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165599,7 +168215,7 @@ function calc(gd, trace) { } arraysToCalcdata(cd, trace); - calcColorscale(trace); + calcColorscale(gd, trace); calcSelection(cd, trace); if(stackGroupOpts) { @@ -165799,7 +168415,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axes":744,"./arrays_to_calcdata":1042,"./calc_selection":1045,"./colorscale_calc":1046,"./subtypes":1067,"fast-isnumeric":214}],1045:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axes":740,"./arrays_to_calcdata":1039,"./calc_selection":1042,"./colorscale_calc":1043,"./subtypes":1064,"fast-isnumeric":214}],1042:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165818,7 +168434,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":696}],1046:[function(_dereq_,module,exports){ +},{"../../lib":692}],1043:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165827,31 +168443,41 @@ module.exports = function calcSelection(cd, trace) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var subTypes = _dereq_('./subtypes'); - -module.exports = function calcMarkerColorscale(trace) { +module.exports = function calcMarkerColorscale(gd, trace) { if(subTypes.hasLines(trace) && hasColorscale(trace, 'line')) { - calcColorscale(trace, trace.line.color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } if(subTypes.hasMarkers(trace)) { if(hasColorscale(trace, 'marker')) { - calcColorscale(trace, trace.marker.color, 'marker', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - calcColorscale(trace, trace.marker.line.color, 'marker.line', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } } }; -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"./subtypes":1067}],1047:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"./subtypes":1064}],1044:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165875,10 +168501,12 @@ module.exports = { // number of viewport sizes away from the visible region // at which we clip all lines to the perimeter - maxScreensAway: 20 + maxScreensAway: 20, + + eventDataKeys: [] }; -},{}],1048:[function(_dereq_,module,exports){ +},{}],1045:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166061,7 +168689,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":1044}],1049:[function(_dereq_,module,exports){ +},{"./calc":1041}],1046:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166100,7 +168728,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],1050:[function(_dereq_,module,exports){ +},{}],1047:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166178,7 +168806,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout dfltHoverOn.push('fills'); } coerce('hoveron', dfltHoverOn.join('+') || 'points'); - + if(traceOut.hoveron !== 'fills') coerce('hovertemplate'); var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults'); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'}); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'}); @@ -166186,7 +168814,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../../registry":827,"./attributes":1043,"./constants":1047,"./fillcolor_defaults":1052,"./line_defaults":1056,"./line_shape_defaults":1058,"./marker_defaults":1062,"./stack_defaults":1065,"./subtypes":1067,"./text_defaults":1068,"./xy_defaults":1069}],1051:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"./attributes":1040,"./constants":1044,"./fillcolor_defaults":1049,"./line_defaults":1053,"./line_shape_defaults":1055,"./marker_defaults":1059,"./stack_defaults":1062,"./subtypes":1064,"./text_defaults":1065,"./xy_defaults":1066}],1048:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166229,7 +168857,7 @@ function isValid(v) { return v || v === 0; } -},{"../../lib":696}],1052:[function(_dereq_,module,exports){ +},{"../../lib":692}],1049:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166267,7 +168895,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":570,"../../lib":696}],1053:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692}],1050:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166320,7 +168948,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":570,"./subtypes":1067}],1054:[function(_dereq_,module,exports){ +},{"../../components/color":569,"./subtypes":1064}],1051:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166416,7 +169044,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { y1: yc + rad, yLabelVal: yLabelVal, - spikeDistance: dxy(di) + spikeDistance: dxy(di), + hovertemplate: trace.hovertemplate }); fillHoverText(di, trace, pointData); @@ -166500,7 +169129,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { x1: xmax, y0: yAvg, y1: yAvg, - color: color + color: color, + hovertemplate: '%{name}' }); delete pointData.index; @@ -166515,7 +169145,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"../../registry":827,"./fill_hover_text":1051,"./get_trace_color":1053}],1055:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"../../registry":823,"./fill_hover_text":1048,"./get_trace_color":1050}],1052:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166568,7 +169198,7 @@ Scatter.meta = { module.exports = Scatter; -},{"../../plots/cartesian":756,"./arrays_to_calcdata":1042,"./attributes":1043,"./calc":1044,"./cross_trace_calc":1048,"./cross_trace_defaults":1049,"./defaults":1050,"./hover":1054,"./marker_colorbar":1061,"./plot":1063,"./select":1064,"./style":1066,"./subtypes":1067}],1056:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./arrays_to_calcdata":1039,"./attributes":1040,"./calc":1041,"./cross_trace_calc":1045,"./cross_trace_defaults":1046,"./defaults":1047,"./hover":1051,"./marker_colorbar":1058,"./plot":1060,"./select":1061,"./style":1063,"./subtypes":1064}],1053:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166580,7 +169210,7 @@ module.exports = Scatter; 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) { @@ -166599,7 +169229,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"../../lib":696}],1057:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"../../lib":692}],1054:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167064,7 +169694,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":673,"../../lib":696,"./constants":1047}],1058:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"./constants":1044}],1055:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167083,7 +169713,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],1059:[function(_dereq_,module,exports){ +},{}],1056:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167176,7 +169806,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],1060:[function(_dereq_,module,exports){ +},{}],1057:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167218,7 +169848,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":214}],1061:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214}],1058:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167236,7 +169866,7 @@ module.exports = { max: 'cmax' }; -},{}],1062:[function(_dereq_,module,exports){ +},{}],1059:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167245,11 +169875,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var subTypes = _dereq_('./subtypes'); @@ -167319,7 +169948,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":570,"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"./subtypes":1067}],1063:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"./subtypes":1064}],1060:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167410,7 +170039,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition function createFills(gd, traceJoin, plotinfo) { traceJoin.each(function(d) { var fills = ensureSingle(d3.select(this), 'g', 'fills'); - Drawing.setClipUrl(fills, plotinfo.layerClipId); + Drawing.setClipUrl(fills, plotinfo.layerClipId, gd); var trace = d[0].trace; @@ -167462,7 +170091,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition var text = ensureSingle(tr, 'g', 'text'); // error bars are at the bottom - Registry.getComponentMethod('errorbars', 'plot')(errorBarGroup, plotinfo, transitionOpts); + Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts); if(trace.visible !== true) return; @@ -167617,7 +170246,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.lineGroupStyle) .each(makeUpdate(true)); - Drawing.setClipUrl(lineJoin, plotinfo.layerClipId); + Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd); function clearFill(selection) { transition(selection).attr('d', 'M0,0Z'); @@ -167845,8 +170474,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = trace.cliponaxis === false; var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId; - Drawing.setClipUrl(points, clipUrl); - Drawing.setClipUrl(text, clipUrl); + Drawing.setClipUrl(points, clipUrl, gd); + Drawing.setClipUrl(text, clipUrl, gd); } function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { @@ -167891,7 +170520,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":595,"../../lib":696,"../../lib/polygon":708,"../../registry":827,"./line_points":1057,"./link_traces":1059,"./subtypes":1067,"d3":148}],1064:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../../lib/polygon":704,"../../registry":823,"./line_points":1054,"./link_traces":1056,"./subtypes":1064,"d3":148}],1061:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167946,7 +170575,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":1067}],1065:[function(_dereq_,module,exports){ +},{"./subtypes":1064}],1062:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168052,7 +170681,7 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],1066:[function(_dereq_,module,exports){ +},{}],1063:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168124,7 +170753,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":595,"../../registry":827,"d3":148}],1067:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../registry":823,"d3":148}],1064:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168163,7 +170792,7 @@ module.exports = { } }; -},{"../../lib":696}],1068:[function(_dereq_,module,exports){ +},{"../../lib":692}],1065:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168193,7 +170822,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":696}],1069:[function(_dereq_,module,exports){ +},{"../../lib":692}],1066:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168202,34 +170831,32 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var Lib = _dereq_('../../lib'); var Registry = _dereq_('../../registry'); - module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { - var len, - x = coerce('x'), - y = coerce('y'); + var x = coerce('x'); + var y = coerce('y'); + var len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); if(x) { + var xlen = Lib.minRowLength(x); if(y) { - len = Math.min(x.length, y.length); - } - else { - len = x.length; + len = Math.min(xlen, Lib.minRowLength(y)); + } else { + len = xlen; coerce('y0'); coerce('dy'); } - } - else { + } else { if(!y) return 0; - len = traceOut.y.length; + len = Lib.minRowLength(y); coerce('x0'); coerce('dx'); } @@ -168239,7 +170866,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../registry":827}],1070:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],1067:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168402,7 +171029,7 @@ var attrs = module.exports = overrideAll({ colorAttributes('marker') ), - textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center', arrayOk: false}), + textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}), textfont: { color: scatterAttrs.textfont.color, size: scatterAttrs.textfont.size, @@ -168414,7 +171041,7 @@ var attrs = module.exports = overrideAll({ attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes'; -},{"../../components/colorscale/attributes":577,"../../constants/gl3d_dashes":670,"../../constants/gl3d_markers":671,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../scatter/attributes":1043}],1071:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":576,"../../constants/gl3d_dashes":666,"../../constants/gl3d_markers":667,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../scatter/attributes":1040}],1068:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168426,8 +171053,7 @@ attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes'; 'use strict'; var arraysToCalcdata = _dereq_('../scatter/arrays_to_calcdata'); -var calcColorscales = _dereq_('../scatter/colorscale_calc'); - +var calcColorscale = _dereq_('../scatter/colorscale_calc'); /** * This is a kludge to put the array attributes into @@ -168438,12 +171064,12 @@ module.exports = function calc(gd, trace) { var cd = [{x: false, y: false, trace: trace, t: {}}]; arraysToCalcdata(cd, trace); - calcColorscales(trace); + calcColorscale(gd, trace); return cd; }; -},{"../scatter/arrays_to_calcdata":1042,"../scatter/colorscale_calc":1046}],1072:[function(_dereq_,module,exports){ +},{"../scatter/arrays_to_calcdata":1039,"../scatter/colorscale_calc":1043}],1069:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168530,7 +171156,7 @@ function calculateErrors(data, scaleFactor, sceneLayout) { module.exports = calculateErrors; -},{"../../registry":827}],1073:[function(_dereq_,module,exports){ +},{"../../registry":823}],1070:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168666,14 +171292,47 @@ function calculateErrorParams(errors) { return {capSize: capSize, color: color, lineWidth: lineWidth}; } +function parseAlignmentX(a) { + if(a === null || a === undefined) return 0; + + return (a.indexOf('left') > -1) ? -1 : + (a.indexOf('right') > -1) ? 1 : 0; +} + +function parseAlignmentY(a) { + if(a === null || a === undefined) return 0; + + return (a.indexOf('top') > -1) ? -1 : + (a.indexOf('bottom') > -1) ? 1 : 0; +} + function calculateTextOffset(tp) { // Read out text properties - var textOffset = [0, 0]; - if(Array.isArray(tp)) return [0, -1]; - if(tp.indexOf('bottom') >= 0) textOffset[1] += 1; - if(tp.indexOf('top') >= 0) textOffset[1] -= 1; - if(tp.indexOf('left') >= 0) textOffset[0] -= 1; - if(tp.indexOf('right') >= 0) textOffset[0] += 1; + + var defaultAlignmentX = 0; + var defaultAlignmentY = 0; + + var textOffset = [ + defaultAlignmentX, + defaultAlignmentY + ]; + + if(Array.isArray(tp)) { + for(var i = 0; i < tp.length; i++) { + textOffset[i] = [ + defaultAlignmentX, + defaultAlignmentY + ]; + if(tp[i]) { + textOffset[i][0] = parseAlignmentX(tp[i]); + textOffset[i][1] = parseAlignmentY(tp[i]); + } + } + } else { + textOffset[0] = parseAlignmentX(tp); + textOffset[1] = parseAlignmentY(tp); + } + return textOffset; } @@ -168766,7 +171425,7 @@ function convertPlotlyOptions(scene, data) { } if('textposition' in data) { - params.textOffset = calculateTextOffset(data.textposition); // arrayOk === false + params.textOffset = calculateTextOffset(data.textposition); params.textColor = formatColor(data.textfont, 1, len); params.textSize = formatParam(data.textfont.size, len, Lib.identity, 12); params.textFont = data.textfont.family; // arrayOk === false @@ -169006,7 +171665,7 @@ function createLineWithMarkers(scene, data) { module.exports = createLineWithMarkers; -},{"../../constants/gl3d_dashes":670,"../../constants/gl3d_markers":671,"../../lib":696,"../../lib/gl_format_color":692,"../../lib/str2rgbarray":719,"../scatter/make_bubble_size_func":1060,"./calc_errors":1072,"delaunay-triangulate":150,"gl-error3d":237,"gl-line3d":245,"gl-mesh3d":268,"gl-scatter3d":284}],1074:[function(_dereq_,module,exports){ +},{"../../constants/gl3d_dashes":666,"../../constants/gl3d_markers":667,"../../lib":692,"../../lib/gl_format_color":689,"../../lib/str2rgbarray":715,"../scatter/make_bubble_size_func":1057,"./calc_errors":1069,"delaunay-triangulate":150,"gl-error3d":237,"gl-line3d":245,"gl-mesh3d":268,"gl-scatter3d":284}],1071:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169094,7 +171753,7 @@ function handleXYZDefaults(traceIn, traceOut, coerce, layout) { return len; } -},{"../../lib":696,"../../registry":827,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1070}],1075:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1067}],1072:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169132,7 +171791,7 @@ Scatter3D.meta = { module.exports = Scatter3D; -},{"../../constants/gl3d_markers":671,"../../plots/gl3d":787,"../scatter/marker_colorbar":1061,"./attributes":1070,"./calc":1071,"./convert":1073,"./defaults":1074}],1076:[function(_dereq_,module,exports){ +},{"../../constants/gl3d_markers":667,"../../plots/gl3d":783,"../scatter/marker_colorbar":1058,"./attributes":1067,"./calc":1068,"./convert":1070,"./defaults":1071}],1073:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169255,7 +171914,7 @@ module.exports = { hoveron: scatterAttrs.hoveron, }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../scatter/attributes":1043}],1077:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../scatter/attributes":1040}],1074:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169308,14 +171967,14 @@ module.exports = function calc(gd, trace) { cd[0].trace = trace; calcMarkerSize(trace, serieslen); - calcColorscale(trace); + calcColorscale(gd, trace); arraysToCalcdata(cd, trace); calcSelection(cd, trace); return cd; }; -},{"../carpet/lookup_carpetid":894,"../scatter/arrays_to_calcdata":1042,"../scatter/calc":1044,"../scatter/calc_selection":1045,"../scatter/colorscale_calc":1046,"fast-isnumeric":214}],1078:[function(_dereq_,module,exports){ +},{"../carpet/lookup_carpetid":891,"../scatter/arrays_to_calcdata":1039,"../scatter/calc":1041,"../scatter/calc_selection":1042,"../scatter/colorscale_calc":1043,"fast-isnumeric":214}],1075:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169401,7 +172060,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/line_shape_defaults":1058,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1076}],1079:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/line_shape_defaults":1055,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1073}],1076:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169421,7 +172080,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],1080:[function(_dereq_,module,exports){ +},{}],1077:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169507,7 +172166,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { return scatterPointData; }; -},{"../scatter/hover":1054}],1081:[function(_dereq_,module,exports){ +},{"../scatter/hover":1051}],1078:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169545,7 +172204,7 @@ ScatterCarpet.meta = { module.exports = ScatterCarpet; -},{"../../plots/cartesian":756,"../scatter/marker_colorbar":1061,"../scatter/select":1064,"../scatter/style":1066,"./attributes":1076,"./calc":1077,"./defaults":1078,"./event_data":1079,"./hover":1080,"./plot":1082}],1082:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../scatter/marker_colorbar":1058,"../scatter/select":1061,"../scatter/style":1063,"./attributes":1073,"./calc":1074,"./defaults":1075,"./event_data":1076,"./hover":1077,"./plot":1079}],1079:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169585,11 +172244,11 @@ module.exports = function plot(gd, plotinfoproxy, data, layer) { // separately to all scattercarpet traces, but that would require // lots of reorganization of scatter traces that is otherwise not // necessary. That makes this a potential optimization. - Drawing.setClipUrl(node, carpet._clipPathId); + Drawing.setClipUrl(node, carpet._clipPathId, gd); } }; -},{"../../components/drawing":595,"../../plots/cartesian/axes":744,"../scatter/plot":1063}],1083:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../plots/cartesian/axes":740,"../scatter/plot":1060}],1080:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169717,7 +172376,7 @@ module.exports = overrideAll({ }) }, 'calc', 'nested'); -},{"../../components/colorscale/attributes":577,"../../components/drawing/attributes":594,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../scatter/attributes":1043}],1084:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":576,"../../components/drawing/attributes":589,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../scatter/attributes":1040}],1081:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169759,7 +172418,7 @@ module.exports = function calc(gd, trace) { } arraysToCalcdata(calcTrace, trace); - calcMarkerColorscale(trace); + calcMarkerColorscale(gd, trace); calcSelection(calcTrace, trace); if(len) { @@ -169774,7 +172433,7 @@ module.exports = function calc(gd, trace) { return calcTrace; }; -},{"../../constants/numerical":673,"../../lib":696,"../scatter/arrays_to_calcdata":1042,"../scatter/calc_selection":1045,"../scatter/colorscale_calc":1046,"fast-isnumeric":214}],1085:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../scatter/arrays_to_calcdata":1039,"../scatter/calc_selection":1042,"../scatter/colorscale_calc":1043,"fast-isnumeric":214}],1082:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169853,7 +172512,7 @@ function handleLonLatLocDefaults(traceIn, traceOut, coerce) { return len; } -},{"../../lib":696,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1083}],1086:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1080}],1083:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169874,7 +172533,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],1087:[function(_dereq_,module,exports){ +},{}],1084:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169981,7 +172640,7 @@ function getExtraText(trace, pt, axis, labels) { return text.join('
'); } -},{"../../components/fx":612,"../../constants/numerical":673,"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051,"../scatter/get_trace_color":1053,"./attributes":1083}],1088:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../constants/numerical":669,"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048,"../scatter/get_trace_color":1050,"./attributes":1080}],1085:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170021,7 +172680,7 @@ ScatterGeo.meta = { module.exports = ScatterGeo; -},{"../../plots/geo":775,"../scatter/marker_colorbar":1061,"../scatter/style":1066,"./attributes":1083,"./calc":1084,"./defaults":1085,"./event_data":1086,"./hover":1087,"./plot":1089,"./select":1090,"./style":1091}],1089:[function(_dereq_,module,exports){ +},{"../../plots/geo":771,"../scatter/marker_colorbar":1058,"../scatter/style":1063,"./attributes":1080,"./calc":1081,"./defaults":1082,"./event_data":1083,"./hover":1084,"./plot":1086,"./select":1087,"./style":1088}],1086:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170115,7 +172774,7 @@ function calcGeoJSON(calcTrace, topojson) { } } -},{"../../constants/numerical":673,"../../lib":696,"../../lib/geo_location_utils":688,"../../lib/geojson_utils":689,"../../lib/topojson_utils":723,"../scatter/subtypes":1067,"./style":1091,"d3":148}],1090:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../lib/geo_location_utils":685,"../../lib/geojson_utils":686,"../../lib/topojson_utils":719,"../scatter/subtypes":1064,"./style":1088,"d3":148}],1087:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170172,7 +172831,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"../../constants/numerical":673,"../scatter/subtypes":1067}],1091:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../scatter/subtypes":1064}],1088:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170221,7 +172880,7 @@ function styleTrace(gd, calcTrace) { }); } -},{"../../components/color":570,"../../components/drawing":595,"../scatter/style":1066,"d3":148}],1092:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../scatter/style":1063,"d3":148}],1089:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170321,8 +172980,9 @@ var attrs = module.exports = overrideAll({ }, 'calc', 'nested'); attrs.x.editType = attrs.y.editType = attrs.x0.editType = attrs.y0.editType = 'calc+clearAxisTypes'; +attrs.hovertemplate = scatterAttrs.hovertemplate; -},{"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../scatter/attributes":1043,"./constants":1093}],1093:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../scatter/attributes":1040,"./constants":1090}],1090:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170355,7 +173015,7 @@ module.exports = { } }; -},{}],1094:[function(_dereq_,module,exports){ +},{}],1091:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170970,7 +173630,7 @@ module.exports = { textPosition: convertTextPosition }; -},{"../../components/drawing":595,"../../constants/interactions":672,"../../lib":696,"../../lib/gl_format_color":692,"../../plots/cartesian/axis_ids":747,"../../registry":827,"../scatter/make_bubble_size_func":1060,"../scatter/subtypes":1067,"./constants":1093,"color-normalize":108,"fast-isnumeric":214,"svg-path-sdf":512}],1095:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../constants/interactions":668,"../../lib":692,"../../lib/gl_format_color":689,"../../plots/cartesian/axis_ids":743,"../../registry":823,"../scatter/make_bubble_size_func":1057,"../scatter/subtypes":1064,"./constants":1090,"color-normalize":108,"fast-isnumeric":214,"svg-path-sdf":511}],1092:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -171010,6 +173670,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); + coerce('hovertemplate'); coerce('mode', defaultMode); if(subTypes.hasLines(traceOut)) { @@ -171039,7 +173700,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../../registry":827,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"../scatter/xy_defaults":1069,"./attributes":1092}],1096:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"../scatter/xy_defaults":1066,"./attributes":1089}],1093:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -171069,7 +173730,7 @@ var scatterCalc = _dereq_('../scatter/calc'); var calcMarkerSize = scatterCalc.calcMarkerSize; var calcAxisExpansion = scatterCalc.calcAxisExpansion; var setFirstScatter = scatterCalc.setFirstScatter; -var calcColorscales = _dereq_('../scatter/colorscale_calc'); +var calcColorscale = _dereq_('../scatter/colorscale_calc'); var linkTraces = _dereq_('../scatter/link_traces'); var getTraceColor = _dereq_('../scatter/get_trace_color'); var fillHoverText = _dereq_('../scatter/fill_hover_text'); @@ -171126,7 +173787,7 @@ function calc(gd, trace) { } // create scene options and scene - calcColorscales(trace); + calcColorscale(gd, trace); var opts = sceneOptions(gd, subplot, trace, positions, x, y); var scene = sceneUpdate(gd, subplot); @@ -171858,6 +174519,11 @@ function calcHover(pointData, x, y, trace) { di.hi = Array.isArray(hoverinfo) ? hoverinfo[id] : hoverinfo; } + var hovertemplate = trace.hovertemplate; + if(hovertemplate) { + di.ht = Array.isArray(hovertemplate) ? hovertemplate[id] : hovertemplate; + } + var fakeCd = {}; fakeCd[pointData.index] = di; @@ -171874,7 +174540,9 @@ function calcHover(pointData, x, y, trace) { cd: fakeCd, distance: minDist, - spikeDistance: dxy + spikeDistance: dxy, + + hovertemplate: di.ht }); if(di.htx) pointData.text = di.htx; @@ -172024,7 +174692,7 @@ module.exports = { } }; -},{"../../components/color":570,"../../constants/interactions":672,"../../constants/numerical":673,"../../lib":696,"../../lib/prepare_regl":709,"../../plots/cartesian":756,"../../plots/cartesian/autorange":743,"../../plots/cartesian/axis_ids":747,"../../registry":827,"../scatter/calc":1044,"../scatter/colorscale_calc":1046,"../scatter/cross_trace_defaults":1049,"../scatter/fill_hover_text":1051,"../scatter/get_trace_color":1053,"../scatter/link_traces":1059,"../scatter/marker_colorbar":1061,"../scatter/subtypes":1067,"./attributes":1092,"./constants":1093,"./convert":1094,"./defaults":1095,"array-range":55,"gl-text":304,"point-cluster":452,"regl-error2d":473,"regl-line2d":474,"regl-scatter2d":475}],1097:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../constants/interactions":668,"../../constants/numerical":669,"../../lib":692,"../../lib/prepare_regl":705,"../../plots/cartesian":752,"../../plots/cartesian/autorange":739,"../../plots/cartesian/axis_ids":743,"../../registry":823,"../scatter/calc":1041,"../scatter/colorscale_calc":1043,"../scatter/cross_trace_defaults":1046,"../scatter/fill_hover_text":1048,"../scatter/get_trace_color":1050,"../scatter/link_traces":1056,"../scatter/marker_colorbar":1058,"../scatter/subtypes":1064,"./attributes":1089,"./constants":1090,"./convert":1091,"./defaults":1092,"array-range":55,"gl-text":304,"point-cluster":452,"regl-error2d":473,"regl-line2d":474,"regl-scatter2d":475}],1094:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172145,7 +174813,7 @@ module.exports = overrideAll({ }) }, 'calc', 'nested'); -},{"../../components/colorbar/attributes":571,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../../plots/mapbox/layout_attributes":804,"../scatter/attributes":1043,"../scattergeo/attributes":1083}],1098:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../../plots/mapbox/layout_attributes":800,"../scatter/attributes":1040,"../scattergeo/attributes":1080}],1095:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172306,7 +174974,7 @@ function makeCircleOpts(calcTrace) { if(arrayColor) { if(Colorscale.hasColorscale(trace, 'marker')) { colorFn = Colorscale.makeColorScaleFunc( - Colorscale.extractScale(marker.colorscale, marker.cmin, marker.cmax) + Colorscale.extractScale(marker, {cLetter: 'c'}) ); } else { colorFn = Lib.identity; @@ -172439,7 +175107,7 @@ function isBADNUM(lonlat) { return lonlat[0] === BADNUM; } -},{"../../components/colorscale":585,"../../components/drawing":595,"../../constants/numerical":673,"../../lib":696,"../../lib/geojson_utils":689,"../../plots/mapbox/convert_text_opts":801,"../scatter/make_bubble_size_func":1060,"../scatter/subtypes":1067,"fast-isnumeric":214}],1099:[function(_dereq_,module,exports){ +},{"../../components/colorscale":581,"../../components/drawing":590,"../../constants/numerical":669,"../../lib":692,"../../lib/geojson_utils":686,"../../plots/mapbox/convert_text_opts":797,"../scatter/make_bubble_size_func":1057,"../scatter/subtypes":1064,"fast-isnumeric":214}],1096:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172511,7 +175179,7 @@ function handleLonLatDefaults(traceIn, traceOut, coerce) { return len; } -},{"../../lib":696,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1097}],1100:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1094}],1097:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172531,7 +175199,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],1101:[function(_dereq_,module,exports){ +},{}],1098:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172634,7 +175302,7 @@ function getExtraText(trace, di, labels) { return text.join('
'); } -},{"../../components/fx":612,"../../constants/numerical":673,"../../lib":696,"../scatter/fill_hover_text":1051,"../scatter/get_trace_color":1053}],1102:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../constants/numerical":669,"../../lib":692,"../scatter/fill_hover_text":1048,"../scatter/get_trace_color":1050}],1099:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172679,7 +175347,7 @@ ScatterMapbox.meta = { module.exports = ScatterMapbox; -},{"../../plots/mapbox":802,"../scatter/marker_colorbar":1061,"../scattergeo/calc":1084,"./attributes":1097,"./defaults":1099,"./event_data":1100,"./hover":1101,"./plot":1103,"./select":1104}],1103:[function(_dereq_,module,exports){ +},{"../../plots/mapbox":798,"../scatter/marker_colorbar":1058,"../scattergeo/calc":1081,"./attributes":1094,"./defaults":1096,"./event_data":1097,"./hover":1098,"./plot":1100,"./select":1101}],1100:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172791,7 +175459,7 @@ module.exports = function createScatterMapbox(subplot, calcTrace) { return scatterMapbox; }; -},{"./convert":1098}],1104:[function(_dereq_,module,exports){ +},{"./convert":1095}],1101:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172846,7 +175514,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"../../constants/numerical":673,"../../lib":696,"../scatter/subtypes":1067}],1105:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../scatter/subtypes":1064}],1102:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172984,7 +175652,7 @@ module.exports = { unselected: scatterAttrs.unselected }; -},{"../../lib/extend":685,"../../plots/attributes":741,"../scatter/attributes":1043}],1106:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plots/attributes":737,"../scatter/attributes":1040}],1103:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173032,14 +175700,14 @@ module.exports = function calc(gd, trace) { var ppad = calcMarkerSize(trace, len); trace._extremes.x = Axes.findExtremes(radialAxis, rArray, {ppad: ppad}); - calcColorscale(trace); + calcColorscale(gd, trace); arraysToCalcdata(cd, trace); calcSelection(cd, trace); return cd; }; -},{"../../constants/numerical":673,"../../plots/cartesian/axes":744,"../scatter/arrays_to_calcdata":1042,"../scatter/calc":1044,"../scatter/calc_selection":1045,"../scatter/colorscale_calc":1046,"fast-isnumeric":214}],1107:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../plots/cartesian/axes":740,"../scatter/arrays_to_calcdata":1039,"../scatter/calc":1041,"../scatter/calc_selection":1042,"../scatter/colorscale_calc":1043,"fast-isnumeric":214}],1104:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173144,7 +175812,7 @@ module.exports = { supplyDefaults: supplyDefaults }; -},{"../../lib":696,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/line_shape_defaults":1058,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1105}],1108:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/line_shape_defaults":1055,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1102}],1105:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173221,7 +175889,7 @@ module.exports = { makeHoverPointText: makeHoverPointText }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../scatter/hover":1054}],1109:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../scatter/hover":1051}],1106:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173261,7 +175929,7 @@ module.exports = { } }; -},{"../../plots/polar":811,"../scatter/marker_colorbar":1061,"../scatter/select":1064,"../scatter/style":1066,"./attributes":1105,"./calc":1106,"./defaults":1107,"./hover":1108,"./plot":1110}],1110:[function(_dereq_,module,exports){ +},{"../../plots/polar":807,"../scatter/marker_colorbar":1058,"../scatter/select":1061,"../scatter/style":1063,"./attributes":1102,"./calc":1103,"./defaults":1104,"./hover":1105,"./plot":1107}],1107:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173311,7 +175979,7 @@ module.exports = function plot(gd, subplot, moduleCalcData) { scatterPlot(gd, plotinfo, moduleCalcData, mlayer); }; -},{"../../constants/numerical":673,"../scatter/plot":1063}],1111:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../scatter/plot":1060}],1108:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173357,7 +176025,7 @@ module.exports = { unselected: scatterPolarAttrs.unselected }; -},{"../scattergl/attributes":1092,"../scatterpolar/attributes":1105}],1112:[function(_dereq_,module,exports){ +},{"../scattergl/attributes":1089,"../scatterpolar/attributes":1102}],1109:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173417,7 +176085,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"../scatterpolar/defaults":1107,"./attributes":1111}],1113:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"../scatterpolar/defaults":1104,"./attributes":1108}],1110:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173432,7 +176100,7 @@ var cluster = _dereq_('point-cluster'); var isNumeric = _dereq_('fast-isnumeric'); var ScatterGl = _dereq_('../scattergl'); -var calcColorscales = _dereq_('../scatter/colorscale_calc'); +var calcColorscale = _dereq_('../scatter/colorscale_calc'); var calcMarkerSize = _dereq_('../scatter/calc').calcMarkerSize; var convert = _dereq_('../scattergl/convert'); @@ -173458,7 +176126,7 @@ function calc(gd, trace) { stash.r = rArray; stash.theta = thetaArray; - calcColorscales(trace); + calcColorscale(gd, trace); // only compute 'style' options in calc, as position options // depend on the radial range and must be set in plot @@ -173651,7 +176319,7 @@ module.exports = { } }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../../plots/polar":811,"../scatter/calc":1044,"../scatter/colorscale_calc":1046,"../scatter/marker_colorbar":1061,"../scattergl":1096,"../scattergl/constants":1093,"../scattergl/convert":1094,"../scatterpolar/hover":1108,"./attributes":1111,"./defaults":1112,"fast-isnumeric":214,"point-cluster":452}],1114:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../../plots/polar":807,"../scatter/calc":1041,"../scatter/colorscale_calc":1043,"../scatter/marker_colorbar":1058,"../scattergl":1093,"../scattergl/constants":1090,"../scattergl/convert":1091,"../scatterpolar/hover":1105,"./attributes":1108,"./defaults":1109,"fast-isnumeric":214,"point-cluster":452}],1111:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173803,7 +176471,7 @@ module.exports = { hoveron: scatterAttrs.hoveron, }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../components/drawing/attributes":594,"../../lib/extend":685,"../../plots/attributes":741,"../scatter/attributes":1043}],1115:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../components/drawing/attributes":589,"../../lib/extend":682,"../../plots/attributes":737,"../scatter/attributes":1040}],1112:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173878,14 +176546,14 @@ module.exports = function calc(gd, trace) { } calcMarkerSize(trace, serieslen); - calcColorscale(trace); + calcColorscale(gd, trace); arraysToCalcdata(cd, trace); calcSelection(cd, trace); return cd; }; -},{"../scatter/arrays_to_calcdata":1042,"../scatter/calc":1044,"../scatter/calc_selection":1045,"../scatter/colorscale_calc":1046,"fast-isnumeric":214}],1116:[function(_dereq_,module,exports){ +},{"../scatter/arrays_to_calcdata":1039,"../scatter/calc":1041,"../scatter/calc_selection":1042,"../scatter/colorscale_calc":1043,"fast-isnumeric":214}],1113:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173989,7 +176657,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/line_shape_defaults":1058,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1114}],1117:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/line_shape_defaults":1055,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1111}],1114:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174021,7 +176689,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],1118:[function(_dereq_,module,exports){ +},{}],1115:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174093,7 +176761,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { return scatterPointData; }; -},{"../../plots/cartesian/axes":744,"../scatter/hover":1054}],1119:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../scatter/hover":1051}],1116:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174131,7 +176799,7 @@ ScatterTernary.meta = { module.exports = ScatterTernary; -},{"../../plots/ternary":823,"../scatter/marker_colorbar":1061,"../scatter/select":1064,"../scatter/style":1066,"./attributes":1114,"./calc":1115,"./defaults":1116,"./event_data":1117,"./hover":1118,"./plot":1120}],1120:[function(_dereq_,module,exports){ +},{"../../plots/ternary":819,"../scatter/marker_colorbar":1058,"../scatter/select":1061,"../scatter/style":1063,"./attributes":1111,"./calc":1112,"./defaults":1113,"./event_data":1114,"./hover":1115,"./plot":1117}],1117:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174164,7 +176832,7 @@ module.exports = function plot(gd, ternary, moduleCalcData) { scatterPlot(gd, plotinfo, moduleCalcData, scatterLayer); }; -},{"../scatter/plot":1063}],1121:[function(_dereq_,module,exports){ +},{"../scatter/plot":1060}],1118:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174347,7 +177015,7 @@ module.exports = { opacity: scatterGlAttrs.opacity }; -},{"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750,"../scatter/attributes":1043,"../scattergl/attributes":1092}],1122:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746,"../scatter/attributes":1040,"../scattergl/attributes":1089}],1119:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174590,7 +177258,7 @@ module.exports = { toSVG: Cartesian.toSVG }; -},{"../../lib/prepare_regl":709,"../../plots/cartesian":756,"../../plots/cartesian/axes":744,"../../plots/cartesian/axis_ids":747,"../../plots/get_data":781,"../../registry":827,"regl-line2d":474}],1123:[function(_dereq_,module,exports){ +},{"../../lib/prepare_regl":705,"../../plots/cartesian":752,"../../plots/cartesian/axes":740,"../../plots/cartesian/axis_ids":743,"../../plots/get_data":777,"../../registry":823,"regl-line2d":474}],1120:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174760,7 +177428,7 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../parcoords/merge_length":1015,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"./attributes":1121}],1124:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../parcoords/merge_length":1012,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"./attributes":1118}],1121:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174782,7 +177450,7 @@ var AxisIDs = _dereq_('../../plots/cartesian/axis_ids'); var subTypes = _dereq_('../scatter/subtypes'); var calcMarkerSize = _dereq_('../scatter/calc').calcMarkerSize; var calcAxisExpansion = _dereq_('../scatter/calc').calcAxisExpansion; -var calcColorscales = _dereq_('../scatter/colorscale_calc'); +var calcColorscale = _dereq_('../scatter/colorscale_calc'); var convertMarkerSelection = _dereq_('../scattergl/convert').markerSelection; var convertMarkerStyle = _dereq_('../scattergl/convert').markerStyle; var calcHover = _dereq_('../scattergl').calcHover; @@ -174843,7 +177511,7 @@ function calc(gd, trace) { } } - calcColorscales(trace); + calcColorscale(gd, trace); Lib.extendFlat(opts, convertMarkerStyle(trace)); var visibleLength = cdata.length; @@ -175073,7 +177741,7 @@ function editStyle(gd, cd0) { var scene = gd._fullLayout._splomScenes[trace.uid]; if(scene) { - calcColorscales(trace); + calcColorscale(gd, trace); Lib.extendFlat(scene.matrixOptions, convertMarkerStyle(trace)); // TODO [un]selected styles? @@ -175247,7 +177915,7 @@ module.exports = { // register it here Registry.register(Grid); -},{"../../components/grid":616,"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axis_ids":747,"../../registry":827,"../scatter/calc":1044,"../scatter/colorscale_calc":1046,"../scatter/marker_colorbar":1061,"../scatter/subtypes":1067,"../scattergl":1096,"../scattergl/constants":1093,"../scattergl/convert":1094,"./attributes":1121,"./base_plot":1122,"./defaults":1123,"array-range":55,"regl-splom":477}],1125:[function(_dereq_,module,exports){ +},{"../../components/grid":612,"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axis_ids":743,"../../registry":823,"../scatter/calc":1041,"../scatter/colorscale_calc":1043,"../scatter/marker_colorbar":1058,"../scatter/subtypes":1064,"../scattergl":1093,"../scattergl/constants":1090,"../scattergl/convert":1091,"./attributes":1118,"./base_plot":1119,"./defaults":1120,"array-range":55,"regl-splom":477}],1122:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175406,7 +178074,7 @@ attrs.transforms = undefined; module.exports = attrs; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../mesh3d/attributes":986}],1126:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../mesh3d/attributes":983}],1123:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175452,7 +178120,11 @@ module.exports = function calc(gd, trace) { normMin = Math.min(normMin, norm); } - colorscaleCalc(trace, [normMin, normMax], '', 'c'); + colorscaleCalc(gd, trace, { + vals: [normMin, normMax], + containerStr: '', + cLetter: 'c' + }); var xMax = -Infinity; var xMin = Infinity; @@ -175496,7 +178168,7 @@ module.exports = function calc(gd, trace) { trace._zbnds = [zMin, zMax]; }; -},{"../../components/colorscale/calc":578}],1127:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577}],1124:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175724,7 +178396,7 @@ function createStreamtubeTrace(scene, data) { module.exports = createStreamtubeTrace; -},{"../../lib":696,"../../lib/gl_format_color":692,"../../plots/gl3d/zip3":798,"gl-streamtube3d":301}],1128:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gl_format_color":689,"../../plots/gl3d/zip3":794,"gl-streamtube3d":301}],1125:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175787,7 +178459,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"./attributes":1125}],1129:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"./attributes":1122}],1126:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175848,7 +178520,7 @@ module.exports = { } }; -},{"../../plots/gl3d":787,"./attributes":1125,"./calc":1126,"./convert":1127,"./defaults":1128}],1130:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":783,"./attributes":1122,"./calc":1123,"./convert":1124,"./defaults":1125}],1127:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176109,7 +178781,7 @@ colorscaleAttrs('', { attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes'; attrs.transforms = undefined; -},{"../../components/color":570,"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741}],1131:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737}],1128:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176127,13 +178799,21 @@ var colorscaleCalc = _dereq_('../../components/colorscale/calc'); // Compute auto-z and autocolorscale if applicable module.exports = function calc(gd, trace) { if(trace.surfacecolor) { - colorscaleCalc(trace, trace.surfacecolor, '', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.surfacecolor, + containerStr: '', + cLetter: 'c' + }); } else { - colorscaleCalc(trace, trace.z, '', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.z, + containerStr: '', + cLetter: 'c' + }); } }; -},{"../../components/colorscale/calc":578}],1132:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577}],1129:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176146,71 +178826,95 @@ module.exports = function calc(gd, trace) { 'use strict'; var createSurface = _dereq_('gl-surface3d'); + var ndarray = _dereq_('ndarray'); var homography = _dereq_('ndarray-homography'); var fill = _dereq_('ndarray-fill'); -var ops = _dereq_('ndarray-ops'); var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; var parseColorScale = _dereq_('../../lib/gl_format_color').parseColorScale; var str2RgbaArray = _dereq_('../../lib/str2rgbarray'); -var MIN_RESOLUTION = 128; - function SurfaceTrace(scene, surface, uid) { this.scene = scene; this.uid = uid; this.surface = surface; this.data = null; this.showContour = [false, false, false]; - this.dataScale = 1.0; + this.minValues = [Infinity, Infinity, Infinity]; + this.maxValues = [-Infinity, -Infinity, -Infinity]; + this.dataScaleX = 1.0; + this.dataScaleY = 1.0; + this.refineData = true; } var proto = SurfaceTrace.prototype; +proto.getXat = function(a, b, calendar, axis) { + var v = ( + (!isArrayOrTypedArray(this.data.x)) ? + a : + (isArrayOrTypedArray(this.data.x[0])) ? + this.data.x[b][a] : + this.data.x[a] + ); + + return (calendar === undefined) ? v : axis.d2l(v, 0, calendar); +}; + +proto.getYat = function(a, b, calendar, axis) { + var v = ( + (!isArrayOrTypedArray(this.data.y)) ? + b : + (isArrayOrTypedArray(this.data.y[0])) ? + this.data.y[b][a] : + this.data.y[b] + ); + + return (calendar === undefined) ? v : axis.d2l(v, 0, calendar); +}; + +proto.getZat = function(a, b, calendar, axis) { + var v = ( + this.data.z[b][a] + ); + + return (calendar === undefined) ? v : axis.d2l(v, 0, calendar); +}; + proto.handlePick = function(selection) { if(selection.object === this.surface) { - var selectIndex = selection.index = [ - Math.min( - Math.round(selection.data.index[0] / this.dataScale - 1)|0, - this.data.z[0].length - 1 - ), - Math.min( - Math.round(selection.data.index[1] / this.dataScale - 1)|0, - this.data.z.length - 1 - ) - ]; - var traceCoordinate = [0, 0, 0]; - if(!isArrayOrTypedArray(this.data.x)) { - traceCoordinate[0] = selectIndex[0]; - } else if(isArrayOrTypedArray(this.data.x[0])) { - traceCoordinate[0] = this.data.x[selectIndex[1]][selectIndex[0]]; - } else { - traceCoordinate[0] = this.data.x[selectIndex[0]]; - } + var xRatio = (selection.data.index[0] - 1) / this.dataScaleX - 1; + var yRatio = (selection.data.index[1] - 1) / this.dataScaleY - 1; - if(!isArrayOrTypedArray(this.data.y)) { - traceCoordinate[1] = selectIndex[1]; - } else if(isArrayOrTypedArray(this.data.y[0])) { - traceCoordinate[1] = this.data.y[selectIndex[1]][selectIndex[0]]; - } else { - traceCoordinate[1] = this.data.y[selectIndex[1]]; - } + var j = Math.max(Math.min(Math.round(xRatio), this.data.z[0].length - 1), 0); + var k = Math.max(Math.min(Math.round(yRatio), this.data._ylength - 1), 0); - traceCoordinate[2] = this.data.z[selectIndex[1]][selectIndex[0]]; - selection.traceCoordinate = traceCoordinate; + selection.index = [j, k]; + + selection.traceCoordinate = [ + this.getXat(j, k), + this.getYat(j, k), + this.getZat(j, k) + ]; - var sceneLayout = this.scene.fullSceneLayout; selection.dataCoordinate = [ - sceneLayout.xaxis.d2l(traceCoordinate[0], 0, this.data.xcalendar) * this.scene.dataScale[0], - sceneLayout.yaxis.d2l(traceCoordinate[1], 0, this.data.ycalendar) * this.scene.dataScale[1], - sceneLayout.zaxis.d2l(traceCoordinate[2], 0, this.data.zcalendar) * this.scene.dataScale[2] + this.getXat(j, k, this.data.xcalendar, this.scene.fullSceneLayout.xaxis), + this.getYat(j, k, this.data.ycalendar, this.scene.fullSceneLayout.yaxis), + this.getZat(j, k, this.data.zcalendar, this.scene.fullSceneLayout.zaxis) ]; + for(var i = 0; i < 3; i++) { + var v = selection.dataCoordinate[i]; + if(v !== null && v !== undefined) { + selection.dataCoordinate[i] *= this.scene.dataScale[i]; + } + } + var text = this.data.text; - if(Array.isArray(text) && text[selectIndex[1]] && text[selectIndex[1]][selectIndex[0]] !== undefined) { - selection.textLabel = text[selectIndex[1]][selectIndex[0]]; + if(Array.isArray(text) && text[k] && text[k][j] !== undefined) { + selection.textLabel = text[k][j]; } else if(text) { selection.textLabel = text; } else { @@ -176240,58 +178944,220 @@ function isColormapCircular(colormap) { ); } -// Pad coords by +1 -function padField(field) { - var shape = field.shape; - var nshape = [shape[0] + 2, shape[1] + 2]; - var nfield = ndarray(new Float32Array(nshape[0] * nshape[1]), nshape); +var shortPrimes = [ + 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, + 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, + 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, + 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, + 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, + 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, + 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, + 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, + 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, + 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, + 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, + 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, + 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, + 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, + 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, + 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, + 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, + 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, + 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, + 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, + 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, + 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, + 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, + 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, + 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, + 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, + 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, + 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, + 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, + 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999 +]; - // Center - ops.assign(nfield.lo(1, 1).hi(shape[0], shape[1]), field); +function getPow(a, b) { + if(a < b) return 0; + var n = 0; + while(Math.floor(a % b) === 0) { + a /= b; + n++; + } + return n; +} - // Edges - ops.assign(nfield.lo(1).hi(shape[0], 1), - field.hi(shape[0], 1)); - ops.assign(nfield.lo(1, nshape[1] - 1).hi(shape[0], 1), - field.lo(0, shape[1] - 1).hi(shape[0], 1)); - ops.assign(nfield.lo(0, 1).hi(1, shape[1]), - field.hi(1)); - ops.assign(nfield.lo(nshape[0] - 1, 1).hi(1, shape[1]), - field.lo(shape[0] - 1)); +function getFactors(a) { + var powers = []; + for(var i = 0; i < shortPrimes.length; i++) { + var b = shortPrimes[i]; + powers.push( + getPow(a, b) + ); + } + return powers; +} - // Corners - nfield.set(0, 0, field.get(0, 0)); - nfield.set(0, nshape[1] - 1, field.get(0, shape[1] - 1)); - nfield.set(nshape[0] - 1, 0, field.get(shape[0] - 1, 0)); - nfield.set(nshape[0] - 1, nshape[1] - 1, field.get(shape[0] - 1, shape[1] - 1)); +function smallestDivisor(a) { + var A = getFactors(a); + var result = a; + for(var i = 0; i < shortPrimes.length; i++) { + if(A[i] > 0) { + result = shortPrimes[i]; + break; + } + } + return result; +} - return nfield; +function leastCommonMultiple(a, b) { + if(a < 1 || b < 1) return undefined; + var A = getFactors(a); + var B = getFactors(b); + var n = 1; + for(var i = 0; i < shortPrimes.length; i++) { + n *= Math.pow( + shortPrimes[i], Math.max(A[i], B[i]) + ); + } + return n; } -function refine(coords) { - var minScale = Math.max(coords[0].shape[0], coords[0].shape[1]); +function arrayLCM(A) { + if(A.length === 0) return undefined; + var n = 1; + for(var i = 0; i < A.length; i++) { + n = leastCommonMultiple(n, A[i]); + } + return n; +} - if(minScale < MIN_RESOLUTION) { - var scaleF = MIN_RESOLUTION / minScale; - var nshape = [ - Math.floor((coords[0].shape[0]) * scaleF + 1)|0, - Math.floor((coords[0].shape[1]) * scaleF + 1)|0 ]; - var nsize = nshape[0] * nshape[1]; +proto.calcXnums = function(xlen) { + var i; + var nums = []; + for(i = 1; i < xlen; i++) { + var a = this.getXat(i - 1, 0); + var b = this.getXat(i, 0); + + if(b !== a && + a !== undefined && a !== null && + b !== undefined && b !== null) { + nums[i - 1] = Math.abs(b - a); + } else { + nums[i - 1] = 0; + } + } - for(var i = 0; i < coords.length; ++i) { - var padImg = padField(coords[i]); - var scaledImg = ndarray(new Float32Array(nsize), nshape); - homography(scaledImg, padImg, [scaleF, 0, 0, - 0, scaleF, 0, - 0, 0, 1]); - coords[i] = scaledImg; + var totalDist = 0; + for(i = 1; i < xlen; i++) { + totalDist += nums[i - 1]; + } + + for(i = 1; i < xlen; i++) { + if(nums[i - 1] === 0) { + nums[i - 1] = 1; + } else { + nums[i - 1] = Math.round(totalDist / nums[i - 1]); } + } - return scaleF; + return nums; +}; + +proto.calcYnums = function(ylen) { + var i; + var nums = []; + for(i = 1; i < ylen; i++) { + var a = this.getYat(0, i - 1); + var b = this.getYat(0, i); + + if(b !== a && + a !== undefined && a !== null && + b !== undefined && b !== null) { + nums[i - 1] = Math.abs(b - a); + } else { + nums[i - 1] = 0; + } } - return 1.0; -} + var totalDist = 0; + for(i = 1; i < ylen; i++) { + totalDist += nums[i - 1]; + } + + for(i = 1; i < ylen; i++) { + if(nums[i - 1] === 0) { + nums[i - 1] = 1; + } else { + nums[i - 1] = Math.round(totalDist / nums[i - 1]); + } + } + + return nums; +}; + +var highlyComposites = [1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1260]; + +var MIN_RESOLUTION = highlyComposites[9]; +var MAX_RESOLUTION = highlyComposites[13]; + +proto.estimateScale = function(resSrc, axis) { + var nums = (axis === 0) ? + this.calcXnums(resSrc) : + this.calcYnums(resSrc); + + var resDst = 1 + arrayLCM(nums); + + while(resDst < MIN_RESOLUTION) { + resDst *= 2; + } + + while(resDst > MAX_RESOLUTION) { + resDst--; + resDst /= smallestDivisor(resDst); + resDst++; + + if(resDst < MIN_RESOLUTION) { + // resDst = MIN_RESOLUTION; // option 1: use min resolution + resDst = MAX_RESOLUTION; // option 2: use max resolution + } + } + + var scale = Math.round(resDst / resSrc); + return (scale > 1) ? scale : 1; +}; + +proto.refineCoords = function(coords) { + + var scaleW = this.dataScaleX; + var scaleH = this.dataScaleY; + + var width = coords[0].shape[0]; + var height = coords[0].shape[1]; + + var newWidth = Math.floor(coords[0].shape[0] * scaleW + 1) | 0; + var newHeight = Math.floor(coords[0].shape[1] * scaleH + 1) | 0; + + // Pad coords by +1 + var padWidth = 1 + width + 1; + var padHeight = 1 + height + 1; + var padImg = ndarray(new Float32Array(padWidth * padHeight), [padWidth, padHeight]); + + for(var i = 0; i < coords.length; ++i) { + + this.surface.padField(padImg, coords[i]); + + var scaledImg = ndarray(new Float32Array(newWidth * newHeight), [newWidth, newHeight]); + homography(scaledImg, padImg, + [ + scaleW, 0, 0, + 0, scaleH, 0, + 0, 0, 1 + ] + ); + coords[i] = scaledImg; + } +}; proto.setContourLevels = function() { var nlevels = [[], [], []]; @@ -176310,28 +179176,14 @@ proto.setContourLevels = function() { }; proto.update = function(data) { - var i, - scene = this.scene, + var scene = this.scene, sceneLayout = scene.fullSceneLayout, surface = this.surface, alpha = data.opacity, colormap = parseColorScale(data.colorscale, alpha), - z = data.z, - x = data.x, - y = data.y, - xaxis = sceneLayout.xaxis, - yaxis = sceneLayout.yaxis, - zaxis = sceneLayout.zaxis, scaleFactor = scene.dataScale, - xlen = z[0].length, + xlen = data.z[0].length, ylen = data._ylength, - coords = [ - ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), - ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), - ndarray(new Float32Array(xlen * ylen), [xlen, ylen]) - ], - xc = coords[0], - yc = coords[1], contourLevels = scene.contourLevels; // Save data @@ -176345,46 +179197,87 @@ proto.update = function(data) { * which is the transpose of 'gl-surface-plot'. */ - var xcalendar = data.xcalendar, - ycalendar = data.ycalendar, - zcalendar = data.zcalendar; + var i, j, k, v; + var rawCoords = []; + for(i = 0; i < 3; i++) { + rawCoords[i] = []; + for(j = 0; j < xlen; j++) { + rawCoords[i][j] = []; + /* + for(k = 0; k < ylen; k++) { + rawCoords[i][j][k] = undefined; + } + */ + } + } - fill(coords[2], function(row, col) { - return zaxis.d2l(z[col][row], 0, zcalendar) * scaleFactor[2]; - }); + // coords x, y & z + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + rawCoords[0][j][k] = this.getXat(j, k, data.xcalendar, sceneLayout.xaxis); + rawCoords[1][j][k] = this.getYat(j, k, data.ycalendar, sceneLayout.yaxis); + rawCoords[2][j][k] = this.getZat(j, k, data.zcalendar, sceneLayout.zaxis); + } + } - // coords x - if(!isArrayOrTypedArray(x)) { - fill(xc, function(row) { - return xaxis.d2l(row, 0, xcalendar) * scaleFactor[0]; - }); - } else if(isArrayOrTypedArray(x[0])) { - fill(xc, function(row, col) { - return xaxis.d2l(x[col][row], 0, xcalendar) * scaleFactor[0]; - }); - } else { - // ticks x - fill(xc, function(row) { - return xaxis.d2l(x[row], 0, xcalendar) * scaleFactor[0]; - }); + // Note: log axes are not defined in surfaces yet. + // but they could be defined here... + + for(i = 0; i < 3; i++) { + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + v = rawCoords[i][j][k]; + if(v === null || v === undefined) { + rawCoords[i][j][k] = NaN; + } else { + v = rawCoords[i][j][k] *= scaleFactor[i]; + } + } + } } - // coords y - if(!isArrayOrTypedArray(x)) { - fill(yc, function(row, col) { - return yaxis.d2l(col, 0, xcalendar) * scaleFactor[1]; - }); - } else if(isArrayOrTypedArray(y[0])) { - fill(yc, function(row, col) { - return yaxis.d2l(y[col][row], 0, ycalendar) * scaleFactor[1]; - }); - } else { - // ticks y - fill(yc, function(row, col) { - return yaxis.d2l(y[col], 0, ycalendar) * scaleFactor[1]; - }); + for(i = 0; i < 3; i++) { + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + v = rawCoords[i][j][k]; + if(v !== null && v !== undefined) { + if(this.minValues[i] > v) { + this.minValues[i] = v; + } + if(this.maxValues[i] < v) { + this.maxValues[i] = v; + } + } + } + } + } + + for(i = 0; i < 3; i++) { + data._objectOffset[i] = 0.5 * (this.minValues[i] + this.maxValues[i]); } + for(i = 0; i < 3; i++) { + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + v = rawCoords[i][j][k]; + if(v !== null && v !== undefined) { + rawCoords[i][j][k] -= data._objectOffset[i]; + } + } + } + } + + // convert processed raw data to Float32 matrices + var coords = [ + ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), + ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), + ndarray(new Float32Array(xlen * ylen), [xlen, ylen]) + ]; + fill(coords[0], function(row, col) { return rawCoords[0][row][col]; }); + fill(coords[1], function(row, col) { return rawCoords[1][row][col]; }); + fill(coords[2], function(row, col) { return rawCoords[2][row][col]; }); + rawCoords = []; // free memory + var params = { colormap: colormap, levels: [[], [], []], @@ -176406,7 +179299,7 @@ proto.update = function(data) { params.intensityBounds = [data.cmin, data.cmax]; - // Refine if necessary + // Refine surface color if necessary if(data.surfacecolor) { var intensity = ndarray(new Float32Array(xlen * ylen), [xlen, ylen]); @@ -176423,7 +179316,18 @@ proto.update = function(data) { params.intensityBounds[1] *= scaleFactor[2]; } - this.dataScale = refine(coords); + if(MAX_RESOLUTION < coords[0].shape[0] || + MAX_RESOLUTION < coords[0].shape[1]) { + this.refineData = false; + } + + if(this.refineData === true) { + this.dataScaleX = this.estimateScale(coords[0].shape[0], 0); + this.dataScaleY = this.estimateScale(coords[0].shape[1], 1); + if(this.dataScaleX !== 1 || this.dataScaleY !== 1) { + this.refineCoords(coords); + } + } if(data.surfacecolor) { params.intensity = coords.pop(); @@ -176472,8 +179376,13 @@ proto.update = function(data) { params.vertexColor = true; } - params.coords = coords; + params.objectOffset = [ + data._objectOffset[0], + data._objectOffset[1], + data._objectOffset[2] + ]; + params.coords = coords; surface.update(params); surface.visible = data.visible; @@ -176516,7 +179425,7 @@ function createSurfaceTrace(scene, data) { module.exports = createSurfaceTrace; -},{"../../lib":696,"../../lib/gl_format_color":692,"../../lib/str2rgbarray":719,"gl-surface3d":303,"ndarray":433,"ndarray-fill":423,"ndarray-homography":425,"ndarray-ops":427}],1133:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gl_format_color":689,"../../lib/str2rgbarray":715,"gl-surface3d":303,"ndarray":433,"ndarray-fill":423,"ndarray-homography":425}],1130:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176554,6 +179463,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._xlength = (Array.isArray(x) && Lib.isArrayOrTypedArray(x[0])) ? z.length : z[0].length; traceOut._ylength = z.length; + traceOut._objectOffset = [0, 0, 0]; + var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y', 'z'], layout); @@ -176627,7 +179538,7 @@ function mapLegacy(traceIn, oldAttr, newAttr) { } } -},{"../../components/colorscale/defaults":580,"../../lib":696,"../../registry":827,"./attributes":1130}],1134:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"../../registry":823,"./attributes":1127}],1131:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176673,7 +179584,7 @@ Surface.meta = { module.exports = Surface; -},{"../../plots/gl3d":787,"./attributes":1130,"./calc":1131,"./convert":1132,"./defaults":1133}],1135:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":783,"./attributes":1127,"./calc":1128,"./convert":1129,"./defaults":1130}],1132:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176876,7 +179787,7 @@ var attrs = module.exports = overrideAll({ }, 'calc', 'from-root'); attrs.transforms = undefined; -},{"../../components/annotations/attributes":553,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/domain":770,"../../plots/font_attributes":771}],1136:[function(_dereq_,module,exports){ +},{"../../components/annotations/attributes":552,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/domain":766,"../../plots/font_attributes":767}],1133:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176908,7 +179819,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../plots/get_data":781,"./plot":1143}],1137:[function(_dereq_,module,exports){ +},{"../../plots/get_data":777,"./plot":1140}],1134:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176927,7 +179838,7 @@ module.exports = function calc() { return wrap({}); }; -},{"../../lib/gup":693}],1138:[function(_dereq_,module,exports){ +},{"../../lib/gup":690}],1135:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176987,7 +179898,7 @@ module.exports = { } }; -},{}],1139:[function(_dereq_,module,exports){ +},{}],1136:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -177048,7 +179959,8 @@ module.exports = function calc(gd, trace) { var maxLineWidth = Math.max(arrayMax(trace.header.line.width), arrayMax(trace.cells.line.width)); var calcdata = { - key: trace.index, + // include staticPlot in the key so if it changes we delete and redraw + key: trace.uid + gd._context.staticPlot, translateX: domain.x[0] * gd._fullLayout._size.w, translateY: gd._fullLayout._size.h * (1 - domain.y[1]), size: gd._fullLayout._size, @@ -177182,7 +180094,7 @@ function makeIdentity() { }; } -},{"../../lib/extend":685,"./constants":1138,"fast-isnumeric":214}],1140:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"./constants":1135,"fast-isnumeric":214}],1137:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -177265,7 +180177,7 @@ function rowFromTo(d) { return [rowFrom, rowTo]; } -},{"../../lib/extend":685}],1141:[function(_dereq_,module,exports){ +},{"../../lib/extend":682}],1138:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -177330,7 +180242,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../lib":696,"../../plots/domain":770,"./attributes":1135}],1142:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/domain":766,"./attributes":1132}],1139:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -177363,7 +180275,7 @@ Table.meta = { module.exports = Table; -},{"./attributes":1135,"./base_plot":1136,"./calc":1137,"./defaults":1141,"./plot":1143}],1143:[function(_dereq_,module,exports){ +},{"./attributes":1132,"./base_plot":1133,"./calc":1134,"./defaults":1138,"./plot":1140}],1140:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -177386,6 +180298,7 @@ var splitData = _dereq_('./data_split_helpers'); var Color = _dereq_('../../components/color'); module.exports = function plot(gd, wrappedTraceHolders) { + var dynamic = !gd._context.staticPlot; var table = gd._fullLayout._paper.selectAll('.' + c.cn.table) .data(wrappedTraceHolders.map(function(wrappedTraceHolder) { @@ -177417,20 +180330,30 @@ module.exports = function plot(gd, wrappedTraceHolders) { var tableControlView = table.selectAll('.' + c.cn.tableControlView) .data(gup.repeat, gup.keyFun); - tableControlView.enter() + var cvEnter = tableControlView.enter() .append('g') .classed(c.cn.tableControlView, true) - .style('box-sizing', 'content-box') - .on('mousemove', function(d) {tableControlView.filter(function(dd) {return d === dd;}).call(renderScrollbarKit, gd);}) - .on('mousewheel', function(d) { - if(d.scrollbarState.wheeling) return; - d.scrollbarState.wheeling = true; - d3.event.stopPropagation(); - d3.event.preventDefault(); - makeDragRow(gd, tableControlView, null, d.scrollY + d3.event.deltaY)(d); - d.scrollbarState.wheeling = false; - }) - .call(renderScrollbarKit, gd, true); + .style('box-sizing', 'content-box'); + if(dynamic) { + cvEnter + .on('mousemove', function(d) { + tableControlView + .filter(function(dd) {return d === dd;}) + .call(renderScrollbarKit, gd); + }) + .on('mousewheel', function(d) { + if(d.scrollbarState.wheeling) return; + d.scrollbarState.wheeling = true; + var newY = d.scrollY + d3.event.deltaY; + var noChange = makeDragRow(gd, tableControlView, null, newY)(d); + if(!noChange) { + d3.event.stopPropagation(); + d3.event.preventDefault(); + } + d.scrollbarState.wheeling = false; + }) + .call(renderScrollbarKit, gd, true); + } tableControlView .attr('transform', function(d) {return 'translate(' + d.size.l + ' ' + d.size.t + ')';}); @@ -177449,8 +180372,9 @@ module.exports = function plot(gd, wrappedTraceHolders) { .attr('width', function(d) {return d.width;}) .attr('height', function(d) {return d.height;}); - tableControlView - .each(function(d) {Drawing.setClipUrl(d3.select(this), scrollAreaBottomClipKey(gd, d));}); + tableControlView.each(function(d) { + Drawing.setClipUrl(d3.select(this), scrollAreaBottomClipKey(gd, d), gd); + }); var yColumn = tableControlView.selectAll('.' + c.cn.yColumn) .data(function(vm) {return vm.columns;}, gup.keyFun); @@ -177461,9 +180385,10 @@ module.exports = function plot(gd, wrappedTraceHolders) { yColumn.exit().remove(); - yColumn - .attr('transform', function(d) {return 'translate(' + d.x + ' 0)';}) - .call(d3.behavior.drag() + yColumn.attr('transform', function(d) {return 'translate(' + d.x + ' 0)';}); + + if(dynamic) { + yColumn.call(d3.behavior.drag() .origin(function(d) { var movedColumn = d3.select(this); easeColumn(movedColumn, d, -c.uplift); @@ -177502,8 +180427,11 @@ module.exports = function plot(gd, wrappedTraceHolders) { columnMoved(gd, p, p.columns.map(function(dd) {return dd.xIndex;})); }) ); + } - yColumn.each(function(d) {Drawing.setClipUrl(d3.select(this), columnBoundaryClipKey(gd, d));}); + yColumn.each(function(d) { + Drawing.setClipUrl(d3.select(this), columnBoundaryClipKey(gd, d), gd); + }); var columnBlock = yColumn.selectAll('.' + c.cn.columnBlock) .data(splitData.splitToPanels, gup.keyFun); @@ -177521,8 +180449,8 @@ module.exports = function plot(gd, wrappedTraceHolders) { var headerColumnBlock = columnBlock.filter(headerBlock); var cellsColumnBlock = columnBlock.filter(cellsBlock); - cellsColumnBlock - .call(d3.behavior.drag() + if(dynamic) { + cellsColumnBlock.call(d3.behavior.drag() .origin(function(d) { d3.event.stopPropagation(); return d; @@ -177532,6 +180460,7 @@ module.exports = function plot(gd, wrappedTraceHolders) { // fixme emit plotly notification }) ); + } // initial rendering: header is rendered first, as it may may have async LaTeX (show header first) // but blocks are _entered_ the way they are due to painter's algo (header on top) @@ -177954,6 +180883,9 @@ function columnMoved(gd, calcdata, indices) { calcdata.columnorder = indices; + // TODO: there's no data here, but also this reordering is not reflected + // in gd.data or even gd._fullData. + // For now I will not attempt to persist this in _preGUI gd.emit('plotly_restyle'); } @@ -178071,13 +181003,20 @@ function updateBlockYPosition(gd, cellsColumnBlock, tableControlView) { function makeDragRow(gd, allTableControlView, optionalMultiplier, optionalPosition) { return function dragRow(eventD) { - // may come from whicever DOM event target: drag, wheel, bar... eventD corresponds to event target + // may come from whichever DOM event target: drag, wheel, bar... eventD corresponds to event target var d = eventD.calcdata ? eventD.calcdata : eventD; var tableControlView = allTableControlView.filter(function(dd) {return d.key === dd.key;}); var multiplier = optionalMultiplier || d.scrollbarState.dragMultiplier; + + var initialScrollY = d.scrollY; + d.scrollY = optionalPosition === void(0) ? d.scrollY + multiplier * d3.event.dy : optionalPosition; var cellsColumnBlock = tableControlView.selectAll('.' + c.cn.yColumn).selectAll('.' + c.cn.columnBlock).filter(cellsBlock); updateBlockYPosition(gd, cellsColumnBlock, tableControlView); + + // return false if we've "used" the scroll, ie it did something, + // so the event shouldn't bubble (if appropriate) + return d.scrollY === initialScrollY; }; } @@ -178242,7 +181181,7 @@ function allRowsHeight(rowBlock) { function getBlock(d) {return d.rowBlocks[d.page];} function getRow(l, i) {return l.rows[i - l.firstRowIndex];} -},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../lib/gup":693,"../../lib/svg_text_utils":720,"./constants":1138,"./data_preparation_helper":1139,"./data_split_helpers":1140,"d3":148}],1144:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../lib/gup":690,"../../lib/svg_text_utils":716,"./constants":1135,"./data_preparation_helper":1136,"./data_split_helpers":1137,"d3":148}],1141:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -178491,7 +181430,7 @@ module.exports = { } }; -},{"../../lib/extend":685,"../box/attributes":859}],1145:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../box/attributes":856}],1142:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -178617,7 +181556,9 @@ function calcSpan(trace, cdi, valAxis, bandwidth) { function calcSpanItem(index) { var s = spanIn[index]; - var sc = valAxis.d2c(s, 0, trace[cdi.valLetter + 'calendar']); + var sc = valAxis.type === 'multicategory' ? + valAxis.r2c(s) : + valAxis.d2c(s, 0, trace[cdi.valLetter + 'calendar']); return sc === BADNUM ? spanLoose[index] : sc; } @@ -178640,7 +181581,7 @@ function calcSpan(trace, cdi, valAxis, bandwidth) { return spanOut; } -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axes":744,"../box/calc":860,"./helpers":1148}],1146:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axes":740,"../box/calc":857,"./helpers":1145}],1143:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -178690,7 +181631,7 @@ module.exports = function crossTraceCalc(gd, plotinfo) { } }; -},{"../box/cross_trace_calc":861}],1147:[function(_dereq_,module,exports){ +},{"../box/cross_trace_calc":858}],1144:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -178747,7 +181688,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(!meanLineVisible) traceOut.meanline = {visible: false}; }; -},{"../../components/color":570,"../../lib":696,"../box/defaults":862,"./attributes":1144}],1148:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../box/defaults":859,"./attributes":1141}],1145:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -178820,7 +181761,7 @@ exports.getKdeValue = function(calcItem, trace, valueDist) { exports.extractVal = function(o) { return o.v; }; -},{"../../lib":696}],1149:[function(_dereq_,module,exports){ +},{"../../lib":692}],1146:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -178929,7 +181870,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return closeData; }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../box/hover":864,"./helpers":1148}],1150:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../box/hover":861,"./helpers":1145}],1147:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -178970,7 +181911,7 @@ module.exports = { } }; -},{"../../plots/cartesian":756,"../box/select":869,"../scatter/style":1066,"./attributes":1144,"./calc":1145,"./cross_trace_calc":1146,"./defaults":1147,"./hover":1149,"./layout_attributes":1151,"./layout_defaults":1152,"./plot":1153,"./style":1154}],1151:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../box/select":866,"../scatter/style":1063,"./attributes":1141,"./calc":1142,"./cross_trace_calc":1143,"./defaults":1144,"./hover":1146,"./layout_attributes":1148,"./layout_defaults":1149,"./plot":1150,"./style":1151}],1148:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -179009,7 +181950,7 @@ module.exports = { }) }; -},{"../../lib":696,"../box/layout_attributes":866}],1152:[function(_dereq_,module,exports){ +},{"../../lib":692,"../box/layout_attributes":863}],1149:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -179031,7 +181972,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { boxLayoutDefaults._supply(layoutIn, layoutOut, fullData, coerce, 'violin'); }; -},{"../../lib":696,"../box/layout_defaults":867,"./layout_attributes":1151}],1153:[function(_dereq_,module,exports){ +},{"../../lib":692,"../box/layout_defaults":864,"./layout_attributes":1148}],1150:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -179231,7 +182172,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) { }); }; -},{"../../components/drawing":595,"../../lib":696,"../box/plot":868,"../scatter/line_points":1057,"./helpers":1148,"d3":148}],1154:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../box/plot":865,"../scatter/line_points":1054,"./helpers":1145,"d3":148}],1151:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -179286,7 +182227,7 @@ module.exports = function style(gd, cd) { }); }; -},{"../../components/color":570,"../scatter/style":1066,"d3":148}],1155:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../scatter/style":1063,"d3":148}],1152:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -179754,7 +182695,7 @@ function last(array, indices) { return array[indices[indices.length - 1]]; } -},{"../constants/numerical":673,"../lib":696,"../plot_api/plot_schema":733,"../plots/cartesian/axes":744,"./helpers":1158}],1156:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"../lib":692,"../plot_api/plot_schema":729,"../plots/cartesian/axes":740,"./helpers":1155}],1153:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -180090,7 +183031,7 @@ function getFilterFunc(opts, d2c, targetCalendar) { } } -},{"../constants/filter_ops":669,"../lib":696,"../plots/cartesian/axes":744,"../registry":827,"./helpers":1158}],1157:[function(_dereq_,module,exports){ +},{"../constants/filter_ops":665,"../lib":692,"../plots/cartesian/axes":740,"../registry":823,"./helpers":1155}],1154:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -180297,9 +183238,6 @@ function transformOne(trace, state) { // Start with a deep extend that just copies array references. newTrace = newData[i] = Lib.extendDeepNoArrays({}, trace); newTrace._group = groupName; - // helper function for when we need to push updates back to the input, - // outside of the normal restyle/relayout pathway, like filling in auto values - newTrace.updateStyle = styleUpdater(groupName, transformIndex); newTrace.transforms[transformIndex]._indexToPoints = {}; var suppliedName = null; @@ -180377,18 +183315,7 @@ function transformOne(trace, state) { return newData; } -function styleUpdater(groupName, transformIndex) { - return function(trace, attr, value) { - Lib.keyedContainer( - trace, - 'transforms[' + transformIndex + '].styles', - 'target', - 'value.' + attr - ).set(String(groupName), value); - }; -} - -},{"../lib":696,"../plot_api/plot_schema":733,"../plots/plots":808,"./helpers":1158}],1158:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/plot_schema":729,"../plots/plots":804,"./helpers":1155}],1155:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -180414,7 +183341,7 @@ exports.pointsAccessorFunction = function(transforms, opts) { return originalPointsAccessor; }; -},{}],1159:[function(_dereq_,module,exports){ +},{}],1156:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -180559,5 +183486,5 @@ function getSortFunc(opts, d2c) { } } -},{"../lib":696,"../plots/cartesian/axes":744,"./helpers":1158}]},{},[22])(22) +},{"../lib":692,"../plots/cartesian/axes":740,"./helpers":1155}]},{},[22])(22) }); diff --git a/dist/plotly.js b/dist/plotly.js index f285cdd01e5..5c9c5b328d1 100644 --- a/dist/plotly.js +++ b/dist/plotly.js @@ -1,5 +1,5 @@ /** -* plotly.js v1.42.5 +* plotly.js v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license @@ -39,8 +39,8 @@ var rules = { "X .cursor-ne-resize": "cursor:ne-resize;", "X .cursor-grab": "cursor:-webkit-grab;cursor:grab;", "X .modebar": "position:absolute;top:2px;right:2px;z-index:1001;", - "X .modebar--hover": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", - "X:hover .modebar--hover": "opacity:1;", + "X .modebar--hover>:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;", + "X:hover .modebar--hover .modebar-group": "opacity:1;", "X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;", "X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;", "X .modebar-btn svg": "position:relative;top:2px;", @@ -71,7 +71,7 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":696}],2:[function(_dereq_,module,exports){ +},{"../src/lib":692}],2:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -214,7 +214,7 @@ module.exports = { module.exports = _dereq_('../src/transforms/aggregate'); -},{"../src/transforms/aggregate":1155}],4:[function(_dereq_,module,exports){ +},{"../src/transforms/aggregate":1152}],4:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -227,7 +227,7 @@ module.exports = _dereq_('../src/transforms/aggregate'); module.exports = _dereq_('../src/traces/bar'); -},{"../src/traces/bar":843}],5:[function(_dereq_,module,exports){ +},{"../src/traces/bar":840}],5:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -240,7 +240,7 @@ module.exports = _dereq_('../src/traces/bar'); module.exports = _dereq_('../src/traces/barpolar'); -},{"../src/traces/barpolar":855}],6:[function(_dereq_,module,exports){ +},{"../src/traces/barpolar":852}],6:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -253,7 +253,7 @@ module.exports = _dereq_('../src/traces/barpolar'); module.exports = _dereq_('../src/traces/box'); -},{"../src/traces/box":865}],7:[function(_dereq_,module,exports){ +},{"../src/traces/box":862}],7:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -266,7 +266,7 @@ module.exports = _dereq_('../src/traces/box'); module.exports = _dereq_('../src/components/calendars'); -},{"../src/components/calendars":568}],8:[function(_dereq_,module,exports){ +},{"../src/components/calendars":567}],8:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -279,7 +279,7 @@ module.exports = _dereq_('../src/components/calendars'); module.exports = _dereq_('../src/traces/candlestick'); -},{"../src/traces/candlestick":874}],9:[function(_dereq_,module,exports){ +},{"../src/traces/candlestick":871}],9:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -292,7 +292,7 @@ module.exports = _dereq_('../src/traces/candlestick'); module.exports = _dereq_('../src/traces/carpet'); -},{"../src/traces/carpet":893}],10:[function(_dereq_,module,exports){ +},{"../src/traces/carpet":890}],10:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -305,7 +305,7 @@ module.exports = _dereq_('../src/traces/carpet'); module.exports = _dereq_('../src/traces/choropleth'); -},{"../src/traces/choropleth":907}],11:[function(_dereq_,module,exports){ +},{"../src/traces/choropleth":904}],11:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -318,7 +318,7 @@ module.exports = _dereq_('../src/traces/choropleth'); module.exports = _dereq_('../src/traces/cone'); -},{"../src/traces/cone":915}],12:[function(_dereq_,module,exports){ +},{"../src/traces/cone":912}],12:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -331,7 +331,7 @@ module.exports = _dereq_('../src/traces/cone'); module.exports = _dereq_('../src/traces/contour'); -},{"../src/traces/contour":930}],13:[function(_dereq_,module,exports){ +},{"../src/traces/contour":927}],13:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -344,7 +344,7 @@ module.exports = _dereq_('../src/traces/contour'); module.exports = _dereq_('../src/traces/contourcarpet'); -},{"../src/traces/contourcarpet":941}],14:[function(_dereq_,module,exports){ +},{"../src/traces/contourcarpet":938}],14:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -357,7 +357,7 @@ module.exports = _dereq_('../src/traces/contourcarpet'); module.exports = _dereq_('../src/core'); -},{"../src/core":675}],15:[function(_dereq_,module,exports){ +},{"../src/core":671}],15:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -370,7 +370,7 @@ module.exports = _dereq_('../src/core'); module.exports = _dereq_('../src/transforms/filter'); -},{"../src/transforms/filter":1156}],16:[function(_dereq_,module,exports){ +},{"../src/transforms/filter":1153}],16:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -383,7 +383,7 @@ module.exports = _dereq_('../src/transforms/filter'); module.exports = _dereq_('../src/transforms/groupby'); -},{"../src/transforms/groupby":1157}],17:[function(_dereq_,module,exports){ +},{"../src/transforms/groupby":1154}],17:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -396,7 +396,7 @@ module.exports = _dereq_('../src/transforms/groupby'); module.exports = _dereq_('../src/traces/heatmap'); -},{"../src/traces/heatmap":953}],18:[function(_dereq_,module,exports){ +},{"../src/traces/heatmap":950}],18:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -409,7 +409,7 @@ module.exports = _dereq_('../src/traces/heatmap'); module.exports = _dereq_('../src/traces/heatmapgl'); -},{"../src/traces/heatmapgl":963}],19:[function(_dereq_,module,exports){ +},{"../src/traces/heatmapgl":959}],19:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -422,7 +422,7 @@ module.exports = _dereq_('../src/traces/heatmapgl'); module.exports = _dereq_('../src/traces/histogram'); -},{"../src/traces/histogram":974}],20:[function(_dereq_,module,exports){ +},{"../src/traces/histogram":971}],20:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -435,7 +435,7 @@ module.exports = _dereq_('../src/traces/histogram'); module.exports = _dereq_('../src/traces/histogram2d'); -},{"../src/traces/histogram2d":981}],21:[function(_dereq_,module,exports){ +},{"../src/traces/histogram2d":978}],21:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -448,7 +448,7 @@ module.exports = _dereq_('../src/traces/histogram2d'); module.exports = _dereq_('../src/traces/histogram2dcontour'); -},{"../src/traces/histogram2dcontour":985}],22:[function(_dereq_,module,exports){ +},{"../src/traces/histogram2dcontour":982}],22:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -545,7 +545,7 @@ module.exports = Plotly; module.exports = _dereq_('../src/traces/mesh3d'); -},{"../src/traces/mesh3d":990}],24:[function(_dereq_,module,exports){ +},{"../src/traces/mesh3d":987}],24:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -558,7 +558,7 @@ module.exports = _dereq_('../src/traces/mesh3d'); module.exports = _dereq_('../src/traces/ohlc'); -},{"../src/traces/ohlc":995}],25:[function(_dereq_,module,exports){ +},{"../src/traces/ohlc":992}],25:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -571,7 +571,7 @@ module.exports = _dereq_('../src/traces/ohlc'); module.exports = _dereq_('../src/traces/parcats'); -},{"../src/traces/parcats":1004}],26:[function(_dereq_,module,exports){ +},{"../src/traces/parcats":1001}],26:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -584,7 +584,7 @@ module.exports = _dereq_('../src/traces/parcats'); module.exports = _dereq_('../src/traces/parcoords'); -},{"../src/traces/parcoords":1013}],27:[function(_dereq_,module,exports){ +},{"../src/traces/parcoords":1010}],27:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -597,7 +597,7 @@ module.exports = _dereq_('../src/traces/parcoords'); module.exports = _dereq_('../src/traces/pie'); -},{"../src/traces/pie":1024}],28:[function(_dereq_,module,exports){ +},{"../src/traces/pie":1021}],28:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -610,7 +610,7 @@ module.exports = _dereq_('../src/traces/pie'); module.exports = _dereq_('../src/traces/pointcloud'); -},{"../src/traces/pointcloud":1033}],29:[function(_dereq_,module,exports){ +},{"../src/traces/pointcloud":1030}],29:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -623,7 +623,7 @@ module.exports = _dereq_('../src/traces/pointcloud'); module.exports = _dereq_('../src/traces/sankey'); -},{"../src/traces/sankey":1039}],30:[function(_dereq_,module,exports){ +},{"../src/traces/sankey":1036}],30:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -636,7 +636,7 @@ module.exports = _dereq_('../src/traces/sankey'); module.exports = _dereq_('../src/traces/scatter3d'); -},{"../src/traces/scatter3d":1075}],31:[function(_dereq_,module,exports){ +},{"../src/traces/scatter3d":1072}],31:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -649,7 +649,7 @@ module.exports = _dereq_('../src/traces/scatter3d'); module.exports = _dereq_('../src/traces/scattercarpet'); -},{"../src/traces/scattercarpet":1081}],32:[function(_dereq_,module,exports){ +},{"../src/traces/scattercarpet":1078}],32:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -662,7 +662,7 @@ module.exports = _dereq_('../src/traces/scattercarpet'); module.exports = _dereq_('../src/traces/scattergeo'); -},{"../src/traces/scattergeo":1088}],33:[function(_dereq_,module,exports){ +},{"../src/traces/scattergeo":1085}],33:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -675,7 +675,7 @@ module.exports = _dereq_('../src/traces/scattergeo'); module.exports = _dereq_('../src/traces/scattergl'); -},{"../src/traces/scattergl":1096}],34:[function(_dereq_,module,exports){ +},{"../src/traces/scattergl":1093}],34:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -688,7 +688,7 @@ module.exports = _dereq_('../src/traces/scattergl'); module.exports = _dereq_('../src/traces/scattermapbox'); -},{"../src/traces/scattermapbox":1102}],35:[function(_dereq_,module,exports){ +},{"../src/traces/scattermapbox":1099}],35:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -701,7 +701,7 @@ module.exports = _dereq_('../src/traces/scattermapbox'); module.exports = _dereq_('../src/traces/scatterpolar'); -},{"../src/traces/scatterpolar":1109}],36:[function(_dereq_,module,exports){ +},{"../src/traces/scatterpolar":1106}],36:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -714,7 +714,7 @@ module.exports = _dereq_('../src/traces/scatterpolar'); module.exports = _dereq_('../src/traces/scatterpolargl'); -},{"../src/traces/scatterpolargl":1113}],37:[function(_dereq_,module,exports){ +},{"../src/traces/scatterpolargl":1110}],37:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -727,7 +727,7 @@ module.exports = _dereq_('../src/traces/scatterpolargl'); module.exports = _dereq_('../src/traces/scatterternary'); -},{"../src/traces/scatterternary":1119}],38:[function(_dereq_,module,exports){ +},{"../src/traces/scatterternary":1116}],38:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -740,7 +740,7 @@ module.exports = _dereq_('../src/traces/scatterternary'); module.exports = _dereq_('../src/transforms/sort'); -},{"../src/transforms/sort":1159}],39:[function(_dereq_,module,exports){ +},{"../src/transforms/sort":1156}],39:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -753,7 +753,7 @@ module.exports = _dereq_('../src/transforms/sort'); module.exports = _dereq_('../src/traces/splom'); -},{"../src/traces/splom":1124}],40:[function(_dereq_,module,exports){ +},{"../src/traces/splom":1121}],40:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -766,7 +766,7 @@ module.exports = _dereq_('../src/traces/splom'); module.exports = _dereq_('../src/traces/streamtube'); -},{"../src/traces/streamtube":1129}],41:[function(_dereq_,module,exports){ +},{"../src/traces/streamtube":1126}],41:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -779,7 +779,7 @@ module.exports = _dereq_('../src/traces/streamtube'); module.exports = _dereq_('../src/traces/surface'); -},{"../src/traces/surface":1134}],42:[function(_dereq_,module,exports){ +},{"../src/traces/surface":1131}],42:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -792,7 +792,7 @@ module.exports = _dereq_('../src/traces/surface'); module.exports = _dereq_('../src/traces/table'); -},{"../src/traces/table":1142}],43:[function(_dereq_,module,exports){ +},{"../src/traces/table":1139}],43:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -805,7 +805,7 @@ module.exports = _dereq_('../src/traces/table'); module.exports = _dereq_('../src/traces/violin'); -},{"../src/traces/violin":1150}],44:[function(_dereq_,module,exports){ +},{"../src/traces/violin":1147}],44:[function(_dereq_,module,exports){ 'use strict' module.exports = createCamera @@ -1166,7 +1166,7 @@ function createViewController(options) { matrix: matrix }, mode) } -},{"matrix-camera-controller":416,"orbit-camera-controller":439,"turntable-camera-controller":519}],46:[function(_dereq_,module,exports){ +},{"matrix-camera-controller":416,"orbit-camera-controller":439,"turntable-camera-controller":518}],46:[function(_dereq_,module,exports){ // https://github.com/d3/d3-sankey Version 0.5.1. Copyright 2018 Mike Bostock. (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, _dereq_('d3-array'), _dereq_('d3-collection'), _dereq_('d3-interpolate')) : @@ -1520,7 +1520,7 @@ function createABigTriangle(gl) { module.exports = createABigTriangle -},{"gl-buffer":230,"gl-vao":310,"weak-map":529}],48:[function(_dereq_,module,exports){ +},{"gl-buffer":230,"gl-vao":310,"weak-map":528}],48:[function(_dereq_,module,exports){ module.exports = absolutize @@ -7415,7 +7415,7 @@ function boxIntersectWrapper(arg0, arg1, arg2) { throw new Error('box-intersect: Invalid arguments') } } -},{"./lib/intersect":86,"./lib/sweep":90,"typedarray-pool":522}],85:[function(_dereq_,module,exports){ +},{"./lib/intersect":86,"./lib/sweep":90,"typedarray-pool":521}],85:[function(_dereq_,module,exports){ 'use strict' var DIMENSION = 'd' @@ -8055,7 +8055,7 @@ function boxIntersectIter( } } } -},{"./brute":85,"./median":87,"./partition":88,"./sweep":90,"bit-twiddle":80,"typedarray-pool":522}],87:[function(_dereq_,module,exports){ +},{"./brute":85,"./median":87,"./partition":88,"./sweep":90,"bit-twiddle":80,"typedarray-pool":521}],87:[function(_dereq_,module,exports){ 'use strict' module.exports = findMedian @@ -8891,7 +8891,7 @@ red_loop: } } } -},{"./sort":89,"bit-twiddle":80,"typedarray-pool":522}],91:[function(_dereq_,module,exports){ +},{"./sort":89,"bit-twiddle":80,"typedarray-pool":521}],91:[function(_dereq_,module,exports){ },{}],92:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. @@ -9467,7 +9467,7 @@ function typedArraySupport () { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } return arr.foo() === 42 } catch (e) { return false @@ -12424,7 +12424,7 @@ function cleanPSLG (points, edges, colors) { return modified } -},{"./lib/rat-seg-intersect":105,"big-rat":66,"big-rat/cmp":64,"big-rat/to-float":78,"box-intersect":84,"nextafter":434,"rat-vec":469,"robust-segment-intersect":489,"union-find":523}],105:[function(_dereq_,module,exports){ +},{"./lib/rat-seg-intersect":105,"big-rat":66,"big-rat/cmp":64,"big-rat/to-float":78,"box-intersect":84,"nextafter":434,"rat-vec":469,"robust-segment-intersect":489,"union-find":522}],105:[function(_dereq_,module,exports){ 'use strict' module.exports = solveIntersection @@ -13406,7 +13406,7 @@ function compareAngle(a, b, c, d) { } } } -},{"robust-orientation":486,"robust-product":487,"robust-sum":491,"signum":492,"two-sum":521}],116:[function(_dereq_,module,exports){ +},{"robust-orientation":486,"robust-product":487,"robust-sum":491,"signum":492,"two-sum":520}],116:[function(_dereq_,module,exports){ module.exports = compareCells var min = Math.min @@ -14047,7 +14047,7 @@ function parseLineHeight(value) { return value } -},{"./lib/util":128,"css-font-stretch-keywords":124,"css-font-style-keywords":125,"css-font-weight-keywords":126,"css-global-keywords":131,"css-system-font-keywords":132,"string-split-by":505,"unquote":525}],130:[function(_dereq_,module,exports){ +},{"./lib/util":128,"css-font-stretch-keywords":124,"css-font-style-keywords":125,"css-font-weight-keywords":126,"css-global-keywords":131,"css-system-font-keywords":132,"string-split-by":505,"unquote":524}],130:[function(_dereq_,module,exports){ 'use strict' var pick = _dereq_('pick-by-alias') @@ -14679,7 +14679,7 @@ function generateCWiseOp(proc, typesig) { } module.exports = generateCWiseOp -},{"uniq":524}],136:[function(_dereq_,module,exports){ +},{"uniq":523}],136:[function(_dereq_,module,exports){ "use strict" // The function below is called when constructing a cwise function object, and does the following: @@ -27873,7 +27873,7 @@ function triangulate(points, includePointAtInfinity) { return hull } -},{"incremental-convex-hull":396,"uniq":524}],151:[function(_dereq_,module,exports){ +},{"incremental-convex-hull":396,"uniq":523}],151:[function(_dereq_,module,exports){ 'use strict' @@ -28835,7 +28835,7 @@ function edgeToAdjacency(edges, numVertices) { } return adj } -},{"uniq":524}],158:[function(_dereq_,module,exports){ +},{"uniq":523}],158:[function(_dereq_,module,exports){ // Inspired by Google Closure: // http://closure-library.googlecode.com/svn/docs/ // closure_goog_array_array.js.html#goog.array.clear @@ -32954,1632 +32954,1646 @@ function getCanvasContext (type, opts) { } },{}],222:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createAxes - -var createText = _dereq_('./lib/text.js') -var createLines = _dereq_('./lib/lines.js') -var createBackground = _dereq_('./lib/background.js') -var getCubeProperties = _dereq_('./lib/cube.js') -var Ticks = _dereq_('./lib/ticks.js') - -var identity = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1]) - -function copyVec3(a, b) { - a[0] = b[0] - a[1] = b[1] - a[2] = b[2] - return a -} - -function Axes(gl) { - this.gl = gl - - this.pixelRatio = 1 - - this.bounds = [ [-10, -10, -10], - [ 10, 10, 10] ] - this.ticks = [ [], [], [] ] - this.autoTicks = true - this.tickSpacing = [ 1, 1, 1 ] - - this.tickEnable = [ true, true, true ] - this.tickFont = [ 'sans-serif', 'sans-serif', 'sans-serif' ] - this.tickSize = [ 12, 12, 12 ] - this.tickAngle = [ 0, 0, 0 ] - this._tickAlign = [ 'auto', 'auto', 'auto' ] - this.tickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - this.tickPad = [ 10, 10, 10 ] - - this.lastCubeProps = { - cubeEdges: [0,0,0], - axis: [0,0,0] - } - - this.labels = [ 'x', 'y', 'z' ] - this.labelEnable = [ true, true, true ] - this.labelFont = 'sans-serif' - this.labelSize = [ 20, 20, 20 ] - this._labelAngle = [ 0, 0, 0 ] - this._labelAlign = [ 'auto', 'auto', 'auto' ] - this.labelColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - this.labelPad = [ 10, 10, 10 ] - - this.lineEnable = [ true, true, true ] - this.lineMirror = [ false, false, false ] - this.lineWidth = [ 1, 1, 1 ] - this.lineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - - this.lineTickEnable = [ true, true, true ] - this.lineTickMirror = [ false, false, false ] - this.lineTickLength = [ 0, 0, 0 ] - this.lineTickWidth = [ 1, 1, 1 ] - this.lineTickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - - this.gridEnable = [ true, true, true ] - this.gridWidth = [ 1, 1, 1 ] - this.gridColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - - this.zeroEnable = [ true, true, true ] - this.zeroLineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] - this.zeroLineWidth = [ 2, 2, 2 ] - - this.backgroundEnable = [ false, false, false ] - this.backgroundColor = [ [0.8, 0.8, 0.8, 0.5], - [0.8, 0.8, 0.8, 0.5], - [0.8, 0.8, 0.8, 0.5] ] - - this._firstInit = true - this._text = null - this._lines = null - this._background = createBackground(gl) -} - -var proto = Axes.prototype - -proto.update = function(options) { - options = options || {} - - //Option parsing helper functions - function parseOption(nest, cons, name) { - if(name in options) { - var opt = options[name] - var prev = this[name] - var next - if(nest ? (Array.isArray(opt) && Array.isArray(opt[0])) : - Array.isArray(opt) ) { - this[name] = next = [ cons(opt[0]), cons(opt[1]), cons(opt[2]) ] - } else { - this[name] = next = [ cons(opt), cons(opt), cons(opt) ] - } - for(var i=0; i<3; ++i) { - if(next[i] !== prev[i]) { - return true - } - } - } - return false - } - - var NUMBER = parseOption.bind(this, false, Number) - var BOOLEAN = parseOption.bind(this, false, Boolean) - var STRING = parseOption.bind(this, false, String) - var COLOR = parseOption.bind(this, true, function(v) { - if(Array.isArray(v)) { - if(v.length === 3) { - return [ +v[0], +v[1], +v[2], 1.0 ] - } else if(v.length === 4) { - return [ +v[0], +v[1], +v[2], +v[3] ] - } - } - return [ 0, 0, 0, 1 ] - }) - - //Tick marks and bounds - var nextTicks - var ticksUpdate = false - var boundsChanged = false - if('bounds' in options) { - var bounds = options.bounds -i_loop: - for(var i=0; i<2; ++i) { - for(var j=0; j<3; ++j) { - if(bounds[i][j] !== this.bounds[i][j]) { - boundsChanged = true - } - this.bounds[i][j] = bounds[i][j] - } - } - } - if('ticks' in options) { - nextTicks = options.ticks - ticksUpdate = true - this.autoTicks = false - for(var i=0; i<3; ++i) { - this.tickSpacing[i] = 0.0 - } - } else if(NUMBER('tickSpacing')) { - this.autoTicks = true - boundsChanged = true - } - - if(this._firstInit) { - if(!('ticks' in options || 'tickSpacing' in options)) { - this.autoTicks = true - } - - //Force tick recomputation on first update - boundsChanged = true - ticksUpdate = true - this._firstInit = false - } - - if(boundsChanged && this.autoTicks) { - nextTicks = Ticks.create(this.bounds, this.tickSpacing) - ticksUpdate = true - } - - //Compare next ticks to previous ticks, only update if needed - if(ticksUpdate) { - for(var i=0; i<3; ++i) { - nextTicks[i].sort(function(a,b) { - return a.x-b.x - }) - } - if(Ticks.equal(nextTicks, this.ticks)) { - ticksUpdate = false - } else { - this.ticks = nextTicks - } - } - - //Parse tick properties - BOOLEAN('tickEnable') - if(STRING('tickFont')) { - ticksUpdate = true //If font changes, must rebuild vbo - } - NUMBER('tickSize') - NUMBER('tickAngle') - NUMBER('tickPad') - COLOR('tickColor') - - //Axis labels - var labelUpdate = STRING('labels') - if(STRING('labelFont')) { - labelUpdate = true - } - BOOLEAN('labelEnable') - NUMBER('labelSize') - NUMBER('labelPad') - COLOR('labelColor') - - //Axis lines - BOOLEAN('lineEnable') - BOOLEAN('lineMirror') - NUMBER('lineWidth') - COLOR('lineColor') - - //Axis line ticks - BOOLEAN('lineTickEnable') - BOOLEAN('lineTickMirror') - NUMBER('lineTickLength') - NUMBER('lineTickWidth') - COLOR('lineTickColor') - - //Grid lines - BOOLEAN('gridEnable') - NUMBER('gridWidth') - COLOR('gridColor') - - //Zero line - BOOLEAN('zeroEnable') - COLOR('zeroLineColor') - NUMBER('zeroLineWidth') - - //Background - BOOLEAN('backgroundEnable') - COLOR('backgroundColor') - - //Update text if necessary - if(!this._text) { - this._text = createText( - this.gl, - this.bounds, - this.labels, - this.labelFont, - this.ticks, - this.tickFont) - } else if(this._text && (labelUpdate || ticksUpdate)) { - this._text.update( - this.bounds, - this.labels, - this.labelFont, - this.ticks, - this.tickFont) - } - - //Update lines if necessary - if(this._lines && ticksUpdate) { - this._lines.dispose() - this._lines = null - } - if(!this._lines) { - this._lines = createLines(this.gl, this.bounds, this.ticks) - } -} - -function OffsetInfo() { - this.primalOffset = [0,0,0] - this.primalMinor = [0,0,0] - this.mirrorOffset = [0,0,0] - this.mirrorMinor = [0,0,0] -} - -var LINE_OFFSET = [ new OffsetInfo(), new OffsetInfo(), new OffsetInfo() ] - -function computeLineOffset(result, i, bounds, cubeEdges, cubeAxis) { - var primalOffset = result.primalOffset - var primalMinor = result.primalMinor - var dualOffset = result.mirrorOffset - var dualMinor = result.mirrorMinor - var e = cubeEdges[i] - - //Calculate offsets - for(var j=0; j<3; ++j) { - if(i === j) { - continue - } - var a = primalOffset, - b = dualOffset, - c = primalMinor, - d = dualMinor - if(e & (1< 0) { - c[j] = -1 - d[j] = 0 - } else { - c[j] = 0 - d[j] = +1 - } - } -} - -var CUBE_ENABLE = [0,0,0] -var DEFAULT_PARAMS = { - model: identity, - view: identity, - projection: identity -} - -proto.isOpaque = function() { - return true -} - -proto.isTransparent = function() { - return false -} - -proto.drawTransparent = function(params) {} - -var ALIGN_OPTION_AUTO = 0 // i.e. as defined in the shader the text would rotate to stay upwards range: [-90,90] - -var PRIMAL_MINOR = [0,0,0] -var MIRROR_MINOR = [0,0,0] -var PRIMAL_OFFSET = [0,0,0] - -proto.draw = function(params) { - params = params || DEFAULT_PARAMS - - var gl = this.gl - - //Geometry for camera and axes - var model = params.model || identity - var view = params.view || identity - var projection = params.projection || identity - var bounds = this.bounds - - //Unpack axis info - var cubeParams = getCubeProperties(model, view, projection, bounds) - var cubeEdges = cubeParams.cubeEdges - var cubeAxis = cubeParams.axis - - var cx = view[12] - var cy = view[13] - var cz = view[14] - var cw = view[15] - - var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight - - for(var i=0; i<3; ++i) { - this.lastCubeProps.cubeEdges[i] = cubeEdges[i] - this.lastCubeProps.axis[i] = cubeAxis[i] - } - - //Compute axis info - var lineOffset = LINE_OFFSET - for(var i=0; i<3; ++i) { - computeLineOffset( - LINE_OFFSET[i], - i, - this.bounds, - cubeEdges, - cubeAxis) - } - - //Set up state parameters - var gl = this.gl - - //Draw background first - var cubeEnable = CUBE_ENABLE - for(var i=0; i<3; ++i) { - if(this.backgroundEnable[i]) { - cubeEnable[i] = cubeAxis[i] - } else { - cubeEnable[i] = 0 - } - } - - this._background.draw( - model, - view, - projection, - bounds, - cubeEnable, - this.backgroundColor) - - //Draw lines - this._lines.bind( - model, - view, - projection, - this) - - //First draw grid lines and zero lines - for(var i=0; i<3; ++i) { - var x = [0,0,0] - if(cubeAxis[i] > 0) { - x[i] = bounds[1][i] - } else { - x[i] = bounds[0][i] - } - - //Draw grid lines - for(var j=0; j<2; ++j) { - var u = (i + 1 + j) % 3 - var v = (i + 1 + (j^1)) % 3 - if(this.gridEnable[u]) { - this._lines.drawGrid(u, v, this.bounds, x, this.gridColor[u], this.gridWidth[u]*this.pixelRatio) - } - } - - //Draw zero lines (need to do this AFTER all grid lines are drawn) - for(var j=0; j<2; ++j) { - var u = (i + 1 + j) % 3 - var v = (i + 1 + (j^1)) % 3 - if(this.zeroEnable[v]) { - //Check if zero line in bounds - if(Math.min(bounds[0][v], bounds[1][v]) <= 0 && Math.max(bounds[0][v], bounds[1][v]) >= 0) { - this._lines.drawZero(u, v, this.bounds, x, this.zeroLineColor[v], this.zeroLineWidth[v]*this.pixelRatio) - } - } - } - } - - //Then draw axis lines and tick marks - for(var i=0; i<3; ++i) { - - //Draw axis lines - if(this.lineEnable[i]) { - this._lines.drawAxisLine(i, this.bounds, lineOffset[i].primalOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) - } - if(this.lineMirror[i]) { - this._lines.drawAxisLine(i, this.bounds, lineOffset[i].mirrorOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) - } - - //Compute minor axes - var primalMinor = copyVec3(PRIMAL_MINOR, lineOffset[i].primalMinor) - var mirrorMinor = copyVec3(MIRROR_MINOR, lineOffset[i].mirrorMinor) - var tickLength = this.lineTickLength - var op = 0 - for(var j=0; j<3; ++j) { - var scaleFactor = pixelScaleF / model[5*j] - primalMinor[j] *= tickLength[j] * scaleFactor - mirrorMinor[j] *= tickLength[j] * scaleFactor - } - - //Draw axis line ticks - if(this.lineTickEnable[i]) { - this._lines.drawAxisTicks(i, lineOffset[i].primalOffset, primalMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) - } - if(this.lineTickMirror[i]) { - this._lines.drawAxisTicks(i, lineOffset[i].mirrorOffset, mirrorMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) - } - } - this._lines.unbind() - - //Draw text sprites - this._text.bind( - model, - view, - projection, - this.pixelRatio) - - var alignOpt // options in shader are from this list {-1, 0, 1, 2, 3, ..., n} - // -1: backward compatible - // 0: raw data - // 1: auto align, free angles - // 2: auto align, horizontal or vertical - //3-n: auto align, round to n directions e.g. 12 -> round to angles with 30-degree steps - - var hv_ratio = 0.5 // can have an effect on the ratio between horizontals and verticals when using option 2 - - var enableAlign - var alignDir - - function alignTo(i) { - alignDir = [0,0,0] - alignDir[i] = 1 - } - - function solveTickAlignments(i, minor, major) { - - var i1 = (i + 1) % 3 - var i2 = (i + 2) % 3 - - var A = minor[i1] - var B = minor[i2] - var C = major[i1] - var D = major[i2] - - if ((A > 0) && (D > 0)) { alignTo(i1); return; } - else if ((A > 0) && (D < 0)) { alignTo(i1); return; } - else if ((A < 0) && (D > 0)) { alignTo(i1); return; } - else if ((A < 0) && (D < 0)) { alignTo(i1); return; } - else if ((B > 0) && (C > 0)) { alignTo(i2); return; } - else if ((B > 0) && (C < 0)) { alignTo(i2); return; } - else if ((B < 0) && (C > 0)) { alignTo(i2); return; } - else if ((B < 0) && (C < 0)) { alignTo(i2); return; } - } - - for(var i=0; i<3; ++i) { - - var minor = lineOffset[i].primalMinor - var major = lineOffset[i].mirrorMinor - - var offset = copyVec3(PRIMAL_OFFSET, lineOffset[i].primalOffset) - - for(var j=0; j<3; ++j) { - if(this.lineTickEnable[i]) { - offset[j] += pixelScaleF * minor[j] * Math.max(this.lineTickLength[j], 0) / model[5*j] - } - } - - var axis = [0,0,0] - axis[i] = 1 - - //Draw tick text - if(this.tickEnable[i]) { - - if(this.tickAngle[i] === -3600) { - this.tickAngle[i] = 0 - this._tickAlign[i] = 'auto' - } else { - this._tickAlign[i] = -1 - } - - enableAlign = 1; - - alignOpt = [this._tickAlign[i], hv_ratio, enableAlign] - if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO - else alignOpt[0] = parseInt('' + alignOpt[0]) - - alignDir = [0,0,0] - solveTickAlignments(i, minor, major) - - //Add tick padding - for(var j=0; j<3; ++j) { - offset[j] += pixelScaleF * minor[j] * this.tickPad[j] / model[5*j] - } - - //Draw axis - this._text.drawTicks( - i, - this.tickSize[i], - this.tickAngle[i], - offset, - this.tickColor[i], - axis, - alignDir, - alignOpt) - } - - //Draw labels - if(this.labelEnable[i]) { - - enableAlign = 0 - alignDir = [0,0,0] - if(this.labels[i].length > 4) { // for large label axis enable alignDir to axis - alignTo(i) - enableAlign = 1 - } - - alignOpt = [this._labelAlign[i], hv_ratio, enableAlign] - if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO - else alignOpt[0] = parseInt('' + alignOpt[0]) - - //Add label padding - for(var j=0; j<3; ++j) { - offset[j] += pixelScaleF * minor[j] * this.labelPad[j] / model[5*j] - } - offset[i] += 0.5 * (bounds[0][i] + bounds[1][i]) - - //Draw axis - this._text.drawLabel( - i, - this.labelSize[i], - this._labelAngle[i], - offset, - this.labelColor[i], - [0,0,0], - alignDir, - alignOpt) - } - } - - this._text.unbind() -} - -proto.dispose = function() { - this._text.dispose() - this._lines.dispose() - this._background.dispose() - this._lines = null - this._text = null - this._background = null - this.gl = null -} - -function createAxes(gl, options) { - var axes = new Axes(gl) - axes.update(options) - return axes -} +'use strict' + +module.exports = createAxes + +var createText = _dereq_('./lib/text.js') +var createLines = _dereq_('./lib/lines.js') +var createBackground = _dereq_('./lib/background.js') +var getCubeProperties = _dereq_('./lib/cube.js') +var Ticks = _dereq_('./lib/ticks.js') + +var identity = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1]) + +function copyVec3(a, b) { + a[0] = b[0] + a[1] = b[1] + a[2] = b[2] + return a +} + +function Axes(gl) { + this.gl = gl + + this.pixelRatio = 1 + + this.bounds = [ [-10, -10, -10], + [ 10, 10, 10] ] + this.ticks = [ [], [], [] ] + this.autoTicks = true + this.tickSpacing = [ 1, 1, 1 ] + + this.tickEnable = [ true, true, true ] + this.tickFont = [ 'sans-serif', 'sans-serif', 'sans-serif' ] + this.tickSize = [ 12, 12, 12 ] + this.tickAngle = [ 0, 0, 0 ] + this._tickAlign = [ 'auto', 'auto', 'auto' ] + this.tickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + this.tickPad = [ 10, 10, 10 ] + + this.lastCubeProps = { + cubeEdges: [0,0,0], + axis: [0,0,0] + } + + this.labels = [ 'x', 'y', 'z' ] + this.labelEnable = [ true, true, true ] + this.labelFont = 'sans-serif' + this.labelSize = [ 20, 20, 20 ] + this.labelAngle = [ 0, 0, 0 ] + this.labelAlign = [ 'auto', 'auto', 'auto' ] + this.labelColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + this.labelPad = [ 10, 10, 10 ] + + this.lineEnable = [ true, true, true ] + this.lineMirror = [ false, false, false ] + this.lineWidth = [ 1, 1, 1 ] + this.lineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + + this.lineTickEnable = [ true, true, true ] + this.lineTickMirror = [ false, false, false ] + this.lineTickLength = [ 0, 0, 0 ] + this.lineTickWidth = [ 1, 1, 1 ] + this.lineTickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + + this.gridEnable = [ true, true, true ] + this.gridWidth = [ 1, 1, 1 ] + this.gridColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + + this.zeroEnable = [ true, true, true ] + this.zeroLineColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] + this.zeroLineWidth = [ 2, 2, 2 ] + + this.backgroundEnable = [ false, false, false ] + this.backgroundColor = [ [0.8, 0.8, 0.8, 0.5], + [0.8, 0.8, 0.8, 0.5], + [0.8, 0.8, 0.8, 0.5] ] + + this._firstInit = true + this._text = null + this._lines = null + this._background = createBackground(gl) +} + +var proto = Axes.prototype + +proto.update = function(options) { + options = options || {} + + //Option parsing helper functions + function parseOption(nest, cons, name) { + if(name in options) { + var opt = options[name] + var prev = this[name] + var next + if(nest ? (Array.isArray(opt) && Array.isArray(opt[0])) : + Array.isArray(opt) ) { + this[name] = next = [ cons(opt[0]), cons(opt[1]), cons(opt[2]) ] + } else { + this[name] = next = [ cons(opt), cons(opt), cons(opt) ] + } + for(var i=0; i<3; ++i) { + if(next[i] !== prev[i]) { + return true + } + } + } + return false + } + + var NUMBER = parseOption.bind(this, false, Number) + var BOOLEAN = parseOption.bind(this, false, Boolean) + var STRING = parseOption.bind(this, false, String) + var COLOR = parseOption.bind(this, true, function(v) { + if(Array.isArray(v)) { + if(v.length === 3) { + return [ +v[0], +v[1], +v[2], 1.0 ] + } else if(v.length === 4) { + return [ +v[0], +v[1], +v[2], +v[3] ] + } + } + return [ 0, 0, 0, 1 ] + }) + + //Tick marks and bounds + var nextTicks + var ticksUpdate = false + var boundsChanged = false + if('bounds' in options) { + var bounds = options.bounds +i_loop: + for(var i=0; i<2; ++i) { + for(var j=0; j<3; ++j) { + if(bounds[i][j] !== this.bounds[i][j]) { + boundsChanged = true + } + this.bounds[i][j] = bounds[i][j] + } + } + } + if('ticks' in options) { + nextTicks = options.ticks + ticksUpdate = true + this.autoTicks = false + for(var i=0; i<3; ++i) { + this.tickSpacing[i] = 0.0 + } + } else if(NUMBER('tickSpacing')) { + this.autoTicks = true + boundsChanged = true + } + + if(this._firstInit) { + if(!('ticks' in options || 'tickSpacing' in options)) { + this.autoTicks = true + } + + //Force tick recomputation on first update + boundsChanged = true + ticksUpdate = true + this._firstInit = false + } + + if(boundsChanged && this.autoTicks) { + nextTicks = Ticks.create(this.bounds, this.tickSpacing) + ticksUpdate = true + } + + //Compare next ticks to previous ticks, only update if needed + if(ticksUpdate) { + for(var i=0; i<3; ++i) { + nextTicks[i].sort(function(a,b) { + return a.x-b.x + }) + } + if(Ticks.equal(nextTicks, this.ticks)) { + ticksUpdate = false + } else { + this.ticks = nextTicks + } + } + + //Parse tick properties + BOOLEAN('tickEnable') + if(STRING('tickFont')) { + ticksUpdate = true //If font changes, must rebuild vbo + } + NUMBER('tickSize') + NUMBER('tickAngle') + NUMBER('tickPad') + COLOR('tickColor') + + //Axis labels + var labelUpdate = STRING('labels') + if(STRING('labelFont')) { + labelUpdate = true + } + BOOLEAN('labelEnable') + NUMBER('labelSize') + NUMBER('labelPad') + COLOR('labelColor') + + //Axis lines + BOOLEAN('lineEnable') + BOOLEAN('lineMirror') + NUMBER('lineWidth') + COLOR('lineColor') + + //Axis line ticks + BOOLEAN('lineTickEnable') + BOOLEAN('lineTickMirror') + NUMBER('lineTickLength') + NUMBER('lineTickWidth') + COLOR('lineTickColor') + + //Grid lines + BOOLEAN('gridEnable') + NUMBER('gridWidth') + COLOR('gridColor') + + //Zero line + BOOLEAN('zeroEnable') + COLOR('zeroLineColor') + NUMBER('zeroLineWidth') + + //Background + BOOLEAN('backgroundEnable') + COLOR('backgroundColor') + + //Update text if necessary + if(!this._text) { + this._text = createText( + this.gl, + this.bounds, + this.labels, + this.labelFont, + this.ticks, + this.tickFont) + } else if(this._text && (labelUpdate || ticksUpdate)) { + this._text.update( + this.bounds, + this.labels, + this.labelFont, + this.ticks, + this.tickFont) + } + + //Update lines if necessary + if(this._lines && ticksUpdate) { + this._lines.dispose() + this._lines = null + } + if(!this._lines) { + this._lines = createLines(this.gl, this.bounds, this.ticks) + } +} + +function OffsetInfo() { + this.primalOffset = [0,0,0] + this.primalMinor = [0,0,0] + this.mirrorOffset = [0,0,0] + this.mirrorMinor = [0,0,0] +} + +var LINE_OFFSET = [ new OffsetInfo(), new OffsetInfo(), new OffsetInfo() ] + +function computeLineOffset(result, i, bounds, cubeEdges, cubeAxis) { + var primalOffset = result.primalOffset + var primalMinor = result.primalMinor + var dualOffset = result.mirrorOffset + var dualMinor = result.mirrorMinor + var e = cubeEdges[i] + + //Calculate offsets + for(var j=0; j<3; ++j) { + if(i === j) { + continue + } + var a = primalOffset, + b = dualOffset, + c = primalMinor, + d = dualMinor + if(e & (1< 0) { + c[j] = -1 + d[j] = 0 + } else { + c[j] = 0 + d[j] = +1 + } + } +} + +var CUBE_ENABLE = [0,0,0] +var DEFAULT_PARAMS = { + model: identity, + view: identity, + projection: identity +} + +proto.isOpaque = function() { + return true +} + +proto.isTransparent = function() { + return false +} + +proto.drawTransparent = function(params) {} + +var ALIGN_OPTION_AUTO = 0 // i.e. as defined in the shader the text would rotate to stay upwards range: [-90,90] + +var PRIMAL_MINOR = [0,0,0] +var MIRROR_MINOR = [0,0,0] +var PRIMAL_OFFSET = [0,0,0] + +proto.draw = function(params) { + params = params || DEFAULT_PARAMS + + var gl = this.gl + + //Geometry for camera and axes + var model = params.model || identity + var view = params.view || identity + var projection = params.projection || identity + var bounds = this.bounds + + //Unpack axis info + var cubeParams = getCubeProperties(model, view, projection, bounds) + var cubeEdges = cubeParams.cubeEdges + var cubeAxis = cubeParams.axis + + var cx = view[12] + var cy = view[13] + var cz = view[14] + var cw = view[15] + + var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight + + for(var i=0; i<3; ++i) { + this.lastCubeProps.cubeEdges[i] = cubeEdges[i] + this.lastCubeProps.axis[i] = cubeAxis[i] + } + + //Compute axis info + var lineOffset = LINE_OFFSET + for(var i=0; i<3; ++i) { + computeLineOffset( + LINE_OFFSET[i], + i, + this.bounds, + cubeEdges, + cubeAxis) + } + + //Set up state parameters + var gl = this.gl + + //Draw background first + var cubeEnable = CUBE_ENABLE + for(var i=0; i<3; ++i) { + if(this.backgroundEnable[i]) { + cubeEnable[i] = cubeAxis[i] + } else { + cubeEnable[i] = 0 + } + } + + this._background.draw( + model, + view, + projection, + bounds, + cubeEnable, + this.backgroundColor) + + //Draw lines + this._lines.bind( + model, + view, + projection, + this) + + //First draw grid lines and zero lines + for(var i=0; i<3; ++i) { + var x = [0,0,0] + if(cubeAxis[i] > 0) { + x[i] = bounds[1][i] + } else { + x[i] = bounds[0][i] + } + + //Draw grid lines + for(var j=0; j<2; ++j) { + var u = (i + 1 + j) % 3 + var v = (i + 1 + (j^1)) % 3 + if(this.gridEnable[u]) { + this._lines.drawGrid(u, v, this.bounds, x, this.gridColor[u], this.gridWidth[u]*this.pixelRatio) + } + } + + //Draw zero lines (need to do this AFTER all grid lines are drawn) + for(var j=0; j<2; ++j) { + var u = (i + 1 + j) % 3 + var v = (i + 1 + (j^1)) % 3 + if(this.zeroEnable[v]) { + //Check if zero line in bounds + if(Math.min(bounds[0][v], bounds[1][v]) <= 0 && Math.max(bounds[0][v], bounds[1][v]) >= 0) { + this._lines.drawZero(u, v, this.bounds, x, this.zeroLineColor[v], this.zeroLineWidth[v]*this.pixelRatio) + } + } + } + } + + //Then draw axis lines and tick marks + for(var i=0; i<3; ++i) { + + //Draw axis lines + if(this.lineEnable[i]) { + this._lines.drawAxisLine(i, this.bounds, lineOffset[i].primalOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) + } + if(this.lineMirror[i]) { + this._lines.drawAxisLine(i, this.bounds, lineOffset[i].mirrorOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) + } + + //Compute minor axes + var primalMinor = copyVec3(PRIMAL_MINOR, lineOffset[i].primalMinor) + var mirrorMinor = copyVec3(MIRROR_MINOR, lineOffset[i].mirrorMinor) + var tickLength = this.lineTickLength + var op = 0 + for(var j=0; j<3; ++j) { + var scaleFactor = pixelScaleF / model[5*j] + primalMinor[j] *= tickLength[j] * scaleFactor + mirrorMinor[j] *= tickLength[j] * scaleFactor + } + + //Draw axis line ticks + if(this.lineTickEnable[i]) { + this._lines.drawAxisTicks(i, lineOffset[i].primalOffset, primalMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) + } + if(this.lineTickMirror[i]) { + this._lines.drawAxisTicks(i, lineOffset[i].mirrorOffset, mirrorMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) + } + } + this._lines.unbind() + + //Draw text sprites + this._text.bind( + model, + view, + projection, + this.pixelRatio) + + var alignOpt // options in shader are from this list {-1, 0, 1, 2, 3, ..., n} + // -1: backward compatible + // 0: raw data + // 1: auto align, free angles + // 2: auto align, horizontal or vertical + //3-n: auto align, round to n directions e.g. 12 -> round to angles with 30-degree steps + + var hv_ratio = 0.5 // can have an effect on the ratio between horizontals and verticals when using option 2 + + var enableAlign + var alignDir + + function alignTo(i) { + alignDir = [0,0,0] + alignDir[i] = 1 + } + + function solveTickAlignments(i, minor, major) { + + var i1 = (i + 1) % 3 + var i2 = (i + 2) % 3 + + var A = minor[i1] + var B = minor[i2] + var C = major[i1] + var D = major[i2] + + if ((A > 0) && (D > 0)) { alignTo(i1); return; } + else if ((A > 0) && (D < 0)) { alignTo(i1); return; } + else if ((A < 0) && (D > 0)) { alignTo(i1); return; } + else if ((A < 0) && (D < 0)) { alignTo(i1); return; } + else if ((B > 0) && (C > 0)) { alignTo(i2); return; } + else if ((B > 0) && (C < 0)) { alignTo(i2); return; } + else if ((B < 0) && (C > 0)) { alignTo(i2); return; } + else if ((B < 0) && (C < 0)) { alignTo(i2); return; } + } + + for(var i=0; i<3; ++i) { + + var minor = lineOffset[i].primalMinor + var major = lineOffset[i].mirrorMinor + + var offset = copyVec3(PRIMAL_OFFSET, lineOffset[i].primalOffset) + + for(var j=0; j<3; ++j) { + if(this.lineTickEnable[i]) { + offset[j] += pixelScaleF * minor[j] * Math.max(this.lineTickLength[j], 0) / model[5*j] + } + } + + var axis = [0,0,0] + axis[i] = 1 + + //Draw tick text + if(this.tickEnable[i]) { + + if(this.tickAngle[i] === -3600) { + this.tickAngle[i] = 0 + this._tickAlign[i] = 'auto' + } else { + this._tickAlign[i] = -1 + } + + enableAlign = 1; + + alignOpt = [this._tickAlign[i], hv_ratio, enableAlign] + if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO + else alignOpt[0] = parseInt('' + alignOpt[0]) + + alignDir = [0,0,0] + solveTickAlignments(i, minor, major) + + //Add tick padding + for(var j=0; j<3; ++j) { + offset[j] += pixelScaleF * minor[j] * this.tickPad[j] / model[5*j] + } + + //Draw axis + this._text.drawTicks( + i, + this.tickSize[i], + this.tickAngle[i], + offset, + this.tickColor[i], + axis, + alignDir, + alignOpt) + } + + //Draw labels + if(this.labelEnable[i]) { + + enableAlign = 0 + alignDir = [0,0,0] + if(this.labels[i].length > 4) { // for large label axis enable alignDir to axis + alignTo(i) + enableAlign = 1 + } + + alignOpt = [this.labelAlign[i], hv_ratio, enableAlign] + if(alignOpt[0] === 'auto') alignOpt[0] = ALIGN_OPTION_AUTO + else alignOpt[0] = parseInt('' + alignOpt[0]) + + //Add label padding + for(var j=0; j<3; ++j) { + offset[j] += pixelScaleF * minor[j] * this.labelPad[j] / model[5*j] + } + offset[i] += 0.5 * (bounds[0][i] + bounds[1][i]) + + //Draw axis + this._text.drawLabel( + i, + this.labelSize[i], + this.labelAngle[i], + offset, + this.labelColor[i], + [0,0,0], + alignDir, + alignOpt) + } + } + + this._text.unbind() +} + +proto.dispose = function() { + this._text.dispose() + this._lines.dispose() + this._background.dispose() + this._lines = null + this._text = null + this._background = null + this.gl = null +} + +function createAxes(gl, options) { + var axes = new Axes(gl) + axes.update(options) + return axes +} },{"./lib/background.js":223,"./lib/cube.js":224,"./lib/lines.js":225,"./lib/text.js":227,"./lib/ticks.js":228}],223:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createBackgroundCube - -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createShader = _dereq_('./shaders').bg - -function BackgroundCube(gl, buffer, vao, shader) { - this.gl = gl - this.buffer = buffer - this.vao = vao - this.shader = shader -} - -var proto = BackgroundCube.prototype - -proto.draw = function(model, view, projection, bounds, enable, colors) { - var needsBG = false - for(var i=0; i<3; ++i) { - needsBG = needsBG || enable[i] - } - if(!needsBG) { - return - } - - var gl = this.gl - - gl.enable(gl.POLYGON_OFFSET_FILL) - gl.polygonOffset(1, 2) - - this.shader.bind() - this.shader.uniforms = { - model: model, - view: view, - projection: projection, - bounds: bounds, - enable: enable, - colors: colors - } - this.vao.bind() - this.vao.draw(this.gl.TRIANGLES, 36) - this.vao.unbind() - - gl.disable(gl.POLYGON_OFFSET_FILL) -} - -proto.dispose = function() { - this.vao.dispose() - this.buffer.dispose() - this.shader.dispose() -} - -function createBackgroundCube(gl) { - //Create cube vertices - var vertices = [] - var indices = [] - var ptr = 0 - for(var d=0; d<3; ++d) { - var u = (d+1) % 3 - var v = (d+2) % 3 - var x = [0,0,0] - var c = [0,0,0] - for(var s=-1; s<=1; s+=2) { - indices.push(ptr, ptr+2, ptr+1, - ptr+1, ptr+2, ptr+3) - x[d] = s - c[d] = s - for(var i=-1; i<=1; i+=2) { - x[u] = i - for(var j=-1; j<=1; j+=2) { - x[v] = j - vertices.push(x[0], x[1], x[2], - c[0], c[1], c[2]) - ptr += 1 - } - } - //Swap u and v - var tt = u - u = v - v = tt - } - } - - //Allocate buffer and vertex array - var buffer = createBuffer(gl, new Float32Array(vertices)) - var elements = createBuffer(gl, new Uint16Array(indices), gl.ELEMENT_ARRAY_BUFFER) - var vao = createVAO(gl, [ - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 0, - stride: 24 - }, - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 12, - stride: 24 - } - ], elements) - - //Create shader object - var shader = createShader(gl) - shader.attributes.position.location = 0 - shader.attributes.normal.location = 1 - - return new BackgroundCube(gl, buffer, vao, shader) -} +'use strict' + +module.exports = createBackgroundCube + +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createShader = _dereq_('./shaders').bg + +function BackgroundCube(gl, buffer, vao, shader) { + this.gl = gl + this.buffer = buffer + this.vao = vao + this.shader = shader +} + +var proto = BackgroundCube.prototype + +proto.draw = function(model, view, projection, bounds, enable, colors) { + var needsBG = false + for(var i=0; i<3; ++i) { + needsBG = needsBG || enable[i] + } + if(!needsBG) { + return + } + + var gl = this.gl + + gl.enable(gl.POLYGON_OFFSET_FILL) + gl.polygonOffset(1, 2) + + this.shader.bind() + this.shader.uniforms = { + model: model, + view: view, + projection: projection, + bounds: bounds, + enable: enable, + colors: colors + } + this.vao.bind() + this.vao.draw(this.gl.TRIANGLES, 36) + this.vao.unbind() + + gl.disable(gl.POLYGON_OFFSET_FILL) +} + +proto.dispose = function() { + this.vao.dispose() + this.buffer.dispose() + this.shader.dispose() +} + +function createBackgroundCube(gl) { + //Create cube vertices + var vertices = [] + var indices = [] + var ptr = 0 + for(var d=0; d<3; ++d) { + var u = (d+1) % 3 + var v = (d+2) % 3 + var x = [0,0,0] + var c = [0,0,0] + for(var s=-1; s<=1; s+=2) { + indices.push(ptr, ptr+2, ptr+1, + ptr+1, ptr+2, ptr+3) + x[d] = s + c[d] = s + for(var i=-1; i<=1; i+=2) { + x[u] = i + for(var j=-1; j<=1; j+=2) { + x[v] = j + vertices.push(x[0], x[1], x[2], + c[0], c[1], c[2]) + ptr += 1 + } + } + //Swap u and v + var tt = u + u = v + v = tt + } + } + + //Allocate buffer and vertex array + var buffer = createBuffer(gl, new Float32Array(vertices)) + var elements = createBuffer(gl, new Uint16Array(indices), gl.ELEMENT_ARRAY_BUFFER) + var vao = createVAO(gl, [ + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 0, + stride: 24 + }, + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 12, + stride: 24 + } + ], elements) + + //Create shader object + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.normal.location = 1 + + return new BackgroundCube(gl, buffer, vao, shader) +} },{"./shaders":226,"gl-buffer":230,"gl-vao":310}],224:[function(_dereq_,module,exports){ -"use strict" - -module.exports = getCubeEdges - -var bits = _dereq_('bit-twiddle') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var splitPoly = _dereq_('split-polygon') -var orient = _dereq_('robust-orientation') - -var mvp = new Array(16) -var imvp = new Array(16) -var pCubeVerts = new Array(8) -var cubeVerts = new Array(8) -var x = new Array(3) -var zero3 = [0,0,0] - -;(function() { - for(var i=0; i<8; ++i) { - pCubeVerts[i] =[1,1,1,1] - cubeVerts[i] = [1,1,1] - } -})() - - -function transformHg(result, x, mat) { - for(var i=0; i<4; ++i) { - result[i] = mat[12+i] - for(var j=0; j<3; ++j) { - result[i] += x[j]*mat[4*j+i] - } - } -} - -var FRUSTUM_PLANES = [ - [ 0, 0, 1, 0, 0], - [ 0, 0,-1, 1, 0], - [ 0,-1, 0, 1, 0], - [ 0, 1, 0, 1, 0], - [-1, 0, 0, 1, 0], - [ 1, 0, 0, 1, 0] -] - -function polygonArea(p) { - for(var i=0; i o0) { - closest |= 1< o0) { - closest |= 1< cubeVerts[i][1]) { - bottom = i - } - } - - //Find left/right neighbors of bottom vertex - var left = -1 - for(var i=0; i<3; ++i) { - var idx = bottom ^ (1< cubeVerts[right][0]) { - right = idx - } - } - - //Determine edge axis coordinates - var cubeEdges = CUBE_EDGES - cubeEdges[0] = cubeEdges[1] = cubeEdges[2] = 0 - cubeEdges[bits.log2(left^bottom)] = bottom&left - cubeEdges[bits.log2(bottom^right)] = bottom&right - var top = right ^ 7 - if(top === closest || top === farthest) { - top = left ^ 7 - cubeEdges[bits.log2(right^top)] = top&right - } else { - cubeEdges[bits.log2(left^top)] = top&left - } - - //Determine visible faces - var axis = CUBE_AXIS - var cutCorner = closest - for(var d=0; d<3; ++d) { - if(cutCorner & (1< o0) { + closest |= 1< o0) { + closest |= 1< cubeVerts[i][1]) { + bottom = i + } + } + + //Find left/right neighbors of bottom vertex + var left = -1 + for(var i=0; i<3; ++i) { + var idx = bottom ^ (1< cubeVerts[right][0]) { + right = idx + } + } + + //Determine edge axis coordinates + var cubeEdges = CUBE_EDGES + cubeEdges[0] = cubeEdges[1] = cubeEdges[2] = 0 + cubeEdges[bits.log2(left^bottom)] = bottom&left + cubeEdges[bits.log2(bottom^right)] = bottom&right + var top = right ^ 7 + if(top === closest || top === farthest) { + top = left ^ 7 + cubeEdges[bits.log2(right^top)] = top&right + } else { + cubeEdges[bits.log2(left^top)] = top&left + } + + //Determine visible faces + var axis = CUBE_AXIS + var cutCorner = closest + for(var d=0; d<3; ++d) { + if(cutCorner & (1< HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]) -var textFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]) -exports.text = function(gl) { - return createShader(gl, textVert, textFrag, null, [ - {name: 'position', type: 'vec3'} - ]) -} - -var bgVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]) -var bgFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]) -exports.bg = function(gl) { - return createShader(gl, bgVert, bgFrag, null, [ - {name: 'position', type: 'vec3'}, - {name: 'normal', type: 'vec3'} - ]) -} +'use strict' + +var glslify = _dereq_('glslify') +var createShader = _dereq_('gl-shader') + +var lineVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\nuniform vec3 offset, majorAxis, minorAxis, screenAxis;\nuniform float lineWidth;\nuniform vec2 screenShape;\n\nvec3 project(vec3 p) {\n vec4 pp = projection * view * model * vec4(p, 1.0);\n return pp.xyz / max(pp.w, 0.0001);\n}\n\nvoid main() {\n vec3 major = position.x * majorAxis;\n vec3 minor = position.y * minorAxis;\n\n vec3 vPosition = major + minor + offset;\n vec3 pPosition = project(vPosition);\n vec3 offset = project(vPosition + screenAxis * position.z);\n\n vec2 screen = normalize((offset - pPosition).xy * screenShape) / screenShape;\n\n gl_Position = vec4(pPosition + vec3(0.5 * screen * lineWidth, 0), 1.0);\n}\n"]) +var lineFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]) +exports.line = function(gl) { + return createShader(gl, lineVert, lineFrag, null, [ + {name: 'position', type: 'vec3'} + ]) +} + +var textVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\nuniform vec3 offset, axis, alignDir, alignOpt;\nuniform float scale, angle, pixelScale;\nuniform vec2 resolution;\n\nvec3 project(vec3 p) {\n vec4 pp = projection * view * model * vec4(p, 1.0);\n return pp.xyz / max(pp.w, 0.0001);\n}\n\nfloat computeViewAngle(vec3 a, vec3 b) {\n vec3 A = project(a);\n vec3 B = project(b);\n\n return atan(\n (B.y - A.y) * resolution.y,\n (B.x - A.x) * resolution.x\n );\n}\n\nconst float PI = 3.141592;\nconst float TWO_PI = 2.0 * PI;\nconst float HALF_PI = 0.5 * PI;\nconst float ONE_AND_HALF_PI = 1.5 * PI;\n\nint option = int(floor(alignOpt.x + 0.001));\nfloat hv_ratio = alignOpt.y;\nbool enableAlign = (alignOpt.z != 0.0);\n\nfloat mod_angle(float a) {\n return mod(a, PI);\n}\n\nfloat positive_angle(float a) {\n return mod_angle((a < 0.0) ?\n a + TWO_PI :\n a\n );\n}\n\nfloat look_upwards(float a) {\n float b = positive_angle(a);\n return ((b > HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]) +var textFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]) +exports.text = function(gl) { + return createShader(gl, textVert, textFrag, null, [ + {name: 'position', type: 'vec3'} + ]) +} + +var bgVert = glslify(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]) +var bgFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]) +exports.bg = function(gl) { + return createShader(gl, bgVert, bgFrag, null, [ + {name: 'position', type: 'vec3'}, + {name: 'normal', type: 'vec3'} + ]) +} },{"gl-shader":288,"glslify":392}],227:[function(_dereq_,module,exports){ (function (process){ -"use strict" - -module.exports = createTextSprites - -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var vectorizeText = _dereq_('vectorize-text') -var createShader = _dereq_('./shaders').text - -var globals = window || process.global || {} -var __TEXT_CACHE = globals.__TEXT_CACHE || {} -globals.__TEXT_CACHE = {} - -//Vertex buffer format for text is: -// -/// [x,y,z] = Spatial coordinate -// - -var VERTEX_SIZE = 3 -var VERTEX_STRIDE = VERTEX_SIZE * 4 - -function TextSprites( - gl, - shader, - buffer, - vao) { - this.gl = gl - this.shader = shader - this.buffer = buffer - this.vao = vao - this.tickOffset = - this.tickCount = - this.labelOffset = - this.labelCount = null -} - -var proto = TextSprites.prototype - -//Bind textures for rendering -var SHAPE = [0,0] -proto.bind = function(model, view, projection, pixelScale) { - this.vao.bind() - this.shader.bind() - var uniforms = this.shader.uniforms - uniforms.model = model - uniforms.view = view - uniforms.projection = projection - uniforms.pixelScale = pixelScale - SHAPE[0] = this.gl.drawingBufferWidth - SHAPE[1] = this.gl.drawingBufferHeight - this.shader.uniforms.resolution = SHAPE -} - -proto.unbind = function() { - this.vao.unbind() -} - -proto.update = function(bounds, labels, labelFont, ticks, tickFont) { - var gl = this.gl - var data = [] - - function addItem(t, text, font, size) { - var fontcache = __TEXT_CACHE[font] - if(!fontcache) { - fontcache = __TEXT_CACHE[font] = {} - } - var mesh = fontcache[text] - if(!mesh) { - mesh = fontcache[text] = tryVectorizeText(text, { - triangles: true, - font: font, - textAlign: 'center', - textBaseline: 'middle' - }) - } - var scale = (size || 12) / 12 - var positions = mesh.positions - var cells = mesh.cells - var lo = [ Infinity, Infinity] - var hi = [-Infinity,-Infinity] - for(var i=0, nc=cells.length; i=0; --j) { - var p = positions[c[j]] - data.push(scale*p[0], -scale*p[1], t) - } - } - } - - //Generate sprites for all 3 axes, store data in texture atlases - var tickOffset = [0,0,0] - var tickCount = [0,0,0] - var labelOffset = [0,0,0] - var labelCount = [0,0,0] - for(var d=0; d<3; ++d) { - - //Generate label - labelOffset[d] = (data.length/VERTEX_SIZE)|0 - addItem(0.5*(bounds[0][d]+bounds[1][d]), labels[d], labelFont) - labelCount[d] = ((data.length/VERTEX_SIZE)|0) - labelOffset[d] - - //Generate sprites for tick marks - tickOffset[d] = (data.length/VERTEX_SIZE)|0 - for(var i=0; i=0; --j) { + var p = positions[c[j]] + data.push(scale*p[0], -scale*p[1], t) + } + } + } + + //Generate sprites for all 3 axes, store data in texture atlases + var tickOffset = [0,0,0] + var tickCount = [0,0,0] + var labelOffset = [0,0,0] + var labelCount = [0,0,0] + var lineSpacing = 1.25 + var styletags = { + breaklines:true, + bolds: true, + italics: true, + subscripts:true, + superscripts:true + } + for(var d=0; d<3; ++d) { + + //Generate label + labelOffset[d] = (data.length/VERTEX_SIZE)|0 + addItem( + 0.5*(bounds[0][d]+bounds[1][d]), + labels[d], + labelFont[d], + 12, // labelFontSize + lineSpacing, + styletags + ) + labelCount[d] = ((data.length/VERTEX_SIZE)|0) - labelOffset[d] + + //Generate sprites for tick marks + tickOffset[d] = (data.length/VERTEX_SIZE)|0 + for(var i=0; i= 0) { - sigFigs = stepStr.length - u - 1 - } - var shift = Math.pow(10, sigFigs) - var x = Math.round(spacing * i * shift) - var xstr = x + "" - if(xstr.indexOf("e") >= 0) { - return xstr - } - var xi = x / shift, xf = x % shift - if(x < 0) { - xi = -Math.ceil(xi)|0 - xf = (-xf)|0 - } else { - xi = Math.floor(xi)|0 - xf = xf|0 - } - var xis = "" + xi - if(x < 0) { - xis = "-" + xis - } - if(sigFigs) { - var xs = "" + xf - while(xs.length < sigFigs) { - xs = "0" + xs - } - return xis + "." + xs - } else { - return xis - } -} - -function defaultTicks(bounds, tickSpacing) { - var array = [] - for(var d=0; d<3; ++d) { - var ticks = [] - var m = 0.5*(bounds[0][d]+bounds[1][d]) - for(var t=0; t*tickSpacing[d]<=bounds[1][d]; ++t) { - ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) - } - for(var t=-1; t*tickSpacing[d]>=bounds[0][d]; --t) { - ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) - } - array.push(ticks) - } - return array -} - -function ticksEqual(ticksA, ticksB) { - for(var i=0; i<3; ++i) { - if(ticksA[i].length !== ticksB[i].length) { - return false - } - for(var j=0; j= 0) { + sigFigs = stepStr.length - u - 1 + } + var shift = Math.pow(10, sigFigs) + var x = Math.round(spacing * i * shift) + var xstr = x + "" + if(xstr.indexOf("e") >= 0) { + return xstr + } + var xi = x / shift, xf = x % shift + if(x < 0) { + xi = -Math.ceil(xi)|0 + xf = (-xf)|0 + } else { + xi = Math.floor(xi)|0 + xf = xf|0 + } + var xis = "" + xi + if(x < 0) { + xis = "-" + xis + } + if(sigFigs) { + var xs = "" + xf + while(xs.length < sigFigs) { + xs = "0" + xs + } + return xis + "." + xs + } else { + return xis + } +} + +function defaultTicks(bounds, tickSpacing) { + var array = [] + for(var d=0; d<3; ++d) { + var ticks = [] + var m = 0.5*(bounds[0][d]+bounds[1][d]) + for(var t=0; t*tickSpacing[d]<=bounds[1][d]; ++t) { + ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) + } + for(var t=-1; t*tickSpacing[d]>=bounds[0][d]; --t) { + ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) + } + array.push(ticks) + } + return array +} + +function ticksEqual(ticksA, ticksB) { + for(var i=0; i<3; ++i) { + if(ticksA[i].length !== ticksB[i].length) { + return false + } + for(var j=0; j= v) { - return i-1; - } - } - return i; -}; - -var tmp = V.create(); -var tmp2 = V.create(); - -var clamp = function(v, min, max) { - return v < min ? min : (v > max ? max : v); -}; - -var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { - var x = point[0]; - var y = point[1]; - var z = point[2]; - - var w = meshgrid[0].length; - var h = meshgrid[1].length; - var d = meshgrid[2].length; - - // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). - // The nearest smaller value index for x is the index x0 such that - // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. - var x0 = findLastSmallerIndex(meshgrid[0], x); - var y0 = findLastSmallerIndex(meshgrid[1], y); - var z0 = findLastSmallerIndex(meshgrid[2], z); - - // Get the nearest larger meshgrid value indices. - // From the above "nearest smaller value", we know that - // meshgrid[0][x0] < x - // meshgrid[0][x0+1] >= x - var x1 = x0 + 1; - var y1 = y0 + 1; - var z1 = z0 + 1; - - if (clampOverflow) { - x0 = clamp(x0, 0, w-1); - x1 = clamp(x1, 0, w-1); - y0 = clamp(y0, 0, h-1); - y1 = clamp(y1, 0, h-1); - z0 = clamp(z0, 0, d-1); - z1 = clamp(z1, 0, d-1); - } - - // Reject points outside the meshgrid, return a zero vector. - if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { - return V.create(); - } - - // Normalize point coordinates to 0..1 scaling factor between x0 and x1. - var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); - var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); - var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); - - if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; - if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; - if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; - - var z0off = z0*w*h; - var z1off = z1*w*h; - - var y0off = y0*w; - var y1off = y1*w; - - var x0off = x0; - var x1off = x1; - - // Sample data array around the (x,y,z) point. - // vZYX = array[zZoff + yYoff + xXoff] - var v000 = array[y0off + z0off + x0off]; - var v001 = array[y0off + z0off + x1off]; - var v010 = array[y1off + z0off + x0off]; - var v011 = array[y1off + z0off + x1off]; - var v100 = array[y0off + z1off + x0off]; - var v101 = array[y0off + z1off + x1off]; - var v110 = array[y1off + z1off + x0off]; - var v111 = array[y1off + z1off + x1off]; - - var result = V.create(); - - // Average samples according to distance to point. - V.lerp(result, v000, v001, xf); - V.lerp(tmp, v010, v011, xf); - V.lerp(result, result, tmp, yf); - V.lerp(tmp, v100, v101, xf); - V.lerp(tmp2, v110, v111, xf); - V.lerp(tmp, tmp, tmp2, yf); - V.lerp(result, result, tmp, zf); - - return result; -}; - -var getOrthogonalVector = function(dst, v) { - // Return up-vector for only-z vector. - if (v[0] === 0 && v[1] === 0) { - V.set(dst, 0, 1, 0); - } else { - // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0). - // From the above if-statement we have ||a|| > 0 U ||b|| > 0. - // Assign z = 0, x = -b, y = a: - // a*-b + b*a + c*0 = -ba + ba + 0 = 0 - V.set(dst, -v[1], v[0], 0); - } - return dst; -}; - -module.exports = function(vectorfield, bounds) { - var positions; - if (vectorfield.positions) { - positions = vectorfield.positions; - } else { - positions = createPositionsForMeshgrid(vectorfield.meshgrid); - } - var meshgrid = vectorfield.meshgrid; - var vectors = vectorfield.vectors; - var geo = { - positions: [], - vertexIntensity: [], - vertexIntensityBounds: vectorfield.vertexIntensityBounds, - vertexNormals: [], - vectors: [], - cells: [], - coneOffset: vectorfield.coneOffset, - colormap: vectorfield.colormap - }; - - if (vectorfield.positions.length === 0) { - if (bounds) { - bounds[0] = [0,0,0]; - bounds[1] = [0,0,0]; - } - return geo; - } - - // Compute bounding box for the dataset. - // Compute maximum velocity for the dataset to use for scaling the cones. - var maxNorm = 0; - var minX = 1/0, maxX = -1/0; - var minY = 1/0, maxY = -1/0; - var minZ = 1/0, maxZ = -1/0; - var p2 = null; - var u2 = null; - var positionVectors = []; - var vectorScale = 1/0; - for (var i = 0; i < positions.length; i++) { - var p = positions[i]; - minX = Math.min(p[0], minX); - maxX = Math.max(p[0], maxX); - minY = Math.min(p[1], minY); - maxY = Math.max(p[1], maxY); - minZ = Math.min(p[2], minZ); - maxZ = Math.max(p[2], maxZ); - var u; - if (meshgrid) { - u = sampleMeshgrid(p, vectors, meshgrid, true); - } else { - u = vectors[i]; - } - if (V.length(u) > maxNorm) { - maxNorm = V.length(u); - } - if (i) { - // Find vector scale [w/ units of time] using "successive" positions - // (not "adjacent" with would be O(n^2)), - // - // The vector scale corresponds to the minimum "time" to travel across two - // two adjacent positions at the average velocity of those two adjacent positions - vectorScale = Math.min(vectorScale, - 2 * V.distance(p2, p) / (V.length(u2) + V.length(u)) - ); - } - p2 = p; - u2 = u; - positionVectors.push(u); - } - var minV = [minX, minY, minZ]; - var maxV = [maxX, maxY, maxZ]; - if (bounds) { - bounds[0] = minV; - bounds[1] = maxV; - } - if (maxNorm === 0) { - maxNorm = 1; - } - - // Inverted max norm would map vector with norm maxNorm to 1 coord space units in length - var invertedMaxNorm = 1 / maxNorm; - - if (!isFinite(vectorScale) || isNaN(vectorScale)) { - vectorScale = 1.0; - } - geo.vectorScale = vectorScale; - - var nml = vec3(0,1,0); - - var coneScale = vectorfield.coneSize || 0.5; - - if (vectorfield.absoluteConeSize) { - coneScale = vectorfield.absoluteConeSize * invertedMaxNorm; - } - - geo.coneScale = coneScale; - - // Build the cone model. - for (var i = 0, j = 0; i < positions.length; i++) { - var p = positions[i]; - var x = p[0], y = p[1], z = p[2]; - var d = positionVectors[i]; - var intensity = V.length(d) * invertedMaxNorm; - for (var k = 0, l = 8; k < l; k++) { - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - geo.positions.push([x, y, z, j++]); - - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - geo.vectors.push(d); - - geo.vertexIntensity.push(intensity, intensity, intensity); - geo.vertexIntensity.push(intensity, intensity, intensity); - - geo.vertexNormals.push(nml, nml, nml); - geo.vertexNormals.push(nml, nml, nml); - - var m = geo.positions.length; - geo.cells.push([m-6, m-5, m-4], [m-3, m-2, m-1]); - } - } - - return geo; -}; - -module.exports.createConeMesh = _dereq_('./lib/conemesh'); +},{"ndarray":433,"ndarray-ops":427,"typedarray-pool":521}],231:[function(_dereq_,module,exports){ +"use strict"; + +var V = _dereq_('gl-vec3'); +var V4 = _dereq_('gl-vec4'); + +var vec3 = function(x, y, z) { + var v = V.create(); + if (x !== undefined) { + V.set(v, x, y, z); + } + return v; +} + +var createPositionsForMeshgrid = function(meshgrid) { + var xs = meshgrid[0], ys = meshgrid[1], zs = meshgrid[2]; + var positions = []; + for (var z=0; z= v) { + return i-1; + } + } + return i; +}; + +var tmp = V.create(); +var tmp2 = V.create(); + +var clamp = function(v, min, max) { + return v < min ? min : (v > max ? max : v); +}; + +var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { + var x = point[0]; + var y = point[1]; + var z = point[2]; + + var w = meshgrid[0].length; + var h = meshgrid[1].length; + var d = meshgrid[2].length; + + // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). + // The nearest smaller value index for x is the index x0 such that + // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. + var x0 = findLastSmallerIndex(meshgrid[0], x); + var y0 = findLastSmallerIndex(meshgrid[1], y); + var z0 = findLastSmallerIndex(meshgrid[2], z); + + // Get the nearest larger meshgrid value indices. + // From the above "nearest smaller value", we know that + // meshgrid[0][x0] < x + // meshgrid[0][x0+1] >= x + var x1 = x0 + 1; + var y1 = y0 + 1; + var z1 = z0 + 1; + + if (clampOverflow) { + x0 = clamp(x0, 0, w-1); + x1 = clamp(x1, 0, w-1); + y0 = clamp(y0, 0, h-1); + y1 = clamp(y1, 0, h-1); + z0 = clamp(z0, 0, d-1); + z1 = clamp(z1, 0, d-1); + } + + // Reject points outside the meshgrid, return a zero vector. + if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { + return V.create(); + } + + // Normalize point coordinates to 0..1 scaling factor between x0 and x1. + var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); + var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); + var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); + + if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; + if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; + if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; + + var z0off = z0*w*h; + var z1off = z1*w*h; + + var y0off = y0*w; + var y1off = y1*w; + + var x0off = x0; + var x1off = x1; + + // Sample data array around the (x,y,z) point. + // vZYX = array[zZoff + yYoff + xXoff] + var v000 = array[y0off + z0off + x0off]; + var v001 = array[y0off + z0off + x1off]; + var v010 = array[y1off + z0off + x0off]; + var v011 = array[y1off + z0off + x1off]; + var v100 = array[y0off + z1off + x0off]; + var v101 = array[y0off + z1off + x1off]; + var v110 = array[y1off + z1off + x0off]; + var v111 = array[y1off + z1off + x1off]; + + var result = V.create(); + + // Average samples according to distance to point. + V.lerp(result, v000, v001, xf); + V.lerp(tmp, v010, v011, xf); + V.lerp(result, result, tmp, yf); + V.lerp(tmp, v100, v101, xf); + V.lerp(tmp2, v110, v111, xf); + V.lerp(tmp, tmp, tmp2, yf); + V.lerp(result, result, tmp, zf); + + return result; +}; + +var getOrthogonalVector = function(dst, v) { + // Return up-vector for only-z vector. + if (v[0] === 0 && v[1] === 0) { + V.set(dst, 0, 1, 0); + } else { + // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0). + // From the above if-statement we have ||a|| > 0 U ||b|| > 0. + // Assign z = 0, x = -b, y = a: + // a*-b + b*a + c*0 = -ba + ba + 0 = 0 + V.set(dst, -v[1], v[0], 0); + } + return dst; +}; + +module.exports = function(vectorfield, bounds) { + var positions; + if (vectorfield.positions) { + positions = vectorfield.positions; + } else { + positions = createPositionsForMeshgrid(vectorfield.meshgrid); + } + var meshgrid = vectorfield.meshgrid; + var vectors = vectorfield.vectors; + var geo = { + positions: [], + vertexIntensity: [], + vertexIntensityBounds: vectorfield.vertexIntensityBounds, + vertexNormals: [], + vectors: [], + cells: [], + coneOffset: vectorfield.coneOffset, + colormap: vectorfield.colormap + }; + + if (vectorfield.positions.length === 0) { + if (bounds) { + bounds[0] = [0,0,0]; + bounds[1] = [0,0,0]; + } + return geo; + } + + // Compute bounding box for the dataset. + // Compute maximum velocity for the dataset to use for scaling the cones. + var maxNorm = 0; + var minX = 1/0, maxX = -1/0; + var minY = 1/0, maxY = -1/0; + var minZ = 1/0, maxZ = -1/0; + var p2 = null; + var u2 = null; + var positionVectors = []; + var vectorScale = 1/0; + for (var i = 0; i < positions.length; i++) { + var p = positions[i]; + minX = Math.min(p[0], minX); + maxX = Math.max(p[0], maxX); + minY = Math.min(p[1], minY); + maxY = Math.max(p[1], maxY); + minZ = Math.min(p[2], minZ); + maxZ = Math.max(p[2], maxZ); + var u; + if (meshgrid) { + u = sampleMeshgrid(p, vectors, meshgrid, true); + } else { + u = vectors[i]; + } + if (V.length(u) > maxNorm) { + maxNorm = V.length(u); + } + if (i) { + // Find vector scale [w/ units of time] using "successive" positions + // (not "adjacent" with would be O(n^2)), + // + // The vector scale corresponds to the minimum "time" to travel across two + // two adjacent positions at the average velocity of those two adjacent positions + vectorScale = Math.min(vectorScale, + 2 * V.distance(p2, p) / (V.length(u2) + V.length(u)) + ); + } + p2 = p; + u2 = u; + positionVectors.push(u); + } + var minV = [minX, minY, minZ]; + var maxV = [maxX, maxY, maxZ]; + if (bounds) { + bounds[0] = minV; + bounds[1] = maxV; + } + if (maxNorm === 0) { + maxNorm = 1; + } + + // Inverted max norm would map vector with norm maxNorm to 1 coord space units in length + var invertedMaxNorm = 1 / maxNorm; + + if (!isFinite(vectorScale) || isNaN(vectorScale)) { + vectorScale = 1.0; + } + geo.vectorScale = vectorScale; + + var nml = vec3(0,1,0); + + var coneScale = vectorfield.coneSize || 0.5; + + if (vectorfield.absoluteConeSize) { + coneScale = vectorfield.absoluteConeSize * invertedMaxNorm; + } + + geo.coneScale = coneScale; + + // Build the cone model. + for (var i = 0, j = 0; i < positions.length; i++) { + var p = positions[i]; + var x = p[0], y = p[1], z = p[2]; + var d = positionVectors[i]; + var intensity = V.length(d) * invertedMaxNorm; + for (var k = 0, l = 8; k < l; k++) { + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + geo.positions.push([x, y, z, j++]); + + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + geo.vectors.push(d); + + geo.vertexIntensity.push(intensity, intensity, intensity); + geo.vertexIntensity.push(intensity, intensity, intensity); + + geo.vertexNormals.push(nml, nml, nml); + geo.vertexNormals.push(nml, nml, nml); + + var m = geo.positions.length; + geo.cells.push([m-6, m-5, m-4], [m-3, m-2, m-1]); + } + } + + return geo; +}; + +module.exports.createConeMesh = _dereq_('./lib/conemesh'); },{"./lib/conemesh":233,"gl-vec3":329,"gl-vec4":365}],232:[function(_dereq_,module,exports){ -'use strict' - -var barycentric = _dereq_('barycentric') -var closestPointToTriangle = _dereq_('polytope-closest-point/lib/closest_point_2d.js') - -module.exports = closestPointToPickLocation - -function xformMatrix(m, v) { - var out = [0,0,0,0] - for(var i=0; i<4; ++i) { - for(var j=0; j<4; ++j) { - out[j] += m[4*i + j] * v[i] - } - } - return out -} - -function projectVertex(v, model, view, projection, resolution) { - var p = xformMatrix(projection, - xformMatrix(view, - xformMatrix(model, [v[0], v[1], v[2], 1]))) - for(var i=0; i<3; ++i) { - p[i] /= p[3] - } - return [ 0.5 * resolution[0] * (1.0+p[0]), 0.5 * resolution[1] * (1.0-p[1]) ] -} - -function barycentricCoord(simplex, point) { - if(simplex.length === 2) { - var d0 = 0.0 - var d1 = 0.0 - for(var i=0; i<2; ++i) { - d0 += Math.pow(point[i] - simplex[0][i], 2) - d1 += Math.pow(point[i] - simplex[1][i], 2) - } - d0 = Math.sqrt(d0) - d1 = Math.sqrt(d1) - if(d0+d1 < 1e-6) { - return [1,0] - } - return [d1/(d0+d1),d0/(d1+d0)] - } else if(simplex.length === 3) { - var closestPoint = [0,0] - closestPointToTriangle(simplex[0], simplex[1], simplex[2], point, closestPoint) - return barycentric(simplex, closestPoint) - } - return [] -} - -function interpolate(simplex, weights) { - var result = [0,0,0] - for(var i=0; i 1.0001) { - return null - } - s += weights[i] - } - if(Math.abs(s - 1.0) > 0.001) { - return null - } - return [closestIndex, interpolate(simplex, weights), weights] +'use strict' + +var barycentric = _dereq_('barycentric') +var closestPointToTriangle = _dereq_('polytope-closest-point/lib/closest_point_2d.js') + +module.exports = closestPointToPickLocation + +function xformMatrix(m, v) { + var out = [0,0,0,0] + for(var i=0; i<4; ++i) { + for(var j=0; j<4; ++j) { + out[j] += m[4*i + j] * v[i] + } + } + return out +} + +function projectVertex(v, model, view, projection, resolution) { + var p = xformMatrix(projection, + xformMatrix(view, + xformMatrix(model, [v[0], v[1], v[2], 1]))) + for(var i=0; i<3; ++i) { + p[i] /= p[3] + } + return [ 0.5 * resolution[0] * (1.0+p[0]), 0.5 * resolution[1] * (1.0-p[1]) ] +} + +function barycentricCoord(simplex, point) { + if(simplex.length === 2) { + var d0 = 0.0 + var d1 = 0.0 + for(var i=0; i<2; ++i) { + d0 += Math.pow(point[i] - simplex[0][i], 2) + d1 += Math.pow(point[i] - simplex[1][i], 2) + } + d0 = Math.sqrt(d0) + d1 = Math.sqrt(d1) + if(d0+d1 < 1e-6) { + return [1,0] + } + return [d1/(d0+d1),d0/(d1+d0)] + } else if(simplex.length === 3) { + var closestPoint = [0,0] + closestPointToTriangle(simplex[0], simplex[1], simplex[2], point, closestPoint) + return barycentric(simplex, closestPoint) + } + return [] +} + +function interpolate(simplex, weights) { + var result = [0,0,0] + for(var i=0; i 1.0001) { + return null + } + s += weights[i] + } + if(Math.abs(s - 1.0) > 0.001) { + return null + } + return [closestIndex, interpolate(simplex, weights), weights] } },{"barycentric":61,"polytope-closest-point/lib/closest_point_2d.js":464}],233:[function(_dereq_,module,exports){ -'use strict' - -var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small -var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var normals = _dereq_('normals') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var ndarray = _dereq_('ndarray') -var colormap = _dereq_('colormap') -var getContour = _dereq_('simplicial-complex-contour') -var pool = _dereq_('typedarray-pool') -var shaders = _dereq_('./shaders') -var closestPoint = _dereq_('./closest-point') - -var meshShader = shaders.meshShader -var pickShader = shaders.pickShader - -var identityMatrix = [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - -function SimplicialMesh(gl - , texture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) { - - this.gl = gl - this.cells = [] - this.positions = [] - this.intensity = [] - this.texture = texture - this.dirty = true - - this.triShader = triShader - this.lineShader = lineShader - this.pointShader = pointShader - this.pickShader = pickShader - this.pointPickShader = pointPickShader - this.contourShader = contourShader - - this.trianglePositions = trianglePositions - this.triangleVectors = triangleVectors - this.triangleColors = triangleColors - this.triangleNormals = triangleNormals - this.triangleUVs = triangleUVs - this.triangleIds = triangleIds - this.triangleVAO = triangleVAO - this.triangleCount = 0 - - this.lineWidth = 1 - this.edgePositions = edgePositions - this.edgeColors = edgeColors - this.edgeUVs = edgeUVs - this.edgeIds = edgeIds - this.edgeVAO = edgeVAO - this.edgeCount = 0 - - this.pointPositions = pointPositions - this.pointColors = pointColors - this.pointUVs = pointUVs - this.pointSizes = pointSizes - this.pointIds = pointIds - this.pointVAO = pointVAO - this.pointCount = 0 - - this.contourLineWidth = 1 - this.contourPositions = contourPositions - this.contourVAO = contourVAO - this.contourCount = 0 - this.contourColor = [0,0,0] - this.contourEnable = true - - this.pickId = 1 - this.bounds = [ - [ Infinity, Infinity, Infinity], - [-Infinity,-Infinity,-Infinity] ] - this.clipBounds = [ - [-Infinity,-Infinity,-Infinity], - [ Infinity, Infinity, Infinity] ] - - this.lightPosition = [1e5, 1e5, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - - this.opacity = 1.0 - - this.coneScale = 2.0 - this.vectorScale = 1.0 - this.coneOffset = 1.0 / 4.0; - - this._model = identityMatrix - this._view = identityMatrix - this._projection = identityMatrix - this._resolution = [1,1] -} - -var proto = SimplicialMesh.prototype - -proto.isOpaque = function() { - return this.opacity >= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.pickSlots = 1 - -proto.setPickBase = function(id) { - this.pickId = id -} - -function genColormap(param) { - var colors = colormap({ - colormap: param - , nshades: 256 - , format: 'rgba' - }) - - var result = new Uint8Array(256*4) - for(var i=0; i<256; ++i) { - var c = colors[i] - for(var j=0; j<3; ++j) { - result[4*i+j] = c[j] - } - result[4*i+3] = c[3]*255 - } - - return ndarray(result, [256,256,4], [4,0,1]) -} - -function unpackIntensity(cells, numVerts, cellIntensity) { - var result = new Array(numVerts) - for(var i=0; i 0) { - var shader = this.triShader - shader.bind() - shader.uniforms = uniforms - - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0 && this.lineWidth > 0) { - var shader = this.lineShader - shader.bind() - shader.uniforms = uniforms - - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } - - if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { - var shader = this.contourShader - shader.bind() - shader.uniforms = uniforms - - this.contourVAO.bind() - gl.drawArrays(gl.LINES, 0, this.contourCount) - this.contourVAO.unbind() - } -} - -proto.drawPick = function(params) { - params = params || {} - - var gl = this.gl - - var model = params.model || identityMatrix - var view = params.view || identityMatrix - var projection = params.projection || identityMatrix - - var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] - for(var i=0; i<3; ++i) { - clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) - clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) - } - - //Save camera parameters - this._model = [].slice.call(model) - this._view = [].slice.call(view) - this._projection = [].slice.call(projection) - this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - - var uniforms = { - model: model, - view: view, - projection: projection, - clipBounds: clipBounds, - - vectorScale: this.vectorScale, - coneScale: this.coneScale, - coneOffset: this.coneOffset, - - pickId: this.pickId / 255.0, - } - - var shader = this.pickShader - shader.bind() - shader.uniforms = uniforms - - if(this.triangleCount > 0) { - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0) { - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointPickShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } -} - - -proto.pick = function(pickData) { - if(!pickData) { - return null - } - if(pickData.id !== this.pickId) { - return null - } - - var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] - var cell = this.cells[cellId] - var pos = this.positions[cell[1]].slice(0, 3) - - return { - // corresponding to input indices - index: Math.floor(cell[1] / 48), - position: pos, - dataCoordinate: pos - } -} - - -proto.dispose = function() { - this.texture.dispose() - - this.triShader.dispose() - // this.lineShader.dispose() - // this.pointShader.dispose() - this.pickShader.dispose() - // this.pointPickShader.dispose() - - this.triangleVAO.dispose() - this.trianglePositions.dispose() - this.triangleVectors.dispose() - this.triangleColors.dispose() - this.triangleUVs.dispose() - this.triangleNormals.dispose() - this.triangleIds.dispose() - - this.edgeVAO.dispose() - this.edgePositions.dispose() - this.edgeColors.dispose() - this.edgeUVs.dispose() - this.edgeIds.dispose() - - this.pointVAO.dispose() - this.pointPositions.dispose() - this.pointColors.dispose() - this.pointUVs.dispose() - this.pointSizes.dispose() - this.pointIds.dispose() - - this.contourVAO.dispose() - this.contourPositions.dispose() - // this.contourShader.dispose() -} - -function createMeshShader(gl) { - // need to pass meshShader attributes manually, - // to make this work on etpinard's Ubuntu Thinkpad - var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.vector.location = 5 - return shader -} - -function createWireShader(gl) { - var shader = createShader(gl, wireShader.vertex, wireShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - return shader -} - -function createPointShader(gl) { - var shader = createShader(gl, pointShader.vertex, pointShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.pointSize.location = 4 - return shader -} - -function createPickShader(gl) { - var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.vector.location = 5 - return shader -} - -function createPointPickShader(gl) { - var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.pointSize.location = 4 - return shader -} - -function createContourShader(gl) { - var shader = createShader(gl, contourShader.vertex, contourShader.fragment) - shader.attributes.position.location = 0 - return shader -} - -function createSimplicialMesh(gl, params) { - if (arguments.length === 1) { - params = gl; - gl = params.gl; - } - - var triShader = params.triShader || createMeshShader(gl) - var lineShader = null; //createWireShader(gl) - var pointShader = null; //createPointShader(gl) - var pickShader = createPickShader(gl) - var pointPickShader = null; //createPointPickShader(gl) - var contourShader = null; //createContourShader(gl) - - var meshTexture = createTexture(gl, - ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) - meshTexture.generateMipmap() - meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR - meshTexture.magFilter = gl.LINEAR - - var trianglePositions = createBuffer(gl) - var triangleVectors = createBuffer(gl) - var triangleColors = createBuffer(gl) - var triangleUVs = createBuffer(gl) - var triangleNormals = createBuffer(gl) - var triangleIds = createBuffer(gl) - var triangleVAO = createVAO(gl, [ - { buffer: trianglePositions, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: triangleColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: triangleNormals, - type: gl.FLOAT, - size: 3 - }, - { buffer: triangleVectors, - type: gl.FLOAT, - size: 3 - } - ]) - - var edgePositions = createBuffer(gl) - var edgeColors = createBuffer(gl) - var edgeUVs = createBuffer(gl) - var edgeIds = createBuffer(gl) - var edgeVAO = createVAO(gl, [ - { buffer: edgePositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: edgeIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: edgeColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: edgeUVs, - type: gl.FLOAT, - size: 2 - } - ]) - - var pointPositions = createBuffer(gl) - var pointColors = createBuffer(gl) - var pointUVs = createBuffer(gl) - var pointSizes = createBuffer(gl) - var pointIds = createBuffer(gl) - var pointVAO = createVAO(gl, [ - { buffer: pointPositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: pointIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: pointColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: pointUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: pointSizes, - type: gl.FLOAT, - size: 1 - } - ]) - - var contourPositions = createBuffer(gl) - var contourVAO = createVAO(gl, [ - { buffer: contourPositions, - type: gl.FLOAT, - size: 3 - }]) - - var mesh = new SimplicialMesh(gl - , meshTexture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) - - mesh.update(params) - - return mesh -} - -module.exports = createSimplicialMesh - -},{"./closest-point":232,"./shaders":234,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"normals":436,"simplicial-complex-contour":494,"typedarray-pool":522}],234:[function(_dereq_,module,exports){ -var glslify = _dereq_('glslify') - -var triVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]) -var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) -var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) - -exports.meshShader = { - vertex: triVertSrc, - fragment: triFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'normal', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'}, - {name: 'vector', type: 'vec3'} - ] -} -exports.pickShader = { - vertex: pickVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'id', type: 'vec4'}, - {name: 'vector', type: 'vec3'} - ] -} +'use strict' + +var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small +var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; + +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var normals = _dereq_('normals') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var ndarray = _dereq_('ndarray') +var colormap = _dereq_('colormap') +var getContour = _dereq_('simplicial-complex-contour') +var pool = _dereq_('typedarray-pool') +var shaders = _dereq_('./shaders') +var closestPoint = _dereq_('./closest-point') + +var meshShader = shaders.meshShader +var pickShader = shaders.pickShader + +var identityMatrix = [ + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +function SimplicialMesh(gl + , texture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) { + + this.gl = gl + this.cells = [] + this.positions = [] + this.intensity = [] + this.texture = texture + this.dirty = true + + this.triShader = triShader + this.lineShader = lineShader + this.pointShader = pointShader + this.pickShader = pickShader + this.pointPickShader = pointPickShader + this.contourShader = contourShader + + this.trianglePositions = trianglePositions + this.triangleVectors = triangleVectors + this.triangleColors = triangleColors + this.triangleNormals = triangleNormals + this.triangleUVs = triangleUVs + this.triangleIds = triangleIds + this.triangleVAO = triangleVAO + this.triangleCount = 0 + + this.lineWidth = 1 + this.edgePositions = edgePositions + this.edgeColors = edgeColors + this.edgeUVs = edgeUVs + this.edgeIds = edgeIds + this.edgeVAO = edgeVAO + this.edgeCount = 0 + + this.pointPositions = pointPositions + this.pointColors = pointColors + this.pointUVs = pointUVs + this.pointSizes = pointSizes + this.pointIds = pointIds + this.pointVAO = pointVAO + this.pointCount = 0 + + this.contourLineWidth = 1 + this.contourPositions = contourPositions + this.contourVAO = contourVAO + this.contourCount = 0 + this.contourColor = [0,0,0] + this.contourEnable = true + + this.pickId = 1 + this.bounds = [ + [ Infinity, Infinity, Infinity], + [-Infinity,-Infinity,-Infinity] ] + this.clipBounds = [ + [-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity] ] + + this.lightPosition = [1e5, 1e5, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + + this.opacity = 1.0 + + this.coneScale = 2.0 + this.vectorScale = 1.0 + this.coneOffset = 1.0 / 4.0; + + this._model = identityMatrix + this._view = identityMatrix + this._projection = identityMatrix + this._resolution = [1,1] +} + +var proto = SimplicialMesh.prototype + +proto.isOpaque = function() { + return this.opacity >= 1 +} + +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.pickSlots = 1 + +proto.setPickBase = function(id) { + this.pickId = id +} + +function genColormap(param) { + var colors = colormap({ + colormap: param + , nshades: 256 + , format: 'rgba' + }) + + var result = new Uint8Array(256*4) + for(var i=0; i<256; ++i) { + var c = colors[i] + for(var j=0; j<3; ++j) { + result[4*i+j] = c[j] + } + result[4*i+3] = c[3]*255 + } + + return ndarray(result, [256,256,4], [4,0,1]) +} + +function unpackIntensity(cells, numVerts, cellIntensity) { + var result = new Array(numVerts) + for(var i=0; i 0) { + var shader = this.triShader + shader.bind() + shader.uniforms = uniforms + + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0 && this.lineWidth > 0) { + var shader = this.lineShader + shader.bind() + shader.uniforms = uniforms + + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } + + if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { + var shader = this.contourShader + shader.bind() + shader.uniforms = uniforms + + this.contourVAO.bind() + gl.drawArrays(gl.LINES, 0, this.contourCount) + this.contourVAO.unbind() + } +} + +proto.drawPick = function(params) { + params = params || {} + + var gl = this.gl + + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix + + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } + + //Save camera parameters + this._model = [].slice.call(model) + this._view = [].slice.call(view) + this._projection = [].slice.call(projection) + this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] + + var uniforms = { + model: model, + view: view, + projection: projection, + clipBounds: clipBounds, + + vectorScale: this.vectorScale, + coneScale: this.coneScale, + coneOffset: this.coneOffset, + + pickId: this.pickId / 255.0, + } + + var shader = this.pickShader + shader.bind() + shader.uniforms = uniforms + + if(this.triangleCount > 0) { + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0) { + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointPickShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } +} + + +proto.pick = function(pickData) { + if(!pickData) { + return null + } + if(pickData.id !== this.pickId) { + return null + } + + var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] + var cell = this.cells[cellId] + var pos = this.positions[cell[1]].slice(0, 3) + + return { + // corresponding to input indices + index: Math.floor(cell[1] / 48), + position: pos, + dataCoordinate: pos + } +} + + +proto.dispose = function() { + this.texture.dispose() + + this.triShader.dispose() + // this.lineShader.dispose() + // this.pointShader.dispose() + this.pickShader.dispose() + // this.pointPickShader.dispose() + + this.triangleVAO.dispose() + this.trianglePositions.dispose() + this.triangleVectors.dispose() + this.triangleColors.dispose() + this.triangleUVs.dispose() + this.triangleNormals.dispose() + this.triangleIds.dispose() + + this.edgeVAO.dispose() + this.edgePositions.dispose() + this.edgeColors.dispose() + this.edgeUVs.dispose() + this.edgeIds.dispose() + + this.pointVAO.dispose() + this.pointPositions.dispose() + this.pointColors.dispose() + this.pointUVs.dispose() + this.pointSizes.dispose() + this.pointIds.dispose() + + this.contourVAO.dispose() + this.contourPositions.dispose() + // this.contourShader.dispose() +} + +function createMeshShader(gl) { + // need to pass meshShader attributes manually, + // to make this work on etpinard's Ubuntu Thinkpad + var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.vector.location = 5 + return shader +} + +function createWireShader(gl) { + var shader = createShader(gl, wireShader.vertex, wireShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + return shader +} + +function createPointShader(gl) { + var shader = createShader(gl, pointShader.vertex, pointShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.pointSize.location = 4 + return shader +} + +function createPickShader(gl) { + var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.vector.location = 5 + return shader +} + +function createPointPickShader(gl) { + var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.pointSize.location = 4 + return shader +} + +function createContourShader(gl) { + var shader = createShader(gl, contourShader.vertex, contourShader.fragment) + shader.attributes.position.location = 0 + return shader +} + +function createSimplicialMesh(gl, params) { + if (arguments.length === 1) { + params = gl; + gl = params.gl; + } + + var triShader = params.triShader || createMeshShader(gl) + var lineShader = null; //createWireShader(gl) + var pointShader = null; //createPointShader(gl) + var pickShader = createPickShader(gl) + var pointPickShader = null; //createPointPickShader(gl) + var contourShader = null; //createContourShader(gl) + + var meshTexture = createTexture(gl, + ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) + meshTexture.generateMipmap() + meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR + meshTexture.magFilter = gl.LINEAR + + var trianglePositions = createBuffer(gl) + var triangleVectors = createBuffer(gl) + var triangleColors = createBuffer(gl) + var triangleUVs = createBuffer(gl) + var triangleNormals = createBuffer(gl) + var triangleIds = createBuffer(gl) + var triangleVAO = createVAO(gl, [ + { buffer: trianglePositions, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: triangleColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: triangleNormals, + type: gl.FLOAT, + size: 3 + }, + { buffer: triangleVectors, + type: gl.FLOAT, + size: 3 + } + ]) + + var edgePositions = createBuffer(gl) + var edgeColors = createBuffer(gl) + var edgeUVs = createBuffer(gl) + var edgeIds = createBuffer(gl) + var edgeVAO = createVAO(gl, [ + { buffer: edgePositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: edgeIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: edgeColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: edgeUVs, + type: gl.FLOAT, + size: 2 + } + ]) + + var pointPositions = createBuffer(gl) + var pointColors = createBuffer(gl) + var pointUVs = createBuffer(gl) + var pointSizes = createBuffer(gl) + var pointIds = createBuffer(gl) + var pointVAO = createVAO(gl, [ + { buffer: pointPositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: pointIds, + type: gl.UNSIGNED_BYTE, + size: 4, + normalized: true + }, + { buffer: pointColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: pointUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: pointSizes, + type: gl.FLOAT, + size: 1 + } + ]) + + var contourPositions = createBuffer(gl) + var contourVAO = createVAO(gl, [ + { buffer: contourPositions, + type: gl.FLOAT, + size: 3 + }]) + + var mesh = new SimplicialMesh(gl + , meshTexture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) + + mesh.update(params) + + return mesh +} + +module.exports = createSimplicialMesh + +},{"./closest-point":232,"./shaders":234,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"normals":436,"simplicial-complex-contour":494,"typedarray-pool":521}],234:[function(_dereq_,module,exports){ +var glslify = _dereq_('glslify') + +var triVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]) +var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) +var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) + +exports.meshShader = { + vertex: triVertSrc, + fragment: triFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'normal', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'}, + {name: 'vector', type: 'vec3'} + ] +} +exports.pickShader = { + vertex: pickVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'id', type: 'vec4'}, + {name: 'vector', type: 'vec3'} + ] +} },{"glslify":392}],235:[function(_dereq_,module,exports){ module.exports = { @@ -36477,259 +36491,259 @@ module.exports = function lookupConstant (number) { } },{"./1.0/numbers":235}],237:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createErrorBars - -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createShader = _dereq_('./shaders/index') - -var IDENTITY = [1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - -function ErrorBars(gl, buffer, vao, shader) { - this.gl = gl - this.shader = shader - this.buffer = buffer - this.vao = vao - this.pixelRatio = 1 - this.bounds = [[ Infinity, Infinity, Infinity], [-Infinity,-Infinity,-Infinity]] - this.clipBounds = [[-Infinity,-Infinity,-Infinity], [ Infinity, Infinity, Infinity]] - this.lineWidth = [1,1,1] - this.capSize = [10,10,10] - this.lineCount = [0,0,0] - this.lineOffset = [0,0,0] - this.opacity = 1 -} - -var proto = ErrorBars.prototype - -proto.isOpaque = function() { - return this.opacity >= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.drawTransparent = proto.draw = function(cameraParams) { - var gl = this.gl - var uniforms = this.shader.uniforms - - this.shader.bind() - var view = uniforms.view = cameraParams.view || IDENTITY - var projection = uniforms.projection = cameraParams.projection || IDENTITY - uniforms.model = cameraParams.model || IDENTITY - uniforms.clipBounds = this.clipBounds - uniforms.opacity = this.opacity - - - var cx = view[12] - var cy = view[13] - var cz = view[14] - var cw = view[15] - var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight - - this.vao.bind() - for(var i=0; i<3; ++i) { - gl.lineWidth(this.lineWidth[i]) - uniforms.capSize = this.capSize[i] * pixelScaleF - if (this.lineCount[i]) { - gl.drawArrays(gl.LINES, this.lineOffset[i], this.lineCount[i]) - } - } - this.vao.unbind() -} - -function updateBounds(bounds, point) { - for(var i=0; i<3; ++i) { - bounds[0][i] = Math.min(bounds[0][i], point[i]) - bounds[1][i] = Math.max(bounds[1][i], point[i]) - } -} - -var FACE_TABLE = (function(){ - var table = new Array(3) - for(var d=0; d<3; ++d) { - var row = [] - for(var j=1; j<=2; ++j) { - for(var s=-1; s<=1; s+=2) { - var u = (j+d) % 3 - var y = [0,0,0] - y[u] = s - row.push(y) - } - } - table[d] = row - } - return table -})() - - -function emitFace(verts, x, c, d) { - var offsets = FACE_TABLE[d] - for(var i=0; i 0) { - var x = p.slice() - x[j] += e[1][j] - verts.push(p[0], p[1], p[2], - c[0], c[1], c[2], c[3], - 0, 0, 0, - x[0], x[1], x[2], - c[0], c[1], c[2], c[3], - 0, 0, 0) - updateBounds(this.bounds, x) - vertexCount += 2 + emitFace(verts, x, c, j) - } - } - this.lineCount[j] = vertexCount - this.lineOffset[j] - } - this.buffer.update(verts) - } -} - -proto.dispose = function() { - this.shader.dispose() - this.buffer.dispose() - this.vao.dispose() -} - -function createErrorBars(options) { - var gl = options.gl - var buffer = createBuffer(gl) - var vao = createVAO(gl, [ - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 0, - stride: 40 - }, - { - buffer: buffer, - type: gl.FLOAT, - size: 4, - offset: 12, - stride: 40 - }, - { - buffer: buffer, - type: gl.FLOAT, - size: 3, - offset: 28, - stride: 40 - } - ]) - - var shader = createShader(gl) - shader.attributes.position.location = 0 - shader.attributes.color.location = 1 - shader.attributes.offset.location = 2 - - var result = new ErrorBars(gl, buffer, vao, shader) - result.update(options) - return result -} +'use strict' + +module.exports = createErrorBars + +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createShader = _dereq_('./shaders/index') + +var IDENTITY = [1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +function ErrorBars(gl, buffer, vao, shader) { + this.gl = gl + this.shader = shader + this.buffer = buffer + this.vao = vao + this.pixelRatio = 1 + this.bounds = [[ Infinity, Infinity, Infinity], [-Infinity,-Infinity,-Infinity]] + this.clipBounds = [[-Infinity,-Infinity,-Infinity], [ Infinity, Infinity, Infinity]] + this.lineWidth = [1,1,1] + this.capSize = [10,10,10] + this.lineCount = [0,0,0] + this.lineOffset = [0,0,0] + this.opacity = 1 +} + +var proto = ErrorBars.prototype + +proto.isOpaque = function() { + return this.opacity >= 1 +} + +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.drawTransparent = proto.draw = function(cameraParams) { + var gl = this.gl + var uniforms = this.shader.uniforms + + this.shader.bind() + var view = uniforms.view = cameraParams.view || IDENTITY + var projection = uniforms.projection = cameraParams.projection || IDENTITY + uniforms.model = cameraParams.model || IDENTITY + uniforms.clipBounds = this.clipBounds + uniforms.opacity = this.opacity + + + var cx = view[12] + var cy = view[13] + var cz = view[14] + var cw = view[15] + var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight + + this.vao.bind() + for(var i=0; i<3; ++i) { + gl.lineWidth(this.lineWidth[i]) + uniforms.capSize = this.capSize[i] * pixelScaleF + if (this.lineCount[i]) { + gl.drawArrays(gl.LINES, this.lineOffset[i], this.lineCount[i]) + } + } + this.vao.unbind() +} + +function updateBounds(bounds, point) { + for(var i=0; i<3; ++i) { + bounds[0][i] = Math.min(bounds[0][i], point[i]) + bounds[1][i] = Math.max(bounds[1][i], point[i]) + } +} + +var FACE_TABLE = (function(){ + var table = new Array(3) + for(var d=0; d<3; ++d) { + var row = [] + for(var j=1; j<=2; ++j) { + for(var s=-1; s<=1; s+=2) { + var u = (j+d) % 3 + var y = [0,0,0] + y[u] = s + row.push(y) + } + } + table[d] = row + } + return table +})() + + +function emitFace(verts, x, c, d) { + var offsets = FACE_TABLE[d] + for(var i=0; i 0) { + var x = p.slice() + x[j] += e[1][j] + verts.push(p[0], p[1], p[2], + c[0], c[1], c[2], c[3], + 0, 0, 0, + x[0], x[1], x[2], + c[0], c[1], c[2], c[3], + 0, 0, 0) + updateBounds(this.bounds, x) + vertexCount += 2 + emitFace(verts, x, c, j) + } + } + this.lineCount[j] = vertexCount - this.lineOffset[j] + } + this.buffer.update(verts) + } +} + +proto.dispose = function() { + this.shader.dispose() + this.buffer.dispose() + this.vao.dispose() +} + +function createErrorBars(options) { + var gl = options.gl + var buffer = createBuffer(gl) + var vao = createVAO(gl, [ + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 0, + stride: 40 + }, + { + buffer: buffer, + type: gl.FLOAT, + size: 4, + offset: 12, + stride: 40 + }, + { + buffer: buffer, + type: gl.FLOAT, + size: 3, + offset: 28, + stride: 40 + } + ]) + + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.color.location = 1 + shader.attributes.offset.location = 2 + + var result = new ErrorBars(gl, buffer, vao, shader) + result.update(options) + return result +} },{"./shaders/index":238,"gl-buffer":230,"gl-vao":310}],238:[function(_dereq_,module,exports){ -'use strict' - -var glslify = _dereq_('glslify') -var createShader = _dereq_('gl-shader') - -var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]) -var fragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]) - -module.exports = function(gl) { - return createShader(gl, vertSrc, fragSrc, null, [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'offset', type: 'vec3'} - ]) -} +'use strict' + +var glslify = _dereq_('glslify') +var createShader = _dereq_('gl-shader') + +var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]) +var fragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]) + +module.exports = function(gl) { + return createShader(gl, vertSrc, fragSrc, null, [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'offset', type: 'vec3'} + ]) +} },{"gl-shader":288,"glslify":392}],239:[function(_dereq_,module,exports){ 'use strict' @@ -37571,7 +37585,7 @@ function createHeatmap2D (plot, options) { return heatmap } -},{"./lib/shaders":242,"binary-search-bounds":243,"gl-buffer":230,"gl-shader":288,"iota-array":399,"typedarray-pool":522}],242:[function(_dereq_,module,exports){ +},{"./lib/shaders":242,"binary-search-bounds":243,"gl-buffer":230,"gl-shader":288,"iota-array":399,"typedarray-pool":521}],242:[function(_dereq_,module,exports){ 'use strict' var glslify = _dereq_('glslify') @@ -37591,7 +37605,7 @@ var createShader = _dereq_('gl-shader') var vertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvec4 project(vec3 p) {\n return projection * view * model * vec4(p, 1.0);\n}\n\nvoid main() {\n vec4 startPoint = project(position);\n vec4 endPoint = project(nextPosition);\n\n vec2 A = startPoint.xy / startPoint.w;\n vec2 B = endPoint.xy / endPoint.w;\n\n float clipAngle = atan(\n (B.y - A.y) * screenShape.y,\n (B.x - A.x) * screenShape.x\n );\n\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(\n sin(clipAngle),\n -cos(clipAngle)\n ) / screenShape;\n\n gl_Position = vec4(startPoint.xy + startPoint.w * offset, startPoint.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n"]) var forwardFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]) -var pickFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1540259130(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1540259130(pixelArcLength).xyz);\n}"]) +var pickFrag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1604150559(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1604150559(pixelArcLength).xyz);\n}"]) var ATTRIBUTES = [ {name: 'position', type: 'vec3'}, @@ -38856,8890 +38870,8987 @@ function invert(out, M) { },{"gl-mat2/invert":246,"gl-mat3/invert":247,"gl-mat4/invert":254}],266:[function(_dereq_,module,exports){ arguments[4][232][0].apply(exports,arguments) },{"barycentric":61,"dup":232,"polytope-closest-point/lib/closest_point_2d.js":464}],267:[function(_dereq_,module,exports){ -var glslify = _dereq_('glslify') - -var triVertSrc = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}\n"]) -var triFragSrc = glslify(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nvec3 normals(vec3 pos) {\n vec3 fdx = dFdx(pos);\n vec3 fdy = dFdy(pos);\n return normalize(cross(fdx, fdy));\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]) -var edgeVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]) -var edgeFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) -var pointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]) -var pointFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) -var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) -var pickPointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]) -var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]) -var contourFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]) - -exports.meshShader = { - vertex: triVertSrc, - fragment: triFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'normal', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'} - ] -} -exports.wireShader = { - vertex: edgeVertSrc, - fragment: edgeFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'} - ] -} -exports.pointShader = { - vertex: pointVertSrc, - fragment: pointFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'}, - {name: 'pointSize', type: 'float'} - ] -} -exports.pickShader = { - vertex: pickVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'id', type: 'vec4'} - ] -} -exports.pointPickShader = { - vertex: pickPointVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec3'}, - {name: 'pointSize', type: 'float'}, - {name: 'id', type: 'vec4'} - ] -} -exports.contourShader = { - vertex: contourVertSrc, - fragment: contourFragSrc, - attributes: [ - {name: 'position', type: 'vec3'} - ] -} +var glslify = _dereq_('glslify') + +var triVertSrc = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}\n"]) +var triFragSrc = glslify(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nvec3 normals(vec3 pos) {\n vec3 fdx = dFdx(pos);\n vec3 fdy = dFdy(pos);\n return normalize(cross(fdx, fdy));\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]) +var edgeVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]) +var edgeFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) +var pointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]) +var pointFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]) +var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) +var pickPointVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]) +var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]) +var contourFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]) + +exports.meshShader = { + vertex: triVertSrc, + fragment: triFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'normal', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'} + ] +} +exports.wireShader = { + vertex: edgeVertSrc, + fragment: edgeFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'} + ] +} +exports.pointShader = { + vertex: pointVertSrc, + fragment: pointFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'}, + {name: 'pointSize', type: 'float'} + ] +} +exports.pickShader = { + vertex: pickVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'id', type: 'vec4'} + ] +} +exports.pointPickShader = { + vertex: pickPointVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec3'}, + {name: 'pointSize', type: 'float'}, + {name: 'id', type: 'vec4'} + ] +} +exports.contourShader = { + vertex: contourVertSrc, + fragment: contourFragSrc, + attributes: [ + {name: 'position', type: 'vec3'} + ] +} },{"glslify":392}],268:[function(_dereq_,module,exports){ +'use strict' + +var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small +var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; + +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var normals = _dereq_('normals') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var ndarray = _dereq_('ndarray') +var colormap = _dereq_('colormap') +var getContour = _dereq_('simplicial-complex-contour') +var pool = _dereq_('typedarray-pool') +var shaders = _dereq_('./lib/shaders') +var closestPoint = _dereq_('./lib/closest-point') + +var meshShader = shaders.meshShader +var wireShader = shaders.wireShader +var pointShader = shaders.pointShader +var pickShader = shaders.pickShader +var pointPickShader = shaders.pointPickShader +var contourShader = shaders.contourShader + +var identityMatrix = [ + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + + +function SimplicialMesh(gl + , texture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) { + + this.gl = gl + this.cells = [] + this.positions = [] + this.intensity = [] + this.texture = texture + this.dirty = true + + this.triShader = triShader + this.lineShader = lineShader + this.pointShader = pointShader + this.pickShader = pickShader + this.pointPickShader = pointPickShader + this.contourShader = contourShader + + this.trianglePositions = trianglePositions + this.triangleColors = triangleColors + this.triangleNormals = triangleNormals + this.triangleUVs = triangleUVs + this.triangleIds = triangleIds + this.triangleVAO = triangleVAO + this.triangleCount = 0 + + this.lineWidth = 1 + this.edgePositions = edgePositions + this.edgeColors = edgeColors + this.edgeUVs = edgeUVs + this.edgeIds = edgeIds + this.edgeVAO = edgeVAO + this.edgeCount = 0 + + this.pointPositions = pointPositions + this.pointColors = pointColors + this.pointUVs = pointUVs + this.pointSizes = pointSizes + this.pointIds = pointIds + this.pointVAO = pointVAO + this.pointCount = 0 + + this.contourLineWidth = 1 + this.contourPositions = contourPositions + this.contourVAO = contourVAO + this.contourCount = 0 + this.contourColor = [0,0,0] + this.contourEnable = true + + this.pickId = 1 + this.bounds = [ + [ Infinity, Infinity, Infinity], + [-Infinity,-Infinity,-Infinity] ] + this.clipBounds = [ + [-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity] ] + + this.lightPosition = [1e5, 1e5, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + + this.opacity = 1.0 + + this._model = identityMatrix + this._view = identityMatrix + this._projection = identityMatrix + this._resolution = [1,1] +} + +var proto = SimplicialMesh.prototype + +proto.isOpaque = function() { + return this.opacity >= 1 +} + +proto.isTransparent = function() { + return this.opacity < 1 +} + +proto.pickSlots = 1 + +proto.setPickBase = function(id) { + this.pickId = id +} + +function genColormap(param) { + var colors = colormap({ + colormap: param + , nshades: 256 + , format: 'rgba' + }) + + var result = new Uint8Array(256*4) + for(var i=0; i<256; ++i) { + var c = colors[i] + for(var j=0; j<3; ++j) { + result[4*i+j] = c[j] + } + result[4*i+3] = c[3]*255 + } + + return ndarray(result, [256,256,4], [4,0,1]) +} + +function unpackIntensity(cells, numVerts, cellIntensity) { + var result = new Array(numVerts) + for(var i=0; i 0) { + var shader = this.triShader + shader.bind() + shader.uniforms = uniforms + + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0 && this.lineWidth > 0) { + var shader = this.lineShader + shader.bind() + shader.uniforms = uniforms + + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } + + if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { + var shader = this.contourShader + shader.bind() + shader.uniforms = uniforms + + this.contourVAO.bind() + gl.drawArrays(gl.LINES, 0, this.contourCount) + this.contourVAO.unbind() + } +} + +proto.drawPick = function(params) { + params = params || {} + + var gl = this.gl + + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix + + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } + + //Save camera parameters + this._model = [].slice.call(model) + this._view = [].slice.call(view) + this._projection = [].slice.call(projection) + this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] + + var uniforms = { + model: model, + view: view, + projection: projection, + clipBounds: clipBounds, + pickId: this.pickId / 255.0, + } + + var shader = this.pickShader + shader.bind() + shader.uniforms = uniforms + + if(this.triangleCount > 0) { + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0) { + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointPickShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } +} + + +proto.pick = function(pickData) { + if(!pickData) { + return null + } + if(pickData.id !== this.pickId) { + return null + } + + var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] + var cell = this.cells[cellId] + var positions = this.positions + + var simplex = new Array(cell.length) + for(var i=0; i tickOffset[start]) { + shader.uniforms.dataAxis = DATA_AXIS + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = textColor[axis] + shader.uniforms.angle = textAngle[axis] + gl.drawArrays( + gl.TRIANGLES, + tickOffset[start], + tickOffset[end] - tickOffset[start]) + } + } + if(labelEnable[axis] && labelCount) { + SCREEN_OFFSET[axis^1] -= screenScale * pixelRatio * labelPad[axis] + shader.uniforms.dataAxis = ZERO_2 + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = labelColor[axis] + shader.uniforms.angle = labelAngle[axis] + gl.drawArrays( + gl.TRIANGLES, + labelOffset, + labelCount) + } + + SCREEN_OFFSET[axis^1] = screenScale * viewBox[2+(axis^1)] - 1.0 + if(tickEnable[axis+2]) { + SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * tickPad[axis+2] + if(start < end && tickOffset[end] > tickOffset[start]) { + shader.uniforms.dataAxis = DATA_AXIS + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = textColor[axis+2] + shader.uniforms.angle = textAngle[axis+2] + gl.drawArrays( + gl.TRIANGLES, + tickOffset[start], + tickOffset[end] - tickOffset[start]) + } + } + if(labelEnable[axis+2] && labelCount) { + SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * labelPad[axis+2] + shader.uniforms.dataAxis = ZERO_2 + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.color = labelColor[axis+2] + shader.uniforms.angle = labelAngle[axis+2] + gl.drawArrays( + gl.TRIANGLES, + labelOffset, + labelCount) + } + + } +})() + +proto.drawTitle = (function() { + var DATA_AXIS = [0,0] + var SCREEN_OFFSET = [0,0] + + return function() { + var plot = this.plot + var shader = this.shader + var gl = plot.gl + var screenBox = plot.screenBox + var titleCenter = plot.titleCenter + var titleAngle = plot.titleAngle + var titleColor = plot.titleColor + var pixelRatio = plot.pixelRatio + + if(!this.titleCount) { + return + } + + for(var i=0; i<2; ++i) { + SCREEN_OFFSET[i] = 2.0 * (titleCenter[i]*pixelRatio - screenBox[i]) / + (screenBox[2+i] - screenBox[i]) - 1 + } + + shader.bind() + shader.uniforms.dataAxis = DATA_AXIS + shader.uniforms.screenOffset = SCREEN_OFFSET + shader.uniforms.angle = titleAngle + shader.uniforms.color = titleColor + + gl.drawArrays(gl.TRIANGLES, this.titleOffset, this.titleCount) + } +})() + +proto.bind = (function() { + var DATA_SHIFT = [0,0] + var DATA_SCALE = [0,0] + var TEXT_SCALE = [0,0] + + return function() { + var plot = this.plot + var shader = this.shader + var bounds = plot._tickBounds + var dataBox = plot.dataBox + var screenBox = plot.screenBox + var viewBox = plot.viewBox + + shader.bind() + + //Set up coordinate scaling uniforms + for(var i=0; i<2; ++i) { + + var lo = bounds[i] + var hi = bounds[i+2] + var boundScale = hi - lo + var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) + var dataWidth = (dataBox[i+2] - dataBox[i]) + + var viewLo = viewBox[i] + var viewHi = viewBox[i+2] + var viewScale = viewHi - viewLo + var screenLo = screenBox[i] + var screenHi = screenBox[i+2] + var screenScale = screenHi - screenLo + + DATA_SCALE[i] = 2.0 * boundScale / dataWidth * viewScale / screenScale + DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth * viewScale / screenScale + } + + TEXT_SCALE[1] = 2.0 * plot.pixelRatio / (screenBox[3] - screenBox[1]) + TEXT_SCALE[0] = TEXT_SCALE[1] * (screenBox[3] - screenBox[1]) / (screenBox[2] - screenBox[0]) + + shader.uniforms.dataScale = DATA_SCALE + shader.uniforms.dataShift = DATA_SHIFT + shader.uniforms.textScale = TEXT_SCALE + + //Set attributes + this.vbo.bind() + shader.attributes.textCoordinate.pointer() + } +})() + +proto.update = function(options) { + var vertices = [] + var axesTicks = options.ticks + var bounds = options.bounds + var i, j, k, data, scale, dimension + + for(dimension=0; dimension<2; ++dimension) { + var offsets = [Math.floor(vertices.length/3)], tickX = [-Infinity] + + //Copy vertices over to buffer + var ticks = axesTicks[dimension] + for(i=0; i= 0)) { + continue + } + + var zeroIntercept = screenBox[i] - + dataBox[i] * (screenBox[i+2] - screenBox[i]) / (dataBox[i+2] - dataBox[i]) + + if(i === 0) { + line.drawLine( + zeroIntercept, screenBox[1], zeroIntercept, screenBox[3], + zeroLineWidth[i], + zeroLineColor[i]) + } else { + line.drawLine( + screenBox[0], zeroIntercept, screenBox[2], zeroIntercept, + zeroLineWidth[i], + zeroLineColor[i]) + } + } + } + + //Draw traces + for(var i=0; i=0; --i) { + this.objects[i].dispose() + } + this.objects.length = 0 + for(var i=this.overlays.length-1; i>=0; --i) { + this.overlays[i].dispose() + } + this.overlays.length = 0 + + this.gl = null +} + +proto.addObject = function(object) { + if(this.objects.indexOf(object) < 0) { + this.objects.push(object) + this.setDirty() + } +} + +proto.removeObject = function(object) { + var objects = this.objects + for(var i=0; i 0) { + var base = Math.round(Math.pow(10, y)) + return Math.ceil(x/base) * base + } + return Math.ceil(x) +} + +function defaultBool(x) { + if(typeof x === 'boolean') { + return x + } + return true +} + +function createScene(options) { + options = options || {} + + var stopped = false + + var pixelRatio = options.pixelRatio || parseFloat(window.devicePixelRatio) + + var canvas = options.canvas + if(!canvas) { + canvas = document.createElement('canvas') + if(options.container) { + var container = options.container + container.appendChild(canvas) + } else { + document.body.appendChild(canvas) + } + } + + var gl = options.gl + if(!gl) { + gl = getContext(canvas, + options.glOptions || { + premultipliedAlpha: true, + antialias: true, + preserveDrawingBuffer: isMobile + }) + } + if(!gl) { + throw new Error('webgl not supported') + } + + //Initial bounds + var bounds = options.bounds || [[-10,-10,-10], [10,10,10]] + + //Create selection + var selection = new MouseSelect() + + //Accumulation buffer + var accumBuffer = createFBO(gl, + [gl.drawingBufferWidth, gl.drawingBufferHeight], { + preferFloat: !isMobile + }) + + var accumShader = createShader(gl) + + //Create a camera + var cameraOptions = options.camera || { + eye: [2,0,0], + center: [0,0,0], + up: [0,1,0], + zoomMin: 0.1, + zoomMax: 100, + mode: 'turntable' + } + + //Create axes + var axesOptions = options.axes || {} + var axes = createAxes(gl, axesOptions) + axes.enable = !axesOptions.disable + + //Create spikes + var spikeOptions = options.spikes || {} + var spikes = createSpikes(gl, spikeOptions) + + //Object list is empty initially + var objects = [] + var pickBufferIds = [] + var pickBufferCount = [] + var pickBuffers = [] + + //Dirty flag, skip redraw if scene static + var dirty = true + var pickDirty = true + + var projection = new Array(16) + var model = new Array(16) + + var cameraParams = { + view: null, + projection: projection, + model: model + } + + var pickDirty = true + + var viewShape = [ gl.drawingBufferWidth, gl.drawingBufferHeight ] + + //Create scene object + var scene = { + gl: gl, + contextLost: false, + pixelRatio: options.pixelRatio || parseFloat(window.devicePixelRatio), + canvas: canvas, + selection: selection, + camera: createCamera(canvas, cameraOptions), + axes: axes, + axesPixels: null, + spikes: spikes, + bounds: bounds, + objects: objects, + shape: viewShape, + aspect: options.aspectRatio || [1,1,1], + pickRadius: options.pickRadius || 10, + zNear: options.zNear || 0.01, + zFar: options.zFar || 1000, + fovy: options.fovy || Math.PI/4, + clearColor: options.clearColor || [0,0,0,0], + autoResize: defaultBool(options.autoResize), + autoBounds: defaultBool(options.autoBounds), + autoScale: !!options.autoScale, + autoCenter: defaultBool(options.autoCenter), + clipToBounds: defaultBool(options.clipToBounds), + snapToData: !!options.snapToData, + onselect: options.onselect || null, + onrender: options.onrender || null, + onclick: options.onclick || null, + cameraParams: cameraParams, + oncontextloss: null, + mouseListener: null + } + + var pickShape = [ (gl.drawingBufferWidth/scene.pixelRatio)|0, (gl.drawingBufferHeight/scene.pixelRatio)|0 ] + + function resizeListener() { + if(stopped) { + return + } + if(!scene.autoResize) { + return + } + var parent = canvas.parentNode + var width = 1 + var height = 1 + if(parent && parent !== document.body) { + width = parent.clientWidth + height = parent.clientHeight + } else { + width = window.innerWidth + height = window.innerHeight + } + var nextWidth = Math.ceil(width * scene.pixelRatio)|0 + var nextHeight = Math.ceil(height * scene.pixelRatio)|0 + if(nextWidth !== canvas.width || nextHeight !== canvas.height) { + canvas.width = nextWidth + canvas.height = nextHeight + var style = canvas.style + style.position = style.position || 'absolute' + style.left = '0px' + style.top = '0px' + style.width = width + 'px' + style.height = height + 'px' + dirty = true + } + } + if(scene.autoResize) { + resizeListener() + } + window.addEventListener('resize', resizeListener) + + function reallocPickIds() { + var numObjs = objects.length + var numPick = pickBuffers.length + for(var i=0; i 0 && pickBufferCount[numPick-1] === 0) { + pickBufferCount.pop() + pickBuffers.pop().dispose() + } + } + + scene.update = function(options) { + if(stopped) { + return + } + options = options || {} + dirty = true + pickDirty = true + } + + scene.add = function(obj) { + if(stopped) { + return + } + obj.axes = axes + objects.push(obj) + pickBufferIds.push(-1) + dirty = true + pickDirty = true + reallocPickIds() + } + + scene.remove = function(obj) { + if(stopped) { + return + } + var idx = objects.indexOf(obj) + if(idx < 0) { + return + } + objects.splice(idx, 1) + pickBufferIds.pop() + dirty = true + pickDirty = true + reallocPickIds() + } + + scene.dispose = function() { + if(stopped) { + return + } + + stopped = true + + window.removeEventListener('resize', resizeListener) + canvas.removeEventListener('webglcontextlost', checkContextLoss) + scene.mouseListener.enabled = false + + if(scene.contextLost) { + return + } + + //Destroy objects + axes.dispose() + spikes.dispose() + for(var i=0; i selection.distance) { + continue + } + for(var j=0; j 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]) +exports.pickVertex = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]) +exports.pickFragment = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"]) + +},{"glslify":392}],279:[function(_dereq_,module,exports){ 'use strict' -var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small -var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var normals = _dereq_('normals') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var ndarray = _dereq_('ndarray') -var colormap = _dereq_('colormap') -var getContour = _dereq_('simplicial-complex-contour') -var pool = _dereq_('typedarray-pool') -var shaders = _dereq_('./lib/shaders') -var closestPoint = _dereq_('./lib/closest-point') - -var meshShader = shaders.meshShader -var wireShader = shaders.wireShader -var pointShader = shaders.pointShader -var pickShader = shaders.pickShader -var pointPickShader = shaders.pointPickShader -var contourShader = shaders.contourShader - -var identityMatrix = [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - - -function SimplicialMesh(gl - , texture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) { - - this.gl = gl - this.cells = [] - this.positions = [] - this.intensity = [] - this.texture = texture - this.dirty = true - - this.triShader = triShader - this.lineShader = lineShader - this.pointShader = pointShader - this.pickShader = pickShader - this.pointPickShader = pointPickShader - this.contourShader = contourShader - - this.trianglePositions = trianglePositions - this.triangleColors = triangleColors - this.triangleNormals = triangleNormals - this.triangleUVs = triangleUVs - this.triangleIds = triangleIds - this.triangleVAO = triangleVAO - this.triangleCount = 0 - - this.lineWidth = 1 - this.edgePositions = edgePositions - this.edgeColors = edgeColors - this.edgeUVs = edgeUVs - this.edgeIds = edgeIds - this.edgeVAO = edgeVAO - this.edgeCount = 0 - - this.pointPositions = pointPositions - this.pointColors = pointColors - this.pointUVs = pointUVs - this.pointSizes = pointSizes - this.pointIds = pointIds - this.pointVAO = pointVAO - this.pointCount = 0 - - this.contourLineWidth = 1 - this.contourPositions = contourPositions - this.contourVAO = contourVAO - this.contourCount = 0 - this.contourColor = [0,0,0] - this.contourEnable = true - - this.pickId = 1 - this.bounds = [ - [ Infinity, Infinity, Infinity], - [-Infinity,-Infinity,-Infinity] ] - this.clipBounds = [ - [-Infinity,-Infinity,-Infinity], - [ Infinity, Infinity, Infinity] ] - - this.lightPosition = [1e5, 1e5, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - - this.opacity = 1.0 - - this._model = identityMatrix - this._view = identityMatrix - this._projection = identityMatrix - this._resolution = [1,1] -} +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') -var proto = SimplicialMesh.prototype +var pool = _dereq_('typedarray-pool') -proto.isOpaque = function() { - return this.opacity >= 1 -} +var SHADERS = _dereq_('./lib/shader') + +module.exports = createPointcloud2D -proto.isTransparent = function() { - return this.opacity < 1 +function Pointcloud2D(plot, offsetBuffer, pickBuffer, shader, pickShader) { + this.plot = plot + this.offsetBuffer = offsetBuffer + this.pickBuffer = pickBuffer + this.shader = shader + this.pickShader = pickShader + this.sizeMin = 0.5 + this.sizeMinCap = 2 + this.sizeMax = 20 + this.areaRatio = 1.0 + this.pointCount = 0 + this.color = [1, 0, 0, 1] + this.borderColor = [0, 0, 0, 1] + this.blend = false + this.pickOffset = 0 + this.points = null } -proto.pickSlots = 1 +var proto = Pointcloud2D.prototype -proto.setPickBase = function(id) { - this.pickId = id +proto.dispose = function() { + this.shader.dispose() + this.pickShader.dispose() + this.offsetBuffer.dispose() + this.pickBuffer.dispose() + this.plot.removeObject(this) } -function genColormap(param) { - var colors = colormap({ - colormap: param - , nshades: 256 - , format: 'rgba' - }) +proto.update = function(options) { - var result = new Uint8Array(256*4) - for(var i=0; i<256; ++i) { - var c = colors[i] - for(var j=0; j<3; ++j) { - result[4*i+j] = c[j] - } - result[4*i+3] = c[3]*255 - } + var i - return ndarray(result, [256,256,4], [4,0,1]) -} + options = options || {} -function unpackIntensity(cells, numVerts, cellIntensity) { - var result = new Array(numVerts) - for(var i=0; i>> 1 + var dataStraightThrough = options.positions instanceof Float32Array + var idStraightThrough = options.idToIndex instanceof Int32Array && options.idToIndex.length >= pointCount // permit larger to help reuse - this.dirty = true + var data = options.positions + var packed = dataStraightThrough ? data : pool.mallocFloat32(data.length) + var packedId = idStraightThrough ? options.idToIndex : pool.mallocInt32(pointCount) - if('contourEnable' in params) { - this.contourEnable = params.contourEnable - } - if('contourColor' in params) { - this.contourColor = params.contourColor - } - if('lineWidth' in params) { - this.lineWidth = params.lineWidth - } - if('lightPosition' in params) { - this.lightPosition = params.lightPosition - } - if('opacity' in params) { - this.opacity = params.opacity - } - if('ambient' in params) { - this.ambientLight = params.ambient - } - if('diffuse' in params) { - this.diffuseLight = params.diffuse - } - if('specular' in params) { - this.specularLight = params.specular - } - if('roughness' in params) { - this.roughness = params.roughness - } - if('fresnel' in params) { - this.fresnel = params.fresnel + if(!dataStraightThrough) { + packed.set(data) } - if(params.texture) { - this.texture.dispose() - this.texture = createTexture(gl, params.texture) - } else if (params.colormap) { - this.texture.shape = [256,256] - this.texture.minFilter = gl.LINEAR_MIPMAP_LINEAR - this.texture.magFilter = gl.LINEAR - this.texture.setPixels(genColormap(params.colormap)) - this.texture.generateMipmap() + if(!idStraightThrough) { + packed.set(data) + for(i = 0; i < pointCount; i++) { + packedId[i] = i + } } - var cells = params.cells - var positions = params.positions + this.points = data - if(!positions || !cells) { - return - } + this.offsetBuffer.update(packed) + this.pickBuffer.update(packedId) - var tPos = [] - var tCol = [] - var tNor = [] - var tUVs = [] - var tIds = [] - - var ePos = [] - var eCol = [] - var eUVs = [] - var eIds = [] - - var pPos = [] - var pCol = [] - var pUVs = [] - var pSiz = [] - var pIds = [] - - //Save geometry data for picking calculations - this.cells = cells - this.positions = positions - - //Compute normals - var vertexNormals = params.vertexNormals - var cellNormals = params.cellNormals - var vertexNormalsEpsilon = params.vertexNormalsEpsilon === void(0) ? DEFAULT_VERTEX_NORMALS_EPSILON : params.vertexNormalsEpsilon - var faceNormalsEpsilon = params.faceNormalsEpsilon === void(0) ? DEFAULT_FACE_NORMALS_EPSILON : params.faceNormalsEpsilon - if(params.useFacetNormals && !cellNormals) { - cellNormals = normals.faceNormals(cells, positions, faceNormalsEpsilon) + if(!dataStraightThrough) { + pool.free(packed) } - if(!cellNormals && !vertexNormals) { - vertexNormals = normals.vertexNormals(cells, positions, vertexNormalsEpsilon) - } - - //Compute colors - var vertexColors = params.vertexColors - var cellColors = params.cellColors - var meshColor = params.meshColor || [1,1,1,1] - - //UVs - var vertexUVs = params.vertexUVs - var vertexIntensity = params.vertexIntensity - var cellUVs = params.cellUVs - var cellIntensity = params.cellIntensity - - var intensityLo = Infinity - var intensityHi = -Infinity - if(!vertexUVs && !cellUVs) { - if(vertexIntensity) { - if(params.vertexIntensityBounds) { - intensityLo = +params.vertexIntensityBounds[0] - intensityHi = +params.vertexIntensityBounds[1] - } else { - for(var i=0; i>> 1 + var i + for(i = 0; i < length; i++) { + var x = points[i * 2] + var y = points[i * 2 + 1] + if(x >= dataBox[0] && x <= dataBox[2] && y >= dataBox[1] && y <= dataBox[3]) + visiblePointCountEstimate++ } + return visiblePointCountEstimate +} - if(this.triangleCount > 0) { - var shader = this.triShader - shader.bind() - shader.uniforms = uniforms - - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } +proto.unifiedDraw = (function() { + var MATRIX = [1, 0, 0, + 0, 1, 0, + 0, 0, 1] + var PICK_VEC4 = [0, 0, 0, 0] +return function(pickOffset) { + var pick = pickOffset !== void(0) - if(this.edgeCount > 0 && this.lineWidth > 0) { - var shader = this.lineShader - shader.bind() - shader.uniforms = uniforms + var shader = pick ? this.pickShader : this.shader + var gl = this.plot.gl + var dataBox = this.plot.dataBox - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() + if(this.pointCount === 0) { + return pickOffset } - if(this.pointCount > 0) { - var shader = this.pointShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } + var dataX = dataBox[2] - dataBox[0] + var dataY = dataBox[3] - dataBox[1] - if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { - var shader = this.contourShader - shader.bind() - shader.uniforms = uniforms + var visiblePointCountEstimate = count(this.points, dataBox) + var basicPointSize = this.plot.pickPixelRatio * Math.max(Math.min(this.sizeMinCap, this.sizeMin), Math.min(this.sizeMax, this.sizeMax / Math.pow(visiblePointCountEstimate, 0.33333))) - this.contourVAO.bind() - gl.drawArrays(gl.LINES, 0, this.contourCount) - this.contourVAO.unbind() - } -} + MATRIX[0] = 2.0 / dataX + MATRIX[4] = 2.0 / dataY + MATRIX[6] = -2.0 * dataBox[0] / dataX - 1.0 + MATRIX[7] = -2.0 * dataBox[1] / dataY - 1.0 -proto.drawPick = function(params) { - params = params || {} + this.offsetBuffer.bind() - var gl = this.gl + shader.bind() + shader.attributes.position.pointer() + shader.uniforms.matrix = MATRIX + shader.uniforms.color = this.color + shader.uniforms.borderColor = this.borderColor + shader.uniforms.pointCloud = basicPointSize < 5 + shader.uniforms.pointSize = basicPointSize + shader.uniforms.centerFraction = Math.min(1, Math.max(0, Math.sqrt(1 - this.areaRatio))) - var model = params.model || identityMatrix - var view = params.view || identityMatrix - var projection = params.projection || identityMatrix + if(pick) { - var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] - for(var i=0; i<3; ++i) { - clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) - clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) - } + PICK_VEC4[0] = ( pickOffset & 0xff) + PICK_VEC4[1] = ((pickOffset >> 8) & 0xff) + PICK_VEC4[2] = ((pickOffset >> 16) & 0xff) + PICK_VEC4[3] = ((pickOffset >> 24) & 0xff) - //Save camera parameters - this._model = [].slice.call(model) - this._view = [].slice.call(view) - this._projection = [].slice.call(projection) - this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - - var uniforms = { - model: model, - view: view, - projection: projection, - clipBounds: clipBounds, - pickId: this.pickId / 255.0, + this.pickBuffer.bind() + shader.attributes.pickId.pointer(gl.UNSIGNED_BYTE) + shader.uniforms.pickOffset = PICK_VEC4 + this.pickOffset = pickOffset } - var shader = this.pickShader - shader.bind() - shader.uniforms = uniforms + // Worth switching these off, but we can't make assumptions about other + // renderers, so let's restore it after each draw + var blend = gl.getParameter(gl.BLEND) + var dither = gl.getParameter(gl.DITHER) - if(this.triangleCount > 0) { - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } + if(blend && !this.blend) + gl.disable(gl.BLEND) + if(dither) + gl.disable(gl.DITHER) - if(this.edgeCount > 0) { - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } + gl.drawArrays(gl.POINTS, 0, this.pointCount) - if(this.pointCount > 0) { - var shader = this.pointPickShader - shader.bind() - shader.uniforms = uniforms + if(blend && !this.blend) + gl.enable(gl.BLEND) + if(dither) + gl.enable(gl.DITHER) - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } + return pickOffset + this.pointCount } +})() +proto.draw = proto.unifiedDraw +proto.drawPick = proto.unifiedDraw -proto.pick = function(pickData) { - if(!pickData) { - return null - } - if(pickData.id !== this.pickId) { - return null - } - - var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] - var cell = this.cells[cellId] - var positions = this.positions - - var simplex = new Array(cell.length) - for(var i=0; i= pickOffset + pointCount) { return null } - - var weights = data[2] - var interpIntensity = 0.0 - for(var i=0; i tickOffset[start]) { - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = textColor[axis] - shader.uniforms.angle = textAngle[axis] - gl.drawArrays( - gl.TRIANGLES, - tickOffset[start], - tickOffset[end] - tickOffset[start]) - } - } - if(labelEnable[axis] && labelCount) { - SCREEN_OFFSET[axis^1] -= screenScale * pixelRatio * labelPad[axis] - shader.uniforms.dataAxis = ZERO_2 - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = labelColor[axis] - shader.uniforms.angle = labelAngle[axis] - gl.drawArrays( - gl.TRIANGLES, - labelOffset, - labelCount) - } - - SCREEN_OFFSET[axis^1] = screenScale * viewBox[2+(axis^1)] - 1.0 - if(tickEnable[axis+2]) { - SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * tickPad[axis+2] - if(start < end && tickOffset[end] > tickOffset[start]) { - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = textColor[axis+2] - shader.uniforms.angle = textAngle[axis+2] - gl.drawArrays( - gl.TRIANGLES, - tickOffset[start], - tickOffset[end] - tickOffset[start]) - } - } - if(labelEnable[axis+2] && labelCount) { - SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * labelPad[axis+2] - shader.uniforms.dataAxis = ZERO_2 - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.color = labelColor[axis+2] - shader.uniforms.angle = labelAngle[axis+2] - gl.drawArrays( - gl.TRIANGLES, - labelOffset, - labelCount) - } - - } -})() - -proto.drawTitle = (function() { - var DATA_AXIS = [0,0] - var SCREEN_OFFSET = [0,0] - - return function() { - var plot = this.plot - var shader = this.shader - var gl = plot.gl - var screenBox = plot.screenBox - var titleCenter = plot.titleCenter - var titleAngle = plot.titleAngle - var titleColor = plot.titleColor - var pixelRatio = plot.pixelRatio - - if(!this.titleCount) { - return - } - - for(var i=0; i<2; ++i) { - SCREEN_OFFSET[i] = 2.0 * (titleCenter[i]*pixelRatio - screenBox[i]) / - (screenBox[2+i] - screenBox[i]) - 1 - } - - shader.bind() - shader.uniforms.dataAxis = DATA_AXIS - shader.uniforms.screenOffset = SCREEN_OFFSET - shader.uniforms.angle = titleAngle - shader.uniforms.color = titleColor - - gl.drawArrays(gl.TRIANGLES, this.titleOffset, this.titleCount) - } -})() - -proto.bind = (function() { - var DATA_SHIFT = [0,0] - var DATA_SCALE = [0,0] - var TEXT_SCALE = [0,0] - - return function() { - var plot = this.plot - var shader = this.shader - var bounds = plot._tickBounds - var dataBox = plot.dataBox - var screenBox = plot.screenBox - var viewBox = plot.viewBox - - shader.bind() - - //Set up coordinate scaling uniforms - for(var i=0; i<2; ++i) { - - var lo = bounds[i] - var hi = bounds[i+2] - var boundScale = hi - lo - var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) - var dataWidth = (dataBox[i+2] - dataBox[i]) - - var viewLo = viewBox[i] - var viewHi = viewBox[i+2] - var viewScale = viewHi - viewLo - var screenLo = screenBox[i] - var screenHi = screenBox[i+2] - var screenScale = screenHi - screenLo - - DATA_SCALE[i] = 2.0 * boundScale / dataWidth * viewScale / screenScale - DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth * viewScale / screenScale - } - - TEXT_SCALE[1] = 2.0 * plot.pixelRatio / (screenBox[3] - screenBox[1]) - TEXT_SCALE[0] = TEXT_SCALE[1] * (screenBox[3] - screenBox[1]) / (screenBox[2] - screenBox[0]) - - shader.uniforms.dataScale = DATA_SCALE - shader.uniforms.dataShift = DATA_SHIFT - shader.uniforms.textScale = TEXT_SCALE - - //Set attributes - this.vbo.bind() - shader.attributes.textCoordinate.pointer() - } -})() - -proto.update = function(options) { - var vertices = [] - var axesTicks = options.ticks - var bounds = options.bounds - var i, j, k, data, scale, dimension - - for(dimension=0; dimension<2; ++dimension) { - var offsets = [Math.floor(vertices.length/3)], tickX = [-Infinity] - - //Copy vertices over to buffer - var ticks = axesTicks[dimension] - for(i=0; i 0.000001) { + // standard case (slerp) + omega = Math.acos(cosom) + sinom = Math.sin(omega) + scale0 = Math.sin((1.0 - t) * omega) / sinom + scale1 = Math.sin(t * omega) / sinom + } else { + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + scale0 = 1.0 - t + scale1 = t + } + // calculate final values + out[0] = scale0 * ax + scale1 * bx + out[1] = scale0 * ay + scale1 * by + out[2] = scale0 * az + scale1 * bz + out[3] = scale0 * aw + scale1 * bw + + return out +} + +},{}],281:[function(_dereq_,module,exports){ +'use strict'; + +module.exports = function(a){ + return (!a && a !== 0) ? '' : a.toString(); +} + +},{}],282:[function(_dereq_,module,exports){ +"use strict" + +var vectorizeText = _dereq_("vectorize-text") + +module.exports = getGlyph + +var GLYPH_CACHE = {} + +function getGlyph(symbol, font) { + var fontCache = GLYPH_CACHE[font] + if(!fontCache) { + fontCache = GLYPH_CACHE[font] = {} + } + if(symbol in fontCache) { + return fontCache[symbol] + } + + var config = { + textAlign: "center", + textBaseline: "middle", + lineHeight: 1.0, + font: font, + lineSpacing: 1.25, + styletags: { + breaklines:true, + bolds: true, + italics: true, + subscripts:true, + superscripts:true + } + } + + //Get line and triangle meshes for glyph + config.triangles = true; + var triSymbol = vectorizeText(symbol, config) + config.triangles = false; + var lineSymbol = vectorizeText(symbol, config) + + //Calculate bounding box + var bounds = [[Infinity,Infinity], [-Infinity,-Infinity]] + var n = lineSymbol.positions.length + for(var i = 0; i < n; ++i) { + var p = lineSymbol.positions[i] + for(var j=0; j<2; ++j) { + bounds[0][j] = Math.min(bounds[0][j], p[j]) + bounds[1][j] = Math.max(bounds[1][j], p[j]) + } + } + + //Save cached symbol + return fontCache[symbol] = [triSymbol, lineSymbol, bounds] +} +},{"vectorize-text":526}],283:[function(_dereq_,module,exports){ +var createShaderWrapper = _dereq_('gl-shader') +var glslify = _dereq_('glslify') + +var perspectiveVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) +var orthographicVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) +var projectionVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]) +var drawFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]) + +var ATTRIBUTES = [ + {name: 'position', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'glyph', type: 'vec2'}, + {name: 'id', type: 'vec4'} +] + +var perspective = { + vertex: perspectiveVertSrc, + fragment: drawFragSrc, + attributes: ATTRIBUTES + }, + ortho = { + vertex: orthographicVertSrc, + fragment: drawFragSrc, + attributes: ATTRIBUTES + }, + project = { + vertex: projectionVertSrc, + fragment: drawFragSrc, + attributes: ATTRIBUTES + }, + pickPerspective = { + vertex: perspectiveVertSrc, + fragment: pickFragSrc, + attributes: ATTRIBUTES + }, + pickOrtho = { + vertex: orthographicVertSrc, + fragment: pickFragSrc, + attributes: ATTRIBUTES + }, + pickProject = { + vertex: projectionVertSrc, + fragment: pickFragSrc, + attributes: ATTRIBUTES + } + +function createShader(gl, src) { + var shader = createShaderWrapper(gl, src) + var attr = shader.attributes + attr.position.location = 0 + attr.color.location = 1 + attr.glyph.location = 2 + attr.id.location = 3 + return shader +} + +exports.createPerspective = function(gl) { + return createShader(gl, perspective) +} +exports.createOrtho = function(gl) { + return createShader(gl, ortho) +} +exports.createProject = function(gl) { + return createShader(gl, project) +} +exports.createPickPerspective = function(gl) { + return createShader(gl, pickPerspective) +} +exports.createPickOrtho = function(gl) { + return createShader(gl, pickOrtho) +} +exports.createPickProject = function(gl) { + return createShader(gl, pickProject) +} + +},{"gl-shader":288,"glslify":392}],284:[function(_dereq_,module,exports){ +'use strict' + +var isAllBlank = _dereq_('is-string-blank') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var pool = _dereq_('typedarray-pool') +var mat4mult = _dereq_('gl-mat4/multiply') +var shaders = _dereq_('./lib/shaders') +var getGlyph = _dereq_('./lib/glyphs') +var getSimpleString = _dereq_('./lib/get-simple-string') + +var IDENTITY = [1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +module.exports = createPointCloud + +function transformMat4(x, m) { + var x0 = x[0] + var x1 = x[1] + var x2 = x[2] + var x3 = x[3] + x[0] = m[0] * x0 + m[4] * x1 + m[8] * x2 + m[12] * x3 + x[1] = m[1] * x0 + m[5] * x1 + m[9] * x2 + m[13] * x3 + x[2] = m[2] * x0 + m[6] * x1 + m[10] * x2 + m[14] * x3 + x[3] = m[3] * x0 + m[7] * x1 + m[11] * x2 + m[15] * x3 + return x +} + +function project(p, v, m, x) { + transformMat4(x, x, m) + transformMat4(x, x, v) + return transformMat4(x, x, p) +} + +function clampVec(v) { + var result = new Array(3) + for(var i=0; i<3; ++i) { + result[i] = Math.min(Math.max(v[i], -1e8), 1e8) + } + return result +} + +function ScatterPlotPickResult(index, position) { + this.index = index + this.dataCoordinate = this.position = position +} + +var MAX_OPACITY = 1 + +function fixOpacity(a) { + if(a === true) return MAX_OPACITY + if(a > MAX_OPACITY) return MAX_OPACITY + return a +} + +function PointCloud( + gl, + shader, + orthoShader, + projectShader, + pointBuffer, + colorBuffer, + glyphBuffer, + idBuffer, + vao, + pickPerspectiveShader, + pickOrthoShader, + pickProjectShader) { + + this.gl = gl + + this.pixelRatio = 1 + + this.shader = shader + this.orthoShader = orthoShader + this.projectShader = projectShader + + this.pointBuffer = pointBuffer + this.colorBuffer = colorBuffer + this.glyphBuffer = glyphBuffer + this.idBuffer = idBuffer + this.vao = vao + this.vertexCount = 0 + this.lineVertexCount = 0 + + this.opacity = MAX_OPACITY + + this.lineWidth = 0 + this.projectScale = [2.0/3.0, 2.0/3.0, 2.0/3.0] + this.projectOpacity = [MAX_OPACITY, MAX_OPACITY, MAX_OPACITY] + + this.pickId = 0 + this.pickPerspectiveShader = pickPerspectiveShader + this.pickOrthoShader = pickOrthoShader + this.pickProjectShader = pickProjectShader + this.points = [] + + this._selectResult = new ScatterPlotPickResult(0, [0,0,0]) + + this.useOrtho = true + this.bounds = [[ Infinity,Infinity,Infinity], + [-Infinity,-Infinity,-Infinity]] + + //Axes projections + this.axesProject = [ true, true, true ] + this.axesBounds = [[-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity]] + + this.highlightId = [1,1,1,1] + this.highlightScale = 2 + + this.clipBounds = [[-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity]] + + this.dirty = true +} + +var proto = PointCloud.prototype + +proto.pickSlots = 1 + +proto.setPickBase = function(pickBase) { + this.pickId = pickBase +} + +proto.isTransparent = function() { + if(this.opacity < MAX_OPACITY) { + return true + } + for(var i=0; i<3; ++i) { + if(this.axesProject[i] && this.projectOpacity[i] < MAX_OPACITY) { + return true + } + } + return false +} + +proto.isOpaque = function() { + if(this.opacity >= MAX_OPACITY) { + return true + } + for(var i=0; i<3; ++i) { + if(this.axesProject[i] && this.projectOpacity[i] >= MAX_OPACITY) { + return true + } + } + return false +} + +var VIEW_SHAPE = [0,0] +var U_VEC = [0,0,0] +var V_VEC = [0,0,0] +var MU_VEC = [0,0,0,1] +var MV_VEC = [0,0,0,1] +var SCRATCH_MATRIX = IDENTITY.slice() +var SCRATCH_VEC = [0,0,0] +var CLIP_BOUNDS = [[0,0,0], [0,0,0]] + +function zeroVec(a) { + a[0] = a[1] = a[2] = 0 + return a +} + +function augment(hg, af) { + hg[0] = af[0] + hg[1] = af[1] + hg[2] = af[2] + hg[3] = 1 + return hg +} + +function setComponent(out, v, i, x) { + out[0] = v[0] + out[1] = v[1] + out[2] = v[2] + out[i] = x + return out +} + +function getClipBounds(bounds) { + var result = CLIP_BOUNDS + for(var i=0; i<2; ++i) { + for(var j=0; j<3; ++j) { + result[i][j] = Math.max(Math.min(bounds[i][j], 1e8), -1e8) + } + } + return result +} + +function drawProject(shader, points, camera) { + var axesProject = points.axesProject + + var gl = points.gl + var uniforms = shader.uniforms + var model = camera.model || IDENTITY + var view = camera.view || IDENTITY + var projection = camera.projection || IDENTITY + var bounds = points.axesBounds + var clipBounds = getClipBounds(points.clipBounds) + + var cubeAxis + if(points.axes && points.axes.lastCubeProps) { + cubeAxis = points.axes.lastCubeProps.axis + } else { + cubeAxis = [1,1,1] + } + + VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth + VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight + + shader.bind() + uniforms.view = view + uniforms.projection = projection + uniforms.screenSize = VIEW_SHAPE + uniforms.highlightId = points.highlightId + uniforms.highlightScale = points.highlightScale + uniforms.clipBounds = clipBounds + uniforms.pickGroup = points.pickId / 255.0 + uniforms.pixelRatio = points.pixelRatio + + for(var i=0; i<3; ++i) { + if(!axesProject[i]) { + continue + } + + uniforms.scale = points.projectScale[i] + uniforms.opacity = points.projectOpacity[i] + + //Project model matrix + var pmodel = SCRATCH_MATRIX + for(var j=0; j<16; ++j) { + pmodel[j] = 0 + } + for(var j=0; j<4; ++j) { + pmodel[5*j] = 1 + } + pmodel[5*i] = 0 + if(cubeAxis[i] < 0) { + pmodel[12+i] = bounds[0][i] + } else { + pmodel[12+i] = bounds[1][i] + } + mat4mult(pmodel, model, pmodel) + uniforms.model = pmodel + + //Compute initial axes + var u = (i+1)%3 + var v = (i+2)%3 + var du = zeroVec(U_VEC) + var dv = zeroVec(V_VEC) + du[u] = 1 + dv[v] = 1 + + //Align orientation relative to viewer + var mdu = project(projection, view, model, augment(MU_VEC, du)) + var mdv = project(projection, view, model, augment(MV_VEC, dv)) + if(Math.abs(mdu[1]) > Math.abs(mdv[1])) { + var tmp = mdu + mdu = mdv + mdv = tmp + tmp = du + du = dv + dv = tmp + var t = u + u = v + v = t + } + if(mdu[0] < 0) { + du[u] = -1 + } + if(mdv[1] > 0) { + dv[v] = -1 + } + var su = 0.0 + var sv = 0.0 + for(var j=0; j<4; ++j) { + su += Math.pow(model[4*u+j], 2) + sv += Math.pow(model[4*v+j], 2) + } + du[u] /= Math.sqrt(su) + dv[v] /= Math.sqrt(sv) + uniforms.axes[0] = du + uniforms.axes[1] = dv + + //Update fragment clip bounds + uniforms.fragClipBounds[0] = setComponent(SCRATCH_VEC, clipBounds[0], i, -1e8) + uniforms.fragClipBounds[1] = setComponent(SCRATCH_VEC, clipBounds[1], i, 1e8) + + points.vao.bind() + + //Draw interior + points.vao.draw(gl.TRIANGLES, points.vertexCount) + + //Draw edges + if(points.lineWidth > 0) { + gl.lineWidth(points.lineWidth) + points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) + } + + points.vao.unbind() + } +} + + +var NEG_INFINITY3 = [-1e8, -1e8, -1e8] +var POS_INFINITY3 = [1e8, 1e8, 1e8] +var CLIP_GROUP = [NEG_INFINITY3, POS_INFINITY3] + +function drawFull(shader, pshader, points, camera, transparent, forceDraw) { + var gl = points.gl + + + + if(transparent === (points.projectOpacity < MAX_OPACITY) || forceDraw) { + drawProject(pshader, points, camera) + } + + if(transparent === (points.opacity < MAX_OPACITY) || forceDraw) { + + shader.bind() + var uniforms = shader.uniforms + + uniforms.model = camera.model || IDENTITY + uniforms.view = camera.view || IDENTITY + uniforms.projection = camera.projection || IDENTITY + + VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth + VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight + uniforms.screenSize = VIEW_SHAPE + + uniforms.highlightId = points.highlightId + uniforms.highlightScale = points.highlightScale + + uniforms.fragClipBounds = CLIP_GROUP + uniforms.clipBounds = points.axes.bounds + + uniforms.opacity = points.opacity + uniforms.pickGroup = points.pickId / 255.0 + + uniforms.pixelRatio = points.pixelRatio + + points.vao.bind() + + //Draw interior + points.vao.draw(gl.TRIANGLES, points.vertexCount) + + //Draw edges + if(points.lineWidth > 0) { + gl.lineWidth(points.lineWidth) + points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) + } + + points.vao.unbind() + } + + +} + +proto.draw = function(camera) { + var shader = this.useOrtho ? this.orthoShader : this.shader + drawFull(shader, this.projectShader, this, camera, false, false) +} + +proto.drawTransparent = function(camera) { + var shader = this.useOrtho ? this.orthoShader : this.shader + drawFull(shader, this.projectShader, this, camera, true, false) +} + +proto.drawPick = function(camera) { + var shader = this.useOrtho ? this.pickOrthoShader : this.pickPerspectiveShader + drawFull(shader, this.pickProjectShader, this, camera, true, true) +} + +proto.pick = function(selected) { + if(!selected) { + return null + } + if(selected.id !== this.pickId) { + return null + } + var x = selected.value[2] + (selected.value[1]<<8) + (selected.value[0]<<16) + if(x >= this.pointCount || x < 0) { + return null + } + + //Unpack result + var coord = this.points[x] + var result = this._selectResult + result.index = x + for(var i=0; i<3; ++i) { + result.position[i] = result.dataCoordinate[i] = coord[i] + } + return result +} + +proto.highlight = function(selection) { + if(!selection) { + this.highlightId = [1,1,1,1] + } else { + var pointId = selection.index + var a0 = pointId &0xff + var a1 = (pointId>>8) &0xff + var a2 = (pointId>>16)&0xff + this.highlightId = [a0/255.0, a1/255.0, a2/255.0, 0] + } +} + +function get_glyphData(glyphs, index, font) { + var str + + // use the data if presented in an array + if(Array.isArray(glyphs)) { + if(index < glyphs.length) { + str = glyphs[index] + } else { + str = undefined + } + } else { + str = glyphs + } + + str = getSimpleString(str) // this would handle undefined cases + + var visible = true + if(isAllBlank(str)) { + str = '▼' // Note: this special character may have minimum number of surfaces + visible = false + } + + var glyph = getGlyph(str, font) + + return { mesh:glyph[0], + lines:glyph[1], + bounds:glyph[2], + visible:visible }; +} + + + +proto.update = function(options) { + + options = options || {} + + if('perspective' in options) { + this.useOrtho = !options.perspective + } + if('orthographic' in options) { + this.useOrtho = !!options.orthographic + } + if('lineWidth' in options) { + this.lineWidth = options.lineWidth + } + if('project' in options) { + if(Array.isArray(options.project)) { + this.axesProject = options.project + } else { + var v = !!options.project + this.axesProject = [v,v,v] + } + } + if('projectScale' in options) { + if(Array.isArray(options.projectScale)) { + this.projectScale = options.projectScale.slice() + } else { + var s = +options.projectScale + this.projectScale = [s,s,s] + } + } + if('projectOpacity' in options) { + if(Array.isArray(options.projectOpacity)) { + this.projectOpacity = options.projectOpacity.slice() + } else { + var s = +options.projectOpacity + this.projectOpacity = [s,s,s] + } + for(var i=0; i<3; ++i) { + this.projectOpacity[i] = fixOpacity(this.projectOpacity[i]); + } + } + if('opacity' in options) { + this.opacity = fixOpacity(options.opacity) + } + + //Set dirty flag + this.dirty = true + + //Create new buffers + var points = options.position + + //Text font + var font = options.font || 'normal' + var alignment = options.alignment || [0,0] + + var alignmentX; + var alignmentY; + if (alignment.length === 2) { + alignmentX = alignment[0] + alignmentY = alignment[1] + } else { + alignmentX = [] + alignmentY = [] + for (var i = 0; i < alignment.length; ++i) { + alignmentX[i] = alignment[i][0] + alignmentY[i] = alignment[i][1] + } + } + + //Bounds + var lowerBound = [ Infinity, Infinity, Infinity] + var upperBound = [-Infinity,-Infinity,-Infinity] + + //Unpack options + var glyphs = options.glyph + var colors = options.color + var sizes = options.size + var angles = options.angle + var lineColors = options.lineColor + + //Picking geometry + var pickCounter = -1 + + //First do pass to compute buffer sizes + var triVertexCount = 0 + var lineVertexCount = 0 + + var numPoints = 0; + + if(points.length) { + + //Count number of points and buffer size + numPoints = points.length + + count_loop: + for(var i=0; i 0) { + var triOffset = 0 + var lineOffset = triVertexCount + var color = [0,0,0,1] + var lineColor = [0,0,0,1] + + var isColorArray = Array.isArray(colors) && Array.isArray(colors[0]) + var isLineColorArray = Array.isArray(lineColors) && Array.isArray(lineColors[0]) + + fill_loop: + for(var i=0; i 0) ? (1 - glyphBounds[0][0]) : + (textOffsetX < 0) ? (1 + glyphBounds[1][0]) : 1; + + textOffsetY *= (textOffsetY > 0) ? (1 - glyphBounds[0][1]) : + (textOffsetY < 0) ? (1 + glyphBounds[1][1]) : 1; + + var textOffset = [textOffsetX, textOffsetY] + + //Write out inner marker + var cells = glyphMesh.cells || [] + var verts = glyphMesh.positions || [] + + for(var j=0; j= 0)) { - continue - } - - var zeroIntercept = screenBox[i] - - dataBox[i] * (screenBox[i+2] - screenBox[i]) / (dataBox[i+2] - dataBox[i]) - - if(i === 0) { - line.drawLine( - zeroIntercept, screenBox[1], zeroIntercept, screenBox[3], - zeroLineWidth[i], - zeroLineColor[i]) - } else { - line.drawLine( - screenBox[0], zeroIntercept, screenBox[2], zeroIntercept, - zeroLineWidth[i], - zeroLineColor[i]) - } - } - } - - //Draw traces - for(var i=0; i=0; --i) { - this.objects[i].dispose() - } - this.objects.length = 0 - for(var i=this.overlays.length-1; i>=0; --i) { - this.overlays[i].dispose() - } - this.overlays.length = 0 - - this.gl = null -} - -proto.addObject = function(object) { - if(this.objects.indexOf(object) < 0) { - this.objects.push(object) - this.setDirty() - } -} - -proto.removeObject = function(object) { - var objects = this.objects - for(var i=0; i 0) { - var base = Math.round(Math.pow(10, y)) - return Math.ceil(x/base) * base - } - return Math.ceil(x) -} - -function defaultBool(x) { - if(typeof x === 'boolean') { - return x - } - return true -} - -function createScene(options) { - options = options || {} - - var stopped = false - - var pixelRatio = options.pixelRatio || parseFloat(window.devicePixelRatio) - - var canvas = options.canvas - if(!canvas) { - canvas = document.createElement('canvas') - if(options.container) { - var container = options.container - container.appendChild(canvas) - } else { - document.body.appendChild(canvas) - } - } - - var gl = options.gl - if(!gl) { - gl = getContext(canvas, - options.glOptions || { - premultipliedAlpha: true, - antialias: true, - preserveDrawingBuffer: isMobile - }) - } - if(!gl) { - throw new Error('webgl not supported') - } - - //Initial bounds - var bounds = options.bounds || [[-10,-10,-10], [10,10,10]] - - //Create selection - var selection = new MouseSelect() - - //Accumulation buffer - var accumBuffer = createFBO(gl, - [gl.drawingBufferWidth, gl.drawingBufferHeight], { - preferFloat: !isMobile - }) - - var accumShader = createShader(gl) - - //Create a camera - var cameraOptions = options.camera || { - eye: [2,0,0], - center: [0,0,0], - up: [0,1,0], - zoomMin: 0.1, - zoomMax: 100, - mode: 'turntable' - } - - //Create axes - var axesOptions = options.axes || {} - var axes = createAxes(gl, axesOptions) - axes.enable = !axesOptions.disable - - //Create spikes - var spikeOptions = options.spikes || {} - var spikes = createSpikes(gl, spikeOptions) - - //Object list is empty initially - var objects = [] - var pickBufferIds = [] - var pickBufferCount = [] - var pickBuffers = [] - - //Dirty flag, skip redraw if scene static - var dirty = true - var pickDirty = true - - var projection = new Array(16) - var model = new Array(16) - - var cameraParams = { - view: null, - projection: projection, - model: model - } - - var pickDirty = true - - var viewShape = [ gl.drawingBufferWidth, gl.drawingBufferHeight ] - - //Create scene object - var scene = { - gl: gl, - contextLost: false, - pixelRatio: options.pixelRatio || parseFloat(window.devicePixelRatio), - canvas: canvas, - selection: selection, - camera: createCamera(canvas, cameraOptions), - axes: axes, - axesPixels: null, - spikes: spikes, - bounds: bounds, - objects: objects, - shape: viewShape, - aspect: options.aspectRatio || [1,1,1], - pickRadius: options.pickRadius || 10, - zNear: options.zNear || 0.01, - zFar: options.zFar || 1000, - fovy: options.fovy || Math.PI/4, - clearColor: options.clearColor || [0,0,0,0], - autoResize: defaultBool(options.autoResize), - autoBounds: defaultBool(options.autoBounds), - autoScale: !!options.autoScale, - autoCenter: defaultBool(options.autoCenter), - clipToBounds: defaultBool(options.clipToBounds), - snapToData: !!options.snapToData, - onselect: options.onselect || null, - onrender: options.onrender || null, - onclick: options.onclick || null, - cameraParams: cameraParams, - oncontextloss: null, - mouseListener: null - } - - var pickShape = [ (gl.drawingBufferWidth/scene.pixelRatio)|0, (gl.drawingBufferHeight/scene.pixelRatio)|0 ] - - function resizeListener() { - if(stopped) { - return - } - if(!scene.autoResize) { - return - } - var parent = canvas.parentNode - var width = 1 - var height = 1 - if(parent && parent !== document.body) { - width = parent.clientWidth - height = parent.clientHeight - } else { - width = window.innerWidth - height = window.innerHeight - } - var nextWidth = Math.ceil(width * scene.pixelRatio)|0 - var nextHeight = Math.ceil(height * scene.pixelRatio)|0 - if(nextWidth !== canvas.width || nextHeight !== canvas.height) { - canvas.width = nextWidth - canvas.height = nextHeight - var style = canvas.style - style.position = style.position || 'absolute' - style.left = '0px' - style.top = '0px' - style.width = width + 'px' - style.height = height + 'px' - dirty = true - } - } - if(scene.autoResize) { - resizeListener() - } - window.addEventListener('resize', resizeListener) - - function reallocPickIds() { - var numObjs = objects.length - var numPick = pickBuffers.length - for(var i=0; i 0 && pickBufferCount[numPick-1] === 0) { - pickBufferCount.pop() - pickBuffers.pop().dispose() - } - } - - scene.update = function(options) { - if(stopped) { - return - } - options = options || {} - dirty = true - pickDirty = true - } - - scene.add = function(obj) { - if(stopped) { - return - } - obj.axes = axes - objects.push(obj) - pickBufferIds.push(-1) - dirty = true - pickDirty = true - reallocPickIds() - } - - scene.remove = function(obj) { - if(stopped) { - return - } - var idx = objects.indexOf(obj) - if(idx < 0) { - return - } - objects.splice(idx, 1) - pickBufferIds.pop() - dirty = true - pickDirty = true - reallocPickIds() - } - - scene.dispose = function() { - if(stopped) { - return - } - - stopped = true - - window.removeEventListener('resize', resizeListener) - canvas.removeEventListener('webglcontextlost', checkContextLoss) - scene.mouseListener.enabled = false - - if(scene.contextLost) { - return - } - - //Destroy objects - axes.dispose() - spikes.dispose() - for(var i=0; i selection.distance) { - continue - } - for(var j=0; j 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]) -exports.pickVertex = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]) -exports.pickFragment = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"]) +exports.boxVertex = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n"]) +exports.boxFragment = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"]) -},{"glslify":392}],279:[function(_dereq_,module,exports){ +},{"glslify":392}],286:[function(_dereq_,module,exports){ 'use strict' var createShader = _dereq_('gl-shader') var createBuffer = _dereq_('gl-buffer') -var pool = _dereq_('typedarray-pool') +var SHADERS = _dereq_('./lib/shaders') -var SHADERS = _dereq_('./lib/shader') +module.exports = createSelectBox -module.exports = createPointcloud2D +function SelectBox(plot, boxBuffer, boxShader) { + this.plot = plot + this.boxBuffer = boxBuffer + this.boxShader = boxShader -function Pointcloud2D(plot, offsetBuffer, pickBuffer, shader, pickShader) { - this.plot = plot - this.offsetBuffer = offsetBuffer - this.pickBuffer = pickBuffer - this.shader = shader - this.pickShader = pickShader - this.sizeMin = 0.5 - this.sizeMinCap = 2 - this.sizeMax = 20 - this.areaRatio = 1.0 - this.pointCount = 0 - this.color = [1, 0, 0, 1] - this.borderColor = [0, 0, 0, 1] - this.blend = false - this.pickOffset = 0 - this.points = null -} + this.enabled = true -var proto = Pointcloud2D.prototype + this.selectBox = [Infinity,Infinity,-Infinity,-Infinity] -proto.dispose = function() { - this.shader.dispose() - this.pickShader.dispose() - this.offsetBuffer.dispose() - this.pickBuffer.dispose() - this.plot.removeObject(this) + this.borderColor = [0,0,0,1] + this.innerFill = false + this.innerColor = [0,0,0,0.25] + this.outerFill = true + this.outerColor = [0,0,0,0.5] + this.borderWidth = 10 } -proto.update = function(options) { - - var i - - options = options || {} +var proto = SelectBox.prototype - function dflt(opt, value) { - if(opt in options) { - return options[opt] - } - return value +proto.draw = function() { + if(!this.enabled) { + return } - this.sizeMin = dflt('sizeMin', 0.5) - // this.sizeMinCap = dflt('sizeMinCap', 2) - this.sizeMax = dflt('sizeMax', 20) - this.color = dflt('color', [1, 0, 0, 1]).slice() - this.areaRatio = dflt('areaRatio', 1) - this.borderColor = dflt('borderColor', [0, 0, 0, 1]).slice() - this.blend = dflt('blend', false) + var plot = this.plot + var selectBox = this.selectBox + var lineWidth = this.borderWidth - //Update point data + var innerFill = this.innerFill + var innerColor = this.innerColor + var outerFill = this.outerFill + var outerColor = this.outerColor + var borderColor = this.borderColor - // Attempt straight-through processing (STP) to avoid allocation and copy - // TODO eventually abstract out STP logic, maybe into `pool` or a layer above - var pointCount = options.positions.length >>> 1 - var dataStraightThrough = options.positions instanceof Float32Array - var idStraightThrough = options.idToIndex instanceof Int32Array && options.idToIndex.length >= pointCount // permit larger to help reuse + var boxes = plot.box + var screenBox = plot.screenBox + var dataBox = plot.dataBox + var viewBox = plot.viewBox + var pixelRatio = plot.pixelRatio - var data = options.positions - var packed = dataStraightThrough ? data : pool.mallocFloat32(data.length) - var packedId = idStraightThrough ? options.idToIndex : pool.mallocInt32(pointCount) + //Map select box into pixel coordinates + var loX = (selectBox[0]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] + var loY = (selectBox[1]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] + var hiX = (selectBox[2]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] + var hiY = (selectBox[3]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] - if(!dataStraightThrough) { - packed.set(data) - } + loX = Math.max(loX, viewBox[0]) + loY = Math.max(loY, viewBox[1]) + hiX = Math.min(hiX, viewBox[2]) + hiY = Math.min(hiY, viewBox[3]) - if(!idStraightThrough) { - packed.set(data) - for(i = 0; i < pointCount; i++) { - packedId[i] = i - } + if(hiX < loX || hiY < loY) { + return } - this.points = data + boxes.bind() - this.offsetBuffer.update(packed) - this.pickBuffer.update(packedId) + //Draw box + var screenWidth = screenBox[2] - screenBox[0] + var screenHeight = screenBox[3] - screenBox[1] - if(!dataStraightThrough) { - pool.free(packed) + if(this.outerFill) { + boxes.drawBox(0, 0, screenWidth, loY, outerColor) + boxes.drawBox(0, loY, loX, hiY, outerColor) + boxes.drawBox(0, hiY, screenWidth, screenHeight, outerColor) + boxes.drawBox(hiX, loY, screenWidth, hiY, outerColor) } - if(!idStraightThrough) { - pool.free(packedId) + if(this.innerFill) { + boxes.drawBox(loX, loY, hiX, hiY, innerColor) } - this.pointCount = pointCount - this.pickOffset = 0 -} + //Draw border + if(lineWidth > 0) { -function count(points, dataBox) { - var visiblePointCountEstimate = 0 - var length = points.length >>> 1 - var i - for(i = 0; i < length; i++) { - var x = points[i * 2] - var y = points[i * 2 + 1] - if(x >= dataBox[0] && x <= dataBox[2] && y >= dataBox[1] && y <= dataBox[3]) - visiblePointCountEstimate++ + //Draw border + var w = lineWidth * pixelRatio + boxes.drawBox(loX-w, loY-w, hiX+w, loY+w, borderColor) + boxes.drawBox(loX-w, hiY-w, hiX+w, hiY+w, borderColor) + boxes.drawBox(loX-w, loY-w, loX+w, hiY+w, borderColor) + boxes.drawBox(hiX-w, loY-w, hiX+w, hiY+w, borderColor) } - return visiblePointCountEstimate } -proto.unifiedDraw = (function() { - var MATRIX = [1, 0, 0, - 0, 1, 0, - 0, 0, 1] - var PICK_VEC4 = [0, 0, 0, 0] -return function(pickOffset) { - var pick = pickOffset !== void(0) - - var shader = pick ? this.pickShader : this.shader - var gl = this.plot.gl - var dataBox = this.plot.dataBox - - if(this.pointCount === 0) { - return pickOffset - } - - var dataX = dataBox[2] - dataBox[0] - var dataY = dataBox[3] - dataBox[1] - - var visiblePointCountEstimate = count(this.points, dataBox) - var basicPointSize = this.plot.pickPixelRatio * Math.max(Math.min(this.sizeMinCap, this.sizeMin), Math.min(this.sizeMax, this.sizeMax / Math.pow(visiblePointCountEstimate, 0.33333))) - - MATRIX[0] = 2.0 / dataX - MATRIX[4] = 2.0 / dataY - MATRIX[6] = -2.0 * dataBox[0] / dataX - 1.0 - MATRIX[7] = -2.0 * dataBox[1] / dataY - 1.0 - - this.offsetBuffer.bind() - - shader.bind() - shader.attributes.position.pointer() - shader.uniforms.matrix = MATRIX - shader.uniforms.color = this.color - shader.uniforms.borderColor = this.borderColor - shader.uniforms.pointCloud = basicPointSize < 5 - shader.uniforms.pointSize = basicPointSize - shader.uniforms.centerFraction = Math.min(1, Math.max(0, Math.sqrt(1 - this.areaRatio))) - - if(pick) { - - PICK_VEC4[0] = ( pickOffset & 0xff) - PICK_VEC4[1] = ((pickOffset >> 8) & 0xff) - PICK_VEC4[2] = ((pickOffset >> 16) & 0xff) - PICK_VEC4[3] = ((pickOffset >> 24) & 0xff) - - this.pickBuffer.bind() - shader.attributes.pickId.pointer(gl.UNSIGNED_BYTE) - shader.uniforms.pickOffset = PICK_VEC4 - this.pickOffset = pickOffset - } - - // Worth switching these off, but we can't make assumptions about other - // renderers, so let's restore it after each draw - var blend = gl.getParameter(gl.BLEND) - var dither = gl.getParameter(gl.DITHER) - - if(blend && !this.blend) - gl.disable(gl.BLEND) - if(dither) - gl.disable(gl.DITHER) - - gl.drawArrays(gl.POINTS, 0, this.pointCount) - - if(blend && !this.blend) - gl.enable(gl.BLEND) - if(dither) - gl.enable(gl.DITHER) +proto.update = function(options) { + options = options || {} - return pickOffset + this.pointCount + this.innerFill = !!options.innerFill + this.outerFill = !!options.outerFill + this.innerColor = (options.innerColor || [0,0,0,0.5]).slice() + this.outerColor = (options.outerColor || [0,0,0,0.5]).slice() + this.borderColor = (options.borderColor || [0,0,0,1]).slice() + this.borderWidth = options.borderWidth || 0 + this.selectBox = (options.selectBox || this.selectBox).slice() } -})() - -proto.draw = proto.unifiedDraw -proto.drawPick = proto.unifiedDraw -proto.pick = function(x, y, value) { - var pickOffset = this.pickOffset - var pointCount = this.pointCount - if(value < pickOffset || value >= pickOffset + pointCount) { - return null - } - var pointId = value - pickOffset - var points = this.points - return { - object: this, - pointId: pointId, - dataCoord: [points[2 * pointId], points[2 * pointId + 1] ] - } +proto.dispose = function() { + this.boxBuffer.dispose() + this.boxShader.dispose() + this.plot.removeOverlay(this) } -function createPointcloud2D(plot, options) { +function createSelectBox(plot, options) { var gl = plot.gl - var buffer = createBuffer(gl) - var pickBuffer = createBuffer(gl) - var shader = createShader(gl, SHADERS.pointVertex, SHADERS.pointFragment) - var pickShader = createShader(gl, SHADERS.pickVertex, SHADERS.pickFragment) - - var result = new Pointcloud2D(plot, buffer, pickBuffer, shader, pickShader) - result.update(options) - - //Register with plot - plot.addObject(result) - - return result + var buffer = createBuffer(gl, [ + 0, 0, + 0, 1, + 1, 0, + 1, 1 ]) + var shader = createShader(gl, SHADERS.boxVertex, SHADERS.boxFragment) + var selectBox = new SelectBox(plot, buffer, shader) + selectBox.update(options) + plot.addOverlay(selectBox) + return selectBox } -},{"./lib/shader":278,"gl-buffer":230,"gl-shader":288,"typedarray-pool":522}],280:[function(_dereq_,module,exports){ -module.exports = slerp +},{"./lib/shaders":285,"gl-buffer":230,"gl-shader":288}],287:[function(_dereq_,module,exports){ +'use strict' + +module.exports = createSelectBuffer + +var createFBO = _dereq_('gl-fbo') +var pool = _dereq_('typedarray-pool') +var ndarray = _dereq_('ndarray') + +var nextPow2 = _dereq_('bit-twiddle').nextPow2 + +var selectRange = _dereq_('cwise/lib/wrapper')({"args":["array",{"offset":[0,0,1],"array":0},{"offset":[0,0,2],"array":0},{"offset":[0,0,3],"array":0},"scalar","scalar","index"],"pre":{"body":"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}","args":[],"thisVars":["this_closestD2","this_closestX","this_closestY"],"localVars":[]},"body":{"body":"{if(_inline_16_arg0_<255||_inline_16_arg1_<255||_inline_16_arg2_<255||_inline_16_arg3_<255){var _inline_16_l=_inline_16_arg4_-_inline_16_arg6_[0],_inline_16_a=_inline_16_arg5_-_inline_16_arg6_[1],_inline_16_f=_inline_16_l*_inline_16_l+_inline_16_a*_inline_16_a;_inline_16_f this.buffer.length) { + pool.free(this.buffer) + var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) + for(var i=0; i oldAttribCount) { + for(i = oldAttribCount; i < newAttribCount; i++) { + this.gl.enableVertexAttribArray(i) + } + } else if(oldAttribCount > newAttribCount) { + for(i = newAttribCount; i < oldAttribCount; i++) { + this.gl.disableVertexAttribArray(i) + } + } + + this.gl.lastAttribCount = newAttribCount + + this.gl.useProgram(this.program) +} + +proto.dispose = function() { + + // disabling vertex attributes so new shader starts with zero + // and it's also useful if all shaders are disposed but the + // gl context is reused for subsequent replotting + var oldAttribCount = this.gl.lastAttribCount + for (var i = 0; i < oldAttribCount; i++) { + this.gl.disableVertexAttribArray(i) + } + this.gl.lastAttribCount = 0 + + if(this._fref) { + this._fref.dispose() + } + if(this._vref) { + this._vref.dispose() + } + this.attributes = + this.types = + this.vertShader = + this.fragShader = + this.program = + this._relink = + this._fref = + this._vref = null +} + +function compareAttributes(a, b) { + if(a.name < b.name) { + return -1 + } + return 1 +} + +//Update export hook for glslify-live +proto.update = function( + vertSource + , fragSource + , uniforms + , attributes) { + + //If only one object passed, assume glslify style output + if(!fragSource || arguments.length === 1) { + var obj = vertSource + vertSource = obj.vertex + fragSource = obj.fragment + uniforms = obj.uniforms + attributes = obj.attributes + } + + var wrapper = this + var gl = wrapper.gl + + //Compile vertex and fragment shaders + var pvref = wrapper._vref + wrapper._vref = shaderCache.shader(gl, gl.VERTEX_SHADER, vertSource) + if(pvref) { + pvref.dispose() + } + wrapper.vertShader = wrapper._vref.shader + var pfref = this._fref + wrapper._fref = shaderCache.shader(gl, gl.FRAGMENT_SHADER, fragSource) + if(pfref) { + pfref.dispose() + } + wrapper.fragShader = wrapper._fref.shader + + //If uniforms/attributes is not specified, use RT reflection + if(!uniforms || !attributes) { + + //Create initial test program + var testProgram = gl.createProgram() + gl.attachShader(testProgram, wrapper.fragShader) + gl.attachShader(testProgram, wrapper.vertShader) + gl.linkProgram(testProgram) + if(!gl.getProgramParameter(testProgram, gl.LINK_STATUS)) { + var errLog = gl.getProgramInfoLog(testProgram) + throw new GLError(errLog, 'Error linking program:' + errLog) + } + + //Load data from runtime + uniforms = uniforms || runtime.uniforms(gl, testProgram) + attributes = attributes || runtime.attributes(gl, testProgram) + + //Release test program + gl.deleteProgram(testProgram) + } + + //Sort attributes lexicographically + // overrides undefined WebGL behavior for attribute locations + attributes = attributes.slice() + attributes.sort(compareAttributes) + + //Convert attribute types, read out locations + var attributeUnpacked = [] + var attributeNames = [] + var attributeLocations = [] + var i + for(i=0; i= 0) { + var size = attr.type.charAt(attr.type.length-1)|0 + var locVector = new Array(size) + for(var j=0; j= 0) { + curLocation += 1 + } + attributeLocations[i] = curLocation + } + } + + //Rebuild program and recompute all uniform locations + var uniformLocations = new Array(uniforms.length) + function relink() { + wrapper.program = shaderCache.program( + gl + , wrapper._vref + , wrapper._fref + , attributeNames + , attributeLocations) -/** - * Performs a spherical linear interpolation between two quat - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @param {Number} t interpolation amount between the two inputs - * @returns {quat} out - */ -function slerp (out, a, b, t) { - // benchmarks: - // http://jsperf.com/quaternion-slerp-implementations + for(var i=0; i 0.000001) { - // standard case (slerp) - omega = Math.acos(cosom) - sinom = Math.sin(omega) - scale0 = Math.sin((1.0 - t) * omega) / sinom - scale1 = Math.sin(t * omega) / sinom - } else { - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - scale0 = 1.0 - t - scale1 = t + //Generate type info + wrapper.types = { + uniforms: makeReflect(uniforms), + attributes: makeReflect(attributes) } - // calculate final values - out[0] = scale0 * ax + scale1 * bx - out[1] = scale0 * ay + scale1 * by - out[2] = scale0 * az + scale1 * bz - out[3] = scale0 * aw + scale1 * bw - return out + //Generate attribute wrappers + wrapper.attributes = createAttributeWrapper( + gl + , wrapper + , attributeUnpacked + , attributeLocations) + + //Generate uniform wrappers + Object.defineProperty(wrapper, 'uniforms', createUniformWrapper( + gl + , wrapper + , uniforms + , uniformLocations)) } -},{}],281:[function(_dereq_,module,exports){ -'use strict'; +//Compiles and links a shader program with the given attribute and vertex list +function createShader( + gl + , vertSource + , fragSource + , uniforms + , attributes) { -module.exports = function(a){ - return (!a && a !== 0) ? '' : a.toString(); + var shader = new Shader(gl) + + shader.update( + vertSource + , fragSource + , uniforms + , attributes) + + return shader } -},{}],282:[function(_dereq_,module,exports){ -"use strict" +module.exports = createShader -var vectorizeText = _dereq_("vectorize-text") +},{"./lib/GLError":289,"./lib/create-attributes":290,"./lib/create-uniforms":291,"./lib/reflect":292,"./lib/runtime-reflect":293,"./lib/shader-cache":294}],289:[function(_dereq_,module,exports){ +function GLError (rawError, shortMessage, longMessage) { + this.shortMessage = shortMessage || '' + this.longMessage = longMessage || '' + this.rawError = rawError || '' + this.message = + 'gl-shader: ' + (shortMessage || rawError || '') + + (longMessage ? '\n'+longMessage : '') + this.stack = (new Error()).stack +} +GLError.prototype = new Error +GLError.prototype.name = 'GLError' +GLError.prototype.constructor = GLError +module.exports = GLError -module.exports = getGlyph +},{}],290:[function(_dereq_,module,exports){ +'use strict' -var GLYPH_CACHE = {} +module.exports = createAttributeWrapper -function getGlyph(symbol, font) { - var fontCache = GLYPH_CACHE[font] - if(!fontCache) { - fontCache = GLYPH_CACHE[font] = {} +var GLError = _dereq_("./GLError") + +function ShaderAttribute( + gl + , wrapper + , index + , locations + , dimension + , constFunc) { + this._gl = gl + this._wrapper = wrapper + this._index = index + this._locations = locations + this._dimension = dimension + this._constFunc = constFunc +} + +var proto = ShaderAttribute.prototype + +proto.pointer = function setAttribPointer( + type + , normalized + , stride + , offset) { + + var self = this + var gl = self._gl + var location = self._locations[self._index] + + gl.vertexAttribPointer( + location + , self._dimension + , type || gl.FLOAT + , !!normalized + , stride || 0 + , offset || 0) + gl.enableVertexAttribArray(location) +} + +proto.set = function(x0, x1, x2, x3) { + return this._constFunc(this._locations[this._index], x0, x1, x2, x3) +} + +Object.defineProperty(proto, 'location', { + get: function() { + return this._locations[this._index] } - if(symbol in fontCache) { - return fontCache[symbol] + , set: function(v) { + if(v !== this._locations[this._index]) { + this._locations[this._index] = v|0 + this._wrapper.program = null + } + return v|0 } +}) - //Get line and triangle meshes for glyph - var lineSymbol = vectorizeText(symbol, { - textAlign: "center", - textBaseline: "middle", - lineHeight: 1.0, - font: font - }) - var triSymbol = vectorizeText(symbol, { - triangles: true, - textAlign: "center", - textBaseline: "middle", - lineHeight: 1.0, - font: font - }) +//Adds a vector attribute to obj +function addVectorAttribute( + gl + , wrapper + , index + , locations + , dimension + , obj + , name) { - //Calculate bounding box - var bounds = [[Infinity,Infinity], [-Infinity,-Infinity]] - for(var i=0; i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) -var orthographicVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]) -var projectionVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]) -var drawFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]) +//Create shims for attributes +function createAttributeWrapper( + gl + , wrapper + , attributes + , locations) { -var ATTRIBUTES = [ - {name: 'position', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'glyph', type: 'vec2'}, - {name: 'id', type: 'vec4'} -] + var obj = {} + for(var i=0, n=attributes.length; i= 0) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) + } + addVectorAttribute( + gl + , wrapper + , locs[0] + , locations + , d + , obj + , name) + } else if(type.indexOf('mat') >= 0) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) + } + addMatrixAttribute( + gl + , wrapper + , locs + , locations + , d + , obj + , name) + } else { + throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) + } + break + } } + return obj +} -function createShader(gl, src) { - var shader = createShaderWrapper(gl, src) - var attr = shader.attributes - attr.position.location = 0 - attr.color.location = 1 - attr.glyph.location = 2 - attr.id.location = 3 - return shader +},{"./GLError":289}],291:[function(_dereq_,module,exports){ +'use strict' + +var coallesceUniforms = _dereq_('./reflect') +var GLError = _dereq_("./GLError") + +module.exports = createUniformWrapper + +//Binds a function and returns a value +function identity(x) { + var c = new Function('y', 'return function(){return y}') + return c(x) } -exports.createPerspective = function(gl) { - return createShader(gl, perspective) +function makeVector(length, fill) { + var result = new Array(length) + for(var i=0; i 4) { + throw new GLError('', 'Invalid data type') + } + switch(type.charAt(0)) { + case 'b': + case 'i': + return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' + case 'v': + return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' + default: + throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) + } + } else if(type.indexOf('mat') === 0 && type.length === 4) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) + } + return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' + } else { + throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) + } + break + } + } + + function enumerateIndices(prefix, type) { + if(typeof type !== 'object') { + return [ [prefix, type] ] + } + var indices = [] + for(var id in type) { + var prop = type[id] + var tprefix = prefix + if(parseInt(id) + '' === id) { + tprefix += '[' + id + ']' + } else { + tprefix += '.' + id + } + if(typeof prop === 'object') { + indices.push.apply(indices, enumerateIndices(tprefix, prop)) + } else { + indices.push([tprefix, prop]) + } + } + return indices + } + + function makeSetter(type) { + var code = [ 'return function updateProperty(obj){' ] + var indices = enumerateIndices('', type) + for(var i=0; i 4) { + throw new GLError('', 'Invalid data type') + } + if(type.charAt(0) === 'b') { + return makeVector(d, false) + } + return makeVector(d, 0) + } else if(type.indexOf('mat') === 0 && type.length === 4) { + var d = type.charCodeAt(type.length-1) - 48 + if(d < 2 || d > 4) { + throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) + } + return makeVector(d*d, 0) + } else { + throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) + } + break + } + } + + function storeProperty(obj, prop, type) { + if(typeof type === 'object') { + var child = processObject(type) + Object.defineProperty(obj, prop, { + get: identity(child), + set: makeSetter(type), + enumerable: true, + configurable: false + }) + } else { + if(locations[type]) { + Object.defineProperty(obj, prop, { + get: makeGetter(type), + set: makeSetter(type), + enumerable: true, + configurable: false + }) + } else { + obj[prop] = defaultValue(uniforms[type].type) + } + } + } + + function processObject(obj) { + var result + if(Array.isArray(obj)) { + result = new Array(obj.length) + for(var i=0; i 1) { + if(!(x[0] in o)) { + o[x[0]] = [] + } + o = o[x[0]] + for(var k=1; k 1) { + for(var j=0; j= 1) { - return true - } - for(var i=0; i<3; ++i) { - if(this.axesProject[i] && this.projectOpacity[i] >= 1) { - return true - } - } return false } -var VIEW_SHAPE = [0,0] -var U_VEC = [0,0,0] -var V_VEC = [0,0,0] -var MU_VEC = [0,0,0,1] -var MV_VEC = [0,0,0,1] -var SCRATCH_MATRIX = IDENTITY.slice() -var SCRATCH_VEC = [0,0,0] -var CLIP_BOUNDS = [[0,0,0], [0,0,0]] +proto.drawTransparent = function(camera) {} -function zeroVec(a) { - a[0] = a[1] = a[2] = 0 - return a -} +proto.draw = function(camera) { + var gl = this.gl + var vao = this.vao + var shader = this.shader -function augment(hg, af) { - hg[0] = af[0] - hg[1] = af[1] - hg[2] = af[2] - hg[3] = 1 - return hg -} + vao.bind() + shader.bind() -function setComponent(out, v, i, x) { - out[0] = v[0] - out[1] = v[1] - out[2] = v[2] - out[i] = x - return out -} + var model = camera.model || identity + var view = camera.view || identity + var projection = camera.projection || identity -function getClipBounds(bounds) { - var result = CLIP_BOUNDS - for(var i=0; i<2; ++i) { - for(var j=0; j<3; ++j) { - result[i][j] = Math.max(Math.min(bounds[i][j], 1e8), -1e8) - } + var axis + if(this.axes) { + axis = this.axes.lastCubeProps.axis } - return result -} - -function drawProject(shader, points, camera, transparent, forceDraw) { - var axesProject = points.axesProject - - var gl = points.gl - var uniforms = shader.uniforms - var model = camera.model || IDENTITY - var view = camera.view || IDENTITY - var projection = camera.projection || IDENTITY - var bounds = points.axesBounds - var clipBounds = getClipBounds(points.clipBounds) - var cubeAxis - if(points.axes && points.axes.lastCubeProps) { - cubeAxis = points.axes.lastCubeProps.axis - } else { - cubeAxis = [1,1,1] + var outerFace = OUTER_FACE + var innerFace = INNER_FACE + for(var i=0; i<3; ++i) { + if(axis && axis[i] < 0) { + outerFace[i] = this.bounds[0][i] + innerFace[i] = this.bounds[1][i] + } else { + outerFace[i] = this.bounds[1][i] + innerFace[i] = this.bounds[0][i] + } } - VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth - VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight + SHAPE[0] = gl.drawingBufferWidth + SHAPE[1] = gl.drawingBufferHeight - shader.bind() - uniforms.view = view - uniforms.projection = projection - uniforms.screenSize = VIEW_SHAPE - uniforms.highlightId = points.highlightId - uniforms.highlightScale = points.highlightScale - uniforms.clipBounds = clipBounds - uniforms.pickGroup = points.pickId / 255.0 - uniforms.pixelRatio = points.pixelRatio + shader.uniforms.model = model + shader.uniforms.view = view + shader.uniforms.projection = projection + shader.uniforms.coordinates = [this.position, outerFace, innerFace] + shader.uniforms.colors = this.colors + shader.uniforms.screenShape = SHAPE for(var i=0; i<3; ++i) { - if(!axesProject[i]) { - continue - } - if((points.projectOpacity[i] < 1) !== transparent) { - continue + shader.uniforms.lineWidth = this.lineWidth[i] * this.pixelRatio + if(this.enabled[i]) { + vao.draw(gl.TRIANGLES, 6, 6*i) + if(this.drawSides[i]) { + vao.draw(gl.TRIANGLES, 12, 18+12*i) + } } + } - uniforms.scale = points.projectScale[i] - uniforms.opacity = points.projectOpacity[i] + vao.unbind() +} - //Project model matrix - var pmodel = SCRATCH_MATRIX - for(var j=0; j<16; ++j) { - pmodel[j] = 0 - } - for(var j=0; j<4; ++j) { - pmodel[5*j] = 1 - } - pmodel[5*i] = 0 - if(cubeAxis[i] < 0) { - pmodel[12+i] = bounds[0][i] - } else { - pmodel[12+i] = bounds[1][i] - } - mat4mult(pmodel, model, pmodel) - uniforms.model = pmodel +proto.update = function(options) { + if(!options) { + return + } + if("bounds" in options) { + this.bounds = options.bounds + } + if("position" in options) { + this.position = options.position + } + if("lineWidth" in options) { + this.lineWidth = options.lineWidth + } + if("colors" in options) { + this.colors = options.colors + } + if("enabled" in options) { + this.enabled = options.enabled + } + if("drawSides" in options) { + this.drawSides = options.drawSides + } +} - //Compute initial axes - var u = (i+1)%3 - var v = (i+2)%3 - var du = zeroVec(U_VEC) - var dv = zeroVec(V_VEC) - du[u] = 1 - dv[v] = 1 +proto.dispose = function() { + this.vao.dispose() + this.buffer.dispose() + this.shader.dispose() +} - //Align orientation relative to viewer - var mdu = project(projection, view, model, augment(MU_VEC, du)) - var mdv = project(projection, view, model, augment(MV_VEC, dv)) - if(Math.abs(mdu[1]) > Math.abs(mdv[1])) { - var tmp = mdu - mdu = mdv - mdv = tmp - tmp = du - du = dv - dv = tmp - var t = u - u = v - v = t - } - if(mdu[0] < 0) { - du[u] = -1 - } - if(mdv[1] > 0) { - dv[v] = -1 - } - var su = 0.0 - var sv = 0.0 - for(var j=0; j<4; ++j) { - su += Math.pow(model[4*u+j], 2) - sv += Math.pow(model[4*v+j], 2) - } - du[u] /= Math.sqrt(su) - dv[v] /= Math.sqrt(sv) - uniforms.axes[0] = du - uniforms.axes[1] = dv - //Update fragment clip bounds - uniforms.fragClipBounds[0] = setComponent(SCRATCH_VEC, clipBounds[0], i, -1e8) - uniforms.fragClipBounds[1] = setComponent(SCRATCH_VEC, clipBounds[1], i, 1e8) - //Draw interior - points.vao.draw(gl.TRIANGLES, points.vertexCount) +function createSpikes(gl, options) { + //Create buffers + var data = [ ] - //Draw edges - if(points.lineWidth > 0) { - gl.lineWidth(points.lineWidth) - points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) - } + function line(x,y,z,i,l,h) { + var row = [x,y,z, 0,0,0, 1] + row[i+3] = 1 + row[i] = l + data.push.apply(data, row) + row[6] = -1 + data.push.apply(data, row) + row[i] = h + data.push.apply(data, row) + data.push.apply(data, row) + row[6] = 1 + data.push.apply(data, row) + row[i] = l + data.push.apply(data, row) } -} - -var NEG_INFINITY3 = [-1e8, -1e8, -1e8] -var POS_INFINITY3 = [1e8, 1e8, 1e8] -var CLIP_GROUP = [NEG_INFINITY3, POS_INFINITY3] + line(0,0,0, 0, 0, 1) + line(0,0,0, 1, 0, 1) + line(0,0,0, 2, 0, 1) -function drawFull(shader, pshader, points, camera, transparent, forceDraw) { - var gl = points.gl + line(1,0,0, 1, -1,1) + line(1,0,0, 2, -1,1) - points.vao.bind() + line(0,1,0, 0, -1,1) + line(0,1,0, 2, -1,1) - if(transparent === (points.opacity < 1) || forceDraw) { - shader.bind() - var uniforms = shader.uniforms + line(0,0,1, 0, -1,1) + line(0,0,1, 1, -1,1) - uniforms.model = camera.model || IDENTITY - uniforms.view = camera.view || IDENTITY - uniforms.projection = camera.projection || IDENTITY + var buffer = createBuffer(gl, data) + var vao = createVAO(gl, [{ + type: gl.FLOAT, + buffer: buffer, + size: 3, + offset: 0, + stride: 28 + }, { + type: gl.FLOAT, + buffer: buffer, + size: 3, + offset: 12, + stride: 28 + }, { + type: gl.FLOAT, + buffer: buffer, + size: 1, + offset: 24, + stride: 28 + }]) + + //Create shader + var shader = createShader(gl) + shader.attributes.position.location = 0 + shader.attributes.color.location = 1 + shader.attributes.weight.location = 2 - VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth - VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight - uniforms.screenSize = VIEW_SHAPE + //Create spike object + var spikes = new AxisSpikes(gl, buffer, vao, shader) - uniforms.highlightId = points.highlightId - uniforms.highlightScale = points.highlightScale + //Set parameters + spikes.update(options) - uniforms.fragClipBounds = CLIP_GROUP - uniforms.clipBounds = points.axes.bounds + //Return resulting object + return spikes +} - uniforms.opacity = points.opacity - uniforms.pickGroup = points.pickId / 255.0 +},{"./shaders/index":296,"gl-buffer":230,"gl-vao":310}],298:[function(_dereq_,module,exports){ +arguments[4][232][0].apply(exports,arguments) +},{"barycentric":61,"dup":232,"polytope-closest-point/lib/closest_point_2d.js":464}],299:[function(_dereq_,module,exports){ +var glslify = _dereq_('glslify') - uniforms.pixelRatio = points.pixelRatio +var triVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]) +var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) +var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) +var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) + +exports.meshShader = { + vertex: triVertSrc, + fragment: triFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'normal', type: 'vec3'}, + {name: 'color', type: 'vec4'}, + {name: 'uv', type: 'vec2'}, + {name: 'vector', type: 'vec4'} + ] +} +exports.pickShader = { + vertex: pickVertSrc, + fragment: pickFragSrc, + attributes: [ + {name: 'position', type: 'vec4'}, + {name: 'id', type: 'vec4'}, + {name: 'vector', type: 'vec4'} + ] +} - //Draw interior - points.vao.draw(gl.TRIANGLES, points.vertexCount) +},{"glslify":392}],300:[function(_dereq_,module,exports){ +'use strict' - //Draw edges - if(points.lineWidth > 0) { - gl.lineWidth(points.lineWidth) - points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) - } - } +var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small +var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - drawProject(pshader, points, camera, transparent, forceDraw) +var createShader = _dereq_('gl-shader') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var normals = _dereq_('normals') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var ndarray = _dereq_('ndarray') +var colormap = _dereq_('colormap') +var getContour = _dereq_('simplicial-complex-contour') +var pool = _dereq_('typedarray-pool') +var shaders = _dereq_('./shaders') +var closestPoint = _dereq_('./closest-point') + +var meshShader = shaders.meshShader +var pickShader = shaders.pickShader + +var identityMatrix = [ + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1] + +function SimplicialMesh(gl + , texture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) { + + this.gl = gl + this.cells = [] + this.positions = [] + this.intensity = [] + this.texture = texture + this.dirty = true + + this.triShader = triShader + this.lineShader = lineShader + this.pointShader = pointShader + this.pickShader = pickShader + this.pointPickShader = pointPickShader + this.contourShader = contourShader + + this.trianglePositions = trianglePositions + this.triangleVectors = triangleVectors + this.triangleColors = triangleColors + this.triangleNormals = triangleNormals + this.triangleUVs = triangleUVs + this.triangleIds = triangleIds + this.triangleVAO = triangleVAO + this.triangleCount = 0 + + this.lineWidth = 1 + this.edgePositions = edgePositions + this.edgeColors = edgeColors + this.edgeUVs = edgeUVs + this.edgeIds = edgeIds + this.edgeVAO = edgeVAO + this.edgeCount = 0 + + this.pointPositions = pointPositions + this.pointColors = pointColors + this.pointUVs = pointUVs + this.pointSizes = pointSizes + this.pointIds = pointIds + this.pointVAO = pointVAO + this.pointCount = 0 + + this.contourLineWidth = 1 + this.contourPositions = contourPositions + this.contourVAO = contourVAO + this.contourCount = 0 + this.contourColor = [0,0,0] + this.contourEnable = false + + this.pickId = 1 + this.bounds = [ + [ Infinity, Infinity, Infinity], + [-Infinity,-Infinity,-Infinity] ] + this.clipBounds = [ + [-Infinity,-Infinity,-Infinity], + [ Infinity, Infinity, Infinity] ] + + this.lightPosition = [1e5, 1e5, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + + this.opacity = 1.0 + + this.tubeScale = 1.0 + + this._model = identityMatrix + this._view = identityMatrix + this._projection = identityMatrix + this._resolution = [1,1] +} + +var proto = SimplicialMesh.prototype - points.vao.unbind() +proto.isOpaque = function() { + return this.opacity >= 1 } -proto.draw = function(camera) { - var shader = this.useOrtho ? this.orthoShader : this.shader - drawFull(shader, this.projectShader, this, camera, false, false) +proto.isTransparent = function() { + return this.opacity < 1 } -proto.drawTransparent = function(camera) { - var shader = this.useOrtho ? this.orthoShader : this.shader - drawFull(shader, this.projectShader, this, camera, true, false) -} +proto.pickSlots = 1 -proto.drawPick = function(camera) { - var shader = this.useOrtho ? this.pickOrthoShader : this.pickPerspectiveShader - drawFull(shader, this.pickProjectShader, this, camera, false, true) +proto.setPickBase = function(id) { + this.pickId = id } -proto.pick = function(selected) { - if(!selected) { - return null +function genColormap(param) { + var colors = colormap({ + colormap: param + , nshades: 256 + , format: 'rgba' + }) + + var result = new Uint8Array(256*4) + for(var i=0; i<256; ++i) { + var c = colors[i] + for(var j=0; j<3; ++j) { + result[4*i+j] = c[j] + } + result[4*i+3] = c[3]*255 } - if(selected.id !== this.pickId) { - return null + + return ndarray(result, [256,256,4], [4,0,1]) +} + +function unpackIntensity(cells, numVerts, cellIntensity) { + var result = new Array(numVerts) + for(var i=0; i= this.pointCount || x < 0) { - return null + var numCells = cells.length + for(var i=0; i>8) &0xff - var a2 = (pointId>>16)&0xff - this.highlightId = [a0/255.0, a1/255.0, a2/255.0, 0] + if(!selection || !this.contourEnable) { + this.contourCount = 0 + return } -} - -function get_glyphData(glyphs, index, font) { - var str - - // use the data if presented in an array - if(Array.isArray(glyphs)) { - if(index < glyphs.length) { - str = glyphs[index] - } else { - str = undefined + var level = getContour(this.cells, this.intensity, selection.intensity) + var cells = level.cells + var vertexIds = level.vertexIds + var vertexWeights = level.vertexWeights + var numCells = cells.length + var result = pool.mallocFloat32(2 * 3 * numCells) + var ptr = 0 + for(var i=0; i 0) { - var triOffset = 0 - var lineOffset = triVertexCount - var color = [0,0,0,1] - var lineColor = [0,0,0,1] + pIds.push(i) - var isColorArray = Array.isArray(colors) && Array.isArray(colors[0]) - var isLineColorArray = Array.isArray(lineColors) && Array.isArray(lineColors[0]) + pointCount += 1 + break - fill_loop: - for(var i=0; i 0) { - textOffset[j] *= (1-glyphBounds[0][j]) - } else if(alignment[j] < 0) { - textOffset[j] *= (1+glyphBounds[1][j]) - } - } + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } - //Write out inner marker - var cells = glyphMesh.cells || [] - var verts = glyphMesh.positions || [] + var uniforms = { + model: model, + view: view, + projection: projection, - for(var j=0; j 0) { + var shader = this.triShader + shader.bind() + shader.uniforms = uniforms + + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + if(this.edgeCount > 0 && this.lineWidth > 0) { + var shader = this.lineShader + shader.bind() + shader.uniforms = uniforms + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() } - //Update bounds - this.bounds = [lowerBound, upperBound] + if(this.pointCount > 0) { + var shader = this.pointShader + shader.bind() + shader.uniforms = uniforms - //Save points - this.points = points + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } - //Save number of points - this.pointCount = points.length + if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { + var shader = this.contourShader + shader.bind() + shader.uniforms = uniforms - //Update vertex counts - this.vertexCount = triVertexCount - this.lineVertexCount = lineVertexCount + this.contourVAO.bind() + gl.drawArrays(gl.LINES, 0, this.contourCount) + this.contourVAO.unbind() + } +} - this.pointBuffer.update(positionArray) - this.colorBuffer.update(colorArray) - this.glyphBuffer.update(glyphArray) - //this.idBuffer.update(new Uint32Array(idArray)) - this.idBuffer.update(idArray) +proto.drawPick = function(params) { + params = params || {} - pool.free(positionArray) - pool.free(colorArray) - pool.free(glyphArray) - pool.free(idArray) + var gl = this.gl + + var model = params.model || identityMatrix + var view = params.view || identityMatrix + var projection = params.projection || identityMatrix + + var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] + for(var i=0; i<3; ++i) { + clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) + clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) + } + + //Save camera parameters + this._model = [].slice.call(model) + this._view = [].slice.call(view) + this._projection = [].slice.call(projection) + this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] + + var uniforms = { + model: model, + view: view, + projection: projection, + clipBounds: clipBounds, + + tubeScale: this.tubeScale, + + pickId: this.pickId / 255.0, + } + + var shader = this.pickShader + shader.bind() + shader.uniforms = uniforms + + if(this.triangleCount > 0) { + this.triangleVAO.bind() + gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) + this.triangleVAO.unbind() + } + + if(this.edgeCount > 0) { + this.edgeVAO.bind() + gl.lineWidth(this.lineWidth) + gl.drawArrays(gl.LINES, 0, this.edgeCount*2) + this.edgeVAO.unbind() + } + + if(this.pointCount > 0) { + var shader = this.pointPickShader + shader.bind() + shader.uniforms = uniforms + + this.pointVAO.bind() + gl.drawArrays(gl.POINTS, 0, this.pointCount) + this.pointVAO.unbind() + } +} + + +proto.pick = function(pickData) { + if(!pickData) { + return null + } + if(pickData.id !== this.pickId) { + return null + } + + var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] + var cell = this.cells[cellId] + + var pos = this.positions[cell[1]].slice(0, 3) + var intensity = this.intensity[cell[1]] + var velocity = this.vectors[cell[1]].slice(0, 3) + var divergence = this.vectors[cell[1]][3] + + return { + index: cellId, + position: pos, + intensity: intensity, + velocity: velocity, + divergence: divergence, + dataCoordinate: pos + } } + proto.dispose = function() { - //Shaders - this.shader.dispose() - this.orthoShader.dispose() - this.pickPerspectiveShader.dispose() - this.pickOrthoShader.dispose() + this.texture.dispose() + + this.triShader.dispose() + // this.lineShader.dispose() + // this.pointShader.dispose() + this.pickShader.dispose() + // this.pointPickShader.dispose() + + this.triangleVAO.dispose() + this.trianglePositions.dispose() + this.triangleVectors.dispose() + this.triangleColors.dispose() + this.triangleUVs.dispose() + this.triangleNormals.dispose() + this.triangleIds.dispose() + + this.edgeVAO.dispose() + this.edgePositions.dispose() + this.edgeColors.dispose() + this.edgeUVs.dispose() + this.edgeIds.dispose() + + this.pointVAO.dispose() + this.pointPositions.dispose() + this.pointColors.dispose() + this.pointUVs.dispose() + this.pointSizes.dispose() + this.pointIds.dispose() + + this.contourVAO.dispose() + this.contourPositions.dispose() + // this.contourShader.dispose() +} + +function createMeshShader(gl) { + var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.vector.location = 5 + return shader +} - //Vertex array - this.vao.dispose() +function createWireShader(gl) { + var shader = createShader(gl, wireShader.vertex, wireShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + return shader +} - //Buffers - this.pointBuffer.dispose() - this.colorBuffer.dispose() - this.glyphBuffer.dispose() - this.idBuffer.dispose() +function createPointShader(gl) { + var shader = createShader(gl, pointShader.vertex, pointShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.color.location = 2 + shader.attributes.uv.location = 3 + shader.attributes.pointSize.location = 4 + return shader } -function createPointCloud(options) { - var gl = options.gl +function createPickShader(gl) { + var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.vector.location = 5 + return shader +} - var shader = shaders.createPerspective(gl) - var orthoShader = shaders.createOrtho(gl) - var projectShader = shaders.createProject(gl) - var pickPerspectiveShader = shaders.createPickPerspective(gl) - var pickOrthoShader = shaders.createPickOrtho(gl) - var pickProjectShader = shaders.createPickProject(gl) +function createPointPickShader(gl) { + var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) + shader.attributes.position.location = 0 + shader.attributes.id.location = 1 + shader.attributes.pointSize.location = 4 + return shader +} - var pointBuffer = createBuffer(gl) - var colorBuffer = createBuffer(gl) - var glyphBuffer = createBuffer(gl) - var idBuffer = createBuffer(gl) - var vao = createVAO(gl, [ - { - buffer: pointBuffer, - size: 3, - type: gl.FLOAT - }, - { - buffer: colorBuffer, +function createContourShader(gl) { + var shader = createShader(gl, contourShader.vertex, contourShader.fragment) + shader.attributes.position.location = 0 + return shader +} + +function createSimplicialMesh(gl, params) { + if (arguments.length === 1) { + params = gl; + gl = params.gl; + } + + var triShader = params.triShader || createMeshShader(gl) + var lineShader = null; //createWireShader(gl) + var pointShader = null; //createPointShader(gl) + var pickShader = createPickShader(gl) + var pointPickShader = null; //createPointPickShader(gl) + var contourShader = null; //createContourShader(gl) + + var meshTexture = createTexture(gl, + ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) + meshTexture.generateMipmap() + meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR + meshTexture.magFilter = gl.LINEAR + + var trianglePositions = createBuffer(gl) + var triangleVectors = createBuffer(gl) + var triangleColors = createBuffer(gl) + var triangleUVs = createBuffer(gl) + var triangleNormals = createBuffer(gl) + var triangleIds = createBuffer(gl) + var triangleVAO = createVAO(gl, [ + { buffer: trianglePositions, + type: gl.FLOAT, + size: 4 + }, + { buffer: triangleIds, + type: gl.UNSIGNED_BYTE, size: 4, - type: gl.FLOAT + normalized: true }, - { - buffer: glyphBuffer, - size: 2, - type: gl.FLOAT + { buffer: triangleColors, + type: gl.FLOAT, + size: 4 }, - { - buffer: idBuffer, + { buffer: triangleUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: triangleNormals, + type: gl.FLOAT, + size: 3 + }, + { buffer: triangleVectors, + type: gl.FLOAT, + size: 4 + } + ]) + + var edgePositions = createBuffer(gl) + var edgeColors = createBuffer(gl) + var edgeUVs = createBuffer(gl) + var edgeIds = createBuffer(gl) + var edgeVAO = createVAO(gl, [ + { buffer: edgePositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: edgeIds, + type: gl.UNSIGNED_BYTE, size: 4, + normalized: true + }, + { buffer: edgeColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: edgeUVs, + type: gl.FLOAT, + size: 2 + } + ]) + + var pointPositions = createBuffer(gl) + var pointColors = createBuffer(gl) + var pointUVs = createBuffer(gl) + var pointSizes = createBuffer(gl) + var pointIds = createBuffer(gl) + var pointVAO = createVAO(gl, [ + { buffer: pointPositions, + type: gl.FLOAT, + size: 3 + }, + { buffer: pointIds, type: gl.UNSIGNED_BYTE, + size: 4, normalized: true + }, + { buffer: pointColors, + type: gl.FLOAT, + size: 4 + }, + { buffer: pointUVs, + type: gl.FLOAT, + size: 2 + }, + { buffer: pointSizes, + type: gl.FLOAT, + size: 1 } ]) - var pointCloud = new PointCloud( - gl, - shader, - orthoShader, - projectShader, - pointBuffer, - colorBuffer, - glyphBuffer, - idBuffer, - vao, - pickPerspectiveShader, - pickOrthoShader, - pickProjectShader) + var contourPositions = createBuffer(gl) + var contourVAO = createVAO(gl, [ + { buffer: contourPositions, + type: gl.FLOAT, + size: 3 + }]) + + var mesh = new SimplicialMesh(gl + , meshTexture + , triShader + , lineShader + , pointShader + , pickShader + , pointPickShader + , contourShader + , trianglePositions + , triangleVectors + , triangleIds + , triangleColors + , triangleUVs + , triangleNormals + , triangleVAO + , edgePositions + , edgeIds + , edgeColors + , edgeUVs + , edgeVAO + , pointPositions + , pointIds + , pointColors + , pointUVs + , pointSizes + , pointVAO + , contourPositions + , contourVAO) + + mesh.update(params) + + return mesh +} + +module.exports = createSimplicialMesh + +},{"./closest-point":298,"./shaders":299,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"normals":436,"simplicial-complex-contour":494,"typedarray-pool":521}],301:[function(_dereq_,module,exports){ +"use strict"; - pointCloud.update(options) +var vec3 = _dereq_('gl-vec3'); +var vec4 = _dereq_('gl-vec4'); + +var streamToTube = function(stream, maxDivergence, minDistance, maxNorm) { + var points = stream.points; + var velocities = stream.velocities; + var divergences = stream.divergences; + + var p, fwd, r, u, v, up; + up = vec3.set(vec3.create(), 0, 1, 0); + u = vec3.create(); + v = vec3.create(); + var p2 = vec3.create(); + + var verts = []; + var faces = []; + var vectors = []; + var previousVerts = []; + var currentVerts = []; + var intensities = []; + var previousIntensity = 0; + var currentIntensity = 0; + var currentVector = vec4.create(); + var previousVector = vec4.create(); + + var facets = 8; + + for (var i = 0; i < points.length; i++) { + p = points[i]; + fwd = velocities[i]; + r = divergences[i]; + if (maxDivergence === 0) { + r = minDistance * 0.05; + } + currentIntensity = vec3.length(fwd) / maxNorm; + currentVector = vec4.create(); + vec3.copy(currentVector, fwd); + currentVector[3] = r; + + for (var a = 0; a < facets; a++) { + currentVerts[a] = [p[0], p[1], p[2], a]; + } + if (previousVerts.length > 0) { + for (var a = 0; a < facets; a++) { + var a1 = (a+1) % facets; + verts.push( + previousVerts[a], + currentVerts[a], + currentVerts[a1], + + currentVerts[a1], + previousVerts[a1], + previousVerts[a] + ); + vectors.push( + previousVector, + currentVector, + currentVector, + + currentVector, + previousVector, + previousVector + ); + intensities.push( + previousIntensity, + currentIntensity, + currentIntensity, + + currentIntensity, + previousIntensity, + previousIntensity + ); + faces.push( + [verts.length-6, verts.length-5, verts.length-4], + [verts.length-3, verts.length-2, verts.length-1] + ); + } + } + var tmp = previousVerts; + previousVerts = currentVerts; + currentVerts = tmp; + tmp = previousVector; + previousVector = currentVector; + currentVector = tmp; + tmp = previousIntensity; + previousIntensity = currentIntensity; + currentIntensity = tmp; + } + return { + positions: verts, + cells: faces, + vectors: vectors, + vertexIntensity: intensities + }; - return pointCloud -} +}; -},{"./lib/get-simple-string":281,"./lib/glyphs":282,"./lib/shaders":283,"gl-buffer":230,"gl-mat4/multiply":256,"gl-vao":310,"is-string-blank":406,"typedarray-pool":522}],285:[function(_dereq_,module,exports){ -'use strict' - -var glslify = _dereq_('glslify') - -exports.boxVertex = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n"]) -exports.boxFragment = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"]) +var createTubes = function(streams, colormap, maxDivergence, minDistance) { -},{"glslify":392}],286:[function(_dereq_,module,exports){ -'use strict' - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') - -var SHADERS = _dereq_('./lib/shaders') - -module.exports = createSelectBox - -function SelectBox(plot, boxBuffer, boxShader) { - this.plot = plot - this.boxBuffer = boxBuffer - this.boxShader = boxShader - - this.enabled = true - - this.selectBox = [Infinity,Infinity,-Infinity,-Infinity] - - this.borderColor = [0,0,0,1] - this.innerFill = false - this.innerColor = [0,0,0,0.25] - this.outerFill = true - this.outerColor = [0,0,0,0.5] - this.borderWidth = 10 -} - -var proto = SelectBox.prototype - -proto.draw = function() { - if(!this.enabled) { - return - } - - var plot = this.plot - var selectBox = this.selectBox - var lineWidth = this.borderWidth - - var innerFill = this.innerFill - var innerColor = this.innerColor - var outerFill = this.outerFill - var outerColor = this.outerColor - var borderColor = this.borderColor - - var boxes = plot.box - var screenBox = plot.screenBox - var dataBox = plot.dataBox - var viewBox = plot.viewBox - var pixelRatio = plot.pixelRatio - - //Map select box into pixel coordinates - var loX = (selectBox[0]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] - var loY = (selectBox[1]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] - var hiX = (selectBox[2]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] - var hiY = (selectBox[3]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] - - loX = Math.max(loX, viewBox[0]) - loY = Math.max(loY, viewBox[1]) - hiX = Math.min(hiX, viewBox[2]) - hiY = Math.min(hiY, viewBox[3]) - - if(hiX < loX || hiY < loY) { - return - } - - boxes.bind() - - //Draw box - var screenWidth = screenBox[2] - screenBox[0] - var screenHeight = screenBox[3] - screenBox[1] - - if(this.outerFill) { - boxes.drawBox(0, 0, screenWidth, loY, outerColor) - boxes.drawBox(0, loY, loX, hiY, outerColor) - boxes.drawBox(0, hiY, screenWidth, screenHeight, outerColor) - boxes.drawBox(hiX, loY, screenWidth, hiY, outerColor) - } - - if(this.innerFill) { - boxes.drawBox(loX, loY, hiX, hiY, innerColor) - } - - //Draw border - if(lineWidth > 0) { - - //Draw border - var w = lineWidth * pixelRatio - boxes.drawBox(loX-w, loY-w, hiX+w, loY+w, borderColor) - boxes.drawBox(loX-w, hiY-w, hiX+w, hiY+w, borderColor) - boxes.drawBox(loX-w, loY-w, loX+w, hiY+w, borderColor) - boxes.drawBox(hiX-w, loY-w, hiX+w, hiY+w, borderColor) - } -} - -proto.update = function(options) { - options = options || {} - - this.innerFill = !!options.innerFill - this.outerFill = !!options.outerFill - this.innerColor = (options.innerColor || [0,0,0,0.5]).slice() - this.outerColor = (options.outerColor || [0,0,0,0.5]).slice() - this.borderColor = (options.borderColor || [0,0,0,1]).slice() - this.borderWidth = options.borderWidth || 0 - this.selectBox = (options.selectBox || this.selectBox).slice() -} - -proto.dispose = function() { - this.boxBuffer.dispose() - this.boxShader.dispose() - this.plot.removeOverlay(this) -} - -function createSelectBox(plot, options) { - var gl = plot.gl - var buffer = createBuffer(gl, [ - 0, 0, - 0, 1, - 1, 0, - 1, 1 ]) - var shader = createShader(gl, SHADERS.boxVertex, SHADERS.boxFragment) - var selectBox = new SelectBox(plot, buffer, shader) - selectBox.update(options) - plot.addOverlay(selectBox) - return selectBox -} + var maxNorm = 0; + for (var i=0; i maxNorm) { + maxNorm = norm; + } + } + } + + var tubes = streams.map(function(s) { + return streamToTube(s, maxDivergence, minDistance, maxNorm); + }); + + var positions = []; + var cells = []; + var vectors = []; + var vertexIntensity = []; + for (var i=0; i < tubes.length; i++) { + var tube = tubes[i]; + var offset = positions.length; + positions = positions.concat(tube.positions); + vectors = vectors.concat(tube.vectors); + vertexIntensity = vertexIntensity.concat(tube.vertexIntensity); + for (var j=0; j v) return i-1; + } + return i; +}; + +var tmp = vec3.create(); +var tmp2 = vec3.create(); + +var clamp = function(v, min, max) { + return v < min ? min : (v > max ? max : v); +}; + +var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { + var x = point[0]; + var y = point[1]; + var z = point[2]; + + var w = meshgrid[0].length; + var h = meshgrid[1].length; + var d = meshgrid[2].length; + + // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). + // The nearest smaller value index for x is the index x0 such that + // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. + var x0 = findLastSmallerIndex(meshgrid[0], x); + var y0 = findLastSmallerIndex(meshgrid[1], y); + var z0 = findLastSmallerIndex(meshgrid[2], z); + + // Get the nearest larger meshgrid value indices. + // From the above "nearest smaller value", we know that + // meshgrid[0][x0] < x + // meshgrid[0][x0+1] >= x + var x1 = x0 + 1; + var y1 = y0 + 1; + var z1 = z0 + 1; + + if (meshgrid[0][x0] === x) x1 = x0; + if (meshgrid[1][y0] === y) y1 = y0; + if (meshgrid[2][z0] === z) z1 = z0; + + if (clampOverflow) { + x0 = clamp(x0, 0, w-1); + x1 = clamp(x1, 0, w-1); + y0 = clamp(y0, 0, h-1); + y1 = clamp(y1, 0, h-1); + z0 = clamp(z0, 0, d-1); + z1 = clamp(z1, 0, d-1); + } + + // Reject points outside the meshgrid, return a zero vector. + if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { + return vec3.create(); + } + + // Normalize point coordinates to 0..1 scaling factor between x0 and x1. + var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); + var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); + var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); + + if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; + if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; + if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; + + var z0off = z0*w*h; + var z1off = z1*w*h; + + var y0off = y0*w; + var y1off = y1*w; + + var x0off = x0; + var x1off = x1; + + // Sample data array around the (x,y,z) point. + // vZYX = array[zZoff + yYoff + xXoff] + var v000 = array[y0off + z0off + x0off]; + var v001 = array[y0off + z0off + x1off]; + var v010 = array[y1off + z0off + x0off]; + var v011 = array[y1off + z0off + x1off]; + var v100 = array[y0off + z1off + x0off]; + var v101 = array[y0off + z1off + x1off]; + var v110 = array[y1off + z1off + x0off]; + var v111 = array[y1off + z1off + x1off]; + + var result = vec3.create(); + + // Average samples according to distance to point. + vec3.lerp(result, v000, v001, xf); + vec3.lerp(tmp, v010, v011, xf); + vec3.lerp(result, result, tmp, yf); + vec3.lerp(tmp, v100, v101, xf); + vec3.lerp(tmp2, v110, v111, xf); + vec3.lerp(tmp, tmp, tmp2, yf); + vec3.lerp(result, result, tmp, zf); + + return result; +}; + + +var vabs = function(dst, v) { + var x = v[0]; + var y = v[1]; + var z = v[2]; + dst[0] = x >= 0 ? x : -x; + dst[1] = y >= 0 ? y : -y; + dst[2] = z >= 0 ? z : -z; + return dst; +}; + +var findMinSeparation = function(xs) { + var minSeparation = 1/0; + xs.sort(function(a, b) { return a - b; }); + for (var i=1; i= minX && x <= maxX && + y >= minY && y <= maxY && + z >= minZ && z <= maxZ + ); + }; - this._readCallback = function() { - if(!self.gl) { - return - } - fbo.bind() - gl.readPixels(0,0,fbo.shape[0],fbo.shape[1],gl.RGBA,gl.UNSIGNED_BYTE,self.buffer) - self._readTimeout = null - } -} + var boundsSize = vec3.distance(bounds[0], bounds[1]); + var maxStepSize = 10 * boundsSize / maxLength; + var maxStepSizeSq = maxStepSize * maxStepSize; -var proto = SelectBuffer.prototype + var minDistance = 1; + var maxDivergence = 0; // For component-wise divergence vec3.create(); + var tmp = vec3.create(); -Object.defineProperty(proto, 'shape', { - get: function() { - if(!this.gl) { - return [0,0] - } - return this.fbo.shape.slice() - }, - set: function(v) { - if(!this.gl) { - return - } - this.fbo.shape = v - var c = this.fbo.shape[0] - var r = this.fbo.shape[1] - if(r*c*4 > this.buffer.length) { - pool.free(this.buffer) - var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) - for(var i=0; i= 2) { + minDistance = calculateMinPositionDistance(positions); + } -proto.begin = function() { - var gl = this.gl - var shape = this.shape - if(!gl) { - return - } + for (var i = 0; i < positions.length; i++) { + var p = vec3.create(); + vec3.copy(p, positions[i]); - this.fbo.bind() - gl.clearColor(1,1,1,1) - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) -} + var stream = [p]; + var velocities = []; + var v = vectorField.getVelocity(p); + var op = p; + velocities.push(v); -proto.end = function() { - var gl = this.gl - if(!gl) { - return - } - gl.bindFramebuffer(gl.FRAMEBUFFER, null) - if(!this._readTimeout) { - clearTimeout(this._readTimeout) - } - this._readTimeout = setTimeout(this._readCallback, 1) -} + var divergences = []; -proto.query = function(x, y, radius) { - if(!this.gl) { - return null - } + var dv = vectorField.getDivergence(p, v); + var dvLength = vec3.length(dv); + if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { + maxDivergence = dvLength; + } + // In case we need to do component-wise divergence visualization + // vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); + divergences.push(dvLength); + + streams.push({points: stream, velocities: velocities, divergences: divergences}); + + var j = 0; + + while (j < maxLength * 100 && stream.length < maxLength && inBounds(bounds, p)) { + j++; + var np = vec3.clone(v); + var sqLen = vec3.squaredLength(np); + if (sqLen === 0) { + break; + } else if (sqLen > maxStepSizeSq) { + vec3.scale(np, np, maxStepSize / Math.sqrt(sqLen)); + } + vec3.add(np, np, p); + + v = vectorField.getVelocity(np); + + if (vec3.squaredDistance(op, np) - maxStepSizeSq > -0.0001 * maxStepSizeSq) { + stream.push(np); + op = np; + velocities.push(v); + var dv = vectorField.getDivergence(np, v); + var dvLength = vec3.length(dv); + if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { + maxDivergence = dvLength; + } + // In case we need to do component-wise divergence visualization + //vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); + divergences.push(dvLength); + } - var shape = this.fbo.shape.slice() + p = np; + } + } - x = x|0 - y = y|0 - if(typeof radius !== 'number') { - radius = 1.0 - } + // Replace NaNs and Infinities with non-NaN, finite maxDivergence + for (var i=0; i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color — in vertex or in fragment\n vec4 surfaceColor =\n step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) +\n step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]) +var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform vec3 objectOffset;\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n worldCoordinate = objectOffset + dataCoordinate;\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z += zOffset;\n\n gl_Position = clipPosition;\n value = f + objectOffset.z;\n kill = -1.0;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]) +var pickSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]) -proto.dispose = function() { - if(!this.gl) { - return - } - this.fbo.dispose() - pool.free(this.buffer) - this.gl = null - if(this._readTimeout) { - clearTimeout(this._readTimeout) - } +exports.createShader = function (gl) { + var shader = createShader(gl, vertSrc, fragSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'vec3'}, + {name: 'normal', type: 'vec3'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + shader.attributes.normal.location = 2 + return shader } - -function createSelectBuffer(gl, shape) { - var fbo = createFBO(gl, shape) - var buffer = pool.mallocUint8(shape[0]*shape[1]*4) - return new SelectBuffer(gl, fbo, buffer) +exports.createPickShader = function (gl) { + var shader = createShader(gl, vertSrc, pickSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'vec3'}, + {name: 'normal', type: 'vec3'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + shader.attributes.normal.location = 2 + return shader +} +exports.createContourShader = function (gl) { + var shader = createShader(gl, contourVertSrc, fragSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'float'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + return shader +} +exports.createPickContourShader = function (gl) { + var shader = createShader(gl, contourVertSrc, pickSrc, null, [ + {name: 'uv', type: 'vec4'}, + {name: 'f', type: 'float'} + ]) + shader.attributes.uv.location = 0 + shader.attributes.f.location = 1 + return shader } -},{"bit-twiddle":80,"cwise/lib/wrapper":137,"gl-fbo":239,"ndarray":433,"typedarray-pool":522}],288:[function(_dereq_,module,exports){ +},{"gl-shader":288,"glslify":392}],303:[function(_dereq_,module,exports){ 'use strict' -var createUniformWrapper = _dereq_('./lib/create-uniforms') -var createAttributeWrapper = _dereq_('./lib/create-attributes') -var makeReflect = _dereq_('./lib/reflect') -var shaderCache = _dereq_('./lib/shader-cache') -var runtime = _dereq_('./lib/runtime-reflect') -var GLError = _dereq_("./lib/GLError") +module.exports = createSurfacePlot -//Shader object -function Shader(gl) { - this.gl = gl - this.gl.lastAttribCount = 0 // fixme where else should we store info, safe but not nice on the gl object +var bits = _dereq_('bit-twiddle') +var createBuffer = _dereq_('gl-buffer') +var createVAO = _dereq_('gl-vao') +var createTexture = _dereq_('gl-texture2d') +var pool = _dereq_('typedarray-pool') +var colormap = _dereq_('colormap') +var ops = _dereq_('ndarray-ops') +var pack = _dereq_('ndarray-pack') +var ndarray = _dereq_('ndarray') +var surfaceNets = _dereq_('surface-nets') +var multiply = _dereq_('gl-mat4/multiply') +var invert = _dereq_('gl-mat4/invert') +var bsearch = _dereq_('binary-search-bounds') +var gradient = _dereq_('ndarray-gradient') +var shaders = _dereq_('./lib/shaders') - //Default initialize these to null - this._vref = - this._fref = - this._relink = - this.vertShader = - this.fragShader = - this.program = - this.attributes = - this.uniforms = - this.types = null -} +var createShader = shaders.createShader +var createContourShader = shaders.createContourShader +var createPickShader = shaders.createPickShader +var createPickContourShader = shaders.createPickContourShader -var proto = Shader.prototype +var SURFACE_VERTEX_SIZE = 4 * (4 + 3 + 3) -proto.bind = function() { - if(!this.program) { - this._relink() - } +var IDENTITY = [ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 ] + +var QUAD = [ + [0, 0], + [0, 1], + [1, 0], + [1, 1], + [1, 0], + [0, 1] +] - // ensuring that we have the right number of enabled vertex attributes - var i - var newAttribCount = this.gl.getProgramParameter(this.program, this.gl.ACTIVE_ATTRIBUTES) // more robust approach - //var newAttribCount = Object.keys(this.attributes).length // avoids the probably immaterial introspection slowdown - var oldAttribCount = this.gl.lastAttribCount - if(newAttribCount > oldAttribCount) { - for(i = oldAttribCount; i < newAttribCount; i++) { - this.gl.enableVertexAttribArray(i) - } - } else if(oldAttribCount > newAttribCount) { - for(i = newAttribCount; i < oldAttribCount; i++) { - this.gl.disableVertexAttribArray(i) - } +var PERMUTATIONS = [ + [0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0] +] + +;(function () { + for (var i = 0; i < 3; ++i) { + var p = PERMUTATIONS[i] + var u = (i + 1) % 3 + var v = (i + 2) % 3 + p[u + 0] = 1 + p[v + 3] = 1 + p[i + 6] = 1 } +})() - this.gl.lastAttribCount = newAttribCount +function SurfacePickResult (position, index, uv, level, dataCoordinate) { + this.position = position + this.index = index + this.uv = uv + this.level = level + this.dataCoordinate = dataCoordinate +} - this.gl.useProgram(this.program) +var N_COLORS = 256 + +function genColormap (name) { + var x = pack([colormap({ + colormap: name, + nshades: N_COLORS, + format: 'rgba' + }).map(function (c) { + return [c[0], c[1], c[2], 255 * c[3]] + })]) + ops.divseq(x, 255.0) + return x } -proto.dispose = function() { +function SurfacePlot ( + gl, + shape, + bounds, + shader, + pickShader, + coordinates, + vao, + colorMap, + contourShader, + contourPickShader, + contourBuffer, + contourVAO, + dynamicBuffer, + dynamicVAO, + objectOffset) { + this.gl = gl + this.shape = shape + this.bounds = bounds + this.objectOffset = objectOffset + this.intensityBounds = [] + + this._shader = shader + this._pickShader = pickShader + this._coordinateBuffer = coordinates + this._vao = vao + this._colorMap = colorMap + + this._contourShader = contourShader + this._contourPickShader = contourPickShader + this._contourBuffer = contourBuffer + this._contourVAO = contourVAO + this._contourOffsets = [[], [], []] + this._contourCounts = [[], [], []] + this._vertexCount = 0 + + this._pickResult = new SurfacePickResult([0, 0, 0], [0, 0], [0, 0], [0, 0, 0], [0, 0, 0]) + + this._dynamicBuffer = dynamicBuffer + this._dynamicVAO = dynamicVAO + this._dynamicOffsets = [0, 0, 0] + this._dynamicCounts = [0, 0, 0] + + this.contourWidth = [ 1, 1, 1 ] + this.contourLevels = [[1], [1], [1]] + this.contourTint = [0, 0, 0] + this.contourColor = [[0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1]] + + this.showContour = true + this.showSurface = true + + this.enableHighlight = [true, true, true] + this.highlightColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]] + this.highlightTint = [ 1, 1, 1 ] + this.highlightLevel = [-1, -1, -1] + + // Dynamic contour options + this.enableDynamic = [ true, true, true ] + this.dynamicLevel = [ NaN, NaN, NaN ] + this.dynamicColor = [ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1] ] + this.dynamicTint = [ 1, 1, 1 ] + this.dynamicWidth = [ 1, 1, 1 ] + + this.axesBounds = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]] + this.surfaceProject = [ false, false, false ] + this.contourProject = [[ false, false, false ], + [ false, false, false ], + [ false, false, false ]] + + this.colorBounds = [ false, false ] + + // Store xyz fields, need this for picking + this._field = [ + ndarray(pool.mallocFloat(1024), [0, 0]), + ndarray(pool.mallocFloat(1024), [0, 0]), + ndarray(pool.mallocFloat(1024), [0, 0]) ] + + this.pickId = 1 + this.clipBounds = [[-Infinity, -Infinity, -Infinity], [Infinity, Infinity, Infinity]] + + this.snapToData = false + + this.opacity = 1.0 + + this.lightPosition = [10, 10000, 0] + this.ambientLight = 0.8 + this.diffuseLight = 0.8 + this.specularLight = 2.0 + this.roughness = 0.5 + this.fresnel = 1.5 + this.vertexColor = 0 - // disabling vertex attributes so new shader starts with zero - // and it's also useful if all shaders are disposed but the - // gl context is reused for subsequent replotting - var oldAttribCount = this.gl.lastAttribCount - for (var i = 0; i < oldAttribCount; i++) { - this.gl.disableVertexAttribArray(i) - } - this.gl.lastAttribCount = 0 + this.dirty = true +} - if(this._fref) { - this._fref.dispose() +var proto = SurfacePlot.prototype + +proto.isTransparent = function () { + return this.opacity < 1 +} + +proto.isOpaque = function () { + if (this.opacity >= 1) { + return true } - if(this._vref) { - this._vref.dispose() + for (var i = 0; i < 3; ++i) { + if (this._contourCounts[i].length > 0 || this._dynamicCounts[i] > 0) { + return true + } } - this.attributes = - this.types = - this.vertShader = - this.fragShader = - this.program = - this._relink = - this._fref = - this._vref = null + return false } -function compareAttributes(a, b) { - if(a.name < b.name) { - return -1 - } - return 1 +proto.pickSlots = 1 + +proto.setPickBase = function (id) { + this.pickId = id } -//Update export hook for glslify-live -proto.update = function( - vertSource - , fragSource - , uniforms - , attributes) { +var ZERO_VEC = [0, 0, 0] - //If only one object passed, assume glslify style output - if(!fragSource || arguments.length === 1) { - var obj = vertSource - vertSource = obj.vertex - fragSource = obj.fragment - uniforms = obj.uniforms - attributes = obj.attributes - } +var PROJECT_DATA = { + showSurface: false, + showContour: false, + projections: [IDENTITY.slice(), IDENTITY.slice(), IDENTITY.slice()], + clipBounds: [ + [[0, 0, 0], [0, 0, 0]], + [[0, 0, 0], [0, 0, 0]], + [[0, 0, 0], [0, 0, 0]]] +} - var wrapper = this - var gl = wrapper.gl +function computeProjectionData (camera, obj) { + var i, j, k - //Compile vertex and fragment shaders - var pvref = wrapper._vref - wrapper._vref = shaderCache.shader(gl, gl.VERTEX_SHADER, vertSource) - if(pvref) { - pvref.dispose() - } - wrapper.vertShader = wrapper._vref.shader - var pfref = this._fref - wrapper._fref = shaderCache.shader(gl, gl.FRAGMENT_SHADER, fragSource) - if(pfref) { - pfref.dispose() - } - wrapper.fragShader = wrapper._fref.shader + // Compute cube properties + var cubeAxis = (obj.axes && obj.axes.lastCubeProps.axis) || ZERO_VEC - //If uniforms/attributes is not specified, use RT reflection - if(!uniforms || !attributes) { + var showSurface = obj.showSurface + var showContour = obj.showContour - //Create initial test program - var testProgram = gl.createProgram() - gl.attachShader(testProgram, wrapper.fragShader) - gl.attachShader(testProgram, wrapper.vertShader) - gl.linkProgram(testProgram) - if(!gl.getProgramParameter(testProgram, gl.LINK_STATUS)) { - var errLog = gl.getProgramInfoLog(testProgram) - throw new GLError(errLog, 'Error linking program:' + errLog) + for (i = 0; i < 3; ++i) { + showSurface = showSurface || obj.surfaceProject[i] + for (j = 0; j < 3; ++j) { + showContour = showContour || obj.contourProject[i][j] } + } - //Load data from runtime - uniforms = uniforms || runtime.uniforms(gl, testProgram) - attributes = attributes || runtime.attributes(gl, testProgram) + for (i = 0; i < 3; ++i) { + // Construct projection onto axis + var axisSquish = PROJECT_DATA.projections[i] + for (j = 0; j < 16; ++j) { + axisSquish[j] = 0 + } + for (j = 0; j < 4; ++j) { + axisSquish[5 * j] = 1 + } + axisSquish[5 * i] = 0 + axisSquish[12 + i] = obj.axesBounds[+(cubeAxis[i] > 0)][i] + multiply(axisSquish, camera.model, axisSquish) - //Release test program - gl.deleteProgram(testProgram) - } + var nclipBounds = PROJECT_DATA.clipBounds[i] + for (k = 0; k < 2; ++k) { + for (j = 0; j < 3; ++j) { + nclipBounds[k][j] = camera.clipBounds[k][j] + } + } + nclipBounds[0][i] = -1e8 + nclipBounds[1][i] = 1e8 + } + + PROJECT_DATA.showSurface = showSurface + PROJECT_DATA.showContour = showContour + + return PROJECT_DATA +} + +var UNIFORMS = { + model: IDENTITY, + view: IDENTITY, + projection: IDENTITY, + inverseModel: IDENTITY.slice(), + lowerBound: [0, 0, 0], + upperBound: [0, 0, 0], + colorMap: 0, + clipBounds: [[0, 0, 0], [0, 0, 0]], + height: 0.0, + contourTint: 0, + contourColor: [0, 0, 0, 1], + permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], + zOffset: -1e-4, + objectOffset: [0, 0, 0], + kambient: 1, + kdiffuse: 1, + kspecular: 1, + lightPosition: [1000, 1000, 1000], + eyePosition: [0, 0, 0], + roughness: 1, + fresnel: 1, + opacity: 1, + vertexColor: 0 +} + +var MATRIX_INVERSE = IDENTITY.slice() +var DEFAULT_PERM = [1, 0, 0, 0, 1, 0, 0, 0, 1] + +function drawCore (params, transparent) { + params = params || {} + var gl = this.gl - //Sort attributes lexicographically - // overrides undefined WebGL behavior for attribute locations - attributes = attributes.slice() - attributes.sort(compareAttributes) + gl.disable(gl.CULL_FACE) - //Convert attribute types, read out locations - var attributeUnpacked = [] - var attributeNames = [] - var attributeLocations = [] - var i - for(i=0; i= 0) { - var size = attr.type.charAt(attr.type.length-1)|0 - var locVector = new Array(size) - for(var j=0; j= 0) { - curLocation += 1 - } - attributeLocations[i] = curLocation + var uniforms = UNIFORMS + uniforms.model = params.model || IDENTITY + uniforms.view = params.view || IDENTITY + uniforms.projection = params.projection || IDENTITY + uniforms.lowerBound = [this.bounds[0][0], this.bounds[0][1], this.colorBounds[0] || this.bounds[0][2]] + uniforms.upperBound = [this.bounds[1][0], this.bounds[1][1], this.colorBounds[1] || this.bounds[1][2]] + uniforms.objectOffset = this.objectOffset + uniforms.contourColor = this.contourColor[0] + + uniforms.inverseModel = invert(uniforms.inverseModel, uniforms.model) + + for (var i = 0; i < 2; ++i) { + var clipClamped = uniforms.clipBounds[i] + for (var j = 0; j < 3; ++j) { + clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) } } - //Rebuild program and recompute all uniform locations - var uniformLocations = new Array(uniforms.length) - function relink() { - wrapper.program = shaderCache.program( - gl - , wrapper._vref - , wrapper._fref - , attributeNames - , attributeLocations) + uniforms.kambient = this.ambientLight + uniforms.kdiffuse = this.diffuseLight + uniforms.kspecular = this.specularLight - for(var i=0; i= 0) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) - } - addVectorAttribute( - gl - , wrapper - , locs[0] - , locations - , d - , obj - , name) - } else if(type.indexOf('mat') >= 0) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) - } - addMatrixAttribute( - gl - , wrapper - , locs - , locations - , d - , obj - , name) - } else { - throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) - } - break + // Compute uv coordinate + var x = shape[0] * (selection.value[0] + (selection.value[2] >> 4) / 16.0) / 255.0 + var ix = Math.floor(x) + var fx = x - ix + + var y = shape[1] * (selection.value[1] + (selection.value[2] & 15) / 16.0) / 255.0 + var iy = Math.floor(y) + var fy = y - iy + + ix += 1 + iy += 1 + + // Compute xyz coordinate + var pos = result.position + pos[0] = pos[1] = pos[2] = 0 + for (var dx = 0; dx < 2; ++dx) { + var s = dx ? fx : 1.0 - fx + for (var dy = 0; dy < 2; ++dy) { + var t = dy ? fy : 1.0 - fy + + var r = ix + dx + var c = iy + dy + var w = s * t + + for (var i = 0; i < 3; ++i) { + pos[i] += this._field[i].get(r, c) * w + } } } - return obj -} - -},{"./GLError":289}],291:[function(_dereq_,module,exports){ -'use strict' -var coallesceUniforms = _dereq_('./reflect') -var GLError = _dereq_("./GLError") + // Find closest level + var levelIndex = this._pickResult.level + for (var j = 0; j < 3; ++j) { + levelIndex[j] = bsearch.le(this.contourLevels[j], pos[j]) + if (levelIndex[j] < 0) { + if (this.contourLevels[j].length > 0) { + levelIndex[j] = 0 + } + } else if (levelIndex[j] < this.contourLevels[j].length - 1) { + var a = this.contourLevels[j][levelIndex[j]] + var b = this.contourLevels[j][levelIndex[j] + 1] + if (Math.abs(a - pos[j]) > Math.abs(b - pos[j])) { + levelIndex[j] += 1 + } + } + } -module.exports = createUniformWrapper + result.index[0] = fx < 0.5 ? ix : (ix + 1) + result.index[1] = fy < 0.5 ? iy : (iy + 1) -//Binds a function and returns a value -function identity(x) { - var c = new Function('y', 'return function(){return y}') - return c(x) -} + result.uv[0] = x / shape[0] + result.uv[1] = y / shape[1] -function makeVector(length, fill) { - var result = new Array(length) - for(var i=0; i 4) { - throw new GLError('', 'Invalid data type') - } - switch(type.charAt(0)) { - case 'b': - case 'i': - return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' - case 'v': - return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' - default: - throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) - } - } else if(type.indexOf('mat') === 0 && type.length === 4) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) - } - return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' - } else { - throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) - } - break - } + // Edges + ops.assign(dstField.lo(1).hi(srcShape[0], 1), + srcField.hi(srcShape[0], 1)) + ops.assign(dstField.lo(1, dstShape[1] - 1).hi(srcShape[0], 1), + srcField.lo(0, srcShape[1] - 1).hi(srcShape[0], 1)) + ops.assign(dstField.lo(0, 1).hi(1, srcShape[1]), + srcField.hi(1)) + ops.assign(dstField.lo(dstShape[0] - 1, 1).hi(1, srcShape[1]), + srcField.lo(srcShape[0] - 1)) + // Corners + dstField.set(0, 0, srcField.get(0, 0)) + dstField.set(0, dstShape[1] - 1, srcField.get(0, srcShape[1] - 1)) + dstField.set(dstShape[0] - 1, 0, srcField.get(srcShape[0] - 1, 0)) + dstField.set(dstShape[0] - 1, dstShape[1] - 1, srcField.get(srcShape[0] - 1, srcShape[1] - 1)) +} + +function handleArray (param, ctor) { + if (Array.isArray(param)) { + return [ ctor(param[0]), ctor(param[1]), ctor(param[2]) ] } + return [ ctor(param), ctor(param), ctor(param) ] +} - function enumerateIndices(prefix, type) { - if(typeof type !== 'object') { - return [ [prefix, type] ] - } - var indices = [] - for(var id in type) { - var prop = type[id] - var tprefix = prefix - if(parseInt(id) + '' === id) { - tprefix += '[' + id + ']' - } else { - tprefix += '.' + id - } - if(typeof prop === 'object') { - indices.push.apply(indices, enumerateIndices(tprefix, prop)) - } else { - indices.push([tprefix, prop]) - } +function toColor (x) { + if (Array.isArray(x)) { + if (x.length === 3) { + return [x[0], x[1], x[2], 1] } - return indices + return [x[0], x[1], x[2], x[3]] } + return [0, 0, 0, 1] +} - function makeSetter(type) { - var code = [ 'return function updateProperty(obj){' ] - var indices = enumerateIndices('', type) - for(var i=0; i 4) { - throw new GLError('', 'Invalid data type') - } - if(type.charAt(0) === 'b') { - return makeVector(d, false) - } - return makeVector(d, 0) - } else if(type.indexOf('mat') === 0 && type.length === 4) { - var d = type.charCodeAt(type.length-1) - 48 - if(d < 2 || d > 4) { - throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) - } - return makeVector(d*d, 0) - } else { - throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) - } - break - } +proto.update = function (params) { + params = params || {} + + this.objectOffset = params.objectOffset || this.objectOffset + + this.dirty = true + + if ('contourWidth' in params) { + this.contourWidth = handleArray(params.contourWidth, Number) + } + if ('showContour' in params) { + this.showContour = handleArray(params.showContour, Boolean) + } + if ('showSurface' in params) { + this.showSurface = !!params.showSurface + } + if ('contourTint' in params) { + this.contourTint = handleArray(params.contourTint, Boolean) + } + if ('contourColor' in params) { + this.contourColor = handleColor(params.contourColor) + } + if ('contourProject' in params) { + this.contourProject = handleArray(params.contourProject, function (x) { + return handleArray(x, Boolean) + }) + } + if ('surfaceProject' in params) { + this.surfaceProject = params.surfaceProject + } + if ('dynamicColor' in params) { + this.dynamicColor = handleColor(params.dynamicColor) + } + if ('dynamicTint' in params) { + this.dynamicTint = handleArray(params.dynamicTint, Number) + } + if ('dynamicWidth' in params) { + this.dynamicWidth = handleArray(params.dynamicWidth, Number) + } + if ('opacity' in params) { + this.opacity = params.opacity + } + if ('colorBounds' in params) { + this.colorBounds = params.colorBounds + } + if ('vertexColor' in params) { + this.vertexColor = params.vertexColor ? 1 : 0; } - function storeProperty(obj, prop, type) { - if(typeof type === 'object') { - var child = processObject(type) - Object.defineProperty(obj, prop, { - get: identity(child), - set: makeSetter(type), - enumerable: true, - configurable: false - }) + var field = params.field || (params.coords && params.coords[2]) || null + var levelsChanged = false + + if (!field) { + if (this._field[2].shape[0] || this._field[2].shape[2]) { + field = this._field[2].lo(1, 1).hi(this._field[2].shape[0] - 2, this._field[2].shape[1] - 2) } else { - if(locations[type]) { - Object.defineProperty(obj, prop, { - get: makeGetter(type), - set: makeSetter(type), - enumerable: true, - configurable: false - }) - } else { - obj[prop] = defaultValue(uniforms[type].type) - } + field = this._field[2].hi(0, 0) } } - function processObject(obj) { - var result - if(Array.isArray(obj)) { - result = new Array(obj.length) - for(var i=0; i this._field[2].data.length) { + pool.freeFloat(this._field[2].data) + this._field[2].data = pool.mallocFloat(bits.nextPow2(fsize)) } - return result - } - //Return data - var coallesced = coallesceUniforms(uniforms, true) - return { - get: identity(processObject(coallesced)), - set: makeSetter(coallesced), - enumerable: true, - configurable: true - } -} + // Pad field + this._field[2] = ndarray(this._field[2].data, [field.shape[0] + 2, field.shape[1] + 2]) + this.padField(this._field[2], field) -},{"./GLError":289,"./reflect":292}],292:[function(_dereq_,module,exports){ -'use strict' + // Save shape of field + this.shape = field.shape.slice() + var shape = this.shape -module.exports = makeReflectTypes + // Resize coordinate fields if necessary + for (var i = 0; i < 2; ++i) { + if (this._field[2].size > this._field[i].data.length) { + pool.freeFloat(this._field[i].data) + this._field[i].data = pool.mallocFloat(this._field[2].size) + } + this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2]) + } -//Construct type info for reflection. -// -// This iterates over the flattened list of uniform type values and smashes them into a JSON object. -// -// The leaves of the resulting object are either indices or type strings representing primitive glslify types -function makeReflectTypes(uniforms, useIndex) { - var obj = {} - for(var i=0; i 1) { - if(!(x[0] in o)) { - o[x[0]] = [] - } - o = o[x[0]] - for(var k=1; k 1) { - for(var j=0; j 0) { + // If we already added first edge, pop off verts + for (var l = 0; l < 5; ++l) { + contourVerts.pop() + } + vertexCount -= 1 + } + continue edge_loop + } + } + } + levelCounts.push(vertexCount) + } + + // Store results + this._contourOffsets[dim] = levelOffsets + this._contourCounts[dim] = levelCounts -function compileShader(gl, type, src) { - var shader = gl.createShader(type) - gl.shaderSource(shader, src) - gl.compileShader(shader) - if(!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - var errLog = gl.getShaderInfoLog(shader) - try { - var fmt = formatCompilerError(errLog, src, type); - } catch (e){ - console.warn('Failed to format compiler error: ' + e); - throw new GLError(errLog, 'Error compiling shader:\n' + errLog) } - throw new GLError(errLog, fmt.short, fmt.long) - } - return shader -} -proto.getShaderReference = function(type, src) { - var gl = this.gl - var shaders = this.shaders[(type === gl.FRAGMENT_SHADER)|0] - var shader = shaders[src] - if(!shader || !gl.isShader(shader.shader)) { - var shaderObj = compileShader(gl, type, src) - shader = shaders[src] = new ShaderReference( - SHADER_COUNTER++, - src, - type, - shaderObj, - [], - 1, - this) - } else { - shader.count += 1 + var floatBuffer = pool.mallocFloat(contourVerts.length) + for (i = 0; i < contourVerts.length; ++i) { + floatBuffer[i] = contourVerts[i] + } + this._contourBuffer.update(floatBuffer) + pool.freeFloat(floatBuffer) } - return shader -} -function linkProgram(gl, vshader, fshader, attribs, locations) { - var program = gl.createProgram() - gl.attachShader(program, vshader) - gl.attachShader(program, fshader) - for(var i=0; i 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]) -var triFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]) -var pickVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]) -var pickFragSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]) - -exports.meshShader = { - vertex: triVertSrc, - fragment: triFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'normal', type: 'vec3'}, - {name: 'color', type: 'vec4'}, - {name: 'uv', type: 'vec2'}, - {name: 'vector', type: 'vec4'} - ] -} -exports.pickShader = { - vertex: pickVertSrc, - fragment: pickFragSrc, - attributes: [ - {name: 'position', type: 'vec4'}, - {name: 'id', type: 'vec4'}, - {name: 'vector', type: 'vec4'} - ] -} + var dynamicBuffer = createBuffer(gl) + var dynamicVAO = createVAO(gl, [ + { + buffer: dynamicBuffer, + size: 2, + type: gl.FLOAT + }]) -},{"glslify":392}],300:[function(_dereq_,module,exports){ -'use strict' - -var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small -var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; - -var createShader = _dereq_('gl-shader') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var normals = _dereq_('normals') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var ndarray = _dereq_('ndarray') -var colormap = _dereq_('colormap') -var getContour = _dereq_('simplicial-complex-contour') -var pool = _dereq_('typedarray-pool') -var shaders = _dereq_('./shaders') -var closestPoint = _dereq_('./closest-point') - -var meshShader = shaders.meshShader -var pickShader = shaders.pickShader - -var identityMatrix = [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1] - -function SimplicialMesh(gl - , texture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) { - - this.gl = gl - this.cells = [] - this.positions = [] - this.intensity = [] - this.texture = texture - this.dirty = true - - this.triShader = triShader - this.lineShader = lineShader - this.pointShader = pointShader - this.pickShader = pickShader - this.pointPickShader = pointPickShader - this.contourShader = contourShader - - this.trianglePositions = trianglePositions - this.triangleVectors = triangleVectors - this.triangleColors = triangleColors - this.triangleNormals = triangleNormals - this.triangleUVs = triangleUVs - this.triangleIds = triangleIds - this.triangleVAO = triangleVAO - this.triangleCount = 0 - - this.lineWidth = 1 - this.edgePositions = edgePositions - this.edgeColors = edgeColors - this.edgeUVs = edgeUVs - this.edgeIds = edgeIds - this.edgeVAO = edgeVAO - this.edgeCount = 0 - - this.pointPositions = pointPositions - this.pointColors = pointColors - this.pointUVs = pointUVs - this.pointSizes = pointSizes - this.pointIds = pointIds - this.pointVAO = pointVAO - this.pointCount = 0 - - this.contourLineWidth = 1 - this.contourPositions = contourPositions - this.contourVAO = contourVAO - this.contourCount = 0 - this.contourColor = [0,0,0] - this.contourEnable = false - - this.pickId = 1 - this.bounds = [ - [ Infinity, Infinity, Infinity], - [-Infinity,-Infinity,-Infinity] ] - this.clipBounds = [ - [-Infinity,-Infinity,-Infinity], - [ Infinity, Infinity, Infinity] ] - - this.lightPosition = [1e5, 1e5, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - - this.opacity = 1.0 - - this.tubeScale = 1.0 - - this._model = identityMatrix - this._view = identityMatrix - this._projection = identityMatrix - this._resolution = [1,1] -} - -var proto = SimplicialMesh.prototype - -proto.isOpaque = function() { - return this.opacity >= 1 -} - -proto.isTransparent = function() { - return this.opacity < 1 -} - -proto.pickSlots = 1 - -proto.setPickBase = function(id) { - this.pickId = id -} - -function genColormap(param) { - var colors = colormap({ - colormap: param - , nshades: 256 - , format: 'rgba' - }) - - var result = new Uint8Array(256*4) - for(var i=0; i<256; ++i) { - var c = colors[i] - for(var j=0; j<3; ++j) { - result[4*i+j] = c[j] - } - result[4*i+3] = c[3]*255 - } - - return ndarray(result, [256,256,4], [4,0,1]) -} - -function unpackIntensity(cells, numVerts, cellIntensity) { - var result = new Array(numVerts) - for(var i=0; i 0) { - var shader = this.triShader - shader.bind() - shader.uniforms = uniforms - - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0 && this.lineWidth > 0) { - var shader = this.lineShader - shader.bind() - shader.uniforms = uniforms - - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } - - if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { - var shader = this.contourShader - shader.bind() - shader.uniforms = uniforms - - this.contourVAO.bind() - gl.drawArrays(gl.LINES, 0, this.contourCount) - this.contourVAO.unbind() - } -} - -proto.drawPick = function(params) { - params = params || {} - - var gl = this.gl - - var model = params.model || identityMatrix - var view = params.view || identityMatrix - var projection = params.projection || identityMatrix - - var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] - for(var i=0; i<3; ++i) { - clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) - clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) - } - - //Save camera parameters - this._model = [].slice.call(model) - this._view = [].slice.call(view) - this._projection = [].slice.call(projection) - this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] - - var uniforms = { - model: model, - view: view, - projection: projection, - clipBounds: clipBounds, - - tubeScale: this.tubeScale, - - pickId: this.pickId / 255.0, - } - - var shader = this.pickShader - shader.bind() - shader.uniforms = uniforms - - if(this.triangleCount > 0) { - this.triangleVAO.bind() - gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) - this.triangleVAO.unbind() - } - - if(this.edgeCount > 0) { - this.edgeVAO.bind() - gl.lineWidth(this.lineWidth) - gl.drawArrays(gl.LINES, 0, this.edgeCount*2) - this.edgeVAO.unbind() - } - - if(this.pointCount > 0) { - var shader = this.pointPickShader - shader.bind() - shader.uniforms = uniforms - - this.pointVAO.bind() - gl.drawArrays(gl.POINTS, 0, this.pointCount) - this.pointVAO.unbind() - } -} - - -proto.pick = function(pickData) { - if(!pickData) { - return null - } - if(pickData.id !== this.pickId) { - return null - } - - var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] - var cell = this.cells[cellId] - - var pos = this.positions[cell[1]].slice(0, 3) - var intensity = this.intensity[cell[1]] - var velocity = this.vectors[cell[1]].slice(0, 3) - var divergence = this.vectors[cell[1]][3] - - return { - index: cellId, - position: pos, - intensity: intensity, - velocity: velocity, - divergence: divergence, - dataCoordinate: pos - } -} - - -proto.dispose = function() { - this.texture.dispose() - - this.triShader.dispose() - // this.lineShader.dispose() - // this.pointShader.dispose() - this.pickShader.dispose() - // this.pointPickShader.dispose() - - this.triangleVAO.dispose() - this.trianglePositions.dispose() - this.triangleVectors.dispose() - this.triangleColors.dispose() - this.triangleUVs.dispose() - this.triangleNormals.dispose() - this.triangleIds.dispose() - - this.edgeVAO.dispose() - this.edgePositions.dispose() - this.edgeColors.dispose() - this.edgeUVs.dispose() - this.edgeIds.dispose() - - this.pointVAO.dispose() - this.pointPositions.dispose() - this.pointColors.dispose() - this.pointUVs.dispose() - this.pointSizes.dispose() - this.pointIds.dispose() - - this.contourVAO.dispose() - this.contourPositions.dispose() - // this.contourShader.dispose() -} - -function createMeshShader(gl) { - var shader = createShader(gl, meshShader.vertex, meshShader.fragment, null, meshShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.vector.location = 5 - return shader -} - -function createWireShader(gl) { - var shader = createShader(gl, wireShader.vertex, wireShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - return shader -} - -function createPointShader(gl) { - var shader = createShader(gl, pointShader.vertex, pointShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.color.location = 2 - shader.attributes.uv.location = 3 - shader.attributes.pointSize.location = 4 - return shader -} - -function createPickShader(gl) { - var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.vector.location = 5 - return shader -} - -function createPointPickShader(gl) { - var shader = createShader(gl, pointPickShader.vertex, pointPickShader.fragment) - shader.attributes.position.location = 0 - shader.attributes.id.location = 1 - shader.attributes.pointSize.location = 4 - return shader -} - -function createContourShader(gl) { - var shader = createShader(gl, contourShader.vertex, contourShader.fragment) - shader.attributes.position.location = 0 - return shader -} - -function createSimplicialMesh(gl, params) { - if (arguments.length === 1) { - params = gl; - gl = params.gl; - } - - var triShader = params.triShader || createMeshShader(gl) - var lineShader = null; //createWireShader(gl) - var pointShader = null; //createPointShader(gl) - var pickShader = createPickShader(gl) - var pointPickShader = null; //createPointPickShader(gl) - var contourShader = null; //createContourShader(gl) - - var meshTexture = createTexture(gl, - ndarray(new Uint8Array([255,255,255,255]), [1,1,4])) - meshTexture.generateMipmap() - meshTexture.minFilter = gl.LINEAR_MIPMAP_LINEAR - meshTexture.magFilter = gl.LINEAR - - var trianglePositions = createBuffer(gl) - var triangleVectors = createBuffer(gl) - var triangleColors = createBuffer(gl) - var triangleUVs = createBuffer(gl) - var triangleNormals = createBuffer(gl) - var triangleIds = createBuffer(gl) - var triangleVAO = createVAO(gl, [ - { buffer: trianglePositions, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: triangleColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: triangleUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: triangleNormals, - type: gl.FLOAT, - size: 3 - }, - { buffer: triangleVectors, - type: gl.FLOAT, - size: 4 - } - ]) - - var edgePositions = createBuffer(gl) - var edgeColors = createBuffer(gl) - var edgeUVs = createBuffer(gl) - var edgeIds = createBuffer(gl) - var edgeVAO = createVAO(gl, [ - { buffer: edgePositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: edgeIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: edgeColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: edgeUVs, - type: gl.FLOAT, - size: 2 - } - ]) - - var pointPositions = createBuffer(gl) - var pointColors = createBuffer(gl) - var pointUVs = createBuffer(gl) - var pointSizes = createBuffer(gl) - var pointIds = createBuffer(gl) - var pointVAO = createVAO(gl, [ - { buffer: pointPositions, - type: gl.FLOAT, - size: 3 - }, - { buffer: pointIds, - type: gl.UNSIGNED_BYTE, - size: 4, - normalized: true - }, - { buffer: pointColors, - type: gl.FLOAT, - size: 4 - }, - { buffer: pointUVs, - type: gl.FLOAT, - size: 2 - }, - { buffer: pointSizes, - type: gl.FLOAT, - size: 1 - } - ]) - - var contourPositions = createBuffer(gl) - var contourVAO = createVAO(gl, [ - { buffer: contourPositions, - type: gl.FLOAT, - size: 3 - }]) - - var mesh = new SimplicialMesh(gl - , meshTexture - , triShader - , lineShader - , pointShader - , pickShader - , pointPickShader - , contourShader - , trianglePositions - , triangleVectors - , triangleIds - , triangleColors - , triangleUVs - , triangleNormals - , triangleVAO - , edgePositions - , edgeIds - , edgeColors - , edgeUVs - , edgeVAO - , pointPositions - , pointIds - , pointColors - , pointUVs - , pointSizes - , pointVAO - , contourPositions - , contourVAO) - - mesh.update(params) - - return mesh -} - -module.exports = createSimplicialMesh - -},{"./closest-point":298,"./shaders":299,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"normals":436,"simplicial-complex-contour":494,"typedarray-pool":522}],301:[function(_dereq_,module,exports){ -"use strict"; - -var vec3 = _dereq_('gl-vec3'); -var vec4 = _dereq_('gl-vec4'); - -var streamToTube = function(stream, maxDivergence, minDistance, maxNorm) { - var points = stream.points; - var velocities = stream.velocities; - var divergences = stream.divergences; - - var p, fwd, r, u, v, up; - up = vec3.set(vec3.create(), 0, 1, 0); - u = vec3.create(); - v = vec3.create(); - var p2 = vec3.create(); - - var verts = []; - var faces = []; - var vectors = []; - var previousVerts = []; - var currentVerts = []; - var intensities = []; - var previousIntensity = 0; - var currentIntensity = 0; - var currentVector = vec4.create(); - var previousVector = vec4.create(); - - var facets = 8; - - for (var i = 0; i < points.length; i++) { - p = points[i]; - fwd = velocities[i]; - r = divergences[i]; - if (maxDivergence === 0) { - r = minDistance * 0.05; - } - currentIntensity = vec3.length(fwd) / maxNorm; - currentVector = vec4.create(); - vec3.copy(currentVector, fwd); - currentVector[3] = r; - - for (var a = 0; a < facets; a++) { - currentVerts[a] = [p[0], p[1], p[2], a]; - } - if (previousVerts.length > 0) { - for (var a = 0; a < facets; a++) { - var a1 = (a+1) % facets; - verts.push( - previousVerts[a], - currentVerts[a], - currentVerts[a1], - - currentVerts[a1], - previousVerts[a1], - previousVerts[a] - ); - vectors.push( - previousVector, - currentVector, - currentVector, - - currentVector, - previousVector, - previousVector - ); - intensities.push( - previousIntensity, - currentIntensity, - currentIntensity, - - currentIntensity, - previousIntensity, - previousIntensity - ); - faces.push( - [verts.length-6, verts.length-5, verts.length-4], - [verts.length-3, verts.length-2, verts.length-1] - ); - } - } - var tmp = previousVerts; - previousVerts = currentVerts; - currentVerts = tmp; - tmp = previousVector; - previousVector = currentVector; - currentVector = tmp; - tmp = previousIntensity; - previousIntensity = currentIntensity; - currentIntensity = tmp; - } - return { - positions: verts, - cells: faces, - vectors: vectors, - vertexIntensity: intensities - }; - -}; - -var createTubes = function(streams, colormap, maxDivergence, minDistance) { - - var maxNorm = 0; - for (var i=0; i maxNorm) { - maxNorm = norm; - } - } - } - - var tubes = streams.map(function(s) { - return streamToTube(s, maxDivergence, minDistance, maxNorm); - }); - - var positions = []; - var cells = []; - var vectors = []; - var vertexIntensity = []; - for (var i=0; i < tubes.length; i++) { - var tube = tubes[i]; - var offset = positions.length; - positions = positions.concat(tube.positions); - vectors = vectors.concat(tube.vectors); - vertexIntensity = vertexIntensity.concat(tube.vertexIntensity); - for (var j=0; j v) return i-1; - } - return i; -}; - -var tmp = vec3.create(); -var tmp2 = vec3.create(); - -var clamp = function(v, min, max) { - return v < min ? min : (v > max ? max : v); -}; - -var sampleMeshgrid = function(point, array, meshgrid, clampOverflow) { - var x = point[0]; - var y = point[1]; - var z = point[2]; - - var w = meshgrid[0].length; - var h = meshgrid[1].length; - var d = meshgrid[2].length; - - // Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z). - // The nearest smaller value index for x is the index x0 such that - // meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x. - var x0 = findLastSmallerIndex(meshgrid[0], x); - var y0 = findLastSmallerIndex(meshgrid[1], y); - var z0 = findLastSmallerIndex(meshgrid[2], z); - - // Get the nearest larger meshgrid value indices. - // From the above "nearest smaller value", we know that - // meshgrid[0][x0] < x - // meshgrid[0][x0+1] >= x - var x1 = x0 + 1; - var y1 = y0 + 1; - var z1 = z0 + 1; - - if (meshgrid[0][x0] === x) x1 = x0; - if (meshgrid[1][y0] === y) y1 = y0; - if (meshgrid[2][z0] === z) z1 = z0; - - if (clampOverflow) { - x0 = clamp(x0, 0, w-1); - x1 = clamp(x1, 0, w-1); - y0 = clamp(y0, 0, h-1); - y1 = clamp(y1, 0, h-1); - z0 = clamp(z0, 0, d-1); - z1 = clamp(z1, 0, d-1); - } - - // Reject points outside the meshgrid, return a zero vector. - if (x0 < 0 || y0 < 0 || z0 < 0 || x1 >= w || y1 >= h || z1 >= d) { - return vec3.create(); - } - - // Normalize point coordinates to 0..1 scaling factor between x0 and x1. - var xf = (x - meshgrid[0][x0]) / (meshgrid[0][x1] - meshgrid[0][x0]); - var yf = (y - meshgrid[1][y0]) / (meshgrid[1][y1] - meshgrid[1][y0]); - var zf = (z - meshgrid[2][z0]) / (meshgrid[2][z1] - meshgrid[2][z0]); - - if (xf < 0 || xf > 1 || isNaN(xf)) xf = 0; - if (yf < 0 || yf > 1 || isNaN(yf)) yf = 0; - if (zf < 0 || zf > 1 || isNaN(zf)) zf = 0; - - var z0off = z0*w*h; - var z1off = z1*w*h; - - var y0off = y0*w; - var y1off = y1*w; - - var x0off = x0; - var x1off = x1; - - // Sample data array around the (x,y,z) point. - // vZYX = array[zZoff + yYoff + xXoff] - var v000 = array[y0off + z0off + x0off]; - var v001 = array[y0off + z0off + x1off]; - var v010 = array[y1off + z0off + x0off]; - var v011 = array[y1off + z0off + x1off]; - var v100 = array[y0off + z1off + x0off]; - var v101 = array[y0off + z1off + x1off]; - var v110 = array[y1off + z1off + x0off]; - var v111 = array[y1off + z1off + x1off]; - - var result = vec3.create(); - - // Average samples according to distance to point. - vec3.lerp(result, v000, v001, xf); - vec3.lerp(tmp, v010, v011, xf); - vec3.lerp(result, result, tmp, yf); - vec3.lerp(tmp, v100, v101, xf); - vec3.lerp(tmp2, v110, v111, xf); - vec3.lerp(tmp, tmp, tmp2, yf); - vec3.lerp(result, result, tmp, zf); - - return result; -}; - - -var vabs = function(dst, v) { - var x = v[0]; - var y = v[1]; - var z = v[2]; - dst[0] = x >= 0 ? x : -x; - dst[1] = y >= 0 ? y : -y; - dst[2] = z >= 0 ? z : -z; - return dst; -}; - -var findMinSeparation = function(xs) { - var minSeparation = 1/0; - xs.sort(function(a, b) { return a - b; }); - for (var i=1; i= minX && x <= maxX && - y >= minY && y <= maxY && - z >= minZ && z <= maxZ - ); - }; - - var boundsSize = vec3.distance(bounds[0], bounds[1]); - var maxStepSize = 10 * boundsSize / maxLength; - var maxStepSizeSq = maxStepSize * maxStepSize; - - var minDistance = 1; - var maxDivergence = 0; // For component-wise divergence vec3.create(); - var tmp = vec3.create(); - - if (positions.length >= 2) { - minDistance = calculateMinPositionDistance(positions); - } - - for (var i = 0; i < positions.length; i++) { - var p = vec3.create(); - vec3.copy(p, positions[i]); - - var stream = [p]; - var velocities = []; - var v = vectorField.getVelocity(p); - var op = p; - velocities.push(v); - - var divergences = []; - - var dv = vectorField.getDivergence(p, v); - var dvLength = vec3.length(dv); - if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { - maxDivergence = dvLength; - } - // In case we need to do component-wise divergence visualization - // vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); - divergences.push(dvLength); - - streams.push({points: stream, velocities: velocities, divergences: divergences}); - - var j = 0; - - while (j < maxLength * 100 && stream.length < maxLength && inBounds(bounds, p)) { - j++; - var np = vec3.clone(v); - var sqLen = vec3.squaredLength(np); - if (sqLen === 0) { - break; - } else if (sqLen > maxStepSizeSq) { - vec3.scale(np, np, maxStepSize / Math.sqrt(sqLen)); - } - vec3.add(np, np, p); - - v = vectorField.getVelocity(np); - - if (vec3.squaredDistance(op, np) - maxStepSizeSq > -0.0001 * maxStepSizeSq) { - stream.push(np); - op = np; - velocities.push(v); - var dv = vectorField.getDivergence(np, v); - var dvLength = vec3.length(dv); - if (dvLength > maxDivergence && !isNaN(dvLength) && isFinite(dvLength)) { - maxDivergence = dvLength; - } - // In case we need to do component-wise divergence visualization - //vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv)); - divergences.push(dvLength); - } - - p = np; - } - } - - // Replace NaNs and Infinities with non-NaN, finite maxDivergence - for (var i=0; i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color — in vertex or in fragment\n vec4 surfaceColor = step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) + step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]) -var contourVertSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]) -var pickSrc = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]) - -exports.createShader = function (gl) { - var shader = createShader(gl, vertSrc, fragSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'vec3'}, - {name: 'normal', type: 'vec3'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - shader.attributes.normal.location = 2 - return shader -} -exports.createPickShader = function (gl) { - var shader = createShader(gl, vertSrc, pickSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'vec3'}, - {name: 'normal', type: 'vec3'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - shader.attributes.normal.location = 2 - return shader -} -exports.createContourShader = function (gl) { - var shader = createShader(gl, contourVertSrc, fragSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'float'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - return shader -} -exports.createPickContourShader = function (gl) { - var shader = createShader(gl, contourVertSrc, pickSrc, null, [ - {name: 'uv', type: 'vec4'}, - {name: 'f', type: 'float'} - ]) - shader.attributes.uv.location = 0 - shader.attributes.f.location = 1 - return shader -} + var surface = new SurfacePlot( + gl, + [0, 0], // shape + [[0, 0, 0], [0, 0, 0]], // bounds + shader, + pickShader, + coordinateBuffer, + vao, + cmap, + contourShader, + contourPickShader, + contourBuffer, + contourVAO, + dynamicBuffer, + dynamicVAO, + [0, 0, 0] // objectOffset + ) -},{"gl-shader":288,"glslify":392}],303:[function(_dereq_,module,exports){ -'use strict' - -module.exports = createSurfacePlot - -var bits = _dereq_('bit-twiddle') -var createBuffer = _dereq_('gl-buffer') -var createVAO = _dereq_('gl-vao') -var createTexture = _dereq_('gl-texture2d') -var pool = _dereq_('typedarray-pool') -var colormap = _dereq_('colormap') -var ops = _dereq_('ndarray-ops') -var pack = _dereq_('ndarray-pack') -var ndarray = _dereq_('ndarray') -var surfaceNets = _dereq_('surface-nets') -var multiply = _dereq_('gl-mat4/multiply') -var invert = _dereq_('gl-mat4/invert') -var bsearch = _dereq_('binary-search-bounds') -var gradient = _dereq_('ndarray-gradient') -var shaders = _dereq_('./lib/shaders') - -var createShader = shaders.createShader -var createContourShader = shaders.createContourShader -var createPickShader = shaders.createPickShader -var createPickContourShader = shaders.createPickContourShader - -var SURFACE_VERTEX_SIZE = 4 * (4 + 3 + 3) - -var IDENTITY = [ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 ] - -var QUAD = [ - [0, 0], - [0, 1], - [1, 0], - [1, 1], - [1, 0], - [0, 1] -] - -var PERMUTATIONS = [ - [0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0] -] - -;(function () { - for (var i = 0; i < 3; ++i) { - var p = PERMUTATIONS[i] - var u = (i + 1) % 3 - var v = (i + 2) % 3 - p[u + 0] = 1 - p[v + 3] = 1 - p[i + 6] = 1 - } -})() - -function SurfacePickResult (position, index, uv, level, dataCoordinate) { - this.position = position - this.index = index - this.uv = uv - this.level = level - this.dataCoordinate = dataCoordinate -} - -var N_COLORS = 256 - -function genColormap (name) { - var x = pack([colormap({ - colormap: name, - nshades: N_COLORS, - format: 'rgba' - }).map(function (c) { - return [c[0], c[1], c[2], 255 * c[3]] - })]) - ops.divseq(x, 255.0) - return x -} - -function SurfacePlot ( - gl, - shape, - bounds, - shader, - pickShader, - coordinates, - vao, - colorMap, - contourShader, - contourPickShader, - contourBuffer, - contourVAO, - dynamicBuffer, - dynamicVAO) { - this.gl = gl - this.shape = shape - this.bounds = bounds - this.intensityBounds = []; - - this._shader = shader - this._pickShader = pickShader - this._coordinateBuffer = coordinates - this._vao = vao - this._colorMap = colorMap - - this._contourShader = contourShader - this._contourPickShader = contourPickShader - this._contourBuffer = contourBuffer - this._contourVAO = contourVAO - this._contourOffsets = [[], [], []] - this._contourCounts = [[], [], []] - this._vertexCount = 0 - - this._pickResult = new SurfacePickResult([0, 0, 0], [0, 0], [0, 0], [0, 0, 0], [0, 0, 0]) - - this._dynamicBuffer = dynamicBuffer - this._dynamicVAO = dynamicVAO - this._dynamicOffsets = [0, 0, 0] - this._dynamicCounts = [0, 0, 0] - - this.contourWidth = [ 1, 1, 1 ] - this.contourLevels = [[1], [1], [1]] - this.contourTint = [0, 0, 0] - this.contourColor = [[0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1]] - - this.showContour = true - this.showSurface = true - - this.enableHighlight = [true, true, true] - this.highlightColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]] - this.highlightTint = [ 1, 1, 1 ] - this.highlightLevel = [-1, -1, -1] - - // Dynamic contour options - this.enableDynamic = [ true, true, true ] - this.dynamicLevel = [ NaN, NaN, NaN ] - this.dynamicColor = [ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1] ] - this.dynamicTint = [ 1, 1, 1 ] - this.dynamicWidth = [ 1, 1, 1 ] - - this.axesBounds = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]] - this.surfaceProject = [ false, false, false ] - this.contourProject = [[ false, false, false ], - [ false, false, false ], - [ false, false, false ]] - - this.colorBounds = [ false, false ] - - // Store xyz fields, need this for picking - this._field = [ - ndarray(pool.mallocFloat(1024), [0, 0]), - ndarray(pool.mallocFloat(1024), [0, 0]), - ndarray(pool.mallocFloat(1024), [0, 0]) ] - - this.pickId = 1 - this.clipBounds = [[-Infinity, -Infinity, -Infinity], [Infinity, Infinity, Infinity]] - - this.snapToData = false - - this.opacity = 1.0 - - this.lightPosition = [10, 10000, 0] - this.ambientLight = 0.8 - this.diffuseLight = 0.8 - this.specularLight = 2.0 - this.roughness = 0.5 - this.fresnel = 1.5 - this.vertexColor = 0; - - this.dirty = true -} - -var proto = SurfacePlot.prototype - -proto.isTransparent = function () { - return this.opacity < 1 -} - -proto.isOpaque = function () { - if (this.opacity >= 1) { - return true - } - for (var i = 0; i < 3; ++i) { - if (this._contourCounts[i].length > 0 || this._dynamicCounts[i] > 0) { - return true - } - } - return false -} - -proto.pickSlots = 1 - -proto.setPickBase = function (id) { - this.pickId = id -} - -var ZERO_VEC = [0, 0, 0] - -var PROJECT_DATA = { - showSurface: false, - showContour: false, - projections: [IDENTITY.slice(), IDENTITY.slice(), IDENTITY.slice()], - clipBounds: [ - [[0, 0, 0], [0, 0, 0]], - [[0, 0, 0], [0, 0, 0]], - [[0, 0, 0], [0, 0, 0]]] -} - -function computeProjectionData (camera, obj) { - var i, j, k - - // Compute cube properties - var cubeAxis = (obj.axes && obj.axes.lastCubeProps.axis) || ZERO_VEC - - var showSurface = obj.showSurface - var showContour = obj.showContour - - for (i = 0; i < 3; ++i) { - showSurface = showSurface || obj.surfaceProject[i] - for (j = 0; j < 3; ++j) { - showContour = showContour || obj.contourProject[i][j] - } - } - - for (i = 0; i < 3; ++i) { - // Construct projection onto axis - var axisSquish = PROJECT_DATA.projections[i] - for (j = 0; j < 16; ++j) { - axisSquish[j] = 0 - } - for (j = 0; j < 4; ++j) { - axisSquish[5 * j] = 1 - } - axisSquish[5 * i] = 0 - axisSquish[12 + i] = obj.axesBounds[+(cubeAxis[i] > 0)][i] - multiply(axisSquish, camera.model, axisSquish) - - var nclipBounds = PROJECT_DATA.clipBounds[i] - for (k = 0; k < 2; ++k) { - for (j = 0; j < 3; ++j) { - nclipBounds[k][j] = camera.clipBounds[k][j] - } - } - nclipBounds[0][i] = -1e8 - nclipBounds[1][i] = 1e8 - } - - PROJECT_DATA.showSurface = showSurface - PROJECT_DATA.showContour = showContour - - return PROJECT_DATA -} - -var UNIFORMS = { - model: IDENTITY, - view: IDENTITY, - projection: IDENTITY, - inverseModel: IDENTITY.slice(), - lowerBound: [0, 0, 0], - upperBound: [0, 0, 0], - colorMap: 0, - clipBounds: [[0, 0, 0], [0, 0, 0]], - height: 0.0, - contourTint: 0, - contourColor: [0, 0, 0, 1], - permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], - zOffset: -1e-4, - kambient: 1, - kdiffuse: 1, - kspecular: 1, - lightPosition: [1000, 1000, 1000], - eyePosition: [0, 0, 0], - roughness: 1, - fresnel: 1, - opacity: 1, - vertexColor: 0 -} - -var MATRIX_INVERSE = IDENTITY.slice() -var DEFAULT_PERM = [1, 0, 0, 0, 1, 0, 0, 0, 1] - -function drawCore (params, transparent) { - params = params || {} - var gl = this.gl - - gl.disable(gl.CULL_FACE) - - this._colorMap.bind(0) - - var uniforms = UNIFORMS - uniforms.model = params.model || IDENTITY - uniforms.view = params.view || IDENTITY - uniforms.projection = params.projection || IDENTITY - uniforms.lowerBound = [this.bounds[0][0], this.bounds[0][1], this.colorBounds[0] || this.bounds[0][2]] - uniforms.upperBound = [this.bounds[1][0], this.bounds[1][1], this.colorBounds[1] || this.bounds[1][2]] - uniforms.contourColor = this.contourColor[0] - - uniforms.inverseModel = invert(uniforms.inverseModel, uniforms.model) - - for (var i = 0; i < 2; ++i) { - var clipClamped = uniforms.clipBounds[i] - for (var j = 0; j < 3; ++j) { - clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) - } - } - - uniforms.kambient = this.ambientLight - uniforms.kdiffuse = this.diffuseLight - uniforms.kspecular = this.specularLight - - uniforms.roughness = this.roughness - uniforms.fresnel = this.fresnel - uniforms.opacity = this.opacity - - uniforms.height = 0.0 - uniforms.permutation = DEFAULT_PERM - - uniforms.vertexColor = this.vertexColor - - // Compute camera matrix inverse - var invCameraMatrix = MATRIX_INVERSE - multiply(invCameraMatrix, uniforms.view, uniforms.model) - multiply(invCameraMatrix, uniforms.projection, invCameraMatrix) - invert(invCameraMatrix, invCameraMatrix) - - for (i = 0; i < 3; ++i) { - uniforms.eyePosition[i] = invCameraMatrix[12 + i] / invCameraMatrix[15] - } - - var w = invCameraMatrix[15] - for (i = 0; i < 3; ++i) { - w += this.lightPosition[i] * invCameraMatrix[4 * i + 3] - } - for (i = 0; i < 3; ++i) { - var s = invCameraMatrix[12 + i] - for (j = 0; j < 3; ++j) { - s += invCameraMatrix[4 * j + i] * this.lightPosition[j] - } - uniforms.lightPosition[i] = s / w - } - - var projectData = computeProjectionData(uniforms, this) - - if (projectData.showSurface && (transparent === (this.opacity < 1))) { - // Set up uniforms - this._shader.bind() - this._shader.uniforms = uniforms - - // Draw it - this._vao.bind() - - if (this.showSurface && this._vertexCount) { - this._vao.draw(gl.TRIANGLES, this._vertexCount) - } - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - if (!this.surfaceProject[i] || !this.vertexCount) { - continue - } - this._shader.uniforms.model = projectData.projections[i] - this._shader.uniforms.clipBounds = projectData.clipBounds[i] - this._vao.draw(gl.TRIANGLES, this._vertexCount) - } - - this._vao.unbind() - } - - if (projectData.showContour && !transparent) { - var shader = this._contourShader - - // Don't apply lighting to contours - uniforms.kambient = 1.0 - uniforms.kdiffuse = 0.0 - uniforms.kspecular = 0.0 - uniforms.opacity = 1.0 - - shader.bind() - shader.uniforms = uniforms - - // Draw contour lines - var vao = this._contourVAO - vao.bind() - - // Draw contour levels - for (i = 0; i < 3; ++i) { - shader.uniforms.permutation = PERMUTATIONS[i] - gl.lineWidth(this.contourWidth[i]) - - for (j = 0; j < this.contourLevels[i].length; ++j) { - if (j === this.highlightLevel[i]) { - shader.uniforms.contourColor = this.highlightColor[i] - shader.uniforms.contourTint = this.highlightTint[i] - } else if (j === 0 || (j - 1) === this.highlightLevel[i]) { - shader.uniforms.contourColor = this.contourColor[i] - shader.uniforms.contourTint = this.contourTint[i] - } - if (!this._contourCounts[i][j]) { - continue - } - shader.uniforms.height = this.contourLevels[i][j] - vao.draw(gl.LINES, this._contourCounts[i][j], this._contourOffsets[i][j]) - } - } - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - shader.uniforms.model = projectData.projections[i] - shader.uniforms.clipBounds = projectData.clipBounds[i] - for (j = 0; j < 3; ++j) { - if (!this.contourProject[i][j]) { - continue - } - shader.uniforms.permutation = PERMUTATIONS[j] - gl.lineWidth(this.contourWidth[j]) - for (var k = 0; k < this.contourLevels[j].length; ++k) { - if (k === this.highlightLevel[j]) { - shader.uniforms.contourColor = this.highlightColor[j] - shader.uniforms.contourTint = this.highlightTint[j] - } else if (k === 0 || (k - 1) === this.highlightLevel[j]) { - shader.uniforms.contourColor = this.contourColor[j] - shader.uniforms.contourTint = this.contourTint[j] - } - shader.uniforms.height = this.contourLevels[j][k] - vao.draw(gl.LINES, this._contourCounts[j][k], this._contourOffsets[j][k]) - } - } - } - vao.unbind() - - // Draw dynamic contours - vao = this._dynamicVAO - vao.bind() - - // Draw contour levels - for (i = 0; i < 3; ++i) { - if (this._dynamicCounts[i] === 0) { - continue - } - - shader.uniforms.model = uniforms.model - shader.uniforms.clipBounds = uniforms.clipBounds - shader.uniforms.permutation = PERMUTATIONS[i] - gl.lineWidth(this.dynamicWidth[i]) - - shader.uniforms.contourColor = this.dynamicColor[i] - shader.uniforms.contourTint = this.dynamicTint[i] - shader.uniforms.height = this.dynamicLevel[i] - vao.draw(gl.LINES, this._dynamicCounts[i], this._dynamicOffsets[i]) - - for (j = 0; j < 3; ++j) { - if (!this.contourProject[j][i]) { - continue - } - - shader.uniforms.model = projectData.projections[j] - shader.uniforms.clipBounds = projectData.clipBounds[j] - vao.draw(gl.LINES, this._dynamicCounts[i], this._dynamicOffsets[i]) - } - } - - vao.unbind() - } -} - -proto.draw = function (params) { - return drawCore.call(this, params, false) -} - -proto.drawTransparent = function (params) { - return drawCore.call(this, params, true) -} - -var PICK_UNIFORMS = { - model: IDENTITY, - view: IDENTITY, - projection: IDENTITY, - inverseModel: IDENTITY, - clipBounds: [[0, 0, 0], [0, 0, 0]], - height: 0.0, - shape: [0, 0], - pickId: 0, - lowerBound: [0, 0, 0], - upperBound: [0, 0, 0], - zOffset: 0.0, - permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], - lightPosition: [0, 0, 0], - eyePosition: [0, 0, 0] -} - -proto.drawPick = function (params) { - params = params || {} - var gl = this.gl - gl.disable(gl.CULL_FACE) - - var uniforms = PICK_UNIFORMS - uniforms.model = params.model || IDENTITY - uniforms.view = params.view || IDENTITY - uniforms.projection = params.projection || IDENTITY - uniforms.shape = this._field[2].shape - uniforms.pickId = this.pickId / 255.0 - uniforms.lowerBound = this.bounds[0] - uniforms.upperBound = this.bounds[1] - uniforms.permutation = DEFAULT_PERM - - for (var i = 0; i < 2; ++i) { - var clipClamped = uniforms.clipBounds[i] - for (var j = 0; j < 3; ++j) { - clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) - } - } - - var projectData = computeProjectionData(uniforms, this) - - if (projectData.showSurface) { - // Set up uniforms - this._pickShader.bind() - this._pickShader.uniforms = uniforms - - // Draw it - this._vao.bind() - this._vao.draw(gl.TRIANGLES, this._vertexCount) - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - if (!this.surfaceProject[i]) { - continue - } - this._pickShader.uniforms.model = projectData.projections[i] - this._pickShader.uniforms.clipBounds = projectData.clipBounds[i] - this._vao.draw(gl.TRIANGLES, this._vertexCount) - } - - this._vao.unbind() - } - - if (projectData.showContour) { - var shader = this._contourPickShader - - shader.bind() - shader.uniforms = uniforms - - var vao = this._contourVAO - vao.bind() - - for (j = 0; j < 3; ++j) { - gl.lineWidth(this.contourWidth[j]) - shader.uniforms.permutation = PERMUTATIONS[j] - for (i = 0; i < this.contourLevels[j].length; ++i) { - if (this._contourCounts[j][i]) { - shader.uniforms.height = this.contourLevels[j][i] - vao.draw(gl.LINES, this._contourCounts[j][i], this._contourOffsets[j][i]) - } - } - } - - // Draw projections of surface - for (i = 0; i < 3; ++i) { - shader.uniforms.model = projectData.projections[i] - shader.uniforms.clipBounds = projectData.clipBounds[i] - - for (j = 0; j < 3; ++j) { - if (!this.contourProject[i][j]) { - continue - } - - shader.uniforms.permutation = PERMUTATIONS[j] - gl.lineWidth(this.contourWidth[j]) - for (var k = 0; k < this.contourLevels[j].length; ++k) { - if (this._contourCounts[j][k]) { - shader.uniforms.height = this.contourLevels[j][k] - vao.draw(gl.LINES, this._contourCounts[j][k], this._contourOffsets[j][k]) - } - } - } - } - - vao.unbind() - } -} - -proto.pick = function (selection) { - if (!selection) { - return null - } - - if (selection.id !== this.pickId) { - return null - } - - var shape = this._field[2].shape - - var result = this._pickResult - - // Compute uv coordinate - var x = shape[0] * (selection.value[0] + (selection.value[2] >> 4) / 16.0) / 255.0 - var ix = Math.floor(x) - var fx = x - ix - - var y = shape[1] * (selection.value[1] + (selection.value[2] & 15) / 16.0) / 255.0 - var iy = Math.floor(y) - var fy = y - iy - - ix += 1 - iy += 1 - - // Compute xyz coordinate - var pos = result.position - pos[0] = pos[1] = pos[2] = 0 - for (var dx = 0; dx < 2; ++dx) { - var s = dx ? fx : 1.0 - fx - for (var dy = 0; dy < 2; ++dy) { - var t = dy ? fy : 1.0 - fy - - var r = ix + dx - var c = iy + dy - var w = s * t - - for (var i = 0; i < 3; ++i) { - pos[i] += this._field[i].get(r, c) * w - } - } - } - - // Find closest level - var levelIndex = this._pickResult.level - for (var j = 0; j < 3; ++j) { - levelIndex[j] = bsearch.le(this.contourLevels[j], pos[j]) - if (levelIndex[j] < 0) { - if (this.contourLevels[j].length > 0) { - levelIndex[j] = 0 - } - } else if (levelIndex[j] < this.contourLevels[j].length - 1) { - var a = this.contourLevels[j][levelIndex[j]] - var b = this.contourLevels[j][levelIndex[j] + 1] - if (Math.abs(a - pos[j]) > Math.abs(b - pos[j])) { - levelIndex[j] += 1 - } - } - } - - result.index[0] = fx < 0.5 ? ix : (ix + 1) - result.index[1] = fy < 0.5 ? iy : (iy + 1) - - result.uv[0] = x / shape[0] - result.uv[1] = y / shape[1] - - for (i = 0; i < 3; ++i) { - result.dataCoordinate[i] = this._field[i].get(result.index[0], result.index[1]) - } - - return result -} - -function padField (nfield, field) { - var shape = field.shape.slice() - var nshape = nfield.shape.slice() - - // Center - ops.assign(nfield.lo(1, 1).hi(shape[0], shape[1]), field) - - // Edges - ops.assign(nfield.lo(1).hi(shape[0], 1), - field.hi(shape[0], 1)) - ops.assign(nfield.lo(1, nshape[1] - 1).hi(shape[0], 1), - field.lo(0, shape[1] - 1).hi(shape[0], 1)) - ops.assign(nfield.lo(0, 1).hi(1, shape[1]), - field.hi(1)) - ops.assign(nfield.lo(nshape[0] - 1, 1).hi(1, shape[1]), - field.lo(shape[0] - 1)) - // Corners - nfield.set(0, 0, field.get(0, 0)) - nfield.set(0, nshape[1] - 1, field.get(0, shape[1] - 1)) - nfield.set(nshape[0] - 1, 0, field.get(shape[0] - 1, 0)) - nfield.set(nshape[0] - 1, nshape[1] - 1, field.get(shape[0] - 1, shape[1] - 1)) -} - -function handleArray (param, ctor) { - if (Array.isArray(param)) { - return [ ctor(param[0]), ctor(param[1]), ctor(param[2]) ] - } - return [ ctor(param), ctor(param), ctor(param) ] -} - -function toColor (x) { - if (Array.isArray(x)) { - if (x.length === 3) { - return [x[0], x[1], x[2], 1] - } - return [x[0], x[1], x[2], x[3]] - } - return [0, 0, 0, 1] -} - -function handleColor (param) { - if (Array.isArray(param)) { - if (Array.isArray(param)) { - return [ - toColor(param[0]), - toColor(param[1]), - toColor(param[2]) ] - } else { - var c = toColor(param) - return [ - c.slice(), - c.slice(), - c.slice() ] - } - } -} - -proto.update = function (params) { - params = params || {} - - this.dirty = true - - if ('contourWidth' in params) { - this.contourWidth = handleArray(params.contourWidth, Number) - } - if ('showContour' in params) { - this.showContour = handleArray(params.showContour, Boolean) - } - if ('showSurface' in params) { - this.showSurface = !!params.showSurface - } - if ('contourTint' in params) { - this.contourTint = handleArray(params.contourTint, Boolean) - } - if ('contourColor' in params) { - this.contourColor = handleColor(params.contourColor) - } - if ('contourProject' in params) { - this.contourProject = handleArray(params.contourProject, function (x) { - return handleArray(x, Boolean) - }) - } - if ('surfaceProject' in params) { - this.surfaceProject = params.surfaceProject - } - if ('dynamicColor' in params) { - this.dynamicColor = handleColor(params.dynamicColor) - } - if ('dynamicTint' in params) { - this.dynamicTint = handleArray(params.dynamicTint, Number) - } - if ('dynamicWidth' in params) { - this.dynamicWidth = handleArray(params.dynamicWidth, Number) - } - if ('opacity' in params) { - this.opacity = params.opacity - } - if ('colorBounds' in params) { - this.colorBounds = params.colorBounds - } - if ('vertexColor' in params) { - this.vertexColor = params.vertexColor ? 1 : 0; - } - - var field = params.field || (params.coords && params.coords[2]) || null - var levelsChanged = false - - if (!field) { - if (this._field[2].shape[0] || this._field[2].shape[2]) { - field = this._field[2].lo(1, 1).hi(this._field[2].shape[0] - 2, this._field[2].shape[1] - 2) - } else { - field = this._field[2].hi(0, 0) - } - } - - // Update field - if ('field' in params || 'coords' in params) { - var fsize = (field.shape[0] + 2) * (field.shape[1] + 2) - - // Resize if necessary - if (fsize > this._field[2].data.length) { - pool.freeFloat(this._field[2].data) - this._field[2].data = pool.mallocFloat(bits.nextPow2(fsize)) - } - - // Pad field - this._field[2] = ndarray(this._field[2].data, [field.shape[0] + 2, field.shape[1] + 2]) - padField(this._field[2], field) - - // Save shape of field - this.shape = field.shape.slice() - var shape = this.shape - - // Resize coordinate fields if necessary - for (var i = 0; i < 2; ++i) { - if (this._field[2].size > this._field[i].data.length) { - pool.freeFloat(this._field[i].data) - this._field[i].data = pool.mallocFloat(this._field[2].size) - } - this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2]) - } - - // Generate x/y coordinates - if (params.coords) { - var coords = params.coords - if (!Array.isArray(coords) || coords.length !== 3) { - throw new Error('gl-surface: invalid coordinates for x/y') - } - for (i = 0; i < 2; ++i) { - var coord = coords[i] - for (j = 0; j < 2; ++j) { - if (coord.shape[j] !== shape[j]) { - throw new Error('gl-surface: coords have incorrect shape') - } - } - padField(this._field[i], coord) - } - } else if (params.ticks) { - var ticks = params.ticks - if (!Array.isArray(ticks) || ticks.length !== 2) { - throw new Error('gl-surface: invalid ticks') - } - for (i = 0; i < 2; ++i) { - var tick = ticks[i] - if (Array.isArray(tick) || tick.length) { - tick = ndarray(tick) - } - if (tick.shape[0] !== shape[i]) { - throw new Error('gl-surface: invalid tick length') - } - // Make a copy view of the tick array - var tick2 = ndarray(tick.data, shape) - tick2.stride[i] = tick.stride[0] - tick2.stride[i ^ 1] = 0 - - // Fill in field array - padField(this._field[i], tick2) - } - } else { - for (i = 0; i < 2; ++i) { - var offset = [0, 0] - offset[i] = 1 - this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2], offset, 0) - } - this._field[0].set(0, 0, 0) - for (var j = 0; j < shape[0]; ++j) { - this._field[0].set(j + 1, 0, j) - } - this._field[0].set(shape[0] + 1, 0, shape[0] - 1) - this._field[1].set(0, 0, 0) - for (j = 0; j < shape[1]; ++j) { - this._field[1].set(0, j + 1, j) - } - this._field[1].set(0, shape[1] + 1, shape[1] - 1) - } - - // Save shape - var fields = this._field - - // Compute surface normals - var dfields = ndarray(pool.mallocFloat(fields[2].size * 3 * 2), [3, shape[0] + 2, shape[1] + 2, 2]) - for (i = 0; i < 3; ++i) { - gradient(dfields.pick(i), fields[i], 'mirror') - } - var normals = ndarray(pool.mallocFloat(fields[2].size * 3), [shape[0] + 2, shape[1] + 2, 3]) - for (i = 0; i < shape[0] + 2; ++i) { - for (j = 0; j < shape[1] + 2; ++j) { - var dxdu = dfields.get(0, i, j, 0) - var dxdv = dfields.get(0, i, j, 1) - var dydu = dfields.get(1, i, j, 0) - var dydv = dfields.get(1, i, j, 1) - var dzdu = dfields.get(2, i, j, 0) - var dzdv = dfields.get(2, i, j, 1) - - var nx = dydu * dzdv - dydv * dzdu - var ny = dzdu * dxdv - dzdv * dxdu - var nz = dxdu * dydv - dxdv * dydu - - var nl = Math.sqrt(nx * nx + ny * ny + nz * nz) - if (nl < 1e-8) { - nl = Math.max(Math.abs(nx), Math.abs(ny), Math.abs(nz)) - if (nl < 1e-8) { - nz = 1.0 - ny = nx = 0.0 - nl = 1.0 - } else { - nl = 1.0 / nl - } - } else { - nl = 1.0 / Math.sqrt(nl) - } - - normals.set(i, j, 0, nx * nl) - normals.set(i, j, 1, ny * nl) - normals.set(i, j, 2, nz * nl) - } - } - pool.free(dfields.data) - - // Initialize surface - var lo = [ Infinity, Infinity, Infinity ] - var hi = [ -Infinity, -Infinity, -Infinity ] - var lo_intensity = Infinity - var hi_intensity = -Infinity - var count = (shape[0] - 1) * (shape[1] - 1) * 6 - var tverts = pool.mallocFloat(bits.nextPow2(10 * count)) - var tptr = 0 - var vertexCount = 0 - for (i = 0; i < shape[0] - 1; ++i) { - j_loop: - for (j = 0; j < shape[1] - 1; ++j) { - // Test for NaNs - for (var dx = 0; dx < 2; ++dx) { - for (var dy = 0; dy < 2; ++dy) { - for (var k = 0; k < 3; ++k) { - var f = this._field[k].get(1 + i + dx, 1 + j + dy) - if (isNaN(f) || !isFinite(f)) { - continue j_loop - } - } - } - } - for (k = 0; k < 6; ++k) { - var r = i + QUAD[k][0] - var c = j + QUAD[k][1] - - var tx = this._field[0].get(r + 1, c + 1) - var ty = this._field[1].get(r + 1, c + 1) - f = this._field[2].get(r + 1, c + 1) - var vf = f - nx = normals.get(r + 1, c + 1, 0) - ny = normals.get(r + 1, c + 1, 1) - nz = normals.get(r + 1, c + 1, 2) - - if (params.intensity) { - vf = params.intensity.get(r, c) - } - - tverts[tptr++] = r - tverts[tptr++] = c - tverts[tptr++] = tx - tverts[tptr++] = ty - tverts[tptr++] = f - tverts[tptr++] = 0 - tverts[tptr++] = vf - tverts[tptr++] = nx - tverts[tptr++] = ny - tverts[tptr++] = nz - - lo[0] = Math.min(lo[0], tx) - lo[1] = Math.min(lo[1], ty) - lo[2] = Math.min(lo[2], f) - lo_intensity = Math.min(lo_intensity, vf) - - hi[0] = Math.max(hi[0], tx) - hi[1] = Math.max(hi[1], ty) - hi[2] = Math.max(hi[2], f) - hi_intensity = Math.max(hi_intensity, vf) - - vertexCount += 1 - } - } - } - - if (params.intensityBounds) { - lo_intensity = +params.intensityBounds[0] - hi_intensity = +params.intensityBounds[1] - } - - // Scale all vertex intensities - for (i = 6; i < tptr; i += 10) { - tverts[i] = (tverts[i] - lo_intensity) / (hi_intensity - lo_intensity) - } - - this._vertexCount = vertexCount - this._coordinateBuffer.update(tverts.subarray(0, tptr)) - pool.freeFloat(tverts) - pool.free(normals.data) - - // Update bounds - this.bounds = [lo, hi] - - // Save intensity - this.intensity = params.intensity || this._field[2] - - if(this.intensityBounds[0] !== lo_intensity || this.intensityBounds[1] !== hi_intensity) { - levelsChanged = true - } - - // Save intensity bound - this.intensityBounds = [lo_intensity, hi_intensity] - } - - // Update level crossings - if ('levels' in params) { - var levels = params.levels - if (!Array.isArray(levels[0])) { - levels = [ [], [], levels ] - } else { - levels = levels.slice() - } - for (i = 0; i < 3; ++i) { - levels[i] = levels[i].slice() - levels.sort(function (a, b) { - return a - b - }) - } - change_test: - for (i = 0; i < 3; ++i) { - if (levels[i].length !== this.contourLevels[i].length) { - levelsChanged = true - break - } - for (j = 0; j < levels[i].length; ++j) { - if (levels[i][j] !== this.contourLevels[i][j]) { - levelsChanged = true - break change_test - } - } - } - this.contourLevels = levels - } - - if (levelsChanged) { - fields = this._field - shape = this.shape - - // Update contour lines - var contourVerts = [] - - for (var dim = 0; dim < 3; ++dim) { - levels = this.contourLevels[dim] - var levelOffsets = [] - var levelCounts = [] - - var parts = [0, 0, 0] - - for (i = 0; i < levels.length; ++i) { - var graph = surfaceNets(this._field[dim], levels[i]) - levelOffsets.push((contourVerts.length / 5) | 0) - vertexCount = 0 - - edge_loop: - for (j = 0; j < graph.cells.length; ++j) { - var e = graph.cells[j] - for (k = 0; k < 2; ++k) { - var p = graph.positions[e[k]] - - var x = p[0] - var ix = Math.floor(x) | 0 - var fx = x - ix - - var y = p[1] - var iy = Math.floor(y) | 0 - var fy = y - iy - - var hole = false - dd_loop: - for (var dd = 0; dd < 3; ++dd) { - parts[dd] = 0.0 - var iu = (dim + dd + 1) % 3 - for (dx = 0; dx < 2; ++dx) { - var s = dx ? fx : 1.0 - fx - r = Math.min(Math.max(ix + dx, 0), shape[0]) | 0 - for (dy = 0; dy < 2; ++dy) { - var t = dy ? fy : 1.0 - fy - c = Math.min(Math.max(iy + dy, 0), shape[1]) | 0 - - if (dd < 2) { - f = this._field[iu].get(r, c) - } else { - f = (this.intensity.get(r, c) - this.intensityBounds[0]) / (this.intensityBounds[1] - this.intensityBounds[0]) - } - if (!isFinite(f) || isNaN(f)) { - hole = true - break dd_loop - } - - var w = s * t - parts[dd] += w * f - } - } - } - - if (!hole) { - contourVerts.push(parts[0], parts[1], p[0], p[1], parts[2]) - vertexCount += 1 - } else { - if (k > 0) { - // If we already added first edge, pop off verts - for (var l = 0; l < 5; ++l) { - contourVerts.pop() - } - vertexCount -= 1 - } - continue edge_loop - } - } - } - levelCounts.push(vertexCount) - } - - // Store results - this._contourOffsets[dim] = levelOffsets - this._contourCounts[dim] = levelCounts - } - - var floatBuffer = pool.mallocFloat(contourVerts.length) - for (i = 0; i < contourVerts.length; ++i) { - floatBuffer[i] = contourVerts[i] - } - this._contourBuffer.update(floatBuffer) - pool.freeFloat(floatBuffer) - } - - if (params.colormap) { - this._colorMap.setPixels(genColormap(params.colormap)) - } -} - -proto.dispose = function () { - this._shader.dispose() - this._vao.dispose() - this._coordinateBuffer.dispose() - this._colorMap.dispose() - this._contourBuffer.dispose() - this._contourVAO.dispose() - this._contourShader.dispose() - this._contourPickShader.dispose() - this._dynamicBuffer.dispose() - this._dynamicVAO.dispose() - for (var i = 0; i < 3; ++i) { - pool.freeFloat(this._field[i].data) - } -} - -proto.highlight = function (selection) { - if (!selection) { - this._dynamicCounts = [0, 0, 0] - this.dyanamicLevel = [NaN, NaN, NaN] - this.highlightLevel = [-1, -1, -1] - return - } - - for (var i = 0; i < 3; ++i) { - if (this.enableHighlight[i]) { - this.highlightLevel[i] = selection.level[i] - } else { - this.highlightLevel[i] = -1 - } - } - - var levels - if (this.snapToData) { - levels = selection.dataCoordinate - } else { - levels = selection.position - } - if ((!this.enableDynamic[0] || levels[0] === this.dynamicLevel[0]) && - (!this.enableDynamic[1] || levels[1] === this.dynamicLevel[1]) && - (!this.enableDynamic[2] || levels[2] === this.dynamicLevel[2])) { - return - } - - var vertexCount = 0 - var shape = this.shape - var scratchBuffer = pool.mallocFloat(12 * shape[0] * shape[1]) - - for (var d = 0; d < 3; ++d) { - if (!this.enableDynamic[d]) { - this.dynamicLevel[d] = NaN - this._dynamicCounts[d] = 0 - continue - } - - this.dynamicLevel[d] = levels[d] - - var u = (d + 1) % 3 - var v = (d + 2) % 3 - - var f = this._field[d] - var g = this._field[u] - var h = this._field[v] - var intensity = this.intensity - - var graph = surfaceNets(f, levels[d]) - var edges = graph.cells - var positions = graph.positions - - this._dynamicOffsets[d] = vertexCount - - for (i = 0; i < edges.length; ++i) { - var e = edges[i] - for (var j = 0; j < 2; ++j) { - var p = positions[e[j]] - - var x = +p[0] - var ix = x | 0 - var jx = Math.min(ix + 1, shape[0]) | 0 - var fx = x - ix - var hx = 1.0 - fx - - var y = +p[1] - var iy = y | 0 - var jy = Math.min(iy + 1, shape[1]) | 0 - var fy = y - iy - var hy = 1.0 - fy - - var w00 = hx * hy - var w01 = hx * fy - var w10 = fx * hy - var w11 = fx * fy - - var cu = w00 * g.get(ix, iy) + - w01 * g.get(ix, jy) + - w10 * g.get(jx, iy) + - w11 * g.get(jx, jy) - - var cv = w00 * h.get(ix, iy) + - w01 * h.get(ix, jy) + - w10 * h.get(jx, iy) + - w11 * h.get(jx, jy) - - if (isNaN(cu) || isNaN(cv)) { - if (j) { - vertexCount -= 1 - } - break - } - - scratchBuffer[2 * vertexCount + 0] = cu - scratchBuffer[2 * vertexCount + 1] = cv - - vertexCount += 1 - } - } - - this._dynamicCounts[d] = vertexCount - this._dynamicOffsets[d] - } - - this._dynamicBuffer.update(scratchBuffer.subarray(0, 2 * vertexCount)) - pool.freeFloat(scratchBuffer) -} - -function createSurfacePlot (params) { - var gl = params.gl - var shader = createShader(gl) - var pickShader = createPickShader(gl) - var contourShader = createContourShader(gl) - var contourPickShader = createPickContourShader(gl) - - var coordinateBuffer = createBuffer(gl) - var vao = createVAO(gl, [ - { buffer: coordinateBuffer, - size: 4, - stride: SURFACE_VERTEX_SIZE, - offset: 0 - }, - { buffer: coordinateBuffer, - size: 3, - stride: SURFACE_VERTEX_SIZE, - offset: 16 - }, - { - buffer: coordinateBuffer, - size: 3, - stride: SURFACE_VERTEX_SIZE, - offset: 28 - } - ]) - - var contourBuffer = createBuffer(gl) - var contourVAO = createVAO(gl, [ - { - buffer: contourBuffer, - size: 4, - stride: 20, - offset: 0 - }, - { - buffer: contourBuffer, - size: 1, - stride: 20, - offset: 16 - } - ]) - - var dynamicBuffer = createBuffer(gl) - var dynamicVAO = createVAO(gl, [ - { - buffer: dynamicBuffer, - size: 2, - type: gl.FLOAT - }]) - - var cmap = createTexture(gl, 1, N_COLORS, gl.RGBA, gl.UNSIGNED_BYTE) - cmap.minFilter = gl.LINEAR - cmap.magFilter = gl.LINEAR - - var surface = new SurfacePlot( - gl, - [0, 0], - [[0, 0, 0], [0, 0, 0]], - shader, - pickShader, - coordinateBuffer, - vao, - cmap, - contourShader, - contourPickShader, - contourBuffer, - contourVAO, - dynamicBuffer, - dynamicVAO - ) - - var nparams = { - levels: [[], [], []] - } - for (var id in params) { - nparams[id] = params[id] - } - nparams.colormap = nparams.colormap || 'jet' - - surface.update(nparams) - - return surface -} + var nparams = { + levels: [[], [], []] + } + for (var id in params) { + nparams[id] = params[id] + } + nparams.colormap = nparams.colormap || 'jet' + + surface.update(nparams) + + return surface +} -},{"./lib/shaders":302,"binary-search-bounds":79,"bit-twiddle":80,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"ndarray-gradient":424,"ndarray-ops":427,"ndarray-pack":428,"surface-nets":508,"typedarray-pool":522}],304:[function(_dereq_,module,exports){ +},{"./lib/shaders":302,"binary-search-bounds":79,"bit-twiddle":80,"colormap":114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-texture2d":305,"gl-vao":310,"ndarray":433,"ndarray-gradient":424,"ndarray-ops":427,"ndarray-pack":428,"surface-nets":507,"typedarray-pool":521}],304:[function(_dereq_,module,exports){ 'use strict' var Font = _dereq_('css-font') @@ -48467,7 +48578,7 @@ function isRegl (o) { module.exports = GlText -},{"bit-twiddle":80,"color-normalize":108,"css-font":127,"detect-kerning":151,"es6-weak-map":209,"flatten-vertex-data":216,"font-atlas":217,"font-measure":218,"gl-util/context":306,"is-plain-obj":405,"object-assign":437,"parse-rect":442,"parse-unit":444,"pick-by-alias":448,"regl":478,"to-px":516,"typedarray-pool":522}],305:[function(_dereq_,module,exports){ +},{"bit-twiddle":80,"color-normalize":108,"css-font":127,"detect-kerning":151,"es6-weak-map":209,"flatten-vertex-data":216,"font-atlas":217,"font-measure":218,"gl-util/context":306,"is-plain-obj":405,"object-assign":437,"parse-rect":442,"parse-unit":444,"pick-by-alias":448,"regl":478,"to-px":515,"typedarray-pool":521}],305:[function(_dereq_,module,exports){ 'use strict' var ndarray = _dereq_('ndarray') @@ -49030,7 +49141,7 @@ function createTexture2D(gl) { throw new Error('gl-texture2d: Invalid arguments for texture2d constructor') } -},{"ndarray":433,"ndarray-ops":427,"typedarray-pool":522}],306:[function(_dereq_,module,exports){ +},{"ndarray":433,"ndarray-ops":427,"typedarray-pool":521}],306:[function(_dereq_,module,exports){ /** @module gl-util/context */ 'use strict' @@ -53709,7 +53820,7 @@ function mouseWheelListen(element, callback, noScroll) { return listener } -},{"to-px":516}],422:[function(_dereq_,module,exports){ +},{"to-px":515}],422:[function(_dereq_,module,exports){ "use strict" var pool = _dereq_("typedarray-pool") @@ -54125,7 +54236,7 @@ function createSurfaceExtractor(args) { order, typesig) } -},{"typedarray-pool":522}],423:[function(_dereq_,module,exports){ +},{"typedarray-pool":521}],423:[function(_dereq_,module,exports){ "use strict" @@ -55794,7 +55905,7 @@ function compileSort(order, dtype) { } module.exports = compileSort -},{"typedarray-pool":522}],431:[function(_dereq_,module,exports){ +},{"typedarray-pool":521}],431:[function(_dereq_,module,exports){ "use strict" var compile = _dereq_("./lib/compile_sort.js") @@ -57491,7 +57602,7 @@ function permutationSign(p) { return sgn } } -},{"typedarray-pool":522}],447:[function(_dereq_,module,exports){ +},{"typedarray-pool":521}],447:[function(_dereq_,module,exports){ "use strict" var pool = _dereq_("typedarray-pool") @@ -57578,7 +57689,7 @@ function unrank(n, r, p) { exports.rank = rank exports.unrank = unrank -},{"invert-permutation":398,"typedarray-pool":522}],448:[function(_dereq_,module,exports){ +},{"invert-permutation":398,"typedarray-pool":521}],448:[function(_dereq_,module,exports){ 'use strict' @@ -58049,7 +58160,7 @@ function planarGraphToPolyline(edges, positions) { return result } -},{"./lib/trim-leaves":450,"edges-to-adjacency-list":157,"planar-dual":449,"point-in-big-polygon":455,"robust-sum":491,"two-product":520,"uniq":524}],452:[function(_dereq_,module,exports){ +},{"./lib/trim-leaves":450,"edges-to-adjacency-list":157,"planar-dual":449,"point-in-big-polygon":455,"robust-sum":491,"two-product":519,"uniq":523}],452:[function(_dereq_,module,exports){ 'use strict' module.exports = _dereq_('./quad') @@ -61222,7 +61333,7 @@ function Error2D (regl, options) { meshBuffer.destroy() } } -},{"array-bounds":53,"color-normalize":108,"flatten-vertex-data":216,"object-assign":437,"pick-by-alias":448,"to-float32":515,"update-diff":526}],474:[function(_dereq_,module,exports){ +},{"array-bounds":53,"color-normalize":108,"flatten-vertex-data":216,"object-assign":437,"pick-by-alias":448,"to-float32":514,"update-diff":525}],474:[function(_dereq_,module,exports){ 'use strict' @@ -61951,254 +62062,1016 @@ Line2D.prototype.destroy = function () { return this } -},{"array-bounds":53,"array-normalize":54,"color-normalize":108,"earcut":156,"es6-weak-map":209,"flatten-vertex-data":216,"glslify":392,"object-assign":437,"parse-rect":442,"pick-by-alias":448,"to-float32":515}],475:[function(_dereq_,module,exports){ +},{"array-bounds":53,"array-normalize":54,"color-normalize":108,"earcut":156,"es6-weak-map":209,"flatten-vertex-data":216,"glslify":392,"object-assign":437,"parse-rect":442,"pick-by-alias":448,"to-float32":514}],475:[function(_dereq_,module,exports){ +'use strict'; + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance"); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} + +var rgba = _dereq_('color-normalize'); + +var getBounds = _dereq_('array-bounds'); + +var colorId = _dereq_('color-id'); + +var cluster = _dereq_('point-cluster'); + +var extend = _dereq_('object-assign'); + +var glslify = _dereq_('glslify'); + +var pick = _dereq_('pick-by-alias'); + +var updateDiff = _dereq_('update-diff'); + +var flatten = _dereq_('flatten-vertex-data'); + +var ie = _dereq_('is-iexplorer'); + +var f32 = _dereq_('to-float32'); + +var parseRect = _dereq_('parse-rect'); + +var scatter = Scatter; + +function Scatter(regl, options) { + var _this = this; + + if (!(this instanceof Scatter)) return new Scatter(regl, options); + + if (typeof regl === 'function') { + if (!options) options = {}; + options.regl = regl; + } else { + options = regl; + regl = null; + } + + if (options && options.length) options.positions = options; + regl = options.regl; // persistent variables + + var gl = regl._gl, + paletteTexture, + palette = [], + paletteIds = {}, + // state + groups = [], + // textures for marker keys + markerTextures = [null], + markerCache = [null]; + var maxColors = 255, + maxSize = 100; // direct color buffer mode + // IE does not support palette anyways + + this.tooManyColors = ie; // texture with color palette + + paletteTexture = regl.texture({ + data: new Uint8Array(maxColors * 4), + width: maxColors, + height: 1, + type: 'uint8', + format: 'rgba', + wrapS: 'clamp', + wrapT: 'clamp', + mag: 'nearest', + min: 'nearest' + }); + extend(this, { + regl: regl, + gl: gl, + groups: groups, + markerCache: markerCache, + markerTextures: markerTextures, + palette: palette, + paletteIds: paletteIds, + paletteTexture: paletteTexture, + maxColors: maxColors, + maxSize: maxSize, + canvas: gl.canvas + }); + this.update(options); // common shader options + + var shaderOptions = { + uniforms: { + pixelRatio: regl.context('pixelRatio'), + palette: paletteTexture, + paletteSize: function paletteSize(ctx, prop) { + return [_this.tooManyColors ? 0 : maxColors, paletteTexture.height]; + }, + scale: regl.prop('scale'), + scaleFract: regl.prop('scaleFract'), + translate: regl.prop('translate'), + translateFract: regl.prop('translateFract'), + opacity: regl.prop('opacity'), + marker: regl.prop('markerTexture') + }, + attributes: { + // FIXME: optimize these parts + x: function x(ctx, prop) { + return prop.xAttr || { + buffer: prop.positionBuffer, + stride: 8, + offset: 0 + }; + }, + y: function y(ctx, prop) { + return prop.yAttr || { + buffer: prop.positionBuffer, + stride: 8, + offset: 4 + }; + }, + xFract: function xFract(ctx, prop) { + return prop.xAttr ? { + constant: [0, 0] + } : { + buffer: prop.positionFractBuffer, + stride: 8, + offset: 0 + }; + }, + yFract: function yFract(ctx, prop) { + return prop.yAttr ? { + constant: [0, 0] + } : { + buffer: prop.positionFractBuffer, + stride: 8, + offset: 4 + }; + }, + size: function size(ctx, prop) { + return prop.size.length ? { + buffer: prop.sizeBuffer, + stride: 2, + offset: 0 + } : { + constant: [Math.round(prop.size * 255 / _this.maxSize)] + }; + }, + borderSize: function borderSize(ctx, prop) { + return prop.borderSize.length ? { + buffer: prop.sizeBuffer, + stride: 2, + offset: 1 + } : { + constant: [Math.round(prop.borderSize * 255 / _this.maxSize)] + }; + }, + colorId: function colorId(ctx, prop) { + return prop.color.length ? { + buffer: prop.colorBuffer, + stride: _this.tooManyColors ? 8 : 4, + offset: 0 + } : { + constant: _this.tooManyColors ? palette.slice(prop.color * 4, prop.color * 4 + 4) : [prop.color] + }; + }, + borderColorId: function borderColorId(ctx, prop) { + return prop.borderColor.length ? { + buffer: prop.colorBuffer, + stride: _this.tooManyColors ? 8 : 4, + offset: _this.tooManyColors ? 4 : 2 + } : { + constant: _this.tooManyColors ? palette.slice(prop.borderColor * 4, prop.borderColor * 4 + 4) : [prop.borderColor] + }; + }, + isActive: function isActive(ctx, prop) { + return prop.activation === true ? { + constant: [1] + } : prop.activation ? prop.activation : { + constant: [0] + }; + } + }, + blend: { + enable: true, + color: [0, 0, 0, 1], + // photoshop blending + func: { + srcRGB: 'src alpha', + dstRGB: 'one minus src alpha', + srcAlpha: 'one minus dst alpha', + dstAlpha: 'one' + } + }, + scissor: { + enable: true, + box: regl.prop('viewport') + }, + viewport: regl.prop('viewport'), + stencil: { + enable: false + }, + depth: { + enable: false + }, + elements: regl.prop('elements'), + count: regl.prop('count'), + offset: regl.prop('offset'), + primitive: 'points' // draw sdf-marker + + }; + var markerOptions = extend({}, shaderOptions); + markerOptions.frag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragWidth, fragBorderColorLevel, fragColorLevel;\n\nuniform sampler2D marker;\nuniform float pixelRatio, opacity;\n\nfloat smoothStep(float x, float y) {\n return 1.0 / (1.0 + exp(50.0*(x - y)));\n}\n\nvoid main() {\n float dist = texture2D(marker, gl_PointCoord).r, delta = fragWidth;\n\n // max-distance alpha\n if (dist < 0.003) discard;\n\n // null-border case\n if (fragBorderColorLevel == fragColorLevel || fragBorderColor.a == 0.) {\n float colorAmt = smoothstep(.5 - delta, .5 + delta, dist);\n gl_FragColor = vec4(fragColor.rgb, colorAmt * fragColor.a * opacity);\n }\n else {\n float borderColorAmt = smoothstep(fragBorderColorLevel - delta, fragBorderColorLevel + delta, dist);\n float colorAmt = smoothstep(fragColorLevel - delta, fragColorLevel + delta, dist);\n\n vec4 color = fragBorderColor;\n color.a *= borderColorAmt;\n color = mix(color, fragColor, colorAmt);\n color.a *= opacity;\n\n gl_FragColor = color;\n }\n\n}\n"]); + markerOptions.vert = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract, paletteSize;\nuniform float pixelRatio;\nuniform sampler2D palette;\n\nconst float maxSize = 100.;\nconst float borderLevel = .5;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragPointSize, fragBorderRadius, fragWidth, fragBorderColorLevel, fragColorLevel;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = 2. * size * pixelRatio;\n fragPointSize = size * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragColor = color;\n fragBorderColor = borderColor;\n fragWidth = 1. / gl_PointSize;\n\n fragBorderColorLevel = clamp(borderLevel - borderLevel * borderSize / size, 0., 1.);\n fragColorLevel = clamp(borderLevel + (1. - borderLevel) * borderSize / size, 0., 1.);\n}"]); + this.drawMarker = regl(markerOptions); // draw circle + + var circleOptions = extend({}, shaderOptions); + circleOptions.frag = glslify(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\n\nuniform float opacity;\nvarying float fragBorderRadius, fragWidth;\n\nfloat smoothStep(float edge0, float edge1, float x) {\n\tfloat t;\n\tt = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n\treturn t * t * (3.0 - 2.0 * t);\n}\n\nvoid main() {\n\tfloat radius, alpha = 1.0, delta = fragWidth;\n\n\tradius = length(2.0 * gl_PointCoord.xy - 1.0);\n\n\tif (radius > 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]); + circleOptions.vert = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]); // polyfill IE + + if (ie) { + circleOptions.frag = circleOptions.frag.replace('smoothstep', 'smoothStep'); + markerOptions.frag = markerOptions.frag.replace('smoothstep', 'smoothStep'); + } + + this.drawCircle = regl(circleOptions); +} // single pass defaults + + +Scatter.defaults = { + color: 'black', + borderColor: 'transparent', + borderSize: 0, + size: 12, + opacity: 1, + marker: undefined, + viewport: null, + range: null, + pixelSize: null, + count: 0, + offset: 0, + bounds: null, + positions: [], + snap: 1e4 // update & redraw + +}; + +Scatter.prototype.render = function () { + if (arguments.length) { + this.update.apply(this, arguments); + } + + this.draw(); + return this; +}; // draw all groups or only indicated ones + + +Scatter.prototype.draw = function () { + var _this2 = this; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var groups = this.groups; // if directly array passed - treat as passes + + if (args.length === 1 && Array.isArray(args[0]) && (args[0][0] === null || Array.isArray(args[0][0]))) { + args = args[0]; + } // FIXME: remove once https://github.com/regl-project/regl/issues/474 resolved + + + this.regl._refresh(); + + if (args.length) { + for (var i = 0; i < args.length; i++) { + this.drawItem(i, args[i]); + } + } // draw all passes + else { + groups.forEach(function (group, i) { + _this2.drawItem(i); + }); + } + + return this; +}; // draw specific scatter group + + +Scatter.prototype.drawItem = function (id, els) { + var groups = this.groups; + var group = groups[id]; // debug viewport + // let { viewport } = group + // gl.enable(gl.SCISSOR_TEST); + // gl.scissor(viewport.x, viewport.y, viewport.width, viewport.height); + // gl.clearColor(0, 0, 0, .5); + // gl.clear(gl.COLOR_BUFFER_BIT); + + if (typeof els === 'number') { + id = els; + group = groups[els]; + els = null; + } + + if (!(group && group.count && group.opacity)) return; // draw circles + + if (group.activation[0]) { + // TODO: optimize this performance by making groups and regl.this props + this.drawCircle(this.getMarkerDrawOptions(0, group, els)); + } // draw all other available markers + + + var batch = []; + + for (var i = 1; i < group.activation.length; i++) { + if (!group.activation[i] || group.activation[i] !== true && !group.activation[i].data.length) continue; + batch.push.apply(batch, _toConsumableArray(this.getMarkerDrawOptions(i, group, els))); + } + + if (batch.length) { + this.drawMarker(batch); + } +}; // get options for the marker ids + + +Scatter.prototype.getMarkerDrawOptions = function (markerId, group, elements) { + var range = group.range, + tree = group.tree, + viewport = group.viewport, + activation = group.activation, + selectionBuffer = group.selectionBuffer, + count = group.count; + var regl = this.regl; // direct points + + if (!tree) { + // if elements array - draw unclustered points + if (elements) { + return [extend({}, group, { + markerTexture: this.markerTextures[markerId], + activation: activation[markerId], + count: elements.length, + elements: elements, + offset: 0 + })]; + } + + return [extend({}, group, { + markerTexture: this.markerTextures[markerId], + activation: activation[markerId], + offset: 0 + })]; + } // clustered points + + + var batch = []; + var lod = tree.range(range, { + lod: true, + px: [(range[2] - range[0]) / viewport.width, (range[3] - range[1]) / viewport.height] + }); // enable elements by using selection buffer + + if (elements) { + var markerActivation = activation[markerId]; + var mask = markerActivation.data; + var data = new Uint8Array(count); + + for (var i = 0; i < elements.length; i++) { + var id = elements[i]; + data[id] = mask ? mask[id] : 1; + } + + selectionBuffer.subdata(data); + } + + for (var l = lod.length; l--;) { + var _lod$l = _slicedToArray(lod[l], 2), + from = _lod$l[0], + to = _lod$l[1]; + + batch.push(extend({}, group, { + markerTexture: this.markerTextures[markerId], + activation: elements ? selectionBuffer : activation[markerId], + offset: from, + count: to - from + })); + } + + return batch; +}; // update groups options + + +Scatter.prototype.update = function () { + var _this3 = this; + + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + if (!args.length) return; // passes are as single array + + if (args.length === 1 && Array.isArray(args[0])) args = args[0]; + var groups = this.groups, + gl = this.gl, + regl = this.regl, + maxSize = this.maxSize, + maxColors = this.maxColors, + palette = this.palette; + this.groups = groups = args.map(function (options, i) { + var group = groups[i]; + if (options === undefined) return group; + if (options === null) options = { + positions: null + };else if (typeof options === 'function') options = { + ondraw: options + };else if (typeof options[0] === 'number') options = { + positions: options // copy options to avoid mutation & handle aliases + + }; + options = pick(options, { + positions: 'positions data points', + snap: 'snap cluster lod tree', + size: 'sizes size radius', + borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', + color: 'colors color fill fill-color fillColor', + borderColor: 'borderColors borderColor stroke stroke-color strokeColor', + marker: 'markers marker shape', + range: 'range dataBox databox', + viewport: 'viewport viewPort viewBox viewbox', + opacity: 'opacity alpha transparency', + bounds: 'bound bounds boundaries limits', + tooManyColors: 'tooManyColors palette paletteMode optimizePalette enablePalette' + }); + if (options.positions === null) options.positions = []; + if (options.tooManyColors != null) _this3.tooManyColors = options.tooManyColors; + + if (!group) { + groups[i] = group = { + id: i, + scale: null, + translate: null, + scaleFract: null, + translateFract: null, + // buffers for active markers + activation: [], + // buffer for filtered markers + selectionBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'stream', + type: 'uint8' + }), + // buffers with data: it is faster to switch them per-pass + // than provide one congregate buffer + sizeBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'uint8' + }), + colorBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'uint8' + }), + positionBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'float' + }), + positionFractBuffer: regl.buffer({ + data: new Uint8Array(0), + usage: 'dynamic', + type: 'float' + }) + }; + options = extend({}, Scatter.defaults, options); + } // force update triggers + + + if (options.positions && !('marker' in options)) { + options.marker = group.marker; + delete group.marker; + } // updating markers cause recalculating snapping + + + if (options.marker && !('positions' in options)) { + options.positions = group.positions; + delete group.positions; + } // global count of points + + + var hasSize = 0, + hasColor = 0; + updateDiff(group, options, [{ + snap: true, + size: function size(s, group) { + if (s == null) s = Scatter.defaults.size; + hasSize += s && s.length ? 1 : 0; + return s; + }, + borderSize: function borderSize(s, group) { + if (s == null) s = Scatter.defaults.borderSize; + hasSize += s && s.length ? 1 : 0; + return s; + }, + opacity: parseFloat, + // add colors to palette, save references + color: function color(c, group) { + if (c == null) c = Scatter.defaults.color; + c = _this3.updateColor(c); + hasColor++; + return c; + }, + borderColor: function borderColor(c, group) { + if (c == null) c = Scatter.defaults.borderColor; + c = _this3.updateColor(c); + hasColor++; + return c; + }, + bounds: function bounds(_bounds, group, options) { + if (!('range' in options)) options.range = null; + return _bounds; + }, + positions: function positions(_positions, group, options) { + var snap = group.snap; + var positionBuffer = group.positionBuffer, + positionFractBuffer = group.positionFractBuffer, + selectionBuffer = group.selectionBuffer; // separate buffers for x/y coordinates + + if (_positions.x || _positions.y) { + if (_positions.x.length) { + group.xAttr = { + buffer: regl.buffer(_positions.x), + offset: 0, + stride: 4, + count: _positions.x.length + }; + } else { + group.xAttr = { + buffer: _positions.x.buffer, + offset: _positions.x.offset * 4 || 0, + stride: (_positions.x.stride || 1) * 4, + count: _positions.x.count + }; + } + + if (_positions.y.length) { + group.yAttr = { + buffer: regl.buffer(_positions.y), + offset: 0, + stride: 4, + count: _positions.y.length + }; + } else { + group.yAttr = { + buffer: _positions.y.buffer, + offset: _positions.y.offset * 4 || 0, + stride: (_positions.y.stride || 1) * 4, + count: _positions.y.count + }; + } + + group.count = Math.max(group.xAttr.count, group.yAttr.count); + return _positions; + } + + _positions = flatten(_positions, 'float64'); + var count = group.count = Math.floor(_positions.length / 2); + var bounds = group.bounds = count ? getBounds(_positions, 2) : null; // if range is not provided updated - recalc it + + if (!options.range && !group.range) { + delete group.range; + options.range = bounds; + } // reset marker + + + if (!options.marker && !group.marker) { + delete group.marker; + options.marker = null; + } // build cluster tree if required + + + if (snap && (snap === true || count > snap)) { + group.tree = cluster(_positions, { + bounds: bounds + }); + } // existing tree instance + else if (snap && snap.length) { + group.tree = snap; + } + + if (group.tree) { + var opts = { + primitive: 'points', + usage: 'static', + data: group.tree, + type: 'uint32' + }; + if (group.elements) group.elements(opts);else group.elements = regl.elements(opts); + } // update position buffers + + + positionBuffer({ + data: f32.float(_positions), + usage: 'dynamic' + }); + positionFractBuffer({ + data: f32.fract(_positions), + usage: 'dynamic' + }); // expand selectionBuffer + + selectionBuffer({ + data: new Uint8Array(count), + type: 'uint8', + usage: 'stream' + }); + return _positions; + } + }, { + // create marker ids corresponding to known marker textures + marker: function marker(markers, group, options) { + var activation = group.activation; // reset marker elements + + activation.forEach(function (buffer) { + return buffer && buffer.destroy && buffer.destroy(); + }); + activation.length = 0; // single sdf marker + + if (!markers || typeof markers[0] === 'number') { + var id = _this3.addMarker(markers); + + activation[id] = true; + } // per-point markers use mask buffers to enable markers in vert shader + else { + var markerMasks = []; + + for (var _i = 0, l = Math.min(markers.length, group.count); _i < l; _i++) { + var _id = _this3.addMarker(markers[_i]); + + if (!markerMasks[_id]) markerMasks[_id] = new Uint8Array(group.count); // enable marker by default + + markerMasks[_id][_i] = 1; + } + + for (var _id2 = 0; _id2 < markerMasks.length; _id2++) { + if (!markerMasks[_id2]) continue; + var opts = { + data: markerMasks[_id2], + type: 'uint8', + usage: 'static' + }; + + if (!activation[_id2]) { + activation[_id2] = regl.buffer(opts); + } else { + activation[_id2](opts); + } + + activation[_id2].data = markerMasks[_id2]; + } + } + + return markers; + }, + range: function range(_range, group, options) { + var bounds = group.bounds; // FIXME: why do we need this? + + if (!bounds) return; + if (!_range) _range = bounds; + group.scale = [1 / (_range[2] - _range[0]), 1 / (_range[3] - _range[1])]; + group.translate = [-_range[0], -_range[1]]; + group.scaleFract = f32.fract(group.scale); + group.translateFract = f32.fract(group.translate); + return _range; + }, + viewport: function viewport(vp) { + var rect = parseRect(vp || [gl.drawingBufferWidth, gl.drawingBufferHeight]); // normalize viewport to the canvas coordinates + // rect.y = gl.drawingBufferHeight - rect.height - rect.y + + return rect; + } + }]); // update size buffer, if needed + + if (hasSize) { + var _group = group, + count = _group.count, + size = _group.size, + borderSize = _group.borderSize, + sizeBuffer = _group.sizeBuffer; + var sizes = new Uint8Array(count * 2); + + if (size.length || borderSize.length) { + for (var _i2 = 0; _i2 < count; _i2++) { + // we downscale size to allow for fractions + sizes[_i2 * 2] = Math.round((size[_i2] == null ? size : size[_i2]) * 255 / maxSize); + sizes[_i2 * 2 + 1] = Math.round((borderSize[_i2] == null ? borderSize : borderSize[_i2]) * 255 / maxSize); + } + } + + sizeBuffer({ + data: sizes, + usage: 'dynamic' + }); + } // update color buffer if needed + + + if (hasColor) { + var _group2 = group, + _count = _group2.count, + color = _group2.color, + borderColor = _group2.borderColor, + colorBuffer = _group2.colorBuffer; + var colors; // if too many colors - put colors to buffer directly + + if (_this3.tooManyColors) { + if (color.length || borderColor.length) { + colors = new Uint8Array(_count * 8); + + for (var _i3 = 0; _i3 < _count; _i3++) { + var _colorId = color[_i3]; + colors[_i3 * 8] = palette[_colorId * 4]; + colors[_i3 * 8 + 1] = palette[_colorId * 4 + 1]; + colors[_i3 * 8 + 2] = palette[_colorId * 4 + 2]; + colors[_i3 * 8 + 3] = palette[_colorId * 4 + 3]; + var borderColorId = borderColor[_i3]; + colors[_i3 * 8 + 4] = palette[borderColorId * 4]; + colors[_i3 * 8 + 5] = palette[borderColorId * 4 + 1]; + colors[_i3 * 8 + 6] = palette[borderColorId * 4 + 2]; + colors[_i3 * 8 + 7] = palette[borderColorId * 4 + 3]; + } + } + } // if limited amount of colors - keep palette color picking + // that saves significant memory + else { + if (color.length || borderColor.length) { + // we need slight data increase by 2 due to vec4 borderId in shader + colors = new Uint8Array(_count * 4 + 2); + + for (var _i4 = 0; _i4 < _count; _i4++) { + // put color coords in palette texture + if (color[_i4] != null) { + colors[_i4 * 4] = color[_i4] % maxColors; + colors[_i4 * 4 + 1] = Math.floor(color[_i4] / maxColors); + } + + if (borderColor[_i4] != null) { + colors[_i4 * 4 + 2] = borderColor[_i4] % maxColors; + colors[_i4 * 4 + 3] = Math.floor(borderColor[_i4] / maxColors); + } + } + } + } + + colorBuffer({ + data: colors || new Uint8Array(0), + type: 'uint8', + usage: 'dynamic' + }); + } + + return group; + }); +}; // get (and create) marker texture id + + +Scatter.prototype.addMarker = function (sdf) { + var markerTextures = this.markerTextures, + regl = this.regl, + markerCache = this.markerCache; + var pos = sdf == null ? 0 : markerCache.indexOf(sdf); + if (pos >= 0) return pos; // convert sdf to 0..255 range + + var distArr; + + if (sdf instanceof Uint8Array || sdf instanceof Uint8ClampedArray) { + distArr = sdf; + } else { + distArr = new Uint8Array(sdf.length); + + for (var i = 0, l = sdf.length; i < l; i++) { + distArr[i] = sdf[i] * 255; + } + } + + var radius = Math.floor(Math.sqrt(distArr.length)); + pos = markerTextures.length; + markerCache.push(sdf); + markerTextures.push(regl.texture({ + channels: 1, + data: distArr, + radius: radius, + mag: 'linear', + min: 'linear' + })); + return pos; +}; // register color to palette, return it's index or list of indexes + + +Scatter.prototype.updateColor = function (colors) { + var paletteIds = this.paletteIds, + palette = this.palette, + maxColors = this.maxColors; + + if (!Array.isArray(colors)) { + colors = [colors]; + } + + var idx = []; // if color groups - flatten them + + if (typeof colors[0] === 'number') { + var grouped = []; + + if (Array.isArray(colors)) { + for (var i = 0; i < colors.length; i += 4) { + grouped.push(colors.slice(i, i + 4)); + } + } else { + for (var _i5 = 0; _i5 < colors.length; _i5 += 4) { + grouped.push(colors.subarray(_i5, _i5 + 4)); + } + } + + colors = grouped; + } + + for (var _i6 = 0; _i6 < colors.length; _i6++) { + var color = colors[_i6]; + color = rgba(color, 'uint8'); + var id = colorId(color, false); // if new color - save it + + if (paletteIds[id] == null) { + var pos = palette.length; + paletteIds[id] = Math.floor(pos / 4); + palette[pos] = color[0]; + palette[pos + 1] = color[1]; + palette[pos + 2] = color[2]; + palette[pos + 3] = color[3]; + } + + idx[_i6] = paletteIds[id]; + } // detect if too many colors in palette + + + if (!this.tooManyColors && palette.length > maxColors * 4) this.tooManyColors = true; // limit max color + + this.updatePalette(palette); // keep static index for single-color property + + return idx.length === 1 ? idx[0] : idx; +}; + +Scatter.prototype.updatePalette = function (palette) { + if (this.tooManyColors) return; + var maxColors = this.maxColors, + paletteTexture = this.paletteTexture; + var requiredHeight = Math.ceil(palette.length * .25 / maxColors); // pad data + + if (requiredHeight > 1) { + palette = palette.slice(); + + for (var i = palette.length * .25 % maxColors; i < requiredHeight * maxColors; i++) { + palette.push(0, 0, 0, 0); + } + } // ensure height + + + if (paletteTexture.height < requiredHeight) { + paletteTexture.resize(maxColors, requiredHeight); + } // update full data + + + paletteTexture.subimage({ + width: Math.min(palette.length * .25, maxColors), + height: requiredHeight, + data: palette + }, 0, 0); +}; // remove unused stuff + + +Scatter.prototype.destroy = function () { + this.groups.forEach(function (group) { + group.sizeBuffer.destroy(); + group.positionBuffer.destroy(); + group.positionFractBuffer.destroy(); + group.colorBuffer.destroy(); + group.activation.forEach(function (b) { + return b && b.destroy && b.destroy(); + }); + group.selectionBuffer.destroy(); + if (group.elements) group.elements.destroy(); + }); + this.groups.length = 0; + this.paletteTexture.destroy(); + this.markerTextures.forEach(function (txt) { + return txt && txt.destroy && txt.destroy(); + }); + return this; +}; + +var extend$1 = _dereq_('object-assign'); + +var reglScatter2d = function reglScatter2d(regl, options) { + var scatter$$1 = new scatter(regl, options); + var render = scatter$$1.render.bind(scatter$$1); // expose API + + extend$1(render, { + render: render, + update: scatter$$1.update.bind(scatter$$1), + draw: scatter$$1.draw.bind(scatter$$1), + destroy: scatter$$1.destroy.bind(scatter$$1), + regl: scatter$$1.regl, + gl: scatter$$1.gl, + canvas: scatter$$1.gl.canvas, + groups: scatter$$1.groups, + markers: scatter$$1.markerCache, + palette: scatter$$1.palette + }); + return render; +}; + +module.exports = reglScatter2d; + +},{"array-bounds":53,"color-id":106,"color-normalize":108,"flatten-vertex-data":216,"glslify":476,"is-iexplorer":402,"object-assign":437,"parse-rect":442,"pick-by-alias":448,"point-cluster":452,"to-float32":514,"update-diff":525}],476:[function(_dereq_,module,exports){ +arguments[4][392][0].apply(exports,arguments) +},{"dup":392}],477:[function(_dereq_,module,exports){ 'use strict' -var Scatter = _dereq_('./scatter') -var extend = _dereq_('object-assign') -module.exports = function (regl, options) { - var scatter = new Scatter(regl, options) - - var render = scatter.render.bind(scatter) - - // expose API - extend(render, { - render: render, - update: scatter.update.bind(scatter), - draw: scatter.draw.bind(scatter), - destroy: scatter.destroy.bind(scatter), - regl: scatter.regl, - gl: scatter.gl, - canvas: scatter.gl.canvas, - groups: scatter.groups, - markers: scatter.markerCache, - palette: scatter.palette - }) - - return render -} -},{"./scatter":476,"object-assign":437}],476:[function(_dereq_,module,exports){ -'use strict' - -var rgba = _dereq_('color-normalize') -var getBounds = _dereq_('array-bounds') -var colorId = _dereq_('color-id') -var cluster = _dereq_('point-cluster') -var extend = _dereq_('object-assign') -var glslify = _dereq_('glslify') +var createScatter = _dereq_('regl-scatter2d') var pick = _dereq_('pick-by-alias') -var updateDiff = _dereq_('update-diff') +var getBounds = _dereq_('array-bounds') +var raf = _dereq_('raf') +var arrRange = _dereq_('array-range') +var rect = _dereq_('parse-rect') var flatten = _dereq_('flatten-vertex-data') -var ie = _dereq_('is-iexplorer') -var f32 = _dereq_('to-float32') -var parseRect = _dereq_('parse-rect') -module.exports = Scatter +module.exports = SPLOM -function Scatter (regl, options) { - var this$1 = this; +// @constructor +function SPLOM (regl, options) { + if (!(this instanceof SPLOM)) { return new SPLOM(regl, options) } - if (!(this instanceof Scatter)) { return new Scatter(regl, options) } + // render passes + this.traces = [] - if (typeof regl === 'function') { - if (!options) { options = {} } - options.regl = regl - } - else { - options = regl - regl = null - } - - if (options && options.length) { options.positions = options } + // passes for scatter, combined across traces + this.passes = {} - regl = options.regl - - // persistent variables - var gl = regl._gl, paletteTexture, palette = [], paletteIds = {}, - - // state - groups = [], + this.regl = regl - // textures for marker keys - markerTextures = [null], - markerCache = [null] + // main scatter drawing instance + this.scatter = createScatter(regl) - var maxColors = 255, maxSize = 100 - - // direct color buffer mode - // IE does not support palette anyways - this.tooManyColors = ie - - // texture with color palette - paletteTexture = regl.texture({ - data: new Uint8Array(maxColors * 4), - width: maxColors, - height: 1, - type: 'uint8', - format: 'rgba', - wrapS: 'clamp', - wrapT: 'clamp', - mag: 'nearest', - min: 'nearest' - }) - - extend(this, { - regl: regl, - gl: gl, - groups: groups, - markerCache: markerCache, - markerTextures: markerTextures, - palette: palette, - paletteIds: paletteIds, - paletteTexture: paletteTexture, - maxColors: maxColors, - maxSize: maxSize, - canvas: gl.canvas - }) - - this.update(options) - - // common shader options - var shaderOptions = { - uniforms: { - pixelRatio: regl.context('pixelRatio'), - palette: paletteTexture, - paletteSize: function (ctx, prop) { return [this$1.tooManyColors ? 0 : maxColors, paletteTexture.height]; }, - scale: regl.prop('scale'), - scaleFract: regl.prop('scaleFract'), - translate: regl.prop('translate'), - translateFract: regl.prop('translateFract'), - opacity: regl.prop('opacity'), - marker: regl.prop('markerTexture'), - }, - - attributes: { - // FIXME: optimize these parts - x: function (ctx, prop) { return prop.xAttr || { - buffer: prop.positionBuffer, - stride: 8, - offset: 0 - }; }, - y: function (ctx, prop) { return prop.yAttr || { - buffer: prop.positionBuffer, - stride: 8, - offset: 4 - }; }, - xFract: function (ctx, prop) { return prop.xAttr ? { constant: [0, 0] } : { - buffer: prop.positionFractBuffer, - stride: 8, - offset: 0 - }; }, - yFract: function (ctx, prop) { return prop.yAttr ? { constant: [0, 0] } : { - buffer: prop.positionFractBuffer, - stride: 8, - offset: 4 - }; }, - size: function (ctx, prop) { return prop.size.length ? { - buffer: prop.sizeBuffer, - stride: 2, - offset: 0 - } : { - constant: [ Math.round(prop.size * 255 / this$1.maxSize) ] - }; }, - borderSize: function (ctx, prop) { return prop.borderSize.length ? { - buffer: prop.sizeBuffer, - stride: 2, - offset: 1 - } : { - constant: [ Math.round(prop.borderSize * 255 / this$1.maxSize) ] - }; }, - colorId: function (ctx, prop) { return prop.color.length ? { - buffer: prop.colorBuffer, - stride: this$1.tooManyColors ? 8 : 4, - offset: 0 - } : { - constant: this$1.tooManyColors ? palette.slice(prop.color * 4, prop.color * 4 + 4) : [ prop.color ] - }; }, - borderColorId: function (ctx, prop) { return prop.borderColor.length ? { - buffer: prop.colorBuffer, - stride: this$1.tooManyColors ? 8 : 4, - offset: this$1.tooManyColors ? 4 : 2 - } : { - constant: this$1.tooManyColors ? palette.slice(prop.borderColor * 4, prop.borderColor * 4 + 4) : [ prop.borderColor ] - }; }, - isActive: function (ctx, prop) { return prop.activation === true ? { constant: [1] } : prop.activation ? prop.activation : { constant: [0] }; } - }, - - blend: { - enable: true, - color: [0,0,0,1], - - // photoshop blending - func: { - srcRGB: 'src alpha', - dstRGB: 'one minus src alpha', - srcAlpha: 'one minus dst alpha', - dstAlpha: 'one' - } - }, - - scissor: { - enable: true, - box: regl.prop('viewport') - }, - viewport: regl.prop('viewport'), - - stencil: {enable: false}, - depth: {enable: false}, - - elements: regl.prop('elements'), - count: regl.prop('count'), - offset: regl.prop('offset'), - - primitive: 'points' - } - - // draw sdf-marker - var markerOptions = extend({}, shaderOptions) - markerOptions.frag = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragWidth, fragBorderColorLevel, fragColorLevel;\n\nuniform sampler2D marker;\nuniform float pixelRatio, opacity;\n\nfloat smoothStep(float x, float y) {\n return 1.0 / (1.0 + exp(50.0*(x - y)));\n}\n\nvoid main() {\n float dist = texture2D(marker, gl_PointCoord).r, delta = fragWidth;\n\n // max-distance alpha\n if (dist < 0.003) discard;\n\n // null-border case\n if (fragBorderColorLevel == fragColorLevel || fragBorderColor.a == 0.) {\n float colorAmt = smoothstep(.5 - delta, .5 + delta, dist);\n gl_FragColor = vec4(fragColor.rgb, colorAmt * fragColor.a * opacity);\n }\n else {\n float borderColorAmt = smoothstep(fragBorderColorLevel - delta, fragBorderColorLevel + delta, dist);\n float colorAmt = smoothstep(fragColorLevel - delta, fragColorLevel + delta, dist);\n\n vec4 color = fragBorderColor;\n color.a *= borderColorAmt;\n color = mix(color, fragColor, colorAmt);\n color.a *= opacity;\n\n gl_FragColor = color;\n }\n\n}\n"]) - markerOptions.vert = glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract, paletteSize;\nuniform float pixelRatio;\nuniform sampler2D palette;\n\nconst float maxSize = 100.;\nconst float borderLevel = .5;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragPointSize, fragBorderRadius,\n fragWidth, fragBorderColorLevel, fragColorLevel;\n\nvec2 paletteCoord(float id) {\n return vec2(\n (mod(id, paletteSize.x) + .5) / paletteSize.x,\n (floor(id / paletteSize.x) + .5) / paletteSize.y\n );\n}\nvec2 paletteCoord(vec2 id) {\n return vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n );\n}\nvec4 getColor(vec4 id) {\n // zero-palette means we deal with direct buffer\n if (paletteSize.x == 0.) return id / 255.;\n return texture2D(palette, paletteCoord(id.xy));\n}\n\nvoid main() {\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = 2. * size * pixelRatio;\n fragPointSize = size * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragColor = color;\n fragBorderColor = borderColor;\n fragWidth = 1. / gl_PointSize;\n\n fragBorderColorLevel = clamp(borderLevel - borderLevel * borderSize / size, 0., 1.);\n fragColorLevel = clamp(borderLevel + (1. - borderLevel) * borderSize / size, 0., 1.);\n}\n"]) - - this.drawMarker = regl(markerOptions) - - // draw circle - var circleOptions = extend({}, shaderOptions) - circleOptions.frag = glslify(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\n\nuniform float opacity;\nvarying float fragBorderRadius, fragWidth;\n\nfloat smoothStep(float edge0, float edge1, float x) {\n\tfloat t;\n\tt = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n\treturn t * t * (3.0 - 2.0 * t);\n}\n\nvoid main() {\n\tfloat radius, alpha = 1.0, delta = fragWidth;\n\n\tradius = length(2.0 * gl_PointCoord.xy - 1.0);\n\n\tif (radius > 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]) - circleOptions.vert = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nvec2 paletteCoord(float id) {\n return vec2(\n (mod(id, paletteSize.x) + .5) / paletteSize.x,\n (floor(id / paletteSize.x) + .5) / paletteSize.y\n );\n}\nvec2 paletteCoord(vec2 id) {\n return vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n );\n}\n\nvec4 getColor(vec4 id) {\n // zero-palette means we deal with direct buffer\n if (paletteSize.x == 0.) return id / 255.;\n return texture2D(palette, paletteCoord(id.xy));\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]) - - // polyfill IE - if (ie) { - circleOptions.frag = circleOptions.frag.replace('smoothstep', 'smoothStep') - markerOptions.frag = markerOptions.frag.replace('smoothstep', 'smoothStep') - } - - this.drawCircle = regl(circleOptions) -} - -// single pass defaults -Scatter.defaults = { - color: 'black', - borderColor: 'transparent', - borderSize: 0, - size: 12, - opacity: 1, - marker: undefined, - viewport: null, - range: null, - pixelSize: null, - count: 0, - offset: 0, - bounds: null, - positions: [], - snap: 1e4 + this.canvas = this.scatter.canvas } -// update & redraw -Scatter.prototype.render = function () { +// update & draw passes once per frame +SPLOM.prototype.render = function () { + var this$1 = this; var ref; var args = [], len = arguments.length; @@ -62207,1281 +63080,536 @@ Scatter.prototype.render = function () { (ref = this).update.apply(ref, args) } - this.draw() + if (this.regl.attributes.preserveDrawingBuffer) { return this.draw() } + + // make sure draw is not called more often than once a frame + if (this.dirty) { + if (this.planned == null) { + this.planned = raf(function () { + this$1.draw() + this$1.dirty = true + this$1.planned = null + }) + } + } + else { + this.draw() + this.dirty = true + raf(function () { + this$1.dirty = false + }) + } return this } -// draw all groups or only indicated ones -Scatter.prototype.draw = function () { +// update passes +SPLOM.prototype.update = function () { var this$1 = this; + var ref; + var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - var ref = this; - var groups = ref.groups; + while ( len-- ) args[ len ] = arguments[ len ]; + if (!args.length) { return } - // if directly array passed - treat as passes - if (args.length === 1 && Array.isArray(args[0]) && (args[0][0] === null || Array.isArray(args[0][0]))) { - args = args[0] + for (var i = 0; i < args.length; i++) { + this$1.updateItem(i, args[i]) } - // FIXME: remove once https://github.com/regl-project/regl/issues/474 resolved - this.regl._refresh() + // remove nulled passes + this.traces = this.traces.filter(Boolean) - if (args.length) { - for (var i = 0; i < args.length; i++) { - this$1.drawItem(i, args[i]) + // FIXME: update passes independently + var passes = [] + var offset = 0 + for (var i$1 = 0; i$1 < this.traces.length; i$1++) { + var trace = this$1.traces[i$1] + var tracePasses = this$1.traces[i$1].passes + for (var j = 0; j < tracePasses.length; j++) { + passes.push(this$1.passes[tracePasses[j]]) } + // save offset of passes + trace.passOffset = offset + offset += trace.passes.length } - // draw all passes - else { - groups.forEach(function (group, i) { - this$1.drawItem(i) - }) - } + + (ref = this.scatter).update.apply(ref, passes) return this } -// draw specific scatter group -Scatter.prototype.drawItem = function (id, els) { + +// update trace by index, not supposed to be called directly +SPLOM.prototype.updateItem = function (i, options) { var this$1 = this; var ref = this; - var groups = ref.groups; - var group = groups[id] - - // debug viewport - // let { viewport } = group - // gl.enable(gl.SCISSOR_TEST); - // gl.scissor(viewport.x, viewport.y, viewport.width, viewport.height); - // gl.clearColor(0, 0, 0, .5); - // gl.clear(gl.COLOR_BUFFER_BIT); - - if (typeof els === 'number') { - id = els - group = groups[els] - els = null - } - - if (!(group && group.count && group.opacity)) { return } + var regl = ref.regl; - // draw circles - if (group.activation[0]) { - // TODO: optimize this performance by making groups and regl.this props - this.drawCircle(this.getMarkerDrawOptions(0, group, els)) + // remove pass if null + if (options === null) { + this.traces[i] = null + return this } - // draw all other available markers - var batch = [] + if (!options) { return this } + + var o = pick(options, { + data: 'data items columns rows values dimensions samples x', + snap: 'snap cluster', + size: 'sizes size radius', + color: 'colors color fill fill-color fillColor', + opacity: 'opacity alpha transparency opaque', + borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', + borderColor: 'borderColors borderColor bordercolor stroke stroke-color strokeColor', + marker: 'markers marker shape', + range: 'range ranges databox dataBox', + viewport: 'viewport viewBox viewbox', + domain: 'domain domains area areas', + padding: 'pad padding paddings pads margin margins', + transpose: 'transpose transposed', + diagonal: 'diagonal diag showDiagonal', + upper: 'upper up top upperhalf upperHalf showupperhalf showUpper showUpperHalf', + lower: 'lower low bottom lowerhalf lowerHalf showlowerhalf showLowerHalf showLower' + }) - for (var i = 1; i < group.activation.length; i++) { - if (!group.activation[i] || (group.activation[i] !== true && !group.activation[i].data.length)) { continue } + // we provide regl buffer per-trace, since trace data can be changed + var trace = (this.traces[i] || (this.traces[i] = { + id: i, + buffer: regl.buffer({ + usage: 'dynamic', + type: 'float', + data: new Uint8Array() + }), + color: 'black', + marker: null, + size: 12, + borderColor: 'transparent', + borderSize: 1, + viewport: rect([regl._gl.drawingBufferWidth, regl._gl.drawingBufferHeight]), + padding: [0, 0, 0, 0], + opacity: 1, + diagonal: true, + upper: true, + lower: true + })) - batch.push.apply(batch, this$1.getMarkerDrawOptions(i, group, els)) - } - if (batch.length) { - this.drawMarker(batch) + // save styles + if (o.color != null) { + trace.color = o.color } -} + if (o.size != null) { + trace.size = o.size + } + if (o.marker != null) { + trace.marker = o.marker + } + if (o.borderColor != null) { + trace.borderColor = o.borderColor + } + if (o.borderSize != null) { + trace.borderSize = o.borderSize + } + if (o.opacity != null) { + trace.opacity = o.opacity + } + if (o.viewport) { + trace.viewport = rect(o.viewport) + } + if (o.diagonal != null) { trace.diagonal = o.diagonal } + if (o.upper != null) { trace.upper = o.upper } + if (o.lower != null) { trace.lower = o.lower } -// get options for the marker ids -Scatter.prototype.getMarkerDrawOptions = function(markerId, group, elements) { - var this$1 = this; + // put flattened data into buffer + if (o.data) { + trace.buffer(flatten(o.data)) + trace.columns = o.data.length + trace.count = o.data[0].length - var range = group.range; - var tree = group.tree; - var viewport = group.viewport; - var activation = group.activation; - var selectionBuffer = group.selectionBuffer; - var count = group.count; - var ref = this; - var regl = ref.regl; + // detect bounds per-column + trace.bounds = [] - // direct points - if (!tree) { - // if elements array - draw unclustered points - if (elements) { - return [extend({}, group, { - markerTexture: this.markerTextures[markerId], - activation: activation[markerId], - count: elements.length, - elements: elements, - offset: 0 - })] + for (var i$1 = 0; i$1 < trace.columns; i$1++) { + trace.bounds[i$1] = getBounds(o.data[i$1], 1) } - - return [ extend({}, group, { - markerTexture: this.markerTextures[markerId], - activation: activation[markerId], - offset: 0 - }) ] } - // clustered points - var batch = [] - - var lod = tree.range(range, { lod: true, px: [ - (range[2] - range[0]) / viewport.width, - (range[3] - range[1]) / viewport.height - ]}) - - // enable elements by using selection buffer - if (elements) { - var markerActivation = activation[markerId] - var mask = markerActivation.data - var data = new Uint8Array(count) - for (var i = 0; i < elements.length; i++) { - var id = elements[i] - data[id] = mask ? mask[id] : 1 - } - selectionBuffer.subdata(data) + // add proper range updating markers + var multirange + if (o.range) { + trace.range = o.range + multirange = trace.range && typeof trace.range[0] !== 'number' } - for (var l = lod.length; l--;) { - var ref$1 = lod[l]; - var from = ref$1[0]; - var to = ref$1[1]; - - batch.push(extend({}, group, { - markerTexture: this$1.markerTextures[markerId], - activation: elements ? selectionBuffer : activation[markerId], - offset: from, - count: to - from - })) + if (o.domain) { + trace.domain = o.domain } - - return batch -} - -// update groups options -Scatter.prototype.update = function () { - var this$1 = this; - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - if (!args.length) { return } - - // passes are as single array - if (args.length === 1 && Array.isArray(args[0])) { args = args[0] } - - var ref = this; - var groups = ref.groups; - var gl = ref.gl; - var regl = ref.regl; - var maxSize = ref.maxSize; - var maxColors = ref.maxColors; - var palette = ref.palette; - - this.groups = groups = args.map(function (options, i) { - var group = groups[i] - - if (options === undefined) { return group } - - if (options === null) { options = { positions: null } } - else if (typeof options === 'function') { options = { ondraw: options } } - else if (typeof options[0] === 'number') { options = { positions: options } } - - // copy options to avoid mutation & handle aliases - options = pick(options, { - positions: 'positions data points', - snap: 'snap cluster lod tree', - size: 'sizes size radius', - borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', - color: 'colors color fill fill-color fillColor', - borderColor: 'borderColors borderColor stroke stroke-color strokeColor', - marker: 'markers marker shape', - range: 'range dataBox databox', - viewport: 'viewport viewPort viewBox viewbox', - opacity: 'opacity alpha transparency', - bounds: 'bound bounds boundaries limits' - }) - - if (options.positions === null) { options.positions = [] } - - if (!group) { - groups[i] = group = { - id: i, - scale: null, - translate: null, - scaleFract: null, - translateFract: null, - - // buffers for active markers - activation: [], - - // buffer for filtered markers - selectionBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'stream', - type: 'uint8' - }), - - // buffers with data: it is faster to switch them per-pass - // than provide one congregate buffer - sizeBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'uint8' - }), - colorBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'uint8' - }), - positionBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'float' - }), - positionFractBuffer: regl.buffer({ - data: new Uint8Array(0), - usage: 'dynamic', - type: 'float' - }) - } - options = extend({}, Scatter.defaults, options) + var multipadding = false + if (o.padding != null) { + // multiple paddings + if (Array.isArray(o.padding) && o.padding.length === trace.columns && typeof o.padding[o.padding.length - 1] === 'number') { + trace.padding = o.padding.map(getPad) + multipadding = true } - - // force update triggers - if (options.positions && !('marker' in options)) { - options.marker = group.marker - delete group.marker - } - - // updating markers cause recalculating snapping - if (options.marker && !('positions' in options)) { - options.positions = group.positions - delete group.positions + // single padding + else { + trace.padding = getPad(o.padding) } + } - // global count of points - var hasSize = 0, hasColor = 0 - - updateDiff(group, options, [{ - snap: true, - size: function (s, group) { - if (s == null) { s = Scatter.defaults.size } - hasSize += s && s.length ? 1 : 0 - return s - }, - borderSize: function (s, group) { - if (s == null) { s = Scatter.defaults.borderSize } - hasSize += s && s.length ? 1 : 0 - return s - }, - opacity: parseFloat, - - // add colors to palette, save references - color: function (c, group) { - if (c == null) { c = Scatter.defaults.color } - c = this$1.updateColor(c) - hasColor++ - return c - }, - borderColor: function (c, group) { - if (c == null) { c = Scatter.defaults.borderColor } - c = this$1.updateColor(c) - hasColor++ - return c - }, - - bounds: function (bounds, group, options) { - if (!('range' in options)) { options.range = null } - return bounds - }, - - positions: function (positions, group, options) { - var snap = group.snap; - var positionBuffer = group.positionBuffer; - var positionFractBuffer = group.positionFractBuffer; - var selectionBuffer = group.selectionBuffer; - - // separate buffers for x/y coordinates - if (positions.x || positions.y) { - if (positions.x.length) { - group.xAttr = { - buffer: regl.buffer(positions.x), - offset: 0, - stride: 4, - count: positions.x.length - } - } - else { - group.xAttr = { - buffer: positions.x.buffer, - offset: positions.x.offset * 4 || 0, - stride: (positions.x.stride || 1) * 4, - count: positions.x.count - } - } - if (positions.y.length) { - group.yAttr = { - buffer: regl.buffer(positions.y), - offset: 0, - stride: 4, - count: positions.y.length - } - } - else { - group.yAttr = { - buffer: positions.y.buffer, - offset: positions.y.offset * 4 || 0, - stride: (positions.y.stride || 1) * 4, - count: positions.y.count - } - } - group.count = Math.max(group.xAttr.count, group.yAttr.count) - - return positions - } + // create passes + var m = trace.columns + var n = trace.count - positions = flatten(positions, 'float64') + var w = trace.viewport.width + var h = trace.viewport.height + var left = trace.viewport.x + var top = trace.viewport.y + var iw = w / m + var ih = h / m - var count = group.count = Math.floor(positions.length / 2) - var bounds = group.bounds = count ? getBounds(positions, 2) : null + trace.passes = [] - // if range is not provided updated - recalc it - if (!options.range && !group.range) { - delete group.range - options.range = bounds - } + for (var i$2 = 0; i$2 < m; i$2++) { + for (var j = 0; j < m; j++) { + if (!trace.diagonal && j === i$2) { continue } + if (!trace.upper && i$2 > j) { continue } + if (!trace.lower && i$2 < j) { continue } - // reset marker - if (!options.marker && !group.marker) { - delete group.marker; - options.marker = null; - } + var key = passId(trace.id, i$2, j) - // build cluster tree if required - if (snap && (snap === true || count > snap)) { - group.tree = cluster(positions, { bounds: bounds }) - } - // existing tree instance - else if (snap && snap.length) { - group.tree = snap - } + var pass = this$1.passes[key] || (this$1.passes[key] = {}) - if (group.tree) { - var opts = { - primitive: 'points', - usage: 'static', - data: group.tree, - type: 'uint32' + if (o.data) { + if (o.transpose) { + pass.positions = { + x: {buffer: trace.buffer, offset: j, count: n, stride: m}, + y: {buffer: trace.buffer, offset: i$2, count: n, stride: m} } - if (group.elements) { group.elements(opts) } - else { group.elements = regl.elements(opts) } - } - - // update position buffers - positionBuffer({ - data: f32.float(positions), - usage: 'dynamic' - }) - positionFractBuffer({ - data: f32.fract(positions), - usage: 'dynamic' - }) - - // expand selectionBuffer - selectionBuffer({ - data: new Uint8Array(count), - type: 'uint8', - usage: 'stream' - }) - - return positions - } - }, { - // create marker ids corresponding to known marker textures - marker: function (markers, group, options) { - var activation = group.activation; - - // reset marker elements - activation.forEach(function (buffer) { return buffer && buffer.destroy && buffer.destroy(); }) - activation.length = 0 - - // single sdf marker - if (!markers || typeof markers[0] === 'number') { - var id = this$1.addMarker(markers) - activation[id] = true } - - // per-point markers use mask buffers to enable markers in vert shader else { - var markerMasks = [] - - for (var i = 0, l = Math.min(markers.length, group.count); i < l; i++) { - var id$1 = this$1.addMarker(markers[i]) - - if (!markerMasks[id$1]) { markerMasks[id$1] = new Uint8Array(group.count) } - - // enable marker by default - markerMasks[id$1][i] = 1 - } - - for (var id$2 = 0; id$2 < markerMasks.length; id$2++) { - if (!markerMasks[id$2]) { continue } - - var opts = { - data: markerMasks[id$2], - type: 'uint8', - usage: 'static' - } - if (!activation[id$2]) { - activation[id$2] = regl.buffer(opts) - } - else { - activation[id$2](opts) - } - - activation[id$2].data = markerMasks[id$2] + pass.positions = { + x: {buffer: trace.buffer, offset: j * n, count: n}, + y: {buffer: trace.buffer, offset: i$2 * n, count: n} } } - return markers - }, - - range: function (range, group, options) { - var bounds = group.bounds - - // FIXME: why do we need this? - if (!bounds) { return } - if (!range) { range = bounds } - - group.scale = [1 / (range[2] - range[0]), 1 / (range[3] - range[1])] - group.translate = [-range[0], -range[1]] - - group.scaleFract = f32.fract(group.scale) - group.translateFract = f32.fract(group.translate) - - return range - }, - - viewport: function (vp) { - var rect = parseRect(vp || [ - gl.drawingBufferWidth, - gl.drawingBufferHeight - ]) - - // normalize viewport to the canvas coordinates - // rect.y = gl.drawingBufferHeight - rect.height - rect.y - - return rect - } - }]) - - // update size buffer, if needed - if (hasSize) { - var count = group.count; - var size = group.size; - var borderSize = group.borderSize; - var sizeBuffer = group.sizeBuffer; - - var sizes = new Uint8Array(count*2) - if (size.length || borderSize.length) { - for (var i$1 = 0; i$1 < count; i$1++) { - // we downscale size to allow for fractions - sizes[i$1*2] = Math.round((size[i$1] == null ? size : size[i$1]) * 255 / maxSize) - sizes[i$1*2 + 1] = Math.round((borderSize[i$1] == null ? borderSize : borderSize[i$1]) * 255 / maxSize) - } + pass.bounds = getBox(trace.bounds, i$2, j) } - sizeBuffer({ - data: sizes, - usage: 'dynamic' - }) - } - // update color buffer if needed - if (hasColor) { - var count$1 = group.count; - var color = group.color; - var borderColor = group.borderColor; - var colorBuffer = group.colorBuffer; - var colors - - // if too many colors - put colors to buffer directly - if (this$1.tooManyColors) { - if (color.length || borderColor.length) { - colors = new Uint8Array(count$1 * 8) - for (var i$2 = 0; i$2 < count$1; i$2++) { - var colorId = color[i$2] - colors[i$2*8] = palette[colorId*4] - colors[i$2*8 + 1] = palette[colorId*4 + 1] - colors[i$2*8 + 2] = palette[colorId*4 + 2] - colors[i$2*8 + 3] = palette[colorId*4 + 3] - - var borderColorId = borderColor[i$2] - colors[i$2*8 + 4] = palette[borderColorId*4] - colors[i$2*8 + 5] = palette[borderColorId*4 + 1] - colors[i$2*8 + 6] = palette[borderColorId*4 + 2] - colors[i$2*8 + 7] = palette[borderColorId*4 + 3] - } + if (o.domain || o.viewport || o.data) { + var pad = multipadding ? getBox(trace.padding, i$2, j) : trace.padding + if (trace.domain) { + var ref$1 = getBox(trace.domain, i$2, j); + var lox = ref$1[0]; + var loy = ref$1[1]; + var hix = ref$1[2]; + var hiy = ref$1[3]; + + pass.viewport = [ + left + lox * w + pad[0], + top + loy * h + pad[1], + left + hix * w - pad[2], + top + hiy * h - pad[3] + ] } - } - - // if limited amount of colors - keep palette color picking - // that saves significant memory - else { - if (color.length || borderColor.length) { - // we need slight data increase by 2 due to vec4 borderId in shader - colors = new Uint8Array(count$1 * 4 + 2) - for (var i$3 = 0; i$3 < count$1; i$3++) { - // put color coords in palette texture - if (color[i$3] != null) { - colors[i$3*4] = color[i$3] % maxColors - colors[i$3*4 + 1] = Math.floor(color[i$3] / maxColors) - } - if (borderColor[i$3] != null) { - colors[i$3*4 + 2] = borderColor[i$3] % maxColors - colors[i$3*4 + 3] = Math.floor(borderColor[i$3] / maxColors) - } - } + // consider auto-domain equipartial + else { + pass.viewport = [ + left + j * iw + iw * pad[0], + top + i$2 * ih + ih * pad[1], + left + (j + 1) * iw - iw * pad[2], + top + (i$2 + 1) * ih - ih * pad[3] + ] } } - colorBuffer({ - data: colors || new Uint8Array(0), - type: 'uint8', - usage: 'dynamic' - }) - } + if (o.color) { pass.color = trace.color } + if (o.size) { pass.size = trace.size } + if (o.marker) { pass.marker = trace.marker } + if (o.borderSize) { pass.borderSize = trace.borderSize } + if (o.borderColor) { pass.borderColor = trace.borderColor } + if (o.opacity) { pass.opacity = trace.opacity } - return group - }) -} - - -// get (and create) marker texture id -Scatter.prototype.addMarker = function (sdf) { - var ref = this; - var markerTextures = ref.markerTextures; - var regl = ref.regl; - var markerCache = ref.markerCache; - - var pos = sdf == null ? 0 : markerCache.indexOf(sdf) - - if (pos >= 0) { return pos } + if (o.range) { + pass.range = multirange ? getBox(trace.range, i$2, j) : trace.range || pass.bounds + } - // convert sdf to 0..255 range - var distArr - if (sdf instanceof Uint8Array || sdf instanceof Uint8ClampedArray) { - distArr = sdf - } - else { - distArr = new Uint8Array(sdf.length) - for (var i = 0, l = sdf.length; i < l; i++) { - distArr[i] = sdf[i] * 255 + trace.passes.push(key) } } - var radius = Math.floor(Math.sqrt(distArr.length)) - - pos = markerTextures.length - - markerCache.push(sdf) - markerTextures.push(regl.texture({ - channels: 1, - data: distArr, - radius: radius, - mag: 'linear', - min: 'linear' - })) - - return pos + return this } -// register color to palette, return it's index or list of indexes -Scatter.prototype.updateColor = function (colors) { - var ref = this; - var paletteIds = ref.paletteIds; - var palette = ref.palette; - var maxColors = ref.maxColors; - if (!Array.isArray(colors)) { - colors = [colors] +// draw all or passed passes +SPLOM.prototype.draw = function () { + var this$1 = this; + var ref$2; + + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + if (!args.length) { + this.scatter.draw() } - - var idx = [] - - // if color groups - flatten them - if (typeof colors[0] === 'number') { - var grouped = [] - - if (Array.isArray(colors)) { - for (var i = 0; i < colors.length; i+=4) { - grouped.push(colors.slice(i, i+4)) + else { + var idx = [] + for (var i = 0; i < args.length; i++) { + // draw(0, 2, 5) - draw traces + if (typeof args[i] === 'number' ) { + var ref = this$1.traces[args[i]]; + var passes = ref.passes; + var passOffset = ref.passOffset; + idx.push.apply(idx, arrRange(passOffset, passOffset + passes.length)) } - } - else { - for (var i$1 = 0; i$1 < colors.length; i$1+=4) { - grouped.push(colors.subarray(i$1, i$1+4)) + // draw([0, 1, 2 ...], [3, 4, 5]) - draw points + else if (args[i].length) { + var els = args[i] + var ref$1 = this$1.traces[i]; + var passes$1 = ref$1.passes; + var passOffset$1 = ref$1.passOffset; + passes$1 = passes$1.map(function (passId, i) { + idx[passOffset$1 + i] = els + }) } } - - colors = grouped + (ref$2 = this.scatter).draw.apply(ref$2, idx) } - for (var i$2 = 0; i$2 < colors.length; i$2++) { - var color = colors[i$2] + return this +} - color = rgba(color, 'uint8') - var id = colorId(color, false) +// dispose resources +SPLOM.prototype.destroy = function () { + this.traces.forEach(function (trace) { + if (trace.buffer && trace.buffer.destroy) { trace.buffer.destroy() } + }) + this.traces = null + this.passes = null - // if new color - save it - if (paletteIds[id] == null) { - var pos = palette.length - paletteIds[id] = Math.floor(pos / 4) - palette[pos] = color[0] - palette[pos+1] = color[1] - palette[pos+2] = color[2] - palette[pos+3] = color[3] - } + this.scatter.destroy() - idx[i$2] = paletteIds[id] - } + return this +} - // detect if too many colors in palette - if (!this.tooManyColors && palette.length > maxColors * maxColors * 4) { this.tooManyColors = true } - // limit max color - this.updatePalette(palette) +// return pass corresponding to trace i- j- square +function passId (trace, i, j) { + var id = (trace.id != null ? trace.id : trace) + var n = i + var m = j + var key = id << 16 | (n & 0xff) << 8 | m & 0xff - // keep static index for single-color property - return idx.length === 1 ? idx[0] : idx + return key } -Scatter.prototype.updatePalette = function (palette) { - if (this.tooManyColors) { return } - - var ref = this; - var maxColors = ref.maxColors; - var paletteTexture = ref.paletteTexture; - var requiredHeight = Math.ceil(palette.length * .25 / maxColors) +// return bounding box corresponding to a pass +function getBox (items, i, j) { + var ilox, iloy, ihix, ihiy, jlox, jloy, jhix, jhiy + var iitem = items[i], jitem = items[j] - // pad data - if (requiredHeight > 1) { - palette = palette.slice() - for (var i = (palette.length * .25) % maxColors; i < requiredHeight * maxColors; i++) { - palette.push(0, 0, 0, 0) - } + if (iitem.length > 2) { + ilox = iitem[0] + ihix = iitem[2] + iloy = iitem[1] + ihiy = iitem[3] + } + else if (iitem.length) { + ilox = iloy = iitem[0] + ihix = ihiy = iitem[1] + } + else { + ilox = iitem.x + iloy = iitem.y + ihix = iitem.x + iitem.width + ihiy = iitem.y + iitem.height } - // ensure height - if (paletteTexture.height < requiredHeight) { - paletteTexture.resize(maxColors, requiredHeight) + if (jitem.length > 2) { + jlox = jitem[0] + jhix = jitem[2] + jloy = jitem[1] + jhiy = jitem[3] + } + else if (jitem.length) { + jlox = jloy = jitem[0] + jhix = jhiy = jitem[1] + } + else { + jlox = jitem.x + jloy = jitem.y + jhix = jitem.x + jitem.width + jhiy = jitem.y + jitem.height } - // update full data - paletteTexture.subimage({ - width: Math.min(palette.length * .25, maxColors), - height: requiredHeight, - data: palette - }, 0, 0) + return [ jlox, iloy, jhix, ihiy ] } -// remove unused stuff -Scatter.prototype.destroy = function () { - this.groups.forEach(function (group) { - group.sizeBuffer.destroy() - group.positionBuffer.destroy() - group.positionFractBuffer.destroy() - group.colorBuffer.destroy() - group.activation.forEach(function (b) { return b && b.destroy && b.destroy(); }) - group.selectionBuffer.destroy() - - if (group.elements) { group.elements.destroy() } - }) - this.groups.length = 0 - - this.paletteTexture.destroy() - - this.markerTextures.forEach(function (txt) { return txt && txt.destroy && txt.destroy(); }) - return this +function getPad (arg) { + if (typeof arg === 'number') { return [arg, arg, arg, arg] } + else if (arg.length === 2) { return [arg[0], arg[1], arg[0], arg[1]] } + else { + var box = rect(arg) + return [box.x, box.y, box.x + box.width, box.y + box.height] + } } -},{"array-bounds":53,"color-id":106,"color-normalize":108,"flatten-vertex-data":216,"glslify":392,"is-iexplorer":402,"object-assign":437,"parse-rect":442,"pick-by-alias":448,"point-cluster":452,"to-float32":515,"update-diff":526}],477:[function(_dereq_,module,exports){ -'use strict' - - -var createScatter = _dereq_('regl-scatter2d/scatter') -var pick = _dereq_('pick-by-alias') -var getBounds = _dereq_('array-bounds') -var raf = _dereq_('raf') -var arrRange = _dereq_('array-range') -var rect = _dereq_('parse-rect') -var flatten = _dereq_('flatten-vertex-data') - - -module.exports = SPLOM - - -// @constructor -function SPLOM (regl, options) { - if (!(this instanceof SPLOM)) { return new SPLOM(regl, options) } - - // render passes - this.traces = [] - - // passes for scatter, combined across traces - this.passes = {} - - this.regl = regl - - // main scatter drawing instance - this.scatter = createScatter(regl) - - this.canvas = this.scatter.canvas -} - - -// update & draw passes once per frame -SPLOM.prototype.render = function () { - var this$1 = this; - var ref; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (args.length) { - (ref = this).update.apply(ref, args) - } - - if (this.regl.attributes.preserveDrawingBuffer) { return this.draw() } - - // make sure draw is not called more often than once a frame - if (this.dirty) { - if (this.planned == null) { - this.planned = raf(function () { - this$1.draw() - this$1.dirty = true - this$1.planned = null - }) - } - } - else { - this.draw() - this.dirty = true - raf(function () { - this$1.dirty = false - }) - } - - return this -} - - -// update passes -SPLOM.prototype.update = function () { - var this$1 = this; - var ref; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (!args.length) { return } - - for (var i = 0; i < args.length; i++) { - this$1.updateItem(i, args[i]) - } - - // remove nulled passes - this.traces = this.traces.filter(Boolean) - - // FIXME: update passes independently - var passes = [] - var offset = 0 - for (var i$1 = 0; i$1 < this.traces.length; i$1++) { - var trace = this$1.traces[i$1] - var tracePasses = this$1.traces[i$1].passes - for (var j = 0; j < tracePasses.length; j++) { - passes.push(this$1.passes[tracePasses[j]]) - } - // save offset of passes - trace.passOffset = offset - offset += trace.passes.length - } - - (ref = this.scatter).update.apply(ref, passes) - - return this -} - - -// update trace by index, not supposed to be called directly -SPLOM.prototype.updateItem = function (i, options) { - var this$1 = this; - - var ref = this; - var regl = ref.regl; - - // remove pass if null - if (options === null) { - this.traces[i] = null - return this - } - - if (!options) { return this } - - var o = pick(options, { - data: 'data items columns rows values dimensions samples x', - snap: 'snap cluster', - size: 'sizes size radius', - color: 'colors color fill fill-color fillColor', - opacity: 'opacity alpha transparency opaque', - borderSize: 'borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline', - borderColor: 'borderColors borderColor bordercolor stroke stroke-color strokeColor', - marker: 'markers marker shape', - range: 'range ranges databox dataBox', - viewport: 'viewport viewBox viewbox', - domain: 'domain domains area areas', - padding: 'pad padding paddings pads margin margins', - transpose: 'transpose transposed', - diagonal: 'diagonal diag showDiagonal', - upper: 'upper up top upperhalf upperHalf showupperhalf showUpper showUpperHalf', - lower: 'lower low bottom lowerhalf lowerHalf showlowerhalf showLowerHalf showLower' - }) - - // we provide regl buffer per-trace, since trace data can be changed - var trace = (this.traces[i] || (this.traces[i] = { - id: i, - buffer: regl.buffer({ - usage: 'dynamic', - type: 'float', - data: new Uint8Array() - }), - color: 'black', - marker: null, - size: 12, - borderColor: 'transparent', - borderSize: 1, - viewport: rect([regl._gl.drawingBufferWidth, regl._gl.drawingBufferHeight]), - padding: [0, 0, 0, 0], - opacity: 1, - diagonal: true, - upper: true, - lower: true - })) - - - // save styles - if (o.color != null) { - trace.color = o.color - } - if (o.size != null) { - trace.size = o.size - } - if (o.marker != null) { - trace.marker = o.marker - } - if (o.borderColor != null) { - trace.borderColor = o.borderColor - } - if (o.borderSize != null) { - trace.borderSize = o.borderSize - } - if (o.opacity != null) { - trace.opacity = o.opacity - } - if (o.viewport) { - trace.viewport = rect(o.viewport) - } - if (o.diagonal != null) { trace.diagonal = o.diagonal } - if (o.upper != null) { trace.upper = o.upper } - if (o.lower != null) { trace.lower = o.lower } - - // put flattened data into buffer - if (o.data) { - trace.buffer(flatten(o.data)) - trace.columns = o.data.length - trace.count = o.data[0].length - - // detect bounds per-column - trace.bounds = [] - - for (var i$1 = 0; i$1 < trace.columns; i$1++) { - trace.bounds[i$1] = getBounds(o.data[i$1], 1) - } - } - - // add proper range updating markers - var multirange - if (o.range) { - trace.range = o.range - multirange = trace.range && typeof trace.range[0] !== 'number' - } - - if (o.domain) { - trace.domain = o.domain - } - var multipadding = false - if (o.padding != null) { - // multiple paddings - if (Array.isArray(o.padding) && o.padding.length === trace.columns && typeof o.padding[o.padding.length - 1] === 'number') { - trace.padding = o.padding.map(getPad) - multipadding = true - } - // single padding - else { - trace.padding = getPad(o.padding) - } - } - - // create passes - var m = trace.columns - var n = trace.count - - var w = trace.viewport.width - var h = trace.viewport.height - var left = trace.viewport.x - var top = trace.viewport.y - var iw = w / m - var ih = h / m - - trace.passes = [] - - for (var i$2 = 0; i$2 < m; i$2++) { - for (var j = 0; j < m; j++) { - if (!trace.diagonal && j === i$2) { continue } - if (!trace.upper && i$2 > j) { continue } - if (!trace.lower && i$2 < j) { continue } - - var key = passId(trace.id, i$2, j) - - var pass = this$1.passes[key] || (this$1.passes[key] = {}) - - if (o.data) { - if (o.transpose) { - pass.positions = { - x: {buffer: trace.buffer, offset: j, count: n, stride: m}, - y: {buffer: trace.buffer, offset: i$2, count: n, stride: m} - } - } - else { - pass.positions = { - x: {buffer: trace.buffer, offset: j * n, count: n}, - y: {buffer: trace.buffer, offset: i$2 * n, count: n} - } - } - - pass.bounds = getBox(trace.bounds, i$2, j) - } - - if (o.domain || o.viewport || o.data) { - var pad = multipadding ? getBox(trace.padding, i$2, j) : trace.padding - if (trace.domain) { - var ref$1 = getBox(trace.domain, i$2, j); - var lox = ref$1[0]; - var loy = ref$1[1]; - var hix = ref$1[2]; - var hiy = ref$1[3]; - - pass.viewport = [ - left + lox * w + pad[0], - top + loy * h + pad[1], - left + hix * w - pad[2], - top + hiy * h - pad[3] - ] - } - // consider auto-domain equipartial - else { - pass.viewport = [ - left + j * iw + iw * pad[0], - top + i$2 * ih + ih * pad[1], - left + (j + 1) * iw - iw * pad[2], - top + (i$2 + 1) * ih - ih * pad[3] - ] - } - } - - if (o.color) { pass.color = trace.color } - if (o.size) { pass.size = trace.size } - if (o.marker) { pass.marker = trace.marker } - if (o.borderSize) { pass.borderSize = trace.borderSize } - if (o.borderColor) { pass.borderColor = trace.borderColor } - if (o.opacity) { pass.opacity = trace.opacity } - - if (o.range) { - pass.range = multirange ? getBox(trace.range, i$2, j) : trace.range || pass.bounds - } - - trace.passes.push(key) - } - } - - return this -} - - -// draw all or passed passes -SPLOM.prototype.draw = function () { - var this$1 = this; - var ref$2; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - if (!args.length) { - this.scatter.draw() - } - else { - var idx = [] - for (var i = 0; i < args.length; i++) { - // draw(0, 2, 5) - draw traces - if (typeof args[i] === 'number' ) { - var ref = this$1.traces[args[i]]; - var passes = ref.passes; - var passOffset = ref.passOffset; - idx.push.apply(idx, arrRange(passOffset, passOffset + passes.length)) - } - // draw([0, 1, 2 ...], [3, 4, 5]) - draw points - else if (args[i].length) { - var els = args[i] - var ref$1 = this$1.traces[i]; - var passes$1 = ref$1.passes; - var passOffset$1 = ref$1.passOffset; - passes$1 = passes$1.map(function (passId, i) { - idx[passOffset$1 + i] = els - }) - } - } - (ref$2 = this.scatter).draw.apply(ref$2, idx) - } - - return this -} - - -// dispose resources -SPLOM.prototype.destroy = function () { - this.traces.forEach(function (trace) { - if (trace.buffer && trace.buffer.destroy) { trace.buffer.destroy() } - }) - this.traces = null - this.passes = null - - this.scatter.destroy() - - return this -} - - -// return pass corresponding to trace i- j- square -function passId (trace, i, j) { - var id = (trace.id != null ? trace.id : trace) - var n = i - var m = j - var key = id << 16 | (n & 0xff) << 8 | m & 0xff - - return key -} - - -// return bounding box corresponding to a pass -function getBox (items, i, j) { - var ilox, iloy, ihix, ihiy, jlox, jloy, jhix, jhiy - var iitem = items[i], jitem = items[j] - - if (iitem.length > 2) { - ilox = iitem[0] - ihix = iitem[2] - iloy = iitem[1] - ihiy = iitem[3] - } - else if (iitem.length) { - ilox = iloy = iitem[0] - ihix = ihiy = iitem[1] - } - else { - ilox = iitem.x - iloy = iitem.y - ihix = iitem.x + iitem.width - ihiy = iitem.y + iitem.height - } - - if (jitem.length > 2) { - jlox = jitem[0] - jhix = jitem[2] - jloy = jitem[1] - jhiy = jitem[3] - } - else if (jitem.length) { - jlox = jloy = jitem[0] - jhix = jhiy = jitem[1] - } - else { - jlox = jitem.x - jloy = jitem.y - jhix = jitem.x + jitem.width - jhiy = jitem.y + jitem.height - } - - return [ jlox, iloy, jhix, ihiy ] -} - - -function getPad (arg) { - if (typeof arg === 'number') { return [arg, arg, arg, arg] } - else if (arg.length === 2) { return [arg[0], arg[1], arg[0], arg[1]] } - else { - var box = rect(arg) - return [box.x, box.y, box.x + box.width, box.y + box.height] - } -} - -},{"array-bounds":53,"array-range":55,"flatten-vertex-data":216,"parse-rect":442,"pick-by-alias":448,"raf":467,"regl-scatter2d/scatter":476}],478:[function(_dereq_,module,exports){ -(function(pa,W){"object"===typeof exports&&"undefined"!==typeof module?module.exports=W():"function"===typeof define&&define.amd?define(W):pa.createREGL=W()})(this,function(){function pa(a,b){this.id=Ab++;this.type=a;this.data=b}function W(a){if(0===a.length)return[];var b=a.charAt(0),c=a.charAt(a.length-1);if(1>>=b;c=(255>>=c;b|=c;c=(15>>=c;b|=c;c=(3>>c>>1}function cb(){function a(a){a:{for(var b=16;268435456>=b;b*=16)if(a<=b){a=b;break a}a=0}b=c[bb(a)>>2];return 0>2].push(a)}var c=O(8,function(){return[]});return{alloc:a,free:b,allocType:function(b,c){var d=null;switch(b){case 5120:d=new Int8Array(a(c),0,c);break;case 5121:d=new Uint8Array(a(c),0,c);break;case 5122:d=new Int16Array(a(2*c),0,c);break;case 5123:d=new Uint16Array(a(2*c),0,c);break;case 5124:d=new Int32Array(a(4*c),0,c);break;case 5125:d=new Uint32Array(a(4*c),0,c);break;case 5126:d=new Float32Array(a(4*c),0,c);break;default:return null}return d.length!==c?d.subarray(0, -c):d},freeType:function(a){b(a.buffer)}}}function ka(a){return!!a&&"object"===typeof a&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&"number"===typeof a.offset&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||P(a.data))}function db(a,b,c,e,f,d){for(var n=0;ne&&(e=d.buffer.byteLength,5123===k?e>>=1:5125===k&&(e>>=2));d.vertCount=e;e=g;0>g&&(e=4,g=d.buffer.dimension,1===g&&(e=0),2===g&&(e=1),3===g&&(e=4));d.primType=e}function n(a){e.elementsCount--;delete k[a.id];a.buffer.destroy();a.buffer=null}var k={},r=0,p={uint8:5121,uint16:5123};b.oes_element_index_uint&&(p.uint32=5125);f.prototype.bind=function(){this.buffer.bind()};var u=[];return{create:function(a,b){function l(a){if(a)if("number"===typeof a)g(a),h.primType=4,h.vertCount=a|0, -h.type=5121;else{var b=null,c=35044,e=-1,f=-1,m=0,k=0;if(Array.isArray(a)||P(a)||ka(a))b=a;else if("data"in a&&(b=a.data),"usage"in a&&(c=jb[a.usage]),"primitive"in a&&(e=Sa[a.primitive]),"count"in a&&(f=a.count|0),"type"in a&&(k=p[a.type]),"length"in a)m=a.length|0;else if(m=f,5123===k||5122===k)m*=2;else if(5125===k||5124===k)m*=4;d(h,b,c,e,f,m,k)}else g(),h.primType=4,h.vertCount=0,h.type=5121;return l}var g=c.create(null,34963,!0),h=new f(g._buffer);e.elementsCount++;l(a);l._reglType="elements"; -l._elements=h;l.subdata=function(a,b){g.subdata(a,b);return l};l.destroy=function(){n(h)};return l},createStream:function(a){var b=u.pop();b||(b=new f(c.create(null,34963,!0,!1)._buffer));d(b,a,35040,-1,-1,0,0);return b},destroyStream:function(a){u.push(a)},getElements:function(a){return"function"===typeof a&&a._elements instanceof f?a._elements:null},clear:function(){R(k).forEach(n)}}}function kb(a){for(var b=z.allocType(5123,a.length),c=0;c>>31<<15,d=(e<<1>>>24)-127,e=e>>13&1023;b[c]=-24>d?f:-14>d?f+(e+1024>>-14-d):15>=d,c.height>>=d,C(c,e[d]),a.mipmask|=1<b;++b)a.images[b]=null;return a}function ib(a){for(var b=a.images,c=0;cb){for(var c=0;c=--this.refCount&&w(this)}});n.profile&&(d.getTotalTextureSize=function(){var a=0;Object.keys(Z).forEach(function(b){a+=Z[b].stats.size});return a});return{create2D:function(b,c){function e(a,b){var c=f.texInfo;v.call(c);var d=x();"number"===typeof a?"number"===typeof b?t(d,a|0,b|0):t(d,a|0,a|0):a?(N(c,a),B(d,a)):t(d,1,1);c.genMipmaps&&(d.mipmask=(d.width<<1)-1);f.mipmask=d.mipmask;r(f,d);f.internalformat=d.internalformat; -e.width=d.width;e.height=d.height;T(f);X(d,3553);Q(c,3553);Ba();ib(d);n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d.width,d.height,c.genMipmaps,!1));e.format=O[f.internalformat];e.type=ba[f.type];e.mag=oa[c.magFilter];e.min=Aa[c.minFilter];e.wrapS=ia[c.wrapS];e.wrapT=ia[c.wrapT];return e}var f=new E(3553);Z[f.id]=f;d.textureCount++;e(b,c);e.subimage=function(a,b,c,d){b|=0;c|=0;d|=0;var q=g();r(q,f);q.width=0;q.height=0;C(q,a);q.width=q.width||(f.width>>d)-b;q.height=q.height||(f.height>>d)- -c;T(f);l(q,3553,b,c,d);Ba();h(q);return e};e.resize=function(b,c){var d=b|0,g=c|0||d;if(d===f.width&&g===f.height)return e;e.width=f.width=d;e.height=f.height=g;T(f);for(var q,y=f.channels,G=f.type,H=0;f.mipmask>>H;++H){var ea=d>>H,fa=g>>H;if(!ea||!fa)break;q=z.zero.allocType(G,ea*fa*y);a.texImage2D(3553,H,f.format,ea,fa,0,f.format,f.type,q);q&&z.zero.freeType(q)}Ba();n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d,g,!1,!1));return e};e._reglType="texture2d";e._texture=f;n.profile&&(e.stats= -f.stats);e.destroy=function(){f.decRef()};return e},createCube:function(b,c,e,f,k,m){function A(a,b,c,d,e,J){var I,da=w.texInfo;v.call(da);for(I=0;6>I;++I)q[I]=x();if("number"===typeof a||!a)for(a=a|0||1,I=0;6>I;++I)t(q[I],a,a);else if("object"===typeof a)if(b)B(q[0],a),B(q[1],b),B(q[2],c),B(q[3],d),B(q[4],e),B(q[5],J);else if(N(da,a),p(w,a),"faces"in a)for(a=a.faces,I=0;6>I;++I)r(q[I],w),B(q[I],a[I]);else for(I=0;6>I;++I)B(q[I],a);r(w,q[0]);w.mipmask=da.genMipmaps?(q[0].width<<1)-1:q[0].mipmask; -w.internalformat=q[0].internalformat;A.width=q[0].width;A.height=q[0].height;T(w);for(I=0;6>I;++I)X(q[I],34069+I);Q(da,34067);Ba();n.profile&&(w.stats.size=Ja(w.internalformat,w.type,A.width,A.height,da.genMipmaps,!0));A.format=O[w.internalformat];A.type=ba[w.type];A.mag=oa[da.magFilter];A.min=Aa[da.minFilter];A.wrapS=ia[da.wrapS];A.wrapT=ia[da.wrapT];for(I=0;6>I;++I)ib(q[I]);return A}var w=new E(34067);Z[w.id]=w;d.cubeCount++;var q=Array(6);A(b,c,e,f,k,m);A.subimage=function(a,b,c,q,d){c|=0;q|=0; -d|=0;var e=g();r(e,w);e.width=0;e.height=0;C(e,b);e.width=e.width||(w.width>>d)-c;e.height=e.height||(w.height>>d)-q;T(w);l(e,34069+a,c,q,d);Ba();h(e);return A};A.resize=function(b){b|=0;if(b!==w.width){A.width=w.width=b;A.height=w.height=b;T(w);for(var c=0;6>c;++c)for(var q=0;w.mipmask>>q;++q)a.texImage2D(34069+c,q,w.format,b>>q,b>>q,0,w.format,w.type,null);Ba();n.profile&&(w.stats.size=Ja(w.internalformat,w.type,A.width,A.height,!1,!0));return A}};A._reglType="textureCube";A._texture=w;n.profile&& -(A.stats=w.stats);A.destroy=function(){w.decRef()};return A},clear:function(){for(var b=0;bc;++c)if(0!==(b.mipmask&1<>c,b.height>>c,0,b.internalformat,b.type,null); -else for(var e=0;6>e;++e)a.texImage2D(34069+e,c,b.internalformat,b.width>>c,b.height>>c,0,b.internalformat,b.type,null);Q(b.texInfo,b.target)})}}}function Ob(a,b,c,e,f,d){function n(a,b,c){this.target=a;this.texture=b;this.renderbuffer=c;var e=a=0;b?(a=b.width,e=b.height):c&&(a=c.width,e=c.height);this.width=a;this.height=e}function k(a){a&&(a.texture&&a.texture._texture.decRef(),a.renderbuffer&&a.renderbuffer._renderbuffer.decRef())}function r(a,b,c){a&&(a.texture?a.texture._texture.refCount+=1: -a.renderbuffer._renderbuffer.refCount+=1)}function p(b,c){c&&(c.texture?a.framebufferTexture2D(36160,b,c.target,c.texture._texture.texture,0):a.framebufferRenderbuffer(36160,b,36161,c.renderbuffer._renderbuffer.renderbuffer))}function u(a){var b=3553,c=null,e=null,d=a;"object"===typeof a&&(d=a.data,"target"in a&&(b=a.target|0));a=d._reglType;"texture2d"===a?c=d:"textureCube"===a?c=d:"renderbuffer"===a&&(e=d,b=36161);return new n(b,c,e)}function m(a,b,c,d,g){if(c)return a=e.create2D({width:a,height:b, -format:d,type:g}),a._texture.refCount=0,new n(3553,a,null);a=f.create({width:a,height:b,format:d});a._renderbuffer.refCount=0;return new n(36161,null,a)}function C(a){return a&&(a.texture||a.renderbuffer)}function l(a,b,c){a&&(a.texture?a.texture.resize(b,c):a.renderbuffer&&a.renderbuffer.resize(b,c))}function g(){this.id=N++;Q[this.id]=this;this.framebuffer=a.createFramebuffer();this.height=this.width=0;this.colorAttachments=[];this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment= -null}function h(a){a.colorAttachments.forEach(k);k(a.depthAttachment);k(a.stencilAttachment);k(a.depthStencilAttachment)}function qa(b){a.deleteFramebuffer(b.framebuffer);b.framebuffer=null;d.framebufferCount--;delete Q[b.id]}function t(b){var e;a.bindFramebuffer(36160,b.framebuffer);var d=b.colorAttachments;for(e=0;ed;++d){for(k=0;ka;++a)c[a].resize(d);b.width=b.height=d;return b},_reglType:"framebufferCube",destroy:function(){c.forEach(function(a){a.destroy()})}})},clear:function(){R(Q).forEach(qa)},restore:function(){R(Q).forEach(function(b){b.framebuffer=a.createFramebuffer();t(b)})}})}function ub(){this.w=this.z=this.y=this.x=this.state=0;this.buffer=null;this.size=0;this.normalized=!1;this.type=5126;this.divisor=this.stride=this.offset= -0}function Pb(a,b,c,e){a=c.maxAttributes;b=Array(a);for(c=0;ca&&(a=b.stats.uniformsCount)});return a},c.getMaxAttributesCount=function(){var a= -0;C.forEach(function(b){b.stats.attributesCount>a&&(a=b.stats.attributesCount)});return a});return{clear:function(){var b=a.deleteShader.bind(a);R(p).forEach(b);p={};R(u).forEach(b);u={};C.forEach(function(b){a.deleteProgram(b.program)});C.length=0;m={};c.shaderCount=0},program:function(a,b,d){var e=m[b];e||(e=m[b]={});var f=e[a];f||(f=new k(b,a),c.shaderCount++,r(f,d),e[a]=f,C.push(f));return f},restore:function(){p={};u={};for(var a=0;a>>=b;c=(255>>=c;b|=c;c=(15>>=c;b|=c;c=(3>>c>>1}function cb(){function a(a){a:{for(var b=16;268435456>=b;b*=16)if(a<=b){a=b;break a}a=0}b=c[bb(a)>>2];return 0>2].push(a)}var c=J(8,function(){return[]});return{alloc:a,free:b,allocType:function(b,c){var d=null;switch(b){case 5120:d=new Int8Array(a(c),0,c);break;case 5121:d=new Uint8Array(a(c),0,c);break;case 5122:d=new Int16Array(a(2*c),0,c);break;case 5123:d=new Uint16Array(a(2*c),0,c);break;case 5124:d=new Int32Array(a(4*c),0,c);break;case 5125:d=new Uint32Array(a(4*c),0,c);break;case 5126:d=new Float32Array(a(4*c),0,c);break;default:return null}return d.length!== +c?d.subarray(0,c):d},freeType:function(a){b(a.buffer)}}}function ma(a){return!!a&&"object"===typeof a&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&"number"===typeof a.offset&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||M(a.data))}function db(a,b,c,e,g,d){for(var n=0;nd&&(d=e.buffer.byteLength,5123===f?d>>=1:5125===f&&(d>>=2));e.vertCount=d;d=h;0>h&&(d=4,h=e.buffer.dimension,1===h&&(d=0),2===h&&(d=1),3===h&&(d=4));e.primType=d}function n(a){e.elementsCount--;delete f[a.id];a.buffer.destroy();a.buffer=null}var f={},r=0,q={uint8:5121,uint16:5123};b.oes_element_index_uint&&(q.uint32=5125);g.prototype.bind=function(){this.buffer.bind()};var t=[];return{create:function(a,b){function k(a){if(a)if("number"===typeof a)h(a),l.primType=4,l.vertCount=a|0, +l.type=5121;else{var b=null,c=35044,e=-1,g=-1,f=0,m=0;if(Array.isArray(a)||M(a)||ma(a))b=a;else if("data"in a&&(b=a.data),"usage"in a&&(c=jb[a.usage]),"primitive"in a&&(e=Sa[a.primitive]),"count"in a&&(g=a.count|0),"type"in a&&(m=q[a.type]),"length"in a)f=a.length|0;else if(f=g,5123===m||5122===m)f*=2;else if(5125===m||5124===m)f*=4;d(l,b,c,e,g,f,m)}else h(),l.primType=4,l.vertCount=0,l.type=5121;return k}var h=c.create(null,34963,!0),l=new g(h._buffer);e.elementsCount++;k(a);k._reglType="elements"; +k._elements=l;k.subdata=function(a,b){h.subdata(a,b);return k};k.destroy=function(){n(l)};return k},createStream:function(a){var b=t.pop();b||(b=new g(c.create(null,34963,!0,!1)._buffer));d(b,a,35040,-1,-1,0,0);return b},destroyStream:function(a){t.push(a)},getElements:function(a){return"function"===typeof a&&a._elements instanceof g?a._elements:null},clear:function(){S(f).forEach(n)}}}function kb(a){for(var b=x.allocType(5123,a.length),c=0;c>>31<<15,d=(e<<1>>>24)-127,e=e>>13&1023;b[c]=-24>d?g:-14>d?g+(e+1024>>-14-d):15>=e,c.height>>=e,C(c,d[e]),a.mipmask|=1<b;++b)a.images[b]=null;return a}function ib(a){for(var b=a.images,c=0;cb){for(var c=0;c=--this.refCount&&A(this)}});n.profile&&(d.getTotalTextureSize=function(){var a=0;Object.keys(X).forEach(function(b){a+=X[b].stats.size});return a});return{create2D:function(b,c){function e(a,b){var c=f.texInfo;y.call(c);var d=D();"number"===typeof a?"number"===typeof b?v(d,a|0,b|0):v(d,a|0,a|0):a?(O(c,a),N(d,a)):v(d,1,1);c.genMipmaps&&(d.mipmask=(d.width<<1)-1);f.mipmask=d.mipmask;r(f,d);f.internalformat=d.internalformat; +e.width=d.width;e.height=d.height;T(f);B(d,3553);R(c,3553);Aa();ib(d);n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d.width,d.height,c.genMipmaps,!1));e.format=J[f.internalformat];e.type=da[f.type];e.mag=oa[c.magFilter];e.min=za[c.minFilter];e.wrapS=ka[c.wrapS];e.wrapT=ka[c.wrapT];return e}var f=new F(3553);X[f.id]=f;d.textureCount++;e(b,c);e.subimage=function(a,b,c,d){b|=0;c|=0;d|=0;var p=h();r(p,f);p.width=0;p.height=0;C(p,a);p.width=p.width||(f.width>>d)-b;p.height=p.height||(f.height>>d)- +c;T(f);k(p,3553,b,c,d);Aa();l(p);return e};e.resize=function(b,c){var d=b|0,h=c|0||d;if(d===f.width&&h===f.height)return e;e.width=f.width=d;e.height=f.height=h;T(f);for(var p,w=f.channels,z=f.type,I=0;f.mipmask>>I;++I){var fa=d>>I,ga=h>>I;if(!fa||!ga)break;p=x.zero.allocType(z,fa*ga*w);a.texImage2D(3553,I,f.format,fa,ga,0,f.format,f.type,p);p&&x.zero.freeType(p)}Aa();n.profile&&(f.stats.size=Ja(f.internalformat,f.type,d,h,!1,!1));return e};e._reglType="texture2d";e._texture=f;n.profile&&(e.stats= +f.stats);e.destroy=function(){f.decRef()};return e},createCube:function(b,c,e,f,g,ua){function A(a,b,c,d,e,f){var H,Y=m.texInfo;y.call(Y);for(H=0;6>H;++H)p[H]=D();if("number"===typeof a||!a)for(a=a|0||1,H=0;6>H;++H)v(p[H],a,a);else if("object"===typeof a)if(b)N(p[0],a),N(p[1],b),N(p[2],c),N(p[3],d),N(p[4],e),N(p[5],f);else if(O(Y,a),q(m,a),"faces"in a)for(a=a.faces,H=0;6>H;++H)r(p[H],m),N(p[H],a[H]);else for(H=0;6>H;++H)N(p[H],a);r(m,p[0]);m.mipmask=Y.genMipmaps?(p[0].width<<1)-1:p[0].mipmask;m.internalformat= +p[0].internalformat;A.width=p[0].width;A.height=p[0].height;T(m);for(H=0;6>H;++H)B(p[H],34069+H);R(Y,34067);Aa();n.profile&&(m.stats.size=Ja(m.internalformat,m.type,A.width,A.height,Y.genMipmaps,!0));A.format=J[m.internalformat];A.type=da[m.type];A.mag=oa[Y.magFilter];A.min=za[Y.minFilter];A.wrapS=ka[Y.wrapS];A.wrapT=ka[Y.wrapT];for(H=0;6>H;++H)ib(p[H]);return A}var m=new F(34067);X[m.id]=m;d.cubeCount++;var p=Array(6);A(b,c,e,f,g,ua);A.subimage=function(a,b,c,p,d){c|=0;p|=0;d|=0;var e=h();r(e,m); +e.width=0;e.height=0;C(e,b);e.width=e.width||(m.width>>d)-c;e.height=e.height||(m.height>>d)-p;T(m);k(e,34069+a,c,p,d);Aa();l(e);return A};A.resize=function(b){b|=0;if(b!==m.width){A.width=m.width=b;A.height=m.height=b;T(m);for(var c=0;6>c;++c)for(var p=0;m.mipmask>>p;++p)a.texImage2D(34069+c,p,m.format,b>>p,b>>p,0,m.format,m.type,null);Aa();n.profile&&(m.stats.size=Ja(m.internalformat,m.type,A.width,A.height,!1,!0));return A}};A._reglType="textureCube";A._texture=m;n.profile&&(A.stats=m.stats);A.destroy= +function(){m.decRef()};return A},clear:function(){for(var b=0;bc;++c)if(0!==(b.mipmask&1<> +c,b.height>>c,0,b.internalformat,b.type,null);else for(var d=0;6>d;++d)a.texImage2D(34069+d,c,b.internalformat,b.width>>c,b.height>>c,0,b.internalformat,b.type,null);R(b.texInfo,b.target)})}}}function Ob(a,b,c,e,g,d){function n(a,b,c){this.target=a;this.texture=b;this.renderbuffer=c;var d=a=0;b?(a=b.width,d=b.height):c&&(a=c.width,d=c.height);this.width=a;this.height=d}function f(a){a&&(a.texture&&a.texture._texture.decRef(),a.renderbuffer&&a.renderbuffer._renderbuffer.decRef())}function r(a,b,c){a&& +(a.texture?a.texture._texture.refCount+=1:a.renderbuffer._renderbuffer.refCount+=1)}function q(b,c){c&&(c.texture?a.framebufferTexture2D(36160,b,c.target,c.texture._texture.texture,0):a.framebufferRenderbuffer(36160,b,36161,c.renderbuffer._renderbuffer.renderbuffer))}function t(a){var b=3553,c=null,d=null,e=a;"object"===typeof a&&(e=a.data,"target"in a&&(b=a.target|0));a=e._reglType;"texture2d"===a?c=e:"textureCube"===a?c=e:"renderbuffer"===a&&(d=e,b=36161);return new n(b,c,d)}function m(a,b,c,d, +f){if(c)return a=e.create2D({width:a,height:b,format:d,type:f}),a._texture.refCount=0,new n(3553,a,null);a=g.create({width:a,height:b,format:d});a._renderbuffer.refCount=0;return new n(36161,null,a)}function C(a){return a&&(a.texture||a.renderbuffer)}function k(a,b,c){a&&(a.texture?a.texture.resize(b,c):a.renderbuffer&&a.renderbuffer.resize(b,c),a.width=b,a.height=c)}function h(){this.id=O++;R[this.id]=this;this.framebuffer=a.createFramebuffer();this.height=this.width=0;this.colorAttachments=[];this.depthStencilAttachment= +this.stencilAttachment=this.depthAttachment=null}function l(a){a.colorAttachments.forEach(f);f(a.depthAttachment);f(a.stencilAttachment);f(a.depthStencilAttachment)}function u(b){a.deleteFramebuffer(b.framebuffer);b.framebuffer=null;d.framebufferCount--;delete R[b.id]}function v(b){var d;a.bindFramebuffer(36160,b.framebuffer);var e=b.colorAttachments;for(d=0;dd;++d){for(m=0;ma;++a)c[a].resize(d);b.width=b.height=d;return b},_reglType:"framebufferCube",destroy:function(){c.forEach(function(a){a.destroy()})}})},clear:function(){S(R).forEach(u)},restore:function(){B.cur=null;B.next=null;B.dirty=!0;S(R).forEach(function(b){b.framebuffer=a.createFramebuffer();v(b)})}})}function ub(){this.w=this.z=this.y= +this.x=this.state=0;this.buffer=null;this.size=0;this.normalized=!1;this.type=5126;this.divisor=this.stride=this.offset=0}function Pb(a,b,c,e){a=c.maxAttributes;b=Array(a);for(c=0;c +a&&(a=b.stats.uniformsCount)});return a},c.getMaxAttributesCount=function(){var a=0;C.forEach(function(b){b.stats.attributesCount>a&&(a=b.stats.attributesCount)});return a});return{clear:function(){var b=a.deleteShader.bind(a);S(q).forEach(b);q={};S(t).forEach(b);t={};C.forEach(function(b){a.deleteProgram(b.program)});C.length=0;m={};c.shaderCount=0},program:function(a,b,d){var e=m[b];e||(e=m[b]={});var g=e[a];g||(g=new f(b,a),c.shaderCount++,r(g,d),e[a]=g,C.push(g));return g},restore:function(){q= +{};t={};for(var a=0;a"+b+"?"+e+".constant["+b+"]:0;"}).join(""),"}}else{", -"if(",f,"(",e,".buffer)){",h,"=",g,".createStream(",34962,",",e,".buffer);","}else{",h,"=",g,".getBuffer(",e,".buffer);","}",k,'="type" in ',e,"?",q.glTypes,"[",e,".type]:",h,".dtype;",y.normalized,"=!!",e,".normalized;");d("size");d("offset");d("stride");d("divisor");c("}}");c.exit("if(",y.isStream,"){",g,".destroyStream(",h,");","}");return y})});return g}function M(a){var b=a["static"],c=a.dynamic,d={};Object.keys(b).forEach(function(a){var c=b[a];d[a]=x(function(a,b){return"number"===typeof c|| -"boolean"===typeof c?""+c:a.link(c)})});Object.keys(c).forEach(function(a){var b=c[a];d[a]=K(b,function(a,c){return a.invoke(c,b)})});return d}function w(a,b,c,d,e){var f=z(a,e),g=D(a,f,e),l=N(a,e),k=Q(a,e),m=P(a,e),xa=g.viewport;xa&&(k.viewport=xa);xa=h("scissor.box");(g=g[xa])&&(k[xa]=g);g=0>1)",u],");")}function b(){c(ba,".drawArraysInstancedANGLE(",[p,r,t,u],");")}n?B?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")):b()}function g(){function a(){c(l+".drawElements("+[p,t,C,r+"<<(("+C+"-5121)>>1)"]+");")}function b(){c(l+".drawArrays("+[p,r,t]+");")}n?B?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")): -b()}var h=a.shared,l=h.gl,k=h.draw,m=d.draw,n=function(){var e=m.elements,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(k,".","elements");e&&f("if("+e+")"+l+".bindBuffer(34963,"+e+".buffer.buffer);");return e}(),p=e("primitive"),r=e("offset"),t=function(){var e=m.count,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(k,".","count");return e}();if("number"===typeof t){if(0===t)return}else c("if(",t,"){"),c.exit("}");var u, -ba;ga&&(u=e("instances"),ba=a.instancing);var C=n+".type",B=m.elements&&wa(m.elements);ga&&("number"!==typeof u||0<=u)?"string"===typeof u?(c("if(",u,">0){"),f(),c("}else if(",u,"<0){"),g(),c("}")):f():g()}function ca(a,b,c,d,e){b=B();e=b.proc("body",e);ga&&(b.instancing=e.def(b.shared.extensions,".angle_instanced_arrays"));a(b,e,c,d);return b.compile().body}function W(a,b,c,d){ya(a,b);U(a,b,c,d.attributes,function(){return!0});Y(a,b,c,d.uniforms,function(){return!0});S(a,b,b,c)}function ba(a,b){var c= -a.proc("draw",1);ya(a,c);A(a,c,b.context);L(a,c,b.framebuffer);V(a,c,b);R(a,c,b.state);F(a,c,b,!1,!0);var d=b.shader.progVar.append(a,c);c(a.shared.gl,".useProgram(",d,".program);");if(b.shader.program)W(a,c,b,b.shader.program);else{var e=a.global.def("{}"),f=c.def(d,".id"),g=c.def(e,"[",f,"]");c(a.cond(g).then(g,".call(this,a0);")["else"](g,"=",e,"[",f,"]=",a.link(function(c){return ca(W,a,b,c,1)}),"(",d,");",g,".call(this,a0);"))}0=--this.refCount&&n(this)};f.profile&&(e.getTotalRenderbufferSize=function(){var a=0;Object.keys(u).forEach(function(b){a+=u[b].stats.size});return a});return{create:function(b,c){function l(b,c){var d=0,e=0,m=32854;"object"===typeof b&&b?("shape"in b?(e=b.shape,d=e[0]|0,e=e[1]|0):("radius"in b&&(d=e=b.radius|0),"width"in b&&(d=b.width|0),"height"in b&&(e=b.height|0)),"format"in b&&(m=k[b.format])): -"number"===typeof b?(d=b|0,e="number"===typeof c?c|0:d):b||(d=e=1);if(d!==g.width||e!==g.height||m!==g.format)return l.width=g.width=d,l.height=g.height=e,g.format=m,a.bindRenderbuffer(36161,g.renderbuffer),a.renderbufferStorage(36161,m,d,e),f.profile&&(g.stats.size=M[g.format]*g.width*g.height),l.format=r[g.format],l}var g=new d(a.createRenderbuffer());u[g.id]=g;e.renderbufferCount++;l(b,c);l.resize=function(b,c){var d=b|0,e=c|0||d;if(d===g.width&&e===g.height)return l;l.width=g.width=d;l.height= -g.height=e;a.bindRenderbuffer(36161,g.renderbuffer);a.renderbufferStorage(36161,g.format,d,e);f.profile&&(g.stats.size=M[g.format]*g.width*g.height);return l};l._reglType="renderbuffer";l._renderbuffer=g;f.profile&&(l.stats=g.stats);l.destroy=function(){g.decRef()};return l},clear:function(){R(u).forEach(n)},restore:function(){R(u).forEach(function(b){b.renderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,b.renderbuffer);a.renderbufferStorage(36161,b.format,b.width,b.height)});a.bindRenderbuffer(36161, -null)}}},Wa=[];Wa[6408]=4;Wa[6407]=3;var Na=[];Na[5121]=1;Na[5126]=4;Na[36193]=2;var Da=["x","y","z","w"],Ub="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),Ga={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771, -"one minus constant alpha":32772,"src alpha saturate":776},Xa={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Pa={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},wb={cw:2304,ccw:2305},xb=new aa(!1,!1,!1,function(){}),Xb=function(a,b){function c(){this.endQueryIndex=this.startQueryIndex=-1;this.sum=0;this.stats= -null}function e(a,b,d){var e=k.pop()||new c;e.startQueryIndex=a;e.endQueryIndex=b;e.sum=0;e.stats=d;r.push(e)}var f=b.ext_disjoint_timer_query;if(!f)return null;var d=[],n=[],k=[],r=[],p=[],u=[];return{beginQuery:function(a){var b=d.pop()||f.createQueryEXT();f.beginQueryEXT(35007,b);n.push(b);e(n.length-1,n.length,a)},endQuery:function(){f.endQueryEXT(35007)},pushScopeStats:e,update:function(){var a,b;a=n.length;if(0!==a){u.length=Math.max(u.length,a+1);p.length=Math.max(p.length,a+1);p[0]=0;var c= -u[0]=0;for(b=a=0;b=F.length&&e()}var c=yb(F,a);F[c]=b}}}function p(){var a=S.viewport,b=S.scissor_box;a[0]=a[1]=b[0]=b[1]=0;N.viewportWidth=N.framebufferWidth=N.drawingBufferWidth=a[2]=b[2]=l.drawingBufferWidth;N.viewportHeight=N.framebufferHeight=N.drawingBufferHeight=a[3]=b[3]=l.drawingBufferHeight}function u(){N.tick+=1;N.time=v();p();V.procs.poll()}function m(){p();V.procs.refresh();x&&x.update()}function v(){return(zb()-O)/1E3}a=Eb(a);if(!a)return null;var l=a.gl,g=l.getContextAttributes(); -l.isContextLost();var h=Fb(l,a);if(!h)return null;var z=Bb(),t={bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},B=h.extensions,x=Xb(l,B),O=zb(),K=l.drawingBufferWidth,P=l.drawingBufferHeight,N={tick:0,time:0,viewportWidth:K,viewportHeight:P,framebufferWidth:K,framebufferHeight:P,drawingBufferWidth:K,drawingBufferHeight:P,pixelRatio:a.pixelRatio},Q=Vb(l,B),K=Pb(l,B,Q,z),E=Gb(l,t,a,K),T=Hb(l,B,E,t),R=Qb(l,z,t,a),w=Kb(l, -B,Q,function(){V.procs.poll()},N,t,a),A=Wb(l,B,Q,t,a),L=Ob(l,B,Q,w,A,t),V=Tb(l,z,B,Q,E,T,w,L,{},K,R,{elements:null,primitive:4,count:-1,offset:0,instances:-1},N,x,a),z=Rb(l,L,V.procs.poll,N,g,B,Q),S=V.next,M=l.canvas,F=[],U=[],Y=[],W=[a.onDestroy],ca=null;M&&(M.addEventListener("webglcontextlost",f,!1),M.addEventListener("webglcontextrestored",d,!1));var aa=L.setFBO=n({framebuffer:ja.define.call(null,1,"framebuffer")});m();g=D(n,{clear:function(a){if("framebuffer"in a)if(a.framebuffer&&"framebufferCube"=== -a.framebuffer_reglType)for(var b=0;6>b;++b)aa(D({framebuffer:a.framebuffer.faces[b]},a),k);else aa(a,k);else k(null,a)},prop:ja.define.bind(null,1),context:ja.define.bind(null,2),"this":ja.define.bind(null,3),draw:n({}),buffer:function(a){return E.create(a,34962,!1,!1)},elements:function(a){return T.create(a,!1)},texture:w.create2D,cube:w.createCube,renderbuffer:A.create,framebuffer:L.create,framebufferCube:L.createCube,attributes:g,frame:r,on:function(a,b){var c;switch(a){case "frame":return r(b); -case "lost":c=U;break;case "restore":c=Y;break;case "destroy":c=W}c.push(b);return{cancel:function(){for(var a=0;a"+b+"?"+e+".constant["+b+"]:0;"}).join(""),"}}else{", +"if(",f,"(",e,".buffer)){",z,"=",g,".createStream(",34962,",",e,".buffer);","}else{",z,"=",g,".getBuffer(",e,".buffer);","}",k,'="type" in ',e,"?",p.glTypes,"[",e,".type]:",z,".dtype;",w.normalized,"=!!",e,".normalized;");d("size");d("offset");d("stride");d("divisor");c("}}");c.exit("if(",w.isStream,"){",g,".destroyStream(",z,");","}");return w})});return f}function M(a){var b=a["static"],c=a.dynamic,d={};Object.keys(b).forEach(function(a){var c=b[a];d[a]=D(function(a,b){return"number"===typeof c|| +"boolean"===typeof c?""+c:a.link(c)})});Object.keys(c).forEach(function(a){var b=c[a];d[a]=P(b,function(a,c){return a.invoke(c,b)})});return d}function A(a,b,c,d,e){var f=y(a,e),g=x(a,f,e),h=O(a,e),k=R(a,e),m=E(a,e),ba=g.viewport;ba&&(k.viewport=ba);ba=l("scissor.box");(g=g[ba])&&(k[ba]=g);g=0>1)",v],");")}function b(){c(u,".drawArraysInstancedANGLE(",[q,r,t,v],");")}n?da?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")):b()}function g(){function a(){c(k+".drawElements("+[q,t,C,r+"<<(("+C+"-5121)>>1)"]+");")}function b(){c(k+".drawArrays("+[q,r,t]+");")}n?da?a():(c("if(",n,"){"),a(),c("}else{"),b(),c("}")): +b()}var h=a.shared,k=h.gl,m=h.draw,l=d.draw,n=function(){var e=l.elements,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(m,".","elements");e&&f("if("+e+")"+k+".bindBuffer(34963,"+e+".buffer.buffer);");return e}(),q=e("primitive"),r=e("offset"),t=function(){var e=l.count,f=b;if(e){if(e.contextDep&&d.contextDynamic||e.propDep)f=c;e=e.append(a,f)}else e=f.def(m,".","count");return e}();if("number"===typeof t){if(0===t)return}else c("if(",t,"){"),c.exit("}");var v, +u;ea&&(v=e("instances"),u=a.instancing);var C=n+".type",da=l.elements&&va(l.elements);ea&&("number"!==typeof v||0<=v)?"string"===typeof v?(c("if(",v,">0){"),f(),c("}else if(",v,"<0){"),g(),c("}")):f():g()}function ca(a,b,c,d,e){b=N();e=b.proc("body",e);ea&&(b.instancing=e.def(b.shared.extensions,".angle_instanced_arrays"));a(b,e,c,d);return b.compile().body}function L(a,b,c,d){wa(a,b);U(a,b,c,d.attributes,function(){return!0});W(a,b,c,d.uniforms,function(){return!0});S(a,b,b,c)}function da(a,b){var c= +a.proc("draw",1);wa(a,c);ua(a,c,b.context);K(a,c,b.framebuffer);V(a,c,b);Q(a,c,b.state);G(a,c,b,!1,!0);var d=b.shader.progVar.append(a,c);c(a.shared.gl,".useProgram(",d,".program);");if(b.shader.program)L(a,c,b,b.shader.program);else{var e=a.global.def("{}"),f=c.def(d,".id"),g=c.def(e,"[",f,"]");c(a.cond(g).then(g,".call(this,a0);")["else"](g,"=",e,"[",f,"]=",a.link(function(c){return ca(L,a,b,c,1)}),"(",d,");",g,".call(this,a0);"))}0=--this.refCount&&n(this)};g.profile&&(e.getTotalRenderbufferSize=function(){var a=0;Object.keys(t).forEach(function(b){a+=t[b].stats.size});return a});return{create:function(b,c){function k(b,c){var d=0,e=0,m=32854; +"object"===typeof b&&b?("shape"in b?(e=b.shape,d=e[0]|0,e=e[1]|0):("radius"in b&&(d=e=b.radius|0),"width"in b&&(d=b.width|0),"height"in b&&(e=b.height|0)),"format"in b&&(m=f[b.format])):"number"===typeof b?(d=b|0,e="number"===typeof c?c|0:d):b||(d=e=1);if(d!==h.width||e!==h.height||m!==h.format)return k.width=h.width=d,k.height=h.height=e,h.format=m,a.bindRenderbuffer(36161,h.renderbuffer),a.renderbufferStorage(36161,m,d,e),g.profile&&(h.stats.size=Q[h.format]*h.width*h.height),k.format=r[h.format], +k}var h=new d(a.createRenderbuffer());t[h.id]=h;e.renderbufferCount++;k(b,c);k.resize=function(b,c){var d=b|0,e=c|0||d;if(d===h.width&&e===h.height)return k;k.width=h.width=d;k.height=h.height=e;a.bindRenderbuffer(36161,h.renderbuffer);a.renderbufferStorage(36161,h.format,d,e);g.profile&&(h.stats.size=Q[h.format]*h.width*h.height);return k};k._reglType="renderbuffer";k._renderbuffer=h;g.profile&&(k.stats=h.stats);k.destroy=function(){h.decRef()};return k},clear:function(){S(t).forEach(n)},restore:function(){S(t).forEach(function(b){b.renderbuffer= +a.createRenderbuffer();a.bindRenderbuffer(36161,b.renderbuffer);a.renderbufferStorage(36161,b.format,b.width,b.height)});a.bindRenderbuffer(36161,null)}}},Wa=[];Wa[6408]=4;Wa[6407]=3;var Na=[];Na[5121]=1;Na[5126]=4;Na[36193]=2;var Da=["x","y","z","w"],Ub="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),Ga={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771, +"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Xa={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Pa={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056, +invert:5386},wb={cw:2304,ccw:2305},xb=new Z(!1,!1,!1,function(){}),Xb=function(a,b){function c(){this.endQueryIndex=this.startQueryIndex=-1;this.sum=0;this.stats=null}function e(a,b,d){var e=n.pop()||new c;e.startQueryIndex=a;e.endQueryIndex=b;e.sum=0;e.stats=d;f.push(e)}if(!b.ext_disjoint_timer_query)return null;var g=[],d=[],n=[],f=[],r=[],q=[];return{beginQuery:function(a){var c=g.pop()||b.ext_disjoint_timer_query.createQueryEXT();b.ext_disjoint_timer_query.beginQueryEXT(35007,c);d.push(c);e(d.length- +1,d.length,a)},endQuery:function(){b.ext_disjoint_timer_query.endQueryEXT(35007)},pushScopeStats:e,update:function(){var a,c;a=d.length;if(0!==a){q.length=Math.max(q.length,a+1);r.length=Math.max(r.length,a+1);r[0]=0;var e=q[0]=0;for(c=a=0;c=G.length&&e()}var c=yb(G,a);G[c]=b}}}function q(){var a=S.viewport,b=S.scissor_box;a[0]=a[1]=b[0]=b[1]=0;O.viewportWidth= +O.framebufferWidth=O.drawingBufferWidth=a[2]=b[2]=k.drawingBufferWidth;O.viewportHeight=O.framebufferHeight=O.drawingBufferHeight=a[3]=b[3]=k.drawingBufferHeight}function t(){O.tick+=1;O.time=y();q();V.procs.poll()}function m(){q();V.procs.refresh();B&&B.update()}function y(){return(zb()-D)/1E3}a=Eb(a);if(!a)return null;var k=a.gl,h=k.getContextAttributes();k.isContextLost();var l=Fb(k,a);if(!l)return null;var u=Bb(),v={bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0, +cubeCount:0,renderbufferCount:0,maxTextureUnits:0},x=l.extensions,B=Xb(k,x),D=zb(),J=k.drawingBufferWidth,P=k.drawingBufferHeight,O={tick:0,time:0,viewportWidth:J,viewportHeight:P,framebufferWidth:J,framebufferHeight:P,drawingBufferWidth:J,drawingBufferHeight:P,pixelRatio:a.pixelRatio},R=Vb(k,x),J=Pb(k,x,R,u),F=Gb(k,v,a,J),T=Hb(k,x,F,v),Q=Qb(k,u,v,a),A=Kb(k,x,R,function(){V.procs.poll()},O,v,a),M=Wb(k,x,R,v,a),K=Ob(k,x,R,A,M,v),V=Tb(k,u,x,R,F,T,A,K,{},J,Q,{elements:null,primitive:4,count:-1,offset:0, +instances:-1},O,B,a),u=Rb(k,K,V.procs.poll,O,h,x,R),S=V.next,L=k.canvas,G=[],U=[],W=[],Z=[a.onDestroy],ca=null;L&&(L.addEventListener("webglcontextlost",g,!1),L.addEventListener("webglcontextrestored",d,!1));var aa=K.setFBO=n({framebuffer:la.define.call(null,1,"framebuffer")});m();h=E(n,{clear:function(a){if("framebuffer"in a)if(a.framebuffer&&"framebufferCube"===a.framebuffer_reglType)for(var b=0;6>b;++b)aa(E({framebuffer:a.framebuffer.faces[b]},a),f);else aa(a,f);else f(null,a)},prop:la.define.bind(null, +1),context:la.define.bind(null,2),"this":la.define.bind(null,3),draw:n({}),buffer:function(a){return F.create(a,34962,!1,!1)},elements:function(a){return T.create(a,!1)},texture:A.create2D,cube:A.createCube,renderbuffer:M.create,framebuffer:K.create,framebufferCube:K.createCube,attributes:h,frame:r,on:function(a,b){var c;switch(a){case "frame":return r(b);case "lost":c=U;break;case "restore":c=W;break;case "destroy":c=Z}c.push(b);return{cancel:function(){for(var a=0;a0) { - shapeX += 0.02 - } - } - - var data = new Float32Array(bufferSize) - var ptr = 0 - var xOffset = -0.5 * shapeX - for(var i=0; i0) { + shapeX += 0.02 + } + } + + var data = new Float32Array(bufferSize) + var ptr = 0 + var xOffset = -0.5 * shapeX + for(var i=0; i" + var clsTag = "" + + var nOPN = opnTag.length + var nCLS = clsTag.length + + var isRecursive = (TAG_CHR[0] === CHR_super0) || + (TAG_CHR[0] === CHR_sub0); + + var a = 0 + var b = -nCLS + while (a > -1) { + a = str.indexOf(opnTag, a) + if(a === -1) break + + b = str.indexOf(clsTag, a + nOPN) + if(b === -1) break + + if(b <= a) break + + for(var i = a; i < b + nCLS; ++i){ + if((i < a + nOPN) || (i >= b)) { + map[i] = null + str = str.substr(0, i) + " " + str.substr(i + 1) + } else { + if(map[i] !== null) { + var pos = map[i].indexOf(TAG_CHR[0]) + if(pos === -1) { + map[i] += TAG_CHR + } else { // i.e. to handle multiple sub/super-scripts + if(isRecursive) { + // i.e to increase the sub/sup number + map[i] = map[i].substr(0, pos + 1) + (1 + parseInt(map[i][pos + 1])) + map[i].substr(pos + 2) + } + } + } + } + } + + var start = a + nOPN + var remainingStr = str.substr(start, b - start) + + var c = remainingStr.indexOf(opnTag) + if(c !== -1) a = c + else a = b + nCLS + } + + return map +} + function transformPositions(positions, options, size) { var align = options.textAlign || "start" var baseline = options.textBaseline || "alphabetic" @@ -70151,27 +70303,169 @@ function transformPositions(positions, options, size) { }) } -function getPixels(canvas, context, str, size) { - var width = Math.ceil(context.measureText(str).width + 2*size)|0 - if(width > 8192) { - throw new Error("vectorize-text: String too long (sorry, this will get fixed later)") +function getPixels(canvas, context, rawString, fontSize, lineSpacing, styletags) { + + rawString = rawString.replace(/\n/g, '') // don't accept \n in the input + + if(styletags.breaklines === true) { + rawString = rawString.replace(/\/g, '\n') // replace
tags with \n in the string + } else { + rawString = rawString.replace(/\/g, ' ') // don't accept
tags in the input and replace with space in this case } - var height = 3 * size - if(canvas.height < height) { - canvas.height = height + + var activeStyle = "" + var map = [] + for(j = 0; j < rawString.length; ++j) { + map[j] = activeStyle + } + + if(styletags.bolds === true) map = parseTag(TAG_bold, CHR_bold, rawString, map) + if(styletags.italics === true) map = parseTag(TAG_italic, CHR_italic, rawString, map) + if(styletags.superscripts === true) map = parseTag(TAG_super, CHR_super, rawString, map) + if(styletags.subscripts === true) map = parseTag(TAG_sub, CHR_sub, rawString, map) + + var allStyles = [] + var plainText = "" + for(j = 0; j < rawString.length; ++j) { + if(map[j] !== null) { + plainText += rawString[j] + allStyles.push(map[j]) + } + } + + var allTexts = plainText.split('\n') + + var numberOfLines = allTexts.length + var lineHeight = Math.round(lineSpacing * fontSize) + var offsetX = fontSize + var offsetY = fontSize * 2 + var maxWidth = 0 + var minHeight = numberOfLines * lineHeight + offsetY + + if(canvas.height < minHeight) { + canvas.height = minHeight } context.fillStyle = "#000" context.fillRect(0, 0, canvas.width, canvas.height) context.fillStyle = "#fff" - context.fillText(str, size, 2*size) + var i, j, xPos, yPos, zPos + var nDone = 0 - //Cut pixels from image - var pixelData = context.getImageData(0, 0, width, height) - var pixels = ndarray(pixelData.data, [height, width, 4]) + for(i = 0; i < numberOfLines; ++i) { + + var txt = allTexts[i] + '\n' + xPos = 0 + yPos = i * lineHeight + zPos = fontSize + + var buffer = "" + function writeBuffer() { + if(buffer !== "") { + var delta = context.measureText(buffer).width + + context.fillText(buffer, offsetX + xPos, offsetY + yPos) + xPos += delta + } + } + + function changeStyle(oldStyle, newStyle) { + + function getTextFontSize() { + return "" + Math.round(zPos) + "px "; + } + + var ctxFont = "" + context.font; + + if(styletags.subscripts === true) { + var oldIndex_Sub = oldStyle.indexOf(CHR_sub0); + var newIndex_Sub = newStyle.indexOf(CHR_sub0); + + var oldSub = (oldIndex_Sub > -1) ? parseInt(oldStyle[1 + oldIndex_Sub]) : 0; + var newSub = (newIndex_Sub > -1) ? parseInt(newStyle[1 + newIndex_Sub]) : 0; + + if(oldSub !== newSub) { + ctxFont = ctxFont.replace(getTextFontSize(), "?px ") + zPos *= Math.pow(0.75, (newSub - oldSub)) + ctxFont = ctxFont.replace("?px ", getTextFontSize()) + } + yPos += 0.25 * lineHeight * (newSub - oldSub); + } + + if(styletags.superscripts === true) { + var oldIndex_Super = oldStyle.indexOf(CHR_super0); + var newIndex_Super = newStyle.indexOf(CHR_super0); + + var oldSuper = (oldIndex_Super > -1) ? parseInt(oldStyle[1 + oldIndex_Super]) : 0; + var newSuper = (newIndex_Super > -1) ? parseInt(newStyle[1 + newIndex_Super]) : 0; + + if(oldSuper !== newSuper) { + ctxFont = ctxFont.replace(getTextFontSize(), "?px ") + zPos *= Math.pow(0.75, (newSuper - oldSuper)) + ctxFont = ctxFont.replace("?px ", getTextFontSize()) + } + yPos -= 0.25 * lineHeight * (newSuper - oldSuper); + } + + if(styletags.bolds === true) { + var wasBold = (oldStyle.indexOf(CHR_bold) > -1) + var is_Bold = (newStyle.indexOf(CHR_bold) > -1) + + if(!wasBold && is_Bold) { + if(wasItalic) { + ctxFont = ctxFont.replace("italic ", "italic bold ") + } else { + ctxFont = "bold " + ctxFont + } + } + if(wasBold && !is_Bold) { + ctxFont = ctxFont.replace("bold ", '') + } + } + + if(styletags.italics === true) { + var wasItalic = (oldStyle.indexOf(CHR_italic) > -1) + var is_Italic = (newStyle.indexOf(CHR_italic) > -1) + + if(!wasItalic && is_Italic) { + ctxFont = "italic " + ctxFont + } + if(wasItalic && !is_Italic) { + ctxFont = ctxFont.replace("italic ", '') + } + } + + context.font = ctxFont + } + + for(j = 0; j < txt.length; ++j) { + var style = (j + nDone < allStyles.length) ? allStyles[j + nDone] : allStyles[allStyles.length - 1] + if(activeStyle === style) { + buffer += txt[j] + } else { + writeBuffer() + buffer = txt[j] + + if(style !== undefined) { + changeStyle(activeStyle, style) + activeStyle = style + } + } + } + writeBuffer() - return pixels.pick(-1,-1,0).transpose(1,0) + nDone += txt.length + + var width = Math.round(xPos + 2 * offsetX) | 0 + if(maxWidth < width) maxWidth = width + } + + //Cut pixels from image + var xCut = maxWidth + var yCut = offsetY + lineHeight * numberOfLines + var pixels = ndarray(context.getImageData(0, 0, xCut, yCut).data, [yCut, xCut, 4]) + return pixels.pick(-1, -1, 0).transpose(1, 0) } function getContour(pixels, doSimplify) { @@ -70258,20 +70552,65 @@ function processPixels(pixels, options, size) { } function vectorizeText(str, canvas, context, options) { - var size = options.size || 64 - var family = options.font || "normal" - context.font = size + "px " + family + var size = 64 + var lineSpacing = 1.25 + var styletags = { + breaklines: false, + bolds: false, + italics: false, + subscripts: false, + superscripts: false + } + + if(options) { + + if(options.size && + options.size > 0) size = + options.size + + if(options.lineSpacing && + options.lineSpacing > 0) lineSpacing = + options.lineSpacing + + if(options.styletags && + options.styletags.breaklines) styletags.breaklines = + options.styletags.breaklines ? true : false + + if(options.styletags && + options.styletags.bolds) styletags.bolds = + options.styletags.bolds ? true : false + + if(options.styletags && + options.styletags.italics) styletags.italics = + options.styletags.italics ? true : false + + if(options.styletags && + options.styletags.subscripts) styletags.subscripts = + options.styletags.subscripts ? true : false + + if(options.styletags && + options.styletags.superscripts) styletags.superscripts = + options.styletags.superscripts ? true : false + } + + context.font = [ + options.fontStyle, + options.fontVariant, + options.fontWeight, + size + "px", + options.font + ].filter(function(d) {return d}).join(" ") context.textAlign = "start" context.textBaseline = "alphabetic" context.direction = "ltr" - var pixels = getPixels(canvas, context, str, size) + var pixels = getPixels(canvas, context, str, size, lineSpacing, styletags) return processPixels(pixels, options, size) } -},{"cdt2d":94,"clean-pslg":104,"ndarray":433,"planar-graph-to-polyline":451,"simplify-planar-graph":500,"surface-nets":508}],529:[function(_dereq_,module,exports){ +},{"cdt2d":94,"clean-pslg":104,"ndarray":433,"planar-graph-to-polyline":451,"simplify-planar-graph":500,"surface-nets":507}],528:[function(_dereq_,module,exports){ // Copyright (C) 2011 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -70958,7 +71297,7 @@ function vectorizeText(str, canvas, context, options) { } })(); -},{}],530:[function(_dereq_,module,exports){ +},{}],529:[function(_dereq_,module,exports){ var hiddenStore = _dereq_('./hidden-store.js'); module.exports = createStore; @@ -70979,7 +71318,7 @@ function createStore() { }; } -},{"./hidden-store.js":531}],531:[function(_dereq_,module,exports){ +},{"./hidden-store.js":530}],530:[function(_dereq_,module,exports){ module.exports = hiddenStore; function hiddenStore(obj, key) { @@ -70997,7 +71336,7 @@ function hiddenStore(obj, key) { return store; } -},{}],532:[function(_dereq_,module,exports){ +},{}],531:[function(_dereq_,module,exports){ // Original - @Gozola. // https://gist.github.com/Gozala/1269991 // This is a reimplemented version (with a few bug fixes). @@ -71028,14 +71367,14 @@ function weakMap() { } } -},{"./create-store.js":530}],533:[function(_dereq_,module,exports){ +},{"./create-store.js":529}],532:[function(_dereq_,module,exports){ var getContext = _dereq_('get-canvas-context') module.exports = function getWebGLContext (opt) { return getContext('webgl', opt) } -},{"get-canvas-context":221}],534:[function(_dereq_,module,exports){ +},{"get-canvas-context":221}],533:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -71768,7 +72107,7 @@ function toSolar(yearOrDate, monthOrResult, day, isIntercalaryOrResult, result) } -},{"../main":548,"object-assign":437}],535:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],534:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -71952,7 +72291,7 @@ assign(CopticCalendar.prototype, { main.calendars.coptic = CopticCalendar; -},{"../main":548,"object-assign":437}],536:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],535:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -72180,7 +72519,7 @@ var centuries = { main.calendars.discworld = DiscworldCalendar; -},{"../main":548,"object-assign":437}],537:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],536:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -72364,7 +72703,7 @@ assign(EthiopianCalendar.prototype, { main.calendars.ethiopian = EthiopianCalendar; -},{"../main":548,"object-assign":437}],538:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],537:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -72638,7 +72977,7 @@ function mod(a, b) { main.calendars.hebrew = HebrewCalendar; -},{"../main":548,"object-assign":437}],539:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],538:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -72819,7 +73158,7 @@ assign(IslamicCalendar.prototype, { main.calendars.islamic = IslamicCalendar; -},{"../main":548,"object-assign":437}],540:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],539:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -73002,7 +73341,7 @@ assign(JulianCalendar.prototype, { main.calendars.julian = JulianCalendar; -},{"../main":548,"object-assign":437}],541:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],540:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -73297,7 +73636,7 @@ function amod(a, b) { main.calendars.mayan = MayanCalendar; -},{"../main":548,"object-assign":437}],542:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],541:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -73477,7 +73816,7 @@ assign(NanakshahiCalendar.prototype, { main.calendars.nanakshahi = NanakshahiCalendar; -},{"../main":548,"object-assign":437}],543:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],542:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -73900,7 +74239,7 @@ assign(NepaliCalendar.prototype, { main.calendars.nepali = NepaliCalendar; -},{"../main":548,"object-assign":437}],544:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],543:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -74090,7 +74429,7 @@ main.calendars.persian = PersianCalendar; main.calendars.jalali = PersianCalendar; -},{"../main":548,"object-assign":437}],545:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],544:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -74276,7 +74615,7 @@ assign(TaiwanCalendar.prototype, { main.calendars.taiwan = TaiwanCalendar; -},{"../main":548,"object-assign":437}],546:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],545:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -74462,7 +74801,7 @@ assign(ThaiCalendar.prototype, { main.calendars.thai = ThaiCalendar; -},{"../main":548,"object-assign":437}],547:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],546:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -74827,7 +75166,7 @@ var ummalqura_dat = [ 79990]; -},{"../main":548,"object-assign":437}],548:[function(_dereq_,module,exports){ +},{"../main":547,"object-assign":437}],547:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -75732,7 +76071,7 @@ _exports.baseCalendar = BaseCalendar; _exports.calendars.gregorian = GregorianCalendar; -},{"object-assign":437}],549:[function(_dereq_,module,exports){ +},{"object-assign":437}],548:[function(_dereq_,module,exports){ /* * World Calendars * https://github.com/alexcjohnson/world-calendars @@ -76234,7 +76573,7 @@ assign(main.baseCalendar.prototype, { }); -},{"./main":548,"object-assign":437}],550:[function(_dereq_,module,exports){ +},{"./main":547,"object-assign":437}],549:[function(_dereq_,module,exports){ module.exports = _dereq_('cwise-compiler')({ args: ['array', { offset: [1], @@ -76286,7 +76625,7 @@ module.exports = _dereq_('cwise-compiler')({ funcName: 'zeroCrossings' }) -},{"cwise-compiler":134}],551:[function(_dereq_,module,exports){ +},{"cwise-compiler":134}],550:[function(_dereq_,module,exports){ "use strict" module.exports = findZeroCrossings @@ -76299,7 +76638,7 @@ function findZeroCrossings(array, level) { core(array.hi(array.shape[0]-1), cross, level) return cross } -},{"./lib/zc-core":550}],552:[function(_dereq_,module,exports){ +},{"./lib/zc-core":549}],551:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76370,7 +76709,7 @@ module.exports = [ } ]; -},{}],553:[function(_dereq_,module,exports){ +},{}],552:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76725,7 +77064,7 @@ module.exports = templatedArray('annotation', { } }); -},{"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750,"../../plots/font_attributes":771,"./arrow_paths":552}],554:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746,"../../plots/font_attributes":767,"./arrow_paths":551}],553:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76814,7 +77153,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"./draw":559}],555:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"./draw":558}],554:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -76953,7 +77292,7 @@ function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":696,"../../plot_api/plot_template":734,"../../registry":827}],556:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../registry":823}],555:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77033,7 +77372,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":696,"../color":570}],557:[function(_dereq_,module,exports){ +},{"../../lib":692,"../color":569}],556:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77096,7 +77435,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":722,"fast-isnumeric":214}],558:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":718,"fast-isnumeric":214}],557:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77202,7 +77541,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/cartesian/axes":744,"./attributes":553,"./common_defaults":556}],559:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/cartesian/axes":740,"./attributes":552,"./common_defaults":555}],558:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -77616,14 +77955,14 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { x: borderfull + xShift - 1, y: borderfull + yShift }) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; annText.call(svgTextUtils.positionText, textx, texty) - .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null); + .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); } annTextClip.select('rect').call(Drawing.setRect, borderfull, borderfull, @@ -77789,7 +78128,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }); }, doneFn: function() { - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -77872,7 +78211,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { }, doneFn: function() { setCursor(annTextGroupInner); - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); var notesBox = document.querySelector('.js-notes-box-panel'); if(notesBox) notesBox.redraw(notesBox.selectedObj); } @@ -77896,13 +78235,13 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { modifyBase(ya._name + '.autorange', true); } - Registry.call('relayout', gd, getUpdateObj()); + Registry.call('_guiRelayout', gd, getUpdateObj()); }); } else annText.call(textLayout); } -},{"../../lib":696,"../../lib/setcursor":716,"../../lib/svg_text_utils":720,"../../plot_api/plot_template":734,"../../plots/cartesian/axes":744,"../../plots/plots":808,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"../fx":612,"./draw_arrow_head":560,"d3":148}],560:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/setcursor":712,"../../lib/svg_text_utils":716,"../../plot_api/plot_template":730,"../../plots/cartesian/axes":740,"../../plots/plots":804,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"../fx":608,"./draw_arrow_head":559,"d3":148}],559:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78056,7 +78395,7 @@ module.exports = function drawArrowHead(el3, ends, options) { if(doEnd) drawhead(headStyle, end, endRot, scale); }; -},{"../color":570,"./arrow_paths":552,"d3":148}],561:[function(_dereq_,module,exports){ +},{"../color":569,"./arrow_paths":551,"d3":148}],560:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78090,7 +78429,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":755,"./attributes":553,"./calc_autorange":554,"./click":555,"./convert_coords":557,"./defaults":558,"./draw":559}],562:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":751,"./attributes":552,"./calc_autorange":553,"./click":554,"./convert_coords":556,"./defaults":557,"./draw":558}],561:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78178,7 +78517,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../annotations/attributes":553}],563:[function(_dereq_,module,exports){ +},{"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../annotations/attributes":552}],562:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78243,7 +78582,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":696,"../../plots/cartesian/axes":744}],564:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740}],563:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78319,7 +78658,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/cartesian/axes":744,"../annotations/common_defaults":556,"./attributes":562}],565:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/cartesian/axes":740,"../annotations/common_defaults":555,"./attributes":561}],564:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78371,7 +78710,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":796,"../annotations/draw":559}],566:[function(_dereq_,module,exports){ +},{"../../plots/gl3d/project":792,"../annotations/draw":558}],565:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78419,7 +78758,7 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":696,"../../registry":827,"./attributes":562,"./convert":563,"./defaults":564,"./draw":565}],567:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"./attributes":561,"./convert":562,"./defaults":563,"./draw":564}],566:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78452,7 +78791,7 @@ _dereq_('world-calendars/dist/calendars/taiwan'); _dereq_('world-calendars/dist/calendars/thai'); _dereq_('world-calendars/dist/calendars/ummalqura'); -},{"world-calendars/dist/calendars/chinese":534,"world-calendars/dist/calendars/coptic":535,"world-calendars/dist/calendars/discworld":536,"world-calendars/dist/calendars/ethiopian":537,"world-calendars/dist/calendars/hebrew":538,"world-calendars/dist/calendars/islamic":539,"world-calendars/dist/calendars/julian":540,"world-calendars/dist/calendars/mayan":541,"world-calendars/dist/calendars/nanakshahi":542,"world-calendars/dist/calendars/nepali":543,"world-calendars/dist/calendars/persian":544,"world-calendars/dist/calendars/taiwan":545,"world-calendars/dist/calendars/thai":546,"world-calendars/dist/calendars/ummalqura":547,"world-calendars/dist/main":548,"world-calendars/dist/plus":549}],568:[function(_dereq_,module,exports){ +},{"world-calendars/dist/calendars/chinese":533,"world-calendars/dist/calendars/coptic":534,"world-calendars/dist/calendars/discworld":535,"world-calendars/dist/calendars/ethiopian":536,"world-calendars/dist/calendars/hebrew":537,"world-calendars/dist/calendars/islamic":538,"world-calendars/dist/calendars/julian":539,"world-calendars/dist/calendars/mayan":540,"world-calendars/dist/calendars/nanakshahi":541,"world-calendars/dist/calendars/nepali":542,"world-calendars/dist/calendars/persian":543,"world-calendars/dist/calendars/taiwan":544,"world-calendars/dist/calendars/thai":545,"world-calendars/dist/calendars/ummalqura":546,"world-calendars/dist/main":547,"world-calendars/dist/plus":548}],567:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78726,7 +79065,7 @@ module.exports = { worldCalFmt: worldCalFmt }; -},{"../../constants/numerical":673,"../../lib":696,"./calendars":567}],569:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"./calendars":566}],568:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78766,7 +79105,7 @@ exports.borderLine = '#BEC8D9'; // gives back exactly lightLine if the other colors are defaults. exports.lightFraction = 100 * (0xe - 0x4) / (0xf - 0x4); -},{}],570:[function(_dereq_,module,exports){ +},{}],569:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -78937,7 +79276,7 @@ function cleanOne(val) { return 'rgb(' + rgbStr + ')'; } -},{"./attributes":569,"fast-isnumeric":214,"tinycolor2":514}],571:[function(_dereq_,module,exports){ +},{"./attributes":568,"fast-isnumeric":214,"tinycolor2":513}],570:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79080,23 +79419,43 @@ module.exports = overrideAll({ exponentformat: axesAttrs.exponentformat, showexponent: axesAttrs.showexponent, title: { - valType: 'string', - - + text: { + valType: 'string', + + + }, + font: fontAttrs({ + + }), + side: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } }, - titlefont: fontAttrs({ - - }), - titleside: { - valType: 'enumerated', - values: ['right', 'top', 'bottom'], - - dflt: 'top', - + + _deprecated: { + title: { + valType: 'string', + + + }, + titlefont: fontAttrs({ + + }), + titleside: { + valType: 'enumerated', + values: ['right', 'top', 'bottom'], + + dflt: 'top', + + } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/cartesian/layout_attributes":757,"../../plots/font_attributes":771}],572:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/cartesian/layout_attributes":753,"../../plots/font_attributes":767}],571:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79105,10 +79464,10 @@ module.exports = overrideAll({ * LICENSE file in the root directory of this source tree. */ - 'use strict'; var drawColorbar = _dereq_('./draw'); +var flipScale = _dereq_('../colorscale/helpers').flipScale; /** * connectColorbar: create a colorbar from a trace, using its module to @@ -79148,12 +79507,16 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) { var cb = cd[0].t.cb = drawColorbar(gd, cbId); - cb.fillgradient(container.colorscale) + var scl = container.reversescale ? + flipScale(container.colorscale) : + container.colorscale; + + cb.fillgradient(scl) .zrange([container[moduleOpts.min], container[moduleOpts.max]]) .options(container.colorbar)(); }; -},{"./draw":575}],573:[function(_dereq_,module,exports){ +},{"../colorscale/helpers":580,"./draw":574}],572:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79181,7 +79544,7 @@ module.exports = { } }; -},{}],574:[function(_dereq_,module,exports){ +},{}],573:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79243,12 +79606,12 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); - coerce('title', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'titlefont', layout.font); - coerce('titleside'); + coerce('title.text', layout._dfltTitle.colorbar); + Lib.coerceFont(coerce, 'title.font', layout.font); + coerce('title.side'); }; -},{"../../lib":696,"../../plot_api/plot_template":734,"../../plots/cartesian/tick_label_defaults":764,"../../plots/cartesian/tick_mark_defaults":765,"../../plots/cartesian/tick_value_defaults":766,"./attributes":571}],575:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../plots/cartesian/tick_label_defaults":760,"../../plots/cartesian/tick_mark_defaults":761,"../../plots/cartesian/tick_value_defaults":762,"./attributes":570}],574:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79435,9 +79798,9 @@ module.exports = function draw(gd, id) { showticksuffix: opts.showticksuffix, ticksuffix: opts.ticksuffix, title: opts.title, - titlefont: opts.titlefont, showline: true, anchor: 'free', + side: 'right', position: 1 }, cbAxisOut = { @@ -79448,6 +79811,7 @@ module.exports = function draw(gd, id) { letter: 'y', font: fullLayout.font, noHover: true, + noTickson: true, calendar: fullLayout.calendar // not really necessary (yet?) }; @@ -79468,11 +79832,11 @@ module.exports = function draw(gd, id) { // save for other callers to access this axis component.axis = cbAxisOut; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { - cbAxisOut.titleside = opts.titleside; + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { + cbAxisOut.title.side = opts.title.side; cbAxisOut.titlex = opts.x + xpadFrac; cbAxisOut.titley = yBottomFrac + - (opts.titleside === 'top' ? lenFrac - ypadFrac : ypadFrac); + (opts.title.side === 'top' ? lenFrac - ypadFrac : ypadFrac); } if(opts.line.color && opts.tickmode === 'auto') { @@ -79532,17 +79896,18 @@ module.exports = function draw(gd, id) { Math.round(gs.l) + ',-' + Math.round(gs.t) + ')'); - cbAxisOut._axislayer = container.select('.cbaxis'); + var axisLayer = container.select('.cbaxis'); + var titleHeight = 0; - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // draw the title so we know how much room it needs // when we squish the axis. This one only applies to // top or bottom titles, not right side. var x = gs.l + (opts.x + xpadFrac) * gs.w, - fontSize = cbAxisOut.titlefont.size, + fontSize = cbAxisOut.title.font.size, y; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; } @@ -79556,7 +79921,7 @@ module.exports = function draw(gd, id) { } function drawAxis() { - if(['top', 'bottom'].indexOf(opts.titleside) !== -1) { + if(['top', 'bottom'].indexOf(opts.title.side) !== -1) { // squish the axis top to make room for the title var titleGroup = container.select('.cbtitle'), titleText = titleGroup.select('text'), @@ -79587,7 +79952,7 @@ module.exports = function draw(gd, id) { // TODO: configurable titleHeight += 5; - if(opts.titleside === 'top') { + if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; } @@ -79608,8 +79973,7 @@ module.exports = function draw(gd, id) { .attr('transform', 'translate(0,' + Math.round(gs.h * (1 - cbAxisOut.domain[1])) + ')'); - cbAxisOut._axislayer.attr('transform', 'translate(0,' + - Math.round(-gs.t) + ')'); + axisLayer.attr('transform', 'translate(0,' + Math.round(-gs.t) + ')'); var fills = container.select('.cbfills') .selectAll('rect.cbfill') @@ -79676,12 +80040,7 @@ module.exports = function draw(gd, id) { }); // force full redraw of labels and ticks - cbAxisOut._axislayer.selectAll('g.' + cbAxisOut._id + 'tick,path') - .remove(); - - cbAxisOut._pos = xLeft + thickPx + - (opts.outlinewidth||0) / 2 - (opts.ticks === 'outside' ? 1 : 0); - cbAxisOut.side = 'right'; + axisLayer.selectAll('g.' + cbAxisOut._id + 'tick,path').remove(); // separate out axis and title drawing, // so we don't need such complicated logic in Titles.draw @@ -79689,11 +80048,33 @@ module.exports = function draw(gd, id) { // this title call only handles side=right return Lib.syncOrAsync([ function() { - return Axes.doTicksSingle(gd, cbAxisOut, true); + var shift = xLeft + thickPx + + (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0); + + var vals = Axes.calcTicks(cbAxisOut); + var transFn = Axes.makeTransFn(cbAxisOut); + var labelFns = Axes.makeLabelFns(cbAxisOut, shift); + var tickSign = Axes.getTickSigns(cbAxisOut)[2]; + + Axes.drawTicks(gd, cbAxisOut, { + vals: cbAxisOut.ticks === 'inside' ? Axes.clipEnds(cbAxisOut, vals) : vals, + layer: axisLayer, + path: Axes.makeTickPath(cbAxisOut, shift, tickSign), + transFn: transFn + }); + + return Axes.drawLabels(gd, cbAxisOut, { + vals: vals, + layer: axisLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); }, function() { - if(['top', 'bottom'].indexOf(opts.titleside) === -1) { - var fontSize = cbAxisOut.titlefont.size, + if(['top', 'bottom'].indexOf(opts.title.side) === -1) { + var fontSize = cbAxisOut.title.font.size, y = cbAxisOut._offset + cbAxisOut._length / 2, x = gs.l + (cbAxisOut.position || 0) * gs.w + ((cbAxisOut.side === 'right') ? 10 + fontSize * ((cbAxisOut.showticklabels ? 1 : 0.5)) : @@ -79705,7 +80086,7 @@ module.exports = function draw(gd, id) { drawTitle('h' + cbAxisOut._id + 'title', { avoid: { selection: d3.select(gd).selectAll('g.' + cbAxisOut._id + 'tick'), - side: opts.titleside, + side: opts.title.side, offsetLeft: gs.l, offsetTop: 0, maxShift: fullLayout.width @@ -79718,15 +80099,10 @@ module.exports = function draw(gd, id) { } function drawTitle(titleClass, titleOpts) { - var trace = getTrace(); - var propName = 'colorbar.title'; - var containerName = trace._module.colorbar.container; - if(containerName) propName = containerName + '.' + propName; - var dfltTitleOpts = { propContainer: cbAxisOut, - propName: propName, - traceIndex: trace.index, + propName: getPropName('title'), + traceIndex: getTrace().index, placeholder: fullLayout._dfltTitle.colorbar, containerGroup: container.select('.cbtitle') }; @@ -79750,7 +80126,7 @@ module.exports = function draw(gd, id) { // TODO: why are we redrawing multiple times now with this? // I guess autoMargin doesn't like being post-promise? var innerWidth = thickPx + opts.outlinewidth / 2 + - Drawing.bBox(cbAxisOut._axislayer.node()).width; + Drawing.bBox(axisLayer.node()).width; titleEl = titleCont.select('text'); if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) { var mathJaxNode = titleCont @@ -79758,11 +80134,11 @@ module.exports = function draw(gd, id) { .node(), titleWidth; if(mathJaxNode && - ['top', 'bottom'].indexOf(opts.titleside) !== -1) { + ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; } else { - // note: the formula below works for all titlesides, + // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift // transform gets removed by Drawing.bBox @@ -79791,7 +80167,7 @@ module.exports = function draw(gd, id) { container.selectAll('.cboutline').attr({ x: xLeft, y: yTopPx + opts.ypad + - (opts.titleside === 'top' ? titleHeight : 0), + (opts.title.side === 'top' ? titleHeight : 0), width: Math.max(thickPx, 2), height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2) }) @@ -79878,11 +80254,10 @@ module.exports = function draw(gd, id) { setCursor(container); if(xf !== undefined && yf !== undefined) { - Registry.call('restyle', - gd, - {'colorbar.x': xf, 'colorbar.y': yf}, - getTrace().index - ); + var update = {}; + update[getPropName('x')] = xf; + update[getPropName('y')] = yf; + Registry.call('_guiRestyle', gd, update, getTrace().index); } } }); @@ -79900,6 +80275,14 @@ module.exports = function draw(gd, id) { } } + function getPropName(suffix) { + var trace = getTrace(); + var propName = 'colorbar.'; + var containerName = trace._module.colorbar.container; + if(containerName) propName = containerName + '.' + propName; + return propName + suffix; + } + // setter/getters for every item defined in opts Object.keys(opts).forEach(function(name) { component[name] = function(v) { @@ -79933,7 +80316,7 @@ module.exports = function draw(gd, id) { return component; }; -},{"../../constants/alignment":668,"../../lib":696,"../../lib/extend":685,"../../lib/setcursor":716,"../../lib/svg_text_utils":720,"../../plots/cartesian/axes":744,"../../plots/cartesian/axis_defaults":746,"../../plots/cartesian/layout_attributes":757,"../../plots/cartesian/position_defaults":760,"../../plots/plots":808,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"../titles":661,"./attributes":571,"./constants":573,"d3":148,"tinycolor2":514}],576:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../lib":692,"../../lib/extend":682,"../../lib/setcursor":712,"../../lib/svg_text_utils":716,"../../plots/cartesian/axes":740,"../../plots/cartesian/axis_defaults":742,"../../plots/cartesian/layout_attributes":753,"../../plots/cartesian/position_defaults":756,"../../plots/plots":804,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"../titles":657,"./attributes":570,"./constants":572,"d3":148,"tinycolor2":513}],575:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79952,7 +80335,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":696}],577:[function(_dereq_,module,exports){ +},{"../../lib":692}],576:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -79963,7 +80346,7 @@ module.exports = function hasColorbar(container) { 'use strict'; -var palettes = _dereq_('./scales.js'); +var palettes = _dereq_('./scales.js').scales; var paletteStr = Object.keys(palettes); function code(s) { @@ -80110,7 +80493,7 @@ module.exports = function colorScaleAttrs(context, opts) { valType: 'boolean', dflt: false, - editType: 'calc', + editType: 'plot', }; @@ -80127,7 +80510,7 @@ module.exports = function colorScaleAttrs(context, opts) { return attrs; }; -},{"./scales.js":589}],578:[function(_dereq_,module,exports){ +},{"./scales.js":584}],577:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80136,49 +80519,19 @@ module.exports = function colorScaleAttrs(context, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); -var scales = _dereq_('./scales'); -var flipScale = _dereq_('./flip_scale'); - - -module.exports = function calc(trace, vals, containerStr, cLetter) { - var container = trace; - var inputContainer = trace._input; - var fullInputContainer = trace._fullInput; - - // set by traces with groupby transforms - var updateStyle = trace.updateStyle; - - function doUpdate(attr, inputVal, fullVal) { - if(fullVal === undefined) fullVal = inputVal; - - if(updateStyle) { - updateStyle(trace._input, containerStr ? (containerStr + '.' + attr) : attr, inputVal); - } - else { - inputContainer[attr] = inputVal; - } - - container[attr] = fullVal; - if(fullInputContainer && (trace !== trace._fullInput)) { - if(updateStyle) { - updateStyle(trace._fullInput, containerStr ? (containerStr + '.' + attr) : attr, fullVal); - } - else { - fullInputContainer[attr] = fullVal; - } - } - } +module.exports = function calc(gd, trace, opts) { + var fullLayout = gd._fullLayout; + var vals = opts.vals; + var containerStr = opts.containerStr; + var cLetter = opts.cLetter; - if(containerStr) { - container = Lib.nestedProperty(container, containerStr).get(); - inputContainer = Lib.nestedProperty(inputContainer, containerStr).get(); - fullInputContainer = Lib.nestedProperty(fullInputContainer, containerStr).get() || {}; - } + var container = containerStr ? + Lib.nestedProperty(trace, containerStr).get() : + trace; var autoAttr = cLetter + 'auto'; var minAttr = cLetter + 'min'; @@ -80201,37 +80554,19 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { max += 0.5; } - doUpdate(minAttr, min); - doUpdate(maxAttr, max); - - /* - * If auto was explicitly false but min or max was missing, - * we filled in the missing piece here but later the trace does - * not look auto. - * Otherwise make sure the trace still looks auto as far as later - * changes are concerned. - */ - doUpdate(autoAttr, (auto !== false || (min === undefined && max === undefined))); + container['_' + minAttr] = container[minAttr] = min; + container['_' + maxAttr] = container[maxAttr] = max; if(container.autocolorscale) { - if(min * max < 0) scl = scales.RdBu; - else if(min >= 0) scl = scales.Reds; - else scl = scales.Blues; + if(min * max < 0) scl = fullLayout.colorscale.diverging; + else if(min >= 0) scl = fullLayout.colorscale.sequential; + else scl = fullLayout.colorscale.sequentialminus; - // reversescale is handled at the containerOut level - doUpdate('colorscale', scl, container.reversescale ? flipScale(scl) : scl); - - // We pushed a colorscale back to input, which will change the default autocolorscale next time - // to avoid spurious redraws from Plotly.react, update resulting autocolorscale now - // This is a conscious decision so that changing the data later does not unexpectedly - // give you a new colorscale - if(!inputContainer.autocolorscale) { - doUpdate('autocolorscale', false); - } + container._colorscale = container.colorscale = scl; } }; -},{"../../lib":696,"./flip_scale":582,"./scales":589}],579:[function(_dereq_,module,exports){ +},{"../../lib":692}],578:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80242,12 +80577,68 @@ module.exports = function calc(trace, vals, containerStr, cLetter) { 'use strict'; -var scales = _dereq_('./scales'); +var Lib = _dereq_('../../lib'); +var hasColorscale = _dereq_('./helpers').hasColorscale; + +module.exports = function crossTraceDefaults(fullData) { + function replace(cont, k) { + var val = cont['_' + k]; + if(val !== undefined) { + cont[k] = val; + } + } + + function relinkColorAtts(trace, cAttrs) { + var cont = cAttrs.container ? + Lib.nestedProperty(trace, cAttrs.container).get() : + trace; + if(cont) { + var isAuto = cont.zauto || cont.cauto; + var minAttr = cAttrs.min; + var maxAttr = cAttrs.max; + + if(isAuto || cont[minAttr] === undefined) { + replace(cont, minAttr); + } + if(isAuto || cont[maxAttr] === undefined) { + replace(cont, maxAttr); + } + if(cont.autocolorscale) { + replace(cont, 'colorscale'); + } + } + } + + for(var i = 0; i < fullData.length; i++) { + var trace = fullData[i]; + var _module = trace._module; + + if(_module.colorbar) { + relinkColorAtts(trace, _module.colorbar); + } -module.exports = scales.RdBu; + // TODO could generalize _module.colorscale and use it here? -},{"./scales":589}],580:[function(_dereq_,module,exports){ + if(hasColorscale(trace, 'marker.line')) { + relinkColorAtts(trace, { + container: 'marker.line', + min: 'cmin', + max: 'cmax' + }); + } + + if(hasColorscale(trace, 'line')) { + relinkColorAtts(trace, { + container: 'line', + min: 'cmin', + max: 'cmax' + }); + } + } +}; + +},{"../../lib":692,"./helpers":580}],579:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80256,33 +80647,32 @@ module.exports = scales.RdBu; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); - var hasColorbar = _dereq_('../colorbar/has_colorbar'); var colorbarDefaults = _dereq_('../colorbar/defaults'); -var isValidScale = _dereq_('./is_valid_scale'); -var flipScale = _dereq_('./flip_scale'); +var isValidScale = _dereq_('./scales').isValid; + +function npMaybe(cont, prefix) { + var containerStr = prefix.slice(0, prefix.length - 1); + return prefix ? + Lib.nestedProperty(cont, containerStr).get() || {} : + cont; +} module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, opts) { - var prefix = opts.prefix, - cLetter = opts.cLetter, - containerStr = prefix.slice(0, prefix.length - 1), - containerIn = prefix ? - Lib.nestedProperty(traceIn, containerStr).get() || {} : - traceIn, - containerOut = prefix ? - Lib.nestedProperty(traceOut, containerStr).get() || {} : - traceOut, - minIn = containerIn[cLetter + 'min'], - maxIn = containerIn[cLetter + 'max'], - sclIn = containerIn.colorscale; + var prefix = opts.prefix; + var cLetter = opts.cLetter; + var containerIn = npMaybe(traceIn, prefix); + var containerOut = npMaybe(traceOut, prefix); + var template = npMaybe(traceOut._template || {}, prefix) || {}; + var minIn = containerIn[cLetter + 'min']; + var maxIn = containerIn[cLetter + 'max']; var validMinMax = isNumeric(minIn) && isNumeric(maxIn) && (minIn < maxIn); coerce(prefix + cLetter + 'auto', !validMinMax); coerce(prefix + cLetter + 'min'); @@ -80290,19 +80680,17 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, // handles both the trace case (autocolorscale is false by default) and // the marker and marker.line case (autocolorscale is true by default) + var sclIn = containerIn.colorscale; + var sclTemplate = template.colorscale; var autoColorscaleDflt; if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn); + if(sclTemplate !== undefined) autoColorscaleDflt = !isValidScale(sclTemplate); coerce(prefix + 'autocolorscale', autoColorscaleDflt); - var sclOut = coerce(prefix + 'colorscale'); - - // reversescale is handled at the containerOut level - var reverseScale = coerce(prefix + 'reversescale'); - if(reverseScale) containerOut.colorscale = flipScale(sclOut); - // ... until Scatter.colorbar can handle marker line colorbars - if(prefix === 'marker.line.') return; + coerce(prefix + 'colorscale'); + coerce(prefix + 'reversescale'); - if(!opts.noScale) { + if(!opts.noScale && prefix !== 'marker.line.') { // handles both the trace case where the dflt is listed in attributes and // the marker case where the dflt is determined by hasColorbar var showScaleDflt; @@ -80313,109 +80701,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, } }; -},{"../../lib":696,"../colorbar/defaults":574,"../colorbar/has_colorbar":576,"./flip_scale":582,"./is_valid_scale":586,"fast-isnumeric":214}],581:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -/** - * Extract colorscale into numeric domain and color range. - * - * @param {array} scl colorscale array of arrays - * @param {number} cmin minimum color value (used to clamp scale) - * @param {number} cmax maximum color value (used to clamp scale) - */ -module.exports = function extractScale(scl, cmin, cmax) { - var N = scl.length, - domain = new Array(N), - range = new Array(N); - - for(var i = 0; i < N; i++) { - var si = scl[i]; - - domain[i] = cmin + si[0] * (cmax - cmin); - range[i] = si[1]; - } - - return { - domain: domain, - range: range - }; -}; - -},{}],582:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function flipScale(scl) { - var N = scl.length, - sclNew = new Array(N), - si; - - for(var i = N - 1, j = 0; i >= 0; i--, j++) { - si = scl[i]; - sclNew[j] = [1 - si[0], si[1]]; - } - - return sclNew; -}; - -},{}],583:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var defaultScale = _dereq_('./default_scale'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function getScale(scl, dflt) { - if(!dflt) dflt = defaultScale; - if(!scl) return dflt; - - function parseScale() { - try { - scl = scales[scl] || JSON.parse(scl); - } - catch(e) { - scl = dflt; - } - } - - if(typeof scl === 'string') { - parseScale(); - // occasionally scl is double-JSON encoded... - if(typeof scl === 'string') parseScale(); - } - - if(!isValidScaleArray(scl)) return dflt; - return scl; -}; - -},{"./default_scale":579,"./is_valid_scale_array":587,"./scales":589}],584:[function(_dereq_,module,exports){ +},{"../../lib":692,"../colorbar/defaults":573,"../colorbar/has_colorbar":575,"./scales":584,"fast-isnumeric":214}],580:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80426,11 +80712,16 @@ module.exports = function getScale(scl, dflt) { 'use strict'; +var d3 = _dereq_('d3'); +var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); + var Lib = _dereq_('../../lib'); -var isValidScale = _dereq_('./is_valid_scale'); +var Color = _dereq_('../color'); -module.exports = function hasColorscale(trace, containerStr) { +var isValidScale = _dereq_('./scales').isValid; + +function hasColorscale(trace, containerStr) { var container = containerStr ? Lib.nestedProperty(trace, containerStr).get() || {} : trace; @@ -80455,117 +80746,61 @@ module.exports = function hasColorscale(trace, containerStr) { Lib.isPlainObject(container.colorbar) ) ); -}; - -},{"../../lib":696,"./is_valid_scale":586,"fast-isnumeric":214}],585:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -exports.scales = _dereq_('./scales'); - -exports.defaultScale = _dereq_('./default_scale'); - -exports.attributes = _dereq_('./attributes'); - -exports.handleDefaults = _dereq_('./defaults'); - -exports.calc = _dereq_('./calc'); - -exports.hasColorscale = _dereq_('./has_colorscale'); - -exports.isValidScale = _dereq_('./is_valid_scale'); - -exports.getScale = _dereq_('./get_scale'); - -exports.flipScale = _dereq_('./flip_scale'); - -exports.extractScale = _dereq_('./extract_scale'); - -exports.makeColorScaleFunc = _dereq_('./make_color_scale_func'); - -},{"./attributes":577,"./calc":578,"./default_scale":579,"./defaults":580,"./extract_scale":581,"./flip_scale":582,"./get_scale":583,"./has_colorscale":584,"./is_valid_scale":586,"./make_color_scale_func":588,"./scales":589}],586:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var scales = _dereq_('./scales'); -var isValidScaleArray = _dereq_('./is_valid_scale_array'); - - -module.exports = function isValidScale(scl) { - if(scales[scl] !== undefined) return true; - else return isValidScaleArray(scl); -}; +} -},{"./is_valid_scale_array":587,"./scales":589}],587:[function(_dereq_,module,exports){ /** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var tinycolor = _dereq_('tinycolor2'); - - -module.exports = function isValidScaleArray(scl) { - var highestVal = 0; + * Extract colorscale into numeric domain and color range. + * + * @param {object} cont colorscale container (e.g. trace, marker) + * - colorscale {array of arrays} + * - cmin/zmin {number} + * - cmax/zmax {number} + * - reversescale {boolean} + * @param {object} opts + * - cLetter {string} 'c' (for cmin/cmax) or 'z' (for zmin/zmax) + * + * @return {object} + * - domain {array} + * - range {array} + */ +function extractScale(cont, opts) { + var cLetter = opts.cLetter; - if(!Array.isArray(scl) || scl.length < 2) return false; + var scl = cont.reversescale ? + flipScale(cont.colorscale) : + cont.colorscale; - if(!scl[0] || !scl[scl.length - 1]) return false; + // minimum color value (used to clamp scale) + var cmin = cont[cLetter + 'min']; + // maximum color value (used to clamp scale) + var cmax = cont[cLetter + 'max']; - if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + var N = scl.length; + var domain = new Array(N); + var range = new Array(N); - for(var i = 0; i < scl.length; i++) { + for(var i = 0; i < N; i++) { var si = scl[i]; - - if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { - return false; - } - - highestVal = +si[0]; + domain[i] = cmin + si[0] * (cmax - cmin); + range[i] = si[1]; } - return true; -}; - -},{"tinycolor2":514}],588:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; + return { + domain: domain, + range: range + }; +} -var d3 = _dereq_('d3'); -var tinycolor = _dereq_('tinycolor2'); -var isNumeric = _dereq_('fast-isnumeric'); +function flipScale(scl) { + var N = scl.length; + var sclNew = new Array(N); -var Color = _dereq_('../color'); + for(var i = N - 1, j = 0; i >= 0; i--, j++) { + var si = scl[i]; + sclNew[j] = [1 - si[0], si[1]]; + } + return sclNew; +} /** * General colorscale function generator. @@ -80580,7 +80815,7 @@ var Color = _dereq_('../color'); * * @return {function} */ -module.exports = function makeColorScaleFunc(specs, opts) { +function makeColorScaleFunc(specs, opts) { opts = opts || {}; var domain = specs.domain, @@ -80632,7 +80867,7 @@ module.exports = function makeColorScaleFunc(specs, opts) { sclFunc.range = function() { return range; }; return sclFunc; -}; +} function colorArray2rbga(colorArray) { var colorObj = { @@ -80645,7 +80880,54 @@ function colorArray2rbga(colorArray) { return tinycolor(colorObj).toRgbString(); } -},{"../color":570,"d3":148,"fast-isnumeric":214,"tinycolor2":514}],589:[function(_dereq_,module,exports){ +module.exports = { + hasColorscale: hasColorscale, + extractScale: extractScale, + flipScale: flipScale, + makeColorScaleFunc: makeColorScaleFunc +}; + +},{"../../lib":692,"../color":569,"./scales":584,"d3":148,"fast-isnumeric":214,"tinycolor2":513}],581:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var scales = _dereq_('./scales'); +var helpers = _dereq_('./helpers'); + +module.exports = { + moduleType: 'component', + name: 'colorscale', + + attributes: _dereq_('./attributes'), + layoutAttributes: _dereq_('./layout_attributes'), + + supplyLayoutDefaults: _dereq_('./layout_defaults'), + handleDefaults: _dereq_('./defaults'), + crossTraceDefaults: _dereq_('./cross_trace_defaults'), + + calc: _dereq_('./calc'), + + // ./scales.js is required in lib/coerce.js ; + // it needs to be a seperate module to avoid circular a dependency + scales: scales.scales, + defaultScale: scales.defaultScale, + getScale: scales.get, + isValidScale: scales.isValid, + + hasColorscale: helpers.hasColorscale, + flipScale: helpers.flipScale, + extractScale: helpers.extractScale, + makeColorScaleFunc: helpers.makeColorScaleFunc +}; + +},{"./attributes":576,"./calc":577,"./cross_trace_defaults":578,"./defaults":579,"./helpers":580,"./layout_attributes":582,"./layout_defaults":583,"./scales":584}],582:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80656,8 +80938,76 @@ function colorArray2rbga(colorArray) { 'use strict'; +var scales = _dereq_('./scales').scales; + +var msg = 'Note that `autocolorscale` must be true for this attribute to work.'; module.exports = { + editType: 'calc', + sequential: { + valType: 'colorscale', + dflt: scales.Reds, + + editType: 'calc', + + }, + sequentialminus: { + valType: 'colorscale', + dflt: scales.Blues, + + editType: 'calc', + + }, + diverging: { + valType: 'colorscale', + dflt: scales.RdBu, + + editType: 'calc', + + } +}; + +},{"./scales":584}],583:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var Lib = _dereq_('../../lib'); +var colorscaleAttrs = _dereq_('./layout_attributes'); +var Template = _dereq_('../../plot_api/plot_template'); + +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var colorscaleIn = layoutIn.colorscale; + var colorscaleOut = Template.newContainer(layoutOut, 'colorscale'); + function coerce(attr, dflt) { + return Lib.coerce(colorscaleIn, colorscaleOut, colorscaleAttrs, attr, dflt); + } + + coerce('sequential'); + coerce('sequentialminus'); + coerce('diverging'); +}; + +},{"../../lib":692,"../../plot_api/plot_template":730,"./layout_attributes":582}],584:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var tinycolor = _dereq_('tinycolor2'); + +var scales = { 'Greys': [ [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] ], @@ -80788,7 +81138,67 @@ module.exports = { ] }; -},{}],590:[function(_dereq_,module,exports){ +var defaultScale = scales.RdBu; + +function getScale(scl, dflt) { + if(!dflt) dflt = defaultScale; + if(!scl) return dflt; + + function parseScale() { + try { + scl = scales[scl] || JSON.parse(scl); + } catch(e) { + scl = dflt; + } + } + + if(typeof scl === 'string') { + parseScale(); + // occasionally scl is double-JSON encoded... + if(typeof scl === 'string') parseScale(); + } + + if(!isValidScaleArray(scl)) return dflt; + return scl; +} + + +function isValidScaleArray(scl) { + var highestVal = 0; + + if(!Array.isArray(scl) || scl.length < 2) return false; + + if(!scl[0] || !scl[scl.length - 1]) return false; + + if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false; + + for(var i = 0; i < scl.length; i++) { + var si = scl[i]; + + if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) { + return false; + } + + highestVal = +si[0]; + } + + return true; +} + +function isValidScale(scl) { + if(scales[scl] !== undefined) return true; + else return isValidScaleArray(scl); +} + +module.exports = { + scales: scales, + defaultScale: defaultScale, + + get: getScale, + isValid: isValidScale +}; + +},{"tinycolor2":513}],585:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80821,7 +81231,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],591:[function(_dereq_,module,exports){ +},{}],586:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80859,7 +81269,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":696}],592:[function(_dereq_,module,exports){ +},{"../../lib":692}],587:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -80986,8 +81396,6 @@ dragElement.init = function init(options) { var clampFn = options.clampFn || _clampFn; function onStart(e) { - e.preventDefault(); - // make dragging and dragged into properties of gd // so that others can look at and modify them gd._dragged = false; @@ -81029,11 +81437,15 @@ dragElement.init = function init(options) { document.documentElement.style.cursor = window.getComputedStyle(element).cursor; } - document.addEventListener('mousemove', onMove); document.addEventListener('mouseup', onDone); - document.addEventListener('touchmove', onMove); document.addEventListener('touchend', onDone); + if(options.dragmode !== false) { + e.preventDefault(); + document.addEventListener('mousemove', onMove); + document.addEventListener('touchmove', onMove); + } + return; } @@ -81057,13 +81469,15 @@ dragElement.init = function init(options) { } function onDone(e) { - document.removeEventListener('mousemove', onMove); + if(options.dragmode !== false) { + e.preventDefault(); + document.removeEventListener('mousemove', onMove); + document.removeEventListener('touchmove', onMove); + } + document.removeEventListener('mouseup', onDone); - document.removeEventListener('touchmove', onMove); document.removeEventListener('touchend', onDone); - e.preventDefault(); - if(hasHover) { Lib.removeElement(dragCover); } @@ -81156,7 +81570,7 @@ function pointerOffset(e) { ); } -},{"../../constants/interactions":672,"../../lib":696,"../../plots/cartesian/constants":750,"../../registry":827,"./align":590,"./cursor":591,"./unhover":593,"has-hover":393,"has-passive-events":394,"mouse-event-offset":419}],593:[function(_dereq_,module,exports){ +},{"../../constants/interactions":668,"../../lib":692,"../../plots/cartesian/constants":746,"../../registry":823,"./align":585,"./cursor":586,"./unhover":588,"has-hover":393,"has-passive-events":394,"mouse-event-offset":419}],588:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81214,7 +81628,7 @@ unhover.raw = function unhoverRaw(gd, evt) { } }; -},{"../../lib/events":684,"../../lib/get_graph_div":691,"../../lib/throttle":721,"../fx/constants":607}],594:[function(_dereq_,module,exports){ +},{"../../lib/events":681,"../../lib/get_graph_div":688,"../../lib/throttle":717,"../fx/constants":602}],589:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81239,7 +81653,7 @@ exports.dash = { }; -},{}],595:[function(_dereq_,module,exports){ +},{}],590:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -81440,7 +81854,11 @@ drawing.fillGroupStyle = function(s) { s.style('stroke-width', 0) .each(function(d) { var shape = d3.select(this); - shape.call(Color.fill, d[0].trace.fillcolor); + // N.B. 'd' won't be a calcdata item when + // fill !== 'none' on a segment-less and marker-less trace + if(d[0].trace) { + shape.call(Color.fill, d[0].trace.fillcolor); + } }); }; @@ -81881,7 +82299,7 @@ drawing.tryColorscale = function(marker, prefix) { if(scl && Lib.isArrayOrTypedArray(colorArray)) { return Colorscale.makeColorScaleFunc( - Colorscale.extractScale(scl, cont.cmin, cont.cmax) + Colorscale.extractScale(cont, {cLetter: 'c'}) ); } } @@ -82242,32 +82660,28 @@ function nodeHash(node) { node.getAttribute('style'); } -/* - * make a robust clipPath url from a local id - * note! We'd better not be exporting from a page - * with a or the svg will not be portable! +/** + * Set clipPath URL in a way that work for all situations. + * + * In details, graphs on pages with HTML tags need to prepend + * the clip path ids with the page's base url EXCEPT during toImage exports. + * + * @param {d3 selection} s : node to add clip-path attribute + * @param {string} localId : local clip-path (w/o base url) id + * @param {DOM element || object} gd + * - context._baseUrl {string} + * - context._exportedPlot {boolean} */ -drawing.setClipUrl = function(s, localId) { +drawing.setClipUrl = function(s, localId, gd) { if(!localId) { s.attr('clip-path', null); return; } - if(drawing.baseUrl === undefined) { - var base = d3.select('base'); - - // Stash base url once and for all! - // We may have to stash this elsewhere when - // we'll try to support for child windows - // more info -> https://github.com/plotly/plotly.js/issues/702 - if(base.size() && base.attr('href')) { - drawing.baseUrl = window.location.href.split('#')[0]; - } else { - drawing.baseUrl = ''; - } - } + var context = gd._context; + var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - s.attr('clip-path', 'url(' + drawing.baseUrl + '#' + localId + ')'); + s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')'); }; drawing.getTranslate = function(element) { @@ -82399,7 +82813,7 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../constants/alignment":668,"../../constants/interactions":672,"../../constants/xmlns_namespaces":674,"../../lib":696,"../../lib/svg_text_utils":720,"../../registry":827,"../../traces/scatter/make_bubble_size_func":1060,"../../traces/scatter/subtypes":1067,"../color":570,"../colorscale":585,"./symbol_defs":596,"d3":148,"fast-isnumeric":214,"tinycolor2":514}],596:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../constants/interactions":668,"../../constants/xmlns_namespaces":670,"../../lib":692,"../../lib/svg_text_utils":716,"../../registry":823,"../../traces/scatter/make_bubble_size_func":1057,"../../traces/scatter/subtypes":1064,"../color":569,"../colorscale":581,"./symbol_defs":591,"d3":148,"fast-isnumeric":214,"tinycolor2":513}],591:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -82887,7 +83301,7 @@ module.exports = { } }; -},{"d3":148}],597:[function(_dereq_,module,exports){ +},{"d3":148}],592:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83002,7 +83416,7 @@ module.exports = { } }; -},{}],598:[function(_dereq_,module,exports){ +},{}],593:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83084,7 +83498,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max); } -},{"../../plots/cartesian/axes":744,"../../registry":827,"./compute_error":599,"fast-isnumeric":214}],599:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../../registry":823,"./compute_error":594,"fast-isnumeric":214}],594:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83188,7 +83602,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],600:[function(_dereq_,module,exports){ +},{}],595:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83264,7 +83678,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":696,"../../plot_api/plot_template":734,"../../registry":827,"./attributes":597,"fast-isnumeric":214}],601:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../registry":823,"./attributes":592,"fast-isnumeric":214}],596:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83333,7 +83747,7 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":696,"../../plot_api/edit_types":727,"./attributes":597,"./calc":598,"./compute_error":599,"./defaults":600,"./plot":602,"./style":603}],602:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/edit_types":723,"./attributes":592,"./calc":593,"./compute_error":594,"./defaults":595,"./plot":597,"./style":598}],597:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83351,7 +83765,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); var subTypes = _dereq_('../../traces/scatter/subtypes'); -module.exports = function plot(traces, plotinfo, transitionOpts) { +module.exports = function plot(gd, traces, plotinfo, transitionOpts) { var isNew; var xa = plotinfo.xaxis; @@ -83402,7 +83816,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { .style('opacity', 1); } - Drawing.setClipUrl(errorbars, plotinfo.layerClipId); + Drawing.setClipUrl(errorbars, plotinfo.layerClipId, gd); errorbars.each(function(d) { var errorbar = d3.select(this); @@ -83507,7 +83921,7 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":1067,"../drawing":595,"d3":148,"fast-isnumeric":214}],603:[function(_dereq_,module,exports){ +},{"../../traces/scatter/subtypes":1064,"../drawing":590,"d3":148,"fast-isnumeric":214}],598:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83544,7 +83958,7 @@ module.exports = function style(traces) { }); }; -},{"../color":570,"d3":148}],604:[function(_dereq_,module,exports){ +},{"../color":569,"d3":148}],599:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83590,7 +84004,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":771}],605:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":767}],600:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83627,6 +84041,8 @@ module.exports = function calc(gd) { fillFn(trace.hoverinfo, cd, 'hi', makeCoerceHoverInfo(trace)); + if(trace.hovertemplate) fillFn(trace.hovertemplate, cd, 'ht'); + if(!trace.hoverlabel) continue; fillFn(trace.hoverlabel.bgcolor, cd, 'hbg'); @@ -83646,7 +84062,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":696,"../../registry":827}],606:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],601:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83684,7 +84100,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":827,"./hover":610}],607:[function(_dereq_,module,exports){ +},{"../../registry":823,"./hover":605}],602:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83716,7 +84132,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],608:[function(_dereq_,module,exports){ +},{}],603:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83739,7 +84155,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, layout.hoverlabel); }; -},{"../../lib":696,"./attributes":604,"./hoverlabel_defaults":611}],609:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":599,"./hoverlabel_defaults":606}],604:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -83982,7 +84398,7 @@ function getPointData(val, pointNumber) { } } -},{"../../lib":696}],610:[function(_dereq_,module,exports){ +},{"../../lib":692}],605:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -84111,13 +84527,17 @@ exports.loneHover = function loneHover(hoverItem, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; var container3 = d3.select(opts.container); @@ -84131,7 +84551,6 @@ exports.loneHover = function loneHover(hoverItem, opts) { container: container3, outerContainer: outerContainer3 }; - var hoverLabel = createHoverText([pointData], fullOpts, opts.gd); alignHoverText(hoverLabel, fullOpts.rotateLabels); @@ -84165,13 +84584,17 @@ exports.multiHovers = function multiHovers(hoverItems, opts) { fontColor: hoverItem.fontColor, // filler to make createHoverText happy - trace: { + trace: hoverItem.trace || { index: 0, hoverinfo: '' }, xa: {_offset: 0}, ya: {_offset: 0}, - index: 0 + index: 0, + + hovertemplate: hoverItem.hovertemplate || false, + eventData: hoverItem.eventData || false, + hovertemplateLabels: hoverItem.hovertemplateLabels || false, }; }); @@ -84647,7 +85070,14 @@ function _hover(gd, evt, subplot, noHoverEvent) { // other people and send it to the event for(itemnum = 0; itemnum < hoverData.length; itemnum++) { var pt = hoverData[itemnum]; - newhoverdata.push(helpers.makeEventData(pt, pt.trace, pt.cd)); + var eventData = helpers.makeEventData(pt, pt.trace, pt.cd); + + var ht = false; + if(pt.cd[pt.index] && pt.cd[pt.index].ht) ht = pt.cd[pt.index].ht; + hoverData[itemnum].hovertemplate = ht || pt.trace.hovertemplate || false; + hoverData[itemnum].eventData = [eventData]; + + newhoverdata.push(eventData); } gd._hoverdata = newhoverdata; @@ -84705,6 +85135,8 @@ function _hover(gd, evt, subplot, noHoverEvent) { }); } +var EXTRA_STRING_REGEX = /([\s\S]*)<\/extra>/; + function createHoverText(hoverData, opts, gd) { var hovermode = opts.hovermode; var rotateLabels = opts.rotateLabels; @@ -84748,11 +85180,13 @@ function createHoverText(hoverData, opts, gd) { if(allHaveZ && hoverData[i].zLabel === undefined) allHaveZ = false; traceHoverinfo = hoverData[i].hoverinfo || hoverData[i].trace.hoverinfo; - var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); - if(parts.indexOf('all') === -1 && - parts.indexOf(hovermode) === -1) { - showCommonLabel = false; - break; + if(traceHoverinfo) { + var parts = Array.isArray(traceHoverinfo) ? traceHoverinfo : traceHoverinfo.split('+'); + if(parts.indexOf('all') === -1 && + parts.indexOf(hovermode) === -1) { + showCommonLabel = false; + break; + } } } @@ -84935,6 +85369,19 @@ function createHoverText(hoverData, opts, gd) { text = name; } + // hovertemplate + var hovertemplate = d.hovertemplate || false; + var hovertemplateLabels = d.hovertemplateLabels || d; + var eventData = d.eventData[0] || {}; + if(hovertemplate) { + text = Lib.hovertemplateString(hovertemplate, hovertemplateLabels, eventData); + + text = text.replace(EXTRA_STRING_REGEX, function(match, extra) { + name = extra; // Assign name for secondary text label + return ''; // Remove from main text label + }); + } + // main label var tx = g.select('text.nums') .call(Drawing.font, @@ -85333,7 +85780,7 @@ function cleanPoint(d, hovermode) { var infomode = d.hoverinfo || d.trace.hoverinfo; - if(infomode !== 'all') { + if(infomode && infomode !== 'all') { infomode = Array.isArray(infomode) ? infomode : infomode.split('+'); if(infomode.indexOf('x') === -1) d.xLabel = undefined; if(infomode.indexOf('y') === -1) d.yLabel = undefined; @@ -85519,8 +85966,11 @@ function hoverChanged(gd, evt, oldhoverdata) { for(var i = oldhoverdata.length - 1; i >= 0; i--) { var oldPt = oldhoverdata[i]; var newPt = gd._hoverdata[i]; + if(oldPt.curveNumber !== newPt.curveNumber || - String(oldPt.pointNumber) !== String(newPt.pointNumber)) { + String(oldPt.pointNumber) !== String(newPt.pointNumber) || + String(oldPt.pointNumbers) !== String(newPt.pointNumbers) + ) { return true; } } @@ -85536,7 +85986,7 @@ function spikesChanged(gd, oldspikepoints) { return false; } -},{"../../lib":696,"../../lib/events":684,"../../lib/override_cursor":707,"../../lib/svg_text_utils":720,"../../plots/cartesian/axes":744,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"./constants":607,"./helpers":609,"d3":148,"fast-isnumeric":214,"tinycolor2":514}],611:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/events":681,"../../lib/override_cursor":703,"../../lib/svg_text_utils":716,"../../plots/cartesian/axes":740,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"./constants":602,"./helpers":604,"d3":148,"fast-isnumeric":214,"tinycolor2":513}],606:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85558,7 +86008,49 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts Lib.coerceFont(coerce, 'hoverlabel.font', opts.font); }; -},{"../../lib":696}],612:[function(_dereq_,module,exports){ +},{"../../lib":692}],607:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function(opts, extra) { + opts = opts || {}; + extra = extra || {}; + + var descPart = extra.description ? ' ' + extra.description : ''; + var keys = extra.keys || []; + if(keys.length > 0) { + var quotedKeys = []; + for(var i = 0; i < keys.length; i++) { + quotedKeys[i] = '`' + keys[i] + '`'; + } + descPart = descPart + 'Finally, the template string has access to '; + if(keys.length === 1) { + descPart = 'variable ' + quotedKeys[0]; + } else { + descPart = 'variables ' + quotedKeys.slice(0, -1).join(', ') + ' and ' + quotedKeys.slice(-1) + '.'; + } + } + + var hovertemplate = { + valType: 'string', + + dflt: '', + arrayOk: true, + editType: 'none', + + }; + + return hovertemplate; +}; + +},{}],608:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85638,7 +86130,7 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":696,"../dragelement":592,"./attributes":604,"./calc":605,"./click":606,"./constants":607,"./defaults":608,"./helpers":609,"./hover":610,"./layout_attributes":613,"./layout_defaults":614,"./layout_global_defaults":615,"d3":148}],613:[function(_dereq_,module,exports){ +},{"../../lib":692,"../dragelement":587,"./attributes":599,"./calc":600,"./click":601,"./constants":602,"./defaults":603,"./helpers":604,"./hover":605,"./layout_attributes":609,"./layout_defaults":610,"./layout_global_defaults":611,"d3":148}],609:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85671,7 +86163,7 @@ module.exports = { dragmode: { valType: 'enumerated', - values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'], + values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable', false], dflt: 'zoom', editType: 'modebar', @@ -85733,7 +86225,7 @@ module.exports = { } }; -},{"../../plots/font_attributes":771,"./constants":607}],614:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":767,"./constants":602}],610:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85806,7 +86298,7 @@ function isHoriz(fullData) { return out; } -},{"../../lib":696,"./layout_attributes":613}],615:[function(_dereq_,module,exports){ +},{"../../lib":692,"./layout_attributes":609}],611:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -85829,7 +86321,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":696,"./hoverlabel_defaults":611,"./layout_attributes":613}],616:[function(_dereq_,module,exports){ +},{"../../lib":692,"./hoverlabel_defaults":606,"./layout_attributes":609}],612:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86214,7 +86706,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":696,"../../lib/regex":712,"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750,"../../plots/domain":770}],617:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/regex":708,"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746,"../../plots/domain":766}],613:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86349,7 +86841,7 @@ module.exports = templatedArray('image', { editType: 'arraydraw' }); -},{"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750}],618:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746}],614:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86432,7 +86924,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":722,"fast-isnumeric":214}],619:[function(_dereq_,module,exports){ +},{"../../lib/to_log_range":718,"fast-isnumeric":214}],615:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86493,7 +86985,7 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/cartesian/axes":744,"./attributes":617}],620:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/cartesian/axes":740,"./attributes":613}],616:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86664,9 +87156,10 @@ module.exports = function draw(gd) { yId = ya ? ya._id : '', clipAxes = xId + yId; - thisImage.call(Drawing.setClipUrl, clipAxes ? - ('clip' + fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + thisImage, + clipAxes ? ('clip' + fullLayout._uid + clipAxes) : null, + gd ); } @@ -86714,7 +87207,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":674,"../../plots/cartesian/axes":744,"../drawing":595,"d3":148}],621:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":670,"../../plots/cartesian/axes":740,"../drawing":590,"d3":148}],617:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86738,56 +87231,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":755,"./attributes":617,"./convert_coords":618,"./defaults":619,"./draw":620}],622:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - - -/** - * Determine the position anchor property of x/y xanchor/yanchor components. - * - * - values < 1/3 align the low side at that fraction, - * - values [1/3, 2/3] align the center at that fraction, - * - values > 2/3 align the right at that fraction. - */ - -exports.isRightAnchor = function isRightAnchor(opts) { - return ( - opts.xanchor === 'right' || - (opts.xanchor === 'auto' && opts.x >= 2 / 3) - ); -}; - -exports.isCenterAnchor = function isCenterAnchor(opts) { - return ( - opts.xanchor === 'center' || - (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) - ); -}; - -exports.isBottomAnchor = function isBottomAnchor(opts) { - return ( - opts.yanchor === 'bottom' || - (opts.yanchor === 'auto' && opts.y <= 1 / 3) - ); -}; - -exports.isMiddleAnchor = function isMiddleAnchor(opts) { - return ( - opts.yanchor === 'middle' || - (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) - ); -}; - -},{}],623:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":751,"./attributes":613,"./convert_coords":614,"./defaults":615,"./draw":616}],618:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86885,11 +87329,25 @@ module.exports = { editType: 'legend', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + valign: { + valType: 'enumerated', + values: ['top', 'middle', 'bottom'], + dflt: 'middle', + + editType: 'legend', + }, editType: 'legend' }; -},{"../../plots/font_attributes":771,"../color/attributes":569}],624:[function(_dereq_,module,exports){ +},{"../../plots/font_attributes":767,"../color/attributes":568}],619:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86908,7 +87366,7 @@ module.exports = { textOffsetX: 40 }; -},{}],625:[function(_dereq_,module,exports){ +},{}],620:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -86977,7 +87435,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { basePlotLayoutAttributes, 'showlegend', legendReallyHasATrace && legendTraceCount > 1); - if(showLegend === false) return; + if(showLegend === false && !containerIn.uirevision) return; var containerOut = Template.newContainer(layoutOut, 'legend'); @@ -86985,6 +87443,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); } + coerce('uirevision', layoutOut.uirevision); + + if(showLegend === false) return; + coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); @@ -86993,7 +87455,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('orientation'); if(containerOut.orientation === 'h') { var xaxis = layoutIn.xaxis; - if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { + if(Registry.getComponentMethod('rangeslider', 'isVisible')(xaxis)) { defaultX = 0; defaultXAnchor = 'left'; defaultY = 1.1; @@ -87014,10 +87476,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('xanchor', defaultXAnchor); coerce('y', defaultY); coerce('yanchor', defaultYAnchor); + coerce('valign'); Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); }; -},{"../../lib":696,"../../plot_api/plot_template":734,"../../plots/layout_attributes":799,"../../registry":827,"./attributes":623,"./helpers":629}],626:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../plots/layout_attributes":795,"../../registry":823,"./attributes":618,"./helpers":624}],621:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87050,7 +87513,6 @@ var FROM_BR = alignmentConstants.FROM_BR; var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); -var anchorUtils = _dereq_('./anchor_utils'); var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; @@ -87174,17 +87636,17 @@ module.exports = function draw(gd) { lx = gs.l + gs.w * opts.x, ly = gs.t + gs.h * (1 - opts.y); - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= opts._width; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= opts._height; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -87244,7 +87706,7 @@ module.exports = function draw(gd) { y: opts.borderwidth }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; @@ -87282,7 +87744,7 @@ module.exports = function draw(gd) { y: opts.borderwidth + scrollBoxY }); - Drawing.setClipUrl(scrollBox, clipId); + Drawing.setClipUrl(scrollBox, clipId, gd); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -87359,7 +87821,7 @@ module.exports = function draw(gd) { }, doneFn: function() { if(xf !== undefined && yf !== undefined) { - Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf}); + Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf}); } }, clickFn: function(numClicks, e) { @@ -87466,7 +87928,7 @@ function drawTexts(g, gd, maxLength) { update.name = newName; } - return Registry.call('restyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, traceIndex); }); } else { textLayout(textEl); @@ -87556,6 +88018,7 @@ function computeTextDimensions(g, gd) { // to avoid getBoundingClientRect var textY = lineHeight * (0.3 + (1 - textLines) / 2); svgTextUtils.positionText(text, constants.textOffsetX, textY); + legendItem.lineHeight = lineHeight; } height = Math.max(height, 16) + 3; @@ -87719,18 +88182,18 @@ function expandMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; } - else if(anchorUtils.isMiddleAnchor(opts)) { + else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -87750,10 +88213,10 @@ function expandHorizontalMargin(gd) { opts = fullLayout.legend; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { xanchor = 'right'; } - else if(anchorUtils.isCenterAnchor(opts)) { + else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } @@ -87768,7 +88231,7 @@ function expandHorizontalMargin(gd) { }); } -},{"../../constants/alignment":668,"../../constants/interactions":672,"../../lib":696,"../../lib/events":684,"../../lib/svg_text_utils":720,"../../plots/plots":808,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"./anchor_utils":622,"./constants":624,"./get_legend_data":627,"./handle_click":628,"./helpers":629,"./style":631,"d3":148}],627:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../constants/interactions":668,"../../lib":692,"../../lib/events":681,"../../lib/svg_text_utils":716,"../../plots/plots":804,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"./constants":619,"./get_legend_data":622,"./handle_click":623,"./helpers":624,"./style":626,"d3":148}],622:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87874,7 +88337,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":827,"./helpers":629}],628:[function(_dereq_,module,exports){ +},{"../../registry":823,"./helpers":624}],623:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -87988,7 +88451,7 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices); + Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices); } else { var hasLegendgroup = legendgroup && legendgroup.length; var traceIndicesInGroup = []; @@ -88094,11 +88557,11 @@ module.exports = function handleClick(g, gd, numClicks) { } } - Registry.call('restyle', gd, attrUpdate, attrIndices); + Registry.call('_guiRestyle', gd, attrUpdate, attrIndices); } }; -},{"../../lib":696,"../../registry":827}],629:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],624:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88122,7 +88585,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],630:[function(_dereq_,module,exports){ +},{}],625:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88146,7 +88609,7 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":623,"./defaults":625,"./draw":626,"./style":631}],631:[function(_dereq_,module,exports){ +},{"./attributes":618,"./defaults":620,"./draw":621,"./style":626}],626:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88174,6 +88637,19 @@ module.exports = function style(s, gd) { var layers = Lib.ensureSingle(traceGroup, 'g', 'layers'); layers.style('opacity', d[0].trace.opacity); + // Marker vertical alignment + var valign = gd._fullLayout.legend.valign; + var lineHeight = d[0].lineHeight; + var height = d[0].height; + + if(valign === 'middle' || !lineHeight || !height) { + layers.attr('transform', null); // this here is a fun d3 trick to unset DOM attributes + } else { + var factor = {top: 1, bottom: -1}[valign]; + var markerOffsetY = factor * (0.5 * (lineHeight - height + 3)); + layers.attr('transform', 'translate(0,' + markerOffsetY + ')'); + } + var fill = layers .selectAll('g.legendfill') .data([d]); @@ -88493,7 +88969,7 @@ module.exports = function style(s, gd) { } }; -},{"../../lib":696,"../../registry":827,"../../traces/pie/style_one":1029,"../../traces/scatter/subtypes":1067,"../color":570,"../drawing":595,"d3":148}],632:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"../../traces/pie/style_one":1026,"../../traces/scatter/subtypes":1064,"../color":569,"../drawing":590,"d3":148}],627:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -88757,7 +89233,7 @@ function handleCartesian(gd, ev) { aobj[astr] = val; } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.zoom3d = { @@ -88813,7 +89289,7 @@ function handleDrag3d(gd, ev) { var val2d = (val === 'pan') ? val : 'zoom'; layoutUpdate.dragmode = val2d; - Registry.call('relayout', gd, layoutUpdate); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.resetCameraDefault3d = { @@ -88852,7 +89328,7 @@ function handleCamera3d(gd, ev) { } } - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } modeBarButtons.hoverClosest3d = { @@ -88866,54 +89342,48 @@ modeBarButtons.hoverClosest3d = { click: handleHover3d }; -function handleHover3d(gd, ev) { +function getNextHover3d(gd, ev) { var button = ev.currentTarget; - var val = button._previousVal || false; - var layout = gd.layout; + var val = button._previousVal; var fullLayout = gd._fullLayout; var sceneIds = fullLayout._subplots.gl3d; var axes = ['xaxis', 'yaxis', 'zaxis']; - var spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor']; // initialize 'current spike' object to be stored in the DOM var currentSpikes = {}; - var axisSpikes = {}; var layoutUpdate = {}; if(val) { - layoutUpdate = Lib.extendDeep(layout, val); + layoutUpdate = val; button._previousVal = null; } else { - layoutUpdate = { - 'allaxes.showspikes': false - }; - for(var i = 0; i < sceneIds.length; i++) { - var sceneId = sceneIds[i], - sceneLayout = fullLayout[sceneId], - sceneSpikes = currentSpikes[sceneId] = {}; + var sceneId = sceneIds[i]; + var sceneLayout = fullLayout[sceneId]; - sceneSpikes.hovermode = sceneLayout.hovermode; - layoutUpdate[sceneId + '.hovermode'] = false; + var hovermodeAStr = sceneId + '.hovermode'; + currentSpikes[hovermodeAStr] = sceneLayout.hovermode; + layoutUpdate[hovermodeAStr] = false; // copy all the current spike attrs for(var j = 0; j < 3; j++) { var axis = axes[j]; - axisSpikes = sceneSpikes[axis] = {}; - - for(var k = 0; k < spikeAttrs.length; k++) { - var spikeAttr = spikeAttrs[k]; - axisSpikes[spikeAttr] = sceneLayout[axis][spikeAttr]; - } + var spikeAStr = sceneId + '.' + axis + '.showspikes'; + layoutUpdate[spikeAStr] = false; + currentSpikes[spikeAStr] = sceneLayout[axis].showspikes; } } - button._previousVal = Lib.extendDeep({}, currentSpikes); + button._previousVal = currentSpikes; } + return layoutUpdate; +} - Registry.call('relayout', gd, layoutUpdate); +function handleHover3d(gd, ev) { + var layoutUpdate = getNextHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } modeBarButtons.zoomInGeo = { @@ -88969,7 +89439,7 @@ function handleGeo(gd, ev) { var scale = geoLayout.projection.scale; var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; - Registry.call('relayout', gd, id + '.projection.scale', newScale); + Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); } else if(attr === 'reset') { resetView(gd, 'geo'); } @@ -88997,18 +89467,20 @@ modeBarButtons.hoverClosestPie = { click: toggleHover }; -function toggleHover(gd) { +function getNextHover(gd) { var fullLayout = gd._fullLayout; - var onHoverVal; + if(fullLayout.hovermode) return false; + if(fullLayout._has('cartesian')) { - onHoverVal = fullLayout._isHoriz ? 'y' : 'x'; + return fullLayout._isHoriz ? 'y' : 'x'; } - else onHoverVal = 'closest'; - - var newHover = gd._fullLayout.hovermode ? false : onHoverVal; + return 'closest'; +} - Registry.call('relayout', gd, 'hovermode', newHover); +function toggleHover(gd) { + var newHover = getNextHover(gd); + Registry.call('_guiRelayout', gd, 'hovermode', newHover); } // buttons when more then one plot types are present @@ -89022,12 +89494,10 @@ modeBarButtons.toggleHover = { icon: Icons.tooltip_basic, gravity: 'ne', click: function(gd, ev) { - toggleHover(gd); + var layoutUpdate = getNextHover3d(gd, ev); + layoutUpdate.hovermode = getNextHover(gd); - // the 3d hovermode update must come - // last so that layout.hovermode update does not - // override scene?.hovermode?.layout. - handleHover3d(gd, ev); + Registry.call('_guiRelayout', gd, layoutUpdate); } }; @@ -89063,7 +89533,7 @@ modeBarButtons.toggleSpikelines = { var aobj = setSpikelineVisibility(gd); - Registry.call('relayout', gd, aobj); + Registry.call('_guiRelayout', gd, aobj); } }; @@ -89110,10 +89580,10 @@ function resetView(gd, subplotType) { } } - Registry.call('relayout', gd, aObj); + Registry.call('_guiRelayout', gd, aObj); } -},{"../../../build/ploticon":2,"../../lib":696,"../../plots/cartesian/axis_ids":747,"../../plots/plots":808,"../../registry":827}],633:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":692,"../../plots/cartesian/axis_ids":743,"../../plots/plots":804,"../../registry":823}],628:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89127,7 +89597,7 @@ function resetView(gd, subplotType) { exports.manage = _dereq_('./manage'); -},{"./manage":634}],634:[function(_dereq_,module,exports){ +},{"./manage":629}],629:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89159,7 +89629,7 @@ module.exports = function manageModeBar(gd) { context = gd._context, modeBar = fullLayout._modeBar; - if(!context.displayModeBar) { + if(!context.displayModeBar && !context.watermark) { if(modeBar) { modeBar.destroy(); delete fullLayout._modeBar; @@ -89187,11 +89657,15 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); } + else if(!context.displayModeBar && context.watermark) { + buttonGroups = []; + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, - context.modeBarButtonsToAdd + context.modeBarButtonsToAdd, + context.showSendToCloud ); } @@ -89200,7 +89674,7 @@ module.exports = function manageModeBar(gd) { }; // logic behind which buttons are displayed by default -function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { +function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; @@ -89231,7 +89705,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { } // buttons common to all plot types - addGroup(['toImage', 'sendDataToCloud']); + var commonGroup = ['toImage']; + if(showSendToCloud) commonGroup.push('sendDataToCloud'); + addGroup(commonGroup); var zoomGroup = []; var hoverGroup = []; @@ -89382,7 +89858,7 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":747,"../../registry":827,"../../traces/scatter/subtypes":1067,"./buttons":632,"./modebar":635}],635:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axis_ids":743,"../../registry":823,"../../traces/scatter/subtypes":1064,"./buttons":627,"./modebar":630}],630:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89465,11 +89941,16 @@ proto.update = function(graphInfo, buttons) { this.updateButtons(buttons); - if(context.displaylogo) { + if(context.watermark || context.displaylogo) { + var logoGroup = this.getLogo(); + if(context.watermark) { + logoGroup.className = logoGroup.className + ' watermark'; + } + if(fullLayout.modebar.orientation === 'v') { - this.element.prepend(this.getLogo()); + this.element.prepend(logoGroup); } else { - this.element.appendChild(this.getLogo()); + this.element.appendChild(logoGroup); } this.hasLogo = true; @@ -89728,7 +90209,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../../build/ploticon":2,"../../lib":696,"d3":148,"fast-isnumeric":214}],636:[function(_dereq_,module,exports){ +},{"../../../build/ploticon":2,"../../lib":692,"d3":148,"fast-isnumeric":214}],631:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89864,7 +90345,7 @@ module.exports = { editType: 'plot' }; -},{"../../plot_api/plot_template":734,"../../plots/font_attributes":771,"../color/attributes":569}],637:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":730,"../../plots/font_attributes":767,"../color/attributes":568}],632:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89893,7 +90374,7 @@ module.exports = { darkAmount: 10 }; -},{}],638:[function(_dereq_,module,exports){ +},{}],633:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -89986,7 +90467,7 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":696,"../../plot_api/plot_template":734,"../../plots/array_container_defaults":740,"../color":570,"./attributes":636,"./constants":637}],639:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../plots/array_container_defaults":736,"../color":569,"./attributes":631,"./constants":632}],634:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90006,7 +90487,6 @@ var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var alignmentConstants = _dereq_('../../constants/alignment'); var LINE_SPACING = alignmentConstants.LINE_SPACING; @@ -90058,7 +90538,7 @@ module.exports = function draw(gd) { button.on('click', function() { if(gd._dragged) return; - Registry.call('relayout', gd, update); + Registry.call('_guiRelayout', gd, update); }); button.on('mouseover', function() { @@ -90207,21 +90687,21 @@ function reposition(gd, buttons, opts, axName, selector) { var ly = graphSize.t + graphSize.h * (1 - opts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(opts)) { + if(Lib.isRightAnchor(opts)) { lx -= width; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(opts)) { + if(Lib.isCenterAnchor(opts)) { lx -= width / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(opts)) { + if(Lib.isBottomAnchor(opts)) { ly -= height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(opts)) { + if(Lib.isMiddleAnchor(opts)) { ly -= height / 2; yanchor = 'middle'; } @@ -90243,7 +90723,7 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', 'translate(' + lx + ',' + ly + ')'); } -},{"../../constants/alignment":668,"../../lib":696,"../../lib/svg_text_utils":720,"../../plots/cartesian/axis_ids":747,"../../plots/plots":808,"../../registry":827,"../color":570,"../drawing":595,"../legend/anchor_utils":622,"./constants":637,"./get_update_object":640,"d3":148}],640:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../lib":692,"../../lib/svg_text_utils":716,"../../plots/cartesian/axis_ids":743,"../../plots/plots":804,"../../registry":823,"../color":569,"../drawing":590,"./constants":632,"./get_update_object":635,"d3":148}],635:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90300,7 +90780,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":148}],641:[function(_dereq_,module,exports){ +},{"d3":148}],636:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90327,7 +90807,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":636,"./defaults":638,"./draw":639}],642:[function(_dereq_,module,exports){ +},{"./attributes":631,"./defaults":633,"./draw":634}],637:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90401,7 +90881,7 @@ module.exports = { editType: 'calc' }; -},{"../color/attributes":569}],643:[function(_dereq_,module,exports){ +},{"../color/attributes":568}],638:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90435,7 +90915,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":743,"../../plots/cartesian/axis_ids":747,"./constants":644}],644:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/autorange":739,"../../plots/cartesian/axis_ids":743,"./constants":639}],639:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90491,7 +90971,7 @@ module.exports = { extraPad: 15 }; -},{}],645:[function(_dereq_,module,exports){ +},{}],640:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90577,7 +91057,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":696,"../../plot_api/plot_template":734,"../../plots/cartesian/axis_ids":747,"./attributes":642,"./oppaxis_attributes":648}],646:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plot_api/plot_template":730,"../../plots/cartesian/axis_ids":743,"./attributes":637,"./oppaxis_attributes":644}],641:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -90599,7 +91079,7 @@ var Color = _dereq_('../color'); var Titles = _dereq_('../titles'); var Cartesian = _dereq_('../../plots/cartesian'); -var Axes = _dereq_('../../plots/cartesian/axes'); +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); var dragElement = _dereq_('../dragelement'); var setCursor = _dereq_('../../lib/setcursor'); @@ -90607,8 +91087,13 @@ var setCursor = _dereq_('../../lib/setcursor'); var constants = _dereq_('./constants'); module.exports = function(gd) { - var fullLayout = gd._fullLayout, - rangeSliderData = makeRangeSliderData(fullLayout); + var fullLayout = gd._fullLayout; + var rangeSliderData = fullLayout._rangeSliderData; + for(var i = 0; i < rangeSliderData.length; i++) { + var opts = rangeSliderData[i][constants.name]; + // fullLayout._uid may not exist when we call makeData + opts._clipId = opts._id + '-' + fullLayout._uid; + } /* * @@ -90635,10 +91120,6 @@ module.exports = function(gd) { .selectAll('g.' + constants.containerClassName) .data(rangeSliderData, keyFunction); - rangeSliders.enter().append('g') - .classed(constants.containerClassName, true) - .attr('pointer-events', 'all'); - // remove exiting sliders and their corresponding clip paths rangeSliders.exit().each(function(axisOpts) { var opts = axisOpts[constants.name]; @@ -90648,48 +91129,51 @@ module.exports = function(gd) { // return early if no range slider is visible if(rangeSliderData.length === 0) return; + rangeSliders.enter().append('g') + .classed(constants.containerClassName, true) + .attr('pointer-events', 'all'); + // for all present range sliders rangeSliders.each(function(axisOpts) { - var rangeSlider = d3.select(this), - opts = axisOpts[constants.name], - oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)], - oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)]; + var rangeSlider = d3.select(this); + var opts = axisOpts[constants.name]; + var oppAxisOpts = fullLayout[axisIDs.id2name(axisOpts.anchor)]; + var oppAxisRangeOpts = opts[axisIDs.id2name(axisOpts.anchor)]; // update range // Expand slider range to the axis range - // TODO: what if the ranges are reversed? if(opts.range) { - var outRange = opts.range; - var axRange = axisOpts.range; + var rng = Lib.simpleMap(opts.range, axisOpts.r2l); + var axRng = Lib.simpleMap(axisOpts.range, axisOpts.r2l); + var newRng; + + if(axRng[0] < axRng[1]) { + newRng = [ + Math.min(rng[0], axRng[0]), + Math.max(rng[1], axRng[1]) + ]; + } else { + newRng = [ + Math.max(rng[0], axRng[0]), + Math.min(rng[1], axRng[1]) + ]; + } - outRange[0] = axisOpts.l2r(Math.min(axisOpts.r2l(outRange[0]), axisOpts.r2l(axRange[0]))); - outRange[1] = axisOpts.l2r(Math.max(axisOpts.r2l(outRange[1]), axisOpts.r2l(axRange[1]))); - opts._input.range = outRange.slice(); + opts.range = opts._input.range = Lib.simpleMap(newRng, axisOpts.l2r); } axisOpts.cleanRange('rangeslider.range'); - // update range slider dimensions var margin = fullLayout.margin; var graphSize = fullLayout._size; var domain = axisOpts.domain; - var tickHeight = (axisOpts._boundingBox || {}).height || 0; + var tickHeight = opts._tickHeight; - var oppBottom = Infinity; - var subplotData = Axes.getSubplots(gd, axisOpts); - for(var i = 0; i < subplotData.length; i++) { - var oppAxis = Axes.getFromId(gd, subplotData[i].substr(subplotData[i].indexOf('y'))); - oppBottom = Math.min(oppBottom, oppAxis.domain[0]); - } - - opts._id = constants.name + axisOpts._id; - opts._clipId = opts._id + '-' + fullLayout._uid; + var oppBottom = opts._oppBottom; opts._width = graphSize.w * (domain[1] - domain[0]); - opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; - opts._offsetShift = Math.floor(opts.borderwidth / 2); var x = Math.round(margin.l + (graphSize.w * domain[0])); @@ -90752,41 +91236,14 @@ module.exports = function(gd) { placeholder: fullLayout._dfltTitle.x, attributes: { x: axisOpts._offset + axisOpts._length / 2, - y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size, + y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.title.font.size, 'text-anchor': 'middle' } }); } - - // update margins - Plots.autoMargin(gd, opts._id, { - x: domain[0], - y: oppBottom, - l: 0, - r: 0, - t: 0, - b: opts._height + margin.b + tickHeight, - pad: constants.extraPad + opts._offsetShift * 2 - }); }); }; -function makeRangeSliderData(fullLayout) { - var axes = Axes.list({ _fullLayout: fullLayout }, 'x', true), - name = constants.name, - out = []; - - if(fullLayout._has('gl2d')) return out; - - for(var i = 0; i < axes.length; i++) { - var ax = axes[i]; - - if(ax[name] && ax[name].visible) out.push(ax); - } - - return out; -} - function setupDragElement(rangeSlider, gd, axisOpts, opts) { var slideBox = rangeSlider.select('rect.' + constants.slideBoxClassName).node(), grabAreaMin = rangeSlider.select('rect.' + constants.grabAreaMinClassName).node(), @@ -90866,7 +91323,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) { dataMax = clamp(opts.p2d(opts._pixelMax)); window.requestAnimationFrame(function() { - Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); + Registry.call('_guiRelayout', gd, axisOpts._name + '.range', [dataMin, dataMax]); }); } @@ -90973,15 +91430,14 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) { } function drawRangePlot(rangeSlider, gd, axisOpts, opts) { - var subplotData = Axes.getSubplots(gd, axisOpts), - calcData = gd.calcdata; + var calcData = gd.calcdata; var rangePlots = rangeSlider.selectAll('g.' + constants.rangePlotClassName) - .data(subplotData, Lib.identity); + .data(axisOpts._subplotsWith, Lib.identity); rangePlots.enter().append('g') .attr('class', function(id) { return constants.rangePlotClassName + ' ' + id; }) - .call(Drawing.setClipUrl, opts._clipId); + .call(Drawing.setClipUrl, opts._clipId, gd); rangePlots.order(); @@ -90993,7 +91449,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var plotgroup = d3.select(this), isMainPlot = (i === 0); - var oppAxisOpts = Axes.getFromId(gd, id, 'y'), + var oppAxisOpts = axisIDs.getFromId(gd, id, 'y'), oppAxisName = oppAxisOpts._name, oppAxisRangeOpts = opts[oppAxisName]; @@ -91025,6 +91481,11 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) { var xa = mockFigure._fullLayout.xaxis; var ya = mockFigure._fullLayout[oppAxisName]; + xa.clearCalc(); + xa.setScale(); + ya.clearCalc(); + ya.setScale(); + var plotinfo = { id: id, plotgroup: plotgroup, @@ -91177,7 +91638,77 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":696,"../../lib/setcursor":716,"../../plots/cartesian":756,"../../plots/cartesian/axes":744,"../../plots/plots":808,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"../titles":661,"./constants":644,"d3":148}],647:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/setcursor":712,"../../plots/cartesian":752,"../../plots/cartesian/axis_ids":743,"../../plots/plots":804,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"../titles":657,"./constants":639,"d3":148}],642:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); +var constants = _dereq_('./constants'); +var name = constants.name; + +function isVisible(ax) { + var rangeSlider = ax && ax[name]; + return rangeSlider && rangeSlider.visible; +} +exports.isVisible = isVisible; + +exports.makeData = function(fullLayout) { + var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true); + var margin = fullLayout.margin; + var rangeSliderData = []; + + if(!fullLayout._has('gl2d')) { + for(var i = 0; i < axes.length; i++) { + var ax = axes[i]; + + if(isVisible(ax)) { + rangeSliderData.push(ax); + + var opts = ax[name]; + opts._id = name + ax._id; + opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness; + opts._offsetShift = Math.floor(opts.borderwidth / 2); + } + } + } + + fullLayout._rangeSliderData = rangeSliderData; +}; + +exports.autoMarginOpts = function(gd, ax) { + var opts = ax[name]; + + var oppBottom = Infinity; + var counterAxes = ax._counterAxes; + for(var j = 0; j < counterAxes.length; j++) { + var counterId = counterAxes[j]; + var oppAxis = axisIDs.getFromId(gd, counterId); + oppBottom = Math.min(oppBottom, oppAxis.domain[0]); + } + opts._oppBottom = oppBottom; + + var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0; + opts._tickHeight = tickHeight; + + return { + x: 0, + y: oppBottom, + l: 0, + r: 0, + t: 0, + b: opts._height + gd._fullLayout.margin.b + tickHeight, + pad: constants.extraPad + opts._offsetShift * 2 + }; +}; + +},{"../../plots/cartesian/axis_ids":743,"./constants":639}],643:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91191,6 +91722,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { var Lib = _dereq_('../../lib'); var attrs = _dereq_('./attributes'); var oppAxisAttrs = _dereq_('./oppaxis_attributes'); +var helpers = _dereq_('./helpers'); module.exports = { moduleType: 'component', @@ -91209,10 +91741,13 @@ module.exports = { layoutAttributes: _dereq_('./attributes'), handleDefaults: _dereq_('./defaults'), calcAutorange: _dereq_('./calc_autorange'), - draw: _dereq_('./draw') + draw: _dereq_('./draw'), + isVisible: helpers.isVisible, + makeData: helpers.makeData, + autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":696,"./attributes":642,"./calc_autorange":643,"./defaults":645,"./draw":646,"./oppaxis_attributes":648}],648:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":637,"./calc_autorange":638,"./defaults":640,"./draw":641,"./helpers":642,"./oppaxis_attributes":644}],644:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91250,7 +91785,7 @@ module.exports = { editType: 'calc' }; -},{}],649:[function(_dereq_,module,exports){ +},{}],645:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91386,7 +91921,7 @@ module.exports = templatedArray('shape', { editType: 'arraydraw' }); -},{"../../lib/extend":685,"../../plot_api/plot_template":734,"../../traces/scatter/attributes":1043,"../annotations/attributes":553,"../drawing/attributes":594}],650:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plot_api/plot_template":730,"../../traces/scatter/attributes":1040,"../annotations/attributes":552,"../drawing/attributes":589}],646:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91395,7 +91930,6 @@ module.exports = templatedArray('shape', { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Lib = _dereq_('../../lib'); @@ -91473,7 +92007,7 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { } function shapeBounds(ax, v0, v1, path, paramsToUse) { - var convertVal = (ax.type === 'category') ? ax.r2c : ax.d2c; + var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; if(!path) return; @@ -91504,7 +92038,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"./constants":651,"./helpers":654}],651:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"./constants":647,"./helpers":650}],647:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91568,7 +92102,7 @@ module.exports = { } }; -},{}],652:[function(_dereq_,module,exports){ +},{}],648:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91693,7 +92227,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/cartesian/axes":744,"./attributes":649,"./helpers":654}],653:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/cartesian/axes":740,"./attributes":645,"./helpers":650}],649:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -91816,9 +92350,10 @@ function setClipPath(shapePath, gd, shapeOptions) { // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 var clipAxes = (shapeOptions.xref + shapeOptions.yref).replace(/paper/g, ''); - shapePath.call(Drawing.setClipUrl, clipAxes ? - ('clip' + gd._fullLayout._uid + clipAxes) : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } @@ -92002,7 +92537,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { // Don't rely on clipPath being activated during re-layout setClipPath(shapePath, gd, shapeOptions); - Registry.call('relayout', gd, editHelpers.getUpdateObj()); + Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj()); } function abortDrag() { @@ -92189,9 +92724,10 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(xref !== 'paper' && !xa.autorange) clipAxes += xref; if(yref !== 'paper' && !ya.autorange) clipAxes += yref; - shapePath.call(Drawing.setClipUrl, clipAxes ? - 'clip' + gd._fullLayout._uid + clipAxes : - null + Drawing.setClipUrl( + shapePath, + clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, + gd ); } } @@ -92323,7 +92859,7 @@ function movePath(pathIn, moveX, moveY) { }); } -},{"../../lib":696,"../../lib/setcursor":716,"../../plot_api/plot_template":734,"../../plots/cartesian/axes":744,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"./constants":651,"./helpers":654}],654:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/setcursor":712,"../../plot_api/plot_template":730,"../../plots/cartesian/axes":740,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"./constants":647,"./helpers":650}],650:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92448,7 +92984,7 @@ exports.roundPositionForSharpStrokeRendering = function(pos, strokeWidth) { return strokeWidthIsOdd ? posValAsInt + 0.5 : posValAsInt; }; -},{"../../lib":696,"./constants":651}],655:[function(_dereq_,module,exports){ +},{"../../lib":692,"./constants":647}],651:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92475,7 +93011,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":755,"./attributes":649,"./calc_autorange":650,"./defaults":652,"./draw":653}],656:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/include_components":751,"./attributes":645,"./calc_autorange":646,"./defaults":648,"./draw":649}],652:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92577,7 +93113,7 @@ module.exports = overrideAll(templatedArray('slider', { }, - pad: extendDeepAll({}, padAttrs, { + pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { }, {t: {dflt: 20}}), xanchor: { @@ -92718,7 +93254,7 @@ module.exports = overrideAll(templatedArray('slider', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../../plots/animation_attributes":739,"../../plots/font_attributes":771,"../../plots/pad_attributes":807,"./constants":657}],657:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../../plots/animation_attributes":735,"../../plots/font_attributes":767,"../../plots/pad_attributes":803,"./constants":653}],653:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92812,7 +93348,7 @@ module.exports = { currentValueInset: 0, }; -},{}],658:[function(_dereq_,module,exports){ +},{}],654:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92929,7 +93465,7 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"./attributes":656,"./constants":657}],659:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"./attributes":652,"./constants":653}],655:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -92947,7 +93483,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var constants = _dereq_('./constants'); @@ -93139,21 +93674,21 @@ function findDimensions(gd, sliderOpts) { dims.height = dims.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + dims.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; var xanchor = 'left'; - if(anchorUtils.isRightAnchor(sliderOpts)) { + if(Lib.isRightAnchor(sliderOpts)) { dims.lx -= dims.outerLength; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(sliderOpts)) { + if(Lib.isCenterAnchor(sliderOpts)) { dims.lx -= dims.outerLength / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(sliderOpts)) { + if(Lib.isBottomAnchor(sliderOpts)) { dims.ly -= dims.height; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(sliderOpts)) { + if(Lib.isMiddleAnchor(sliderOpts)) { dims.ly -= dims.height / 2; yanchor = 'middle'; } @@ -93560,7 +94095,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":668,"../../lib":696,"../../lib/svg_text_utils":720,"../../plot_api/plot_template":734,"../../plots/plots":808,"../color":570,"../drawing":595,"../legend/anchor_utils":622,"./constants":657,"d3":148}],660:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../lib":692,"../../lib/svg_text_utils":716,"../../plot_api/plot_template":730,"../../plots/plots":804,"../color":569,"../drawing":590,"./constants":653,"d3":148}],656:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93583,7 +94118,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":656,"./constants":657,"./defaults":658,"./draw":659}],661:[function(_dereq_,module,exports){ +},{"./attributes":652,"./constants":653,"./defaults":654,"./draw":655}],657:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93653,19 +94188,21 @@ function draw(gd, titleClass, options) { var group = options.containerGroup; var fullLayout = gd._fullLayout; - var titlefont = cont.titlefont || {}; - var font = titlefont.family; - var fontSize = titlefont.size; - var fontColor = titlefont.color; var opacity = 1; var isplaceholder = false; - var txt = (cont.title || '').trim(); + var title = cont.title; + var txt = (title && title.text ? title.text : '').trim(); + + var font = title && title.font ? title.font : {}; + var fontFamily = font.family; + var fontSize = font.size; + var fontColor = font.color; // only make this title editable if we positively identify its property // as one that has editing enabled. var editAttr; - if(prop === 'title') editAttr = 'titleText'; + if(prop === 'title.text') editAttr = 'titleText'; else if(prop.indexOf('axis') !== -1) editAttr = 'axisTitleText'; else if(prop.indexOf('colorbar' !== -1)) editAttr = 'colorbarTitleText'; var editable = gd._context.edits[editAttr]; @@ -93723,7 +94260,7 @@ function draw(gd, titleClass, options) { titleEl.attr('transform', transformVal); titleEl.style({ - 'font-family': font, + 'font-family': fontFamily, 'font-size': d3.round(fontSize, 2) + 'px', fill: Color.rgb(fontColor), opacity: opacity * Color.opacity(fontColor), @@ -93823,9 +94360,9 @@ function draw(gd, titleClass, options) { el.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { if(traceIndex !== undefined) { - Registry.call('restyle', gd, prop, text, traceIndex); + Registry.call('_guiRestyle', gd, prop, text, traceIndex); } else { - Registry.call('relayout', gd, prop, text); + Registry.call('_guiRelayout', gd, prop, text); } }) .on('cancel', function() { @@ -93842,7 +94379,7 @@ function draw(gd, titleClass, options) { return group; } -},{"../../constants/interactions":672,"../../lib":696,"../../lib/svg_text_utils":720,"../../plots/plots":808,"../../registry":827,"../color":570,"../drawing":595,"d3":148,"fast-isnumeric":214}],662:[function(_dereq_,module,exports){ +},{"../../constants/interactions":668,"../../lib":692,"../../lib/svg_text_utils":716,"../../plots/plots":804,"../../registry":823,"../color":569,"../drawing":590,"d3":148,"fast-isnumeric":214}],658:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -93971,7 +94508,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { }, - pad: extendFlat({}, padAttrs, { + pad: extendFlat(padAttrs({editType: 'arraydraw'}), { }), @@ -94000,7 +94537,7 @@ module.exports = overrideAll(templatedArray('updatemenu', { } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../../plots/font_attributes":771,"../../plots/pad_attributes":807,"../color/attributes":569}],663:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../../plots/font_attributes":767,"../../plots/pad_attributes":803,"../color/attributes":568}],659:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94081,7 +94618,7 @@ module.exports = { } }; -},{}],664:[function(_dereq_,module,exports){ +},{}],660:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94164,7 +94701,7 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"./attributes":662,"./constants":663}],665:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"./attributes":658,"./constants":659}],661:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -94183,7 +94720,6 @@ var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); var Lib = _dereq_('../../lib'); var svgTextUtils = _dereq_('../../lib/svg_text_utils'); -var anchorUtils = _dereq_('../legend/anchor_utils'); var arrayEditor = _dereq_('../../plot_api/plot_template').arrayEditor; var LINE_SPACING = _dereq_('../../constants/alignment').LINE_SPACING; @@ -94733,21 +95269,21 @@ function findDimensions(gd, menuOpts) { dims.ly = graphSize.t + graphSize.h * (1 - menuOpts.y); var xanchor = 'left'; - if(anchorUtils.isRightAnchor(menuOpts)) { + if(Lib.isRightAnchor(menuOpts)) { dims.lx -= paddedWidth; xanchor = 'right'; } - if(anchorUtils.isCenterAnchor(menuOpts)) { + if(Lib.isCenterAnchor(menuOpts)) { dims.lx -= paddedWidth / 2; xanchor = 'center'; } var yanchor = 'top'; - if(anchorUtils.isBottomAnchor(menuOpts)) { + if(Lib.isBottomAnchor(menuOpts)) { dims.ly -= paddedHeight; yanchor = 'bottom'; } - if(anchorUtils.isMiddleAnchor(menuOpts)) { + if(Lib.isMiddleAnchor(menuOpts)) { dims.ly -= paddedHeight / 2; yanchor = 'middle'; } @@ -94814,9 +95350,9 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":668,"../../lib":696,"../../lib/svg_text_utils":720,"../../plot_api/plot_template":734,"../../plots/plots":808,"../color":570,"../drawing":595,"../legend/anchor_utils":622,"./constants":663,"./scrollbox":667,"d3":148}],666:[function(_dereq_,module,exports){ -arguments[4][660][0].apply(exports,arguments) -},{"./attributes":662,"./constants":663,"./defaults":664,"./draw":665,"dup":660}],667:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../lib":692,"../../lib/svg_text_utils":716,"../../plot_api/plot_template":730,"../../plots/plots":804,"../color":569,"../drawing":590,"./constants":659,"./scrollbox":663,"d3":148}],662:[function(_dereq_,module,exports){ +arguments[4][656][0].apply(exports,arguments) +},{"./attributes":658,"./constants":659,"./defaults":660,"./draw":661,"dup":656}],663:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95073,7 +95609,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { height: Math.ceil(clipB) - Math.floor(clipT) }); - this.container.call(Drawing.setClipUrl, clipId); + this.container.call(Drawing.setClipUrl, clipId, this.gd); this.bg.attr({ x: l, @@ -95287,7 +95823,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":696,"../color":570,"../drawing":595,"d3":148}],668:[function(_dereq_,module,exports){ +},{"../../lib":692,"../color":569,"../drawing":590,"d3":148}],664:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95331,12 +95867,17 @@ module.exports = { // multiple of fontSize to get the vertical offset between lines LINE_SPACING: 1.3, - // multiple of fontSize to shift from the baseline to the midline + // multiple of fontSize to shift from the baseline + // to the cap (captical letter) line // (to use when we don't calculate this shift from Drawing.bBox) - // To be precise this should be half the cap height (capital letter) - // of the font, and according to wikipedia: + // This is an approximation since in reality cap height can differ + // from font to font. However, according to Wikipedia // an "average" font might have a cap height of 70% of the em // https://en.wikipedia.org/wiki/Em_(typography)#History + CAP_SHIFT: 0.70, + + // half the cap height (distance between baseline and cap line) + // of an "average" font (for more info see above). MID_SHIFT: 0.35, OPPOSITE_SIDE: { @@ -95347,7 +95888,7 @@ module.exports = { } }; -},{}],669:[function(_dereq_,module,exports){ +},{}],665:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95385,7 +95926,7 @@ module.exports = { } }; -},{}],670:[function(_dereq_,module,exports){ +},{}],666:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95406,7 +95947,7 @@ module.exports = { longdashdot: [[0.5, 0.7, 0.8, 1], 10] }; -},{}],671:[function(_dereq_,module,exports){ +},{}],667:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95429,7 +95970,7 @@ module.exports = { x: '❌' }; -},{}],672:[function(_dereq_,module,exports){ +},{}],668:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95456,7 +95997,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],673:[function(_dereq_,module,exports){ +},{}],669:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95521,7 +96062,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],674:[function(_dereq_,module,exports){ +},{}],670:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95545,7 +96086,7 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],675:[function(_dereq_,module,exports){ +},{}],671:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95557,7 +96098,7 @@ exports.svgAttrs = { 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.42.5'; +exports.version = '1.43.0'; // inject promise polyfill _dereq_('es6-promise').polyfill(); @@ -95566,7 +96107,7 @@ _dereq_('es6-promise').polyfill(); _dereq_('../build/plotcss'); // inject default MathJax config -_dereq_('./fonts/mathjax_config'); +_dereq_('./fonts/mathjax_config')(); // include registry module and expose register method var Registry = _dereq_('./registry'); @@ -95577,7 +96118,8 @@ var plotApi = _dereq_('./plot_api'); var methodNames = Object.keys(plotApi); for(var i = 0; i < methodNames.length; i++) { var name = methodNames[i]; - exports[name] = plotApi[name]; + // _ -> private API methods, but still registered for internal use + if(name.charAt(0) !== '_') exports[name] = plotApi[name]; register({ moduleType: 'apiMethod', name: name, @@ -95601,7 +96143,8 @@ register([ _dereq_('./components/rangeslider'), _dereq_('./components/rangeselector'), _dereq_('./components/grid'), - _dereq_('./components/errorbars') + _dereq_('./components/errorbars'), + _dereq_('./components/colorscale') ]); // locales en and en-US are required for default behavior @@ -95623,7 +96166,7 @@ exports.Queue = _dereq_('./lib/queue'); // export d3 used in the bundle exports.d3 = _dereq_('d3'); -},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":561,"./components/annotations3d":566,"./components/errorbars":601,"./components/fx":612,"./components/grid":616,"./components/images":621,"./components/legend":630,"./components/rangeselector":641,"./components/rangeslider":647,"./components/shapes":655,"./components/sliders":660,"./components/updatemenus":666,"./fonts/mathjax_config":676,"./lib/queue":711,"./locale-en":725,"./locale-en-us":724,"./plot_api":729,"./plot_api/plot_schema":733,"./plots/plots":808,"./registry":827,"./snapshot":832,"./traces/scatter":1055,"d3":148,"es6-promise":203}],676:[function(_dereq_,module,exports){ +},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":560,"./components/annotations3d":565,"./components/colorscale":581,"./components/errorbars":596,"./components/fx":608,"./components/grid":612,"./components/images":617,"./components/legend":625,"./components/rangeselector":636,"./components/rangeslider":643,"./components/shapes":651,"./components/sliders":656,"./components/updatemenus":662,"./fonts/mathjax_config":672,"./lib/queue":707,"./locale-en":721,"./locale-en-us":720,"./plot_api":725,"./plot_api/plot_schema":729,"./plots/plots":804,"./registry":823,"./snapshot":828,"./traces/scatter":1052,"d3":148,"es6-promise":203}],672:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95636,31 +96179,89 @@ exports.d3 = _dereq_('d3'); /* global MathJax:false */ +module.exports = function() { + if(typeof MathJax !== 'undefined') { + var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; + + if(globalConfig) { + MathJax.Hub.Config({ + messageStyle: 'none', + skipStartupTypeset: true, + displayAlign: 'left', + tex2jax: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + } + }); + MathJax.Hub.Configured(); + } + } +}; + +},{}],673:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + + /** - * Check and configure MathJax + * Determine the position anchor property of x/y xanchor/yanchor components. + * + * - values < 1/3 align the low side at that fraction, + * - values [1/3, 2/3] align the center at that fraction, + * - values > 2/3 align the right at that fraction. */ -if(typeof MathJax !== 'undefined') { - exports.MathJax = true; - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } +exports.isLeftAnchor = function isLeftAnchor(opts) { + return ( + opts.xanchor === 'left' || + (opts.xanchor === 'auto' && opts.x <= 1 / 3) + ); +}; -} else { - exports.MathJax = false; -} +exports.isCenterAnchor = function isCenterAnchor(opts) { + return ( + opts.xanchor === 'center' || + (opts.xanchor === 'auto' && opts.x > 1 / 3 && opts.x < 2 / 3) + ); +}; + +exports.isRightAnchor = function isRightAnchor(opts) { + return ( + opts.xanchor === 'right' || + (opts.xanchor === 'auto' && opts.x >= 2 / 3) + ); +}; + +exports.isTopAnchor = function isTopAnchor(opts) { + return ( + opts.yanchor === 'top' || + (opts.yanchor === 'auto' && opts.y >= 2 / 3) + ); +}; + +exports.isMiddleAnchor = function isMiddleAnchor(opts) { + return ( + opts.yanchor === 'middle' || + (opts.yanchor === 'auto' && opts.y > 1 / 3 && opts.y < 2 / 3) + ); +}; + +exports.isBottomAnchor = function isBottomAnchor(opts) { + return ( + opts.yanchor === 'bottom' || + (opts.yanchor === 'auto' && opts.y <= 1 / 3) + ); +}; -},{}],677:[function(_dereq_,module,exports){ +},{}],674:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -95901,7 +96502,7 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":703}],678:[function(_dereq_,module,exports){ +},{"./mod":699}],675:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96037,7 +96638,30 @@ exports.concat = function() { return out; }; -},{}],679:[function(_dereq_,module,exports){ +exports.maxRowLength = function(z) { + return _rowLength(z, Math.max, 0); +}; + +exports.minRowLength = function(z) { + return _rowLength(z, Math.min, Infinity); +}; + +function _rowLength(z, fn, len0) { + if(isArrayOrTypedArray(z)) { + if(isArrayOrTypedArray(z[0])) { + var len = len0; + for(var i = 0; i < z.length; i++) { + len = fn(len, z[i].length); + } + return len; + } else { + return z.length; + } + } + return 0; +} + +},{}],676:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96070,7 +96694,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":673,"fast-isnumeric":214}],680:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"fast-isnumeric":214}],677:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96098,7 +96722,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],681:[function(_dereq_,module,exports){ +},{}],678:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96121,7 +96745,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],682:[function(_dereq_,module,exports){ +},{}],679:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -96130,18 +96754,17 @@ module.exports = function clearResponsive(gd) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); var baseTraceAttrs = _dereq_('../plots/attributes'); -var getColorscale = _dereq_('../components/colorscale/get_scale'); -var colorscaleNames = Object.keys(_dereq_('../components/colorscale/scales')); +var scales = _dereq_('../components/colorscale/scales'); +var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; + var nestedProperty = _dereq_('./nested_property'); var counterRegex = _dereq_('./regex').counter; -var DESELECTDIM = _dereq_('../constants/interactions').DESELECTDIM; var modHalf = _dereq_('./mod').modHalf; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -96259,7 +96882,7 @@ exports.valObjectMeta = { coerceFunction: function(v, propOut, dflt) { - propOut.set(getColorscale(v, dflt)); + propOut.set(scales.get(v, dflt)); } }, angle: { @@ -96593,7 +97216,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/get_scale":583,"../components/colorscale/scales":589,"../constants/interactions":672,"../plots/attributes":741,"./array":678,"./mod":703,"./nested_property":704,"./regex":712,"fast-isnumeric":214,"tinycolor2":514}],683:[function(_dereq_,module,exports){ +},{"../components/colorscale/scales":584,"../constants/interactions":668,"../plots/attributes":737,"./array":675,"./mod":699,"./nested_property":700,"./regex":708,"fast-isnumeric":214,"tinycolor2":513}],680:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97196,7 +97819,7 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":673,"../registry":827,"./loggers":700,"./mod":703,"d3":148,"fast-isnumeric":214}],684:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"../registry":823,"./loggers":696,"./mod":699,"d3":148,"fast-isnumeric":214}],681:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97370,7 +97993,7 @@ var Events = { module.exports = Events; -},{"events":92}],685:[function(_dereq_,module,exports){ +},{"events":92}],682:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97486,7 +98109,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":697}],686:[function(_dereq_,module,exports){ +},{"./is_plain_object.js":693}],683:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97537,7 +98160,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],687:[function(_dereq_,module,exports){ +},{}],684:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97584,7 +98207,7 @@ function isCalcData(cont) { ); } -},{}],688:[function(_dereq_,module,exports){ +},{}],685:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97648,7 +98271,7 @@ function countryNameToISO3(countryName) { return false; } -},{"../lib":696,"country-regex":122}],689:[function(_dereq_,module,exports){ +},{"../lib":692,"country-regex":122}],686:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -97765,7 +98388,7 @@ exports.makeBlank = function() { }; }; -},{"../constants/numerical":673}],690:[function(_dereq_,module,exports){ +},{"../constants/numerical":669}],687:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98011,7 +98634,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":703}],691:[function(_dereq_,module,exports){ +},{"./mod":699}],688:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98049,7 +98672,7 @@ module.exports = function(gd) { return gd; // otherwise assume that gd is a DOM element }; -},{}],692:[function(_dereq_,module,exports){ +},{}],689:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98100,11 +98723,7 @@ function formatColor(containerIn, opacityIn, len) { if(containerIn.colorscale !== undefined) { sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - containerIn.colorscale, - containerIn.cmin, - containerIn.cmax - ) + Colorscale.extractScale(containerIn, {cLetter: 'c'}) ); } else { @@ -98157,7 +98776,7 @@ module.exports = { parseColorScale: parseColorScale }; -},{"../components/color/attributes":569,"../components/colorscale":585,"./array":678,"color-normalize":108,"fast-isnumeric":214,"tinycolor2":514}],693:[function(_dereq_,module,exports){ +},{"../components/color/attributes":568,"../components/colorscale":581,"./array":675,"color-normalize":108,"fast-isnumeric":214,"tinycolor2":513}],690:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98193,54 +98812,7 @@ module.exports = { unwrap: function(d) {return d[0];} }; -},{"./identity":695}],694:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var toSuperScript = _dereq_('superscript-text'); -var fixEntities = _dereq_('./svg_text_utils').convertEntities; - -function fixSuperScript(x) { - var idx = 0; - - while((idx = x.indexOf('', idx)) >= 0) { - var nidx = x.indexOf('', idx); - if(nidx < idx) break; - - x = x.slice(0, idx) + toSuperScript(x.slice(idx + 5, nidx)) + x.slice(nidx + 6); - } - - return x; -} - -function fixBR(x) { - return x.replace(/\/g, '\n'); -} - -function stripTags(x) { - return x.replace(/\<.*\>/g, ''); -} - -function convertHTMLToUnicode(html) { - return '' + - fixEntities( - stripTags( - fixSuperScript( - fixBR( - html)))); -} - -module.exports = convertHTMLToUnicode; - -},{"./svg_text_utils":720,"superscript-text":507}],695:[function(_dereq_,module,exports){ +},{"./identity":691}],691:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98256,7 +98828,7 @@ module.exports = convertHTMLToUnicode; module.exports = function identity(d) { return d; }; -},{}],696:[function(_dereq_,module,exports){ +},{}],692:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -98290,6 +98862,8 @@ lib.isArrayOrTypedArray = arrayModule.isArrayOrTypedArray; lib.isArray1D = arrayModule.isArray1D; lib.ensureArray = arrayModule.ensureArray; lib.concat = arrayModule.concat; +lib.maxRowLength = arrayModule.maxRowLength; +lib.minRowLength = arrayModule.minRowLength; var modModule = _dereq_('./mod'); lib.mod = modModule.mod; @@ -98359,6 +98933,14 @@ lib.pathArc = anglesModule.pathArc; lib.pathSector = anglesModule.pathSector; lib.pathAnnulus = anglesModule.pathAnnulus; +var anchorUtils = _dereq_('./anchor_utils'); +lib.isLeftAnchor = anchorUtils.isLeftAnchor; +lib.isCenterAnchor = anchorUtils.isCenterAnchor; +lib.isRightAnchor = anchorUtils.isRightAnchor; +lib.isTopAnchor = anchorUtils.isTopAnchor; +lib.isMiddleAnchor = anchorUtils.isMiddleAnchor; +lib.isBottomAnchor = anchorUtils.isBottomAnchor; + var geom2dModule = _dereq_('./geometry2d'); lib.segmentsIntersect = geom2dModule.segmentsIntersect; lib.segmentDistance = geom2dModule.segmentDistance; @@ -98893,7 +99475,13 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) objOut[k] = v.slice(0, arrayLen); + else if(Array.isArray(v)) { + if(k === 'colorscale') { + objOut[k] = v.slice(); + } else { + objOut[k] = v.slice(0, arrayLen); + } + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -99238,10 +99826,10 @@ lib.numSeparate = function(value, separators, separatethousands) { return x1 + x2; }; -var TEMPLATE_STRING_REGEX = /%{([^\s%{}]*)}/g; +var TEMPLATE_STRING_REGEX = /%{([^\s%{}:]*)(:[^}]*)?}/g; var SIMPLE_PROPERTY_REGEX = /^\w*$/; -/* +/** * Substitute values from an object into a string * * Examples: @@ -99253,7 +99841,6 @@ var SIMPLE_PROPERTY_REGEX = /^\w*$/; * * @return {string} templated string */ - lib.templateString = function(string, obj) { // Not all that useful, but cache nestedProperty instantiation // just in case it speeds things up *slightly*: @@ -99268,6 +99855,67 @@ lib.templateString = function(string, obj) { }); }; +var TEMPLATE_STRING_FORMAT_SEPARATOR = /^:/; +var numberOfHoverTemplateWarnings = 0; +var maximumNumberOfHoverTemplateWarnings = 10; +/** + * Substitute values from an object into a string and optionally formats them using d3-format, + * or fallback to associated labels. + * + * Examples: + * Lib.templateString('name: %{trace}', {trace: 'asdf'}) --> 'name: asdf' + * Lib.templateString('name: %{trace[0].name}', {trace: [{name: 'asdf'}]}) --> 'name: asdf' + * Lib.templateString('price: %{y:$.2f}', {y: 1}) --> 'price: $1.00' + * + * @param {string} input string containing %{...:...} template strings + * @param {obj} data object containing fallback text when no formatting is specified, ex.: {yLabel: 'formattedYValue'} + * @param {obj} data objects containing substitution values + * + * @return {string} templated string + */ +lib.hovertemplateString = function(string, labels) { + var args = arguments; + // Not all that useful, but cache nestedProperty instantiation + // just in case it speeds things up *slightly*: + var getterCache = {}; + + return string.replace(TEMPLATE_STRING_REGEX, function(match, key, format) { + var obj, value, i; + for(i = 2; i < args.length; i++) { + obj = args[i]; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; + } + + if(value === undefined) { + if(numberOfHoverTemplateWarnings < maximumNumberOfHoverTemplateWarnings) { + lib.warn('Variable \'' + key + '\' in hovertemplate could not be found!'); + value = match; + } + + if(numberOfHoverTemplateWarnings === maximumNumberOfHoverTemplateWarnings) { + lib.warn('Too many hovertemplate warnings - additional warnings will be suppressed'); + } + numberOfHoverTemplateWarnings++; + } + + if(format) { + value = d3.format(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value); + } else { + if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + } + return value; + }); +}; + /* * alphanumeric string sort, tailored for subplot IDs like scene2, scene10, x10y13 etc */ @@ -99310,7 +99958,7 @@ lib.pseudoRandom = function() { return randSeed / 4294967296; }; -},{"../constants/numerical":673,"./angles":677,"./array":678,"./clean_number":679,"./clear_responsive":681,"./coerce":682,"./dates":683,"./extend":685,"./filter_unique":686,"./filter_visible":687,"./geometry2d":690,"./get_graph_div":691,"./identity":695,"./is_plain_object":697,"./keyed_container":698,"./localize":699,"./loggers":700,"./make_trace_groups":701,"./matrix":702,"./mod":703,"./nested_property":704,"./noop":705,"./notifier":706,"./push_unique":710,"./regex":712,"./relative_attr":713,"./relink_private":714,"./search":715,"./stats":718,"./throttle":721,"./to_log_range":722,"d3":148,"fast-isnumeric":214}],697:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"./anchor_utils":673,"./angles":674,"./array":675,"./clean_number":676,"./clear_responsive":678,"./coerce":679,"./dates":680,"./extend":682,"./filter_unique":683,"./filter_visible":684,"./geometry2d":687,"./get_graph_div":688,"./identity":691,"./is_plain_object":693,"./keyed_container":694,"./localize":695,"./loggers":696,"./make_trace_groups":697,"./matrix":698,"./mod":699,"./nested_property":700,"./noop":701,"./notifier":702,"./push_unique":706,"./regex":708,"./relative_attr":709,"./relink_private":710,"./search":711,"./stats":714,"./throttle":717,"./to_log_range":718,"d3":148,"fast-isnumeric":214}],693:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99339,7 +99987,7 @@ module.exports = function isPlainObject(obj) { ); }; -},{}],698:[function(_dereq_,module,exports){ +},{}],694:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99532,7 +100180,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":704}],699:[function(_dereq_,module,exports){ +},{"./nested_property":700}],695:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99588,7 +100236,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":827}],700:[function(_dereq_,module,exports){ +},{"../registry":823}],696:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99674,7 +100322,7 @@ function apply(f, args) { } } -},{"../plot_api/plot_config":732}],701:[function(_dereq_,module,exports){ +},{"../plot_api/plot_config":728}],697:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99711,7 +100359,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{}],702:[function(_dereq_,module,exports){ +},{}],698:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99821,7 +100469,7 @@ exports.apply2DTransform2 = function(transform) { }; }; -},{}],703:[function(_dereq_,module,exports){ +},{}],699:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -99856,7 +100504,7 @@ module.exports = { modHalf: modHalf }; -},{}],704:[function(_dereq_,module,exports){ +},{}],700:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100103,7 +100751,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":678,"fast-isnumeric":214}],705:[function(_dereq_,module,exports){ +},{"./array":675,"fast-isnumeric":214}],701:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100119,7 +100767,7 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],706:[function(_dereq_,module,exports){ +},{}],702:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100201,7 +100849,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":148,"fast-isnumeric":214}],707:[function(_dereq_,module,exports){ +},{"d3":148,"fast-isnumeric":214}],703:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100250,7 +100898,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":716}],708:[function(_dereq_,module,exports){ +},{"./setcursor":712}],704:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100503,7 +101151,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":673,"./matrix":702}],709:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"./matrix":698}],705:[function(_dereq_,module,exports){ (function (global){ /** * Copyright 2012-2018, Plotly, Inc. @@ -100575,7 +101223,7 @@ module.exports = function prepareRegl(gd, extensions) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./show_no_webgl_msg":717,"regl":478}],710:[function(_dereq_,module,exports){ +},{"./show_no_webgl_msg":713,"regl":478}],706:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100615,7 +101263,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],711:[function(_dereq_,module,exports){ +},{}],707:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100826,7 +101474,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":696,"../plot_api/plot_config":732}],712:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/plot_config":728}],708:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100845,16 +101493,18 @@ module.exports = queue; * @param {Optional(string)} tail: a fixed piece after the id * eg counterRegex('scene', '.annotations') for scene2.annotations etc. * @param {boolean} openEnded: if true, the string may continue past the match. + * @param {boolean} matchBeginning: if false, the string may start before the match. */ -exports.counter = function(head, tail, openEnded) { +exports.counter = function(head, tail, openEnded, matchBeginning) { var fullTail = (tail || '') + (openEnded ? '' : '$'); + var startWithPrefix = matchBeginning === false ? '' : '^'; if(head === 'xy') { - return new RegExp('^x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + 'x([2-9]|[1-9][0-9]+)?y([2-9]|[1-9][0-9]+)?' + fullTail); } - return new RegExp('^' + head + '([2-9]|[1-9][0-9]+)?' + fullTail); + return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],713:[function(_dereq_,module,exports){ +},{}],709:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100907,7 +101557,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],714:[function(_dereq_,module,exports){ +},{}],710:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -100970,7 +101620,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":678,"./is_plain_object":697}],715:[function(_dereq_,module,exports){ +},{"./array":675,"./is_plain_object":693}],711:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101158,7 +101808,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"./identity":695,"./loggers":700,"fast-isnumeric":214}],716:[function(_dereq_,module,exports){ +},{"./identity":691,"./loggers":696,"fast-isnumeric":214}],712:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101181,7 +101831,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],717:[function(_dereq_,module,exports){ +},{}],713:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101245,7 +101895,7 @@ module.exports = function showNoWebGlMsg(scene) { return false; }; -},{"../components/color":570}],718:[function(_dereq_,module,exports){ +},{"../components/color":569}],714:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101346,7 +101996,7 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":678,"fast-isnumeric":214}],719:[function(_dereq_,module,exports){ +},{"./array":675,"fast-isnumeric":214}],715:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -101367,7 +102017,7 @@ function str2RgbaArray(color) { module.exports = str2RgbaArray; -},{"color-normalize":108}],720:[function(_dereq_,module,exports){ +},{"color-normalize":108}],716:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102142,7 +102792,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":668,"../constants/xmlns_namespaces":674,"../lib":696,"d3":148}],721:[function(_dereq_,module,exports){ +},{"../constants/alignment":664,"../constants/xmlns_namespaces":670,"../lib":692,"d3":148}],717:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102246,7 +102896,7 @@ function _clearTimeout(cache) { } } -},{}],722:[function(_dereq_,module,exports){ +},{}],718:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102274,7 +102924,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":214}],723:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214}],719:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102310,7 +102960,7 @@ topojsonUtils.getTopojsonFeatures = function(trace, topojson) { return topojsonFeature(topojson, obj).features; }; -},{"../plots/geo/constants":773,"topojson-client":517}],724:[function(_dereq_,module,exports){ +},{"../plots/geo/constants":769,"topojson-client":516}],720:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102332,7 +102982,7 @@ module.exports = { } }; -},{}],725:[function(_dereq_,module,exports){ +},{}],721:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102375,7 +103025,7 @@ module.exports = { } }; -},{}],726:[function(_dereq_,module,exports){ +},{}],722:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102433,7 +103083,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":827}],727:[function(_dereq_,module,exports){ +},{"../registry":823}],723:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102559,7 +103209,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":696}],728:[function(_dereq_,module,exports){ +},{"../lib":692}],724:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -102615,6 +103265,8 @@ exports.cleanLayout = function(layout) { } var axisAttrRegex = (Plots.subplotsRegistry.cartesian || {}).attrRegex; + var polarAttrRegex = (Plots.subplotsRegistry.polar || {}).attrRegex; + var ternaryAttrRegex = (Plots.subplotsRegistry.ternary || {}).attrRegex; var sceneAttrRegex = (Plots.subplotsRegistry.gl3d || {}).attrRegex; var keys = Object.keys(layout); @@ -102653,6 +103305,24 @@ exports.cleanLayout = function(layout) { } delete ax.autotick; } + + cleanTitle(ax); + } + + // modifications for polar + else if(polarAttrRegex && polarAttrRegex.test(key)) { + var polar = layout[key]; + + cleanTitle(polar.radialaxis); + } + + // modifications for ternary + else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + var ternary = layout[key]; + + cleanTitle(ternary.aaxis); + cleanTitle(ternary.baxis); + cleanTitle(ternary.caxis); } // modifications for 3D scenes @@ -102676,11 +103346,16 @@ exports.cleanLayout = function(layout) { scene.camera = { eye: {x: eye[0], y: eye[1], z: eye[2]}, center: {x: center[0], y: center[1], z: center[2]}, - up: {x: mat[1], y: mat[5], z: mat[9]} + up: {x: 0, y: 0, z: 1} // we just ignore calculating camera z up in this case }; delete scene.cameraposition; } + + // clean axis titles + cleanTitle(scene.xaxis); + cleanTitle(scene.yaxis); + cleanTitle(scene.zaxis); } } @@ -102738,6 +103413,9 @@ exports.cleanLayout = function(layout) { } } + // clean plot title + cleanTitle(layout); + /* * Moved from rotate -> orbit for dragmode */ @@ -102747,6 +103425,11 @@ exports.cleanLayout = function(layout) { // supported, but new tinycolor does not because they're not valid css Color.clean(layout); + // clean the layout container in layout.template + if(layout.template && layout.template.layout) { + exports.cleanLayout(layout.template.layout); + } + return layout; }; @@ -102758,6 +103441,46 @@ function cleanAxRef(container, attr) { } } +/** + * Cleans up old title attribute structure (flat) in favor of the new one (nested). + * + * @param {Object} titleContainer - an object potentially including deprecated title attributes + */ +function cleanTitle(titleContainer) { + if(titleContainer) { + + // title -> title.text + // (although title used to be a string attribute, + // numbers are accepted as well) + if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') { + titleContainer.title = { + text: titleContainer.title + }; + } + + rewireAttr('titlefont', 'font'); + rewireAttr('titleposition', 'position'); + rewireAttr('titleside', 'side'); + rewireAttr('titleoffset', 'offset'); + } + + function rewireAttr(oldAttrName, newAttrName) { + var oldAttrSet = titleContainer[oldAttrName]; + var newAttrSet = titleContainer.title && titleContainer.title[newAttrName]; + + if(oldAttrSet && !newAttrSet) { + + // Ensure title object exists + if(!titleContainer.title) { + titleContainer.title = {}; + } + + titleContainer.title[newAttrName] = titleContainer[oldAttrName]; + delete titleContainer[oldAttrName]; + } + } +} + /* * cleanData: Make a few changes to the data for backward compatibility * before it gets used for anything. Modifies the data traces users provide. @@ -102961,6 +103684,13 @@ exports.cleanData = function(data) { delete trace.autobiny; delete trace.ybins; } + + cleanTitle(trace); + if(trace.colorbar) cleanTitle(trace.colorbar); + if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar); + if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar); + if(trace.aaxis) cleanTitle(trace.aaxis); + if(trace.baxis) cleanTitle(trace.baxis); } }; @@ -103001,11 +103731,14 @@ function commonPrefix(name1, name2, show1, show2) { function cleanTextPosition(textposition) { var posY = 'middle', posX = 'center'; - if(textposition.indexOf('top') !== -1) posY = 'top'; - else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; - if(textposition.indexOf('left') !== -1) posX = 'left'; - else if(textposition.indexOf('right') !== -1) posX = 'right'; + if(typeof textposition === 'string') { + if(textposition.indexOf('top') !== -1) posY = 'top'; + else if(textposition.indexOf('bottom') !== -1) posY = 'bottom'; + + if(textposition.indexOf('left') !== -1) posX = 'left'; + else if(textposition.indexOf('right') !== -1) posX = 'right'; + } return posY + ' ' + posX; } @@ -103181,7 +103914,7 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":570,"../lib":696,"../plots/cartesian/axis_ids":747,"../plots/plots":808,"../registry":827,"fast-isnumeric":214,"gl-mat4/fromQuat":251}],729:[function(_dereq_,module,exports){ +},{"../components/color":569,"../lib":692,"../plots/cartesian/axis_ids":743,"../plots/plots":804,"../registry":823,"fast-isnumeric":214,"gl-mat4/fromQuat":251}],725:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103200,6 +103933,10 @@ exports.restyle = main.restyle; exports.relayout = main.relayout; exports.redraw = main.redraw; exports.update = main.update; +exports._guiRestyle = main._guiRestyle; +exports._guiRelayout = main._guiRelayout; +exports._guiUpdate = main._guiUpdate; +exports._storeDirectGUIEdit = main._storeDirectGUIEdit; exports.react = main.react; exports.extendTraces = main.extendTraces; exports.prependTraces = main.prependTraces; @@ -103220,7 +103957,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":829,"./plot_api":731,"./template_api":736,"./to_image":737,"./validate":738}],730:[function(_dereq_,module,exports){ +},{"../snapshot/download":825,"./plot_api":727,"./template_api":732,"./to_image":733,"./validate":734}],726:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103232,7 +103969,6 @@ exports.validateTemplate = templateApi.validateTemplate; 'use strict'; -var nestedProperty = _dereq_('../lib/nested_property'); var isPlainObject = _dereq_('../lib/is_plain_object'); var noop = _dereq_('../lib/noop'); var Loggers = _dereq_('../lib/loggers'); @@ -103289,11 +104025,15 @@ var isRemoveVal = exports.isRemoveVal = function isRemoveVal(val) { * the flags for which actions we're going to perform to display these (and * any other) changes. If we're already `recalc`ing, we don't need to redraw * individual items + * @param {function} _nestedProperty + * a (possibly modified for gui edits) nestedProperty constructor + * The modified version takes a 3rd argument, for a prefix to the attribute + * string necessary for storing GUI edits * * @returns {bool} `true` if it managed to complete drawing of the changes * `false` would mean the parent should replot. */ -exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags) { +exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, edits, flags, _nestedProperty) { var componentType = np.astr, supplyComponentDefaults = Registry.getComponentMethod(componentType, 'supplyLayoutDefaults'), draw = Registry.getComponentMethod(componentType, 'draw'), @@ -103333,7 +104073,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, // redoing supplyDefaults // TODO: this assumes componentArray is in gd.layout - which will not be // true after we extend this to restyle - componentArrayFull = nestedProperty(fullLayout, componentType).get(); + componentArrayFull = _nestedProperty(fullLayout, componentType).get(); var deletes = [], firstIndexChange = -1, @@ -103344,7 +104084,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, objEdits, objKeys, objVal, - adding; + adding, prefix; // first make the add and edit changes for(i = 0; i < componentNums.length; i++) { @@ -103383,7 +104123,9 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, } else { for(j = 0; j < objKeys.length; j++) { - nestedProperty(componentArray[componentNum], objKeys[j]).set(objEdits[objKeys[j]]); + prefix = componentType + '[' + componentNum + '].'; + _nestedProperty(componentArray[componentNum], objKeys[j], prefix) + .set(objEdits[objKeys[j]]); } } } @@ -103434,7 +104176,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":697,"../lib/loggers":700,"../lib/nested_property":704,"../lib/noop":705,"../lib/search":715,"../registry":827,"./container_array_match":726}],731:[function(_dereq_,module,exports){ +},{"../lib/is_plain_object":693,"../lib/loggers":696,"../lib/noop":701,"../lib/search":711,"../registry":823,"./container_array_match":722}],727:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -103452,6 +104194,8 @@ var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); var Lib = _dereq_('../lib'); +var nestedProperty = Lib.nestedProperty; + var Events = _dereq_('../lib/events'); var Queue = _dereq_('../lib/queue'); @@ -103547,9 +104291,6 @@ exports.plot = function(gd, data, layout, config) { // so we can share cached text across tabs Drawing.makeTester(); - // clear stashed base url - delete Drawing.baseUrl; - // collect promises for any async actions during plotting // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all @@ -103594,7 +104335,7 @@ exports.plot = function(gd, data, layout, config) { // Legacy polar plots if(!fullLayout._has('polar') && data && data[0] && data[0].r) { Lib.log('Legacy polar charts are deprecated!'); - return plotPolar(gd, data, layout); + return plotLegacyPolar(gd, data, layout); } // so we don't try to re-call Plotly.plot from inside @@ -103770,8 +104511,7 @@ exports.plot = function(gd, data, layout, config) { return Lib.syncOrAsync([ Registry.getComponentMethod('shapes', 'calcAutorange'), Registry.getComponentMethod('annotations', 'calcAutorange'), - doAutoRangeAndConstraints, - Registry.getComponentMethod('rangeslider', 'calcAutorange') + doAutoRangeAndConstraints ], gd); } @@ -103783,11 +104523,16 @@ exports.plot = function(gd, data, layout, config) { // store initial ranges *after* enforcing constraints, otherwise // we will never look like we're at the initial ranges if(graphWasEmpty) Axes.saveRangeInitial(gd); + + // this one is different from shapes/annotations calcAutorange + // the others incorporate those components into ax._extremes, + // this one actually sets the ranges in rangesliders. + Registry.getComponentMethod('rangeslider', 'calcAutorange')(gd); } // draw ticks, titles, and calculate axis scaling (._b, ._m) function drawAxes() { - return Axes.doTicks(gd, graphWasEmpty ? '' : 'redraw'); + return Axes.draw(gd, graphWasEmpty ? '' : 'redraw'); } var seq = [ @@ -103856,7 +104601,16 @@ function opaqueSetBackground(gd, bgColor) { } function setPlotContext(gd, config) { - if(!gd._context) gd._context = Lib.extendDeep({}, defaultConfig); + if(!gd._context) { + gd._context = Lib.extendDeep({}, defaultConfig); + + // stash href, used to make robust clipPath URLs + var base = d3.select('base'); + gd._context._baseUrl = base.size() && base.attr('href') ? + window.location.href.split('#')[0] : + ''; + } + var context = gd._context; var i, keys, key; @@ -103902,6 +104656,9 @@ function setPlotContext(gd, config) { } } } + + // not part of the user-facing config options + context._exportedPlot = config._exportedPlot; } // staticPlot forces a bunch of others: @@ -103931,7 +104688,7 @@ function setPlotContext(gd, config) { context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0; } -function plotPolar(gd, data, layout) { +function plotLegacyPolar(gd, data, layout) { // build or reuse the container skeleton var plotContainer = d3.select(gd).selectAll('.plot-container') .data([0]); @@ -103972,7 +104729,7 @@ function plotPolar(gd, data, layout) { // editable title var opacity = 1; - var txt = gd._fullLayout.title; + var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; if(txt === '' || !txt) opacity = 0; var titleLayout = function() { @@ -104006,7 +104763,7 @@ function plotPolar(gd, data, layout) { var setContenteditable = function() { this.call(svgTextUtils.makeEditable, {gd: gd}) .on('edit', function(text) { - gd.framework({layout: {title: text}}); + gd.framework({layout: {title: {text: text}}}); this.text(text) .call(titleLayout); this.call(setContenteditable); @@ -104279,7 +105036,7 @@ function getExtendProperties(gd, update, indices, maxPoints) { * instance that references the key and value for this particular trace. */ trace = gd.data[indices[j]]; - prop = Lib.nestedProperty(trace, key); + prop = nestedProperty(trace, key); /* * Target is the existing gd.data.trace.dataArray value like "x" or "marker.size" @@ -104750,7 +105507,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) { * If the array is too short, it will wrap around (useful for * style files that want to specify cyclical default values). */ -exports.restyle = function restyle(gd, astr, val, _traces) { +function restyle(gd, astr, val, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -104820,7 +105577,8 @@ exports.restyle = function restyle(gd, astr, val, _traces) { gd.emit('plotly_restyle', specs.eventData); return gd; }); -}; +} +exports.restyle = restyle; // for undo: undefined initial vals must be turned into nulls // so that we unset rather than ignore them @@ -104829,11 +105587,77 @@ function undefinedToNull(val) { return val; } +/** + * Factory function to wrap nestedProperty with GUI edits if necessary + * with GUI edits we add an optional prefix to the nestedProperty constructor + * to prepend to the attribute string in the preGUI store. + */ +function makeNP(preGUI, guiEditFlag) { + if(!guiEditFlag) return nestedProperty; + + return function(container, attr, prefix) { + var np = nestedProperty(container, attr); + var npSet = np.set; + np.set = function(val) { + var fullAttr = (prefix || '') + attr; + storeCurrent(fullAttr, np.get(), val, preGUI); + npSet(val); + }; + return np; + }; +} + +function storeCurrent(attr, val, newVal, preGUI) { + if(Array.isArray(val) || Array.isArray(newVal)) { + var arrayVal = Array.isArray(val) ? val : []; + var arrayNew = Array.isArray(newVal) ? newVal : []; + var maxLen = Math.max(arrayVal.length, arrayNew.length); + for(var i = 0; i < maxLen; i++) { + storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); + } + } + else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + var objVal = Lib.isPlainObject(val) ? val : {}; + var objNew = Lib.isPlainObject(newVal) ? newVal : {}; + var objBoth = Lib.extendFlat({}, objVal, objNew); + for(var key in objBoth) { + storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); + } + } + else if(preGUI[attr] === undefined) { + preGUI[attr] = undefinedToNull(val); + } +} + +/** + * storeDirectGUIEdit: for routines that skip restyle/relayout and mock it + * by emitting a plotly_restyle or plotly_relayout event, this routine + * keeps track of the initial state in _preGUI for use by uirevision + * Does *not* apply these changes to data/layout - that's the responsibility + * of the calling routine. + * + * @param {object} container: the input attributes container (eg `layout` or a `trace`) + * @param {object} preGUI: where original values should be stored, either + * `layout._preGUI` or `layout._tracePreGUI[uid]` + * @param {object} edits: the {attr: val} object as normally passed to `relayout` etc + */ +exports._storeDirectGUIEdit = function(container, preGUI, edits) { + for(var attr in edits) { + var np = nestedProperty(container, attr); + storeCurrent(attr, np.get(), edits[attr], preGUI); + } +}; + function _restyle(gd, aobj, traces) { - var fullLayout = gd._fullLayout, - fullData = gd._fullData, - data = gd.data, - i; + var fullLayout = gd._fullLayout; + var fullData = gd._fullData; + var data = gd.data; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var eventData = Lib.extendDeepAll({}, aobj); + var i; + + cleanDeprecatedAttributeKeys(aobj); // initialize flags var flags = editTypes.traceFlags(); @@ -104857,6 +105681,16 @@ function _restyle(gd, aobj, traces) { function rangeAttr(axName) { return 'LAYOUT' + axName + '.range'; } + function getFullTrace(traceIndex) { + // usually fullData maps 1:1 onto data, but with groupby transforms + // the fullData index can be greater. Take the *first* matching trace. + for(var j = traceIndex; j < fullData.length; j++) { + if(fullData[j]._input === data[traceIndex]) return fullData[j]; + } + // should never get here - and if we *do* it should cause an error + // later on undefined fullTrace is passed to nestedProperty. + } + // for attrs that interact (like scales & autoscales), save the // old vals before making the change // val=undefined will not set a value, just record what the value was. @@ -104872,9 +105706,11 @@ function _restyle(gd, aobj, traces) { var extraparam; if(attr.substr(0, 6) === 'LAYOUT') { - extraparam = Lib.nestedProperty(gd.layout, attr.replace('LAYOUT', '')); + extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', '')); } else { - extraparam = Lib.nestedProperty(data[traces[i]], attr); + var tracei = traces[i]; + var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid]; + extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr); } if(!(attr in undoit)) { @@ -104929,7 +105765,7 @@ function _restyle(gd, aobj, traces) { redoit[ai] = vi; if(ai.substr(0, 6) === 'LAYOUT') { - param = Lib.nestedProperty(gd.layout, ai.replace('LAYOUT', '')); + param = layoutNP(gd.layout, ai.replace('LAYOUT', '')); undoit[ai] = [undefinedToNull(param.get())]; // since we're allowing val to be an array, allow it here too, // even though that's meaningless @@ -104944,8 +105780,9 @@ function _restyle(gd, aobj, traces) { undoit[ai] = a0(); for(i = 0; i < traces.length; i++) { cont = data[traces[i]]; - contFull = fullData[traces[i]]; - param = Lib.nestedProperty(cont, ai); + contFull = getFullTrace(traces[i]); + var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid]; + param = makeNP(preGUI, guiEditFlag)(cont, ai); oldVal = param.get(); newVal = Array.isArray(vi) ? vi[i % vi.length] : vi; @@ -104955,7 +105792,7 @@ function _restyle(gd, aobj, traces) { var prefix = ai.substr(0, ai.length - finalPart.length - 1); var prefixDot = prefix ? prefix + '.' : ''; var innerContFull = prefix ? - Lib.nestedProperty(contFull, prefix).get() : contFull; + nestedProperty(contFull, prefix).get() : contFull; valObject = PlotSchema.getTraceValObject(contFull, param.parts); @@ -105002,14 +105839,14 @@ function _restyle(gd, aobj, traces) { Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo); if(oldVal === 'pie') { - Lib.nestedProperty(cont, 'marker.color') - .set(Lib.nestedProperty(cont, 'marker.colors').get()); + nestedProperty(cont, 'marker.color') + .set(nestedProperty(cont, 'marker.colors').get()); // super kludgy - but if all pies are gone we won't remove them otherwise fullLayout._pielayer.selectAll('g.trace').remove(); } else if(Registry.traceIs(cont, 'cartesian')) { - Lib.nestedProperty(cont, 'marker.colors') - .set(Lib.nestedProperty(cont, 'marker.color').get()); + nestedProperty(cont, 'marker.colors') + .set(nestedProperty(cont, 'marker.color').get()); } } @@ -105080,7 +105917,7 @@ function _restyle(gd, aobj, traces) { // swap hovermode if set to "compare x/y data" if(ai === 'orientationaxes') { - var hovermode = Lib.nestedProperty(gd.layout, 'hovermode'); + var hovermode = nestedProperty(gd.layout, 'hovermode'); if(hovermode.get() === 'x') { hovermode.set('y'); } else if(hovermode.get() === 'y') { @@ -105119,10 +105956,53 @@ function _restyle(gd, aobj, traces) { undoit: undoit, redoit: redoit, traces: traces, - eventData: Lib.extendDeepNoArrays([], [redoit, traces]) + eventData: Lib.extendDeepNoArrays([], [eventData, traces]) }; } +/** + * Converts deprecated attribute keys to + * the current API to ensure backwards compatibility. + * + * This is needed for the update mechanism to determine which + * subroutines to run based on the actual attribute + * definitions (that don't include the deprecated ones). + * + * E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'} + * and {titlefont: {...}} to {'title.font': {...}}. + * + * @param aobj + */ +function cleanDeprecatedAttributeKeys(aobj) { + var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false); + var colorbarRegex = /colorbar\.title$/; + var keys = Object.keys(aobj); + var i, key, value; + + for(i = 0; i < keys.length; i++) { + key = keys[i]; + value = aobj[key]; + + if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) && + (typeof value === 'string' || typeof value === 'number')) { + replace(key, key.replace('title', 'title.text')); + } else if(key.indexOf('titlefont') > -1) { + replace(key, key.replace('titlefont', 'title.font')); + } else if(key.indexOf('titleposition') > -1) { + replace(key, key.replace('titleposition', 'title.position')); + } else if(key.indexOf('titleside') > -1) { + replace(key, key.replace('titleside', 'title.side')); + } else if(key.indexOf('titleoffset') > -1) { + replace(key, key.replace('titleoffset', 'title.offset')); + } + } + + function replace(oldAttrStr, newAttrStr) { + aobj[newAttrStr] = aobj[oldAttrStr]; + delete aobj[oldAttrStr]; + } +} + /** * relayout: update layout attributes of an existing plot * @@ -105143,7 +106023,7 @@ function _restyle(gd, aobj, traces) { * attribute object `{astr1: val1, astr2: val2 ...}` * allows setting multiple attributes simultaneously */ -exports.relayout = function relayout(gd, astr, val) { +function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -105206,7 +106086,8 @@ exports.relayout = function relayout(gd, astr, val) { gd.emit('plotly_relayout', specs.eventData); return gd; }); -}; +} +exports.relayout = relayout; // Optimization mostly for large splom traces where // Plots.supplyDefaults can take > 100ms @@ -105234,13 +106115,24 @@ function addAxRangeSequence(seq, rangesAltered) { // N.B. leave as sequence of subroutines (for now) instead of // subroutine of its own so that finalDraw always gets // executed after drawData - var doTicks = rangesAltered ? - function(gd) { return Axes.doTicks(gd, Object.keys(rangesAltered), true); } : - function(gd) { return Axes.doTicks(gd, 'redraw'); }; + var drawAxes = rangesAltered ? + function(gd) { + var opts = {skipTitle: true}; + for(var id in rangesAltered) { + if(Axes.getFromId(gd, id).automargin) { + opts = {}; + break; + } + } + return Axes.draw(gd, Object.keys(rangesAltered), opts); + } : + function(gd) { + return Axes.draw(gd, 'redraw'); + }; seq.push( subroutines.doAutoRangeAndConstraints, - doTicks, + drawAxes, subroutines.drawData, subroutines.finalDraw ); @@ -105251,14 +106143,19 @@ var AX_AUTORANGE_RE = /^[xyz]axis[0-9]*\.autorange$/; var AX_DOMAIN_RE = /^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/; function _relayout(gd, aobj) { - var layout = gd.layout, - fullLayout = gd._fullLayout, - keys = Object.keys(aobj), - axes = Axes.list(gd), - arrayEdits = {}, - arrayStr, - i, - j; + var layout = gd.layout; + var fullLayout = gd._fullLayout; + var guiEditFlag = fullLayout._guiEditing; + var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag); + var keys = Object.keys(aobj); + var axes = Axes.list(gd); + var eventData = Lib.extendDeepAll({}, aobj); + var arrayEdits = {}; + + var arrayStr, i, j; + + cleanDeprecatedAttributeKeys(aobj); + keys = Object.keys(aobj); // look for 'allaxes', split out into all axes // in case of 3D the axis are nested within a scene which is held in _id @@ -105298,7 +106195,7 @@ function _relayout(gd, aobj) { // via a parent) do not override with this auto-generated extra if(attr in aobj || helpers.hasParent(aobj, attr)) return; - var p = Lib.nestedProperty(layout, attr); + var p = layoutNP(layout, attr); if(!(attr in undoit)) { undoit[attr] = undefinedToNull(p.get()); } @@ -105323,7 +106220,7 @@ function _relayout(gd, aobj) { throw new Error('cannot set ' + ai + 'and a parent attribute simultaneously'); } - var p = Lib.nestedProperty(layout, ai); + var p = layoutNP(layout, ai); var vi = aobj[ai]; var plen = p.parts.length; // p.parts may end with an index integer if the property is an array @@ -105335,8 +106232,8 @@ function _relayout(gd, aobj) { var pleafPlus = p.parts[pend - 1] + '.' + pleaf; // trunk nodes (everything except the leaf) var ptrunk = p.parts.slice(0, pend).join('.'); - var parentIn = Lib.nestedProperty(gd.layout, ptrunk).get(); - var parentFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + var parentIn = nestedProperty(gd.layout, ptrunk).get(); + var parentFull = nestedProperty(fullLayout, ptrunk).get(); var vOld = p.get(); if(vi === undefined) continue; @@ -105381,12 +106278,12 @@ function _relayout(gd, aobj) { // check autorange vs range else if(pleafPlus.match(AX_RANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - var axFull = Lib.nestedProperty(fullLayout, ptrunk).get(); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + var axFull = nestedProperty(fullLayout, ptrunk).get(); if(axFull._inputDomain) { // if we're autoranging and this axis has a constrained domain, // reset it so we don't get locked into a shrunken size @@ -105394,7 +106291,7 @@ function _relayout(gd, aobj) { } } else if(pleafPlus.match(AX_DOMAIN_RE)) { - Lib.nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); + nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } // toggling axis type between log and linear: we need to convert @@ -105463,10 +106360,10 @@ function _relayout(gd, aobj) { doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } - Lib.nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); + nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); } else if(pleaf.match(AX_NAME_PATTERN)) { - var fullProp = Lib.nestedProperty(fullLayout, ai).get(), + var fullProp = nestedProperty(fullLayout, ai).get(), newType = (vi || {}).type; // This can potentially cause strange behavior if the autotype is not @@ -105488,8 +106385,6 @@ function _relayout(gd, aobj) { arrayStr = containerArrayMatch.array; i = containerArrayMatch.index; var propStr = containerArrayMatch.property; - var componentArray = Lib.nestedProperty(layout, arrayStr); - var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; if(i !== '' && propStr === '') { @@ -105499,7 +106394,7 @@ function _relayout(gd, aobj) { if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { - undoit[ai] = obji; + undoit[ai] = (nestedProperty(layout, arrayStr).get() || [])[i]; } else { Lib.warn('unrecognized full object value', aobj); } @@ -105543,7 +106438,7 @@ function _relayout(gd, aobj) { // now we've collected component edits - execute them all together for(arrayStr in arrayEdits) { var finished = manageArrays.applyContainerArrayChanges(gd, - Lib.nestedProperty(layout, arrayStr), arrayEdits[arrayStr], flags); + layoutNP(layout, arrayStr), arrayEdits[arrayStr], flags, layoutNP); if(!finished) flags.plot = true; } @@ -105586,7 +106481,7 @@ function _relayout(gd, aobj) { rangesAltered: rangesAltered, undoit: undoit, redoit: redoit, - eventData: Lib.extendDeep({}, redoit) + eventData: eventData }; } @@ -105621,7 +106516,7 @@ function updateAutosize(gd) { * integer or array of integers for the traces to alter (all if omitted) * */ -exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { +function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); @@ -105701,7 +106596,235 @@ exports.update = function update(gd, traceUpdate, layoutUpdate, _traces) { return gd; }); -}; +} +exports.update = update; + +/* + * internal-use-only restyle/relayout/update variants that record the initial + * values in (fullLayout|fullTrace)._preGUI so changes can be persisted across + * Plotly.react data updates, dependent on uirevision attributes + */ +function guiEdit(func) { + return function wrappedEdit(gd) { + gd._fullLayout._guiEditing = true; + var p = func.apply(null, arguments); + gd._fullLayout._guiEditing = false; + return p; + }; +} +exports._guiRestyle = guiEdit(restyle); +exports._guiRelayout = guiEdit(relayout); +exports._guiUpdate = guiEdit(update); + +// For connecting edited layout attributes to uirevision attrs +// If no `attr` we use `match[1] + '.uirevision'` +// Ordered by most common edits first, to minimize our search time +var layoutUIControlPatterns = [ + {pattern: /^hiddenlabels/, attr: 'legend.uirevision'}, + {pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/}, + + // showspikes and modes include those nested inside scenes + {pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'}, + {pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'}, + + {pattern: /^(scene\d*)\.camera/}, + {pattern: /^(geo\d*)\.(projection|center)/}, + {pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/}, + {pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/}, + {pattern: /^(polar\d*\.angularaxis)\.rotation/}, + {pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/}, + + {pattern: /^legend\.(x|y)$/, attr: 'editrevision'}, + {pattern: /^(shapes|annotations)/, attr: 'editrevision'}, + {pattern: /^title\.text$/, attr: 'editrevision'} +]; + +// same for trace attributes: if `attr` is given it's in layout, +// or with no `attr` we use `trace.uirevision` +var traceUIControlPatterns = [ + {pattern: /^selectedpoints$/, attr: 'selectionrevision'}, + // "visible" includes trace.transforms[i].styles[j].value.visible + {pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'}, + {pattern: /^dimensions\[\d+\]\.constraintrange/}, + + // below this you must be in editable: true mode + // TODO: I still put name and title with `trace.uirevision` + // reasonable or should these be `editrevision`? + // Also applies to axis titles up in the layout section + + // "name" also includes transform.styles + {pattern: /(^|value\.)name$/}, + // including nested colorbar attributes (ie marker.colorbar) + {pattern: /colorbar\.title\.text$/}, + {pattern: /colorbar\.(x|y)$/, attr: 'editrevision'} +]; + +function findUIPattern(key, patternSpecs) { + for(var i = 0; i < patternSpecs.length; i++) { + var spec = patternSpecs[i]; + var match = key.match(spec.pattern); + if(match) { + return {head: match[1], attr: spec.attr}; + } + } +} + +// We're finding the new uirevision before supplyDefaults, so do the +// inheritance manually. Note that only `undefined` inherits - other +// falsy values are returned. +function getNewRev(revAttr, container) { + var newRev = nestedProperty(container, revAttr).get(); + if(newRev !== undefined) return newRev; + + var parts = revAttr.split('.'); + parts.pop(); + while(parts.length > 1) { + parts.pop(); + newRev = nestedProperty(container, parts.join('.') + '.uirevision').get(); + if(newRev !== undefined) return newRev; + } + + return container.uirevision; +} + +function getFullTraceIndexFromUid(uid, fullData) { + for(var i = 0; i < fullData.length; i++) { + if(fullData[i]._fullInput.uid === uid) return i; + } + return -1; +} + +function getTraceIndexFromUid(uid, data, tracei) { + for(var i = 0; i < data.length; i++) { + if(data[i].uid === uid) return i; + } + // fall back on trace order, but only if user didn't provide a uid for that trace + return data[tracei].uid ? -1 : tracei; +} + +function valsMatch(v1, v2) { + var v1IsObj = Lib.isPlainObject(v1); + var v1IsArray = Array.isArray(v1); + if(v1IsObj || v1IsArray) { + return ( + (v1IsObj && Lib.isPlainObject(v2)) || + (v1IsArray && Array.isArray(v2)) + ) && JSON.stringify(v1) === JSON.stringify(v2); + } + return v1 === v2; +} + +function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { + var layoutPreGUI = oldFullLayout._preGUI; + var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal; + var bothInheritAutorange = []; + var newRangeAccepted = {}; + for(key in layoutPreGUI) { + match = findUIPattern(key, layoutUIControlPatterns); + if(match) { + revAttr = match.attr || (match.head + '.uirevision'); + oldRev = nestedProperty(oldFullLayout, revAttr).get(); + newRev = oldRev && getNewRev(revAttr, layout); + if(newRev && (newRev === oldRev)) { + preGUIVal = layoutPreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(layout, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + if(newVal === undefined && key.substr(key.length - 9) === 'autorange') { + bothInheritAutorange.push(key.substr(0, key.length - 10)); + } + newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key); + } + // if we got this far, the new value was accepted as the new starting + // point (either because it changed or revision changed) + // so remove it from _preGUI for next time. + delete layoutPreGUI[key]; + + if(key.substr(key.length - 8, 6) === 'range[') { + newRangeAccepted[key.substr(0, key.length - 9)] = 1; + } + } + + // Special logic for `autorange`, since it interacts with `range`: + // If the new figure's matching `range` was kept, and `autorange` + // wasn't supplied explicitly in either the original or the new figure, + // we shouldn't alter that - but we may just have done that, so fix it. + for(var i = 0; i < bothInheritAutorange.length; i++) { + var axAttr = bothInheritAutorange[i]; + if(newRangeAccepted[axAttr]) { + var newAx = nestedProperty(layout, axAttr).get(); + if(newAx) delete newAx.autorange; + } + } + + // Now traces - try to match them up by uid (in case we added/deleted in + // the middle), then fall back on index. + var allTracePreGUI = oldFullLayout._tracePreGUI; + for(var uid in allTracePreGUI) { + var tracePreGUI = allTracePreGUI[uid]; + var newTrace = null; + var fullInput; + for(key in tracePreGUI) { + // wait until we know we have preGUI values to look for traces + // but if we don't find both, stop looking at this uid + if(!newTrace) { + var fulli = getFullTraceIndexFromUid(uid, oldFullData); + if(fulli < 0) { + // Somehow we didn't even have this trace in oldFullData... + // I guess this could happen with `deleteTraces` or something + delete allTracePreGUI[uid]; + break; + } + var fullTrace = oldFullData[fulli]; + fullInput = fullTrace._fullInput; + + var newTracei = getTraceIndexFromUid(uid, data, fullInput.index); + if(newTracei < 0) { + // No match in new data + delete allTracePreGUI[uid]; + break; + } + newTrace = data[newTracei]; + } + + match = findUIPattern(key, traceUIControlPatterns); + if(match) { + if(match.attr) { + oldRev = nestedProperty(oldFullLayout, match.attr).get(); + newRev = oldRev && getNewRev(match.attr, layout); + } + else { + oldRev = fullInput.uirevision; + // inheritance for trace.uirevision is simple, just layout.uirevision + newRev = newTrace.uirevision; + if(newRev === undefined) newRev = layout.uirevision; + } + + if(newRev && newRev === oldRev) { + preGUIVal = tracePreGUI[key]; + if(preGUIVal === null) preGUIVal = undefined; + newNP = nestedProperty(newTrace, key); + newVal = newNP.get(); + if(valsMatch(newVal, preGUIVal)) { + newNP.set(undefinedToNull(nestedProperty(fullInput, key).get())); + continue; + } + } + } + else { + Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); + } + delete tracePreGUI[key]; + } + } +} /** * Plotly.react: @@ -105765,6 +106888,8 @@ exports.react = function(gd, data, layout, config) { gd.layout = layout || {}; helpers.cleanLayout(gd.layout); + applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout); + // "true" skips updating calcdata and remapping arrays from calcTransforms, // which supplyDefaults usually does at the end, but we may need to NOT do // if the diff (which we haven't determined yet) says we'll recalc @@ -106819,7 +107944,7 @@ function makePlotFramework(gd) { gd.emit('plotly_framework'); } -},{"../components/color":570,"../components/colorbar/connect":572,"../components/drawing":595,"../constants/xmlns_namespaces":674,"../lib":696,"../lib/events":684,"../lib/queue":711,"../lib/svg_text_utils":720,"../plots/cartesian/axes":744,"../plots/cartesian/constants":750,"../plots/cartesian/graph_interact":754,"../plots/plots":808,"../plots/polar/legacy":816,"../registry":827,"./edit_types":727,"./helpers":728,"./manage_arrays":730,"./plot_config":732,"./plot_schema":733,"./subroutines":735,"d3":148,"fast-isnumeric":214,"has-hover":393}],732:[function(_dereq_,module,exports){ +},{"../components/color":569,"../components/colorbar/connect":571,"../components/drawing":590,"../constants/xmlns_namespaces":670,"../lib":692,"../lib/events":681,"../lib/queue":707,"../lib/svg_text_utils":716,"../plots/cartesian/axes":740,"../plots/cartesian/constants":746,"../plots/cartesian/graph_interact":750,"../plots/plots":804,"../plots/polar/legacy":812,"../registry":823,"./edit_types":723,"./helpers":724,"./manage_arrays":726,"./plot_config":728,"./plot_schema":729,"./subroutines":731,"d3":148,"fast-isnumeric":214,"has-hover":393}],728:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -106912,12 +108037,34 @@ module.exports = { */ showAxisRangeEntryBoxes: true, - // link to open this plot in plotly + /* + * Add a text link to open this plot in plotly? + * This link shows up in the bottom right corner of the plot, and works + * identically to the newer ModeBar button controlled by `showSendToCloud` + * unless `sendData: false` is used. + */ showLink: false, - // if we show a link, does it contain data or just link to a plotly file? + /* + * If we show a text link (`showLink: true`), does it contain data or just + * a reference to a plotly cloud file? This option should only be used on + * plot.ly or another plotly server, and is not supported by the newer + * ModeBar button `showSendToCloud`. + */ sendData: true, + /* + * Should we include a ModeBar button, labeled "Edit in Chart Studio", + * that sends this chart to plot.ly or another plotly server as specified + * by `plotlyServerURL` for editing, export, etc? Prior to version 1.43.0 + * this button was included by default, now it is opt-in using this flag. + * + * Note that this button can (depending on `plotlyServerURL`) send your data + * to an external server. However that server doesn't persist your data + * until you arrive at the Chart Studio and explicitly click "Save". + */ + showSendToCloud: false, + // text appearing in the sendData link linkText: 'Edit chart', @@ -106955,6 +108102,9 @@ module.exports = { // add the plotly logo on the end of the mode bar displaylogo: true, + // watermark the images with the company's logo + watermark: false, + // increase the pixel ratio for Gl plot images plotGlPixelRatio: 2, @@ -107021,7 +108171,7 @@ module.exports = { locales: {} }; -},{}],733:[function(_dereq_,module,exports){ +},{}],729:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -107707,7 +108857,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":696,"../plots/animation_attributes":739,"../plots/attributes":741,"../plots/frame_attributes":772,"../plots/layout_attributes":799,"../plots/polar/legacy/area_attributes":814,"../plots/polar/legacy/axis_attributes":815,"../registry":827,"./edit_types":727}],734:[function(_dereq_,module,exports){ +},{"../lib":692,"../plots/animation_attributes":735,"../plots/attributes":737,"../plots/frame_attributes":768,"../plots/layout_attributes":795,"../plots/polar/legacy/area_attributes":810,"../plots/polar/legacy/axis_attributes":811,"../registry":823,"./edit_types":723}],730:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108021,7 +109171,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":696,"../plots/attributes":741}],735:[function(_dereq_,module,exports){ +},{"../lib":692,"../plots/attributes":737}],731:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -108051,6 +109201,10 @@ var enforceAxisConstraints = axisConstraints.enforce; var cleanAxisConstraints = axisConstraints.clean; var doAutoRange = _dereq_('../plots/cartesian/autorange').doAutoRange; +var SVG_TEXT_ANCHOR_START = 'start'; +var SVG_TEXT_ANCHOR_MIDDLE = 'middle'; +var SVG_TEXT_ANCHOR_END = 'end'; + exports.layoutStyles = function(gd) { return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd); }; @@ -108075,7 +109229,7 @@ function lsInner(gd) { var gs = fullLayout._size; var pad = gs.p; var axList = Axes.list(gd, '', true); - var i, subplot, plotinfo, xa, ya; + var i, subplot, plotinfo, ax, xa, ya; fullLayout._paperdiv.style({ width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px', @@ -108111,10 +109265,7 @@ function lsInner(gd) { // some preparation of axis position info for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - - // reset scale in case the margins have changed - ax.setScale(); + ax = axList[i]; var counterAx = ax._anchorAxis; @@ -108133,11 +109284,6 @@ function lsInner(gd) { ax._mainMirrorPosition = (ax.mirror && counterAx) ? getLinePosition(ax, counterAx, alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; - - // Figure out which subplot to draw ticks, labels, & axis lines on - // do this as a separate loop so we already have all the - // _mainAxis and _anchorAxis links set - ax._mainSubplot = findMainSubplot(ax, fullLayout); } // figure out which backgrounds we need to draw, @@ -108248,7 +109394,7 @@ function lsInner(gd) { layerClipId = null; } - Drawing.setClipUrl(plotinfo.plot, plotClipId); + Drawing.setClipUrl(plotinfo.plot, plotClipId, gd); // stash layer clipId value (null or same as clipId) // to DRY up Drawing.setClipUrl calls on trace-module and trace layers @@ -108378,48 +109524,6 @@ function lsInner(gd) { return gd._promises.length && Promise.all(gd._promises); } -function findMainSubplot(ax, fullLayout) { - var subplotList = fullLayout._subplots; - var ids = subplotList.cartesian.concat(subplotList.gl2d || []); - var mockGd = {_fullLayout: fullLayout}; - - var isX = ax._id.charAt(0) === 'x'; - var anchorAx = ax._mainAxis._anchorAxis; - var mainSubplotID = ''; - var nextBestMainSubplotID = ''; - var anchorID = ''; - - // First try the main ID with the anchor - if(anchorAx) { - anchorID = anchorAx._mainAxis._id; - mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); - } - - // Then look for a subplot with the counteraxis overlaying the anchor - // If that fails just use the first subplot including this axis - if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { - mainSubplotID = ''; - - for(var j = 0; j < ids.length; j++) { - var id = ids[j]; - var yIndex = id.indexOf('y'); - var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); - var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); - - if(idPart === ax._id) { - if(!nextBestMainSubplotID) nextBestMainSubplotID = id; - var counterAx = Axes.getFromId(mockGd, counterPart); - if(anchorID && counterAx.overlaying === anchorID) { - mainSubplotID = id; - break; - } - } - } - } - - return mainSubplotID || nextBestMainSubplotID; -} - function shouldShowLinesOrTicks(ax, subplot) { return (ax.ticks || ax.showline) && (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); @@ -108474,18 +109578,92 @@ function findCounterAxisLineWidth(ax, side, counterAx, axList) { exports.drawMainTitle = function(gd) { var fullLayout = gd._fullLayout; + var textAnchor = getMainTitleTextAnchor(fullLayout); + var dy = getMainTitleDy(fullLayout); + Titles.draw(gd, 'gtitle', { propContainer: fullLayout, - propName: 'title', + propName: 'title.text', placeholder: fullLayout._dfltTitle.plot, attributes: { - x: fullLayout.width / 2, - y: fullLayout._size.t / 2, - 'text-anchor': 'middle' + x: getMainTitleX(fullLayout, textAnchor), + y: getMainTitleY(fullLayout, dy), + 'text-anchor': textAnchor, + dy: dy } }); }; +function getMainTitleX(fullLayout, textAnchor) { + var title = fullLayout.title; + var gs = fullLayout._size; + var hPadShift = 0; + + if(textAnchor === SVG_TEXT_ANCHOR_START) { + hPadShift = title.pad.l; + } else if(textAnchor === SVG_TEXT_ANCHOR_END) { + hPadShift = -title.pad.r; + } + + switch(title.xref) { + case 'paper': + return gs.l + gs.w * title.x + hPadShift; + case 'container': + default: + return fullLayout.width * title.x + hPadShift; + } +} + +function getMainTitleY(fullLayout, dy) { + var title = fullLayout.title; + var gs = fullLayout._size; + var vPadShift = 0; + + if(dy === '0em' || !dy) { + vPadShift = -title.pad.b; + } else if(dy === alignmentConstants.CAP_SHIFT + 'em') { + vPadShift = title.pad.t; + } + + if(title.y === 'auto') { + return gs.t / 2; + } else { + switch(title.yref) { + case 'paper': + return gs.t + gs.h - gs.h * title.y + vPadShift; + case 'container': + default: + return fullLayout.height - fullLayout.height * title.y + vPadShift; + } + } +} + +function getMainTitleTextAnchor(fullLayout) { + var title = fullLayout.title; + + var textAnchor = SVG_TEXT_ANCHOR_MIDDLE; + if(Lib.isRightAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_END; + } else if(Lib.isLeftAnchor(title)) { + textAnchor = SVG_TEXT_ANCHOR_START; + } + + return textAnchor; +} + +function getMainTitleDy(fullLayout) { + var title = fullLayout.title; + + var dy = '0em'; + if(Lib.isTopAnchor(title)) { + dy = alignmentConstants.CAP_SHIFT + 'em'; + } else if(Lib.isMiddleAnchor(title)) { + dy = alignmentConstants.MID_SHIFT + 'em'; + } + + return dy; +} + exports.doTraceStyle = function(gd) { var calcdata = gd.calcdata; var editStyleCalls = []; @@ -108563,7 +109741,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.doTicks(gd, 'redraw'); + Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -108698,6 +109876,8 @@ exports.doAutoRangeAndConstraints = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; cleanAxisConstraints(gd, ax); + // in case margins changed, update scale + ax.setScale(); doAutoRange(gd, ax); } @@ -108729,7 +109909,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('updatemenus', 'draw')(gd); }; -},{"../components/color":570,"../components/drawing":595,"../components/modebar":633,"../components/titles":661,"../constants/alignment":668,"../lib":696,"../lib/clear_gl_canvases":680,"../plots/cartesian/autorange":743,"../plots/cartesian/axes":744,"../plots/cartesian/constraints":752,"../plots/plots":808,"../registry":827,"d3":148}],736:[function(_dereq_,module,exports){ +},{"../components/color":569,"../components/drawing":590,"../components/modebar":628,"../components/titles":657,"../constants/alignment":664,"../lib":692,"../lib/clear_gl_canvases":677,"../plots/cartesian/autorange":739,"../plots/cartesian/axes":740,"../plots/cartesian/constraints":748,"../plots/plots":804,"../registry":823,"d3":148}],732:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109203,7 +110383,7 @@ function format(opts) { return opts; } -},{"../lib":696,"../plots/attributes":741,"../plots/plots":808,"./plot_config":732,"./plot_schema":733,"./plot_template":734}],737:[function(_dereq_,module,exports){ +},{"../lib":692,"../plots/attributes":737,"../plots/plots":804,"./plot_config":728,"./plot_schema":729,"./plot_template":730}],733:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109323,6 +110503,7 @@ function toImage(gd, opts) { // extend config for static plot var configImage = Lib.extendFlat({}, config, { + _exportedPlot: true, staticPlot: true, setBackground: setBackground }); @@ -109393,7 +110574,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":696,"../snapshot/helpers":831,"../snapshot/svgtoimg":833,"../snapshot/tosvg":835,"./plot_api":731}],738:[function(_dereq_,module,exports){ +},{"../lib":692,"../snapshot/helpers":827,"../snapshot/svgtoimg":829,"../snapshot/tosvg":831,"./plot_api":727}],734:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109839,7 +111020,7 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":696,"../plots/plots":808,"./plot_config":732,"./plot_schema":733}],739:[function(_dereq_,module,exports){ +},{"../lib":692,"../plots/plots":804,"./plot_config":728,"./plot_schema":729}],735:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -109941,7 +111122,7 @@ module.exports = { } }; -},{}],740:[function(_dereq_,module,exports){ +},{}],736:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110037,7 +111218,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":696,"../plot_api/plot_template":734}],741:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/plot_template":730}],737:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110159,10 +111340,16 @@ module.exports = { _isLinkedToArray: 'transform', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + } }; -},{"../components/fx/attributes":604}],742:[function(_dereq_,module,exports){ +},{"../components/fx/attributes":599}],738:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110191,7 +111378,7 @@ module.exports = { } }; -},{}],743:[function(_dereq_,module,exports){ +},{}],739:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110206,6 +111393,7 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; +var Registry = _dereq_('../../registry'); module.exports = { getAutoRange: getAutoRange, @@ -110430,10 +111618,6 @@ function concatExtremes(gd, ax) { } function doAutoRange(gd, ax) { - if(!ax._length) ax.setScale(); - - var axIn; - if(ax.autorange) { ax.range = getAutoRange(gd, ax); @@ -110443,20 +111627,28 @@ function doAutoRange(gd, ax) { // doAutoRange will get called on fullLayout, // but we want to report its results back to layout - axIn = ax._input; + var axIn = ax._input; + + // before we edit _input, store preGUI values + var edits = {}; + edits[ax._attr + '.range'] = ax.range; + edits[ax._attr + '.autorange'] = ax.autorange; + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, edits); + axIn.range = ax.range.slice(); axIn.autorange = ax.autorange; } - if(ax._anchorAxis && ax._anchorAxis.rangeslider) { - var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name]; + var anchorAx = ax._anchorAxis; + + if(anchorAx && anchorAx.rangeslider) { + var axeRangeOpts = anchorAx.rangeslider[ax._name]; if(axeRangeOpts) { if(axeRangeOpts.rangemode === 'auto') { axeRangeOpts.range = getAutoRange(gd, ax); } } - axIn = ax._anchorAxis._input; - axIn.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); + anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts); } } @@ -110674,7 +111866,7 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":673,"../../lib":696,"fast-isnumeric":214}],744:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../registry":823,"fast-isnumeric":214}],740:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -110834,6 +112026,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t ax.d2c(targetArray[i]); } } + // TODO what to do for transforms? } else { ax = axes.getFromTrace(gd, trace, d2cTarget); } @@ -110874,7 +112067,7 @@ axes.counterLetter = function(id) { axes.minDtick = function(ax, newDiff, newFirst, allow) { // doesn't make sense to do forced min dTick on log or category axes, // and the plot itself may decide to cancel (ie non-grouped bars) - if(['log', 'category'].indexOf(ax.type) !== -1 || !allow) { + if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; } // undefined means there's nothing there yet @@ -110906,18 +112099,15 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // save a copy of the initial axis ranges in fullLayout // use them in mode bar and dblclick events axes.saveRangeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._rangeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.range[0] === ax._rangeInitial[0] && - ax.range[1] === ax._rangeInitial[1] - ) + var hasChanged = isNew || !( + ax.range[0] === ax._rangeInitial[0] && + ax.range[1] === ax._rangeInitial[1] ); if((isNew && ax.autorange === false) || (overwrite && hasChanged)) { @@ -110931,21 +112121,16 @@ axes.saveRangeInitial = function(gd, overwrite) { // save a copy of the initial spike visibility axes.saveShowSpikeInitial = function(gd, overwrite) { - var axList = axes.list(gd, '', true), - hasOneAxisChanged = false, - allSpikesEnabled = 'on'; + var axList = axes.list(gd, '', true); + var hasOneAxisChanged = false; + var allSpikesEnabled = 'on'; for(var i = 0; i < axList.length; i++) { var ax = axList[i]; - var isNew = (ax._showSpikeInitial === undefined); - var hasChanged = ( - isNew || !( - ax.showspikes === ax._showspikes - ) - ); + var hasChanged = isNew || !(ax.showspikes === ax._showspikes); - if((isNew) || (overwrite && hasChanged)) { + if(isNew || (overwrite && hasChanged)) { ax._showSpikeInitial = ax.showspikes; hasOneAxisChanged = true; } @@ -110962,7 +112147,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { var dataMin = Lib.aggNums(Math.min, null, data); var dataMax = Lib.aggNums(Math.max, null, data); - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { return { start: dataMin - 0.5, end: dataMax + 0.5, @@ -110980,8 +112165,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { type: 'linear', range: [dataMin, dataMax] }; - } - else { + } else { dummyAx = { type: ax.type, range: Lib.simpleMap([dataMin, dataMax], ax.c2r, 0, calendar), @@ -111066,10 +112250,10 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { - var edgecount = 0, - midcount = 0, - intcount = 0, - blankCount = 0; + var edgecount = 0; + var midcount = 0; + var intcount = 0; + var blankCount = 0; function nearEdge(v) { // is a value within 1% of a bin edge? @@ -111160,14 +112344,14 @@ axes.prepTicks = function(ax) { // calculate max number of (auto) ticks to display based on plot size if(ax.tickmode === 'auto' || !ax.dtick) { - var nt = ax.nticks, - minPx; + var nt = ax.nticks; + var minPx; + if(!nt) { - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; nt = ax._length / minPx; - } - else { + } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; nt = Lib.constrain(ax._length / minPx, 4, 9) + 1; } @@ -111229,7 +112413,7 @@ axes.calcTicks = function calcTicks(ax) { // return the full set of tick vals var vals = []; - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { endTick = (axrev) ? Math.max(-0.5, endTick) : Math.min(ax._categories.length - 0.5, endTick); } @@ -111273,23 +112457,22 @@ axes.calcTicks = function calcTicks(ax) { }; function arrayTicks(ax) { - var vals = ax.tickvals, - text = ax.ticktext, - ticksOut = new Array(vals.length), - rng = Lib.simpleMap(ax.range, ax.r2l), - r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001, - r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001, - tickMin = Math.min(r0expanded, r1expanded), - tickMax = Math.max(r0expanded, r1expanded), - vali, - i, - j = 0; + var vals = ax.tickvals; + var text = ax.ticktext; + var ticksOut = new Array(vals.length); + var rng = Lib.simpleMap(ax.range, ax.r2l); + var r0expanded = rng[0] * 1.0001 - rng[1] * 0.0001; + var r1expanded = rng[1] * 1.0001 - rng[0] * 0.0001; + var tickMin = Math.min(r0expanded, r1expanded); + var tickMax = Math.max(r0expanded, r1expanded); + var j = 0; // without a text array, just format the given values as any other ticks // except with more precision to the numbers if(!Array.isArray(text)) text = []; // make sure showing ticks doesn't accidentally add new categories + // TODO multicategory, if we allow ticktext / tickvals var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; // array ticks on log axes always show the full number @@ -111298,8 +112481,8 @@ function arrayTicks(ax) { ax.dtick = 'L' + Math.pow(10, Math.floor(Math.min(ax.range[0], ax.range[1])) - 1); } - for(i = 0; i < vals.length; i++) { - vali = tickVal2l(vals[i]); + for(var i = 0; i < vals.length; i++) { + var vali = tickVal2l(vals[i]); if(vali > tickMin && vali < tickMax) { if(text[i] === undefined) ticksOut[j] = axes.tickText(ax, vali); else ticksOut[j] = tickTextObj(ax, vali, String(text[i])); @@ -111312,17 +112495,17 @@ function arrayTicks(ax) { return ticksOut; } -var roundBase10 = [2, 5, 10], - roundBase24 = [1, 2, 3, 6, 12], - roundBase60 = [1, 2, 5, 10, 15, 30], - // 2&3 day ticks are weird, but need something btwn 1&7 - roundDays = [1, 2, 3, 7, 14], - // approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) - // these don't have to be exact, just close enough to round to the right value - roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1], - roundLog2 = [-0.301, 0, 0.301, 0.699, 1], - // N.B. `thetaunit; 'radians' angular axes must be converted to degrees - roundAngles = [15, 30, 45, 90, 180]; +var roundBase10 = [2, 5, 10]; +var roundBase24 = [1, 2, 3, 6, 12]; +var roundBase60 = [1, 2, 5, 10, 15, 30]; +// 2&3 day ticks are weird, but need something btwn 1&7 +var roundDays = [1, 2, 3, 7, 14]; +// approx. tick positions for log axes, showing all (1) and just 1, 2, 5 (2) +// these don't have to be exact, just close enough to round to the right value +var roundLog1 = [-0.046, 0, 0.301, 0.477, 0.602, 0.699, 0.778, 0.845, 0.903, 0.954, 1]; +var roundLog2 = [-0.301, 0, 0.301, 0.699, 1]; +// N.B. `thetaunit; 'radians' angular axes must be converted to degrees +var roundAngles = [15, 30, 45, 90, 180]; function roundDTick(roughDTick, base, roundingSet) { return base * Lib.roundUp(roughDTick / base, roundingSet); @@ -111413,7 +112596,7 @@ axes.autoTicks = function(ax, roughDTick) { ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } } - else if(ax.type === 'category') { + else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); } @@ -111453,7 +112636,7 @@ function autoTickRound(ax) { dtick = 1; } - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { ax._tickround = null; } if(ax.type === 'date') { @@ -111545,36 +112728,34 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { // calculate the first tick on an axis axes.tickFirst = function(ax) { - var r2l = ax.r2l || Number, - rng = Lib.simpleMap(ax.range, r2l), - axrev = rng[1] < rng[0], - sRound = axrev ? Math.floor : Math.ceil, - // add a tiny extra bit to make sure we get ticks - // that may have been rounded out - r0 = rng[0] * 1.0001 - rng[1] * 0.0001, - dtick = ax.dtick, - tick0 = r2l(ax.tick0); + var r2l = ax.r2l || Number; + var rng = Lib.simpleMap(ax.range, r2l); + var axrev = rng[1] < rng[0]; + var sRound = axrev ? Math.floor : Math.ceil; + // add a tiny extra bit to make sure we get ticks + // that may have been rounded out + var r0 = rng[0] * 1.0001 - rng[1] * 0.0001; + var dtick = ax.dtick; + var tick0 = r2l(ax.tick0); if(isNumeric(dtick)) { var tmin = sRound((r0 - tick0) / dtick) * dtick + tick0; // make sure no ticks outside the category list - if(ax.type === 'category') { + if(ax.type === 'category' || ax.type === 'multicategory') { tmin = Lib.constrain(tmin, 0, ax._categories.length - 1); } return tmin; } - var tType = dtick.charAt(0), - dtNum = Number(dtick.substr(1)); + var tType = dtick.charAt(0); + var dtNum = Number(dtick.substr(1)); // Dates: months (or years) if(tType === 'M') { - var cnt = 0, - t0 = tick0, - t1, - mult, - newDTick; + var cnt = 0; + var t0 = tick0; + var t1, mult, newDTick; // This algorithm should work for *any* nonlinear (but close to linear!) // tick spacing. Limit to 10 iterations, for gregorian months it's normally <=3. @@ -111616,16 +112797,18 @@ axes.tickFirst = function(ax) { // hover is a (truthy) flag for whether to show numbers with a bit // more precision for hovertext axes.tickText = function(ax, x, hover) { - var out = tickTextObj(ax, x), - hideexp, - arrayMode = ax.tickmode === 'array', - extraPrecision = hover || arrayMode, - i, - tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l; + var out = tickTextObj(ax, x); + var arrayMode = ax.tickmode === 'array'; + var extraPrecision = hover || arrayMode; + var axType = ax.type; + // TODO multicategory, if we allow ticktext / tickvals + var tickVal2l = axType === 'category' ? ax.d2l_noadd : ax.d2l; + var i; if(arrayMode && Array.isArray(ax.ticktext)) { - var rng = Lib.simpleMap(ax.range, ax.r2l), - minDiff = Math.abs(rng[1] - rng[0]) / 10000; + var rng = Lib.simpleMap(ax.range, ax.r2l); + var minDiff = Math.abs(rng[1] - rng[0]) / 10000; + for(i = 0; i < ax.ticktext.length; i++) { if(Math.abs(x - tickVal2l(ax.tickvals[i])) < minDiff) break; } @@ -111636,28 +112819,25 @@ axes.tickText = function(ax, x, hover) { } function isHidden(showAttr) { - var first_or_last; - if(showAttr === undefined) return true; if(hover) return showAttr === 'none'; - first_or_last = { + var firstOrLast = { first: ax._tmin, last: ax._tmax }[showAttr]; - return showAttr !== 'all' && x !== first_or_last; + return showAttr !== 'all' && x !== firstOrLast; } - if(hover) { - hideexp = 'never'; - } else { - hideexp = ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - } + var hideexp = hover ? + 'never' : + ax.exponentformat !== 'none' && isHidden(ax.showexponent) ? 'hide' : ''; - if(ax.type === 'date') formatDate(ax, out, hover, extraPrecision); - else if(ax.type === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); - else if(ax.type === 'category') formatCategory(ax, out); + if(axType === 'date') formatDate(ax, out, hover, extraPrecision); + else if(axType === 'log') formatLog(ax, out, hover, extraPrecision, hideexp); + else if(axType === 'category') formatCategory(ax, out); + else if(axType === 'multicategory') formatMultiCategory(ax, out, hover); else if(isAngular(ax)) formatAngle(ax, out, hover, extraPrecision, hideexp); else formatLinear(ax, out, hover, extraPrecision, hideexp); @@ -111665,6 +112845,20 @@ axes.tickText = function(ax, x, hover) { if(ax.tickprefix && !isHidden(ax.showtickprefix)) out.text = ax.tickprefix + out.text; if(ax.ticksuffix && !isHidden(ax.showticksuffix)) out.text += ax.ticksuffix; + // Setup ticks and grid lines boundaries + // at 1/2 a 'category' to the left/bottom + if(ax.tickson === 'boundaries' || ax.showdividers) { + var inbounds = function(v) { + var p = ax.l2p(v); + return p >= 0 && p <= ax._length ? v : null; + }; + + out.xbnd = [ + inbounds(out.x - 0.5), + inbounds(out.x + ax.dtick - 0.5) + ]; + } + return out; }; @@ -111714,8 +112908,8 @@ function tickTextObj(ax, x, text) { } function formatDate(ax, out, hover, extraPrecision) { - var tr = ax._tickround, - fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); + var tr = ax._tickround; + var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax); if(extraPrecision) { // second or sub-second precision: extra always shows max digits. @@ -111724,8 +112918,8 @@ function formatDate(ax, out, hover, extraPrecision) { else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr]; } - var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat), - headStr; + var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat); + var headStr; var splitIndex = dateStr.indexOf('\n'); if(splitIndex !== -1) { @@ -111842,6 +113036,22 @@ function formatCategory(ax, out) { out.text = String(tt); } +function formatMultiCategory(ax, out, hover) { + var v = Math.round(out.x); + var cats = ax._categories[v] || []; + var tt = cats[1] === undefined ? '' : String(cats[1]); + var tt2 = cats[0] === undefined ? '' : String(cats[0]); + + if(hover) { + // TODO is this what we want? + out.text = tt2 + ' - ' + tt; + } else { + // setup for secondary labels + out.text = tt; + out.text2 = tt2; + } +} + function formatLinear(ax, out, hover, extraPrecision, hideexp) { if(hideexp === 'never') { // If this is a hover label, then we must *never* hide the exponent @@ -111947,14 +113157,13 @@ function beyondSI(exponent) { } function numFormat(v, ax, fmtoverride, hover) { - // negative? - var isNeg = v < 0, - // max number of digits past decimal point to show - tickRound = ax._tickround, - exponentFormat = fmtoverride || ax.exponentformat || 'B', - exponent = ax._tickexponent, - tickformat = axes.getTickFormat(ax), - separatethousands = ax.separatethousands; + var isNeg = v < 0; + // max number of digits past decimal point to show + var tickRound = ax._tickround; + var exponentFormat = fmtoverride || ax.exponentformat || 'B'; + var exponent = ax._tickexponent; + var tickformat = axes.getTickFormat(ax); + var separatethousands = ax.separatethousands; // special case for hover: set exponent just for this value, and // add a couple more digits of precision over tick labels @@ -112127,6 +113336,9 @@ axes.getTickFormat = function(ax) { // as an array of items like 'xy', 'x2y', 'x2y2'... // sorted by x (x,x2,x3...) then y // optionally restrict to only subplots containing axis object ax +// +// NOTE: this is currently only used OUTSIDE plotly.js (toolpanel, webapp) +// ideally we get rid of it there (or just copy this there) and remove it here axes.getSubplots = function(gd, ax) { var subplotObj = gd._fullLayout._subplots; var allSubplots = subplotObj.cartesian.concat(subplotObj.gl2d || []); @@ -112145,18 +113357,20 @@ axes.getSubplots = function(gd, ax) { }; // find all subplots with axis 'ax' +// NOTE: this is only used in axes.getSubplots (only used outside plotly.js) and +// gl2d/convert (where it restricts axis subplots to only those with gl2d) axes.findSubplotsWithAxis = function(subplots, ax) { var axMatch = new RegExp( (ax._id.charAt(0) === 'x') ? ('^' + ax._id + 'y') : (ax._id + '$') ); - var subplotsWithAxis = []; + var subplotsWithAx = []; for(var i = 0; i < subplots.length; i++) { var sp = subplots[i]; - if(axMatch.test(sp)) subplotsWithAxis.push(sp); + if(axMatch.test(sp)) subplotsWithAx.push(sp); } - return subplotsWithAxis; + return subplotsWithAx; }; // makeClipPaths: prepare clipPaths for all single axes and all possible xy pairings @@ -112209,24 +113423,25 @@ axes.makeClipPaths = function(gd) { * * @param {DOM element} gd : graph div * @param {string or array of strings} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update + * @param {object} opts: + * - @param {boolean} skipTitle : optional flag to skip axis title draw/update * - * Signature 1: Axes.doTicks(gd, 'redraw') + * Signature 1: Axes.draw(gd, 'redraw') * use this to clear and redraw all axes on graph * - * Signature 2: Axes.doTicks(gd, '') + * Signature 2: Axes.draw(gd, '') * use this to draw all axes on graph w/o the selectAll().remove() * of the 'redraw' signature * - * Signature 3: Axes.doTicks(gd, [axId, axId2, ...]) + * Signature 3: Axes.draw(gd, [axId, axId2, ...]) * where the items are axis id string, * use this to update multiple axes in one call * - * N.B doTicks updates: + * N.B draw updates: * - ax._r (stored range for use by zoom/pan) * - ax._rl (stored linearized range for use by zoom/pan) */ -axes.doTicks = function(gd, arg, skipTitle) { +axes.draw = function(gd, arg, opts) { var fullLayout = gd._fullLayout; if(arg === 'redraw') { @@ -112238,6 +113453,8 @@ axes.doTicks = function(gd, arg, skipTitle) { plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove(); plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove(); + plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove(); if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove(); if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove(); fullLayout._infolayer.select('.g-' + xa._id + 'title').remove(); @@ -112247,13 +113464,13 @@ axes.doTicks = function(gd, arg, skipTitle) { var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg; - Lib.syncOrAsync(axList.map(function(axid) { + return Lib.syncOrAsync(axList.map(function(axId) { return function() { - if(!axid) return; + if(!axId) return; - var axDone = axes.doTicksSingle(gd, axid, skipTitle); + var ax = axes.getFromId(gd, axId); + var axDone = axes.drawOne(gd, ax, opts); - var ax = axes.getFromId(gd, axid); ax._r = ax.range.slice(); ax._rl = Lib.simpleMap(ax._r, ax.r2l); @@ -112263,692 +113480,1077 @@ axes.doTicks = function(gd, arg, skipTitle) { }; /** - * Per-axis drawing routine! + * Draw one cartesian axis * - * This routine draws axis ticks and much more (... grids, labels, title etc.) - * Supports multiple argument signatures. - * N.B. this thing is async in general (because of MathJax rendering) - * - * @param {DOM element} gd : graph div - * @param {string or object} arg : polymorphic argument - * @param {boolean} skipTitle : optional flag to skip axis title draw/update - * @return {promise} - * - * Signature 1: Axes.doTicks(gd, ax) - * where ax is an axis object as in fullLayout - * - * Signature 2: Axes.doTicks(gd, axId) - * where axId is a axis id string + * @param {DOM element} gd + * @param {object} ax (full) axis object + * @param {object} opts + * - @param {boolean} skipTitle (set to true to skip axis title draw call) */ -axes.doTicksSingle = function(gd, arg, skipTitle) { - var fullLayout = gd._fullLayout; - var independent = false; - var ax; +axes.drawOne = function(gd, ax, opts) { + opts = opts || {}; - if(Lib.isPlainObject(arg)) { - ax = arg; - independent = true; - } else { - ax = axes.getFromId(gd, arg); - } + var i, sp, plotinfo; - // set scaling to pixels ax.setScale(); - var axid = ax._id; - var axLetter = axid.charAt(0); - var counterLetter = axes.counterLetter(axid); + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var counterLetter = axes.counterLetter(axId); + var mainSubplot = ax._mainSubplot; + var mainLinePosition = ax._mainLinePosition; + var mainMirrorPosition = ax._mainMirrorPosition; + var mainPlotinfo = fullLayout._plots[mainSubplot]; + var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; + var subplotsWithAx = ax._subplotsWith; + var vals = ax._vals = axes.calcTicks(ax); - var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; - var tcls = axid + 'tick'; - var gcls = axid + 'grid'; - var zcls = axid + 'zl'; - var pad = (ax.linewidth || 1) / 2; - var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); - var labelShift = 0; - var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); - var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); - var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); - var sides, transfn, tickpathfn, subplots; - var tickLabels; - var i; - if(ax._counterangle && ax.ticks === 'outside') { - var caRad = ax._counterangle * Math.PI / 180; - labelStandoff = ax.ticklen * Math.cos(caRad) + 1; - labelShift = ax.ticklen * Math.sin(caRad); + // Add a couple of axis properties that should cause us to recreate + // elements. Used in d3 data function. + var axInfo = [ax.mirror, mainLinePosition, mainMirrorPosition].join('_'); + for(i = 0; i < vals.length; i++) { + vals[i].axInfo = axInfo; } - if(ax.showticklabels && (ax.ticks === 'outside' || ax.showline)) { - labelStandoff += 0.2 * ax.tickfont.size; - } + if(!ax.visible) return; - // positioning arguments for x vs y axes - if(axLetter === 'x') { - sides = ['bottom', 'top']; - transfn = ax._transfn || function(d) { - return 'translate(' + (ax._offset + ax.l2p(d.x)) + ',0)'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M0,' + shift + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len); - } - else return 'M0,' + shift + 'v' + len; - }; - } - else if(axLetter === 'y') { - sides = ['left', 'right']; - transfn = ax._transfn || function(d) { - return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')'; - }; - tickpathfn = function(shift, len) { - if(ax._counterangle) { - var caRad = ax._counterangle * Math.PI / 180; - return 'M' + shift + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); - } - else return 'M' + shift + ',0h' + len; - }; - } - else if(isAngular(ax)) { - sides = ['left', 'right']; - transfn = ax._transfn; - tickpathfn = function(shift, len) { - return 'M' + shift + ',0h' + len; - }; - } - else { - Lib.warn('Unrecognized doTicks axis:', axid); - return; + // stash selections to avoid DOM queries e.g. + // - stash tickLabels selection, so that drawTitle can use it to scoot title + ax._selections = {}; + // stash tick angle (including the computed 'auto' values) per tick-label class + ax._tickAngles = {}; + + var transFn = axes.makeTransFn(ax); + var tickVals; + // We remove zero lines, grid lines, and inside ticks if they're within 1px of the end + // The key case here is removing zero lines when the axis bound is zero + var valsClipped; + + if(ax.tickson === 'boundaries') { + var boundaryVals = getBoundaryVals(ax, vals); + valsClipped = axes.clipEnds(ax, boundaryVals); + tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals; + } else { + valsClipped = axes.clipEnds(ax, vals); + tickVals = ax.ticks === 'inside' ? valsClipped : vals; } - var axside = ax.side || sides[0]; - // which direction do the side[0], side[1], and free ticks go? - // then we flip if outside XOR y axis - var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; - if((ax.ticks !== 'inside') === (axLetter === 'x')) { - ticksign = ticksign.map(function(v) { return -v; }); - } + var gridVals = ax._gridVals = valsClipped; + var dividerVals = getDividerVals(ax, vals); - if(!ax.visible) return; + if(!fullLayout._hasOnlyLargeSploms) { + // keep track of which subplots (by main conteraxis) we've already + // drawn grids for, so we don't overdraw overlaying subplots + var finishedGrids = {}; - if(ax._tickFilter) { - vals = vals.filter(ax._tickFilter); - } + for(i = 0; i < subplotsWithAx.length; i++) { + sp = subplotsWithAx[i]; + plotinfo = fullLayout._plots[sp]; - // Remove zero lines, grid lines, and inside ticks if they're within - // 1 pixel of the end. - // The key case here is removing zero lines when the axis bound is zero. - // Don't clip angular values. - var valsClipped = ax._valsClipped = isAngular(ax) ? - vals : - vals.filter(function(d) { return clipEnds(ax, d.x); }); + var counterAxis = plotinfo[counterLetter + 'axis']; + var mainCounterID = counterAxis._mainAxis._id; + if(finishedGrids[mainCounterID]) continue; + finishedGrids[mainCounterID] = 1; - function drawTicks(container, tickpath) { - var ticks = container.selectAll('path.' + tcls) - .data(ax.ticks === 'inside' ? valsClipped : vals, datafn); + var gridPath = axLetter === 'x' ? + 'M0,' + counterAxis._offset + 'v' + counterAxis._length : + 'M' + counterAxis._offset + ',0h' + counterAxis._length; - if(tickpath && ax.ticks) { - ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) - .classed('crisp', 1) - .call(Color.stroke, ax.tickcolor) - .style('stroke-width', tickWidth + 'px') - .attr('d', tickpath); - ticks.attr('transform', transfn); - ticks.exit().remove(); + axes.drawGrid(gd, ax, { + vals: gridVals, + counterAxis: counterAxis, + layer: plotinfo.gridlayer.select('.' + axId), + path: gridPath, + transFn: transFn + }); + axes.drawZeroLine(gd, ax, { + counterAxis: counterAxis, + layer: plotinfo.zerolinelayer, + path: gridPath, + transFn: transFn + }); } - else ticks.remove(); } - function drawLabels(container, position) { - // tick labels - for now just the main labels. - // TODO: mirror labels, esp for subplots - tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); + var tickSigns = axes.getTickSigns(ax); + var tickSubplots = []; - if(!isNumeric(position)) { - tickLabels.remove(); - drawAxTitle(); - return; - } - if(!ax.showticklabels) { - tickLabels.remove(); - drawAxTitle(); - calcBoundingBox(); - return; + if(ax.ticks) { + var mainTickPath = axes.makeTickPath(ax, mainLinePosition, tickSigns[2]); + var mirrorTickPath; + var fullTickPath; + if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { + mirrorTickPath = axes.makeTickPath(ax, mainMirrorPosition, tickSigns[3]); + fullTickPath = mainTickPath + mirrorTickPath; + } else { + mirrorTickPath = ''; + fullTickPath = mainTickPath; } - var labelx, labely, labelanchor, labelpos0, flipit; - if(axLetter === 'x') { - flipit = (axside === 'bottom') ? 1 : -1; - labelx = function(d) { return d.dx + labelShift * flipit; }; - labelpos0 = position + (labelStandoff + pad) * flipit; - labely = function(d) { - return d.dy + labelpos0 + d.fontSize * - ((axside === 'bottom') ? 1 : -0.2); - }; - labelanchor = function(angle) { - if(!isNumeric(angle) || angle === 0 || angle === 180) { - return 'middle'; - } - return (angle * flipit < 0) ? 'end' : 'start'; - }; - } - else if(axLetter === 'y') { - flipit = (axside === 'right') ? 1 : -1; - labely = function(d) { - return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit; - }; - labelx = function(d) { - return d.dx + position + (labelStandoff + pad + - ((Math.abs(ax.tickangle) === 90) ? d.fontSize / 2 : 0)) * flipit; - }; - labelanchor = function(angle) { - if(isNumeric(angle) && Math.abs(angle) === 90) { - return 'middle'; - } - return axside === 'right' ? 'start' : 'end'; + var tickPath; + if(ax.showdividers && ax.ticks === 'outside' && ax.tickson === 'boundaries') { + var dividerLookup = {}; + for(i = 0; i < dividerVals.length; i++) { + dividerLookup[dividerVals[i].x] = 1; + } + tickPath = function(d) { + return dividerLookup[d.x] ? mirrorTickPath : fullTickPath; }; + } else { + tickPath = fullTickPath; } - else if(isAngular(ax)) { - ax._labelShift = labelShift; - ax._labelStandoff = labelStandoff; - ax._pad = pad; - - labelx = ax._labelx; - labely = ax._labely; - labelanchor = ax._labelanchor; - } - - var maxFontSize = 0, - autoangle = 0, - labelsReady = []; - tickLabels.enter().append('g').classed(tcls, 1) - .append('text') - // only so tex has predictable alignment that we can - // alter later - .attr('text-anchor', 'middle') - .each(function(d) { - var thisLabel = d3.select(this), - newPromise = gd._promises.length; - thisLabel - .call(svgTextUtils.positionText, labelx(d), labely(d)) - .call(Drawing.font, d.font, d.fontSize, d.fontColor) - .text(d.text) - .call(svgTextUtils.convertToTspans, gd); - newPromise = gd._promises[newPromise]; - if(newPromise) { - // if we have an async label, we'll deal with that - // all here so take it out of gd._promises and - // instead position the label and promise this in - // labelsReady - labelsReady.push(gd._promises.pop().then(function() { - positionLabels(thisLabel, ax.tickangle); - })); - } - else { - // sync label: just position it now. - positionLabels(thisLabel, ax.tickangle); - } - }); - tickLabels.exit().remove(); - tickLabels.each(function(d) { - maxFontSize = Math.max(maxFontSize, d.fontSize); + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: mainAxLayer, + path: tickPath, + transFn: transFn }); - if(isAngular(ax)) { - tickLabels.each(function(d) { - d3.select(this).select('text') - .call(svgTextUtils.positionText, labelx(d), labely(d)); + tickSubplots = Object.keys(ax._linepositions || {}); + } + + for(i = 0; i < tickSubplots.length; i++) { + sp = tickSubplots[i]; + plotinfo = fullLayout._plots[sp]; + // [bottom or left, top or right], free and main are handled above + var linepositions = ax._linepositions[sp] || []; + var spTickPath = axes.makeTickPath(ax, linepositions[0], tickSigns[0]) + + axes.makeTickPath(ax, linepositions[1], tickSigns[1]); + + axes.drawTicks(gd, ax, { + vals: tickVals, + layer: plotinfo[axLetter + 'axislayer'], + path: spTickPath, + transFn: transFn + }); + } + + var seq = []; + + // tick labels - for now just the main labels. + // TODO: mirror labels, esp for subplots + + seq.push(function() { + var labelFns = axes.makeLabelFns(ax, mainLinePosition); + return axes.drawLabels(gd, ax, { + vals: vals, + layer: mainAxLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn, + }); + }); + + if(ax.type === 'multicategory') { + var labelLength = 0; + var pad = {x: 2, y: 10}[axLetter]; + var sgn = tickSigns[2] * (ax.ticks === 'inside' ? -1 : 1); + + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick') + pad; + labelLength += ax._tickAngles[axId + 'tick'] ? ax.tickfont.size * LINE_SPACING : 0; + var secondaryPosition = mainLinePosition + labelLength * sgn; + var secondaryLabelFns = axes.makeLabelFns(ax, secondaryPosition); + + return axes.drawLabels(gd, ax, { + vals: getSecondaryLabelVals(ax, vals), + layer: mainAxLayer, + cls: axId + 'tick2', + repositionOnUpdate: true, + secondary: true, + transFn: transFn, + labelXFn: secondaryLabelFns.labelXFn, + labelYFn: secondaryLabelFns.labelYFn, + labelAnchorFn: secondaryLabelFns.labelAnchorFn, }); - } + }); - // How much to shift a multi-line label to center it vertically. - function getAnchorHeight(lineCount, lineHeight, angle) { - var h = (lineCount - 1) * lineHeight; - if(axLetter === 'x') { - if(angle < -60 || 60 < angle) { - return -0.5 * h; - } else if(axside === 'top') { - return -h; - } - } else { - angle *= axside === 'left' ? 1 : -1; - if(angle < -30) { - return -h; - } else if(angle < 30) { - return -0.5 * h; - } - } - return 0; - } - - function positionLabels(s, angle) { - s.each(function(d) { - var anchor = labelanchor(angle, d); - var thisLabel = d3.select(this), - mathjaxGroup = thisLabel.select('.text-math-group'), - transform = transfn.call(thisLabel.node(), d) + - ((isNumeric(angle) && +angle !== 0) ? - (' rotate(' + angle + ',' + labelx(d) + ',' + - (labely(d) - d.fontSize / 2) + ')') : - ''); - var anchorHeight = getAnchorHeight( - svgTextUtils.lineCount(thisLabel), - LINE_SPACING * d.fontSize, - isNumeric(angle) ? +angle : 0); - if(anchorHeight) { - transform += ' translate(0, ' + anchorHeight + ')'; - } - if(mathjaxGroup.empty()) { - thisLabel.select('text').attr({ - transform: transform, - 'text-anchor': anchor - }); - } - else { - var mjShift = - Drawing.bBox(mathjaxGroup.node()).width * - {end: -0.5, start: 0.5}[anchor]; - mathjaxGroup.attr('transform', transform + - (mjShift ? 'translate(' + mjShift + ',0)' : '')); - } + seq.push(function() { + labelLength += getLabelLevelSpan(ax, axId + 'tick2'); + ax._labelLength = labelLength; + + return drawDividers(gd, ax, { + vals: dividerVals, + layer: mainAxLayer, + path: axes.makeTickPath(ax, mainLinePosition, sgn, labelLength), + transFn: transFn }); - } + }); + } - // make sure all labels are correctly positioned at their base angle - // the positionLabels call above is only for newly drawn labels. - // do this without waiting, using the last calculated angle to - // minimize flicker, then do it again when we know all labels are - // there, putting back the prescribed angle to check for overlaps. - positionLabels(tickLabels, ax._lastangle || ax.tickangle); - - function allLabelsReady() { - return labelsReady.length && Promise.all(labelsReady); - } - - function fixLabelOverlaps() { - positionLabels(tickLabels, ax.tickangle); - - // check for auto-angling if x labels overlap - // don't auto-angle at all for log axes with - // base and digit format - if(axLetter === 'x' && !isNumeric(ax.tickangle) && - (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')) { - var lbbArray = []; - tickLabels.each(function(d) { - var s = d3.select(this), - thisLabel = s.select('.text-math-group'), - x = ax.l2p(d.x); - if(thisLabel.empty()) thisLabel = s.select('text'); - - var bb = Drawing.bBox(thisLabel.node()); - - lbbArray.push({ - // ignore about y, just deal with x overlaps - top: 0, - bottom: 10, - height: 10, - left: x - bb.width / 2, - // impose a 2px gap - right: x + bb.width / 2 + 2, - width: bb.width + 2 - }); - }); - for(i = 0; i < lbbArray.length - 1; i++) { - if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { - // any overlap at all - set 30 degrees - autoangle = 30; - break; - } - } - if(autoangle) { - var tickspacing = Math.abs( - (vals[vals.length - 1].x - vals[0].x) * ax._m - ) / (vals.length - 1); - if(tickspacing < maxFontSize * 2.5) { - autoangle = 90; - } - positionLabels(tickLabels, autoangle); - } - ax._lastangle = autoangle; - } + function extendRange(range, newRange) { + range[0] = Math.min(range[0], newRange[0]); + range[1] = Math.max(range[1], newRange[1]); + } - // update the axis title - // (so it can move out of the way if needed) - // TODO: separate out scoot so we don't need to do - // a full redraw of the title (mostly relevant for MathJax) - drawAxTitle(); - return axid + ' done'; - } + function calcBoundingBox() { + if(ax.showticklabels) { + var gdBB = gd.getBoundingClientRect(); + var bBox = mainAxLayer.node().getBoundingClientRect(); - function calcBoundingBox() { - if(ax.showticklabels) { - var gdBB = gd.getBoundingClientRect(); - var bBox = container.node().getBoundingClientRect(); + /* + * the way we're going to use this, the positioning that matters + * is relative to the origin of gd. This is important particularly + * if gd is scrollable, and may have been scrolled between the time + * we calculate this and the time we use it + */ - /* - * the way we're going to use this, the positioning that matters - * is relative to the origin of gd. This is important particularly - * if gd is scrollable, and may have been scrolled between the time - * we calculate this and the time we use it - */ + ax._boundingBox = { + width: bBox.width, + height: bBox.height, + left: bBox.left - gdBB.left, + right: bBox.right - gdBB.left, + top: bBox.top - gdBB.top, + bottom: bBox.bottom - gdBB.top + }; + } else { + var gs = fullLayout._size; + var pos; + + // set dummy bbox for ticklabel-less axes + + if(axLetter === 'x') { + pos = ax.anchor === 'free' ? + gs.t + gs.h * (1 - ax.position) : + gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); ax._boundingBox = { - width: bBox.width, - height: bBox.height, - left: bBox.left - gdBB.left, - right: bBox.right - gdBB.left, - top: bBox.top - gdBB.top, - bottom: bBox.bottom - gdBB.top + top: pos, + bottom: pos, + left: ax._offset, + right: ax._offset + ax._length, + width: ax._length, + height: 0 }; } else { - var gs = fullLayout._size; - var pos; - - // set dummy bbox for ticklabel-less axes + pos = ax.anchor === 'free' ? + gs.l + gs.w * ax.position : + gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - if(axLetter === 'x') { - pos = ax.anchor === 'free' ? - gs.t + gs.h * (1 - ax.position) : - gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]); - - ax._boundingBox = { - top: pos, - bottom: pos, - left: ax._offset, - right: ax._offset + ax._length, - width: ax._length, - height: 0 - }; - } else { - pos = ax.anchor === 'free' ? - gs.l + gs.w * ax.position : - gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]]; - - ax._boundingBox = { - left: pos, - right: pos, - bottom: ax._offset + ax._length, - top: ax._offset, - height: ax._length, - width: 0 - }; - } + ax._boundingBox = { + left: pos, + right: pos, + bottom: ax._offset + ax._length, + top: ax._offset, + height: ax._length, + width: 0 + }; } + } - /* - * for spikelines: what's the full domain of positions in the - * opposite direction that are associated with this axis? - * This means any axes that we make a subplot with, plus the - * position of the axis itself if it's free. - */ - if(subplots) { - var fullRange = ax._counterSpan = [Infinity, -Infinity]; - - for(i = 0; i < subplots.length; i++) { - var subplot = fullLayout._plots[subplots[i]]; - var counterAxis = subplot[(axLetter === 'x') ? 'yaxis' : 'xaxis']; + /* + * for spikelines: what's the full domain of positions in the + * opposite direction that are associated with this axis? + * This means any axes that we make a subplot with, plus the + * position of the axis itself if it's free. + */ + if(subplotsWithAx) { + var fullRange = ax._counterSpan = [Infinity, -Infinity]; - extendRange(fullRange, [ - counterAxis._offset, - counterAxis._offset + counterAxis._length - ]); - } + for(var i = 0; i < subplotsWithAx.length; i++) { + var plotinfo = fullLayout._plots[subplotsWithAx[i]]; + var counterAxis = plotinfo[(axLetter === 'x') ? 'yaxis' : 'xaxis']; - if(ax.anchor === 'free') { - extendRange(fullRange, (axLetter === 'x') ? - [ax._boundingBox.bottom, ax._boundingBox.top] : - [ax._boundingBox.right, ax._boundingBox.left]); - } + extendRange(fullRange, [ + counterAxis._offset, + counterAxis._offset + counterAxis._length + ]); } - function extendRange(range, newRange) { - range[0] = Math.min(range[0], newRange[0]); - range[1] = Math.max(range[1], newRange[1]); + if(ax.anchor === 'free') { + extendRange(fullRange, (axLetter === 'x') ? + [ax._boundingBox.bottom, ax._boundingBox.top] : + [ax._boundingBox.right, ax._boundingBox.left]); } } + } - function doAutoMargins() { - var pushKey = ax._name + '.automargin'; - if(axLetter !== 'x' && axLetter !== 'y') { return; } - if(!ax.automargin) { - Plots.autoMargin(gd, pushKey); - return; - } + var hasRangeSlider = Registry.getComponentMethod('rangeslider', 'isVisible')(ax); - var s = ax.side[0]; - var push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; + function doAutoMargins() { + var push, rangeSliderPush; + + if(hasRangeSlider) { + rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); + } + Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); + + var s = ax.side.charAt(0); + if(ax.automargin && (!hasRangeSlider || s !== 'b')) { + push = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; if(axLetter === 'x') { push.y = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 't' ? 1 : 0]); + ax._anchorAxis.domain[s === 't' ? 1 : 0]); push[s] += ax._boundingBox.height; - } - else { + } else { push.x = (ax.anchor === 'free' ? ax.position : - ax._anchorAxis.domain[s === 'r' ? 1 : 0]); + ax._anchorAxis.domain[s === 'r' ? 1 : 0]); push[s] += ax._boundingBox.width; } - if(ax.title !== fullLayout._dfltTitle[axLetter]) { - push[s] += ax.titlefont.size; + if(ax.title.text !== fullLayout._dfltTitle[axLetter]) { + push[s] += ax.title.font.size; } - - Plots.autoMargin(gd, pushKey, push); } - var done = Lib.syncOrAsync([ - allLabelsReady, - fixLabelOverlaps, - calcBoundingBox, - doAutoMargins - ]); - if(done && done.then) gd._promises.push(done); - return done; + Plots.autoMargin(gd, axAutoMarginID(ax), push); } - function drawAxTitle() { - if(skipTitle) return; + seq.push(calcBoundingBox, doAutoMargins); - // now this only applies to regular cartesian axes; colorbars and - // others ALWAYS call doTicks with skipTitle=true so they can - // configure their own titles. + if(!opts.skipTitle && + !(hasRangeSlider && ax._boundingBox && ax.side === 'bottom') + ) { + seq.push(function() { return drawTitle(gd, ax); }); + } - // rangeslider takes over a bottom title so drop it here - if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; + return Lib.syncOrAsync(seq); +}; - var avoid = { - selection: tickLabels, - side: ax.side - }; - var axLetter = axid.charAt(0); - var gs = gd._fullLayout._size; - var offsetBase = 1.5; - var fontSize = ax.titlefont.size; +function getBoundaryVals(ax, vals) { + var out = []; + var i; - var transform, counterAxis, x, y; + // boundaryVals are never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); + } + }; - if(tickLabels.size()) { - var translation = Drawing.getTranslate(tickLabels.node().parentNode); - avoid.offsetLeft = translation.x; - avoid.offsetTop = translation.y; + if(vals.length) { + for(i = 0; i < vals.length; i++) { + _push(vals[i], 0); } + _push(vals[i - 1], 1); + } - var titleStandoff = 10 + fontSize * offsetBase + - (ax.linewidth ? ax.linewidth - 1 : 0); + return out; +} - if(axLetter === 'x') { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : - axisIds.getFromId(gd, ax.anchor); +function getSecondaryLabelVals(ax, vals) { + var out = []; + var lookup = {}; - x = ax._offset + ax._length / 2; + for(var i = 0; i < vals.length; i++) { + var d = vals[i]; + if(lookup[d.text2]) { + lookup[d.text2].push(d.x); + } else { + lookup[d.text2] = [d.x]; + } + } - if(ax.side === 'top') { - y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); - } - else { - y = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1.5 : 0.5); - } - y += counterAxis._offset; + for(var k in lookup) { + out.push(tickTextObj(ax, Lib.interp(lookup[k], 0.5), k)); + } + + return out; +} + +function getDividerVals(ax, vals) { + var out = []; + var i, current; - if(!avoid.side) avoid.side = 'bottom'; + // never used for labels; + // no need to worry about the other tickTextObj keys + var _push = function(d, bndIndex) { + var xb = d.xbnd[bndIndex]; + if(xb !== null) { + out.push(Lib.extendFlat({}, d, {x: xb})); } - else { - counterAxis = (ax.anchor === 'free') ? - {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : - axisIds.getFromId(gd, ax.anchor); + }; - y = ax._offset + ax._length / 2; - if(ax.side === 'right') { - x = counterAxis._length + titleStandoff + - fontSize * (ax.showticklabels ? 1 : 0.5); - } - else { - x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + if(ax.showdividers && vals.length) { + for(i = 0; i < vals.length; i++) { + var d = vals[i]; + if(d.text2 !== current) { + _push(d, 0); } - x += counterAxis._offset; + current = d.text2; + } + _push(vals[i - 1], 1); + } + + return out; +} + +function getLabelLevelSpan(ax, cls) { + var axLetter = ax._id.charAt(0); + var angle = ax._tickAngles[cls] || 0; + var rad = Lib.deg2rad(angle); + var sinA = Math.sin(rad); + var cosA = Math.cos(rad); + var maxX = 0; + var maxY = 0; + + // N.B. Drawing.bBox does not take into account rotate transforms + + ax._selections[cls].each(function() { + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + var w = bb.width; + var h = bb.height; + maxX = Math.max(maxX, cosA * w, sinA * h); + maxY = Math.max(maxY, sinA * w, cosA * h); + }); + + return {x: maxY, y: maxX}[axLetter]; +} + +/** + * Which direction do the 'ax.side' values, and free ticks go? + * + * @param {object} ax (full) axis object + * - {string} _id (starting with 'x' or 'y') + * - {string} side + * - {string} ticks + * @return {array} all entries are either -1 or 1 + * - [0]: sign for top/right ticks (i.e. negative SVG direction) + * - [1]: sign for bottom/left ticks (i.e. positive SVG direction) + * - [2]: sign for ticks corresponding to 'ax.side' + * - [3]: sign for ticks mirroring 'ax.side' + */ +axes.getTickSigns = function(ax) { + var axLetter = ax._id.charAt(0); + var sideOpposite = {x: 'top', y: 'right'}[axLetter]; + var main = ax.side === sideOpposite ? 1 : -1; + var out = [-1, 1, main, -main]; + // then we flip if outside XOR y axis + if((ax.ticks !== 'inside') === (axLetter === 'x')) { + out = out.map(function(v) { return -v; }); + } + return out; +}; + +/** + * Make axis translate transform function + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} _offset + * - {fn} l2p + * @return {fn} function of calcTicks items + */ +axes.makeTransFn = function(ax) { + var axLetter = ax._id.charAt(0); + var offset = ax._offset; + return axLetter === 'x' ? + function(d) { return 'translate(' + (offset + ax.l2p(d.x)) + ',0)'; } : + function(d) { return 'translate(0,' + (offset + ax.l2p(d.x)) + ')'; }; +}; + +/** + * Make axis tick path string + * + * @param {object} ax (full) axis object + * - {string} _id + * - {number} ticklen + * - {number} linewidth + * @param {number} shift along direction of ticklen + * @param {1 or -1} sng tick sign + * @param {number (optional)} len tick length + * @return {string} + */ +axes.makeTickPath = function(ax, shift, sgn, len) { + len = len !== undefined ? len : ax.ticklen; + + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + + return axLetter === 'x' ? + 'M0,' + (shift + pad * sgn) + 'v' + (len * sgn) : + 'M' + (shift + pad * sgn) + ',0h' + (len * sgn); +}; + +/** + * Make axis tick label x, y and anchor functions + * + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} ticklen + * - {string} side + * - {number} linewidth + * - {number} tickfont.size + * - {boolean} showline + * @param {number} shift + * @param {number} angle [in degrees] ... + * @return {object} + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + * - {number} labelStandoff + * - {number} labelShift + */ +axes.makeLabelFns = function(ax, shift, angle) { + var axLetter = ax._id.charAt(0); + var pad = (ax.linewidth || 1) / 2; + var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside'; - transform = {rotate: '-90', offset: 0}; - if(!avoid.side) avoid.side = 'left'; + var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0; + var labelShift = 0; + + if(angle && ax.ticks === 'outside') { + var rad = Lib.deg2rad(angle); + labelStandoff = ax.ticklen * Math.cos(rad) + 1; + labelShift = ax.ticklen * Math.sin(rad); + } + + if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) { + labelStandoff += 0.2 * ax.tickfont.size; + } + + // Used in polar angular label x/y functions + // TODO generalize makeLabelFns so that it just work for angular axes + var out = { + labelStandoff: labelStandoff, + labelShift: labelShift + }; + + var x0, y0, ff, flipIt; + if(axLetter === 'x') { + flipIt = ax.side === 'bottom' ? 1 : -1; + x0 = labelShift * flipIt; + y0 = shift + (labelStandoff + pad) * flipIt; + ff = ax.side === 'bottom' ? 1 : -0.2; + + out.labelXFn = function(d) { return d.dx + x0; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * ff; }; + out.labelAnchorFn = function(a) { + if(!isNumeric(a) || a === 0 || a === 180) { + return 'middle'; + } + return (a * flipIt < 0) ? 'end' : 'start'; + }; + } else if(axLetter === 'y') { + flipIt = ax.side === 'right' ? 1 : -1; + x0 = labelStandoff + pad; + y0 = -labelShift * flipIt; + ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0; + + out.labelXFn = function(d) { return d.dx + shift + (x0 + d.fontSize * ff) * flipIt; }; + out.labelYFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; }; + out.labelAnchorFn = function(a) { + if(isNumeric(a) && Math.abs(a) === 90) { + return 'middle'; + } + return ax.side === 'right' ? 'start' : 'end'; + }; + } + + return out; +}; + +function tickDataFn(d) { + return [d.text, d.x, d.axInfo, d.font, d.fontSize, d.fontColor].join('_'); +} + +/** + * Draw axis ticks + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} ticks + * - {number} linewidth + * - {string} tickcolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawTicks = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'tick'; + + var ticks = opts.layer.selectAll('path.' + cls) + .data(ax.ticks ? opts.vals : [], tickDataFn); + + ticks.exit().remove(); + + ticks.enter().append('path') + .classed(cls, 1) + .classed('ticks', 1) + .classed('crisp', opts.crisp !== false) + .call(Color.stroke, ax.tickcolor) + .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') + .attr('d', opts.path); + + ticks.attr('transform', opts.transFn); +}; + +/** + * Draw axis grid + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showgrid + * - {string} gridcolor + * - {string} gridwidth + * - {boolean} zeroline + * - {string} type + * - {string} dtick + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * optional - only required if this axis supports zero lines + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawGrid = function(gd, ax, opts) { + opts = opts || {}; + + var cls = ax._id + 'grid'; + var vals = opts.vals; + var counterAx = opts.counterAxis; + if(ax.showgrid === false) { + vals = []; + } + else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + var isArrayMode = ax.tickmode === 'array'; + for(var i = 0; i < vals.length; i++) { + var xi = vals[i].x; + if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) { + vals = vals.slice(0, i).concat(vals.slice(i + 1)); + // In array mode you can in principle have multiple + // ticks at 0, so test them all. Otherwise once we found + // one we can stop. + if(isArrayMode) i--; + else break; + } } + } + + var grid = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + grid.exit().remove(); + + grid.enter().append('path') + .classed(cls, 1) + .classed('crisp', opts.crisp !== false); + + ax._gw = Drawing.crispRound(gd, ax.gridwidth, 1); + + grid.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.gridcolor || '#ddd') + .style('stroke-width', ax._gw + 'px'); + + if(typeof opts.path === 'function') grid.attr('d', opts.path); +}; + +/** + * Draw axis zero-line + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} zeroline + * - {number} zerolinewidth + * - {string} zerolinecolor + * - {number (optional)} _gridWidthCrispRound + * @param {object} opts + * - {d3 selection} layer + * - {object} counterAxis (full axis object corresponding to counter axis) + * - {string or fn} path + * - {fn} transFn + * - {boolean} crisp (set to false to unset crisp-edge SVG rendering) + */ +axes.drawZeroLine = function(gd, ax, opts) { + opts = opts || opts; + + var cls = ax._id + 'zl'; + var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis); - Titles.draw(gd, axid + 'title', { - propContainer: ax, - propName: ax._name + '.title', - placeholder: fullLayout._dfltTitle[axLetter], - avoid: avoid, - transform: transform, - attributes: {x: x, y: y, 'text-anchor': 'middle'} + var zl = opts.layer.selectAll('path.' + cls) + .data(show ? [{x: 0, id: ax._id}] : []); + + zl.exit().remove(); + + zl.enter().append('path') + .classed(cls, 1) + .classed('zl', 1) + .classed('crisp', opts.crisp !== false) + .each(function() { + // use the fact that only one element can enter to trigger a sort. + // If several zerolines enter at the same time we will sort once per, + // but generally this should be a minimal overhead. + opts.layer.selectAll('path').sort(function(da, db) { + return axisIds.idSort(da.id, db.id); + }); }); - } - function drawGrid(plotinfo, counteraxis) { - if(fullLayout._hasOnlyLargeSploms) return; - - var gridcontainer = plotinfo.gridlayer.selectAll('.' + axid); - var zlcontainer = plotinfo.zerolinelayer; - var gridpath = ax._gridpath || ((axLetter === 'x' ? - ('M0,' + counteraxis._offset + 'v') : - ('M' + counteraxis._offset + ',0h') - ) + counteraxis._length); - var grid = gridcontainer.selectAll('path.' + gcls) - .data((ax.showgrid === false) ? [] : valsClipped, datafn); - grid.enter().append('path').classed(gcls, 1) - .classed('crisp', 1) - .attr('d', gridpath) + zl.attr('transform', opts.transFn) + .attr('d', opts.path) + .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); +}; + +/** + * Draw axis tick labels + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {boolean} showticklabels + * - {number} tickangle + * - {object (optional)} _selections + * - {object} (optional)} _tickAngles + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {string (optional)} cls (node className) + * - {boolean} repositionOnUpdate (set to true to reposition update selection) + * - {boolean} secondary + * - {fn} transFn + * - {fn} labelXFn + * - {fn} labelYFn + * - {fn} labelAnchorFn + */ +axes.drawLabels = function(gd, ax, opts) { + opts = opts || {}; + + var axId = ax._id; + var axLetter = axId.charAt(0); + var cls = opts.cls || axId + 'tick'; + var vals = opts.vals; + var labelXFn = opts.labelXFn; + var labelYFn = opts.labelYFn; + var labelAnchorFn = opts.labelAnchorFn; + var tickAngle = opts.secondary ? 0 : ax.tickangle; + var lastAngle = (ax._tickAngles || {})[cls]; + + var tickLabels = opts.layer.selectAll('g.' + cls) + .data(ax.showticklabels ? vals : [], tickDataFn); + + var labelsReady = []; + + tickLabels.enter().append('g') + .classed(cls, 1) + .append('text') + // only so tex has predictable alignment that we can + // alter later + .attr('text-anchor', 'middle') .each(function(d) { - if(ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - Math.abs(d.x) < ax.dtick / 100) { - d3.select(this).remove(); + var thisLabel = d3.select(this); + var newPromise = gd._promises.length; + + thisLabel + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)) + .call(Drawing.font, d.font, d.fontSize, d.fontColor) + .text(d.text) + .call(svgTextUtils.convertToTspans, gd); + + if(gd._promises[newPromise]) { + // if we have an async label, we'll deal with that + // all here so take it out of gd._promises and + // instead position the label and promise this in + // labelsReady + labelsReady.push(gd._promises.pop().then(function() { + positionLabels(thisLabel, tickAngle); + })); + } else { + // sync label: just position it now. + positionLabels(thisLabel, tickAngle); } }); - grid.attr('transform', transfn) - .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', gridWidth + 'px'); - if(typeof gridpath === 'function') grid.attr('d', gridpath); - grid.exit().remove(); - - // zero line - if(zlcontainer) { - var zlData = {x: 0, id: axid}; - var showZl = axes.shouldShowZeroLine(gd, ax, counteraxis); - var zl = zlcontainer.selectAll('path.' + zcls) - .data(showZl ? [zlData] : []); - zl.enter().append('path').classed(zcls, 1).classed('zl', 1) - .classed('crisp', 1) - .attr('d', gridpath) - .each(function() { - // use the fact that only one element can enter to trigger a sort. - // If several zerolines enter at the same time we will sort once per, - // but generally this should be a minimal overhead. - zlcontainer.selectAll('path').sort(function(da, db) { - return axisIds.idSort(da.id, db.id); - }); - }); - zl.attr('transform', transfn) - .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', zeroLineWidth + 'px'); - zl.exit().remove(); - } + + tickLabels.exit().remove(); + + if(opts.repositionOnUpdate) { + tickLabels.each(function(d) { + d3.select(this).select('text') + .call(svgTextUtils.positionText, labelXFn(d), labelYFn(d)); + }); } - if(independent) { - drawTicks(ax._axislayer, tickpathfn(ax._pos + pad * ticksign[2], ticksign[2] * ax.ticklen)); - if(ax._counteraxis) { - var fictionalPlotinfo = { - gridlayer: ax._gridlayer, - zerolinelayer: ax._zerolinelayer - }; - drawGrid(fictionalPlotinfo, ax._counteraxis); + // How much to shift a multi-line label to center it vertically. + function getAnchorHeight(lineCount, lineHeight, angle) { + var h = (lineCount - 1) * lineHeight; + if(axLetter === 'x') { + if(angle < -60 || 60 < angle) { + return -0.5 * h; + } else if(ax.side === 'top') { + return -h; + } + } else { + angle *= ax.side === 'left' ? 1 : -1; + if(angle < -30) { + return -h; + } else if(angle < 30) { + return -0.5 * h; + } } - return drawLabels(ax._axislayer, ax._pos); + return 0; } - else if(fullLayout._has('cartesian')) { - subplots = axes.getSubplots(gd, ax); - // keep track of which subplots (by main conteraxis) we've already - // drawn grids for, so we don't overdraw overlaying subplots - var finishedGrids = {}; - - subplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; - var counterAxis = plotinfo[counterLetter + 'axis']; + function positionLabels(s, angle) { + s.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + var anchor = labelAnchorFn(angle, d); + + var transform = opts.transFn.call(thisLabel.node(), d) + + ((isNumeric(angle) && +angle !== 0) ? + (' rotate(' + angle + ',' + labelXFn(d) + ',' + + (labelYFn(d) - d.fontSize / 2) + ')') : + ''); + + var anchorHeight = getAnchorHeight( + svgTextUtils.lineCount(thisLabel), + LINE_SPACING * d.fontSize, + isNumeric(angle) ? +angle : 0 + ); - var mainCounterID = counterAxis._mainAxis._id; - if(finishedGrids[mainCounterID]) return; - finishedGrids[mainCounterID] = 1; + if(anchorHeight) { + transform += ' translate(0, ' + anchorHeight + ')'; + } - drawGrid(plotinfo, counterAxis, subplot); + if(mathjaxGroup.empty()) { + thisLabel.select('text').attr({ + transform: transform, + 'text-anchor': anchor + }); + } else { + var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; + var mjShift = mjWidth * {end: -0.5, start: 0.5}[anchor]; + mathjaxGroup.attr('transform', transform + (mjShift ? 'translate(' + mjShift + ',0)' : '')); + } }); + } - var mainSubplot = ax._mainSubplot; - var mainPlotinfo = fullLayout._plots[mainSubplot]; - var tickSubplots = []; + // make sure all labels are correctly positioned at their base angle + // the positionLabels call above is only for newly drawn labels. + // do this without waiting, using the last calculated angle to + // minimize flicker, then do it again when we know all labels are + // there, putting back the prescribed angle to check for overlaps. + positionLabels(tickLabels, lastAngle || tickAngle); - if(ax.ticks) { - var mainSign = ticksign[2]; - var tickpath = tickpathfn(ax._mainLinePosition + pad * mainSign, mainSign * ax.ticklen); - if(ax._anchorAxis && ax.mirror && ax.mirror !== true) { - tickpath += tickpathfn(ax._mainMirrorPosition - pad * mainSign, -mainSign * ax.ticklen); - } - drawTicks(mainPlotinfo[axLetter + 'axislayer'], tickpath); + function allLabelsReady() { + return labelsReady.length && Promise.all(labelsReady); + } - tickSubplots = Object.keys(ax._linepositions || {}); - } + function fixLabelOverlaps() { + positionLabels(tickLabels, tickAngle); + + var autoangle = null; + + // check for auto-angling if x labels overlap + // don't auto-angle at all for log axes with + // base and digit format + if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) && + (ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D') + ) { + autoangle = 0; + + var maxFontSize = 0; + var lbbArray = []; + var i; - tickSubplots.map(function(subplot) { - var plotinfo = fullLayout._plots[subplot]; + tickLabels.each(function(d) { + maxFontSize = Math.max(maxFontSize, d.fontSize); + + var x = ax.l2p(d.x); + var thisLabel = selectTickLabel(this); + var bb = Drawing.bBox(thisLabel.node()); + + lbbArray.push({ + // ignore about y, just deal with x overlaps + top: 0, + bottom: 10, + height: 10, + left: x - bb.width / 2, + // impose a 2px gap + right: x + bb.width / 2 + 2, + width: bb.width + 2 + }); + }); - var container = plotinfo[axLetter + 'axislayer']; + if((ax.tickson === 'boundaries' || ax.showdividers) && !opts.secondary) { + var gap = 2; + if(ax.ticks) gap += ax.tickwidth / 2; - // [bottom or left, top or right] - // free and main are handled above - var linepositions = ax._linepositions[subplot] || []; + // TODO should secondary labels also fall into this fix-overlap regime? + + for(i = 0; i < lbbArray.length; i++) { + var xbnd = vals[i].xbnd; + var lbb = lbbArray[i]; + if( + (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || + (xbnd[1] !== null && (ax.l2p(xbnd[1]) - lbb.right) < gap) + ) { + autoangle = 90; + break; + } + } + } else { + var vLen = vals.length; + var tickSpacing = Math.abs((vals[vLen - 1].x - vals[0].x) * ax._m) / (vLen - 1); + var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory'; - function tickPathSide(sidei) { - var tsign = ticksign[sidei]; - return tickpathfn(linepositions[sidei] + pad * tsign, tsign * ax.ticklen); + // any overlap at all - set 30 degrees or 90 degrees + for(i = 0; i < lbbArray.length - 1; i++) { + if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) { + autoangle = rotate90 ? 90 : 30; + break; + } + } } - drawTicks(container, tickPathSide(0) + tickPathSide(1)); - }); + if(autoangle) { + positionLabels(tickLabels, autoangle); + } + } - var mainContainer = mainPlotinfo[axLetter + 'axislayer']; + if(ax._tickAngles) { + ax._tickAngles[cls] = autoangle === null ? + (isNumeric(tickAngle) ? tickAngle : 0) : + autoangle; + } + } - return drawLabels(mainContainer, ax._mainLinePosition); + if(ax._selections) { + ax._selections[cls] = tickLabels; } + + var done = Lib.syncOrAsync([allLabelsReady, fixLabelOverlaps]); + if(done && done.then) gd._promises.push(done); + return done; }; +/** + * Draw axis dividers + * + * @param {DOM element} gd + * @param {object} ax (full) axis object + * - {string} _id + * - {string} showdividers + * - {number} dividerwidth + * - {string} dividercolor + * @param {object} opts + * - {array of object} vals (calcTicks output-like) + * - {d3 selection} layer + * - {fn} path + * - {fn} transFn + */ +function drawDividers(gd, ax, opts) { + var cls = ax._id + 'divider'; + var vals = opts.vals; + + var dividers = opts.layer.selectAll('path.' + cls) + .data(vals, tickDataFn); + + dividers.exit().remove(); + + dividers.enter().insert('path', ':first-child') + .classed(cls, 1) + .classed('crisp', 1) + .call(Color.stroke, ax.dividercolor) + .style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px'); + + dividers + .attr('transform', opts.transFn) + .attr('d', opts.path); +} + +function drawTitle(gd, ax) { + var fullLayout = gd._fullLayout; + var axId = ax._id; + var axLetter = axId.charAt(0); + var gs = fullLayout._size; + var fontSize = ax.title.font.size; + + var titleStandoff; + if(ax.type === 'multicategory') { + titleStandoff = ax._labelLength; + } else { + var offsetBase = 1.5; + titleStandoff = 10 + fontSize * offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); + } + + var transform, counterAxis, x, y; + + if(axLetter === 'x') { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.t + (1 - (ax.position || 0)) * gs.h, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + x = ax._offset + ax._length / 2; + + if(ax.side === 'top') { + y = -titleStandoff - fontSize * (ax.showticklabels ? 1 : 0); + } else { + y = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1.5 : 0.5); + } + y += counterAxis._offset; + } else { + counterAxis = (ax.anchor === 'free') ? + {_offset: gs.l + (ax.position || 0) * gs.w, _length: 0} : + axisIds.getFromId(gd, ax.anchor); + + y = ax._offset + ax._length / 2; + + if(ax.side === 'right') { + x = counterAxis._length + titleStandoff + + fontSize * (ax.showticklabels ? 1 : 0.5); + } else { + x = -titleStandoff - fontSize * (ax.showticklabels ? 0.5 : 0); + } + x += counterAxis._offset; + + transform = {rotate: '-90', offset: 0}; + } + + var avoid; + + if(ax.type !== 'multicategory') { + var tickLabels = ax._selections[ax._id + 'tick']; + + avoid = { + selection: tickLabels, + side: ax.side + }; + + if(tickLabels && tickLabels.node() && tickLabels.node().parentNode) { + var translation = Drawing.getTranslate(tickLabels.node().parentNode); + avoid.offsetLeft = translation.x; + avoid.offsetTop = translation.y; + } + } + + return Titles.draw(gd, axId + 'title', { + propContainer: ax, + propName: ax._name + '.title.text', + placeholder: fullLayout._dfltTitle[axLetter], + avoid: avoid, + transform: transform, + attributes: {x: x, y: y, 'text-anchor': 'middle'} + }); +} + axes.shouldShowZeroLine = function(gd, ax, counterAxis) { var rng = Lib.simpleMap(ax.range, ax.r2l); return ( (rng[0] * rng[1] <= 0) && ax.zeroline && (ax.type === 'linear' || ax.type === '-') && - ax._valsClipped.length && + ax._gridVals.length && ( clipEnds(ax, 0) || !anyCounterAxLineAtZero(gd, ax, counterAxis, rng) || @@ -112957,6 +114559,10 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) { ); }; +axes.clipEnds = function(ax, vals) { + return vals.filter(function(d) { return clipEnds(ax, d.x); }); +}; + function clipEnds(ax, l) { var p = ax.l2p(l); return (p > 1 && p < ax._length - 1); @@ -113032,6 +114638,12 @@ function hasBarsOrFill(gd, ax) { return false; } +function selectTickLabel(gTick) { + var s = d3.select(gTick); + var mj = s.select('.text-math-group'); + return mj.empty() ? s.select('text') : mj; +} + /** * Find all margin pushers for 2D axes and reserve them for later use * Both label and rangeslider automargin calculations happen later so @@ -113046,14 +114658,17 @@ axes.allowAutoMargin = function(gd) { for(var i = 0; i < axList.length; i++) { var ax = axList[i]; if(ax.automargin) { - Plots.allowAutoMargin(gd, ax._name + '.automargin'); + Plots.allowAutoMargin(gd, axAutoMarginID(ax)); } - if(ax.rangeslider && ax.rangeslider.visible) { - Plots.allowAutoMargin(gd, 'rangeslider' + ax._id); + if(Registry.getComponentMethod('rangeslider', 'isVisible')(ax)) { + Plots.allowAutoMargin(gd, rangeSliderAutoMarginID(ax)); } } }; +function axAutoMarginID(ax) { return ax._id + '.automargin'; } +function rangeSliderAutoMarginID(ax) { return ax._id + '.rangeslider'; } + // swap all the presentation attributes of the axes showing these traces axes.swap = function(gd, traces) { var axGroups = makeAxisGroups(gd, traces); @@ -113109,11 +114724,10 @@ function mergeAxisGroups(intoSet, fromSet) { } function swapAxisGroup(gd, xIds, yIds) { - var i, - j, - xFullAxes = [], - yFullAxes = [], - layout = gd.layout; + var xFullAxes = []; + var yFullAxes = []; + var layout = gd.layout; + var i, j; for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i])); for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i])); @@ -113126,12 +114740,12 @@ function swapAxisGroup(gd, xIds, yIds) { var numericTypes = ['linear', 'log']; for(i = 0; i < allAxKeys.length; i++) { - var keyi = allAxKeys[i], - xVal = xFullAxes[0][keyi], - yVal = yFullAxes[0][keyi], - allEqual = true, - coerceLinearX = false, - coerceLinearY = false; + var keyi = allAxKeys[i]; + var xVal = xFullAxes[0][keyi]; + var yVal = yFullAxes[0][keyi]; + var allEqual = true; + var coerceLinearX = false; + var coerceLinearY = false; if(keyi.charAt(0) === '_' || typeof xVal === 'function' || noSwapAttrs.indexOf(keyi) !== -1) { continue; @@ -113177,17 +114791,18 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes, dfltTitle) { // in case the value is the default for either axis, // look at the first axis in each list and see if // this key's value is undefined - var np = Lib.nestedProperty, - xVal = np(layout[xFullAxes[0]._name], key).get(), - yVal = np(layout[yFullAxes[0]._name], key).get(), - i; + var np = Lib.nestedProperty; + var xVal = np(layout[xFullAxes[0]._name], key).get(); + var yVal = np(layout[yFullAxes[0]._name], key).get(); + var i; + if(key === 'title') { // special handling of placeholder titles - if(xVal === dfltTitle.x) { - xVal = dfltTitle.y; + if(xVal && xVal.text === dfltTitle.x) { + xVal.text = dfltTitle.y; } - if(yVal === dfltTitle.y) { - yVal = dfltTitle.x; + if(yVal && yVal.text === dfltTitle.y) { + yVal.text = dfltTitle.x; } } @@ -113203,7 +114818,7 @@ function isAngular(ax) { return ax._id === 'angularaxis'; } -},{"../../components/color":570,"../../components/drawing":595,"../../components/titles":661,"../../constants/alignment":668,"../../constants/numerical":673,"../../lib":696,"../../lib/svg_text_utils":720,"../../plots/plots":808,"../../registry":827,"./autorange":743,"./axis_autotype":745,"./axis_ids":747,"./clean_ticks":749,"./layout_attributes":757,"./set_convert":763,"d3":148,"fast-isnumeric":214}],745:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../components/titles":657,"../../constants/alignment":664,"../../constants/numerical":669,"../../lib":692,"../../lib/svg_text_utils":716,"../../plots/plots":804,"../../registry":823,"./autorange":739,"./axis_autotype":741,"./axis_ids":743,"./clean_ticks":745,"./layout_attributes":753,"./set_convert":759,"d3":148,"fast-isnumeric":214}],741:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -113220,7 +114835,10 @@ var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var BADNUM = _dereq_('../../constants/numerical').BADNUM; -module.exports = function autoType(array, calendar) { +module.exports = function autoType(array, calendar, opts) { + opts = opts || {}; + + if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory'; if(moreDates(array, calendar)) return 'date'; if(category(array)) return 'category'; if(linearOK(array)) return 'linear'; @@ -113288,7 +114906,14 @@ function category(a) { return curvecats > curvenums * 2; } -},{"../../constants/numerical":673,"../../lib":696,"fast-isnumeric":214}],746:[function(_dereq_,module,exports){ +// very-loose requirements for multicategory, +// trace modules that should never auto-type to multicategory +// should be declared with 'noMultiCategory' +function multiCategory(a) { + return Lib.isArrayOrTypedArray(a[0]) && Lib.isArrayOrTypedArray(a[1]); +} + +},{"../../constants/numerical":669,"../../lib":692,"fast-isnumeric":214}],742:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -113319,6 +114944,7 @@ var setConvert = _dereq_('./set_convert'); * outerTicks: boolean, should ticks default to outside? * showGrid: boolean, should gridlines be shown by default? * noHover: boolean, this axis doesn't support hover effects? + * noTickson: boolean, this axis doesn't support 'tickson' * data: the plot data, used to manage categories * bgColor: the plot background color, to calculate default gridline colors */ @@ -113359,8 +114985,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, // try to get default title from splom trace, fallback to graph-wide value var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter]; - coerce('title', dfltTitle); - Lib.coerceFont(coerce, 'titlefont', { + coerce('title.text', dfltTitle); + Lib.coerceFont(coerce, 'title.font', { family: font.family, size: Math.round(font.size * 1.2), color: dfltFontColor @@ -113380,10 +115006,29 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, if(options.automargin) coerce('automargin'); + var isMultiCategory = containerOut.type === 'multicategory'; + + if(!options.noTickson && + (containerOut.type === 'category' || isMultiCategory) && + (containerOut.ticks || containerOut.showgrid) + ) { + var ticksonDflt; + if(isMultiCategory) ticksonDflt = 'boundaries'; + coerce('tickson', ticksonDflt); + } + + if(isMultiCategory) { + var showDividers = coerce('showdividers'); + if(showDividers) { + coerce('dividercolor'); + coerce('dividerwidth'); + } + } + return containerOut; }; -},{"../../lib":696,"../../registry":827,"./category_order_defaults":748,"./layout_attributes":757,"./line_grid_defaults":759,"./set_convert":763,"./tick_label_defaults":764,"./tick_mark_defaults":765,"./tick_value_defaults":766}],747:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"./category_order_defaults":744,"./layout_attributes":753,"./line_grid_defaults":755,"./set_convert":759,"./tick_label_defaults":760,"./tick_mark_defaults":761,"./tick_value_defaults":762}],743:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -113501,7 +115146,7 @@ exports.idSort = function(id1, id2) { return +(id1.substr(1) || 1) - +(id2.substr(1) || 1); }; -},{"../../registry":827,"./constants":750}],748:[function(_dereq_,module,exports){ +},{"../../registry":823,"./constants":746}],744:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -113595,7 +115240,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],749:[function(_dereq_,module,exports){ +},{}],745:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -113684,7 +115329,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":673,"../../lib":696,"fast-isnumeric":214}],750:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"fast-isnumeric":214}],746:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -113766,7 +115411,7 @@ module.exports = { } }; -},{"../../lib/regex":712}],751:[function(_dereq_,module,exports){ +},{"../../lib/regex":708}],747:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -113920,7 +115565,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[scaleanchor] = 1; } -},{"../../lib":696,"./axis_ids":747}],752:[function(_dereq_,module,exports){ +},{"../../lib":692,"./axis_ids":743}],748:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -114062,7 +115707,6 @@ exports.enforce = function enforceAxisConstraints(gd) { var getPad = makePadFn(ax); updateDomain(ax, factor); - ax.setScale(); var m = Math.abs(ax._m); var extremes = concatExtremes(gd, ax); var minArray = extremes.min; @@ -114129,9 +115773,10 @@ function updateDomain(ax, factor) { center + (inputDomain[0] - center) / factor, center + (inputDomain[1] - center) / factor ]; + ax.setScale(); } -},{"../../constants/alignment":668,"../../constants/numerical":673,"./autorange":743,"./axis_ids":747,"./scale_zoom":761}],753:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664,"../../constants/numerical":669,"./autorange":739,"./axis_ids":743,"./scale_zoom":757}],749:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -114153,6 +115798,7 @@ var svgTextUtils = _dereq_('../../lib/svg_text_utils'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Fx = _dereq_('../../components/fx'); +var Axes = _dereq_('./axes'); var setCursor = _dereq_('../../lib/setcursor'); var dragElement = _dereq_('../../components/dragelement'); var FROM_TL = _dereq_('../../constants/alignment').FROM_TL; @@ -114161,7 +115807,6 @@ var redrawReglTraces = _dereq_('../../plot_api/subroutines').redrawReglTraces; var Plots = _dereq_('../plots'); -var doTicksSingle = _dereq_('./axes').doTicksSingle; var getFromId = _dereq_('./axis_ids').getFromId; var prepSelect = _dereq_('./select').prepSelect; var clearSelect = _dereq_('./select').clearSelect; @@ -114405,7 +116050,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { .on('edit', function(text) { var v = ax.d2r(text); if(v !== undefined) { - Registry.call('relayout', gd, attrStr, v); + Registry.call('_guiRelayout', gd, attrStr, v); } }); } @@ -114650,6 +116295,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { return; } + // prevent axis drawing from monkeying with margins until we're done + gd._fullLayout._replotting = true; + if(xActive === 'ew' || yActive === 'ns') { if(xActive) dragAxList(xaxes, dx); if(yActive) dragAxList(yaxes, dy); @@ -114753,8 +116401,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { updates = {}; for(i = 0; i < activeAxIds.length; i++) { var axId = activeAxIds[i]; - doTicksSingle(gd, axId, true); var ax = getFromId(gd, axId); + Axes.drawOne(gd, ax, {skipTitle: true}); updates[ax._name + '.range[0]'] = ax.range[0]; updates[ax._name + '.range[1]'] = ax.range[1]; } @@ -114846,7 +116494,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, attrs); } // dragTail - finish a drag event with a redraw @@ -114860,7 +116508,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // accumulated MathJax promises - wait for them before we relayout. Lib.syncOrAsync([ Plots.previousPromises, - function() { Registry.call('relayout', gd, updates); } + function() { + gd._fullLayout._replotting = false; + Registry.call('_guiRelayout', gd, updates); + } ], gd); } @@ -115318,7 +116969,7 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../constants/alignment":668,"../../lib":696,"../../lib/clear_gl_canvases":680,"../../lib/setcursor":716,"../../lib/svg_text_utils":720,"../../plot_api/subroutines":735,"../../registry":827,"../plots":808,"./axes":744,"./axis_ids":747,"./constants":750,"./scale_zoom":761,"./select":762,"d3":148,"has-passive-events":394,"tinycolor2":514}],754:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../constants/alignment":664,"../../lib":692,"../../lib/clear_gl_canvases":677,"../../lib/setcursor":712,"../../lib/svg_text_utils":716,"../../plot_api/subroutines":731,"../../registry":823,"../plots":804,"./axes":740,"./axis_ids":743,"./constants":746,"./scale_zoom":757,"./select":758,"d3":148,"has-passive-events":394,"tinycolor2":513}],750:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -115486,7 +117137,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":592,"../../components/fx":612,"../../lib/setcursor":716,"./constants":750,"./dragbox":753,"d3":148}],755:[function(_dereq_,module,exports){ +},{"../../components/dragelement":587,"../../components/fx":608,"../../lib/setcursor":712,"./constants":746,"./dragbox":749,"d3":148}],751:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -115561,7 +117212,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":696,"../../registry":827}],756:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],752:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -115826,7 +117477,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback // layers that allow `cliponaxis: false` if(className !== 'scatterlayer' && className !== 'barlayer') { - Drawing.setClipUrl(sel, plotinfo.layerClipId); + Drawing.setClipUrl(sel, plotinfo.layerClipId, gd); } }); @@ -116184,7 +117835,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":595,"../../constants/xmlns_namespaces":674,"../../lib":696,"../../registry":827,"../get_data":781,"../plots":808,"./attributes":742,"./axis_ids":747,"./constants":750,"./graph_interact":754,"./layout_attributes":757,"./layout_defaults":758,"./transition_axes":767,"d3":148}],757:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../constants/xmlns_namespaces":670,"../../lib":692,"../../registry":823,"../get_data":777,"../plots":804,"./attributes":738,"./axis_ids":743,"./constants":746,"./graph_interact":750,"./layout_attributes":753,"./layout_defaults":754,"./transition_axes":763,"d3":148}],753:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -116219,21 +117870,24 @@ module.exports = { }, title: { - valType: 'string', - - editType: 'ticks', - + text: { + valType: 'string', + + editType: 'ticks', + + }, + font: fontAttrs({ + editType: 'ticks', + + }), + editType: 'ticks' }, - titlefont: fontAttrs({ - editType: 'ticks', - - }), type: { valType: 'enumerated', // '-' means we haven't yet run autotype or couldn't find any data // it gets turned into linear in gd._fullLayout but not copied back // to gd.data like the others are. - values: ['-', 'linear', 'log', 'date', 'category'], + values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', editType: 'calc', @@ -116362,6 +118016,14 @@ module.exports = { editType: 'ticks', + }, + tickson: { + valType: 'enumerated', + values: ['labels', 'boundaries'], + + dflt: 'labels', + editType: 'ticks', + }, mirror: { valType: 'enumerated', @@ -116615,6 +118277,30 @@ module.exports = { editType: 'ticks', }, + + showdividers: { + valType: 'boolean', + dflt: true, + + editType: 'ticks', + + }, + dividercolor: { + valType: 'color', + dflt: colorAttrs.defaultLine, + + editType: 'ticks', + + }, + dividerwidth: { + valType: 'number', + dflt: 1, + + editType: 'ticks', + + }, + // TODO dividerlen: that would override "to label base" length? + // positioning attributes // anchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -116696,6 +118382,12 @@ module.exports = { editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'calc', @@ -116705,11 +118397,21 @@ module.exports = { editType: 'ticks', - } + }, + title: { + valType: 'string', + + editType: 'ticks', + + }, + titlefont: fontAttrs({ + editType: 'ticks', + + }) } }; -},{"../../components/color/attributes":569,"../../components/drawing/attributes":594,"../../lib/extend":685,"../../plot_api/plot_template":734,"../font_attributes":771,"./constants":750}],758:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../components/drawing/attributes":589,"../../lib/extend":682,"../../plot_api/plot_template":730,"../font_attributes":767,"./constants":746}],754:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -116868,9 +118570,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; }); axLayoutOut._annIndices = []; axLayoutOut._shapeIndices = []; + axLayoutOut._subplotsWith = []; + axLayoutOut._counterAxes = []; // set up some private properties - axLayoutOut._name = axName; + axLayoutOut._name = axLayoutOut._attr = axName; var id = axLayoutOut._id = name2id(axName); var overlayableAxes = getOverlayableAxes(axLetter, axName); @@ -116888,6 +118592,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id] }; + coerce('uirevision', layoutOut.uirevision); + handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions); handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut); @@ -116949,11 +118655,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var anchoredAxis = layoutOut[id2name(axLayoutOut.anchor)]; - var fixedRangeDflt = ( - anchoredAxis && - anchoredAxis.rangeslider && - anchoredAxis.rangeslider.visible - ); + var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis); coerce('fixedrange', fixedRangeDflt); } @@ -116978,7 +118680,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } }; -},{"../../components/color":570,"../../lib":696,"../../plot_api/plot_template":734,"../../registry":827,"../layout_attributes":799,"./axis_defaults":746,"./axis_ids":747,"./constraint_defaults":751,"./layout_attributes":757,"./position_defaults":760,"./type_defaults":768}],759:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../plot_api/plot_template":730,"../../registry":823,"../layout_attributes":795,"./axis_defaults":742,"./axis_ids":743,"./constraint_defaults":747,"./layout_attributes":753,"./position_defaults":756,"./type_defaults":764}],755:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -117043,7 +118745,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":569,"../../lib":696,"tinycolor2":514}],760:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../lib":692,"tinycolor2":513}],756:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -117127,7 +118829,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":696,"fast-isnumeric":214}],761:[function(_dereq_,module,exports){ +},{"../../lib":692,"fast-isnumeric":214}],757:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -117155,7 +118857,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ]; }; -},{"../../constants/alignment":668}],762:[function(_dereq_,module,exports){ +},{"../../constants/alignment":664}],758:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -117824,13 +119526,22 @@ function isOnlyOnePointSelected(searchTraces) { function updateSelectedState(gd, searchTraces, eventData) { var i, searchInfo, cd, trace; + // before anything else, update preGUI if necessary + for(i = 0; i < searchTraces.length; i++) { + var fullInputTrace = searchTraces[i].cd[0].trace._fullInput; + var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid]; + if(tracePreGUI.selectedpoints === undefined) { + tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null; + } + } + if(eventData) { var pts = eventData.points || []; for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; - trace.selectedpoints = []; - trace._input.selectedpoints = []; + trace._input.selectedpoints = trace._fullInput.selectedpoints = []; + if(trace._fullInput !== trace) trace.selectedpoints = []; } for(i = 0; i < pts.length; i++) { @@ -117840,10 +119551,14 @@ function updateSelectedState(gd, searchTraces, eventData) { if(pt.pointIndices) { [].push.apply(data.selectedpoints, pt.pointIndices); - [].push.apply(fullData.selectedpoints, pt.pointIndices); + if(trace._fullInput !== trace) { + [].push.apply(fullData.selectedpoints, pt.pointIndices); + } } else { data.selectedpoints.push(pt.pointIndex); - fullData.selectedpoints.push(pt.pointIndex); + if(trace._fullInput !== trace) { + fullData.selectedpoints.push(pt.pointIndex); + } } } } @@ -117852,6 +119567,9 @@ function updateSelectedState(gd, searchTraces, eventData) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; delete trace._input.selectedpoints; + if(trace._fullInput !== trace) { + delete trace._fullInput.selectedpoints; + } } } @@ -117929,7 +119647,7 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":570,"../../components/fx":612,"../../components/fx/helpers":609,"../../lib/clear_gl_canvases":680,"../../lib/polygon":708,"../../lib/throttle":721,"../../plot_api/subroutines":735,"../../registry":827,"./axis_ids":747,"./constants":750,"polybooljs":456}],763:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../components/fx/helpers":604,"../../lib/clear_gl_canvases":677,"../../lib/polygon":704,"../../lib/throttle":717,"../../plot_api/subroutines":731,"../../registry":823,"./axis_ids":743,"./constants":746,"polybooljs":456}],759:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -117962,6 +119680,10 @@ function fromLog(v) { return Math.pow(10, v); } +function isValidCategory(v) { + return v !== null && v !== undefined; +} + /** * Define the conversion functions for an axis data is used in 5 ways: * @@ -118055,7 +119777,7 @@ module.exports = function setConvert(ax, fullLayout) { * a disconnect between the array and the index returned */ function setCategoryIndex(v) { - if(v !== null && v !== undefined) { + if(isValidCategory(v)) { if(ax._categoriesMap === undefined) { ax._categoriesMap = {}; } @@ -118074,14 +119796,58 @@ module.exports = function setConvert(ax, fullLayout) { return BADNUM; } + function setMultiCategoryIndex(arrayIn, len) { + var arrayOut = new Array(len); + var i; + + // [ [arrayIn[0][i], arrayIn[1][i]], for i .. len ] + var tmp = new Array(len); + // [ [cnt, {$cat: index}], for j .. arrayIn.length ] + var seen = [[0, {}], [0, {}]]; + + if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) { + for(i = 0; i < len; i++) { + var v0 = arrayIn[0][i]; + var v1 = arrayIn[1][i]; + if(isValidCategory(v0) && isValidCategory(v1)) { + tmp[i] = [v0, v1]; + if(!(v0 in seen[0][1])) { + seen[0][1][v0] = seen[0][0]++; + } + if(!(v1 in seen[1][1])) { + seen[1][1][v1] = seen[1][0]++; + } + } + } + + tmp.sort(function(a, b) { + var ind0 = seen[0][1]; + var d = ind0[a[0]] - ind0[b[0]]; + if(d) return d; + + var ind1 = seen[1][1]; + return ind1[a[1]] - ind1[b[1]]; + }); + } + + for(i = 0; i < len; i++) { + arrayOut[i] = setCategoryIndex(tmp[i]); + } + + return arrayOut; + } + function getCategoryIndex(v) { - // d2l/d2c variant that that won't add categories but will also - // allow numbers to be mapped to the linearized axis positions if(ax._categoriesMap) { - var index = ax._categoriesMap[v]; - if(index !== undefined) return index; + return ax._categoriesMap[v]; } + } + function getCategoryPosition(v) { + // d2l/d2c variant that that won't add categories but will also + // allow numbers to be mapped to the linearized axis positions + var index = getCategoryIndex(v); + if(index !== undefined) return index; if(isNumeric(v)) return +v; } @@ -118167,15 +119933,15 @@ module.exports = function setConvert(ax, fullLayout) { ax.d2c = ax.d2l = setCategoryIndex; ax.r2d = ax.c2d = ax.l2d = getCategoryName; - ax.d2r = ax.d2l_noadd = getCategoryIndex; + ax.d2r = ax.d2l_noadd = getCategoryPosition; ax.r2c = function(v) { - var index = getCategoryIndex(v); + var index = getCategoryPosition(v); return index !== undefined ? index : ax.fraction2r(0.5); }; ax.l2r = ax.c2r = ensureNumber; - ax.r2l = getCategoryIndex; + ax.r2l = getCategoryPosition; ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; ax.p2d = function(px) { return getCategoryName(p2l(px)); }; @@ -118187,6 +119953,34 @@ module.exports = function setConvert(ax, fullLayout) { return ensureNumber(v); }; } + else if(ax.type === 'multicategory') { + // N.B. multicategory axes don't define d2c and d2l, + // as 'data-to-calcdata' conversion needs to take into + // account all data array items as in ax.makeCalcdata. + + ax.r2d = ax.c2d = ax.l2d = getCategoryName; + ax.d2r = ax.d2l_noadd = getCategoryPosition; + + ax.r2c = function(v) { + var index = getCategoryPosition(v); + return index !== undefined ? index : ax.fraction2r(0.5); + }; + + ax.r2c_just_indices = getCategoryIndex; + + ax.l2r = ax.c2r = ensureNumber; + ax.r2l = getCategoryPosition; + + ax.d2p = function(v) { return ax.l2p(ax.r2c(v)); }; + ax.p2d = function(px) { return getCategoryName(p2l(px)); }; + ax.r2p = ax.d2p; + ax.p2r = p2l; + + ax.cleanPos = function(v) { + if(Array.isArray(v) || (typeof v === 'string' && v !== '')) return v; + return ensureNumber(v); + }; + } // find the range value at the specified (linear) fraction of the axis ax.fraction2r = function(v) { @@ -118280,11 +120074,6 @@ module.exports = function setConvert(ax, fullLayout) { ax.setScale = function(usePrivateRange) { var gs = fullLayout._size; - // TODO cleaner way to handle this case - if(!ax._categories) ax._categories = []; - // Add a map to optimize the performance of category collection - if(!ax._categoriesMap) ax._categoriesMap = {}; - // make sure we have a domain (pull it in from the axis // this one is overlaying if necessary) if(ax.overlaying) { @@ -118339,7 +120128,7 @@ module.exports = function setConvert(ax, fullLayout) { if(axLetter in trace) { arrayIn = trace[axLetter]; - len = trace._length || arrayIn.length; + len = trace._length || Lib.minRowLength(arrayIn); if(Lib.isTypedArray(arrayIn) && (axType === 'linear' || axType === 'log')) { if(len === arrayIn.length) { @@ -118349,6 +120138,10 @@ module.exports = function setConvert(ax, fullLayout) { } } + if(axType === 'multicategory') { + return setMultiCategoryIndex(arrayIn, len); + } + arrayOut = new Array(len); for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); @@ -118425,7 +120218,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":673,"../../lib":696,"./axis_ids":747,"./constants":750,"d3":148,"fast-isnumeric":214}],764:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"./axis_ids":743,"./constants":746,"d3":148,"fast-isnumeric":214}],760:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -118526,7 +120319,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../lib":696,"../array_container_defaults":740,"./layout_attributes":757}],765:[function(_dereq_,module,exports){ +},{"../../lib":692,"../array_container_defaults":736,"./layout_attributes":753}],761:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -118559,7 +120352,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":696,"./layout_attributes":757}],766:[function(_dereq_,module,exports){ +},{"../../lib":692,"./layout_attributes":753}],762:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -118568,22 +120361,18 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, * LICENSE file in the root directory of this source tree. */ - 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); - module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { var tickmode; if(containerIn.tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; - } - else { - var tickmodeDefault = - Array.isArray(containerIn.tickvals) ? 'array' : + } else { + var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : containerIn.dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); @@ -118598,15 +120387,14 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe containerIn.dtick, axType); containerOut.tick0 = cleanTicks.tick0( containerIn.tick0, axType, containerOut.calendar, dtick); - } - else { + } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto'; else coerce('ticktext'); } }; -},{"./clean_ticks":749}],767:[function(_dereq_,module,exports){ +},{"./clean_ticks":745}],763:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -118728,14 +120516,11 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo } function ticksAndAnnotations(xa, ya) { - var activeAxIds = [], - i; + var activeAxIds = [xa._id, ya._id]; + var i; - activeAxIds = [xa._id, ya._id]; - - for(i = 0; i < activeAxIds.length; i++) { - Axes.doTicksSingle(gd, activeAxIds[i], true); - } + Axes.drawOne(gd, xa, {skipTitle: true}); + Axes.drawOne(gd, ya, {skipTitle: true}); function redrawObjs(objArray, method, shortCircuit) { for(i = 0; i < objArray.length; i++) { @@ -118934,7 +120719,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo return Promise.resolve(); }; -},{"../../components/drawing":595,"../../registry":827,"./axes":744,"./constants":750,"d3":148}],768:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../registry":823,"./axes":740,"./constants":746,"d3":148}],764:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -118945,7 +120730,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo 'use strict'; -var Registry = _dereq_('../../registry'); +var traceIs = _dereq_('../../registry').traceIs; var autoType = _dereq_('./axis_autotype'); /* @@ -118994,6 +120779,7 @@ function setAutoType(ax, data) { var calAttr = axLetter + 'calendar'; var calendar = d0[calAttr]; + var opts = {noMultiCategory: !traceIs(d0, 'cartesian') || traceIs(d0, 'noMultiCategory')}; var i; // check all boxes on this x axis to see @@ -119004,8 +120790,7 @@ function setAutoType(ax, data) { for(i = 0; i < data.length; i++) { var trace = data[i]; - if(!Registry.traceIs(trace, 'box-violin') || - (trace[axLetter + 'axis'] || axLetter) !== id) continue; + if(!traceIs(trace, 'box-violin') || (trace[axLetter + 'axis'] || axLetter) !== id) continue; if(trace[posLetter] !== undefined) boxPositions.push(trace[posLetter][0]); else if(trace.name !== undefined) boxPositions.push(trace.name); @@ -119014,7 +120799,7 @@ function setAutoType(ax, data) { if(trace[calAttr] !== calendar) calendar = undefined; } - ax.type = autoType(boxPositions, calendar); + ax.type = autoType(boxPositions, calendar, opts); } else if(d0.type === 'splom') { var dimensions = d0.dimensions; @@ -119022,13 +120807,13 @@ function setAutoType(ax, data) { for(i = 0; i < dimensions.length; i++) { var dim = dimensions[i]; if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) { - ax.type = autoType(dim.values, calendar); + ax.type = autoType(dim.values, calendar, opts); break; } } } else { - ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar); + ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -119059,9 +120844,9 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace), - isBox = Registry.traceIs(trace, 'box-violin'), - isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); + var posLetter = getBoxPosLetter(trace); + var isBox = traceIs(trace, 'box-violin'); + var isCandlestick = traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox && @@ -119072,7 +120857,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":827,"./axis_autotype":745}],769:[function(_dereq_,module,exports){ +},{"../../registry":823,"./axis_autotype":741}],765:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119496,7 +121281,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":696,"../registry":827}],770:[function(_dereq_,module,exports){ +},{"../lib":692,"../registry":823}],766:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119604,7 +121389,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { coerce('domain.y', dfltY); }; -},{"../lib/extend":685}],771:[function(_dereq_,module,exports){ +},{"../lib/extend":682}],767:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119669,7 +121454,7 @@ module.exports = function(opts) { return attrs; }; -},{}],772:[function(_dereq_,module,exports){ +},{}],768:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119715,7 +121500,7 @@ module.exports = { } }; -},{}],773:[function(_dereq_,module,exports){ +},{}],769:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -119890,7 +121675,7 @@ exports.layerNameToAdjective = { frame: 'frame' }; -},{}],774:[function(_dereq_,module,exports){ +},{}],770:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -120260,7 +122045,7 @@ proto.updateFx = function(fullLayout, geoLayout) { updateObj[_this.id + '.' + k] = viewInitial[k]; } - Registry.call('relayout', gd, updateObj); + Registry.call('_guiRelayout', gd, updateObj); gd.emit('plotly_doubleclick', null); } @@ -120363,7 +122148,8 @@ proto.updateFx = function(fullLayout, geoLayout) { proto.makeFramework = function() { var _this = this; - var fullLayout = _this.graphDiv._fullLayout; + var gd = _this.graphDiv; + var fullLayout = gd._fullLayout; var clipId = 'clip' + fullLayout._uid + _this.id; _this.clipDef = fullLayout._clips.append('clipPath') @@ -120373,7 +122159,7 @@ proto.makeFramework = function() { _this.framework = d3.select(_this.container).append('g') .attr('class', 'geo ' + _this.id) - .call(Drawing.setClipUrl, clipId); + .call(Drawing.setClipUrl, clipId, gd); // sane lonlat to px _this.project = function(v) { @@ -120599,7 +122385,7 @@ function makeRangeBox(lon, lat) { }; } -},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../lib":696,"../../lib/topojson_utils":723,"../../registry":827,"../cartesian/axes":744,"../cartesian/select":762,"../plots":808,"./constants":773,"./projections":779,"./zoom":780,"d3":148,"topojson-client":517}],775:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../lib":692,"../../lib/topojson_utils":719,"../../registry":823,"../cartesian/axes":740,"../cartesian/select":758,"../plots":804,"./constants":769,"./projections":775,"./zoom":776,"d3":148,"topojson-client":516}],771:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -120691,7 +122477,7 @@ exports.updateFx = function(gd) { } }; -},{"../../lib":696,"../../plots/get_data":781,"./geo":774,"./layout/attributes":776,"./layout/defaults":777,"./layout/layout_attributes":778}],776:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/get_data":777,"./geo":770,"./layout/attributes":772,"./layout/defaults":773,"./layout/layout_attributes":774}],772:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -120713,7 +122499,7 @@ module.exports = { } }; -},{}],777:[function(_dereq_,module,exports){ +},{}],773:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -120877,7 +122663,7 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce) { coerce('bgcolor'); } -},{"../../subplot_defaults":822,"../constants":773,"./layout_attributes":778}],778:[function(_dereq_,module,exports){ +},{"../../subplot_defaults":818,"../constants":769,"./layout_attributes":774}],774:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -120934,7 +122720,7 @@ var geoAxesAttrs = { } }; -module.exports = overrideAll({ +var attrs = module.exports = overrideAll({ domain: domainAttrs({name: 'geo'}, { }), @@ -121144,7 +122930,15 @@ module.exports = overrideAll({ lataxis: geoAxesAttrs }, 'plot', 'from-root'); -},{"../../../components/color/attributes":569,"../../../plot_api/edit_types":727,"../../domain":770,"../constants":773}],779:[function(_dereq_,module,exports){ +// set uirevision outside of overrideAll so it can be `editType: 'none'` +attrs.uirevision = { + valType: 'any', + + editType: 'none', + +}; + +},{"../../../components/color/attributes":568,"../../../plot_api/edit_types":723,"../../domain":766,"../constants":769}],775:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -121590,7 +123384,7 @@ function addProjectionsToD3(d3) { module.exports = addProjectionsToD3; -},{}],780:[function(_dereq_,module,exports){ +},{}],776:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -121604,6 +123398,7 @@ module.exports = addProjectionsToD3; var d3 = _dereq_('d3'); var Lib = _dereq_('../../lib'); +var Registry = _dereq_('../../registry'); var radians = Math.PI / 180; var degrees = 180 / Math.PI; @@ -121640,8 +123435,10 @@ function initZoom(geo, projection) { function sync(geo, projection, cb) { var id = geo.id; var gd = geo.graphDiv; - var userOpts = gd.layout[id]; - var fullOpts = gd._fullLayout[id]; + var layout = gd.layout; + var userOpts = layout[id]; + var fullLayout = gd._fullLayout; + var fullOpts = fullLayout[id]; var eventData = {}; @@ -121657,6 +123454,7 @@ function sync(geo, projection, cb) { cb(set); set('projection.scale', projection.scale() / geo.fitScale); + Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, eventData); gd.emit('plotly_relayout', eventData); } @@ -122064,7 +123862,7 @@ function d3_eventDispatch(target) { return dispatch; } -},{"../../lib":696,"d3":148}],781:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"d3":148}],777:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122192,7 +123990,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":827,"./cartesian/constants":750}],782:[function(_dereq_,module,exports){ +},{"../registry":823,"./cartesian/constants":746}],778:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122494,7 +124292,7 @@ function createCamera(scene) { return result; } -},{"../cartesian/constants":750,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421}],783:[function(_dereq_,module,exports){ +},{"../cartesian/constants":746,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421}],779:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122508,7 +124306,6 @@ function createCamera(scene) { var Axes = _dereq_('../cartesian/axes'); -var convertHTMLToUnicode = _dereq_('../../lib/html2unicode'); var str2RGBArray = _dereq_('../../lib/str2rgbarray'); function Axes2DOptions(scene) { @@ -122611,14 +124408,14 @@ proto.merge = function(options) { // '_name' is e.g. xaxis, xaxis2, yaxis, yaxis4 ... ax = options[this.scene[axisName]._name]; - axTitle = ax.title === this.scene.fullLayout._dfltTitle[axisLetter] ? '' : ax.title; + axTitle = ax.title.text === this.scene.fullLayout._dfltTitle[axisLetter] ? '' : ax.title.text; for(j = 0; j <= 2; j += 2) { this.labelEnable[i + j] = false; - this.labels[i + j] = convertHTMLToUnicode(axTitle); - this.labelColor[i + j] = str2RGBArray(ax.titlefont.color); - this.labelFont[i + j] = ax.titlefont.family; - this.labelSize[i + j] = ax.titlefont.size; + this.labels[i + j] = axTitle; + this.labelColor[i + j] = str2RGBArray(ax.title.font.color); + this.labelFont[i + j] = ax.title.font.family; + this.labelSize[i + j] = ax.title.font.size; this.labelPad[i + j] = this.getLabelPad(axisName, ax); this.tickEnable[i + j] = false; @@ -122706,7 +124503,7 @@ proto.hasAxisInAltrPos = function(axisName, ax) { proto.getLabelPad = function(axisName, ax) { var offsetBase = 1.5, - fontSize = ax.titlefont.size, + fontSize = ax.title.font.size, showticklabels = ax.showticklabels; if(axisName === 'xaxis') { @@ -122740,7 +124537,7 @@ function createAxes2D(scene) { module.exports = createAxes2D; -},{"../../lib/html2unicode":694,"../../lib/str2rgbarray":719,"../cartesian/axes":744}],784:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":715,"../cartesian/axes":740}],780:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122891,7 +124688,7 @@ exports.updateFx = function(gd) { } }; -},{"../../components/fx/layout_attributes":613,"../../constants/xmlns_namespaces":674,"../../plot_api/edit_types":727,"../cartesian":756,"../cartesian/attributes":742,"../cartesian/constants":750,"../get_data":781,"../layout_attributes":799,"./scene2d":785}],785:[function(_dereq_,module,exports){ +},{"../../components/fx/layout_attributes":609,"../../constants/xmlns_namespaces":670,"../../plot_api/edit_types":723,"../cartesian":752,"../cartesian/attributes":738,"../cartesian/constants":746,"../get_data":777,"../layout_attributes":795,"./scene2d":781}],781:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -122914,7 +124711,6 @@ var getContext = _dereq_('webgl-context'); var createOptions = _dereq_('./convert'); var createCamera = _dereq_('./camera'); -var convertHTMLToUnicode = _dereq_('../../lib/html2unicode'); var showNoWebGlMsg = _dereq_('../../lib/show_no_webgl_msg'); var axisConstraints = _dereq_('../cartesian/constraints'); var enforceAxisConstraints = axisConstraints.enforce; @@ -123173,7 +124969,7 @@ proto.computeTickMarks = function() { for(var j = 0; j < 2; ++j) { for(var i = 0; i < nextTicks[j].length; ++i) { // coercing tick value (may not be a string) to a string - nextTicks[j][i].text = convertHTMLToUnicode(nextTicks[j][i].text + ''); + nextTicks[j][i].text = nextTicks[j][i].text + ''; } } @@ -123207,27 +125003,31 @@ proto.updateRefs = function(newFullLayout) { }; proto.relayoutCallback = function() { - var graphDiv = this.graphDiv, - xaxis = this.xaxis, - yaxis = this.yaxis, - layout = graphDiv.layout; + var graphDiv = this.graphDiv; + var xaxis = this.xaxis; + var yaxis = this.yaxis; + var layout = graphDiv.layout; - // update user layout - layout.xaxis.autorange = xaxis.autorange; - layout.xaxis.range = xaxis.range.slice(0); - layout.yaxis.autorange = yaxis.autorange; - layout.yaxis.range = yaxis.range.slice(0); + // make a meaningful value to be passed on to possible 'plotly_relayout' subscriber(s) + var update = {}; + var xrange = update[xaxis._name + '.range'] = xaxis.range.slice(); + var yrange = update[yaxis._name + '.range'] = yaxis.range.slice(); + update[xaxis._name + '.autorange'] = xaxis.autorange; + update[yaxis._name + '.autorange'] = yaxis.autorange; - // make a meaningful value to be passed on to the possible 'plotly_relayout' subscriber(s) - // scene.camera has no many useful projection or scale information - // helps determine which one is the latest input (if async) - var update = { - lastInputTime: this.camera.lastInputTime - }; + Registry.call('_storeDirectGUIEdit', graphDiv.layout, graphDiv._fullLayout._preGUI, update); + + // update the input layout + var xaIn = layout[xaxis._name]; + xaIn.range = xrange; + xaIn.autorange = xaxis.autorange; - update[xaxis._name] = xaxis.range.slice(0); - update[yaxis._name] = yaxis.range.slice(0); + var yaIn = layout[yaxis._name]; + yaIn.range = yrange; + yaIn.autorange = yaxis.autorange; + // lastInputTime helps determine which one is the latest input (if async) + update.lastInputTime = this.camera.lastInputTime; graphDiv.emit('plotly_relayout', update); }; @@ -123613,7 +125413,7 @@ proto.hoverFormatter = function(axisName, val) { return Axes.tickText(axis, axis.c2l(val), 'hover').text; }; -},{"../../components/fx":612,"../../lib/html2unicode":694,"../../lib/show_no_webgl_msg":717,"../../plots/cartesian/axes":744,"../../registry":827,"../cartesian/autorange":743,"../cartesian/constants":750,"../cartesian/constraints":752,"./camera":782,"./convert":783,"gl-plot2d":275,"gl-select-box":286,"gl-spikes2d":295,"webgl-context":533}],786:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../lib/show_no_webgl_msg":713,"../../plots/cartesian/axes":740,"../../registry":823,"../cartesian/autorange":739,"../cartesian/constants":746,"../cartesian/constraints":748,"./camera":778,"./convert":779,"gl-plot2d":275,"gl-select-box":286,"gl-spikes2d":295,"webgl-context":532}],782:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -123887,7 +125687,7 @@ function createCamera(element, options) { return camera; } -},{"3d-view":45,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421,"right-now":480}],787:[function(_dereq_,module,exports){ +},{"3d-view":45,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421,"right-now":480}],783:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124029,7 +125829,7 @@ exports.updateFx = function(gd) { } }; -},{"../../components/fx/layout_attributes":613,"../../constants/xmlns_namespaces":674,"../../lib":696,"../../plot_api/edit_types":727,"../get_data":781,"./layout/attributes":788,"./layout/defaults":792,"./layout/layout_attributes":793,"./scene":797}],788:[function(_dereq_,module,exports){ +},{"../../components/fx/layout_attributes":609,"../../constants/xmlns_namespaces":670,"../../lib":692,"../../plot_api/edit_types":723,"../get_data":777,"./layout/attributes":784,"./layout/defaults":788,"./layout/layout_attributes":789,"./scene":793}],784:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124051,7 +125851,7 @@ module.exports = { } }; -},{}],789:[function(_dereq_,module,exports){ +},{}],785:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124067,7 +125867,6 @@ var axesAttrs = _dereq_('../../cartesian/layout_attributes'); var extendFlat = _dereq_('../../../lib/extend').extendFlat; var overrideAll = _dereq_('../../../plot_api/edit_types').overrideAll; - module.exports = overrideAll({ visible: axesAttrs.visible, showspikes: { @@ -124117,8 +125916,9 @@ module.exports = overrideAll({ categoryorder: axesAttrs.categoryorder, categoryarray: axesAttrs.categoryarray, title: axesAttrs.title, - titlefont: axesAttrs.titlefont, - type: axesAttrs.type, + type: extendFlat({}, axesAttrs.type, { + values: ['-', 'linear', 'log', 'date', 'category'] + }), autorange: axesAttrs.autorange, rangemode: axesAttrs.rangemode, range: axesAttrs.range, @@ -124157,10 +125957,14 @@ module.exports = overrideAll({ gridwidth: axesAttrs.gridwidth, zeroline: axesAttrs.zeroline, zerolinecolor: axesAttrs.zerolinecolor, - zerolinewidth: axesAttrs.zerolinewidth + zerolinewidth: axesAttrs.zerolinewidth, + _deprecated: { + title: axesAttrs._deprecated.title, + titlefont: axesAttrs._deprecated.titlefont + } }, 'plot', 'from-root'); -},{"../../../components/color":570,"../../../lib/extend":685,"../../../plot_api/edit_types":727,"../../cartesian/layout_attributes":757}],790:[function(_dereq_,module,exports){ +},{"../../../components/color":569,"../../../lib/extend":682,"../../../plot_api/edit_types":723,"../../cartesian/layout_attributes":753}],786:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124213,13 +126017,14 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) { letter: axName[0], data: options.data, showGrid: true, + noTickson: true, bgColor: options.bgColor, calendar: options.calendar }, options.fullLayout); coerce('gridcolor', colorMix(containerOut.color, options.bgColor, gridLightness).toRgbString()); - coerce('title', axName[0]); // shouldn't this be on-par with 2D? + coerce('title.text', axName[0]); // shouldn't this be on-par with 2D? containerOut.setScale = Lib.noop; @@ -124234,7 +126039,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) { } }; -},{"../../../lib":696,"../../../plot_api/plot_template":734,"../../cartesian/axis_defaults":746,"../../cartesian/type_defaults":768,"./axis_attributes":789,"tinycolor2":514}],791:[function(_dereq_,module,exports){ +},{"../../../lib":692,"../../../plot_api/plot_template":730,"../../cartesian/axis_defaults":742,"../../cartesian/type_defaults":764,"./axis_attributes":785,"tinycolor2":513}],787:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124246,7 +126051,6 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) { 'use strict'; -var convertHTMLToUnicode = _dereq_('../../../lib/html2unicode'); var str2RgbaArray = _dereq_('../../../lib/str2rgbarray'); var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis']; @@ -124321,11 +126125,11 @@ proto.merge = function(sceneLayout) { } // Axes labels - opts.labels[i] = convertHTMLToUnicode(axes.title); - if('titlefont' in axes) { - if(axes.titlefont.color) opts.labelColor[i] = str2RgbaArray(axes.titlefont.color); - if(axes.titlefont.family) opts.labelFont[i] = axes.titlefont.family; - if(axes.titlefont.size) opts.labelSize[i] = axes.titlefont.size; + opts.labels[i] = axes.title.text; + if('font' in axes.title) { + if(axes.title.font.color) opts.labelColor[i] = str2RgbaArray(axes.title.font.color); + if(axes.title.font.family) opts.labelFont[i] = axes.title.font.family; + if(axes.title.font.size) opts.labelSize[i] = axes.title.font.size; } // Lines @@ -124397,7 +126201,7 @@ function createAxesOptions(plotlyOptions) { module.exports = createAxesOptions; -},{"../../../lib/html2unicode":694,"../../../lib/str2rgbarray":719}],792:[function(_dereq_,module,exports){ +},{"../../../lib/str2rgbarray":715}],788:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124510,11 +126314,36 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) { sceneLayoutIn, sceneLayoutOut, opts ); - coerce('dragmode', opts.getDfltFromLayout('dragmode')); + var dragmode = opts.getDfltFromLayout('dragmode'); + + if(dragmode !== false) { + if(!dragmode) { + + dragmode = 'orbit'; + + if(sceneLayoutIn.camera && + sceneLayoutIn.camera.up) { + + var x = sceneLayoutIn.camera.up.x; + var y = sceneLayoutIn.camera.up.y; + var z = sceneLayoutIn.camera.up.z; + + if(!x || !y || !z) { + dragmode = 'turntable'; + } else if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) { + dragmode = 'turntable'; + } + } else { + dragmode = 'turntable'; + } + } + } + + coerce('dragmode', dragmode); coerce('hovermode', opts.getDfltFromLayout('hovermode')); } -},{"../../../components/color":570,"../../../lib":696,"../../../registry":827,"../../subplot_defaults":822,"./axis_defaults":790,"./layout_attributes":793}],793:[function(_dereq_,module,exports){ +},{"../../../components/color":569,"../../../lib":692,"../../../registry":823,"../../subplot_defaults":818,"./axis_defaults":786,"./layout_attributes":789}],789:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124625,7 +126454,6 @@ module.exports = { valType: 'enumerated', values: ['orbit', 'turntable', 'zoom', 'pan', false], - dflt: 'turntable', editType: 'plot', }, @@ -124636,6 +126464,12 @@ module.exports = { dflt: 'closest', editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'plot', @@ -124649,7 +126483,7 @@ module.exports = { } }; -},{"../../../lib":696,"../../../lib/extend":685,"../../domain":770,"./axis_attributes":789}],794:[function(_dereq_,module,exports){ +},{"../../../lib":692,"../../../lib/extend":682,"../../domain":766,"./axis_attributes":785}],790:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124701,7 +126535,7 @@ function createSpikeOptions(layout) { module.exports = createSpikeOptions; -},{"../../../lib/str2rgbarray":719}],795:[function(_dereq_,module,exports){ +},{"../../../lib/str2rgbarray":715}],791:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124719,7 +126553,6 @@ module.exports = computeTickMarks; var Axes = _dereq_('../../cartesian/axes'); var Lib = _dereq_('../../../lib'); -var convertHTMLToUnicode = _dereq_('../../../lib/html2unicode'); var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis']; @@ -124751,7 +126584,8 @@ function computeTickMarks(scene) { axes._length = (glRange[i].hi - glRange[i].lo) * glRange[i].pixelsPerDataUnit / scene.dataScale[i]; - if(Math.abs(axes._length) === Infinity) { + if(Math.abs(axes._length) === Infinity || + isNaN(axes._length)) { ticks[i] = []; } else { axes._input_range = axes.range.slice(); @@ -124776,7 +126610,11 @@ function computeTickMarks(scene) { var dataTicks = Axes.calcTicks(axes); for(var j = 0; j < dataTicks.length; ++j) { dataTicks[j].x = dataTicks[j].x * scene.dataScale[i]; - dataTicks[j].text = convertHTMLToUnicode(dataTicks[j].text); + + if(axes.type === 'date') { + dataTicks[j].text = + dataTicks[j].text.replace(/\/g, ' '); + } } ticks[i] = dataTicks; @@ -124798,7 +126636,7 @@ function computeTickMarks(scene) { scene.contourLevels = contourLevelsFromTicks(ticks); } -},{"../../../lib":696,"../../../lib/html2unicode":694,"../../cartesian/axes":744}],796:[function(_dereq_,module,exports){ +},{"../../../lib":692,"../../cartesian/axes":740}],792:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -124832,7 +126670,7 @@ function project(camera, v) { module.exports = project; -},{}],797:[function(_dereq_,module,exports){ +},{}],793:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125004,7 +126842,7 @@ function render(scene) { scene.drawAnnotations(scene); } -function initializeGLPlot(scene, fullLayout, canvas, gl) { +function initializeGLPlot(scene, canvas, gl) { var gd = scene.graphDiv; var glplotOptions = { @@ -125153,7 +126991,7 @@ function Scene(options, fullLayout) { this.convertAnnotations = Registry.getComponentMethod('annotations3d', 'convert'); this.drawAnnotations = Registry.getComponentMethod('annotations3d', 'draw'); - if(!initializeGLPlot(this, fullLayout)) return; // todo check the necessity for this line + if(!initializeGLPlot(this)) return; // todo check the necessity for this line } var proto = Scene.prototype; @@ -125169,7 +127007,7 @@ proto.recoverContext = function() { requestAnimationFrame(tryRecover); return; } - if(!initializeGLPlot(scene, scene.fullLayout, canvas, gl)) { + if(!initializeGLPlot(scene, canvas, gl)) { Lib.error('Catastrophic and unrecoverable WebGL error. Context lost.'); return; } @@ -125536,10 +127374,10 @@ proto.setCamera = function setCamera(cameraData) { // save camera to user layout (i.e. gd.layout) proto.saveCamera = function saveCamera(layout) { - var cameraData = this.getCamera(), - cameraNestedProp = Lib.nestedProperty(layout, this.id + '.camera'), - cameraDataLastSave = cameraNestedProp.get(), - hasChanged = false; + var cameraData = this.getCamera(); + var cameraNestedProp = Lib.nestedProperty(layout, this.id + '.camera'); + var cameraDataLastSave = cameraNestedProp.get(); + var hasChanged = false; function same(x, y, i, j) { var vectors = ['up', 'center', 'eye'], @@ -125559,7 +127397,14 @@ proto.saveCamera = function saveCamera(layout) { } } - if(hasChanged) cameraNestedProp.set(cameraData); + if(hasChanged) { + cameraNestedProp.set(cameraData); + + var fullLayout = this.fullLayout; + var cameraFullNP = Lib.nestedProperty(fullLayout, this.id + '.camera'); + cameraFullNP.set(cameraData); + Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, cameraData); + } return hasChanged; }; @@ -125578,6 +127423,26 @@ proto.updateFx = function(dragmode, hovermode) { camera.mode = 'turntable'; camera.keyBindingMode = 'rotate'; + // The setter for camera.mode animates the transition to z-up, + // but only if we *don't* explicitly set z-up earlier via the + // relayout. So push `up` back to layout & fullLayout manually now. + var gd = this.graphDiv; + var fullLayout = gd._fullLayout; + var fullCamera = this.fullSceneLayout.camera; + var x = fullCamera.up.x; + var y = fullCamera.up.y; + var z = fullCamera.up.z; + // only push `up` back to (full)layout if it's going to change + if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) return; + + var attr = this.id + '.camera.up'; + var zUp = {x: 0, y: 0, z: 1}; + var edits = {}; + edits[attr] = zUp; + var layout = gd.layout; + Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, edits); + fullCamera.up = zUp; + Lib.nestedProperty(layout, attr).set(zUp); } else { // none rotation modes [pan or zoom] @@ -125654,7 +127519,7 @@ proto.setConvert = function() { module.exports = Scene; -},{"../../components/fx":612,"../../lib":696,"../../lib/show_no_webgl_msg":717,"../../lib/str2rgbarray":719,"../../plots/cartesian/axes":744,"../../registry":827,"./camera":786,"./layout/convert":791,"./layout/spikes":794,"./layout/tick_marks":795,"./project":796,"gl-plot3d":277,"has-passive-events":394,"webgl-context":533}],798:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../lib":692,"../../lib/show_no_webgl_msg":713,"../../lib/str2rgbarray":715,"../../plots/cartesian/axes":740,"../../registry":823,"./camera":782,"./layout/convert":787,"./layout/spikes":790,"./layout/tick_marks":791,"./project":792,"gl-plot3d":277,"has-passive-events":394,"webgl-context":532}],794:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125675,7 +127540,7 @@ module.exports = function zip3(x, y, z, len) { return result; }; -},{}],799:[function(_dereq_,module,exports){ +},{}],795:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125688,6 +127553,9 @@ module.exports = function zip3(x, y, z, len) { var fontAttrs = _dereq_('./font_attributes'); var colorAttrs = _dereq_('../components/color/attributes'); +var colorscaleAttrs = _dereq_('../components/colorscale/layout_attributes'); +var padAttrs = _dereq_('./pad_attributes'); +var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', @@ -125700,15 +127568,71 @@ globalFont.color.dflt = colorAttrs.defaultLine; module.exports = { font: globalFont, title: { - valType: 'string', - - editType: 'layoutstyle', - + text: { + valType: 'string', + + editType: 'layoutstyle', + + }, + font: fontAttrs({ + editType: 'layoutstyle', + + }), + xref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + yref: { + valType: 'enumerated', + dflt: 'container', + values: ['container', 'paper'], + + editType: 'layoutstyle', + + }, + x: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.5, + + editType: 'layoutstyle', + + }, + y: { + valType: 'number', + min: 0, + max: 1, + dflt: 'auto', + + editType: 'layoutstyle', + + }, + xanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'left', 'center', 'right'], + + editType: 'layoutstyle', + + }, + yanchor: { + valType: 'enumerated', + dflt: 'auto', + values: ['auto', 'top', 'middle', 'bottom'], + + editType: 'layoutstyle', + + }, + pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { + + }), + editType: 'layoutstyle' }, - titlefont: fontAttrs({ - editType: 'layoutstyle', - - }), autosize: { valType: 'boolean', @@ -125827,11 +127751,30 @@ module.exports = { editType: 'calc', }, + colorscale: colorscaleAttrs, datarevision: { valType: 'any', editType: 'calc', + }, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editrevision: { + valType: 'any', + + editType: 'none', + + }, + selectionrevision: { + valType: 'any', + + editType: 'none', + }, template: { valType: 'any', @@ -125865,12 +127808,30 @@ module.exports = { editType: 'modebar', + }, + uirevision: { + valType: 'any', + + editType: 'none', + }, editType: 'modebar' + }, + _deprecated: { + title: { + valType: 'string', + + editType: 'layoutstyle', + + }, + titlefont: fontAttrs({ + editType: 'layoutstyle', + + }) } }; -},{"../components/color/attributes":569,"./font_attributes":771}],800:[function(_dereq_,module,exports){ +},{"../components/color/attributes":568,"../components/colorscale/layout_attributes":582,"../lib/extend":682,"./font_attributes":767,"./pad_attributes":803}],796:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125913,7 +127874,7 @@ module.exports = { } }; -},{}],801:[function(_dereq_,module,exports){ +},{}],797:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -125986,7 +127947,7 @@ module.exports = function convertTextOpts(textposition, iconSize) { return { anchor: anchor, offset: offset }; }; -},{"../../lib":696}],802:[function(_dereq_,module,exports){ +},{"../../lib":692}],798:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126146,7 +128107,7 @@ exports.updateFx = function(gd) { } }; -},{"../../constants/xmlns_namespaces":674,"../../lib":696,"../../plots/get_data":781,"./constants":800,"./layout_attributes":804,"./layout_defaults":805,"./mapbox":806,"mapbox-gl":409}],803:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":670,"../../lib":692,"../../plots/get_data":777,"./constants":796,"./layout_attributes":800,"./layout_defaults":801,"./mapbox":802,"mapbox-gl":409}],799:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126366,7 +128327,7 @@ module.exports = function createMapboxLayer(mapbox, index, opts) { return mapboxLayer; }; -},{"../../lib":696,"./convert_text_opts":801}],804:[function(_dereq_,module,exports){ +},{"../../lib":692,"./convert_text_opts":797}],800:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126391,7 +128352,7 @@ var fontAttr = fontAttrs({ }); fontAttr.family.dflt = 'Open Sans Regular, Arial Unicode MS Regular'; -module.exports = overrideAll({ +var attrs = module.exports = overrideAll({ _arrayAttrRegexps: [Lib.counterRegex('mapbox', '.layers', true)], domain: domainAttrs({name: 'mapbox'}), @@ -126555,7 +128516,15 @@ module.exports = overrideAll({ }) }, 'plot', 'from-root'); -},{"../../components/color":570,"../../lib":696,"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../../traces/scatter/attributes":1043,"../domain":770,"../font_attributes":771}],805:[function(_dereq_,module,exports){ +// set uirevision outside of overrideAll so it can be `editType: 'none'` +attrs.uirevision = { + valType: 'any', + + editType: 'none', + +}; + +},{"../../components/color":569,"../../lib":692,"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../../traces/scatter/attributes":1040,"../domain":766,"../font_attributes":767}],801:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126644,7 +128613,7 @@ function handleLayerDefaults(layerIn, layerOut) { } } -},{"../../lib":696,"../array_container_defaults":740,"../subplot_defaults":822,"./layout_attributes":804}],806:[function(_dereq_,module,exports){ +},{"../../lib":692,"../array_container_defaults":736,"../subplot_defaults":818,"./layout_attributes":800}],802:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -126660,6 +128629,7 @@ var mapboxgl = _dereq_('mapbox-gl'); var Fx = _dereq_('../../components/fx'); var Lib = _dereq_('../../lib'); +var Registry = _dereq_('../../registry'); var dragElement = _dereq_('../../components/dragelement'); var prepSelect = _dereq_('../cartesian/select').prepSelect; var selectOnClick = _dereq_('../cartesian/select').selectOnClick; @@ -126784,22 +128754,22 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) { map.on('moveend', function(eventData) { if(!self.map) return; - var view = self.getView(); - - opts._input.center = opts.center = view.center; - opts._input.zoom = opts.zoom = view.zoom; - opts._input.bearing = opts.bearing = view.bearing; - opts._input.pitch = opts.pitch = view.pitch; - // 'moveend' gets triggered by map.setCenter, map.setZoom, // map.setBearing and map.setPitch. // - // Here, we make sure that 'plotly_relayout' is - // triggered here only when the 'moveend' originates from a + // Here, we make sure that state updates amd 'plotly_relayout' + // are triggered only when the 'moveend' originates from a // mouse target (filtering out API calls) to not // duplicate 'plotly_relayout' events. if(eventData.originalEvent || wheeling) { + var view = self.getView(); + + opts._input.center = opts.center = view.center; + opts._input.zoom = opts.zoom = view.zoom; + opts._input.bearing = opts.bearing = view.bearing; + opts._input.pitch = opts.pitch = view.pitch; + emitRelayoutFromView(view); } wheeling = false; @@ -126857,6 +128827,7 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) { for(var k in view) { evtData[id + '.' + k] = view[k]; } + Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, evtData); gd.emit('plotly_relayout', evtData); } @@ -126953,8 +128924,8 @@ proto.updateData = function(calcData) { }; proto.updateLayout = function(fullLayout) { - var map = this.map, - opts = this.opts; + var map = this.map; + var opts = this.opts; map.setCenter(convertCenter(opts.center)); map.setZoom(opts.zoom); @@ -127208,7 +129179,7 @@ function convertCenter(center) { return [center.lon, center.lat]; } -},{"../../components/dragelement":592,"../../components/fx":612,"../../lib":696,"../cartesian/select":762,"./constants":800,"./layers":803,"./layout_attributes":804,"mapbox-gl":409}],807:[function(_dereq_,module,exports){ +},{"../../components/dragelement":587,"../../components/fx":608,"../../lib":692,"../../registry":823,"../cartesian/select":758,"./constants":796,"./layers":799,"./layout_attributes":800,"mapbox-gl":409}],803:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -127219,42 +129190,51 @@ function convertCenter(center) { 'use strict'; -// This is used exclusively by components inside component arrays, -// hence the 'arraydraw' editType. If this ever gets used elsewhere -// we could generalize it as a function ala font_attributes -module.exports = { - t: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - r: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - b: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - l: { - valType: 'number', - dflt: 0, - - editType: 'arraydraw', - - }, - editType: 'arraydraw' +/** + * Creates a set of padding attributes. + * + * @param {object} opts + * @param {string} editType: + * the editType for all pieces of this padding definition + * + * @return {object} attributes object containing {t, r, b, l} as specified + */ +module.exports = function(opts) { + var editType = opts.editType; + return { + t: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + r: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + b: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + l: { + valType: 'number', + dflt: 0, + + editType: editType, + + }, + editType: editType + }; }; -},{}],808:[function(_dereq_,module,exports){ +},{}],804:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -127706,6 +129686,7 @@ plots.supplyDefaults = function(gd, opts) { for(i = 0; i < crossTraceDefaultsFuncs.length; i++) { crossTraceDefaultsFuncs[i](newFullData, newFullLayout); } + Registry.getComponentMethod('colorscale', 'crossTraceDefaults')(newFullData, newFullLayout); // turn on flag to optimize large splom-only graphs // mostly by omitting SVG layers during Cartesian.drawFramework @@ -127736,16 +129717,30 @@ plots.supplyDefaults = function(gd, opts) { // relink functions and _ attributes to promote consistency between plots relinkPrivateKeys(newFullLayout, oldFullLayout); - // TODO may return a promise - plots.doAutoMargin(gd); - - // set scale after auto margin routine - var axList = axisIDs.list(gd); - for(i = 0; i < axList.length; i++) { - var ax = axList[i]; - ax.setScale(); + // For persisting GUI-driven changes in layout + // _preGUI and _tracePreGUI were already copied over in relinkPrivateKeys + if(!newFullLayout._preGUI) newFullLayout._preGUI = {}; + // track trace GUI changes by uid rather than by trace index + if(!newFullLayout._tracePreGUI) newFullLayout._tracePreGUI = {}; + var tracePreGUI = newFullLayout._tracePreGUI; + var uids = {}; + var uid; + for(uid in tracePreGUI) uids[uid] = 'old'; + for(i = 0; i < newFullData.length; i++) { + uid = newFullData[i]._fullInput.uid; + if(!uids[uid]) tracePreGUI[uid] = {}; + uids[uid] = 'new'; + } + for(uid in uids) { + if(uids[uid] === 'old') delete tracePreGUI[uid]; } + // set up containers for margin calculations + initMargins(newFullLayout); + + // collect and do some initial calculations for rangesliders + Registry.getComponentMethod('rangeslider', 'makeData')(newFullLayout); + // update object references in calcdata if(!skipUpdateCalc && oldCalcdata.length === newFullData.length) { plots.supplyDefaultsUpdateCalc(oldCalcdata, newFullData); @@ -128054,6 +130049,12 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa plotinfo.id = id; } + // add these axis ids to each others' subplot lists + xaxis._counterAxes.push(yaxis._id); + yaxis._counterAxes.push(xaxis._id); + xaxis._subplotsWith.push(id); + yaxis._subplotsWith.push(id); + // update x and y axis layout object refs plotinfo.xaxis = xaxis; plotinfo.yaxis = yaxis; @@ -128081,8 +130082,9 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // while we're at it, link overlaying axes to their main axes and // anchored axes to the axes they're anchored to var axList = axisIDs.list(mockGd, null, true); + var ax; for(i = 0; i < axList.length; i++) { - var ax = axList[i]; + ax = axList[i]; var mainAx = null; if(ax.overlaying) { @@ -128110,8 +130112,53 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa null : axisIDs.getFromId(mockGd, ax.anchor); } + + // finally, we can find the main subplot for each axis + // (on which the ticks & labels are drawn) + for(i = 0; i < axList.length; i++) { + ax = axList[i]; + ax._counterAxes.sort(axisIDs.idSort); + ax._subplotsWith.sort(Lib.subplotSort); + ax._mainSubplot = findMainSubplot(ax, newFullLayout); + } }; +function findMainSubplot(ax, fullLayout) { + var mockGd = {_fullLayout: fullLayout}; + + var isX = ax._id.charAt(0) === 'x'; + var anchorAx = ax._mainAxis._anchorAxis; + var mainSubplotID = ''; + var nextBestMainSubplotID = ''; + var anchorID = ''; + + // First try the main ID with the anchor + if(anchorAx) { + anchorID = anchorAx._mainAxis._id; + mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); + } + + // Then look for a subplot with the counteraxis overlaying the anchor + // If that fails just use the first subplot including this axis + if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { + mainSubplotID = ''; + + var counterIDs = ax._counterAxes; + for(var j = 0; j < counterIDs.length; j++) { + var counterPart = counterIDs[j]; + var id = isX ? (ax._id + counterPart) : (counterPart + ax._id); + if(!nextBestMainSubplotID) nextBestMainSubplotID = id; + var counterAx = axisIDs.getFromId(mockGd, counterPart); + if(anchorID && counterAx.overlaying === anchorID) { + mainSubplotID = id; + break; + } + } + } + + return mainSubplotID || nextBestMainSubplotID; +} + // This function clears any trace attributes with valType: color and // no set dflt filed in the plot schema. This is needed because groupby (which // is the only transform for which this currently applies) supplies parent @@ -128379,6 +130426,8 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac coerce('type'); coerce('name', layout._traceWord + ' ' + traceInIndex); + coerce('uirevision', layout.uirevision); + // we want even invisible traces to make their would-be subplots visible // so coerce the subplot id(s) now no matter what var _module = plots.getModule(traceOut); @@ -128452,7 +130501,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac if(_module) { _module.supplyDefaults(traceIn, traceOut, defaultColor, layout); - Lib.coerceHoverinfo(traceIn, traceOut, layout); + if(!traceOut.hovertemplate) Lib.coerceHoverinfo(traceIn, traceOut, layout); } if(!Registry.traceIs(traceOut, 'noOpacity')) coerce('opacity'); @@ -128581,14 +130630,25 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { var globalFont = Lib.coerceFont(coerce, 'font'); - coerce('title', layoutOut._dfltTitle.plot); + coerce('title.text', layoutOut._dfltTitle.plot); - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: globalFont.family, size: Math.round(globalFont.size * 1.4), color: globalFont.color }); + coerce('title.xref'); + coerce('title.yref'); + coerce('title.x'); + coerce('title.y'); + coerce('title.xanchor'); + coerce('title.yanchor'); + coerce('title.pad.t'); + coerce('title.pad.r'); + coerce('title.pad.b'); + coerce('title.pad.l'); + // Make sure that autosize is defaulted to *true* // on layouts with no set width and height for backward compatibly, // in particular https://plot.ly/javascript/responsive-fluid-layout/ @@ -128621,12 +130681,16 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('colorway'); coerce('datarevision'); + var uirevision = coerce('uirevision'); + coerce('editrevision', uirevision); + coerce('selectionrevision', uirevision); coerce('modebar.orientation'); coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); + coerce('modebar.uirevision', uirevision); Registry.getComponentMethod( 'calendars', @@ -128908,7 +130972,20 @@ plots.allowAutoMargin = function(gd, id) { gd._fullLayout._pushmarginIds[id] = 1; }; -function setupAutoMargin(fullLayout) { +function initMargins(fullLayout) { + var margin = fullLayout.margin; + + if(!fullLayout._size) { + var gs = fullLayout._size = { + l: Math.round(margin.l), + r: Math.round(margin.r), + t: Math.round(margin.t), + b: Math.round(margin.b), + p: Math.round(margin.pad) + }; + gs.w = Math.round(fullLayout.width) - gs.l - gs.r; + gs.h = Math.round(fullLayout.height) - gs.t - gs.b; + } if(!fullLayout._pushmargin) fullLayout._pushmargin = {}; if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {}; } @@ -128931,8 +131008,6 @@ function setupAutoMargin(fullLayout) { plots.autoMargin = function(gd, id, o) { var fullLayout = gd._fullLayout; - setupAutoMargin(fullLayout); - var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -128976,18 +131051,19 @@ plots.autoMargin = function(gd, id, o) { plots.doAutoMargin = function(gd) { var fullLayout = gd._fullLayout; if(!fullLayout._size) fullLayout._size = {}; - setupAutoMargin(fullLayout); + initMargins(fullLayout); - var gs = fullLayout._size, - oldmargins = JSON.stringify(gs); + var gs = fullLayout._size; + var oldmargins = JSON.stringify(gs); + var margin = fullLayout.margin; // adjust margins for outside components // fullLayout.margin is the requested margin, // fullLayout._size has margins and plotsize after adjustment - var ml = Math.max(fullLayout.margin.l || 0, 0); - var mr = Math.max(fullLayout.margin.r || 0, 0); - var mt = Math.max(fullLayout.margin.t || 0, 0); - var mb = Math.max(fullLayout.margin.b || 0, 0); + var ml = margin.l; + var mr = margin.r; + var mt = margin.t; + var mb = margin.b; var pushMargin = fullLayout._pushmargin; var pushMarginIds = fullLayout._pushmarginIds; @@ -129057,7 +131133,7 @@ plots.doAutoMargin = function(gd) { gs.r = Math.round(mr); gs.t = Math.round(mt); gs.b = Math.round(mb); - gs.p = Math.round(fullLayout.margin.pad); + gs.p = Math.round(margin.pad); gs.w = Math.round(fullLayout.width) - gs.l - gs.r; gs.h = Math.round(fullLayout.height) - gs.t - gs.b; @@ -129938,7 +132014,7 @@ plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subpl subplot.traceHash = traceHash; }; -},{"../components/color":570,"../constants/numerical":673,"../lib":696,"../plot_api/plot_schema":733,"../plot_api/plot_template":734,"../plots/cartesian/axis_ids":747,"../registry":827,"./animation_attributes":739,"./attributes":741,"./command":769,"./font_attributes":771,"./frame_attributes":772,"./layout_attributes":799,"d3":148,"fast-isnumeric":214}],809:[function(_dereq_,module,exports){ +},{"../components/color":569,"../constants/numerical":669,"../lib":692,"../plot_api/plot_schema":729,"../plot_api/plot_template":730,"../plots/cartesian/axis_ids":743,"../registry":823,"./animation_attributes":735,"./attributes":737,"./command":765,"./font_attributes":767,"./frame_attributes":768,"./layout_attributes":795,"d3":148,"fast-isnumeric":214}],805:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -129983,7 +132059,7 @@ module.exports = { OFFEDGE: 20 }; -},{}],810:[function(_dereq_,module,exports){ +},{}],806:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -130278,7 +132354,7 @@ module.exports = { pathPolygonAnnulus: pathPolygonAnnulus }; -},{"../../lib":696,"../../lib/polygon":708}],811:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/polygon":704}],807:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -130367,7 +132443,7 @@ module.exports = { toSVG: _dereq_('../cartesian').toSVG }; -},{"../../lib":696,"../cartesian":756,"../get_data":781,"./constants":809,"./layout_attributes":812,"./layout_defaults":813,"./polar":820}],812:[function(_dereq_,module,exports){ +},{"../../lib":692,"../cartesian":752,"../get_data":777,"./constants":805,"./layout_attributes":808,"./layout_defaults":809,"./polar":816}],808:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -130427,7 +132503,9 @@ var axisTickAttrs = overrideAll({ var radialAxisAttrs = { visible: extendFlat({}, axesAttrs.visible, {dflt: true}), - type: axesAttrs.type, + type: extendFlat({}, axesAttrs.type, { + values: ['-', 'linear', 'log', 'date', 'category'] + }), autorange: extendFlat({}, axesAttrs.autorange, {editType: 'plot'}), rangemode: { @@ -130467,15 +132545,29 @@ var radialAxisAttrs = { }, - title: extendFlat({}, axesAttrs.title, {editType: 'plot', dflt: ''}), - titlefont: overrideAll(axesAttrs.titlefont, 'plot', 'from-root'), + title: overrideAll(axesAttrs.title, 'plot', 'from-root'), // might need a 'titleside' and even 'titledirection' down the road hoverformat: axesAttrs.hoverformat, - editType: 'calc' + uirevision: { + valType: 'any', + + editType: 'none', + + }, + + editType: 'calc', + + _deprecated: { + title: axesAttrs._deprecated.title, + titlefont: axesAttrs._deprecated.titlefont + } }; +// radial title is not gui-editable, so it needs dflt: '', similar to carpet axes. +radialAxisAttrs.title.text.dflt = ''; + extendFlat( radialAxisAttrs, @@ -130551,6 +132643,13 @@ var angularAxisAttrs = { hoverformat: axesAttrs.hoverformat, + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editType: 'calc' }; @@ -130617,10 +132716,17 @@ module.exports = { // TODO maybe? // annotations: + uirevision: { + valType: 'any', + + editType: 'none', + + }, + editType: 'calc' }; -},{"../../components/color/attributes":569,"../../lib":696,"../../plot_api/edit_types":727,"../cartesian/layout_attributes":757,"../domain":770}],813:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../lib":692,"../../plot_api/edit_types":723,"../cartesian/layout_attributes":753,"../domain":766}],809:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -130676,6 +132782,7 @@ function handleDefaults(contIn, contOut, coerce, opts) { var axIn = contIn[axName]; var axOut = Template.newContainer(contOut, axName); axOut._id = axOut._name = axName; + axOut._attr = opts.id + '.' + axName; axOut._traceIndices = subplotData.map(function(t) { return t._expandedIndex; }); var dataAttr = constants.axisName2dataArray[axName]; @@ -130689,6 +132796,8 @@ function handleDefaults(contIn, contOut, coerce, opts) { var visible = coerceAxis('visible'); setConvert(axOut, contOut, layoutOut); + coerceAxis('uirevision', contOut.uirevision); + var dfltColor; var dfltFontColor; @@ -130723,8 +132832,8 @@ function handleDefaults(contIn, contOut, coerce, opts) { coerceAxis('side'); coerceAxis('angle', sector[0]); - coerceAxis('title'); - Lib.coerceFont(coerceAxis, 'titlefont', { + coerceAxis('title.text'); + Lib.coerceFont(coerceAxis, 'title.font', { family: opts.font.family, size: Math.round(opts.font.size * 1.2), color: dfltFontColor @@ -130850,7 +132959,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { }); }; -},{"../../components/color":570,"../../lib":696,"../../plot_api/plot_template":734,"../cartesian/axis_autotype":745,"../cartesian/category_order_defaults":748,"../cartesian/line_grid_defaults":759,"../cartesian/tick_label_defaults":764,"../cartesian/tick_mark_defaults":765,"../cartesian/tick_value_defaults":766,"../get_data":781,"../subplot_defaults":822,"./constants":809,"./layout_attributes":812,"./set_convert":821}],814:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../plot_api/plot_template":730,"../cartesian/axis_autotype":741,"../cartesian/category_order_defaults":744,"../cartesian/line_grid_defaults":755,"../cartesian/tick_label_defaults":760,"../cartesian/tick_mark_defaults":761,"../cartesian/tick_value_defaults":762,"../get_data":777,"../subplot_defaults":818,"./constants":805,"./layout_attributes":808,"./set_convert":817}],810:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -130894,7 +133003,7 @@ module.exports = { } }; -},{"../../../lib/extend":685,"../../../traces/scatter/attributes":1043}],815:[function(_dereq_,module,exports){ +},{"../../../lib/extend":682,"../../../traces/scatter/attributes":1040}],811:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -131016,7 +133125,7 @@ module.exports = overrideAll({ } }, 'plot', 'nested'); -},{"../../../lib/extend":685,"../../../plot_api/edit_types":727,"../../cartesian/layout_attributes":757}],816:[function(_dereq_,module,exports){ +},{"../../../lib/extend":682,"../../../plot_api/edit_types":723,"../../cartesian/layout_attributes":753}],812:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -131031,7 +133140,7 @@ var Polar = module.exports = _dereq_('./micropolar'); Polar.manager = _dereq_('./micropolar_manager'); -},{"./micropolar":817,"./micropolar_manager":818}],817:[function(_dereq_,module,exports){ +},{"./micropolar":813,"./micropolar_manager":814}],813:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -131249,8 +133358,8 @@ var µ = module.exports = { version: '0.2.2' }; centeringOffset[0] = Math.max(0, centeringOffset[0]); centeringOffset[1] = Math.max(0, centeringOffset[1]); svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title); + if (axisConfig.title && axisConfig.title.text) { + var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); var titleBBox = title.node().getBBox(); title.attr({ x: chartCenter[0] - titleBBox.width / 2, @@ -132451,7 +134560,7 @@ var µ = module.exports = { version: '0.2.2' }; return exports; }; -},{"../../../constants/alignment":668,"../../../lib":696,"d3":148}],818:[function(_dereq_,module,exports){ +},{"../../../constants/alignment":664,"../../../lib":692,"d3":148}],814:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -132537,7 +134646,7 @@ manager.fillLayout = function(_gd) { _gd._fullLayout = extendDeepAll(dflts, _gd.layout); }; -},{"../../../components/color":570,"../../../lib":696,"./micropolar":817,"./undo_manager":819,"d3":148}],819:[function(_dereq_,module,exports){ +},{"../../../components/color":569,"../../../lib":692,"./micropolar":813,"./undo_manager":815,"d3":148}],815:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -132603,7 +134712,7 @@ module.exports = function UndoManager() { }; }; -},{}],820:[function(_dereq_,module,exports){ +},{}],816:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -132622,10 +134731,10 @@ var Lib = _dereq_('../../lib'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Plots = _dereq_('../plots'); +var Axes = _dereq_('../../plots/cartesian/axes'); var setConvertCartesian = _dereq_('../cartesian/set_convert'); var setConvertPolar = _dereq_('./set_convert'); var doAutoRange = _dereq_('../cartesian/autorange').doAutoRange; -var doTicksSingle = _dereq_('../cartesian/axes').doTicksSingle; var dragBox = _dereq_('../cartesian/dragbox'); var dragElement = _dereq_('../../components/dragelement'); var Fx = _dereq_('../../components/fx'); @@ -132671,7 +134780,7 @@ function Polar(gd, id) { .attr('class', id); // unfortunately, we have to keep track of some axis tick settings - // so that we don't have to call doTicksSingle with its special redraw flag + // as polar subplots do not implement the 'ticks' editType this.radialTickLayout = null; this.angularTickLayout = null; } @@ -132747,11 +134856,9 @@ proto.updateLayers = function(fullLayout, polarLayout) { break; case 'radial-grid': sel.style('fill', 'none'); - sel.append('g').classed('x', 1); break; case 'angular-grid': sel.style('fill', 'none'); - sel.append('g').classed('angularaxis', 1); break; case 'radial-line': sel.append('line').style('fill', 'none'); @@ -132773,14 +134880,15 @@ proto.updateLayers = function(fullLayout, polarLayout) { * * - this.radialAxis * extends polarLayout.radialaxis, adds mocked 'domain' and - * few other keys in order to reuse Cartesian doAutoRange and doTicksSingle, + * few other keys in order to reuse Cartesian doAutoRange and the Axes + * drawing routines. * used for calcdata -> geometric conversions (aka c2g) during the plot step * + setGeometry setups ax.c2g for given ax.range * + setScale setups ax._m,ax._b for given ax.range * * - this.angularAxis * extends polarLayout.angularaxis, adds mocked 'range' and 'domain' and - * a few other keys in order to reuse Cartesian doTicksSingle, + * a few other keys in order to reuse the Axes drawing routines. * used for calcdata -> geometric conversions (aka c2g) during the plot step * + setGeometry setups ax.c2g given ax.rotation, ax.direction & ax._categories, * and mocks ax.range @@ -132853,8 +134961,6 @@ proto.updateLayout = function(fullLayout, polarLayout) { var cyy = _this.cyy = cy - yOffset2; _this.radialAxis = _this.mockAxis(fullLayout, polarLayout, radialLayout, { - _axislayer: layers['radial-axis'], - _gridlayer: layers['radial-grid'], // make this an 'x' axis to make positioning (especially rotation) easier _id: 'x', // convert to 'x' axis equivalent @@ -132867,8 +134973,6 @@ proto.updateLayout = function(fullLayout, polarLayout) { }); _this.angularAxis = _this.mockAxis(fullLayout, polarLayout, angularLayout, { - _axislayer: layers['angular-axis'], - _gridlayer: layers['angular-grid'], side: 'right', // to get auto nticks right domain: [0, Math.PI], @@ -132901,28 +135005,19 @@ proto.updateLayout = function(fullLayout, polarLayout) { layers.frontplot .attr('transform', strTranslate(xOffset2, yOffset2)) - .call(Drawing.setClipUrl, _this._hasClipOnAxisFalse ? null : _this.clipIds.forTraces); + .call(Drawing.setClipUrl, _this._hasClipOnAxisFalse ? null : _this.clipIds.forTraces, _this.gd); layers.bg .attr('d', dPath) .attr('transform', strTranslate(cx, cy)) .call(Color.fill, polarLayout.bgcolor); - - // remove crispEdges - all the off-square angles in polar plots - // make these counterproductive. - _this.framework.selectAll('.crisp').classed('crisp', 0); }; proto.mockAxis = function(fullLayout, polarLayout, axLayout, opts) { var commonOpts = { // to get _boundingBox computation right when showticklabels is false anchor: 'free', - position: 0, - _pos: 0, - // dummy truthy value to make doTicksSingle draw the grid - _counteraxis: true, - // don't use automargins routine for labels - automargin: false + position: 0 }; var ax = Lib.extendFlat(commonOpts, axLayout, opts); @@ -132998,18 +135093,18 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) { // rotate auto tick labels by 180 if in quadrant II and III to make them // readable from left-to-right // - // TODO try moving deeper in doTicksSingle for better results? + // TODO try moving deeper in Axes.drawLabels for better results? if(ax.tickangle === 'auto' && (a0 > 90 && a0 <= 270)) { ax.tickangle = 180; } // easier to set rotate angle with custom translate function - ax._transfn = function(d) { + var transFn = function(d) { return 'translate(' + (ax.l2p(d.x) + innerRadius) + ',0)'; }; // set special grid path function - ax._gridpath = function(d) { + var gridPathFn = function(d) { return _this.pathArc(ax.r2p(d.x) + innerRadius); }; @@ -133021,7 +135116,36 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) { if(hasRoomForIt) { ax.setScale(); - doTicksSingle(gd, ax, true); + + var vals = Axes.calcTicks(ax); + var valsClipped = Axes.clipEnds(ax, vals); + var labelFns = Axes.makeLabelFns(ax, 0); + var tickSign = Axes.getTickSigns(ax)[2]; + + Axes.drawTicks(gd, ax, { + vals: vals, + layer: layers['radial-axis'], + path: Axes.makeTickPath(ax, 0, tickSign), + transFn: transFn, + crisp: false + }); + + Axes.drawGrid(gd, ax, { + vals: valsClipped, + layer: layers['radial-grid'], + path: gridPathFn, + transFn: Lib.noop, + crisp: false + }); + + Axes.drawLabels(gd, ax, { + vals: vals, + layer: layers['radial-axis'], + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); } // stash 'actual' radial axis angle for drag handlers (in degrees) @@ -133029,21 +135153,20 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) { rad2deg(snapToVertexAngle(deg2rad(radialLayout.angle), _this.vangles)) : radialLayout.angle; - var trans = strTranslate(cx, cy) + strRotate(-angle); + var tLayer = strTranslate(cx, cy); + var tLayer2 = tLayer + strRotate(-angle); updateElement( layers['radial-axis'], hasRoomForIt && (radialLayout.showticklabels || radialLayout.ticks), - {transform: trans} + {transform: tLayer2} ); - // move all grid paths to about circle center, - // undo individual grid lines translations updateElement( layers['radial-grid'], hasRoomForIt && radialLayout.showgrid, - {transform: strTranslate(cx, cy)} - ).selectAll('path').attr('transform', null); + {transform: tLayer} + ); updateElement( layers['radial-line'].select('line'), @@ -133053,7 +135176,7 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) { y1: 0, x2: radius, y2: 0, - transform: trans + transform: tLayer2 } ) .attr('stroke-width', radialLayout.linewidth) @@ -133075,9 +135198,13 @@ proto.updateRadialAxisTitle = function(fullLayout, polarLayout, _angle) { var sina = Math.sin(angleRad); var pad = 0; + + // Hint: no need to check if there is in fact a title.text set + // because if plot is editable, pad needs to be calculated anyways + // to properly show placeholder text when title is empty. if(radialLayout.title) { var h = Drawing.bBox(_this.layers['radial-axis'].node()).height; - var ts = radialLayout.titlefont.size; + var ts = radialLayout.title.font.size; pad = radialLayout.side === 'counterclockwise' ? -h - ts * 0.4 : h + ts * 0.8; @@ -133110,6 +135237,7 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { _this.fillViewInitialKey('angularaxis.rotation', angularLayout.rotation); ax.setGeometry(); + ax.setScale(); // 't'ick to 'g'eometric radians is used all over the place here var t2g = function(d) { return ax.t2g(d.x); }; @@ -133120,34 +135248,20 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { ax.dtick = rad2deg(ax.dtick); } - // Use tickval filter for category axes instead of tweaking - // the range w.r.t sector, so that sectors that cross 360 can - // show all their ticks. - if(ax.type === 'category') { - ax._tickFilter = function(d) { - return Lib.isAngleInsideSector(t2g(d), _this.sectorInRad); - }; - } - - ax._transfn = function(d) { - var sel = d3.select(this); - var hasElement = sel && sel.node(); + var _transFn = function(rad) { + return strTranslate(cx + radius * Math.cos(rad), cy - radius * Math.sin(rad)); + }; - // don't translate grid lines - if(hasElement && sel.classed('angularaxisgrid')) return ''; + var transFn = function(d) { + return _transFn(t2g(d)); + }; + var transFn2 = function(d) { var rad = t2g(d); - var out = strTranslate(cx + radius * Math.cos(rad), cy - radius * Math.sin(rad)); - - // must also rotate ticks, but don't rotate labels - if(hasElement && sel.classed('ticks')) { - out += strRotate(-rad2deg(rad)); - } - - return out; + return _transFn(rad) + strRotate(-rad2deg(rad)); }; - ax._gridpath = function(d) { + var gridPathFn = function(d) { var rad = t2g(d); var cosRad = Math.cos(rad); var sinRad = Math.sin(rad); @@ -133155,12 +135269,14 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { 'L' + [cx + radius * cosRad, cy - radius * sinRad]; }; + var out = Axes.makeLabelFns(ax, 0); + var labelStandoff = out.labelStandoff; + var labelShift = out.labelShift; var offset4fontsize = (angularLayout.ticks !== 'outside' ? 0.7 : 0.5); + var pad = (ax.linewidth || 1) / 2; - ax._labelx = function(d) { + var labelXFn = function(d) { var rad = t2g(d); - var labelStandoff = ax._labelStandoff; - var pad = ax._pad; var offset4tx = signSin(rad) === 0 ? 0 : @@ -133170,11 +135286,8 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { return offset4tx + offset4tick; }; - ax._labely = function(d) { + var labelYFn = function(d) { var rad = t2g(d); - var labelStandoff = ax._labelStandoff; - var labelShift = ax._labelShift; - var pad = ax._pad; var offset4tx = d.dy + d.fontSize * MID_SHIFT - labelShift; var offset4tick = -Math.sin(rad) * (labelStandoff + pad + offset4fontsize * d.fontSize); @@ -133182,7 +135295,8 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { return offset4tx + offset4tick; }; - ax._labelanchor = function(angle, d) { + // TODO maybe switch angle, d ordering ?? + var labelAnchorFn = function(angle, d) { var rad = t2g(d); return signSin(rad) === 0 ? (signCos(rad) > 0 ? 'start' : 'end') : @@ -133195,14 +135309,13 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { _this.angularTickLayout = newTickLayout; } - ax.setScale(); - doTicksSingle(gd, ax, true); + var vals = Axes.calcTicks(ax); // angle of polygon vertices in geometric radians (null means circles) // TODO what to do when ax.period > ax._categories ?? var vangles; if(polarLayout.gridshape === 'linear') { - vangles = ax._vals.map(t2g); + vangles = vals.map(t2g); // ax._vals should be always ordered, make them // always turn counterclockwise for convenience here @@ -133214,6 +135327,45 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) { } _this.vangles = vangles; + // Use tickval filter for category axes instead of tweaking + // the range w.r.t sector, so that sectors that cross 360 can + // show all their ticks. + if(ax.type === 'category') { + vals = vals.filter(function(d) { + return Lib.isAngleInsideSector(t2g(d), _this.sectorInRad); + }); + } + + if(ax.visible) { + var tickSign = ax.ticks === 'inside' ? -1 : 1; + + Axes.drawTicks(gd, ax, { + vals: vals, + layer: layers['angular-axis'], + path: 'M' + (tickSign * pad) + ',0h' + (tickSign * ax.ticklen), + transFn: transFn2, + crisp: false + }); + + Axes.drawGrid(gd, ax, { + vals: vals, + layer: layers['angular-grid'], + path: gridPathFn, + transFn: Lib.noop, + crisp: false + }); + + Axes.drawLabels(gd, ax, { + vals: vals, + layer: layers['angular-axis'], + repositionOnUpdate: true, + transFn: transFn, + labelXFn: labelXFn, + labelYFn: labelYFn, + labelAnchorFn: labelAnchorFn + }); + } + // TODO maybe two arcs is better here? // maybe split style attributes between inner and outer angular axes? @@ -133470,7 +135622,7 @@ proto.updateMainDrag = function(fullLayout) { rl[0] + (r0 - innerRadius) * m, rl[0] + (r1 - innerRadius) * m ]; - Registry.call('relayout', gd, _this.id + '.radialaxis.range', newRng); + Registry.call('_guiRelayout', gd, _this.id + '.radialaxis.range', newRng); } function zoomClick(numClicks, evt) { @@ -133486,7 +135638,7 @@ proto.updateMainDrag = function(fullLayout) { } gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, updateObj); + Registry.call('_guiRelayout', gd, updateObj); } if(clickMode.indexOf('select') > -1 && numClicks === 1) { @@ -133613,9 +135765,9 @@ proto.updateRadialDrag = function(fullLayout, polarLayout, rngIndex) { function doneFn() { if(angle1 !== null) { - Registry.call('relayout', gd, _this.id + '.radialaxis.angle', angle1); + Registry.call('_guiRelayout', gd, _this.id + '.radialaxis.angle', angle1); } else if(rprime !== null) { - Registry.call('relayout', gd, _this.id + '.radialaxis.range[' + rngIndex + ']', rprime); + Registry.call('_guiRelayout', gd, _this.id + '.radialaxis.range[' + rngIndex + ']', rprime); } } @@ -133650,29 +135802,25 @@ proto.updateRadialDrag = function(fullLayout, polarLayout, rngIndex) { return; } + var fullLayoutNow = gd._fullLayout; + var polarLayoutNow = fullLayoutNow[_this.id]; + // update radial range -> update c2g -> update _m,_b radialAxis.range[rngIndex] = rprime; radialAxis._rl[rngIndex] = rprime; - radialAxis.setGeometry(); - radialAxis.setScale(); + _this.updateRadialAxis(fullLayoutNow, polarLayoutNow); _this.xaxis.setRange(); _this.xaxis.setScale(); _this.yaxis.setRange(); _this.yaxis.setScale(); - doTicksSingle(gd, radialAxis, true); - layers['radial-grid'] - .attr('transform', strTranslate(cx, cy)) - .selectAll('path').attr('transform', null); - var hasRegl = false; for(var traceType in _this.traceHash) { var moduleCalcData = _this.traceHash[traceType]; var moduleCalcDataVisible = Lib.filterVisible(moduleCalcData); var _module = moduleCalcData[0][0].trace._module; - var polarLayoutNow = gd._fullLayout[_this.id]; _module.plot(gd, _this, moduleCalcDataVisible, polarLayoutNow); if(Registry.traceIs(traceType, 'gl') && moduleCalcDataVisible.length) hasRegl = true; } @@ -133746,6 +135894,7 @@ proto.updateAngularDrag = function(fullLayout) { function moveFn(dx, dy) { var fullLayoutNow = _this.gd._fullLayout; var polarLayoutNow = fullLayoutNow[_this.id]; + var x1 = x0 + dx; var y1 = y0 + dy; var a1 = xy2a(x1, y1); @@ -133764,7 +135913,6 @@ proto.updateAngularDrag = function(fullLayout) { layers.bg.attr('transform', trans); layers['radial-grid'].attr('transform', trans); - layers['angular-line'].select('path').attr('transform', trans); layers['radial-axis'].attr('transform', trans2); layers['radial-line'].select('line').attr('transform', trans2); _this.updateRadialAxisTitle(fullLayoutNow, polarLayoutNow, rrot1); @@ -133790,10 +135938,7 @@ proto.updateAngularDrag = function(fullLayout) { // update rotation -> range -> _m,_b angularAxis.rotation = Lib.modHalf(rot1, 360); - angularAxis.setGeometry(); - angularAxis.setScale(); - - doTicksSingle(gd, angularAxis, true); + _this.updateAngularAxis(fullLayoutNow, polarLayoutNow); if(_this._hasClipOnAxisFalse && !Lib.isFullCircle(_this.sectorInRad)) { scatterTraces.call(Drawing.hideOutsideRangePoints, _this); @@ -133827,7 +135972,7 @@ proto.updateAngularDrag = function(fullLayout) { updateObj[_this.id + '.radialaxis.angle'] = rrot1; } - Registry.call('relayout', gd, updateObj); + Registry.call('_guiRelayout', gd, updateObj); } dragOpts.prepFn = function(evt, startX, startY) { @@ -133999,7 +136144,7 @@ function signSin(v) { return sign(Math.sin(v)); } -},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../components/titles":661,"../../constants/alignment":668,"../../lib":696,"../../lib/clear_gl_canvases":680,"../../lib/setcursor":716,"../../plot_api/subroutines":735,"../../registry":827,"../cartesian/autorange":743,"../cartesian/axes":744,"../cartesian/dragbox":753,"../cartesian/select":762,"../cartesian/set_convert":763,"../plots":808,"./constants":809,"./helpers":810,"./set_convert":821,"d3":148,"tinycolor2":514}],821:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../components/titles":657,"../../constants/alignment":664,"../../lib":692,"../../lib/clear_gl_canvases":677,"../../lib/setcursor":712,"../../plot_api/subroutines":731,"../../plots/cartesian/axes":740,"../../registry":823,"../cartesian/autorange":739,"../cartesian/dragbox":749,"../cartesian/select":758,"../cartesian/set_convert":759,"../plots":804,"./constants":805,"./helpers":806,"./set_convert":817,"d3":148,"tinycolor2":513}],817:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -134191,7 +136336,7 @@ function setConvertAngular(ax, polarLayout) { }; } -},{"../../lib":696,"../cartesian/set_convert":763}],822:[function(_dereq_,module,exports){ +},{"../../lib":692,"../cartesian/set_convert":759}],818:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -134261,6 +136406,12 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o subplotLayoutOut = Template.newContainer(layoutOut, id, baseId); + // All subplot containers get a `uirevision` inheriting from the base. + // Currently all subplots containers have some user interaction + // attributes, but if we ever add one that doesn't, we would need an + // option to skip this step. + coerce('uirevision', layoutOut.uirevision); + var dfltDomains = {}; dfltDomains[partition] = [i / idsLength, (i + 1) / idsLength]; handleDomainDefaults(subplotLayoutOut, layoutOut, coerce, dfltDomains); @@ -134270,7 +136421,7 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o } }; -},{"../lib":696,"../plot_api/plot_template":734,"./domain":770}],823:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/plot_template":730,"./domain":766}],819:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -134354,7 +136505,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../lib":696,"../../plots/get_data":781,"./layout_attributes":824,"./layout_defaults":825,"./ternary":826}],824:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/get_data":777,"./layout_attributes":820,"./layout_defaults":821,"./ternary":822}],820:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -134374,7 +136525,6 @@ var extendFlat = _dereq_('../../lib/extend').extendFlat; var ternaryAxesAttrs = { title: axesAttrs.title, - titlefont: axesAttrs.titlefont, color: axesAttrs.color, // ticks tickmode: axesAttrs.tickmode, @@ -134415,10 +136565,14 @@ var ternaryAxesAttrs = { min: 0, + }, + _deprecated: { + title: axesAttrs._deprecated.title, + titlefont: axesAttrs._deprecated.titlefont } }; -module.exports = overrideAll({ +var attrs = module.exports = overrideAll({ domain: domainAttrs({name: 'ternary'}), bgcolor: { @@ -134439,7 +136593,22 @@ module.exports = overrideAll({ caxis: ternaryAxesAttrs }, 'plot', 'from-root'); -},{"../../components/color/attributes":569,"../../lib/extend":685,"../../plot_api/edit_types":727,"../cartesian/layout_attributes":757,"../domain":770}],825:[function(_dereq_,module,exports){ +// set uirevisions outside of `overrideAll` so we can get `editType: none` +attrs.uirevision = { + valType: 'any', + + editType: 'none', + +}; + +attrs.aaxis.uirevision = attrs.baxis.uirevision = attrs.caxis.uirevision = { + valType: 'any', + + editType: 'none', + +}; + +},{"../../components/color/attributes":568,"../../lib/extend":682,"../../plot_api/edit_types":723,"../cartesian/layout_attributes":753,"../domain":766}],821:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -134488,7 +136657,7 @@ function handleTernaryDefaults(ternaryLayoutIn, ternaryLayoutOut, coerce, option containerOut = Template.newContainer(ternaryLayoutOut, axName); containerOut._name = axName; - handleAxisDefaults(containerIn, containerOut, options); + handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut); } // if the min values contradict each other, set them all to default (0) @@ -134507,13 +136676,15 @@ function handleTernaryDefaults(ternaryLayoutIn, ternaryLayoutOut, coerce, option } } -function handleAxisDefaults(containerIn, containerOut, options) { +function handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut) { var axAttrs = layoutAttributes[containerOut._name]; function coerce(attr, dflt) { return Lib.coerce(containerIn, containerOut, axAttrs, attr, dflt); } + coerce('uirevision', ternaryLayoutOut.uirevision); + containerOut.type = 'linear'; // no other types allowed for ternary var dfltColor = coerce('color'); @@ -134525,10 +136696,10 @@ function handleAxisDefaults(containerIn, containerOut, options) { letterUpper = axName.charAt(0).toUpperCase(), dfltTitle = 'Component ' + letterUpper; - var title = coerce('title', dfltTitle); + var title = coerce('title.text', dfltTitle); containerOut._hovertitle = title === dfltTitle ? title : letterUpper; - Lib.coerceFont(coerce, 'titlefont', { + Lib.coerceFont(coerce, 'title.font', { family: options.font.family, size: Math.round(options.font.size * 1.2), color: dfltFontColor @@ -134569,7 +136740,7 @@ function handleAxisDefaults(containerIn, containerOut, options) { coerce('layer'); } -},{"../../components/color":570,"../../lib":696,"../../plot_api/plot_template":734,"../cartesian/line_grid_defaults":759,"../cartesian/tick_label_defaults":764,"../cartesian/tick_mark_defaults":765,"../cartesian/tick_value_defaults":766,"../subplot_defaults":822,"./layout_attributes":824}],826:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../plot_api/plot_template":730,"../cartesian/line_grid_defaults":755,"../cartesian/tick_label_defaults":760,"../cartesian/tick_mark_defaults":761,"../cartesian/tick_value_defaults":762,"../subplot_defaults":818,"./layout_attributes":820}],822:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -134649,6 +136820,7 @@ proto.plot = function(ternaryCalcData, fullLayout) { proto.makeFramework = function(fullLayout) { var _this = this; + var gd = _this.graphDiv; var ternaryLayout = fullLayout[_this.id]; var clipId = _this.clipId = 'clip' + _this.layoutId + _this.id; @@ -134668,8 +136840,8 @@ proto.makeFramework = function(fullLayout) { _this.plotContainer = Lib.ensureSingle(_this.container, 'g', _this.id); _this.updateLayers(ternaryLayout); - Drawing.setClipUrl(_this.layers.backplot, clipId); - Drawing.setClipUrl(_this.layers.grids, clipId); + Drawing.setClipUrl(_this.layers.backplot, clipId, gd); + Drawing.setClipUrl(_this.layers.grids, clipId, gd); }; proto.updateLayers = function(ternaryLayout) { @@ -134730,9 +136902,6 @@ proto.updateLayers = function(ternaryLayout) { } else if(d === 'grids') { grids.forEach(function(d) { layers[d] = s.append('g').classed('grid ' + d, true); - - var fictID = (d === 'bgrid') ? 'x' : 'y'; - layers[d].append('g').classed(fictID, true); }); } }); @@ -134822,23 +136991,16 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { // fictitious angles and domain, but then rotate and translate // it into place at the end var aaxis = _this.aaxis = extendFlat({}, ternaryLayout.aaxis, { - visible: true, range: [amin, sum - bmin - cmin], side: 'left', - _counterangle: 30, // tickangle = 'auto' means 0 anyway for a y axis, need to coerce to 0 here // so we can shift by 30. tickangle: (+ternaryLayout.aaxis.tickangle || 0) - 30, domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h], - _axislayer: _this.layers.aaxis, - _gridlayer: _this.layers.agrid, anchor: 'free', position: 0, - _pos: 0, // _this.xaxis.domain[0] * graphSize.w, _id: 'y', - _length: w, - _gridpath: 'M0,0l' + h + ',-' + (w / 2), - automargin: false // don't use automargins routine for labels + _length: w }); setConvert(aaxis, _this.graphDiv._fullLayout); aaxis.setScale(); @@ -134846,45 +137008,28 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { // baxis goes across the bottom (backward). We can set it up as an x axis // without any enclosing transformation. var baxis = _this.baxis = extendFlat({}, ternaryLayout.baxis, { - visible: true, range: [sum - amin - cmin, bmin], side: 'bottom', - _counterangle: 30, domain: _this.xaxis.domain, - _axislayer: _this.layers.baxis, - _gridlayer: _this.layers.bgrid, - _counteraxis: _this.aaxis, anchor: 'free', position: 0, - _pos: 0, // (1 - yDomain0) * graphSize.h, _id: 'x', - _length: w, - _gridpath: 'M0,0l-' + (w / 2) + ',-' + h, - automargin: false // don't use automargins routine for labels + _length: w }); setConvert(baxis, _this.graphDiv._fullLayout); baxis.setScale(); - aaxis._counteraxis = baxis; // caxis goes down the right side. Set it up as a y axis, with // post-transformation similar to aaxis var caxis = _this.caxis = extendFlat({}, ternaryLayout.caxis, { - visible: true, range: [sum - amin - bmin, cmin], side: 'right', - _counterangle: 30, tickangle: (+ternaryLayout.caxis.tickangle || 0) + 30, domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h], - _axislayer: _this.layers.caxis, - _gridlayer: _this.layers.cgrid, - _counteraxis: _this.baxis, anchor: 'free', position: 0, - _pos: 0, // _this.xaxis.domain[1] * graphSize.w, _id: 'y', - _length: w, - _gridpath: 'M0,0l-' + h + ',' + (w / 2), - automargin: false // don't use automargins routine for labels + _length: w }); setConvert(caxis, _this.graphDiv._fullLayout); caxis.setScale(); @@ -134922,10 +137067,6 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { _this.drawAxes(true); - // remove crispEdges - all the off-square angles in ternary plots - // make these counterproductive. - _this.plotContainer.selectAll('.crisp').classed('crisp', false); - _this.layers.aline.select('path') .attr('d', aaxis.showline ? 'M' + x0 + ',' + (y0 + h) + 'l' + (w / 2) + ',-' + h : 'M0,0') @@ -134948,7 +137089,8 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { Drawing.setClipUrl( _this.layers.frontplot, - _this._hasClipOnAxisFalse ? null : _this.clipId + _this._hasClipOnAxisFalse ? null : _this.clipId, + _this.graphDiv ); }; @@ -134960,80 +137102,122 @@ proto.drawAxes = function(doTitles) { var aaxis = _this.aaxis; var baxis = _this.baxis; var caxis = _this.caxis; - var newTickLayout; - newTickLayout = strTickLayout(aaxis); - if(_this.aTickLayout !== newTickLayout) { - layers.aaxis.selectAll('.ytick').remove(); - _this.aTickLayout = newTickLayout; - } - - newTickLayout = strTickLayout(baxis); - if(_this.bTickLayout !== newTickLayout) { - layers.baxis.selectAll('.xtick').remove(); - _this.bTickLayout = newTickLayout; - } - - newTickLayout = strTickLayout(caxis); - if(_this.cTickLayout !== newTickLayout) { - layers.caxis.selectAll('.ytick').remove(); - _this.cTickLayout = newTickLayout; - } - - // 3rd arg true below skips titles, so we can configure them - // correctly later on. - Axes.doTicksSingle(gd, aaxis, true); - Axes.doTicksSingle(gd, baxis, true); - Axes.doTicksSingle(gd, caxis, true); + _this.drawAx(aaxis); + _this.drawAx(baxis); + _this.drawAx(caxis); if(doTitles) { var apad = Math.max(aaxis.showticklabels ? aaxis.tickfont.size / 2 : 0, (caxis.showticklabels ? caxis.tickfont.size * 0.75 : 0) + (caxis.ticks === 'outside' ? caxis.ticklen * 0.87 : 0)); - _this.layers['a-title'] = Titles.draw(gd, 'a' + titlesuffix, { + var bpad = (baxis.showticklabels ? baxis.tickfont.size : 0) + + (baxis.ticks === 'outside' ? baxis.ticklen : 0) + 3; + + layers['a-title'] = Titles.draw(gd, 'a' + titlesuffix, { propContainer: aaxis, propName: _this.id + '.aaxis.title', placeholder: _(gd, 'Click to enter Component A title'), attributes: { x: _this.x0 + _this.w / 2, - y: _this.y0 - aaxis.titlefont.size / 3 - apad, + y: _this.y0 - aaxis.title.font.size / 3 - apad, 'text-anchor': 'middle' } }); - - - var bpad = (baxis.showticklabels ? baxis.tickfont.size : 0) + - (baxis.ticks === 'outside' ? baxis.ticklen : 0) + 3; - - _this.layers['b-title'] = Titles.draw(gd, 'b' + titlesuffix, { + layers['b-title'] = Titles.draw(gd, 'b' + titlesuffix, { propContainer: baxis, propName: _this.id + '.baxis.title', placeholder: _(gd, 'Click to enter Component B title'), attributes: { x: _this.x0 - bpad, - y: _this.y0 + _this.h + baxis.titlefont.size * 0.83 + bpad, + y: _this.y0 + _this.h + baxis.title.font.size * 0.83 + bpad, 'text-anchor': 'middle' } }); - - _this.layers['c-title'] = Titles.draw(gd, 'c' + titlesuffix, { + layers['c-title'] = Titles.draw(gd, 'c' + titlesuffix, { propContainer: caxis, propName: _this.id + '.caxis.title', placeholder: _(gd, 'Click to enter Component C title'), attributes: { x: _this.x0 + _this.w + bpad, - y: _this.y0 + _this.h + caxis.titlefont.size * 0.83 + bpad, + y: _this.y0 + _this.h + caxis.title.font.size * 0.83 + bpad, 'text-anchor': 'middle' } }); } }; +proto.drawAx = function(ax) { + var _this = this; + var gd = _this.graphDiv; + var axName = ax._name; + var axLetter = axName.charAt(0); + var axId = ax._id; + var axLayer = _this.layers[axName]; + var counterAngle = 30; + + var stashKey = axLetter + 'tickLayout'; + var newTickLayout = strTickLayout(ax); + if(_this[stashKey] !== newTickLayout) { + axLayer.selectAll('.' + axId + 'tick').remove(); + _this[stashKey] = newTickLayout; + } + + ax.setScale(); + + var vals = Axes.calcTicks(ax); + var valsClipped = Axes.clipEnds(ax, vals); + var transFn = Axes.makeTransFn(ax); + var tickSign = Axes.getTickSigns(ax)[2]; + + var caRad = Lib.deg2rad(counterAngle); + var pad = tickSign * (ax.linewidth || 1) / 2; + var len = tickSign * ax.ticklen; + var w = _this.w; + var h = _this.h; + + var tickPath = axLetter === 'b' ? + 'M0,' + pad + 'l' + (Math.sin(caRad) * len) + ',' + (Math.cos(caRad) * len) : + 'M' + pad + ',0l' + (Math.cos(caRad) * len) + ',' + (-Math.sin(caRad) * len); + + var gridPath = { + a: 'M0,0l' + h + ',-' + (w / 2), + b: 'M0,0l-' + (w / 2) + ',-' + h, + c: 'M0,0l-' + h + ',' + (w / 2) + }[axLetter]; + + Axes.drawTicks(gd, ax, { + vals: ax.ticks === 'inside' ? valsClipped : vals, + layer: axLayer, + path: tickPath, + transFn: transFn, + crisp: false + }); + + Axes.drawGrid(gd, ax, { + vals: valsClipped, + layer: _this.layers[axLetter + 'grid'], + path: gridPath, + transFn: transFn, + crisp: false + }); + + var labelFns = Axes.makeLabelFns(ax, 0, counterAngle); + + Axes.drawLabels(gd, ax, { + vals: vals, + layer: axLayer, + transFn: transFn, + labelXFn: labelFns.labelXFn, + labelYFn: labelFns.labelYFn, + labelAnchorFn: labelFns.labelAnchorFn + }); +}; + function strTickLayout(axLayout) { return axLayout.ticks + String(axLayout.ticklen) + String(axLayout.showticklabels); } - // hard coded paths for zoom corners // uses the same sizing as cartesian, length is MINZOOM/2, width is 3px var CLEN = constants.MINZOOM / 2 + 0.87; @@ -135099,18 +137283,22 @@ proto.initInteractions = function() { var x0, y0, mins0, span0, mins, lum, path0, dimmed, zb, corners; + function makeUpdate(_mins) { + var attrs = {}; + attrs[_this.id + '.aaxis.min'] = _mins.a; + attrs[_this.id + '.baxis.min'] = _mins.b; + attrs[_this.id + '.caxis.min'] = _mins.c; + return attrs; + } + function clickZoomPan(numClicks, evt) { var clickMode = gd._fullLayout.clickmode; removeZoombox(gd); if(numClicks === 2) { - var attrs = {}; - attrs[_this.id + '.aaxis.min'] = 0; - attrs[_this.id + '.baxis.min'] = 0; - attrs[_this.id + '.caxis.min'] = 0; gd.emit('plotly_doubleclick', null); - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, makeUpdate({a: 0, b: 0, c: 0})); } if(clickMode.indexOf('select') > -1 && numClicks === 1) { @@ -135214,12 +137402,7 @@ proto.initInteractions = function() { if(mins === mins0) return; - var attrs = {}; - attrs[_this.id + '.aaxis.min'] = mins.a; - attrs[_this.id + '.baxis.min'] = mins.b; - attrs[_this.id + '.caxis.min'] = mins.c; - - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, makeUpdate(mins)); if(SHOWZOOMOUTTIP && gd.data && gd._context.showTips) { Lib.notifier(_(gd, 'Double-click to zoom back out'), 'long'); @@ -135283,7 +137466,6 @@ proto.initInteractions = function() { _this.caxis.range = [_this.sum - mins.a - mins.b, mins.c]; _this.drawAxes(false); - _this.plotContainer.selectAll('.crisp').classed('crisp', false); if(_this._hasClipOnAxisFalse) { _this.plotContainer @@ -135293,12 +137475,7 @@ proto.initInteractions = function() { } function dragDone() { - var attrs = {}; - attrs[_this.id + '.aaxis.min'] = mins.a; - attrs[_this.id + '.baxis.min'] = mins.b; - attrs[_this.id + '.caxis.min'] = mins.c; - - Registry.call('relayout', gd, attrs); + Registry.call('_guiRelayout', gd, makeUpdate(mins)); } // finally, set up hover and click @@ -135325,7 +137502,7 @@ function removeZoombox(gd) { .remove(); } -},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../components/titles":661,"../../lib":696,"../../lib/extend":685,"../../registry":827,"../cartesian/axes":744,"../cartesian/constants":750,"../cartesian/select":762,"../cartesian/set_convert":763,"../plots":808,"d3":148,"tinycolor2":514}],827:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../components/titles":657,"../../lib":692,"../../lib/extend":682,"../../registry":823,"../cartesian/axes":740,"../cartesian/constants":746,"../cartesian/select":758,"../cartesian/set_convert":759,"../plots":804,"d3":148,"tinycolor2":513}],823:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -135767,7 +137944,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/extend":685,"./lib/is_plain_object":697,"./lib/loggers":700,"./lib/noop":705,"./lib/push_unique":710,"./plots/attributes":741,"./plots/layout_attributes":799}],828:[function(_dereq_,module,exports){ +},{"./lib/extend":682,"./lib/is_plain_object":693,"./lib/loggers":696,"./lib/noop":701,"./lib/push_unique":706,"./plots/attributes":737,"./plots/layout_attributes":795}],824:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -135794,7 +137971,7 @@ function cloneLayoutOverride(tileClass) { autosize: true, width: 150, height: 150, - title: '', + title: {text: ''}, showlegend: false, margin: {l: 5, r: 5, t: 5, b: 5, pad: 0}, annotations: [] @@ -135803,7 +137980,7 @@ function cloneLayoutOverride(tileClass) { case 'thumbnail': override = { - title: '', + title: {text: ''}, hidesources: true, showlegend: false, borderwidth: 0, @@ -135851,7 +138028,7 @@ module.exports = function clonePlot(graphObj, options) { for(i = 0; i < keys.length; i++) { if(keyIsAxis(keys[i])) { - newLayout[keys[i]].title = ''; + newLayout[keys[i]].title = {text: ''}; } } @@ -135879,7 +138056,7 @@ module.exports = function clonePlot(graphObj, options) { var axesImageOverride = {}; if(options.tileClass === 'thumbnail') { axesImageOverride = { - title: '', + title: {text: ''}, showaxeslabels: false, showticklabels: false, linetickenable: false @@ -135941,7 +138118,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":696}],829:[function(_dereq_,module,exports){ +},{"../lib":692}],825:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136009,7 +138186,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":696,"../plot_api/to_image":737,"./filesaver":830}],830:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/to_image":733,"./filesaver":826}],826:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136081,7 +138258,7 @@ var fileSaver = function(url, name) { module.exports = fileSaver; -},{}],831:[function(_dereq_,module,exports){ +},{}],827:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136118,7 +138295,7 @@ exports.getRedrawFunc = function(gd) { }; }; -},{}],832:[function(_dereq_,module,exports){ +},{}],828:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136144,7 +138321,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":828,"./download":829,"./helpers":831,"./svgtoimg":833,"./toimage":834,"./tosvg":835}],833:[function(_dereq_,module,exports){ +},{"./cloneplot":824,"./download":825,"./helpers":827,"./svgtoimg":829,"./toimage":830,"./tosvg":831}],829:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136260,7 +138437,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":696,"events":92}],834:[function(_dereq_,module,exports){ +},{"../lib":692,"events":92}],830:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136339,7 +138516,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":696,"../registry":827,"./cloneplot":828,"./helpers":831,"./svgtoimg":833,"./tosvg":835,"events":92}],835:[function(_dereq_,module,exports){ +},{"../lib":692,"../registry":823,"./cloneplot":824,"./helpers":827,"./svgtoimg":829,"./tosvg":831,"events":92}],831:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136521,7 +138698,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":570,"../components/drawing":595,"../constants/xmlns_namespaces":674,"../lib":696,"d3":148}],836:[function(_dereq_,module,exports){ +},{"../components/color":569,"../components/drawing":590,"../constants/xmlns_namespaces":670,"../lib":692,"d3":148}],832:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136556,7 +138733,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":696}],837:[function(_dereq_,module,exports){ +},{"../../lib":692}],833:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136568,9 +138745,11 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); +var constants = _dereq_('./constants.js'); var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -136619,6 +138798,9 @@ module.exports = { text: scatterAttrs.text, hovertext: scatterAttrs.hovertext, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), textposition: { valType: 'enumerated', @@ -136726,7 +138908,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/font_attributes":771,"../scatter/attributes":1043}],838:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plots/font_attributes":767,"../scatter/attributes":1040,"./constants.js":835}],834:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136738,7 +138920,7 @@ module.exports = { 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var arraysToCalcdata = _dereq_('./arrays_to_calcdata'); var calcSelection = _dereq_('../scatter/calc_selection'); @@ -136771,10 +138953,18 @@ module.exports = function calc(gd, trace) { // auto-z and autocolorscale if applicable if(hasColorscale(trace, 'marker')) { - colorscaleCalc(trace, trace.marker.color, 'marker', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - colorscaleCalc(trace, trace.marker.line.color, 'marker.line', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } arraysToCalcdata(cd, trace); @@ -136783,7 +138973,23 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"../../plots/cartesian/axes":744,"../scatter/calc_selection":1045,"./arrays_to_calcdata":836}],839:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"../../plots/cartesian/axes":740,"../scatter/calc_selection":1042,"./arrays_to_calcdata":832}],835:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + eventDataKeys: [] +}; + +},{}],836:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -136912,9 +139118,14 @@ function initBase(gd, pa, sa, calcTraces) { // time. But included here for completeness. var scalendar = trace.orientation === 'h' ? trace.xcalendar : trace.ycalendar; + // 'base' on categorical axes makes no sense + var d2c = sa.type === 'category' || sa.type === 'multicategory' ? + function() { return null; } : + sa.d2c; + if(isArrayOrTypedArray(base)) { for(j = 0; j < Math.min(base.length, cd.length); j++) { - b = sa.d2c(base[j], 0, scalendar); + b = d2c(base[j], 0, scalendar); if(isNumeric(b)) { cd[j].b = +b; cd[j].hasB = 1; @@ -136925,7 +139136,7 @@ function initBase(gd, pa, sa, calcTraces) { cd[j].b = 0; } } else { - b = sa.d2c(base, 0, scalendar); + b = d2c(base, 0, scalendar); var hasBase = isNumeric(b); b = hasBase ? b : 0; for(j = 0; j < cd.length; j++) { @@ -137504,7 +139715,7 @@ module.exports = { setGroupPositions: setGroupPositions }; -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axes":744,"../../registry":827,"./sieve.js":848,"fast-isnumeric":214}],840:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axes":740,"../../registry":823,"./sieve.js":845,"fast-isnumeric":214}],837:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137544,6 +139755,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); + coerce('hovertemplate'); var textPosition = coerce('textposition'); @@ -137584,7 +139796,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/color":570,"../../lib":696,"../../registry":827,"../bar/style_defaults":850,"../scatter/xy_defaults":1069,"./attributes":837}],841:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../registry":823,"../bar/style_defaults":847,"../scatter/xy_defaults":1066,"./attributes":833}],838:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137653,7 +139865,7 @@ exports.getValue = function(arrayOrScalar, index) { return value; }; -},{"fast-isnumeric":214,"tinycolor2":514}],842:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214,"tinycolor2":513}],839:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137793,6 +140005,7 @@ function hoverPoints(pointData, xval, yval, hovermode) { fillHoverText(di, trace, pointData); Registry.getComponentMethod('errorbars', 'hoverInfo')(di, trace, pointData); + pointData.hovertemplate = trace.hovertemplate; return [pointData]; } @@ -137810,7 +140023,7 @@ module.exports = { getTraceColor: getTraceColor }; -},{"../../components/color":570,"../../components/fx":612,"../../registry":827,"../scatter/fill_hover_text":1051}],843:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../registry":823,"../scatter/fill_hover_text":1048}],840:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137848,7 +140061,7 @@ Bar.meta = { module.exports = Bar; -},{"../../plots/cartesian":756,"../scatter/marker_colorbar":1061,"./arrays_to_calcdata":836,"./attributes":837,"./calc":838,"./cross_trace_calc":839,"./defaults":840,"./hover":842,"./layout_attributes":844,"./layout_defaults":845,"./plot":846,"./select":847,"./style":849}],844:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../scatter/marker_colorbar":1058,"./arrays_to_calcdata":832,"./attributes":833,"./calc":834,"./cross_trace_calc":836,"./defaults":837,"./hover":839,"./layout_attributes":841,"./layout_defaults":842,"./plot":843,"./select":844,"./style":846}],841:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137896,7 +140109,7 @@ module.exports = { } }; -},{}],845:[function(_dereq_,module,exports){ +},{}],842:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -137954,7 +140167,7 @@ module.exports = function(layoutIn, layoutOut, fullData) { coerce('bargroupgap'); }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../../registry":827,"./layout_attributes":844}],846:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../../registry":823,"./layout_attributes":841}],843:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138081,7 +140294,7 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { .style('vector-effect', 'non-scaling-stroke') .attr('d', 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z') - .call(Drawing.setClipUrl, plotinfo.layerClipId); + .call(Drawing.setClipUrl, plotinfo.layerClipId, gd); appendBarText(gd, bar, cd, i, x0, x1, y0, y1); @@ -138093,11 +140306,11 @@ module.exports = function plot(gd, plotinfo, cdbar, barLayer) { // lastly, clip points groups of `cliponaxis !== false` traces // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = cd0.trace.cliponaxis === false; - Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId); + Drawing.setClipUrl(plotGroup, hasClipOnAxisFalse ? null : plotinfo.layerClipId, gd); }); // error bars are on the top - Registry.getComponentMethod('errorbars', 'plot')(bartraces, plotinfo); + Registry.getComponentMethod('errorbars', 'plot')(gd, bartraces, plotinfo); }; function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) { @@ -138394,7 +140607,7 @@ function getTextPosition(trace, index) { return helpers.coerceEnumerated(attributeTextPosition, value); } -},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../lib/svg_text_utils":720,"../../registry":827,"./attributes":837,"./helpers":841,"./style":849,"d3":148,"fast-isnumeric":214}],847:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../lib/svg_text_utils":716,"../../registry":823,"./attributes":833,"./helpers":838,"./style":846,"d3":148,"fast-isnumeric":214}],844:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138437,7 +140650,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],848:[function(_dereq_,module,exports){ +},{}],845:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138546,7 +140759,7 @@ Sieve.prototype.getLabel = function getLabel(position, value) { return prefix + label; }; -},{"../../constants/numerical":673,"../../lib":696}],849:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692}],846:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138720,7 +140933,7 @@ module.exports = { getBarColor: getBarColor }; -},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../registry":827,"./attributes":837,"./helpers":841,"d3":148}],850:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../registry":823,"./attributes":833,"./helpers":838,"d3":148}],847:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138729,11 +140942,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout) { @@ -138759,7 +140971,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, default coerce('unselected.marker.color'); }; -},{"../../components/color":570,"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584}],851:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580}],848:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138824,7 +141036,7 @@ module.exports = { // error_y }; -},{"../../lib/extend":685,"../bar/attributes":837,"../scatterpolar/attributes":1105}],852:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../bar/attributes":833,"../scatterpolar/attributes":1102}],849:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138835,7 +141047,7 @@ module.exports = { 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var arraysToCalcdata = _dereq_('../bar/arrays_to_calcdata'); var setGroupPositions = _dereq_('../bar/cross_trace_calc').setGroupPositions; @@ -138880,10 +141092,18 @@ function calc(gd, trace) { } if(hasColorscale(trace, 'marker')) { - colorscaleCalc(trace, trace.marker.color, 'marker', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - colorscaleCalc(trace, trace.marker.line.color, 'marker.line', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } arraysToCalcdata(cd, trace); @@ -138927,7 +141147,7 @@ module.exports = { crossTraceCalc: crossTraceCalc }; -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../registry":827,"../bar/arrays_to_calcdata":836,"../bar/cross_trace_calc":839,"../scatter/calc_selection":1045}],853:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"../../lib":692,"../../registry":823,"../bar/arrays_to_calcdata":832,"../bar/cross_trace_calc":836,"../scatter/calc_selection":1042}],850:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -138985,7 +141205,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../bar/style_defaults":850,"../scatterpolar/defaults":1107,"./attributes":851}],854:[function(_dereq_,module,exports){ +},{"../../lib":692,"../bar/style_defaults":847,"../scatterpolar/defaults":1104,"./attributes":848}],851:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139059,7 +141279,7 @@ module.exports = function hoverPoints(pointData, xval, yval) { return [pointData]; }; -},{"../../components/fx":612,"../../lib":696,"../../plots/polar/helpers":810,"../bar/hover":842,"../scatter/fill_hover_text":1051,"../scatterpolar/hover":1108}],855:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../lib":692,"../../plots/polar/helpers":806,"../bar/hover":839,"../scatter/fill_hover_text":1048,"../scatterpolar/hover":1105}],852:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139097,7 +141317,7 @@ module.exports = { } }; -},{"../../plots/polar":811,"../bar/select":847,"../bar/style":849,"../scatter/marker_colorbar":1061,"./attributes":851,"./calc":852,"./defaults":853,"./hover":854,"./layout_attributes":856,"./layout_defaults":857,"./plot":858}],856:[function(_dereq_,module,exports){ +},{"../../plots/polar":807,"../bar/select":844,"../bar/style":846,"../scatter/marker_colorbar":1058,"./attributes":848,"./calc":849,"./defaults":850,"./hover":851,"./layout_attributes":853,"./layout_defaults":854,"./plot":855}],853:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139128,7 +141348,7 @@ module.exports = { } }; -},{}],857:[function(_dereq_,module,exports){ +},{}],854:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139163,7 +141383,7 @@ module.exports = function(layoutIn, layoutOut, fullData) { } }; -},{"../../lib":696,"./layout_attributes":856}],858:[function(_dereq_,module,exports){ +},{"../../lib":692,"./layout_attributes":853}],855:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139235,7 +141455,11 @@ module.exports = function plot(gd, subplot, cdbar) { }); // clip plotGroup, when trace layer isn't clipped - Drawing.setClipUrl(plotGroup, subplot._hasClipOnAxisFalse ? subplot.clipIds.forTraces : null); + Drawing.setClipUrl( + plotGroup, + subplot._hasClipOnAxisFalse ? subplot.clipIds.forTraces : null, + gd + ); }); }; @@ -139267,7 +141491,7 @@ function makePathFn(subplot) { }; } -},{"../../components/drawing":595,"../../lib":696,"../../plots/polar/helpers":810,"d3":148,"fast-isnumeric":214}],859:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../../plots/polar/helpers":806,"d3":148,"fast-isnumeric":214}],856:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139459,7 +141683,7 @@ module.exports = { } }; -},{"../../components/color/attributes":569,"../../lib/extend":685,"../scatter/attributes":1043}],860:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../lib/extend":682,"../scatter/attributes":1040}],857:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139640,7 +141864,10 @@ function getPos(trace, posLetter, posAxis, val, num) { pos0 = num; } - var pos0c = posAxis.d2c(pos0, 0, trace[posLetter + 'calendar']); + var pos0c = posAxis.type === 'multicategory' ? + posAxis.r2c_just_indices(pos0) : + posAxis.d2c(pos0, 0, trace[posLetter + 'calendar']); + return val.map(function() { return pos0c; }); } @@ -139695,7 +141922,7 @@ function sortByVal(a, b) { return a.v - b.v; } function extractVal(o) { return o.v; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"fast-isnumeric":214}],861:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"fast-isnumeric":214}],858:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139811,7 +142038,7 @@ module.exports = { setPositionOffset: setPositionOffset }; -},{"../../lib":696,"../../plots/cartesian/axes":744}],862:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740}],859:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139859,16 +142086,15 @@ function handleSampleDefaults(traceIn, traceOut, coerce, layout) { if(y && y.length) { defaultOrientation = 'v'; if(hasX) { - len = Math.min(x.length, y.length); - } - else { + len = Math.min(Lib.minRowLength(x), Lib.minRowLength(y)); + } else { coerce('x0'); - len = y.length; + len = Lib.minRowLength(y); } } else if(hasX) { defaultOrientation = 'h'; coerce('y0'); - len = x.length; + len = Lib.minRowLength(x); } else { traceOut.visible = false; return; @@ -139929,7 +142155,7 @@ module.exports = { handlePointsDefaults: handlePointsDefaults }; -},{"../../components/color":570,"../../lib":696,"../../registry":827,"./attributes":859}],863:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../registry":823,"./attributes":856}],860:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -139955,7 +142181,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],864:[function(_dereq_,module,exports){ +},{}],861:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140218,7 +142444,7 @@ module.exports = { hoverOnPoints: hoverOnPoints }; -},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051}],865:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048}],862:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140254,7 +142480,7 @@ Box.meta = { module.exports = Box; -},{"../../plots/cartesian":756,"./attributes":859,"./calc":860,"./cross_trace_calc":861,"./defaults":862,"./event_data":863,"./hover":864,"./layout_attributes":866,"./layout_defaults":867,"./plot":868,"./select":869,"./style":870}],866:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":856,"./calc":857,"./cross_trace_calc":858,"./defaults":859,"./event_data":860,"./hover":861,"./layout_attributes":863,"./layout_defaults":864,"./plot":865,"./select":866,"./style":867}],863:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140295,7 +142521,7 @@ module.exports = { } }; -},{}],867:[function(_dereq_,module,exports){ +},{}],864:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140338,7 +142564,7 @@ module.exports = { _supply: _supply }; -},{"../../lib":696,"../../registry":827,"./layout_attributes":866}],868:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"./layout_attributes":863}],865:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140678,7 +142904,7 @@ module.exports = { plotBoxMean: plotBoxMean }; -},{"../../components/drawing":595,"../../lib":696,"d3":148}],869:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"d3":148}],866:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140727,7 +142953,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],870:[function(_dereq_,module,exports){ +},{}],867:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140801,7 +143027,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/color":570,"../../components/drawing":595,"d3":148}],871:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"d3":148}],868:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140854,7 +143080,7 @@ module.exports = { hoverlabel: OHLCattrs.hoverlabel, }; -},{"../../lib":696,"../box/attributes":859,"../ohlc/attributes":991}],872:[function(_dereq_,module,exports){ +},{"../../lib":692,"../box/attributes":856,"../ohlc/attributes":988}],869:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140904,7 +143130,7 @@ function ptFunc(o, h, l, c) { }; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"../ohlc/calc":992}],873:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../ohlc/calc":989}],870:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140949,7 +143175,7 @@ function handleDirection(traceIn, traceOut, coerce, direction) { coerce(direction + '.fillcolor', Color.addOpacity(lineColor, 0.5)); } -},{"../../components/color":570,"../../lib":696,"../ohlc/ohlc_defaults":996,"./attributes":871}],874:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../ohlc/ohlc_defaults":993,"./attributes":868}],871:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -140982,7 +143208,7 @@ module.exports = { selectPoints: _dereq_('../ohlc/select') }; -},{"../../plots/cartesian":756,"../box/cross_trace_calc":861,"../box/layout_attributes":866,"../box/layout_defaults":867,"../box/plot":868,"../box/style":870,"../ohlc/hover":994,"../ohlc/select":998,"./attributes":871,"./calc":872,"./defaults":873}],875:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../box/cross_trace_calc":858,"../box/layout_attributes":863,"../box/layout_defaults":864,"../box/plot":865,"../box/style":867,"../ohlc/hover":991,"../ohlc/select":995,"./attributes":868,"./calc":869,"./defaults":870}],872:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141046,7 +143272,7 @@ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) { }); } -},{"../../plot_api/plot_template":734,"./axis_defaults":880}],876:[function(_dereq_,module,exports){ +},{"../../plot_api/plot_template":730,"./axis_defaults":877}],873:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141093,7 +143319,7 @@ function minMax(a, depth) { return [min, max]; } -},{"../../lib":696}],877:[function(_dereq_,module,exports){ +},{"../../lib":692}],874:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141192,7 +143418,7 @@ module.exports = { transforms: undefined }; -},{"../../components/color/attributes":569,"../../plots/font_attributes":771,"./axis_attributes":879}],878:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../plots/font_attributes":767,"./axis_attributes":876}],875:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141299,7 +143525,7 @@ module.exports = function(carpet, carpetcd, a, b) { return segments; }; -},{"../../lib":696}],879:[function(_dereq_,module,exports){ +},{"../../lib":692}],876:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141331,21 +143557,25 @@ module.exports = { editType: 'calc' }, title: { - valType: 'string', - - editType: 'calc', - - }, - titlefont: fontAttrs({ - editType: 'calc', - - }), - titleoffset: { - valType: 'number', - - dflt: 10, + text: { + valType: 'string', + dflt: '', + + editType: 'calc', + + }, + font: fontAttrs({ + editType: 'calc', + + }), + offset: { + valType: 'number', + + dflt: 10, + editType: 'calc', + + }, editType: 'calc', - }, type: { valType: 'enumerated', @@ -141678,10 +143908,31 @@ module.exports = { editType: 'calc', }, + + _deprecated: { + title: { + valType: 'string', + + editType: 'calc', + + }, + titlefont: fontAttrs({ + editType: 'calc', + + }), + titleoffset: { + valType: 'number', + + dflt: 10, + editType: 'calc', + + } + }, + editType: 'calc' }; -},{"../../components/color/attributes":569,"../../plot_api/edit_types":727,"../../plots/cartesian/layout_attributes":757,"../../plots/font_attributes":771}],880:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../plot_api/edit_types":723,"../../plots/cartesian/layout_attributes":753,"../../plots/font_attributes":767}],877:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -141797,14 +144048,15 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options) // inherit from global font color in case that was provided. var dfltFontColor = (dfltColor === containerIn.color) ? dfltColor : font.color; - coerce('title'); - Lib.coerceFont(coerce, 'titlefont', { - family: font.family, - size: Math.round(font.size * 1.2), - color: dfltFontColor - }); - - coerce('titleoffset'); + var title = coerce('title.text'); + if(title) { + Lib.coerceFont(coerce, 'title.font', { + family: font.family, + size: Math.round(font.size * 1.2), + color: dfltFontColor + }); + coerce('title.offset'); + } coerce('tickangle'); @@ -141887,11 +144139,6 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options) // but no, we *actually* want to coerce this. coerce('tickmode'); - if(!containerOut.title || (containerOut.title && containerOut.title.length === 0)) { - delete containerOut.titlefont; - delete containerOut.titleoffset; - } - return containerOut; }; @@ -141909,7 +144156,7 @@ function setAutoType(ax, data) { ax.type = autoType(data, calendar); } -},{"../../components/color":570,"../../lib":696,"../../plots/cartesian/axis_autotype":745,"../../plots/cartesian/category_order_defaults":748,"../../plots/cartesian/set_convert":763,"../../plots/cartesian/tick_label_defaults":764,"../../plots/cartesian/tick_value_defaults":766,"../../registry":827,"./attributes":877}],881:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../plots/cartesian/axis_autotype":741,"../../plots/cartesian/category_order_defaults":744,"../../plots/cartesian/set_convert":759,"../../plots/cartesian/tick_label_defaults":760,"../../plots/cartesian/tick_value_defaults":762,"../../registry":823,"./attributes":874}],878:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142019,7 +144266,7 @@ module.exports = function calc(gd, trace) { return [t]; }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../heatmap/clean_2d_array":947,"../heatmap/convert_column_xyz":949,"./array_minmax":876,"./calc_clippath":882,"./calc_gridlines":883,"./calc_labels":884,"./cheater_basis":886,"./set_convert":899,"./smooth_fill_2d_array":900}],882:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../heatmap/clean_2d_array":944,"../heatmap/convert_column_xyz":946,"./array_minmax":873,"./calc_clippath":879,"./calc_gridlines":880,"./calc_labels":881,"./cheater_basis":883,"./set_convert":896,"./smooth_fill_2d_array":897}],879:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142071,7 +144318,7 @@ module.exports = function makeClipPath(xctrl, yctrl, aax, bax) { return segments; }; -},{}],883:[function(_dereq_,module,exports){ +},{}],880:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142414,7 +144661,7 @@ module.exports = function calcGridlines(trace, axisLetter, crossAxisLetter) { } }; -},{"../../lib/extend":685,"../../plots/cartesian/axes":744}],884:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plots/cartesian/axes":740}],881:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142475,7 +144722,7 @@ module.exports = function calcLabels(trace, axis) { } }; -},{"../../lib/extend":685,"../../plots/cartesian/axes":744}],885:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plots/cartesian/axes":740}],882:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142517,7 +144764,7 @@ module.exports = function makeControlPoints(p0, p1, p2, smoothness) { ]]; }; -},{}],886:[function(_dereq_,module,exports){ +},{}],883:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142585,7 +144832,7 @@ module.exports = function(a, b, cheaterslope) { return data; }; -},{"../../lib":696}],887:[function(_dereq_,module,exports){ +},{"../../lib":692}],884:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142937,7 +145184,7 @@ module.exports = function computeControlPoints(xe, ye, x, y, asmoothing, bsmooth return [xe, ye]; }; -},{"../../lib":696,"./catmull_rom":885}],888:[function(_dereq_,module,exports){ +},{"../../lib":692,"./catmull_rom":882}],885:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -142953,7 +145200,7 @@ module.exports = { RELATIVE_CULL_TOLERANCE: 1e-6 }; -},{}],889:[function(_dereq_,module,exports){ +},{}],886:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143105,7 +145352,7 @@ module.exports = function(arrays, asmoothing, bsmoothing) { } }; -},{}],890:[function(_dereq_,module,exports){ +},{}],887:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143233,7 +145480,7 @@ module.exports = function(arrays, asmoothing, bsmoothing) { }; -},{}],891:[function(_dereq_,module,exports){ +},{}],888:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143384,7 +145631,7 @@ module.exports = function(arrays, na, nb, asmoothing, bsmoothing) { }; -},{}],892:[function(_dereq_,module,exports){ +},{}],889:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143443,7 +145690,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, dfltColor, fullLayou } }; -},{"../../components/color/attributes":569,"../../lib":696,"./ab_defaults":875,"./attributes":877,"./xy_defaults":901}],893:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../lib":692,"./ab_defaults":872,"./attributes":874,"./xy_defaults":898}],890:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143467,14 +145714,14 @@ Carpet.isContainer = true; // so carpet traces get `calc` before other traces Carpet.moduleType = 'trace'; Carpet.name = 'carpet'; Carpet.basePlotModule = _dereq_('../../plots/cartesian'); -Carpet.categories = ['cartesian', 'svg', 'carpet', 'carpetAxis', 'notLegendIsolatable']; +Carpet.categories = ['cartesian', 'svg', 'carpet', 'carpetAxis', 'notLegendIsolatable', 'noMultiCategory']; Carpet.meta = { }; module.exports = Carpet; -},{"../../plots/cartesian":756,"./attributes":877,"./calc":881,"./defaults":892,"./plot":898}],894:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":874,"./calc":878,"./defaults":889,"./plot":895}],891:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143510,7 +145757,7 @@ module.exports = function(gd, trace) { return firstAxis; }; -},{}],895:[function(_dereq_,module,exports){ +},{}],892:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143541,7 +145788,7 @@ module.exports = function makePath(xp, yp, isBicubic) { return path.join(isBicubic ? '' : 'L'); }; -},{}],896:[function(_dereq_,module,exports){ +},{}],893:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143578,7 +145825,7 @@ module.exports = function mapArray(out, data, func) { return out; }; -},{"../../lib":696}],897:[function(_dereq_,module,exports){ +},{"../../lib":692}],894:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143620,7 +145867,7 @@ module.exports = function orientText(trace, xaxis, yaxis, xy, dxy, refDxy) { }; }; -},{}],898:[function(_dereq_,module,exports){ +},{}],895:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -143820,7 +146067,7 @@ var midShift = ((1 - alignmentConstants.MID_SHIFT) / lineSpacing) + 1; function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientation, labelClass) { var data = []; - if(axis.title) data.push(axis.title); + if(axis.title.text) data.push(axis.title.text); var titleJoin = layer.selectAll('text.' + labelClass).data(data); var offset = labelOrientation.maxExtent; @@ -143836,8 +146083,8 @@ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientat } // In addition to the size of the labels, add on some extra padding: - var titleSize = axis.titlefont.size; - offset += titleSize + axis.titleoffset; + var titleSize = axis.title.font.size; + offset += titleSize + axis.title.offset; var labelNorm = labelOrientation.angle + (labelOrientation.flip < 0 ? 180 : 0); var angleDiff = (labelNorm - orientation.angle + 450) % 360; @@ -143845,7 +146092,7 @@ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientat var el = d3.select(this); - el.text(axis.title || '') + el.text(axis.title.text) .call(svgTextUtils.convertToTspans, gd); if(reverseTitle) { @@ -143859,13 +146106,13 @@ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientat ) .classed('user-select-none', true) .attr('text-anchor', 'middle') - .call(Drawing.font, axis.titlefont); + .call(Drawing.font, axis.title.font); }); titleJoin.exit().remove(); } -},{"../../components/drawing":595,"../../constants/alignment":668,"../../lib":696,"../../lib/svg_text_utils":720,"./makepath":895,"./map_1d_array":896,"./orient_text":897,"d3":148}],899:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../constants/alignment":664,"../../lib":692,"../../lib/svg_text_utils":716,"./makepath":892,"./map_1d_array":893,"./orient_text":894,"d3":148}],896:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144148,7 +146395,7 @@ module.exports = function setConvert(trace) { }; }; -},{"../../lib/search":715,"./compute_control_points":887,"./constants":888,"./create_i_derivative_evaluator":889,"./create_j_derivative_evaluator":890,"./create_spline_evaluator":891}],900:[function(_dereq_,module,exports){ +},{"../../lib/search":711,"./compute_control_points":884,"./constants":885,"./create_i_derivative_evaluator":886,"./create_j_derivative_evaluator":887,"./create_spline_evaluator":888}],897:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144371,7 +146618,7 @@ module.exports = function smoothFill2dArray(data, a, b) { return data; }; -},{"../../lib":696}],901:[function(_dereq_,module,exports){ +},{"../../lib":692}],898:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144406,7 +146653,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, coerce) { return true; }; -},{"../../lib":696}],902:[function(_dereq_,module,exports){ +},{"../../lib":692}],899:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144488,7 +146735,7 @@ module.exports = extendFlat({ {colorbar: colorbarAttrs} ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../scattergeo/attributes":1083}],903:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../scattergeo/attributes":1080}],900:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144521,13 +146768,17 @@ module.exports = function calc(gd, trace) { } arraysToCalcdata(calcTrace, trace); - colorscaleCalc(trace, trace.z, '', 'z'); + colorscaleCalc(gd, trace, { + vals: trace.z, + containerStr: '', + cLetter: 'z' + }); calcSelection(calcTrace, trace); return calcTrace; }; -},{"../../components/colorscale/calc":578,"../../constants/numerical":673,"../scatter/arrays_to_calcdata":1042,"../scatter/calc_selection":1045,"fast-isnumeric":214}],904:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../constants/numerical":669,"../scatter/arrays_to_calcdata":1039,"../scatter/calc_selection":1042,"fast-isnumeric":214}],901:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144572,7 +146823,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"./attributes":902}],905:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"./attributes":899}],902:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144591,7 +146842,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],906:[function(_dereq_,module,exports){ +},{}],903:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144681,7 +146932,7 @@ function makeHoverInfo(pointData, trace, pt, axis) { pointData.extraText = text.join('
'); } -},{"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051,"./attributes":902}],907:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048,"./attributes":899}],904:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144716,7 +146967,7 @@ Choropleth.meta = { module.exports = Choropleth; -},{"../../plots/geo":775,"../heatmap/colorbar":948,"./attributes":902,"./calc":903,"./defaults":904,"./event_data":905,"./hover":906,"./plot":908,"./select":909,"./style":910}],908:[function(_dereq_,module,exports){ +},{"../../plots/geo":771,"../heatmap/colorbar":945,"./attributes":899,"./calc":900,"./defaults":901,"./event_data":902,"./hover":903,"./plot":905,"./select":906,"./style":907}],905:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144884,7 +147135,7 @@ function feature2polygons(feature) { return polygons; } -},{"../../lib":696,"../../lib/geo_location_utils":688,"../../lib/polygon":708,"../../lib/topojson_utils":723,"./style":910,"d3":148}],909:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/geo_location_utils":685,"../../lib/polygon":704,"../../lib/topojson_utils":719,"./style":907,"d3":148}],906:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144933,7 +147184,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],910:[function(_dereq_,module,exports){ +},{}],907:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -144961,11 +147212,7 @@ function styleTrace(gd, calcTrace) { var markerLine = marker.line || {}; var sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - trace.colorscale, - trace.zmin, - trace.zmax - ) + Colorscale.extractScale(trace, {cLetter: 'z'}) ); locs.each(function(d) { @@ -144995,7 +147242,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/color":570,"../../components/colorscale":585,"../../components/drawing":595,"d3":148}],911:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/colorscale":581,"../../components/drawing":590,"d3":148}],908:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145149,7 +147396,7 @@ attrs.transforms = undefined; module.exports = attrs; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../mesh3d/attributes":986}],912:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../mesh3d/attributes":983}],909:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145186,10 +147433,14 @@ module.exports = function calc(gd, trace) { trace._len = len; trace._normMax = normMax; - colorscaleCalc(trace, [normMin, normMax], '', 'c'); + colorscaleCalc(gd, trace, { + vals: [normMin, normMax], + containerStr: '', + cLetter: 'c' + }); }; -},{"../../components/colorscale/calc":578}],913:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577}],910:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145334,7 +147585,7 @@ function createConeTrace(scene, data) { module.exports = createConeTrace; -},{"../../lib":696,"../../lib/gl_format_color":692,"../../plots/gl3d/zip3":798,"gl-cone3d":231}],914:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gl_format_color":689,"../../plots/gl3d/zip3":794,"gl-cone3d":231}],911:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145394,7 +147645,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"./attributes":911}],915:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"./attributes":908}],912:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145425,7 +147676,7 @@ module.exports = { } }; -},{"../../plots/gl3d":787,"./attributes":911,"./calc":912,"./convert":913,"./defaults":914}],916:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":783,"./attributes":908,"./calc":909,"./convert":910,"./defaults":911}],913:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145604,7 +147855,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../components/drawing/attributes":594,"../../constants/filter_ops":669,"../../lib/extend":685,"../../plots/font_attributes":771,"../heatmap/attributes":945,"../scatter/attributes":1043}],917:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../components/drawing/attributes":589,"../../constants/filter_ops":665,"../../lib/extend":682,"../../plots/font_attributes":767,"../heatmap/attributes":942,"../scatter/attributes":1040}],914:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145628,7 +147879,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../heatmap/calc":946,"./set_contours":935}],918:[function(_dereq_,module,exports){ +},{"../heatmap/calc":943,"./set_contours":932}],915:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145695,7 +147946,7 @@ module.exports = function(pathinfo, operation, perimeter, trace) { } }; -},{}],919:[function(_dereq_,module,exports){ +},{}],916:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145746,7 +147997,7 @@ module.exports = function colorbar(gd, cd) { .options(trace.colorbar)(); }; -},{"../../components/colorbar/draw":575,"./end_plus":927,"./make_color_map":932}],920:[function(_dereq_,module,exports){ +},{"../../components/colorbar/draw":574,"./end_plus":924,"./make_color_map":929}],917:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145824,7 +148075,7 @@ module.exports = { } }; -},{}],921:[function(_dereq_,module,exports){ +},{}],918:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145919,7 +148170,7 @@ function handleConstraintValueDefaults(coerce, contours) { } } -},{"../../components/color":570,"../../constants/filter_ops":669,"./label_defaults":931,"fast-isnumeric":214}],922:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../constants/filter_ops":665,"./label_defaults":928,"fast-isnumeric":214}],919:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -145998,7 +148249,7 @@ function makeInequalitySettings(operation) { }; } -},{"../../constants/filter_ops":669,"fast-isnumeric":214}],923:[function(_dereq_,module,exports){ +},{"../../constants/filter_ops":665,"fast-isnumeric":214}],920:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146027,7 +148278,7 @@ module.exports = function handleContourDefaults(traceIn, traceOut, coerce, coerc if(autoContour || !contourSize) coerce('ncontours'); }; -},{}],924:[function(_dereq_,module,exports){ +},{}],921:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146115,7 +148366,7 @@ function copyPathinfo(pi) { }); } -},{"../../lib":696}],925:[function(_dereq_,module,exports){ +},{"../../lib":692}],922:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146164,7 +148415,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../lib":696,"../heatmap/xyz_defaults":960,"./attributes":916,"./constraint_defaults":921,"./contours_defaults":923,"./style_defaults":937}],926:[function(_dereq_,module,exports){ +},{"../../lib":692,"../heatmap/xyz_defaults":956,"./attributes":913,"./constraint_defaults":918,"./contours_defaults":920,"./style_defaults":934}],923:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146228,7 +148479,7 @@ module.exports = function emptyPathinfo(contours, plotinfo, cd0) { return pathinfo; }; -},{"../../lib":696,"./constraint_mapping":922,"./end_plus":927}],927:[function(_dereq_,module,exports){ +},{"../../lib":692,"./constraint_mapping":919,"./end_plus":924}],924:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146248,7 +148499,7 @@ module.exports = function endPlus(contours) { return contours.end + contours.size / 1e6; }; -},{}],928:[function(_dereq_,module,exports){ +},{}],925:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146548,7 +148799,7 @@ function getInterpPx(pi, loc, step) { } } -},{"../../lib":696,"./constants":920}],929:[function(_dereq_,module,exports){ +},{"../../lib":692,"./constants":917}],926:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146584,7 +148835,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return hoverData; }; -},{"../../components/color":570,"../heatmap/hover":952}],930:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../heatmap/hover":949}],927:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146616,7 +148867,7 @@ Contour.meta = { module.exports = Contour; -},{"../../plots/cartesian":756,"./attributes":916,"./calc":917,"./colorbar":919,"./defaults":925,"./hover":929,"./plot":934,"./style":936}],931:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":913,"./calc":914,"./colorbar":916,"./defaults":922,"./hover":926,"./plot":931,"./style":933}],928:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146646,7 +148897,7 @@ module.exports = function handleLabelDefaults(coerce, layout, lineColor, opts) { if(opts.hasHover !== false) coerce('zhoverformat'); }; -},{"../../lib":696}],932:[function(_dereq_,module,exports){ +},{"../../lib":692}],929:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146675,11 +148926,13 @@ module.exports = function makeColorMap(trace) { nc = 1; } - var scl = trace.colorscale, - len = scl.length; + var scl = trace.reversescale ? + Colorscale.flipScale(trace.colorscale) : + trace.colorscale; - var domain = new Array(len), - range = new Array(len); + var len = scl.length; + var domain = new Array(len); + var range = new Array(len); var si, i; @@ -146730,7 +148983,7 @@ module.exports = function makeColorMap(trace) { }); }; -},{"../../components/colorscale":585,"./end_plus":927,"d3":148}],933:[function(_dereq_,module,exports){ +},{"../../components/colorscale":581,"./end_plus":924,"d3":148}],930:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146822,7 +149075,7 @@ function getMarchingIndex(val, corners) { return (mi === 15) ? 0 : mi; } -},{"./constants":920}],934:[function(_dereq_,module,exports){ +},{"./constants":917}],931:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -146854,7 +149107,6 @@ var costConstants = constants.LABELOPTIMIZER; exports.plot = function plot(gd, plotinfo, cdcontours, contourLayer) { var xa = plotinfo.xaxis; var ya = plotinfo.yaxis; - var fullLayout = gd._fullLayout; Lib.makeTraceGroups(contourLayer, cdcontours, 'contour').each(function(cd) { var plotGroup = d3.select(this); @@ -146903,7 +149155,7 @@ exports.plot = function plot(gd, plotinfo, cdcontours, contourLayer) { makeBackground(plotGroup, perimeter, contours); makeFills(plotGroup, fillPathinfo, perimeter, contours); makeLinesAndLabels(plotGroup, pathinfo, gd, cd0, contours, perimeter); - clipGaps(plotGroup, plotinfo, fullLayout._clips, cd0, perimeter); + clipGaps(plotGroup, plotinfo, gd, cd0, perimeter); }); }; @@ -147055,8 +149307,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) { // In this case we'll remove the lines after making the labels. var linegroup = exports.createLines(lineContainer, showLines || showLabels, pathinfo); - var lineClip = exports.createLineClip(lineContainer, clipLinesForLabels, - gd._fullLayout._clips, cd0.trace.uid); + var lineClip = exports.createLineClip(lineContainer, clipLinesForLabels, gd, cd0.trace.uid); var labelGroup = plotgroup.selectAll('g.contourlabels') .data(showLabels ? [0] : []); @@ -147080,17 +149331,37 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) { .attr('data-notex', 1) .call(Drawing.font, contours.labelfont); - var xLen = pathinfo[0].xaxis._length; - var yLen = pathinfo[0].yaxis._length; + var xa = pathinfo[0].xaxis; + var ya = pathinfo[0].yaxis; + var xLen = xa._length; + var yLen = ya._length; + var xRng = xa.range; + var yRng = ya.range; + var x0 = Math.max(perimeter[0][0], 0); + var x1 = Math.min(perimeter[2][0], xLen); + var y0 = Math.max(perimeter[0][1], 0); + var y1 = Math.min(perimeter[2][1], yLen); // visible bounds of the contour trace (and the midpoints, to // help with cost calculations) - var bounds = { - left: Math.max(perimeter[0][0], 0), - right: Math.min(perimeter[2][0], xLen), - top: Math.max(perimeter[0][1], 0), - bottom: Math.min(perimeter[2][1], yLen) - }; + var bounds = {}; + + if(xRng[0] < xRng[1]) { + bounds.left = x0; + bounds.right = x1; + } else { + bounds.left = x1; + bounds.right = x0; + } + + if(yRng[0] < yRng[1]) { + bounds.top = y0; + bounds.bottom = y1; + } else { + bounds.top = y1; + bounds.bottom = y0; + } + bounds.middle = (bounds.top + bounds.bottom) / 2; bounds.center = (bounds.left + bounds.right) / 2; @@ -147178,7 +149449,8 @@ exports.createLines = function(lineContainer, makeLines, pathinfo) { return linegroup; }; -exports.createLineClip = function(lineContainer, clipLinesForLabels, clips, uid) { +exports.createLineClip = function(lineContainer, clipLinesForLabels, gd, uid) { + var clips = gd._fullLayout._clips; var clipId = clipLinesForLabels ? ('clipline' + uid) : null; var lineClip = clips.selectAll('#' + clipId) @@ -147189,7 +149461,7 @@ exports.createLineClip = function(lineContainer, clipLinesForLabels, clips, uid) .classed('contourlineclip', true) .attr('id', clipId); - Drawing.setClipUrl(lineContainer, clipId); + Drawing.setClipUrl(lineContainer, clipId, gd); return lineClip; }; @@ -147420,7 +149692,8 @@ exports.drawLabels = function(labelGroup, labelData, gd, lineClip, labelClipPath } }; -function clipGaps(plotGroup, plotinfo, clips, cd0, perimeter) { +function clipGaps(plotGroup, plotinfo, gd, cd0, perimeter) { + var clips = gd._fullLayout._clips; var clipId = 'clip' + cd0.trace.uid; var clipPath = clips.selectAll('#' + clipId) @@ -147459,7 +149732,7 @@ function clipGaps(plotGroup, plotinfo, clips, cd0, perimeter) { } else clipId = null; - plotGroup.call(Drawing.setClipUrl, clipId); + Drawing.setClipUrl(plotGroup, clipId, gd); } function makeClipMask(cd0) { @@ -147482,7 +149755,7 @@ function makeClipMask(cd0) { return z; } -},{"../../components/drawing":595,"../../lib":696,"../../lib/svg_text_utils":720,"../../plots/cartesian/axes":744,"../../plots/cartesian/set_convert":763,"../heatmap/plot":957,"./close_boundaries":918,"./constants":920,"./convert_to_constraints":924,"./empty_pathinfo":926,"./find_all_paths":928,"./make_crossings":933,"d3":148}],935:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../../lib/svg_text_utils":716,"../../plots/cartesian/axes":740,"../../plots/cartesian/set_convert":759,"../heatmap/plot":953,"./close_boundaries":915,"./constants":917,"./convert_to_constraints":921,"./empty_pathinfo":923,"./find_all_paths":925,"./make_crossings":930,"d3":148}],932:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147586,7 +149859,7 @@ function autoContours(start, end, ncontours) { return dummyAx; } -},{"../../lib":696,"../../plots/cartesian/axes":744}],936:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740}],933:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147668,7 +149941,7 @@ module.exports = function style(gd) { heatmapStyle(gd); }; -},{"../../components/drawing":595,"../heatmap/style":958,"./make_color_map":932,"d3":148}],937:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../heatmap/style":954,"./make_color_map":929,"d3":148}],934:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147713,7 +149986,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, layout, handleLabelDefaults(coerce, layout, lineColor, opts); }; -},{"../../components/colorscale/defaults":580,"./label_defaults":931}],938:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"./label_defaults":928}],935:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147804,7 +150077,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../contour/attributes":916,"../heatmap/attributes":945,"../scatter/attributes":1043}],939:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../contour/attributes":913,"../heatmap/attributes":942,"../scatter/attributes":1040}],936:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147816,11 +150089,10 @@ module.exports = extendFlat({ 'use strict'; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); -var isArray1D = _dereq_('../../lib').isArray1D; +var Lib = _dereq_('../../lib'); var convertColumnData = _dereq_('../heatmap/convert_column_xyz'); var clean2dArray = _dereq_('../heatmap/clean_2d_array'); -var maxRowLength = _dereq_('../heatmap/max_row_length'); var interp2d = _dereq_('../heatmap/interp2d'); var findEmpties = _dereq_('../heatmap/find_empties'); var makeBoundArray = _dereq_('../heatmap/make_bound_array'); @@ -147877,7 +150149,7 @@ function heatmappishCalc(gd, trace) { aax._minDtick = 0; bax._minDtick = 0; - if(isArray1D(trace.z)) convertColumnData(trace, aax, bax, 'a', 'b', ['z']); + if(Lib.isArray1D(trace.z)) convertColumnData(trace, aax, bax, 'a', 'b', ['z']); a = trace._a = trace._a || trace.a; b = trace._b = trace._b || trace.b; @@ -147894,7 +150166,7 @@ function heatmappishCalc(gd, trace) { interp2d(z, trace._emptypoints); // create arrays of brick boundaries, to be used by autorange and heatmap.plot - var xlen = maxRowLength(z), + var xlen = Lib.maxRowLength(z), xIn = trace.xtype === 'scaled' ? '' : a, xArray = makeBoundArray(trace, xIn, a0, da, xlen, aax), yIn = trace.ytype === 'scaled' ? '' : b, @@ -147908,13 +150180,17 @@ function heatmappishCalc(gd, trace) { if(trace.contours.type === 'levels' && trace.contours.coloring !== 'none') { // auto-z and autocolorscale if applicable - colorscaleCalc(trace, z, '', 'z'); + colorscaleCalc(gd, trace, { + vals: z, + containerStr: '', + cLetter: 'z' + }); } return [cd0]; } -},{"../../components/colorscale/calc":578,"../../lib":696,"../carpet/lookup_carpetid":894,"../contour/set_contours":935,"../heatmap/clean_2d_array":947,"../heatmap/convert_column_xyz":949,"../heatmap/find_empties":951,"../heatmap/interp2d":954,"../heatmap/make_bound_array":955,"../heatmap/max_row_length":956,"./defaults":940}],940:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../lib":692,"../carpet/lookup_carpetid":891,"../contour/set_contours":932,"../heatmap/clean_2d_array":944,"../heatmap/convert_column_xyz":946,"../heatmap/find_empties":948,"../heatmap/interp2d":951,"../heatmap/make_bound_array":952,"./defaults":937}],937:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -147984,7 +150260,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../lib":696,"../contour/constraint_defaults":921,"../contour/contours_defaults":923,"../contour/style_defaults":937,"../heatmap/xyz_defaults":960,"./attributes":938}],941:[function(_dereq_,module,exports){ +},{"../../lib":692,"../contour/constraint_defaults":918,"../contour/contours_defaults":920,"../contour/style_defaults":934,"../heatmap/xyz_defaults":956,"./attributes":935}],938:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148015,7 +150291,7 @@ ContourCarpet.meta = { module.exports = ContourCarpet; -},{"../../plots/cartesian":756,"../contour/colorbar":919,"../contour/style":936,"./attributes":938,"./calc":939,"./defaults":940,"./plot":944}],942:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../contour/colorbar":916,"../contour/style":933,"./attributes":935,"./calc":936,"./defaults":937,"./plot":941}],939:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148149,7 +150425,7 @@ module.exports = function joinAllPaths(trace, pi, perimeter, ab2p, carpet, carpe return fullpath; }; -},{"../../components/drawing":595,"../../lib":696,"../carpet/axis_aligned_line":878}],943:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../carpet/axis_aligned_line":875}],940:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148186,7 +150462,7 @@ module.exports = function mapPathinfo(pathinfo, map) { } }; -},{}],944:[function(_dereq_,module,exports){ +},{}],941:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148302,7 +150578,7 @@ module.exports = function plot(gd, plotinfo, cdcontours, contourcarpetLayer) { makeLinesAndLabels(plotGroup, pathinfo, gd, cd0, contours, plotinfo, carpet); // Clip the boundary of the plot - Drawing.setClipUrl(plotGroup, carpet._clipPathId); + Drawing.setClipUrl(plotGroup, carpet._clipPathId, gd); }); }; @@ -148318,8 +150594,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, plotinfo, ca // In this case we'll remove the lines after making the labels. var linegroup = contourPlot.createLines(lineContainer, showLines || showLabels, pathinfo); - var lineClip = contourPlot.createLineClip(lineContainer, clipLinesForLabels, - gd._fullLayout._defs, cd0.trace.uid); + var lineClip = contourPlot.createLineClip(lineContainer, clipLinesForLabels, gd, cd0.trace.uid); var labelGroup = plotgroup.selectAll('g.contourlabels') .data(showLabels ? [0] : []); @@ -148521,7 +150796,7 @@ function makeFills(trace, plotgroup, xa, ya, pathinfo, perimeter, ab2p, carpet, }); } -},{"../../components/drawing":595,"../../lib":696,"../carpet/lookup_carpetid":894,"../carpet/makepath":895,"../carpet/map_1d_array":896,"../contour/close_boundaries":918,"../contour/constants":920,"../contour/convert_to_constraints":924,"../contour/empty_pathinfo":926,"../contour/find_all_paths":928,"../contour/make_crossings":933,"../contour/plot":934,"./join_all_paths":942,"./map_pathinfo":943,"d3":148}],945:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../carpet/lookup_carpetid":891,"../carpet/makepath":892,"../carpet/map_1d_array":893,"../contour/close_boundaries":915,"../contour/constants":917,"../contour/convert_to_constraints":921,"../contour/empty_pathinfo":923,"../contour/find_all_paths":925,"../contour/make_crossings":930,"../contour/plot":931,"./join_all_paths":939,"./map_pathinfo":940,"d3":148}],942:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148624,7 +150899,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../scatter/attributes":1043}],946:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../scatter/attributes":1040}],943:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148643,7 +150918,6 @@ var Axes = _dereq_('../../plots/cartesian/axes'); var histogram2dCalc = _dereq_('../histogram2d/calc'); var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var convertColumnData = _dereq_('./convert_column_xyz'); -var maxRowLength = _dereq_('./max_row_length'); var clean2dArray = _dereq_('./clean_2d_array'); var interp2d = _dereq_('./interp2d'); var findEmpties = _dereq_('./find_empties'); @@ -148743,7 +151017,7 @@ module.exports = function calc(gd, trace) { } // create arrays of brick boundaries, to be used by autorange and heatmap.plot - var xlen = maxRowLength(z); + var xlen = Lib.maxRowLength(z); var xIn = trace.xtype === 'scaled' ? '' : x; var xArray = makeBoundArray(trace, xIn, x0, dx, xlen, xa); var yIn = trace.ytype === 'scaled' ? '' : y; @@ -148773,7 +151047,11 @@ module.exports = function calc(gd, trace) { // auto-z and autocolorscale if applicable if(!isContour || trace.contours.type !== 'constraint') { - colorscaleCalc(trace, z, '', 'z'); + colorscaleCalc(gd, trace, { + vals: z, + containerStr: '', + cLetter: 'z' + }); } if(isContour && trace.contours && trace.contours.coloring === 'heatmap') { @@ -148789,7 +151067,7 @@ module.exports = function calc(gd, trace) { return [cd0]; }; -},{"../../components/colorscale/calc":578,"../../lib":696,"../../plots/cartesian/axes":744,"../../registry":827,"../histogram2d/calc":977,"./clean_2d_array":947,"./convert_column_xyz":949,"./find_empties":951,"./interp2d":954,"./make_bound_array":955,"./max_row_length":956}],947:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../lib":692,"../../plots/cartesian/axes":740,"../../registry":823,"../histogram2d/calc":974,"./clean_2d_array":944,"./convert_column_xyz":946,"./find_empties":948,"./interp2d":951,"./make_bound_array":952}],944:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148834,7 +151112,7 @@ module.exports = function clean2dArray(zOld, transpose) { return zNew; }; -},{"fast-isnumeric":214}],948:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214}],945:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148850,7 +151128,7 @@ module.exports = { max: 'zmax' }; -},{}],949:[function(_dereq_,module,exports){ +},{}],946:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148867,43 +151145,36 @@ var BADNUM = _dereq_('../../constants/numerical').BADNUM; module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, arrayVarNames) { var colLen = trace._length; - var col1 = trace[var1Name].slice(0, colLen); - var col2 = trace[var2Name].slice(0, colLen); + var col1 = ax1.makeCalcdata(trace, var1Name); + var col2 = ax2.makeCalcdata(trace, var2Name); var textCol = trace.text; var hasColumnText = (textCol !== undefined && Lib.isArray1D(textCol)); - var col1Calendar = trace[var1Name + 'calendar']; - var col2Calendar = trace[var2Name + 'calendar']; - - var i, j, arrayVar, newArray, arrayVarName; - - for(i = 0; i < colLen; i++) { - col1[i] = ax1.d2c(col1[i], 0, col1Calendar); - col2[i] = ax2.d2c(col2[i], 0, col2Calendar); - } + var i, j; - var col1dv = Lib.distinctVals(col1), - col1vals = col1dv.vals, - col2dv = Lib.distinctVals(col2), - col2vals = col2dv.vals, - newArrays = []; + var col1dv = Lib.distinctVals(col1); + var col1vals = col1dv.vals; + var col2dv = Lib.distinctVals(col2); + var col2vals = col2dv.vals; + var newArrays = []; + var text; for(i = 0; i < arrayVarNames.length; i++) { newArrays[i] = Lib.init2dArray(col2vals.length, col1vals.length); } - var i1, i2, text; - - if(hasColumnText) text = Lib.init2dArray(col2vals.length, col1vals.length); + if(hasColumnText) { + text = Lib.init2dArray(col2vals.length, col1vals.length); + } for(i = 0; i < colLen; i++) { if(col1[i] !== BADNUM && col2[i] !== BADNUM) { - i1 = Lib.findBin(col1[i] + col1dv.minDiff / 2, col1vals); - i2 = Lib.findBin(col2[i] + col2dv.minDiff / 2, col2vals); + var i1 = Lib.findBin(col1[i] + col1dv.minDiff / 2, col1vals); + var i2 = Lib.findBin(col2[i] + col2dv.minDiff / 2, col2vals); for(j = 0; j < arrayVarNames.length; j++) { - arrayVarName = arrayVarNames[j]; - arrayVar = trace[arrayVarName]; - newArray = newArrays[j]; + var arrayVarName = arrayVarNames[j]; + var arrayVar = trace[arrayVarName]; + var newArray = newArrays[j]; newArray[i2][i1] = arrayVar[i]; } @@ -148919,7 +151190,7 @@ module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, if(hasColumnText) trace._text = text; }; -},{"../../constants/numerical":673,"../../lib":696}],950:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692}],947:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148959,7 +151230,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}); }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"./attributes":945,"./style_defaults":959,"./xyz_defaults":960}],951:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"./attributes":942,"./style_defaults":955,"./xyz_defaults":956}],948:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -148970,7 +151241,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout 'use strict'; -var maxRowLength = _dereq_('./max_row_length'); +var maxRowLength = _dereq_('../../lib').maxRowLength; /* Return a list of empty points in 2D array z * each empty point z[i][j] gives an array [i, j, neighborCount] @@ -149065,7 +151336,7 @@ module.exports = function findEmpties(z) { return empties.sort(function(a, b) { return b[2] - a[2]; }); }; -},{"./max_row_length":956}],952:[function(_dereq_,module,exports){ +},{"../../lib":692}],949:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149194,7 +151465,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay })]; }; -},{"../../components/fx":612,"../../lib":696,"../../plots/cartesian/axes":744}],953:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../lib":692,"../../plots/cartesian/axes":740}],950:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149226,7 +151497,7 @@ Heatmap.meta = { module.exports = Heatmap; -},{"../../plots/cartesian":756,"./attributes":945,"./calc":946,"./colorbar":948,"./defaults":950,"./hover":952,"./plot":957,"./style":958}],954:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":942,"./calc":943,"./colorbar":945,"./defaults":947,"./hover":949,"./plot":953,"./style":954}],951:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149361,7 +151632,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { return maxFractionalChange; } -},{"../../lib":696}],955:[function(_dereq_,module,exports){ +},{"../../lib":692}],952:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149431,10 +151702,15 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, var calendar = trace[ax._id.charAt(0) + 'calendar']; - if(isHist || ax.type === 'category') v0 = ax.r2c(v0In, 0, calendar) || 0; - else if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) v0 = arrayIn[0]; - else if(v0In === undefined) v0 = 0; - else v0 = ax.d2c(v0In, 0, calendar); + if(isHist || ax.type === 'category' || ax.type === 'multicategory') { + v0 = ax.r2c(v0In, 0, calendar) || 0; + } else if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) { + v0 = arrayIn[0]; + } else if(v0In === undefined) { + v0 = 0; + } else { + v0 = ax.d2c(v0In, 0, calendar); + } for(i = (isContour || isGL2D) ? 0 : -0.5; i < numbricks; i++) { arrayOut.push(v0 + dv * i); @@ -149444,29 +151720,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, return arrayOut; }; -},{"../../lib":696,"../../registry":827}],956:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -module.exports = function maxRowLength(z) { - var len = 0; - - for(var i = 0; i < z.length; i++) { - len = Math.max(len, z[i].length); - } - - return len; -}; - -},{}],957:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],953:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149486,8 +151740,6 @@ var Lib = _dereq_('../../lib'); var Colorscale = _dereq_('../../components/colorscale'); var xmlnsNamespaces = _dereq_('../../constants/xmlns_namespaces'); -var maxRowLength = _dereq_('./max_row_length'); - module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { var xa = plotinfo.xaxis; var ya = plotinfo.yaxis; @@ -149507,7 +151759,7 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { // get z dims var m = z.length; - var n = maxRowLength(z); + var n = Lib.maxRowLength(z); var xrev = false; var yrev = false; @@ -149612,11 +151864,7 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { var context = canvas.getContext('2d'); var sclFunc = Colorscale.makeColorScaleFunc( - Colorscale.extractScale( - trace.colorscale, - trace.zmin, - trace.zmax - ), + Colorscale.extractScale(trace, {cLetter: 'z'}), { noNumericCheck: true, returnArray: true } ); @@ -149887,7 +152135,7 @@ function putColor(pixels, pxIndex, c) { pixels[pxIndex + 3] = Math.round(c[3] * 255); } -},{"../../components/colorscale":585,"../../constants/xmlns_namespaces":674,"../../lib":696,"../../registry":827,"./max_row_length":956,"d3":148,"tinycolor2":514}],958:[function(_dereq_,module,exports){ +},{"../../components/colorscale":581,"../../constants/xmlns_namespaces":670,"../../lib":692,"../../registry":823,"d3":148,"tinycolor2":513}],954:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149908,7 +152156,7 @@ module.exports = function style(gd) { }); }; -},{"d3":148}],959:[function(_dereq_,module,exports){ +},{"d3":148}],955:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149931,7 +152179,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { coerce('zhoverformat'); }; -},{}],960:[function(_dereq_,module,exports){ +},{}],956:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -149940,7 +152188,6 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -149960,10 +152207,13 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x x = coerce(xName); y = coerce(yName); + var xlen = Lib.minRowLength(x); + var ylen = Lib.minRowLength(y); + // column z must be accompanied by xName and yName arrays - if(!(x && x.length && y && y.length)) return 0; + if(xlen === 0 || ylen === 0) return 0; - traceOut._length = Math.min(x.length, y.length, z.length); + traceOut._length = Math.min(xlen, ylen, z.length); } else { x = coordDefaults(xName, coerce); @@ -149984,10 +152234,8 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x }; function coordDefaults(coordStr, coerce) { - var coord = coerce(coordStr), - coordType = coord ? - coerce(coordStr + 'type', 'array') : - 'scaled'; + var coord = coerce(coordStr); + var coordType = coord ? coerce(coordStr + 'type', 'array') : 'scaled'; if(coordType === 'scaled') { coerce(coordStr + '0'); @@ -150029,7 +152277,7 @@ function isValidZ(z) { return (allRowsAreArrays && oneRowIsFilled && hasOneNumber); } -},{"../../lib":696,"../../registry":827,"fast-isnumeric":214}],961:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"fast-isnumeric":214}],957:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150072,7 +152320,7 @@ extendFlat( module.exports = overrideAll(attrs, 'calc', 'nested'); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/edit_types":727,"../heatmap/attributes":945}],962:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/edit_types":723,"../heatmap/attributes":942}],958:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150214,7 +152462,7 @@ function createHeatmap(scene, fullTrace, calcTrace) { module.exports = createHeatmap; -},{"../../lib/str2rgbarray":719,"../../plots/cartesian/axes":744,"gl-heatmap2d":241}],963:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":715,"../../plots/cartesian/axes":740,"gl-heatmap2d":241}],959:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150245,7 +152493,7 @@ HeatmapGl.meta = { module.exports = HeatmapGl; -},{"../../plots/gl2d":784,"../heatmap/calc":946,"../heatmap/colorbar":948,"../heatmap/defaults":950,"./attributes":961,"./convert":962}],964:[function(_dereq_,module,exports){ +},{"../../plots/gl2d":780,"../heatmap/calc":943,"../heatmap/colorbar":945,"../heatmap/defaults":947,"./attributes":957,"./convert":958}],960:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150257,7 +152505,9 @@ module.exports = HeatmapGl; 'use strict'; var barAttrs = _dereq_('../bar/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var makeBinAttrs = _dereq_('./bin_attributes'); +var constants = _dereq_('./constants'); module.exports = { x: { @@ -150350,14 +152600,13 @@ module.exports = { dflt: null, editType: 'calc', - impliedEdits: { - 'ybins.start': undefined, - 'ybins.end': undefined, - 'ybins.size': undefined - }, }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), + marker: barAttrs.marker, selected: barAttrs.selected, @@ -150368,7 +152617,7 @@ module.exports = { } }; -},{"../bar/attributes":837,"./bin_attributes":966}],965:[function(_dereq_,module,exports){ +},{"../../components/fx/hovertemplate_attributes":607,"../bar/attributes":833,"./bin_attributes":962,"./constants":966}],961:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150394,7 +152643,7 @@ module.exports = function doAvg(size, counts) { return total; }; -},{}],966:[function(_dereq_,module,exports){ +},{}],962:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150429,7 +152678,7 @@ module.exports = function makeBinAttrs(axLetter, match) { }; }; -},{}],967:[function(_dereq_,module,exports){ +},{}],963:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150505,7 +152754,7 @@ module.exports = { } }; -},{"fast-isnumeric":214}],968:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214}],964:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150683,7 +152932,7 @@ function dateParts(v, pa, calendar) { return parts; } -},{"../../constants/numerical":673,"../../plots/cartesian/axes":744}],969:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../plots/cartesian/axes":740}],965:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -150937,16 +153186,18 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { var isFirstVisible = true; for(i = 0; i < traces.length; i++) { tracei = traces[i]; - pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData); - allPos = Lib.concat(allPos, pos0); - delete tracei._autoBinFinished; - if(trace.visible === true) { - if(isFirstVisible) { - isFirstVisible = false; - } - else { - delete tracei._autoBin; - tracei._autoBinFinished = 1; + if(tracei.visible) { + pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData); + allPos = Lib.concat(allPos, pos0); + delete tracei._autoBinFinished; + if(trace.visible === true) { + if(isFirstVisible) { + isFirstVisible = false; + } + else { + delete tracei._autoBin; + tracei._autoBinFinished = 1; + } } } } @@ -150956,7 +153207,8 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { // Edge case: single-valued histogram overlaying others // Use them all together to calculate the bin size for the single-valued one - if(isOverlay && newBinSpec._dataSpan === 0 && pa.type !== 'category') { + if(isOverlay && newBinSpec._dataSpan === 0 && + pa.type !== 'category' && pa.type !== 'multicategory') { // Several single-valued histograms! Stop infinite recursion, // just return an extra flag that tells handleSingleValueOverlays // to sort out this trace too @@ -151013,7 +153265,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { Lib.aggNums(Math.min, null, pos0); var dummyAx = { - type: pa.type === 'category' ? 'linear' : pa.type, + type: (pa.type === 'category' || pa.type === 'multicategory') ? 'linear' : pa.type, r2l: pa.r2l, dtick: binOpts.size, tick0: mainStart, @@ -151213,7 +153465,23 @@ function cdf(size, direction, currentBin) { } } -},{"../../lib":696,"../../plots/cartesian/axes":744,"../bar/arrays_to_calcdata":836,"./average":965,"./bin_functions":967,"./bin_label_vals":968,"./norm_functions":975,"fast-isnumeric":214}],970:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../bar/arrays_to_calcdata":832,"./average":961,"./bin_functions":963,"./bin_label_vals":964,"./norm_functions":972,"fast-isnumeric":214}],966:[function(_dereq_,module,exports){ +/** +* Copyright 2012-2018, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +'use strict'; + +module.exports = { + eventDataKeys: ['binNumber'] +}; + +},{}],967:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151327,7 +153595,7 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) { } }; -},{"../../lib":696,"./attributes":964}],971:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":960}],968:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151366,7 +153634,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var sampleLetter = orientation === 'v' ? 'x' : 'y'; var aggLetter = orientation === 'v' ? 'y' : 'x'; - var len = (x && y) ? Math.min(x.length && y.length) : (traceOut[sampleLetter] || []).length; + var len = (x && y) ? + Math.min(Lib.minRowLength(x) && Lib.minRowLength(y)) : + Lib.minRowLength(traceOut[sampleLetter] || []); if(!len) { traceOut.visible = false; @@ -151386,6 +153656,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout // autobin(x|y) are only included here to appease Plotly.validate coerce('autobin' + sampleLetter); + coerce('hovertemplate'); + handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout); // override defaultColor for error bars with defaultLine @@ -151396,7 +153668,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../components/color":570,"../../lib":696,"../../registry":827,"../bar/style_defaults":850,"./attributes":964}],972:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../../registry":823,"../bar/style_defaults":847,"./attributes":960}],969:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151442,7 +153714,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],973:[function(_dereq_,module,exports){ +},{}],970:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151472,10 +153744,12 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { pointData[posLetter + 'Label'] = hoverLabelText(pointData[posLetter + 'a'], di.ph0, di.ph1); } + if(trace.hovermplate) pointData.hovertemplate = trace.hovertemplate; + return pts; }; -},{"../../plots/cartesian/axes":744,"../bar/hover":842}],974:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../bar/hover":839}],971:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151529,7 +153803,7 @@ Histogram.meta = { module.exports = Histogram; -},{"../../plots/cartesian":756,"../bar/cross_trace_calc":839,"../bar/layout_attributes":844,"../bar/layout_defaults":845,"../bar/plot":846,"../bar/select":847,"../bar/style":849,"../scatter/marker_colorbar":1061,"./attributes":964,"./calc":969,"./cross_trace_defaults":970,"./defaults":971,"./event_data":972,"./hover":973}],975:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../bar/cross_trace_calc":836,"../bar/layout_attributes":841,"../bar/layout_defaults":842,"../bar/plot":843,"../bar/select":844,"../bar/style":846,"../scatter/marker_colorbar":1058,"./attributes":960,"./calc":965,"./cross_trace_defaults":967,"./defaults":968,"./event_data":969,"./hover":970}],972:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151564,7 +153838,7 @@ module.exports = { } }; -},{}],976:[function(_dereq_,module,exports){ +},{}],973:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151623,7 +153897,7 @@ module.exports = extendFlat( { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../heatmap/attributes":945,"../histogram/attributes":964,"../histogram/bin_attributes":966}],977:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../heatmap/attributes":942,"../histogram/attributes":960,"../histogram/bin_attributes":962}],974:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151888,7 +154162,7 @@ function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) { return out; } -},{"../../lib":696,"../../plots/cartesian/axes":744,"../histogram/average":965,"../histogram/bin_functions":967,"../histogram/bin_label_vals":968,"../histogram/norm_functions":975}],978:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../histogram/average":961,"../histogram/bin_functions":963,"../histogram/bin_label_vals":964,"../histogram/norm_functions":972}],975:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -151983,7 +154257,7 @@ function cleanBins(trace, binDirection, fullLayout, autoBins) { } } -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axis_ids":747,"./attributes":976,"fast-isnumeric":214}],979:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axis_ids":743,"./attributes":973,"fast-isnumeric":214}],976:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152017,7 +154291,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout ); }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"../heatmap/style_defaults":959,"./attributes":976,"./sample_defaults":982}],980:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"../heatmap/style_defaults":955,"./attributes":973,"./sample_defaults":979}],977:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152051,7 +154325,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return pts; }; -},{"../../plots/cartesian/axes":744,"../heatmap/hover":952}],981:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../heatmap/hover":949}],978:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152087,7 +154361,7 @@ Histogram2D.meta = { module.exports = Histogram2D; -},{"../../plots/cartesian":756,"../heatmap/calc":946,"../heatmap/colorbar":948,"../heatmap/plot":957,"../heatmap/style":958,"../histogram/event_data":972,"./attributes":976,"./cross_trace_defaults":978,"./defaults":979,"./hover":980}],982:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../heatmap/calc":943,"../heatmap/colorbar":945,"../heatmap/plot":953,"../heatmap/style":954,"../histogram/event_data":969,"./attributes":973,"./cross_trace_defaults":975,"./defaults":976,"./hover":977}],979:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152096,24 +154370,26 @@ module.exports = Histogram2D; * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Registry = _dereq_('../../registry'); +var Lib = _dereq_('../../lib'); module.exports = function handleSampleDefaults(traceIn, traceOut, coerce, layout) { var x = coerce('x'); var y = coerce('y'); + var xlen = Lib.minRowLength(x); + var ylen = Lib.minRowLength(y); // we could try to accept x0 and dx, etc... // but that's a pretty weird use case. // for now require both x and y explicitly specified. - if(!(x && x.length && y && y.length)) { + if(!xlen || !ylen) { traceOut.visible = false; return; } - traceOut._length = Math.min(x.length, y.length); + traceOut._length = Math.min(xlen, ylen); var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); @@ -152130,7 +154406,7 @@ module.exports = function handleSampleDefaults(traceIn, traceOut, coerce, layout coerce('autobiny'); }; -},{"../../registry":827}],983:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],980:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152176,7 +154452,7 @@ module.exports = extendFlat({ { colorbar: colorbarAttrs } ); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../contour/attributes":916,"../histogram2d/attributes":976}],984:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../contour/attributes":913,"../histogram2d/attributes":973}],981:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152212,7 +154488,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleStyleDefaults(traceIn, traceOut, coerce, layout); }; -},{"../../lib":696,"../contour/contours_defaults":923,"../contour/style_defaults":937,"../histogram2d/sample_defaults":982,"./attributes":983}],985:[function(_dereq_,module,exports){ +},{"../../lib":692,"../contour/contours_defaults":920,"../contour/style_defaults":934,"../histogram2d/sample_defaults":979,"./attributes":980}],982:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152247,7 +154523,7 @@ Histogram2dContour.meta = { module.exports = Histogram2dContour; -},{"../../plots/cartesian":756,"../contour/calc":917,"../contour/colorbar":919,"../contour/hover":929,"../contour/plot":934,"../contour/style":936,"../histogram2d/cross_trace_defaults":978,"./attributes":983,"./defaults":984}],986:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../contour/calc":914,"../contour/colorbar":916,"../contour/hover":926,"../contour/plot":931,"../contour/style":933,"../histogram2d/cross_trace_defaults":975,"./attributes":980,"./defaults":981}],983:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152413,7 +154689,7 @@ colorscaleAttrs('', { hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {editType: 'calc'}) }); -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../surface/attributes":1130}],987:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../surface/attributes":1127}],984:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152428,11 +154704,15 @@ var colorscaleCalc = _dereq_('../../components/colorscale/calc'); module.exports = function calc(gd, trace) { if(trace.intensity) { - colorscaleCalc(trace, trace.intensity, '', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.intensity, + containerStr: '', + cLetter: 'c' + }); } }; -},{"../../components/colorscale/calc":578}],988:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577}],985:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152583,7 +154863,7 @@ function createMesh3DTrace(scene, data) { module.exports = createMesh3DTrace; -},{"../../lib/gl_format_color":692,"../../lib/str2rgbarray":719,"../../plots/gl3d/zip3":798,"alpha-shape":52,"convex-hull":118,"delaunay-triangulate":150,"gl-mesh3d":268}],989:[function(_dereq_,module,exports){ +},{"../../lib/gl_format_color":689,"../../lib/str2rgbarray":715,"../../plots/gl3d/zip3":794,"alpha-shape":52,"convex-hull":118,"delaunay-triangulate":150,"gl-mesh3d":268}],986:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152679,7 +154959,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"../../registry":827,"./attributes":986}],990:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"../../registry":823,"./attributes":983}],987:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152712,7 +154992,7 @@ Mesh3D.meta = { module.exports = Mesh3D; -},{"../../plots/gl3d":787,"./attributes":986,"./calc":987,"./convert":988,"./defaults":989}],991:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":783,"./attributes":983,"./calc":984,"./convert":985,"./defaults":986}],988:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152822,7 +155102,7 @@ module.exports = { }), }; -},{"../../components/drawing/attributes":594,"../../components/fx/attributes":604,"../../lib":696,"../scatter/attributes":1043}],992:[function(_dereq_,module,exports){ +},{"../../components/drawing/attributes":589,"../../components/fx/attributes":599,"../../lib":692,"../scatter/attributes":1040}],989:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -152917,7 +155197,7 @@ function calcCommon(gd, trace, x, ya, ptFunc) { } } - trace._extremes[ya._id] = Axes.findExtremes(ya, l.concat(h), {padded: true}); + trace._extremes[ya._id] = Axes.findExtremes(ya, Lib.concat(l, h), {padded: true}); if(cd.length) { cd[0].t = { @@ -152987,7 +155267,7 @@ module.exports = { calcCommon: calcCommon }; -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axes":744}],993:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axes":740}],990:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153032,7 +155312,7 @@ function handleDirection(traceIn, traceOut, coerce, direction) { coerce(direction + '.line.dash', traceOut.line.dash); } -},{"../../lib":696,"./attributes":991,"./ohlc_defaults":996}],994:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":988,"./ohlc_defaults":993}],991:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153234,7 +155514,7 @@ module.exports = { hoverOnPoints: hoverOnPoints }; -},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051}],995:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048}],992:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153263,7 +155543,7 @@ module.exports = { selectPoints: _dereq_('./select') }; -},{"../../plots/cartesian":756,"./attributes":991,"./calc":992,"./defaults":993,"./hover":994,"./plot":997,"./select":998,"./style":999}],996:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./attributes":988,"./calc":989,"./defaults":990,"./hover":991,"./plot":994,"./select":995,"./style":996}],993:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153272,11 +155552,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Registry = _dereq_('../../registry'); - +var Lib = _dereq_('../../lib'); module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) { var x = coerce('x'); @@ -153293,15 +155572,13 @@ module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) { if(!(open && high && low && close)) return; var len = Math.min(open.length, high.length, low.length, close.length); - - if(x) len = Math.min(len, x.length); - + if(x) len = Math.min(len, Lib.minRowLength(x)); traceOut._length = len; return len; }; -},{"../../registry":827}],997:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],994:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153357,7 +155634,7 @@ module.exports = function plot(gd, plotinfo, cdOHLC, ohlcLayer) { }); }; -},{"../../lib":696,"d3":148}],998:[function(_dereq_,module,exports){ +},{"../../lib":692,"d3":148}],995:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153402,7 +155679,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],999:[function(_dereq_,module,exports){ +},{}],996:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153439,7 +155716,7 @@ module.exports = function style(gd, cd) { }); }; -},{"../../components/color":570,"../../components/drawing":595,"d3":148}],1000:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"d3":148}],997:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153599,7 +155876,7 @@ module.exports = { showlegend: undefined }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../../plots/domain":770,"../../plots/font_attributes":771,"../scatter/attributes":1043}],1001:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../../plots/domain":766,"../../plots/font_attributes":767,"../scatter/attributes":1040}],998:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153635,7 +155912,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../plots/get_data":781,"./plot":1006}],1002:[function(_dereq_,module,exports){ +},{"../../plots/get_data":777,"./plot":1003}],999:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -153649,7 +155926,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) // Requirements // ============ var wrap = _dereq_('../../lib/gup').wrap; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleCalc = _dereq_('../../components/colorscale/calc'); var filterUnique = _dereq_('../../lib/filter_unique.js'); var Drawing = _dereq_('../../components/drawing'); @@ -153711,7 +155988,11 @@ module.exports = function calc(gd, trace) { // Process colorscale if(line) { if(hasColorscale(trace, 'line')) { - colorscaleCalc(trace, trace.line.color, 'line', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } markerColorscale = Drawing.tryColorscale(line); } else { @@ -154142,7 +156423,7 @@ function isRangePermutation(inds) { return true; } -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"../../components/drawing":595,"../../lib":696,"../../lib/filter_unique.js":686,"../../lib/gup":693}],1003:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"../../components/drawing":590,"../../lib":692,"../../lib/filter_unique.js":683,"../../lib/gup":690}],1000:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154154,7 +156435,7 @@ function isRangePermutation(inds) { 'use strict'; var Lib = _dereq_('../../lib'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var handleDomainDefaults = _dereq_('../../plots/domain').defaults; var handleArrayContainerDefaults = _dereq_('../../plots/array_container_defaults'); @@ -154263,7 +156544,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceFont(coerce, 'tickfont', categoryfontDefault); }; -},{"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/domain":770,"../parcoords/merge_length":1015,"./attributes":1000}],1004:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/domain":766,"../parcoords/merge_length":1012,"./attributes":997}],1001:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -154296,7 +156577,7 @@ Parcats.meta = { module.exports = Parcats; -},{"./attributes":1000,"./base_plot":1001,"./calc":1002,"./defaults":1003,"./plot":1006}],1005:[function(_dereq_,module,exports){ +},{"./attributes":997,"./base_plot":998,"./calc":999,"./defaults":1000,"./plot":1003}],1002:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -156381,7 +158662,7 @@ function createDimensionViewModel(parcatsViewModel, dimensionModel) { * The parent trace's view model */ -},{"../../components/drawing":595,"../../components/fx":612,"../../lib":696,"../../lib/svg_text_utils":720,"../../plot_api/plot_api":731,"d3":148,"tinycolor2":514}],1006:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../components/fx":608,"../../lib":692,"../../lib/svg_text_utils":716,"../../plot_api/plot_api":727,"d3":148,"tinycolor2":513}],1003:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -156425,7 +158706,7 @@ module.exports = function plot(graphDiv, parcatsModels, transitionOpts, makeOnCo ); }; -},{"./parcats":1005}],1007:[function(_dereq_,module,exports){ +},{"./parcats":1002}],1004:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -156540,7 +158821,7 @@ module.exports = { }) }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/plot_template":734,"../../plots/cartesian/layout_attributes":757,"../../plots/domain":770,"../../plots/font_attributes":771}],1008:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/plot_template":730,"../../plots/cartesian/layout_attributes":753,"../../plots/domain":766,"../../plots/font_attributes":767}],1005:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -157072,7 +159353,7 @@ module.exports = { cleanRanges: cleanRanges }; -},{"../../lib":696,"../../lib/gup":693,"./constants":1011,"d3":148}],1009:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gup":690,"./constants":1008,"d3":148}],1006:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -157141,7 +159422,7 @@ exports.toSVG = function(gd) { }, 60); }; -},{"../../constants/xmlns_namespaces":674,"../../plots/get_data":781,"./plot":1017,"d3":148}],1010:[function(_dereq_,module,exports){ +},{"../../constants/xmlns_namespaces":670,"../../plots/get_data":777,"./plot":1014,"d3":148}],1007:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -157152,7 +159433,7 @@ exports.toSVG = function(gd) { 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var Lib = _dereq_('../../lib'); var wrap = _dereq_('../../lib/gup').wrap; @@ -157163,7 +159444,11 @@ module.exports = function calc(gd, trace) { var cscale = cs ? trace.line.colorscale : [[0, trace.line.color], [1, trace.line.color]]; if(hasColorscale(trace, 'line')) { - calcColorscale(trace, color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: color, + containerStr: 'line', + cLetter: 'c' + }); } return wrap({ @@ -157180,7 +159465,7 @@ function constHalf(len) { return out; } -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../lib/gup":693}],1011:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"../../lib":692,"../../lib/gup":690}],1008:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -157241,7 +159526,7 @@ module.exports = { } }; -},{}],1012:[function(_dereq_,module,exports){ +},{}],1009:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -157253,7 +159538,7 @@ module.exports = { 'use strict'; var Lib = _dereq_('../../lib'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var handleDomainDefaults = _dereq_('../../plots/domain').defaults; var handleArrayContainerDefaults = _dereq_('../../plots/array_container_defaults'); @@ -157347,7 +159632,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceFont(coerce, 'rangefont', fontDflt); }; -},{"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/domain":770,"./attributes":1007,"./axisbrush":1008,"./constants":1011,"./merge_length":1015}],1013:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/domain":766,"./attributes":1004,"./axisbrush":1005,"./constants":1008,"./merge_length":1012}],1010:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -157380,7 +159665,7 @@ Parcoords.meta = { module.exports = Parcoords; -},{"./attributes":1007,"./base_plot":1009,"./calc":1010,"./defaults":1012,"./plot":1017}],1014:[function(_dereq_,module,exports){ +},{"./attributes":1004,"./base_plot":1006,"./calc":1007,"./defaults":1009,"./plot":1014}],1011:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -157912,7 +160197,7 @@ module.exports = function(canvasGL, d) { }; }; -},{"../../lib":696,"glslify":392}],1015:[function(_dereq_,module,exports){ +},{"../../lib":692,"glslify":392}],1012:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -157950,7 +160235,7 @@ module.exports = function(traceOut, dimensions, dataAttr, len) { return len; }; -},{}],1016:[function(_dereq_,module,exports){ +},{}],1013:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -157961,16 +160246,20 @@ module.exports = function(traceOut, dimensions, dataAttr, len) { 'use strict'; -var lineLayerMaker = _dereq_('./lines'); -var c = _dereq_('./constants'); -var Lib = _dereq_('../../lib'); var d3 = _dereq_('d3'); + +var Lib = _dereq_('../../lib'); var Drawing = _dereq_('../../components/drawing'); +var Colorscale = _dereq_('../../components/colorscale'); + var gup = _dereq_('../../lib/gup'); var keyFun = gup.keyFun; var repeat = gup.repeat; var unwrap = gup.unwrap; + +var c = _dereq_('./constants'); var brush = _dereq_('./axisbrush'); +var lineLayerMaker = _dereq_('./lines'); function visible(dimension) { return !('visible' in dimension) || dimension.visible; } @@ -158082,8 +160371,8 @@ function model(layout, d, i) { var cd0 = unwrap(d), trace = cd0.trace, lineColor = cd0.lineColor, - cscale = cd0.cscale, line = trace.line, + cscale = line.reversescale ? Colorscale.flipScale(cd0.cscale) : cd0.cscale, domain = trace.domain, dimensions = trace.dimensions, width = layout.width, @@ -158605,7 +160894,7 @@ module.exports = function(root, svg, parcoordsLineLayers, styledData, layout, ca brush.ensureAxisBrush(axisOverlays); }; -},{"../../components/drawing":595,"../../lib":696,"../../lib/gup":693,"./axisbrush":1008,"./constants":1011,"./lines":1014,"d3":148}],1017:[function(_dereq_,module,exports){ +},{"../../components/colorscale":581,"../../components/drawing":590,"../../lib":692,"../../lib/gup":690,"./axisbrush":1005,"./constants":1008,"./lines":1011,"d3":148}],1014:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -158630,12 +160919,17 @@ module.exports = function plot(gd, cdparcoords) { var gdDimensions = {}; var gdDimensionsOriginalOrder = {}; + var fullIndices = {}; + var inputIndices = {}; var size = fullLayout._size; cdparcoords.forEach(function(d, i) { - gdDimensions[i] = gd.data[i].dimensions; - gdDimensionsOriginalOrder[i] = gd.data[i].dimensions.slice(); + var trace = d[0].trace; + fullIndices[i] = trace.index; + var iIn = inputIndices[i] = trace._fullInput.index; + gdDimensions[i] = gd.data[iIn].dimensions; + gdDimensionsOriginalOrder[i] = gd.data[iIn].dimensions.slice(); }); var filterChanged = function(i, originalDimensionIndex, newRanges) { @@ -158645,21 +160939,36 @@ module.exports = function plot(gd, cdparcoords) { var gdDimension = gdDimensionsOriginalOrder[i][originalDimensionIndex]; var newConstraints = newRanges.map(function(r) { return r.slice(); }); + + // Store constraint range in preGUI + // This one doesn't work if it's stored in pieces in _storeDirectGUIEdit + // because it's an array of variable dimensionality. So store the whole + // thing at once manually. + var aStr = 'dimensions[' + originalDimensionIndex + '].constraintrange'; + var preGUI = fullLayout._tracePreGUI[gd._fullData[fullIndices[i]]._fullInput.uid]; + if(preGUI[aStr] === undefined) { + var initialVal = gdDimension.constraintrange; + preGUI[aStr] = initialVal || null; + } + + var fullDimension = gd._fullData[fullIndices[i]].dimensions[originalDimensionIndex]; + if(!newConstraints.length) { delete gdDimension.constraintrange; + delete fullDimension.constraintrange; newConstraints = null; } else { if(newConstraints.length === 1) newConstraints = newConstraints[0]; gdDimension.constraintrange = newConstraints; + fullDimension.constraintrange = newConstraints.slice(); // wrap in another array for restyle event data newConstraints = [newConstraints]; } var restyleData = {}; - var aStr = 'dimensions[' + originalDimensionIndex + '].constraintrange'; restyleData[aStr] = newConstraints; - gd.emit('plotly_restyle', [restyleData, [i]]); + gd.emit('plotly_restyle', [restyleData, [inputIndices[i]]]); }; var hover = function(eventData) { @@ -158711,7 +161020,17 @@ module.exports = function plot(gd, cdparcoords) { gdDimensions[i].splice(gdDimensionsOriginalOrder[i].indexOf(d), 0, d); // insert at original index }); - gd.emit('plotly_restyle'); + // TODO: we can't really store this part of the interaction state + // directly as below, since it incudes data arrays. If we want to + // persist column order we may have to do something special for this + // case to just store the order itself. + // Registry.call('_storeDirectGUIEdit', + // gd.data[inputIndices[i]], + // fullLayout._tracePreGUI[gd._fullData[fullIndices[i]]._fullInput.uid], + // {dimensions: gdDimensions[i]} + // ); + + gd.emit('plotly_restyle', [{dimensions: [gdDimensions[i]]}, [inputIndices[i]]]); }; parcoords( @@ -158737,7 +161056,7 @@ module.exports = function plot(gd, cdparcoords) { }); }; -},{"../../lib/prepare_regl":709,"./parcoords":1016}],1018:[function(_dereq_,module,exports){ +},{"../../lib/prepare_regl":705,"./parcoords":1013}],1015:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -158751,6 +161070,7 @@ module.exports = function plot(gd, cdparcoords) { var colorAttrs = _dereq_('../../components/color/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); var plotAttrs = _dereq_('../../plots/attributes'); +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var domainAttrs = _dereq_('../../plots/domain').attributes; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -158858,6 +161178,9 @@ module.exports = { hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { flags: ['label', 'text', 'value', 'percent', 'name'] }), + hovertemplate: hovertemplateAttrs({}, { + keys: ['label', 'color', 'value', 'percent', 'text'] + }), textposition: { valType: 'enumerated', @@ -158878,26 +161201,30 @@ module.exports = { }), title: { - valType: 'string', - dflt: '', - - editType: 'calc', - - }, - titleposition: { - valType: 'enumerated', - values: [ - 'top left', 'top center', 'top right', - 'middle center', - 'bottom left', 'bottom center', 'bottom right' - ], - - editType: 'calc', - + text: { + valType: 'string', + dflt: '', + + editType: 'calc', + + }, + font: extendFlat({}, textFontAttrs, { + + }), + position: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + + editType: 'calc', + + }, + + editType: 'calc' }, - titlefont: extendFlat({}, textFontAttrs, { - - }), // position and shape domain: domainAttrs({name: 'pie', trace: true, editType: 'calc'}), @@ -158954,10 +161281,34 @@ module.exports = { arrayOk: true, editType: 'calc', + }, + + _deprecated: { + title: { + valType: 'string', + dflt: '', + + editType: 'calc', + + }, + titlefont: extendFlat({}, textFontAttrs, { + + }), + titleposition: { + valType: 'enumerated', + values: [ + 'top left', 'top center', 'top right', + 'middle center', + 'bottom left', 'bottom center', 'bottom right' + ], + + editType: 'calc', + + } } }; -},{"../../components/color/attributes":569,"../../lib/extend":685,"../../plots/attributes":741,"../../plots/domain":770,"../../plots/font_attributes":771}],1019:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plots/attributes":737,"../../plots/domain":766,"../../plots/font_attributes":767}],1016:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -158989,7 +161340,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../plots/get_data":781,"../../registry":827}],1020:[function(_dereq_,module,exports){ +},{"../../plots/get_data":777,"../../registry":823}],1017:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159180,7 +161531,7 @@ function generateExtendedColors(colorList) { return pieColors; } -},{"../../components/color":570,"../../lib":696,"./helpers":1023,"fast-isnumeric":214,"tinycolor2":514}],1021:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"./helpers":1020,"fast-isnumeric":214,"tinycolor2":513}],1018:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159234,6 +161585,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var textData = coerce('text'); var textInfo = coerce('textinfo', Array.isArray(textData) ? 'text+percent' : 'percent'); coerce('hovertext'); + coerce('hovertemplate'); if(textInfo && textInfo !== 'none') { var textPosition = coerce('textposition'), @@ -159259,11 +161611,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleDomainDefaults(traceOut, layout, coerce); var hole = coerce('hole'); - var title = coerce('title'); + var title = coerce('title.text'); if(title) { - var titlePosition = coerce('titleposition', hole ? 'middle center' : 'top center'); - if(!hole && titlePosition === 'middle center') traceOut.titleposition = 'top center'; - coerceFont(coerce, 'titlefont', layout.font); + var titlePosition = coerce('title.position', hole ? 'middle center' : 'top center'); + if(!hole && titlePosition === 'middle center') traceOut.title.position = 'top center'; + coerceFont(coerce, 'title.font', layout.font); } coerce('sort'); @@ -159273,7 +161625,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('pull'); }; -},{"../../lib":696,"../../plots/domain":770,"./attributes":1018}],1022:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/domain":766,"./attributes":1015}],1019:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159300,6 +161652,8 @@ module.exports = function eventData(pt, trace) { label: pt.label, color: pt.color, value: pt.v, + percent: pt.percent, + text: pt.text, // pt.v (and pt.i below) for backward compatibility v: pt.v @@ -159316,7 +161670,7 @@ module.exports = function eventData(pt, trace) { return out; }; -},{"../../components/fx/helpers":609}],1023:[function(_dereq_,module,exports){ +},{"../../components/fx/helpers":604}],1020:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159358,7 +161712,7 @@ exports.castOption = function castOption(item, indices) { else if(item) return item; }; -},{"../../lib":696}],1024:[function(_dereq_,module,exports){ +},{"../../lib":692}],1021:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159394,7 +161748,7 @@ Pie.meta = { module.exports = Pie; -},{"./attributes":1018,"./base_plot":1019,"./calc":1020,"./defaults":1021,"./layout_attributes":1025,"./layout_defaults":1026,"./plot":1027,"./style":1028,"./style_one":1029}],1025:[function(_dereq_,module,exports){ +},{"./attributes":1015,"./base_plot":1016,"./calc":1017,"./defaults":1018,"./layout_attributes":1022,"./layout_defaults":1023,"./plot":1024,"./style":1025,"./style_one":1026}],1022:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159430,7 +161784,7 @@ module.exports = { } }; -},{}],1026:[function(_dereq_,module,exports){ +},{}],1023:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159454,7 +161808,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { coerce('extendpiecolors'); }; -},{"../../lib":696,"./layout_attributes":1025}],1027:[function(_dereq_,module,exports){ +},{"../../lib":692,"./layout_attributes":1022}],1024:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -159556,20 +161910,25 @@ module.exports = function plot(gd, cdpie) { // in case we dragged over the pie from another subplot, // or if hover is turned off - if(hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo) { + if(trace2.hovertemplate || (hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo)) { var rInscribed = getInscribedRadiusFraction(pt, cd0); var hoverCenterX = cx + pt.pxmid[0] * (1 - rInscribed); var hoverCenterY = cy + pt.pxmid[1] * (1 - rInscribed); var separators = fullLayout.separators; var thisText = []; - if(hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); - if(hoverinfo.indexOf('text') !== -1) { - var texti = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('label') !== -1) thisText.push(pt.label); + pt.text = helpers.castOption(trace2.hovertext || trace2.text, pt.pts); + if(hoverinfo && hoverinfo.indexOf('text') !== -1) { + var texti = pt.text; if(texti) thisText.push(texti); } - if(hoverinfo.indexOf('value') !== -1) thisText.push(helpers.formatPieValue(pt.v, separators)); - if(hoverinfo.indexOf('percent') !== -1) thisText.push(helpers.formatPiePercent(pt.v / cd0.vTotal, separators)); + pt.value = pt.v; + pt.valueLabel = helpers.formatPieValue(pt.v, separators); + if(hoverinfo && hoverinfo.indexOf('value') !== -1) thisText.push(pt.valueLabel); + pt.percent = pt.v / cd0.vTotal; + pt.percentLabel = helpers.formatPiePercent(pt.percent, separators); + if(hoverinfo && hoverinfo.indexOf('percent') !== -1) thisText.push(pt.percentLabel); var hoverLabel = trace.hoverlabel; var hoverFont = hoverLabel.font; @@ -159579,13 +161938,18 @@ module.exports = function plot(gd, cdpie) { x1: hoverCenterX + rInscribed * cd0.r, y: hoverCenterY, text: thisText.join('
'), - name: hoverinfo.indexOf('name') !== -1 ? trace2.name : undefined, + name: (trace2.hovertemplate || hoverinfo.indexOf('name') !== -1) ? trace2.name : undefined, idealAlign: pt.pxmid[0] < 0 ? 'left' : 'right', color: helpers.castOption(hoverLabel.bgcolor, pt.pts) || pt.color, borderColor: helpers.castOption(hoverLabel.bordercolor, pt.pts), fontFamily: helpers.castOption(hoverFont.family, pt.pts), fontSize: helpers.castOption(hoverFont.size, pt.pts), - fontColor: helpers.castOption(hoverFont.color, pt.pts) + fontColor: helpers.castOption(hoverFont.color, pt.pts), + + trace: trace2, + hovertemplate: helpers.castOption(trace2.hovertemplate, pt.pts), + hovertemplateLabels: pt, + eventData: [eventData(pt, trace2)] }, { container: fullLayout2._hoverlayer.node(), outerContainer: fullLayout2._paper.node(), @@ -159769,7 +162133,7 @@ module.exports = function plot(gd, cdpie) { // add the title var titleTextGroup = d3.select(this).selectAll('g.titletext') - .data(trace.title ? [0] : []); + .data(trace.title.text ? [0] : []); titleTextGroup.enter().append('g') .classed('titletext', true); @@ -159781,18 +162145,18 @@ module.exports = function plot(gd, cdpie) { s.attr('data-notex', 1); }); - titleText.text(trace.title) + titleText.text(trace.title.text) .attr({ 'class': 'titletext', transform: '', 'text-anchor': 'middle', }) - .call(Drawing.font, trace.titlefont) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var transform; - if(trace.titleposition === 'middle center') { + if(trace.title.position === 'middle center') { transform = positionTitleInside(cd0); } else { transform = positionTitleOutside(cd0, fullLayout._size); @@ -159920,11 +162284,11 @@ function prerenderTitles(cdpie, gd) { cd0 = cdpie[i][0]; trace = cd0.trace; - if(trace.title) { + if(trace.title.text) { var dummyTitle = Drawing.tester.append('text') .attr('data-notex', 1) - .text(trace.title) - .call(Drawing.font, trace.titlefont) + .text(trace.title.text) + .call(Drawing.font, trace.title.font) .call(svgTextUtils.convertToTspans, gd); var bBox = Drawing.bBox(dummyTitle.node(), true); cd0.titleBox = { @@ -160026,7 +162390,7 @@ function positionTitleInside(cd0) { y: cd0.cy, scale: cd0.trace.hole * cd0.r * 2 / textDiameter, tx: 0, - ty: - cd0.titleBox.height / 2 + cd0.trace.titlefont.size + ty: - cd0.titleBox.height / 2 + cd0.trace.title.font.size }; } @@ -160049,25 +162413,25 @@ function positionTitleOutside(cd0, plotSize) { // we reason below as if the baseline is the top middle point of the text box. // so we must add the font size to approximate the y-coord. of the top. // note that this correction must happen after scaling. - translate.ty += trace.titlefont.size; + translate.ty += trace.title.font.size; maxPull = getMaxPull(trace); - if(trace.titleposition.indexOf('top') !== -1) { + if(trace.title.position.indexOf('top') !== -1) { topMiddle.y -= (1 + maxPull) * cd0.r; translate.ty -= cd0.titleBox.height; } - else if(trace.titleposition.indexOf('bottom') !== -1) { + else if(trace.title.position.indexOf('bottom') !== -1) { topMiddle.y += (1 + maxPull) * cd0.r; } - if(trace.titleposition.indexOf('left') !== -1) { + if(trace.title.position.indexOf('left') !== -1) { // we start the text at the left edge of the pie maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x -= (1 + maxPull) * cd0.r; translate.tx += cd0.titleBox.width / 2; - } else if(trace.titleposition.indexOf('center') !== -1) { + } else if(trace.title.position.indexOf('center') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); - } else if(trace.titleposition.indexOf('right') !== -1) { + } else if(trace.title.position.indexOf('right') !== -1) { maxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]) / 2 + cd0.r; topMiddle.x += (1 + maxPull) * cd0.r; translate.tx -= cd0.titleBox.width / 2; @@ -160221,7 +162585,7 @@ function scalePies(cdpie, plotSize) { pieBoxWidth = plotSize.w * (trace.domain.x[1] - trace.domain.x[0]); pieBoxHeight = plotSize.h * (trace.domain.y[1] - trace.domain.y[0]); // leave some space for the title, if it will be displayed outside - if(trace.title && trace.titleposition !== 'middle center') { + if(trace.title.text && trace.title.position !== 'middle center') { pieBoxHeight -= getTitleSpace(cd0, plotSize); } @@ -160231,7 +162595,7 @@ function scalePies(cdpie, plotSize) { cd0.cx = plotSize.l + plotSize.w * (trace.domain.x[1] + trace.domain.x[0]) / 2; cd0.cy = plotSize.t + plotSize.h * (1 - trace.domain.y[0]) - pieBoxHeight / 2; - if(trace.title && trace.titleposition.indexOf('bottom') !== -1) { + if(trace.title.text && trace.title.position.indexOf('bottom') !== -1) { cd0.cy -= getTitleSpace(cd0, plotSize); } @@ -160310,7 +162674,7 @@ function setCoords(cd) { } } -},{"../../components/color":570,"../../components/drawing":595,"../../components/fx":612,"../../lib":696,"../../lib/svg_text_utils":720,"./event_data":1022,"./helpers":1023,"d3":148}],1028:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../components/fx":608,"../../lib":692,"../../lib/svg_text_utils":716,"./event_data":1019,"./helpers":1020,"d3":148}],1025:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160339,7 +162703,7 @@ module.exports = function style(gd) { }); }; -},{"./style_one":1029,"d3":148}],1029:[function(_dereq_,module,exports){ +},{"./style_one":1026,"d3":148}],1026:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160363,7 +162727,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":570,"./helpers":1023}],1030:[function(_dereq_,module,exports){ +},{"../../components/color":569,"./helpers":1020}],1027:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160466,7 +162830,7 @@ module.exports = { transforms: undefined }; -},{"../scatter/attributes":1043}],1031:[function(_dereq_,module,exports){ +},{"../scatter/attributes":1040}],1028:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160683,7 +163047,7 @@ function createPointcloud(scene, data) { module.exports = createPointcloud; -},{"../../lib/str2rgbarray":719,"../../plots/cartesian/autorange":743,"../scatter/get_trace_color":1053,"gl-pointcloud2d":279}],1032:[function(_dereq_,module,exports){ +},{"../../lib/str2rgbarray":715,"../../plots/cartesian/autorange":739,"../scatter/get_trace_color":1050,"gl-pointcloud2d":279}],1029:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160731,7 +163095,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor) { traceOut._length = null; }; -},{"../../lib":696,"./attributes":1030}],1033:[function(_dereq_,module,exports){ +},{"../../lib":692,"./attributes":1027}],1030:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160761,7 +163125,7 @@ pointcloud.meta = { module.exports = pointcloud; -},{"../../plots/gl2d":784,"../scatter3d/calc":1071,"./attributes":1030,"./convert":1031,"./defaults":1032}],1034:[function(_dereq_,module,exports){ +},{"../../plots/gl2d":780,"../scatter3d/calc":1068,"./attributes":1027,"./convert":1028,"./defaults":1029}],1031:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160777,6 +163141,7 @@ var plotAttrs = _dereq_('../../plots/attributes'); var colorAttrs = _dereq_('../../components/color/attributes'); var fxAttrs = _dereq_('../../components/fx/attributes'); var domainAttrs = _dereq_('../../plots/domain').attributes; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var extendFlat = _dereq_('../../lib/extend').extendFlat; var overrideAll = _dereq_('../../plot_api/edit_types').overrideAll; @@ -160878,6 +163243,10 @@ var attrs = module.exports = overrideAll({ }, hoverlabel: fxAttrs.hoverlabel, // needs editType override, + hovertemplate: hovertemplateAttrs({}, { + + keys: ['value', 'label'] + }), }, @@ -160937,12 +163306,16 @@ var attrs = module.exports = overrideAll({ }, hoverlabel: fxAttrs.hoverlabel, // needs editType override, + hovertemplate: hovertemplateAttrs({}, { + + keys: ['value', 'label'] + }), } }, 'calc', 'nested'); attrs.transforms = undefined; -},{"../../components/color/attributes":569,"../../components/fx/attributes":604,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../../plots/domain":770,"../../plots/font_attributes":771}],1035:[function(_dereq_,module,exports){ +},{"../../components/color/attributes":568,"../../components/fx/attributes":599,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../../plots/domain":766,"../../plots/font_attributes":767}],1032:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -160980,7 +163353,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../components/fx/layout_attributes":613,"../../plot_api/edit_types":727,"../../plots/get_data":781,"./plot":1040}],1036:[function(_dereq_,module,exports){ +},{"../../components/fx/layout_attributes":609,"../../plot_api/edit_types":723,"../../plots/get_data":777,"./plot":1037}],1033:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161037,7 +163410,7 @@ module.exports = function calc(gd, trace) { }); }; -},{"../../lib":696,"../../lib/gup":693,"strongly-connected-components":506}],1037:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gup":690,"strongly-connected-components":506}],1034:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161072,7 +163445,7 @@ module.exports = { } }; -},{}],1038:[function(_dereq_,module,exports){ +},{}],1035:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161110,6 +163483,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerceNode('line.width'); coerceNode('hoverinfo', traceIn.hoverinfo); handleHoverLabelDefaults(nodeIn, nodeOut, coerceNode, hoverlabelDefault); + coerceNode('hovertemplate'); var colors = layout.colorway; @@ -161132,6 +163506,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerceLink('line.width'); coerceLink('hoverinfo', traceIn.hoverinfo); handleHoverLabelDefaults(linkIn, linkOut, coerceLink, hoverlabelDefault); + coerceLink('hovertemplate'); var defaultLinkColor = tinycolor(layout.paper_bgcolor).getLuminance() < 0.333 ? 'rgba(255, 255, 255, 0.6)' : @@ -161153,7 +163528,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/color":570,"../../components/fx/hoverlabel_defaults":611,"../../lib":696,"../../plot_api/plot_template":734,"../../plots/domain":770,"./attributes":1034,"tinycolor2":514}],1039:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx/hoverlabel_defaults":606,"../../lib":692,"../../plot_api/plot_template":730,"../../plots/domain":766,"./attributes":1031,"tinycolor2":513}],1036:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161181,7 +163556,7 @@ Plot.meta = { module.exports = Plot; -},{"./attributes":1034,"./base_plot":1035,"./calc":1036,"./defaults":1038,"./plot":1040}],1040:[function(_dereq_,module,exports){ +},{"./attributes":1031,"./base_plot":1032,"./calc":1033,"./defaults":1035,"./plot":1037}],1037:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -161317,6 +163692,7 @@ module.exports = function plot(gd, calcData) { if(gd._fullLayout.hovermode === false) return; d3.select(element).call(linkHoveredStyle.bind(0, d, sankey, true)); if(d.link.trace.link.hoverinfo !== 'skip') { + d.link.fullData = d.link.trace; gd.emit('plotly_hover', { event: d3.event, points: [d.link] @@ -161339,10 +163715,13 @@ module.exports = function plot(gd, calcData) { var hoverCenterX = boundingBox.left + boundingBox.width / 2; var hoverCenterY = boundingBox.top + boundingBox.height / 2; + var hovertemplateLabels = {valueLabel: d3.format(d.valueFormat)(d.link.value) + d.valueSuffix}; + d.link.fullData = d.link.trace; + var tooltip = Fx.loneHover({ x: hoverCenterX - rootBBox.left, y: hoverCenterY - rootBBox.top, - name: d3.format(d.valueFormat)(d.link.value) + d.valueSuffix, + name: hovertemplateLabels.valueLabel, text: [ d.link.label || '', sourceLabel + d.link.source.label, @@ -161353,7 +163732,11 @@ module.exports = function plot(gd, calcData) { fontFamily: castHoverOption(obj, 'font.family'), fontSize: castHoverOption(obj, 'font.size'), fontColor: castHoverOption(obj, 'font.color'), - idealAlign: d3.event.x < hoverCenterX ? 'right' : 'left' + idealAlign: d3.event.x < hoverCenterX ? 'right' : 'left', + + hovertemplate: obj.hovertemplate, + hovertemplateLabels: hovertemplateLabels, + eventData: [d.link] }, { container: fullLayout._hoverlayer.node(), outerContainer: fullLayout._paper.node(), @@ -161368,6 +163751,7 @@ module.exports = function plot(gd, calcData) { if(gd._fullLayout.hovermode === false) return; d3.select(element).call(linkNonHoveredStyle.bind(0, d, sankey, true)); if(d.link.trace.link.hoverinfo !== 'skip') { + d.link.fullData = d.link.trace; gd.emit('plotly_unhover', { event: d3.event, points: [d.link] @@ -161389,6 +163773,7 @@ module.exports = function plot(gd, calcData) { if(gd._fullLayout.hovermode === false) return; d3.select(element).call(nodeHoveredStyle, d, sankey); if(d.node.trace.node.hoverinfo !== 'skip') { + d.node.fullData = d.node.trace; gd.emit('plotly_hover', { event: d3.event, points: [d.node] @@ -161408,6 +163793,9 @@ module.exports = function plot(gd, calcData) { var hoverCenterX1 = boundingBox.right + 2 - rootBBox.left; var hoverCenterY = boundingBox.top + boundingBox.height / 4 - rootBBox.top; + var hovertemplateLabels = {valueLabel: d3.format(d.valueFormat)(d.node.value) + d.valueSuffix}; + d.node.fullData = d.node.trace; + var tooltip = Fx.loneHover({ x0: hoverCenterX0, x1: hoverCenterX1, @@ -161423,7 +163811,11 @@ module.exports = function plot(gd, calcData) { fontFamily: castHoverOption(obj, 'font.family'), fontSize: castHoverOption(obj, 'font.size'), fontColor: castHoverOption(obj, 'font.color'), - idealAlign: 'left' + idealAlign: 'left', + + hovertemplate: obj.hovertemplate, + hovertemplateLabels: hovertemplateLabels, + eventData: [d.node] }, { container: fullLayout._hoverlayer.node(), outerContainer: fullLayout._paper.node(), @@ -161438,6 +163830,7 @@ module.exports = function plot(gd, calcData) { if(gd._fullLayout.hovermode === false) return; d3.select(element).call(nodeNonHoveredStyle, d, sankey); if(d.node.trace.node.hoverinfo !== 'skip') { + d.node.fullData = d.node.trace; gd.emit('plotly_unhover', { event: d3.event, points: [d.node] @@ -161477,7 +163870,7 @@ module.exports = function plot(gd, calcData) { ); }; -},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"./constants":1037,"./render":1041,"d3":148}],1041:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"./constants":1034,"./render":1038,"d3":148}],1038:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162150,7 +164543,7 @@ module.exports = function(svg, styledData, layout, callbacks) { .style('fill', nodeTextColor); }; -},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../lib/gup":693,"./constants":1037,"@plotly/d3-sankey":46,"d3":148,"d3-force":144,"tinycolor2":514}],1042:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../lib/gup":690,"./constants":1034,"@plotly/d3-sankey":46,"d3":148,"d3-force":144,"tinycolor2":513}],1039:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162202,7 +164595,7 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":696}],1043:[function(_dereq_,module,exports){ +},{"../../lib":692}],1040:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162213,6 +164606,7 @@ module.exports = function arraysToCalcdata(cd, trace) { 'use strict'; +var hovertemplateAttrs = _dereq_('../../components/fx/hovertemplate_attributes'); var colorAttributes = _dereq_('../../components/colorscale/attributes'); var colorbarAttrs = _dereq_('../../components/colorbar/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -162324,6 +164718,9 @@ module.exports = { editType: 'style', }, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), line: { color: { valType: 'color', @@ -162598,7 +164995,7 @@ module.exports = { } }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../components/drawing":595,"../../components/drawing/attributes":594,"../../lib/extend":685,"../../plots/font_attributes":771,"./constants":1047}],1044:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../components/drawing":590,"../../components/drawing/attributes":589,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plots/font_attributes":767,"./constants":1044}],1041:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162688,7 +165085,7 @@ function calc(gd, trace) { } arraysToCalcdata(cd, trace); - calcColorscale(trace); + calcColorscale(gd, trace); calcSelection(cd, trace); if(stackGroupOpts) { @@ -162888,7 +165285,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axes":744,"./arrays_to_calcdata":1042,"./calc_selection":1045,"./colorscale_calc":1046,"./subtypes":1067,"fast-isnumeric":214}],1045:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axes":740,"./arrays_to_calcdata":1039,"./calc_selection":1042,"./colorscale_calc":1043,"./subtypes":1064,"fast-isnumeric":214}],1042:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162907,7 +165304,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":696}],1046:[function(_dereq_,module,exports){ +},{"../../lib":692}],1043:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162916,31 +165313,41 @@ module.exports = function calcSelection(cd, trace) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var calcColorscale = _dereq_('../../components/colorscale/calc'); var subTypes = _dereq_('./subtypes'); - -module.exports = function calcMarkerColorscale(trace) { +module.exports = function calcMarkerColorscale(gd, trace) { if(subTypes.hasLines(trace) && hasColorscale(trace, 'line')) { - calcColorscale(trace, trace.line.color, 'line', 'c'); + calcColorscale(gd, trace, { + vals: trace.line.color, + containerStr: 'line', + cLetter: 'c' + }); } if(subTypes.hasMarkers(trace)) { if(hasColorscale(trace, 'marker')) { - calcColorscale(trace, trace.marker.color, 'marker', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.color, + containerStr: 'marker', + cLetter: 'c' + }); } if(hasColorscale(trace, 'marker.line')) { - calcColorscale(trace, trace.marker.line.color, 'marker.line', 'c'); + calcColorscale(gd, trace, { + vals: trace.marker.line.color, + containerStr: 'marker.line', + cLetter: 'c' + }); } } }; -},{"../../components/colorscale/calc":578,"../../components/colorscale/has_colorscale":584,"./subtypes":1067}],1047:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577,"../../components/colorscale/helpers":580,"./subtypes":1064}],1044:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -162964,10 +165371,12 @@ module.exports = { // number of viewport sizes away from the visible region // at which we clip all lines to the perimeter - maxScreensAway: 20 + maxScreensAway: 20, + + eventDataKeys: [] }; -},{}],1048:[function(_dereq_,module,exports){ +},{}],1045:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163150,7 +165559,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":1044}],1049:[function(_dereq_,module,exports){ +},{"./calc":1041}],1046:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163189,7 +165598,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],1050:[function(_dereq_,module,exports){ +},{}],1047:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163267,7 +165676,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout dfltHoverOn.push('fills'); } coerce('hoveron', dfltHoverOn.join('+') || 'points'); - + if(traceOut.hoveron !== 'fills') coerce('hovertemplate'); var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults'); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'}); errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'}); @@ -163275,7 +165684,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../../registry":827,"./attributes":1043,"./constants":1047,"./fillcolor_defaults":1052,"./line_defaults":1056,"./line_shape_defaults":1058,"./marker_defaults":1062,"./stack_defaults":1065,"./subtypes":1067,"./text_defaults":1068,"./xy_defaults":1069}],1051:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"./attributes":1040,"./constants":1044,"./fillcolor_defaults":1049,"./line_defaults":1053,"./line_shape_defaults":1055,"./marker_defaults":1059,"./stack_defaults":1062,"./subtypes":1064,"./text_defaults":1065,"./xy_defaults":1066}],1048:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163318,7 +165727,7 @@ function isValid(v) { return v || v === 0; } -},{"../../lib":696}],1052:[function(_dereq_,module,exports){ +},{"../../lib":692}],1049:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163356,7 +165765,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":570,"../../lib":696}],1053:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692}],1050:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163409,7 +165818,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":570,"./subtypes":1067}],1054:[function(_dereq_,module,exports){ +},{"../../components/color":569,"./subtypes":1064}],1051:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163505,7 +165914,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { y1: yc + rad, yLabelVal: yLabelVal, - spikeDistance: dxy(di) + spikeDistance: dxy(di), + hovertemplate: trace.hovertemplate }); fillHoverText(di, trace, pointData); @@ -163589,7 +165999,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { x1: xmax, y0: yAvg, y1: yAvg, - color: color + color: color, + hovertemplate: '%{name}' }); delete pointData.index; @@ -163604,7 +166015,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"../../registry":827,"./fill_hover_text":1051,"./get_trace_color":1053}],1055:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"../../registry":823,"./fill_hover_text":1048,"./get_trace_color":1050}],1052:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163651,7 +166062,7 @@ Scatter.meta = { module.exports = Scatter; -},{"../../plots/cartesian":756,"./arrays_to_calcdata":1042,"./attributes":1043,"./calc":1044,"./cross_trace_calc":1048,"./cross_trace_defaults":1049,"./defaults":1050,"./hover":1054,"./marker_colorbar":1061,"./plot":1063,"./select":1064,"./style":1066,"./subtypes":1067}],1056:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"./arrays_to_calcdata":1039,"./attributes":1040,"./calc":1041,"./cross_trace_calc":1045,"./cross_trace_defaults":1046,"./defaults":1047,"./hover":1051,"./marker_colorbar":1058,"./plot":1060,"./select":1061,"./style":1063,"./subtypes":1064}],1053:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -163663,7 +166074,7 @@ module.exports = Scatter; 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) { @@ -163682,7 +166093,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"../../lib":696}],1057:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"../../lib":692}],1054:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164147,7 +166558,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":673,"../../lib":696,"./constants":1047}],1058:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"./constants":1044}],1055:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164166,7 +166577,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],1059:[function(_dereq_,module,exports){ +},{}],1056:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164259,7 +166670,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],1060:[function(_dereq_,module,exports){ +},{}],1057:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164301,7 +166712,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":214}],1061:[function(_dereq_,module,exports){ +},{"fast-isnumeric":214}],1058:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164319,7 +166730,7 @@ module.exports = { max: 'cmax' }; -},{}],1062:[function(_dereq_,module,exports){ +},{}],1059:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164328,11 +166739,10 @@ module.exports = { * LICENSE file in the root directory of this source tree. */ - 'use strict'; var Color = _dereq_('../../components/color'); -var hasColorscale = _dereq_('../../components/colorscale/has_colorscale'); +var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); var subTypes = _dereq_('./subtypes'); @@ -164402,7 +166812,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":570,"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"./subtypes":1067}],1063:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"./subtypes":1064}],1060:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -164493,7 +166903,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition function createFills(gd, traceJoin, plotinfo) { traceJoin.each(function(d) { var fills = ensureSingle(d3.select(this), 'g', 'fills'); - Drawing.setClipUrl(fills, plotinfo.layerClipId); + Drawing.setClipUrl(fills, plotinfo.layerClipId, gd); var trace = d[0].trace; @@ -164545,7 +166955,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition var text = ensureSingle(tr, 'g', 'text'); // error bars are at the bottom - Registry.getComponentMethod('errorbars', 'plot')(errorBarGroup, plotinfo, transitionOpts); + Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts); if(trace.visible !== true) return; @@ -164700,7 +167110,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.lineGroupStyle) .each(makeUpdate(true)); - Drawing.setClipUrl(lineJoin, plotinfo.layerClipId); + Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd); function clearFill(selection) { transition(selection).attr('d', 'M0,0Z'); @@ -164928,8 +167338,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // on `plotinfo._hasClipOnAxisFalse === true` subplots var hasClipOnAxisFalse = trace.cliponaxis === false; var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId; - Drawing.setClipUrl(points, clipUrl); - Drawing.setClipUrl(text, clipUrl); + Drawing.setClipUrl(points, clipUrl, gd); + Drawing.setClipUrl(text, clipUrl, gd); } function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { @@ -164974,7 +167384,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":595,"../../lib":696,"../../lib/polygon":708,"../../registry":827,"./line_points":1057,"./link_traces":1059,"./subtypes":1067,"d3":148}],1064:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../../lib/polygon":704,"../../registry":823,"./line_points":1054,"./link_traces":1056,"./subtypes":1064,"d3":148}],1061:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165029,7 +167439,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":1067}],1065:[function(_dereq_,module,exports){ +},{"./subtypes":1064}],1062:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165135,7 +167545,7 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],1066:[function(_dereq_,module,exports){ +},{}],1063:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165207,7 +167617,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":595,"../../registry":827,"d3":148}],1067:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../registry":823,"d3":148}],1064:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165246,7 +167656,7 @@ module.exports = { } }; -},{"../../lib":696}],1068:[function(_dereq_,module,exports){ +},{"../../lib":692}],1065:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165276,7 +167686,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":696}],1069:[function(_dereq_,module,exports){ +},{"../../lib":692}],1066:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165285,34 +167695,32 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { * LICENSE file in the root directory of this source tree. */ - 'use strict'; +var Lib = _dereq_('../../lib'); var Registry = _dereq_('../../registry'); - module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { - var len, - x = coerce('x'), - y = coerce('y'); + var x = coerce('x'); + var y = coerce('y'); + var len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); if(x) { + var xlen = Lib.minRowLength(x); if(y) { - len = Math.min(x.length, y.length); - } - else { - len = x.length; + len = Math.min(xlen, Lib.minRowLength(y)); + } else { + len = xlen; coerce('y0'); coerce('dy'); } - } - else { + } else { if(!y) return 0; - len = traceOut.y.length; + len = Lib.minRowLength(y); coerce('x0'); coerce('dx'); } @@ -165322,7 +167730,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../registry":827}],1070:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823}],1067:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165453,7 +167861,7 @@ var attrs = module.exports = overrideAll({ colorAttributes('marker') ), - textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center', arrayOk: false}), + textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}), textfont: { color: scatterAttrs.textfont.color, size: scatterAttrs.textfont.size, @@ -165465,7 +167873,7 @@ var attrs = module.exports = overrideAll({ attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes'; -},{"../../components/colorscale/attributes":577,"../../constants/gl3d_dashes":670,"../../constants/gl3d_markers":671,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../scatter/attributes":1043}],1071:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":576,"../../constants/gl3d_dashes":666,"../../constants/gl3d_markers":667,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../scatter/attributes":1040}],1068:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165477,8 +167885,7 @@ attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes'; 'use strict'; var arraysToCalcdata = _dereq_('../scatter/arrays_to_calcdata'); -var calcColorscales = _dereq_('../scatter/colorscale_calc'); - +var calcColorscale = _dereq_('../scatter/colorscale_calc'); /** * This is a kludge to put the array attributes into @@ -165489,12 +167896,12 @@ module.exports = function calc(gd, trace) { var cd = [{x: false, y: false, trace: trace, t: {}}]; arraysToCalcdata(cd, trace); - calcColorscales(trace); + calcColorscale(gd, trace); return cd; }; -},{"../scatter/arrays_to_calcdata":1042,"../scatter/colorscale_calc":1046}],1072:[function(_dereq_,module,exports){ +},{"../scatter/arrays_to_calcdata":1039,"../scatter/colorscale_calc":1043}],1069:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165581,7 +167988,7 @@ function calculateErrors(data, scaleFactor, sceneLayout) { module.exports = calculateErrors; -},{"../../registry":827}],1073:[function(_dereq_,module,exports){ +},{"../../registry":823}],1070:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -165717,14 +168124,47 @@ function calculateErrorParams(errors) { return {capSize: capSize, color: color, lineWidth: lineWidth}; } +function parseAlignmentX(a) { + if(a === null || a === undefined) return 0; + + return (a.indexOf('left') > -1) ? -1 : + (a.indexOf('right') > -1) ? 1 : 0; +} + +function parseAlignmentY(a) { + if(a === null || a === undefined) return 0; + + return (a.indexOf('top') > -1) ? -1 : + (a.indexOf('bottom') > -1) ? 1 : 0; +} + function calculateTextOffset(tp) { // Read out text properties - var textOffset = [0, 0]; - if(Array.isArray(tp)) return [0, -1]; - if(tp.indexOf('bottom') >= 0) textOffset[1] += 1; - if(tp.indexOf('top') >= 0) textOffset[1] -= 1; - if(tp.indexOf('left') >= 0) textOffset[0] -= 1; - if(tp.indexOf('right') >= 0) textOffset[0] += 1; + + var defaultAlignmentX = 0; + var defaultAlignmentY = 0; + + var textOffset = [ + defaultAlignmentX, + defaultAlignmentY + ]; + + if(Array.isArray(tp)) { + for(var i = 0; i < tp.length; i++) { + textOffset[i] = [ + defaultAlignmentX, + defaultAlignmentY + ]; + if(tp[i]) { + textOffset[i][0] = parseAlignmentX(tp[i]); + textOffset[i][1] = parseAlignmentY(tp[i]); + } + } + } else { + textOffset[0] = parseAlignmentX(tp); + textOffset[1] = parseAlignmentY(tp); + } + return textOffset; } @@ -165817,7 +168257,7 @@ function convertPlotlyOptions(scene, data) { } if('textposition' in data) { - params.textOffset = calculateTextOffset(data.textposition); // arrayOk === false + params.textOffset = calculateTextOffset(data.textposition); params.textColor = formatColor(data.textfont, 1, len); params.textSize = formatParam(data.textfont.size, len, Lib.identity, 12); params.textFont = data.textfont.family; // arrayOk === false @@ -166057,7 +168497,7 @@ function createLineWithMarkers(scene, data) { module.exports = createLineWithMarkers; -},{"../../constants/gl3d_dashes":670,"../../constants/gl3d_markers":671,"../../lib":696,"../../lib/gl_format_color":692,"../../lib/str2rgbarray":719,"../scatter/make_bubble_size_func":1060,"./calc_errors":1072,"delaunay-triangulate":150,"gl-error3d":237,"gl-line3d":245,"gl-mesh3d":268,"gl-scatter3d":284}],1074:[function(_dereq_,module,exports){ +},{"../../constants/gl3d_dashes":666,"../../constants/gl3d_markers":667,"../../lib":692,"../../lib/gl_format_color":689,"../../lib/str2rgbarray":715,"../scatter/make_bubble_size_func":1057,"./calc_errors":1069,"delaunay-triangulate":150,"gl-error3d":237,"gl-line3d":245,"gl-mesh3d":268,"gl-scatter3d":284}],1071:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166145,7 +168585,7 @@ function handleXYZDefaults(traceIn, traceOut, coerce, layout) { return len; } -},{"../../lib":696,"../../registry":827,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1070}],1075:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1067}],1072:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166176,7 +168616,7 @@ Scatter3D.meta = { module.exports = Scatter3D; -},{"../../constants/gl3d_markers":671,"../../plots/gl3d":787,"../scatter/marker_colorbar":1061,"./attributes":1070,"./calc":1071,"./convert":1073,"./defaults":1074}],1076:[function(_dereq_,module,exports){ +},{"../../constants/gl3d_markers":667,"../../plots/gl3d":783,"../scatter/marker_colorbar":1058,"./attributes":1067,"./calc":1068,"./convert":1070,"./defaults":1071}],1073:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166267,7 +168707,7 @@ module.exports = { hoveron: scatterAttrs.hoveron, }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../scatter/attributes":1043}],1077:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../scatter/attributes":1040}],1074:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166320,14 +168760,14 @@ module.exports = function calc(gd, trace) { cd[0].trace = trace; calcMarkerSize(trace, serieslen); - calcColorscale(trace); + calcColorscale(gd, trace); arraysToCalcdata(cd, trace); calcSelection(cd, trace); return cd; }; -},{"../carpet/lookup_carpetid":894,"../scatter/arrays_to_calcdata":1042,"../scatter/calc":1044,"../scatter/calc_selection":1045,"../scatter/colorscale_calc":1046,"fast-isnumeric":214}],1078:[function(_dereq_,module,exports){ +},{"../carpet/lookup_carpetid":891,"../scatter/arrays_to_calcdata":1039,"../scatter/calc":1041,"../scatter/calc_selection":1042,"../scatter/colorscale_calc":1043,"fast-isnumeric":214}],1075:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166413,7 +168853,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/line_shape_defaults":1058,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1076}],1079:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/line_shape_defaults":1055,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1073}],1076:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166433,7 +168873,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],1080:[function(_dereq_,module,exports){ +},{}],1077:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166519,7 +168959,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { return scatterPointData; }; -},{"../scatter/hover":1054}],1081:[function(_dereq_,module,exports){ +},{"../scatter/hover":1051}],1078:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166554,7 +168994,7 @@ ScatterCarpet.meta = { module.exports = ScatterCarpet; -},{"../../plots/cartesian":756,"../scatter/marker_colorbar":1061,"../scatter/select":1064,"../scatter/style":1066,"./attributes":1076,"./calc":1077,"./defaults":1078,"./event_data":1079,"./hover":1080,"./plot":1082}],1082:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../scatter/marker_colorbar":1058,"../scatter/select":1061,"../scatter/style":1063,"./attributes":1073,"./calc":1074,"./defaults":1075,"./event_data":1076,"./hover":1077,"./plot":1079}],1079:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166594,11 +169034,11 @@ module.exports = function plot(gd, plotinfoproxy, data, layer) { // separately to all scattercarpet traces, but that would require // lots of reorganization of scatter traces that is otherwise not // necessary. That makes this a potential optimization. - Drawing.setClipUrl(node, carpet._clipPathId); + Drawing.setClipUrl(node, carpet._clipPathId, gd); } }; -},{"../../components/drawing":595,"../../plots/cartesian/axes":744,"../scatter/plot":1063}],1083:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../plots/cartesian/axes":740,"../scatter/plot":1060}],1080:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166697,7 +169137,7 @@ module.exports = overrideAll({ }) }, 'calc', 'nested'); -},{"../../components/colorscale/attributes":577,"../../components/drawing/attributes":594,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../scatter/attributes":1043}],1084:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":576,"../../components/drawing/attributes":589,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../scatter/attributes":1040}],1081:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166739,7 +169179,7 @@ module.exports = function calc(gd, trace) { } arraysToCalcdata(calcTrace, trace); - calcMarkerColorscale(trace); + calcMarkerColorscale(gd, trace); calcSelection(calcTrace, trace); if(len) { @@ -166754,7 +169194,7 @@ module.exports = function calc(gd, trace) { return calcTrace; }; -},{"../../constants/numerical":673,"../../lib":696,"../scatter/arrays_to_calcdata":1042,"../scatter/calc_selection":1045,"../scatter/colorscale_calc":1046,"fast-isnumeric":214}],1085:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../scatter/arrays_to_calcdata":1039,"../scatter/calc_selection":1042,"../scatter/colorscale_calc":1043,"fast-isnumeric":214}],1082:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166833,7 +169273,7 @@ function handleLonLatLocDefaults(traceIn, traceOut, coerce) { return len; } -},{"../../lib":696,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1083}],1086:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1080}],1083:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166854,7 +169294,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],1087:[function(_dereq_,module,exports){ +},{}],1084:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166961,7 +169401,7 @@ function getExtraText(trace, pt, axis, labels) { return text.join('
'); } -},{"../../components/fx":612,"../../constants/numerical":673,"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051,"../scatter/get_trace_color":1053,"./attributes":1083}],1088:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../constants/numerical":669,"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048,"../scatter/get_trace_color":1050,"./attributes":1080}],1085:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -166997,7 +169437,7 @@ ScatterGeo.meta = { module.exports = ScatterGeo; -},{"../../plots/geo":775,"../scatter/marker_colorbar":1061,"../scatter/style":1066,"./attributes":1083,"./calc":1084,"./defaults":1085,"./event_data":1086,"./hover":1087,"./plot":1089,"./select":1090,"./style":1091}],1089:[function(_dereq_,module,exports){ +},{"../../plots/geo":771,"../scatter/marker_colorbar":1058,"../scatter/style":1063,"./attributes":1080,"./calc":1081,"./defaults":1082,"./event_data":1083,"./hover":1084,"./plot":1086,"./select":1087,"./style":1088}],1086:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167091,7 +169531,7 @@ function calcGeoJSON(calcTrace, topojson) { } } -},{"../../constants/numerical":673,"../../lib":696,"../../lib/geo_location_utils":688,"../../lib/geojson_utils":689,"../../lib/topojson_utils":723,"../scatter/subtypes":1067,"./style":1091,"d3":148}],1090:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../lib/geo_location_utils":685,"../../lib/geojson_utils":686,"../../lib/topojson_utils":719,"../scatter/subtypes":1064,"./style":1088,"d3":148}],1087:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167148,7 +169588,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"../../constants/numerical":673,"../scatter/subtypes":1067}],1091:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../scatter/subtypes":1064}],1088:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167197,7 +169637,7 @@ function styleTrace(gd, calcTrace) { }); } -},{"../../components/color":570,"../../components/drawing":595,"../scatter/style":1066,"d3":148}],1092:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../scatter/style":1063,"d3":148}],1089:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167292,8 +169732,9 @@ var attrs = module.exports = overrideAll({ }, 'calc', 'nested'); attrs.x.editType = attrs.y.editType = attrs.x0.editType = attrs.y0.editType = 'calc+clearAxisTypes'; +attrs.hovertemplate = scatterAttrs.hovertemplate; -},{"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../scatter/attributes":1043,"./constants":1093}],1093:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../scatter/attributes":1040,"./constants":1090}],1090:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167326,7 +169767,7 @@ module.exports = { } }; -},{}],1094:[function(_dereq_,module,exports){ +},{}],1091:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167941,7 +170382,7 @@ module.exports = { textPosition: convertTextPosition }; -},{"../../components/drawing":595,"../../constants/interactions":672,"../../lib":696,"../../lib/gl_format_color":692,"../../plots/cartesian/axis_ids":747,"../../registry":827,"../scatter/make_bubble_size_func":1060,"../scatter/subtypes":1067,"./constants":1093,"color-normalize":108,"fast-isnumeric":214,"svg-path-sdf":512}],1095:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../constants/interactions":668,"../../lib":692,"../../lib/gl_format_color":689,"../../plots/cartesian/axis_ids":743,"../../registry":823,"../scatter/make_bubble_size_func":1057,"../scatter/subtypes":1064,"./constants":1090,"color-normalize":108,"fast-isnumeric":214,"svg-path-sdf":511}],1092:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -167981,6 +170422,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); + coerce('hovertemplate'); coerce('mode', defaultMode); if(subTypes.hasLines(traceOut)) { @@ -168010,7 +170452,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../../registry":827,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"../scatter/xy_defaults":1069,"./attributes":1092}],1096:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../registry":823,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"../scatter/xy_defaults":1066,"./attributes":1089}],1093:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -168040,7 +170482,7 @@ var scatterCalc = _dereq_('../scatter/calc'); var calcMarkerSize = scatterCalc.calcMarkerSize; var calcAxisExpansion = scatterCalc.calcAxisExpansion; var setFirstScatter = scatterCalc.setFirstScatter; -var calcColorscales = _dereq_('../scatter/colorscale_calc'); +var calcColorscale = _dereq_('../scatter/colorscale_calc'); var linkTraces = _dereq_('../scatter/link_traces'); var getTraceColor = _dereq_('../scatter/get_trace_color'); var fillHoverText = _dereq_('../scatter/fill_hover_text'); @@ -168097,7 +170539,7 @@ function calc(gd, trace) { } // create scene options and scene - calcColorscales(trace); + calcColorscale(gd, trace); var opts = sceneOptions(gd, subplot, trace, positions, x, y); var scene = sceneUpdate(gd, subplot); @@ -168829,6 +171271,11 @@ function calcHover(pointData, x, y, trace) { di.hi = Array.isArray(hoverinfo) ? hoverinfo[id] : hoverinfo; } + var hovertemplate = trace.hovertemplate; + if(hovertemplate) { + di.ht = Array.isArray(hovertemplate) ? hovertemplate[id] : hovertemplate; + } + var fakeCd = {}; fakeCd[pointData.index] = di; @@ -168845,7 +171292,9 @@ function calcHover(pointData, x, y, trace) { cd: fakeCd, distance: minDist, - spikeDistance: dxy + spikeDistance: dxy, + + hovertemplate: di.ht }); if(di.htx) pointData.text = di.htx; @@ -168990,7 +171439,7 @@ module.exports = { } }; -},{"../../components/color":570,"../../constants/interactions":672,"../../constants/numerical":673,"../../lib":696,"../../lib/prepare_regl":709,"../../plots/cartesian":756,"../../plots/cartesian/autorange":743,"../../plots/cartesian/axis_ids":747,"../../registry":827,"../scatter/calc":1044,"../scatter/colorscale_calc":1046,"../scatter/cross_trace_defaults":1049,"../scatter/fill_hover_text":1051,"../scatter/get_trace_color":1053,"../scatter/link_traces":1059,"../scatter/marker_colorbar":1061,"../scatter/subtypes":1067,"./attributes":1092,"./constants":1093,"./convert":1094,"./defaults":1095,"array-range":55,"gl-text":304,"point-cluster":452,"regl-error2d":473,"regl-line2d":474,"regl-scatter2d":475}],1097:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../constants/interactions":668,"../../constants/numerical":669,"../../lib":692,"../../lib/prepare_regl":705,"../../plots/cartesian":752,"../../plots/cartesian/autorange":739,"../../plots/cartesian/axis_ids":743,"../../registry":823,"../scatter/calc":1041,"../scatter/colorscale_calc":1043,"../scatter/cross_trace_defaults":1046,"../scatter/fill_hover_text":1048,"../scatter/get_trace_color":1050,"../scatter/link_traces":1056,"../scatter/marker_colorbar":1058,"../scatter/subtypes":1064,"./attributes":1089,"./constants":1090,"./convert":1091,"./defaults":1092,"array-range":55,"gl-text":304,"point-cluster":452,"regl-error2d":473,"regl-line2d":474,"regl-scatter2d":475}],1094:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169086,7 +171535,7 @@ module.exports = overrideAll({ }) }, 'calc', 'nested'); -},{"../../components/colorbar/attributes":571,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../../plots/mapbox/layout_attributes":804,"../scatter/attributes":1043,"../scattergeo/attributes":1083}],1098:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../../plots/mapbox/layout_attributes":800,"../scatter/attributes":1040,"../scattergeo/attributes":1080}],1095:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169247,7 +171696,7 @@ function makeCircleOpts(calcTrace) { if(arrayColor) { if(Colorscale.hasColorscale(trace, 'marker')) { colorFn = Colorscale.makeColorScaleFunc( - Colorscale.extractScale(marker.colorscale, marker.cmin, marker.cmax) + Colorscale.extractScale(marker, {cLetter: 'c'}) ); } else { colorFn = Lib.identity; @@ -169380,7 +171829,7 @@ function isBADNUM(lonlat) { return lonlat[0] === BADNUM; } -},{"../../components/colorscale":585,"../../components/drawing":595,"../../constants/numerical":673,"../../lib":696,"../../lib/geojson_utils":689,"../../plots/mapbox/convert_text_opts":801,"../scatter/make_bubble_size_func":1060,"../scatter/subtypes":1067,"fast-isnumeric":214}],1099:[function(_dereq_,module,exports){ +},{"../../components/colorscale":581,"../../components/drawing":590,"../../constants/numerical":669,"../../lib":692,"../../lib/geojson_utils":686,"../../plots/mapbox/convert_text_opts":797,"../scatter/make_bubble_size_func":1057,"../scatter/subtypes":1064,"fast-isnumeric":214}],1096:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169452,7 +171901,7 @@ function handleLonLatDefaults(traceIn, traceOut, coerce) { return len; } -},{"../../lib":696,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1097}],1100:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1094}],1097:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169472,7 +171921,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],1101:[function(_dereq_,module,exports){ +},{}],1098:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169575,7 +172024,7 @@ function getExtraText(trace, di, labels) { return text.join('
'); } -},{"../../components/fx":612,"../../constants/numerical":673,"../../lib":696,"../scatter/fill_hover_text":1051,"../scatter/get_trace_color":1053}],1102:[function(_dereq_,module,exports){ +},{"../../components/fx":608,"../../constants/numerical":669,"../../lib":692,"../scatter/fill_hover_text":1048,"../scatter/get_trace_color":1050}],1099:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169616,7 +172065,7 @@ ScatterMapbox.meta = { module.exports = ScatterMapbox; -},{"../../plots/mapbox":802,"../scatter/marker_colorbar":1061,"../scattergeo/calc":1084,"./attributes":1097,"./defaults":1099,"./event_data":1100,"./hover":1101,"./plot":1103,"./select":1104}],1103:[function(_dereq_,module,exports){ +},{"../../plots/mapbox":798,"../scatter/marker_colorbar":1058,"../scattergeo/calc":1081,"./attributes":1094,"./defaults":1096,"./event_data":1097,"./hover":1098,"./plot":1100,"./select":1101}],1100:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169728,7 +172177,7 @@ module.exports = function createScatterMapbox(subplot, calcTrace) { return scatterMapbox; }; -},{"./convert":1098}],1104:[function(_dereq_,module,exports){ +},{"./convert":1095}],1101:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169783,7 +172232,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"../../constants/numerical":673,"../../lib":696,"../scatter/subtypes":1067}],1105:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../scatter/subtypes":1064}],1102:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169894,7 +172343,7 @@ module.exports = { unselected: scatterAttrs.unselected }; -},{"../../lib/extend":685,"../../plots/attributes":741,"../scatter/attributes":1043}],1106:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../../plots/attributes":737,"../scatter/attributes":1040}],1103:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -169942,14 +172391,14 @@ module.exports = function calc(gd, trace) { var ppad = calcMarkerSize(trace, len); trace._extremes.x = Axes.findExtremes(radialAxis, rArray, {ppad: ppad}); - calcColorscale(trace); + calcColorscale(gd, trace); arraysToCalcdata(cd, trace); calcSelection(cd, trace); return cd; }; -},{"../../constants/numerical":673,"../../plots/cartesian/axes":744,"../scatter/arrays_to_calcdata":1042,"../scatter/calc":1044,"../scatter/calc_selection":1045,"../scatter/colorscale_calc":1046,"fast-isnumeric":214}],1107:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../plots/cartesian/axes":740,"../scatter/arrays_to_calcdata":1039,"../scatter/calc":1041,"../scatter/calc_selection":1042,"../scatter/colorscale_calc":1043,"fast-isnumeric":214}],1104:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170054,7 +172503,7 @@ module.exports = { supplyDefaults: supplyDefaults }; -},{"../../lib":696,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/line_shape_defaults":1058,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1105}],1108:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/line_shape_defaults":1055,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1102}],1105:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170131,7 +172580,7 @@ module.exports = { makeHoverPointText: makeHoverPointText }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../scatter/hover":1054}],1109:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../scatter/hover":1051}],1106:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170163,7 +172612,7 @@ module.exports = { } }; -},{"../../plots/polar":811,"../scatter/marker_colorbar":1061,"../scatter/select":1064,"../scatter/style":1066,"./attributes":1105,"./calc":1106,"./defaults":1107,"./hover":1108,"./plot":1110}],1110:[function(_dereq_,module,exports){ +},{"../../plots/polar":807,"../scatter/marker_colorbar":1058,"../scatter/select":1061,"../scatter/style":1063,"./attributes":1102,"./calc":1103,"./defaults":1104,"./hover":1105,"./plot":1107}],1107:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170213,7 +172662,7 @@ module.exports = function plot(gd, subplot, moduleCalcData) { scatterPlot(gd, plotinfo, moduleCalcData, mlayer); }; -},{"../../constants/numerical":673,"../scatter/plot":1063}],1111:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../scatter/plot":1060}],1108:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170259,7 +172708,7 @@ module.exports = { unselected: scatterPolarAttrs.unselected }; -},{"../scattergl/attributes":1092,"../scatterpolar/attributes":1105}],1112:[function(_dereq_,module,exports){ +},{"../scattergl/attributes":1089,"../scatterpolar/attributes":1102}],1109:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170319,7 +172768,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"../scatterpolar/defaults":1107,"./attributes":1111}],1113:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"../scatterpolar/defaults":1104,"./attributes":1108}],1110:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170334,7 +172783,7 @@ var cluster = _dereq_('point-cluster'); var isNumeric = _dereq_('fast-isnumeric'); var ScatterGl = _dereq_('../scattergl'); -var calcColorscales = _dereq_('../scatter/colorscale_calc'); +var calcColorscale = _dereq_('../scatter/colorscale_calc'); var calcMarkerSize = _dereq_('../scatter/calc').calcMarkerSize; var convert = _dereq_('../scattergl/convert'); @@ -170360,7 +172809,7 @@ function calc(gd, trace) { stash.r = rArray; stash.theta = thetaArray; - calcColorscales(trace); + calcColorscale(gd, trace); // only compute 'style' options in calc, as position options // depend on the radial range and must be set in plot @@ -170546,7 +172995,7 @@ module.exports = { } }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../../plots/polar":811,"../scatter/calc":1044,"../scatter/colorscale_calc":1046,"../scatter/marker_colorbar":1061,"../scattergl":1096,"../scattergl/constants":1093,"../scattergl/convert":1094,"../scatterpolar/hover":1108,"./attributes":1111,"./defaults":1112,"fast-isnumeric":214,"point-cluster":452}],1114:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../../plots/polar":807,"../scatter/calc":1041,"../scatter/colorscale_calc":1043,"../scatter/marker_colorbar":1058,"../scattergl":1093,"../scattergl/constants":1090,"../scattergl/convert":1091,"../scatterpolar/hover":1105,"./attributes":1108,"./defaults":1109,"fast-isnumeric":214,"point-cluster":452}],1111:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170649,7 +173098,7 @@ module.exports = { hoveron: scatterAttrs.hoveron, }; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../components/drawing/attributes":594,"../../lib/extend":685,"../../plots/attributes":741,"../scatter/attributes":1043}],1115:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../components/drawing/attributes":589,"../../lib/extend":682,"../../plots/attributes":737,"../scatter/attributes":1040}],1112:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170724,14 +173173,14 @@ module.exports = function calc(gd, trace) { } calcMarkerSize(trace, serieslen); - calcColorscale(trace); + calcColorscale(gd, trace); arraysToCalcdata(cd, trace); calcSelection(cd, trace); return cd; }; -},{"../scatter/arrays_to_calcdata":1042,"../scatter/calc":1044,"../scatter/calc_selection":1045,"../scatter/colorscale_calc":1046,"fast-isnumeric":214}],1116:[function(_dereq_,module,exports){ +},{"../scatter/arrays_to_calcdata":1039,"../scatter/calc":1041,"../scatter/calc_selection":1042,"../scatter/colorscale_calc":1043,"fast-isnumeric":214}],1113:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170835,7 +173284,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":696,"../scatter/constants":1047,"../scatter/fillcolor_defaults":1052,"../scatter/line_defaults":1056,"../scatter/line_shape_defaults":1058,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1114}],1117:[function(_dereq_,module,exports){ +},{"../../lib":692,"../scatter/constants":1044,"../scatter/fillcolor_defaults":1049,"../scatter/line_defaults":1053,"../scatter/line_shape_defaults":1055,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1111}],1114:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170867,7 +173316,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],1118:[function(_dereq_,module,exports){ +},{}],1115:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170939,7 +173388,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { return scatterPointData; }; -},{"../../plots/cartesian/axes":744,"../scatter/hover":1054}],1119:[function(_dereq_,module,exports){ +},{"../../plots/cartesian/axes":740,"../scatter/hover":1051}],1116:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -170974,7 +173423,7 @@ ScatterTernary.meta = { module.exports = ScatterTernary; -},{"../../plots/ternary":823,"../scatter/marker_colorbar":1061,"../scatter/select":1064,"../scatter/style":1066,"./attributes":1114,"./calc":1115,"./defaults":1116,"./event_data":1117,"./hover":1118,"./plot":1120}],1120:[function(_dereq_,module,exports){ +},{"../../plots/ternary":819,"../scatter/marker_colorbar":1058,"../scatter/select":1061,"../scatter/style":1063,"./attributes":1111,"./calc":1112,"./defaults":1113,"./event_data":1114,"./hover":1115,"./plot":1117}],1117:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -171007,7 +173456,7 @@ module.exports = function plot(gd, ternary, moduleCalcData) { scatterPlot(gd, plotinfo, moduleCalcData, scatterLayer); }; -},{"../scatter/plot":1063}],1121:[function(_dereq_,module,exports){ +},{"../scatter/plot":1060}],1118:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -171159,7 +173608,7 @@ module.exports = { opacity: scatterGlAttrs.opacity }; -},{"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750,"../scatter/attributes":1043,"../scattergl/attributes":1092}],1122:[function(_dereq_,module,exports){ +},{"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746,"../scatter/attributes":1040,"../scattergl/attributes":1089}],1119:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -171402,7 +173851,7 @@ module.exports = { toSVG: Cartesian.toSVG }; -},{"../../lib/prepare_regl":709,"../../plots/cartesian":756,"../../plots/cartesian/axes":744,"../../plots/cartesian/axis_ids":747,"../../plots/get_data":781,"../../registry":827,"regl-line2d":474}],1123:[function(_dereq_,module,exports){ +},{"../../lib/prepare_regl":705,"../../plots/cartesian":752,"../../plots/cartesian/axes":740,"../../plots/cartesian/axis_ids":743,"../../plots/get_data":777,"../../registry":823,"regl-line2d":474}],1120:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -171572,7 +174021,7 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) { } } -},{"../../lib":696,"../../plots/array_container_defaults":740,"../parcoords/merge_length":1015,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"./attributes":1121}],1124:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/array_container_defaults":736,"../parcoords/merge_length":1012,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"./attributes":1118}],1121:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -171594,7 +174043,7 @@ var AxisIDs = _dereq_('../../plots/cartesian/axis_ids'); var subTypes = _dereq_('../scatter/subtypes'); var calcMarkerSize = _dereq_('../scatter/calc').calcMarkerSize; var calcAxisExpansion = _dereq_('../scatter/calc').calcAxisExpansion; -var calcColorscales = _dereq_('../scatter/colorscale_calc'); +var calcColorscale = _dereq_('../scatter/colorscale_calc'); var convertMarkerSelection = _dereq_('../scattergl/convert').markerSelection; var convertMarkerStyle = _dereq_('../scattergl/convert').markerStyle; var calcHover = _dereq_('../scattergl').calcHover; @@ -171655,7 +174104,7 @@ function calc(gd, trace) { } } - calcColorscales(trace); + calcColorscale(gd, trace); Lib.extendFlat(opts, convertMarkerStyle(trace)); var visibleLength = cdata.length; @@ -171885,7 +174334,7 @@ function editStyle(gd, cd0) { var scene = gd._fullLayout._splomScenes[trace.uid]; if(scene) { - calcColorscales(trace); + calcColorscale(gd, trace); Lib.extendFlat(scene.matrixOptions, convertMarkerStyle(trace)); // TODO [un]selected styles? @@ -172052,7 +174501,7 @@ module.exports = { // register it here Registry.register(Grid); -},{"../../components/grid":616,"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axis_ids":747,"../../registry":827,"../scatter/calc":1044,"../scatter/colorscale_calc":1046,"../scatter/marker_colorbar":1061,"../scatter/subtypes":1067,"../scattergl":1096,"../scattergl/constants":1093,"../scattergl/convert":1094,"./attributes":1121,"./base_plot":1122,"./defaults":1123,"array-range":55,"regl-splom":477}],1125:[function(_dereq_,module,exports){ +},{"../../components/grid":612,"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axis_ids":743,"../../registry":823,"../scatter/calc":1041,"../scatter/colorscale_calc":1043,"../scatter/marker_colorbar":1058,"../scatter/subtypes":1064,"../scattergl":1093,"../scattergl/constants":1090,"../scattergl/convert":1091,"./attributes":1118,"./base_plot":1119,"./defaults":1120,"array-range":55,"regl-splom":477}],1122:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172192,7 +174641,7 @@ attrs.transforms = undefined; module.exports = attrs; -},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../mesh3d/attributes":986}],1126:[function(_dereq_,module,exports){ +},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../mesh3d/attributes":983}],1123:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172238,7 +174687,11 @@ module.exports = function calc(gd, trace) { normMin = Math.min(normMin, norm); } - colorscaleCalc(trace, [normMin, normMax], '', 'c'); + colorscaleCalc(gd, trace, { + vals: [normMin, normMax], + containerStr: '', + cLetter: 'c' + }); var xMax = -Infinity; var xMin = Infinity; @@ -172282,7 +174735,7 @@ module.exports = function calc(gd, trace) { trace._zbnds = [zMin, zMax]; }; -},{"../../components/colorscale/calc":578}],1127:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577}],1124:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172510,7 +174963,7 @@ function createStreamtubeTrace(scene, data) { module.exports = createStreamtubeTrace; -},{"../../lib":696,"../../lib/gl_format_color":692,"../../plots/gl3d/zip3":798,"gl-streamtube3d":301}],1128:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gl_format_color":689,"../../plots/gl3d/zip3":794,"gl-streamtube3d":301}],1125:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172573,7 +175026,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../components/colorscale/defaults":580,"../../lib":696,"./attributes":1125}],1129:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"./attributes":1122}],1126:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172623,7 +175076,7 @@ module.exports = { } }; -},{"../../plots/gl3d":787,"./attributes":1125,"./calc":1126,"./convert":1127,"./defaults":1128}],1130:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":783,"./attributes":1122,"./calc":1123,"./convert":1124,"./defaults":1125}],1127:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172852,7 +175305,7 @@ colorscaleAttrs('', { attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes'; attrs.transforms = undefined; -},{"../../components/color":570,"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741}],1131:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737}],1128:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172870,13 +175323,21 @@ var colorscaleCalc = _dereq_('../../components/colorscale/calc'); // Compute auto-z and autocolorscale if applicable module.exports = function calc(gd, trace) { if(trace.surfacecolor) { - colorscaleCalc(trace, trace.surfacecolor, '', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.surfacecolor, + containerStr: '', + cLetter: 'c' + }); } else { - colorscaleCalc(trace, trace.z, '', 'c'); + colorscaleCalc(gd, trace, { + vals: trace.z, + containerStr: '', + cLetter: 'c' + }); } }; -},{"../../components/colorscale/calc":578}],1132:[function(_dereq_,module,exports){ +},{"../../components/colorscale/calc":577}],1129:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -172889,71 +175350,95 @@ module.exports = function calc(gd, trace) { 'use strict'; var createSurface = _dereq_('gl-surface3d'); + var ndarray = _dereq_('ndarray'); var homography = _dereq_('ndarray-homography'); var fill = _dereq_('ndarray-fill'); -var ops = _dereq_('ndarray-ops'); var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; var parseColorScale = _dereq_('../../lib/gl_format_color').parseColorScale; var str2RgbaArray = _dereq_('../../lib/str2rgbarray'); -var MIN_RESOLUTION = 128; - function SurfaceTrace(scene, surface, uid) { this.scene = scene; this.uid = uid; this.surface = surface; this.data = null; this.showContour = [false, false, false]; - this.dataScale = 1.0; + this.minValues = [Infinity, Infinity, Infinity]; + this.maxValues = [-Infinity, -Infinity, -Infinity]; + this.dataScaleX = 1.0; + this.dataScaleY = 1.0; + this.refineData = true; } var proto = SurfaceTrace.prototype; +proto.getXat = function(a, b, calendar, axis) { + var v = ( + (!isArrayOrTypedArray(this.data.x)) ? + a : + (isArrayOrTypedArray(this.data.x[0])) ? + this.data.x[b][a] : + this.data.x[a] + ); + + return (calendar === undefined) ? v : axis.d2l(v, 0, calendar); +}; + +proto.getYat = function(a, b, calendar, axis) { + var v = ( + (!isArrayOrTypedArray(this.data.y)) ? + b : + (isArrayOrTypedArray(this.data.y[0])) ? + this.data.y[b][a] : + this.data.y[b] + ); + + return (calendar === undefined) ? v : axis.d2l(v, 0, calendar); +}; + +proto.getZat = function(a, b, calendar, axis) { + var v = ( + this.data.z[b][a] + ); + + return (calendar === undefined) ? v : axis.d2l(v, 0, calendar); +}; + proto.handlePick = function(selection) { if(selection.object === this.surface) { - var selectIndex = selection.index = [ - Math.min( - Math.round(selection.data.index[0] / this.dataScale - 1)|0, - this.data.z[0].length - 1 - ), - Math.min( - Math.round(selection.data.index[1] / this.dataScale - 1)|0, - this.data.z.length - 1 - ) - ]; - var traceCoordinate = [0, 0, 0]; - if(!isArrayOrTypedArray(this.data.x)) { - traceCoordinate[0] = selectIndex[0]; - } else if(isArrayOrTypedArray(this.data.x[0])) { - traceCoordinate[0] = this.data.x[selectIndex[1]][selectIndex[0]]; - } else { - traceCoordinate[0] = this.data.x[selectIndex[0]]; - } + var xRatio = (selection.data.index[0] - 1) / this.dataScaleX - 1; + var yRatio = (selection.data.index[1] - 1) / this.dataScaleY - 1; - if(!isArrayOrTypedArray(this.data.y)) { - traceCoordinate[1] = selectIndex[1]; - } else if(isArrayOrTypedArray(this.data.y[0])) { - traceCoordinate[1] = this.data.y[selectIndex[1]][selectIndex[0]]; - } else { - traceCoordinate[1] = this.data.y[selectIndex[1]]; - } + var j = Math.max(Math.min(Math.round(xRatio), this.data.z[0].length - 1), 0); + var k = Math.max(Math.min(Math.round(yRatio), this.data._ylength - 1), 0); + + selection.index = [j, k]; - traceCoordinate[2] = this.data.z[selectIndex[1]][selectIndex[0]]; - selection.traceCoordinate = traceCoordinate; + selection.traceCoordinate = [ + this.getXat(j, k), + this.getYat(j, k), + this.getZat(j, k) + ]; - var sceneLayout = this.scene.fullSceneLayout; selection.dataCoordinate = [ - sceneLayout.xaxis.d2l(traceCoordinate[0], 0, this.data.xcalendar) * this.scene.dataScale[0], - sceneLayout.yaxis.d2l(traceCoordinate[1], 0, this.data.ycalendar) * this.scene.dataScale[1], - sceneLayout.zaxis.d2l(traceCoordinate[2], 0, this.data.zcalendar) * this.scene.dataScale[2] + this.getXat(j, k, this.data.xcalendar, this.scene.fullSceneLayout.xaxis), + this.getYat(j, k, this.data.ycalendar, this.scene.fullSceneLayout.yaxis), + this.getZat(j, k, this.data.zcalendar, this.scene.fullSceneLayout.zaxis) ]; + for(var i = 0; i < 3; i++) { + var v = selection.dataCoordinate[i]; + if(v !== null && v !== undefined) { + selection.dataCoordinate[i] *= this.scene.dataScale[i]; + } + } + var text = this.data.text; - if(Array.isArray(text) && text[selectIndex[1]] && text[selectIndex[1]][selectIndex[0]] !== undefined) { - selection.textLabel = text[selectIndex[1]][selectIndex[0]]; + if(Array.isArray(text) && text[k] && text[k][j] !== undefined) { + selection.textLabel = text[k][j]; } else if(text) { selection.textLabel = text; } else { @@ -172983,58 +175468,220 @@ function isColormapCircular(colormap) { ); } -// Pad coords by +1 -function padField(field) { - var shape = field.shape; - var nshape = [shape[0] + 2, shape[1] + 2]; - var nfield = ndarray(new Float32Array(nshape[0] * nshape[1]), nshape); +var shortPrimes = [ + 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, + 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, + 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, + 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, + 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, + 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, + 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, + 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, + 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, + 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, + 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, + 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, + 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, + 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, + 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, + 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, + 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, + 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, + 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, + 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, + 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, + 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, + 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, + 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, + 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, + 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, + 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, + 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, + 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, + 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999 +]; - // Center - ops.assign(nfield.lo(1, 1).hi(shape[0], shape[1]), field); +function getPow(a, b) { + if(a < b) return 0; + var n = 0; + while(Math.floor(a % b) === 0) { + a /= b; + n++; + } + return n; +} - // Edges - ops.assign(nfield.lo(1).hi(shape[0], 1), - field.hi(shape[0], 1)); - ops.assign(nfield.lo(1, nshape[1] - 1).hi(shape[0], 1), - field.lo(0, shape[1] - 1).hi(shape[0], 1)); - ops.assign(nfield.lo(0, 1).hi(1, shape[1]), - field.hi(1)); - ops.assign(nfield.lo(nshape[0] - 1, 1).hi(1, shape[1]), - field.lo(shape[0] - 1)); +function getFactors(a) { + var powers = []; + for(var i = 0; i < shortPrimes.length; i++) { + var b = shortPrimes[i]; + powers.push( + getPow(a, b) + ); + } + return powers; +} - // Corners - nfield.set(0, 0, field.get(0, 0)); - nfield.set(0, nshape[1] - 1, field.get(0, shape[1] - 1)); - nfield.set(nshape[0] - 1, 0, field.get(shape[0] - 1, 0)); - nfield.set(nshape[0] - 1, nshape[1] - 1, field.get(shape[0] - 1, shape[1] - 1)); +function smallestDivisor(a) { + var A = getFactors(a); + var result = a; + for(var i = 0; i < shortPrimes.length; i++) { + if(A[i] > 0) { + result = shortPrimes[i]; + break; + } + } + return result; +} - return nfield; +function leastCommonMultiple(a, b) { + if(a < 1 || b < 1) return undefined; + var A = getFactors(a); + var B = getFactors(b); + var n = 1; + for(var i = 0; i < shortPrimes.length; i++) { + n *= Math.pow( + shortPrimes[i], Math.max(A[i], B[i]) + ); + } + return n; } -function refine(coords) { - var minScale = Math.max(coords[0].shape[0], coords[0].shape[1]); +function arrayLCM(A) { + if(A.length === 0) return undefined; + var n = 1; + for(var i = 0; i < A.length; i++) { + n = leastCommonMultiple(n, A[i]); + } + return n; +} - if(minScale < MIN_RESOLUTION) { - var scaleF = MIN_RESOLUTION / minScale; - var nshape = [ - Math.floor((coords[0].shape[0]) * scaleF + 1)|0, - Math.floor((coords[0].shape[1]) * scaleF + 1)|0 ]; - var nsize = nshape[0] * nshape[1]; +proto.calcXnums = function(xlen) { + var i; + var nums = []; + for(i = 1; i < xlen; i++) { + var a = this.getXat(i - 1, 0); + var b = this.getXat(i, 0); + + if(b !== a && + a !== undefined && a !== null && + b !== undefined && b !== null) { + nums[i - 1] = Math.abs(b - a); + } else { + nums[i - 1] = 0; + } + } - for(var i = 0; i < coords.length; ++i) { - var padImg = padField(coords[i]); - var scaledImg = ndarray(new Float32Array(nsize), nshape); - homography(scaledImg, padImg, [scaleF, 0, 0, - 0, scaleF, 0, - 0, 0, 1]); - coords[i] = scaledImg; + var totalDist = 0; + for(i = 1; i < xlen; i++) { + totalDist += nums[i - 1]; + } + + for(i = 1; i < xlen; i++) { + if(nums[i - 1] === 0) { + nums[i - 1] = 1; + } else { + nums[i - 1] = Math.round(totalDist / nums[i - 1]); } + } + + return nums; +}; - return scaleF; +proto.calcYnums = function(ylen) { + var i; + var nums = []; + for(i = 1; i < ylen; i++) { + var a = this.getYat(0, i - 1); + var b = this.getYat(0, i); + + if(b !== a && + a !== undefined && a !== null && + b !== undefined && b !== null) { + nums[i - 1] = Math.abs(b - a); + } else { + nums[i - 1] = 0; + } } - return 1.0; -} + var totalDist = 0; + for(i = 1; i < ylen; i++) { + totalDist += nums[i - 1]; + } + + for(i = 1; i < ylen; i++) { + if(nums[i - 1] === 0) { + nums[i - 1] = 1; + } else { + nums[i - 1] = Math.round(totalDist / nums[i - 1]); + } + } + + return nums; +}; + +var highlyComposites = [1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1260]; + +var MIN_RESOLUTION = highlyComposites[9]; +var MAX_RESOLUTION = highlyComposites[13]; + +proto.estimateScale = function(resSrc, axis) { + var nums = (axis === 0) ? + this.calcXnums(resSrc) : + this.calcYnums(resSrc); + + var resDst = 1 + arrayLCM(nums); + + while(resDst < MIN_RESOLUTION) { + resDst *= 2; + } + + while(resDst > MAX_RESOLUTION) { + resDst--; + resDst /= smallestDivisor(resDst); + resDst++; + + if(resDst < MIN_RESOLUTION) { + // resDst = MIN_RESOLUTION; // option 1: use min resolution + resDst = MAX_RESOLUTION; // option 2: use max resolution + } + } + + var scale = Math.round(resDst / resSrc); + return (scale > 1) ? scale : 1; +}; + +proto.refineCoords = function(coords) { + + var scaleW = this.dataScaleX; + var scaleH = this.dataScaleY; + + var width = coords[0].shape[0]; + var height = coords[0].shape[1]; + + var newWidth = Math.floor(coords[0].shape[0] * scaleW + 1) | 0; + var newHeight = Math.floor(coords[0].shape[1] * scaleH + 1) | 0; + + // Pad coords by +1 + var padWidth = 1 + width + 1; + var padHeight = 1 + height + 1; + var padImg = ndarray(new Float32Array(padWidth * padHeight), [padWidth, padHeight]); + + for(var i = 0; i < coords.length; ++i) { + + this.surface.padField(padImg, coords[i]); + + var scaledImg = ndarray(new Float32Array(newWidth * newHeight), [newWidth, newHeight]); + homography(scaledImg, padImg, + [ + scaleW, 0, 0, + 0, scaleH, 0, + 0, 0, 1 + ] + ); + coords[i] = scaledImg; + } +}; proto.setContourLevels = function() { var nlevels = [[], [], []]; @@ -173053,28 +175700,14 @@ proto.setContourLevels = function() { }; proto.update = function(data) { - var i, - scene = this.scene, + var scene = this.scene, sceneLayout = scene.fullSceneLayout, surface = this.surface, alpha = data.opacity, colormap = parseColorScale(data.colorscale, alpha), - z = data.z, - x = data.x, - y = data.y, - xaxis = sceneLayout.xaxis, - yaxis = sceneLayout.yaxis, - zaxis = sceneLayout.zaxis, scaleFactor = scene.dataScale, - xlen = z[0].length, + xlen = data.z[0].length, ylen = data._ylength, - coords = [ - ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), - ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), - ndarray(new Float32Array(xlen * ylen), [xlen, ylen]) - ], - xc = coords[0], - yc = coords[1], contourLevels = scene.contourLevels; // Save data @@ -173088,46 +175721,87 @@ proto.update = function(data) { * which is the transpose of 'gl-surface-plot'. */ - var xcalendar = data.xcalendar, - ycalendar = data.ycalendar, - zcalendar = data.zcalendar; + var i, j, k, v; + var rawCoords = []; + for(i = 0; i < 3; i++) { + rawCoords[i] = []; + for(j = 0; j < xlen; j++) { + rawCoords[i][j] = []; + /* + for(k = 0; k < ylen; k++) { + rawCoords[i][j][k] = undefined; + } + */ + } + } - fill(coords[2], function(row, col) { - return zaxis.d2l(z[col][row], 0, zcalendar) * scaleFactor[2]; - }); + // coords x, y & z + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + rawCoords[0][j][k] = this.getXat(j, k, data.xcalendar, sceneLayout.xaxis); + rawCoords[1][j][k] = this.getYat(j, k, data.ycalendar, sceneLayout.yaxis); + rawCoords[2][j][k] = this.getZat(j, k, data.zcalendar, sceneLayout.zaxis); + } + } - // coords x - if(!isArrayOrTypedArray(x)) { - fill(xc, function(row) { - return xaxis.d2l(row, 0, xcalendar) * scaleFactor[0]; - }); - } else if(isArrayOrTypedArray(x[0])) { - fill(xc, function(row, col) { - return xaxis.d2l(x[col][row], 0, xcalendar) * scaleFactor[0]; - }); - } else { - // ticks x - fill(xc, function(row) { - return xaxis.d2l(x[row], 0, xcalendar) * scaleFactor[0]; - }); + // Note: log axes are not defined in surfaces yet. + // but they could be defined here... + + for(i = 0; i < 3; i++) { + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + v = rawCoords[i][j][k]; + if(v === null || v === undefined) { + rawCoords[i][j][k] = NaN; + } else { + v = rawCoords[i][j][k] *= scaleFactor[i]; + } + } + } } - // coords y - if(!isArrayOrTypedArray(x)) { - fill(yc, function(row, col) { - return yaxis.d2l(col, 0, xcalendar) * scaleFactor[1]; - }); - } else if(isArrayOrTypedArray(y[0])) { - fill(yc, function(row, col) { - return yaxis.d2l(y[col][row], 0, ycalendar) * scaleFactor[1]; - }); - } else { - // ticks y - fill(yc, function(row, col) { - return yaxis.d2l(y[col], 0, ycalendar) * scaleFactor[1]; - }); + for(i = 0; i < 3; i++) { + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + v = rawCoords[i][j][k]; + if(v !== null && v !== undefined) { + if(this.minValues[i] > v) { + this.minValues[i] = v; + } + if(this.maxValues[i] < v) { + this.maxValues[i] = v; + } + } + } + } + } + + for(i = 0; i < 3; i++) { + data._objectOffset[i] = 0.5 * (this.minValues[i] + this.maxValues[i]); + } + + for(i = 0; i < 3; i++) { + for(j = 0; j < xlen; j++) { + for(k = 0; k < ylen; k++) { + v = rawCoords[i][j][k]; + if(v !== null && v !== undefined) { + rawCoords[i][j][k] -= data._objectOffset[i]; + } + } + } } + // convert processed raw data to Float32 matrices + var coords = [ + ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), + ndarray(new Float32Array(xlen * ylen), [xlen, ylen]), + ndarray(new Float32Array(xlen * ylen), [xlen, ylen]) + ]; + fill(coords[0], function(row, col) { return rawCoords[0][row][col]; }); + fill(coords[1], function(row, col) { return rawCoords[1][row][col]; }); + fill(coords[2], function(row, col) { return rawCoords[2][row][col]; }); + rawCoords = []; // free memory + var params = { colormap: colormap, levels: [[], [], []], @@ -173149,7 +175823,7 @@ proto.update = function(data) { params.intensityBounds = [data.cmin, data.cmax]; - // Refine if necessary + // Refine surface color if necessary if(data.surfacecolor) { var intensity = ndarray(new Float32Array(xlen * ylen), [xlen, ylen]); @@ -173166,7 +175840,18 @@ proto.update = function(data) { params.intensityBounds[1] *= scaleFactor[2]; } - this.dataScale = refine(coords); + if(MAX_RESOLUTION < coords[0].shape[0] || + MAX_RESOLUTION < coords[0].shape[1]) { + this.refineData = false; + } + + if(this.refineData === true) { + this.dataScaleX = this.estimateScale(coords[0].shape[0], 0); + this.dataScaleY = this.estimateScale(coords[0].shape[1], 1); + if(this.dataScaleX !== 1 || this.dataScaleY !== 1) { + this.refineCoords(coords); + } + } if(data.surfacecolor) { params.intensity = coords.pop(); @@ -173215,8 +175900,13 @@ proto.update = function(data) { params.vertexColor = true; } - params.coords = coords; + params.objectOffset = [ + data._objectOffset[0], + data._objectOffset[1], + data._objectOffset[2] + ]; + params.coords = coords; surface.update(params); surface.visible = data.visible; @@ -173259,7 +175949,7 @@ function createSurfaceTrace(scene, data) { module.exports = createSurfaceTrace; -},{"../../lib":696,"../../lib/gl_format_color":692,"../../lib/str2rgbarray":719,"gl-surface3d":303,"ndarray":433,"ndarray-fill":423,"ndarray-homography":425,"ndarray-ops":427}],1133:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../lib/gl_format_color":689,"../../lib/str2rgbarray":715,"gl-surface3d":303,"ndarray":433,"ndarray-fill":423,"ndarray-homography":425}],1130:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173297,6 +175987,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._xlength = (Array.isArray(x) && Lib.isArrayOrTypedArray(x[0])) ? z.length : z[0].length; traceOut._ylength = z.length; + traceOut._objectOffset = [0, 0, 0]; + var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, ['x', 'y', 'z'], layout); @@ -173370,7 +176062,7 @@ function mapLegacy(traceIn, oldAttr, newAttr) { } } -},{"../../components/colorscale/defaults":580,"../../lib":696,"../../registry":827,"./attributes":1130}],1134:[function(_dereq_,module,exports){ +},{"../../components/colorscale/defaults":579,"../../lib":692,"../../registry":823,"./attributes":1127}],1131:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173403,7 +176095,7 @@ Surface.meta = { module.exports = Surface; -},{"../../plots/gl3d":787,"./attributes":1130,"./calc":1131,"./convert":1132,"./defaults":1133}],1135:[function(_dereq_,module,exports){ +},{"../../plots/gl3d":783,"./attributes":1127,"./calc":1128,"./convert":1129,"./defaults":1130}],1132:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173577,7 +176269,7 @@ var attrs = module.exports = overrideAll({ }, 'calc', 'from-root'); attrs.transforms = undefined; -},{"../../components/annotations/attributes":553,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/domain":770,"../../plots/font_attributes":771}],1136:[function(_dereq_,module,exports){ +},{"../../components/annotations/attributes":552,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/domain":766,"../../plots/font_attributes":767}],1133:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173609,7 +176301,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../plots/get_data":781,"./plot":1143}],1137:[function(_dereq_,module,exports){ +},{"../../plots/get_data":777,"./plot":1140}],1134:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173628,7 +176320,7 @@ module.exports = function calc() { return wrap({}); }; -},{"../../lib/gup":693}],1138:[function(_dereq_,module,exports){ +},{"../../lib/gup":690}],1135:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173688,7 +176380,7 @@ module.exports = { } }; -},{}],1139:[function(_dereq_,module,exports){ +},{}],1136:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173749,7 +176441,8 @@ module.exports = function calc(gd, trace) { var maxLineWidth = Math.max(arrayMax(trace.header.line.width), arrayMax(trace.cells.line.width)); var calcdata = { - key: trace.index, + // include staticPlot in the key so if it changes we delete and redraw + key: trace.uid + gd._context.staticPlot, translateX: domain.x[0] * gd._fullLayout._size.w, translateY: gd._fullLayout._size.h * (1 - domain.y[1]), size: gd._fullLayout._size, @@ -173883,7 +176576,7 @@ function makeIdentity() { }; } -},{"../../lib/extend":685,"./constants":1138,"fast-isnumeric":214}],1140:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"./constants":1135,"fast-isnumeric":214}],1137:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -173966,7 +176659,7 @@ function rowFromTo(d) { return [rowFrom, rowTo]; } -},{"../../lib/extend":685}],1141:[function(_dereq_,module,exports){ +},{"../../lib/extend":682}],1138:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174031,7 +176724,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout traceOut._length = null; }; -},{"../../lib":696,"../../plots/domain":770,"./attributes":1135}],1142:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/domain":766,"./attributes":1132}],1139:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174059,7 +176752,7 @@ Table.meta = { module.exports = Table; -},{"./attributes":1135,"./base_plot":1136,"./calc":1137,"./defaults":1141,"./plot":1143}],1143:[function(_dereq_,module,exports){ +},{"./attributes":1132,"./base_plot":1133,"./calc":1134,"./defaults":1138,"./plot":1140}],1140:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -174082,6 +176775,7 @@ var splitData = _dereq_('./data_split_helpers'); var Color = _dereq_('../../components/color'); module.exports = function plot(gd, wrappedTraceHolders) { + var dynamic = !gd._context.staticPlot; var table = gd._fullLayout._paper.selectAll('.' + c.cn.table) .data(wrappedTraceHolders.map(function(wrappedTraceHolder) { @@ -174113,20 +176807,30 @@ module.exports = function plot(gd, wrappedTraceHolders) { var tableControlView = table.selectAll('.' + c.cn.tableControlView) .data(gup.repeat, gup.keyFun); - tableControlView.enter() + var cvEnter = tableControlView.enter() .append('g') .classed(c.cn.tableControlView, true) - .style('box-sizing', 'content-box') - .on('mousemove', function(d) {tableControlView.filter(function(dd) {return d === dd;}).call(renderScrollbarKit, gd);}) - .on('mousewheel', function(d) { - if(d.scrollbarState.wheeling) return; - d.scrollbarState.wheeling = true; - d3.event.stopPropagation(); - d3.event.preventDefault(); - makeDragRow(gd, tableControlView, null, d.scrollY + d3.event.deltaY)(d); - d.scrollbarState.wheeling = false; - }) - .call(renderScrollbarKit, gd, true); + .style('box-sizing', 'content-box'); + if(dynamic) { + cvEnter + .on('mousemove', function(d) { + tableControlView + .filter(function(dd) {return d === dd;}) + .call(renderScrollbarKit, gd); + }) + .on('mousewheel', function(d) { + if(d.scrollbarState.wheeling) return; + d.scrollbarState.wheeling = true; + var newY = d.scrollY + d3.event.deltaY; + var noChange = makeDragRow(gd, tableControlView, null, newY)(d); + if(!noChange) { + d3.event.stopPropagation(); + d3.event.preventDefault(); + } + d.scrollbarState.wheeling = false; + }) + .call(renderScrollbarKit, gd, true); + } tableControlView .attr('transform', function(d) {return 'translate(' + d.size.l + ' ' + d.size.t + ')';}); @@ -174145,8 +176849,9 @@ module.exports = function plot(gd, wrappedTraceHolders) { .attr('width', function(d) {return d.width;}) .attr('height', function(d) {return d.height;}); - tableControlView - .each(function(d) {Drawing.setClipUrl(d3.select(this), scrollAreaBottomClipKey(gd, d));}); + tableControlView.each(function(d) { + Drawing.setClipUrl(d3.select(this), scrollAreaBottomClipKey(gd, d), gd); + }); var yColumn = tableControlView.selectAll('.' + c.cn.yColumn) .data(function(vm) {return vm.columns;}, gup.keyFun); @@ -174157,9 +176862,10 @@ module.exports = function plot(gd, wrappedTraceHolders) { yColumn.exit().remove(); - yColumn - .attr('transform', function(d) {return 'translate(' + d.x + ' 0)';}) - .call(d3.behavior.drag() + yColumn.attr('transform', function(d) {return 'translate(' + d.x + ' 0)';}); + + if(dynamic) { + yColumn.call(d3.behavior.drag() .origin(function(d) { var movedColumn = d3.select(this); easeColumn(movedColumn, d, -c.uplift); @@ -174198,8 +176904,11 @@ module.exports = function plot(gd, wrappedTraceHolders) { columnMoved(gd, p, p.columns.map(function(dd) {return dd.xIndex;})); }) ); + } - yColumn.each(function(d) {Drawing.setClipUrl(d3.select(this), columnBoundaryClipKey(gd, d));}); + yColumn.each(function(d) { + Drawing.setClipUrl(d3.select(this), columnBoundaryClipKey(gd, d), gd); + }); var columnBlock = yColumn.selectAll('.' + c.cn.columnBlock) .data(splitData.splitToPanels, gup.keyFun); @@ -174217,8 +176926,8 @@ module.exports = function plot(gd, wrappedTraceHolders) { var headerColumnBlock = columnBlock.filter(headerBlock); var cellsColumnBlock = columnBlock.filter(cellsBlock); - cellsColumnBlock - .call(d3.behavior.drag() + if(dynamic) { + cellsColumnBlock.call(d3.behavior.drag() .origin(function(d) { d3.event.stopPropagation(); return d; @@ -174228,6 +176937,7 @@ module.exports = function plot(gd, wrappedTraceHolders) { // fixme emit plotly notification }) ); + } // initial rendering: header is rendered first, as it may may have async LaTeX (show header first) // but blocks are _entered_ the way they are due to painter's algo (header on top) @@ -174650,6 +177360,9 @@ function columnMoved(gd, calcdata, indices) { calcdata.columnorder = indices; + // TODO: there's no data here, but also this reordering is not reflected + // in gd.data or even gd._fullData. + // For now I will not attempt to persist this in _preGUI gd.emit('plotly_restyle'); } @@ -174767,13 +177480,20 @@ function updateBlockYPosition(gd, cellsColumnBlock, tableControlView) { function makeDragRow(gd, allTableControlView, optionalMultiplier, optionalPosition) { return function dragRow(eventD) { - // may come from whicever DOM event target: drag, wheel, bar... eventD corresponds to event target + // may come from whichever DOM event target: drag, wheel, bar... eventD corresponds to event target var d = eventD.calcdata ? eventD.calcdata : eventD; var tableControlView = allTableControlView.filter(function(dd) {return d.key === dd.key;}); var multiplier = optionalMultiplier || d.scrollbarState.dragMultiplier; + + var initialScrollY = d.scrollY; + d.scrollY = optionalPosition === void(0) ? d.scrollY + multiplier * d3.event.dy : optionalPosition; var cellsColumnBlock = tableControlView.selectAll('.' + c.cn.yColumn).selectAll('.' + c.cn.columnBlock).filter(cellsBlock); updateBlockYPosition(gd, cellsColumnBlock, tableControlView); + + // return false if we've "used" the scroll, ie it did something, + // so the event shouldn't bubble (if appropriate) + return d.scrollY === initialScrollY; }; } @@ -174938,7 +177658,7 @@ function allRowsHeight(rowBlock) { function getBlock(d) {return d.rowBlocks[d.page];} function getRow(l, i) {return l.rows[i - l.firstRowIndex];} -},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../lib/gup":693,"../../lib/svg_text_utils":720,"./constants":1138,"./data_preparation_helper":1139,"./data_split_helpers":1140,"d3":148}],1144:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../lib/gup":690,"../../lib/svg_text_utils":716,"./constants":1135,"./data_preparation_helper":1136,"./data_split_helpers":1137,"d3":148}],1141:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175125,7 +177845,7 @@ module.exports = { } }; -},{"../../lib/extend":685,"../box/attributes":859}],1145:[function(_dereq_,module,exports){ +},{"../../lib/extend":682,"../box/attributes":856}],1142:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175251,7 +177971,9 @@ function calcSpan(trace, cdi, valAxis, bandwidth) { function calcSpanItem(index) { var s = spanIn[index]; - var sc = valAxis.d2c(s, 0, trace[cdi.valLetter + 'calendar']); + var sc = valAxis.type === 'multicategory' ? + valAxis.r2c(s) : + valAxis.d2c(s, 0, trace[cdi.valLetter + 'calendar']); return sc === BADNUM ? spanLoose[index] : sc; } @@ -175274,7 +177996,7 @@ function calcSpan(trace, cdi, valAxis, bandwidth) { return spanOut; } -},{"../../constants/numerical":673,"../../lib":696,"../../plots/cartesian/axes":744,"../box/calc":860,"./helpers":1148}],1146:[function(_dereq_,module,exports){ +},{"../../constants/numerical":669,"../../lib":692,"../../plots/cartesian/axes":740,"../box/calc":857,"./helpers":1145}],1143:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175324,7 +178046,7 @@ module.exports = function crossTraceCalc(gd, plotinfo) { } }; -},{"../box/cross_trace_calc":861}],1147:[function(_dereq_,module,exports){ +},{"../box/cross_trace_calc":858}],1144:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175381,7 +178103,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(!meanLineVisible) traceOut.meanline = {visible: false}; }; -},{"../../components/color":570,"../../lib":696,"../box/defaults":862,"./attributes":1144}],1148:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../../lib":692,"../box/defaults":859,"./attributes":1141}],1145:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175454,7 +178176,7 @@ exports.getKdeValue = function(calcItem, trace, valueDist) { exports.extractVal = function(o) { return o.v; }; -},{"../../lib":696}],1149:[function(_dereq_,module,exports){ +},{"../../lib":692}],1146:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175563,7 +178285,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return closeData; }; -},{"../../lib":696,"../../plots/cartesian/axes":744,"../box/hover":864,"./helpers":1148}],1150:[function(_dereq_,module,exports){ +},{"../../lib":692,"../../plots/cartesian/axes":740,"../box/hover":861,"./helpers":1145}],1147:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175596,7 +178318,7 @@ module.exports = { } }; -},{"../../plots/cartesian":756,"../box/select":869,"../scatter/style":1066,"./attributes":1144,"./calc":1145,"./cross_trace_calc":1146,"./defaults":1147,"./hover":1149,"./layout_attributes":1151,"./layout_defaults":1152,"./plot":1153,"./style":1154}],1151:[function(_dereq_,module,exports){ +},{"../../plots/cartesian":752,"../box/select":866,"../scatter/style":1063,"./attributes":1141,"./calc":1142,"./cross_trace_calc":1143,"./defaults":1144,"./hover":1146,"./layout_attributes":1148,"./layout_defaults":1149,"./plot":1150,"./style":1151}],1148:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175622,7 +178344,7 @@ module.exports = { }) }; -},{"../../lib":696,"../box/layout_attributes":866}],1152:[function(_dereq_,module,exports){ +},{"../../lib":692,"../box/layout_attributes":863}],1149:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175644,7 +178366,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { boxLayoutDefaults._supply(layoutIn, layoutOut, fullData, coerce, 'violin'); }; -},{"../../lib":696,"../box/layout_defaults":867,"./layout_attributes":1151}],1153:[function(_dereq_,module,exports){ +},{"../../lib":692,"../box/layout_defaults":864,"./layout_attributes":1148}],1150:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175844,7 +178566,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) { }); }; -},{"../../components/drawing":595,"../../lib":696,"../box/plot":868,"../scatter/line_points":1057,"./helpers":1148,"d3":148}],1154:[function(_dereq_,module,exports){ +},{"../../components/drawing":590,"../../lib":692,"../box/plot":865,"../scatter/line_points":1054,"./helpers":1145,"d3":148}],1151:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -175899,7 +178621,7 @@ module.exports = function style(gd, cd) { }); }; -},{"../../components/color":570,"../scatter/style":1066,"d3":148}],1155:[function(_dereq_,module,exports){ +},{"../../components/color":569,"../scatter/style":1063,"d3":148}],1152:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176325,7 +179047,7 @@ function last(array, indices) { return array[indices[indices.length - 1]]; } -},{"../constants/numerical":673,"../lib":696,"../plot_api/plot_schema":733,"../plots/cartesian/axes":744,"./helpers":1158}],1156:[function(_dereq_,module,exports){ +},{"../constants/numerical":669,"../lib":692,"../plot_api/plot_schema":729,"../plots/cartesian/axes":740,"./helpers":1155}],1153:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176601,7 +179323,7 @@ function getFilterFunc(opts, d2c, targetCalendar) { } } -},{"../constants/filter_ops":669,"../lib":696,"../plots/cartesian/axes":744,"../registry":827,"./helpers":1158}],1157:[function(_dereq_,module,exports){ +},{"../constants/filter_ops":665,"../lib":692,"../plots/cartesian/axes":740,"../registry":823,"./helpers":1155}],1154:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176786,9 +179508,6 @@ function transformOne(trace, state) { // Start with a deep extend that just copies array references. newTrace = newData[i] = Lib.extendDeepNoArrays({}, trace); newTrace._group = groupName; - // helper function for when we need to push updates back to the input, - // outside of the normal restyle/relayout pathway, like filling in auto values - newTrace.updateStyle = styleUpdater(groupName, transformIndex); newTrace.transforms[transformIndex]._indexToPoints = {}; var suppliedName = null; @@ -176866,18 +179585,7 @@ function transformOne(trace, state) { return newData; } -function styleUpdater(groupName, transformIndex) { - return function(trace, attr, value) { - Lib.keyedContainer( - trace, - 'transforms[' + transformIndex + '].styles', - 'target', - 'value.' + attr - ).set(String(groupName), value); - }; -} - -},{"../lib":696,"../plot_api/plot_schema":733,"../plots/plots":808,"./helpers":1158}],1158:[function(_dereq_,module,exports){ +},{"../lib":692,"../plot_api/plot_schema":729,"../plots/plots":804,"./helpers":1155}],1155:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -176903,7 +179611,7 @@ exports.pointsAccessorFunction = function(transforms, opts) { return originalPointsAccessor; }; -},{}],1159:[function(_dereq_,module,exports){ +},{}],1156:[function(_dereq_,module,exports){ /** * Copyright 2012-2018, Plotly, Inc. * All rights reserved. @@ -177033,5 +179741,5 @@ function getSortFunc(opts, d2c) { } } -},{"../lib":696,"../plots/cartesian/axes":744,"./helpers":1158}]},{},[22])(22) +},{"../lib":692,"../plots/cartesian/axes":740,"./helpers":1155}]},{},[22])(22) }); diff --git a/dist/plotly.min.js b/dist/plotly.min.js index bfd1f9690c5..6b7f0acb94d 100644 --- a/dist/plotly.min.js +++ b/dist/plotly.min.js @@ -1,7 +1,7 @@ /** -* plotly.js v1.42.5 +* plotly.js v1.43.0 * Copyright 2012-2018, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,r,n){function i(o,s){if(!r[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};e[o][0].call(u.exports,function(t){return i(e[o][1][t]||t)},u,u.exports,t,e,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oplotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/transforms/aggregate")},{"../src/transforms/aggregate":1155}],4:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":843}],5:[function(t,e,r){"use strict";e.exports=t("../src/traces/barpolar")},{"../src/traces/barpolar":855}],6:[function(t,e,r){"use strict";e.exports=t("../src/traces/box")},{"../src/traces/box":865}],7:[function(t,e,r){"use strict";e.exports=t("../src/components/calendars")},{"../src/components/calendars":568}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/candlestick")},{"../src/traces/candlestick":874}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/carpet")},{"../src/traces/carpet":893}],10:[function(t,e,r){"use strict";e.exports=t("../src/traces/choropleth")},{"../src/traces/choropleth":907}],11:[function(t,e,r){"use strict";e.exports=t("../src/traces/cone")},{"../src/traces/cone":915}],12:[function(t,e,r){"use strict";e.exports=t("../src/traces/contour")},{"../src/traces/contour":930}],13:[function(t,e,r){"use strict";e.exports=t("../src/traces/contourcarpet")},{"../src/traces/contourcarpet":941}],14:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":675}],15:[function(t,e,r){"use strict";e.exports=t("../src/transforms/filter")},{"../src/transforms/filter":1156}],16:[function(t,e,r){"use strict";e.exports=t("../src/transforms/groupby")},{"../src/transforms/groupby":1157}],17:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmap")},{"../src/traces/heatmap":953}],18:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmapgl")},{"../src/traces/heatmapgl":963}],19:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram")},{"../src/traces/histogram":974}],20:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2d")},{"../src/traces/histogram2d":981}],21:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2dcontour")},{"../src/traces/histogram2dcontour":985}],22:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./box"),t("./heatmap"),t("./histogram"),t("./histogram2d"),t("./histogram2dcontour"),t("./pie"),t("./contour"),t("./scatterternary"),t("./violin"),t("./scatter3d"),t("./surface"),t("./mesh3d"),t("./cone"),t("./streamtube"),t("./scattergeo"),t("./choropleth"),t("./scattergl"),t("./splom"),t("./pointcloud"),t("./heatmapgl"),t("./parcoords"),t("./parcats"),t("./scattermapbox"),t("./sankey"),t("./table"),t("./carpet"),t("./scattercarpet"),t("./contourcarpet"),t("./ohlc"),t("./candlestick"),t("./scatterpolar"),t("./scatterpolargl"),t("./barpolar")]),n.register([t("./aggregate"),t("./filter"),t("./groupby"),t("./sort")]),n.register([t("./calendars")]),e.exports=n},{"./aggregate":3,"./bar":4,"./barpolar":5,"./box":6,"./calendars":7,"./candlestick":8,"./carpet":9,"./choropleth":10,"./cone":11,"./contour":12,"./contourcarpet":13,"./core":14,"./filter":15,"./groupby":16,"./heatmap":17,"./heatmapgl":18,"./histogram":19,"./histogram2d":20,"./histogram2dcontour":21,"./mesh3d":23,"./ohlc":24,"./parcats":25,"./parcoords":26,"./pie":27,"./pointcloud":28,"./sankey":29,"./scatter3d":30,"./scattercarpet":31,"./scattergeo":32,"./scattergl":33,"./scattermapbox":34,"./scatterpolar":35,"./scatterpolargl":36,"./scatterternary":37,"./sort":38,"./splom":39,"./streamtube":40,"./surface":41,"./table":42,"./violin":43}],23:[function(t,e,r){"use strict";e.exports=t("../src/traces/mesh3d")},{"../src/traces/mesh3d":990}],24:[function(t,e,r){"use strict";e.exports=t("../src/traces/ohlc")},{"../src/traces/ohlc":995}],25:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcats")},{"../src/traces/parcats":1004}],26:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcoords")},{"../src/traces/parcoords":1013}],27:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":1024}],28:[function(t,e,r){"use strict";e.exports=t("../src/traces/pointcloud")},{"../src/traces/pointcloud":1033}],29:[function(t,e,r){"use strict";e.exports=t("../src/traces/sankey")},{"../src/traces/sankey":1039}],30:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatter3d")},{"../src/traces/scatter3d":1075}],31:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattercarpet")},{"../src/traces/scattercarpet":1081}],32:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergeo")},{"../src/traces/scattergeo":1088}],33:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergl")},{"../src/traces/scattergl":1096}],34:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattermapbox")},{"../src/traces/scattermapbox":1102}],35:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterpolar")},{"../src/traces/scatterpolar":1109}],36:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterpolargl")},{"../src/traces/scatterpolargl":1113}],37:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterternary")},{"../src/traces/scatterternary":1119}],38:[function(t,e,r){"use strict";e.exports=t("../src/transforms/sort")},{"../src/transforms/sort":1159}],39:[function(t,e,r){"use strict";e.exports=t("../src/traces/splom")},{"../src/traces/splom":1124}],40:[function(t,e,r){"use strict";e.exports=t("../src/traces/streamtube")},{"../src/traces/streamtube":1129}],41:[function(t,e,r){"use strict";e.exports=t("../src/traces/surface")},{"../src/traces/surface":1134}],42:[function(t,e,r){"use strict";e.exports=t("../src/traces/table")},{"../src/traces/table":1142}],43:[function(t,e,r){"use strict";e.exports=t("../src/traces/violin")},{"../src/traces/violin":1150}],44:[function(t,e,r){"use strict";e.exports=function(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]);"zoomMin"in e&&(r[0]=e.zoomMin);"zoomMax"in e&&(r[1]=e.zoomMax);var c=i({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=0,h=t.clientWidth,p=t.clientHeight,d={view:c,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:c.modes,tick:function(){var e=n(),r=this.delay;c.idle(e-r),c.flush(e-(100+2*r));var i=e-2*r;c.recalcMatrix(i);for(var a=!0,o=c.computedMatrix,s=0;s<16;++s)a=a&&u[s]===o[s],u[s]=o[s];var l=t.clientWidth===h&&t.clientHeight===p;return h=t.clientWidth,p=t.clientHeight,a?!l:(f=Math.exp(c.computedRadius[0]),!0)},lookAt:function(t,e,r){c.lookAt(c.lastT(),t,e,r)},rotate:function(t,e,r){c.rotate(c.lastT(),t,e,r)},pan:function(t,e,r){c.pan(c.lastT(),t,e,r)},translate:function(t,e,r){c.translate(c.lastT(),t,e,r)}};Object.defineProperties(d,{matrix:{get:function(){return c.computedMatrix},set:function(t){return c.setMatrix(c.lastT(),t),c.computedMatrix},enumerable:!0},mode:{get:function(){return c.getMode()},set:function(t){return c.setMode(t),c.getMode()},enumerable:!0},center:{get:function(){return c.computedCenter},set:function(t){return c.lookAt(c.lastT(),t),c.computedCenter},enumerable:!0},eye:{get:function(){return c.computedEye},set:function(t){return c.lookAt(c.lastT(),null,t),c.computedEye},enumerable:!0},up:{get:function(){return c.computedUp},set:function(t){return c.lookAt(c.lastT(),null,null,t),c.computedUp},enumerable:!0},distance:{get:function(){return f},set:function(t){return c.setDistance(c.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return c.getDistanceLimits(r)},set:function(t){return c.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var g=0,v=0,m={shift:!1,control:!1,alt:!1,meta:!1};function y(e,r,i,a){var o=1/t.clientHeight,s=o*(r-g),l=o*(i-v),u=d.flipX?1:-1,h=d.flipY?1:-1,p=Math.PI*d.rotateSpeed,y=n();if(1&e)a.shift?c.rotate(y,0,0,-s*p):c.rotate(y,u*p*s,-h*p*l,0);else if(2&e)c.pan(y,-d.translateSpeed*s*f,d.translateSpeed*l*f,0);else if(4&e){var x=d.zoomSpeed*l/window.innerHeight*(y-c.lastT())*50;c.pan(y,0,0,f*(Math.exp(x)-1))}g=r,v=i,m=a}return a(t,y),t.addEventListener("touchstart",function(e){var r=s(e.changedTouches[0],t);y(0,r[0],r[1],m),y(1,r[0],r[1],m),e.preventDefault()},!!l&&{passive:!1}),t.addEventListener("touchmove",function(e){var r=s(e.changedTouches[0],t);y(1,r[0],r[1],m),e.preventDefault()},!!l&&{passive:!1}),t.addEventListener("touchend",function(e){s(e.changedTouches[0],t),y(0,g,v,m),e.preventDefault()},!!l&&{passive:!1}),o(t,function(t,e,r){var i=d.flipX?1:-1,a=d.flipY?1:-1,o=n();if(Math.abs(t)>Math.abs(e))c.rotate(o,0,0,-t*i*Math.PI*d.rotateSpeed/window.innerWidth);else{var s=d.zoomSpeed*a*e/window.innerHeight*(o-c.lastT())/100;c.pan(o,0,0,f*(Math.exp(s)-1))}},!0),d};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset"),l=t("has-passive-events")},{"3d-view":45,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421,"right-now":480}],45:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).eye||[0,0,1],r=t.center||[0,0,0],s=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=n(),f=i(),h=a();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,s),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,s),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,s),new o({turntable:u,orbit:f,matrix:h},c)};var n=t("turntable-camera-controller"),i=t("orbit-camera-controller"),a=t("matrix-camera-controller");function o(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.turntable),this.modes=this._controllerNames,this.computedMatrix=this._active.computedMatrix,this.computedEye=this._active.computedEye,this.computedUp=this._active.computedUp,this.computedCenter=this._active.computedCenter,this.computedRadius=this._active.computedRadius}var s=o.prototype;[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]].forEach(function(t){for(var e=t[0],r=[],n=0;nr&&(a=r);var i=e.min(n,function(t){return(o[1]-(t.length-1)*a)/e.sum(t,h)});n.forEach(function(t){t.forEach(function(t,e){t.y=e,t.dy=t.value*i})}),l.forEach(function(t){t.dy=t.value*i})})(),d();for(var i=1;t>0;--t)p(i*=.99),d(),u(i),d();function u(t){function r(t){return f(t.source)*t.value}n.forEach(function(n){n.forEach(function(n){if(n.targetLinks.length){var i=e.sum(n.targetLinks,r)/e.sum(n.targetLinks,h);n.y+=(i-f(n))*t}})})}function p(t){function r(t){return f(t.target)*t.value}n.slice().reverse().forEach(function(n){n.forEach(function(n){if(n.sourceLinks.length){var i=e.sum(n.sourceLinks,r)/e.sum(n.sourceLinks,h);n.y+=(i-f(n))*t}})})}function d(){n.forEach(function(t){var e,r,n,i=0,s=t.length;for(t.sort(g),n=0;n0&&(e.y+=r),i=e.y+e.dy+a;if((r=i-a-o[1])>0)for(i=e.y-=r,n=s-2;n>=0;--n)e=t[n],(r=e.y+e.dy+a-i)>0&&(e.y-=r),i=e.y})}function g(t,e){return t.y-e.y}}(n),u(),t},t.relayout=function(){return u(),t},t.link=function(){var t=.5;function e(e){var r=e.source.x+e.source.dx,i=e.target.x,a=n.interpolateNumber(r,i),o=a(t),s=a(1-t),l=e.source.y+e.sy,c=l+e.dy,u=e.target.y+e.ty,f=u+e.dy;return"M"+r+","+l+"C"+o+","+l+" "+s+","+u+" "+i+","+u+"L"+i+","+f+"C"+s+","+f+" "+o+","+c+" "+r+","+c+"Z"}return e.curvature=function(r){return arguments.length?(t=+r,e):t},e},t},Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof r&&"undefined"!=typeof e?i(r,t("d3-array"),t("d3-collection"),t("d3-interpolate")):i(n.d3=n.d3||{},n.d3,n.d3,n.d3)},{"d3-array":140,"d3-collection":141,"d3-interpolate":145}],47:[function(t,e,r){"use strict";var n="undefined"==typeof WeakMap?t("weak-map"):WeakMap,i=t("gl-buffer"),a=t("gl-vao"),o=new n;e.exports=function(t){var e=o.get(t),r=e&&(e._triangleBuffer.handle||e._triangleBuffer.buffer);if(!r||!t.isBuffer(r)){var n=i(t,new Float32Array([-1,-1,-1,4,4,-1]));(e=a(t,[{buffer:n,type:t.FLOAT,size:2}]))._triangleBuffer=n,o.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}},{"gl-buffer":230,"gl-vao":310,"weak-map":529}],48:[function(t,e,r){e.exports=function(t){var e=0,r=0,n=0,i=0;return t.map(function(t){var a=(t=t.slice())[0],o=a.toUpperCase();if(a!=o)switch(t[0]=o,a){case"a":t[6]+=n,t[7]+=i;break;case"v":t[1]+=i;break;case"h":t[1]+=n;break;default:for(var s=1;si&&(i=t[o]),t[o]=0;c--)if(u[c]!==f[c])return!1;for(c=u.length-1;c>=0;c--)if(l=u[c],!y(t[l],e[l],r,n))return!1;return!0}(t,e,r,o))}return r?t===e:t==e}function x(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function b(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function _(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&v(i,r,"Missing expected exception"+n);var o="string"==typeof n,s=!t&&i&&!r;if((!t&&a.isError(i)&&o&&b(i,r)||s)&&v(i,r,"Got unwanted exception"+n),t&&i&&r&&!b(i,r)||!t&&i)throw i}f.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=d(g((e=this).actual),128)+" "+e.operator+" "+d(g(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,a=p(r),o=i.indexOf("\n"+a);if(o>=0){var s=i.indexOf("\n",o+1);i=i.substring(s+1)}this.stack=i}}},a.inherits(f.AssertionError,Error),f.fail=v,f.ok=m,f.equal=function(t,e,r){t!=e&&v(t,e,r,"==",f.equal)},f.notEqual=function(t,e,r){t==e&&v(t,e,r,"!=",f.notEqual)},f.deepEqual=function(t,e,r){y(t,e,!1)||v(t,e,r,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(t,e,r){y(t,e,!0)||v(t,e,r,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(t,e,r){y(t,e,!1)&&v(t,e,r,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function t(e,r,n){y(e,r,!0)&&v(e,r,n,"notDeepStrictEqual",t)},f.strictEqual=function(t,e,r){t!==e&&v(t,e,r,"===",f.strictEqual)},f.notStrictEqual=function(t,e,r){t===e&&v(t,e,r,"!==",f.notStrictEqual)},f.throws=function(t,e,r){_(!0,t,e,r)},f.doesNotThrow=function(t,e,r){_(!1,t,e,r)},f.ifError=function(t){if(t)throw t};var w=Object.keys||function(t){var e=[];for(var r in t)o.call(t,r)&&e.push(r);return e}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":59}],57:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],58:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],59:[function(t,e,r){(function(e,n){var i=/%[sdj%]/g;r.format=function(t){if(!m(t)){for(var e=[],r=0;r=a)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),l=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(e)?n.showHidden=e:e&&r._extend(n,e),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=l),u(n,t,n.depth)}function l(t,e){var r=s.styles[e];return r?"\x1b["+s.colors[r][0]+"m"+t+"\x1b["+s.colors[r][1]+"m":t}function c(t,e){return t}function u(t,e,n){if(t.customInspect&&e&&k(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return m(i)||(i=u(t,i,n)),i}var a=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(v(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,e);if(a)return a;var o=Object.keys(e),s=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),w(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(e);if(0===o.length){if(k(e)){var l=e.name?": "+e.name:"";return t.stylize("[Function"+l+"]","special")}if(x(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(w(e))return f(e)}var c,b="",M=!1,A=["{","}"];(p(e)&&(M=!0,A=["[","]"]),k(e))&&(b=" [Function"+(e.name?": "+e.name:"")+"]");return x(e)&&(b=" "+RegExp.prototype.toString.call(e)),_(e)&&(b=" "+Date.prototype.toUTCString.call(e)),w(e)&&(b=" "+f(e)),0!==o.length||M&&0!=e.length?n<0?x(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=M?function(t,e,r,n,i){for(var a=[],o=0,s=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,b,A)):A[0]+b+A[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i,a){var o,s,l;if((l=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=l.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):l.set&&(s=t.stylize("[Setter]","special")),S(n,i)||(o="["+i+"]"),s||(t.seen.indexOf(l.value)<0?(s=g(r)?u(t,l.value,null):u(t,l.value,r-1)).indexOf("\n")>-1&&(s=a?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),y(o)){if(a&&i.match(/^\d+$/))return s;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+s}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function v(t){return"number"==typeof t}function m(t){return"string"==typeof t}function y(t){return void 0===t}function x(t){return b(t)&&"[object RegExp]"===M(t)}function b(t){return"object"==typeof t&&null!==t}function _(t){return b(t)&&"[object Date]"===M(t)}function w(t){return b(t)&&("[object Error]"===M(t)||t instanceof Error)}function k(t){return"function"==typeof t}function M(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(y(a)&&(a=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(a)){var n=e.pid;o[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else o[t]=function(){};return o[t]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=p,r.isBoolean=d,r.isNull=g,r.isNullOrUndefined=function(t){return null==t},r.isNumber=v,r.isString=m,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=y,r.isRegExp=x,r.isObject=b,r.isDate=_,r.isError=w,r.isFunction=k,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t},r.isBuffer=t("./support/isBuffer");var T=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function S(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),T[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!b(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":58,_process:465,inherits:57}],60:[function(t,e,r){e.exports=function(t){return atob(t)}},{}],61:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=e.length,a=new Array(r+1),o=0;o0?n-4:n,f=0;f>16&255,s[l++]=e>>8&255,s[l++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,s[l++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,s[l++]=e>>8&255,s[l++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,a=[],o=0,s=r-i;os?s:o+16383));1===i?(e=t[r-1],a.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],a.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,r){for(var i,a,o=[],s=e;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],63:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}},{"./lib/rationalize":73}],64:[function(t,e,r){"use strict";e.exports=function(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}},{}],65:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]),t[1].mul(e[0]))}},{"./lib/rationalize":73}],66:[function(t,e,r){"use strict";var n=t("./is-rat"),i=t("./lib/is-bn"),a=t("./lib/num-to-bn"),o=t("./lib/str-to-bn"),s=t("./lib/rationalize"),l=t("./div");e.exports=function t(e,r){if(n(e))return r?l(e,t(r)):[e[0].clone(),e[1].clone()];var c=0;var u,f;if(i(e))u=e.clone();else if("string"==typeof e)u=o(e);else{if(0===e)return[a(0),a(1)];if(e===Math.floor(e))u=a(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),c-=256;u=a(e)}}if(n(r))u.mul(r[1]),f=r[0].clone();else if(i(r))f=r.clone();else if("string"==typeof r)f=o(r);else if(r)if(r===Math.floor(r))f=a(r);else{for(;r!==Math.floor(r);)r*=Math.pow(2,256),c+=256;f=a(r)}else f=a(1);c>0?u=u.ushln(c):c<0&&(f=f.ushln(-c));return s(u,f)}},{"./div":65,"./is-rat":67,"./lib/is-bn":71,"./lib/num-to-bn":72,"./lib/rationalize":73,"./lib/str-to-bn":74}],67:[function(t,e,r){"use strict";var n=t("./lib/is-bn");e.exports=function(t){return Array.isArray(t)&&2===t.length&&n(t[0])&&n(t[1])}},{"./lib/is-bn":71}],68:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return t.cmp(new n(0))}},{"bn.js":82}],69:[function(t,e,r){"use strict";var n=t("./bn-sign");e.exports=function(t){var e=t.length,r=t.words,i=0;if(1===e)i=r[0];else if(2===e)i=r[0]+67108864*r[1];else for(var a=0;a20)return 52;return r+32}},{"bit-twiddle":80,"double-bits":152}],71:[function(t,e,r){"use strict";t("bn.js");e.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},{"bn.js":82}],72:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("double-bits");e.exports=function(t){var e=i.exponent(t);return e<52?new n(t):new n(t*Math.pow(2,52-e)).ushln(e-52)}},{"bn.js":82,"double-bits":152}],73:[function(t,e,r){"use strict";var n=t("./num-to-bn"),i=t("./bn-sign");e.exports=function(t,e){var r=i(t),a=i(e);if(0===r)return[n(0),n(1)];if(0===a)return[n(0),n(0)];a<0&&(t=t.neg(),e=e.neg());var o=t.gcd(e);if(o.cmpn(1))return[t.div(o),e.div(o)];return[t,e]}},{"./bn-sign":68,"./num-to-bn":72}],74:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return new n(t)}},{"bn.js":82}],75:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[0]),t[1].mul(e[1]))}},{"./lib/rationalize":73}],76:[function(t,e,r){"use strict";var n=t("./lib/bn-sign");e.exports=function(t){return n(t[0])*n(t[1])}},{"./lib/bn-sign":68}],77:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},{"./lib/rationalize":73}],78:[function(t,e,r){"use strict";var n=t("./lib/bn-to-num"),i=t("./lib/ctz");e.exports=function(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var a=e.abs().divmod(r.abs()),o=a.div,s=n(o),l=a.mod,c=e.negative!==r.negative?-1:1;if(0===l.cmpn(0))return c*s;if(s){var u=i(s)+4,f=n(l.ushln(u).divRound(r));return c*(s+f*Math.pow(2,-u))}var h=r.bitLength()-l.bitLength()+53,f=n(l.ushln(h).divRound(r));return h<1023?c*f*Math.pow(2,-h):(f*=Math.pow(2,-1023),c*f*Math.pow(2,1023-h))}},{"./lib/bn-to-num":69,"./lib/ctz":70}],79:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],80:[function(t,e,r){"use strict";function n(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}r.INT_BITS=32,r.INT_MAX=2147483647,r.INT_MIN=-1<<31,r.sign=function(t){return(t>0)-(t<0)},r.abs=function(t){var e=t>>31;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},r.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},r.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},r.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},r.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],81:[function(t,e,r){"use strict";var n=t("clamp");e.exports=function(t,e){e||(e={});var r,o,s,l,c,u,f,h,p,d,g,v=null==e.cutoff?.25:e.cutoff,m=null==e.radius?8:e.radius,y=e.channel||0;if(ArrayBuffer.isView(t)||Array.isArray(t)){if(!e.width||!e.height)throw Error("For raw data width and height should be provided by options");r=e.width,o=e.height,l=t,u=e.stride?e.stride:Math.floor(t.length/r/o)}else window.HTMLCanvasElement&&t instanceof window.HTMLCanvasElement?(f=(h=t).getContext("2d"),r=h.width,o=h.height,p=f.getImageData(0,0,r,o),l=p.data,u=4):window.CanvasRenderingContext2D&&t instanceof window.CanvasRenderingContext2D?(h=t.canvas,f=t,r=h.width,o=h.height,p=f.getImageData(0,0,r,o),l=p.data,u=4):window.ImageData&&t instanceof window.ImageData&&(p=t,r=t.width,o=t.height,l=p.data,u=4);if(s=Math.max(r,o),window.Uint8ClampedArray&&l instanceof window.Uint8ClampedArray||window.Uint8Array&&l instanceof window.Uint8Array)for(c=l,l=Array(r*o),d=0,g=c.length;d=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function l(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return i}a.isBN=function(t){return t instanceof a||null!==t&&"object"==typeof t&&t.constructor.wordSize===a.wordSize&&Array.isArray(t.words)},a.max=function(t,e){return t.cmp(e)>0?t:e},a.min=function(t,e){return t.cmp(e)<0?t:e},a.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if("le"===r)for(i=0,a=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},a.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=s(t,r,r+6),this.words[n]|=i<>>26-a&4194303,(a+=24)>=26&&(a-=26,n++);r+6!==e&&(i=s(t,e,r+6),this.words[n]|=i<>>26-a&4194303),this.strip()},a.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,o=a%n,s=Math.min(a,a-o)+r,c=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],a=0|e.words[0],o=i*a,s=67108863&o,l=o/67108864|0;r.words[0]=s;for(var c=1;c>>26,f=67108863&l,h=Math.min(c,e.length-1),p=Math.max(0,c-t.length+1);p<=h;p++){var d=c-p|0;u+=(o=(i=0|t.words[d])*(a=0|e.words[p])+f)/67108864|0,f=67108863&o}r.words[c]=0|f,l=0|u}return 0!==l?r.words[c]=0|l:r.length--,r.strip()}a.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,a=0,o=0;o>>24-i&16777215)||o!==this.length-1?c[6-l.length]+l+r:l+r,(i+=2)>=26&&(i-=26,o--)}for(0!==a&&(r=a.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var h=u[t],p=f[t];r="";var d=this.clone();for(d.negative=0;!d.isZero();){var g=d.modn(p).toString(t);r=(d=d.idivn(p)).isZero()?g+r:c[h-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(t,e){return n("undefined"!=typeof o),this.toArrayLike(o,t,e)},a.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},a.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,"byte array longer than desired length"),n(a>0,"Requested array length <= 0"),this.strip();var o,s,l="le"===e,c=new t(a),u=this.clone();if(l){for(s=0;!u.isZero();s++)o=u.andln(255),u.iushrn(8),c[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},a.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},a.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},a.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},a.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},a.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},a.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},a.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},a.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},a.prototype.notn=function(t){return this.clone().inotn(t)},a.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26;for(;0!==i&&a>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},a.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,p=0|o[1],d=8191&p,g=p>>>13,v=0|o[2],m=8191&v,y=v>>>13,x=0|o[3],b=8191&x,_=x>>>13,w=0|o[4],k=8191&w,M=w>>>13,A=0|o[5],T=8191&A,S=A>>>13,E=0|o[6],C=8191&E,L=E>>>13,z=0|o[7],O=8191&z,I=z>>>13,P=0|o[8],D=8191&P,R=P>>>13,B=0|o[9],F=8191&B,N=B>>>13,j=0|s[0],V=8191&j,U=j>>>13,q=0|s[1],H=8191&q,G=q>>>13,W=0|s[2],Y=8191&W,X=W>>>13,Z=0|s[3],$=8191&Z,J=Z>>>13,K=0|s[4],Q=8191&K,tt=K>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],at=8191&it,ot=it>>>13,st=0|s[7],lt=8191&st,ct=st>>>13,ut=0|s[8],ft=8191&ut,ht=ut>>>13,pt=0|s[9],dt=8191&pt,gt=pt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(c+(n=Math.imul(f,V))|0)+((8191&(i=(i=Math.imul(f,U))+Math.imul(h,V)|0))<<13)|0;c=((a=Math.imul(h,U))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(d,V),i=(i=Math.imul(d,U))+Math.imul(g,V)|0,a=Math.imul(g,U);var mt=(c+(n=n+Math.imul(f,H)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(h,H)|0))<<13)|0;c=((a=a+Math.imul(h,G)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,V),i=(i=Math.imul(m,U))+Math.imul(y,V)|0,a=Math.imul(y,U),n=n+Math.imul(d,H)|0,i=(i=i+Math.imul(d,G)|0)+Math.imul(g,H)|0,a=a+Math.imul(g,G)|0;var yt=(c+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,X)|0)+Math.imul(h,Y)|0))<<13)|0;c=((a=a+Math.imul(h,X)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(b,V),i=(i=Math.imul(b,U))+Math.imul(_,V)|0,a=Math.imul(_,U),n=n+Math.imul(m,H)|0,i=(i=i+Math.imul(m,G)|0)+Math.imul(y,H)|0,a=a+Math.imul(y,G)|0,n=n+Math.imul(d,Y)|0,i=(i=i+Math.imul(d,X)|0)+Math.imul(g,Y)|0,a=a+Math.imul(g,X)|0;var xt=(c+(n=n+Math.imul(f,$)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(h,$)|0))<<13)|0;c=((a=a+Math.imul(h,J)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(k,V),i=(i=Math.imul(k,U))+Math.imul(M,V)|0,a=Math.imul(M,U),n=n+Math.imul(b,H)|0,i=(i=i+Math.imul(b,G)|0)+Math.imul(_,H)|0,a=a+Math.imul(_,G)|0,n=n+Math.imul(m,Y)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(y,Y)|0,a=a+Math.imul(y,X)|0,n=n+Math.imul(d,$)|0,i=(i=i+Math.imul(d,J)|0)+Math.imul(g,$)|0,a=a+Math.imul(g,J)|0;var bt=(c+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(h,Q)|0))<<13)|0;c=((a=a+Math.imul(h,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(T,V),i=(i=Math.imul(T,U))+Math.imul(S,V)|0,a=Math.imul(S,U),n=n+Math.imul(k,H)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(M,H)|0,a=a+Math.imul(M,G)|0,n=n+Math.imul(b,Y)|0,i=(i=i+Math.imul(b,X)|0)+Math.imul(_,Y)|0,a=a+Math.imul(_,X)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(y,$)|0,a=a+Math.imul(y,J)|0,n=n+Math.imul(d,Q)|0,i=(i=i+Math.imul(d,tt)|0)+Math.imul(g,Q)|0,a=a+Math.imul(g,tt)|0;var _t=(c+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(h,rt)|0))<<13)|0;c=((a=a+Math.imul(h,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,V),i=(i=Math.imul(C,U))+Math.imul(L,V)|0,a=Math.imul(L,U),n=n+Math.imul(T,H)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,G)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(M,Y)|0,a=a+Math.imul(M,X)|0,n=n+Math.imul(b,$)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(_,$)|0,a=a+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(y,Q)|0,a=a+Math.imul(y,tt)|0,n=n+Math.imul(d,rt)|0,i=(i=i+Math.imul(d,nt)|0)+Math.imul(g,rt)|0,a=a+Math.imul(g,nt)|0;var wt=(c+(n=n+Math.imul(f,at)|0)|0)+((8191&(i=(i=i+Math.imul(f,ot)|0)+Math.imul(h,at)|0))<<13)|0;c=((a=a+Math.imul(h,ot)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(O,V),i=(i=Math.imul(O,U))+Math.imul(I,V)|0,a=Math.imul(I,U),n=n+Math.imul(C,H)|0,i=(i=i+Math.imul(C,G)|0)+Math.imul(L,H)|0,a=a+Math.imul(L,G)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(S,Y)|0,a=a+Math.imul(S,X)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(M,$)|0,a=a+Math.imul(M,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(_,Q)|0,a=a+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(y,rt)|0,a=a+Math.imul(y,nt)|0,n=n+Math.imul(d,at)|0,i=(i=i+Math.imul(d,ot)|0)+Math.imul(g,at)|0,a=a+Math.imul(g,ot)|0;var kt=(c+(n=n+Math.imul(f,lt)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(h,lt)|0))<<13)|0;c=((a=a+Math.imul(h,ct)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,V),i=(i=Math.imul(D,U))+Math.imul(R,V)|0,a=Math.imul(R,U),n=n+Math.imul(O,H)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,G)|0,n=n+Math.imul(C,Y)|0,i=(i=i+Math.imul(C,X)|0)+Math.imul(L,Y)|0,a=a+Math.imul(L,X)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(M,Q)|0,a=a+Math.imul(M,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(_,rt)|0,a=a+Math.imul(_,nt)|0,n=n+Math.imul(m,at)|0,i=(i=i+Math.imul(m,ot)|0)+Math.imul(y,at)|0,a=a+Math.imul(y,ot)|0,n=n+Math.imul(d,lt)|0,i=(i=i+Math.imul(d,ct)|0)+Math.imul(g,lt)|0,a=a+Math.imul(g,ct)|0;var Mt=(c+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ht)|0)+Math.imul(h,ft)|0))<<13)|0;c=((a=a+Math.imul(h,ht)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(F,V),i=(i=Math.imul(F,U))+Math.imul(N,V)|0,a=Math.imul(N,U),n=n+Math.imul(D,H)|0,i=(i=i+Math.imul(D,G)|0)+Math.imul(R,H)|0,a=a+Math.imul(R,G)|0,n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(I,Y)|0,a=a+Math.imul(I,X)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(L,$)|0,a=a+Math.imul(L,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(S,Q)|0,a=a+Math.imul(S,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,nt)|0,n=n+Math.imul(b,at)|0,i=(i=i+Math.imul(b,ot)|0)+Math.imul(_,at)|0,a=a+Math.imul(_,ot)|0,n=n+Math.imul(m,lt)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(y,lt)|0,a=a+Math.imul(y,ct)|0,n=n+Math.imul(d,ft)|0,i=(i=i+Math.imul(d,ht)|0)+Math.imul(g,ft)|0,a=a+Math.imul(g,ht)|0;var At=(c+(n=n+Math.imul(f,dt)|0)|0)+((8191&(i=(i=i+Math.imul(f,gt)|0)+Math.imul(h,dt)|0))<<13)|0;c=((a=a+Math.imul(h,gt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(F,H),i=(i=Math.imul(F,G))+Math.imul(N,H)|0,a=Math.imul(N,G),n=n+Math.imul(D,Y)|0,i=(i=i+Math.imul(D,X)|0)+Math.imul(R,Y)|0,a=a+Math.imul(R,X)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,J)|0,n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(L,Q)|0,a=a+Math.imul(L,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,nt)|0,n=n+Math.imul(k,at)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,n=n+Math.imul(b,lt)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(_,lt)|0,a=a+Math.imul(_,ct)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ht)|0)+Math.imul(y,ft)|0,a=a+Math.imul(y,ht)|0;var Tt=(c+(n=n+Math.imul(d,dt)|0)|0)+((8191&(i=(i=i+Math.imul(d,gt)|0)+Math.imul(g,dt)|0))<<13)|0;c=((a=a+Math.imul(g,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(F,Y),i=(i=Math.imul(F,X))+Math.imul(N,Y)|0,a=Math.imul(N,X),n=n+Math.imul(D,$)|0,i=(i=i+Math.imul(D,J)|0)+Math.imul(R,$)|0,a=a+Math.imul(R,J)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(I,Q)|0,a=a+Math.imul(I,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(L,rt)|0,a=a+Math.imul(L,nt)|0,n=n+Math.imul(T,at)|0,i=(i=i+Math.imul(T,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,n=n+Math.imul(k,lt)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(M,lt)|0,a=a+Math.imul(M,ct)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ht)|0)+Math.imul(_,ft)|0,a=a+Math.imul(_,ht)|0;var St=(c+(n=n+Math.imul(m,dt)|0)|0)+((8191&(i=(i=i+Math.imul(m,gt)|0)+Math.imul(y,dt)|0))<<13)|0;c=((a=a+Math.imul(y,gt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(F,$),i=(i=Math.imul(F,J))+Math.imul(N,$)|0,a=Math.imul(N,J),n=n+Math.imul(D,Q)|0,i=(i=i+Math.imul(D,tt)|0)+Math.imul(R,Q)|0,a=a+Math.imul(R,tt)|0,n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,nt)|0,n=n+Math.imul(C,at)|0,i=(i=i+Math.imul(C,ot)|0)+Math.imul(L,at)|0,a=a+Math.imul(L,ot)|0,n=n+Math.imul(T,lt)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(S,lt)|0,a=a+Math.imul(S,ct)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ht)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ht)|0;var Et=(c+(n=n+Math.imul(b,dt)|0)|0)+((8191&(i=(i=i+Math.imul(b,gt)|0)+Math.imul(_,dt)|0))<<13)|0;c=((a=a+Math.imul(_,gt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(F,Q),i=(i=Math.imul(F,tt))+Math.imul(N,Q)|0,a=Math.imul(N,tt),n=n+Math.imul(D,rt)|0,i=(i=i+Math.imul(D,nt)|0)+Math.imul(R,rt)|0,a=a+Math.imul(R,nt)|0,n=n+Math.imul(O,at)|0,i=(i=i+Math.imul(O,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,n=n+Math.imul(C,lt)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(L,lt)|0,a=a+Math.imul(L,ct)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ht)|0)+Math.imul(S,ft)|0,a=a+Math.imul(S,ht)|0;var Ct=(c+(n=n+Math.imul(k,dt)|0)|0)+((8191&(i=(i=i+Math.imul(k,gt)|0)+Math.imul(M,dt)|0))<<13)|0;c=((a=a+Math.imul(M,gt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(F,rt),i=(i=Math.imul(F,nt))+Math.imul(N,rt)|0,a=Math.imul(N,nt),n=n+Math.imul(D,at)|0,i=(i=i+Math.imul(D,ot)|0)+Math.imul(R,at)|0,a=a+Math.imul(R,ot)|0,n=n+Math.imul(O,lt)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(I,lt)|0,a=a+Math.imul(I,ct)|0,n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,ht)|0)+Math.imul(L,ft)|0,a=a+Math.imul(L,ht)|0;var Lt=(c+(n=n+Math.imul(T,dt)|0)|0)+((8191&(i=(i=i+Math.imul(T,gt)|0)+Math.imul(S,dt)|0))<<13)|0;c=((a=a+Math.imul(S,gt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(F,at),i=(i=Math.imul(F,ot))+Math.imul(N,at)|0,a=Math.imul(N,ot),n=n+Math.imul(D,lt)|0,i=(i=i+Math.imul(D,ct)|0)+Math.imul(R,lt)|0,a=a+Math.imul(R,ct)|0,n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,ht)|0)+Math.imul(I,ft)|0,a=a+Math.imul(I,ht)|0;var zt=(c+(n=n+Math.imul(C,dt)|0)|0)+((8191&(i=(i=i+Math.imul(C,gt)|0)+Math.imul(L,dt)|0))<<13)|0;c=((a=a+Math.imul(L,gt)|0)+(i>>>13)|0)+(zt>>>26)|0,zt&=67108863,n=Math.imul(F,lt),i=(i=Math.imul(F,ct))+Math.imul(N,lt)|0,a=Math.imul(N,ct),n=n+Math.imul(D,ft)|0,i=(i=i+Math.imul(D,ht)|0)+Math.imul(R,ft)|0,a=a+Math.imul(R,ht)|0;var Ot=(c+(n=n+Math.imul(O,dt)|0)|0)+((8191&(i=(i=i+Math.imul(O,gt)|0)+Math.imul(I,dt)|0))<<13)|0;c=((a=a+Math.imul(I,gt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(F,ft),i=(i=Math.imul(F,ht))+Math.imul(N,ft)|0,a=Math.imul(N,ht);var It=(c+(n=n+Math.imul(D,dt)|0)|0)+((8191&(i=(i=i+Math.imul(D,gt)|0)+Math.imul(R,dt)|0))<<13)|0;c=((a=a+Math.imul(R,gt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863;var Pt=(c+(n=Math.imul(F,dt))|0)+((8191&(i=(i=Math.imul(F,gt))+Math.imul(N,dt)|0))<<13)|0;return c=((a=Math.imul(N,gt))+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,l[0]=vt,l[1]=mt,l[2]=yt,l[3]=xt,l[4]=bt,l[5]=_t,l[6]=wt,l[7]=kt,l[8]=Mt,l[9]=At,l[10]=Tt,l[11]=St,l[12]=Et,l[13]=Ct,l[14]=Lt,l[15]=zt,l[16]=Ot,l[17]=It,l[18]=Pt,0!==c&&(l[19]=c,r.length++),r};function d(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=h),a.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?h(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,n=o,o=i}return 0!==n?r.words[a]=n:r.length--,r.strip()}(this,t,e):d(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=a.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,i,a){for(var o=0;o>>=1)i++;return 1<>>=13,r[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=a>>>26,this.words[r]=67108863&a}return 0!==e&&(this.words[r]=e,this.length++),this},a.prototype.muln=function(t){return this.clone().imuln(t)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new a(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,c=0;c=0&&(0!==u||c>=i);c--){var f=0|this.words[c];this.words[c]=u<<26-a|f>>>a,u=f&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},a.prototype.shln=function(t){return this.clone().ishln(t)},a.prototype.ushln=function(t){return this.clone().iushln(t)},a.prototype.shrn=function(t){return this.clone().ishrn(t)},a.prototype.ushrn=function(t){return this.clone().iushrn(t)},a.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},a.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(l/67108864|0),this.words[i+r]=67108863&a}for(;i>26,this.words[i+r]=67108863&a;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&a;return this.negative=1,this.strip()},a.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var s,l=n.length-i.length;if("mod"!==e){(s=new a(null)).length=l+1,s.words=new Array(s.length);for(var c=0;c=0;f--){var h=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(h=Math.min(h/o|0,67108863),n._ishlnsubmul(i,h,f);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=h)}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},a.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(i=s.div.neg()),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new a(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new a(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new a(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,s},a.prototype.div=function(t){return this.divmod(t,"div",!1).div},a.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},a.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},a.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),a=r.cmp(n);return a<0||1===i&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},a.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},a.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},a.prototype.divn=function(t){return this.clone().idivn(t)},a.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new a(1),o=new a(0),s=new a(0),l=new a(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var u=r.clone(),f=e.clone();!e.isZero();){for(var h=0,p=1;0==(e.words[0]&p)&&h<26;++h,p<<=1);if(h>0)for(e.iushrn(h);h-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(u),o.isub(f)),i.iushrn(1),o.iushrn(1);for(var d=0,g=1;0==(r.words[0]&g)&&d<26;++d,g<<=1);if(d>0)for(r.iushrn(d);d-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(u),l.isub(f)),s.iushrn(1),l.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(s),o.isub(l)):(r.isub(e),s.isub(i),l.isub(o))}return{a:s,b:l,gcd:r.iushln(c)}},a.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new a(1),s=new a(0),l=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,u=1;0==(e.words[0]&u)&&c<26;++c,u<<=1);if(c>0)for(e.iushrn(c);c-- >0;)o.isOdd()&&o.iadd(l),o.iushrn(1);for(var f=0,h=1;0==(r.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(s)):(r.isub(e),s.isub(o))}return(i=0===e.cmpn(1)?o:s).cmpn(0)<0&&i.iadd(t),i},a.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},a.prototype.invm=function(t){return this.egcd(t).a.umod(t)},a.prototype.isEven=function(){return 0==(1&this.words[0])},a.prototype.isOdd=function(){return 1==(1&this.words[0])},a.prototype.andln=function(t){return this.words[0]&t},a.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},a.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},a.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},a.prototype.gtn=function(t){return 1===this.cmpn(t)},a.prototype.gt=function(t){return 1===this.cmp(t)},a.prototype.gten=function(t){return this.cmpn(t)>=0},a.prototype.gte=function(t){return this.cmp(t)>=0},a.prototype.ltn=function(t){return-1===this.cmpn(t)},a.prototype.lt=function(t){return-1===this.cmp(t)},a.prototype.lten=function(t){return this.cmpn(t)<=0},a.prototype.lte=function(t){return this.cmp(t)<=0},a.prototype.eqn=function(t){return 0===this.cmpn(t)},a.prototype.eq=function(t){return 0===this.cmp(t)},a.red=function(t){return new w(t)},a.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},a.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(t){return this.red=t,this},a.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},a.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},a.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},a.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},a.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},a.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},a.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},a.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},a.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new a(e,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function x(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=a._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function k(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var t=new a(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(y,m),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=a}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},a._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new x;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return v[t]=e,e},w.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new a(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var s=new a(1).toRed(this),l=s.redNeg(),c=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new a(2*u*u).toRed(this);0!==this.pow(u,c).cmp(l);)u.redIAdd(l);for(var f=this.pow(u,i),h=this.pow(t,i.addn(1).iushrn(1)),p=this.pow(t,i),d=o;0!==p.cmp(s);){for(var g=p,v=0;0!==g.cmp(s);v++)g=g.redSqr();n(v=0;n--){for(var c=e.words[n],u=l-1;u>=0;u--){var f=c>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==o?(o<<=1,o|=f,(4===++s||0===n&&0===u)&&(i=this.mul(i,r[o]),s=0,o=0)):s=0}l=26}return i},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},a.mont=function(t){return new k(t)},i(k,w),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new a(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof e||e,this)},{buffer:91}],83:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i=t.length,a=0;for(e=0;e>>1;if(!(u<=0)){var f,h=i.mallocDouble(2*u*s),p=i.mallocInt32(s);if((s=l(t,u,h,p))>0){if(1===u&&n)a.init(s),f=a.sweepComplete(u,r,0,s,h,p,0,s,h,p);else{var d=i.mallocDouble(2*u*c),g=i.mallocInt32(c);(c=l(e,u,d,g))>0&&(a.init(s+c),f=1===u?a.sweepBipartite(u,r,0,s,h,p,0,c,d,g):o(u,r,n,s,h,p,c,d,g),i.free(d),i.free(g))}i.free(h),i.free(p)}return f}}}function u(t,e){n.push([t,e])}},{"./lib/intersect":86,"./lib/sweep":90,"typedarray-pool":522}],85:[function(t,e,r){"use strict";var n="d",i="ax",a="vv",o="fp",s="es",l="rs",c="re",u="rb",f="ri",h="rp",p="bs",d="be",g="bb",v="bi",m="bp",y="rv",x="Q",b=[n,i,a,l,c,u,f,p,d,g,v];function _(t){var e="bruteForce"+(t?"Full":"Partial"),r=[],_=b.slice();t||_.splice(3,0,o);var w=["function "+e+"("+_.join()+"){"];function k(e,o){var _=function(t,e,r){var o="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),_=["function ",o,"(",b.join(),"){","var ",s,"=2*",n,";"],w="for(var i="+l+","+h+"="+s+"*"+l+";i<"+c+";++i,"+h+"+="+s+"){var x0="+u+"["+i+"+"+h+"],x1="+u+"["+i+"+"+h+"+"+n+"],xi="+f+"[i];",k="for(var j="+p+","+m+"="+s+"*"+p+";j<"+d+";++j,"+m+"+="+s+"){var y0="+g+"["+i+"+"+m+"],"+(r?"y1="+g+"["+i+"+"+m+"+"+n+"],":"")+"yi="+v+"[j];";return t?_.push(w,x,":",k):_.push(k,x,":",w),r?_.push("if(y1"+d+"-"+p+"){"),t?(k(!0,!1),w.push("}else{"),k(!1,!1)):(w.push("if("+o+"){"),k(!0,!0),w.push("}else{"),k(!0,!1),w.push("}}else{if("+o+"){"),k(!1,!0),w.push("}else{"),k(!1,!1),w.push("}")),w.push("}}return "+e);var M=r.join("")+w.join("");return new Function(M)()}r.partial=_(!1),r.full=_(!0)},{}],86:[function(t,e,r){"use strict";e.exports=function(t,e,r,a,u,S,E,C,L){!function(t,e){var r=8*i.log2(e+1)*(t+1)|0,a=i.nextPow2(b*r);w.length0;){var P=(O-=1)*b,D=w[P],R=w[P+1],B=w[P+2],F=w[P+3],N=w[P+4],j=w[P+5],V=O*_,U=k[V],q=k[V+1],H=1&j,G=!!(16&j),W=u,Y=S,X=C,Z=L;if(H&&(W=C,Y=L,X=u,Z=S),!(2&j&&(B=v(t,D,R,B,W,Y,q),R>=B)||4&j&&(R=m(t,D,R,B,W,Y,U))>=B)){var $=B-R,J=N-F;if(G){if(t*$*($+J)=p0)&&!(p1>=hi)",["p0","p1"]),g=u("lo===p0",["p0"]),v=u("lo>>1,h=2*t,p=f,d=s[h*f+e];for(;c=x?(p=y,d=x):m>=_?(p=v,d=m):(p=b,d=_):x>=_?(p=y,d=x):_>=m?(p=v,d=m):(p=b,d=_);for(var w=h*(u-1),k=h*p,M=0;Mr&&i[f+e]>c;--u,f-=o){for(var h=f,p=f+o,d=0;d=0&&i.push("lo=e[k+n]");t.indexOf("hi")>=0&&i.push("hi=e[k+o]");return r.push(n.replace("_",i.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],89:[function(t,e,r){"use strict";e.exports=function(t,e){e<=4*n?i(0,e-1,t):function t(e,r,f){var h=(r-e+1)/6|0,p=e+h,d=r-h,g=e+r>>1,v=g-h,m=g+h,y=p,x=v,b=g,_=m,w=d,k=e+1,M=r-1,A=0;c(y,x,f)&&(A=y,y=x,x=A);c(_,w,f)&&(A=_,_=w,w=A);c(y,b,f)&&(A=y,y=b,b=A);c(x,b,f)&&(A=x,x=b,b=A);c(y,_,f)&&(A=y,y=_,_=A);c(b,_,f)&&(A=b,b=_,_=A);c(x,w,f)&&(A=x,x=w,w=A);c(x,b,f)&&(A=x,x=b,b=A);c(_,w,f)&&(A=_,_=w,w=A);var T=f[2*x];var S=f[2*x+1];var E=f[2*_];var C=f[2*_+1];var L=2*y;var z=2*b;var O=2*w;var I=2*p;var P=2*g;var D=2*d;for(var R=0;R<2;++R){var B=f[L+R],F=f[z+R],N=f[O+R];f[I+R]=B,f[P+R]=F,f[D+R]=N}o(v,e,f);o(m,r,f);for(var j=k;j<=M;++j)if(u(j,T,S,f))j!==k&&a(j,k,f),++k;else if(!u(j,E,C,f))for(;;){if(u(M,E,C,f)){u(M,T,S,f)?(s(j,k,M,f),++k,--M):(a(j,M,f),--M);break}if(--Mt;){var c=r[l-2],u=r[l-1];if(cr[e+1])}function u(t,e,r,n){var i=n[t*=2];return i>>1;a(p,S);for(var E=0,C=0,k=0;k=o)d(c,u,C--,L=L-o|0);else if(L>=0)d(s,l,E--,L);else if(L<=-o){L=-L-o|0;for(var z=0;z>>1;a(p,E);for(var C=0,L=0,z=0,M=0;M>1==p[2*M+3]>>1&&(I=2,M+=1),O<0){for(var P=-(O>>1)-1,D=0;D>1)-1;0===I?d(s,l,C--,P):1===I?d(c,u,L--,P):2===I&&d(f,h,z--,P)}}},scanBipartite:function(t,e,r,n,i,c,u,f,h,v,m,y){var x=0,b=2*t,_=e,w=e+t,k=1,M=1;n?M=o:k=o;for(var A=i;A>>1;a(p,C);for(var L=0,A=0;A=o?(O=!n,T-=o):(O=!!n,T-=1),O)g(s,l,L++,T);else{var I=y[T],P=b*T,D=m[P+e+1],R=m[P+e+1+t];t:for(var B=0;B>>1;a(p,k);for(var M=0,x=0;x=o)s[M++]=b-o;else{var T=d[b-=1],S=v*b,E=h[S+e+1],C=h[S+e+1+t];t:for(var L=0;L=0;--L)if(s[L]===b){for(var P=L+1;P0&&s.length>a){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=o[e]=r,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,i=v(t,n),a=0;a=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,a=o;break}if(a<0)return this;0===a?r.shift():function(t,e){for(var r=e,n=r+1,i=t.length;n=0;a--)this.removeListener(t,e[a]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],93:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var a=2147483647;function o(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return f(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(j(t,ArrayBuffer)||t&&j(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return B(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return n?-1:B(t).length;e=(""+e).toLowerCase(),i=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var a,o=1,s=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,r/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var u=-1;for(a=r;as&&(r=s-l),a=r;a>=0;a--){for(var f=!0,h=0;hi&&(n=i):n=i;var a=e.length;n>a/2&&(n=a/2);for(var o=0;o>8,i=r%256,a.push(i),a.push(n);return a}(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function M(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(u=c);break;case 2:128==(192&(a=t[i+1]))&&(l=(31&c)<<6|63&a)>127&&(u=l);break;case 3:a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&(l=(15&c)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(l=(15&c)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,f=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=f}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return E(this,e,r);case"utf8":case"utf-8":return M(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return S(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(j(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var a=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),l=Math.min(a,o),c=this.slice(n,i),u=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return x(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function T(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",a=e;ar)throw new RangeError("Trying to access beyond buffer length")}function z(t,e,r,n,i,a){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function O(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,a){return e=+e,r>>>=0,a||O(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function P(t,e,r,n,a){return e=+e,r>>>=0,a||O(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t],i=1,a=0;++a>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t],i=1,a=0;++a=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||L(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*e)),a},s.prototype.readInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||L(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||L(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||L(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||L(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||L(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||L(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||z(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[e]=255&t;++a>>=0,r>>>=0,n)||z(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,a=1;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=t/a&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);z(this,t,e,r,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);z(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return P(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return P(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--a)t[a+e]=this[a+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(a=e;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(D,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function j(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}},{"base64-js":62,ieee754:395}],94:[function(t,e,r){"use strict";var n=t("./lib/monotone"),i=t("./lib/triangulation"),a=t("./lib/delaunay"),o=t("./lib/filter");function s(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function l(t,e){return t[0]-e[0]||t[1]-e[1]}function c(t,e,r){return e in t?t[e]:r}e.exports=function(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var u=!!c(r,"delaunay",!0),f=!!c(r,"interior",!0),h=!!c(r,"exterior",!0),p=!!c(r,"infinity",!1);if(!f&&!h||0===t.length)return[];var d=n(t,e);if(u||f!==h||p){for(var g=i(t.length,function(t){return t.map(s).sort(l)}(e)),v=0;v0;){for(var u=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],d=1;d=0||(e.flip(s,u),i(t,e,r,f,s,h),i(t,e,r,s,h,f),i(t,e,r,h,u,f),i(t,e,r,u,f,h)))}}},{"binary-search-bounds":99,"robust-in-sphere":484}],96:[function(t,e,r){"use strict";var n,i=t("binary-search-bounds");function a(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function o(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}e.exports=function(t,e,r){var n=function(t,e){for(var r=t.cells(),n=r.length,i=0;i0||l.length>0;){for(;s.length>0;){var p=s.pop();if(c[p]!==-i){c[p]=i;u[p];for(var d=0;d<3;++d){var g=h[3*p+d];g>=0&&0===c[g]&&(f[3*p+d]?l.push(g):(s.push(g),c[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=function(t,e,r){for(var n=0,i=0;i1&&i(r[h[p-2]],r[h[p-1]],a)>0;)t.push([h[p-1],h[p-2],o]),p-=1;h.length=p,h.push(o);var d=u.upperIds;for(p=d.length;p>1&&i(r[d[p-2]],r[d[p-1]],a)<0;)t.push([d[p-2],d[p-1],o]),p-=1;d.length=p,d.push(o)}}function p(t,e){var r;return(r=t.a[0]m[0]&&i.push(new c(m,v,s,f),new c(v,m,o,f))}i.sort(u);for(var y=i[0].a[0]-(1+Math.abs(i[0].a[0]))*Math.pow(2,-52),x=[new l([y,1],[y,0],-1,[],[],[],[])],b=[],f=0,_=i.length;f<_;++f){var w=i[f],k=w.type;k===a?h(b,x,t,w.a,w.idx):k===s?d(x,t,w):g(x,t,w)}return b}},{"binary-search-bounds":99,"robust-orientation":486}],98:[function(t,e,r){"use strict";var n=t("binary-search-bounds");function i(t,e){this.stars=t,this.edges=e}e.exports=function(t,e){for(var r=new Array(t),n=0;n=0}}(),a.removeTriangle=function(t,e,r){var n=this.stars;o(n[t],e,r),o(n[e],r,t),o(n[r],t,e)},a.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},a.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;n>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],100:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1,r=1;rr?r:t:te?e:t}},{}],104:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n;if(r){n=e;for(var i=new Array(e.length),a=0;ae[2]?1:0)}function m(t,e,r){if(0!==t.length){if(e)for(var n=0;n=0;--a){var x=e[u=(S=n[a])[0]],b=x[0],_=x[1],w=t[b],k=t[_];if((w[0]-k[0]||w[1]-k[1])<0){var M=b;b=_,_=M}x[0]=b;var A,T=x[1]=S[1];for(i&&(A=x[2]);a>0&&n[a-1][0]===u;){var S,E=(S=n[--a])[1];i?e.push([T,E,A]):e.push([T,E]),T=E}i?e.push([T,_,A]):e.push([T,_])}return h}(t,e,h,v,r));return m(e,y,r),!!y||(h.length>0||v.length>0)}},{"./lib/rat-seg-intersect":105,"big-rat":66,"big-rat/cmp":64,"big-rat/to-float":78,"box-intersect":84,nextafter:434,"rat-vec":469,"robust-segment-intersect":489,"union-find":523}],105:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var a=s(e,t),f=s(n,r),h=u(a,f);if(0===o(h))return null;var p=s(t,r),d=u(f,p),g=i(d,h),v=c(a,g);return l(t,v)};var n=t("big-rat/mul"),i=t("big-rat/div"),a=t("big-rat/sub"),o=t("big-rat/sign"),s=t("rat-vec/sub"),l=t("rat-vec/add"),c=t("rat-vec/muls");function u(t,e){return a(n(t[0],e[1]),n(t[1],e[0]))}},{"big-rat/div":65,"big-rat/mul":75,"big-rat/sign":76,"big-rat/sub":77,"rat-vec/add":468,"rat-vec/muls":470,"rat-vec/sub":471}],106:[function(t,e,r){"use strict";var n=t("clamp");function i(t,e){null==e&&(e=!0);var r=t[0],i=t[1],a=t[2],o=t[3];return null==o&&(o=e?1:255),e&&(r*=255,i*=255,a*=255,o*=255),16777216*(r=255&n(r,0,255))+((i=255&n(i,0,255))<<16)+((a=255&n(a,0,255))<<8)+(o=255&n(o,0,255))}e.exports=i,e.exports.to=i,e.exports.from=function(t,e){var r=(t=+t)>>>24,n=(16711680&t)>>>16,i=(65280&t)>>>8,a=255&t;return!1===e?[r,n,i,a]:[r/255,n/255,i/255,a/255]}},{clamp:103}],107:[function(t,e,r){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],108:[function(t,e,r){"use strict";var n=t("color-rgba"),i=t("clamp"),a=t("dtype");e.exports=function(t,e){"float"!==e&&e||(e="array"),"uint"===e&&(e="uint8"),"uint_clamped"===e&&(e="uint8_clamped");var r=new(a(e))(4),o="uint8"!==e&&"uint8_clamped"!==e;return t.length&&"string"!=typeof t||((t=n(t))[0]/=255,t[1]/=255,t[2]/=255),function(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||!!(Array.isArray(t)&&(t[0]>1||0===t[0])&&(t[1]>1||0===t[1])&&(t[2]>1||0===t[2])&&(!t[3]||t[3]>1))}(t)?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:255,o&&(r[0]/=255,r[1]/=255,r[2]/=255,r[3]/=255),r):(o?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:1):(r[0]=i(Math.floor(255*t[0]),0,255),r[1]=i(Math.floor(255*t[1]),0,255),r[2]=i(Math.floor(255*t[2]),0,255),r[3]=null==t[3]?255:i(Math.floor(255*t[3]),0,255)),r)}},{clamp:103,"color-rgba":110,dtype:154}],109:[function(t,e,r){(function(r){"use strict";var n=t("color-name"),i=t("is-plain-obj"),a=t("defined");e.exports=function(t){var e,s,l=[],c=1;if("string"==typeof t)if(n[t])l=n[t].slice(),s="rgb";else if("transparent"===t)c=0,s="rgb",l=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var u=t.slice(1),f=u.length,h=f<=4;c=1,h?(l=[parseInt(u[0]+u[0],16),parseInt(u[1]+u[1],16),parseInt(u[2]+u[2],16)],4===f&&(c=parseInt(u[3]+u[3],16)/255)):(l=[parseInt(u[0]+u[1],16),parseInt(u[2]+u[3],16),parseInt(u[4]+u[5],16)],8===f&&(c=parseInt(u[6]+u[7],16)/255)),l[0]||(l[0]=0),l[1]||(l[1]=0),l[2]||(l[2]=0),s="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var p=e[1],u=p.replace(/a$/,"");s=u;var f="cmyk"===u?4:"gray"===u?1:3;l=e[2].trim().split(/\s*,\s*/).map(function(t,e){if(/%$/.test(t))return e===f?parseFloat(t)/100:"rgb"===u?255*parseFloat(t)/100:parseFloat(t);if("h"===u[e]){if(/deg$/.test(t))return parseFloat(t);if(void 0!==o[t])return o[t]}return parseFloat(t)}),p===u&&l.push(1),c=void 0===l[f]?1:l[f],l=l.slice(0,f)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(l=t.match(/([0-9]+)/g).map(function(t){return parseFloat(t)}),s=t.match(/([a-z])/gi).join("").toLowerCase());else if(isNaN(t))if(i(t)){var d=a(t.r,t.red,t.R,null);null!==d?(s="rgb",l=[d,a(t.g,t.green,t.G),a(t.b,t.blue,t.B)]):(s="hsl",l=[a(t.h,t.hue,t.H),a(t.s,t.saturation,t.S),a(t.l,t.lightness,t.L,t.b,t.brightness)]),c=a(t.a,t.alpha,t.opacity,1),null!=t.opacity&&(c/=100)}else(Array.isArray(t)||r.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(t))&&(l=[t[0],t[1],t[2]],s="rgb",c=4===t.length?t[3]:1);else s="rgb",l=[t>>>16,(65280&t)>>>8,255&t];return{space:s,values:l,alpha:c}};var o={red:0,orange:60,yellow:120,green:180,blue:240,purple:300}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"color-name":107,defined:149,"is-plain-obj":405}],110:[function(t,e,r){"use strict";var n=t("color-parse"),i=t("color-space/hsl"),a=t("clamp");e.exports=function(t){var e,r=n(t);return r.space?((e=Array(3))[0]=a(r.values[0],0,255),e[1]=a(r.values[1],0,255),e[2]=a(r.values[2],0,255),"h"===r.space[0]&&(e=i.rgb(e)),e.push(a(r.alpha,0,1)),e):[]}},{clamp:103,"color-parse":109,"color-space/hsl":111}],111:[function(t,e,r){"use strict";var n=t("./rgb");e.exports={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e,r,n,i,a,o=t[0]/360,s=t[1]/100,l=t[2]/100;if(0===s)return[a=255*l,a,a];e=2*l-(r=l<.5?l*(1+s):l+s-l*s),i=[0,0,0];for(var c=0;c<3;c++)(n=o+1/3*-(c-1))<0?n++:n>1&&n--,a=6*n<1?e+6*(r-e)*n:2*n<1?r:3*n<2?e+(r-e)*(2/3-n)*6:e,i[c]=255*a;return i}},n.hsl=function(t){var e,r,n=t[0]/255,i=t[1]/255,a=t[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),l=s-o;return s===o?e=0:n===s?e=(i-a)/l:i===s?e=2+(a-n)/l:a===s&&(e=4+(n-i)/l),(e=Math.min(60*e,360))<0&&(e+=360),r=(o+s)/2,[e,100*(s===o?0:r<=.5?l/(s+o):l/(2-s-o)),100*r]}},{"./rgb":112}],112:[function(t,e,r){"use strict";e.exports={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]}},{}],113:[function(t,e,r){e.exports={jet:[{index:0,rgb:[0,0,131]},{index:.125,rgb:[0,60,170]},{index:.375,rgb:[5,255,255]},{index:.625,rgb:[255,255,0]},{index:.875,rgb:[250,0,0]},{index:1,rgb:[128,0,0]}],hsv:[{index:0,rgb:[255,0,0]},{index:.169,rgb:[253,255,2]},{index:.173,rgb:[247,255,2]},{index:.337,rgb:[0,252,4]},{index:.341,rgb:[0,252,10]},{index:.506,rgb:[1,249,255]},{index:.671,rgb:[2,0,253]},{index:.675,rgb:[8,0,253]},{index:.839,rgb:[255,0,251]},{index:.843,rgb:[255,0,245]},{index:1,rgb:[255,0,6]}],hot:[{index:0,rgb:[0,0,0]},{index:.3,rgb:[230,0,0]},{index:.6,rgb:[255,210,0]},{index:1,rgb:[255,255,255]}],cool:[{index:0,rgb:[0,255,255]},{index:1,rgb:[255,0,255]}],spring:[{index:0,rgb:[255,0,255]},{index:1,rgb:[255,255,0]}],summer:[{index:0,rgb:[0,128,102]},{index:1,rgb:[255,255,102]}],autumn:[{index:0,rgb:[255,0,0]},{index:1,rgb:[255,255,0]}],winter:[{index:0,rgb:[0,0,255]},{index:1,rgb:[0,255,128]}],bone:[{index:0,rgb:[0,0,0]},{index:.376,rgb:[84,84,116]},{index:.753,rgb:[169,200,200]},{index:1,rgb:[255,255,255]}],copper:[{index:0,rgb:[0,0,0]},{index:.804,rgb:[255,160,102]},{index:1,rgb:[255,199,127]}],greys:[{index:0,rgb:[0,0,0]},{index:1,rgb:[255,255,255]}],yignbu:[{index:0,rgb:[8,29,88]},{index:.125,rgb:[37,52,148]},{index:.25,rgb:[34,94,168]},{index:.375,rgb:[29,145,192]},{index:.5,rgb:[65,182,196]},{index:.625,rgb:[127,205,187]},{index:.75,rgb:[199,233,180]},{index:.875,rgb:[237,248,217]},{index:1,rgb:[255,255,217]}],greens:[{index:0,rgb:[0,68,27]},{index:.125,rgb:[0,109,44]},{index:.25,rgb:[35,139,69]},{index:.375,rgb:[65,171,93]},{index:.5,rgb:[116,196,118]},{index:.625,rgb:[161,217,155]},{index:.75,rgb:[199,233,192]},{index:.875,rgb:[229,245,224]},{index:1,rgb:[247,252,245]}],yiorrd:[{index:0,rgb:[128,0,38]},{index:.125,rgb:[189,0,38]},{index:.25,rgb:[227,26,28]},{index:.375,rgb:[252,78,42]},{index:.5,rgb:[253,141,60]},{index:.625,rgb:[254,178,76]},{index:.75,rgb:[254,217,118]},{index:.875,rgb:[255,237,160]},{index:1,rgb:[255,255,204]}],bluered:[{index:0,rgb:[0,0,255]},{index:1,rgb:[255,0,0]}],rdbu:[{index:0,rgb:[5,10,172]},{index:.35,rgb:[106,137,247]},{index:.5,rgb:[190,190,190]},{index:.6,rgb:[220,170,132]},{index:.7,rgb:[230,145,90]},{index:1,rgb:[178,10,28]}],picnic:[{index:0,rgb:[0,0,255]},{index:.1,rgb:[51,153,255]},{index:.2,rgb:[102,204,255]},{index:.3,rgb:[153,204,255]},{index:.4,rgb:[204,204,255]},{index:.5,rgb:[255,255,255]},{index:.6,rgb:[255,204,255]},{index:.7,rgb:[255,153,255]},{index:.8,rgb:[255,102,204]},{index:.9,rgb:[255,102,102]},{index:1,rgb:[255,0,0]}],rainbow:[{index:0,rgb:[150,0,90]},{index:.125,rgb:[0,0,200]},{index:.25,rgb:[0,25,255]},{index:.375,rgb:[0,152,255]},{index:.5,rgb:[44,255,150]},{index:.625,rgb:[151,255,0]},{index:.75,rgb:[255,234,0]},{index:.875,rgb:[255,111,0]},{index:1,rgb:[255,0,0]}],portland:[{index:0,rgb:[12,51,131]},{index:.25,rgb:[10,136,186]},{index:.5,rgb:[242,211,56]},{index:.75,rgb:[242,143,56]},{index:1,rgb:[217,30,30]}],blackbody:[{index:0,rgb:[0,0,0]},{index:.2,rgb:[230,0,0]},{index:.4,rgb:[230,210,0]},{index:.7,rgb:[255,255,255]},{index:1,rgb:[160,200,255]}],earth:[{index:0,rgb:[0,0,130]},{index:.1,rgb:[0,180,180]},{index:.2,rgb:[40,210,40]},{index:.4,rgb:[230,230,50]},{index:.6,rgb:[120,70,20]},{index:1,rgb:[255,255,255]}],electric:[{index:0,rgb:[0,0,0]},{index:.15,rgb:[30,0,100]},{index:.4,rgb:[120,0,100]},{index:.6,rgb:[160,90,0]},{index:.8,rgb:[230,200,0]},{index:1,rgb:[255,250,220]}],alpha:[{index:0,rgb:[255,255,255,0]},{index:1,rgb:[255,255,255,1]}],viridis:[{index:0,rgb:[68,1,84]},{index:.13,rgb:[71,44,122]},{index:.25,rgb:[59,81,139]},{index:.38,rgb:[44,113,142]},{index:.5,rgb:[33,144,141]},{index:.63,rgb:[39,173,129]},{index:.75,rgb:[92,200,99]},{index:.88,rgb:[170,220,50]},{index:1,rgb:[253,231,37]}],inferno:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[31,12,72]},{index:.25,rgb:[85,15,109]},{index:.38,rgb:[136,34,106]},{index:.5,rgb:[186,54,85]},{index:.63,rgb:[227,89,51]},{index:.75,rgb:[249,140,10]},{index:.88,rgb:[249,201,50]},{index:1,rgb:[252,255,164]}],magma:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[28,16,68]},{index:.25,rgb:[79,18,123]},{index:.38,rgb:[129,37,129]},{index:.5,rgb:[181,54,122]},{index:.63,rgb:[229,80,100]},{index:.75,rgb:[251,135,97]},{index:.88,rgb:[254,194,135]},{index:1,rgb:[252,253,191]}],plasma:[{index:0,rgb:[13,8,135]},{index:.13,rgb:[75,3,161]},{index:.25,rgb:[125,3,168]},{index:.38,rgb:[168,34,150]},{index:.5,rgb:[203,70,121]},{index:.63,rgb:[229,107,93]},{index:.75,rgb:[248,148,65]},{index:.88,rgb:[253,195,40]},{index:1,rgb:[240,249,33]}],warm:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[172,0,187]},{index:.25,rgb:[219,0,170]},{index:.38,rgb:[255,0,130]},{index:.5,rgb:[255,63,74]},{index:.63,rgb:[255,123,0]},{index:.75,rgb:[234,176,0]},{index:.88,rgb:[190,228,0]},{index:1,rgb:[147,255,0]}],cool:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[116,0,218]},{index:.25,rgb:[98,74,237]},{index:.38,rgb:[68,146,231]},{index:.5,rgb:[0,204,197]},{index:.63,rgb:[0,247,146]},{index:.75,rgb:[0,255,88]},{index:.88,rgb:[40,255,8]},{index:1,rgb:[147,255,0]}],"rainbow-soft":[{index:0,rgb:[125,0,179]},{index:.1,rgb:[199,0,180]},{index:.2,rgb:[255,0,121]},{index:.3,rgb:[255,108,0]},{index:.4,rgb:[222,194,0]},{index:.5,rgb:[150,255,0]},{index:.6,rgb:[0,255,55]},{index:.7,rgb:[0,246,150]},{index:.8,rgb:[50,167,222]},{index:.9,rgb:[103,51,235]},{index:1,rgb:[124,0,186]}],bathymetry:[{index:0,rgb:[40,26,44]},{index:.13,rgb:[59,49,90]},{index:.25,rgb:[64,76,139]},{index:.38,rgb:[63,110,151]},{index:.5,rgb:[72,142,158]},{index:.63,rgb:[85,174,163]},{index:.75,rgb:[120,206,163]},{index:.88,rgb:[187,230,172]},{index:1,rgb:[253,254,204]}],cdom:[{index:0,rgb:[47,15,62]},{index:.13,rgb:[87,23,86]},{index:.25,rgb:[130,28,99]},{index:.38,rgb:[171,41,96]},{index:.5,rgb:[206,67,86]},{index:.63,rgb:[230,106,84]},{index:.75,rgb:[242,149,103]},{index:.88,rgb:[249,193,135]},{index:1,rgb:[254,237,176]}],chlorophyll:[{index:0,rgb:[18,36,20]},{index:.13,rgb:[25,63,41]},{index:.25,rgb:[24,91,59]},{index:.38,rgb:[13,119,72]},{index:.5,rgb:[18,148,80]},{index:.63,rgb:[80,173,89]},{index:.75,rgb:[132,196,122]},{index:.88,rgb:[175,221,162]},{index:1,rgb:[215,249,208]}],density:[{index:0,rgb:[54,14,36]},{index:.13,rgb:[89,23,80]},{index:.25,rgb:[110,45,132]},{index:.38,rgb:[120,77,178]},{index:.5,rgb:[120,113,213]},{index:.63,rgb:[115,151,228]},{index:.75,rgb:[134,185,227]},{index:.88,rgb:[177,214,227]},{index:1,rgb:[230,241,241]}],"freesurface-blue":[{index:0,rgb:[30,4,110]},{index:.13,rgb:[47,14,176]},{index:.25,rgb:[41,45,236]},{index:.38,rgb:[25,99,212]},{index:.5,rgb:[68,131,200]},{index:.63,rgb:[114,156,197]},{index:.75,rgb:[157,181,203]},{index:.88,rgb:[200,208,216]},{index:1,rgb:[241,237,236]}],"freesurface-red":[{index:0,rgb:[60,9,18]},{index:.13,rgb:[100,17,27]},{index:.25,rgb:[142,20,29]},{index:.38,rgb:[177,43,27]},{index:.5,rgb:[192,87,63]},{index:.63,rgb:[205,125,105]},{index:.75,rgb:[216,162,148]},{index:.88,rgb:[227,199,193]},{index:1,rgb:[241,237,236]}],oxygen:[{index:0,rgb:[64,5,5]},{index:.13,rgb:[106,6,15]},{index:.25,rgb:[144,26,7]},{index:.38,rgb:[168,64,3]},{index:.5,rgb:[188,100,4]},{index:.63,rgb:[206,136,11]},{index:.75,rgb:[220,174,25]},{index:.88,rgb:[231,215,44]},{index:1,rgb:[248,254,105]}],par:[{index:0,rgb:[51,20,24]},{index:.13,rgb:[90,32,35]},{index:.25,rgb:[129,44,34]},{index:.38,rgb:[159,68,25]},{index:.5,rgb:[182,99,19]},{index:.63,rgb:[199,134,22]},{index:.75,rgb:[212,171,35]},{index:.88,rgb:[221,210,54]},{index:1,rgb:[225,253,75]}],phase:[{index:0,rgb:[145,105,18]},{index:.13,rgb:[184,71,38]},{index:.25,rgb:[186,58,115]},{index:.38,rgb:[160,71,185]},{index:.5,rgb:[110,97,218]},{index:.63,rgb:[50,123,164]},{index:.75,rgb:[31,131,110]},{index:.88,rgb:[77,129,34]},{index:1,rgb:[145,105,18]}],salinity:[{index:0,rgb:[42,24,108]},{index:.13,rgb:[33,50,162]},{index:.25,rgb:[15,90,145]},{index:.38,rgb:[40,118,137]},{index:.5,rgb:[59,146,135]},{index:.63,rgb:[79,175,126]},{index:.75,rgb:[120,203,104]},{index:.88,rgb:[193,221,100]},{index:1,rgb:[253,239,154]}],temperature:[{index:0,rgb:[4,35,51]},{index:.13,rgb:[23,51,122]},{index:.25,rgb:[85,59,157]},{index:.38,rgb:[129,79,143]},{index:.5,rgb:[175,95,130]},{index:.63,rgb:[222,112,101]},{index:.75,rgb:[249,146,66]},{index:.88,rgb:[249,196,65]},{index:1,rgb:[232,250,91]}],turbidity:[{index:0,rgb:[34,31,27]},{index:.13,rgb:[65,50,41]},{index:.25,rgb:[98,69,52]},{index:.38,rgb:[131,89,57]},{index:.5,rgb:[161,112,59]},{index:.63,rgb:[185,140,66]},{index:.75,rgb:[202,174,88]},{index:.88,rgb:[216,209,126]},{index:1,rgb:[233,246,171]}],"velocity-blue":[{index:0,rgb:[17,32,64]},{index:.13,rgb:[35,52,116]},{index:.25,rgb:[29,81,156]},{index:.38,rgb:[31,113,162]},{index:.5,rgb:[50,144,169]},{index:.63,rgb:[87,173,176]},{index:.75,rgb:[149,196,189]},{index:.88,rgb:[203,221,211]},{index:1,rgb:[254,251,230]}],"velocity-green":[{index:0,rgb:[23,35,19]},{index:.13,rgb:[24,64,38]},{index:.25,rgb:[11,95,45]},{index:.38,rgb:[39,123,35]},{index:.5,rgb:[95,146,12]},{index:.63,rgb:[152,165,18]},{index:.75,rgb:[201,186,69]},{index:.88,rgb:[233,216,137]},{index:1,rgb:[255,253,205]}],cubehelix:[{index:0,rgb:[0,0,0]},{index:.07,rgb:[22,5,59]},{index:.13,rgb:[60,4,105]},{index:.2,rgb:[109,1,135]},{index:.27,rgb:[161,0,147]},{index:.33,rgb:[210,2,142]},{index:.4,rgb:[251,11,123]},{index:.47,rgb:[255,29,97]},{index:.53,rgb:[255,54,69]},{index:.6,rgb:[255,85,46]},{index:.67,rgb:[255,120,34]},{index:.73,rgb:[255,157,37]},{index:.8,rgb:[241,191,57]},{index:.87,rgb:[224,220,93]},{index:.93,rgb:[218,241,142]},{index:1,rgb:[227,253,198]}]}},{}],114:[function(t,e,r){"use strict";var n=t("./colorScale"),i=t("lerp");function a(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}function o(t){for(var e,r="#",n=0;n<3;++n)r+=("00"+(e=(e=t[n]).toString(16))).substr(e.length);return r}function s(t){return"rgba("+t.join(",")+")"}e.exports=function(t){var e,r,l,c,u,f,h,p,d,g;t||(t={});p=(t.nshades||72)-1,h=t.format||"hex",(f=t.colormap)||(f="jet");if("string"==typeof f){if(f=f.toLowerCase(),!n[f])throw Error(f+" not a supported colorscale");u=n[f]}else{if(!Array.isArray(f))throw Error("unsupported colormap option",f);u=f.slice()}if(u.length>p)throw new Error(f+" map requires nshades to be at least size "+u.length);d=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:t.alpha.slice():"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1];e=u.map(function(t){return Math.round(t.index*p)}),d[0]=Math.min(Math.max(d[0],0),1),d[1]=Math.min(Math.max(d[1],0),1);var v=u.map(function(t,e){var r=u[e].index,n=u[e].rgb.slice();return 4===n.length&&n[3]>=0&&n[3]<=1?n:(n[3]=d[0]+(d[1]-d[0])*r,n)}),m=[];for(g=0;g0?-1:l(t,e,a)?-1:1:0===s?c>0?1:l(t,e,r)?1:-1:i(c-s)}var h=n(t,e,r);if(h>0)return o>0&&n(t,e,a)>0?1:-1;if(h<0)return o>0||n(t,e,a)>0?1:-1;var p=n(t,e,a);return p>0?1:l(t,e,r)?1:-1};var n=t("robust-orientation"),i=t("signum"),a=t("two-sum"),o=t("robust-product"),s=t("robust-sum");function l(t,e,r){var n=a(t[0],-e[0]),i=a(t[1],-e[1]),l=a(r[0],-e[0]),c=a(r[1],-e[1]),u=s(o(n,l),o(i,c));return u[u.length-1]>=0}},{"robust-orientation":486,"robust-product":487,"robust-sum":491,signum:492,"two-sum":521}],116:[function(t,e,r){e.exports=function(t,e){var r=t.length,a=t.length-e.length;if(a)return a;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||n(t[0],t[1])-n(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=n(t[0],t[1]),c=n(e[0],e[1]);return n(l,t[2])-n(c,e[2])||n(l+t[2],o)-n(c+e[2],s);case 4:var u=t[0],f=t[1],h=t[2],p=t[3],d=e[0],g=e[1],v=e[2],m=e[3];return u+f+h+p-(d+g+v+m)||n(u,f,h,p)-n(d,g,v,m,d)||n(u+f,u+h,u+p,f+h,f+p,h+p)-n(d+g,d+v,d+m,g+v,g+m,v+m)||n(u+f+h,u+f+p,u+h+p,f+h+p)-n(d+g+v,d+g+m,d+v+m,g+v+m);default:for(var y=t.slice().sort(i),x=e.slice().sort(i),b=0;bt[r][0]&&(r=n);return er?[[r],[e]]:[[e]]}},{}],120:[function(t,e,r){"use strict";e.exports=function(t){var e=n(t),r=e.length;if(r<=2)return[];for(var i=new Array(r),a=e[r-1],o=0;o=e[l]&&(s+=1);a[o]=s}}return t}(o,r)}};var n=t("incremental-convex-hull"),i=t("affine-hull")},{"affine-hull":50,"incremental-convex-hull":396}],122:[function(t,e,r){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",CPV:"verde",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai)(?!.*\\brep).*china|^(?=.*peo)(?=.*rep).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COG:"^(?!.*\\bdem)(?!.*\\bd[\\.]?r)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CSK:"czechoslovakia",CZE:"^(?=.*rep).*czech|czechia|bohemia",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bd[\\.]?r|\\bd[\\.]?r.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"(^ireland)|(^republic.*ireland)",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat|people|north|d.*p.*.r).*\\bkorea|dprk|korea.*(d.*p.*r)",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"fed.*micronesia|micronesia.*fed",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",KOR:"^(?!.*d.*p.*r)(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea(?!.*d.*p.*r)",MDA:"moldov|b(a|e)ssarabia",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"south.africa|s\\\\..?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa|^(?!.*peo)(?=.*rep).*china",TJK:"tajik",THA:"thailand|\\bsiam",MKD:"macedonia|fyrom",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",TZA:"tanzania",USA:"united.?states\\b(?!.*islands)|\\bu\\.?s\\.?a\\.?\\b|^\\s*u\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],123:[function(t,e,r){e.exports=["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller"]},{}],124:[function(t,e,r){e.exports=["normal","condensed","semi-condensed","extra-condensed","ultra-condensed","expanded","semi-expanded","extra-expanded","ultra-expanded"]},{}],125:[function(t,e,r){e.exports=["normal","italic","oblique"]},{}],126:[function(t,e,r){e.exports=["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900"]},{}],127:[function(t,e,r){"use strict";e.exports={parse:t("./parse"),stringify:t("./stringify")}},{"./parse":129,"./stringify":130}],128:[function(t,e,r){"use strict";var n=t("css-font-size-keywords");e.exports={isSize:function(t){return/^[\d\.]/.test(t)||-1!==t.indexOf("/")||-1!==n.indexOf(t)}}},{"css-font-size-keywords":123}],129:[function(t,e,r){"use strict";var n=t("unquote"),i=t("css-global-keywords"),a=t("css-system-font-keywords"),o=t("css-font-weight-keywords"),s=t("css-font-style-keywords"),l=t("css-font-stretch-keywords"),c=t("string-split-by"),u=t("./lib/util").isSize;e.exports=h;var f=h.cache={};function h(t){if("string"!=typeof t)throw new Error("Font argument must be a string.");if(f[t])return f[t];if(""===t)throw new Error("Cannot parse an empty string.");if(-1!==a.indexOf(t))return f[t]={system:t};for(var e,r={style:"normal",variant:"normal",weight:"normal",stretch:"normal",lineHeight:"normal",size:"1rem",family:["serif"]},h=c(t,/\s+/);e=h.shift();){if(-1!==i.indexOf(e))return["style","variant","weight","stretch"].forEach(function(t){r[t]=e}),f[t]=r;if(-1===s.indexOf(e))if("normal"!==e&&"small-caps"!==e)if(-1===l.indexOf(e)){if(-1===o.indexOf(e)){if(u(e)){var d=c(e,"/");if(r.size=d[0],null!=d[1]?r.lineHeight=p(d[1]):"/"===h[0]&&(h.shift(),r.lineHeight=p(h.shift())),!h.length)throw new Error("Missing required font-family.");return r.family=c(h.join(" "),/\s*,\s*/).map(n),f[t]=r}throw new Error("Unknown or unsupported font token: "+e)}r.weight=e}else r.stretch=e;else r.variant=e;else r.style=e}throw new Error("Missing required font-size.")}function p(t){var e=parseFloat(t);return e.toString()===t?e:t}},{"./lib/util":128,"css-font-stretch-keywords":124,"css-font-style-keywords":125,"css-font-weight-keywords":126,"css-global-keywords":131,"css-system-font-keywords":132,"string-split-by":505,unquote:525}],130:[function(t,e,r){"use strict";var n=t("pick-by-alias"),i=t("./lib/util").isSize,a=g(t("css-global-keywords")),o=g(t("css-system-font-keywords")),s=g(t("css-font-weight-keywords")),l=g(t("css-font-style-keywords")),c=g(t("css-font-stretch-keywords")),u={normal:1,"small-caps":1},f={serif:1,"sans-serif":1,monospace:1,cursive:1,fantasy:1,"system-ui":1},h="1rem",p="serif";function d(t,e){if(t&&!e[t]&&!a[t])throw Error("Unknown keyword `"+t+"`");return t}function g(t){for(var e={},r=0;r=0;--p)a[p]=c*t[p]+u*e[p]+f*r[p]+h*n[p];return a}return c*t+u*e+f*r+h*n},e.exports.derivative=function(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}},{}],134:[function(t,e,r){"use strict";var n=t("./lib/thunk.js");function i(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}e.exports=function(t){var e=new i;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var a=0;a0)throw new Error("cwise: pre() block may not reference array args");if(a0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(a),e.shimArgs.push("scalar"+a);else if("index"===o){if(e.indexArgs.push(a),a0)throw new Error("cwise: pre() block may not reference array index");if(a0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(a),ar.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},{"./lib/thunk.js":136}],135:[function(t,e,r){"use strict";var n=t("uniq");function i(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],c=[],u=0,f=0;for(n=0;n0&&l.push("var "+c.join(",")),n=a-1;n>=0;--n)u=t[n],l.push(["for(i",n,"=0;i",n,"0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",u,"]"].join(""))),l.push("}")}return l.join("\n")}function a(t,e,r){for(var n=t.body,i=[],a=[],o=0;o0&&y.push("shape=SS.slice(0)"),t.indexArgs.length>0){var x=new Array(r);for(l=0;l0&&m.push("var "+y.join(",")),l=0;l3&&m.push(a(t.pre,t,s));var k=a(t.body,t,s),M=function(t){for(var e=0,r=t[0].length;e0,c=[],u=0;u0;){"].join("")),c.push(["if(j",u,"<",s,"){"].join("")),c.push(["s",e[u],"=j",u].join("")),c.push(["j",u,"=0"].join("")),c.push(["}else{s",e[u],"=",s].join("")),c.push(["j",u,"-=",s,"}"].join("")),l&&c.push(["index[",e[u],"]=j",u].join(""));for(u=0;u3&&m.push(a(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+m.join("\n")+"\n----------");var A=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",M,function(t){for(var e=new Array(t.length),r=!0,n=0;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}(s)].join("");return new Function(["function ",A,"(",v.join(","),"){",m.join("\n"),"} return ",A].join(""))()}},{uniq:524}],136:[function(t,e,r){"use strict";var n=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],c=[],u=0;u0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[u]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[u])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),u=0;ue?1:t>=e?0:NaN}function r(t){var r;return 1===t.length&&(r=t,t=function(t,n){return e(r(t),n)}),{left:function(e,r,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}var n=r(e),i=n.right,a=n.left;function o(t,e){return[t,e]}function s(t){return null===t?NaN:+t}function l(t,e){var r,n,i=t.length,a=0,o=-1,l=0,c=0;if(null==e)for(;++o1)return c/(a-1)}function c(t,e){var r=l(t,e);return r?Math.sqrt(r):r}function u(t,e){var r,n,i,a=t.length,o=-1;if(null==e){for(;++o=r)for(n=i=r;++or&&(n=r),i=r)for(n=i=r;++or&&(n=r),i=0?(a>=m?10:a>=y?5:a>=x?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(a>=m?10:a>=y?5:a>=x?2:1)}function _(t,e,r){var n=Math.abs(e-t)/Math.max(0,r),i=Math.pow(10,Math.floor(Math.log(n)/Math.LN10)),a=n/i;return a>=m?i*=10:a>=y?i*=5:a>=x&&(i*=2),e=1)return+r(t[n-1],n-1,t);var n,i=(n-1)*e,a=Math.floor(i),o=+r(t[a],a,t);return o+(+r(t[a+1],a+1,t)-o)*(i-a)}}function M(t,e){var r,n,i=t.length,a=-1;if(null==e){for(;++a=r)for(n=r;++ar&&(n=r)}else for(;++a=r)for(n=r;++ar&&(n=r);return n}function A(t){if(!(i=t.length))return[];for(var e=-1,r=M(t,T),n=new Array(r);++et?1:e>=t?0:NaN},t.deviation=c,t.extent=u,t.histogram=function(){var t=g,e=u,r=w;function n(n){var a,o,s=n.length,l=new Array(s);for(a=0;af;)h.pop(),--p;var d,g=new Array(p+1);for(a=0;a<=p;++a)(d=g[a]=[]).x0=a>0?h[a-1]:u,d.x1=a=r)for(n=r;++an&&(n=r)}else for(;++a=r)for(n=r;++an&&(n=r);return n},t.mean=function(t,e){var r,n=t.length,i=n,a=-1,o=0;if(null==e)for(;++a=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r},t.min=M,t.pairs=function(t,e){null==e&&(e=o);for(var r=0,n=t.length-1,i=t[0],a=new Array(n<0?0:n);r0)return[t];if((n=e0)for(t=Math.ceil(t/o),e=Math.floor(e/o),a=new Array(i=Math.ceil(e-t+1));++s=l.length)return null!=t&&n.sort(t),null!=e?e(n):n;for(var s,c,f,h=-1,p=n.length,d=l[i++],g=r(),v=a();++hl.length)return r;var i,a=c[n-1];return null!=e&&n>=l.length?i=r.entries():(i=[],r.each(function(e,r){i.push({key:r,values:t(e,n)})})),null!=a?i.sort(function(t,e){return a(t.key,e.key)}):i}(u(t,0,a,o),0)},key:function(t){return l.push(t),s},sortKeys:function(t){return c[l.length-1]=t,s},sortValues:function(e){return t=e,s},rollup:function(t){return e=t,s}}},t.set=c,t.map=r,t.keys=function(t){var e=[];for(var r in t)e.push(r);return e},t.values=function(t){var e=[];for(var r in t)e.push(t[r]);return e},t.entries=function(t){var e=[];for(var r in t)e.push({key:r,value:t[r]});return e},Object.defineProperty(t,"__esModule",{value:!0})}("object"==typeof r&&"undefined"!=typeof e?r:n.d3=n.d3||{})},{}],142:[function(t,e,r){var n;n=this,function(t){"use strict";function e(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function r(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function n(){}var i="\\s*([+-]?\\d+)\\s*",a="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",o="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",s=/^#([0-9a-f]{3})$/,l=/^#([0-9a-f]{6})$/,c=new RegExp("^rgb\\("+[i,i,i]+"\\)$"),u=new RegExp("^rgb\\("+[o,o,o]+"\\)$"),f=new RegExp("^rgba\\("+[i,i,i,a]+"\\)$"),h=new RegExp("^rgba\\("+[o,o,o,a]+"\\)$"),p=new RegExp("^hsl\\("+[a,o,o]+"\\)$"),d=new RegExp("^hsla\\("+[a,o,o,a]+"\\)$"),g={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function v(t){var e;return t=(t+"").trim().toLowerCase(),(e=s.exec(t))?new _((e=parseInt(e[1],16))>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):(e=l.exec(t))?m(parseInt(e[1],16)):(e=c.exec(t))?new _(e[1],e[2],e[3],1):(e=u.exec(t))?new _(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=f.exec(t))?y(e[1],e[2],e[3],e[4]):(e=h.exec(t))?y(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=p.exec(t))?k(e[1],e[2]/100,e[3]/100,1):(e=d.exec(t))?k(e[1],e[2]/100,e[3]/100,e[4]):g.hasOwnProperty(t)?m(g[t]):"transparent"===t?new _(NaN,NaN,NaN,0):null}function m(t){return new _(t>>16&255,t>>8&255,255&t,1)}function y(t,e,r,n){return n<=0&&(t=e=r=NaN),new _(t,e,r,n)}function x(t){return t instanceof n||(t=v(t)),t?new _((t=t.rgb()).r,t.g,t.b,t.opacity):new _}function b(t,e,r,n){return 1===arguments.length?x(t):new _(t,e,r,null==n?1:n)}function _(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function w(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function k(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new A(t,e,r,n)}function M(t,e,r,i){return 1===arguments.length?function(t){if(t instanceof A)return new A(t.h,t.s,t.l,t.opacity);if(t instanceof n||(t=v(t)),!t)return new A;if(t instanceof A)return t;var e=(t=t.rgb()).r/255,r=t.g/255,i=t.b/255,a=Math.min(e,r,i),o=Math.max(e,r,i),s=NaN,l=o-a,c=(o+a)/2;return l?(s=e===o?(r-i)/l+6*(r0&&c<1?0:s,new A(s,l,c,t.opacity)}(t):new A(t,e,r,null==i?1:i)}function A(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function T(t,e,r){return 255*(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)}e(n,v,{displayable:function(){return this.rgb().displayable()},hex:function(){return this.rgb().hex()},toString:function(){return this.rgb()+""}}),e(_,b,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new _(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new _(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},hex:function(){return"#"+w(this.r)+w(this.g)+w(this.b)},toString:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}})),e(A,M,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new A(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new A(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new _(T(t>=240?t-240:t+120,i,n),T(t,i,n),T(t<120?t+240:t-120,i,n),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1}}));var S=Math.PI/180,E=180/Math.PI,C=.96422,L=1,z=.82521,O=4/29,I=6/29,P=3*I*I,D=I*I*I;function R(t){if(t instanceof F)return new F(t.l,t.a,t.b,t.opacity);if(t instanceof G){if(isNaN(t.h))return new F(t.l,0,0,t.opacity);var e=t.h*S;return new F(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}t instanceof _||(t=x(t));var r,n,i=U(t.r),a=U(t.g),o=U(t.b),s=N((.2225045*i+.7168786*a+.0606169*o)/L);return i===a&&a===o?r=n=s:(r=N((.4360747*i+.3850649*a+.1430804*o)/C),n=N((.0139322*i+.0971045*a+.7141733*o)/z)),new F(116*s-16,500*(r-s),200*(s-n),t.opacity)}function B(t,e,r,n){return 1===arguments.length?R(t):new F(t,e,r,null==n?1:n)}function F(t,e,r,n){this.l=+t,this.a=+e,this.b=+r,this.opacity=+n}function N(t){return t>D?Math.pow(t,1/3):t/P+O}function j(t){return t>I?t*t*t:P*(t-O)}function V(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function U(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function q(t){if(t instanceof G)return new G(t.h,t.c,t.l,t.opacity);if(t instanceof F||(t=R(t)),0===t.a&&0===t.b)return new G(NaN,0,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*E;return new G(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function H(t,e,r,n){return 1===arguments.length?q(t):new G(t,e,r,null==n?1:n)}function G(t,e,r,n){this.h=+t,this.c=+e,this.l=+r,this.opacity=+n}e(F,B,r(n,{brighter:function(t){return new F(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new F(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,r=isNaN(this.b)?t:t-this.b/200;return new _(V(3.1338561*(e=C*j(e))-1.6168667*(t=L*j(t))-.4906146*(r=z*j(r))),V(-.9787684*e+1.9161415*t+.033454*r),V(.0719453*e-.2289914*t+1.4052427*r),this.opacity)}})),e(G,H,r(n,{brighter:function(t){return new G(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new G(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return R(this).rgb()}}));var W=-.14861,Y=1.78277,X=-.29227,Z=-.90649,$=1.97294,J=$*Z,K=$*Y,Q=Y*X-Z*W;function tt(t,e,r,n){return 1===arguments.length?function(t){if(t instanceof et)return new et(t.h,t.s,t.l,t.opacity);t instanceof _||(t=x(t));var e=t.r/255,r=t.g/255,n=t.b/255,i=(Q*n+J*e-K*r)/(Q+J-K),a=n-i,o=($*(r-i)-X*a)/Z,s=Math.sqrt(o*o+a*a)/($*i*(1-i)),l=s?Math.atan2(o,a)*E-120:NaN;return new et(l<0?l+360:l,s,i,t.opacity)}(t):new et(t,e,r,null==n?1:n)}function et(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}e(et,tt,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new et(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new et(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*S,e=+this.l,r=isNaN(this.s)?0:this.s*e*(1-e),n=Math.cos(t),i=Math.sin(t);return new _(255*(e+r*(W*n+Y*i)),255*(e+r*(X*n+Z*i)),255*(e+r*($*n)),this.opacity)}})),t.color=v,t.rgb=b,t.hsl=M,t.lab=B,t.hcl=H,t.lch=function(t,e,r,n){return 1===arguments.length?q(t):new G(r,e,t,null==n?1:n)},t.gray=function(t,e){return new F(t,0,0,null==e?1:e)},t.cubehelix=tt,Object.defineProperty(t,"__esModule",{value:!0})}("object"==typeof r&&"undefined"!=typeof e?r:n.d3=n.d3||{})},{}],143:[function(t,e,r){var n;n=this,function(t){"use strict";var e={value:function(){}};function r(){for(var t,e=0,r=arguments.length,i={};e=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),l=-1,c=s.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++l0)for(var r,n,i=new Array(r),a=0;ah+c||np+c||au.index){var f=h-s.x-s.vx,v=p-s.y-s.vy,m=f*f+v*v;mt.r&&(t.r=t[e].r)}function h(){if(r){var e,i,a=r.length;for(n=new Array(a),e=0;e=c)){(t.data!==r||t.next)&&(0===f&&(d+=(f=o())*f),0===h&&(d+=(h=o())*h),d1?(null==r?u.remove(t):u.set(t,y(r)),e):u.get(t)},find:function(e,r,n){var i,a,o,s,l,c=0,u=t.length;for(null==n?n=1/0:n*=n,c=0;c1?(h.on(t,r),e):h.on(t)}}},t.forceX=function(t){var e,r,n,i=a(.1);function o(t){for(var i,a=0,o=e.length;a=1?(n=1,e-1):Math.floor(n*e),a=t[i],o=t[i+1],s=i>0?t[i-1]:2*a-o,l=i180||r<-180?r-360*Math.round(r/360):r):a(isNaN(t)?e:t)}function l(t){return 1==(t=+t)?c:function(e,r){return r-e?function(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}(e,r,t):a(isNaN(e)?r:e)}}function c(t,e){var r=e-t;return r?o(t,r):a(isNaN(t)?e:t)}var u=function t(r){var n=l(r);function i(t,r){var i=n((t=e.rgb(t)).r,(r=e.rgb(r)).r),a=n(t.g,r.g),o=n(t.b,r.b),s=c(t.opacity,r.opacity);return function(e){return t.r=i(e),t.g=a(e),t.b=o(e),t.opacity=s(e),t+""}}return i.gamma=t,i}(1);function f(t){return function(r){var n,i,a=r.length,o=new Array(a),s=new Array(a),l=new Array(a);for(n=0;na&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:v(r,n)})),a=x.lastIndex;return a180?e+=360:e-t>180&&(t+=360),a.push({i:r.push(i(r)+"rotate(",null,n)-2,x:v(t,e)})):e&&r.push(i(r)+"rotate("+e+n)}(a.rotate,o.rotate,s,l),function(t,e,r,a){t!==e?a.push({i:r.push(i(r)+"skewX(",null,n)-2,x:v(t,e)}):e&&r.push(i(r)+"skewX("+e+n)}(a.skewX,o.skewX,s,l),function(t,e,r,n,a,o){if(t!==r||e!==n){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:v(t,r)},{i:s-2,x:v(e,n)})}else 1===r&&1===n||a.push(i(a)+"scale("+r+","+n+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,l),a=o=null,function(t){for(var e,r=-1,n=l.length;++r=(a=(g+m)/2))?g=a:m=a,(u=r>=(o=(v+y)/2))?v=o:y=o,i=p,!(p=p[f=u<<1|c]))return i[f]=d,t;if(s=+t._x.call(null,p.data),l=+t._y.call(null,p.data),e===s&&r===l)return d.next=p,i?i[f]=d:t._root=d,t;do{i=i?i[f]=new Array(4):t._root=new Array(4),(c=e>=(a=(g+m)/2))?g=a:m=a,(u=r>=(o=(v+y)/2))?v=o:y=o}while((f=u<<1|c)==(h=(l>=o)<<1|s>=a));return i[h]=p,i[f]=d,t}var r=function(t,e,r,n,i){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=i};function n(t){return t[0]}function i(t){return t[1]}function a(t,e,r){var a=new o(null==e?n:e,null==r?i:r,NaN,NaN,NaN,NaN);return null==t?a:a.addAll(t)}function o(t,e,r,n,i,a){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=i,this._y1=a,this._root=void 0}function s(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var l=a.prototype=o.prototype;l.copy=function(){var t,e,r=new o(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=s(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var i=0;i<4;++i)(e=n.source[i])&&(e.length?t.push({source:e,target:n.target[i]=new Array(4)}):n.target[i]=s(e));return r},l.add=function(t){var r=+this._x.call(null,t),n=+this._y.call(null,t);return e(this.cover(r,n),r,n,t)},l.addAll=function(t){var r,n,i,a,o=t.length,s=new Array(o),l=new Array(o),c=1/0,u=1/0,f=-1/0,h=-1/0;for(n=0;nf&&(f=i),ah&&(h=a));for(ft||t>i||n>e||e>a))return this;var o,s,l=i-r,c=this._root;switch(s=(e<(n+a)/2)<<1|t<(r+i)/2){case 0:do{(o=new Array(4))[s]=c,c=o}while(a=n+(l*=2),t>(i=r+l)||e>a);break;case 1:do{(o=new Array(4))[s]=c,c=o}while(a=n+(l*=2),(r=i-l)>t||e>a);break;case 2:do{(o=new Array(4))[s]=c,c=o}while(n=a-(l*=2),t>(i=r+l)||n>e);break;case 3:do{(o=new Array(4))[s]=c,c=o}while(n=a-(l*=2),(r=i-l)>t||n>e)}this._root&&this._root.length&&(this._root=c)}return this._x0=r,this._y0=n,this._x1=i,this._y1=a,this},l.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},l.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},l.find=function(t,e,n){var i,a,o,s,l,c,u,f=this._x0,h=this._y0,p=this._x1,d=this._y1,g=[],v=this._root;for(v&&g.push(new r(v,f,h,p,d)),null==n?n=1/0:(f=t-n,h=e-n,p=t+n,d=e+n,n*=n);c=g.pop();)if(!(!(v=c.node)||(a=c.x0)>p||(o=c.y0)>d||(s=c.x1)=y)<<1|t>=m)&&(c=g[g.length-1],g[g.length-1]=g[g.length-1-u],g[g.length-1-u]=c)}else{var x=t-+this._x.call(null,v.data),b=e-+this._y.call(null,v.data),_=x*x+b*b;if(_=(s=(d+v)/2))?d=s:v=s,(u=o>=(l=(g+m)/2))?g=l:m=l,e=p,!(p=p[f=u<<1|c]))return this;if(!p.length)break;(e[f+1&3]||e[f+2&3]||e[f+3&3])&&(r=e,h=f)}for(;p.data!==t;)if(n=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,n?(i?n.next=i:delete n.next,this):e?(i?e[f]=i:delete e[f],(p=e[0]||e[1]||e[2]||e[3])&&p===(e[3]||e[2]||e[1]||e[0])&&!p.length&&(r?r[h]=p:this._root=p),this):(this._root=i,this)},l.removeAll=function(t){for(var e=0,r=t.length;e=0&&r._call.call(null,t),r=r._next;--n}function m(){l=(s=u.now())+c,n=i=0;try{v()}finally{n=0,function(){var t,n,i=e,a=1/0;for(;i;)i._call?(a>i._time&&(a=i._time),t=i,i=i._next):(n=i._next,i._next=null,i=t?t._next=n:e=n);r=t,x(a)}(),l=0}}function y(){var t=u.now(),e=t-s;e>o&&(c-=e,s=t)}function x(t){n||(i&&(i=clearTimeout(i)),t-l>24?(t<1/0&&(i=setTimeout(m,t-u.now()-c)),a&&(a=clearInterval(a))):(a||(s=u.now(),a=setInterval(y,o)),n=1,f(m)))}d.prototype=g.prototype={constructor:d,restart:function(t,n,i){if("function"!=typeof t)throw new TypeError("callback is not a function");i=(null==i?h():+i)+(null==n?0:+n),this._next||r===this||(r?r._next=this:e=this,r=this),this._call=t,this._time=i,x()},stop:function(){this._call&&(this._call=null,this._time=1/0,x())}};t.now=h,t.timer=g,t.timerFlush=v,t.timeout=function(t,e,r){var n=new d;return e=null==e?0:+e,n.restart(function(r){n.stop(),t(r+e)},e,r),n},t.interval=function(t,e,r){var n=new d,i=e;return null==e?(n.restart(t,e,r),n):(e=+e,r=null==r?h():+r,n.restart(function a(o){o+=i,n.restart(a,i+=e,r),t(o)},e,r),n)},Object.defineProperty(t,"__esModule",{value:!0})}("object"==typeof r&&"undefined"!=typeof e?r:n.d3=n.d3||{})},{}],148:[function(t,e,r){!function(){var t={version:"3.5.17"},r=[].slice,n=function(t){return r.call(t)},i=this.document;function a(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(i)try{n(i.documentElement.childNodes)[0].nodeType}catch(t){n=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),i)try{i.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var s=this.Element.prototype,l=s.setAttribute,c=s.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;s.setAttribute=function(t,e){l.call(this,t,e+"")},s.setAttributeNS=function(t,e,r){c.call(this,t,e,r+"")},u.setProperty=function(t,e,r){f.call(this,t,e+"",r)}}function h(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function d(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}t.ascending=h,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},t.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},t.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),i=n){r=i=n;break}for(;++an&&(r=n),i1)return o/(l-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(h);function m(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return h(t(e),r)}:t)},t.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,a<2&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],i=new Array(r<0?0:r);e=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r};var y=Math.abs;function x(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,i=[],a=function(t){var e=1;for(;t*e%1;)e*=10;return e}(y(r)),o=-1;if(t*=a,e*=a,(r*=a)<0)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=i.length)return r?r.call(n,a):e?a.sort(e):a;for(var l,c,u,f,h=-1,p=a.length,d=i[s++],g=new b;++h=i.length)return e;var n=[],o=a[r++];return e.forEach(function(e,i){n.push({key:e,values:t(i,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return i.push(t),n},n.sortKeys=function(t){return a[i.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new L;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(V,"\\$&")};var V=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,U={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function q(t){return U(t,Y),t}var H=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},W=function(t,e){var r=t.matches||t[I(t,"matchesSelector")];return(W=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(H=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,W=Sizzle.matchesSelector),t.selection=function(){return t.select(i.documentElement)};var Y=t.selection.prototype=[];function X(t){return"function"==typeof t?t:function(){return H(t,this)}}function Z(t){return"function"==typeof t?t:function(){return G(t,this)}}Y.select=function(t){var e,r,n,i,a=[];t=X(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),J.hasOwnProperty(r)?{space:J[r],local:t}:t}},Y.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each(K(r,e[r]));return this}return this.each(K(e,r))},Y.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,i=-1;if(e=r.classList){for(;++i=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},Y.sort=function(t){t=function(t){arguments.length||(t=h);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var l=dt.get(e);function c(){var t=this[a];t&&(this.removeEventListener(e,t,t.$),delete this[a])}return l&&(e=l,s=vt),o?r?function(){var t=s(r,n(arguments));c.call(this),this.addEventListener(e,this[a]=t,t.$=i),t._=r}:c:r?D:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var i in this)if(r=i.match(n)){var a=this[i];this.removeEventListener(r[1],a,a.$),delete this[i]}}}t.selection.enter=ft,t.selection.enter.prototype=ht,ht.append=Y.append,ht.empty=Y.empty,ht.node=Y.node,ht.call=Y.call,ht.size=Y.size,ht.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++s=n&&(n=e+1);!(o=s[n])&&++n0?1:t<0?-1:0}function Ot(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function It(t){return t>1?0:t<-1?At:Math.acos(t)}function Pt(t){return t>1?Et:t<-1?-Et:Math.asin(t)}function Dt(t){return((t=Math.exp(t))+1/t)/2}function Rt(t){return(t=Math.sin(t/2))*t}var Bt=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,f=l-a,h=u*u+f*f;if(h0&&(e=e.transition().duration(g)),e.call(w.event)}function S(){c&&c.domain(l.range().map(function(t){return(t-h.x)/h.k}).map(l.invert)),f&&f.domain(u.range().map(function(t){return(t-h.y)/h.k}).map(u.invert))}function E(t){v++||t({type:"zoomstart"})}function C(t){S(),t({type:"zoom",scale:h.k,translate:[h.x,h.y]})}function L(t){--v||(t({type:"zoomend"}),r=null)}function z(){var e=this,r=_.of(e,arguments),n=0,i=t.select(o(e)).on(y,function(){n=1,A(t.mouse(e),a),C(r)}).on(x,function(){i.on(y,null).on(x,null),s(n),L(r)}),a=k(t.mouse(e)),s=xt(e);fs.call(e),E(r)}function O(){var e,r=this,n=_.of(r,arguments),i={},a=0,o=".zoom-"+t.event.changedTouches[0].identifier,l="touchmove"+o,c="touchend"+o,u=[],f=t.select(r),p=xt(r);function d(){var n=t.touches(r);return e=h.k,n.forEach(function(t){t.identifier in i&&(i[t.identifier]=k(t))}),n}function g(){var e=t.event.target;t.select(e).on(l,v).on(c,y),u.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){m=p[0];var x=p[1],b=m[0]-x[0],_=m[1]-x[1];a=b*b+_*_}}function v(){var o,l,c,u,f=t.touches(r);fs.call(r);for(var h=0,p=f.length;h360?t-=360:t<0&&(t+=360),t<60?n+(i-n)*t/60:t<180?i:t<240?n+(i-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(i=r<=.5?r*(1+e):r+e-r*e),new ae(a(t+120),a(t),a(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Xt?e.l:(e=he((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}qt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ut(this.h,this.s,this.l/t)},qt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ut(this.h,this.s,t*this.l)},qt.rgb=function(){return Ht(this.h,this.s,this.l)},t.hcl=Gt;var Wt=Gt.prototype=new Vt;function Yt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Xt(r,Math.cos(t*=Ct)*e,Math.sin(t)*e)}function Xt(t,e,r){return this instanceof Xt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Xt?new Xt(t.l,t.a,t.b):t instanceof Gt?Yt(t.h,t.c,t.l):he((t=ae(t)).r,t.g,t.b):new Xt(t,e,r)}Wt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Zt*(arguments.length?t:1)))},Wt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Zt*(arguments.length?t:1)))},Wt.rgb=function(){return Yt(this.h,this.c,this.l).rgb()},t.lab=Xt;var Zt=18,$t=.95047,Jt=1,Kt=1.08883,Qt=Xt.prototype=new Vt;function te(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return new ae(ie(3.2404542*(i=re(i)*$t)-1.5371385*(n=re(n)*Jt)-.4985314*(a=re(a)*Kt)),ie(-.969266*i+1.8760108*n+.041556*a),ie(.0556434*i-.2040259*n+1.0572252*a))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Lt,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ie(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ae(t,e,r){return this instanceof ae?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ae?new ae(t.r,t.g,t.b):ue(""+t,ae,Ht):new ae(t,e,r)}function oe(t){return new ae(t>>16,t>>8&255,255&t)}function se(t){return oe(t)+""}Qt.brighter=function(t){return new Xt(Math.min(100,this.l+Zt*(arguments.length?t:1)),this.a,this.b)},Qt.darker=function(t){return new Xt(Math.max(0,this.l-Zt*(arguments.length?t:1)),this.a,this.b)},Qt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ae;var le=ae.prototype=new Vt;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(de(i[0]),de(i[1]),de(i[2]))}return(a=ge.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o|=o>>4,s=240&a,s|=s>>4,l=15&a,l|=l<<4):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function fe(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=l<.5?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(e0&&l<1?0:n),new Ut(n,i,l)}function he(t,e,r){var n=ne((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(r=pe(r)))/$t),i=ne((.2126729*t+.7151522*e+.072175*r)/Jt);return Xt(116*i-16,500*(n-i),200*(i-ne((.0193339*t+.119192*e+.9503041*r)/Kt)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function de(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}le.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=i.call(o,c)}catch(t){return void s.error.call(o,t)}s.load.call(o,t)}else s.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var r=t.event;t.event=e;try{s.progress.call(o,c)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return i=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),c.open(t,e,!0),null==r||"accept"in l||(l.accept=r+",*/*"),c.setRequestHeader)for(var a in l)c.setRequestHeader(a,l[a]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=u&&(c.responseType=u),null!=i&&o.on("error",i).on("load",function(t){i(null,t)}),s.beforesend.call(o,c),c.send(null==n?null:n),o},o.abort=function(){return c.abort(),o},t.rebind(o,s,"on"),null==a?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(a))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=me(z),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function i(t,r,n){arguments.length<3&&(n=r,r=null);var i=ye(t,e,null==r?a:o(r),n);return i.row=function(t){return arguments.length?i.response(null==(r=t)?a:o(t)):r},i}function a(t){return i.parse(t.responseText)}function o(t){return function(e){return i.parse(e.responseText,t)}}function s(e){return e.map(l).join(t)}function l(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,e){var r;return i.parseRows(t,function(t,n){if(r)return r(t,n-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(i(t),r)}:i})},i.parseRows=function(t,e){var r,i,a={},o={},s=[],l=t.length,c=0,u=0;function f(){if(c>=l)return o;if(i)return i=!1,a;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Ae,e)),_e=0):(_e=1,ke(Ae))}function Te(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Se(){for(var t,e=xe,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Ee(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Ce[8+n/3]};var Le=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ze=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Ee(e,r))).toFixed(Math.max(0,Math.min(20,Ee(e*(1+1e-15),r))))}});function Oe(t){return t+""}var Ie=t.time={},Pe=Date;function De(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}De.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Re.setUTCDate.apply(this._,arguments)},setDay:function(){Re.setUTCDay.apply(this._,arguments)},setFullYear:function(){Re.setUTCFullYear.apply(this._,arguments)},setHours:function(){Re.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Re.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Re.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Re.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Re.setUTCSeconds.apply(this._,arguments)},setTime:function(){Re.setTime.apply(this._,arguments)}};var Re=Date.prototype;function Be(t,e,r){function n(e){var r=t(e),n=a(r,1);return e-r1)for(;o68?1900:2e3),r+i[0].length):-1}function $e(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function Je(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function Ke(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Qe(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ir(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=y(e)/60|0,i=y(e)%60;return r+Ue(n,"0",2)+Ue(i,"0",2)}function ar(t,e,r){Ve.lastIndex=0;var n=Ve.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(r-=s,r+s)),!((l+=s+1)>e));)s=i[o=(o+1)%i.length];return a.reverse().join(n)}:z;return function(e){var n=Le.exec(e),i=n[1]||" ",s=n[2]||">",l=n[3]||"-",c=n[4]||"",u=n[5],f=+n[6],h=n[7],p=n[8],d=n[9],g=1,v="",m="",y=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===i&&"="===s)&&(u=i="0",s="="),d){case"n":h=!0,d="g";break;case"%":g=100,m="%",d="f";break;case"p":g=100,m="%",d="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+d.toLowerCase());case"c":x=!1;case"d":y=!0,p=0;break;case"s":g=-1,d="r"}"$"===c&&(v=a[0],m=a[1]),"r"!=d||p||(d="g"),null!=p&&("g"==d?p=Math.max(1,Math.min(21,p)):"e"!=d&&"f"!=d||(p=Math.max(0,Math.min(20,p)))),d=ze.get(d)||Oe;var b=u&&h;return function(e){var n=m;if(y&&e%1)return"";var a=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===l?"":l;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),n=c.symbol+m}else e*=g;var _,w,k=(e=d(e,p)).lastIndexOf(".");if(k<0){var M=x?e.lastIndexOf("e"):-1;M<0?(_=e,w=""):(_=e.substring(0,M),w=e.substring(M))}else _=e.substring(0,k),w=r+e.substring(k+1);!u&&h&&(_=o(_,1/0));var A=v.length+_.length+w.length+(b?0:a.length),T=A"===s?T+a+e:"^"===s?T.substring(0,A>>=1)+a+e+T.substring(A):a+(b?e:T+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,i=e.time,a=e.periods,o=e.days,s=e.shortDays,l=e.months,c=e.shortMonths;function u(t){var e=t.length;function r(r){for(var n,i,a,o=[],s=-1,l=0;++s=c)return-1;if(37===(i=e.charCodeAt(s++))){if(o=e.charAt(s++),!(a=w[o in Ne?e.charAt(s++):o])||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}u.utc=function(t){var e=u(t);function r(t){try{var r=new(Pe=De);return r._=t,e(r)}finally{Pe=Date}}return r.parse=function(t){try{Pe=De;var r=e.parse(t);return r&&r._}finally{Pe=Date}},r.toString=e.toString,r},u.multi=u.utc.multi=or;var h=t.map(),p=qe(o),d=He(o),g=qe(s),v=He(s),m=qe(l),y=He(l),x=qe(c),b=He(c);a.forEach(function(t,e){h.set(t.toLowerCase(),e)});var _={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:u(r),d:function(t,e){return Ue(t.getDate(),e,2)},e:function(t,e){return Ue(t.getDate(),e,2)},H:function(t,e){return Ue(t.getHours(),e,2)},I:function(t,e){return Ue(t.getHours()%12||12,e,2)},j:function(t,e){return Ue(1+Ie.dayOfYear(t),e,3)},L:function(t,e){return Ue(t.getMilliseconds(),e,3)},m:function(t,e){return Ue(t.getMonth()+1,e,2)},M:function(t,e){return Ue(t.getMinutes(),e,2)},p:function(t){return a[+(t.getHours()>=12)]},S:function(t,e){return Ue(t.getSeconds(),e,2)},U:function(t,e){return Ue(Ie.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Ue(Ie.mondayOfYear(t),e,2)},x:u(n),X:u(i),y:function(t,e){return Ue(t.getFullYear()%100,e,2)},Y:function(t,e){return Ue(t.getFullYear()%1e4,e,4)},Z:ir,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=d.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){m.lastIndex=0;var n=m.exec(e.slice(r));return n?(t.m=y.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:Ke,e:Ke,H:tr,I:tr,j:Qe,L:nr,m:Je,M:er,p:function(t,e,r){var n=h.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:We,w:Ge,W:Ye,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:Ze,Y:Xe,Z:$e,"%":ar};return u}(e)}};var sr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function lr(){}t.format=sr.numberFormat,t.geo={},lr.prototype={s:0,t:0,add:function(t){ur(t,this.t,cr),ur(cr.s,this.s,this),this.s?this.t+=cr.t:this.s=cr.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cr=new lr;function ur(t,e,r){var n=r.s=t+e,i=n-t,a=n-i;r.t=t-a+(e-i)}function fr(t,e){t&&pr.hasOwnProperty(t.type)&&pr[t.type](t,e)}t.geo.stream=function(t,e){t&&hr.hasOwnProperty(t.type)?hr[t.type](t,e):fr(t,e)};var hr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++n=0?1:-1,s=o*a,l=Math.cos(e),c=Math.sin(e),u=i*c,f=n*l+u*Math.cos(s),h=u*o*Math.sin(s);Er.add(Math.atan2(h,f)),r=t,n=l,i=c}Cr.point=function(o,s){Cr.point=a,r=(t=o)*Ct,n=Math.cos(s=(e=s)*Ct/2+At/4),i=Math.sin(s)},Cr.lineEnd=function(){a(t,e)}}function zr(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Or(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ir(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Pr(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Dr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Rr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Br(t){return[Math.atan2(t[1],t[0]),Pt(t[2])]}function Fr(t,e){return y(t[0]-e[0])kt?i=90:c<-kt&&(r=-90),f[0]=e,f[1]=n}};function p(t,a){u.push(f=[e=t,n=t]),ai&&(i=a)}function d(t,o){var s=zr([t*Ct,o*Ct]);if(l){var c=Ir(l,s),u=Ir([c[1],-c[0],0],c);Rr(u),u=Br(u);var f=t-a,h=f>0?1:-1,d=u[0]*Lt*h,g=y(f)>180;if(g^(h*ai&&(i=v);else if(g^(h*a<(d=(d+360)%360-180)&&di&&(i=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>a?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else p(t,o);l=s,a=t}function g(){h.point=d}function v(){f[0]=e,f[1]=n,h.point=p,l=null}function m(t,e){if(l){var r=t-a;c+=y(r)>180?r+(r>0?360:-360):r}else o=t,s=e;Cr.point(t,e),d(t,e)}function x(){Cr.lineStart()}function b(){m(o,s),Cr.lineEnd(),y(c)>kt&&(e=-(n=180)),f[0]=e,f[1]=n,l=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):s.push(g=p);for(var l,c,p,d=-1/0,g=(o=0,s[c=s.length-1]);o<=c;g=p,++o)p=s[o],(l=_(g[1],p[0]))>d&&(d=l,e=p[0],n=g[1])}return u=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,i]]}}(),t.geo.centroid=function(e){mr=yr=xr=br=_r=wr=kr=Mr=Ar=Tr=Sr=0,t.geo.stream(e,Nr);var r=Ar,n=Tr,i=Sr,a=r*r+n*n+i*i;return a=0;--s)i.point((f=u[s])[0],f[1]);else n(p.x,p.p.x,-1,i);p=p.p}u=(p=p.o).z,d=!d}while(!p.v);i.lineEnd()}}}function Xr(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n=0?1:-1,k=w*_,M=k>At,A=d*x;if(Er.add(Math.atan2(A*w*Math.sin(k),g*b+A*Math.cos(k))),a+=M?_+w*Tt:_,M^h>=r^m>=r){var T=Ir(zr(f),zr(t));Rr(T);var S=Ir(i,T);Rr(S);var E=(M^_>=0?-1:1)*Pt(S[2]);(n>E||n===E&&(T[0]||T[1]))&&(o+=M^_>=0?1:-1)}if(!v++)break;h=m,d=x,g=b,f=t}}return(a<-kt||a0){for(x||(o.polygonStart(),x=!0),o.lineStart();++a1&&2&e&&r.push(r.pop().concat(r.shift())),s.push(r.filter(Jr))}return u}}function Jr(t){return t.length>1}function Kr(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:D,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Qr(t,e){return((t=t.x)[0]<0?t[1]-Et-kt:Et-t[1])-((e=e.x)[0]<0?e[1]-Et-kt:Et-e[1])}var tn=$r(Wr,function(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?At:-At,l=y(a-r);y(l-At)0?Et:-Et),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=At&&(y(r-i)kt?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}(r,n,a,o),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),e=0),t.point(r=a,n=o),i=s},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var i;if(null==t)i=r*Et,n.point(-At,i),n.point(0,i),n.point(At,i),n.point(At,0),n.point(At,-i),n.point(0,-i),n.point(-At,-i),n.point(-At,0),n.point(-At,i);else if(y(t[0]-e[0])>kt){var a=t[0]0)){if(a/=h,h<0){if(a0){if(a>f)return;a>u&&(u=a)}if(a=r-l,h||!(a<0)){if(a/=h,h<0){if(a>f)return;a>u&&(u=a)}else if(h>0){if(a0)){if(a/=p,p<0){if(a0){if(a>f)return;a>u&&(u=a)}if(a=n-c,p||!(a<0)){if(a/=p,p<0){if(a>f)return;a>u&&(u=a)}else if(p>0){if(a0&&(i.a={x:l+u*h,y:c+u*p}),f<1&&(i.b={x:l+f*h,y:c+f*p}),i}}}}}}var rn=1e9;function nn(e,r,n,i){return function(l){var c,u,f,h,p,d,g,v,m,y,x,b=l,_=Kr(),w=en(e,r,n,i),k={point:T,lineStart:function(){k.point=S,u&&u.push(f=[]);y=!0,m=!1,g=v=NaN},lineEnd:function(){c&&(S(h,p),d&&m&&_.rejoin(),c.push(_.buffer()));k.point=T,m&&l.lineEnd()},polygonStart:function(){l=_,c=[],u=[],x=!0},polygonEnd:function(){l=b,c=t.merge(c);var r=function(t){for(var e=0,r=u.length,n=t[1],i=0;in&&Ot(c,a,t)>0&&++e:a[1]<=n&&Ot(c,a,t)<0&&--e,c=a;return 0!==e}([e,i]),n=x&&r,a=c.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),M(null,null,1,l),l.lineEnd()),a&&Yr(c,o,r,M,l),l.polygonEnd()),c=u=f=null}};function M(t,o,l,c){var u=0,f=0;if(null==t||(u=a(t,l))!==(f=a(o,l))||s(t,o)<0^l>0)do{c.point(0===u||3===u?e:n,u>1?i:r)}while((u=(u+l+4)%4)!==f);else c.point(o[0],o[1])}function A(t,a){return e<=t&&t<=n&&r<=a&&a<=i}function T(t,e){A(t,e)&&l.point(t,e)}function S(t,e){var r=A(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(u&&f.push([t,e]),y)h=t,p=e,d=r,y=!1,r&&(l.lineStart(),l.point(t,e));else if(r&&m)l.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(m||(l.lineStart(),l.point(n.a.x,n.a.y)),l.point(n.b.x,n.b.y),r||l.lineEnd(),x=!1):r&&(l.lineStart(),l.point(t,e),x=!1)}g=t,v=e,m=r}return k};function a(t,i){return y(t[0]-e)0?0:3:y(t[0]-n)0?2:1:y(t[1]-r)0?1:0:i>0?3:2}function o(t,e){return s(t.x,e.x)}function s(t,e){var r=a(t,1),n=a(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=At/3,n=Cn(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*At/180,r=t[1]*At/180):[e/At*180,r/At*180]},i}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,i=1+r*(2*n-r),a=Math.sqrt(i)/n;function o(t,e){var r=Math.sqrt(i-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),a-r*Math.cos(t)]}return o.invert=function(t,e){var r=a-e;return[Math.atan2(t,r)/n,Pt((i-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),(i=a(t)).valid=!0,i},extent:function(s){return arguments.length?(a=nn(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,i,a=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};function c(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}return c.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&i<.234&&n>=-.425&&n<-.214?o:i>=.166&&i<.234&&n>=-.214&&n<-.115?s:a).invert(t)},c.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},c.precision=function(t){return arguments.length?(a.precision(t),o.precision(t),s.precision(t),c):a.precision()},c.scale=function(t){return arguments.length?(a.scale(t),o.scale(.35*t),s.scale(t),c.translate(a.translate())):a.scale()},c.translate=function(t){if(!arguments.length)return a.translate();var e=a.scale(),u=+t[0],f=+t[1];return r=a.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(l).point,n=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(l).point,i=s.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(l).point,c},c.scale(1070)};var sn,ln,cn,un,fn,hn,pn={point:D,lineStart:D,lineEnd:D,polygonStart:function(){ln=0,pn.lineStart=dn},polygonEnd:function(){pn.lineStart=pn.lineEnd=pn.point=D,sn+=y(ln/2)}};function dn(){var t,e,r,n;function i(t,e){ln+=n*t-r*e,r=t,n=e}pn.point=function(a,o){pn.point=i,t=r=a,e=n=o},pn.lineEnd=function(){i(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);ehn&&(hn=e)},lineStart:D,lineEnd:D,polygonStart:D,polygonEnd:D};function vn(){var t=mn(4.5),e=[],r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=mn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function i(t,n){e.push("M",t,",",n),r.point=a}function a(t,r){e.push("L",t,",",r)}function o(){r.point=n}function s(){e.push("Z")}return r}function mn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var yn,xn={point:bn,lineStart:_n,lineEnd:wn,polygonStart:function(){xn.lineStart=kn},polygonEnd:function(){xn.point=bn,xn.lineStart=_n,xn.lineEnd=wn}};function bn(t,e){xr+=t,br+=e,++_r}function _n(){var t,e;function r(r,n){var i=r-t,a=n-e,o=Math.sqrt(i*i+a*a);wr+=o*(t+r)/2,kr+=o*(e+n)/2,Mr+=o,bn(t=r,e=n)}xn.point=function(n,i){xn.point=r,bn(t=n,e=i)}}function wn(){xn.point=bn}function kn(){var t,e,r,n;function i(t,e){var i=t-r,a=e-n,o=Math.sqrt(i*i+a*a);wr+=o*(r+t)/2,kr+=o*(n+e)/2,Mr+=o,Ar+=(o=n*t-r*e)*(r+t),Tr+=o*(n+e),Sr+=3*o,bn(r=t,n=e)}xn.point=function(a,o){xn.point=i,bn(t=r=a,e=n=o)},xn.lineEnd=function(){i(t,e)}}function Mn(t){var e=4.5,r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:D};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,Tt)}function i(e,n){t.moveTo(e,n),r.point=a}function a(e,r){t.lineTo(e,r)}function o(){r.point=n}function s(){t.closePath()}return r}function An(t){var e=.5,r=Math.cos(30*Ct),n=16;function i(e){return(n?function(e){var r,i,o,s,l,c,u,f,h,p,d,g,v={point:m,lineStart:y,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=y}};function m(r,n){r=t(r,n),e.point(r[0],r[1])}function y(){f=NaN,v.point=x,e.lineStart()}function x(r,i){var o=zr([r,i]),s=t(r,i);a(f,h,u,p,d,g,f=s[0],h=s[1],u=r,p=o[0],d=o[1],g=o[2],n,e),e.point(f,h)}function b(){v.point=m,e.lineEnd()}function _(){y(),v.point=w,v.lineEnd=k}function w(t,e){x(r=t,e),i=f,o=h,s=p,l=d,c=g,v.point=x}function k(){a(f,h,u,p,d,g,i,o,r,s,l,c,n,e),v.lineEnd=b,b()}return v}:function(e){return Sn(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function a(n,i,o,s,l,c,u,f,h,p,d,g,v,m){var x=u-n,b=f-i,_=x*x+b*b;if(_>4*e&&v--){var w=s+p,k=l+d,M=c+g,A=Math.sqrt(w*w+k*k+M*M),T=Math.asin(M/=A),S=y(y(M)-1)e||y((x*z+b*O)/_-.5)>.3||s*p+l*d+c*g0&&16,i):Math.sqrt(e)},i}function Tn(t){this.stream=t}function Sn(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function En(t){return Cn(function(){return t})()}function Cn(e){var r,n,i,a,o,s,l=An(function(t,e){return[(t=r(t,e))[0]*c+a,o-t[1]*c]}),c=150,u=480,f=250,h=0,p=0,d=0,g=0,v=0,m=tn,x=z,b=null,_=null;function w(t){return[(t=i(t[0]*Ct,t[1]*Ct))[0]*c+a,o-t[1]*c]}function k(t){return(t=i.invert((t[0]-a)/c,(o-t[1])/c))&&[t[0]*Lt,t[1]*Lt]}function M(){i=Gr(n=In(d,g,v),r);var t=r(h,p);return a=u-t[0]*c,o=f+t[1]*c,A()}function A(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Ln(m(n,l(x(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(m=null==t?(b=t,tn):function(t){var e=Math.cos(t),r=e>0,n=y(e)>kt;return $r(i,function(t){var e,s,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,h){var p,d=[f,h],g=i(f,h),v=r?g?0:o(f,h):g?o(f+(f<0?At:-At),h):0;if(!e&&(c=l=g)&&t.lineStart(),g!==l&&(p=a(e,d),(Fr(e,p)||Fr(d,p))&&(d[0]+=kt,d[1]+=kt,g=i(d[0],d[1]))),g!==l)u=0,g?(t.lineStart(),p=a(d,e),t.point(p[0],p[1])):(p=a(e,d),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(n&&e&&r^g){var m;v&s||!(m=a(d,e,!0))||(u=0,r?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||e&&Fr(e,d)||t.point(d[0],d[1]),e=d,l=g,s=v},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return u|(c&&l)<<1}}},Bn(t,6*Ct),r?[0,-t]:[-At,t-At]);function i(t,r){return Math.cos(t)*Math.cos(r)>e}function a(t,r,n){var i=[1,0,0],a=Ir(zr(t),zr(r)),o=Or(a,a),s=a[0],l=o-s*s;if(!l)return!n&&t;var c=e*o/l,u=-e*s/l,f=Ir(i,a),h=Dr(i,c);Pr(h,Dr(a,u));var p=f,d=Or(h,p),g=Or(p,p),v=d*d-g*(Or(h,h)-1);if(!(v<0)){var m=Math.sqrt(v),x=Dr(p,(-d-m)/g);if(Pr(x,h),x=Br(x),!n)return x;var b,_=t[0],w=r[0],k=t[1],M=r[1];w<_&&(b=_,_=w,w=b);var A=w-_,T=y(A-At)0^x[1]<(y(x[0]-_)At^(_<=x[0]&&x[0]<=w)){var S=Dr(p,(-d+m)/g);return Pr(S,h),[x,Br(S)]}}}function o(e,n){var i=r?t:At-t,a=0;return e<-i?a|=1:e>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}}((b=+t)*Ct),A()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):z,A()):_},w.scale=function(t){return arguments.length?(c=+t,M()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],M()):[u,f]},w.center=function(t){return arguments.length?(h=t[0]%360*Ct,p=t[1]%360*Ct,M()):[h*Lt,p*Lt]},w.rotate=function(t){return arguments.length?(d=t[0]%360*Ct,g=t[1]%360*Ct,v=t.length>2?t[2]%360*Ct:0,M()):[d*Lt,g*Lt,v*Lt]},t.rebind(w,l,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&k,M()}}function Ln(t){return Sn(t,function(e,r){t.point(e*Ct,r*Ct)})}function zn(t,e){return[t,e]}function On(t,e){return[t>At?t-Tt:t<-At?t+Tt:t,e]}function In(t,e,r){return t?e||r?Gr(Dn(t),Rn(e,r)):Dn(t):e||r?Rn(e,r):On}function Pn(t){return function(e,r){return[(e+=t)>At?e-Tt:e<-At?e+Tt:e,r]}}function Dn(t){var e=Pn(t);return e.invert=Pn(-t),e}function Rn(t,e){var r=Math.cos(t),n=Math.sin(t),i=Math.cos(e),a=Math.sin(e);function o(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,c=Math.sin(e),u=c*r+s*n;return[Math.atan2(l*i-u*a,s*r-c*n),Pt(u*i+l*a)]}return o.invert=function(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,c=Math.sin(e),u=c*i-l*a;return[Math.atan2(l*i+c*a,s*r+u*n),Pt(u*r-s*n)]},o}function Bn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=Fn(r,i),a=Fn(r,a),(o>0?ia)&&(i+=o*Tt)):(i=t+o*Tt,a=t-.5*l);for(var c,u=i;o>0?u>a:u2?t[2]*Ct:0),e.invert=function(e){return(e=t.invert(e[0]*Ct,e[1]*Ct))[0]*=Lt,e[1]*=Lt,e},e},On.invert=zn,t.geo.circle=function(){var t,e,r=[0,0],n=6;function i(){var t="function"==typeof r?r.apply(this,arguments):r,n=In(-t[0]*Ct,-t[1]*Ct,0).invert,i=[];return e(null,null,1,{point:function(t,e){i.push(t=n(t,e)),t[0]*=Lt,t[1]*=Lt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(r=t,i):r},i.angle=function(r){return arguments.length?(e=Bn((t=+r)*Ct,n*Ct),i):t},i.precision=function(r){return arguments.length?(e=Bn(t*Ct,(n=+r)*Ct),i):n},i.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Ct,i=t[1]*Ct,a=e[1]*Ct,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-l*f*s)*r),l*u+c*f*s)},t.geo.graticule=function(){var e,r,n,i,a,o,s,l,c,u,f,h,p=10,d=p,g=90,v=360,m=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(i/g)*g,n,g).map(f).concat(t.range(Math.ceil(l/v)*v,s,v).map(h)).concat(t.range(Math.ceil(r/p)*p,e,p).filter(function(t){return y(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/d)*d,a,d).filter(function(t){return y(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(i).concat(h(s).slice(1),f(n).reverse().slice(1),h(l).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(i=+t[0][0],n=+t[1][0],l=+t[0][1],s=+t[1][1],i>n&&(t=i,i=n,n=t),l>s&&(t=l,l=s,s=t),x.precision(m)):[[i,l],[n,s]]},x.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),o>a&&(t=o,o=a,a=t),x.precision(m)):[[r,o],[e,a]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],d=+t[1],x):[p,d]},x.precision=function(t){return arguments.length?(m=+t,c=Nn(o,a,90),u=jn(r,e,m),f=Nn(l,s,90),h=jn(i,n,m),x):m},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,r,n=Vn,i=Un;function a(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}return a.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},a.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,a):n},a.target=function(t){return arguments.length?(i=t,r="function"==typeof t?null:t,a):i},a.precision=function(){return arguments.length?a:0},a},t.geo.interpolate=function(t,e){return r=t[0]*Ct,n=t[1]*Ct,i=e[0]*Ct,a=e[1]*Ct,o=Math.cos(n),s=Math.sin(n),l=Math.cos(a),c=Math.sin(a),u=o*Math.cos(r),f=o*Math.sin(r),h=l*Math.cos(i),p=l*Math.sin(i),d=2*Math.asin(Math.sqrt(Rt(a-n)+o*l*Rt(i-r))),g=1/Math.sin(d),(v=d?function(t){var e=Math.sin(t*=d)*g,r=Math.sin(d-t)*g,n=r*u+e*h,i=r*f+e*p,a=r*s+e*c;return[Math.atan2(i,n)*Lt,Math.atan2(a,Math.sqrt(n*n+i*i))*Lt]}:function(){return[r*Lt,n*Lt]}).distance=d,v;var r,n,i,a,o,s,l,c,u,f,h,p,d,g,v},t.geo.length=function(e){return yn=0,t.geo.stream(e,qn),yn};var qn={sphere:D,point:D,lineStart:function(){var t,e,r;function n(n,i){var a=Math.sin(i*=Ct),o=Math.cos(i),s=y((n*=Ct)-t),l=Math.cos(s);yn+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=r*a-e*o*l)*s),e*a+r*o*l),t=n,e=a,r=o}qn.point=function(i,a){t=i*Ct,e=Math.sin(a*=Ct),r=Math.cos(a),qn.point=n},qn.lineEnd=function(){qn.point=qn.lineEnd=D}},lineEnd:D,polygonStart:D,polygonEnd:D};function Hn(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}var Gn=Hn(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return En(Gn)}).raw=Gn;var Wn=Hn(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},z);function Yn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(At/4+t/2)},i=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),a=r*Math.pow(n(t),i)/i;if(!i)return $n;function o(t,e){a>0?e<-Et+kt&&(e=-Et+kt):e>Et-kt&&(e=Et-kt);var r=a/Math.pow(n(e),i);return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}return o.invert=function(t,e){var r=a-e,n=zt(i)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/i,2*Math.atan(Math.pow(a/n,1/i))-Et]},o}function Xn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),i=r/n+t;if(y(n)1&&Ot(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function ii(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return En(Qn)}).raw=Qn,ti.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Et]},(t.geo.transverseMercator=function(){var t=Jn(ti),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ti,t.geom={},t.geom.hull=function(t){var e=ei,r=ri;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,i=ve(e),a=ve(r),o=t.length,s=[],l=[];for(n=0;n=0;--n)p.push(t[s[c[n]][2]]);for(n=+f;nkt)s=s.L;else{if(!((i=a-wi(s,o))>kt)){n>-kt?(e=s.P,r=s):i>-kt?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=mi(t);if(fi.insert(e,l),e||r){if(e===r)return Si(e),r=mi(e.site),fi.insert(l,r),l.edge=r.edge=Li(e.site,l.site),Ti(e),void Ti(r);if(r){Si(e),Si(r);var c=e.site,u=c.x,f=c.y,h=t.x-u,p=t.y-f,d=r.site,g=d.x-u,v=d.y-f,m=2*(h*v-p*g),y=h*h+p*p,x=g*g+v*v,b={x:(v*y-p*x)/m+u,y:(h*x-g*y)/m+f};zi(r.edge,c,d,b),l.edge=Li(c,t,null,b),r.edge=Li(t,d,null,b),Ti(e),Ti(r)}else l.edge=Li(e.site,l.site)}}function _i(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-1/0;var s=(r=o.site).x,l=r.y,c=l-e;if(!c)return s;var u=s-n,f=1/a-1/c,h=u/c;return f?(-h+Math.sqrt(h*h-2*f*(u*u/(-2*c)-l+c/2+i-a/2)))/f+n:(n+s)/2}function wi(t,e){var r=t.N;if(r)return _i(r,e);var n=t.site;return n.y===e?n.x:1/0}function ki(t){this.site=t,this.edges=[]}function Mi(t,e){return e.angle-t.angle}function Ai(){Pi(this),this.x=this.y=this.arc=this.site=this.cy=null}function Ti(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,i=t.site,a=r.site;if(n!==a){var o=i.x,s=i.y,l=n.x-o,c=n.y-s,u=a.x-o,f=2*(l*(v=a.y-s)-c*u);if(!(f>=-Mt)){var h=l*l+c*c,p=u*u+v*v,d=(v*h-c*p)/f,g=(l*p-u*h)/f,v=g+s,m=gi.pop()||new Ai;m.arc=t,m.site=i,m.x=d+o,m.y=v+Math.sqrt(d*d+g*g),m.cy=v,t.circle=m;for(var y=null,x=pi._;x;)if(m.y=s)return;if(h>d){if(a){if(a.y>=c)return}else a={x:v,y:l};r={x:v,y:c}}else{if(a){if(a.y1)if(h>d){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.y=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xkt||y(i-r)>kt)&&(s.splice(o,0,new Oi((m=a.site,x=u,b=y(n-f)kt?{x:f,y:y(e-f)kt?{x:y(r-d)kt?{x:h,y:y(e-h)kt?{x:y(r-p)=r&&c.x<=i&&c.y>=n&&c.y<=o?[[r,o],[i,o],[i,n],[r,n]]:[]).point=t[s]}),e}function s(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/kt)*kt,y:Math.round(i(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Fi(s(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Fi(s(t)).cells.forEach(function(r,n){for(var i,a,o,s,l=r.site,c=r.edges.sort(Mi),u=-1,f=c.length,h=c[f-1].edge,p=h.l===l?h.r:h.l;++ua&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:Gi(r,n)})),a=Xi.lastIndex;return ag&&(g=l.x),l.y>v&&(v=l.y),c.push(l.x),u.push(l.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-d;function M(t,e,r,n,i,a,o,s){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var l=t.x,c=t.y;if(null!=l)if(y(l-r)+y(c-n)<.01)A(t,e,r,n,i,a,o,s);else{var u=t.point;t.x=t.y=t.point=null,A(t,u,l,c,i,a,o,s),A(t,e,r,n,i,a,o,s)}else t.x=r,t.y=n,t.point=e}else A(t,e,r,n,i,a,o,s)}function A(t,e,r,n,i,a,o,s){var l=.5*(i+o),c=.5*(a+s),u=r>=l,f=n>=c,h=f<<1|u;t.leaf=!1,u?i=l:o=l,f?a=c:s=c,M(t=t.nodes[h]||(t.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(T,t,+m(t,++f),+x(t,f),p,d,g,v)}}),e,r,n,i,a,o,s)}w>k?v=d+w:g=p+k;var T={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(T,t,+m(t,++f),+x(t,f),p,d,g,v)}};if(T.visit=function(t){!function t(e,r,n,i,a,o){if(!e(r,n,i,a,o)){var s=.5*(n+a),l=.5*(i+o),c=r.nodes;c[0]&&t(e,c[0],n,i,s,l),c[1]&&t(e,c[1],s,i,a,l),c[2]&&t(e,c[2],n,l,s,o),c[3]&&t(e,c[3],s,l,a,o)}}(t,T,p,d,g,v)},T.find=function(t){return function(t,e,r,n,i,a,o){var s,l=1/0;return function t(c,u,f,h,p){if(!(u>a||f>o||h=_)<<1|e>=b,k=w+4;w=0&&!(n=t.interpolators[i](e,r)););return n}function $i(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function aa(t){return 1-Math.cos(t*Et)}function oa(t){return Math.pow(2,10*(t-1))}function sa(t){return 1-Math.sqrt(1-t*t)}function la(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ca(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ua(t){var e,r,n,i=[t.a,t.b],a=[t.c,t.d],o=ha(i),s=fa(i,a),l=ha(((e=a)[0]+=(n=-s)*(r=i)[0],e[1]+=n*r[1],e))||0;i[0]*a[1]=0?t.slice(0,n):t,a=n>=0?t.slice(n+1):"in";return i=Ki.get(i)||Ji,a=Qi.get(a)||z,e=a(i.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,i=e.c,a=e.l,o=r.h-n,s=r.c-i,l=r.l-a;isNaN(s)&&(s=0,i=isNaN(i)?r.c:i);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Yt(n+o*t,i+s*t,a+l*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,i=e.s,a=e.l,o=r.h-n,s=r.s-i,l=r.l-a;isNaN(s)&&(s=0,i=isNaN(i)?r.s:i);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ht(n+o*t,i+s*t,a+l*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,i=e.a,a=e.b,o=r.l-n,s=r.a-i,l=r.b-a;return function(t){return te(n+o*t,i+s*t,a+l*t)+""}},t.interpolateRound=ca,t.transform=function(e){var r=i.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ua(e?e.matrix:pa)})(e)},ua.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pa={a:1,b:0,c:0,d:1,e:0,f:0};function da(t){return t.length?t.pop()+",":""}function ga(e,r){var n=[],i=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push("translate(",null,",",null,")");n.push({i:i-4,x:Gi(t[0],e[0])},{i:i-2,x:Gi(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,i),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(da(r)+"rotate(",null,")")-2,x:Gi(t,e)})):e&&r.push(da(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,i),function(t,e,r,n){t!==e?n.push({i:r.push(da(r)+"skewX(",null,")")-2,x:Gi(t,e)}):e&&r.push(da(r)+"skewX("+e+")")}(e.skew,r.skew,n,i),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(da(r)+"scale(",null,",",null,")");n.push({i:i-4,x:Gi(t[0],e[0])},{i:i-2,x:Gi(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(da(r)+"scale("+e+")")}(e.scale,r.scale,n,i),e=r=null,function(t){for(var e,r=-1,a=i.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:n=0})):t>0&&(l.start({type:"start",alpha:n=t}),e=Me(s.tick)),s):n},s.start=function(){var t,e,r,n=m.length,l=y.length,u=c[0],d=c[1];for(t=0;t=0;)r.push(i[n])}function Ca(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++o=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;r&&(a.value=0),a.children=c}else r&&(a.value=+r.call(n,a,a.depth)||0),delete a.children;return Ca(i,function(e){var n,i;t&&(n=e.children)&&n.sort(t),r&&(i=e.parent)&&(i.value+=e.value)}),s}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Ea(t,function(t){t.children&&(t.value=0)}),Ca(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var i=e.call(this,t,n);return function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cs&&(s=n),o.push(n)}for(r=0;ri&&(n=r,i=e);return n}function qa(t){return t.reduce(Ha,0)}function Ha(t,e){return t+e[1]}function Ga(t,e){return Wa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Wa(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function Ya(e){return[t.min(e),t.max(e)]}function Xa(t,e){return t.value-e.value}function Za(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function $a(t,e){t._pack_next=e,e._pack_prev=t}function Ja(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Ka(t){if((e=t.children)&&(l=e.length)){var e,r,n,i,a,o,s,l,c=1/0,u=-1/0,f=1/0,h=-1/0;if(e.forEach(Qa),(r=e[0]).x=-r.r,r.y=0,x(r),l>1&&((n=e[1]).x=n.r,n.y=0,x(n),l>2))for(eo(r,n,i=e[2]),x(i),Za(r,i),r._pack_prev=i,Za(i,n),n=r._pack_next,a=3;a0)for(o=-1;++o=f[0]&&l<=f[1]&&((s=c[t.bisect(h,l,1,d)-1]).y+=g,s.push(a[o]));return c}return a.value=function(t){return arguments.length?(r=t,a):r},a.range=function(t){return arguments.length?(n=ve(t),a):n},a.bins=function(t){return arguments.length?(i="number"==typeof t?function(e){return Wa(e,t)}:ve(t),a):i},a.frequency=function(t){return arguments.length?(e=!!t,a):e},a},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Xa),n=0,i=[1,1];function a(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,Ca(s,function(t){t.r=+u(t.value)}),Ca(s,Ka),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;Ca(s,function(t){t.r+=f}),Ca(s,Ka),Ca(s,function(t){t.r-=f})}return function t(e,r,n,i){var a=e.children;e.x=r+=i*e.x;e.y=n+=i*e.y;e.r*=i;if(a)for(var o=-1,s=a.length;++op.x&&(p=t),t.depth>d.depth&&(d=t)});var g=r(h,p)/2-h.x,v=n[0]/(p.x+r(p,h)/2+g),m=n[1]/(d.depth||1);Ea(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*m})}return c}function o(t){var e=t.children,n=t.parent.children,i=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,i=t.children,a=i.length;for(;--a>=0;)(e=i[a]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var a=(e[0].z+e[e.length-1].z)/2;i?(t.z=i.z+r(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+r(t._,i._));t.parent.A=function(t,e,n){if(e){for(var i,a=t,o=t,s=e,l=a.parent.children[0],c=a.m,u=o.m,f=s.m,h=l.m;s=io(s),a=no(a),s&&a;)l=no(l),(o=io(o)).a=t,(i=s.z+f-a.z-c+r(s._,a._))>0&&(ao(oo(s,t,n),t,i),c+=i,u+=i),f+=s.m,c+=a.m,h+=l.m,u+=o.m;s&&!io(o)&&(o.t=s,o.m+=f-u),a&&!no(l)&&(l.t=a,l.m+=c-h,n=t)}return n}(t,i,t.parent.A||n[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function l(t){t.x*=n[0],t.y=t.depth*n[1]}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t)?l:null,a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null==(n=t)?null:l,a):i?n:null},Sa(a,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],i=!1;function a(a,o){var s,l=e.call(this,a,o),c=l[0],u=0;Ca(c,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=s?u+=r(e,s):0,e.y=0,s=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(c),h=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(c),p=f.x-r(f,h)/2,d=h.x+r(h,f)/2;return Ca(c,i?function(t){t.x=(t.x-c.x)*n[0],t.y=(c.y-t.y)*n[1]}:function(t){t.x=(t.x-p)/(d-p)*n[0],t.y=(1-(c.y?t.y/c.y:1))*n[1]}),l}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t),a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null!=(n=t),a):i?n:null},Sa(a,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,i=[1,1],a=null,o=so,s=!1,l="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var r,n,i=-1,a=t.length;++i0;)s.push(r=c[i-1]),s.area+=r.area,"squarify"!==l||(n=p(s,g))<=h?(c.pop(),h=n):(s.area-=s.pop().area,d(s,g,a,!1),g=Math.min(a.dx,a.dy),s.length=s.area=0,h=1/0);s.length&&(d(s,g,a,!0),s.length=s.area=0),e.forEach(f)}}function h(t){var e=t.children;if(e&&e.length){var r,n=o(t),i=e.slice(),a=[];for(u(i,n.dx*n.dy/t.value),a.area=0;r=i.pop();)a.push(r),a.area+=r.area,null!=r.z&&(d(a,r.z?n.dx:n.dy,n,!i.length),a.length=a.area=0);e.forEach(h)}}function p(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++oi&&(i=r));return e*=e,(n*=n)?Math.max(e*i*c/n,n/(e*a*c)):1/0}function d(t,e,r,i){var a,o=-1,s=t.length,l=r.x,c=r.y,u=e?n(t.area/e):0;if(e==r.dx){for((i||u>r.dy)&&(u=r.dy);++or.dx)&&(u=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,s=i?ma:va;return a=t(e,r,s,n),o=t(r,e,s,Zi),l}function l(t){return a(t)}l.invert=function(t){return o(t)};l.domain=function(t){return arguments.length?(e=t.map(Number),s()):e};l.range=function(t){return arguments.length?(r=t,s()):r};l.rangeRound=function(t){return l.range(t).interpolate(ca)};l.clamp=function(t){return arguments.length?(i=t,s()):i};l.interpolate=function(t){return arguments.length?(n=t,s()):n};l.ticks=function(t){return bo(e,t)};l.tickFormat=function(t,r){return _o(e,t,r)};l.nice=function(t){return yo(e,t),s()};l.copy=function(){return t(e,r,n,i)};return s()}([0,1],[0,1],Zi,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,i,a){function o(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function s(t){return i?Math.pow(n,t):-Math.pow(n,-t)}function l(t){return r(o(t))}l.invert=function(t){return s(r.invert(t))};l.domain=function(t){return arguments.length?(i=t[0]>=0,r.domain((a=t.map(Number)).map(o)),l):a};l.base=function(t){return arguments.length?(n=+t,r.domain(a.map(o)),l):n};l.nice=function(){var t=ho(a.map(o),i?Math:Ao);return r.domain(t),a=t.map(s),l};l.ticks=function(){var t=co(a),e=[],r=t[0],l=t[1],c=Math.floor(o(r)),u=Math.ceil(o(l)),f=n%1?2:n;if(isFinite(u-c)){if(i){for(;c0;h--)e.push(s(c)*h);for(c=0;e[c]l;u--);e=e.slice(c,u)}return e};l.tickFormat=function(e,r){if(!arguments.length)return Mo;arguments.length<2?r=Mo:"function"!=typeof r&&(r=t.format(r));var i=Math.max(1,n*e/l.ticks().length);return function(t){var e=t/s(Math.round(o(t)));return e*n0?i[t-1]:r[0],tf?0:1;if(c=St)return l(c,p)+(s?l(s,1-p):"")+"Z";var d,g,v,m,y,x,b,_,w,k,M,A,T=0,S=0,E=[];if((m=(+o.apply(this,arguments)||0)/2)&&(v=n===Oo?Math.sqrt(s*s+c*c):+n.apply(this,arguments),p||(S*=-1),c&&(S=Pt(v/c*Math.sin(m))),s&&(T=Pt(v/s*Math.sin(m)))),c){y=c*Math.cos(u+S),x=c*Math.sin(u+S),b=c*Math.cos(f-S),_=c*Math.sin(f-S);var C=Math.abs(f-u-2*S)<=At?0:1;if(S&&Fo(y,x,b,_)===p^C){var L=(u+f)/2;y=c*Math.cos(L),x=c*Math.sin(L),b=_=null}}else y=x=0;if(s){w=s*Math.cos(f-T),k=s*Math.sin(f-T),M=s*Math.cos(u+T),A=s*Math.sin(u+T);var z=Math.abs(u-f+2*T)<=At?0:1;if(T&&Fo(w,k,M,A)===1-p^z){var O=(u+f)/2;w=s*Math.cos(O),k=s*Math.sin(O),M=A=null}}else w=k=0;if(h>kt&&(d=Math.min(Math.abs(c-s)/2,+r.apply(this,arguments)))>.001){g=s0?0:1}function No(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,f=t[1]+c,h=e[0]+l,p=e[1]+c,d=(u+h)/2,g=(f+p)/2,v=h-u,m=p-f,y=v*v+m*m,x=r-n,b=u*p-h*f,_=(m<0?-1:1)*Math.sqrt(Math.max(0,x*x*y-b*b)),w=(b*m-v*_)/y,k=(-b*v-m*_)/y,M=(b*m+v*_)/y,A=(-b*v+m*_)/y,T=w-d,S=k-g,E=M-d,C=A-g;return T*T+S*S>E*E+C*C&&(w=M,k=A),[[w-l,k-c],[w*r/x,k*r/x]]}function jo(t){var e=ei,r=ri,n=Wr,i=Uo,a=i.key,o=.7;function s(a){var s,l=[],c=[],u=-1,f=a.length,h=ve(e),p=ve(r);function d(){l.push("M",i(t(c),o))}for(;++u1&&i.push("H",n[0]);return i.join("")},"step-before":Ho,"step-after":Go,basis:Xo,"basis-open":function(t){if(t.length<4)return Uo(t);var e,r=[],n=-1,i=t.length,a=[0],o=[0];for(;++n<3;)e=t[n],a.push(e[0]),o.push(e[1]);r.push(Zo(Ko,a)+","+Zo(Ko,o)),--n;for(;++n9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));s=-1;for(;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}(t))}});function Uo(t){return t.length>1?t.join("L"):t+"Z"}function qo(t){return t.join("L")+"Z"}function Ho(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;cAt)+",1 "+e}function l(t,e,r,n){return"Q 0,0 "+n}return a.radius=function(t){return arguments.length?(r=ve(t),a):r},a.source=function(e){return arguments.length?(t=ve(e),a):t},a.target=function(t){return arguments.length?(e=ve(t),a):e},a.startAngle=function(t){return arguments.length?(n=ve(t),a):n},a.endAngle=function(t){return arguments.length?(i=ve(t),a):i},a},t.svg.diagonal=function(){var t=Vn,e=Un,r=is;function n(n,i){var a=t.call(this,n,i),o=e.call(this,n,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(r))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=is,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-Et;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=os,e=as;function r(r,n){return(ls.get(t.call(this,r,n))||ss)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var ls=t.map({circle:ss,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*us)),r=e*us;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cs),r=e*cs/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cs),r=e*cs/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=ls.keys();var cs=Math.sqrt(3),us=Math.tan(30*Ct);Y.transition=function(t){for(var e,r,n=ds||++ms,i=bs(t),a=[],o=gs||{time:Date.now(),ease:ia,delay:0,duration:250},s=-1,l=this.length;++s0;)c[--h].call(t,o);if(a>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[n]:delete t[r],1}f||(a=i.time,o=Me(function(t){var e=f.delay;if(o.t=e+a,e<=t)return h(t-e);o.c=h},0,a),f=u[n]={tween:new b,time:a,timer:o,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++u.count)}vs.call=Y.call,vs.empty=Y.empty,vs.node=Y.node,vs.size=Y.size,t.transition=function(e,r){return e&&e.transition?ds?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vs,vs.select=function(t){var e,r,n,i=this.id,a=this.namespace,o=[];t=X(t);for(var s=-1,l=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function g(t){t.select(".extent").attr("y",l[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function v(){var f,v,m=this,y=t.select(t.event.target),x=n.of(m,arguments),b=t.select(m),_=y.datum(),w=!/^(n|s)$/.test(_)&&i,k=!/^(e|w)$/.test(_)&&a,M=y.classed("extent"),A=xt(m),T=t.mouse(m),S=t.select(o(m)).on("keydown.brush",function(){32==t.event.keyCode&&(M||(f=null,T[0]-=s[1],T[1]-=l[1],M=2),F())}).on("keyup.brush",function(){32==t.event.keyCode&&2==M&&(T[0]+=s[1],T[1]+=l[1],M=0,F())});if(t.event.changedTouches?S.on("touchmove.brush",L).on("touchend.brush",O):S.on("mousemove.brush",L).on("mouseup.brush",O),b.interrupt().selectAll("*").interrupt(),M)T[0]=s[0]-T[0],T[1]=l[0]-T[1];else if(_){var E=+/w$/.test(_),C=+/^n/.test(_);v=[s[1-E]-T[0],l[1-C]-T[1]],T[0]=s[E],T[1]=l[C]}else t.event.altKey&&(f=T.slice());function L(){var e=t.mouse(m),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),M||(t.event.altKey?(f||(f=[(s[0]+s[1])/2,(l[0]+l[1])/2]),T[0]=s[+(e[0]1?{floor:function(e){for(;s(e=t.floor(e));)e=Is(e-1);return e},ceil:function(e){for(;s(e=t.ceil(e));)e=Is(+e+1);return e}}:t))},i.ticks=function(t,e){var r=co(i.domain()),n=null==t?a(r,10):"number"==typeof t?a(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],Is(+r[1]+1),e<1?1:e)},i.tickFormat=function(){return n},i.copy=function(){return Os(e.copy(),r,n)},mo(i,e)}function Is(t){return new Date(t)}Es.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?zs:Ls,zs.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},zs.toString=Ls.toString,Ie.second=Be(function(t){return new Pe(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),Ie.seconds=Ie.second.range,Ie.seconds.utc=Ie.second.utc.range,Ie.minute=Be(function(t){return new Pe(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),Ie.minutes=Ie.minute.range,Ie.minutes.utc=Ie.minute.utc.range,Ie.hour=Be(function(t){var e=t.getTimezoneOffset()/60;return new Pe(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),Ie.hours=Ie.hour.range,Ie.hours.utc=Ie.hour.utc.range,Ie.month=Be(function(t){return(t=Ie.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),Ie.months=Ie.month.range,Ie.months.utc=Ie.month.utc.range;var Ps=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ds=[[Ie.second,1],[Ie.second,5],[Ie.second,15],[Ie.second,30],[Ie.minute,1],[Ie.minute,5],[Ie.minute,15],[Ie.minute,30],[Ie.hour,1],[Ie.hour,3],[Ie.hour,6],[Ie.hour,12],[Ie.day,1],[Ie.day,2],[Ie.week,1],[Ie.month,1],[Ie.month,3],[Ie.year,1]],Rs=Es.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Wr]]),Bs={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(Is)},floor:z,ceil:z};Ds.year=Ie.year,Ie.scale=function(){return Os(t.scale.linear(),Ds,Rs)};var Fs=Ds.map(function(t){return[t[0].utc,t[1]]}),Ns=Cs.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Wr]]);function js(t){return JSON.parse(t.responseText)}function Vs(t){var e=i.createRange();return e.selectNode(i.body),e.createContextualFragment(t.responseText)}Fs.year=Ie.year.utc,Ie.scale.utc=function(){return Os(t.scale.linear(),Fs,Ns)},t.text=me(function(t){return t.responseText}),t.json=function(t,e){return ye(t,"application/json",js,e)},t.html=function(t,e){return ye(t,"text/html",Vs,e)},t.xml=me(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],149:[function(t,e,r){e.exports=function(){for(var t=0;t=2)return!1;t[r]=n}return!0}):_.filter(function(t){for(var e=0;e<=s;++e){var r=m[t[e]];if(r<0)return!1;t[e]=r}return!0});if(1&s)for(var u=0;u<_.length;++u){var b=_[u],h=b[0];b[0]=b[1],b[1]=h}return _}},{"incremental-convex-hull":396,uniq:524}],151:[function(t,e,r){"use strict";e.exports=a;var n=(a.canvas=document.createElement("canvas")).getContext("2d"),i=o([32,126]);function a(t,e){Array.isArray(t)&&(t=t.join(", "));var r,a={},s=16,l=.05;e&&(2===e.length&&"number"==typeof e[0]?r=o(e):Array.isArray(e)?r=e:(e.o?r=o(e.o):e.pairs&&(r=e.pairs),e.fontSize&&(s=e.fontSize),null!=e.threshold&&(l=e.threshold))),r||(r=i),n.font=s+"px "+t;for(var c=0;cs*l){var p=(h-f)/s;a[u]=1e3*p}}return a}function o(t){for(var e=[],r=t[0];r<=t[1];r++)for(var n=String.fromCharCode(r),i=t[0];i>>31},e.exports.exponent=function(t){return(e.exports.hi(t)<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){return!(2146435072&e.exports.hi(t))}}).call(this,t("buffer").Buffer)},{buffer:93}],153:[function(t,e,r){var n=t("abs-svg-path"),i=t("normalize-svg-path"),a={M:"moveTo",C:"bezierCurveTo"};e.exports=function(t,e){t.beginPath(),i(n(e)).forEach(function(e){var r=e[0],n=e.slice(1);t[a[r]].apply(t,n)}),t.closePath()}},{"abs-svg-path":48,"normalize-svg-path":435}],154:[function(t,e,r){e.exports=function(t){switch(t){case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"uint8":return Uint8Array;case"uint16":return Uint16Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;case"array":return Array;case"uint8_clamped":return Uint8ClampedArray}}},{}],155:[function(t,e,r){"use strict";e.exports=function(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return function(t,e){var r,n;for(r=new Array(t),n=0;n80*r){n=l=t[0],s=c=t[1];for(var b=r;bl&&(l=u),p>c&&(c=p);g=0!==(g=Math.max(l-n,c-s))?1/g:0}return o(y,x,r,n,s,g),x}function i(t,e,r,n,i){var a,o;if(i===A(t,e,r,n)>0)for(a=e;a=e;a-=n)o=w(a,t[a],t[a+1],o);return o&&y(o,o.next)&&(k(o),o=o.next),o}function a(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!y(n,n.next)&&0!==m(n.prev,n,n.next))n=n.next;else{if(k(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function o(t,e,r,n,i,f,h){if(t){!h&&f&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=p(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,o,s,l,c=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,c*=2}while(o>1)}(i)}(t,n,i,f);for(var d,g,v=t;t.prev!==t.next;)if(d=t.prev,g=t.next,f?l(t,n,i,f):s(t))e.push(d.i/r),e.push(t.i/r),e.push(g.i/r),k(t),t=g.next,v=g.next;else if((t=g)===v){h?1===h?o(t=c(t,e,r),e,r,n,i,f,2):2===h&&u(t,e,r,n,i,f):o(a(t),e,r,n,i,f,1);break}}}function s(t){var e=t.prev,r=t,n=t.next;if(m(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(g(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&m(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function l(t,e,r,n){var i=t.prev,a=t,o=t.next;if(m(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,f=p(s,l,e,r,n),h=p(c,u,e,r,n),d=t.prevZ,v=t.nextZ;d&&d.z>=f&&v&&v.z<=h;){if(d!==t.prev&&d!==t.next&&g(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&m(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,v!==t.prev&&v!==t.next&&g(i.x,i.y,a.x,a.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;d&&d.z>=f;){if(d!==t.prev&&d!==t.next&&g(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&m(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;v&&v.z<=h;){if(v!==t.prev&&v!==t.next&&g(i.x,i.y,a.x,a.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function c(t,e,r){var n=t;do{var i=n.prev,a=n.next.next;!y(i,a)&&x(i,n,n.next,a)&&b(i,a)&&b(a,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(a.i/r),k(n),k(n.next),n=t=a),n=n.next}while(n!==t);return n}function u(t,e,r,n,i,s){var l=t;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&v(l,c)){var u=_(l,c);return l=a(l,l.next),u=a(u,u.next),o(l,e,r,n,i,s),void o(u,e,r,n,i,s)}c=c.next}l=l.next}while(l!==t)}function f(t,e){return t.x-e.x}function h(t,e){if(e=function(t,e){var r,n=e,i=t.x,a=t.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=u&&i!==n.x&&g(ar.x)&&b(n,t)&&(r=n,h=l),n=n.next;return r}(t,e)){var r=_(e,t);a(r,r.next)}}function p(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function d(t){var e=t,r=t;do{e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&x(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&b(t,e)&&b(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)}function m(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function y(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,r,n){return!!(y(t,e)&&y(r,n)||y(t,n)&&y(r,e))||m(t,e,r)>0!=m(t,e,n)>0&&m(r,n,t)>0!=m(r,n,e)>0}function b(t,e){return m(t.prev,t,t.next)<0?m(t,e,t.next)>=0&&m(t,t.prev,e)>=0:m(t,e,t.prev)<0||m(t,t.next,e)<0}function _(t,e){var r=new M(t.i,t.x,t.y),n=new M(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function w(t,e,r,n){var i=new M(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function k(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function M(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function A(t,e,r,n){for(var i=0,a=e,o=r-n;a0&&(n+=t[i-1].length,r.holes.push(n))}return r}},{}],157:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if("number"!=typeof e){e=0;for(var i=0;i=55296&&y<=56319&&(w+=t[++r]),w=k?h.call(k,M,w,g):w,e?(p.value=w,d(v,g,p)):v[g]=w,++g;m=g}if(void 0===m)for(m=o(t.length),e&&(v=new e(m)),r=0;r0?1:-1}},{}],168:[function(t,e,r){"use strict";var n=t("../math/sign"),i=Math.abs,a=Math.floor;e.exports=function(t){return isNaN(t)?0:0!==(t=Number(t))&&isFinite(t)?n(t)*a(i(t)):t}},{"../math/sign":165}],169:[function(t,e,r){"use strict";var n=t("./to-integer"),i=Math.max;e.exports=function(t){return i(0,n(t))}},{"./to-integer":168}],170:[function(t,e,r){"use strict";var n=t("./valid-callable"),i=t("./valid-value"),a=Function.prototype.bind,o=Function.prototype.call,s=Object.keys,l=Object.prototype.propertyIsEnumerable;e.exports=function(t,e){return function(r,c){var u,f=arguments[2],h=arguments[3];return r=Object(i(r)),n(c),u=s(r),h&&u.sort("function"==typeof h?a.call(h,r):void 0),"function"!=typeof t&&(t=u[t]),o.call(t,u,function(t,n){return l.call(r,t)?o.call(c,f,r[t],t,r,n):e})}}},{"./valid-callable":188,"./valid-value":190}],171:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Object.assign:t("./shim")},{"./is-implemented":172,"./shim":173}],172:[function(t,e,r){"use strict";e.exports=function(){var t,e=Object.assign;return"function"==typeof e&&(e(t={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},{}],173:[function(t,e,r){"use strict";var n=t("../keys"),i=t("../valid-value"),a=Math.max;e.exports=function(t,e){var r,o,s,l=a(arguments.length,2);for(t=Object(i(t)),s=function(n){try{t[n]=e[n]}catch(t){r||(r=t)}},o=1;o-1}},{}],194:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return"string"==typeof t||t&&"object"==typeof t&&(t instanceof String||n.call(t)===i)||!1}},{}],195:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],196:[function(t,e,r){"use strict";var n,i=t("es5-ext/object/set-prototype-of"),a=t("es5-ext/string/#/contains"),o=t("d"),s=t("es6-symbol"),l=t("./"),c=Object.defineProperty;n=e.exports=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");l.call(this,t),e=e?a.call(e,"key+value")?"key+value":a.call(e,"key")?"key":"value":"value",c(this,"__kind__",o("",e))},i&&i(n,l),delete n.prototype.constructor,n.prototype=Object.create(l.prototype,{_resolve:o(function(t){return"value"===this.__kind__?this.__list__[t]:"key+value"===this.__kind__?[t,this.__list__[t]]:t})}),c(n.prototype,s.toStringTag,o("c","Array Iterator"))},{"./":199,d:139,"es5-ext/object/set-prototype-of":185,"es5-ext/string/#/contains":191,"es6-symbol":204}],197:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),i=t("es5-ext/object/valid-callable"),a=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,l=Function.prototype.call,c=Array.prototype.some;e.exports=function(t,e){var r,u,f,h,p,d,g,v,m=arguments[2];if(s(t)||n(t)?r="array":a(t)?r="string":t=o(t),i(e),f=function(){h=!0},"array"!==r)if("string"!==r)for(u=t.next();!u.done;){if(l.call(e,m,u.value,f),h)return;u=t.next()}else for(d=t.length,p=0;p=55296&&v<=56319&&(g+=t[++p]),l.call(e,m,g,f),!h);++p);else c.call(t,function(t){return l.call(e,m,t,f),h})}},{"./get":198,"es5-ext/function/is-arguments":162,"es5-ext/object/valid-callable":188,"es5-ext/string/is-string":194}],198:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),i=t("es5-ext/string/is-string"),a=t("./array"),o=t("./string"),s=t("./valid-iterable"),l=t("es6-symbol").iterator;e.exports=function(t){return"function"==typeof s(t)[l]?t[l]():n(t)?new a(t):i(t)?new o(t):new a(t)}},{"./array":196,"./string":201,"./valid-iterable":202,"es5-ext/function/is-arguments":162,"es5-ext/string/is-string":194,"es6-symbol":204}],199:[function(t,e,r){"use strict";var n,i=t("es5-ext/array/#/clear"),a=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),l=t("d"),c=t("d/auto-bind"),u=t("es6-symbol"),f=Object.defineProperty,h=Object.defineProperties;e.exports=n=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");h(this,{__list__:l("w",s(t)),__context__:l("w",e),__nextIndex__:l("w",0)}),e&&(o(e.on),e.on("_add",this._onAdd),e.on("_delete",this._onDelete),e.on("_clear",this._onClear))},delete n.prototype.constructor,h(n.prototype,a({_next:l(function(){var t;if(this.__list__)return this.__redo__&&void 0!==(t=this.__redo__.shift())?t:this.__nextIndex__=this.__nextIndex__||(++this.__nextIndex__,this.__redo__?(this.__redo__.forEach(function(e,r){e>=t&&(this.__redo__[r]=++e)},this),this.__redo__.push(t)):f(this,"__redo__",l("c",[t])))}),_onDelete:l(function(t){var e;t>=this.__nextIndex__||(--this.__nextIndex__,this.__redo__&&(-1!==(e=this.__redo__.indexOf(t))&&this.__redo__.splice(e,1),this.__redo__.forEach(function(e,r){e>t&&(this.__redo__[r]=--e)},this)))}),_onClear:l(function(){this.__redo__&&i.call(this.__redo__),this.__nextIndex__=0})}))),f(n.prototype,u.iterator,l(function(){return this}))},{d:139,"d/auto-bind":138,"es5-ext/array/#/clear":158,"es5-ext/object/assign":171,"es5-ext/object/valid-callable":188,"es5-ext/object/valid-value":190,"es6-symbol":204}],200:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),i=t("es5-ext/object/is-value"),a=t("es5-ext/string/is-string"),o=t("es6-symbol").iterator,s=Array.isArray;e.exports=function(t){return!!i(t)&&(!!s(t)||(!!a(t)||(!!n(t)||"function"==typeof t[o])))}},{"es5-ext/function/is-arguments":162,"es5-ext/object/is-value":179,"es5-ext/string/is-string":194,"es6-symbol":204}],201:[function(t,e,r){"use strict";var n,i=t("es5-ext/object/set-prototype-of"),a=t("d"),o=t("es6-symbol"),s=t("./"),l=Object.defineProperty;n=e.exports=function(t){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");t=String(t),s.call(this,t),l(this,"__length__",a("",t.length))},i&&i(n,s),delete n.prototype.constructor,n.prototype=Object.create(s.prototype,{_next:a(function(){if(this.__list__)return this.__nextIndex__=55296&&e<=56319?r+this.__list__[this.__nextIndex__++]:r})}),l(n.prototype,o.toStringTag,a("c","String Iterator"))},{"./":199,d:139,"es5-ext/object/set-prototype-of":185,"es6-symbol":204}],202:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":200}],203:[function(t,e,r){(function(n,i){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},a=0,o=void 0,s=void 0,l=function(t,e){g[a]=t,g[a+1]=e,2===(a+=2)&&(s?s(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,h="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t=r-1){h=l.length-1;var d=t-e[r-1];for(p=0;p=r-1)for(var u=s.length-1,f=(e[r-1],0);f=0;--r)if(t[--e])return!1;return!0},s.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(t0;--f)n.push(a(l[f-1],c[f-1],arguments[f])),i.push(0)}},s.push=function(t){var e=this.lastT(),r=this.dimension;if(!(t1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var p=a(c[h-1],u[h-1],arguments[h]);n.push(p),i.push((p-n[o++])*f)}}},s.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(a(o[l-1],s[l-1],arguments[l])),n.push(0)}},s.move=function(t){var e=this.lastT(),r=this.dimension;if(!(t<=e||arguments.length!==r+1)){var n=this._state,i=this._velocity,o=n.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,f=u>1e-6?1/u:0;this._time.push(t);for(var h=r;h>0;--h){var p=arguments[h];n.push(a(l[h-1],c[h-1],n[o++]+p)),i.push(p*f)}}},s.idle=function(t){var e=this.lastT();if(!(t=0;--f)n.push(a(l[f],c[f],n[o]+u*i[o])),i.push(0),o+=1}}},{"binary-search-bounds":79,"cubic-hermite":133}],216:[function(t,e,r){var n=t("dtype");e.exports=function(t,e,r){if(!t)throw new TypeError("must specify data as first parameter");if(r=0|+(r||0),Array.isArray(t)&&t[0]&&"number"==typeof t[0][0]){var i,a,o,s,l=t[0].length,c=t.length*l;e&&"string"!=typeof e||(e=new(n(e||"float32"))(c+r));var u=e.length-r;if(c!==u)throw new Error("source length "+c+" ("+l+"x"+t.length+") does not match destination length "+u);for(i=0,o=r;ie[0]-o[0]/2&&(h=o[0]/2,p+=o[1]);return r}},{"css-font/stringify":130}],218:[function(t,e,r){"use strict";function n(t,e){e||(e={}),("string"==typeof t||Array.isArray(t))&&(e.family=t);var r=Array.isArray(e.family)?e.family.join(", "):e.family;if(!r)throw Error("`family` must be defined");var s=e.size||e.fontSize||e.em||48,l=e.weight||e.fontWeight||"",c=(t=[e.style||e.fontStyle||"",l,s].join(" ")+"px "+r,e.origin||"top");if(n.cache[r]&&s<=n.cache[r].em)return i(n.cache[r],c);var u=e.canvas||n.canvas,f=u.getContext("2d"),h={upper:void 0!==e.upper?e.upper:"H",lower:void 0!==e.lower?e.lower:"x",descent:void 0!==e.descent?e.descent:"p",ascent:void 0!==e.ascent?e.ascent:"h",tittle:void 0!==e.tittle?e.tittle:"i",overshoot:void 0!==e.overshoot?e.overshoot:"O"},p=Math.ceil(1.5*s);u.height=p,u.width=.5*p,f.font=t;var d={top:0};f.clearRect(0,0,p,p),f.textBaseline="top",f.fillStyle="black",f.fillText("H",0,0);var g=a(f.getImageData(0,0,p,p));f.clearRect(0,0,p,p),f.textBaseline="bottom",f.fillText("H",0,p);var v=a(f.getImageData(0,0,p,p));d.lineHeight=d.bottom=p-v+g,f.clearRect(0,0,p,p),f.textBaseline="alphabetic",f.fillText("H",0,p);var m=p-a(f.getImageData(0,0,p,p))-1+g;d.baseline=d.alphabetic=m,f.clearRect(0,0,p,p),f.textBaseline="middle",f.fillText("H",0,.5*p);var y=a(f.getImageData(0,0,p,p));d.median=d.middle=p-y-1+g-.5*p,f.clearRect(0,0,p,p),f.textBaseline="hanging",f.fillText("H",0,.5*p);var x=a(f.getImageData(0,0,p,p));d.hanging=p-x-1+g-.5*p,f.clearRect(0,0,p,p),f.textBaseline="ideographic",f.fillText("H",0,p);var b=a(f.getImageData(0,0,p,p));if(d.ideographic=p-b-1+g,h.upper&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.upper,0,0),d.upper=a(f.getImageData(0,0,p,p)),d.capHeight=d.baseline-d.upper),h.lower&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.lower,0,0),d.lower=a(f.getImageData(0,0,p,p)),d.xHeight=d.baseline-d.lower),h.tittle&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.tittle,0,0),d.tittle=a(f.getImageData(0,0,p,p))),h.ascent&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.ascent,0,0),d.ascent=a(f.getImageData(0,0,p,p))),h.descent&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.descent,0,0),d.descent=o(f.getImageData(0,0,p,p))),h.overshoot){f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.overshoot,0,0);var _=o(f.getImageData(0,0,p,p));d.overshoot=_-m}for(var w in d)d[w]/=s;return d.em=s,n.cache[r]=d,i(d,c)}function i(t,e){var r={};for(var n in"string"==typeof e&&(e=t[e]),t)"em"!==n&&(r[n]=t[n]-e);return r}function a(t){for(var e=t.height,r=t.data,n=3;n0;n-=4)if(0!==r[n])return Math.floor(.25*(n-3)/e)}e.exports=n,n.canvas=document.createElement("canvas"),n.cache={}},{}],219:[function(t,e,r){"use strict";e.exports=function(t){return new c(t||d,null)};var n=0,i=1;function a(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function o(t){return new a(t._color,t.key,t.value,t.left,t.right,t._count)}function s(t,e){return new a(t,e.key,e.value,e.left,e.right,e._count)}function l(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function c(t,e){this._compare=t,this.root=e}var u=c.prototype;function f(t,e){this.tree=t,this._stack=e}Object.defineProperty(u,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(u,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(u,"length",{get:function(){return this.root?this.root._count:0}}),u.insert=function(t,e){for(var r=this._compare,o=this.root,u=[],f=[];o;){var h=r(t,o.key);u.push(o),f.push(h),o=h<=0?o.left:o.right}u.push(new a(n,t,e,null,null,1));for(var p=u.length-2;p>=0;--p){o=u[p];f[p]<=0?u[p]=new a(o._color,o.key,o.value,u[p+1],o.right,o._count+1):u[p]=new a(o._color,o.key,o.value,o.left,u[p+1],o._count+1)}for(p=u.length-1;p>1;--p){var d=u[p-1];o=u[p];if(d._color===i||o._color===i)break;var g=u[p-2];if(g.left===d)if(d.left===o){if(!(v=g.right)||v._color!==n){if(g._color=n,g.left=d.right,d._color=i,d.right=g,u[p-2]=d,u[p-1]=o,l(g),l(d),p>=3)(m=u[p-3]).left===g?m.left=d:m.right=d;break}d._color=i,g.right=s(i,v),g._color=n,p-=1}else{if(!(v=g.right)||v._color!==n){if(d.right=o.left,g._color=n,g.left=o.right,o._color=i,o.left=d,o.right=g,u[p-2]=o,u[p-1]=d,l(g),l(d),l(o),p>=3)(m=u[p-3]).left===g?m.left=o:m.right=o;break}d._color=i,g.right=s(i,v),g._color=n,p-=1}else if(d.right===o){if(!(v=g.left)||v._color!==n){if(g._color=n,g.right=d.left,d._color=i,d.left=g,u[p-2]=d,u[p-1]=o,l(g),l(d),p>=3)(m=u[p-3]).right===g?m.right=d:m.left=d;break}d._color=i,g.left=s(i,v),g._color=n,p-=1}else{var v;if(!(v=g.left)||v._color!==n){var m;if(d.left=o.right,g._color=n,g.right=o.left,o._color=i,o.right=d,o.left=g,u[p-2]=o,u[p-1]=d,l(g),l(d),l(o),p>=3)(m=u[p-3]).right===g?m.right=o:m.left=o;break}d._color=i,g.left=s(i,v),g._color=n,p-=1}}return u[0]._color=i,new c(r,u[0])},u.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return function t(e,r){var n;if(r.left&&(n=t(e,r.left)))return n;return(n=e(r.key,r.value))||(r.right?t(e,r.right):void 0)}(t,this.root);case 2:return function t(e,r,n,i){if(r(e,i.key)<=0){var a;if(i.left&&(a=t(e,r,n,i.left)))return a;if(a=n(i.key,i.value))return a}if(i.right)return t(e,r,n,i.right)}(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return function t(e,r,n,i,a){var o,s=n(e,a.key),l=n(r,a.key);if(s<=0){if(a.left&&(o=t(e,r,n,i,a.left)))return o;if(l>0&&(o=i(a.key,a.value)))return o}if(l>0&&a.right)return t(e,r,n,i,a.right)}(e,r,this._compare,t,this.root)}},Object.defineProperty(u,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(u,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),u.at=function(t){if(t<0)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},u.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<=0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},u.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},u.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},u.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},u.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=i<=0?r.left:r.right}return new f(this,[])},u.remove=function(t){var e=this.find(t);return e?e.remove():this},u.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=n<=0?r.left:r.right}};var h=f.prototype;function p(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t,e){return te?1:0}Object.defineProperty(h,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(h,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),h.clone=function(){return new f(this.tree,this._stack.slice())},h.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new a(r._color,r.key,r.value,r.left,r.right,r._count);for(var u=t.length-2;u>=0;--u){(r=t[u]).left===t[u+1]?e[u]=new a(r._color,r.key,r.value,e[u+1],r.right,r._count):e[u]=new a(r._color,r.key,r.value,r.left,e[u+1],r._count)}if((r=e[e.length-1]).left&&r.right){var f=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var h=e[f-1];e.push(new a(r._color,h.key,h.value,r.left,r.right,r._count)),e[f-1].key=r.key,e[f-1].value=r.value;for(u=e.length-2;u>=f;--u)r=e[u],e[u]=new a(r._color,r.key,r.value,r.left,e[u+1],r._count);e[f-1].left=e[f]}if((r=e[e.length-1])._color===n){var d=e[e.length-2];d.left===r?d.left=null:d.right===r&&(d.right=null),e.pop();for(u=0;u=0;--u){if(e=t[u],0===u)return void(e._color=i);if((r=t[u-1]).left===e){if((a=r.right).right&&a.right._color===n)return c=(a=r.right=o(a)).right=o(a.right),r.right=a.left,a.left=r,a.right=c,a._color=r._color,e._color=i,r._color=i,c._color=i,l(r),l(a),u>1&&((f=t[u-2]).left===r?f.left=a:f.right=a),void(t[u-1]=a);if(a.left&&a.left._color===n)return c=(a=r.right=o(a)).left=o(a.left),r.right=c.left,a.left=c.right,c.left=r,c.right=a,c._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(c),u>1&&((f=t[u-2]).left===r?f.left=c:f.right=c),void(t[u-1]=c);if(a._color===i){if(r._color===n)return r._color=i,void(r.right=s(n,a));r.right=s(n,a);continue}a=o(a),r.right=a.left,a.left=r,a._color=r._color,r._color=n,l(r),l(a),u>1&&((f=t[u-2]).left===r?f.left=a:f.right=a),t[u-1]=a,t[u]=r,u+11&&((f=t[u-2]).right===r?f.right=a:f.left=a),void(t[u-1]=a);if(a.right&&a.right._color===n)return c=(a=r.left=o(a)).right=o(a.right),r.left=c.right,a.right=c.left,c.right=r,c.left=a,c._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(c),u>1&&((f=t[u-2]).right===r?f.right=c:f.left=c),void(t[u-1]=c);if(a._color===i){if(r._color===n)return r._color=i,void(r.left=s(n,a));r.left=s(n,a);continue}var f;a=o(a),r.left=a.right,a.right=r,a._color=r._color,r._color=n,l(r),l(a),u>1&&((f=t[u-2]).right===r?f.right=a:f.left=a),t[u-1]=a,t[u]=r,u+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(h,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(h,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),h.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),h.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),n=e[e.length-1];r[r.length-1]=new a(n._color,n.key,t,n.left,n.right,n._count);for(var i=e.length-2;i>=0;--i)(n=e[i]).left===e[i+1]?r[i]=new a(n._color,n.key,n.value,r[i+1],n.right,n._count):r[i]=new a(n._color,n.key,n.value,n.left,r[i+1],n._count);return new c(this.tree._compare,r[0])},h.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],220:[function(t,e,r){var n=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],i=607/128,a=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function o(t){if(t<0)return Number("0/0");for(var e=a[0],r=a.length-1;r>0;--r)e+=a[r]/(t+r);var n=t+i+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}e.exports=function t(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*t(1-e));if(e>100)return Math.exp(o(e));e-=1;for(var r=n[0],i=1;i<9;i++)r+=n[i]/(e+i);var a=e+7+.5;return Math.sqrt(2*Math.PI)*Math.pow(a,e+.5)*Math.exp(-a)*r},e.exports.log=o},{}],221:[function(t,e,r){e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("must specify type string");if(e=e||{},"undefined"==typeof document&&!e.canvas)return null;var r=e.canvas||document.createElement("canvas");"number"==typeof e.width&&(r.width=e.width);"number"==typeof e.height&&(r.height=e.height);var n,i=e;try{var a=[t];0===t.indexOf("webgl")&&a.push("experimental-"+t);for(var o=0;o0?(p[u]=-1,d[u]=0):(p[u]=0,d[u]=1)}}var g=[0,0,0],v={model:l,view:l,projection:l};f.isOpaque=function(){return!0},f.isTransparent=function(){return!1},f.drawTransparent=function(t){};var m=[0,0,0],y=[0,0,0],x=[0,0,0];f.draw=function(t){t=t||v;for(var e=this.gl,r=t.model||l,n=t.view||l,i=t.projection||l,a=this.bounds,s=o(r,n,i,a),u=s.cubeEdges,f=s.axis,h=n[12],b=n[13],_=n[14],w=n[15],k=this.pixelRatio*(i[3]*h+i[7]*b+i[11]*_+i[15]*w)/e.drawingBufferHeight,M=0;M<3;++M)this.lastCubeProps.cubeEdges[M]=u[M],this.lastCubeProps.axis[M]=f[M];var A=p;for(M=0;M<3;++M)d(p[M],M,this.bounds,u,f);e=this.gl;var T,S=g;for(M=0;M<3;++M)this.backgroundEnable[M]?S[M]=f[M]:S[M]=0;this._background.draw(r,n,i,a,S,this.backgroundColor),this._lines.bind(r,n,i,this);for(M=0;M<3;++M){var E=[0,0,0];f[M]>0?E[M]=a[1][M]:E[M]=a[0][M];for(var C=0;C<2;++C){var L=(M+1+C)%3,z=(M+1+(1^C))%3;this.gridEnable[L]&&this._lines.drawGrid(L,z,this.bounds,E,this.gridColor[L],this.gridWidth[L]*this.pixelRatio)}for(C=0;C<2;++C){L=(M+1+C)%3,z=(M+1+(1^C))%3;this.zeroEnable[z]&&Math.min(a[0][z],a[1][z])<=0&&Math.max(a[0][z],a[1][z])>=0&&this._lines.drawZero(L,z,this.bounds,E,this.zeroLineColor[z],this.zeroLineWidth[z]*this.pixelRatio)}}for(M=0;M<3;++M){this.lineEnable[M]&&this._lines.drawAxisLine(M,this.bounds,A[M].primalOffset,this.lineColor[M],this.lineWidth[M]*this.pixelRatio),this.lineMirror[M]&&this._lines.drawAxisLine(M,this.bounds,A[M].mirrorOffset,this.lineColor[M],this.lineWidth[M]*this.pixelRatio);var O=c(m,A[M].primalMinor),I=c(y,A[M].mirrorMinor),P=this.lineTickLength;for(C=0;C<3;++C){var D=k/r[5*C];O[C]*=P[C]*D,I[C]*=P[C]*D}this.lineTickEnable[M]&&this._lines.drawAxisTicks(M,A[M].primalOffset,O,this.lineTickColor[M],this.lineTickWidth[M]*this.pixelRatio),this.lineTickMirror[M]&&this._lines.drawAxisTicks(M,A[M].mirrorOffset,I,this.lineTickColor[M],this.lineTickWidth[M]*this.pixelRatio)}this._lines.unbind(),this._text.bind(r,n,i,this.pixelRatio);var R,B;function F(t){(B=[0,0,0])[t]=1}function N(t,e,r){var n=(t+1)%3,i=(t+2)%3,a=e[n],o=e[i],s=r[n],l=r[i];a>0&&l>0?F(n):a>0&&l<0?F(n):a<0&&l>0?F(n):a<0&&l<0?F(n):o>0&&s>0?F(i):o>0&&s<0?F(i):o<0&&s>0?F(i):o<0&&s<0&&F(i)}for(M=0;M<3;++M){var j=A[M].primalMinor,V=A[M].mirrorMinor,U=c(x,A[M].primalOffset);for(C=0;C<3;++C)this.lineTickEnable[M]&&(U[C]+=k*j[C]*Math.max(this.lineTickLength[C],0)/r[5*C]);var q=[0,0,0];if(q[M]=1,this.tickEnable[M]){-3600===this.tickAngle[M]?(this.tickAngle[M]=0,this._tickAlign[M]="auto"):this._tickAlign[M]=-1,R=1,"auto"===(T=[this._tickAlign[M],.5,R])[0]?T[0]=0:T[0]=parseInt(""+T[0]),B=[0,0,0],N(M,j,V);for(C=0;C<3;++C)U[C]+=k*j[C]*this.tickPad[C]/r[5*C];this._text.drawTicks(M,this.tickSize[M],this.tickAngle[M],U,this.tickColor[M],q,B,T)}if(this.labelEnable[M]){R=0,B=[0,0,0],this.labels[M].length>4&&(F(M),R=1),"auto"===(T=[this._labelAlign[M],.5,R])[0]?T[0]=0:T[0]=parseInt(""+T[0]);for(C=0;C<3;++C)U[C]+=k*j[C]*this.labelPad[C]/r[5*C];U[M]+=.5*(a[0][M]+a[1][M]),this._text.drawLabel(M,this.labelSize[M],this._labelAngle[M],U,this.labelColor[M],[0,0,0],B,T)}}this._text.unbind()},f.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":223,"./lib/cube.js":224,"./lib/lines.js":225,"./lib/text.js":227,"./lib/ticks.js":228}],223:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=[],s=0,l=0;l<3;++l)for(var c=(l+1)%3,u=(l+2)%3,f=[0,0,0],h=[0,0,0],p=-1;p<=1;p+=2){r.push(s,s+2,s+1,s+1,s+2,s+3),f[l]=p,h[l]=p;for(var d=-1;d<=1;d+=2){f[c]=d;for(var g=-1;g<=1;g+=2)f[u]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),s+=1}var v=c;c=u,u=v}var m=n(t,new Float32Array(e)),y=n(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),x=i(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),b=a(t);return b.attributes.position.location=0,b.attributes.normal.location=1,new o(t,m,x,b)};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders").bg;function o(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}var s=o.prototype;s.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;s<3;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),this.vao.unbind(),l.disable(l.POLYGON_OFFSET_FILL)}},s.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":226,"gl-buffer":230,"gl-vao":310}],224:[function(t,e,r){"use strict";e.exports=function(t,e,r,a){i(s,e,t),i(s,r,s);for(var p=0,y=0;y<2;++y){u[2]=a[y][2];for(var x=0;x<2;++x){u[1]=a[x][1];for(var b=0;b<2;++b)u[0]=a[b][0],h(l[p],u,s),p+=1}}for(var _=-1,y=0;y<8;++y){for(var w=l[y][3],k=0;k<3;++k)c[y][k]=l[y][k]/w;w<0&&(_<0?_=y:c[y][2]S&&(_|=1<S&&(_|=1<c[y][1]&&(D=y));for(var R=-1,y=0;y<3;++y){var B=D^1<c[F][0]&&(F=B)}}var N=g;N[0]=N[1]=N[2]=0,N[n.log2(R^D)]=D&R,N[n.log2(D^F)]=D&F;var j=7^F;j===_||j===P?(j=7^R,N[n.log2(F^j)]=j&F):N[n.log2(R^j)]=j&R;for(var V=v,U=_,M=0;M<3;++M)V[M]=U&1< HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]),l=n(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]);r.text=function(t){return i(t,s,l,null,[{name:"position",type:"vec3"}])};var c=n(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]),u=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]);r.bg=function(t){return i(t,c,u,null,[{name:"position",type:"vec3"},{name:"normal",type:"vec3"}])}},{"gl-shader":288,glslify:392}],227:[function(t,e,r){(function(r){"use strict";e.exports=function(t,e,r,a,s,l){var u=n(t),f=i(t,[{buffer:u,size:3}]),h=o(t);h.attributes.position.location=0;var p=new c(t,h,u,f);return p.update(e,r,a,s,l),p};var n=t("gl-buffer"),i=t("gl-vao"),a=t("vectorize-text"),o=t("./shaders").text,s=window||r.global||{},l=s.__TEXT_CACHE||{};s.__TEXT_CACHE={};function c(t,e,r,n){this.gl=t,this.shader=e,this.buffer=r,this.vao=n,this.tickOffset=this.tickCount=this.labelOffset=this.labelCount=null}var u=c.prototype,f=[0,0];u.bind=function(t,e,r,n){this.vao.bind(),this.shader.bind();var i=this.shader.uniforms;i.model=t,i.view=e,i.projection=r,i.pixelScale=n,f[0]=this.gl.drawingBufferWidth,f[1]=this.gl.drawingBufferHeight,this.shader.uniforms.resolution=f},u.unbind=function(){this.vao.unbind()},u.update=function(t,e,r,n,i){this.gl;var o=[];function s(t,e,r,n){var i=l[r];i||(i=l[r]={});var s=i[e];s||(s=i[e]=function(t,e){try{return a(t,e)}catch(t){return console.warn("error vectorizing text:",t),{cells:[],positions:[]}}}(e,{triangles:!0,font:r,textAlign:"center",textBaseline:"middle"}));for(var c=(n||12)/12,u=s.positions,f=s.cells,h=0,p=f.length;h=0;--g){var v=u[d[g]];o.push(c*v[0],-c*v[1],t)}}for(var c=[0,0,0],u=[0,0,0],f=[0,0,0],h=[0,0,0],p=0;p<3;++p){f[p]=o.length/3|0,s(.5*(t[0][p]+t[1][p]),e[p],r),h[p]=(o.length/3|0)-f[p],c[p]=o.length/3|0;for(var d=0;d=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,c=o%a;o<0?(l=0|-Math.ceil(l),c=0|-c):(l=0|Math.floor(l),c|=0);var u=""+l;if(o<0&&(u="-"+u),i){for(var f=""+c;f.length=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r},r.equal=function(t,e){for(var r=0;r<3;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;nr)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function u(t,e){for(var r=n.malloc(t.length,e),i=t.length,a=0;a=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=c(this.gl,this.type,this.length,this.usage,t.data,e):this.length=c(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=n.malloc(t.size,r),l=a(s,t.shape);i.assign(l,t),this.length=c(this.gl,this.type,this.length,this.usage,e<0?s:s.subarray(0,t.size),e),n.free(s)}}else if(Array.isArray(t)){var f;f=this.type===this.gl.ELEMENT_ARRAY_BUFFER?u(t,"uint16"):u(t,"float32"),this.length=c(this.gl,this.type,this.length,this.usage,e<0?f:f.subarray(0,t.length),e),n.free(f)}else if("object"==typeof t&&"number"==typeof t.length)this.length=c(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");(t|=0)<=0&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=function(t,e,r,n){if(r=r||t.ARRAY_BUFFER,n=n||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(n!==t.DYNAMIC_DRAW&&n!==t.STATIC_DRAW&&n!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var i=t.createBuffer(),a=new s(t,r,i,0,n);return a.update(e),a}},{ndarray:433,"ndarray-ops":427,"typedarray-pool":522}],231:[function(t,e,r){"use strict";var n=t("gl-vec3"),i=(t("gl-vec4"),function(t,e){for(var r=0;r=e)return r-1;return r}),a=n.create(),o=n.create(),s=function(t,e,r){return tr?r:t},l=function(t,e,r,l){var c=t[0],u=t[1],f=t[2],h=r[0].length,p=r[1].length,d=r[2].length,g=i(r[0],c),v=i(r[1],u),m=i(r[2],f),y=g+1,x=v+1,b=m+1;if(l&&(g=s(g,0,h-1),y=s(y,0,h-1),v=s(v,0,p-1),x=s(x,0,p-1),m=s(m,0,d-1),b=s(b,0,d-1)),g<0||v<0||m<0||y>=h||x>=p||b>=d)return n.create();var _=(c-r[0][g])/(r[0][y]-r[0][g]),w=(u-r[1][v])/(r[1][x]-r[1][v]),k=(f-r[2][m])/(r[2][b]-r[2][m]);(_<0||_>1||isNaN(_))&&(_=0),(w<0||w>1||isNaN(w))&&(w=0),(k<0||k>1||isNaN(k))&&(k=0);var M=m*h*p,A=b*h*p,T=v*h,S=x*h,E=g,C=y,L=e[T+M+E],z=e[T+M+C],O=e[S+M+E],I=e[S+M+C],P=e[T+A+E],D=e[T+A+C],R=e[S+A+E],B=e[S+A+C],F=n.create();return n.lerp(F,L,z,_),n.lerp(a,O,I,_),n.lerp(F,F,a,w),n.lerp(a,P,D,_),n.lerp(o,R,B,_),n.lerp(a,a,o,w),n.lerp(F,F,a,k),F};e.exports=function(t,e){var r;r=t.positions?t.positions:function(t){for(var e=t[0],r=t[1],n=t[2],i=[],a=0;as&&(s=n.length(b)),x&&(y=Math.min(y,2*n.distance(g,_)/(n.length(v)+n.length(b)))),g=_,v=b,m.push(b)}var w=[c,f,p],k=[u,h,d];e&&(e[0]=w,e[1]=k),0===s&&(s=1);var M=1/s;isFinite(y)&&!isNaN(y)||(y=1),o.vectorScale=y;var A=function(t,e,r){var i=n.create();return void 0!==t&&n.set(i,t,e,r),i}(0,1,0),T=t.coneSize||.5;t.absoluteConeSize&&(T=t.absoluteConeSize*M),o.coneScale=T;x=0;for(var S=0;x1.0001)return null;v+=g[u]}if(Math.abs(v-1)>.001)return null;return[f,function(t,e){for(var r=[0,0,0],n=0;n=1},x.isTransparent=function(){return this.opacity<1},x.pickSlots=1,x.setPickBase=function(t){this.pickId=t},x.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=p.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},x.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||m,n=t.view||m,i=t.projection||m,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,vectorScale:this.vectorScale,coneScale:this.coneScale,coneOffset:this.coneOffset,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},x.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions[r[1]].slice(0,3);return{index:Math.floor(r[1]/48),position:n,dataCoordinate:n}},x.dispose=function(){this.texture.dispose(),this.triShader.dispose(),this.pickShader.dispose(),this.triangleVAO.dispose(),this.trianglePositions.dispose(),this.triangleVectors.dispose(),this.triangleColors.dispose(),this.triangleUVs.dispose(),this.triangleNormals.dispose(),this.triangleIds.dispose(),this.edgeVAO.dispose(),this.edgePositions.dispose(),this.edgeColors.dispose(),this.edgeUVs.dispose(),this.edgeIds.dispose(),this.pointVAO.dispose(),this.pointPositions.dispose(),this.pointColors.dispose(),this.pointUVs.dispose(),this.pointSizes.dispose(),this.pointIds.dispose(),this.contourVAO.dispose(),this.contourPositions.dispose()},e.exports=function(t,e){1===arguments.length&&(t=(e=t).gl);var r=e.triShader||function(t){var e=n(t,g.vertex,g.fragment,null,g.attributes);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.vector.location=5,e}(t),s=b(t),l=o(t,u(new Uint8Array([255,255,255,255]),[1,1,4]));l.generateMipmap(),l.minFilter=t.LINEAR_MIPMAP_LINEAR,l.magFilter=t.LINEAR;var c=i(t),f=i(t),h=i(t),p=i(t),d=i(t),v=i(t),m=a(t,[{buffer:c,type:t.FLOAT,size:4},{buffer:v,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:h,type:t.FLOAT,size:4},{buffer:p,type:t.FLOAT,size:2},{buffer:d,type:t.FLOAT,size:3},{buffer:f,type:t.FLOAT,size:3}]),x=i(t),_=i(t),w=i(t),k=i(t),M=a(t,[{buffer:x,type:t.FLOAT,size:3},{buffer:k,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:_,type:t.FLOAT,size:4},{buffer:w,type:t.FLOAT,size:2}]),A=i(t),T=i(t),S=i(t),E=i(t),C=i(t),L=a(t,[{buffer:A,type:t.FLOAT,size:3},{buffer:C,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:T,type:t.FLOAT,size:4},{buffer:S,type:t.FLOAT,size:2},{buffer:E,type:t.FLOAT,size:1}]),z=i(t),O=new y(t,l,r,null,null,s,null,null,c,f,v,h,p,d,m,x,k,_,w,M,A,C,T,S,E,L,z,a(t,[{buffer:z,type:t.FLOAT,size:3}]));return O.update(e),O}},{"./closest-point":232,"./shaders":234,colormap:114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,ndarray:433,normals:436,"simplicial-complex-contour":494,"typedarray-pool":522}],234:[function(t,e,r){var n=t("glslify"),i=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec3"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec3"}]}},{glslify:392}],235:[function(t,e,r){e.exports={0:"NONE",1:"ONE",2:"LINE_LOOP",3:"LINE_STRIP",4:"TRIANGLES",5:"TRIANGLE_STRIP",6:"TRIANGLE_FAN",256:"DEPTH_BUFFER_BIT",512:"NEVER",513:"LESS",514:"EQUAL",515:"LEQUAL",516:"GREATER",517:"NOTEQUAL",518:"GEQUAL",519:"ALWAYS",768:"SRC_COLOR",769:"ONE_MINUS_SRC_COLOR",770:"SRC_ALPHA",771:"ONE_MINUS_SRC_ALPHA",772:"DST_ALPHA",773:"ONE_MINUS_DST_ALPHA",774:"DST_COLOR",775:"ONE_MINUS_DST_COLOR",776:"SRC_ALPHA_SATURATE",1024:"STENCIL_BUFFER_BIT",1028:"FRONT",1029:"BACK",1032:"FRONT_AND_BACK",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",2304:"CW",2305:"CCW",2849:"LINE_WIDTH",2884:"CULL_FACE",2885:"CULL_FACE_MODE",2886:"FRONT_FACE",2928:"DEPTH_RANGE",2929:"DEPTH_TEST",2930:"DEPTH_WRITEMASK",2931:"DEPTH_CLEAR_VALUE",2932:"DEPTH_FUNC",2960:"STENCIL_TEST",2961:"STENCIL_CLEAR_VALUE",2962:"STENCIL_FUNC",2963:"STENCIL_VALUE_MASK",2964:"STENCIL_FAIL",2965:"STENCIL_PASS_DEPTH_FAIL",2966:"STENCIL_PASS_DEPTH_PASS",2967:"STENCIL_REF",2968:"STENCIL_WRITEMASK",2978:"VIEWPORT",3024:"DITHER",3042:"BLEND",3088:"SCISSOR_BOX",3089:"SCISSOR_TEST",3106:"COLOR_CLEAR_VALUE",3107:"COLOR_WRITEMASK",3317:"UNPACK_ALIGNMENT",3333:"PACK_ALIGNMENT",3379:"MAX_TEXTURE_SIZE",3386:"MAX_VIEWPORT_DIMS",3408:"SUBPIXEL_BITS",3410:"RED_BITS",3411:"GREEN_BITS",3412:"BLUE_BITS",3413:"ALPHA_BITS",3414:"DEPTH_BITS",3415:"STENCIL_BITS",3553:"TEXTURE_2D",4352:"DONT_CARE",4353:"FASTEST",4354:"NICEST",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT",5386:"INVERT",5890:"TEXTURE",6401:"STENCIL_INDEX",6402:"DEPTH_COMPONENT",6406:"ALPHA",6407:"RGB",6408:"RGBA",6409:"LUMINANCE",6410:"LUMINANCE_ALPHA",7680:"KEEP",7681:"REPLACE",7682:"INCR",7683:"DECR",7936:"VENDOR",7937:"RENDERER",7938:"VERSION",9728:"NEAREST",9729:"LINEAR",9984:"NEAREST_MIPMAP_NEAREST",9985:"LINEAR_MIPMAP_NEAREST",9986:"NEAREST_MIPMAP_LINEAR",9987:"LINEAR_MIPMAP_LINEAR",10240:"TEXTURE_MAG_FILTER",10241:"TEXTURE_MIN_FILTER",10242:"TEXTURE_WRAP_S",10243:"TEXTURE_WRAP_T",10497:"REPEAT",10752:"POLYGON_OFFSET_UNITS",16384:"COLOR_BUFFER_BIT",32769:"CONSTANT_COLOR",32770:"ONE_MINUS_CONSTANT_COLOR",32771:"CONSTANT_ALPHA",32772:"ONE_MINUS_CONSTANT_ALPHA",32773:"BLEND_COLOR",32774:"FUNC_ADD",32777:"BLEND_EQUATION_RGB",32778:"FUNC_SUBTRACT",32779:"FUNC_REVERSE_SUBTRACT",32819:"UNSIGNED_SHORT_4_4_4_4",32820:"UNSIGNED_SHORT_5_5_5_1",32823:"POLYGON_OFFSET_FILL",32824:"POLYGON_OFFSET_FACTOR",32854:"RGBA4",32855:"RGB5_A1",32873:"TEXTURE_BINDING_2D",32926:"SAMPLE_ALPHA_TO_COVERAGE",32928:"SAMPLE_COVERAGE",32936:"SAMPLE_BUFFERS",32937:"SAMPLES",32938:"SAMPLE_COVERAGE_VALUE",32939:"SAMPLE_COVERAGE_INVERT",32968:"BLEND_DST_RGB",32969:"BLEND_SRC_RGB",32970:"BLEND_DST_ALPHA",32971:"BLEND_SRC_ALPHA",33071:"CLAMP_TO_EDGE",33170:"GENERATE_MIPMAP_HINT",33189:"DEPTH_COMPONENT16",33306:"DEPTH_STENCIL_ATTACHMENT",33635:"UNSIGNED_SHORT_5_6_5",33648:"MIRRORED_REPEAT",33901:"ALIASED_POINT_SIZE_RANGE",33902:"ALIASED_LINE_WIDTH_RANGE",33984:"TEXTURE0",33985:"TEXTURE1",33986:"TEXTURE2",33987:"TEXTURE3",33988:"TEXTURE4",33989:"TEXTURE5",33990:"TEXTURE6",33991:"TEXTURE7",33992:"TEXTURE8",33993:"TEXTURE9",33994:"TEXTURE10",33995:"TEXTURE11",33996:"TEXTURE12",33997:"TEXTURE13",33998:"TEXTURE14",33999:"TEXTURE15",34000:"TEXTURE16",34001:"TEXTURE17",34002:"TEXTURE18",34003:"TEXTURE19",34004:"TEXTURE20",34005:"TEXTURE21",34006:"TEXTURE22",34007:"TEXTURE23",34008:"TEXTURE24",34009:"TEXTURE25",34010:"TEXTURE26",34011:"TEXTURE27",34012:"TEXTURE28",34013:"TEXTURE29",34014:"TEXTURE30",34015:"TEXTURE31",34016:"ACTIVE_TEXTURE",34024:"MAX_RENDERBUFFER_SIZE",34041:"DEPTH_STENCIL",34055:"INCR_WRAP",34056:"DECR_WRAP",34067:"TEXTURE_CUBE_MAP",34068:"TEXTURE_BINDING_CUBE_MAP",34069:"TEXTURE_CUBE_MAP_POSITIVE_X",34070:"TEXTURE_CUBE_MAP_NEGATIVE_X",34071:"TEXTURE_CUBE_MAP_POSITIVE_Y",34072:"TEXTURE_CUBE_MAP_NEGATIVE_Y",34073:"TEXTURE_CUBE_MAP_POSITIVE_Z",34074:"TEXTURE_CUBE_MAP_NEGATIVE_Z",34076:"MAX_CUBE_MAP_TEXTURE_SIZE",34338:"VERTEX_ATTRIB_ARRAY_ENABLED",34339:"VERTEX_ATTRIB_ARRAY_SIZE",34340:"VERTEX_ATTRIB_ARRAY_STRIDE",34341:"VERTEX_ATTRIB_ARRAY_TYPE",34342:"CURRENT_VERTEX_ATTRIB",34373:"VERTEX_ATTRIB_ARRAY_POINTER",34466:"NUM_COMPRESSED_TEXTURE_FORMATS",34467:"COMPRESSED_TEXTURE_FORMATS",34660:"BUFFER_SIZE",34661:"BUFFER_USAGE",34816:"STENCIL_BACK_FUNC",34817:"STENCIL_BACK_FAIL",34818:"STENCIL_BACK_PASS_DEPTH_FAIL",34819:"STENCIL_BACK_PASS_DEPTH_PASS",34877:"BLEND_EQUATION_ALPHA",34921:"MAX_VERTEX_ATTRIBS",34922:"VERTEX_ATTRIB_ARRAY_NORMALIZED",34930:"MAX_TEXTURE_IMAGE_UNITS",34962:"ARRAY_BUFFER",34963:"ELEMENT_ARRAY_BUFFER",34964:"ARRAY_BUFFER_BINDING",34965:"ELEMENT_ARRAY_BUFFER_BINDING",34975:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",35040:"STREAM_DRAW",35044:"STATIC_DRAW",35048:"DYNAMIC_DRAW",35632:"FRAGMENT_SHADER",35633:"VERTEX_SHADER",35660:"MAX_VERTEX_TEXTURE_IMAGE_UNITS",35661:"MAX_COMBINED_TEXTURE_IMAGE_UNITS",35663:"SHADER_TYPE",35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",35712:"DELETE_STATUS",35713:"COMPILE_STATUS",35714:"LINK_STATUS",35715:"VALIDATE_STATUS",35716:"INFO_LOG_LENGTH",35717:"ATTACHED_SHADERS",35718:"ACTIVE_UNIFORMS",35719:"ACTIVE_UNIFORM_MAX_LENGTH",35720:"SHADER_SOURCE_LENGTH",35721:"ACTIVE_ATTRIBUTES",35722:"ACTIVE_ATTRIBUTE_MAX_LENGTH",35724:"SHADING_LANGUAGE_VERSION",35725:"CURRENT_PROGRAM",36003:"STENCIL_BACK_REF",36004:"STENCIL_BACK_VALUE_MASK",36005:"STENCIL_BACK_WRITEMASK",36006:"FRAMEBUFFER_BINDING",36007:"RENDERBUFFER_BINDING",36048:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36049:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36050:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36051:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36053:"FRAMEBUFFER_COMPLETE",36054:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36055:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36057:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36061:"FRAMEBUFFER_UNSUPPORTED",36064:"COLOR_ATTACHMENT0",36096:"DEPTH_ATTACHMENT",36128:"STENCIL_ATTACHMENT",36160:"FRAMEBUFFER",36161:"RENDERBUFFER",36162:"RENDERBUFFER_WIDTH",36163:"RENDERBUFFER_HEIGHT",36164:"RENDERBUFFER_INTERNAL_FORMAT",36168:"STENCIL_INDEX8",36176:"RENDERBUFFER_RED_SIZE",36177:"RENDERBUFFER_GREEN_SIZE",36178:"RENDERBUFFER_BLUE_SIZE",36179:"RENDERBUFFER_ALPHA_SIZE",36180:"RENDERBUFFER_DEPTH_SIZE",36181:"RENDERBUFFER_STENCIL_SIZE",36194:"RGB565",36336:"LOW_FLOAT",36337:"MEDIUM_FLOAT",36338:"HIGH_FLOAT",36339:"LOW_INT",36340:"MEDIUM_INT",36341:"HIGH_INT",36346:"SHADER_COMPILER",36347:"MAX_VERTEX_UNIFORM_VECTORS",36348:"MAX_VARYING_VECTORS",36349:"MAX_FRAGMENT_UNIFORM_VECTORS",37440:"UNPACK_FLIP_Y_WEBGL",37441:"UNPACK_PREMULTIPLY_ALPHA_WEBGL",37442:"CONTEXT_LOST_WEBGL",37443:"UNPACK_COLORSPACE_CONVERSION_WEBGL",37444:"BROWSER_DEFAULT_WEBGL"}},{}],236:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":235}],237:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=n(e),o=i(e,[{buffer:r,type:e.FLOAT,size:3,offset:0,stride:40},{buffer:r,type:e.FLOAT,size:4,offset:12,stride:40},{buffer:r,type:e.FLOAT,size:3,offset:28,stride:40}]),l=a(e);l.attributes.position.location=0,l.attributes.color.location=1,l.attributes.offset.location=2;var c=new s(e,r,o,l);return c.update(t),c};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders/index"),o=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function s(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}var l=s.prototype;function c(t,e){for(var r=0;r<3;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}l.isOpaque=function(){return this.opacity>=1},l.isTransparent=function(){return this.opacity<1},l.drawTransparent=l.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||o,i=r.projection=t.projection||o;r.model=t.model||o,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],s=n[13],l=n[14],c=n[15],u=this.pixelRatio*(i[3]*a+i[7]*s+i[11]*l+i[15]*c)/e.drawingBufferHeight;this.vao.bind();for(var f=0;f<3;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*u,this.lineCount[f]&&e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var u=function(){for(var t=new Array(3),e=0;e<3;++e){for(var r=[],n=1;n<=2;++n)for(var i=-1;i<=1;i+=2){var a=[0,0,0];a[(n+e)%3]=i,r.push(a)}t[e]=r}return t}();function f(t,e,r,n){for(var i=u[n],a=0;a0)(g=u.slice())[s]+=p[1][s],i.push(u[0],u[1],u[2],d[0],d[1],d[2],d[3],0,0,0,g[0],g[1],g[2],d[0],d[1],d[2],d[3],0,0,0),c(this.bounds,g),o+=2+f(i,g,d,s)}}this.lineCount[s]=o-this.lineOffset[s]}this.buffer.update(i)}},l.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":238,"gl-buffer":230,"gl-vao":310}],238:[function(t,e,r){"use strict";var n=t("glslify"),i=t("gl-shader"),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]);e.exports=function(t){return i(t,a,o,null,[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"offset",type:"vec3"}])}},{"gl-shader":288,glslify:392}],239:[function(t,e,r){"use strict";var n=t("gl-texture2d");e.exports=function(t,e,r,n){i||(i=t.FRAMEBUFFER_UNSUPPORTED,a=t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT,o=t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS,s=t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);var c=t.getExtension("WEBGL_draw_buffers");!l&&c&&function(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);l=new Array(r+1);for(var n=0;n<=r;++n){for(var i=new Array(r),a=0;au||r<0||r>u)throw new Error("gl-fbo: Parameters are too large for FBO");var f=1;if("color"in(n=n||{})){if((f=Math.max(0|n.color,0))<0)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(f>1){if(!c)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(f>t.getParameter(c.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+f+" draw buffers")}}var h=t.UNSIGNED_BYTE,p=t.getExtension("OES_texture_float");if(n.float&&f>0){if(!p)throw new Error("gl-fbo: Context does not support floating point textures");h=t.FLOAT}else n.preferFloat&&f>0&&p&&(h=t.FLOAT);var g=!0;"depth"in n&&(g=!!n.depth);var v=!1;"stencil"in n&&(v=!!n.stencil);return new d(t,e,r,h,f,g,v,c)};var i,a,o,s,l=null;function c(t){return[t.getParameter(t.FRAMEBUFFER_BINDING),t.getParameter(t.RENDERBUFFER_BINDING),t.getParameter(t.TEXTURE_BINDING_2D)]}function u(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function f(t){switch(t){case i:throw new Error("gl-fbo: Framebuffer unsupported");case a:throw new Error("gl-fbo: Framebuffer incomplete attachment");case o:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case s:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function h(t,e,r,i,a,o){if(!i)return null;var s=n(t,e,r,a,i);return s.magFilter=t.NEAREST,s.minFilter=t.NEAREST,s.mipSamples=1,s.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_2D,s.handle,0),s}function p(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function d(t,e,r,n,i,a,o,s){this.gl=t,this._shape=[0|e,0|r],this._destroyed=!1,this._ext=s,this.color=new Array(i);for(var d=0;d1&&s.drawBuffersWEBGL(l[o]);var y=r.getExtension("WEBGL_depth_texture");y?d?t.depth=h(r,i,a,y.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g&&(t.depth=h(r,i,a,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):g&&d?t._depth_rb=p(r,i,a,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g?t._depth_rb=p(r,i,a,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=p(r,i,a,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var x=r.checkFramebufferStatus(r.FRAMEBUFFER);if(x!==r.FRAMEBUFFER_COMPLETE){for(t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null),m=0;mi||r<0||r>i)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var a=c(n),o=0;o>8*p&255;this.pickOffset=r,i.bind();var d=i.uniforms;d.viewTransform=t,d.pickOffset=e,d.shape=this.shape;var g=i.attributes;return this.positionBuffer.bind(),g.position.pointer(),this.weightBuffer.bind(),g.weight.pointer(s.UNSIGNED_BYTE,!1),this.idBuffer.bind(),g.pickId.pointer(s.UNSIGNED_BYTE,!1),s.drawArrays(s.TRIANGLES,0,o),r+this.shape[0]*this.shape[1]}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.shape[0]*this.shape[1];if(r=n+i)return null;var a=r-n,o=this.xData,s=this.yData;return{object:this,pointId:a,dataCoord:[o[a%this.shape[0]],s[a/this.shape[0]|0]]}},f.update=function(t){var e=(t=t||{}).shape||[0,0],r=t.x||i(e[0]),o=t.y||i(e[1]),s=t.z||new Float32Array(e[0]*e[1]);this.xData=r,this.yData=o;var l=t.colorLevels||[0],c=t.colorValues||[0,0,0,1],u=l.length,f=this.bounds,p=f[0]=r[0],d=f[1]=o[0],g=1/((f[2]=r[r.length-1])-p),v=1/((f[3]=o[o.length-1])-d),m=e[0],y=e[1];this.shape=[m,y];var x=(m-1)*(y-1)*(h.length>>>1);this.numVertices=x;for(var b=a.mallocUint8(4*x),_=a.mallocFloat32(2*x),w=a.mallocUint8(2*x),k=a.mallocUint32(x),M=0,A=0;A max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1540259130(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1540259130(pixelArcLength).xyz);\n}"]),l=[{name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return i(t,a,o,null,l)},r.createPickShader=function(t){return i(t,a,s,null,l)}},{"gl-shader":288,glslify:392}],245:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl||t.scene&&t.scene.gl,r=u(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var o=f(e);o.attributes.position.location=0,o.attributes.nextPosition.location=1,o.attributes.arcLength.location=2,o.attributes.lineWidth.location=3,o.attributes.color.location=4;for(var s=n(e),c=i(e,[{buffer:s,size:3,offset:0,stride:48},{buffer:s,size:3,offset:12,stride:48},{buffer:s,size:1,offset:24,stride:48},{buffer:s,size:1,offset:28,stride:48},{buffer:s,size:4,offset:32,stride:48}]),h=l(new Array(1024),[256,1,4]),p=0;p<1024;++p)h.data[p]=255;var d=a(e,h);d.wrap=e.REPEAT;var g=new v(e,r,o,s,c,d);return g.update(t),g};var n=t("gl-buffer"),i=t("gl-vao"),a=t("gl-texture2d"),o=t("glsl-read-float"),s=t("binary-search-bounds"),l=t("ndarray"),c=t("./lib/shaders"),u=c.createShader,f=c.createPickShader,h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function p(t,e){for(var r=0,n=0;n<3;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function d(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;r<3;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function g(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function v(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}var m=v.prototype;m.isTransparent=function(){return this.opacity<1},m.isOpaque=function(){return this.opacity>=1},m.pickSlots=1,m.setPickBase=function(t){this.pickId=t},m.drawTransparent=m.draw=function(t){if(this.vertexCount){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||h,view:t.view||h,projection:t.projection||h,clipBounds:d(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},m.drawPick=function(t){if(this.vertexCount){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||h,view:t.view||h,projection:t.projection||h,pickId:this.pickId,clipBounds:d(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},m.update=function(t){var e,r;this.dirty=!0;var n=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var i=[],a=[],o=[],c=0,u=0,f=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],h=t.position||t.positions;if(h){var d=t.color||t.colors||[0,0,0,1],g=t.lineWidth||1,v=!1;t:for(e=1;e0){for(var w=0;w<24;++w)i.push(i[i.length-12]);u+=2,v=!0}continue t}f[0][r]=Math.min(f[0][r],b[r],_[r]),f[1][r]=Math.max(f[1][r],b[r],_[r])}Array.isArray(d[0])?(m=d.length>e-1?d[e-1]:d.length>0?d[d.length-1]:[0,0,0,1],y=d.length>e?d[e]:d.length>0?d[d.length-1]:[0,0,0,1]):m=y=d,3===m.length&&(m=[m[0],m[1],m[2],1]),3===y.length&&(y=[y[0],y[1],y[2],1]),x=Array.isArray(g)?g.length>e-1?g[e-1]:g.length>0?g[g.length-1]:[0,0,0,1]:g;var k=c;if(c+=p(b,_),v){for(r=0;r<2;++r)i.push(b[0],b[1],b[2],_[0],_[1],_[2],k,x,m[0],m[1],m[2],m[3]);u+=2,v=!1}i.push(b[0],b[1],b[2],_[0],_[1],_[2],k,x,m[0],m[1],m[2],m[3],b[0],b[1],b[2],_[0],_[1],_[2],k,-x,m[0],m[1],m[2],m[3],_[0],_[1],_[2],b[0],b[1],b[2],c,-x,y[0],y[1],y[2],y[3],_[0],_[1],_[2],b[0],b[1],b[2],c,x,y[0],y[1],y[2],y[3]),u+=4}}if(this.buffer.update(i),a.push(c),o.push(h[h.length-1].slice()),this.bounds=f,this.vertexCount=u,this.points=o,this.arcLength=a,"dashes"in t){var M=t.dashes.slice();for(M.unshift(0),e=1;e max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),l=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]),c=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),u=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]),f=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]),h=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]),p=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]),d=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:l,fragment:c,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:u,fragment:f,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:h,fragment:f,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:p,fragment:d,attributes:[{name:"position",type:"vec3"}]}},{glslify:392}],268:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("normals"),l=t("gl-mat4/multiply"),c=t("gl-mat4/invert"),u=t("ndarray"),f=t("colormap"),h=t("simplicial-complex-contour"),p=t("typedarray-pool"),d=t("./lib/shaders"),g=t("./lib/closest-point"),v=d.meshShader,m=d.wireShader,y=d.pointShader,x=d.pickShader,b=d.pointPickShader,_=d.contourShader,w=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function k(t,e,r,n,i,a,o,s,l,c,u,f,h,p,d,g,v,m,y,x,b,_,k,M,A,T,S){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=c,this.triangleVAO=p,this.triangleCount=0,this.lineWidth=1,this.edgePositions=d,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=x,this.pointColors=_,this.pointUVs=k,this.pointSizes=M,this.pointIds=b,this.pointVAO=A,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=T,this.contourVAO=S,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=w,this._view=w,this._projection=w,this._resolution=[1,1]}var M=k.prototype;function A(t){var e=n(t,y.vertex,y.fragment);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function T(t){var e=n(t,x.vertex,x.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e}function S(t){var e=n(t,b.vertex,b.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function E(t){var e=n(t,_.vertex,_.fragment);return e.attributes.position.location=0,e}M.isOpaque=function(){return this.opacity>=1},M.isTransparent=function(){return this.opacity<1},M.pickSlots=1,M.setPickBase=function(t){this.pickId=t},M.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=p.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},M.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||w,n=t.view||w,i=t.projection||w,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},M.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;ai[M]&&(r.uniforms.dataAxis=c,r.uniforms.screenOffset=u,r.uniforms.color=v[t],r.uniforms.angle=m[t],a.drawArrays(a.TRIANGLES,i[M],i[A]-i[M]))),y[t]&&k&&(u[1^t]-=T*p*x[t],r.uniforms.dataAxis=f,r.uniforms.screenOffset=u,r.uniforms.color=b[t],r.uniforms.angle=_[t],a.drawArrays(a.TRIANGLES,w,k)),u[1^t]=T*s[2+(1^t)]-1,d[t+2]&&(u[1^t]+=T*p*g[t+2],Mi[M]&&(r.uniforms.dataAxis=c,r.uniforms.screenOffset=u,r.uniforms.color=v[t+2],r.uniforms.angle=m[t+2],a.drawArrays(a.TRIANGLES,i[M],i[A]-i[M]))),y[t+2]&&k&&(u[1^t]+=T*p*x[t+2],r.uniforms.dataAxis=f,r.uniforms.screenOffset=u,r.uniforms.color=b[t+2],r.uniforms.angle=_[t+2],a.drawArrays(a.TRIANGLES,w,k))}),g.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,c=r.pixelRatio;if(this.titleCount){for(var u=0;u<2;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),g.bind=(h=[0,0],p=[0,0],d=[0,0],function(){var t=this.plot,e=this.shader,r=t._tickBounds,n=t.dataBox,i=t.screenBox,a=t.viewBox;e.bind();for(var o=0;o<2;++o){var s=r[o],l=r[o+2]-s,c=.5*(n[o+2]+n[o]),u=n[o+2]-n[o],f=a[o],g=a[o+2]-f,v=i[o],m=i[o+2]-v;p[o]=2*l/u*g/m,h[o]=2*(s-c)/u*g/m}d[1]=2*t.pixelRatio/(i[3]-i[1]),d[0]=d[1]*(i[3]-i[1])/(i[2]-i[0]),e.uniforms.dataScale=p,e.uniforms.dataShift=h,e.uniforms.textScale=d,this.vbo.bind(),e.attributes.textCoordinate.pointer()}),g.update=function(t){var e,r,n,i,o,s=[],l=t.ticks,c=t.bounds;for(o=0;o<2;++o){var u=[Math.floor(s.length/3)],f=[-1/0],h=l[o];for(e=0;e=0){var g=e[d]-n[d]*(e[d+2]-e[d])/(n[d+2]-n[d]);0===d?o.drawLine(g,e[1],g,e[3],p[d],h[d]):o.drawLine(e[0],g,e[2],g,p[d],h[d])}}for(d=0;d=0;--t)this.objects[t].dispose();this.objects.length=0;for(t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},c.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},c.removeObject=function(t){for(var e=this.objects,r=0;r0&&0===L[e-1];)L.pop(),z.pop().dispose()}window.addEventListener("resize",j),F.update=function(t){e||(t=t||{},O=!0,I=!0)},F.add=function(t){e||(t.axes=A,E.push(t),C.push(-1),O=!0,I=!0,V())},F.remove=function(t){if(!e){var r=E.indexOf(t);r<0||(E.splice(r,1),C.pop(),O=!0,I=!0,V())}},F.dispose=function(){if(!e&&(e=!0,window.removeEventListener("resize",j),r.removeEventListener("webglcontextlost",H),F.mouseListener.enabled=!1,!F.contextLost)){A.dispose(),S.dispose();for(var t=0;tb.distance)continue;for(var u=0;u0){r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function v(t){return"boolean"!=typeof t||t}},{"./lib/shader":276,"3d-view-controls":44,"a-big-triangle":47,"gl-axes3d":222,"gl-axes3d/properties":229,"gl-fbo":239,"gl-mat4/perspective":257,"gl-select-static":287,"gl-spikes3d":297,"is-mobile":403,"mouse-change":418}],278:[function(t,e,r){var n=t("glslify");r.pointVertex=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform float pointCloud;\n\nhighp float rand(vec2 co) {\n highp float a = 12.9898;\n highp float b = 78.233;\n highp float c = 43758.5453;\n highp float d = dot(co.xy, vec2(a, b));\n highp float e = mod(d, 3.14);\n return fract(sin(e) * c);\n}\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n // if we don't jitter the point size a bit, overall point cloud\n // saturation 'jumps' on zooming, which is disturbing and confusing\n gl_PointSize = pointSize * ((19.5 + rand(position)) / 20.0);\n if(pointCloud != 0.0) { // pointCloud is truthy\n // get the same square surface as circle would be\n gl_PointSize *= 0.886;\n }\n}"]),r.pointFragment=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color, borderColor;\nuniform float centerFraction;\nuniform float pointCloud;\n\nvoid main() {\n float radius;\n vec4 baseColor;\n if(pointCloud != 0.0) { // pointCloud is truthy\n if(centerFraction == 1.0) {\n gl_FragColor = color;\n } else {\n gl_FragColor = mix(borderColor, color, centerFraction);\n }\n } else {\n radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]),r.pickVertex=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]),r.pickFragment=n(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"])},{glslify:392}],279:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("typedarray-pool"),o=t("./lib/shader");function s(t,e,r,n,i){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.shader=n,this.pickShader=i,this.sizeMin=.5,this.sizeMinCap=2,this.sizeMax=20,this.areaRatio=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.blend=!1,this.pickOffset=0,this.points=null}e.exports=function(t,e){var r=t.gl,a=i(r),l=i(r),c=n(r,o.pointVertex,o.pointFragment),u=n(r,o.pickVertex,o.pickFragment),f=new s(t,a,l,c,u);return f.update(e),t.addObject(f),f};var l,c,u=s.prototype;u.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.plot.removeObject(this)},u.update=function(t){var e;function r(e,r){return e in t?t[e]:r}t=t||{},this.sizeMin=r("sizeMin",.5),this.sizeMax=r("sizeMax",20),this.color=r("color",[1,0,0,1]).slice(),this.areaRatio=r("areaRatio",1),this.borderColor=r("borderColor",[0,0,0,1]).slice(),this.blend=r("blend",!1);var n=t.positions.length>>>1,i=t.positions instanceof Float32Array,o=t.idToIndex instanceof Int32Array&&t.idToIndex.length>=n,s=t.positions,l=i?s:a.mallocFloat32(s.length),c=o?t.idToIndex:a.mallocInt32(n);if(i||l.set(s),!o)for(l.set(s),e=0;e>>1;for(r=0;r=e[0]&&a<=e[2]&&o>=e[1]&&o<=e[3]&&n++}return n}(this.points,i),u=this.plot.pickPixelRatio*Math.max(Math.min(this.sizeMinCap,this.sizeMin),Math.min(this.sizeMax,this.sizeMax/Math.pow(s,.33333)));l[0]=2/a,l[4]=2/o,l[6]=-2*i[0]/a-1,l[7]=-2*i[1]/o-1,this.offsetBuffer.bind(),r.bind(),r.attributes.position.pointer(),r.uniforms.matrix=l,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointCloud=u<5,r.uniforms.pointSize=u,r.uniforms.centerFraction=Math.min(1,Math.max(0,Math.sqrt(1-this.areaRatio))),e&&(c[0]=255&t,c[1]=t>>8&255,c[2]=t>>16&255,c[3]=t>>24&255,this.pickBuffer.bind(),r.attributes.pickId.pointer(n.UNSIGNED_BYTE),r.uniforms.pickOffset=c,this.pickOffset=t);var f=n.getParameter(n.BLEND),h=n.getParameter(n.DITHER);return f&&!this.blend&&n.disable(n.BLEND),h&&n.disable(n.DITHER),n.drawArrays(n.POINTS,0,this.pointCount),f&&!this.blend&&n.enable(n.BLEND),h&&n.enable(n.DITHER),t+this.pointCount}),u.draw=u.unifiedDraw,u.drawPick=u.unifiedDraw,u.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(r=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":278,"gl-buffer":230,"gl-shader":288,"typedarray-pool":522}],280:[function(t,e,r){e.exports=function(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],f=e[2],h=e[3],p=r[0],d=r[1],g=r[2],v=r[3];(a=c*p+u*d+f*g+h*v)<0&&(a=-a,p=-p,d=-d,g=-g,v=-v);1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n);return t[0]=s*c+l*p,t[1]=s*u+l*d,t[2]=s*f+l*g,t[3]=s*h+l*v,t}},{}],281:[function(t,e,r){"use strict";e.exports=function(t){return t||0===t?t.toString():""}},{}],282:[function(t,e,r){"use strict";var n=t("vectorize-text");e.exports=function(t,e){var r=i[e];r||(r=i[e]={});if(t in r)return r[t];for(var a=n(t,{textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),o=n(t,{triangles:!0,textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),s=[[1/0,1/0],[-1/0,-1/0]],l=0;l max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),o=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),s=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]),l=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]),c=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]),u=[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:u},h={vertex:o,fragment:l,attributes:u},p={vertex:s,fragment:l,attributes:u},d={vertex:a,fragment:c,attributes:u},g={vertex:o,fragment:c,attributes:u},v={vertex:s,fragment:c,attributes:u};function m(t,e){var r=n(t,e),i=r.attributes;return i.position.location=0,i.color.location=1,i.glyph.location=2,i.id.location=3,r}r.createPerspective=function(t){return m(t,f)},r.createOrtho=function(t){return m(t,h)},r.createProject=function(t){return m(t,p)},r.createPickPerspective=function(t){return m(t,d)},r.createPickOrtho=function(t){return m(t,g)},r.createPickProject=function(t){return m(t,v)}},{"gl-shader":288,glslify:392}],284:[function(t,e,r){"use strict";var n=t("is-string-blank"),i=t("gl-buffer"),a=t("gl-vao"),o=t("typedarray-pool"),s=t("gl-mat4/multiply"),l=t("./lib/shaders"),c=t("./lib/glyphs"),u=t("./lib/get-simple-string"),f=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function h(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function p(t,e,r,n){return h(n,n),h(n,n),h(n,n)}function d(t,e){this.index=t,this.dataCoordinate=this.position=e}function g(t,e,r,n,i,a,o,s,l,c,u,f){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=a,this.glyphBuffer=o,this.idBuffer=s,this.vao=l,this.vertexCount=0,this.lineVertexCount=0,this.opacity=1,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[1,1,1],this.pickId=0,this.pickPerspectiveShader=c,this.pickOrthoShader=u,this.pickProjectShader=f,this.points=[],this._selectResult=new d(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.dirty=!0}e.exports=function(t){var e=t.gl,r=l.createPerspective(e),n=l.createOrtho(e),o=l.createProject(e),s=l.createPickPerspective(e),c=l.createPickOrtho(e),u=l.createPickProject(e),f=i(e),h=i(e),p=i(e),d=i(e),v=a(e,[{buffer:f,size:3,type:e.FLOAT},{buffer:h,size:4,type:e.FLOAT},{buffer:p,size:2,type:e.FLOAT},{buffer:d,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),m=new g(e,r,n,o,f,h,p,d,v,s,c,u);return m.update(t),m};var v=g.prototype;v.pickSlots=1,v.setPickBase=function(t){this.pickId=t},v.isTransparent=function(){if(this.opacity<1)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&this.projectOpacity[t]<1)return!0;return!1},v.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=1)return!0;return!1};var m=[0,0],y=[0,0,0],x=[0,0,0],b=[0,0,0,1],_=[0,0,0,1],w=f.slice(),k=[0,0,0],M=[[0,0,0],[0,0,0]];function A(t){return t[0]=t[1]=t[2]=0,t}function T(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function S(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function E(t,e,r,n,i){var a,o=e.axesProject,l=e.gl,c=t.uniforms,u=r.model||f,h=r.view||f,d=r.projection||f,g=e.axesBounds,v=function(t){for(var e=M,r=0;r<2;++r)for(var n=0;n<3;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}(e.clipBounds);a=e.axes&&e.axes.lastCubeProps?e.axes.lastCubeProps.axis:[1,1,1],m[0]=2/l.drawingBufferWidth,m[1]=2/l.drawingBufferHeight,t.bind(),c.view=h,c.projection=d,c.screenSize=m,c.highlightId=e.highlightId,c.highlightScale=e.highlightScale,c.clipBounds=v,c.pickGroup=e.pickId/255,c.pixelRatio=e.pixelRatio;for(var E=0;E<3;++E)if(o[E]&&e.projectOpacity[E]<1===n){c.scale=e.projectScale[E],c.opacity=e.projectOpacity[E];for(var C=w,L=0;L<16;++L)C[L]=0;for(L=0;L<4;++L)C[5*L]=1;C[5*E]=0,a[E]<0?C[12+E]=g[0][E]:C[12+E]=g[1][E],s(C,u,C),c.model=C;var z=(E+1)%3,O=(E+2)%3,I=A(y),P=A(x);I[z]=1,P[O]=1;var D=p(0,0,0,T(b,I)),R=p(0,0,0,T(_,P));if(Math.abs(D[1])>Math.abs(R[1])){var B=D;D=R,R=B,B=I,I=P,P=B;var F=z;z=O,O=F}D[0]<0&&(I[z]=-1),R[1]>0&&(P[O]=-1);var N=0,j=0;for(L=0;L<4;++L)N+=Math.pow(u[4*z+L],2),j+=Math.pow(u[4*O+L],2);I[z]/=Math.sqrt(N),P[O]/=Math.sqrt(j),c.axes[0]=I,c.axes[1]=P,c.fragClipBounds[0]=S(k,v[0],E,-1e8),c.fragClipBounds[1]=S(k,v[1],E,1e8),e.vao.draw(l.TRIANGLES,e.vertexCount),e.lineWidth>0&&(l.lineWidth(e.lineWidth),e.vao.draw(l.LINES,e.lineVertexCount,e.vertexCount))}}var C=[[-1e8,-1e8,-1e8],[1e8,1e8,1e8]];function L(t,e,r,n,i,a){var o=r.gl;if(r.vao.bind(),i===r.opacity<1||a){t.bind();var s=t.uniforms;s.model=n.model||f,s.view=n.view||f,s.projection=n.projection||f,m[0]=2/o.drawingBufferWidth,m[1]=2/o.drawingBufferHeight,s.screenSize=m,s.highlightId=r.highlightId,s.highlightScale=r.highlightScale,s.fragClipBounds=C,s.clipBounds=r.axes.bounds,s.opacity=r.opacity,s.pickGroup=r.pickId/255,s.pixelRatio=r.pixelRatio,r.vao.draw(o.TRIANGLES,r.vertexCount),r.lineWidth>0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount))}E(e,r,n,i),r.vao.unbind()}function z(t,e,r){var i;i=Array.isArray(t)?e=this.pointCount||e<0)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;i<3;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},v.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},v.update=function(t){if("perspective"in(t=t||{})&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t)if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{r=+t.projectOpacity;this.projectOpacity=[r,r,r]}"opacity"in t&&(this.opacity=t.opacity),this.dirty=!0;var n=t.position,i=t.font||"normal",a=t.alignment||[0,0],s=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0],c=t.glyph,u=t.color,f=t.size,h=t.angle,p=t.lineColor,d=-1,g=0,v=0,m=0;if(n.length){m=n.length;t:for(var y=0;y0){var C=0,L=g,O=[0,0,0,1],I=[0,0,0,1],P=Array.isArray(u)&&Array.isArray(u[0]),D=Array.isArray(p)&&Array.isArray(p[0]);t:for(y=0;y0?q[b]*=1-k[0][b]:a[b]<0&&(q[b]*=1+k[1][b]);var H=_.cells||[],G=_.positions||[];for(b=0;b0){var m=r*u;o.drawBox(f-m,h-m,p+m,h+m,a),o.drawBox(f-m,d-m,p+m,d+m,a),o.drawBox(f-m,h-m,f+m,d+m,a),o.drawBox(p-m,h-m,p+m,d+m,a)}}}},s.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},s.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":285,"gl-buffer":230,"gl-shader":288}],287:[function(t,e,r){"use strict";e.exports=function(t,e){var r=n(t,e),a=i.mallocUint8(e[0]*e[1]*4);return new c(t,r,a)};var n=t("gl-fbo"),i=t("typedarray-pool"),a=t("ndarray"),o=t("bit-twiddle").nextPow2,s=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(_inline_16_arg0_<255||_inline_16_arg1_<255||_inline_16_arg2_<255||_inline_16_arg3_<255){var _inline_16_l=_inline_16_arg4_-_inline_16_arg6_[0],_inline_16_a=_inline_16_arg5_-_inline_16_arg6_[1],_inline_16_f=_inline_16_l*_inline_16_l+_inline_16_a*_inline_16_a;_inline_16_fthis.buffer.length){i.free(this.buffer);for(var n=this.buffer=i.mallocUint8(o(r*e*4)),a=0;ar)for(t=r;te)for(t=e;t=0){for(var k=0|w.type.charAt(w.type.length-1),M=new Array(k),A=0;A=0;)T+=1;_[y]=T}var S=new Array(r.length);function E(){h.program=o.program(p,h._vref,h._fref,b,_);for(var t=0;t=0){var d=h.charCodeAt(h.length-1)-48;if(d<2||d>4)throw new n("","Invalid data type for attribute "+f+": "+h);o(t,e,p[0],i,d,a,f)}else{if(!(h.indexOf("mat")>=0))throw new n("","Unknown data type for attribute "+f+": "+h);var d=h.charCodeAt(h.length-1)-48;if(d<2||d>4)throw new n("","Invalid data type for attribute "+f+": "+h);s(t,e,p,i,d,a,f)}}}return a};var n=t("./GLError");function i(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}var a=i.prototype;function o(t,e,r,n,a,o,s){for(var l=["gl","v"],c=[],u=0;u4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+a+"fv(locations["+e+"],false,obj"+t+")"}throw new i("","Unknown uniform data type for "+name+": "+r)}var a=r.charCodeAt(r.length-1)-48;if(a<2||a>4)throw new i("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+a+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+a+"fv(locations["+e+"],obj"+t+")";default:throw new i("","Unrecognized data type for vector "+name+": "+r)}}}function c(e){for(var n=["return function updateProperty(obj){"],i=function t(e,r){if("object"!=typeof r)return[[e,r]];var n=[];for(var i in r){var a=r[i],o=e;parseInt(i)+""===i?o+="["+i+"]":o+="."+i,"object"==typeof a?n.push.apply(n,t(o,a)):n.push([o,a])}return n}("",e),a=0;a4)throw new i("","Invalid data type");return"b"===t.charAt(0)?o(r,!1):o(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(r<2||r>4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+t);return o(r*r,0)}throw new i("","Unknown uniform data type for "+name+": "+t)}}(r[u].type);var p}function f(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var c=1;c1)for(var l=0;l 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec4"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec4"}]}},{glslify:392}],300:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("normals"),l=t("gl-mat4/multiply"),c=t("gl-mat4/invert"),u=t("ndarray"),f=t("colormap"),h=t("simplicial-complex-contour"),p=t("typedarray-pool"),d=t("./shaders"),g=(t("./closest-point"),d.meshShader),v=d.pickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function y(t,e,r,n,i,a,o,s,l,c,u,f,h,p,d,g,v,y,x,b,_,w,k,M,A,T,S,E){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleVectors=c,this.triangleColors=f,this.triangleNormals=p,this.triangleUVs=h,this.triangleIds=u,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=g,this.edgeColors=y,this.edgeUVs=x,this.edgeIds=v,this.edgeVAO=b,this.edgeCount=0,this.pointPositions=_,this.pointColors=k,this.pointUVs=M,this.pointSizes=A,this.pointIds=w,this.pointVAO=T,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=S,this.contourVAO=E,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!1,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this.tubeScale=1,this._model=m,this._view=m,this._projection=m,this._resolution=[1,1]}var x=y.prototype;function b(t){var e=n(t,v.vertex,v.fragment,null,v.attributes);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.vector.location=5,e}x.isOpaque=function(){return this.opacity>=1},x.isTransparent=function(){return this.opacity<1},x.pickSlots=1,x.setPickBase=function(t){this.pickId=t},x.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=p.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},x.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||m,n=t.view||m,i=t.projection||m,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,tubeScale:this.tubeScale,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},x.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions[r[1]].slice(0,3);return{index:e,position:n,intensity:this.intensity[r[1]],velocity:this.vectors[r[1]].slice(0,3),divergence:this.vectors[r[1]][3],dataCoordinate:n}},x.dispose=function(){this.texture.dispose(),this.triShader.dispose(),this.pickShader.dispose(),this.triangleVAO.dispose(),this.trianglePositions.dispose(),this.triangleVectors.dispose(),this.triangleColors.dispose(),this.triangleUVs.dispose(),this.triangleNormals.dispose(),this.triangleIds.dispose(),this.edgeVAO.dispose(),this.edgePositions.dispose(),this.edgeColors.dispose(),this.edgeUVs.dispose(),this.edgeIds.dispose(),this.pointVAO.dispose(),this.pointPositions.dispose(),this.pointColors.dispose(),this.pointUVs.dispose(),this.pointSizes.dispose(),this.pointIds.dispose(),this.contourVAO.dispose(),this.contourPositions.dispose()},e.exports=function(t,e){1===arguments.length&&(t=(e=t).gl);var r=e.triShader||function(t){var e=n(t,g.vertex,g.fragment,null,g.attributes);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.vector.location=5,e}(t),s=b(t),l=o(t,u(new Uint8Array([255,255,255,255]),[1,1,4]));l.generateMipmap(),l.minFilter=t.LINEAR_MIPMAP_LINEAR,l.magFilter=t.LINEAR;var c=i(t),f=i(t),h=i(t),p=i(t),d=i(t),v=i(t),m=a(t,[{buffer:c,type:t.FLOAT,size:4},{buffer:v,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:h,type:t.FLOAT,size:4},{buffer:p,type:t.FLOAT,size:2},{buffer:d,type:t.FLOAT,size:3},{buffer:f,type:t.FLOAT,size:4}]),x=i(t),_=i(t),w=i(t),k=i(t),M=a(t,[{buffer:x,type:t.FLOAT,size:3},{buffer:k,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:_,type:t.FLOAT,size:4},{buffer:w,type:t.FLOAT,size:2}]),A=i(t),T=i(t),S=i(t),E=i(t),C=i(t),L=a(t,[{buffer:A,type:t.FLOAT,size:3},{buffer:C,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:T,type:t.FLOAT,size:4},{buffer:S,type:t.FLOAT,size:2},{buffer:E,type:t.FLOAT,size:1}]),z=i(t),O=new y(t,l,r,null,null,s,null,null,c,f,v,h,p,d,m,x,k,_,w,M,A,C,T,S,E,L,z,a(t,[{buffer:z,type:t.FLOAT,size:3}]));return O.update(e),O}},{"./closest-point":298,"./shaders":299,colormap:114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,ndarray:433,normals:436,"simplicial-complex-contour":494,"typedarray-pool":522}],301:[function(t,e,r){"use strict";var n=t("gl-vec3"),i=t("gl-vec4"),a=function(t,e,r,a){for(var o=0,s=0;so&&(o=u)}var f=t.map(function(t){return function(t,e,r,a){var o,s,l,c=t.points,u=t.velocities,f=t.divergences;n.set(n.create(),0,1,0),n.create(),n.create();n.create();for(var h=[],p=[],d=[],g=[],v=[],m=[],y=0,x=0,b=i.create(),_=i.create(),w=0;w0)for(k=0;k<8;k++){var M=(k+1)%8;h.push(g[k],v[k],v[M],v[M],g[M],g[k]),d.push(_,b,b,b,_,_),m.push(y,x,x,x,y,y),p.push([h.length-6,h.length-5,h.length-4],[h.length-3,h.length-2,h.length-1])}var A=g;g=v,v=A,A=_,_=b,b=A,A=y,y=x,x=A}return{positions:h,cells:p,vectors:d,vertexIntensity:m}}(t,r,a,o)}),h=[],p=[],d=[],g=[];for(s=0;se)return r-1}return r},c=n.create(),u=n.create(),f=function(t,e,r){return tr?r:t},h=function(t,e,r,i){var a=t[0],o=t[1],s=t[2],h=r[0].length,p=r[1].length,d=r[2].length,g=l(r[0],a),v=l(r[1],o),m=l(r[2],s),y=g+1,x=v+1,b=m+1;if(r[0][g]===a&&(y=g),r[1][v]===o&&(x=v),r[2][m]===s&&(b=m),i&&(g=f(g,0,h-1),y=f(y,0,h-1),v=f(v,0,p-1),x=f(x,0,p-1),m=f(m,0,d-1),b=f(b,0,d-1)),g<0||v<0||m<0||y>=h||x>=p||b>=d)return n.create();var _=(a-r[0][g])/(r[0][y]-r[0][g]),w=(o-r[1][v])/(r[1][x]-r[1][v]),k=(s-r[2][m])/(r[2][b]-r[2][m]);(_<0||_>1||isNaN(_))&&(_=0),(w<0||w>1||isNaN(w))&&(w=0),(k<0||k>1||isNaN(k))&&(k=0);var M=m*h*p,A=b*h*p,T=v*h,S=x*h,E=g,C=y,L=e[T+M+E],z=e[T+M+C],O=e[S+M+E],I=e[S+M+C],P=e[T+A+E],D=e[T+A+C],R=e[S+A+E],B=e[S+A+C],F=n.create();return n.lerp(F,L,z,_),n.lerp(c,O,I,_),n.lerp(F,F,c,w),n.lerp(c,P,D,_),n.lerp(u,R,B,_),n.lerp(c,c,u,w),n.lerp(F,F,c,k),F},p=function(t){var e=1/0;t.sort(function(t,e){return t-e});for(var r=1;r=f&&r<=g&&n>=h&&n<=v&&i>=d&&i<=m},x=10*n.distance(e[0],e[1])/i,b=x*x,_=1,w=0;n.create();r.length>=2&&(_=function(t){for(var e=[],r=[],n=[],i={},a={},o={},s=0;sw&&!isNaN(P)&&isFinite(P)&&(w=P),C.push(P),u.push({points:A,velocities:T,divergences:C});for(var z=0;z<100*i&&A.lengthb&&n.scale(O,O,x/Math.sqrt(I)),n.add(O,O,M),S=t.getVelocity(O),n.squaredDistance(E,O)-b>-1e-4*b){A.push(O),E=O,T.push(S);L=t.getDivergence(O,S);(P=n.length(L))>w&&!isNaN(P)&&isFinite(P)&&(w=P),C.push(P)}M=O}}for(k=0;k max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color \u2014 in vertex or in fragment\n vec4 surfaceColor = step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) + step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]),s=i(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]),l=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]);r.createShader=function(t){var e=n(t,a,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,a,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,s,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,s,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":288,glslify:392}],303:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=y(e),n=b(e),s=x(e),l=_(e),c=i(e),u=a(e,[{buffer:c,size:4,stride:w,offset:0},{buffer:c,size:3,stride:w,offset:16},{buffer:c,size:3,stride:w,offset:28}]),f=i(e),h=a(e,[{buffer:f,size:4,stride:20,offset:0},{buffer:f,size:1,stride:20,offset:16}]),p=i(e),d=a(e,[{buffer:p,size:2,type:e.FLOAT}]),g=o(e,1,S,e.RGBA,e.UNSIGNED_BYTE);g.minFilter=e.LINEAR,g.magFilter=e.LINEAR;var v=new E(e,[0,0],[[0,0,0],[0,0,0]],r,n,c,u,g,s,l,f,h,p,d),m={levels:[[],[],[]]};for(var k in t)m[k]=t[k];return m.colormap=m.colormap||"jet",v.update(m),v};var n=t("bit-twiddle"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("typedarray-pool"),l=t("colormap"),c=t("ndarray-ops"),u=t("ndarray-pack"),f=t("ndarray"),h=t("surface-nets"),p=t("gl-mat4/multiply"),d=t("gl-mat4/invert"),g=t("binary-search-bounds"),v=t("ndarray-gradient"),m=t("./lib/shaders"),y=m.createShader,x=m.createContourShader,b=m.createPickShader,_=m.createPickContourShader,w=40,k=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],M=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],A=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];function T(t,e,r,n,i){this.position=t,this.index=e,this.uv=r,this.level=n,this.dataCoordinate=i}!function(){for(var t=0;t<3;++t){var e=A[t],r=(t+2)%3;e[(t+1)%3+0]=1,e[r+3]=1,e[t+6]=1}}();var S=256;function E(t,e,r,n,i,a,o,l,c,u,h,p,d,g){this.gl=t,this.shape=e,this.bounds=r,this.intensityBounds=[],this._shader=n,this._pickShader=i,this._coordinateBuffer=a,this._vao=o,this._colorMap=l,this._contourShader=c,this._contourPickShader=u,this._contourBuffer=h,this._contourVAO=p,this._contourOffsets=[[],[],[]],this._contourCounts=[[],[],[]],this._vertexCount=0,this._pickResult=new T([0,0,0],[0,0],[0,0],[0,0,0],[0,0,0]),this._dynamicBuffer=d,this._dynamicVAO=g,this._dynamicOffsets=[0,0,0],this._dynamicCounts=[0,0,0],this.contourWidth=[1,1,1],this.contourLevels=[[1],[1],[1]],this.contourTint=[0,0,0],this.contourColor=[[.5,.5,.5,1],[.5,.5,.5,1],[.5,.5,.5,1]],this.showContour=!0,this.showSurface=!0,this.enableHighlight=[!0,!0,!0],this.highlightColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.highlightTint=[1,1,1],this.highlightLevel=[-1,-1,-1],this.enableDynamic=[!0,!0,!0],this.dynamicLevel=[NaN,NaN,NaN],this.dynamicColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.dynamicTint=[1,1,1],this.dynamicWidth=[1,1,1],this.axesBounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.surfaceProject=[!1,!1,!1],this.contourProject=[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],this.colorBounds=[!1,!1],this._field=[f(s.mallocFloat(1024),[0,0]),f(s.mallocFloat(1024),[0,0]),f(s.mallocFloat(1024),[0,0])],this.pickId=1,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.snapToData=!1,this.opacity=1,this.lightPosition=[10,1e4,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.vertexColor=0,this.dirty=!0}var C=E.prototype;C.isTransparent=function(){return this.opacity<1},C.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;t<3;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},C.pickSlots=1,C.setPickBase=function(t){this.pickId=t};var L=[0,0,0],z={showSurface:!1,showContour:!1,projections:[k.slice(),k.slice(),k.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]};function O(t,e){var r,n,i,a=e.axes&&e.axes.lastCubeProps.axis||L,o=e.showSurface,s=e.showContour;for(r=0;r<3;++r)for(o=o||e.surfaceProject[r],n=0;n<3;++n)s=s||e.contourProject[r][n];for(r=0;r<3;++r){var l=z.projections[r];for(n=0;n<16;++n)l[n]=0;for(n=0;n<4;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],p(l,t.model,l);var c=z.clipBounds[r];for(i=0;i<2;++i)for(n=0;n<3;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return z.showSurface=o,z.showContour=s,z}var I={model:k,view:k,projection:k,inverseModel:k.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1,vertexColor:0},P=k.slice(),D=[1,0,0,0,1,0,0,0,1];function R(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=I;n.model=t.model||k,n.view=t.view||k,n.projection=t.projection||k,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.contourColor=this.contourColor[0],n.inverseModel=d(n.inverseModel,n.model);for(var i=0;i<2;++i)for(var a=n.clipBounds[i],o=0;o<3;++o)a[o]=Math.min(Math.max(this.clipBounds[i][o],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=D,n.vertexColor=this.vertexColor;var s=P;for(p(s,n.view,n.model),p(s,n.projection,s),d(s,s),i=0;i<3;++i)n.eyePosition[i]=s[12+i]/s[15];var l=s[15];for(i=0;i<3;++i)l+=this.lightPosition[i]*s[4*i+3];for(i=0;i<3;++i){var c=s[12+i];for(o=0;o<3;++o)c+=s[4*o+i]*this.lightPosition[o];n.lightPosition[i]=c/l}var u=O(n,this);if(u.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;i<3;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=u.projections[i],this._shader.uniforms.clipBounds=u.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(u.showContour&&!e){var f=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,f.bind(),f.uniforms=n;var h=this._contourVAO;for(h.bind(),i=0;i<3;++i)for(f.uniforms.permutation=A[i],r.lineWidth(this.contourWidth[i]),o=0;o>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;u<2;++u)for(var f=u?a:1-a,h=0;h<2;++h)for(var p=i+u,d=s+h,v=f*(h?l:1-l),m=0;m<3;++m)c[m]+=this._field[m].get(p,d)*v;for(var y=this._pickResult.level,x=0;x<3;++x)if(y[x]=g.le(this.contourLevels[x],c[x]),y[x]<0)this.contourLevels[x].length>0&&(y[x]=0);else if(y[x]Math.abs(_-c[x])&&(y[x]+=1)}for(r.index[0]=a<.5?i:i+1,r.index[1]=l<.5?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;m<3;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},C.update=function(t){t=t||{},this.dirty=!0,"contourWidth"in t&&(this.contourWidth=N(t.contourWidth,Number)),"showContour"in t&&(this.showContour=N(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=N(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=V(t.contourColor)),"contourProject"in t&&(this.contourProject=N(t.contourProject,function(t){return N(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=V(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=N(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=N(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds),"vertexColor"in t&&(this.vertexColor=t.vertexColor?1:0);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var i=(e.shape[0]+2)*(e.shape[1]+2);i>this._field[2].data.length&&(s.freeFloat(this._field[2].data),this._field[2].data=s.mallocFloat(n.nextPow2(i))),this._field[2]=f(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),F(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;o<2;++o)this._field[2].size>this._field[o].data.length&&(s.freeFloat(this._field[o].data),this._field[o].data=s.mallocFloat(this._field[2].size)),this._field[o]=f(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var p=t.coords;if(!Array.isArray(p)||3!==p.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;o<2;++o){var d=p[o];for(b=0;b<2;++b)if(d.shape[b]!==a[b])throw new Error("gl-surface: coords have incorrect shape");F(this._field[o],d)}}else if(t.ticks){var g=t.ticks;if(!Array.isArray(g)||2!==g.length)throw new Error("gl-surface: invalid ticks");for(o=0;o<2;++o){var m=g[o];if((Array.isArray(m)||m.length)&&(m=f(m)),m.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var y=f(m.data,a);y.stride[o]=m.stride[0],y.stride[1^o]=0,F(this._field[o],y)}}else{for(o=0;o<2;++o){var x=[0,0];x[o]=1,this._field[o]=f(this._field[o].data,[a[0]+2,a[1]+2],x,0)}this._field[0].set(0,0,0);for(var b=0;b0){for(var kt=0;kt<5;++kt)nt.pop();W-=1}continue t}nt.push(st[0],st[1],ut[0],ut[1],st[2]),W+=1}}ot.push(W)}this._contourOffsets[it]=at,this._contourCounts[it]=ot}var Mt=s.mallocFloat(nt.length);for(o=0;o halfCharStep + halfCharWidth ||\n\t\t\t\t\tfloor(uv.x) < halfCharStep - halfCharWidth) return;\n\n\t\t\t\tuv += charId * charStep;\n\t\t\t\tuv = uv / atlasSize;\n\n\t\t\t\tvec4 color = fontColor;\n\t\t\t\tvec4 mask = texture2D(atlas, uv);\n\n\t\t\t\tfloat maskY = lightness(mask);\n\t\t\t\t// float colorY = lightness(color);\n\t\t\t\tcolor.a *= maskY;\n\t\t\t\tcolor.a *= opacity;\n\n\t\t\t\t// color.a += .1;\n\n\t\t\t\t// antialiasing, see yiq color space y-channel formula\n\t\t\t\t// color.rgb += (1. - color.rgb) * (1. - mask.rgb);\n\n\t\t\t\tgl_FragColor = color;\n\t\t\t}"});return{regl:t,draw:e,atlas:{}}},k.prototype.update=function(t){var e=this;if("string"==typeof t)t={text:t};else if(!t)return;null!=(t=i(t,{position:"position positions coord coords coordinates",font:"font fontFace fontface typeface cssFont css-font family fontFamily",fontSize:"fontSize fontsize size font-size",text:"text texts chars characters value values symbols",align:"align alignment textAlign textbaseline",baseline:"baseline textBaseline textbaseline",direction:"dir direction textDirection",color:"color colour fill fill-color fillColor textColor textcolor",kerning:"kerning kern",range:"range dataBox",viewport:"vp viewport viewBox viewbox viewPort",opacity:"opacity alpha transparency visible visibility opaque",offset:"offset positionOffset padding shift indent indentation"},!0)).opacity&&(Array.isArray(t.opacity)?this.opacity=t.opacity.map(function(t){return parseFloat(t)}):this.opacity=parseFloat(t.opacity)),null!=t.viewport&&(this.viewport=f(t.viewport),k.normalViewport&&(this.viewport.y=this.canvas.height-this.viewport.y-this.viewport.height),this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null==this.viewport&&(this.viewport={x:0,y:0,width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight},this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null!=t.kerning&&(this.kerning=t.kerning),null!=t.offset&&("number"==typeof t.offset&&(t.offset=[t.offset,0]),this.positionOffset=y(t.offset)),t.direction&&(this.direction=t.direction),t.range&&(this.range=t.range,this.scale=[1/(t.range[2]-t.range[0]),1/(t.range[3]-t.range[1])],this.translate=[-t.range[0],-t.range[1]]),t.scale&&(this.scale=t.scale),t.translate&&(this.translate=t.translate),this.scale||(this.scale=[1/this.viewport.width,1/this.viewport.height]),this.translate||(this.translate=[0,0]),this.font.length||t.font||(t.font=k.baseFontSize+"px sans-serif");var r,a=!1,o=!1;if(t.font&&(Array.isArray(t.font)?t.font:[t.font]).forEach(function(t,r){if("string"==typeof t)try{t=n.parse(t)}catch(e){t=n.parse(k.baseFontSize+"px "+t)}else t=n.parse(n.stringify(t));var i=n.stringify({size:k.baseFontSize,family:t.family,stretch:_?t.stretch:void 0,variant:t.variant,weight:t.weight,style:t.style}),s=p(t.size),l=Math.round(s[0]*d(s[1]));if(l!==e.fontSize[r]&&(o=!0,e.fontSize[r]=l),!(e.font[r]&&i==e.font[r].baseString||(a=!0,e.font[r]=k.fonts[i],e.font[r]))){var c=t.family.join(", "),u=[t.style];t.style!=t.variant&&u.push(t.variant),t.variant!=t.weight&&u.push(t.weight),_&&t.weight!=t.stretch&&u.push(t.stretch),e.font[r]={baseString:i,family:c,weight:t.weight,stretch:t.stretch,style:t.style,variant:t.variant,width:{},kerning:{},metrics:m(c,{origin:"top",fontSize:k.baseFontSize,fontStyle:u.join(" ")})},k.fonts[i]=e.font[r]}}),(a||o)&&this.font.forEach(function(r,i){var a=n.stringify({size:e.fontSize[i],family:r.family,stretch:_?r.stretch:void 0,variant:r.variant,weight:r.weight,style:r.style});if(e.fontAtlas[i]=e.shader.atlas[a],!e.fontAtlas[i]){var o=r.metrics;e.shader.atlas[a]=e.fontAtlas[i]={fontString:a,step:2*Math.ceil(e.fontSize[i]*o.bottom*.5),em:e.fontSize[i],cols:0,rows:0,height:0,width:0,chars:[],ids:{},texture:e.regl.texture()}}null==t.text&&(t.text=e.text)}),"string"==typeof t.text&&t.position&&t.position.length>2){for(var s=Array(.5*t.position.length),h=0;h2){for(var w=!t.position[0].length,M=u.mallocFloat(2*this.count),A=0,T=0;A1?e.align[r]:e.align[0]:e.align;if("number"==typeof n)return n;switch(n){case"right":case"end":return-t;case"center":case"centre":case"middle":return.5*-t}return 0})),null==this.baseline&&null==t.baseline&&(t.baseline=0),null!=t.baseline&&(this.baseline=t.baseline,Array.isArray(this.baseline)||(this.baseline=[this.baseline]),this.baselineOffset=this.baseline.map(function(t,r){var n=(e.font[r]||e.font[0]).metrics,i=0;return i+=.5*n.bottom,i+="number"==typeof t?t-n.baseline:-n[t],k.normalViewport||(i*=-1),i})),null!=t.color)if(t.color||(t.color="transparent"),"string"!=typeof t.color&&isNaN(t.color)){var H;if("number"==typeof t.color[0]&&t.color.length>this.counts.length){var G=t.color.length;H=u.mallocUint8(G);for(var W=(t.color.subarray||t.color.slice).bind(t.color),Y=0;Y4||this.baselineOffset.length>1||this.align&&this.align.length>1||this.fontAtlas.length>1||this.positionOffset.length>2){var $=Math.max(.5*this.position.length||0,.25*this.color.length||0,this.baselineOffset.length||0,this.alignOffset.length||0,this.font.length||0,this.opacity.length||0,.5*this.positionOffset.length||0);this.batch=Array($);for(var J=0;J1?e.counts[J]:e.counts[0],offset:e.textOffsets.length>1?e.textOffsets[J]:e.textOffsets[0],color:e.color?e.color.length<=4?e.color:e.color.subarray(4*J,4*J+4):[0,0,0,255],opacity:Array.isArray(e.opacity)?e.opacity[J]:e.opacity,baseline:null!=e.baselineOffset[J]?e.baselineOffset[J]:e.baselineOffset[0],align:e.align?null!=e.alignOffset[J]?e.alignOffset[J]:e.alignOffset[0]:0,atlas:e.fontAtlas[J]||e.fontAtlas[0],positionOffset:e.positionOffset.length>2?e.positionOffset.subarray(2*J,2*J+2):e.positionOffset}}else this.count?this.batch=[{count:this.count,offset:0,color:this.color||[0,0,0,255],opacity:Array.isArray(this.opacity)?this.opacity[0]:this.opacity,baseline:this.baselineOffset[0],align:this.alignOffset?this.alignOffset[0]:0,atlas:this.fontAtlas[0],positionOffset:this.positionOffset}]:this.batch=[]},k.prototype.destroy=function(){},k.prototype.kerning=!0,k.prototype.position={constant:new Float32Array(2)},k.prototype.translate=null,k.prototype.scale=null,k.prototype.font=null,k.prototype.text="",k.prototype.positionOffset=[0,0],k.prototype.opacity=1,k.prototype.color=new Uint8Array([0,0,0,255]),k.prototype.alignOffset=[0,0],k.normalViewport=!1,k.maxAtlasSize=1024,k.atlasCanvas=document.createElement("canvas"),k.atlasContext=k.atlasCanvas.getContext("2d",{alpha:!1}),k.baseFontSize=64,k.fonts={},e.exports=k},{"bit-twiddle":80,"color-normalize":108,"css-font":127,"detect-kerning":151,"es6-weak-map":209,"flatten-vertex-data":216,"font-atlas":217,"font-measure":218,"gl-util/context":306,"is-plain-obj":405,"object-assign":437,"parse-rect":442,"parse-unit":444,"pick-by-alias":448,regl:478,"to-px":516,"typedarray-pool":522}],305:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("ndarray-ops"),a=t("typedarray-pool");e.exports=function(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");o||function(t){o=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],s=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],l=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}(t);if("number"==typeof arguments[1])return v(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return v(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1],r=c(e)?e:e.raw;if(r)return function(t,e,r,n,i,a){var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,i,i,a,e),new h(t,o,r,n,i,a)}(t,r,0|e.width,0|e.height,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return function(t,e){var r=e.dtype,o=e.shape.slice(),s=t.getParameter(t.MAX_TEXTURE_SIZE);if(o[0]<0||o[0]>s||o[1]<0||o[1]>s)throw new Error("gl-texture2d: Invalid texture size");var l=d(o,e.stride.slice()),c=0;"float32"===r?c=t.FLOAT:"float64"===r?(c=t.FLOAT,l=!1,r="float32"):"uint8"===r?c=t.UNSIGNED_BYTE:(c=t.UNSIGNED_BYTE,l=!1,r="uint8");var f,p,v=0;if(2===o.length)v=t.LUMINANCE,o=[o[0],o[1],1],e=n(e.data,o,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==o.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===o[2])v=t.ALPHA;else if(2===o[2])v=t.LUMINANCE_ALPHA;else if(3===o[2])v=t.RGB;else{if(4!==o[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}}c!==t.FLOAT||t.getExtension("OES_texture_float")||(c=t.UNSIGNED_BYTE,l=!1);var m=e.size;if(l)f=0===e.offset&&e.data.length===m?e.data:e.data.subarray(e.offset,e.offset+m);else{var y=[o[2],o[2]*o[0],1];p=a.malloc(m,r);var x=n(p,o,y,0);"float32"!==r&&"float64"!==r||c!==t.UNSIGNED_BYTE?i.assign(x,e):u(x,e),f=p.subarray(0,m)}var b=g(t);t.texImage2D(t.TEXTURE_2D,0,v,o[0],o[1],0,v,c,f),l||a.free(p);return new h(t,b,o[0],o[1],v,c)}(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")};var o=null,s=null,l=null;function c(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement||"undefined"!=typeof ImageData&&t instanceof ImageData}var u=function(t,e){i.muls(t,e,255)};function f(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(e<0||e>i||r<0||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function h(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}var p=h.prototype;function d(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function g(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function v(t,e,r,n,i){var a=t.getParameter(t.MAX_TEXTURE_SIZE);if(e<0||e>a||r<0||r>a)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new h(t,o,e,r,n,i)}Object.defineProperties(p,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=this.gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;e<2;++e)if(l.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return f(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return f(this,t|=0,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t|=0,f(this,this._shape[0],t),t}}}),p.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},p.dispose=function(){this.gl.deleteTexture(this.handle)},p.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},p.setPixels=function(t,e,r,o){var s=this.gl;this.bind(),Array.isArray(e)?(o=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),o=o||0;var l=c(t)?t:t.raw;if(l){this._mipLevels.indexOf(o)<0?(s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,this.type,l),this._mipLevels.push(o)):s.texSubImage2D(s.TEXTURE_2D,o,e,r,this.format,this.type,l)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>o||r+t.shape[0]>this._shape[0]>>>o||e<0||r<0)throw new Error("gl-texture2d: Texture dimensions are out of bounds");!function(t,e,r,o,s,l,c,f){var h=f.dtype,p=f.shape.slice();if(p.length<2||p.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var g=0,v=0,m=d(p,f.stride.slice());"float32"===h?g=t.FLOAT:"float64"===h?(g=t.FLOAT,m=!1,h="float32"):"uint8"===h?g=t.UNSIGNED_BYTE:(g=t.UNSIGNED_BYTE,m=!1,h="uint8");if(2===p.length)v=t.LUMINANCE,p=[p[0],p[1],1],f=n(f.data,p,[f.stride[0],f.stride[1],1],f.offset);else{if(3!==p.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===p[2])v=t.ALPHA;else if(2===p[2])v=t.LUMINANCE_ALPHA;else if(3===p[2])v=t.RGB;else{if(4!==p[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}p[2]}v!==t.LUMINANCE&&v!==t.ALPHA||s!==t.LUMINANCE&&s!==t.ALPHA||(v=s);if(v!==s)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=f.size,x=c.indexOf(o)<0;x&&c.push(o);if(g===l&&m)0===f.offset&&f.data.length===y?x?t.texImage2D(t.TEXTURE_2D,o,s,p[0],p[1],0,s,l,f.data):t.texSubImage2D(t.TEXTURE_2D,o,e,r,p[0],p[1],s,l,f.data):x?t.texImage2D(t.TEXTURE_2D,o,s,p[0],p[1],0,s,l,f.data.subarray(f.offset,f.offset+y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,p[0],p[1],s,l,f.data.subarray(f.offset,f.offset+y));else{var b;b=l===t.FLOAT?a.mallocFloat32(y):a.mallocUint8(y);var _=n(b,p,[p[2],p[2]*p[0],1]);g===t.FLOAT&&l===t.UNSIGNED_BYTE?u(_,f):i.assign(_,f),x?t.texImage2D(t.TEXTURE_2D,o,s,p[0],p[1],0,s,l,b.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,p[0],p[1],s,l,b.subarray(0,y)),l===t.FLOAT?a.freeFloat32(b):a.freeUint8(b)}}(s,e,r,o,this.format,this.type,this._mipLevels,t)}}},{ndarray:433,"ndarray-ops":427,"typedarray-pool":522}],306:[function(t,e,r){"use strict";var n=t("pick-by-alias");function i(t){if(t.container)if(t.container==document.body)document.body.style.width||(t.canvas.width=t.width||t.pixelRatio*window.innerWidth),document.body.style.height||(t.canvas.height=t.height||t.pixelRatio*window.innerHeight);else{var e=t.container.getBoundingClientRect();t.canvas.width=t.width||e.right-e.left,t.canvas.height=t.height||e.bottom-e.top}}function a(t){return"function"==typeof t.getContext&&"width"in t&&"height"in t}e.exports=function(t){var e;if(t?"string"==typeof t&&(t={container:t}):t={},a(t)?t={container:t}:t="string"==typeof(e=t).nodeName&&"function"==typeof e.appendChild&&"function"==typeof e.getBoundingClientRect?{container:t}:function(t){return"function"==typeof t.drawArrays||"function"==typeof t.drawElements}(t)?{gl:t}:n(t,{container:"container target element el canvas holder parent parentNode wrapper use ref root node",gl:"gl context webgl glContext",attrs:"attributes attrs contextAttributes",pixelRatio:"pixelRatio pxRatio px ratio pxratio pixelratio"},!0),t.pixelRatio||(t.pixelRatio=window.pixelRatio||1),t.gl)return t.gl;if(t.canvas&&(t.container=t.canvas.parentNode),t.container){if("string"==typeof t.container){var r=document.querySelector(t.container);if(!r)throw Error("Element "+t.container+" is not found");t.container=r}a(t.container)?(t.canvas=t.container,t.container=t.canvas.parentNode):t.canvas||(t.canvas=document.createElement("canvas"),t.container.appendChild(t.canvas),i(t))}else t.canvas||(t.container=document.body||document.documentElement,t.canvas=document.createElement("canvas"),t.canvas.style.position="absolute",t.canvas.style.top=0,t.canvas.style.left=0,t.container.appendChild(t.canvas),i(t));if(!t.gl)try{t.gl=t.canvas.getContext("webgl",t.attrs)}catch(e){try{t.gl=t.canvas.getContext("experimental-webgl",t.attrs)}catch(e){t.gl=t.canvas.getContext("webgl-experimental",t.attrs)}}return t.gl}},{"pick-by-alias":448}],307:[function(t,e,r){"use strict";e.exports=function(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;i1?0:Math.acos(s)};var n=t("./fromValues"),i=t("./normalize"),a=t("./dot")},{"./dot":322,"./fromValues":328,"./normalize":339}],313:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}},{}],314:[function(t,e,r){e.exports=function(t){var e=new Float32Array(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}},{}],315:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}},{}],316:[function(t,e,r){e.exports=function(){var t=new Float32Array(3);return t[0]=0,t[1]=0,t[2]=0,t}},{}],317:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}},{}],318:[function(t,e,r){e.exports=t("./distance")},{"./distance":319}],319:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}},{}],320:[function(t,e,r){e.exports=t("./divide")},{"./divide":321}],321:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}},{}],322:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}},{}],323:[function(t,e,r){e.exports=1e-6},{}],324:[function(t,e,r){e.exports=function(t,e){var r=t[0],i=t[1],a=t[2],o=e[0],s=e[1],l=e[2];return Math.abs(r-o)<=n*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-l)<=n*Math.max(1,Math.abs(a),Math.abs(l))};var n=t("./epsilon")},{"./epsilon":323}],325:[function(t,e,r){e.exports=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}},{}],326:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}},{}],327:[function(t,e,r){e.exports=function(t,e,r,i,a,o){var s,l;e||(e=3);r||(r=0);l=i?Math.min(i*e+r,t.length):t.length;for(s=r;s0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a);return t}},{}],340:[function(t,e,r){e.exports=function(t,e){e=e||1;var r=2*Math.random()*Math.PI,n=2*Math.random()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t}},{}],341:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[1],a=r[2],o=e[1]-i,s=e[2]-a,l=Math.sin(n),c=Math.cos(n);return t[0]=e[0],t[1]=i+o*c-s*l,t[2]=a+o*l+s*c,t}},{}],342:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[2],o=e[0]-i,s=e[2]-a,l=Math.sin(n),c=Math.cos(n);return t[0]=i+s*l+o*c,t[1]=e[1],t[2]=a+s*c-o*l,t}},{}],343:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[1],o=e[0]-i,s=e[1]-a,l=Math.sin(n),c=Math.cos(n);return t[0]=i+o*c-s*l,t[1]=a+o*l+s*c,t[2]=e[2],t}},{}],344:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}},{}],345:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}},{}],346:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}},{}],347:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}},{}],348:[function(t,e,r){e.exports=t("./squaredDistance")},{"./squaredDistance":350}],349:[function(t,e,r){e.exports=t("./squaredLength")},{"./squaredLength":351}],350:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}},{}],351:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}},{}],352:[function(t,e,r){e.exports=t("./subtract")},{"./subtract":353}],353:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}},{}],354:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}},{}],355:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t}},{}],356:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],c=r[3],u=c*n+s*a-l*i,f=c*i+l*n-o*a,h=c*a+o*i-s*n,p=-o*n-s*i-l*a;return t[0]=u*c+p*-o+f*-l-h*-s,t[1]=f*c+p*-s+h*-o-u*-l,t[2]=h*c+p*-l+u*-s-f*-o,t}},{}],357:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}},{}],358:[function(t,e,r){e.exports=function(t){var e=new Float32Array(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}},{}],359:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}},{}],360:[function(t,e,r){e.exports=function(){var t=new Float32Array(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}},{}],361:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+a*a)}},{}],362:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}},{}],363:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}},{}],364:[function(t,e,r){e.exports=function(t,e,r,n){var i=new Float32Array(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i}},{}],365:[function(t,e,r){e.exports={create:t("./create"),clone:t("./clone"),fromValues:t("./fromValues"),copy:t("./copy"),set:t("./set"),add:t("./add"),subtract:t("./subtract"),multiply:t("./multiply"),divide:t("./divide"),min:t("./min"),max:t("./max"),scale:t("./scale"),scaleAndAdd:t("./scaleAndAdd"),distance:t("./distance"),squaredDistance:t("./squaredDistance"),length:t("./length"),squaredLength:t("./squaredLength"),negate:t("./negate"),inverse:t("./inverse"),normalize:t("./normalize"),dot:t("./dot"),lerp:t("./lerp"),random:t("./random"),transformMat4:t("./transformMat4"),transformQuat:t("./transformQuat")}},{"./add":357,"./clone":358,"./copy":359,"./create":360,"./distance":361,"./divide":362,"./dot":363,"./fromValues":364,"./inverse":366,"./length":367,"./lerp":368,"./max":369,"./min":370,"./multiply":371,"./negate":372,"./normalize":373,"./random":374,"./scale":375,"./scaleAndAdd":376,"./set":377,"./squaredDistance":378,"./squaredLength":379,"./subtract":380,"./transformMat4":381,"./transformQuat":382}],366:[function(t,e,r){e.exports=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}},{}],367:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}},{}],368:[function(t,e,r){e.exports=function(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t[3]=s+n*(r[3]-s),t}},{}],369:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}},{}],370:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}},{}],371:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}},{}],372:[function(t,e,r){e.exports=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}},{}],373:[function(t,e,r){e.exports=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=a*o);return t}},{}],374:[function(t,e,r){var n=t("./normalize"),i=t("./scale");e.exports=function(t,e){return e=e||1,t[0]=Math.random(),t[1]=Math.random(),t[2]=Math.random(),t[3]=Math.random(),n(t,t),i(t,t,e),t}},{"./normalize":373,"./scale":375}],375:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}},{}],376:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}},{}],377:[function(t,e,r){e.exports=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}},{}],378:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a}},{}],379:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}},{}],380:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}},{}],381:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}},{}],382:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],c=r[3],u=c*n+s*a-l*i,f=c*i+l*n-o*a,h=c*a+o*i-s*n,p=-o*n-s*i-l*a;return t[0]=u*c+p*-o+f*-l-h*-s,t[1]=f*c+p*-s+h*-o-u*-l,t[2]=h*c+p*-l+u*-s-f*-o,t[3]=e[3],t}},{}],383:[function(t,e,r){e.exports=function(t,e,r,a){return n[0]=a,n[1]=r,n[2]=e,n[3]=t,i[0]};var n=new Uint8Array(4),i=new Float32Array(n.buffer)},{}],384:[function(t,e,r){var n=t("glsl-tokenizer"),i=t("atob-lite");e.exports=function(t){for(var e=Array.isArray(t)?t:n(t),r=0;r0)continue;r=t.slice(0,1).join("")}return B(r),z+=r.length,(S=S.slice(r.length)).length}}function H(){return/[^a-fA-F0-9]/.test(e)?(B(S.join("")),T=l,M):(S.push(e),r=e,M+1)}function G(){return"."===e?(S.push(e),T=g,r=e,M+1):/[eE]/.test(e)?(S.push(e),T=g,r=e,M+1):"x"===e&&1===S.length&&"0"===S[0]?(T=_,S.push(e),r=e,M+1):/[^\d]/.test(e)?(B(S.join("")),T=l,M):(S.push(e),r=e,M+1)}function W(){return"f"===e&&(S.push(e),r=e,M+=1),/[eE]/.test(e)?(S.push(e),r=e,M+1):"-"===e&&/[eE]/.test(r)?(S.push(e),r=e,M+1):/[^\d]/.test(e)?(B(S.join("")),T=l,M):(S.push(e),r=e,M+1)}function Y(){if(/[^\d\w_]/.test(e)){var t=S.join("");return T=R.indexOf(t)>-1?y:D.indexOf(t)>-1?m:v,B(S.join("")),T=l,M}return S.push(e),r=e,M+1}};var n=t("./lib/literals"),i=t("./lib/operators"),a=t("./lib/builtins"),o=t("./lib/literals-300es"),s=t("./lib/builtins-300es"),l=999,c=9999,u=0,f=1,h=2,p=3,d=4,g=5,v=6,m=7,y=8,x=9,b=10,_=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":387,"./lib/builtins-300es":386,"./lib/literals":389,"./lib/literals-300es":388,"./lib/operators":390}],386:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":387}],387:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],388:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":389}],389:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],390:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],391:[function(t,e,r){var n=t("./index");e.exports=function(t,e){var r=n(e),i=[];return i=(i=i.concat(r(t))).concat(r(null))}},{"./index":385}],392:[function(t,e,r){e.exports=function(t){"string"==typeof t&&(t=[t]);for(var e=[].slice.call(arguments,1),r=[],n=0;n>1,u=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+t[e+f],f+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),a-=c}return(p?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=u?(s=0,o=u):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*g}},{}],396:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(r<=i)throw new Error("Must input at least d+1 points");var o=t.slice(0,i+1),s=n.apply(void 0,o);if(0===s)throw new Error("Input not in general position");for(var l=new Array(i+1),u=0;u<=i;++u)l[u]=u;s<0&&(l[0]=1,l[1]=0);for(var f=new a(l,new Array(i+1),!1),h=f.adjacent,p=new Array(i+2),u=0;u<=i;++u){for(var d=l.slice(),g=0;g<=i;++g)g===u&&(d[g]=-1);var v=d[0];d[0]=d[1],d[1]=v;var m=new a(d,new Array(i+1),!0);h[u]=m,p[u]=m}p[i+1]=f;for(var u=0;u<=i;++u)for(var d=h[u].vertices,y=h[u].adjacent,g=0;g<=i;++g){var x=d[g];if(x<0)y[g]=f;else for(var b=0;b<=i;++b)h[b].vertices.indexOf(x)<0&&(y[g]=h[b])}for(var _=new c(i,o,p),w=!!e,u=i+1;u0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var i=new Function("test",e.join("")),a=n[t+1];return a||(a=n),i(a)}(t)),this.orient=a}var u=c.prototype;u.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){(t=o.pop()).vertices;for(var s=t.adjacent,l=0;l<=r;++l){var c=s[l];if(c.boundary&&!(c.lastVisited<=-n)){for(var u=c.vertices,f=0;f<=r;++f){var h=u[f];i[f]=h<0?e:a[h]}var p=this.orient();if(p>0)return c;c.lastVisited=-n,0===p&&o.push(c)}}}return null},u.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,c=s.adjacent,u=0;u<=n;++u)a[u]=i[l[u]];s.lastVisited=r;for(u=0;u<=n;++u){var f=c[u];if(!(f.lastVisited>=r)){var h=a[u];a[u]=t;var p=this.orient();if(a[u]=h,p<0){s=f;continue t}f.boundary?f.lastVisited=-r:f.lastVisited=r}}return}return s},u.addPeaks=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,l=this.tuple,c=this.interior,u=this.simplices,f=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,c.push(e);for(var h=[];f.length>0;){var p=(e=f.pop()).vertices,d=e.adjacent,g=p.indexOf(r);if(!(g<0))for(var v=0;v<=n;++v)if(v!==g){var m=d[v];if(m.boundary&&!(m.lastVisited>=r)){var y=m.vertices;if(m.lastVisited!==-r){for(var x=0,b=0;b<=n;++b)y[b]<0?(x=b,l[b]=t):l[b]=i[y[b]];if(this.orient()>0){y[x]=r,m.boundary=!1,c.push(m),f.push(m),m.lastVisited=r;continue}m.lastVisited=-r}var _=m.adjacent,w=p.slice(),k=d.slice(),M=new a(w,k,!0);u.push(M);var A=_.indexOf(e);if(!(A<0)){_[A]=M,k[g]=m,w[v]=-1,k[v]=e,d[v]=M,M.flip();for(b=0;b<=n;++b){var T=w[b];if(!(T<0||T===r)){for(var S=new Array(n-1),E=0,C=0;C<=n;++C){var L=w[C];L<0||C===b||(S[E++]=L)}h.push(new o(S,M,b))}}}}}}h.sort(s);for(v=0;v+1=0?o[l++]=s[u]:c=1&u;if(c===(1&t)){var f=o[0];o[0]=o[1],o[1]=f}e.push(o)}}return e}},{"robust-orientation":486,"simplicial-complex":496}],397:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=0,a=1;function o(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}e.exports=function(t){if(!t||0===t.length)return new x(null);return new x(y(t))};var s=o.prototype;function l(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function c(t,e){var r=y(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function u(t,e){var r=t.intervals([]);r.push(e),c(t,r)}function f(t,e){var r=t.intervals([]),n=r.indexOf(e);return n<0?i:(r.splice(n,1),c(t,r),a)}function h(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function d(t,e){for(var r=0;r>1],i=[],a=[],s=[];for(r=0;r3*(e+1)?u(this,t):this.left.insert(t):this.left=y([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?u(this,t):this.right.insert(t):this.right=y([t]);else{var r=n.ge(this.leftPoints,t,v),i=n.ge(this.rightPoints,t,m);this.leftPoints.splice(r,0,t),this.rightPoints.splice(i,0,t)}},s.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1)?f(this,t):2===(c=this.left.remove(t))?(this.left=null,this.count-=1,a):(c===a&&(this.count-=1),c):i;if(t[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(e-1)?f(this,t):2===(c=this.right.remove(t))?(this.right=null,this.count-=1,a):(c===a&&(this.count-=1),c):i;if(1===this.count)return this.leftPoints[0]===t?2:i;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var r=this,o=this.left;o.right;)r=o,o=o.right;if(r===this)o.right=this.right;else{var s=this.left,c=this.right;r.count-=o.count,r.right=o.left,o.left=s,o.right=c}l(this,o),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?l(this,this.left):l(this,this.right);return a}for(s=n.ge(this.leftPoints,t,v);sthis.mid){var r;if(this.right)if(r=this.right.queryPoint(t,e))return r;return p(this.rightPoints,t,e)}return d(this.leftPoints,e)},s.queryInterval=function(t,e,r){var n;if(tthis.mid&&this.right&&(n=this.right.queryInterval(t,e,r)))return n;return ethis.mid?p(this.rightPoints,t,r):d(this.leftPoints,r)};var b=x.prototype;b.insert=function(t){this.root?this.root.insert(t):this.root=new o(t[0],null,null,[t],[t])},b.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),e!==i}return!1},b.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},b.queryInterval=function(t,e,r){if(t<=e&&this.root)return this.root.queryInterval(t,e,r)},Object.defineProperty(b,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(b,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":79}],398:[function(t,e,r){"use strict";e.exports=function(t,e){e=e||new Array(t.length);for(var r=0;r13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],407:[function(t,e,r){"use strict";e.exports=function(t){return"string"==typeof t&&(t=t.trim(),!!(/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(t)&&/[\dz]$/i.test(t)&&t.length>4))}},{}],408:[function(t,e,r){e.exports=function(t,e,r){return t*(1-r)+e*r}},{}],409:[function(t,e,r){(function(t){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.mapboxgl=n()}(this,function(){"use strict";var e,r,n;function i(t,i){if(e)if(r){var a="var sharedChunk = {}; ("+e+")(sharedChunk); ("+r+")(sharedChunk);",o={};e(o),(n=i(o)).workerUrl=window.URL.createObjectURL(new Blob([a],{type:"text/javascript"}))}else r=i;else e=i}return i(0,function(e){var r="undefined"!=typeof window?window:"undefined"!=typeof t?t:"undefined"!=typeof self?self:{};function n(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t,e){return t(e={exports:{}},e.exports),e.exports}var a=o;function o(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=n,this.p2x=r,this.p2y=n}o.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},o.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},o.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},o.prototype.solveCurveX=function(t,e){var r,n,i,a,o;for(void 0===e&&(e=1e-6),i=t,o=0;o<8;o++){if(a=this.sampleCurveX(i)-t,Math.abs(a)(n=1))return n;for(;ra?r=i:n=i,i=.5*(n-r)+r}return i},o.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var s=function(t,e,r){this.column=t,this.row=e,this.zoom=r};s.prototype.clone=function(){return new s(this.column,this.row,this.zoom)},s.prototype.zoomTo=function(t){return this.clone()._zoomTo(t)},s.prototype.sub=function(t){return this.clone()._sub(t)},s.prototype._zoomTo=function(t){var e=Math.pow(2,t-this.zoom);return this.column*=e,this.row*=e,this.zoom=t,this},s.prototype._sub=function(t){return t=t.zoomTo(this.zoom),this.column-=t.column,this.row-=t.row,this};var l=c;function c(t,e){this.x=t,this.y=e}function u(t,e,r,n){var i=new a(t,e,r,n);return function(t){return i.solve(t)}}c.prototype={clone:function(){return new c(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=e*this.x-r*this.y,i=r*this.x+e*this.y;return this.x=n,this.y=i,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.x+r*(this.x-e.x)-n*(this.y-e.y),a=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=i,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},c.convert=function(t){return t instanceof c?t:Array.isArray(t)?new c(t[0],t[1]):t};var f=u(.25,.1,.25,1);function h(t,e,r){return Math.min(r,Math.max(e,t))}function p(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];for(var n=0,i=e;n(e.y-t.y)*(r.x-t.x)}function k(t){for(var e=0,r=0,n=t.length,i=n-1,a=void 0,o=void 0;r=200&&r.status<300&&r.response?e(null,{data:n,cacheControl:r.getResponseHeader("Cache-Control"),expires:r.getResponseHeader("Expires")}):e(new A(r.statusText,r.status,t.url))},r.send(),r};function E(t,e,r){r[t]=r[t]||[],r[t].push(e)}function C(t,e,r){if(r&&r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}var L=function(t,e){void 0===e&&(e={}),p(this,e),this.type=t},z=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,"error",p({error:e},r))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(L),O=function(){};O.prototype.on=function(t,e){return this._listeners=this._listeners||{},E(t,e,this._listeners),this},O.prototype.off=function(t,e){return C(t,e,this._listeners),C(t,e,this._oneTimeListeners),this},O.prototype.once=function(t,e){return this._oneTimeListeners=this._oneTimeListeners||{},E(t,e,this._oneTimeListeners),this},O.prototype.fire=function(t){"string"==typeof t&&(t=new L(t,arguments[1]||{}));var e=t.type;if(this.listens(e)){t.target=this;for(var r=0,n=this._listeners&&this._listeners[e]?this._listeners[e].slice():[];r0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)},O.prototype.setEventedParent=function(t,e){return this._eventedParent=t,this._eventedParentData=e,this};var I={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},buffer:{type:"number",default:128,maximum:512,minimum:0},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},lineMetrics:{type:"boolean",default:!1}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_fill:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_circle:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_line:{"line-cap":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{butt:{},round:{},square:{}},default:"butt"},"line-join":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{bevel:{},round:{},miter:{}},default:"miter"},"line-miter-limit":{type:"number",default:2,function:"interpolated","zoom-function":!0,requires:[{"line-join":"miter"}]},"line-round-limit":{type:"number",default:1.05,function:"interpolated","zoom-function":!0,requires:[{"line-join":"round"}]},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_symbol:{"symbol-placement":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{point:{},line:{}},default:"point"},"symbol-spacing":{type:"number",default:250,minimum:1,function:"interpolated","zoom-function":!0,units:"pixels",requires:[{"symbol-placement":"line"}]},"symbol-avoid-edges":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1},"icon-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image"]},"icon-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image"]},"icon-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image","text-field"]},"icon-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"]},"icon-size":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,units:"factor of the original icon size",requires:["icon-image"]},"icon-text-fit":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"]},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",function:"interpolated","zoom-function":!0,requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}]},"icon-image":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,tokens:!0},"icon-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,"property-function":!0,units:"degrees",requires:["icon-image"]},"icon-padding":{type:"number",default:2,minimum:0,function:"interpolated","zoom-function":!0,units:"pixels",requires:["icon-image"]},"icon-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":"line"}]},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,requires:["icon-image"]},"icon-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"]},"icon-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"]},"text-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"]},"text-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"]},"text-field":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:"",tokens:!0},"text-font":{type:"array",value:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"]},"text-size":{type:"number",default:16,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-line-height":{type:"number",default:1.2,units:"ems",function:"interpolated","zoom-function":!0,requires:["text-field"]},"text-letter-spacing":{type:"number",default:0,units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-justify":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{left:{},center:{},right:{}},default:"center",requires:["text-field"]},"text-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field"]},"text-max-angle":{type:"number",default:45,units:"degrees",function:"interpolated","zoom-function":!0,requires:["text-field",{"symbol-placement":"line"}]},"text-rotate":{type:"number",default:0,period:360,units:"degrees",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,requires:["text-field"]},"text-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":"line"}]},"text-transform":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"]},"text-offset":{type:"array",value:"number",units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,length:2,default:[0,0],requires:["text-field"]},"text-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field"]},"text-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field"]},"text-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field","icon-image"]},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function_stop:{type:"array",minimum:0,maximum:22,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},expression_name:{type:"enum",values:{let:{group:"Variable binding"},var:{group:"Variable binding"},literal:{group:"Types"},array:{group:"Types"},at:{group:"Lookup"},case:{group:"Decision"},match:{group:"Decision"},coalesce:{group:"Decision"},step:{group:"Ramps, scales, curves"},interpolate:{group:"Ramps, scales, curves"},ln2:{group:"Math"},pi:{group:"Math"},e:{group:"Math"},typeof:{group:"Types"},string:{group:"Types"},number:{group:"Types"},boolean:{group:"Types"},object:{group:"Types"},collator:{group:"Types"},"to-string":{group:"Types"},"to-number":{group:"Types"},"to-boolean":{group:"Types"},"to-rgba":{group:"Color"},"to-color":{group:"Types"},rgb:{group:"Color"},rgba:{group:"Color"},get:{group:"Lookup"},has:{group:"Lookup"},length:{group:"Lookup"},properties:{group:"Feature data"},"geometry-type":{group:"Feature data"},id:{group:"Feature data"},zoom:{group:"Zoom"},"heatmap-density":{group:"Heatmap"},"line-progress":{group:"Heatmap"},"+":{group:"Math"},"*":{group:"Math"},"-":{group:"Math"},"/":{group:"Math"},"%":{group:"Math"},"^":{group:"Math"},sqrt:{group:"Math"},log10:{group:"Math"},ln:{group:"Math"},log2:{group:"Math"},sin:{group:"Math"},cos:{group:"Math"},tan:{group:"Math"},asin:{group:"Math"},acos:{group:"Math"},atan:{group:"Math"},min:{group:"Math"},max:{group:"Math"},round:{group:"Math"},abs:{group:"Math"},ceil:{group:"Math"},floor:{group:"Math"},"==":{group:"Decision"},"!=":{group:"Decision"},">":{group:"Decision"},"<":{group:"Decision"},">=":{group:"Decision"},"<=":{group:"Decision"},all:{group:"Decision"},any:{group:"Decision"},"!":{group:"Decision"},"is-supported-script":{group:"String"},upcase:{group:"String"},downcase:{group:"String"},concat:{group:"String"},"resolved-locale":{group:"String"}}},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},transition:!1,"zoom-function":!0,"property-function":!1,function:"piecewise-constant"},position:{type:"array",default:[1.15,210,30],length:3,value:"number",transition:!0,function:"interpolated","zoom-function":!0,"property-function":!1},color:{type:"color",default:"#ffffff",function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0},intensity:{type:"number",default:.5,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!0},"fill-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"fill-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"}]},"fill-outline-color":{type:"color",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}]},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"fill-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["fill-translate"]},"fill-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0}},paint_line:{"line-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"line-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"line-pattern"}]},"line-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"line-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["line-translate"]},"line-width":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-gap-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-offset":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-dasharray":{type:"array",value:"number",function:"piecewise-constant","zoom-function":!0,minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}]},"line-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"line-gradient":{type:"color",function:"interpolated","zoom-function":!1,"property-function":!1,transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}]}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-blur":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"circle-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["circle-translate"]},"circle-pitch-scale":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map"},"circle-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"viewport"},"circle-stroke-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-stroke-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"heatmap-weight":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!1},"heatmap-intensity":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],function:"interpolated","zoom-function":!1,"property-function":!1,transition:!1},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"]},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"]}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-hue-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,transition:!0,units:"degrees"},"raster-brightness-min":{type:"number",function:"interpolated","zoom-function":!0,default:0,minimum:0,maximum:1,transition:!0},"raster-brightness-max":{type:"number",function:"interpolated","zoom-function":!0,default:1,minimum:0,maximum:1,transition:!0},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-fade-duration":{type:"number",default:300,minimum:0,function:"interpolated","zoom-function":!0,transition:!1,units:"milliseconds"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,function:"interpolated","zoom-function":!0,transition:!1},"hillshade-illumination-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"viewport"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"hillshade-shadow-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",function:"interpolated","zoom-function":!0,transition:!0},"hillshade-accent-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0}},paint_background:{"background-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0,requires:[{"!":"background-pattern"}]},"background-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!1,default:1,minimum:0,maximum:1,transition:!0},"fill-extrusion-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-extrusion-pattern"}]},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"fill-extrusion-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"]},"fill-extrusion-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"fill-extrusion-height":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:0,minimum:0,units:"meters",transition:!0},"fill-extrusion-base":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"]}}},P=function(t,e,r,n){this.message=(t?t+": ":"")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)};function D(t){var e=t.key,r=t.value;return r?[new P(e,r,"constants have been deprecated as of v8")]:[]}function R(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];for(var n=0,i=e;n":"value"===t.itemType.kind?"array":"array<"+e+">"}return t.kind}var J=[V,U,q,H,G,W,Z(Y)];function K(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&!K(t.itemType,e.itemType)&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(var r=0,n=J;r255?255:t}function i(t){return t<0?0:t>1?1:t}function a(t){return"%"===t[t.length-1]?n(parseFloat(t)/100*255):n(parseInt(t))}function o(t){return"%"===t[t.length-1]?i(parseFloat(t)/100):i(parseFloat(t))}function s(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{e.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in r)return r[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=i.indexOf("("),c=i.indexOf(")");if(-1!==l&&c+1===i.length){var u=i.substr(0,l),f=i.substr(l+1,c-(l+1)).split(","),h=1;switch(u){case"rgba":if(4!==f.length)return null;h=o(f.pop());case"rgb":return 3!==f.length?null:[a(f[0]),a(f[1]),a(f[2]),h];case"hsla":if(4!==f.length)return null;h=o(f.pop());case"hsl":if(3!==f.length)return null;var p=(parseFloat(f[0])%360+360)%360/360,d=o(f[1]),g=o(f[2]),v=g<=.5?g*(d+1):g+d-g*d,m=2*g-v;return[n(255*s(m,v,p+1/3)),n(255*s(m,v,p)),n(255*s(m,v,p-1/3)),h];default:return null}}return null}}catch(t){}}).parseCSSColor,tt=function(t,e,r,n){void 0===n&&(n=1),this.r=t,this.g=e,this.b=r,this.a=n};tt.parse=function(t){if(t){if(t instanceof tt)return t;if("string"==typeof t){var e=Q(t);if(e)return new tt(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3])}}},tt.prototype.toString=function(){var t=this.toArray(),e=t[0],r=t[1],n=t[2],i=t[3];return"rgba("+Math.round(e)+","+Math.round(r)+","+Math.round(n)+","+i+")"},tt.prototype.toArray=function(){var t=this.r,e=this.g,r=this.b,n=this.a;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*r/n,n]},tt.black=new tt(0,0,0,1),tt.white=new tt(1,1,1,1),tt.transparent=new tt(0,0,0,0);var et=function(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})};et.prototype.compare=function(t,e){return this.collator.compare(t,e)},et.prototype.resolvedLocale=function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale};var rt=function(t,e,r){this.type=X,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e};function nt(t,e,r,n){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:"Invalid rgba value ["+[t,e,r,n].join(", ")+"]: 'a' must be between 0 and 1.":"Invalid rgba value ["+("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")+"]: 'r', 'g', and 'b' must be between 0 and 255."}function it(t){if(null===t)return V;if("string"==typeof t)return q;if("boolean"==typeof t)return H;if("number"==typeof t)return U;if(t instanceof tt)return G;if(t instanceof et)return X;if(Array.isArray(t)){for(var e,r=t.length,n=0,i=t;n4)return e.error("Expected 1, 2, or 3 arguments, but found "+(t.length-1)+" instead.");var r,n;if(t.length>2){var i=t[1];if("string"!=typeof i||!(i in ct))return e.error('The item type argument of "array" must be one of string, number, boolean',1);r=ct[i]}else r=Y;if(t.length>3){if("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2]))return e.error('The length argument to "array" must be a positive integer literal',2);n=t[2]}var a=Z(r,n),o=e.parse(t[t.length-1],t.length-1,Y);return o?new ut(a,o):null},ut.prototype.evaluate=function(t){var e=this.input.evaluate(t);if(K(this.type,it(e)))throw new ot("Expected value to be of type "+$(this.type)+", but found "+$(it(e))+" instead.");return e},ut.prototype.eachChild=function(t){t(this.input)},ut.prototype.possibleOutputs=function(){return this.input.possibleOutputs()},ut.prototype.serialize=function(){var t=["array"],e=this.type.itemType;if("string"===e.kind||"number"===e.kind||"boolean"===e.kind){t.push(e.kind);var r=this.type.N;"number"==typeof r&&t.push(r)}return t.push(this.input.serialize()),t};var ft={"to-number":U,"to-color":G},ht=function(t,e){this.type=t,this.args=e};ht.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");for(var r=t[0],n=ft[r],i=[],a=1;a4?"Invalid rbga value "+JSON.stringify(e)+": expected an array containing either three or four numeric values.":nt(e[0],e[1],e[2],e[3])))return new tt(e[0]/255,e[1]/255,e[2]/255,e[3]);throw new ot(r||"Could not parse color from value '"+("string"==typeof e?e:JSON.stringify(e))+"'")}for(var o=null,s=0,l=this.args;s=0)return!1;var r=!0;return t.eachChild(function(t){r&&!mt(t,e)&&(r=!1)}),r}gt.prototype.evaluate=function(t){return this._evaluate(t,this.args)},gt.prototype.eachChild=function(t){this.args.forEach(t)},gt.prototype.possibleOutputs=function(){return[void 0]},gt.prototype.serialize=function(){return[this.name].concat(this.args.map(function(t){return t.serialize()}))},gt.parse=function(t,e){var r=t[0],n=gt.definitions[r];if(!n)return e.error('Unknown expression "'+r+'". If you wanted a literal array, use ["literal", [...]].',0);for(var i=Array.isArray(n)?n[0]:n.type,a=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,o=a.filter(function(e){var r=e[0];return!Array.isArray(r)||r.length===t.length-1}),s=[],l=1;lr&&ee))throw new ot("Input is not a number.");a=o-1}}return Math.max(o-1,0)}xt.prototype.parse=function(t,e,r,n,i){return void 0===i&&(i={}),e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)},xt.prototype._parse=function(t,e){if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var r=t[0];if("string"!=typeof r)return this.error("Expression name must be a string, but found "+typeof r+' instead. If you wanted a literal array, use ["literal", [...]].',0),null;var n=this.registry[r];if(n){var i=n.parse(t,this);if(!i)return null;if(this.expectedType){var a=this.expectedType,o=i.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind||"value"!==o.kind)if("array"===a.kind&&"value"===o.kind)e.omitTypeAnnotations||(i=new ut(a,i));else if("color"!==a.kind||"value"!==o.kind&&"string"!==o.kind){if(this.checkSubtype(this.expectedType,i.type))return null}else e.omitTypeAnnotations||(i=new ht(a,[i]));else e.omitTypeAnnotations||(i=new lt(a,[i]))}if(!(i instanceof at)&&function t(e){if(e instanceof yt)return t(e.boundExpression);if(e instanceof gt&&"error"===e.name)return!1;if(e instanceof rt)return!1;var r=e instanceof ht||e instanceof lt||e instanceof ut,n=!0;return e.eachChild(function(e){n=r?n&&t(e):n&&e instanceof at}),!!n&&(vt(e)&&mt(e,["zoom","heatmap-density","line-progress","is-supported-script"]))}(i)){var s=new dt;try{i=new at(i.type,i.evaluate(s))}catch(t){return this.error(t.message),null}}return i}return this.error('Unknown expression "'+r+'". If you wanted a literal array, use ["literal", [...]].',0)}return void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error("Expected an array, but found "+typeof t+" instead.")},xt.prototype.concat=function(t,e,r){var n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new xt(this.registry,n,e||null,i,this.errors)},xt.prototype.error=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];var n=""+this.key+e.map(function(t){return"["+t+"]"}).join("");this.errors.push(new N(n,t))},xt.prototype.checkSubtype=function(t,e){var r=K(t,e);return r&&this.error(r),r};var _t=function(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(var n=0,i=r;n=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',c);var f=e.parse(l,u,a);if(!f)return null;a=a||f.type,i.push([s,f])}return new _t(a,r,i)},_t.prototype.evaluate=function(t){var e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);var n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);var i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[bt(e,n)].evaluate(t)},_t.prototype.eachChild=function(t){t(this.input);for(var e=0,r=this.outputs;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t};var kt=Object.freeze({number:wt,color:function(t,e,r){return new tt(wt(t.r,e.r,r),wt(t.g,e.g,r),wt(t.b,e.b,r),wt(t.a,e.a,r))},array:function(t,e,r){return t.map(function(t,n){return wt(t,e[n],r)})}}),Mt=function(t,e,r,n){this.type=t,this.interpolation=e,this.input=r,this.labels=[],this.outputs=[];for(var i=0,a=n;i1}))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:o}}if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(!(n=e.parse(n,2,U)))return null;var s=[],l=null;e.expectedType&&"value"!==e.expectedType.kind&&(l=e.expectedType);for(var c=0;c=u)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',h);var d=e.parse(f,p,l);if(!d)return null;l=l||d.type,s.push([u,d])}return"number"===l.kind||"color"===l.kind||"array"===l.kind&&"number"===l.itemType.kind&&"number"==typeof l.N?new Mt(l,r,n,s):e.error("Type "+$(l)+" is not interpolatable.")},Mt.prototype.evaluate=function(t){var e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);var n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);var i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);var a=bt(e,n),o=e[a],s=e[a+1],l=Mt.interpolationFactor(this.interpolation,n,o,s),c=r[a].evaluate(t),u=r[a+1].evaluate(t);return kt[this.type.kind.toLowerCase()](c,u,l)},Mt.prototype.eachChild=function(t){t(this.input);for(var e=0,r=this.outputs;e=r.length)throw new ot("Array index out of bounds: "+e+" > "+(r.length-1)+".");if(e!==Math.floor(e))throw new ot("Array index must be an integer, but found "+e+" instead.");return r[e]},Et.prototype.eachChild=function(t){t(this.index),t(this.input)},Et.prototype.possibleOutputs=function(){return[void 0]},Et.prototype.serialize=function(){return["at",this.index.serialize(),this.input.serialize()]};var Ct=function(t,e,r,n,i,a){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=a};Ct.parse=function(t,e){if(t.length<5)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if(t.length%2!=1)return e.error("Expected an even number of arguments.");var r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(var i={},a=[],o=2;oNumber.MAX_SAFE_INTEGER)return c.error("Branch labels must be integers no larger than "+Number.MAX_SAFE_INTEGER+".");if("number"==typeof h&&Math.floor(h)!==h)return c.error("Numeric branch labels must be integer values.");if(r){if(c.checkSubtype(r,it(h)))return null}else r=it(h);if(void 0!==i[String(h)])return c.error("Branch labels must be unique.");i[String(h)]=a.length}var p=e.parse(l,o,n);if(!p)return null;n=n||p.type,a.push(p)}var d=e.parse(t[1],1,r);if(!d)return null;var g=e.parse(t[t.length-1],t.length-1,n);return g?new Ct(r,n,d,i,a,g):null},Ct.prototype.evaluate=function(t){var e=this.input.evaluate(t);return(this.outputs[this.cases[e]]||this.otherwise).evaluate(t)},Ct.prototype.eachChild=function(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)},Ct.prototype.possibleOutputs=function(){return(t=[]).concat.apply(t,this.outputs.map(function(t){return t.possibleOutputs()})).concat(this.otherwise.possibleOutputs());var t},Ct.prototype.serialize=function(){for(var t=this,e=["match",this.input.serialize()],r=[],n={},i=0,a=Object.keys(this.cases).sort();in.evaluate(t)}function Ut(t,e){var r=e[0],n=e[1];return r.evaluate(t)<=n.evaluate(t)}function qt(t,e){var r=e[0],n=e[1];return r.evaluate(t)>=n.evaluate(t)}function Ht(t){return{type:t}}function Gt(t){return{result:"success",value:t}}function Wt(t){return{result:"error",value:t}}gt.register(Rt,{error:[{kind:"error"},[q],function(t,e){var r=e[0];throw new ot(r.evaluate(t))}],typeof:[q,[Y],function(t,e){return $(it(e[0].evaluate(t)))}],"to-string":[q,[Y],function(t,e){var r=e[0],n=typeof(r=r.evaluate(t));return null===r?"":"string"===n||"number"===n||"boolean"===n?String(r):r instanceof tt?r.toString():JSON.stringify(r)}],"to-boolean":[H,[Y],function(t,e){var r=e[0];return Boolean(r.evaluate(t))}],"to-rgba":[Z(U,4),[G],function(t,e){return e[0].evaluate(t).toArray()}],rgb:[G,[U,U,U],Bt],rgba:[G,[U,U,U,U],Bt],has:{type:H,overloads:[[[q],function(t,e){return Ft(e[0].evaluate(t),t.properties())}],[[q,W],function(t,e){var r=e[0],n=e[1];return Ft(r.evaluate(t),n.evaluate(t))}]]},get:{type:Y,overloads:[[[q],function(t,e){return Nt(e[0].evaluate(t),t.properties())}],[[q,W],function(t,e){var r=e[0],n=e[1];return Nt(r.evaluate(t),n.evaluate(t))}]]},properties:[W,[],function(t){return t.properties()}],"geometry-type":[q,[],function(t){return t.geometryType()}],id:[Y,[],function(t){return t.id()}],zoom:[U,[],function(t){return t.globals.zoom}],"heatmap-density":[U,[],function(t){return t.globals.heatmapDensity||0}],"line-progress":[U,[],function(t){return t.globals.lineProgress||0}],"+":[U,Ht(U),function(t,e){for(var r=0,n=0,i=e;n":[H,[q,Y],function(t,e){var r=e[0],n=e[1],i=t.properties()[r.value],a=n.value;return typeof i==typeof a&&i>a}],"filter-id->":[H,[Y],function(t,e){var r=e[0],n=t.id(),i=r.value;return typeof n==typeof i&&n>i}],"filter-<=":[H,[q,Y],function(t,e){var r=e[0],n=e[1],i=t.properties()[r.value],a=n.value;return typeof i==typeof a&&i<=a}],"filter-id-<=":[H,[Y],function(t,e){var r=e[0],n=t.id(),i=r.value;return typeof n==typeof i&&n<=i}],"filter->=":[H,[q,Y],function(t,e){var r=e[0],n=e[1],i=t.properties()[r.value],a=n.value;return typeof i==typeof a&&i>=a}],"filter-id->=":[H,[Y],function(t,e){var r=e[0],n=t.id(),i=r.value;return typeof n==typeof i&&n>=i}],"filter-has":[H,[Y],function(t,e){return e[0].value in t.properties()}],"filter-has-id":[H,[],function(t){return null!==t.id()}],"filter-type-in":[H,[Z(q)],function(t,e){return e[0].value.indexOf(t.geometryType())>=0}],"filter-id-in":[H,[Z(Y)],function(t,e){return e[0].value.indexOf(t.id())>=0}],"filter-in-small":[H,[q,Z(Y)],function(t,e){var r=e[0];return e[1].value.indexOf(t.properties()[r.value])>=0}],"filter-in-large":[H,[q,Z(Y)],function(t,e){var r=e[0],n=e[1];return function(t,e,r,n){for(;r<=n;){var i=r+n>>1;if(e[i]===t)return!0;e[i]>t?n=i-1:r=i+1}return!1}(t.properties()[r.value],n.value,0,n.value.length-1)}],">":{type:H,overloads:[[[U,U],Vt],[[q,q],Vt],[[q,q,X],function(t,e){var r=e[0],n=e[1];return e[2].evaluate(t).compare(r.evaluate(t),n.evaluate(t))>0}]]},"<":{type:H,overloads:[[[U,U],jt],[[q,q],jt],[[q,q,X],function(t,e){var r=e[0],n=e[1];return e[2].evaluate(t).compare(r.evaluate(t),n.evaluate(t))<0}]]},">=":{type:H,overloads:[[[U,U],qt],[[q,q],qt],[[q,q,X],function(t,e){var r=e[0],n=e[1];return e[2].evaluate(t).compare(r.evaluate(t),n.evaluate(t))>=0}]]},"<=":{type:H,overloads:[[[U,U],Ut],[[q,q],Ut],[[q,q,X],function(t,e){var r=e[0],n=e[1];return e[2].evaluate(t).compare(r.evaluate(t),n.evaluate(t))<=0}]]},all:{type:H,overloads:[[[H,H],function(t,e){var r=e[0],n=e[1];return r.evaluate(t)&&n.evaluate(t)}],[Ht(H),function(t,e){for(var r=0,n=e;rQt?Math.pow(t,1/3):t/Kt+$t}function ne(t){return t>Jt?t*t*t:Kt*(t-$t)}function ie(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function ae(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function oe(t){var e=ae(t.r),r=ae(t.g),n=ae(t.b),i=re((.4124564*e+.3575761*r+.1804375*n)/Yt),a=re((.2126729*e+.7151522*r+.072175*n)/Xt);return{l:116*a-16,a:500*(i-a),b:200*(a-re((.0193339*e+.119192*r+.9503041*n)/Zt)),alpha:t.a}}function se(t){var e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=Xt*ne(e),r=Yt*ne(r),n=Zt*ne(n),new tt(ie(3.2404542*r-1.5371385*e-.4985314*n),ie(-.969266*r+1.8760108*e+.041556*n),ie(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}var le={forward:oe,reverse:se,interpolate:function(t,e,r){return{l:wt(t.l,e.l,r),a:wt(t.a,e.a,r),b:wt(t.b,e.b,r),alpha:wt(t.alpha,e.alpha,r)}}},ce={forward:function(t){var e=oe(t),r=e.l,n=e.a,i=e.b,a=Math.atan2(i,n)*ee;return{h:a<0?a+360:a,c:Math.sqrt(n*n+i*i),l:r,alpha:t.a}},reverse:function(t){var e=t.h*te,r=t.c;return se({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return{h:function(t,e,r){var n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}(t.h,e.h,r),c:wt(t.c,e.c,r),l:wt(t.l,e.l,r),alpha:wt(t.alpha,e.alpha,r)}}},ue=Object.freeze({lab:le,hcl:ce});function fe(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function he(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function pe(t){return t}function de(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function ge(t,e,r,n,i){return de(typeof r===i?n[r]:void 0,t.default,e.default)}function ve(t,e,r){if("number"!==fe(r))return de(t.default,e.default);var n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];var i=xe(t.stops,r);return t.stops[i][1]}function me(t,e,r){var n=void 0!==t.base?t.base:1;if("number"!==fe(r))return de(t.default,e.default);var i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];var a=xe(t.stops,r),o=function(t,e,r,n){var i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[a][0],t.stops[a+1][0]),s=t.stops[a][1],l=t.stops[a+1][1],c=kt[e.type]||pe;if(t.colorSpace&&"rgb"!==t.colorSpace){var u=ue[t.colorSpace];c=function(t,e){return u.reverse(u.interpolate(u.forward(t),u.forward(e),o))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=s.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==r&&void 0!==n)return c(r,n,o)}}:c(s,l,o)}function ye(t,e,r){return"color"===e.type?r=tt.parse(r):fe(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0),de(r,t.default,e.default)}function xe(t,e){for(var r,n,i=0,a=t.length-1,o=0;i<=a;){if(r=t[o=Math.floor((i+a)/2)][0],n=t[o+1][0],e===r||e>r&&ee&&(a=o-1)}return Math.max(o-1,0)}var be=function(t,e){var r;this.expression=t,this._warningHistory={},this._defaultValue="color"===(r=e).type&&he(r.default)?new tt(0,0,0,0):"color"===r.type?tt.parse(r.default)||null:void 0===r.default?null:r.default,"enum"===e.type&&(this._enumValues=e.values)};function _e(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Rt}function we(t,e){var r=new xt(Rt,[],function(t){var e={color:G,string:q,number:U,enum:q,boolean:H};return"array"===t.type?Z(e[t.value]||Y,t.length):e[t.type]||null}(e)),n=r.parse(t);return n?Gt(new be(n,e)):Wt(r.errors)}be.prototype.evaluateWithoutErrorHandling=function(t,e){return this._evaluator||(this._evaluator=new dt),this._evaluator.globals=t,this._evaluator.feature=e,this.expression.evaluate(this._evaluator)},be.prototype.evaluate=function(t,e){this._evaluator||(this._evaluator=new dt),this._evaluator.globals=t,this._evaluator.feature=e;try{var r=this.expression.evaluate(this._evaluator);if(null==r)return this._defaultValue;if(this._enumValues&&!(r in this._enumValues))throw new ot("Expected value to be one of "+Object.keys(this._enumValues).map(function(t){return JSON.stringify(t)}).join(", ")+", but found "+JSON.stringify(r)+" instead.");return r}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}};var ke=function(t,e){this.kind=t,this._styleExpression=e};ke.prototype.evaluateWithoutErrorHandling=function(t,e){return this._styleExpression.evaluateWithoutErrorHandling(t,e)},ke.prototype.evaluate=function(t,e){return this._styleExpression.evaluate(t,e)};var Me=function(t,e,r){this.kind=t,this.zoomStops=r.labels,this._styleExpression=e,r instanceof Mt&&(this._interpolationType=r.interpolation)};function Ae(t,e){if("error"===(t=we(t,e)).result)return t;var r=t.value.expression,n=vt(r);if(!n&&!e["property-function"])return Wt([new N("","property expressions not supported")]);var i=mt(r,["zoom"]);if(!i&&!1===e["zoom-function"])return Wt([new N("","zoom expressions not supported")]);var a=function t(e){var r=null;if(e instanceof St)r=t(e.result);else if(e instanceof Tt)for(var n=0,i=e.args;nn.maximum?[new P(e,r,r+" is greater than the maximum value "+n.maximum)]:[]}function ze(t){var e,r,n,i=t.valueSpec,a=B(t.value.type),o={},s="categorical"!==a&&void 0===t.value.property,l=!s,c="array"===fe(t.value.stops)&&"array"===fe(t.value.stops[0])&&"object"===fe(t.value.stops[0][0]),u=Ee({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===a)return[new P(t.key,t.value,'identity function may not have a "stops" property')];var e=[],r=t.value;return e=e.concat(Ce({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),"array"===fe(r)&&0===r.length&&e.push(new P(t.key,r,"array must have at least one stop")),e},default:function(t){return Ke({key:t.key,value:t.value,valueSpec:i,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===a&&s&&u.push(new P(t.key,t.value,'missing required property "property"')),"identity"===a||t.value.stops||u.push(new P(t.key,t.value,'missing required property "stops"')),"exponential"===a&&"piecewise-constant"===t.valueSpec.function&&u.push(new P(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!t.valueSpec["property-function"]?u.push(new P(t.key,t.value,"property functions not supported")):s&&!t.valueSpec["zoom-function"]&&"heatmap-color"!==t.objectKey&&"line-gradient"!==t.objectKey&&u.push(new P(t.key,t.value,"zoom functions not supported"))),"categorical"!==a&&!c||void 0!==t.value.property||u.push(new P(t.key,t.value,'"property" property is required')),u;function f(t){var e=[],a=t.value,s=t.key;if("array"!==fe(a))return[new P(s,a,"array expected, "+fe(a)+" found")];if(2!==a.length)return[new P(s,a,"array length 2 expected, length "+a.length+" found")];if(c){if("object"!==fe(a[0]))return[new P(s,a,"object expected, "+fe(a[0])+" found")];if(void 0===a[0].zoom)return[new P(s,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new P(s,a,"object stop key must have value")];if(n&&n>B(a[0].zoom))return[new P(s,a[0].zoom,"stop zoom values must appear in ascending order")];B(a[0].zoom)!==n&&(n=B(a[0].zoom),r=void 0,o={}),e=e.concat(Ee({key:s+"[0]",value:a[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Le,value:h}}))}else e=e.concat(h({key:s+"[0]",value:a[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},a));return e.concat(Ke({key:s+"[1]",value:a[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function h(t,n){var s=fe(t.value),l=B(t.value),c=null!==t.value?t.value:n;if(e){if(s!==e)return[new P(t.key,c,s+" stop domain type must match previous stop domain type "+e)]}else e=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new P(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==a){var u="number expected, "+s+" found";return i["property-function"]&&void 0===a&&(u+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new P(t.key,c,u)]}return"categorical"!==a||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==a&&"number"===s&&void 0!==r&&l=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3===t.length&&(Array.isArray(t[1])||Array.isArray(t[2]));case"any":case"all":for(var e=0,r=t.slice(1);ee?1:0}function Fe(t){if(!t)return!0;var e,r=t[0];return t.length<=1?"any"!==r:"=="===r?Ne(t[1],t[2],"=="):"!="===r?Ue(Ne(t[1],t[2],"==")):"<"===r||">"===r||"<="===r||">="===r?Ne(t[1],t[2],r):"any"===r?(e=t.slice(1),["any"].concat(e.map(Fe))):"all"===r?["all"].concat(t.slice(1).map(Fe)):"none"===r?["all"].concat(t.slice(1).map(Fe).map(Ue)):"in"===r?je(t[1],t.slice(2)):"!in"===r?Ue(je(t[1],t.slice(2))):"has"===r?Ve(t[1]):"!has"!==r||Ue(Ve(t[1]))}function Ne(t,e,r){switch(t){case"$type":return["filter-type-"+r,e];case"$id":return["filter-id-"+r,e];default:return["filter-"+r,t,e]}}function je(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(function(t){return typeof t!=typeof e[0]})?["filter-in-large",t,["literal",e.sort(Be)]]:["filter-in-small",t,["literal",e]]}}function Ve(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Ue(t){return["!",t]}function qe(t){return Pe(F(t.value))?Oe(R({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):function t(e){var r=e.value,n=e.key;if("array"!==fe(r))return[new P(n,r,"array expected, "+fe(r)+" found")];var i,a=e.styleSpec,o=[];if(r.length<1)return[new P(n,r,"filter array must have at least 1 element")];switch(o=o.concat(Ie({key:n+"[0]",value:r[0],valueSpec:a.filter_operator,style:e.style,styleSpec:e.styleSpec})),B(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&"$type"===B(r[1])&&o.push(new P(n,r,'"$type" cannot be use with operator "'+r[0]+'"'));case"==":case"!=":3!==r.length&&o.push(new P(n,r,'filter array for operator "'+r[0]+'" must have 3 elements'));case"in":case"!in":r.length>=2&&"string"!==(i=fe(r[1]))&&o.push(new P(n+"[1]",r[1],"string expected, "+i+" found"));for(var s=2;s=c[h+0]&&n>=c[h+1]?(o[f]=!0,a.push(l[f])):o[f]=!1}}},ur.prototype._forEachCell=function(t,e,r,n,i,a,o){for(var s=this._convertToCellCoord(t),l=this._convertToCellCoord(e),c=this._convertToCellCoord(r),u=this._convertToCellCoord(n),f=s;f<=c;f++)for(var h=l;h<=u;h++){var p=this.d*h+f;if(i.call(this,t,e,r,n,p,a,o))return}},ur.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},ur.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=cr+this.cells.length+1+1,r=0,n=0;n=0)){var f=t[u];c[u]=hr[l].shallow.indexOf(u)>=0?f:gr(f,e)}t instanceof Error&&(c.message=t.message)}return{name:l,properties:c}}throw new Error("can't serialize object of type "+typeof t)}function vr(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof fr)return t;if(Array.isArray(t))return t.map(function(t){return vr(t)});if("object"==typeof t){var e=t,r=e.name,n=e.properties;if(!r)throw new Error("can't deserialize object of anonymous class");var i=hr[r].klass;if(!i)throw new Error("can't deserialize unregistered class "+r);if(i.deserialize)return i.deserialize(n._serialized);for(var a=Object.create(i.prototype),o=0,s=Object.keys(n);o=0?n[l]:vr(n[l])}return a}throw new Error("can't deserialize object of type "+typeof t)}var mr=function(){this.first=!0};mr.prototype.update=function(t,e){var r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoom=128&&t<=255},Arabic:function(t){return t>=1536&&t<=1791},"Arabic Supplement":function(t){return t>=1872&&t<=1919},"Arabic Extended-A":function(t){return t>=2208&&t<=2303},"Hangul Jamo":function(t){return t>=4352&&t<=4607},"Unified Canadian Aboriginal Syllabics":function(t){return t>=5120&&t<=5759},Khmer:function(t){return t>=6016&&t<=6143},"Unified Canadian Aboriginal Syllabics Extended":function(t){return t>=6320&&t<=6399},"General Punctuation":function(t){return t>=8192&&t<=8303},"Letterlike Symbols":function(t){return t>=8448&&t<=8527},"Number Forms":function(t){return t>=8528&&t<=8591},"Miscellaneous Technical":function(t){return t>=8960&&t<=9215},"Control Pictures":function(t){return t>=9216&&t<=9279},"Optical Character Recognition":function(t){return t>=9280&&t<=9311},"Enclosed Alphanumerics":function(t){return t>=9312&&t<=9471},"Geometric Shapes":function(t){return t>=9632&&t<=9727},"Miscellaneous Symbols":function(t){return t>=9728&&t<=9983},"Miscellaneous Symbols and Arrows":function(t){return t>=11008&&t<=11263},"CJK Radicals Supplement":function(t){return t>=11904&&t<=12031},"Kangxi Radicals":function(t){return t>=12032&&t<=12255},"Ideographic Description Characters":function(t){return t>=12272&&t<=12287},"CJK Symbols and Punctuation":function(t){return t>=12288&&t<=12351},Hiragana:function(t){return t>=12352&&t<=12447},Katakana:function(t){return t>=12448&&t<=12543},Bopomofo:function(t){return t>=12544&&t<=12591},"Hangul Compatibility Jamo":function(t){return t>=12592&&t<=12687},Kanbun:function(t){return t>=12688&&t<=12703},"Bopomofo Extended":function(t){return t>=12704&&t<=12735},"CJK Strokes":function(t){return t>=12736&&t<=12783},"Katakana Phonetic Extensions":function(t){return t>=12784&&t<=12799},"Enclosed CJK Letters and Months":function(t){return t>=12800&&t<=13055},"CJK Compatibility":function(t){return t>=13056&&t<=13311},"CJK Unified Ideographs Extension A":function(t){return t>=13312&&t<=19903},"Yijing Hexagram Symbols":function(t){return t>=19904&&t<=19967},"CJK Unified Ideographs":function(t){return t>=19968&&t<=40959},"Yi Syllables":function(t){return t>=40960&&t<=42127},"Yi Radicals":function(t){return t>=42128&&t<=42191},"Hangul Jamo Extended-A":function(t){return t>=43360&&t<=43391},"Hangul Syllables":function(t){return t>=44032&&t<=55215},"Hangul Jamo Extended-B":function(t){return t>=55216&&t<=55295},"Private Use Area":function(t){return t>=57344&&t<=63743},"CJK Compatibility Ideographs":function(t){return t>=63744&&t<=64255},"Arabic Presentation Forms-A":function(t){return t>=64336&&t<=65023},"Vertical Forms":function(t){return t>=65040&&t<=65055},"CJK Compatibility Forms":function(t){return t>=65072&&t<=65103},"Small Form Variants":function(t){return t>=65104&&t<=65135},"Arabic Presentation Forms-B":function(t){return t>=65136&&t<=65279},"Halfwidth and Fullwidth Forms":function(t){return t>=65280&&t<=65519}};function xr(t){for(var e=0,r=t;e=65097&&t<=65103)||yr["CJK Compatibility Ideographs"](t)||yr["CJK Compatibility"](t)||yr["CJK Radicals Supplement"](t)||yr["CJK Strokes"](t)||!(!yr["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||yr["CJK Unified Ideographs Extension A"](t)||yr["CJK Unified Ideographs"](t)||yr["Enclosed CJK Letters and Months"](t)||yr["Hangul Compatibility Jamo"](t)||yr["Hangul Jamo Extended-A"](t)||yr["Hangul Jamo Extended-B"](t)||yr["Hangul Jamo"](t)||yr["Hangul Syllables"](t)||yr.Hiragana(t)||yr["Ideographic Description Characters"](t)||yr.Kanbun(t)||yr["Kangxi Radicals"](t)||yr["Katakana Phonetic Extensions"](t)||yr.Katakana(t)&&12540!==t||!(!yr["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!yr["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||yr["Unified Canadian Aboriginal Syllabics"](t)||yr["Unified Canadian Aboriginal Syllabics Extended"](t)||yr["Vertical Forms"](t)||yr["Yijing Hexagram Symbols"](t)||yr["Yi Syllables"](t)||yr["Yi Radicals"](t)))}function wr(t){return!(_r(t)||function(t){return!!(yr["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||yr["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||yr["Letterlike Symbols"](t)||yr["Number Forms"](t)||yr["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||yr["Control Pictures"](t)&&9251!==t||yr["Optical Character Recognition"](t)||yr["Enclosed Alphanumerics"](t)||yr["Geometric Shapes"](t)||yr["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||yr["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||yr["CJK Symbols and Punctuation"](t)||yr.Katakana(t)||yr["Private Use Area"](t)||yr["CJK Compatibility Forms"](t)||yr["Small Form Variants"](t)||yr["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function kr(t,e){return!(!e&&(t>=1424&&t<=2303||yr["Arabic Presentation Forms-A"](t)||yr["Arabic Presentation Forms-B"](t))||t>=2304&&t<=3583||t>=3840&&t<=4255||yr.Khmer(t))}var Mr,Ar=!1,Tr=null,Sr=!1,Er=new O,Cr={applyArabicShaping:null,processBidirectionalText:null,isLoaded:function(){return Sr||null!=Cr.applyArabicShaping}},Lr=function(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new mr,this.transition={})};Lr.prototype.isSupportedScript=function(t){return function(t,e){for(var r=0,n=t;rthis.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(e=1)return 1;var e=i*i,r=e*i;return 4*(i<.5?r:3*(i-e)+r-.75)}())}return r};var Dr=function(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)};Dr.prototype.possiblyEvaluate=function(t){for(var e=new Fr(this._properties),r=0,n=Object.keys(this._values);rn.zoomHistory.lastIntegerZoom?{from:t,to:e,fromScale:2,toScale:1,t:a+(1-a)*o}:{from:r,to:e,fromScale:.5,toScale:1,t:1-(1-o)*a}},Vr.prototype.interpolate=function(t){return t};var Ur=function(t){this.specification=t};Ur.prototype.possiblyEvaluate=function(t,e){return!!t.expression.evaluate(e)},Ur.prototype.interpolate=function(){return!1};var qr=function(t){for(var e in this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},t){var r=t[e],n=this.defaultPropertyValues[e]=new zr(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new Or(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({})}};pr("DataDrivenProperty",jr),pr("DataConstantProperty",Nr),pr("CrossFadedProperty",Vr),pr("ColorRampProperty",Ur);var Hr=function(t){function e(e,r){for(var n in t.call(this),this.id=e.id,this.metadata=e.metadata,this.type=e.type,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,this.visibility="visible","background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),this._featureFilter=function(){return!0},r.layout&&(this._unevaluatedLayout=new Rr(r.layout)),this._transitionablePaint=new Ir(r.paint),e.paint)this.setPaintProperty(n,e.paint[n],{validate:!1});for(var i in e.layout)this.setLayoutProperty(i,e.layout[i],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getLayoutProperty=function(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)},e.prototype.setLayoutProperty=function(t,e,r){if(null!=e){var n="layers."+this.id+".layout."+t;if(this._validate(or,n,t,e,r))return}"visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility="none"===e?e:"visible"},e.prototype.getPaintProperty=function(t){return v(t,"-transition")?this._transitionablePaint.getTransition(t.slice(0,-"-transition".length)):this._transitionablePaint.getValue(t)},e.prototype.setPaintProperty=function(t,e,r){if(null!=e){var n="layers."+this.id+".paint."+t;if(this._validate(ar,n,t,e,r))return}v(t,"-transition")?this._transitionablePaint.setTransition(t.slice(0,-"-transition".length),e||void 0):this._transitionablePaint.setValue(t,e)},e.prototype.isHidden=function(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility},e.prototype.updateTransitions=function(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)},e.prototype.hasTransition=function(){return this._transitioningPaint.hasTransition()},e.prototype.recalculate=function(t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t)),this.paint=this._transitioningPaint.possiblyEvaluate(t)},e.prototype.serialize=function(){var t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return"none"===this.visibility&&(t.layout=t.layout||{},t.layout.visibility="none"),y(t,function(t,e){return!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)})},e.prototype._validate=function(t,e,r,n,i){return(!i||!1!==i.validate)&&sr(this,t.call(nr,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:I,style:{glyphs:!0,sprite:!0}}))},e.prototype.hasOffscreenPass=function(){return!1},e.prototype.resize=function(){},e}(O),Gr={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},Wr=function(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8},Yr=function(){this.isTransferred=!1,this.capacity=-1,this.resize(0)};function Xr(t,e){void 0===e&&(e=1);var r=0,n=0;return{members:t.map(function(t){var i,a=(i=t.type,Gr[i].BYTES_PER_ELEMENT),o=r=Zr(r,Math.max(e,a)),s=t.components||1;return n=Math.max(n,a),r+=a*s,{name:t.name,type:t.type,components:s,offset:o}}),size:Zr(r,Math.max(n,e)),alignment:e}}function Zr(t,e){return Math.ceil(t/e)*e}Yr.serialize=function(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}},Yr.deserialize=function(t){var e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e},Yr.prototype._trim=function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())},Yr.prototype.clear=function(){this.length=0},Yr.prototype.resize=function(t){this.reserve(t),this.length=t},Yr.prototype.reserve=function(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}},Yr.prototype._refreshViews=function(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")};var $r=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;this.resize(r+1);var n=2*r;return this.int16[n+0]=t,this.int16[n+1]=e,r},e}(Yr);$r.prototype.bytesPerElement=4,pr("StructArrayLayout2i4",$r);var Jr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n){var i=this.length;this.resize(i+1);var a=4*i;return this.int16[a+0]=t,this.int16[a+1]=e,this.int16[a+2]=r,this.int16[a+3]=n,i},e}(Yr);Jr.prototype.bytesPerElement=8,pr("StructArrayLayout4i8",Jr);var Kr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a){var o=this.length;this.resize(o+1);var s=6*o;return this.int16[s+0]=t,this.int16[s+1]=e,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=i,this.int16[s+5]=a,o},e}(Yr);Kr.prototype.bytesPerElement=12,pr("StructArrayLayout2i4i12",Kr);var Qr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s){var l=this.length;this.resize(l+1);var c=6*l,u=12*l;return this.int16[c+0]=t,this.int16[c+1]=e,this.int16[c+2]=r,this.int16[c+3]=n,this.uint8[u+8]=i,this.uint8[u+9]=a,this.uint8[u+10]=o,this.uint8[u+11]=s,l},e}(Yr);Qr.prototype.bytesPerElement=12,pr("StructArrayLayout4i4ub12",Qr);var tn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s){var l=this.length;this.resize(l+1);var c=8*l;return this.int16[c+0]=t,this.int16[c+1]=e,this.int16[c+2]=r,this.int16[c+3]=n,this.uint16[c+4]=i,this.uint16[c+5]=a,this.uint16[c+6]=o,this.uint16[c+7]=s,l},e}(Yr);tn.prototype.bytesPerElement=16,pr("StructArrayLayout4i4ui16",tn);var en=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;this.resize(n+1);var i=3*n;return this.float32[i+0]=t,this.float32[i+1]=e,this.float32[i+2]=r,n},e}(Yr);en.prototype.bytesPerElement=12,pr("StructArrayLayout3f12",en);var rn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;this.resize(e+1);var r=1*e;return this.uint32[r+0]=t,e},e}(Yr);rn.prototype.bytesPerElement=4,pr("StructArrayLayout1ul4",rn);var nn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s,l,c,u){var f=this.length;this.resize(f+1);var h=12*f,p=6*f;return this.int16[h+0]=t,this.int16[h+1]=e,this.int16[h+2]=r,this.int16[h+3]=n,this.int16[h+4]=i,this.int16[h+5]=a,this.uint32[p+3]=o,this.uint16[h+8]=s,this.uint16[h+9]=l,this.int16[h+10]=c,this.int16[h+11]=u,f},e}(Yr);nn.prototype.bytesPerElement=24,pr("StructArrayLayout6i1ul2ui2i24",nn);var an=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a){var o=this.length;this.resize(o+1);var s=6*o;return this.int16[s+0]=t,this.int16[s+1]=e,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=i,this.int16[s+5]=a,o},e}(Yr);an.prototype.bytesPerElement=12,pr("StructArrayLayout2i2i2i12",an);var on=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;this.resize(r+1);var n=4*r;return this.uint8[n+0]=t,this.uint8[n+1]=e,r},e}(Yr);on.prototype.bytesPerElement=4,pr("StructArrayLayout2ub4",on);var sn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s,l,c,u,f,h,p){var d=this.length;this.resize(d+1);var g=20*d,v=10*d,m=40*d;return this.int16[g+0]=t,this.int16[g+1]=e,this.uint16[g+2]=r,this.uint16[g+3]=n,this.uint32[v+2]=i,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[g+10]=s,this.uint16[g+11]=l,this.uint16[g+12]=c,this.float32[v+7]=u,this.float32[v+8]=f,this.uint8[m+36]=h,this.uint8[m+37]=p,d},e}(Yr);sn.prototype.bytesPerElement=40,pr("StructArrayLayout2i2ui3ul3ui2f2ub40",sn);var ln=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;this.resize(e+1);var r=1*e;return this.float32[r+0]=t,e},e}(Yr);ln.prototype.bytesPerElement=4,pr("StructArrayLayout1f4",ln);var cn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;this.resize(n+1);var i=3*n;return this.int16[i+0]=t,this.int16[i+1]=e,this.int16[i+2]=r,n},e}(Yr);cn.prototype.bytesPerElement=6,pr("StructArrayLayout3i6",cn);var un=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;this.resize(n+1);var i=2*n,a=4*n;return this.uint32[i+0]=t,this.uint16[a+2]=e,this.uint16[a+3]=r,n},e}(Yr);un.prototype.bytesPerElement=8,pr("StructArrayLayout1ul2ui8",un);var fn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;this.resize(n+1);var i=3*n;return this.uint16[i+0]=t,this.uint16[i+1]=e,this.uint16[i+2]=r,n},e}(Yr);fn.prototype.bytesPerElement=6,pr("StructArrayLayout3ui6",fn);var hn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;this.resize(r+1);var n=2*r;return this.uint16[n+0]=t,this.uint16[n+1]=e,r},e}(Yr);hn.prototype.bytesPerElement=4,pr("StructArrayLayout2ui4",hn);var pn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;this.resize(r+1);var n=2*r;return this.float32[n+0]=t,this.float32[n+1]=e,r},e}(Yr);pn.prototype.bytesPerElement=8,pr("StructArrayLayout2f8",pn);var dn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n){var i=this.length;this.resize(i+1);var a=4*i;return this.float32[a+0]=t,this.float32[a+1]=e,this.float32[a+2]=r,this.float32[a+3]=n,i},e}(Yr);dn.prototype.bytesPerElement=16,pr("StructArrayLayout4f16",dn);var gn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={anchorPointX:{configurable:!0},anchorPointY:{configurable:!0},x1:{configurable:!0},y1:{configurable:!0},x2:{configurable:!0},y2:{configurable:!0},featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0},radius:{configurable:!0},signedDistanceFromAnchor:{configurable:!0},anchorPoint:{configurable:!0}};return r.anchorPointX.get=function(){return this._structArray.int16[this._pos2+0]},r.anchorPointX.set=function(t){this._structArray.int16[this._pos2+0]=t},r.anchorPointY.get=function(){return this._structArray.int16[this._pos2+1]},r.anchorPointY.set=function(t){this._structArray.int16[this._pos2+1]=t},r.x1.get=function(){return this._structArray.int16[this._pos2+2]},r.x1.set=function(t){this._structArray.int16[this._pos2+2]=t},r.y1.get=function(){return this._structArray.int16[this._pos2+3]},r.y1.set=function(t){this._structArray.int16[this._pos2+3]=t},r.x2.get=function(){return this._structArray.int16[this._pos2+4]},r.x2.set=function(t){this._structArray.int16[this._pos2+4]=t},r.y2.get=function(){return this._structArray.int16[this._pos2+5]},r.y2.set=function(t){this._structArray.int16[this._pos2+5]=t},r.featureIndex.get=function(){return this._structArray.uint32[this._pos4+3]},r.featureIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},r.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+8]},r.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+8]=t},r.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+9]},r.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+9]=t},r.radius.get=function(){return this._structArray.int16[this._pos2+10]},r.radius.set=function(t){this._structArray.int16[this._pos2+10]=t},r.signedDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+11]},r.signedDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+11]=t},r.anchorPoint.get=function(){return new l(this.anchorPointX,this.anchorPointY)},Object.defineProperties(e.prototype,r),e}(Wr);gn.prototype.size=24;var vn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new gn(this,t)},e}(nn);pr("CollisionBoxArray",vn);var mn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={anchorX:{configurable:!0},anchorY:{configurable:!0},glyphStartIndex:{configurable:!0},numGlyphs:{configurable:!0},vertexStartIndex:{configurable:!0},lineStartIndex:{configurable:!0},lineLength:{configurable:!0},segment:{configurable:!0},lowerSize:{configurable:!0},upperSize:{configurable:!0},lineOffsetX:{configurable:!0},lineOffsetY:{configurable:!0},writingMode:{configurable:!0},hidden:{configurable:!0}};return r.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},r.anchorX.set=function(t){this._structArray.int16[this._pos2+0]=t},r.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},r.anchorY.set=function(t){this._structArray.int16[this._pos2+1]=t},r.glyphStartIndex.get=function(){return this._structArray.uint16[this._pos2+2]},r.glyphStartIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},r.numGlyphs.get=function(){return this._structArray.uint16[this._pos2+3]},r.numGlyphs.set=function(t){this._structArray.uint16[this._pos2+3]=t},r.vertexStartIndex.get=function(){return this._structArray.uint32[this._pos4+2]},r.vertexStartIndex.set=function(t){this._structArray.uint32[this._pos4+2]=t},r.lineStartIndex.get=function(){return this._structArray.uint32[this._pos4+3]},r.lineStartIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},r.lineLength.get=function(){return this._structArray.uint32[this._pos4+4]},r.lineLength.set=function(t){this._structArray.uint32[this._pos4+4]=t},r.segment.get=function(){return this._structArray.uint16[this._pos2+10]},r.segment.set=function(t){this._structArray.uint16[this._pos2+10]=t},r.lowerSize.get=function(){return this._structArray.uint16[this._pos2+11]},r.lowerSize.set=function(t){this._structArray.uint16[this._pos2+11]=t},r.upperSize.get=function(){return this._structArray.uint16[this._pos2+12]},r.upperSize.set=function(t){this._structArray.uint16[this._pos2+12]=t},r.lineOffsetX.get=function(){return this._structArray.float32[this._pos4+7]},r.lineOffsetX.set=function(t){this._structArray.float32[this._pos4+7]=t},r.lineOffsetY.get=function(){return this._structArray.float32[this._pos4+8]},r.lineOffsetY.set=function(t){this._structArray.float32[this._pos4+8]=t},r.writingMode.get=function(){return this._structArray.uint8[this._pos1+36]},r.writingMode.set=function(t){this._structArray.uint8[this._pos1+36]=t},r.hidden.get=function(){return this._structArray.uint8[this._pos1+37]},r.hidden.set=function(t){this._structArray.uint8[this._pos1+37]=t},Object.defineProperties(e.prototype,r),e}(Wr);mn.prototype.size=40;var yn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new mn(this,t)},e}(sn);pr("PlacedSymbolArray",yn);var xn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={offsetX:{configurable:!0}};return r.offsetX.get=function(){return this._structArray.float32[this._pos4+0]},r.offsetX.set=function(t){this._structArray.float32[this._pos4+0]=t},Object.defineProperties(e.prototype,r),e}(Wr);xn.prototype.size=4;var bn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getoffsetX=function(t){return this.float32[1*t+0]},e.prototype.get=function(t){return new xn(this,t)},e}(ln);pr("GlyphOffsetArray",bn);var _n=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={x:{configurable:!0},y:{configurable:!0},tileUnitDistanceFromAnchor:{configurable:!0}};return r.x.get=function(){return this._structArray.int16[this._pos2+0]},r.x.set=function(t){this._structArray.int16[this._pos2+0]=t},r.y.get=function(){return this._structArray.int16[this._pos2+1]},r.y.set=function(t){this._structArray.int16[this._pos2+1]=t},r.tileUnitDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+2]},r.tileUnitDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+2]=t},Object.defineProperties(e.prototype,r),e}(Wr);_n.prototype.size=6;var wn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getx=function(t){return this.int16[3*t+0]},e.prototype.gety=function(t){return this.int16[3*t+1]},e.prototype.gettileUnitDistanceFromAnchor=function(t){return this.int16[3*t+2]},e.prototype.get=function(t){return new _n(this,t)},e}(cn);pr("SymbolLineVertexArray",wn);var kn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0}};return r.featureIndex.get=function(){return this._structArray.uint32[this._pos4+0]},r.featureIndex.set=function(t){this._structArray.uint32[this._pos4+0]=t},r.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+2]},r.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},r.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+3]},r.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+3]=t},Object.defineProperties(e.prototype,r),e}(Wr);kn.prototype.size=8;var Mn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new kn(this,t)},e}(un);pr("FeatureIndexArray",Mn);var An=Xr([{name:"a_pos",components:2,type:"Int16"}],4).members,Tn=function(t){void 0===t&&(t=[]),this.segments=t};Tn.prototype.prepareSegment=function(t,e,r){var n=this.segments[this.segments.length-1];return t>Tn.MAX_VERTEX_ARRAY_LENGTH&&_("Max vertices per segment is "+Tn.MAX_VERTEX_ARRAY_LENGTH+": bucket requested "+t),(!n||n.vertexLength+t>Tn.MAX_VERTEX_ARRAY_LENGTH)&&(n={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},this.segments.push(n)),n},Tn.prototype.get=function(){return this.segments},Tn.prototype.destroy=function(){for(var t=0,e=this.segments;tRn.max||o.yRn.max)&&_("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return r}function Fn(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2)}var Nn=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(function(t){return t.id}),this.index=t.index,this.layoutVertexArray=new $r,this.indexArray=new fn,this.segments=new Tn,this.programConfigurations=new In(An,t.layers,t.zoom)};function jn(t,e,r){for(var n=0;n=3)for(var s=0;s1){if(Hn(t,e))return!0;for(var n=0;n1?t.distSqr(r):t.distSqr(r.sub(e)._mult(i)._add(e))}function Xn(t,e){for(var r,n,i,a=!1,o=0;oe.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(a=!a);return a}function Zn(t,e){for(var r=!1,n=0,i=t.length-1;ne.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}function $n(t,e,r){var n=e.paint.get(t).value;return"constant"===n.kind?n.value:r.programConfigurations.get(e.id).binders[t].statistics.max}function Jn(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Kn(t,e,r,n,i){if(!e[0]&&!e[1])return t;var a=l.convert(e);"viewport"===r&&a._rotate(-n);for(var o=[],s=0;s=Dn||l<0||l>=Dn)){var c=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray),u=c.vertexLength;Fn(this.layoutVertexArray,s,l,-1,-1),Fn(this.layoutVertexArray,s,l,1,-1),Fn(this.layoutVertexArray,s,l,1,1),Fn(this.layoutVertexArray,s,l,-1,1),this.indexArray.emplaceBack(u,u+1,u+2),this.indexArray.emplaceBack(u,u+3,u+2),c.vertexLength+=4,c.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t)},pr("CircleBucket",Nn,{omit:["layers"]});var Qn={paint:new qr({"circle-radius":new jr(I.paint_circle["circle-radius"]),"circle-color":new jr(I.paint_circle["circle-color"]),"circle-blur":new jr(I.paint_circle["circle-blur"]),"circle-opacity":new jr(I.paint_circle["circle-opacity"]),"circle-translate":new Nr(I.paint_circle["circle-translate"]),"circle-translate-anchor":new Nr(I.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Nr(I.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Nr(I.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new jr(I.paint_circle["circle-stroke-width"]),"circle-stroke-color":new jr(I.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new jr(I.paint_circle["circle-stroke-opacity"])})},ti=i(function(t,e){var r;t.exports=((r=new Float32Array(3))[0]=0,r[1]=0,r[2]=0,function(){var t=new Float32Array(4);t[0]=0,t[1]=0,t[2]=0,t[3]=0}(),{vec3:{transformMat3:function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}},vec4:{transformMat4:function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}},mat2:{create:function(){var t=new Float32Array(4);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},rotate:function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l+a*s,t[1]=i*l+o*s,t[2]=n*-s+a*l,t[3]=i*-s+o*l,t},scale:function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=r[0],l=r[1];return t[0]=n*s,t[1]=i*s,t[2]=a*l,t[3]=o*l,t}},mat3:{create:function(){var t=new Float32Array(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fromRotation:function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}},mat4:{create:function(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},translate:function(t,e,r){var n,i,a,o,s,l,c,u,f,h,p,d,g=r[0],v=r[1],m=r[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],p=e[10],d=e[11],t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=f,t[9]=h,t[10]=p,t[11]=d,t[12]=n*g+s*v+f*m+e[12],t[13]=i*g+l*v+h*m+e[13],t[14]=a*g+c*v+p*m+e[14],t[15]=o*g+u*v+d*m+e[15]),t},scale:function(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},multiply:function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],p=e[10],d=e[11],g=e[12],v=e[13],m=e[14],y=e[15],x=r[0],b=r[1],_=r[2],w=r[3];return t[0]=x*n+b*s+_*f+w*g,t[1]=x*i+b*l+_*h+w*v,t[2]=x*a+b*c+_*p+w*m,t[3]=x*o+b*u+_*d+w*y,x=r[4],b=r[5],_=r[6],w=r[7],t[4]=x*n+b*s+_*f+w*g,t[5]=x*i+b*l+_*h+w*v,t[6]=x*a+b*c+_*p+w*m,t[7]=x*o+b*u+_*d+w*y,x=r[8],b=r[9],_=r[10],w=r[11],t[8]=x*n+b*s+_*f+w*g,t[9]=x*i+b*l+_*h+w*v,t[10]=x*a+b*c+_*p+w*m,t[11]=x*o+b*u+_*d+w*y,x=r[12],b=r[13],_=r[14],w=r[15],t[12]=x*n+b*s+_*f+w*g,t[13]=x*i+b*l+_*h+w*v,t[14]=x*a+b*c+_*p+w*m,t[15]=x*o+b*u+_*d+w*y,t},perspective:function(t,e,r,n,i){var a=1/Math.tan(e/2),o=1/(n-i);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*o,t[15]=0,t},rotateX:function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+c*n,t[5]=o*i+u*n,t[6]=s*i+f*n,t[7]=l*i+h*n,t[8]=c*i-a*n,t[9]=u*i-o*n,t[10]=f*i-s*n,t[11]=h*i-l*n,t},rotateZ:function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+c*n,t[1]=o*i+u*n,t[2]=s*i+f*n,t[3]=l*i+h*n,t[4]=c*i-a*n,t[5]=u*i-o*n,t[6]=f*i-s*n,t[7]=h*i-l*n,t},invert:function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=e[9],h=e[10],p=e[11],d=e[12],g=e[13],v=e[14],m=e[15],y=r*s-n*o,x=r*l-i*o,b=r*c-a*o,_=n*l-i*s,w=n*c-a*s,k=i*c-a*l,M=u*g-f*d,A=u*v-h*d,T=u*m-p*d,S=f*v-h*g,E=f*m-p*g,C=h*m-p*v,L=y*C-x*E+b*S+_*T-w*A+k*M;return L?(L=1/L,t[0]=(s*C-l*E+c*S)*L,t[1]=(i*E-n*C-a*S)*L,t[2]=(g*k-v*w+m*_)*L,t[3]=(h*w-f*k-p*_)*L,t[4]=(l*T-o*C-c*A)*L,t[5]=(r*C-i*T+a*A)*L,t[6]=(v*b-d*k-m*x)*L,t[7]=(u*k-h*b+p*x)*L,t[8]=(o*E-s*T+c*M)*L,t[9]=(n*T-r*E-a*M)*L,t[10]=(d*w-g*b+m*y)*L,t[11]=(f*b-u*w-p*y)*L,t[12]=(s*A-o*S-l*M)*L,t[13]=(r*S-n*A+i*M)*L,t[14]=(g*x-d*_-v*y)*L,t[15]=(u*_-f*x+h*y)*L,t):null},ortho:function(t,e,r,n,i,a,o){var s=1/(e-r),l=1/(n-i),c=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*l,t[14]=(o+a)*c,t[15]=1,t}}})}),ei=(ti.vec3,ti.vec4),ri=(ti.mat2,ti.mat3,ti.mat4),ni=function(t){function e(e){t.call(this,e,Qn)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createBucket=function(t){return new Nn(t)},e.prototype.queryRadius=function(t){var e=t;return $n("circle-radius",this,e)+$n("circle-stroke-width",this,e)+Jn(this.paint.get("circle-translate"))},e.prototype.queryIntersectsFeature=function(t,e,r,n,i,a,o){for(var s=Kn(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),i.angle,a),l=this.paint.get("circle-radius").evaluate(e)+this.paint.get("circle-stroke-width").evaluate(e),c="map"===this.paint.get("circle-pitch-alignment"),u=c?s:function(t,e,r){return s.map(function(t){return t.map(function(t){return ii(t,e,r)})})}(0,o,i),f=c?l*a:l,h=0,p=r;ht.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=t.data,s=e.data,l=0;l80*r){n=a=t[0],i=o=t[1];for(var d=r;da&&(a=s),l>o&&(o=l);c=0!==(c=Math.max(a-n,o-i))?1/c:0}return wi(h,p,r,n,i,c),p}function bi(t,e,r,n,i){var a,o;if(i===Vi(t,e,r,n)>0)for(a=e;a=e;a-=n)o=Fi(a,t[a],t[a+1],o);return o&&Pi(o,o.next)&&(Ni(o),o=o.next),o}function _i(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!Pi(n,n.next)&&0!==Ii(n.prev,n,n.next))n=n.next;else{if(Ni(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function wi(t,e,r,n,i,a,o){if(t){!o&&a&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=Ci(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,o,s,l,c=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,c*=2}while(o>1)}(i)}(t,n,i,a);for(var s,l,c=t;t.prev!==t.next;)if(s=t.prev,l=t.next,a?Mi(t,n,i,a):ki(t))e.push(s.i/r),e.push(t.i/r),e.push(l.i/r),Ni(t),t=l.next,c=l.next;else if((t=l)===c){o?1===o?wi(t=Ai(t,e,r),e,r,n,i,a,2):2===o&&Ti(t,e,r,n,i,a):wi(_i(t),e,r,n,i,a,1);break}}}function ki(t){var e=t.prev,r=t,n=t.next;if(Ii(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(zi(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&Ii(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Mi(t,e,r,n){var i=t.prev,a=t,o=t.next;if(Ii(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,f=Ci(s,l,e,r,n),h=Ci(c,u,e,r,n),p=t.prevZ,d=t.nextZ;p&&p.z>=f&&d&&d.z<=h;){if(p!==t.prev&&p!==t.next&&zi(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Ii(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,d!==t.prev&&d!==t.next&&zi(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Ii(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;p&&p.z>=f;){if(p!==t.prev&&p!==t.next&&zi(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Ii(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;d&&d.z<=h;){if(d!==t.prev&&d!==t.next&&zi(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Ii(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Ai(t,e,r){var n=t;do{var i=n.prev,a=n.next.next;!Pi(i,a)&&Di(i,n,n.next,a)&&Ri(i,a)&&Ri(a,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(a.i/r),Ni(n),Ni(n.next),n=t=a),n=n.next}while(n!==t);return n}function Ti(t,e,r,n,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Oi(o,s)){var l=Bi(o,s);return o=_i(o,o.next),l=_i(l,l.next),wi(o,e,r,n,i,a),void wi(l,e,r,n,i,a)}s=s.next}o=o.next}while(o!==t)}function Si(t,e){return t.x-e.x}function Ei(t,e){if(e=function(t,e){var r,n=e,i=t.x,a=t.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=u&&i!==n.x&&zi(ar.x)&&Ri(n,t)&&(r=n,h=l),n=n.next;return r}(t,e)){var r=Bi(e,t);_i(r,r.next)}}function Ci(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Li(t){var e=t,r=t;do{e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function Oi(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Di(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&Ri(t,e)&&Ri(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)}function Ii(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Pi(t,e){return t.x===e.x&&t.y===e.y}function Di(t,e,r,n){return!!(Pi(t,e)&&Pi(r,n)||Pi(t,n)&&Pi(r,e))||Ii(t,e,r)>0!=Ii(t,e,n)>0&&Ii(r,n,t)>0!=Ii(r,n,e)>0}function Ri(t,e){return Ii(t.prev,t,t.next)<0?Ii(t,e,t.next)>=0&&Ii(t,t.prev,e)>=0:Ii(t,e,t.prev)<0||Ii(t,t.next,e)<0}function Bi(t,e){var r=new ji(t.i,t.x,t.y),n=new ji(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function Fi(t,e,r,n){var i=new ji(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ni(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ji(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Vi(t,e,r,n){for(var i=0,a=e,o=r-n;a0&&(n+=t[i-1].length,r.holes.push(n))}return r},mi.default=yi;var Ui=Hi,qi=Hi;function Hi(t,e,r,n,i){!function t(e,r,n,i,a){for(;i>n;){if(i-n>600){var o=i-n+1,s=r-n+1,l=Math.log(o),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(o-c)/o)*(s-o/2<0?-1:1);t(e,r,Math.max(n,Math.floor(r-s*c/o+u)),Math.min(i,Math.floor(r+(o-s)*c/o+u)),a)}var f=e[r],h=n,p=i;for(Gi(e,n,r),a(e[i],f)>0&&Gi(e,n,i);h0;)p--}0===a(e[n],f)?Gi(e,n,p):Gi(e,++p,i),p<=r&&(n=p+1),r<=p&&(i=p-1)}}(t,e,r||0,n||t.length-1,i||Wi)}function Gi(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Wi(t,e){return te?1:0}function Yi(t,e){var r=t.length;if(r<=1)return[t];for(var n,i,a=[],o=0;o1)for(var l=0;lDn)||t.y===e.y&&(t.y<0||t.y>Dn)}function na(t){return t.every(function(t){return t.x<0})||t.every(function(t){return t.x>Dn})||t.every(function(t){return t.y<0})||t.every(function(t){return t.y>Dn})}ea.prototype.populate=function(t,e){for(var r=0,n=t;r=1){var g=f[p-1];if(!ra(d,g)){l.vertexLength+4>Tn.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));var v=d.sub(g)._perp()._unit(),m=g.dist(d);h+m>32768&&(h=0),ta(this.layoutVertexArray,d.x,d.y,v.x,v.y,0,0,h),ta(this.layoutVertexArray,d.x,d.y,v.x,v.y,0,1,h),h+=m,ta(this.layoutVertexArray,g.x,g.y,v.x,v.y,0,0,h),ta(this.layoutVertexArray,g.x,g.y,v.x,v.y,0,1,h);var y=l.vertexLength;this.indexArray.emplaceBack(y,y+1,y+2),this.indexArray.emplaceBack(y+1,y+2,y+3),l.vertexLength+=4,l.primitiveLength+=2}}}}l.vertexLength+a>Tn.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(a,this.layoutVertexArray,this.indexArray));for(var x=[],b=[],_=l.vertexLength,w=0,k=i;w>3}if(i--,1===n||2===n)a+=t.readSVarint(),o+=t.readSVarint(),1===n&&(e&&s.push(e),e=[]),e.push(new l(a,o));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&s.push(e),s},la.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,o=1/0,s=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===r||2===r)(i+=t.readSVarint())s&&(s=i),(a+=t.readSVarint())c&&(c=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,s,c]},la.prototype.toGeoJSON=function(t,e,r){var n,i,a=this.extent*Math.pow(2,r),o=this.extent*t,s=this.extent*e,l=this.loadGeometry(),c=la.types[this.type];function u(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}function da(t,e,r){if(3===t){var n=new fa(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n)}}ha.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new sa(this._pbf,e,this.extent,this._keys,this._values)};var ga={VectorTile:function(t,e){this.layers=t.readFields(da,{},e)},VectorTileFeature:sa,VectorTileLayer:fa},va=ga.VectorTileFeature.types,ma=63,ya=Math.cos(Math.PI/180*37.5),xa=.5,ba=Math.pow(2,14)/xa;function _a(t,e,r,n,i,a,o){t.emplaceBack(e.x,e.y,n?1:0,i?1:-1,Math.round(ma*r.x)+128,Math.round(ma*r.y)+128,1+(0===a?0:a<0?-1:1)|(o*xa&63)<<2,o*xa>>6)}var wa=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(function(t){return t.id}),this.index=t.index,this.layoutVertexArray=new Qr,this.indexArray=new fn,this.programConfigurations=new In(oa,t.layers,t.zoom),this.segments=new Tn};function ka(t,e){return(t/e.tileTotal*(e.end-e.start)+e.start)*(ba-1)}wa.prototype.populate=function(t,e){for(var r=0,n=t;r=2&&t[l-1].equals(t[l-2]);)l--;for(var c=0;cc){var E=p.dist(x);if(E>2*u){var C=p.sub(p.sub(x)._mult(u/E)._round());this.distance+=C.dist(x),this.addCurrentVertex(C,this.distance,_.mult(1),0,0,!1,h,o),x=C}}var L=x&&b,z=L?r:b?v:m;if(L&&"round"===z&&(Ti&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)M=w.clone().mult(-1);else{var O=_.x*w.y-_.y*w.x>0?-1:1,I=T*_.add(w).mag()/_.sub(w).mag();M._perp()._mult(I*O)}this.addCurrentVertex(p,this.distance,M,0,0,!1,h,o),this.addCurrentVertex(p,this.distance,M.mult(-1),0,0,!1,h,o)}else if("bevel"===z||"fakeround"===z){var P=_.x*w.y-_.y*w.x>0,D=-Math.sqrt(T*T-1);if(P?(g=0,d=D):(d=0,g=D),y||this.addCurrentVertex(p,this.distance,_,d,g,!1,h,o),"fakeround"===z){for(var R=Math.floor(8*(.5-(A-.5))),B=void 0,F=0;F=0;N--)B=_.mult((N+1)/(R+1))._add(w)._unit(),this.addPieSliceVertex(p,this.distance,B,P,h,o)}b&&this.addCurrentVertex(p,this.distance,w,-d,-g,!1,h,o)}else"butt"===z?(y||this.addCurrentVertex(p,this.distance,_,0,0,!1,h,o),b&&this.addCurrentVertex(p,this.distance,w,0,0,!1,h,o)):"square"===z?(y||(this.addCurrentVertex(p,this.distance,_,1,1,!1,h,o),this.e1=this.e2=-1),b&&this.addCurrentVertex(p,this.distance,w,-1,-1,!1,h,o)):"round"===z&&(y||(this.addCurrentVertex(p,this.distance,_,0,0,!1,h,o),this.addCurrentVertex(p,this.distance,_,1,1,!0,h,o),this.e1=this.e2=-1),b&&(this.addCurrentVertex(p,this.distance,w,-1,-1,!0,h,o),this.addCurrentVertex(p,this.distance,w,0,0,!1,h,o)));if(S&&k2*u){var V=p.add(b.sub(p)._mult(u/j)._round());this.distance+=V.dist(p),this.addCurrentVertex(V,this.distance,w.mult(1),0,0,!1,h,o),p=V}}y=!1}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e)}},wa.prototype.addCurrentVertex=function(t,e,r,n,i,a,o,s){var l,c=this.layoutVertexArray,u=this.indexArray;s&&(e=ka(e,s)),l=r.clone(),n&&l._sub(r.perp()._mult(n)),_a(c,t,l,a,!1,n,e),this.e3=o.vertexLength++,this.e1>=0&&this.e2>=0&&(u.emplaceBack(this.e1,this.e2,this.e3),o.primitiveLength++),this.e1=this.e2,this.e2=this.e3,l=r.mult(-1),i&&l._sub(r.perp()._mult(i)),_a(c,t,l,a,!0,-i,e),this.e3=o.vertexLength++,this.e1>=0&&this.e2>=0&&(u.emplaceBack(this.e1,this.e2,this.e3),o.primitiveLength++),this.e1=this.e2,this.e2=this.e3,e>ba/2&&!s&&(this.distance=0,this.addCurrentVertex(t,this.distance,r,n,i,a,o))},wa.prototype.addPieSliceVertex=function(t,e,r,n,i,a){r=r.mult(n?-1:1);var o=this.layoutVertexArray,s=this.indexArray;a&&(e=ka(e,a)),_a(o,t,r,!1,n,0,e),this.e3=i.vertexLength++,this.e1>=0&&this.e2>=0&&(s.emplaceBack(this.e1,this.e2,this.e3),i.primitiveLength++),n?this.e2=this.e3:this.e1=this.e3},pr("LineBucket",wa,{omit:["layers"]});var Ma=new qr({"line-cap":new Nr(I.layout_line["line-cap"]),"line-join":new jr(I.layout_line["line-join"]),"line-miter-limit":new Nr(I.layout_line["line-miter-limit"]),"line-round-limit":new Nr(I.layout_line["line-round-limit"])}),Aa={paint:new qr({"line-opacity":new jr(I.paint_line["line-opacity"]),"line-color":new jr(I.paint_line["line-color"]),"line-translate":new Nr(I.paint_line["line-translate"]),"line-translate-anchor":new Nr(I.paint_line["line-translate-anchor"]),"line-width":new jr(I.paint_line["line-width"]),"line-gap-width":new jr(I.paint_line["line-gap-width"]),"line-offset":new jr(I.paint_line["line-offset"]),"line-blur":new jr(I.paint_line["line-blur"]),"line-dasharray":new Vr(I.paint_line["line-dasharray"]),"line-pattern":new Vr(I.paint_line["line-pattern"]),"line-gradient":new Ur(I.paint_line["line-gradient"])}),layout:Ma},Ta=new(function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.possiblyEvaluate=function(e,r){return r=new Lr(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),t.prototype.possiblyEvaluate.call(this,e,r)},e.prototype.evaluate=function(e,r,n){return r=p({},r,{zoom:Math.floor(r.zoom)}),t.prototype.evaluate.call(this,e,r,n)},e}(jr))(Aa.paint.properties["line-width"].specification);Ta.useIntegerZoom=!0;var Sa=function(t){function e(e){t.call(this,e,Aa)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setPaintProperty=function(e,r,n){t.prototype.setPaintProperty.call(this,e,r,n),"line-gradient"===e&&this._updateGradient()},e.prototype._updateGradient=function(){var t=this._transitionablePaint._values["line-gradient"].value.expression;this.gradient=hi(t,"lineProgress"),this.gradientTexture=null},e.prototype.recalculate=function(e){t.prototype.recalculate.call(this,e),this.paint._values["line-floorwidth"]=Ta.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)},e.prototype.createBucket=function(t){return new wa(t)},e.prototype.queryRadius=function(t){var e=t,r=Ea($n("line-width",this,e),$n("line-gap-width",this,e)),n=$n("line-offset",this,e);return r/2+Math.abs(n)+Jn(this.paint.get("line-translate"))},e.prototype.queryIntersectsFeature=function(t,e,r,n,i,a){var o=Kn(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),i.angle,a),s=a/2*Ea(this.paint.get("line-width").evaluate(e),this.paint.get("line-gap-width").evaluate(e)),c=this.paint.get("line-offset").evaluate(e);return c&&(r=function(t,e){for(var r=[],n=new l(0,0),i=0;i0?e+2*t:t}var Ca=Xr([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"}]),La=Xr([{name:"a_projected_pos",components:3,type:"Float32"}],4),za=(Xr([{name:"a_fade_opacity",components:1,type:"Uint32"}],4),Xr([{name:"a_placed",components:2,type:"Uint8"}],4)),Oa=(Xr([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"},{type:"Int16",name:"radius"},{type:"Int16",name:"signedDistanceFromAnchor"}]),Xr([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4)),Ia=Xr([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);function Pa(t,e,r){var n=e.layout.get("text-transform").evaluate(r);return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Cr.applyArabicShaping&&(t=Cr.applyArabicShaping(t)),t}Xr([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"hidden"}]),Xr([{type:"Float32",name:"offsetX"}]),Xr([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Da={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42"},Ra=function(t){function e(e,r,n,i){t.call(this,e,r),this.angle=n,void 0!==i&&(this.segment=i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.clone=function(){return new e(this.x,this.y,this.angle,this.segment)},e}(l);function Ba(t,e){var r=e.expression;if("constant"===r.kind)return{functionType:"constant",layoutSize:r.evaluate(new Lr(t+1))};if("source"===r.kind)return{functionType:"source"};for(var n=r.zoomStops,i=0;i0)&&("constant"!==i.value.kind||i.value.value.length>0),l="constant"!==o.value.kind||o.value.value&&o.value.value.length>0;if(this.features=[],s||l){for(var c=e.iconDependencies,u=e.glyphDependencies,f=new Lr(this.zoom),h=0,p=t;h=0;s--)a[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:i},s>0&&(i+=e[s-1].dist(e[s]));for(var l=0;l0;this.addCollisionDebugVertices(s,l,c,u,f?this.collisionCircle:this.collisionBox,o.anchorPoint,r,f)}}}},Ha.prototype.deserializeCollisionBoxes=function(t,e,r,n,i){for(var a={},o=e;o0},Ha.prototype.hasIconData=function(){return this.icon.segments.get().length>0},Ha.prototype.hasCollisionBoxData=function(){return this.collisionBox.segments.get().length>0},Ha.prototype.hasCollisionCircleData=function(){return this.collisionCircle.segments.get().length>0},Ha.prototype.sortFeatures=function(t){var e=this;if(this.sortFeaturesByY&&this.sortedAngle!==t&&(this.sortedAngle=t,!(this.text.segments.get().length>1||this.icon.segments.get().length>1))){for(var r=[],n=0;ni.maxh||t>i.maxw||r<=i.maxh&&t<=i.maxw&&(o=i.maxw*i.maxh-t*r)a.free)){if(r===a.h)return this.allocShelf(s,t,r,n);r>a.h||ru)&&(f=2*Math.max(t,u)),(ll)&&(c=2*Math.max(r,l)),this.resize(f,c),this.packOne(t,r,n)):null},t.prototype.allocFreebin=function(t,e,r,n){var i=this.freebins.splice(t,1)[0];return i.id=n,i.w=e,i.h=r,i.refcount=0,this.bins[n]=i,this.ref(i),i},t.prototype.allocShelf=function(t,e,r,n){var i=this.shelves[t].alloc(e,r,n);return this.bins[n]=i,this.ref(i),i},t.prototype.shrink=function(){if(this.shelves.length>0){for(var t=0,e=0,r=0;rthis.free||e>this.h)return null;var n=this.x;return this.x+=t,this.free-=t,new function(t,e,r,n,i,a,o){this.id=t,this.x=e,this.y=r,this.w=n,this.h=i,this.maxw=a||n,this.maxh=o||i,this.refcount=0}(r,n,this.y,t,e,t,this.h)},e.prototype.resize=function(t){return this.free+=t-this.w,this.w=t,!0},t}()}),Qa=function(t,e){var r=e.pixelRatio;this.paddedRect=t,this.pixelRatio=r},to={tl:{configurable:!0},br:{configurable:!0},displaySize:{configurable:!0}};to.tl.get=function(){return[this.paddedRect.x+1,this.paddedRect.y+1]},to.br.get=function(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]},to.displaySize.get=function(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]},Object.defineProperties(Qa.prototype,to);var eo=function(t){var e=new ui({width:0,height:0}),r={},n=new Ka(0,0,{autoResize:!0});for(var i in t){var a=t[i],o=n.packOne(a.data.width+2,a.data.height+2);e.resize({width:n.w,height:n.h}),ui.copy(a.data,e,{x:0,y:0},{x:o.x+1,y:o.y+1},a.data),r[i]=new Qa(o,a)}n.shrink(),e.resize({width:n.w,height:n.h}),this.image=e,this.positions=r};pr("ImagePosition",Qa),pr("ImageAtlas",eo);var ro=function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+t[e+f],f+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),a-=c}return(p?-1:1)*o*Math.pow(2,a-n)},no=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=u?(s=0,o=u):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*g},io=ao;function ao(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}function oo(t){return t.type===ao.Bytes?t.readVarint()+t.pos:t.pos+1}function so(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function lo(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i]}function co(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function _o(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}ao.Varint=0,ao.Fixed64=1,ao.Bytes=2,ao.Fixed32=5,ao.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=xo(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=_o(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=xo(this.buf,this.pos)+4294967296*xo(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=xo(this.buf,this.pos)+4294967296*_o(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=ro(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ro(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,a=r.buf;if(n=(112&(i=a[r.pos++]))>>4,i<128)return so(t,n,e);if(n|=(127&(i=a[r.pos++]))<<3,i<128)return so(t,n,e);if(n|=(127&(i=a[r.pos++]))<<10,i<128)return so(t,n,e);if(n|=(127&(i=a[r.pos++]))<<17,i<128)return so(t,n,e);if(n|=(127&(i=a[r.pos++]))<<24,i<128)return so(t,n,e);if(n|=(1&(i=a[r.pos++]))<<31,i<128)return so(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+u>r)break;1===u?l<128&&(c=l):2===u?128==(192&(a=t[i+1]))&&(c=(31&l)<<6|63&a)<=127&&(c=null):3===u?(a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&((c=(15&l)<<12|(63&a)<<6|63&o)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((c=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),i+=u}return n}(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){var r=oo(this);for(t=t||[];this.pos127;);else if(e===ao.Bytes)this.pos=this.readVarint()+this.pos;else if(e===ao.Fixed32)this.pos+=4;else{if(e!==ao.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos]=127&t}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,a=0;a55295&&n<57344){if(!i){n>56319||a+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&lo(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),no(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),no(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&lo(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,ao.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){this.writeMessage(t,co,e)},writePackedSVarint:function(t,e){this.writeMessage(t,uo,e)},writePackedBoolean:function(t,e){this.writeMessage(t,po,e)},writePackedFloat:function(t,e){this.writeMessage(t,fo,e)},writePackedDouble:function(t,e){this.writeMessage(t,ho,e)},writePackedFixed32:function(t,e){this.writeMessage(t,go,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,vo,e)},writePackedFixed64:function(t,e){this.writeMessage(t,mo,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,yo,e)},writeBytesField:function(t,e){this.writeTag(t,ao.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,ao.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,ao.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,ao.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,ao.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,ao.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,ao.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,ao.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,ao.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,ao.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var wo=3;function ko(t,e,r){1===t&&r.readMessage(Mo,e)}function Mo(t,e,r){if(3===t){var n=r.readMessage(Ao,{}),i=n.id,a=n.bitmap,o=n.width,s=n.height,l=n.left,c=n.top,u=n.advance;e.push({id:i,bitmap:new ci({width:o+2*wo,height:s+2*wo},a),metrics:{width:o,height:s,left:l,top:c,advance:u}})}}function Ao(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint())}var To=wo,So=function(t,e,r){this.target=t,this.parent=e,this.mapId=r,this.callbacks={},this.callbackID=0,g(["receive"],this),this.target.addEventListener("message",this.receive,!1)};So.prototype.send=function(t,e,r,n){var i=r?this.mapId+":"+this.callbackID++:null;r&&(this.callbacks[i]=r);var a=[];this.target.postMessage({targetMapId:n,sourceMapId:this.mapId,type:t,id:String(i),data:gr(e,a)},a)},So.prototype.receive=function(t){var e,r=this,n=t.data,i=n.id;if(!n.targetMapId||this.mapId===n.targetMapId){var a=function(t,e){var n=[];r.target.postMessage({sourceMapId:r.mapId,type:"",id:String(i),error:t?gr(t):null,data:gr(e,n)},n)};if(""===n.type)e=this.callbacks[n.id],delete this.callbacks[n.id],e&&n.error?e(vr(n.error)):e&&e(null,vr(n.data));else if(void 0!==n.id&&this.parent[n.type])this.parent[n.type](n.sourceMapId,vr(n.data),a);else if(void 0!==n.id&&this.parent.getWorkerSource){var o=n.type.split(".");this.parent.getWorkerSource(n.sourceMapId,o[0],o[1])[o[2]](vr(n.data),a)}else this.parent[n.type](vr(n.data))}},So.prototype.remove=function(){this.target.removeEventListener("message",this.receive,!1)};var Eo=n(i(function(t,e){!function(t){function e(t,e,n){var i=r(256*t,256*(e=Math.pow(2,n)-e-1),n),a=r(256*(t+1),256*(e+1),n);return i[0]+","+i[1]+","+a[0]+","+a[1]}function r(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}t.getURL=function(t,r,n,i,a,o){return o=o||{},t+"?"+["bbox="+e(n,i,a),"format="+(o.format||"image/png"),"service="+(o.service||"WMS"),"version="+(o.version||"1.1.1"),"request="+(o.request||"GetMap"),"srs="+(o.srs||"EPSG:3857"),"width="+(o.width||256),"height="+(o.height||256),"layers="+r].join("&")},t.getTileBBox=e,t.getMercCoords=r,Object.defineProperty(t,"__esModule",{value:!0})}(e)})),Co=function(t,e,r){this.z=t,this.x=e,this.y=r,this.key=Oo(0,t,e,r)};Co.prototype.equals=function(t){return this.z===t.z&&this.x===t.x&&this.y===t.y},Co.prototype.url=function(t,e){var r=Eo.getTileBBox(this.x,this.y,this.z),n=function(t,e,r){for(var n,i="",a=t;a>0;a--)i+=(e&(n=1<this.canonical.z?new zo(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new zo(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)},zo.prototype.isChildOf=function(t){var e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e},zo.prototype.children=function(t){if(this.overscaledZ>=t)return[new zo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return[new zo(e,this.wrap,e,r,n),new zo(e,this.wrap,e,r+1,n),new zo(e,this.wrap,e,r,n+1),new zo(e,this.wrap,e,r+1,n+1)]},zo.prototype.isLessThan=function(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=this.dim+this.border||e<-this.border||e>=this.dim+this.border)throw new RangeError("out of range source coordinates for DEM data");return(e+this.border)*this.stride+(t+this.border)},pr("Level",Io);var Po=function(t,e,r){this.uid=t,this.scale=e||1,this.level=r||new Io(256,512),this.loaded=!!r};Po.prototype.loadFromImage=function(t,e){if(t.height!==t.width)throw new RangeError("DEM tiles must be square");if(e&&"mapbox"!==e&&"terrarium"!==e)return _('"'+e+'" is not a valid encoding type. Valid types include "mapbox" and "terrarium".');var r=this.level=new Io(t.width,t.width/2),n=t.data;this._unpackData(r,n,e||"mapbox");for(var i=0;i=0&&l[3]>=0&&this.grid.insert(a,l[0],l[1],l[2],l[3])}},Fo.prototype.loadVTLayers=function(){return this.vtLayers||(this.vtLayers=new ga.VectorTile(new io(this.rawTileData)).layers,this.sourceLayerCoder=new Do(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers},Fo.prototype.query=function(t,e){var r=this;this.loadVTLayers();for(var n=t.params||{},i=Dn/t.tileSize/t.scale,a=Re(n.filter),o=t.queryGeometry,s=t.queryPadding*i,l=1/0,c=1/0,u=-1/0,f=-1/0,h=0;h=0)return!0;return!1}(a,l)){var c=this.sourceLayerCoder.decode(r),u=this.vtLayers[c].feature(n);if(i(new Lr(this.tileID.overscaledZ),u))for(var f=0;f=200&&r.status<300&&r.response){var n;try{n=JSON.parse(r.response)}catch(t){return e(t)}e(null,n)}else 401===r.status&&t.url.match(/mapbox.com/)?e(new A(r.statusText+": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens",r.status,t.url)):e(new A(r.statusText,r.status,t.url))},r.send(),r},e.getImage=function(t,e){return S(t,function(t,r){if(t)e(t);else if(r){var n=new self.Image,i=self.URL||self.webkitURL;n.onload=function(){e(null,n),i.revokeObjectURL(n.src)};var a=new self.Blob([new Uint8Array(r.data)],{type:"image/png"});n.cacheControl=r.cacheControl,n.expires=r.expires,n.src=r.data.byteLength?i.createObjectURL(a):"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII="}})},e.ResourceType=M,e.RGBAImage=ui,e.default$2=Ka,e.ImagePosition=Qa,e.getArrayBuffer=S,e.default$3=function(t){return new io(t).readFields(ko,[])},e.default$4=yr,e.asyncAll=function(t,e,r){if(!t.length)return r(null,[]);var n=t.length,i=new Array(t.length),a=null;t.forEach(function(t,o){e(t,function(t,e){t&&(a=t),i[o]=e,0==--n&&r(a,i)})})},e.AlphaImage=ci,e.default$5=I,e.endsWith=v,e.extend=p,e.sphericalToCartesian=function(t){var e=t[0],r=t[1],n=t[2];return r+=90,r*=Math.PI/180,n*=Math.PI/180,{x:e*Math.cos(r)*Math.sin(n),y:e*Math.sin(r)*Math.sin(n),z:e*Math.cos(n)}},e.Evented=O,e.validateStyle=nr,e.validateLight=ir,e.emitValidationErrors=sr,e.default$6=tt,e.number=wt,e.Properties=qr,e.Transitionable=Ir,e.Transitioning=Dr,e.PossiblyEvaluated=Fr,e.DataConstantProperty=Nr,e.warnOnce=_,e.uniqueId=function(){return d++},e.default$7=So,e.pick=function(t,e){for(var r={},n=0;n@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,function(t,r,n,i){var a=n||i;return e[r]=!a||a.toLowerCase(),""}),e["max-age"]){var r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},e.default$11=Fo,e.default$12=Ro,e.default$13=Re,e.default$14=Ha,e.CollisionBoxArray=vn,e.default$15=Tn,e.TriangleIndexArray=fn,e.default$16=Lr,e.default$17=s,e.keysDifference=function(t,e){var r=[];for(var n in t)n in e||r.push(n);return r},e.default$18=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.mat4=ri,e.vec4=ei,e.getSizeData=Ba,e.evaluateSizeForFeature=function(t,e,r){var n=e;return"source"===t.functionType?r.lowerSize/10:"composite"===t.functionType?wt(r.lowerSize/10,r.upperSize/10,n.uSizeT):n.uSize},e.evaluateSizeForZoom=function(t,e,r){if("constant"===t.functionType)return{uSizeT:0,uSize:t.layoutSize};if("source"===t.functionType)return{uSizeT:0,uSize:0};if("camera"===t.functionType){var n=t.propertyValue,i=t.zoomRange,a=t.sizeRange,o=h(Se(n,r.specification).interpolationFactor(e,i.min,i.max),0,1);return{uSizeT:0,uSize:a.min+o*(a.max-a.min)}}var s=t.propertyValue,l=t.zoomRange;return{uSizeT:h(Se(s,r.specification).interpolationFactor(e,l.min,l.max),0,1),uSize:0}},e.addDynamicAttributes=Va,e.default$19=Wa,e.WritingMode=jo,e.multiPolygonIntersectsBufferedPoint=jn,e.multiPolygonIntersectsMultiPolygon=Vn,e.multiPolygonIntersectsBufferedMultiLine=Un,e.polygonIntersectsPolygon=function(t,e){for(var r=0;r-r/2;){if(--o<0)return!1;s-=t[o].dist(a),a=t[o]}s+=t[o].dist(t[o+1]),o++;for(var l=[],c=0;sn;)c-=l.shift().angleDelta;if(c>i)return!1;o++,s+=f.dist(h)}return!0}function a(e,r,n,a,o,s,l,c,u){var f=a?.6*s*l:0,h=Math.max(a?a.right-a.left:0,o?o.right-o.left:0),p=0===e[0].x||e[0].x===u||0===e[0].y||e[0].y===u;return r-h*l=0&&M=0&&A=0&&v+h<=p){var T=new t.default$25(M,A,w,y);T._round(),o&&!i(r,T,l,o,s)||m.push(T)}}g+=_}return u||m.length||c||(m=e(r,g/2,a,o,s,l,c,!0,f)),m}(e,p?r/2*c%r:(h/2+2*s)*l*c%r,r,f,n,h*l,p,!1,u)}n.prototype.replace=function(t){this._layerConfigs={},this._layers={},this.update(t,[])},n.prototype.update=function(e,n){for(var i=this,a=0,o=e;a0&&(g=Math.max(10*s,g),this._addLineCollisionCircles(t,e,r,r.segment,v,g,n,i,a,u))}else t.emplaceBack(r.x,r.y,p,f,d,h,n,i,a,0,0);this.boxEndIndex=t.length};s.prototype._addLineCollisionCircles=function(t,e,r,n,i,a,o,s,l,c){var u=a/2,f=Math.floor(i/u),h=1+.4*Math.log(c)/Math.LN2,p=Math.floor(f*h/2),d=-a/2,g=r,v=n+1,m=d,y=-i/2,x=y-i/4;do{if(--v<0){if(m>y)return;v=0;break}m-=e[v].dist(g),g=e[v]}while(m>x);for(var b=e[v].dist(e[v+1]),_=-p;_i&&(k+=w-i),!(k=e.length)return;b=e[v].dist(e[v+1])}var M=k-m,A=e[v],T=e[v+1].sub(A)._unit()._mult(M)._add(A)._round(),S=Math.abs(k-d)0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)}function f(t,e){return te?1:0}function h(e,r,n){void 0===r&&(r=1),void 0===n&&(n=!1);for(var i=1/0,a=1/0,o=-1/0,s=-1/0,c=e[0],u=0;uo)&&(o=f.x),(!u||f.y>s)&&(s=f.y)}var h=o-i,g=s-a,v=Math.min(h,g),m=v/2,y=new l(null,p);if(0===v)return new t.default$1(i,a);for(var x=i;x_.d||!_.d)&&(_=k,n&&console.log("found best %d after %d probes",Math.round(1e4*k.d)/1e4,w)),k.max-_.d<=r||(m=k.h/2,y.push(new d(k.p.x-m,k.p.y-m,m,e)),y.push(new d(k.p.x+m,k.p.y-m,m,e)),y.push(new d(k.p.x-m,k.p.y+m,m,e)),y.push(new d(k.p.x+m,k.p.y+m,m,e)),w+=4)}return n&&(console.log("num probes: "+w),console.log("best distance: "+_.d)),_.p}function p(t,e){return e.max-t.max}function d(e,r,n,i){this.p=new t.default$1(e,r),this.h=n,this.d=function(e,r){for(var n=!1,i=1/0,a=0;ae.y!=f.y>e.y&&e.x<(f.x-u.x)*(e.y-u.y)/(f.y-u.y)+u.x&&(n=!n),i=Math.min(i,t.distToSegmentSquared(e,u,f))}return(n?1:-1)*Math.sqrt(i)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}function g(e,r,n,i,a,o){e.createArrays(),e.symbolInstances=[];var s=512*e.overscaling;e.tilePixelRatio=t.default$8/s,e.compareText={},e.iconsNeedLinear=!1;var l=e.layers[0].layout,c=e.layers[0]._unevaluatedLayout._values,u={};if("composite"===e.textSizeData.functionType){var f=e.textSizeData.zoomRange,h=f.min,p=f.max;u.compositeTextSizes=[c["text-size"].possiblyEvaluate(new t.default$16(h)),c["text-size"].possiblyEvaluate(new t.default$16(p))]}if("composite"===e.iconSizeData.functionType){var d=e.iconSizeData.zoomRange,g=d.min,m=d.max;u.compositeIconSizes=[c["icon-size"].possiblyEvaluate(new t.default$16(g)),c["icon-size"].possiblyEvaluate(new t.default$16(m))]}u.layoutTextSize=c["text-size"].possiblyEvaluate(new t.default$16(e.zoom+1)),u.layoutIconSize=c["icon-size"].possiblyEvaluate(new t.default$16(e.zoom+1)),u.textMaxSize=c["text-size"].possiblyEvaluate(new t.default$16(18));for(var y=24*l.get("text-line-height"),x="map"===l.get("text-rotation-alignment")&&"line"===l.get("symbol-placement"),b=l.get("text-keep-upright"),_=0,w=e.features;_=t.default$8||u.y<0||u.y>=t.default$8||e.symbolInstances.push(function(e,r,n,i,a,l,c,u,f,h,p,d,g,v,y,x,b,_,w,k,M){var A,T,S=e.addToLineVertexArray(r,n),E=0,C=0,L=0,z=i.horizontal?i.horizontal.text:"",O=[];i.horizontal&&(A=new s(c,n,r,u,f,h,i.horizontal,p,d,g,e.overscaling),C+=m(e,r,i.horizontal,l,g,w,v,S,i.vertical?t.WritingMode.horizontal:t.WritingMode.horizontalOnly,O,k,M),i.vertical&&(L+=m(e,r,i.vertical,l,g,w,v,S,t.WritingMode.vertical,O,k,M)));var I=A?A.boxStartIndex:e.collisionBoxArray.length,P=A?A.boxEndIndex:e.collisionBoxArray.length;if(a){var D=function(e,r,n,i,a,o){var s,l,c,u,f=r.image,h=n.layout,p=r.top-1/f.pixelRatio,d=r.left-1/f.pixelRatio,g=r.bottom+1/f.pixelRatio,v=r.right+1/f.pixelRatio;if("none"!==h.get("icon-text-fit")&&a){var m=v-d,y=g-p,x=h.get("text-size").evaluate(o)/24,b=a.left*x,_=a.right*x,w=a.top*x,k=_-b,M=a.bottom*x-w,A=h.get("icon-text-fit-padding")[0],T=h.get("icon-text-fit-padding")[1],S=h.get("icon-text-fit-padding")[2],E=h.get("icon-text-fit-padding")[3],C="width"===h.get("icon-text-fit")?.5*(M-y):0,L="height"===h.get("icon-text-fit")?.5*(k-m):0,z="width"===h.get("icon-text-fit")||"both"===h.get("icon-text-fit")?k:m,O="height"===h.get("icon-text-fit")||"both"===h.get("icon-text-fit")?M:y;s=new t.default$1(b+L-E,w+C-A),l=new t.default$1(b+L+T+z,w+C-A),c=new t.default$1(b+L+T+z,w+C+S+O),u=new t.default$1(b+L-E,w+C+S+O)}else s=new t.default$1(d,p),l=new t.default$1(v,p),c=new t.default$1(v,g),u=new t.default$1(d,g);var I=n.layout.get("icon-rotate").evaluate(o)*Math.PI/180;if(I){var P=Math.sin(I),D=Math.cos(I),R=[D,-P,P,D];s._matMult(R),l._matMult(R),u._matMult(R),c._matMult(R)}return[{tl:s,tr:l,bl:u,br:c,tex:f.paddedRect,writingMode:void 0,glyphOffset:[0,0]}]}(0,a,l,0,i.horizontal,w);T=new s(c,n,r,u,f,h,a,y,x,!1,e.overscaling),E=4*D.length;var R=e.iconSizeData,B=null;"source"===R.functionType?B=[10*l.layout.get("icon-size").evaluate(w)]:"composite"===R.functionType&&(B=[10*M.compositeIconSizes[0].evaluate(w),10*M.compositeIconSizes[1].evaluate(w)]),e.addSymbols(e.icon,D,B,_,b,w,!1,r,S.lineStartIndex,S.lineLength)}var F=T?T.boxStartIndex:e.collisionBoxArray.length,N=T?T.boxEndIndex:e.collisionBoxArray.length;return e.glyphOffsetArray.length>=t.default$14.MAX_GLYPHS&&t.warnOnce("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),{key:z,textBoxStartIndex:I,textBoxEndIndex:P,iconBoxStartIndex:F,iconBoxEndIndex:N,textOffset:v,iconOffset:_,anchor:r,line:n,featureIndex:u,feature:w,numGlyphVertices:C,numVerticalGlyphVertices:L,numIconVertices:E,textOpacityState:new o,iconOpacityState:new o,isDuplicate:!1,placedTextSymbolIndices:O,crossTileID:0}}(e,u,a,n,i,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,b,M,S,g,w,A,E,v,r,l,c))};if("line"===d.get("symbol-placement"))for(var z=0,O=function(e,r,n,i,a){for(var o=[],s=0;s=i&&h.x>=i||(f.x>=i?f=new t.default$1(i,f.y+(h.y-f.y)*((i-f.x)/(h.x-f.x)))._round():h.x>=i&&(h=new t.default$1(i,f.y+(h.y-f.y)*((i-f.x)/(h.x-f.x)))._round()),f.y>=a&&h.y>=a||(f.y>=a?f=new t.default$1(f.x+(h.x-f.x)*((a-f.y)/(h.y-f.y)),a)._round():h.y>=a&&(h=new t.default$1(f.x+(h.x-f.x)*((a-f.y)/(h.y-f.y)),a)._round()),c&&f.equals(c[c.length-1])||(c=[f],o.push(c)),c.push(h)))))}return o}(r.geometry,0,0,t.default$8,t.default$8);z=0;o--)if(n.dist(a[o])0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,r=this.compare,n=e[t];t>0;){var i=t-1>>1,a=e[i];if(r(n,a)>=0)break;e[t]=a,t=i}e[t]=n},_down:function(t){for(var e=this.data,r=this.compare,n=this.length>>1,i=e[t];t=0)break;e[t]=s,t=a}e[t]=i}},l.default=c;var x=function(e){var r=new t.AlphaImage({width:0,height:0}),n={},i=new t.default$2(0,0,{autoResize:!0});for(var a in e){var o=e[a],s=n[a]={};for(var l in o){var c=o[+l];if(c&&0!==c.bitmap.width&&0!==c.bitmap.height){var u=i.packOne(c.bitmap.width+2,c.bitmap.height+2);r.resize({width:i.w,height:i.h}),t.AlphaImage.copy(c.bitmap,r,{x:0,y:0},{x:u.x+1,y:u.y+1},c.bitmap),s[l]={rect:u,metrics:c.metrics}}}}i.shrink(),r.resize({width:i.w,height:i.h}),this.image=r,this.positions=n};t.register("GlyphAtlas",x);var b=function(e){this.tileID=new t.OverscaledTileID(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming};function _(e,r){for(var n=new t.default$16(r),i=0,a=e;i=T.maxzoom||"none"!==T.visibility&&(_(A,a.zoom),(f[T.id]=T.createBucket({index:s.bucketLayerIDs.length,layers:A,zoom:a.zoom,pixelRatio:a.pixelRatio,overscaling:a.overscaling,collisionBoxArray:a.collisionBoxArray,sourceLayerIndex:m})).populate(y,h),s.bucketLayerIDs.push(A.map(function(t){return t.id})))}}}var S=t.mapObject(h.glyphDependencies,function(t){return Object.keys(t).map(Number)});Object.keys(S).length?n.send("getGlyphs",{uid:this.uid,stacks:S},function(t,e){l||(l=t,c=e,C.call(a))}):c={};var E=Object.keys(h.iconDependencies);function C(){if(l)return i(l);if(c&&u){var e=new x(c),r=new t.default$28(u);for(var n in f){var a=f[n];a instanceof t.default$14&&(_(a.layers,this.zoom),g(a,c,e.positions,u,r.positions,this.showCollisionBoxes))}this.status="done",i(null,{buckets:t.values(f).filter(function(t){return!t.isEmpty()}),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,iconAtlasImage:r.image})}}E.length?n.send("getImages",{icons:E},function(t,e){l||(l=t,u=e,C.call(a))}):u={},C.call(this)};var w=function(t){return!(!performance||!performance.getEntriesByName)&&performance.getEntriesByName(t)};function k(e,r){var n=t.getArrayBuffer(e.request,function(e,n){e?r(e):n&&r(null,{vectorTile:new t.default$29.VectorTile(new t.default$30(n.data)),rawData:n.data,cacheControl:n.cacheControl,expires:n.expires})});return function(){n.abort(),r()}}var M=function(t,e,r){this.actor=t,this.layerIndex=e,this.loadVectorData=r||k,this.loading={},this.loaded={}};M.prototype.loadTile=function(e,r){var n=this,i=e.uid;this.loading||(this.loading={});var a=this.loading[i]=new b(e);a.abort=this.loadVectorData(e,function(o,s){if(delete n.loading[i],o||!s)return r(o);var l=s.rawData,c={};s.expires&&(c.expires=s.expires),s.cacheControl&&(c.cacheControl=s.cacheControl);var u={};if(e.request&&e.request.collectResourceTiming){var f=w(e.request.url);f&&(u.resourceTiming=JSON.parse(JSON.stringify(f)))}a.vectorTile=s.vectorTile,a.parse(s.vectorTile,n.layerIndex,n.actor,function(e,n){if(e||!n)return r(e);r(null,t.extend({rawTileData:l.slice(0)},n,c,u))}),n.loaded=n.loaded||{},n.loaded[i]=a})},M.prototype.reloadTile=function(t,e){var r=this.loaded,n=t.uid,i=this;if(r&&r[n]){var a=r[n];a.showCollisionBoxes=t.showCollisionBoxes;var o=function(t,r){var n=a.reloadCallback;n&&(delete a.reloadCallback,a.parse(a.vectorTile,i.layerIndex,i.actor,n)),e(t,r)};"parsing"===a.status?a.reloadCallback=o:"done"===a.status&&a.parse(a.vectorTile,this.layerIndex,this.actor,o)}},M.prototype.abortTile=function(t,e){var r=this.loading,n=t.uid;r&&r[n]&&r[n].abort&&(r[n].abort(),delete r[n]),e()},M.prototype.removeTile=function(t,e){var r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e()};var A=function(){this.loading={},this.loaded={}};A.prototype.loadTile=function(e,r){var n=e.uid,i=e.encoding,a=new t.default$31(n);this.loading[n]=a,a.loadFromImage(e.rawImageData,i),delete this.loading[n],this.loaded=this.loaded||{},this.loaded[n]=a,r(null,a)},A.prototype.removeTile=function(t){var e=this.loaded,r=t.uid;e&&e[r]&&delete e[r]};var T={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:6356752.3142};function S(t){var e=0;if(t&&t.length>0){e+=Math.abs(E(t[0]));for(var r=1;r2){for(o=0;o=0}(t)===e?t:t.reverse()}var P=t.default$29.VectorTileFeature.prototype.toGeoJSON,D=function(e){this._feature=e,this.extent=t.default$8,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))};D.prototype.loadGeometry=function(){if(1===this._feature.type){for(var e=[],r=0,n=this._feature.geometry;r>31}function $(t,e){for(var r=t.loadGeometry(),n=t.type,i=0,a=0,o=r.length,s=0;si;){if(a-i>600){var s=a-i+1,l=n-i+1,c=Math.log(s),u=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*u*(s-u)/s)*(l-s/2<0?-1:1);t(e,r,n,Math.max(i,Math.floor(n-l*u/s+f)),Math.min(a,Math.floor(n+(s-l)*u/s+f)),o)}var h=r[2*n+o],p=i,d=a;for(Q(e,r,i,n),r[2*a+o]>h&&Q(e,r,i,a);ph;)d--}r[2*i+o]===h?Q(e,r,i,d):Q(e,r,++d,a),d<=n&&(i=d+1),n<=d&&(a=d-1)}}(e,r,s,i,a,o%2),t(e,r,n,i,s-1,o+1),t(e,r,n,s+1,a,o+1)}};function Q(t,e,r,n){tt(t,r,n),tt(e,2*r,2*n),tt(e,2*r+1,2*n+1)}function tt(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function et(t,e,r,n){var i=t-r,a=e-n;return i*i+a*a}var rt=function(t,e,r,n,i){return new nt(t,e,r,n,i)};function nt(t,e,r,n,i){e=e||it,r=r||at,i=i||Array,this.nodeSize=n||64,this.points=t,this.ids=new i(t.length),this.coords=new i(2*t.length);for(var a=0;a=r&&s<=i&&l>=n&&l<=a&&u.push(t[d]);else{var g=Math.floor((p+h)/2);s=e[2*g],l=e[2*g+1],s>=r&&s<=i&&l>=n&&l<=a&&u.push(t[g]);var v=(f+1)%2;(0===f?r<=s:n<=l)&&(c.push(p),c.push(g-1),c.push(v)),(0===f?i>=s:a>=l)&&(c.push(g+1),c.push(h),c.push(v))}}return u}(this.ids,this.coords,t,e,r,n,this.nodeSize)},within:function(t,e,r){return function(t,e,r,n,i,a){for(var o=[0,t.length-1,0],s=[],l=i*i;o.length;){var c=o.pop(),u=o.pop(),f=o.pop();if(u-f<=a)for(var h=f;h<=u;h++)et(e[2*h],e[2*h+1],r,n)<=l&&s.push(t[h]);else{var p=Math.floor((f+u)/2),d=e[2*p],g=e[2*p+1];et(d,g,r,n)<=l&&s.push(t[p]);var v=(c+1)%2;(0===c?r-i<=d:n-i<=g)&&(o.push(f),o.push(p-1),o.push(v)),(0===c?r+i>=d:n+i>=g)&&(o.push(p+1),o.push(u),o.push(v))}}return s}(this.ids,this.coords,t,e,r,this.nodeSize)}};function ot(t){this.options=pt(Object.create(this.options),t),this.trees=new Array(this.options.maxZoom+1)}function st(t,e,r,n,i){return{x:t,y:e,zoom:1/0,id:n,properties:i,parentId:-1,numPoints:r}}function lt(t,e){var r=t.geometry.coordinates;return{x:ft(r[0]),y:ht(r[1]),zoom:1/0,id:e,parentId:-1}}function ct(t){return{type:"Feature",properties:ut(t),geometry:{type:"Point",coordinates:[(n=t.x,360*(n-.5)),(e=t.y,r=(180-360*e)*Math.PI/180,360*Math.atan(Math.exp(r))/Math.PI-90)]}};var e,r,n}function ut(t){var e=t.numPoints,r=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return pt(pt({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:r})}function ft(t){return t/360+.5}function ht(t){var e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function pt(t,e){for(var r in e)t[r]=e[r];return t}function dt(t){return t.x}function gt(t){return t.y}function vt(t,e,r,n,i,a){var o=i-r,s=a-n;if(0!==o||0!==s){var l=((t-r)*o+(e-n)*s)/(o*o+s*s);l>1?(r=i,n=a):l>0&&(r+=o*l,n+=s*l)}return(o=t-r)*o+(s=e-n)*s}function mt(t,e,r,n){var i={id:t||null,type:e,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,r=t.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)yt(t,e);else if("Polygon"===r||"MultiLineString"===r)for(var n=0;n0&&(o+=n?(i*c-l*a)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(c-a,2))),i=l,a=c}var u=e.length-3;e[2]=1,function t(e,r,n,i){for(var a,o=i,s=e[r],l=e[r+1],c=e[n],u=e[n+1],f=r+3;fo&&(a=f,o=h)}o>i&&(a-r>3&&t(e,r,a,i),e[a+2]=o,n-a>3&&t(e,a,n,i))}(e,0,u,r),e[u+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function wt(t,e,r,n){for(var i=0;i1?1:r}function At(t,e,r,n,i,a,o,s){if(n/=e,a>=(r/=e)&&o<=n)return t;if(a>n||o=r&&d<=n)l.push(u);else if(!(p>n||d=r&&o<=n&&(e.push(t[a]),e.push(t[a+1]),e.push(t[a+2]))}}function St(t,e,r,n,i,a,o){for(var s,l,c=Et(t),u=0===i?zt:Ot,f=t.start,h=0;h=r&&(l=u(c,p,d,v,m,r),o&&(c.start=f+s*l)):y>n?x<=n&&(l=u(c,p,d,v,m,n),o&&(c.start=f+s*l)):Lt(c,p,d,g),x=r&&(l=u(c,p,d,v,m,r),b=!0),x>n&&y<=n&&(l=u(c,p,d,v,m,n),b=!0),!a&&b&&(o&&(c.end=f+s*l),e.push(c),c=Et(t)),o&&(f+=s)}var _=t.length-3;p=t[_],d=t[_+1],g=t[_+2],(y=0===i?p:d)>=r&&y<=n&&Lt(c,p,d,g),_=c.length-3,a&&_>=3&&(c[_]!==c[0]||c[_+1]!==c[1])&&Lt(c,c[0],c[1],c[2]),c.length&&e.push(c)}function Et(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Ct(t,e,r,n,i,a){for(var o=0;oo.maxX&&(o.maxX=u),f>o.maxY&&(o.maxY=f)}return o}function Ft(t,e,r,n){var i=e.geometry,a=e.type,o=[];if("Point"===a||"MultiPoint"===a)for(var s=0;s0&&e.size<(i?o:n))r.numPoints+=e.length/3;else{for(var s=[],l=0;lo)&&(r.numSimplified++,s.push(e[l]),s.push(e[l+1])),r.numPoints++;i&&function(t,e){for(var r=0,n=0,i=t.length,a=i-2;n0===e)for(n=0,i=t.length;n24)throw new Error("maxZoom should be in the 0-24 range");var n=function(t,e){var r=[];if("FeatureCollection"===t.type)for(var n=0;n=this.options.minZoom;i--){var a=+Date.now();this.trees[i+1]=rt(n,dt,gt,this.options.nodeSize,Float32Array),n=this._cluster(n,i),e&&console.log("z%d: %d clusters in %dms",i,n.length,+Date.now()-a)}return this.trees[this.options.minZoom]=rt(n,dt,gt,this.options.nodeSize,Float32Array),e&&console.timeEnd("total time"),this},getClusters:function(t,e){for(var r=this.trees[this._limitZoom(e)],n=r.range(ft(t[0]),ht(t[3]),ft(t[2]),ht(t[1])),i=[],a=0;a1&&console.time("creation"),h=this.tiles[f]=Bt(t,e,r,n,l),this.tileCoords.push({z:e,x:r,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,h.numFeatures,h.numPoints,h.numSimplified),console.timeEnd("creation"));var p="z"+e;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(h.source=t,i){if(e===l.maxZoom||e===i)continue;var d=1<1&&console.time("clipping");var g,v,m,y,x,b,_=.5*l.buffer/l.extent,w=.5-_,k=.5+_,M=1+_;g=v=m=y=null,x=At(t,u,r-_,r+k,0,h.minX,h.maxX,l),b=At(t,u,r+w,r+M,0,h.minX,h.maxX,l),t=null,x&&(g=At(x,u,n-_,n+k,1,h.minY,h.maxY,l),v=At(x,u,n+w,n+M,1,h.minY,h.maxY,l),x=null),b&&(m=At(b,u,n-_,n+k,1,h.minY,h.maxY,l),y=At(b,u,n+w,n+M,1,h.minY,h.maxY,l),b=null),c>1&&console.timeEnd("clipping"),s.push(g||[],e+1,2*r,2*n),s.push(v||[],e+1,2*r,2*n+1),s.push(m||[],e+1,2*r+1,2*n),s.push(y||[],e+1,2*r+1,2*n+1)}}},jt.prototype.getTile=function(t,e,r){var n=this.options,i=n.extent,a=n.debug;if(t<0||t>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",t,e,r);for(var l,c=t,u=e,f=r;!l&&c>0;)c--,u=Math.floor(u/2),f=Math.floor(f/2),l=this.tiles[Vt(c,u,f)];return l&&l.source?(a>1&&console.log("found parent tile z%d-%d-%d",c,u,f),a>1&&console.time("drilling down"),this.splitTile(l.source,c,u,f,t,e,r),a>1&&console.timeEnd("drilling down"),this.tiles[s]?Dt(this.tiles[s],i):null):null};var qt=function(e){function r(t,r,n){e.call(this,t,r,Ut),n&&(this.loadGeoJSON=n)}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.loadData=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),this._pendingCallback=e,this._pendingLoadDataParams=t,this._state&&"Idle"!==this._state?this._state="NeedsLoadData":(this._state="Coalescing",this._loadData())},r.prototype._loadData=function(){var t=this;if(this._pendingCallback&&this._pendingLoadDataParams){var e=this._pendingCallback,r=this._pendingLoadDataParams;delete this._pendingCallback,delete this._pendingLoadDataParams,this.loadGeoJSON(r,function(n,i){if(n||!i)return e(n);if("object"!=typeof i)return e(new Error("Input data is not a valid GeoJSON object."));!function t(e,r){switch(e&&e.type||null){case"FeatureCollection":return e.features=e.features.map(z(t,r)),e;case"Feature":return e.geometry=t(e.geometry,r),e;case"Polygon":case"MultiPolygon":return function(t,e){return"Polygon"===t.type?t.coordinates=O(t.coordinates,e):"MultiPolygon"===t.type&&(t.coordinates=t.coordinates.map(z(O,e))),t}(e,r);default:return e}}(i,!0);try{t._geoJSONIndex=r.cluster?function(t){return new ot(t)}(r.superclusterOptions).load(i.features):new jt(i,r.geojsonVtOptions)}catch(n){return e(n)}t.loaded={};var a={};if(r.request&&r.request.collectResourceTiming){var o=w(r.request.url);o&&(a.resourceTiming={},a.resourceTiming[r.source]=JSON.parse(JSON.stringify(o)))}e(null,a)})}},r.prototype.coalesce=function(){"Coalescing"===this._state?this._state="Idle":"NeedsLoadData"===this._state&&(this._state="Coalescing",this._loadData())},r.prototype.reloadTile=function(t,r){var n=this.loaded,i=t.uid;return n&&n[i]?e.prototype.reloadTile.call(this,t,r):this.loadTile(t,r)},r.prototype.loadGeoJSON=function(e,r){if(e.request)t.getJSON(e.request,r);else{if("string"!=typeof e.data)return r(new Error("Input data is not a valid GeoJSON object."));try{return r(null,JSON.parse(e.data))}catch(t){return r(new Error("Input data is not a valid GeoJSON object."))}}},r.prototype.removeSource=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),e()},r}(M),Ht=function(e){var r=this;this.self=e,this.actor=new t.default$7(e,this),this.layerIndexes={},this.workerSourceTypes={vector:M,geojson:qt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=function(t,e){if(r.workerSourceTypes[t])throw new Error('Worker source with name "'+t+'" already registered.');r.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=function(e){if(t.plugin.isLoaded())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText}};return Ht.prototype.setLayers=function(t,e,r){this.getLayerIndex(t).replace(e),r()},Ht.prototype.updateLayers=function(t,e,r){this.getLayerIndex(t).update(e.layers,e.removedIds),r()},Ht.prototype.loadTile=function(t,e,r){this.getWorkerSource(t,e.type,e.source).loadTile(e,r)},Ht.prototype.loadDEMTile=function(t,e,r){this.getDEMWorkerSource(t,e.source).loadTile(e,r)},Ht.prototype.reloadTile=function(t,e,r){this.getWorkerSource(t,e.type,e.source).reloadTile(e,r)},Ht.prototype.abortTile=function(t,e,r){this.getWorkerSource(t,e.type,e.source).abortTile(e,r)},Ht.prototype.removeTile=function(t,e,r){this.getWorkerSource(t,e.type,e.source).removeTile(e,r)},Ht.prototype.removeDEMTile=function(t,e){this.getDEMWorkerSource(t,e.source).removeTile(e)},Ht.prototype.removeSource=function(t,e,r){if(this.workerSources[t]&&this.workerSources[t][e.type]&&this.workerSources[t][e.type][e.source]){var n=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==n.removeSource?n.removeSource(e,r):r()}},Ht.prototype.loadWorkerSource=function(t,e,r){try{this.self.importScripts(e.url),r()}catch(t){r(t.toString())}},Ht.prototype.loadRTLTextPlugin=function(e,r,n){try{t.plugin.isLoaded()||(this.self.importScripts(r),n(t.plugin.isLoaded()?null:new Error("RTL Text Plugin failed to import scripts from "+r)))}catch(t){n(t.toString())}},Ht.prototype.getLayerIndex=function(t){var e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new n),e},Ht.prototype.getWorkerSource=function(t,e,r){var n=this;if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][r]){var i={send:function(e,r,i){n.actor.send(e,r,i,t)}};this.workerSources[t][e][r]=new this.workerSourceTypes[e](i,this.getLayerIndex(t))}return this.workerSources[t][e][r]},Ht.prototype.getDEMWorkerSource=function(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new A),this.demWorkerSources[t][e]},"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&new Ht(self),Ht}),i(0,function(t){var e=t.createCommonjsModule(function(t){function e(t){return!!("undefined"!=typeof window&&"undefined"!=typeof document&&Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray&&Function.prototype&&Function.prototype.bind&&Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions&&"JSON"in window&&"parse"in JSON&&"stringify"in JSON&&function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,r=new Blob([""],{type:"text/javascript"}),n=URL.createObjectURL(r);try{e=new Worker(n),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(n),t}()&&"Uint8ClampedArray"in window&&function(t){return void 0===r[t]&&(r[t]=function(t){var r=document.createElement("canvas"),n=Object.create(e.webGLContextAttributes);return n.failIfMajorPerformanceCaveat=t,r.probablySupportsContext?r.probablySupportsContext("webgl",n)||r.probablySupportsContext("experimental-webgl",n):r.supportsContext?r.supportsContext("webgl",n)||r.supportsContext("experimental-webgl",n):r.getContext("webgl",n)||r.getContext("experimental-webgl",n)}(t)),r[t]}(t&&t.failIfMajorPerformanceCaveat))}t.exports?t.exports=e:window&&(window.mapboxgl=window.mapboxgl||{},window.mapboxgl.supported=e);var r={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0}}),r=t.default.performance&&t.default.performance.now?t.default.performance.now.bind(t.default.performance):Date.now.bind(Date),n=t.default.requestAnimationFrame||t.default.mozRequestAnimationFrame||t.default.webkitRequestAnimationFrame||t.default.msRequestAnimationFrame,i=t.default.cancelAnimationFrame||t.default.mozCancelAnimationFrame||t.default.webkitCancelAnimationFrame||t.default.msCancelAnimationFrame,a={now:r,frame:function(t){return n(t)},cancelFrame:function(t){return i(t)},getImageData:function(e){var r=t.default.document.createElement("canvas"),n=r.getContext("2d");if(!n)throw new Error("failed to create canvas 2d context");return r.width=e.width,r.height=e.height,n.drawImage(e,0,0,e.width,e.height),n.getImageData(0,0,e.width,e.height)},hardwareConcurrency:t.default.navigator.hardwareConcurrency||4,get devicePixelRatio(){return t.default.devicePixelRatio},supportsWebp:!1};if(t.default.document){var o=t.default.document.createElement("img");o.onload=function(){a.supportsWebp=!0},o.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="}var s={create:function(e,r,n){var i=t.default.document.createElement(e);return r&&(i.className=r),n&&n.appendChild(i),i},createNS:function(e,r){return t.default.document.createElementNS(e,r)}},l=t.default.document?t.default.document.documentElement.style:null;function c(t){if(!l)return null;for(var e=0;e=0?0:e.button},s.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};var v={API_URL:"https://api.mapbox.com",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null},m="See https://www.mapbox.com/api-documentation/#access-tokens";function y(t,e){var r=A(v.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"/"!==r.path&&(t.path=""+r.path+t.path),!v.REQUIRE_ACCESS_TOKEN)return T(t);if(!(e=e||v.ACCESS_TOKEN))throw new Error("An API access token is required to use Mapbox GL. "+m);if("s"===e[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+m);return t.params.push("access_token="+e),T(t)}function x(t){return 0===t.indexOf("mapbox:")}var b=function(t,e){if(!x(t))return t;var r=A(t);return r.path="/v4/"+r.authority+".json",r.params.push("secure"),y(r,e)},_=function(t,e,r,n){var i=A(t);return x(t)?(i.path="/styles/v1"+i.path+"/sprite"+e+r,y(i,n)):(i.path+=""+e+r,T(i))},w=/(\.(png|jpg)\d*)(?=$)/,k=function(t,e,r){if(!e||!x(e))return t;var n=A(t),i=a.devicePixelRatio>=2||512===r?"@2x":"",o=a.supportsWebp?".webp":"$1";return n.path=n.path.replace(w,""+i+o),function(t){for(var e=0;e=0?1.2:1))}function R(t,e,r,n,i,a,o){for(var s=0;s65535)e(new Error("glyphs > 65535 not supported"));else{var l=a.requests[s];l||(l=a.requests[s]=[],F.loadGlyphRange(r,s,n.url,n.requestTransform,function(t,e){if(e)for(var r in e)a.glyphs[+r]=e[+r];for(var n=0,i=l;nthis.height)return t.warnOnce("LineAtlas out of space"),null;for(var a=0,o=0;o90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")};G.prototype.wrap=function(){return new G(t.wrap(this.lng,-180,180),this.lat)},G.prototype.toArray=function(){return[this.lng,this.lat]},G.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},G.prototype.toBounds=function(t){var e=360*t/40075017,r=e/Math.cos(Math.PI/180*this.lat);return new W(new G(this.lng-r,this.lat-e),new G(this.lng+r,this.lat+e))},G.convert=function(t){if(t instanceof G)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new G(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new G(Number(t.lng),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, or an array of [, ]")};var W=function(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))};W.prototype.setNorthEast=function(t){return this._ne=t instanceof G?new G(t.lng,t.lat):G.convert(t),this},W.prototype.setSouthWest=function(t){return this._sw=t instanceof G?new G(t.lng,t.lat):G.convert(t),this},W.prototype.extend=function(t){var e,r,n=this._sw,i=this._ne;if(t instanceof G)e=t,r=t;else{if(!(t instanceof W))return Array.isArray(t)?t.every(Array.isArray)?this.extend(W.convert(t)):this.extend(G.convert(t)):this;if(e=t._sw,r=t._ne,!e||!r)return this}return n||i?(n.lng=Math.min(e.lng,n.lng),n.lat=Math.min(e.lat,n.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new G(e.lng,e.lat),this._ne=new G(r.lng,r.lat)),this},W.prototype.getCenter=function(){return new G((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},W.prototype.getSouthWest=function(){return this._sw},W.prototype.getNorthEast=function(){return this._ne},W.prototype.getNorthWest=function(){return new G(this.getWest(),this.getNorth())},W.prototype.getSouthEast=function(){return new G(this.getEast(),this.getSouth())},W.prototype.getWest=function(){return this._sw.lng},W.prototype.getSouth=function(){return this._sw.lat},W.prototype.getEast=function(){return this._ne.lng},W.prototype.getNorth=function(){return this._ne.lat},W.prototype.toArray=function(){return[this._sw.toArray(),this._ne.toArray()]},W.prototype.toString=function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"},W.prototype.isEmpty=function(){return!(this._sw&&this._ne)},W.convert=function(t){return!t||t instanceof W?t:new W(t)};var Y=function(t,e,r){this.bounds=W.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=r||24};Y.prototype.validateBounds=function(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]},Y.prototype.contains=function(t){var e=Math.floor(this.lngX(this.bounds.getWest(),t.z)),r=Math.floor(this.latY(this.bounds.getNorth(),t.z)),n=Math.ceil(this.lngX(this.bounds.getEast(),t.z)),i=Math.ceil(this.latY(this.bounds.getSouth(),t.z));return t.x>=e&&t.x=r&&t.y0&&(l[new t.OverscaledTileID(e.overscaledZ,a,r.z,i,r.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,r.z,o,r.y-1).key]={backfilled:!1}),r.y+10&&(n.resourceTiming=e._resourceTiming,e._resourceTiming=[]),e.fire(new t.Event("data",n))}})},r.prototype.onAdd=function(t){this.map=t,this.load()},r.prototype.setData=function(e){var r=this;return this._data=e,this.fire(new t.Event("dataloading",{dataType:"source"})),this._updateWorkerData(function(e){if(e)return r.fire(new t.ErrorEvent(e));var n={dataType:"source",sourceDataType:"content"};r._collectResourceTiming&&r._resourceTiming&&r._resourceTiming.length>0&&(n.resourceTiming=r._resourceTiming,r._resourceTiming=[]),r.fire(new t.Event("data",n))}),this},r.prototype._updateWorkerData=function(e){var r,n,i=this,a=t.extend({},this.workerOptions),o=this._data;"string"==typeof o?(a.request=this.map._transformRequest((r=o,(n=t.default.document.createElement("a")).href=r,n.href),t.ResourceType.Source),a.request.collectResourceTiming=this._collectResourceTiming):a.data=JSON.stringify(o),this.workerID=this.dispatcher.send(this.type+"."+a.source+".loadData",a,function(t,r){i._removed||r&&r.abandoned||(i._loaded=!0,r&&r.resourceTiming&&r.resourceTiming[i.id]&&(i._resourceTiming=r.resourceTiming[i.id].slice(0)),i.dispatcher.send(i.type+"."+a.source+".coalesce",null,null,i.workerID),e(t))},this.workerID)},r.prototype.loadTile=function(t,e){var r=this,n=void 0===t.workerID?"loadTile":"reloadTile",i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes};t.workerID=this.dispatcher.send(n,i,function(i,a){return t.unloadVectorData(),t.aborted?e(null):i?e(i):(t.loadVectorData(a,r.map.painter,"reloadTile"===n),e(null))},this.workerID)},r.prototype.abortTile=function(t){t.aborted=!0},r.prototype.unloadTile=function(t){t.unloadVectorData(),this.dispatcher.send("removeTile",{uid:t.uid,type:this.type,source:this.id},null,t.workerID)},r.prototype.onRemove=function(){this._removed=!0,this.dispatcher.send("removeSource",{type:this.type,source:this.id},null,this.workerID)},r.prototype.serialize=function(){return t.extend({},this._options,{type:this.type,data:this._data})},r.prototype.hasTransition=function(){return!1},r}(t.Evented),K=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Q=function(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null};Q.prototype.bind=function(t,e,r,n,i,a,o,s){this.context=t;for(var l=this.boundPaintVertexBuffers.length!==n.length,c=0;!l&&c>s.z,c=new t.default$1(s.x*l,s.y*l),u=new t.default$1(c.x+l,c.y+l),f=this.segments.prepareSegment(4,n,i);n.emplaceBack(c.x,c.y,c.x,c.y),n.emplaceBack(u.x,c.y,u.x,c.y),n.emplaceBack(c.x,u.y,c.x,u.y),n.emplaceBack(u.x,u.y,u.x,u.y);var h=f.vertexLength;i.emplaceBack(h,h+1,h+2),i.emplaceBack(h+1,h+2,h+3),f.vertexLength+=4,f.primitiveLength+=2}this.maskedBoundsBuffer=r.createVertexBuffer(n,K.members),this.maskedIndexBuffer=r.createIndexBuffer(i)}},st.prototype.hasData=function(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state},st.prototype.setExpiryData=function(e){var r=this.expirationTime;if(e.cacheControl){var n=t.parseCacheControl(e.cacheControl);n["max-age"]&&(this.expirationTime=Date.now()+1e3*n["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){var i=Date.now(),a=!1;if(this.expirationTime>i)a=!1;else if(r)if(this.expirationTimethis.max){var o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this},lt.prototype.has=function(t){return t.wrapped().key in this.data},lt.prototype.getAndRemove=function(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null},lt.prototype._getAndRemoveByKey=function(t){var e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value},lt.prototype.get=function(t){return this.has(t)?this.data[t.wrapped().key][0].value:null},lt.prototype.remove=function(t,e){if(!this.has(t))return this;var r=t.wrapped().key,n=void 0===e?0:this.data[r].indexOf(e),i=this.data[r][n];return this.data[r].splice(n,1),i.timeout&&clearTimeout(i.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(i.value),this.order.splice(this.order.indexOf(r),1),this},lt.prototype.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this};var ct=function(t,e,r){this.context=t;var n=t.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(r),this.unbindVAO(),t.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};ct.prototype.unbindVAO=function(){this.context.extVertexArrayObject&&this.context.bindVertexArrayOES.set(null)},ct.prototype.bind=function(){this.context.bindElementBuffer.set(this.buffer)},ct.prototype.updateData=function(t){var e=this.context.gl;this.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)},ct.prototype.destroy=function(){var t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)};var ut={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},ft=function(t,e,r,n){this.length=e.length,this.attributes=r,this.itemSize=e.bytesPerElement,this.dynamicDraw=n,this.context=t;var i=t.gl;this.buffer=i.createBuffer(),t.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};ft.prototype.bind=function(){this.context.bindVertexBuffer.set(this.buffer)},ft.prototype.updateData=function(t){var e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)},ft.prototype.enableAttributes=function(t,e){for(var r=0;r1||(Math.abs(r)>1&&(1===Math.abs(r+i)?r+=i:1===Math.abs(r-i)&&(r-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,r,n),t.neighboringTiles&&t.neighboringTiles[a]&&(t.neighboringTiles[a].backfilled=!0)))}},r.prototype.getTile=function(t){return this.getTileByID(t.key)},r.prototype.getTileByID=function(t){return this._tiles[t]},r.prototype.getZoom=function(t){return t.zoom+t.scaleZoom(t.tileSize/this._source.tileSize)},r.prototype._findLoadedChildren=function(t,e,r){var n=!1;for(var i in this._tiles){var a=this._tiles[i];if(!(r[i]||!a.hasData()||a.tileID.overscaledZ<=t.overscaledZ||a.tileID.overscaledZ>e)){var o=Math.pow(2,a.tileID.canonical.z-t.canonical.z);if(Math.floor(a.tileID.canonical.x/o)===t.canonical.x&&Math.floor(a.tileID.canonical.y/o)===t.canonical.y)for(r[i]=a.tileID,n=!0;a&&a.tileID.overscaledZ-1>t.overscaledZ;){var s=a.tileID.scaledTo(a.tileID.overscaledZ-1);if(!s)break;(a=this._tiles[s.key])&&a.hasData()&&(delete r[i],r[s.key]=s)}}}return n},r.prototype.findLoadedParent=function(t,e,r){for(var n=t.overscaledZ-1;n>=e;n--){var i=t.scaledTo(n);if(!i)return;var a=String(i.key),o=this._tiles[a];if(o&&o.hasData())return r[a]=i,o;if(this._cache.has(i))return r[a]=i,this._cache.get(i)}},r.prototype.updateCacheSize=function(t){var e=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),r=Math.floor(5*e),n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(n)},r.prototype.handleWrapJump=function(t){var e=(t-(void 0===this._prevLng?t:this._prevLng))/360,r=Math.round(e);if(this._prevLng=t,r){var n={};for(var i in this._tiles){var a=this._tiles[i];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+r),n[a.tileID.key]=a}for(var o in this._tiles=n,this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(var s in this._tiles){var l=this._tiles[s];this._setTileReloadTimer(s,l)}}},r.prototype.update=function(e){var n=this;if(this.transform=e,this._sourceLoaded&&!this._paused){var i;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(function(e){return new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)}):(i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}),this._source.hasTile&&(i=i.filter(function(t){return n._source.hasTile(t)}))):i=[];var o,s=(this._source.roundZoom?Math.round:Math.floor)(this.getZoom(e)),l=Math.max(s-r.maxOverzooming,this._source.minzoom),c=Math.max(s+r.maxUnderzooming,this._source.minzoom),u=this._updateRetainedTiles(i,s),f={};if(Zt(this._source.type))for(var h=Object.keys(u),p=0;p=a.now())){n._findLoadedChildren(g,c,u)&&(u[d]=g);var m=n.findLoadedParent(g,l,f);m&&n._addTile(m.tileID)}}for(o in f)u[o]||(n._coveredTiles[o]=!0);for(o in f)u[o]=f[o];for(var y=t.keysDifference(this._tiles,u),x=0;xthis._source.maxzoom){var h=l.children(this._source.maxzoom)[0],p=this.getTile(h);p&&p.hasData()?n[h.key]=h:f=!1}else{this._findLoadedChildren(l,o,n);for(var d=l.children(this._source.maxzoom),g=0;g=a;--v){var m=l.scaledTo(v);if(i[m.key])break;if(i[m.key]=!0,!(c=this.getTile(m))&&u&&(c=this._addTile(m)),c&&(n[m.key]=m,u=c.wasRequested(),c.hasData()))break}}}return n},r.prototype._addTile=function(e){var r=this._tiles[e.key];if(r)return r;(r=this._cache.getAndRemove(e))&&(this._setTileReloadTimer(e.key,r),r.tileID=e);var n=Boolean(r);return n||(r=new st(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(r,this._tileLoaded.bind(this,r,e.key,r.state))),r?(r.uses++,this._tiles[e.key]=r,n||this._source.fire(new t.Event("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null},r.prototype._setTileReloadTimer=function(t,e){var r=this;t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);var n=e.getExpiryTimeout();n&&(this._timers[t]=setTimeout(function(){r._reloadTile(t,"expired"),delete r._timers[t]},n))},r.prototype._removeTile=function(t){var e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))},r.prototype.clearTiles=function(){for(var t in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(t);this._cache.reset()},r.prototype.tilesIn=function(e,r){for(var n=[],i=this.getIds(),a=1/0,o=1/0,s=-1/0,l=-1/0,c=e[0].zoom,u=0;u=0&&m[1].y+v>=0){for(var y=[],x=0;x=a.now())return!0}return!1},r}(t.Evented);function Xt(e,r){var n=r.zoomTo(e.canonical.z);return new t.default$1((n.column-(e.canonical.x+e.wrap*Math.pow(2,e.canonical.z)))*t.default$8,(n.row-e.canonical.y)*t.default$8)}function Zt(t){return"raster"===t||"image"===t||"video"===t}function $t(){return new t.default.Worker(En.workerUrl)}Yt.maxOverzooming=10,Yt.maxUnderzooming=3;var Jt,Kt=function(){this.active={}};function Qt(e,r){var n={};for(var i in e)"ref"!==i&&(n[i]=e[i]);return t.default$18.forEach(function(t){t in r&&(n[t]=r[t])}),n}function te(t){t=t.slice();for(var e=Object.create(null),r=0;rthis.width||n<0||e>this.height)return!i&&[];var a=[];if(t<=0&&e<=0&&this.width<=r&&this.height<=n){if(i)return!0;for(var o=0;o0:a},ce.prototype._queryCircle=function(t,e,r,n){var i=t-r,a=t+r,o=e-r,s=e+r;if(a<0||i>this.width||s<0||o>this.height)return!n&&[];var l=[],c={hitTest:n,circle:{x:t,y:e,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(i,o,a,s,this._queryCellCircle,l,c),n?l.length>0:l},ce.prototype.query=function(t,e,r,n){return this._query(t,e,r,n,!1)},ce.prototype.hitTest=function(t,e,r,n){return this._query(t,e,r,n,!0)},ce.prototype.hitTestCircle=function(t,e,r){return this._queryCircle(t,e,r,!0)},ce.prototype._queryCell=function(t,e,r,n,i,a,o){var s=o.seenUids,l=this.boxCells[i];if(null!==l)for(var c=this.bboxes,u=0,f=l;u=c[p+0]&&n>=c[p+1]){if(o.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[h],x1:c[p],y1:c[p+1],x2:c[p+2],y2:c[p+3]})}}}var d=this.circleCells[i];if(null!==d)for(var g=this.circles,v=0,m=d;vo*o+s*s},ce.prototype._circleAndRectCollide=function(t,e,r,n,i,a,o){var s=(a-n)/2,l=Math.abs(t-(n+s));if(l>s+r)return!1;var c=(o-i)/2,u=Math.abs(e-(i+c));if(u>c+r)return!1;if(l<=s||u<=c)return!0;var f=l-s,h=u-c;return f*f+h*h<=r*r};var ue=t.default$19.layout;function fe(e,r,n,i,a){var o=t.mat4.identity(new Float32Array(16));return r?(t.mat4.identity(o),t.mat4.scale(o,o,[1/a,1/a,1]),n||t.mat4.rotateZ(o,o,i.angle)):(t.mat4.scale(o,o,[i.width/2,-i.height/2,1]),t.mat4.translate(o,o,[1,-1,0]),t.mat4.multiply(o,o,e)),o}function he(e,r,n,i,a){var o=t.mat4.identity(new Float32Array(16));return r?(t.mat4.multiply(o,o,e),t.mat4.scale(o,o,[a,a,1]),n||t.mat4.rotateZ(o,o,-i.angle)):(t.mat4.scale(o,o,[1,-1,1]),t.mat4.translate(o,o,[-1,-1,0]),t.mat4.scale(o,o,[2/i.width,2/i.height,1])),o}function pe(e,r){var n=[e.x,e.y,0,1];ke(n,n,r);var i=n[3];return{point:new t.default$1(n[0]/i,n[1]/i),signedDistanceFromCamera:i}}function de(t,e){var r=t[0]/t[3],n=t[1]/t[3];return r>=-e[0]&&r<=e[0]&&n>=-e[1]&&n<=e[1]}function ge(e,r,n,i,a,o,s,l){var c=i?e.textSizeData:e.iconSizeData,u=t.evaluateSizeForZoom(c,n.transform.zoom,ue.properties[i?"text-size":"icon-size"]),f=[256/n.width*2+1,256/n.height*2+1],h=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;h.clear();for(var p=e.lineVertexArray,d=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,g=n.transform.width/n.transform.height,v=!1,m=0;mMath.abs(n.x-r.x)*i?{useVertical:!0}:(e===t.WritingMode.vertical?r.yn.x)?{needsFlipping:!0}:null}function ye(e,r,n,i,a,o,s,l,c,u,f,h,p,d){var g,v=r/24,m=e.lineOffsetX*r,y=e.lineOffsetY*r;if(e.numGlyphs>1){var x=e.glyphStartIndex+e.numGlyphs,b=e.lineStartIndex,_=e.lineStartIndex+e.lineLength,w=ve(v,l,m,y,n,f,h,e,c,o,p,!1);if(!w)return{notEnoughRoom:!0};var k=pe(w.first.point,s).point,M=pe(w.last.point,s).point;if(i&&!n){var A=me(e.writingMode,k,M,d);if(A)return A}g=[w.first];for(var T=e.glyphStartIndex+1;T0?L.point:xe(h,C,S,1,a),O=me(e.writingMode,S,z,d);if(O)return O}var I=be(v*l.getoffsetX(e.glyphStartIndex),m,y,n,f,h,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,o,p,!1);if(!I)return{notEnoughRoom:!0};g=[I]}for(var P=0,D=g;P0?1:-1,v=0;i&&(g*=-1,v=Math.PI),g<0&&(v+=Math.PI);for(var m=g>0?l+s:l+s+1,y=m,x=a,b=a,_=0,w=0,k=Math.abs(d);_+w<=k;){if((m+=g)=c)return null;if(b=x,void 0===(x=h[m])){var M=new t.default$1(u.getx(m),u.gety(m)),A=pe(M,f);if(A.signedDistanceFromCamera>0)x=h[m]=A.point;else{var T=m-g;x=xe(0===_?o:new t.default$1(u.getx(T),u.gety(T)),M,b,k-_+1,f)}}_+=w,w=b.dist(x)}var S=(k-_)/w,E=x.sub(b),C=E.mult(S)._add(b);return C._add(E._unit()._perp()._mult(n*g)),{point:C,angle:v+Math.atan2(x.y-b.y,x.x-b.x),tileDistance:p?{prevTileDistance:m-g===y?0:u.gettileUnitDistanceFromAnchor(m-g),lastSegmentViewportDistance:k-_}:null}}var _e=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function we(t,e){for(var r=0;rT)Ae(e,S,!1);else{var O=this.projectPoint(u,E,C),I=L*k;if(d.length>0){var P=O.x-d[d.length-4],D=O.y-d[d.length-3];if(I*I*2>P*P+D*D&&S+8-A&&R=this.screenRightBoundary||n<100||e>this.screenBottomBoundary};var Se=t.default$19.layout,Ee=function(t,e,r,n){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):n&&r?1:0,this.placed=r};Ee.prototype.isHidden=function(){return 0===this.opacity&&!this.placed};var Ce=function(t,e,r,n,i){this.text=new Ee(t?t.text:null,e,r,i),this.icon=new Ee(t?t.icon:null,e,n,i)};Ce.prototype.isHidden=function(){return this.text.isHidden()&&this.icon.isHidden()};var Le=function(t,e,r){this.text=t,this.icon=e,this.skipFade=r},ze=function(t,e){this.transform=t.clone(),this.collisionIndex=new Me(this.transform),this.placements={},this.opacities={},this.stale=!1,this.fadeDuration=e,this.retainedQueryData={}};function Oe(t,e,r){t.emplaceBack(e?1:0,r?1:0),t.emplaceBack(e?1:0,r?1:0),t.emplaceBack(e?1:0,r?1:0),t.emplaceBack(e?1:0,r?1:0)}ze.prototype.placeLayerTile=function(e,r,n,i){var a=r.getBucket(e),o=r.latestFeatureIndex;if(a&&o&&e.id===a.layerIds[0]){var s=r.collisionBoxArray,l=a.layers[0].layout,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.default$8,f=this.transform.calculatePosMatrix(r.tileID.toUnwrapped()),h=fe(f,"map"===l.get("text-pitch-alignment"),"map"===l.get("text-rotation-alignment"),this.transform,Te(r,1,this.transform.zoom)),p=fe(f,"map"===l.get("icon-pitch-alignment"),"map"===l.get("icon-rotation-alignment"),this.transform,Te(r,1,this.transform.zoom));this.retainedQueryData[a.bucketInstanceId]=new function(t,e,r,n,i){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=r,this.bucketIndex=n,this.tileID=i}(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,r.tileID),this.placeLayerBucket(a,f,h,p,c,u,n,i,s)}},ze.prototype.placeLayerBucket=function(e,r,n,i,a,o,s,l,c){for(var u=e.layers[0].layout,f=t.evaluateSizeForZoom(e.textSizeData,this.transform.zoom,Se.properties["text-size"]),h=!e.hasTextData()||u.get("text-optional"),p=!e.hasIconData()||u.get("icon-optional"),d=0,g=e.symbolInstances;d0,x=x&&b.offscreen);var A=v.collisionArrays.textCircles;if(A){var T=e.text.placedSymbolArray.get(v.placedTextSymbolIndices[0]),S=t.evaluateSizeForFeature(e.textSizeData,f,T);_=this.collisionIndex.placeCollisionCircles(A,u.get("text-allow-overlap"),a,o,v.key,T,e.lineVertexArray,e.glyphOffsetArray,S,r,n,s,"map"===u.get("text-pitch-alignment")),m=u.get("text-allow-overlap")||_.circles.length>0,x=x&&_.offscreen}v.collisionArrays.iconFeatureIndex&&(M=v.collisionArrays.iconFeatureIndex),v.collisionArrays.iconBox&&(y=(w=this.collisionIndex.placeCollisionBox(v.collisionArrays.iconBox,u.get("icon-allow-overlap"),o,r)).box.length>0,x=x&&w.offscreen),h||p?p?h||(y=y&&m):m=y&&m:y=m=y&&m,m&&b&&this.collisionIndex.insertCollisionBox(b.box,u.get("text-ignore-placement"),e.bucketInstanceId,k),y&&w&&this.collisionIndex.insertCollisionBox(w.box,u.get("icon-ignore-placement"),e.bucketInstanceId,M),m&&_&&this.collisionIndex.insertCollisionCircles(_.circles,u.get("text-ignore-placement"),e.bucketInstanceId,k),this.placements[v.crossTileID]=new Le(m,y,x||e.justReloaded),l[v.crossTileID]=!0}}e.justReloaded=!1},ze.prototype.commit=function(t,e){this.commitTime=e;var r=!1,n=t&&0!==this.fadeDuration?(this.commitTime-t.commitTime)/this.fadeDuration:1,i=t?t.opacities:{};for(var a in this.placements){var o=this.placements[a],s=i[a];s?(this.opacities[a]=new Ce(s,n,o.text,o.icon),r=r||o.text!==s.text.placed||o.icon!==s.icon.placed):(this.opacities[a]=new Ce(null,n,o.text,o.icon,o.skipFade),r=r||o.text||o.icon)}for(var l in i){var c=i[l];if(!this.opacities[l]){var u=new Ce(c,n,!1,!1);u.isHidden()||(this.opacities[l]=u,r=r||c.text.placed||c.icon.placed)}}r?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)},ze.prototype.updateLayerOpacities=function(t,e){for(var r={},n=0,i=e;n0||s.numVerticalGlyphVertices>0,f=s.numIconVertices>0;if(u){for(var h=je(c.text),p=(s.numGlyphVertices+s.numVerticalGlyphVertices)/4,d=0;dt},ze.prototype.setStale=function(){this.stale=!0};var Ie=Math.pow(2,25),Pe=Math.pow(2,24),De=Math.pow(2,17),Re=Math.pow(2,16),Be=Math.pow(2,9),Fe=Math.pow(2,8),Ne=Math.pow(2,1);function je(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;var e=t.placed?1:0,r=Math.floor(127*t.opacity);return r*Ie+e*Pe+r*De+e*Re+r*Be+e*Fe+r*Ne+e}var Ve=function(){this._currentTileIndex=0,this._seenCrossTileIDs={}};Ve.prototype.continuePlacement=function(t,e,r,n,i){for(;this._currentTileIndex2};this._currentPlacementIndex>=0;){var s=e[t[n._currentPlacementIndex]],l=n.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){if(n._inProgressLayer||(n._inProgressLayer=new Ve),n._inProgressLayer.continuePlacement(r[s.source],n.placement,n._showCollisionBoxes,s,o))return;delete n._inProgressLayer}n._currentPlacementIndex--}this._done=!0},Ue.prototype.commit=function(t,e){return this.placement.commit(t,e),this.placement};var qe=512/t.default$8/2,He=function(t,e,r){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=r;for(var n=0,i=e;nt.overscaledZ)for(var l in s){var c=s[l];c.tileID.isChildOf(t)&&c.findMatches(e.symbolInstances,t,a)}else{var u=s[t.scaledTo(Number(o)).key];u&&u.findMatches(e.symbolInstances,t,a)}}for(var f=0,h=e.symbolInstances;f1?"@2x":"";function c(){if(s)n(s);else if(i&&o){var e=a.getImageData(o),r={};for(var l in i){var c=i[l],u=c.width,f=c.height,h=c.x,p=c.y,d=c.sdf,g=c.pixelRatio,v=new t.RGBAImage({width:u,height:f});t.RGBAImage.copy(e,v,{x:h,y:p},{x:0,y:0},{width:u,height:f}),r[l]={data:v,pixelRatio:g,sdf:d}}n(null,r)}}t.getJSON(r(_(e,l,".json"),t.ResourceType.SpriteJSON),function(t,e){s||(s=t,i=e,c())}),t.getImage(r(_(e,l,".png"),t.ResourceType.SpriteImage),function(t,e){s||(s=t,o=e,c())})}(e.sprite,this.map._transformRequest,function(e,r){if(e)n.fire(new t.ErrorEvent(e));else if(r)for(var i in r)n.imageManager.addImage(i,r[i]);n.imageManager.setLoaded(!0),n.fire(new t.Event("data",{dataType:"style"}))}):this.imageManager.setLoaded(!0),this.glyphManager.setURL(e.glyphs);var o=te(this.stylesheet.layers);this._order=o.map(function(t){return t.id}),this._layers={};for(var s=0,l=o;s0)throw new Error("Unimplemented: "+i.map(function(t){return t.command}).join(", ")+".");return n.forEach(function(t){"setTransition"!==t.command&&r[t.command].apply(r,t.args)}),this.stylesheet=e,!0},r.prototype.addImage=function(e,r){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(e,r),this.fire(new t.Event("data",{dataType:"style"}))},r.prototype.getImage=function(t){return this.imageManager.getImage(t)},r.prototype.removeImage=function(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(e),this.fire(new t.Event("data",{dataType:"style"}))},r.prototype.addSource=function(e,r,n){var i=this;if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error("There is already a source with this ID");if(!r.type)throw new Error("The type property must be defined, but the only the following properties were given: "+Object.keys(r).join(", ")+".");if(!(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(t.validateStyle.source,"sources."+e,r,null,n))){this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);var a=this.sourceCaches[e]=new Yt(e,r,this.dispatcher);a.style=this,a.setEventedParent(this,function(){return{isSourceLoaded:i.loaded(),source:a.serialize(),sourceId:e}}),a.onAdd(this.map),this._changed=!0}},r.prototype.removeSource=function(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(var r in this._layers)if(this._layers[r].source===e)return this.fire(new t.ErrorEvent(new Error('Source "'+e+'" cannot be removed while layer "'+r+'" is using it.')));var n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.clearTiles(),n.onRemove&&n.onRemove(this.map),this._changed=!0},r.prototype.setGeoJSONSourceData=function(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0},r.prototype.getSource=function(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()},r.prototype.addLayer=function(e,r,n){this._checkLoaded();var i=e.id;if(this.getLayer(i))this.fire(new t.ErrorEvent(new Error('Layer with id "'+i+'" already exists on this map')));else if("object"==typeof e.source&&(this.addSource(i,e.source),e=t.clone(e),e=t.extend(e,{source:i})),!this._validate(t.validateStyle.layer,"layers."+i,e,{arrayIndex:-1},n)){var a=t.default$22(e);this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}});var o=r?this._order.indexOf(r):this._order.length;if(r&&-1===o)this.fire(new t.ErrorEvent(new Error('Layer with id "'+r+'" does not exist on this map.')));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source){var s=this._removedLayers[i];delete this._removedLayers[i],s.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause())}this._updateLayer(a)}}},r.prototype.moveLayer=function(e,r){if(this._checkLoaded(),this._changed=!0,this._layers[e]){if(e!==r){var n=this._order.indexOf(e);this._order.splice(n,1);var i=r?this._order.indexOf(r):this._order.length;r&&-1===i?this.fire(new t.ErrorEvent(new Error('Layer with id "'+r+'" does not exist on this map.'))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be moved.")))},r.prototype.removeLayer=function(e){this._checkLoaded();var r=this._layers[e];if(r){r.setEventedParent(null);var n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=r,delete this._layers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e]}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be removed.")))},r.prototype.getLayer=function(t){return this._layers[t]},r.prototype.setLayerZoomRange=function(e,r,n){this._checkLoaded();var i=this.getLayer(e);i?i.minzoom===r&&i.maxzoom===n||(null!=r&&(i.minzoom=r),null!=n&&(i.maxzoom=n),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot have zoom extent.")))},r.prototype.setFilter=function(e,r){this._checkLoaded();var n=this.getLayer(e);if(n){if(!t.default$10(n.filter,r))return null==r?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(t.validateStyle.filter,"layers."+n.id+".filter",r)||(n.filter=t.clone(r),this._updateLayer(n)))}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be filtered.")))},r.prototype.getFilter=function(e){return t.clone(this.getLayer(e).filter)},r.prototype.setLayoutProperty=function(e,r,n){this._checkLoaded();var i=this.getLayer(e);i?t.default$10(i.getLayoutProperty(r),n)||(i.setLayoutProperty(r,n),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},r.prototype.getLayoutProperty=function(t,e){return this.getLayer(t).getLayoutProperty(e)},r.prototype.setPaintProperty=function(e,r,n){this._checkLoaded();var i=this.getLayer(e);if(i){if(!t.default$10(i.getPaintProperty(r),n)){var a=i._transitionablePaint._values[r].value.isDataDriven();i.setPaintProperty(r,n),(i._transitionablePaint._values[r].value.isDataDriven()||a)&&this._updateLayer(i),this._changed=!0,this._updatedPaintProps[e]=!0}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},r.prototype.getPaintProperty=function(t,e){return this.getLayer(t).getPaintProperty(e)},r.prototype.getTransition=function(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)},r.prototype.serialize=function(){var e=this;return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:t.mapObject(this.sourceCaches,function(t){return t.serialize()}),layers:this._order.map(function(t){return e._layers[t].serialize()})},function(t){return void 0!==t})},r.prototype._updateLayer=function(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0},r.prototype._flattenRenderedFeatures=function(t){for(var e=[],r=this._order.length-1;r>=0;r--)for(var n=this._order[r],i=0,a=t;i 0.5) {\n gl_FragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha;\n }\n\n if (v_notUsed > 0.5) {\n // This box not used, fade it out\n gl_FragColor *= .1;\n }\n}",vertexSource:"attribute vec2 a_pos;\nattribute vec2 a_anchor_pos;\nattribute vec2 a_extrude;\nattribute vec2 a_placed;\n\nuniform mat4 u_matrix;\nuniform vec2 u_extrude_scale;\nuniform float u_camera_to_center_distance;\n\nvarying float v_placed;\nvarying float v_notUsed;\n\nvoid main() {\n vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n highp float collision_perspective_ratio = clamp(\n 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),\n 0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles\n 4.0);\n\n gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n gl_Position.xy += a_extrude * u_extrude_scale * gl_Position.w * collision_perspective_ratio;\n\n v_placed = a_placed.x;\n v_notUsed = a_placed.y;\n}\n"},collisionCircle:{fragmentSource:"uniform float u_overscale_factor;\n\nvarying float v_placed;\nvarying float v_notUsed;\nvarying float v_radius;\nvarying vec2 v_extrude;\nvarying vec2 v_extrude_scale;\n\nvoid main() {\n float alpha = 0.5;\n\n // Red = collision, hide label\n vec4 color = vec4(1.0, 0.0, 0.0, 1.0) * alpha;\n\n // Blue = no collision, label is showing\n if (v_placed > 0.5) {\n color = vec4(0.0, 0.0, 1.0, 0.5) * alpha;\n }\n\n if (v_notUsed > 0.5) {\n // This box not used, fade it out\n color *= .2;\n }\n\n float extrude_scale_length = length(v_extrude_scale);\n float extrude_length = length(v_extrude) * extrude_scale_length;\n float stroke_width = 15.0 * extrude_scale_length / u_overscale_factor;\n float radius = v_radius * extrude_scale_length;\n\n float distance_to_edge = abs(extrude_length - radius);\n float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge);\n\n gl_FragColor = opacity_t * color;\n}\n",vertexSource:"attribute vec2 a_pos;\nattribute vec2 a_anchor_pos;\nattribute vec2 a_extrude;\nattribute vec2 a_placed;\n\nuniform mat4 u_matrix;\nuniform vec2 u_extrude_scale;\nuniform float u_camera_to_center_distance;\n\nvarying float v_placed;\nvarying float v_notUsed;\nvarying float v_radius;\n\nvarying vec2 v_extrude;\nvarying vec2 v_extrude_scale;\n\nvoid main() {\n vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n highp float collision_perspective_ratio = clamp(\n 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),\n 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles\n 4.0);\n\n gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n\n highp float padding_factor = 1.2; // Pad the vertices slightly to make room for anti-alias blur\n gl_Position.xy += a_extrude * u_extrude_scale * padding_factor * gl_Position.w * collision_perspective_ratio;\n\n v_placed = a_placed.x;\n v_notUsed = a_placed.y;\n v_radius = abs(a_extrude.y); // We don't pitch the circles, so both units of the extrusion vector are equal in magnitude to the radius\n\n v_extrude = a_extrude * padding_factor;\n v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio;\n}\n"},debug:{fragmentSource:"uniform highp vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n}\n"},fill:{fragmentSource:"#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float opacity\n\n gl_FragColor = color * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n}\n"},fillOutline:{fragmentSource:"#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_pos;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = 1.0 - smoothstep(0.0, 1.0, dist);\n gl_FragColor = outline_color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\nuniform vec2 u_world;\n\nvarying vec2 v_pos;\n\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},fillOutlinePattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n // find distance to outline for alpha interpolation\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = 1.0 - smoothstep(0.0, 1.0, dist);\n\n\n gl_FragColor = mix(color1, color2, u_mix) * alpha * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_world;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);\n\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},fillPattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n gl_FragColor = mix(color1, color2, u_mix) * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);\n}\n"},fillExtrusion:{fragmentSource:"varying vec4 v_color;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define highp vec4 color\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n #pragma mapbox: initialize highp vec4 color\n\n gl_FragColor = v_color;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec3 u_lightcolor;\nuniform lowp vec3 u_lightpos;\nuniform lowp float u_lightintensity;\n\nattribute vec2 a_pos;\nattribute vec4 a_normal_ed;\n\nvarying vec4 v_color;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\n#pragma mapbox: define highp vec4 color\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n #pragma mapbox: initialize highp vec4 color\n\n vec3 normal = a_normal_ed.xyz;\n\n base = max(0.0, base);\n height = max(0.0, height);\n\n float t = mod(normal.x, 2.0);\n\n gl_Position = u_matrix * vec4(a_pos, t > 0.0 ? height : base, 1);\n\n // Relative luminance (how dark/bright is the surface color?)\n float colorvalue = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722;\n\n v_color = vec4(0.0, 0.0, 0.0, 1.0);\n\n // Add slight ambient lighting so no extrusions are totally black\n vec4 ambientlight = vec4(0.03, 0.03, 0.03, 1.0);\n color += ambientlight;\n\n // Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray\n float directional = clamp(dot(normal / 16384.0, u_lightpos), 0.0, 1.0);\n\n // Adjust directional so that\n // the range of values for highlight/shading is narrower\n // with lower light intensity\n // and with lighter/brighter surface colors\n directional = mix((1.0 - u_lightintensity), max((1.0 - colorvalue + u_lightintensity), 1.0), directional);\n\n // Add gradient along z axis of side surfaces\n if (normal.y != 0.0) {\n directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0);\n }\n\n // Assign final color based on surface + ambient light color, diffuse light directional, and light color\n // with lower bounds adjusted to hue of light\n // so that shading is tinted with the complementary (opposite) color to the light color\n v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0);\n v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0);\n v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0);\n}\n"},fillExtrusionPattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec4 v_lighting;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n vec4 mixedColor = mix(color1, color2, u_mix);\n\n gl_FragColor = mixedColor * v_lighting;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\nuniform float u_height_factor;\n\nuniform vec3 u_lightcolor;\nuniform lowp vec3 u_lightpos;\nuniform lowp float u_lightintensity;\n\nattribute vec2 a_pos;\nattribute vec4 a_normal_ed;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec4 v_lighting;\nvarying float v_directional;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n\n vec3 normal = a_normal_ed.xyz;\n float edgedistance = a_normal_ed.w;\n\n base = max(0.0, base);\n height = max(0.0, height);\n\n float t = mod(normal.x, 2.0);\n float z = t > 0.0 ? height : base;\n\n gl_Position = u_matrix * vec4(a_pos, z, 1);\n\n vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0\n ? a_pos // extrusion top\n : vec2(edgedistance, z * u_height_factor); // extrusion side\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, pos);\n\n v_lighting = vec4(0.0, 0.0, 0.0, 1.0);\n float directional = clamp(dot(normal / 16383.0, u_lightpos), 0.0, 1.0);\n directional = mix((1.0 - u_lightintensity), max((0.5 + u_lightintensity), 1.0), directional);\n\n if (normal.y != 0.0) {\n directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0);\n }\n\n v_lighting.rgb += clamp(directional * u_lightcolor, mix(vec3(0.0), vec3(0.3), 1.0 - u_lightcolor), vec3(1.0));\n}\n"},extrusionTexture:{fragmentSource:"uniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\n\nvoid main() {\n gl_FragColor = texture2D(u_image, v_pos) * u_opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(0.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_world;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1);\n\n v_pos.x = a_pos.x;\n v_pos.y = 1.0 - a_pos.y;\n}\n"},hillshadePrepare:{fragmentSource:"#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D u_image;\nvarying vec2 v_pos;\nuniform vec2 u_dimension;\nuniform float u_zoom;\nuniform float u_maxzoom;\n\nfloat getElevation(vec2 coord, float bias) {\n // Convert encoded elevation value to meters\n vec4 data = texture2D(u_image, coord) * 255.0;\n return (data.r + data.g * 256.0 + data.b * 256.0 * 256.0) / 4.0;\n}\n\nvoid main() {\n vec2 epsilon = 1.0 / u_dimension;\n\n // queried pixels:\n // +-----------+\n // | | | |\n // | a | b | c |\n // | | | |\n // +-----------+\n // | | | |\n // | d | e | f |\n // | | | |\n // +-----------+\n // | | | |\n // | g | h | i |\n // | | | |\n // +-----------+\n\n float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0);\n float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0);\n float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0);\n float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0);\n float e = getElevation(v_pos, 0.0);\n float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0);\n float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0);\n float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0);\n float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0);\n\n // here we divide the x and y slopes by 8 * pixel size\n // where pixel size (aka meters/pixel) is:\n // circumference of the world / (pixels per tile * number of tiles)\n // which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom))\n // which can be reduced to: pow(2, 19.25619978527 - u_zoom)\n // we want to vertically exaggerate the hillshading though, because otherwise\n // it is barely noticeable at low zooms. to do this, we multiply this by some\n // scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value\n // Here we use a=0.3 which works out to the expression below. see \n // nickidlugash's awesome breakdown for more info\n // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556\n float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;\n\n vec2 deriv = vec2(\n (c + f + f + i) - (a + d + d + g),\n (g + h + h + i) - (a + b + b + c)\n ) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom);\n\n gl_FragColor = clamp(vec4(\n deriv.x / 2.0 + 0.5,\n deriv.y / 2.0 + 0.5,\n 1.0,\n 1.0), 0.0, 1.0);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = (a_texture_pos / 8192.0) / 2.0 + 0.25;\n}\n"},hillshade:{fragmentSource:"uniform sampler2D u_image;\nvarying vec2 v_pos;\n\nuniform vec2 u_latrange;\nuniform vec2 u_light;\nuniform vec4 u_shadow;\nuniform vec4 u_highlight;\nuniform vec4 u_accent;\n\n#define PI 3.141592653589793\n\nvoid main() {\n vec4 pixel = texture2D(u_image, v_pos);\n\n vec2 deriv = ((pixel.rg * 2.0) - 1.0);\n\n // We divide the slope by a scale factor based on the cosin of the pixel's approximate latitude\n // to account for mercator projection distortion. see #4807 for details\n float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_pos.y) + u_latrange[1]));\n // We also multiply the slope by an arbitrary z-factor of 1.25\n float slope = atan(1.25 * length(deriv) / scaleFactor);\n float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0);\n\n float intensity = u_light.x;\n // We add PI to make this property match the global light object, which adds PI/2 to the light's azimuthal\n // position property to account for 0deg corresponding to north/the top of the viewport in the style spec\n // and the original shader was written to accept (-illuminationDirection - 90) as the azimuthal.\n float azimuth = u_light.y + PI;\n\n // We scale the slope exponentially based on intensity, using a calculation similar to\n // the exponential interpolation function in the style spec:\n // https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/expression/definitions/interpolate.js#L217-L228\n // so that higher intensity values create more opaque hillshading.\n float base = 1.875 - intensity * 1.75;\n float maxValue = 0.5 * PI;\n float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope;\n\n // The accent color is calculated with the cosine of the slope while the shade color is calculated with the sine\n // so that the accent color's rate of change eases in while the shade color's eases out.\n float accent = cos(scaledSlope);\n // We multiply both the accent and shade color by a clamped intensity value\n // so that intensities >= 0.5 do not additionally affect the color values\n // while intensity values < 0.5 make the overall color more transparent.\n vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0);\n float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0);\n vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0);\n gl_FragColor = accent_color * (1.0 - shade_color.a) + shade_color;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = a_texture_pos / 8192.0;\n}\n"},line:{fragmentSource:"#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_width2;\nvarying vec2 v_normal;\nvarying float v_gamma_scale;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_gamma_scale;\nvarying highp float v_linesofar;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n\n v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_width2 = vec2(outset, inset);\n}\n"},lineGradient:{fragmentSource:"\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nuniform sampler2D u_image;\n\nvarying vec2 v_width2;\nvarying vec2 v_normal;\nvarying float v_gamma_scale;\nvarying highp float v_lineprogress;\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n // For gradient lines, v_lineprogress is the ratio along the entire line,\n // scaled to [0, 2^15), and the gradient ramp is stored in a texture.\n vec4 color = texture2D(u_image, vec2(v_lineprogress, 0.5));\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"\n// the attribute conveying progress along a line is scaled to [0, 2^15)\n#define MAX_LINE_DISTANCE 32767.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_gamma_scale;\nvarying highp float v_lineprogress;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n\n v_lineprogress = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_width2 = vec2(outset, inset);\n}\n"},linePattern:{fragmentSource:"uniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_fade;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n float x_a = mod(v_linesofar / u_pattern_size_a.x, 1.0);\n float x_b = mod(v_linesofar / u_pattern_size_b.x, 1.0);\n\n // v_normal.y is 0 at the midpoint of the line, -1 at the lower edge, 1 at the upper edge\n // we clamp the line width outset to be between 0 and half the pattern height plus padding (2.0)\n // to ensure we don't sample outside the designated symbol on the sprite sheet.\n // 0.5 is added to shift the component to be bounded between 0 and 1 for interpolation of\n // the texture coordinate\n float y_a = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (u_pattern_size_a.y + 2.0) / 2.0) / u_pattern_size_a.y);\n float y_b = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (u_pattern_size_b.y + 2.0) / 2.0) / u_pattern_size_b.y);\n vec2 pos_a = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, vec2(x_a, y_a));\n vec2 pos_b = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, vec2(x_b, y_b));\n\n vec4 color = mix(texture2D(u_image, pos_a), texture2D(u_image, pos_b), u_fade);\n\n gl_FragColor = color * alpha * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_linesofar = a_linesofar;\n v_width2 = vec2(outset, inset);\n}\n"},lineSDF:{fragmentSource:"\nuniform sampler2D u_image;\nuniform float u_sdfgamma;\nuniform float u_mix;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float width\n #pragma mapbox: initialize lowp float floorwidth\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n float sdfdist_a = texture2D(u_image, v_tex_a).a;\n float sdfdist_b = texture2D(u_image, v_tex_b).a;\n float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix);\n alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist);\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_patternscale_a;\nuniform float u_tex_y_a;\nuniform vec2 u_patternscale_b;\nuniform float u_tex_y_b;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n #pragma mapbox: initialize lowp float floorwidth\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist =outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a);\n v_tex_b = vec2(a_linesofar * u_patternscale_b.x / floorwidth, normal.y * u_patternscale_b.y + u_tex_y_b);\n\n v_width2 = vec2(outset, inset);\n}\n"},raster:{fragmentSource:"uniform float u_fade_t;\nuniform float u_opacity;\nuniform sampler2D u_image0;\nuniform sampler2D u_image1;\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nuniform float u_brightness_low;\nuniform float u_brightness_high;\n\nuniform float u_saturation_factor;\nuniform float u_contrast_factor;\nuniform vec3 u_spin_weights;\n\nvoid main() {\n\n // read and cross-fade colors from the main and parent tiles\n vec4 color0 = texture2D(u_image0, v_pos0);\n vec4 color1 = texture2D(u_image1, v_pos1);\n if (color0.a > 0.0) {\n color0.rgb = color0.rgb / color0.a;\n }\n if (color1.a > 0.0) {\n color1.rgb = color1.rgb / color1.a;\n }\n vec4 color = mix(color0, color1, u_fade_t);\n color.a *= u_opacity;\n vec3 rgb = color.rgb;\n\n // spin\n rgb = vec3(\n dot(rgb, u_spin_weights.xyz),\n dot(rgb, u_spin_weights.zxy),\n dot(rgb, u_spin_weights.yzx));\n\n // saturation\n float average = (color.r + color.g + color.b) / 3.0;\n rgb += (average - rgb) * u_saturation_factor;\n\n // contrast\n rgb = (rgb - 0.5) * u_contrast_factor + 0.5;\n\n // brightness\n vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);\n vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);\n\n gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_tl_parent;\nuniform float u_scale_parent;\nuniform float u_buffer_scale;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n // We are using Int16 for texture position coordinates to give us enough precision for\n // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer\n // as an arbitrarily high number to preserve adequate precision when rendering.\n // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates,\n // so math for modifying either is consistent.\n v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5;\n v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;\n}\n"},symbolIcon:{fragmentSource:"uniform sampler2D u_texture;\n\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_tex;\nvarying float v_fade_opacity;\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n lowp float alpha = opacity * v_fade_opacity;\n gl_FragColor = texture2D(u_texture, v_tex) * alpha;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"const float PI = 3.141592653589793;\n\nattribute vec4 a_pos_offset;\nattribute vec4 a_data;\nattribute vec3 a_projected_pos;\nattribute float a_fade_opacity;\n\nuniform bool u_is_size_zoom_constant;\nuniform bool u_is_size_feature_constant;\nuniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function\nuniform highp float u_size; // used when size is both zoom and feature constant\nuniform highp float u_camera_to_center_distance;\nuniform highp float u_pitch;\nuniform bool u_rotate_symbol;\nuniform highp float u_aspect_ratio;\nuniform float u_fade_change;\n\n#pragma mapbox: define lowp float opacity\n\nuniform mat4 u_matrix;\nuniform mat4 u_label_plane_matrix;\nuniform mat4 u_gl_coord_matrix;\n\nuniform bool u_is_text;\nuniform bool u_pitch_with_map;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_tex;\nvarying float v_fade_opacity;\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 a_pos = a_pos_offset.xy;\n vec2 a_offset = a_pos_offset.zw;\n\n vec2 a_tex = a_data.xy;\n vec2 a_size = a_data.zw;\n\n highp float segment_angle = -a_projected_pos[2];\n\n float size;\n if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = mix(a_size[0], a_size[1], u_size_t) / 10.0;\n } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = a_size[0] / 10.0;\n } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {\n size = u_size;\n } else {\n size = u_size;\n }\n\n vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n // See comments in symbol_sdf.vertex\n highp float distance_ratio = u_pitch_with_map ?\n camera_to_anchor_distance / u_camera_to_center_distance :\n u_camera_to_center_distance / camera_to_anchor_distance;\n highp float perspective_ratio = clamp(\n 0.5 + 0.5 * distance_ratio,\n 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles\n 4.0);\n\n size *= perspective_ratio;\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n highp float symbol_rotation = 0.0;\n if (u_rotate_symbol) {\n // See comments in symbol_sdf.vertex\n vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);\n\n vec2 a = projectedPoint.xy / projectedPoint.w;\n vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;\n\n symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);\n }\n\n highp float angle_sin = sin(segment_angle + symbol_rotation);\n highp float angle_cos = cos(segment_angle + symbol_rotation);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);\n gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);\n\n v_tex = a_tex / u_texsize;\n vec2 fade_opacity = unpack_opacity(a_fade_opacity);\n float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;\n v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));\n}\n"},symbolSDF:{fragmentSource:"#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105/DEVICE_PIXEL_RATIO\n\nuniform bool u_is_halo;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n\nuniform sampler2D u_texture;\nuniform highp float u_gamma_scale;\nuniform bool u_is_text;\n\nvarying vec2 v_data0;\nvarying vec3 v_data1;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 fill_color\n #pragma mapbox: initialize highp vec4 halo_color\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float halo_width\n #pragma mapbox: initialize lowp float halo_blur\n\n vec2 tex = v_data0.xy;\n float gamma_scale = v_data1.x;\n float size = v_data1.y;\n float fade_opacity = v_data1[2];\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n lowp vec4 color = fill_color;\n highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);\n lowp float buff = (256.0 - 64.0) / 256.0;\n if (u_is_halo) {\n color = halo_color;\n gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);\n buff = (6.0 - halo_width / fontScale) / SDF_PX;\n }\n\n lowp float dist = texture2D(u_texture, tex).a;\n highp float gamma_scaled = gamma * gamma_scale;\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = color * (alpha * opacity * fade_opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"const float PI = 3.141592653589793;\n\nattribute vec4 a_pos_offset;\nattribute vec4 a_data;\nattribute vec3 a_projected_pos;\nattribute float a_fade_opacity;\n\n// contents of a_size vary based on the type of property value\n// used for {text,icon}-size.\n// For constants, a_size is disabled.\n// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.\n// For composite functions:\n// [ text-size(lowerZoomStop, feature),\n// text-size(upperZoomStop, feature) ]\nuniform bool u_is_size_zoom_constant;\nuniform bool u_is_size_feature_constant;\nuniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function\nuniform highp float u_size; // used when size is both zoom and feature constant\n\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n\nuniform mat4 u_matrix;\nuniform mat4 u_label_plane_matrix;\nuniform mat4 u_gl_coord_matrix;\n\nuniform bool u_is_text;\nuniform bool u_pitch_with_map;\nuniform highp float u_pitch;\nuniform bool u_rotate_symbol;\nuniform highp float u_aspect_ratio;\nuniform highp float u_camera_to_center_distance;\nuniform float u_fade_change;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_data0;\nvarying vec3 v_data1;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 fill_color\n #pragma mapbox: initialize highp vec4 halo_color\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float halo_width\n #pragma mapbox: initialize lowp float halo_blur\n\n vec2 a_pos = a_pos_offset.xy;\n vec2 a_offset = a_pos_offset.zw;\n\n vec2 a_tex = a_data.xy;\n vec2 a_size = a_data.zw;\n\n highp float segment_angle = -a_projected_pos[2];\n float size;\n\n if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = mix(a_size[0], a_size[1], u_size_t) / 10.0;\n } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = a_size[0] / 10.0;\n } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {\n size = u_size;\n } else {\n size = u_size;\n }\n\n vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n // If the label is pitched with the map, layout is done in pitched space,\n // which makes labels in the distance smaller relative to viewport space.\n // We counteract part of that effect by multiplying by the perspective ratio.\n // If the label isn't pitched with the map, we do layout in viewport space,\n // which makes labels in the distance larger relative to the features around\n // them. We counteract part of that effect by dividing by the perspective ratio.\n highp float distance_ratio = u_pitch_with_map ?\n camera_to_anchor_distance / u_camera_to_center_distance :\n u_camera_to_center_distance / camera_to_anchor_distance;\n highp float perspective_ratio = clamp(\n 0.5 + 0.5 * distance_ratio,\n 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles\n 4.0);\n\n size *= perspective_ratio;\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n highp float symbol_rotation = 0.0;\n if (u_rotate_symbol) {\n // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units\n // To figure out that angle in projected space, we draw a short horizontal line in tile\n // space, project it, and measure its angle in projected space.\n vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);\n\n vec2 a = projectedPoint.xy / projectedPoint.w;\n vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;\n\n symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);\n }\n\n highp float angle_sin = sin(segment_angle + symbol_rotation);\n highp float angle_cos = cos(segment_angle + symbol_rotation);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);\n gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);\n float gamma_scale = gl_Position.w;\n\n vec2 tex = a_tex / u_texsize;\n vec2 fade_opacity = unpack_opacity(a_fade_opacity);\n float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;\n float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));\n\n v_data0 = vec2(tex.x, tex.y);\n v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity);\n}\n"}},tr=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,er=function(t){var e=Qe[t],r={};e.fragmentSource=e.fragmentSource.replace(tr,function(t,e,n,i,a){return r[a]=!0,"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nvarying "+n+" "+i+" "+a+";\n#else\nuniform "+n+" "+i+" u_"+a+";\n#endif\n":"\n#ifdef HAS_UNIFORM_u_"+a+"\n "+n+" "+i+" "+a+" = u_"+a+";\n#endif\n"}),e.vertexSource=e.vertexSource.replace(tr,function(t,e,n,i,a){var o="float"===i?"vec2":"vec4";return r[a]?"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float a_"+a+"_t;\nattribute "+n+" "+o+" a_"+a+";\nvarying "+n+" "+i+" "+a+";\n#else\nuniform "+n+" "+i+" u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+a+" = unpack_mix_"+o+"(a_"+a+", a_"+a+"_t);\n#else\n "+n+" "+i+" "+a+" = u_"+a+";\n#endif\n":"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float a_"+a+"_t;\nattribute "+n+" "+o+" a_"+a+";\n#else\nuniform "+n+" "+i+" u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+n+" "+i+" "+a+" = unpack_mix_"+o+"(a_"+a+", a_"+a+"_t);\n#else\n "+n+" "+i+" "+a+" = u_"+a+";\n#endif\n"})};for(var rr in Qe)er(rr);var nr=Qe,ir=function(t,e,r,n){var i=t.gl;this.program=i.createProgram();var o=r.defines().concat("#define DEVICE_PIXEL_RATIO "+a.devicePixelRatio.toFixed(1));n&&o.push("#define OVERDRAW_INSPECTOR;");var s=o.concat(nr.prelude.fragmentSource,e.fragmentSource).join("\n"),l=o.concat(nr.prelude.vertexSource,e.vertexSource).join("\n"),c=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(c,s),i.compileShader(c),i.attachShader(this.program,c);var u=i.createShader(i.VERTEX_SHADER);i.shaderSource(u,l),i.compileShader(u),i.attachShader(this.program,u);for(var f=r.layoutAttributes||[],h=0;h>16,s>>16),n.uniform2f(r.uniforms.u_pixel_coord_lower,65535&o,65535&s)};function mr(t,e,r,n,i){if(!dr(r.paint.get("fill-pattern"),t))for(var a=!0,o=0,s=n;o0){var l=a.now(),c=(l-e.timeAdded)/s,u=r?(l-r.timeAdded)/s:-1,f=n.getSource(),h=o.coveringZoomLevel({tileSize:f.tileSize,roundZoom:f.roundZoom}),p=!r||Math.abs(r.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),d=p&&e.refreshedUponExpiration?1:t.clamp(p?c:1-u,0,1);return e.refreshedUponExpiration&&c>=1&&(e.refreshedUponExpiration=!1),r?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}function Er(e,r,n){var i=e.context,o=i.gl;i.lineWidth.set(1*a.devicePixelRatio);var s=n.posMatrix,l=e.useProgram("debug");i.setDepthMode(qt.disabled),i.setStencilMode(Ht.disabled),i.setColorMode(e.colorModeForRenderPass()),o.uniformMatrix4fv(l.uniforms.u_matrix,!1,s),o.uniform4f(l.uniforms.u_color,1,0,0,1),e.debugVAO.bind(i,l,e.debugBuffer,[]),o.drawArrays(o.LINE_STRIP,0,e.debugBuffer.length);for(var c=function(t,e,r,n){n=n||1;var i,a,o,s,l,c,u,f,h=[];for(i=0,a=t.length;i":[24,[4,18,20,9,4,0]],"?":[18,[3,16,3,17,4,19,5,20,7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,12,9,10,9,7,-1,-1,9,2,8,1,9,0,10,1,9,2]],"@":[27,[18,13,17,15,15,16,12,16,10,15,9,14,8,11,8,8,9,6,11,5,14,5,16,6,17,8,-1,-1,12,16,10,14,9,11,9,8,10,6,11,5,-1,-1,18,16,17,8,17,6,19,5,21,5,23,7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,21,9,20,7,19,5,17,4,15,3,12,3,9,4,6,5,4,7,2,9,1,12,0,15,0,18,1,20,2,21,3,-1,-1,19,16,18,8,18,6,19,5]],A:[18,[9,21,1,0,-1,-1,9,21,17,0,-1,-1,4,7,14,7]],B:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,-1,-1,4,11,13,11,16,10,17,9,18,7,18,4,17,2,16,1,13,0,4,0]],C:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5]],D:[21,[4,21,4,0,-1,-1,4,21,11,21,14,20,16,18,17,16,18,13,18,8,17,5,16,3,14,1,11,0,4,0]],E:[19,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11,-1,-1,4,0,17,0]],F:[18,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11]],G:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,18,8,-1,-1,13,8,18,8]],H:[22,[4,21,4,0,-1,-1,18,21,18,0,-1,-1,4,11,18,11]],I:[8,[4,21,4,0]],J:[16,[12,21,12,5,11,2,10,1,8,0,6,0,4,1,3,2,2,5,2,7]],K:[21,[4,21,4,0,-1,-1,18,21,4,7,-1,-1,9,12,18,0]],L:[17,[4,21,4,0,-1,-1,4,0,16,0]],M:[24,[4,21,4,0,-1,-1,4,21,12,0,-1,-1,20,21,12,0,-1,-1,20,21,20,0]],N:[22,[4,21,4,0,-1,-1,4,21,18,0,-1,-1,18,21,18,0]],O:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21]],P:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,10,4,10]],Q:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21,-1,-1,12,4,18,-2]],R:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,4,11,-1,-1,11,11,18,0]],S:[20,[17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3]],T:[16,[8,21,8,0,-1,-1,1,21,15,21]],U:[22,[4,21,4,6,5,3,7,1,10,0,12,0,15,1,17,3,18,6,18,21]],V:[18,[1,21,9,0,-1,-1,17,21,9,0]],W:[24,[2,21,7,0,-1,-1,12,21,7,0,-1,-1,12,21,17,0,-1,-1,22,21,17,0]],X:[20,[3,21,17,0,-1,-1,17,21,3,0]],Y:[18,[1,21,9,11,9,0,-1,-1,17,21,9,11]],Z:[20,[17,21,3,0,-1,-1,3,21,17,21,-1,-1,3,0,17,0]],"[":[14,[4,25,4,-7,-1,-1,5,25,5,-7,-1,-1,4,25,11,25,-1,-1,4,-7,11,-7]],"\\":[14,[0,21,14,-3]],"]":[14,[9,25,9,-7,-1,-1,10,25,10,-7,-1,-1,3,25,10,25,-1,-1,3,-7,10,-7]],"^":[16,[6,15,8,18,10,15,-1,-1,3,12,8,17,13,12,-1,-1,8,17,8,0]],_:[16,[0,-2,16,-2]],"`":[10,[6,21,5,20,4,18,4,16,5,15,6,16,5,17]],a:[19,[15,14,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],b:[19,[4,21,4,0,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],c:[18,[15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],d:[19,[15,21,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],e:[18,[3,8,15,8,15,10,14,12,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],f:[12,[10,21,8,21,6,20,5,17,5,0,-1,-1,2,14,9,14]],g:[19,[15,14,15,-2,14,-5,13,-6,11,-7,8,-7,6,-6,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],h:[19,[4,21,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],i:[8,[3,21,4,20,5,21,4,22,3,21,-1,-1,4,14,4,0]],j:[10,[5,21,6,20,7,21,6,22,5,21,-1,-1,6,14,6,-3,5,-6,3,-7,1,-7]],k:[17,[4,21,4,0,-1,-1,14,14,4,4,-1,-1,8,8,15,0]],l:[8,[4,21,4,0]],m:[30,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0,-1,-1,15,10,18,13,20,14,23,14,25,13,26,10,26,0]],n:[19,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],o:[19,[8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3,16,6,16,8,15,11,13,13,11,14,8,14]],p:[19,[4,14,4,-7,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],q:[19,[15,14,15,-7,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],r:[13,[4,14,4,0,-1,-1,4,8,5,11,7,13,9,14,12,14]],s:[17,[14,11,13,13,10,14,7,14,4,13,3,11,4,9,6,8,11,7,13,6,14,4,14,3,13,1,10,0,7,0,4,1,3,3]],t:[12,[5,21,5,4,6,1,8,0,10,0,-1,-1,2,14,9,14]],u:[19,[4,14,4,4,5,1,7,0,10,0,12,1,15,4,-1,-1,15,14,15,0]],v:[16,[2,14,8,0,-1,-1,14,14,8,0]],w:[22,[3,14,7,0,-1,-1,11,14,7,0,-1,-1,11,14,15,0,-1,-1,19,14,15,0]],x:[17,[3,14,14,0,-1,-1,14,14,3,0]],y:[16,[2,14,8,0,-1,-1,14,14,8,0,6,-4,4,-6,2,-7,1,-7]],z:[17,[14,14,3,0,-1,-1,3,14,14,14,-1,-1,3,0,14,0]],"{":[14,[9,25,7,24,6,23,5,21,5,19,6,17,7,16,8,14,8,12,6,10,-1,-1,7,24,6,22,6,20,7,18,8,17,9,15,9,13,8,11,4,9,8,7,9,5,9,3,8,1,7,0,6,-2,6,-4,7,-6,-1,-1,6,8,8,6,8,4,7,2,6,1,5,-1,5,-3,6,-5,7,-6,9,-7]],"|":[8,[4,25,4,-7]],"}":[14,[5,25,7,24,8,23,9,21,9,19,8,17,7,16,6,14,6,12,8,10,-1,-1,7,24,8,22,8,20,7,18,6,17,5,15,5,13,6,11,10,9,6,7,5,5,5,3,6,1,7,0,8,-2,8,-4,7,-6,-1,-1,8,8,6,6,6,4,7,2,8,1,9,-1,9,-3,8,-5,7,-6,5,-7]],"~":[24,[3,6,3,8,4,11,6,12,8,12,10,11,14,8,16,7,18,7,20,8,21,10,-1,-1,3,8,4,10,6,11,8,11,10,10,14,7,16,6,18,6,20,7,21,10,21,12]]},Lr={symbol:function(t,e,r,n){if("translucent"===t.renderPass){var i=t.context;i.setStencilMode(Ht.disabled),i.setColorMode(t.colorModeForRenderPass()),0!==r.paint.get("icon-opacity").constantOr(1)&&cr(t,e,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright")),0!==r.paint.get("text-opacity").constantOr(1)&&cr(t,e,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright")),e.map.showCollisionBoxes&&function(t,e,r,n){or(t,e,r,n,!1),or(t,e,r,n,!0)}(t,e,r,n)}},circle:function(t,e,r,n){if("translucent"===t.renderPass){var i=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),o=r.paint.get("circle-stroke-opacity");if(0!==i.constantOr(1)||0!==a.constantOr(1)&&0!==o.constantOr(1)){var s=t.context,l=s.gl;s.setDepthMode(t.depthModeForSublayer(0,qt.ReadOnly)),s.setStencilMode(Ht.disabled),s.setColorMode(t.colorModeForRenderPass());for(var c=!0,u=0;u0?1-1/(1.001-i):-i),s.uniform1f(c.uniforms.u_contrast_factor,(a=r.paint.get("raster-contrast"))>0?1/(1-a):1+a),s.uniform3fv(c.uniforms.u_spin_weights,function(t){t*=Math.PI/180;var e=Math.sin(t),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*e-r+1)/3,(Math.sqrt(3)*e-r+1)/3]}(r.paint.get("raster-hue-rotate"))),s.uniform1f(c.uniforms.u_buffer_scale,1),s.uniform1i(c.uniforms.u_image0,0),s.uniform1i(c.uniforms.u_image1,1);for(var u=n.length&&n[0].overscaledZ,f=0,h=n;fe.row){var r=t;t=e,e=r}return{x0:t.column,y0:t.row,x1:e.column,y1:e.row,dx:e.column-t.column,dy:e.row-t.row}}function Ir(t,e,r,n,i){var a=Math.max(r,Math.floor(e.y0)),o=Math.min(n,Math.ceil(e.y1));if(t.x0===e.x0&&t.y0===e.y0?t.x0+e.dy/t.dy*t.dx0,f=e.dx<0,h=a;hl.dy&&(o=s,s=l,l=o),s.dy>c.dy&&(o=s,s=c,c=o),l.dy>c.dy&&(o=l,l=c,c=o),s.dy&&Ir(c,s,n,i,a),l.dy&&Ir(c,l,n,i,a)}zr.prototype.resize=function(t,e){var r=this.context.gl;if(this.width=t*a.devicePixelRatio,this.height=e*a.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(var n=0,i=this.style._order;n=0;this.currentLayer--){var m=n.style._layers[s[n.currentLayer]];m.source!==(g&&g.id)&&(v=[],(g=n.style.sourceCaches[m.source])&&(n.clearStencil(),v=g.getVisibleCoordinates(),g.getSource().isTileClipped&&n._renderTileClippingMasks(v))),n.renderLayer(n,g,m,v)}this.renderPass="translucent";var y,x=[];for(this.currentLayer=0,this.currentLayer;this.currentLayer0?e.pop():null},zr.prototype._createProgramCached=function(t,e){this.cache=this.cache||{};var r=""+t+(e.cacheKey||"")+(this._showOverdrawInspector?"/overdraw":"");return this.cache[r]||(this.cache[r]=new ir(this.context,nr[t],e,this._showOverdrawInspector)),this.cache[r]},zr.prototype.useProgram=function(t,e){var r=this._createProgramCached(t,e||this.emptyProgramConfiguration);return this.context.program.set(r.program),r};var Dr=t.default$20.vec4,Rr=t.default$20.mat4,Br=t.default$20.mat2,Fr=function(t,e,r){this.tileSize=512,this._renderWorldCopies=void 0===r||r,this._minZoom=t||0,this._maxZoom=e||22,this.latRange=[-85.05113,85.05113],this.width=0,this.height=0,this._center=new G(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._posMatrixCache={},this._alignedPosMatrixCache={}},Nr={minZoom:{configurable:!0},maxZoom:{configurable:!0},renderWorldCopies:{configurable:!0},worldSize:{configurable:!0},centerPoint:{configurable:!0},size:{configurable:!0},bearing:{configurable:!0},pitch:{configurable:!0},fov:{configurable:!0},zoom:{configurable:!0},center:{configurable:!0},unmodified:{configurable:!0},x:{configurable:!0},y:{configurable:!0},point:{configurable:!0}};Fr.prototype.clone=function(){var t=new Fr(this._minZoom,this._maxZoom,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._calcMatrices(),t},Nr.minZoom.get=function(){return this._minZoom},Nr.minZoom.set=function(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},Nr.maxZoom.get=function(){return this._maxZoom},Nr.maxZoom.set=function(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},Nr.renderWorldCopies.get=function(){return this._renderWorldCopies},Nr.renderWorldCopies.set=function(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t},Nr.worldSize.get=function(){return this.tileSize*this.scale},Nr.centerPoint.get=function(){return this.size._div(2)},Nr.size.get=function(){return new t.default$1(this.width,this.height)},Nr.bearing.get=function(){return-this.angle/Math.PI*180},Nr.bearing.set=function(e){var r=-t.wrap(e,-180,180)*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=Br.create(),Br.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},Nr.pitch.get=function(){return this._pitch/Math.PI*180},Nr.pitch.set=function(e){var r=t.clamp(e,0,60)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())},Nr.fov.get=function(){return this._fov/Math.PI*180},Nr.fov.set=function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())},Nr.zoom.get=function(){return this._zoom},Nr.zoom.set=function(t){var e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._constrain(),this._calcMatrices())},Nr.center.get=function(){return this._center},Nr.center.set=function(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())},Fr.prototype.coveringZoomLevel=function(t){return(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize))},Fr.prototype.getVisibleUnwrappedCoordinates=function(e){var r=this.pointCoordinate(new t.default$1(0,0),0),n=this.pointCoordinate(new t.default$1(this.width,0),0),i=Math.floor(r.column),a=Math.floor(n.column),o=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies)for(var s=i;s<=a;s++)0!==s&&o.push(new t.UnwrappedTileID(s,e));return o},Fr.prototype.coveringTiles=function(e){var r=this.coveringZoomLevel(e),n=r;if(void 0!==e.minzoom&&re.maxzoom&&(r=e.maxzoom);var i=this.pointCoordinate(this.centerPoint,r),a=new t.default$1(i.column-.5,i.row-.5);return function(e,r,n,i){void 0===i&&(i=!0);var a=1<=0&&l<=a)for(c=r;co&&(i=o-g)}if(this.lngRange){var v=this.x,m=c.x/2;v-ml&&(n=l-m)}void 0===n&&void 0===i||(this.center=this.unproject(new t.default$1(void 0!==n?n:this.x,void 0!==i?i:this.y))),this._unmodified=u,this._constraining=!1}},Fr.prototype._calcMatrices=function(){if(this.height){this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height;var t=this._fov/2,e=Math.PI/2+this._pitch,r=Math.sin(t)*this.cameraToCenterDistance/Math.sin(Math.PI-e-t),n=this.x,i=this.y,a=1.01*(Math.cos(Math.PI/2-this._pitch)*r+this.cameraToCenterDistance),o=new Float64Array(16);Rr.perspective(o,this._fov,this.width/this.height,1,a),Rr.scale(o,o,[1,-1,1]),Rr.translate(o,o,[0,0,-this.cameraToCenterDistance]),Rr.rotateX(o,o,this._pitch),Rr.rotateZ(o,o,this.angle),Rr.translate(o,o,[-n,-i,0]);var s=this.worldSize/(2*Math.PI*6378137*Math.abs(Math.cos(this.center.lat*(Math.PI/180))));Rr.scale(o,o,[1,1,s,1]),this.projMatrix=o;var l=this.width%2/2,c=this.height%2/2,u=Math.cos(this.angle),f=Math.sin(this.angle),h=n-Math.round(n)+u*l+f*c,p=i-Math.round(i)+u*c+f*l,d=new Float64Array(o);if(Rr.translate(d,d,[h>.5?h-1:h,p>.5?p-1:p,0]),this.alignedProjMatrix=d,o=Rr.create(),Rr.scale(o,o,[this.width/2,-this.height/2,1]),Rr.translate(o,o,[1,-1,0]),this.pixelMatrix=Rr.multiply(new Float64Array(16),o,this.projMatrix),!(o=Rr.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={}}},Fr.prototype.maxPitchScaleFactor=function(){if(!this.pixelMatrixInverse)return 1;var e=this.pointCoordinate(new t.default$1(0,0)).zoomTo(this.zoom),r=[e.column*this.tileSize,e.row*this.tileSize,0,1];return Dr.transformMat4(r,r,this.pixelMatrix)[3]/this.cameraToCenterDistance},Object.defineProperties(Fr.prototype,Nr);var jr=function(){var e,r,n,i;t.bindAll(["_onHashChange","_updateHash"],this),this._updateHash=(e=this._updateHashUnthrottled.bind(this),300,r=!1,n=0,i=function(){n=0,r&&(e(),n=setTimeout(i,300),r=!1)},function(){return r=!0,n||i(),n})};jr.prototype.addTo=function(e){return this._map=e,t.default.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this},jr.prototype.remove=function(){return t.default.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this},jr.prototype.getHashString=function(t){var e=this._map.getCenter(),r=Math.round(100*this._map.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.pow(10,n),a=Math.round(e.lng*i)/i,o=Math.round(e.lat*i)/i,s=this._map.getBearing(),l=this._map.getPitch(),c="";return c+=t?"#/"+a+"/"+o+"/"+r:"#"+r+"/"+o+"/"+a,(s||l)&&(c+="/"+Math.round(10*s)/10),l&&(c+="/"+Math.round(l)),c},jr.prototype._onHashChange=function(){var e=t.default.location.hash.replace("#","").split("/");return e.length>=3&&(this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:+(e[3]||0),pitch:+(e[4]||0)}),!0)},jr.prototype._updateHashUnthrottled=function(){var e=this.getHashString();t.default.history.replaceState(t.default.history.state,"",e)};var Vr=function(e){function r(r,n,i,a){void 0===a&&(a={});var o=s.mousePos(n.getCanvasContainer(),i),l=n.unproject(o);e.call(this,r,t.extend({point:o,lngLat:l,originalEvent:i},a)),this._defaultPrevented=!1,this.target=n}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var n={defaultPrevented:{configurable:!0}};return r.prototype.preventDefault=function(){this._defaultPrevented=!0},n.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(r.prototype,n),r}(t.Event),Ur=function(e){function r(r,n,i){var a=s.touchPos(n.getCanvasContainer(),i),o=a.map(function(t){return n.unproject(t)}),l=a.reduce(function(t,e,r,n){return t.add(e.div(n.length))},new t.default$1(0,0)),c=n.unproject(l);e.call(this,r,{points:a,point:l,lngLats:o,lngLat:c,originalEvent:i}),this._defaultPrevented=!1}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var n={defaultPrevented:{configurable:!0}};return r.prototype.preventDefault=function(){this._defaultPrevented=!0},n.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(r.prototype,n),r}(t.Event),qr=function(t){function e(e,r,n){t.call(this,e,{originalEvent:n}),this._defaultPrevented=!1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultPrevented:{configurable:!0}};return e.prototype.preventDefault=function(){this._defaultPrevented=!0},r.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(e.prototype,r),e}(t.Event),Hr=function(e){this._map=e,this._el=e.getCanvasContainer(),this._delta=0,t.bindAll(["_onWheel","_onTimeout","_onScrollFrame","_onScrollFinished"],this)};Hr.prototype.isEnabled=function(){return!!this._enabled},Hr.prototype.isActive=function(){return!!this._active},Hr.prototype.enable=function(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)},Hr.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Hr.prototype.onWheel=function(e){if(this.isEnabled()){var r=e.deltaMode===t.default.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,n=a.now(),i=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==r&&r%4.000244140625==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=r,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*r)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),e.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=e,this._delta-=r,this.isActive()||this._start(e)),e.preventDefault()}},Hr.prototype._onTimeout=function(t){this._type="wheel",this._delta-=this._lastValue,this.isActive()||this._start(t)},Hr.prototype._start=function(e){if(this._delta){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),this._active=!0,this._map.fire(new t.Event("movestart",{originalEvent:e})),this._map.fire(new t.Event("zoomstart",{originalEvent:e})),this._finishTimeout&&clearTimeout(this._finishTimeout);var r=s.mousePos(this._el,e);this._around=G.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(r)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame))}},Hr.prototype._onScrollFrame=function(){var e=this;if(this._frameId=null,this.isActive()){var r=this._map.transform;if(0!==this._delta){var n="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?1/450:.01,i=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&0!==i&&(i=1/i);var o="number"==typeof this._targetZoom?r.zoomScale(this._targetZoom):r.scale;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(o*i))),"wheel"===this._type&&(this._startZoom=r.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}var s=!1;if("wheel"===this._type){var l=Math.min((a.now()-this._lastWheelEventTime)/200,1),c=this._easing(l);r.zoom=t.number(this._startZoom,this._targetZoom,c),l<1?this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame)):s=!0}else r.zoom=this._targetZoom,s=!0;r.setLocationAtPoint(this._around,this._aroundPoint),this._map.fire(new t.Event("move",{originalEvent:this._lastWheelEvent})),this._map.fire(new t.Event("zoom",{originalEvent:this._lastWheelEvent})),s&&(this._active=!1,this._finishTimeout=setTimeout(function(){e._map.fire(new t.Event("zoomend",{originalEvent:e._lastWheelEvent})),e._map.fire(new t.Event("moveend",{originalEvent:e._lastWheelEvent})),delete e._targetZoom},200))}},Hr.prototype._smoothOutEasing=function(e){var r=t.ease;if(this._prevEase){var n=this._prevEase,i=(a.now()-n.start)/n.duration,o=n.easing(i+.01)-n.easing(i),s=.27/Math.sqrt(o*o+1e-4)*.01,l=Math.sqrt(.0729-s*s);r=t.bezier(s,l,.25,1)}return this._prevEase={start:a.now(),duration:e,easing:r},r};var Gr=function(e){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),t.bindAll(["_onMouseMove","_onMouseUp","_onKeyDown"],this)};Gr.prototype.isEnabled=function(){return!!this._enabled},Gr.prototype.isActive=function(){return!!this._active},Gr.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Gr.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Gr.prototype.onMouseDown=function(e){this.isEnabled()&&e.shiftKey&&0===e.button&&(t.default.document.addEventListener("mousemove",this._onMouseMove,!1),t.default.document.addEventListener("keydown",this._onKeyDown,!1),t.default.document.addEventListener("mouseup",this._onMouseUp,!1),s.disableDrag(),this._startPos=s.mousePos(this._el,e),this._active=!0)},Gr.prototype._onMouseMove=function(t){var e=this._startPos,r=s.mousePos(this._el,t);this._box||(this._box=s.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));var n=Math.min(e.x,r.x),i=Math.max(e.x,r.x),a=Math.min(e.y,r.y),o=Math.max(e.y,r.y);s.setTransform(this._box,"translate("+n+"px,"+a+"px)"),this._box.style.width=i-n+"px",this._box.style.height=o-a+"px"},Gr.prototype._onMouseUp=function(e){if(0===e.button){var r=this._startPos,n=s.mousePos(this._el,e),i=(new W).extend(this._map.unproject(r)).extend(this._map.unproject(n));this._finish(),s.suppressClick(),r.x===n.x&&r.y===n.y?this._fireEvent("boxzoomcancel",e):this._map.fitBounds(i,{linear:!0}).fire(new t.Event("boxzoomend",{originalEvent:e,boxZoomBounds:i}))}},Gr.prototype._onKeyDown=function(t){27===t.keyCode&&(this._finish(),this._fireEvent("boxzoomcancel",t))},Gr.prototype._finish=function(){this._active=!1,t.default.document.removeEventListener("mousemove",this._onMouseMove,!1),t.default.document.removeEventListener("keydown",this._onKeyDown,!1),t.default.document.removeEventListener("mouseup",this._onMouseUp,!1),this._container.classList.remove("mapboxgl-crosshair"),this._box&&(s.remove(this._box),this._box=null),s.enableDrag()},Gr.prototype._fireEvent=function(e,r){return this._map.fire(new t.Event(e,{originalEvent:r}))};var Wr=t.bezier(0,0,.25,1),Yr=function(e,r){this._map=e,this._el=r.element||e.getCanvasContainer(),this._state="disabled",this._button=r.button||"right",this._bearingSnap=r.bearingSnap||0,this._pitchWithRotate=!1!==r.pitchWithRotate,t.bindAll(["_onMouseMove","_onMouseUp","_onBlur","_onDragFrame"],this)};Yr.prototype.isEnabled=function(){return"disabled"!==this._state},Yr.prototype.isActive=function(){return"active"===this._state},Yr.prototype.enable=function(){this.isEnabled()||(this._state="enabled")},Yr.prototype.disable=function(){if(this.isEnabled())switch(this._state){case"active":this._state="disabled",this._unbind(),this._deactivate(),this._fireEvent("rotateend"),this._pitchWithRotate&&this._fireEvent("pitchend"),this._fireEvent("moveend");break;case"pending":this._state="disabled",this._unbind();break;default:this._state="disabled"}},Yr.prototype.onMouseDown=function(e){if("enabled"===this._state){if("right"===this._button){if(this._eventButton=s.mouseButton(e),this._eventButton!==(e.ctrlKey?0:2))return}else{if(e.ctrlKey||0!==s.mouseButton(e))return;this._eventButton=0}s.disableDrag(),t.default.document.addEventListener("mousemove",this._onMouseMove,{capture:!0}),t.default.document.addEventListener("mouseup",this._onMouseUp),t.default.addEventListener("blur",this._onBlur),this._state="pending",this._inertia=[[a.now(),this._map.getBearing()]],this._previousPos=s.mousePos(this._el,e),this._center=this._map.transform.centerPoint,e.preventDefault()}},Yr.prototype._onMouseMove=function(t){this._lastMoveEvent=t,this._pos=s.mousePos(this._el,t),"pending"===this._state&&(this._state="active",this._fireEvent("rotatestart",t),this._fireEvent("movestart",t),this._pitchWithRotate&&this._fireEvent("pitchstart",t)),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onDragFrame))},Yr.prototype._onDragFrame=function(){this._frameId=null;var t=this._lastMoveEvent;if(t){var e=this._map.transform,r=this._previousPos,n=this._pos,i=.8*(r.x-n.x),o=-.5*(r.y-n.y),s=e.bearing-i,l=e.pitch-o,c=this._inertia,u=c[c.length-1];this._drainInertiaBuffer(),c.push([a.now(),this._map._normalizeBearing(s,u[1])]),e.bearing=s,this._pitchWithRotate&&(this._fireEvent("pitch",t),e.pitch=l),this._fireEvent("rotate",t),this._fireEvent("move",t),delete this._lastMoveEvent,this._previousPos=this._pos}},Yr.prototype._onMouseUp=function(t){if(s.mouseButton(t)===this._eventButton)switch(this._state){case"active":this._state="enabled",s.suppressClick(),this._unbind(),this._deactivate(),this._inertialRotate(t);break;case"pending":this._state="enabled",this._unbind()}},Yr.prototype._onBlur=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._fireEvent("rotateend",t),this._pitchWithRotate&&this._fireEvent("pitchend",t),this._fireEvent("moveend",t);break;case"pending":this._state="enabled",this._unbind()}},Yr.prototype._unbind=function(){t.default.document.removeEventListener("mousemove",this._onMouseMove,{capture:!0}),t.default.document.removeEventListener("mouseup",this._onMouseUp),t.default.removeEventListener("blur",this._onBlur),s.enableDrag()},Yr.prototype._deactivate=function(){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._lastMoveEvent,delete this._previousPos},Yr.prototype._inertialRotate=function(t){var e=this;this._fireEvent("rotateend",t),this._drainInertiaBuffer();var r=this._map,n=r.getBearing(),i=this._inertia,a=function(){Math.abs(n)180&&(p=180);var d=p/180;c+=f*p*(d/2),Math.abs(r._normalizeBearing(c,0))0&&e-t[0][0]>160;)t.shift()};var Xr=t.bezier(0,0,.3,1),Zr=function(e){this._map=e,this._el=e.getCanvasContainer(),this._state="disabled",t.bindAll(["_onMove","_onMouseUp","_onTouchEnd","_onBlur","_onDragFrame"],this)};Zr.prototype.isEnabled=function(){return"disabled"!==this._state},Zr.prototype.isActive=function(){return"active"===this._state},Zr.prototype.enable=function(){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-drag-pan"),this._state="enabled")},Zr.prototype.disable=function(){if(this.isEnabled())switch(this._el.classList.remove("mapboxgl-touch-drag-pan"),this._state){case"active":this._state="disabled",this._unbind(),this._deactivate(),this._fireEvent("dragend"),this._fireEvent("moveend");break;case"pending":this._state="disabled",this._unbind();break;default:this._state="disabled"}},Zr.prototype.onMouseDown=function(e){"enabled"===this._state&&(e.ctrlKey||0!==s.mouseButton(e)||(s.addEventListener(t.default.document,"mousemove",this._onMove,{capture:!0}),s.addEventListener(t.default.document,"mouseup",this._onMouseUp),this._start(e)))},Zr.prototype.onTouchStart=function(e){"enabled"===this._state&&(e.touches.length>1||(s.addEventListener(t.default.document,"touchmove",this._onMove,{capture:!0,passive:!1}),s.addEventListener(t.default.document,"touchend",this._onTouchEnd),this._start(e)))},Zr.prototype._start=function(e){t.default.addEventListener("blur",this._onBlur),this._state="pending",this._previousPos=s.mousePos(this._el,e),this._inertia=[[a.now(),this._previousPos]]},Zr.prototype._onMove=function(t){this._lastMoveEvent=t,t.preventDefault(),this._pos=s.mousePos(this._el,t),this._drainInertiaBuffer(),this._inertia.push([a.now(),this._pos]),"pending"===this._state&&(this._state="active",this._fireEvent("dragstart",t),this._fireEvent("movestart",t)),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onDragFrame))},Zr.prototype._onDragFrame=function(){this._frameId=null;var t=this._lastMoveEvent;if(t){var e=this._map.transform;e.setLocationAtPoint(e.pointLocation(this._previousPos),this._pos),this._fireEvent("drag",t),this._fireEvent("move",t),this._previousPos=this._pos,delete this._lastMoveEvent}},Zr.prototype._onMouseUp=function(t){if(0===s.mouseButton(t))switch(this._state){case"active":this._state="enabled",s.suppressClick(),this._unbind(),this._deactivate(),this._inertialPan(t);break;case"pending":this._state="enabled",this._unbind()}},Zr.prototype._onTouchEnd=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._inertialPan(t);break;case"pending":this._state="enabled",this._unbind()}},Zr.prototype._onBlur=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._fireEvent("dragend",t),this._fireEvent("moveend",t);break;case"pending":this._state="enabled",this._unbind()}},Zr.prototype._unbind=function(){s.removeEventListener(t.default.document,"touchmove",this._onMove,{capture:!0,passive:!1}),s.removeEventListener(t.default.document,"touchend",this._onTouchEnd),s.removeEventListener(t.default.document,"mousemove",this._onMove,{capture:!0}),s.removeEventListener(t.default.document,"mouseup",this._onMouseUp),s.removeEventListener(t.default,"blur",this._onBlur)},Zr.prototype._deactivate=function(){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._lastMoveEvent,delete this._previousPos,delete this._pos},Zr.prototype._inertialPan=function(t){this._fireEvent("dragend",t),this._drainInertiaBuffer();var e=this._inertia;if(e.length<2)this._fireEvent("moveend",t);else{var r=e[e.length-1],n=e[0],i=r[1].sub(n[1]),a=(r[0]-n[0])/1e3;if(0===a||r[1].equals(n[1]))this._fireEvent("moveend",t);else{var o=i.mult(.3/a),s=o.mag();s>1400&&(s=1400,o._unit()._mult(s));var l=s/750,c=o.mult(-l/2);this._map.panBy(c,{duration:1e3*l,easing:Xr,noMoveStart:!0},{originalEvent:t})}}},Zr.prototype._fireEvent=function(e,r){return this._map.fire(new t.Event(e,r?{originalEvent:r}:{}))},Zr.prototype._drainInertiaBuffer=function(){for(var t=this._inertia,e=a.now();t.length>0&&e-t[0][0]>160;)t.shift()};var $r=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onKeyDown"],this)};function Jr(t){return t*(2-t)}$r.prototype.isEnabled=function(){return!!this._enabled},$r.prototype.enable=function(){this.isEnabled()||(this._el.addEventListener("keydown",this._onKeyDown,!1),this._enabled=!0)},$r.prototype.disable=function(){this.isEnabled()&&(this._el.removeEventListener("keydown",this._onKeyDown),this._enabled=!1)},$r.prototype._onKeyDown=function(t){if(!(t.altKey||t.ctrlKey||t.metaKey)){var e=0,r=0,n=0,i=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),i=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),i=1);break;case 38:t.shiftKey?n=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?n=-1:(a=1,t.preventDefault());break;default:return}var o=this._map,s=o.getZoom(),l={duration:300,delayEndEvents:500,easing:Jr,zoom:e?Math.round(s)+e*(t.shiftKey?2:1):s,bearing:o.getBearing()+15*r,pitch:o.getPitch()+10*n,offset:[100*-i,100*-a],center:o.getCenter()};o.easeTo(l,{originalEvent:t})}};var Kr=function(e){this._map=e,t.bindAll(["_onDblClick","_onZoomEnd"],this)};Kr.prototype.isEnabled=function(){return!!this._enabled},Kr.prototype.isActive=function(){return!!this._active},Kr.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Kr.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Kr.prototype.onTouchStart=function(t){var e=this;this.isEnabled()&&(t.points.length>1||(this._tapped?(clearTimeout(this._tapped),this._tapped=null,this._zoom(t)):this._tapped=setTimeout(function(){e._tapped=null},300)))},Kr.prototype.onDblClick=function(t){this.isEnabled()&&(t.originalEvent.preventDefault(),this._zoom(t))},Kr.prototype._zoom=function(t){this._active=!0,this._map.on("zoomend",this._onZoomEnd),this._map.zoomTo(this._map.getZoom()+(t.originalEvent.shiftKey?-1:1),{around:t.lngLat},t)},Kr.prototype._onZoomEnd=function(){this._active=!1,this._map.off("zoomend",this._onZoomEnd)};var Qr=t.bezier(0,0,.15,1),tn=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onMove","_onEnd","_onTouchFrame"],this)};tn.prototype.isEnabled=function(){return!!this._enabled},tn.prototype.enable=function(t){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-zoom-rotate"),this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)},tn.prototype.disable=function(){this.isEnabled()&&(this._el.classList.remove("mapboxgl-touch-zoom-rotate"),this._enabled=!1)},tn.prototype.disableRotation=function(){this._rotationDisabled=!0},tn.prototype.enableRotation=function(){this._rotationDisabled=!1},tn.prototype.onStart=function(e){if(this.isEnabled()&&2===e.touches.length){var r=s.mousePos(this._el,e.touches[0]),n=s.mousePos(this._el,e.touches[1]);this._startVec=r.sub(n),this._gestureIntent=void 0,this._inertia=[],s.addEventListener(t.default.document,"touchmove",this._onMove,{passive:!1}),s.addEventListener(t.default.document,"touchend",this._onEnd)}},tn.prototype._getTouchEventData=function(t){var e=s.mousePos(this._el,t.touches[0]),r=s.mousePos(this._el,t.touches[1]),n=e.sub(r);return{vec:n,center:e.add(r).div(2),scale:n.mag()/this._startVec.mag(),bearing:this._rotationDisabled?0:180*n.angleWith(this._startVec)/Math.PI}},tn.prototype._onMove=function(e){if(2===e.touches.length){var r=this._getTouchEventData(e),n=r.vec,i=r.scale,a=r.bearing;if(!this._gestureIntent){var o=Math.abs(1-i)>.15;Math.abs(a)>10?this._gestureIntent="rotate":o&&(this._gestureIntent="zoom"),this._gestureIntent&&(this._map.fire(new t.Event(this._gestureIntent+"start",{originalEvent:e})),this._map.fire(new t.Event("movestart",{originalEvent:e})),this._startVec=n)}this._lastTouchEvent=e,this._frameId||(this._frameId=this._map._requestRenderFrame(this._onTouchFrame)),e.preventDefault()}},tn.prototype._onTouchFrame=function(){this._frameId=null;var e=this._gestureIntent;if(e){var r=this._map.transform;this._startScale||(this._startScale=r.scale,this._startBearing=r.bearing);var n=this._getTouchEventData(this._lastTouchEvent),i=n.center,o=n.bearing,s=n.scale,l=r.pointLocation(i),c=r.locationPoint(l);"rotate"===e&&(r.bearing=this._startBearing+o),r.zoom=r.scaleZoom(this._startScale*s),r.setLocationAtPoint(l,c),this._map.fire(new t.Event(e,{originalEvent:this._lastTouchEvent})),this._map.fire(new t.Event("move",{originalEvent:this._lastTouchEvent})),this._drainInertiaBuffer(),this._inertia.push([a.now(),s,i])}},tn.prototype._onEnd=function(e){s.removeEventListener(t.default.document,"touchmove",this._onMove,{passive:!1}),s.removeEventListener(t.default.document,"touchend",this._onEnd);var r=this._gestureIntent,n=this._startScale;if(this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._gestureIntent,delete this._startScale,delete this._startBearing,delete this._lastTouchEvent,r){this._map.fire(new t.Event(r+"end",{originalEvent:e})),this._drainInertiaBuffer();var i=this._inertia,a=this._map;if(i.length<2)a.snapToNorth({},{originalEvent:e});else{var o=i[i.length-1],l=i[0],c=a.transform.scaleZoom(n*o[1]),u=a.transform.scaleZoom(n*l[1]),f=c-u,h=(o[0]-l[0])/1e3,p=o[2];if(0!==h&&c!==u){var d=.15*f/h;Math.abs(d)>2.5&&(d=d>0?2.5:-2.5);var g=1e3*Math.abs(d/(12*.15)),v=c+d*g/2e3;v<0&&(v=0),a.easeTo({zoom:v,duration:g,easing:Qr,around:this._aroundCenter?a.getCenter():a.unproject(p),noMoveStart:!0},{originalEvent:e})}else a.snapToNorth({},{originalEvent:e})}}},tn.prototype._drainInertiaBuffer=function(){for(var t=this._inertia,e=a.now();t.length>2&&e-t[0][0]>160;)t.shift()};var en={scrollZoom:Hr,boxZoom:Gr,dragRotate:Yr,dragPan:Zr,keyboard:$r,doubleClickZoom:Kr,touchZoomRotate:tn},rn=function(e){function r(r,n){e.call(this),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=n.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.getCenter=function(){return this.transform.center},r.prototype.setCenter=function(t,e){return this.jumpTo({center:t},e)},r.prototype.panBy=function(e,r,n){return e=t.default$1.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},r),n)},r.prototype.panTo=function(e,r,n){return this.easeTo(t.extend({center:e},r),n)},r.prototype.getZoom=function(){return this.transform.zoom},r.prototype.setZoom=function(t,e){return this.jumpTo({zoom:t},e),this},r.prototype.zoomTo=function(e,r,n){return this.easeTo(t.extend({zoom:e},r),n)},r.prototype.zoomIn=function(t,e){return this.zoomTo(this.getZoom()+1,t,e),this},r.prototype.zoomOut=function(t,e){return this.zoomTo(this.getZoom()-1,t,e),this},r.prototype.getBearing=function(){return this.transform.bearing},r.prototype.setBearing=function(t,e){return this.jumpTo({bearing:t},e),this},r.prototype.rotateTo=function(e,r,n){return this.easeTo(t.extend({bearing:e},r),n)},r.prototype.resetNorth=function(e,r){return this.rotateTo(0,t.extend({duration:1e3},e),r),this},r.prototype.snapToNorth=function(t,e){return Math.abs(this.getBearing())e?1:0}),["bottom","left","right","top"]))return t.warnOnce("options.padding must be a positive number, or an Object with keys 'bottom', 'left', 'right', 'top'"),this;e=W.convert(e);var a=[(r.padding.left-r.padding.right)/2,(r.padding.top-r.padding.bottom)/2],o=Math.min(r.padding.right,r.padding.left),s=Math.min(r.padding.top,r.padding.bottom);r.offset=[r.offset[0]+a[0],r.offset[1]+a[1]];var l=t.default$1.convert(r.offset),c=this.transform,u=c.project(e.getNorthWest()),f=c.project(e.getSouthEast()),h=f.sub(u),p=(c.width-2*o-2*Math.abs(l.x))/h.x,d=(c.height-2*s-2*Math.abs(l.y))/h.y;return d<0||p<0?(t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset."),this):(r.center=c.unproject(u.add(f).div(2)),r.zoom=Math.min(c.scaleZoom(c.scale*Math.min(p,d)),r.maxZoom),r.bearing=0,r.linear?this.easeTo(r,n):this.flyTo(r,n))},r.prototype.jumpTo=function(e,r){this.stop();var n=this.transform,i=!1,a=!1,o=!1;return"zoom"in e&&n.zoom!==+e.zoom&&(i=!0,n.zoom=+e.zoom),void 0!==e.center&&(n.center=G.convert(e.center)),"bearing"in e&&n.bearing!==+e.bearing&&(a=!0,n.bearing=+e.bearing),"pitch"in e&&n.pitch!==+e.pitch&&(o=!0,n.pitch=+e.pitch),this.fire(new t.Event("movestart",r)).fire(new t.Event("move",r)),i&&this.fire(new t.Event("zoomstart",r)).fire(new t.Event("zoom",r)).fire(new t.Event("zoomend",r)),a&&this.fire(new t.Event("rotatestart",r)).fire(new t.Event("rotate",r)).fire(new t.Event("rotateend",r)),o&&this.fire(new t.Event("pitchstart",r)).fire(new t.Event("pitch",r)).fire(new t.Event("pitchend",r)),this.fire(new t.Event("moveend",r))},r.prototype.easeTo=function(e,r){var n=this;this.stop(),!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate&&(e.duration=0);var i=this.transform,a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l="zoom"in e?+e.zoom:a,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,f=i.centerPoint.add(t.default$1.convert(e.offset)),h=i.pointLocation(f),p=G.convert(e.center||h);this._normalizeCenter(p);var d,g,v=i.project(h),m=i.project(p).sub(v),y=i.zoomScale(l-a);return e.around&&(d=G.convert(e.around),g=i.locationPoint(d)),this._zooming=l!==a,this._rotating=o!==c,this._pitching=u!==s,this._prepareEase(r,e.noMoveStart),clearTimeout(this._easeEndTimeoutID),this._ease(function(e){if(n._zooming&&(i.zoom=t.number(a,l,e)),n._rotating&&(i.bearing=t.number(o,c,e)),n._pitching&&(i.pitch=t.number(s,u,e)),d)i.setLocationAtPoint(d,g);else{var h=i.zoomScale(i.zoom-a),p=l>a?Math.min(2,y):Math.max(.5,y),x=Math.pow(p,1-e),b=i.unproject(v.add(m.mult(e*x)).mult(h));i.setLocationAtPoint(i.renderWorldCopies?b.wrap():b,f)}n._fireMoveEvents(r)},function(){e.delayEndEvents?n._easeEndTimeoutID=setTimeout(function(){return n._afterEase(r)},e.delayEndEvents):n._afterEase(r)},e),this},r.prototype._prepareEase=function(e,r){this._moving=!0,r||this.fire(new t.Event("movestart",e)),this._zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&this.fire(new t.Event("pitchstart",e))},r.prototype._fireMoveEvents=function(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))},r.prototype._afterEase=function(e){var r=this._zooming,n=this._rotating,i=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,r&&this.fire(new t.Event("zoomend",e)),n&&this.fire(new t.Event("rotateend",e)),i&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))},r.prototype.flyTo=function(e,r){var n=this;this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);var i=this.transform,a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l="zoom"in e?t.clamp(+e.zoom,i.minZoom,i.maxZoom):a,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,f=i.zoomScale(l-a),h=i.centerPoint.add(t.default$1.convert(e.offset)),p=i.pointLocation(h),d=G.convert(e.center||p);this._normalizeCenter(d);var g=i.project(p),v=i.project(d).sub(g),m=e.curve,y=Math.max(i.width,i.height),x=y/f,b=v.mag();if("minZoom"in e){var _=t.clamp(Math.min(e.minZoom,a,l),i.minZoom,i.maxZoom),w=y/i.zoomScale(_-a);m=Math.sqrt(w/b*2)}var k=m*m;function M(t){var e=(x*x-y*y+(t?-1:1)*k*k*b*b)/(2*(t?x:y)*k*b);return Math.log(Math.sqrt(e*e+1)-e)}function A(t){return(Math.exp(t)-Math.exp(-t))/2}function T(t){return(Math.exp(t)+Math.exp(-t))/2}var S=M(0),E=function(t){return T(S)/T(S+m*t)},C=function(t){return y*((T(S)*(A(e=S+m*t)/T(e))-A(S))/k)/b;var e},L=(M(1)-S)/m;if(Math.abs(b)<1e-6||!isFinite(L)){if(Math.abs(y-x)<1e-6)return this.easeTo(e,r);var z=xe.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=u!==s,this._prepareEase(r,!1),this._ease(function(e){var l=e*L,f=1/E(l);i.zoom=a+i.scaleZoom(f),n._rotating&&(i.bearing=t.number(o,c,e)),n._pitching&&(i.pitch=t.number(s,u,e));var p=i.unproject(g.add(v.mult(C(l))).mult(f));i.setLocationAtPoint(i.renderWorldCopies?p.wrap():p,h),n._fireMoveEvents(r)},function(){return n._afterEase(r)},e),this},r.prototype.isEasing=function(){return!!this._easeFrameId},r.prototype.stop=function(){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){var t=this._onEaseEnd;delete this._onEaseEnd,t.call(this)}return this},r.prototype._ease=function(t,e,r){!1===r.animate||0===r.duration?(t(1),e()):(this._easeStart=a.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))},r.prototype._renderFrameCallback=function(){var t=Math.min((a.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},r.prototype._normalizeBearing=function(e,r){e=t.wrap(e,-180,180);var n=Math.abs(e-r);return Math.abs(e-360-r)180?-360:r<-180?360:0}},r}(t.Evented),nn=function(e){void 0===e&&(e={}),this.options=e,t.bindAll(["_updateEditLink","_updateData","_updateCompact"],this)};nn.prototype.getDefaultPosition=function(){return"bottom-right"},nn.prototype.onAdd=function(t){var e=this.options&&this.options.compact;return this._map=t,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),e&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container},nn.prototype.onRemove=function(){s.remove(this._container),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0},nn.prototype._updateEditLink=function(){var t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));var e=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:v.ACCESS_TOKEN}];if(t){var r=e.reduce(function(t,r,n){return r.value&&(t+=r.key+"="+r.value+(n=0)return!1;return!0})).length?(this._container.innerHTML=t.join(" | "),this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null}},nn.prototype._updateCompact=function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact")};var an=function(){t.bindAll(["_updateLogo"],this)};an.prototype.onAdd=function(t){this._map=t,this._container=s.create("div","mapboxgl-ctrl");var e=s.create("a","mapboxgl-ctrl-logo");return e.target="_blank",e.href="https://www.mapbox.com/",e.setAttribute("aria-label","Mapbox logo"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._container},an.prototype.onRemove=function(){s.remove(this._container),this._map.off("sourcedata",this._updateLogo)},an.prototype.getDefaultPosition=function(){return"bottom-left"},an.prototype._updateLogo=function(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")},an.prototype._logoRequired=function(){if(this._map.style){var t=this._map.style.sourceCaches;for(var e in t)if(t[e].getSource().mapbox_logo)return!0;return!1}};var on=function(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1};on.prototype.add=function(t){var e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e},on.prototype.remove=function(t){for(var e=this._currentlyRunning,r=0,n=e?this._queue.concat(e):this._queue;re.maxZoom)throw new Error("maxZoom must be greater than minZoom");var n=new Fr(e.minZoom,e.maxZoom,e.renderWorldCopies);r.call(this,n,e),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new on;var i=e.transformRequest;if(this._transformRequest=i?function(t,e){return i(t,e)||{url:t}}:function(t){return{url:t}},"string"==typeof e.container){var a=t.default.document.getElementById(e.container);if(!a)throw new Error("Container '"+e.container+"' not found.");this._container=a}else{if(!(e.container instanceof ln))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_contextLost","_contextRestored","_update","_render","_onData","_onDataLoading"],this),this._setupContainer(),this._setupPainter(),this.on("move",this._update.bind(this,!1)),this.on("zoom",this._update.bind(this,!0)),void 0!==t.default&&(t.default.addEventListener("online",this._onWindowOnline,!1),t.default.addEventListener("resize",this._onWindowResize,!1)),function(t,e){var r=t.getCanvasContainer(),n=null,i=!1;for(var a in en)t[a]=new en[a](t,e),e.interactive&&e[a]&&t[a].enable(e[a]);s.addEventListener(r,"mouseout",function(e){t.fire(new Vr("mouseout",t,e))}),s.addEventListener(r,"mousedown",function(r){i=!0;var n=new Vr("mousedown",t,r);t.fire(n),n.defaultPrevented||(e.interactive&&!t.doubleClickZoom.isActive()&&t.stop(),t.boxZoom.onMouseDown(r),t.boxZoom.isActive()||t.dragPan.isActive()||t.dragRotate.onMouseDown(r),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onMouseDown(r))}),s.addEventListener(r,"mouseup",function(e){var r=t.dragRotate.isActive();n&&!r&&t.fire(new Vr("contextmenu",t,n)),n=null,i=!1,t.fire(new Vr("mouseup",t,e))}),s.addEventListener(r,"mousemove",function(e){if(!t.dragPan.isActive()&&!t.dragRotate.isActive()){for(var n=e.toElement||e.target;n&&n!==r;)n=n.parentNode;n===r&&t.fire(new Vr("mousemove",t,e))}}),s.addEventListener(r,"mouseover",function(e){for(var n=e.toElement||e.target;n&&n!==r;)n=n.parentNode;n===r&&t.fire(new Vr("mouseover",t,e))}),s.addEventListener(r,"touchstart",function(r){var n=new Ur("touchstart",t,r);t.fire(n),n.defaultPrevented||(e.interactive&&t.stop(),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onTouchStart(r),t.touchZoomRotate.onStart(r),t.doubleClickZoom.onTouchStart(n))},{passive:!1}),s.addEventListener(r,"touchmove",function(e){t.fire(new Ur("touchmove",t,e))},{passive:!1}),s.addEventListener(r,"touchend",function(e){t.fire(new Ur("touchend",t,e))}),s.addEventListener(r,"touchcancel",function(e){t.fire(new Ur("touchcancel",t,e))}),s.addEventListener(r,"click",function(e){t.fire(new Vr("click",t,e))}),s.addEventListener(r,"dblclick",function(e){var r=new Vr("dblclick",t,e);t.fire(r),r.defaultPrevented||t.doubleClickZoom.onDblClick(r)}),s.addEventListener(r,"contextmenu",function(e){var r=t.dragRotate.isActive();i||r?i&&(n=e):t.fire(new Vr("contextmenu",t,e)),e.preventDefault()}),s.addEventListener(r,"wheel",function(e){var r=new qr("wheel",t,e);t.fire(r),r.defaultPrevented||t.scrollZoom.onWheel(e)},{passive:!1})}(this,e),this._hash=e.hash&&(new jr).addTo(this),this._hash&&this._hash._onHashChange()||this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),this.resize(),e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new nn),this.addControl(new an,e.logoPosition),this.on("style.load",function(){this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",this._onData),this.on("dataloading",this._onDataLoading)}r&&(n.__proto__=r),n.prototype=Object.create(r&&r.prototype),n.prototype.constructor=n;var i={showTileBoundaries:{configurable:!0},showCollisionBoxes:{configurable:!0},showOverdrawInspector:{configurable:!0},repaint:{configurable:!0},vertices:{configurable:!0}};return n.prototype.addControl=function(t,e){void 0===e&&t.getDefaultPosition&&(e=t.getDefaultPosition()),void 0===e&&(e="top-right");var r=t.onAdd(this),n=this._controlPositions[e];return-1!==e.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this},n.prototype.removeControl=function(t){return t.onRemove(this),this},n.prototype.resize=function(e){var r=this._containerDimensions(),n=r[0],i=r[1];return this._resizeCanvas(n,i),this.transform.resize(n,i),this.painter.resize(n,i),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)).fire(new t.Event("resize",e)).fire(new t.Event("moveend",e))},n.prototype.getBounds=function(){var e=new W(this.transform.pointLocation(new t.default$1(0,this.transform.height)),this.transform.pointLocation(new t.default$1(this.transform.width,0)));return(this.transform.angle||this.transform.pitch)&&(e.extend(this.transform.pointLocation(new t.default$1(this.transform.size.x,0))),e.extend(this.transform.pointLocation(new t.default$1(0,this.transform.size.y)))),e},n.prototype.getMaxBounds=function(){return this.transform.latRange&&2===this.transform.latRange.length&&this.transform.lngRange&&2===this.transform.lngRange.length?new W([this.transform.lngRange[0],this.transform.latRange[0]],[this.transform.lngRange[1],this.transform.latRange[1]]):null},n.prototype.setMaxBounds=function(t){if(t){var e=W.convert(t);this.transform.lngRange=[e.getWest(),e.getEast()],this.transform.latRange=[e.getSouth(),e.getNorth()],this.transform._constrain(),this._update()}else null==t&&(this.transform.lngRange=null,this.transform.latRange=null,this._update());return this},n.prototype.setMinZoom=function(t){if((t=null==t?0:t)>=0&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")},n.prototype.getRenderWorldCopies=function(){return this.transform.renderWorldCopies},n.prototype.setRenderWorldCopies=function(t){return this.transform.renderWorldCopies=t,this._update(),this},n.prototype.getMaxZoom=function(){return this.transform.maxZoom},n.prototype.project=function(t){return this.transform.locationPoint(G.convert(t))},n.prototype.unproject=function(e){return this.transform.pointLocation(t.default$1.convert(e))},n.prototype.isMoving=function(){return this._moving||this.dragPan.isActive()||this.dragRotate.isActive()||this.scrollZoom.isActive()},n.prototype.isZooming=function(){return this._zooming||this.scrollZoom.isActive()},n.prototype.isRotating=function(){return this._rotating||this.dragRotate.isActive()},n.prototype.on=function(t,e,n){var i,a=this;if(void 0===n)return r.prototype.on.call(this,t,e);var o=function(){if("mouseenter"===t||"mouseover"===t){var r=!1;return{layer:e,listener:n,delegates:{mousemove:function(i){var o=a.getLayer(e)?a.queryRenderedFeatures(i.point,{layers:[e]}):[];o.length?r||(r=!0,n.call(a,new Vr(t,a,i.originalEvent,{features:o}))):r=!1},mouseout:function(){r=!1}}}}if("mouseleave"===t||"mouseout"===t){var o=!1;return{layer:e,listener:n,delegates:{mousemove:function(r){(a.getLayer(e)?a.queryRenderedFeatures(r.point,{layers:[e]}):[]).length?o=!0:o&&(o=!1,n.call(a,new Vr(t,a,r.originalEvent)))},mouseout:function(e){o&&(o=!1,n.call(a,new Vr(t,a,e.originalEvent)))}}}}return{layer:e,listener:n,delegates:(i={},i[t]=function(t){var r=a.getLayer(e)?a.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,n.call(a,t),delete t.features)},i)}}();for(var s in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(o),o.delegates)a.on(s,o.delegates[s]);return this},n.prototype.off=function(t,e,n){if(void 0===n)return r.prototype.off.call(this,t,e);if(this._delegatedListeners&&this._delegatedListeners[t])for(var i=this._delegatedListeners[t],a=0;a180;){var o=r.locationPoint(t);if(o.x>=0&&o.y>=0&&o.x<=r.width&&o.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}pn.prototype._rotateCompassArrow=function(){var t="rotate("+this._map.transform.angle*(180/Math.PI)+"deg)";this._compassArrow.style.transform=t},pn.prototype.onAdd=function(t){return this._map=t,this.options.showCompass&&(this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Yr(t,{button:"left",element:this._compass}),this._handler.enable()),this._container},pn.prototype.onRemove=function(){s.remove(this._container),this.options.showCompass&&(this._map.off("rotate",this._rotateCompassArrow),this._handler.disable(),delete this._handler),delete this._map},pn.prototype._createButton=function(t,e,r){var n=s.create("button",t,this._container);return n.type="button",n.setAttribute("aria-label",e),n.addEventListener("click",r),n};var gn={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function vn(t,e,r){var n=t.classList;for(var i in gn)n.remove("mapboxgl-"+r+"-anchor-"+i);n.add("mapboxgl-"+r+"-anchor-"+e)}var mn=function(e){if((arguments[0]instanceof t.default.HTMLElement||2===arguments.length)&&(e=t.extend({element:e},arguments[1])),t.bindAll(["_update","_onMapClick"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",e&&e.element)this._element=e.element,this._offset=t.default$1.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=s.create("div");var r=s.createNS("http://www.w3.org/2000/svg","svg");r.setAttributeNS(null,"height","41px"),r.setAttributeNS(null,"width","27px"),r.setAttributeNS(null,"viewBox","0 0 27 41");var n=s.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"stroke","none"),n.setAttributeNS(null,"stroke-width","1"),n.setAttributeNS(null,"fill","none"),n.setAttributeNS(null,"fill-rule","evenodd");var i=s.createNS("http://www.w3.org/2000/svg","g");i.setAttributeNS(null,"fill-rule","nonzero");var a=s.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");for(var o=0,l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];o5280?Mn(e,c,h/5280,"mi"):Mn(e,c,h,"ft")}else r&&"nautical"===r.unit?Mn(e,c,f/1852,"nm"):Mn(e,c,f,"m")}function Mn(t,e,r,n){var i,a,o,s=(i=r,(a=Math.pow(10,(""+Math.floor(i)).length-1))*(o=(o=i/a)>=10?10:o>=5?5:o>=3?3:o>=2?2:1)),l=s/r;"m"===n&&s>=1e3&&(s/=1e3,n="km"),t.style.width=e*l+"px",t.innerHTML=s+n}wn.prototype.getDefaultPosition=function(){return"bottom-left"},wn.prototype._onMove=function(){kn(this._map,this._container,this.options)},wn.prototype.onAdd=function(t){return this._map=t,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container},wn.prototype.onRemove=function(){s.remove(this._container),this._map.off("move",this._onMove),this._map=void 0},wn.prototype.setUnit=function(t){this.options.unit=t,kn(this._map,this._container,this.options)};var An=function(){this._fullscreen=!1,t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.default.document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in t.default.document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in t.default.document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in t.default.document&&(this._fullscreenchange="MSFullscreenChange"),this._className="mapboxgl-ctrl"};An.prototype.onAdd=function(e){return this._map=e,this._mapContainer=this._map.getContainer(),this._container=s.create("div",this._className+" mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._container.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._container},An.prototype.onRemove=function(){s.remove(this._container),this._map=null,t.default.document.removeEventListener(this._fullscreenchange,this._changeIcon)},An.prototype._checkFullscreenSupport=function(){return!!(t.default.document.fullscreenEnabled||t.default.document.mozFullScreenEnabled||t.default.document.msFullscreenEnabled||t.default.document.webkitFullscreenEnabled)},An.prototype._setupUI=function(){var e=this._fullscreenButton=s.create("button",this._className+"-icon "+this._className+"-fullscreen",this._container);e.setAttribute("aria-label","Toggle fullscreen"),e.type="button",this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.default.document.addEventListener(this._fullscreenchange,this._changeIcon)},An.prototype._isFullscreen=function(){return this._fullscreen},An.prototype._changeIcon=function(){(t.default.document.fullscreenElement||t.default.document.mozFullScreenElement||t.default.document.webkitFullscreenElement||t.default.document.msFullscreenElement)===this._mapContainer!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(this._className+"-shrink"),this._fullscreenButton.classList.toggle(this._className+"-fullscreen"))},An.prototype._onClickFullscreen=function(){this._isFullscreen()?t.default.document.exitFullscreen?t.default.document.exitFullscreen():t.default.document.mozCancelFullScreen?t.default.document.mozCancelFullScreen():t.default.document.msExitFullscreen?t.default.document.msExitFullscreen():t.default.document.webkitCancelFullScreen&&t.default.document.webkitCancelFullScreen():this._mapContainer.requestFullscreen?this._mapContainer.requestFullscreen():this._mapContainer.mozRequestFullScreen?this._mapContainer.mozRequestFullScreen():this._mapContainer.msRequestFullscreen?this._mapContainer.msRequestFullscreen():this._mapContainer.webkitRequestFullscreen&&this._mapContainer.webkitRequestFullscreen()};var Tn={closeButton:!0,closeOnClick:!0},Sn=function(e){function r(r){e.call(this),this.options=t.extend(Object.create(Tn),r),t.bindAll(["_update","_onClickClose"],this)}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.addTo=function(e){return this._map=e,this._map.on("move",this._update),this.options.closeOnClick&&this._map.on("click",this._onClickClose),this._update(),this.fire(new t.Event("open")),this},r.prototype.isOpen=function(){return!!this._map},r.prototype.remove=function(){return this._content&&s.remove(this._content),this._container&&(s.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("click",this._onClickClose),delete this._map),this.fire(new t.Event("close")),this},r.prototype.getLngLat=function(){return this._lngLat},r.prototype.setLngLat=function(t){return this._lngLat=G.convert(t),this._pos=null,this._update(),this},r.prototype.setText=function(e){return this.setDOMContent(t.default.document.createTextNode(e))},r.prototype.setHTML=function(e){var r,n=t.default.document.createDocumentFragment(),i=t.default.document.createElement("body");for(i.innerHTML=e;r=i.firstChild;)n.appendChild(r);return this.setDOMContent(n)},r.prototype.setDOMContent=function(t){return this._createContent(),this._content.appendChild(t),this._update(),this},r.prototype._createContent=function(){this._content&&s.remove(this._content),this._content=s.create("div","mapboxgl-popup-content",this._container),this.options.closeButton&&(this._closeButton=s.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClickClose))},r.prototype._update=function(){if(this._map&&this._lngLat&&this._content){this._container||(this._container=s.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=s.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this._map.transform.renderWorldCopies&&(this._lngLat=dn(this._lngLat,this._pos,this._map.transform));var e=this._pos=this._map.project(this._lngLat),r=this.options.anchor,n=function e(r){if(r){if("number"==typeof r){var n=Math.round(Math.sqrt(.5*Math.pow(r,2)));return{center:new t.default$1(0,0),top:new t.default$1(0,r),"top-left":new t.default$1(n,n),"top-right":new t.default$1(-n,n),bottom:new t.default$1(0,-r),"bottom-left":new t.default$1(n,-n),"bottom-right":new t.default$1(-n,-n),left:new t.default$1(r,0),right:new t.default$1(-r,0)}}if(r instanceof t.default$1||Array.isArray(r)){var i=t.default$1.convert(r);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.default$1.convert(r.center||[0,0]),top:t.default$1.convert(r.top||[0,0]),"top-left":t.default$1.convert(r["top-left"]||[0,0]),"top-right":t.default$1.convert(r["top-right"]||[0,0]),bottom:t.default$1.convert(r.bottom||[0,0]),"bottom-left":t.default$1.convert(r["bottom-left"]||[0,0]),"bottom-right":t.default$1.convert(r["bottom-right"]||[0,0]),left:t.default$1.convert(r.left||[0,0]),right:t.default$1.convert(r.right||[0,0])}}return e(new t.default$1(0,0))}(this.options.offset);if(!r){var i,a=this._container.offsetWidth,o=this._container.offsetHeight;i=e.y+n.bottom.ythis._map.transform.height-o?["bottom"]:[],e.x
this._map.transform.width-a/2&&i.push("right"),r=0===i.length?"bottom":i.join("-")}var l=e.add(n[r]).round();s.setTransform(this._container,gn[r]+" translate("+l.x+"px,"+l.y+"px)"),vn(this._container,r,"popup")}},r.prototype._onClickClose=function(){this.remove()},r}(t.Evented),En={version:"0.45.0",supported:e,workerCount:Math.max(Math.floor(a.hardwareConcurrency/2),1),setRTLTextPlugin:t.setRTLTextPlugin,Map:un,NavigationControl:pn,GeolocateControl:bn,AttributionControl:nn,ScaleControl:wn,FullscreenControl:An,Popup:Sn,Marker:mn,Style:Je,LngLat:G,LngLatBounds:W,Point:t.default$1,Evented:t.Evented,config:v,get accessToken(){return v.ACCESS_TOKEN},set accessToken(t){v.ACCESS_TOKEN=t},workerUrl:""};return En}),n})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],410:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1<p[1][2]&&(m[0]=-m[0]),p[0][2]>p[2][0]&&(m[1]=-m[1]),p[1][0]>p[0][1]&&(m[2]=-m[2]),!0}},{"./normalize":412,"gl-mat4/clone":248,"gl-mat4/create":249,"gl-mat4/determinant":250,"gl-mat4/invert":254,"gl-mat4/transpose":264,"gl-vec3/cross":317,"gl-vec3/dot":322,"gl-vec3/length":332,"gl-vec3/normalize":339}],412:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;i<16;i++)t[i]=e[i]*n;return!0}},{}],413:[function(t,e,r){var n=t("gl-vec3/lerp"),i=t("mat4-recompose"),a=t("mat4-decompose"),o=t("gl-mat4/determinant"),s=t("quat-slerp"),l=f(),c=f(),u=f();function f(){return{translate:h(),scale:h(1),skew:h(),perspective:[0,0,0,1],quaternion:[0,0,0,1]}}function h(t){return[t||0,t||0,t||0]}e.exports=function(t,e,r,f){if(0===o(e)||0===o(r))return!1;var h=a(e,l.translate,l.scale,l.skew,l.perspective,l.quaternion),p=a(r,c.translate,c.scale,c.skew,c.perspective,c.quaternion);return!(!h||!p||(n(u.translate,l.translate,c.translate,f),n(u.skew,l.skew,c.skew,f),n(u.scale,l.scale,c.scale,f),n(u.perspective,l.perspective,c.perspective,f),s(u.quaternion,l.quaternion,c.quaternion,f),i(t,u.translate,u.scale,u.skew,u.perspective,u.quaternion),0))}},{"gl-mat4/determinant":250,"gl-vec3/lerp":333,"mat4-decompose":411,"mat4-recompose":414,"quat-slerp":466}],414:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":249,"gl-mat4/fromRotationTranslation":252,"gl-mat4/identity":253,"gl-mat4/multiply":256,"gl-mat4/scale":262,"gl-mat4/translate":263}],415:[function(t,e,r){"use strict";e.exports=Math.log2||function(t){return Math.log(t)*Math.LOG2E}},{}],416:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=t("mat4-interpolate"),a=t("gl-mat4/invert"),o=t("gl-mat4/rotateX"),s=t("gl-mat4/rotateY"),l=t("gl-mat4/rotateZ"),c=t("gl-mat4/lookAt"),u=t("gl-mat4/translate"),f=(t("gl-mat4/scale"),t("gl-vec3/normalize")),h=[0,0,0];function p(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-1/0,1/0]}e.exports=function(t){return new p((t=t||{}).matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])};var d=p.prototype;d.recalcMatrix=function(t){var e=this._time,r=n.le(e,t),o=this.computedMatrix;if(!(r<0)){var s=this._components;if(r===e.length-1)for(var l=16*r,c=0;c<16;++c)o[c]=s[l++];else{var u=e[r+1]-e[r],h=(l=16*r,this.prevMatrix),p=!0;for(c=0;c<16;++c)h[c]=s[l++];var d=this.nextMatrix;for(c=0;c<16;++c)d[c]=s[l++],p=p&&h[c]===d[c];if(u<1e-6||p)for(c=0;c<16;++c)o[c]=h[c];else i(o,h,d,(t-e[r])/u)}var g=this.computedUp;g[0]=o[1],g[1]=o[5],g[2]=o[9],f(g,g);var v=this.computedInverse;a(v,o);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;var x=this.computedCenter,b=Math.exp(this.computedRadius[0]);for(c=0;c<3;++c)x[c]=m[c]-o[2+4*c]*b}},d.idle=function(t){if(!(t1&&n(t[o[u-2]],t[o[u-1]],c)<=0;)u-=1,o.pop();for(o.push(l),u=s.length;u>1&&n(t[s[u-2]],t[s[u-1]],c)>=0;)u-=1,s.pop();s.push(l)}for(var r=new Array(s.length+o.length-2),f=0,i=0,h=o.length;i0;--p)r[f++]=s[p];return r};var n=t("robust-orientation")[3]},{"robust-orientation":486}],418:[function(t,e,r){"use strict";e.exports=function(t,e){e||(e=t,t=window);var r=0,i=0,a=0,o={shift:!1,alt:!1,control:!1,meta:!1},s=!1;function l(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==o.alt,o.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==o.shift,o.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==o.control,o.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==o.meta,o.meta=!!t.metaKey),e}function c(t,s){var c=n.x(s),u=n.y(s);"buttons"in s&&(t=0|s.buttons),(t!==r||c!==i||u!==a||l(s))&&(r=0|t,i=c||0,a=u||0,e&&e(r,i,a,o))}function u(t){c(0,t)}function f(){(r||i||a||o.shift||o.alt||o.meta||o.control)&&(i=a=0,r=0,o.shift=o.alt=o.control=o.meta=!1,e&&e(0,0,0,o))}function h(t){l(t)&&e&&e(r,i,a,o)}function p(t){0===n.buttons(t)?c(0,t):c(r,t)}function d(t){c(r|n.buttons(t),t)}function g(t){c(r&~n.buttons(t),t)}function v(){s||(s=!0,t.addEventListener("mousemove",p),t.addEventListener("mousedown",d),t.addEventListener("mouseup",g),t.addEventListener("mouseleave",u),t.addEventListener("mouseenter",u),t.addEventListener("mouseout",u),t.addEventListener("mouseover",u),t.addEventListener("blur",f),t.addEventListener("keyup",h),t.addEventListener("keydown",h),t.addEventListener("keypress",h),t!==window&&(window.addEventListener("blur",f),window.addEventListener("keyup",h),window.addEventListener("keydown",h),window.addEventListener("keypress",h)))}v();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return s},set:function(e){e?v():s&&(s=!1,t.removeEventListener("mousemove",p),t.removeEventListener("mousedown",d),t.removeEventListener("mouseup",g),t.removeEventListener("mouseleave",u),t.removeEventListener("mouseenter",u),t.removeEventListener("mouseout",u),t.removeEventListener("mouseover",u),t.removeEventListener("blur",f),t.removeEventListener("keyup",h),t.removeEventListener("keydown",h),t.removeEventListener("keypress",h),t!==window&&(window.removeEventListener("blur",f),window.removeEventListener("keyup",h),window.removeEventListener("keydown",h),window.removeEventListener("keypress",h)))},enumerable:!0},buttons:{get:function(){return r},enumerable:!0},x:{get:function(){return i},enumerable:!0},y:{get:function(){return a},enumerable:!0},mods:{get:function(){return o},enumerable:!0}}),m};var n=t("mouse-event")},{"mouse-event":420}],419:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var i=t.clientX||0,a=t.clientY||0,o=(s=e,s===window||s===document||s===document.body?n:s.getBoundingClientRect());var s;return r[0]=i-o.left,r[1]=a-o.top,r}},{}],420:[function(t,e,r){"use strict";function n(t){return t.target||t.srcElement||window}r.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){if(2===(e=t.which))return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1< 0");"function"!=typeof t.vertex&&e("Must specify vertex creation function");"function"!=typeof t.cell&&e("Must specify cell creation function");"function"!=typeof t.phase&&e("Must specify phase function");for(var E=t.getters||[],C=new Array(T),L=0;L=0?C[L]=!0:C[L]=!1;return function(t,e,r,T,S,E){var C=E.length,L=S.length;if(L<2)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var z="extractContour"+S.join("_"),O=[],I=[],P=[],D=0;D0&&N.push(l(D,S[R-1])+"*"+s(S[R-1])),I.push(d(D,S[R])+"=("+N.join("-")+")|0")}for(var D=0;D=0;--D)j.push(s(S[D]));I.push(w+"=("+j.join("*")+")|0",b+"=mallocUint32("+w+")",x+"=mallocUint32("+w+")",k+"=0"),I.push(g(0)+"=0");for(var R=1;R<1<0;M=M-1&d)w.push(x+"["+k+"+"+m(M)+"]");w.push(y(0));for(var M=0;M=0;--e)G(e,0);for(var r=[],e=0;e0){",p(S[e]),"=1;");t(e-1,r|1<=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),a.push("1"),o.push("s["+l+"]-2"));var c=".lo("+a.join()+").hi("+o.join()+")";if(0===a.length&&(c=""),i>0){n.push("if(1");for(var l=0;l=0||e.indexOf(-(l+1))>=0||n.push("&&s[",l,"]>2");n.push("){grad",i,"(src.pick(",s.join(),")",c);for(var l=0;l=0||e.indexOf(-(l+1))>=0||n.push(",dst.pick(",s.join(),",",l,")",c);n.push(");")}for(var l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",h.join(),")-src.get(",p.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):n.push("if(s[",u,"]>1){diff(",f,",src.pick(",h.join(),")",c,",src.pick(",p.join(),")",c,");}else{zero(",f,");};");break;case"mirror":0===i?n.push("dst.set(",s.join(),",",u,",0);"):n.push("zero(",f,");");break;case"wrap":var d=s.slice(),g=s.slice();e[l]<0?(d[u]="s["+u+"]-2",g[u]="0"):(d[u]="s["+u+"]-1",g[u]="1"),0===i?n.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",d.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):n.push("if(s[",u,"]>2){diff(",f,",src.pick(",d.join(),")",c,",src.pick(",g.join(),")",c,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}i>0&&n.push("};")}for(var s=0;s<1<>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in l){var e=l[t];r[t]=o({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var c={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in c){var e=c[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var u=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=n({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=n({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=n({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=n({args:["array","array"],pre:i,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":134}],428:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var r=[],a=t,o=1;Array.isArray(a);)r.push(a.length),o*=a.length,a=a[0];return 0===r.length?n():(e||(e=n(new Float64Array(o),r)),i(e,t),e)}},{"./doConvert.js":429,ndarray:433}],429:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":134}],430:[function(t,e,r){"use strict";var n=t("typedarray-pool"),i=32;function a(t){switch(t){case"uint8":return[n.mallocUint8,n.freeUint8];case"uint16":return[n.mallocUint16,n.freeUint16];case"uint32":return[n.mallocUint32,n.freeUint32];case"int8":return[n.mallocInt8,n.freeInt8];case"int16":return[n.mallocInt16,n.freeInt16];case"int32":return[n.mallocInt32,n.freeInt32];case"float32":return[n.mallocFloat,n.freeFloat];case"float64":return[n.mallocDouble,n.freeDouble];default:return null}}function o(t){for(var e=[],r=0;r0?s.push(["d",d,"=s",d,"-d",f,"*n",f].join("")):s.push(["d",d,"=s",d].join("")),f=d),0!=(p=t.length-1-l)&&(h>0?s.push(["e",p,"=s",p,"-e",h,"*n",h,",f",p,"=",c[p],"-f",h,"*n",h].join("")):s.push(["e",p,"=s",p,",f",p,"=",c[p]].join("")),h=p)}r.push("var "+s.join(","));var g=["0","n0-1","data","offset"].concat(o(t.length));r.push(["if(n0<=",i,"){","insertionSort(",g.join(","),")}else{","quickSort(",g.join(","),")}"].join("")),r.push("}return "+n);var v=new Function("insertionSort","quickSort",r.join("\n")),m=function(t,e){var r=["'use strict'"],n=["ndarrayInsertionSort",t.join("d"),e].join(""),i=["left","right","data","offset"].concat(o(t.length)),s=a(e),l=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var c=[],u=1;u1){for(r.push("dptr=0;sptr=ptr"),u=t.length-1;u>=0;--u)0!==(p=t[u])&&r.push(["for(i",p,"=0;i",p,"b){break __l}"].join("")),u=t.length-1;u>=1;--u)r.push("sptr+=e"+u,"dptr+=f"+u,"}");for(r.push("dptr=cptr;sptr=cptr-s0"),u=t.length-1;u>=0;--u)0!==(p=t[u])&&r.push(["for(i",p,"=0;i",p,"=0;--u)0!==(p=t[u])&&r.push(["for(i",p,"=0;i",p,"scratch)){",h("cptr",f("cptr-s0")),"cptr-=s0","}",h("cptr","scratch"));return r.push("}"),t.length>1&&s&&r.push("free(scratch)"),r.push("} return "+n),s?new Function("malloc","free",r.join("\n"))(s[0],s[1]):new Function(r.join("\n"))()}(t,e),y=function(t,e,r){var n=["'use strict'"],s=["ndarrayQuickSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(o(t.length)),c=a(e),u=0;n.push(["function ",s,"(",l.join(","),"){"].join(""));var f=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var h=[],p=1;p=0;--a)0!==(o=t[a])&&n.push(["for(i",o,"=0;i",o,"1)for(a=0;a1?n.push("ptr_shift+=d"+o):n.push("ptr0+=d"+o),n.push("}"))}}function y(e,r,i,a){if(1===r.length)n.push("ptr0="+d(r[0]));else{for(var o=0;o1)for(o=0;o=1;--o)i&&n.push("pivot_ptr+=f"+o),r.length>1?n.push("ptr_shift+=e"+o):n.push("ptr0+=e"+o),n.push("}")}function x(){t.length>1&&c&&n.push("free(pivot1)","free(pivot2)")}function b(e,r){var i="el"+e,a="el"+r;if(t.length>1){var o="__l"+ ++u;y(o,[i,a],!1,["comp=",g("ptr0"),"-",g("ptr1"),"\n","if(comp>0){tmp0=",i,";",i,"=",a,";",a,"=tmp0;break ",o,"}\n","if(comp<0){break ",o,"}"].join(""))}else n.push(["if(",g(d(i)),">",g(d(a)),"){tmp0=",i,";",i,"=",a,";",a,"=tmp0}"].join(""))}function _(e,r){t.length>1?m([e,r],!1,v("ptr0",g("ptr1"))):n.push(v(d(e),g(d(r))))}function w(e,r,i){if(t.length>1){var a="__l"+ ++u;y(a,[r],!0,[e,"=",g("ptr0"),"-pivot",i,"[pivot_ptr]\n","if(",e,"!==0){break ",a,"}"].join(""))}else n.push([e,"=",g(d(r)),"-pivot",i].join(""))}function k(e,r){t.length>1?m([e,r],!1,["tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1","tmp")].join("")):n.push(["ptr0=",d(e),"\n","ptr1=",d(r),"\n","tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1","tmp")].join(""))}function M(e,r,i){t.length>1?(m([e,r,i],!1,["tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1",g("ptr2")),"\n",v("ptr2","tmp")].join("")),n.push("++"+r,"--"+i)):n.push(["ptr0=",d(e),"\n","ptr1=",d(r),"\n","ptr2=",d(i),"\n","++",r,"\n","--",i,"\n","tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1",g("ptr2")),"\n",v("ptr2","tmp")].join(""))}function A(t,e){k(t,e),n.push("--"+e)}function T(e,r,i){t.length>1?m([e,r],!0,[v("ptr0",g("ptr1")),"\n",v("ptr1",["pivot",i,"[pivot_ptr]"].join(""))].join("")):n.push(v(d(e),g(d(r))),v(d(r),"pivot"+i))}function S(e,r){n.push(["if((",r,"-",e,")<=",i,"){\n","insertionSort(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}else{\n",s,"(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}"].join(""))}function E(e,r,i){t.length>1?(n.push(["__l",++u,":while(true){"].join("")),m([e],!0,["if(",g("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",u,"}"].join("")),n.push(i,"}")):n.push(["while(",g(d(e)),"===pivot",r,"){",i,"}"].join(""))}return n.push("var "+f.join(",")),b(1,2),b(4,5),b(1,3),b(2,3),b(1,4),b(3,4),b(2,5),b(2,3),b(4,5),t.length>1?m(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",g("ptr1"),"\n","pivot2[pivot_ptr]=",g("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",g("ptr0"),"\n","y=",g("ptr2"),"\n","z=",g("ptr4"),"\n",v("ptr5","x"),"\n",v("ptr6","y"),"\n",v("ptr7","z")].join("")):n.push(["pivot1=",g(d("el2")),"\n","pivot2=",g(d("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",g(d("el1")),"\n","y=",g(d("el3")),"\n","z=",g(d("el5")),"\n",v(d("index1"),"x"),"\n",v(d("index3"),"y"),"\n",v(d("index5"),"z")].join("")),_("index2","left"),_("index4","right"),n.push("if(pivots_are_equal){"),n.push("for(k=less;k<=great;++k){"),w("comp","k",1),n.push("if(comp===0){continue}"),n.push("if(comp<0){"),n.push("if(k!==less){"),k("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),n.push("while(true){"),w("comp","great",1),n.push("if(comp>0){"),n.push("great--"),n.push("}else if(comp<0){"),M("k","less","great"),n.push("break"),n.push("}else{"),A("k","great"),n.push("break"),n.push("}"),n.push("}"),n.push("}"),n.push("}"),n.push("}else{"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1<0){"),n.push("if(k!==less){"),k("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2>0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp>0){"),n.push("if(--greatindex5){"),E("less",1,"++less"),E("great",2,"--great"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1===0){"),n.push("if(k!==less){"),k("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2===0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp===0){"),n.push("if(--great1&&c?new Function("insertionSort","malloc","free",n.join("\n"))(r,c[0],c[1]):new Function("insertionSort",n.join("\n"))(r)}(t,e,m);return v(m,y)}},{"typedarray-pool":522}],431:[function(t,e,r){"use strict";var n=t("./lib/compile_sort.js"),i={};e.exports=function(t){var e=t.order,r=t.dtype,a=[e,r].join(":"),o=i[a];return o||(i[a]=o=n(e,r)),o(t),t}},{"./lib/compile_sort.js":430}],432:[function(t,e,r){"use strict";var n=t("ndarray-linear-interpolate"),i=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=new Array(_inline_3_arg4_)}",args:[{name:"_inline_3_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg2_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg3_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_4_arg2_(this_warped,_inline_4_arg0_),_inline_4_arg1_=_inline_4_arg3_.apply(void 0,this_warped)}",args:[{name:"_inline_4_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_4_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg4_",lvalue:!1,rvalue:!1,count:0}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warpND",blockSize:64}),a=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_7_arg2_(this_warped,_inline_7_arg0_),_inline_7_arg1_=_inline_7_arg3_(_inline_7_arg4_,this_warped[0])}",args:[{name:"_inline_7_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_7_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_7_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_7_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_7_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp1D",blockSize:64}),o=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_10_arg2_(this_warped,_inline_10_arg0_),_inline_10_arg1_=_inline_10_arg3_(_inline_10_arg4_,this_warped[0],this_warped[1])}",args:[{name:"_inline_10_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_10_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp2D",blockSize:64}),s=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_13_arg2_(this_warped,_inline_13_arg0_),_inline_13_arg1_=_inline_13_arg3_(_inline_13_arg4_,this_warped[0],this_warped[1],this_warped[2])}",args:[{name:"_inline_13_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_13_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp3D",blockSize:64});e.exports=function(t,e,r){switch(e.shape.length){case 1:a(t,r,n.d1,e);break;case 2:o(t,r,n.d2,e);break;case 3:s(t,r,n.d3,e);break;default:i(t,r,n.bind(void 0,e),e.shape.length)}return t}},{"cwise/lib/wrapper":137,"ndarray-linear-interpolate":426}],433:[function(t,e,r){var n=t("iota-array"),i=t("is-buffer"),a="undefined"!=typeof Float64Array;function o(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,r=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+l.join(",")+",v){"),i?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+l.join(",")+"){"),i?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",l.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+l.join(",")+"){return new "+r+"(this.data,"+o.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+o.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=o.map(function(t){return"a"+t+"=this.shape["+t+"]"}),d=o.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+d.join(","));for(var g=0;g=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");a.push("return new "+r+"(this.data,"+o.map(function(t){return"a"+t}).join(",")+","+o.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+l.join(",")+"){var "+o.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+o.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(g=0;g=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");return a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+o.map(function(t){return"shape["+t+"]"}).join(",")+","+o.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",a.join("\n"))(c[t],s)}var c={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,r,n){if(void 0===t)return(0,c.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var o=e.length;if(void 0===r){r=new Array(o);for(var s=o-1,u=1;s>=0;--s)r[s]=u,u*=e[s]}if(void 0===n)for(n=0,s=0;s>>0;e.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-i:i;var r=n.hi(t),o=n.lo(t);e>t==t>0?o===a?(r+=1,o=0):o+=1:0===o?(o=a,r-=1):o-=1;return n.pack(o,r)}},{"double-bits":152}],435:[function(t,e,r){var n=Math.PI,i=c(120);function a(t,e,r,n){return["C",t,e,r,n,r,n]}function o(t,e,r,n,i,a){return["C",t/3+2/3*r,e/3+2/3*n,i/3+2/3*r,a/3+2/3*n,i,a]}function s(t,e,r,a,o,c,u,f,h,p){if(p)k=p[0],M=p[1],_=p[2],w=p[3];else{var d=l(t,e,-o);t=d.x,e=d.y;var g=(t-(f=(d=l(f,h,-o)).x))/2,v=(e-(h=d.y))/2,m=g*g/(r*r)+v*v/(a*a);m>1&&(r*=m=Math.sqrt(m),a*=m);var y=r*r,x=a*a,b=(c==u?-1:1)*Math.sqrt(Math.abs((y*x-y*v*v-x*g*g)/(y*v*v+x*g*g)));b==1/0&&(b=1);var _=b*r*v/a+(t+f)/2,w=b*-a*g/r+(e+h)/2,k=Math.asin(((e-w)/a).toFixed(9)),M=Math.asin(((h-w)/a).toFixed(9));(k=t<_?n-k:k)<0&&(k=2*n+k),(M=f<_?n-M:M)<0&&(M=2*n+M),u&&k>M&&(k-=2*n),!u&&M>k&&(M-=2*n)}if(Math.abs(M-k)>i){var A=M,T=f,S=h;M=k+i*(u&&M>k?1:-1);var E=s(f=_+r*Math.cos(M),h=w+a*Math.sin(M),r,a,o,0,u,T,S,[M,A,_,w])}var C=Math.tan((M-k)/4),L=4/3*r*C,z=4/3*a*C,O=[2*t-(t+L*Math.sin(k)),2*e-(e-z*Math.cos(k)),f+L*Math.sin(M),h-z*Math.cos(M),f,h];if(p)return O;E&&(O=O.concat(E));for(var I=0;I7&&(r.push(m.splice(0,7)),m.unshift("C"));break;case"S":var x=p,b=d;"C"!=e&&"S"!=e||(x+=x-n,b+=b-i),m=["C",x,b,m[1],m[2],m[3],m[4]];break;case"T":"Q"==e||"T"==e?(f=2*p-f,h=2*d-h):(f=p,h=d),m=o(p,d,f,h,m[1],m[2]);break;case"Q":f=m[1],h=m[2],m=o(p,d,m[1],m[2],m[3],m[4]);break;case"L":m=a(p,d,m[1],m[2]);break;case"H":m=a(p,d,m[1],d);break;case"V":m=a(p,d,p,m[1]);break;case"Z":m=a(p,d,l,u)}e=y,p=m[m.length-2],d=m[m.length-1],m.length>4?(n=m[m.length-4],i=m[m.length-3]):(n=p,i=d),r.push(m)}return r}},{}],436:[function(t,e,r){r.vertexNormals=function(t,e,r){for(var n=e.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa){var b=i[c],_=1/Math.sqrt(v*y);for(x=0;x<3;++x){var w=(x+1)%3,k=(x+2)%3;b[x]+=_*(m[w]*g[k]-m[k]*g[w])}}}for(o=0;oa)for(_=1/Math.sqrt(M),x=0;x<3;++x)b[x]*=_;else for(x=0;x<3;++x)b[x]=0}return i},r.faceNormals=function(t,e,r){for(var n=t.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa?1/Math.sqrt(p):0;for(c=0;c<3;++c)h[c]*=p;i[o]=h}return i}},{}],437:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,o,s=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),l=1;l0){var f=Math.sqrt(u+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,c),f=Math.sqrt(2*h-u+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}},{}],439:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),u(r=[].slice.call(r,0,4),r);var i=new f(r,e,Math.log(n));i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up);return i};var n=t("filtered-vector"),i=t("gl-mat4/lookAt"),a=t("gl-mat4/fromQuat"),o=t("gl-mat4/invert"),s=t("./lib/quatFromFrame");function l(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function c(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function u(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=c(r,n,i,a);o>1e-6?(t[0]=r/o,t[1]=n/o,t[2]=i/o,t[3]=a/o):(t[0]=t[1]=t[2]=0,t[3]=1)}function f(t,e,r){this.radius=n([r]),this.center=n(e),this.rotation=n(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}var h=f.prototype;h.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},h.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;u(e,e);var r=this.computedMatrix;a(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;l<3;++l){for(var c=0,f=0;f<3;++f)c+=r[l+4*f]*i[f];r[12+l]=-c}},h.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r},h.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},h.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},h.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=i[1],o=i[5],s=i[9],c=l(a,o,s);a/=c,o/=c,s/=c;var u=i[0],f=i[4],h=i[8],p=u*a+f*o+h*s,d=l(u-=a*p,f-=o*p,h-=s*p);u/=d,f/=d,h/=d;var g=i[2],v=i[6],m=i[10],y=g*a+v*o+m*s,x=g*u+v*f+m*h,b=l(g-=y*a+x*u,v-=y*o+x*f,m-=y*s+x*h);g/=b,v/=b,m/=b;var _=u*e+a*r,w=f*e+o*r,k=h*e+s*r;this.center.move(t,_,w,k);var M=Math.exp(this.computedRadius[0]);M=Math.max(1e-4,M+n),this.radius.set(t,Math.log(M))},h.rotate=function(t,e,r,n){this.recalcMatrix(t),e=e||0,r=r||0;var i=this.computedMatrix,a=i[0],o=i[4],s=i[8],u=i[1],f=i[5],h=i[9],p=i[2],d=i[6],g=i[10],v=e*a+r*u,m=e*o+r*f,y=e*s+r*h,x=-(d*y-g*m),b=-(g*v-p*y),_=-(p*m-d*v),w=Math.sqrt(Math.max(0,1-Math.pow(x,2)-Math.pow(b,2)-Math.pow(_,2))),k=c(x,b,_,w);k>1e-6?(x/=k,b/=k,_/=k,w/=k):(x=b=_=0,w=1);var M=this.computedRotation,A=M[0],T=M[1],S=M[2],E=M[3],C=A*w+E*x+T*_-S*b,L=T*w+E*b+S*x-A*_,z=S*w+E*_+A*b-T*x,O=E*w-A*x-T*b-S*_;if(n){x=p,b=d,_=g;var I=Math.sin(n)/l(x,b,_);x*=I,b*=I,_*=I,O=O*(w=Math.cos(e))-(C=C*w+O*x+L*_-z*b)*x-(L=L*w+O*b+z*x-C*_)*b-(z=z*w+O*_+C*b-L*x)*_}var P=c(C,L,z,O);P>1e-6?(C/=P,L/=P,z/=P,O/=P):(C=L=z=0,O=1),this.rotation.set(t,C,L,z,O)},h.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var a=this.computedMatrix;i(a,e,r,n);var o=this.computedRotation;s(o,a[0],a[1],a[2],a[4],a[5],a[6],a[8],a[9],a[10]),u(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var l=0,c=0;c<3;++c)l+=Math.pow(r[c]-e[c],2);this.radius.set(t,.5*Math.log(Math.max(l,1e-6))),this.center.set(t,r[0],r[1],r[2])},h.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},h.setMatrix=function(t,e){var r=this.computedRotation;s(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),u(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;o(n,e);var i=n[15];if(Math.abs(i)>1e-6){var a=n[12]/i,l=n[13]/i,c=n[14]/i;this.recalcMatrix(t);var f=Math.exp(this.computedRadius[0]);this.center.set(t,a-n[2]*f,l-n[6]*f,c-n[10]*f),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},h.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},h.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},h.getDistanceLimits=function(t){var e=this.radius.bounds;return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},h.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},h.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":438,"filtered-vector":215,"gl-mat4/fromQuat":251,"gl-mat4/invert":254,"gl-mat4/lookAt":255}],440:[function(t,e,r){"use strict";var n=t("repeat-string");e.exports=function(t,e,r){return n(r="undefined"!=typeof r?r+"":" ",e)+t}},{"repeat-string":479}],441:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)return[t];var r=[t];"string"==typeof e||Array.isArray(e)?e={brackets:e}:e||(e={});var n=e.brackets?Array.isArray(e.brackets)?e.brackets:[e.brackets]:["{}","[]","()"],i=e.escape||"___",a=!!e.flat;n.forEach(function(t){var e=new RegExp(["\\",t[0],"[^\\",t[0],"\\",t[1],"]*\\",t[1]].join("")),n=[];function a(e,a,o){var s=r.push(e.slice(t[0].length,-t[1].length))-1;return n.push(s),i+s}r.forEach(function(t,n){for(var i,o=0;t!=i;)if(i=t,t=t.replace(e,a),o++>1e4)throw Error("References have circular dependency. Please, check them.");r[n]=t}),n=n.reverse(),r=r.map(function(e){return n.forEach(function(r){e=e.replace(new RegExp("(\\"+i+r+"(?![0-9]))","g"),t[0]+"$1"+t[1])}),e})});var o=new RegExp("\\"+i+"([0-9]+)");return a?r:function t(e,r,n){for(var i,a=[],s=0;i=o.exec(e);){if(s++>1e4)throw Error("Circular references in parenthesis");a.push(e.slice(0,i.index)),a.push(t(r[i[1]],r)),e=e.slice(i.index+i[0].length)}return a.push(e),a}(r[0],r)}function i(t,e){if(e&&e.flat){var r,n=e&&e.escape||"___",i=t[0];if(!i)return"";for(var a=new RegExp("\\"+n+"([0-9]+)"),o=0;i!=r;){if(o++>1e4)throw Error("Circular references in "+t);r=i,i=i.replace(a,s)}return i}return t.reduce(function t(e,r){return Array.isArray(r)&&(r=r.reduce(t,"")),e+r},"");function s(e,r){if(null==t[r])throw Error("Reference "+r+"is undefined");return t[r]}}function a(t,e){return Array.isArray(t)?i(t,e):n(t,e)}a.parse=n,a.stringify=i,e.exports=a},{}],442:[function(t,e,r){"use strict";var n=t("pick-by-alias");e.exports=function(t){var e;arguments.length>1&&(t=arguments);"string"==typeof t?t=t.split(/\s/).map(parseFloat):"number"==typeof t&&(t=[t]);t.length&&"number"==typeof t[0]?e=1===t.length?{width:t[0],height:t[0],x:0,y:0}:2===t.length?{width:t[0],height:t[1],x:0,y:0}:{x:t[0],y:t[1],width:t[2]-t[0]||0,height:t[3]-t[1]||0}:t&&(t=n(t,{left:"x l left Left",top:"y t top Top",width:"w width W Width",height:"h height W Width",bottom:"b bottom Bottom",right:"r right Right"}),e={x:t.left||0,y:t.top||0},null==t.width?t.right?e.width=t.right-e.x:e.width=0:e.width=t.width,null==t.height?t.bottom?e.height=t.bottom-e.y:e.height=0:e.height=t.height);return e}},{"pick-by-alias":448}],443:[function(t,e,r){e.exports=function(t){var e=[];return t.replace(i,function(t,r,i){var o=r.toLowerCase();for(i=function(t){var e=t.match(a);return e?e.map(Number):[]}(i),"m"==o&&i.length>2&&(e.push([r].concat(i.splice(0,2))),o="l",r="m"==r?"l":"L");;){if(i.length==n[o])return i.unshift(r),e.push(i);if(i.length0;--o)a=l[o],r=s[o],s[o]=s[a],s[a]=r,l[o]=l[r],l[r]=a,c=(c+r)*o;return n.freeUint32(l),n.freeUint32(s),c},r.unrank=function(t,e,r){switch(t){case 0:return r||[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}var n,i,a,o=1;for((r=r||new Array(t))[0]=0,a=1;a0;--a)e=e-(n=e/o|0)*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}},{"invert-permutation":398,"typedarray-pool":522}],448:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n,a,o={};if("string"==typeof e&&(e=i(e)),Array.isArray(e)){var s={};for(a=0;a0){o=a[u][r][0],l=u;break}s=o[1^l];for(var f=0;f<2;++f)for(var h=a[f][r],p=0;p0&&(o=d,s=g,l=f)}return i?s:(o&&c(o,l),s)}function f(t,r){var i=a[r][t][0],o=[t];c(i,r);for(var s=i[1^r];;){for(;s!==t;)o.push(s),s=u(o[o.length-2],s,!1);if(a[0][t].length+a[1][t].length===0)break;var l=o[o.length-1],f=t,h=o[1],p=u(l,f,!0);if(n(e[l],e[f],e[h],e[p])<0)break;o.push(t),s=u(l,f)}return o}function h(t,e){return e[1]===e[e.length-1]}for(var o=0;o0;){a[0][o].length;var g=f(o,p);h(d,g)?d.push.apply(d,g):(d.length>0&&l.push(d),d=g)}d.length>0&&l.push(d)}return l};var n=t("compare-angle")},{"compare-angle":115}],450:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=n(t,e.length),i=new Array(e.length),a=new Array(e.length),o=[],s=0;s0;){var c=o.pop();i[c]=!1;for(var u=r[c],s=0;s0})).length,v=new Array(g),m=new Array(g),p=0;p0;){var N=B.pop(),j=C[N];l(j,function(t,e){return t-e});var V,U=j.length,q=F[N];if(0===q){var k=d[N];V=[k]}for(var p=0;p=0)&&(F[H]=1^q,B.push(H),0===q)){var k=d[H];R(k)||(k.reverse(),V.push(k))}}0===q&&r.push(V)}return r};var n=t("edges-to-adjacency-list"),i=t("planar-dual"),a=t("point-in-big-polygon"),o=t("two-product"),s=t("robust-sum"),l=t("uniq"),c=t("./lib/trim-leaves");function u(t,e){for(var r=new Array(t),n=0;n>>1;e.dtype||(e.dtype="array"),"string"==typeof e.dtype?d=new(f(e.dtype))(v):e.dtype&&(d=e.dtype,Array.isArray(d)&&(d.length=v));for(var m=0;mr){for(var h=0;hl||A>c||T=C||o===s)){var u=y[a];void 0===s&&(s=u.length);for(var f=o;f=g&&p<=m&&d>=v&&d<=w&&z.push(h)}var b=x[a],_=b[4*o+0],k=b[4*o+1],E=b[4*o+2],L=b[4*o+3],O=function(t,e){for(var r=null,n=0;null===r;)if(r=t[4*e+n],++n>t.length)return null;return r}(b,o+1),I=.5*i,P=a+1;e(r,n,I,P,_,k||E||L||O),e(r,n+I,I,P,k,E||L||O),e(r+I,n,I,P,E,L||O),e(r+I,n+I,I,P,L,O)}}}(0,0,1,0,0,1),z},d;function E(t,e,r){for(var n=1,i=.5,a=.5,o=.5,s=0;s0&&e[i]===r[0]))return 1;a=t[i-1]}for(var s=1;a;){var l=a.key,c=n(r,l[0],l[1]);if(l[0][0]0))return 0;s=-1,a=a.right}else if(c>0)a=a.left;else{if(!(c<0))return 0;s=1,a=a.right}}return s}}(m.slabs,m.coordinates);return 0===a.length?y:function(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}(l(a),y)};var n=t("robust-orientation")[3],i=t("slab-decomposition"),a=t("interval-tree-1d"),o=t("binary-search-bounds");function s(){return!0}function l(t){for(var e={},r=0;r=-t},pointBetween:function(e,r,n){var i=e[1]-r[1],a=n[0]-r[0],o=e[0]-r[0],s=n[1]-r[1],l=o*a+i*s;return!(l-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-i>t&&(a-c)*(i-u)/(o-u)+c-n>t&&(s=!s),a=c,o=u}return s}};return e}},{}],459:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),i=1;i0})}function u(t,n){var i=t.seg,a=n.seg,o=i.start,s=i.end,c=a.start,u=a.end;r&&r.checkIntersection(i,a);var f=e.linesIntersect(o,s,c,u);if(!1===f){if(!e.pointsCollinear(o,s,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(s,c))return!1;var h=e.pointsSame(o,c),p=e.pointsSame(s,u);if(h&&p)return n;var d=!h&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(s,c,u);if(h)return g?l(n,s):l(t,u),n;d&&(p||(g?l(n,s):l(t,u)),l(n,o))}else 0===f.alongA&&(-1===f.alongB?l(t,c):0===f.alongB?l(t,f.pt):1===f.alongB&&l(t,u)),0===f.alongB&&(-1===f.alongA?l(n,o):0===f.alongA?l(n,f.pt):1===f.alongA&&l(n,s));return!1}for(var f=[];!a.isEmpty();){var h=a.getHead();if(r&&r.vert(h.pt[0]),h.isStart){r&&r.segmentNew(h.seg,h.primary);var p=c(h),d=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(d){var t=u(h,d);if(t)return t}return!!g&&u(h,g)}r&&r.tempStatus(h.seg,!!d&&d.seg,!!g&&g.seg);var m,y,x=v();if(x)t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=h.seg.myFill,r&&r.segmentUpdate(x.seg),h.other.remove(),h.remove();if(a.getHead()!==h){r&&r.rewind(h.seg);continue}t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below,h.seg.myFill.below=g?g.seg.myFill.above:i,h.seg.myFill.above=y?!h.seg.myFill.below:h.seg.myFill.below):null===h.seg.otherFill&&(m=g?h.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:h.primary?o:i,h.seg.otherFill={above:m,below:m}),r&&r.status(h.seg,!!d&&d.seg,!!g&&g.seg),h.other.status=p.insert(n.node({ev:h}))}else{var b=h.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(s.exists(b.prev)&&s.exists(b.next)&&u(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!h.primary){var _=h.seg.myFill;h.seg.myFill=h.seg.otherFill,h.seg.otherFill=_}f.push(h.seg)}a.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,i,a,o=t[t.length-1],l=0;l=c?(M=1,y=c+2*h+d):y=h*(M=-h/c)+d):(M=0,p>=0?(A=0,y=d):-p>=f?(A=1,y=f+2*p+d):y=p*(A=-p/f)+d);else if(A<0)A=0,h>=0?(M=0,y=d):-h>=c?(M=1,y=c+2*h+d):y=h*(M=-h/c)+d;else{var T=1/k;y=(M*=T)*(c*M+u*(A*=T)+2*h)+A*(u*M+f*A+2*p)+d}else M<0?(b=f+p)>(x=u+h)?(_=b-x)>=(w=c-2*u+f)?(M=1,A=0,y=c+2*h+d):y=(M=_/w)*(c*M+u*(A=1-M)+2*h)+A*(u*M+f*A+2*p)+d:(M=0,b<=0?(A=1,y=f+2*p+d):p>=0?(A=0,y=d):y=p*(A=-p/f)+d):A<0?(b=c+h)>(x=u+p)?(_=b-x)>=(w=c-2*u+f)?(A=1,M=0,y=f+2*p+d):y=(M=1-(A=_/w))*(c*M+u*A+2*h)+A*(u*M+f*A+2*p)+d:(A=0,b<=0?(M=1,y=c+2*h+d):h>=0?(M=0,y=d):y=h*(M=-h/c)+d):(_=f+p-u-h)<=0?(M=0,A=1,y=f+2*p+d):_>=(w=c-2*u+f)?(M=1,A=0,y=c+2*h+d):y=(M=_/w)*(c*M+u*(A=1-M)+2*h)+A*(u*M+f*A+2*p)+d;var S=1-M-A;for(l=0;l1)for(var r=1;r0){var c=t[r-1];if(0===n(s,c)&&a(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}},{"cell-orientation":100,"compare-cell":116,"compare-oriented-cell":117}],473:[function(t,e,r){"use strict";var n=t("array-bounds"),i=t("color-normalize"),a=t("update-diff"),o=t("pick-by-alias"),s=t("object-assign"),l=t("flatten-vertex-data"),c=t("to-float32"),u=c.float32,f=c.fract32;e.exports=function(t,e){"function"==typeof t?(e||(e={}),e.regl=t):e=t;e.length&&(e.positions=e);if(!(t=e.regl).hasExtension("ANGLE_instanced_arrays"))throw Error("regl-error2d: `ANGLE_instanced_arrays` extension should be enabled");var r,c,p,d,g,v,m=t._gl,y={color:"black",capSize:5,lineWidth:1,opacity:1,viewport:null,range:null,offset:0,count:0,bounds:null,positions:[],errors:[]},x=[];return d=t.buffer({usage:"dynamic",type:"uint8",data:new Uint8Array(0)}),c=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)}),p=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)}),g=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)}),v=t.buffer({usage:"static",type:"float",data:h}),k(e),r=t({vert:"\n\t\tprecision highp float;\n\n\t\tattribute vec2 position, positionFract;\n\t\tattribute vec4 error;\n\t\tattribute vec4 color;\n\n\t\tattribute vec2 direction, lineOffset, capOffset;\n\n\t\tuniform vec4 viewport;\n\t\tuniform float lineWidth, capSize;\n\t\tuniform vec2 scale, scaleFract, translate, translateFract;\n\n\t\tvarying vec4 fragColor;\n\n\t\tvoid main() {\n\t\t\tfragColor = color / 255.;\n\n\t\t\tvec2 pixelOffset = lineWidth * lineOffset + (capSize + lineWidth) * capOffset;\n\n\t\t\tvec2 dxy = -step(.5, direction.xy) * error.xz + step(direction.xy, vec2(-.5)) * error.yw;\n\n\t\t\tvec2 position = position + dxy;\n\n\t\t\tvec2 pos = (position + translate) * scale\n\t\t\t\t+ (positionFract + translateFract) * scale\n\t\t\t\t+ (position + translate) * scaleFract\n\t\t\t\t+ (positionFract + translateFract) * scaleFract;\n\n\t\t\tpos += pixelOffset / viewport.zw;\n\n\t\t\tgl_Position = vec4(pos * 2. - 1., 0, 1);\n\t\t}\n\t\t",frag:"\n\t\tprecision mediump float;\n\n\t\tvarying vec4 fragColor;\n\n\t\tuniform float opacity;\n\n\t\tvoid main() {\n\t\t\tgl_FragColor = fragColor;\n\t\t\tgl_FragColor.a *= opacity;\n\t\t}\n\t\t",uniforms:{range:t.prop("range"),lineWidth:t.prop("lineWidth"),capSize:t.prop("capSize"),opacity:t.prop("opacity"),scale:t.prop("scale"),translate:t.prop("translate"),scaleFract:t.prop("scaleFract"),translateFract:t.prop("translateFract"),viewport:function(t,e){return[e.viewport.x,e.viewport.y,t.viewportWidth,t.viewportHeight]}},attributes:{color:{buffer:d,offset:function(t,e){return 4*e.offset},divisor:1},position:{buffer:c,offset:function(t,e){return 8*e.offset},divisor:1},positionFract:{buffer:p,offset:function(t,e){return 8*e.offset},divisor:1},error:{buffer:g,offset:function(t,e){return 16*e.offset},divisor:1},direction:{buffer:v,stride:24,offset:0},lineOffset:{buffer:v,stride:24,offset:8},capOffset:{buffer:v,stride:24,offset:16}},primitive:"triangles",blend:{enable:!0,color:[0,0,0,0],equation:{rgb:"add",alpha:"add"},func:{srcRGB:"src alpha",dstRGB:"one minus src alpha",srcAlpha:"one minus dst alpha",dstAlpha:"one"}},depth:{enable:!1},scissor:{enable:!0,box:t.prop("viewport")},viewport:t.prop("viewport"),stencil:!1,instances:t.prop("count"),count:h.length}),s(b,{update:k,draw:_,destroy:M,regl:t,gl:m,canvas:m.canvas,groups:x}),b;function b(t){t?k(t):null===t&&M(),_()}function _(e){if("number"==typeof e)return w(e);e&&!Array.isArray(e)&&(e=[e]),t._refresh(),x.forEach(function(t,r){t&&(e&&(e[r]?t.draw=!0:t.draw=!1),t.draw?w(r):t.draw=!0)})}function w(t){"number"==typeof t&&(t=x[t]),null!=t&&t&&t.count&&t.color&&t.opacity&&t.positions&&t.positions.length>1&&(t.scaleRatio=[t.scale[0]*t.viewport.width,t.scale[1]*t.viewport.height],r(t),t.after&&t.after(t))}function k(t){if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var e=0,r=0;if(b.groups=x=t.map(function(t,c){var u=x[c];return t?("function"==typeof t?t={after:t}:"number"==typeof t[0]&&(t={positions:t}),t=o(t,{color:"color colors fill",capSize:"capSize cap capsize cap-size",lineWidth:"lineWidth line-width width line thickness",opacity:"opacity alpha",range:"range dataBox",viewport:"viewport viewBox",errors:"errors error",positions:"positions position data points"}),u||(x[c]=u={id:c,scale:null,translate:null,scaleFract:null,translateFract:null,draw:!0},t=s({},y,t)),a(u,t,[{lineWidth:function(t){return.5*+t},capSize:function(t){return.5*+t},opacity:parseFloat,errors:function(t){return t=l(t),r+=t.length,t},positions:function(t,r){return t=l(t,"float64"),r.count=Math.floor(t.length/2),r.bounds=n(t,2),r.offset=e,e+=r.count,t}},{color:function(t,e){var r=e.count;if(t||(t="transparent"),!Array.isArray(t)||"number"==typeof t[0]){var n=t;t=Array(r);for(var a=0;a 0. && baClipping < length(normalWidth * endBotJoin)) {\n\t\t//handle miter clipping\n\t\tbTopCoord -= normalWidth * endTopJoin;\n\t\tbTopCoord += normalize(endTopJoin * normalWidth) * baClipping;\n\t}\n\n\tif (nextReverse) {\n\t\t//make join rectangular\n\t\tvec2 miterShift = normalWidth * endJoinDirection * miterLimit * .5;\n\t\tfloat normalAdjust = 1. - min(miterLimit / endMiterRatio, 1.);\n\t\tbBotCoord = bCoord + miterShift - normalAdjust * normalWidth * currNormal * .5;\n\t\tbTopCoord = bCoord + miterShift + normalAdjust * normalWidth * currNormal * .5;\n\t}\n\telse if (!prevReverse && abClipping > 0. && abClipping < length(normalWidth * startBotJoin)) {\n\t\t//handle miter clipping\n\t\taBotCoord -= normalWidth * startBotJoin;\n\t\taBotCoord += normalize(startBotJoin * normalWidth) * abClipping;\n\t}\n\n\tvec2 aTopPosition = (aTopCoord) * adjustedScale + translate;\n\tvec2 aBotPosition = (aBotCoord) * adjustedScale + translate;\n\n\tvec2 bTopPosition = (bTopCoord) * adjustedScale + translate;\n\tvec2 bBotPosition = (bBotCoord) * adjustedScale + translate;\n\n\t//position is normalized 0..1 coord on the screen\n\tvec2 position = (aTopPosition * lineTop + aBotPosition * lineBot) * lineStart + (bTopPosition * lineTop + bBotPosition * lineBot) * lineEnd;\n\n\tstartCoord = aCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\tendCoord = bCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tenableStartMiter = step(dot(currTangent, prevTangent), .5);\n\tenableEndMiter = step(dot(currTangent, nextTangent), .5);\n\n\t//bevel miter cutoffs\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * miterLimit * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * miterLimit * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n\n\t//round miter cutoffs\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * abs(dot(startJoinDirection, currNormal)) * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * abs(dot(endJoinDirection, currNormal)) * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nuniform sampler2D dashPattern;\nuniform float dashSize, pixelRatio, thickness, opacity, id, miterMode;\n\nvarying vec4 fragColor;\nvarying vec2 tangent;\nvarying vec4 startCutoff, endCutoff;\nvarying vec2 startCoord, endCoord;\nvarying float enableStartMiter, enableEndMiter;\n\nfloat distToLine(vec2 p, vec2 a, vec2 b) {\n\tvec2 diff = b - a;\n\tvec2 perp = normalize(vec2(-diff.y, diff.x));\n\treturn dot(p - a, perp);\n}\n\nvoid main() {\n\tfloat alpha = 1., distToStart, distToEnd;\n\tfloat cutoff = thickness * .5;\n\n\t//bevel miter\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToStart + 1., 0.), 1.);\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToEnd + 1., 0.), 1.);\n\t\t}\n\t}\n\n\t// round miter\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - startCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - endCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\t}\n\n\tfloat t = fract(dot(tangent, gl_FragCoord.xy) / dashSize) * .5 + .25;\n\tfloat dash = texture2D(dashPattern, vec2(t, .5)).r;\n\n\tgl_FragColor = fragColor;\n\tgl_FragColor.a *= alpha * opacity * dash;\n}\n"]),attributes:{lineEnd:{buffer:r,divisor:0,stride:8,offset:0},lineTop:{buffer:r,divisor:0,stride:8,offset:4},aColor:{buffer:t.prop("colorBuffer"),stride:4,offset:0,divisor:1},bColor:{buffer:t.prop("colorBuffer"),stride:4,offset:4,divisor:1},prevCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:0,divisor:1},aCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:8,divisor:1},bCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:16,divisor:1},nextCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:24,divisor:1}}},n))}catch(t){e=i}return{fill:t({primitive:"triangle",elements:function(t,e){return e.triangles},offset:0,vert:o(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec2 position, positionFract;\n\nuniform vec4 color;\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio, id;\nuniform vec4 viewport;\nuniform float opacity;\n\nvarying vec4 fragColor;\n\nconst float MAX_LINES = 256.;\n\nvoid main() {\n\tfloat depth = (MAX_LINES - 4. - id) / (MAX_LINES);\n\n\tvec2 position = position * scale + translate\n + positionFract * scale + translateFract\n + position * scaleFract\n + positionFract * scaleFract;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tfragColor = color / 255.;\n\tfragColor.a *= opacity;\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n\tgl_FragColor = fragColor;\n}\n"]),uniforms:{scale:t.prop("scale"),color:t.prop("fill"),scaleFract:t.prop("scaleFract"),translateFract:t.prop("translateFract"),translate:t.prop("translate"),opacity:t.prop("opacity"),pixelRatio:t.context("pixelRatio"),id:t.prop("id"),viewport:function(t,e){return[e.viewport.x,e.viewport.y,t.viewportWidth,t.viewportHeight]}},attributes:{position:{buffer:t.prop("positionBuffer"),stride:8,offset:8},positionFract:{buffer:t.prop("positionFractBuffer"),stride:8,offset:8}},blend:n.blend,depth:{enable:!1},scissor:n.scissor,stencil:n.stencil,viewport:n.viewport}),rect:i,miter:e}},v.defaults={dashes:null,join:"miter",miterLimit:1,thickness:10,cap:"square",color:"black",opacity:1,overlay:!1,viewport:null,range:null,close:!1,fill:null},v.prototype.render=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];e.length&&(t=this).update.apply(t,e),this.draw()},v.prototype.draw=function(){for(var t=this,e=[],r=arguments.length;r--;)e[r]=arguments[r];return(e.length?e:this.passes).forEach(function(e,r){var n;if(e&&Array.isArray(e))return(n=t).draw.apply(n,e);"number"==typeof e&&(e=t.passes[e]),e&&e.count>1&&e.opacity&&(t.regl._refresh(),e.fill&&e.triangles&&e.triangles.length>2&&t.shaders.fill(e),e.thickness&&(e.scale[0]*e.viewport.width>v.precisionThreshold||e.scale[1]*e.viewport.height>v.precisionThreshold?t.shaders.rect(e):"rect"===e.join||!e.join&&(e.thickness<=2||e.count>=v.maxPoints)?t.shaders.rect(e):t.shaders.miter(e)))}),this},v.prototype.update=function(t){var e=this;if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var r=this.regl,o=this.gl;if(t.forEach(function(t,f){var d=e.passes[f];if(void 0!==t)if(null!==t){if("number"==typeof t[0]&&(t={positions:t}),t=s(t,{positions:"positions points data coords",thickness:"thickness lineWidth lineWidths line-width linewidth width stroke-width strokewidth strokeWidth",join:"lineJoin linejoin join type mode",miterLimit:"miterlimit miterLimit",dashes:"dash dashes dasharray dash-array dashArray",color:"color colour stroke colors colours stroke-color strokeColor",fill:"fill fill-color fillColor",opacity:"alpha opacity",overlay:"overlay crease overlap intersect",close:"closed close closed-path closePath",range:"range dataBox",viewport:"viewport viewBox",hole:"holes hole hollow"}),d||(e.passes[f]=d={id:f,scale:null,scaleFract:null,translate:null,translateFract:null,count:0,hole:[],depth:0,dashLength:1,dashTexture:r.texture({channels:1,data:new Uint8Array([255]),width:1,height:1,mag:"linear",min:"linear"}),colorBuffer:r.buffer({usage:"dynamic",type:"uint8",data:new Uint8Array}),positionBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array}),positionFractBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array})},t=a({},v.defaults,t)),null!=t.thickness&&(d.thickness=parseFloat(t.thickness)),null!=t.opacity&&(d.opacity=parseFloat(t.opacity)),null!=t.miterLimit&&(d.miterLimit=parseFloat(t.miterLimit)),null!=t.overlay&&(d.overlay=!!t.overlay,f 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]),u.vert=l(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nvec2 paletteCoord(float id) {\n return vec2(\n (mod(id, paletteSize.x) + .5) / paletteSize.x,\n (floor(id / paletteSize.x) + .5) / paletteSize.y\n );\n}\nvec2 paletteCoord(vec2 id) {\n return vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n );\n}\n\nvec4 getColor(vec4 id) {\n // zero-palette means we deal with direct buffer\n if (paletteSize.x == 0.) return id / 255.;\n return texture2D(palette, paletteCoord(id.xy));\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]),h&&(u.frag=u.frag.replace("smoothstep","smoothStep"),c.frag=c.frag.replace("smoothstep","smoothStep")),this.drawCircle=t(u)}e.exports=g,g.defaults={color:"black",borderColor:"transparent",borderSize:0,size:12,opacity:1,marker:void 0,viewport:null,range:null,pixelSize:null,count:0,offset:0,bounds:null,positions:[],snap:1e4},g.prototype.render=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];return e.length&&(t=this).update.apply(t,e),this.draw(),this},g.prototype.draw=function(){for(var t=this,e=[],r=arguments.length;r--;)e[r]=arguments[r];var n=this.groups;if(1===e.length&&Array.isArray(e[0])&&(null===e[0][0]||Array.isArray(e[0][0]))&&(e=e[0]),this.regl._refresh(),e.length)for(var i=0;in)?e.tree=o(t,{bounds:h}):n&&n.length&&(e.tree=n),e.tree){var d={primitive:"points",usage:"static",data:e.tree,type:"uint32"};e.elements?e.elements(d):e.elements=l.elements(d)}return a({data:p.float(t),usage:"dynamic"}),s({data:p.fract(t),usage:"dynamic"}),c({data:new Uint8Array(u),type:"uint8",usage:"stream"}),t}},{marker:function(e,r,n){var i=r.activation;if(i.forEach(function(t){return t&&t.destroy&&t.destroy()}),i.length=0,e&&"number"!=typeof e[0]){for(var a=[],o=0,s=Math.min(e.length,r.count);o=0)return a;if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)e=t;else{e=new Uint8Array(t.length);for(var o=0,s=t.length;oi*i*4&&(this.tooManyColors=!0),this.updatePalette(r),1===o.length?o[0]:o},g.prototype.updatePalette=function(t){if(!this.tooManyColors){var e=this.maxColors,r=this.paletteTexture,n=Math.ceil(.25*t.length/e);if(n>1)for(var i=.25*(t=t.slice()).length%e;i2?(s[0],s[2],n=s[1],i=s[3]):s.length?(n=s[0],i=s[1]):(s.x,n=s.y,s.x+s.width,i=s.y+s.height),l.length>2?(a=l[0],o=l[2],l[1],l[3]):l.length?(a=l[0],o=l[1]):(a=l.x,l.y,o=l.x+l.width,l.y+l.height),[a,n,o,i]}function p(t){if("number"==typeof t)return[t,t,t,t];if(2===t.length)return[t[0],t[1],t[0],t[1]];var e=l(t);return[e.x,e.y,e.x+e.width,e.y+e.height]}e.exports=u,u.prototype.render=function(){for(var t,e=this,r=[],n=arguments.length;n--;)r[n]=arguments[n];return r.length&&(t=this).update.apply(t,r),this.regl.attributes.preserveDrawingBuffer?this.draw():(this.dirty?null==this.planned&&(this.planned=o(function(){e.draw(),e.dirty=!0,e.planned=null})):(this.draw(),this.dirty=!0,o(function(){e.dirty=!1})),this)},u.prototype.update=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e.length){for(var n=0;nM))&&(s.lower||!(k>>=e))<<3,(e|=r=(15<(t>>>=r))<<2)|(r=(3<(t>>>=r))<<1)|t>>>r>>1}function s(){function t(t){t:{for(var e=16;268435456>=e;e*=16)if(t<=e){t=e;break t}t=0}return 0<(e=r[o(t)>>2]).length?e.pop():new ArrayBuffer(t)}function e(t){r[o(t.byteLength)>>2].push(t)}var r=a(8,function(){return[]});return{alloc:t,free:e,allocType:function(e,r){var n=null;switch(e){case 5120:n=new Int8Array(t(r),0,r);break;case 5121:n=new Uint8Array(t(r),0,r);break;case 5122:n=new Int16Array(t(2*r),0,r);break;case 5123:n=new Uint16Array(t(2*r),0,r);break;case 5124:n=new Int32Array(t(4*r),0,r);break;case 5125:n=new Uint32Array(t(4*r),0,r);break;case 5126:n=new Float32Array(t(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(t){e(t.buffer)}}}function l(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||Y(t.data))}function c(t,e,r,n,i,a){for(var o=0;o(i=s)&&(i=n.buffer.byteLength,5123===f?i>>=1:5125===f&&(i>>=2)),n.vertCount=i,i=o,0>o&&(i=4,1===(o=n.buffer.dimension)&&(i=0),2===o&&(i=1),3===o&&(i=4)),n.primType=i}function o(t){n.elementsCount--,delete s[t.id],t.buffer.destroy(),t.buffer=null}var s={},c=0,u={uint8:5121,uint16:5123};e.oes_element_index_uint&&(u.uint32=5125),i.prototype.bind=function(){this.buffer.bind()};var f=[];return{create:function(t,e){function s(t){if(t)if("number"==typeof t)c(t),f.primType=4,f.vertCount=0|t,f.type=5121;else{var e=null,r=35044,n=-1,i=-1,o=0,h=0;Array.isArray(t)||Y(t)||l(t)?e=t:("data"in t&&(e=t.data),"usage"in t&&(r=K[t.usage]),"primitive"in t&&(n=rt[t.primitive]),"count"in t&&(i=0|t.count),"type"in t&&(h=u[t.type]),"length"in t?o=0|t.length:(o=i,5123===h||5122===h?o*=2:5125!==h&&5124!==h||(o*=4))),a(f,e,r,n,i,o,h)}else c(),f.primType=4,f.vertCount=0,f.type=5121;return s}var c=r.create(null,34963,!0),f=new i(c._buffer);return n.elementsCount++,s(t),s._reglType="elements",s._elements=f,s.subdata=function(t,e){return c.subdata(t,e),s},s.destroy=function(){o(f)},s},createStream:function(t){var e=f.pop();return e||(e=new i(r.create(null,34963,!0,!1)._buffer)),a(e,t,35040,-1,-1,0,0),e},destroyStream:function(t){f.push(t)},getElements:function(t){return"function"==typeof t&&t._elements instanceof i?t._elements:null},clear:function(){X(s).forEach(o)}}}function g(t){for(var e=G.allocType(5123,t.length),r=0;r>>31<<15,i=(a<<1>>>24)-127,a=a>>13&1023;e[r]=-24>i?n:-14>i?n+(a+1024>>-14-i):15>=i,r.height>>=i,p(r,n[i]),t.mipmask|=1<e;++e)t.images[e]=null;return t}function L(t){for(var e=t.images,r=0;re){for(var r=0;r=--this.refCount&&B(this)}}),o.profile&&(a.getTotalTextureSize=function(){var t=0;return Object.keys(mt).forEach(function(e){t+=mt[e].stats.size}),t}),{create2D:function(e,r){function n(t,e){var r=i.texInfo;z.call(r);var a=C();return"number"==typeof t?T(a,0|t,"number"==typeof e?0|e:0|t):t?(O(r,t),S(a,t)):T(a,1,1),r.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,c(i,a),i.internalformat=a.internalformat,n.width=a.width,n.height=a.height,D(i),E(a,3553),I(r,3553),R(),L(a),o.profile&&(i.stats.size=k(i.internalformat,i.type,a.width,a.height,r.genMipmaps,!1)),n.format=tt[i.internalformat],n.type=et[i.type],n.mag=rt[r.magFilter],n.min=nt[r.minFilter],n.wrapS=it[r.wrapS],n.wrapT=it[r.wrapT],n}var i=new P(3553);return mt[i.id]=i,a.textureCount++,n(e,r),n.subimage=function(t,e,r,a){e|=0,r|=0,a|=0;var o=m();return c(o,i),o.width=0,o.height=0,p(o,t),o.width=o.width||(i.width>>a)-e,o.height=o.height||(i.height>>a)-r,D(i),d(o,3553,e,r,a),R(),M(o),n},n.resize=function(e,r){var a=0|e,s=0|r||a;if(a===i.width&&s===i.height)return n;n.width=i.width=a,n.height=i.height=s,D(i);for(var l,c=i.channels,u=i.type,f=0;i.mipmask>>f;++f){var h=a>>f,p=s>>f;if(!h||!p)break;l=G.zero.allocType(u,h*p*c),t.texImage2D(3553,f,i.format,h,p,0,i.format,i.type,l),l&&G.zero.freeType(l)}return R(),o.profile&&(i.stats.size=k(i.internalformat,i.type,a,s,!1,!1)),n},n._reglType="texture2d",n._texture=i,o.profile&&(n.stats=i.stats),n.destroy=function(){i.decRef()},n},createCube:function(e,r,n,i,s,l){function f(t,e,r,n,i,a){var s,l=h.texInfo;for(z.call(l),s=0;6>s;++s)g[s]=C();if("number"!=typeof t&&t){if("object"==typeof t)if(e)S(g[0],t),S(g[1],e),S(g[2],r),S(g[3],n),S(g[4],i),S(g[5],a);else if(O(l,t),u(h,t),"faces"in t)for(t=t.faces,s=0;6>s;++s)c(g[s],h),S(g[s],t[s]);else for(s=0;6>s;++s)S(g[s],t)}else for(t=0|t||1,s=0;6>s;++s)T(g[s],t,t);for(c(h,g[0]),h.mipmask=l.genMipmaps?(g[0].width<<1)-1:g[0].mipmask,h.internalformat=g[0].internalformat,f.width=g[0].width,f.height=g[0].height,D(h),s=0;6>s;++s)E(g[s],34069+s);for(I(l,34067),R(),o.profile&&(h.stats.size=k(h.internalformat,h.type,f.width,f.height,l.genMipmaps,!0)),f.format=tt[h.internalformat],f.type=et[h.type],f.mag=rt[l.magFilter],f.min=nt[l.minFilter],f.wrapS=it[l.wrapS],f.wrapT=it[l.wrapT],s=0;6>s;++s)L(g[s]);return f}var h=new P(34067);mt[h.id]=h,a.cubeCount++;var g=Array(6);return f(e,r,n,i,s,l),f.subimage=function(t,e,r,n,i){r|=0,n|=0,i|=0;var a=m();return c(a,h),a.width=0,a.height=0,p(a,e),a.width=a.width||(h.width>>i)-r,a.height=a.height||(h.height>>i)-n,D(h),d(a,34069+t,r,n,i),R(),M(a),f},f.resize=function(e){if((e|=0)!==h.width){f.width=h.width=e,f.height=h.height=e,D(h);for(var r=0;6>r;++r)for(var n=0;h.mipmask>>n;++n)t.texImage2D(34069+r,n,h.format,e>>n,e>>n,0,h.format,h.type,null);return R(),o.profile&&(h.stats.size=k(h.internalformat,h.type,f.width,f.height,!1,!0)),f}},f._reglType="textureCube",f._texture=h,o.profile&&(f.stats=h.stats),f.destroy=function(){h.decRef()},f},clear:function(){for(var e=0;er;++r)if(0!=(e.mipmask&1<>r,e.height>>r,0,e.internalformat,e.type,null);else for(var n=0;6>n;++n)t.texImage2D(34069+n,r,e.internalformat,e.width>>r,e.height>>r,0,e.internalformat,e.type,null);I(e.texInfo,e.target)})}}}function A(t,e,r,n,i,a){function o(t,e,r){this.target=t,this.texture=e,this.renderbuffer=r;var n=t=0;e?(t=e.width,n=e.height):r&&(t=r.width,n=r.height),this.width=t,this.height=n}function s(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function l(t,e,r){t&&(t.texture?t.texture._texture.refCount+=1:t.renderbuffer._renderbuffer.refCount+=1)}function c(e,r){r&&(r.texture?t.framebufferTexture2D(36160,e,r.target,r.texture._texture.texture,0):t.framebufferRenderbuffer(36160,e,36161,r.renderbuffer._renderbuffer.renderbuffer))}function u(t){var e=3553,r=null,n=null,i=t;return"object"==typeof t&&(i=t.data,"target"in t&&(e=0|t.target)),"texture2d"===(t=i._reglType)?r=i:"textureCube"===t?r=i:"renderbuffer"===t&&(n=i,e=36161),new o(e,r,n)}function f(t,e,r,a,s){return r?((t=n.create2D({width:t,height:e,format:a,type:s}))._texture.refCount=0,new o(3553,t,null)):((t=i.create({width:t,height:e,format:a}))._renderbuffer.refCount=0,new o(36161,null,t))}function h(t){return t&&(t.texture||t.renderbuffer)}function p(t,e,r){t&&(t.texture?t.texture.resize(e,r):t.renderbuffer&&t.renderbuffer.resize(e,r))}function d(){this.id=k++,M[this.id]=this,this.framebuffer=t.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function g(t){t.colorAttachments.forEach(s),s(t.depthAttachment),s(t.stencilAttachment),s(t.depthStencilAttachment)}function v(e){t.deleteFramebuffer(e.framebuffer),e.framebuffer=null,a.framebufferCount--,delete M[e.id]}function m(e){var n;t.bindFramebuffer(36160,e.framebuffer);var i=e.colorAttachments;for(n=0;ni;++i){for(c=0;ct;++t)r[t].resize(n);return e.width=e.height=n,e},_reglType:"framebufferCube",destroy:function(){r.forEach(function(t){t.destroy()})}})},clear:function(){X(M).forEach(v)},restore:function(){X(M).forEach(function(e){e.framebuffer=t.createFramebuffer(),m(e)})}})}function T(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function S(t,e,r,n){function i(t,e,r,n){this.name=t,this.id=e,this.location=r,this.info=n}function a(t,e){for(var r=0;rt&&(t=e.stats.uniformsCount)}),t},r.getMaxAttributesCount=function(){var t=0;return h.forEach(function(e){e.stats.attributesCount>t&&(t=e.stats.attributesCount)}),t}),{clear:function(){var e=t.deleteShader.bind(t);X(c).forEach(e),c={},X(u).forEach(e),u={},h.forEach(function(e){t.deleteProgram(e.program)}),h.length=0,f={},r.shaderCount=0},program:function(t,e,n){var i=f[e];i||(i=f[e]={});var a=i[t];return a||(a=new s(e,t),r.shaderCount++,l(a),i[t]=a,h.push(a)),a},restore:function(){c={},u={};for(var t=0;t"+e+"?"+i+".constant["+e+"]:0;"}).join(""),"}}else{","if(",o,"(",i,".buffer)){",u,"=",s,".createStream(",34962,",",i,".buffer);","}else{",u,"=",s,".getBuffer(",i,".buffer);","}",f,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",u,".dtype;",l.normalized,"=!!",i,".normalized;"),n("size"),n("offset"),n("stride"),n("divisor"),r("}}"),r.exit("if(",l.isStream,"){",s,".destroyStream(",u,");","}"),l})}),o}function A(t,e,r,n,i){var o=_(t),s=function(t,e,r){function n(t){if(t in i){var r=i[t];t=!0;var n,o,s=0|r.x,l=0|r.y;return"width"in r?n=0|r.width:t=!1,"height"in r?o=0|r.height:t=!1,new P(!t&&e&&e.thisDep,!t&&e&&e.contextDep,!t&&e&&e.propDep,function(t,e){var i=t.shared.context,a=n;"width"in r||(a=e.def(i,".","framebufferWidth","-",s));var c=o;return"height"in r||(c=e.def(i,".","framebufferHeight","-",l)),[s,l,a,c]})}if(t in a){var c=a[t];return t=B(c,function(t,e){var r=t.invoke(e,c),n=t.shared.context,i=e.def(r,".x|0"),a=e.def(r,".y|0");return[i,a,e.def('"width" in ',r,"?",r,".width|0:","(",n,".","framebufferWidth","-",i,")"),r=e.def('"height" in ',r,"?",r,".height|0:","(",n,".","framebufferHeight","-",a,")")]}),e&&(t.thisDep=t.thisDep||e.thisDep,t.contextDep=t.contextDep||e.contextDep,t.propDep=t.propDep||e.propDep),t}return e?new P(e.thisDep,e.contextDep,e.propDep,function(t,e){var r=t.shared.context;return[0,0,e.def(r,".","framebufferWidth"),e.def(r,".","framebufferHeight")]}):null}var i=t.static,a=t.dynamic;if(t=n("viewport")){var o=t;t=new P(t.thisDep,t.contextDep,t.propDep,function(t,e){var r=o.append(t,e),n=t.shared.context;return e.set(n,".viewportWidth",r[2]),e.set(n,".viewportHeight",r[3]),r})}return{viewport:t,scissor_box:n("scissor.box")}}(t,o),l=k(t),c=function(t,e){var r=t.static,n=t.dynamic,i={};return nt.forEach(function(t){function e(e,a){if(t in r){var s=e(r[t]);i[o]=R(function(){return s})}else if(t in n){var l=n[t];i[o]=B(l,function(t,e){return a(t,e,t.invoke(e,l))})}}var o=m(t);switch(t){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":return e(function(t){return t},function(t,e,r){return r});case"depth.func":return e(function(t){return kt[t]},function(t,e,r){return e.def(t.constants.compareFuncs,"[",r,"]")});case"depth.range":return e(function(t){return t},function(t,e,r){return[e.def("+",r,"[0]"),e=e.def("+",r,"[1]")]});case"blend.func":return e(function(t){return[wt["srcRGB"in t?t.srcRGB:t.src],wt["dstRGB"in t?t.dstRGB:t.dst],wt["srcAlpha"in t?t.srcAlpha:t.src],wt["dstAlpha"in t?t.dstAlpha:t.dst]]},function(t,e,r){function n(t,n){return e.def('"',t,n,'" in ',r,"?",r,".",t,n,":",r,".",t)}t=t.constants.blendFuncs;var i=n("src","RGB"),a=n("dst","RGB"),o=(i=e.def(t,"[",i,"]"),e.def(t,"[",n("src","Alpha"),"]"));return[i,a=e.def(t,"[",a,"]"),o,t=e.def(t,"[",n("dst","Alpha"),"]")]});case"blend.equation":return e(function(t){return"string"==typeof t?[$[t],$[t]]:"object"==typeof t?[$[t.rgb],$[t.alpha]]:void 0},function(t,e,r){var n=t.constants.blendEquations,i=e.def(),a=e.def();return(t=t.cond("typeof ",r,'==="string"')).then(i,"=",a,"=",n,"[",r,"];"),t.else(i,"=",n,"[",r,".rgb];",a,"=",n,"[",r,".alpha];"),e(t),[i,a]});case"blend.color":return e(function(t){return a(4,function(e){return+t[e]})},function(t,e,r){return a(4,function(t){return e.def("+",r,"[",t,"]")})});case"stencil.mask":return e(function(t){return 0|t},function(t,e,r){return e.def(r,"|0")});case"stencil.func":return e(function(t){return[kt[t.cmp||"keep"],t.ref||0,"mask"in t?t.mask:-1]},function(t,e,r){return[t=e.def('"cmp" in ',r,"?",t.constants.compareFuncs,"[",r,".cmp]",":",7680),e.def(r,".ref|0"),e=e.def('"mask" in ',r,"?",r,".mask|0:-1")]});case"stencil.opFront":case"stencil.opBack":return e(function(e){return["stencil.opBack"===t?1029:1028,Mt[e.fail||"keep"],Mt[e.zfail||"keep"],Mt[e.zpass||"keep"]]},function(e,r,n){function i(t){return r.def('"',t,'" in ',n,"?",a,"[",n,".",t,"]:",7680)}var a=e.constants.stencilOps;return["stencil.opBack"===t?1029:1028,i("fail"),i("zfail"),i("zpass")]});case"polygonOffset.offset":return e(function(t){return[0|t.factor,0|t.units]},function(t,e,r){return[e.def(r,".factor|0"),e=e.def(r,".units|0")]});case"cull.face":return e(function(t){var e=0;return"front"===t?e=1028:"back"===t&&(e=1029),e},function(t,e,r){return e.def(r,'==="front"?',1028,":",1029)});case"lineWidth":return e(function(t){return t},function(t,e,r){return r});case"frontFace":return e(function(t){return At[t]},function(t,e,r){return e.def(r+'==="cw"?2304:2305')});case"colorMask":return e(function(t){return t.map(function(t){return!!t})},function(t,e,r){return a(4,function(t){return"!!"+r+"["+t+"]"})});case"sample.coverage":return e(function(t){return["value"in t?t.value:1,!!t.invert]},function(t,e,r){return[e.def('"value" in ',r,"?+",r,".value:1"),e=e.def("!!",r,".invert")]})}}),i}(t),u=w(t),f=s.viewport;return f&&(c.viewport=f),(s=s[f=m("scissor.box")])&&(c[f]=s),(o={framebuffer:o,draw:l,shader:u,state:c,dirty:s=0>1)",s],");")}function e(){r(l,".drawArraysInstancedANGLE(",[d,g,v,s],");")}p?y?t():(r("if(",p,"){"),t(),r("}else{"),e(),r("}")):e()}function o(){function t(){r(u+".drawElements("+[d,v,m,g+"<<(("+m+"-5121)>>1)"]+");")}function e(){r(u+".drawArrays("+[d,g,v]+");")}p?y?t():(r("if(",p,"){"),t(),r("}else{"),e(),r("}")):e()}var s,l,c=t.shared,u=c.gl,f=c.draw,h=n.draw,p=function(){var i=h.elements,a=e;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(t,a)):i=a.def(f,".","elements"),i&&a("if("+i+")"+u+".bindBuffer(34963,"+i+".buffer.buffer);"),i}(),d=i("primitive"),g=i("offset"),v=function(){var i=h.count,a=e;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(t,a)):i=a.def(f,".","count"),i}();if("number"==typeof v){if(0===v)return}else r("if(",v,"){"),r.exit("}");K&&(s=i("instances"),l=t.instancing);var m=p+".type",y=h.elements&&D(h.elements);K&&("number"!=typeof s||0<=s)?"string"==typeof s?(r("if(",s,">0){"),a(),r("}else if(",s,"<0){"),o(),r("}")):a():o()}function q(t,e,r,n,i){return i=(e=b()).proc("body",i),K&&(e.instancing=i.def(e.shared.extensions,".angle_instanced_arrays")),t(e,i,r,n),e.compile().body}function H(t,e,r,n){L(t,e),N(t,e,r,n.attributes,function(){return!0}),j(t,e,r,n.uniforms,function(){return!0}),V(t,e,e,r)}function G(t,e,r,n){function i(){return!0}t.batchId="a1",L(t,e),N(t,e,r,n.attributes,i),j(t,e,r,n.uniforms,i),V(t,e,e,r)}function W(t,e,r,n){function i(t){return t.contextDep&&o||t.propDep}function a(t){return!i(t)}L(t,e);var o=r.contextDep,s=e.def(),l=e.def();t.shared.props=l,t.batchId=s;var c=t.scope(),u=t.scope();e(c.entry,"for(",s,"=0;",s,"<","a1",";++",s,"){",l,"=","a0","[",s,"];",u,"}",c.exit),r.needsContext&&T(t,u,r.context),r.needsFramebuffer&&S(t,u,r.framebuffer),C(t,u,r.state,i),r.profile&&i(r.profile)&&F(t,u,r,!1,!0),n?(N(t,c,r,n.attributes,a),N(t,u,r,n.attributes,i),j(t,c,r,n.uniforms,a),j(t,u,r,n.uniforms,i),V(t,c,u,r)):(e=t.global.def("{}"),n=r.shader.progVar.append(t,u),l=u.def(n,".id"),c=u.def(e,"[",l,"]"),u(t.shared.gl,".useProgram(",n,".program);","if(!",c,"){",c,"=",e,"[",l,"]=",t.link(function(e){return q(G,t,r,e,2)}),"(",n,");}",c,".call(this,a0[",s,"],",s,");"))}function Y(t,r){function n(e){var n=r.shader[e];n&&i.set(a.shader,"."+e,n.append(t,i))}var i=t.proc("scope",3);t.batchId="a2";var a=t.shared,o=a.current;T(t,i,r.context),r.framebuffer&&r.framebuffer.append(t,i),I(Object.keys(r.state)).forEach(function(e){var n=r.state[e].append(t,i);v(n)?n.forEach(function(r,n){i.set(t.next[e],"["+n+"]",r)}):i.set(a.next,"."+e,n)}),F(t,i,r,!0,!0),["elements","offset","count","instances","primitive"].forEach(function(e){var n=r.draw[e];n&&i.set(a.draw,"."+e,""+n.append(t,i))}),Object.keys(r.uniforms).forEach(function(n){i.set(a.uniforms,"["+e.id(n)+"]",r.uniforms[n].append(t,i))}),Object.keys(r.attributes).forEach(function(e){var n=r.attributes[e].append(t,i),a=t.scopeAttrib(e);Object.keys(new Z).forEach(function(t){i.set(a,"."+t,n[t])})}),n("vert"),n("frag"),0=--this.refCount&&o(this)},i.profile&&(n.getTotalRenderbufferSize=function(){var t=0;return Object.keys(u).forEach(function(e){t+=u[e].stats.size}),t}),{create:function(e,r){function o(e,r){var n=0,a=0,u=32854;if("object"==typeof e&&e?("shape"in e?(n=0|(a=e.shape)[0],a=0|a[1]):("radius"in e&&(n=a=0|e.radius),"width"in e&&(n=0|e.width),"height"in e&&(a=0|e.height)),"format"in e&&(u=s[e.format])):"number"==typeof e?(n=0|e,a="number"==typeof r?0|r:n):e||(n=a=1),n!==c.width||a!==c.height||u!==c.format)return o.width=c.width=n,o.height=c.height=a,c.format=u,t.bindRenderbuffer(36161,c.renderbuffer),t.renderbufferStorage(36161,u,n,a),i.profile&&(c.stats.size=vt[c.format]*c.width*c.height),o.format=l[c.format],o}var c=new a(t.createRenderbuffer());return u[c.id]=c,n.renderbufferCount++,o(e,r),o.resize=function(e,r){var n=0|e,a=0|r||n;return n===c.width&&a===c.height?o:(o.width=c.width=n,o.height=c.height=a,t.bindRenderbuffer(36161,c.renderbuffer),t.renderbufferStorage(36161,c.format,n,a),i.profile&&(c.stats.size=vt[c.format]*c.width*c.height),o)},o._reglType="renderbuffer",o._renderbuffer=c,i.profile&&(o.stats=c.stats),o.destroy=function(){c.decRef()},o},clear:function(){X(u).forEach(o)},restore:function(){X(u).forEach(function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,e.renderbuffer),t.renderbufferStorage(36161,e.format,e.width,e.height)}),t.bindRenderbuffer(36161,null)}}},yt=[];yt[6408]=4,yt[6407]=3;var xt=[];xt[5121]=1,xt[5126]=4,xt[36193]=2;var bt=["x","y","z","w"],_t="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),wt={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},kt={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Mt={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},At={cw:2304,ccw:2305},Tt=new P(!1,!1,!1,function(){});return function(t){function e(){if(0===Z.length)w&&w.update(),Q=null;else{Q=q.next(e),f();for(var t=Z.length-1;0<=t;--t){var r=Z[t];r&&r(z,null,0)}v.flush(),w&&w.update()}}function r(){!Q&&0=Z.length&&n()}}}}function u(){var t=Y.viewport,e=Y.scissor_box;t[0]=t[1]=e[0]=e[1]=0,z.viewportWidth=z.framebufferWidth=z.drawingBufferWidth=t[2]=e[2]=v.drawingBufferWidth,z.viewportHeight=z.framebufferHeight=z.drawingBufferHeight=t[3]=e[3]=v.drawingBufferHeight}function f(){z.tick+=1,z.time=g(),u(),G.procs.poll()}function h(){u(),G.procs.refresh(),w&&w.update()}function g(){return(H()-k)/1e3}if(!(t=i(t)))return null;var v=t.gl,m=v.getContextAttributes();v.isContextLost();var y=function(t,e){function r(e){var r;e=e.toLowerCase();try{r=n[e]=t.getExtension(e)}catch(t){}return!!r}for(var n={},i=0;ie;++e)tt(j({framebuffer:t.framebuffer.faces[e]},t),l);else tt(t,l);else l(0,t)},prop:U.define.bind(null,1),context:U.define.bind(null,2),this:U.define.bind(null,3),draw:s({}),buffer:function(t){return I.create(t,34962,!1,!1)},elements:function(t){return P.create(t,!1)},texture:R.create2D,cube:R.createCube,renderbuffer:B.create,framebuffer:V.create,framebufferCube:V.createCube,attributes:m,frame:c,on:function(t,e){var r;switch(t){case"frame":return c(e);case"lost":r=$;break;case"restore":r=J;break;case"destroy":r=K}return r.push(e),{cancel:function(){for(var t=0;t=r)return i.substr(0,r);for(;r>i.length&&e>1;)1&e&&(i+=t),e>>=1,t+=t;return i=(i+=t).substr(0,r)}},{}],480:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],481:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i],s=(r=a+o)-a,l=o-s;l&&(t[--n]=r,r=l)}for(var c=0,i=n;i>1;return["sum(",t(e.slice(0,r)),",",t(e.slice(r)),")"].join("")}(e);var n}function u(t){return new Function("sum","scale","prod","compress",["function robustDeterminant",t,"(m){return compress(",c(function(t){for(var e=new Array(t),r=0;r>1;return["sum(",c(t.slice(0,e)),",",c(t.slice(e)),")"].join("")}function u(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return u(e,t)}function f(t){if(2===t.length)return[["diff(",u(t[0][0],t[1][1]),",",u(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r0&&r.push(","),r.push("[");for(var o=0;o0&&r.push(","),o===i?r.push("+b[",a,"]"):r.push("+A[",a,"][",o,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var s=new Function("det",r.join(""));return s(t<6?n[t]:n)}var o=[function(){return[0]},function(t,e){return[[e[0]],[t[0][0]]]}];!function(){for(;o.length>1;return["sum(",c(t.slice(0,e)),",",c(t.slice(e)),")"].join("")}function u(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(a<=0)return o;n=i+a}else{if(!(i<0))return o;if(a>=0)return o;n=-(i+a)}var s=3.3306690738754716e-16*n;return o>=s||o<=-s?o:h(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*c,g=o*l,v=o*s,m=i*c,y=i*l,x=a*s,b=u*(d-g)+f*(v-m)+h*(y-x),_=7.771561172376103e-16*((Math.abs(d)+Math.abs(g))*Math.abs(u)+(Math.abs(v)+Math.abs(m))*Math.abs(f)+(Math.abs(y)+Math.abs(x))*Math.abs(h));return b>_||-b>_?b:p(t,e,r,n)}];!function(){for(;d.length<=s;)d.push(f(d.length));for(var t=[],r=["slow"],n=0;n<=s;++n)t.push("a"+n),r.push("o"+n);var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(n=2;n<=s;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i0&&o>0||a<0&&o<0)return!1;var s=n(r,t,e),l=n(i,t,e);if(s>0&&l>0||s<0&&l<0)return!1;if(0===a&&0===o&&0===s&&0===l)return function(t,e,r,n){for(var i=0;i<2;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],f=Math.min(c,u),h=Math.max(c,u);if(h=n?(i=f,(l+=1)=n?(i=f,(l+=1)0?1:0}},{}],493:[function(t,e,r){"use strict";e.exports=function(t){return i(n(t))};var n=t("boundary-cells"),i=t("reduce-simplicial-complex")},{"boundary-cells":83,"reduce-simplicial-complex":472}],494:[function(t,e,r){"use strict";e.exports=function(t,e,r,s){r=r||0,"undefined"==typeof s&&(s=function(t){for(var e=t.length,r=0,n=0;n>1,v=E[2*m+1];","if(v===b){return m}","if(b0&&l.push(","),l.push("[");for(var n=0;n0&&l.push(","),l.push("B(C,E,c[",i[0],"],c[",i[1],"])")}l.push("]")}l.push(");")}}for(var a=t+1;a>1;--a){a>1,s=a(t[o],e);s<=0?(0===s&&(i=o),r=o+1):s>0&&(n=o-1)}return i}function u(t,e){for(var r=new Array(t.length),i=0,o=r.length;i=t.length||0!==a(t[v],s)););}return r}function f(t,e){if(e<0)return[];for(var r=[],i=(1<>>u&1&&c.push(i[u]);e.push(c)}return s(e)},r.skeleton=f,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function x(t){for(var e=m(t);;){var r=e,n=2*t+1,i=2*(t+1),a=t;if(n0;){var r=y(t);if(r>=0){var n=m(r);if(e0){var t=M[0];return v(0,S-1),S-=1,x(0),t}return-1}function w(t,e){var r=M[t];return c[r]===e?t:(c[r]=-1/0,b(t),_(),c[r]=e,b((S+=1)-1))}function k(t){if(!u[t]){u[t]=!0;var e=s[t],r=l[t];s[r]>=0&&(s[r]=e),l[e]>=0&&(l[e]=r),A[e]>=0&&w(A[e],g(e)),A[r]>=0&&w(A[r],g(r))}}for(var M=[],A=new Array(a),f=0;f>1;f>=0;--f)x(f);for(;;){var E=_();if(E<0||c[E]>r)break;k(E)}for(var C=[],f=0;f=0&&r>=0&&e!==r){var n=A[e],i=A[r];n!==i&&z.push([n,i])}}),i.unique(i.normalize(z)),{positions:C,edges:z}};var n=t("robust-orientation"),i=t("simplicial-complex")},{"robust-orientation":486,"simplicial-complex":498}],501:[function(t,e,r){"use strict";e.exports=function(t,e){var r,a,o,s;if(e[0][0]e[1][0]))return i(e,t);r=e[1],a=e[0]}if(t[0][0]t[1][0]))return-i(t,e);o=t[1],s=t[0]}var l=n(r,a,s),c=n(r,a,o);if(l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=n(s,o,a),c=n(s,o,r),l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return a[0]-s[0]};var n=t("robust-orientation");function i(t,e){var r,i,a,o;if(e[0][0]e[1][0])){var s=Math.min(t[0][1],t[1][1]),l=Math.max(t[0][1],t[1][1]),c=Math.min(e[0][1],e[1][1]),u=Math.max(e[0][1],e[1][1]);return lu?s-u:l-u}r=e[1],i=e[0]}t[0][1]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=c(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=c(t.right,e))return l;t=t.left}}return r}function u(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function f(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}s.prototype.castUp=function(t){var e=n.le(this.coordinates,t[0]);if(e<0)return-1;this.slabs[e];var r=c(this.slabs[e],t),i=-1;if(r&&(i=r.value),this.coordinates[e]===t[0]){var s=null;if(r&&(s=r.key),e>0){var u=c(this.slabs[e-1],t);u&&(s?o(u.key,s)>0&&(s=u.key,i=u.value):(i=u.value,s=u.key))}var f=this.horizontal[e];if(f.length>0){var h=n.ge(f,t[1],l);if(h=f.length)return i;p=f[h]}}if(p.start)if(s){var d=a(s[0],s[1],[t[0],p.y]);s[0][0]>s[1][0]&&(d=-d),d>0&&(i=p.index)}else i=p.index;else p.y!==t[1]&&(i=p.index)}}}return i}},{"./lib/order-segments":501,"binary-search-bounds":79,"functional-red-black-tree":219,"robust-orientation":486}],503:[function(t,e,r){"use strict";var n=t("robust-dot-product"),i=t("robust-sum");function a(t,e){var r=i(n(t,e),[e[e.length-1]]);return r[r.length-1]}function o(t,e,r,n){var i=-e/(n-e);i<0?i=0:i>1&&(i=1);for(var a=1-i,o=t.length,s=new Array(o),l=0;l0||i>0&&u<0){var f=o(s,u,l,i);r.push(f),n.push(f.slice())}u<0?n.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),n.push(l.slice())),i=u}return{positive:r,negative:n}},e.exports.positive=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c>=0&&r.push(s.slice()),n=c}return r},e.exports.negative=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c<=0&&r.push(s.slice()),n=c}return r}},{"robust-dot-product":483,"robust-sum":491}],504:[function(t,e,r){!function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function e(r){return function(r,n){var i,a,o,s,l,c,u,f,h,p=1,d=r.length,g="";for(a=0;a=0),s[8]){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,s[6]?parseInt(s[6]):0);break;case"e":i=s[7]?parseFloat(i).toExponential(s[7]):parseFloat(i).toExponential();break;case"f":i=s[7]?parseFloat(i).toFixed(s[7]):parseFloat(i);break;case"g":i=s[7]?String(Number(i.toPrecision(s[7]))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=s[7]?i.substring(0,s[7]):i;break;case"t":i=String(!!i),i=s[7]?i.substring(0,s[7]):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=s[7]?i.substring(0,s[7]):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=s[7]?i.substring(0,s[7]):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}t.json.test(s[8])?g+=i:(!t.number.test(s[8])||f&&!s[3]?h="":(h=f?"+":"-",i=i.toString().replace(t.sign,"")),c=s[4]?"0"===s[4]?"0":s[4].charAt(1):" ",u=s[6]-(h+i).length,l=s[6]&&u>0?c.repeat(u):"",g+=s[5]?h+i+l:"0"===c?h+l+i:l+h+i)}return g}(function(e){if(i[e])return i[e];var r,n=e,a=[],o=0;for(;n;){if(null!==(r=t.text.exec(n)))a.push(r[0]);else if(null!==(r=t.modulo.exec(n)))a.push("%");else{if(null===(r=t.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){o|=1;var s=[],l=r[2],c=[];if(null===(c=t.key.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(c[1]);""!==(l=l.substring(c[0].length));)if(null!==(c=t.key_access.exec(l)))s.push(c[1]);else{if(null===(c=t.index_access.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(c[1])}r[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");a.push(r)}n=n.substring(r[0].length)}return i[e]=a}(r),arguments)}function n(t,r){return e.apply(null,[t].concat(r||[]))}var i=Object.create(null);"undefined"!=typeof r&&(r.sprintf=e,r.vsprintf=n),"undefined"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}()},{}],505:[function(t,e,r){"use strict";var n=t("parenthesis");e.exports=function(t,e,r){if(null==t)throw Error("First argument should be a string");if(null==e)throw Error("Separator should be a string or a RegExp");r?("string"==typeof r||Array.isArray(r))&&(r={ignore:r}):r={},null==r.escape&&(r.escape=!0),null==r.ignore?r.ignore=["[]","()","{}","<>",'""',"''","``","\u201c\u201d","\xab\xbb"]:("string"==typeof r.ignore&&(r.ignore=[r.ignore]),r.ignore=r.ignore.map(function(t){return 1===t.length&&(t+=t),t}));var i=n.parse(t,{flat:!0,brackets:r.ignore}),a=i[0].split(e);if(r.escape){for(var o=[],s=0;s0;){e=c[c.length-1];var p=t[e];if(a[e]=0&&s[e].push(o[g])}a[e]=d}else{if(n[e]===r[e]){for(var v=[],m=[],y=0,d=l.length-1;d>=0;--d){var x=l[d];if(i[x]=!1,v.push(x),m.push(s[x]),y+=s[x].length,o[x]=f.length,x===e){l.length=d;break}}f.push(v);for(var b=new Array(y),d=0;d c)|0 },"),"generic"===e&&a.push("getters:[0],");for(var s=[],l=[],c=0;c>>7){");for(var c=0;c<1<<(1<128&&c%128==0){f.length>0&&h.push("}}");var p="vExtra"+f.length;a.push("case ",c>>>7,":",p,"(m&0x7f,",l.join(),");break;"),h=["function ",p,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&c,":");for(var d=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,x=0;xx)&&!(c&1<<_)!=!(c&1<0&&(A="+"+v[b]+"*c");var T=d[b].length/y*.5,S=.5+m[b]/y*.5;M.push("d"+b+"-"+S+"-"+T+"*("+d[b].join("+")+A+")/("+g[b].join("+")+")")}h.push("a.push([",M.join(),"]);","break;")}a.push("}},"),f.length>0&&h.push("}}");for(var E=[],c=0;c<1<1&&(a=1),a<-1&&(a=-1),i*Math.acos(a)};r.default=function(t){var e=t.px,r=t.py,l=t.cx,c=t.cy,u=t.rx,f=t.ry,h=t.xAxisRotation,p=void 0===h?0:h,d=t.largeArcFlag,g=void 0===d?0:d,v=t.sweepFlag,m=void 0===v?0:v,y=[];if(0===u||0===f)return[];var x=Math.sin(p*i/360),b=Math.cos(p*i/360),_=b*(e-l)/2+x*(r-c)/2,w=-x*(e-l)/2+b*(r-c)/2;if(0===_&&0===w)return[];u=Math.abs(u),f=Math.abs(f);var k=Math.pow(_,2)/Math.pow(u,2)+Math.pow(w,2)/Math.pow(f,2);k>1&&(u*=Math.sqrt(k),f*=Math.sqrt(k));var M=function(t,e,r,n,a,o,l,c,u,f,h,p){var d=Math.pow(a,2),g=Math.pow(o,2),v=Math.pow(h,2),m=Math.pow(p,2),y=d*g-d*m-g*v;y<0&&(y=0),y/=d*m+g*v;var x=(y=Math.sqrt(y)*(l===c?-1:1))*a/o*p,b=y*-o/a*h,_=f*x-u*b+(t+r)/2,w=u*x+f*b+(e+n)/2,k=(h-x)/a,M=(p-b)/o,A=(-h-x)/a,T=(-p-b)/o,S=s(1,0,k,M),E=s(k,M,A,T);return 0===c&&E>0&&(E-=i),1===c&&E<0&&(E+=i),[_,w,S,E]}(e,r,l,c,u,f,g,m,x,b,_,w),A=n(M,4),T=A[0],S=A[1],E=A[2],C=A[3],L=Math.abs(C)/(i/4);Math.abs(1-L)<1e-7&&(L=1);var z=Math.max(Math.ceil(L),1);C/=z;for(var O=0;Oe[2]&&(e[2]=c[u+0]),c[u+1]>e[3]&&(e[3]=c[u+1]);return e}},{"abs-svg-path":48,assert:56,"is-svg-path":407,"normalize-svg-path":511,"parse-svg-path":443}],511:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=[],o=0,s=0,l=0,c=0,u=null,f=null,h=0,p=0,d=0,g=t.length;d4?(o=v[v.length-4],s=v[v.length-3]):(o=h,s=p),r.push(v)}return r};var n=t("svg-arc-to-cubic-bezier");function i(t,e,r,n){return["C",t,e,r,n,r,n]}function a(t,e,r,n,i,a){return["C",t/3+2/3*r,e/3+2/3*n,i/3+2/3*r,a/3+2/3*n,i,a]}},{"svg-arc-to-cubic-bezier":509}],512:[function(t,e,r){"use strict";var n=t("svg-path-bounds"),i=t("parse-svg-path"),a=t("draw-svg-path"),o=t("is-svg-path"),s=t("bitmap-sdf"),l=document.createElement("canvas"),c=l.getContext("2d");e.exports=function(t,e){if(!o(t))throw Error("Argument should be valid svg path string");e||(e={});var r,u;e.shape?(r=e.shape[0],u=e.shape[1]):(r=l.width=e.w||e.width||200,u=l.height=e.h||e.height||200);var f=Math.min(r,u),h=e.stroke||0,p=e.viewbox||e.viewBox||n(t),d=[r/(p[2]-p[0]),u/(p[3]-p[1])],g=Math.min(d[0]||0,d[1]||0)/2;c.fillStyle="black",c.fillRect(0,0,r,u),c.fillStyle="white",h&&("number"!=typeof h&&(h=1),c.strokeStyle=h>0?"white":"black",c.lineWidth=Math.abs(h));if(c.translate(.5*r,.5*u),c.scale(g,g),function(){var t=document.createElement("canvas").getContext("2d");t.canvas.width=t.canvas.height=1;var e=new Path2D("M0,0h1v1h-1v-1Z");t.fillStyle="black",t.fill(e);var r=t.getImageData(0,0,1,1);return r&&r.data&&255===r.data[3]}()){var v=new Path2D(t);c.fill(v),h&&c.stroke(v)}else{var m=i(t);a(c,m),c.fill(),h&&c.stroke()}return c.setTransform(1,0,0,1,0,0),s(c,{cutoff:null!=e.cutoff?e.cutoff:.5,radius:null!=e.radius?e.radius:.5*f})}},{"bitmap-sdf":81,"draw-svg-path":153,"is-svg-path":407,"parse-svg-path":443,"svg-path-bounds":510}],513:[function(t,e,r){(function(r){"use strict";e.exports=function t(e,r,i){var i=i||{};var o=a[e];o||(o=a[e]={" ":{data:new Float32Array(0),shape:.2}});var s=o[r];if(!s)if(r.length<=1||!/\d/.test(r))s=o[r]=function(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;o0&&(f+=.02);for(var p=new Float32Array(u),d=0,g=-.5*f,h=0;h1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=L(t,360),e=L(e,100),r=L(r,100),0===e)n=i=a=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;n=o(l,s,t+1/3),i=o(l,s,t),a=o(l,s,t-1/3)}return{r:255*n,g:255*i,b:255*a}}(e.h,l,u),f=!0,h="hsl"),e.hasOwnProperty("a")&&(a=e.a));var p,d,g;return a=C(a),{ok:f,format:e.format||h,r:o(255,s(i.r,0)),g:o(255,s(i.g,0)),b:o(255,s(i.b,0)),a:a}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=a(100*this._a)/100,this._format=l.format||u.format,this._gradientType=l.gradientType,this._r<1&&(this._r=a(this._r)),this._g<1&&(this._g=a(this._g)),this._b<1&&(this._b=a(this._b)),this._ok=u.ok,this._tc_id=i++}function u(t,e,r){t=L(t,255),e=L(e,255),r=L(r,255);var n,i,a=s(t,e,r),l=o(t,e,r),c=(a+l)/2;if(a==l)n=i=0;else{var u=a-l;switch(i=c>.5?u/(2-a-l):u/(a+l),a){case t:n=(e-r)/u+(e>1)+720)%360;--e;)n.h=(n.h+i)%360,a.push(c(n));return a}function T(t,e){e=e||6;for(var r=c(t).toHsv(),n=r.h,i=r.s,a=r.v,o=[],s=1/e;e--;)o.push(c({h:n,s:i,v:a})),a=(a+s)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,i=this.toRgb();return e=i.r/255,r=i.g/255,n=i.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=C(t),this._roundA=a(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return h(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,i){var o=[I(a(t).toString(16)),I(a(e).toString(16)),I(a(r).toString(16)),I(D(n))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:a(this._r),g:a(this._g),b:a(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+a(this._r)+", "+a(this._g)+", "+a(this._b)+")":"rgba("+a(this._r)+", "+a(this._g)+", "+a(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:a(100*L(this._r,255))+"%",g:a(100*L(this._g,255))+"%",b:a(100*L(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+a(100*L(this._r,255))+"%, "+a(100*L(this._g,255))+"%, "+a(100*L(this._b,255))+"%)":"rgba("+a(100*L(this._r,255))+"%, "+a(100*L(this._g,255))+"%, "+a(100*L(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(E[h(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var i=c(t);r="#"+p(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(m,arguments)},brighten:function(){return this._applyModification(y,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(A,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(T,arguments)},splitcomplement:function(){return this._applyCombination(M,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:P(t[n]));t=r}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:l(),g:l(),b:l()})},c.mix=function(t,e,r){r=0===r?0:r||50;var n=c(t).toRgb(),i=c(e).toRgb(),a=r/100;return c({r:(i.r-n.r)*a+n.r,g:(i.g-n.g)*a+n.g,b:(i.b-n.b)*a+n.b,a:(i.a-n.a)*a+n.a})},c.readability=function(e,r){var n=c(e),i=c(r);return(t.max(n.getLuminance(),i.getLuminance())+.05)/(t.min(n.getLuminance(),i.getLuminance())+.05)},c.isReadable=function(t,e,r){var n,i,a=c.readability(t,e);switch(i=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},c.mostReadable=function(t,e,r){var n,i,a,o,s=null,l=0;i=(r=r||{}).includeFallbackColors,a=r.level,o=r.size;for(var u=0;ul&&(l=n,s=c(e[u]));return c.isReadable(t,s,{level:a,size:o})||!i?s:(r.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],r))};var S=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},E=c.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(S);function C(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function L(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,s(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function z(t){return o(1,s(0,t))}function O(t){return parseInt(t,16)}function I(t){return 1==t.length?"0"+t:""+t}function P(t){return t<=1&&(t=100*t+"%"),t}function D(e){return t.round(255*parseFloat(e)).toString(16)}function R(t){return O(t)/255}var B,F,N,j=(F="[\\s|\\(]+("+(B="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+B+")[,|\\s]+("+B+")\\s*\\)?",N="[\\s|\\(]+("+B+")[,|\\s]+("+B+")[,|\\s]+("+B+")[,|\\s]+("+B+")\\s*\\)?",{CSS_UNIT:new RegExp(B),rgb:new RegExp("rgb"+F),rgba:new RegExp("rgba"+N),hsl:new RegExp("hsl"+F),hsla:new RegExp("hsla"+N),hsv:new RegExp("hsv"+F),hsva:new RegExp("hsva"+N),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function V(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],515:[function(t,e,r){"use strict";function n(t){if(t instanceof Float32Array)return t;if("number"==typeof t)return new Float32Array([t])[0];var e=new Float32Array(t);return e.set(t),e}e.exports=n,e.exports.float32=e.exports.float=n,e.exports.fract32=e.exports.fract=function(t){if("number"==typeof t)return n(t-n(t));for(var e=n(t),r=0,i=e.length;rf&&(f=l[0]),l[1]h&&(h=l[1])}function i(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(i);break;case"Point":n(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(n)}}if(!e){var a,o,s=r(t),l=new Array(2),c=1/0,u=c,f=-c,h=-c;for(o in t.arcs.forEach(function(t){for(var e=-1,r=t.length;++ef&&(f=l[0]),l[1]h&&(h=l[1])}),t.objects)i(t.objects[o]);e=t.bbox=[c,u,f,h]}return e},i=function(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r};function a(t,e){var r=e.id,n=e.bbox,i=null==e.properties?{}:e.properties,a=o(t,e);return null==r&&null==n?{type:"Feature",properties:i,geometry:a}:null==n?{type:"Feature",id:r,properties:i,geometry:a}:{type:"Feature",id:r,bbox:n,properties:i,geometry:a}}function o(t,e){var n=r(t),a=t.arcs;function o(t,e){e.length&&e.pop();for(var r=a[t<0?~t:t],o=0,s=r.length;o1)n=function(t,e,r){var n,i=[],a=[];function o(t){var e=t<0?~t:t;(a[e]||(a[e]=[])).push({i:t,g:n})}function s(t){t.forEach(o)}function l(t){t.forEach(s)}return function t(e){switch(n=e,e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"LineString":s(e.arcs);break;case"MultiLineString":case"Polygon":l(e.arcs);break;case"MultiPolygon":e.arcs.forEach(l)}}(e),a.forEach(null==r?function(t){i.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&i.push(t[0].i)}),i}(0,e,r);else for(i=0,n=new Array(a=t.arcs.length);i1)for(var a,o,c=1,u=l(i[0]);cu&&(o=i[0],i[0]=i[c],i[c]=o,u=a);return i})}}var u=function(t,e){for(var r=0,n=t.length;r>>1;t[i]=2))throw new Error("n must be \u22652");if(t.transform)throw new Error("already quantized");var r,i=n(t),a=i[0],o=(i[2]-a)/(e-1)||1,s=i[1],l=(i[3]-s)/(e-1)||1;function c(t){t[0]=Math.round((t[0]-a)/o),t[1]=Math.round((t[1]-s)/l)}function u(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(u);break;case"Point":c(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(c)}}for(r in t.arcs.forEach(function(t){for(var e,r,n,i=1,c=1,u=t.length,f=t[0],h=f[0]=Math.round((f[0]-a)/o),p=f[1]=Math.round((f[1]-s)/l);iMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,l=0;l<3;++l)a+=t[l]*t[l],o+=i[l]*t[l];for(l=0;l<3;++l)i[l]-=o/a*t[l];return s(i,i),i}function h(t,e,r,i,a,o,s,l){this.center=n(r),this.up=n(i),this.right=n(a),this.radius=n([o]),this.angle=n([s,l]),this.angle.bounds=[[-1/0,-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;c<16;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}var p=h.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,n=0,i=0,a=0;a<3;++a)i+=e[a]*r[a],n+=e[a]*e[a];var l=Math.sqrt(n),u=0;for(a=0;a<3;++a)r[a]-=e[a]*i/n,u+=r[a]*r[a],e[a]/=l;var f=Math.sqrt(u);for(a=0;a<3;++a)r[a]/=f;var h=this.computedToward;o(h,e,r),s(h,h);var p=Math.exp(this.computedRadius[0]),d=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(d),m=Math.sin(d),y=Math.cos(g),x=Math.sin(g),b=this.computedCenter,_=v*y,w=m*y,k=x,M=-v*x,A=-m*x,T=y,S=this.computedEye,E=this.computedMatrix;for(a=0;a<3;++a){var C=_*r[a]+w*h[a]+k*e[a];E[4*a+1]=M*r[a]+A*h[a]+T*e[a],E[4*a+2]=C,E[4*a+3]=0}var L=E[1],z=E[5],O=E[9],I=E[2],P=E[6],D=E[10],R=z*D-O*P,B=O*I-L*D,F=L*P-z*I,N=c(R,B,F);R/=N,B/=N,F/=N,E[0]=R,E[4]=B,E[8]=F;for(a=0;a<3;++a)S[a]=b[a]+E[2+4*a]*p;for(a=0;a<3;++a){u=0;for(var j=0;j<3;++j)u+=E[a+4*j]*S[j];E[12+a]=-u}E[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r};var d=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;d[0]=i[2],d[1]=i[6],d[2]=i[10];for(var o=this.computedUp,s=this.computedRight,l=this.computedToward,c=0;c<3;++c)i[4*c]=o[c],i[4*c+1]=s[c],i[4*c+2]=l[c];a(i,i,n,d);for(c=0;c<3;++c)o[c]=i[4*c],s[c]=i[4*c+1];this.up.set(t,o[0],o[1],o[2]),this.right.set(t,s[0],s[1],s[2])}},p.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=(Math.exp(this.computedRadius[0]),i[1]),o=i[5],s=i[9],l=c(a,o,s);a/=l,o/=l,s/=l;var u=i[0],f=i[4],h=i[8],p=u*a+f*o+h*s,d=c(u-=a*p,f-=o*p,h-=s*p),g=(u/=d)*e+a*r,v=(f/=d)*e+o*r,m=(h/=d)*e+s*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+n),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,n){var a=1;"number"==typeof r&&(a=0|r),(a<0||a>3)&&(a=1);var o=(a+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var s=e[a],l=e[a+4],f=e[a+8];if(n){var h=Math.abs(s),p=Math.abs(l),d=Math.abs(f),g=Math.max(h,p,d);h===g?(s=s<0?-1:1,l=f=0):d===g?(f=f<0?-1:1,s=l=0):(l=l<0?-1:1,s=f=0)}else{var v=c(s,l,f);s/=v,l/=v,f/=v}var m,y,x=e[o],b=e[o+4],_=e[o+8],w=x*s+b*l+_*f,k=c(x-=s*w,b-=l*w,_-=f*w),M=l*(_/=k)-f*(b/=k),A=f*(x/=k)-s*_,T=s*b-l*x,S=c(M,A,T);if(M/=S,A/=S,T/=S,this.center.jump(t,H,G,W),this.radius.idle(t),this.up.jump(t,s,l,f),this.right.jump(t,x,b,_),2===a){var E=e[1],C=e[5],L=e[9],z=E*x+C*b+L*_,O=E*M+C*A+L*T;m=R<0?-Math.PI/2:Math.PI/2,y=Math.atan2(O,z)}else{var I=e[2],P=e[6],D=e[10],R=I*s+P*l+D*f,B=I*x+P*b+D*_,F=I*M+P*A+D*T;m=Math.asin(u(R)),y=Math.atan2(F,B)}this.angle.jump(t,y,m),this.recalcMatrix(t);var N=e[2],j=e[6],V=e[10],U=this.computedMatrix;i(U,e);var q=U[15],H=U[12]/q,G=U[13]/q,W=U[14]/q,Y=Math.exp(this.computedRadius[0]);this.center.jump(t,H-N*Y,G-j*Y,W-V*Y)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter;var i=(n=n||this.computedUp)[0],a=n[1],o=n[2],s=c(i,a,o);if(!(s<1e-6)){i/=s,a/=s,o/=s;var l=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],p=c(l,f,h);if(!(p<1e-6)){l/=p,f/=p,h/=p;var d=this.computedRight,g=d[0],v=d[1],m=d[2],y=i*g+a*v+o*m,x=c(g-=y*i,v-=y*a,m-=y*o);if(!(x<.01&&(x=c(g=a*h-o*f,v=o*l-i*h,m=i*f-a*l))<1e-6)){g/=x,v/=x,m/=x,this.up.set(t,i,a,o),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(p));var b=a*m-o*v,_=o*g-i*m,w=i*v-a*g,k=c(b,_,w),M=i*l+a*f+o*h,A=g*l+v*f+m*h,T=(b/=k)*l+(_/=k)*f+(w/=k)*h,S=Math.asin(u(M)),E=Math.atan2(T,A),C=this.angle._state,L=C[C.length-1],z=C[C.length-2];L%=2*Math.PI;var O=Math.abs(L+2*Math.PI-E),I=Math.abs(L-E),P=Math.abs(L-2*Math.PI-E);O0?r.pop():new ArrayBuffer(t)}function h(t){return new Uint8Array(f(t),0,t)}function p(t){return new Uint16Array(f(2*t),0,t)}function d(t){return new Uint32Array(f(4*t),0,t)}function g(t){return new Int8Array(f(t),0,t)}function v(t){return new Int16Array(f(2*t),0,t)}function m(t){return new Int32Array(f(4*t),0,t)}function y(t){return new Float32Array(f(4*t),0,t)}function x(t){return new Float64Array(f(8*t),0,t)}function b(t){return o?new Uint8ClampedArray(f(t),0,t):h(t)}function _(t){return new DataView(f(t),0,t)}function w(t){t=i.nextPow2(t);var e=i.log2(t),r=c[e];return r.length>0?r.pop():new n(t)}r.free=function(t){if(n.isBuffer(t))c[i.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|i.log2(e);l[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=function(t){u(t.buffer)},r.freeArrayBuffer=u,r.freeBuffer=function(t){c[i.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return f(t);switch(e){case"uint8":return h(t);case"uint16":return p(t);case"uint32":return d(t);case"int8":return g(t);case"int16":return v(t);case"int32":return m(t);case"float":case"float32":return y(t);case"double":case"float64":return x(t);case"uint8_clamped":return b(t);case"buffer":return w(t);case"data":case"dataview":return _(t);default:return null}return null},r.mallocArrayBuffer=f,r.mallocUint8=h,r.mallocUint16=p,r.mallocUint32=d,r.mallocInt8=g,r.mallocInt16=v,r.mallocInt32=m,r.mallocFloat32=r.mallocFloat=y,r.mallocFloat64=r.mallocDouble=x,r.mallocUint8Clamped=b,r.mallocDataView=_,r.mallocBuffer=w,r.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,l[t].length=0,c[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":80,buffer:93,dup:155}],523:[function(t,e,r){"use strict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var o=3*n;t.height=0?e[a]:i})},has___:{value:x(function(e){var n=y(e);return n?r in n:t.indexOf(e)>=0})},set___:{value:x(function(n,i){var a,o=y(n);return o?o[r]=i:(a=t.indexOf(n))>=0?e[a]=i:(a=t.length,e[a]=i,t[a]=n),this})},delete___:{value:x(function(n){var i,a,o=y(n);return o?r in o&&delete o[r]:!((i=t.indexOf(n))<0||(a=t.length-1,t[i]=void 0,e[i]=e[a],t[i]=t[a],t.length=a,e.length=a,0))})}})};g.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},delete:{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof r?function(){function n(){this instanceof g||b();var e,n=new r,i=void 0,a=!1;return e=t?function(t,e){return n.set(t,e),n.has(t)||(i||(i=new g),i.set(t,e)),this}:function(t,e){if(a)try{n.set(t,e)}catch(r){i||(i=new g),i.set___(t,e)}else n.set(t,e);return this},Object.create(g.prototype,{get___:{value:x(function(t,e){return i?n.has(t)?n.get(t):i.get___(t,e):n.get(t,e)})},has___:{value:x(function(t){return n.has(t)||!!i&&i.has___(t)})},set___:{value:x(e)},delete___:{value:x(function(t){var e=!!n.delete(t);return i&&i.delete___(t)||e})},permitHostObjects___:{value:x(function(t){if(t!==v)throw new Error("bogus call to permitHostObjects___");a=!0})}})}t&&"undefined"!=typeof Proxy&&(Proxy=void 0),n.prototype=g.prototype,e.exports=n,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=g)}function v(t){t.permitHostObjects___&&t.permitHostObjects___(v)}function m(t){return!(t.substr(0,l.length)==l&&"___"===t.substr(t.length-3))}function y(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[c];if(e&&e.key===t)return e;if(s(t)){e={key:t};try{return o(t,c,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(t){return}}}function x(t){return t.prototype=null,Object.freeze(t)}function b(){p||"undefined"==typeof console||(p=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}}()},{}],530:[function(t,e,r){var n=t("./hidden-store.js");e.exports=function(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:n(e,t)}}},{"./hidden-store.js":531}],531:[function(t,e,r){e.exports=function(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}},{}],532:[function(t,e,r){var n=t("./create-store.js");e.exports=function(){var t=n();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){return t(e).value=r,this},has:function(e){return"value"in t(e)},delete:function(e){return delete t(e).value}}}},{"./create-store.js":530}],533:[function(t,e,r){var n=t("get-canvas-context");e.exports=function(t){return n("webgl",t)}},{"get-canvas-context":221}],534:[function(t,e,r){var n=t("../main"),i=t("object-assign"),a=n.instance();function o(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}o.prototype=new n.baseCalendar,i(o.prototype,{name:"Chinese",jdEpoch:1721425.5,hasYearZero:!1,minMonth:0,firstMonth:0,minDay:1,regionalOptions:{"":{name:"Chinese",epochs:["BEC","EC"],monthNumbers:function(t,e){if("string"==typeof t){var r=t.match(l);return r?r[0]:""}var n=this._validateYear(t),i=t.month(),a=""+this.toChineseMonth(n,i);return e&&a.length<2&&(a="0"+a),this.isIntercalaryMonth(n,i)&&(a+="i"),a},monthNames:function(t){if("string"==typeof t){var e=t.match(c);return e?e[0]:""}var r=this._validateYear(t),n=t.month(),i=["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"][this.toChineseMonth(r,n)-1];return this.isIntercalaryMonth(r,n)&&(i="\u95f0"+i),i},monthNamesShort:function(t){if("string"==typeof t){var e=t.match(u);return e?e[0]:""}var r=this._validateYear(t),n=t.month(),i=["\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u5341\u4e00","\u5341\u4e8c"][this.toChineseMonth(r,n)-1];return this.isIntercalaryMonth(r,n)&&(i="\u95f0"+i),i},parseMonth:function(t,e){t=this._validateYear(t);var r,n=parseInt(e);if(isNaN(n))"\u95f0"===e[0]&&(r=!0,e=e.substring(1)),"\u6708"===e[e.length-1]&&(e=e.substring(0,e.length-1)),n=1+["\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u5341\u4e00","\u5341\u4e8c"].indexOf(e);else{var i=e[e.length-1];r="i"===i||"I"===i}return this.toMonthIndex(t,n,r)},dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:1,isRTL:!1}},_validateYear:function(t,e){if(t.year&&(t=t.year()),"number"!=typeof t||t<1888||t>2111)throw e.replace(/\{0\}/,this.local.name);return t},toMonthIndex:function(t,e,r){var i=this.intercalaryMonth(t);if(r&&e!==i||e<1||e>12)throw n.local.invalidMonth.replace(/\{0\}/,this.local.name);return i?!r&&e<=i?e-1:e:e-1},toChineseMonth:function(t,e){t.year&&(e=(t=t.year()).month());var r=this.intercalaryMonth(t);if(e<0||e>(r?12:11))throw n.local.invalidMonth.replace(/\{0\}/,this.local.name);return r?e>13},isIntercalaryMonth:function(t,e){t.year&&(e=(t=t.year()).month());var r=this.intercalaryMonth(t);return!!r&&r===e},leapYear:function(t){return 0!==this.intercalaryMonth(t)},weekOfYear:function(t,e,r){var i,o=this._validateYear(t,n.local.invalidyear),s=h[o-h[0]],l=s>>9&4095,c=s>>5&15,u=31&s;(i=a.newDate(l,c,u)).add(4-(i.dayOfWeek()||7),"d");var f=this.toJD(t,e,r)-i.toJD();return 1+Math.floor(f/7)},monthsInYear:function(t){return this.leapYear(t)?13:12},daysInMonth:function(t,e){t.year&&(e=t.month(),t=t.year()),t=this._validateYear(t);var r=f[t-f[0]];if(e>(r>>13?12:11))throw n.local.invalidMonth.replace(/\{0\}/,this.local.name);return r&1<<12-e?30:29},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,s,r,n.local.invalidDate);t=this._validateYear(i.year()),e=i.month(),r=i.day();var o=this.isIntercalaryMonth(t,e),s=this.toChineseMonth(t,e),l=function(t,e,r,n,i){var a,o,s;if("object"==typeof t)o=t,a=e||{};else{var l="number"==typeof t&&t>=1888&&t<=2111;if(!l)throw new Error("Lunar year outside range 1888-2111");var c="number"==typeof e&&e>=1&&e<=12;if(!c)throw new Error("Lunar month outside range 1 - 12");var u,p="number"==typeof r&&r>=1&&r<=30;if(!p)throw new Error("Lunar day outside range 1 - 30");"object"==typeof n?(u=!1,a=n):(u=!!n,a=i||{}),o={year:t,month:e,day:r,isIntercalary:u}}s=o.day-1;var d,g=f[o.year-f[0]],v=g>>13;d=v?o.month>v?o.month:o.isIntercalary?o.month:o.month-1:o.month-1;for(var m=0;m>9&4095,(x>>5&15)-1,(31&x)+s);return a.year=b.getFullYear(),a.month=1+b.getMonth(),a.day=b.getDate(),a}(t,s,r,o);return a.toJD(l.year,l.month,l.day)},fromJD:function(t){var e=a.fromJD(t),r=function(t,e,r,n){var i,a;if("object"==typeof t)i=t,a=e||{};else{var o="number"==typeof t&&t>=1888&&t<=2111;if(!o)throw new Error("Solar year outside range 1888-2111");var s="number"==typeof e&&e>=1&&e<=12;if(!s)throw new Error("Solar month outside range 1 - 12");var l="number"==typeof r&&r>=1&&r<=31;if(!l)throw new Error("Solar day outside range 1 - 31");i={year:t,month:e,day:r},a=n||{}}var c=h[i.year-h[0]],u=i.year<<9|i.month<<5|i.day;a.year=u>=c?i.year:i.year-1,c=h[a.year-h[0]];var p,d=new Date(c>>9&4095,(c>>5&15)-1,31&c),g=new Date(i.year,i.month-1,i.day);p=Math.round((g-d)/864e5);var v,m=f[a.year-f[0]];for(v=0;v<13;v++){var y=m&1<<12-v?30:29;if(p>13;!x||v=2&&n<=6},extraInfo:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return{century:o[Math.floor((i.year()-1)/100)+1]||""}},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=i.year()+(i.year()<0?1:0),e=i.month(),(r=i.day())+(e>1?16:0)+(e>2?32*(e-2):0)+400*(t-1)+this.jdEpoch-1},fromJD:function(t){t=Math.floor(t+.5)-Math.floor(this.jdEpoch)-1;var e=Math.floor(t/400)+1;t-=400*(e-1),t+=t>15?16:0;var r=Math.floor(t/32)+1,n=t-32*(r-1)+1;return this.newDate(e<=0?e-1:e,r,n)}});var o={20:"Fruitbat",21:"Anchovy"};n.calendars.discworld=a},{"../main":548,"object-assign":437}],537:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Ethiopian",jdEpoch:1724220.5,daysPerMonth:[30,30,30,30,30,30,30,30,30,30,30,30,5],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Ethiopian",epochs:["BEE","EE"],monthNames:["Meskerem","Tikemet","Hidar","Tahesas","Tir","Yekatit","Megabit","Miazia","Genbot","Sene","Hamle","Nehase","Pagume"],monthNamesShort:["Mes","Tik","Hid","Tah","Tir","Yek","Meg","Mia","Gen","Sen","Ham","Neh","Pag"],dayNames:["Ehud","Segno","Maksegno","Irob","Hamus","Arb","Kidame"],dayNamesShort:["Ehu","Seg","Mak","Iro","Ham","Arb","Kid"],dayNamesMin:["Eh","Se","Ma","Ir","Ha","Ar","Ki"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return(t=e.year()+(e.year()<0?1:0))%4==3||t%4==-1},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear||n.regionalOptions[""].invalidYear),13},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(13===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return(t=i.year())<0&&t++,i.day()+30*(i.month()-1)+365*(t-1)+Math.floor(t/4)+this.jdEpoch-1},fromJD:function(t){var e=Math.floor(t)+.5-this.jdEpoch,r=Math.floor((e-Math.floor((e+366)/1461))/365)+1;r<=0&&r--,e=Math.floor(t)+.5-this.newDate(r,1,1).toJD();var n=Math.floor(e/30)+1,i=e-30*(n-1)+1;return this.newDate(r,n,i)}}),n.calendars.ethiopian=a},{"../main":548,"object-assign":437}],538:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}function o(t,e){return t-e*Math.floor(t/e)}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Hebrew",jdEpoch:347995.5,daysPerMonth:[30,29,30,29,30,29,30,29,30,29,30,29,29],hasYearZero:!1,minMonth:1,firstMonth:7,minDay:1,regionalOptions:{"":{name:"Hebrew",epochs:["BAM","AM"],monthNames:["Nisan","Iyar","Sivan","Tammuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Shevat","Adar","Adar II"],monthNamesShort:["Nis","Iya","Siv","Tam","Av","Elu","Tis","Che","Kis","Tev","She","Ada","Ad2"],dayNames:["Yom Rishon","Yom Sheni","Yom Shlishi","Yom Revi'i","Yom Chamishi","Yom Shishi","Yom Shabbat"],dayNamesShort:["Ris","She","Shl","Rev","Cha","Shi","Sha"],dayNamesMin:["Ri","She","Shl","Re","Ch","Shi","Sha"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return this._leapYear(e.year())},_leapYear:function(t){return o(7*(t=t<0?t+1:t)+1,19)<7},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),this._leapYear(t.year?t.year():t)?13:12},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){return t=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year(),this.toJD(-1===t?1:t+1,7,1)-this.toJD(t,7,1)},daysInMonth:function(t,e){return t.year&&(e=t.month(),t=t.year()),this._validate(t,e,this.minDay,n.local.invalidMonth),12===e&&this.leapYear(t)?30:8===e&&5===o(this.daysInYear(t),10)?30:9===e&&3===o(this.daysInYear(t),10)?29:this.daysPerMonth[e-1]},weekDay:function(t,e,r){return 6!==this.dayOfWeek(t,e,r)},extraInfo:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return{yearType:(this.leapYear(i)?"embolismic":"common")+" "+["deficient","regular","complete"][this.daysInYear(i)%10-3]}},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=i.year(),e=i.month(),r=i.day();var a=t<=0?t+1:t,o=this.jdEpoch+this._delay1(a)+this._delay2(a)+r+1;if(e<7){for(var s=7;s<=this.monthsInYear(t);s++)o+=this.daysInMonth(t,s);for(s=1;s=this.toJD(-1===e?1:e+1,7,1);)e++;for(var r=tthis.toJD(e,r,this.daysInMonth(e,r));)r++;var n=t-this.toJD(e,r,1)+1;return this.newDate(e,r,n)}}),n.calendars.hebrew=a},{"../main":548,"object-assign":437}],539:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Islamic",jdEpoch:1948439.5,daysPerMonth:[30,29,30,29,30,29,30,29,30,29,30,29],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Islamic",epochs:["BH","AH"],monthNames:["Muharram","Safar","Rabi' al-awwal","Rabi' al-thani","Jumada al-awwal","Jumada al-thani","Rajab","Sha'aban","Ramadan","Shawwal","Dhu al-Qi'dah","Dhu al-Hijjah"],monthNamesShort:["Muh","Saf","Rab1","Rab2","Jum1","Jum2","Raj","Sha'","Ram","Shaw","DhuQ","DhuH"],dayNames:["Yawm al-ahad","Yawm al-ithnayn","Yawm ath-thulaathaa'","Yawm al-arbi'aa'","Yawm al-kham\u012bs","Yawm al-jum'a","Yawm as-sabt"],dayNamesShort:["Aha","Ith","Thu","Arb","Kha","Jum","Sab"],dayNamesMin:["Ah","It","Th","Ar","Kh","Ju","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:6,isRTL:!1}},leapYear:function(t){return(11*this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year()+14)%30<11},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){return this.leapYear(t)?355:354},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=i.year(),e=i.month(),t=t<=0?t+1:t,(r=i.day())+Math.ceil(29.5*(e-1))+354*(t-1)+Math.floor((3+11*t)/30)+this.jdEpoch-1},fromJD:function(t){t=Math.floor(t)+.5;var e=Math.floor((30*(t-this.jdEpoch)+10646)/10631);e=e<=0?e-1:e;var r=Math.min(12,Math.ceil((t-29-this.toJD(e,1,1))/29.5)+1),n=t-this.toJD(e,r,1)+1;return this.newDate(e,r,n)}}),n.calendars.islamic=a},{"../main":548,"object-assign":437}],540:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Julian",jdEpoch:1721423.5,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Julian",epochs:["BC","AD"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"mm/dd/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return(t=e.year()<0?e.year()+1:e.year())%4==0},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(4-(n.dayOfWeek()||7),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=i.year(),e=i.month(),r=i.day(),t<0&&t++,e<=2&&(t--,e+=12),Math.floor(365.25*(t+4716))+Math.floor(30.6001*(e+1))+r-1524.5},fromJD:function(t){var e=Math.floor(t+.5)+1524,r=Math.floor((e-122.1)/365.25),n=Math.floor(365.25*r),i=Math.floor((e-n)/30.6001),a=i-Math.floor(i<14?1:13),o=r-Math.floor(a>2?4716:4715),s=e-n-Math.floor(30.6001*i);return o<=0&&o--,this.newDate(o,a,s)}}),n.calendars.julian=a},{"../main":548,"object-assign":437}],541:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}function o(t,e){return t-e*Math.floor(t/e)}function s(t,e){return o(t-1,e)+1}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Mayan",jdEpoch:584282.5,hasYearZero:!0,minMonth:0,firstMonth:0,minDay:0,regionalOptions:{"":{name:"Mayan",epochs:["",""],monthNames:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"],monthNamesShort:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"],dayNames:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],dayNamesShort:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],dayNamesMin:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],digits:null,dateFormat:"YYYY.m.d",firstDay:0,isRTL:!1,haabMonths:["Pop","Uo","Zip","Zotz","Tzec","Xul","Yaxkin","Mol","Chen","Yax","Zac","Ceh","Mac","Kankin","Muan","Pax","Kayab","Cumku","Uayeb"],tzolkinMonths:["Imix","Ik","Akbal","Kan","Chicchan","Cimi","Manik","Lamat","Muluc","Oc","Chuen","Eb","Ben","Ix","Men","Cib","Caban","Etznab","Cauac","Ahau"]}},leapYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),!1},formatYear:function(t){t=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year();var e=Math.floor(t/400);return t%=400,t+=t<0?400:0,e+"."+Math.floor(t/20)+"."+t%20},forYear:function(t){if((t=t.split(".")).length<3)throw"Invalid Mayan year";for(var e=0,r=0;r19||r>0&&n<0)throw"Invalid Mayan year";e=20*e+n}return e},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),18},weekOfYear:function(t,e,r){return this._validate(t,e,r,n.local.invalidDate),0},daysInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),360},daysInMonth:function(t,e){return this._validate(t,e,this.minDay,n.local.invalidMonth),20},daysInWeek:function(){return 5},dayOfWeek:function(t,e,r){return this._validate(t,e,r,n.local.invalidDate).day()},weekDay:function(t,e,r){return this._validate(t,e,r,n.local.invalidDate),!0},extraInfo:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate).toJD(),a=this._toHaab(i),o=this._toTzolkin(i);return{haabMonthName:this.local.haabMonths[a[0]-1],haabMonth:a[0],haabDay:a[1],tzolkinDayName:this.local.tzolkinMonths[o[0]-1],tzolkinDay:o[0],tzolkinTrecena:o[1]}},_toHaab:function(t){var e=o((t-=this.jdEpoch)+8+340,365);return[Math.floor(e/20)+1,o(e,20)]},_toTzolkin:function(t){return[s((t-=this.jdEpoch)+20,20),s(t+4,13)]},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return i.day()+20*i.month()+360*i.year()+this.jdEpoch},fromJD:function(t){t=Math.floor(t)+.5-this.jdEpoch;var e=Math.floor(t/360);t%=360,t+=t<0?360:0;var r=Math.floor(t/20),n=t%20;return this.newDate(e,r,n)}}),n.calendars.mayan=a},{"../main":548,"object-assign":437}],542:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar;var o=n.instance("gregorian");i(a.prototype,{name:"Nanakshahi",jdEpoch:2257673.5,daysPerMonth:[31,31,31,31,31,30,30,30,30,30,30,30],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Nanakshahi",epochs:["BN","AN"],monthNames:["Chet","Vaisakh","Jeth","Harh","Sawan","Bhadon","Assu","Katak","Maghar","Poh","Magh","Phagun"],monthNamesShort:["Che","Vai","Jet","Har","Saw","Bha","Ass","Kat","Mgr","Poh","Mgh","Pha"],dayNames:["Somvaar","Mangalvar","Budhvaar","Veervaar","Shukarvaar","Sanicharvaar","Etvaar"],dayNamesShort:["Som","Mangal","Budh","Veer","Shukar","Sanichar","Et"],dayNamesMin:["So","Ma","Bu","Ve","Sh","Sa","Et"],digits:null,dateFormat:"dd-mm-yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear||n.regionalOptions[""].invalidYear);return o.leapYear(e.year()+(e.year()<1?1:0)+1469)},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(1-(n.dayOfWeek()||7),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidMonth);(t=i.year())<0&&t++;for(var a=i.day(),s=1;s=this.toJD(e+1,1,1);)e++;for(var r=t-Math.floor(this.toJD(e,1,1)+.5)+1,n=1;r>this.daysInMonth(e,n);)r-=this.daysInMonth(e,n),n++;return this.newDate(e,n,r)}}),n.calendars.nanakshahi=a},{"../main":548,"object-assign":437}],543:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Nepali",jdEpoch:1700709.5,daysPerMonth:[31,31,32,32,31,30,30,29,30,29,30,30],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,daysPerYear:365,regionalOptions:{"":{name:"Nepali",epochs:["BBS","ABS"],monthNames:["Baisakh","Jestha","Ashadh","Shrawan","Bhadra","Ashwin","Kartik","Mangsir","Paush","Mangh","Falgun","Chaitra"],monthNamesShort:["Bai","Je","As","Shra","Bha","Ash","Kar","Mang","Pau","Ma","Fal","Chai"],dayNames:["Aaitabaar","Sombaar","Manglbaar","Budhabaar","Bihibaar","Shukrabaar","Shanibaar"],dayNamesShort:["Aaita","Som","Mangl","Budha","Bihi","Shukra","Shani"],dayNamesMin:["Aai","So","Man","Bu","Bi","Shu","Sha"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:1,isRTL:!1}},leapYear:function(t){return this.daysInYear(t)!==this.daysPerYear},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){if(t=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year(),"undefined"==typeof this.NEPALI_CALENDAR_DATA[t])return this.daysPerYear;for(var e=0,r=this.minMonth;r<=12;r++)e+=this.NEPALI_CALENDAR_DATA[t][r];return e},daysInMonth:function(t,e){return t.year&&(e=t.month(),t=t.year()),this._validate(t,e,this.minDay,n.local.invalidMonth),"undefined"==typeof this.NEPALI_CALENDAR_DATA[t]?this.daysPerMonth[e-1]:this.NEPALI_CALENDAR_DATA[t][e]},weekDay:function(t,e,r){return 6!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=i.year(),e=i.month(),r=i.day();var a=n.instance(),o=0,s=e,l=t;this._createMissingCalendarData(t);var c=t-(s>9||9===s&&r>=this.NEPALI_CALENDAR_DATA[l][0]?56:57);for(9!==e&&(o=r,s--);9!==s;)s<=0&&(s=12,l--),o+=this.NEPALI_CALENDAR_DATA[l][s],s--;return 9===e?(o+=r-this.NEPALI_CALENDAR_DATA[l][0])<0&&(o+=a.daysInYear(c)):o+=this.NEPALI_CALENDAR_DATA[l][9]-this.NEPALI_CALENDAR_DATA[l][0],a.newDate(c,1,1).add(o,"d").toJD()},fromJD:function(t){var e=n.instance().fromJD(t),r=e.year(),i=e.dayOfYear(),a=r+56;this._createMissingCalendarData(a);for(var o=9,s=this.NEPALI_CALENDAR_DATA[a][0],l=this.NEPALI_CALENDAR_DATA[a][o]-s+1;i>l;)++o>12&&(o=1,a++),l+=this.NEPALI_CALENDAR_DATA[a][o];var c=this.NEPALI_CALENDAR_DATA[a][o]-(l-i);return this.newDate(a,o,c)},_createMissingCalendarData:function(t){var e=this.daysPerMonth.slice(0);e.unshift(17);for(var r=t-1;r0?474:473))%2820+474+38)%2816<682},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-(n.dayOfWeek()+1)%7,"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=i.year(),e=i.month(),r=i.day();var a=t-(t>=0?474:473),s=474+o(a,2820);return r+(e<=7?31*(e-1):30*(e-1)+6)+Math.floor((682*s-110)/2816)+365*(s-1)+1029983*Math.floor(a/2820)+this.jdEpoch-1},fromJD:function(t){var e=(t=Math.floor(t)+.5)-this.toJD(475,1,1),r=Math.floor(e/1029983),n=o(e,1029983),i=2820;if(1029982!==n){var a=Math.floor(n/366),s=o(n,366);i=Math.floor((2134*a+2816*s+2815)/1028522)+a+1}var l=i+2820*r+474;l=l<=0?l-1:l;var c=t-this.toJD(l,1,1)+1,u=c<=186?Math.ceil(c/31):Math.ceil((c-6)/30),f=t-this.toJD(l,u,1)+1;return this.newDate(l,u,f)}}),n.calendars.persian=a,n.calendars.jalali=a},{"../main":548,"object-assign":437}],545:[function(t,e,r){var n=t("../main"),i=t("object-assign"),a=n.instance();function o(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}o.prototype=new n.baseCalendar,i(o.prototype,{name:"Taiwan",jdEpoch:2419402.5,yearsOffset:1911,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Taiwan",epochs:["BROC","ROC"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:1,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);t=this._t2gYear(e.year());return a.leapYear(t)},weekOfYear:function(t,e,r){var i=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);t=this._t2gYear(i.year());return a.weekOfYear(t,i.month(),i.day())},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=this._t2gYear(i.year());return a.toJD(t,i.month(),i.day())},fromJD:function(t){var e=a.fromJD(t),r=this._g2tYear(e.year());return this.newDate(r,e.month(),e.day())},_t2gYear:function(t){return t+this.yearsOffset+(t>=-this.yearsOffset&&t<=-1?1:0)},_g2tYear:function(t){return t-this.yearsOffset-(t>=1&&t<=this.yearsOffset?1:0)}}),n.calendars.taiwan=o},{"../main":548,"object-assign":437}],546:[function(t,e,r){var n=t("../main"),i=t("object-assign"),a=n.instance();function o(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}o.prototype=new n.baseCalendar,i(o.prototype,{name:"Thai",jdEpoch:1523098.5,yearsOffset:543,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Thai",epochs:["BBE","BE"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);t=this._t2gYear(e.year());return a.leapYear(t)},weekOfYear:function(t,e,r){var i=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);t=this._t2gYear(i.year());return a.weekOfYear(t,i.month(),i.day())},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=this._t2gYear(i.year());return a.toJD(t,i.month(),i.day())},fromJD:function(t){var e=a.fromJD(t),r=this._g2tYear(e.year());return this.newDate(r,e.month(),e.day())},_t2gYear:function(t){return t-this.yearsOffset-(t>=1&&t<=this.yearsOffset?1:0)},_g2tYear:function(t){return t+this.yearsOffset+(t>=-this.yearsOffset&&t<=-1?1:0)}}),n.calendars.thai=o},{"../main":548,"object-assign":437}],547:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"UmmAlQura",hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Umm al-Qura",epochs:["BH","AH"],monthNames:["Al-Muharram","Safar","Rabi' al-awwal","Rabi' Al-Thani","Jumada Al-Awwal","Jumada Al-Thani","Rajab","Sha'aban","Ramadan","Shawwal","Dhu al-Qi'dah","Dhu al-Hijjah"],monthNamesShort:["Muh","Saf","Rab1","Rab2","Jum1","Jum2","Raj","Sha'","Ram","Shaw","DhuQ","DhuH"],dayNames:["Yawm al-Ahad","Yawm al-Ithnain","Yawm al-Thal\u0101th\u0101\u2019","Yawm al-Arba\u2018\u0101\u2019","Yawm al-Kham\u012bs","Yawm al-Jum\u2018a","Yawm al-Sabt"],dayNamesMin:["Ah","Ith","Th","Ar","Kh","Ju","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:6,isRTL:!0}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return 355===this.daysInYear(e.year())},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){for(var e=0,r=1;r<=12;r++)e+=this.daysInMonth(t,r);return e},daysInMonth:function(t,e){for(var r=this._validate(t,e,this.minDay,n.local.invalidMonth).toJD()-24e5+.5,i=0,a=0;ar)return o[i]-o[i-1];i++}return 30},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate),a=12*(i.year()-1)+i.month()-15292;return i.day()+o[a-1]-1+24e5-.5},fromJD:function(t){for(var e=t-24e5+.5,r=0,n=0;ne);n++)r++;var i=r+15292,a=Math.floor((i-1)/12),s=a+1,l=i-12*a,c=e-o[r-1]+1;return this.newDate(s,l,c)},isValid:function(t,e,r){var i=n.baseCalendar.prototype.isValid.apply(this,arguments);return i&&(i=(t=null!=t.year?t.year:t)>=1276&&t<=1500),i},_validate:function(t,e,r,i){var a=n.baseCalendar.prototype._validate.apply(this,arguments);if(a.year<1276||a.year>1500)throw i.replace(/\{0\}/,this.local.name);return a}}),n.calendars.ummalqura=a;var o=[20,50,79,109,138,168,197,227,256,286,315,345,374,404,433,463,492,522,551,581,611,641,670,700,729,759,788,818,847,877,906,936,965,995,1024,1054,1083,1113,1142,1172,1201,1231,1260,1290,1320,1350,1379,1409,1438,1468,1497,1527,1556,1586,1615,1645,1674,1704,1733,1763,1792,1822,1851,1881,1910,1940,1969,1999,2028,2058,2087,2117,2146,2176,2205,2235,2264,2294,2323,2353,2383,2413,2442,2472,2501,2531,2560,2590,2619,2649,2678,2708,2737,2767,2796,2826,2855,2885,2914,2944,2973,3003,3032,3062,3091,3121,3150,3180,3209,3239,3268,3298,3327,3357,3386,3416,3446,3476,3505,3535,3564,3594,3623,3653,3682,3712,3741,3771,3800,3830,3859,3889,3918,3948,3977,4007,4036,4066,4095,4125,4155,4185,4214,4244,4273,4303,4332,4362,4391,4421,4450,4480,4509,4539,4568,4598,4627,4657,4686,4716,4745,4775,4804,4834,4863,4893,4922,4952,4981,5011,5040,5070,5099,5129,5158,5188,5218,5248,5277,5307,5336,5366,5395,5425,5454,5484,5513,5543,5572,5602,5631,5661,5690,5720,5749,5779,5808,5838,5867,5897,5926,5956,5985,6015,6044,6074,6103,6133,6162,6192,6221,6251,6281,6311,6340,6370,6399,6429,6458,6488,6517,6547,6576,6606,6635,6665,6694,6724,6753,6783,6812,6842,6871,6901,6930,6960,6989,7019,7048,7078,7107,7137,7166,7196,7225,7255,7284,7314,7344,7374,7403,7433,7462,7492,7521,7551,7580,7610,7639,7669,7698,7728,7757,7787,7816,7846,7875,7905,7934,7964,7993,8023,8053,8083,8112,8142,8171,8201,8230,8260,8289,8319,8348,8378,8407,8437,8466,8496,8525,8555,8584,8614,8643,8673,8702,8732,8761,8791,8821,8850,8880,8909,8938,8968,8997,9027,9056,9086,9115,9145,9175,9205,9234,9264,9293,9322,9352,9381,9410,9440,9470,9499,9529,9559,9589,9618,9648,9677,9706,9736,9765,9794,9824,9853,9883,9913,9943,9972,10002,10032,10061,10090,10120,10149,10178,10208,10237,10267,10297,10326,10356,10386,10415,10445,10474,10504,10533,10562,10592,10621,10651,10680,10710,10740,10770,10799,10829,10858,10888,10917,10947,10976,11005,11035,11064,11094,11124,11153,11183,11213,11242,11272,11301,11331,11360,11389,11419,11448,11478,11507,11537,11567,11596,11626,11655,11685,11715,11744,11774,11803,11832,11862,11891,11921,11950,11980,12010,12039,12069,12099,12128,12158,12187,12216,12246,12275,12304,12334,12364,12393,12423,12453,12483,12512,12542,12571,12600,12630,12659,12688,12718,12747,12777,12807,12837,12866,12896,12926,12955,12984,13014,13043,13072,13102,13131,13161,13191,13220,13250,13280,13310,13339,13368,13398,13427,13456,13486,13515,13545,13574,13604,13634,13664,13693,13723,13752,13782,13811,13840,13870,13899,13929,13958,13988,14018,14047,14077,14107,14136,14166,14195,14224,14254,14283,14313,14342,14372,14401,14431,14461,14490,14520,14550,14579,14609,14638,14667,14697,14726,14756,14785,14815,14844,14874,14904,14933,14963,14993,15021,15051,15081,15110,15140,15169,15199,15228,15258,15287,15317,15347,15377,15406,15436,15465,15494,15524,15553,15582,15612,15641,15671,15701,15731,15760,15790,15820,15849,15878,15908,15937,15966,15996,16025,16055,16085,16114,16144,16174,16204,16233,16262,16292,16321,16350,16380,16409,16439,16468,16498,16528,16558,16587,16617,16646,16676,16705,16734,16764,16793,16823,16852,16882,16912,16941,16971,17001,17030,17060,17089,17118,17148,17177,17207,17236,17266,17295,17325,17355,17384,17414,17444,17473,17502,17532,17561,17591,17620,17650,17679,17709,17738,17768,17798,17827,17857,17886,17916,17945,17975,18004,18034,18063,18093,18122,18152,18181,18211,18241,18270,18300,18330,18359,18388,18418,18447,18476,18506,18535,18565,18595,18625,18654,18684,18714,18743,18772,18802,18831,18860,18890,18919,18949,18979,19008,19038,19068,19098,19127,19156,19186,19215,19244,19274,19303,19333,19362,19392,19422,19452,19481,19511,19540,19570,19599,19628,19658,19687,19717,19746,19776,19806,19836,19865,19895,19924,19954,19983,20012,20042,20071,20101,20130,20160,20190,20219,20249,20279,20308,20338,20367,20396,20426,20455,20485,20514,20544,20573,20603,20633,20662,20692,20721,20751,20780,20810,20839,20869,20898,20928,20957,20987,21016,21046,21076,21105,21135,21164,21194,21223,21253,21282,21312,21341,21371,21400,21430,21459,21489,21519,21548,21578,21607,21637,21666,21696,21725,21754,21784,21813,21843,21873,21902,21932,21962,21991,22021,22050,22080,22109,22138,22168,22197,22227,22256,22286,22316,22346,22375,22405,22434,22464,22493,22522,22552,22581,22611,22640,22670,22700,22730,22759,22789,22818,22848,22877,22906,22936,22965,22994,23024,23054,23083,23113,23143,23173,23202,23232,23261,23290,23320,23349,23379,23408,23438,23467,23497,23527,23556,23586,23616,23645,23674,23704,23733,23763,23792,23822,23851,23881,23910,23940,23970,23999,24029,24058,24088,24117,24147,24176,24206,24235,24265,24294,24324,24353,24383,24413,24442,24472,24501,24531,24560,24590,24619,24648,24678,24707,24737,24767,24796,24826,24856,24885,24915,24944,24974,25003,25032,25062,25091,25121,25150,25180,25210,25240,25269,25299,25328,25358,25387,25416,25446,25475,25505,25534,25564,25594,25624,25653,25683,25712,25742,25771,25800,25830,25859,25888,25918,25948,25977,26007,26037,26067,26096,26126,26155,26184,26214,26243,26272,26302,26332,26361,26391,26421,26451,26480,26510,26539,26568,26598,26627,26656,26686,26715,26745,26775,26805,26834,26864,26893,26923,26952,26982,27011,27041,27070,27099,27129,27159,27188,27218,27248,27277,27307,27336,27366,27395,27425,27454,27484,27513,27542,27572,27602,27631,27661,27691,27720,27750,27779,27809,27838,27868,27897,27926,27956,27985,28015,28045,28074,28104,28134,28163,28193,28222,28252,28281,28310,28340,28369,28399,28428,28458,28488,28517,28547,28577,28607,28636,28665,28695,28724,28754,28783,28813,28843,28872,28901,28931,28960,28990,29019,29049,29078,29108,29137,29167,29196,29226,29255,29285,29315,29345,29375,29404,29434,29463,29492,29522,29551,29580,29610,29640,29669,29699,29729,29759,29788,29818,29847,29876,29906,29935,29964,29994,30023,30053,30082,30112,30141,30171,30200,30230,30259,30289,30318,30348,30378,30408,30437,30467,30496,30526,30555,30585,30614,30644,30673,30703,30732,30762,30791,30821,30850,30880,30909,30939,30968,30998,31027,31057,31086,31116,31145,31175,31204,31234,31263,31293,31322,31352,31381,31411,31441,31471,31500,31530,31559,31589,31618,31648,31676,31706,31736,31766,31795,31825,31854,31884,31913,31943,31972,32002,32031,32061,32090,32120,32150,32180,32209,32239,32268,32298,32327,32357,32386,32416,32445,32475,32504,32534,32563,32593,32622,32652,32681,32711,32740,32770,32799,32829,32858,32888,32917,32947,32976,33006,33035,33065,33094,33124,33153,33183,33213,33243,33272,33302,33331,33361,33390,33420,33450,33479,33509,33539,33568,33598,33627,33657,33686,33716,33745,33775,33804,33834,33863,33893,33922,33952,33981,34011,34040,34069,34099,34128,34158,34187,34217,34247,34277,34306,34336,34365,34395,34424,34454,34483,34512,34542,34571,34601,34631,34660,34690,34719,34749,34778,34808,34837,34867,34896,34926,34955,34985,35015,35044,35074,35103,35133,35162,35192,35222,35251,35280,35310,35340,35370,35399,35429,35458,35488,35517,35547,35576,35605,35635,35665,35694,35723,35753,35782,35811,35841,35871,35901,35930,35960,35989,36019,36048,36078,36107,36136,36166,36195,36225,36254,36284,36314,36343,36373,36403,36433,36462,36492,36521,36551,36580,36610,36639,36669,36698,36728,36757,36786,36816,36845,36875,36904,36934,36963,36993,37022,37052,37081,37111,37141,37170,37200,37229,37259,37288,37318,37347,37377,37406,37436,37465,37495,37524,37554,37584,37613,37643,37672,37701,37731,37760,37790,37819,37849,37878,37908,37938,37967,37997,38027,38056,38085,38115,38144,38174,38203,38233,38262,38292,38322,38351,38381,38410,38440,38469,38499,38528,38558,38587,38617,38646,38676,38705,38735,38764,38794,38823,38853,38882,38912,38941,38971,39001,39030,39059,39089,39118,39148,39178,39208,39237,39267,39297,39326,39355,39385,39414,39444,39473,39503,39532,39562,39592,39621,39650,39680,39709,39739,39768,39798,39827,39857,39886,39916,39946,39975,40005,40035,40064,40094,40123,40153,40182,40212,40241,40271,40300,40330,40359,40389,40418,40448,40477,40507,40536,40566,40595,40625,40655,40685,40714,40744,40773,40803,40832,40862,40892,40921,40951,40980,41009,41039,41068,41098,41127,41157,41186,41216,41245,41275,41304,41334,41364,41393,41422,41452,41481,41511,41540,41570,41599,41629,41658,41688,41718,41748,41777,41807,41836,41865,41894,41924,41953,41983,42012,42042,42072,42102,42131,42161,42190,42220,42249,42279,42308,42337,42367,42397,42426,42456,42485,42515,42545,42574,42604,42633,42662,42692,42721,42751,42780,42810,42839,42869,42899,42929,42958,42988,43017,43046,43076,43105,43135,43164,43194,43223,43253,43283,43312,43342,43371,43401,43430,43460,43489,43519,43548,43578,43607,43637,43666,43696,43726,43755,43785,43814,43844,43873,43903,43932,43962,43991,44021,44050,44080,44109,44139,44169,44198,44228,44258,44287,44317,44346,44375,44405,44434,44464,44493,44523,44553,44582,44612,44641,44671,44700,44730,44759,44788,44818,44847,44877,44906,44936,44966,44996,45025,45055,45084,45114,45143,45172,45202,45231,45261,45290,45320,45350,45380,45409,45439,45468,45498,45527,45556,45586,45615,45644,45674,45704,45733,45763,45793,45823,45852,45882,45911,45940,45970,45999,46028,46058,46088,46117,46147,46177,46206,46236,46265,46295,46324,46354,46383,46413,46442,46472,46501,46531,46560,46590,46620,46649,46679,46708,46738,46767,46797,46826,46856,46885,46915,46944,46974,47003,47033,47063,47092,47122,47151,47181,47210,47240,47269,47298,47328,47357,47387,47417,47446,47476,47506,47535,47565,47594,47624,47653,47682,47712,47741,47771,47800,47830,47860,47890,47919,47949,47978,48008,48037,48066,48096,48125,48155,48184,48214,48244,48273,48303,48333,48362,48392,48421,48450,48480,48509,48538,48568,48598,48627,48657,48687,48717,48746,48776,48805,48834,48864,48893,48922,48952,48982,49011,49041,49071,49100,49130,49160,49189,49218,49248,49277,49306,49336,49365,49395,49425,49455,49484,49514,49543,49573,49602,49632,49661,49690,49720,49749,49779,49809,49838,49868,49898,49927,49957,49986,50016,50045,50075,50104,50133,50163,50192,50222,50252,50281,50311,50340,50370,50400,50429,50459,50488,50518,50547,50576,50606,50635,50665,50694,50724,50754,50784,50813,50843,50872,50902,50931,50960,50990,51019,51049,51078,51108,51138,51167,51197,51227,51256,51286,51315,51345,51374,51403,51433,51462,51492,51522,51552,51582,51611,51641,51670,51699,51729,51758,51787,51816,51846,51876,51906,51936,51965,51995,52025,52054,52083,52113,52142,52171,52200,52230,52260,52290,52319,52349,52379,52408,52438,52467,52497,52526,52555,52585,52614,52644,52673,52703,52733,52762,52792,52822,52851,52881,52910,52939,52969,52998,53028,53057,53087,53116,53146,53176,53205,53235,53264,53294,53324,53353,53383,53412,53441,53471,53500,53530,53559,53589,53619,53648,53678,53708,53737,53767,53796,53825,53855,53884,53913,53943,53973,54003,54032,54062,54092,54121,54151,54180,54209,54239,54268,54297,54327,54357,54387,54416,54446,54476,54505,54535,54564,54593,54623,54652,54681,54711,54741,54770,54800,54830,54859,54889,54919,54948,54977,55007,55036,55066,55095,55125,55154,55184,55213,55243,55273,55302,55332,55361,55391,55420,55450,55479,55508,55538,55567,55597,55627,55657,55686,55716,55745,55775,55804,55834,55863,55892,55922,55951,55981,56011,56040,56070,56100,56129,56159,56188,56218,56247,56276,56306,56335,56365,56394,56424,56454,56483,56513,56543,56572,56601,56631,56660,56690,56719,56749,56778,56808,56837,56867,56897,56926,56956,56985,57015,57044,57074,57103,57133,57162,57192,57221,57251,57280,57310,57340,57369,57399,57429,57458,57487,57517,57546,57576,57605,57634,57664,57694,57723,57753,57783,57813,57842,57871,57901,57930,57959,57989,58018,58048,58077,58107,58137,58167,58196,58226,58255,58285,58314,58343,58373,58402,58432,58461,58491,58521,58551,58580,58610,58639,58669,58698,58727,58757,58786,58816,58845,58875,58905,58934,58964,58994,59023,59053,59082,59111,59141,59170,59200,59229,59259,59288,59318,59348,59377,59407,59436,59466,59495,59525,59554,59584,59613,59643,59672,59702,59731,59761,59791,59820,59850,59879,59909,59939,59968,59997,60027,60056,60086,60115,60145,60174,60204,60234,60264,60293,60323,60352,60381,60411,60440,60469,60499,60528,60558,60588,60618,60648,60677,60707,60736,60765,60795,60824,60853,60883,60912,60942,60972,61002,61031,61061,61090,61120,61149,61179,61208,61237,61267,61296,61326,61356,61385,61415,61445,61474,61504,61533,61563,61592,61621,61651,61680,61710,61739,61769,61799,61828,61858,61888,61917,61947,61976,62006,62035,62064,62094,62123,62153,62182,62212,62242,62271,62301,62331,62360,62390,62419,62448,62478,62507,62537,62566,62596,62625,62655,62685,62715,62744,62774,62803,62832,62862,62891,62921,62950,62980,63009,63039,63069,63099,63128,63157,63187,63216,63246,63275,63305,63334,63363,63393,63423,63453,63482,63512,63541,63571,63600,63630,63659,63689,63718,63747,63777,63807,63836,63866,63895,63925,63955,63984,64014,64043,64073,64102,64131,64161,64190,64220,64249,64279,64309,64339,64368,64398,64427,64457,64486,64515,64545,64574,64603,64633,64663,64692,64722,64752,64782,64811,64841,64870,64899,64929,64958,64987,65017,65047,65076,65106,65136,65166,65195,65225,65254,65283,65313,65342,65371,65401,65431,65460,65490,65520,65549,65579,65608,65638,65667,65697,65726,65755,65785,65815,65844,65874,65903,65933,65963,65992,66022,66051,66081,66110,66140,66169,66199,66228,66258,66287,66317,66346,66376,66405,66435,66465,66494,66524,66553,66583,66612,66641,66671,66700,66730,66760,66789,66819,66849,66878,66908,66937,66967,66996,67025,67055,67084,67114,67143,67173,67203,67233,67262,67292,67321,67351,67380,67409,67439,67468,67497,67527,67557,67587,67617,67646,67676,67705,67735,67764,67793,67823,67852,67882,67911,67941,67971,68e3,68030,68060,68089,68119,68148,68177,68207,68236,68266,68295,68325,68354,68384,68414,68443,68473,68502,68532,68561,68591,68620,68650,68679,68708,68738,68768,68797,68827,68857,68886,68916,68946,68975,69004,69034,69063,69092,69122,69152,69181,69211,69240,69270,69300,69330,69359,69388,69418,69447,69476,69506,69535,69565,69595,69624,69654,69684,69713,69743,69772,69802,69831,69861,69890,69919,69949,69978,70008,70038,70067,70097,70126,70156,70186,70215,70245,70274,70303,70333,70362,70392,70421,70451,70481,70510,70540,70570,70599,70629,70658,70687,70717,70746,70776,70805,70835,70864,70894,70924,70954,70983,71013,71042,71071,71101,71130,71159,71189,71218,71248,71278,71308,71337,71367,71397,71426,71455,71485,71514,71543,71573,71602,71632,71662,71691,71721,71751,71781,71810,71839,71869,71898,71927,71957,71986,72016,72046,72075,72105,72135,72164,72194,72223,72253,72282,72311,72341,72370,72400,72429,72459,72489,72518,72548,72577,72607,72637,72666,72695,72725,72754,72784,72813,72843,72872,72902,72931,72961,72991,73020,73050,73080,73109,73139,73168,73197,73227,73256,73286,73315,73345,73375,73404,73434,73464,73493,73523,73552,73581,73611,73640,73669,73699,73729,73758,73788,73818,73848,73877,73907,73936,73965,73995,74024,74053,74083,74113,74142,74172,74202,74231,74261,74291,74320,74349,74379,74408,74437,74467,74497,74526,74556,74586,74615,74645,74675,74704,74733,74763,74792,74822,74851,74881,74910,74940,74969,74999,75029,75058,75088,75117,75147,75176,75206,75235,75264,75294,75323,75353,75383,75412,75442,75472,75501,75531,75560,75590,75619,75648,75678,75707,75737,75766,75796,75826,75856,75885,75915,75944,75974,76003,76032,76062,76091,76121,76150,76180,76210,76239,76269,76299,76328,76358,76387,76416,76446,76475,76505,76534,76564,76593,76623,76653,76682,76712,76741,76771,76801,76830,76859,76889,76918,76948,76977,77007,77036,77066,77096,77125,77155,77185,77214,77243,77273,77302,77332,77361,77390,77420,77450,77479,77509,77539,77569,77598,77627,77657,77686,77715,77745,77774,77804,77833,77863,77893,77923,77952,77982,78011,78041,78070,78099,78129,78158,78188,78217,78247,78277,78307,78336,78366,78395,78425,78454,78483,78513,78542,78572,78601,78631,78661,78690,78720,78750,78779,78808,78838,78867,78897,78926,78956,78985,79015,79044,79074,79104,79133,79163,79192,79222,79251,79281,79310,79340,79369,79399,79428,79458,79487,79517,79546,79576,79606,79635,79665,79695,79724,79753,79783,79812,79841,79871,79900,79930,79960,79990]},{"../main":548,"object-assign":437}],548:[function(t,e,r){var n=t("object-assign");function i(){this.regionalOptions=[],this.regionalOptions[""]={invalidCalendar:"Calendar {0} not found",invalidDate:"Invalid {0} date",invalidMonth:"Invalid {0} month",invalidYear:"Invalid {0} year",differentCalendars:"Cannot mix {0} and {1} dates"},this.local=this.regionalOptions[""],this.calendars={},this._localCals={}}function a(t,e,r,n){if(this._calendar=t,this._year=e,this._month=r,this._day=n,0===this._calendar._validateLevel&&!this._calendar.isValid(this._year,this._month,this._day))throw(c.local.invalidDate||c.regionalOptions[""].invalidDate).replace(/\{0\}/,this._calendar.local.name)}function o(t,e){return"000000".substring(0,e-(t=""+t).length)+t}function s(){this.shortYearCutoff="+10"}function l(t){this.local=this.regionalOptions[t]||this.regionalOptions[""]}n(i.prototype,{instance:function(t,e){t=(t||"gregorian").toLowerCase(),e=e||"";var r=this._localCals[t+"-"+e];if(!r&&this.calendars[t]&&(r=new this.calendars[t](e),this._localCals[t+"-"+e]=r),!r)throw(this.local.invalidCalendar||this.regionalOptions[""].invalidCalendar).replace(/\{0\}/,t);return r},newDate:function(t,e,r,n,i){return(n=(null!=t&&t.year?t.calendar():"string"==typeof n?this.instance(n,i):n)||this.instance()).newDate(t,e,r)},substituteDigits:function(t){return function(e){return(e+"").replace(/[0-9]/g,function(e){return t[e]})}},substituteChineseDigits:function(t,e){return function(r){for(var n="",i=0;r>0;){var a=r%10;n=(0===a?"":t[a]+e[i])+n,i++,r=Math.floor(r/10)}return 0===n.indexOf(t[1]+e[1])&&(n=n.substr(1)),n||t[0]}}}),n(a.prototype,{newDate:function(t,e,r){return this._calendar.newDate(null==t?this:t,e,r)},year:function(t){return 0===arguments.length?this._year:this.set(t,"y")},month:function(t){return 0===arguments.length?this._month:this.set(t,"m")},day:function(t){return 0===arguments.length?this._day:this.set(t,"d")},date:function(t,e,r){if(!this._calendar.isValid(t,e,r))throw(c.local.invalidDate||c.regionalOptions[""].invalidDate).replace(/\{0\}/,this._calendar.local.name);return this._year=t,this._month=e,this._day=r,this},leapYear:function(){return this._calendar.leapYear(this)},epoch:function(){return this._calendar.epoch(this)},formatYear:function(){return this._calendar.formatYear(this)},monthOfYear:function(){return this._calendar.monthOfYear(this)},weekOfYear:function(){return this._calendar.weekOfYear(this)},daysInYear:function(){return this._calendar.daysInYear(this)},dayOfYear:function(){return this._calendar.dayOfYear(this)},daysInMonth:function(){return this._calendar.daysInMonth(this)},dayOfWeek:function(){return this._calendar.dayOfWeek(this)},weekDay:function(){return this._calendar.weekDay(this)},extraInfo:function(){return this._calendar.extraInfo(this)},add:function(t,e){return this._calendar.add(this,t,e)},set:function(t,e){return this._calendar.set(this,t,e)},compareTo:function(t){if(this._calendar.name!==t._calendar.name)throw(c.local.differentCalendars||c.regionalOptions[""].differentCalendars).replace(/\{0\}/,this._calendar.local.name).replace(/\{1\}/,t._calendar.local.name);var e=this._year!==t._year?this._year-t._year:this._month!==t._month?this.monthOfYear()-t.monthOfYear():this._day-t._day;return 0===e?0:e<0?-1:1},calendar:function(){return this._calendar},toJD:function(){return this._calendar.toJD(this)},fromJD:function(t){return this._calendar.fromJD(t)},toJSDate:function(){return this._calendar.toJSDate(this)},fromJSDate:function(t){return this._calendar.fromJSDate(t)},toString:function(){return(this.year()<0?"-":"")+o(Math.abs(this.year()),4)+"-"+o(this.month(),2)+"-"+o(this.day(),2)}}),n(s.prototype,{_validateLevel:0,newDate:function(t,e,r){return null==t?this.today():(t.year&&(this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),r=t.day(),e=t.month(),t=t.year()),new a(this,t,e,r))},today:function(){return this.fromJSDate(new Date)},epoch:function(t){return this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear).year()<0?this.local.epochs[0]:this.local.epochs[1]},formatYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear);return(e.year()<0?"-":"")+o(Math.abs(e.year()),4)},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear),12},monthOfYear:function(t,e){var r=this._validate(t,e,this.minDay,c.local.invalidMonth||c.regionalOptions[""].invalidMonth);return(r.month()+this.monthsInYear(r)-this.firstMonth)%this.monthsInYear(r)+this.minMonth},fromMonthOfYear:function(t,e){var r=(e+this.firstMonth-2*this.minMonth)%this.monthsInYear(t)+this.minMonth;return this._validate(t,r,this.minDay,c.local.invalidMonth||c.regionalOptions[""].invalidMonth),r},daysInYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear);return this.leapYear(e)?366:365},dayOfYear:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate);return n.toJD()-this.newDate(n.year(),this.fromMonthOfYear(n.year(),this.minMonth),this.minDay).toJD()+1},daysInWeek:function(){return 7},dayOfWeek:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate);return(Math.floor(this.toJD(n))+2)%this.daysInWeek()},extraInfo:function(t,e,r){return this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),{}},add:function(t,e,r){return this._validate(t,this.minMonth,this.minDay,c.local.invalidDate||c.regionalOptions[""].invalidDate),this._correctAdd(t,this._add(t,e,r),e,r)},_add:function(t,e,r){if(this._validateLevel++,"d"===r||"w"===r){var n=t.toJD()+e*("w"===r?this.daysInWeek():1),i=t.calendar().fromJD(n);return this._validateLevel--,[i.year(),i.month(),i.day()]}try{var a=t.year()+("y"===r?e:0),o=t.monthOfYear()+("m"===r?e:0);i=t.day();"y"===r?(t.month()!==this.fromMonthOfYear(a,o)&&(o=this.newDate(a,t.month(),this.minDay).monthOfYear()),o=Math.min(o,this.monthsInYear(a)),i=Math.min(i,this.daysInMonth(a,this.fromMonthOfYear(a,o)))):"m"===r&&(!function(t){for(;oe-1+t.minMonth;)a++,o-=e,e=t.monthsInYear(a)}(this),i=Math.min(i,this.daysInMonth(a,this.fromMonthOfYear(a,o))));var s=[a,this.fromMonthOfYear(a,o),i];return this._validateLevel--,s}catch(t){throw this._validateLevel--,t}},_correctAdd:function(t,e,r,n){if(!(this.hasYearZero||"y"!==n&&"m"!==n||0!==e[0]&&t.year()>0==e[0]>0)){var i={y:[1,1,"y"],m:[1,this.monthsInYear(-1),"m"],w:[this.daysInWeek(),this.daysInYear(-1),"d"],d:[1,this.daysInYear(-1),"d"]}[n],a=r<0?-1:1;e=this._add(t,r*i[0]+a*i[1],i[2])}return t.date(e[0],e[1],e[2])},set:function(t,e,r){this._validate(t,this.minMonth,this.minDay,c.local.invalidDate||c.regionalOptions[""].invalidDate);var n="y"===r?e:t.year(),i="m"===r?e:t.month(),a="d"===r?e:t.day();return"y"!==r&&"m"!==r||(a=Math.min(a,this.daysInMonth(n,i))),t.date(n,i,a)},isValid:function(t,e,r){this._validateLevel++;var n=this.hasYearZero||0!==t;if(n){var i=this.newDate(t,e,this.minDay);n=e>=this.minMonth&&e-this.minMonth=this.minDay&&r-this.minDay13.5?13:1),c=i-(l>2.5?4716:4715);return c<=0&&c--,this.newDate(c,l,s)},toJSDate:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),i=new Date(n.year(),n.month()-1,n.day());return i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i.setHours(i.getHours()>12?i.getHours()+2:0),i},fromJSDate:function(t){return this.newDate(t.getFullYear(),t.getMonth()+1,t.getDate())}});var c=e.exports=new i;c.cdate=a,c.baseCalendar=s,c.calendars.gregorian=l},{"object-assign":437}],549:[function(t,e,r){var n=t("object-assign"),i=t("./main");n(i.regionalOptions[""],{invalidArguments:"Invalid arguments",invalidFormat:"Cannot format a date from another calendar",missingNumberAt:"Missing number at position {0}",unknownNameAt:"Unknown name at position {0}",unexpectedLiteralAt:"Unexpected literal at position {0}",unexpectedText:"Additional text found at end"}),i.local=i.regionalOptions[""],n(i.cdate.prototype,{formatDate:function(t,e){return"string"!=typeof t&&(e=t,t=""),this._calendar.formatDate(t||"",this,e)}}),n(i.baseCalendar.prototype,{UNIX_EPOCH:i.instance().newDate(1970,1,1).toJD(),SECS_PER_DAY:86400,TICKS_EPOCH:i.instance().jdEpoch,TICKS_PER_DAY:864e9,ATOM:"yyyy-mm-dd",COOKIE:"D, dd M yyyy",FULL:"DD, MM d, yyyy",ISO_8601:"yyyy-mm-dd",JULIAN:"J",RFC_822:"D, d M yy",RFC_850:"DD, dd-M-yy",RFC_1036:"D, d M yy",RFC_1123:"D, d M yyyy",RFC_2822:"D, d M yyyy",RSS:"D, d M yy",TICKS:"!",TIMESTAMP:"@",W3C:"yyyy-mm-dd",formatDate:function(t,e,r){if("string"!=typeof t&&(r=e,e=t,t=""),!e)return"";if(e.calendar()!==this)throw i.local.invalidFormat||i.regionalOptions[""].invalidFormat;t=t||this.local.dateFormat;for(var n,a,o,s,l=(r=r||{}).dayNamesShort||this.local.dayNamesShort,c=r.dayNames||this.local.dayNames,u=r.monthNumbers||this.local.monthNumbers,f=r.monthNamesShort||this.local.monthNamesShort,h=r.monthNames||this.local.monthNames,p=(r.calculateWeek||this.local.calculateWeek,function(e,r){for(var n=1;w+n1}),d=function(t,e,r,n){var i=""+e;if(p(t,n))for(;i.length1},x=function(t,r){var n=y(t,r),a=[2,3,n?4:2,n?4:2,10,11,20]["oyYJ@!".indexOf(t)+1],o=new RegExp("^-?\\d{1,"+a+"}"),s=e.substring(A).match(o);if(!s)throw(i.local.missingNumberAt||i.regionalOptions[""].missingNumberAt).replace(/\{0\}/,A);return A+=s[0].length,parseInt(s[0],10)},b=this,_=function(){if("function"==typeof l){y("m");var t=l.call(b,e.substring(A));return A+=t.length,t}return x("m")},w=function(t,r,n,a){for(var o=y(t,a)?n:r,s=0;s-1){p=1,d=g;for(var E=this.daysInMonth(h,p);d>E;E=this.daysInMonth(h,p))p++,d-=E}return f>-1?this.fromJD(f):this.newDate(h,p,d)},determineDate:function(t,e,r,n,i){r&&"object"!=typeof r&&(i=n,n=r,r=null),"string"!=typeof n&&(i=n,n="");var a=this;return e=e?e.newDate():null,t=null==t?e:"string"==typeof t?function(t){try{return a.parseDate(n,t,i)}catch(t){}for(var e=((t=t.toLowerCase()).match(/^c/)&&r?r.newDate():null)||a.today(),o=/([+-]?[0-9]+)\s*(d|w|m|y)?/g,s=o.exec(t);s;)e.add(parseInt(s[1],10),s[2]||"d"),s=o.exec(t);return e}(t):"number"==typeof t?isNaN(t)||t===1/0||t===-1/0?e:a.today().add(t,"d"):a.newDate(t)}})},{"./main":548,"object-assign":437}],550:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array",{offset:[1],array:0},"scalar","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":134}],551:[function(t,e,r){"use strict";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t("./lib/zc-core")},{"./lib/zc-core":550}],552:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],553:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:i({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:i({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750,"../../plots/font_attributes":771,"./arrow_paths":552}],554:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=i.getFromId(t,e.xref),n=i.getFromId(t,e.yref);e._extremes={},r&&s(e,r),n&&s(e,n)})}function s(t,e){var r,n=e._id,a=n.charAt(0),o=t[a],s=t["a"+a],l=t[a+"ref"],c=t["a"+a+"ref"],u=t["_"+a+"padplus"],f=t["_"+a+"padminus"],h={x:1,y:-1}[a]*t[a+"shift"],p=3*t.arrowsize*t.arrowwidth||0,d=p+h,g=p-h,v=3*t.startarrowsize*t.arrowwidth||0,m=v+h,y=v-h;if(c===l){var x=i.findExtremes(e,[e.r2c(o)],{ppadplus:d,ppadminus:g}),b=i.findExtremes(e,[e.r2c(s)],{ppadplus:Math.max(u,m),ppadminus:Math.max(f,y)});r={min:[x.min[0],b.min[0]],max:[x.max[0],b.max[0]]}}else m=s?m+s:m,y=s?y-s:y,r=i.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(u,d,m),ppadminus:Math.max(f,g,y)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([a,o],t)}},{"../../lib":696,"../../plots/cartesian/axes":744,"./draw":559}],555:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,i,a,o,l,c,u=t._fullLayout.annotations,f=[],h=[],p=[],d=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,s,l=o(t,e),c=l.on,u=l.off.concat(l.explicitOff),f={},h=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var q=!1,H=["x","y"],G=0;G1)&&(Q===K?((lt=tt.r2fraction(e["a"+J]))<0||lt>1)&&(q=!0):q=!0),W=tt._offset+tt.r2p(e[J]),Z=.5}else"x"===J?(X=e[J],W=b.l+b.w*X):(X=1-e[J],W=b.t+b.h*X),Z=e.showarrow?.5:X;if(e.showarrow){st.head=W;var ct=e["a"+J];$=rt*U(.5,e.xanchor)-nt*U(.5,e.yanchor),Q===K?(st.tail=tt._offset+tt.r2p(ct),Y=$):(st.tail=W+ct,Y=$+ct),st.text=st.tail+$;var ut=x["x"===J?"width":"height"];if("paper"===K&&(st.head=o.constrain(st.head,1,ut-1)),"pixel"===Q){var ft=-Math.max(st.tail-3,st.text),ht=Math.min(st.tail+3,st.text)-ut;ft>0?(st.tail+=ft,st.text+=ft):ht>0&&(st.tail-=ht,st.text-=ht)}st.tail+=ot,st.head+=ot}else Y=$=it*U(Z,at),st.text=W+$;st.text+=ot,$+=ot,Y+=ot,e["_"+J+"padplus"]=it/2+Y,e["_"+J+"padminus"]=it/2-Y,e["_"+J+"size"]=it,e["_"+J+"shift"]=$}if(t._dragging||!q){var pt=0,dt=0;if("left"!==e.align&&(pt=(w-m)*("center"===e.align?.5:1)),"top"!==e.valign&&(dt=(O-y)*("middle"===e.valign?.5:1)),u)n.select("svg").attr({x:R+pt-1,y:R+dt}).call(c.setClipUrl,F?T:null);else{var gt=R+dt-d.top,vt=R+pt-d.left;V.call(f.positionText,vt,gt).call(c.setClipUrl,F?T:null)}N.select("rect").call(c.setRect,R,R,w,O),B.call(c.setRect,P/2,P/2,D-P,j-P),I.call(c.setTranslate,Math.round(S.x.text-D/2),Math.round(S.y.text-j/2)),L.attr({transform:"rotate("+E+","+S.x.text+","+S.y.text+")"});var mt,yt=function(r,n){C.selectAll(".annotation-arrow-g").remove();var u=S.x.head,f=S.y.head,h=S.x.tail+r,d=S.y.tail+n,m=S.x.text+r,y=S.y.text+n,x=o.rotationXYMatrix(E,m,y),w=o.apply2DTransform(x),T=o.apply2DTransform2(x),z=+B.attr("width"),O=+B.attr("height"),P=m-.5*z,D=P+z,R=y-.5*O,F=R+O,N=[[P,R,P,F],[P,F,D,F],[D,F,D,R],[D,R,P,R]].map(T);if(!N.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){N.forEach(function(t){var e=o.segmentsIntersect(h,d,u,f,t[0],t[1],t[2],t[3]);e&&(h=e.x,d=e.y)});var j=e.arrowwidth,V=e.arrowcolor,U=e.arrowside,q=C.append("g").style({opacity:l.opacity(V)}).classed("annotation-arrow-g",!0),H=q.append("path").attr("d","M"+h+","+d+"L"+u+","+f).style("stroke-width",j+"px").call(l.stroke,l.rgb(V));if(g(H,U,e),_.annotationPosition&&H.node().parentNode&&!a){var G=u,W=f;if(e.standoff){var Y=Math.sqrt(Math.pow(u-h,2)+Math.pow(f-d,2));G+=e.standoff*(h-u)/Y,W+=e.standoff*(d-f)/Y}var X,Z,$=q.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(h-G)+","+(d-W),transform:"translate("+G+","+W+")"}).style("stroke-width",j+6+"px").call(l.stroke,"rgba(0,0,0,0)").call(l.fill,"rgba(0,0,0,0)");p.init({element:$.node(),gd:t,prepFn:function(){var t=c.getTranslate(I);X=t.x,Z=t.y,s&&s.autorange&&k(s._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(X,Z),i=n[0]+t,a=n[1]+r;I.call(c.setTranslate,i,a),M("x",s?s.p2r(s.r2p(e.x)+t):e.x+t/b.w),M("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/b.h),e.axref===e.xref&&M("ax",s.p2r(s.r2p(e.ax)+t)),e.ayref===e.yref&&M("ay",v.p2r(v.r2p(e.ay)+r)),q.attr("transform","translate("+t+","+r+")"),L.attr({transform:"rotate("+E+","+i+","+a+")"})},doneFn:function(){i.call("relayout",t,A());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&yt(0,0),z)p.init({element:I.node(),gd:t,prepFn:function(){mt=L.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?M("ax",s.p2r(s.r2p(e.ax)+t)):M("ax",e.ax+t),e.ayref===e.yref?M("ay",v.p2r(v.r2p(e.ay)+r)):M("ay",e.ay+r),yt(t,r);else{if(a)return;var i,o;if(s)i=s.p2r(s.r2p(e.x)+t);else{var l=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-l/2;i=p.align(c+t/b.w,l,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-r/b.h,u,0,1,e.yanchor)}M("x",i),M("y",o),s&&v||(n=p.getCursor(s?.5:i,v?.5:o,e.xanchor,e.yanchor))}L.attr({transform:"translate("+t+","+r+")"+mt}),h(I,n)},doneFn:function(){h(I),i.call("relayout",t,A());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else I.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,m=f.backoff*p+r.standoff,y=h.backoff*d+r.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},s={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-s.x,b=o.y-s.y;if(c=(l=Math.atan2(b,x))+Math.PI,m&&y&&m+y>Math.sqrt(x*x+b*b))return void z();if(m){if(m*m>x*x+b*b)return void z();var _=m*Math.cos(l),w=m*Math.sin(l);s.x+=_,s.y+=w,t.attr({x2:s.x,y2:s.y})}if(y){if(y*y>x*x+b*b)return void z();var k=y*Math.cos(l),M=y*Math.sin(l);o.x-=k,o.y-=M,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var A=u.getTotalLength(),T="";if(A1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l._pdata=i(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*r[0],e.yaxis.r2l(l.y)*r[1],e.zaxis.r2l(l.z)*r[2]]),n(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":796,"../annotations/draw":559}],566:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var a=r.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return a?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}a.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},a.rgb=function(t){return a.tinyRGB(n(t))},a.opacity=function(t){return t?n(t).getAlpha():0},a.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},a.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var i=n(e||l).toRgb(),a=1===i.a?i:{r:255*(1-i.a)+i.r*i.a,g:255*(1-i.a)+i.g*i.a,b:255*(1-i.a)+i.b*i.a},o={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},a.contrast=function(t,e,r){var i=n(t);return 1!==i.getAlpha()&&(i=n(a.combine(t,l))),(i.isDark()?e?i.lighten(e):l:r?i.darken(r):s).toString()},a.stroke=function(t,e){var r=n(e);t.style({stroke:a.tinyRGB(r),"stroke-opacity":r.getAlpha()})},a.fill=function(t,e){var r=n(e);t.style({fill:a.tinyRGB(r),"fill-opacity":r.getAlpha()})},a.clean=function(t){if(t&&"object"==typeof t){var e,r,n,i,o=Object.keys(t);for(e=0;e0?S>=P:S<=P));E++)S>R&&S0?S>=P:S<=P));E++)S>C[0]&&S1){var at=Math.pow(10,Math.floor(Math.log(it)/Math.LN10));rt*=at*c.roundUp(it/at,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(tt.tick0=0)}tt.dtick=rt}tt.domain=[$+Y,$+H-Y],tt.setScale();var ot=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(M.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(M.cbbg,!0),t.append("g").classed(M.cbfills,!0),t.append("g").classed(M.cblines,!0),t.append("g").classed(M.cbaxis,!0).classed(M.crisp,!0),t.append("g").classed(M.cbtitleunshift,!0).append("g").classed(M.cbtitle,!0),t.append("rect").classed(M.cboutline,!0),t.select(".cbtitle").datum(0)})});ot.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var st=ot.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")");tt._axislayer=ot.select(".cbaxis");var lt=0;if(-1!==["top","bottom"].indexOf(r.titleside)){var ct,ut=k.l+(r.x+G)*k.w,ft=tt.titlefont.size;ct="top"===r.titleside?(1-($+H-Y))*k.h+k.t+3+.75*ft:(1-($+Y))*k.h+k.t-3-.25*ft,mt(tt._id+"title",{attributes:{x:ut,y:ct,"text-anchor":"start"}})}var ht,pt,dt,gt=c.syncOrAsync([a.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.titleside)){var a=ot.select(".cbtitle"),o=a.select("text"),l=[-r.outlinewidth/2,r.outlinewidth/2],u=a.select(".h"+tt._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*m),u?(lt=h.bBox(u).height)>f&&(l[1]-=(lt-f)/2):o.node()&&!o.classed(M.jsPlaceholder)&&(lt=h.bBox(o.node()).height),lt){if(lt+=5,"top"===r.titleside)tt.domain[1]-=lt/k.h,l[1]*=-1;else{tt.domain[0]+=lt/k.h;var p=g.lineCount(o);l[1]+=(1-p)*f}a.attr("transform","translate("+l+")"),tt.setScale()}}ot.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-tt.domain[1]))+")"),tt._axislayer.attr("transform","translate(0,"+Math.round(-k.t)+")");var d=ot.select(".cbfills").selectAll("rect.cbfill").data(z);d.enter().append("rect").classed(M.cbfill,!0).style("stroke","none"),d.exit().remove();var y=C.map(tt.c2p).map(Math.round).sort(function(t,e){return t-e});d.each(function(a,o){var s=[0===o?C[0]:(z[o]+z[o-1])/2,o===z.length-1?C[1]:(z[o]+z[o+1])/2].map(tt.c2p).map(Math.round);s[1]=c.constrain(s[1]+(s[1]>s[0])?1:-1,y[0],y[1]);var l=n.select(this).attr({x:X,width:Math.max(V,2),y:n.min(s),height:Math.max(n.max(s)-n.min(s),2)});if(r.fillgradient)h.gradient(l,t,e,"vertical",r.fillgradient,"fill");else{var u=I(a).replace("e-","");l.attr("fill",i(u).toHexString())}});var x=ot.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?L:[]);return x.enter().append("path").classed(M.cbline,!0),x.exit().remove(),x.each(function(t){n.select(this).attr("d","M"+X+","+(Math.round(tt.c2p(t))+r.line.width/2%1)+"h"+V).call(h.lineGroupStyle,r.line.width,O(t),r.line.dash)}),tt._axislayer.selectAll("g."+tt._id+"tick,path").remove(),tt._pos=X+V+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),tt.side="right",c.syncOrAsync([function(){return s.doTicksSingle(t,tt,!0)},function(){if(-1===["top","bottom"].indexOf(r.titleside)){var e=tt.titlefont.size,i=tt._offset+tt._length/2,a=k.l+(tt.position||0)*k.w+("right"===tt.side?10+e*(tt.showticklabels?1:.5):-10-e*(tt.showticklabels?.5:0));mt("h"+tt._id+"title",{avoid:{selection:n.select(t).selectAll("g."+tt._id+"tick"),side:r.titleside,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:a,y:i,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},a.previousPromises,function(){var n=V+r.outlinewidth/2+h.bBox(tt._axislayer.node()).width;if((F=st.select("text")).node()&&!F.classed(M.jsPlaceholder)){var i,o=st.select(".h"+tt._id+"title-math-group").node();i=o&&-1!==["top","bottom"].indexOf(r.titleside)?h.bBox(o).width:h.bBox(st.node()).right-X-k.l,n=Math.max(n,i)}var s=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,l=J-K;ot.select(".cbbg").attr({x:X-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:K-W,width:Math.max(s,2),height:Math.max(l+2*W,2)}).call(p.fill,r.bgcolor).call(p.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),ot.selectAll(".cboutline").attr({x:X,y:K+r.ypad+("top"===r.titleside?lt:0),width:Math.max(V,2),height:Math.max(l-2*r.ypad-lt,2)}).call(p.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var c=({center:.5,right:1}[r.xanchor]||0)*s;ot.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=y[r.yanchor],d=x[r.yanchor];"pixels"===r.lenmode?(u.y=r.y,u.t=l*f,u.b=l*d):(u.t=u.b=0,u.yt=r.y+r.len*f,u.yb=r.y-r.len*d);var g=y[r.xanchor],v=x[r.xanchor];if("pixels"===r.thicknessmode)u.x=r.x,u.l=s*g,u.r=s*v;else{var m=s-V;u.l=m*g,u.r=m*v,u.xl=r.x-r.thickness*g,u.xr=r.x+r.thickness*v}a.autoMargin(t,e,u)}],t);if(gt&>.then&&(t._promises||[]).push(gt),t._context.edits.colorbarPosition)l.init({element:ot.node(),gd:t,prepFn:function(){ht=ot.attr("transform"),f(ot)},moveFn:function(t,e){ot.attr("transform",ht+" translate("+t+","+e+")"),pt=l.align(Z+t/k.w,U,0,1,r.xanchor),dt=l.align($-e/k.h,H,0,1,r.yanchor);var n=l.getCursor(pt,dt,r.xanchor,r.yanchor);f(ot,n)},doneFn:function(){f(ot),void 0!==pt&&void 0!==dt&&o.call("restyle",t,{"colorbar.x":pt,"colorbar.y":dt},T().index)}});return gt}function vt(t,e){return c.coerce(Q,tt,w,t,e)}function mt(e,r){var n=T(),i="colorbar.title",a=n._module.colorbar.container;a&&(i=a+"."+i);var o={propContainer:tt,propName:i,traceIndex:n.index,placeholder:v._dfltTitle.colorbar,containerGroup:ot.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;ot.selectAll("."+s+",."+s+"-math-group").remove(),d.draw(t,e,u(o,r||{}))}v._infolayer.selectAll("g."+e).remove()}function T(){var r,n,i=e.substr(2);for(r=0;r=0?i.Reds:i.Blues,s.reversescale?a(y):y),l.autocolorscale||f("autocolorscale",!1))}},{"../../lib":696,"./flip_scale":582,"./scales":589}],579:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":589}],580:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var f,h=u.prefix,p=u.cLetter,d=h.slice(0,h.length-1),g=h?i.nestedProperty(t,d).get()||{}:t,v=h?i.nestedProperty(e,d).get()||{}:e,m=g[p+"min"],y=g[p+"max"],x=g.colorscale;c(h+p+"auto",!(n(m)&&n(y)&&m=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],583:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){if(e||(e=i),!t)return e;function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return"string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e}},{"./default_scale":579,"./is_valid_scale_array":587,"./scales":589}],584:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(i.isArrayOrTypedArray(o))for(var l=0;l4/3-s?o:s}},{}],591:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":696}],592:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),i=t("has-hover"),a=t("has-passive-events"),o=t("../../registry"),s=t("../../lib"),l=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function h(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,r,n,f,d,g,v,m,y=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;y._mouseDownTime||(y._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,a?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,r){return Math.abs(t)b&&(x=Math.max(x-1,1)),y._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!m){var r;try{r=new MouseEvent("click",e)}catch(t){var n=p(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(y),y._dragged=!1}else y._dragged=!1}},u.coverSlip=h},{"../../constants/interactions":672,"../../lib":696,"../../plots/cartesian/constants":750,"../../registry":827,"./align":590,"./cursor":591,"./unhover":593,"has-hover":393,"has-passive-events":394,"mouse-event-offset":419}],593:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=t("../../lib/throttle"),a=t("../../lib/get_graph_div"),o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,r){(t=a(t))._fullLayout&&i.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,r)},s.raw=function(t,e){var r=t._fullLayout,i=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&i&&t.emit("plotly_unhover",{event:e,points:i}))}},{"../../lib/events":684,"../../lib/get_graph_div":691,"../../lib/throttle":721,"../fx/constants":607}],594:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],595:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("tinycolor2"),o=t("../../registry"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,d=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){c.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,i){t.call(v.setPosition,e,r).call(v.setSize,n,i)},v.translatePoint=function(t,e,r,n){var a=r.c2p(t.x),o=n.c2p(t.y);return!!(i(a)&&i(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",a).attr("y",o):e.attr("transform","translate("+a+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var i=n.select(this);v.translatePoint(t,i,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,i,a){e.attr("display",r.isPtWithinRange(t,i)&&n.isPtWithinRange(t,a)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,i=e.yaxis;t.each(function(e){var a=e[0].trace,o=a.xcalendar,s=a.ycalendar,l="bar"===a.type?".bartext":".point,.textpoint";t.selectAll(l).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,i,o,s)})})}},v.crispRound=function(t,e,r){return e&&i(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,i){e.style("fill","none");var a=(((t||[])[0]||{}).trace||{}).line||{},o=r||a.width||0,l=i||a.dash||"";s.stroke(e,n||a.color),v.dashLine(e,l,o)},v.lineGroupStyle=function(t,e,r,i){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=i||a.dash||"";n.select(this).call(s.stroke,r||a.color).call(v.dashLine,l,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(s.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){n.select(this).call(s.fill,t[0].trace.fillcolor)})};var m=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(m).forEach(function(t){var e=m[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var y=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=y||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=n.format("~.1f"),M={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,i,o,l){for(var u=o.length,f=M[i],h=new Array(u),p=0;p=100,e.attr("d",b(u,l))}var f,h,p,d=!1;if(t.so)p=o.outlierwidth,h=o.outliercolor,f=a.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,h="mlc"in t?t.mlcc=n.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?s.defaultLine:o.color,c.isArrayOrTypedArray(a.color)&&(f=s.defaultLine,d=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):a.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(s.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var m=a.gradient,y=t.mgt;if(y?d=!0:y=m&&m.type,Array.isArray(y)&&(y=y[0],M[y]||(y=0)),y&&"none"!==y){var x=t.mgc;x?d=!0:x=m.color;var _=r.uid;d&&(_+="-"+t.i),v.gradient(e,i,_,y,[[0,x],[1,f]],"fill")}else s.fill(e,f);p&&s.stroke(e,h)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=d.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.marker||{},a=r.marker||{},s=n.marker||{},l=i.opacity,u=a.opacity,f=s.opacity,h=void 0!==u,d=void 0!==f;(c.isArrayOrTypedArray(l)||h||d)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?i.opacity:t.mo;return t.selected?h?u:e:d?f:p*e});var g=i.color,v=a.color,m=s.color;(v||m)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:m||e});var y=i.size,x=a.size,b=s.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||y/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.textfont||{},a=r.textfont||{},o=n.textfont||{},l=i.color,c=a.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||l;return t.selected?c||e:u||(c?e:s.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),i=e.marker||{},a=[];r.selectedOpacityFn&&a.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&a.push(function(t,e){s.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&a.push(function(t,e){var n=e.mx||i.symbol||0,a=r.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(n),a)),e.mrc2=a}),a.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var i;if(e.selectedpoints){var a=v.makeSelectedTextStyleFns(e);i=a.selectedTextColorFn}t.each(function(t){var a=n.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var s=t.tp||e.textposition,l=S(t,e),f=i?i(t):t.tc||e.textfont.color;a.call(v.font,t.tf||e.textfont.family,l,f).text(o).call(u.convertToTspans,r).call(T,s,l,t.mrc)}else a.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var i=n.select(this),a=r.selectedTextColorFn(t),o=t.tp||e.textposition,l=S(t,e);s.fill(i,a),T(i,o,l,t.mrc2||t.mrc)})}};var E=.5;function C(t,e,r,i){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,E/2),u=Math.pow(s*s+l*l,E/2),f=(u*u*a-c*c*s)*i,h=(u*u*o-c*c*l)*i,p=3*u*(c+u),d=3*c*(c+u);return[[n.round(e[0]+(p&&f/p),2),n.round(e[1]+(p&&h/p),2)],[n.round(e[0]-(d&&f/d),2),n.round(e[1]-(d&&h/d),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],i=[];for(r=1;r=1e4&&(v.savedBBoxes={},O=0),r&&(v.savedBBoxes[r]=m),O++,c.extendFlat({},m)},v.setClipUrl=function(t,e){if(e){if(void 0===v.baseUrl){var r=n.select("base");r.size()&&r.attr("href")?v.baseUrl=window.location.href.split("#")[0]:v.baseUrl=""}t.attr("clip-path","url("+v.baseUrl+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||0,r=r||0,a=a.replace(/(\btranslate\(.*?\);?)/,"").trim(),a=(a+=" translate("+e+", "+r+")").trim(),t[i]("transform",a),a},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||1,r=r||1,a=a.replace(/(\bscale\(.*?\);?)/,"").trim(),a=(a+=" scale("+e+", "+r+")").trim(),t[i]("transform",a),a};var P=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(P,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var D=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,i=n.select(this),a=i.select("text");if(a.node()){var o=parseFloat(a.attr("x")||0),s=parseFloat(a.attr("y")||0),l=(i.attr("transform")||"").match(D);t=1===e&&1===r?[]:["translate("+o+","+s+")","scale("+e+","+r+")","translate("+-o+","+-s+")"],l&&t.push(l),i.attr("transform",t.join(" "))}})}},{"../../constants/alignment":668,"../../constants/interactions":672,"../../constants/xmlns_namespaces":674,"../../lib":696,"../../lib/svg_text_utils":720,"../../registry":827,"../../traces/scatter/make_bubble_size_func":1060,"../../traces/scatter/subtypes":1067,"../color":570,"../colorscale":585,"./symbol_defs":596,d3:148,"fast-isnumeric":214,tinycolor2:514}],596:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(-.309*t,2);return"M"+e+","+a+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:148}],597:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],598:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../registry"),a=t("../../plots/cartesian/axes"),o=t("./compute_error");function s(t,e,r,i){var s=e["error_"+i]||{},l=[];if(s.visible&&-1!==["linear","log"].indexOf(r.type)){for(var c=o(s),u=0;u0;t.each(function(t){var u,f=t[0].trace,h=f.error_x||{},p=f.error_y||{};f.ids&&(u=function(t){return t.id});var d=o.hasMarkers(f)&&f.marker.maxdisplayed>0;p.visible||h.visible||(t=[]);var g=n.select(this).selectAll("g.errorbar").data(t,u);if(g.exit().remove(),t.length){h.visible||g.selectAll("path.xerror").remove(),p.visible||g.selectAll("path.yerror").remove(),g.style("opacity",1);var v=g.enter().append("g").classed("errorbar",!0);c&&v.style("opacity",0).transition().duration(r.duration).style("opacity",1),a.setClipUrl(g,e.layerClipId),g.each(function(t){var e=n.select(this),a=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),i(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),i(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,s,l);if(!d||t.vis){var o,u=e.select("path.yerror");if(p.visible&&i(a.x)&&i(a.yh)&&i(a.ys)){var f=p.width;o="M"+(a.x-f)+","+a.yh+"h"+2*f+"m-"+f+",0V"+a.ys,a.noYS||(o+="m-"+f+",0h"+2*f),!u.size()?u=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):c&&(u=u.transition().duration(r.duration).ease(r.easing)),u.attr("d",o)}else u.remove();var g=e.select("path.xerror");if(h.visible&&i(a.y)&&i(a.xh)&&i(a.xs)){var v=(h.copy_ystyle?p:h).width;o="M"+a.xh+","+(a.y-v)+"v"+2*v+"m0,-"+v+"H"+a.xs,a.noXS||(o+="m0,-"+v+"v"+2*v),!g.size()?g=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):c&&(g=g.transition().duration(r.duration).ease(r.easing)),g.attr("d",o)}else g.remove()}})}})}},{"../../traces/scatter/subtypes":1067,"../drawing":595,d3:148,"fast-isnumeric":214}],603:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":570,d3:148}],604:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":771}],605:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry");function a(t,e,r,i){i=i||n.identity,Array.isArray(t)&&(e[0][r]=i(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var s=0;s=0&&r.index-1&&o.length>x&&(o=x>3?o.substr(0,x-3)+"...":o.substr(0,x))}void 0!==t.zLabel?(void 0!==t.xLabel&&(c+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(c+="y: "+t.yLabel+"
"),c+=(c?"z: ":"")+t.zLabel):L&&t[i+"Label"]===M?c=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(c=t.yLabel):c=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(c+=(c?"
":"")+t.text),void 0!==t.extraText&&(c+=(c?"
":"")+t.extraText),""===c&&(""===o&&e.remove(),c=o);var b=e.select("text.nums").call(u.font,t.fontFamily||d,t.fontSize||g,t.fontColor||y).text(c).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),_=e.select("text.name"),A=0;o&&o!==c?(_.call(u.font,t.fontFamily||d,t.fontSize||g,v).text(o).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),A=_.node().getBoundingClientRect().width+2*k):(_.remove(),e.select("rect").remove()),e.select("path").style({fill:p,stroke:y});var T,z,O=b.node().getBoundingClientRect(),I=t.xa._offset+(t.x0+t.x1)/2,P=t.ya._offset+(t.y0+t.y1)/2,D=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),B=O.width+w+k+A;t.ty0=S-O.top,t.bx=O.width+2*k,t.by=O.height+2*k,t.anchor="start",t.txwidth=O.width,t.tx2width=A,t.offset=0,a?(t.pos=I,T=P+R/2+B<=C,z=P-R/2-B>=0,"top"!==t.idealAlign&&T||!z?T?(P+=R/2,t.anchor="start"):t.anchor="middle":(P-=R/2,t.anchor="end")):(t.pos=P,T=I+D/2+B<=E,z=I-D/2-B>=0,"left"!==t.idealAlign&&T||!z?T?(I+=D/2,t.anchor="start"):t.anchor="middle":(I-=D/2,t.anchor="end")),b.attr("text-anchor",t.anchor),A&&_.attr("text-anchor",t.anchor),e.attr("transform","translate("+I+","+P+")"+(a?"rotate("+m+")":""))}),R}function A(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var i="end"===t.anchor?-1:1,a=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],s=o*(w+k),c=s+o*(t.txwidth+k),f=0,h=t.offset;"middle"===t.anchor&&(s-=t.tx2width/2,c+=t.txwidth/2+k),e&&(h*=-_,f=t.offset*b),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(h-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(i*w+f)+","+(w+h)+"v"+(t.by/2-w)+"h"+i*t.bx+"v-"+t.by+"H"+(i*w+f)+"V"+(h-w)+"Z"),a.call(l.positionText,s+f,h+t.ty0-t.by/2+k),t.tx2width&&(r.select("text.name").call(l.positionText,c+o*k+f,h+t.ty0-t.by/2+k),r.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,h-t.by/2-1,t.tx2width,t.by+2))}})}function T(t,e){var r=t.index,n=t.trace||{},i=t.cd[0],a=t.cd[r]||{},s=Array.isArray(r)?function(t,e){return o.castOption(i,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(a,n,t,e)};function l(e,r,n){var i=s(r,n);i&&(t[e]=i)}if(l("hoverinfo","hi","hoverinfo"),l("bgcolor","hbg","hoverlabel.bgcolor"),l("borderColor","hbc","hoverlabel.bordercolor"),l("fontFamily","htf","hoverlabel.font.family"),l("fontSize","hts","hoverlabel.font.size"),l("fontColor","htc","hoverlabel.font.color"),l("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function S(t,e){var r,n,i=e.container,o=e.fullLayout,s=e.event,l=!!t.hLinePoint,c=!!t.vLinePoint;if(i.selectAll(".spikeline").remove(),c||l){var h=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(l){var p,d,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(p=s.pointerX,d=s.pointerY):(p=r._offset+g.x,d=n._offset+g.y);var v,m,y=a.readability(g.color,h)<1.5?f.contrast(h):g.color,x=n.spikemode,b=n.spikethickness,_=n.spikecolor||y,w=n._boundingBox,k=(w.left+w.right)/2w[0]._length||et<0||et>k[0]._length)return h.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,D="xval"in e?g.flat(l,e.xval):g.p2c(w,tt),R="yval"in e?g.flat(l,e.yval):g.p2c(k,et),!i(D[0])||!i(R[0]))return o.warn("Fx.hover failed",e,t),h.unhoverRaw(t,e)}var it=1/0;for(F=0;FY&&($.splice(0,Y),it=$[0].distance),y&&0!==Z&&0===$.length){W.distance=Z,W.index=!1;var ct=j._module.hoverPoints(W,H,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=Z})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var ht=ft[0];i(ht.x0)&&i(ht.y0)&&(ut=vt(ht),(!K.vLinePoint||K.vLinePoint.spikeDistance>ut.spikeDistance)&&(K.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var dt=pt[0];i(dt.x0)&&i(dt.y0)&&(ut=vt(dt),(!K.hLinePoint||K.hLinePoint.spikeDistance>ut.spikeDistance)&&(K.hLinePoint=ut))}}}}function gt(t,e){for(var r,n=null,i=1/0,a=0;a1||$.length>1)||"closest"===P&&Q&&$.length>1,Ct=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),Lt={hovermode:P,rotateLabels:Et,bgColor:Ct,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},zt=M($,Lt,t);if(function(t,e,r){var n,i,a,o,s,l,c,u=0,f=1,h=t.map(function(t,n){var i=t[e],a="x"===i._id.charAt(0),o=i.range;return!n&&o&&o[0]>o[1]!==a&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(a?x:1)/2,pmin:0,pmax:a?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(a<.01)){if(i<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(l=t[o]).pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(c<=0);o--)(l=t[o]).pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(;!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&v.pmin===m.pmin&&v.pmax===m.pmax){for(s=g.length-1;s>=0;s--)g[s].dp+=i;for(d.push.apply(d,g),h.splice(o+1,1),c=0,s=d.length-1;s>=0;s--)c+=d[s].dp;for(a=c/d.length,s=d.length-1;s>=0;s--)d[s].dp-=a;n=!1}else o++}h.forEach(p)}for(o=h.length-1;o>=0;o--){var y=h[o];for(s=y.length-1;s>=0;s--){var b=y[s],_=t[b.i];_.offset=b.dp,_.del=b.del}}}($,Et?"xa":"ya",u),A(zt,Et),e.target&&e.target.tagName){var Ot=d.getComponentMethod("annotations","hasClickToShow")(t,Tt);c(n.select(e.target),Ot?"pointer":"")}if(!e.target||a||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}(t,0,At))return;At&&t.emit("plotly_unhover",{event:e,points:At});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:D,yvals:R})}(t,e,r,a)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0},i=n.select(e.container),a=e.outerContainer?n.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=M([r],o,e.gd);return A(s,o.rotateLabels),s.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0}}),i=n.select(e.container),a=e.outerContainer?n.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=M(r,o,e.gd),l=0;return s.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){h||p||d||"independent"===M("pattern")&&(h=!0),v._hasSubplotGrid=h;var x,b,_="top to bottom"===M("roworder"),w=h?.2:.1,k=h?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",M,w,x,y),y:u("y",M,k,b,m,_)}}else delete e.grid}function M(t,e){return n.coerce(r,v,l,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,i,a,o,s,l,u,h=t.grid||{},p=e._subplots,d=r._hasSubplotGrid,g=r.rows,v=r.columns,m="independent"===r.pattern,y=r._axisMap={};if(d){var x=h.subplots||[];l=r.subplots=new Array(g);var b=1;for(n=0;n=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],623:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes");e.exports={bgcolor:{valType:"color",editType:"legend"},bordercolor:{valType:"color",dflt:i.defaultLine,editType:"legend"},borderwidth:{valType:"number",min:0,dflt:0,editType:"legend"},font:n({editType:"legend"}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v",editType:"legend"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"],editType:"legend"},tracegroupgap:{valType:"number",min:0,dflt:10,editType:"legend"},x:{valType:"number",min:-2,max:3,dflt:1.02,editType:"legend"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left",editType:"legend"},y:{valType:"number",min:-2,max:3,dflt:1,editType:"legend"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"legend"},editType:"legend"}},{"../../plots/font_attributes":771,"../color/attributes":569}],624:[function(t,e,r){"use strict";e.exports={scrollBarWidth:6,scrollBarMinHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4,textOffsetX:40}},{}],625:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../../plot_api/plot_template"),o=t("./attributes"),s=t("../../plots/layout_attributes"),l=t("./helpers");e.exports=function(t,e,r){for(var c,u,f,h,p=t.legend||{},d=0,g=!1,v="normal",m=0;m1)){var x=a.newContainer(e,"legend");if(_("bgcolor",e.paper_bgcolor),_("bordercolor"),_("borderwidth"),i.coerceFont(_,"font",e.font),_("orientation"),"h"===x.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(c=0,f="left",u=1.1,h="bottom"):(c=0,f="left",u=-.1,h="top")}_("traceorder",v),l.isGrouped(e.legend)&&_("tracegroupgap"),_("x",c),_("xanchor",f),_("y",u),_("yanchor",h),i.noneOrAll(p,x,["x","y"])}function _(t,e){return i.coerce(p,x,o,t,e)}}},{"../../lib":696,"../../plot_api/plot_template":734,"../../plots/layout_attributes":799,"../../registry":827,"./attributes":623,"./helpers":629}],626:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib/events"),l=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),h=t("./handle_click"),p=t("./constants"),d=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,m=g.FROM_TL,y=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=t("./anchor_utils"),k=d.DBLCLICKDELAY;function M(t,e,r,n,i){var a=r.data()[0][0].trace,o={event:i,node:r.node(),curveNumber:a.index,expandedIndex:a._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(a._group&&(o.group=a._group),"pie"===a.type&&(o.label=r.datum()[0].label),!1!==s.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){h(r,t,n)},k);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==s.triggerHandler(t,"plotly_legenddoubleclick",o)&&h(r,t,n)}}function A(t,e,r){var n=t.data()[0][0],a=e._fullLayout,s=n.trace,l=o.traceIs(s,"pie"),u=s.index,h=l?n.label:s.name,d=e._context.edits.legendText&&!l,g=i.ensureSingle(t,"text","legendtext");function m(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,i,a=t.select("g[class*=math-group]"),o=a.node(),s=e._fullLayout.legend.font.size*v;if(o){var l=c.bBox(o);n=l.height,i=l.width,c.setTranslate(a,0,n/4)}else{var u=t.select(".legendtext"),h=f.lineCount(u),d=u.node();n=s*h,i=d?c.bBox(d).width:0;var g=s*(.3+(1-h)/2);f.positionText(u,p.textOffsetX,g)}n=Math.max(n,16)+3,r.height=n,r.width=i}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,a.legend.font).text(d?T(h,r):h),f.positionText(g,p.textOffsetX,0),d?g.call(f.makeEditable,{gd:e,text:h}).call(m).on("edit",function(t){this.text(T(t,r)).call(m);var a=n.trace._fullInput||{},s={};if(o.hasTransform(a,"groupby")){var l=o.getTransformIndices(a,"groupby"),c=l[l.length-1],f=i.keyedContainer(a,"transforms["+c+"].styles","target","value.name");f.set(n.trace._group,t),s=f.constructUpdate()}else s.name=t;return o.call("restyle",e,s,u)}):m(g)}function T(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function S(t,e){var r,a=1,o=i.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimek&&(a=Math.max(a-1,1)),M(e,r,t,a,n.event)}})}function E(t,e,r){var i=t._fullLayout,a=i.legend,o=a.borderwidth,s=_.isGrouped(a),l=0;if(a._width=0,a._height=0,_.isVertical(a))s&&e.each(function(t,e){c.setTranslate(this,0,e*a.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;c.setTranslate(this,o,5+o+a._height+r/2),a._height+=r,a._width=Math.max(a._width,n)}),a._width+=45+2*o,a._height+=10+2*o,s&&(a._height+=(a._lgroupsLength-1)*a.tracegroupgap),l=40;else if(s){for(var u=[a._width],f=e.data(),h=0,p=f.length;ho+w-k,r.each(function(t){var e=t[0],r=v?40+t[0].width:x;o+b+k+r>i._size.w&&(b=0,m+=y,a._height=a._height+y,y=0),c.setTranslate(this,o+b,5+o+e.height/2+m),a._width+=k+r,a._height=Math.max(a._height,e.height),b+=k+r,y=Math.max(e.height,y)}),a._width+=2*o,a._height+=10+2*o}a._width=Math.ceil(a._width),a._height=Math.ceil(a._height);var M=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");c.setRect(r,0,-e.height/2,(M?0:a._width)+l,e.height)})}function C(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");var n="top";w.isBottomAnchor(e)?n="bottom":w.isMiddleAnchor(e)&&(n="middle"),a.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*m[r],r:e._width*y[r],b:e._height*y[n],t:e._height*m[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var s=e.legend,f=e.showlegend&&x(t.calcdata,s),h=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void a.autoMargin(t,"legend");for(var d=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";w.isRightAnchor(e)?r="right":w.isCenterAnchor(e)&&(r="center");a.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*m[r],r:e._width*y[r],b:0,t:0})}(t):C(t);var h=e._size,d=h.l+h.w*s.x,g=h.t+h.h*(1-s.y);w.isRightAnchor(s)?d-=s._width:w.isCenterAnchor(s)&&(d-=s._width/2),w.isBottomAnchor(s)?g-=s._height:w.isMiddleAnchor(s)&&(g-=s._height/2);var v=s._width,x=h.w;v>x?(d=h.l,v=x):(d+v>u&&(d=u-v),d<0&&(d=0),v=Math.min(u-d,s._width));var b,_,k,A,T=s._height,S=h.h;if(T>S?(g=h.t,T=S):(g+T>f&&(g=f-T),g<0&&(g=0),T=Math.min(f-g,s._height)),c.setTranslate(z,d,g),D.on(".drag",null),z.on("wheel",null),s._height<=T||t._context.staticPlot)I.attr({width:v-s.borderwidth,height:T-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),c.setTranslate(P,0,0),O.select("rect").attr({width:v-2*s.borderwidth,height:T-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth}),c.setClipUrl(P,r),c.setRect(D,0,0,0,0),delete s._scrollY;else{var F,N,j=Math.max(p.scrollBarMinHeight,T*T/s._height),V=T-j-2*p.scrollBarMargin,U=s._height-T,q=V/U,H=Math.min(s._scrollY||0,U);I.attr({width:v-2*s.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:T-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),O.select("rect").attr({width:v-2*s.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:T-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth+H}),c.setClipUrl(P,r),W(H,j,q),z.on("wheel",function(){W(H=i.constrain(s._scrollY+n.event.deltaY/V*U,0,U),j,q),0!==H&&H!==U&&n.event.preventDefault()});var G=n.behavior.drag().on("dragstart",function(){F=n.event.sourceEvent.clientY,N=H}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||W(H=i.constrain((t.clientY-F)/q+N,0,U),j,q)});D.call(G)}function W(e,r,n){s._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(P,0,-e),c.setRect(D,v,p.scrollBarMargin+e*n,p.scrollBarWidth,r),O.select("rect").attr({y:s.borderwidth+e})}t._context.edits.legendPosition&&(z.classed("cursor-move",!0),l.init({element:z.node(),gd:t,prepFn:function(){var t=c.getTranslate(z);k=t.x,A=t.y},moveFn:function(t,e){var r=k+t,n=A+e;c.setTranslate(z,r,n),b=l.align(r,0,h.l,h.l+h.w,s.xanchor),_=l.align(n,0,h.t+h.h,h.t,s.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("relayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(r,n){var i=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});i.size()>0&&M(t,z,i,r,n)}}))}],t)}}},{"../../constants/alignment":668,"../../constants/interactions":672,"../../lib":696,"../../lib/events":684,"../../lib/svg_text_utils":720,"../../plots/plots":808,"../../registry":827,"../color":570,"../dragelement":592,"../drawing":595,"./anchor_utils":622,"./constants":624,"./get_legend_data":627,"./handle_click":628,"./helpers":629,"./style":631,d3:148}],627:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("./helpers");e.exports=function(t,e){var r,a,o={},s=[],l=!1,c={},u=0;function f(t,r){if(""!==t&&i.isGrouped(e))-1===s.indexOf(t)?(s.push(t),l=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+u;s.push(n),o[n]=[[r]],u++}}for(r=0;rr[1])return r[1]}return i}function d(t){return t[0]}if(u||f||h){var g={},v={};if(u){g.mc=p("marker.color",d),g.mx=p("marker.symbol",d),g.mo=p("marker.opacity",a.mean,[.2,1]),g.mlc=p("marker.line.color",d),g.mlw=p("marker.line.width",a.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var m=p("marker.size",a.mean,[2,16]);g.ms=m,v.marker.size=m}h&&(v.line={width:p("line.width",d,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",d),g.ts=10,g.tc=p("textfont.color",d),g.tf=p("textfont.family",d)),r=[a.minExtend(s,g)],(i=a.minExtend(c,v)).selectedpoints=null}var y=n.select(this).select("g.legendpoints"),x=y.selectAll("path.scatterpts").data(u?r:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,i,e),u&&(r[0].mrc=3);var b=y.selectAll("g.pointtext").data(f?r:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,i,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var i=e[r?"increasing":"decreasing"],a=i.line.width,o=n.select(this);o.style("stroke-width",a+"px").call(s.fill,i.fillcolor),a&&s.stroke(o,i.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var i=e[r?"increasing":"decreasing"],a=i.line.width,l=n.select(this);l.style("fill","none").call(o.dashLine,i.line.dash,a),a&&s.stroke(l,i.line.color)})})}},{"../../lib":696,"../../registry":827,"../../traces/pie/style_one":1029,"../../traces/scatter/subtypes":1067,"../color":570,"../drawing":595,d3:148}],632:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),s=t("../../../build/ploticon"),l=o._,c=e.exports={};function u(t,e){var r,i,o=e.currentTarget,s=o.getAttribute("data-attr"),l=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=a.list(t,null,!0),h="on";if("zoom"===s){var p,d="in"===l?.5:2,g=(1+d)/2,v=(1-d)/2;for(i=0;i1?(_=["toggleHover"],w=["resetViews"]):f?(b=["zoomInGeo","zoomOutGeo"],_=["hoverClosestGeo"],w=["resetGeo"]):u?(_=["hoverClosest3d"],w=["resetCameraDefault3d","resetCameraLastSave3d"]):g?(_=["toggleHover"],w=["resetViewMapbox"]):_=p?["hoverClosestGl2d"]:h?["hoverClosestPie"]:["toggleHover"];c&&(_=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!c&&!p||m||(b=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==w[0]&&(w=["resetScale2d"]));u?k=["zoom3d","pan3d","orbitRotation","tableRotation"]:(c||p)&&!m||d?k=["zoom2d","pan2d"]:g||f?k=["pan2d"]:v&&(k=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),i=0,a=0;a0?h+c:c;return{ppad:c,ppadplus:u?d:g,ppadminus:u?g:d}}return{ppad:c}}function u(t,e,r,n,i){var s="category"===t.type?t.r2c:t.d2c;if(void 0!==e)return[s(e),s(r)];if(n){var l,c,u,f,h=1/0,p=-1/0,d=n.match(a.segmentRE);for("date"===t.type&&(s=o.decodeDate(s)),l=0;lp&&(p=f)));return p>=h?[h,p]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:D?q(r.xanchor)+r.x0:q(r.x0),cy:R?H(r.yanchor)-r.y0:H(r.y0),r:a}).style(i).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:D?q(r.xanchor)+r.x1:q(r.x1),cy:R?H(r.yanchor)-r.y1:H(r.y1),r:a}).style(i).classed("cursor-grab",!0),n}():e,X={element:Y.node(),gd:t,prepFn:function(n){D&&(_=q(r.xanchor));R&&(w=H(r.yanchor));"path"===r.type?z=r.path:(m=D?r.x0:q(r.x0),y=R?r.y0:H(r.y0),x=D?r.x1:q(r.x1),b=R?r.y1:H(r.y1));mb?(k=y,S="y0",M=b,E="y1"):(k=b,S="y1",M=y,E="y0");Z(n),K(p,r),function(t,e,r){var n=e.xref,i=e.yref,o=a.getFromId(r,n),l=a.getFromId(r,i),c="";"paper"===n||o.autorange||(c+=n);"paper"===i||l.autorange||(c+=i);t.call(s.setClipUrl,c?"clip"+r._fullLayout._uid+c:null)}(e,r,t),X.moveFn="move"===O?$:J},doneFn:function(){u(e),Q(p),d(e,t,r),n.call("relayout",t,N.getUpdateObj())},clickFn:function(){Q(p)}};function Z(t){if(B)O="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=X.element.getBoundingClientRect(),n=r.right-r.left,i=r.bottom-r.top,a=t.clientX-r.left,o=t.clientY-r.top,s=!F&&n>I&&i>P&&!t.shiftKey?c.getCursor(a/n,1-o/i):"move";u(e,s),O=s.split("-")[0]}}function $(n,i){if("path"===r.type){var a=function(t){return t},o=a,s=a;D?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(q(t)+n)},V&&"date"===V.type&&(o=h.encodeDate(o))),R?j("yanchor",r.yanchor=W(w+i)):(s=function(t){return W(H(t)+i)},U&&"date"===U.type&&(s=h.encodeDate(s))),j("path",r.path=v(z,o,s))}else D?j("xanchor",r.xanchor=G(_+n)):(j("x0",r.x0=G(m+n)),j("x1",r.x1=G(x+n))),R?j("yanchor",r.yanchor=W(w+i)):(j("y0",r.y0=W(y+i)),j("y1",r.y1=W(b+i)));e.attr("d",g(t,r)),K(p,r)}function J(n,i){if(F){var a=function(t){return t},o=a,s=a;D?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(q(t)+n)},V&&"date"===V.type&&(o=h.encodeDate(o))),R?j("yanchor",r.yanchor=W(w+i)):(s=function(t){return W(H(t)+i)},U&&"date"===U.type&&(s=h.encodeDate(s))),j("path",r.path=v(z,o,s))}else if(B){if("resize-over-start-point"===O){var l=m+n,c=R?y-i:y+i;j("x0",r.x0=D?l:G(l)),j("y0",r.y0=R?c:W(c))}else if("resize-over-end-point"===O){var u=x+n,f=R?b-i:b+i;j("x1",r.x1=D?u:G(u)),j("y1",r.y1=R?f:W(f))}}else{var d=~O.indexOf("n")?k+i:k,N=~O.indexOf("s")?M+i:M,Y=~O.indexOf("w")?A+n:A,X=~O.indexOf("e")?T+n:T;~O.indexOf("n")&&R&&(d=k-i),~O.indexOf("s")&&R&&(N=M-i),(!R&&N-d>P||R&&d-N>P)&&(j(S,r[S]=R?d:W(d)),j(E,r[E]=R?N:W(N))),X-Y>I&&(j(C,r[C]=D?Y:G(Y)),j(L,r[L]=D?X:G(X)))}e.attr("d",g(t,r)),K(p,r)}function K(t,e){(D||R)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var a=q(D?e.xanchor:i.midRange(r?[e.x0,e.x1]:h.extractPathCoords(e.path,f.paramIsX))),o=H(R?e.yanchor:i.midRange(r?[e.y0,e.y1]:h.extractPathCoords(e.path,f.paramIsY)));if(a=h.roundPositionForSharpStrokeRendering(a,1),o=h.roundPositionForSharpStrokeRendering(o,1),D&&R){var s="M"+(a-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",s)}else if(D){var l="M"+(a-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",l)}else{var c="M"+(a-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",c)}}()}function Q(t){t.selectAll(".visual-cue").remove()}c.init(X),Y.node().onmousemove=Z}(t,x,r,e,p)}}function d(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");t.call(s.setClipUrl,n?"clip"+e._fullLayout._uid+n:null)}function g(t,e){var r,n,o,s,l,c,u,p,d=e.type,g=a.getFromId(t,e.xref),v=a.getFromId(t,e.yref),m=t._fullLayout._size;if(g?(r=h.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return m.l+m.w*t},v?(o=h.shapePositionToRange(v),s=function(t){return v._offset+v.r2p(o(t,!0))}):s=function(t){return m.t+m.h*(1-t)},"path"===d)return g&&"date"===g.type&&(n=h.decodeDate(n)),v&&"date"===v.type&&(s=h.decodeDate(s)),function(t,e,r){var n=t.path,a=t.xsizemode,o=t.ysizemode,s=t.xanchor,l=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,c=t.charAt(0),u=f.paramIsX[c],h=f.paramIsY[c],p=f.numParams[c],d=t.substr(1).replace(f.paramRE,function(t){return u[n]?t="pixel"===a?e(s)+Number(t):e(t):h[n]&&(t="pixel"===o?r(l)-Number(t):r(t)),++n>p&&(t="X"),t});return n>p&&(d=d.replace(/[\s,]*X.*/,""),i.log("Ignoring extra params in segment "+t)),c+d})}(e,n,s);if("pixel"===e.xsizemode){var y=n(e.xanchor);l=y+e.x0,c=y+e.x1}else l=n(e.x0),c=n(e.x1);if("pixel"===e.ysizemode){var x=s(e.yanchor);u=x-e.y0,p=x-e.y1}else u=s(e.y0),p=s(e.y1);if("line"===d)return"M"+l+","+u+"L"+c+","+p;if("rect"===d)return"M"+l+","+u+"H"+c+"V"+p+"H"+l+"Z";var b=(l+c)/2,_=(u+p)/2,w=Math.abs(b-l),k=Math.abs(_-u),M="A"+w+","+k,A=b+w+","+_;return"M"+A+M+" 0 1,1 "+(b+","+(_-k))+M+" 0 0,1 "+A+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,i=t.charAt(0),a=f.paramIsX[i],o=f.paramIsY[i],s=f.numParams[i];return i+t.substr(1).replace(f.paramRE,function(t){return n>=s?t:(a[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var i=0;i0&&(s=s.transition().duration(e.transition.duration).ease(e.transition.easing)),s.attr("transform","translate("+(o-.5*f.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function E(t,e){var r=t._dims;return r.inputAreaStart+f.stepInset+(r.inputAreaLength-2*f.stepInset)*Math.min(1,Math.max(0,e))}function C(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-f.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*f.stepInset-2*r.inputAreaStart)))}function L(t,e,r){var n=r._dims,i=s.ensureSingle(t,"rect",f.railTouchRectClass,function(n){n.call(A,e,t,r).style("pointer-events","all")});i.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,f.tickOffset+r.ticklen+n.labelHeight)}).call(a.fill,r.bgcolor).attr("opacity",0),o.setTranslate(i,0,n.currentValueTotalHeight)}function z(t,e){var r=e._dims,n=r.inputAreaLength-2*f.railInset,i=s.ensureSingle(t,"rect",f.railRectClass);i.attr({width:n,height:f.railWidth,rx:f.railRadius,ry:f.railRadius,"shape-rendering":"crispEdges"}).call(a.stroke,e.bordercolor).call(a.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(i,f.railInset,.5*(r.inputAreaWidth-f.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[f.name],n=[],i=0;i0?[0]:[]);function s(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),i.autoMargin(t,v(e))}if(a.enter().append("g").classed(f.containerClassName,!0).style("cursor","ew-resize"),a.exit().each(function(){n.select(this).selectAll("g."+f.groupClassName).each(s)}).remove(),0!==r.length){var l=a.selectAll("g."+f.groupClassName).data(r,m);l.enter().append("g").classed(f.groupClassName,!0),l.exit().each(s).remove();for(var c=0;c0||h<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[y.side];e.attr("transform","translate("+g+")")}}}O.call(I),L&&(C?O.on(".opacity",null):(S=0,E=!0,O.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),O.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==m?o.call("restyle",t,g,e,m):o.call("relayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(I)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return O.classed("js-placeholder",E),_}};var h=/ [XY][0-9]* /},{"../../constants/interactions":672,"../../lib":696,"../../lib/svg_text_utils":720,"../../plots/plots":808,"../../registry":827,"../color":570,"../drawing":595,d3:148,"fast-isnumeric":214}],662:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes"),l=t("../../plot_api/plot_template").templatedArray,c=l("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(l("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:a({},s,{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../../plots/font_attributes":771,"../../plots/pad_attributes":807,"../color/attributes":569}],663:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],664:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/array_container_defaults"),a=t("./attributes"),o=t("./constants").name,s=a.buttons;function l(t,e,r){function o(r,i){return n.coerce(t,e,a,r,i)}o("visible",i(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function r(r,i){return n.coerce(t,e,s,r,i)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){i(t,e,{name:o,handleItemDefaults:l})}},{"../../lib":696,"../../plots/array_container_defaults":740,"./attributes":662,"./constants":663}],665:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plots/plots"),a=t("../color"),o=t("../drawing"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),c=t("../legend/anchor_utils"),u=t("../../plot_api/plot_template").arrayEditor,f=t("../../constants/alignment").LINE_SPACING,h=t("./constants"),p=t("./scrollbox");function d(t){return t._index}function g(t,e){return+t.attr(h.menuIndexAttrName)===e._index}function v(t,e,r,n,i,a,o,s){e.active=o,u(t.layout,h.name,e).applyUpdate("active",o),"buttons"===e.type?y(t,n,null,null,e):"dropdown"===e.type&&(i.attr(h.menuIndexAttrName,"-1"),m(t,n,i,a,e),s||y(t,n,i,a,e))}function m(t,e,r,n,i){var a=s.ensureSingle(e,"g",h.headerClassName,function(t){t.style("pointer-events","all")}),l=i._dims,c=i.active,u=i.buttons[c]||h.blankHeaderOpts,f={y:i.pad.t,yPad:0,x:i.pad.l,xPad:0,index:0},p={width:l.headerWidth,height:l.headerHeight};a.call(x,i,u,t).call(S,i,f,p),s.ensureSingle(e,"text",h.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,i.font).text(h.arrowSymbol[i.direction])}).attr({x:l.headerWidth-h.arrowOffsetX+i.pad.l,y:l.headerHeight/2+h.textOffsetY+i.pad.t}),a.on("click",function(){r.call(E,String(g(r,i)?-1:i._index)),y(t,e,r,n,i)}),a.on("mouseover",function(){a.call(k)}),a.on("mouseout",function(){a.call(M,i)}),o.setTranslate(e,l.lx,l.ly)}function y(t,e,r,a,o){r||(r=e).attr("pointer-events","all");var l=function(t){return-1==+t.attr(h.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?h.dropdownButtonClassName:h.buttonClassName,u=r.selectAll("g."+c).data(s.filterVisible(l)),f=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(f.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var d=0,g=0,m=o._dims,y=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(y?g=m.headerHeight+h.gapButtonHeader:d=m.headerWidth+h.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(g=-h.gapButtonHeader+h.gapButton-m.openHeight),"dropdown"===o.type&&"left"===o.direction&&(d=-h.gapButtonHeader+h.gapButton-m.openWidth);var b={x:m.lx+d+o.pad.l,y:m.ly+g+o.pad.t,yPad:h.gapButton,xPad:h.gapButton,index:0},_={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(s,l){var c=n.select(this);c.call(x,o,s,t).call(S,o,b),c.on("click",function(){n.event.defaultPrevented||(v(t,o,0,e,r,a,l),s.execute&&i.executeAPICommand(t,s.method,s.args),t.emit("plotly_buttonclicked",{menu:o,button:s,active:o.active}))}),c.on("mouseover",function(){c.call(k)}),c.on("mouseout",function(){c.call(M,o),u.call(w,o)})}),u.call(w,o),y?(_.w=Math.max(m.openWidth,m.headerWidth),_.h=b.y-_.t):(_.w=b.x-_.l,_.h=Math.max(m.openHeight,m.headerHeight)),_.direction=o.direction,a&&(u.size()?function(t,e,r,n,i,a){var o,s,l,c=i.direction,u="up"===c||"down"===c,f=i._dims,p=i.active;if(u)for(s=0,l=0;l0?[0]:[]);if(o.enter().append("g").classed(h.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+h.headerGroupClassName).each(a)}).remove(),0!==r.length){var l=o.selectAll("g."+h.headerGroupClassName).data(r,d);l.enter().append("g").classed(h.headerGroupClassName,!0);for(var c=s.ensureSingle(o,"g",h.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,A=s.barLength+2*s.barPad,T=s.barWidth+2*s.barPad,S=d,E=v+m;E+T>c&&(E=c-T);var C=this.container.selectAll("rect.scrollbar-horizontal").data(M?[0]:[]);C.exit().on(".drag",null).remove(),C.enter().append("rect").classed("scrollbar-horizontal",!0).call(i.fill,s.barColor),M?(this.hbar=C.attr({rx:s.barRadius,ry:s.barRadius,x:S,y:E,width:A,height:T}),this._hbarXMin=S+A/2,this._hbarTranslateMax=w-A):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var L=m>k,z=s.barWidth+2*s.barPad,O=s.barLength+2*s.barPad,I=d+g,P=v;I+z>l&&(I=l-z);var D=this.container.selectAll("rect.scrollbar-vertical").data(L?[0]:[]);D.exit().on(".drag",null).remove(),D.enter().append("rect").classed("scrollbar-vertical",!0).call(i.fill,s.barColor),L?(this.vbar=D.attr({rx:s.barRadius,ry:s.barRadius,x:I,y:P,width:z,height:O}),this._vbarYMin=P+O/2,this._vbarTranslateMax=k-O):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var R=this.id,B=u-.5,F=L?f+z+.5:f+.5,N=h-.5,j=M?p+T+.5:p+.5,V=o._topdefs.selectAll("#"+R).data(M||L?[0]:[]);if(V.exit().remove(),V.enter().append("clipPath").attr("id",R).append("rect"),M||L?(this._clipRect=V.select("rect").attr({x:Math.floor(B),y:Math.floor(N),width:Math.ceil(F)-Math.floor(B),height:Math.ceil(j)-Math.floor(N)}),this.container.call(a.setClipUrl,R),this.bg.attr({x:d,y:v,width:g,height:m})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),M||L){var U=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(U);var q=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));M&&this.hbar.on(".drag",null).call(q),L&&this.vbar.on(".drag",null).call(q)}this.setTranslate(e,r)},s.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},s.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},s.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},s.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,i=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,i)-r)/(i-r)*(this.position.w-this._box.w)}if(this.vbar){var a=e+this._vbarYMin,s=a+this._vbarTranslateMax;e=(o.constrain(n.event.y,a,s)-a)/(s-a)*(this.position.h-this._box.h)}this.setTranslate(t,e)},s.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(a.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var i=t/r;this.hbar.call(a.setTranslate,t+i*this._hbarTranslateMax,e)}if(this.vbar){var s=e/n;this.vbar.call(a.setTranslate,t,e+s*this._vbarTranslateMax)}}},{"../../lib":696,"../color":570,"../drawing":595,d3:148}],668:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],669:[function(t,e,r){"use strict";e.exports={COMPARISON_OPS:["=","!=","<",">=",">","<="],COMPARISON_OPS2:["=","<",">=",">","<="],INTERVAL_OPS:["[]","()","[)","(]","][",")(","](",")["],SET_OPS:["{}","}{"],CONSTRAINT_REDUCTION:{"=":"=","<":"<","<=":"<",">":">",">=":">","[]":"[]","()":"[]","[)":"[]","(]":"[]","][":"][",")(":"][","](":"][",")[":"]["}}},{}],670:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],671:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],672:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],673:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],674:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],675:[function(t,e,r){"use strict";r.version="1.42.5",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config");for(var n=t("./registry"),i=r.register=n.register,a=t("./plot_api"),o=Object.keys(a),s=0;ss-1e-15}function c(t,e){return a(e-t,s)}function u(t,e){if(l(e))return!0;var r,n;e[0](n=i(n,s))&&(n+=s);var a=i(t,s),o=a+s;return a>=r&&a<=n||o>=r&&o<=n}function f(t,e,r,n,i,a,c){i=i||0,a=a||0;var u,f,h,p,d,g=l([r,n]);function v(t,e){return[t*Math.cos(e)+i,a-t*Math.sin(e)]}g?(u=0,f=o,h=s):r=i&&t<=a);var i,a},pathArc:function(t,e,r,n,i){return f(null,t,e,r,n,i,0)},pathSector:function(t,e,r,n,i){return f(null,t,e,r,n,i,1)},pathAnnulus:function(t,e,r,n,i,a){return f(t,e,r,n,i,a,1)}}},{"./mod":703}],678:[function(t,e,r){"use strict";var n=Array.isArray,i="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},a="undefined"==typeof DataView?function(){}:DataView;function o(t){return i.isView(t)&&!(t instanceof a)}function s(t){return n(t)||o(t)}r.isTypedArray=o,r.isArrayOrTypedArray=s,r.isArray1D=function(t){return!s(t[0])},r.ensureArray=function(t,e){return n(t)||(t=[]),t.length=e,t},r.concat=function(){var t,e,r,i,a,o,s,l,c=[],u=!0,f=0;for(r=0;ri.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var i="number"==typeof t;!0!==n.strict&&i?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return i(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(u(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var i=n.regex||l(r);"string"==typeof t&&i.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!l(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var i=t.split("+"),a=0;a=n&&t<=i?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),m=t.charAt(0);!c||"G"!==m&&"g"!==m||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:y);if(!k)return u;var M=k[1],A=k[3]||"1",T=Number(k[5]||1),S=Number(k[7]||0),E=Number(k[9]||0),C=Number(k[11]||0);if(c){if(2===M.length)return u;var L;M=Number(M);try{var z=v.getComponentMethod("calendars","getCal")(e);if(w){var O="i"===A.charAt(A.length-1);A=parseInt(A,10),L=z.newDate(M,z.toMonthIndex(M,A,O),T)}else L=z.newDate(M,Number(A),T)}catch(t){return u}return L?(L.toJD()-g)*f+S*h+E*p+C*d:u}M=2===M.length?(Number(M)+2e3-b)%100+b:Number(M),A-=1;var I=new Date(Date.UTC(2e3,A,T,S,E));return I.setUTCFullYear(M),I.getUTCMonth()!==A?u:I.getUTCDate()!==T?u:I.getTime()+C*d},n=r.MIN_MS=r.dateTime2ms("-9999"),i=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==u};var k=90*f,M=3*h,A=5*p;function T(t,e,r,n,i){if((e||r||n||i)&&(t+=" "+w(e,2)+":"+w(r,2),(n||i)&&(t+=":"+w(n,2),i))){for(var a=4;i%10==0;)a-=1,i/=10;t+="."+w(i,a)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=i))return u;e||(e=0);var a,o,s,c,y,x,b=Math.floor(10*l(t+.05,1)),w=Math.round(t-b/10);if(_(r)){var S=Math.floor(w/f)+g,E=Math.floor(l(t,f));try{a=v.getComponentMethod("calendars","getCal")(r).fromJD(S).formatDate("yyyy-mm-dd")}catch(t){a=m("G%Y-%m-%d")(new Date(w))}if("-"===a.charAt(0))for(;a.length<11;)a="-0"+a.substr(1);else for(;a.length<10;)a="0"+a;o=e=n+f&&t<=i-f))return u;var e=Math.floor(10*l(t+.05,1)),r=new Date(Math.round(t-e/10));return T(a.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===u)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return s.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return s.error("unrecognized date",t),e;return t};var S=/%\d?f/g;function E(t,e,r,n){t=t.replace(S,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var i=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(i)}var C=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,i,a){if(i=_(i)&&i,!e)if("y"===r)e=a.year;else if("m"===r)e=a.month;else{if("d"!==r)return function(t,e){var r=l(t+.05,f),n=w(Math.floor(r/h),2)+":"+w(l(Math.floor(r/p),60),2);if("M"!==e){o(e)||(e=0);var i=(100+Math.min(l(t/d,60),C[e])).toFixed(e).substr(1);e>0&&(i=i.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+i}return n}(t,r)+"\n"+E(a.dayMonthYear,t,n,i);e=a.dayMonth+"\n"+a.year}return E(e,t,n,i)};var L=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=l(t,f);if(t=Math.round(t-n),r)try{var i=Math.round(t/f)+g,a=v.getComponentMethod("calendars","getCal")(r),o=a.fromJD(i);return e%12?a.add(o,e,"m"):a.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){s.error("invalid ms "+t+" in calendar "+r)}var c=new Date(t+L);return c.setUTCMonth(c.getUTCMonth()+e)+n-L},r.findExactDates=function(t,e){for(var r,n,i=0,a=0,s=0,l=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u0&&(r.push(i),i=[])}return i.length>0&&r.push(i),r},r.makeLine=function(t){return 1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}},r.makePolygon=function(t){if(1===t.length)return{type:"Polygon",coordinates:t};for(var e=new Array(t.length),r=0;r1||g<0||g>1?null:{x:t+l*g,y:e+f*g}}function l(t,e,r,n,i){var a=n*t+i*e;if(a<0)return n*n+i*i;if(a>r){var o=n-t,s=i-e;return o*o+s*s}var l=n*e-i*t;return l*l/r}r.segmentsIntersect=s,r.segmentDistance=function(t,e,r,n,i,a,o,c){if(s(t,e,r,n,i,a,o,c))return 0;var u=r-t,f=n-e,h=o-i,p=c-a,d=u*u+f*f,g=h*h+p*p,v=Math.min(l(u,f,d,i-t,a-e),l(u,f,d,o-t,c-e),l(h,p,g,t-i,e-a),l(h,p,g,r-i,n-a));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,s){if(t===i&&s===a||(n={},i=t,a=s),n[r])return n[r];var l=t.getPointAtLength(o(r-s/2,e)),c=t.getPointAtLength(o(r+s/2,e)),u=Math.atan((c.y-l.y)/(c.x-l.x)),f=t.getPointAtLength(o(r,e)),h={x:(4*f.x+l.x+c.x)/6,y:(4*f.y+l.y+c.y)/6,theta:u};return n[r]=h,h},r.clearLocationCache=function(){i=null},r.getVisibleSegment=function(t,e,r){var n,i,a=e.left,o=e.right,s=e.top,l=e.bottom,c=0,u=t.getTotalLength(),f=u;function h(e){var r=t.getPointAtLength(e);0===e?n=r:e===u&&(i=r);var c=r.xo?r.x-o:0,f=r.yl?r.y-l:0;return Math.sqrt(c*c+f*f)}for(var p=h(c);p;){if((c+=p+r)>f)return;p=h(c)}for(p=h(f);p;){if(c>(f-=p+r))return;p=h(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(n.x-i.x)<.1&&Math.abs(n.y-i.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var i,a,o,s=(n=n||{}).pathLength||t.getTotalLength(),l=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(s)[r]?-1:1,f=0,h=0,p=s;f0?p=i:h=i,f++}return a}},{"./mod":703}],691:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],692:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("color-normalize"),o=t("../components/colorscale"),s=t("../components/color/attributes").defaultLine,l=t("./array").isArrayOrTypedArray,c=a(s),u=1;function f(t,e){var r=t;return r[3]*=e,r}function h(t){if(n(t))return c;var e=a(t);return e.length?e:c}function p(t){return n(t)?t:u}e.exports={formatColor:function(t,e,r){var n,i,s,d,g,v=t.color,m=l(v),y=l(e),x=[];if(n=void 0!==t.colorscale?o.makeColorScaleFunc(o.extractScale(t.colorscale,t.cmin,t.cmax)):h,i=m?function(t,e){return void 0===t[e]?c:a(n(t[e]))}:h,s=y?function(t,e){return void 0===t[e]?u:p(t[e])}:p,m||y)for(var b=0;b/g,"")}(function(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(r/g,"\n"))))}},{"./svg_text_utils":720,"superscript-text":507}],695:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],696:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../constants/numerical"),o=a.FP_SAFE,s=a.BADNUM,l=e.exports={};l.nestedProperty=t("./nested_property"),l.keyedContainer=t("./keyed_container"),l.relativeAttr=t("./relative_attr"),l.isPlainObject=t("./is_plain_object"),l.toLogRange=t("./to_log_range"),l.relinkPrivateKeys=t("./relink_private");var c=t("./array");l.isTypedArray=c.isTypedArray,l.isArrayOrTypedArray=c.isArrayOrTypedArray,l.isArray1D=c.isArray1D,l.ensureArray=c.ensureArray,l.concat=c.concat;var u=t("./mod");l.mod=u.mod,l.modHalf=u.modHalf;var f=t("./coerce");l.valObjectMeta=f.valObjectMeta,l.coerce=f.coerce,l.coerce2=f.coerce2,l.coerceFont=f.coerceFont,l.coerceHoverinfo=f.coerceHoverinfo,l.coerceSelectionMarkerOpacity=f.coerceSelectionMarkerOpacity,l.validate=f.validate;var h=t("./dates");l.dateTime2ms=h.dateTime2ms,l.isDateTime=h.isDateTime,l.ms2DateTime=h.ms2DateTime,l.ms2DateTimeLocal=h.ms2DateTimeLocal,l.cleanDate=h.cleanDate,l.isJSDate=h.isJSDate,l.formatDate=h.formatDate,l.incrementMonth=h.incrementMonth,l.dateTick0=h.dateTick0,l.dfltRange=h.dfltRange,l.findExactDates=h.findExactDates,l.MIN_MS=h.MIN_MS,l.MAX_MS=h.MAX_MS;var p=t("./search");l.findBin=p.findBin,l.sorterAsc=p.sorterAsc,l.sorterDes=p.sorterDes,l.distinctVals=p.distinctVals,l.roundUp=p.roundUp,l.sort=p.sort,l.findIndexOfMin=p.findIndexOfMin;var d=t("./stats");l.aggNums=d.aggNums,l.len=d.len,l.mean=d.mean,l.midRange=d.midRange,l.variance=d.variance,l.stdev=d.stdev,l.interp=d.interp;var g=t("./matrix");l.init2dArray=g.init2dArray,l.transposeRagged=g.transposeRagged,l.dot=g.dot,l.translationMatrix=g.translationMatrix,l.rotationMatrix=g.rotationMatrix,l.rotationXYMatrix=g.rotationXYMatrix,l.apply2DTransform=g.apply2DTransform,l.apply2DTransform2=g.apply2DTransform2;var v=t("./angles");l.deg2rad=v.deg2rad,l.rad2deg=v.rad2deg,l.angleDelta=v.angleDelta,l.angleDist=v.angleDist,l.isFullCircle=v.isFullCircle,l.isAngleInsideSector=v.isAngleInsideSector,l.isPtInsideSector=v.isPtInsideSector,l.pathArc=v.pathArc,l.pathSector=v.pathSector,l.pathAnnulus=v.pathAnnulus;var m=t("./geometry2d");l.segmentsIntersect=m.segmentsIntersect,l.segmentDistance=m.segmentDistance,l.getTextLocation=m.getTextLocation,l.clearLocationCache=m.clearLocationCache,l.getVisibleSegment=m.getVisibleSegment,l.findPointOnPath=m.findPointOnPath;var y=t("./extend");l.extendFlat=y.extendFlat,l.extendDeep=y.extendDeep,l.extendDeepAll=y.extendDeepAll,l.extendDeepNoArrays=y.extendDeepNoArrays;var x=t("./loggers");l.log=x.log,l.warn=x.warn,l.error=x.error;var b=t("./regex");l.counterRegex=b.counter;var _=t("./throttle");function w(t){var e={};for(var r in t)for(var n=t[r],i=0;io?s:i(t)?Number(t):s:s},l.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(i(t)&&t>=0&&t%1==0)},l.noop=t("./noop"),l.identity=t("./identity"),l.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},l.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},l.simpleMap=function(t,e,r,n){for(var i=t.length,a=new Array(i),o=0;o=Math.pow(2,r)?i>10?(l.warn("randstr failed uniqueness"),c):t(e,r,n,(i||0)+1):c},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;r=s&&(i-=s*Math.floor(i/s)),i<0?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},l.syncOrAsync=function(t,e,r){var n;function i(){return l.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(i).then(void 0,l.promiseError);return r&&r(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,r){if(t){var n,i=!1,a=!0;for(n=0;n1?i+o[1]:"";if(a&&(o.length>1||s.length>4||r))for(;n.test(s);)s=s.replace(n,"$1"+a+"$2");return s+l};var A=/%{([^\s%{}]*)}/g,T=/^\w*$/;l.templateString=function(t,e){var r={};return t.replace(A,function(t,n){return T.test(n)?e[n]||"":(r[n]=r[n]||l.nestedProperty(e,n).get,r[n]()||"")})};l.subplotSort=function(t,e){for(var r=Math.min(t.length,e.length)+1,n=0,i=0,a=0;a=48&&o<=57,c=s>=48&&s<=57;if(l&&(n=10*n+o-48),c&&(i=10*i+s-48),!l||!c){if(n!==i)return n-i;if(o!==s)return o-s}}return i-n};var S=2e9;l.seedPseudoRandom=function(){S=2e9},l.pseudoRandom=function(){var t=S;return S=(69069*S+1)%4294967296,Math.abs(S-t)<429496729?l.pseudoRandom():S/4294967296}},{"../constants/numerical":673,"./angles":677,"./array":678,"./clean_number":679,"./clear_responsive":681,"./coerce":682,"./dates":683,"./extend":685,"./filter_unique":686,"./filter_visible":687,"./geometry2d":690,"./get_graph_div":691,"./identity":695,"./is_plain_object":697,"./keyed_container":698,"./localize":699,"./loggers":700,"./make_trace_groups":701,"./matrix":702,"./mod":703,"./nested_property":704,"./noop":705,"./notifier":706,"./push_unique":710,"./regex":712,"./relative_attr":713,"./relink_private":714,"./search":715,"./stats":718,"./throttle":721,"./to_log_range":722,d3:148,"fast-isnumeric":214}],697:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],698:[function(t,e,r){"use strict";var n=t("./nested_property"),i=/^\w*$/;e.exports=function(t,e,r,a){var o,s,l;r=r||"name",a=a||"value";var c={};e&&e.length?(l=n(t,e),s=l.get()):s=t,e=e||"";var u={};if(s)for(o=0;o2)return c[e]=2|c[e],h.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],704:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,a,o,l=0,c=e.split(".");l/g),o=0;oa||c===i||cs||e&&l(t))}:function(t,e){var l=t[0],c=t[1];if(l===i||la||c===i||cs)return!1;var u,f,h,p,d,g=r.length,v=r[0][0],m=r[0][1],y=0;for(u=1;uMath.max(f,v)||c>Math.max(h,m)))if(cu||Math.abs(n(o,h))>i)return!0;return!1};a.filter=function(t,e){var r=[t[0]],n=0,i=0;function a(a){t.push(a);var s=r.length,l=n;r.splice(i+1);for(var c=l+1;c1&&a(t.pop());return{addPt:a,raw:t,filtered:r}}},{"../constants/numerical":673,"./matrix":702}],709:[function(t,e,r){(function(r){"use strict";var n=t("./show_no_webgl_msg"),i=t("regl");e.exports=function(t,e){var a=t._fullLayout,o=!0;return a._glcanvas.each(function(n){if(!n.regl&&(!n.pick||a._has("parcoords"))){try{n.regl=i({canvas:this,attributes:{antialias:!n.pick,preserveDrawingBuffer:!0},pixelRatio:t._context.plotGlPixelRatio||r.devicePixelRatio,extensions:e||[]})}catch(t){o=!1}o&&this.addEventListener("webglcontextlost",function(e){t&&t.emit&&t.emit("plotly_webglcontextlost",{event:e,layer:n.key})},!1)}}),o||n({container:a._glcontainer.node()}),o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./show_no_webgl_msg":717,regl:478}],710:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ri.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function c(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var a,u,f=0,h=e.length,p=0,d=h>1?(e[h-1]-e[0])/(h-1):1;for(u=d>=0?r?o:s:r?c:l,t+=1e-9*d*(r?-1:1)*(d>=0?1:-1);f90&&i.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;se[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;i0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||a;for(var r,n=1/0,i=0;ia.length)&&(o=a.length),n(e)||(e=!1),i(a[0])){for(l=new Array(o),s=0;st.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":678,"fast-isnumeric":214}],719:[function(t,e,r){"use strict";var n=t("color-normalize");e.exports=function(t){return t?n(t):[0,0,0,1]}},{"color-normalize":108}],720:[function(t,e,r){"use strict";var n=t("d3"),i=t("../lib"),a=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function s(t,e){return t.node().getBoundingClientRect()[e]}var l=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var S=t.text(),E=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&S.match(l),L=n.select(t.node().parentNode);if(!L.empty()){var z=t.attr("class")?t.attr("class").split(" ")[0]:"text";return z+="-math",L.selectAll("svg."+z).remove(),L.selectAll("g."+z+"-group").remove(),t.style("display",null).attr({"data-unformatted":S,"data-math":"N"}),E?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),a={fontSize:r};!function(t,e,r){var a,o,s,l;MathJax.Hub.Queue(function(){return o=i.extendDeepAll({},MathJax.Hub.config),s=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(a=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+i.randstr({},64);return l=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(l.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(l.select(".MathJax_SVG").empty()||!l.select("svg").node())i.log("There was an error in the tex syntax.",t),r();else{var o=l.select("svg").node().getBoundingClientRect();r(l.select(".MathJax_SVG"),e,o)}if(l.remove(),"SVG"!==a)return MathJax.Hub.setRenderer(a)},function(){return void 0!==s&&(MathJax.Hub.processSectionDelay=s),MathJax.Hub.Config(o)})}(E[2],a,function(n,i,a){L.selectAll("svg."+z).remove(),L.selectAll("g."+z+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return O(),void e();var l=L.append("g").classed(z+"-group",!0).attr({"pointer-events":"none","data-unformatted":S,"data-math":"Y"});l.node().appendChild(o.node()),i&&i.node()&&o.node().insertBefore(i.node().cloneNode(!0),o.node().firstChild),o.attr({class:z,height:a.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=s(o,"width"),f=s(o,"height"),h=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(r||s(t,"height"))/4;"y"===z[0]?(l.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===z[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===z[0]?o.attr({x:0,y:p}):o.attr({x:h,y:+t.attr("y")+p-f/2}),v&&v.call(t,l),e(l)})})):O(),t}function O(){L.empty()||(z=t.attr("class")+"-math",L.select("svg."+z).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(m," ");var r,s=!1,l=[],c=-1;function u(){c++;var e=document.createElementNS(a.svg,"tspan");n.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),r=e;var i=l;if(l=[{node:e}],i.length>1)for(var s=1;s doesnt match end tag <"+t+">. Pretending it did match.",e),r=l[l.length-1].node}else i.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(r=t,l=[{node:t}]);for(var L=e.split(y),z=0;z|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},h={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},d="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),m=/(\r\n?|\n)/g,y=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,M=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function A(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&C(n)}var T=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var S={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},E=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function C(t){return t.replace(E,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):S[e])||t})}function L(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}r.convertEntities=C,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function i(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var a=i("x",e),o=i("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:a,y:o})})},r.makeEditable=function(t,e){var r=e.gd,i=e.delegate,a=n.dispatch("edit","input","cancel"),o=i||t;if(t.style({"pointer-events":i?"none":"all"}),1!==t.size())throw new Error("boo");function s(){!function(){var i=n.select(r).select(".svg-container"),o=i.append("div"),s=t.node().style,c=parseFloat(s.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":s.fontFamily||"Arial","font-size":c,color:e.fill||s.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(L(t,i,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,i=n.select(this).attr("class");(e=i?"."+i.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),a.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),a.cancel.call(t,this.textContent)):(a.input.call(t,this.textContent),n.select(this).call(L(t,i,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(l)}(),t.style({opacity:0});var i,s=o.attr("class");(i=s?"."+s.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(i).style({opacity:0})}function l(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?s():o.on("click",s),n.rebind(t,a,"on")}},{"../constants/alignment":668,"../constants/xmlns_namespaces":674,"../lib":696,d3:148}],721:[function(t,e,r){"use strict";var n={};function i(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var a=n[t],o=Date.now();if(!a){for(var s in n)n[s].tsa.ts+e?l():a.timer=setTimeout(function(){l(),a.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)i(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],722:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":214}],723:[function(t,e,r){"use strict";var n=e.exports={},i=t("../plots/geo/constants").locationmodeToLayer,a=t("topojson-client").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../plots/geo/constants":773,"topojson-client":517}],724:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],725:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],726:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,i=n.layoutArrayContainers,a=n.layoutArrayRegexes,o=t.split("[")[0],s=0;s0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var n=(s.subplotsRegistry.cartesian||{}).attrRegex,a=(s.subplotsRegistry.gl3d||{}).attrRegex,l=Object.keys(t);for(e=0;e3?(T.x=1.02,T.xanchor="left"):T.x<-2&&(T.x=-.02,T.xanchor="right"),T.y>3?(T.y=1.02,T.yanchor="bottom"):T.y<-2&&(T.y=-.02,T.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=y(e);r;){if(r in t)return!0;r=y(r)}return!1};var x=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&o.warn("Full array edits are incompatible with other edits",f);var y=r[""][""];if(u(y))e.set(null);else{if(!Array.isArray(y))return o.warn("Unrecognized full array edit value",f,y),!0;e.set(y)}return!g&&(h(v,m),p(t),!0)}var x,b,_,w,k,M,A,T=Object.keys(r).map(Number).sort(s),S=e.get(),E=S||[],C=n(m,f).get(),L=[],z=-1,O=E.length;for(x=0;xE.length-(A?0:1))o.warn("index out of range",f,_);else if(void 0!==M)k.length>1&&o.warn("Insertion & removal are incompatible with edits to the same index.",f,_),u(M)?L.push(_):A?("add"===M&&(M={}),E.splice(_,0,M),C&&C.splice(_,0,{})):o.warn("Unrecognized full object edit value",f,_,M),-1===z&&(z=_);else for(b=0;b=0;x--)E.splice(L[x],1),C&&C.splice(L[x],1);if(E.length?S||e.set(E):e.set(null),g)return!1;if(h(v,m),d!==a){var I;if(-1===z)I=T;else{for(O=Math.max(E.length,O),I=[],x=0;x=z);x++)I.push(_);for(x=z;x=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||i<0&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function I(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),O(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&O(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function P(t,e,r,n,a){!function(t,e,r,n){var i=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var a in O(t,r,"indices"),e){if(!Array.isArray(e[a])||e[a].length!==r.length)throw new Error("attribute "+a+" must be an array of length equal to indices array length");if(i&&(!(a in n)||!Array.isArray(n[a])||n[a].length!==e[a].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var s=function(t,e,r,n){var a,s,l,c,u,f=o.isPlainObject(n),h=[];for(var p in Array.isArray(r)||(r=[r]),r=z(r,t.data.length-1),e)for(var d=0;d=0&&r=0&&r0&&"string"!=typeof C.parts[z];)z--;var O=C.parts[z],I=C.parts[z-1]+"."+O,P=C.parts.slice(0,z).join("."),D=o.nestedProperty(t.layout,P).get(),B=o.nestedProperty(s,P).get(),F=C.get();if(void 0!==L){y[E]=L,x[E]="reverse"===O?L:R(F);var N=u.getLayoutValObject(s,C.parts);if(N&&N.impliedEdits&&null!==L)for(var q in N.impliedEdits)b(o.relativeAttr(E,q),N.impliedEdits[q]);if(-1!==["width","height"].indexOf(E))if(L){b("autosize",null);var G="height"===E?"width":"height";b(G,s[G])}else s[E]=t._initialAutoSize[E];else if("autosize"===E)b("width",L?null:s.width),b("height",L?null:s.height);else if(I.match(j))S(I),o.nestedProperty(s,P+"._inputRange").set(null);else if(I.match(V)){S(I),o.nestedProperty(s,P+"._inputRange").set(null);var W=o.nestedProperty(s,P).get();W._inputDomain&&(W._input.domain=W._inputDomain.slice())}else I.match(U)&&o.nestedProperty(s,P+"._inputDomain").set(null);if("type"===O){var Y=D,X="linear"===B.type&&"log"===L,Z="log"===B.type&&"linear"===L;if(X||Z){if(Y&&Y.range)if(B.autorange)X&&(Y.range=Y.range[1]>Y.range[0]?[1,2]:[2,1]);else{var $=Y.range[0],J=Y.range[1];X?($<=0&&J<=0&&b(P+".autorange",!0),$<=0?$=J/1e6:J<=0&&(J=$/1e6),b(P+".range[0]",Math.log($)/Math.LN10),b(P+".range[1]",Math.log(J)/Math.LN10)):(b(P+".range[0]",Math.pow(10,$)),b(P+".range[1]",Math.pow(10,J)))}else b(P+".autorange",!0);Array.isArray(s._subplots.polar)&&s._subplots.polar.length&&s[C.parts[0]]&&"radialaxis"===C.parts[1]&&delete s[C.parts[0]]._subplot.viewInitial["radialaxis.range"],c.getComponentMethod("annotations","convertCoords")(t,B,L,b),c.getComponentMethod("images","convertCoords")(t,B,L,b)}else b(P+".autorange",!0),b(P+".range",null);o.nestedProperty(s,P+"._inputRange").set(null)}else if(O.match(A)){var K=o.nestedProperty(s,E).get(),Q=(L||{}).type;Q&&"-"!==Q||(Q="linear"),c.getComponentMethod("annotations","convertCoords")(t,K,Q,b),c.getComponentMethod("images","convertCoords")(t,K,Q,b)}var tt=_.containerArrayMatch(E);if(tt){r=tt.array,n=tt.index;var et=tt.property,rt=(o.nestedProperty(a,r)||[])[n]||{},nt=N||{editType:"calc"};""!==n&&""===et&&(_.isAddVal(L)?x[E]=null:_.isRemoveVal(L)?x[E]=rt:o.warn("unrecognized full object value",e)),M.update(m,nt),h[r]||(h[r]={});var it=h[r][n];it||(it=h[r][n]={}),it[et]=L,delete e[E]}else"reverse"===O?(D.range?D.range.reverse():(b(P+".autorange",!0),D.range=[1,0]),B.autorange?m.calc=!0:m.plot=!0):(s._has("scatter-like")&&s._has("regl")&&"dragmode"===E&&("lasso"===L||"select"===L)&&"lasso"!==F&&"select"!==F?m.plot=!0:N?M.update(m,N):m.calc=!0,C.set(L))}}for(r in h){_.applyContainerArrayChanges(t,o.nestedProperty(a,r),h[r],m)||(m.plot=!0)}var at=s._axisConstraintGroups||[];for(k in T)for(n=0;n=i.length?i[0]:i[t]:i}function l(t){return Array.isArray(a)?t>=a.length?a[0]:a[t]:a}function c(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(a,u){function h(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,f.transition(t,e.frame.data,e.frame.layout,w.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function p(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&h()};e()}var d,g,v=0;function m(t){return Array.isArray(i)?v>=i.length?t.transitionOpts=i[v]:t.transitionOpts=i[0]:t.transitionOpts=i,v++,t}var y=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))y.push({type:"object",data:m(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(d=0;d0&&MM)&&A.push(g);y=A}}y.length>0?function(e){if(0!==e.length){for(var i=0;i=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(u[g]||d[g]||{}).name,m=e[n].name,y=u[v]||d[v];v&&m&&"number"==typeof m&&y&&T<5&&(T++,o.warn('addFrames: overwriting frame "'+(u[v]||d[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===T&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),d[g]={name:g},p.push({frame:f.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:h+n})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(i=p[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!i.name)for(;u[i.name="frame "+t._transitionData._counter++];);if(u[i.name]){for(a=0;a=0;r--)n=e[r],a.push({type:"delete",index:n}),s.unshift({type:"insert",index:n,value:i[n]});var c=f.modifyFrames,u=f.modifyFrames,h=[t,s],p=[t,a];return l&&l.add(t,c,h,u,p),f.modifyFrames(t,a)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return f.cleanPlot([],{},r,e),f.purge(t),s.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":570,"../components/colorbar/connect":572,"../components/drawing":595,"../constants/xmlns_namespaces":674,"../lib":696,"../lib/events":684,"../lib/queue":711,"../lib/svg_text_utils":720,"../plots/cartesian/axes":744,"../plots/cartesian/constants":750,"../plots/cartesian/graph_interact":754,"../plots/plots":808,"../plots/polar/legacy":816,"../registry":827,"./edit_types":727,"./helpers":728,"./manage_arrays":730,"./plot_config":732,"./plot_schema":733,"./subroutines":735,d3:148,"fast-isnumeric":214,"has-hover":393}],732:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],733:[function(t,e,r){"use strict";var n=t("../registry"),i=t("../lib"),a=t("../plots/attributes"),o=t("../plots/layout_attributes"),s=t("../plots/frame_attributes"),l=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),h=i.extendFlat,p=i.extendDeepAll,d=i.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",m=[g,v,"_arrayAttrRegexps","_deprecated"];function y(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(x(e[r]))r++;else if(r=a.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!x(o))return!1;t=a[i][o]}else t=a[i]}else t=a}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):d(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(d(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=l.length)return!1;i=(r=(n.transformsRegistry[l[u].type]||{}).attributes)&&r[e[2]],s=3}else if("area"===t.type)i=c[o];else{var f=t._module;if(f||(f=(n.modules[t.type||a.type.dflt]||{})._module),!f)return!1;if(!(i=(r=f.attributes)&&r[o])){var h=f.basePlotModule;h&&h.attributes&&(i=h.attributes[o])}i||(i=a[o])}return y(i,e,s)},r.getLayoutValObject=function(t,e){return y(function(t,e){var r,i,a,s,l=t._basePlotModules;if(l){var c;for(r=0;r=i&&(r._input||{})._templateitemname;s&&(o=i);var l,c=e+"["+o+"]";function u(){l={},s&&(l[c]={},l[c][a]=s)}function f(t,e){s?n.nestedProperty(l[c],t).set(e):l[c+"."+t]=e}function h(){var t=l;return u(),t}return u(),{modifyBase:function(t,e){l[t]=e},modifyItem:f,getUpdateObj:h,applyUpdate:function(e,r){e&&f(e,r);var i=h();for(var a in i)n.nestedProperty(t,a).set(i[a])}}}},{"../lib":696,"../plots/attributes":741}],735:[function(t,e,r){"use strict";var n=t("d3"),i=t("../registry"),a=t("../plots/plots"),o=t("../lib"),s=t("../lib/clear_gl_canvases"),l=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),h=t("../plots/cartesian/axes"),p=t("../constants/alignment"),d=t("../plots/cartesian/constraints"),g=d.enforce,v=d.clean,m=t("../plots/cartesian/autorange").doAutoRange;function y(t,e,r){for(var n=0;n=t[1]||i[1]<=t[0])&&(a[0]e[0]))return!0}return!1}function x(t){var e,i,a,s,u,d=t._fullLayout,g=d._size,v=g.p,m=h.list(t,"",!0);if(d._paperdiv.style({width:t._context.responsive&&d.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":d.width+"px",height:t._context.responsive&&d.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":d.height+"px"}).selectAll(".main-svg").call(c.setSize,d.width,d.height),t._context.setBackground(t,d.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!d._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-v-n:e._offset+e._length+v+n:g.t+g.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+v+n:e._offset-v-n:g.l+g.w*(t.position||0)+n%1}for(e=0;ek?u.push({code:"unused",traceType:y,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:y,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var a=e[n],o=p(e,n,r);i(a)?(Array.isArray(e)&&!1===a._template&&a.templateitemname&&u.push({code:"missing",path:o,templateitemname:a.templateitemname}),t(a,o)):Array.isArray(a)&&d(a)&&t(a,o)}}({data:v,layout:h},""),u.length)return u.map(g)}},{"../lib":696,"../plots/attributes":741,"../plots/plots":808,"./plot_config":732,"./plot_schema":733,"./plot_template":734}],737:[function(t,e,r){"use strict";var n=t("./plot_api"),i=t("../lib"),a=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),s=t("../snapshot/svgtoimg"),l={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,u,f;function h(t){return!(t in e)||i.validate(e[t],l[t])}if(e=e||{},i.isPlainObject(t)?(r=t.data||[],u=t.layout||{},f=t.config||{}):(t=i.getGraphDiv(t),r=i.extendDeep([],t.data),u=i.extendDeep({},t.layout),f=t._context),!h("width")||!h("height"))throw new Error("Height and width should be pixel values.");if(!h("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function d(t,r){return i.coerce(e,p,l,t,r)}var g=d("format"),v=d("width"),m=d("height"),y=d("scale"),x=d("setBackground"),b=d("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=i.extendFlat({},u);v&&(w.width=v),m&&(w.height=m);var k=i.extendFlat({},f,{staticPlot:!0,setBackground:x}),M=a.getRedrawFunc(_);function A(){return new Promise(function(t){setTimeout(t,a.getDelay(_._fullLayout))})}function T(){return new Promise(function(t,e){var r=o(_,g,y),a=_._fullLayout.width,l=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(b?r:"data:image/svg+xml,"+encodeURIComponent(r));var c=document.createElement("canvas");c.id=i.randstr(),s({format:g,width:a,height:l,scale:y,canvas:c,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,k).then(M).then(A).then(T).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":696,"../snapshot/helpers":831,"../snapshot/svgtoimg":833,"../snapshot/tosvg":835,"./plot_api":731}],738:[function(t,e,r){"use strict";var n=t("../lib"),i=t("../plots/plots"),a=t("./plot_schema"),o=t("./plot_config"),s=n.isPlainObject,l=Array.isArray,c=n.isArrayOrTypedArray;function u(t,e,r,i,a,o){o=o||[];for(var f=Object.keys(t),h=0;hx.length&&i.push(p("unused",a,m.concat(x.length)));var M,A,T,S,E,C=x.length,L=Array.isArray(k);if(L&&(C=Math.min(C,k.length)),2===b.dimensions)for(A=0;Ax[A].length&&i.push(p("unused",a,m.concat(A,x[A].length)));var z=x[A].length;for(M=0;M<(L?Math.min(z,k[A].length):z);M++)T=L?k[A][M]:k,S=y[A][M],E=x[A][M],n.validate(S,T)?E!==S&&E!==+S&&i.push(p("dynamic",a,m.concat(A,M),S,E)):i.push(p("value",a,m.concat(A,M),S))}else i.push(p("array",a,m.concat(A),y[A]));else for(A=0;A1&&h.push(p("object","layout"))),i.supplyDefaults(d);for(var g=d._fullData,v=r.length,m=0;m0&&((b=A-o(v)-o(m))>T?_/b>S&&(y=v,x=m,S=_/b):_/A>S&&(y={val:v.val,pad:0},x={val:m.val,pad:0},S=_/A));if(h===p){var E=h-1,C=h+1;if(k)if(0===h)a=[0,1];else{var L=(h>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),z=h/(1-Math.min(.5,L/A));a=h>0?[0,z]:[z,0]}else a=M?[Math.max(0,E),Math.max(1,C)]:[E,C]}else k?(y.val>=0&&(y={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):M&&(y.val-S*o(y)<0&&(y={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),S=(x.val-y.val)/(A-o(y)-o(x)),a=[y.val-S*o(y),x.val+S*o(x)];return d&&a.reverse(),i.simpleMap(a,e.l2r||Number)}function s(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function l(t,e){var r,n,i,a=e._id,o=t._fullData,s=t._fullLayout,l=[],f=[];function h(t,e){for(r=0;r=r&&(c.extrapad||!o)){s=!1;break}i(e,c.val)&&c.pad<=r&&(o||!c.extrapad)&&(t.splice(l,1),l--)}if(s){var u=a&&0===e;t.push({val:e,pad:u?0:r,extrapad:!u&&o})}}function h(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:o,makePadFn:s,doAutoRange:function(t,e){e._length||e.setScale();var r;e.autorange&&(e.range=o(t,e),e._r=e.range.slice(),e._rl=i.simpleMap(e._r,e.r2l),(r=e._input).range=e.range.slice(),r.autorange=e.autorange);if(e._anchorAxis&&e._anchorAxis.rangeslider){var n=e._anchorAxis.rangeslider[e._name];n&&"auto"===n.rangemode&&(n.range=o(t,e)),(r=e._anchorAxis._input).rangeslider[e._name]=i.extendFlat({},n)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var i,o,s,l,f,p,d,g,v,m=[],y=[],x=e.length,b=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function M(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var A=M((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),T=M((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),S=M(r.vpadplus||r.vpad),E=M(r.vpadminus||r.vpad);if(!k){if(g=1/0,v=-1/0,w)for(i=0;i0&&(g=o),o>v&&o-a&&(g=o),o>v&&o=z;i--)L(i);return{min:m,max:y}},concatExtremes:l}},{"../../constants/numerical":673,"../../lib":696,"fast-isnumeric":214}],744:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),h=t("./layout_attributes"),p=t("./clean_ticks"),d=t("../../constants/numerical"),g=d.ONEAVGYEAR,v=d.ONEAVGMONTH,m=d.ONEDAY,y=d.ONEHOUR,x=d.ONEMIN,b=d.ONESEC,_=d.MINUS_SIGN,w=d.BADNUM,k=t("../../constants/alignment").MID_SHIFT,M=t("../../constants/alignment").LINE_SPACING,A=e.exports={};A.setConvert=t("./set_convert");var T=t("./axis_autotype"),S=t("./axis_ids");A.id2name=S.id2name,A.name2id=S.name2id,A.cleanId=S.cleanId,A.list=S.list,A.listIds=S.listIds,A.getFromId=S.getFromId,A.getFromTrace=S.getFromTrace;var E=t("./autorange");A.getAutoRange=E.getAutoRange,A.findExtremes=E.findExtremes,A.coerceRef=function(t,e,r,n,i,a){var o=n.charAt(n.length-1),l=r._fullLayout._subplots[o+"axis"],c=n+"ref",u={};return i||(i=l[0]||a),a||(a=i),u[c]={valType:"enumerated",values:l.concat(a?[a]:[]),dflt:i},s.coerce(t,e,u,c)},A.coercePosition=function(t,e,r,n,i,a){var o,l;if("paper"===n||"pixel"===n)o=s.ensureNumber,l=r(i,a);else{var c=A.getFromId(e,n);l=r(i,a=c.fraction2r(a)),o=c.cleanPos}t[i]=o(l)},A.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?s.ensureNumber:A.getFromId(e,r).cleanPos)(t)};var C=A.getDataConversions=function(t,e,r,n){var i,a="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(a)){if(i={type:T(n),_categories:[]},A.setConvert(i),"category"===i.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},A.saveRangeInitial=function(t,e){for(var r=A.list(t,"",!0),n=!1,i=0;i.3*h||u(n)||u(a))){var p=r.dtick/2;t+=t+p.8){var o=Number(r.substr(1));a.exactYears>.8&&o%12==0?t=A.tickIncrement(t,"M6","reverse")+1.5*m:a.exactMonths>.8?t=A.tickIncrement(t,"M1","reverse")+15.5*m:t-=m/2;var l=A.tickIncrement(t,r);if(l<=n)return l}return t}(x,t,y,c,a)),v=x,0;v<=u;)v=A.tickIncrement(v,y,!1,a),0;return{start:e.c2r(x,0,a),end:e.c2r(v,0,a),size:y,_dataSpan:u-c}},A.prepTicks=function(t){var e=s.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=s.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),A.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},A.calcTicks=function(t){A.prepTicks(t);var e=s.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e,r,n=t.tickvals,i=t.ticktext,a=new Array(n.length),o=s.simpleMap(t.range,t.r2l),l=1.0001*o[0]-1e-4*o[1],c=1.0001*o[1]-1e-4*o[0],u=Math.min(l,c),f=Math.max(l,c),h=0;Array.isArray(i)||(i=[]);var p="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(r=0;ru&&e=n:c<=n)&&!(a.length>l||c===o);c=A.tickIncrement(c,t.dtick,i,t.calendar))o=c,a.push(c);$(t)&&360===Math.abs(e[1]-e[0])&&a.pop(),t._tmax=a[a.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(a.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=m&&a<=10||e>=15*m)t._tickround="d";else if(e>=x&&a<=16||e>=y)t._tickround="M";else if(e>=b&&a<=19||e>=x)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(a,o)-20,t._tickround<0&&(t._tickround=4)}}else if(i(e)||"L"===e.charAt(0)){var s=t.range.map(t.r2d||Number);i(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var l=Math.max(Math.abs(s[0]),Math.abs(s[1])),c=Math.floor(Math.log(l)/Math.LN10+.01);Math.abs(c)>3&&(q(t.exponentformat)&&!H(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function V(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}A.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=s.dateTick0(t.calendar);var a=2*e;a>g?(e/=g,r=n(10),t.dtick="M"+12*N(e,r,O)):a>v?(e/=v,t.dtick="M"+N(e,1,I)):a>m?(t.dtick=N(e,m,D),t.tick0=s.dateTick0(t.calendar,!0)):a>y?t.dtick=N(e,y,I):a>x?t.dtick=N(e,x,P):a>b?t.dtick=N(e,b,P):(r=n(10),t.dtick=N(e,r,O))}else if("log"===t.type){t.tick0=0;var o=s.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var l=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/l,r=n(10),t.dtick="L"+N(e,r,O)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):$(t)?(t.tick0=0,r=1,t.dtick=N(e,r,F)):(t.tick0=0,r=n(10),t.dtick=N(e,r,O));if(0===t.dtick&&(t.dtick=1),!i(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},A.tickIncrement=function(t,e,r,a){var o=r?-1:1;if(i(e))return t+o*e;var l=e.charAt(0),c=o*Number(e.substr(1));if("M"===l)return s.incrementMonth(t,c,a);if("L"===l)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===l){var u="D2"===e?B:R,f=t+.01*o,h=s.roundUp(s.mod(f,1),u,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(e)},A.tickFirst=function(t){var e=t.r2l||Number,r=s.simpleMap(t.range,e),a=r[1]"+l,t._prevDateHead=l));e.text=c}(t,o,r,c):"log"===t.type?function(t,e,r,n,a){var o=t.dtick,l=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===a&&(a="");n&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,l),t,a,n);else if(i(o)||"D"===u&&s.mod(l+.01,1)<.1){var f=Math.round(l),h=Math.abs(f),p=t.exponentformat;"power"===p||q(p)&&H(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+h+"",e.fontSize*=1.25):("e"===p||"E"===p)&&h>2?e.text="1"+p+(f>0?"+":_)+h:(e.text=G(Math.pow(10,l),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,s.mod(l,1)))),e.fontSize*=.75}if("D1"===t.dtick){var d=String(e.text).charAt(0);"0"!==d&&"1"!==d||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(l<0?.5:.25)))}}(t,o,0,c,n):"category"===t.type?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,o):$(t)?function(t,e,r,n,i){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,i,n);else{var a=e.x/180;if(0===a)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,i=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/i),Math.round(r/i)]}(a);if(o[1]>=100)e.text=G(s.deg2rad(e.x),t,i,n);else{var l=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),l&&(e.text=_+e.text)}}}}(t,o,r,c,n):function(t,e,r,n,i){"never"===i?i="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide");e.text=G(e.x,t,i,n)}(t,o,0,c,n),t.tickprefix&&!p(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!p(t.showticksuffix)&&(o.text+=t.ticksuffix),o},A.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return A.hoverLabelText(t,e)+" - "+A.hoverLabelText(t,r);var n="log"===t.type&&e<=0,i=A.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+i:i};var U=["f","p","n","\u03bc","m","","k","M","G","T"];function q(t){return"SI"===t||"B"===t}function H(t){return t>14||t<-15}function G(t,e,r,n){var a=t<0,o=e._tickround,l=r||e.exponentformat||"B",c=e._tickexponent,u=A.getTickFormat(e),f=e.separatethousands;if(n){var h={exponentformat:l,dtick:"none"===e.showexponent?e.dtick:i(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(h),o=(Number(h._tickround)||0)+4,c=h._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,d=Math.pow(10,-o)/2;if("none"===l&&(c=0),(t=Math.abs(t))"+p+"":"B"===l&&9===c?t+="B":q(l)&&(t+=U[c/3+5]));return a?_+t:t}function W(t,e){var r=t.l2p(e);return r>1&&r=0,a=u(t,e[1])<=0;return(r||i)&&(n||a)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(i)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},s=0;s2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":827,"./constants":750}],748:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var i,a=t.categoryarray,o=Array.isArray(a)&&a.length>0;o&&(i="array");var s,l=r("categoryorder",i);"array"===l&&(s=r("categoryarray")),o||"array"!==l||(l=e.categoryorder="trace"),"trace"===l?e._initialCategories=[]:"array"===l?e._initialCategories=s.slice():(s=function(t,e){var r,n,i,a=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;ns*x)||k)for(r=0;rI&&Rz&&(z=R);p/=(z-L)/(2*O),L=u.l2r(L),z=u.l2r(z),u.range=u._input.range=S=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function P(t,e,r,n,i){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",i+"Z")}function D(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function R(t,e,r,n,i,a){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),B(t,e,i,a)}function B(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function F(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function N(t){S&&t.data&&t._context.showTips&&(s.notifier(s._(t,"Double-click to zoom back out"),"long"),S=!1)}function j(t){return"lasso"===t||"select"===t}function V(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,T)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function U(t,e){if(a){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function q(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,a,c,h,S,E){var B,H,G,W,Y,X,Z,$,J,K,Q,tt,et,rt,nt,it,at,ot,st,lt,ct,ut=t._fullLayout._zoomlayer,ft=S+E==="nsew",ht=1===(S+E).length;function pt(){if(B=e.xaxis,H=e.yaxis,J=B._length,K=H._length,Z=B._offset,$=H._offset,(G={})[B._id]=B,(W={})[H._id]=H,S&&E)for(var r=e.overlays,n=0;n-1&&w(i,t,Y,X,e.id,Tt),a.indexOf("event")>-1&&f.click(t,i,e.id);else if(1===r&&ht){var s=S?H:B,c="s"===S||"w"===E?0:1,u=s._name+".range["+c+"]",h=function(t,e){var r,i=t.range[e],a=Math.abs(i-t.range[1-e]);return"date"===t.type?i:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,i))):(r=Math.floor(Math.log(Math.abs(i))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,n.format("."+String(r)+"g")(i))}(s,c),p="left",d="middle";if(s.fixedrange)return;S?(d="n"===S?"top":"bottom","right"===s.side&&(p="right")):"e"===E&&(p="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(l.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(h),fill:s.tickfont?s.tickfont.color:"#444",horizontalAlign:p,verticalAlign:d}).on("edit",function(e){var r=s.d2r(e);void 0!==r&&o.call("relayout",t,u,r)})}}function Ct(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min(J,e+vt)),i=Math.max(0,Math.min(K,r+mt)),a=Math.abs(n-vt),o=Math.abs(i-mt);function s(){wt="",yt.r=yt.l,yt.t=yt.b,Mt.attr("d","M0,0Z")}yt.l=Math.min(vt,n),yt.r=Math.max(vt,n),yt.t=Math.min(mt,i),yt.b=Math.max(mt,i),nt?a>T||o>T?(wt="xy",a/J>o/K?(o=a*K/J,mt>i?yt.t=mt-o:yt.b=mt+o):(a=o*J/K,vt>n?yt.l=vt-a:yt.r=vt+a),Mt.attr("d",V(yt))):s():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Pt);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var i,a=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=Rt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(it){for(E||(l=.5),i=0;ig[1]-.01&&(e.domain=s),i.noneOrAll(t.domain,e.domain,s)}return r("layer"),e}},{"../../lib":696,"fast-isnumeric":214}],761:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var i=[t.r2l(t.range[0]),t.r2l(t.range[1])],a=i[0]+(i[1]-i[0])*r;t.range=t._input.range=[t.l2r(a+(i[0]-a)*e),t.l2r(a+(i[1]-a)*e)]}},{"../../constants/alignment":668}],762:[function(t,e,r){"use strict";var n=t("polybooljs"),i=t("../../registry"),a=t("../../components/color"),o=t("../../components/fx"),s=t("../../lib/polygon"),l=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),h=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),d=p.MINSELECT,g=s.filter,v=s.tester;function m(t){return t._id}function y(t,e,r,n,i,a,o){var s,l,c,u,f,h,p,d,g,v=e._hoverdata,m=e._fullLayout.clickmode.indexOf("event")>-1,y=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,a);var x=function(t,e){var r,n,i=t[0],a=-1,o=[];for(n=0;n0?function(t,e){var r,n,i,a=[];for(i=0;i0&&a.push(r);if(1===a.length&&a[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(i=0;i1)return!1;if((i+=r.selectedpoints.length)>1)return!1}return 1===i}(s)&&(h=T(x))){for(o&&o.remove(),g=0;g0?"M"+i.join("M")+"Z":"M0,0Z",e.attr("d",n)}function T(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,i=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(i)>-1}function S(t,e,r){var n,a,o,s;if(r){var l=r.points||[];for(n=0;n-1&&y(e,T,i.xaxes,i.yaxes,i.subplot,i,H),"event"===r&&T.emit("plotly_selected",void 0);o.click(T,e)})},i.doneFn=function(){W.remove(),l.done(Y).then(function(){l.clear(Y),i.gd.emit("plotly_selected",b),h&&i.selectionDefs&&(h.subtract=q,i.selectionDefs.push(h),i.mergedPolygons.length=0,[].push.apply(i.mergedPolygons,f))})}},clearSelect:C,selectOnClick:y}},{"../../components/color":570,"../../components/fx":612,"../../components/fx/helpers":609,"../../lib/clear_gl_canvases":680,"../../lib/polygon":708,"../../lib/throttle":721,"../../plot_api/subroutines":735,"../../registry":827,"./axis_ids":747,"./constants":750,polybooljs:456}],763:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=a.cleanNumber,s=a.ms2DateTime,l=a.dateTime2ms,c=a.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,h=u.BADNUM,p=u.LOG_CLIP,d=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function u(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-2*p*Math.abs(n-i))}return h}function m(e,r,n){var o=l(e,n||t.calendar);if(o===h){if(!i(e))return h;e=+e;var s=Math.floor(10*a.mod(e+.05,1)),c=Math.round(e-s/10);o=l(new Date(c))+s/10}return o}function y(e,r,n){return s(e,r,n||t.calendar)}function x(e){return t._categories[Math.round(e)]}function b(e){if(t._categoriesMap){var r=t._categoriesMap[e];if(void 0!==r)return r}if(i(e))return+e}function _(e){return i(e)?n.round(t._b+t._m*e,2):h}function w(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=_,t.p2l=w,t.c2p="log"===t.type?function(t,e){return _(u(t,e))}:_,t.p2c="log"===t.type?function(t){return v(w(t))}:w,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=w,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(w(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=w,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=a.identity,t.d2c=t.r2c=t.d2l=t.r2l=m,t.c2d=t.c2r=t.l2d=t.l2r=y,t.d2p=t.r2p=function(e,r,n){return t.l2p(m(e,0,n))},t.p2d=t.p2r=function(t,e,r){return y(w(t),e,r)},t.cleanPos=function(e){return a.cleanDate(e,h,t.calendar)}):"category"===t.type&&(t.d2c=t.d2l=function(e){if(null!=e){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return h},t.r2d=t.c2d=t.l2d=x,t.d2r=t.d2l_noadd=b,t.r2c=function(e){var r=b(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=b,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return x(w(t))},t.r2p=t.d2p,t.p2r=w,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,s,l=a.nestedProperty(t,e).get();if(s=(s="date"===t.type?a.dfltRange(t.calendar):"y"===r?d.DFLTRANGEY:n.dfltRange||d.DFLTRANGEX).slice(),l&&2===l.length)for("date"===t.type&&(l[0]=a.cleanDate(l[0],h,t.calendar),l[1]=a.cleanDate(l[1],h,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!a.isDateTime(l[o],t.calendar)){t[e]=s;break}if(t.r2l(l[0])===t.r2l(l[1])){var c=a.constrain(t.r2l(l[0]),a.MIN_MS+1e3,a.MAX_MS-1e3);l[0]=t.l2r(c-1e3),l[1]=t.l2r(c+1e3);break}}else{if(!i(l[o])){if(!i(l[1-o])){t[e]=s;break}l[o]=l[1-o]*(o?10:.1)}if(l[o]<-f?l[o]=-f:l[o]>f&&(l[o]=f),l[0]===l[1]){var u=Math.max(1,Math.abs(1e-6*l[0]));l[0]-=u,l[1]+=u}}else a.nestedProperty(t,e).set(s)},t.setScale=function(n){var i=e._size;if(t._categories||(t._categories=[]),t._categoriesMap||(t._categoriesMap={}),t.overlaying){var a=g.getFromId({_fullLayout:e},t.overlaying);t.domain=a.domain}var o=n&&t._r?"_r":"range",s=t.calendar;t.cleanRange(o);var l=t.r2l(t[o][0],s),c=t.r2l(t[o][1],s);if("y"===r?(t._offset=i.t+(1-t.domain[1])*i.h,t._length=i.h*(t.domain[1]-t.domain[0]),t._m=t._length/(l-c),t._b=-t._m*c):(t._offset=i.l+t.domain[0]*i.w,t._length=i.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-l),t._b=-t._m*l),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,i,o,s,l=t.type,c="date"===l&&e[r+"calendar"];if(r in e){if(n=e[r],s=e._length||n.length,a.isTypedArray(n)&&("linear"===l||"log"===l)){if(s===n.length)return n;if(n.subarray)return n.subarray(0,s)}for(i=new Array(s),o=0;o rect").call(a.setTranslate,0,0).call(a.setScale,1,1),t.plot.call(a.setTranslate,e._offset,r._offset).call(a.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(a.setPointGroupScale,1,1),n.selectAll(".textpoint").call(a.setTextPointsScale,1,1),n.call(a.hideOutsideRangePoints,t)}function x(e,r){var n,s,l,u=g[e.xaxis._id],f=g[e.yaxis._id],h=[];if(u){s=(n=t._fullLayout[u.axisName])._r,l=u.to,h[0]=(s[0]*(1-r)+r*l[0]-s[0])/(s[1]-s[0])*e.xaxis._length;var p=s[1]-s[0],d=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[2]=e.xaxis._length*(1-r+r*d/p)}else h[0]=0,h[2]=e.xaxis._length;if(f){s=(n=t._fullLayout[f.axisName])._r,l=f.to,h[1]=(s[1]*(1-r)+r*l[1]-s[1])/(s[0]-s[1])*e.yaxis._length;var v=s[1]-s[0],m=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[3]=e.yaxis._length*(1-r+r*m/v)}else h[1]=0,h[3]=e.yaxis._length;!function(e,r){var n,a=[];for(a=[e._id,r._id],n=0;nr.duration?(function(){for(var e={},r=0;r0&&(i["_"+r+"axes"]||{})[e])return i;if((i[r+"axis"]||r)===e){if(o(i,r))return i;if((i[r]||[]).length||i[r+"0"])return i}}}(e,r,s);if(!l)return;if("histogram"===l.type&&s==={v:"y",h:"x"}[l.orientation||"v"])return void(t.type="linear");var c,u=s+"calendar",f=l[u];if(o(l,s)){var h=a(l),p=[];for(c=0;c0?".":"")+a;i.isPlainObject(o)?l(o,e,s,n+1):e(s,a,o)}})}r.manageCommandObserver=function(t,e,n,o){var s={},l=!0;e&&e._commandObserver&&(s=e._commandObserver),s.cache||(s.cache={}),s.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,n,s.lookupTable);if(e&&e._commandObserver){if(c)return s;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,s}if(c){a(t,c,s.cache),s.check=function(){if(l){var e=a(t,c,s.cache);return e.changed&&o&&void 0!==s.lookupTable[e.value]&&(s.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:s.lookupTable[e.value]})).then(s.enable,s.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;fi*Math.PI/180}return!1},r.getPath=function(){return n.geo.path().projection(r)},r.getBounds=function(t){return r.getPath().bounds(t)},r.fitExtent=function(t,e){var n=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=r.clipExtent&&r.clipExtent();r.scale(150).translate([0,0]),a&&r.clipExtent(null);var o=r.getBounds(e),s=Math.min(n/(o[1][0]-o[0][0]),i/(o[1][1]-o[0][1])),l=+t[0][0]+(n-s*(o[1][0]+o[0][0]))/2,c=+t[0][1]+(i-s*(o[1][1]+o[0][1]))/2;return a&&r.clipExtent(a),r.scale(150*s).translate([l,c])},r.precision(g.precision),i&&r.clipAngle(i-g.clipPad);return r}(e);u.center([c.lon-l.lon,c.lat-l.lat]).rotate([-l.lon,-l.lat,l.roll]).parallels(s.parallels);var f=[[r.l+r.w*o.x[0],r.t+r.h*(1-o.y[1])],[r.l+r.w*o.x[1],r.t+r.h*(1-o.y[0])]],h=e.lonaxis,p=e.lataxis,d=function(t,e){var r=g.clipPad,n=t[0]+r,i=t[1]-r,a=e[0]+r,o=e[1]-r;n>0&&i<0&&(i+=360);var s=(i-n)/4;return{type:"Polygon",coordinates:[[[n,a],[n,o],[n+s,o],[n+2*s,o],[n+3*s,o],[i,o],[i,a],[i-s,a],[i-2*s,a],[i-3*s,a],[n,a]]]}}(h.range,p.range);u.fitExtent(f,d);var v=this.bounds=u.getBounds(d),m=this.fitScale=u.scale(),y=u.translate();if(!isFinite(v[0][0])||!isFinite(v[0][1])||!isFinite(v[1][0])||!isFinite(v[1][1])||isNaN(y[0])||isNaN(y[0])){for(var x=this.graphDiv,b=["projection.rotation","center","lonaxis.range","lataxis.range"],_="Invalid geo settings, relayout'ing to default view.",w={},k=0;k-1&&p(n.event,a,[r.xaxis],[r.yaxis],r.id,g),c.indexOf("event")>-1&&l.click(a,n.event))})}function v(t){return r.projection.invert([t[0]+r.xaxis._offset,t[1]+r.yaxis._offset])}},x.makeFramework=function(){var t=this,e=t.graphDiv._fullLayout,r="clip"+e._uid+t.id;t.clipDef=e._clips.append("clipPath").attr("id",r),t.clipRect=t.clipDef.append("rect"),t.framework=n.select(t.container).append("g").attr("class","geo "+t.id).call(s.setClipUrl,r),t.project=function(e){var r=t.projection(e);return r?[r[0]-t.xaxis._offset,r[1]-t.yaxis._offset]:[null,null]},t.xaxis={_id:"x",c2p:function(e){return t.project(e)[0]}},t.yaxis={_id:"y",c2p:function(e){return t.project(e)[1]}},t.mockAxis={type:"linear",showexponent:"all",exponentformat:"B"},u.setConvert(t.mockAxis,e)},x.saveViewInitial=function(t){var e=t.center||{},r=t.projection,n=r.rotation||{};t._isScoped?this.viewInitial={"center.lon":e.lon,"center.lat":e.lat,"projection.scale":r.scale}:t._isClipped?this.viewInitial={"projection.scale":r.scale,"projection.rotation.lon":n.lon,"projection.rotation.lat":n.lat}:this.viewInitial={"center.lon":e.lon,"center.lat":e.lat,"projection.scale":r.scale,"projection.rotation.lon":n.lon}},x.render=function(){var t,e=this.projection,r=e.getPath();function n(t){var r=e(t.lonlat);return r?"translate("+r[0]+","+r[1]+")":null}function i(t){return e.isLonLatOverEdges(t.lonlat)?"none":null}for(t in this.basePaths)this.basePaths[t].attr("d",r);for(t in this.dataPaths)this.dataPaths[t].attr("d",function(t){return r(t.geojson)});for(t in this.dataPoints)this.dataPoints[t].attr("display",i).attr("transform",n)}},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../lib":696,"../../lib/topojson_utils":723,"../../registry":827,"../cartesian/axes":744,"../cartesian/select":762,"../plots":808,"./constants":773,"./projections":779,"./zoom":780,d3:148,"topojson-client":517}],775:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/get_data").getSubplotCalcData,a=t("../../lib").counterRegex,o="geo";r.name=o,r.attr=o,r.idRoot=o,r.idRegex=r.attrRegex=a(o),r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t.calcdata,a=e._subplots.geo;void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var s=0;s0&&k<0&&(k+=360);var M,A,T,S=(w+k)/2;if(!c){var E=u?s.projRotate:[S,0,0];M=r("projection.rotation.lon",E[0]),r("projection.rotation.lat",E[1]),r("projection.rotation.roll",E[2]),r("showcoastlines",!u)&&(r("coastlinecolor"),r("coastlinewidth")),r("showocean")&&r("oceancolor")}(c?(A=-96.6,T=38.7):(A=u?S:M,T=(_[0]+_[1])/2),r("center.lon",A),r("center.lat",T),f)&&r("projection.parallels",s.projParallels||[0,60]);r("projection.scale"),r("showland")&&r("landcolor"),r("showlakes")&&r("lakecolor"),r("showrivers")&&(r("rivercolor"),r("riverwidth")),r("showcountries",u&&"usa"!==a)&&(r("countrycolor"),r("countrywidth")),("usa"===a||"north america"===a&&50===n)&&(r("showsubunits",!0),r("subunitcolor"),r("subunitwidth")),u||r("showframe",!0)&&(r("framecolor"),r("framewidth")),r("bgcolor")}e.exports=function(t,e,r){n(t,e,r,{type:"geo",attributes:a,handleDefaults:s,partition:"y"})}},{"../../subplot_defaults":822,"../constants":773,"./layout_attributes":778}],778:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("../../domain").attributes,a=t("../constants"),o=t("../../../plot_api/edit_types").overrideAll,s={range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},showgrid:{valType:"boolean",dflt:!1},tick0:{valType:"number"},dtick:{valType:"number"},gridcolor:{valType:"color",dflt:n.lightLine},gridwidth:{valType:"number",min:0,dflt:1}};e.exports=o({domain:i({name:"geo"},{}),resolution:{valType:"enumerated",values:[110,50],dflt:110,coerceNumber:!0},scope:{valType:"enumerated",values:Object.keys(a.scopeDefaults),dflt:"world"},projection:{type:{valType:"enumerated",values:Object.keys(a.projNames)},rotation:{lon:{valType:"number"},lat:{valType:"number"},roll:{valType:"number"}},parallels:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},scale:{valType:"number",min:0,dflt:1}},center:{lon:{valType:"number"},lat:{valType:"number"}},showcoastlines:{valType:"boolean"},coastlinecolor:{valType:"color",dflt:n.defaultLine},coastlinewidth:{valType:"number",min:0,dflt:1},showland:{valType:"boolean",dflt:!1},landcolor:{valType:"color",dflt:a.landColor},showocean:{valType:"boolean",dflt:!1},oceancolor:{valType:"color",dflt:a.waterColor},showlakes:{valType:"boolean",dflt:!1},lakecolor:{valType:"color",dflt:a.waterColor},showrivers:{valType:"boolean",dflt:!1},rivercolor:{valType:"color",dflt:a.waterColor},riverwidth:{valType:"number",min:0,dflt:1},showcountries:{valType:"boolean"},countrycolor:{valType:"color",dflt:n.defaultLine},countrywidth:{valType:"number",min:0,dflt:1},showsubunits:{valType:"boolean"},subunitcolor:{valType:"color",dflt:n.defaultLine},subunitwidth:{valType:"number",min:0,dflt:1},showframe:{valType:"boolean"},framecolor:{valType:"color",dflt:n.defaultLine},framewidth:{valType:"number",min:0,dflt:1},bgcolor:{valType:"color",dflt:n.background},lonaxis:s,lataxis:s},"plot","from-root")},{"../../../components/color/attributes":569,"../../../plot_api/edit_types":727,"../../domain":770,"../constants":773}],779:[function(t,e,r){"use strict";e.exports=function(t){function e(t,e){return{type:"Feature",id:t.id,properties:t.properties,geometry:r(t.geometry,e)}}function r(e,n){if(!e)return null;if("GeometryCollection"===e.type)return{type:"GeometryCollection",geometries:object.geometries.map(function(t){return r(t,n)})};if(!c.hasOwnProperty(e.type))return null;var i=c[e.type];return t.geo.stream(e,n(i)),i.result()}t.geo.project=function(t,e){var i=e.stream;if(!i)throw new Error("not yet supported");return(t&&n.hasOwnProperty(t.type)?n[t.type]:r)(t,i)};var n={Feature:e,FeatureCollection:function(t,r){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,r)})}}},i=[],a=[],o={point:function(t,e){i.push([t,e])},result:function(){var t=i.length?i.length<2?{type:"Point",coordinates:i[0]}:{type:"MultiPoint",coordinates:i}:null;return i=[],t}},s={lineStart:u,point:function(t,e){i.push([t,e])},lineEnd:function(){i.length&&(a.push(i),i=[])},result:function(){var t=a.length?a.length<2?{type:"LineString",coordinates:a[0]}:{type:"MultiLineString",coordinates:a}:null;return a=[],t}},l={polygonStart:u,lineStart:u,point:function(t,e){i.push([t,e])},lineEnd:function(){var t=i.length;if(t){do{i.push(i[0].slice())}while(++t<4);a.push(i),i=[]}},polygonEnd:u,result:function(){if(!a.length)return null;var t=[],e=[];return a.forEach(function(r){!function(t){if((e=t.length)<4)return!1;for(var e,r=0,n=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++rn^p>n&&r<(h-c)*(n-u)/(p-u)+c&&(i=!i)}return i}(t[0],r))return t.push(e),!0})||t.push([e])}),a=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},c={Point:o,MultiPoint:o,LineString:s,MultiLineString:s,Polygon:l,MultiPolygon:l,Sphere:l};function u(){}var f=1e-6,h=f*f,p=Math.PI,d=p/2,g=(Math.sqrt(p),p/180),v=180/p;function m(t){return t>1?d:t<-1?-d:Math.asin(t)}function y(t){return t>1?0:t<-1?p:Math.acos(t)}var x=t.geo.projection,b=t.geo.projectionMutator;function _(t,e){var r=(2+d)*Math.sin(e);e/=2;for(var n=0,i=1/0;n<10&&Math.abs(i)>f;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(p*(4+p))*t*(1+Math.cos(e)),2*Math.sqrt(p/(4+p))*Math.sin(e)]}t.geo.interrupt=function(e){var r,n=[[[[-p,0],[0,d],[p,0]]],[[[-p,0],[0,-d],[p,0]]]];function i(t,r){for(var i=r<0?-1:1,a=n[+(r<0)],o=0,s=a.length-1;oa[o][2][0];++o);var l=e(t-a[o][1][0],r);return l[0]+=e(a[o][1][0],i*r>i*a[o][0][1]?a[o][0][1]:r)[0],l}e.invert&&(i.invert=function(t,a){for(var o=r[+(a<0)],s=n[+(a<0)],c=0,u=o.length;c=0;--i){var o=n[1][i],l=180*o[0][0]/p,c=180*o[0][1]/p,u=180*o[1][1]/p,f=180*o[2][0]/p,h=180*o[2][1]/p;r.push(s([[f-e,h-e],[f-e,u+e],[l+e,u+e],[l+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(r)]}}(),l)},i},a.lobes=function(t){return arguments.length?(n=t.map(function(t){return t.map(function(t){return[[t[0][0]*p/180,t[0][1]*p/180],[t[1][0]*p/180,t[1][1]*p/180],[t[2][0]*p/180,t[2][1]*p/180]]})}),r=n.map(function(t){return t.map(function(t){var r,n=e(t[0][0],t[0][1])[0],i=e(t[2][0],t[2][1])[0],a=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})}),a):n.map(function(t){return t.map(function(t){return[[180*t[0][0]/p,180*t[0][1]/p],[180*t[1][0]/p,180*t[1][1]/p],[180*t[2][0]/p,180*t[2][1]/p]]})})},a},_.invert=function(t,e){var r=.5*e*Math.sqrt((4+p)/p),n=m(r),i=Math.cos(n);return[t/(2/Math.sqrt(p*(4+p))*(1+i)),m((n+r*(i+2))/(2+d))]},(t.geo.eckert4=function(){return x(_)}).raw=_;var w=t.geo.azimuthalEqualArea.raw;function k(t,e){if(arguments.length<2&&(e=t),1===e)return w;if(e===1/0)return M;function r(r,n){var i=w(r/e,n);return i[0]*=t,i}return r.invert=function(r,n){var i=w.invert(r/t,n);return i[0]*=e,i},r}function M(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function A(t,e){return[3*t/(2*p)*Math.sqrt(p*p/3-e*e),e]}function T(t,e){return[t,1.25*Math.log(Math.tan(p/4+.4*e))]}function S(t){return function(e){var r,n=t*Math.sin(e),i=30;do{e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e))}while(Math.abs(r)>f&&--i>0);return e/2}}M.invert=function(t,e){var r=2*m(e/2);return[t*Math.cos(r/2)/Math.cos(r),r]},(t.geo.hammer=function(){var t=2,e=b(k),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}).raw=k,A.invert=function(t,e){return[2/3*p*t/Math.sqrt(p*p/3-e*e),e]},(t.geo.kavrayskiy7=function(){return x(A)}).raw=A,T.invert=function(t,e){return[t,2.5*Math.atan(Math.exp(.8*e))-.625*p]},(t.geo.miller=function(){return x(T)}).raw=T,S(p);var E=function(t,e,r){var n=S(r);function i(r,i){return[t*r*Math.cos(i=n(i)),e*Math.sin(i)]}return i.invert=function(n,i){var a=m(i/e);return[n/(t*Math.cos(a)),m((2*a+Math.sin(2*a))/r)]},i}(Math.SQRT2/d,Math.SQRT2,p);function C(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791)),e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))]}(t.geo.mollweide=function(){return x(E)}).raw=E,C.invert=function(t,e){var r,n=e,i=25;do{var a=n*n,o=a*a;n-=r=(n*(1.007226+a*(.015085+o*(.028874*a-.044475-.005916*o)))-e)/(1.007226+a*(.045255+o*(.259866*a-.311325-.005916*11*o)))}while(Math.abs(r)>f&&--i>0);return[t/(.8707+(a=n*n)*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979)),n]},(t.geo.naturalEarth=function(){return x(C)}).raw=C;var L=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];function z(t,e){var r,n=Math.min(18,36*Math.abs(e)/p),i=Math.floor(n),a=n-i,o=(r=L[i])[0],s=r[1],l=(r=L[++i])[0],c=r[1],u=(r=L[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?d:-d)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function O(t,e){return[t*Math.cos(e),e]}function I(t,e){var r,n=Math.cos(e),i=(r=y(n*Math.cos(t/=2)))?r/Math.sin(r):1;return[2*n*Math.sin(t)*i,Math.sin(e)*i]}function P(t,e){var r=I(t,e);return[(r[0]+t/d)/2,(r[1]+e)/2]}L.forEach(function(t){t[1]*=1.0144}),z.invert=function(t,e){var r=e/d,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=L[a][1],s=L[a+1][1],l=L[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,p=u/c,m=f*(1-p*f*(1-2*p*f));if(m>=0||1===a){n=(e>=0?5:-5)*(m+i);var y,x=50;do{m=(i=Math.min(18,Math.abs(n)/5))-(a=Math.floor(i)),o=L[a][1],s=L[a+1][1],l=L[Math.min(19,a+2)][1],n-=(y=(e>=0?d:-d)*(s+m*(l-o)/2+m*m*(l-2*s+o)/2)-e)*v}while(Math.abs(y)>h&&--x>0);break}}while(--a>=0);var b=L[a][0],_=L[a+1][0],w=L[Math.min(19,a+2)][0];return[t/(_+m*(w-b)/2+m*m*(w-2*_+b)/2),n*g]},(t.geo.robinson=function(){return x(z)}).raw=z,O.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return x(O)}).raw=O,I.invert=function(t,e){if(!(t*t+4*e*e>p*p+f)){var r=t,n=e,i=25;do{var a,o=Math.sin(r),s=Math.sin(r/2),l=Math.cos(r/2),c=Math.sin(n),u=Math.cos(n),h=Math.sin(2*n),d=c*c,g=u*u,v=s*s,m=1-g*l*l,x=m?y(u*l)*Math.sqrt(a=1/m):a=0,b=2*x*u*s-t,_=x*c-e,w=a*(g*v+x*u*l*d),k=a*(.5*o*h-2*x*c*s),M=.25*a*(h*s-x*c*g*o),A=a*(d*l+x*v*u),T=k*M-A*w;if(!T)break;var S=(_*k-b*A)/T,E=(b*M-_*w)/T;r-=S,n-=E}while((Math.abs(S)>f||Math.abs(E)>f)&&--i>0);return[r,n]}},(t.geo.aitoff=function(){return x(I)}).raw=I,P.invert=function(t,e){var r=t,n=e,i=25;do{var a,o=Math.cos(n),s=Math.sin(n),l=Math.sin(2*n),c=s*s,u=o*o,h=Math.sin(r),p=Math.cos(r/2),g=Math.sin(r/2),v=g*g,m=1-u*p*p,x=m?y(o*p)*Math.sqrt(a=1/m):a=0,b=.5*(2*x*o*g+r/d)-t,_=.5*(x*s+n)-e,w=.5*a*(u*v+x*o*p*c)+.5/d,k=a*(h*l/4-x*s*g),M=.125*a*(l*g-x*s*u*h),A=.5*a*(c*p+x*v*o)+.5,T=k*M-A*w,S=(_*k-b*A)/T,E=(b*M-_*w)/T;r-=S,n-=E}while((Math.abs(S)>f||Math.abs(E)>f)&&--i>0);return[r,n]},(t.geo.winkel3=function(){return x(P)}).raw=P}},{}],780:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=Math.PI/180,o=180/Math.PI,s={cursor:"pointer"},l={cursor:"auto"};function c(t,e){return n.behavior.zoom().translate(e.translate()).scale(e.scale())}function u(t,e,r){var n=t.id,a=t.graphDiv,o=a.layout[n],s=a._fullLayout[n],l={};function c(t,e){var r=i.nestedProperty(s,t);r.get()!==e&&(r.set(e),i.nestedProperty(o,t).set(e),l[n+"."+t]=e)}r(c),c("projection.scale",e.scale()/t.fitScale),a.emit("plotly_relayout",l)}function f(t,e){var r=c(0,e);function i(r){var n=e.invert(t.midPt);r("center.lon",n[0]),r("center.lat",n[1])}return r.on("zoomstart",function(){n.select(this).style(s)}).on("zoom",function(){e.scale(n.event.scale).translate(n.event.translate),t.render()}).on("zoomend",function(){n.select(this).style(l),u(t,e,i)}),r}function h(t,e){var r,i,a,o,f,h,p,d,g,v=c(0,e),m=2;function y(t){return e.invert(t)}function x(r){var n=e.rotate(),i=e.invert(t.midPt);r("projection.rotation.lon",-n[0]),r("center.lon",i[0]),r("center.lat",i[1])}return v.on("zoomstart",function(){n.select(this).style(s),r=n.mouse(this),i=e.rotate(),a=e.translate(),o=i,f=y(r)}).on("zoom",function(){if(h=n.mouse(this),function(t){var r=y(t);if(!r)return!0;var n=e(r);return Math.abs(n[0]-t[0])>m||Math.abs(n[1]-t[1])>m}(r))return v.scale(e.scale()),void v.translate(e.translate());e.scale(n.event.scale),e.translate([a[0],n.event.translate[1]]),f?y(h)&&(d=y(h),p=[o[0]+(d[0]-f[0]),i[1],i[2]],e.rotate(p),o=p):f=y(r=h),g=!0,t.render()}).on("zoomend",function(){n.select(this).style(l),g&&u(t,e,x)}),v}function p(t,e){var r,i={r:e.rotate(),k:e.scale()},f=c(0,e),h=function(t){var e=0,r=arguments.length,i=[];for(;++ed?(a=(f>0?90:-90)-p,i=0):(a=Math.asin(f/d)*o-p,i=Math.sqrt(d*d-f*f));var v=180-a-2*p,y=(Math.atan2(h,u)-Math.atan2(c,i))*o,x=(Math.atan2(h,u)-Math.atan2(c,-i))*o,b=g(r[0],r[1],a,y),_=g(r[0],r[1],v,x);return b<=_?[a,y,r[2]]:[v,x,r[2]]}(k,r,E);isFinite(M[0])&&isFinite(M[1])&&isFinite(M[2])||(M=E),e.rotate(M),E=M}}else r=d(e,T=b);h.of(this,arguments)({type:"zoom"})}),A=h.of(this,arguments),p++||A({type:"zoomstart"})}).on("zoomend",function(){var r;n.select(this).style(l),v.call(f,"zoom",null),r=h.of(this,arguments),--p||r({type:"zoomend"}),u(t,e,x)}).on("zoom.redraw",function(){t.render()}),n.rebind(f,h,"on")}function d(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&function(t){var e=t[0]*a,r=t[1]*a,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}(r)}function g(t,e,r,n){var i=v(r-t),a=v(n-e);return Math.sqrt(i*i+a*a)}function v(t){return(t%360+540)%360-180}function m(t,e,r){var n=r*a,i=t.slice(),o=0===e?1:0,s=2===e?1:2,l=Math.cos(n),c=Math.sin(n);return i[o]=t[o]*l-t[s]*c,i[s]=t[s]*l+t[o]*c,i}function y(t,e){for(var r=0,n=0,i=t.length;nMath.abs(s)?(c.boxEnd[1]=c.boxStart[1]+Math.abs(a)*_*(s>=0?1:-1),c.boxEnd[1]l[3]&&(c.boxEnd[1]=l[3],c.boxEnd[0]=c.boxStart[0]+(l[3]-c.boxStart[1])/Math.abs(_))):(c.boxEnd[0]=c.boxStart[0]+Math.abs(s)/_*(a>=0?1:-1),c.boxEnd[0]l[2]&&(c.boxEnd[0]=l[2],c.boxEnd[1]=c.boxStart[1]+(l[2]-c.boxStart[0])*Math.abs(_)))}}else c.boxEnabled?(a=c.boxStart[0]!==c.boxEnd[0],s=c.boxStart[1]!==c.boxEnd[1],a||s?(a&&(v(0,c.boxStart[0],c.boxEnd[0]),t.xaxis.autorange=!1),s&&(v(1,c.boxStart[1],c.boxEnd[1]),t.yaxis.autorange=!1),t.relayoutCallback()):t.glplot.setDirty(),c.boxEnabled=!1,c.boxInited=!1):c.boxInited&&(c.boxInited=!1);break;case"pan":c.boxEnabled=!1,c.boxInited=!1,e?(c.panning||(c.dragStart[0]=n,c.dragStart[1]=i),Math.abs(c.dragStart[0]-n)Math.abs(e))c.rotate(a,0,0,-t*r*Math.PI*d.rotateSpeed/window.innerWidth);else{var o=-d.zoomSpeed*i*e/window.innerHeight*(a-c.lastT())/20;c.pan(a,0,0,f*(Math.exp(o)-1))}}},!0),d};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset"),l=t("has-passive-events")},{"3d-view":45,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421,"right-now":480}],787:[function(t,e,r){"use strict";var n=t("../../plot_api/edit_types").overrideAll,i=t("../../components/fx/layout_attributes"),a=t("./scene"),o=t("../get_data").getSubplotData,s=t("../../lib"),l=t("../../constants/xmlns_namespaces");r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=r.attrRegex=s.counterRegex("scene"),r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.baseLayoutAttrOverrides=n({hoverlabel:i.hoverlabel},"plot","nested"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=e._subplots.gl3d,i=0;i1;o(t,e,r,{type:"gl3d",attributes:l,handleDefaults:c,fullLayout:e,font:e.font,fullData:r,getDfltFromLayout:function(e){if(!i)return n.validate(t[e],l[e])?t[e]:void 0},paper_bgcolor:e.paper_bgcolor,calendar:e.calendar})}},{"../../../components/color":570,"../../../lib":696,"../../../registry":827,"../../subplot_defaults":822,"./axis_defaults":790,"./layout_attributes":793}],793:[function(t,e,r){"use strict";var n=t("./axis_attributes"),i=t("../../domain").attributes,a=t("../../../lib/extend").extendFlat,o=t("../../../lib").counterRegex;function s(t,e,r){return{x:{valType:"number",dflt:t,editType:"camera"},y:{valType:"number",dflt:e,editType:"camera"},z:{valType:"number",dflt:r,editType:"camera"},editType:"camera"}}e.exports={_arrayAttrRegexps:[o("scene",".annotations",!0)],bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"plot"},camera:{up:a(s(0,0,1),{}),center:a(s(0,0,0),{}),eye:a(s(1.25,1.25,1.25),{}),editType:"camera"},domain:i({name:"scene",editType:"plot"}),aspectmode:{valType:"enumerated",values:["auto","cube","data","manual"],dflt:"auto",editType:"plot",impliedEdits:{"aspectratio.x":void 0,"aspectratio.y":void 0,"aspectratio.z":void 0}},aspectratio:{x:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},y:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},z:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},editType:"plot",impliedEdits:{aspectmode:"manual"}},xaxis:n,yaxis:n,zaxis:n,dragmode:{valType:"enumerated",values:["orbit","turntable","zoom","pan",!1],dflt:"turntable",editType:"plot"},hovermode:{valType:"enumerated",values:["closest",!1],dflt:"closest",editType:"modebar"},editType:"plot",_deprecated:{cameraposition:{valType:"info_array",editType:"camera"}}}},{"../../../lib":696,"../../../lib/extend":685,"../../domain":770,"./axis_attributes":789}],794:[function(t,e,r){"use strict";var n=t("../../../lib/str2rgbarray"),i=["xaxis","yaxis","zaxis"];function a(){this.enabled=[!0,!0,!0],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.drawSides=[!0,!0,!0],this.lineWidth=[1,1,1]}a.prototype.merge=function(t){for(var e=0;e<3;++e){var r=t[i[e]];r.visible?(this.enabled[e]=r.showspikes,this.colors[e]=n(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness):(this.enabled[e]=!1,this.drawSides[e]=!1)}},e.exports=function(t){var e=new a;return e.merge(t),e}},{"../../../lib/str2rgbarray":719}],795:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.axesOptions,r=t.glplot.axesPixels,l=t.fullSceneLayout,c=[[],[],[]],u=0;u<3;++u){var f=l[o[u]];if(f._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(f._length)===1/0)c[u]=[];else{f._input_range=f.range.slice(),f.range[0]=r[u].lo/t.dataScale[u],f.range[1]=r[u].hi/t.dataScale[u],f._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var p=f.nticks||i.constrain(f._length/40,4,9);n.autoTicks(f,Math.abs(f.range[1]-f.range[0])/p)}for(var d=n.calcTicks(f),g=0;g")}else v=c.textLabel;t.fullSceneLayout.hovermode&&f.loneHover({x:(.5+.5*d[0]/d[3])*i,y:(.5-.5*d[1]/d[3])*a,xLabel:w,yLabel:k,zLabel:M,text:v,name:l.name,color:f.castHoverOption(e,m,"bgcolor")||l.color,borderColor:f.castHoverOption(e,m,"bordercolor"),fontFamily:f.castHoverOption(e,m,"font.family"),fontSize:f.castHoverOption(e,m,"font.size"),fontColor:f.castHoverOption(e,m,"font.color")},{container:r,gd:t.graphDiv});var T={x:c.traceCoordinate[0],y:c.traceCoordinate[1],z:c.traceCoordinate[2],data:e._input,fullData:e,curveNumber:e.index,pointNumber:m};e._module.eventData&&(T=e._module.eventData(T,c,e,{},m)),f.appendArrayPointValue(T,e,m);var S={points:[T]};c.buttons&&c.distance<5?t.graphDiv.emit("plotly_click",S):t.graphDiv.emit("plotly_hover",S),o=S}else f.loneUnhover(r),t.graphDiv.emit("plotly_unhover",o);t.drawAnnotations(t)}.bind(null,t),t.traces={},!0}function b(t,e){var r=document.createElement("div"),n=t.container;this.graphDiv=t.graphDiv;var i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.top=i.style.left="0px",i.style.width=i.style.height="100%",i.style["z-index"]=20,i.style["pointer-events"]="none",r.appendChild(i),this.svgContainer=i,r.id=t.id,r.style.position="absolute",r.style.top=r.style.left="0px",r.style.width=r.style.height="100%",n.appendChild(r),this.fullLayout=e,this.id=t.id||"scene",this.fullSceneLayout=e[this.id],this.plotArgs=[[],{},{}],this.axesOptions=v(e[this.id]),this.spikeOptions=m(e[this.id]),this.container=r,this.staticMode=!!t.staticPlot,this.pixelRatio=t.plotGlPixelRatio||2,this.dataScale=[1,1,1],this.contourLevels=[[],[],[]],this.convertAnnotations=l.getComponentMethod("annotations3d","convert"),this.drawAnnotations=l.getComponentMethod("annotations3d","draw"),x(this)}var _=b.prototype;_.recoverContext=function(){var t=this,e=this.glplot.gl,r=this.glplot.canvas;this.glplot.dispose(),requestAnimationFrame(function n(){e.isContextLost()?requestAnimationFrame(n):x(t,t.fullLayout,r,e)?t.plot.apply(t,t.plotArgs):c.error("Catastrophic and unrecoverable WebGL error. Context lost.")})};var w=["xaxis","yaxis","zaxis"];function k(t,e,r){for(var n=t.fullSceneLayout,i=0;i<3;i++){var a=w[i],o=a.charAt(0),s=n[a],l=e[o],u=e[o+"calendar"],f=e["_"+o+"length"];if(c.isArrayOrTypedArray(l))for(var h,p=0;p<(f||l.length);p++)if(c.isArrayOrTypedArray(l[p]))for(var d=0;dg[1][a])g[0][a]=-1,g[1][a]=1;else{var E=g[1][a]-g[0][a];g[0][a]-=E/32,g[1][a]+=E/32}if("reversed"===s.autorange){var C=g[0][a];g[0][a]=g[1][a],g[1][a]=C}}else{var L=s.range;g[0][a]=s.r2l(L[0]),g[1][a]=s.r2l(L[1])}g[0][a]===g[1][a]&&(g[0][a]-=1,g[1][a]+=1),v[a]=g[1][a]-g[0][a],this.glplot.bounds[0][a]=g[0][a]*p[a],this.glplot.bounds[1][a]=g[1][a]*p[a]}var z=[1,1,1];for(a=0;a<3;++a){var O=m[l=(s=c[w[a]]).type];z[a]=Math.pow(O.acc,1/O.count)/p[a]}var I;if("auto"===c.aspectmode)I=Math.max.apply(null,z)/Math.min.apply(null,z)<=4?z:[1,1,1];else if("cube"===c.aspectmode)I=[1,1,1];else if("data"===c.aspectmode)I=z;else{if("manual"!==c.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var P=c.aspectratio;I=[P.x,P.y,P.z]}c.aspectratio.x=u.aspectratio.x=I[0],c.aspectratio.y=u.aspectratio.y=I[1],c.aspectratio.z=u.aspectratio.z=I[2],this.glplot.aspect=I;var D=c.domain||null,R=e._size||null;if(D&&R){var B=this.container.style;B.position="absolute",B.left=R.l+D.x[0]*R.w+"px",B.top=R.t+(1-D.y[1])*R.h+"px",B.width=R.w*(D.x[1]-D.x[0])+"px",B.height=R.h*(D.y[1]-D.y[0])+"px"}this.glplot.redraw()}},_.destroy=function(){this.glplot&&(this.camera.mouseListener.enabled=!1,this.container.removeEventListener("wheel",this.camera.wheelListener),this.camera=this.glplot.camera=null,this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null)},_.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),M(this.glplot.camera)},_.setCamera=function(t){var e;this.glplot.camera.lookAt.apply(this,[[(e=t).eye.x,e.eye.y,e.eye.z],[e.center.x,e.center.y,e.center.z],[e.up.x,e.up.y,e.up.z]])},_.saveCamera=function(t){var e=this.getCamera(),r=c.nestedProperty(t,this.id+".camera"),n=r.get(),i=!1;function a(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}if(void 0===n)i=!0;else for(var o=0;o<3;o++)for(var s=0;s<3;s++)if(!a(e,n,o,s)){i=!0;break}return i&&r.set(e),i},_.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},_.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(n),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,i=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var a=new Uint8Array(r*i*4);e.readPixels(0,0,r,i,e.RGBA,e.UNSIGNED_BYTE,a);for(var o=0,s=i-1;o0)}function l(t){var e={},r={};switch(t.type){case"circle":n.extendFlat(r,{"circle-radius":t.circle.radius,"circle-color":t.color,"circle-opacity":t.opacity});break;case"line":n.extendFlat(r,{"line-width":t.line.width,"line-color":t.color,"line-opacity":t.opacity});break;case"fill":n.extendFlat(r,{"fill-color":t.color,"fill-outline-color":t.fill.outlinecolor,"fill-opacity":t.opacity});break;case"symbol":var a=t.symbol,o=i(a.textposition,a.iconsize);n.extendFlat(e,{"icon-image":a.icon+"-15","icon-size":a.iconsize/10,"text-field":a.text,"text-size":a.textfont.size,"text-anchor":o.anchor,"text-offset":o.offset}),n.extendFlat(r,{"icon-color":t.color,"text-color":a.textfont.color,"text-opacity":t.opacity})}return{layout:e,paint:r}}o.update=function(t){this.visible?this.needsNewSource(t)?(this.removeLayer(),this.updateSource(t),this.updateLayer(t)):this.needsNewLayer(t)?this.updateLayer(t):this.updateStyle(t):(this.updateSource(t),this.updateLayer(t)),this.visible=s(t)},o.needsNewSource=function(t){return this.sourceType!==t.sourcetype||this.source!==t.source||this.layerType!==t.type},o.needsNewLayer=function(t){return this.layerType!==t.type||this.below!==t.below},o.updateSource=function(t){var e=this.map;if(e.getSource(this.idSource)&&e.removeSource(this.idSource),this.sourceType=t.sourcetype,this.source=t.source,s(t)){var r=function(t){var e,r=t.sourcetype,n=t.source,i={type:r};"geojson"===r?e="data":"vector"===r&&(e="string"==typeof n?"url":"tiles");return i[e]=n,i}(t);e.addSource(this.idSource,r)}},o.updateLayer=function(t){var e=this.map,r=l(t);this.removeLayer(),this.layerType=t.type,s(t)&&e.addLayer({id:this.idLayer,source:this.idSource,"source-layer":t.sourcelayer||"",type:t.type,layout:r.layout,paint:r.paint},t.below)},o.updateStyle=function(t){if(s(t)){var e=l(t);this.mapbox.setOptions(this.idLayer,"setLayoutProperty",e.layout),this.mapbox.setOptions(this.idLayer,"setPaintProperty",e.paint)}},o.removeLayer=function(){var t=this.map;t.getLayer(this.idLayer)&&t.removeLayer(this.idLayer)},o.dispose=function(){var t=this.map;t.removeLayer(this.idLayer),t.removeSource(this.idSource)},e.exports=function(t,e,r){var n=new a(t,e);return n.update(r),n}},{"../../lib":696,"./convert_text_opts":801}],804:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color").defaultLine,a=t("../domain").attributes,o=t("../font_attributes"),s=t("../../traces/scatter/attributes").textposition,l=t("../../plot_api/edit_types").overrideAll,c=t("../../plot_api/plot_template").templatedArray,u=o({});u.family.dflt="Open Sans Regular, Arial Unicode MS Regular",e.exports=l({_arrayAttrRegexps:[n.counterRegex("mapbox",".layers",!0)],domain:a({name:"mapbox"}),accesstoken:{valType:"string",noBlank:!0,strict:!0},style:{valType:"any",values:["basic","streets","outdoors","light","dark","satellite","satellite-streets"],dflt:"basic"},center:{lon:{valType:"number",dflt:0},lat:{valType:"number",dflt:0}},zoom:{valType:"number",dflt:1},bearing:{valType:"number",dflt:0},pitch:{valType:"number",dflt:0},layers:c("layer",{visible:{valType:"boolean",dflt:!0},sourcetype:{valType:"enumerated",values:["geojson","vector"],dflt:"geojson"},source:{valType:"any"},sourcelayer:{valType:"string",dflt:""},type:{valType:"enumerated",values:["circle","line","fill","symbol"],dflt:"circle"},below:{valType:"string",dflt:""},color:{valType:"color",dflt:i},opacity:{valType:"number",min:0,max:1,dflt:1},circle:{radius:{valType:"number",dflt:15}},line:{width:{valType:"number",dflt:2}},fill:{outlinecolor:{valType:"color",dflt:i}},symbol:{icon:{valType:"string",dflt:"marker"},iconsize:{valType:"number",dflt:10},text:{valType:"string",dflt:""},textfont:u,textposition:n.extendFlat({},s,{arrayOk:!1})}})},"plot","from-root")},{"../../components/color":570,"../../lib":696,"../../plot_api/edit_types":727,"../../plot_api/plot_template":734,"../../traces/scatter/attributes":1043,"../domain":770,"../font_attributes":771}],805:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../subplot_defaults"),a=t("../array_container_defaults"),o=t("./layout_attributes");function s(t,e,r,n){r("accesstoken",n.accessToken),r("style"),r("center.lon"),r("center.lat"),r("zoom"),r("bearing"),r("pitch"),a(t,e,{name:"layers",handleItemDefaults:l}),e._input=t}function l(t,e){function r(r,i){return n.coerce(t,e,o.layers,r,i)}if(r("visible")){var i=r("sourcetype");r("source"),"vector"===i&&r("sourcelayer");var a=r("type");r("below"),r("color"),r("opacity"),"circle"===a&&r("circle.radius"),"line"===a&&r("line.width"),"fill"===a&&r("fill.outlinecolor"),"symbol"===a&&(r("symbol.icon"),r("symbol.iconsize"),r("symbol.text"),n.coerceFont(r,"symbol.textfont"),r("symbol.textposition"))}}e.exports=function(t,e,r){i(t,e,r,{type:"mapbox",attributes:o,handleDefaults:s,partition:"y",accessToken:e._mapboxAccessToken})}},{"../../lib":696,"../array_container_defaults":740,"../subplot_defaults":822,"./layout_attributes":804}],806:[function(t,e,r){"use strict";var n=t("mapbox-gl"),i=t("../../components/fx"),a=t("../../lib"),o=t("../../components/dragelement"),s=t("../cartesian/select").prepSelect,l=t("../cartesian/select").selectOnClick,c=t("./constants"),u=t("./layout_attributes"),f=t("./layers");function h(t){this.id=t.id,this.gd=t.gd,this.container=t.container,this.isStatic=t.staticPlot;var e=t.fullLayout;this.uid=e._uid+"-"+this.id,this.opts=e[this.id],this.div=null,this.xaxis=null,this.yaxis=null,this.createFramework(e),this.map=null,this.accessToken=null,this.styleObj=null,this.traceHash={},this.layerList=[]}var p=h.prototype;function d(t){var e=u.style.values,r=u.style.dflt,n={};return a.isPlainObject(t)?(n.id=t.id,n.style=t):"string"==typeof t?(n.id=t,n.style=-1!==e.indexOf(t)?g(t):t):(n.id=r,n.style=g(r)),n.transition={duration:0,delay:0},n}function g(t){return c.styleUrlPrefix+t+"-"+c.styleUrlSuffix}function v(t){return[t.lon,t.lat]}e.exports=function(t){return new h(t)},p.plot=function(t,e,r){var n,i=this,a=i.opts=e[this.id];i.map&&a.accesstoken!==i.accessToken&&(i.map.remove(),i.map=null,i.styleObj=null,i.traceHash=[],i.layerList={}),n=i.map?new Promise(function(r,n){i.updateMap(t,e,r,n)}):new Promise(function(r,n){i.createMap(t,e,r,n)}),r.push(n)},p.createMap=function(t,e,r,a){var o=this,s=o.gd,u=o.opts,f=o.styleObj=d(u.style);o.accessToken=u.accesstoken;var h=o.map=new n.Map({container:o.div,style:f.style,center:v(u.center),zoom:u.zoom,bearing:u.bearing,pitch:u.pitch,interactive:!o.isStatic,preserveDrawingBuffer:o.isStatic,doubleClickZoom:!1,boxZoom:!1}),p=c.controlContainerClassName,g=o.div.getElementsByClassName(p)[0];if(o.div.removeChild(g),h._canvas.style.left="0px",h._canvas.style.top="0px",o.rejectOnError(a),h.once("load",function(){o.updateData(t),o.updateLayout(e),o.resolveOnRender(r)}),!o.isStatic){var m=!1;h.on("moveend",function(t){if(o.map){var e=o.getView();u._input.center=u.center=e.center,u._input.zoom=u.zoom=e.zoom,u._input.bearing=u.bearing=e.bearing,u._input.pitch=u.pitch=e.pitch,(t.originalEvent||m)&&x(e),m=!1}}),h.on("wheel",function(){m=!0}),h.on("mousemove",function(t){var e=o.div.getBoundingClientRect();t.clientX=t.point.x+e.left,t.clientY=t.point.y+e.top,t.target.getBoundingClientRect=function(){return e},o.xaxis.p2c=function(){return t.lngLat.lng},o.yaxis.p2c=function(){return t.lngLat.lat},i.hover(s,t,o.id)}),h.on("dragstart",y),h.on("zoomstart",y),h.on("dblclick",function(){s.emit("plotly_doubleclick",null);var t=o.viewInitial;h.setCenter(v(t.center)),h.setZoom(t.zoom),h.setBearing(t.bearing),h.setPitch(t.pitch);var e=o.getView();u._input.center=u.center=e.center,u._input.zoom=u.zoom=e.zoom,u._input.bearing=u.bearing=e.bearing,u._input.pitch=u.pitch=e.pitch,x(e)}),o.clearSelect=function(){s._fullLayout._zoomlayer.selectAll(".select-outline").remove()},o.onClickInPanFn=function(t){return function(e){var r=s._fullLayout.clickmode;r.indexOf("select")>-1&&l(e.originalEvent,s,[o.xaxis],[o.yaxis],o.id,t),r.indexOf("event")>-1&&i.click(s,e.originalEvent)}}}function y(){i.loneUnhover(e._toppaper)}function x(t){var e=o.id,r={};for(var n in t)r[e+"."+n]=t[n];s.emit("plotly_relayout",r)}},p.updateMap=function(t,e,r,n){var i=this,a=i.map;i.rejectOnError(n);var o=d(i.opts.style);i.styleObj.id!==o.id?(i.styleObj=o,a.setStyle(o.style),a.once("styledata",function(){i.traceHash={},i.updateData(t),i.updateLayout(e),i.resolveOnRender(r)})):(i.updateData(t),i.updateLayout(e),i.resolveOnRender(r))},p.updateData=function(t){var e,r,n,i,a=this.traceHash;for(n=0;n=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}(t,o),s.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),i=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return i.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),i.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,i={};function o(t){for(var r=!0,a=0;a1&&I.length>1){for(a.getComponentMethod("grid","sizeDefaults")(c,s),o=0;o15&&I.length>15&&0===s.shapes.length&&0===s.images.length,s._hasCartesian=s._has("cartesian"),s._hasGeo=s._has("geo"),s._hasGL3D=s._has("gl3d"),s._hasGL2D=s._has("gl2d"),s._hasTernary=s._has("ternary"),s._hasPie=s._has("pie"),v.linkSubplots(h,s,u,i),v.cleanPlot(h,s,u,i),d(s,i),v.doAutoMargin(t);var F=f.list(t);for(o=0;o0){var f=1-2*s;n=Math.round(f*n),a=Math.round(f*a)}}var h=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-a)>1;(g||d)&&(d&&(r.width=n),g&&(r.height=a)),t._initialAutoSize||(t._initialAutoSize={width:n,height:a}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var i,o,s,c=a.componentsRegistry,u=e._basePlotModules,f=a.subplotsRegistry.cartesian;for(i in c)(s=c[i]).includeBasePlot&&s.includeBasePlot(t,e);for(var h in u.length||u.push(f),e._has("cartesian")&&(a.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[h].sort(l.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var l=void 0!==r.xl?r.xl:r.x,c=void 0!==r.xr?r.xr:r.x,u=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;i[e]={l:{val:l,size:r.l+o},r:{val:c,size:r.r+o},b:{val:f,size:r.b+o},t:{val:u,size:r.t+o}},a[e]=1}else delete i[e],delete a[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),A(e);var r=e._size,n=JSON.stringify(r),o=Math.max(e.margin.l||0,0),s=Math.max(e.margin.r||0,0),l=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin,f=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var h in u)f[h]||delete u[h];for(var p in u.base={l:{val:0,size:o},r:{val:1,size:s},t:{val:1,size:l},b:{val:0,size:c}},u){var d=u[p].l||{},g=u[p].b||{},v=d.val,m=d.size,y=g.val,x=g.size;for(var b in u){if(i(m)&&u[b].r){var _=u[b].r.val,w=u[b].r.size;if(_>v){var k=(m*_+(w-e.width)*v)/(_-v),M=(w*(1-v)+(m-e.width)*(1-_))/(_-v);k>=0&&M>=0&&k+M>o+s&&(o=k,s=M)}}if(i(x)&&u[b].t){var T=u[b].t.val,S=u[b].t.size;if(T>y){var E=(x*T+(S-e.height)*y)/(T-y),C=(S*(1-y)+(x-e.height)*(1-T))/(T-y);E>=0&&C>=0&&E+C>c+l&&(c=E,l=C)}}}}}if(r.l=Math.round(o),r.r=Math.round(s),r.t=Math.round(l),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,a.call("plot",t)},v.graphJson=function(t,e,r,n,i){(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var a=i?t._fullData:t.data,o=i?t._fullLayout:t.layout,s=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(l.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!l.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;i[e]=c(t[e])}return i}return Array.isArray(t)?t.map(c):l.isTypedArray(t)?l.simpleMap(t,l.identity):l.isJSDate(t)?l.ms2DateTimeLocal(+t):t}var u={data:(a||[]).map(function(t){var r=c(t);return e&&delete r.fit,r})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),s&&(u.frames=c(s)),"object"===n?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var r,n,i,a=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),i.redraw&&t._transitionData._interruptCallbacks.push(function(){return a.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,s,c=0,u=0;function f(){return c++,function(){var r;u++,p||u!==c||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(i.redraw)return a.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var d=t._fullLayout._basePlotModules,g=!1;if(r)for(s=0;s=0;s--)if(o[s].enabled){r._indexToPoints=o[s]._indexToPoints;break}n&&n.calc&&(a=n.calc(t,r))}Array.isArray(a)&&a[0]||(a=[{x:u,y:u}]),a[0].t||(a[0].t={}),a[0].trace=r,d[e]=a}}for(y&&T(c),i=0;i1e-10?t:0}function h(t,e,r){e=e||0,r=r||0;for(var n=t.length,i=new Array(n),a=0;a0?r:1/0}),i=n.mod(r+1,e.length);return[e[r],e[i]]},findIntersectionXY:c,findXYatLength:function(t,e,r,n){var i=-e*r,a=e*e+1,o=2*(e*i-r),s=i*i+r*r-t*t,l=Math.sqrt(o*o-4*a*s),c=(-o+l)/(2*a),u=(-o-l)/(2*a);return[[c,e*c+i+n],[u,e*u+i+n]]},clampTiny:f,pathPolygon:function(t,e,r,n,i,a){return"M"+h(u(t,e,r,n),i,a).join("L")},pathPolygonAnnulus:function(t,e,r,n,i,a,o){var s,l;t=0?h.angularAxis.domain:n.extent(k),E=Math.abs(k[1]-k[0]);A&&!M&&(E=0);var C=S.slice();T&&M&&(C[1]+=E);var L=h.angularAxis.ticksCount||4;L>8&&(L=L/(L/8)+L%8),h.angularAxis.ticksStep&&(L=(C[1]-C[0])/L);var z=h.angularAxis.ticksStep||(C[1]-C[0])/(L*(h.minorTicks+1));w&&(z=Math.max(Math.round(z),1)),C[2]||(C[2]=z);var O=n.range.apply(this,C);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=n.scale.linear().domain(C.slice(0,2)).range("clockwise"===h.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=T?E:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var I=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),P=this.appendChild(this.ownerDocument.importNode(I.documentElement,!0));t=n.select(P)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var D,R=t.select(".chart-group"),B={fill:"none",stroke:h.tickColor},F={"font-size":h.font.size,"font-family":h.font.family,fill:h.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+h.font.outlineColor}).join(",")};if(h.showLegend){D=t.select(".legend-group").attr({transform:"translate("+[x,h.margin.top]+")"}).style({display:"block"});var N=p.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:D,elements:N,reverseOrder:h.legend.reverseOrder})})();var j=D.node().getBBox();x=Math.min(h.width-j.width-h.margin.left-h.margin.right,h.height-h.margin.top-h.margin.bottom)/2,x=Math.max(10,x),_=[h.margin.left+x,h.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),D.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else D=t.select(".legend-group").style({display:"none"});t.attr({width:h.width,height:h.height}).style({opacity:h.opacity}),R.attr("transform","translate("+_+")").style({cursor:"crosshair"});var V=[(h.width-(h.margin.left+h.margin.right+2*x+(j?j.width:0)))/2,(h.height-(h.margin.top+h.margin.bottom+2*x))/2];if(V[0]=Math.max(0,V[0]),V[1]=Math.max(0,V[1]),t.select(".outer-group").attr("transform","translate("+V+")"),h.title){var U=t.select("g.title-group text").style(F).text(h.title),q=U.node().getBBox();U.attr({x:_[0]-q.width/2,y:_[1]-x-20})}var H=t.select(".radial.axis-group");if(h.radialAxis.gridLinesVisible){var G=H.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(B),G.attr("r",r),G.exit().remove()}H.select("circle.outside-circle").attr({r:x}).style(B);var W=t.select("circle.background-circle").attr({r:x}).style({fill:h.backgroundColor,stroke:h.stroke});function Y(t,e){return s(t)%360+h.orientation}if(h.radialAxis.visible){var X=n.svg.axis().scale(r).ticks(5).tickSize(5);H.call(X).attr({transform:"rotate("+h.radialAxis.orientation+")"}),H.selectAll(".domain").style(B),H.selectAll("g>text").text(function(t,e){return this.textContent+h.radialAxis.ticksSuffix}).style(F).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===h.radialAxis.tickOrientation?"rotate("+-h.radialAxis.orientation+") translate("+[0,F["font-size"]]+")":"translate("+[0,F["font-size"]]+")"}}),H.selectAll("g>line").style({stroke:"black"})}var Z=t.select(".angular.axis-group").selectAll("g.angular-tick").data(O),$=Z.enter().append("g").classed("angular-tick",!0);Z.attr({transform:function(t,e){return"rotate("+Y(t)+")"}}).style({display:h.angularAxis.visible?"block":"none"}),Z.exit().remove(),$.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(h.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(h.minorTicks+1)==0)}).style(B),$.selectAll(".minor").style({stroke:h.minorTickColor}),Z.select("line.grid-line").attr({x1:h.tickLength?x-h.tickLength:0,x2:x}).style({display:h.angularAxis.gridLinesVisible?"block":"none"}),$.append("text").classed("axis-text",!0).style(F);var J=Z.select("text.axis-text").attr({x:x+h.labelOffset,dy:a+"em",transform:function(t,e){var r=Y(t),n=x+h.labelOffset,i=h.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:h.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(h.minorTicks+1)!=0?"":w?w[t]+h.angularAxis.ticksSuffix:t+h.angularAxis.ticksSuffix}).style(F);h.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(h.minorTicks+1)!=0?"":h.angularAxis.rewriteTicks(this.textContent,e)});var K=n.max(R.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));D.attr({transform:"translate("+[x+K,h.margin.top]+")"});var Q=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||Q){var et=[];p.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=s,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=h.orientation,n.direction=h.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return i(o[r].defaultConfig(),t)});o[r]().config(n)()})}var it,at,ot=t.select(".guides-group"),st=t.select(".tooltips-group"),lt=o.tooltipPanel().config({container:st,fontSize:8})(),ct=o.tooltipPanel().config({container:st,fontSize:8})(),ut=o.tooltipPanel().config({container:st,hasTick:!0})();if(!M){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});R.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(W).angle;ft.attr({x2:-x,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-h.orientation)%360;it=s.invert(n);var i=o.util.convertToCartesian(x+12,r+180);lt.text(o.util.round(it)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var ht=ot.select("circle").style({stroke:"grey",fill:"none"});R.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(W).radius;ht.attr({r:n}).style({opacity:.5}),at=r.invert(o.util.getMousePos(W).radius);var i=o.util.convertToCartesian(n,h.radialAxis.orientation);ct.text(o.util.round(at)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){ht.style({opacity:0}),ut.hide(),lt.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var i=n.select(this),a=this.style.fill,s="black",l=this.style.opacity||1;if(i.attr({"data-opacity":l}),a&&"none"!==a){i.attr({"data-fill":a}),s=n.hsl(a).darker().toString(),i.style({fill:s,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};M&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=t.node().getBoundingClientRect(),p=[f.left+f.width/2-V[0]-h.left,f.top+f.height/2-V[1]-h.top];ut.config({color:s}).text(u),ut.move(p)}else a=this.style.stroke||"black",i.attr({"data-stroke":a}),s=n.hsl(a).darker().toString(),i.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var r=n.select(this),i=r.attr("data-fill");i?r.style({fill:i,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(c),this},h.config=function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),i(l.data[e],o.Axis.defaultConfig().data[0]),i(l.data[e],t)}),i(l.layout,o.Axis.defaultConfig().layout),i(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return r},h.angularScale=function(t){return s},h.svg=function(){return t},n.rebind(h,f,"on"),h},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var i=e||6,a=[],o=[];n.range(0,360+i,i).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],i=e[1],a={};return a.x=r,a.y=i,a.pos=e,a.angle=180*(Math.atan2(i,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+i*i),a},o.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;i0)){var l=n.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:u(s),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return d.fill(r,i,a)},"fill-opacity":0,stroke:function(t,e){return d.stroke(r,i,a)},"stroke-width":function(t,e){return d["stroke-width"](r,i,a)},"stroke-dasharray":function(t,e){return d["stroke-dasharray"](r,i,a)},opacity:function(t,e){return d.opacity(r,i,a)},display:function(t,e){return d.display(r,i,a)}})}};var f=e.angularScale.range(),h=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=n.svg.arc().startAngle(function(t){return-h/2}).endAngle(function(t){return h/2}).innerRadius(function(t){return e.radialScale(l+(t[2]||0))}).outerRadius(function(t){return e.radialScale(l+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,r,i){n.select(this).attr({class:"mark arc",d:p,transform:function(t,r){return"rotate("+(e.orientation+s(t[0])+90)+")"}})};var d={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,i){return r[t[i].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(d).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return a.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),i(t[r],o.PolyChart.defaultConfig()),i(t[r],e)}),this):t},a.getColorScale=function(){},n.rebind(a,e,"on"),a},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,a=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var a=i({},e.elements[r]);return a.name=t,a.color=[].concat(e.elements[r].color)[n],a})}),o=n.merge(a);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var s=e.container;("string"==typeof s||s.nodeName)&&(s=n.select(s));var l=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,h=s.classed("legend-group",!0).selectAll("svg").data([0]),p=h.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var d=n.range(o.length),g=n.scale[u?"linear":"ordinal"]().domain(d).range(l),v=n.scale[u?"linear":"ordinal"]().domain(d)[u?"range":"rangePoints"]([0,f]);if(u){var m=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);m.enter().append("stop"),m.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var y=h.select(".legend-marks").selectAll("path.legend-mark").data(o);y.enter().append("path").classed("legend-mark",!0),y.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var r,i,a,o=t.symbol;return a=3*(i=c),"line"===(r=o)?"M"+[[-i/2,-i/12],[i/2,-i/12],[i/2,i/12],[-i/2,i/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(a)():n.svg.symbol().type("square").size(a)()},fill:function(t,e){return g(e)}}),y.exit().remove()}var x=n.svg.axis().scale(v).orient("right"),b=h.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(i(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,a={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,c=function(){var n=(t=a.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:a.padding+l,dy:.3*+a.fontSize}),c};return c.text=function(i){var o=n.hsl(a.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=i||"";e.style({fill:u,"font-size":a.fontSize+"px"}).text(f);var h=a.padding,p=e.node().getBBox(),d={fill:a.color,stroke:s,"stroke-width":"2px"},g=p.width+2*h+l,v=p.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[a.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(d),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return i(a,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=i({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var a=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=a.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var s=i({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var l=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(s.margin).forEach(function(t,e){u[c[l.indexOf(t.key)]]=t.value}),s.margin=u}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r}};return t}},{"../../../constants/alignment":668,"../../../lib":696,d3:148}],818:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../../lib"),a=t("../../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=i.extendDeepAll,c=e.exports={};c.framework=function(t){var e,r,i,a,u,f=new s;function h(r,s){return s&&(u=s),n.select(n.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?l(e,r):r,i||(i=o.Axis()),a=o.adapter.plotly().convert(e),i.config(a).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return h.isPolar=!0,h.svg=function(){return i.svg()},h.getConfig=function(){return e},h.getLiveConfig=function(){return o.adapter.plotly().convert(i.getLiveConfig(),!0)},h.getLiveScales=function(){return{t:i.angularScale(),r:i.radialScale()}},h.setUndoPoint=function(){var t,n,i=this,a=o.util.cloneJson(e);t=a,n=r,f.add({undo:function(){n&&i(n)},redo:function(){i(t)}}),r=o.util.cloneJson(a)},h.undo=function(){f.undo()},h.redo=function(){f.redo()},h},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),i=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:a.background,_container:e,_paperdiv:r,_paper:i};t._fullLayout=l(o,t.layout)}},{"../../../components/color":570,"../../../lib":696,"./micropolar":817,"./undo_manager":819,d3:148}],819:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function i(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(i(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(i(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r0?1:-1}function N(t){return F(Math.cos(t))}function j(t){return F(Math.sin(t))}e.exports=function(t,e){return new z(t,e)},O.plot=function(t,e){var r=e[this.id];this._hasClipOnAxisFalse=!1;for(var n=0;n=90||s>90&&l>=450?1:u<=0&&h<=0?0:Math.max(u,h);e=s<=180&&l>=180||s>180&&l>=540?-1:c>=0&&f>=0?0:Math.min(c,f);r=s<=270&&l>=270||s>270&&l>=630?-1:u>=0&&h>=0?0:Math.min(u,h);n=l>=360?1:c<=0&&f<=0?0:Math.max(c,f);return[e,r,n,i]}(h),x=y[2]-y[0],b=y[3]-y[1],_=f/u,w=Math.abs(b/x);_>w?(p=u,m=(f-(d=u*w))/n.h/2,g=[o[0],o[1]],v=[c[0]+m,c[1]-m]):(d=f,m=(u-(p=f/w))/n.w/2,g=[o[0]+m,o[1]-m],v=[c[0],c[1]]),this.xLength2=p,this.yLength2=d,this.xDomain2=g,this.yDomain2=v;var k=this.xOffset2=n.l+n.w*g[0],M=this.yOffset2=n.t+n.h*(1-v[1]),A=this.radius=p/x,T=this.innerRadius=e.hole*A,S=this.cx=k-A*y[0],L=this.cy=M+A*y[3],z=this.cxx=S-k,O=this.cyy=L-M;this.radialAxis=this.mockAxis(t,e,i,{_axislayer:r["radial-axis"],_gridlayer:r["radial-grid"],_id:"x",side:{counterclockwise:"top",clockwise:"bottom"}[i.side],domain:[T/n.w,A/n.w]}),this.angularAxis=this.mockAxis(t,e,a,{_axislayer:r["angular-axis"],_gridlayer:r["angular-grid"],side:"right",domain:[0,Math.PI],autorange:!1}),this.doAutoRange(t,e),this.updateAngularAxis(t,e),this.updateRadialAxis(t,e),this.updateRadialAxisTitle(t,e),this.xaxis=this.mockCartesianAxis(t,e,{_id:"x",domain:g}),this.yaxis=this.mockCartesianAxis(t,e,{_id:"y",domain:v});var I=this.pathSubplot();this.clipPaths.forTraces.select("path").attr("d",I).attr("transform",R(z,O)),r.frontplot.attr("transform",R(k,M)).call(l.setClipUrl,this._hasClipOnAxisFalse?null:this.clipIds.forTraces),r.bg.attr("d",I).attr("transform",R(S,L)).call(s.fill,e.bgcolor),this.framework.selectAll(".crisp").classed("crisp",0)},O.mockAxis=function(t,e,r,n){var i=o.extendFlat({anchor:"free",position:0,_pos:0,_counteraxis:!0,automargin:!1},r,n);return f(i,e,t),i},O.mockCartesianAxis=function(t,e,r){var n=this,i=r._id,a=o.extendFlat({type:"linear"},r);u(a,t);var s={x:[0,2],y:[1,3]};return a.setRange=function(){var t=n.sectorBBox,r=s[i],o=n.radialAxis._rl,l=(o[1]-o[0])/(1-e.hole);a.range=[t[r[0]]*l,t[r[1]]*l]},a.isPtWithinRange="x"===i?function(t){return n.isPtInside(t)}:function(){return!0},a.setRange(),a.setScale(),a},O.doAutoRange=function(t,e){var r=this.gd,n=this.radialAxis,i=e.radialaxis;n.setScale(),h(r,n);var a=n.range;i.range=a.slice(),i._input.range=a.slice(),n._rl=[n.r2l(a[0],null,"gregorian"),n.r2l(a[1],null,"gregorian")]},O.updateRadialAxis=function(t,e){var r=this,n=r.gd,i=r.layers,a=r.radius,o=r.innerRadius,l=r.cx,c=r.cy,u=e.radialaxis,f=E(e.sector[0],360),h=r.radialAxis,d=o90&&f<=270&&(h.tickangle=180),h._transfn=function(t){return"translate("+(h.l2p(t.x)+o)+",0)"},h._gridpath=function(t){return r.pathArc(h.r2p(t.x)+o)};var g=I(u);r.radialTickLayout!==g&&(i["radial-axis"].selectAll(".xtick").remove(),r.radialTickLayout=g),d&&(h.setScale(),p(n,h,!0));var v=r.radialAxisAngle=r.vangles?L(P(C(u.angle),r.vangles)):u.angle,m=R(l,c)+B(-v);D(i["radial-axis"],d&&(u.showticklabels||u.ticks),{transform:m}),D(i["radial-grid"],d&&u.showgrid,{transform:R(l,c)}).selectAll("path").attr("transform",null),D(i["radial-line"].select("line"),d&&u.showline,{x1:o,y1:0,x2:a,y2:0,transform:m}).attr("stroke-width",u.linewidth).call(s.stroke,u.linecolor)},O.updateRadialAxisTitle=function(t,e,r){var n=this.gd,i=this.radius,a=this.cx,o=this.cy,s=e.radialaxis,c=this.id+"title",u=void 0!==r?r:this.radialAxisAngle,f=C(u),h=Math.cos(f),p=Math.sin(f),d=0;if(s.title){var g=l.bBox(this.layers["radial-axis"].node()).height,v=s.titlefont.size;d="counterclockwise"===s.side?-g-.4*v:g+.8*v}this.layers["radial-axis-title"]=m.draw(n,c,{propContainer:s,propName:this.id+".radialaxis.title",placeholder:S(n,"Click to enter radial axis title"),attributes:{x:a+i/2*h+d*p,y:o-i/2*p+d*h,"text-anchor":"middle"},transform:{rotate:-u}})},O.updateAngularAxis=function(t,e){var r=this,i=r.gd,a=r.layers,l=r.radius,c=r.innerRadius,u=r.cx,f=r.cy,h=e.angularaxis,d=r.angularAxis;r.fillViewInitialKey("angularaxis.rotation",h.rotation),d.setGeometry();var g=function(t){return d.t2g(t.x)};"linear"===d.type&&"radians"===d.thetaunit&&(d.tick0=L(d.tick0),d.dtick=L(d.dtick)),"category"===d.type&&(d._tickFilter=function(t){return o.isAngleInsideSector(g(t),r.sectorInRad)}),d._transfn=function(t){var e=n.select(this),r=e&&e.node();if(r&&e.classed("angularaxisgrid"))return"";var i=g(t),a=R(u+l*Math.cos(i),f-l*Math.sin(i));return r&&e.classed("ticks")&&(a+=B(-L(i))),a},d._gridpath=function(t){var e=g(t),r=Math.cos(e),n=Math.sin(e);return"M"+[u+c*r,f-c*n]+"L"+[u+l*r,f-l*n]};var v="outside"!==h.ticks?.7:.5;d._labelx=function(t){var e=g(t),r=d._labelStandoff,n=d._pad;return(0===j(e)?0:Math.cos(e)*(r+n+v*t.fontSize))+N(e)*(t.dx+r+n)},d._labely=function(t){var e=g(t),r=d._labelStandoff,n=d._labelShift,i=d._pad;return t.dy+t.fontSize*M-n+-Math.sin(e)*(r+i+v*t.fontSize)},d._labelanchor=function(t,e){var r=g(e);return 0===j(r)?N(r)>0?"start":"end":"middle"};var m,y=I(h);r.angularTickLayout!==y&&(a["angular-axis"].selectAll("."+d._id+"tick").remove(),r.angularTickLayout=y),d.setScale(),p(i,d,!0),"linear"===e.gridshape?(m=d._vals.map(g),o.angleDelta(m[0],m[1])<0&&(m=m.slice().reverse())):m=null,r.vangles=m,D(a["angular-line"].select("path"),h.showline,{d:r.pathSubplot(),transform:R(u,f)}).attr("stroke-width",h.linewidth).call(s.stroke,h.linecolor)},O.updateFx=function(t,e){this.gd._context.staticPlot||(this.updateAngularDrag(t),this.updateRadialDrag(t,e,0),this.updateRadialDrag(t,e,1),this.updateMainDrag(t))},O.updateMainDrag=function(t){var e=this,r=e.gd,o=e.layers,s=t._zoomlayer,l=A.MINZOOM,c=A.OFFEDGE,u=e.radius,f=e.innerRadius,h=e.cx,p=e.cy,m=e.cxx,_=e.cyy,w=e.sectorInRad,k=e.vangles,M=e.radialAxis,S=T.clampTiny,E=T.findXYatLength,C=T.findEnclosingVertexAngles,L=A.cornerHalfWidth,z=A.cornerLen/2,O=d.makeDragger(o,"path","maindrag","crosshair");n.select(O).attr("d",e.pathSubplot()).attr("transform",R(h,p));var I,P,D,B,F,N,j,V,U,q={element:O,gd:r,subplot:e.id,plotinfo:{id:e.id,xaxis:e.xaxis,yaxis:e.yaxis},xaxes:[e.xaxis],yaxes:[e.yaxis]};function H(t,e){return Math.sqrt(t*t+e*e)}function G(t,e){return H(t-m,e-_)}function W(t,e){return Math.atan2(_-e,t-m)}function Y(t,e){return[t*Math.cos(e),t*Math.sin(-e)]}function X(t,r){if(0===t)return e.pathSector(2*L);var n=z/t,i=r-n,a=r+n,o=Math.max(0,Math.min(t,u)),s=o-L,l=o+L;return"M"+Y(s,i)+"A"+[s,s]+" 0,0,0 "+Y(s,a)+"L"+Y(l,a)+"A"+[l,l]+" 0,0,1 "+Y(l,i)+"Z"}function Z(t,r,n){if(0===t)return e.pathSector(2*L);var i,a,o=Y(t,r),s=Y(t,n),l=S((o[0]+s[0])/2),c=S((o[1]+s[1])/2);if(l&&c){var u=c/l,f=-1/u,h=E(L,u,l,c);i=E(z,f,h[0][0],h[0][1]),a=E(z,f,h[1][0],h[1][1])}else{var p,d;c?(p=z,d=L):(p=L,d=z),i=[[l-p,c-d],[l+p,c-d]],a=[[l-p,c+d],[l+p,c+d]]}return"M"+i.join("L")+"L"+a.reverse().join("L")+"Z"}function $(t,e){return e=Math.max(Math.min(e,u),f),tl?(t-1&&1===t&&x(n,r,[e.xaxis],[e.yaxis],e.id,q),i.indexOf("event")>-1&&v.click(r,n,e.id)}q.prepFn=function(t,n,a){var o=r._fullLayout.dragmode,l=O.getBoundingClientRect();if(I=n-l.left,P=a-l.top,k){var c=T.findPolygonOffset(u,w[0],w[1],k);I+=m+c[0],P+=_+c[1]}switch(o){case"zoom":q.moveFn=k?tt:K,q.clickFn=rt,q.doneFn=et,function(){D=null,B=null,F=e.pathSubplot(),N=!1;var t=r._fullLayout[e.id];j=i(t.bgcolor).getLuminance(),(V=d.makeZoombox(s,j,h,p,F)).attr("fill-rule","evenodd"),U=d.makeCorners(s,h,p),b(s)}();break;case"select":case"lasso":y(t,n,a,q,o)}},O.onmousemove=function(t){v.hover(r,t,e.id),r._fullLayout._lasthover=O,r._fullLayout._hoversubplot=e.id},O.onmouseout=function(t){r._dragging||g.unhover(r,t)},g.init(q)},O.updateRadialDrag=function(t,e,r){var i=this,s=i.gd,l=i.layers,c=i.radius,u=i.innerRadius,f=i.cx,h=i.cy,v=i.radialAxis,m=A.radialDragBoxSize,y=m/2;if(v.visible){var x,_,M,T=C(i.radialAxisAngle),S=v._rl,E=S[0],z=S[1],O=S[r],I=.75*(S[1]-S[0])/(1-e.hole)/c;r?(x=f+(c+y)*Math.cos(T),_=h-(c+y)*Math.sin(T),M="radialdrag"):(x=f+(u-y)*Math.cos(T),_=h-(u-y)*Math.sin(T),M="radialdrag-inner");var F,N,j,V=d.makeRectDragger(l,M,"crosshair",-y,-y,m,m),U={element:V,gd:s};D(n.select(V),v.visible&&u0==(r?j>E:jn?function(t){return t<=0}:function(t){return t>=0};t.c2g=function(r){var n=t.c2l(r)-e;return(s(n)?n:0)+o},t.g2c=function(r){return t.l2c(r+e-o)},t.g2p=function(t){return t*a},t.c2p=function(e){return t.g2p(t.c2g(e))}}}(t,e);break;case"angularaxis":!function(t,e){var r=t.type;if("linear"===r){var i=t.d2c,s=t.c2d;t.d2c=function(t,e){return function(t,e){return"degrees"===e?a(t):t}(i(t),e)},t.c2d=function(t,e){return s(function(t,e){return"degrees"===e?o(t):t}(t,e))}}t.makeCalcdata=function(e,i){var a,o,s=e[i],l=e._length,c=function(r){return t.d2c(r,e.thetaunit)};if(s){if(n.isTypedArray(s)&&"linear"===r){if(l===s.length)return s;if(s.subarray)return s.subarray(0,l)}for(a=new Array(l),o=0;o=u&&(p.min=0,g.min=0,v.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}function d(t,e,r){var n=f[e._name];function i(r,i){return a.coerce(t,e,n,r,i)}e.type="linear";var o=i("color"),h=o!==n.color.dflt?o:r.font.color,p=e._name.charAt(0).toUpperCase(),d="Component "+p,g=i("title",d);e._hovertitle=g===d?g:p,a.coerceFont(i,"titlefont",{family:r.font.family,size:Math.round(1.2*r.font.size),color:h}),i("min"),c(t,e,i,"linear"),s(t,e,i,"linear",{}),l(t,e,i,{outerTicks:!0}),i("showticklabels")&&(a.coerceFont(i,"tickfont",{family:r.font.family,size:r.font.size,color:h}),i("tickangle"),i("tickformat")),u(t,e,i,{dfltColor:o,bgColor:r.bgColor,blend:60,showLine:!0,showGrid:!0,noZeroLine:!0,attributes:n}),i("hoverformat"),i("layer")}e.exports=function(t,e,r){o(t,e,r,{type:"ternary",attributes:f,handleDefaults:p,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../components/color":570,"../../lib":696,"../../plot_api/plot_template":734,"../cartesian/line_grid_defaults":759,"../cartesian/tick_label_defaults":764,"../cartesian/tick_mark_defaults":765,"../cartesian/tick_value_defaults":766,"../subplot_defaults":822,"./layout_attributes":824}],826:[function(t,e,r){"use strict";var n=t("d3"),i=t("tinycolor2"),a=t("../../registry"),o=t("../../lib"),s=o._,l=t("../../components/color"),c=t("../../components/drawing"),u=t("../cartesian/set_convert"),f=t("../../lib/extend").extendFlat,h=t("../plots"),p=t("../cartesian/axes"),d=t("../../components/dragelement"),g=t("../../components/fx"),v=t("../../components/titles"),m=t("../cartesian/select").prepSelect,y=t("../cartesian/select").selectOnClick,x=t("../cartesian/select").clearSelect,b=t("../cartesian/constants");function _(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework(e),this.aTickLayout=null,this.bTickLayout=null,this.cTickLayout=null}e.exports=_;var w=_.prototype;w.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={},this.layers={}},w.plot=function(t,e){var r=e[this.id],n=e._size;this._hasClipOnAxisFalse=!1;for(var i=0;ik*x?i=(a=x)*k:a=(i=y)/k,o=v*i/y,s=m*a/x,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-g)-a/2,h.x0=r,h.y0=n,h.w=i,h.h=a,h.sum=b,h.xaxis={type:"linear",range:[_+2*M-b,b-_-2*w],domain:[d-o/2,d+o/2],_id:"x"},u(h.xaxis,h.graphDiv._fullLayout),h.xaxis.setScale(),h.xaxis.isPtWithinRange=function(t){return t.a>=h.aaxis.range[0]&&t.a<=h.aaxis.range[1]&&t.b>=h.baxis.range[1]&&t.b<=h.baxis.range[0]&&t.c>=h.caxis.range[1]&&t.c<=h.caxis.range[0]},h.yaxis={type:"linear",range:[_,b-w-M],domain:[g-s/2,g+s/2],_id:"y"},u(h.yaxis,h.graphDiv._fullLayout),h.yaxis.setScale(),h.yaxis.isPtWithinRange=function(){return!0};var A=h.yaxis.domain[0],T=h.aaxis=f({},t.aaxis,{visible:!0,range:[_,b-w-M],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*k],_axislayer:h.layers.aaxis,_gridlayer:h.layers.agrid,anchor:"free",position:0,_pos:0,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2,automargin:!1});u(T,h.graphDiv._fullLayout),T.setScale();var S=h.baxis=f({},t.baxis,{visible:!0,range:[b-_-M,w],side:"bottom",_counterangle:30,domain:h.xaxis.domain,_axislayer:h.layers.baxis,_gridlayer:h.layers.bgrid,_counteraxis:h.aaxis,anchor:"free",position:0,_pos:0,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a,automargin:!1});u(S,h.graphDiv._fullLayout),S.setScale(),T._counteraxis=S;var E=h.caxis=f({},t.caxis,{visible:!0,range:[b-_-w,M],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*k],_axislayer:h.layers.caxis,_gridlayer:h.layers.cgrid,_counteraxis:h.baxis,anchor:"free",position:0,_pos:0,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2,automargin:!1});u(E,h.graphDiv._fullLayout),E.setScale();var C="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";h.clipDef.select("path").attr("d",C),h.layers.plotbg.select("path").attr("d",C);var L="M0,"+a+"h"+i+"l-"+i/2+",-"+a+"Z";h.clipDefRelative.select("path").attr("d",L);var z="translate("+r+","+n+")";h.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",z),h.clipDefRelative.select("path").attr("transform",null);var O="translate("+(r-S._offset)+","+(n+a)+")";h.layers.baxis.attr("transform",O),h.layers.bgrid.attr("transform",O);var I="translate("+(r+i/2)+","+n+")rotate(30)translate(0,"+-T._offset+")";h.layers.aaxis.attr("transform",I),h.layers.agrid.attr("transform",I);var P="translate("+(r+i/2)+","+n+")rotate(-30)translate(0,"+-E._offset+")";h.layers.caxis.attr("transform",P),h.layers.cgrid.attr("transform",P),h.drawAxes(!0),h.plotContainer.selectAll(".crisp").classed("crisp",!1),h.layers.aline.select("path").attr("d",T.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(l.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),h.layers.bline.select("path").attr("d",S.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(l.stroke,S.linecolor||"#000").style("stroke-width",(S.linewidth||0)+"px"),h.layers.cline.select("path").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(l.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px"),h.graphDiv._context.staticPlot||h.initInteractions(),c.setClipUrl(h.layers.frontplot,h._hasClipOnAxisFalse?null:h.clipId)},w.drawAxes=function(t){var e,r=this.graphDiv,n=this.id.substr(7)+"title",i=this.layers,a=this.aaxis,o=this.baxis,l=this.caxis;if(e=M(a),this.aTickLayout!==e&&(i.aaxis.selectAll(".ytick").remove(),this.aTickLayout=e),e=M(o),this.bTickLayout!==e&&(i.baxis.selectAll(".xtick").remove(),this.bTickLayout=e),e=M(l),this.cTickLayout!==e&&(i.caxis.selectAll(".ytick").remove(),this.cTickLayout=e),p.doTicksSingle(r,a,!0),p.doTicksSingle(r,o,!0),p.doTicksSingle(r,l,!0),t){var c=Math.max(a.showticklabels?a.tickfont.size/2:0,(l.showticklabels?.75*l.tickfont.size:0)+("outside"===l.ticks?.87*l.ticklen:0));this.layers["a-title"]=v.draw(r,"a"+n,{propContainer:a,propName:this.id+".aaxis.title",placeholder:s(r,"Click to enter Component A title"),attributes:{x:this.x0+this.w/2,y:this.y0-a.titlefont.size/3-c,"text-anchor":"middle"}});var u=(o.showticklabels?o.tickfont.size:0)+("outside"===o.ticks?o.ticklen:0)+3;this.layers["b-title"]=v.draw(r,"b"+n,{propContainer:o,propName:this.id+".baxis.title",placeholder:s(r,"Click to enter Component B title"),attributes:{x:this.x0-u,y:this.y0+this.h+.83*o.titlefont.size+u,"text-anchor":"middle"}}),this.layers["c-title"]=v.draw(r,"c"+n,{propContainer:l,propName:this.id+".caxis.title",placeholder:s(r,"Click to enter Component C title"),attributes:{x:this.x0+this.w+u,y:this.y0+this.h+.83*l.titlefont.size+u,"text-anchor":"middle"}})}};var A=b.MINZOOM/2+.87,T="m-0.87,.5h"+A+"v3h-"+(A+5.2)+"l"+(A/2+2.6)+",-"+(.87*A+4.5)+"l2.6,1.5l-"+A/2+","+.87*A+"Z",S="m0.87,.5h-"+A+"v3h"+(A+5.2)+"l-"+(A/2+2.6)+",-"+(.87*A+4.5)+"l-2.6,1.5l"+A/2+","+.87*A+"Z",E="m0,1l"+A/2+","+.87*A+"l2.6,-1.5l-"+(A/2+2.6)+",-"+(.87*A+4.5)+"l-"+(A/2+2.6)+","+(.87*A+4.5)+"l2.6,1.5l"+A/2+",-"+.87*A+"Z",C="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",L=!0;function z(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}w.initInteractions=function(){var t,e,r,n,u,f,h,p,v,_,w=this,M=w.layers.plotbg.select("path").node(),A=w.graphDiv,O=A._fullLayout._zoomlayer,I={element:M,gd:A,plotinfo:{id:w.id,xaxis:w.xaxis,yaxis:w.yaxis},subplot:w.id,prepFn:function(a,o,s){I.xaxes=[w.xaxis],I.yaxes=[w.yaxis];var c=A._fullLayout.dragmode;I.minDrag="lasso"===c?1:void 0,"zoom"===c?(I.moveFn=F,I.clickFn=P,I.doneFn=N,function(a,o,s){var c=M.getBoundingClientRect();t=o-c.left,e=s-c.top,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,n=w.aaxis.range[1]-r.a,f=i(w.graphDiv._fullLayout[w.id].bgcolor).getLuminance(),h="M0,"+w.h+"L"+w.w/2+", 0L"+w.w+","+w.h+"Z",p=!1,v=O.append("path").attr("class","zoombox").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:f>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",h),_=O.append("path").attr("class","zoombox-corners").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:l.background,stroke:l.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),x(O)}(0,o,s)):"pan"===c?(I.moveFn=j,I.clickFn=P,I.doneFn=V,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,x(O)):"select"!==c&&"lasso"!==c||m(a,o,s,I,c)}};function P(t,e){var r=A._fullLayout.clickmode;if(z(A),2===t){var n={};n[w.id+".aaxis.min"]=0,n[w.id+".baxis.min"]=0,n[w.id+".caxis.min"]=0,A.emit("plotly_doubleclick",null),a.call("relayout",A,n)}r.indexOf("select")>-1&&1===t&&y(e,A,[w.xaxis],[w.yaxis],w.id,I),r.indexOf("event")>-1&&g.click(A,e,w.id)}function D(t,e){return 1-e/w.h}function R(t,e){return 1-(t+(w.h-e)/Math.sqrt(3))/w.w}function B(t,e){return(t-(w.h-e)/Math.sqrt(3))/w.w}function F(i,a){var o=t+i,s=e+a,l=Math.max(0,Math.min(1,D(0,e),D(0,s))),c=Math.max(0,Math.min(1,R(t,e),R(o,s))),d=Math.max(0,Math.min(1,B(t,e),B(o,s))),g=(l/2+d)*w.w,m=(1-l/2-c)*w.w,y=(g+m)/2,x=m-g,M=(1-l)*w.h,A=M-x/k;x.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),_.transition().style("opacity",1).duration(200),p=!0)}function N(){if(z(A),u!==r){var t={};t[w.id+".aaxis.min"]=u.a,t[w.id+".baxis.min"]=u.b,t[w.id+".caxis.min"]=u.c,a.call("relayout",A,t),L&&A.data&&A._context.showTips&&(o.notifier(s(A,"Double-click to zoom back out"),"long"),L=!1)}}function j(t,e){var n=t/w.xaxis._m,i=e/w.yaxis._m,a=[(u={a:r.a-i,b:r.b+(n+i)/2,c:r.c-(n-i)/2}).a,u.b,u.c].sort(),o=a.indexOf(u.a),s=a.indexOf(u.b),l=a.indexOf(u.c);a[0]<0&&(a[1]+a[0]/2<0?(a[2]+=a[0]+a[1],a[0]=a[1]=0):(a[2]+=a[0]/2,a[1]+=a[0]/2,a[0]=0),u={a:a[o],b:a[s],c:a[l]},e=(r.a-u.a)*w.yaxis._m,t=(r.c-u.c-r.b+u.b)*w.xaxis._m);var f="translate("+(w.x0+t)+","+(w.y0+e)+")";w.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",f);var h="translate("+-t+","+-e+")";w.clipDefRelative.select("path").attr("transform",h),w.aaxis.range=[u.a,w.sum-u.b-u.c],w.baxis.range=[w.sum-u.a-u.c,u.b],w.caxis.range=[w.sum-u.a-u.b,u.c],w.drawAxes(!1),w.plotContainer.selectAll(".crisp").classed("crisp",!1),w._hasClipOnAxisFalse&&w.plotContainer.select(".scatterlayer").selectAll(".trace").call(c.hideOutsideRangePoints,w)}function V(){var t={};t[w.id+".aaxis.min"]=u.a,t[w.id+".baxis.min"]=u.b,t[w.id+".caxis.min"]=u.c,a.call("relayout",A,t)}M.onmousemove=function(t){g.hover(A,t,w.id),A._fullLayout._lasthover=M,A._fullLayout._hoversubplot=w.id},M.onmouseout=function(t){A._dragging||d.unhover(A,t)},d.init(I)}},{"../../components/color":570,"../../components/dragelement":592,"../../components/drawing":595,"../../components/fx":612,"../../components/titles":661,"../../lib":696,"../../lib/extend":685,"../../registry":827,"../cartesian/axes":744,"../cartesian/constants":750,"../cartesian/select":762,"../cartesian/set_convert":763,"../plots":808,d3:148,tinycolor2:514}],827:[function(t,e,r){"use strict";var n=t("./lib/loggers"),i=t("./lib/noop"),a=t("./lib/push_unique"),o=t("./lib/is_plain_object"),s=t("./lib/extend"),l=t("./plots/attributes"),c=t("./plots/layout_attributes"),u=s.extendFlat,f=s.extendDeepAll;function h(t){var e=t.name,i=t.categories,a=t.meta;if(r.modules[e])n.log("Type "+e+" already registered");else{r.subplotsRegistry[t.basePlotModule.name]||function(t){var e=t.name;if(r.subplotsRegistry[e])return void n.log("Plot type "+e+" already registered.");for(var i in v(t),r.subplotsRegistry[e]=t,r.componentsRegistry)x(i,t.name)}(t.basePlotModule);for(var o={},s=0;s-1&&(u[h[r]].title="");for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(l,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(l,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||h.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),h.node().setAttributeNS(s.xmlns,"xmlns",s.svg),h.node().setAttributeNS(s.xmlns,"xmlns:xlink",s.xlink),"svg"===e&&r&&(h.attr("width",r*d),h.attr("height",r*g),h.attr("viewBox","0 0 "+d+" "+g));var _=(new window.XMLSerializer).serializeToString(h.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),i.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":570,"../components/drawing":595,"../constants/xmlns_namespaces":674,"../lib":696,d3:148}],836:[function(t,e,r){"use strict";var n=t("../../lib").mergeArray;e.exports=function(t,e){for(var r=0;rf+c||!n(u))&&(p=!0,g(h,t))}for(var v=0;va))return e}return void 0!==r?r:t.dflt},r.coerceColor=function(t,e,r){return i(e).isValid()?e:void 0!==r?r:t.dflt},r.coerceEnumerated=function(t,e,r){return t.coerceNumber&&(e=+e),-1!==t.values.indexOf(e)?e:void 0!==r?r:t.dflt},r.getValue=function(t,e){var r;return Array.isArray(t)?e.01?C:function(t,e){return Math.abs(t-e)>=2?C(t):t>e?Math.ceil(t):Math.floor(t)};_=E(_,w),w=E(w,_),k=E(k,M),M=E(M,k)}a.ensureSingle(A,"path").style("vector-effect","non-scaling-stroke").attr("d","M"+_+","+k+"V"+M+"H"+w+"V"+k+"Z").call(l.setClipUrl,e.layerClipId),function(t,e,r,n,i,s,c,u){var m;function y(e,r,n){var i=a.ensureSingle(e,"text").text(r).attr({class:"bartext bartext-"+m,transform:"","text-anchor":"middle","data-notex":1}).call(l.font,n).call(o.convertToTspans,t);return i}var x=r[0].trace,b=x.orientation,_=function(t,e){var r=p.getValue(t.text,e);return p.coerceString(f,r)}(x,n);if(m=function(t,e){var r=p.getValue(t.textposition,e);return p.coerceEnumerated(h,r)}(x,n),!_||"none"===m)return void e.select("text").remove();var w,k,M,A,T,S,E=t._fullLayout.font,C=d.getBarColor(r[n],x),L=d.getInsideTextFont(x,n,E,C),z=d.getOutsideTextFont(x,n,E),O=t._fullLayout.barmode,I="relative"===O,P="stack"===O||I,D=r[n],R=!P||D._outmost,B=Math.abs(s-i)-2*g,F=Math.abs(u-c)-2*g;"outside"===m&&(R||D.hasB||(m="inside"));if("auto"===m)if(R){m="inside",w=y(e,_,L),k=l.bBox(w.node()),M=k.width,A=k.height;var N=M>0&&A>0,j=M<=B&&A<=F,V=M<=F&&A<=B,U="h"===b?B>=M*(F/A):F>=A*(B/M);N&&(j||V||U)?m="inside":(m="outside",w.remove(),w=null)}else m="inside";if(!w&&(w=y(e,_,"outside"===m?z:L),k=l.bBox(w.node()),M=k.width,A=k.height,M<=0||A<=0))return void w.remove();"outside"===m?(S="both"===x.constraintext||"outside"===x.constraintext,T=function(t,e,r,n,i,a,o){var s,l="h"===a?Math.abs(n-r):Math.abs(e-t);l>2*g&&(s=g);var c=1;o&&(c="h"===a?Math.min(1,l/i.height):Math.min(1,l/i.width));var u,f,h,p,d=(i.left+i.right)/2,m=(i.top+i.bottom)/2;u=c*i.width,f=c*i.height,"h"===a?er?(h=(t+e)/2,p=n+s+f/2):(h=(t+e)/2,p=n-s-f/2);return v(d,m,h,p,c,!1)}(i,s,c,u,k,b,S)):(S="both"===x.constraintext||"inside"===x.constraintext,T=function(t,e,r,n,i,a,o){var s,l,c,u,f,h,p,d=i.width,m=i.height,y=(i.left+i.right)/2,x=(i.top+i.bottom)/2,b=Math.abs(e-t),_=Math.abs(n-r);b>2*g&&_>2*g?(b-=2*(f=g),_-=2*f):f=0;d<=b&&m<=_?(h=!1,p=1):d<=_&&m<=b?(h=!0,p=1):dr?(c=(t+e)/2,u=n-f-l/2):(c=(t+e)/2,u=n+f+l/2);return v(y,x,c,u,p,h)}(i,s,c,u,k,b,S));w.attr("transform",T)}(t,A,r,u,_,w,k,M),e.layerClipId&&l.hideOutsideRangePoint(c,A.select("text"),m,y,b.xcalendar,b.ycalendar)}else A.remove();function C(t){return 0===x.bargap&&0===x.bargroupgap?n.round(Math.round(t)-S,2):t}});var w=!1===u.trace.cliponaxis;l.setClipUrl(c,w?null:e.layerClipId)});c.getComponentMethod("errorbars","plot")(b,e)}},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../lib/svg_text_utils":720,"../../registry":827,"./attributes":837,"./helpers":841,"./style":849,d3:148,"fast-isnumeric":214}],847:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,i=t.xaxis,a=t.yaxis,o=[];if(!1===e)for(r=0;r1||0===a.bargap&&0===a.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),r.selectAll("g.points").each(function(e){p(n.select(this),e[0].trace,t)}),s.getComponentMethod("errorbars","style")(r)},styleOnSelect:function(t,e){var r=e[0].node3,i=e[0].trace;i.selectedpoints?function(t,e,r){a.selectedPointStyle(t.selectAll("path"),e),function(t,e,r){t.each(function(t){var i,s=n.select(this);if(t.selected){i=o.extendFlat({},d(s,t,e,r));var l=e.selected.textfont&&e.selected.textfont.color;l&&(i.color=l),a.font(s,i)}else a.selectedTextStyle(s,e)})}(t.selectAll("text"),e,r)}(r,i,t):p(r,i,t)},getInsideTextFont:v,getOutsideTextFont:m,getBarColor:x}},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../registry":827,"./attributes":837,"./helpers":841,d3:148}],850:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":570,"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584}],851:[function(t,e,r){"use strict";var n=t("../../lib/extend").extendFlat,i=t("../scatterpolar/attributes"),a=t("../bar/attributes");e.exports={r:i.r,theta:i.theta,r0:i.r0,dr:i.dr,theta0:i.theta0,dtheta:i.dtheta,thetaunit:i.thetaunit,base:n({},a.base,{}),offset:n({},a.offset,{}),width:n({},a.width,{}),text:n({},a.text,{}),marker:a.marker,hoverinfo:i.hoverinfo,selected:a.selected,unselected:a.unselected}},{"../../lib/extend":685,"../bar/attributes":837,"../scatterpolar/attributes":1105}],852:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("../bar/arrays_to_calcdata"),o=t("../bar/cross_trace_calc").setGroupPositions,s=t("../scatter/calc_selection"),l=t("../../registry").traceIs,c=t("../../lib").extendFlat;e.exports={calc:function(t,e){for(var r=t._fullLayout,o=e.subplot,l=r[o].radialaxis,c=r[o].angularaxis,u=l.makeCalcdata(e,"r"),f=c.makeCalcdata(e,"theta"),h=e._length,p=new Array(h),d=u,g=f,v=0;vh.range[1]&&(x+=Math.PI);if(n.getClosest(c,function(t){return g(y,x,[t.rp0,t.rp1],[t.thetag0,t.thetag1],d)?v+Math.min(1,Math.abs(t.thetag1-t.thetag0)/m)-1+(t.rp1-y)/(t.rp1-t.rp0)-1:1/0},t),!1!==t.index){var b=c[t.index];t.x0=t.x1=b.ct[0],t.y0=t.y1=b.ct[1];var _=i.extendFlat({},b,{r:b.s,theta:b.p});return o(b,u,t),s(_,u,f,t),t.color=a(u,b),t.xLabelVal=t.yLabelVal=void 0,b.s<0&&(t.idealAlign="left"),[t]}}},{"../../components/fx":612,"../../lib":696,"../../plots/polar/helpers":810,"../bar/hover":842,"../scatter/fill_hover_text":1051,"../scatterpolar/hover":1108}],855:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"barpolar",basePlotModule:t("../../plots/polar"),categories:["polar","bar","showLegend"],attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc").calc,crossTraceCalc:t("./calc").crossTraceCalc,plot:t("./plot"),colorbar:t("../scatter/marker_colorbar"),style:t("../bar/style").style,hoverPoints:t("./hover"),selectPoints:t("../bar/select"),meta:{}}},{"../../plots/polar":811,"../bar/select":847,"../bar/style":849,"../scatter/marker_colorbar":1061,"./attributes":851,"./calc":852,"./defaults":853,"./hover":854,"./layout_attributes":856,"./layout_defaults":857,"./plot":858}],856:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","overlay"],dflt:"stack",editType:"calc"},bargap:{valType:"number",dflt:.1,min:0,max:1,editType:"calc"}}},{}],857:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,r){var a,o={};function s(r,o){return n.coerce(t[a]||{},e[a],i,r,o)}for(var l=0;l0?(c=o,u=l):(c=l,u=o);var f=s.findEnclosingVertexAngles(c,t.vangles)[0],h=s.findEnclosingVertexAngles(u,t.vangles)[1],p=[f,(c+u)/2,h];return s.pathPolygonAnnulus(n,i,c,u,p,e,r)};return function(t,n,i,o){return a.pathAnnulus(t,n,i,o,e,r)}}(e),p=e.layers.frontplot.select("g.barlayer");a.makeTraceGroups(p,r,"trace bars").each(function(t){var r=t[0].node3=n.select(this),s=a.ensureSingle(r,"g","points").selectAll("g.point").data(a.identity);s.enter().append("g").style("vector-effect","non-scaling-stroke").style("stroke-miterlimit",2).classed("point",!0),s.exit().remove(),s.each(function(t){var e,r=n.select(this),o=t.rp0=u.c2p(t.s0),s=t.rp1=u.c2p(t.s1),p=t.thetag0=f.c2g(t.p0),d=t.thetag1=f.c2g(t.p1);if(i(o)&&i(s)&&i(p)&&i(d)&&o!==s&&p!==d){var g=u.c2g(t.s1),v=(p+d)/2;t.ct=[l.c2p(g*Math.cos(v)),c.c2p(g*Math.sin(v))],e=h(o,s,p,d)}else e="M0,0Z";a.ensureSingle(r,"path").attr("d",e)}),o.setClipUrl(r,e._hasClipOnAxisFalse?e.clipIds.forTraces:null)})}},{"../../components/drawing":595,"../../lib":696,"../../plots/polar/helpers":810,d3:148,"fast-isnumeric":214}],859:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array",editType:"calc+clearAxisTypes"},x:{valType:"data_array",editType:"calc+clearAxisTypes"},x0:{valType:"any",editType:"calc+clearAxisTypes"},y0:{valType:"any",editType:"calc+clearAxisTypes"},name:{valType:"string",editType:"calc+clearAxisTypes"},text:a({},n.text,{}),whiskerwidth:{valType:"number",min:0,max:1,dflt:.5,editType:"calc"},notched:{valType:"boolean",editType:"calc"},notchwidth:{valType:"number",min:0,max:.5,dflt:.25,editType:"calc"},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers",editType:"calc"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1,editType:"calc"},jitter:{valType:"number",min:0,max:1,editType:"calc"},pointpos:{valType:"number",min:-2,max:2,editType:"calc"},orientation:{valType:"enumerated",values:["v","h"],editType:"calc+clearAxisTypes"},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)",editType:"style"},symbol:a({},o.symbol,{arrayOk:!1,editType:"plot"}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1,editType:"style"}),size:a({},o.size,{arrayOk:!1,editType:"calc"}),color:a({},o.color,{arrayOk:!1,editType:"style"}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine,editType:"style"}),width:a({},s.width,{arrayOk:!1,dflt:0,editType:"style"}),outliercolor:{valType:"color",editType:"style"},outlierwidth:{valType:"number",min:0,dflt:1,editType:"style"},editType:"style"},editType:"plot"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,selected:{marker:n.selected.marker,editType:"style"},unselected:{marker:n.unselected.marker,editType:"style"},hoveron:{valType:"flaglist",flags:["boxes","points"],dflt:"boxes+points",editType:"style"}}},{"../../components/color/attributes":569,"../../lib/extend":685,"../scatter/attributes":1043}],860:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=i._,o=t("../../plots/cartesian/axes");function s(t,e,r){var n={text:"tx"};for(var i in n)Array.isArray(e[i])&&(t[n[i]]=e[i][r])}function l(t,e){return t.v-e.v}function c(t){return t.v}e.exports=function(t,e){var r,u,f,h,p,d=t._fullLayout,g=o.getFromId(t,e.xaxis||"x"),v=o.getFromId(t,e.yaxis||"y"),m=[],y="violin"===e.type?"_numViolins":"_numBoxes";"h"===e.orientation?(u=g,f="x",h=v,p="y"):(u=v,f="y",h=g,p="x");var x=u.makeCalcdata(e,f),b=function(t,e,r,a,o){if(e in t)return r.makeCalcdata(t,e);var s;s=e+"0"in t?t[e+"0"]:"name"in t&&("category"===r.type||n(t.name)&&-1!==["linear","log"].indexOf(r.type)||i.isDateTime(t.name)&&"date"===r.type)?t.name:o;var l=r.d2c(s,0,t[e+"calendar"]);return a.map(function(){return l})}(e,p,h,x,d[y]),_=i.distinctVals(b),w=_.vals,k=_.minDiff/2,M=function(t,e){for(var r=t.length,n=new Array(r+1),i=0;i=0&&E0){var L=T[r].sort(l),z=L.map(c),O=z.length,I={pos:w[r],pts:L};I.min=z[0],I.max=z[O-1],I.mean=i.mean(z,O),I.sd=i.stdev(z,O,I.mean),I.q1=i.interp(z,.25),I.med=i.interp(z,.5),I.q3=i.interp(z,.75),I.lf=Math.min(I.q1,z[Math.min(i.findBin(2.5*I.q1-1.5*I.q3,z,!0)+1,O-1)]),I.uf=Math.max(I.q3,z[Math.max(i.findBin(2.5*I.q3-1.5*I.q1,z),0)]),I.lo=4*I.q1-3*I.q3,I.uo=4*I.q3-3*I.q1;var P=1.57*(I.q3-I.q1)/Math.sqrt(O);I.ln=I.med-P,I.un=I.med+P,m.push(I)}!function(t,e){if(i.isArrayOrTypedArray(e.selectedpoints))for(var r=0;r0?(m[0].t={num:d[y],dPos:k,posLetter:p,valLetter:f,labels:{med:a(t,"median:"),min:a(t,"min:"),q1:a(t,"q1:"),q3:a(t,"q3:"),max:a(t,"max:"),mean:"sd"===e.boxmean?a(t,"mean \xb1 \u03c3:"):a(t,"mean:"),lf:a(t,"lower fence:"),uf:a(t,"upper fence:")}},d[y]++,m):[{t:{empty:!0}}]}},{"../../lib":696,"../../plots/cartesian/axes":744,"fast-isnumeric":214}],861:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib"),a=["v","h"];function o(t,e,r,a,o){var s,l,c,u=e.calcdata,f=e._fullLayout,h=[],p="violin"===t?"_numViolins":"_numBoxes";for(s=0;st.uf}),l=Math.max((t.max-t.min)/10,t.q3-t.q1),c=1e-9*l,p=l*s,d=[],g=0;if(r.jitter){if(0===l)for(g=1,d=new Array(a.length),e=0;et.lo&&(_.so=!0)}return a});d.enter().append("path").classed("point",!0),d.exit().remove(),d.call(a.translatePoints,l,c)}function u(t,e,r,a){var o,s,l=e.pos,c=e.val,u=a.bPos,f=a.bPosPxOffset||0,h=r.boxmean||(r.meanline||{}).visible;Array.isArray(a.bdPos)?(o=a.bdPos[0],s=a.bdPos[1]):(o=a.bdPos,s=a.bdPos);var p=t.selectAll("path.mean").data("box"===r.type&&r.boxmean||"violin"===r.type&&r.box.visible&&r.meanline.visible?i.identity:[]);p.enter().append("path").attr("class","mean").style({fill:"none","vector-effect":"non-scaling-stroke"}),p.exit().remove(),p.each(function(t){var e=l.c2p(t.pos+u,!0)+f,i=l.c2p(t.pos+u-o,!0)+f,a=l.c2p(t.pos+u+s,!0)+f,p=c.c2p(t.mean,!0),d=c.c2p(t.mean-t.sd,!0),g=c.c2p(t.mean+t.sd,!0);"h"===r.orientation?n.select(this).attr("d","M"+p+","+i+"V"+a+("sd"===h?"m0,0L"+d+","+e+"L"+p+","+i+"L"+g+","+e+"Z":"")):n.select(this).attr("d","M"+i+","+p+"H"+a+("sd"===h?"m0,0L"+e+","+d+"L"+i+","+p+"L"+e+","+g+"Z":""))})}e.exports={plot:function(t,e,r,a){var o=t._fullLayout,s=e.xaxis,f=e.yaxis,h=o._numBoxes,p=1-o.boxgap,d="group"===o.boxmode&&h>1;i.makeTraceGroups(a,r,"trace boxes").each(function(t){var r=n.select(this),i=t[0],a=i.t,g=i.trace;e.isRangePlot||(i.node3=r);var v,m,y=a.dPos*p*(1-o.boxgroupgap)/(d?h:1),x=d?2*a.dPos*((a.num+.5)/h-.5)*p:0,b=y*g.whiskerwidth;!0!==g.visible||a.empty?r.remove():("h"===g.orientation?(v=f,m=s):(v=s,m=f),a.bPos=x,a.bdPos=y,a.wdPos=b,a.wHover=a.dPos*(d?p/h:1),l(r,{pos:v,val:m},g,a),c(r,{x:s,y:f},g,a),u(r,{pos:v,val:m},g,a))})},plotBoxAndWhiskers:l,plotPoints:c,plotBoxMean:u}},{"../../components/drawing":595,"../../lib":696,d3:148}],869:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n,i=t.cd,a=t.xaxis,o=t.yaxis,s=[];if(!1===e)for(r=0;r=10)return null;var i=1/0;var a=-1/0;var o=e.length;for(var s=0;s0?Math.floor:Math.ceil,O=C>0?Math.ceil:Math.floor,I=C>0?Math.min:Math.max,P=C>0?Math.max:Math.min,D=z(S+L),R=O(E-L),B=[[f=T(S)]];for(a=D;a*C=0;i--)a[u-i]=t[f][i],o[u-i]=e[f][i];for(s.push({x:a,y:o,bicubic:l}),i=f,a=[],o=[];i>=0;i--)a[f-i]=t[i][0],o[f-i]=e[i][0];return s.push({x:a,y:o,bicubic:c}),s}},{}],883:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib/extend").extendFlat;e.exports=function(t,e,r){var a,o,s,l,c,u,f,h,p,d,g,v,m,y,x=t["_"+e],b=t[e+"axis"],_=b._gridlines=[],w=b._minorgridlines=[],k=b._boundarylines=[],M=t["_"+r],A=t[r+"axis"];"array"===b.tickmode&&(b.tickvals=x.slice());var T=t._xctrl,S=t._yctrl,E=T[0].length,C=T.length,L=t._a.length,z=t._b.length;n.prepTicks(b),"array"===b.tickmode&&delete b.tickvals;var O=b.smoothing?3:1;function I(n){var i,a,o,s,l,c,u,f,p,d,g,v,m=[],y=[],x={};if("b"===e)for(a=t.b2j(n),o=Math.floor(Math.max(0,Math.min(z-2,a))),s=a-o,x.length=z,x.crossLength=L,x.xy=function(e){return t.evalxy([],e,a)},x.dxy=function(e,r){return t.dxydi([],e,o,r,s)},i=0;i0&&(p=t.dxydi([],i-1,o,0,s),m.push(l[0]+p[0]/3),y.push(l[1]+p[1]/3),d=t.dxydi([],i-1,o,1,s),m.push(f[0]-d[0]/3),y.push(f[1]-d[1]/3)),m.push(f[0]),y.push(f[1]),l=f;else for(i=t.a2i(n),c=Math.floor(Math.max(0,Math.min(L-2,i))),u=i-c,x.length=L,x.crossLength=z,x.xy=function(e){return t.evalxy([],i,e)},x.dxy=function(e,r){return t.dxydj([],c,e,u,r)},a=0;a0&&(g=t.dxydj([],c,a-1,u,0),m.push(l[0]+g[0]/3),y.push(l[1]+g[1]/3),v=t.dxydj([],c,a-1,u,1),m.push(f[0]-v[0]/3),y.push(f[1]-v[1]/3)),m.push(f[0]),y.push(f[1]),l=f;return x.axisLetter=e,x.axis=b,x.crossAxis=A,x.value=n,x.constvar=r,x.index=h,x.x=m,x.y=y,x.smoothing=A.smoothing,x}function P(n){var i,a,o,s,l,c=[],u=[],f={};if(f.length=x.length,f.crossLength=M.length,"b"===e)for(o=Math.max(0,Math.min(z-2,n)),l=Math.min(1,Math.max(0,n-o)),f.xy=function(e){return t.evalxy([],e,n)},f.dxy=function(e,r){return t.dxydi([],e,o,r,l)},i=0;ix.length-1||_.push(i(P(o),{color:b.gridcolor,width:b.gridwidth}));for(h=u;hx.length-1||g<0||g>x.length-1))for(v=x[s],m=x[g],a=0;ax[x.length-1]||w.push(i(I(d),{color:b.minorgridcolor,width:b.minorgridwidth}));b.startline&&k.push(i(P(0),{color:b.startlinecolor,width:b.startlinewidth})),b.endline&&k.push(i(P(x.length-1),{color:b.endlinecolor,width:b.endlinewidth}))}else{for(l=5e-15,u=(c=[Math.floor((x[x.length-1]-b.tick0)/b.dtick*(1+l)),Math.ceil((x[0]-b.tick0)/b.dtick/(1+l))].sort(function(t,e){return t-e}))[0],f=c[1],h=u;h<=f;h++)p=b.tick0+b.dtick*h,_.push(i(I(p),{color:b.gridcolor,width:b.gridwidth}));for(h=u-1;hx[x.length-1]||w.push(i(I(d),{color:b.minorgridcolor,width:b.minorgridwidth}));b.startline&&k.push(i(I(x[0]),{color:b.startlinecolor,width:b.startlinewidth})),b.endline&&k.push(i(I(x[x.length-1]),{color:b.endlinecolor,width:b.endlinewidth}))}}},{"../../lib/extend":685,"../../plots/cartesian/axes":744}],884:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib/extend").extendFlat;e.exports=function(t,e){var r,a,o,s=e._labels=[],l=e._gridlines;for(r=0;re.length&&(t=t.slice(0,e.length)):t=[],i=0;i90&&(p-=180,l=-l),{angle:p,flip:l,p:t.c2p(n,e,r),offsetMultplier:c}}},{}],898:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../components/drawing"),a=t("./map_1d_array"),o=t("./makepath"),s=t("./orient_text"),l=t("../../lib/svg_text_utils"),c=t("../../lib"),u=t("../../constants/alignment");function f(t,e,r,i,s,l){var c="const-"+s+"-lines",u=r.selectAll("."+c).data(l);u.enter().append("path").classed(c,!0).style("vector-effect","non-scaling-stroke"),u.each(function(r){var i=r,s=i.x,l=i.y,c=a([],s,t.c2p),u=a([],l,e.c2p),f="M"+o(c,u,i.smoothing);n.select(this).attr("d",f).style("stroke-width",i.width).style("stroke",i.color).style("fill","none")}),u.exit().remove()}function h(t,e,r,a,o,c,u,f){var h=c.selectAll("text."+f).data(u);h.enter().append("text").classed(f,!0);var p=0,d={};return h.each(function(o,c){var u;if("auto"===o.axis.tickangle)u=s(a,e,r,o.xy,o.dxy);else{var f=(o.axis.tickangle+180)*Math.PI/180;u=s(a,e,r,o.xy,[Math.cos(f),Math.sin(f)])}c||(d={angle:u.angle,flip:u.flip});var h=(o.endAnchor?-1:1)*u.flip,g=n.select(this).attr({"text-anchor":h>0?"start":"end","data-notex":1}).call(i.font,o.font).text(o.text).call(l.convertToTspans,t),v=i.bBox(this);g.attr("transform","translate("+u.p[0]+","+u.p[1]+") rotate("+u.angle+")translate("+o.axis.labelpadding*h+","+.3*v.height+")"),p=Math.max(p,v.width+o.axis.labelpadding)}),h.exit().remove(),d.maxExtent=p,d}e.exports=function(t,e,r,i){var l=e.xaxis,u=e.yaxis,p=t._fullLayout._clips;c.makeTraceGroups(i,r,"trace").each(function(e){var r=n.select(this),i=e[0],d=i.trace,v=d.aaxis,m=d.baxis,y=c.ensureSingle(r,"g","minorlayer"),x=c.ensureSingle(r,"g","majorlayer"),b=c.ensureSingle(r,"g","boundarylayer"),_=c.ensureSingle(r,"g","labellayer");r.style("opacity",d.opacity),f(l,u,x,v,"a",v._gridlines),f(l,u,x,m,"b",m._gridlines),f(l,u,y,v,"a",v._minorgridlines),f(l,u,y,m,"b",m._minorgridlines),f(l,u,b,v,"a-boundary",v._boundarylines),f(l,u,b,m,"b-boundary",m._boundarylines);var w=h(t,l,u,d,i,_,v._labels,"a-label"),k=h(t,l,u,d,i,_,m._labels,"b-label");!function(t,e,r,n,i,a,o,l){var u,f,h,p;u=.5*(r.a[0]+r.a[r.a.length-1]),f=r.b[0],h=r.ab2xy(u,f,!0),p=r.dxyda_rough(u,f),void 0===o.angle&&c.extendFlat(o,s(r,i,a,h,r.dxydb_rough(u,f)));g(t,e,r,n,h,p,r.aaxis,i,a,o,"a-title"),u=r.a[0],f=.5*(r.b[0]+r.b[r.b.length-1]),h=r.ab2xy(u,f,!0),p=r.dxydb_rough(u,f),void 0===l.angle&&c.extendFlat(l,s(r,i,a,h,r.dxyda_rough(u,f)));g(t,e,r,n,h,p,r.baxis,i,a,l,"b-title")}(t,_,d,i,l,u,w,k),function(t,e,r,n,i){var s,l,u,f,h=r.select("#"+t._clipPathId);h.size()||(h=r.append("clipPath").classed("carpetclip",!0));var p=c.ensureSingle(h,"path","carpetboundary"),d=e.clipsegments,g=[];for(f=0;f90&&v<270,y=n.select(this);y.text(u.title||"").call(l.convertToTspans,t),m&&(x=(-l.lineCount(y)+d)*p*a-x),y.attr("transform","translate("+e.p[0]+","+e.p[1]+") rotate("+e.angle+") translate(0,"+x+")").classed("user-select-none",!0).attr("text-anchor","middle").call(i.font,u.titlefont)}),y.exit().remove()}},{"../../components/drawing":595,"../../constants/alignment":668,"../../lib":696,"../../lib/svg_text_utils":720,"./makepath":895,"./map_1d_array":896,"./orient_text":897,d3:148}],899:[function(t,e,r){"use strict";var n=t("./constants"),i=t("../../lib/search").findBin,a=t("./compute_control_points"),o=t("./create_spline_evaluator"),s=t("./create_i_derivative_evaluator"),l=t("./create_j_derivative_evaluator");e.exports=function(t){var e=t._a,r=t._b,c=e.length,u=r.length,f=t.aaxis,h=t.baxis,p=e[0],d=e[c-1],g=r[0],v=r[u-1],m=e[e.length-1]-e[0],y=r[r.length-1]-r[0],x=m*n.RELATIVE_CULL_TOLERANCE,b=y*n.RELATIVE_CULL_TOLERANCE;p-=x,d+=x,g-=b,v+=b,t.isVisible=function(t,e){return t>p&&tg&&ed||ev},t.setScale=function(){var e=t._x,r=t._y,n=a(t._xctrl,t._yctrl,e,r,f.smoothing,h.smoothing);t._xctrl=n[0],t._yctrl=n[1],t.evalxy=o([t._xctrl,t._yctrl],c,u,f.smoothing,h.smoothing),t.dxydi=s([t._xctrl,t._yctrl],f.smoothing,h.smoothing),t.dxydj=l([t._xctrl,t._yctrl],f.smoothing,h.smoothing)},t.i2a=function(t){var r=Math.max(0,Math.floor(t[0]),c-2),n=t[0]-r;return(1-n)*e[r]+n*e[r+1]},t.j2b=function(t){var e=Math.max(0,Math.floor(t[1]),c-2),n=t[1]-e;return(1-n)*r[e]+n*r[e+1]},t.ij2ab=function(e){return[t.i2a(e[0]),t.j2b(e[1])]},t.a2i=function(t){var r=Math.max(0,Math.min(i(t,e),c-2)),n=e[r],a=e[r+1];return Math.max(0,Math.min(c-1,r+(t-n)/(a-n)))},t.b2j=function(t){var e=Math.max(0,Math.min(i(t,r),u-2)),n=r[e],a=r[e+1];return Math.max(0,Math.min(u-1,e+(t-n)/(a-n)))},t.ab2ij=function(e){return[t.a2i(e[0]),t.b2j(e[1])]},t.i2c=function(e,r){return t.evalxy([],e,r)},t.ab2xy=function(n,i,a){if(!a&&(ne[c-1]|ir[u-1]))return[!1,!1];var o=t.a2i(n),s=t.b2j(i),l=t.evalxy([],o,s);if(a){var f,h,p,d,g=0,v=0,m=[];ne[c-1]?(f=c-2,h=1,g=(n-e[c-1])/(e[c-1]-e[c-2])):h=o-(f=Math.max(0,Math.min(c-2,Math.floor(o)))),ir[u-1]?(p=u-2,d=1,v=(i-r[u-1])/(r[u-1]-r[u-2])):d=s-(p=Math.max(0,Math.min(u-2,Math.floor(s)))),g&&(t.dxydi(m,f,p,h,d),l[0]+=m[0]*g,l[1]+=m[1]*g),v&&(t.dxydj(m,f,p,h,d),l[0]+=m[0]*v,l[1]+=m[1]*v)}return l},t.c2p=function(t,e,r){return[e.c2p(t[0]),r.c2p(t[1])]},t.p2x=function(t,e,r){return[e.p2c(t[0]),r.p2c(t[1])]},t.dadi=function(t){var r=Math.max(0,Math.min(e.length-2,t));return e[r+1]-e[r]},t.dbdj=function(t){var e=Math.max(0,Math.min(r.length-2,t));return r[e+1]-r[e]},t.dxyda=function(e,r,n,i){var a=t.dxydi(null,e,r,n,i),o=t.dadi(e,n);return[a[0]/o,a[1]/o]},t.dxydb=function(e,r,n,i){var a=t.dxydj(null,e,r,n,i),o=t.dbdj(r,i);return[a[0]/o,a[1]/o]},t.dxyda_rough=function(e,r,n){var i=m*(n||.1),a=t.ab2xy(e+i,r,!0),o=t.ab2xy(e-i,r,!0);return[.5*(a[0]-o[0])/i,.5*(a[1]-o[1])/i]},t.dxydb_rough=function(e,r,n){var i=y*(n||.1),a=t.ab2xy(e,r+i,!0),o=t.ab2xy(e,r-i,!0);return[.5*(a[0]-o[0])/i,.5*(a[1]-o[1])/i]},t.dpdx=function(t){return t._m},t.dpdy=function(t){return t._m}}},{"../../lib/search":715,"./compute_control_points":887,"./constants":888,"./create_i_derivative_evaluator":889,"./create_j_derivative_evaluator":890,"./create_spline_evaluator":891}],900:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a,o,s=[],l=[],c=t[0].length,u=t.length;function f(e,r){var n,i=0,a=0;return e>0&&void 0!==(n=t[r][e-1])&&(a++,i+=n),e0&&void 0!==(n=t[r-1][e])&&(a++,i+=n),r0&&a0&&i1e-5);return n.log("Smoother converged to",M,"after",A,"iterations"),t}},{"../../lib":696}],901:[function(t,e,r){"use strict";var n=t("../../lib").isArray1D;e.exports=function(t,e,r){var i=r("x"),a=i&&i.length,o=r("y"),s=o&&o.length;if(!a&&!s)return!1;if(e._cheater=!i,a&&!n(i)||s&&!n(o))e._length=null;else{var l=a?i.length:1/0;s&&(l=Math.min(l,o.length)),e.a&&e.a.length&&(l=Math.min(l,e.a.length)),e.b&&e.b.length&&(l=Math.min(l,e.b.length)),e._length=l}return!0}},{"../../lib":696}],902:[function(t,e,r){"use strict";var n=t("../scattergeo/attributes"),i=t("../../components/colorscale/attributes"),a=t("../../components/colorbar/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat,l=n.marker.line;e.exports=s({locations:{valType:"data_array",editType:"calc"},locationmode:n.locationmode,z:{valType:"data_array",editType:"calc"},text:s({},n.text,{}),marker:{line:{color:l.color,width:s({},l.width,{dflt:1}),editType:"calc"},opacity:{valType:"number",arrayOk:!0,min:0,max:1,dflt:1,editType:"style"},editType:"calc"},selected:{marker:{opacity:n.selected.marker.opacity,editType:"plot"},editType:"plot"},unselected:{marker:{opacity:n.unselected.marker.opacity,editType:"plot"},editType:"plot"},hoverinfo:s({},o.hoverinfo,{editType:"calc",flags:["location","z","text","name"]})},i("",{cLetter:"z",editTypeOverride:"calc"}),{colorbar:a})},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../scattergeo/attributes":1083}],903:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../constants/numerical").BADNUM,a=t("../../components/colorscale/calc"),o=t("../scatter/arrays_to_calcdata"),s=t("../scatter/calc_selection");e.exports=function(t,e){for(var r=e._length,l=new Array(r),c=0;c")}(t,f,o,h.mockAxis),[t]}},{"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051,"./attributes":902}],907:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.eventData=t("./event_data"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":775,"../heatmap/colorbar":948,"./attributes":902,"./calc":903,"./defaults":904,"./event_data":905,"./hover":906,"./plot":908,"./select":909,"./style":910}],908:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../lib/polygon"),o=t("../../lib/topojson_utils").getTopojsonFeatures,s=t("../../lib/geo_location_utils").locationToFeature,l=t("./style").style;function c(t,e){for(var r=t[0].trace,n=t.length,i=o(r,e),a=0;a0&&t[e+1][0]<0)return e;return null}switch(e="RUS"===l||"FJI"===l?function(t){var e;if(null===u(t))e=t;else for(e=new Array(t.length),i=0;ie?r[n++]=[t[i][0]+360,t[i][1]]:i===e?(r[n++]=t[i],r[n++]=[t[i][0],-90]):r[n++]=t[i];var o=a.tester(r);o.pts.pop(),c.push(o)}:function(t){c.push(a.tester(t))},o.type){case"MultiPolygon":for(r=0;r":f.value>h&&(s.prefixBoundary=!0);break;case"<":f.valueh)&&(s.prefixBoundary=!0);break;case"][":a=Math.min.apply(null,f.value),o=Math.max.apply(null,f.value),ah&&(s.prefixBoundary=!0)}}},{}],919:[function(t,e,r){"use strict";var n=t("../../components/colorbar/draw"),i=t("./make_color_map"),a=t("./end_plus");e.exports=function(t,e){var r=e[0].trace,o="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+o).remove(),r.showscale){var s=e[0].t.cb=n(t,o),l=r.contours,c=r.line,u=l.size||1,f=l.coloring,h=i(r,{isColorbar:!0});s.fillgradient("heatmap"===f?r.colorscale:"").zrange("heatmap"===f?[r.zmin,r.zmax]:"").fillcolor("fill"===f?h:"").line({color:"lines"===f?h:c.color,width:!1!==l.showlines?c.width:0,dash:c.dash}).levels({start:l.start,end:a(l),size:u}).options(r.colorbar)()}}},{"../../components/colorbar/draw":575,"./end_plus":927,"./make_color_map":932}],920:[function(t,e,r){"use strict";e.exports={BOTTOMSTART:[1,9,13,104,713],TOPSTART:[4,6,7,104,713],LEFTSTART:[8,12,14,208,1114],RIGHTSTART:[2,3,11,208,1114],NEWDELTA:[null,[-1,0],[0,-1],[-1,0],[1,0],null,[0,-1],[-1,0],[0,1],[0,1],null,[0,1],[1,0],[1,0],[0,-1]],CHOOSESADDLE:{104:[4,1],208:[2,8],713:[7,13],1114:[11,14]},SADDLEREMAINDER:{1:4,2:8,4:1,7:13,8:2,11:14,13:7,14:11},LABELDISTANCE:2,LABELINCREASE:10,LABELMIN:3,LABELMAX:10,LABELOPTIMIZER:{EDGECOST:1,ANGLECOST:1,NEIGHBORCOST:5,SAMELEVELFACTOR:10,SAMELEVELDISTANCE:5,MAXCOST:100,INITIALSEARCHPOINTS:10,ITERATIONS:5}}},{}],921:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("./label_defaults"),a=t("../../components/color"),o=a.addOpacity,s=a.opacity,l=t("../../constants/filter_ops"),c=l.CONSTRAINT_REDUCTION,u=l.COMPARISON_OPS2;e.exports=function(t,e,r,a,l,f){var h,p,d,g=e.contours,v=r("contours.operation");(g._operation=c[v],function(t,e){var r;-1===u.indexOf(e.operation)?(t("contours.value",[0,1]),Array.isArray(e.value)?e.value.length>2?e.value=e.value.slice(2):0===e.length?e.value=[0,1]:e.length<2?(r=parseFloat(e.value[0]),e.value=[r,r+1]):e.value=[parseFloat(e.value[0]),parseFloat(e.value[1])]:n(e.value)&&(r=parseFloat(e.value),e.value=[r,r+1])):(t("contours.value",0),n(e.value)||(Array.isArray(e.value)?e.value=parseFloat(e.value[0]):e.value=0))}(r,g),"="===v?h=g.showlines=!0:(h=r("contours.showlines"),d=r("fillcolor",o((t.line||{}).color||l,.5))),h)&&(p=r("line.color",d&&s(d)?o(e.fillcolor,1):l),r("line.width",2),r("line.dash"));r("line.smoothing"),i(r,a,p,f)}},{"../../components/color":570,"../../constants/filter_ops":669,"./label_defaults":931,"fast-isnumeric":214}],922:[function(t,e,r){"use strict";var n=t("../../constants/filter_ops"),i=t("fast-isnumeric");function a(t,e){var r,a=Array.isArray(e);function o(t){return i(t)?+t:null}return-1!==n.COMPARISON_OPS2.indexOf(t)?r=o(a?e[0]:e):-1!==n.INTERVAL_OPS.indexOf(t)?r=a?[o(e[0]),o(e[1])]:[o(e),o(e)]:-1!==n.SET_OPS.indexOf(t)&&(r=a?e.map(o):[o(e)]),r}function o(t){return function(e){e=a(t,e);var r=Math.min(e[0],e[1]),n=Math.max(e[0],e[1]);return{start:r,end:n,size:n-r}}}function s(t){return function(e){return{start:e=a(t,e),end:1/0,size:1/0}}}e.exports={"[]":o("[]"),"][":o("]["),">":s(">"),"<":s("<"),"=":s("=")}},{"../../constants/filter_ops":669,"fast-isnumeric":214}],923:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var i=n("contours.start"),a=n("contours.end"),o=!1===i||!1===a,s=r("contours.size");!(o?e.autocontour=!0:r("autocontour",!1))&&s||r("ncontours")}},{}],924:[function(t,e,r){"use strict";var n=t("../../lib");function i(t){return n.extendFlat({},t,{edgepaths:n.extendDeep([],t.edgepaths),paths:n.extendDeep([],t.paths)})}e.exports=function(t,e){var r,a,o,s=function(t){return t.reverse()},l=function(t){return t};switch(e){case"=":case"<":return t;case">":for(1!==t.length&&n.warn("Contour data invalid for the specified inequality operation."),a=t[0],r=0;r1e3){n.warn("Too many contours, clipping at 1000",t);break}return l}},{"../../lib":696,"./constraint_mapping":922,"./end_plus":927}],927:[function(t,e,r){"use strict";e.exports=function(t){return t.end+t.size/1e6}},{}],928:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./constants");function a(t,e,r,n){return Math.abs(t[0]-e[0])20&&e?208===t||1114===t?n=0===r[0]?1:-1:a=0===r[1]?1:-1:-1!==i.BOTTOMSTART.indexOf(t)?a=1:-1!==i.LEFTSTART.indexOf(t)?n=1:-1!==i.TOPSTART.indexOf(t)?a=-1:n=-1;return[n,a]}(h,r,e),d=[s(t,e,[-p[0],-p[1]])],g=p.join(","),v=t.z.length,m=t.z[0].length;for(c=0;c<1e4;c++){if(h>20?(h=i.CHOOSESADDLE[h][(p[0]||p[1])<0?0:1],t.crossings[f]=i.SADDLEREMAINDER[h]):delete t.crossings[f],!(p=i.NEWDELTA[h])){n.log("Found bad marching index:",h,e,t.level);break}d.push(s(t,e,p)),e[0]+=p[0],e[1]+=p[1],a(d[d.length-1],d[d.length-2],o,l)&&d.pop(),f=e.join(",");var y=p[0]&&(e[0]<0||e[0]>m-2)||p[1]&&(e[1]<0||e[1]>v-2);if(f===u&&p.join(",")===g||r&&y)break;h=t.crossings[f]}1e4===c&&n.log("Infinite loop in contour?");var x,b,_,w,k,M,A,T,S,E,C,L,z,O,I,P=a(d[0],d[d.length-1],o,l),D=0,R=.2*t.smoothing,B=[],F=0;for(c=1;c=F;c--)if((x=B[c])=F&&x+B[b]T&&S--,t.edgepaths[S]=C.concat(d,E));break}U||(t.edgepaths[T]=d.concat(E))}for(T=0;Tt?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);return 5===r||10===r?t>(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4?5===r?713:1114:5===r?104:208:15===r?0:r}e.exports=function(t){var e,r,a,o,s,l,c,u,f,h=t[0].z,p=h.length,d=h[0].length,g=2===p||2===d;for(r=0;rt.level}return r?"M"+e.join("L")+"Z":""}(t,e),h=0,p=t.edgepaths.map(function(t,e){return e}),d=!0;function g(t){return Math.abs(t[1]-e[2][1])<.01}function v(t){return Math.abs(t[0]-e[0][0])<.01}function m(t){return Math.abs(t[0]-e[2][0])<.01}for(;p.length;){for(c=a.smoothopen(t.edgepaths[h],t.smoothing),f+=d?c:c.replace(/^M/,"L"),p.splice(p.indexOf(h),1),r=t.edgepaths[h][t.edgepaths[h].length-1],s=-1,o=0;o<4;o++){if(!r){i.log("Missing end?",h,t);break}for(u=r,Math.abs(u[1]-e[0][1])<.01&&!m(r)?n=e[1]:v(r)?n=e[0]:g(r)?n=e[3]:m(r)&&(n=e[2]),l=0;l=0&&(n=y,s=l):Math.abs(r[1]-n[1])<.01?Math.abs(r[1]-y[1])<.01&&(y[0]-r[0])*(n[0]-y[0])>=0&&(n=y,s=l):i.log("endpt to newendpt is not vert. or horz.",r,n,y)}if(r=n,s>=0)break;f+="L"+n}if(s===t.edgepaths.length){i.log("unclosed perimeter path");break}h=s,(d=-1===p.indexOf(h))&&(h=p[0],f+="Z")}for(h=0;hn.center?n.right-s:s-n.left)/(u+Math.abs(Math.sin(c)*o)),p=(l>n.middle?n.bottom-l:l-n.top)/(Math.abs(f)+Math.cos(c)*o);if(h<1||p<1)return 1/0;var d=v.EDGECOST*(1/(h-1)+1/(p-1));d+=v.ANGLECOST*c*c;for(var g=s-u,m=l-f,y=s+u,x=l+f,b=0;b2*v.MAXCOST)break;p&&(s/=2),l=(o=c-s/2)+1.5*s}if(h<=v.MAXCOST)return u},r.addLabelData=function(t,e,r,n){var i=e.width/2,a=e.height/2,o=t.x,s=t.y,l=t.theta,c=Math.sin(l),u=Math.cos(l),f=i*u,h=a*c,p=i*c,d=-a*u,g=[[o-f-h,s-p-d],[o+f-h,s+p-d],[o+f+h,s+p+d],[o-f+h,s-p+d]];r.push({text:e.text,x:o,y:s,dy:e.dy,theta:l,level:e.level,width:e.width,height:e.height}),n.push(g)},r.drawLabels=function(t,e,r,a,s){var l=t.selectAll("text").data(e,function(t){return t.text+","+t.x+","+t.y+","+t.theta});if(l.exit().remove(),l.enter().append("text").attr({"data-notex":1,"text-anchor":"middle"}).each(function(t){var e=t.x+Math.sin(t.theta)*t.dy,i=t.y-Math.cos(t.theta)*t.dy;n.select(this).text(t.text).attr({x:e,y:i,transform:"rotate("+180*t.theta/Math.PI+" "+e+" "+i+")"}).call(o.convertToTspans,r)}),s){for(var c="",u=0;ue.end&&(e.start=e.end=(e.start+e.end)/2),t._input.contours||(t._input.contours={}),i.extendFlat(t._input.contours,{start:e.start,end:e.end,size:e.size}),t._input.autocontour=!0}else if("constraint"!==e.type){var l,c=e.start,u=e.end,f=t._input.contours;if(c>u&&(e.start=f.start=u,u=e.end=f.end=c,c=e.start),!(e.size>0))l=c===u?1:a(c,u,t.ncontours).dtick,f.size=e.size=l}}},{"../../lib":696,"../../plots/cartesian/axes":744}],936:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../components/drawing"),a=t("../heatmap/style"),o=t("./make_color_map");e.exports=function(t){var e=n.select(t).selectAll("g.contour");e.style("opacity",function(t){return t[0].trace.opacity}),e.each(function(t){var e=n.select(this),r=t[0].trace,a=r.contours,s=r.line,l=a.size||1,c=a.start,u="constraint"===a.type,f=!u&&"lines"===a.coloring,h=!u&&"fill"===a.coloring,p=f||h?o(r):null;e.selectAll("g.contourlevel").each(function(t){n.select(this).selectAll("path").call(i.lineGroupStyle,s.width,f?p(t.level):s.color,s.dash)});var d=a.labelfont;if(e.selectAll("g.contourlabels text").each(function(t){i.font(n.select(this),{family:d.family,size:d.size,color:d.color||(f?p(t.level):s.color)})}),u)e.selectAll("g.contourfill path").style("fill",r.fillcolor);else if(h){var g;e.selectAll("g.contourfill path").style("fill",function(t){return void 0===g&&(g=t.level),p(t.level+.5*l)}),void 0===g&&(g=c),e.selectAll("g.contourbg path").style("fill",p(g-.5*l))}}),a(t)}},{"../../components/drawing":595,"../heatmap/style":958,"./make_color_map":932,d3:148}],937:[function(t,e,r){"use strict";var n=t("../../components/colorscale/defaults"),i=t("./label_defaults");e.exports=function(t,e,r,a,o){var s,l=r("contours.coloring"),c="";"fill"===l&&(s=r("contours.showlines")),!1!==s&&("lines"!==l&&(c=r("line.color","#000")),r("line.width",.5),r("line.dash")),"none"!==l&&(!0!==t.showlegend&&(e.showlegend=!1),e._dfltShowLegend=!1,n(t,e,a,r,{prefix:"",cLetter:"z"})),r("line.smoothing"),i(r,a,c,o)}},{"../../components/colorscale/defaults":580,"./label_defaults":931}],938:[function(t,e,r){"use strict";var n=t("../heatmap/attributes"),i=t("../contour/attributes"),a=i.contours,o=t("../scatter/attributes"),s=t("../../components/colorscale/attributes"),l=t("../../components/colorbar/attributes"),c=t("../../lib/extend").extendFlat,u=o.line;e.exports=c({carpet:{valType:"string",editType:"calc"},z:n.z,a:n.x,a0:n.x0,da:n.dx,b:n.y,b0:n.y0,db:n.dy,text:n.text,transpose:n.transpose,atype:n.xtype,btype:n.ytype,fillcolor:i.fillcolor,autocontour:i.autocontour,ncontours:i.ncontours,contours:{type:a.type,start:a.start,end:a.end,size:a.size,coloring:{valType:"enumerated",values:["fill","lines","none"],dflt:"fill",editType:"calc"},showlines:a.showlines,showlabels:a.showlabels,labelfont:a.labelfont,labelformat:a.labelformat,operation:a.operation,value:a.value,editType:"calc",impliedEdits:{autocontour:!1}},line:{color:c({},u.color,{}),width:u.width,dash:u.dash,smoothing:c({},u.smoothing,{}),editType:"plot"},transforms:void 0},s("",{cLetter:"z",autoColorDflt:!1}),{colorbar:l})},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../contour/attributes":916,"../heatmap/attributes":945,"../scatter/attributes":1043}],939:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc"),i=t("../../lib").isArray1D,a=t("../heatmap/convert_column_xyz"),o=t("../heatmap/clean_2d_array"),s=t("../heatmap/max_row_length"),l=t("../heatmap/interp2d"),c=t("../heatmap/find_empties"),u=t("../heatmap/make_bound_array"),f=t("./defaults"),h=t("../carpet/lookup_carpetid"),p=t("../contour/set_contours");e.exports=function(t,e){var r=e._carpetTrace=h(t,e);if(r&&r.visible&&"legendonly"!==r.visible){if(!e.a||!e.b){var d=t.data[r.index],g=t.data[e.index];g.a||(g.a=d.a),g.b||(g.b=d.b),f(g,e,e._defaultColor,t._fullLayout)}var v=function(t,e){var r,f,h,p,d,g,v,m=e._carpetTrace,y=m.aaxis,x=m.baxis;y._minDtick=0,x._minDtick=0,i(e.z)&&a(e,y,x,"a","b",["z"]);r=e._a=e._a||e.a,p=e._b=e._b||e.b,r=r?y.makeCalcdata(e,"_a"):[],p=p?x.makeCalcdata(e,"_b"):[],f=e.a0||0,h=e.da||1,d=e.b0||0,g=e.db||1,v=e._z=o(e._z||e.z,e.transpose),e._emptypoints=c(v),l(v,e._emptypoints);var b=s(v),_="scaled"===e.xtype?"":r,w=u(e,_,f,h,b,y),k="scaled"===e.ytype?"":p,M=u(e,k,d,g,v.length,x),A={a:w,b:M,z:v};"levels"===e.contours.type&&"none"!==e.contours.coloring&&n(e,v,"","z");return[A]}(0,e);return p(e),v}}},{"../../components/colorscale/calc":578,"../../lib":696,"../carpet/lookup_carpetid":894,"../contour/set_contours":935,"../heatmap/clean_2d_array":947,"../heatmap/convert_column_xyz":949,"../heatmap/find_empties":951,"../heatmap/interp2d":954,"../heatmap/make_bound_array":955,"../heatmap/max_row_length":956,"./defaults":940}],940:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../heatmap/xyz_defaults"),a=t("./attributes"),o=t("../contour/constraint_defaults"),s=t("../contour/contours_defaults"),l=t("../contour/style_defaults");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,a,r,i)}if(u("carpet"),t.a&&t.b){if(!i(t,e,u,c,"a","b"))return void(e.visible=!1);u("text"),"constraint"===u("contours.type")?o(t,e,u,c,r,{hasHover:!1}):(s(t,e,u,function(r){return n.coerce2(t,e,a,r)}),l(t,e,u,c,{hasHover:!1}))}else e._defaultColor=r,e._length=null}},{"../../lib":696,"../contour/constraint_defaults":921,"../contour/contours_defaults":923,"../contour/style_defaults":937,"../heatmap/xyz_defaults":960,"./attributes":938}],941:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../contour/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("../contour/style"),n.moduleType="trace",n.name="contourcarpet",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","carpet","contour","symbols","showLegend","hasLines","carpetDependent"],n.meta={},e.exports=n},{"../../plots/cartesian":756,"../contour/colorbar":919,"../contour/style":936,"./attributes":938,"./calc":939,"./defaults":940,"./plot":944}],942:[function(t,e,r){"use strict";var n=t("../../components/drawing"),i=t("../carpet/axis_aligned_line"),a=t("../../lib");e.exports=function(t,e,r,o,s,l,c,u){var f,h,p,d,g,v,m,y="",x=e.edgepaths.map(function(t,e){return e}),b=!0,_=1e-4*Math.abs(r[0][0]-r[2][0]),w=1e-4*Math.abs(r[0][1]-r[2][1]);function k(t){return Math.abs(t[1]-r[0][1])=0&&(p=C,g=v):Math.abs(h[1]-p[1])=0&&(p=C,g=v):a.log("endpt to newendpt is not vert. or horz.",h,p,C)}if(g>=0)break;y+=S(h,p),h=p}if(g===e.edgepaths.length){a.log("unclosed perimeter path");break}f=g,(b=-1===x.indexOf(f))&&(f=x[0],y+=S(h,p)+"Z",h=null)}for(f=0;f=0;V--)F=S.clipsegments[V],N=i([],F.x,w.c2p),j=i([],F.y,k.c2p),N.reverse(),j.reverse(),q.push(a(N,j,F.bicubic));var H="M"+q.join("L")+"Z";!function(t,e,r,n,o,l){var c,u,f,h,p=s.ensureSingle(t,"g","contourbg").selectAll("path").data("fill"!==l||o?[]:[0]);p.enter().append("path"),p.exit().remove();var d=[];for(h=0;hv&&(n.max=v);n.len=n.max-n.min}(this,r,t,n,c,e.height),!(n.len<(e.width+e.height)*f.LABELMIN)))for(var i=Math.min(Math.ceil(n.len/O),f.LABELMAX),a=0;az){C("x scale is not linear");break}}if(v.length&&"fast"===S){var O=(v[v.length-1]-v[0])/(v.length-1),I=Math.abs(O/100);for(b=0;bI){C("y scale is not linear");break}}}var P=c(x),D="scaled"===e.xtype?"":r,R=p(e,D,d,g,P,w),B="scaled"===e.ytype?"":v,F=p(e,B,m,y,x.length,k);T||(e._extremes[w._id]=a.findExtremes(w,R),e._extremes[k._id]=a.findExtremes(k,F));var N={x:R,y:F,z:x,text:e._text||e.text};if(D&&D.length===R.length-1&&(N.xCenter=D),B&&B.length===F.length-1&&(N.yCenter=B),A&&(N.xRanges=_.xRanges,N.yRanges=_.yRanges,N.pts=_.pts),M&&"constraint"===e.contours.type||s(e,x,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var j={type:"contour"===e.type?"heatmap":"histogram2d",xcalendar:e.xcalendar,ycalendar:e.ycalendar};N.xfill=p(j,D,d,g,P,w),N.yfill=p(j,B,m,y,x.length,k)}return[N]}},{"../../components/colorscale/calc":578,"../../lib":696,"../../plots/cartesian/axes":744,"../../registry":827,"../histogram2d/calc":977,"./clean_2d_array":947,"./convert_column_xyz":949,"./find_empties":951,"./interp2d":954,"./make_bound_array":955,"./max_row_length":956}],947:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){var r,i,a,o,s,l;function c(t){if(n(t))return+t}if(e){for(r=0,s=0;s=0;o--)(s=((f[[(r=(a=h[o])[0])-1,i=a[1]]]||g)[2]+(f[[r+1,i]]||g)[2]+(f[[r,i-1]]||g)[2]+(f[[r,i+1]]||g)[2])/20)&&(l[a]=[r,i,s],h.splice(o,1),c=!0);if(!c)throw"findEmpties iterated with no new neighbors";for(a in l)f[a]=l[a],u.push(l[a])}return u.sort(function(t,e){return e[2]-t[2]})}},{"./max_row_length":956}],952:[function(t,e,r){"use strict";var n=t("../../components/fx"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e,r,o,s,l){var c,u,f,h,p=t.cd[0],d=p.trace,g=t.xa,v=t.ya,m=p.x,y=p.y,x=p.z,b=p.xCenter,_=p.yCenter,w=p.zmask,k=[d.zmin,d.zmax],M=d.zhoverformat,A=m,T=y;if(!1!==t.index){try{f=Math.round(t.index[1]),h=Math.round(t.index[0])}catch(e){return void i.error("Error hovering on heatmap, pointNumber must be [row,col], found:",t.index)}if(f<0||f>=x[0].length||h<0||h>x.length)return}else{if(n.inbox(e-m[0],e-m[m.length-1],0)>0||n.inbox(r-y[0],r-y[y.length-1],0)>0)return;if(l){var S;for(A=[2*m[0]-m[1]],S=1;Sg&&(m=Math.max(m,Math.abs(t[a][o]-d)/(v-g))))}return m}e.exports=function(t,e){var r,i=1;for(o(t,e),r=0;r.01;r++)i=o(t,e,a(i));return i>.01&&n.log("interp2d didn't converge quickly",i),t}},{"../../lib":696}],955:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib").isArrayOrTypedArray;e.exports=function(t,e,r,a,o,s){var l,c,u,f=[],h=n.traceIs(t,"contour"),p=n.traceIs(t,"histogram"),d=n.traceIs(t,"gl2d");if(i(e)&&e.length>1&&!p&&"category"!==s.type){var g=e.length;if(!(g<=o))return h?e.slice(0,o):e.slice(0,o+1);if(h||d)f=e.slice(0,o);else if(1===o)f=[e[0]-.5,e[0]+.5];else{for(f=[1.5*e[0]-.5*e[1]],u=1;u0;)p=d.c2p(M[x]),x--;for(p0;)y=g.c2p(A[x]),x--;if(y0&&(a=!0);for(var l=0;la){var o=a-r[t];return r[t]=a,o}}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]c?t>o?t>1.1*i?i:t>1.1*a?a:o:t>s?s:t>l?l:c:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function p(t,e,r,n,a,s){if(n&&t>o){var l=d(e,a,s),c=d(r,a,s),u=t===i?0:1;return l[u]!==c[u]}return Math.floor(r/t)-Math.floor(e/t)>.1}function d(t,e,r){var n=e.c2d(t,i,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}e.exports=function(t,e,r,n,a){var s,l,c=-1.1*e,h=-.1*e,p=t-h,d=r[0],g=r[1],v=Math.min(f(d+h,d+p,n,a),f(g+h,g+p,n,a)),m=Math.min(f(d+c,d+h,n,a),f(g+c,g+h,n,a));if(v>m&&mo){var y=s===i?1:6,x=s===i?"M12":"M1";return function(e,r){var o=n.c2d(e,i,a),s=o.indexOf("-",y);s>0&&(o=o.substr(0,s));var c=n.d2c(o,0,a);if(cr.r2l(z)&&(I=a.tickIncrement(I,_.size,!0,h)),S.start=r.l2r(I),L||i.nestedProperty(e,v+".start").set(S.start)}var P=_.end,D=r.r2l(T.end),R=void 0!==D;if((_.endFound||R)&&D!==r.r2l(P)){var B=R?D:i.aggNums(Math.max,null,p);S.end=r.l2r(B),R||i.nestedProperty(e,v+".start").set(S.end)}var F="autobin"+o;return!1===e._input[F]&&(e._input[v]=i.extendFlat({},e[v]||{}),delete e._input[F],delete e[F]),[S,p]}e.exports=function(t,e){if(!0===e.visible){var r,h,p,d,g=[],v=[],m=a.getFromId(t,"h"===e.orientation?e.yaxis||"y":e.xaxis||"x"),y="h"===e.orientation?"y":"x",x={x:"y",y:"x"}[y],b=e[y+"calendar"],_=e.cumulative,w=f(t,e,m,y),k=w[0],M=w[1],A="string"==typeof k.size,T=[],S=A?T:k,E=[],C=[],L=[],z=0,O=e.histnorm,I=e.histfunc,P=-1!==O.indexOf("density");_.enabled&&P&&(O=O.replace(/ ?density$/,""),P=!1);var D,R="max"===I||"min"===I?null:0,B=s.count,F=l[O],N=!1,j=function(t){return m.r2c(t,0,b)};for(i.isArrayOrTypedArray(e[x])&&"count"!==I&&(D=e[x],N="avg"===I,B=s[I]),r=j(k.start),p=j(k.end)+(r-a.tickIncrement(r,k.size,!1,b))/1e6;r=0&&d=0;n--)s(n);else if("increasing"===e){for(n=1;n=0;n--)t[n]+=t[n+1];"exclude"===r&&(t.push(0),t.shift())}}(v,_.direction,_.currentbin);var X=Math.min(g.length,v.length),Z=[],$=0,J=X-1;for(r=0;r=$;r--)if(v[r]){J=r;break}for(r=$;r<=J;r++)if(n(g[r])&&n(v[r])){var K={p:g[r],s:v[r],b:0};_.enabled||(K.pts=L[r],q?K.ph0=K.ph1=L[r].length?M[L[r][0]]:g[r]:(K.ph0=V(T[r]),K.ph1=V(T[r+1],!0))),Z.push(K)}return 1===Z.length&&(Z[0].width1=a.tickIncrement(Z[0].p,k.size,!1,b)-Z[0].p),o(Z,e),i.isArrayOrTypedArray(e.selectedpoints)&&i.tagSelected(Z,e,W),Z}}},{"../../lib":696,"../../plots/cartesian/axes":744,"../bar/arrays_to_calcdata":836,"./average":965,"./bin_functions":967,"./bin_label_vals":968,"./norm_functions":975,"fast-isnumeric":214}],970:[function(t,e,r){"use strict";var n=t("../../lib"),i=n.nestedProperty,a=t("./attributes"),o={x:[{aStr:"xbins.start",name:"start"},{aStr:"xbins.end",name:"end"},{aStr:"xbins.size",name:"size"},{aStr:"nbinsx",name:"nbins"}],y:[{aStr:"ybins.start",name:"start"},{aStr:"ybins.end",name:"end"},{aStr:"ybins.size",name:"size"},{aStr:"nbinsy",name:"nbins"}]};e.exports=function(t,e){var r,s,l,c,u,f,h,p=e._histogramBinOpts={},d="overlay"===e.barmode;function g(t){return n.coerce(l._input,l,a,t)}for(r=0;rA&&v.splice(A,v.length-A),y.length>A&&y.splice(A,y.length-A),c(e,"x",v,g,_,k,x),c(e,"y",y,m,w,M,b);var T=[],S=[],E=[],C="string"==typeof e.xbins.size,L="string"==typeof e.ybins.size,z=[],O=[],I=C?z:e.xbins,P=L?O:e.ybins,D=0,R=[],B=[],F=e.histnorm,N=e.histfunc,j=-1!==F.indexOf("density"),V="max"===N||"min"===N?null:0,U=a.count,q=o[F],H=!1,G=[],W=[],Y="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";Y&&"count"!==N&&(H="avg"===N,U=a[N]);var X=e.xbins,Z=_(X.start),$=_(X.end)+(Z-i.tickIncrement(Z,X.size,!1,x))/1e6;for(r=Z;r<$;r=i.tickIncrement(r,X.size,!1,x))S.push(V),z.push(r),H&&E.push(0);z.push(r);var J=S.length,K=_(e.xbins.start),Q=(r-K)/J,tt=k(K+Q/2);for(Z=w((X=e.ybins).start),$=w(X.end)+(Z-i.tickIncrement(Z,X.size,!1,b))/1e6,r=Z;r<$;r=i.tickIncrement(r,X.size,!1,b)){T.push(S.slice()),O.push(r);var et=new Array(J);for(l=0;l=0&&p=0&&d0?Number(d):p;else if("string"!=typeof d)u.size=p;else{var g=d.charAt(0),v=d.substr(1);((v=n(v)?Number(v):0)<=0||"date"!==l||"M"!==g||v!==Math.round(v))&&(u.size=p)}}e.exports=function(t,e){var r,n,i,a;function u(t){return o.coerce(i._input,i,s,t)}for(r=0;r0)u=a(t.alphahull,f);else{var p=["x","y","z"].indexOf(t.delaunayaxis);u=i(f.map(function(t){return[t[(p+1)%3],t[(p+2)%3]]}))}var d={positions:f,cells:u,lightPosition:[t.lightposition.x,t.lightposition.y,t.lightposition.z],ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,vertexNormalsEpsilon:t.lighting.vertexnormalsepsilon,faceNormalsEpsilon:t.lighting.facenormalsepsilon,opacity:t.opacity,contourEnable:t.contour.show,contourColor:l(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",d.vertexIntensity=t.intensity,d.vertexIntensityBounds=[t.cmin,t.cmax],d.colormap=s(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolor[0],d.vertexColors=h(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],d.cellColors=h(t.facecolor)):(this.color=t.color,d.meshColor=l(t.color)),this.mesh.update(d)},f.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=function(t,e){var r=t.glplot.gl,i=n({gl:r}),a=new u(t,i,e.uid);return i._trace=a,a.update(e),t.glplot.add(i),a}},{"../../lib/gl_format_color":692,"../../lib/str2rgbarray":719,"../../plots/gl3d/zip3":798,"alpha-shape":52,"convex-hull":118,"delaunay-triangulate":150,"gl-mesh3d":268}],989:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}function c(t){var e=t.map(function(t){var e=l(t);return e&&i.isArrayOrTypedArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var u=c(["x","y","z"]),f=c(["i","j","k"]);u?(f&&f.forEach(function(t){for(var e=0;ed):p=_>y,d=_;var w=s(y,x,b,_);w.pos=m,w.yc=(y+_)/2,w.i=v,w.dir=p?"increasing":"decreasing",h&&(w.tx=e.text[v]),g.push(w)}}return e._extremes[n._id]=a.findExtremes(n,u.concat(c),{padded:!0}),g.length&&(g[0].t={labels:{open:i(t,"open:")+" ",high:i(t,"high:")+" ",low:i(t,"low:")+" ",close:i(t,"close:")+" "}}),g}e.exports={calc:function(t,e){var r=a.getFromId(t,e.xaxis),i=a.getFromId(t,e.yaxis),o=function(t,e,r){var i=r._minDiff;if(!i){var a,o=t._fullData,s=[];for(i=1/0,a=0;a"+u.labels[x]+n.hoverLabelText(s,b):((y=i.extendFlat({},h)).y0=y.y1=_,y.yLabelVal=b,y.yLabel=u.labels[x]+n.hoverLabelText(s,b),y.name="",f.push(y),v[b]=y)}return f}function f(t,e,r,i){var a=t.cd,o=t.ya,u=a[0].trace,f=a[0].t,h=c(t,e,r,i);if(!h)return[];var p=a[h.index],d=h.index=p.i,g=p.dir;function v(t){return f.labels[t]+n.hoverLabelText(o,u[t][d])}var m=p.hi||u.hoverinfo,y=m.split("+"),x="all"===m,b=x||-1!==y.indexOf("y"),_=x||-1!==y.indexOf("text"),w=b?[v("open"),v("high"),v("low"),v("close")+" "+l[g]]:[];return _&&s(p,u,w),h.extraText=w.join("
"),h.y0=h.y1=o.c2p(p.yc,!0),[h]}e.exports={hoverPoints:function(t,e,r,n){return t.cd[0].trace.hoverlabel.split?u(t,e,r,n):f(t,e,r,n)},hoverSplit:u,hoverOnPoints:f}},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051}],995:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"ohlc",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","showLegend"],meta:{},attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("./calc").calc,plot:t("./plot"),style:t("./style"),hoverPoints:t("./hover").hoverPoints,selectPoints:t("./select")}},{"../../plots/cartesian":756,"./attributes":991,"./calc":992,"./defaults":993,"./hover":994,"./plot":997,"./select":998,"./style":999}],996:[function(t,e,r){"use strict";var n=t("../../registry");e.exports=function(t,e,r,i){var a=r("x"),o=r("open"),s=r("high"),l=r("low"),c=r("close");if(r("hoverlabel.split"),n.getComponentMethod("calendars","handleTraceDefaults")(t,e,["x"],i),o&&s&&l&&c){var u=Math.min(o.length,s.length,l.length,c.length);return a&&(u=Math.min(u,a.length)),e._length=u,u}}},{"../../registry":827}],997:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib");e.exports=function(t,e,r,a){var o=e.xaxis,s=e.yaxis;i.makeTraceGroups(a,r,"trace ohlc").each(function(t){var r=n.select(this),a=t[0],l=a.t,c=a.trace;if(e.isRangePlot||(a.node3=r),!0!==c.visible||l.empty)r.remove();else{var u=l.tickLen,f=r.selectAll("path").data(i.identity);f.enter().append("path"),f.exit().remove(),f.attr("d",function(t){var e=o.c2p(t.pos,!0),r=o.c2p(t.pos-u,!0),n=o.c2p(t.pos+u,!0);return"M"+r+","+s.c2p(t.o,!0)+"H"+e+"M"+e+","+s.c2p(t.h,!0)+"V"+s.c2p(t.l,!0)+"M"+n+","+s.c2p(t.c,!0)+"H"+e})}})}},{"../../lib":696,d3:148}],998:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,i=t.xaxis,a=t.yaxis,o=[],s=n[0].t.bPos||0;if(!1===e)for(r=0;r=t.length)return!1;if(void 0!==e[t[r]])return!1;e[t[r]]=!0}return!0}(t.map(function(t){return t.displayindex})))for(e=0;e0;c&&(o="array");var u=r("categoryorder",o);"array"===u?(r("categoryarray"),r("ticktext")):(delete t.categoryarray,delete t.ticktext),c||"array"!==u||(e.categoryorder="trace")}}e.exports=function(t,e,r,f){function h(r,i){return n.coerce(t,e,l,r,i)}var p=s(t,e,{name:"dimensions",handleItemDefaults:u}),d=function(t,e,r,o,s){s("line.shape");var l=s("line.color",o.colorway[0]);if(i(t,"line")&&n.isArrayOrTypedArray(l)){if(l.length)return s("line.colorscale"),a(t,e,o,s,{prefix:"line.",cLetter:"c"}),l.length;e.line.color=r}return 1/0}(t,e,r,f,h);o(e,f,h),Array.isArray(p)&&p.length||(e.visible=!1),c(e,p,"values",d),h("hoveron"),h("arrangement"),h("bundlecolors"),h("sortpaths"),h("counts");var g={family:f.font.family,size:Math.round(f.font.size),color:f.font.color};n.coerceFont(h,"labelfont",g);var v={family:f.font.family,size:Math.round(f.font.size/1.2),color:f.font.color};n.coerceFont(h,"tickfont",v)}},{"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/domain":770,"../parcoords/merge_length":1015,"./attributes":1e3}],1004:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.colorbar={container:"line",min:"cmin",max:"cmax"},n.moduleType="trace",n.name="parcats",n.basePlotModule=t("./base_plot"),n.categories=["noOpacity"],n.meta={},e.exports=n},{"./attributes":1e3,"./base_plot":1001,"./calc":1002,"./defaults":1003,"./plot":1006}],1005:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plot_api/plot_api"),a=t("../../components/fx"),o=t("../../lib"),s=t("../../components/drawing"),l=t("tinycolor2"),c=t("../../lib/svg_text_utils");function u(t,e,r,i){var a=t.map(function(t,e,r){var n,i=r[0],a=e.margin||{l:80,r:80,t:100,b:80},o=i.trace,s=o.domain,l=e.width,c=e.height,u=Math.floor(l*(s.x[1]-s.x[0])),f=Math.floor(c*(s.y[1]-s.y[0])),h=s.x[0]*l+a.l,p=e.height-s.y[1]*e.height+a.t,d=o.line.shape;n="all"===o.hoverinfo?["count","probability"]:o.hoverinfo.split("+");var g={key:o.uid,model:i,x:h,y:p,width:u,height:f,hoveron:o.hoveron,hoverinfoItems:n,arrangement:o.arrangement,bundlecolors:o.bundlecolors,sortpaths:o.sortpaths,labelfont:o.labelfont,categorylabelfont:o.tickfont,pathShape:d,dragDimension:null,margin:a,paths:[],dimensions:[],graphDiv:t,traceSelection:null,pathSelection:null,dimensionSelection:null};i.dimensions&&(R(g),D(g));return g}.bind(0,e,r)),l=i.selectAll("g.parcatslayer").data([null]);l.enter().append("g").attr("class","parcatslayer").style("pointer-events","all");var u=l.selectAll("g.trace.parcats").data(a,f),v=u.enter().append("g").attr("class","trace parcats");u.attr("transform",function(t){return"translate("+t.x+", "+t.y+")"}),v.append("g").attr("class","paths");var x=u.select("g.paths").selectAll("path.path").data(function(t){return t.paths},f);x.attr("fill",function(t){return t.model.color});var w=x.enter().append("path").attr("class","path").attr("stroke-opacity",0).attr("fill",function(t){return t.model.color}).attr("fill-opacity",0);y(w),x.attr("d",function(t){return t.svgD}),w.empty()||x.sort(p),x.exit().remove(),x.on("mouseover",d).on("mouseout",g).on("click",m),v.append("g").attr("class","dimensions");var k=u.select("g.dimensions").selectAll("g.dimension").data(function(t){return t.dimensions},f);k.enter().append("g").attr("class","dimension"),k.attr("transform",function(t){return"translate("+t.x+", 0)"}),k.exit().remove();var M=k.selectAll("g.category").data(function(t){return t.categories},f),A=M.enter().append("g").attr("class","category");M.attr("transform",function(t){return"translate(0, "+t.y+")"}),A.append("rect").attr("class","catrect").attr("pointer-events","none"),M.select("rect.catrect").attr("fill","none").attr("width",function(t){return t.width}).attr("height",function(t){return t.height}),b(A);var z=M.selectAll("rect.bandrect").data(function(t){return t.bands},f);z.each(function(){o.raiseToTop(this)}),z.attr("fill",function(t){return t.color});var O=z.enter().append("rect").attr("class","bandrect").attr("stroke-opacity",0).attr("fill",function(t){return t.color}).attr("fill-opacity",0);z.attr("fill",function(t){return t.color}).attr("width",function(t){return t.width}).attr("height",function(t){return t.height}).attr("y",function(t){return t.y}).attr("cursor",function(t){return"fixed"===t.parcatsViewModel.arrangement?"default":"perpendicular"===t.parcatsViewModel.arrangement?"ns-resize":"move"}),_(O),z.exit().remove(),A.append("text").attr("class","catlabel").attr("pointer-events","none");var I=e._fullLayout.paper_bgcolor;M.select("text.catlabel").attr("text-anchor",function(t){return h(t)?"start":"end"}).attr("alignment-baseline","middle").style("text-shadow",I+" -1px 1px 2px, "+I+" 1px 1px 2px, "+I+" 1px -1px 2px, "+I+" -1px -1px 2px").style("fill","rgb(0, 0, 0)").attr("x",function(t){return h(t)?t.width+5:-5}).attr("y",function(t){return t.height/2}).text(function(t){return t.model.categoryLabel}).each(function(t){s.font(n.select(this),t.parcatsViewModel.categorylabelfont),c.convertToTspans(n.select(this),e)}),A.append("text").attr("class","dimlabel"),M.select("text.dimlabel").attr("text-anchor","middle").attr("alignment-baseline","baseline").attr("cursor",function(t){return"fixed"===t.parcatsViewModel.arrangement?"default":"ew-resize"}).attr("x",function(t){return t.width/2}).attr("y",-5).text(function(t,e){return 0===e?t.parcatsViewModel.model.dimensions[t.model.dimensionInd].dimensionLabel:null}).each(function(t){s.font(n.select(this),t.parcatsViewModel.labelfont)}),M.selectAll("rect.bandrect").on("mouseover",T).on("mouseout",S),M.exit().remove(),k.call(n.behavior.drag().origin(function(t){return{x:t.x,y:0}}).on("dragstart",E).on("drag",C).on("dragend",L)),u.each(function(t){t.traceSelection=n.select(this),t.pathSelection=n.select(this).selectAll("g.paths").selectAll("path.path"),t.dimensionSelection=n.select(this).selectAll("g.dimensions").selectAll("g.dimension")}),u.exit().remove()}function f(t){return t.key}function h(t){var e=t.parcatsViewModel.dimensions.length,r=t.parcatsViewModel.dimensions[e-1].model.dimensionInd;return t.model.dimensionInd===r}function p(t,e){return t.model.rawColor>e.model.rawColor?1:t.model.rawColor"),k=n.mouse(u)[0];a.loneHover({x:m-h.left+p.left,y:y-h.top+p.top,text:w,color:t.model.color,borderColor:"black",fontFamily:'Monaco, "Courier New", monospace',fontSize:10,fontColor:b,idealAlign:k1&&c.displayInd===l.dimensions.length-1?(r=o.left,i="left"):(r=o.left+o.width,i="right");var f=[];-1!==s.parcatsViewModel.hoverinfoItems.indexOf("count")&&f.push(["Count:",s.model.count].join(" ")),-1!==s.parcatsViewModel.hoverinfoItems.indexOf("probability")&&f.push(["P("+s.model.categoryLabel+"):",(s.model.count/s.parcatsViewModel.model.count).toFixed(3)].join(" "));var h=f.join("
");return{x:r-t.left,y:u-t.top,text:h,color:"lightgray",borderColor:"black",fontFamily:'Monaco, "Courier New", monospace',fontSize:12,fontColor:"black",idealAlign:i}}function T(t){if(!t.parcatsViewModel.dragDimension&&-1===t.parcatsViewModel.hoverinfoItems.indexOf("skip")){if(n.mouse(this)[1]<-1)return;var e,r=t.parcatsViewModel.graphDiv,i=r._fullLayout,s=i._paperdiv.node().getBoundingClientRect(),c=t.parcatsViewModel.hoveron;if("color"===c?(!function(t){var e=n.select(t).datum(),r=w(e);x(r),r.each(function(){o.raiseToTop(this)}),n.select(t.parentNode).selectAll("rect.bandrect").filter(function(t){return t.color===e.color}).each(function(){o.raiseToTop(this),n.select(this).attr("stroke","black").attr("stroke-width",1.5)})}(this),M(this,"plotly_hover",n.event)):(!function(t){n.select(t.parentNode).selectAll("rect.bandrect").each(function(t){var e=w(t);x(e),e.each(function(){o.raiseToTop(this)})}),n.select(t.parentNode).select("rect.catrect").attr("stroke","black").attr("stroke-width",2.5)}(this),k(this,"plotly_hover",n.event)),-1===t.parcatsViewModel.hoverinfoItems.indexOf("none"))"category"===c?e=A(s,this):"color"===c?e=function(t,e){var r,i,a=e.getBoundingClientRect(),o=n.select(e).datum(),s=o.categoryViewModel,c=s.parcatsViewModel,u=c.model.dimensions[s.model.dimensionInd],f=a.y+a.height/2;c.dimensions.length>1&&u.displayInd===c.dimensions.length-1?(r=a.left,i="left"):(r=a.left+a.width,i="right");var h=s.model.categoryLabel,p=o.parcatsViewModel.model.count,d=0;o.categoryViewModel.bands.forEach(function(t){t.color===o.color&&(d+=t.count)});var g=s.model.count,v=0;c.pathSelection.each(function(t){t.model.color===o.color&&(v+=t.model.count)});var m=[];if(-1!==s.parcatsViewModel.hoverinfoItems.indexOf("count")&&m.push(["Count:",d].join(" ")),-1!==s.parcatsViewModel.hoverinfoItems.indexOf("probability")){var y="P(color \u2229 "+h+"): "+(d/p).toFixed(3);m.push(y);var x="P("+h+" | color): "+(d/v).toFixed(3);m.push(x);var b="P(color | "+h+"): "+(d/g).toFixed(3);m.push(b)}var _=m.join("
"),w=l.mostReadable(o.color,["black","white"]);return{x:r-t.left,y:f-t.top,text:_,color:o.color,borderColor:"black",fontFamily:'Monaco, "Courier New", monospace',fontColor:w,fontSize:10,idealAlign:i}}(s,this):"dimension"===c&&(e=function(t,e){var r=[];return n.select(e.parentNode.parentNode).selectAll("g.category").select("rect.catrect").each(function(){r.push(A(t,this))}),r}(s,this)),e&&a.multiHovers(e,{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:r})}}function S(t){var e=t.parcatsViewModel;if(!e.dragDimension&&(y(e.pathSelection),b(e.dimensionSelection.selectAll("g.category")),_(e.dimensionSelection.selectAll("g.category").selectAll("rect.bandrect")),a.loneUnhover(e.graphDiv._fullLayout._hoverlayer.node()),e.pathSelection.sort(p),-1===e.hoverinfoItems.indexOf("skip"))){"color"===t.parcatsViewModel.hoveron?M(this,"plotly_unhover",n.event):k(this,"plotly_unhover",n.event)}}function E(t){"fixed"!==t.parcatsViewModel.arrangement&&(t.dragDimensionDisplayInd=t.model.displayInd,t.initialDragDimensionDisplayInds=t.parcatsViewModel.model.dimensions.map(function(t){return t.displayInd}),t.dragHasMoved=!1,t.dragCategoryDisplayInd=null,n.select(this).selectAll("g.category").select("rect.catrect").each(function(e){var r=n.mouse(this)[0],i=n.mouse(this)[1];-2<=r&&r<=e.width+2&&-2<=i&&i<=e.height+2&&(t.dragCategoryDisplayInd=e.model.displayInd,t.initialDragCategoryDisplayInds=t.model.categories.map(function(t){return t.displayInd}),e.model.dragY=e.y,o.raiseToTop(this.parentNode),n.select(this.parentNode).selectAll("rect.bandrect").each(function(e){e.yf.y+f.height/2&&(o.model.displayInd=f.model.displayInd,f.model.displayInd=l),t.dragCategoryDisplayInd=o.model.displayInd}if(null===t.dragCategoryDisplayInd||"freeform"===t.parcatsViewModel.arrangement){a.model.dragX=n.event.x;var h=t.parcatsViewModel.dimensions[r],p=t.parcatsViewModel.dimensions[i];void 0!==h&&a.model.dragXp.x&&(a.model.displayInd=p.model.displayInd,p.model.displayInd=t.dragDimensionDisplayInd),t.dragDimensionDisplayInd=a.model.displayInd}R(t.parcatsViewModel),D(t.parcatsViewModel),I(t.parcatsViewModel),O(t.parcatsViewModel)}}function L(t){if("fixed"!==t.parcatsViewModel.arrangement&&null!==t.dragDimensionDisplayInd){n.select(this).selectAll("text").attr("font-weight","normal");var e={},r=z(t.parcatsViewModel),a=t.parcatsViewModel.model.dimensions.map(function(t){return t.displayInd}),o=t.initialDragDimensionDisplayInds.some(function(t,e){return t!==a[e]});o&&a.forEach(function(r,n){var i=t.parcatsViewModel.model.dimensions[n].containerInd;e["dimensions["+i+"].displayindex"]=r});var s=!1;if(null!==t.dragCategoryDisplayInd){var l=t.model.categories.map(function(t){return t.displayInd});if(s=t.initialDragCategoryDisplayInds.some(function(t,e){return t!==l[e]})){var c=t.model.categories.slice().sort(function(t,e){return t.displayInd-e.displayInd}),u=c.map(function(t){return t.categoryValue}),f=c.map(function(t){return t.categoryLabel});e["dimensions["+t.model.containerInd+"].categoryarray"]=[u],e["dimensions["+t.model.containerInd+"].ticktext"]=[f],e["dimensions["+t.model.containerInd+"].categoryorder"]="array"}}if(-1===t.parcatsViewModel.hoverinfoItems.indexOf("skip")&&!t.dragHasMoved&&t.potentialClickBand&&("color"===t.parcatsViewModel.hoveron?M(t.potentialClickBand,"plotly_click",n.event.sourceEvent):k(t.potentialClickBand,"plotly_click",n.event.sourceEvent)),t.model.dragX=null,null!==t.dragCategoryDisplayInd)t.parcatsViewModel.dimensions[t.dragDimensionDisplayInd].categories[t.dragCategoryDisplayInd].model.dragY=null,t.dragCategoryDisplayInd=null;t.dragDimensionDisplayInd=null,t.parcatsViewModel.dragDimension=null,t.dragHasMoved=null,t.potentialClickBand=null,R(t.parcatsViewModel),D(t.parcatsViewModel),n.transition().duration(300).ease("cubic-in-out").each(function(){I(t.parcatsViewModel,!0),O(t.parcatsViewModel,!0)}).each("end",function(){(o||s)&&i.restyle(t.parcatsViewModel.graphDiv,e,[r])})}}function z(t){for(var e,r=t.graphDiv._fullData,n=0;n=0;s--)u+="C"+c[s]+","+(e[s+1]+i)+" "+l[s]+","+(e[s]+i)+" "+(t[s]+r[s])+","+(e[s]+i),u+="l-"+r[s]+",0 ";return u+="Z"}function D(t){var e=t.dimensions,r=t.model,n=e.map(function(t){return t.categories.map(function(t){return t.y})}),i=t.model.dimensions.map(function(t){return t.categories.map(function(t){return t.displayInd})}),a=t.model.dimensions.map(function(t){return t.displayInd}),o=t.dimensions.map(function(t){return t.model.dimensionInd}),s=e.map(function(t){return t.x}),l=e.map(function(t){return t.width}),c=[];for(var u in r.paths)r.paths.hasOwnProperty(u)&&c.push(r.paths[u]);function f(t){var e=t.categoryInds.map(function(t,e){return i[e][t]});return o.map(function(t){return e[t]})}c.sort(function(e,r){var n=f(e),i=f(r);return"backward"===t.sortpaths&&(n.reverse(),i.reverse()),n.push(e.valueInds[0]),i.push(r.valueInds[0]),t.bundlecolors&&(n.unshift(e.rawColor),i.unshift(r.rawColor)),ni?1:0});for(var h=new Array(c.length),p=e[0].model.count,d=e[0].categories.map(function(t){return t.height}).reduce(function(t,e){return t+e}),g=0;g0?d*(m.count/p):0;for(var y,x=new Array(n.length),b=0;b1?(t.width-80-16)/(n-1):0)*i;var a,o,s,l,c,u=[],f=t.model.maxCats,h=e.categories.length,p=e.count,d=t.height-8*(f-1),g=8*(f-h)/2,v=e.categories.map(function(t){return{displayInd:t.displayInd,categoryInd:t.categoryInd}});for(v.sort(function(t,e){return t.displayInd-e.displayInd}),c=0;c0?o.count/p*d:0,s={key:o.valueInds[0],model:o,width:16,height:a,y:null!==o.dragY?o.dragY:g,bands:[],parcatsViewModel:t},g=g+a+8,u.push(s);return{key:e.dimensionInd,x:null!==e.dragX?e.dragX:r,y:0,width:16,model:e,categories:u,parcatsViewModel:t,dragCategoryDisplayInd:null,dragDimensionDisplayInd:null,initialDragDimensionDisplayInds:null,initialDragCategoryDisplayInds:null,dragHasMoved:null,potentialClickBand:null}}e.exports=function(t,e,r,n){u(r,t,n,e)}},{"../../components/drawing":595,"../../components/fx":612,"../../lib":696,"../../lib/svg_text_utils":720,"../../plot_api/plot_api":731,d3:148,tinycolor2:514}],1006:[function(t,e,r){"use strict";var n=t("./parcats");e.exports=function(t,e,r,i){var a=t._fullLayout,o=a._paper,s=a._size;n(t,o,e,{width:s.w,height:s.h,margin:{t:s.t,r:s.r,b:s.b,l:s.l}},r,i)}},{"./parcats":1005}],1007:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),a=t("../../plots/cartesian/layout_attributes"),o=t("../../plots/font_attributes"),s=t("../../plots/domain").attributes,l=t("../../lib/extend").extendFlat,c=t("../../plot_api/plot_template").templatedArray;e.exports={domain:s({name:"parcoords",trace:!0,editType:"calc"}),hoverlabel:void 0,labelfont:o({editType:"calc"}),tickfont:o({editType:"calc"}),rangefont:o({editType:"calc"}),dimensions:c("dimension",{label:{valType:"string",editType:"calc"},tickvals:l({},a.tickvals,{editType:"calc"}),ticktext:l({},a.ticktext,{editType:"calc"}),tickformat:{valType:"string",dflt:"3s",editType:"calc"},visible:{valType:"boolean",dflt:!0,editType:"calc"},range:{valType:"info_array",items:[{valType:"number",editType:"calc"},{valType:"number",editType:"calc"}],editType:"calc"},constraintrange:{valType:"info_array",freeLength:!0,dimensions:"1-2",items:[{valType:"number",editType:"calc"},{valType:"number",editType:"calc"}],editType:"calc"},multiselect:{valType:"boolean",dflt:!0,editType:"calc"},values:{valType:"data_array",editType:"calc"},editType:"calc"}),line:l(n("line",{colorscaleDflt:"Viridis",autoColorDflt:!1,editTypeOverride:"calc"}),{colorbar:i,editType:"calc"})}},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/plot_template":734,"../../plots/cartesian/layout_attributes":757,"../../plots/domain":770,"../../plots/font_attributes":771}],1008:[function(t,e,r){"use strict";var n=t("./constants"),i=t("d3"),a=t("../../lib/gup").keyFun,o=t("../../lib/gup").repeat,s=t("../../lib").sorterAsc,l=n.bar.snapRatio;function c(t,e){return t*(1-l)+e*l}var u=n.bar.snapClose;function f(t,e){return t*(1-u)+e*u}function h(t,e,r){if(d(e,r))return e;for(var n=t[0],i=n,a=1;a=0;a--){var o=t[a];if(e>f(n,o))return c(n,i);if(e>o||a===t.length-1)return c(o,n);i=n,n=o}}function d(t,e){for(var r=0;r=e[r][0]&&t<=e[r][1])return!0;return!1}function g(t){t.attr("x",-n.bar.captureWidth/2).attr("width",n.bar.captureWidth)}function v(t){t.attr("visibility","visible").style("visibility","visible").attr("fill","yellow").attr("opacity",0)}function m(t){if(!t.brush.filterSpecified)return"0,"+t.height;for(var e,r,n,i=y(t.brush.filter.getConsolidated(),t.height),a=[0],o=i.length?i[0][0]:null,s=0;se){h=r;break}}if(a=u,isNaN(a)&&(a=isNaN(f)||isNaN(h)?isNaN(f)?h:f:e-c[f][1]t[1]+r||e=.9*t[1]+.1*t[0]?"n":e<=.9*t[0]+.1*t[1]?"s":"ns"}(d,e);g&&(o.interval=l[a],o.intervalPix=d,o.region=g)}}if(t.ordinal&&!o.region){var v=t.unitTickvals,m=t.unitToPaddedPx.invert(e);for(r=0;r=x[0]&&m<=x[1]){o.clickableOrdinalRange=x;break}}}return o}function k(t){t.on("mousemove",function(t){if(i.event.preventDefault(),!t.parent.inBrushDrag){var e=w(t,t.height-i.mouse(this)[1]-2*n.verticalPadding),r="crosshair";e.clickableOrdinalRange?r="pointer":e.region&&(r=e.region+"-resize"),i.select(document.body).style("cursor",r)}}).on("mouseleave",function(t){t.parent.inBrushDrag||x()}).call(i.behavior.drag().on("dragstart",function(t){i.event.sourceEvent.stopPropagation();var e=t.height-i.mouse(this)[1]-2*n.verticalPadding,r=t.unitToPaddedPx.invert(e),a=t.brush,o=w(t,e),s=o.interval,l=a.svgBrush;if(l.wasDragged=!1,l.grabbingBar="ns"===o.region,l.grabbingBar){var c=s.map(t.unitToPaddedPx);l.grabPoint=e-c[0]-n.verticalPadding,l.barLength=c[1]-c[0]}l.clickableOrdinalRange=o.clickableOrdinalRange,l.stayingIntervals=t.multiselect&&a.filterSpecified?a.filter.getConsolidated():[],s&&(l.stayingIntervals=l.stayingIntervals.filter(function(t){return t[0]!==s[0]&&t[1]!==s[1]})),l.startExtent=o.region?s["s"===o.region?1:0]:r,t.parent.inBrushDrag=!0,l.brushStartCallback()}).on("drag",function(t){i.event.sourceEvent.stopPropagation();var e=t.height-i.mouse(this)[1]-2*n.verticalPadding,r=t.brush.svgBrush;r.wasDragged=!0,r.grabbingBar?r.newExtent=[e-r.grabPoint,e+r.barLength-r.grabPoint].map(t.unitToPaddedPx.invert):r.newExtent=[r.startExtent,t.unitToPaddedPx.invert(e)].sort(s);var a=Math.max(0,-r.newExtent[0]),o=Math.max(0,r.newExtent[1]-1);r.newExtent[0]+=a,r.newExtent[1]-=o,r.grabbingBar&&(r.newExtent[1]+=a,r.newExtent[0]-=o),t.brush.filterSpecified=!0,r.extent=r.stayingIntervals.concat([r.newExtent]),r.brushCallback(t),_(this.parentNode)}).on("dragend",function(t){i.event.sourceEvent.stopPropagation();var e=t.brush,r=e.filter,n=e.svgBrush,a=n.grabbingBar;if(n.grabbingBar=!1,n.grabLocation=void 0,t.parent.inBrushDrag=!1,x(),!n.wasDragged)return n.wasDragged=void 0,n.clickableOrdinalRange?e.filterSpecified&&t.multiselect?n.extent.push(n.clickableOrdinalRange):(n.extent=[n.clickableOrdinalRange],e.filterSpecified=!0):a?(n.extent=n.stayingIntervals,0===n.extent.length&&A(e)):A(e),n.brushCallback(t),_(this.parentNode),void n.brushEndCallback(e.filterSpecified?r.getConsolidated():[]);var o=function(){r.set(r.getConsolidated())};if(t.ordinal){var s=t.unitTickvals;s[s.length-1]n.newExtent[0];n.extent=n.stayingIntervals.concat(l?[n.newExtent]:[]),n.extent.length||A(e),n.brushCallback(t),l?_(this.parentNode,o):(o(),_(this.parentNode))}else o();n.brushEndCallback(e.filterSpecified?r.getConsolidated():[])}))}function M(t,e){return t[0]-e[0]}function A(t){t.filterSpecified=!1,t.svgBrush.extent=[[0,1]]}function T(t){for(var e,r=t.slice(),n=[],i=r.shift();i;){for(e=i.slice();(i=r.shift())&&i[0]<=e[1];)e[1]=Math.max(e[1],i[1]);n.push(e)}return n}e.exports={makeBrush:function(t,e,r,n,i,a){var o,l=function(){var t,e,r=[];return{set:function(n){r=n.map(function(t){return t.slice().sort(s)}).sort(M),t=T(r),e=r.reduce(function(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1])]},[1/0,-1/0])},get:function(){return r.slice()},getConsolidated:function(){return t},getBounds:function(){return e}}}();return l.set(r),{filter:l,filterSpecified:e,svgBrush:{extent:[],brushStartCallback:n,brushCallback:(o=i,function(t){var e=t.brush,r=function(t){return t.svgBrush.extent.map(function(t){return t.slice()})}(e).slice();e.filter.set(r),o()}),brushEndCallback:a}}},ensureAxisBrush:function(t){var e=t.selectAll("."+n.cn.axisBrush).data(o,a);e.enter().append("g").classed(n.cn.axisBrush,!0),function(t){var e=t.selectAll(".background").data(o);e.enter().append("rect").classed("background",!0).call(g).call(v).style("pointer-events","auto").attr("transform","translate(0 "+n.verticalPadding+")"),e.call(k).attr("height",function(t){return t.height-n.verticalPadding});var r=t.selectAll(".highlight-shadow").data(o);r.enter().append("line").classed("highlight-shadow",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width+n.bar.strokeWidth).attr("stroke",n.bar.strokeColor).attr("opacity",n.bar.strokeOpacity).attr("stroke-linecap","butt"),r.attr("y1",function(t){return t.height}).call(b);var i=t.selectAll(".highlight").data(o);i.enter().append("line").classed("highlight",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width-n.bar.strokeWidth).attr("stroke",n.bar.fillColor).attr("opacity",n.bar.fillOpacity).attr("stroke-linecap","butt"),i.attr("y1",function(t){return t.height}).call(b)}(e)},cleanRanges:function(t,e){if(Array.isArray(t[0])?(t=t.map(function(t){return t.sort(s)}),t=e.multiselect?T(t.sort(M)):[t[0]]):t=[t.sort(s)],e.tickvals){var r=e.tickvals.slice().sort(s);if(!(t=t.map(function(t){var e=[h(r,t[0],[]),p(r,t[1],[])];if(e[1]>e[0])return e}).filter(function(t){return t})).length)return}return t.length>1?t:t[0]}}},{"../../lib":696,"../../lib/gup":693,"./constants":1011,d3:148}],1009:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plots/get_data").getModuleCalcData,a=t("./plot"),o=t("../../constants/xmlns_namespaces");r.name="parcoords",r.plot=function(t){var e=i(t.calcdata,"parcoords")[0];e.length&&a(t,e)},r.clean=function(t,e,r,n){var i=n._has&&n._has("parcoords"),a=e._has&&e._has("parcoords");i&&!a&&(n._paperdiv.selectAll(".parcoords").remove(),n._glimages.selectAll("*").remove())},r.toSVG=function(t){var e=t._fullLayout._glimages,r=n.select(t).selectAll(".svg-container");r.filter(function(t,e){return e===r.size()-1}).selectAll(".gl-canvas-context, .gl-canvas-focus").each(function(){var t=this.toDataURL("image/png");e.append("svg:image").attr({xmlns:o.svg,"xlink:href":t,preserveAspectRatio:"none",x:0,y:0,width:this.width,height:this.height})}),window.setTimeout(function(){n.selectAll("#filterBarPattern").attr("id","filterBarPattern")},60)}},{"../../constants/xmlns_namespaces":674,"../../plots/get_data":781,"./plot":1017,d3:148}],1010:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("../../lib"),o=t("../../lib/gup").wrap;e.exports=function(t,e){var r=!!e.line.colorscale&&a.isArrayOrTypedArray(e.line.color),s=r?e.line.color:function(t){for(var e=new Array(t),r=0;ru&&(n.log("parcoords traces support up to "+u+" dimensions at the moment"),d.splice(u));var g=s(t,e,{name:"dimensions",handleItemDefaults:h}),v=function(t,e,r,o,s){var l=s("line.color",r);if(i(t,"line")&&n.isArrayOrTypedArray(l)){if(l.length)return s("line.colorscale"),a(t,e,o,s,{prefix:"line.",cLetter:"c"}),l.length;e.line.color=r}return 1/0}(t,e,r,c,p);o(e,c,p),Array.isArray(g)&&g.length||(e.visible=!1),f(e,g,"values",v);var m={family:c.font.family,size:Math.round(c.font.size/1.2),color:c.font.color};n.coerceFont(p,"labelfont",m),n.coerceFont(p,"tickfont",m),n.coerceFont(p,"rangefont",m)}},{"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"../../lib":696,"../../plots/array_container_defaults":740,"../../plots/domain":770,"./attributes":1007,"./axisbrush":1008,"./constants":1011,"./merge_length":1015}],1013:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.colorbar={container:"line",min:"cmin",max:"cmax"},n.moduleType="trace",n.name="parcoords",n.basePlotModule=t("./base_plot"),n.categories=["gl","regl","noOpacity"],n.meta={},e.exports=n},{"./attributes":1007,"./base_plot":1009,"./calc":1010,"./defaults":1012,"./plot":1017}],1014:[function(t,e,r){"use strict";var n=t("glslify"),i=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\nuniform sampler2D mask;\nuniform float maskHeight;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec4 unit_1 = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit_1, unit_1);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nconst int bitsPerByte = 8;\n\nint mod2(int a) {\n return a - 2 * (a / 2);\n}\n\nint mod8(int a) {\n return a - 8 * (a / 8);\n}\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit_0 = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nbool withinBoundingBox(\n mat4 d[4],\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD\n ) {\n\n return mshow(d[0], loA, hiA) &&\n mshow(d[1], loB, hiB) &&\n mshow(d[2], loC, hiC) &&\n mshow(d[3], loD, hiD);\n}\n\nbool withinRasterMask(mat4 d[4], sampler2D mask, float height) {\n bool result = true;\n int bitInByteStepper;\n float valY, valueY, scaleX;\n int hit, bitmask, valX;\n for(int i = 0; i < 4; i++) {\n for(int j = 0; j < 4; j++) {\n for(int k = 0; k < 4; k++) {\n bitInByteStepper = mod8(j * 4 + k);\n valX = i * 2 + j / 2;\n valY = d[i][j][k];\n valueY = valY * (height - 1.0) + 0.5;\n scaleX = (float(valX) + 0.5) / 8.0;\n hit = int(texture2D(mask, vec2(scaleX, (valueY + 0.5) / height))[3] * 255.0) / int(pow(2.0, float(bitInByteStepper)));\n result = result && mod2(hit) == 1;\n }\n }\n }\n return result;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D,\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD,\n sampler2D mask, float maskHeight\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n float show = float(\n withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD)\n && withinRasterMask(dims, mask, maskHeight)\n );\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD,\n mask, maskHeight\n );\n\n float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);\n fragColor = texture2D(palette, vec2((clampedColorIndex * 255.0 + 0.5) / 256.0, 0.5));\n}\n"]),a=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec2 xyProjection = vec2(1, 1);\n\nvec4 unit = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit, unit);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depth,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D\n );\n\n float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);\n fragColor = texture2D(palette, vec2((clampedColorIndex * 255.0 + 0.5) / 256.0, 0.5));\n}\n"]),o=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D mask;\nuniform float maskHeight;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec4 unit_1 = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit_1, unit_1);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nconst int bitsPerByte = 8;\n\nint mod2(int a) {\n return a - 2 * (a / 2);\n}\n\nint mod8(int a) {\n return a - 8 * (a / 8);\n}\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit_0 = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nbool withinBoundingBox(\n mat4 d[4],\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD\n ) {\n\n return mshow(d[0], loA, hiA) &&\n mshow(d[1], loB, hiB) &&\n mshow(d[2], loC, hiC) &&\n mshow(d[3], loD, hiD);\n}\n\nbool withinRasterMask(mat4 d[4], sampler2D mask, float height) {\n bool result = true;\n int bitInByteStepper;\n float valY, valueY, scaleX;\n int hit, bitmask, valX;\n for(int i = 0; i < 4; i++) {\n for(int j = 0; j < 4; j++) {\n for(int k = 0; k < 4; k++) {\n bitInByteStepper = mod8(j * 4 + k);\n valX = i * 2 + j / 2;\n valY = d[i][j][k];\n valueY = valY * (height - 1.0) + 0.5;\n scaleX = (float(valX) + 0.5) / 8.0;\n hit = int(texture2D(mask, vec2(scaleX, (valueY + 0.5) / height))[3] * 255.0) / int(pow(2.0, float(bitInByteStepper)));\n result = result && mod2(hit) == 1;\n }\n }\n }\n return result;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D,\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD,\n sampler2D mask, float maskHeight\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n float show = float(\n withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD)\n && withinRasterMask(dims, mask, maskHeight)\n );\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD,\n mask, maskHeight\n );\n\n fragColor = vec4(pf.rgb, 1.0);\n}\n"]),s=n(["precision lowp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}\n"]),l=t("../../lib"),c=1e-6,u=1e-7,f=2048,h=64,p=2,d=4,g=8,v=h/g,m=[119,119,119],y=new Uint8Array(4),x=new Uint8Array(4),b={shape:[256,1],format:"rgba",type:"uint8",mag:"nearest",min:"nearest"};function _(t,e,r,n,i){var a=t._gl;a.enable(a.SCISSOR_TEST),a.scissor(e,r,n,i),t.clear({color:[0,0,0,0],depth:1})}function w(t,e,r,n,i,a){var o=a.key;r.drawCompleted||(!function(t){t.read({x:0,y:0,width:1,height:1,data:y})}(t),r.drawCompleted=!0),function s(l){var c;c=Math.min(n,i-l*n),a.offset=p*l*n,a.count=p*c,0===l&&(window.cancelAnimationFrame(r.currentRafs[o]),delete r.currentRafs[o],_(t,a.scissorX,a.scissorY,a.scissorWidth,a.viewBoxSize[1])),r.clearOnly||(e(a),l*n+c>>8*e)%256/255}function M(t,e,r){var n,i,a,o=[];for(i=0;i=h-4?k(o,h-2-s):.5);return a}(d,p,i);!function(t,e,r){for(var n=0;n<16;n++)t["p"+n.toString(16)](M(e,r,n))}(C,d,o),L=S.texture(l.extendFlat({data:function(t,e,r){for(var n=[],i=0;i<256;i++){var a=t(i/255);n.push((e?m:a).concat(r))}return n}(r.unitToColor,A,Math.round(255*(A?a:1)))},b))}var I=[0,1];var P=[];function D(t,e,n,i,a,o,s,c,u,f,h){var p,d,g,v,m=[t,e],y=[0,1].map(function(){return[0,1,2,3].map(function(){return new Float32Array(16)})});for(p=0;p<2;p++)for(v=m[p],d=0;d<4;d++)for(g=0;g<16;g++)y[p][d][g]=g+16*d===v?1:0;var x=r.lines.canvasOverdrag,b=r.domain,_=r.canvasWidth,w=r.canvasHeight;return l.extendFlat({key:s,resolution:[_,w],viewBoxPosition:[n+x,i],viewBoxSize:[a,o],i:t,ii:e,dim1A:y[0][0],dim1B:y[0][1],dim1C:y[0][2],dim1D:y[0][3],dim2A:y[1][0],dim2B:y[1][1],dim2C:y[1][2],dim2D:y[1][3],colorClamp:I,scissorX:(c===u?0:n+x)+(r.pad.l-x)+r.layoutWidth*b.x[0],scissorWidth:(c===f?_-n+x:a+.5)+(c===u?n+x:0),scissorY:i+r.pad.b+r.layoutHeight*b.y[0],scissorHeight:o,viewportX:r.pad.l-x+r.layoutWidth*b.x[0],viewportY:r.pad.b+r.layoutHeight*b.y[0],viewportWidth:_,viewportHeight:w},h)}return{setColorDomain:function(t){I[0]=t[0],I[1]=t[1]},render:function(t,e,n){var i,a,o,s=t.length,l=1/0,c=-1/0;for(i=0;ic&&(c=t[i].dim2.canvasX,o=i),t[i].dim1.canvasXn._length&&(M=M.slice(0,n._length));var A,T=n.tickvals;function S(t,e){return{val:t,text:A[e]}}function E(t,e){return t.val-e.val}if(Array.isArray(T)&&T.length){A=n.ticktext,Array.isArray(A)&&A.length?A.length>T.length?A=A.slice(0,T.length):T.length>A.length&&(T=T.slice(0,A.length)):A=T.map(o.format(n.tickformat));for(var C=1;C=r||s>=n)return;var l=t.lineLayer.readPixel(a,n-1-s),c=0!==l[3],u=c?l[2]+256*(l[1]+256*l[0]):null,f={x:a,y:s,clientX:e.clientX,clientY:e.clientY,dataIndex:t.model.key,curveNumber:u};u!==M&&(c?d.hover(f):d.unhover&&d.unhover(f),M=u)}}),k.style("opacity",function(t){return t.pick?.01:1}),e.style("background","rgba(255, 255, 255, 0)");var A=e.selectAll("."+i.cn.parcoords).data(w,c);A.exit().remove(),A.enter().append("g").classed(i.cn.parcoords,!0).style("shape-rendering","crispEdges").style("pointer-events","none"),A.attr("transform",function(t){return"translate("+t.model.translateX+","+t.model.translateY+")"});var T=A.selectAll("."+i.cn.parcoordsControlView).data(u,c);T.enter().append("g").classed(i.cn.parcoordsControlView,!0),T.attr("transform",function(t){return"translate("+t.model.pad.l+","+t.model.pad.t+")"});var S=T.selectAll("."+i.cn.yAxis).data(function(t){return t.dimensions},c);function E(t,e){for(var r=e.panels||(e.panels=[]),n=t.data(),i=n.length-1,a=0;aline").attr("fill","none").attr("stroke","black").attr("stroke-opacity",.25).attr("stroke-width","1px"),L.selectAll("text").style("text-shadow","1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff").style("cursor","default").style("user-select","none");var z=C.selectAll("."+i.cn.axisHeading).data(u,c);z.enter().append("g").classed(i.cn.axisHeading,!0);var O=z.selectAll("."+i.cn.axisTitle).data(u,c);O.enter().append("text").classed(i.cn.axisTitle,!0).attr("text-anchor","middle").style("cursor","ew-resize").style("user-select","none").style("pointer-events","auto"),O.attr("transform","translate(0,"+-i.axisTitleOffset+")").text(function(t){return t.label}).each(function(t){s.font(o.select(this),t.model.labelFont)});var I=C.selectAll("."+i.cn.axisExtent).data(u,c);I.enter().append("g").classed(i.cn.axisExtent,!0);var P=I.selectAll("."+i.cn.axisExtentTop).data(u,c);P.enter().append("g").classed(i.cn.axisExtentTop,!0),P.attr("transform","translate(0,"+-i.axisExtentOffset+")");var D=P.selectAll("."+i.cn.axisExtentTopText).data(u,c);function R(t,e){if(t.ordinal)return"";var r=t.domainScale.domain();return o.format(t.tickFormat)(r[e?r.length-1:0])}D.enter().append("text").classed(i.cn.axisExtentTopText,!0).call(y),D.text(function(t){return R(t,!0)}).each(function(t){s.font(o.select(this),t.model.rangeFont)});var B=I.selectAll("."+i.cn.axisExtentBottom).data(u,c);B.enter().append("g").classed(i.cn.axisExtentBottom,!0),B.attr("transform",function(t){return"translate(0,"+(t.model.height+i.axisExtentOffset)+")"});var F=B.selectAll("."+i.cn.axisExtentBottomText).data(u,c);F.enter().append("text").classed(i.cn.axisExtentBottomText,!0).attr("dy","0.75em").call(y),F.text(function(t){return R(t)}).each(function(t){s.font(o.select(this),t.model.rangeFont)}),h.ensureAxisBrush(C)}},{"../../components/drawing":595,"../../lib":696,"../../lib/gup":693,"./axisbrush":1008,"./constants":1011,"./lines":1014,d3:148}],1017:[function(t,e,r){"use strict";var n=t("./parcoords"),i=t("../../lib/prepare_regl");e.exports=function(t,e){var r=t._fullLayout,a=r._toppaper,o=r._paperdiv,s=r._glcontainer;if(i(t)){var l={},c={},u=r._size;e.forEach(function(e,r){l[r]=t.data[r].dimensions,c[r]=t.data[r].dimensions.slice()});n(o,a,s,e,{width:u.w,height:u.h,margin:{t:u.t,r:u.r,b:u.b,l:u.l}},{filterChanged:function(e,r,n){var i=c[e][r],a=n.map(function(t){return t.slice()});a.length?(1===a.length&&(a=a[0]),i.constraintrange=a,a=[a]):(delete i.constraintrange,a=null);var o={};o["dimensions["+r+"].constraintrange"]=a,t.emit("plotly_restyle",[o,[e]])},hover:function(e){t.emit("plotly_hover",e)},unhover:function(e){t.emit("plotly_unhover",e)},axesMoved:function(e,r){function n(t){return!("visible"in t)||t.visible}function i(t,e,r){var n=e.indexOf(r),i=t.indexOf(n);return-1===i&&(i+=e.length),i}var a=function(t){return function(e,n){return i(r,t,e)-i(r,t,n)}}(c[e].filter(n));l[e].sort(a),c[e].filter(function(t){return!n(t)}).sort(function(t){return c[e].indexOf(t)}).forEach(function(t){l[e].splice(l[e].indexOf(t),1),l[e].splice(c[e].indexOf(t),0,t)}),t.emit("plotly_restyle")}})}}},{"../../lib/prepare_regl":709,"./parcoords":1016}],1018:[function(t,e,r){"use strict";var n=t("../../components/color/attributes"),i=t("../../plots/font_attributes"),a=t("../../plots/attributes"),o=t("../../plots/domain").attributes,s=t("../../lib/extend").extendFlat,l=i({editType:"calc",arrayOk:!0,colorEditType:"plot"});e.exports={labels:{valType:"data_array",editType:"calc"},label0:{valType:"number",dflt:0,editType:"calc"},dlabel:{valType:"number",dflt:1,editType:"calc"},values:{valType:"data_array",editType:"calc"},marker:{colors:{valType:"data_array",editType:"calc"},line:{color:{valType:"color",dflt:n.defaultLine,arrayOk:!0,editType:"style"},width:{valType:"number",min:0,dflt:0,arrayOk:!0,editType:"style"},editType:"calc"},editType:"calc"},text:{valType:"data_array",editType:"calc"},hovertext:{valType:"string",dflt:"",arrayOk:!0,editType:"style"},scalegroup:{valType:"string",dflt:"",editType:"calc"},textinfo:{valType:"flaglist",flags:["label","text","value","percent"],extras:["none"],editType:"calc"},hoverinfo:s({},a.hoverinfo,{flags:["label","text","value","percent","name"]}),textposition:{valType:"enumerated",values:["inside","outside","auto","none"],dflt:"auto",arrayOk:!0,editType:"calc"},textfont:s({},l,{}),insidetextfont:s({},l,{}),outsidetextfont:s({},l,{}),title:{valType:"string",dflt:"",editType:"calc"},titleposition:{valType:"enumerated",values:["top left","top center","top right","middle center","bottom left","bottom center","bottom right"],editType:"calc"},titlefont:s({},l,{}),domain:o({name:"pie",trace:!0,editType:"calc"}),hole:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},sort:{valType:"boolean",dflt:!0,editType:"calc"},direction:{valType:"enumerated",values:["clockwise","counterclockwise"],dflt:"counterclockwise",editType:"calc"},rotation:{valType:"number",min:-360,max:360,dflt:0,editType:"calc"},pull:{valType:"number",min:0,max:1,dflt:0,arrayOk:!0,editType:"calc"}}},{"../../components/color/attributes":569,"../../lib/extend":685,"../../plots/attributes":741,"../../plots/domain":770,"../../plots/font_attributes":771}],1019:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../plots/get_data").getModuleCalcData;r.name="pie",r.plot=function(t){var e=n.getModule("pie"),r=i(t.calcdata,e)[0];r.length&&e.plot(t,r)},r.clean=function(t,e,r,n){var i=n._has&&n._has("pie"),a=e._has&&e._has("pie");i&&!a&&n._pielayer.selectAll("g.trace").remove()}},{"../../plots/get_data":781,"../../registry":827}],1020:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib").isArrayOrTypedArray,a=t("tinycolor2"),o=t("../../components/color"),s=t("./helpers");r.calc=function(t,e){var r,l,c,u,f,h=e.values,p=i(h)&&h.length,d=e.labels,g=e.marker.colors||[],v=[],m=t._fullLayout,y=m._piecolormap,x={},b=0,_=m.hiddenlabels||[];if(e.dlabel)for(d=new Array(h.length),r=0;r")}}return v},r.crossTraceCalc=function(t){var e=t._fullLayout,r=t.calcdata,n=e.piecolorway,i=e._piecolormap;e.extendpiecolors&&(n=function(t){var e,r=JSON.stringify(t),n=l[r];if(!n){for(n=t.slice(),e=0;e0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function p(t,e){var r=t.trace,n=e.h*(r.domain.y[1]-r.domain.y[0]);return Math.min(t.titleBox.height,n/2)}function d(t){var e,r=t.pull;if(Array.isArray(r))for(r=0,e=0;er&&(r=t.pull[e]);return r}e.exports=function(t,e){var r=t._fullLayout;!function(t,e){for(var r,n,i=0;ii.vTotal/2?1:0)}(e),g.attr("stroke-linejoin","round"),g.each(function(){var g=n.select(this).selectAll("g.slice").data(e);g.enter().append("g").classed("slice",!0),g.exit().remove();var y=[[[],[]],[[],[]]],x=!1;g.each(function(e){if(e.hidden)n.select(this).selectAll("path,g").remove();else{e.pointNumber=e.i,e.curveNumber=m.index,y[e.pxmid[1]<0?0:1][e.pxmid[0]<0?0:1].push(e);var p=v.cx,d=v.cy,g=n.select(this),b=g.selectAll("path.surface").data([e]),_=!1,w=!1;if(b.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),g.select("path.textline").remove(),g.on("mouseover",function(){var a=t._fullLayout,o=t._fullData[m.index];if(!t._dragging&&!1!==a.hovermode){var s=o.hoverinfo;if(Array.isArray(s)&&(s=i.castHoverinfo({hoverinfo:[c.castOption(s,e.pts)],_module:m._module},a,0)),"all"===s&&(s="label+text+value+percent+name"),"none"!==s&&"skip"!==s&&s){var l=f(e,v),h=p+e.pxmid[0]*(1-l),g=d+e.pxmid[1]*(1-l),y=r.separators,x=[];if(-1!==s.indexOf("label")&&x.push(e.label),-1!==s.indexOf("text")){var b=c.castOption(o.hovertext||o.text,e.pts);b&&x.push(b)}-1!==s.indexOf("value")&&x.push(c.formatPieValue(e.v,y)),-1!==s.indexOf("percent")&&x.push(c.formatPiePercent(e.v/v.vTotal,y));var k=m.hoverlabel,M=k.font;i.loneHover({x0:h-l*v.r,x1:h+l*v.r,y:g,text:x.join("
"),name:-1!==s.indexOf("name")?o.name:void 0,idealAlign:e.pxmid[0]<0?"left":"right",color:c.castOption(k.bgcolor,e.pts)||e.color,borderColor:c.castOption(k.bordercolor,e.pts),fontFamily:c.castOption(M.family,e.pts),fontSize:c.castOption(M.size,e.pts),fontColor:c.castOption(M.color,e.pts)},{container:a._hoverlayer.node(),outerContainer:a._paper.node(),gd:t}),_=!0}t.emit("plotly_hover",{points:[u(e,o)],event:n.event}),w=!0}}).on("mouseout",function(r){var a=t._fullLayout,o=t._fullData[m.index];w&&(r.originalEvent=n.event,t.emit("plotly_unhover",{points:[u(e,o)],event:n.event}),w=!1),_&&(i.loneUnhover(a._hoverlayer.node()),_=!1)}).on("click",function(){var r=t._fullLayout,a=t._fullData[m.index];t._dragging||!1===r.hovermode||(t._hoverdata=[u(e,a)],i.click(t,n.event))}),m.pull){var k=+c.castOption(m.pull,e.pts)||0;k>0&&(p+=k*e.pxmid[0],d+=k*e.pxmid[1])}e.cxFinal=p,e.cyFinal=d;var M=m.hole;if(e.v===v.vTotal){var A="M"+(p+e.px0[0])+","+(d+e.px0[1])+L(e.px0,e.pxmid,!0,1)+L(e.pxmid,e.px0,!0,1)+"Z";M?b.attr("d","M"+(p+M*e.px0[0])+","+(d+M*e.px0[1])+L(e.px0,e.pxmid,!1,M)+L(e.pxmid,e.px0,!1,M)+"Z"+A):b.attr("d",A)}else{var T=L(e.px0,e.px1,!0,1);if(M){var S=1-M;b.attr("d","M"+(p+M*e.px1[0])+","+(d+M*e.px1[1])+L(e.px1,e.px0,!1,M)+"l"+S*e.px0[0]+","+S*e.px0[1]+T+"Z")}else b.attr("d","M"+p+","+d+"l"+e.px0[0]+","+e.px0[1]+T+"Z")}var E=c.castOption(m.textposition,e.pts),C=g.selectAll("g.slicetext").data(e.text&&"none"!==E?[0]:[]);C.enter().append("g").classed("slicetext",!0),C.exit().remove(),C.each(function(){var r=s.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});r.text(e.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(o.font,"outside"===E?function(t,e,r){var n=c.castOption(t.outsidetextfont.color,e.pts)||c.castOption(t.textfont.color,e.pts)||r.color,i=c.castOption(t.outsidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,a=c.castOption(t.outsidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n,family:i,size:a}}(m,e,t._fullLayout.font):function(t,e,r){var n=c.castOption(t.insidetextfont.color,e.pts);!n&&t._input.textfont&&(n=c.castOption(t._input.textfont.color,e.pts));var i=c.castOption(t.insidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,o=c.castOption(t.insidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n||a.contrast(e.color),family:i,size:o}}(m,e,t._fullLayout.font)).call(l.convertToTspans,t);var i,u=o.bBox(r.node());"outside"===E?i=h(u,e):(i=function(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),i=t.width/t.height,a=Math.PI*Math.min(e.v/r.vTotal,.5),o=1-r.trace.hole,s=f(e,r),l={scale:s*r.r*2/n,rCenter:1-s,rotate:0};if(l.scale>=1)return l;var c=i+1/(2*Math.tan(a)),u=r.r*Math.min(1/(Math.sqrt(c*c+.5)+c),o/(Math.sqrt(i*i+o/2)+i)),h={scale:2*u/t.height,rCenter:Math.cos(u/r.r)-u*i/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},p=1/i,d=p+1/(2*Math.tan(a)),g=r.r*Math.min(1/(Math.sqrt(d*d+.5)+d),o/(Math.sqrt(p*p+o/2)+p)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/i/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return l.scale<1&&m.scale>l.scale?m:l}(u,e,v),"auto"===E&&i.scale<1&&(r.call(o.font,m.outsidetextfont),m.outsidetextfont.family===m.insidetextfont.family&&m.outsidetextfont.size===m.insidetextfont.size||(u=o.bBox(r.node())),i=h(u,e)));var g=p+e.pxmid[0]*i.rCenter+(i.x||0),y=d+e.pxmid[1]*i.rCenter+(i.y||0);i.outside&&(e.yLabelMin=y-u.height/2,e.yLabelMid=y,e.yLabelMax=y+u.height/2,e.labelExtraX=0,e.labelExtraY=0,x=!0),r.attr("transform","translate("+g+","+y+")"+(i.scale<1?"scale("+i.scale+")":"")+(i.rotate?"rotate("+i.rotate+")":"")+"translate("+-(u.left+u.right)/2+","+-(u.top+u.bottom)/2+")")})}function L(t,r,n,i){return"a"+i*v.r+","+i*v.r+" 0 "+e.largeArc+(n?" 1 ":" 0 ")+i*(r[0]-t[0])+","+i*(r[1]-t[1])}});var b=n.select(this).selectAll("g.titletext").data(m.title?[0]:[]);b.enter().append("g").classed("titletext",!0),b.exit().remove(),b.each(function(){var e,i=s.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});i.text(m.title).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(o.font,m.titlefont).call(l.convertToTspans,t),e="middle center"===m.titleposition?function(t){var e=Math.sqrt(t.titleBox.width*t.titleBox.width+t.titleBox.height*t.titleBox.height);return{x:t.cx,y:t.cy,scale:t.trace.hole*t.r*2/e,tx:0,ty:-t.titleBox.height/2+t.trace.titlefont.size}}(v):function(t,e){var r,n,i=1,a=1,o=t.trace,s={x:t.cx,y:t.cy},l={tx:0,ty:0};l.ty+=o.titlefont.size,n=d(o),-1!==o.titleposition.indexOf("top")?(s.y-=(1+n)*t.r,l.ty-=t.titleBox.height):-1!==o.titleposition.indexOf("bottom")&&(s.y+=(1+n)*t.r);-1!==o.titleposition.indexOf("left")?(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,s.x-=(1+n)*t.r,l.tx+=t.titleBox.width/2):-1!==o.titleposition.indexOf("center")?r=e.w*(o.domain.x[1]-o.domain.x[0]):-1!==o.titleposition.indexOf("right")&&(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,s.x+=(1+n)*t.r,l.tx-=t.titleBox.width/2);return i=r/t.titleBox.width,a=p(t,e)/t.titleBox.height,{x:s.x,y:s.y,scale:Math.min(i,a),tx:l.tx,ty:l.ty}}(v,r._size),i.attr("transform","translate("+e.x+","+e.y+")"+(e.scale<1?"scale("+e.scale+")":"")+"translate("+e.tx+","+e.ty+")")}),x&&function(t,e){var r,n,i,a,o,s,l,u,f,h,p,d,g;function v(t,e){return t.pxmid[1]-e.pxmid[1]}function m(t,e){return e.pxmid[1]-t.pxmid[1]}function y(t,r){r||(r={});var i,u,f,p,d,g,v=r.labelExtraY+(n?r.yLabelMax:r.yLabelMin),m=n?t.yLabelMin:t.yLabelMax,y=n?t.yLabelMax:t.yLabelMin,x=t.cyFinal+o(t.px0[1],t.px1[1]),b=v-m;if(b*l>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(u=0;u=(c.castOption(e.pull,f.pts)||0)||((t.pxmid[1]-f.pxmid[1])*l>0?(p=f.cyFinal+o(f.px0[1],f.px1[1]),(b=p-m-t.labelExtraY)*l>0&&(t.labelExtraY+=b)):(y+t.labelExtraY-x)*l>0&&(i=3*s*Math.abs(u-h.indexOf(t)),d=f.cxFinal+a(f.px0[0],f.px1[0]),(g=d+i-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*s>0&&(t.labelExtraX+=g)))}for(n=0;n<2;n++)for(i=n?v:m,o=n?Math.max:Math.min,l=n?1:-1,r=0;r<2;r++){for(a=r?Math.max:Math.min,s=r?1:-1,(u=t[n][r]).sort(i),f=t[1-n][r],h=f.concat(u),d=[],p=0;pMath.abs(c)?o+="l"+c*t.pxmid[0]/t.pxmid[1]+","+c+"H"+(i+t.labelExtraX+s):o+="l"+t.labelExtraX+","+l+"v"+(c-l)+"h"+s}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+s;e.append("path").classed("textline",!0).call(a.stroke,m.outsidetextfont.color).attr({"stroke-width":Math.min(2,m.outsidetextfont.size/8),d:o,fill:"none"})}})})});setTimeout(function(){g.selectAll("tspan").each(function(){var t=n.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":570,"../../components/drawing":595,"../../components/fx":612,"../../lib":696,"../../lib/svg_text_utils":720,"./event_data":1022,"./helpers":1023,d3:148}],1028:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each(function(t){n.select(this).call(i,t,e)})})}},{"./style_one":1029,d3:148}],1029:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("./helpers").castOption;e.exports=function(t,e,r){var a=r.marker.line,o=i(a.color,e.pts)||n.defaultLine,s=i(a.width,e.pts)||0;t.style({"stroke-width":s}).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":570,"./helpers":1023}],1030:[function(t,e,r){"use strict";var n=t("../scatter/attributes");e.exports={x:n.x,y:n.y,xy:{valType:"data_array",editType:"calc"},indices:{valType:"data_array",editType:"calc"},xbounds:{valType:"data_array",editType:"calc"},ybounds:{valType:"data_array",editType:"calc"},text:n.text,marker:{color:{valType:"color",arrayOk:!1,editType:"calc"},opacity:{valType:"number",min:0,max:1,dflt:1,arrayOk:!1,editType:"calc"},blend:{valType:"boolean",dflt:null,editType:"calc"},sizemin:{valType:"number",min:.1,max:2,dflt:.5,editType:"calc"},sizemax:{valType:"number",min:.1,dflt:20,editType:"calc"},border:{color:{valType:"color",arrayOk:!1,editType:"calc"},arearatio:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},editType:"calc"},editType:"calc"},transforms:void 0}},{"../scatter/attributes":1043}],1031:[function(t,e,r){"use strict";var n=t("gl-pointcloud2d"),i=t("../../lib/str2rgbarray"),a=t("../../plots/cartesian/autorange").findExtremes,o=t("../scatter/get_trace_color");function s(t,e){this.scene=t,this.uid=e,this.type="pointcloud",this.pickXData=[],this.pickYData=[],this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.idToIndex=new Int32Array(0),this.bounds=[0,0,0,0],this.pointcloudOptions={positions:new Float32Array(0),idToIndex:this.idToIndex,sizemin:.5,sizemax:12,color:[0,0,0,1],areaRatio:1,borderColor:[0,0,0,1]},this.pointcloud=n(t.glplot,this.pointcloudOptions),this.pointcloud._trace=this}var l=s.prototype;l.handlePick=function(t){var e=this.idToIndex[t.pointId];return{trace:this,dataCoord:t.dataCoord,traceCoord:this.pickXYData?[this.pickXYData[2*e],this.pickXYData[2*e+1]]:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:this.color,name:this.name,pointIndex:e,hoverinfo:this.hoverinfo}},l.update=function(t){this.index=t.index,this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-1/0,-1/0],this.updateFast(t),this.color=o(t,{})},l.updateFast=function(t){var e,r,n,o,s,l,c=this.xData=this.pickXData=t.x,u=this.yData=this.pickYData=t.y,f=this.pickXYData=t.xy,h=t.xbounds&&t.ybounds,p=t.indices,d=this.bounds;if(f){if(n=f,e=f.length>>>1,h)d[0]=t.xbounds[0],d[2]=t.xbounds[1],d[1]=t.ybounds[0],d[3]=t.ybounds[1];else for(l=0;ld[2]&&(d[2]=o),sd[3]&&(d[3]=s);if(p)r=p;else for(r=new Int32Array(e),l=0;ld[2]&&(d[2]=o),sd[3]&&(d[3]=s);this.idToIndex=r,this.pointcloudOptions.idToIndex=r,this.pointcloudOptions.positions=n;var g=i(t.marker.color),v=i(t.marker.border.color),m=t.opacity*t.marker.opacity;g[3]*=m,this.pointcloudOptions.color=g;var y=t.marker.blend;if(null===y){y=c.length<100||u.length<100}this.pointcloudOptions.blend=y,v[3]*=m,this.pointcloudOptions.borderColor=v;var x=t.marker.sizemin,b=Math.max(t.marker.sizemax,t.marker.sizemin);this.pointcloudOptions.sizeMin=x,this.pointcloudOptions.sizeMax=b,this.pointcloudOptions.areaRatio=t.marker.border.arearatio,this.pointcloud.update(this.pointcloudOptions);var _=this.scene.xaxis,w=this.scene.yaxis,k=b/2||.5;t._extremes[_._id]=a(_,[d[0],d[2]],{ppad:k}),t._extremes[w._id]=a(w,[d[1],d[3]],{ppad:k})},l.dispose=function(){this.pointcloud.dispose()},e.exports=function(t,e){var r=new s(t,e.uid);return r.update(e),r}},{"../../lib/str2rgbarray":719,"../../plots/cartesian/autorange":743,"../scatter/get_trace_color":1053,"gl-pointcloud2d":279}],1032:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r){function a(r,a){return n.coerce(t,e,i,r,a)}a("x"),a("y"),a("xbounds"),a("ybounds"),t.xy&&t.xy instanceof Float32Array&&(e.xy=t.xy),t.indices&&t.indices instanceof Int32Array&&(e.indices=t.indices),a("text"),a("marker.color",r),a("marker.opacity"),a("marker.blend"),a("marker.sizemin"),a("marker.sizemax"),a("marker.border.color",r),a("marker.border.arearatio"),e._length=null}},{"../../lib":696,"./attributes":1030}],1033:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../scatter3d/calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="pointcloud",n.basePlotModule=t("../../plots/gl2d"),n.categories=["gl","gl2d","showLegend"],n.meta={},e.exports=n},{"../../plots/gl2d":784,"../scatter3d/calc":1071,"./attributes":1030,"./convert":1031,"./defaults":1032}],1034:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../../plots/attributes"),a=t("../../components/color/attributes"),o=t("../../components/fx/attributes"),s=t("../../plots/domain").attributes,l=t("../../lib/extend").extendFlat,c=t("../../plot_api/edit_types").overrideAll;(e.exports=c({hoverinfo:l({},i.hoverinfo,{flags:[],arrayOk:!1}),hoverlabel:o.hoverlabel,domain:s({name:"sankey",trace:!0}),orientation:{valType:"enumerated",values:["v","h"],dflt:"h"},valueformat:{valType:"string",dflt:".3s"},valuesuffix:{valType:"string",dflt:""},arrangement:{valType:"enumerated",values:["snap","perpendicular","freeform","fixed"],dflt:"snap"},textfont:n({}),node:{label:{valType:"data_array",dflt:[]},color:{valType:"color",arrayOk:!0},line:{color:{valType:"color",dflt:a.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:.5,arrayOk:!0}},pad:{valType:"number",arrayOk:!1,min:0,dflt:20},thickness:{valType:"number",arrayOk:!1,min:1,dflt:20},hoverinfo:{valType:"enumerated",values:["all","none","skip"],dflt:"all"},hoverlabel:o.hoverlabel},link:{label:{valType:"data_array",dflt:[]},color:{valType:"color",arrayOk:!0},line:{color:{valType:"color",dflt:a.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:0,arrayOk:!0}},source:{valType:"data_array",dflt:[]},target:{valType:"data_array",dflt:[]},value:{valType:"data_array",dflt:[]},hoverinfo:{valType:"enumerated",values:["all","none","skip"],dflt:"all"},hoverlabel:o.hoverlabel}},"calc","nested")).transforms=void 0},{"../../components/color/attributes":569,"../../components/fx/attributes":604,"../../lib/extend":685,"../../plot_api/edit_types":727,"../../plots/attributes":741,"../../plots/domain":770,"../../plots/font_attributes":771}],1035:[function(t,e,r){"use strict";var n=t("../../plot_api/edit_types").overrideAll,i=t("../../plots/get_data").getModuleCalcData,a=t("./plot"),o=t("../../components/fx/layout_attributes");r.name="sankey",r.baseLayoutAttrOverrides=n({hoverlabel:o.hoverlabel},"plot","nested"),r.plot=function(t){var e=i(t.calcdata,"sankey")[0];a(t,e)},r.clean=function(t,e,r,n){var i=n._has&&n._has("sankey"),a=e._has&&e._has("sankey");i&&!a&&n._paperdiv.selectAll(".sankey").remove()}},{"../../components/fx/layout_attributes":613,"../../plot_api/edit_types":727,"../../plots/get_data":781,"./plot":1040}],1036:[function(t,e,r){"use strict";var n=t("strongly-connected-components"),i=t("../../lib"),a=t("../../lib/gup").wrap;e.exports=function(t,e){return function(t,e,r){for(var a=t.length,o=i.init2dArray(a,0),s=0;s1})}(e.node.label,e.link.source,e.link.target)&&(i.error("Circularity is present in the Sankey data. Removing all nodes and links."),e.link.label=[],e.link.source=[],e.link.target=[],e.link.value=[],e.link.color=[],e.node.label=[],e.node.color=[]),a({link:e.link,node:e.node})}},{"../../lib":696,"../../lib/gup":693,"strongly-connected-components":506}],1037:[function(t,e,r){"use strict";e.exports={nodeTextOffsetHorizontal:4,nodeTextOffsetVertical:3,nodePadAcross:10,sankeyIterations:50,forceIterations:5,forceTicksPerFrame:10,duration:500,ease:"cubic-in-out",cn:{sankey:"sankey",sankeyLinks:"sankey-links",sankeyLink:"sankey-link",sankeyNodeSet:"sankey-node-set",sankeyNode:"sankey-node",nodeRect:"node-rect",nodeCapture:"node-capture",nodeCentered:"node-entered",nodeLabelGuide:"node-label-guide",nodeLabel:"node-label",nodeLabelTextPath:"node-label-text-path"}}},{}],1038:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("../../components/color"),o=t("tinycolor2"),s=t("../../plots/domain").defaults,l=t("../../components/fx/hoverlabel_defaults"),c=t("../../plot_api/plot_template");e.exports=function(t,e,r,u){function f(r,a){return n.coerce(t,e,i,r,a)}var h=n.extendDeep(u.hoverlabel,t.hoverlabel),p=t.node,d=c.newContainer(e,"node");function g(t,e){return n.coerce(p,d,i.node,t,e)}g("label"),g("pad"),g("thickness"),g("line.color"),g("line.width"),g("hoverinfo",t.hoverinfo),l(p,d,g,h);var v=u.colorway;g("color",d.label.map(function(t,e){return a.addOpacity(function(t){return v[t%v.length]}(e),.8)}));var m=t.link,y=c.newContainer(e,"link");function x(t,e){return n.coerce(m,y,i.link,t,e)}x("label"),x("source"),x("target"),x("value"),x("line.color"),x("line.width"),x("hoverinfo",t.hoverinfo),l(m,y,x,h);var b=o(u.paper_bgcolor).getLuminance()<.333?"rgba(255, 255, 255, 0.6)":"rgba(0, 0, 0, 0.2)";x("color",n.repeat(b,y.value.length)),s(e,u,f),f("orientation"),f("valueformat"),f("valuesuffix"),f("arrangement"),n.coerceFont(f,"textfont",n.extendFlat({},u.font)),e._length=null}},{"../../components/color":570,"../../components/fx/hoverlabel_defaults":611,"../../lib":696,"../../plot_api/plot_template":734,"../../plots/domain":770,"./attributes":1034,tinycolor2:514}],1039:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.moduleType="trace",n.name="sankey",n.basePlotModule=t("./base_plot"),n.categories=["noOpacity"],n.meta={},e.exports=n},{"./attributes":1034,"./base_plot":1035,"./calc":1036,"./defaults":1038,"./plot":1040}],1040:[function(t,e,r){"use strict";var n=t("d3"),i=t("./render"),a=t("../../components/fx"),o=t("../../components/color"),s=t("../../lib"),l=t("./constants").cn,c=s._;function u(t){return""!==t}function f(t,e){return t.filter(function(t){return t.key===e.traceId})}function h(t,e){n.select(t).select("path").style("fill-opacity",e),n.select(t).select("rect").style("fill-opacity",e)}function p(t){n.select(t).select("text.name").style("fill","black")}function d(t){return function(e){return-1!==t.node.sourceLinks.indexOf(e.link)||-1!==t.node.targetLinks.indexOf(e.link)}}function g(t){return function(e){return-1!==e.node.sourceLinks.indexOf(t.link)||-1!==e.node.targetLinks.indexOf(t.link)}}function v(t,e,r){e&&r&&f(r,e).selectAll("."+l.sankeyLink).filter(d(e)).call(y.bind(0,e,r,!1))}function m(t,e,r){e&&r&&f(r,e).selectAll("."+l.sankeyLink).filter(d(e)).call(x.bind(0,e,r,!1))}function y(t,e,r,n){var i=n.datum().link.label;n.style("fill-opacity",.4),i&&f(e,t).selectAll("."+l.sankeyLink).filter(function(t){return t.link.label===i}).style("fill-opacity",.4),r&&f(e,t).selectAll("."+l.sankeyNode).filter(g(t)).call(v)}function x(t,e,r,n){var i=n.datum().link.label;n.style("fill-opacity",function(t){return t.tinyColorAlpha}),i&&f(e,t).selectAll("."+l.sankeyLink).filter(function(t){return t.link.label===i}).style("fill-opacity",function(t){return t.tinyColorAlpha}),r&&f(e,t).selectAll(l.sankeyNode).filter(g(t)).call(m)}function b(t,e){var r=t.hoverlabel||{},n=s.nestedProperty(r,e).get();return!Array.isArray(n)&&n}e.exports=function(t,e){var r=t._fullLayout,s=r._paper,f=r._size,d=c(t,"source:")+" ",g=c(t,"target:")+" ",_=c(t,"incoming flow count:")+" ",w=c(t,"outgoing flow count:")+" ";i(s,e,{width:f.w,height:f.h,margin:{t:f.t,r:f.r,b:f.b,l:f.l}},{linkEvents:{hover:function(e,r,i){!1!==t._fullLayout.hovermode&&(n.select(e).call(y.bind(0,r,i,!0)),"skip"!==r.link.trace.link.hoverinfo&&t.emit("plotly_hover",{event:n.event,points:[r.link]}))},follow:function(e,i){if(!1!==t._fullLayout.hovermode){var s=i.link.trace.link;if("none"!==s.hoverinfo&&"skip"!==s.hoverinfo){var l=t._fullLayout._paperdiv.node().getBoundingClientRect(),c=e.getBoundingClientRect(),f=c.left+c.width/2,v=c.top+c.height/2,m=a.loneHover({x:f-l.left,y:v-l.top,name:n.format(i.valueFormat)(i.link.value)+i.valueSuffix,text:[i.link.label||"",d+i.link.source.label,g+i.link.target.label].filter(u).join("
"),color:b(s,"bgcolor")||o.addOpacity(i.tinyColorHue,1),borderColor:b(s,"bordercolor"),fontFamily:b(s,"font.family"),fontSize:b(s,"font.size"),fontColor:b(s,"font.color"),idealAlign:n.event.x"),color:b(o,"bgcolor")||i.tinyColorHue,borderColor:b(o,"bordercolor"),fontFamily:b(o,"font.family"),fontSize:b(o,"font.size"),fontColor:b(o,"font.color"),idealAlign:"left"},{container:r._hoverlayer.node(),outerContainer:r._paper.node(),gd:t});h(m,.85),p(m)}}},unhover:function(e,i,o){!1!==t._fullLayout.hovermode&&(n.select(e).call(m,i,o),"skip"!==i.node.trace.node.hoverinfo&&t.emit("plotly_unhover",{event:n.event,points:[i.node]}),a.loneUnhover(r._hoverlayer.node()))},select:function(e,r,i){var o=r.node;o.originalEvent=n.event,t._hoverdata=[o],n.select(e).call(m,r,i),a.click(t,{target:!0})}}})}},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"./constants":1037,"./render":1041,d3:148}],1041:[function(t,e,r){"use strict";var n=t("./constants"),i=t("d3"),a=t("tinycolor2"),o=t("../../components/color"),s=t("../../components/drawing"),l=t("@plotly/d3-sankey").sankey,c=t("d3-force"),u=t("../../lib"),f=u.isArrayOrTypedArray,h=u.isIndex,p=t("../../lib/gup"),d=p.keyFun,g=p.repeat,v=p.unwrap;function m(t){t.lastDraggedX=t.x,t.lastDraggedY=t.y}function y(t){return function(e){return e.node.originalX===t.node.originalX}}function x(t){for(var e=0;e1||t.linkLineWidth>0}function T(t){return"translate("+t.translateX+","+t.translateY+")"+(t.horizontal?"matrix(1 0 0 1 0 0)":"matrix(0 1 1 0 0 0)")}function S(t){return"translate("+(t.horizontal?0:t.labelY)+" "+(t.horizontal?t.labelY:0)+")"}function E(t){return i.svg.line()([[t.horizontal?t.left?-t.sizeAcross:t.visibleWidth+n.nodeTextOffsetHorizontal:n.nodeTextOffsetHorizontal,0],[t.horizontal?t.left?-n.nodeTextOffsetHorizontal:t.sizeAcross:t.visibleHeight-n.nodeTextOffsetHorizontal,0]])}function C(t){return t.horizontal?"matrix(1 0 0 1 0 0)":"matrix(0 1 1 0 0 0)"}function L(t){return t.horizontal?"scale(1 1)":"scale(-1 1)"}function z(t){return t.darkBackground&&!t.horizontal?"rgb(255,255,255)":"rgb(0,0,0)"}function O(t){return t.horizontal&&t.left?"100%":"0%"}function I(t,e,r){t.on(".basic",null).on("mouseover.basic",function(t){t.interactionState.dragInProgress||(r.hover(this,t,e),t.interactionState.hovered=[this,t])}).on("mousemove.basic",function(t){t.interactionState.dragInProgress||(r.follow(this,t),t.interactionState.hovered=[this,t])}).on("mouseout.basic",function(t){t.interactionState.dragInProgress||(r.unhover(this,t,e),t.interactionState.hovered=!1)}).on("click.basic",function(t){t.interactionState.hovered&&(r.unhover(this,t,e),t.interactionState.hovered=!1),t.interactionState.dragInProgress||r.select(this,t,e)})}function P(t,e,r){var a=i.behavior.drag().origin(function(t){return t.node}).on("dragstart",function(i){if("fixed"!==i.arrangement&&(u.raiseToTop(this),i.interactionState.dragInProgress=i.node,m(i.node),i.interactionState.hovered&&(r.nodeEvents.unhover.apply(0,i.interactionState.hovered),i.interactionState.hovered=!1),"snap"===i.arrangement)){var a=i.traceId+"|"+Math.floor(i.node.originalX);i.forceLayouts[a]?i.forceLayouts[a].alpha(1):function(t,e,r){var i=r.sankey.nodes().filter(function(t){return t.originalX===r.node.originalX});r.forceLayouts[e]=c.forceSimulation(i).alphaDecay(0).force("collide",c.forceCollide().radius(function(t){return t.dy/2+r.nodePad/2}).strength(1).iterations(n.forceIterations)).force("constrain",function(t,e,r,i){return function(){for(var t=0,a=0;a0&&i.forceLayouts[e].alpha(0)}}(0,e,i,r)).stop()}(0,a,i),function(t,e,r,i){window.requestAnimationFrame(function a(){for(var o=0;o0&&window.requestAnimationFrame(a)})}(t,e,i,a)}}).on("drag",function(r){if("fixed"!==r.arrangement){var n=i.event.x,a=i.event.y;"snap"===r.arrangement?(r.node.x=n,r.node.y=a):("freeform"===r.arrangement&&(r.node.x=n),r.node.y=Math.max(r.node.dy/2,Math.min(r.size-r.node.dy/2,a))),m(r.node),"snap"!==r.arrangement&&(r.sankey.relayout(),k(t.filter(y(r)),e))}}).on("dragend",function(t){t.interactionState.dragInProgress=!1});t.on(".drag",null).call(a)}e.exports=function(t,e,r,i){var c=t.selectAll("."+n.cn.sankey).data(e.filter(function(t){return v(t).trace.visible}).map(function(t,e,r){var i,a=v(e).trace,o=a.domain,s=a.node,c=a.link,p=a.arrangement,d="h"===a.orientation,g=a.node.pad,m=a.node.thickness,y=a.node.line.color,b=a.node.line.width,_=a.link.line.color,w=a.link.line.width,k=a.valueformat,M=a.valuesuffix,A=a.textfont,T=t.width*(o.x[1]-o.x[0]),S=t.height*(o.y[1]-o.y[0]),E=[],C=f(c.color),L={},z=s.label.length;for(i=0;i0&&h(I,z)&&h(P,z)&&(P=+P,L[I=+I]=L[P]=!0,E.push({pointNumber:i,label:c.label[i],color:C?c.color[i]:c.color,source:I,target:P,value:+O}))}var D=f(s.color),R=[],B=!1,F={};for(i=0;i5?t.node.label:""}).attr("text-anchor",function(t){return t.horizontal&&t.left?"end":"start"}),N.transition().ease(n.ease).duration(n.duration).attr("startOffset",O).style("fill",z)}},{"../../components/color":570,"../../components/drawing":595,"../../lib":696,"../../lib/gup":693,"./constants":1037,"@plotly/d3-sankey":46,d3:148,"d3-force":144,tinycolor2:514}],1042:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rs&&A[v].gap;)v--;for(y=A[v].s,d=A.length-1;d>v;d--)A[d].s=y;for(;sT[u]&&u=0;i--){var a=t[i];if("scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}}}}},{}],1050:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("./constants"),s=t("./subtypes"),l=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),h=t("./line_shape_defaults"),p=t("./text_defaults"),d=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,i){return n.coerce(t,e,a,r,i)}var m=l(t,e,g,v);if(m||(e.visible=!1),e.visible){var y=c(t,e,g,v),x=!y&&mG!=(B=O[L][1])>=G&&(P=O[L-1][0],D=O[L][0],B-R&&(I=P+(D-P)*(G-R)/(B-R),V=Math.min(V,I),U=Math.max(U,I)));V=Math.max(V,0),U=Math.min(U,h._length);var W=s.defaultLine;return s.opacity(f.fillcolor)?W=f.fillcolor:s.opacity((f.line||{}).color)&&(W=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:V,x1:U,y0:G,y1:G,color:W}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":570,"../../components/fx":612,"../../lib":696,"../../registry":827,"./fill_hover_text":1051,"./get_trace_color":1053}],1055:[function(t,e,r){"use strict";var n={},i=t("./subtypes");n.hasLines=i.hasLines,n.hasMarkers=i.hasMarkers,n.hasText=i.hasText,n.isBubble=i.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":756,"./arrays_to_calcdata":1042,"./attributes":1043,"./calc":1044,"./cross_trace_calc":1048,"./cross_trace_defaults":1049,"./defaults":1050,"./hover":1054,"./marker_colorbar":1061,"./plot":1063,"./select":1064,"./style":1066,"./subtypes":1067}],1056:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s,l){var c=(t.marker||{}).color;(s("line.color",r),i(t,"line"))?a(t,e,o,s,{prefix:"line.",cLetter:"c",noScale:!0}):s("line.color",!n(c)&&c||r);s("line.width"),(l||{}).noDash||s("line.dash")}},{"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"../../lib":696}],1057:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),i=n.BADNUM,a=n.LOG_CLIP,o=a+.5,s=a-.5,l=t("../../lib"),c=l.segmentsIntersect,u=l.constrain,f=t("./constants");e.exports=function(t,e){var r,n,a,h,p,d,g,v,m,y,x,b,_,w,k,M,A,T,S=e.xaxis,E=e.yaxis,C="log"===S.type,L="log"===E.type,z=S._length,O=E._length,I=e.connectGaps,P=e.baseTolerance,D=e.shape,R="linear"===D,B=[],F=f.minTolerance,N=new Array(t.length),j=0;function V(e){var r=t[e];if(!r)return!1;var n=S.c2p(r.x),a=E.c2p(r.y);if(n===i){if(C&&(n=S.c2p(r.x,!0)),n===i)return!1;L&&a===i&&(n*=Math.abs(S._m*O*(S._m>0?o:s)/(E._m*z*(E._m>0?o:s)))),n*=1e3}if(a===i){if(L&&(a=E.c2p(r.y,!0)),a===i)return!1;a*=1e3}return[n,a]}function U(t,e,r,n){var i=r-t,a=n-e,o=.5-t,s=.5-e,l=i*i+a*a,c=i*o+a*s;if(c>0&&ctt||t[1]rt)return[u(t[0],Q,tt),u(t[1],et,rt)]}function at(t,e){return t[0]===e[0]&&(t[0]===Q||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,i){var a=it(n),o=it(i),s=[];if(a&&o&&at(a,o))return s;a&&s.push(a),o&&s.push(o);var c=2*l.constrain((n[t]+i[t])/2,e,r)-((a||n)[t]+(o||i)[t]);c&&((a&&o?c>0==a[t]>o[t]?a:o:a||o)[t]+=c);return s}}function st(t){var e=t[0],r=t[1],n=e===N[j-1][0],i=r===N[j-1][1];if(!n||!i)if(j>1){var a=e===N[j-2][0],o=r===N[j-2][1];n&&(e===Q||e===tt)&&a?o?j--:N[j-1]=t:i&&(r===et||r===rt)&&o?a?j--:N[j-1]=t:N[j++]=t}else N[j++]=t}function lt(t){N[j-1][0]!==t[0]&&N[j-1][1]!==t[1]&&st([Y,X]),st(t),Z=null,Y=X=0}function ct(t){if(A=t[0]/z,T=t[1]/O,G=t[0]tt?tt:0,W=t[1]rt?rt:0,G||W){if(j)if(Z){var e=J(Z,t);e.length>1&&(lt(e[0]),N[j++]=e[1])}else $=J(N[j-1],t)[0],N[j++]=$;else N[j++]=[G||t[0],W||t[1]];var r=N[j-1];G&&W&&(r[0]!==G||r[1]!==W)?(Z&&(Y!==G&&X!==W?st(Y&&X?(n=Z,a=(i=t)[0]-n[0],o=(i[1]-n[1])/a,(n[1]*i[0]-i[1]*n[0])/a>0?[o>0?Q:tt,rt]:[o>0?tt:Q,et]):[Y||G,X||W]):Y&&X&&st([Y,X])),st([G,W])):Y-G&&X-W&&st([G||Y,W||X]),Z=t,Y=G,X=W}else Z&<(J(Z,t)[0]),N[j++]=t;var n,i,a,o}for("linear"===D||"spline"===D?J=function(t,e){for(var r=[],n=0,i=0;i<4;i++){var a=nt[i],o=c(t[0],t[1],e[0],e[1],a[0],a[1],a[2],a[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&H(o,t)q(d,ut))break;a=d,(_=m[0]*v[0]+m[1]*v[1])>x?(x=_,h=d,g=!1):_=t.length||!d)break;ct(d),n=d}}else ct(h)}Z&&st([Y||Z[0],X||Z[1]]),B.push(N.slice(0,j))}return B}},{"../../constants/numerical":673,"../../lib":696,"./constants":1047}],1058:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],1059:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var i,a,o,s,l,c={},u=!1,f=-1,h=0,p=-1;for(a=0;a=0?l=p:(l=p=h,h++),l0?Math.max(e,i):0}}},{"fast-isnumeric":214}],1061:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],1062:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),c.noLine||(l("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?n.background:n.defaultLine),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0)),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),c.gradient)&&("none"!==l("marker.gradient.type")&&l("marker.gradient.color"))}},{"../../components/color":570,"../../components/colorscale/defaults":580,"../../components/colorscale/has_colorscale":584,"./subtypes":1067}],1063:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../registry"),a=t("../../lib"),o=a.ensureSingle,s=a.identity,l=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),h=t("../../lib/polygon").tester;function p(t,e,r,f,p,d,g){var v;!function(t,e,r,i,o){var s=r.xaxis,l=r.yaxis,u=n.extent(a.simpleMap(s.range,s.r2c)),f=n.extent(a.simpleMap(l.range,l.r2c)),h=i[0].trace;if(!c.hasMarkers(h))return;var p=h.marker.maxdisplayed;if(0===p)return;var d=i.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(d.length/p),v=0;o.forEach(function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function y(t){return m?t.transition():t}var x=r.xaxis,b=r.yaxis,_=f[0].trace,w=_.line,k=n.select(d),M=o(k,"g","errorbars"),A=o(k,"g","lines"),T=o(k,"g","points"),S=o(k,"g","text");if(i.getComponentMethod("errorbars","plot")(M,r,g),!0===_.visible){var E,C;y(k).style("opacity",_.opacity);var L=_.fill.charAt(_.fill.length-1);"x"!==L&&"y"!==L&&(L=""),r.isRangePlot||(f[0].node3=k);var z="",O=[],I=_._prevtrace;I&&(z=I._prevRevpath||"",C=I._nextFill,O=I._polygons);var P,D,R,B,F,N,j,V,U,q="",H="",G=[],W=a.noop;if(E=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(C&&C.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(R=l.steps(w.shape),B=l.steps(w.shape.split("").reverse().join(""))):R=B="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?l.smoothclosed(t.slice(1),w.smoothing):l.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},F=function(t){return B(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),U=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)y(r.style("opacity",0).attr("d",P).call(l.lineGroupStyle)).style("opacity",1);else{var i=y(r);i.attr("d",P),l.singleLineStyle(f,i)}}}}}var Y=A.selectAll(".js-line").data(G);y(Y.exit()).style("opacity",0).remove(),Y.each(W(!1)),Y.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(l.lineGroupStyle).each(W(!0)),l.setClipUrl(Y,r.layerClipId),G.length?(E?(E.datum(f),N&&V&&(L?("y"===L?N[1]=V[1]=b.c2p(0,!0):"x"===L&&(N[0]=V[0]=x.c2p(0,!0)),y(E).attr("d","M"+V+"L"+N+"L"+q.substr(1)).call(l.singleFillStyle)):y(E).attr("d",q+"Z").call(l.singleFillStyle))):C&&("tonext"===_.fill.substr(0,6)&&q&&z?("tonext"===_.fill?y(C).attr("d",q+"Z"+z+"Z").call(l.singleFillStyle):y(C).attr("d",q+"L"+z.substr(1)+"Z").call(l.singleFillStyle),_._polygons=_._polygons.concat(O)):(Z(C),_._polygons=null)),_._prevRevpath=H,_._prevPolygons=U):(E?Z(E):C&&Z(C),_._polygons=_._prevRevpath=_._prevPolygons=null),T.datum(f),S.datum(f),function(e,i,a){var o,u=a[0].trace,f=c.hasMarkers(u),h=c.hasText(u),p=tt(u),d=et,g=et;if(f||h){var v=s,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?J:$:_&&!w&&(v=K),f&&(d=v),h&&(g=v)}var k,M=(o=e.selectAll("path.point").data(d,p)).enter().append("path").classed("point",!0);m&&M.call(l.pointStyle,u,t).call(l.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=l.makePointStyleFns(u)),o.each(function(e){var i=n.select(this),a=y(i);l.translatePoint(e,a,x,b)?(l.singlePointStyle(e,a,u,k,t),r.layerClipId&&l.hideOutsideRangePoint(e,a,x,b,u.xcalendar,u.ycalendar),u.customdata&&i.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):a.remove()}),m?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=i.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),i=y(e.select("text"));l.translatePoint(t,i,x,b)?r.layerClipId&&l.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(l.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),r=b.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){y(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(T,S,f);var X=!1===_.cliponaxis?null:r.layerClipId;l.setClipUrl(T,X),l.setClipUrl(S,X)}function Z(t){y(t).attr("d","M0,0Z")}function $(t){return t.filter(function(t){return!t.gap&&t.vis})}function J(t){return t.filter(function(t){return t.vis})}function K(t){return t.filter(function(t){return!t.gap})}function Q(t){return t.id}function tt(t){if(t.ids)return Q}function et(){return!1}}e.exports=function(t,e,r,i,a,c){var u,h,d=!a,g=!!a&&a.duration>0,v=f(t,e,r);((u=i.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,r){e.each(function(t){var e=o(n.select(this),"g","fills");l.setClipUrl(e,r.layerClipId);var i=t[0].trace,a=[];i._ownfill&&a.push("_ownFill"),i._nexttrace&&a.push("_nextFill");var c=e.selectAll("g").data(a,s);c.enter().append("g"),c.exit().each(function(t){i[t]=null}).remove(),c.order().each(function(t){i[t]=o(n.select(this),"path","js-fill")})})}(0,u,e),g)?(c&&(h=c()),n.transition().duration(a.duration).ease(a.easing).each("end",function(){h&&h()}).each("interrupt",function(){h&&h()}).each(function(){i.selectAll("g.trace").each(function(r,n){p(t,n,e,r,v,this,a)})})):u.each(function(r,n){p(t,n,e,r,v,this,a)});d&&u.exit().remove(),i.selectAll("path:not([d])").remove()}},{"../../components/drawing":595,"../../lib":696,"../../lib/polygon":708,"../../registry":827,"./line_points":1057,"./link_traces":1059,"./subtypes":1067,d3:148}],1064:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,i,a,o,s=t.cd,l=t.xaxis,c=t.yaxis,u=[],f=s[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r0){var h=i.c2l(u);i._lowerLogErrorBound||(i._lowerLogErrorBound=h),i._lowerErrorBound=Math.min(i._lowerLogErrorBound,h)}}else o[s]=[-l[0]*r,l[1]*r]}return o}e.exports=function(t,e,r){var n=[i(t.x,t.error_x,e[0],r.xaxis),i(t.y,t.error_y,e[1],r.yaxis),i(t.z,t.error_z,e[2],r.zaxis)],a=function(t){for(var e=0;e=0&&(p[1]+=1),h.indexOf("top")>=0&&(p[1]-=1),h.indexOf("left")>=0&&(p[0]-=1),h.indexOf("right")>=0&&(p[0]+=1),p)),r.textColor=u(e.textfont,1,C),r.textSize=x(e.textfont.size,C,l.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var P=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;n<3;++n){var D=e.projection[P[n]];(r.project[n]=D.show)&&(r.projectOpacity[n]=D.opacity,r.projectScale[n]=D.scale)}r.errorBounds=d(e,b,v);var R=function(t){for(var e=[0,0,0],r=[[0,0,0],[0,0,0],[0,0,0]],n=[1,1,1],i=0;i<3;i++){var a=t[i];a&&!1!==a.copy_zstyle&&!1!==t[2].visible&&(a=t[2]),a&&a.visible&&(e[i]=a.width/2,r[i]=c(a.color),n[i]=a.thickness)}return{capSize:e,color:r,lineWidth:n}}([e.error_x,e.error_y,e.error_z]);return r.errorColor=R.color,r.errorLineWidth=R.lineWidth,r.errorCapSize=R.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=c(e.surfacecolor),r}function _(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}v.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){var e=t.index=t.data.index;return t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),t.textLabel="",this.textLabels&&(Array.isArray(this.textLabels)?(this.textLabels[e]||0===this.textLabels[e])&&(t.textLabel=this.textLabels[e]):t.textLabel=this.textLabels),t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},v.update=function(t){var e,r,l,c,u=this.scene.glplot.gl,f=h.solid;this.data=t;var p=b(this.scene,t);"mode"in p&&(this.mode=p.mode),"lineDashes"in p&&p.lineDashes in h&&(f=h[p.lineDashes]),this.color=_(p.scatterColor)||_(p.lineColor),this.dataPoints=p.position,e={gl:u,position:p.position,color:p.lineColor,lineWidth:p.lineWidth||1,dashes:f[0],dashScale:f[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=n(e),this.linePlot._trace=this,this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var d=t.opacity;if(t.marker&&t.marker.opacity&&(d*=t.marker.opacity),r={gl:u,position:p.position,color:p.scatterColor,size:p.scatterSize,glyph:p.scatterMarker,opacity:d,orthographic:!0,lineWidth:p.scatterLineWidth,lineColor:p.scatterLineColor,project:p.project,projectScale:p.projectScale,projectOpacity:p.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=i(r),this.scatterPlot._trace=this,this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),c={gl:u,position:p.position,glyph:p.text,color:p.textColor,size:p.textSize,angle:p.textAngle,alignment:p.textOffset,font:p.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=t.hovertext||t.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(c):(this.textMarkers=i(c),this.textMarkers._trace=this,this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),l={gl:u,position:p.position,color:p.errorColor,error:p.errorBounds,lineWidth:p.errorLineWidth,capSize:p.errorCapSize,opacity:t.opacity},this.errorBars?p.errorBounds?this.errorBars.update(l):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):p.errorBounds&&(this.errorBars=a(l),this.errorBars._trace=this,this.scene.glplot.add(this.errorBars)),p.delaunayAxis>=0){var g=function(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],l=[];for(n=0;n=0&&f("surfacecolor",h||p);for(var d=["x","y","z"],g=0;g<3;++g){var v="projection."+d[g];f(v+".show")&&(f(v+".opacity"),f(v+".scale"))}var m=n.getComponentMethod("errorbars","supplyDefaults");m(t,e,r,{axis:"z"}),m(t,e,r,{axis:"y",inherit:"z"}),m(t,e,r,{axis:"x",inherit:"z"})}else e.visible=!1}},{"../../lib":696,"../../registry":827,"../scatter/line_defaults":1056,"../scatter/marker_defaults":1062,"../scatter/subtypes":1067,"../scatter/text_defaults":1068,"./attributes":1070}],1075:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl3d_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","showLegend"],n.meta={},e.exports=n},{"../../constants/gl3d_markers":671,"../../plots/gl3d":787,"../scatter/marker_colorbar":1061,"./attributes":1070,"./calc":1071,"./convert":1073,"./defaults":1074}],1076:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../components/colorbar/attributes"),s=t("../../lib/extend").extendFlat,l=n.marker,c=n.line,u=l.line;e.exports={carpet:{valType:"string",editType:"calc"},a:{valType:"data_array",editType:"calc"},b:{valType:"data_array",editType:"calc"},mode:s({},n.mode,{dflt:"markers"}),text:s({},n.text,{}),line:{color:c.color,width:c.width,dash:c.dash,shape:s({},c.shape,{values:["linear","spline"]}),smoothing:c.smoothing,editType:"calc"},connectgaps:n.connectgaps,fill:s({},n.fill,{values:["none","toself","tonext"],dflt:"none"}),fillcolor:n.fillcolor,marker:s({symbol:l.symbol,opacity:l.opacity,maxdisplayed:l.maxdisplayed,size:l.size,sizeref:l.sizeref,sizemin:l.sizemin,sizemode:l.sizemode,line:s({width:u.width,editType:"calc"},a("marker.line")),gradient:l.gradient,editType:"calc"},a("marker"),{colorbar:o}),textfont:n.textfont,textposition:n.textposition,selected:n.selected,unselected:n.unselected,hoverinfo:s({},i.hoverinfo,{flags:["a","b","text","name"]}),hoveron:n.hoveron}},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plots/attributes":741,"../scatter/attributes":1043}],1077:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../scatter/colorscale_calc"),a=t("../scatter/arrays_to_calcdata"),o=t("../scatter/calc_selection"),s=t("../scatter/calc").calcMarkerSize,l=t("../carpet/lookup_carpetid");e.exports=function(t,e){var r=e._carpetTrace=l(t,e);if(r&&r.visible&&"legendonly"!==r.visible){var c;e.xaxis=r.xaxis,e.yaxis=r.yaxis;var u,f,h=e._length,p=new Array(h),d=!1;for(c=0;c"),a}function w(t,e){var r;r=t.labelprefix&&t.labelprefix.length>0?t.labelprefix.replace(/ = $/,""):t._hovertitle,g.push(r+": "+e.toFixed(3)+t.labelsuffix)}}},{"../scatter/hover":1054}],1081:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("../scatter/style").style,n.styleOnSelect=t("../scatter/style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("../scatter/select"),n.eventData=t("./event_data"),n.moduleType="trace",n.name="scattercarpet",n.basePlotModule=t("../../plots/cartesian"),n.categories=["svg","carpet","symbols","showLegend","carpetDependent","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":756,"../scatter/marker_colorbar":1061,"../scatter/select":1064,"../scatter/style":1066,"./attributes":1076,"./calc":1077,"./defaults":1078,"./event_data":1079,"./hover":1080,"./plot":1082}],1082:[function(t,e,r){"use strict";var n=t("../scatter/plot"),i=t("../../plots/cartesian/axes"),a=t("../../components/drawing");e.exports=function(t,e,r,o){var s,l,c,u=r[0][0].carpet,f={xaxis:i.getFromId(t,u.xaxis||"x"),yaxis:i.getFromId(t,u.yaxis||"y"),plot:e.plot};for(n(t,f,r,o),s=0;s")}(u,v,p.mockAxis,c[0].t.labels),[t]}}},{"../../components/fx":612,"../../constants/numerical":673,"../../plots/cartesian/axes":744,"../scatter/fill_hover_text":1051,"../scatter/get_trace_color":1053,"./attributes":1083}],1088:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOnSelect=t("../scatter/style").styleOnSelect,n.hoverPoints=t("./hover"),n.eventData=t("./event_data"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scattergeo",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","symbols","showLegend","scatter-like"],n.meta={},e.exports=n},{"../../plots/geo":775,"../scatter/marker_colorbar":1061,"../scatter/style":1066,"./attributes":1083,"./calc":1084,"./defaults":1085,"./event_data":1086,"./hover":1087,"./plot":1089,"./select":1090,"./style":1091}],1089:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../constants/numerical").BADNUM,o=t("../../lib/topojson_utils").getTopojsonFeatures,s=t("../../lib/geo_location_utils").locationToFeature,l=t("../../lib/geojson_utils"),c=t("../scatter/subtypes"),u=t("./style");function f(t,e){var r=t[0].trace;if(Array.isArray(r.locations))for(var n=o(r,e),i=r.locationmode,l=0;lp.TOO_MANY_POINTS?"rect":f.hasMarkers(e)?"rect":"round";if(c&&e.connectgaps){var h=n[0],d=n[1];for(i=0;i1?l[i]:l[0]:l,d=Array.isArray(c)?c.length>1?c[i]:c[0]:c,v=g[p],m=g[d],y=u?u/.8+1:0,x=-m*y-.5*m;o.offset[i]=[v*y/h,x/h]}}return o}}},{"../../components/drawing":595,"../../constants/interactions":672,"../../lib":696,"../../lib/gl_format_color":692,"../../plots/cartesian/axis_ids":747,"../../registry":827,"../scatter/make_bubble_size_func":1060,"../scatter/subtypes":1067,"./constants":1093,"color-normalize":108,"fast-isnumeric":214,"svg-path-sdf":512}],1095:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("../scatter/constants"),s=t("../scatter/subtypes"),l=t("../scatter/xy_defaults"),c=t("../scatter/marker_defaults"),u=t("../scatter/line_defaults"),f=t("../scatter/fillcolor_defaults"),h=t("../scatter/text_defaults");e.exports=function(t,e,r,p){function d(r,i){return n.coerce(t,e,a,r,i)}var g=!!t.marker&&/-open/.test(t.marker.symbol),v=s.isBubble(t),m=l(t,e,p,d);if(m){var y=m1&&u.extendFlat(o.line,M.linePositions(t,r,n)),o.errorX||o.errorY){var s=M.errorBarPositions(t,r,n,i,a);o.errorX&&u.extendFlat(o.errorX,s.x),o.errorY&&u.extendFlat(o.errorY,s.y)}return o.text&&(u.extendFlat(o.text,{positions:n},M.textPosition(t,r,o.text,o.marker)),u.extendFlat(o.textSel,{positions:n},M.textPosition(t,r,o.text,o.markerSel)),u.extendFlat(o.textUnsel,{positions:n},M.textPosition(t,r,o.text,o.markerUnsel))),o}(t,0,e,_,g,v),L=C(0,c);return x(a,e),f=T&&(S.marker.cluster=d.tree),L.lineOptions.push(S.line),L.errorXOptions.push(S.errorX),L.errorYOptions.push(S.errorY),L.fillOptions.push(S.fill),L.markerOptions.push(S.marker),L.markerSelectedOptions.push(S.markerSel),L.markerUnselectedOptions.push(S.markerUnsel),L.textOptions.push(S.text),L.textSelectedOptions.push(S.textSel),L.textUnselectedOptions.push(S.textUnsel),d._scene=L,d.index=L.count,d.x=g,d.y=v,d.positions=_,L.count++,[{x:!1,y:!1,t:d,trace:e}]},plot:function(t,e,r){if(r.length){var o,s,c=t._fullLayout,h=e._scene,p=e.xaxis,d=e.yaxis;if(h)if(f(t,["ANGLE_instanced_arrays","OES_element_index_uint"])){var g=c._glcanvas.data()[0].regl;if(_(t,e,r),h.dirty){if(!0===h.error2d&&(h.error2d=a(g)),!0===h.line2d&&(h.line2d=i(g)),!0===h.scatter2d&&(h.scatter2d=n(g)),!0===h.fill2d&&(h.fill2d=i(g)),!0===h.glText)for(h.glText=new Array(h.count),o=0;or&&(isNaN(e[n])||isNaN(e[n+1]));)n-=2;t.positions=e.slice(r,n+2)}return t}),h.line2d.update(h.lineOptions)),h.error2d){var v=(h.errorXOptions||[]).concat(h.errorYOptions||[]);h.error2d.update(v)}h.scatter2d&&h.scatter2d.update(h.markerOptions),h.fillOrder=u.repeat(null,h.count),h.fill2d&&(h.fillOptions=h.fillOptions.map(function(t,e){var n=r[e];if(t&&n&&n[0]&&n[0].trace){var i,a,o=n[0],s=o.trace,l=o.t,c=h.lineOptions[e],u=[];s._ownfill&&u.push(e),s._nexttrace&&u.push(e+1),u.length&&(h.fillOrder[e]=u);var f,p,d=[],g=c&&c.positions||l.positions;if("tozeroy"===s.fill){for(f=0;ff&&isNaN(g[p+1]);)p-=2;0!==g[f+1]&&(d=[g[f],0]),d=d.concat(g.slice(f,p+2)),0!==g[p+1]&&(d=d.concat([g[p],0]))}else if("tozerox"===s.fill){for(f=0;ff&&isNaN(g[p]);)p-=2;0!==g[f]&&(d=[0,g[f+1]]),d=d.concat(g.slice(f,p+2)),0!==g[p]&&(d=d.concat([0,g[p+1]]))}else if("toself"===s.fill||"tonext"===s.fill){for(d=[],i=0,a=0;a-1;for(o=0;o=0?Math.floor((e+180)/360):Math.ceil((e-180)/360)),d=e-p;if(n.getClosest(l,function(t){var e=t.lonlat;if(e[0]===s)return 1/0;var n=i.modHalf(e[0],360),a=e[1],o=h.project([n,a]),l=o.x-u.c2p([d,a]),c=o.y-f.c2p([n,r]),p=Math.max(3,t.mrc||0);return Math.max(Math.sqrt(l*l+c*c)-p,1-3/p)},t),!1!==t.index){var g=l[t.index],v=g.lonlat,m=[i.modHalf(v[0],360)+p,v[1]],y=u.c2p(m),x=f.c2p(m),b=g.mrc||1;return t.x0=y-b,t.x1=y+b,t.y0=x-b,t.y1=x+b,t.color=a(c,g),t.extraText=function(t,e,r){var n=(e.hi||t.hoverinfo).split("+"),i=-1!==n.indexOf("all"),a=-1!==n.indexOf("lon"),s=-1!==n.indexOf("lat"),l=e.lonlat,c=[];function u(t){return t+"\xb0"}i||a&&s?c.push("("+u(l[0])+", "+u(l[1])+")"):a?c.push(r.lon+u(l[0])):s&&c.push(r.lat+u(l[1]));(i||-1!==n.indexOf("text"))&&o(e,t,c);return c.join("
")}(c,g,l[0].t.labels),[t]}}},{"../../components/fx":612,"../../constants/numerical":673,"../../lib":696,"../scatter/fill_hover_text":1051,"../scatter/get_trace_color":1053}],1102:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("../scattergeo/calc"),n.plot=t("./plot"),n.hoverPoints=t("./hover"),n.eventData=t("./event_data"),n.selectPoints=t("./select"),n.style=function(t,e){e&&e[0].trace._glTrace.update(e)},n.moduleType="trace",n.name="scattermapbox",n.basePlotModule=t("../../plots/mapbox"),n.categories=["mapbox","gl","symbols","showLegend","scatterlike"],n.meta={},e.exports=n},{"../../plots/mapbox":802,"../scatter/marker_colorbar":1061,"../scattergeo/calc":1084,"./attributes":1097,"./defaults":1099,"./event_data":1100,"./hover":1101,"./plot":1103,"./select":1104}],1103:[function(t,e,r){"use strict";var n=t("./convert");function i(t,e){this.subplot=t,this.uid=e,this.sourceIds={fill:e+"-source-fill",line:e+"-source-line",circle:e+"-source-circle",symbol:e+"-source-symbol"},this.layerIds={fill:e+"-layer-fill",line:e+"-layer-line",circle:e+"-layer-circle",symbol:e+"-layer-symbol"},this.order=["fill","line","circle","symbol"]}var a=i.prototype;a.addSource=function(t,e){this.subplot.map.addSource(this.sourceIds[t],{type:"geojson",data:e.geojson})},a.setSourceData=function(t,e){this.subplot.map.getSource(this.sourceIds[t]).setData(e.geojson)},a.addLayer=function(t,e){this.subplot.map.addLayer({type:t,id:this.layerIds[t],source:this.sourceIds[t],layout:e.layout,paint:e.paint})},a.update=function(t){for(var e=this.subplot,r=n(t),i=0;i")}e.exports={hoverPoints:function(t,e,r,i){var a=n(t,e,r,i);if(a&&!1!==a[0].index){var s=a[0];if(void 0===s.index)return a;var l=t.subplot,c=s.cd[s.index],u=s.trace;if(l.isPtInside(c))return s.xLabelVal=void 0,s.yLabelVal=void 0,o(c,u,l,s),a}},makeHoverPointText:o}},{"../../lib":696,"../../plots/cartesian/axes":744,"../scatter/hover":1054}],1109:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"scatterpolar",basePlotModule:t("../../plots/polar"),categories:["polar","symbols","showLegend","scatter-like"],attributes:t("./attributes"),supplyDefaults:t("./defaults").supplyDefaults,colorbar:t("../scatter/marker_colorbar"),calc:t("./calc"),plot:t("./plot"),style:t("../scatter/style").style,hoverPoints:t("./hover").hoverPoints,selectPoints:t("../scatter/select"),meta:{}}},{"../../plots/polar":811,"../scatter/marker_colorbar":1061,"../scatter/select":1064,"../scatter/style":1066,"./attributes":1105,"./calc":1106,"./defaults":1107,"./hover":1108,"./plot":1110}],1110:[function(t,e,r){"use strict";var n=t("../scatter/plot"),i=t("../../constants/numerical").BADNUM;e.exports=function(t,e,r){for(var a=e.layers.frontplot.select("g.scatterlayer"),o={xaxis:e.xaxis,yaxis:e.yaxis,plot:e.framework,layerClipId:e._hasClipOnAxisFalse?e.clipIds.forTraces:null},s=e.radialAxis,l=e.angularAxis,c=0;c=h&&(y.marker.cluster=d.tree),y.marker&&(y.markerSel.positions=y.markerUnsel.positions=y.marker.positions=_),y.line&&_.length>1&&c.extendFlat(y.line,l.linePositions(t,p,_)),y.text&&(c.extendFlat(y.text,{positions:_},l.textPosition(t,p,y.text,y.marker)),c.extendFlat(y.textSel,{positions:_},l.textPosition(t,p,y.text,y.markerSel)),c.extendFlat(y.textUnsel,{positions:_},l.textPosition(t,p,y.text,y.markerUnsel))),y.fill&&!u.fill2d&&(u.fill2d=!0),y.marker&&!u.scatter2d&&(u.scatter2d=!0),y.line&&!u.line2d&&(u.line2d=!0),y.text&&!u.glText&&(u.glText=!0),u.lineOptions.push(y.line),u.fillOptions.push(y.fill),u.markerOptions.push(y.marker),u.markerSelectedOptions.push(y.markerSel),u.markerUnselectedOptions.push(y.markerUnsel),u.textOptions.push(y.text),u.textSelectedOptions.push(y.textSel),u.textUnselectedOptions.push(y.textUnsel),d.x=w,d.y=k,d.rawx=w,d.rawy=k,d.r=v,d.theta=m,d.positions=_,d._scene=u,d.index=u.count,u.count++}}),a.plot(t,e,r)}},hoverPoints:function(t,e,r,n){var i=t.cd[0].t,o=i.r,s=i.theta,l=a.hoverPoints(t,e,r,n);if(l&&!1!==l[0].index){var c=l[0];if(void 0===c.index)return l;var u=t.subplot,h=c.cd[c.index],p=c.trace;if(h.r=o[c.index],h.theta=s[c.index],u.isPtInside(h))return c.xLabelVal=void 0,c.yLabelVal=void 0,f(h,p,u,c),l}},selectPoints:a.selectPoints,meta:{}}},{"../../lib":696,"../../plots/cartesian/axes":744,"../../plots/polar":811,"../scatter/calc":1044,"../scatter/colorscale_calc":1046,"../scatter/marker_colorbar":1061,"../scattergl":1096,"../scattergl/constants":1093,"../scattergl/convert":1094,"../scatterpolar/hover":1108,"./attributes":1111,"./defaults":1112,"fast-isnumeric":214,"point-cluster":452}],1114:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../components/colorbar/attributes"),s=t("../../components/drawing/attributes").dash,l=t("../../lib/extend").extendFlat,c=n.marker,u=n.line,f=c.line;e.exports={a:{valType:"data_array",editType:"calc"},b:{valType:"data_array",editType:"calc"},c:{valType:"data_array",editType:"calc"},sum:{valType:"number",dflt:0,min:0,editType:"calc"},mode:l({},n.mode,{dflt:"markers"}),text:l({},n.text,{}),hovertext:l({},n.hovertext,{}),line:{color:u.color,width:u.width,dash:s,shape:l({},u.shape,{values:["linear","spline"]}),smoothing:u.smoothing,editType:"calc"},connectgaps:n.connectgaps,cliponaxis:n.cliponaxis,fill:l({},n.fill,{values:["none","toself","tonext"],dflt:"none"}),fillcolor:n.fillcolor,marker:l({symbol:c.symbol,opacity:c.opacity,maxdisplayed:c.maxdisplayed,size:c.size,sizeref:c.sizeref,sizemin:c.sizemin,sizemode:c.sizemode,line:l({width:f.width,editType:"calc"},a("marker.line")),gradient:c.gradient,editType:"calc"},a("marker"),{colorbar:o}),textfont:n.textfont,textposition:n.textposition,selected:n.selected,unselected:n.unselected,hoverinfo:l({},i.hoverinfo,{flags:["a","b","c","text","name"]}),hoveron:n.hoveron}},{"../../components/colorbar/attributes":571,"../../components/colorscale/attributes":577,"../../components/drawing/attributes":594,"../../lib/extend":685,"../../plots/attributes":741,"../scatter/attributes":1043}],1115:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../scatter/colorscale_calc"),a=t("../scatter/arrays_to_calcdata"),o=t("../scatter/calc_selection"),s=t("../scatter/calc").calcMarkerSize,l=["a","b","c"],c={a:["b","c"],b:["a","c"],c:["a","b"]};e.exports=function(t,e){var r,u,f,h,p,d,g=t._fullLayout[e.subplot].sum,v=e.sum||g,m={a:e.a,b:e.b,c:e.c};for(r=0;r"),o}function m(t,e){v.push(t._hovertitle+": "+i.tickText(t,e,"hover").text)}}},{"../../plots/cartesian/axes":744,"../scatter/hover":1054}],1119:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("../scatter/style").style,n.styleOnSelect=t("../scatter/style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("../scatter/select"),n.eventData=t("./event_data"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","showLegend","scatter-like"],n.meta={},e.exports=n},{"../../plots/ternary":823,"../scatter/marker_colorbar":1061,"../scatter/select":1064,"../scatter/style":1066,"./attributes":1114,"./calc":1115,"./defaults":1116,"./event_data":1117,"./hover":1118,"./plot":1120}],1120:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e,r){var i=e.plotContainer;i.select(".scatterlayer").selectAll("*").remove();var a={xaxis:e.xaxis,yaxis:e.yaxis,plot:i,layerClipId:e._hasClipOnAxisFalse?e.clipIdRelative:null},o=e.layers.frontplot.select("g.scatterlayer");n(t,a,r,o)}},{"../scatter/plot":1063}],1121:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/colorscale/attributes"),a=t("../scattergl/attributes"),o=t("../../plots/cartesian/constants").idRegex,s=t("../../plot_api/plot_template").templatedArray,l=t("../../lib/extend").extendFlat,c=n.marker,u=c.line,f=l(i("marker.line",{editTypeOverride:"calc"}),{width:l({},u.width,{editType:"calc"}),editType:"calc"}),h=l(i("marker"),{symbol:c.symbol,size:l({},c.size,{editType:"markerSize"}),sizeref:c.sizeref,sizemin:c.sizemin,sizemode:c.sizemode,opacity:c.opacity,colorbar:c.colorbar,line:f,editType:"calc"});function p(t){return{valType:"info_array",freeLength:!0,editType:"calc",items:{valType:"subplotid",regex:o[t],editType:"plot"}}}h.color.editType=h.cmin.editType=h.cmax.editType="style",e.exports={dimensions:s("dimension",{visible:{valType:"boolean",dflt:!0,editType:"calc"},label:{valType:"string",editType:"calc"},values:{valType:"data_array",editType:"calc+clearAxisTypes"},axis:{type:{valType:"enumerated",values:["linear","log","date","category"],editType:"calc+clearAxisTypes"},editType:"calc+clearAxisTypes"},editType:"calc+clearAxisTypes"}),text:l({},a.text,{}),marker:h,xaxes:p("x"),yaxes:p("y"),diagonal:{visible:{valType:"boolean",dflt:!0,editType:"calc"},editType:"calc"},showupperhalf:{valType:"boolean",dflt:!0,editType:"calc"},showlowerhalf:{valType:"boolean",dflt:!0,editType:"calc"},selected:{marker:a.selected.marker,editType:"calc"},unselected:{marker:a.unselected.marker,editType:"calc"},opacity:a.opacity}},{"../../components/colorscale/attributes":577,"../../lib/extend":685,"../../plot_api/plot_template":734,"../../plots/cartesian/constants":750,"../scatter/attributes":1043,"../scattergl/attributes":1092}],1122:[function(t,e,r){"use strict";var n=t("regl-line2d"),i=t("../../registry"),a=t("../../lib/prepare_regl"),o=t("../../plots/get_data").getModuleCalcData,s=t("../../plots/cartesian"),l=t("../../plots/cartesian/axis_ids").getFromId,c=t("../../plots/cartesian/axes").shouldShowZeroLine,u="splom";function f(t,e,r){for(var n=r.matrixOptions.data.length,i=e._visibleDims,a=r.viewOpts.ranges=new Array(n),o=0;oa&&l?r._splomSubplots[S]=1:i-1,A="lasso"===y||"select"===y||!!h.selectedpoints||M;if(d.selectBatch=null,d.unselectBatch=null,A){var T=h._length;if(d.selectBatch||(d.selectBatch=[],d.unselectBatch=[]),h.selectedpoints){d.selectBatch=h.selectedpoints;var S=h.selectedpoints,E={};for(a=0;am?2*(x.sizeAvg||Math.max(x.size,3)):u(e,y),n=0;n2?t.slice(1,e-1):2===e?[(t[0]+t[1])/2]:t}function p(t){var e=t.length;return 1===e?[.5,.5]:[t[1]-t[0],t[e-1]-t[e-2]]}function d(t,e){var r=t.fullSceneLayout,i=t.dataScale,c=e._len,u={};function d(t,e){var n=r[e],o=i[l[e]];return a.simpleMap(t,function(t){return n.d2l(t)*o})}u.vectors=s(d(e.u,"xaxis"),d(e.v,"yaxis"),d(e.w,"zaxis"),c);var g=f(e.x.slice(0,c)),v=f(e.y.slice(0,c)),m=f(e.z.slice(0,c));if(g.length*v.length*m.length>c)return{positions:[],cells:[]};var y=d(g,"xaxis"),x=d(v,"yaxis"),b=d(m,"zaxis");if(u.meshgrid=[y,x,b],e.starts){var _=e._slen;u.startingPositions=s(d(e.starts.x.slice(0,_),"xaxis"),d(e.starts.y.slice(0,_),"yaxis"),d(e.starts.z.slice(0,_),"zaxis"))}else{for(var w=x[0],k=h(y),M=h(b),A=new Array(k.length*M.length),T=0,S=0;S",maxDimensionCount:60,overdrag:45,releaseTransitionDuration:120,releaseTransitionEase:"cubic-out",scrollbarCaptureWidth:18,scrollbarHideDelay:1e3,scrollbarHideDuration:1e3,scrollbarOffset:5,scrollbarWidth:8,transitionDuration:100,transitionEase:"cubic-out",uplift:5,wrapSpacer:" ",wrapSplitCharacter:" ",cn:{table:"table",tableControlView:"table-control-view",scrollBackground:"scroll-background",yColumn:"y-column",columnBlock:"column-block",scrollAreaClip:"scroll-area-clip",scrollAreaClipRect:"scroll-area-clip-rect",columnBoundary:"column-boundary",columnBoundaryClippath:"column-boundary-clippath",columnBoundaryRect:"column-boundary-rect",columnCells:"column-cells",columnCell:"column-cell",cellRect:"cell-rect",cellText:"cell-text",cellTextHolder:"cell-text-holder",scrollbarKit:"scrollbar-kit",scrollbar:"scrollbar",scrollbarSlider:"scrollbar-slider",scrollbarGlyph:"scrollbar-glyph",scrollbarCaptureZone:"scrollbar-capture-zone"}}},{}],1139:[function(t,e,r){"use strict";var n=t("./constants"),i=t("../../lib/extend").extendFlat,a=t("fast-isnumeric");function o(t){if(Array.isArray(t)){for(var e=0,r=0;r=e||c===t.length-1)&&(n[i]=o,o.key=l++,o.firstRowIndex=s,o.lastRowIndex=c,o={firstRowIndex:null,lastRowIndex:null,rows:[]},i+=a,s=c+1,a=0);return n}e.exports=function(t,e){var r=l(e.cells.values),p=function(t){return t.slice(e.header.values.length,t.length)},d=l(e.header.values);d.length&&!d[0].length&&(d[0]=[""],d=l(d));var g=d.concat(p(r).map(function(){return c((d[0]||[""]).length)})),v=e.domain,m=Math.floor(t._fullLayout._size.w*(v.x[1]-v.x[0])),y=Math.floor(t._fullLayout._size.h*(v.y[1]-v.y[0])),x=e.header.values.length?g[0].map(function(){return e.header.height}):[n.emptyHeaderHeight],b=r.length?r[0].map(function(){return e.cells.height}):[],_=x.reduce(s,0),w=h(b,y-_+n.uplift),k=f(h(x,_),[]),M=f(w,k),A={},T=e._fullInput.columnorder.concat(p(r.map(function(t,e){return e}))),S=g.map(function(t,r){var n=Array.isArray(e.columnwidth)?e.columnwidth[Math.min(r,e.columnwidth.length-1)]:e.columnwidth;return a(n)?Number(n):1}),E=S.reduce(s,0);S=S.map(function(t){return t/E*m});var C=Math.max(o(e.header.line.width),o(e.cells.line.width)),L={key:e.index,translateX:v.x[0]*t._fullLayout._size.w,translateY:t._fullLayout._size.h*(1-v.y[1]),size:t._fullLayout._size,width:m,maxLineWidth:C,height:y,columnOrder:T,groupHeight:y,rowBlocks:M,headerRowBlocks:k,scrollY:0,cells:i({},e.cells,{values:r}),headerCells:i({},e.header,{values:g}),gdColumns:g.map(function(t){return t[0]}),gdColumnsOriginalOrder:g.map(function(t){return t[0]}),prevPages:[0,0],scrollbarState:{scrollbarScrollInProgress:!1},columns:g.map(function(t,e){var r=A[t];return A[t]=(r||0)+1,{key:t+"__"+A[t],label:t,specIndex:e,xIndex:T[e],xScale:u,x:void 0,calcdata:void 0,columnWidth:S[e]}})};return L.columns.forEach(function(t){t.calcdata=L,t.x=u(t)}),L}},{"../../lib/extend":685,"./constants":1138,"fast-isnumeric":214}],1140:[function(t,e,r){"use strict";var n=t("../../lib/extend").extendFlat;r.splitToPanels=function(t){var e=[0,0],r=n({},t,{key:"header",type:"header",page:0,prevPages:e,currentRepaint:[null,null],dragHandle:!0,values:t.calcdata.headerCells.values[t.specIndex],rowBlocks:t.calcdata.headerRowBlocks,calcdata:n({},t.calcdata,{cells:t.calcdata.headerCells})});return[n({},t,{key:"cells1",type:"cells",page:0,prevPages:e,currentRepaint:[null,null],dragHandle:!1,values:t.calcdata.cells.values[t.specIndex],rowBlocks:t.calcdata.rowBlocks}),n({},t,{key:"cells2",type:"cells",page:1,prevPages:e,currentRepaint:[null,null],dragHandle:!1,values:t.calcdata.cells.values[t.specIndex],rowBlocks:t.calcdata.rowBlocks}),r]},r.splitToCells=function(t){var e=function(t){var e=t.rowBlocks[t.page],r=e?e.rows[0].rowIndex:0,n=e?r+e.rows.length:0;return[r,n]}(t);return(t.values||[]).slice(e[0],e[1]).map(function(r,n){return{keyWithinBlock:n+("string"==typeof r&&r.match(/[<$&> ]/)?"_keybuster_"+Math.random():""),key:e[0]+n,column:t,calcdata:t.calcdata,page:t.page,rowBlocks:t.rowBlocks,value:r}})}},{"../../lib/extend":685}],1141:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("../../plots/domain").defaults;e.exports=function(t,e,r,o){function s(r,a){return n.coerce(t,e,i,r,a)}a(e,o,s),s("columnwidth"),s("header.values"),s("header.format"),s("header.align"),s("header.prefix"),s("header.suffix"),s("header.height"),s("header.line.width"),s("header.line.color"),s("header.fill.color"),n.coerceFont(s,"header.font",n.extendFlat({},o.font)),function(t,e){for(var r=t.columnorder||[],n=t.header.values.length,i=r.slice(0,n),a=i.slice().sort(function(t,e){return t-e}),o=i.map(function(t){return a.indexOf(t)}),s=o.length;s/i),l=!o||s;t.mayHaveMarkup=o&&a.match(/[<&>]/);var c,u="string"==typeof(c=a)&&c.match(n.latexCheck);t.latex=u;var f,h,p=u?"":_(t.calcdata.cells.prefix,e,r)||"",d=u?"":_(t.calcdata.cells.suffix,e,r)||"",g=u?null:_(t.calcdata.cells.format,e,r)||null,v=p+(g?i.format(g)(t.value):t.value)+d;if(t.wrappingNeeded=!t.wrapped&&!l&&!u&&(f=b(v)),t.cellHeightMayIncrease=s||u||t.mayHaveMarkup||(void 0===f?b(v):f),t.needsConvertToTspans=t.mayHaveMarkup||t.wrappingNeeded||t.latex,t.wrappingNeeded){var m=(" "===n.wrapSplitCharacter?v.replace(/
i&&n.push(a),i+=l}return n}(i,l,s);1===c.length&&(c[0]===i.length-1?c.unshift(c[0]-1):c.push(c[0]+1)),c[0]%2&&c.reverse(),e.each(function(t,e){t.page=c[e],t.scrollY=l}),e.attr("transform",function(t){return"translate(0 "+(I(t.rowBlocks,t.page)-t.scrollY)+")"}),t&&(E(t,r,e,c,n.prevPages,n,0),E(t,r,e,c,n.prevPages,n,1),m(r,t))}}function S(t,e,r,a){return function(o){var s=o.calcdata?o.calcdata:o,l=e.filter(function(t){return s.key===t.key}),c=r||s.scrollbarState.dragMultiplier;s.scrollY=void 0===a?s.scrollY+c*i.event.dy:a;var u=l.selectAll("."+n.cn.yColumn).selectAll("."+n.cn.columnBlock).filter(k);T(t,u,l)}}function E(t,e,r,n,i,a,o){n[o]!==i[o]&&(clearTimeout(a.currentRepaint[o]),a.currentRepaint[o]=setTimeout(function(){var a=r.filter(function(t,e){return e===o&&n[e]!==i[e]});y(t,e,a,r),i[o]=n[o]}))}function C(t,e,r,a){return function(){var o=i.select(e.parentNode);o.each(function(t){var e=t.fragments;o.selectAll("tspan.line").each(function(t,r){e[r].width=this.getComputedTextLength()});var r,i,a=e[e.length-1].width,s=e.slice(0,-1),l=[],c=0,u=t.column.columnWidth-2*n.cellPad;for(t.value="";s.length;)c+(i=(r=s.shift()).width+a)>u&&(t.value+=l.join(n.wrapSpacer)+n.lineBreaker,l=[],c=0),l.push(r.text),c+=i;c&&(t.value+=l.join(n.wrapSpacer)),t.wrapped=!0}),o.selectAll("tspan.line").remove(),x(o.select("."+n.cn.cellText),r,t,a),i.select(e.parentNode.parentNode).call(O)}}function L(t,e,r,a,o){return function(){if(!o.settledY){var s=i.select(e.parentNode),l=R(o),c=o.key-l.firstRowIndex,u=l.rows[c].rowHeight,f=o.cellHeightMayIncrease?e.parentNode.getBoundingClientRect().height+2*n.cellPad:u,h=Math.max(f,u);h-l.rows[c].rowHeight&&(l.rows[c].rowHeight=h,t.selectAll("."+n.cn.columnCell).call(O),T(null,t.filter(k),0),m(r,a,!0)),s.attr("transform",function(){var t=this.parentNode.getBoundingClientRect(),e=i.select(this.parentNode).select("."+n.cn.cellRect).node().getBoundingClientRect(),r=this.transform.baseVal.consolidate(),a=e.top-t.top+(r?r.matrix.f:n.cellPad);return"translate("+z(o,i.select(this.parentNode).select("."+n.cn.cellTextHolder).node().getBoundingClientRect().width)+" "+a+")"}),o.settledY=!0}}}function z(t,e){switch(t.align){case"left":return n.cellPad;case"right":return t.column.columnWidth-(e||0)-n.cellPad;case"center":return(t.column.columnWidth-(e||0))/2;default:return n.cellPad}}function O(t){t.attr("transform",function(t){var e=t.rowBlocks[0].auxiliaryBlocks.reduce(function(t,e){return t+P(e,1/0)},0);return"translate(0 "+(P(R(t),t.key)+e)+")"}).selectAll("."+n.cn.cellRect).attr("height",function(t){return(e=R(t),r=t.key,e.rows[r-e.firstRowIndex]).rowHeight;var e,r})}function I(t,e){for(var r=0,n=e-1;n>=0;n--)r+=D(t[n]);return r}function P(t,e){for(var r=0,n=0;n0){var y,x,b,_,w,k=t.xa,M=t.ya;"h"===h.orientation?(w=e,y="y",b=M,x="x",_=k):(w=r,y="x",b=k,x="y",_=M);var A=f[t.index];if(w>=A.span[0]&&w<=A.span[1]){var T=n.extendFlat({},t),S=_.c2p(w,!0),E=o.getKdeValue(A,h,w),C=o.getPositionOnKdePath(A,h,S),L=b._offset,z=b._length;T[y+"0"]=C[0],T[y+"1"]=C[1],T[x+"0"]=T[x+"1"]=S,T[x+"Label"]=x+": "+i.hoverLabelText(_,w)+", "+f[0].t.labels.kde+" "+E.toFixed(3),T.spikeDistance=m[0].spikeDistance;var O=y+"Spike";T[O]=m[0][O],m[0].spikeDistance=void 0,m[0][O]=void 0,v.push(T),(u={stroke:t.color})[y+"1"]=n.constrain(L+C[0],L,L+z),u[y+"2"]=n.constrain(L+C[1],L,L+z),u[x+"1"]=u[x+"2"]=_._offset+S}}}-1!==p.indexOf("points")&&(c=a.hoverOnPoints(t,e,r));var I=l.selectAll(".violinline-"+h.uid).data(u?[0]:[]);return I.enter().append("line").classed("violinline-"+h.uid,!0).attr("stroke-width",1.5),I.exit().remove(),I.attr(u),"closest"===s?c?[c]:v:c?(v.push(c),v):v}},{"../../lib":696,"../../plots/cartesian/axes":744,"../box/hover":864,"./helpers":1148}],1150:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),crossTraceCalc:t("./cross_trace_calc"),plot:t("./plot"),style:t("./style"),styleOnSelect:t("../scatter/style").styleOnSelect,hoverPoints:t("./hover"),selectPoints:t("../box/select"),moduleType:"trace",name:"violin",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","symbols","oriented","box-violin","showLegend","violinLayout","zoomScale"],meta:{}}},{"../../plots/cartesian":756,"../box/select":869,"../scatter/style":1066,"./attributes":1144,"./calc":1145,"./cross_trace_calc":1146,"./defaults":1147,"./hover":1149,"./layout_attributes":1151,"./layout_defaults":1152,"./plot":1153,"./style":1154}],1151:[function(t,e,r){"use strict";var n=t("../box/layout_attributes"),i=t("../../lib").extendFlat;e.exports={violinmode:i({},n.boxmode,{}),violingap:i({},n.boxgap,{}),violingroupgap:i({},n.boxgroupgap,{})}},{"../../lib":696,"../box/layout_attributes":866}],1152:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes"),a=t("../box/layout_defaults");e.exports=function(t,e,r){a._supply(t,e,r,function(r,a){return n.coerce(t,e,i,r,a)},"violin")}},{"../../lib":696,"../box/layout_defaults":867,"./layout_attributes":1151}],1153:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../components/drawing"),o=t("../box/plot"),s=t("../scatter/line_points"),l=t("./helpers");e.exports=function(t,e,r,c){var u=t._fullLayout,f=e.xaxis,h=e.yaxis;function p(t){var e=s(t,{xaxis:f,yaxis:h,connectGaps:!0,baseTolerance:.75,shape:"spline",simplify:!0});return a.smoothopen(e[0],1)}i.makeTraceGroups(c,r,"trace violins").each(function(t){var r=n.select(this),a=t[0],s=a.t,c=a.trace;e.isRangePlot||(a.node3=r);var d=u._numViolins,g="group"===u.violinmode&&d>1,v=1-u.violingap,m=s.bdPos=s.dPos*v*(1-u.violingroupgap)/(g?d:1),y=s.bPos=g?2*s.dPos*((s.num+.5)/d-.5)*v:0;if(s.wHover=s.dPos*(g?v/d:1),!0!==c.visible||s.empty)r.remove();else{var x=e[s.valLetter+"axis"],b=e[s.posLetter+"axis"],_="both"===c.side,w=_||"positive"===c.side,k=_||"negative"===c.side,M=u._violinScaleGroupStats[c.scalegroup],A=r.selectAll("path.violin").data(i.identity);A.enter().append("path").style("vector-effect","non-scaling-stroke").attr("class","violin"),A.exit().remove(),A.each(function(t){var e,r,i,a,o,l,u,f,h=n.select(this),d=t.density,g=d.length,v=t.pos+y,A=b.c2p(v);switch(c.scalemode){case"width":e=M.maxWidth/m;break;case"count":e=M.maxWidth/m*(M.maxCount/t.pts.length)}if(w){for(u=new Array(g),o=0;oa&&(a=u,o=c)}}return a?i(o):s};case"rms":return function(t,e){for(var r=0,a=0,o=0;o":return function(t){return h(t)>s};case">=":return function(t){return h(t)>=s};case"[]":return function(t){var e=h(t);return e>=s[0]&&e<=s[1]};case"()":return function(t){var e=h(t);return e>s[0]&&e=s[0]&&es[0]&&e<=s[1]};case"][":return function(t){var e=h(t);return e<=s[0]||e>=s[1]};case")(":return function(t){var e=h(t);return es[1]};case"](":return function(t){var e=h(t);return e<=s[0]||e>s[1]};case")[":return function(t){var e=h(t);return e=s[1]};case"{}":return function(t){return-1!==s.indexOf(h(t))};case"}{":return function(t){return-1===s.indexOf(h(t))}}}(r,a.getDataToCoordFunc(t,e,s,i),h),x={},b={},_=0;d?(v=function(t){x[t.astr]=n.extendDeep([],t.get()),t.set(new Array(f))},m=function(t,e){var r=x[t.astr][e];t.get()[e]=r}):(v=function(t){x[t.astr]=n.extendDeep([],t.get()),t.set([])},m=function(t,e){var r=x[t.astr][e];t.get().push(r)}),M(v);for(var w=o(e.transforms,r),k=0;k1?"%{group} (%{trace})":"%{group}");var l=t.styles,c=o.styles=[];if(l)for(a=0;a:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;margin-left:0px;margin-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var a in i){var o=a.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");n.addStyleRule(o,i[a])}},{"../src/lib":692}],2:[function(t,e,r){"use strict";e.exports={undo:{width:857.1,height:1e3,path:"m857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z",transform:"matrix(1 0 0 -1 0 850)"},home:{width:928.6,height:1e3,path:"m786 296v-267q0-15-11-26t-25-10h-214v214h-143v-214h-214q-15 0-25 10t-11 26v267q0 1 0 2t0 2l321 264 321-264q1-1 1-4z m124 39l-34-41q-5-5-12-6h-2q-7 0-12 3l-386 322-386-322q-7-4-13-4-7 2-12 7l-35 41q-4 5-3 13t6 12l401 334q18 15 42 15t43-15l136-114v109q0 8 5 13t13 5h107q8 0 13-5t5-13v-227l122-102q5-5 6-12t-4-13z",transform:"matrix(1 0 0 -1 0 850)"},"camera-retro":{width:1e3,height:1e3,path:"m518 386q0 8-5 13t-13 5q-37 0-63-27t-26-63q0-8 5-13t13-5 12 5 5 13q0 23 16 38t38 16q8 0 13 5t5 13z m125-73q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101z m-572-320h858v71h-858v-71z m643 320q0 89-62 152t-152 62-151-62-63-152 63-151 151-63 152 63 62 151z m-571 358h214v72h-214v-72z m-72-107h858v143h-462l-36-71h-360v-72z m929 143v-714q0-30-21-51t-50-21h-858q-29 0-50 21t-21 51v714q0 30 21 51t50 21h858q29 0 50-21t21-51z",transform:"matrix(1 0 0 -1 0 850)"},zoombox:{width:1e3,height:1e3,path:"m1000-25l-250 251c40 63 63 138 63 218 0 224-182 406-407 406-224 0-406-182-406-406s183-406 407-406c80 0 155 22 218 62l250-250 125 125z m-812 250l0 438 437 0 0-438-437 0z m62 375l313 0 0-312-313 0 0 312z",transform:"matrix(1 0 0 -1 0 850)"},pan:{width:1e3,height:1e3,path:"m1000 350l-187 188 0-125-250 0 0 250 125 0-188 187-187-187 125 0 0-250-250 0 0 125-188-188 186-187 0 125 252 0 0-250-125 0 187-188 188 188-125 0 0 250 250 0 0-126 187 188z",transform:"matrix(1 0 0 -1 0 850)"},zoom_plus:{width:875,height:1e3,path:"m1 787l0-875 875 0 0 875-875 0z m687-500l-187 0 0-187-125 0 0 187-188 0 0 125 188 0 0 187 125 0 0-187 187 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},zoom_minus:{width:875,height:1e3,path:"m0 788l0-876 875 0 0 876-875 0z m688-500l-500 0 0 125 500 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},autoscale:{width:1e3,height:1e3,path:"m250 850l-187 0-63 0 0-62 0-188 63 0 0 188 187 0 0 62z m688 0l-188 0 0-62 188 0 0-188 62 0 0 188 0 62-62 0z m-875-938l0 188-63 0 0-188 0-62 63 0 187 0 0 62-187 0z m875 188l0-188-188 0 0-62 188 0 62 0 0 62 0 188-62 0z m-125 188l-1 0-93-94-156 156 156 156 92-93 2 0 0 250-250 0 0-2 93-92-156-156-156 156 94 92 0 2-250 0 0-250 0 0 93 93 157-156-157-156-93 94 0 0 0-250 250 0 0 0-94 93 156 157 156-157-93-93 0 0 250 0 0 250z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_basic:{width:1500,height:1e3,path:"m375 725l0 0-375-375 375-374 0-1 1125 0 0 750-1125 0z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_compare:{width:1125,height:1e3,path:"m187 786l0 2-187-188 188-187 0 0 937 0 0 373-938 0z m0-499l0 1-187-188 188-188 0 0 937 0 0 376-938-1z",transform:"matrix(1 0 0 -1 0 850)"},plotlylogo:{width:1542,height:1e3,path:"m0-10h182v-140h-182v140z m228 146h183v-286h-183v286z m225 714h182v-1000h-182v1000z m225-285h182v-715h-182v715z m225 142h183v-857h-183v857z m231-428h182v-429h-182v429z m225-291h183v-138h-183v138z",transform:"matrix(1 0 0 -1 0 850)"},"z-axis":{width:1e3,height:1e3,path:"m833 5l-17 108v41l-130-65 130-66c0 0 0 38 0 39 0-1 36-14 39-25 4-15-6-22-16-30-15-12-39-16-56-20-90-22-187-23-279-23-261 0-341 34-353 59 3 60 228 110 228 110-140-8-351-35-351-116 0-120 293-142 474-142 155 0 477 22 477 142 0 50-74 79-163 96z m-374 94c-58-5-99-21-99-40 0-24 65-43 144-43 79 0 143 19 143 43 0 19-42 34-98 40v216h87l-132 135-133-135h88v-216z m167 515h-136v1c16 16 31 34 46 52l84 109v54h-230v-71h124v-1c-16-17-28-32-44-51l-89-114v-51h245v72z",transform:"matrix(1 0 0 -1 0 850)"},"3d_rotate":{width:1e3,height:1e3,path:"m922 660c-5 4-9 7-14 11-359 263-580-31-580-31l-102 28 58-400c0 1 1 1 2 2 118 108 351 249 351 249s-62 27-100 42c88 83 222 183 347 122 16-8 30-17 44-27-2 1-4 2-6 4z m36-329c0 0 64 229-88 296-62 27-124 14-175-11 157-78 225-208 249-266 8-19 11-31 11-31 2 5 6 15 11 32-5-13-8-20-8-20z m-775-239c70-31 117-50 198-32-121 80-199 346-199 346l-96-15-58-12c0 0 55-226 155-287z m603 133l-317-139c0 0 4-4 19-14 7-5 24-15 24-15s-177-147-389 4c235-287 536-112 536-112l31-22 100 299-4-1z m-298-153c6-4 14-9 24-15 0 0-17 10-24 15z",transform:"matrix(1 0 0 -1 0 850)"},camera:{width:1e3,height:1e3,path:"m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z m400 150h-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28l-31-94c-6-15-23-28-40-28h-120c-55 0-100-45-100-100v-450c0-55 45-100 100-100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250-250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35-35z",transform:"matrix(1 0 0 -1 0 850)"},movie:{width:1e3,height:1e3,path:"m938 413l-188-125c0 37-17 71-44 94 64 38 107 107 107 187 0 121-98 219-219 219-121 0-219-98-219-219 0-61 25-117 66-156h-115c30 33 49 76 49 125 0 103-84 187-187 187s-188-84-188-187c0-57 26-107 65-141-38-22-65-62-65-109v-250c0-70 56-126 125-126h500c69 0 125 56 125 126l188-126c34 0 62 28 62 63v375c0 35-28 63-62 63z m-750 0c-69 0-125 56-125 125s56 125 125 125 125-56 125-125-56-125-125-125z m406-1c-87 0-157 70-157 157 0 86 70 156 157 156s156-70 156-156-70-157-156-157z",transform:"matrix(1 0 0 -1 0 850)"},question:{width:857.1,height:1e3,path:"m500 82v107q0 8-5 13t-13 5h-107q-8 0-13-5t-5-13v-107q0-8 5-13t13-5h107q8 0 13 5t5 13z m143 375q0 49-31 91t-77 65-95 23q-136 0-207-119-9-14 4-24l74-55q4-4 10-4 9 0 14 7 30 38 48 51 19 14 48 14 27 0 48-15t21-33q0-21-11-34t-38-25q-35-16-65-48t-29-70v-20q0-8 5-13t13-5h107q8 0 13 5t5 13q0 10 12 27t30 28q18 10 28 16t25 19 25 27 16 34 7 45z m214-107q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z",transform:"matrix(1 0 0 -1 0 850)"},disk:{width:857.1,height:1e3,path:"m214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z",transform:"matrix(1 0 0 -1 0 850)"},lasso:{width:1031,height:1e3,path:"m1018 538c-36 207-290 336-568 286-277-48-473-256-436-463 10-57 36-108 76-151-13-66 11-137 68-183 34-28 75-41 114-42l-55-70 0 0c-2-1-3-2-4-3-10-14-8-34 5-45 14-11 34-8 45 4 1 1 2 3 2 5l0 0 113 140c16 11 31 24 45 40 4 3 6 7 8 11 48-3 100 0 151 9 278 48 473 255 436 462z m-624-379c-80 14-149 48-197 96 42 42 109 47 156 9 33-26 47-66 41-105z m-187-74c-19 16-33 37-39 60 50-32 109-55 174-68-42-25-95-24-135 8z m360 75c-34-7-69-9-102-8 8 62-16 128-68 170-73 59-175 54-244-5-9 20-16 40-20 61-28 159 121 317 333 354s407-60 434-217c28-159-121-318-333-355z",transform:"matrix(1 0 0 -1 0 850)"},selectbox:{width:1e3,height:1e3,path:"m0 850l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-285l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z",transform:"matrix(1 0 0 -1 0 850)"},spikeline:{width:1e3,height:1e3,path:"M512 409c0-57-46-104-103-104-57 0-104 47-104 104 0 57 47 103 104 103 57 0 103-46 103-103z m-327-39l92 0 0 92-92 0z m-185 0l92 0 0 92-92 0z m370-186l92 0 0 93-92 0z m0-184l92 0 0 92-92 0z",transform:"matrix(1.5 0 0 -1.5 0 850)"},newplotlylogo:{name:"newplotlylogo",svg:"plotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/transforms/aggregate")},{"../src/transforms/aggregate":1152}],4:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":840}],5:[function(t,e,r){"use strict";e.exports=t("../src/traces/barpolar")},{"../src/traces/barpolar":852}],6:[function(t,e,r){"use strict";e.exports=t("../src/traces/box")},{"../src/traces/box":862}],7:[function(t,e,r){"use strict";e.exports=t("../src/components/calendars")},{"../src/components/calendars":567}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/candlestick")},{"../src/traces/candlestick":871}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/carpet")},{"../src/traces/carpet":890}],10:[function(t,e,r){"use strict";e.exports=t("../src/traces/choropleth")},{"../src/traces/choropleth":904}],11:[function(t,e,r){"use strict";e.exports=t("../src/traces/cone")},{"../src/traces/cone":912}],12:[function(t,e,r){"use strict";e.exports=t("../src/traces/contour")},{"../src/traces/contour":927}],13:[function(t,e,r){"use strict";e.exports=t("../src/traces/contourcarpet")},{"../src/traces/contourcarpet":938}],14:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":671}],15:[function(t,e,r){"use strict";e.exports=t("../src/transforms/filter")},{"../src/transforms/filter":1153}],16:[function(t,e,r){"use strict";e.exports=t("../src/transforms/groupby")},{"../src/transforms/groupby":1154}],17:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmap")},{"../src/traces/heatmap":950}],18:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmapgl")},{"../src/traces/heatmapgl":959}],19:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram")},{"../src/traces/histogram":971}],20:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2d")},{"../src/traces/histogram2d":978}],21:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2dcontour")},{"../src/traces/histogram2dcontour":982}],22:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./box"),t("./heatmap"),t("./histogram"),t("./histogram2d"),t("./histogram2dcontour"),t("./pie"),t("./contour"),t("./scatterternary"),t("./violin"),t("./scatter3d"),t("./surface"),t("./mesh3d"),t("./cone"),t("./streamtube"),t("./scattergeo"),t("./choropleth"),t("./scattergl"),t("./splom"),t("./pointcloud"),t("./heatmapgl"),t("./parcoords"),t("./parcats"),t("./scattermapbox"),t("./sankey"),t("./table"),t("./carpet"),t("./scattercarpet"),t("./contourcarpet"),t("./ohlc"),t("./candlestick"),t("./scatterpolar"),t("./scatterpolargl"),t("./barpolar")]),n.register([t("./aggregate"),t("./filter"),t("./groupby"),t("./sort")]),n.register([t("./calendars")]),e.exports=n},{"./aggregate":3,"./bar":4,"./barpolar":5,"./box":6,"./calendars":7,"./candlestick":8,"./carpet":9,"./choropleth":10,"./cone":11,"./contour":12,"./contourcarpet":13,"./core":14,"./filter":15,"./groupby":16,"./heatmap":17,"./heatmapgl":18,"./histogram":19,"./histogram2d":20,"./histogram2dcontour":21,"./mesh3d":23,"./ohlc":24,"./parcats":25,"./parcoords":26,"./pie":27,"./pointcloud":28,"./sankey":29,"./scatter3d":30,"./scattercarpet":31,"./scattergeo":32,"./scattergl":33,"./scattermapbox":34,"./scatterpolar":35,"./scatterpolargl":36,"./scatterternary":37,"./sort":38,"./splom":39,"./streamtube":40,"./surface":41,"./table":42,"./violin":43}],23:[function(t,e,r){"use strict";e.exports=t("../src/traces/mesh3d")},{"../src/traces/mesh3d":987}],24:[function(t,e,r){"use strict";e.exports=t("../src/traces/ohlc")},{"../src/traces/ohlc":992}],25:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcats")},{"../src/traces/parcats":1001}],26:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcoords")},{"../src/traces/parcoords":1010}],27:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":1021}],28:[function(t,e,r){"use strict";e.exports=t("../src/traces/pointcloud")},{"../src/traces/pointcloud":1030}],29:[function(t,e,r){"use strict";e.exports=t("../src/traces/sankey")},{"../src/traces/sankey":1036}],30:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatter3d")},{"../src/traces/scatter3d":1072}],31:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattercarpet")},{"../src/traces/scattercarpet":1078}],32:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergeo")},{"../src/traces/scattergeo":1085}],33:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergl")},{"../src/traces/scattergl":1093}],34:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattermapbox")},{"../src/traces/scattermapbox":1099}],35:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterpolar")},{"../src/traces/scatterpolar":1106}],36:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterpolargl")},{"../src/traces/scatterpolargl":1110}],37:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterternary")},{"../src/traces/scatterternary":1116}],38:[function(t,e,r){"use strict";e.exports=t("../src/transforms/sort")},{"../src/transforms/sort":1156}],39:[function(t,e,r){"use strict";e.exports=t("../src/traces/splom")},{"../src/traces/splom":1121}],40:[function(t,e,r){"use strict";e.exports=t("../src/traces/streamtube")},{"../src/traces/streamtube":1126}],41:[function(t,e,r){"use strict";e.exports=t("../src/traces/surface")},{"../src/traces/surface":1131}],42:[function(t,e,r){"use strict";e.exports=t("../src/traces/table")},{"../src/traces/table":1139}],43:[function(t,e,r){"use strict";e.exports=t("../src/traces/violin")},{"../src/traces/violin":1147}],44:[function(t,e,r){"use strict";e.exports=function(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]);"zoomMin"in e&&(r[0]=e.zoomMin);"zoomMax"in e&&(r[1]=e.zoomMax);var c=i({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=0,h=t.clientWidth,p=t.clientHeight,d={view:c,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:c.modes,tick:function(){var e=n(),r=this.delay;c.idle(e-r),c.flush(e-(100+2*r));var i=e-2*r;c.recalcMatrix(i);for(var a=!0,o=c.computedMatrix,s=0;s<16;++s)a=a&&u[s]===o[s],u[s]=o[s];var l=t.clientWidth===h&&t.clientHeight===p;return h=t.clientWidth,p=t.clientHeight,a?!l:(f=Math.exp(c.computedRadius[0]),!0)},lookAt:function(t,e,r){c.lookAt(c.lastT(),t,e,r)},rotate:function(t,e,r){c.rotate(c.lastT(),t,e,r)},pan:function(t,e,r){c.pan(c.lastT(),t,e,r)},translate:function(t,e,r){c.translate(c.lastT(),t,e,r)}};Object.defineProperties(d,{matrix:{get:function(){return c.computedMatrix},set:function(t){return c.setMatrix(c.lastT(),t),c.computedMatrix},enumerable:!0},mode:{get:function(){return c.getMode()},set:function(t){return c.setMode(t),c.getMode()},enumerable:!0},center:{get:function(){return c.computedCenter},set:function(t){return c.lookAt(c.lastT(),t),c.computedCenter},enumerable:!0},eye:{get:function(){return c.computedEye},set:function(t){return c.lookAt(c.lastT(),null,t),c.computedEye},enumerable:!0},up:{get:function(){return c.computedUp},set:function(t){return c.lookAt(c.lastT(),null,null,t),c.computedUp},enumerable:!0},distance:{get:function(){return f},set:function(t){return c.setDistance(c.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return c.getDistanceLimits(r)},set:function(t){return c.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var g=0,v=0,m={shift:!1,control:!1,alt:!1,meta:!1};function y(e,r,i,a){var o=1/t.clientHeight,s=o*(r-g),l=o*(i-v),u=d.flipX?1:-1,h=d.flipY?1:-1,p=Math.PI*d.rotateSpeed,y=n();if(1&e)a.shift?c.rotate(y,0,0,-s*p):c.rotate(y,u*p*s,-h*p*l,0);else if(2&e)c.pan(y,-d.translateSpeed*s*f,d.translateSpeed*l*f,0);else if(4&e){var x=d.zoomSpeed*l/window.innerHeight*(y-c.lastT())*50;c.pan(y,0,0,f*(Math.exp(x)-1))}g=r,v=i,m=a}return a(t,y),t.addEventListener("touchstart",function(e){var r=s(e.changedTouches[0],t);y(0,r[0],r[1],m),y(1,r[0],r[1],m),e.preventDefault()},!!l&&{passive:!1}),t.addEventListener("touchmove",function(e){var r=s(e.changedTouches[0],t);y(1,r[0],r[1],m),e.preventDefault()},!!l&&{passive:!1}),t.addEventListener("touchend",function(e){s(e.changedTouches[0],t),y(0,g,v,m),e.preventDefault()},!!l&&{passive:!1}),o(t,function(t,e,r){var i=d.flipX?1:-1,a=d.flipY?1:-1,o=n();if(Math.abs(t)>Math.abs(e))c.rotate(o,0,0,-t*i*Math.PI*d.rotateSpeed/window.innerWidth);else{var s=d.zoomSpeed*a*e/window.innerHeight*(o-c.lastT())/100;c.pan(o,0,0,f*(Math.exp(s)-1))}},!0),d};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset"),l=t("has-passive-events")},{"3d-view":45,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421,"right-now":480}],45:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).eye||[0,0,1],r=t.center||[0,0,0],s=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=n(),f=i(),h=a();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,s),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,s),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,s),new o({turntable:u,orbit:f,matrix:h},c)};var n=t("turntable-camera-controller"),i=t("orbit-camera-controller"),a=t("matrix-camera-controller");function o(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.turntable),this.modes=this._controllerNames,this.computedMatrix=this._active.computedMatrix,this.computedEye=this._active.computedEye,this.computedUp=this._active.computedUp,this.computedCenter=this._active.computedCenter,this.computedRadius=this._active.computedRadius}var s=o.prototype;[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]].forEach(function(t){for(var e=t[0],r=[],n=0;nr&&(a=r);var i=e.min(n,function(t){return(o[1]-(t.length-1)*a)/e.sum(t,h)});n.forEach(function(t){t.forEach(function(t,e){t.y=e,t.dy=t.value*i})}),l.forEach(function(t){t.dy=t.value*i})})(),d();for(var i=1;t>0;--t)p(i*=.99),d(),u(i),d();function u(t){function r(t){return f(t.source)*t.value}n.forEach(function(n){n.forEach(function(n){if(n.targetLinks.length){var i=e.sum(n.targetLinks,r)/e.sum(n.targetLinks,h);n.y+=(i-f(n))*t}})})}function p(t){function r(t){return f(t.target)*t.value}n.slice().reverse().forEach(function(n){n.forEach(function(n){if(n.sourceLinks.length){var i=e.sum(n.sourceLinks,r)/e.sum(n.sourceLinks,h);n.y+=(i-f(n))*t}})})}function d(){n.forEach(function(t){var e,r,n,i=0,s=t.length;for(t.sort(g),n=0;n0&&(e.y+=r),i=e.y+e.dy+a;if((r=i-a-o[1])>0)for(i=e.y-=r,n=s-2;n>=0;--n)e=t[n],(r=e.y+e.dy+a-i)>0&&(e.y-=r),i=e.y})}function g(t,e){return t.y-e.y}}(n),u(),t},t.relayout=function(){return u(),t},t.link=function(){var t=.5;function e(e){var r=e.source.x+e.source.dx,i=e.target.x,a=n.interpolateNumber(r,i),o=a(t),s=a(1-t),l=e.source.y+e.sy,c=l+e.dy,u=e.target.y+e.ty,f=u+e.dy;return"M"+r+","+l+"C"+o+","+l+" "+s+","+u+" "+i+","+u+"L"+i+","+f+"C"+s+","+f+" "+o+","+c+" "+r+","+c+"Z"}return e.curvature=function(r){return arguments.length?(t=+r,e):t},e},t},Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof r&&"undefined"!=typeof e?i(r,t("d3-array"),t("d3-collection"),t("d3-interpolate")):i(n.d3=n.d3||{},n.d3,n.d3,n.d3)},{"d3-array":140,"d3-collection":141,"d3-interpolate":145}],47:[function(t,e,r){"use strict";var n="undefined"==typeof WeakMap?t("weak-map"):WeakMap,i=t("gl-buffer"),a=t("gl-vao"),o=new n;e.exports=function(t){var e=o.get(t),r=e&&(e._triangleBuffer.handle||e._triangleBuffer.buffer);if(!r||!t.isBuffer(r)){var n=i(t,new Float32Array([-1,-1,-1,4,4,-1]));(e=a(t,[{buffer:n,type:t.FLOAT,size:2}]))._triangleBuffer=n,o.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}},{"gl-buffer":230,"gl-vao":310,"weak-map":528}],48:[function(t,e,r){e.exports=function(t){var e=0,r=0,n=0,i=0;return t.map(function(t){var a=(t=t.slice())[0],o=a.toUpperCase();if(a!=o)switch(t[0]=o,a){case"a":t[6]+=n,t[7]+=i;break;case"v":t[1]+=i;break;case"h":t[1]+=n;break;default:for(var s=1;si&&(i=t[o]),t[o]=0;c--)if(u[c]!==f[c])return!1;for(c=u.length-1;c>=0;c--)if(l=u[c],!y(t[l],e[l],r,n))return!1;return!0}(t,e,r,o))}return r?t===e:t==e}function x(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function b(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function _(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&v(i,r,"Missing expected exception"+n);var o="string"==typeof n,s=!t&&i&&!r;if((!t&&a.isError(i)&&o&&b(i,r)||s)&&v(i,r,"Got unwanted exception"+n),t&&i&&r&&!b(i,r)||!t&&i)throw i}f.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=d(g((e=this).actual),128)+" "+e.operator+" "+d(g(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,a=p(r),o=i.indexOf("\n"+a);if(o>=0){var s=i.indexOf("\n",o+1);i=i.substring(s+1)}this.stack=i}}},a.inherits(f.AssertionError,Error),f.fail=v,f.ok=m,f.equal=function(t,e,r){t!=e&&v(t,e,r,"==",f.equal)},f.notEqual=function(t,e,r){t==e&&v(t,e,r,"!=",f.notEqual)},f.deepEqual=function(t,e,r){y(t,e,!1)||v(t,e,r,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(t,e,r){y(t,e,!0)||v(t,e,r,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(t,e,r){y(t,e,!1)&&v(t,e,r,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function t(e,r,n){y(e,r,!0)&&v(e,r,n,"notDeepStrictEqual",t)},f.strictEqual=function(t,e,r){t!==e&&v(t,e,r,"===",f.strictEqual)},f.notStrictEqual=function(t,e,r){t===e&&v(t,e,r,"!==",f.notStrictEqual)},f.throws=function(t,e,r){_(!0,t,e,r)},f.doesNotThrow=function(t,e,r){_(!1,t,e,r)},f.ifError=function(t){if(t)throw t};var w=Object.keys||function(t){var e=[];for(var r in t)o.call(t,r)&&e.push(r);return e}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":59}],57:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],58:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],59:[function(t,e,r){(function(e,n){var i=/%[sdj%]/g;r.format=function(t){if(!m(t)){for(var e=[],r=0;r=a)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),l=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(e)?n.showHidden=e:e&&r._extend(n,e),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=l),u(n,t,n.depth)}function l(t,e){var r=s.styles[e];return r?"\x1b["+s.colors[r][0]+"m"+t+"\x1b["+s.colors[r][1]+"m":t}function c(t,e){return t}function u(t,e,n){if(t.customInspect&&e&&k(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return m(i)||(i=u(t,i,n)),i}var a=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(v(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,e);if(a)return a;var o=Object.keys(e),s=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),w(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(e);if(0===o.length){if(k(e)){var l=e.name?": "+e.name:"";return t.stylize("[Function"+l+"]","special")}if(x(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(w(e))return f(e)}var c,b="",M=!1,A=["{","}"];(p(e)&&(M=!0,A=["[","]"]),k(e))&&(b=" [Function"+(e.name?": "+e.name:"")+"]");return x(e)&&(b=" "+RegExp.prototype.toString.call(e)),_(e)&&(b=" "+Date.prototype.toUTCString.call(e)),w(e)&&(b=" "+f(e)),0!==o.length||M&&0!=e.length?n<0?x(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=M?function(t,e,r,n,i){for(var a=[],o=0,s=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,b,A)):A[0]+b+A[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i,a){var o,s,l;if((l=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=l.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):l.set&&(s=t.stylize("[Setter]","special")),S(n,i)||(o="["+i+"]"),s||(t.seen.indexOf(l.value)<0?(s=g(r)?u(t,l.value,null):u(t,l.value,r-1)).indexOf("\n")>-1&&(s=a?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),y(o)){if(a&&i.match(/^\d+$/))return s;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+s}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function v(t){return"number"==typeof t}function m(t){return"string"==typeof t}function y(t){return void 0===t}function x(t){return b(t)&&"[object RegExp]"===M(t)}function b(t){return"object"==typeof t&&null!==t}function _(t){return b(t)&&"[object Date]"===M(t)}function w(t){return b(t)&&("[object Error]"===M(t)||t instanceof Error)}function k(t){return"function"==typeof t}function M(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(y(a)&&(a=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(a)){var n=e.pid;o[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else o[t]=function(){};return o[t]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=p,r.isBoolean=d,r.isNull=g,r.isNullOrUndefined=function(t){return null==t},r.isNumber=v,r.isString=m,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=y,r.isRegExp=x,r.isObject=b,r.isDate=_,r.isError=w,r.isFunction=k,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t},r.isBuffer=t("./support/isBuffer");var T=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function S(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),T[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!b(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":58,_process:465,inherits:57}],60:[function(t,e,r){e.exports=function(t){return atob(t)}},{}],61:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=e.length,a=new Array(r+1),o=0;o0?n-4:n,f=0;f>16&255,s[l++]=e>>8&255,s[l++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,s[l++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,s[l++]=e>>8&255,s[l++]=255&e);return s},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,a=[],o=0,s=r-i;os?s:o+16383));1===i?(e=t[r-1],a.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],a.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,r){for(var i,a,o=[],s=e;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],63:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}},{"./lib/rationalize":73}],64:[function(t,e,r){"use strict";e.exports=function(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}},{}],65:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]),t[1].mul(e[0]))}},{"./lib/rationalize":73}],66:[function(t,e,r){"use strict";var n=t("./is-rat"),i=t("./lib/is-bn"),a=t("./lib/num-to-bn"),o=t("./lib/str-to-bn"),s=t("./lib/rationalize"),l=t("./div");e.exports=function t(e,r){if(n(e))return r?l(e,t(r)):[e[0].clone(),e[1].clone()];var c=0;var u,f;if(i(e))u=e.clone();else if("string"==typeof e)u=o(e);else{if(0===e)return[a(0),a(1)];if(e===Math.floor(e))u=a(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),c-=256;u=a(e)}}if(n(r))u.mul(r[1]),f=r[0].clone();else if(i(r))f=r.clone();else if("string"==typeof r)f=o(r);else if(r)if(r===Math.floor(r))f=a(r);else{for(;r!==Math.floor(r);)r*=Math.pow(2,256),c+=256;f=a(r)}else f=a(1);c>0?u=u.ushln(c):c<0&&(f=f.ushln(-c));return s(u,f)}},{"./div":65,"./is-rat":67,"./lib/is-bn":71,"./lib/num-to-bn":72,"./lib/rationalize":73,"./lib/str-to-bn":74}],67:[function(t,e,r){"use strict";var n=t("./lib/is-bn");e.exports=function(t){return Array.isArray(t)&&2===t.length&&n(t[0])&&n(t[1])}},{"./lib/is-bn":71}],68:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return t.cmp(new n(0))}},{"bn.js":82}],69:[function(t,e,r){"use strict";var n=t("./bn-sign");e.exports=function(t){var e=t.length,r=t.words,i=0;if(1===e)i=r[0];else if(2===e)i=r[0]+67108864*r[1];else for(var a=0;a20)return 52;return r+32}},{"bit-twiddle":80,"double-bits":152}],71:[function(t,e,r){"use strict";t("bn.js");e.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},{"bn.js":82}],72:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("double-bits");e.exports=function(t){var e=i.exponent(t);return e<52?new n(t):new n(t*Math.pow(2,52-e)).ushln(e-52)}},{"bn.js":82,"double-bits":152}],73:[function(t,e,r){"use strict";var n=t("./num-to-bn"),i=t("./bn-sign");e.exports=function(t,e){var r=i(t),a=i(e);if(0===r)return[n(0),n(1)];if(0===a)return[n(0),n(0)];a<0&&(t=t.neg(),e=e.neg());var o=t.gcd(e);if(o.cmpn(1))return[t.div(o),e.div(o)];return[t,e]}},{"./bn-sign":68,"./num-to-bn":72}],74:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return new n(t)}},{"bn.js":82}],75:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[0]),t[1].mul(e[1]))}},{"./lib/rationalize":73}],76:[function(t,e,r){"use strict";var n=t("./lib/bn-sign");e.exports=function(t){return n(t[0])*n(t[1])}},{"./lib/bn-sign":68}],77:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},{"./lib/rationalize":73}],78:[function(t,e,r){"use strict";var n=t("./lib/bn-to-num"),i=t("./lib/ctz");e.exports=function(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var a=e.abs().divmod(r.abs()),o=a.div,s=n(o),l=a.mod,c=e.negative!==r.negative?-1:1;if(0===l.cmpn(0))return c*s;if(s){var u=i(s)+4,f=n(l.ushln(u).divRound(r));return c*(s+f*Math.pow(2,-u))}var h=r.bitLength()-l.bitLength()+53,f=n(l.ushln(h).divRound(r));return h<1023?c*f*Math.pow(2,-h):(f*=Math.pow(2,-1023),c*f*Math.pow(2,1023-h))}},{"./lib/bn-to-num":69,"./lib/ctz":70}],79:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],80:[function(t,e,r){"use strict";function n(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}r.INT_BITS=32,r.INT_MAX=2147483647,r.INT_MIN=-1<<31,r.sign=function(t){return(t>0)-(t<0)},r.abs=function(t){var e=t>>31;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},r.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},r.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},r.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},r.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],81:[function(t,e,r){"use strict";var n=t("clamp");e.exports=function(t,e){e||(e={});var r,o,s,l,c,u,f,h,p,d,g,v=null==e.cutoff?.25:e.cutoff,m=null==e.radius?8:e.radius,y=e.channel||0;if(ArrayBuffer.isView(t)||Array.isArray(t)){if(!e.width||!e.height)throw Error("For raw data width and height should be provided by options");r=e.width,o=e.height,l=t,u=e.stride?e.stride:Math.floor(t.length/r/o)}else window.HTMLCanvasElement&&t instanceof window.HTMLCanvasElement?(f=(h=t).getContext("2d"),r=h.width,o=h.height,p=f.getImageData(0,0,r,o),l=p.data,u=4):window.CanvasRenderingContext2D&&t instanceof window.CanvasRenderingContext2D?(h=t.canvas,f=t,r=h.width,o=h.height,p=f.getImageData(0,0,r,o),l=p.data,u=4):window.ImageData&&t instanceof window.ImageData&&(p=t,r=t.width,o=t.height,l=p.data,u=4);if(s=Math.max(r,o),window.Uint8ClampedArray&&l instanceof window.Uint8ClampedArray||window.Uint8Array&&l instanceof window.Uint8Array)for(c=l,l=Array(r*o),d=0,g=c.length;d=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function l(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return i}a.isBN=function(t){return t instanceof a||null!==t&&"object"==typeof t&&t.constructor.wordSize===a.wordSize&&Array.isArray(t.words)},a.max=function(t,e){return t.cmp(e)>0?t:e},a.min=function(t,e){return t.cmp(e)<0?t:e},a.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if("le"===r)for(i=0,a=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},a.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=s(t,r,r+6),this.words[n]|=i<>>26-a&4194303,(a+=24)>=26&&(a-=26,n++);r+6!==e&&(i=s(t,e,r+6),this.words[n]|=i<>>26-a&4194303),this.strip()},a.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,o=a%n,s=Math.min(a,a-o)+r,c=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],a=0|e.words[0],o=i*a,s=67108863&o,l=o/67108864|0;r.words[0]=s;for(var c=1;c>>26,f=67108863&l,h=Math.min(c,e.length-1),p=Math.max(0,c-t.length+1);p<=h;p++){var d=c-p|0;u+=(o=(i=0|t.words[d])*(a=0|e.words[p])+f)/67108864|0,f=67108863&o}r.words[c]=0|f,l=0|u}return 0!==l?r.words[c]=0|l:r.length--,r.strip()}a.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,a=0,o=0;o>>24-i&16777215)||o!==this.length-1?c[6-l.length]+l+r:l+r,(i+=2)>=26&&(i-=26,o--)}for(0!==a&&(r=a.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var h=u[t],p=f[t];r="";var d=this.clone();for(d.negative=0;!d.isZero();){var g=d.modn(p).toString(t);r=(d=d.idivn(p)).isZero()?g+r:c[h-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(t,e){return n("undefined"!=typeof o),this.toArrayLike(o,t,e)},a.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},a.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,"byte array longer than desired length"),n(a>0,"Requested array length <= 0"),this.strip();var o,s,l="le"===e,c=new t(a),u=this.clone();if(l){for(s=0;!u.isZero();s++)o=u.andln(255),u.iushrn(8),c[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},a.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},a.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},a.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},a.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},a.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},a.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},a.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},a.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},a.prototype.notn=function(t){return this.clone().inotn(t)},a.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26;for(;0!==i&&a>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},a.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,p=0|o[1],d=8191&p,g=p>>>13,v=0|o[2],m=8191&v,y=v>>>13,x=0|o[3],b=8191&x,_=x>>>13,w=0|o[4],k=8191&w,M=w>>>13,A=0|o[5],T=8191&A,S=A>>>13,C=0|o[6],E=8191&C,L=C>>>13,z=0|o[7],O=8191&z,I=z>>>13,P=0|o[8],D=8191&P,R=P>>>13,F=0|o[9],B=8191&F,N=F>>>13,j=0|s[0],V=8191&j,U=j>>>13,q=0|s[1],H=8191&q,G=q>>>13,W=0|s[2],Y=8191&W,X=W>>>13,Z=0|s[3],$=8191&Z,J=Z>>>13,K=0|s[4],Q=8191&K,tt=K>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],at=8191&it,ot=it>>>13,st=0|s[7],lt=8191&st,ct=st>>>13,ut=0|s[8],ft=8191&ut,ht=ut>>>13,pt=0|s[9],dt=8191&pt,gt=pt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(c+(n=Math.imul(f,V))|0)+((8191&(i=(i=Math.imul(f,U))+Math.imul(h,V)|0))<<13)|0;c=((a=Math.imul(h,U))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(d,V),i=(i=Math.imul(d,U))+Math.imul(g,V)|0,a=Math.imul(g,U);var mt=(c+(n=n+Math.imul(f,H)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(h,H)|0))<<13)|0;c=((a=a+Math.imul(h,G)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,V),i=(i=Math.imul(m,U))+Math.imul(y,V)|0,a=Math.imul(y,U),n=n+Math.imul(d,H)|0,i=(i=i+Math.imul(d,G)|0)+Math.imul(g,H)|0,a=a+Math.imul(g,G)|0;var yt=(c+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,X)|0)+Math.imul(h,Y)|0))<<13)|0;c=((a=a+Math.imul(h,X)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(b,V),i=(i=Math.imul(b,U))+Math.imul(_,V)|0,a=Math.imul(_,U),n=n+Math.imul(m,H)|0,i=(i=i+Math.imul(m,G)|0)+Math.imul(y,H)|0,a=a+Math.imul(y,G)|0,n=n+Math.imul(d,Y)|0,i=(i=i+Math.imul(d,X)|0)+Math.imul(g,Y)|0,a=a+Math.imul(g,X)|0;var xt=(c+(n=n+Math.imul(f,$)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(h,$)|0))<<13)|0;c=((a=a+Math.imul(h,J)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(k,V),i=(i=Math.imul(k,U))+Math.imul(M,V)|0,a=Math.imul(M,U),n=n+Math.imul(b,H)|0,i=(i=i+Math.imul(b,G)|0)+Math.imul(_,H)|0,a=a+Math.imul(_,G)|0,n=n+Math.imul(m,Y)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(y,Y)|0,a=a+Math.imul(y,X)|0,n=n+Math.imul(d,$)|0,i=(i=i+Math.imul(d,J)|0)+Math.imul(g,$)|0,a=a+Math.imul(g,J)|0;var bt=(c+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(h,Q)|0))<<13)|0;c=((a=a+Math.imul(h,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(T,V),i=(i=Math.imul(T,U))+Math.imul(S,V)|0,a=Math.imul(S,U),n=n+Math.imul(k,H)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(M,H)|0,a=a+Math.imul(M,G)|0,n=n+Math.imul(b,Y)|0,i=(i=i+Math.imul(b,X)|0)+Math.imul(_,Y)|0,a=a+Math.imul(_,X)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(y,$)|0,a=a+Math.imul(y,J)|0,n=n+Math.imul(d,Q)|0,i=(i=i+Math.imul(d,tt)|0)+Math.imul(g,Q)|0,a=a+Math.imul(g,tt)|0;var _t=(c+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(h,rt)|0))<<13)|0;c=((a=a+Math.imul(h,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(E,V),i=(i=Math.imul(E,U))+Math.imul(L,V)|0,a=Math.imul(L,U),n=n+Math.imul(T,H)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,G)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(M,Y)|0,a=a+Math.imul(M,X)|0,n=n+Math.imul(b,$)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(_,$)|0,a=a+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(y,Q)|0,a=a+Math.imul(y,tt)|0,n=n+Math.imul(d,rt)|0,i=(i=i+Math.imul(d,nt)|0)+Math.imul(g,rt)|0,a=a+Math.imul(g,nt)|0;var wt=(c+(n=n+Math.imul(f,at)|0)|0)+((8191&(i=(i=i+Math.imul(f,ot)|0)+Math.imul(h,at)|0))<<13)|0;c=((a=a+Math.imul(h,ot)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(O,V),i=(i=Math.imul(O,U))+Math.imul(I,V)|0,a=Math.imul(I,U),n=n+Math.imul(E,H)|0,i=(i=i+Math.imul(E,G)|0)+Math.imul(L,H)|0,a=a+Math.imul(L,G)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(S,Y)|0,a=a+Math.imul(S,X)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(M,$)|0,a=a+Math.imul(M,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(_,Q)|0,a=a+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(y,rt)|0,a=a+Math.imul(y,nt)|0,n=n+Math.imul(d,at)|0,i=(i=i+Math.imul(d,ot)|0)+Math.imul(g,at)|0,a=a+Math.imul(g,ot)|0;var kt=(c+(n=n+Math.imul(f,lt)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(h,lt)|0))<<13)|0;c=((a=a+Math.imul(h,ct)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,V),i=(i=Math.imul(D,U))+Math.imul(R,V)|0,a=Math.imul(R,U),n=n+Math.imul(O,H)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,G)|0,n=n+Math.imul(E,Y)|0,i=(i=i+Math.imul(E,X)|0)+Math.imul(L,Y)|0,a=a+Math.imul(L,X)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(M,Q)|0,a=a+Math.imul(M,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(_,rt)|0,a=a+Math.imul(_,nt)|0,n=n+Math.imul(m,at)|0,i=(i=i+Math.imul(m,ot)|0)+Math.imul(y,at)|0,a=a+Math.imul(y,ot)|0,n=n+Math.imul(d,lt)|0,i=(i=i+Math.imul(d,ct)|0)+Math.imul(g,lt)|0,a=a+Math.imul(g,ct)|0;var Mt=(c+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ht)|0)+Math.imul(h,ft)|0))<<13)|0;c=((a=a+Math.imul(h,ht)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(B,V),i=(i=Math.imul(B,U))+Math.imul(N,V)|0,a=Math.imul(N,U),n=n+Math.imul(D,H)|0,i=(i=i+Math.imul(D,G)|0)+Math.imul(R,H)|0,a=a+Math.imul(R,G)|0,n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(I,Y)|0,a=a+Math.imul(I,X)|0,n=n+Math.imul(E,$)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(L,$)|0,a=a+Math.imul(L,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(S,Q)|0,a=a+Math.imul(S,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,nt)|0,n=n+Math.imul(b,at)|0,i=(i=i+Math.imul(b,ot)|0)+Math.imul(_,at)|0,a=a+Math.imul(_,ot)|0,n=n+Math.imul(m,lt)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(y,lt)|0,a=a+Math.imul(y,ct)|0,n=n+Math.imul(d,ft)|0,i=(i=i+Math.imul(d,ht)|0)+Math.imul(g,ft)|0,a=a+Math.imul(g,ht)|0;var At=(c+(n=n+Math.imul(f,dt)|0)|0)+((8191&(i=(i=i+Math.imul(f,gt)|0)+Math.imul(h,dt)|0))<<13)|0;c=((a=a+Math.imul(h,gt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(B,H),i=(i=Math.imul(B,G))+Math.imul(N,H)|0,a=Math.imul(N,G),n=n+Math.imul(D,Y)|0,i=(i=i+Math.imul(D,X)|0)+Math.imul(R,Y)|0,a=a+Math.imul(R,X)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(L,Q)|0,a=a+Math.imul(L,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,nt)|0,n=n+Math.imul(k,at)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,n=n+Math.imul(b,lt)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(_,lt)|0,a=a+Math.imul(_,ct)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ht)|0)+Math.imul(y,ft)|0,a=a+Math.imul(y,ht)|0;var Tt=(c+(n=n+Math.imul(d,dt)|0)|0)+((8191&(i=(i=i+Math.imul(d,gt)|0)+Math.imul(g,dt)|0))<<13)|0;c=((a=a+Math.imul(g,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(B,Y),i=(i=Math.imul(B,X))+Math.imul(N,Y)|0,a=Math.imul(N,X),n=n+Math.imul(D,$)|0,i=(i=i+Math.imul(D,J)|0)+Math.imul(R,$)|0,a=a+Math.imul(R,J)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(I,Q)|0,a=a+Math.imul(I,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(L,rt)|0,a=a+Math.imul(L,nt)|0,n=n+Math.imul(T,at)|0,i=(i=i+Math.imul(T,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,n=n+Math.imul(k,lt)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(M,lt)|0,a=a+Math.imul(M,ct)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ht)|0)+Math.imul(_,ft)|0,a=a+Math.imul(_,ht)|0;var St=(c+(n=n+Math.imul(m,dt)|0)|0)+((8191&(i=(i=i+Math.imul(m,gt)|0)+Math.imul(y,dt)|0))<<13)|0;c=((a=a+Math.imul(y,gt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(B,$),i=(i=Math.imul(B,J))+Math.imul(N,$)|0,a=Math.imul(N,J),n=n+Math.imul(D,Q)|0,i=(i=i+Math.imul(D,tt)|0)+Math.imul(R,Q)|0,a=a+Math.imul(R,tt)|0,n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,nt)|0,n=n+Math.imul(E,at)|0,i=(i=i+Math.imul(E,ot)|0)+Math.imul(L,at)|0,a=a+Math.imul(L,ot)|0,n=n+Math.imul(T,lt)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(S,lt)|0,a=a+Math.imul(S,ct)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ht)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ht)|0;var Ct=(c+(n=n+Math.imul(b,dt)|0)|0)+((8191&(i=(i=i+Math.imul(b,gt)|0)+Math.imul(_,dt)|0))<<13)|0;c=((a=a+Math.imul(_,gt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(B,Q),i=(i=Math.imul(B,tt))+Math.imul(N,Q)|0,a=Math.imul(N,tt),n=n+Math.imul(D,rt)|0,i=(i=i+Math.imul(D,nt)|0)+Math.imul(R,rt)|0,a=a+Math.imul(R,nt)|0,n=n+Math.imul(O,at)|0,i=(i=i+Math.imul(O,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,n=n+Math.imul(E,lt)|0,i=(i=i+Math.imul(E,ct)|0)+Math.imul(L,lt)|0,a=a+Math.imul(L,ct)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ht)|0)+Math.imul(S,ft)|0,a=a+Math.imul(S,ht)|0;var Et=(c+(n=n+Math.imul(k,dt)|0)|0)+((8191&(i=(i=i+Math.imul(k,gt)|0)+Math.imul(M,dt)|0))<<13)|0;c=((a=a+Math.imul(M,gt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(B,rt),i=(i=Math.imul(B,nt))+Math.imul(N,rt)|0,a=Math.imul(N,nt),n=n+Math.imul(D,at)|0,i=(i=i+Math.imul(D,ot)|0)+Math.imul(R,at)|0,a=a+Math.imul(R,ot)|0,n=n+Math.imul(O,lt)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(I,lt)|0,a=a+Math.imul(I,ct)|0,n=n+Math.imul(E,ft)|0,i=(i=i+Math.imul(E,ht)|0)+Math.imul(L,ft)|0,a=a+Math.imul(L,ht)|0;var Lt=(c+(n=n+Math.imul(T,dt)|0)|0)+((8191&(i=(i=i+Math.imul(T,gt)|0)+Math.imul(S,dt)|0))<<13)|0;c=((a=a+Math.imul(S,gt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(B,at),i=(i=Math.imul(B,ot))+Math.imul(N,at)|0,a=Math.imul(N,ot),n=n+Math.imul(D,lt)|0,i=(i=i+Math.imul(D,ct)|0)+Math.imul(R,lt)|0,a=a+Math.imul(R,ct)|0,n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,ht)|0)+Math.imul(I,ft)|0,a=a+Math.imul(I,ht)|0;var zt=(c+(n=n+Math.imul(E,dt)|0)|0)+((8191&(i=(i=i+Math.imul(E,gt)|0)+Math.imul(L,dt)|0))<<13)|0;c=((a=a+Math.imul(L,gt)|0)+(i>>>13)|0)+(zt>>>26)|0,zt&=67108863,n=Math.imul(B,lt),i=(i=Math.imul(B,ct))+Math.imul(N,lt)|0,a=Math.imul(N,ct),n=n+Math.imul(D,ft)|0,i=(i=i+Math.imul(D,ht)|0)+Math.imul(R,ft)|0,a=a+Math.imul(R,ht)|0;var Ot=(c+(n=n+Math.imul(O,dt)|0)|0)+((8191&(i=(i=i+Math.imul(O,gt)|0)+Math.imul(I,dt)|0))<<13)|0;c=((a=a+Math.imul(I,gt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(B,ft),i=(i=Math.imul(B,ht))+Math.imul(N,ft)|0,a=Math.imul(N,ht);var It=(c+(n=n+Math.imul(D,dt)|0)|0)+((8191&(i=(i=i+Math.imul(D,gt)|0)+Math.imul(R,dt)|0))<<13)|0;c=((a=a+Math.imul(R,gt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863;var Pt=(c+(n=Math.imul(B,dt))|0)+((8191&(i=(i=Math.imul(B,gt))+Math.imul(N,dt)|0))<<13)|0;return c=((a=Math.imul(N,gt))+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,l[0]=vt,l[1]=mt,l[2]=yt,l[3]=xt,l[4]=bt,l[5]=_t,l[6]=wt,l[7]=kt,l[8]=Mt,l[9]=At,l[10]=Tt,l[11]=St,l[12]=Ct,l[13]=Et,l[14]=Lt,l[15]=zt,l[16]=Ot,l[17]=It,l[18]=Pt,0!==c&&(l[19]=c,r.length++),r};function d(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=h),a.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?h(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,n=o,o=i}return 0!==n?r.words[a]=n:r.length--,r.strip()}(this,t,e):d(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=a.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,i,a){for(var o=0;o>>=1)i++;return 1<>>=13,r[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=a>>>26,this.words[r]=67108863&a}return 0!==e&&(this.words[r]=e,this.length++),this},a.prototype.muln=function(t){return this.clone().imuln(t)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new a(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,c=0;c=0&&(0!==u||c>=i);c--){var f=0|this.words[c];this.words[c]=u<<26-a|f>>>a,u=f&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},a.prototype.shln=function(t){return this.clone().ishln(t)},a.prototype.ushln=function(t){return this.clone().iushln(t)},a.prototype.shrn=function(t){return this.clone().ishrn(t)},a.prototype.ushrn=function(t){return this.clone().iushrn(t)},a.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},a.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(l/67108864|0),this.words[i+r]=67108863&a}for(;i>26,this.words[i+r]=67108863&a;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&a;return this.negative=1,this.strip()},a.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var s,l=n.length-i.length;if("mod"!==e){(s=new a(null)).length=l+1,s.words=new Array(s.length);for(var c=0;c=0;f--){var h=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(h=Math.min(h/o|0,67108863),n._ishlnsubmul(i,h,f);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=h)}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},a.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(i=s.div.neg()),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new a(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new a(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new a(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,s},a.prototype.div=function(t){return this.divmod(t,"div",!1).div},a.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},a.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},a.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),a=r.cmp(n);return a<0||1===i&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},a.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},a.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},a.prototype.divn=function(t){return this.clone().idivn(t)},a.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new a(1),o=new a(0),s=new a(0),l=new a(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var u=r.clone(),f=e.clone();!e.isZero();){for(var h=0,p=1;0==(e.words[0]&p)&&h<26;++h,p<<=1);if(h>0)for(e.iushrn(h);h-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(u),o.isub(f)),i.iushrn(1),o.iushrn(1);for(var d=0,g=1;0==(r.words[0]&g)&&d<26;++d,g<<=1);if(d>0)for(r.iushrn(d);d-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(u),l.isub(f)),s.iushrn(1),l.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(s),o.isub(l)):(r.isub(e),s.isub(i),l.isub(o))}return{a:s,b:l,gcd:r.iushln(c)}},a.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new a(1),s=new a(0),l=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,u=1;0==(e.words[0]&u)&&c<26;++c,u<<=1);if(c>0)for(e.iushrn(c);c-- >0;)o.isOdd()&&o.iadd(l),o.iushrn(1);for(var f=0,h=1;0==(r.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(s)):(r.isub(e),s.isub(o))}return(i=0===e.cmpn(1)?o:s).cmpn(0)<0&&i.iadd(t),i},a.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},a.prototype.invm=function(t){return this.egcd(t).a.umod(t)},a.prototype.isEven=function(){return 0==(1&this.words[0])},a.prototype.isOdd=function(){return 1==(1&this.words[0])},a.prototype.andln=function(t){return this.words[0]&t},a.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},a.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},a.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},a.prototype.gtn=function(t){return 1===this.cmpn(t)},a.prototype.gt=function(t){return 1===this.cmp(t)},a.prototype.gten=function(t){return this.cmpn(t)>=0},a.prototype.gte=function(t){return this.cmp(t)>=0},a.prototype.ltn=function(t){return-1===this.cmpn(t)},a.prototype.lt=function(t){return-1===this.cmp(t)},a.prototype.lten=function(t){return this.cmpn(t)<=0},a.prototype.lte=function(t){return this.cmp(t)<=0},a.prototype.eqn=function(t){return 0===this.cmpn(t)},a.prototype.eq=function(t){return 0===this.cmp(t)},a.red=function(t){return new w(t)},a.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},a.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(t){return this.red=t,this},a.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},a.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},a.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},a.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},a.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},a.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},a.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},a.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},a.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new a(e,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function x(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=a._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function k(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var t=new a(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(y,m),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=a}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},a._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new x;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return v[t]=e,e},w.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new a(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var s=new a(1).toRed(this),l=s.redNeg(),c=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new a(2*u*u).toRed(this);0!==this.pow(u,c).cmp(l);)u.redIAdd(l);for(var f=this.pow(u,i),h=this.pow(t,i.addn(1).iushrn(1)),p=this.pow(t,i),d=o;0!==p.cmp(s);){for(var g=p,v=0;0!==g.cmp(s);v++)g=g.redSqr();n(v=0;n--){for(var c=e.words[n],u=l-1;u>=0;u--){var f=c>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==o?(o<<=1,o|=f,(4===++s||0===n&&0===u)&&(i=this.mul(i,r[o]),s=0,o=0)):s=0}l=26}return i},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},a.mont=function(t){return new k(t)},i(k,w),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new a(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof e||e,this)},{buffer:91}],83:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i=t.length,a=0;for(e=0;e>>1;if(!(u<=0)){var f,h=i.mallocDouble(2*u*s),p=i.mallocInt32(s);if((s=l(t,u,h,p))>0){if(1===u&&n)a.init(s),f=a.sweepComplete(u,r,0,s,h,p,0,s,h,p);else{var d=i.mallocDouble(2*u*c),g=i.mallocInt32(c);(c=l(e,u,d,g))>0&&(a.init(s+c),f=1===u?a.sweepBipartite(u,r,0,s,h,p,0,c,d,g):o(u,r,n,s,h,p,c,d,g),i.free(d),i.free(g))}i.free(h),i.free(p)}return f}}}function u(t,e){n.push([t,e])}},{"./lib/intersect":86,"./lib/sweep":90,"typedarray-pool":521}],85:[function(t,e,r){"use strict";var n="d",i="ax",a="vv",o="fp",s="es",l="rs",c="re",u="rb",f="ri",h="rp",p="bs",d="be",g="bb",v="bi",m="bp",y="rv",x="Q",b=[n,i,a,l,c,u,f,p,d,g,v];function _(t){var e="bruteForce"+(t?"Full":"Partial"),r=[],_=b.slice();t||_.splice(3,0,o);var w=["function "+e+"("+_.join()+"){"];function k(e,o){var _=function(t,e,r){var o="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),_=["function ",o,"(",b.join(),"){","var ",s,"=2*",n,";"],w="for(var i="+l+","+h+"="+s+"*"+l+";i<"+c+";++i,"+h+"+="+s+"){var x0="+u+"["+i+"+"+h+"],x1="+u+"["+i+"+"+h+"+"+n+"],xi="+f+"[i];",k="for(var j="+p+","+m+"="+s+"*"+p+";j<"+d+";++j,"+m+"+="+s+"){var y0="+g+"["+i+"+"+m+"],"+(r?"y1="+g+"["+i+"+"+m+"+"+n+"],":"")+"yi="+v+"[j];";return t?_.push(w,x,":",k):_.push(k,x,":",w),r?_.push("if(y1"+d+"-"+p+"){"),t?(k(!0,!1),w.push("}else{"),k(!1,!1)):(w.push("if("+o+"){"),k(!0,!0),w.push("}else{"),k(!0,!1),w.push("}}else{if("+o+"){"),k(!1,!0),w.push("}else{"),k(!1,!1),w.push("}")),w.push("}}return "+e);var M=r.join("")+w.join("");return new Function(M)()}r.partial=_(!1),r.full=_(!0)},{}],86:[function(t,e,r){"use strict";e.exports=function(t,e,r,a,u,S,C,E,L){!function(t,e){var r=8*i.log2(e+1)*(t+1)|0,a=i.nextPow2(b*r);w.length0;){var P=(O-=1)*b,D=w[P],R=w[P+1],F=w[P+2],B=w[P+3],N=w[P+4],j=w[P+5],V=O*_,U=k[V],q=k[V+1],H=1&j,G=!!(16&j),W=u,Y=S,X=E,Z=L;if(H&&(W=E,Y=L,X=u,Z=S),!(2&j&&(F=v(t,D,R,F,W,Y,q),R>=F)||4&j&&(R=m(t,D,R,F,W,Y,U))>=F)){var $=F-R,J=N-B;if(G){if(t*$*($+J)=p0)&&!(p1>=hi)",["p0","p1"]),g=u("lo===p0",["p0"]),v=u("lo>>1,h=2*t,p=f,d=s[h*f+e];for(;c=x?(p=y,d=x):m>=_?(p=v,d=m):(p=b,d=_):x>=_?(p=y,d=x):_>=m?(p=v,d=m):(p=b,d=_);for(var w=h*(u-1),k=h*p,M=0;Mr&&i[f+e]>c;--u,f-=o){for(var h=f,p=f+o,d=0;d=0&&i.push("lo=e[k+n]");t.indexOf("hi")>=0&&i.push("hi=e[k+o]");return r.push(n.replace("_",i.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],89:[function(t,e,r){"use strict";e.exports=function(t,e){e<=4*n?i(0,e-1,t):function t(e,r,f){var h=(r-e+1)/6|0,p=e+h,d=r-h,g=e+r>>1,v=g-h,m=g+h,y=p,x=v,b=g,_=m,w=d,k=e+1,M=r-1,A=0;c(y,x,f)&&(A=y,y=x,x=A);c(_,w,f)&&(A=_,_=w,w=A);c(y,b,f)&&(A=y,y=b,b=A);c(x,b,f)&&(A=x,x=b,b=A);c(y,_,f)&&(A=y,y=_,_=A);c(b,_,f)&&(A=b,b=_,_=A);c(x,w,f)&&(A=x,x=w,w=A);c(x,b,f)&&(A=x,x=b,b=A);c(_,w,f)&&(A=_,_=w,w=A);var T=f[2*x];var S=f[2*x+1];var C=f[2*_];var E=f[2*_+1];var L=2*y;var z=2*b;var O=2*w;var I=2*p;var P=2*g;var D=2*d;for(var R=0;R<2;++R){var F=f[L+R],B=f[z+R],N=f[O+R];f[I+R]=F,f[P+R]=B,f[D+R]=N}o(v,e,f);o(m,r,f);for(var j=k;j<=M;++j)if(u(j,T,S,f))j!==k&&a(j,k,f),++k;else if(!u(j,C,E,f))for(;;){if(u(M,C,E,f)){u(M,T,S,f)?(s(j,k,M,f),++k,--M):(a(j,M,f),--M);break}if(--Mt;){var c=r[l-2],u=r[l-1];if(cr[e+1])}function u(t,e,r,n){var i=n[t*=2];return i>>1;a(p,S);for(var C=0,E=0,k=0;k=o)d(c,u,E--,L=L-o|0);else if(L>=0)d(s,l,C--,L);else if(L<=-o){L=-L-o|0;for(var z=0;z>>1;a(p,C);for(var E=0,L=0,z=0,M=0;M>1==p[2*M+3]>>1&&(I=2,M+=1),O<0){for(var P=-(O>>1)-1,D=0;D>1)-1;0===I?d(s,l,E--,P):1===I?d(c,u,L--,P):2===I&&d(f,h,z--,P)}}},scanBipartite:function(t,e,r,n,i,c,u,f,h,v,m,y){var x=0,b=2*t,_=e,w=e+t,k=1,M=1;n?M=o:k=o;for(var A=i;A>>1;a(p,E);for(var L=0,A=0;A=o?(O=!n,T-=o):(O=!!n,T-=1),O)g(s,l,L++,T);else{var I=y[T],P=b*T,D=m[P+e+1],R=m[P+e+1+t];t:for(var F=0;F>>1;a(p,k);for(var M=0,x=0;x=o)s[M++]=b-o;else{var T=d[b-=1],S=v*b,C=h[S+e+1],E=h[S+e+1+t];t:for(var L=0;L=0;--L)if(s[L]===b){for(var P=L+1;P0&&s.length>a){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=o[e]=r,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,i=v(t,n),a=0;a=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,a=o;break}if(a<0)return this;0===a?r.shift():function(t,e){for(var r=e,n=r+1,i=t.length;n=0;a--)this.removeListener(t,e[a]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],93:[function(t,e,r){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=s,r.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},r.INSPECT_MAX_BYTES=50;var a=2147483647;function o(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return f(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(j(t,ArrayBuffer)||t&&j(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return B(t).length;default:if(i)return n?-1:F(t).length;e=(""+e).toLowerCase(),i=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var a,o=1,s=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,r/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var u=-1;for(a=r;as&&(r=s-l),a=r;a>=0;a--){for(var f=!0,h=0;hi&&(n=i):n=i;var a=e.length;n>a/2&&(n=a/2);for(var o=0;o>8,i=r%256,a.push(i),a.push(n);return a}(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function M(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(u=c);break;case 2:128==(192&(a=t[i+1]))&&(l=(31&c)<<6|63&a)>127&&(u=l);break;case 3:a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&(l=(15&c)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(l=(15&c)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,f=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=f}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return M(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return S(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},s.prototype.compare=function(t,e,r,n,i){if(j(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var a=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),l=Math.min(a,o),c=this.slice(n,i),u=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return x(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function T(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",a=e;ar)throw new RangeError("Trying to access beyond buffer length")}function z(t,e,r,n,i,a){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function O(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,a){return e=+e,r>>>=0,a||O(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function P(t,e,r,n,a){return e=+e,r>>>=0,a||O(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t],i=1,a=0;++a>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||L(t,e,this.length);for(var n=this[t],i=1,a=0;++a=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||L(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*e)),a},s.prototype.readInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||L(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||L(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||L(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||L(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||L(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||L(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||z(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[e]=255&t;++a>>=0,r>>>=0,n)||z(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,a=1;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=t/a&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);z(this,t,e,r,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);z(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return P(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return P(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--a)t[a+e]=this[a+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(a=e;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function B(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(D,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function j(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}},{"base64-js":62,ieee754:395}],94:[function(t,e,r){"use strict";var n=t("./lib/monotone"),i=t("./lib/triangulation"),a=t("./lib/delaunay"),o=t("./lib/filter");function s(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function l(t,e){return t[0]-e[0]||t[1]-e[1]}function c(t,e,r){return e in t?t[e]:r}e.exports=function(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var u=!!c(r,"delaunay",!0),f=!!c(r,"interior",!0),h=!!c(r,"exterior",!0),p=!!c(r,"infinity",!1);if(!f&&!h||0===t.length)return[];var d=n(t,e);if(u||f!==h||p){for(var g=i(t.length,function(t){return t.map(s).sort(l)}(e)),v=0;v0;){for(var u=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],d=1;d=0||(e.flip(s,u),i(t,e,r,f,s,h),i(t,e,r,s,h,f),i(t,e,r,h,u,f),i(t,e,r,u,f,h)))}}},{"binary-search-bounds":99,"robust-in-sphere":484}],96:[function(t,e,r){"use strict";var n,i=t("binary-search-bounds");function a(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function o(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}e.exports=function(t,e,r){var n=function(t,e){for(var r=t.cells(),n=r.length,i=0;i0||l.length>0;){for(;s.length>0;){var p=s.pop();if(c[p]!==-i){c[p]=i;u[p];for(var d=0;d<3;++d){var g=h[3*p+d];g>=0&&0===c[g]&&(f[3*p+d]?l.push(g):(s.push(g),c[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=function(t,e,r){for(var n=0,i=0;i1&&i(r[h[p-2]],r[h[p-1]],a)>0;)t.push([h[p-1],h[p-2],o]),p-=1;h.length=p,h.push(o);var d=u.upperIds;for(p=d.length;p>1&&i(r[d[p-2]],r[d[p-1]],a)<0;)t.push([d[p-2],d[p-1],o]),p-=1;d.length=p,d.push(o)}}function p(t,e){var r;return(r=t.a[0]m[0]&&i.push(new c(m,v,s,f),new c(v,m,o,f))}i.sort(u);for(var y=i[0].a[0]-(1+Math.abs(i[0].a[0]))*Math.pow(2,-52),x=[new l([y,1],[y,0],-1,[],[],[],[])],b=[],f=0,_=i.length;f<_;++f){var w=i[f],k=w.type;k===a?h(b,x,t,w.a,w.idx):k===s?d(x,t,w):g(x,t,w)}return b}},{"binary-search-bounds":99,"robust-orientation":486}],98:[function(t,e,r){"use strict";var n=t("binary-search-bounds");function i(t,e){this.stars=t,this.edges=e}e.exports=function(t,e){for(var r=new Array(t),n=0;n=0}}(),a.removeTriangle=function(t,e,r){var n=this.stars;o(n[t],e,r),o(n[e],r,t),o(n[r],t,e)},a.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},a.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;n>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],100:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1,r=1;rr?r:t:te?e:t}},{}],104:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n;if(r){n=e;for(var i=new Array(e.length),a=0;ae[2]?1:0)}function m(t,e,r){if(0!==t.length){if(e)for(var n=0;n=0;--a){var x=e[u=(S=n[a])[0]],b=x[0],_=x[1],w=t[b],k=t[_];if((w[0]-k[0]||w[1]-k[1])<0){var M=b;b=_,_=M}x[0]=b;var A,T=x[1]=S[1];for(i&&(A=x[2]);a>0&&n[a-1][0]===u;){var S,C=(S=n[--a])[1];i?e.push([T,C,A]):e.push([T,C]),T=C}i?e.push([T,_,A]):e.push([T,_])}return h}(t,e,h,v,r));return m(e,y,r),!!y||(h.length>0||v.length>0)}},{"./lib/rat-seg-intersect":105,"big-rat":66,"big-rat/cmp":64,"big-rat/to-float":78,"box-intersect":84,nextafter:434,"rat-vec":469,"robust-segment-intersect":489,"union-find":522}],105:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var a=s(e,t),f=s(n,r),h=u(a,f);if(0===o(h))return null;var p=s(t,r),d=u(f,p),g=i(d,h),v=c(a,g);return l(t,v)};var n=t("big-rat/mul"),i=t("big-rat/div"),a=t("big-rat/sub"),o=t("big-rat/sign"),s=t("rat-vec/sub"),l=t("rat-vec/add"),c=t("rat-vec/muls");function u(t,e){return a(n(t[0],e[1]),n(t[1],e[0]))}},{"big-rat/div":65,"big-rat/mul":75,"big-rat/sign":76,"big-rat/sub":77,"rat-vec/add":468,"rat-vec/muls":470,"rat-vec/sub":471}],106:[function(t,e,r){"use strict";var n=t("clamp");function i(t,e){null==e&&(e=!0);var r=t[0],i=t[1],a=t[2],o=t[3];return null==o&&(o=e?1:255),e&&(r*=255,i*=255,a*=255,o*=255),16777216*(r=255&n(r,0,255))+((i=255&n(i,0,255))<<16)+((a=255&n(a,0,255))<<8)+(o=255&n(o,0,255))}e.exports=i,e.exports.to=i,e.exports.from=function(t,e){var r=(t=+t)>>>24,n=(16711680&t)>>>16,i=(65280&t)>>>8,a=255&t;return!1===e?[r,n,i,a]:[r/255,n/255,i/255,a/255]}},{clamp:103}],107:[function(t,e,r){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],108:[function(t,e,r){"use strict";var n=t("color-rgba"),i=t("clamp"),a=t("dtype");e.exports=function(t,e){"float"!==e&&e||(e="array"),"uint"===e&&(e="uint8"),"uint_clamped"===e&&(e="uint8_clamped");var r=new(a(e))(4),o="uint8"!==e&&"uint8_clamped"!==e;return t.length&&"string"!=typeof t||((t=n(t))[0]/=255,t[1]/=255,t[2]/=255),function(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||!!(Array.isArray(t)&&(t[0]>1||0===t[0])&&(t[1]>1||0===t[1])&&(t[2]>1||0===t[2])&&(!t[3]||t[3]>1))}(t)?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:255,o&&(r[0]/=255,r[1]/=255,r[2]/=255,r[3]/=255),r):(o?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:1):(r[0]=i(Math.floor(255*t[0]),0,255),r[1]=i(Math.floor(255*t[1]),0,255),r[2]=i(Math.floor(255*t[2]),0,255),r[3]=null==t[3]?255:i(Math.floor(255*t[3]),0,255)),r)}},{clamp:103,"color-rgba":110,dtype:154}],109:[function(t,e,r){(function(r){"use strict";var n=t("color-name"),i=t("is-plain-obj"),a=t("defined");e.exports=function(t){var e,s,l=[],c=1;if("string"==typeof t)if(n[t])l=n[t].slice(),s="rgb";else if("transparent"===t)c=0,s="rgb",l=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var u=t.slice(1),f=u.length,h=f<=4;c=1,h?(l=[parseInt(u[0]+u[0],16),parseInt(u[1]+u[1],16),parseInt(u[2]+u[2],16)],4===f&&(c=parseInt(u[3]+u[3],16)/255)):(l=[parseInt(u[0]+u[1],16),parseInt(u[2]+u[3],16),parseInt(u[4]+u[5],16)],8===f&&(c=parseInt(u[6]+u[7],16)/255)),l[0]||(l[0]=0),l[1]||(l[1]=0),l[2]||(l[2]=0),s="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var p=e[1],u=p.replace(/a$/,"");s=u;var f="cmyk"===u?4:"gray"===u?1:3;l=e[2].trim().split(/\s*,\s*/).map(function(t,e){if(/%$/.test(t))return e===f?parseFloat(t)/100:"rgb"===u?255*parseFloat(t)/100:parseFloat(t);if("h"===u[e]){if(/deg$/.test(t))return parseFloat(t);if(void 0!==o[t])return o[t]}return parseFloat(t)}),p===u&&l.push(1),c=void 0===l[f]?1:l[f],l=l.slice(0,f)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(l=t.match(/([0-9]+)/g).map(function(t){return parseFloat(t)}),s=t.match(/([a-z])/gi).join("").toLowerCase());else if(isNaN(t))if(i(t)){var d=a(t.r,t.red,t.R,null);null!==d?(s="rgb",l=[d,a(t.g,t.green,t.G),a(t.b,t.blue,t.B)]):(s="hsl",l=[a(t.h,t.hue,t.H),a(t.s,t.saturation,t.S),a(t.l,t.lightness,t.L,t.b,t.brightness)]),c=a(t.a,t.alpha,t.opacity,1),null!=t.opacity&&(c/=100)}else(Array.isArray(t)||r.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(t))&&(l=[t[0],t[1],t[2]],s="rgb",c=4===t.length?t[3]:1);else s="rgb",l=[t>>>16,(65280&t)>>>8,255&t];return{space:s,values:l,alpha:c}};var o={red:0,orange:60,yellow:120,green:180,blue:240,purple:300}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"color-name":107,defined:149,"is-plain-obj":405}],110:[function(t,e,r){"use strict";var n=t("color-parse"),i=t("color-space/hsl"),a=t("clamp");e.exports=function(t){var e,r=n(t);return r.space?((e=Array(3))[0]=a(r.values[0],0,255),e[1]=a(r.values[1],0,255),e[2]=a(r.values[2],0,255),"h"===r.space[0]&&(e=i.rgb(e)),e.push(a(r.alpha,0,1)),e):[]}},{clamp:103,"color-parse":109,"color-space/hsl":111}],111:[function(t,e,r){"use strict";var n=t("./rgb");e.exports={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e,r,n,i,a,o=t[0]/360,s=t[1]/100,l=t[2]/100;if(0===s)return[a=255*l,a,a];e=2*l-(r=l<.5?l*(1+s):l+s-l*s),i=[0,0,0];for(var c=0;c<3;c++)(n=o+1/3*-(c-1))<0?n++:n>1&&n--,a=6*n<1?e+6*(r-e)*n:2*n<1?r:3*n<2?e+(r-e)*(2/3-n)*6:e,i[c]=255*a;return i}},n.hsl=function(t){var e,r,n=t[0]/255,i=t[1]/255,a=t[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),l=s-o;return s===o?e=0:n===s?e=(i-a)/l:i===s?e=2+(a-n)/l:a===s&&(e=4+(n-i)/l),(e=Math.min(60*e,360))<0&&(e+=360),r=(o+s)/2,[e,100*(s===o?0:r<=.5?l/(s+o):l/(2-s-o)),100*r]}},{"./rgb":112}],112:[function(t,e,r){"use strict";e.exports={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]}},{}],113:[function(t,e,r){e.exports={jet:[{index:0,rgb:[0,0,131]},{index:.125,rgb:[0,60,170]},{index:.375,rgb:[5,255,255]},{index:.625,rgb:[255,255,0]},{index:.875,rgb:[250,0,0]},{index:1,rgb:[128,0,0]}],hsv:[{index:0,rgb:[255,0,0]},{index:.169,rgb:[253,255,2]},{index:.173,rgb:[247,255,2]},{index:.337,rgb:[0,252,4]},{index:.341,rgb:[0,252,10]},{index:.506,rgb:[1,249,255]},{index:.671,rgb:[2,0,253]},{index:.675,rgb:[8,0,253]},{index:.839,rgb:[255,0,251]},{index:.843,rgb:[255,0,245]},{index:1,rgb:[255,0,6]}],hot:[{index:0,rgb:[0,0,0]},{index:.3,rgb:[230,0,0]},{index:.6,rgb:[255,210,0]},{index:1,rgb:[255,255,255]}],cool:[{index:0,rgb:[0,255,255]},{index:1,rgb:[255,0,255]}],spring:[{index:0,rgb:[255,0,255]},{index:1,rgb:[255,255,0]}],summer:[{index:0,rgb:[0,128,102]},{index:1,rgb:[255,255,102]}],autumn:[{index:0,rgb:[255,0,0]},{index:1,rgb:[255,255,0]}],winter:[{index:0,rgb:[0,0,255]},{index:1,rgb:[0,255,128]}],bone:[{index:0,rgb:[0,0,0]},{index:.376,rgb:[84,84,116]},{index:.753,rgb:[169,200,200]},{index:1,rgb:[255,255,255]}],copper:[{index:0,rgb:[0,0,0]},{index:.804,rgb:[255,160,102]},{index:1,rgb:[255,199,127]}],greys:[{index:0,rgb:[0,0,0]},{index:1,rgb:[255,255,255]}],yignbu:[{index:0,rgb:[8,29,88]},{index:.125,rgb:[37,52,148]},{index:.25,rgb:[34,94,168]},{index:.375,rgb:[29,145,192]},{index:.5,rgb:[65,182,196]},{index:.625,rgb:[127,205,187]},{index:.75,rgb:[199,233,180]},{index:.875,rgb:[237,248,217]},{index:1,rgb:[255,255,217]}],greens:[{index:0,rgb:[0,68,27]},{index:.125,rgb:[0,109,44]},{index:.25,rgb:[35,139,69]},{index:.375,rgb:[65,171,93]},{index:.5,rgb:[116,196,118]},{index:.625,rgb:[161,217,155]},{index:.75,rgb:[199,233,192]},{index:.875,rgb:[229,245,224]},{index:1,rgb:[247,252,245]}],yiorrd:[{index:0,rgb:[128,0,38]},{index:.125,rgb:[189,0,38]},{index:.25,rgb:[227,26,28]},{index:.375,rgb:[252,78,42]},{index:.5,rgb:[253,141,60]},{index:.625,rgb:[254,178,76]},{index:.75,rgb:[254,217,118]},{index:.875,rgb:[255,237,160]},{index:1,rgb:[255,255,204]}],bluered:[{index:0,rgb:[0,0,255]},{index:1,rgb:[255,0,0]}],rdbu:[{index:0,rgb:[5,10,172]},{index:.35,rgb:[106,137,247]},{index:.5,rgb:[190,190,190]},{index:.6,rgb:[220,170,132]},{index:.7,rgb:[230,145,90]},{index:1,rgb:[178,10,28]}],picnic:[{index:0,rgb:[0,0,255]},{index:.1,rgb:[51,153,255]},{index:.2,rgb:[102,204,255]},{index:.3,rgb:[153,204,255]},{index:.4,rgb:[204,204,255]},{index:.5,rgb:[255,255,255]},{index:.6,rgb:[255,204,255]},{index:.7,rgb:[255,153,255]},{index:.8,rgb:[255,102,204]},{index:.9,rgb:[255,102,102]},{index:1,rgb:[255,0,0]}],rainbow:[{index:0,rgb:[150,0,90]},{index:.125,rgb:[0,0,200]},{index:.25,rgb:[0,25,255]},{index:.375,rgb:[0,152,255]},{index:.5,rgb:[44,255,150]},{index:.625,rgb:[151,255,0]},{index:.75,rgb:[255,234,0]},{index:.875,rgb:[255,111,0]},{index:1,rgb:[255,0,0]}],portland:[{index:0,rgb:[12,51,131]},{index:.25,rgb:[10,136,186]},{index:.5,rgb:[242,211,56]},{index:.75,rgb:[242,143,56]},{index:1,rgb:[217,30,30]}],blackbody:[{index:0,rgb:[0,0,0]},{index:.2,rgb:[230,0,0]},{index:.4,rgb:[230,210,0]},{index:.7,rgb:[255,255,255]},{index:1,rgb:[160,200,255]}],earth:[{index:0,rgb:[0,0,130]},{index:.1,rgb:[0,180,180]},{index:.2,rgb:[40,210,40]},{index:.4,rgb:[230,230,50]},{index:.6,rgb:[120,70,20]},{index:1,rgb:[255,255,255]}],electric:[{index:0,rgb:[0,0,0]},{index:.15,rgb:[30,0,100]},{index:.4,rgb:[120,0,100]},{index:.6,rgb:[160,90,0]},{index:.8,rgb:[230,200,0]},{index:1,rgb:[255,250,220]}],alpha:[{index:0,rgb:[255,255,255,0]},{index:1,rgb:[255,255,255,1]}],viridis:[{index:0,rgb:[68,1,84]},{index:.13,rgb:[71,44,122]},{index:.25,rgb:[59,81,139]},{index:.38,rgb:[44,113,142]},{index:.5,rgb:[33,144,141]},{index:.63,rgb:[39,173,129]},{index:.75,rgb:[92,200,99]},{index:.88,rgb:[170,220,50]},{index:1,rgb:[253,231,37]}],inferno:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[31,12,72]},{index:.25,rgb:[85,15,109]},{index:.38,rgb:[136,34,106]},{index:.5,rgb:[186,54,85]},{index:.63,rgb:[227,89,51]},{index:.75,rgb:[249,140,10]},{index:.88,rgb:[249,201,50]},{index:1,rgb:[252,255,164]}],magma:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[28,16,68]},{index:.25,rgb:[79,18,123]},{index:.38,rgb:[129,37,129]},{index:.5,rgb:[181,54,122]},{index:.63,rgb:[229,80,100]},{index:.75,rgb:[251,135,97]},{index:.88,rgb:[254,194,135]},{index:1,rgb:[252,253,191]}],plasma:[{index:0,rgb:[13,8,135]},{index:.13,rgb:[75,3,161]},{index:.25,rgb:[125,3,168]},{index:.38,rgb:[168,34,150]},{index:.5,rgb:[203,70,121]},{index:.63,rgb:[229,107,93]},{index:.75,rgb:[248,148,65]},{index:.88,rgb:[253,195,40]},{index:1,rgb:[240,249,33]}],warm:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[172,0,187]},{index:.25,rgb:[219,0,170]},{index:.38,rgb:[255,0,130]},{index:.5,rgb:[255,63,74]},{index:.63,rgb:[255,123,0]},{index:.75,rgb:[234,176,0]},{index:.88,rgb:[190,228,0]},{index:1,rgb:[147,255,0]}],cool:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[116,0,218]},{index:.25,rgb:[98,74,237]},{index:.38,rgb:[68,146,231]},{index:.5,rgb:[0,204,197]},{index:.63,rgb:[0,247,146]},{index:.75,rgb:[0,255,88]},{index:.88,rgb:[40,255,8]},{index:1,rgb:[147,255,0]}],"rainbow-soft":[{index:0,rgb:[125,0,179]},{index:.1,rgb:[199,0,180]},{index:.2,rgb:[255,0,121]},{index:.3,rgb:[255,108,0]},{index:.4,rgb:[222,194,0]},{index:.5,rgb:[150,255,0]},{index:.6,rgb:[0,255,55]},{index:.7,rgb:[0,246,150]},{index:.8,rgb:[50,167,222]},{index:.9,rgb:[103,51,235]},{index:1,rgb:[124,0,186]}],bathymetry:[{index:0,rgb:[40,26,44]},{index:.13,rgb:[59,49,90]},{index:.25,rgb:[64,76,139]},{index:.38,rgb:[63,110,151]},{index:.5,rgb:[72,142,158]},{index:.63,rgb:[85,174,163]},{index:.75,rgb:[120,206,163]},{index:.88,rgb:[187,230,172]},{index:1,rgb:[253,254,204]}],cdom:[{index:0,rgb:[47,15,62]},{index:.13,rgb:[87,23,86]},{index:.25,rgb:[130,28,99]},{index:.38,rgb:[171,41,96]},{index:.5,rgb:[206,67,86]},{index:.63,rgb:[230,106,84]},{index:.75,rgb:[242,149,103]},{index:.88,rgb:[249,193,135]},{index:1,rgb:[254,237,176]}],chlorophyll:[{index:0,rgb:[18,36,20]},{index:.13,rgb:[25,63,41]},{index:.25,rgb:[24,91,59]},{index:.38,rgb:[13,119,72]},{index:.5,rgb:[18,148,80]},{index:.63,rgb:[80,173,89]},{index:.75,rgb:[132,196,122]},{index:.88,rgb:[175,221,162]},{index:1,rgb:[215,249,208]}],density:[{index:0,rgb:[54,14,36]},{index:.13,rgb:[89,23,80]},{index:.25,rgb:[110,45,132]},{index:.38,rgb:[120,77,178]},{index:.5,rgb:[120,113,213]},{index:.63,rgb:[115,151,228]},{index:.75,rgb:[134,185,227]},{index:.88,rgb:[177,214,227]},{index:1,rgb:[230,241,241]}],"freesurface-blue":[{index:0,rgb:[30,4,110]},{index:.13,rgb:[47,14,176]},{index:.25,rgb:[41,45,236]},{index:.38,rgb:[25,99,212]},{index:.5,rgb:[68,131,200]},{index:.63,rgb:[114,156,197]},{index:.75,rgb:[157,181,203]},{index:.88,rgb:[200,208,216]},{index:1,rgb:[241,237,236]}],"freesurface-red":[{index:0,rgb:[60,9,18]},{index:.13,rgb:[100,17,27]},{index:.25,rgb:[142,20,29]},{index:.38,rgb:[177,43,27]},{index:.5,rgb:[192,87,63]},{index:.63,rgb:[205,125,105]},{index:.75,rgb:[216,162,148]},{index:.88,rgb:[227,199,193]},{index:1,rgb:[241,237,236]}],oxygen:[{index:0,rgb:[64,5,5]},{index:.13,rgb:[106,6,15]},{index:.25,rgb:[144,26,7]},{index:.38,rgb:[168,64,3]},{index:.5,rgb:[188,100,4]},{index:.63,rgb:[206,136,11]},{index:.75,rgb:[220,174,25]},{index:.88,rgb:[231,215,44]},{index:1,rgb:[248,254,105]}],par:[{index:0,rgb:[51,20,24]},{index:.13,rgb:[90,32,35]},{index:.25,rgb:[129,44,34]},{index:.38,rgb:[159,68,25]},{index:.5,rgb:[182,99,19]},{index:.63,rgb:[199,134,22]},{index:.75,rgb:[212,171,35]},{index:.88,rgb:[221,210,54]},{index:1,rgb:[225,253,75]}],phase:[{index:0,rgb:[145,105,18]},{index:.13,rgb:[184,71,38]},{index:.25,rgb:[186,58,115]},{index:.38,rgb:[160,71,185]},{index:.5,rgb:[110,97,218]},{index:.63,rgb:[50,123,164]},{index:.75,rgb:[31,131,110]},{index:.88,rgb:[77,129,34]},{index:1,rgb:[145,105,18]}],salinity:[{index:0,rgb:[42,24,108]},{index:.13,rgb:[33,50,162]},{index:.25,rgb:[15,90,145]},{index:.38,rgb:[40,118,137]},{index:.5,rgb:[59,146,135]},{index:.63,rgb:[79,175,126]},{index:.75,rgb:[120,203,104]},{index:.88,rgb:[193,221,100]},{index:1,rgb:[253,239,154]}],temperature:[{index:0,rgb:[4,35,51]},{index:.13,rgb:[23,51,122]},{index:.25,rgb:[85,59,157]},{index:.38,rgb:[129,79,143]},{index:.5,rgb:[175,95,130]},{index:.63,rgb:[222,112,101]},{index:.75,rgb:[249,146,66]},{index:.88,rgb:[249,196,65]},{index:1,rgb:[232,250,91]}],turbidity:[{index:0,rgb:[34,31,27]},{index:.13,rgb:[65,50,41]},{index:.25,rgb:[98,69,52]},{index:.38,rgb:[131,89,57]},{index:.5,rgb:[161,112,59]},{index:.63,rgb:[185,140,66]},{index:.75,rgb:[202,174,88]},{index:.88,rgb:[216,209,126]},{index:1,rgb:[233,246,171]}],"velocity-blue":[{index:0,rgb:[17,32,64]},{index:.13,rgb:[35,52,116]},{index:.25,rgb:[29,81,156]},{index:.38,rgb:[31,113,162]},{index:.5,rgb:[50,144,169]},{index:.63,rgb:[87,173,176]},{index:.75,rgb:[149,196,189]},{index:.88,rgb:[203,221,211]},{index:1,rgb:[254,251,230]}],"velocity-green":[{index:0,rgb:[23,35,19]},{index:.13,rgb:[24,64,38]},{index:.25,rgb:[11,95,45]},{index:.38,rgb:[39,123,35]},{index:.5,rgb:[95,146,12]},{index:.63,rgb:[152,165,18]},{index:.75,rgb:[201,186,69]},{index:.88,rgb:[233,216,137]},{index:1,rgb:[255,253,205]}],cubehelix:[{index:0,rgb:[0,0,0]},{index:.07,rgb:[22,5,59]},{index:.13,rgb:[60,4,105]},{index:.2,rgb:[109,1,135]},{index:.27,rgb:[161,0,147]},{index:.33,rgb:[210,2,142]},{index:.4,rgb:[251,11,123]},{index:.47,rgb:[255,29,97]},{index:.53,rgb:[255,54,69]},{index:.6,rgb:[255,85,46]},{index:.67,rgb:[255,120,34]},{index:.73,rgb:[255,157,37]},{index:.8,rgb:[241,191,57]},{index:.87,rgb:[224,220,93]},{index:.93,rgb:[218,241,142]},{index:1,rgb:[227,253,198]}]}},{}],114:[function(t,e,r){"use strict";var n=t("./colorScale"),i=t("lerp");function a(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}function o(t){for(var e,r="#",n=0;n<3;++n)r+=("00"+(e=(e=t[n]).toString(16))).substr(e.length);return r}function s(t){return"rgba("+t.join(",")+")"}e.exports=function(t){var e,r,l,c,u,f,h,p,d,g;t||(t={});p=(t.nshades||72)-1,h=t.format||"hex",(f=t.colormap)||(f="jet");if("string"==typeof f){if(f=f.toLowerCase(),!n[f])throw Error(f+" not a supported colorscale");u=n[f]}else{if(!Array.isArray(f))throw Error("unsupported colormap option",f);u=f.slice()}if(u.length>p)throw new Error(f+" map requires nshades to be at least size "+u.length);d=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:t.alpha.slice():"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1];e=u.map(function(t){return Math.round(t.index*p)}),d[0]=Math.min(Math.max(d[0],0),1),d[1]=Math.min(Math.max(d[1],0),1);var v=u.map(function(t,e){var r=u[e].index,n=u[e].rgb.slice();return 4===n.length&&n[3]>=0&&n[3]<=1?n:(n[3]=d[0]+(d[1]-d[0])*r,n)}),m=[];for(g=0;g0?-1:l(t,e,a)?-1:1:0===s?c>0?1:l(t,e,r)?1:-1:i(c-s)}var h=n(t,e,r);if(h>0)return o>0&&n(t,e,a)>0?1:-1;if(h<0)return o>0||n(t,e,a)>0?1:-1;var p=n(t,e,a);return p>0?1:l(t,e,r)?1:-1};var n=t("robust-orientation"),i=t("signum"),a=t("two-sum"),o=t("robust-product"),s=t("robust-sum");function l(t,e,r){var n=a(t[0],-e[0]),i=a(t[1],-e[1]),l=a(r[0],-e[0]),c=a(r[1],-e[1]),u=s(o(n,l),o(i,c));return u[u.length-1]>=0}},{"robust-orientation":486,"robust-product":487,"robust-sum":491,signum:492,"two-sum":520}],116:[function(t,e,r){e.exports=function(t,e){var r=t.length,a=t.length-e.length;if(a)return a;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||n(t[0],t[1])-n(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=n(t[0],t[1]),c=n(e[0],e[1]);return n(l,t[2])-n(c,e[2])||n(l+t[2],o)-n(c+e[2],s);case 4:var u=t[0],f=t[1],h=t[2],p=t[3],d=e[0],g=e[1],v=e[2],m=e[3];return u+f+h+p-(d+g+v+m)||n(u,f,h,p)-n(d,g,v,m,d)||n(u+f,u+h,u+p,f+h,f+p,h+p)-n(d+g,d+v,d+m,g+v,g+m,v+m)||n(u+f+h,u+f+p,u+h+p,f+h+p)-n(d+g+v,d+g+m,d+v+m,g+v+m);default:for(var y=t.slice().sort(i),x=e.slice().sort(i),b=0;bt[r][0]&&(r=n);return er?[[r],[e]]:[[e]]}},{}],120:[function(t,e,r){"use strict";e.exports=function(t){var e=n(t),r=e.length;if(r<=2)return[];for(var i=new Array(r),a=e[r-1],o=0;o=e[l]&&(s+=1);a[o]=s}}return t}(o,r)}};var n=t("incremental-convex-hull"),i=t("affine-hull")},{"affine-hull":50,"incremental-convex-hull":396}],122:[function(t,e,r){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",CPV:"verde",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai)(?!.*\\brep).*china|^(?=.*peo)(?=.*rep).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COG:"^(?!.*\\bdem)(?!.*\\bd[\\.]?r)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CSK:"czechoslovakia",CZE:"^(?=.*rep).*czech|czechia|bohemia",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bd[\\.]?r|\\bd[\\.]?r.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"(^ireland)|(^republic.*ireland)",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat|people|north|d.*p.*.r).*\\bkorea|dprk|korea.*(d.*p.*r)",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"fed.*micronesia|micronesia.*fed",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",KOR:"^(?!.*d.*p.*r)(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea(?!.*d.*p.*r)",MDA:"moldov|b(a|e)ssarabia",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"south.africa|s\\\\..?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa|^(?!.*peo)(?=.*rep).*china",TJK:"tajik",THA:"thailand|\\bsiam",MKD:"macedonia|fyrom",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",TZA:"tanzania",USA:"united.?states\\b(?!.*islands)|\\bu\\.?s\\.?a\\.?\\b|^\\s*u\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],123:[function(t,e,r){e.exports=["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller"]},{}],124:[function(t,e,r){e.exports=["normal","condensed","semi-condensed","extra-condensed","ultra-condensed","expanded","semi-expanded","extra-expanded","ultra-expanded"]},{}],125:[function(t,e,r){e.exports=["normal","italic","oblique"]},{}],126:[function(t,e,r){e.exports=["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900"]},{}],127:[function(t,e,r){"use strict";e.exports={parse:t("./parse"),stringify:t("./stringify")}},{"./parse":129,"./stringify":130}],128:[function(t,e,r){"use strict";var n=t("css-font-size-keywords");e.exports={isSize:function(t){return/^[\d\.]/.test(t)||-1!==t.indexOf("/")||-1!==n.indexOf(t)}}},{"css-font-size-keywords":123}],129:[function(t,e,r){"use strict";var n=t("unquote"),i=t("css-global-keywords"),a=t("css-system-font-keywords"),o=t("css-font-weight-keywords"),s=t("css-font-style-keywords"),l=t("css-font-stretch-keywords"),c=t("string-split-by"),u=t("./lib/util").isSize;e.exports=h;var f=h.cache={};function h(t){if("string"!=typeof t)throw new Error("Font argument must be a string.");if(f[t])return f[t];if(""===t)throw new Error("Cannot parse an empty string.");if(-1!==a.indexOf(t))return f[t]={system:t};for(var e,r={style:"normal",variant:"normal",weight:"normal",stretch:"normal",lineHeight:"normal",size:"1rem",family:["serif"]},h=c(t,/\s+/);e=h.shift();){if(-1!==i.indexOf(e))return["style","variant","weight","stretch"].forEach(function(t){r[t]=e}),f[t]=r;if(-1===s.indexOf(e))if("normal"!==e&&"small-caps"!==e)if(-1===l.indexOf(e)){if(-1===o.indexOf(e)){if(u(e)){var d=c(e,"/");if(r.size=d[0],null!=d[1]?r.lineHeight=p(d[1]):"/"===h[0]&&(h.shift(),r.lineHeight=p(h.shift())),!h.length)throw new Error("Missing required font-family.");return r.family=c(h.join(" "),/\s*,\s*/).map(n),f[t]=r}throw new Error("Unknown or unsupported font token: "+e)}r.weight=e}else r.stretch=e;else r.variant=e;else r.style=e}throw new Error("Missing required font-size.")}function p(t){var e=parseFloat(t);return e.toString()===t?e:t}},{"./lib/util":128,"css-font-stretch-keywords":124,"css-font-style-keywords":125,"css-font-weight-keywords":126,"css-global-keywords":131,"css-system-font-keywords":132,"string-split-by":505,unquote:524}],130:[function(t,e,r){"use strict";var n=t("pick-by-alias"),i=t("./lib/util").isSize,a=g(t("css-global-keywords")),o=g(t("css-system-font-keywords")),s=g(t("css-font-weight-keywords")),l=g(t("css-font-style-keywords")),c=g(t("css-font-stretch-keywords")),u={normal:1,"small-caps":1},f={serif:1,"sans-serif":1,monospace:1,cursive:1,fantasy:1,"system-ui":1},h="1rem",p="serif";function d(t,e){if(t&&!e[t]&&!a[t])throw Error("Unknown keyword `"+t+"`");return t}function g(t){for(var e={},r=0;r=0;--p)a[p]=c*t[p]+u*e[p]+f*r[p]+h*n[p];return a}return c*t+u*e+f*r+h*n},e.exports.derivative=function(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}},{}],134:[function(t,e,r){"use strict";var n=t("./lib/thunk.js");function i(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}e.exports=function(t){var e=new i;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var a=0;a0)throw new Error("cwise: pre() block may not reference array args");if(a0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(a),e.shimArgs.push("scalar"+a);else if("index"===o){if(e.indexArgs.push(a),a0)throw new Error("cwise: pre() block may not reference array index");if(a0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(a),ar.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},{"./lib/thunk.js":136}],135:[function(t,e,r){"use strict";var n=t("uniq");function i(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],c=[],u=0,f=0;for(n=0;n0&&l.push("var "+c.join(",")),n=a-1;n>=0;--n)u=t[n],l.push(["for(i",n,"=0;i",n,"0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",u,"]"].join(""))),l.push("}")}return l.join("\n")}function a(t,e,r){for(var n=t.body,i=[],a=[],o=0;o0&&y.push("shape=SS.slice(0)"),t.indexArgs.length>0){var x=new Array(r);for(l=0;l0&&m.push("var "+y.join(",")),l=0;l3&&m.push(a(t.pre,t,s));var k=a(t.body,t,s),M=function(t){for(var e=0,r=t[0].length;e0,c=[],u=0;u0;){"].join("")),c.push(["if(j",u,"<",s,"){"].join("")),c.push(["s",e[u],"=j",u].join("")),c.push(["j",u,"=0"].join("")),c.push(["}else{s",e[u],"=",s].join("")),c.push(["j",u,"-=",s,"}"].join("")),l&&c.push(["index[",e[u],"]=j",u].join(""));for(u=0;u3&&m.push(a(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+m.join("\n")+"\n----------");var A=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",M,function(t){for(var e=new Array(t.length),r=!0,n=0;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}(s)].join("");return new Function(["function ",A,"(",v.join(","),"){",m.join("\n"),"} return ",A].join(""))()}},{uniq:523}],136:[function(t,e,r){"use strict";var n=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],c=[],u=0;u0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[u]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[u])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),u=0;ue?1:t>=e?0:NaN}function r(t){var r;return 1===t.length&&(r=t,t=function(t,n){return e(r(t),n)}),{left:function(e,r,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}var n=r(e),i=n.right,a=n.left;function o(t,e){return[t,e]}function s(t){return null===t?NaN:+t}function l(t,e){var r,n,i=t.length,a=0,o=-1,l=0,c=0;if(null==e)for(;++o1)return c/(a-1)}function c(t,e){var r=l(t,e);return r?Math.sqrt(r):r}function u(t,e){var r,n,i,a=t.length,o=-1;if(null==e){for(;++o=r)for(n=i=r;++or&&(n=r),i=r)for(n=i=r;++or&&(n=r),i=0?(a>=m?10:a>=y?5:a>=x?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(a>=m?10:a>=y?5:a>=x?2:1)}function _(t,e,r){var n=Math.abs(e-t)/Math.max(0,r),i=Math.pow(10,Math.floor(Math.log(n)/Math.LN10)),a=n/i;return a>=m?i*=10:a>=y?i*=5:a>=x&&(i*=2),e=1)return+r(t[n-1],n-1,t);var n,i=(n-1)*e,a=Math.floor(i),o=+r(t[a],a,t);return o+(+r(t[a+1],a+1,t)-o)*(i-a)}}function M(t,e){var r,n,i=t.length,a=-1;if(null==e){for(;++a=r)for(n=r;++ar&&(n=r)}else for(;++a=r)for(n=r;++ar&&(n=r);return n}function A(t){if(!(i=t.length))return[];for(var e=-1,r=M(t,T),n=new Array(r);++et?1:e>=t?0:NaN},t.deviation=c,t.extent=u,t.histogram=function(){var t=g,e=u,r=w;function n(n){var a,o,s=n.length,l=new Array(s);for(a=0;af;)h.pop(),--p;var d,g=new Array(p+1);for(a=0;a<=p;++a)(d=g[a]=[]).x0=a>0?h[a-1]:u,d.x1=a=r)for(n=r;++an&&(n=r)}else for(;++a=r)for(n=r;++an&&(n=r);return n},t.mean=function(t,e){var r,n=t.length,i=n,a=-1,o=0;if(null==e)for(;++a=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r},t.min=M,t.pairs=function(t,e){null==e&&(e=o);for(var r=0,n=t.length-1,i=t[0],a=new Array(n<0?0:n);r0)return[t];if((n=e0)for(t=Math.ceil(t/o),e=Math.floor(e/o),a=new Array(i=Math.ceil(e-t+1));++s=l.length)return null!=t&&n.sort(t),null!=e?e(n):n;for(var s,c,f,h=-1,p=n.length,d=l[i++],g=r(),v=a();++hl.length)return r;var i,a=c[n-1];return null!=e&&n>=l.length?i=r.entries():(i=[],r.each(function(e,r){i.push({key:r,values:t(e,n)})})),null!=a?i.sort(function(t,e){return a(t.key,e.key)}):i}(u(t,0,a,o),0)},key:function(t){return l.push(t),s},sortKeys:function(t){return c[l.length-1]=t,s},sortValues:function(e){return t=e,s},rollup:function(t){return e=t,s}}},t.set=c,t.map=r,t.keys=function(t){var e=[];for(var r in t)e.push(r);return e},t.values=function(t){var e=[];for(var r in t)e.push(t[r]);return e},t.entries=function(t){var e=[];for(var r in t)e.push({key:r,value:t[r]});return e},Object.defineProperty(t,"__esModule",{value:!0})}("object"==typeof r&&"undefined"!=typeof e?r:n.d3=n.d3||{})},{}],142:[function(t,e,r){var n;n=this,function(t){"use strict";function e(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function r(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function n(){}var i="\\s*([+-]?\\d+)\\s*",a="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",o="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",s=/^#([0-9a-f]{3})$/,l=/^#([0-9a-f]{6})$/,c=new RegExp("^rgb\\("+[i,i,i]+"\\)$"),u=new RegExp("^rgb\\("+[o,o,o]+"\\)$"),f=new RegExp("^rgba\\("+[i,i,i,a]+"\\)$"),h=new RegExp("^rgba\\("+[o,o,o,a]+"\\)$"),p=new RegExp("^hsl\\("+[a,o,o]+"\\)$"),d=new RegExp("^hsla\\("+[a,o,o,a]+"\\)$"),g={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function v(t){var e;return t=(t+"").trim().toLowerCase(),(e=s.exec(t))?new _((e=parseInt(e[1],16))>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):(e=l.exec(t))?m(parseInt(e[1],16)):(e=c.exec(t))?new _(e[1],e[2],e[3],1):(e=u.exec(t))?new _(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=f.exec(t))?y(e[1],e[2],e[3],e[4]):(e=h.exec(t))?y(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=p.exec(t))?k(e[1],e[2]/100,e[3]/100,1):(e=d.exec(t))?k(e[1],e[2]/100,e[3]/100,e[4]):g.hasOwnProperty(t)?m(g[t]):"transparent"===t?new _(NaN,NaN,NaN,0):null}function m(t){return new _(t>>16&255,t>>8&255,255&t,1)}function y(t,e,r,n){return n<=0&&(t=e=r=NaN),new _(t,e,r,n)}function x(t){return t instanceof n||(t=v(t)),t?new _((t=t.rgb()).r,t.g,t.b,t.opacity):new _}function b(t,e,r,n){return 1===arguments.length?x(t):new _(t,e,r,null==n?1:n)}function _(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function w(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function k(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new A(t,e,r,n)}function M(t,e,r,i){return 1===arguments.length?function(t){if(t instanceof A)return new A(t.h,t.s,t.l,t.opacity);if(t instanceof n||(t=v(t)),!t)return new A;if(t instanceof A)return t;var e=(t=t.rgb()).r/255,r=t.g/255,i=t.b/255,a=Math.min(e,r,i),o=Math.max(e,r,i),s=NaN,l=o-a,c=(o+a)/2;return l?(s=e===o?(r-i)/l+6*(r0&&c<1?0:s,new A(s,l,c,t.opacity)}(t):new A(t,e,r,null==i?1:i)}function A(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function T(t,e,r){return 255*(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)}e(n,v,{displayable:function(){return this.rgb().displayable()},hex:function(){return this.rgb().hex()},toString:function(){return this.rgb()+""}}),e(_,b,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new _(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new _(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},hex:function(){return"#"+w(this.r)+w(this.g)+w(this.b)},toString:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}})),e(A,M,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new A(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new A(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new _(T(t>=240?t-240:t+120,i,n),T(t,i,n),T(t<120?t+240:t-120,i,n),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1}}));var S=Math.PI/180,C=180/Math.PI,E=.96422,L=1,z=.82521,O=4/29,I=6/29,P=3*I*I,D=I*I*I;function R(t){if(t instanceof B)return new B(t.l,t.a,t.b,t.opacity);if(t instanceof G){if(isNaN(t.h))return new B(t.l,0,0,t.opacity);var e=t.h*S;return new B(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}t instanceof _||(t=x(t));var r,n,i=U(t.r),a=U(t.g),o=U(t.b),s=N((.2225045*i+.7168786*a+.0606169*o)/L);return i===a&&a===o?r=n=s:(r=N((.4360747*i+.3850649*a+.1430804*o)/E),n=N((.0139322*i+.0971045*a+.7141733*o)/z)),new B(116*s-16,500*(r-s),200*(s-n),t.opacity)}function F(t,e,r,n){return 1===arguments.length?R(t):new B(t,e,r,null==n?1:n)}function B(t,e,r,n){this.l=+t,this.a=+e,this.b=+r,this.opacity=+n}function N(t){return t>D?Math.pow(t,1/3):t/P+O}function j(t){return t>I?t*t*t:P*(t-O)}function V(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function U(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function q(t){if(t instanceof G)return new G(t.h,t.c,t.l,t.opacity);if(t instanceof B||(t=R(t)),0===t.a&&0===t.b)return new G(NaN,0,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*C;return new G(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function H(t,e,r,n){return 1===arguments.length?q(t):new G(t,e,r,null==n?1:n)}function G(t,e,r,n){this.h=+t,this.c=+e,this.l=+r,this.opacity=+n}e(B,F,r(n,{brighter:function(t){return new B(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new B(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,r=isNaN(this.b)?t:t-this.b/200;return new _(V(3.1338561*(e=E*j(e))-1.6168667*(t=L*j(t))-.4906146*(r=z*j(r))),V(-.9787684*e+1.9161415*t+.033454*r),V(.0719453*e-.2289914*t+1.4052427*r),this.opacity)}})),e(G,H,r(n,{brighter:function(t){return new G(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new G(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return R(this).rgb()}}));var W=-.14861,Y=1.78277,X=-.29227,Z=-.90649,$=1.97294,J=$*Z,K=$*Y,Q=Y*X-Z*W;function tt(t,e,r,n){return 1===arguments.length?function(t){if(t instanceof et)return new et(t.h,t.s,t.l,t.opacity);t instanceof _||(t=x(t));var e=t.r/255,r=t.g/255,n=t.b/255,i=(Q*n+J*e-K*r)/(Q+J-K),a=n-i,o=($*(r-i)-X*a)/Z,s=Math.sqrt(o*o+a*a)/($*i*(1-i)),l=s?Math.atan2(o,a)*C-120:NaN;return new et(l<0?l+360:l,s,i,t.opacity)}(t):new et(t,e,r,null==n?1:n)}function et(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}e(et,tt,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new et(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new et(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*S,e=+this.l,r=isNaN(this.s)?0:this.s*e*(1-e),n=Math.cos(t),i=Math.sin(t);return new _(255*(e+r*(W*n+Y*i)),255*(e+r*(X*n+Z*i)),255*(e+r*($*n)),this.opacity)}})),t.color=v,t.rgb=b,t.hsl=M,t.lab=F,t.hcl=H,t.lch=function(t,e,r,n){return 1===arguments.length?q(t):new G(r,e,t,null==n?1:n)},t.gray=function(t,e){return new B(t,0,0,null==e?1:e)},t.cubehelix=tt,Object.defineProperty(t,"__esModule",{value:!0})}("object"==typeof r&&"undefined"!=typeof e?r:n.d3=n.d3||{})},{}],143:[function(t,e,r){var n;n=this,function(t){"use strict";var e={value:function(){}};function r(){for(var t,e=0,r=arguments.length,i={};e=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),l=-1,c=s.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++l0)for(var r,n,i=new Array(r),a=0;ah+c||np+c||au.index){var f=h-s.x-s.vx,v=p-s.y-s.vy,m=f*f+v*v;mt.r&&(t.r=t[e].r)}function h(){if(r){var e,i,a=r.length;for(n=new Array(a),e=0;e=c)){(t.data!==r||t.next)&&(0===f&&(d+=(f=o())*f),0===h&&(d+=(h=o())*h),d1?(null==r?u.remove(t):u.set(t,y(r)),e):u.get(t)},find:function(e,r,n){var i,a,o,s,l,c=0,u=t.length;for(null==n?n=1/0:n*=n,c=0;c1?(h.on(t,r),e):h.on(t)}}},t.forceX=function(t){var e,r,n,i=a(.1);function o(t){for(var i,a=0,o=e.length;a=1?(n=1,e-1):Math.floor(n*e),a=t[i],o=t[i+1],s=i>0?t[i-1]:2*a-o,l=i180||r<-180?r-360*Math.round(r/360):r):a(isNaN(t)?e:t)}function l(t){return 1==(t=+t)?c:function(e,r){return r-e?function(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}(e,r,t):a(isNaN(e)?r:e)}}function c(t,e){var r=e-t;return r?o(t,r):a(isNaN(t)?e:t)}var u=function t(r){var n=l(r);function i(t,r){var i=n((t=e.rgb(t)).r,(r=e.rgb(r)).r),a=n(t.g,r.g),o=n(t.b,r.b),s=c(t.opacity,r.opacity);return function(e){return t.r=i(e),t.g=a(e),t.b=o(e),t.opacity=s(e),t+""}}return i.gamma=t,i}(1);function f(t){return function(r){var n,i,a=r.length,o=new Array(a),s=new Array(a),l=new Array(a);for(n=0;na&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:v(r,n)})),a=x.lastIndex;return a180?e+=360:e-t>180&&(t+=360),a.push({i:r.push(i(r)+"rotate(",null,n)-2,x:v(t,e)})):e&&r.push(i(r)+"rotate("+e+n)}(a.rotate,o.rotate,s,l),function(t,e,r,a){t!==e?a.push({i:r.push(i(r)+"skewX(",null,n)-2,x:v(t,e)}):e&&r.push(i(r)+"skewX("+e+n)}(a.skewX,o.skewX,s,l),function(t,e,r,n,a,o){if(t!==r||e!==n){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:v(t,r)},{i:s-2,x:v(e,n)})}else 1===r&&1===n||a.push(i(a)+"scale("+r+","+n+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,l),a=o=null,function(t){for(var e,r=-1,n=l.length;++r=(a=(g+m)/2))?g=a:m=a,(u=r>=(o=(v+y)/2))?v=o:y=o,i=p,!(p=p[f=u<<1|c]))return i[f]=d,t;if(s=+t._x.call(null,p.data),l=+t._y.call(null,p.data),e===s&&r===l)return d.next=p,i?i[f]=d:t._root=d,t;do{i=i?i[f]=new Array(4):t._root=new Array(4),(c=e>=(a=(g+m)/2))?g=a:m=a,(u=r>=(o=(v+y)/2))?v=o:y=o}while((f=u<<1|c)==(h=(l>=o)<<1|s>=a));return i[h]=p,i[f]=d,t}var r=function(t,e,r,n,i){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=i};function n(t){return t[0]}function i(t){return t[1]}function a(t,e,r){var a=new o(null==e?n:e,null==r?i:r,NaN,NaN,NaN,NaN);return null==t?a:a.addAll(t)}function o(t,e,r,n,i,a){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=i,this._y1=a,this._root=void 0}function s(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var l=a.prototype=o.prototype;l.copy=function(){var t,e,r=new o(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=s(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var i=0;i<4;++i)(e=n.source[i])&&(e.length?t.push({source:e,target:n.target[i]=new Array(4)}):n.target[i]=s(e));return r},l.add=function(t){var r=+this._x.call(null,t),n=+this._y.call(null,t);return e(this.cover(r,n),r,n,t)},l.addAll=function(t){var r,n,i,a,o=t.length,s=new Array(o),l=new Array(o),c=1/0,u=1/0,f=-1/0,h=-1/0;for(n=0;nf&&(f=i),ah&&(h=a));for(ft||t>i||n>e||e>a))return this;var o,s,l=i-r,c=this._root;switch(s=(e<(n+a)/2)<<1|t<(r+i)/2){case 0:do{(o=new Array(4))[s]=c,c=o}while(a=n+(l*=2),t>(i=r+l)||e>a);break;case 1:do{(o=new Array(4))[s]=c,c=o}while(a=n+(l*=2),(r=i-l)>t||e>a);break;case 2:do{(o=new Array(4))[s]=c,c=o}while(n=a-(l*=2),t>(i=r+l)||n>e);break;case 3:do{(o=new Array(4))[s]=c,c=o}while(n=a-(l*=2),(r=i-l)>t||n>e)}this._root&&this._root.length&&(this._root=c)}return this._x0=r,this._y0=n,this._x1=i,this._y1=a,this},l.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},l.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},l.find=function(t,e,n){var i,a,o,s,l,c,u,f=this._x0,h=this._y0,p=this._x1,d=this._y1,g=[],v=this._root;for(v&&g.push(new r(v,f,h,p,d)),null==n?n=1/0:(f=t-n,h=e-n,p=t+n,d=e+n,n*=n);c=g.pop();)if(!(!(v=c.node)||(a=c.x0)>p||(o=c.y0)>d||(s=c.x1)=y)<<1|t>=m)&&(c=g[g.length-1],g[g.length-1]=g[g.length-1-u],g[g.length-1-u]=c)}else{var x=t-+this._x.call(null,v.data),b=e-+this._y.call(null,v.data),_=x*x+b*b;if(_=(s=(d+v)/2))?d=s:v=s,(u=o>=(l=(g+m)/2))?g=l:m=l,e=p,!(p=p[f=u<<1|c]))return this;if(!p.length)break;(e[f+1&3]||e[f+2&3]||e[f+3&3])&&(r=e,h=f)}for(;p.data!==t;)if(n=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,n?(i?n.next=i:delete n.next,this):e?(i?e[f]=i:delete e[f],(p=e[0]||e[1]||e[2]||e[3])&&p===(e[3]||e[2]||e[1]||e[0])&&!p.length&&(r?r[h]=p:this._root=p),this):(this._root=i,this)},l.removeAll=function(t){for(var e=0,r=t.length;e=0&&r._call.call(null,t),r=r._next;--n}function m(){l=(s=u.now())+c,n=i=0;try{v()}finally{n=0,function(){var t,n,i=e,a=1/0;for(;i;)i._call?(a>i._time&&(a=i._time),t=i,i=i._next):(n=i._next,i._next=null,i=t?t._next=n:e=n);r=t,x(a)}(),l=0}}function y(){var t=u.now(),e=t-s;e>o&&(c-=e,s=t)}function x(t){n||(i&&(i=clearTimeout(i)),t-l>24?(t<1/0&&(i=setTimeout(m,t-u.now()-c)),a&&(a=clearInterval(a))):(a||(s=u.now(),a=setInterval(y,o)),n=1,f(m)))}d.prototype=g.prototype={constructor:d,restart:function(t,n,i){if("function"!=typeof t)throw new TypeError("callback is not a function");i=(null==i?h():+i)+(null==n?0:+n),this._next||r===this||(r?r._next=this:e=this,r=this),this._call=t,this._time=i,x()},stop:function(){this._call&&(this._call=null,this._time=1/0,x())}};t.now=h,t.timer=g,t.timerFlush=v,t.timeout=function(t,e,r){var n=new d;return e=null==e?0:+e,n.restart(function(r){n.stop(),t(r+e)},e,r),n},t.interval=function(t,e,r){var n=new d,i=e;return null==e?(n.restart(t,e,r),n):(e=+e,r=null==r?h():+r,n.restart(function a(o){o+=i,n.restart(a,i+=e,r),t(o)},e,r),n)},Object.defineProperty(t,"__esModule",{value:!0})}("object"==typeof r&&"undefined"!=typeof e?r:n.d3=n.d3||{})},{}],148:[function(t,e,r){!function(){var t={version:"3.5.17"},r=[].slice,n=function(t){return r.call(t)},i=this.document;function a(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(i)try{n(i.documentElement.childNodes)[0].nodeType}catch(t){n=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),i)try{i.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var s=this.Element.prototype,l=s.setAttribute,c=s.setAttributeNS,u=this.CSSStyleDeclaration.prototype,f=u.setProperty;s.setAttribute=function(t,e){l.call(this,t,e+"")},s.setAttributeNS=function(t,e,r){c.call(this,t,e,r+"")},u.setProperty=function(t,e,r){f.call(this,t,e+"",r)}}function h(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function d(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}t.ascending=h,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},t.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},t.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),i=n){r=i=n;break}for(;++an&&(r=n),i1)return o/(l-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var v=g(h);function m(t){return t.length}t.bisectLeft=v.left,t.bisect=t.bisectRight=v.right,t.bisector=function(t){return g(1===t.length?function(e,r){return h(t(e),r)}:t)},t.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,a<2&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],i=new Array(r<0?0:r);e=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r};var y=Math.abs;function x(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function b(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,i=[],a=function(t){var e=1;for(;t*e%1;)e*=10;return e}(y(r)),o=-1;if(t*=a,e*=a,(r*=a)<0)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=i.length)return r?r.call(n,a):e?a.sort(e):a;for(var l,c,u,f,h=-1,p=a.length,d=i[s++],g=new b;++h=i.length)return e;var n=[],o=a[r++];return e.forEach(function(e,i){n.push({key:e,values:t(i,r)})}),o?n.sort(function(t,e){return o(t.key,e.key)}):n}(o(t.map,e,0),0)},n.key=function(t){return i.push(t),n},n.sortKeys=function(t){return a[i.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new L;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(V,"\\$&")};var V=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,U={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function q(t){return U(t,Y),t}var H=function(t,e){return e.querySelector(t)},G=function(t,e){return e.querySelectorAll(t)},W=function(t,e){var r=t.matches||t[I(t,"matchesSelector")];return(W=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(H=function(t,e){return Sizzle(t,e)[0]||null},G=Sizzle,W=Sizzle.matchesSelector),t.selection=function(){return t.select(i.documentElement)};var Y=t.selection.prototype=[];function X(t){return"function"==typeof t?t:function(){return H(t,this)}}function Z(t){return"function"==typeof t?t:function(){return G(t,this)}}Y.select=function(t){var e,r,n,i,a=[];t=X(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),J.hasOwnProperty(r)?{space:J[r],local:t}:t}},Y.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each(K(r,e[r]));return this}return this.each(K(e,r))},Y.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=et(t)).length,i=-1;if(e=r.classList){for(;++i=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},Y.sort=function(t){t=function(t){arguments.length||(t=h);return function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.slice(0,o));var l=dt.get(e);function c(){var t=this[a];t&&(this.removeEventListener(e,t,t.$),delete this[a])}return l&&(e=l,s=vt),o?r?function(){var t=s(r,n(arguments));c.call(this),this.addEventListener(e,this[a]=t,t.$=i),t._=r}:c:r?D:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var i in this)if(r=i.match(n)){var a=this[i];this.removeEventListener(r[1],a,a.$),delete this[i]}}}t.selection.enter=ft,t.selection.enter.prototype=ht,ht.append=Y.append,ht.empty=Y.empty,ht.node=Y.node,ht.call=Y.call,ht.size=Y.size,ht.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++s=n&&(n=e+1);!(o=s[n])&&++n0?1:t<0?-1:0}function Ot(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function It(t){return t>1?0:t<-1?At:Math.acos(t)}function Pt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function Dt(t){return((t=Math.exp(t))+1/t)/2}function Rt(t){return(t=Math.sin(t/2))*t}var Ft=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,f=l-a,h=u*u+f*f;if(h0&&(e=e.transition().duration(g)),e.call(w.event)}function S(){c&&c.domain(l.range().map(function(t){return(t-h.x)/h.k}).map(l.invert)),f&&f.domain(u.range().map(function(t){return(t-h.y)/h.k}).map(u.invert))}function C(t){v++||t({type:"zoomstart"})}function E(t){S(),t({type:"zoom",scale:h.k,translate:[h.x,h.y]})}function L(t){--v||(t({type:"zoomend"}),r=null)}function z(){var e=this,r=_.of(e,arguments),n=0,i=t.select(o(e)).on(y,function(){n=1,A(t.mouse(e),a),E(r)}).on(x,function(){i.on(y,null).on(x,null),s(n),L(r)}),a=k(t.mouse(e)),s=xt(e);fs.call(e),C(r)}function O(){var e,r=this,n=_.of(r,arguments),i={},a=0,o=".zoom-"+t.event.changedTouches[0].identifier,l="touchmove"+o,c="touchend"+o,u=[],f=t.select(r),p=xt(r);function d(){var n=t.touches(r);return e=h.k,n.forEach(function(t){t.identifier in i&&(i[t.identifier]=k(t))}),n}function g(){var e=t.event.target;t.select(e).on(l,v).on(c,y),u.push(e);for(var n=t.event.changedTouches,o=0,f=n.length;o1){m=p[0];var x=p[1],b=m[0]-x[0],_=m[1]-x[1];a=b*b+_*_}}function v(){var o,l,c,u,f=t.touches(r);fs.call(r);for(var h=0,p=f.length;h360?t-=360:t<0&&(t+=360),t<60?n+(i-n)*t/60:t<180?i:t<240?n+(i-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(i=r<=.5?r*(1+e):r+e-r*e),new ae(a(t+120),a(t),a(t-120))}function Gt(e,r,n){return this instanceof Gt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Gt?new Gt(e.h,e.c,e.l):ee(e instanceof Xt?e.l:(e=he((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Gt(e,r,n)}qt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ut(this.h,this.s,this.l/t)},qt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ut(this.h,this.s,t*this.l)},qt.rgb=function(){return Ht(this.h,this.s,this.l)},t.hcl=Gt;var Wt=Gt.prototype=new Vt;function Yt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Xt(r,Math.cos(t*=Et)*e,Math.sin(t)*e)}function Xt(t,e,r){return this instanceof Xt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Xt?new Xt(t.l,t.a,t.b):t instanceof Gt?Yt(t.h,t.c,t.l):he((t=ae(t)).r,t.g,t.b):new Xt(t,e,r)}Wt.brighter=function(t){return new Gt(this.h,this.c,Math.min(100,this.l+Zt*(arguments.length?t:1)))},Wt.darker=function(t){return new Gt(this.h,this.c,Math.max(0,this.l-Zt*(arguments.length?t:1)))},Wt.rgb=function(){return Yt(this.h,this.c,this.l).rgb()},t.lab=Xt;var Zt=18,$t=.95047,Jt=1,Kt=1.08883,Qt=Xt.prototype=new Vt;function te(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return new ae(ie(3.2404542*(i=re(i)*$t)-1.5371385*(n=re(n)*Jt)-.4985314*(a=re(a)*Kt)),ie(-.969266*i+1.8760108*n+.041556*a),ie(.0556434*i-.2040259*n+1.0572252*a))}function ee(t,e,r){return t>0?new Gt(Math.atan2(r,e)*Lt,Math.sqrt(e*e+r*r),t):new Gt(NaN,NaN,t)}function re(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ne(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ie(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ae(t,e,r){return this instanceof ae?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ae?new ae(t.r,t.g,t.b):ue(""+t,ae,Ht):new ae(t,e,r)}function oe(t){return new ae(t>>16,t>>8&255,255&t)}function se(t){return oe(t)+""}Qt.brighter=function(t){return new Xt(Math.min(100,this.l+Zt*(arguments.length?t:1)),this.a,this.b)},Qt.darker=function(t){return new Xt(Math.max(0,this.l-Zt*(arguments.length?t:1)),this.a,this.b)},Qt.rgb=function(){return te(this.l,this.a,this.b)},t.rgb=ae;var le=ae.prototype=new Vt;function ce(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function ue(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(de(i[0]),de(i[1]),de(i[2]))}return(a=ge.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o|=o>>4,s=240&a,s|=s>>4,l=15&a,l|=l<<4):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function fe(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=l<.5?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(e0&&l<1?0:n),new Ut(n,i,l)}function he(t,e,r){var n=ne((.4124564*(t=pe(t))+.3575761*(e=pe(e))+.1804375*(r=pe(r)))/$t),i=ne((.2126729*t+.7151522*e+.072175*r)/Jt);return Xt(116*i-16,500*(n-i),200*(i-ne((.0193339*t+.119192*e+.9503041*r)/Kt)))}function pe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function de(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}le.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=i.call(o,c)}catch(t){return void s.error.call(o,t)}s.load.call(o,t)}else s.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=f:c.onreadystatechange=function(){c.readyState>3&&f()},c.onprogress=function(e){var r=t.event;t.event=e;try{s.progress.call(o,c)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return i=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}}),o.send=function(t,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),c.open(t,e,!0),null==r||"accept"in l||(l.accept=r+",*/*"),c.setRequestHeader)for(var a in l)c.setRequestHeader(a,l[a]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=u&&(c.responseType=u),null!=i&&o.on("error",i).on("load",function(t){i(null,t)}),s.beforesend.call(o,c),c.send(null==n?null:n),o},o.abort=function(){return c.abort(),o},t.rebind(o,s,"on"),null==a?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(a))}ge.forEach(function(t,e){ge.set(t,oe(e))}),t.functor=ve,t.xhr=me(z),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function i(t,r,n){arguments.length<3&&(n=r,r=null);var i=ye(t,e,null==r?a:o(r),n);return i.row=function(t){return arguments.length?i.response(null==(r=t)?a:o(t)):r},i}function a(t){return i.parse(t.responseText)}function o(t){return function(e){return i.parse(e.responseText,t)}}function s(e){return e.map(l).join(t)}function l(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,e){var r;return i.parseRows(t,function(t,n){if(r)return r(t,n-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,r){return e(i(t),r)}:i})},i.parseRows=function(t,e){var r,i,a={},o={},s=[],l=t.length,c=0,u=0;function f(){if(c>=l)return o;if(i)return i=!1,a;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(we),we=setTimeout(Ae,e)),_e=0):(_e=1,ke(Ae))}function Te(){for(var t=Date.now(),e=xe;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Se(){for(var t,e=xe,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}});t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Ce(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),Ee[8+n/3]};var Le=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ze=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Ce(e,r))).toFixed(Math.max(0,Math.min(20,Ce(e*(1+1e-15),r))))}});function Oe(t){return t+""}var Ie=t.time={},Pe=Date;function De(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}De.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Re.setUTCDate.apply(this._,arguments)},setDay:function(){Re.setUTCDay.apply(this._,arguments)},setFullYear:function(){Re.setUTCFullYear.apply(this._,arguments)},setHours:function(){Re.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Re.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Re.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Re.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Re.setUTCSeconds.apply(this._,arguments)},setTime:function(){Re.setTime.apply(this._,arguments)}};var Re=Date.prototype;function Fe(t,e,r){function n(e){var r=t(e),n=a(r,1);return e-r1)for(;o68?1900:2e3),r+i[0].length):-1}function $e(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function Je(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function Ke(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Qe(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function tr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function er(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function rr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function nr(t,e,r){je.lastIndex=0;var n=je.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ir(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=y(e)/60|0,i=y(e)%60;return r+Ue(n,"0",2)+Ue(i,"0",2)}function ar(t,e,r){Ve.lastIndex=0;var n=Ve.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function or(t){for(var e=t.length,r=-1;++r0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(r-=s,r+s)),!((l+=s+1)>e));)s=i[o=(o+1)%i.length];return a.reverse().join(n)}:z;return function(e){var n=Le.exec(e),i=n[1]||" ",s=n[2]||">",l=n[3]||"-",c=n[4]||"",u=n[5],f=+n[6],h=n[7],p=n[8],d=n[9],g=1,v="",m="",y=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===i&&"="===s)&&(u=i="0",s="="),d){case"n":h=!0,d="g";break;case"%":g=100,m="%",d="f";break;case"p":g=100,m="%",d="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+d.toLowerCase());case"c":x=!1;case"d":y=!0,p=0;break;case"s":g=-1,d="r"}"$"===c&&(v=a[0],m=a[1]),"r"!=d||p||(d="g"),null!=p&&("g"==d?p=Math.max(1,Math.min(21,p)):"e"!=d&&"f"!=d||(p=Math.max(0,Math.min(20,p)))),d=ze.get(d)||Oe;var b=u&&h;return function(e){var n=m;if(y&&e%1)return"";var a=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===l?"":l;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),n=c.symbol+m}else e*=g;var _,w,k=(e=d(e,p)).lastIndexOf(".");if(k<0){var M=x?e.lastIndexOf("e"):-1;M<0?(_=e,w=""):(_=e.substring(0,M),w=e.substring(M))}else _=e.substring(0,k),w=r+e.substring(k+1);!u&&h&&(_=o(_,1/0));var A=v.length+_.length+w.length+(b?0:a.length),T=A"===s?T+a+e:"^"===s?T.substring(0,A>>=1)+a+e+T.substring(A):a+(b?e:T+e))+n}}}(e),timeFormat:function(e){var r=e.dateTime,n=e.date,i=e.time,a=e.periods,o=e.days,s=e.shortDays,l=e.months,c=e.shortMonths;function u(t){var e=t.length;function r(r){for(var n,i,a,o=[],s=-1,l=0;++s=c)return-1;if(37===(i=e.charCodeAt(s++))){if(o=e.charAt(s++),!(a=w[o in Ne?e.charAt(s++):o])||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}u.utc=function(t){var e=u(t);function r(t){try{var r=new(Pe=De);return r._=t,e(r)}finally{Pe=Date}}return r.parse=function(t){try{Pe=De;var r=e.parse(t);return r&&r._}finally{Pe=Date}},r.toString=e.toString,r},u.multi=u.utc.multi=or;var h=t.map(),p=qe(o),d=He(o),g=qe(s),v=He(s),m=qe(l),y=He(l),x=qe(c),b=He(c);a.forEach(function(t,e){h.set(t.toLowerCase(),e)});var _={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:u(r),d:function(t,e){return Ue(t.getDate(),e,2)},e:function(t,e){return Ue(t.getDate(),e,2)},H:function(t,e){return Ue(t.getHours(),e,2)},I:function(t,e){return Ue(t.getHours()%12||12,e,2)},j:function(t,e){return Ue(1+Ie.dayOfYear(t),e,3)},L:function(t,e){return Ue(t.getMilliseconds(),e,3)},m:function(t,e){return Ue(t.getMonth()+1,e,2)},M:function(t,e){return Ue(t.getMinutes(),e,2)},p:function(t){return a[+(t.getHours()>=12)]},S:function(t,e){return Ue(t.getSeconds(),e,2)},U:function(t,e){return Ue(Ie.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Ue(Ie.mondayOfYear(t),e,2)},x:u(n),X:u(i),y:function(t,e){return Ue(t.getFullYear()%100,e,2)},Y:function(t,e){return Ue(t.getFullYear()%1e4,e,4)},Z:ir,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=v.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=d.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){m.lastIndex=0;var n=m.exec(e.slice(r));return n?(t.m=y.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return f(t,_.c.toString(),e,r)},d:Ke,e:Ke,H:tr,I:tr,j:Qe,L:nr,m:Je,M:er,p:function(t,e,r){var n=h.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:rr,U:We,w:Ge,W:Ye,x:function(t,e,r){return f(t,_.x.toString(),e,r)},X:function(t,e,r){return f(t,_.X.toString(),e,r)},y:Ze,Y:Xe,Z:$e,"%":ar};return u}(e)}};var sr=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function lr(){}t.format=sr.numberFormat,t.geo={},lr.prototype={s:0,t:0,add:function(t){ur(t,this.t,cr),ur(cr.s,this.s,this),this.s?this.t+=cr.t:this.s=cr.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var cr=new lr;function ur(t,e,r){var n=r.s=t+e,i=n-t,a=n-i;r.t=t-a+(e-i)}function fr(t,e){t&&pr.hasOwnProperty(t.type)&&pr[t.type](t,e)}t.geo.stream=function(t,e){t&&hr.hasOwnProperty(t.type)?hr[t.type](t,e):fr(t,e)};var hr={Feature:function(t,e){fr(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++n=0?1:-1,s=o*a,l=Math.cos(e),c=Math.sin(e),u=i*c,f=n*l+u*Math.cos(s),h=u*o*Math.sin(s);Cr.add(Math.atan2(h,f)),r=t,n=l,i=c}Er.point=function(o,s){Er.point=a,r=(t=o)*Et,n=Math.cos(s=(e=s)*Et/2+At/4),i=Math.sin(s)},Er.lineEnd=function(){a(t,e)}}function zr(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Or(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ir(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Pr(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Dr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Rr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Fr(t){return[Math.atan2(t[1],t[0]),Pt(t[2])]}function Br(t,e){return y(t[0]-e[0])kt?i=90:c<-kt&&(r=-90),f[0]=e,f[1]=n}};function p(t,a){u.push(f=[e=t,n=t]),ai&&(i=a)}function d(t,o){var s=zr([t*Et,o*Et]);if(l){var c=Ir(l,s),u=Ir([c[1],-c[0],0],c);Rr(u),u=Fr(u);var f=t-a,h=f>0?1:-1,d=u[0]*Lt*h,g=y(f)>180;if(g^(h*ai&&(i=v);else if(g^(h*a<(d=(d+360)%360-180)&&di&&(i=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>a?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else p(t,o);l=s,a=t}function g(){h.point=d}function v(){f[0]=e,f[1]=n,h.point=p,l=null}function m(t,e){if(l){var r=t-a;c+=y(r)>180?r+(r>0?360:-360):r}else o=t,s=e;Er.point(t,e),d(t,e)}function x(){Er.lineStart()}function b(){m(o,s),Er.lineEnd(),y(c)>kt&&(e=-(n=180)),f[0]=e,f[1]=n,l=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function k(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):s.push(g=p);for(var l,c,p,d=-1/0,g=(o=0,s[c=s.length-1]);o<=c;g=p,++o)p=s[o],(l=_(g[1],p[0]))>d&&(d=l,e=p[0],n=g[1])}return u=f=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,i]]}}(),t.geo.centroid=function(e){mr=yr=xr=br=_r=wr=kr=Mr=Ar=Tr=Sr=0,t.geo.stream(e,Nr);var r=Ar,n=Tr,i=Sr,a=r*r+n*n+i*i;return a=0;--s)i.point((f=u[s])[0],f[1]);else n(p.x,p.p.x,-1,i);p=p.p}u=(p=p.o).z,d=!d}while(!p.v);i.lineEnd()}}}function Xr(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n=0?1:-1,k=w*_,M=k>At,A=d*x;if(Cr.add(Math.atan2(A*w*Math.sin(k),g*b+A*Math.cos(k))),a+=M?_+w*Tt:_,M^h>=r^m>=r){var T=Ir(zr(f),zr(t));Rr(T);var S=Ir(i,T);Rr(S);var C=(M^_>=0?-1:1)*Pt(S[2]);(n>C||n===C&&(T[0]||T[1]))&&(o+=M^_>=0?1:-1)}if(!v++)break;h=m,d=x,g=b,f=t}}return(a<-kt||a0){for(x||(o.polygonStart(),x=!0),o.lineStart();++a1&&2&e&&r.push(r.pop().concat(r.shift())),s.push(r.filter(Jr))}return u}}function Jr(t){return t.length>1}function Kr(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:D,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Qr(t,e){return((t=t.x)[0]<0?t[1]-Ct-kt:Ct-t[1])-((e=e.x)[0]<0?e[1]-Ct-kt:Ct-e[1])}var tn=$r(Wr,function(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?At:-At,l=y(a-r);y(l-At)0?Ct:-Ct),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=At&&(y(r-i)kt?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}(r,n,a,o),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),e=0),t.point(r=a,n=o),i=s},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var i;if(null==t)i=r*Ct,n.point(-At,i),n.point(0,i),n.point(At,i),n.point(At,0),n.point(At,-i),n.point(0,-i),n.point(-At,-i),n.point(-At,0),n.point(-At,i);else if(y(t[0]-e[0])>kt){var a=t[0]0)){if(a/=h,h<0){if(a0){if(a>f)return;a>u&&(u=a)}if(a=r-l,h||!(a<0)){if(a/=h,h<0){if(a>f)return;a>u&&(u=a)}else if(h>0){if(a0)){if(a/=p,p<0){if(a0){if(a>f)return;a>u&&(u=a)}if(a=n-c,p||!(a<0)){if(a/=p,p<0){if(a>f)return;a>u&&(u=a)}else if(p>0){if(a0&&(i.a={x:l+u*h,y:c+u*p}),f<1&&(i.b={x:l+f*h,y:c+f*p}),i}}}}}}var rn=1e9;function nn(e,r,n,i){return function(l){var c,u,f,h,p,d,g,v,m,y,x,b=l,_=Kr(),w=en(e,r,n,i),k={point:T,lineStart:function(){k.point=S,u&&u.push(f=[]);y=!0,m=!1,g=v=NaN},lineEnd:function(){c&&(S(h,p),d&&m&&_.rejoin(),c.push(_.buffer()));k.point=T,m&&l.lineEnd()},polygonStart:function(){l=_,c=[],u=[],x=!0},polygonEnd:function(){l=b,c=t.merge(c);var r=function(t){for(var e=0,r=u.length,n=t[1],i=0;in&&Ot(c,a,t)>0&&++e:a[1]<=n&&Ot(c,a,t)<0&&--e,c=a;return 0!==e}([e,i]),n=x&&r,a=c.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),M(null,null,1,l),l.lineEnd()),a&&Yr(c,o,r,M,l),l.polygonEnd()),c=u=f=null}};function M(t,o,l,c){var u=0,f=0;if(null==t||(u=a(t,l))!==(f=a(o,l))||s(t,o)<0^l>0)do{c.point(0===u||3===u?e:n,u>1?i:r)}while((u=(u+l+4)%4)!==f);else c.point(o[0],o[1])}function A(t,a){return e<=t&&t<=n&&r<=a&&a<=i}function T(t,e){A(t,e)&&l.point(t,e)}function S(t,e){var r=A(t=Math.max(-rn,Math.min(rn,t)),e=Math.max(-rn,Math.min(rn,e)));if(u&&f.push([t,e]),y)h=t,p=e,d=r,y=!1,r&&(l.lineStart(),l.point(t,e));else if(r&&m)l.point(t,e);else{var n={a:{x:g,y:v},b:{x:t,y:e}};w(n)?(m||(l.lineStart(),l.point(n.a.x,n.a.y)),l.point(n.b.x,n.b.y),r||l.lineEnd(),x=!1):r&&(l.lineStart(),l.point(t,e),x=!1)}g=t,v=e,m=r}return k};function a(t,i){return y(t[0]-e)0?0:3:y(t[0]-n)0?2:1:y(t[1]-r)0?1:0:i>0?3:2}function o(t,e){return s(t.x,e.x)}function s(t,e){var r=a(t,1),n=a(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function an(t){var e=0,r=At/3,n=En(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*At/180,r=t[1]*At/180):[e/At*180,r/At*180]},i}function on(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,i=1+r*(2*n-r),a=Math.sqrt(i)/n;function o(t,e){var r=Math.sqrt(i-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),a-r*Math.cos(t)]}return o.invert=function(t,e){var r=a-e;return[Math.atan2(t,r)/n,Pt((i-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),(i=a(t)).valid=!0,i},extent:function(s){return arguments.length?(a=nn(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return an(on)}).raw=on,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,i,a=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};function c(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}return c.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&i<.234&&n>=-.425&&n<-.214?o:i>=.166&&i<.234&&n>=-.214&&n<-.115?s:a).invert(t)},c.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},c.precision=function(t){return arguments.length?(a.precision(t),o.precision(t),s.precision(t),c):a.precision()},c.scale=function(t){return arguments.length?(a.scale(t),o.scale(.35*t),s.scale(t),c.translate(a.translate())):a.scale()},c.translate=function(t){if(!arguments.length)return a.translate();var e=a.scale(),u=+t[0],f=+t[1];return r=a.translate(t).clipExtent([[u-.455*e,f-.238*e],[u+.455*e,f+.238*e]]).stream(l).point,n=o.translate([u-.307*e,f+.201*e]).clipExtent([[u-.425*e+kt,f+.12*e+kt],[u-.214*e-kt,f+.234*e-kt]]).stream(l).point,i=s.translate([u-.205*e,f+.212*e]).clipExtent([[u-.214*e+kt,f+.166*e+kt],[u-.115*e-kt,f+.234*e-kt]]).stream(l).point,c},c.scale(1070)};var sn,ln,cn,un,fn,hn,pn={point:D,lineStart:D,lineEnd:D,polygonStart:function(){ln=0,pn.lineStart=dn},polygonEnd:function(){pn.lineStart=pn.lineEnd=pn.point=D,sn+=y(ln/2)}};function dn(){var t,e,r,n;function i(t,e){ln+=n*t-r*e,r=t,n=e}pn.point=function(a,o){pn.point=i,t=r=a,e=n=o},pn.lineEnd=function(){i(t,e)}}var gn={point:function(t,e){tfn&&(fn=t);ehn&&(hn=e)},lineStart:D,lineEnd:D,polygonStart:D,polygonEnd:D};function vn(){var t=mn(4.5),e=[],r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=mn(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function i(t,n){e.push("M",t,",",n),r.point=a}function a(t,r){e.push("L",t,",",r)}function o(){r.point=n}function s(){e.push("Z")}return r}function mn(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var yn,xn={point:bn,lineStart:_n,lineEnd:wn,polygonStart:function(){xn.lineStart=kn},polygonEnd:function(){xn.point=bn,xn.lineStart=_n,xn.lineEnd=wn}};function bn(t,e){xr+=t,br+=e,++_r}function _n(){var t,e;function r(r,n){var i=r-t,a=n-e,o=Math.sqrt(i*i+a*a);wr+=o*(t+r)/2,kr+=o*(e+n)/2,Mr+=o,bn(t=r,e=n)}xn.point=function(n,i){xn.point=r,bn(t=n,e=i)}}function wn(){xn.point=bn}function kn(){var t,e,r,n;function i(t,e){var i=t-r,a=e-n,o=Math.sqrt(i*i+a*a);wr+=o*(r+t)/2,kr+=o*(n+e)/2,Mr+=o,Ar+=(o=n*t-r*e)*(r+t),Tr+=o*(n+e),Sr+=3*o,bn(r=t,n=e)}xn.point=function(a,o){xn.point=i,bn(t=r=a,e=n=o)},xn.lineEnd=function(){i(t,e)}}function Mn(t){var e=4.5,r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:D};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,Tt)}function i(e,n){t.moveTo(e,n),r.point=a}function a(e,r){t.lineTo(e,r)}function o(){r.point=n}function s(){t.closePath()}return r}function An(t){var e=.5,r=Math.cos(30*Et),n=16;function i(e){return(n?function(e){var r,i,o,s,l,c,u,f,h,p,d,g,v={point:m,lineStart:y,lineEnd:b,polygonStart:function(){e.polygonStart(),v.lineStart=_},polygonEnd:function(){e.polygonEnd(),v.lineStart=y}};function m(r,n){r=t(r,n),e.point(r[0],r[1])}function y(){f=NaN,v.point=x,e.lineStart()}function x(r,i){var o=zr([r,i]),s=t(r,i);a(f,h,u,p,d,g,f=s[0],h=s[1],u=r,p=o[0],d=o[1],g=o[2],n,e),e.point(f,h)}function b(){v.point=m,e.lineEnd()}function _(){y(),v.point=w,v.lineEnd=k}function w(t,e){x(r=t,e),i=f,o=h,s=p,l=d,c=g,v.point=x}function k(){a(f,h,u,p,d,g,i,o,r,s,l,c,n,e),v.lineEnd=b,b()}return v}:function(e){return Sn(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function a(n,i,o,s,l,c,u,f,h,p,d,g,v,m){var x=u-n,b=f-i,_=x*x+b*b;if(_>4*e&&v--){var w=s+p,k=l+d,M=c+g,A=Math.sqrt(w*w+k*k+M*M),T=Math.asin(M/=A),S=y(y(M)-1)e||y((x*z+b*O)/_-.5)>.3||s*p+l*d+c*g0&&16,i):Math.sqrt(e)},i}function Tn(t){this.stream=t}function Sn(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Cn(t){return En(function(){return t})()}function En(e){var r,n,i,a,o,s,l=An(function(t,e){return[(t=r(t,e))[0]*c+a,o-t[1]*c]}),c=150,u=480,f=250,h=0,p=0,d=0,g=0,v=0,m=tn,x=z,b=null,_=null;function w(t){return[(t=i(t[0]*Et,t[1]*Et))[0]*c+a,o-t[1]*c]}function k(t){return(t=i.invert((t[0]-a)/c,(o-t[1])/c))&&[t[0]*Lt,t[1]*Lt]}function M(){i=Gr(n=In(d,g,v),r);var t=r(h,p);return a=u-t[0]*c,o=f+t[1]*c,A()}function A(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Ln(m(n,l(x(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(m=null==t?(b=t,tn):function(t){var e=Math.cos(t),r=e>0,n=y(e)>kt;return $r(i,function(t){var e,s,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,h){var p,d=[f,h],g=i(f,h),v=r?g?0:o(f,h):g?o(f+(f<0?At:-At),h):0;if(!e&&(c=l=g)&&t.lineStart(),g!==l&&(p=a(e,d),(Br(e,p)||Br(d,p))&&(d[0]+=kt,d[1]+=kt,g=i(d[0],d[1]))),g!==l)u=0,g?(t.lineStart(),p=a(d,e),t.point(p[0],p[1])):(p=a(e,d),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(n&&e&&r^g){var m;v&s||!(m=a(d,e,!0))||(u=0,r?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||e&&Br(e,d)||t.point(d[0],d[1]),e=d,l=g,s=v},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return u|(c&&l)<<1}}},Fn(t,6*Et),r?[0,-t]:[-At,t-At]);function i(t,r){return Math.cos(t)*Math.cos(r)>e}function a(t,r,n){var i=[1,0,0],a=Ir(zr(t),zr(r)),o=Or(a,a),s=a[0],l=o-s*s;if(!l)return!n&&t;var c=e*o/l,u=-e*s/l,f=Ir(i,a),h=Dr(i,c);Pr(h,Dr(a,u));var p=f,d=Or(h,p),g=Or(p,p),v=d*d-g*(Or(h,h)-1);if(!(v<0)){var m=Math.sqrt(v),x=Dr(p,(-d-m)/g);if(Pr(x,h),x=Fr(x),!n)return x;var b,_=t[0],w=r[0],k=t[1],M=r[1];w<_&&(b=_,_=w,w=b);var A=w-_,T=y(A-At)0^x[1]<(y(x[0]-_)At^(_<=x[0]&&x[0]<=w)){var S=Dr(p,(-d+m)/g);return Pr(S,h),[x,Fr(S)]}}}function o(e,n){var i=r?t:At-t,a=0;return e<-i?a|=1:e>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}}((b=+t)*Et),A()):b},w.clipExtent=function(t){return arguments.length?(_=t,x=t?nn(t[0][0],t[0][1],t[1][0],t[1][1]):z,A()):_},w.scale=function(t){return arguments.length?(c=+t,M()):c},w.translate=function(t){return arguments.length?(u=+t[0],f=+t[1],M()):[u,f]},w.center=function(t){return arguments.length?(h=t[0]%360*Et,p=t[1]%360*Et,M()):[h*Lt,p*Lt]},w.rotate=function(t){return arguments.length?(d=t[0]%360*Et,g=t[1]%360*Et,v=t.length>2?t[2]%360*Et:0,M()):[d*Lt,g*Lt,v*Lt]},t.rebind(w,l,"precision"),function(){return r=e.apply(this,arguments),w.invert=r.invert&&k,M()}}function Ln(t){return Sn(t,function(e,r){t.point(e*Et,r*Et)})}function zn(t,e){return[t,e]}function On(t,e){return[t>At?t-Tt:t<-At?t+Tt:t,e]}function In(t,e,r){return t?e||r?Gr(Dn(t),Rn(e,r)):Dn(t):e||r?Rn(e,r):On}function Pn(t){return function(e,r){return[(e+=t)>At?e-Tt:e<-At?e+Tt:e,r]}}function Dn(t){var e=Pn(t);return e.invert=Pn(-t),e}function Rn(t,e){var r=Math.cos(t),n=Math.sin(t),i=Math.cos(e),a=Math.sin(e);function o(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,c=Math.sin(e),u=c*r+s*n;return[Math.atan2(l*i-u*a,s*r-c*n),Pt(u*i+l*a)]}return o.invert=function(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,c=Math.sin(e),u=c*i-l*a;return[Math.atan2(l*i+c*a,s*r+u*n),Pt(u*r-s*n)]},o}function Fn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=Bn(r,i),a=Bn(r,a),(o>0?ia)&&(i+=o*Tt)):(i=t+o*Tt,a=t-.5*l);for(var c,u=i;o>0?u>a:u2?t[2]*Et:0),e.invert=function(e){return(e=t.invert(e[0]*Et,e[1]*Et))[0]*=Lt,e[1]*=Lt,e},e},On.invert=zn,t.geo.circle=function(){var t,e,r=[0,0],n=6;function i(){var t="function"==typeof r?r.apply(this,arguments):r,n=In(-t[0]*Et,-t[1]*Et,0).invert,i=[];return e(null,null,1,{point:function(t,e){i.push(t=n(t,e)),t[0]*=Lt,t[1]*=Lt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(r=t,i):r},i.angle=function(r){return arguments.length?(e=Fn((t=+r)*Et,n*Et),i):t},i.precision=function(r){return arguments.length?(e=Fn(t*Et,(n=+r)*Et),i):n},i.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Et,i=t[1]*Et,a=e[1]*Et,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-l*f*s)*r),l*u+c*f*s)},t.geo.graticule=function(){var e,r,n,i,a,o,s,l,c,u,f,h,p=10,d=p,g=90,v=360,m=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(i/g)*g,n,g).map(f).concat(t.range(Math.ceil(l/v)*v,s,v).map(h)).concat(t.range(Math.ceil(r/p)*p,e,p).filter(function(t){return y(t%g)>kt}).map(c)).concat(t.range(Math.ceil(o/d)*d,a,d).filter(function(t){return y(t%v)>kt}).map(u))}return x.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},x.outline=function(){return{type:"Polygon",coordinates:[f(i).concat(h(s).slice(1),f(n).reverse().slice(1),h(l).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(i=+t[0][0],n=+t[1][0],l=+t[0][1],s=+t[1][1],i>n&&(t=i,i=n,n=t),l>s&&(t=l,l=s,s=t),x.precision(m)):[[i,l],[n,s]]},x.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),o>a&&(t=o,o=a,a=t),x.precision(m)):[[r,o],[e,a]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],x):[g,v]},x.minorStep=function(t){return arguments.length?(p=+t[0],d=+t[1],x):[p,d]},x.precision=function(t){return arguments.length?(m=+t,c=Nn(o,a,90),u=jn(r,e,m),f=Nn(l,s,90),h=jn(i,n,m),x):m},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,r,n=Vn,i=Un;function a(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}return a.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},a.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,a):n},a.target=function(t){return arguments.length?(i=t,r="function"==typeof t?null:t,a):i},a.precision=function(){return arguments.length?a:0},a},t.geo.interpolate=function(t,e){return r=t[0]*Et,n=t[1]*Et,i=e[0]*Et,a=e[1]*Et,o=Math.cos(n),s=Math.sin(n),l=Math.cos(a),c=Math.sin(a),u=o*Math.cos(r),f=o*Math.sin(r),h=l*Math.cos(i),p=l*Math.sin(i),d=2*Math.asin(Math.sqrt(Rt(a-n)+o*l*Rt(i-r))),g=1/Math.sin(d),(v=d?function(t){var e=Math.sin(t*=d)*g,r=Math.sin(d-t)*g,n=r*u+e*h,i=r*f+e*p,a=r*s+e*c;return[Math.atan2(i,n)*Lt,Math.atan2(a,Math.sqrt(n*n+i*i))*Lt]}:function(){return[r*Lt,n*Lt]}).distance=d,v;var r,n,i,a,o,s,l,c,u,f,h,p,d,g,v},t.geo.length=function(e){return yn=0,t.geo.stream(e,qn),yn};var qn={sphere:D,point:D,lineStart:function(){var t,e,r;function n(n,i){var a=Math.sin(i*=Et),o=Math.cos(i),s=y((n*=Et)-t),l=Math.cos(s);yn+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=r*a-e*o*l)*s),e*a+r*o*l),t=n,e=a,r=o}qn.point=function(i,a){t=i*Et,e=Math.sin(a*=Et),r=Math.cos(a),qn.point=n},qn.lineEnd=function(){qn.point=qn.lineEnd=D}},lineEnd:D,polygonStart:D,polygonEnd:D};function Hn(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}var Gn=Hn(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(t.geo.azimuthalEqualArea=function(){return Cn(Gn)}).raw=Gn;var Wn=Hn(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},z);function Yn(t,e){var r=Math.cos(t),n=function(t){return Math.tan(At/4+t/2)},i=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),a=r*Math.pow(n(t),i)/i;if(!i)return $n;function o(t,e){a>0?e<-Ct+kt&&(e=-Ct+kt):e>Ct-kt&&(e=Ct-kt);var r=a/Math.pow(n(e),i);return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}return o.invert=function(t,e){var r=a-e,n=zt(i)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/i,2*Math.atan(Math.pow(a/n,1/i))-Ct]},o}function Xn(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),i=r/n+t;if(y(n)1&&Ot(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function ii(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return Cn(Qn)}).raw=Qn,ti.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ct]},(t.geo.transverseMercator=function(){var t=Jn(ti),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=ti,t.geom={},t.geom.hull=function(t){var e=ei,r=ri;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,i=ve(e),a=ve(r),o=t.length,s=[],l=[];for(n=0;n=0;--n)p.push(t[s[c[n]][2]]);for(n=+f;nkt)s=s.L;else{if(!((i=a-wi(s,o))>kt)){n>-kt?(e=s.P,r=s):i>-kt?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=mi(t);if(fi.insert(e,l),e||r){if(e===r)return Si(e),r=mi(e.site),fi.insert(l,r),l.edge=r.edge=Li(e.site,l.site),Ti(e),void Ti(r);if(r){Si(e),Si(r);var c=e.site,u=c.x,f=c.y,h=t.x-u,p=t.y-f,d=r.site,g=d.x-u,v=d.y-f,m=2*(h*v-p*g),y=h*h+p*p,x=g*g+v*v,b={x:(v*y-p*x)/m+u,y:(h*x-g*y)/m+f};zi(r.edge,c,d,b),l.edge=Li(c,t,null,b),r.edge=Li(t,d,null,b),Ti(e),Ti(r)}else l.edge=Li(e.site,l.site)}}function _i(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-1/0;var s=(r=o.site).x,l=r.y,c=l-e;if(!c)return s;var u=s-n,f=1/a-1/c,h=u/c;return f?(-h+Math.sqrt(h*h-2*f*(u*u/(-2*c)-l+c/2+i-a/2)))/f+n:(n+s)/2}function wi(t,e){var r=t.N;if(r)return _i(r,e);var n=t.site;return n.y===e?n.x:1/0}function ki(t){this.site=t,this.edges=[]}function Mi(t,e){return e.angle-t.angle}function Ai(){Pi(this),this.x=this.y=this.arc=this.site=this.cy=null}function Ti(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,i=t.site,a=r.site;if(n!==a){var o=i.x,s=i.y,l=n.x-o,c=n.y-s,u=a.x-o,f=2*(l*(v=a.y-s)-c*u);if(!(f>=-Mt)){var h=l*l+c*c,p=u*u+v*v,d=(v*h-c*p)/f,g=(l*p-u*h)/f,v=g+s,m=gi.pop()||new Ai;m.arc=t,m.site=i,m.x=d+o,m.y=v+Math.sqrt(d*d+g*g),m.cy=v,t.circle=m;for(var y=null,x=pi._;x;)if(m.y=s)return;if(h>d){if(a){if(a.y>=c)return}else a={x:v,y:l};r={x:v,y:c}}else{if(a){if(a.y1)if(h>d){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.y=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xkt||y(i-r)>kt)&&(s.splice(o,0,new Oi((m=a.site,x=u,b=y(n-f)kt?{x:f,y:y(e-f)kt?{x:y(r-d)kt?{x:h,y:y(e-h)kt?{x:y(r-p)=r&&c.x<=i&&c.y>=n&&c.y<=o?[[r,o],[i,o],[i,n],[r,n]]:[]).point=t[s]}),e}function s(t){return t.map(function(t,e){return{x:Math.round(n(t,e)/kt)*kt,y:Math.round(i(t,e)/kt)*kt,i:e}})}return o.links=function(t){return Bi(s(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},o.triangles=function(t){var e=[];return Bi(s(t)).cells.forEach(function(r,n){for(var i,a,o,s,l=r.site,c=r.edges.sort(Mi),u=-1,f=c.length,h=c[f-1].edge,p=h.l===l?h.r:h.l;++ua&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:Gi(r,n)})),a=Xi.lastIndex;return ag&&(g=l.x),l.y>v&&(v=l.y),c.push(l.x),u.push(l.y);else for(f=0;fg&&(g=b),_>v&&(v=_),c.push(b),u.push(_)}var w=g-p,k=v-d;function M(t,e,r,n,i,a,o,s){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var l=t.x,c=t.y;if(null!=l)if(y(l-r)+y(c-n)<.01)A(t,e,r,n,i,a,o,s);else{var u=t.point;t.x=t.y=t.point=null,A(t,u,l,c,i,a,o,s),A(t,e,r,n,i,a,o,s)}else t.x=r,t.y=n,t.point=e}else A(t,e,r,n,i,a,o,s)}function A(t,e,r,n,i,a,o,s){var l=.5*(i+o),c=.5*(a+s),u=r>=l,f=n>=c,h=f<<1|u;t.leaf=!1,u?i=l:o=l,f?a=c:s=c,M(t=t.nodes[h]||(t.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(T,t,+m(t,++f),+x(t,f),p,d,g,v)}}),e,r,n,i,a,o,s)}w>k?v=d+w:g=p+k;var T={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(T,t,+m(t,++f),+x(t,f),p,d,g,v)}};if(T.visit=function(t){!function t(e,r,n,i,a,o){if(!e(r,n,i,a,o)){var s=.5*(n+a),l=.5*(i+o),c=r.nodes;c[0]&&t(e,c[0],n,i,s,l),c[1]&&t(e,c[1],s,i,a,l),c[2]&&t(e,c[2],n,l,s,o),c[3]&&t(e,c[3],s,l,a,o)}}(t,T,p,d,g,v)},T.find=function(t){return function(t,e,r,n,i,a,o){var s,l=1/0;return function t(c,u,f,h,p){if(!(u>a||f>o||h=_)<<1|e>=b,k=w+4;w=0&&!(n=t.interpolators[i](e,r)););return n}function $i(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;r=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function aa(t){return 1-Math.cos(t*Ct)}function oa(t){return Math.pow(2,10*(t-1))}function sa(t){return 1-Math.sqrt(1-t*t)}function la(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function ca(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ua(t){var e,r,n,i=[t.a,t.b],a=[t.c,t.d],o=ha(i),s=fa(i,a),l=ha(((e=a)[0]+=(n=-s)*(r=i)[0],e[1]+=n*r[1],e))||0;i[0]*a[1]=0?t.slice(0,n):t,a=n>=0?t.slice(n+1):"in";return i=Ki.get(i)||Ji,a=Qi.get(a)||z,e=a(i.apply(null,r.call(arguments,1))),function(t){return t<=0?0:t>=1?1:e(t)}},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,i=e.c,a=e.l,o=r.h-n,s=r.c-i,l=r.l-a;isNaN(s)&&(s=0,i=isNaN(i)?r.c:i);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Yt(n+o*t,i+s*t,a+l*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,i=e.s,a=e.l,o=r.h-n,s=r.s-i,l=r.l-a;isNaN(s)&&(s=0,i=isNaN(i)?r.s:i);isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360);return function(t){return Ht(n+o*t,i+s*t,a+l*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,i=e.a,a=e.b,o=r.l-n,s=r.a-i,l=r.b-a;return function(t){return te(n+o*t,i+s*t,a+l*t)+""}},t.interpolateRound=ca,t.transform=function(e){var r=i.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ua(e?e.matrix:pa)})(e)},ua.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pa={a:1,b:0,c:0,d:1,e:0,f:0};function da(t){return t.length?t.pop()+",":""}function ga(e,r){var n=[],i=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push("translate(",null,",",null,")");n.push({i:i-4,x:Gi(t[0],e[0])},{i:i-2,x:Gi(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,i),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(da(r)+"rotate(",null,")")-2,x:Gi(t,e)})):e&&r.push(da(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,i),function(t,e,r,n){t!==e?n.push({i:r.push(da(r)+"skewX(",null,")")-2,x:Gi(t,e)}):e&&r.push(da(r)+"skewX("+e+")")}(e.skew,r.skew,n,i),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(da(r)+"scale(",null,",",null,")");n.push({i:i-4,x:Gi(t[0],e[0])},{i:i-2,x:Gi(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(da(r)+"scale("+e+")")}(e.scale,r.scale,n,i),e=r=null,function(t){for(var e,r=-1,a=i.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:n=0})):t>0&&(l.start({type:"start",alpha:n=t}),e=Me(s.tick)),s):n},s.start=function(){var t,e,r,n=m.length,l=y.length,u=c[0],d=c[1];for(t=0;t=0;)r.push(i[n])}function Ea(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++o=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;r&&(a.value=0),a.children=c}else r&&(a.value=+r.call(n,a,a.depth)||0),delete a.children;return Ea(i,function(e){var n,i;t&&(n=e.children)&&n.sort(t),r&&(i=e.parent)&&(i.value+=e.value)}),s}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Ca(t,function(t){t.children&&(t.value=0)}),Ea(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var i=e.call(this,t,n);return function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cs&&(s=n),o.push(n)}for(r=0;ri&&(n=r,i=e);return n}function qa(t){return t.reduce(Ha,0)}function Ha(t,e){return t+e[1]}function Ga(t,e){return Wa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function Wa(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function Ya(e){return[t.min(e),t.max(e)]}function Xa(t,e){return t.value-e.value}function Za(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function $a(t,e){t._pack_next=e,e._pack_prev=t}function Ja(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Ka(t){if((e=t.children)&&(l=e.length)){var e,r,n,i,a,o,s,l,c=1/0,u=-1/0,f=1/0,h=-1/0;if(e.forEach(Qa),(r=e[0]).x=-r.r,r.y=0,x(r),l>1&&((n=e[1]).x=n.r,n.y=0,x(n),l>2))for(eo(r,n,i=e[2]),x(i),Za(r,i),r._pack_prev=i,Za(i,n),n=r._pack_next,a=3;a0)for(o=-1;++o=f[0]&&l<=f[1]&&((s=c[t.bisect(h,l,1,d)-1]).y+=g,s.push(a[o]));return c}return a.value=function(t){return arguments.length?(r=t,a):r},a.range=function(t){return arguments.length?(n=ve(t),a):n},a.bins=function(t){return arguments.length?(i="number"==typeof t?function(e){return Wa(e,t)}:ve(t),a):i},a.frequency=function(t){return arguments.length?(e=!!t,a):e},a},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(Xa),n=0,i=[1,1];function a(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,Ea(s,function(t){t.r=+u(t.value)}),Ea(s,Ka),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;Ea(s,function(t){t.r+=f}),Ea(s,Ka),Ea(s,function(t){t.r-=f})}return function t(e,r,n,i){var a=e.children;e.x=r+=i*e.x;e.y=n+=i*e.y;e.r*=i;if(a)for(var o=-1,s=a.length;++op.x&&(p=t),t.depth>d.depth&&(d=t)});var g=r(h,p)/2-h.x,v=n[0]/(p.x+r(p,h)/2+g),m=n[1]/(d.depth||1);Ca(u,function(t){t.x=(t.x+g)*v,t.y=t.depth*m})}return c}function o(t){var e=t.children,n=t.parent.children,i=t.i?n[t.i-1]:null;if(e.length){!function(t){var e,r=0,n=0,i=t.children,a=i.length;for(;--a>=0;)(e=i[a]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var a=(e[0].z+e[e.length-1].z)/2;i?(t.z=i.z+r(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+r(t._,i._));t.parent.A=function(t,e,n){if(e){for(var i,a=t,o=t,s=e,l=a.parent.children[0],c=a.m,u=o.m,f=s.m,h=l.m;s=io(s),a=no(a),s&&a;)l=no(l),(o=io(o)).a=t,(i=s.z+f-a.z-c+r(s._,a._))>0&&(ao(oo(s,t,n),t,i),c+=i,u+=i),f+=s.m,c+=a.m,h+=l.m,u+=o.m;s&&!io(o)&&(o.t=s,o.m+=f-u),a&&!no(l)&&(l.t=a,l.m+=c-h,n=t)}return n}(t,i,t.parent.A||n[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function l(t){t.x*=n[0],t.y=t.depth*n[1]}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t)?l:null,a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null==(n=t)?null:l,a):i?n:null},Sa(a,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=ro,n=[1,1],i=!1;function a(a,o){var s,l=e.call(this,a,o),c=l[0],u=0;Ea(c,function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(n),e.y=function(e){return 1+t.max(e,function(t){return t.y})}(n)):(e.x=s?u+=r(e,s):0,e.y=0,s=e)});var f=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(c),h=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(c),p=f.x-r(f,h)/2,d=h.x+r(h,f)/2;return Ea(c,i?function(t){t.x=(t.x-c.x)*n[0],t.y=(c.y-t.y)*n[1]}:function(t){t.x=(t.x-p)/(d-p)*n[0],t.y=(1-(c.y?t.y/c.y:1))*n[1]}),l}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t),a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null!=(n=t),a):i?n:null},Sa(a,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,i=[1,1],a=null,o=so,s=!1,l="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var r,n,i=-1,a=t.length;++i0;)s.push(r=c[i-1]),s.area+=r.area,"squarify"!==l||(n=p(s,g))<=h?(c.pop(),h=n):(s.area-=s.pop().area,d(s,g,a,!1),g=Math.min(a.dx,a.dy),s.length=s.area=0,h=1/0);s.length&&(d(s,g,a,!0),s.length=s.area=0),e.forEach(f)}}function h(t){var e=t.children;if(e&&e.length){var r,n=o(t),i=e.slice(),a=[];for(u(i,n.dx*n.dy/t.value),a.area=0;r=i.pop();)a.push(r),a.area+=r.area,null!=r.z&&(d(a,r.z?n.dx:n.dy,n,!i.length),a.length=a.area=0);e.forEach(h)}}function p(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++oi&&(i=r));return e*=e,(n*=n)?Math.max(e*i*c/n,n/(e*a*c)):1/0}function d(t,e,r,i){var a,o=-1,s=t.length,l=r.x,c=r.y,u=e?n(t.area/e):0;if(e==r.dx){for((i||u>r.dy)&&(u=r.dy);++or.dx)&&(u=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?vo:fo,s=i?ma:va;return a=t(e,r,s,n),o=t(r,e,s,Zi),l}function l(t){return a(t)}l.invert=function(t){return o(t)};l.domain=function(t){return arguments.length?(e=t.map(Number),s()):e};l.range=function(t){return arguments.length?(r=t,s()):r};l.rangeRound=function(t){return l.range(t).interpolate(ca)};l.clamp=function(t){return arguments.length?(i=t,s()):i};l.interpolate=function(t){return arguments.length?(n=t,s()):n};l.ticks=function(t){return bo(e,t)};l.tickFormat=function(t,r){return _o(e,t,r)};l.nice=function(t){return yo(e,t),s()};l.copy=function(){return t(e,r,n,i)};return s()}([0,1],[0,1],Zi,!1)};var wo={s:1,g:1,p:1,r:1,e:1};function ko(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,i,a){function o(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function s(t){return i?Math.pow(n,t):-Math.pow(n,-t)}function l(t){return r(o(t))}l.invert=function(t){return s(r.invert(t))};l.domain=function(t){return arguments.length?(i=t[0]>=0,r.domain((a=t.map(Number)).map(o)),l):a};l.base=function(t){return arguments.length?(n=+t,r.domain(a.map(o)),l):n};l.nice=function(){var t=ho(a.map(o),i?Math:Ao);return r.domain(t),a=t.map(s),l};l.ticks=function(){var t=co(a),e=[],r=t[0],l=t[1],c=Math.floor(o(r)),u=Math.ceil(o(l)),f=n%1?2:n;if(isFinite(u-c)){if(i){for(;c0;h--)e.push(s(c)*h);for(c=0;e[c]l;u--);e=e.slice(c,u)}return e};l.tickFormat=function(e,r){if(!arguments.length)return Mo;arguments.length<2?r=Mo:"function"!=typeof r&&(r=t.format(r));var i=Math.max(1,n*e/l.ticks().length);return function(t){var e=t/s(Math.round(o(t)));return e*n0?i[t-1]:r[0],tf?0:1;if(c=St)return l(c,p)+(s?l(s,1-p):"")+"Z";var d,g,v,m,y,x,b,_,w,k,M,A,T=0,S=0,C=[];if((m=(+o.apply(this,arguments)||0)/2)&&(v=n===Oo?Math.sqrt(s*s+c*c):+n.apply(this,arguments),p||(S*=-1),c&&(S=Pt(v/c*Math.sin(m))),s&&(T=Pt(v/s*Math.sin(m)))),c){y=c*Math.cos(u+S),x=c*Math.sin(u+S),b=c*Math.cos(f-S),_=c*Math.sin(f-S);var E=Math.abs(f-u-2*S)<=At?0:1;if(S&&Bo(y,x,b,_)===p^E){var L=(u+f)/2;y=c*Math.cos(L),x=c*Math.sin(L),b=_=null}}else y=x=0;if(s){w=s*Math.cos(f-T),k=s*Math.sin(f-T),M=s*Math.cos(u+T),A=s*Math.sin(u+T);var z=Math.abs(u-f+2*T)<=At?0:1;if(T&&Bo(w,k,M,A)===1-p^z){var O=(u+f)/2;w=s*Math.cos(O),k=s*Math.sin(O),M=A=null}}else w=k=0;if(h>kt&&(d=Math.min(Math.abs(c-s)/2,+r.apply(this,arguments)))>.001){g=s0?0:1}function No(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,f=t[1]+c,h=e[0]+l,p=e[1]+c,d=(u+h)/2,g=(f+p)/2,v=h-u,m=p-f,y=v*v+m*m,x=r-n,b=u*p-h*f,_=(m<0?-1:1)*Math.sqrt(Math.max(0,x*x*y-b*b)),w=(b*m-v*_)/y,k=(-b*v-m*_)/y,M=(b*m+v*_)/y,A=(-b*v+m*_)/y,T=w-d,S=k-g,C=M-d,E=A-g;return T*T+S*S>C*C+E*E&&(w=M,k=A),[[w-l,k-c],[w*r/x,k*r/x]]}function jo(t){var e=ei,r=ri,n=Wr,i=Uo,a=i.key,o=.7;function s(a){var s,l=[],c=[],u=-1,f=a.length,h=ve(e),p=ve(r);function d(){l.push("M",i(t(c),o))}for(;++u1&&i.push("H",n[0]);return i.join("")},"step-before":Ho,"step-after":Go,basis:Xo,"basis-open":function(t){if(t.length<4)return Uo(t);var e,r=[],n=-1,i=t.length,a=[0],o=[0];for(;++n<3;)e=t[n],a.push(e[0]),o.push(e[1]);r.push(Zo(Ko,a)+","+Zo(Ko,o)),--n;for(;++n9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));s=-1;for(;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}(t))}});function Uo(t){return t.length>1?t.join("L"):t+"Z"}function qo(t){return t.join("L")+"Z"}function Ho(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;cAt)+",1 "+e}function l(t,e,r,n){return"Q 0,0 "+n}return a.radius=function(t){return arguments.length?(r=ve(t),a):r},a.source=function(e){return arguments.length?(t=ve(e),a):t},a.target=function(t){return arguments.length?(e=ve(t),a):e},a.startAngle=function(t){return arguments.length?(n=ve(t),a):n},a.endAngle=function(t){return arguments.length?(i=ve(t),a):i},a},t.svg.diagonal=function(){var t=Vn,e=Un,r=is;function n(n,i){var a=t.call(this,n,i),o=e.call(this,n,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(r))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return n.source=function(e){return arguments.length?(t=ve(e),n):t},n.target=function(t){return arguments.length?(e=ve(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=is,n=e.projection;return e.projection=function(t){return arguments.length?n(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-Ct;return[r*Math.cos(n),r*Math.sin(n)]}}(r=t)):r},e},t.svg.symbol=function(){var t=os,e=as;function r(r,n){return(ls.get(t.call(this,r,n))||ss)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=ve(e),r):t},r.size=function(t){return arguments.length?(e=ve(t),r):e},r};var ls=t.map({circle:ss,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*us)),r=e*us;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/cs),r=e*cs/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/cs),r=e*cs/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=ls.keys();var cs=Math.sqrt(3),us=Math.tan(30*Et);Y.transition=function(t){for(var e,r,n=ds||++ms,i=bs(t),a=[],o=gs||{time:Date.now(),ease:ia,delay:0,duration:250},s=-1,l=this.length;++s0;)c[--h].call(t,o);if(a>=1)return f.event&&f.event.end.call(t,t.__data__,e),--u.count?delete u[n]:delete t[r],1}f||(a=i.time,o=Me(function(t){var e=f.delay;if(o.t=e+a,e<=t)return h(t-e);o.c=h},0,a),f=u[n]={tween:new b,time:a,timer:o,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++u.count)}vs.call=Y.call,vs.empty=Y.empty,vs.node=Y.node,vs.size=Y.size,t.transition=function(e,r){return e&&e.transition?ds?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=vs,vs.select=function(t){var e,r,n,i=this.id,a=this.namespace,o=[];t=X(t);for(var s=-1,l=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function g(t){t.select(".extent").attr("y",l[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function v(){var f,v,m=this,y=t.select(t.event.target),x=n.of(m,arguments),b=t.select(m),_=y.datum(),w=!/^(n|s)$/.test(_)&&i,k=!/^(e|w)$/.test(_)&&a,M=y.classed("extent"),A=xt(m),T=t.mouse(m),S=t.select(o(m)).on("keydown.brush",function(){32==t.event.keyCode&&(M||(f=null,T[0]-=s[1],T[1]-=l[1],M=2),B())}).on("keyup.brush",function(){32==t.event.keyCode&&2==M&&(T[0]+=s[1],T[1]+=l[1],M=0,B())});if(t.event.changedTouches?S.on("touchmove.brush",L).on("touchend.brush",O):S.on("mousemove.brush",L).on("mouseup.brush",O),b.interrupt().selectAll("*").interrupt(),M)T[0]=s[0]-T[0],T[1]=l[0]-T[1];else if(_){var C=+/w$/.test(_),E=+/^n/.test(_);v=[s[1-C]-T[0],l[1-E]-T[1]],T[0]=s[C],T[1]=l[E]}else t.event.altKey&&(f=T.slice());function L(){var e=t.mouse(m),r=!1;v&&(e[0]+=v[0],e[1]+=v[1]),M||(t.event.altKey?(f||(f=[(s[0]+s[1])/2,(l[0]+l[1])/2]),T[0]=s[+(e[0]1?{floor:function(e){for(;s(e=t.floor(e));)e=Is(e-1);return e},ceil:function(e){for(;s(e=t.ceil(e));)e=Is(+e+1);return e}}:t))},i.ticks=function(t,e){var r=co(i.domain()),n=null==t?a(r,10):"number"==typeof t?a(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],Is(+r[1]+1),e<1?1:e)},i.tickFormat=function(){return n},i.copy=function(){return Os(e.copy(),r,n)},mo(i,e)}function Is(t){return new Date(t)}Cs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?zs:Ls,zs.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},zs.toString=Ls.toString,Ie.second=Fe(function(t){return new Pe(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),Ie.seconds=Ie.second.range,Ie.seconds.utc=Ie.second.utc.range,Ie.minute=Fe(function(t){return new Pe(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),Ie.minutes=Ie.minute.range,Ie.minutes.utc=Ie.minute.utc.range,Ie.hour=Fe(function(t){var e=t.getTimezoneOffset()/60;return new Pe(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),Ie.hours=Ie.hour.range,Ie.hours.utc=Ie.hour.utc.range,Ie.month=Fe(function(t){return(t=Ie.day(t)).setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),Ie.months=Ie.month.range,Ie.months.utc=Ie.month.utc.range;var Ps=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ds=[[Ie.second,1],[Ie.second,5],[Ie.second,15],[Ie.second,30],[Ie.minute,1],[Ie.minute,5],[Ie.minute,15],[Ie.minute,30],[Ie.hour,1],[Ie.hour,3],[Ie.hour,6],[Ie.hour,12],[Ie.day,1],[Ie.day,2],[Ie.week,1],[Ie.month,1],[Ie.month,3],[Ie.year,1]],Rs=Cs.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Wr]]),Fs={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(Is)},floor:z,ceil:z};Ds.year=Ie.year,Ie.scale=function(){return Os(t.scale.linear(),Ds,Rs)};var Bs=Ds.map(function(t){return[t[0].utc,t[1]]}),Ns=Es.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Wr]]);function js(t){return JSON.parse(t.responseText)}function Vs(t){var e=i.createRange();return e.selectNode(i.body),e.createContextualFragment(t.responseText)}Bs.year=Ie.year.utc,Ie.scale.utc=function(){return Os(t.scale.linear(),Bs,Ns)},t.text=me(function(t){return t.responseText}),t.json=function(t,e){return ye(t,"application/json",js,e)},t.html=function(t,e){return ye(t,"text/html",Vs,e)},t.xml=me(function(t){return t.responseXML}),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],149:[function(t,e,r){e.exports=function(){for(var t=0;t=2)return!1;t[r]=n}return!0}):_.filter(function(t){for(var e=0;e<=s;++e){var r=m[t[e]];if(r<0)return!1;t[e]=r}return!0});if(1&s)for(var u=0;u<_.length;++u){var b=_[u],h=b[0];b[0]=b[1],b[1]=h}return _}},{"incremental-convex-hull":396,uniq:523}],151:[function(t,e,r){"use strict";e.exports=a;var n=(a.canvas=document.createElement("canvas")).getContext("2d"),i=o([32,126]);function a(t,e){Array.isArray(t)&&(t=t.join(", "));var r,a={},s=16,l=.05;e&&(2===e.length&&"number"==typeof e[0]?r=o(e):Array.isArray(e)?r=e:(e.o?r=o(e.o):e.pairs&&(r=e.pairs),e.fontSize&&(s=e.fontSize),null!=e.threshold&&(l=e.threshold))),r||(r=i),n.font=s+"px "+t;for(var c=0;cs*l){var p=(h-f)/s;a[u]=1e3*p}}return a}function o(t){for(var e=[],r=t[0];r<=t[1];r++)for(var n=String.fromCharCode(r),i=t[0];i>>31},e.exports.exponent=function(t){return(e.exports.hi(t)<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){return!(2146435072&e.exports.hi(t))}}).call(this,t("buffer").Buffer)},{buffer:93}],153:[function(t,e,r){var n=t("abs-svg-path"),i=t("normalize-svg-path"),a={M:"moveTo",C:"bezierCurveTo"};e.exports=function(t,e){t.beginPath(),i(n(e)).forEach(function(e){var r=e[0],n=e.slice(1);t[a[r]].apply(t,n)}),t.closePath()}},{"abs-svg-path":48,"normalize-svg-path":435}],154:[function(t,e,r){e.exports=function(t){switch(t){case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"uint8":return Uint8Array;case"uint16":return Uint16Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;case"array":return Array;case"uint8_clamped":return Uint8ClampedArray}}},{}],155:[function(t,e,r){"use strict";e.exports=function(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return function(t,e){var r,n;for(r=new Array(t),n=0;n80*r){n=l=t[0],s=c=t[1];for(var b=r;bl&&(l=u),p>c&&(c=p);g=0!==(g=Math.max(l-n,c-s))?1/g:0}return o(y,x,r,n,s,g),x}function i(t,e,r,n,i){var a,o;if(i===A(t,e,r,n)>0)for(a=e;a=e;a-=n)o=w(a,t[a],t[a+1],o);return o&&y(o,o.next)&&(k(o),o=o.next),o}function a(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!y(n,n.next)&&0!==m(n.prev,n,n.next))n=n.next;else{if(k(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function o(t,e,r,n,i,f,h){if(t){!h&&f&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=p(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,o,s,l,c=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,c*=2}while(o>1)}(i)}(t,n,i,f);for(var d,g,v=t;t.prev!==t.next;)if(d=t.prev,g=t.next,f?l(t,n,i,f):s(t))e.push(d.i/r),e.push(t.i/r),e.push(g.i/r),k(t),t=g.next,v=g.next;else if((t=g)===v){h?1===h?o(t=c(t,e,r),e,r,n,i,f,2):2===h&&u(t,e,r,n,i,f):o(a(t),e,r,n,i,f,1);break}}}function s(t){var e=t.prev,r=t,n=t.next;if(m(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(g(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&m(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function l(t,e,r,n){var i=t.prev,a=t,o=t.next;if(m(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,f=p(s,l,e,r,n),h=p(c,u,e,r,n),d=t.prevZ,v=t.nextZ;d&&d.z>=f&&v&&v.z<=h;){if(d!==t.prev&&d!==t.next&&g(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&m(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,v!==t.prev&&v!==t.next&&g(i.x,i.y,a.x,a.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;d&&d.z>=f;){if(d!==t.prev&&d!==t.next&&g(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&m(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;v&&v.z<=h;){if(v!==t.prev&&v!==t.next&&g(i.x,i.y,a.x,a.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function c(t,e,r){var n=t;do{var i=n.prev,a=n.next.next;!y(i,a)&&x(i,n,n.next,a)&&b(i,a)&&b(a,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(a.i/r),k(n),k(n.next),n=t=a),n=n.next}while(n!==t);return n}function u(t,e,r,n,i,s){var l=t;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&v(l,c)){var u=_(l,c);return l=a(l,l.next),u=a(u,u.next),o(l,e,r,n,i,s),void o(u,e,r,n,i,s)}c=c.next}l=l.next}while(l!==t)}function f(t,e){return t.x-e.x}function h(t,e){if(e=function(t,e){var r,n=e,i=t.x,a=t.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=u&&i!==n.x&&g(ar.x)&&b(n,t)&&(r=n,h=l),n=n.next;return r}(t,e)){var r=_(e,t);a(r,r.next)}}function p(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function d(t){var e=t,r=t;do{e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&x(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&b(t,e)&&b(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)}function m(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function y(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,r,n){return!!(y(t,e)&&y(r,n)||y(t,n)&&y(r,e))||m(t,e,r)>0!=m(t,e,n)>0&&m(r,n,t)>0!=m(r,n,e)>0}function b(t,e){return m(t.prev,t,t.next)<0?m(t,e,t.next)>=0&&m(t,t.prev,e)>=0:m(t,e,t.prev)<0||m(t,t.next,e)<0}function _(t,e){var r=new M(t.i,t.x,t.y),n=new M(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function w(t,e,r,n){var i=new M(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function k(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function M(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function A(t,e,r,n){for(var i=0,a=e,o=r-n;a0&&(n+=t[i-1].length,r.holes.push(n))}return r}},{}],157:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if("number"!=typeof e){e=0;for(var i=0;i=55296&&y<=56319&&(w+=t[++r]),w=k?h.call(k,M,w,g):w,e?(p.value=w,d(v,g,p)):v[g]=w,++g;m=g}if(void 0===m)for(m=o(t.length),e&&(v=new e(m)),r=0;r0?1:-1}},{}],168:[function(t,e,r){"use strict";var n=t("../math/sign"),i=Math.abs,a=Math.floor;e.exports=function(t){return isNaN(t)?0:0!==(t=Number(t))&&isFinite(t)?n(t)*a(i(t)):t}},{"../math/sign":165}],169:[function(t,e,r){"use strict";var n=t("./to-integer"),i=Math.max;e.exports=function(t){return i(0,n(t))}},{"./to-integer":168}],170:[function(t,e,r){"use strict";var n=t("./valid-callable"),i=t("./valid-value"),a=Function.prototype.bind,o=Function.prototype.call,s=Object.keys,l=Object.prototype.propertyIsEnumerable;e.exports=function(t,e){return function(r,c){var u,f=arguments[2],h=arguments[3];return r=Object(i(r)),n(c),u=s(r),h&&u.sort("function"==typeof h?a.call(h,r):void 0),"function"!=typeof t&&(t=u[t]),o.call(t,u,function(t,n){return l.call(r,t)?o.call(c,f,r[t],t,r,n):e})}}},{"./valid-callable":188,"./valid-value":190}],171:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Object.assign:t("./shim")},{"./is-implemented":172,"./shim":173}],172:[function(t,e,r){"use strict";e.exports=function(){var t,e=Object.assign;return"function"==typeof e&&(e(t={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},{}],173:[function(t,e,r){"use strict";var n=t("../keys"),i=t("../valid-value"),a=Math.max;e.exports=function(t,e){var r,o,s,l=a(arguments.length,2);for(t=Object(i(t)),s=function(n){try{t[n]=e[n]}catch(t){r||(r=t)}},o=1;o-1}},{}],194:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return"string"==typeof t||t&&"object"==typeof t&&(t instanceof String||n.call(t)===i)||!1}},{}],195:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],196:[function(t,e,r){"use strict";var n,i=t("es5-ext/object/set-prototype-of"),a=t("es5-ext/string/#/contains"),o=t("d"),s=t("es6-symbol"),l=t("./"),c=Object.defineProperty;n=e.exports=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");l.call(this,t),e=e?a.call(e,"key+value")?"key+value":a.call(e,"key")?"key":"value":"value",c(this,"__kind__",o("",e))},i&&i(n,l),delete n.prototype.constructor,n.prototype=Object.create(l.prototype,{_resolve:o(function(t){return"value"===this.__kind__?this.__list__[t]:"key+value"===this.__kind__?[t,this.__list__[t]]:t})}),c(n.prototype,s.toStringTag,o("c","Array Iterator"))},{"./":199,d:139,"es5-ext/object/set-prototype-of":185,"es5-ext/string/#/contains":191,"es6-symbol":204}],197:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),i=t("es5-ext/object/valid-callable"),a=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,l=Function.prototype.call,c=Array.prototype.some;e.exports=function(t,e){var r,u,f,h,p,d,g,v,m=arguments[2];if(s(t)||n(t)?r="array":a(t)?r="string":t=o(t),i(e),f=function(){h=!0},"array"!==r)if("string"!==r)for(u=t.next();!u.done;){if(l.call(e,m,u.value,f),h)return;u=t.next()}else for(d=t.length,p=0;p=55296&&v<=56319&&(g+=t[++p]),l.call(e,m,g,f),!h);++p);else c.call(t,function(t){return l.call(e,m,t,f),h})}},{"./get":198,"es5-ext/function/is-arguments":162,"es5-ext/object/valid-callable":188,"es5-ext/string/is-string":194}],198:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),i=t("es5-ext/string/is-string"),a=t("./array"),o=t("./string"),s=t("./valid-iterable"),l=t("es6-symbol").iterator;e.exports=function(t){return"function"==typeof s(t)[l]?t[l]():n(t)?new a(t):i(t)?new o(t):new a(t)}},{"./array":196,"./string":201,"./valid-iterable":202,"es5-ext/function/is-arguments":162,"es5-ext/string/is-string":194,"es6-symbol":204}],199:[function(t,e,r){"use strict";var n,i=t("es5-ext/array/#/clear"),a=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),l=t("d"),c=t("d/auto-bind"),u=t("es6-symbol"),f=Object.defineProperty,h=Object.defineProperties;e.exports=n=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");h(this,{__list__:l("w",s(t)),__context__:l("w",e),__nextIndex__:l("w",0)}),e&&(o(e.on),e.on("_add",this._onAdd),e.on("_delete",this._onDelete),e.on("_clear",this._onClear))},delete n.prototype.constructor,h(n.prototype,a({_next:l(function(){var t;if(this.__list__)return this.__redo__&&void 0!==(t=this.__redo__.shift())?t:this.__nextIndex__=this.__nextIndex__||(++this.__nextIndex__,this.__redo__?(this.__redo__.forEach(function(e,r){e>=t&&(this.__redo__[r]=++e)},this),this.__redo__.push(t)):f(this,"__redo__",l("c",[t])))}),_onDelete:l(function(t){var e;t>=this.__nextIndex__||(--this.__nextIndex__,this.__redo__&&(-1!==(e=this.__redo__.indexOf(t))&&this.__redo__.splice(e,1),this.__redo__.forEach(function(e,r){e>t&&(this.__redo__[r]=--e)},this)))}),_onClear:l(function(){this.__redo__&&i.call(this.__redo__),this.__nextIndex__=0})}))),f(n.prototype,u.iterator,l(function(){return this}))},{d:139,"d/auto-bind":138,"es5-ext/array/#/clear":158,"es5-ext/object/assign":171,"es5-ext/object/valid-callable":188,"es5-ext/object/valid-value":190,"es6-symbol":204}],200:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),i=t("es5-ext/object/is-value"),a=t("es5-ext/string/is-string"),o=t("es6-symbol").iterator,s=Array.isArray;e.exports=function(t){return!!i(t)&&(!!s(t)||(!!a(t)||(!!n(t)||"function"==typeof t[o])))}},{"es5-ext/function/is-arguments":162,"es5-ext/object/is-value":179,"es5-ext/string/is-string":194,"es6-symbol":204}],201:[function(t,e,r){"use strict";var n,i=t("es5-ext/object/set-prototype-of"),a=t("d"),o=t("es6-symbol"),s=t("./"),l=Object.defineProperty;n=e.exports=function(t){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");t=String(t),s.call(this,t),l(this,"__length__",a("",t.length))},i&&i(n,s),delete n.prototype.constructor,n.prototype=Object.create(s.prototype,{_next:a(function(){if(this.__list__)return this.__nextIndex__=55296&&e<=56319?r+this.__list__[this.__nextIndex__++]:r})}),l(n.prototype,o.toStringTag,a("c","String Iterator"))},{"./":199,d:139,"es5-ext/object/set-prototype-of":185,"es6-symbol":204}],202:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":200}],203:[function(t,e,r){(function(n,i){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.ES6Promise=n()}(this,function(){"use strict";function e(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},a=0,o=void 0,s=void 0,l=function(t,e){g[a]=t,g[a+1]=e,2===(a+=2)&&(s?s(v):_())};var c="undefined"!=typeof window?window:void 0,u=c||{},f=u.MutationObserver||u.WebKitMutationObserver,h="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(v,1)}}var g=new Array(1e3);function v(){for(var t=0;t=r-1){h=l.length-1;var d=t-e[r-1];for(p=0;p=r-1)for(var u=s.length-1,f=(e[r-1],0);f=0;--r)if(t[--e])return!1;return!0},s.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(t0;--f)n.push(a(l[f-1],c[f-1],arguments[f])),i.push(0)}},s.push=function(t){var e=this.lastT(),r=this.dimension;if(!(t1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var p=a(c[h-1],u[h-1],arguments[h]);n.push(p),i.push((p-n[o++])*f)}}},s.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(a(o[l-1],s[l-1],arguments[l])),n.push(0)}},s.move=function(t){var e=this.lastT(),r=this.dimension;if(!(t<=e||arguments.length!==r+1)){var n=this._state,i=this._velocity,o=n.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,f=u>1e-6?1/u:0;this._time.push(t);for(var h=r;h>0;--h){var p=arguments[h];n.push(a(l[h-1],c[h-1],n[o++]+p)),i.push(p*f)}}},s.idle=function(t){var e=this.lastT();if(!(t=0;--f)n.push(a(l[f],c[f],n[o]+u*i[o])),i.push(0),o+=1}}},{"binary-search-bounds":79,"cubic-hermite":133}],216:[function(t,e,r){var n=t("dtype");e.exports=function(t,e,r){if(!t)throw new TypeError("must specify data as first parameter");if(r=0|+(r||0),Array.isArray(t)&&t[0]&&"number"==typeof t[0][0]){var i,a,o,s,l=t[0].length,c=t.length*l;e&&"string"!=typeof e||(e=new(n(e||"float32"))(c+r));var u=e.length-r;if(c!==u)throw new Error("source length "+c+" ("+l+"x"+t.length+") does not match destination length "+u);for(i=0,o=r;ie[0]-o[0]/2&&(h=o[0]/2,p+=o[1]);return r}},{"css-font/stringify":130}],218:[function(t,e,r){"use strict";function n(t,e){e||(e={}),("string"==typeof t||Array.isArray(t))&&(e.family=t);var r=Array.isArray(e.family)?e.family.join(", "):e.family;if(!r)throw Error("`family` must be defined");var s=e.size||e.fontSize||e.em||48,l=e.weight||e.fontWeight||"",c=(t=[e.style||e.fontStyle||"",l,s].join(" ")+"px "+r,e.origin||"top");if(n.cache[r]&&s<=n.cache[r].em)return i(n.cache[r],c);var u=e.canvas||n.canvas,f=u.getContext("2d"),h={upper:void 0!==e.upper?e.upper:"H",lower:void 0!==e.lower?e.lower:"x",descent:void 0!==e.descent?e.descent:"p",ascent:void 0!==e.ascent?e.ascent:"h",tittle:void 0!==e.tittle?e.tittle:"i",overshoot:void 0!==e.overshoot?e.overshoot:"O"},p=Math.ceil(1.5*s);u.height=p,u.width=.5*p,f.font=t;var d={top:0};f.clearRect(0,0,p,p),f.textBaseline="top",f.fillStyle="black",f.fillText("H",0,0);var g=a(f.getImageData(0,0,p,p));f.clearRect(0,0,p,p),f.textBaseline="bottom",f.fillText("H",0,p);var v=a(f.getImageData(0,0,p,p));d.lineHeight=d.bottom=p-v+g,f.clearRect(0,0,p,p),f.textBaseline="alphabetic",f.fillText("H",0,p);var m=p-a(f.getImageData(0,0,p,p))-1+g;d.baseline=d.alphabetic=m,f.clearRect(0,0,p,p),f.textBaseline="middle",f.fillText("H",0,.5*p);var y=a(f.getImageData(0,0,p,p));d.median=d.middle=p-y-1+g-.5*p,f.clearRect(0,0,p,p),f.textBaseline="hanging",f.fillText("H",0,.5*p);var x=a(f.getImageData(0,0,p,p));d.hanging=p-x-1+g-.5*p,f.clearRect(0,0,p,p),f.textBaseline="ideographic",f.fillText("H",0,p);var b=a(f.getImageData(0,0,p,p));if(d.ideographic=p-b-1+g,h.upper&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.upper,0,0),d.upper=a(f.getImageData(0,0,p,p)),d.capHeight=d.baseline-d.upper),h.lower&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.lower,0,0),d.lower=a(f.getImageData(0,0,p,p)),d.xHeight=d.baseline-d.lower),h.tittle&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.tittle,0,0),d.tittle=a(f.getImageData(0,0,p,p))),h.ascent&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.ascent,0,0),d.ascent=a(f.getImageData(0,0,p,p))),h.descent&&(f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.descent,0,0),d.descent=o(f.getImageData(0,0,p,p))),h.overshoot){f.clearRect(0,0,p,p),f.textBaseline="top",f.fillText(h.overshoot,0,0);var _=o(f.getImageData(0,0,p,p));d.overshoot=_-m}for(var w in d)d[w]/=s;return d.em=s,n.cache[r]=d,i(d,c)}function i(t,e){var r={};for(var n in"string"==typeof e&&(e=t[e]),t)"em"!==n&&(r[n]=t[n]-e);return r}function a(t){for(var e=t.height,r=t.data,n=3;n0;n-=4)if(0!==r[n])return Math.floor(.25*(n-3)/e)}e.exports=n,n.canvas=document.createElement("canvas"),n.cache={}},{}],219:[function(t,e,r){"use strict";e.exports=function(t){return new c(t||d,null)};var n=0,i=1;function a(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function o(t){return new a(t._color,t.key,t.value,t.left,t.right,t._count)}function s(t,e){return new a(t,e.key,e.value,e.left,e.right,e._count)}function l(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function c(t,e){this._compare=t,this.root=e}var u=c.prototype;function f(t,e){this.tree=t,this._stack=e}Object.defineProperty(u,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(u,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(u,"length",{get:function(){return this.root?this.root._count:0}}),u.insert=function(t,e){for(var r=this._compare,o=this.root,u=[],f=[];o;){var h=r(t,o.key);u.push(o),f.push(h),o=h<=0?o.left:o.right}u.push(new a(n,t,e,null,null,1));for(var p=u.length-2;p>=0;--p){o=u[p];f[p]<=0?u[p]=new a(o._color,o.key,o.value,u[p+1],o.right,o._count+1):u[p]=new a(o._color,o.key,o.value,o.left,u[p+1],o._count+1)}for(p=u.length-1;p>1;--p){var d=u[p-1];o=u[p];if(d._color===i||o._color===i)break;var g=u[p-2];if(g.left===d)if(d.left===o){if(!(v=g.right)||v._color!==n){if(g._color=n,g.left=d.right,d._color=i,d.right=g,u[p-2]=d,u[p-1]=o,l(g),l(d),p>=3)(m=u[p-3]).left===g?m.left=d:m.right=d;break}d._color=i,g.right=s(i,v),g._color=n,p-=1}else{if(!(v=g.right)||v._color!==n){if(d.right=o.left,g._color=n,g.left=o.right,o._color=i,o.left=d,o.right=g,u[p-2]=o,u[p-1]=d,l(g),l(d),l(o),p>=3)(m=u[p-3]).left===g?m.left=o:m.right=o;break}d._color=i,g.right=s(i,v),g._color=n,p-=1}else if(d.right===o){if(!(v=g.left)||v._color!==n){if(g._color=n,g.right=d.left,d._color=i,d.left=g,u[p-2]=d,u[p-1]=o,l(g),l(d),p>=3)(m=u[p-3]).right===g?m.right=d:m.left=d;break}d._color=i,g.left=s(i,v),g._color=n,p-=1}else{var v;if(!(v=g.left)||v._color!==n){var m;if(d.left=o.right,g._color=n,g.right=o.left,o._color=i,o.right=d,o.left=g,u[p-2]=o,u[p-1]=d,l(g),l(d),l(o),p>=3)(m=u[p-3]).right===g?m.right=o:m.left=o;break}d._color=i,g.left=s(i,v),g._color=n,p-=1}}return u[0]._color=i,new c(r,u[0])},u.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return function t(e,r){var n;if(r.left&&(n=t(e,r.left)))return n;return(n=e(r.key,r.value))||(r.right?t(e,r.right):void 0)}(t,this.root);case 2:return function t(e,r,n,i){if(r(e,i.key)<=0){var a;if(i.left&&(a=t(e,r,n,i.left)))return a;if(a=n(i.key,i.value))return a}if(i.right)return t(e,r,n,i.right)}(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return function t(e,r,n,i,a){var o,s=n(e,a.key),l=n(r,a.key);if(s<=0){if(a.left&&(o=t(e,r,n,i,a.left)))return o;if(l>0&&(o=i(a.key,a.value)))return o}if(l>0&&a.right)return t(e,r,n,i,a.right)}(e,r,this._compare,t,this.root)}},Object.defineProperty(u,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(u,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),u.at=function(t){if(t<0)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},u.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<=0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},u.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},u.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},u.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},u.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=i<=0?r.left:r.right}return new f(this,[])},u.remove=function(t){var e=this.find(t);return e?e.remove():this},u.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=n<=0?r.left:r.right}};var h=f.prototype;function p(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t,e){return te?1:0}Object.defineProperty(h,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(h,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),h.clone=function(){return new f(this.tree,this._stack.slice())},h.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new a(r._color,r.key,r.value,r.left,r.right,r._count);for(var u=t.length-2;u>=0;--u){(r=t[u]).left===t[u+1]?e[u]=new a(r._color,r.key,r.value,e[u+1],r.right,r._count):e[u]=new a(r._color,r.key,r.value,r.left,e[u+1],r._count)}if((r=e[e.length-1]).left&&r.right){var f=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var h=e[f-1];e.push(new a(r._color,h.key,h.value,r.left,r.right,r._count)),e[f-1].key=r.key,e[f-1].value=r.value;for(u=e.length-2;u>=f;--u)r=e[u],e[u]=new a(r._color,r.key,r.value,r.left,e[u+1],r._count);e[f-1].left=e[f]}if((r=e[e.length-1])._color===n){var d=e[e.length-2];d.left===r?d.left=null:d.right===r&&(d.right=null),e.pop();for(u=0;u=0;--u){if(e=t[u],0===u)return void(e._color=i);if((r=t[u-1]).left===e){if((a=r.right).right&&a.right._color===n)return c=(a=r.right=o(a)).right=o(a.right),r.right=a.left,a.left=r,a.right=c,a._color=r._color,e._color=i,r._color=i,c._color=i,l(r),l(a),u>1&&((f=t[u-2]).left===r?f.left=a:f.right=a),void(t[u-1]=a);if(a.left&&a.left._color===n)return c=(a=r.right=o(a)).left=o(a.left),r.right=c.left,a.left=c.right,c.left=r,c.right=a,c._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(c),u>1&&((f=t[u-2]).left===r?f.left=c:f.right=c),void(t[u-1]=c);if(a._color===i){if(r._color===n)return r._color=i,void(r.right=s(n,a));r.right=s(n,a);continue}a=o(a),r.right=a.left,a.left=r,a._color=r._color,r._color=n,l(r),l(a),u>1&&((f=t[u-2]).left===r?f.left=a:f.right=a),t[u-1]=a,t[u]=r,u+11&&((f=t[u-2]).right===r?f.right=a:f.left=a),void(t[u-1]=a);if(a.right&&a.right._color===n)return c=(a=r.left=o(a)).right=o(a.right),r.left=c.right,a.right=c.left,c.right=r,c.left=a,c._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(c),u>1&&((f=t[u-2]).right===r?f.right=c:f.left=c),void(t[u-1]=c);if(a._color===i){if(r._color===n)return r._color=i,void(r.left=s(n,a));r.left=s(n,a);continue}var f;a=o(a),r.left=a.right,a.right=r,a._color=r._color,r._color=n,l(r),l(a),u>1&&((f=t[u-2]).right===r?f.right=a:f.left=a),t[u-1]=a,t[u]=r,u+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(h,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(h,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),h.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),h.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),n=e[e.length-1];r[r.length-1]=new a(n._color,n.key,t,n.left,n.right,n._count);for(var i=e.length-2;i>=0;--i)(n=e[i]).left===e[i+1]?r[i]=new a(n._color,n.key,n.value,r[i+1],n.right,n._count):r[i]=new a(n._color,n.key,n.value,n.left,r[i+1],n._count);return new c(this.tree._compare,r[0])},h.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(h,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],220:[function(t,e,r){var n=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],i=607/128,a=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function o(t){if(t<0)return Number("0/0");for(var e=a[0],r=a.length-1;r>0;--r)e+=a[r]/(t+r);var n=t+i+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}e.exports=function t(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*t(1-e));if(e>100)return Math.exp(o(e));e-=1;for(var r=n[0],i=1;i<9;i++)r+=n[i]/(e+i);var a=e+7+.5;return Math.sqrt(2*Math.PI)*Math.pow(a,e+.5)*Math.exp(-a)*r},e.exports.log=o},{}],221:[function(t,e,r){e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("must specify type string");if(e=e||{},"undefined"==typeof document&&!e.canvas)return null;var r=e.canvas||document.createElement("canvas");"number"==typeof e.width&&(r.width=e.width);"number"==typeof e.height&&(r.height=e.height);var n,i=e;try{var a=[t];0===t.indexOf("webgl")&&a.push("experimental-"+t);for(var o=0;o0?(p[u]=-1,d[u]=0):(p[u]=0,d[u]=1)}}var g=[0,0,0],v={model:l,view:l,projection:l};f.isOpaque=function(){return!0},f.isTransparent=function(){return!1},f.drawTransparent=function(t){};var m=[0,0,0],y=[0,0,0],x=[0,0,0];f.draw=function(t){t=t||v;for(var e=this.gl,r=t.model||l,n=t.view||l,i=t.projection||l,a=this.bounds,s=o(r,n,i,a),u=s.cubeEdges,f=s.axis,h=n[12],b=n[13],_=n[14],w=n[15],k=this.pixelRatio*(i[3]*h+i[7]*b+i[11]*_+i[15]*w)/e.drawingBufferHeight,M=0;M<3;++M)this.lastCubeProps.cubeEdges[M]=u[M],this.lastCubeProps.axis[M]=f[M];var A=p;for(M=0;M<3;++M)d(p[M],M,this.bounds,u,f);e=this.gl;var T,S=g;for(M=0;M<3;++M)this.backgroundEnable[M]?S[M]=f[M]:S[M]=0;this._background.draw(r,n,i,a,S,this.backgroundColor),this._lines.bind(r,n,i,this);for(M=0;M<3;++M){var C=[0,0,0];f[M]>0?C[M]=a[1][M]:C[M]=a[0][M];for(var E=0;E<2;++E){var L=(M+1+E)%3,z=(M+1+(1^E))%3;this.gridEnable[L]&&this._lines.drawGrid(L,z,this.bounds,C,this.gridColor[L],this.gridWidth[L]*this.pixelRatio)}for(E=0;E<2;++E){L=(M+1+E)%3,z=(M+1+(1^E))%3;this.zeroEnable[z]&&Math.min(a[0][z],a[1][z])<=0&&Math.max(a[0][z],a[1][z])>=0&&this._lines.drawZero(L,z,this.bounds,C,this.zeroLineColor[z],this.zeroLineWidth[z]*this.pixelRatio)}}for(M=0;M<3;++M){this.lineEnable[M]&&this._lines.drawAxisLine(M,this.bounds,A[M].primalOffset,this.lineColor[M],this.lineWidth[M]*this.pixelRatio),this.lineMirror[M]&&this._lines.drawAxisLine(M,this.bounds,A[M].mirrorOffset,this.lineColor[M],this.lineWidth[M]*this.pixelRatio);var O=c(m,A[M].primalMinor),I=c(y,A[M].mirrorMinor),P=this.lineTickLength;for(E=0;E<3;++E){var D=k/r[5*E];O[E]*=P[E]*D,I[E]*=P[E]*D}this.lineTickEnable[M]&&this._lines.drawAxisTicks(M,A[M].primalOffset,O,this.lineTickColor[M],this.lineTickWidth[M]*this.pixelRatio),this.lineTickMirror[M]&&this._lines.drawAxisTicks(M,A[M].mirrorOffset,I,this.lineTickColor[M],this.lineTickWidth[M]*this.pixelRatio)}this._lines.unbind(),this._text.bind(r,n,i,this.pixelRatio);var R,F;function B(t){(F=[0,0,0])[t]=1}function N(t,e,r){var n=(t+1)%3,i=(t+2)%3,a=e[n],o=e[i],s=r[n],l=r[i];a>0&&l>0?B(n):a>0&&l<0?B(n):a<0&&l>0?B(n):a<0&&l<0?B(n):o>0&&s>0?B(i):o>0&&s<0?B(i):o<0&&s>0?B(i):o<0&&s<0&&B(i)}for(M=0;M<3;++M){var j=A[M].primalMinor,V=A[M].mirrorMinor,U=c(x,A[M].primalOffset);for(E=0;E<3;++E)this.lineTickEnable[M]&&(U[E]+=k*j[E]*Math.max(this.lineTickLength[E],0)/r[5*E]);var q=[0,0,0];if(q[M]=1,this.tickEnable[M]){-3600===this.tickAngle[M]?(this.tickAngle[M]=0,this._tickAlign[M]="auto"):this._tickAlign[M]=-1,R=1,"auto"===(T=[this._tickAlign[M],.5,R])[0]?T[0]=0:T[0]=parseInt(""+T[0]),F=[0,0,0],N(M,j,V);for(E=0;E<3;++E)U[E]+=k*j[E]*this.tickPad[E]/r[5*E];this._text.drawTicks(M,this.tickSize[M],this.tickAngle[M],U,this.tickColor[M],q,F,T)}if(this.labelEnable[M]){R=0,F=[0,0,0],this.labels[M].length>4&&(B(M),R=1),"auto"===(T=[this.labelAlign[M],.5,R])[0]?T[0]=0:T[0]=parseInt(""+T[0]);for(E=0;E<3;++E)U[E]+=k*j[E]*this.labelPad[E]/r[5*E];U[M]+=.5*(a[0][M]+a[1][M]),this._text.drawLabel(M,this.labelSize[M],this.labelAngle[M],U,this.labelColor[M],[0,0,0],F,T)}}this._text.unbind()},f.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":223,"./lib/cube.js":224,"./lib/lines.js":225,"./lib/text.js":227,"./lib/ticks.js":228}],223:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=[],s=0,l=0;l<3;++l)for(var c=(l+1)%3,u=(l+2)%3,f=[0,0,0],h=[0,0,0],p=-1;p<=1;p+=2){r.push(s,s+2,s+1,s+1,s+2,s+3),f[l]=p,h[l]=p;for(var d=-1;d<=1;d+=2){f[c]=d;for(var g=-1;g<=1;g+=2)f[u]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),s+=1}var v=c;c=u,u=v}var m=n(t,new Float32Array(e)),y=n(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),x=i(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),b=a(t);return b.attributes.position.location=0,b.attributes.normal.location=1,new o(t,m,x,b)};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders").bg;function o(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}var s=o.prototype;s.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;s<3;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),this.vao.unbind(),l.disable(l.POLYGON_OFFSET_FILL)}},s.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":226,"gl-buffer":230,"gl-vao":310}],224:[function(t,e,r){"use strict";e.exports=function(t,e,r,a){i(s,e,t),i(s,r,s);for(var p=0,y=0;y<2;++y){u[2]=a[y][2];for(var x=0;x<2;++x){u[1]=a[x][1];for(var b=0;b<2;++b)u[0]=a[b][0],h(l[p],u,s),p+=1}}for(var _=-1,y=0;y<8;++y){for(var w=l[y][3],k=0;k<3;++k)c[y][k]=l[y][k]/w;w<0&&(_<0?_=y:c[y][2]S&&(_|=1<S&&(_|=1<c[y][1]&&(D=y));for(var R=-1,y=0;y<3;++y){var F=D^1<c[B][0]&&(B=F)}}var N=g;N[0]=N[1]=N[2]=0,N[n.log2(R^D)]=D&R,N[n.log2(D^B)]=D&B;var j=7^B;j===_||j===P?(j=7^R,N[n.log2(B^j)]=j&B):N[n.log2(R^j)]=j&R;for(var V=v,U=_,M=0;M<3;++M)V[M]=U&1< HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]),l=n(["precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]);r.text=function(t){return i(t,s,l,null,[{name:"position",type:"vec3"}])};var c=n(["#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]),u=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]);r.bg=function(t){return i(t,c,u,null,[{name:"position",type:"vec3"},{name:"normal",type:"vec3"}])}},{"gl-shader":288,glslify:392}],227:[function(t,e,r){(function(r){"use strict";e.exports=function(t,e,r,a,s,l){var u=n(t),f=i(t,[{buffer:u,size:3}]),h=o(t);h.attributes.position.location=0;var p=new c(t,h,u,f);return p.update(e,r,a,s,l),p};var n=t("gl-buffer"),i=t("gl-vao"),a=t("vectorize-text"),o=t("./shaders").text,s=window||r.global||{},l=s.__TEXT_CACHE||{};s.__TEXT_CACHE={};function c(t,e,r,n){this.gl=t,this.shader=e,this.buffer=r,this.vao=n,this.tickOffset=this.tickCount=this.labelOffset=this.labelCount=null}var u=c.prototype,f=[0,0];u.bind=function(t,e,r,n){this.vao.bind(),this.shader.bind();var i=this.shader.uniforms;i.model=t,i.view=e,i.projection=r,i.pixelScale=n,f[0]=this.gl.drawingBufferWidth,f[1]=this.gl.drawingBufferHeight,this.shader.uniforms.resolution=f},u.unbind=function(){this.vao.unbind()},u.update=function(t,e,r,n,i){var o=[];function s(t,e,r,n,i,s){var c=l[r];c||(c=l[r]={});var u=c[e];u||(u=c[e]=function(t,e){try{return a(t,e)}catch(e){return console.warn('error vectorizing text:"'+t+'" error:',e),{cells:[],positions:[]}}}(e,{triangles:!0,font:r,textAlign:"center",textBaseline:"middle",lineSpacing:i,styletags:s}));for(var f=(n||12)/12,h=u.positions,p=u.cells,d=0,g=p.length;d=0;--m){var y=h[v[m]];o.push(f*y[0],-f*y[1],t)}}for(var c=[0,0,0],u=[0,0,0],f=[0,0,0],h=[0,0,0],p={breaklines:!0,bolds:!0,italics:!0,subscripts:!0,superscripts:!0},d=0;d<3;++d){f[d]=o.length/3|0,s(.5*(t[0][d]+t[1][d]),e[d],r[d],12,1.25,p),h[d]=(o.length/3|0)-f[d],c[d]=o.length/3|0;for(var g=0;g=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,c=o%a;o<0?(l=0|-Math.ceil(l),c=0|-c):(l=0|Math.floor(l),c|=0);var u=""+l;if(o<0&&(u="-"+u),i){for(var f=""+c;f.length=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r},r.equal=function(t,e){for(var r=0;r<3;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;nr)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function u(t,e){for(var r=n.malloc(t.length,e),i=t.length,a=0;a=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=c(this.gl,this.type,this.length,this.usage,t.data,e):this.length=c(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=n.malloc(t.size,r),l=a(s,t.shape);i.assign(l,t),this.length=c(this.gl,this.type,this.length,this.usage,e<0?s:s.subarray(0,t.size),e),n.free(s)}}else if(Array.isArray(t)){var f;f=this.type===this.gl.ELEMENT_ARRAY_BUFFER?u(t,"uint16"):u(t,"float32"),this.length=c(this.gl,this.type,this.length,this.usage,e<0?f:f.subarray(0,t.length),e),n.free(f)}else if("object"==typeof t&&"number"==typeof t.length)this.length=c(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");(t|=0)<=0&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=function(t,e,r,n){if(r=r||t.ARRAY_BUFFER,n=n||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(n!==t.DYNAMIC_DRAW&&n!==t.STATIC_DRAW&&n!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var i=t.createBuffer(),a=new s(t,r,i,0,n);return a.update(e),a}},{ndarray:433,"ndarray-ops":427,"typedarray-pool":521}],231:[function(t,e,r){"use strict";var n=t("gl-vec3"),i=(t("gl-vec4"),function(t,e){for(var r=0;r=e)return r-1;return r}),a=n.create(),o=n.create(),s=function(t,e,r){return tr?r:t},l=function(t,e,r,l){var c=t[0],u=t[1],f=t[2],h=r[0].length,p=r[1].length,d=r[2].length,g=i(r[0],c),v=i(r[1],u),m=i(r[2],f),y=g+1,x=v+1,b=m+1;if(l&&(g=s(g,0,h-1),y=s(y,0,h-1),v=s(v,0,p-1),x=s(x,0,p-1),m=s(m,0,d-1),b=s(b,0,d-1)),g<0||v<0||m<0||y>=h||x>=p||b>=d)return n.create();var _=(c-r[0][g])/(r[0][y]-r[0][g]),w=(u-r[1][v])/(r[1][x]-r[1][v]),k=(f-r[2][m])/(r[2][b]-r[2][m]);(_<0||_>1||isNaN(_))&&(_=0),(w<0||w>1||isNaN(w))&&(w=0),(k<0||k>1||isNaN(k))&&(k=0);var M=m*h*p,A=b*h*p,T=v*h,S=x*h,C=g,E=y,L=e[T+M+C],z=e[T+M+E],O=e[S+M+C],I=e[S+M+E],P=e[T+A+C],D=e[T+A+E],R=e[S+A+C],F=e[S+A+E],B=n.create();return n.lerp(B,L,z,_),n.lerp(a,O,I,_),n.lerp(B,B,a,w),n.lerp(a,P,D,_),n.lerp(o,R,F,_),n.lerp(a,a,o,w),n.lerp(B,B,a,k),B};e.exports=function(t,e){var r;r=t.positions?t.positions:function(t){for(var e=t[0],r=t[1],n=t[2],i=[],a=0;as&&(s=n.length(b)),x&&(y=Math.min(y,2*n.distance(g,_)/(n.length(v)+n.length(b)))),g=_,v=b,m.push(b)}var w=[c,f,p],k=[u,h,d];e&&(e[0]=w,e[1]=k),0===s&&(s=1);var M=1/s;isFinite(y)&&!isNaN(y)||(y=1),o.vectorScale=y;var A=function(t,e,r){var i=n.create();return void 0!==t&&n.set(i,t,e,r),i}(0,1,0),T=t.coneSize||.5;t.absoluteConeSize&&(T=t.absoluteConeSize*M),o.coneScale=T;x=0;for(var S=0;x1.0001)return null;v+=g[u]}if(Math.abs(v-1)>.001)return null;return[f,function(t,e){for(var r=[0,0,0],n=0;n=1},x.isTransparent=function(){return this.opacity<1},x.pickSlots=1,x.setPickBase=function(t){this.pickId=t},x.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=p.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},x.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||m,n=t.view||m,i=t.projection||m,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,vectorScale:this.vectorScale,coneScale:this.coneScale,coneOffset:this.coneOffset,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},x.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions[r[1]].slice(0,3);return{index:Math.floor(r[1]/48),position:n,dataCoordinate:n}},x.dispose=function(){this.texture.dispose(),this.triShader.dispose(),this.pickShader.dispose(),this.triangleVAO.dispose(),this.trianglePositions.dispose(),this.triangleVectors.dispose(),this.triangleColors.dispose(),this.triangleUVs.dispose(),this.triangleNormals.dispose(),this.triangleIds.dispose(),this.edgeVAO.dispose(),this.edgePositions.dispose(),this.edgeColors.dispose(),this.edgeUVs.dispose(),this.edgeIds.dispose(),this.pointVAO.dispose(),this.pointPositions.dispose(),this.pointColors.dispose(),this.pointUVs.dispose(),this.pointSizes.dispose(),this.pointIds.dispose(),this.contourVAO.dispose(),this.contourPositions.dispose()},e.exports=function(t,e){1===arguments.length&&(t=(e=t).gl);var r=e.triShader||function(t){var e=n(t,g.vertex,g.fragment,null,g.attributes);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.vector.location=5,e}(t),s=b(t),l=o(t,u(new Uint8Array([255,255,255,255]),[1,1,4]));l.generateMipmap(),l.minFilter=t.LINEAR_MIPMAP_LINEAR,l.magFilter=t.LINEAR;var c=i(t),f=i(t),h=i(t),p=i(t),d=i(t),v=i(t),m=a(t,[{buffer:c,type:t.FLOAT,size:4},{buffer:v,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:h,type:t.FLOAT,size:4},{buffer:p,type:t.FLOAT,size:2},{buffer:d,type:t.FLOAT,size:3},{buffer:f,type:t.FLOAT,size:3}]),x=i(t),_=i(t),w=i(t),k=i(t),M=a(t,[{buffer:x,type:t.FLOAT,size:3},{buffer:k,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:_,type:t.FLOAT,size:4},{buffer:w,type:t.FLOAT,size:2}]),A=i(t),T=i(t),S=i(t),C=i(t),E=i(t),L=a(t,[{buffer:A,type:t.FLOAT,size:3},{buffer:E,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:T,type:t.FLOAT,size:4},{buffer:S,type:t.FLOAT,size:2},{buffer:C,type:t.FLOAT,size:1}]),z=i(t),O=new y(t,l,r,null,null,s,null,null,c,f,v,h,p,d,m,x,k,_,w,M,A,E,T,S,C,L,z,a(t,[{buffer:z,type:t.FLOAT,size:3}]));return O.update(e),O}},{"./closest-point":232,"./shaders":234,colormap:114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,ndarray:433,normals:436,"simplicial-complex-contour":494,"typedarray-pool":521}],234:[function(t,e,r){var n=t("glslify"),i=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float vectorScale;\nuniform float coneScale;\n\nuniform float coneOffset;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n f_color = color; //vec4(position.w, color.r, 0, 0);\n f_normal = normal;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - conePosition.xyz;\n f_lightDirection = lightPosition - conePosition.xyz;\n f_uv = uv;\n}\n"]),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float index, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n index = mod(index, segmentCount * 6.0);\n\n float segment = floor(index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex == 3.0) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n // angle = 2pi * ((segment + ((segmentIndex == 1.0 || segmentIndex == 5.0) ? 1.0 : 0.0)) / segmentCount)\n float nextAngle = float(segmentIndex == 1.0 || segmentIndex == 5.0);\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex <= 2.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nuniform float vectorScale;\nuniform float coneScale;\nuniform float coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec3"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec3"}]}},{glslify:392}],235:[function(t,e,r){e.exports={0:"NONE",1:"ONE",2:"LINE_LOOP",3:"LINE_STRIP",4:"TRIANGLES",5:"TRIANGLE_STRIP",6:"TRIANGLE_FAN",256:"DEPTH_BUFFER_BIT",512:"NEVER",513:"LESS",514:"EQUAL",515:"LEQUAL",516:"GREATER",517:"NOTEQUAL",518:"GEQUAL",519:"ALWAYS",768:"SRC_COLOR",769:"ONE_MINUS_SRC_COLOR",770:"SRC_ALPHA",771:"ONE_MINUS_SRC_ALPHA",772:"DST_ALPHA",773:"ONE_MINUS_DST_ALPHA",774:"DST_COLOR",775:"ONE_MINUS_DST_COLOR",776:"SRC_ALPHA_SATURATE",1024:"STENCIL_BUFFER_BIT",1028:"FRONT",1029:"BACK",1032:"FRONT_AND_BACK",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",2304:"CW",2305:"CCW",2849:"LINE_WIDTH",2884:"CULL_FACE",2885:"CULL_FACE_MODE",2886:"FRONT_FACE",2928:"DEPTH_RANGE",2929:"DEPTH_TEST",2930:"DEPTH_WRITEMASK",2931:"DEPTH_CLEAR_VALUE",2932:"DEPTH_FUNC",2960:"STENCIL_TEST",2961:"STENCIL_CLEAR_VALUE",2962:"STENCIL_FUNC",2963:"STENCIL_VALUE_MASK",2964:"STENCIL_FAIL",2965:"STENCIL_PASS_DEPTH_FAIL",2966:"STENCIL_PASS_DEPTH_PASS",2967:"STENCIL_REF",2968:"STENCIL_WRITEMASK",2978:"VIEWPORT",3024:"DITHER",3042:"BLEND",3088:"SCISSOR_BOX",3089:"SCISSOR_TEST",3106:"COLOR_CLEAR_VALUE",3107:"COLOR_WRITEMASK",3317:"UNPACK_ALIGNMENT",3333:"PACK_ALIGNMENT",3379:"MAX_TEXTURE_SIZE",3386:"MAX_VIEWPORT_DIMS",3408:"SUBPIXEL_BITS",3410:"RED_BITS",3411:"GREEN_BITS",3412:"BLUE_BITS",3413:"ALPHA_BITS",3414:"DEPTH_BITS",3415:"STENCIL_BITS",3553:"TEXTURE_2D",4352:"DONT_CARE",4353:"FASTEST",4354:"NICEST",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT",5386:"INVERT",5890:"TEXTURE",6401:"STENCIL_INDEX",6402:"DEPTH_COMPONENT",6406:"ALPHA",6407:"RGB",6408:"RGBA",6409:"LUMINANCE",6410:"LUMINANCE_ALPHA",7680:"KEEP",7681:"REPLACE",7682:"INCR",7683:"DECR",7936:"VENDOR",7937:"RENDERER",7938:"VERSION",9728:"NEAREST",9729:"LINEAR",9984:"NEAREST_MIPMAP_NEAREST",9985:"LINEAR_MIPMAP_NEAREST",9986:"NEAREST_MIPMAP_LINEAR",9987:"LINEAR_MIPMAP_LINEAR",10240:"TEXTURE_MAG_FILTER",10241:"TEXTURE_MIN_FILTER",10242:"TEXTURE_WRAP_S",10243:"TEXTURE_WRAP_T",10497:"REPEAT",10752:"POLYGON_OFFSET_UNITS",16384:"COLOR_BUFFER_BIT",32769:"CONSTANT_COLOR",32770:"ONE_MINUS_CONSTANT_COLOR",32771:"CONSTANT_ALPHA",32772:"ONE_MINUS_CONSTANT_ALPHA",32773:"BLEND_COLOR",32774:"FUNC_ADD",32777:"BLEND_EQUATION_RGB",32778:"FUNC_SUBTRACT",32779:"FUNC_REVERSE_SUBTRACT",32819:"UNSIGNED_SHORT_4_4_4_4",32820:"UNSIGNED_SHORT_5_5_5_1",32823:"POLYGON_OFFSET_FILL",32824:"POLYGON_OFFSET_FACTOR",32854:"RGBA4",32855:"RGB5_A1",32873:"TEXTURE_BINDING_2D",32926:"SAMPLE_ALPHA_TO_COVERAGE",32928:"SAMPLE_COVERAGE",32936:"SAMPLE_BUFFERS",32937:"SAMPLES",32938:"SAMPLE_COVERAGE_VALUE",32939:"SAMPLE_COVERAGE_INVERT",32968:"BLEND_DST_RGB",32969:"BLEND_SRC_RGB",32970:"BLEND_DST_ALPHA",32971:"BLEND_SRC_ALPHA",33071:"CLAMP_TO_EDGE",33170:"GENERATE_MIPMAP_HINT",33189:"DEPTH_COMPONENT16",33306:"DEPTH_STENCIL_ATTACHMENT",33635:"UNSIGNED_SHORT_5_6_5",33648:"MIRRORED_REPEAT",33901:"ALIASED_POINT_SIZE_RANGE",33902:"ALIASED_LINE_WIDTH_RANGE",33984:"TEXTURE0",33985:"TEXTURE1",33986:"TEXTURE2",33987:"TEXTURE3",33988:"TEXTURE4",33989:"TEXTURE5",33990:"TEXTURE6",33991:"TEXTURE7",33992:"TEXTURE8",33993:"TEXTURE9",33994:"TEXTURE10",33995:"TEXTURE11",33996:"TEXTURE12",33997:"TEXTURE13",33998:"TEXTURE14",33999:"TEXTURE15",34000:"TEXTURE16",34001:"TEXTURE17",34002:"TEXTURE18",34003:"TEXTURE19",34004:"TEXTURE20",34005:"TEXTURE21",34006:"TEXTURE22",34007:"TEXTURE23",34008:"TEXTURE24",34009:"TEXTURE25",34010:"TEXTURE26",34011:"TEXTURE27",34012:"TEXTURE28",34013:"TEXTURE29",34014:"TEXTURE30",34015:"TEXTURE31",34016:"ACTIVE_TEXTURE",34024:"MAX_RENDERBUFFER_SIZE",34041:"DEPTH_STENCIL",34055:"INCR_WRAP",34056:"DECR_WRAP",34067:"TEXTURE_CUBE_MAP",34068:"TEXTURE_BINDING_CUBE_MAP",34069:"TEXTURE_CUBE_MAP_POSITIVE_X",34070:"TEXTURE_CUBE_MAP_NEGATIVE_X",34071:"TEXTURE_CUBE_MAP_POSITIVE_Y",34072:"TEXTURE_CUBE_MAP_NEGATIVE_Y",34073:"TEXTURE_CUBE_MAP_POSITIVE_Z",34074:"TEXTURE_CUBE_MAP_NEGATIVE_Z",34076:"MAX_CUBE_MAP_TEXTURE_SIZE",34338:"VERTEX_ATTRIB_ARRAY_ENABLED",34339:"VERTEX_ATTRIB_ARRAY_SIZE",34340:"VERTEX_ATTRIB_ARRAY_STRIDE",34341:"VERTEX_ATTRIB_ARRAY_TYPE",34342:"CURRENT_VERTEX_ATTRIB",34373:"VERTEX_ATTRIB_ARRAY_POINTER",34466:"NUM_COMPRESSED_TEXTURE_FORMATS",34467:"COMPRESSED_TEXTURE_FORMATS",34660:"BUFFER_SIZE",34661:"BUFFER_USAGE",34816:"STENCIL_BACK_FUNC",34817:"STENCIL_BACK_FAIL",34818:"STENCIL_BACK_PASS_DEPTH_FAIL",34819:"STENCIL_BACK_PASS_DEPTH_PASS",34877:"BLEND_EQUATION_ALPHA",34921:"MAX_VERTEX_ATTRIBS",34922:"VERTEX_ATTRIB_ARRAY_NORMALIZED",34930:"MAX_TEXTURE_IMAGE_UNITS",34962:"ARRAY_BUFFER",34963:"ELEMENT_ARRAY_BUFFER",34964:"ARRAY_BUFFER_BINDING",34965:"ELEMENT_ARRAY_BUFFER_BINDING",34975:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",35040:"STREAM_DRAW",35044:"STATIC_DRAW",35048:"DYNAMIC_DRAW",35632:"FRAGMENT_SHADER",35633:"VERTEX_SHADER",35660:"MAX_VERTEX_TEXTURE_IMAGE_UNITS",35661:"MAX_COMBINED_TEXTURE_IMAGE_UNITS",35663:"SHADER_TYPE",35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",35712:"DELETE_STATUS",35713:"COMPILE_STATUS",35714:"LINK_STATUS",35715:"VALIDATE_STATUS",35716:"INFO_LOG_LENGTH",35717:"ATTACHED_SHADERS",35718:"ACTIVE_UNIFORMS",35719:"ACTIVE_UNIFORM_MAX_LENGTH",35720:"SHADER_SOURCE_LENGTH",35721:"ACTIVE_ATTRIBUTES",35722:"ACTIVE_ATTRIBUTE_MAX_LENGTH",35724:"SHADING_LANGUAGE_VERSION",35725:"CURRENT_PROGRAM",36003:"STENCIL_BACK_REF",36004:"STENCIL_BACK_VALUE_MASK",36005:"STENCIL_BACK_WRITEMASK",36006:"FRAMEBUFFER_BINDING",36007:"RENDERBUFFER_BINDING",36048:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36049:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36050:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36051:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36053:"FRAMEBUFFER_COMPLETE",36054:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36055:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36057:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36061:"FRAMEBUFFER_UNSUPPORTED",36064:"COLOR_ATTACHMENT0",36096:"DEPTH_ATTACHMENT",36128:"STENCIL_ATTACHMENT",36160:"FRAMEBUFFER",36161:"RENDERBUFFER",36162:"RENDERBUFFER_WIDTH",36163:"RENDERBUFFER_HEIGHT",36164:"RENDERBUFFER_INTERNAL_FORMAT",36168:"STENCIL_INDEX8",36176:"RENDERBUFFER_RED_SIZE",36177:"RENDERBUFFER_GREEN_SIZE",36178:"RENDERBUFFER_BLUE_SIZE",36179:"RENDERBUFFER_ALPHA_SIZE",36180:"RENDERBUFFER_DEPTH_SIZE",36181:"RENDERBUFFER_STENCIL_SIZE",36194:"RGB565",36336:"LOW_FLOAT",36337:"MEDIUM_FLOAT",36338:"HIGH_FLOAT",36339:"LOW_INT",36340:"MEDIUM_INT",36341:"HIGH_INT",36346:"SHADER_COMPILER",36347:"MAX_VERTEX_UNIFORM_VECTORS",36348:"MAX_VARYING_VECTORS",36349:"MAX_FRAGMENT_UNIFORM_VECTORS",37440:"UNPACK_FLIP_Y_WEBGL",37441:"UNPACK_PREMULTIPLY_ALPHA_WEBGL",37442:"CONTEXT_LOST_WEBGL",37443:"UNPACK_COLORSPACE_CONVERSION_WEBGL",37444:"BROWSER_DEFAULT_WEBGL"}},{}],236:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":235}],237:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=n(e),o=i(e,[{buffer:r,type:e.FLOAT,size:3,offset:0,stride:40},{buffer:r,type:e.FLOAT,size:4,offset:12,stride:40},{buffer:r,type:e.FLOAT,size:3,offset:28,stride:40}]),l=a(e);l.attributes.position.location=0,l.attributes.color.location=1,l.attributes.offset.location=2;var c=new s(e,r,o,l);return c.update(t),c};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders/index"),o=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function s(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}var l=s.prototype;function c(t,e){for(var r=0;r<3;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}l.isOpaque=function(){return this.opacity>=1},l.isTransparent=function(){return this.opacity<1},l.drawTransparent=l.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||o,i=r.projection=t.projection||o;r.model=t.model||o,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],s=n[13],l=n[14],c=n[15],u=this.pixelRatio*(i[3]*a+i[7]*s+i[11]*l+i[15]*c)/e.drawingBufferHeight;this.vao.bind();for(var f=0;f<3;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*u,this.lineCount[f]&&e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var u=function(){for(var t=new Array(3),e=0;e<3;++e){for(var r=[],n=1;n<=2;++n)for(var i=-1;i<=1;i+=2){var a=[0,0,0];a[(n+e)%3]=i,r.push(a)}t[e]=r}return t}();function f(t,e,r,n){for(var i=u[n],a=0;a0)(g=u.slice())[s]+=p[1][s],i.push(u[0],u[1],u[2],d[0],d[1],d[2],d[3],0,0,0,g[0],g[1],g[2],d[0],d[1],d[2],d[3],0,0,0),c(this.bounds,g),o+=2+f(i,g,d,s)}}this.lineCount[s]=o-this.lineOffset[s]}this.buffer.update(i)}},l.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":238,"gl-buffer":230,"gl-vao":310}],238:[function(t,e,r){"use strict";var n=t("glslify"),i=t("gl-shader"),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], fragPosition)) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]);e.exports=function(t){return i(t,a,o,null,[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"offset",type:"vec3"}])}},{"gl-shader":288,glslify:392}],239:[function(t,e,r){"use strict";var n=t("gl-texture2d");e.exports=function(t,e,r,n){i||(i=t.FRAMEBUFFER_UNSUPPORTED,a=t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT,o=t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS,s=t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);var c=t.getExtension("WEBGL_draw_buffers");!l&&c&&function(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);l=new Array(r+1);for(var n=0;n<=r;++n){for(var i=new Array(r),a=0;au||r<0||r>u)throw new Error("gl-fbo: Parameters are too large for FBO");var f=1;if("color"in(n=n||{})){if((f=Math.max(0|n.color,0))<0)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(f>1){if(!c)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(f>t.getParameter(c.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+f+" draw buffers")}}var h=t.UNSIGNED_BYTE,p=t.getExtension("OES_texture_float");if(n.float&&f>0){if(!p)throw new Error("gl-fbo: Context does not support floating point textures");h=t.FLOAT}else n.preferFloat&&f>0&&p&&(h=t.FLOAT);var g=!0;"depth"in n&&(g=!!n.depth);var v=!1;"stencil"in n&&(v=!!n.stencil);return new d(t,e,r,h,f,g,v,c)};var i,a,o,s,l=null;function c(t){return[t.getParameter(t.FRAMEBUFFER_BINDING),t.getParameter(t.RENDERBUFFER_BINDING),t.getParameter(t.TEXTURE_BINDING_2D)]}function u(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function f(t){switch(t){case i:throw new Error("gl-fbo: Framebuffer unsupported");case a:throw new Error("gl-fbo: Framebuffer incomplete attachment");case o:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case s:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function h(t,e,r,i,a,o){if(!i)return null;var s=n(t,e,r,a,i);return s.magFilter=t.NEAREST,s.minFilter=t.NEAREST,s.mipSamples=1,s.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_2D,s.handle,0),s}function p(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function d(t,e,r,n,i,a,o,s){this.gl=t,this._shape=[0|e,0|r],this._destroyed=!1,this._ext=s,this.color=new Array(i);for(var d=0;d1&&s.drawBuffersWEBGL(l[o]);var y=r.getExtension("WEBGL_depth_texture");y?d?t.depth=h(r,i,a,y.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g&&(t.depth=h(r,i,a,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):g&&d?t._depth_rb=p(r,i,a,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g?t._depth_rb=p(r,i,a,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=p(r,i,a,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var x=r.checkFramebufferStatus(r.FRAMEBUFFER);if(x!==r.FRAMEBUFFER_COMPLETE){for(t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null),m=0;mi||r<0||r>i)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var a=c(n),o=0;o>8*p&255;this.pickOffset=r,i.bind();var d=i.uniforms;d.viewTransform=t,d.pickOffset=e,d.shape=this.shape;var g=i.attributes;return this.positionBuffer.bind(),g.position.pointer(),this.weightBuffer.bind(),g.weight.pointer(s.UNSIGNED_BYTE,!1),this.idBuffer.bind(),g.pickId.pointer(s.UNSIGNED_BYTE,!1),s.drawArrays(s.TRIANGLES,0,o),r+this.shape[0]*this.shape[1]}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.shape[0]*this.shape[1];if(r=n+i)return null;var a=r-n,o=this.xData,s=this.yData;return{object:this,pointId:a,dataCoord:[o[a%this.shape[0]],s[a/this.shape[0]|0]]}},f.update=function(t){var e=(t=t||{}).shape||[0,0],r=t.x||i(e[0]),o=t.y||i(e[1]),s=t.z||new Float32Array(e[0]*e[1]);this.xData=r,this.yData=o;var l=t.colorLevels||[0],c=t.colorValues||[0,0,0,1],u=l.length,f=this.bounds,p=f[0]=r[0],d=f[1]=o[0],g=1/((f[2]=r[r.length-1])-p),v=1/((f[3]=o[o.length-1])-d),m=e[0],y=e[1];this.shape=[m,y];var x=(m-1)*(y-1)*(h.length>>>1);this.numVertices=x;for(var b=a.mallocUint8(4*x),_=a.mallocFloat32(2*x),w=a.mallocUint8(2*x),k=a.mallocUint32(x),M=0,A=0;A max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1604150559(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1604150559(pixelArcLength).xyz);\n}"]),l=[{name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return i(t,a,o,null,l)},r.createPickShader=function(t){return i(t,a,s,null,l)}},{"gl-shader":288,glslify:392}],245:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl||t.scene&&t.scene.gl,r=u(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var o=f(e);o.attributes.position.location=0,o.attributes.nextPosition.location=1,o.attributes.arcLength.location=2,o.attributes.lineWidth.location=3,o.attributes.color.location=4;for(var s=n(e),c=i(e,[{buffer:s,size:3,offset:0,stride:48},{buffer:s,size:3,offset:12,stride:48},{buffer:s,size:1,offset:24,stride:48},{buffer:s,size:1,offset:28,stride:48},{buffer:s,size:4,offset:32,stride:48}]),h=l(new Array(1024),[256,1,4]),p=0;p<1024;++p)h.data[p]=255;var d=a(e,h);d.wrap=e.REPEAT;var g=new v(e,r,o,s,c,d);return g.update(t),g};var n=t("gl-buffer"),i=t("gl-vao"),a=t("gl-texture2d"),o=t("glsl-read-float"),s=t("binary-search-bounds"),l=t("ndarray"),c=t("./lib/shaders"),u=c.createShader,f=c.createPickShader,h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function p(t,e){for(var r=0,n=0;n<3;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function d(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;r<3;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function g(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function v(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}var m=v.prototype;m.isTransparent=function(){return this.opacity<1},m.isOpaque=function(){return this.opacity>=1},m.pickSlots=1,m.setPickBase=function(t){this.pickId=t},m.drawTransparent=m.draw=function(t){if(this.vertexCount){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||h,view:t.view||h,projection:t.projection||h,clipBounds:d(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},m.drawPick=function(t){if(this.vertexCount){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||h,view:t.view||h,projection:t.projection||h,pickId:this.pickId,clipBounds:d(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},m.update=function(t){var e,r;this.dirty=!0;var n=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var i=[],a=[],o=[],c=0,u=0,f=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],h=t.position||t.positions;if(h){var d=t.color||t.colors||[0,0,0,1],g=t.lineWidth||1,v=!1;t:for(e=1;e0){for(var w=0;w<24;++w)i.push(i[i.length-12]);u+=2,v=!0}continue t}f[0][r]=Math.min(f[0][r],b[r],_[r]),f[1][r]=Math.max(f[1][r],b[r],_[r])}Array.isArray(d[0])?(m=d.length>e-1?d[e-1]:d.length>0?d[d.length-1]:[0,0,0,1],y=d.length>e?d[e]:d.length>0?d[d.length-1]:[0,0,0,1]):m=y=d,3===m.length&&(m=[m[0],m[1],m[2],1]),3===y.length&&(y=[y[0],y[1],y[2],1]),x=Array.isArray(g)?g.length>e-1?g[e-1]:g.length>0?g[g.length-1]:[0,0,0,1]:g;var k=c;if(c+=p(b,_),v){for(r=0;r<2;++r)i.push(b[0],b[1],b[2],_[0],_[1],_[2],k,x,m[0],m[1],m[2],m[3]);u+=2,v=!1}i.push(b[0],b[1],b[2],_[0],_[1],_[2],k,x,m[0],m[1],m[2],m[3],b[0],b[1],b[2],_[0],_[1],_[2],k,-x,m[0],m[1],m[2],m[3],_[0],_[1],_[2],b[0],b[1],b[2],c,-x,y[0],y[1],y[2],y[3],_[0],_[1],_[2],b[0],b[1],b[2],c,x,y[0],y[1],y[2],y[3]),u+=4}}if(this.buffer.update(i),a.push(c),o.push(h[h.length-1].slice()),this.bounds=f,this.vertexCount=u,this.points=o,this.arcLength=a,"dashes"in t){var M=t.dashes.slice();for(M.unshift(0),e=1;e max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n vec3 normal = normals(f_data);\n\n if (dot(N, normal) < 0.0) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),l=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]),c=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),u=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]),f=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]),h=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]),p=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]),d=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:l,fragment:c,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:u,fragment:f,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:h,fragment:f,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:p,fragment:d,attributes:[{name:"position",type:"vec3"}]}},{glslify:392}],268:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("normals"),l=t("gl-mat4/multiply"),c=t("gl-mat4/invert"),u=t("ndarray"),f=t("colormap"),h=t("simplicial-complex-contour"),p=t("typedarray-pool"),d=t("./lib/shaders"),g=t("./lib/closest-point"),v=d.meshShader,m=d.wireShader,y=d.pointShader,x=d.pickShader,b=d.pointPickShader,_=d.contourShader,w=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function k(t,e,r,n,i,a,o,s,l,c,u,f,h,p,d,g,v,m,y,x,b,_,k,M,A,T,S){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=c,this.triangleVAO=p,this.triangleCount=0,this.lineWidth=1,this.edgePositions=d,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=x,this.pointColors=_,this.pointUVs=k,this.pointSizes=M,this.pointIds=b,this.pointVAO=A,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=T,this.contourVAO=S,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=w,this._view=w,this._projection=w,this._resolution=[1,1]}var M=k.prototype;function A(t){var e=n(t,y.vertex,y.fragment);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function T(t){var e=n(t,x.vertex,x.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e}function S(t){var e=n(t,b.vertex,b.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function C(t){var e=n(t,_.vertex,_.fragment);return e.attributes.position.location=0,e}M.isOpaque=function(){return this.opacity>=1},M.isTransparent=function(){return this.opacity<1},M.pickSlots=1,M.setPickBase=function(t){this.pickId=t},M.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=p.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},M.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||w,n=t.view||w,i=t.projection||w,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},M.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;ai[M]&&(r.uniforms.dataAxis=c,r.uniforms.screenOffset=u,r.uniforms.color=v[t],r.uniforms.angle=m[t],a.drawArrays(a.TRIANGLES,i[M],i[A]-i[M]))),y[t]&&k&&(u[1^t]-=T*p*x[t],r.uniforms.dataAxis=f,r.uniforms.screenOffset=u,r.uniforms.color=b[t],r.uniforms.angle=_[t],a.drawArrays(a.TRIANGLES,w,k)),u[1^t]=T*s[2+(1^t)]-1,d[t+2]&&(u[1^t]+=T*p*g[t+2],Mi[M]&&(r.uniforms.dataAxis=c,r.uniforms.screenOffset=u,r.uniforms.color=v[t+2],r.uniforms.angle=m[t+2],a.drawArrays(a.TRIANGLES,i[M],i[A]-i[M]))),y[t+2]&&k&&(u[1^t]+=T*p*x[t+2],r.uniforms.dataAxis=f,r.uniforms.screenOffset=u,r.uniforms.color=b[t+2],r.uniforms.angle=_[t+2],a.drawArrays(a.TRIANGLES,w,k))}),g.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,c=r.pixelRatio;if(this.titleCount){for(var u=0;u<2;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),g.bind=(h=[0,0],p=[0,0],d=[0,0],function(){var t=this.plot,e=this.shader,r=t._tickBounds,n=t.dataBox,i=t.screenBox,a=t.viewBox;e.bind();for(var o=0;o<2;++o){var s=r[o],l=r[o+2]-s,c=.5*(n[o+2]+n[o]),u=n[o+2]-n[o],f=a[o],g=a[o+2]-f,v=i[o],m=i[o+2]-v;p[o]=2*l/u*g/m,h[o]=2*(s-c)/u*g/m}d[1]=2*t.pixelRatio/(i[3]-i[1]),d[0]=d[1]*(i[3]-i[1])/(i[2]-i[0]),e.uniforms.dataScale=p,e.uniforms.dataShift=h,e.uniforms.textScale=d,this.vbo.bind(),e.attributes.textCoordinate.pointer()}),g.update=function(t){var e,r,n,i,o,s=[],l=t.ticks,c=t.bounds;for(o=0;o<2;++o){var u=[Math.floor(s.length/3)],f=[-1/0],h=l[o];for(e=0;e=0){var g=e[d]-n[d]*(e[d+2]-e[d])/(n[d+2]-n[d]);0===d?o.drawLine(g,e[1],g,e[3],p[d],h[d]):o.drawLine(e[0],g,e[2],g,p[d],h[d])}}for(d=0;d=0;--t)this.objects[t].dispose();this.objects.length=0;for(t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},c.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},c.removeObject=function(t){for(var e=this.objects,r=0;r0&&0===L[e-1];)L.pop(),z.pop().dispose()}window.addEventListener("resize",j),B.update=function(t){e||(t=t||{},O=!0,I=!0)},B.add=function(t){e||(t.axes=A,C.push(t),E.push(-1),O=!0,I=!0,V())},B.remove=function(t){if(!e){var r=C.indexOf(t);r<0||(C.splice(r,1),E.pop(),O=!0,I=!0,V())}},B.dispose=function(){if(!e&&(e=!0,window.removeEventListener("resize",j),r.removeEventListener("webglcontextlost",H),B.mouseListener.enabled=!1,!B.contextLost)){A.dispose(),S.dispose();for(var t=0;tb.distance)continue;for(var u=0;u0){r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function v(t){return"boolean"!=typeof t||t}},{"./lib/shader":276,"3d-view-controls":44,"a-big-triangle":47,"gl-axes3d":222,"gl-axes3d/properties":229,"gl-fbo":239,"gl-mat4/perspective":257,"gl-select-static":287,"gl-spikes3d":297,"is-mobile":403,"mouse-change":418}],278:[function(t,e,r){var n=t("glslify");r.pointVertex=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform float pointCloud;\n\nhighp float rand(vec2 co) {\n highp float a = 12.9898;\n highp float b = 78.233;\n highp float c = 43758.5453;\n highp float d = dot(co.xy, vec2(a, b));\n highp float e = mod(d, 3.14);\n return fract(sin(e) * c);\n}\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n // if we don't jitter the point size a bit, overall point cloud\n // saturation 'jumps' on zooming, which is disturbing and confusing\n gl_PointSize = pointSize * ((19.5 + rand(position)) / 20.0);\n if(pointCloud != 0.0) { // pointCloud is truthy\n // get the same square surface as circle would be\n gl_PointSize *= 0.886;\n }\n}"]),r.pointFragment=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color, borderColor;\nuniform float centerFraction;\nuniform float pointCloud;\n\nvoid main() {\n float radius;\n vec4 baseColor;\n if(pointCloud != 0.0) { // pointCloud is truthy\n if(centerFraction == 1.0) {\n gl_FragColor = color;\n } else {\n gl_FragColor = mix(borderColor, color, centerFraction);\n }\n } else {\n radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]),r.pickVertex=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]),r.pickFragment=n(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"])},{glslify:392}],279:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("typedarray-pool"),o=t("./lib/shader");function s(t,e,r,n,i){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.shader=n,this.pickShader=i,this.sizeMin=.5,this.sizeMinCap=2,this.sizeMax=20,this.areaRatio=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.blend=!1,this.pickOffset=0,this.points=null}e.exports=function(t,e){var r=t.gl,a=i(r),l=i(r),c=n(r,o.pointVertex,o.pointFragment),u=n(r,o.pickVertex,o.pickFragment),f=new s(t,a,l,c,u);return f.update(e),t.addObject(f),f};var l,c,u=s.prototype;u.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.plot.removeObject(this)},u.update=function(t){var e;function r(e,r){return e in t?t[e]:r}t=t||{},this.sizeMin=r("sizeMin",.5),this.sizeMax=r("sizeMax",20),this.color=r("color",[1,0,0,1]).slice(),this.areaRatio=r("areaRatio",1),this.borderColor=r("borderColor",[0,0,0,1]).slice(),this.blend=r("blend",!1);var n=t.positions.length>>>1,i=t.positions instanceof Float32Array,o=t.idToIndex instanceof Int32Array&&t.idToIndex.length>=n,s=t.positions,l=i?s:a.mallocFloat32(s.length),c=o?t.idToIndex:a.mallocInt32(n);if(i||l.set(s),!o)for(l.set(s),e=0;e>>1;for(r=0;r=e[0]&&a<=e[2]&&o>=e[1]&&o<=e[3]&&n++}return n}(this.points,i),u=this.plot.pickPixelRatio*Math.max(Math.min(this.sizeMinCap,this.sizeMin),Math.min(this.sizeMax,this.sizeMax/Math.pow(s,.33333)));l[0]=2/a,l[4]=2/o,l[6]=-2*i[0]/a-1,l[7]=-2*i[1]/o-1,this.offsetBuffer.bind(),r.bind(),r.attributes.position.pointer(),r.uniforms.matrix=l,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointCloud=u<5,r.uniforms.pointSize=u,r.uniforms.centerFraction=Math.min(1,Math.max(0,Math.sqrt(1-this.areaRatio))),e&&(c[0]=255&t,c[1]=t>>8&255,c[2]=t>>16&255,c[3]=t>>24&255,this.pickBuffer.bind(),r.attributes.pickId.pointer(n.UNSIGNED_BYTE),r.uniforms.pickOffset=c,this.pickOffset=t);var f=n.getParameter(n.BLEND),h=n.getParameter(n.DITHER);return f&&!this.blend&&n.disable(n.BLEND),h&&n.disable(n.DITHER),n.drawArrays(n.POINTS,0,this.pointCount),f&&!this.blend&&n.enable(n.BLEND),h&&n.enable(n.DITHER),t+this.pointCount}),u.draw=u.unifiedDraw,u.drawPick=u.unifiedDraw,u.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(r=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":278,"gl-buffer":230,"gl-shader":288,"typedarray-pool":521}],280:[function(t,e,r){e.exports=function(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],f=e[2],h=e[3],p=r[0],d=r[1],g=r[2],v=r[3];(a=c*p+u*d+f*g+h*v)<0&&(a=-a,p=-p,d=-d,g=-g,v=-v);1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n);return t[0]=s*c+l*p,t[1]=s*u+l*d,t[2]=s*f+l*g,t[3]=s*h+l*v,t}},{}],281:[function(t,e,r){"use strict";e.exports=function(t){return t||0===t?t.toString():""}},{}],282:[function(t,e,r){"use strict";var n=t("vectorize-text");e.exports=function(t,e){var r=i[e];r||(r=i[e]={});if(t in r)return r[t];var a={textAlign:"center",textBaseline:"middle",lineHeight:1,font:e,lineSpacing:1.25,styletags:{breaklines:!0,bolds:!0,italics:!0,subscripts:!0,superscripts:!0},triangles:!0},o=n(t,a);a.triangles=!1;for(var s=n(t,a),l=[[1/0,1/0],[-1/0,-1/0]],c=s.positions.length,u=0;u max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),o=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),s=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]),l=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = interpColor * opacity;\n}\n"]),c=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]),u=[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:u},h={vertex:o,fragment:l,attributes:u},p={vertex:s,fragment:l,attributes:u},d={vertex:a,fragment:c,attributes:u},g={vertex:o,fragment:c,attributes:u},v={vertex:s,fragment:c,attributes:u};function m(t,e){var r=n(t,e),i=r.attributes;return i.position.location=0,i.color.location=1,i.glyph.location=2,i.id.location=3,r}r.createPerspective=function(t){return m(t,f)},r.createOrtho=function(t){return m(t,h)},r.createProject=function(t){return m(t,p)},r.createPickPerspective=function(t){return m(t,d)},r.createPickOrtho=function(t){return m(t,g)},r.createPickProject=function(t){return m(t,v)}},{"gl-shader":288,glslify:392}],284:[function(t,e,r){"use strict";var n=t("is-string-blank"),i=t("gl-buffer"),a=t("gl-vao"),o=t("typedarray-pool"),s=t("gl-mat4/multiply"),l=t("./lib/shaders"),c=t("./lib/glyphs"),u=t("./lib/get-simple-string"),f=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function h(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function p(t,e,r,n){return h(n,n),h(n,n),h(n,n)}function d(t,e){this.index=t,this.dataCoordinate=this.position=e}e.exports=function(t){var e=t.gl,r=l.createPerspective(e),n=l.createOrtho(e),o=l.createProject(e),s=l.createPickPerspective(e),c=l.createPickOrtho(e),u=l.createPickProject(e),f=i(e),h=i(e),p=i(e),d=i(e),g=a(e,[{buffer:f,size:3,type:e.FLOAT},{buffer:h,size:4,type:e.FLOAT},{buffer:p,size:2,type:e.FLOAT},{buffer:d,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),v=new m(e,r,n,o,f,h,p,d,g,s,c,u);return v.update(t),v};var g=1;function v(t){return!0===t?g:t>g?g:t}function m(t,e,r,n,i,a,o,s,l,c,u,f){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=a,this.glyphBuffer=o,this.idBuffer=s,this.vao=l,this.vertexCount=0,this.lineVertexCount=0,this.opacity=g,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[g,g,g],this.pickId=0,this.pickPerspectiveShader=c,this.pickOrthoShader=u,this.pickProjectShader=f,this.points=[],this._selectResult=new d(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.dirty=!0}var y=m.prototype;y.pickSlots=1,y.setPickBase=function(t){this.pickId=t},y.isTransparent=function(){if(this.opacity=g)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=g)return!0;return!1};var x=[0,0],b=[0,0,0],_=[0,0,0],w=[0,0,0,1],k=[0,0,0,1],M=f.slice(),A=[0,0,0],T=[[0,0,0],[0,0,0]];function S(t){return t[0]=t[1]=t[2]=0,t}function C(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function E(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function L(t,e,r){var n,i=e.axesProject,a=e.gl,o=t.uniforms,l=r.model||f,c=r.view||f,u=r.projection||f,h=e.axesBounds,d=function(t){for(var e=T,r=0;r<2;++r)for(var n=0;n<3;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}(e.clipBounds);n=e.axes&&e.axes.lastCubeProps?e.axes.lastCubeProps.axis:[1,1,1],x[0]=2/a.drawingBufferWidth,x[1]=2/a.drawingBufferHeight,t.bind(),o.view=c,o.projection=u,o.screenSize=x,o.highlightId=e.highlightId,o.highlightScale=e.highlightScale,o.clipBounds=d,o.pickGroup=e.pickId/255,o.pixelRatio=e.pixelRatio;for(var g=0;g<3;++g)if(i[g]){o.scale=e.projectScale[g],o.opacity=e.projectOpacity[g];for(var v=M,m=0;m<16;++m)v[m]=0;for(m=0;m<4;++m)v[5*m]=1;v[5*g]=0,n[g]<0?v[12+g]=h[0][g]:v[12+g]=h[1][g],s(v,l,v),o.model=v;var y=(g+1)%3,L=(g+2)%3,z=S(b),O=S(_);z[y]=1,O[L]=1;var I=p(0,0,0,C(w,z)),P=p(0,0,0,C(k,O));if(Math.abs(I[1])>Math.abs(P[1])){var D=I;I=P,P=D,D=z,z=O,O=D;var R=y;y=L,L=R}I[0]<0&&(z[y]=-1),P[1]>0&&(O[L]=-1);var F=0,B=0;for(m=0;m<4;++m)F+=Math.pow(l[4*y+m],2),B+=Math.pow(l[4*L+m],2);z[y]/=Math.sqrt(F),O[L]/=Math.sqrt(B),o.axes[0]=z,o.axes[1]=O,o.fragClipBounds[0]=E(A,d[0],g,-1e8),o.fragClipBounds[1]=E(A,d[1],g,1e8),e.vao.bind(),e.vao.draw(a.TRIANGLES,e.vertexCount),e.lineWidth>0&&(a.lineWidth(e.lineWidth),e.vao.draw(a.LINES,e.lineVertexCount,e.vertexCount)),e.vao.unbind()}}var z=[[-1e8,-1e8,-1e8],[1e8,1e8,1e8]];function O(t,e,r,n,i,a){var o=r.gl;if((i===r.projectOpacity0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount)),r.vao.unbind()}}function I(t,e,r){var i;i=Array.isArray(t)?e=this.pointCount||e<0)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;i<3;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},y.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},y.update=function(t){if("perspective"in(t=t||{})&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t){if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{r=+t.projectOpacity;this.projectOpacity=[r,r,r]}for(var n=0;n<3;++n)this.projectOpacity[n]=v(this.projectOpacity[n])}"opacity"in t&&(this.opacity=v(t.opacity)),this.dirty=!0;var i,a,s=t.position,l=t.font||"normal",c=t.alignment||[0,0];if(2===c.length)i=c[0],a=c[1];else{i=[],a=[];for(n=0;n0){var O=0,P=x,D=[0,0,0,1],R=[0,0,0,1],F=Array.isArray(p)&&Array.isArray(p[0]),B=Array.isArray(m)&&Array.isArray(m[0]);t:for(n=0;n<_;++n){y+=1;for(w=s[n],k=0;k<3;++k){if(isNaN(w[k])||!isFinite(w[k]))continue t;f[k]=Math.max(f[k],w[k]),u[k]=Math.min(u[k],w[k])}M=(N=I(h,n,l)).mesh,A=N.lines,T=N.bounds;var N,j=N.visible;if(j)if(Array.isArray(p)){if(3===(V=F?n0?1-T[0][0]:W<0?1+T[1][0]:1,Y*=Y>0?1-T[0][1]:Y<0?1+T[1][1]:1],Z=M.cells||[],$=M.positions||[];for(k=0;k0){var m=r*u;o.drawBox(f-m,h-m,p+m,h+m,a),o.drawBox(f-m,d-m,p+m,d+m,a),o.drawBox(f-m,h-m,f+m,d+m,a),o.drawBox(p-m,h-m,p+m,d+m,a)}}}},s.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},s.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":285,"gl-buffer":230,"gl-shader":288}],287:[function(t,e,r){"use strict";e.exports=function(t,e){var r=n(t,e),a=i.mallocUint8(e[0]*e[1]*4);return new c(t,r,a)};var n=t("gl-fbo"),i=t("typedarray-pool"),a=t("ndarray"),o=t("bit-twiddle").nextPow2,s=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(_inline_16_arg0_<255||_inline_16_arg1_<255||_inline_16_arg2_<255||_inline_16_arg3_<255){var _inline_16_l=_inline_16_arg4_-_inline_16_arg6_[0],_inline_16_a=_inline_16_arg5_-_inline_16_arg6_[1],_inline_16_f=_inline_16_l*_inline_16_l+_inline_16_a*_inline_16_a;_inline_16_fthis.buffer.length){i.free(this.buffer);for(var n=this.buffer=i.mallocUint8(o(r*e*4)),a=0;ar)for(t=r;te)for(t=e;t=0){for(var k=0|w.type.charAt(w.type.length-1),M=new Array(k),A=0;A=0;)T+=1;_[y]=T}var S=new Array(r.length);function C(){h.program=o.program(p,h._vref,h._fref,b,_);for(var t=0;t=0){var d=h.charCodeAt(h.length-1)-48;if(d<2||d>4)throw new n("","Invalid data type for attribute "+f+": "+h);o(t,e,p[0],i,d,a,f)}else{if(!(h.indexOf("mat")>=0))throw new n("","Unknown data type for attribute "+f+": "+h);var d=h.charCodeAt(h.length-1)-48;if(d<2||d>4)throw new n("","Invalid data type for attribute "+f+": "+h);s(t,e,p,i,d,a,f)}}}return a};var n=t("./GLError");function i(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}var a=i.prototype;function o(t,e,r,n,a,o,s){for(var l=["gl","v"],c=[],u=0;u4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+a+"fv(locations["+e+"],false,obj"+t+")"}throw new i("","Unknown uniform data type for "+name+": "+r)}var a=r.charCodeAt(r.length-1)-48;if(a<2||a>4)throw new i("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+a+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+a+"fv(locations["+e+"],obj"+t+")";default:throw new i("","Unrecognized data type for vector "+name+": "+r)}}}function c(e){for(var n=["return function updateProperty(obj){"],i=function t(e,r){if("object"!=typeof r)return[[e,r]];var n=[];for(var i in r){var a=r[i],o=e;parseInt(i)+""===i?o+="["+i+"]":o+="."+i,"object"==typeof a?n.push.apply(n,t(o,a)):n.push([o,a])}return n}("",e),a=0;a4)throw new i("","Invalid data type");return"b"===t.charAt(0)?o(r,!1):o(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(r<2||r>4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+t);return o(r*r,0)}throw new i("","Unknown uniform data type for "+name+": "+t)}}(r[u].type);var p}function f(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var c=1;c1)for(var l=0;l 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\nuniform float tubeScale;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n normal = normalize(normal * inverse(mat3(model)));\n\n gl_Position = projection * view * tubePosition;\n f_color = color;\n f_normal = normal;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_eyeDirection = eyePosition - tubePosition.xyz;\n f_lightDirection = lightPosition - tubePosition.xyz;\n f_uv = uv;\n}\n"]),a=n(["precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data\n , f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec4"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec4"}]}},{glslify:392}],300:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("normals"),l=t("gl-mat4/multiply"),c=t("gl-mat4/invert"),u=t("ndarray"),f=t("colormap"),h=t("simplicial-complex-contour"),p=t("typedarray-pool"),d=t("./shaders"),g=(t("./closest-point"),d.meshShader),v=d.pickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function y(t,e,r,n,i,a,o,s,l,c,u,f,h,p,d,g,v,y,x,b,_,w,k,M,A,T,S,C){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleVectors=c,this.triangleColors=f,this.triangleNormals=p,this.triangleUVs=h,this.triangleIds=u,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=g,this.edgeColors=y,this.edgeUVs=x,this.edgeIds=v,this.edgeVAO=b,this.edgeCount=0,this.pointPositions=_,this.pointColors=k,this.pointUVs=M,this.pointSizes=A,this.pointIds=w,this.pointVAO=T,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=S,this.contourVAO=C,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!1,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this.tubeScale=1,this._model=m,this._view=m,this._projection=m,this._resolution=[1,1]}var x=y.prototype;function b(t){var e=n(t,v.vertex,v.fragment,null,v.attributes);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.vector.location=5,e}x.isOpaque=function(){return this.opacity>=1},x.isTransparent=function(){return this.opacity<1},x.pickSlots=1,x.setPickBase=function(t){this.pickId=t},x.highlight=function(t){if(t&&this.contourEnable){for(var e=h(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=p.mallocFloat32(6*a),s=0,l=0;l0&&((f=this.triShader).bind(),f.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind());this.edgeCount>0&&this.lineWidth>0&&((f=this.lineShader).bind(),f.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind());this.pointCount>0&&((f=this.pointShader).bind(),f.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind());this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((f=this.contourShader).bind(),f.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},x.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||m,n=t.view||m,i=t.projection||m,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,tubeScale:this.tubeScale,pickId:this.pickId/255};((s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0)&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},x.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions[r[1]].slice(0,3);return{index:e,position:n,intensity:this.intensity[r[1]],velocity:this.vectors[r[1]].slice(0,3),divergence:this.vectors[r[1]][3],dataCoordinate:n}},x.dispose=function(){this.texture.dispose(),this.triShader.dispose(),this.pickShader.dispose(),this.triangleVAO.dispose(),this.trianglePositions.dispose(),this.triangleVectors.dispose(),this.triangleColors.dispose(),this.triangleUVs.dispose(),this.triangleNormals.dispose(),this.triangleIds.dispose(),this.edgeVAO.dispose(),this.edgePositions.dispose(),this.edgeColors.dispose(),this.edgeUVs.dispose(),this.edgeIds.dispose(),this.pointVAO.dispose(),this.pointPositions.dispose(),this.pointColors.dispose(),this.pointUVs.dispose(),this.pointSizes.dispose(),this.pointIds.dispose(),this.contourVAO.dispose(),this.contourPositions.dispose()},e.exports=function(t,e){1===arguments.length&&(t=(e=t).gl);var r=e.triShader||function(t){var e=n(t,g.vertex,g.fragment,null,g.attributes);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.vector.location=5,e}(t),s=b(t),l=o(t,u(new Uint8Array([255,255,255,255]),[1,1,4]));l.generateMipmap(),l.minFilter=t.LINEAR_MIPMAP_LINEAR,l.magFilter=t.LINEAR;var c=i(t),f=i(t),h=i(t),p=i(t),d=i(t),v=i(t),m=a(t,[{buffer:c,type:t.FLOAT,size:4},{buffer:v,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:h,type:t.FLOAT,size:4},{buffer:p,type:t.FLOAT,size:2},{buffer:d,type:t.FLOAT,size:3},{buffer:f,type:t.FLOAT,size:4}]),x=i(t),_=i(t),w=i(t),k=i(t),M=a(t,[{buffer:x,type:t.FLOAT,size:3},{buffer:k,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:_,type:t.FLOAT,size:4},{buffer:w,type:t.FLOAT,size:2}]),A=i(t),T=i(t),S=i(t),C=i(t),E=i(t),L=a(t,[{buffer:A,type:t.FLOAT,size:3},{buffer:E,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:T,type:t.FLOAT,size:4},{buffer:S,type:t.FLOAT,size:2},{buffer:C,type:t.FLOAT,size:1}]),z=i(t),O=new y(t,l,r,null,null,s,null,null,c,f,v,h,p,d,m,x,k,_,w,M,A,E,T,S,C,L,z,a(t,[{buffer:z,type:t.FLOAT,size:3}]));return O.update(e),O}},{"./closest-point":298,"./shaders":299,colormap:114,"gl-buffer":230,"gl-mat4/invert":254,"gl-mat4/multiply":256,"gl-shader":288,"gl-texture2d":305,"gl-vao":310,ndarray:433,normals:436,"simplicial-complex-contour":494,"typedarray-pool":521}],301:[function(t,e,r){"use strict";var n=t("gl-vec3"),i=t("gl-vec4"),a=function(t,e,r,a){for(var o=0,s=0;so&&(o=u)}var f=t.map(function(t){return function(t,e,r,a){var o,s,l,c=t.points,u=t.velocities,f=t.divergences;n.set(n.create(),0,1,0),n.create(),n.create();n.create();for(var h=[],p=[],d=[],g=[],v=[],m=[],y=0,x=0,b=i.create(),_=i.create(),w=0;w0)for(k=0;k<8;k++){var M=(k+1)%8;h.push(g[k],v[k],v[M],v[M],g[M],g[k]),d.push(_,b,b,b,_,_),m.push(y,x,x,x,y,y),p.push([h.length-6,h.length-5,h.length-4],[h.length-3,h.length-2,h.length-1])}var A=g;g=v,v=A,A=_,_=b,b=A,A=y,y=x,x=A}return{positions:h,cells:p,vectors:d,vertexIntensity:m}}(t,r,a,o)}),h=[],p=[],d=[],g=[];for(s=0;se)return r-1}return r},c=n.create(),u=n.create(),f=function(t,e,r){return tr?r:t},h=function(t,e,r,i){var a=t[0],o=t[1],s=t[2],h=r[0].length,p=r[1].length,d=r[2].length,g=l(r[0],a),v=l(r[1],o),m=l(r[2],s),y=g+1,x=v+1,b=m+1;if(r[0][g]===a&&(y=g),r[1][v]===o&&(x=v),r[2][m]===s&&(b=m),i&&(g=f(g,0,h-1),y=f(y,0,h-1),v=f(v,0,p-1),x=f(x,0,p-1),m=f(m,0,d-1),b=f(b,0,d-1)),g<0||v<0||m<0||y>=h||x>=p||b>=d)return n.create();var _=(a-r[0][g])/(r[0][y]-r[0][g]),w=(o-r[1][v])/(r[1][x]-r[1][v]),k=(s-r[2][m])/(r[2][b]-r[2][m]);(_<0||_>1||isNaN(_))&&(_=0),(w<0||w>1||isNaN(w))&&(w=0),(k<0||k>1||isNaN(k))&&(k=0);var M=m*h*p,A=b*h*p,T=v*h,S=x*h,C=g,E=y,L=e[T+M+C],z=e[T+M+E],O=e[S+M+C],I=e[S+M+E],P=e[T+A+C],D=e[T+A+E],R=e[S+A+C],F=e[S+A+E],B=n.create();return n.lerp(B,L,z,_),n.lerp(c,O,I,_),n.lerp(B,B,c,w),n.lerp(c,P,D,_),n.lerp(u,R,F,_),n.lerp(c,c,u,w),n.lerp(B,B,c,k),B},p=function(t){var e=1/0;t.sort(function(t,e){return t-e});for(var r=1;r=f&&r<=g&&n>=h&&n<=v&&i>=d&&i<=m},x=10*n.distance(e[0],e[1])/i,b=x*x,_=1,w=0;n.create();r.length>=2&&(_=function(t){for(var e=[],r=[],n=[],i={},a={},o={},s=0;sw&&!isNaN(P)&&isFinite(P)&&(w=P),E.push(P),u.push({points:A,velocities:T,divergences:E});for(var z=0;z<100*i&&A.lengthb&&n.scale(O,O,x/Math.sqrt(I)),n.add(O,O,M),S=t.getVelocity(O),n.squaredDistance(C,O)-b>-1e-4*b){A.push(O),C=O,T.push(S);L=t.getDivergence(O,S);(P=n.length(L))>w&&!isNaN(P)&&isFinite(P)&&(w=P),E.push(P)}M=O}}for(k=0;k max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color \u2014 in vertex or in fragment\n vec4 surfaceColor =\n step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) +\n step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]),s=i(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform vec3 objectOffset;\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n worldCoordinate = objectOffset + dataCoordinate;\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z += zOffset;\n\n gl_Position = clipPosition;\n value = f + objectOffset.z;\n kill = -1.0;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]),l=i(["precision mediump float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]);r.createShader=function(t){var e=n(t,a,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,a,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,s,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,s,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":288,glslify:392}],303:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=y(e),n=b(e),s=x(e),l=_(e),c=i(e),u=a(e,[{buffer:c,size:4,stride:w,offset:0},{buffer:c,size:3,stride:w,offset:16},{buffer:c,size:3,stride:w,offset:28}]),f=i(e),h=a(e,[{buffer:f,size:4,stride:20,offset:0},{buffer:f,size:1,stride:20,offset:16}]),p=i(e),d=a(e,[{buffer:p,size:2,type:e.FLOAT}]),g=o(e,1,S,e.RGBA,e.UNSIGNED_BYTE);g.minFilter=e.LINEAR,g.magFilter=e.LINEAR;var v=new C(e,[0,0],[[0,0,0],[0,0,0]],r,n,c,u,g,s,l,f,h,p,d,[0,0,0]),m={levels:[[],[],[]]};for(var k in t)m[k]=t[k];return m.colormap=m.colormap||"jet",v.update(m),v};var n=t("bit-twiddle"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("typedarray-pool"),l=t("colormap"),c=t("ndarray-ops"),u=t("ndarray-pack"),f=t("ndarray"),h=t("surface-nets"),p=t("gl-mat4/multiply"),d=t("gl-mat4/invert"),g=t("binary-search-bounds"),v=t("ndarray-gradient"),m=t("./lib/shaders"),y=m.createShader,x=m.createContourShader,b=m.createPickShader,_=m.createPickContourShader,w=40,k=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],M=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],A=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];function T(t,e,r,n,i){this.position=t,this.index=e,this.uv=r,this.level=n,this.dataCoordinate=i}!function(){for(var t=0;t<3;++t){var e=A[t],r=(t+2)%3;e[(t+1)%3+0]=1,e[r+3]=1,e[t+6]=1}}();var S=256;function C(t,e,r,n,i,a,o,l,c,u,h,p,d,g,v){this.gl=t,this.shape=e,this.bounds=r,this.objectOffset=v,this.intensityBounds=[],this._shader=n,this._pickShader=i,this._coordinateBuffer=a,this._vao=o,this._colorMap=l,this._contourShader=c,this._contourPickShader=u,this._contourBuffer=h,this._contourVAO=p,this._contourOffsets=[[],[],[]],this._contourCounts=[[],[],[]],this._vertexCount=0,this._pickResult=new T([0,0,0],[0,0],[0,0],[0,0,0],[0,0,0]),this._dynamicBuffer=d,this._dynamicVAO=g,this._dynamicOffsets=[0,0,0],this._dynamicCounts=[0,0,0],this.contourWidth=[1,1,1],this.contourLevels=[[1],[1],[1]],this.contourTint=[0,0,0],this.contourColor=[[.5,.5,.5,1],[.5,.5,.5,1],[.5,.5,.5,1]],this.showContour=!0,this.showSurface=!0,this.enableHighlight=[!0,!0,!0],this.highlightColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.highlightTint=[1,1,1],this.highlightLevel=[-1,-1,-1],this.enableDynamic=[!0,!0,!0],this.dynamicLevel=[NaN,NaN,NaN],this.dynamicColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.dynamicTint=[1,1,1],this.dynamicWidth=[1,1,1],this.axesBounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.surfaceProject=[!1,!1,!1],this.contourProject=[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],this.colorBounds=[!1,!1],this._field=[f(s.mallocFloat(1024),[0,0]),f(s.mallocFloat(1024),[0,0]),f(s.mallocFloat(1024),[0,0])],this.pickId=1,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.snapToData=!1,this.opacity=1,this.lightPosition=[10,1e4,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.vertexColor=0,this.dirty=!0}var E=C.prototype;E.isTransparent=function(){return this.opacity<1},E.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;t<3;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},E.pickSlots=1,E.setPickBase=function(t){this.pickId=t};var L=[0,0,0],z={showSurface:!1,showContour:!1,projections:[k.slice(),k.slice(),k.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]};function O(t,e){var r,n,i,a=e.axes&&e.axes.lastCubeProps.axis||L,o=e.showSurface,s=e.showContour;for(r=0;r<3;++r)for(o=o||e.surfaceProject[r],n=0;n<3;++n)s=s||e.contourProject[r][n];for(r=0;r<3;++r){var l=z.projections[r];for(n=0;n<16;++n)l[n]=0;for(n=0;n<4;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],p(l,t.model,l);var c=z.clipBounds[r];for(i=0;i<2;++i)for(n=0;n<3;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return z.showSurface=o,z.showContour=s,z}var I={model:k,view:k,projection:k,inverseModel:k.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,objectOffset:[0,0,0],kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1,vertexColor:0},P=k.slice(),D=[1,0,0,0,1,0,0,0,1];function R(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=I;n.model=t.model||k,n.view=t.view||k,n.projection=t.projection||k,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.objectOffset=this.objectOffset,n.contourColor=this.contourColor[0],n.inverseModel=d(n.inverseModel,n.model);for(var i=0;i<2;++i)for(var a=n.clipBounds[i],o=0;o<3;++o)a[o]=Math.min(Math.max(this.clipBounds[i][o],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=D,n.vertexColor=this.vertexColor;var s=P;for(p(s,n.view,n.model),p(s,n.projection,s),d(s,s),i=0;i<3;++i)n.eyePosition[i]=s[12+i]/s[15];var l=s[15];for(i=0;i<3;++i)l+=this.lightPosition[i]*s[4*i+3];for(i=0;i<3;++i){var c=s[12+i];for(o=0;o<3;++o)c+=s[4*o+i]*this.lightPosition[o];n.lightPosition[i]=c/l}var u=O(n,this);if(u.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;i<3;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=u.projections[i],this._shader.uniforms.clipBounds=u.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(u.showContour&&!e){var f=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,f.bind(),f.uniforms=n;var h=this._contourVAO;for(h.bind(),i=0;i<3;++i)for(f.uniforms.permutation=A[i],r.lineWidth(this.contourWidth[i]),o=0;o>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;u<2;++u)for(var f=u?a:1-a,h=0;h<2;++h)for(var p=i+u,d=s+h,v=f*(h?l:1-l),m=0;m<3;++m)c[m]+=this._field[m].get(p,d)*v;for(var y=this._pickResult.level,x=0;x<3;++x)if(y[x]=g.le(this.contourLevels[x],c[x]),y[x]<0)this.contourLevels[x].length>0&&(y[x]=0);else if(y[x]Math.abs(_-c[x])&&(y[x]+=1)}for(r.index[0]=a<.5?i:i+1,r.index[1]=l<.5?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;m<3;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},E.padField=function(t,e){var r=e.shape.slice(),n=t.shape.slice();c.assign(t.lo(1,1).hi(r[0],r[1]),e),c.assign(t.lo(1).hi(r[0],1),e.hi(r[0],1)),c.assign(t.lo(1,n[1]-1).hi(r[0],1),e.lo(0,r[1]-1).hi(r[0],1)),c.assign(t.lo(0,1).hi(1,r[1]),e.hi(1)),c.assign(t.lo(n[0]-1,1).hi(1,r[1]),e.lo(r[0]-1)),t.set(0,0,e.get(0,0)),t.set(0,n[1]-1,e.get(0,r[1]-1)),t.set(n[0]-1,0,e.get(r[0]-1,0)),t.set(n[0]-1,n[1]-1,e.get(r[0]-1,r[1]-1))},E.update=function(t){t=t||{},this.objectOffset=t.objectOffset||this.objectOffset,this.dirty=!0,"contourWidth"in t&&(this.contourWidth=B(t.contourWidth,Number)),"showContour"in t&&(this.showContour=B(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=B(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=j(t.contourColor)),"contourProject"in t&&(this.contourProject=B(t.contourProject,function(t){return B(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=j(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=B(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=B(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds),"vertexColor"in t&&(this.vertexColor=t.vertexColor?1:0);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var i=(e.shape[0]+2)*(e.shape[1]+2);i>this._field[2].data.length&&(s.freeFloat(this._field[2].data),this._field[2].data=s.mallocFloat(n.nextPow2(i))),this._field[2]=f(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),this.padField(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;o<2;++o)this._field[2].size>this._field[o].data.length&&(s.freeFloat(this._field[o].data),this._field[o].data=s.mallocFloat(this._field[2].size)),this._field[o]=f(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var p=t.coords;if(!Array.isArray(p)||3!==p.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;o<2;++o){var d=p[o];for(b=0;b<2;++b)if(d.shape[b]!==a[b])throw new Error("gl-surface: coords have incorrect shape");this.padField(this._field[o],d)}}else if(t.ticks){var g=t.ticks;if(!Array.isArray(g)||2!==g.length)throw new Error("gl-surface: invalid ticks");for(o=0;o<2;++o){var m=g[o];if((Array.isArray(m)||m.length)&&(m=f(m)),m.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var y=f(m.data,a);y.stride[o]=m.stride[0],y.stride[1^o]=0,this.padField(this._field[o],y)}}else{for(o=0;o<2;++o){var x=[0,0];x[o]=1,this._field[o]=f(this._field[o].data,[a[0]+2,a[1]+2],x,0)}this._field[0].set(0,0,0);for(var b=0;b0){for(var wt=0;wt<5;++wt)rt.pop();G-=1}continue t}rt.push(ot[0],ot[1],ct[0],ct[1],ot[2]),G+=1}}at.push(G)}this._contourOffsets[nt]=it,this._contourCounts[nt]=at}var kt=s.mallocFloat(rt.length);for(o=0;o halfCharStep + halfCharWidth ||\n\t\t\t\t\tfloor(uv.x) < halfCharStep - halfCharWidth) return;\n\n\t\t\t\tuv += charId * charStep;\n\t\t\t\tuv = uv / atlasSize;\n\n\t\t\t\tvec4 color = fontColor;\n\t\t\t\tvec4 mask = texture2D(atlas, uv);\n\n\t\t\t\tfloat maskY = lightness(mask);\n\t\t\t\t// float colorY = lightness(color);\n\t\t\t\tcolor.a *= maskY;\n\t\t\t\tcolor.a *= opacity;\n\n\t\t\t\t// color.a += .1;\n\n\t\t\t\t// antialiasing, see yiq color space y-channel formula\n\t\t\t\t// color.rgb += (1. - color.rgb) * (1. - mask.rgb);\n\n\t\t\t\tgl_FragColor = color;\n\t\t\t}"});return{regl:t,draw:e,atlas:{}}},k.prototype.update=function(t){var e=this;if("string"==typeof t)t={text:t};else if(!t)return;null!=(t=i(t,{position:"position positions coord coords coordinates",font:"font fontFace fontface typeface cssFont css-font family fontFamily",fontSize:"fontSize fontsize size font-size",text:"text texts chars characters value values symbols",align:"align alignment textAlign textbaseline",baseline:"baseline textBaseline textbaseline",direction:"dir direction textDirection",color:"color colour fill fill-color fillColor textColor textcolor",kerning:"kerning kern",range:"range dataBox",viewport:"vp viewport viewBox viewbox viewPort",opacity:"opacity alpha transparency visible visibility opaque",offset:"offset positionOffset padding shift indent indentation"},!0)).opacity&&(Array.isArray(t.opacity)?this.opacity=t.opacity.map(function(t){return parseFloat(t)}):this.opacity=parseFloat(t.opacity)),null!=t.viewport&&(this.viewport=f(t.viewport),k.normalViewport&&(this.viewport.y=this.canvas.height-this.viewport.y-this.viewport.height),this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null==this.viewport&&(this.viewport={x:0,y:0,width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight},this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null!=t.kerning&&(this.kerning=t.kerning),null!=t.offset&&("number"==typeof t.offset&&(t.offset=[t.offset,0]),this.positionOffset=y(t.offset)),t.direction&&(this.direction=t.direction),t.range&&(this.range=t.range,this.scale=[1/(t.range[2]-t.range[0]),1/(t.range[3]-t.range[1])],this.translate=[-t.range[0],-t.range[1]]),t.scale&&(this.scale=t.scale),t.translate&&(this.translate=t.translate),this.scale||(this.scale=[1/this.viewport.width,1/this.viewport.height]),this.translate||(this.translate=[0,0]),this.font.length||t.font||(t.font=k.baseFontSize+"px sans-serif");var r,a=!1,o=!1;if(t.font&&(Array.isArray(t.font)?t.font:[t.font]).forEach(function(t,r){if("string"==typeof t)try{t=n.parse(t)}catch(e){t=n.parse(k.baseFontSize+"px "+t)}else t=n.parse(n.stringify(t));var i=n.stringify({size:k.baseFontSize,family:t.family,stretch:_?t.stretch:void 0,variant:t.variant,weight:t.weight,style:t.style}),s=p(t.size),l=Math.round(s[0]*d(s[1]));if(l!==e.fontSize[r]&&(o=!0,e.fontSize[r]=l),!(e.font[r]&&i==e.font[r].baseString||(a=!0,e.font[r]=k.fonts[i],e.font[r]))){var c=t.family.join(", "),u=[t.style];t.style!=t.variant&&u.push(t.variant),t.variant!=t.weight&&u.push(t.weight),_&&t.weight!=t.stretch&&u.push(t.stretch),e.font[r]={baseString:i,family:c,weight:t.weight,stretch:t.stretch,style:t.style,variant:t.variant,width:{},kerning:{},metrics:m(c,{origin:"top",fontSize:k.baseFontSize,fontStyle:u.join(" ")})},k.fonts[i]=e.font[r]}}),(a||o)&&this.font.forEach(function(r,i){var a=n.stringify({size:e.fontSize[i],family:r.family,stretch:_?r.stretch:void 0,variant:r.variant,weight:r.weight,style:r.style});if(e.fontAtlas[i]=e.shader.atlas[a],!e.fontAtlas[i]){var o=r.metrics;e.shader.atlas[a]=e.fontAtlas[i]={fontString:a,step:2*Math.ceil(e.fontSize[i]*o.bottom*.5),em:e.fontSize[i],cols:0,rows:0,height:0,width:0,chars:[],ids:{},texture:e.regl.texture()}}null==t.text&&(t.text=e.text)}),"string"==typeof t.text&&t.position&&t.position.length>2){for(var s=Array(.5*t.position.length),h=0;h2){for(var w=!t.position[0].length,M=u.mallocFloat(2*this.count),A=0,T=0;A1?e.align[r]:e.align[0]:e.align;if("number"==typeof n)return n;switch(n){case"right":case"end":return-t;case"center":case"centre":case"middle":return.5*-t}return 0})),null==this.baseline&&null==t.baseline&&(t.baseline=0),null!=t.baseline&&(this.baseline=t.baseline,Array.isArray(this.baseline)||(this.baseline=[this.baseline]),this.baselineOffset=this.baseline.map(function(t,r){var n=(e.font[r]||e.font[0]).metrics,i=0;return i+=.5*n.bottom,i+="number"==typeof t?t-n.baseline:-n[t],k.normalViewport||(i*=-1),i})),null!=t.color)if(t.color||(t.color="transparent"),"string"!=typeof t.color&&isNaN(t.color)){var H;if("number"==typeof t.color[0]&&t.color.length>this.counts.length){var G=t.color.length;H=u.mallocUint8(G);for(var W=(t.color.subarray||t.color.slice).bind(t.color),Y=0;Y4||this.baselineOffset.length>1||this.align&&this.align.length>1||this.fontAtlas.length>1||this.positionOffset.length>2){var $=Math.max(.5*this.position.length||0,.25*this.color.length||0,this.baselineOffset.length||0,this.alignOffset.length||0,this.font.length||0,this.opacity.length||0,.5*this.positionOffset.length||0);this.batch=Array($);for(var J=0;J1?e.counts[J]:e.counts[0],offset:e.textOffsets.length>1?e.textOffsets[J]:e.textOffsets[0],color:e.color?e.color.length<=4?e.color:e.color.subarray(4*J,4*J+4):[0,0,0,255],opacity:Array.isArray(e.opacity)?e.opacity[J]:e.opacity,baseline:null!=e.baselineOffset[J]?e.baselineOffset[J]:e.baselineOffset[0],align:e.align?null!=e.alignOffset[J]?e.alignOffset[J]:e.alignOffset[0]:0,atlas:e.fontAtlas[J]||e.fontAtlas[0],positionOffset:e.positionOffset.length>2?e.positionOffset.subarray(2*J,2*J+2):e.positionOffset}}else this.count?this.batch=[{count:this.count,offset:0,color:this.color||[0,0,0,255],opacity:Array.isArray(this.opacity)?this.opacity[0]:this.opacity,baseline:this.baselineOffset[0],align:this.alignOffset?this.alignOffset[0]:0,atlas:this.fontAtlas[0],positionOffset:this.positionOffset}]:this.batch=[]},k.prototype.destroy=function(){},k.prototype.kerning=!0,k.prototype.position={constant:new Float32Array(2)},k.prototype.translate=null,k.prototype.scale=null,k.prototype.font=null,k.prototype.text="",k.prototype.positionOffset=[0,0],k.prototype.opacity=1,k.prototype.color=new Uint8Array([0,0,0,255]),k.prototype.alignOffset=[0,0],k.normalViewport=!1,k.maxAtlasSize=1024,k.atlasCanvas=document.createElement("canvas"),k.atlasContext=k.atlasCanvas.getContext("2d",{alpha:!1}),k.baseFontSize=64,k.fonts={},e.exports=k},{"bit-twiddle":80,"color-normalize":108,"css-font":127,"detect-kerning":151,"es6-weak-map":209,"flatten-vertex-data":216,"font-atlas":217,"font-measure":218,"gl-util/context":306,"is-plain-obj":405,"object-assign":437,"parse-rect":442,"parse-unit":444,"pick-by-alias":448,regl:478,"to-px":515,"typedarray-pool":521}],305:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("ndarray-ops"),a=t("typedarray-pool");e.exports=function(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");o||function(t){o=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],s=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],l=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}(t);if("number"==typeof arguments[1])return v(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return v(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1],r=c(e)?e:e.raw;if(r)return function(t,e,r,n,i,a){var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,i,i,a,e),new h(t,o,r,n,i,a)}(t,r,0|e.width,0|e.height,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return function(t,e){var r=e.dtype,o=e.shape.slice(),s=t.getParameter(t.MAX_TEXTURE_SIZE);if(o[0]<0||o[0]>s||o[1]<0||o[1]>s)throw new Error("gl-texture2d: Invalid texture size");var l=d(o,e.stride.slice()),c=0;"float32"===r?c=t.FLOAT:"float64"===r?(c=t.FLOAT,l=!1,r="float32"):"uint8"===r?c=t.UNSIGNED_BYTE:(c=t.UNSIGNED_BYTE,l=!1,r="uint8");var f,p,v=0;if(2===o.length)v=t.LUMINANCE,o=[o[0],o[1],1],e=n(e.data,o,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==o.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===o[2])v=t.ALPHA;else if(2===o[2])v=t.LUMINANCE_ALPHA;else if(3===o[2])v=t.RGB;else{if(4!==o[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}}c!==t.FLOAT||t.getExtension("OES_texture_float")||(c=t.UNSIGNED_BYTE,l=!1);var m=e.size;if(l)f=0===e.offset&&e.data.length===m?e.data:e.data.subarray(e.offset,e.offset+m);else{var y=[o[2],o[2]*o[0],1];p=a.malloc(m,r);var x=n(p,o,y,0);"float32"!==r&&"float64"!==r||c!==t.UNSIGNED_BYTE?i.assign(x,e):u(x,e),f=p.subarray(0,m)}var b=g(t);t.texImage2D(t.TEXTURE_2D,0,v,o[0],o[1],0,v,c,f),l||a.free(p);return new h(t,b,o[0],o[1],v,c)}(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")};var o=null,s=null,l=null;function c(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement||"undefined"!=typeof ImageData&&t instanceof ImageData}var u=function(t,e){i.muls(t,e,255)};function f(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(e<0||e>i||r<0||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function h(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}var p=h.prototype;function d(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function g(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function v(t,e,r,n,i){var a=t.getParameter(t.MAX_TEXTURE_SIZE);if(e<0||e>a||r<0||r>a)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new h(t,o,e,r,n,i)}Object.defineProperties(p,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=this.gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;e<2;++e)if(l.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return f(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return f(this,t|=0,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t|=0,f(this,this._shape[0],t),t}}}),p.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},p.dispose=function(){this.gl.deleteTexture(this.handle)},p.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},p.setPixels=function(t,e,r,o){var s=this.gl;this.bind(),Array.isArray(e)?(o=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),o=o||0;var l=c(t)?t:t.raw;if(l){this._mipLevels.indexOf(o)<0?(s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,this.type,l),this._mipLevels.push(o)):s.texSubImage2D(s.TEXTURE_2D,o,e,r,this.format,this.type,l)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>o||r+t.shape[0]>this._shape[0]>>>o||e<0||r<0)throw new Error("gl-texture2d: Texture dimensions are out of bounds");!function(t,e,r,o,s,l,c,f){var h=f.dtype,p=f.shape.slice();if(p.length<2||p.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var g=0,v=0,m=d(p,f.stride.slice());"float32"===h?g=t.FLOAT:"float64"===h?(g=t.FLOAT,m=!1,h="float32"):"uint8"===h?g=t.UNSIGNED_BYTE:(g=t.UNSIGNED_BYTE,m=!1,h="uint8");if(2===p.length)v=t.LUMINANCE,p=[p[0],p[1],1],f=n(f.data,p,[f.stride[0],f.stride[1],1],f.offset);else{if(3!==p.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===p[2])v=t.ALPHA;else if(2===p[2])v=t.LUMINANCE_ALPHA;else if(3===p[2])v=t.RGB;else{if(4!==p[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");v=t.RGBA}p[2]}v!==t.LUMINANCE&&v!==t.ALPHA||s!==t.LUMINANCE&&s!==t.ALPHA||(v=s);if(v!==s)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=f.size,x=c.indexOf(o)<0;x&&c.push(o);if(g===l&&m)0===f.offset&&f.data.length===y?x?t.texImage2D(t.TEXTURE_2D,o,s,p[0],p[1],0,s,l,f.data):t.texSubImage2D(t.TEXTURE_2D,o,e,r,p[0],p[1],s,l,f.data):x?t.texImage2D(t.TEXTURE_2D,o,s,p[0],p[1],0,s,l,f.data.subarray(f.offset,f.offset+y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,p[0],p[1],s,l,f.data.subarray(f.offset,f.offset+y));else{var b;b=l===t.FLOAT?a.mallocFloat32(y):a.mallocUint8(y);var _=n(b,p,[p[2],p[2]*p[0],1]);g===t.FLOAT&&l===t.UNSIGNED_BYTE?u(_,f):i.assign(_,f),x?t.texImage2D(t.TEXTURE_2D,o,s,p[0],p[1],0,s,l,b.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,p[0],p[1],s,l,b.subarray(0,y)),l===t.FLOAT?a.freeFloat32(b):a.freeUint8(b)}}(s,e,r,o,this.format,this.type,this._mipLevels,t)}}},{ndarray:433,"ndarray-ops":427,"typedarray-pool":521}],306:[function(t,e,r){"use strict";var n=t("pick-by-alias");function i(t){if(t.container)if(t.container==document.body)document.body.style.width||(t.canvas.width=t.width||t.pixelRatio*window.innerWidth),document.body.style.height||(t.canvas.height=t.height||t.pixelRatio*window.innerHeight);else{var e=t.container.getBoundingClientRect();t.canvas.width=t.width||e.right-e.left,t.canvas.height=t.height||e.bottom-e.top}}function a(t){return"function"==typeof t.getContext&&"width"in t&&"height"in t}e.exports=function(t){var e;if(t?"string"==typeof t&&(t={container:t}):t={},a(t)?t={container:t}:t="string"==typeof(e=t).nodeName&&"function"==typeof e.appendChild&&"function"==typeof e.getBoundingClientRect?{container:t}:function(t){return"function"==typeof t.drawArrays||"function"==typeof t.drawElements}(t)?{gl:t}:n(t,{container:"container target element el canvas holder parent parentNode wrapper use ref root node",gl:"gl context webgl glContext",attrs:"attributes attrs contextAttributes",pixelRatio:"pixelRatio pxRatio px ratio pxratio pixelratio"},!0),t.pixelRatio||(t.pixelRatio=window.pixelRatio||1),t.gl)return t.gl;if(t.canvas&&(t.container=t.canvas.parentNode),t.container){if("string"==typeof t.container){var r=document.querySelector(t.container);if(!r)throw Error("Element "+t.container+" is not found");t.container=r}a(t.container)?(t.canvas=t.container,t.container=t.canvas.parentNode):t.canvas||(t.canvas=document.createElement("canvas"),t.container.appendChild(t.canvas),i(t))}else t.canvas||(t.container=document.body||document.documentElement,t.canvas=document.createElement("canvas"),t.canvas.style.position="absolute",t.canvas.style.top=0,t.canvas.style.left=0,t.container.appendChild(t.canvas),i(t));if(!t.gl)try{t.gl=t.canvas.getContext("webgl",t.attrs)}catch(e){try{t.gl=t.canvas.getContext("experimental-webgl",t.attrs)}catch(e){t.gl=t.canvas.getContext("webgl-experimental",t.attrs)}}return t.gl}},{"pick-by-alias":448}],307:[function(t,e,r){"use strict";e.exports=function(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;i1?0:Math.acos(s)};var n=t("./fromValues"),i=t("./normalize"),a=t("./dot")},{"./dot":322,"./fromValues":328,"./normalize":339}],313:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}},{}],314:[function(t,e,r){e.exports=function(t){var e=new Float32Array(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}},{}],315:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}},{}],316:[function(t,e,r){e.exports=function(){var t=new Float32Array(3);return t[0]=0,t[1]=0,t[2]=0,t}},{}],317:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}},{}],318:[function(t,e,r){e.exports=t("./distance")},{"./distance":319}],319:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}},{}],320:[function(t,e,r){e.exports=t("./divide")},{"./divide":321}],321:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}},{}],322:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}},{}],323:[function(t,e,r){e.exports=1e-6},{}],324:[function(t,e,r){e.exports=function(t,e){var r=t[0],i=t[1],a=t[2],o=e[0],s=e[1],l=e[2];return Math.abs(r-o)<=n*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-l)<=n*Math.max(1,Math.abs(a),Math.abs(l))};var n=t("./epsilon")},{"./epsilon":323}],325:[function(t,e,r){e.exports=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}},{}],326:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}},{}],327:[function(t,e,r){e.exports=function(t,e,r,i,a,o){var s,l;e||(e=3);r||(r=0);l=i?Math.min(i*e+r,t.length):t.length;for(s=r;s0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a);return t}},{}],340:[function(t,e,r){e.exports=function(t,e){e=e||1;var r=2*Math.random()*Math.PI,n=2*Math.random()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t}},{}],341:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[1],a=r[2],o=e[1]-i,s=e[2]-a,l=Math.sin(n),c=Math.cos(n);return t[0]=e[0],t[1]=i+o*c-s*l,t[2]=a+o*l+s*c,t}},{}],342:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[2],o=e[0]-i,s=e[2]-a,l=Math.sin(n),c=Math.cos(n);return t[0]=i+s*l+o*c,t[1]=e[1],t[2]=a+s*c-o*l,t}},{}],343:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[1],o=e[0]-i,s=e[1]-a,l=Math.sin(n),c=Math.cos(n);return t[0]=i+o*c-s*l,t[1]=a+o*l+s*c,t[2]=e[2],t}},{}],344:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}},{}],345:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}},{}],346:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}},{}],347:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}},{}],348:[function(t,e,r){e.exports=t("./squaredDistance")},{"./squaredDistance":350}],349:[function(t,e,r){e.exports=t("./squaredLength")},{"./squaredLength":351}],350:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}},{}],351:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}},{}],352:[function(t,e,r){e.exports=t("./subtract")},{"./subtract":353}],353:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}},{}],354:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}},{}],355:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t}},{}],356:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],c=r[3],u=c*n+s*a-l*i,f=c*i+l*n-o*a,h=c*a+o*i-s*n,p=-o*n-s*i-l*a;return t[0]=u*c+p*-o+f*-l-h*-s,t[1]=f*c+p*-s+h*-o-u*-l,t[2]=h*c+p*-l+u*-s-f*-o,t}},{}],357:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}},{}],358:[function(t,e,r){e.exports=function(t){var e=new Float32Array(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}},{}],359:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}},{}],360:[function(t,e,r){e.exports=function(){var t=new Float32Array(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}},{}],361:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+a*a)}},{}],362:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}},{}],363:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}},{}],364:[function(t,e,r){e.exports=function(t,e,r,n){var i=new Float32Array(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i}},{}],365:[function(t,e,r){e.exports={create:t("./create"),clone:t("./clone"),fromValues:t("./fromValues"),copy:t("./copy"),set:t("./set"),add:t("./add"),subtract:t("./subtract"),multiply:t("./multiply"),divide:t("./divide"),min:t("./min"),max:t("./max"),scale:t("./scale"),scaleAndAdd:t("./scaleAndAdd"),distance:t("./distance"),squaredDistance:t("./squaredDistance"),length:t("./length"),squaredLength:t("./squaredLength"),negate:t("./negate"),inverse:t("./inverse"),normalize:t("./normalize"),dot:t("./dot"),lerp:t("./lerp"),random:t("./random"),transformMat4:t("./transformMat4"),transformQuat:t("./transformQuat")}},{"./add":357,"./clone":358,"./copy":359,"./create":360,"./distance":361,"./divide":362,"./dot":363,"./fromValues":364,"./inverse":366,"./length":367,"./lerp":368,"./max":369,"./min":370,"./multiply":371,"./negate":372,"./normalize":373,"./random":374,"./scale":375,"./scaleAndAdd":376,"./set":377,"./squaredDistance":378,"./squaredLength":379,"./subtract":380,"./transformMat4":381,"./transformQuat":382}],366:[function(t,e,r){e.exports=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}},{}],367:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}},{}],368:[function(t,e,r){e.exports=function(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t[3]=s+n*(r[3]-s),t}},{}],369:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}},{}],370:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}},{}],371:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}},{}],372:[function(t,e,r){e.exports=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}},{}],373:[function(t,e,r){e.exports=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=a*o);return t}},{}],374:[function(t,e,r){var n=t("./normalize"),i=t("./scale");e.exports=function(t,e){return e=e||1,t[0]=Math.random(),t[1]=Math.random(),t[2]=Math.random(),t[3]=Math.random(),n(t,t),i(t,t,e),t}},{"./normalize":373,"./scale":375}],375:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}},{}],376:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}},{}],377:[function(t,e,r){e.exports=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}},{}],378:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a}},{}],379:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}},{}],380:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}},{}],381:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}},{}],382:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],c=r[3],u=c*n+s*a-l*i,f=c*i+l*n-o*a,h=c*a+o*i-s*n,p=-o*n-s*i-l*a;return t[0]=u*c+p*-o+f*-l-h*-s,t[1]=f*c+p*-s+h*-o-u*-l,t[2]=h*c+p*-l+u*-s-f*-o,t[3]=e[3],t}},{}],383:[function(t,e,r){e.exports=function(t,e,r,a){return n[0]=a,n[1]=r,n[2]=e,n[3]=t,i[0]};var n=new Uint8Array(4),i=new Float32Array(n.buffer)},{}],384:[function(t,e,r){var n=t("glsl-tokenizer"),i=t("atob-lite");e.exports=function(t){for(var e=Array.isArray(t)?t:n(t),r=0;r0)continue;r=t.slice(0,1).join("")}return F(r),z+=r.length,(S=S.slice(r.length)).length}}function H(){return/[^a-fA-F0-9]/.test(e)?(F(S.join("")),T=l,M):(S.push(e),r=e,M+1)}function G(){return"."===e?(S.push(e),T=g,r=e,M+1):/[eE]/.test(e)?(S.push(e),T=g,r=e,M+1):"x"===e&&1===S.length&&"0"===S[0]?(T=_,S.push(e),r=e,M+1):/[^\d]/.test(e)?(F(S.join("")),T=l,M):(S.push(e),r=e,M+1)}function W(){return"f"===e&&(S.push(e),r=e,M+=1),/[eE]/.test(e)?(S.push(e),r=e,M+1):"-"===e&&/[eE]/.test(r)?(S.push(e),r=e,M+1):/[^\d]/.test(e)?(F(S.join("")),T=l,M):(S.push(e),r=e,M+1)}function Y(){if(/[^\d\w_]/.test(e)){var t=S.join("");return T=R.indexOf(t)>-1?y:D.indexOf(t)>-1?m:v,F(S.join("")),T=l,M}return S.push(e),r=e,M+1}};var n=t("./lib/literals"),i=t("./lib/operators"),a=t("./lib/builtins"),o=t("./lib/literals-300es"),s=t("./lib/builtins-300es"),l=999,c=9999,u=0,f=1,h=2,p=3,d=4,g=5,v=6,m=7,y=8,x=9,b=10,_=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":387,"./lib/builtins-300es":386,"./lib/literals":389,"./lib/literals-300es":388,"./lib/operators":390}],386:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":387}],387:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],388:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":389}],389:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],390:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],391:[function(t,e,r){var n=t("./index");e.exports=function(t,e){var r=n(e),i=[];return i=(i=i.concat(r(t))).concat(r(null))}},{"./index":385}],392:[function(t,e,r){e.exports=function(t){"string"==typeof t&&(t=[t]);for(var e=[].slice.call(arguments,1),r=[],n=0;n>1,u=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+t[e+f],f+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),a-=c}return(p?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=u?(s=0,o=u):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*g}},{}],396:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(r<=i)throw new Error("Must input at least d+1 points");var o=t.slice(0,i+1),s=n.apply(void 0,o);if(0===s)throw new Error("Input not in general position");for(var l=new Array(i+1),u=0;u<=i;++u)l[u]=u;s<0&&(l[0]=1,l[1]=0);for(var f=new a(l,new Array(i+1),!1),h=f.adjacent,p=new Array(i+2),u=0;u<=i;++u){for(var d=l.slice(),g=0;g<=i;++g)g===u&&(d[g]=-1);var v=d[0];d[0]=d[1],d[1]=v;var m=new a(d,new Array(i+1),!0);h[u]=m,p[u]=m}p[i+1]=f;for(var u=0;u<=i;++u)for(var d=h[u].vertices,y=h[u].adjacent,g=0;g<=i;++g){var x=d[g];if(x<0)y[g]=f;else for(var b=0;b<=i;++b)h[b].vertices.indexOf(x)<0&&(y[g]=h[b])}for(var _=new c(i,o,p),w=!!e,u=i+1;u0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var i=new Function("test",e.join("")),a=n[t+1];return a||(a=n),i(a)}(t)),this.orient=a}var u=c.prototype;u.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){(t=o.pop()).vertices;for(var s=t.adjacent,l=0;l<=r;++l){var c=s[l];if(c.boundary&&!(c.lastVisited<=-n)){for(var u=c.vertices,f=0;f<=r;++f){var h=u[f];i[f]=h<0?e:a[h]}var p=this.orient();if(p>0)return c;c.lastVisited=-n,0===p&&o.push(c)}}}return null},u.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,c=s.adjacent,u=0;u<=n;++u)a[u]=i[l[u]];s.lastVisited=r;for(u=0;u<=n;++u){var f=c[u];if(!(f.lastVisited>=r)){var h=a[u];a[u]=t;var p=this.orient();if(a[u]=h,p<0){s=f;continue t}f.boundary?f.lastVisited=-r:f.lastVisited=r}}return}return s},u.addPeaks=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,l=this.tuple,c=this.interior,u=this.simplices,f=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,c.push(e);for(var h=[];f.length>0;){var p=(e=f.pop()).vertices,d=e.adjacent,g=p.indexOf(r);if(!(g<0))for(var v=0;v<=n;++v)if(v!==g){var m=d[v];if(m.boundary&&!(m.lastVisited>=r)){var y=m.vertices;if(m.lastVisited!==-r){for(var x=0,b=0;b<=n;++b)y[b]<0?(x=b,l[b]=t):l[b]=i[y[b]];if(this.orient()>0){y[x]=r,m.boundary=!1,c.push(m),f.push(m),m.lastVisited=r;continue}m.lastVisited=-r}var _=m.adjacent,w=p.slice(),k=d.slice(),M=new a(w,k,!0);u.push(M);var A=_.indexOf(e);if(!(A<0)){_[A]=M,k[g]=m,w[v]=-1,k[v]=e,d[v]=M,M.flip();for(b=0;b<=n;++b){var T=w[b];if(!(T<0||T===r)){for(var S=new Array(n-1),C=0,E=0;E<=n;++E){var L=w[E];L<0||E===b||(S[C++]=L)}h.push(new o(S,M,b))}}}}}}h.sort(s);for(v=0;v+1=0?o[l++]=s[u]:c=1&u;if(c===(1&t)){var f=o[0];o[0]=o[1],o[1]=f}e.push(o)}}return e}},{"robust-orientation":486,"simplicial-complex":496}],397:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=0,a=1;function o(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}e.exports=function(t){if(!t||0===t.length)return new x(null);return new x(y(t))};var s=o.prototype;function l(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function c(t,e){var r=y(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function u(t,e){var r=t.intervals([]);r.push(e),c(t,r)}function f(t,e){var r=t.intervals([]),n=r.indexOf(e);return n<0?i:(r.splice(n,1),c(t,r),a)}function h(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function d(t,e){for(var r=0;r>1],i=[],a=[],s=[];for(r=0;r3*(e+1)?u(this,t):this.left.insert(t):this.left=y([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?u(this,t):this.right.insert(t):this.right=y([t]);else{var r=n.ge(this.leftPoints,t,v),i=n.ge(this.rightPoints,t,m);this.leftPoints.splice(r,0,t),this.rightPoints.splice(i,0,t)}},s.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1)?f(this,t):2===(c=this.left.remove(t))?(this.left=null,this.count-=1,a):(c===a&&(this.count-=1),c):i;if(t[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(e-1)?f(this,t):2===(c=this.right.remove(t))?(this.right=null,this.count-=1,a):(c===a&&(this.count-=1),c):i;if(1===this.count)return this.leftPoints[0]===t?2:i;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var r=this,o=this.left;o.right;)r=o,o=o.right;if(r===this)o.right=this.right;else{var s=this.left,c=this.right;r.count-=o.count,r.right=o.left,o.left=s,o.right=c}l(this,o),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?l(this,this.left):l(this,this.right);return a}for(s=n.ge(this.leftPoints,t,v);sthis.mid){var r;if(this.right)if(r=this.right.queryPoint(t,e))return r;return p(this.rightPoints,t,e)}return d(this.leftPoints,e)},s.queryInterval=function(t,e,r){var n;if(tthis.mid&&this.right&&(n=this.right.queryInterval(t,e,r)))return n;return ethis.mid?p(this.rightPoints,t,r):d(this.leftPoints,r)};var b=x.prototype;b.insert=function(t){this.root?this.root.insert(t):this.root=new o(t[0],null,null,[t],[t])},b.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),e!==i}return!1},b.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},b.queryInterval=function(t,e,r){if(t<=e&&this.root)return this.root.queryInterval(t,e,r)},Object.defineProperty(b,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(b,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":79}],398:[function(t,e,r){"use strict";e.exports=function(t,e){e=e||new Array(t.length);for(var r=0;r13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],407:[function(t,e,r){"use strict";e.exports=function(t){return"string"==typeof t&&(t=t.trim(),!!(/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(t)&&/[\dz]$/i.test(t)&&t.length>4))}},{}],408:[function(t,e,r){e.exports=function(t,e,r){return t*(1-r)+e*r}},{}],409:[function(t,e,r){(function(t){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():t.mapboxgl=n()}(this,function(){"use strict";var e,r,n;function i(t,i){if(e)if(r){var a="var sharedChunk = {}; ("+e+")(sharedChunk); ("+r+")(sharedChunk);",o={};e(o),(n=i(o)).workerUrl=window.URL.createObjectURL(new Blob([a],{type:"text/javascript"}))}else r=i;else e=i}return i(0,function(e){var r="undefined"!=typeof window?window:"undefined"!=typeof t?t:"undefined"!=typeof self?self:{};function n(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t,e){return t(e={exports:{}},e.exports),e.exports}var a=o;function o(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=n,this.p2x=r,this.p2y=n}o.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},o.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},o.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},o.prototype.solveCurveX=function(t,e){var r,n,i,a,o;for(void 0===e&&(e=1e-6),i=t,o=0;o<8;o++){if(a=this.sampleCurveX(i)-t,Math.abs(a)(n=1))return n;for(;ra?r=i:n=i,i=.5*(n-r)+r}return i},o.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var s=function(t,e,r){this.column=t,this.row=e,this.zoom=r};s.prototype.clone=function(){return new s(this.column,this.row,this.zoom)},s.prototype.zoomTo=function(t){return this.clone()._zoomTo(t)},s.prototype.sub=function(t){return this.clone()._sub(t)},s.prototype._zoomTo=function(t){var e=Math.pow(2,t-this.zoom);return this.column*=e,this.row*=e,this.zoom=t,this},s.prototype._sub=function(t){return t=t.zoomTo(this.zoom),this.column-=t.column,this.row-=t.row,this};var l=c;function c(t,e){this.x=t,this.y=e}function u(t,e,r,n){var i=new a(t,e,r,n);return function(t){return i.solve(t)}}c.prototype={clone:function(){return new c(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=e*this.x-r*this.y,i=r*this.x+e*this.y;return this.x=n,this.y=i,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.x+r*(this.x-e.x)-n*(this.y-e.y),a=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=i,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},c.convert=function(t){return t instanceof c?t:Array.isArray(t)?new c(t[0],t[1]):t};var f=u(.25,.1,.25,1);function h(t,e,r){return Math.min(r,Math.max(e,t))}function p(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];for(var n=0,i=e;n(e.y-t.y)*(r.x-t.x)}function k(t){for(var e=0,r=0,n=t.length,i=n-1,a=void 0,o=void 0;r=200&&r.status<300&&r.response?e(null,{data:n,cacheControl:r.getResponseHeader("Cache-Control"),expires:r.getResponseHeader("Expires")}):e(new A(r.statusText,r.status,t.url))},r.send(),r};function C(t,e,r){r[t]=r[t]||[],r[t].push(e)}function E(t,e,r){if(r&&r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}var L=function(t,e){void 0===e&&(e={}),p(this,e),this.type=t},z=function(t){function e(e,r){void 0===r&&(r={}),t.call(this,"error",p({error:e},r))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(L),O=function(){};O.prototype.on=function(t,e){return this._listeners=this._listeners||{},C(t,e,this._listeners),this},O.prototype.off=function(t,e){return E(t,e,this._listeners),E(t,e,this._oneTimeListeners),this},O.prototype.once=function(t,e){return this._oneTimeListeners=this._oneTimeListeners||{},C(t,e,this._oneTimeListeners),this},O.prototype.fire=function(t){"string"==typeof t&&(t=new L(t,arguments[1]||{}));var e=t.type;if(this.listens(e)){t.target=this;for(var r=0,n=this._listeners&&this._listeners[e]?this._listeners[e].slice():[];r0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)},O.prototype.setEventedParent=function(t,e){return this._eventedParent=t,this._eventedParentData=e,this};var I={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.0511,180,85.0511]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},buffer:{type:"number",default:128,maximum:512,minimum:0},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},lineMetrics:{type:"boolean",default:!1}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_fill:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_circle:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_line:{"line-cap":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{butt:{},round:{},square:{}},default:"butt"},"line-join":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{bevel:{},round:{},miter:{}},default:"miter"},"line-miter-limit":{type:"number",default:2,function:"interpolated","zoom-function":!0,requires:[{"line-join":"miter"}]},"line-round-limit":{type:"number",default:1.05,function:"interpolated","zoom-function":!0,requires:[{"line-join":"round"}]},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_symbol:{"symbol-placement":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{point:{},line:{}},default:"point"},"symbol-spacing":{type:"number",default:250,minimum:1,function:"interpolated","zoom-function":!0,units:"pixels",requires:[{"symbol-placement":"line"}]},"symbol-avoid-edges":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1},"icon-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image"]},"icon-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image"]},"icon-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image","text-field"]},"icon-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"]},"icon-size":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,units:"factor of the original icon size",requires:["icon-image"]},"icon-text-fit":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"]},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",function:"interpolated","zoom-function":!0,requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}]},"icon-image":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,tokens:!0},"icon-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,"property-function":!0,units:"degrees",requires:["icon-image"]},"icon-padding":{type:"number",default:2,minimum:0,function:"interpolated","zoom-function":!0,units:"pixels",requires:["icon-image"]},"icon-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":"line"}]},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,requires:["icon-image"]},"icon-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"]},"icon-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"]},"text-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"]},"text-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"]},"text-field":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:"",tokens:!0},"text-font":{type:"array",value:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"]},"text-size":{type:"number",default:16,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-line-height":{type:"number",default:1.2,units:"ems",function:"interpolated","zoom-function":!0,requires:["text-field"]},"text-letter-spacing":{type:"number",default:0,units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-justify":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{left:{},center:{},right:{}},default:"center",requires:["text-field"]},"text-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field"]},"text-max-angle":{type:"number",default:45,units:"degrees",function:"interpolated","zoom-function":!0,requires:["text-field",{"symbol-placement":"line"}]},"text-rotate":{type:"number",default:0,period:360,units:"degrees",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,requires:["text-field"]},"text-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":"line"}]},"text-transform":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"]},"text-offset":{type:"array",value:"number",units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,length:2,default:[0,0],requires:["text-field"]},"text-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field"]},"text-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field"]},"text-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!1,requires:["text-field","icon-image"]},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function_stop:{type:"array",minimum:0,maximum:22,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},expression_name:{type:"enum",values:{let:{group:"Variable binding"},var:{group:"Variable binding"},literal:{group:"Types"},array:{group:"Types"},at:{group:"Lookup"},case:{group:"Decision"},match:{group:"Decision"},coalesce:{group:"Decision"},step:{group:"Ramps, scales, curves"},interpolate:{group:"Ramps, scales, curves"},ln2:{group:"Math"},pi:{group:"Math"},e:{group:"Math"},typeof:{group:"Types"},string:{group:"Types"},number:{group:"Types"},boolean:{group:"Types"},object:{group:"Types"},collator:{group:"Types"},"to-string":{group:"Types"},"to-number":{group:"Types"},"to-boolean":{group:"Types"},"to-rgba":{group:"Color"},"to-color":{group:"Types"},rgb:{group:"Color"},rgba:{group:"Color"},get:{group:"Lookup"},has:{group:"Lookup"},length:{group:"Lookup"},properties:{group:"Feature data"},"geometry-type":{group:"Feature data"},id:{group:"Feature data"},zoom:{group:"Zoom"},"heatmap-density":{group:"Heatmap"},"line-progress":{group:"Heatmap"},"+":{group:"Math"},"*":{group:"Math"},"-":{group:"Math"},"/":{group:"Math"},"%":{group:"Math"},"^":{group:"Math"},sqrt:{group:"Math"},log10:{group:"Math"},ln:{group:"Math"},log2:{group:"Math"},sin:{group:"Math"},cos:{group:"Math"},tan:{group:"Math"},asin:{group:"Math"},acos:{group:"Math"},atan:{group:"Math"},min:{group:"Math"},max:{group:"Math"},round:{group:"Math"},abs:{group:"Math"},ceil:{group:"Math"},floor:{group:"Math"},"==":{group:"Decision"},"!=":{group:"Decision"},">":{group:"Decision"},"<":{group:"Decision"},">=":{group:"Decision"},"<=":{group:"Decision"},all:{group:"Decision"},any:{group:"Decision"},"!":{group:"Decision"},"is-supported-script":{group:"String"},upcase:{group:"String"},downcase:{group:"String"},concat:{group:"String"},"resolved-locale":{group:"String"}}},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},transition:!1,"zoom-function":!0,"property-function":!1,function:"piecewise-constant"},position:{type:"array",default:[1.15,210,30],length:3,value:"number",transition:!0,function:"interpolated","zoom-function":!0,"property-function":!1},color:{type:"color",default:"#ffffff",function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0},intensity:{type:"number",default:.5,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",function:"piecewise-constant","zoom-function":!0,default:!0},"fill-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"fill-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"}]},"fill-outline-color":{type:"color",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}]},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"fill-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["fill-translate"]},"fill-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0}},paint_line:{"line-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"line-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"line-pattern"}]},"line-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"line-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["line-translate"]},"line-width":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-gap-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-offset":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-dasharray":{type:"array",value:"number",function:"piecewise-constant","zoom-function":!0,minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}]},"line-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"line-gradient":{type:"color",function:"interpolated","zoom-function":!1,"property-function":!1,transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}]}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-blur":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"circle-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["circle-translate"]},"circle-pitch-scale":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map"},"circle-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"viewport"},"circle-stroke-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-stroke-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"heatmap-weight":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!1},"heatmap-intensity":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],function:"interpolated","zoom-function":!1,"property-function":!1,transition:!1},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!1,transition:!0}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"]},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"]}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-hue-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,transition:!0,units:"degrees"},"raster-brightness-min":{type:"number",function:"interpolated","zoom-function":!0,default:0,minimum:0,maximum:1,transition:!0},"raster-brightness-max":{type:"number",function:"interpolated","zoom-function":!0,default:1,minimum:0,maximum:1,transition:!0},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-fade-duration":{type:"number",default:300,minimum:0,function:"interpolated","zoom-function":!0,transition:!1,units:"milliseconds"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,function:"interpolated","zoom-function":!0,transition:!1},"hillshade-illumination-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"viewport"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"hillshade-shadow-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",function:"interpolated","zoom-function":!0,transition:!0},"hillshade-accent-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0}},paint_background:{"background-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0,requires:[{"!":"background-pattern"}]},"background-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible"}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!1,default:1,minimum:0,maximum:1,transition:!0},"fill-extrusion-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-extrusion-pattern"}]},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,transition:!0,units:"pixels"},"fill-extrusion-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"]},"fill-extrusion-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"fill-extrusion-height":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:0,minimum:0,units:"meters",transition:!0},"fill-extrusion-base":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"]}}},P=function(t,e,r,n){this.message=(t?t+": ":"")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)};function D(t){var e=t.key,r=t.value;return r?[new P(e,r,"constants have been deprecated as of v8")]:[]}function R(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];for(var n=0,i=e;n":"value"===t.itemType.kind?"array":"array<"+e+">"}return t.kind}var J=[V,U,q,H,G,W,Z(Y)];function K(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&!K(t.itemType,e.itemType)&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(var r=0,n=J;r255?255:t}function i(t){return t<0?0:t>1?1:t}function a(t){return"%"===t[t.length-1]?n(parseFloat(t)/100*255):n(parseInt(t))}function o(t){return"%"===t[t.length-1]?i(parseFloat(t)/100):i(parseFloat(t))}function s(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{e.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in r)return r[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=i.indexOf("("),c=i.indexOf(")");if(-1!==l&&c+1===i.length){var u=i.substr(0,l),f=i.substr(l+1,c-(l+1)).split(","),h=1;switch(u){case"rgba":if(4!==f.length)return null;h=o(f.pop());case"rgb":return 3!==f.length?null:[a(f[0]),a(f[1]),a(f[2]),h];case"hsla":if(4!==f.length)return null;h=o(f.pop());case"hsl":if(3!==f.length)return null;var p=(parseFloat(f[0])%360+360)%360/360,d=o(f[1]),g=o(f[2]),v=g<=.5?g*(d+1):g+d-g*d,m=2*g-v;return[n(255*s(m,v,p+1/3)),n(255*s(m,v,p)),n(255*s(m,v,p-1/3)),h];default:return null}}return null}}catch(t){}}).parseCSSColor,tt=function(t,e,r,n){void 0===n&&(n=1),this.r=t,this.g=e,this.b=r,this.a=n};tt.parse=function(t){if(t){if(t instanceof tt)return t;if("string"==typeof t){var e=Q(t);if(e)return new tt(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3])}}},tt.prototype.toString=function(){var t=this.toArray(),e=t[0],r=t[1],n=t[2],i=t[3];return"rgba("+Math.round(e)+","+Math.round(r)+","+Math.round(n)+","+i+")"},tt.prototype.toArray=function(){var t=this.r,e=this.g,r=this.b,n=this.a;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*r/n,n]},tt.black=new tt(0,0,0,1),tt.white=new tt(1,1,1,1),tt.transparent=new tt(0,0,0,0);var et=function(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})};et.prototype.compare=function(t,e){return this.collator.compare(t,e)},et.prototype.resolvedLocale=function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale};var rt=function(t,e,r){this.type=X,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e};function nt(t,e,r,n){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:"Invalid rgba value ["+[t,e,r,n].join(", ")+"]: 'a' must be between 0 and 1.":"Invalid rgba value ["+("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")+"]: 'r', 'g', and 'b' must be between 0 and 255."}function it(t){if(null===t)return V;if("string"==typeof t)return q;if("boolean"==typeof t)return H;if("number"==typeof t)return U;if(t instanceof tt)return G;if(t instanceof et)return X;if(Array.isArray(t)){for(var e,r=t.length,n=0,i=t;n4)return e.error("Expected 1, 2, or 3 arguments, but found "+(t.length-1)+" instead.");var r,n;if(t.length>2){var i=t[1];if("string"!=typeof i||!(i in ct))return e.error('The item type argument of "array" must be one of string, number, boolean',1);r=ct[i]}else r=Y;if(t.length>3){if("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2]))return e.error('The length argument to "array" must be a positive integer literal',2);n=t[2]}var a=Z(r,n),o=e.parse(t[t.length-1],t.length-1,Y);return o?new ut(a,o):null},ut.prototype.evaluate=function(t){var e=this.input.evaluate(t);if(K(this.type,it(e)))throw new ot("Expected value to be of type "+$(this.type)+", but found "+$(it(e))+" instead.");return e},ut.prototype.eachChild=function(t){t(this.input)},ut.prototype.possibleOutputs=function(){return this.input.possibleOutputs()},ut.prototype.serialize=function(){var t=["array"],e=this.type.itemType;if("string"===e.kind||"number"===e.kind||"boolean"===e.kind){t.push(e.kind);var r=this.type.N;"number"==typeof r&&t.push(r)}return t.push(this.input.serialize()),t};var ft={"to-number":U,"to-color":G},ht=function(t,e){this.type=t,this.args=e};ht.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");for(var r=t[0],n=ft[r],i=[],a=1;a4?"Invalid rbga value "+JSON.stringify(e)+": expected an array containing either three or four numeric values.":nt(e[0],e[1],e[2],e[3])))return new tt(e[0]/255,e[1]/255,e[2]/255,e[3]);throw new ot(r||"Could not parse color from value '"+("string"==typeof e?e:JSON.stringify(e))+"'")}for(var o=null,s=0,l=this.args;s=0)return!1;var r=!0;return t.eachChild(function(t){r&&!mt(t,e)&&(r=!1)}),r}gt.prototype.evaluate=function(t){return this._evaluate(t,this.args)},gt.prototype.eachChild=function(t){this.args.forEach(t)},gt.prototype.possibleOutputs=function(){return[void 0]},gt.prototype.serialize=function(){return[this.name].concat(this.args.map(function(t){return t.serialize()}))},gt.parse=function(t,e){var r=t[0],n=gt.definitions[r];if(!n)return e.error('Unknown expression "'+r+'". If you wanted a literal array, use ["literal", [...]].',0);for(var i=Array.isArray(n)?n[0]:n.type,a=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,o=a.filter(function(e){var r=e[0];return!Array.isArray(r)||r.length===t.length-1}),s=[],l=1;lr&&ee))throw new ot("Input is not a number.");a=o-1}}return Math.max(o-1,0)}xt.prototype.parse=function(t,e,r,n,i){return void 0===i&&(i={}),e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)},xt.prototype._parse=function(t,e){if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var r=t[0];if("string"!=typeof r)return this.error("Expression name must be a string, but found "+typeof r+' instead. If you wanted a literal array, use ["literal", [...]].',0),null;var n=this.registry[r];if(n){var i=n.parse(t,this);if(!i)return null;if(this.expectedType){var a=this.expectedType,o=i.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind||"value"!==o.kind)if("array"===a.kind&&"value"===o.kind)e.omitTypeAnnotations||(i=new ut(a,i));else if("color"!==a.kind||"value"!==o.kind&&"string"!==o.kind){if(this.checkSubtype(this.expectedType,i.type))return null}else e.omitTypeAnnotations||(i=new ht(a,[i]));else e.omitTypeAnnotations||(i=new lt(a,[i]))}if(!(i instanceof at)&&function t(e){if(e instanceof yt)return t(e.boundExpression);if(e instanceof gt&&"error"===e.name)return!1;if(e instanceof rt)return!1;var r=e instanceof ht||e instanceof lt||e instanceof ut,n=!0;return e.eachChild(function(e){n=r?n&&t(e):n&&e instanceof at}),!!n&&(vt(e)&&mt(e,["zoom","heatmap-density","line-progress","is-supported-script"]))}(i)){var s=new dt;try{i=new at(i.type,i.evaluate(s))}catch(t){return this.error(t.message),null}}return i}return this.error('Unknown expression "'+r+'". If you wanted a literal array, use ["literal", [...]].',0)}return void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error("Expected an array, but found "+typeof t+" instead.")},xt.prototype.concat=function(t,e,r){var n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new xt(this.registry,n,e||null,i,this.errors)},xt.prototype.error=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];var n=""+this.key+e.map(function(t){return"["+t+"]"}).join("");this.errors.push(new N(n,t))},xt.prototype.checkSubtype=function(t,e){var r=K(t,e);return r&&this.error(r),r};var _t=function(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(var n=0,i=r;n=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',c);var f=e.parse(l,u,a);if(!f)return null;a=a||f.type,i.push([s,f])}return new _t(a,r,i)},_t.prototype.evaluate=function(t){var e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);var n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);var i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[bt(e,n)].evaluate(t)},_t.prototype.eachChild=function(t){t(this.input);for(var e=0,r=this.outputs;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t};var kt=Object.freeze({number:wt,color:function(t,e,r){return new tt(wt(t.r,e.r,r),wt(t.g,e.g,r),wt(t.b,e.b,r),wt(t.a,e.a,r))},array:function(t,e,r){return t.map(function(t,n){return wt(t,e[n],r)})}}),Mt=function(t,e,r,n){this.type=t,this.interpolation=e,this.input=r,this.labels=[],this.outputs=[];for(var i=0,a=n;i1}))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:o}}if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(!(n=e.parse(n,2,U)))return null;var s=[],l=null;e.expectedType&&"value"!==e.expectedType.kind&&(l=e.expectedType);for(var c=0;c=u)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',h);var d=e.parse(f,p,l);if(!d)return null;l=l||d.type,s.push([u,d])}return"number"===l.kind||"color"===l.kind||"array"===l.kind&&"number"===l.itemType.kind&&"number"==typeof l.N?new Mt(l,r,n,s):e.error("Type "+$(l)+" is not interpolatable.")},Mt.prototype.evaluate=function(t){var e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);var n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);var i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);var a=bt(e,n),o=e[a],s=e[a+1],l=Mt.interpolationFactor(this.interpolation,n,o,s),c=r[a].evaluate(t),u=r[a+1].evaluate(t);return kt[this.type.kind.toLowerCase()](c,u,l)},Mt.prototype.eachChild=function(t){t(this.input);for(var e=0,r=this.outputs;e=r.length)throw new ot("Array index out of bounds: "+e+" > "+(r.length-1)+".");if(e!==Math.floor(e))throw new ot("Array index must be an integer, but found "+e+" instead.");return r[e]},Ct.prototype.eachChild=function(t){t(this.index),t(this.input)},Ct.prototype.possibleOutputs=function(){return[void 0]},Ct.prototype.serialize=function(){return["at",this.index.serialize(),this.input.serialize()]};var Et=function(t,e,r,n,i,a){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=a};Et.parse=function(t,e){if(t.length<5)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if(t.length%2!=1)return e.error("Expected an even number of arguments.");var r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(var i={},a=[],o=2;oNumber.MAX_SAFE_INTEGER)return c.error("Branch labels must be integers no larger than "+Number.MAX_SAFE_INTEGER+".");if("number"==typeof h&&Math.floor(h)!==h)return c.error("Numeric branch labels must be integer values.");if(r){if(c.checkSubtype(r,it(h)))return null}else r=it(h);if(void 0!==i[String(h)])return c.error("Branch labels must be unique.");i[String(h)]=a.length}var p=e.parse(l,o,n);if(!p)return null;n=n||p.type,a.push(p)}var d=e.parse(t[1],1,r);if(!d)return null;var g=e.parse(t[t.length-1],t.length-1,n);return g?new Et(r,n,d,i,a,g):null},Et.prototype.evaluate=function(t){var e=this.input.evaluate(t);return(this.outputs[this.cases[e]]||this.otherwise).evaluate(t)},Et.prototype.eachChild=function(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)},Et.prototype.possibleOutputs=function(){return(t=[]).concat.apply(t,this.outputs.map(function(t){return t.possibleOutputs()})).concat(this.otherwise.possibleOutputs());var t},Et.prototype.serialize=function(){for(var t=this,e=["match",this.input.serialize()],r=[],n={},i=0,a=Object.keys(this.cases).sort();in.evaluate(t)}function Ut(t,e){var r=e[0],n=e[1];return r.evaluate(t)<=n.evaluate(t)}function qt(t,e){var r=e[0],n=e[1];return r.evaluate(t)>=n.evaluate(t)}function Ht(t){return{type:t}}function Gt(t){return{result:"success",value:t}}function Wt(t){return{result:"error",value:t}}gt.register(Rt,{error:[{kind:"error"},[q],function(t,e){var r=e[0];throw new ot(r.evaluate(t))}],typeof:[q,[Y],function(t,e){return $(it(e[0].evaluate(t)))}],"to-string":[q,[Y],function(t,e){var r=e[0],n=typeof(r=r.evaluate(t));return null===r?"":"string"===n||"number"===n||"boolean"===n?String(r):r instanceof tt?r.toString():JSON.stringify(r)}],"to-boolean":[H,[Y],function(t,e){var r=e[0];return Boolean(r.evaluate(t))}],"to-rgba":[Z(U,4),[G],function(t,e){return e[0].evaluate(t).toArray()}],rgb:[G,[U,U,U],Ft],rgba:[G,[U,U,U,U],Ft],has:{type:H,overloads:[[[q],function(t,e){return Bt(e[0].evaluate(t),t.properties())}],[[q,W],function(t,e){var r=e[0],n=e[1];return Bt(r.evaluate(t),n.evaluate(t))}]]},get:{type:Y,overloads:[[[q],function(t,e){return Nt(e[0].evaluate(t),t.properties())}],[[q,W],function(t,e){var r=e[0],n=e[1];return Nt(r.evaluate(t),n.evaluate(t))}]]},properties:[W,[],function(t){return t.properties()}],"geometry-type":[q,[],function(t){return t.geometryType()}],id:[Y,[],function(t){return t.id()}],zoom:[U,[],function(t){return t.globals.zoom}],"heatmap-density":[U,[],function(t){return t.globals.heatmapDensity||0}],"line-progress":[U,[],function(t){return t.globals.lineProgress||0}],"+":[U,Ht(U),function(t,e){for(var r=0,n=0,i=e;n":[H,[q,Y],function(t,e){var r=e[0],n=e[1],i=t.properties()[r.value],a=n.value;return typeof i==typeof a&&i>a}],"filter-id->":[H,[Y],function(t,e){var r=e[0],n=t.id(),i=r.value;return typeof n==typeof i&&n>i}],"filter-<=":[H,[q,Y],function(t,e){var r=e[0],n=e[1],i=t.properties()[r.value],a=n.value;return typeof i==typeof a&&i<=a}],"filter-id-<=":[H,[Y],function(t,e){var r=e[0],n=t.id(),i=r.value;return typeof n==typeof i&&n<=i}],"filter->=":[H,[q,Y],function(t,e){var r=e[0],n=e[1],i=t.properties()[r.value],a=n.value;return typeof i==typeof a&&i>=a}],"filter-id->=":[H,[Y],function(t,e){var r=e[0],n=t.id(),i=r.value;return typeof n==typeof i&&n>=i}],"filter-has":[H,[Y],function(t,e){return e[0].value in t.properties()}],"filter-has-id":[H,[],function(t){return null!==t.id()}],"filter-type-in":[H,[Z(q)],function(t,e){return e[0].value.indexOf(t.geometryType())>=0}],"filter-id-in":[H,[Z(Y)],function(t,e){return e[0].value.indexOf(t.id())>=0}],"filter-in-small":[H,[q,Z(Y)],function(t,e){var r=e[0];return e[1].value.indexOf(t.properties()[r.value])>=0}],"filter-in-large":[H,[q,Z(Y)],function(t,e){var r=e[0],n=e[1];return function(t,e,r,n){for(;r<=n;){var i=r+n>>1;if(e[i]===t)return!0;e[i]>t?n=i-1:r=i+1}return!1}(t.properties()[r.value],n.value,0,n.value.length-1)}],">":{type:H,overloads:[[[U,U],Vt],[[q,q],Vt],[[q,q,X],function(t,e){var r=e[0],n=e[1];return e[2].evaluate(t).compare(r.evaluate(t),n.evaluate(t))>0}]]},"<":{type:H,overloads:[[[U,U],jt],[[q,q],jt],[[q,q,X],function(t,e){var r=e[0],n=e[1];return e[2].evaluate(t).compare(r.evaluate(t),n.evaluate(t))<0}]]},">=":{type:H,overloads:[[[U,U],qt],[[q,q],qt],[[q,q,X],function(t,e){var r=e[0],n=e[1];return e[2].evaluate(t).compare(r.evaluate(t),n.evaluate(t))>=0}]]},"<=":{type:H,overloads:[[[U,U],Ut],[[q,q],Ut],[[q,q,X],function(t,e){var r=e[0],n=e[1];return e[2].evaluate(t).compare(r.evaluate(t),n.evaluate(t))<=0}]]},all:{type:H,overloads:[[[H,H],function(t,e){var r=e[0],n=e[1];return r.evaluate(t)&&n.evaluate(t)}],[Ht(H),function(t,e){for(var r=0,n=e;rQt?Math.pow(t,1/3):t/Kt+$t}function ne(t){return t>Jt?t*t*t:Kt*(t-$t)}function ie(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function ae(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function oe(t){var e=ae(t.r),r=ae(t.g),n=ae(t.b),i=re((.4124564*e+.3575761*r+.1804375*n)/Yt),a=re((.2126729*e+.7151522*r+.072175*n)/Xt);return{l:116*a-16,a:500*(i-a),b:200*(a-re((.0193339*e+.119192*r+.9503041*n)/Zt)),alpha:t.a}}function se(t){var e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=Xt*ne(e),r=Yt*ne(r),n=Zt*ne(n),new tt(ie(3.2404542*r-1.5371385*e-.4985314*n),ie(-.969266*r+1.8760108*e+.041556*n),ie(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}var le={forward:oe,reverse:se,interpolate:function(t,e,r){return{l:wt(t.l,e.l,r),a:wt(t.a,e.a,r),b:wt(t.b,e.b,r),alpha:wt(t.alpha,e.alpha,r)}}},ce={forward:function(t){var e=oe(t),r=e.l,n=e.a,i=e.b,a=Math.atan2(i,n)*ee;return{h:a<0?a+360:a,c:Math.sqrt(n*n+i*i),l:r,alpha:t.a}},reverse:function(t){var e=t.h*te,r=t.c;return se({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return{h:function(t,e,r){var n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}(t.h,e.h,r),c:wt(t.c,e.c,r),l:wt(t.l,e.l,r),alpha:wt(t.alpha,e.alpha,r)}}},ue=Object.freeze({lab:le,hcl:ce});function fe(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function he(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function pe(t){return t}function de(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function ge(t,e,r,n,i){return de(typeof r===i?n[r]:void 0,t.default,e.default)}function ve(t,e,r){if("number"!==fe(r))return de(t.default,e.default);var n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];var i=xe(t.stops,r);return t.stops[i][1]}function me(t,e,r){var n=void 0!==t.base?t.base:1;if("number"!==fe(r))return de(t.default,e.default);var i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];var a=xe(t.stops,r),o=function(t,e,r,n){var i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[a][0],t.stops[a+1][0]),s=t.stops[a][1],l=t.stops[a+1][1],c=kt[e.type]||pe;if(t.colorSpace&&"rgb"!==t.colorSpace){var u=ue[t.colorSpace];c=function(t,e){return u.reverse(u.interpolate(u.forward(t),u.forward(e),o))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=s.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==r&&void 0!==n)return c(r,n,o)}}:c(s,l,o)}function ye(t,e,r){return"color"===e.type?r=tt.parse(r):fe(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0),de(r,t.default,e.default)}function xe(t,e){for(var r,n,i=0,a=t.length-1,o=0;i<=a;){if(r=t[o=Math.floor((i+a)/2)][0],n=t[o+1][0],e===r||e>r&&ee&&(a=o-1)}return Math.max(o-1,0)}var be=function(t,e){var r;this.expression=t,this._warningHistory={},this._defaultValue="color"===(r=e).type&&he(r.default)?new tt(0,0,0,0):"color"===r.type?tt.parse(r.default)||null:void 0===r.default?null:r.default,"enum"===e.type&&(this._enumValues=e.values)};function _e(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Rt}function we(t,e){var r=new xt(Rt,[],function(t){var e={color:G,string:q,number:U,enum:q,boolean:H};return"array"===t.type?Z(e[t.value]||Y,t.length):e[t.type]||null}(e)),n=r.parse(t);return n?Gt(new be(n,e)):Wt(r.errors)}be.prototype.evaluateWithoutErrorHandling=function(t,e){return this._evaluator||(this._evaluator=new dt),this._evaluator.globals=t,this._evaluator.feature=e,this.expression.evaluate(this._evaluator)},be.prototype.evaluate=function(t,e){this._evaluator||(this._evaluator=new dt),this._evaluator.globals=t,this._evaluator.feature=e;try{var r=this.expression.evaluate(this._evaluator);if(null==r)return this._defaultValue;if(this._enumValues&&!(r in this._enumValues))throw new ot("Expected value to be one of "+Object.keys(this._enumValues).map(function(t){return JSON.stringify(t)}).join(", ")+", but found "+JSON.stringify(r)+" instead.");return r}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}};var ke=function(t,e){this.kind=t,this._styleExpression=e};ke.prototype.evaluateWithoutErrorHandling=function(t,e){return this._styleExpression.evaluateWithoutErrorHandling(t,e)},ke.prototype.evaluate=function(t,e){return this._styleExpression.evaluate(t,e)};var Me=function(t,e,r){this.kind=t,this.zoomStops=r.labels,this._styleExpression=e,r instanceof Mt&&(this._interpolationType=r.interpolation)};function Ae(t,e){if("error"===(t=we(t,e)).result)return t;var r=t.value.expression,n=vt(r);if(!n&&!e["property-function"])return Wt([new N("","property expressions not supported")]);var i=mt(r,["zoom"]);if(!i&&!1===e["zoom-function"])return Wt([new N("","zoom expressions not supported")]);var a=function t(e){var r=null;if(e instanceof St)r=t(e.result);else if(e instanceof Tt)for(var n=0,i=e.args;nn.maximum?[new P(e,r,r+" is greater than the maximum value "+n.maximum)]:[]}function ze(t){var e,r,n,i=t.valueSpec,a=F(t.value.type),o={},s="categorical"!==a&&void 0===t.value.property,l=!s,c="array"===fe(t.value.stops)&&"array"===fe(t.value.stops[0])&&"object"===fe(t.value.stops[0][0]),u=Ce({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===a)return[new P(t.key,t.value,'identity function may not have a "stops" property')];var e=[],r=t.value;return e=e.concat(Ee({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),"array"===fe(r)&&0===r.length&&e.push(new P(t.key,r,"array must have at least one stop")),e},default:function(t){return Ke({key:t.key,value:t.value,valueSpec:i,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===a&&s&&u.push(new P(t.key,t.value,'missing required property "property"')),"identity"===a||t.value.stops||u.push(new P(t.key,t.value,'missing required property "stops"')),"exponential"===a&&"piecewise-constant"===t.valueSpec.function&&u.push(new P(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!t.valueSpec["property-function"]?u.push(new P(t.key,t.value,"property functions not supported")):s&&!t.valueSpec["zoom-function"]&&"heatmap-color"!==t.objectKey&&"line-gradient"!==t.objectKey&&u.push(new P(t.key,t.value,"zoom functions not supported"))),"categorical"!==a&&!c||void 0!==t.value.property||u.push(new P(t.key,t.value,'"property" property is required')),u;function f(t){var e=[],a=t.value,s=t.key;if("array"!==fe(a))return[new P(s,a,"array expected, "+fe(a)+" found")];if(2!==a.length)return[new P(s,a,"array length 2 expected, length "+a.length+" found")];if(c){if("object"!==fe(a[0]))return[new P(s,a,"object expected, "+fe(a[0])+" found")];if(void 0===a[0].zoom)return[new P(s,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new P(s,a,"object stop key must have value")];if(n&&n>F(a[0].zoom))return[new P(s,a[0].zoom,"stop zoom values must appear in ascending order")];F(a[0].zoom)!==n&&(n=F(a[0].zoom),r=void 0,o={}),e=e.concat(Ce({key:s+"[0]",value:a[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Le,value:h}}))}else e=e.concat(h({key:s+"[0]",value:a[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},a));return e.concat(Ke({key:s+"[1]",value:a[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function h(t,n){var s=fe(t.value),l=F(t.value),c=null!==t.value?t.value:n;if(e){if(s!==e)return[new P(t.key,c,s+" stop domain type must match previous stop domain type "+e)]}else e=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new P(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==a){var u="number expected, "+s+" found";return i["property-function"]&&void 0===a&&(u+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new P(t.key,c,u)]}return"categorical"!==a||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==a&&"number"===s&&void 0!==r&&l=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3===t.length&&(Array.isArray(t[1])||Array.isArray(t[2]));case"any":case"all":for(var e=0,r=t.slice(1);ee?1:0}function Be(t){if(!t)return!0;var e,r=t[0];return t.length<=1?"any"!==r:"=="===r?Ne(t[1],t[2],"=="):"!="===r?Ue(Ne(t[1],t[2],"==")):"<"===r||">"===r||"<="===r||">="===r?Ne(t[1],t[2],r):"any"===r?(e=t.slice(1),["any"].concat(e.map(Be))):"all"===r?["all"].concat(t.slice(1).map(Be)):"none"===r?["all"].concat(t.slice(1).map(Be).map(Ue)):"in"===r?je(t[1],t.slice(2)):"!in"===r?Ue(je(t[1],t.slice(2))):"has"===r?Ve(t[1]):"!has"!==r||Ue(Ve(t[1]))}function Ne(t,e,r){switch(t){case"$type":return["filter-type-"+r,e];case"$id":return["filter-id-"+r,e];default:return["filter-"+r,t,e]}}function je(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(function(t){return typeof t!=typeof e[0]})?["filter-in-large",t,["literal",e.sort(Fe)]]:["filter-in-small",t,["literal",e]]}}function Ve(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Ue(t){return["!",t]}function qe(t){return Pe(B(t.value))?Oe(R({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):function t(e){var r=e.value,n=e.key;if("array"!==fe(r))return[new P(n,r,"array expected, "+fe(r)+" found")];var i,a=e.styleSpec,o=[];if(r.length<1)return[new P(n,r,"filter array must have at least 1 element")];switch(o=o.concat(Ie({key:n+"[0]",value:r[0],valueSpec:a.filter_operator,style:e.style,styleSpec:e.styleSpec})),F(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&"$type"===F(r[1])&&o.push(new P(n,r,'"$type" cannot be use with operator "'+r[0]+'"'));case"==":case"!=":3!==r.length&&o.push(new P(n,r,'filter array for operator "'+r[0]+'" must have 3 elements'));case"in":case"!in":r.length>=2&&"string"!==(i=fe(r[1]))&&o.push(new P(n+"[1]",r[1],"string expected, "+i+" found"));for(var s=2;s=c[h+0]&&n>=c[h+1]?(o[f]=!0,a.push(l[f])):o[f]=!1}}},ur.prototype._forEachCell=function(t,e,r,n,i,a,o){for(var s=this._convertToCellCoord(t),l=this._convertToCellCoord(e),c=this._convertToCellCoord(r),u=this._convertToCellCoord(n),f=s;f<=c;f++)for(var h=l;h<=u;h++){var p=this.d*h+f;if(i.call(this,t,e,r,n,p,a,o))return}},ur.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},ur.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=cr+this.cells.length+1+1,r=0,n=0;n=0)){var f=t[u];c[u]=hr[l].shallow.indexOf(u)>=0?f:gr(f,e)}t instanceof Error&&(c.message=t.message)}return{name:l,properties:c}}throw new Error("can't serialize object of type "+typeof t)}function vr(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof fr)return t;if(Array.isArray(t))return t.map(function(t){return vr(t)});if("object"==typeof t){var e=t,r=e.name,n=e.properties;if(!r)throw new Error("can't deserialize object of anonymous class");var i=hr[r].klass;if(!i)throw new Error("can't deserialize unregistered class "+r);if(i.deserialize)return i.deserialize(n._serialized);for(var a=Object.create(i.prototype),o=0,s=Object.keys(n);o=0?n[l]:vr(n[l])}return a}throw new Error("can't deserialize object of type "+typeof t)}var mr=function(){this.first=!0};mr.prototype.update=function(t,e){var r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoom=128&&t<=255},Arabic:function(t){return t>=1536&&t<=1791},"Arabic Supplement":function(t){return t>=1872&&t<=1919},"Arabic Extended-A":function(t){return t>=2208&&t<=2303},"Hangul Jamo":function(t){return t>=4352&&t<=4607},"Unified Canadian Aboriginal Syllabics":function(t){return t>=5120&&t<=5759},Khmer:function(t){return t>=6016&&t<=6143},"Unified Canadian Aboriginal Syllabics Extended":function(t){return t>=6320&&t<=6399},"General Punctuation":function(t){return t>=8192&&t<=8303},"Letterlike Symbols":function(t){return t>=8448&&t<=8527},"Number Forms":function(t){return t>=8528&&t<=8591},"Miscellaneous Technical":function(t){return t>=8960&&t<=9215},"Control Pictures":function(t){return t>=9216&&t<=9279},"Optical Character Recognition":function(t){return t>=9280&&t<=9311},"Enclosed Alphanumerics":function(t){return t>=9312&&t<=9471},"Geometric Shapes":function(t){return t>=9632&&t<=9727},"Miscellaneous Symbols":function(t){return t>=9728&&t<=9983},"Miscellaneous Symbols and Arrows":function(t){return t>=11008&&t<=11263},"CJK Radicals Supplement":function(t){return t>=11904&&t<=12031},"Kangxi Radicals":function(t){return t>=12032&&t<=12255},"Ideographic Description Characters":function(t){return t>=12272&&t<=12287},"CJK Symbols and Punctuation":function(t){return t>=12288&&t<=12351},Hiragana:function(t){return t>=12352&&t<=12447},Katakana:function(t){return t>=12448&&t<=12543},Bopomofo:function(t){return t>=12544&&t<=12591},"Hangul Compatibility Jamo":function(t){return t>=12592&&t<=12687},Kanbun:function(t){return t>=12688&&t<=12703},"Bopomofo Extended":function(t){return t>=12704&&t<=12735},"CJK Strokes":function(t){return t>=12736&&t<=12783},"Katakana Phonetic Extensions":function(t){return t>=12784&&t<=12799},"Enclosed CJK Letters and Months":function(t){return t>=12800&&t<=13055},"CJK Compatibility":function(t){return t>=13056&&t<=13311},"CJK Unified Ideographs Extension A":function(t){return t>=13312&&t<=19903},"Yijing Hexagram Symbols":function(t){return t>=19904&&t<=19967},"CJK Unified Ideographs":function(t){return t>=19968&&t<=40959},"Yi Syllables":function(t){return t>=40960&&t<=42127},"Yi Radicals":function(t){return t>=42128&&t<=42191},"Hangul Jamo Extended-A":function(t){return t>=43360&&t<=43391},"Hangul Syllables":function(t){return t>=44032&&t<=55215},"Hangul Jamo Extended-B":function(t){return t>=55216&&t<=55295},"Private Use Area":function(t){return t>=57344&&t<=63743},"CJK Compatibility Ideographs":function(t){return t>=63744&&t<=64255},"Arabic Presentation Forms-A":function(t){return t>=64336&&t<=65023},"Vertical Forms":function(t){return t>=65040&&t<=65055},"CJK Compatibility Forms":function(t){return t>=65072&&t<=65103},"Small Form Variants":function(t){return t>=65104&&t<=65135},"Arabic Presentation Forms-B":function(t){return t>=65136&&t<=65279},"Halfwidth and Fullwidth Forms":function(t){return t>=65280&&t<=65519}};function xr(t){for(var e=0,r=t;e=65097&&t<=65103)||yr["CJK Compatibility Ideographs"](t)||yr["CJK Compatibility"](t)||yr["CJK Radicals Supplement"](t)||yr["CJK Strokes"](t)||!(!yr["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||yr["CJK Unified Ideographs Extension A"](t)||yr["CJK Unified Ideographs"](t)||yr["Enclosed CJK Letters and Months"](t)||yr["Hangul Compatibility Jamo"](t)||yr["Hangul Jamo Extended-A"](t)||yr["Hangul Jamo Extended-B"](t)||yr["Hangul Jamo"](t)||yr["Hangul Syllables"](t)||yr.Hiragana(t)||yr["Ideographic Description Characters"](t)||yr.Kanbun(t)||yr["Kangxi Radicals"](t)||yr["Katakana Phonetic Extensions"](t)||yr.Katakana(t)&&12540!==t||!(!yr["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!yr["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||yr["Unified Canadian Aboriginal Syllabics"](t)||yr["Unified Canadian Aboriginal Syllabics Extended"](t)||yr["Vertical Forms"](t)||yr["Yijing Hexagram Symbols"](t)||yr["Yi Syllables"](t)||yr["Yi Radicals"](t)))}function wr(t){return!(_r(t)||function(t){return!!(yr["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||yr["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||yr["Letterlike Symbols"](t)||yr["Number Forms"](t)||yr["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||yr["Control Pictures"](t)&&9251!==t||yr["Optical Character Recognition"](t)||yr["Enclosed Alphanumerics"](t)||yr["Geometric Shapes"](t)||yr["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||yr["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||yr["CJK Symbols and Punctuation"](t)||yr.Katakana(t)||yr["Private Use Area"](t)||yr["CJK Compatibility Forms"](t)||yr["Small Form Variants"](t)||yr["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function kr(t,e){return!(!e&&(t>=1424&&t<=2303||yr["Arabic Presentation Forms-A"](t)||yr["Arabic Presentation Forms-B"](t))||t>=2304&&t<=3583||t>=3840&&t<=4255||yr.Khmer(t))}var Mr,Ar=!1,Tr=null,Sr=!1,Cr=new O,Er={applyArabicShaping:null,processBidirectionalText:null,isLoaded:function(){return Sr||null!=Er.applyArabicShaping}},Lr=function(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new mr,this.transition={})};Lr.prototype.isSupportedScript=function(t){return function(t,e){for(var r=0,n=t;rthis.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(e=1)return 1;var e=i*i,r=e*i;return 4*(i<.5?r:3*(i-e)+r-.75)}())}return r};var Dr=function(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)};Dr.prototype.possiblyEvaluate=function(t){for(var e=new Br(this._properties),r=0,n=Object.keys(this._values);rn.zoomHistory.lastIntegerZoom?{from:t,to:e,fromScale:2,toScale:1,t:a+(1-a)*o}:{from:r,to:e,fromScale:.5,toScale:1,t:1-(1-o)*a}},Vr.prototype.interpolate=function(t){return t};var Ur=function(t){this.specification=t};Ur.prototype.possiblyEvaluate=function(t,e){return!!t.expression.evaluate(e)},Ur.prototype.interpolate=function(){return!1};var qr=function(t){for(var e in this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},t){var r=t[e],n=this.defaultPropertyValues[e]=new zr(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new Or(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({})}};pr("DataDrivenProperty",jr),pr("DataConstantProperty",Nr),pr("CrossFadedProperty",Vr),pr("ColorRampProperty",Ur);var Hr=function(t){function e(e,r){for(var n in t.call(this),this.id=e.id,this.metadata=e.metadata,this.type=e.type,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,this.visibility="visible","background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),this._featureFilter=function(){return!0},r.layout&&(this._unevaluatedLayout=new Rr(r.layout)),this._transitionablePaint=new Ir(r.paint),e.paint)this.setPaintProperty(n,e.paint[n],{validate:!1});for(var i in e.layout)this.setLayoutProperty(i,e.layout[i],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getLayoutProperty=function(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)},e.prototype.setLayoutProperty=function(t,e,r){if(null!=e){var n="layers."+this.id+".layout."+t;if(this._validate(or,n,t,e,r))return}"visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility="none"===e?e:"visible"},e.prototype.getPaintProperty=function(t){return v(t,"-transition")?this._transitionablePaint.getTransition(t.slice(0,-"-transition".length)):this._transitionablePaint.getValue(t)},e.prototype.setPaintProperty=function(t,e,r){if(null!=e){var n="layers."+this.id+".paint."+t;if(this._validate(ar,n,t,e,r))return}v(t,"-transition")?this._transitionablePaint.setTransition(t.slice(0,-"-transition".length),e||void 0):this._transitionablePaint.setValue(t,e)},e.prototype.isHidden=function(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility},e.prototype.updateTransitions=function(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)},e.prototype.hasTransition=function(){return this._transitioningPaint.hasTransition()},e.prototype.recalculate=function(t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t)),this.paint=this._transitioningPaint.possiblyEvaluate(t)},e.prototype.serialize=function(){var t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return"none"===this.visibility&&(t.layout=t.layout||{},t.layout.visibility="none"),y(t,function(t,e){return!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)})},e.prototype._validate=function(t,e,r,n,i){return(!i||!1!==i.validate)&&sr(this,t.call(nr,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:I,style:{glyphs:!0,sprite:!0}}))},e.prototype.hasOffscreenPass=function(){return!1},e.prototype.resize=function(){},e}(O),Gr={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},Wr=function(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8},Yr=function(){this.isTransferred=!1,this.capacity=-1,this.resize(0)};function Xr(t,e){void 0===e&&(e=1);var r=0,n=0;return{members:t.map(function(t){var i,a=(i=t.type,Gr[i].BYTES_PER_ELEMENT),o=r=Zr(r,Math.max(e,a)),s=t.components||1;return n=Math.max(n,a),r+=a*s,{name:t.name,type:t.type,components:s,offset:o}}),size:Zr(r,Math.max(n,e)),alignment:e}}function Zr(t,e){return Math.ceil(t/e)*e}Yr.serialize=function(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}},Yr.deserialize=function(t){var e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e},Yr.prototype._trim=function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())},Yr.prototype.clear=function(){this.length=0},Yr.prototype.resize=function(t){this.reserve(t),this.length=t},Yr.prototype.reserve=function(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}},Yr.prototype._refreshViews=function(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")};var $r=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;this.resize(r+1);var n=2*r;return this.int16[n+0]=t,this.int16[n+1]=e,r},e}(Yr);$r.prototype.bytesPerElement=4,pr("StructArrayLayout2i4",$r);var Jr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n){var i=this.length;this.resize(i+1);var a=4*i;return this.int16[a+0]=t,this.int16[a+1]=e,this.int16[a+2]=r,this.int16[a+3]=n,i},e}(Yr);Jr.prototype.bytesPerElement=8,pr("StructArrayLayout4i8",Jr);var Kr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a){var o=this.length;this.resize(o+1);var s=6*o;return this.int16[s+0]=t,this.int16[s+1]=e,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=i,this.int16[s+5]=a,o},e}(Yr);Kr.prototype.bytesPerElement=12,pr("StructArrayLayout2i4i12",Kr);var Qr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s){var l=this.length;this.resize(l+1);var c=6*l,u=12*l;return this.int16[c+0]=t,this.int16[c+1]=e,this.int16[c+2]=r,this.int16[c+3]=n,this.uint8[u+8]=i,this.uint8[u+9]=a,this.uint8[u+10]=o,this.uint8[u+11]=s,l},e}(Yr);Qr.prototype.bytesPerElement=12,pr("StructArrayLayout4i4ub12",Qr);var tn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s){var l=this.length;this.resize(l+1);var c=8*l;return this.int16[c+0]=t,this.int16[c+1]=e,this.int16[c+2]=r,this.int16[c+3]=n,this.uint16[c+4]=i,this.uint16[c+5]=a,this.uint16[c+6]=o,this.uint16[c+7]=s,l},e}(Yr);tn.prototype.bytesPerElement=16,pr("StructArrayLayout4i4ui16",tn);var en=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;this.resize(n+1);var i=3*n;return this.float32[i+0]=t,this.float32[i+1]=e,this.float32[i+2]=r,n},e}(Yr);en.prototype.bytesPerElement=12,pr("StructArrayLayout3f12",en);var rn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;this.resize(e+1);var r=1*e;return this.uint32[r+0]=t,e},e}(Yr);rn.prototype.bytesPerElement=4,pr("StructArrayLayout1ul4",rn);var nn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s,l,c,u){var f=this.length;this.resize(f+1);var h=12*f,p=6*f;return this.int16[h+0]=t,this.int16[h+1]=e,this.int16[h+2]=r,this.int16[h+3]=n,this.int16[h+4]=i,this.int16[h+5]=a,this.uint32[p+3]=o,this.uint16[h+8]=s,this.uint16[h+9]=l,this.int16[h+10]=c,this.int16[h+11]=u,f},e}(Yr);nn.prototype.bytesPerElement=24,pr("StructArrayLayout6i1ul2ui2i24",nn);var an=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a){var o=this.length;this.resize(o+1);var s=6*o;return this.int16[s+0]=t,this.int16[s+1]=e,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=i,this.int16[s+5]=a,o},e}(Yr);an.prototype.bytesPerElement=12,pr("StructArrayLayout2i2i2i12",an);var on=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;this.resize(r+1);var n=4*r;return this.uint8[n+0]=t,this.uint8[n+1]=e,r},e}(Yr);on.prototype.bytesPerElement=4,pr("StructArrayLayout2ub4",on);var sn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s,l,c,u,f,h,p){var d=this.length;this.resize(d+1);var g=20*d,v=10*d,m=40*d;return this.int16[g+0]=t,this.int16[g+1]=e,this.uint16[g+2]=r,this.uint16[g+3]=n,this.uint32[v+2]=i,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[g+10]=s,this.uint16[g+11]=l,this.uint16[g+12]=c,this.float32[v+7]=u,this.float32[v+8]=f,this.uint8[m+36]=h,this.uint8[m+37]=p,d},e}(Yr);sn.prototype.bytesPerElement=40,pr("StructArrayLayout2i2ui3ul3ui2f2ub40",sn);var ln=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;this.resize(e+1);var r=1*e;return this.float32[r+0]=t,e},e}(Yr);ln.prototype.bytesPerElement=4,pr("StructArrayLayout1f4",ln);var cn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;this.resize(n+1);var i=3*n;return this.int16[i+0]=t,this.int16[i+1]=e,this.int16[i+2]=r,n},e}(Yr);cn.prototype.bytesPerElement=6,pr("StructArrayLayout3i6",cn);var un=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;this.resize(n+1);var i=2*n,a=4*n;return this.uint32[i+0]=t,this.uint16[a+2]=e,this.uint16[a+3]=r,n},e}(Yr);un.prototype.bytesPerElement=8,pr("StructArrayLayout1ul2ui8",un);var fn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;this.resize(n+1);var i=3*n;return this.uint16[i+0]=t,this.uint16[i+1]=e,this.uint16[i+2]=r,n},e}(Yr);fn.prototype.bytesPerElement=6,pr("StructArrayLayout3ui6",fn);var hn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;this.resize(r+1);var n=2*r;return this.uint16[n+0]=t,this.uint16[n+1]=e,r},e}(Yr);hn.prototype.bytesPerElement=4,pr("StructArrayLayout2ui4",hn);var pn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;this.resize(r+1);var n=2*r;return this.float32[n+0]=t,this.float32[n+1]=e,r},e}(Yr);pn.prototype.bytesPerElement=8,pr("StructArrayLayout2f8",pn);var dn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n){var i=this.length;this.resize(i+1);var a=4*i;return this.float32[a+0]=t,this.float32[a+1]=e,this.float32[a+2]=r,this.float32[a+3]=n,i},e}(Yr);dn.prototype.bytesPerElement=16,pr("StructArrayLayout4f16",dn);var gn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={anchorPointX:{configurable:!0},anchorPointY:{configurable:!0},x1:{configurable:!0},y1:{configurable:!0},x2:{configurable:!0},y2:{configurable:!0},featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0},radius:{configurable:!0},signedDistanceFromAnchor:{configurable:!0},anchorPoint:{configurable:!0}};return r.anchorPointX.get=function(){return this._structArray.int16[this._pos2+0]},r.anchorPointX.set=function(t){this._structArray.int16[this._pos2+0]=t},r.anchorPointY.get=function(){return this._structArray.int16[this._pos2+1]},r.anchorPointY.set=function(t){this._structArray.int16[this._pos2+1]=t},r.x1.get=function(){return this._structArray.int16[this._pos2+2]},r.x1.set=function(t){this._structArray.int16[this._pos2+2]=t},r.y1.get=function(){return this._structArray.int16[this._pos2+3]},r.y1.set=function(t){this._structArray.int16[this._pos2+3]=t},r.x2.get=function(){return this._structArray.int16[this._pos2+4]},r.x2.set=function(t){this._structArray.int16[this._pos2+4]=t},r.y2.get=function(){return this._structArray.int16[this._pos2+5]},r.y2.set=function(t){this._structArray.int16[this._pos2+5]=t},r.featureIndex.get=function(){return this._structArray.uint32[this._pos4+3]},r.featureIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},r.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+8]},r.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+8]=t},r.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+9]},r.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+9]=t},r.radius.get=function(){return this._structArray.int16[this._pos2+10]},r.radius.set=function(t){this._structArray.int16[this._pos2+10]=t},r.signedDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+11]},r.signedDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+11]=t},r.anchorPoint.get=function(){return new l(this.anchorPointX,this.anchorPointY)},Object.defineProperties(e.prototype,r),e}(Wr);gn.prototype.size=24;var vn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new gn(this,t)},e}(nn);pr("CollisionBoxArray",vn);var mn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={anchorX:{configurable:!0},anchorY:{configurable:!0},glyphStartIndex:{configurable:!0},numGlyphs:{configurable:!0},vertexStartIndex:{configurable:!0},lineStartIndex:{configurable:!0},lineLength:{configurable:!0},segment:{configurable:!0},lowerSize:{configurable:!0},upperSize:{configurable:!0},lineOffsetX:{configurable:!0},lineOffsetY:{configurable:!0},writingMode:{configurable:!0},hidden:{configurable:!0}};return r.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},r.anchorX.set=function(t){this._structArray.int16[this._pos2+0]=t},r.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},r.anchorY.set=function(t){this._structArray.int16[this._pos2+1]=t},r.glyphStartIndex.get=function(){return this._structArray.uint16[this._pos2+2]},r.glyphStartIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},r.numGlyphs.get=function(){return this._structArray.uint16[this._pos2+3]},r.numGlyphs.set=function(t){this._structArray.uint16[this._pos2+3]=t},r.vertexStartIndex.get=function(){return this._structArray.uint32[this._pos4+2]},r.vertexStartIndex.set=function(t){this._structArray.uint32[this._pos4+2]=t},r.lineStartIndex.get=function(){return this._structArray.uint32[this._pos4+3]},r.lineStartIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},r.lineLength.get=function(){return this._structArray.uint32[this._pos4+4]},r.lineLength.set=function(t){this._structArray.uint32[this._pos4+4]=t},r.segment.get=function(){return this._structArray.uint16[this._pos2+10]},r.segment.set=function(t){this._structArray.uint16[this._pos2+10]=t},r.lowerSize.get=function(){return this._structArray.uint16[this._pos2+11]},r.lowerSize.set=function(t){this._structArray.uint16[this._pos2+11]=t},r.upperSize.get=function(){return this._structArray.uint16[this._pos2+12]},r.upperSize.set=function(t){this._structArray.uint16[this._pos2+12]=t},r.lineOffsetX.get=function(){return this._structArray.float32[this._pos4+7]},r.lineOffsetX.set=function(t){this._structArray.float32[this._pos4+7]=t},r.lineOffsetY.get=function(){return this._structArray.float32[this._pos4+8]},r.lineOffsetY.set=function(t){this._structArray.float32[this._pos4+8]=t},r.writingMode.get=function(){return this._structArray.uint8[this._pos1+36]},r.writingMode.set=function(t){this._structArray.uint8[this._pos1+36]=t},r.hidden.get=function(){return this._structArray.uint8[this._pos1+37]},r.hidden.set=function(t){this._structArray.uint8[this._pos1+37]=t},Object.defineProperties(e.prototype,r),e}(Wr);mn.prototype.size=40;var yn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new mn(this,t)},e}(sn);pr("PlacedSymbolArray",yn);var xn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={offsetX:{configurable:!0}};return r.offsetX.get=function(){return this._structArray.float32[this._pos4+0]},r.offsetX.set=function(t){this._structArray.float32[this._pos4+0]=t},Object.defineProperties(e.prototype,r),e}(Wr);xn.prototype.size=4;var bn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getoffsetX=function(t){return this.float32[1*t+0]},e.prototype.get=function(t){return new xn(this,t)},e}(ln);pr("GlyphOffsetArray",bn);var _n=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={x:{configurable:!0},y:{configurable:!0},tileUnitDistanceFromAnchor:{configurable:!0}};return r.x.get=function(){return this._structArray.int16[this._pos2+0]},r.x.set=function(t){this._structArray.int16[this._pos2+0]=t},r.y.get=function(){return this._structArray.int16[this._pos2+1]},r.y.set=function(t){this._structArray.int16[this._pos2+1]=t},r.tileUnitDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+2]},r.tileUnitDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+2]=t},Object.defineProperties(e.prototype,r),e}(Wr);_n.prototype.size=6;var wn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getx=function(t){return this.int16[3*t+0]},e.prototype.gety=function(t){return this.int16[3*t+1]},e.prototype.gettileUnitDistanceFromAnchor=function(t){return this.int16[3*t+2]},e.prototype.get=function(t){return new _n(this,t)},e}(cn);pr("SymbolLineVertexArray",wn);var kn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0}};return r.featureIndex.get=function(){return this._structArray.uint32[this._pos4+0]},r.featureIndex.set=function(t){this._structArray.uint32[this._pos4+0]=t},r.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+2]},r.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},r.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+3]},r.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+3]=t},Object.defineProperties(e.prototype,r),e}(Wr);kn.prototype.size=8;var Mn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new kn(this,t)},e}(un);pr("FeatureIndexArray",Mn);var An=Xr([{name:"a_pos",components:2,type:"Int16"}],4).members,Tn=function(t){void 0===t&&(t=[]),this.segments=t};Tn.prototype.prepareSegment=function(t,e,r){var n=this.segments[this.segments.length-1];return t>Tn.MAX_VERTEX_ARRAY_LENGTH&&_("Max vertices per segment is "+Tn.MAX_VERTEX_ARRAY_LENGTH+": bucket requested "+t),(!n||n.vertexLength+t>Tn.MAX_VERTEX_ARRAY_LENGTH)&&(n={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},this.segments.push(n)),n},Tn.prototype.get=function(){return this.segments},Tn.prototype.destroy=function(){for(var t=0,e=this.segments;tRn.max||o.yRn.max)&&_("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return r}function Bn(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2)}var Nn=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(function(t){return t.id}),this.index=t.index,this.layoutVertexArray=new $r,this.indexArray=new fn,this.segments=new Tn,this.programConfigurations=new In(An,t.layers,t.zoom)};function jn(t,e,r){for(var n=0;n=3)for(var s=0;s1){if(Hn(t,e))return!0;for(var n=0;n1?t.distSqr(r):t.distSqr(r.sub(e)._mult(i)._add(e))}function Xn(t,e){for(var r,n,i,a=!1,o=0;oe.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(a=!a);return a}function Zn(t,e){for(var r=!1,n=0,i=t.length-1;ne.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}function $n(t,e,r){var n=e.paint.get(t).value;return"constant"===n.kind?n.value:r.programConfigurations.get(e.id).binders[t].statistics.max}function Jn(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Kn(t,e,r,n,i){if(!e[0]&&!e[1])return t;var a=l.convert(e);"viewport"===r&&a._rotate(-n);for(var o=[],s=0;s=Dn||l<0||l>=Dn)){var c=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray),u=c.vertexLength;Bn(this.layoutVertexArray,s,l,-1,-1),Bn(this.layoutVertexArray,s,l,1,-1),Bn(this.layoutVertexArray,s,l,1,1),Bn(this.layoutVertexArray,s,l,-1,1),this.indexArray.emplaceBack(u,u+1,u+2),this.indexArray.emplaceBack(u,u+3,u+2),c.vertexLength+=4,c.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t)},pr("CircleBucket",Nn,{omit:["layers"]});var Qn={paint:new qr({"circle-radius":new jr(I.paint_circle["circle-radius"]),"circle-color":new jr(I.paint_circle["circle-color"]),"circle-blur":new jr(I.paint_circle["circle-blur"]),"circle-opacity":new jr(I.paint_circle["circle-opacity"]),"circle-translate":new Nr(I.paint_circle["circle-translate"]),"circle-translate-anchor":new Nr(I.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Nr(I.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Nr(I.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new jr(I.paint_circle["circle-stroke-width"]),"circle-stroke-color":new jr(I.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new jr(I.paint_circle["circle-stroke-opacity"])})},ti=i(function(t,e){var r;t.exports=((r=new Float32Array(3))[0]=0,r[1]=0,r[2]=0,function(){var t=new Float32Array(4);t[0]=0,t[1]=0,t[2]=0,t[3]=0}(),{vec3:{transformMat3:function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}},vec4:{transformMat4:function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}},mat2:{create:function(){var t=new Float32Array(4);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},rotate:function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l+a*s,t[1]=i*l+o*s,t[2]=n*-s+a*l,t[3]=i*-s+o*l,t},scale:function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=r[0],l=r[1];return t[0]=n*s,t[1]=i*s,t[2]=a*l,t[3]=o*l,t}},mat3:{create:function(){var t=new Float32Array(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fromRotation:function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}},mat4:{create:function(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},translate:function(t,e,r){var n,i,a,o,s,l,c,u,f,h,p,d,g=r[0],v=r[1],m=r[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],p=e[10],d=e[11],t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=f,t[9]=h,t[10]=p,t[11]=d,t[12]=n*g+s*v+f*m+e[12],t[13]=i*g+l*v+h*m+e[13],t[14]=a*g+c*v+p*m+e[14],t[15]=o*g+u*v+d*m+e[15]),t},scale:function(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},multiply:function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],p=e[10],d=e[11],g=e[12],v=e[13],m=e[14],y=e[15],x=r[0],b=r[1],_=r[2],w=r[3];return t[0]=x*n+b*s+_*f+w*g,t[1]=x*i+b*l+_*h+w*v,t[2]=x*a+b*c+_*p+w*m,t[3]=x*o+b*u+_*d+w*y,x=r[4],b=r[5],_=r[6],w=r[7],t[4]=x*n+b*s+_*f+w*g,t[5]=x*i+b*l+_*h+w*v,t[6]=x*a+b*c+_*p+w*m,t[7]=x*o+b*u+_*d+w*y,x=r[8],b=r[9],_=r[10],w=r[11],t[8]=x*n+b*s+_*f+w*g,t[9]=x*i+b*l+_*h+w*v,t[10]=x*a+b*c+_*p+w*m,t[11]=x*o+b*u+_*d+w*y,x=r[12],b=r[13],_=r[14],w=r[15],t[12]=x*n+b*s+_*f+w*g,t[13]=x*i+b*l+_*h+w*v,t[14]=x*a+b*c+_*p+w*m,t[15]=x*o+b*u+_*d+w*y,t},perspective:function(t,e,r,n,i){var a=1/Math.tan(e/2),o=1/(n-i);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*o,t[15]=0,t},rotateX:function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+c*n,t[5]=o*i+u*n,t[6]=s*i+f*n,t[7]=l*i+h*n,t[8]=c*i-a*n,t[9]=u*i-o*n,t[10]=f*i-s*n,t[11]=h*i-l*n,t},rotateZ:function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+c*n,t[1]=o*i+u*n,t[2]=s*i+f*n,t[3]=l*i+h*n,t[4]=c*i-a*n,t[5]=u*i-o*n,t[6]=f*i-s*n,t[7]=h*i-l*n,t},invert:function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=e[9],h=e[10],p=e[11],d=e[12],g=e[13],v=e[14],m=e[15],y=r*s-n*o,x=r*l-i*o,b=r*c-a*o,_=n*l-i*s,w=n*c-a*s,k=i*c-a*l,M=u*g-f*d,A=u*v-h*d,T=u*m-p*d,S=f*v-h*g,C=f*m-p*g,E=h*m-p*v,L=y*E-x*C+b*S+_*T-w*A+k*M;return L?(L=1/L,t[0]=(s*E-l*C+c*S)*L,t[1]=(i*C-n*E-a*S)*L,t[2]=(g*k-v*w+m*_)*L,t[3]=(h*w-f*k-p*_)*L,t[4]=(l*T-o*E-c*A)*L,t[5]=(r*E-i*T+a*A)*L,t[6]=(v*b-d*k-m*x)*L,t[7]=(u*k-h*b+p*x)*L,t[8]=(o*C-s*T+c*M)*L,t[9]=(n*T-r*C-a*M)*L,t[10]=(d*w-g*b+m*y)*L,t[11]=(f*b-u*w-p*y)*L,t[12]=(s*A-o*S-l*M)*L,t[13]=(r*S-n*A+i*M)*L,t[14]=(g*x-d*_-v*y)*L,t[15]=(u*_-f*x+h*y)*L,t):null},ortho:function(t,e,r,n,i,a,o){var s=1/(e-r),l=1/(n-i),c=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*l,t[14]=(o+a)*c,t[15]=1,t}}})}),ei=(ti.vec3,ti.vec4),ri=(ti.mat2,ti.mat3,ti.mat4),ni=function(t){function e(e){t.call(this,e,Qn)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createBucket=function(t){return new Nn(t)},e.prototype.queryRadius=function(t){var e=t;return $n("circle-radius",this,e)+$n("circle-stroke-width",this,e)+Jn(this.paint.get("circle-translate"))},e.prototype.queryIntersectsFeature=function(t,e,r,n,i,a,o){for(var s=Kn(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),i.angle,a),l=this.paint.get("circle-radius").evaluate(e)+this.paint.get("circle-stroke-width").evaluate(e),c="map"===this.paint.get("circle-pitch-alignment"),u=c?s:function(t,e,r){return s.map(function(t){return t.map(function(t){return ii(t,e,r)})})}(0,o,i),f=c?l*a:l,h=0,p=r;ht.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=t.data,s=e.data,l=0;l80*r){n=a=t[0],i=o=t[1];for(var d=r;da&&(a=s),l>o&&(o=l);c=0!==(c=Math.max(a-n,o-i))?1/c:0}return wi(h,p,r,n,i,c),p}function bi(t,e,r,n,i){var a,o;if(i===Vi(t,e,r,n)>0)for(a=e;a=e;a-=n)o=Bi(a,t[a],t[a+1],o);return o&&Pi(o,o.next)&&(Ni(o),o=o.next),o}function _i(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!Pi(n,n.next)&&0!==Ii(n.prev,n,n.next))n=n.next;else{if(Ni(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function wi(t,e,r,n,i,a,o){if(t){!o&&a&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=Ei(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,o,s,l,c=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,c*=2}while(o>1)}(i)}(t,n,i,a);for(var s,l,c=t;t.prev!==t.next;)if(s=t.prev,l=t.next,a?Mi(t,n,i,a):ki(t))e.push(s.i/r),e.push(t.i/r),e.push(l.i/r),Ni(t),t=l.next,c=l.next;else if((t=l)===c){o?1===o?wi(t=Ai(t,e,r),e,r,n,i,a,2):2===o&&Ti(t,e,r,n,i,a):wi(_i(t),e,r,n,i,a,1);break}}}function ki(t){var e=t.prev,r=t,n=t.next;if(Ii(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(zi(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&Ii(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Mi(t,e,r,n){var i=t.prev,a=t,o=t.next;if(Ii(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,f=Ei(s,l,e,r,n),h=Ei(c,u,e,r,n),p=t.prevZ,d=t.nextZ;p&&p.z>=f&&d&&d.z<=h;){if(p!==t.prev&&p!==t.next&&zi(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Ii(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,d!==t.prev&&d!==t.next&&zi(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Ii(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;p&&p.z>=f;){if(p!==t.prev&&p!==t.next&&zi(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Ii(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;d&&d.z<=h;){if(d!==t.prev&&d!==t.next&&zi(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Ii(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Ai(t,e,r){var n=t;do{var i=n.prev,a=n.next.next;!Pi(i,a)&&Di(i,n,n.next,a)&&Ri(i,a)&&Ri(a,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(a.i/r),Ni(n),Ni(n.next),n=t=a),n=n.next}while(n!==t);return n}function Ti(t,e,r,n,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Oi(o,s)){var l=Fi(o,s);return o=_i(o,o.next),l=_i(l,l.next),wi(o,e,r,n,i,a),void wi(l,e,r,n,i,a)}s=s.next}o=o.next}while(o!==t)}function Si(t,e){return t.x-e.x}function Ci(t,e){if(e=function(t,e){var r,n=e,i=t.x,a=t.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=u&&i!==n.x&&zi(ar.x)&&Ri(n,t)&&(r=n,h=l),n=n.next;return r}(t,e)){var r=Fi(e,t);_i(r,r.next)}}function Ei(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Li(t){var e=t,r=t;do{e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function Oi(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Di(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&Ri(t,e)&&Ri(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)}function Ii(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Pi(t,e){return t.x===e.x&&t.y===e.y}function Di(t,e,r,n){return!!(Pi(t,e)&&Pi(r,n)||Pi(t,n)&&Pi(r,e))||Ii(t,e,r)>0!=Ii(t,e,n)>0&&Ii(r,n,t)>0!=Ii(r,n,e)>0}function Ri(t,e){return Ii(t.prev,t,t.next)<0?Ii(t,e,t.next)>=0&&Ii(t,t.prev,e)>=0:Ii(t,e,t.prev)<0||Ii(t,t.next,e)<0}function Fi(t,e){var r=new ji(t.i,t.x,t.y),n=new ji(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function Bi(t,e,r,n){var i=new ji(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ni(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ji(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Vi(t,e,r,n){for(var i=0,a=e,o=r-n;a0&&(n+=t[i-1].length,r.holes.push(n))}return r},mi.default=yi;var Ui=Hi,qi=Hi;function Hi(t,e,r,n,i){!function t(e,r,n,i,a){for(;i>n;){if(i-n>600){var o=i-n+1,s=r-n+1,l=Math.log(o),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(o-c)/o)*(s-o/2<0?-1:1);t(e,r,Math.max(n,Math.floor(r-s*c/o+u)),Math.min(i,Math.floor(r+(o-s)*c/o+u)),a)}var f=e[r],h=n,p=i;for(Gi(e,n,r),a(e[i],f)>0&&Gi(e,n,i);h0;)p--}0===a(e[n],f)?Gi(e,n,p):Gi(e,++p,i),p<=r&&(n=p+1),r<=p&&(i=p-1)}}(t,e,r||0,n||t.length-1,i||Wi)}function Gi(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Wi(t,e){return te?1:0}function Yi(t,e){var r=t.length;if(r<=1)return[t];for(var n,i,a=[],o=0;o1)for(var l=0;lDn)||t.y===e.y&&(t.y<0||t.y>Dn)}function na(t){return t.every(function(t){return t.x<0})||t.every(function(t){return t.x>Dn})||t.every(function(t){return t.y<0})||t.every(function(t){return t.y>Dn})}ea.prototype.populate=function(t,e){for(var r=0,n=t;r=1){var g=f[p-1];if(!ra(d,g)){l.vertexLength+4>Tn.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));var v=d.sub(g)._perp()._unit(),m=g.dist(d);h+m>32768&&(h=0),ta(this.layoutVertexArray,d.x,d.y,v.x,v.y,0,0,h),ta(this.layoutVertexArray,d.x,d.y,v.x,v.y,0,1,h),h+=m,ta(this.layoutVertexArray,g.x,g.y,v.x,v.y,0,0,h),ta(this.layoutVertexArray,g.x,g.y,v.x,v.y,0,1,h);var y=l.vertexLength;this.indexArray.emplaceBack(y,y+1,y+2),this.indexArray.emplaceBack(y+1,y+2,y+3),l.vertexLength+=4,l.primitiveLength+=2}}}}l.vertexLength+a>Tn.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(a,this.layoutVertexArray,this.indexArray));for(var x=[],b=[],_=l.vertexLength,w=0,k=i;w>3}if(i--,1===n||2===n)a+=t.readSVarint(),o+=t.readSVarint(),1===n&&(e&&s.push(e),e=[]),e.push(new l(a,o));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&s.push(e),s},la.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,o=1/0,s=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===r||2===r)(i+=t.readSVarint())s&&(s=i),(a+=t.readSVarint())c&&(c=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,s,c]},la.prototype.toGeoJSON=function(t,e,r){var n,i,a=this.extent*Math.pow(2,r),o=this.extent*t,s=this.extent*e,l=this.loadGeometry(),c=la.types[this.type];function u(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}function da(t,e,r){if(3===t){var n=new fa(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n)}}ha.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new sa(this._pbf,e,this.extent,this._keys,this._values)};var ga={VectorTile:function(t,e){this.layers=t.readFields(da,{},e)},VectorTileFeature:sa,VectorTileLayer:fa},va=ga.VectorTileFeature.types,ma=63,ya=Math.cos(Math.PI/180*37.5),xa=.5,ba=Math.pow(2,14)/xa;function _a(t,e,r,n,i,a,o){t.emplaceBack(e.x,e.y,n?1:0,i?1:-1,Math.round(ma*r.x)+128,Math.round(ma*r.y)+128,1+(0===a?0:a<0?-1:1)|(o*xa&63)<<2,o*xa>>6)}var wa=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(function(t){return t.id}),this.index=t.index,this.layoutVertexArray=new Qr,this.indexArray=new fn,this.programConfigurations=new In(oa,t.layers,t.zoom),this.segments=new Tn};function ka(t,e){return(t/e.tileTotal*(e.end-e.start)+e.start)*(ba-1)}wa.prototype.populate=function(t,e){for(var r=0,n=t;r=2&&t[l-1].equals(t[l-2]);)l--;for(var c=0;cc){var C=p.dist(x);if(C>2*u){var E=p.sub(p.sub(x)._mult(u/C)._round());this.distance+=E.dist(x),this.addCurrentVertex(E,this.distance,_.mult(1),0,0,!1,h,o),x=E}}var L=x&&b,z=L?r:b?v:m;if(L&&"round"===z&&(Ti&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)M=w.clone().mult(-1);else{var O=_.x*w.y-_.y*w.x>0?-1:1,I=T*_.add(w).mag()/_.sub(w).mag();M._perp()._mult(I*O)}this.addCurrentVertex(p,this.distance,M,0,0,!1,h,o),this.addCurrentVertex(p,this.distance,M.mult(-1),0,0,!1,h,o)}else if("bevel"===z||"fakeround"===z){var P=_.x*w.y-_.y*w.x>0,D=-Math.sqrt(T*T-1);if(P?(g=0,d=D):(d=0,g=D),y||this.addCurrentVertex(p,this.distance,_,d,g,!1,h,o),"fakeround"===z){for(var R=Math.floor(8*(.5-(A-.5))),F=void 0,B=0;B=0;N--)F=_.mult((N+1)/(R+1))._add(w)._unit(),this.addPieSliceVertex(p,this.distance,F,P,h,o)}b&&this.addCurrentVertex(p,this.distance,w,-d,-g,!1,h,o)}else"butt"===z?(y||this.addCurrentVertex(p,this.distance,_,0,0,!1,h,o),b&&this.addCurrentVertex(p,this.distance,w,0,0,!1,h,o)):"square"===z?(y||(this.addCurrentVertex(p,this.distance,_,1,1,!1,h,o),this.e1=this.e2=-1),b&&this.addCurrentVertex(p,this.distance,w,-1,-1,!1,h,o)):"round"===z&&(y||(this.addCurrentVertex(p,this.distance,_,0,0,!1,h,o),this.addCurrentVertex(p,this.distance,_,1,1,!0,h,o),this.e1=this.e2=-1),b&&(this.addCurrentVertex(p,this.distance,w,-1,-1,!0,h,o),this.addCurrentVertex(p,this.distance,w,0,0,!1,h,o)));if(S&&k2*u){var V=p.add(b.sub(p)._mult(u/j)._round());this.distance+=V.dist(p),this.addCurrentVertex(V,this.distance,w.mult(1),0,0,!1,h,o),p=V}}y=!1}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e)}},wa.prototype.addCurrentVertex=function(t,e,r,n,i,a,o,s){var l,c=this.layoutVertexArray,u=this.indexArray;s&&(e=ka(e,s)),l=r.clone(),n&&l._sub(r.perp()._mult(n)),_a(c,t,l,a,!1,n,e),this.e3=o.vertexLength++,this.e1>=0&&this.e2>=0&&(u.emplaceBack(this.e1,this.e2,this.e3),o.primitiveLength++),this.e1=this.e2,this.e2=this.e3,l=r.mult(-1),i&&l._sub(r.perp()._mult(i)),_a(c,t,l,a,!0,-i,e),this.e3=o.vertexLength++,this.e1>=0&&this.e2>=0&&(u.emplaceBack(this.e1,this.e2,this.e3),o.primitiveLength++),this.e1=this.e2,this.e2=this.e3,e>ba/2&&!s&&(this.distance=0,this.addCurrentVertex(t,this.distance,r,n,i,a,o))},wa.prototype.addPieSliceVertex=function(t,e,r,n,i,a){r=r.mult(n?-1:1);var o=this.layoutVertexArray,s=this.indexArray;a&&(e=ka(e,a)),_a(o,t,r,!1,n,0,e),this.e3=i.vertexLength++,this.e1>=0&&this.e2>=0&&(s.emplaceBack(this.e1,this.e2,this.e3),i.primitiveLength++),n?this.e2=this.e3:this.e1=this.e3},pr("LineBucket",wa,{omit:["layers"]});var Ma=new qr({"line-cap":new Nr(I.layout_line["line-cap"]),"line-join":new jr(I.layout_line["line-join"]),"line-miter-limit":new Nr(I.layout_line["line-miter-limit"]),"line-round-limit":new Nr(I.layout_line["line-round-limit"])}),Aa={paint:new qr({"line-opacity":new jr(I.paint_line["line-opacity"]),"line-color":new jr(I.paint_line["line-color"]),"line-translate":new Nr(I.paint_line["line-translate"]),"line-translate-anchor":new Nr(I.paint_line["line-translate-anchor"]),"line-width":new jr(I.paint_line["line-width"]),"line-gap-width":new jr(I.paint_line["line-gap-width"]),"line-offset":new jr(I.paint_line["line-offset"]),"line-blur":new jr(I.paint_line["line-blur"]),"line-dasharray":new Vr(I.paint_line["line-dasharray"]),"line-pattern":new Vr(I.paint_line["line-pattern"]),"line-gradient":new Ur(I.paint_line["line-gradient"])}),layout:Ma},Ta=new(function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.possiblyEvaluate=function(e,r){return r=new Lr(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),t.prototype.possiblyEvaluate.call(this,e,r)},e.prototype.evaluate=function(e,r,n){return r=p({},r,{zoom:Math.floor(r.zoom)}),t.prototype.evaluate.call(this,e,r,n)},e}(jr))(Aa.paint.properties["line-width"].specification);Ta.useIntegerZoom=!0;var Sa=function(t){function e(e){t.call(this,e,Aa)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setPaintProperty=function(e,r,n){t.prototype.setPaintProperty.call(this,e,r,n),"line-gradient"===e&&this._updateGradient()},e.prototype._updateGradient=function(){var t=this._transitionablePaint._values["line-gradient"].value.expression;this.gradient=hi(t,"lineProgress"),this.gradientTexture=null},e.prototype.recalculate=function(e){t.prototype.recalculate.call(this,e),this.paint._values["line-floorwidth"]=Ta.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)},e.prototype.createBucket=function(t){return new wa(t)},e.prototype.queryRadius=function(t){var e=t,r=Ca($n("line-width",this,e),$n("line-gap-width",this,e)),n=$n("line-offset",this,e);return r/2+Math.abs(n)+Jn(this.paint.get("line-translate"))},e.prototype.queryIntersectsFeature=function(t,e,r,n,i,a){var o=Kn(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),i.angle,a),s=a/2*Ca(this.paint.get("line-width").evaluate(e),this.paint.get("line-gap-width").evaluate(e)),c=this.paint.get("line-offset").evaluate(e);return c&&(r=function(t,e){for(var r=[],n=new l(0,0),i=0;i0?e+2*t:t}var Ea=Xr([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"}]),La=Xr([{name:"a_projected_pos",components:3,type:"Float32"}],4),za=(Xr([{name:"a_fade_opacity",components:1,type:"Uint32"}],4),Xr([{name:"a_placed",components:2,type:"Uint8"}],4)),Oa=(Xr([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"},{type:"Int16",name:"radius"},{type:"Int16",name:"signedDistanceFromAnchor"}]),Xr([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4)),Ia=Xr([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);function Pa(t,e,r){var n=e.layout.get("text-transform").evaluate(r);return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Er.applyArabicShaping&&(t=Er.applyArabicShaping(t)),t}Xr([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"hidden"}]),Xr([{type:"Float32",name:"offsetX"}]),Xr([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Da={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42"},Ra=function(t){function e(e,r,n,i){t.call(this,e,r),this.angle=n,void 0!==i&&(this.segment=i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.clone=function(){return new e(this.x,this.y,this.angle,this.segment)},e}(l);function Fa(t,e){var r=e.expression;if("constant"===r.kind)return{functionType:"constant",layoutSize:r.evaluate(new Lr(t+1))};if("source"===r.kind)return{functionType:"source"};for(var n=r.zoomStops,i=0;i0)&&("constant"!==i.value.kind||i.value.value.length>0),l="constant"!==o.value.kind||o.value.value&&o.value.value.length>0;if(this.features=[],s||l){for(var c=e.iconDependencies,u=e.glyphDependencies,f=new Lr(this.zoom),h=0,p=t;h=0;s--)a[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:i},s>0&&(i+=e[s-1].dist(e[s]));for(var l=0;l0;this.addCollisionDebugVertices(s,l,c,u,f?this.collisionCircle:this.collisionBox,o.anchorPoint,r,f)}}}},Ha.prototype.deserializeCollisionBoxes=function(t,e,r,n,i){for(var a={},o=e;o0},Ha.prototype.hasIconData=function(){return this.icon.segments.get().length>0},Ha.prototype.hasCollisionBoxData=function(){return this.collisionBox.segments.get().length>0},Ha.prototype.hasCollisionCircleData=function(){return this.collisionCircle.segments.get().length>0},Ha.prototype.sortFeatures=function(t){var e=this;if(this.sortFeaturesByY&&this.sortedAngle!==t&&(this.sortedAngle=t,!(this.text.segments.get().length>1||this.icon.segments.get().length>1))){for(var r=[],n=0;ni.maxh||t>i.maxw||r<=i.maxh&&t<=i.maxw&&(o=i.maxw*i.maxh-t*r)a.free)){if(r===a.h)return this.allocShelf(s,t,r,n);r>a.h||ru)&&(f=2*Math.max(t,u)),(ll)&&(c=2*Math.max(r,l)),this.resize(f,c),this.packOne(t,r,n)):null},t.prototype.allocFreebin=function(t,e,r,n){var i=this.freebins.splice(t,1)[0];return i.id=n,i.w=e,i.h=r,i.refcount=0,this.bins[n]=i,this.ref(i),i},t.prototype.allocShelf=function(t,e,r,n){var i=this.shelves[t].alloc(e,r,n);return this.bins[n]=i,this.ref(i),i},t.prototype.shrink=function(){if(this.shelves.length>0){for(var t=0,e=0,r=0;rthis.free||e>this.h)return null;var n=this.x;return this.x+=t,this.free-=t,new function(t,e,r,n,i,a,o){this.id=t,this.x=e,this.y=r,this.w=n,this.h=i,this.maxw=a||n,this.maxh=o||i,this.refcount=0}(r,n,this.y,t,e,t,this.h)},e.prototype.resize=function(t){return this.free+=t-this.w,this.w=t,!0},t}()}),Qa=function(t,e){var r=e.pixelRatio;this.paddedRect=t,this.pixelRatio=r},to={tl:{configurable:!0},br:{configurable:!0},displaySize:{configurable:!0}};to.tl.get=function(){return[this.paddedRect.x+1,this.paddedRect.y+1]},to.br.get=function(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]},to.displaySize.get=function(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]},Object.defineProperties(Qa.prototype,to);var eo=function(t){var e=new ui({width:0,height:0}),r={},n=new Ka(0,0,{autoResize:!0});for(var i in t){var a=t[i],o=n.packOne(a.data.width+2,a.data.height+2);e.resize({width:n.w,height:n.h}),ui.copy(a.data,e,{x:0,y:0},{x:o.x+1,y:o.y+1},a.data),r[i]=new Qa(o,a)}n.shrink(),e.resize({width:n.w,height:n.h}),this.image=e,this.positions=r};pr("ImagePosition",Qa),pr("ImageAtlas",eo);var ro=function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+t[e+f],f+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),a-=c}return(p?-1:1)*o*Math.pow(2,a-n)},no=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(o++,l/=2),o+f>=u?(s=0,o=u):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*g},io=ao;function ao(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}function oo(t){return t.type===ao.Bytes?t.readVarint()+t.pos:t.pos+1}function so(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function lo(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i]}function co(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function _o(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}ao.Varint=0,ao.Fixed64=1,ao.Bytes=2,ao.Fixed32=5,ao.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=xo(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=_o(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=xo(this.buf,this.pos)+4294967296*xo(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=xo(this.buf,this.pos)+4294967296*_o(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=ro(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ro(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,a=r.buf;if(n=(112&(i=a[r.pos++]))>>4,i<128)return so(t,n,e);if(n|=(127&(i=a[r.pos++]))<<3,i<128)return so(t,n,e);if(n|=(127&(i=a[r.pos++]))<<10,i<128)return so(t,n,e);if(n|=(127&(i=a[r.pos++]))<<17,i<128)return so(t,n,e);if(n|=(127&(i=a[r.pos++]))<<24,i<128)return so(t,n,e);if(n|=(1&(i=a[r.pos++]))<<31,i<128)return so(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+u>r)break;1===u?l<128&&(c=l):2===u?128==(192&(a=t[i+1]))&&(c=(31&l)<<6|63&a)<=127&&(c=null):3===u?(a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&((c=(15&l)<<12|(63&a)<<6|63&o)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((c=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),i+=u}return n}(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){var r=oo(this);for(t=t||[];this.pos127;);else if(e===ao.Bytes)this.pos=this.readVarint()+this.pos;else if(e===ao.Fixed32)this.pos+=4;else{if(e!==ao.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos]=127&t}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,a=0;a55295&&n<57344){if(!i){n>56319||a+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&lo(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),no(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),no(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&lo(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,ao.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){this.writeMessage(t,co,e)},writePackedSVarint:function(t,e){this.writeMessage(t,uo,e)},writePackedBoolean:function(t,e){this.writeMessage(t,po,e)},writePackedFloat:function(t,e){this.writeMessage(t,fo,e)},writePackedDouble:function(t,e){this.writeMessage(t,ho,e)},writePackedFixed32:function(t,e){this.writeMessage(t,go,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,vo,e)},writePackedFixed64:function(t,e){this.writeMessage(t,mo,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,yo,e)},writeBytesField:function(t,e){this.writeTag(t,ao.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,ao.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,ao.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,ao.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,ao.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,ao.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,ao.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,ao.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,ao.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,ao.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var wo=3;function ko(t,e,r){1===t&&r.readMessage(Mo,e)}function Mo(t,e,r){if(3===t){var n=r.readMessage(Ao,{}),i=n.id,a=n.bitmap,o=n.width,s=n.height,l=n.left,c=n.top,u=n.advance;e.push({id:i,bitmap:new ci({width:o+2*wo,height:s+2*wo},a),metrics:{width:o,height:s,left:l,top:c,advance:u}})}}function Ao(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint())}var To=wo,So=function(t,e,r){this.target=t,this.parent=e,this.mapId=r,this.callbacks={},this.callbackID=0,g(["receive"],this),this.target.addEventListener("message",this.receive,!1)};So.prototype.send=function(t,e,r,n){var i=r?this.mapId+":"+this.callbackID++:null;r&&(this.callbacks[i]=r);var a=[];this.target.postMessage({targetMapId:n,sourceMapId:this.mapId,type:t,id:String(i),data:gr(e,a)},a)},So.prototype.receive=function(t){var e,r=this,n=t.data,i=n.id;if(!n.targetMapId||this.mapId===n.targetMapId){var a=function(t,e){var n=[];r.target.postMessage({sourceMapId:r.mapId,type:"",id:String(i),error:t?gr(t):null,data:gr(e,n)},n)};if(""===n.type)e=this.callbacks[n.id],delete this.callbacks[n.id],e&&n.error?e(vr(n.error)):e&&e(null,vr(n.data));else if(void 0!==n.id&&this.parent[n.type])this.parent[n.type](n.sourceMapId,vr(n.data),a);else if(void 0!==n.id&&this.parent.getWorkerSource){var o=n.type.split(".");this.parent.getWorkerSource(n.sourceMapId,o[0],o[1])[o[2]](vr(n.data),a)}else this.parent[n.type](vr(n.data))}},So.prototype.remove=function(){this.target.removeEventListener("message",this.receive,!1)};var Co=n(i(function(t,e){!function(t){function e(t,e,n){var i=r(256*t,256*(e=Math.pow(2,n)-e-1),n),a=r(256*(t+1),256*(e+1),n);return i[0]+","+i[1]+","+a[0]+","+a[1]}function r(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}t.getURL=function(t,r,n,i,a,o){return o=o||{},t+"?"+["bbox="+e(n,i,a),"format="+(o.format||"image/png"),"service="+(o.service||"WMS"),"version="+(o.version||"1.1.1"),"request="+(o.request||"GetMap"),"srs="+(o.srs||"EPSG:3857"),"width="+(o.width||256),"height="+(o.height||256),"layers="+r].join("&")},t.getTileBBox=e,t.getMercCoords=r,Object.defineProperty(t,"__esModule",{value:!0})}(e)})),Eo=function(t,e,r){this.z=t,this.x=e,this.y=r,this.key=Oo(0,t,e,r)};Eo.prototype.equals=function(t){return this.z===t.z&&this.x===t.x&&this.y===t.y},Eo.prototype.url=function(t,e){var r=Co.getTileBBox(this.x,this.y,this.z),n=function(t,e,r){for(var n,i="",a=t;a>0;a--)i+=(e&(n=1<this.canonical.z?new zo(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new zo(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)},zo.prototype.isChildOf=function(t){var e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e},zo.prototype.children=function(t){if(this.overscaledZ>=t)return[new zo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return[new zo(e,this.wrap,e,r,n),new zo(e,this.wrap,e,r+1,n),new zo(e,this.wrap,e,r,n+1),new zo(e,this.wrap,e,r+1,n+1)]},zo.prototype.isLessThan=function(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=this.dim+this.border||e<-this.border||e>=this.dim+this.border)throw new RangeError("out of range source coordinates for DEM data");return(e+this.border)*this.stride+(t+this.border)},pr("Level",Io);var Po=function(t,e,r){this.uid=t,this.scale=e||1,this.level=r||new Io(256,512),this.loaded=!!r};Po.prototype.loadFromImage=function(t,e){if(t.height!==t.width)throw new RangeError("DEM tiles must be square");if(e&&"mapbox"!==e&&"terrarium"!==e)return _('"'+e+'" is not a valid encoding type. Valid types include "mapbox" and "terrarium".');var r=this.level=new Io(t.width,t.width/2),n=t.data;this._unpackData(r,n,e||"mapbox");for(var i=0;i=0&&l[3]>=0&&this.grid.insert(a,l[0],l[1],l[2],l[3])}},Bo.prototype.loadVTLayers=function(){return this.vtLayers||(this.vtLayers=new ga.VectorTile(new io(this.rawTileData)).layers,this.sourceLayerCoder=new Do(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers},Bo.prototype.query=function(t,e){var r=this;this.loadVTLayers();for(var n=t.params||{},i=Dn/t.tileSize/t.scale,a=Re(n.filter),o=t.queryGeometry,s=t.queryPadding*i,l=1/0,c=1/0,u=-1/0,f=-1/0,h=0;h=0)return!0;return!1}(a,l)){var c=this.sourceLayerCoder.decode(r),u=this.vtLayers[c].feature(n);if(i(new Lr(this.tileID.overscaledZ),u))for(var f=0;f=200&&r.status<300&&r.response){var n;try{n=JSON.parse(r.response)}catch(t){return e(t)}e(null,n)}else 401===r.status&&t.url.match(/mapbox.com/)?e(new A(r.statusText+": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens",r.status,t.url)):e(new A(r.statusText,r.status,t.url))},r.send(),r},e.getImage=function(t,e){return S(t,function(t,r){if(t)e(t);else if(r){var n=new self.Image,i=self.URL||self.webkitURL;n.onload=function(){e(null,n),i.revokeObjectURL(n.src)};var a=new self.Blob([new Uint8Array(r.data)],{type:"image/png"});n.cacheControl=r.cacheControl,n.expires=r.expires,n.src=r.data.byteLength?i.createObjectURL(a):"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII="}})},e.ResourceType=M,e.RGBAImage=ui,e.default$2=Ka,e.ImagePosition=Qa,e.getArrayBuffer=S,e.default$3=function(t){return new io(t).readFields(ko,[])},e.default$4=yr,e.asyncAll=function(t,e,r){if(!t.length)return r(null,[]);var n=t.length,i=new Array(t.length),a=null;t.forEach(function(t,o){e(t,function(t,e){t&&(a=t),i[o]=e,0==--n&&r(a,i)})})},e.AlphaImage=ci,e.default$5=I,e.endsWith=v,e.extend=p,e.sphericalToCartesian=function(t){var e=t[0],r=t[1],n=t[2];return r+=90,r*=Math.PI/180,n*=Math.PI/180,{x:e*Math.cos(r)*Math.sin(n),y:e*Math.sin(r)*Math.sin(n),z:e*Math.cos(n)}},e.Evented=O,e.validateStyle=nr,e.validateLight=ir,e.emitValidationErrors=sr,e.default$6=tt,e.number=wt,e.Properties=qr,e.Transitionable=Ir,e.Transitioning=Dr,e.PossiblyEvaluated=Br,e.DataConstantProperty=Nr,e.warnOnce=_,e.uniqueId=function(){return d++},e.default$7=So,e.pick=function(t,e){for(var r={},n=0;n@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,function(t,r,n,i){var a=n||i;return e[r]=!a||a.toLowerCase(),""}),e["max-age"]){var r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},e.default$11=Bo,e.default$12=Ro,e.default$13=Re,e.default$14=Ha,e.CollisionBoxArray=vn,e.default$15=Tn,e.TriangleIndexArray=fn,e.default$16=Lr,e.default$17=s,e.keysDifference=function(t,e){var r=[];for(var n in t)n in e||r.push(n);return r},e.default$18=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.mat4=ri,e.vec4=ei,e.getSizeData=Fa,e.evaluateSizeForFeature=function(t,e,r){var n=e;return"source"===t.functionType?r.lowerSize/10:"composite"===t.functionType?wt(r.lowerSize/10,r.upperSize/10,n.uSizeT):n.uSize},e.evaluateSizeForZoom=function(t,e,r){if("constant"===t.functionType)return{uSizeT:0,uSize:t.layoutSize};if("source"===t.functionType)return{uSizeT:0,uSize:0};if("camera"===t.functionType){var n=t.propertyValue,i=t.zoomRange,a=t.sizeRange,o=h(Se(n,r.specification).interpolationFactor(e,i.min,i.max),0,1);return{uSizeT:0,uSize:a.min+o*(a.max-a.min)}}var s=t.propertyValue,l=t.zoomRange;return{uSizeT:h(Se(s,r.specification).interpolationFactor(e,l.min,l.max),0,1),uSize:0}},e.addDynamicAttributes=Va,e.default$19=Wa,e.WritingMode=jo,e.multiPolygonIntersectsBufferedPoint=jn,e.multiPolygonIntersectsMultiPolygon=Vn,e.multiPolygonIntersectsBufferedMultiLine=Un,e.polygonIntersectsPolygon=function(t,e){for(var r=0;r-r/2;){if(--o<0)return!1;s-=t[o].dist(a),a=t[o]}s+=t[o].dist(t[o+1]),o++;for(var l=[],c=0;sn;)c-=l.shift().angleDelta;if(c>i)return!1;o++,s+=f.dist(h)}return!0}function a(e,r,n,a,o,s,l,c,u){var f=a?.6*s*l:0,h=Math.max(a?a.right-a.left:0,o?o.right-o.left:0),p=0===e[0].x||e[0].x===u||0===e[0].y||e[0].y===u;return r-h*l=0&&M=0&&A=0&&v+h<=p){var T=new t.default$25(M,A,w,y);T._round(),o&&!i(r,T,l,o,s)||m.push(T)}}g+=_}return u||m.length||c||(m=e(r,g/2,a,o,s,l,c,!0,f)),m}(e,p?r/2*c%r:(h/2+2*s)*l*c%r,r,f,n,h*l,p,!1,u)}n.prototype.replace=function(t){this._layerConfigs={},this._layers={},this.update(t,[])},n.prototype.update=function(e,n){for(var i=this,a=0,o=e;a0&&(g=Math.max(10*s,g),this._addLineCollisionCircles(t,e,r,r.segment,v,g,n,i,a,u))}else t.emplaceBack(r.x,r.y,p,f,d,h,n,i,a,0,0);this.boxEndIndex=t.length};s.prototype._addLineCollisionCircles=function(t,e,r,n,i,a,o,s,l,c){var u=a/2,f=Math.floor(i/u),h=1+.4*Math.log(c)/Math.LN2,p=Math.floor(f*h/2),d=-a/2,g=r,v=n+1,m=d,y=-i/2,x=y-i/4;do{if(--v<0){if(m>y)return;v=0;break}m-=e[v].dist(g),g=e[v]}while(m>x);for(var b=e[v].dist(e[v+1]),_=-p;_i&&(k+=w-i),!(k=e.length)return;b=e[v].dist(e[v+1])}var M=k-m,A=e[v],T=e[v+1].sub(A)._unit()._mult(M)._add(A)._round(),S=Math.abs(k-d)0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)}function f(t,e){return te?1:0}function h(e,r,n){void 0===r&&(r=1),void 0===n&&(n=!1);for(var i=1/0,a=1/0,o=-1/0,s=-1/0,c=e[0],u=0;uo)&&(o=f.x),(!u||f.y>s)&&(s=f.y)}var h=o-i,g=s-a,v=Math.min(h,g),m=v/2,y=new l(null,p);if(0===v)return new t.default$1(i,a);for(var x=i;x_.d||!_.d)&&(_=k,n&&console.log("found best %d after %d probes",Math.round(1e4*k.d)/1e4,w)),k.max-_.d<=r||(m=k.h/2,y.push(new d(k.p.x-m,k.p.y-m,m,e)),y.push(new d(k.p.x+m,k.p.y-m,m,e)),y.push(new d(k.p.x-m,k.p.y+m,m,e)),y.push(new d(k.p.x+m,k.p.y+m,m,e)),w+=4)}return n&&(console.log("num probes: "+w),console.log("best distance: "+_.d)),_.p}function p(t,e){return e.max-t.max}function d(e,r,n,i){this.p=new t.default$1(e,r),this.h=n,this.d=function(e,r){for(var n=!1,i=1/0,a=0;ae.y!=f.y>e.y&&e.x<(f.x-u.x)*(e.y-u.y)/(f.y-u.y)+u.x&&(n=!n),i=Math.min(i,t.distToSegmentSquared(e,u,f))}return(n?1:-1)*Math.sqrt(i)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}function g(e,r,n,i,a,o){e.createArrays(),e.symbolInstances=[];var s=512*e.overscaling;e.tilePixelRatio=t.default$8/s,e.compareText={},e.iconsNeedLinear=!1;var l=e.layers[0].layout,c=e.layers[0]._unevaluatedLayout._values,u={};if("composite"===e.textSizeData.functionType){var f=e.textSizeData.zoomRange,h=f.min,p=f.max;u.compositeTextSizes=[c["text-size"].possiblyEvaluate(new t.default$16(h)),c["text-size"].possiblyEvaluate(new t.default$16(p))]}if("composite"===e.iconSizeData.functionType){var d=e.iconSizeData.zoomRange,g=d.min,m=d.max;u.compositeIconSizes=[c["icon-size"].possiblyEvaluate(new t.default$16(g)),c["icon-size"].possiblyEvaluate(new t.default$16(m))]}u.layoutTextSize=c["text-size"].possiblyEvaluate(new t.default$16(e.zoom+1)),u.layoutIconSize=c["icon-size"].possiblyEvaluate(new t.default$16(e.zoom+1)),u.textMaxSize=c["text-size"].possiblyEvaluate(new t.default$16(18));for(var y=24*l.get("text-line-height"),x="map"===l.get("text-rotation-alignment")&&"line"===l.get("symbol-placement"),b=l.get("text-keep-upright"),_=0,w=e.features;_=t.default$8||u.y<0||u.y>=t.default$8||e.symbolInstances.push(function(e,r,n,i,a,l,c,u,f,h,p,d,g,v,y,x,b,_,w,k,M){var A,T,S=e.addToLineVertexArray(r,n),C=0,E=0,L=0,z=i.horizontal?i.horizontal.text:"",O=[];i.horizontal&&(A=new s(c,n,r,u,f,h,i.horizontal,p,d,g,e.overscaling),E+=m(e,r,i.horizontal,l,g,w,v,S,i.vertical?t.WritingMode.horizontal:t.WritingMode.horizontalOnly,O,k,M),i.vertical&&(L+=m(e,r,i.vertical,l,g,w,v,S,t.WritingMode.vertical,O,k,M)));var I=A?A.boxStartIndex:e.collisionBoxArray.length,P=A?A.boxEndIndex:e.collisionBoxArray.length;if(a){var D=function(e,r,n,i,a,o){var s,l,c,u,f=r.image,h=n.layout,p=r.top-1/f.pixelRatio,d=r.left-1/f.pixelRatio,g=r.bottom+1/f.pixelRatio,v=r.right+1/f.pixelRatio;if("none"!==h.get("icon-text-fit")&&a){var m=v-d,y=g-p,x=h.get("text-size").evaluate(o)/24,b=a.left*x,_=a.right*x,w=a.top*x,k=_-b,M=a.bottom*x-w,A=h.get("icon-text-fit-padding")[0],T=h.get("icon-text-fit-padding")[1],S=h.get("icon-text-fit-padding")[2],C=h.get("icon-text-fit-padding")[3],E="width"===h.get("icon-text-fit")?.5*(M-y):0,L="height"===h.get("icon-text-fit")?.5*(k-m):0,z="width"===h.get("icon-text-fit")||"both"===h.get("icon-text-fit")?k:m,O="height"===h.get("icon-text-fit")||"both"===h.get("icon-text-fit")?M:y;s=new t.default$1(b+L-C,w+E-A),l=new t.default$1(b+L+T+z,w+E-A),c=new t.default$1(b+L+T+z,w+E+S+O),u=new t.default$1(b+L-C,w+E+S+O)}else s=new t.default$1(d,p),l=new t.default$1(v,p),c=new t.default$1(v,g),u=new t.default$1(d,g);var I=n.layout.get("icon-rotate").evaluate(o)*Math.PI/180;if(I){var P=Math.sin(I),D=Math.cos(I),R=[D,-P,P,D];s._matMult(R),l._matMult(R),u._matMult(R),c._matMult(R)}return[{tl:s,tr:l,bl:u,br:c,tex:f.paddedRect,writingMode:void 0,glyphOffset:[0,0]}]}(0,a,l,0,i.horizontal,w);T=new s(c,n,r,u,f,h,a,y,x,!1,e.overscaling),C=4*D.length;var R=e.iconSizeData,F=null;"source"===R.functionType?F=[10*l.layout.get("icon-size").evaluate(w)]:"composite"===R.functionType&&(F=[10*M.compositeIconSizes[0].evaluate(w),10*M.compositeIconSizes[1].evaluate(w)]),e.addSymbols(e.icon,D,F,_,b,w,!1,r,S.lineStartIndex,S.lineLength)}var B=T?T.boxStartIndex:e.collisionBoxArray.length,N=T?T.boxEndIndex:e.collisionBoxArray.length;return e.glyphOffsetArray.length>=t.default$14.MAX_GLYPHS&&t.warnOnce("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),{key:z,textBoxStartIndex:I,textBoxEndIndex:P,iconBoxStartIndex:B,iconBoxEndIndex:N,textOffset:v,iconOffset:_,anchor:r,line:n,featureIndex:u,feature:w,numGlyphVertices:E,numVerticalGlyphVertices:L,numIconVertices:C,textOpacityState:new o,iconOpacityState:new o,isDuplicate:!1,placedTextSymbolIndices:O,crossTileID:0}}(e,u,a,n,i,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,b,M,S,g,w,A,C,v,r,l,c))};if("line"===d.get("symbol-placement"))for(var z=0,O=function(e,r,n,i,a){for(var o=[],s=0;s=i&&h.x>=i||(f.x>=i?f=new t.default$1(i,f.y+(h.y-f.y)*((i-f.x)/(h.x-f.x)))._round():h.x>=i&&(h=new t.default$1(i,f.y+(h.y-f.y)*((i-f.x)/(h.x-f.x)))._round()),f.y>=a&&h.y>=a||(f.y>=a?f=new t.default$1(f.x+(h.x-f.x)*((a-f.y)/(h.y-f.y)),a)._round():h.y>=a&&(h=new t.default$1(f.x+(h.x-f.x)*((a-f.y)/(h.y-f.y)),a)._round()),c&&f.equals(c[c.length-1])||(c=[f],o.push(c)),c.push(h)))))}return o}(r.geometry,0,0,t.default$8,t.default$8);z=0;o--)if(n.dist(a[o])0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,r=this.compare,n=e[t];t>0;){var i=t-1>>1,a=e[i];if(r(n,a)>=0)break;e[t]=a,t=i}e[t]=n},_down:function(t){for(var e=this.data,r=this.compare,n=this.length>>1,i=e[t];t=0)break;e[t]=s,t=a}e[t]=i}},l.default=c;var x=function(e){var r=new t.AlphaImage({width:0,height:0}),n={},i=new t.default$2(0,0,{autoResize:!0});for(var a in e){var o=e[a],s=n[a]={};for(var l in o){var c=o[+l];if(c&&0!==c.bitmap.width&&0!==c.bitmap.height){var u=i.packOne(c.bitmap.width+2,c.bitmap.height+2);r.resize({width:i.w,height:i.h}),t.AlphaImage.copy(c.bitmap,r,{x:0,y:0},{x:u.x+1,y:u.y+1},c.bitmap),s[l]={rect:u,metrics:c.metrics}}}}i.shrink(),r.resize({width:i.w,height:i.h}),this.image=r,this.positions=n};t.register("GlyphAtlas",x);var b=function(e){this.tileID=new t.OverscaledTileID(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming};function _(e,r){for(var n=new t.default$16(r),i=0,a=e;i=T.maxzoom||"none"!==T.visibility&&(_(A,a.zoom),(f[T.id]=T.createBucket({index:s.bucketLayerIDs.length,layers:A,zoom:a.zoom,pixelRatio:a.pixelRatio,overscaling:a.overscaling,collisionBoxArray:a.collisionBoxArray,sourceLayerIndex:m})).populate(y,h),s.bucketLayerIDs.push(A.map(function(t){return t.id})))}}}var S=t.mapObject(h.glyphDependencies,function(t){return Object.keys(t).map(Number)});Object.keys(S).length?n.send("getGlyphs",{uid:this.uid,stacks:S},function(t,e){l||(l=t,c=e,E.call(a))}):c={};var C=Object.keys(h.iconDependencies);function E(){if(l)return i(l);if(c&&u){var e=new x(c),r=new t.default$28(u);for(var n in f){var a=f[n];a instanceof t.default$14&&(_(a.layers,this.zoom),g(a,c,e.positions,u,r.positions,this.showCollisionBoxes))}this.status="done",i(null,{buckets:t.values(f).filter(function(t){return!t.isEmpty()}),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,iconAtlasImage:r.image})}}C.length?n.send("getImages",{icons:C},function(t,e){l||(l=t,u=e,E.call(a))}):u={},E.call(this)};var w=function(t){return!(!performance||!performance.getEntriesByName)&&performance.getEntriesByName(t)};function k(e,r){var n=t.getArrayBuffer(e.request,function(e,n){e?r(e):n&&r(null,{vectorTile:new t.default$29.VectorTile(new t.default$30(n.data)),rawData:n.data,cacheControl:n.cacheControl,expires:n.expires})});return function(){n.abort(),r()}}var M=function(t,e,r){this.actor=t,this.layerIndex=e,this.loadVectorData=r||k,this.loading={},this.loaded={}};M.prototype.loadTile=function(e,r){var n=this,i=e.uid;this.loading||(this.loading={});var a=this.loading[i]=new b(e);a.abort=this.loadVectorData(e,function(o,s){if(delete n.loading[i],o||!s)return r(o);var l=s.rawData,c={};s.expires&&(c.expires=s.expires),s.cacheControl&&(c.cacheControl=s.cacheControl);var u={};if(e.request&&e.request.collectResourceTiming){var f=w(e.request.url);f&&(u.resourceTiming=JSON.parse(JSON.stringify(f)))}a.vectorTile=s.vectorTile,a.parse(s.vectorTile,n.layerIndex,n.actor,function(e,n){if(e||!n)return r(e);r(null,t.extend({rawTileData:l.slice(0)},n,c,u))}),n.loaded=n.loaded||{},n.loaded[i]=a})},M.prototype.reloadTile=function(t,e){var r=this.loaded,n=t.uid,i=this;if(r&&r[n]){var a=r[n];a.showCollisionBoxes=t.showCollisionBoxes;var o=function(t,r){var n=a.reloadCallback;n&&(delete a.reloadCallback,a.parse(a.vectorTile,i.layerIndex,i.actor,n)),e(t,r)};"parsing"===a.status?a.reloadCallback=o:"done"===a.status&&a.parse(a.vectorTile,this.layerIndex,this.actor,o)}},M.prototype.abortTile=function(t,e){var r=this.loading,n=t.uid;r&&r[n]&&r[n].abort&&(r[n].abort(),delete r[n]),e()},M.prototype.removeTile=function(t,e){var r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e()};var A=function(){this.loading={},this.loaded={}};A.prototype.loadTile=function(e,r){var n=e.uid,i=e.encoding,a=new t.default$31(n);this.loading[n]=a,a.loadFromImage(e.rawImageData,i),delete this.loading[n],this.loaded=this.loaded||{},this.loaded[n]=a,r(null,a)},A.prototype.removeTile=function(t){var e=this.loaded,r=t.uid;e&&e[r]&&delete e[r]};var T={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:6356752.3142};function S(t){var e=0;if(t&&t.length>0){e+=Math.abs(C(t[0]));for(var r=1;r2){for(o=0;o=0}(t)===e?t:t.reverse()}var P=t.default$29.VectorTileFeature.prototype.toGeoJSON,D=function(e){this._feature=e,this.extent=t.default$8,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))};D.prototype.loadGeometry=function(){if(1===this._feature.type){for(var e=[],r=0,n=this._feature.geometry;r>31}function $(t,e){for(var r=t.loadGeometry(),n=t.type,i=0,a=0,o=r.length,s=0;si;){if(a-i>600){var s=a-i+1,l=n-i+1,c=Math.log(s),u=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*u*(s-u)/s)*(l-s/2<0?-1:1);t(e,r,n,Math.max(i,Math.floor(n-l*u/s+f)),Math.min(a,Math.floor(n+(s-l)*u/s+f)),o)}var h=r[2*n+o],p=i,d=a;for(Q(e,r,i,n),r[2*a+o]>h&&Q(e,r,i,a);ph;)d--}r[2*i+o]===h?Q(e,r,i,d):Q(e,r,++d,a),d<=n&&(i=d+1),n<=d&&(a=d-1)}}(e,r,s,i,a,o%2),t(e,r,n,i,s-1,o+1),t(e,r,n,s+1,a,o+1)}};function Q(t,e,r,n){tt(t,r,n),tt(e,2*r,2*n),tt(e,2*r+1,2*n+1)}function tt(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function et(t,e,r,n){var i=t-r,a=e-n;return i*i+a*a}var rt=function(t,e,r,n,i){return new nt(t,e,r,n,i)};function nt(t,e,r,n,i){e=e||it,r=r||at,i=i||Array,this.nodeSize=n||64,this.points=t,this.ids=new i(t.length),this.coords=new i(2*t.length);for(var a=0;a=r&&s<=i&&l>=n&&l<=a&&u.push(t[d]);else{var g=Math.floor((p+h)/2);s=e[2*g],l=e[2*g+1],s>=r&&s<=i&&l>=n&&l<=a&&u.push(t[g]);var v=(f+1)%2;(0===f?r<=s:n<=l)&&(c.push(p),c.push(g-1),c.push(v)),(0===f?i>=s:a>=l)&&(c.push(g+1),c.push(h),c.push(v))}}return u}(this.ids,this.coords,t,e,r,n,this.nodeSize)},within:function(t,e,r){return function(t,e,r,n,i,a){for(var o=[0,t.length-1,0],s=[],l=i*i;o.length;){var c=o.pop(),u=o.pop(),f=o.pop();if(u-f<=a)for(var h=f;h<=u;h++)et(e[2*h],e[2*h+1],r,n)<=l&&s.push(t[h]);else{var p=Math.floor((f+u)/2),d=e[2*p],g=e[2*p+1];et(d,g,r,n)<=l&&s.push(t[p]);var v=(c+1)%2;(0===c?r-i<=d:n-i<=g)&&(o.push(f),o.push(p-1),o.push(v)),(0===c?r+i>=d:n+i>=g)&&(o.push(p+1),o.push(u),o.push(v))}}return s}(this.ids,this.coords,t,e,r,this.nodeSize)}};function ot(t){this.options=pt(Object.create(this.options),t),this.trees=new Array(this.options.maxZoom+1)}function st(t,e,r,n,i){return{x:t,y:e,zoom:1/0,id:n,properties:i,parentId:-1,numPoints:r}}function lt(t,e){var r=t.geometry.coordinates;return{x:ft(r[0]),y:ht(r[1]),zoom:1/0,id:e,parentId:-1}}function ct(t){return{type:"Feature",properties:ut(t),geometry:{type:"Point",coordinates:[(n=t.x,360*(n-.5)),(e=t.y,r=(180-360*e)*Math.PI/180,360*Math.atan(Math.exp(r))/Math.PI-90)]}};var e,r,n}function ut(t){var e=t.numPoints,r=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return pt(pt({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:r})}function ft(t){return t/360+.5}function ht(t){var e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function pt(t,e){for(var r in e)t[r]=e[r];return t}function dt(t){return t.x}function gt(t){return t.y}function vt(t,e,r,n,i,a){var o=i-r,s=a-n;if(0!==o||0!==s){var l=((t-r)*o+(e-n)*s)/(o*o+s*s);l>1?(r=i,n=a):l>0&&(r+=o*l,n+=s*l)}return(o=t-r)*o+(s=e-n)*s}function mt(t,e,r,n){var i={id:t||null,type:e,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,r=t.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)yt(t,e);else if("Polygon"===r||"MultiLineString"===r)for(var n=0;n0&&(o+=n?(i*c-l*a)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(c-a,2))),i=l,a=c}var u=e.length-3;e[2]=1,function t(e,r,n,i){for(var a,o=i,s=e[r],l=e[r+1],c=e[n],u=e[n+1],f=r+3;fo&&(a=f,o=h)}o>i&&(a-r>3&&t(e,r,a,i),e[a+2]=o,n-a>3&&t(e,a,n,i))}(e,0,u,r),e[u+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function wt(t,e,r,n){for(var i=0;i1?1:r}function At(t,e,r,n,i,a,o,s){if(n/=e,a>=(r/=e)&&o<=n)return t;if(a>n||o=r&&d<=n)l.push(u);else if(!(p>n||d=r&&o<=n&&(e.push(t[a]),e.push(t[a+1]),e.push(t[a+2]))}}function St(t,e,r,n,i,a,o){for(var s,l,c=Ct(t),u=0===i?zt:Ot,f=t.start,h=0;h=r&&(l=u(c,p,d,v,m,r),o&&(c.start=f+s*l)):y>n?x<=n&&(l=u(c,p,d,v,m,n),o&&(c.start=f+s*l)):Lt(c,p,d,g),x=r&&(l=u(c,p,d,v,m,r),b=!0),x>n&&y<=n&&(l=u(c,p,d,v,m,n),b=!0),!a&&b&&(o&&(c.end=f+s*l),e.push(c),c=Ct(t)),o&&(f+=s)}var _=t.length-3;p=t[_],d=t[_+1],g=t[_+2],(y=0===i?p:d)>=r&&y<=n&&Lt(c,p,d,g),_=c.length-3,a&&_>=3&&(c[_]!==c[0]||c[_+1]!==c[1])&&Lt(c,c[0],c[1],c[2]),c.length&&e.push(c)}function Ct(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Et(t,e,r,n,i,a){for(var o=0;oo.maxX&&(o.maxX=u),f>o.maxY&&(o.maxY=f)}return o}function Bt(t,e,r,n){var i=e.geometry,a=e.type,o=[];if("Point"===a||"MultiPoint"===a)for(var s=0;s0&&e.size<(i?o:n))r.numPoints+=e.length/3;else{for(var s=[],l=0;lo)&&(r.numSimplified++,s.push(e[l]),s.push(e[l+1])),r.numPoints++;i&&function(t,e){for(var r=0,n=0,i=t.length,a=i-2;n0===e)for(n=0,i=t.length;n24)throw new Error("maxZoom should be in the 0-24 range");var n=function(t,e){var r=[];if("FeatureCollection"===t.type)for(var n=0;n=this.options.minZoom;i--){var a=+Date.now();this.trees[i+1]=rt(n,dt,gt,this.options.nodeSize,Float32Array),n=this._cluster(n,i),e&&console.log("z%d: %d clusters in %dms",i,n.length,+Date.now()-a)}return this.trees[this.options.minZoom]=rt(n,dt,gt,this.options.nodeSize,Float32Array),e&&console.timeEnd("total time"),this},getClusters:function(t,e){for(var r=this.trees[this._limitZoom(e)],n=r.range(ft(t[0]),ht(t[3]),ft(t[2]),ht(t[1])),i=[],a=0;a1&&console.time("creation"),h=this.tiles[f]=Ft(t,e,r,n,l),this.tileCoords.push({z:e,x:r,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,h.numFeatures,h.numPoints,h.numSimplified),console.timeEnd("creation"));var p="z"+e;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(h.source=t,i){if(e===l.maxZoom||e===i)continue;var d=1<1&&console.time("clipping");var g,v,m,y,x,b,_=.5*l.buffer/l.extent,w=.5-_,k=.5+_,M=1+_;g=v=m=y=null,x=At(t,u,r-_,r+k,0,h.minX,h.maxX,l),b=At(t,u,r+w,r+M,0,h.minX,h.maxX,l),t=null,x&&(g=At(x,u,n-_,n+k,1,h.minY,h.maxY,l),v=At(x,u,n+w,n+M,1,h.minY,h.maxY,l),x=null),b&&(m=At(b,u,n-_,n+k,1,h.minY,h.maxY,l),y=At(b,u,n+w,n+M,1,h.minY,h.maxY,l),b=null),c>1&&console.timeEnd("clipping"),s.push(g||[],e+1,2*r,2*n),s.push(v||[],e+1,2*r,2*n+1),s.push(m||[],e+1,2*r+1,2*n),s.push(y||[],e+1,2*r+1,2*n+1)}}},jt.prototype.getTile=function(t,e,r){var n=this.options,i=n.extent,a=n.debug;if(t<0||t>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",t,e,r);for(var l,c=t,u=e,f=r;!l&&c>0;)c--,u=Math.floor(u/2),f=Math.floor(f/2),l=this.tiles[Vt(c,u,f)];return l&&l.source?(a>1&&console.log("found parent tile z%d-%d-%d",c,u,f),a>1&&console.time("drilling down"),this.splitTile(l.source,c,u,f,t,e,r),a>1&&console.timeEnd("drilling down"),this.tiles[s]?Dt(this.tiles[s],i):null):null};var qt=function(e){function r(t,r,n){e.call(this,t,r,Ut),n&&(this.loadGeoJSON=n)}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.loadData=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),this._pendingCallback=e,this._pendingLoadDataParams=t,this._state&&"Idle"!==this._state?this._state="NeedsLoadData":(this._state="Coalescing",this._loadData())},r.prototype._loadData=function(){var t=this;if(this._pendingCallback&&this._pendingLoadDataParams){var e=this._pendingCallback,r=this._pendingLoadDataParams;delete this._pendingCallback,delete this._pendingLoadDataParams,this.loadGeoJSON(r,function(n,i){if(n||!i)return e(n);if("object"!=typeof i)return e(new Error("Input data is not a valid GeoJSON object."));!function t(e,r){switch(e&&e.type||null){case"FeatureCollection":return e.features=e.features.map(z(t,r)),e;case"Feature":return e.geometry=t(e.geometry,r),e;case"Polygon":case"MultiPolygon":return function(t,e){return"Polygon"===t.type?t.coordinates=O(t.coordinates,e):"MultiPolygon"===t.type&&(t.coordinates=t.coordinates.map(z(O,e))),t}(e,r);default:return e}}(i,!0);try{t._geoJSONIndex=r.cluster?function(t){return new ot(t)}(r.superclusterOptions).load(i.features):new jt(i,r.geojsonVtOptions)}catch(n){return e(n)}t.loaded={};var a={};if(r.request&&r.request.collectResourceTiming){var o=w(r.request.url);o&&(a.resourceTiming={},a.resourceTiming[r.source]=JSON.parse(JSON.stringify(o)))}e(null,a)})}},r.prototype.coalesce=function(){"Coalescing"===this._state?this._state="Idle":"NeedsLoadData"===this._state&&(this._state="Coalescing",this._loadData())},r.prototype.reloadTile=function(t,r){var n=this.loaded,i=t.uid;return n&&n[i]?e.prototype.reloadTile.call(this,t,r):this.loadTile(t,r)},r.prototype.loadGeoJSON=function(e,r){if(e.request)t.getJSON(e.request,r);else{if("string"!=typeof e.data)return r(new Error("Input data is not a valid GeoJSON object."));try{return r(null,JSON.parse(e.data))}catch(t){return r(new Error("Input data is not a valid GeoJSON object."))}}},r.prototype.removeSource=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),e()},r}(M),Ht=function(e){var r=this;this.self=e,this.actor=new t.default$7(e,this),this.layerIndexes={},this.workerSourceTypes={vector:M,geojson:qt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=function(t,e){if(r.workerSourceTypes[t])throw new Error('Worker source with name "'+t+'" already registered.');r.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=function(e){if(t.plugin.isLoaded())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText}};return Ht.prototype.setLayers=function(t,e,r){this.getLayerIndex(t).replace(e),r()},Ht.prototype.updateLayers=function(t,e,r){this.getLayerIndex(t).update(e.layers,e.removedIds),r()},Ht.prototype.loadTile=function(t,e,r){this.getWorkerSource(t,e.type,e.source).loadTile(e,r)},Ht.prototype.loadDEMTile=function(t,e,r){this.getDEMWorkerSource(t,e.source).loadTile(e,r)},Ht.prototype.reloadTile=function(t,e,r){this.getWorkerSource(t,e.type,e.source).reloadTile(e,r)},Ht.prototype.abortTile=function(t,e,r){this.getWorkerSource(t,e.type,e.source).abortTile(e,r)},Ht.prototype.removeTile=function(t,e,r){this.getWorkerSource(t,e.type,e.source).removeTile(e,r)},Ht.prototype.removeDEMTile=function(t,e){this.getDEMWorkerSource(t,e.source).removeTile(e)},Ht.prototype.removeSource=function(t,e,r){if(this.workerSources[t]&&this.workerSources[t][e.type]&&this.workerSources[t][e.type][e.source]){var n=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==n.removeSource?n.removeSource(e,r):r()}},Ht.prototype.loadWorkerSource=function(t,e,r){try{this.self.importScripts(e.url),r()}catch(t){r(t.toString())}},Ht.prototype.loadRTLTextPlugin=function(e,r,n){try{t.plugin.isLoaded()||(this.self.importScripts(r),n(t.plugin.isLoaded()?null:new Error("RTL Text Plugin failed to import scripts from "+r)))}catch(t){n(t.toString())}},Ht.prototype.getLayerIndex=function(t){var e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new n),e},Ht.prototype.getWorkerSource=function(t,e,r){var n=this;if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][r]){var i={send:function(e,r,i){n.actor.send(e,r,i,t)}};this.workerSources[t][e][r]=new this.workerSourceTypes[e](i,this.getLayerIndex(t))}return this.workerSources[t][e][r]},Ht.prototype.getDEMWorkerSource=function(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new A),this.demWorkerSources[t][e]},"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&new Ht(self),Ht}),i(0,function(t){var e=t.createCommonjsModule(function(t){function e(t){return!!("undefined"!=typeof window&&"undefined"!=typeof document&&Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray&&Function.prototype&&Function.prototype.bind&&Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions&&"JSON"in window&&"parse"in JSON&&"stringify"in JSON&&function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,r=new Blob([""],{type:"text/javascript"}),n=URL.createObjectURL(r);try{e=new Worker(n),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(n),t}()&&"Uint8ClampedArray"in window&&function(t){return void 0===r[t]&&(r[t]=function(t){var r=document.createElement("canvas"),n=Object.create(e.webGLContextAttributes);return n.failIfMajorPerformanceCaveat=t,r.probablySupportsContext?r.probablySupportsContext("webgl",n)||r.probablySupportsContext("experimental-webgl",n):r.supportsContext?r.supportsContext("webgl",n)||r.supportsContext("experimental-webgl",n):r.getContext("webgl",n)||r.getContext("experimental-webgl",n)}(t)),r[t]}(t&&t.failIfMajorPerformanceCaveat))}t.exports?t.exports=e:window&&(window.mapboxgl=window.mapboxgl||{},window.mapboxgl.supported=e);var r={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0}}),r=t.default.performance&&t.default.performance.now?t.default.performance.now.bind(t.default.performance):Date.now.bind(Date),n=t.default.requestAnimationFrame||t.default.mozRequestAnimationFrame||t.default.webkitRequestAnimationFrame||t.default.msRequestAnimationFrame,i=t.default.cancelAnimationFrame||t.default.mozCancelAnimationFrame||t.default.webkitCancelAnimationFrame||t.default.msCancelAnimationFrame,a={now:r,frame:function(t){return n(t)},cancelFrame:function(t){return i(t)},getImageData:function(e){var r=t.default.document.createElement("canvas"),n=r.getContext("2d");if(!n)throw new Error("failed to create canvas 2d context");return r.width=e.width,r.height=e.height,n.drawImage(e,0,0,e.width,e.height),n.getImageData(0,0,e.width,e.height)},hardwareConcurrency:t.default.navigator.hardwareConcurrency||4,get devicePixelRatio(){return t.default.devicePixelRatio},supportsWebp:!1};if(t.default.document){var o=t.default.document.createElement("img");o.onload=function(){a.supportsWebp=!0},o.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="}var s={create:function(e,r,n){var i=t.default.document.createElement(e);return r&&(i.className=r),n&&n.appendChild(i),i},createNS:function(e,r){return t.default.document.createElementNS(e,r)}},l=t.default.document?t.default.document.documentElement.style:null;function c(t){if(!l)return null;for(var e=0;e=0?0:e.button},s.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};var v={API_URL:"https://api.mapbox.com",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null},m="See https://www.mapbox.com/api-documentation/#access-tokens";function y(t,e){var r=A(v.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"/"!==r.path&&(t.path=""+r.path+t.path),!v.REQUIRE_ACCESS_TOKEN)return T(t);if(!(e=e||v.ACCESS_TOKEN))throw new Error("An API access token is required to use Mapbox GL. "+m);if("s"===e[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+m);return t.params.push("access_token="+e),T(t)}function x(t){return 0===t.indexOf("mapbox:")}var b=function(t,e){if(!x(t))return t;var r=A(t);return r.path="/v4/"+r.authority+".json",r.params.push("secure"),y(r,e)},_=function(t,e,r,n){var i=A(t);return x(t)?(i.path="/styles/v1"+i.path+"/sprite"+e+r,y(i,n)):(i.path+=""+e+r,T(i))},w=/(\.(png|jpg)\d*)(?=$)/,k=function(t,e,r){if(!e||!x(e))return t;var n=A(t),i=a.devicePixelRatio>=2||512===r?"@2x":"",o=a.supportsWebp?".webp":"$1";return n.path=n.path.replace(w,""+i+o),function(t){for(var e=0;e=0?1.2:1))}function R(t,e,r,n,i,a,o){for(var s=0;s65535)e(new Error("glyphs > 65535 not supported"));else{var l=a.requests[s];l||(l=a.requests[s]=[],B.loadGlyphRange(r,s,n.url,n.requestTransform,function(t,e){if(e)for(var r in e)a.glyphs[+r]=e[+r];for(var n=0,i=l;nthis.height)return t.warnOnce("LineAtlas out of space"),null;for(var a=0,o=0;o90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")};G.prototype.wrap=function(){return new G(t.wrap(this.lng,-180,180),this.lat)},G.prototype.toArray=function(){return[this.lng,this.lat]},G.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},G.prototype.toBounds=function(t){var e=360*t/40075017,r=e/Math.cos(Math.PI/180*this.lat);return new W(new G(this.lng-r,this.lat-e),new G(this.lng+r,this.lat+e))},G.convert=function(t){if(t instanceof G)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new G(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new G(Number(t.lng),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, or an array of [, ]")};var W=function(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))};W.prototype.setNorthEast=function(t){return this._ne=t instanceof G?new G(t.lng,t.lat):G.convert(t),this},W.prototype.setSouthWest=function(t){return this._sw=t instanceof G?new G(t.lng,t.lat):G.convert(t),this},W.prototype.extend=function(t){var e,r,n=this._sw,i=this._ne;if(t instanceof G)e=t,r=t;else{if(!(t instanceof W))return Array.isArray(t)?t.every(Array.isArray)?this.extend(W.convert(t)):this.extend(G.convert(t)):this;if(e=t._sw,r=t._ne,!e||!r)return this}return n||i?(n.lng=Math.min(e.lng,n.lng),n.lat=Math.min(e.lat,n.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new G(e.lng,e.lat),this._ne=new G(r.lng,r.lat)),this},W.prototype.getCenter=function(){return new G((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},W.prototype.getSouthWest=function(){return this._sw},W.prototype.getNorthEast=function(){return this._ne},W.prototype.getNorthWest=function(){return new G(this.getWest(),this.getNorth())},W.prototype.getSouthEast=function(){return new G(this.getEast(),this.getSouth())},W.prototype.getWest=function(){return this._sw.lng},W.prototype.getSouth=function(){return this._sw.lat},W.prototype.getEast=function(){return this._ne.lng},W.prototype.getNorth=function(){return this._ne.lat},W.prototype.toArray=function(){return[this._sw.toArray(),this._ne.toArray()]},W.prototype.toString=function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"},W.prototype.isEmpty=function(){return!(this._sw&&this._ne)},W.convert=function(t){return!t||t instanceof W?t:new W(t)};var Y=function(t,e,r){this.bounds=W.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=r||24};Y.prototype.validateBounds=function(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]},Y.prototype.contains=function(t){var e=Math.floor(this.lngX(this.bounds.getWest(),t.z)),r=Math.floor(this.latY(this.bounds.getNorth(),t.z)),n=Math.ceil(this.lngX(this.bounds.getEast(),t.z)),i=Math.ceil(this.latY(this.bounds.getSouth(),t.z));return t.x>=e&&t.x=r&&t.y0&&(l[new t.OverscaledTileID(e.overscaledZ,a,r.z,i,r.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,r.z,o,r.y-1).key]={backfilled:!1}),r.y+10&&(n.resourceTiming=e._resourceTiming,e._resourceTiming=[]),e.fire(new t.Event("data",n))}})},r.prototype.onAdd=function(t){this.map=t,this.load()},r.prototype.setData=function(e){var r=this;return this._data=e,this.fire(new t.Event("dataloading",{dataType:"source"})),this._updateWorkerData(function(e){if(e)return r.fire(new t.ErrorEvent(e));var n={dataType:"source",sourceDataType:"content"};r._collectResourceTiming&&r._resourceTiming&&r._resourceTiming.length>0&&(n.resourceTiming=r._resourceTiming,r._resourceTiming=[]),r.fire(new t.Event("data",n))}),this},r.prototype._updateWorkerData=function(e){var r,n,i=this,a=t.extend({},this.workerOptions),o=this._data;"string"==typeof o?(a.request=this.map._transformRequest((r=o,(n=t.default.document.createElement("a")).href=r,n.href),t.ResourceType.Source),a.request.collectResourceTiming=this._collectResourceTiming):a.data=JSON.stringify(o),this.workerID=this.dispatcher.send(this.type+"."+a.source+".loadData",a,function(t,r){i._removed||r&&r.abandoned||(i._loaded=!0,r&&r.resourceTiming&&r.resourceTiming[i.id]&&(i._resourceTiming=r.resourceTiming[i.id].slice(0)),i.dispatcher.send(i.type+"."+a.source+".coalesce",null,null,i.workerID),e(t))},this.workerID)},r.prototype.loadTile=function(t,e){var r=this,n=void 0===t.workerID?"loadTile":"reloadTile",i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes};t.workerID=this.dispatcher.send(n,i,function(i,a){return t.unloadVectorData(),t.aborted?e(null):i?e(i):(t.loadVectorData(a,r.map.painter,"reloadTile"===n),e(null))},this.workerID)},r.prototype.abortTile=function(t){t.aborted=!0},r.prototype.unloadTile=function(t){t.unloadVectorData(),this.dispatcher.send("removeTile",{uid:t.uid,type:this.type,source:this.id},null,t.workerID)},r.prototype.onRemove=function(){this._removed=!0,this.dispatcher.send("removeSource",{type:this.type,source:this.id},null,this.workerID)},r.prototype.serialize=function(){return t.extend({},this._options,{type:this.type,data:this._data})},r.prototype.hasTransition=function(){return!1},r}(t.Evented),K=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Q=function(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null};Q.prototype.bind=function(t,e,r,n,i,a,o,s){this.context=t;for(var l=this.boundPaintVertexBuffers.length!==n.length,c=0;!l&&c>s.z,c=new t.default$1(s.x*l,s.y*l),u=new t.default$1(c.x+l,c.y+l),f=this.segments.prepareSegment(4,n,i);n.emplaceBack(c.x,c.y,c.x,c.y),n.emplaceBack(u.x,c.y,u.x,c.y),n.emplaceBack(c.x,u.y,c.x,u.y),n.emplaceBack(u.x,u.y,u.x,u.y);var h=f.vertexLength;i.emplaceBack(h,h+1,h+2),i.emplaceBack(h+1,h+2,h+3),f.vertexLength+=4,f.primitiveLength+=2}this.maskedBoundsBuffer=r.createVertexBuffer(n,K.members),this.maskedIndexBuffer=r.createIndexBuffer(i)}},st.prototype.hasData=function(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state},st.prototype.setExpiryData=function(e){var r=this.expirationTime;if(e.cacheControl){var n=t.parseCacheControl(e.cacheControl);n["max-age"]&&(this.expirationTime=Date.now()+1e3*n["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){var i=Date.now(),a=!1;if(this.expirationTime>i)a=!1;else if(r)if(this.expirationTimethis.max){var o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this},lt.prototype.has=function(t){return t.wrapped().key in this.data},lt.prototype.getAndRemove=function(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null},lt.prototype._getAndRemoveByKey=function(t){var e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value},lt.prototype.get=function(t){return this.has(t)?this.data[t.wrapped().key][0].value:null},lt.prototype.remove=function(t,e){if(!this.has(t))return this;var r=t.wrapped().key,n=void 0===e?0:this.data[r].indexOf(e),i=this.data[r][n];return this.data[r].splice(n,1),i.timeout&&clearTimeout(i.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(i.value),this.order.splice(this.order.indexOf(r),1),this},lt.prototype.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this};var ct=function(t,e,r){this.context=t;var n=t.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(r),this.unbindVAO(),t.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};ct.prototype.unbindVAO=function(){this.context.extVertexArrayObject&&this.context.bindVertexArrayOES.set(null)},ct.prototype.bind=function(){this.context.bindElementBuffer.set(this.buffer)},ct.prototype.updateData=function(t){var e=this.context.gl;this.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)},ct.prototype.destroy=function(){var t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)};var ut={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},ft=function(t,e,r,n){this.length=e.length,this.attributes=r,this.itemSize=e.bytesPerElement,this.dynamicDraw=n,this.context=t;var i=t.gl;this.buffer=i.createBuffer(),t.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};ft.prototype.bind=function(){this.context.bindVertexBuffer.set(this.buffer)},ft.prototype.updateData=function(t){var e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)},ft.prototype.enableAttributes=function(t,e){for(var r=0;r1||(Math.abs(r)>1&&(1===Math.abs(r+i)?r+=i:1===Math.abs(r-i)&&(r-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,r,n),t.neighboringTiles&&t.neighboringTiles[a]&&(t.neighboringTiles[a].backfilled=!0)))}},r.prototype.getTile=function(t){return this.getTileByID(t.key)},r.prototype.getTileByID=function(t){return this._tiles[t]},r.prototype.getZoom=function(t){return t.zoom+t.scaleZoom(t.tileSize/this._source.tileSize)},r.prototype._findLoadedChildren=function(t,e,r){var n=!1;for(var i in this._tiles){var a=this._tiles[i];if(!(r[i]||!a.hasData()||a.tileID.overscaledZ<=t.overscaledZ||a.tileID.overscaledZ>e)){var o=Math.pow(2,a.tileID.canonical.z-t.canonical.z);if(Math.floor(a.tileID.canonical.x/o)===t.canonical.x&&Math.floor(a.tileID.canonical.y/o)===t.canonical.y)for(r[i]=a.tileID,n=!0;a&&a.tileID.overscaledZ-1>t.overscaledZ;){var s=a.tileID.scaledTo(a.tileID.overscaledZ-1);if(!s)break;(a=this._tiles[s.key])&&a.hasData()&&(delete r[i],r[s.key]=s)}}}return n},r.prototype.findLoadedParent=function(t,e,r){for(var n=t.overscaledZ-1;n>=e;n--){var i=t.scaledTo(n);if(!i)return;var a=String(i.key),o=this._tiles[a];if(o&&o.hasData())return r[a]=i,o;if(this._cache.has(i))return r[a]=i,this._cache.get(i)}},r.prototype.updateCacheSize=function(t){var e=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),r=Math.floor(5*e),n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(n)},r.prototype.handleWrapJump=function(t){var e=(t-(void 0===this._prevLng?t:this._prevLng))/360,r=Math.round(e);if(this._prevLng=t,r){var n={};for(var i in this._tiles){var a=this._tiles[i];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+r),n[a.tileID.key]=a}for(var o in this._tiles=n,this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(var s in this._tiles){var l=this._tiles[s];this._setTileReloadTimer(s,l)}}},r.prototype.update=function(e){var n=this;if(this.transform=e,this._sourceLoaded&&!this._paused){var i;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(function(e){return new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)}):(i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}),this._source.hasTile&&(i=i.filter(function(t){return n._source.hasTile(t)}))):i=[];var o,s=(this._source.roundZoom?Math.round:Math.floor)(this.getZoom(e)),l=Math.max(s-r.maxOverzooming,this._source.minzoom),c=Math.max(s+r.maxUnderzooming,this._source.minzoom),u=this._updateRetainedTiles(i,s),f={};if(Zt(this._source.type))for(var h=Object.keys(u),p=0;p=a.now())){n._findLoadedChildren(g,c,u)&&(u[d]=g);var m=n.findLoadedParent(g,l,f);m&&n._addTile(m.tileID)}}for(o in f)u[o]||(n._coveredTiles[o]=!0);for(o in f)u[o]=f[o];for(var y=t.keysDifference(this._tiles,u),x=0;xthis._source.maxzoom){var h=l.children(this._source.maxzoom)[0],p=this.getTile(h);p&&p.hasData()?n[h.key]=h:f=!1}else{this._findLoadedChildren(l,o,n);for(var d=l.children(this._source.maxzoom),g=0;g=a;--v){var m=l.scaledTo(v);if(i[m.key])break;if(i[m.key]=!0,!(c=this.getTile(m))&&u&&(c=this._addTile(m)),c&&(n[m.key]=m,u=c.wasRequested(),c.hasData()))break}}}return n},r.prototype._addTile=function(e){var r=this._tiles[e.key];if(r)return r;(r=this._cache.getAndRemove(e))&&(this._setTileReloadTimer(e.key,r),r.tileID=e);var n=Boolean(r);return n||(r=new st(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(r,this._tileLoaded.bind(this,r,e.key,r.state))),r?(r.uses++,this._tiles[e.key]=r,n||this._source.fire(new t.Event("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null},r.prototype._setTileReloadTimer=function(t,e){var r=this;t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);var n=e.getExpiryTimeout();n&&(this._timers[t]=setTimeout(function(){r._reloadTile(t,"expired"),delete r._timers[t]},n))},r.prototype._removeTile=function(t){var e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))},r.prototype.clearTiles=function(){for(var t in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(t);this._cache.reset()},r.prototype.tilesIn=function(e,r){for(var n=[],i=this.getIds(),a=1/0,o=1/0,s=-1/0,l=-1/0,c=e[0].zoom,u=0;u=0&&m[1].y+v>=0){for(var y=[],x=0;x=a.now())return!0}return!1},r}(t.Evented);function Xt(e,r){var n=r.zoomTo(e.canonical.z);return new t.default$1((n.column-(e.canonical.x+e.wrap*Math.pow(2,e.canonical.z)))*t.default$8,(n.row-e.canonical.y)*t.default$8)}function Zt(t){return"raster"===t||"image"===t||"video"===t}function $t(){return new t.default.Worker(Cn.workerUrl)}Yt.maxOverzooming=10,Yt.maxUnderzooming=3;var Jt,Kt=function(){this.active={}};function Qt(e,r){var n={};for(var i in e)"ref"!==i&&(n[i]=e[i]);return t.default$18.forEach(function(t){t in r&&(n[t]=r[t])}),n}function te(t){t=t.slice();for(var e=Object.create(null),r=0;rthis.width||n<0||e>this.height)return!i&&[];var a=[];if(t<=0&&e<=0&&this.width<=r&&this.height<=n){if(i)return!0;for(var o=0;o0:a},ce.prototype._queryCircle=function(t,e,r,n){var i=t-r,a=t+r,o=e-r,s=e+r;if(a<0||i>this.width||s<0||o>this.height)return!n&&[];var l=[],c={hitTest:n,circle:{x:t,y:e,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(i,o,a,s,this._queryCellCircle,l,c),n?l.length>0:l},ce.prototype.query=function(t,e,r,n){return this._query(t,e,r,n,!1)},ce.prototype.hitTest=function(t,e,r,n){return this._query(t,e,r,n,!0)},ce.prototype.hitTestCircle=function(t,e,r){return this._queryCircle(t,e,r,!0)},ce.prototype._queryCell=function(t,e,r,n,i,a,o){var s=o.seenUids,l=this.boxCells[i];if(null!==l)for(var c=this.bboxes,u=0,f=l;u=c[p+0]&&n>=c[p+1]){if(o.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[h],x1:c[p],y1:c[p+1],x2:c[p+2],y2:c[p+3]})}}}var d=this.circleCells[i];if(null!==d)for(var g=this.circles,v=0,m=d;vo*o+s*s},ce.prototype._circleAndRectCollide=function(t,e,r,n,i,a,o){var s=(a-n)/2,l=Math.abs(t-(n+s));if(l>s+r)return!1;var c=(o-i)/2,u=Math.abs(e-(i+c));if(u>c+r)return!1;if(l<=s||u<=c)return!0;var f=l-s,h=u-c;return f*f+h*h<=r*r};var ue=t.default$19.layout;function fe(e,r,n,i,a){var o=t.mat4.identity(new Float32Array(16));return r?(t.mat4.identity(o),t.mat4.scale(o,o,[1/a,1/a,1]),n||t.mat4.rotateZ(o,o,i.angle)):(t.mat4.scale(o,o,[i.width/2,-i.height/2,1]),t.mat4.translate(o,o,[1,-1,0]),t.mat4.multiply(o,o,e)),o}function he(e,r,n,i,a){var o=t.mat4.identity(new Float32Array(16));return r?(t.mat4.multiply(o,o,e),t.mat4.scale(o,o,[a,a,1]),n||t.mat4.rotateZ(o,o,-i.angle)):(t.mat4.scale(o,o,[1,-1,1]),t.mat4.translate(o,o,[-1,-1,0]),t.mat4.scale(o,o,[2/i.width,2/i.height,1])),o}function pe(e,r){var n=[e.x,e.y,0,1];ke(n,n,r);var i=n[3];return{point:new t.default$1(n[0]/i,n[1]/i),signedDistanceFromCamera:i}}function de(t,e){var r=t[0]/t[3],n=t[1]/t[3];return r>=-e[0]&&r<=e[0]&&n>=-e[1]&&n<=e[1]}function ge(e,r,n,i,a,o,s,l){var c=i?e.textSizeData:e.iconSizeData,u=t.evaluateSizeForZoom(c,n.transform.zoom,ue.properties[i?"text-size":"icon-size"]),f=[256/n.width*2+1,256/n.height*2+1],h=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;h.clear();for(var p=e.lineVertexArray,d=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,g=n.transform.width/n.transform.height,v=!1,m=0;mMath.abs(n.x-r.x)*i?{useVertical:!0}:(e===t.WritingMode.vertical?r.yn.x)?{needsFlipping:!0}:null}function ye(e,r,n,i,a,o,s,l,c,u,f,h,p,d){var g,v=r/24,m=e.lineOffsetX*r,y=e.lineOffsetY*r;if(e.numGlyphs>1){var x=e.glyphStartIndex+e.numGlyphs,b=e.lineStartIndex,_=e.lineStartIndex+e.lineLength,w=ve(v,l,m,y,n,f,h,e,c,o,p,!1);if(!w)return{notEnoughRoom:!0};var k=pe(w.first.point,s).point,M=pe(w.last.point,s).point;if(i&&!n){var A=me(e.writingMode,k,M,d);if(A)return A}g=[w.first];for(var T=e.glyphStartIndex+1;T0?L.point:xe(h,E,S,1,a),O=me(e.writingMode,S,z,d);if(O)return O}var I=be(v*l.getoffsetX(e.glyphStartIndex),m,y,n,f,h,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,o,p,!1);if(!I)return{notEnoughRoom:!0};g=[I]}for(var P=0,D=g;P0?1:-1,v=0;i&&(g*=-1,v=Math.PI),g<0&&(v+=Math.PI);for(var m=g>0?l+s:l+s+1,y=m,x=a,b=a,_=0,w=0,k=Math.abs(d);_+w<=k;){if((m+=g)=c)return null;if(b=x,void 0===(x=h[m])){var M=new t.default$1(u.getx(m),u.gety(m)),A=pe(M,f);if(A.signedDistanceFromCamera>0)x=h[m]=A.point;else{var T=m-g;x=xe(0===_?o:new t.default$1(u.getx(T),u.gety(T)),M,b,k-_+1,f)}}_+=w,w=b.dist(x)}var S=(k-_)/w,C=x.sub(b),E=C.mult(S)._add(b);return E._add(C._unit()._perp()._mult(n*g)),{point:E,angle:v+Math.atan2(x.y-b.y,x.x-b.x),tileDistance:p?{prevTileDistance:m-g===y?0:u.gettileUnitDistanceFromAnchor(m-g),lastSegmentViewportDistance:k-_}:null}}var _e=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function we(t,e){for(var r=0;rT)Ae(e,S,!1);else{var O=this.projectPoint(u,C,E),I=L*k;if(d.length>0){var P=O.x-d[d.length-4],D=O.y-d[d.length-3];if(I*I*2>P*P+D*D&&S+8-A&&R=this.screenRightBoundary||n<100||e>this.screenBottomBoundary};var Se=t.default$19.layout,Ce=function(t,e,r,n){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):n&&r?1:0,this.placed=r};Ce.prototype.isHidden=function(){return 0===this.opacity&&!this.placed};var Ee=function(t,e,r,n,i){this.text=new Ce(t?t.text:null,e,r,i),this.icon=new Ce(t?t.icon:null,e,n,i)};Ee.prototype.isHidden=function(){return this.text.isHidden()&&this.icon.isHidden()};var Le=function(t,e,r){this.text=t,this.icon=e,this.skipFade=r},ze=function(t,e){this.transform=t.clone(),this.collisionIndex=new Me(this.transform),this.placements={},this.opacities={},this.stale=!1,this.fadeDuration=e,this.retainedQueryData={}};function Oe(t,e,r){t.emplaceBack(e?1:0,r?1:0),t.emplaceBack(e?1:0,r?1:0),t.emplaceBack(e?1:0,r?1:0),t.emplaceBack(e?1:0,r?1:0)}ze.prototype.placeLayerTile=function(e,r,n,i){var a=r.getBucket(e),o=r.latestFeatureIndex;if(a&&o&&e.id===a.layerIds[0]){var s=r.collisionBoxArray,l=a.layers[0].layout,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.default$8,f=this.transform.calculatePosMatrix(r.tileID.toUnwrapped()),h=fe(f,"map"===l.get("text-pitch-alignment"),"map"===l.get("text-rotation-alignment"),this.transform,Te(r,1,this.transform.zoom)),p=fe(f,"map"===l.get("icon-pitch-alignment"),"map"===l.get("icon-rotation-alignment"),this.transform,Te(r,1,this.transform.zoom));this.retainedQueryData[a.bucketInstanceId]=new function(t,e,r,n,i){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=r,this.bucketIndex=n,this.tileID=i}(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,r.tileID),this.placeLayerBucket(a,f,h,p,c,u,n,i,s)}},ze.prototype.placeLayerBucket=function(e,r,n,i,a,o,s,l,c){for(var u=e.layers[0].layout,f=t.evaluateSizeForZoom(e.textSizeData,this.transform.zoom,Se.properties["text-size"]),h=!e.hasTextData()||u.get("text-optional"),p=!e.hasIconData()||u.get("icon-optional"),d=0,g=e.symbolInstances;d0,x=x&&b.offscreen);var A=v.collisionArrays.textCircles;if(A){var T=e.text.placedSymbolArray.get(v.placedTextSymbolIndices[0]),S=t.evaluateSizeForFeature(e.textSizeData,f,T);_=this.collisionIndex.placeCollisionCircles(A,u.get("text-allow-overlap"),a,o,v.key,T,e.lineVertexArray,e.glyphOffsetArray,S,r,n,s,"map"===u.get("text-pitch-alignment")),m=u.get("text-allow-overlap")||_.circles.length>0,x=x&&_.offscreen}v.collisionArrays.iconFeatureIndex&&(M=v.collisionArrays.iconFeatureIndex),v.collisionArrays.iconBox&&(y=(w=this.collisionIndex.placeCollisionBox(v.collisionArrays.iconBox,u.get("icon-allow-overlap"),o,r)).box.length>0,x=x&&w.offscreen),h||p?p?h||(y=y&&m):m=y&&m:y=m=y&&m,m&&b&&this.collisionIndex.insertCollisionBox(b.box,u.get("text-ignore-placement"),e.bucketInstanceId,k),y&&w&&this.collisionIndex.insertCollisionBox(w.box,u.get("icon-ignore-placement"),e.bucketInstanceId,M),m&&_&&this.collisionIndex.insertCollisionCircles(_.circles,u.get("text-ignore-placement"),e.bucketInstanceId,k),this.placements[v.crossTileID]=new Le(m,y,x||e.justReloaded),l[v.crossTileID]=!0}}e.justReloaded=!1},ze.prototype.commit=function(t,e){this.commitTime=e;var r=!1,n=t&&0!==this.fadeDuration?(this.commitTime-t.commitTime)/this.fadeDuration:1,i=t?t.opacities:{};for(var a in this.placements){var o=this.placements[a],s=i[a];s?(this.opacities[a]=new Ee(s,n,o.text,o.icon),r=r||o.text!==s.text.placed||o.icon!==s.icon.placed):(this.opacities[a]=new Ee(null,n,o.text,o.icon,o.skipFade),r=r||o.text||o.icon)}for(var l in i){var c=i[l];if(!this.opacities[l]){var u=new Ee(c,n,!1,!1);u.isHidden()||(this.opacities[l]=u,r=r||c.text.placed||c.icon.placed)}}r?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)},ze.prototype.updateLayerOpacities=function(t,e){for(var r={},n=0,i=e;n0||s.numVerticalGlyphVertices>0,f=s.numIconVertices>0;if(u){for(var h=je(c.text),p=(s.numGlyphVertices+s.numVerticalGlyphVertices)/4,d=0;dt},ze.prototype.setStale=function(){this.stale=!0};var Ie=Math.pow(2,25),Pe=Math.pow(2,24),De=Math.pow(2,17),Re=Math.pow(2,16),Fe=Math.pow(2,9),Be=Math.pow(2,8),Ne=Math.pow(2,1);function je(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;var e=t.placed?1:0,r=Math.floor(127*t.opacity);return r*Ie+e*Pe+r*De+e*Re+r*Fe+e*Be+r*Ne+e}var Ve=function(){this._currentTileIndex=0,this._seenCrossTileIDs={}};Ve.prototype.continuePlacement=function(t,e,r,n,i){for(;this._currentTileIndex2};this._currentPlacementIndex>=0;){var s=e[t[n._currentPlacementIndex]],l=n.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){if(n._inProgressLayer||(n._inProgressLayer=new Ve),n._inProgressLayer.continuePlacement(r[s.source],n.placement,n._showCollisionBoxes,s,o))return;delete n._inProgressLayer}n._currentPlacementIndex--}this._done=!0},Ue.prototype.commit=function(t,e){return this.placement.commit(t,e),this.placement};var qe=512/t.default$8/2,He=function(t,e,r){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=r;for(var n=0,i=e;nt.overscaledZ)for(var l in s){var c=s[l];c.tileID.isChildOf(t)&&c.findMatches(e.symbolInstances,t,a)}else{var u=s[t.scaledTo(Number(o)).key];u&&u.findMatches(e.symbolInstances,t,a)}}for(var f=0,h=e.symbolInstances;f1?"@2x":"";function c(){if(s)n(s);else if(i&&o){var e=a.getImageData(o),r={};for(var l in i){var c=i[l],u=c.width,f=c.height,h=c.x,p=c.y,d=c.sdf,g=c.pixelRatio,v=new t.RGBAImage({width:u,height:f});t.RGBAImage.copy(e,v,{x:h,y:p},{x:0,y:0},{width:u,height:f}),r[l]={data:v,pixelRatio:g,sdf:d}}n(null,r)}}t.getJSON(r(_(e,l,".json"),t.ResourceType.SpriteJSON),function(t,e){s||(s=t,i=e,c())}),t.getImage(r(_(e,l,".png"),t.ResourceType.SpriteImage),function(t,e){s||(s=t,o=e,c())})}(e.sprite,this.map._transformRequest,function(e,r){if(e)n.fire(new t.ErrorEvent(e));else if(r)for(var i in r)n.imageManager.addImage(i,r[i]);n.imageManager.setLoaded(!0),n.fire(new t.Event("data",{dataType:"style"}))}):this.imageManager.setLoaded(!0),this.glyphManager.setURL(e.glyphs);var o=te(this.stylesheet.layers);this._order=o.map(function(t){return t.id}),this._layers={};for(var s=0,l=o;s0)throw new Error("Unimplemented: "+i.map(function(t){return t.command}).join(", ")+".");return n.forEach(function(t){"setTransition"!==t.command&&r[t.command].apply(r,t.args)}),this.stylesheet=e,!0},r.prototype.addImage=function(e,r){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(e,r),this.fire(new t.Event("data",{dataType:"style"}))},r.prototype.getImage=function(t){return this.imageManager.getImage(t)},r.prototype.removeImage=function(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(e),this.fire(new t.Event("data",{dataType:"style"}))},r.prototype.addSource=function(e,r,n){var i=this;if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error("There is already a source with this ID");if(!r.type)throw new Error("The type property must be defined, but the only the following properties were given: "+Object.keys(r).join(", ")+".");if(!(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(t.validateStyle.source,"sources."+e,r,null,n))){this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);var a=this.sourceCaches[e]=new Yt(e,r,this.dispatcher);a.style=this,a.setEventedParent(this,function(){return{isSourceLoaded:i.loaded(),source:a.serialize(),sourceId:e}}),a.onAdd(this.map),this._changed=!0}},r.prototype.removeSource=function(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(var r in this._layers)if(this._layers[r].source===e)return this.fire(new t.ErrorEvent(new Error('Source "'+e+'" cannot be removed while layer "'+r+'" is using it.')));var n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.clearTiles(),n.onRemove&&n.onRemove(this.map),this._changed=!0},r.prototype.setGeoJSONSourceData=function(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0},r.prototype.getSource=function(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()},r.prototype.addLayer=function(e,r,n){this._checkLoaded();var i=e.id;if(this.getLayer(i))this.fire(new t.ErrorEvent(new Error('Layer with id "'+i+'" already exists on this map')));else if("object"==typeof e.source&&(this.addSource(i,e.source),e=t.clone(e),e=t.extend(e,{source:i})),!this._validate(t.validateStyle.layer,"layers."+i,e,{arrayIndex:-1},n)){var a=t.default$22(e);this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}});var o=r?this._order.indexOf(r):this._order.length;if(r&&-1===o)this.fire(new t.ErrorEvent(new Error('Layer with id "'+r+'" does not exist on this map.')));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source){var s=this._removedLayers[i];delete this._removedLayers[i],s.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause())}this._updateLayer(a)}}},r.prototype.moveLayer=function(e,r){if(this._checkLoaded(),this._changed=!0,this._layers[e]){if(e!==r){var n=this._order.indexOf(e);this._order.splice(n,1);var i=r?this._order.indexOf(r):this._order.length;r&&-1===i?this.fire(new t.ErrorEvent(new Error('Layer with id "'+r+'" does not exist on this map.'))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be moved.")))},r.prototype.removeLayer=function(e){this._checkLoaded();var r=this._layers[e];if(r){r.setEventedParent(null);var n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=r,delete this._layers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e]}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be removed.")))},r.prototype.getLayer=function(t){return this._layers[t]},r.prototype.setLayerZoomRange=function(e,r,n){this._checkLoaded();var i=this.getLayer(e);i?i.minzoom===r&&i.maxzoom===n||(null!=r&&(i.minzoom=r),null!=n&&(i.maxzoom=n),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot have zoom extent.")))},r.prototype.setFilter=function(e,r){this._checkLoaded();var n=this.getLayer(e);if(n){if(!t.default$10(n.filter,r))return null==r?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(t.validateStyle.filter,"layers."+n.id+".filter",r)||(n.filter=t.clone(r),this._updateLayer(n)))}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be filtered.")))},r.prototype.getFilter=function(e){return t.clone(this.getLayer(e).filter)},r.prototype.setLayoutProperty=function(e,r,n){this._checkLoaded();var i=this.getLayer(e);i?t.default$10(i.getLayoutProperty(r),n)||(i.setLayoutProperty(r,n),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},r.prototype.getLayoutProperty=function(t,e){return this.getLayer(t).getLayoutProperty(e)},r.prototype.setPaintProperty=function(e,r,n){this._checkLoaded();var i=this.getLayer(e);if(i){if(!t.default$10(i.getPaintProperty(r),n)){var a=i._transitionablePaint._values[r].value.isDataDriven();i.setPaintProperty(r,n),(i._transitionablePaint._values[r].value.isDataDriven()||a)&&this._updateLayer(i),this._changed=!0,this._updatedPaintProps[e]=!0}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},r.prototype.getPaintProperty=function(t,e){return this.getLayer(t).getPaintProperty(e)},r.prototype.getTransition=function(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)},r.prototype.serialize=function(){var e=this;return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:t.mapObject(this.sourceCaches,function(t){return t.serialize()}),layers:this._order.map(function(t){return e._layers[t].serialize()})},function(t){return void 0!==t})},r.prototype._updateLayer=function(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0},r.prototype._flattenRenderedFeatures=function(t){for(var e=[],r=this._order.length-1;r>=0;r--)for(var n=this._order[r],i=0,a=t;i 0.5) {\n gl_FragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha;\n }\n\n if (v_notUsed > 0.5) {\n // This box not used, fade it out\n gl_FragColor *= .1;\n }\n}",vertexSource:"attribute vec2 a_pos;\nattribute vec2 a_anchor_pos;\nattribute vec2 a_extrude;\nattribute vec2 a_placed;\n\nuniform mat4 u_matrix;\nuniform vec2 u_extrude_scale;\nuniform float u_camera_to_center_distance;\n\nvarying float v_placed;\nvarying float v_notUsed;\n\nvoid main() {\n vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n highp float collision_perspective_ratio = clamp(\n 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),\n 0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles\n 4.0);\n\n gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n gl_Position.xy += a_extrude * u_extrude_scale * gl_Position.w * collision_perspective_ratio;\n\n v_placed = a_placed.x;\n v_notUsed = a_placed.y;\n}\n"},collisionCircle:{fragmentSource:"uniform float u_overscale_factor;\n\nvarying float v_placed;\nvarying float v_notUsed;\nvarying float v_radius;\nvarying vec2 v_extrude;\nvarying vec2 v_extrude_scale;\n\nvoid main() {\n float alpha = 0.5;\n\n // Red = collision, hide label\n vec4 color = vec4(1.0, 0.0, 0.0, 1.0) * alpha;\n\n // Blue = no collision, label is showing\n if (v_placed > 0.5) {\n color = vec4(0.0, 0.0, 1.0, 0.5) * alpha;\n }\n\n if (v_notUsed > 0.5) {\n // This box not used, fade it out\n color *= .2;\n }\n\n float extrude_scale_length = length(v_extrude_scale);\n float extrude_length = length(v_extrude) * extrude_scale_length;\n float stroke_width = 15.0 * extrude_scale_length / u_overscale_factor;\n float radius = v_radius * extrude_scale_length;\n\n float distance_to_edge = abs(extrude_length - radius);\n float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge);\n\n gl_FragColor = opacity_t * color;\n}\n",vertexSource:"attribute vec2 a_pos;\nattribute vec2 a_anchor_pos;\nattribute vec2 a_extrude;\nattribute vec2 a_placed;\n\nuniform mat4 u_matrix;\nuniform vec2 u_extrude_scale;\nuniform float u_camera_to_center_distance;\n\nvarying float v_placed;\nvarying float v_notUsed;\nvarying float v_radius;\n\nvarying vec2 v_extrude;\nvarying vec2 v_extrude_scale;\n\nvoid main() {\n vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n highp float collision_perspective_ratio = clamp(\n 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),\n 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles\n 4.0);\n\n gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n\n highp float padding_factor = 1.2; // Pad the vertices slightly to make room for anti-alias blur\n gl_Position.xy += a_extrude * u_extrude_scale * padding_factor * gl_Position.w * collision_perspective_ratio;\n\n v_placed = a_placed.x;\n v_notUsed = a_placed.y;\n v_radius = abs(a_extrude.y); // We don't pitch the circles, so both units of the extrusion vector are equal in magnitude to the radius\n\n v_extrude = a_extrude * padding_factor;\n v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio;\n}\n"},debug:{fragmentSource:"uniform highp vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n}\n"},fill:{fragmentSource:"#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float opacity\n\n gl_FragColor = color * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n}\n"},fillOutline:{fragmentSource:"#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_pos;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = 1.0 - smoothstep(0.0, 1.0, dist);\n gl_FragColor = outline_color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\nuniform vec2 u_world;\n\nvarying vec2 v_pos;\n\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},fillOutlinePattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n // find distance to outline for alpha interpolation\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = 1.0 - smoothstep(0.0, 1.0, dist);\n\n\n gl_FragColor = mix(color1, color2, u_mix) * alpha * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_world;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);\n\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},fillPattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n gl_FragColor = mix(color1, color2, u_mix) * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);\n}\n"},fillExtrusion:{fragmentSource:"varying vec4 v_color;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define highp vec4 color\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n #pragma mapbox: initialize highp vec4 color\n\n gl_FragColor = v_color;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec3 u_lightcolor;\nuniform lowp vec3 u_lightpos;\nuniform lowp float u_lightintensity;\n\nattribute vec2 a_pos;\nattribute vec4 a_normal_ed;\n\nvarying vec4 v_color;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\n#pragma mapbox: define highp vec4 color\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n #pragma mapbox: initialize highp vec4 color\n\n vec3 normal = a_normal_ed.xyz;\n\n base = max(0.0, base);\n height = max(0.0, height);\n\n float t = mod(normal.x, 2.0);\n\n gl_Position = u_matrix * vec4(a_pos, t > 0.0 ? height : base, 1);\n\n // Relative luminance (how dark/bright is the surface color?)\n float colorvalue = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722;\n\n v_color = vec4(0.0, 0.0, 0.0, 1.0);\n\n // Add slight ambient lighting so no extrusions are totally black\n vec4 ambientlight = vec4(0.03, 0.03, 0.03, 1.0);\n color += ambientlight;\n\n // Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray\n float directional = clamp(dot(normal / 16384.0, u_lightpos), 0.0, 1.0);\n\n // Adjust directional so that\n // the range of values for highlight/shading is narrower\n // with lower light intensity\n // and with lighter/brighter surface colors\n directional = mix((1.0 - u_lightintensity), max((1.0 - colorvalue + u_lightintensity), 1.0), directional);\n\n // Add gradient along z axis of side surfaces\n if (normal.y != 0.0) {\n directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0);\n }\n\n // Assign final color based on surface + ambient light color, diffuse light directional, and light color\n // with lower bounds adjusted to hue of light\n // so that shading is tinted with the complementary (opposite) color to the light color\n v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0);\n v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0);\n v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0);\n}\n"},fillExtrusionPattern:{fragmentSource:"uniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec4 v_lighting;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n vec4 mixedColor = mix(color1, color2, u_mix);\n\n gl_FragColor = mixedColor * v_lighting;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\nuniform float u_height_factor;\n\nuniform vec3 u_lightcolor;\nuniform lowp vec3 u_lightpos;\nuniform lowp float u_lightintensity;\n\nattribute vec2 a_pos;\nattribute vec4 a_normal_ed;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec4 v_lighting;\nvarying float v_directional;\n\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n\nvoid main() {\n #pragma mapbox: initialize lowp float base\n #pragma mapbox: initialize lowp float height\n\n vec3 normal = a_normal_ed.xyz;\n float edgedistance = a_normal_ed.w;\n\n base = max(0.0, base);\n height = max(0.0, height);\n\n float t = mod(normal.x, 2.0);\n float z = t > 0.0 ? height : base;\n\n gl_Position = u_matrix * vec4(a_pos, z, 1);\n\n vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0\n ? a_pos // extrusion top\n : vec2(edgedistance, z * u_height_factor); // extrusion side\n\n v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, pos);\n v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, pos);\n\n v_lighting = vec4(0.0, 0.0, 0.0, 1.0);\n float directional = clamp(dot(normal / 16383.0, u_lightpos), 0.0, 1.0);\n directional = mix((1.0 - u_lightintensity), max((0.5 + u_lightintensity), 1.0), directional);\n\n if (normal.y != 0.0) {\n directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0);\n }\n\n v_lighting.rgb += clamp(directional * u_lightcolor, mix(vec3(0.0), vec3(0.3), 1.0 - u_lightcolor), vec3(1.0));\n}\n"},extrusionTexture:{fragmentSource:"uniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\n\nvoid main() {\n gl_FragColor = texture2D(u_image, v_pos) * u_opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(0.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_world;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1);\n\n v_pos.x = a_pos.x;\n v_pos.y = 1.0 - a_pos.y;\n}\n"},hillshadePrepare:{fragmentSource:"#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D u_image;\nvarying vec2 v_pos;\nuniform vec2 u_dimension;\nuniform float u_zoom;\nuniform float u_maxzoom;\n\nfloat getElevation(vec2 coord, float bias) {\n // Convert encoded elevation value to meters\n vec4 data = texture2D(u_image, coord) * 255.0;\n return (data.r + data.g * 256.0 + data.b * 256.0 * 256.0) / 4.0;\n}\n\nvoid main() {\n vec2 epsilon = 1.0 / u_dimension;\n\n // queried pixels:\n // +-----------+\n // | | | |\n // | a | b | c |\n // | | | |\n // +-----------+\n // | | | |\n // | d | e | f |\n // | | | |\n // +-----------+\n // | | | |\n // | g | h | i |\n // | | | |\n // +-----------+\n\n float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0);\n float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0);\n float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0);\n float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0);\n float e = getElevation(v_pos, 0.0);\n float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0);\n float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0);\n float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0);\n float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0);\n\n // here we divide the x and y slopes by 8 * pixel size\n // where pixel size (aka meters/pixel) is:\n // circumference of the world / (pixels per tile * number of tiles)\n // which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom))\n // which can be reduced to: pow(2, 19.25619978527 - u_zoom)\n // we want to vertically exaggerate the hillshading though, because otherwise\n // it is barely noticeable at low zooms. to do this, we multiply this by some\n // scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value\n // Here we use a=0.3 which works out to the expression below. see \n // nickidlugash's awesome breakdown for more info\n // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556\n float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;\n\n vec2 deriv = vec2(\n (c + f + f + i) - (a + d + d + g),\n (g + h + h + i) - (a + b + b + c)\n ) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom);\n\n gl_FragColor = clamp(vec4(\n deriv.x / 2.0 + 0.5,\n deriv.y / 2.0 + 0.5,\n 1.0,\n 1.0), 0.0, 1.0);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = (a_texture_pos / 8192.0) / 2.0 + 0.25;\n}\n"},hillshade:{fragmentSource:"uniform sampler2D u_image;\nvarying vec2 v_pos;\n\nuniform vec2 u_latrange;\nuniform vec2 u_light;\nuniform vec4 u_shadow;\nuniform vec4 u_highlight;\nuniform vec4 u_accent;\n\n#define PI 3.141592653589793\n\nvoid main() {\n vec4 pixel = texture2D(u_image, v_pos);\n\n vec2 deriv = ((pixel.rg * 2.0) - 1.0);\n\n // We divide the slope by a scale factor based on the cosin of the pixel's approximate latitude\n // to account for mercator projection distortion. see #4807 for details\n float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_pos.y) + u_latrange[1]));\n // We also multiply the slope by an arbitrary z-factor of 1.25\n float slope = atan(1.25 * length(deriv) / scaleFactor);\n float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0);\n\n float intensity = u_light.x;\n // We add PI to make this property match the global light object, which adds PI/2 to the light's azimuthal\n // position property to account for 0deg corresponding to north/the top of the viewport in the style spec\n // and the original shader was written to accept (-illuminationDirection - 90) as the azimuthal.\n float azimuth = u_light.y + PI;\n\n // We scale the slope exponentially based on intensity, using a calculation similar to\n // the exponential interpolation function in the style spec:\n // https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/expression/definitions/interpolate.js#L217-L228\n // so that higher intensity values create more opaque hillshading.\n float base = 1.875 - intensity * 1.75;\n float maxValue = 0.5 * PI;\n float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope;\n\n // The accent color is calculated with the cosine of the slope while the shade color is calculated with the sine\n // so that the accent color's rate of change eases in while the shade color's eases out.\n float accent = cos(scaledSlope);\n // We multiply both the accent and shade color by a clamped intensity value\n // so that intensities >= 0.5 do not additionally affect the color values\n // while intensity values < 0.5 make the overall color more transparent.\n vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0);\n float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0);\n vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0);\n gl_FragColor = accent_color * (1.0 - shade_color.a) + shade_color;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = a_texture_pos / 8192.0;\n}\n"},line:{fragmentSource:"#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_width2;\nvarying vec2 v_normal;\nvarying float v_gamma_scale;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_gamma_scale;\nvarying highp float v_linesofar;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n\n v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_width2 = vec2(outset, inset);\n}\n"},lineGradient:{fragmentSource:"\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nuniform sampler2D u_image;\n\nvarying vec2 v_width2;\nvarying vec2 v_normal;\nvarying float v_gamma_scale;\nvarying highp float v_lineprogress;\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n // For gradient lines, v_lineprogress is the ratio along the entire line,\n // scaled to [0, 2^15), and the gradient ramp is stored in a texture.\n vec4 color = texture2D(u_image, vec2(v_lineprogress, 0.5));\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"\n// the attribute conveying progress along a line is scaled to [0, 2^15)\n#define MAX_LINE_DISTANCE 32767.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_gamma_scale;\nvarying highp float v_lineprogress;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n\n v_lineprogress = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_width2 = vec2(outset, inset);\n}\n"},linePattern:{fragmentSource:"uniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform vec2 u_texsize;\nuniform float u_fade;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n float x_a = mod(v_linesofar / u_pattern_size_a.x, 1.0);\n float x_b = mod(v_linesofar / u_pattern_size_b.x, 1.0);\n\n // v_normal.y is 0 at the midpoint of the line, -1 at the lower edge, 1 at the upper edge\n // we clamp the line width outset to be between 0 and half the pattern height plus padding (2.0)\n // to ensure we don't sample outside the designated symbol on the sprite sheet.\n // 0.5 is added to shift the component to be bounded between 0 and 1 for interpolation of\n // the texture coordinate\n float y_a = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (u_pattern_size_a.y + 2.0) / 2.0) / u_pattern_size_a.y);\n float y_b = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (u_pattern_size_b.y + 2.0) / 2.0) / u_pattern_size_b.y);\n vec2 pos_a = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, vec2(x_a, y_a));\n vec2 pos_b = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, vec2(x_b, y_b));\n\n vec4 color = mix(texture2D(u_image, pos_a), texture2D(u_image, pos_b), u_fade);\n\n gl_FragColor = color * alpha * opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n\nvoid main() {\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize mediump float width\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_linesofar = a_linesofar;\n v_width2 = vec2(outset, inset);\n}\n"},lineSDF:{fragmentSource:"\nuniform sampler2D u_image;\nuniform float u_sdfgamma;\nuniform float u_mix;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float width\n #pragma mapbox: initialize lowp float floorwidth\n\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_width2.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_width2.t) or when fading out\n // (v_width2.s)\n float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;\n float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);\n\n float sdfdist_a = texture2D(u_image, v_tex_a).a;\n float sdfdist_b = texture2D(u_image, v_tex_b).a;\n float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix);\n alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist);\n\n gl_FragColor = color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\n// the distance over which the line edge fades out.\n// Retina devices need a smaller distance to avoid aliasing.\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n\nattribute vec4 a_pos_normal;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform vec2 u_patternscale_a;\nuniform float u_tex_y_a;\nuniform vec2 u_patternscale_b;\nuniform float u_tex_y_b;\nuniform vec2 u_gl_units_to_pixels;\n\nvarying vec2 v_normal;\nvarying vec2 v_width2;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 color\n #pragma mapbox: initialize lowp float blur\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize mediump float gapwidth\n #pragma mapbox: initialize lowp float offset\n #pragma mapbox: initialize mediump float width\n #pragma mapbox: initialize lowp float floorwidth\n\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n vec2 pos = a_pos_normal.xy;\n\n // x is 1 if it's a round cap, 0 otherwise\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = a_pos_normal.zw;\n v_normal = normal;\n\n // these transformations used to be applied in the JS and native code bases.\n // moved them into the shader for clarity and simplicity.\n gapwidth = gapwidth / 2.0;\n float halfwidth = width / 2.0;\n offset = -1.0 * offset;\n\n float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);\n float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist =outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);\n gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;\n\n // calculate how much the perspective view squishes or stretches the extrude\n float extrude_length_without_perspective = length(dist);\n float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_gl_units_to_pixels);\n v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;\n\n v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a);\n v_tex_b = vec2(a_linesofar * u_patternscale_b.x / floorwidth, normal.y * u_patternscale_b.y + u_tex_y_b);\n\n v_width2 = vec2(outset, inset);\n}\n"},raster:{fragmentSource:"uniform float u_fade_t;\nuniform float u_opacity;\nuniform sampler2D u_image0;\nuniform sampler2D u_image1;\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nuniform float u_brightness_low;\nuniform float u_brightness_high;\n\nuniform float u_saturation_factor;\nuniform float u_contrast_factor;\nuniform vec3 u_spin_weights;\n\nvoid main() {\n\n // read and cross-fade colors from the main and parent tiles\n vec4 color0 = texture2D(u_image0, v_pos0);\n vec4 color1 = texture2D(u_image1, v_pos1);\n if (color0.a > 0.0) {\n color0.rgb = color0.rgb / color0.a;\n }\n if (color1.a > 0.0) {\n color1.rgb = color1.rgb / color1.a;\n }\n vec4 color = mix(color0, color1, u_fade_t);\n color.a *= u_opacity;\n vec3 rgb = color.rgb;\n\n // spin\n rgb = vec3(\n dot(rgb, u_spin_weights.xyz),\n dot(rgb, u_spin_weights.zxy),\n dot(rgb, u_spin_weights.yzx));\n\n // saturation\n float average = (color.r + color.g + color.b) / 3.0;\n rgb += (average - rgb) * u_saturation_factor;\n\n // contrast\n rgb = (rgb - 0.5) * u_contrast_factor + 0.5;\n\n // brightness\n vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);\n vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);\n\n gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"uniform mat4 u_matrix;\nuniform vec2 u_tl_parent;\nuniform float u_scale_parent;\nuniform float u_buffer_scale;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n // We are using Int16 for texture position coordinates to give us enough precision for\n // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer\n // as an arbitrarily high number to preserve adequate precision when rendering.\n // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates,\n // so math for modifying either is consistent.\n v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5;\n v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;\n}\n"},symbolIcon:{fragmentSource:"uniform sampler2D u_texture;\n\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_tex;\nvarying float v_fade_opacity;\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n lowp float alpha = opacity * v_fade_opacity;\n gl_FragColor = texture2D(u_texture, v_tex) * alpha;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"const float PI = 3.141592653589793;\n\nattribute vec4 a_pos_offset;\nattribute vec4 a_data;\nattribute vec3 a_projected_pos;\nattribute float a_fade_opacity;\n\nuniform bool u_is_size_zoom_constant;\nuniform bool u_is_size_feature_constant;\nuniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function\nuniform highp float u_size; // used when size is both zoom and feature constant\nuniform highp float u_camera_to_center_distance;\nuniform highp float u_pitch;\nuniform bool u_rotate_symbol;\nuniform highp float u_aspect_ratio;\nuniform float u_fade_change;\n\n#pragma mapbox: define lowp float opacity\n\nuniform mat4 u_matrix;\nuniform mat4 u_label_plane_matrix;\nuniform mat4 u_gl_coord_matrix;\n\nuniform bool u_is_text;\nuniform bool u_pitch_with_map;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_tex;\nvarying float v_fade_opacity;\n\nvoid main() {\n #pragma mapbox: initialize lowp float opacity\n\n vec2 a_pos = a_pos_offset.xy;\n vec2 a_offset = a_pos_offset.zw;\n\n vec2 a_tex = a_data.xy;\n vec2 a_size = a_data.zw;\n\n highp float segment_angle = -a_projected_pos[2];\n\n float size;\n if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = mix(a_size[0], a_size[1], u_size_t) / 10.0;\n } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = a_size[0] / 10.0;\n } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {\n size = u_size;\n } else {\n size = u_size;\n }\n\n vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n // See comments in symbol_sdf.vertex\n highp float distance_ratio = u_pitch_with_map ?\n camera_to_anchor_distance / u_camera_to_center_distance :\n u_camera_to_center_distance / camera_to_anchor_distance;\n highp float perspective_ratio = clamp(\n 0.5 + 0.5 * distance_ratio,\n 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles\n 4.0);\n\n size *= perspective_ratio;\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n highp float symbol_rotation = 0.0;\n if (u_rotate_symbol) {\n // See comments in symbol_sdf.vertex\n vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);\n\n vec2 a = projectedPoint.xy / projectedPoint.w;\n vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;\n\n symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);\n }\n\n highp float angle_sin = sin(segment_angle + symbol_rotation);\n highp float angle_cos = cos(segment_angle + symbol_rotation);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);\n gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);\n\n v_tex = a_tex / u_texsize;\n vec2 fade_opacity = unpack_opacity(a_fade_opacity);\n float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;\n v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));\n}\n"},symbolSDF:{fragmentSource:"#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105/DEVICE_PIXEL_RATIO\n\nuniform bool u_is_halo;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n\nuniform sampler2D u_texture;\nuniform highp float u_gamma_scale;\nuniform bool u_is_text;\n\nvarying vec2 v_data0;\nvarying vec3 v_data1;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 fill_color\n #pragma mapbox: initialize highp vec4 halo_color\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float halo_width\n #pragma mapbox: initialize lowp float halo_blur\n\n vec2 tex = v_data0.xy;\n float gamma_scale = v_data1.x;\n float size = v_data1.y;\n float fade_opacity = v_data1[2];\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n lowp vec4 color = fill_color;\n highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);\n lowp float buff = (256.0 - 64.0) / 256.0;\n if (u_is_halo) {\n color = halo_color;\n gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);\n buff = (6.0 - halo_width / fontScale) / SDF_PX;\n }\n\n lowp float dist = texture2D(u_texture, tex).a;\n highp float gamma_scaled = gamma * gamma_scale;\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = color * (alpha * opacity * fade_opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"const float PI = 3.141592653589793;\n\nattribute vec4 a_pos_offset;\nattribute vec4 a_data;\nattribute vec3 a_projected_pos;\nattribute float a_fade_opacity;\n\n// contents of a_size vary based on the type of property value\n// used for {text,icon}-size.\n// For constants, a_size is disabled.\n// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.\n// For composite functions:\n// [ text-size(lowerZoomStop, feature),\n// text-size(upperZoomStop, feature) ]\nuniform bool u_is_size_zoom_constant;\nuniform bool u_is_size_feature_constant;\nuniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function\nuniform highp float u_size; // used when size is both zoom and feature constant\n\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n\nuniform mat4 u_matrix;\nuniform mat4 u_label_plane_matrix;\nuniform mat4 u_gl_coord_matrix;\n\nuniform bool u_is_text;\nuniform bool u_pitch_with_map;\nuniform highp float u_pitch;\nuniform bool u_rotate_symbol;\nuniform highp float u_aspect_ratio;\nuniform highp float u_camera_to_center_distance;\nuniform float u_fade_change;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_data0;\nvarying vec3 v_data1;\n\nvoid main() {\n #pragma mapbox: initialize highp vec4 fill_color\n #pragma mapbox: initialize highp vec4 halo_color\n #pragma mapbox: initialize lowp float opacity\n #pragma mapbox: initialize lowp float halo_width\n #pragma mapbox: initialize lowp float halo_blur\n\n vec2 a_pos = a_pos_offset.xy;\n vec2 a_offset = a_pos_offset.zw;\n\n vec2 a_tex = a_data.xy;\n vec2 a_size = a_data.zw;\n\n highp float segment_angle = -a_projected_pos[2];\n float size;\n\n if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = mix(a_size[0], a_size[1], u_size_t) / 10.0;\n } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {\n size = a_size[0] / 10.0;\n } else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {\n size = u_size;\n } else {\n size = u_size;\n }\n\n vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);\n highp float camera_to_anchor_distance = projectedPoint.w;\n // If the label is pitched with the map, layout is done in pitched space,\n // which makes labels in the distance smaller relative to viewport space.\n // We counteract part of that effect by multiplying by the perspective ratio.\n // If the label isn't pitched with the map, we do layout in viewport space,\n // which makes labels in the distance larger relative to the features around\n // them. We counteract part of that effect by dividing by the perspective ratio.\n highp float distance_ratio = u_pitch_with_map ?\n camera_to_anchor_distance / u_camera_to_center_distance :\n u_camera_to_center_distance / camera_to_anchor_distance;\n highp float perspective_ratio = clamp(\n 0.5 + 0.5 * distance_ratio,\n 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles\n 4.0);\n\n size *= perspective_ratio;\n\n float fontScale = u_is_text ? size / 24.0 : size;\n\n highp float symbol_rotation = 0.0;\n if (u_rotate_symbol) {\n // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units\n // To figure out that angle in projected space, we draw a short horizontal line in tile\n // space, project it, and measure its angle in projected space.\n vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);\n\n vec2 a = projectedPoint.xy / projectedPoint.w;\n vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;\n\n symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);\n }\n\n highp float angle_sin = sin(segment_angle + symbol_rotation);\n highp float angle_cos = cos(segment_angle + symbol_rotation);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);\n gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);\n float gamma_scale = gl_Position.w;\n\n vec2 tex = a_tex / u_texsize;\n vec2 fade_opacity = unpack_opacity(a_fade_opacity);\n float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;\n float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));\n\n v_data0 = vec2(tex.x, tex.y);\n v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity);\n}\n"}},tr=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,er=function(t){var e=Qe[t],r={};e.fragmentSource=e.fragmentSource.replace(tr,function(t,e,n,i,a){return r[a]=!0,"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nvarying "+n+" "+i+" "+a+";\n#else\nuniform "+n+" "+i+" u_"+a+";\n#endif\n":"\n#ifdef HAS_UNIFORM_u_"+a+"\n "+n+" "+i+" "+a+" = u_"+a+";\n#endif\n"}),e.vertexSource=e.vertexSource.replace(tr,function(t,e,n,i,a){var o="float"===i?"vec2":"vec4";return r[a]?"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float a_"+a+"_t;\nattribute "+n+" "+o+" a_"+a+";\nvarying "+n+" "+i+" "+a+";\n#else\nuniform "+n+" "+i+" u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+a+" = unpack_mix_"+o+"(a_"+a+", a_"+a+"_t);\n#else\n "+n+" "+i+" "+a+" = u_"+a+";\n#endif\n":"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float a_"+a+"_t;\nattribute "+n+" "+o+" a_"+a+";\n#else\nuniform "+n+" "+i+" u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+n+" "+i+" "+a+" = unpack_mix_"+o+"(a_"+a+", a_"+a+"_t);\n#else\n "+n+" "+i+" "+a+" = u_"+a+";\n#endif\n"})};for(var rr in Qe)er(rr);var nr=Qe,ir=function(t,e,r,n){var i=t.gl;this.program=i.createProgram();var o=r.defines().concat("#define DEVICE_PIXEL_RATIO "+a.devicePixelRatio.toFixed(1));n&&o.push("#define OVERDRAW_INSPECTOR;");var s=o.concat(nr.prelude.fragmentSource,e.fragmentSource).join("\n"),l=o.concat(nr.prelude.vertexSource,e.vertexSource).join("\n"),c=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(c,s),i.compileShader(c),i.attachShader(this.program,c);var u=i.createShader(i.VERTEX_SHADER);i.shaderSource(u,l),i.compileShader(u),i.attachShader(this.program,u);for(var f=r.layoutAttributes||[],h=0;h>16,s>>16),n.uniform2f(r.uniforms.u_pixel_coord_lower,65535&o,65535&s)};function mr(t,e,r,n,i){if(!dr(r.paint.get("fill-pattern"),t))for(var a=!0,o=0,s=n;o0){var l=a.now(),c=(l-e.timeAdded)/s,u=r?(l-r.timeAdded)/s:-1,f=n.getSource(),h=o.coveringZoomLevel({tileSize:f.tileSize,roundZoom:f.roundZoom}),p=!r||Math.abs(r.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),d=p&&e.refreshedUponExpiration?1:t.clamp(p?c:1-u,0,1);return e.refreshedUponExpiration&&c>=1&&(e.refreshedUponExpiration=!1),r?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}function Cr(e,r,n){var i=e.context,o=i.gl;i.lineWidth.set(1*a.devicePixelRatio);var s=n.posMatrix,l=e.useProgram("debug");i.setDepthMode(qt.disabled),i.setStencilMode(Ht.disabled),i.setColorMode(e.colorModeForRenderPass()),o.uniformMatrix4fv(l.uniforms.u_matrix,!1,s),o.uniform4f(l.uniforms.u_color,1,0,0,1),e.debugVAO.bind(i,l,e.debugBuffer,[]),o.drawArrays(o.LINE_STRIP,0,e.debugBuffer.length);for(var c=function(t,e,r,n){n=n||1;var i,a,o,s,l,c,u,f,h=[];for(i=0,a=t.length;i":[24,[4,18,20,9,4,0]],"?":[18,[3,16,3,17,4,19,5,20,7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,12,9,10,9,7,-1,-1,9,2,8,1,9,0,10,1,9,2]],"@":[27,[18,13,17,15,15,16,12,16,10,15,9,14,8,11,8,8,9,6,11,5,14,5,16,6,17,8,-1,-1,12,16,10,14,9,11,9,8,10,6,11,5,-1,-1,18,16,17,8,17,6,19,5,21,5,23,7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,21,9,20,7,19,5,17,4,15,3,12,3,9,4,6,5,4,7,2,9,1,12,0,15,0,18,1,20,2,21,3,-1,-1,19,16,18,8,18,6,19,5]],A:[18,[9,21,1,0,-1,-1,9,21,17,0,-1,-1,4,7,14,7]],B:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,-1,-1,4,11,13,11,16,10,17,9,18,7,18,4,17,2,16,1,13,0,4,0]],C:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5]],D:[21,[4,21,4,0,-1,-1,4,21,11,21,14,20,16,18,17,16,18,13,18,8,17,5,16,3,14,1,11,0,4,0]],E:[19,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11,-1,-1,4,0,17,0]],F:[18,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11]],G:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,18,8,-1,-1,13,8,18,8]],H:[22,[4,21,4,0,-1,-1,18,21,18,0,-1,-1,4,11,18,11]],I:[8,[4,21,4,0]],J:[16,[12,21,12,5,11,2,10,1,8,0,6,0,4,1,3,2,2,5,2,7]],K:[21,[4,21,4,0,-1,-1,18,21,4,7,-1,-1,9,12,18,0]],L:[17,[4,21,4,0,-1,-1,4,0,16,0]],M:[24,[4,21,4,0,-1,-1,4,21,12,0,-1,-1,20,21,12,0,-1,-1,20,21,20,0]],N:[22,[4,21,4,0,-1,-1,4,21,18,0,-1,-1,18,21,18,0]],O:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21]],P:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,10,4,10]],Q:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21,-1,-1,12,4,18,-2]],R:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,4,11,-1,-1,11,11,18,0]],S:[20,[17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3]],T:[16,[8,21,8,0,-1,-1,1,21,15,21]],U:[22,[4,21,4,6,5,3,7,1,10,0,12,0,15,1,17,3,18,6,18,21]],V:[18,[1,21,9,0,-1,-1,17,21,9,0]],W:[24,[2,21,7,0,-1,-1,12,21,7,0,-1,-1,12,21,17,0,-1,-1,22,21,17,0]],X:[20,[3,21,17,0,-1,-1,17,21,3,0]],Y:[18,[1,21,9,11,9,0,-1,-1,17,21,9,11]],Z:[20,[17,21,3,0,-1,-1,3,21,17,21,-1,-1,3,0,17,0]],"[":[14,[4,25,4,-7,-1,-1,5,25,5,-7,-1,-1,4,25,11,25,-1,-1,4,-7,11,-7]],"\\":[14,[0,21,14,-3]],"]":[14,[9,25,9,-7,-1,-1,10,25,10,-7,-1,-1,3,25,10,25,-1,-1,3,-7,10,-7]],"^":[16,[6,15,8,18,10,15,-1,-1,3,12,8,17,13,12,-1,-1,8,17,8,0]],_:[16,[0,-2,16,-2]],"`":[10,[6,21,5,20,4,18,4,16,5,15,6,16,5,17]],a:[19,[15,14,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],b:[19,[4,21,4,0,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],c:[18,[15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],d:[19,[15,21,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],e:[18,[3,8,15,8,15,10,14,12,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],f:[12,[10,21,8,21,6,20,5,17,5,0,-1,-1,2,14,9,14]],g:[19,[15,14,15,-2,14,-5,13,-6,11,-7,8,-7,6,-6,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],h:[19,[4,21,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],i:[8,[3,21,4,20,5,21,4,22,3,21,-1,-1,4,14,4,0]],j:[10,[5,21,6,20,7,21,6,22,5,21,-1,-1,6,14,6,-3,5,-6,3,-7,1,-7]],k:[17,[4,21,4,0,-1,-1,14,14,4,4,-1,-1,8,8,15,0]],l:[8,[4,21,4,0]],m:[30,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0,-1,-1,15,10,18,13,20,14,23,14,25,13,26,10,26,0]],n:[19,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],o:[19,[8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3,16,6,16,8,15,11,13,13,11,14,8,14]],p:[19,[4,14,4,-7,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],q:[19,[15,14,15,-7,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],r:[13,[4,14,4,0,-1,-1,4,8,5,11,7,13,9,14,12,14]],s:[17,[14,11,13,13,10,14,7,14,4,13,3,11,4,9,6,8,11,7,13,6,14,4,14,3,13,1,10,0,7,0,4,1,3,3]],t:[12,[5,21,5,4,6,1,8,0,10,0,-1,-1,2,14,9,14]],u:[19,[4,14,4,4,5,1,7,0,10,0,12,1,15,4,-1,-1,15,14,15,0]],v:[16,[2,14,8,0,-1,-1,14,14,8,0]],w:[22,[3,14,7,0,-1,-1,11,14,7,0,-1,-1,11,14,15,0,-1,-1,19,14,15,0]],x:[17,[3,14,14,0,-1,-1,14,14,3,0]],y:[16,[2,14,8,0,-1,-1,14,14,8,0,6,-4,4,-6,2,-7,1,-7]],z:[17,[14,14,3,0,-1,-1,3,14,14,14,-1,-1,3,0,14,0]],"{":[14,[9,25,7,24,6,23,5,21,5,19,6,17,7,16,8,14,8,12,6,10,-1,-1,7,24,6,22,6,20,7,18,8,17,9,15,9,13,8,11,4,9,8,7,9,5,9,3,8,1,7,0,6,-2,6,-4,7,-6,-1,-1,6,8,8,6,8,4,7,2,6,1,5,-1,5,-3,6,-5,7,-6,9,-7]],"|":[8,[4,25,4,-7]],"}":[14,[5,25,7,24,8,23,9,21,9,19,8,17,7,16,6,14,6,12,8,10,-1,-1,7,24,8,22,8,20,7,18,6,17,5,15,5,13,6,11,10,9,6,7,5,5,5,3,6,1,7,0,8,-2,8,-4,7,-6,-1,-1,8,8,6,6,6,4,7,2,8,1,9,-1,9,-3,8,-5,7,-6,5,-7]],"~":[24,[3,6,3,8,4,11,6,12,8,12,10,11,14,8,16,7,18,7,20,8,21,10,-1,-1,3,8,4,10,6,11,8,11,10,10,14,7,16,6,18,6,20,7,21,10,21,12]]},Lr={symbol:function(t,e,r,n){if("translucent"===t.renderPass){var i=t.context;i.setStencilMode(Ht.disabled),i.setColorMode(t.colorModeForRenderPass()),0!==r.paint.get("icon-opacity").constantOr(1)&&cr(t,e,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright")),0!==r.paint.get("text-opacity").constantOr(1)&&cr(t,e,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright")),e.map.showCollisionBoxes&&function(t,e,r,n){or(t,e,r,n,!1),or(t,e,r,n,!0)}(t,e,r,n)}},circle:function(t,e,r,n){if("translucent"===t.renderPass){var i=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),o=r.paint.get("circle-stroke-opacity");if(0!==i.constantOr(1)||0!==a.constantOr(1)&&0!==o.constantOr(1)){var s=t.context,l=s.gl;s.setDepthMode(t.depthModeForSublayer(0,qt.ReadOnly)),s.setStencilMode(Ht.disabled),s.setColorMode(t.colorModeForRenderPass());for(var c=!0,u=0;u0?1-1/(1.001-i):-i),s.uniform1f(c.uniforms.u_contrast_factor,(a=r.paint.get("raster-contrast"))>0?1/(1-a):1+a),s.uniform3fv(c.uniforms.u_spin_weights,function(t){t*=Math.PI/180;var e=Math.sin(t),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*e-r+1)/3,(Math.sqrt(3)*e-r+1)/3]}(r.paint.get("raster-hue-rotate"))),s.uniform1f(c.uniforms.u_buffer_scale,1),s.uniform1i(c.uniforms.u_image0,0),s.uniform1i(c.uniforms.u_image1,1);for(var u=n.length&&n[0].overscaledZ,f=0,h=n;fe.row){var r=t;t=e,e=r}return{x0:t.column,y0:t.row,x1:e.column,y1:e.row,dx:e.column-t.column,dy:e.row-t.row}}function Ir(t,e,r,n,i){var a=Math.max(r,Math.floor(e.y0)),o=Math.min(n,Math.ceil(e.y1));if(t.x0===e.x0&&t.y0===e.y0?t.x0+e.dy/t.dy*t.dx0,f=e.dx<0,h=a;hl.dy&&(o=s,s=l,l=o),s.dy>c.dy&&(o=s,s=c,c=o),l.dy>c.dy&&(o=l,l=c,c=o),s.dy&&Ir(c,s,n,i,a),l.dy&&Ir(c,l,n,i,a)}zr.prototype.resize=function(t,e){var r=this.context.gl;if(this.width=t*a.devicePixelRatio,this.height=e*a.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(var n=0,i=this.style._order;n=0;this.currentLayer--){var m=n.style._layers[s[n.currentLayer]];m.source!==(g&&g.id)&&(v=[],(g=n.style.sourceCaches[m.source])&&(n.clearStencil(),v=g.getVisibleCoordinates(),g.getSource().isTileClipped&&n._renderTileClippingMasks(v))),n.renderLayer(n,g,m,v)}this.renderPass="translucent";var y,x=[];for(this.currentLayer=0,this.currentLayer;this.currentLayer0?e.pop():null},zr.prototype._createProgramCached=function(t,e){this.cache=this.cache||{};var r=""+t+(e.cacheKey||"")+(this._showOverdrawInspector?"/overdraw":"");return this.cache[r]||(this.cache[r]=new ir(this.context,nr[t],e,this._showOverdrawInspector)),this.cache[r]},zr.prototype.useProgram=function(t,e){var r=this._createProgramCached(t,e||this.emptyProgramConfiguration);return this.context.program.set(r.program),r};var Dr=t.default$20.vec4,Rr=t.default$20.mat4,Fr=t.default$20.mat2,Br=function(t,e,r){this.tileSize=512,this._renderWorldCopies=void 0===r||r,this._minZoom=t||0,this._maxZoom=e||22,this.latRange=[-85.05113,85.05113],this.width=0,this.height=0,this._center=new G(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._posMatrixCache={},this._alignedPosMatrixCache={}},Nr={minZoom:{configurable:!0},maxZoom:{configurable:!0},renderWorldCopies:{configurable:!0},worldSize:{configurable:!0},centerPoint:{configurable:!0},size:{configurable:!0},bearing:{configurable:!0},pitch:{configurable:!0},fov:{configurable:!0},zoom:{configurable:!0},center:{configurable:!0},unmodified:{configurable:!0},x:{configurable:!0},y:{configurable:!0},point:{configurable:!0}};Br.prototype.clone=function(){var t=new Br(this._minZoom,this._maxZoom,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._calcMatrices(),t},Nr.minZoom.get=function(){return this._minZoom},Nr.minZoom.set=function(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},Nr.maxZoom.get=function(){return this._maxZoom},Nr.maxZoom.set=function(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},Nr.renderWorldCopies.get=function(){return this._renderWorldCopies},Nr.renderWorldCopies.set=function(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t},Nr.worldSize.get=function(){return this.tileSize*this.scale},Nr.centerPoint.get=function(){return this.size._div(2)},Nr.size.get=function(){return new t.default$1(this.width,this.height)},Nr.bearing.get=function(){return-this.angle/Math.PI*180},Nr.bearing.set=function(e){var r=-t.wrap(e,-180,180)*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=Fr.create(),Fr.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},Nr.pitch.get=function(){return this._pitch/Math.PI*180},Nr.pitch.set=function(e){var r=t.clamp(e,0,60)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())},Nr.fov.get=function(){return this._fov/Math.PI*180},Nr.fov.set=function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())},Nr.zoom.get=function(){return this._zoom},Nr.zoom.set=function(t){var e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._constrain(),this._calcMatrices())},Nr.center.get=function(){return this._center},Nr.center.set=function(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())},Br.prototype.coveringZoomLevel=function(t){return(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize))},Br.prototype.getVisibleUnwrappedCoordinates=function(e){var r=this.pointCoordinate(new t.default$1(0,0),0),n=this.pointCoordinate(new t.default$1(this.width,0),0),i=Math.floor(r.column),a=Math.floor(n.column),o=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies)for(var s=i;s<=a;s++)0!==s&&o.push(new t.UnwrappedTileID(s,e));return o},Br.prototype.coveringTiles=function(e){var r=this.coveringZoomLevel(e),n=r;if(void 0!==e.minzoom&&re.maxzoom&&(r=e.maxzoom);var i=this.pointCoordinate(this.centerPoint,r),a=new t.default$1(i.column-.5,i.row-.5);return function(e,r,n,i){void 0===i&&(i=!0);var a=1<=0&&l<=a)for(c=r;co&&(i=o-g)}if(this.lngRange){var v=this.x,m=c.x/2;v-ml&&(n=l-m)}void 0===n&&void 0===i||(this.center=this.unproject(new t.default$1(void 0!==n?n:this.x,void 0!==i?i:this.y))),this._unmodified=u,this._constraining=!1}},Br.prototype._calcMatrices=function(){if(this.height){this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height;var t=this._fov/2,e=Math.PI/2+this._pitch,r=Math.sin(t)*this.cameraToCenterDistance/Math.sin(Math.PI-e-t),n=this.x,i=this.y,a=1.01*(Math.cos(Math.PI/2-this._pitch)*r+this.cameraToCenterDistance),o=new Float64Array(16);Rr.perspective(o,this._fov,this.width/this.height,1,a),Rr.scale(o,o,[1,-1,1]),Rr.translate(o,o,[0,0,-this.cameraToCenterDistance]),Rr.rotateX(o,o,this._pitch),Rr.rotateZ(o,o,this.angle),Rr.translate(o,o,[-n,-i,0]);var s=this.worldSize/(2*Math.PI*6378137*Math.abs(Math.cos(this.center.lat*(Math.PI/180))));Rr.scale(o,o,[1,1,s,1]),this.projMatrix=o;var l=this.width%2/2,c=this.height%2/2,u=Math.cos(this.angle),f=Math.sin(this.angle),h=n-Math.round(n)+u*l+f*c,p=i-Math.round(i)+u*c+f*l,d=new Float64Array(o);if(Rr.translate(d,d,[h>.5?h-1:h,p>.5?p-1:p,0]),this.alignedProjMatrix=d,o=Rr.create(),Rr.scale(o,o,[this.width/2,-this.height/2,1]),Rr.translate(o,o,[1,-1,0]),this.pixelMatrix=Rr.multiply(new Float64Array(16),o,this.projMatrix),!(o=Rr.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={}}},Br.prototype.maxPitchScaleFactor=function(){if(!this.pixelMatrixInverse)return 1;var e=this.pointCoordinate(new t.default$1(0,0)).zoomTo(this.zoom),r=[e.column*this.tileSize,e.row*this.tileSize,0,1];return Dr.transformMat4(r,r,this.pixelMatrix)[3]/this.cameraToCenterDistance},Object.defineProperties(Br.prototype,Nr);var jr=function(){var e,r,n,i;t.bindAll(["_onHashChange","_updateHash"],this),this._updateHash=(e=this._updateHashUnthrottled.bind(this),300,r=!1,n=0,i=function(){n=0,r&&(e(),n=setTimeout(i,300),r=!1)},function(){return r=!0,n||i(),n})};jr.prototype.addTo=function(e){return this._map=e,t.default.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this},jr.prototype.remove=function(){return t.default.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this},jr.prototype.getHashString=function(t){var e=this._map.getCenter(),r=Math.round(100*this._map.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.pow(10,n),a=Math.round(e.lng*i)/i,o=Math.round(e.lat*i)/i,s=this._map.getBearing(),l=this._map.getPitch(),c="";return c+=t?"#/"+a+"/"+o+"/"+r:"#"+r+"/"+o+"/"+a,(s||l)&&(c+="/"+Math.round(10*s)/10),l&&(c+="/"+Math.round(l)),c},jr.prototype._onHashChange=function(){var e=t.default.location.hash.replace("#","").split("/");return e.length>=3&&(this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:+(e[3]||0),pitch:+(e[4]||0)}),!0)},jr.prototype._updateHashUnthrottled=function(){var e=this.getHashString();t.default.history.replaceState(t.default.history.state,"",e)};var Vr=function(e){function r(r,n,i,a){void 0===a&&(a={});var o=s.mousePos(n.getCanvasContainer(),i),l=n.unproject(o);e.call(this,r,t.extend({point:o,lngLat:l,originalEvent:i},a)),this._defaultPrevented=!1,this.target=n}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var n={defaultPrevented:{configurable:!0}};return r.prototype.preventDefault=function(){this._defaultPrevented=!0},n.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(r.prototype,n),r}(t.Event),Ur=function(e){function r(r,n,i){var a=s.touchPos(n.getCanvasContainer(),i),o=a.map(function(t){return n.unproject(t)}),l=a.reduce(function(t,e,r,n){return t.add(e.div(n.length))},new t.default$1(0,0)),c=n.unproject(l);e.call(this,r,{points:a,point:l,lngLats:o,lngLat:c,originalEvent:i}),this._defaultPrevented=!1}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var n={defaultPrevented:{configurable:!0}};return r.prototype.preventDefault=function(){this._defaultPrevented=!0},n.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(r.prototype,n),r}(t.Event),qr=function(t){function e(e,r,n){t.call(this,e,{originalEvent:n}),this._defaultPrevented=!1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultPrevented:{configurable:!0}};return e.prototype.preventDefault=function(){this._defaultPrevented=!0},r.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(e.prototype,r),e}(t.Event),Hr=function(e){this._map=e,this._el=e.getCanvasContainer(),this._delta=0,t.bindAll(["_onWheel","_onTimeout","_onScrollFrame","_onScrollFinished"],this)};Hr.prototype.isEnabled=function(){return!!this._enabled},Hr.prototype.isActive=function(){return!!this._active},Hr.prototype.enable=function(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)},Hr.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Hr.prototype.onWheel=function(e){if(this.isEnabled()){var r=e.deltaMode===t.default.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,n=a.now(),i=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==r&&r%4.000244140625==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=r,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*r)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),e.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=e,this._delta-=r,this.isActive()||this._start(e)),e.preventDefault()}},Hr.prototype._onTimeout=function(t){this._type="wheel",this._delta-=this._lastValue,this.isActive()||this._start(t)},Hr.prototype._start=function(e){if(this._delta){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),this._active=!0,this._map.fire(new t.Event("movestart",{originalEvent:e})),this._map.fire(new t.Event("zoomstart",{originalEvent:e})),this._finishTimeout&&clearTimeout(this._finishTimeout);var r=s.mousePos(this._el,e);this._around=G.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(r)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame))}},Hr.prototype._onScrollFrame=function(){var e=this;if(this._frameId=null,this.isActive()){var r=this._map.transform;if(0!==this._delta){var n="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?1/450:.01,i=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&0!==i&&(i=1/i);var o="number"==typeof this._targetZoom?r.zoomScale(this._targetZoom):r.scale;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(o*i))),"wheel"===this._type&&(this._startZoom=r.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}var s=!1;if("wheel"===this._type){var l=Math.min((a.now()-this._lastWheelEventTime)/200,1),c=this._easing(l);r.zoom=t.number(this._startZoom,this._targetZoom,c),l<1?this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame)):s=!0}else r.zoom=this._targetZoom,s=!0;r.setLocationAtPoint(this._around,this._aroundPoint),this._map.fire(new t.Event("move",{originalEvent:this._lastWheelEvent})),this._map.fire(new t.Event("zoom",{originalEvent:this._lastWheelEvent})),s&&(this._active=!1,this._finishTimeout=setTimeout(function(){e._map.fire(new t.Event("zoomend",{originalEvent:e._lastWheelEvent})),e._map.fire(new t.Event("moveend",{originalEvent:e._lastWheelEvent})),delete e._targetZoom},200))}},Hr.prototype._smoothOutEasing=function(e){var r=t.ease;if(this._prevEase){var n=this._prevEase,i=(a.now()-n.start)/n.duration,o=n.easing(i+.01)-n.easing(i),s=.27/Math.sqrt(o*o+1e-4)*.01,l=Math.sqrt(.0729-s*s);r=t.bezier(s,l,.25,1)}return this._prevEase={start:a.now(),duration:e,easing:r},r};var Gr=function(e){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),t.bindAll(["_onMouseMove","_onMouseUp","_onKeyDown"],this)};Gr.prototype.isEnabled=function(){return!!this._enabled},Gr.prototype.isActive=function(){return!!this._active},Gr.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Gr.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Gr.prototype.onMouseDown=function(e){this.isEnabled()&&e.shiftKey&&0===e.button&&(t.default.document.addEventListener("mousemove",this._onMouseMove,!1),t.default.document.addEventListener("keydown",this._onKeyDown,!1),t.default.document.addEventListener("mouseup",this._onMouseUp,!1),s.disableDrag(),this._startPos=s.mousePos(this._el,e),this._active=!0)},Gr.prototype._onMouseMove=function(t){var e=this._startPos,r=s.mousePos(this._el,t);this._box||(this._box=s.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));var n=Math.min(e.x,r.x),i=Math.max(e.x,r.x),a=Math.min(e.y,r.y),o=Math.max(e.y,r.y);s.setTransform(this._box,"translate("+n+"px,"+a+"px)"),this._box.style.width=i-n+"px",this._box.style.height=o-a+"px"},Gr.prototype._onMouseUp=function(e){if(0===e.button){var r=this._startPos,n=s.mousePos(this._el,e),i=(new W).extend(this._map.unproject(r)).extend(this._map.unproject(n));this._finish(),s.suppressClick(),r.x===n.x&&r.y===n.y?this._fireEvent("boxzoomcancel",e):this._map.fitBounds(i,{linear:!0}).fire(new t.Event("boxzoomend",{originalEvent:e,boxZoomBounds:i}))}},Gr.prototype._onKeyDown=function(t){27===t.keyCode&&(this._finish(),this._fireEvent("boxzoomcancel",t))},Gr.prototype._finish=function(){this._active=!1,t.default.document.removeEventListener("mousemove",this._onMouseMove,!1),t.default.document.removeEventListener("keydown",this._onKeyDown,!1),t.default.document.removeEventListener("mouseup",this._onMouseUp,!1),this._container.classList.remove("mapboxgl-crosshair"),this._box&&(s.remove(this._box),this._box=null),s.enableDrag()},Gr.prototype._fireEvent=function(e,r){return this._map.fire(new t.Event(e,{originalEvent:r}))};var Wr=t.bezier(0,0,.25,1),Yr=function(e,r){this._map=e,this._el=r.element||e.getCanvasContainer(),this._state="disabled",this._button=r.button||"right",this._bearingSnap=r.bearingSnap||0,this._pitchWithRotate=!1!==r.pitchWithRotate,t.bindAll(["_onMouseMove","_onMouseUp","_onBlur","_onDragFrame"],this)};Yr.prototype.isEnabled=function(){return"disabled"!==this._state},Yr.prototype.isActive=function(){return"active"===this._state},Yr.prototype.enable=function(){this.isEnabled()||(this._state="enabled")},Yr.prototype.disable=function(){if(this.isEnabled())switch(this._state){case"active":this._state="disabled",this._unbind(),this._deactivate(),this._fireEvent("rotateend"),this._pitchWithRotate&&this._fireEvent("pitchend"),this._fireEvent("moveend");break;case"pending":this._state="disabled",this._unbind();break;default:this._state="disabled"}},Yr.prototype.onMouseDown=function(e){if("enabled"===this._state){if("right"===this._button){if(this._eventButton=s.mouseButton(e),this._eventButton!==(e.ctrlKey?0:2))return}else{if(e.ctrlKey||0!==s.mouseButton(e))return;this._eventButton=0}s.disableDrag(),t.default.document.addEventListener("mousemove",this._onMouseMove,{capture:!0}),t.default.document.addEventListener("mouseup",this._onMouseUp),t.default.addEventListener("blur",this._onBlur),this._state="pending",this._inertia=[[a.now(),this._map.getBearing()]],this._previousPos=s.mousePos(this._el,e),this._center=this._map.transform.centerPoint,e.preventDefault()}},Yr.prototype._onMouseMove=function(t){this._lastMoveEvent=t,this._pos=s.mousePos(this._el,t),"pending"===this._state&&(this._state="active",this._fireEvent("rotatestart",t),this._fireEvent("movestart",t),this._pitchWithRotate&&this._fireEvent("pitchstart",t)),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onDragFrame))},Yr.prototype._onDragFrame=function(){this._frameId=null;var t=this._lastMoveEvent;if(t){var e=this._map.transform,r=this._previousPos,n=this._pos,i=.8*(r.x-n.x),o=-.5*(r.y-n.y),s=e.bearing-i,l=e.pitch-o,c=this._inertia,u=c[c.length-1];this._drainInertiaBuffer(),c.push([a.now(),this._map._normalizeBearing(s,u[1])]),e.bearing=s,this._pitchWithRotate&&(this._fireEvent("pitch",t),e.pitch=l),this._fireEvent("rotate",t),this._fireEvent("move",t),delete this._lastMoveEvent,this._previousPos=this._pos}},Yr.prototype._onMouseUp=function(t){if(s.mouseButton(t)===this._eventButton)switch(this._state){case"active":this._state="enabled",s.suppressClick(),this._unbind(),this._deactivate(),this._inertialRotate(t);break;case"pending":this._state="enabled",this._unbind()}},Yr.prototype._onBlur=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._fireEvent("rotateend",t),this._pitchWithRotate&&this._fireEvent("pitchend",t),this._fireEvent("moveend",t);break;case"pending":this._state="enabled",this._unbind()}},Yr.prototype._unbind=function(){t.default.document.removeEventListener("mousemove",this._onMouseMove,{capture:!0}),t.default.document.removeEventListener("mouseup",this._onMouseUp),t.default.removeEventListener("blur",this._onBlur),s.enableDrag()},Yr.prototype._deactivate=function(){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._lastMoveEvent,delete this._previousPos},Yr.prototype._inertialRotate=function(t){var e=this;this._fireEvent("rotateend",t),this._drainInertiaBuffer();var r=this._map,n=r.getBearing(),i=this._inertia,a=function(){Math.abs(n)180&&(p=180);var d=p/180;c+=f*p*(d/2),Math.abs(r._normalizeBearing(c,0))0&&e-t[0][0]>160;)t.shift()};var Xr=t.bezier(0,0,.3,1),Zr=function(e){this._map=e,this._el=e.getCanvasContainer(),this._state="disabled",t.bindAll(["_onMove","_onMouseUp","_onTouchEnd","_onBlur","_onDragFrame"],this)};Zr.prototype.isEnabled=function(){return"disabled"!==this._state},Zr.prototype.isActive=function(){return"active"===this._state},Zr.prototype.enable=function(){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-drag-pan"),this._state="enabled")},Zr.prototype.disable=function(){if(this.isEnabled())switch(this._el.classList.remove("mapboxgl-touch-drag-pan"),this._state){case"active":this._state="disabled",this._unbind(),this._deactivate(),this._fireEvent("dragend"),this._fireEvent("moveend");break;case"pending":this._state="disabled",this._unbind();break;default:this._state="disabled"}},Zr.prototype.onMouseDown=function(e){"enabled"===this._state&&(e.ctrlKey||0!==s.mouseButton(e)||(s.addEventListener(t.default.document,"mousemove",this._onMove,{capture:!0}),s.addEventListener(t.default.document,"mouseup",this._onMouseUp),this._start(e)))},Zr.prototype.onTouchStart=function(e){"enabled"===this._state&&(e.touches.length>1||(s.addEventListener(t.default.document,"touchmove",this._onMove,{capture:!0,passive:!1}),s.addEventListener(t.default.document,"touchend",this._onTouchEnd),this._start(e)))},Zr.prototype._start=function(e){t.default.addEventListener("blur",this._onBlur),this._state="pending",this._previousPos=s.mousePos(this._el,e),this._inertia=[[a.now(),this._previousPos]]},Zr.prototype._onMove=function(t){this._lastMoveEvent=t,t.preventDefault(),this._pos=s.mousePos(this._el,t),this._drainInertiaBuffer(),this._inertia.push([a.now(),this._pos]),"pending"===this._state&&(this._state="active",this._fireEvent("dragstart",t),this._fireEvent("movestart",t)),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onDragFrame))},Zr.prototype._onDragFrame=function(){this._frameId=null;var t=this._lastMoveEvent;if(t){var e=this._map.transform;e.setLocationAtPoint(e.pointLocation(this._previousPos),this._pos),this._fireEvent("drag",t),this._fireEvent("move",t),this._previousPos=this._pos,delete this._lastMoveEvent}},Zr.prototype._onMouseUp=function(t){if(0===s.mouseButton(t))switch(this._state){case"active":this._state="enabled",s.suppressClick(),this._unbind(),this._deactivate(),this._inertialPan(t);break;case"pending":this._state="enabled",this._unbind()}},Zr.prototype._onTouchEnd=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._inertialPan(t);break;case"pending":this._state="enabled",this._unbind()}},Zr.prototype._onBlur=function(t){switch(this._state){case"active":this._state="enabled",this._unbind(),this._deactivate(),this._fireEvent("dragend",t),this._fireEvent("moveend",t);break;case"pending":this._state="enabled",this._unbind()}},Zr.prototype._unbind=function(){s.removeEventListener(t.default.document,"touchmove",this._onMove,{capture:!0,passive:!1}),s.removeEventListener(t.default.document,"touchend",this._onTouchEnd),s.removeEventListener(t.default.document,"mousemove",this._onMove,{capture:!0}),s.removeEventListener(t.default.document,"mouseup",this._onMouseUp),s.removeEventListener(t.default,"blur",this._onBlur)},Zr.prototype._deactivate=function(){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._lastMoveEvent,delete this._previousPos,delete this._pos},Zr.prototype._inertialPan=function(t){this._fireEvent("dragend",t),this._drainInertiaBuffer();var e=this._inertia;if(e.length<2)this._fireEvent("moveend",t);else{var r=e[e.length-1],n=e[0],i=r[1].sub(n[1]),a=(r[0]-n[0])/1e3;if(0===a||r[1].equals(n[1]))this._fireEvent("moveend",t);else{var o=i.mult(.3/a),s=o.mag();s>1400&&(s=1400,o._unit()._mult(s));var l=s/750,c=o.mult(-l/2);this._map.panBy(c,{duration:1e3*l,easing:Xr,noMoveStart:!0},{originalEvent:t})}}},Zr.prototype._fireEvent=function(e,r){return this._map.fire(new t.Event(e,r?{originalEvent:r}:{}))},Zr.prototype._drainInertiaBuffer=function(){for(var t=this._inertia,e=a.now();t.length>0&&e-t[0][0]>160;)t.shift()};var $r=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onKeyDown"],this)};function Jr(t){return t*(2-t)}$r.prototype.isEnabled=function(){return!!this._enabled},$r.prototype.enable=function(){this.isEnabled()||(this._el.addEventListener("keydown",this._onKeyDown,!1),this._enabled=!0)},$r.prototype.disable=function(){this.isEnabled()&&(this._el.removeEventListener("keydown",this._onKeyDown),this._enabled=!1)},$r.prototype._onKeyDown=function(t){if(!(t.altKey||t.ctrlKey||t.metaKey)){var e=0,r=0,n=0,i=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),i=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),i=1);break;case 38:t.shiftKey?n=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?n=-1:(a=1,t.preventDefault());break;default:return}var o=this._map,s=o.getZoom(),l={duration:300,delayEndEvents:500,easing:Jr,zoom:e?Math.round(s)+e*(t.shiftKey?2:1):s,bearing:o.getBearing()+15*r,pitch:o.getPitch()+10*n,offset:[100*-i,100*-a],center:o.getCenter()};o.easeTo(l,{originalEvent:t})}};var Kr=function(e){this._map=e,t.bindAll(["_onDblClick","_onZoomEnd"],this)};Kr.prototype.isEnabled=function(){return!!this._enabled},Kr.prototype.isActive=function(){return!!this._active},Kr.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Kr.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Kr.prototype.onTouchStart=function(t){var e=this;this.isEnabled()&&(t.points.length>1||(this._tapped?(clearTimeout(this._tapped),this._tapped=null,this._zoom(t)):this._tapped=setTimeout(function(){e._tapped=null},300)))},Kr.prototype.onDblClick=function(t){this.isEnabled()&&(t.originalEvent.preventDefault(),this._zoom(t))},Kr.prototype._zoom=function(t){this._active=!0,this._map.on("zoomend",this._onZoomEnd),this._map.zoomTo(this._map.getZoom()+(t.originalEvent.shiftKey?-1:1),{around:t.lngLat},t)},Kr.prototype._onZoomEnd=function(){this._active=!1,this._map.off("zoomend",this._onZoomEnd)};var Qr=t.bezier(0,0,.15,1),tn=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onMove","_onEnd","_onTouchFrame"],this)};tn.prototype.isEnabled=function(){return!!this._enabled},tn.prototype.enable=function(t){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-zoom-rotate"),this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)},tn.prototype.disable=function(){this.isEnabled()&&(this._el.classList.remove("mapboxgl-touch-zoom-rotate"),this._enabled=!1)},tn.prototype.disableRotation=function(){this._rotationDisabled=!0},tn.prototype.enableRotation=function(){this._rotationDisabled=!1},tn.prototype.onStart=function(e){if(this.isEnabled()&&2===e.touches.length){var r=s.mousePos(this._el,e.touches[0]),n=s.mousePos(this._el,e.touches[1]);this._startVec=r.sub(n),this._gestureIntent=void 0,this._inertia=[],s.addEventListener(t.default.document,"touchmove",this._onMove,{passive:!1}),s.addEventListener(t.default.document,"touchend",this._onEnd)}},tn.prototype._getTouchEventData=function(t){var e=s.mousePos(this._el,t.touches[0]),r=s.mousePos(this._el,t.touches[1]),n=e.sub(r);return{vec:n,center:e.add(r).div(2),scale:n.mag()/this._startVec.mag(),bearing:this._rotationDisabled?0:180*n.angleWith(this._startVec)/Math.PI}},tn.prototype._onMove=function(e){if(2===e.touches.length){var r=this._getTouchEventData(e),n=r.vec,i=r.scale,a=r.bearing;if(!this._gestureIntent){var o=Math.abs(1-i)>.15;Math.abs(a)>10?this._gestureIntent="rotate":o&&(this._gestureIntent="zoom"),this._gestureIntent&&(this._map.fire(new t.Event(this._gestureIntent+"start",{originalEvent:e})),this._map.fire(new t.Event("movestart",{originalEvent:e})),this._startVec=n)}this._lastTouchEvent=e,this._frameId||(this._frameId=this._map._requestRenderFrame(this._onTouchFrame)),e.preventDefault()}},tn.prototype._onTouchFrame=function(){this._frameId=null;var e=this._gestureIntent;if(e){var r=this._map.transform;this._startScale||(this._startScale=r.scale,this._startBearing=r.bearing);var n=this._getTouchEventData(this._lastTouchEvent),i=n.center,o=n.bearing,s=n.scale,l=r.pointLocation(i),c=r.locationPoint(l);"rotate"===e&&(r.bearing=this._startBearing+o),r.zoom=r.scaleZoom(this._startScale*s),r.setLocationAtPoint(l,c),this._map.fire(new t.Event(e,{originalEvent:this._lastTouchEvent})),this._map.fire(new t.Event("move",{originalEvent:this._lastTouchEvent})),this._drainInertiaBuffer(),this._inertia.push([a.now(),s,i])}},tn.prototype._onEnd=function(e){s.removeEventListener(t.default.document,"touchmove",this._onMove,{passive:!1}),s.removeEventListener(t.default.document,"touchend",this._onEnd);var r=this._gestureIntent,n=this._startScale;if(this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._gestureIntent,delete this._startScale,delete this._startBearing,delete this._lastTouchEvent,r){this._map.fire(new t.Event(r+"end",{originalEvent:e})),this._drainInertiaBuffer();var i=this._inertia,a=this._map;if(i.length<2)a.snapToNorth({},{originalEvent:e});else{var o=i[i.length-1],l=i[0],c=a.transform.scaleZoom(n*o[1]),u=a.transform.scaleZoom(n*l[1]),f=c-u,h=(o[0]-l[0])/1e3,p=o[2];if(0!==h&&c!==u){var d=.15*f/h;Math.abs(d)>2.5&&(d=d>0?2.5:-2.5);var g=1e3*Math.abs(d/(12*.15)),v=c+d*g/2e3;v<0&&(v=0),a.easeTo({zoom:v,duration:g,easing:Qr,around:this._aroundCenter?a.getCenter():a.unproject(p),noMoveStart:!0},{originalEvent:e})}else a.snapToNorth({},{originalEvent:e})}}},tn.prototype._drainInertiaBuffer=function(){for(var t=this._inertia,e=a.now();t.length>2&&e-t[0][0]>160;)t.shift()};var en={scrollZoom:Hr,boxZoom:Gr,dragRotate:Yr,dragPan:Zr,keyboard:$r,doubleClickZoom:Kr,touchZoomRotate:tn},rn=function(e){function r(r,n){e.call(this),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=n.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.getCenter=function(){return this.transform.center},r.prototype.setCenter=function(t,e){return this.jumpTo({center:t},e)},r.prototype.panBy=function(e,r,n){return e=t.default$1.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},r),n)},r.prototype.panTo=function(e,r,n){return this.easeTo(t.extend({center:e},r),n)},r.prototype.getZoom=function(){return this.transform.zoom},r.prototype.setZoom=function(t,e){return this.jumpTo({zoom:t},e),this},r.prototype.zoomTo=function(e,r,n){return this.easeTo(t.extend({zoom:e},r),n)},r.prototype.zoomIn=function(t,e){return this.zoomTo(this.getZoom()+1,t,e),this},r.prototype.zoomOut=function(t,e){return this.zoomTo(this.getZoom()-1,t,e),this},r.prototype.getBearing=function(){return this.transform.bearing},r.prototype.setBearing=function(t,e){return this.jumpTo({bearing:t},e),this},r.prototype.rotateTo=function(e,r,n){return this.easeTo(t.extend({bearing:e},r),n)},r.prototype.resetNorth=function(e,r){return this.rotateTo(0,t.extend({duration:1e3},e),r),this},r.prototype.snapToNorth=function(t,e){return Math.abs(this.getBearing())e?1:0}),["bottom","left","right","top"]))return t.warnOnce("options.padding must be a positive number, or an Object with keys 'bottom', 'left', 'right', 'top'"),this;e=W.convert(e);var a=[(r.padding.left-r.padding.right)/2,(r.padding.top-r.padding.bottom)/2],o=Math.min(r.padding.right,r.padding.left),s=Math.min(r.padding.top,r.padding.bottom);r.offset=[r.offset[0]+a[0],r.offset[1]+a[1]];var l=t.default$1.convert(r.offset),c=this.transform,u=c.project(e.getNorthWest()),f=c.project(e.getSouthEast()),h=f.sub(u),p=(c.width-2*o-2*Math.abs(l.x))/h.x,d=(c.height-2*s-2*Math.abs(l.y))/h.y;return d<0||p<0?(t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset."),this):(r.center=c.unproject(u.add(f).div(2)),r.zoom=Math.min(c.scaleZoom(c.scale*Math.min(p,d)),r.maxZoom),r.bearing=0,r.linear?this.easeTo(r,n):this.flyTo(r,n))},r.prototype.jumpTo=function(e,r){this.stop();var n=this.transform,i=!1,a=!1,o=!1;return"zoom"in e&&n.zoom!==+e.zoom&&(i=!0,n.zoom=+e.zoom),void 0!==e.center&&(n.center=G.convert(e.center)),"bearing"in e&&n.bearing!==+e.bearing&&(a=!0,n.bearing=+e.bearing),"pitch"in e&&n.pitch!==+e.pitch&&(o=!0,n.pitch=+e.pitch),this.fire(new t.Event("movestart",r)).fire(new t.Event("move",r)),i&&this.fire(new t.Event("zoomstart",r)).fire(new t.Event("zoom",r)).fire(new t.Event("zoomend",r)),a&&this.fire(new t.Event("rotatestart",r)).fire(new t.Event("rotate",r)).fire(new t.Event("rotateend",r)),o&&this.fire(new t.Event("pitchstart",r)).fire(new t.Event("pitch",r)).fire(new t.Event("pitchend",r)),this.fire(new t.Event("moveend",r))},r.prototype.easeTo=function(e,r){var n=this;this.stop(),!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate&&(e.duration=0);var i=this.transform,a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l="zoom"in e?+e.zoom:a,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,f=i.centerPoint.add(t.default$1.convert(e.offset)),h=i.pointLocation(f),p=G.convert(e.center||h);this._normalizeCenter(p);var d,g,v=i.project(h),m=i.project(p).sub(v),y=i.zoomScale(l-a);return e.around&&(d=G.convert(e.around),g=i.locationPoint(d)),this._zooming=l!==a,this._rotating=o!==c,this._pitching=u!==s,this._prepareEase(r,e.noMoveStart),clearTimeout(this._easeEndTimeoutID),this._ease(function(e){if(n._zooming&&(i.zoom=t.number(a,l,e)),n._rotating&&(i.bearing=t.number(o,c,e)),n._pitching&&(i.pitch=t.number(s,u,e)),d)i.setLocationAtPoint(d,g);else{var h=i.zoomScale(i.zoom-a),p=l>a?Math.min(2,y):Math.max(.5,y),x=Math.pow(p,1-e),b=i.unproject(v.add(m.mult(e*x)).mult(h));i.setLocationAtPoint(i.renderWorldCopies?b.wrap():b,f)}n._fireMoveEvents(r)},function(){e.delayEndEvents?n._easeEndTimeoutID=setTimeout(function(){return n._afterEase(r)},e.delayEndEvents):n._afterEase(r)},e),this},r.prototype._prepareEase=function(e,r){this._moving=!0,r||this.fire(new t.Event("movestart",e)),this._zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&this.fire(new t.Event("pitchstart",e))},r.prototype._fireMoveEvents=function(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))},r.prototype._afterEase=function(e){var r=this._zooming,n=this._rotating,i=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,r&&this.fire(new t.Event("zoomend",e)),n&&this.fire(new t.Event("rotateend",e)),i&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))},r.prototype.flyTo=function(e,r){var n=this;this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);var i=this.transform,a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l="zoom"in e?t.clamp(+e.zoom,i.minZoom,i.maxZoom):a,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,f=i.zoomScale(l-a),h=i.centerPoint.add(t.default$1.convert(e.offset)),p=i.pointLocation(h),d=G.convert(e.center||p);this._normalizeCenter(d);var g=i.project(p),v=i.project(d).sub(g),m=e.curve,y=Math.max(i.width,i.height),x=y/f,b=v.mag();if("minZoom"in e){var _=t.clamp(Math.min(e.minZoom,a,l),i.minZoom,i.maxZoom),w=y/i.zoomScale(_-a);m=Math.sqrt(w/b*2)}var k=m*m;function M(t){var e=(x*x-y*y+(t?-1:1)*k*k*b*b)/(2*(t?x:y)*k*b);return Math.log(Math.sqrt(e*e+1)-e)}function A(t){return(Math.exp(t)-Math.exp(-t))/2}function T(t){return(Math.exp(t)+Math.exp(-t))/2}var S=M(0),C=function(t){return T(S)/T(S+m*t)},E=function(t){return y*((T(S)*(A(e=S+m*t)/T(e))-A(S))/k)/b;var e},L=(M(1)-S)/m;if(Math.abs(b)<1e-6||!isFinite(L)){if(Math.abs(y-x)<1e-6)return this.easeTo(e,r);var z=xe.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=u!==s,this._prepareEase(r,!1),this._ease(function(e){var l=e*L,f=1/C(l);i.zoom=a+i.scaleZoom(f),n._rotating&&(i.bearing=t.number(o,c,e)),n._pitching&&(i.pitch=t.number(s,u,e));var p=i.unproject(g.add(v.mult(E(l))).mult(f));i.setLocationAtPoint(i.renderWorldCopies?p.wrap():p,h),n._fireMoveEvents(r)},function(){return n._afterEase(r)},e),this},r.prototype.isEasing=function(){return!!this._easeFrameId},r.prototype.stop=function(){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){var t=this._onEaseEnd;delete this._onEaseEnd,t.call(this)}return this},r.prototype._ease=function(t,e,r){!1===r.animate||0===r.duration?(t(1),e()):(this._easeStart=a.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))},r.prototype._renderFrameCallback=function(){var t=Math.min((a.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},r.prototype._normalizeBearing=function(e,r){e=t.wrap(e,-180,180);var n=Math.abs(e-r);return Math.abs(e-360-r)180?-360:r<-180?360:0}},r}(t.Evented),nn=function(e){void 0===e&&(e={}),this.options=e,t.bindAll(["_updateEditLink","_updateData","_updateCompact"],this)};nn.prototype.getDefaultPosition=function(){return"bottom-right"},nn.prototype.onAdd=function(t){var e=this.options&&this.options.compact;return this._map=t,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),e&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container},nn.prototype.onRemove=function(){s.remove(this._container),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0},nn.prototype._updateEditLink=function(){var t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));var e=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:v.ACCESS_TOKEN}];if(t){var r=e.reduce(function(t,r,n){return r.value&&(t+=r.key+"="+r.value+(n=0)return!1;return!0})).length?(this._container.innerHTML=t.join(" | "),this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null}},nn.prototype._updateCompact=function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact")};var an=function(){t.bindAll(["_updateLogo"],this)};an.prototype.onAdd=function(t){this._map=t,this._container=s.create("div","mapboxgl-ctrl");var e=s.create("a","mapboxgl-ctrl-logo");return e.target="_blank",e.href="https://www.mapbox.com/",e.setAttribute("aria-label","Mapbox logo"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._container},an.prototype.onRemove=function(){s.remove(this._container),this._map.off("sourcedata",this._updateLogo)},an.prototype.getDefaultPosition=function(){return"bottom-left"},an.prototype._updateLogo=function(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")},an.prototype._logoRequired=function(){if(this._map.style){var t=this._map.style.sourceCaches;for(var e in t)if(t[e].getSource().mapbox_logo)return!0;return!1}};var on=function(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1};on.prototype.add=function(t){var e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e},on.prototype.remove=function(t){for(var e=this._currentlyRunning,r=0,n=e?this._queue.concat(e):this._queue;re.maxZoom)throw new Error("maxZoom must be greater than minZoom");var n=new Br(e.minZoom,e.maxZoom,e.renderWorldCopies);r.call(this,n,e),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new on;var i=e.transformRequest;if(this._transformRequest=i?function(t,e){return i(t,e)||{url:t}}:function(t){return{url:t}},"string"==typeof e.container){var a=t.default.document.getElementById(e.container);if(!a)throw new Error("Container '"+e.container+"' not found.");this._container=a}else{if(!(e.container instanceof ln))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_contextLost","_contextRestored","_update","_render","_onData","_onDataLoading"],this),this._setupContainer(),this._setupPainter(),this.on("move",this._update.bind(this,!1)),this.on("zoom",this._update.bind(this,!0)),void 0!==t.default&&(t.default.addEventListener("online",this._onWindowOnline,!1),t.default.addEventListener("resize",this._onWindowResize,!1)),function(t,e){var r=t.getCanvasContainer(),n=null,i=!1;for(var a in en)t[a]=new en[a](t,e),e.interactive&&e[a]&&t[a].enable(e[a]);s.addEventListener(r,"mouseout",function(e){t.fire(new Vr("mouseout",t,e))}),s.addEventListener(r,"mousedown",function(r){i=!0;var n=new Vr("mousedown",t,r);t.fire(n),n.defaultPrevented||(e.interactive&&!t.doubleClickZoom.isActive()&&t.stop(),t.boxZoom.onMouseDown(r),t.boxZoom.isActive()||t.dragPan.isActive()||t.dragRotate.onMouseDown(r),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onMouseDown(r))}),s.addEventListener(r,"mouseup",function(e){var r=t.dragRotate.isActive();n&&!r&&t.fire(new Vr("contextmenu",t,n)),n=null,i=!1,t.fire(new Vr("mouseup",t,e))}),s.addEventListener(r,"mousemove",function(e){if(!t.dragPan.isActive()&&!t.dragRotate.isActive()){for(var n=e.toElement||e.target;n&&n!==r;)n=n.parentNode;n===r&&t.fire(new Vr("mousemove",t,e))}}),s.addEventListener(r,"mouseover",function(e){for(var n=e.toElement||e.target;n&&n!==r;)n=n.parentNode;n===r&&t.fire(new Vr("mouseover",t,e))}),s.addEventListener(r,"touchstart",function(r){var n=new Ur("touchstart",t,r);t.fire(n),n.defaultPrevented||(e.interactive&&t.stop(),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onTouchStart(r),t.touchZoomRotate.onStart(r),t.doubleClickZoom.onTouchStart(n))},{passive:!1}),s.addEventListener(r,"touchmove",function(e){t.fire(new Ur("touchmove",t,e))},{passive:!1}),s.addEventListener(r,"touchend",function(e){t.fire(new Ur("touchend",t,e))}),s.addEventListener(r,"touchcancel",function(e){t.fire(new Ur("touchcancel",t,e))}),s.addEventListener(r,"click",function(e){t.fire(new Vr("click",t,e))}),s.addEventListener(r,"dblclick",function(e){var r=new Vr("dblclick",t,e);t.fire(r),r.defaultPrevented||t.doubleClickZoom.onDblClick(r)}),s.addEventListener(r,"contextmenu",function(e){var r=t.dragRotate.isActive();i||r?i&&(n=e):t.fire(new Vr("contextmenu",t,e)),e.preventDefault()}),s.addEventListener(r,"wheel",function(e){var r=new qr("wheel",t,e);t.fire(r),r.defaultPrevented||t.scrollZoom.onWheel(e)},{passive:!1})}(this,e),this._hash=e.hash&&(new jr).addTo(this),this._hash&&this._hash._onHashChange()||this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),this.resize(),e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new nn),this.addControl(new an,e.logoPosition),this.on("style.load",function(){this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",this._onData),this.on("dataloading",this._onDataLoading)}r&&(n.__proto__=r),n.prototype=Object.create(r&&r.prototype),n.prototype.constructor=n;var i={showTileBoundaries:{configurable:!0},showCollisionBoxes:{configurable:!0},showOverdrawInspector:{configurable:!0},repaint:{configurable:!0},vertices:{configurable:!0}};return n.prototype.addControl=function(t,e){void 0===e&&t.getDefaultPosition&&(e=t.getDefaultPosition()),void 0===e&&(e="top-right");var r=t.onAdd(this),n=this._controlPositions[e];return-1!==e.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this},n.prototype.removeControl=function(t){return t.onRemove(this),this},n.prototype.resize=function(e){var r=this._containerDimensions(),n=r[0],i=r[1];return this._resizeCanvas(n,i),this.transform.resize(n,i),this.painter.resize(n,i),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)).fire(new t.Event("resize",e)).fire(new t.Event("moveend",e))},n.prototype.getBounds=function(){var e=new W(this.transform.pointLocation(new t.default$1(0,this.transform.height)),this.transform.pointLocation(new t.default$1(this.transform.width,0)));return(this.transform.angle||this.transform.pitch)&&(e.extend(this.transform.pointLocation(new t.default$1(this.transform.size.x,0))),e.extend(this.transform.pointLocation(new t.default$1(0,this.transform.size.y)))),e},n.prototype.getMaxBounds=function(){return this.transform.latRange&&2===this.transform.latRange.length&&this.transform.lngRange&&2===this.transform.lngRange.length?new W([this.transform.lngRange[0],this.transform.latRange[0]],[this.transform.lngRange[1],this.transform.latRange[1]]):null},n.prototype.setMaxBounds=function(t){if(t){var e=W.convert(t);this.transform.lngRange=[e.getWest(),e.getEast()],this.transform.latRange=[e.getSouth(),e.getNorth()],this.transform._constrain(),this._update()}else null==t&&(this.transform.lngRange=null,this.transform.latRange=null,this._update());return this},n.prototype.setMinZoom=function(t){if((t=null==t?0:t)>=0&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")},n.prototype.getRenderWorldCopies=function(){return this.transform.renderWorldCopies},n.prototype.setRenderWorldCopies=function(t){return this.transform.renderWorldCopies=t,this._update(),this},n.prototype.getMaxZoom=function(){return this.transform.maxZoom},n.prototype.project=function(t){return this.transform.locationPoint(G.convert(t))},n.prototype.unproject=function(e){return this.transform.pointLocation(t.default$1.convert(e))},n.prototype.isMoving=function(){return this._moving||this.dragPan.isActive()||this.dragRotate.isActive()||this.scrollZoom.isActive()},n.prototype.isZooming=function(){return this._zooming||this.scrollZoom.isActive()},n.prototype.isRotating=function(){return this._rotating||this.dragRotate.isActive()},n.prototype.on=function(t,e,n){var i,a=this;if(void 0===n)return r.prototype.on.call(this,t,e);var o=function(){if("mouseenter"===t||"mouseover"===t){var r=!1;return{layer:e,listener:n,delegates:{mousemove:function(i){var o=a.getLayer(e)?a.queryRenderedFeatures(i.point,{layers:[e]}):[];o.length?r||(r=!0,n.call(a,new Vr(t,a,i.originalEvent,{features:o}))):r=!1},mouseout:function(){r=!1}}}}if("mouseleave"===t||"mouseout"===t){var o=!1;return{layer:e,listener:n,delegates:{mousemove:function(r){(a.getLayer(e)?a.queryRenderedFeatures(r.point,{layers:[e]}):[]).length?o=!0:o&&(o=!1,n.call(a,new Vr(t,a,r.originalEvent)))},mouseout:function(e){o&&(o=!1,n.call(a,new Vr(t,a,e.originalEvent)))}}}}return{layer:e,listener:n,delegates:(i={},i[t]=function(t){var r=a.getLayer(e)?a.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,n.call(a,t),delete t.features)},i)}}();for(var s in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(o),o.delegates)a.on(s,o.delegates[s]);return this},n.prototype.off=function(t,e,n){if(void 0===n)return r.prototype.off.call(this,t,e);if(this._delegatedListeners&&this._delegatedListeners[t])for(var i=this._delegatedListeners[t],a=0;a180;){var o=r.locationPoint(t);if(o.x>=0&&o.y>=0&&o.x<=r.width&&o.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}pn.prototype._rotateCompassArrow=function(){var t="rotate("+this._map.transform.angle*(180/Math.PI)+"deg)";this._compassArrow.style.transform=t},pn.prototype.onAdd=function(t){return this._map=t,this.options.showCompass&&(this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Yr(t,{button:"left",element:this._compass}),this._handler.enable()),this._container},pn.prototype.onRemove=function(){s.remove(this._container),this.options.showCompass&&(this._map.off("rotate",this._rotateCompassArrow),this._handler.disable(),delete this._handler),delete this._map},pn.prototype._createButton=function(t,e,r){var n=s.create("button",t,this._container);return n.type="button",n.setAttribute("aria-label",e),n.addEventListener("click",r),n};var gn={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function vn(t,e,r){var n=t.classList;for(var i in gn)n.remove("mapboxgl-"+r+"-anchor-"+i);n.add("mapboxgl-"+r+"-anchor-"+e)}var mn=function(e){if((arguments[0]instanceof t.default.HTMLElement||2===arguments.length)&&(e=t.extend({element:e},arguments[1])),t.bindAll(["_update","_onMapClick"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",e&&e.element)this._element=e.element,this._offset=t.default$1.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=s.create("div");var r=s.createNS("http://www.w3.org/2000/svg","svg");r.setAttributeNS(null,"height","41px"),r.setAttributeNS(null,"width","27px"),r.setAttributeNS(null,"viewBox","0 0 27 41");var n=s.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"stroke","none"),n.setAttributeNS(null,"stroke-width","1"),n.setAttributeNS(null,"fill","none"),n.setAttributeNS(null,"fill-rule","evenodd");var i=s.createNS("http://www.w3.org/2000/svg","g");i.setAttributeNS(null,"fill-rule","nonzero");var a=s.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");for(var o=0,l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];o5280?Mn(e,c,h/5280,"mi"):Mn(e,c,h,"ft")}else r&&"nautical"===r.unit?Mn(e,c,f/1852,"nm"):Mn(e,c,f,"m")}function Mn(t,e,r,n){var i,a,o,s=(i=r,(a=Math.pow(10,(""+Math.floor(i)).length-1))*(o=(o=i/a)>=10?10:o>=5?5:o>=3?3:o>=2?2:1)),l=s/r;"m"===n&&s>=1e3&&(s/=1e3,n="km"),t.style.width=e*l+"px",t.innerHTML=s+n}wn.prototype.getDefaultPosition=function(){return"bottom-left"},wn.prototype._onMove=function(){kn(this._map,this._container,this.options)},wn.prototype.onAdd=function(t){return this._map=t,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container},wn.prototype.onRemove=function(){s.remove(this._container),this._map.off("move",this._onMove),this._map=void 0},wn.prototype.setUnit=function(t){this.options.unit=t,kn(this._map,this._container,this.options)};var An=function(){this._fullscreen=!1,t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.default.document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in t.default.document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in t.default.document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in t.default.document&&(this._fullscreenchange="MSFullscreenChange"),this._className="mapboxgl-ctrl"};An.prototype.onAdd=function(e){return this._map=e,this._mapContainer=this._map.getContainer(),this._container=s.create("div",this._className+" mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._container.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._container},An.prototype.onRemove=function(){s.remove(this._container),this._map=null,t.default.document.removeEventListener(this._fullscreenchange,this._changeIcon)},An.prototype._checkFullscreenSupport=function(){return!!(t.default.document.fullscreenEnabled||t.default.document.mozFullScreenEnabled||t.default.document.msFullscreenEnabled||t.default.document.webkitFullscreenEnabled)},An.prototype._setupUI=function(){var e=this._fullscreenButton=s.create("button",this._className+"-icon "+this._className+"-fullscreen",this._container);e.setAttribute("aria-label","Toggle fullscreen"),e.type="button",this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.default.document.addEventListener(this._fullscreenchange,this._changeIcon)},An.prototype._isFullscreen=function(){return this._fullscreen},An.prototype._changeIcon=function(){(t.default.document.fullscreenElement||t.default.document.mozFullScreenElement||t.default.document.webkitFullscreenElement||t.default.document.msFullscreenElement)===this._mapContainer!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(this._className+"-shrink"),this._fullscreenButton.classList.toggle(this._className+"-fullscreen"))},An.prototype._onClickFullscreen=function(){this._isFullscreen()?t.default.document.exitFullscreen?t.default.document.exitFullscreen():t.default.document.mozCancelFullScreen?t.default.document.mozCancelFullScreen():t.default.document.msExitFullscreen?t.default.document.msExitFullscreen():t.default.document.webkitCancelFullScreen&&t.default.document.webkitCancelFullScreen():this._mapContainer.requestFullscreen?this._mapContainer.requestFullscreen():this._mapContainer.mozRequestFullScreen?this._mapContainer.mozRequestFullScreen():this._mapContainer.msRequestFullscreen?this._mapContainer.msRequestFullscreen():this._mapContainer.webkitRequestFullscreen&&this._mapContainer.webkitRequestFullscreen()};var Tn={closeButton:!0,closeOnClick:!0},Sn=function(e){function r(r){e.call(this),this.options=t.extend(Object.create(Tn),r),t.bindAll(["_update","_onClickClose"],this)}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.addTo=function(e){return this._map=e,this._map.on("move",this._update),this.options.closeOnClick&&this._map.on("click",this._onClickClose),this._update(),this.fire(new t.Event("open")),this},r.prototype.isOpen=function(){return!!this._map},r.prototype.remove=function(){return this._content&&s.remove(this._content),this._container&&(s.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("click",this._onClickClose),delete this._map),this.fire(new t.Event("close")),this},r.prototype.getLngLat=function(){return this._lngLat},r.prototype.setLngLat=function(t){return this._lngLat=G.convert(t),this._pos=null,this._update(),this},r.prototype.setText=function(e){return this.setDOMContent(t.default.document.createTextNode(e))},r.prototype.setHTML=function(e){var r,n=t.default.document.createDocumentFragment(),i=t.default.document.createElement("body");for(i.innerHTML=e;r=i.firstChild;)n.appendChild(r);return this.setDOMContent(n)},r.prototype.setDOMContent=function(t){return this._createContent(),this._content.appendChild(t),this._update(),this},r.prototype._createContent=function(){this._content&&s.remove(this._content),this._content=s.create("div","mapboxgl-popup-content",this._container),this.options.closeButton&&(this._closeButton=s.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClickClose))},r.prototype._update=function(){if(this._map&&this._lngLat&&this._content){this._container||(this._container=s.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=s.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this._map.transform.renderWorldCopies&&(this._lngLat=dn(this._lngLat,this._pos,this._map.transform));var e=this._pos=this._map.project(this._lngLat),r=this.options.anchor,n=function e(r){if(r){if("number"==typeof r){var n=Math.round(Math.sqrt(.5*Math.pow(r,2)));return{center:new t.default$1(0,0),top:new t.default$1(0,r),"top-left":new t.default$1(n,n),"top-right":new t.default$1(-n,n),bottom:new t.default$1(0,-r),"bottom-left":new t.default$1(n,-n),"bottom-right":new t.default$1(-n,-n),left:new t.default$1(r,0),right:new t.default$1(-r,0)}}if(r instanceof t.default$1||Array.isArray(r)){var i=t.default$1.convert(r);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.default$1.convert(r.center||[0,0]),top:t.default$1.convert(r.top||[0,0]),"top-left":t.default$1.convert(r["top-left"]||[0,0]),"top-right":t.default$1.convert(r["top-right"]||[0,0]),bottom:t.default$1.convert(r.bottom||[0,0]),"bottom-left":t.default$1.convert(r["bottom-left"]||[0,0]),"bottom-right":t.default$1.convert(r["bottom-right"]||[0,0]),left:t.default$1.convert(r.left||[0,0]),right:t.default$1.convert(r.right||[0,0])}}return e(new t.default$1(0,0))}(this.options.offset);if(!r){var i,a=this._container.offsetWidth,o=this._container.offsetHeight;i=e.y+n.bottom.ythis._map.transform.height-o?["bottom"]:[],e.xthis._map.transform.width-a/2&&i.push("right"),r=0===i.length?"bottom":i.join("-")}var l=e.add(n[r]).round();s.setTransform(this._container,gn[r]+" translate("+l.x+"px,"+l.y+"px)"),vn(this._container,r,"popup")}},r.prototype._onClickClose=function(){this.remove()},r}(t.Evented),Cn={version:"0.45.0",supported:e,workerCount:Math.max(Math.floor(a.hardwareConcurrency/2),1),setRTLTextPlugin:t.setRTLTextPlugin,Map:un,NavigationControl:pn,GeolocateControl:bn,AttributionControl:nn,ScaleControl:wn,FullscreenControl:An,Popup:Sn,Marker:mn,Style:Je,LngLat:G,LngLatBounds:W,Point:t.default$1,Evented:t.Evented,config:v,get accessToken(){return v.ACCESS_TOKEN},set accessToken(t){v.ACCESS_TOKEN=t},workerUrl:""};return Cn}),n})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],410:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1<p[1][2]&&(m[0]=-m[0]),p[0][2]>p[2][0]&&(m[1]=-m[1]),p[1][0]>p[0][1]&&(m[2]=-m[2]),!0}},{"./normalize":412,"gl-mat4/clone":248,"gl-mat4/create":249,"gl-mat4/determinant":250,"gl-mat4/invert":254,"gl-mat4/transpose":264,"gl-vec3/cross":317,"gl-vec3/dot":322,"gl-vec3/length":332,"gl-vec3/normalize":339}],412:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;i<16;i++)t[i]=e[i]*n;return!0}},{}],413:[function(t,e,r){var n=t("gl-vec3/lerp"),i=t("mat4-recompose"),a=t("mat4-decompose"),o=t("gl-mat4/determinant"),s=t("quat-slerp"),l=f(),c=f(),u=f();function f(){return{translate:h(),scale:h(1),skew:h(),perspective:[0,0,0,1],quaternion:[0,0,0,1]}}function h(t){return[t||0,t||0,t||0]}e.exports=function(t,e,r,f){if(0===o(e)||0===o(r))return!1;var h=a(e,l.translate,l.scale,l.skew,l.perspective,l.quaternion),p=a(r,c.translate,c.scale,c.skew,c.perspective,c.quaternion);return!(!h||!p||(n(u.translate,l.translate,c.translate,f),n(u.skew,l.skew,c.skew,f),n(u.scale,l.scale,c.scale,f),n(u.perspective,l.perspective,c.perspective,f),s(u.quaternion,l.quaternion,c.quaternion,f),i(t,u.translate,u.scale,u.skew,u.perspective,u.quaternion),0))}},{"gl-mat4/determinant":250,"gl-vec3/lerp":333,"mat4-decompose":411,"mat4-recompose":414,"quat-slerp":466}],414:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":249,"gl-mat4/fromRotationTranslation":252,"gl-mat4/identity":253,"gl-mat4/multiply":256,"gl-mat4/scale":262,"gl-mat4/translate":263}],415:[function(t,e,r){"use strict";e.exports=Math.log2||function(t){return Math.log(t)*Math.LOG2E}},{}],416:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=t("mat4-interpolate"),a=t("gl-mat4/invert"),o=t("gl-mat4/rotateX"),s=t("gl-mat4/rotateY"),l=t("gl-mat4/rotateZ"),c=t("gl-mat4/lookAt"),u=t("gl-mat4/translate"),f=(t("gl-mat4/scale"),t("gl-vec3/normalize")),h=[0,0,0];function p(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-1/0,1/0]}e.exports=function(t){return new p((t=t||{}).matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])};var d=p.prototype;d.recalcMatrix=function(t){var e=this._time,r=n.le(e,t),o=this.computedMatrix;if(!(r<0)){var s=this._components;if(r===e.length-1)for(var l=16*r,c=0;c<16;++c)o[c]=s[l++];else{var u=e[r+1]-e[r],h=(l=16*r,this.prevMatrix),p=!0;for(c=0;c<16;++c)h[c]=s[l++];var d=this.nextMatrix;for(c=0;c<16;++c)d[c]=s[l++],p=p&&h[c]===d[c];if(u<1e-6||p)for(c=0;c<16;++c)o[c]=h[c];else i(o,h,d,(t-e[r])/u)}var g=this.computedUp;g[0]=o[1],g[1]=o[5],g[2]=o[9],f(g,g);var v=this.computedInverse;a(v,o);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;var x=this.computedCenter,b=Math.exp(this.computedRadius[0]);for(c=0;c<3;++c)x[c]=m[c]-o[2+4*c]*b}},d.idle=function(t){if(!(t1&&n(t[o[u-2]],t[o[u-1]],c)<=0;)u-=1,o.pop();for(o.push(l),u=s.length;u>1&&n(t[s[u-2]],t[s[u-1]],c)>=0;)u-=1,s.pop();s.push(l)}for(var r=new Array(s.length+o.length-2),f=0,i=0,h=o.length;i0;--p)r[f++]=s[p];return r};var n=t("robust-orientation")[3]},{"robust-orientation":486}],418:[function(t,e,r){"use strict";e.exports=function(t,e){e||(e=t,t=window);var r=0,i=0,a=0,o={shift:!1,alt:!1,control:!1,meta:!1},s=!1;function l(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==o.alt,o.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==o.shift,o.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==o.control,o.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==o.meta,o.meta=!!t.metaKey),e}function c(t,s){var c=n.x(s),u=n.y(s);"buttons"in s&&(t=0|s.buttons),(t!==r||c!==i||u!==a||l(s))&&(r=0|t,i=c||0,a=u||0,e&&e(r,i,a,o))}function u(t){c(0,t)}function f(){(r||i||a||o.shift||o.alt||o.meta||o.control)&&(i=a=0,r=0,o.shift=o.alt=o.control=o.meta=!1,e&&e(0,0,0,o))}function h(t){l(t)&&e&&e(r,i,a,o)}function p(t){0===n.buttons(t)?c(0,t):c(r,t)}function d(t){c(r|n.buttons(t),t)}function g(t){c(r&~n.buttons(t),t)}function v(){s||(s=!0,t.addEventListener("mousemove",p),t.addEventListener("mousedown",d),t.addEventListener("mouseup",g),t.addEventListener("mouseleave",u),t.addEventListener("mouseenter",u),t.addEventListener("mouseout",u),t.addEventListener("mouseover",u),t.addEventListener("blur",f),t.addEventListener("keyup",h),t.addEventListener("keydown",h),t.addEventListener("keypress",h),t!==window&&(window.addEventListener("blur",f),window.addEventListener("keyup",h),window.addEventListener("keydown",h),window.addEventListener("keypress",h)))}v();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return s},set:function(e){e?v():s&&(s=!1,t.removeEventListener("mousemove",p),t.removeEventListener("mousedown",d),t.removeEventListener("mouseup",g),t.removeEventListener("mouseleave",u),t.removeEventListener("mouseenter",u),t.removeEventListener("mouseout",u),t.removeEventListener("mouseover",u),t.removeEventListener("blur",f),t.removeEventListener("keyup",h),t.removeEventListener("keydown",h),t.removeEventListener("keypress",h),t!==window&&(window.removeEventListener("blur",f),window.removeEventListener("keyup",h),window.removeEventListener("keydown",h),window.removeEventListener("keypress",h)))},enumerable:!0},buttons:{get:function(){return r},enumerable:!0},x:{get:function(){return i},enumerable:!0},y:{get:function(){return a},enumerable:!0},mods:{get:function(){return o},enumerable:!0}}),m};var n=t("mouse-event")},{"mouse-event":420}],419:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var i=t.clientX||0,a=t.clientY||0,o=(s=e,s===window||s===document||s===document.body?n:s.getBoundingClientRect());var s;return r[0]=i-o.left,r[1]=a-o.top,r}},{}],420:[function(t,e,r){"use strict";function n(t){return t.target||t.srcElement||window}r.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){if(2===(e=t.which))return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1< 0");"function"!=typeof t.vertex&&e("Must specify vertex creation function");"function"!=typeof t.cell&&e("Must specify cell creation function");"function"!=typeof t.phase&&e("Must specify phase function");for(var C=t.getters||[],E=new Array(T),L=0;L=0?E[L]=!0:E[L]=!1;return function(t,e,r,T,S,C){var E=C.length,L=S.length;if(L<2)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var z="extractContour"+S.join("_"),O=[],I=[],P=[],D=0;D0&&N.push(l(D,S[R-1])+"*"+s(S[R-1])),I.push(d(D,S[R])+"=("+N.join("-")+")|0")}for(var D=0;D=0;--D)j.push(s(S[D]));I.push(w+"=("+j.join("*")+")|0",b+"=mallocUint32("+w+")",x+"=mallocUint32("+w+")",k+"=0"),I.push(g(0)+"=0");for(var R=1;R<1<0;M=M-1&d)w.push(x+"["+k+"+"+m(M)+"]");w.push(y(0));for(var M=0;M=0;--e)G(e,0);for(var r=[],e=0;e0){",p(S[e]),"=1;");t(e-1,r|1<=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),a.push("1"),o.push("s["+l+"]-2"));var c=".lo("+a.join()+").hi("+o.join()+")";if(0===a.length&&(c=""),i>0){n.push("if(1");for(var l=0;l=0||e.indexOf(-(l+1))>=0||n.push("&&s[",l,"]>2");n.push("){grad",i,"(src.pick(",s.join(),")",c);for(var l=0;l=0||e.indexOf(-(l+1))>=0||n.push(",dst.pick(",s.join(),",",l,")",c);n.push(");")}for(var l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",h.join(),")-src.get(",p.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):n.push("if(s[",u,"]>1){diff(",f,",src.pick(",h.join(),")",c,",src.pick(",p.join(),")",c,");}else{zero(",f,");};");break;case"mirror":0===i?n.push("dst.set(",s.join(),",",u,",0);"):n.push("zero(",f,");");break;case"wrap":var d=s.slice(),g=s.slice();e[l]<0?(d[u]="s["+u+"]-2",g[u]="0"):(d[u]="s["+u+"]-1",g[u]="1"),0===i?n.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",d.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):n.push("if(s[",u,"]>2){diff(",f,",src.pick(",d.join(),")",c,",src.pick(",g.join(),")",c,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}i>0&&n.push("};")}for(var s=0;s<1<>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in l){var e=l[t];r[t]=o({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var c={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in c){var e=c[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var u=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=n({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=n({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=n({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=n({args:["array","array"],pre:i,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":134}],428:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var r=[],a=t,o=1;Array.isArray(a);)r.push(a.length),o*=a.length,a=a[0];return 0===r.length?n():(e||(e=n(new Float64Array(o),r)),i(e,t),e)}},{"./doConvert.js":429,ndarray:433}],429:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":134}],430:[function(t,e,r){"use strict";var n=t("typedarray-pool"),i=32;function a(t){switch(t){case"uint8":return[n.mallocUint8,n.freeUint8];case"uint16":return[n.mallocUint16,n.freeUint16];case"uint32":return[n.mallocUint32,n.freeUint32];case"int8":return[n.mallocInt8,n.freeInt8];case"int16":return[n.mallocInt16,n.freeInt16];case"int32":return[n.mallocInt32,n.freeInt32];case"float32":return[n.mallocFloat,n.freeFloat];case"float64":return[n.mallocDouble,n.freeDouble];default:return null}}function o(t){for(var e=[],r=0;r0?s.push(["d",d,"=s",d,"-d",f,"*n",f].join("")):s.push(["d",d,"=s",d].join("")),f=d),0!=(p=t.length-1-l)&&(h>0?s.push(["e",p,"=s",p,"-e",h,"*n",h,",f",p,"=",c[p],"-f",h,"*n",h].join("")):s.push(["e",p,"=s",p,",f",p,"=",c[p]].join("")),h=p)}r.push("var "+s.join(","));var g=["0","n0-1","data","offset"].concat(o(t.length));r.push(["if(n0<=",i,"){","insertionSort(",g.join(","),")}else{","quickSort(",g.join(","),")}"].join("")),r.push("}return "+n);var v=new Function("insertionSort","quickSort",r.join("\n")),m=function(t,e){var r=["'use strict'"],n=["ndarrayInsertionSort",t.join("d"),e].join(""),i=["left","right","data","offset"].concat(o(t.length)),s=a(e),l=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var c=[],u=1;u1){for(r.push("dptr=0;sptr=ptr"),u=t.length-1;u>=0;--u)0!==(p=t[u])&&r.push(["for(i",p,"=0;i",p,"b){break __l}"].join("")),u=t.length-1;u>=1;--u)r.push("sptr+=e"+u,"dptr+=f"+u,"}");for(r.push("dptr=cptr;sptr=cptr-s0"),u=t.length-1;u>=0;--u)0!==(p=t[u])&&r.push(["for(i",p,"=0;i",p,"=0;--u)0!==(p=t[u])&&r.push(["for(i",p,"=0;i",p,"scratch)){",h("cptr",f("cptr-s0")),"cptr-=s0","}",h("cptr","scratch"));return r.push("}"),t.length>1&&s&&r.push("free(scratch)"),r.push("} return "+n),s?new Function("malloc","free",r.join("\n"))(s[0],s[1]):new Function(r.join("\n"))()}(t,e),y=function(t,e,r){var n=["'use strict'"],s=["ndarrayQuickSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(o(t.length)),c=a(e),u=0;n.push(["function ",s,"(",l.join(","),"){"].join(""));var f=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var h=[],p=1;p=0;--a)0!==(o=t[a])&&n.push(["for(i",o,"=0;i",o,"1)for(a=0;a1?n.push("ptr_shift+=d"+o):n.push("ptr0+=d"+o),n.push("}"))}}function y(e,r,i,a){if(1===r.length)n.push("ptr0="+d(r[0]));else{for(var o=0;o1)for(o=0;o=1;--o)i&&n.push("pivot_ptr+=f"+o),r.length>1?n.push("ptr_shift+=e"+o):n.push("ptr0+=e"+o),n.push("}")}function x(){t.length>1&&c&&n.push("free(pivot1)","free(pivot2)")}function b(e,r){var i="el"+e,a="el"+r;if(t.length>1){var o="__l"+ ++u;y(o,[i,a],!1,["comp=",g("ptr0"),"-",g("ptr1"),"\n","if(comp>0){tmp0=",i,";",i,"=",a,";",a,"=tmp0;break ",o,"}\n","if(comp<0){break ",o,"}"].join(""))}else n.push(["if(",g(d(i)),">",g(d(a)),"){tmp0=",i,";",i,"=",a,";",a,"=tmp0}"].join(""))}function _(e,r){t.length>1?m([e,r],!1,v("ptr0",g("ptr1"))):n.push(v(d(e),g(d(r))))}function w(e,r,i){if(t.length>1){var a="__l"+ ++u;y(a,[r],!0,[e,"=",g("ptr0"),"-pivot",i,"[pivot_ptr]\n","if(",e,"!==0){break ",a,"}"].join(""))}else n.push([e,"=",g(d(r)),"-pivot",i].join(""))}function k(e,r){t.length>1?m([e,r],!1,["tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1","tmp")].join("")):n.push(["ptr0=",d(e),"\n","ptr1=",d(r),"\n","tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1","tmp")].join(""))}function M(e,r,i){t.length>1?(m([e,r,i],!1,["tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1",g("ptr2")),"\n",v("ptr2","tmp")].join("")),n.push("++"+r,"--"+i)):n.push(["ptr0=",d(e),"\n","ptr1=",d(r),"\n","ptr2=",d(i),"\n","++",r,"\n","--",i,"\n","tmp=",g("ptr0"),"\n",v("ptr0",g("ptr1")),"\n",v("ptr1",g("ptr2")),"\n",v("ptr2","tmp")].join(""))}function A(t,e){k(t,e),n.push("--"+e)}function T(e,r,i){t.length>1?m([e,r],!0,[v("ptr0",g("ptr1")),"\n",v("ptr1",["pivot",i,"[pivot_ptr]"].join(""))].join("")):n.push(v(d(e),g(d(r))),v(d(r),"pivot"+i))}function S(e,r){n.push(["if((",r,"-",e,")<=",i,"){\n","insertionSort(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}else{\n",s,"(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}"].join(""))}function C(e,r,i){t.length>1?(n.push(["__l",++u,":while(true){"].join("")),m([e],!0,["if(",g("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",u,"}"].join("")),n.push(i,"}")):n.push(["while(",g(d(e)),"===pivot",r,"){",i,"}"].join(""))}return n.push("var "+f.join(",")),b(1,2),b(4,5),b(1,3),b(2,3),b(1,4),b(3,4),b(2,5),b(2,3),b(4,5),t.length>1?m(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",g("ptr1"),"\n","pivot2[pivot_ptr]=",g("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",g("ptr0"),"\n","y=",g("ptr2"),"\n","z=",g("ptr4"),"\n",v("ptr5","x"),"\n",v("ptr6","y"),"\n",v("ptr7","z")].join("")):n.push(["pivot1=",g(d("el2")),"\n","pivot2=",g(d("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",g(d("el1")),"\n","y=",g(d("el3")),"\n","z=",g(d("el5")),"\n",v(d("index1"),"x"),"\n",v(d("index3"),"y"),"\n",v(d("index5"),"z")].join("")),_("index2","left"),_("index4","right"),n.push("if(pivots_are_equal){"),n.push("for(k=less;k<=great;++k){"),w("comp","k",1),n.push("if(comp===0){continue}"),n.push("if(comp<0){"),n.push("if(k!==less){"),k("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),n.push("while(true){"),w("comp","great",1),n.push("if(comp>0){"),n.push("great--"),n.push("}else if(comp<0){"),M("k","less","great"),n.push("break"),n.push("}else{"),A("k","great"),n.push("break"),n.push("}"),n.push("}"),n.push("}"),n.push("}"),n.push("}else{"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1<0){"),n.push("if(k!==less){"),k("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2>0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp>0){"),n.push("if(--greatindex5){"),C("less",1,"++less"),C("great",2,"--great"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1===0){"),n.push("if(k!==less){"),k("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2===0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp===0){"),n.push("if(--great1&&c?new Function("insertionSort","malloc","free",n.join("\n"))(r,c[0],c[1]):new Function("insertionSort",n.join("\n"))(r)}(t,e,m);return v(m,y)}},{"typedarray-pool":521}],431:[function(t,e,r){"use strict";var n=t("./lib/compile_sort.js"),i={};e.exports=function(t){var e=t.order,r=t.dtype,a=[e,r].join(":"),o=i[a];return o||(i[a]=o=n(e,r)),o(t),t}},{"./lib/compile_sort.js":430}],432:[function(t,e,r){"use strict";var n=t("ndarray-linear-interpolate"),i=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=new Array(_inline_3_arg4_)}",args:[{name:"_inline_3_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg2_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg3_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_4_arg2_(this_warped,_inline_4_arg0_),_inline_4_arg1_=_inline_4_arg3_.apply(void 0,this_warped)}",args:[{name:"_inline_4_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_4_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg4_",lvalue:!1,rvalue:!1,count:0}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warpND",blockSize:64}),a=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_7_arg2_(this_warped,_inline_7_arg0_),_inline_7_arg1_=_inline_7_arg3_(_inline_7_arg4_,this_warped[0])}",args:[{name:"_inline_7_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_7_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_7_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_7_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_7_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp1D",blockSize:64}),o=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_10_arg2_(this_warped,_inline_10_arg0_),_inline_10_arg1_=_inline_10_arg3_(_inline_10_arg4_,this_warped[0],this_warped[1])}",args:[{name:"_inline_10_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_10_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp2D",blockSize:64}),s=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_13_arg2_(this_warped,_inline_13_arg0_),_inline_13_arg1_=_inline_13_arg3_(_inline_13_arg4_,this_warped[0],this_warped[1],this_warped[2])}",args:[{name:"_inline_13_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_13_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp3D",blockSize:64});e.exports=function(t,e,r){switch(e.shape.length){case 1:a(t,r,n.d1,e);break;case 2:o(t,r,n.d2,e);break;case 3:s(t,r,n.d3,e);break;default:i(t,r,n.bind(void 0,e),e.shape.length)}return t}},{"cwise/lib/wrapper":137,"ndarray-linear-interpolate":426}],433:[function(t,e,r){var n=t("iota-array"),i=t("is-buffer"),a="undefined"!=typeof Float64Array;function o(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,r=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+l.join(",")+",v){"),i?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+l.join(",")+"){"),i?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",l.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+l.join(",")+"){return new "+r+"(this.data,"+o.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+o.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=o.map(function(t){return"a"+t+"=this.shape["+t+"]"}),d=o.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+d.join(","));for(var g=0;g=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");a.push("return new "+r+"(this.data,"+o.map(function(t){return"a"+t}).join(",")+","+o.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+l.join(",")+"){var "+o.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+o.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(g=0;g=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");return a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+o.map(function(t){return"shape["+t+"]"}).join(",")+","+o.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",a.join("\n"))(c[t],s)}var c={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,r,n){if(void 0===t)return(0,c.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var o=e.length;if(void 0===r){r=new Array(o);for(var s=o-1,u=1;s>=0;--s)r[s]=u,u*=e[s]}if(void 0===n)for(n=0,s=0;s>>0;e.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-i:i;var r=n.hi(t),o=n.lo(t);e>t==t>0?o===a?(r+=1,o=0):o+=1:0===o?(o=a,r-=1):o-=1;return n.pack(o,r)}},{"double-bits":152}],435:[function(t,e,r){var n=Math.PI,i=c(120);function a(t,e,r,n){return["C",t,e,r,n,r,n]}function o(t,e,r,n,i,a){return["C",t/3+2/3*r,e/3+2/3*n,i/3+2/3*r,a/3+2/3*n,i,a]}function s(t,e,r,a,o,c,u,f,h,p){if(p)k=p[0],M=p[1],_=p[2],w=p[3];else{var d=l(t,e,-o);t=d.x,e=d.y;var g=(t-(f=(d=l(f,h,-o)).x))/2,v=(e-(h=d.y))/2,m=g*g/(r*r)+v*v/(a*a);m>1&&(r*=m=Math.sqrt(m),a*=m);var y=r*r,x=a*a,b=(c==u?-1:1)*Math.sqrt(Math.abs((y*x-y*v*v-x*g*g)/(y*v*v+x*g*g)));b==1/0&&(b=1);var _=b*r*v/a+(t+f)/2,w=b*-a*g/r+(e+h)/2,k=Math.asin(((e-w)/a).toFixed(9)),M=Math.asin(((h-w)/a).toFixed(9));(k=t<_?n-k:k)<0&&(k=2*n+k),(M=f<_?n-M:M)<0&&(M=2*n+M),u&&k>M&&(k-=2*n),!u&&M>k&&(M-=2*n)}if(Math.abs(M-k)>i){var A=M,T=f,S=h;M=k+i*(u&&M>k?1:-1);var C=s(f=_+r*Math.cos(M),h=w+a*Math.sin(M),r,a,o,0,u,T,S,[M,A,_,w])}var E=Math.tan((M-k)/4),L=4/3*r*E,z=4/3*a*E,O=[2*t-(t+L*Math.sin(k)),2*e-(e-z*Math.cos(k)),f+L*Math.sin(M),h-z*Math.cos(M),f,h];if(p)return O;C&&(O=O.concat(C));for(var I=0;I7&&(r.push(m.splice(0,7)),m.unshift("C"));break;case"S":var x=p,b=d;"C"!=e&&"S"!=e||(x+=x-n,b+=b-i),m=["C",x,b,m[1],m[2],m[3],m[4]];break;case"T":"Q"==e||"T"==e?(f=2*p-f,h=2*d-h):(f=p,h=d),m=o(p,d,f,h,m[1],m[2]);break;case"Q":f=m[1],h=m[2],m=o(p,d,m[1],m[2],m[3],m[4]);break;case"L":m=a(p,d,m[1],m[2]);break;case"H":m=a(p,d,m[1],d);break;case"V":m=a(p,d,p,m[1]);break;case"Z":m=a(p,d,l,u)}e=y,p=m[m.length-2],d=m[m.length-1],m.length>4?(n=m[m.length-4],i=m[m.length-3]):(n=p,i=d),r.push(m)}return r}},{}],436:[function(t,e,r){r.vertexNormals=function(t,e,r){for(var n=e.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa){var b=i[c],_=1/Math.sqrt(v*y);for(x=0;x<3;++x){var w=(x+1)%3,k=(x+2)%3;b[x]+=_*(m[w]*g[k]-m[k]*g[w])}}}for(o=0;oa)for(_=1/Math.sqrt(M),x=0;x<3;++x)b[x]*=_;else for(x=0;x<3;++x)b[x]=0}return i},r.faceNormals=function(t,e,r){for(var n=t.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa?1/Math.sqrt(p):0;for(c=0;c<3;++c)h[c]*=p;i[o]=h}return i}},{}],437:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,o,s=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),l=1;l0){var f=Math.sqrt(u+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,c),f=Math.sqrt(2*h-u+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}},{}],439:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),u(r=[].slice.call(r,0,4),r);var i=new f(r,e,Math.log(n));i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up);return i};var n=t("filtered-vector"),i=t("gl-mat4/lookAt"),a=t("gl-mat4/fromQuat"),o=t("gl-mat4/invert"),s=t("./lib/quatFromFrame");function l(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function c(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function u(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=c(r,n,i,a);o>1e-6?(t[0]=r/o,t[1]=n/o,t[2]=i/o,t[3]=a/o):(t[0]=t[1]=t[2]=0,t[3]=1)}function f(t,e,r){this.radius=n([r]),this.center=n(e),this.rotation=n(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}var h=f.prototype;h.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},h.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;u(e,e);var r=this.computedMatrix;a(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;l<3;++l){for(var c=0,f=0;f<3;++f)c+=r[l+4*f]*i[f];r[12+l]=-c}},h.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r},h.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},h.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},h.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=i[1],o=i[5],s=i[9],c=l(a,o,s);a/=c,o/=c,s/=c;var u=i[0],f=i[4],h=i[8],p=u*a+f*o+h*s,d=l(u-=a*p,f-=o*p,h-=s*p);u/=d,f/=d,h/=d;var g=i[2],v=i[6],m=i[10],y=g*a+v*o+m*s,x=g*u+v*f+m*h,b=l(g-=y*a+x*u,v-=y*o+x*f,m-=y*s+x*h);g/=b,v/=b,m/=b;var _=u*e+a*r,w=f*e+o*r,k=h*e+s*r;this.center.move(t,_,w,k);var M=Math.exp(this.computedRadius[0]);M=Math.max(1e-4,M+n),this.radius.set(t,Math.log(M))},h.rotate=function(t,e,r,n){this.recalcMatrix(t),e=e||0,r=r||0;var i=this.computedMatrix,a=i[0],o=i[4],s=i[8],u=i[1],f=i[5],h=i[9],p=i[2],d=i[6],g=i[10],v=e*a+r*u,m=e*o+r*f,y=e*s+r*h,x=-(d*y-g*m),b=-(g*v-p*y),_=-(p*m-d*v),w=Math.sqrt(Math.max(0,1-Math.pow(x,2)-Math.pow(b,2)-Math.pow(_,2))),k=c(x,b,_,w);k>1e-6?(x/=k,b/=k,_/=k,w/=k):(x=b=_=0,w=1);var M=this.computedRotation,A=M[0],T=M[1],S=M[2],C=M[3],E=A*w+C*x+T*_-S*b,L=T*w+C*b+S*x-A*_,z=S*w+C*_+A*b-T*x,O=C*w-A*x-T*b-S*_;if(n){x=p,b=d,_=g;var I=Math.sin(n)/l(x,b,_);x*=I,b*=I,_*=I,O=O*(w=Math.cos(e))-(E=E*w+O*x+L*_-z*b)*x-(L=L*w+O*b+z*x-E*_)*b-(z=z*w+O*_+E*b-L*x)*_}var P=c(E,L,z,O);P>1e-6?(E/=P,L/=P,z/=P,O/=P):(E=L=z=0,O=1),this.rotation.set(t,E,L,z,O)},h.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var a=this.computedMatrix;i(a,e,r,n);var o=this.computedRotation;s(o,a[0],a[1],a[2],a[4],a[5],a[6],a[8],a[9],a[10]),u(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var l=0,c=0;c<3;++c)l+=Math.pow(r[c]-e[c],2);this.radius.set(t,.5*Math.log(Math.max(l,1e-6))),this.center.set(t,r[0],r[1],r[2])},h.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},h.setMatrix=function(t,e){var r=this.computedRotation;s(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),u(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;o(n,e);var i=n[15];if(Math.abs(i)>1e-6){var a=n[12]/i,l=n[13]/i,c=n[14]/i;this.recalcMatrix(t);var f=Math.exp(this.computedRadius[0]);this.center.set(t,a-n[2]*f,l-n[6]*f,c-n[10]*f),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},h.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},h.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},h.getDistanceLimits=function(t){var e=this.radius.bounds;return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},h.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},h.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":438,"filtered-vector":215,"gl-mat4/fromQuat":251,"gl-mat4/invert":254,"gl-mat4/lookAt":255}],440:[function(t,e,r){"use strict";var n=t("repeat-string");e.exports=function(t,e,r){return n(r="undefined"!=typeof r?r+"":" ",e)+t}},{"repeat-string":479}],441:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)return[t];var r=[t];"string"==typeof e||Array.isArray(e)?e={brackets:e}:e||(e={});var n=e.brackets?Array.isArray(e.brackets)?e.brackets:[e.brackets]:["{}","[]","()"],i=e.escape||"___",a=!!e.flat;n.forEach(function(t){var e=new RegExp(["\\",t[0],"[^\\",t[0],"\\",t[1],"]*\\",t[1]].join("")),n=[];function a(e,a,o){var s=r.push(e.slice(t[0].length,-t[1].length))-1;return n.push(s),i+s}r.forEach(function(t,n){for(var i,o=0;t!=i;)if(i=t,t=t.replace(e,a),o++>1e4)throw Error("References have circular dependency. Please, check them.");r[n]=t}),n=n.reverse(),r=r.map(function(e){return n.forEach(function(r){e=e.replace(new RegExp("(\\"+i+r+"(?![0-9]))","g"),t[0]+"$1"+t[1])}),e})});var o=new RegExp("\\"+i+"([0-9]+)");return a?r:function t(e,r,n){for(var i,a=[],s=0;i=o.exec(e);){if(s++>1e4)throw Error("Circular references in parenthesis");a.push(e.slice(0,i.index)),a.push(t(r[i[1]],r)),e=e.slice(i.index+i[0].length)}return a.push(e),a}(r[0],r)}function i(t,e){if(e&&e.flat){var r,n=e&&e.escape||"___",i=t[0];if(!i)return"";for(var a=new RegExp("\\"+n+"([0-9]+)"),o=0;i!=r;){if(o++>1e4)throw Error("Circular references in "+t);r=i,i=i.replace(a,s)}return i}return t.reduce(function t(e,r){return Array.isArray(r)&&(r=r.reduce(t,"")),e+r},"");function s(e,r){if(null==t[r])throw Error("Reference "+r+"is undefined");return t[r]}}function a(t,e){return Array.isArray(t)?i(t,e):n(t,e)}a.parse=n,a.stringify=i,e.exports=a},{}],442:[function(t,e,r){"use strict";var n=t("pick-by-alias");e.exports=function(t){var e;arguments.length>1&&(t=arguments);"string"==typeof t?t=t.split(/\s/).map(parseFloat):"number"==typeof t&&(t=[t]);t.length&&"number"==typeof t[0]?e=1===t.length?{width:t[0],height:t[0],x:0,y:0}:2===t.length?{width:t[0],height:t[1],x:0,y:0}:{x:t[0],y:t[1],width:t[2]-t[0]||0,height:t[3]-t[1]||0}:t&&(t=n(t,{left:"x l left Left",top:"y t top Top",width:"w width W Width",height:"h height W Width",bottom:"b bottom Bottom",right:"r right Right"}),e={x:t.left||0,y:t.top||0},null==t.width?t.right?e.width=t.right-e.x:e.width=0:e.width=t.width,null==t.height?t.bottom?e.height=t.bottom-e.y:e.height=0:e.height=t.height);return e}},{"pick-by-alias":448}],443:[function(t,e,r){e.exports=function(t){var e=[];return t.replace(i,function(t,r,i){var o=r.toLowerCase();for(i=function(t){var e=t.match(a);return e?e.map(Number):[]}(i),"m"==o&&i.length>2&&(e.push([r].concat(i.splice(0,2))),o="l",r="m"==r?"l":"L");;){if(i.length==n[o])return i.unshift(r),e.push(i);if(i.length0;--o)a=l[o],r=s[o],s[o]=s[a],s[a]=r,l[o]=l[r],l[r]=a,c=(c+r)*o;return n.freeUint32(l),n.freeUint32(s),c},r.unrank=function(t,e,r){switch(t){case 0:return r||[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}var n,i,a,o=1;for((r=r||new Array(t))[0]=0,a=1;a0;--a)e=e-(n=e/o|0)*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}},{"invert-permutation":398,"typedarray-pool":521}],448:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n,a,o={};if("string"==typeof e&&(e=i(e)),Array.isArray(e)){var s={};for(a=0;a0){o=a[u][r][0],l=u;break}s=o[1^l];for(var f=0;f<2;++f)for(var h=a[f][r],p=0;p0&&(o=d,s=g,l=f)}return i?s:(o&&c(o,l),s)}function f(t,r){var i=a[r][t][0],o=[t];c(i,r);for(var s=i[1^r];;){for(;s!==t;)o.push(s),s=u(o[o.length-2],s,!1);if(a[0][t].length+a[1][t].length===0)break;var l=o[o.length-1],f=t,h=o[1],p=u(l,f,!0);if(n(e[l],e[f],e[h],e[p])<0)break;o.push(t),s=u(l,f)}return o}function h(t,e){return e[1]===e[e.length-1]}for(var o=0;o0;){a[0][o].length;var g=f(o,p);h(d,g)?d.push.apply(d,g):(d.length>0&&l.push(d),d=g)}d.length>0&&l.push(d)}return l};var n=t("compare-angle")},{"compare-angle":115}],450:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=n(t,e.length),i=new Array(e.length),a=new Array(e.length),o=[],s=0;s0;){var c=o.pop();i[c]=!1;for(var u=r[c],s=0;s0})).length,v=new Array(g),m=new Array(g),p=0;p0;){var N=F.pop(),j=E[N];l(j,function(t,e){return t-e});var V,U=j.length,q=B[N];if(0===q){var k=d[N];V=[k]}for(var p=0;p=0)&&(B[H]=1^q,F.push(H),0===q)){var k=d[H];R(k)||(k.reverse(),V.push(k))}}0===q&&r.push(V)}return r};var n=t("edges-to-adjacency-list"),i=t("planar-dual"),a=t("point-in-big-polygon"),o=t("two-product"),s=t("robust-sum"),l=t("uniq"),c=t("./lib/trim-leaves");function u(t,e){for(var r=new Array(t),n=0;n>>1;e.dtype||(e.dtype="array"),"string"==typeof e.dtype?d=new(f(e.dtype))(v):e.dtype&&(d=e.dtype,Array.isArray(d)&&(d.length=v));for(var m=0;mr){for(var h=0;hl||A>c||T=E||o===s)){var u=y[a];void 0===s&&(s=u.length);for(var f=o;f=g&&p<=m&&d>=v&&d<=w&&z.push(h)}var b=x[a],_=b[4*o+0],k=b[4*o+1],C=b[4*o+2],L=b[4*o+3],O=function(t,e){for(var r=null,n=0;null===r;)if(r=t[4*e+n],++n>t.length)return null;return r}(b,o+1),I=.5*i,P=a+1;e(r,n,I,P,_,k||C||L||O),e(r,n+I,I,P,k,C||L||O),e(r+I,n,I,P,C,L||O),e(r+I,n+I,I,P,L,O)}}}(0,0,1,0,0,1),z},d;function C(t,e,r){for(var n=1,i=.5,a=.5,o=.5,s=0;s0&&e[i]===r[0]))return 1;a=t[i-1]}for(var s=1;a;){var l=a.key,c=n(r,l[0],l[1]);if(l[0][0]0))return 0;s=-1,a=a.right}else if(c>0)a=a.left;else{if(!(c<0))return 0;s=1,a=a.right}}return s}}(m.slabs,m.coordinates);return 0===a.length?y:function(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}(l(a),y)};var n=t("robust-orientation")[3],i=t("slab-decomposition"),a=t("interval-tree-1d"),o=t("binary-search-bounds");function s(){return!0}function l(t){for(var e={},r=0;r=-t},pointBetween:function(e,r,n){var i=e[1]-r[1],a=n[0]-r[0],o=e[0]-r[0],s=n[1]-r[1],l=o*a+i*s;return!(l-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-i>t&&(a-c)*(i-u)/(o-u)+c-n>t&&(s=!s),a=c,o=u}return s}};return e}},{}],459:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),i=1;i0})}function u(t,n){var i=t.seg,a=n.seg,o=i.start,s=i.end,c=a.start,u=a.end;r&&r.checkIntersection(i,a);var f=e.linesIntersect(o,s,c,u);if(!1===f){if(!e.pointsCollinear(o,s,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(s,c))return!1;var h=e.pointsSame(o,c),p=e.pointsSame(s,u);if(h&&p)return n;var d=!h&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(s,c,u);if(h)return g?l(n,s):l(t,u),n;d&&(p||(g?l(n,s):l(t,u)),l(n,o))}else 0===f.alongA&&(-1===f.alongB?l(t,c):0===f.alongB?l(t,f.pt):1===f.alongB&&l(t,u)),0===f.alongB&&(-1===f.alongA?l(n,o):0===f.alongA?l(n,f.pt):1===f.alongA&&l(n,s));return!1}for(var f=[];!a.isEmpty();){var h=a.getHead();if(r&&r.vert(h.pt[0]),h.isStart){r&&r.segmentNew(h.seg,h.primary);var p=c(h),d=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function v(){if(d){var t=u(h,d);if(t)return t}return!!g&&u(h,g)}r&&r.tempStatus(h.seg,!!d&&d.seg,!!g&&g.seg);var m,y,x=v();if(x)t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=h.seg.myFill,r&&r.segmentUpdate(x.seg),h.other.remove(),h.remove();if(a.getHead()!==h){r&&r.rewind(h.seg);continue}t?(y=null===h.seg.myFill.below||h.seg.myFill.above!==h.seg.myFill.below,h.seg.myFill.below=g?g.seg.myFill.above:i,h.seg.myFill.above=y?!h.seg.myFill.below:h.seg.myFill.below):null===h.seg.otherFill&&(m=g?h.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:h.primary?o:i,h.seg.otherFill={above:m,below:m}),r&&r.status(h.seg,!!d&&d.seg,!!g&&g.seg),h.other.status=p.insert(n.node({ev:h}))}else{var b=h.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(s.exists(b.prev)&&s.exists(b.next)&&u(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!h.primary){var _=h.seg.myFill;h.seg.myFill=h.seg.otherFill,h.seg.otherFill=_}f.push(h.seg)}a.getHead().remove()}return r&&r.done(),f}return t?{addRegion:function(t){for(var n,i,a,o=t[t.length-1],l=0;l=c?(M=1,y=c+2*h+d):y=h*(M=-h/c)+d):(M=0,p>=0?(A=0,y=d):-p>=f?(A=1,y=f+2*p+d):y=p*(A=-p/f)+d);else if(A<0)A=0,h>=0?(M=0,y=d):-h>=c?(M=1,y=c+2*h+d):y=h*(M=-h/c)+d;else{var T=1/k;y=(M*=T)*(c*M+u*(A*=T)+2*h)+A*(u*M+f*A+2*p)+d}else M<0?(b=f+p)>(x=u+h)?(_=b-x)>=(w=c-2*u+f)?(M=1,A=0,y=c+2*h+d):y=(M=_/w)*(c*M+u*(A=1-M)+2*h)+A*(u*M+f*A+2*p)+d:(M=0,b<=0?(A=1,y=f+2*p+d):p>=0?(A=0,y=d):y=p*(A=-p/f)+d):A<0?(b=c+h)>(x=u+p)?(_=b-x)>=(w=c-2*u+f)?(A=1,M=0,y=f+2*p+d):y=(M=1-(A=_/w))*(c*M+u*A+2*h)+A*(u*M+f*A+2*p)+d:(A=0,b<=0?(M=1,y=c+2*h+d):h>=0?(M=0,y=d):y=h*(M=-h/c)+d):(_=f+p-u-h)<=0?(M=0,A=1,y=f+2*p+d):_>=(w=c-2*u+f)?(M=1,A=0,y=c+2*h+d):y=(M=_/w)*(c*M+u*(A=1-M)+2*h)+A*(u*M+f*A+2*p)+d;var S=1-M-A;for(l=0;l1)for(var r=1;r0){var c=t[r-1];if(0===n(s,c)&&a(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}},{"cell-orientation":100,"compare-cell":116,"compare-oriented-cell":117}],473:[function(t,e,r){"use strict";var n=t("array-bounds"),i=t("color-normalize"),a=t("update-diff"),o=t("pick-by-alias"),s=t("object-assign"),l=t("flatten-vertex-data"),c=t("to-float32"),u=c.float32,f=c.fract32;e.exports=function(t,e){"function"==typeof t?(e||(e={}),e.regl=t):e=t;e.length&&(e.positions=e);if(!(t=e.regl).hasExtension("ANGLE_instanced_arrays"))throw Error("regl-error2d: `ANGLE_instanced_arrays` extension should be enabled");var r,c,p,d,g,v,m=t._gl,y={color:"black",capSize:5,lineWidth:1,opacity:1,viewport:null,range:null,offset:0,count:0,bounds:null,positions:[],errors:[]},x=[];return d=t.buffer({usage:"dynamic",type:"uint8",data:new Uint8Array(0)}),c=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)}),p=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)}),g=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)}),v=t.buffer({usage:"static",type:"float",data:h}),k(e),r=t({vert:"\n\t\tprecision highp float;\n\n\t\tattribute vec2 position, positionFract;\n\t\tattribute vec4 error;\n\t\tattribute vec4 color;\n\n\t\tattribute vec2 direction, lineOffset, capOffset;\n\n\t\tuniform vec4 viewport;\n\t\tuniform float lineWidth, capSize;\n\t\tuniform vec2 scale, scaleFract, translate, translateFract;\n\n\t\tvarying vec4 fragColor;\n\n\t\tvoid main() {\n\t\t\tfragColor = color / 255.;\n\n\t\t\tvec2 pixelOffset = lineWidth * lineOffset + (capSize + lineWidth) * capOffset;\n\n\t\t\tvec2 dxy = -step(.5, direction.xy) * error.xz + step(direction.xy, vec2(-.5)) * error.yw;\n\n\t\t\tvec2 position = position + dxy;\n\n\t\t\tvec2 pos = (position + translate) * scale\n\t\t\t\t+ (positionFract + translateFract) * scale\n\t\t\t\t+ (position + translate) * scaleFract\n\t\t\t\t+ (positionFract + translateFract) * scaleFract;\n\n\t\t\tpos += pixelOffset / viewport.zw;\n\n\t\t\tgl_Position = vec4(pos * 2. - 1., 0, 1);\n\t\t}\n\t\t",frag:"\n\t\tprecision mediump float;\n\n\t\tvarying vec4 fragColor;\n\n\t\tuniform float opacity;\n\n\t\tvoid main() {\n\t\t\tgl_FragColor = fragColor;\n\t\t\tgl_FragColor.a *= opacity;\n\t\t}\n\t\t",uniforms:{range:t.prop("range"),lineWidth:t.prop("lineWidth"),capSize:t.prop("capSize"),opacity:t.prop("opacity"),scale:t.prop("scale"),translate:t.prop("translate"),scaleFract:t.prop("scaleFract"),translateFract:t.prop("translateFract"),viewport:function(t,e){return[e.viewport.x,e.viewport.y,t.viewportWidth,t.viewportHeight]}},attributes:{color:{buffer:d,offset:function(t,e){return 4*e.offset},divisor:1},position:{buffer:c,offset:function(t,e){return 8*e.offset},divisor:1},positionFract:{buffer:p,offset:function(t,e){return 8*e.offset},divisor:1},error:{buffer:g,offset:function(t,e){return 16*e.offset},divisor:1},direction:{buffer:v,stride:24,offset:0},lineOffset:{buffer:v,stride:24,offset:8},capOffset:{buffer:v,stride:24,offset:16}},primitive:"triangles",blend:{enable:!0,color:[0,0,0,0],equation:{rgb:"add",alpha:"add"},func:{srcRGB:"src alpha",dstRGB:"one minus src alpha",srcAlpha:"one minus dst alpha",dstAlpha:"one"}},depth:{enable:!1},scissor:{enable:!0,box:t.prop("viewport")},viewport:t.prop("viewport"),stencil:!1,instances:t.prop("count"),count:h.length}),s(b,{update:k,draw:_,destroy:M,regl:t,gl:m,canvas:m.canvas,groups:x}),b;function b(t){t?k(t):null===t&&M(),_()}function _(e){if("number"==typeof e)return w(e);e&&!Array.isArray(e)&&(e=[e]),t._refresh(),x.forEach(function(t,r){t&&(e&&(e[r]?t.draw=!0:t.draw=!1),t.draw?w(r):t.draw=!0)})}function w(t){"number"==typeof t&&(t=x[t]),null!=t&&t&&t.count&&t.color&&t.opacity&&t.positions&&t.positions.length>1&&(t.scaleRatio=[t.scale[0]*t.viewport.width,t.scale[1]*t.viewport.height],r(t),t.after&&t.after(t))}function k(t){if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var e=0,r=0;if(b.groups=x=t.map(function(t,c){var u=x[c];return t?("function"==typeof t?t={after:t}:"number"==typeof t[0]&&(t={positions:t}),t=o(t,{color:"color colors fill",capSize:"capSize cap capsize cap-size",lineWidth:"lineWidth line-width width line thickness",opacity:"opacity alpha",range:"range dataBox",viewport:"viewport viewBox",errors:"errors error",positions:"positions position data points"}),u||(x[c]=u={id:c,scale:null,translate:null,scaleFract:null,translateFract:null,draw:!0},t=s({},y,t)),a(u,t,[{lineWidth:function(t){return.5*+t},capSize:function(t){return.5*+t},opacity:parseFloat,errors:function(t){return t=l(t),r+=t.length,t},positions:function(t,r){return t=l(t,"float64"),r.count=Math.floor(t.length/2),r.bounds=n(t,2),r.offset=e,e+=r.count,t}},{color:function(t,e){var r=e.count;if(t||(t="transparent"),!Array.isArray(t)||"number"==typeof t[0]){var n=t;t=Array(r);for(var a=0;a 0. && baClipping < length(normalWidth * endBotJoin)) {\n\t\t//handle miter clipping\n\t\tbTopCoord -= normalWidth * endTopJoin;\n\t\tbTopCoord += normalize(endTopJoin * normalWidth) * baClipping;\n\t}\n\n\tif (nextReverse) {\n\t\t//make join rectangular\n\t\tvec2 miterShift = normalWidth * endJoinDirection * miterLimit * .5;\n\t\tfloat normalAdjust = 1. - min(miterLimit / endMiterRatio, 1.);\n\t\tbBotCoord = bCoord + miterShift - normalAdjust * normalWidth * currNormal * .5;\n\t\tbTopCoord = bCoord + miterShift + normalAdjust * normalWidth * currNormal * .5;\n\t}\n\telse if (!prevReverse && abClipping > 0. && abClipping < length(normalWidth * startBotJoin)) {\n\t\t//handle miter clipping\n\t\taBotCoord -= normalWidth * startBotJoin;\n\t\taBotCoord += normalize(startBotJoin * normalWidth) * abClipping;\n\t}\n\n\tvec2 aTopPosition = (aTopCoord) * adjustedScale + translate;\n\tvec2 aBotPosition = (aBotCoord) * adjustedScale + translate;\n\n\tvec2 bTopPosition = (bTopCoord) * adjustedScale + translate;\n\tvec2 bBotPosition = (bBotCoord) * adjustedScale + translate;\n\n\t//position is normalized 0..1 coord on the screen\n\tvec2 position = (aTopPosition * lineTop + aBotPosition * lineBot) * lineStart + (bTopPosition * lineTop + bBotPosition * lineBot) * lineEnd;\n\n\tstartCoord = aCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\tendCoord = bCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tenableStartMiter = step(dot(currTangent, prevTangent), .5);\n\tenableEndMiter = step(dot(currTangent, nextTangent), .5);\n\n\t//bevel miter cutoffs\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * miterLimit * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * miterLimit * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n\n\t//round miter cutoffs\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * abs(dot(startJoinDirection, currNormal)) * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * abs(dot(endJoinDirection, currNormal)) * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nuniform sampler2D dashPattern;\nuniform float dashSize, pixelRatio, thickness, opacity, id, miterMode;\n\nvarying vec4 fragColor;\nvarying vec2 tangent;\nvarying vec4 startCutoff, endCutoff;\nvarying vec2 startCoord, endCoord;\nvarying float enableStartMiter, enableEndMiter;\n\nfloat distToLine(vec2 p, vec2 a, vec2 b) {\n\tvec2 diff = b - a;\n\tvec2 perp = normalize(vec2(-diff.y, diff.x));\n\treturn dot(p - a, perp);\n}\n\nvoid main() {\n\tfloat alpha = 1., distToStart, distToEnd;\n\tfloat cutoff = thickness * .5;\n\n\t//bevel miter\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToStart + 1., 0.), 1.);\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToEnd + 1., 0.), 1.);\n\t\t}\n\t}\n\n\t// round miter\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - startCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - endCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\t}\n\n\tfloat t = fract(dot(tangent, gl_FragCoord.xy) / dashSize) * .5 + .25;\n\tfloat dash = texture2D(dashPattern, vec2(t, .5)).r;\n\n\tgl_FragColor = fragColor;\n\tgl_FragColor.a *= alpha * opacity * dash;\n}\n"]),attributes:{lineEnd:{buffer:r,divisor:0,stride:8,offset:0},lineTop:{buffer:r,divisor:0,stride:8,offset:4},aColor:{buffer:t.prop("colorBuffer"),stride:4,offset:0,divisor:1},bColor:{buffer:t.prop("colorBuffer"),stride:4,offset:4,divisor:1},prevCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:0,divisor:1},aCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:8,divisor:1},bCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:16,divisor:1},nextCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:24,divisor:1}}},n))}catch(t){e=i}return{fill:t({primitive:"triangle",elements:function(t,e){return e.triangles},offset:0,vert:o(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec2 position, positionFract;\n\nuniform vec4 color;\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio, id;\nuniform vec4 viewport;\nuniform float opacity;\n\nvarying vec4 fragColor;\n\nconst float MAX_LINES = 256.;\n\nvoid main() {\n\tfloat depth = (MAX_LINES - 4. - id) / (MAX_LINES);\n\n\tvec2 position = position * scale + translate\n + positionFract * scale + translateFract\n + position * scaleFract\n + positionFract * scaleFract;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tfragColor = color / 255.;\n\tfragColor.a *= opacity;\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n\tgl_FragColor = fragColor;\n}\n"]),uniforms:{scale:t.prop("scale"),color:t.prop("fill"),scaleFract:t.prop("scaleFract"),translateFract:t.prop("translateFract"),translate:t.prop("translate"),opacity:t.prop("opacity"),pixelRatio:t.context("pixelRatio"),id:t.prop("id"),viewport:function(t,e){return[e.viewport.x,e.viewport.y,t.viewportWidth,t.viewportHeight]}},attributes:{position:{buffer:t.prop("positionBuffer"),stride:8,offset:8},positionFract:{buffer:t.prop("positionFractBuffer"),stride:8,offset:8}},blend:n.blend,depth:{enable:!1},scissor:n.scissor,stencil:n.stencil,viewport:n.viewport}),rect:i,miter:e}},v.defaults={dashes:null,join:"miter",miterLimit:1,thickness:10,cap:"square",color:"black",opacity:1,overlay:!1,viewport:null,range:null,close:!1,fill:null},v.prototype.render=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];e.length&&(t=this).update.apply(t,e),this.draw()},v.prototype.draw=function(){for(var t=this,e=[],r=arguments.length;r--;)e[r]=arguments[r];return(e.length?e:this.passes).forEach(function(e,r){var n;if(e&&Array.isArray(e))return(n=t).draw.apply(n,e);"number"==typeof e&&(e=t.passes[e]),e&&e.count>1&&e.opacity&&(t.regl._refresh(),e.fill&&e.triangles&&e.triangles.length>2&&t.shaders.fill(e),e.thickness&&(e.scale[0]*e.viewport.width>v.precisionThreshold||e.scale[1]*e.viewport.height>v.precisionThreshold?t.shaders.rect(e):"rect"===e.join||!e.join&&(e.thickness<=2||e.count>=v.maxPoints)?t.shaders.rect(e):t.shaders.miter(e)))}),this},v.prototype.update=function(t){var e=this;if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var r=this.regl,o=this.gl;if(t.forEach(function(t,f){var d=e.passes[f];if(void 0!==t)if(null!==t){if("number"==typeof t[0]&&(t={positions:t}),t=s(t,{positions:"positions points data coords",thickness:"thickness lineWidth lineWidths line-width linewidth width stroke-width strokewidth strokeWidth",join:"lineJoin linejoin join type mode",miterLimit:"miterlimit miterLimit",dashes:"dash dashes dasharray dash-array dashArray",color:"color colour stroke colors colours stroke-color strokeColor",fill:"fill fill-color fillColor",opacity:"alpha opacity",overlay:"overlay crease overlap intersect",close:"closed close closed-path closePath",range:"range dataBox",viewport:"viewport viewBox",hole:"holes hole hollow"}),d||(e.passes[f]=d={id:f,scale:null,scaleFract:null,translate:null,translateFract:null,count:0,hole:[],depth:0,dashLength:1,dashTexture:r.texture({channels:1,data:new Uint8Array([255]),width:1,height:1,mag:"linear",min:"linear"}),colorBuffer:r.buffer({usage:"dynamic",type:"uint8",data:new Uint8Array}),positionBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array}),positionFractBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array})},t=a({},v.defaults,t)),null!=t.thickness&&(d.thickness=parseFloat(t.thickness)),null!=t.opacity&&(d.opacity=parseFloat(t.opacity)),null!=t.miterLimit&&(d.miterLimit=parseFloat(t.miterLimit)),null!=t.overlay&&(d.overlay=!!t.overlay,f 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]),l.vert=u(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]),d&&(l.frag=l.frag.replace("smoothstep","smoothStep"),s.frag=s.frag.replace("smoothstep","smoothStep")),this.drawCircle=t(l)}y.defaults={color:"black",borderColor:"transparent",borderSize:0,size:12,opacity:1,marker:void 0,viewport:null,range:null,pixelSize:null,count:0,offset:0,bounds:null,positions:[],snap:1e4},y.prototype.render=function(){return arguments.length&&this.update.apply(this,arguments),this.draw(),this},y.prototype.draw=function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;nn)?e.tree=l(t,{bounds:f}):n&&n.length&&(e.tree=n),e.tree){var h={primitive:"points",usage:"static",data:e.tree,type:"uint32"};e.elements?e.elements(h):e.elements=s.elements(h)}return i({data:g.float(t),usage:"dynamic"}),a({data:g.fract(t),usage:"dynamic"}),c({data:new Uint8Array(u),type:"uint8",usage:"stream"}),t}},{marker:function(e,r,n){var i=r.activation;if(i.forEach(function(t){return t&&t.destroy&&t.destroy()}),i.length=0,e&&"number"!=typeof e[0]){for(var a=[],o=0,l=Math.min(e.length,r.count);o=0)return a;if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)e=t;else{e=new Uint8Array(t.length);for(var o=0,s=t.length;o4*n&&(this.tooManyColors=!0),this.updatePalette(r),1===i.length?i[0]:i},y.prototype.updatePalette=function(t){if(!this.tooManyColors){var e=this.maxColors,r=this.paletteTexture,n=Math.ceil(.25*t.length/e);if(n>1)for(var i=.25*(t=t.slice()).length%e;i2?(s[0],s[2],n=s[1],i=s[3]):s.length?(n=s[0],i=s[1]):(s.x,n=s.y,s.x+s.width,i=s.y+s.height),l.length>2?(a=l[0],o=l[2],l[1],l[3]):l.length?(a=l[0],o=l[1]):(a=l.x,l.y,o=l.x+l.width,l.y+l.height),[a,n,o,i]}function p(t){if("number"==typeof t)return[t,t,t,t];if(2===t.length)return[t[0],t[1],t[0],t[1]];var e=l(t);return[e.x,e.y,e.x+e.width,e.y+e.height]}e.exports=u,u.prototype.render=function(){for(var t,e=this,r=[],n=arguments.length;n--;)r[n]=arguments[n];return r.length&&(t=this).update.apply(t,r),this.regl.attributes.preserveDrawingBuffer?this.draw():(this.dirty?null==this.planned&&(this.planned=o(function(){e.draw(),e.dirty=!0,e.planned=null})):(this.draw(),this.dirty=!0,o(function(){e.dirty=!1})),this)},u.prototype.update=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e.length){for(var n=0;nM))&&(s.lower||!(k>>=e))<<3,(e|=r=(15<(t>>>=r))<<2)|(r=(3<(t>>>=r))<<1)|t>>>r>>1}function s(){function t(t){t:{for(var e=16;268435456>=e;e*=16)if(t<=e){t=e;break t}t=0}return 0<(e=r[o(t)>>2]).length?e.pop():new ArrayBuffer(t)}function e(t){r[o(t.byteLength)>>2].push(t)}var r=a(8,function(){return[]});return{alloc:t,free:e,allocType:function(e,r){var n=null;switch(e){case 5120:n=new Int8Array(t(r),0,r);break;case 5121:n=new Uint8Array(t(r),0,r);break;case 5122:n=new Int16Array(t(2*r),0,r);break;case 5123:n=new Uint16Array(t(2*r),0,r);break;case 5124:n=new Int32Array(t(4*r),0,r);break;case 5125:n=new Uint32Array(t(4*r),0,r);break;case 5126:n=new Float32Array(t(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(t){e(t.buffer)}}}function l(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||Y(t.data))}function c(t,e,r,n,i,a){for(var o=0;o(i=s)&&(i=n.buffer.byteLength,5123===f?i>>=1:5125===f&&(i>>=2)),n.vertCount=i,i=o,0>o&&(i=4,1===(o=n.buffer.dimension)&&(i=0),2===o&&(i=1),3===o&&(i=4)),n.primType=i}function o(t){n.elementsCount--,delete s[t.id],t.buffer.destroy(),t.buffer=null}var s={},c=0,u={uint8:5121,uint16:5123};e.oes_element_index_uint&&(u.uint32=5125),i.prototype.bind=function(){this.buffer.bind()};var f=[];return{create:function(t,e){function s(t){if(t)if("number"==typeof t)c(t),f.primType=4,f.vertCount=0|t,f.type=5121;else{var e=null,r=35044,n=-1,i=-1,o=0,h=0;Array.isArray(t)||Y(t)||l(t)?e=t:("data"in t&&(e=t.data),"usage"in t&&(r=K[t.usage]),"primitive"in t&&(n=rt[t.primitive]),"count"in t&&(i=0|t.count),"type"in t&&(h=u[t.type]),"length"in t?o=0|t.length:(o=i,5123===h||5122===h?o*=2:5125!==h&&5124!==h||(o*=4))),a(f,e,r,n,i,o,h)}else c(),f.primType=4,f.vertCount=0,f.type=5121;return s}var c=r.create(null,34963,!0),f=new i(c._buffer);return n.elementsCount++,s(t),s._reglType="elements",s._elements=f,s.subdata=function(t,e){return c.subdata(t,e),s},s.destroy=function(){o(f)},s},createStream:function(t){var e=f.pop();return e||(e=new i(r.create(null,34963,!0,!1)._buffer)),a(e,t,35040,-1,-1,0,0),e},destroyStream:function(t){f.push(t)},getElements:function(t){return"function"==typeof t&&t._elements instanceof i?t._elements:null},clear:function(){X(s).forEach(o)}}}function g(t){for(var e=G.allocType(5123,t.length),r=0;r>>31<<15,i=(a<<1>>>24)-127,a=a>>13&1023;e[r]=-24>i?n:-14>i?n+(a+1024>>-14-i):15>=i,r.height>>=i,p(r,n[i]),t.mipmask|=1<e;++e)t.images[e]=null;return t}function L(t){for(var e=t.images,r=0;re){for(var r=0;r=--this.refCount&&F(this)}}),o.profile&&(a.getTotalTextureSize=function(){var t=0;return Object.keys(mt).forEach(function(e){t+=mt[e].stats.size}),t}),{create2D:function(e,r){function n(t,e){var r=i.texInfo;z.call(r);var a=E();return"number"==typeof t?T(a,0|t,"number"==typeof e?0|e:0|t):t?(O(r,t),S(a,t)):T(a,1,1),r.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,c(i,a),i.internalformat=a.internalformat,n.width=a.width,n.height=a.height,D(i),C(a,3553),I(r,3553),R(),L(a),o.profile&&(i.stats.size=k(i.internalformat,i.type,a.width,a.height,r.genMipmaps,!1)),n.format=tt[i.internalformat],n.type=et[i.type],n.mag=rt[r.magFilter],n.min=nt[r.minFilter],n.wrapS=it[r.wrapS],n.wrapT=it[r.wrapT],n}var i=new P(3553);return mt[i.id]=i,a.textureCount++,n(e,r),n.subimage=function(t,e,r,a){e|=0,r|=0,a|=0;var o=m();return c(o,i),o.width=0,o.height=0,p(o,t),o.width=o.width||(i.width>>a)-e,o.height=o.height||(i.height>>a)-r,D(i),d(o,3553,e,r,a),R(),M(o),n},n.resize=function(e,r){var a=0|e,s=0|r||a;if(a===i.width&&s===i.height)return n;n.width=i.width=a,n.height=i.height=s,D(i);for(var l,c=i.channels,u=i.type,f=0;i.mipmask>>f;++f){var h=a>>f,p=s>>f;if(!h||!p)break;l=G.zero.allocType(u,h*p*c),t.texImage2D(3553,f,i.format,h,p,0,i.format,i.type,l),l&&G.zero.freeType(l)}return R(),o.profile&&(i.stats.size=k(i.internalformat,i.type,a,s,!1,!1)),n},n._reglType="texture2d",n._texture=i,o.profile&&(n.stats=i.stats),n.destroy=function(){i.decRef()},n},createCube:function(e,r,n,i,s,l){function f(t,e,r,n,i,a){var s,l=h.texInfo;for(z.call(l),s=0;6>s;++s)g[s]=E();if("number"!=typeof t&&t){if("object"==typeof t)if(e)S(g[0],t),S(g[1],e),S(g[2],r),S(g[3],n),S(g[4],i),S(g[5],a);else if(O(l,t),u(h,t),"faces"in t)for(t=t.faces,s=0;6>s;++s)c(g[s],h),S(g[s],t[s]);else for(s=0;6>s;++s)S(g[s],t)}else for(t=0|t||1,s=0;6>s;++s)T(g[s],t,t);for(c(h,g[0]),h.mipmask=l.genMipmaps?(g[0].width<<1)-1:g[0].mipmask,h.internalformat=g[0].internalformat,f.width=g[0].width,f.height=g[0].height,D(h),s=0;6>s;++s)C(g[s],34069+s);for(I(l,34067),R(),o.profile&&(h.stats.size=k(h.internalformat,h.type,f.width,f.height,l.genMipmaps,!0)),f.format=tt[h.internalformat],f.type=et[h.type],f.mag=rt[l.magFilter],f.min=nt[l.minFilter],f.wrapS=it[l.wrapS],f.wrapT=it[l.wrapT],s=0;6>s;++s)L(g[s]);return f}var h=new P(34067);mt[h.id]=h,a.cubeCount++;var g=Array(6);return f(e,r,n,i,s,l),f.subimage=function(t,e,r,n,i){r|=0,n|=0,i|=0;var a=m();return c(a,h),a.width=0,a.height=0,p(a,e),a.width=a.width||(h.width>>i)-r,a.height=a.height||(h.height>>i)-n,D(h),d(a,34069+t,r,n,i),R(),M(a),f},f.resize=function(e){if((e|=0)!==h.width){f.width=h.width=e,f.height=h.height=e,D(h);for(var r=0;6>r;++r)for(var n=0;h.mipmask>>n;++n)t.texImage2D(34069+r,n,h.format,e>>n,e>>n,0,h.format,h.type,null);return R(),o.profile&&(h.stats.size=k(h.internalformat,h.type,f.width,f.height,!1,!0)),f}},f._reglType="textureCube",f._texture=h,o.profile&&(f.stats=h.stats),f.destroy=function(){h.decRef()},f},clear:function(){for(var e=0;er;++r)if(0!=(e.mipmask&1<>r,e.height>>r,0,e.internalformat,e.type,null);else for(var n=0;6>n;++n)t.texImage2D(34069+n,r,e.internalformat,e.width>>r,e.height>>r,0,e.internalformat,e.type,null);I(e.texInfo,e.target)})}}}function A(t,e,r,n,i,a){function o(t,e,r){this.target=t,this.texture=e,this.renderbuffer=r;var n=t=0;e?(t=e.width,n=e.height):r&&(t=r.width,n=r.height),this.width=t,this.height=n}function s(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function l(t,e,r){t&&(t.texture?t.texture._texture.refCount+=1:t.renderbuffer._renderbuffer.refCount+=1)}function c(e,r){r&&(r.texture?t.framebufferTexture2D(36160,e,r.target,r.texture._texture.texture,0):t.framebufferRenderbuffer(36160,e,36161,r.renderbuffer._renderbuffer.renderbuffer))}function u(t){var e=3553,r=null,n=null,i=t;return"object"==typeof t&&(i=t.data,"target"in t&&(e=0|t.target)),"texture2d"===(t=i._reglType)?r=i:"textureCube"===t?r=i:"renderbuffer"===t&&(n=i,e=36161),new o(e,r,n)}function f(t,e,r,a,s){return r?((t=n.create2D({width:t,height:e,format:a,type:s}))._texture.refCount=0,new o(3553,t,null)):((t=i.create({width:t,height:e,format:a}))._renderbuffer.refCount=0,new o(36161,null,t))}function h(t){return t&&(t.texture||t.renderbuffer)}function p(t,e,r){t&&(t.texture?t.texture.resize(e,r):t.renderbuffer&&t.renderbuffer.resize(e,r),t.width=e,t.height=r)}function d(){this.id=k++,M[this.id]=this,this.framebuffer=t.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function g(t){t.colorAttachments.forEach(s),s(t.depthAttachment),s(t.stencilAttachment),s(t.depthStencilAttachment)}function v(e){t.deleteFramebuffer(e.framebuffer),e.framebuffer=null,a.framebufferCount--,delete M[e.id]}function m(e){var n;t.bindFramebuffer(36160,e.framebuffer);var i=e.colorAttachments;for(n=0;ni;++i){for(c=0;ct;++t)r[t].resize(n);return e.width=e.height=n,e},_reglType:"framebufferCube",destroy:function(){r.forEach(function(t){t.destroy()})}})},clear:function(){X(M).forEach(v)},restore:function(){x.cur=null,x.next=null,x.dirty=!0,X(M).forEach(function(e){e.framebuffer=t.createFramebuffer(),m(e)})}})}function T(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function S(t,e,r,n){function i(t,e,r,n){this.name=t,this.id=e,this.location=r,this.info=n}function a(t,e){for(var r=0;rt&&(t=e.stats.uniformsCount)}),t},r.getMaxAttributesCount=function(){var t=0;return h.forEach(function(e){e.stats.attributesCount>t&&(t=e.stats.attributesCount)}),t}),{clear:function(){var e=t.deleteShader.bind(t);X(c).forEach(e),c={},X(u).forEach(e),u={},h.forEach(function(e){t.deleteProgram(e.program)}),h.length=0,f={},r.shaderCount=0},program:function(t,e,n){var i=f[e];i||(i=f[e]={});var a=i[t];return a||(a=new s(e,t),r.shaderCount++,l(a),i[t]=a,h.push(a)),a},restore:function(){c={},u={};for(var t=0;t"+e+"?"+i+".constant["+e+"]:0;"}).join(""),"}}else{","if(",o,"(",i,".buffer)){",u,"=",s,".createStream(",34962,",",i,".buffer);","}else{",u,"=",s,".getBuffer(",i,".buffer);","}",f,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",u,".dtype;",l.normalized,"=!!",i,".normalized;"),n("size"),n("offset"),n("stride"),n("divisor"),r("}}"),r.exit("if(",l.isStream,"){",s,".destroyStream(",u,");","}"),l})}),o}function A(t,e,r,n,i){var o=_(t),s=function(t,e,r){function n(t){if(t in i){var r=i[t];t=!0;var n,o,s=0|r.x,l=0|r.y;return"width"in r?n=0|r.width:t=!1,"height"in r?o=0|r.height:t=!1,new P(!t&&e&&e.thisDep,!t&&e&&e.contextDep,!t&&e&&e.propDep,function(t,e){var i=t.shared.context,a=n;"width"in r||(a=e.def(i,".","framebufferWidth","-",s));var c=o;return"height"in r||(c=e.def(i,".","framebufferHeight","-",l)),[s,l,a,c]})}if(t in a){var c=a[t];return t=F(c,function(t,e){var r=t.invoke(e,c),n=t.shared.context,i=e.def(r,".x|0"),a=e.def(r,".y|0");return[i,a,e.def('"width" in ',r,"?",r,".width|0:","(",n,".","framebufferWidth","-",i,")"),r=e.def('"height" in ',r,"?",r,".height|0:","(",n,".","framebufferHeight","-",a,")")]}),e&&(t.thisDep=t.thisDep||e.thisDep,t.contextDep=t.contextDep||e.contextDep,t.propDep=t.propDep||e.propDep),t}return e?new P(e.thisDep,e.contextDep,e.propDep,function(t,e){var r=t.shared.context;return[0,0,e.def(r,".","framebufferWidth"),e.def(r,".","framebufferHeight")]}):null}var i=t.static,a=t.dynamic;if(t=n("viewport")){var o=t;t=new P(t.thisDep,t.contextDep,t.propDep,function(t,e){var r=o.append(t,e),n=t.shared.context;return e.set(n,".viewportWidth",r[2]),e.set(n,".viewportHeight",r[3]),r})}return{viewport:t,scissor_box:n("scissor.box")}}(t,o),l=k(t),c=function(t,e){var r=t.static,n=t.dynamic,i={};return nt.forEach(function(t){function e(e,a){if(t in r){var s=e(r[t]);i[o]=R(function(){return s})}else if(t in n){var l=n[t];i[o]=F(l,function(t,e){return a(t,e,t.invoke(e,l))})}}var o=m(t);switch(t){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":return e(function(t){return t},function(t,e,r){return r});case"depth.func":return e(function(t){return kt[t]},function(t,e,r){return e.def(t.constants.compareFuncs,"[",r,"]")});case"depth.range":return e(function(t){return t},function(t,e,r){return[e.def("+",r,"[0]"),e=e.def("+",r,"[1]")]});case"blend.func":return e(function(t){return[wt["srcRGB"in t?t.srcRGB:t.src],wt["dstRGB"in t?t.dstRGB:t.dst],wt["srcAlpha"in t?t.srcAlpha:t.src],wt["dstAlpha"in t?t.dstAlpha:t.dst]]},function(t,e,r){function n(t,n){return e.def('"',t,n,'" in ',r,"?",r,".",t,n,":",r,".",t)}t=t.constants.blendFuncs;var i=n("src","RGB"),a=n("dst","RGB"),o=(i=e.def(t,"[",i,"]"),e.def(t,"[",n("src","Alpha"),"]"));return[i,a=e.def(t,"[",a,"]"),o,t=e.def(t,"[",n("dst","Alpha"),"]")]});case"blend.equation":return e(function(t){return"string"==typeof t?[$[t],$[t]]:"object"==typeof t?[$[t.rgb],$[t.alpha]]:void 0},function(t,e,r){var n=t.constants.blendEquations,i=e.def(),a=e.def();return(t=t.cond("typeof ",r,'==="string"')).then(i,"=",a,"=",n,"[",r,"];"),t.else(i,"=",n,"[",r,".rgb];",a,"=",n,"[",r,".alpha];"),e(t),[i,a]});case"blend.color":return e(function(t){return a(4,function(e){return+t[e]})},function(t,e,r){return a(4,function(t){return e.def("+",r,"[",t,"]")})});case"stencil.mask":return e(function(t){return 0|t},function(t,e,r){return e.def(r,"|0")});case"stencil.func":return e(function(t){return[kt[t.cmp||"keep"],t.ref||0,"mask"in t?t.mask:-1]},function(t,e,r){return[t=e.def('"cmp" in ',r,"?",t.constants.compareFuncs,"[",r,".cmp]",":",7680),e.def(r,".ref|0"),e=e.def('"mask" in ',r,"?",r,".mask|0:-1")]});case"stencil.opFront":case"stencil.opBack":return e(function(e){return["stencil.opBack"===t?1029:1028,Mt[e.fail||"keep"],Mt[e.zfail||"keep"],Mt[e.zpass||"keep"]]},function(e,r,n){function i(t){return r.def('"',t,'" in ',n,"?",a,"[",n,".",t,"]:",7680)}var a=e.constants.stencilOps;return["stencil.opBack"===t?1029:1028,i("fail"),i("zfail"),i("zpass")]});case"polygonOffset.offset":return e(function(t){return[0|t.factor,0|t.units]},function(t,e,r){return[e.def(r,".factor|0"),e=e.def(r,".units|0")]});case"cull.face":return e(function(t){var e=0;return"front"===t?e=1028:"back"===t&&(e=1029),e},function(t,e,r){return e.def(r,'==="front"?',1028,":",1029)});case"lineWidth":return e(function(t){return t},function(t,e,r){return r});case"frontFace":return e(function(t){return At[t]},function(t,e,r){return e.def(r+'==="cw"?2304:2305')});case"colorMask":return e(function(t){return t.map(function(t){return!!t})},function(t,e,r){return a(4,function(t){return"!!"+r+"["+t+"]"})});case"sample.coverage":return e(function(t){return["value"in t?t.value:1,!!t.invert]},function(t,e,r){return[e.def('"value" in ',r,"?+",r,".value:1"),e=e.def("!!",r,".invert")]})}}),i}(t),u=w(t),f=s.viewport;return f&&(c.viewport=f),(s=s[f=m("scissor.box")])&&(c[f]=s),(o={framebuffer:o,draw:l,shader:u,state:c,dirty:s=0>1)",s],");")}function e(){r(l,".drawArraysInstancedANGLE(",[d,g,v,s],");")}p?y?t():(r("if(",p,"){"),t(),r("}else{"),e(),r("}")):e()}function o(){function t(){r(u+".drawElements("+[d,v,m,g+"<<(("+m+"-5121)>>1)"]+");")}function e(){r(u+".drawArrays("+[d,g,v]+");")}p?y?t():(r("if(",p,"){"),t(),r("}else{"),e(),r("}")):e()}var s,l,c=t.shared,u=c.gl,f=c.draw,h=n.draw,p=function(){var i=h.elements,a=e;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(t,a)):i=a.def(f,".","elements"),i&&a("if("+i+")"+u+".bindBuffer(34963,"+i+".buffer.buffer);"),i}(),d=i("primitive"),g=i("offset"),v=function(){var i=h.count,a=e;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(t,a)):i=a.def(f,".","count"),i}();if("number"==typeof v){if(0===v)return}else r("if(",v,"){"),r.exit("}");K&&(s=i("instances"),l=t.instancing);var m=p+".type",y=h.elements&&D(h.elements);K&&("number"!=typeof s||0<=s)?"string"==typeof s?(r("if(",s,">0){"),a(),r("}else if(",s,"<0){"),o(),r("}")):a():o()}function q(t,e,r,n,i){return i=(e=b()).proc("body",i),K&&(e.instancing=i.def(e.shared.extensions,".angle_instanced_arrays")),t(e,i,r,n),e.compile().body}function H(t,e,r,n){L(t,e),N(t,e,r,n.attributes,function(){return!0}),j(t,e,r,n.uniforms,function(){return!0}),V(t,e,e,r)}function G(t,e,r,n){function i(){return!0}t.batchId="a1",L(t,e),N(t,e,r,n.attributes,i),j(t,e,r,n.uniforms,i),V(t,e,e,r)}function W(t,e,r,n){function i(t){return t.contextDep&&o||t.propDep}function a(t){return!i(t)}L(t,e);var o=r.contextDep,s=e.def(),l=e.def();t.shared.props=l,t.batchId=s;var c=t.scope(),u=t.scope();e(c.entry,"for(",s,"=0;",s,"<","a1",";++",s,"){",l,"=","a0","[",s,"];",u,"}",c.exit),r.needsContext&&T(t,u,r.context),r.needsFramebuffer&&S(t,u,r.framebuffer),E(t,u,r.state,i),r.profile&&i(r.profile)&&B(t,u,r,!1,!0),n?(N(t,c,r,n.attributes,a),N(t,u,r,n.attributes,i),j(t,c,r,n.uniforms,a),j(t,u,r,n.uniforms,i),V(t,c,u,r)):(e=t.global.def("{}"),n=r.shader.progVar.append(t,u),l=u.def(n,".id"),c=u.def(e,"[",l,"]"),u(t.shared.gl,".useProgram(",n,".program);","if(!",c,"){",c,"=",e,"[",l,"]=",t.link(function(e){return q(G,t,r,e,2)}),"(",n,");}",c,".call(this,a0[",s,"],",s,");"))}function Y(t,r){function n(e){var n=r.shader[e];n&&i.set(a.shader,"."+e,n.append(t,i))}var i=t.proc("scope",3);t.batchId="a2";var a=t.shared,o=a.current;T(t,i,r.context),r.framebuffer&&r.framebuffer.append(t,i),I(Object.keys(r.state)).forEach(function(e){var n=r.state[e].append(t,i);v(n)?n.forEach(function(r,n){i.set(t.next[e],"["+n+"]",r)}):i.set(a.next,"."+e,n)}),B(t,i,r,!0,!0),["elements","offset","count","instances","primitive"].forEach(function(e){var n=r.draw[e];n&&i.set(a.draw,"."+e,""+n.append(t,i))}),Object.keys(r.uniforms).forEach(function(n){i.set(a.uniforms,"["+e.id(n)+"]",r.uniforms[n].append(t,i))}),Object.keys(r.attributes).forEach(function(e){var n=r.attributes[e].append(t,i),a=t.scopeAttrib(e);Object.keys(new Z).forEach(function(t){i.set(a,"."+t,n[t])})}),n("vert"),n("frag"),0=--this.refCount&&o(this)},i.profile&&(n.getTotalRenderbufferSize=function(){var t=0;return Object.keys(u).forEach(function(e){t+=u[e].stats.size}),t}),{create:function(e,r){function o(e,r){var n=0,a=0,u=32854;if("object"==typeof e&&e?("shape"in e?(n=0|(a=e.shape)[0],a=0|a[1]):("radius"in e&&(n=a=0|e.radius),"width"in e&&(n=0|e.width),"height"in e&&(a=0|e.height)),"format"in e&&(u=s[e.format])):"number"==typeof e?(n=0|e,a="number"==typeof r?0|r:n):e||(n=a=1),n!==c.width||a!==c.height||u!==c.format)return o.width=c.width=n,o.height=c.height=a,c.format=u,t.bindRenderbuffer(36161,c.renderbuffer),t.renderbufferStorage(36161,u,n,a),i.profile&&(c.stats.size=vt[c.format]*c.width*c.height),o.format=l[c.format],o}var c=new a(t.createRenderbuffer());return u[c.id]=c,n.renderbufferCount++,o(e,r),o.resize=function(e,r){var n=0|e,a=0|r||n;return n===c.width&&a===c.height?o:(o.width=c.width=n,o.height=c.height=a,t.bindRenderbuffer(36161,c.renderbuffer),t.renderbufferStorage(36161,c.format,n,a),i.profile&&(c.stats.size=vt[c.format]*c.width*c.height),o)},o._reglType="renderbuffer",o._renderbuffer=c,i.profile&&(o.stats=c.stats),o.destroy=function(){c.decRef()},o},clear:function(){X(u).forEach(o)},restore:function(){X(u).forEach(function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,e.renderbuffer),t.renderbufferStorage(36161,e.format,e.width,e.height)}),t.bindRenderbuffer(36161,null)}}},yt=[];yt[6408]=4,yt[6407]=3;var xt=[];xt[5121]=1,xt[5126]=4,xt[36193]=2;var bt=["x","y","z","w"],_t="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),wt={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},kt={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Mt={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},At={cw:2304,ccw:2305},Tt=new P(!1,!1,!1,function(){});return function(t){function e(){if(0===Z.length)w&&w.update(),Q=null;else{Q=q.next(e),f();for(var t=Z.length-1;0<=t;--t){var r=Z[t];r&&r(z,null,0)}v.flush(),w&&w.update()}}function r(){!Q&&0=Z.length&&n()}}}}function u(){var t=Y.viewport,e=Y.scissor_box;t[0]=t[1]=e[0]=e[1]=0,z.viewportWidth=z.framebufferWidth=z.drawingBufferWidth=t[2]=e[2]=v.drawingBufferWidth,z.viewportHeight=z.framebufferHeight=z.drawingBufferHeight=t[3]=e[3]=v.drawingBufferHeight}function f(){z.tick+=1,z.time=g(),u(),G.procs.poll()}function h(){u(),G.procs.refresh(),w&&w.update()}function g(){return(H()-k)/1e3}if(!(t=i(t)))return null;var v=t.gl,m=v.getContextAttributes();v.isContextLost();var y=function(t,e){function r(e){var r;e=e.toLowerCase();try{r=n[e]=t.getExtension(e)}catch(t){}return!!r}for(var n={},i=0;ie;++e)tt(j({framebuffer:t.framebuffer.faces[e]},t),l);else tt(t,l);else l(0,t)},prop:U.define.bind(null,1),context:U.define.bind(null,2),this:U.define.bind(null,3),draw:s({}),buffer:function(t){return I.create(t,34962,!1,!1)},elements:function(t){return P.create(t,!1)},texture:R.create2D,cube:R.createCube,renderbuffer:F.create,framebuffer:V.create,framebufferCube:V.createCube,attributes:m,frame:c,on:function(t,e){var r;switch(t){case"frame":return c(e);case"lost":r=$;break;case"restore":r=J;break;case"destroy":r=K}return r.push(e),{cancel:function(){for(var t=0;t=r)return i.substr(0,r);for(;r>i.length&&e>1;)1&e&&(i+=t),e>>=1,t+=t;return i=(i+=t).substr(0,r)}},{}],480:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],481:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i],s=(r=a+o)-a,l=o-s;l&&(t[--n]=r,r=l)}for(var c=0,i=n;i>1;return["sum(",t(e.slice(0,r)),",",t(e.slice(r)),")"].join("")}(e);var n}function u(t){return new Function("sum","scale","prod","compress",["function robustDeterminant",t,"(m){return compress(",c(function(t){for(var e=new Array(t),r=0;r>1;return["sum(",c(t.slice(0,e)),",",c(t.slice(e)),")"].join("")}function u(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return u(e,t)}function f(t){if(2===t.length)return[["diff(",u(t[0][0],t[1][1]),",",u(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r0&&r.push(","),r.push("[");for(var o=0;o0&&r.push(","),o===i?r.push("+b[",a,"]"):r.push("+A[",a,"][",o,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var s=new Function("det",r.join(""));return s(t<6?n[t]:n)}var o=[function(){return[0]},function(t,e){return[[e[0]],[t[0][0]]]}];!function(){for(;o.length>1;return["sum(",c(t.slice(0,e)),",",c(t.slice(e)),")"].join("")}function u(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(a<=0)return o;n=i+a}else{if(!(i<0))return o;if(a>=0)return o;n=-(i+a)}var s=3.3306690738754716e-16*n;return o>=s||o<=-s?o:h(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*c,g=o*l,v=o*s,m=i*c,y=i*l,x=a*s,b=u*(d-g)+f*(v-m)+h*(y-x),_=7.771561172376103e-16*((Math.abs(d)+Math.abs(g))*Math.abs(u)+(Math.abs(v)+Math.abs(m))*Math.abs(f)+(Math.abs(y)+Math.abs(x))*Math.abs(h));return b>_||-b>_?b:p(t,e,r,n)}];!function(){for(;d.length<=s;)d.push(f(d.length));for(var t=[],r=["slow"],n=0;n<=s;++n)t.push("a"+n),r.push("o"+n);var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(n=2;n<=s;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i0&&o>0||a<0&&o<0)return!1;var s=n(r,t,e),l=n(i,t,e);if(s>0&&l>0||s<0&&l<0)return!1;if(0===a&&0===o&&0===s&&0===l)return function(t,e,r,n){for(var i=0;i<2;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],f=Math.min(c,u),h=Math.max(c,u);if(h=n?(i=f,(l+=1)=n?(i=f,(l+=1)0?1:0}},{}],493:[function(t,e,r){"use strict";e.exports=function(t){return i(n(t))};var n=t("boundary-cells"),i=t("reduce-simplicial-complex")},{"boundary-cells":83,"reduce-simplicial-complex":472}],494:[function(t,e,r){"use strict";e.exports=function(t,e,r,s){r=r||0,"undefined"==typeof s&&(s=function(t){for(var e=t.length,r=0,n=0;n>1,v=E[2*m+1];","if(v===b){return m}","if(b0&&l.push(","),l.push("[");for(var n=0;n0&&l.push(","),l.push("B(C,E,c[",i[0],"],c[",i[1],"])")}l.push("]")}l.push(");")}}for(var a=t+1;a>1;--a){a>1,s=a(t[o],e);s<=0?(0===s&&(i=o),r=o+1):s>0&&(n=o-1)}return i}function u(t,e){for(var r=new Array(t.length),i=0,o=r.length;i=t.length||0!==a(t[v],s)););}return r}function f(t,e){if(e<0)return[];for(var r=[],i=(1<>>u&1&&c.push(i[u]);e.push(c)}return s(e)},r.skeleton=f,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function x(t){for(var e=m(t);;){var r=e,n=2*t+1,i=2*(t+1),a=t;if(n0;){var r=y(t);if(r>=0){var n=m(r);if(e0){var t=M[0];return v(0,S-1),S-=1,x(0),t}return-1}function w(t,e){var r=M[t];return c[r]===e?t:(c[r]=-1/0,b(t),_(),c[r]=e,b((S+=1)-1))}function k(t){if(!u[t]){u[t]=!0;var e=s[t],r=l[t];s[r]>=0&&(s[r]=e),l[e]>=0&&(l[e]=r),A[e]>=0&&w(A[e],g(e)),A[r]>=0&&w(A[r],g(r))}}for(var M=[],A=new Array(a),f=0;f>1;f>=0;--f)x(f);for(;;){var C=_();if(C<0||c[C]>r)break;k(C)}for(var E=[],f=0;f=0&&r>=0&&e!==r){var n=A[e],i=A[r];n!==i&&z.push([n,i])}}),i.unique(i.normalize(z)),{positions:E,edges:z}};var n=t("robust-orientation"),i=t("simplicial-complex")},{"robust-orientation":486,"simplicial-complex":498}],501:[function(t,e,r){"use strict";e.exports=function(t,e){var r,a,o,s;if(e[0][0]e[1][0]))return i(e,t);r=e[1],a=e[0]}if(t[0][0]t[1][0]))return-i(t,e);o=t[1],s=t[0]}var l=n(r,a,s),c=n(r,a,o);if(l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=n(s,o,a),c=n(s,o,r),l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return a[0]-s[0]};var n=t("robust-orientation");function i(t,e){var r,i,a,o;if(e[0][0]e[1][0])){var s=Math.min(t[0][1],t[1][1]),l=Math.max(t[0][1],t[1][1]),c=Math.min(e[0][1],e[1][1]),u=Math.max(e[0][1],e[1][1]);return lu?s-u:l-u}r=e[1],i=e[0]}t[0][1]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=c(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=c(t.right,e))return l;t=t.left}}return r}function u(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function f(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}s.prototype.castUp=function(t){var e=n.le(this.coordinates,t[0]);if(e<0)return-1;this.slabs[e];var r=c(this.slabs[e],t),i=-1;if(r&&(i=r.value),this.coordinates[e]===t[0]){var s=null;if(r&&(s=r.key),e>0){var u=c(this.slabs[e-1],t);u&&(s?o(u.key,s)>0&&(s=u.key,i=u.value):(i=u.value,s=u.key))}var f=this.horizontal[e];if(f.length>0){var h=n.ge(f,t[1],l);if(h=f.length)return i;p=f[h]}}if(p.start)if(s){var d=a(s[0],s[1],[t[0],p.y]);s[0][0]>s[1][0]&&(d=-d),d>0&&(i=p.index)}else i=p.index;else p.y!==t[1]&&(i=p.index)}}}return i}},{"./lib/order-segments":501,"binary-search-bounds":79,"functional-red-black-tree":219,"robust-orientation":486}],503:[function(t,e,r){"use strict";var n=t("robust-dot-product"),i=t("robust-sum");function a(t,e){var r=i(n(t,e),[e[e.length-1]]);return r[r.length-1]}function o(t,e,r,n){var i=-e/(n-e);i<0?i=0:i>1&&(i=1);for(var a=1-i,o=t.length,s=new Array(o),l=0;l0||i>0&&u<0){var f=o(s,u,l,i);r.push(f),n.push(f.slice())}u<0?n.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),n.push(l.slice())),i=u}return{positive:r,negative:n}},e.exports.positive=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c>=0&&r.push(s.slice()),n=c}return r},e.exports.negative=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c<=0&&r.push(s.slice()),n=c}return r}},{"robust-dot-product":483,"robust-sum":491}],504:[function(t,e,r){!function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function e(r){return function(r,n){var i,a,o,s,l,c,u,f,h,p=1,d=r.length,g="";for(a=0;a=0),s[8]){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,s[6]?parseInt(s[6]):0);break;case"e":i=s[7]?parseFloat(i).toExponential(s[7]):parseFloat(i).toExponential();break;case"f":i=s[7]?parseFloat(i).toFixed(s[7]):parseFloat(i);break;case"g":i=s[7]?String(Number(i.toPrecision(s[7]))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=s[7]?i.substring(0,s[7]):i;break;case"t":i=String(!!i),i=s[7]?i.substring(0,s[7]):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=s[7]?i.substring(0,s[7]):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=s[7]?i.substring(0,s[7]):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}t.json.test(s[8])?g+=i:(!t.number.test(s[8])||f&&!s[3]?h="":(h=f?"+":"-",i=i.toString().replace(t.sign,"")),c=s[4]?"0"===s[4]?"0":s[4].charAt(1):" ",u=s[6]-(h+i).length,l=s[6]&&u>0?c.repeat(u):"",g+=s[5]?h+i+l:"0"===c?h+l+i:l+h+i)}return g}(function(e){if(i[e])return i[e];var r,n=e,a=[],o=0;for(;n;){if(null!==(r=t.text.exec(n)))a.push(r[0]);else if(null!==(r=t.modulo.exec(n)))a.push("%");else{if(null===(r=t.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){o|=1;var s=[],l=r[2],c=[];if(null===(c=t.key.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(c[1]);""!==(l=l.substring(c[0].length));)if(null!==(c=t.key_access.exec(l)))s.push(c[1]);else{if(null===(c=t.index_access.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(c[1])}r[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");a.push(r)}n=n.substring(r[0].length)}return i[e]=a}(r),arguments)}function n(t,r){return e.apply(null,[t].concat(r||[]))}var i=Object.create(null);"undefined"!=typeof r&&(r.sprintf=e,r.vsprintf=n),"undefined"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}()},{}],505:[function(t,e,r){"use strict";var n=t("parenthesis");e.exports=function(t,e,r){if(null==t)throw Error("First argument should be a string");if(null==e)throw Error("Separator should be a string or a RegExp");r?("string"==typeof r||Array.isArray(r))&&(r={ignore:r}):r={},null==r.escape&&(r.escape=!0),null==r.ignore?r.ignore=["[]","()","{}","<>",'""',"''","``","\u201c\u201d","\xab\xbb"]:("string"==typeof r.ignore&&(r.ignore=[r.ignore]),r.ignore=r.ignore.map(function(t){return 1===t.length&&(t+=t),t}));var i=n.parse(t,{flat:!0,brackets:r.ignore}),a=i[0].split(e);if(r.escape){for(var o=[],s=0;s0;){e=c[c.length-1];var p=t[e];if(a[e]=0&&s[e].push(o[g])}a[e]=d}else{if(n[e]===r[e]){for(var v=[],m=[],y=0,d=l.length-1;d>=0;--d){var x=l[d];if(i[x]=!1,v.push(x),m.push(s[x]),y+=s[x].length,o[x]=f.length,x===e){l.length=d;break}}f.push(v);for(var b=new Array(y),d=0;d c)|0 },"),"generic"===e&&a.push("getters:[0],");for(var s=[],l=[],c=0;c>>7){");for(var c=0;c<1<<(1<128&&c%128==0){f.length>0&&h.push("}}");var p="vExtra"+f.length;a.push("case ",c>>>7,":",p,"(m&0x7f,",l.join(),");break;"),h=["function ",p,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&c,":");for(var d=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,x=0;xx)&&!(c&1<<_)!=!(c&1<0&&(A="+"+v[b]+"*c");var T=d[b].length/y*.5,S=.5+m[b]/y*.5;M.push("d"+b+"-"+S+"-"+T+"*("+d[b].join("+")+A+")/("+g[b].join("+")+")")}h.push("a.push([",M.join(),"]);","break;")}a.push("}},"),f.length>0&&h.push("}}");for(var C=[],c=0;c<1<1&&(a=1),a<-1&&(a=-1),i*Math.acos(a)};r.default=function(t){var e=t.px,r=t.py,l=t.cx,c=t.cy,u=t.rx,f=t.ry,h=t.xAxisRotation,p=void 0===h?0:h,d=t.largeArcFlag,g=void 0===d?0:d,v=t.sweepFlag,m=void 0===v?0:v,y=[];if(0===u||0===f)return[];var x=Math.sin(p*i/360),b=Math.cos(p*i/360),_=b*(e-l)/2+x*(r-c)/2,w=-x*(e-l)/2+b*(r-c)/2;if(0===_&&0===w)return[];u=Math.abs(u),f=Math.abs(f);var k=Math.pow(_,2)/Math.pow(u,2)+Math.pow(w,2)/Math.pow(f,2);k>1&&(u*=Math.sqrt(k),f*=Math.sqrt(k));var M=function(t,e,r,n,a,o,l,c,u,f,h,p){var d=Math.pow(a,2),g=Math.pow(o,2),v=Math.pow(h,2),m=Math.pow(p,2),y=d*g-d*m-g*v;y<0&&(y=0),y/=d*m+g*v;var x=(y=Math.sqrt(y)*(l===c?-1:1))*a/o*p,b=y*-o/a*h,_=f*x-u*b+(t+r)/2,w=u*x+f*b+(e+n)/2,k=(h-x)/a,M=(p-b)/o,A=(-h-x)/a,T=(-p-b)/o,S=s(1,0,k,M),C=s(k,M,A,T);return 0===c&&C>0&&(C-=i),1===c&&C<0&&(C+=i),[_,w,S,C]}(e,r,l,c,u,f,g,m,x,b,_,w),A=n(M,4),T=A[0],S=A[1],C=A[2],E=A[3],L=Math.abs(E)/(i/4);Math.abs(1-L)<1e-7&&(L=1);var z=Math.max(Math.ceil(L),1);E/=z;for(var O=0;Oe[2]&&(e[2]=c[u+0]),c[u+1]>e[3]&&(e[3]=c[u+1]);return e}},{"abs-svg-path":48,assert:56,"is-svg-path":407,"normalize-svg-path":510,"parse-svg-path":443}],510:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=[],o=0,s=0,l=0,c=0,u=null,f=null,h=0,p=0,d=0,g=t.length;d4?(o=v[v.length-4],s=v[v.length-3]):(o=h,s=p),r.push(v)}return r};var n=t("svg-arc-to-cubic-bezier");function i(t,e,r,n){return["C",t,e,r,n,r,n]}function a(t,e,r,n,i,a){return["C",t/3+2/3*r,e/3+2/3*n,i/3+2/3*r,a/3+2/3*n,i,a]}},{"svg-arc-to-cubic-bezier":508}],511:[function(t,e,r){"use strict";var n,i=t("svg-path-bounds"),a=t("parse-svg-path"),o=t("draw-svg-path"),s=t("is-svg-path"),l=t("bitmap-sdf"),c=document.createElement("canvas"),u=c.getContext("2d");e.exports=function(t,e){if(!s(t))throw Error("Argument should be valid svg path string");e||(e={});var r,f;e.shape?(r=e.shape[0],f=e.shape[1]):(r=c.width=e.w||e.width||200,f=c.height=e.h||e.height||200);var h=Math.min(r,f),p=e.stroke||0,d=e.viewbox||e.viewBox||i(t),g=[r/(d[2]-d[0]),f/(d[3]-d[1])],v=Math.min(g[0]||0,g[1]||0)/2;u.fillStyle="black",u.fillRect(0,0,r,f),u.fillStyle="white",p&&("number"!=typeof p&&(p=1),u.strokeStyle=p>0?"white":"black",u.lineWidth=Math.abs(p));if(u.translate(.5*r,.5*f),u.scale(v,v),function(){if(null!=n)return n;var t=document.createElement("canvas").getContext("2d");if(t.canvas.width=t.canvas.height=1,!window.Path2D)return n=!1;var e=new Path2D("M0,0h1v1h-1v-1Z");t.fillStyle="black",t.fill(e);var r=t.getImageData(0,0,1,1);return n=r&&r.data&&255===r.data[3]}()){var m=new Path2D(t);u.fill(m),p&&u.stroke(m)}else{var y=a(t);o(u,y),u.fill(),p&&u.stroke()}return u.setTransform(1,0,0,1,0,0),l(u,{cutoff:null!=e.cutoff?e.cutoff:.5,radius:null!=e.radius?e.radius:.5*h})}},{"bitmap-sdf":81,"draw-svg-path":153,"is-svg-path":407,"parse-svg-path":443,"svg-path-bounds":509}],512:[function(t,e,r){(function(r){"use strict";e.exports=function t(e,r,i){var i=i||{};var o=a[e];o||(o=a[e]={" ":{data:new Float32Array(0),shape:.2}});var s=o[r];if(!s)if(r.length<=1||!/\d/.test(r))s=o[r]=function(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;o0&&(f+=.02);for(var p=new Float32Array(u),d=0,g=-.5*f,h=0;h1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=L(t,360),e=L(e,100),r=L(r,100),0===e)n=i=a=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;n=o(l,s,t+1/3),i=o(l,s,t),a=o(l,s,t-1/3)}return{r:255*n,g:255*i,b:255*a}}(e.h,l,u),f=!0,h="hsl"),e.hasOwnProperty("a")&&(a=e.a));var p,d,g;return a=E(a),{ok:f,format:e.format||h,r:o(255,s(i.r,0)),g:o(255,s(i.g,0)),b:o(255,s(i.b,0)),a:a}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=a(100*this._a)/100,this._format=l.format||u.format,this._gradientType=l.gradientType,this._r<1&&(this._r=a(this._r)),this._g<1&&(this._g=a(this._g)),this._b<1&&(this._b=a(this._b)),this._ok=u.ok,this._tc_id=i++}function u(t,e,r){t=L(t,255),e=L(e,255),r=L(r,255);var n,i,a=s(t,e,r),l=o(t,e,r),c=(a+l)/2;if(a==l)n=i=0;else{var u=a-l;switch(i=c>.5?u/(2-a-l):u/(a+l),a){case t:n=(e-r)/u+(e>1)+720)%360;--e;)n.h=(n.h+i)%360,a.push(c(n));return a}function T(t,e){e=e||6;for(var r=c(t).toHsv(),n=r.h,i=r.s,a=r.v,o=[],s=1/e;e--;)o.push(c({h:n,s:i,v:a})),a=(a+s)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,i=this.toRgb();return e=i.r/255,r=i.g/255,n=i.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=E(t),this._roundA=a(100*this._a)/100,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return h(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,i){var o=[I(a(t).toString(16)),I(a(e).toString(16)),I(a(r).toString(16)),I(D(n))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:a(this._r),g:a(this._g),b:a(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+a(this._r)+", "+a(this._g)+", "+a(this._b)+")":"rgba("+a(this._r)+", "+a(this._g)+", "+a(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:a(100*L(this._r,255))+"%",g:a(100*L(this._g,255))+"%",b:a(100*L(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+a(100*L(this._r,255))+"%, "+a(100*L(this._g,255))+"%, "+a(100*L(this._b,255))+"%)":"rgba("+a(100*L(this._r,255))+"%, "+a(100*L(this._g,255))+"%, "+a(100*L(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(C[h(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var i=c(t);r="#"+p(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(m,arguments)},brighten:function(){return this._applyModification(y,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(A,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(T,arguments)},splitcomplement:function(){return this._applyCombination(M,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:P(t[n]));t=r}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:l(),g:l(),b:l()})},c.mix=function(t,e,r){r=0===r?0:r||50;var n=c(t).toRgb(),i=c(e).toRgb(),a=r/100;return c({r:(i.r-n.r)*a+n.r,g:(i.g-n.g)*a+n.g,b:(i.b-n.b)*a+n.b,a:(i.a-n.a)*a+n.a})},c.readability=function(e,r){var n=c(e),i=c(r);return(t.max(n.getLuminance(),i.getLuminance())+.05)/(t.min(n.getLuminance(),i.getLuminance())+.05)},c.isReadable=function(t,e,r){var n,i,a=c.readability(t,e);switch(i=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},c.mostReadable=function(t,e,r){var n,i,a,o,s=null,l=0;i=(r=r||{}).includeFallbackColors,a=r.level,o=r.size;for(var u=0;ul&&(l=n,s=c(e[u]));return c.isReadable(t,s,{level:a,size:o})||!i?s:(r.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],r))};var S=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},C=c.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(S);function E(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function L(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,s(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function z(t){return o(1,s(0,t))}function O(t){return parseInt(t,16)}function I(t){return 1==t.length?"0"+t:""+t}function P(t){return t<=1&&(t=100*t+"%"),t}function D(e){return t.round(255*parseFloat(e)).toString(16)}function R(t){return O(t)/255}var F,B,N,j=(B="[\\s|\\(]+("+(F="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",N="[\\s|\\(]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",{CSS_UNIT:new RegExp(F),rgb:new RegExp("rgb"+B),rgba:new RegExp("rgba"+N),hsl:new RegExp("hsl"+B),hsla:new RegExp("hsla"+N),hsv:new RegExp("hsv"+B),hsva:new RegExp("hsva"+N),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function V(t){return!!j.CSS_UNIT.exec(t)}"undefined"!=typeof e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],514:[function(t,e,r){"use strict";function n(t){if(t instanceof Float32Array)return t;if("number"==typeof t)return new Float32Array([t])[0];var e=new Float32Array(t);return e.set(t),e}e.exports=n,e.exports.float32=e.exports.float=n,e.exports.fract32=e.exports.fract=function(t){if("number"==typeof t)return n(t-n(t));for(var e=n(t),r=0,i=e.length;rf&&(f=l[0]),l[1]h&&(h=l[1])}function i(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(i);break;case"Point":n(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(n)}}if(!e){var a,o,s=r(t),l=new Array(2),c=1/0,u=c,f=-c,h=-c;for(o in t.arcs.forEach(function(t){for(var e=-1,r=t.length;++ef&&(f=l[0]),l[1]h&&(h=l[1])}),t.objects)i(t.objects[o]);e=t.bbox=[c,u,f,h]}return e},i=function(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r};function a(t,e){var r=e.id,n=e.bbox,i=null==e.properties?{}:e.properties,a=o(t,e);return null==r&&null==n?{type:"Feature",properties:i,geometry:a}:null==n?{type:"Feature",id:r,properties:i,geometry:a}:{type:"Feature",id:r,bbox:n,properties:i,geometry:a}}function o(t,e){var n=r(t),a=t.arcs;function o(t,e){e.length&&e.pop();for(var r=a[t<0?~t:t],o=0,s=r.length;o1)n=function(t,e,r){var n,i=[],a=[];function o(t){var e=t<0?~t:t;(a[e]||(a[e]=[])).push({i:t,g:n})}function s(t){t.forEach(o)}function l(t){t.forEach(s)}return function t(e){switch(n=e,e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"LineString":s(e.arcs);break;case"MultiLineString":case"Polygon":l(e.arcs);break;case"MultiPolygon":e.arcs.forEach(l)}}(e),a.forEach(null==r?function(t){i.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&i.push(t[0].i)}),i}(0,e,r);else for(i=0,n=new Array(a=t.arcs.length);i1)for(var a,o,c=1,u=l(i[0]);cu&&(o=i[0],i[0]=i[c],i[c]=o,u=a);return i})}}var u=function(t,e){for(var r=0,n=t.length;r>>1;t[i]=2))throw new Error("n must be \u22652");if(t.transform)throw new Error("already quantized");var r,i=n(t),a=i[0],o=(i[2]-a)/(e-1)||1,s=i[1],l=(i[3]-s)/(e-1)||1;function c(t){t[0]=Math.round((t[0]-a)/o),t[1]=Math.round((t[1]-s)/l)}function u(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(u);break;case"Point":c(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(c)}}for(r in t.arcs.forEach(function(t){for(var e,r,n,i=1,c=1,u=t.length,f=t[0],h=f[0]=Math.round((f[0]-a)/o),p=f[1]=Math.round((f[1]-s)/l);iMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,l=0;l<3;++l)a+=t[l]*t[l],o+=i[l]*t[l];for(l=0;l<3;++l)i[l]-=o/a*t[l];return s(i,i),i}function h(t,e,r,i,a,o,s,l){this.center=n(r),this.up=n(i),this.right=n(a),this.radius=n([o]),this.angle=n([s,l]),this.angle.bounds=[[-1/0,-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;c<16;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}var p=h.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,n=0,i=0,a=0;a<3;++a)i+=e[a]*r[a],n+=e[a]*e[a];var l=Math.sqrt(n),u=0;for(a=0;a<3;++a)r[a]-=e[a]*i/n,u+=r[a]*r[a],e[a]/=l;var f=Math.sqrt(u);for(a=0;a<3;++a)r[a]/=f;var h=this.computedToward;o(h,e,r),s(h,h);var p=Math.exp(this.computedRadius[0]),d=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(d),m=Math.sin(d),y=Math.cos(g),x=Math.sin(g),b=this.computedCenter,_=v*y,w=m*y,k=x,M=-v*x,A=-m*x,T=y,S=this.computedEye,C=this.computedMatrix;for(a=0;a<3;++a){var E=_*r[a]+w*h[a]+k*e[a];C[4*a+1]=M*r[a]+A*h[a]+T*e[a],C[4*a+2]=E,C[4*a+3]=0}var L=C[1],z=C[5],O=C[9],I=C[2],P=C[6],D=C[10],R=z*D-O*P,F=O*I-L*D,B=L*P-z*I,N=c(R,F,B);R/=N,F/=N,B/=N,C[0]=R,C[4]=F,C[8]=B;for(a=0;a<3;++a)S[a]=b[a]+C[2+4*a]*p;for(a=0;a<3;++a){u=0;for(var j=0;j<3;++j)u+=C[a+4*j]*S[j];C[12+a]=-u}C[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r};var d=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;d[0]=i[2],d[1]=i[6],d[2]=i[10];for(var o=this.computedUp,s=this.computedRight,l=this.computedToward,c=0;c<3;++c)i[4*c]=o[c],i[4*c+1]=s[c],i[4*c+2]=l[c];a(i,i,n,d);for(c=0;c<3;++c)o[c]=i[4*c],s[c]=i[4*c+1];this.up.set(t,o[0],o[1],o[2]),this.right.set(t,s[0],s[1],s[2])}},p.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=(Math.exp(this.computedRadius[0]),i[1]),o=i[5],s=i[9],l=c(a,o,s);a/=l,o/=l,s/=l;var u=i[0],f=i[4],h=i[8],p=u*a+f*o+h*s,d=c(u-=a*p,f-=o*p,h-=s*p),g=(u/=d)*e+a*r,v=(f/=d)*e+o*r,m=(h/=d)*e+s*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+n),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,n){var a=1;"number"==typeof r&&(a=0|r),(a<0||a>3)&&(a=1);var o=(a+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var s=e[a],l=e[a+4],f=e[a+8];if(n){var h=Math.abs(s),p=Math.abs(l),d=Math.abs(f),g=Math.max(h,p,d);h===g?(s=s<0?-1:1,l=f=0):d===g?(f=f<0?-1:1,s=l=0):(l=l<0?-1:1,s=f=0)}else{var v=c(s,l,f);s/=v,l/=v,f/=v}var m,y,x=e[o],b=e[o+4],_=e[o+8],w=x*s+b*l+_*f,k=c(x-=s*w,b-=l*w,_-=f*w),M=l*(_/=k)-f*(b/=k),A=f*(x/=k)-s*_,T=s*b-l*x,S=c(M,A,T);if(M/=S,A/=S,T/=S,this.center.jump(t,H,G,W),this.radius.idle(t),this.up.jump(t,s,l,f),this.right.jump(t,x,b,_),2===a){var C=e[1],E=e[5],L=e[9],z=C*x+E*b+L*_,O=C*M+E*A+L*T;m=R<0?-Math.PI/2:Math.PI/2,y=Math.atan2(O,z)}else{var I=e[2],P=e[6],D=e[10],R=I*s+P*l+D*f,F=I*x+P*b+D*_,B=I*M+P*A+D*T;m=Math.asin(u(R)),y=Math.atan2(B,F)}this.angle.jump(t,y,m),this.recalcMatrix(t);var N=e[2],j=e[6],V=e[10],U=this.computedMatrix;i(U,e);var q=U[15],H=U[12]/q,G=U[13]/q,W=U[14]/q,Y=Math.exp(this.computedRadius[0]);this.center.jump(t,H-N*Y,G-j*Y,W-V*Y)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter;var i=(n=n||this.computedUp)[0],a=n[1],o=n[2],s=c(i,a,o);if(!(s<1e-6)){i/=s,a/=s,o/=s;var l=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],p=c(l,f,h);if(!(p<1e-6)){l/=p,f/=p,h/=p;var d=this.computedRight,g=d[0],v=d[1],m=d[2],y=i*g+a*v+o*m,x=c(g-=y*i,v-=y*a,m-=y*o);if(!(x<.01&&(x=c(g=a*h-o*f,v=o*l-i*h,m=i*f-a*l))<1e-6)){g/=x,v/=x,m/=x,this.up.set(t,i,a,o),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(p));var b=a*m-o*v,_=o*g-i*m,w=i*v-a*g,k=c(b,_,w),M=i*l+a*f+o*h,A=g*l+v*f+m*h,T=(b/=k)*l+(_/=k)*f+(w/=k)*h,S=Math.asin(u(M)),C=Math.atan2(T,A),E=this.angle._state,L=E[E.length-1],z=E[E.length-2];L%=2*Math.PI;var O=Math.abs(L+2*Math.PI-C),I=Math.abs(L-C),P=Math.abs(L-2*Math.PI-C);O0?r.pop():new ArrayBuffer(t)}function h(t){return new Uint8Array(f(t),0,t)}function p(t){return new Uint16Array(f(2*t),0,t)}function d(t){return new Uint32Array(f(4*t),0,t)}function g(t){return new Int8Array(f(t),0,t)}function v(t){return new Int16Array(f(2*t),0,t)}function m(t){return new Int32Array(f(4*t),0,t)}function y(t){return new Float32Array(f(4*t),0,t)}function x(t){return new Float64Array(f(8*t),0,t)}function b(t){return o?new Uint8ClampedArray(f(t),0,t):h(t)}function _(t){return new DataView(f(t),0,t)}function w(t){t=i.nextPow2(t);var e=i.log2(t),r=c[e];return r.length>0?r.pop():new n(t)}r.free=function(t){if(n.isBuffer(t))c[i.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|i.log2(e);l[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=function(t){u(t.buffer)},r.freeArrayBuffer=u,r.freeBuffer=function(t){c[i.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return f(t);switch(e){case"uint8":return h(t);case"uint16":return p(t);case"uint32":return d(t);case"int8":return g(t);case"int16":return v(t);case"int32":return m(t);case"float":case"float32":return y(t);case"double":case"float64":return x(t);case"uint8_clamped":return b(t);case"buffer":return w(t);case"data":case"dataview":return _(t);default:return null}return null},r.mallocArrayBuffer=f,r.mallocUint8=h,r.mallocUint16=p,r.mallocUint32=d,r.mallocInt8=g,r.mallocInt16=v,r.mallocInt32=m,r.mallocFloat32=r.mallocFloat=y,r.mallocFloat64=r.mallocDouble=x,r.mallocUint8Clamped=b,r.mallocDataView=_,r.mallocBuffer=w,r.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,l[t].length=0,c[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":80,buffer:93,dup:155}],522:[function(t,e,r){"use strict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e0&&(a=n.size),n.lineSpacing&&n.lineSpacing>0&&(o=n.lineSpacing),n.styletags&&n.styletags.breaklines&&(s.breaklines=!!n.styletags.breaklines),n.styletags&&n.styletags.bolds&&(s.bolds=!!n.styletags.bolds),n.styletags&&n.styletags.italics&&(s.italics=!!n.styletags.italics),n.styletags&&n.styletags.subscripts&&(s.subscripts=!!n.styletags.subscripts),n.styletags&&n.styletags.superscripts&&(s.superscripts=!!n.styletags.superscripts));return r.font=[n.fontStyle,n.fontVariant,n.fontWeight,a+"px",n.font].filter(function(t){return t}).join(" "),r.textAlign="start",r.textBaseline="alphabetic",r.direction="ltr",w(function(t,e,r,n,a,o){r=r.replace(/\n/g,""),r=!0===o.breaklines?r.replace(/\/g,"\n"):r.replace(/\/g," ");var s="",l=[];for(k=0;k-1?parseInt(t[1+a]):0,c=s>-1?parseInt(r[1+s]):0;l!==c&&(i=i.replace(n(),"?px "),T*=Math.pow(.75,c-l),i=i.replace("?px ",n())),A+=.25*E*(c-l)}if(!0===o.superscripts){var f=t.indexOf(d),p=r.indexOf(d),g=f>-1?parseInt(t[1+f]):0,v=p>-1?parseInt(r[1+p]):0;g!==v&&(i=i.replace(n(),"?px "),T*=Math.pow(.75,v-g),i=i.replace("?px ",n())),A-=.25*E*(v-g)}if(!0===o.bolds){var y=t.indexOf(u)>-1,x=r.indexOf(u)>-1;!y&&x&&(i=b?i.replace("italic ","italic bold "):"bold "+i),y&&!x&&(i=i.replace("bold ",""))}if(!0===o.italics){var b=t.indexOf(h)>-1,_=r.indexOf(h)>-1;!b&&_&&(i="italic "+i),b&&!_&&(i=i.replace("italic ",""))}e.font=i}for(k=0;k",a="",o=i.length,s=a.length,l=e[0]===d||e[0]===m,c=0,u=-s;c>-1&&-1!==(c=r.indexOf(i,c))&&-1!==(u=r.indexOf(a,c+o))&&!(u<=c);){for(var f=c;f=u)n[f]=null,r=r.substr(0,f)+" "+r.substr(f+1);else if(null!==n[f]){var h=n[f].indexOf(e[0]);-1===h?n[f]+=e:l&&(n[f]=n[f].substr(0,h+1)+(1+parseInt(n[f][h+1]))+n[f].substr(h+2))}var p=c+o,g=r.substr(p,u-p).indexOf(i);c=-1!==g?g:u+s}return n}function b(t,e){var r=n(t,128);return e?a(r.cells,r.positions,.25):{edges:r.cells,positions:r.positions}}function _(t,e,r,n){var i=b(t,n),a=function(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;l=0?e[a]:i})},has___:{value:x(function(e){var n=y(e);return n?r in n:t.indexOf(e)>=0})},set___:{value:x(function(n,i){var a,o=y(n);return o?o[r]=i:(a=t.indexOf(n))>=0?e[a]=i:(a=t.length,e[a]=i,t[a]=n),this})},delete___:{value:x(function(n){var i,a,o=y(n);return o?r in o&&delete o[r]:!((i=t.indexOf(n))<0||(a=t.length-1,t[i]=void 0,e[i]=e[a],t[i]=t[a],t.length=a,e.length=a,0))})}})};g.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},delete:{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof r?function(){function n(){this instanceof g||b();var e,n=new r,i=void 0,a=!1;return e=t?function(t,e){return n.set(t,e),n.has(t)||(i||(i=new g),i.set(t,e)),this}:function(t,e){if(a)try{n.set(t,e)}catch(r){i||(i=new g),i.set___(t,e)}else n.set(t,e);return this},Object.create(g.prototype,{get___:{value:x(function(t,e){return i?n.has(t)?n.get(t):i.get___(t,e):n.get(t,e)})},has___:{value:x(function(t){return n.has(t)||!!i&&i.has___(t)})},set___:{value:x(e)},delete___:{value:x(function(t){var e=!!n.delete(t);return i&&i.delete___(t)||e})},permitHostObjects___:{value:x(function(t){if(t!==v)throw new Error("bogus call to permitHostObjects___");a=!0})}})}t&&"undefined"!=typeof Proxy&&(Proxy=void 0),n.prototype=g.prototype,e.exports=n,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=g)}function v(t){t.permitHostObjects___&&t.permitHostObjects___(v)}function m(t){return!(t.substr(0,l.length)==l&&"___"===t.substr(t.length-3))}function y(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[c];if(e&&e.key===t)return e;if(s(t)){e={key:t};try{return o(t,c,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(t){return}}}function x(t){return t.prototype=null,Object.freeze(t)}function b(){p||"undefined"==typeof console||(p=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}}()},{}],529:[function(t,e,r){var n=t("./hidden-store.js");e.exports=function(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:n(e,t)}}},{"./hidden-store.js":530}],530:[function(t,e,r){e.exports=function(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}},{}],531:[function(t,e,r){var n=t("./create-store.js");e.exports=function(){var t=n();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){return t(e).value=r,this},has:function(e){return"value"in t(e)},delete:function(e){return delete t(e).value}}}},{"./create-store.js":529}],532:[function(t,e,r){var n=t("get-canvas-context");e.exports=function(t){return n("webgl",t)}},{"get-canvas-context":221}],533:[function(t,e,r){var n=t("../main"),i=t("object-assign"),a=n.instance();function o(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}o.prototype=new n.baseCalendar,i(o.prototype,{name:"Chinese",jdEpoch:1721425.5,hasYearZero:!1,minMonth:0,firstMonth:0,minDay:1,regionalOptions:{"":{name:"Chinese",epochs:["BEC","EC"],monthNumbers:function(t,e){if("string"==typeof t){var r=t.match(l);return r?r[0]:""}var n=this._validateYear(t),i=t.month(),a=""+this.toChineseMonth(n,i);return e&&a.length<2&&(a="0"+a),this.isIntercalaryMonth(n,i)&&(a+="i"),a},monthNames:function(t){if("string"==typeof t){var e=t.match(c);return e?e[0]:""}var r=this._validateYear(t),n=t.month(),i=["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"][this.toChineseMonth(r,n)-1];return this.isIntercalaryMonth(r,n)&&(i="\u95f0"+i),i},monthNamesShort:function(t){if("string"==typeof t){var e=t.match(u);return e?e[0]:""}var r=this._validateYear(t),n=t.month(),i=["\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u5341\u4e00","\u5341\u4e8c"][this.toChineseMonth(r,n)-1];return this.isIntercalaryMonth(r,n)&&(i="\u95f0"+i),i},parseMonth:function(t,e){t=this._validateYear(t);var r,n=parseInt(e);if(isNaN(n))"\u95f0"===e[0]&&(r=!0,e=e.substring(1)),"\u6708"===e[e.length-1]&&(e=e.substring(0,e.length-1)),n=1+["\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u5341\u4e00","\u5341\u4e8c"].indexOf(e);else{var i=e[e.length-1];r="i"===i||"I"===i}return this.toMonthIndex(t,n,r)},dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:1,isRTL:!1}},_validateYear:function(t,e){if(t.year&&(t=t.year()),"number"!=typeof t||t<1888||t>2111)throw e.replace(/\{0\}/,this.local.name);return t},toMonthIndex:function(t,e,r){var i=this.intercalaryMonth(t);if(r&&e!==i||e<1||e>12)throw n.local.invalidMonth.replace(/\{0\}/,this.local.name);return i?!r&&e<=i?e-1:e:e-1},toChineseMonth:function(t,e){t.year&&(e=(t=t.year()).month());var r=this.intercalaryMonth(t);if(e<0||e>(r?12:11))throw n.local.invalidMonth.replace(/\{0\}/,this.local.name);return r?e>13},isIntercalaryMonth:function(t,e){t.year&&(e=(t=t.year()).month());var r=this.intercalaryMonth(t);return!!r&&r===e},leapYear:function(t){return 0!==this.intercalaryMonth(t)},weekOfYear:function(t,e,r){var i,o=this._validateYear(t,n.local.invalidyear),s=h[o-h[0]],l=s>>9&4095,c=s>>5&15,u=31&s;(i=a.newDate(l,c,u)).add(4-(i.dayOfWeek()||7),"d");var f=this.toJD(t,e,r)-i.toJD();return 1+Math.floor(f/7)},monthsInYear:function(t){return this.leapYear(t)?13:12},daysInMonth:function(t,e){t.year&&(e=t.month(),t=t.year()),t=this._validateYear(t);var r=f[t-f[0]];if(e>(r>>13?12:11))throw n.local.invalidMonth.replace(/\{0\}/,this.local.name);return r&1<<12-e?30:29},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,s,r,n.local.invalidDate);t=this._validateYear(i.year()),e=i.month(),r=i.day();var o=this.isIntercalaryMonth(t,e),s=this.toChineseMonth(t,e),l=function(t,e,r,n,i){var a,o,s;if("object"==typeof t)o=t,a=e||{};else{var l="number"==typeof t&&t>=1888&&t<=2111;if(!l)throw new Error("Lunar year outside range 1888-2111");var c="number"==typeof e&&e>=1&&e<=12;if(!c)throw new Error("Lunar month outside range 1 - 12");var u,p="number"==typeof r&&r>=1&&r<=30;if(!p)throw new Error("Lunar day outside range 1 - 30");"object"==typeof n?(u=!1,a=n):(u=!!n,a=i||{}),o={year:t,month:e,day:r,isIntercalary:u}}s=o.day-1;var d,g=f[o.year-f[0]],v=g>>13;d=v?o.month>v?o.month:o.isIntercalary?o.month:o.month-1:o.month-1;for(var m=0;m>9&4095,(x>>5&15)-1,(31&x)+s);return a.year=b.getFullYear(),a.month=1+b.getMonth(),a.day=b.getDate(),a}(t,s,r,o);return a.toJD(l.year,l.month,l.day)},fromJD:function(t){var e=a.fromJD(t),r=function(t,e,r,n){var i,a;if("object"==typeof t)i=t,a=e||{};else{var o="number"==typeof t&&t>=1888&&t<=2111;if(!o)throw new Error("Solar year outside range 1888-2111");var s="number"==typeof e&&e>=1&&e<=12;if(!s)throw new Error("Solar month outside range 1 - 12");var l="number"==typeof r&&r>=1&&r<=31;if(!l)throw new Error("Solar day outside range 1 - 31");i={year:t,month:e,day:r},a=n||{}}var c=h[i.year-h[0]],u=i.year<<9|i.month<<5|i.day;a.year=u>=c?i.year:i.year-1,c=h[a.year-h[0]];var p,d=new Date(c>>9&4095,(c>>5&15)-1,31&c),g=new Date(i.year,i.month-1,i.day);p=Math.round((g-d)/864e5);var v,m=f[a.year-f[0]];for(v=0;v<13;v++){var y=m&1<<12-v?30:29;if(p>13;!x||v=2&&n<=6},extraInfo:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return{century:o[Math.floor((i.year()-1)/100)+1]||""}},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=i.year()+(i.year()<0?1:0),e=i.month(),(r=i.day())+(e>1?16:0)+(e>2?32*(e-2):0)+400*(t-1)+this.jdEpoch-1},fromJD:function(t){t=Math.floor(t+.5)-Math.floor(this.jdEpoch)-1;var e=Math.floor(t/400)+1;t-=400*(e-1),t+=t>15?16:0;var r=Math.floor(t/32)+1,n=t-32*(r-1)+1;return this.newDate(e<=0?e-1:e,r,n)}});var o={20:"Fruitbat",21:"Anchovy"};n.calendars.discworld=a},{"../main":547,"object-assign":437}],536:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Ethiopian",jdEpoch:1724220.5,daysPerMonth:[30,30,30,30,30,30,30,30,30,30,30,30,5],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Ethiopian",epochs:["BEE","EE"],monthNames:["Meskerem","Tikemet","Hidar","Tahesas","Tir","Yekatit","Megabit","Miazia","Genbot","Sene","Hamle","Nehase","Pagume"],monthNamesShort:["Mes","Tik","Hid","Tah","Tir","Yek","Meg","Mia","Gen","Sen","Ham","Neh","Pag"],dayNames:["Ehud","Segno","Maksegno","Irob","Hamus","Arb","Kidame"],dayNamesShort:["Ehu","Seg","Mak","Iro","Ham","Arb","Kid"],dayNamesMin:["Eh","Se","Ma","Ir","Ha","Ar","Ki"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return(t=e.year()+(e.year()<0?1:0))%4==3||t%4==-1},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear||n.regionalOptions[""].invalidYear),13},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(13===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return(t=i.year())<0&&t++,i.day()+30*(i.month()-1)+365*(t-1)+Math.floor(t/4)+this.jdEpoch-1},fromJD:function(t){var e=Math.floor(t)+.5-this.jdEpoch,r=Math.floor((e-Math.floor((e+366)/1461))/365)+1;r<=0&&r--,e=Math.floor(t)+.5-this.newDate(r,1,1).toJD();var n=Math.floor(e/30)+1,i=e-30*(n-1)+1;return this.newDate(r,n,i)}}),n.calendars.ethiopian=a},{"../main":547,"object-assign":437}],537:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}function o(t,e){return t-e*Math.floor(t/e)}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Hebrew",jdEpoch:347995.5,daysPerMonth:[30,29,30,29,30,29,30,29,30,29,30,29,29],hasYearZero:!1,minMonth:1,firstMonth:7,minDay:1,regionalOptions:{"":{name:"Hebrew",epochs:["BAM","AM"],monthNames:["Nisan","Iyar","Sivan","Tammuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Shevat","Adar","Adar II"],monthNamesShort:["Nis","Iya","Siv","Tam","Av","Elu","Tis","Che","Kis","Tev","She","Ada","Ad2"],dayNames:["Yom Rishon","Yom Sheni","Yom Shlishi","Yom Revi'i","Yom Chamishi","Yom Shishi","Yom Shabbat"],dayNamesShort:["Ris","She","Shl","Rev","Cha","Shi","Sha"],dayNamesMin:["Ri","She","Shl","Re","Ch","Shi","Sha"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return this._leapYear(e.year())},_leapYear:function(t){return o(7*(t=t<0?t+1:t)+1,19)<7},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),this._leapYear(t.year?t.year():t)?13:12},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){return t=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year(),this.toJD(-1===t?1:t+1,7,1)-this.toJD(t,7,1)},daysInMonth:function(t,e){return t.year&&(e=t.month(),t=t.year()),this._validate(t,e,this.minDay,n.local.invalidMonth),12===e&&this.leapYear(t)?30:8===e&&5===o(this.daysInYear(t),10)?30:9===e&&3===o(this.daysInYear(t),10)?29:this.daysPerMonth[e-1]},weekDay:function(t,e,r){return 6!==this.dayOfWeek(t,e,r)},extraInfo:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return{yearType:(this.leapYear(i)?"embolismic":"common")+" "+["deficient","regular","complete"][this.daysInYear(i)%10-3]}},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=i.year(),e=i.month(),r=i.day();var a=t<=0?t+1:t,o=this.jdEpoch+this._delay1(a)+this._delay2(a)+r+1;if(e<7){for(var s=7;s<=this.monthsInYear(t);s++)o+=this.daysInMonth(t,s);for(s=1;s=this.toJD(-1===e?1:e+1,7,1);)e++;for(var r=tthis.toJD(e,r,this.daysInMonth(e,r));)r++;var n=t-this.toJD(e,r,1)+1;return this.newDate(e,r,n)}}),n.calendars.hebrew=a},{"../main":547,"object-assign":437}],538:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Islamic",jdEpoch:1948439.5,daysPerMonth:[30,29,30,29,30,29,30,29,30,29,30,29],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Islamic",epochs:["BH","AH"],monthNames:["Muharram","Safar","Rabi' al-awwal","Rabi' al-thani","Jumada al-awwal","Jumada al-thani","Rajab","Sha'aban","Ramadan","Shawwal","Dhu al-Qi'dah","Dhu al-Hijjah"],monthNamesShort:["Muh","Saf","Rab1","Rab2","Jum1","Jum2","Raj","Sha'","Ram","Shaw","DhuQ","DhuH"],dayNames:["Yawm al-ahad","Yawm al-ithnayn","Yawm ath-thulaathaa'","Yawm al-arbi'aa'","Yawm al-kham\u012bs","Yawm al-jum'a","Yawm as-sabt"],dayNamesShort:["Aha","Ith","Thu","Arb","Kha","Jum","Sab"],dayNamesMin:["Ah","It","Th","Ar","Kh","Ju","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:6,isRTL:!1}},leapYear:function(t){return(11*this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year()+14)%30<11},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){return this.leapYear(t)?355:354},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=i.year(),e=i.month(),t=t<=0?t+1:t,(r=i.day())+Math.ceil(29.5*(e-1))+354*(t-1)+Math.floor((3+11*t)/30)+this.jdEpoch-1},fromJD:function(t){t=Math.floor(t)+.5;var e=Math.floor((30*(t-this.jdEpoch)+10646)/10631);e=e<=0?e-1:e;var r=Math.min(12,Math.ceil((t-29-this.toJD(e,1,1))/29.5)+1),n=t-this.toJD(e,r,1)+1;return this.newDate(e,r,n)}}),n.calendars.islamic=a},{"../main":547,"object-assign":437}],539:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Julian",jdEpoch:1721423.5,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Julian",epochs:["BC","AD"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"mm/dd/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return(t=e.year()<0?e.year()+1:e.year())%4==0},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(4-(n.dayOfWeek()||7),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=i.year(),e=i.month(),r=i.day(),t<0&&t++,e<=2&&(t--,e+=12),Math.floor(365.25*(t+4716))+Math.floor(30.6001*(e+1))+r-1524.5},fromJD:function(t){var e=Math.floor(t+.5)+1524,r=Math.floor((e-122.1)/365.25),n=Math.floor(365.25*r),i=Math.floor((e-n)/30.6001),a=i-Math.floor(i<14?1:13),o=r-Math.floor(a>2?4716:4715),s=e-n-Math.floor(30.6001*i);return o<=0&&o--,this.newDate(o,a,s)}}),n.calendars.julian=a},{"../main":547,"object-assign":437}],540:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}function o(t,e){return t-e*Math.floor(t/e)}function s(t,e){return o(t-1,e)+1}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Mayan",jdEpoch:584282.5,hasYearZero:!0,minMonth:0,firstMonth:0,minDay:0,regionalOptions:{"":{name:"Mayan",epochs:["",""],monthNames:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"],monthNamesShort:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"],dayNames:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],dayNamesShort:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],dayNamesMin:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],digits:null,dateFormat:"YYYY.m.d",firstDay:0,isRTL:!1,haabMonths:["Pop","Uo","Zip","Zotz","Tzec","Xul","Yaxkin","Mol","Chen","Yax","Zac","Ceh","Mac","Kankin","Muan","Pax","Kayab","Cumku","Uayeb"],tzolkinMonths:["Imix","Ik","Akbal","Kan","Chicchan","Cimi","Manik","Lamat","Muluc","Oc","Chuen","Eb","Ben","Ix","Men","Cib","Caban","Etznab","Cauac","Ahau"]}},leapYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),!1},formatYear:function(t){t=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year();var e=Math.floor(t/400);return t%=400,t+=t<0?400:0,e+"."+Math.floor(t/20)+"."+t%20},forYear:function(t){if((t=t.split(".")).length<3)throw"Invalid Mayan year";for(var e=0,r=0;r19||r>0&&n<0)throw"Invalid Mayan year";e=20*e+n}return e},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),18},weekOfYear:function(t,e,r){return this._validate(t,e,r,n.local.invalidDate),0},daysInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),360},daysInMonth:function(t,e){return this._validate(t,e,this.minDay,n.local.invalidMonth),20},daysInWeek:function(){return 5},dayOfWeek:function(t,e,r){return this._validate(t,e,r,n.local.invalidDate).day()},weekDay:function(t,e,r){return this._validate(t,e,r,n.local.invalidDate),!0},extraInfo:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate).toJD(),a=this._toHaab(i),o=this._toTzolkin(i);return{haabMonthName:this.local.haabMonths[a[0]-1],haabMonth:a[0],haabDay:a[1],tzolkinDayName:this.local.tzolkinMonths[o[0]-1],tzolkinDay:o[0],tzolkinTrecena:o[1]}},_toHaab:function(t){var e=o((t-=this.jdEpoch)+8+340,365);return[Math.floor(e/20)+1,o(e,20)]},_toTzolkin:function(t){return[s((t-=this.jdEpoch)+20,20),s(t+4,13)]},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return i.day()+20*i.month()+360*i.year()+this.jdEpoch},fromJD:function(t){t=Math.floor(t)+.5-this.jdEpoch;var e=Math.floor(t/360);t%=360,t+=t<0?360:0;var r=Math.floor(t/20),n=t%20;return this.newDate(e,r,n)}}),n.calendars.mayan=a},{"../main":547,"object-assign":437}],541:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar;var o=n.instance("gregorian");i(a.prototype,{name:"Nanakshahi",jdEpoch:2257673.5,daysPerMonth:[31,31,31,31,31,30,30,30,30,30,30,30],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Nanakshahi",epochs:["BN","AN"],monthNames:["Chet","Vaisakh","Jeth","Harh","Sawan","Bhadon","Assu","Katak","Maghar","Poh","Magh","Phagun"],monthNamesShort:["Che","Vai","Jet","Har","Saw","Bha","Ass","Kat","Mgr","Poh","Mgh","Pha"],dayNames:["Somvaar","Mangalvar","Budhvaar","Veervaar","Shukarvaar","Sanicharvaar","Etvaar"],dayNamesShort:["Som","Mangal","Budh","Veer","Shukar","Sanichar","Et"],dayNamesMin:["So","Ma","Bu","Ve","Sh","Sa","Et"],digits:null,dateFormat:"dd-mm-yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear||n.regionalOptions[""].invalidYear);return o.leapYear(e.year()+(e.year()<1?1:0)+1469)},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(1-(n.dayOfWeek()||7),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidMonth);(t=i.year())<0&&t++;for(var a=i.day(),s=1;s=this.toJD(e+1,1,1);)e++;for(var r=t-Math.floor(this.toJD(e,1,1)+.5)+1,n=1;r>this.daysInMonth(e,n);)r-=this.daysInMonth(e,n),n++;return this.newDate(e,n,r)}}),n.calendars.nanakshahi=a},{"../main":547,"object-assign":437}],542:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Nepali",jdEpoch:1700709.5,daysPerMonth:[31,31,32,32,31,30,30,29,30,29,30,30],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,daysPerYear:365,regionalOptions:{"":{name:"Nepali",epochs:["BBS","ABS"],monthNames:["Baisakh","Jestha","Ashadh","Shrawan","Bhadra","Ashwin","Kartik","Mangsir","Paush","Mangh","Falgun","Chaitra"],monthNamesShort:["Bai","Je","As","Shra","Bha","Ash","Kar","Mang","Pau","Ma","Fal","Chai"],dayNames:["Aaitabaar","Sombaar","Manglbaar","Budhabaar","Bihibaar","Shukrabaar","Shanibaar"],dayNamesShort:["Aaita","Som","Mangl","Budha","Bihi","Shukra","Shani"],dayNamesMin:["Aai","So","Man","Bu","Bi","Shu","Sha"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:1,isRTL:!1}},leapYear:function(t){return this.daysInYear(t)!==this.daysPerYear},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){if(t=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year(),"undefined"==typeof this.NEPALI_CALENDAR_DATA[t])return this.daysPerYear;for(var e=0,r=this.minMonth;r<=12;r++)e+=this.NEPALI_CALENDAR_DATA[t][r];return e},daysInMonth:function(t,e){return t.year&&(e=t.month(),t=t.year()),this._validate(t,e,this.minDay,n.local.invalidMonth),"undefined"==typeof this.NEPALI_CALENDAR_DATA[t]?this.daysPerMonth[e-1]:this.NEPALI_CALENDAR_DATA[t][e]},weekDay:function(t,e,r){return 6!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=i.year(),e=i.month(),r=i.day();var a=n.instance(),o=0,s=e,l=t;this._createMissingCalendarData(t);var c=t-(s>9||9===s&&r>=this.NEPALI_CALENDAR_DATA[l][0]?56:57);for(9!==e&&(o=r,s--);9!==s;)s<=0&&(s=12,l--),o+=this.NEPALI_CALENDAR_DATA[l][s],s--;return 9===e?(o+=r-this.NEPALI_CALENDAR_DATA[l][0])<0&&(o+=a.daysInYear(c)):o+=this.NEPALI_CALENDAR_DATA[l][9]-this.NEPALI_CALENDAR_DATA[l][0],a.newDate(c,1,1).add(o,"d").toJD()},fromJD:function(t){var e=n.instance().fromJD(t),r=e.year(),i=e.dayOfYear(),a=r+56;this._createMissingCalendarData(a);for(var o=9,s=this.NEPALI_CALENDAR_DATA[a][0],l=this.NEPALI_CALENDAR_DATA[a][o]-s+1;i>l;)++o>12&&(o=1,a++),l+=this.NEPALI_CALENDAR_DATA[a][o];var c=this.NEPALI_CALENDAR_DATA[a][o]-(l-i);return this.newDate(a,o,c)},_createMissingCalendarData:function(t){var e=this.daysPerMonth.slice(0);e.unshift(17);for(var r=t-1;r0?474:473))%2820+474+38)%2816<682},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-(n.dayOfWeek()+1)%7,"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=i.year(),e=i.month(),r=i.day();var a=t-(t>=0?474:473),s=474+o(a,2820);return r+(e<=7?31*(e-1):30*(e-1)+6)+Math.floor((682*s-110)/2816)+365*(s-1)+1029983*Math.floor(a/2820)+this.jdEpoch-1},fromJD:function(t){var e=(t=Math.floor(t)+.5)-this.toJD(475,1,1),r=Math.floor(e/1029983),n=o(e,1029983),i=2820;if(1029982!==n){var a=Math.floor(n/366),s=o(n,366);i=Math.floor((2134*a+2816*s+2815)/1028522)+a+1}var l=i+2820*r+474;l=l<=0?l-1:l;var c=t-this.toJD(l,1,1)+1,u=c<=186?Math.ceil(c/31):Math.ceil((c-6)/30),f=t-this.toJD(l,u,1)+1;return this.newDate(l,u,f)}}),n.calendars.persian=a,n.calendars.jalali=a},{"../main":547,"object-assign":437}],544:[function(t,e,r){var n=t("../main"),i=t("object-assign"),a=n.instance();function o(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}o.prototype=new n.baseCalendar,i(o.prototype,{name:"Taiwan",jdEpoch:2419402.5,yearsOffset:1911,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Taiwan",epochs:["BROC","ROC"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:1,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);t=this._t2gYear(e.year());return a.leapYear(t)},weekOfYear:function(t,e,r){var i=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);t=this._t2gYear(i.year());return a.weekOfYear(t,i.month(),i.day())},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=this._t2gYear(i.year());return a.toJD(t,i.month(),i.day())},fromJD:function(t){var e=a.fromJD(t),r=this._g2tYear(e.year());return this.newDate(r,e.month(),e.day())},_t2gYear:function(t){return t+this.yearsOffset+(t>=-this.yearsOffset&&t<=-1?1:0)},_g2tYear:function(t){return t-this.yearsOffset-(t>=1&&t<=this.yearsOffset?1:0)}}),n.calendars.taiwan=o},{"../main":547,"object-assign":437}],545:[function(t,e,r){var n=t("../main"),i=t("object-assign"),a=n.instance();function o(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}o.prototype=new n.baseCalendar,i(o.prototype,{name:"Thai",jdEpoch:1523098.5,yearsOffset:543,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Thai",epochs:["BBE","BE"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);t=this._t2gYear(e.year());return a.leapYear(t)},weekOfYear:function(t,e,r){var i=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);t=this._t2gYear(i.year());return a.weekOfYear(t,i.month(),i.day())},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=this._t2gYear(i.year());return a.toJD(t,i.month(),i.day())},fromJD:function(t){var e=a.fromJD(t),r=this._g2tYear(e.year());return this.newDate(r,e.month(),e.day())},_t2gYear:function(t){return t-this.yearsOffset-(t>=1&&t<=this.yearsOffset?1:0)},_g2tYear:function(t){return t+this.yearsOffset+(t>=-this.yearsOffset&&t<=-1?1:0)}}),n.calendars.thai=o},{"../main":547,"object-assign":437}],546:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"UmmAlQura",hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Umm al-Qura",epochs:["BH","AH"],monthNames:["Al-Muharram","Safar","Rabi' al-awwal","Rabi' Al-Thani","Jumada Al-Awwal","Jumada Al-Thani","Rajab","Sha'aban","Ramadan","Shawwal","Dhu al-Qi'dah","Dhu al-Hijjah"],monthNamesShort:["Muh","Saf","Rab1","Rab2","Jum1","Jum2","Raj","Sha'","Ram","Shaw","DhuQ","DhuH"],dayNames:["Yawm al-Ahad","Yawm al-Ithnain","Yawm al-Thal\u0101th\u0101\u2019","Yawm al-Arba\u2018\u0101\u2019","Yawm al-Kham\u012bs","Yawm al-Jum\u2018a","Yawm al-Sabt"],dayNamesMin:["Ah","Ith","Th","Ar","Kh","Ju","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:6,isRTL:!0}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return 355===this.daysInYear(e.year())},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){for(var e=0,r=1;r<=12;r++)e+=this.daysInMonth(t,r);return e},daysInMonth:function(t,e){for(var r=this._validate(t,e,this.minDay,n.local.invalidMonth).toJD()-24e5+.5,i=0,a=0;ar)return o[i]-o[i-1];i++}return 30},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate),a=12*(i.year()-1)+i.month()-15292;return i.day()+o[a-1]-1+24e5-.5},fromJD:function(t){for(var e=t-24e5+.5,r=0,n=0;ne);n++)r++;var i=r+15292,a=Math.floor((i-1)/12),s=a+1,l=i-12*a,c=e-o[r-1]+1;return this.newDate(s,l,c)},isValid:function(t,e,r){var i=n.baseCalendar.prototype.isValid.apply(this,arguments);return i&&(i=(t=null!=t.year?t.year:t)>=1276&&t<=1500),i},_validate:function(t,e,r,i){var a=n.baseCalendar.prototype._validate.apply(this,arguments);if(a.year<1276||a.year>1500)throw i.replace(/\{0\}/,this.local.name);return a}}),n.calendars.ummalqura=a;var o=[20,50,79,109,138,168,197,227,256,286,315,345,374,404,433,463,492,522,551,581,611,641,670,700,729,759,788,818,847,877,906,936,965,995,1024,1054,1083,1113,1142,1172,1201,1231,1260,1290,1320,1350,1379,1409,1438,1468,1497,1527,1556,1586,1615,1645,1674,1704,1733,1763,1792,1822,1851,1881,1910,1940,1969,1999,2028,2058,2087,2117,2146,2176,2205,2235,2264,2294,2323,2353,2383,2413,2442,2472,2501,2531,2560,2590,2619,2649,2678,2708,2737,2767,2796,2826,2855,2885,2914,2944,2973,3003,3032,3062,3091,3121,3150,3180,3209,3239,3268,3298,3327,3357,3386,3416,3446,3476,3505,3535,3564,3594,3623,3653,3682,3712,3741,3771,3800,3830,3859,3889,3918,3948,3977,4007,4036,4066,4095,4125,4155,4185,4214,4244,4273,4303,4332,4362,4391,4421,4450,4480,4509,4539,4568,4598,4627,4657,4686,4716,4745,4775,4804,4834,4863,4893,4922,4952,4981,5011,5040,5070,5099,5129,5158,5188,5218,5248,5277,5307,5336,5366,5395,5425,5454,5484,5513,5543,5572,5602,5631,5661,5690,5720,5749,5779,5808,5838,5867,5897,5926,5956,5985,6015,6044,6074,6103,6133,6162,6192,6221,6251,6281,6311,6340,6370,6399,6429,6458,6488,6517,6547,6576,6606,6635,6665,6694,6724,6753,6783,6812,6842,6871,6901,6930,6960,6989,7019,7048,7078,7107,7137,7166,7196,7225,7255,7284,7314,7344,7374,7403,7433,7462,7492,7521,7551,7580,7610,7639,7669,7698,7728,7757,7787,7816,7846,7875,7905,7934,7964,7993,8023,8053,8083,8112,8142,8171,8201,8230,8260,8289,8319,8348,8378,8407,8437,8466,8496,8525,8555,8584,8614,8643,8673,8702,8732,8761,8791,8821,8850,8880,8909,8938,8968,8997,9027,9056,9086,9115,9145,9175,9205,9234,9264,9293,9322,9352,9381,9410,9440,9470,9499,9529,9559,9589,9618,9648,9677,9706,9736,9765,9794,9824,9853,9883,9913,9943,9972,10002,10032,10061,10090,10120,10149,10178,10208,10237,10267,10297,10326,10356,10386,10415,10445,10474,10504,10533,10562,10592,10621,10651,10680,10710,10740,10770,10799,10829,10858,10888,10917,10947,10976,11005,11035,11064,11094,11124,11153,11183,11213,11242,11272,11301,11331,11360,11389,11419,11448,11478,11507,11537,11567,11596,11626,11655,11685,11715,11744,11774,11803,11832,11862,11891,11921,11950,11980,12010,12039,12069,12099,12128,12158,12187,12216,12246,12275,12304,12334,12364,12393,12423,12453,12483,12512,12542,12571,12600,12630,12659,12688,12718,12747,12777,12807,12837,12866,12896,12926,12955,12984,13014,13043,13072,13102,13131,13161,13191,13220,13250,13280,13310,13339,13368,13398,13427,13456,13486,13515,13545,13574,13604,13634,13664,13693,13723,13752,13782,13811,13840,13870,13899,13929,13958,13988,14018,14047,14077,14107,14136,14166,14195,14224,14254,14283,14313,14342,14372,14401,14431,14461,14490,14520,14550,14579,14609,14638,14667,14697,14726,14756,14785,14815,14844,14874,14904,14933,14963,14993,15021,15051,15081,15110,15140,15169,15199,15228,15258,15287,15317,15347,15377,15406,15436,15465,15494,15524,15553,15582,15612,15641,15671,15701,15731,15760,15790,15820,15849,15878,15908,15937,15966,15996,16025,16055,16085,16114,16144,16174,16204,16233,16262,16292,16321,16350,16380,16409,16439,16468,16498,16528,16558,16587,16617,16646,16676,16705,16734,16764,16793,16823,16852,16882,16912,16941,16971,17001,17030,17060,17089,17118,17148,17177,17207,17236,17266,17295,17325,17355,17384,17414,17444,17473,17502,17532,17561,17591,17620,17650,17679,17709,17738,17768,17798,17827,17857,17886,17916,17945,17975,18004,18034,18063,18093,18122,18152,18181,18211,18241,18270,18300,18330,18359,18388,18418,18447,18476,18506,18535,18565,18595,18625,18654,18684,18714,18743,18772,18802,18831,18860,18890,18919,18949,18979,19008,19038,19068,19098,19127,19156,19186,19215,19244,19274,19303,19333,19362,19392,19422,19452,19481,19511,19540,19570,19599,19628,19658,19687,19717,19746,19776,19806,19836,19865,19895,19924,19954,19983,20012,20042,20071,20101,20130,20160,20190,20219,20249,20279,20308,20338,20367,20396,20426,20455,20485,20514,20544,20573,20603,20633,20662,20692,20721,20751,20780,20810,20839,20869,20898,20928,20957,20987,21016,21046,21076,21105,21135,21164,21194,21223,21253,21282,21312,21341,21371,21400,21430,21459,21489,21519,21548,21578,21607,21637,21666,21696,21725,21754,21784,21813,21843,21873,21902,21932,21962,21991,22021,22050,22080,22109,22138,22168,22197,22227,22256,22286,22316,22346,22375,22405,22434,22464,22493,22522,22552,22581,22611,22640,22670,22700,22730,22759,22789,22818,22848,22877,22906,22936,22965,22994,23024,23054,23083,23113,23143,23173,23202,23232,23261,23290,23320,23349,23379,23408,23438,23467,23497,23527,23556,23586,23616,23645,23674,23704,23733,23763,23792,23822,23851,23881,23910,23940,23970,23999,24029,24058,24088,24117,24147,24176,24206,24235,24265,24294,24324,24353,24383,24413,24442,24472,24501,24531,24560,24590,24619,24648,24678,24707,24737,24767,24796,24826,24856,24885,24915,24944,24974,25003,25032,25062,25091,25121,25150,25180,25210,25240,25269,25299,25328,25358,25387,25416,25446,25475,25505,25534,25564,25594,25624,25653,25683,25712,25742,25771,25800,25830,25859,25888,25918,25948,25977,26007,26037,26067,26096,26126,26155,26184,26214,26243,26272,26302,26332,26361,26391,26421,26451,26480,26510,26539,26568,26598,26627,26656,26686,26715,26745,26775,26805,26834,26864,26893,26923,26952,26982,27011,27041,27070,27099,27129,27159,27188,27218,27248,27277,27307,27336,27366,27395,27425,27454,27484,27513,27542,27572,27602,27631,27661,27691,27720,27750,27779,27809,27838,27868,27897,27926,27956,27985,28015,28045,28074,28104,28134,28163,28193,28222,28252,28281,28310,28340,28369,28399,28428,28458,28488,28517,28547,28577,28607,28636,28665,28695,28724,28754,28783,28813,28843,28872,28901,28931,28960,28990,29019,29049,29078,29108,29137,29167,29196,29226,29255,29285,29315,29345,29375,29404,29434,29463,29492,29522,29551,29580,29610,29640,29669,29699,29729,29759,29788,29818,29847,29876,29906,29935,29964,29994,30023,30053,30082,30112,30141,30171,30200,30230,30259,30289,30318,30348,30378,30408,30437,30467,30496,30526,30555,30585,30614,30644,30673,30703,30732,30762,30791,30821,30850,30880,30909,30939,30968,30998,31027,31057,31086,31116,31145,31175,31204,31234,31263,31293,31322,31352,31381,31411,31441,31471,31500,31530,31559,31589,31618,31648,31676,31706,31736,31766,31795,31825,31854,31884,31913,31943,31972,32002,32031,32061,32090,32120,32150,32180,32209,32239,32268,32298,32327,32357,32386,32416,32445,32475,32504,32534,32563,32593,32622,32652,32681,32711,32740,32770,32799,32829,32858,32888,32917,32947,32976,33006,33035,33065,33094,33124,33153,33183,33213,33243,33272,33302,33331,33361,33390,33420,33450,33479,33509,33539,33568,33598,33627,33657,33686,33716,33745,33775,33804,33834,33863,33893,33922,33952,33981,34011,34040,34069,34099,34128,34158,34187,34217,34247,34277,34306,34336,34365,34395,34424,34454,34483,34512,34542,34571,34601,34631,34660,34690,34719,34749,34778,34808,34837,34867,34896,34926,34955,34985,35015,35044,35074,35103,35133,35162,35192,35222,35251,35280,35310,35340,35370,35399,35429,35458,35488,35517,35547,35576,35605,35635,35665,35694,35723,35753,35782,35811,35841,35871,35901,35930,35960,35989,36019,36048,36078,36107,36136,36166,36195,36225,36254,36284,36314,36343,36373,36403,36433,36462,36492,36521,36551,36580,36610,36639,36669,36698,36728,36757,36786,36816,36845,36875,36904,36934,36963,36993,37022,37052,37081,37111,37141,37170,37200,37229,37259,37288,37318,37347,37377,37406,37436,37465,37495,37524,37554,37584,37613,37643,37672,37701,37731,37760,37790,37819,37849,37878,37908,37938,37967,37997,38027,38056,38085,38115,38144,38174,38203,38233,38262,38292,38322,38351,38381,38410,38440,38469,38499,38528,38558,38587,38617,38646,38676,38705,38735,38764,38794,38823,38853,38882,38912,38941,38971,39001,39030,39059,39089,39118,39148,39178,39208,39237,39267,39297,39326,39355,39385,39414,39444,39473,39503,39532,39562,39592,39621,39650,39680,39709,39739,39768,39798,39827,39857,39886,39916,39946,39975,40005,40035,40064,40094,40123,40153,40182,40212,40241,40271,40300,40330,40359,40389,40418,40448,40477,40507,40536,40566,40595,40625,40655,40685,40714,40744,40773,40803,40832,40862,40892,40921,40951,40980,41009,41039,41068,41098,41127,41157,41186,41216,41245,41275,41304,41334,41364,41393,41422,41452,41481,41511,41540,41570,41599,41629,41658,41688,41718,41748,41777,41807,41836,41865,41894,41924,41953,41983,42012,42042,42072,42102,42131,42161,42190,42220,42249,42279,42308,42337,42367,42397,42426,42456,42485,42515,42545,42574,42604,42633,42662,42692,42721,42751,42780,42810,42839,42869,42899,42929,42958,42988,43017,43046,43076,43105,43135,43164,43194,43223,43253,43283,43312,43342,43371,43401,43430,43460,43489,43519,43548,43578,43607,43637,43666,43696,43726,43755,43785,43814,43844,43873,43903,43932,43962,43991,44021,44050,44080,44109,44139,44169,44198,44228,44258,44287,44317,44346,44375,44405,44434,44464,44493,44523,44553,44582,44612,44641,44671,44700,44730,44759,44788,44818,44847,44877,44906,44936,44966,44996,45025,45055,45084,45114,45143,45172,45202,45231,45261,45290,45320,45350,45380,45409,45439,45468,45498,45527,45556,45586,45615,45644,45674,45704,45733,45763,45793,45823,45852,45882,45911,45940,45970,45999,46028,46058,46088,46117,46147,46177,46206,46236,46265,46295,46324,46354,46383,46413,46442,46472,46501,46531,46560,46590,46620,46649,46679,46708,46738,46767,46797,46826,46856,46885,46915,46944,46974,47003,47033,47063,47092,47122,47151,47181,47210,47240,47269,47298,47328,47357,47387,47417,47446,47476,47506,47535,47565,47594,47624,47653,47682,47712,47741,47771,47800,47830,47860,47890,47919,47949,47978,48008,48037,48066,48096,48125,48155,48184,48214,48244,48273,48303,48333,48362,48392,48421,48450,48480,48509,48538,48568,48598,48627,48657,48687,48717,48746,48776,48805,48834,48864,48893,48922,48952,48982,49011,49041,49071,49100,49130,49160,49189,49218,49248,49277,49306,49336,49365,49395,49425,49455,49484,49514,49543,49573,49602,49632,49661,49690,49720,49749,49779,49809,49838,49868,49898,49927,49957,49986,50016,50045,50075,50104,50133,50163,50192,50222,50252,50281,50311,50340,50370,50400,50429,50459,50488,50518,50547,50576,50606,50635,50665,50694,50724,50754,50784,50813,50843,50872,50902,50931,50960,50990,51019,51049,51078,51108,51138,51167,51197,51227,51256,51286,51315,51345,51374,51403,51433,51462,51492,51522,51552,51582,51611,51641,51670,51699,51729,51758,51787,51816,51846,51876,51906,51936,51965,51995,52025,52054,52083,52113,52142,52171,52200,52230,52260,52290,52319,52349,52379,52408,52438,52467,52497,52526,52555,52585,52614,52644,52673,52703,52733,52762,52792,52822,52851,52881,52910,52939,52969,52998,53028,53057,53087,53116,53146,53176,53205,53235,53264,53294,53324,53353,53383,53412,53441,53471,53500,53530,53559,53589,53619,53648,53678,53708,53737,53767,53796,53825,53855,53884,53913,53943,53973,54003,54032,54062,54092,54121,54151,54180,54209,54239,54268,54297,54327,54357,54387,54416,54446,54476,54505,54535,54564,54593,54623,54652,54681,54711,54741,54770,54800,54830,54859,54889,54919,54948,54977,55007,55036,55066,55095,55125,55154,55184,55213,55243,55273,55302,55332,55361,55391,55420,55450,55479,55508,55538,55567,55597,55627,55657,55686,55716,55745,55775,55804,55834,55863,55892,55922,55951,55981,56011,56040,56070,56100,56129,56159,56188,56218,56247,56276,56306,56335,56365,56394,56424,56454,56483,56513,56543,56572,56601,56631,56660,56690,56719,56749,56778,56808,56837,56867,56897,56926,56956,56985,57015,57044,57074,57103,57133,57162,57192,57221,57251,57280,57310,57340,57369,57399,57429,57458,57487,57517,57546,57576,57605,57634,57664,57694,57723,57753,57783,57813,57842,57871,57901,57930,57959,57989,58018,58048,58077,58107,58137,58167,58196,58226,58255,58285,58314,58343,58373,58402,58432,58461,58491,58521,58551,58580,58610,58639,58669,58698,58727,58757,58786,58816,58845,58875,58905,58934,58964,58994,59023,59053,59082,59111,59141,59170,59200,59229,59259,59288,59318,59348,59377,59407,59436,59466,59495,59525,59554,59584,59613,59643,59672,59702,59731,59761,59791,59820,59850,59879,59909,59939,59968,59997,60027,60056,60086,60115,60145,60174,60204,60234,60264,60293,60323,60352,60381,60411,60440,60469,60499,60528,60558,60588,60618,60648,60677,60707,60736,60765,60795,60824,60853,60883,60912,60942,60972,61002,61031,61061,61090,61120,61149,61179,61208,61237,61267,61296,61326,61356,61385,61415,61445,61474,61504,61533,61563,61592,61621,61651,61680,61710,61739,61769,61799,61828,61858,61888,61917,61947,61976,62006,62035,62064,62094,62123,62153,62182,62212,62242,62271,62301,62331,62360,62390,62419,62448,62478,62507,62537,62566,62596,62625,62655,62685,62715,62744,62774,62803,62832,62862,62891,62921,62950,62980,63009,63039,63069,63099,63128,63157,63187,63216,63246,63275,63305,63334,63363,63393,63423,63453,63482,63512,63541,63571,63600,63630,63659,63689,63718,63747,63777,63807,63836,63866,63895,63925,63955,63984,64014,64043,64073,64102,64131,64161,64190,64220,64249,64279,64309,64339,64368,64398,64427,64457,64486,64515,64545,64574,64603,64633,64663,64692,64722,64752,64782,64811,64841,64870,64899,64929,64958,64987,65017,65047,65076,65106,65136,65166,65195,65225,65254,65283,65313,65342,65371,65401,65431,65460,65490,65520,65549,65579,65608,65638,65667,65697,65726,65755,65785,65815,65844,65874,65903,65933,65963,65992,66022,66051,66081,66110,66140,66169,66199,66228,66258,66287,66317,66346,66376,66405,66435,66465,66494,66524,66553,66583,66612,66641,66671,66700,66730,66760,66789,66819,66849,66878,66908,66937,66967,66996,67025,67055,67084,67114,67143,67173,67203,67233,67262,67292,67321,67351,67380,67409,67439,67468,67497,67527,67557,67587,67617,67646,67676,67705,67735,67764,67793,67823,67852,67882,67911,67941,67971,68e3,68030,68060,68089,68119,68148,68177,68207,68236,68266,68295,68325,68354,68384,68414,68443,68473,68502,68532,68561,68591,68620,68650,68679,68708,68738,68768,68797,68827,68857,68886,68916,68946,68975,69004,69034,69063,69092,69122,69152,69181,69211,69240,69270,69300,69330,69359,69388,69418,69447,69476,69506,69535,69565,69595,69624,69654,69684,69713,69743,69772,69802,69831,69861,69890,69919,69949,69978,70008,70038,70067,70097,70126,70156,70186,70215,70245,70274,70303,70333,70362,70392,70421,70451,70481,70510,70540,70570,70599,70629,70658,70687,70717,70746,70776,70805,70835,70864,70894,70924,70954,70983,71013,71042,71071,71101,71130,71159,71189,71218,71248,71278,71308,71337,71367,71397,71426,71455,71485,71514,71543,71573,71602,71632,71662,71691,71721,71751,71781,71810,71839,71869,71898,71927,71957,71986,72016,72046,72075,72105,72135,72164,72194,72223,72253,72282,72311,72341,72370,72400,72429,72459,72489,72518,72548,72577,72607,72637,72666,72695,72725,72754,72784,72813,72843,72872,72902,72931,72961,72991,73020,73050,73080,73109,73139,73168,73197,73227,73256,73286,73315,73345,73375,73404,73434,73464,73493,73523,73552,73581,73611,73640,73669,73699,73729,73758,73788,73818,73848,73877,73907,73936,73965,73995,74024,74053,74083,74113,74142,74172,74202,74231,74261,74291,74320,74349,74379,74408,74437,74467,74497,74526,74556,74586,74615,74645,74675,74704,74733,74763,74792,74822,74851,74881,74910,74940,74969,74999,75029,75058,75088,75117,75147,75176,75206,75235,75264,75294,75323,75353,75383,75412,75442,75472,75501,75531,75560,75590,75619,75648,75678,75707,75737,75766,75796,75826,75856,75885,75915,75944,75974,76003,76032,76062,76091,76121,76150,76180,76210,76239,76269,76299,76328,76358,76387,76416,76446,76475,76505,76534,76564,76593,76623,76653,76682,76712,76741,76771,76801,76830,76859,76889,76918,76948,76977,77007,77036,77066,77096,77125,77155,77185,77214,77243,77273,77302,77332,77361,77390,77420,77450,77479,77509,77539,77569,77598,77627,77657,77686,77715,77745,77774,77804,77833,77863,77893,77923,77952,77982,78011,78041,78070,78099,78129,78158,78188,78217,78247,78277,78307,78336,78366,78395,78425,78454,78483,78513,78542,78572,78601,78631,78661,78690,78720,78750,78779,78808,78838,78867,78897,78926,78956,78985,79015,79044,79074,79104,79133,79163,79192,79222,79251,79281,79310,79340,79369,79399,79428,79458,79487,79517,79546,79576,79606,79635,79665,79695,79724,79753,79783,79812,79841,79871,79900,79930,79960,79990]},{"../main":547,"object-assign":437}],547:[function(t,e,r){var n=t("object-assign");function i(){this.regionalOptions=[],this.regionalOptions[""]={invalidCalendar:"Calendar {0} not found",invalidDate:"Invalid {0} date",invalidMonth:"Invalid {0} month",invalidYear:"Invalid {0} year",differentCalendars:"Cannot mix {0} and {1} dates"},this.local=this.regionalOptions[""],this.calendars={},this._localCals={}}function a(t,e,r,n){if(this._calendar=t,this._year=e,this._month=r,this._day=n,0===this._calendar._validateLevel&&!this._calendar.isValid(this._year,this._month,this._day))throw(c.local.invalidDate||c.regionalOptions[""].invalidDate).replace(/\{0\}/,this._calendar.local.name)}function o(t,e){return"000000".substring(0,e-(t=""+t).length)+t}function s(){this.shortYearCutoff="+10"}function l(t){this.local=this.regionalOptions[t]||this.regionalOptions[""]}n(i.prototype,{instance:function(t,e){t=(t||"gregorian").toLowerCase(),e=e||"";var r=this._localCals[t+"-"+e];if(!r&&this.calendars[t]&&(r=new this.calendars[t](e),this._localCals[t+"-"+e]=r),!r)throw(this.local.invalidCalendar||this.regionalOptions[""].invalidCalendar).replace(/\{0\}/,t);return r},newDate:function(t,e,r,n,i){return(n=(null!=t&&t.year?t.calendar():"string"==typeof n?this.instance(n,i):n)||this.instance()).newDate(t,e,r)},substituteDigits:function(t){return function(e){return(e+"").replace(/[0-9]/g,function(e){return t[e]})}},substituteChineseDigits:function(t,e){return function(r){for(var n="",i=0;r>0;){var a=r%10;n=(0===a?"":t[a]+e[i])+n,i++,r=Math.floor(r/10)}return 0===n.indexOf(t[1]+e[1])&&(n=n.substr(1)),n||t[0]}}}),n(a.prototype,{newDate:function(t,e,r){return this._calendar.newDate(null==t?this:t,e,r)},year:function(t){return 0===arguments.length?this._year:this.set(t,"y")},month:function(t){return 0===arguments.length?this._month:this.set(t,"m")},day:function(t){return 0===arguments.length?this._day:this.set(t,"d")},date:function(t,e,r){if(!this._calendar.isValid(t,e,r))throw(c.local.invalidDate||c.regionalOptions[""].invalidDate).replace(/\{0\}/,this._calendar.local.name);return this._year=t,this._month=e,this._day=r,this},leapYear:function(){return this._calendar.leapYear(this)},epoch:function(){return this._calendar.epoch(this)},formatYear:function(){return this._calendar.formatYear(this)},monthOfYear:function(){return this._calendar.monthOfYear(this)},weekOfYear:function(){return this._calendar.weekOfYear(this)},daysInYear:function(){return this._calendar.daysInYear(this)},dayOfYear:function(){return this._calendar.dayOfYear(this)},daysInMonth:function(){return this._calendar.daysInMonth(this)},dayOfWeek:function(){return this._calendar.dayOfWeek(this)},weekDay:function(){return this._calendar.weekDay(this)},extraInfo:function(){return this._calendar.extraInfo(this)},add:function(t,e){return this._calendar.add(this,t,e)},set:function(t,e){return this._calendar.set(this,t,e)},compareTo:function(t){if(this._calendar.name!==t._calendar.name)throw(c.local.differentCalendars||c.regionalOptions[""].differentCalendars).replace(/\{0\}/,this._calendar.local.name).replace(/\{1\}/,t._calendar.local.name);var e=this._year!==t._year?this._year-t._year:this._month!==t._month?this.monthOfYear()-t.monthOfYear():this._day-t._day;return 0===e?0:e<0?-1:1},calendar:function(){return this._calendar},toJD:function(){return this._calendar.toJD(this)},fromJD:function(t){return this._calendar.fromJD(t)},toJSDate:function(){return this._calendar.toJSDate(this)},fromJSDate:function(t){return this._calendar.fromJSDate(t)},toString:function(){return(this.year()<0?"-":"")+o(Math.abs(this.year()),4)+"-"+o(this.month(),2)+"-"+o(this.day(),2)}}),n(s.prototype,{_validateLevel:0,newDate:function(t,e,r){return null==t?this.today():(t.year&&(this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),r=t.day(),e=t.month(),t=t.year()),new a(this,t,e,r))},today:function(){return this.fromJSDate(new Date)},epoch:function(t){return this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear).year()<0?this.local.epochs[0]:this.local.epochs[1]},formatYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear);return(e.year()<0?"-":"")+o(Math.abs(e.year()),4)},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear),12},monthOfYear:function(t,e){var r=this._validate(t,e,this.minDay,c.local.invalidMonth||c.regionalOptions[""].invalidMonth);return(r.month()+this.monthsInYear(r)-this.firstMonth)%this.monthsInYear(r)+this.minMonth},fromMonthOfYear:function(t,e){var r=(e+this.firstMonth-2*this.minMonth)%this.monthsInYear(t)+this.minMonth;return this._validate(t,r,this.minDay,c.local.invalidMonth||c.regionalOptions[""].invalidMonth),r},daysInYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear);return this.leapYear(e)?366:365},dayOfYear:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate);return n.toJD()-this.newDate(n.year(),this.fromMonthOfYear(n.year(),this.minMonth),this.minDay).toJD()+1},daysInWeek:function(){return 7},dayOfWeek:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate);return(Math.floor(this.toJD(n))+2)%this.daysInWeek()},extraInfo:function(t,e,r){return this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),{}},add:function(t,e,r){return this._validate(t,this.minMonth,this.minDay,c.local.invalidDate||c.regionalOptions[""].invalidDate),this._correctAdd(t,this._add(t,e,r),e,r)},_add:function(t,e,r){if(this._validateLevel++,"d"===r||"w"===r){var n=t.toJD()+e*("w"===r?this.daysInWeek():1),i=t.calendar().fromJD(n);return this._validateLevel--,[i.year(),i.month(),i.day()]}try{var a=t.year()+("y"===r?e:0),o=t.monthOfYear()+("m"===r?e:0);i=t.day();"y"===r?(t.month()!==this.fromMonthOfYear(a,o)&&(o=this.newDate(a,t.month(),this.minDay).monthOfYear()),o=Math.min(o,this.monthsInYear(a)),i=Math.min(i,this.daysInMonth(a,this.fromMonthOfYear(a,o)))):"m"===r&&(!function(t){for(;oe-1+t.minMonth;)a++,o-=e,e=t.monthsInYear(a)}(this),i=Math.min(i,this.daysInMonth(a,this.fromMonthOfYear(a,o))));var s=[a,this.fromMonthOfYear(a,o),i];return this._validateLevel--,s}catch(t){throw this._validateLevel--,t}},_correctAdd:function(t,e,r,n){if(!(this.hasYearZero||"y"!==n&&"m"!==n||0!==e[0]&&t.year()>0==e[0]>0)){var i={y:[1,1,"y"],m:[1,this.monthsInYear(-1),"m"],w:[this.daysInWeek(),this.daysInYear(-1),"d"],d:[1,this.daysInYear(-1),"d"]}[n],a=r<0?-1:1;e=this._add(t,r*i[0]+a*i[1],i[2])}return t.date(e[0],e[1],e[2])},set:function(t,e,r){this._validate(t,this.minMonth,this.minDay,c.local.invalidDate||c.regionalOptions[""].invalidDate);var n="y"===r?e:t.year(),i="m"===r?e:t.month(),a="d"===r?e:t.day();return"y"!==r&&"m"!==r||(a=Math.min(a,this.daysInMonth(n,i))),t.date(n,i,a)},isValid:function(t,e,r){this._validateLevel++;var n=this.hasYearZero||0!==t;if(n){var i=this.newDate(t,e,this.minDay);n=e>=this.minMonth&&e-this.minMonth=this.minDay&&r-this.minDay13.5?13:1),c=i-(l>2.5?4716:4715);return c<=0&&c--,this.newDate(c,l,s)},toJSDate:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),i=new Date(n.year(),n.month()-1,n.day());return i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i.setHours(i.getHours()>12?i.getHours()+2:0),i},fromJSDate:function(t){return this.newDate(t.getFullYear(),t.getMonth()+1,t.getDate())}});var c=e.exports=new i;c.cdate=a,c.baseCalendar=s,c.calendars.gregorian=l},{"object-assign":437}],548:[function(t,e,r){var n=t("object-assign"),i=t("./main");n(i.regionalOptions[""],{invalidArguments:"Invalid arguments",invalidFormat:"Cannot format a date from another calendar",missingNumberAt:"Missing number at position {0}",unknownNameAt:"Unknown name at position {0}",unexpectedLiteralAt:"Unexpected literal at position {0}",unexpectedText:"Additional text found at end"}),i.local=i.regionalOptions[""],n(i.cdate.prototype,{formatDate:function(t,e){return"string"!=typeof t&&(e=t,t=""),this._calendar.formatDate(t||"",this,e)}}),n(i.baseCalendar.prototype,{UNIX_EPOCH:i.instance().newDate(1970,1,1).toJD(),SECS_PER_DAY:86400,TICKS_EPOCH:i.instance().jdEpoch,TICKS_PER_DAY:864e9,ATOM:"yyyy-mm-dd",COOKIE:"D, dd M yyyy",FULL:"DD, MM d, yyyy",ISO_8601:"yyyy-mm-dd",JULIAN:"J",RFC_822:"D, d M yy",RFC_850:"DD, dd-M-yy",RFC_1036:"D, d M yy",RFC_1123:"D, d M yyyy",RFC_2822:"D, d M yyyy",RSS:"D, d M yy",TICKS:"!",TIMESTAMP:"@",W3C:"yyyy-mm-dd",formatDate:function(t,e,r){if("string"!=typeof t&&(r=e,e=t,t=""),!e)return"";if(e.calendar()!==this)throw i.local.invalidFormat||i.regionalOptions[""].invalidFormat;t=t||this.local.dateFormat;for(var n,a,o,s,l=(r=r||{}).dayNamesShort||this.local.dayNamesShort,c=r.dayNames||this.local.dayNames,u=r.monthNumbers||this.local.monthNumbers,f=r.monthNamesShort||this.local.monthNamesShort,h=r.monthNames||this.local.monthNames,p=(r.calculateWeek||this.local.calculateWeek,function(e,r){for(var n=1;w+n1}),d=function(t,e,r,n){var i=""+e;if(p(t,n))for(;i.length1},x=function(t,r){var n=y(t,r),a=[2,3,n?4:2,n?4:2,10,11,20]["oyYJ@!".indexOf(t)+1],o=new RegExp("^-?\\d{1,"+a+"}"),s=e.substring(A).match(o);if(!s)throw(i.local.missingNumberAt||i.regionalOptions[""].missingNumberAt).replace(/\{0\}/,A);return A+=s[0].length,parseInt(s[0],10)},b=this,_=function(){if("function"==typeof l){y("m");var t=l.call(b,e.substring(A));return A+=t.length,t}return x("m")},w=function(t,r,n,a){for(var o=y(t,a)?n:r,s=0;s-1){p=1,d=g;for(var C=this.daysInMonth(h,p);d>C;C=this.daysInMonth(h,p))p++,d-=C}return f>-1?this.fromJD(f):this.newDate(h,p,d)},determineDate:function(t,e,r,n,i){r&&"object"!=typeof r&&(i=n,n=r,r=null),"string"!=typeof n&&(i=n,n="");var a=this;return e=e?e.newDate():null,t=null==t?e:"string"==typeof t?function(t){try{return a.parseDate(n,t,i)}catch(t){}for(var e=((t=t.toLowerCase()).match(/^c/)&&r?r.newDate():null)||a.today(),o=/([+-]?[0-9]+)\s*(d|w|m|y)?/g,s=o.exec(t);s;)e.add(parseInt(s[1],10),s[2]||"d"),s=o.exec(t);return e}(t):"number"==typeof t?isNaN(t)||t===1/0||t===-1/0?e:a.today().add(t,"d"):a.newDate(t)}})},{"./main":547,"object-assign":437}],549:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array",{offset:[1],array:0},"scalar","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":134}],550:[function(t,e,r){"use strict";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t("./lib/zc-core")},{"./lib/zc-core":549}],551:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],552:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:i({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:i({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746,"../../plots/font_attributes":767,"./arrow_paths":551}],553:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach(function(e){var r=i.getFromId(t,e.xref),n=i.getFromId(t,e.yref);e._extremes={},r&&s(e,r),n&&s(e,n)})}function s(t,e){var r,n=e._id,a=n.charAt(0),o=t[a],s=t["a"+a],l=t[a+"ref"],c=t["a"+a+"ref"],u=t["_"+a+"padplus"],f=t["_"+a+"padminus"],h={x:1,y:-1}[a]*t[a+"shift"],p=3*t.arrowsize*t.arrowwidth||0,d=p+h,g=p-h,v=3*t.startarrowsize*t.arrowwidth||0,m=v+h,y=v-h;if(c===l){var x=i.findExtremes(e,[e.r2c(o)],{ppadplus:d,ppadminus:g}),b=i.findExtremes(e,[e.r2c(s)],{ppadplus:Math.max(u,m),ppadminus:Math.max(f,y)});r={min:[x.min[0],b.min[0]],max:[x.max[0],b.max[0]]}}else m=s?m+s:m,y=s?y-s:y,r=i.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(u,d,m),ppadminus:Math.max(f,g,y)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([a,o],t)}},{"../../lib":692,"../../plots/cartesian/axes":740,"./draw":558}],554:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,i,a,o,l,c,u=t._fullLayout.annotations,f=[],h=[],p=[],d=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,s,l=o(t,e),c=l.on,u=l.off.concat(l.explicitOff),f={},h=t._fullLayout.annotations;if(!c.length&&!u.length)return;for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var q=!1,H=["x","y"],G=0;G1)&&(Q===K?((lt=tt.r2fraction(e["a"+J]))<0||lt>1)&&(q=!0):q=!0),W=tt._offset+tt.r2p(e[J]),Z=.5}else"x"===J?(X=e[J],W=b.l+b.w*X):(X=1-e[J],W=b.t+b.h*X),Z=e.showarrow?.5:X;if(e.showarrow){st.head=W;var ct=e["a"+J];$=rt*U(.5,e.xanchor)-nt*U(.5,e.yanchor),Q===K?(st.tail=tt._offset+tt.r2p(ct),Y=$):(st.tail=W+ct,Y=$+ct),st.text=st.tail+$;var ut=x["x"===J?"width":"height"];if("paper"===K&&(st.head=o.constrain(st.head,1,ut-1)),"pixel"===Q){var ft=-Math.max(st.tail-3,st.text),ht=Math.min(st.tail+3,st.text)-ut;ft>0?(st.tail+=ft,st.text+=ft):ht>0&&(st.tail-=ht,st.text-=ht)}st.tail+=ot,st.head+=ot}else Y=$=it*U(Z,at),st.text=W+$;st.text+=ot,$+=ot,Y+=ot,e["_"+J+"padplus"]=it/2+Y,e["_"+J+"padminus"]=it/2-Y,e["_"+J+"size"]=it,e["_"+J+"shift"]=$}if(t._dragging||!q){var pt=0,dt=0;if("left"!==e.align&&(pt=(w-m)*("center"===e.align?.5:1)),"top"!==e.valign&&(dt=(O-y)*("middle"===e.valign?.5:1)),u)n.select("svg").attr({x:R+pt-1,y:R+dt}).call(c.setClipUrl,B?T:null,t);else{var gt=R+dt-d.top,vt=R+pt-d.left;V.call(f.positionText,vt,gt).call(c.setClipUrl,B?T:null,t)}N.select("rect").call(c.setRect,R,R,w,O),F.call(c.setRect,P/2,P/2,D-P,j-P),I.call(c.setTranslate,Math.round(S.x.text-D/2),Math.round(S.y.text-j/2)),L.attr({transform:"rotate("+C+","+S.x.text+","+S.y.text+")"});var mt,yt=function(r,n){E.selectAll(".annotation-arrow-g").remove();var u=S.x.head,f=S.y.head,h=S.x.tail+r,d=S.y.tail+n,m=S.x.text+r,y=S.y.text+n,x=o.rotationXYMatrix(C,m,y),w=o.apply2DTransform(x),T=o.apply2DTransform2(x),z=+F.attr("width"),O=+F.attr("height"),P=m-.5*z,D=P+z,R=y-.5*O,B=R+O,N=[[P,R,P,B],[P,B,D,B],[D,B,D,R],[D,R,P,R]].map(T);if(!N.reduce(function(t,e){return t^!!o.segmentsIntersect(u,f,u+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){N.forEach(function(t){var e=o.segmentsIntersect(h,d,u,f,t[0],t[1],t[2],t[3]);e&&(h=e.x,d=e.y)});var j=e.arrowwidth,V=e.arrowcolor,U=e.arrowside,q=E.append("g").style({opacity:l.opacity(V)}).classed("annotation-arrow-g",!0),H=q.append("path").attr("d","M"+h+","+d+"L"+u+","+f).style("stroke-width",j+"px").call(l.stroke,l.rgb(V));if(g(H,U,e),_.annotationPosition&&H.node().parentNode&&!a){var G=u,W=f;if(e.standoff){var Y=Math.sqrt(Math.pow(u-h,2)+Math.pow(f-d,2));G+=e.standoff*(h-u)/Y,W+=e.standoff*(d-f)/Y}var X,Z,$=q.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(h-G)+","+(d-W),transform:"translate("+G+","+W+")"}).style("stroke-width",j+6+"px").call(l.stroke,"rgba(0,0,0,0)").call(l.fill,"rgba(0,0,0,0)");p.init({element:$.node(),gd:t,prepFn:function(){var t=c.getTranslate(I);X=t.x,Z=t.y,s&&s.autorange&&k(s._name+".autorange",!0),v&&v.autorange&&k(v._name+".autorange",!0)},moveFn:function(t,r){var n=w(X,Z),i=n[0]+t,a=n[1]+r;I.call(c.setTranslate,i,a),M("x",s?s.p2r(s.r2p(e.x)+t):e.x+t/b.w),M("y",v?v.p2r(v.r2p(e.y)+r):e.y-r/b.h),e.axref===e.xref&&M("ax",s.p2r(s.r2p(e.ax)+t)),e.ayref===e.yref&&M("ay",v.p2r(v.r2p(e.ay)+r)),q.attr("transform","translate("+t+","+r+")"),L.attr({transform:"rotate("+C+","+i+","+a+")"})},doneFn:function(){i.call("_guiRelayout",t,A());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&yt(0,0),z)p.init({element:I.node(),gd:t,prepFn:function(){mt=L.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?M("ax",s.p2r(s.r2p(e.ax)+t)):M("ax",e.ax+t),e.ayref===e.yref?M("ay",v.p2r(v.r2p(e.ay)+r)):M("ay",e.ay+r),yt(t,r);else{if(a)return;var i,o;if(s)i=s.p2r(s.r2p(e.x)+t);else{var l=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-l/2;i=p.align(c+t/b.w,l,0,1,e.xanchor)}if(v)o=v.p2r(v.r2p(e.y)+r);else{var u=e._ysize/b.h,f=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(f-r/b.h,u,0,1,e.yanchor)}M("x",i),M("y",o),s&&v||(n=p.getCursor(s?.5:i,v?.5:o,e.xanchor,e.yanchor))}L.attr({transform:"translate("+t+","+r+")"+mt}),h(I,n)},doneFn:function(){h(I),i.call("_guiRelayout",t,A());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}else I.remove()}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,v=e.indexOf("end")>=0,m=f.backoff*p+r.standoff,y=h.backoff*d+r.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},s={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-s.x,b=o.y-s.y;if(c=(l=Math.atan2(b,x))+Math.PI,m&&y&&m+y>Math.sqrt(x*x+b*b))return void z();if(m){if(m*m>x*x+b*b)return void z();var _=m*Math.cos(l),w=m*Math.sin(l);s.x+=_,s.y+=w,t.attr({x2:s.x,y2:s.y})}if(y){if(y*y>x*x+b*b)return void z();var k=y*Math.cos(l),M=y*Math.sin(l);o.x-=k,o.y-=M,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var A=u.getTotalLength(),T="";if(A1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l._pdata=i(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*r[0],e.yaxis.r2l(l.y)*r[1],e.zaxis.r2l(l.z)*r[2]]),n(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":792,"../annotations/draw":558}],565:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(!r)return;for(var a=r.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return a?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}a.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},a.rgb=function(t){return a.tinyRGB(n(t))},a.opacity=function(t){return t?n(t).getAlpha():0},a.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},a.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var i=n(e||l).toRgb(),a=1===i.a?i:{r:255*(1-i.a)+i.r*i.a,g:255*(1-i.a)+i.g*i.a,b:255*(1-i.a)+i.b*i.a},o={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},a.contrast=function(t,e,r){var i=n(t);return 1!==i.getAlpha()&&(i=n(a.combine(t,l))),(i.isDark()?e?i.lighten(e):l:r?i.darken(r):s).toString()},a.stroke=function(t,e){var r=n(e);t.style({stroke:a.tinyRGB(r),"stroke-opacity":r.getAlpha()})},a.fill=function(t,e){var r=n(e);t.style({fill:a.tinyRGB(r),"fill-opacity":r.getAlpha()})},a.clean=function(t){if(t&&"object"==typeof t){var e,r,n,i,o=Object.keys(t);for(e=0;e0?C>=D:C<=D));E++)C>F&&C0?C>=D:C<=D));E++)C>L[0]&&C1){var ot=Math.pow(10,Math.floor(Math.log(at)/Math.LN10));nt*=ot*c.roundUp(at/ot,[2,5,10]),(Math.abs(r.levels.start)/r.levels.size+1e-6)%1<2e-6&&(et.tick0=0)}et.dtick=nt}et.domain=[J+X,J+G-X],et.setScale();var st=c.ensureSingle(v._infolayer,"g",e,function(t){t.classed(M.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(M.cbbg,!0),t.append("g").classed(M.cbfills,!0),t.append("g").classed(M.cblines,!0),t.append("g").classed(M.cbaxis,!0).classed(M.crisp,!0),t.append("g").classed(M.cbtitleunshift,!0).append("g").classed(M.cbtitle,!0),t.append("rect").classed(M.cboutline,!0),t.select(".cbtitle").datum(0)})});st.attr("transform","translate("+Math.round(k.l)+","+Math.round(k.t)+")");var lt=st.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(k.l)+",-"+Math.round(k.t)+")"),ct=st.select(".cbaxis"),ut=0;if(-1!==["top","bottom"].indexOf(r.title.side)){var ft,ht=k.l+(r.x+W)*k.w,pt=et.title.font.size;ft="top"===r.title.side?(1-(J+G-X))*k.h+k.t+3+.75*pt:(1-(J+X))*k.h+k.t-3-.25*pt,xt(et._id+"title",{attributes:{x:ht,y:ft,"text-anchor":"start"}})}var dt,gt,vt,mt=c.syncOrAsync([a.previousPromises,function(){if(-1!==["top","bottom"].indexOf(r.title.side)){var a=st.select(".cbtitle"),o=a.select("text"),l=[-r.outlinewidth/2,r.outlinewidth/2],u=a.select(".h"+et._id+"title-math-group").node(),f=15.6;if(o.node()&&(f=parseInt(o.node().style.fontSize,10)*m),u?(ut=h.bBox(u).height)>f&&(l[1]-=(ut-f)/2):o.node()&&!o.classed(M.jsPlaceholder)&&(ut=h.bBox(o.node()).height),ut){if(ut+=5,"top"===r.title.side)et.domain[1]-=ut/k.h,l[1]*=-1;else{et.domain[0]+=ut/k.h;var p=g.lineCount(o);l[1]+=(1-p)*f}a.attr("transform","translate("+l+")"),et.setScale()}}st.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(k.h*(1-et.domain[1]))+")"),ct.attr("transform","translate(0,"+Math.round(-k.t)+")");var d=st.select(".cbfills").selectAll("rect.cbfill").data(O);d.enter().append("rect").classed(M.cbfill,!0).style("stroke","none"),d.exit().remove();var y=L.map(et.c2p).map(Math.round).sort(function(t,e){return t-e});d.each(function(a,o){var s=[0===o?L[0]:(O[o]+O[o-1])/2,o===O.length-1?L[1]:(O[o]+O[o+1])/2].map(et.c2p).map(Math.round);s[1]=c.constrain(s[1]+(s[1]>s[0])?1:-1,y[0],y[1]);var l=n.select(this).attr({x:Z,width:Math.max(U,2),y:n.min(s),height:Math.max(n.max(s)-n.min(s),2)});if(r.fillgradient)h.gradient(l,t,e,"vertical",r.fillgradient,"fill");else{var u=P(a).replace("e-","");l.attr("fill",i(u).toHexString())}});var x=st.select(".cblines").selectAll("path.cbline").data(r.line.color&&r.line.width?z:[]);return x.enter().append("path").classed(M.cbline,!0),x.exit().remove(),x.each(function(t){n.select(this).attr("d","M"+Z+","+(Math.round(et.c2p(t))+r.line.width/2%1)+"h"+U).call(h.lineGroupStyle,r.line.width,I(t),r.line.dash)}),ct.selectAll("g."+et._id+"tick,path").remove(),c.syncOrAsync([function(){var e=Z+U+(r.outlinewidth||0)/2-("outside"===r.ticks?1:0),n=s.calcTicks(et),i=s.makeTransFn(et),a=s.makeLabelFns(et,e),o=s.getTickSigns(et)[2];return s.drawTicks(t,et,{vals:"inside"===et.ticks?s.clipEnds(et,n):n,layer:ct,path:s.makeTickPath(et,e,o),transFn:i}),s.drawLabels(t,et,{vals:n,layer:ct,transFn:i,labelXFn:a.labelXFn,labelYFn:a.labelYFn,labelAnchorFn:a.labelAnchorFn})},function(){if(-1===["top","bottom"].indexOf(r.title.side)){var e=et.title.font.size,i=et._offset+et._length/2,a=k.l+(et.position||0)*k.w+("right"===et.side?10+e*(et.showticklabels?1:.5):-10-e*(et.showticklabels?.5:0));xt("h"+et._id+"title",{avoid:{selection:n.select(t).selectAll("g."+et._id+"tick"),side:r.title.side,offsetLeft:k.l,offsetTop:0,maxShift:v.width},attributes:{x:a,y:i,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},a.previousPromises,function(){var n=U+r.outlinewidth/2+h.bBox(ct.node()).width;if((N=lt.select("text")).node()&&!N.classed(M.jsPlaceholder)){var i,o=lt.select(".h"+et._id+"title-math-group").node();i=o&&-1!==["top","bottom"].indexOf(r.title.side)?h.bBox(o).width:h.bBox(lt.node()).right-Z-k.l,n=Math.max(n,i)}var s=2*r.xpad+n+r.borderwidth+r.outlinewidth/2,l=K-Q;st.select(".cbbg").attr({x:Z-r.xpad-(r.borderwidth+r.outlinewidth)/2,y:Q-Y,width:Math.max(s,2),height:Math.max(l+2*Y,2)}).call(p.fill,r.bgcolor).call(p.stroke,r.bordercolor).style({"stroke-width":r.borderwidth}),st.selectAll(".cboutline").attr({x:Z,y:Q+r.ypad+("top"===r.title.side?ut:0),width:Math.max(U,2),height:Math.max(l-2*r.ypad-ut,2)}).call(p.stroke,r.outlinecolor).style({fill:"None","stroke-width":r.outlinewidth});var c=({center:.5,right:1}[r.xanchor]||0)*s;st.attr("transform","translate("+(k.l-c)+","+k.t+")");var u={},f=y[r.yanchor],d=x[r.yanchor];"pixels"===r.lenmode?(u.y=r.y,u.t=l*f,u.b=l*d):(u.t=u.b=0,u.yt=r.y+r.len*f,u.yb=r.y-r.len*d);var g=y[r.xanchor],v=x[r.xanchor];if("pixels"===r.thicknessmode)u.x=r.x,u.l=s*g,u.r=s*v;else{var m=s-U;u.l=m*g,u.r=m*v,u.xl=r.x-r.thickness*g,u.xr=r.x+r.thickness*v}a.autoMargin(t,e,u)}],t);if(mt&&mt.then&&(t._promises||[]).push(mt),t._context.edits.colorbarPosition)l.init({element:st.node(),gd:t,prepFn:function(){dt=st.attr("transform"),f(st)},moveFn:function(t,e){st.attr("transform",dt+" translate("+t+","+e+")"),gt=l.align($+t/k.w,q,0,1,r.xanchor),vt=l.align(J-e/k.h,G,0,1,r.yanchor);var n=l.getCursor(gt,vt,r.xanchor,r.yanchor);f(st,n)},doneFn:function(){if(f(st),void 0!==gt&&void 0!==vt){var e={};e[S("x")]=gt,e[S("y")]=vt,o.call("_guiRestyle",t,e,T().index)}}});return mt}function yt(t,e){return c.coerce(tt,et,w,t,e)}function xt(e,r){var n={propContainer:et,propName:S("title"),traceIndex:T().index,placeholder:v._dfltTitle.colorbar,containerGroup:st.select(".cbtitle")},i="h"===e.charAt(0)?e.substr(1):"h"+e;st.selectAll("."+i+",."+i+"-math-group").remove(),d.draw(t,e,u(n,r||{}))}v._infolayer.selectAll("g."+e).remove()}function T(){var r,n,i=e.substr(2);for(r=0;r=0?i.colorscale.sequential:i.colorscale.sequentialminus,l._colorscale=l.colorscale=d)}},{"../../lib":692}],578:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./helpers").hasColorscale;e.exports=function(t){function e(t,e){var r=t["_"+e];void 0!==r&&(t[e]=r)}function r(t,r){var i=r.container?n.nestedProperty(t,r.container).get():t;if(i){var a=i.zauto||i.cauto,o=r.min,s=r.max;(a||void 0===i[o])&&e(i,o),(a||void 0===i[s])&&e(i,s),i.autocolorscale&&e(i,"colorscale")}}for(var a=0;a=0;n--,i++){var a=t[n];r[i]=[1-a[0],a[1]]}return r}function u(t){var e={r:t[0],g:t[1],b:t[2],a:t[3]};return i(e).toRgbString()}e.exports={hasColorscale:function(t,e){var r=e?o.nestedProperty(t,e).get()||{}:t,n=r.color,i=!1;if(o.isArrayOrTypedArray(n))for(var s=0;s4/3-s?o:s}},{}],586:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":692}],587:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),i=t("has-hover"),a=t("has-passive-events"),o=t("../../registry"),s=t("../../lib"),l=t("../../plots/cartesian/constants"),c=t("../../constants/interactions"),u=e.exports={};u.align=t("./align"),u.getCursor=t("./cursor");var f=t("./unhover");function h(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function p(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}u.unhover=f.wrapped,u.unhoverRaw=f.raw,u.init=function(t){var e,r,n,f,d,g,v,m,y=t.gd,x=1,b=c.DBLCLICKDELAY,_=t.element;y._mouseDownTime||(y._mouseDownTime=0),_.style.pointerEvents="all",_.onmousedown=k,a?(_._ontouchstart&&_.removeEventListener("touchstart",_._ontouchstart),_._ontouchstart=k,_.addEventListener("touchstart",k,{passive:!1})):_.ontouchstart=k;var w=t.clampFn||function(t,e,r){return Math.abs(t)b&&(x=Math.max(x-1,1)),y._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(x,g),!m){var r;try{r=new MouseEvent("click",e)}catch(t){var n=p(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}v.dispatchEvent(r)}!function(t){t._dragging=!1,t._replotPending&&o.call("plot",t)}(y),y._dragged=!1}else y._dragged=!1}},u.coverSlip=h},{"../../constants/interactions":668,"../../lib":692,"../../plots/cartesian/constants":746,"../../registry":823,"./align":585,"./cursor":586,"./unhover":588,"has-hover":393,"has-passive-events":394,"mouse-event-offset":419}],588:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=t("../../lib/throttle"),a=t("../../lib/get_graph_div"),o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,r){(t=a(t))._fullLayout&&i.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,r)},s.raw=function(t,e){var r=t._fullLayout,i=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&i&&t.emit("plotly_unhover",{event:e,points:i}))}},{"../../lib/events":681,"../../lib/get_graph_div":688,"../../lib/throttle":717,"../fx/constants":602}],589:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],590:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("tinycolor2"),o=t("../../registry"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,d=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),v=e.exports={};v.font=function(t,e,r,n){c.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,i){t.call(v.setPosition,e,r).call(v.setSize,n,i)},v.translatePoint=function(t,e,r,n){var a=r.c2p(t.x),o=n.c2p(t.y);return!!(i(a)&&i(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",a).attr("y",o):e.attr("transform","translate("+a+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each(function(t){var i=n.select(this);v.translatePoint(t,i,e,r)})},v.hideOutsideRangePoint=function(t,e,r,n,i,a){e.attr("display",r.isPtWithinRange(t,i)&&n.isPtWithinRange(t,a)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,i=e.yaxis;t.each(function(e){var a=e[0].trace,o=a.xcalendar,s=a.ycalendar,l="bar"===a.type?".bartext":".point,.textpoint";t.selectAll(l).each(function(t){v.hideOutsideRangePoint(t,n.select(this),r,i,o,s)})})}},v.crispRound=function(t,e,r){return e&&i(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,i){e.style("fill","none");var a=(((t||[])[0]||{}).trace||{}).line||{},o=r||a.width||0,l=i||a.dash||"";s.stroke(e,n||a.color),v.dashLine(e,l,o)},v.lineGroupStyle=function(t,e,r,i){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=i||a.dash||"";n.select(this).call(s.stroke,r||a.color).call(v.dashLine,l,o)})},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(s.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(t){var e=n.select(this);t[0].trace&&e.call(s.fill,t[0].trace.fillcolor)})};var m=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(m).forEach(function(t){var e=m[t];v.symbolList=v.symbolList.concat([e.n,t,e.n+100,t+"-open"]),v.symbolNames[e.n]=t,v.symbolFuncs[e.n]=e.f,e.needLine&&(v.symbolNeedLines[e.n]=!0),e.noDot?v.symbolNoDot[e.n]=!0:v.symbolList=v.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"]),e.noFill&&(v.symbolNoFill[e.n]=!0)});var y=v.symbolNames.length,x="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function b(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?x:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=y||t>=400?0:Math.floor(Math.max(t,0))};var _={x1:1,x2:0,y1:0,y2:0},w={x1:0,x2:0,y1:1,y2:0},k=n.format("~.1f"),M={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:_},horizontalreversed:{node:"linearGradient",attrs:_,reversed:!0},vertical:{node:"linearGradient",attrs:w},verticalreversed:{node:"linearGradient",attrs:w,reversed:!0}};v.gradient=function(t,e,r,i,o,l){for(var u=o.length,f=M[i],h=new Array(u),p=0;p=100,e.attr("d",b(u,l))}var f,h,p,d=!1;if(t.so)p=o.outlierwidth,h=o.outliercolor,f=a.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,h="mlc"in t?t.mlcc=n.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?s.defaultLine:o.color,c.isArrayOrTypedArray(a.color)&&(f=s.defaultLine,d=!0),f="mc"in t?t.mcc=n.markerScale(t.mc):a.color||"rgba(0,0,0,0)",n.selectedColorFn&&(f=n.selectedColorFn(t))}if(t.om)e.call(s.stroke,f).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var m=a.gradient,y=t.mgt;if(y?d=!0:y=m&&m.type,Array.isArray(y)&&(y=y[0],M[y]||(y=0)),y&&"none"!==y){var x=t.mgc;x?d=!0:x=m.color;var _=r.uid;d&&(_+="-"+t.i),v.gradient(e,i,_,y,[[0,x],[1,f]],"fill")}else s.fill(e,f);p&&s.stroke(e,h)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=d.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.marker||{},a=r.marker||{},s=n.marker||{},l=i.opacity,u=a.opacity,f=s.opacity,h=void 0!==u,d=void 0!==f;(c.isArrayOrTypedArray(l)||h||d)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?i.opacity:t.mo;return t.selected?h?u:e:d?f:p*e});var g=i.color,v=a.color,m=s.color;(v||m)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?v||e:m||e});var y=i.size,x=a.size,b=s.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||y/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.textfont||{},a=r.textfont||{},o=n.textfont||{},l=i.color,c=a.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||l;return t.selected?c||e:u||(c?e:s.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),i=e.marker||{},a=[];r.selectedOpacityFn&&a.push(function(t,e){t.style("opacity",r.selectedOpacityFn(e))}),r.selectedColorFn&&a.push(function(t,e){s.fill(t,r.selectedColorFn(e))}),r.selectedSizeFn&&a.push(function(t,e){var n=e.mx||i.symbol||0,a=r.selectedSizeFn(e);t.attr("d",b(v.symbolNumber(n),a)),e.mrc2=a}),a.length&&t.each(function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var i;if(e.selectedpoints){var a=v.makeSelectedTextStyleFns(e);i=a.selectedTextColorFn}t.each(function(t){var a=n.select(this),o=c.extractOption(t,e,"tx","text");if(o||0===o){var s=t.tp||e.textposition,l=S(t,e),f=i?i(t):t.tc||e.textfont.color;a.call(v.font,t.tf||e.textfont.family,l,f).text(o).call(u.convertToTspans,r).call(T,s,l,t.mrc)}else a.remove()})}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each(function(t){var i=n.select(this),a=r.selectedTextColorFn(t),o=t.tp||e.textposition,l=S(t,e);s.fill(i,a),T(i,o,l,t.mrc2||t.mrc)})}};var C=.5;function E(t,e,r,i){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,C/2),u=Math.pow(s*s+l*l,C/2),f=(u*u*a-c*c*s)*i,h=(u*u*o-c*c*l)*i,p=3*u*(c+u),d=3*c*(c+u);return[[n.round(e[0]+(p&&f/p),2),n.round(e[1]+(p&&h/p),2)],[n.round(e[0]-(d&&f/d),2),n.round(e[1]-(d&&h/d),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],i=[];for(r=1;r=1e4&&(v.savedBBoxes={},O=0),r&&(v.savedBBoxes[r]=m),O++,c.extendFlat({},m)},v.setClipUrl=function(t,e,r){if(e){var n=r._context,i=n._exportedPlot?"":n._baseUrl||"";t.attr("clip-path","url("+i+"#"+e+")")}else t.attr("clip-path",null)},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||0,r=r||0,a=a.replace(/(\btranslate\(.*?\);?)/,"").trim(),a=(a+=" translate("+e+", "+r+")").trim(),t[i]("transform",a),a},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||1,r=r||1,a=a.replace(/(\bscale\(.*?\);?)/,"").trim(),a=(a+=" scale("+e+", "+r+")").trim(),t[i]("transform",a),a};var P=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each(function(){var t=(this.getAttribute("transform")||"").replace(P,"");t=(t+=n).trim(),this.setAttribute("transform",t)})}};var D=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each(function(){var t,i=n.select(this),a=i.select("text");if(a.node()){var o=parseFloat(a.attr("x")||0),s=parseFloat(a.attr("y")||0),l=(i.attr("transform")||"").match(D);t=1===e&&1===r?[]:["translate("+o+","+s+")","scale("+e+","+r+")","translate("+-o+","+-s+")"],l&&t.push(l),i.attr("transform",t.join(" "))}})}},{"../../constants/alignment":664,"../../constants/interactions":668,"../../constants/xmlns_namespaces":670,"../../lib":692,"../../lib/svg_text_utils":716,"../../registry":823,"../../traces/scatter/make_bubble_size_func":1057,"../../traces/scatter/subtypes":1064,"../color":569,"../colorscale":581,"./symbol_defs":591,d3:148,"fast-isnumeric":214,tinycolor2:513}],591:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(-.309*t,2);return"M"+e+","+a+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:148}],592:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],593:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../registry"),a=t("../../plots/cartesian/axes"),o=t("./compute_error");function s(t,e,r,i){var s=e["error_"+i]||{},l=[];if(s.visible&&-1!==["linear","log"].indexOf(r.type)){for(var c=o(s),u=0;u0;e.each(function(e){var f,h=e[0].trace,p=h.error_x||{},d=h.error_y||{};h.ids&&(f=function(t){return t.id});var g=o.hasMarkers(h)&&h.marker.maxdisplayed>0;d.visible||p.visible||(e=[]);var v=n.select(this).selectAll("g.errorbar").data(e,f);if(v.exit().remove(),e.length){p.visible||v.selectAll("path.xerror").remove(),d.visible||v.selectAll("path.yerror").remove(),v.style("opacity",1);var m=v.enter().append("g").classed("errorbar",!0);u&&m.style("opacity",0).transition().duration(s.duration).style("opacity",1),a.setClipUrl(v,r.layerClipId,t),v.each(function(t){var e=n.select(this),r=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),i(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0)));void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),i(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0)));return n}(t,l,c);if(!g||t.vis){var a,o=e.select("path.yerror");if(d.visible&&i(r.x)&&i(r.yh)&&i(r.ys)){var f=d.width;a="M"+(r.x-f)+","+r.yh+"h"+2*f+"m-"+f+",0V"+r.ys,r.noYS||(a+="m-"+f+",0h"+2*f),!o.size()?o=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):u&&(o=o.transition().duration(s.duration).ease(s.easing)),o.attr("d",a)}else o.remove();var h=e.select("path.xerror");if(p.visible&&i(r.y)&&i(r.xh)&&i(r.xs)){var v=(p.copy_ystyle?d:p).width;a="M"+r.xh+","+(r.y-v)+"v"+2*v+"m0,-"+v+"H"+r.xs,r.noXS||(a+="m0,-"+v+"v"+2*v),!h.size()?h=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):u&&(h=h.transition().duration(s.duration).ease(s.easing)),h.attr("d",a)}else h.remove()}})}})}},{"../../traces/scatter/subtypes":1064,"../drawing":590,d3:148,"fast-isnumeric":214}],598:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":569,d3:148}],599:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":767}],600:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry");function a(t,e,r,i){i=i||n.identity,Array.isArray(t)&&(e[0][r]=i(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var s=0;s=0&&r.indexw[0]._length||et<0||et>k[0]._length)return h.unhoverRaw(t,e)}if(e.pointerX=tt+w[0]._offset,e.pointerY=et+k[0]._offset,D="xval"in e?g.flat(l,e.xval):g.p2c(w,tt),R="yval"in e?g.flat(l,e.yval):g.p2c(k,et),!i(D[0])||!i(R[0]))return o.warn("Fx.hover failed",e,t),h.unhoverRaw(t,e)}var it=1/0;for(B=0;BY&&($.splice(0,Y),it=$[0].distance),y&&0!==Z&&0===$.length){W.distance=Z,W.index=!1;var ct=j._module.hoverPoints(W,H,G,"closest",u._hoverlayer);if(ct&&(ct=ct.filter(function(t){return t.spikeDistance<=Z})),ct&&ct.length){var ut,ft=ct.filter(function(t){return t.xa.showspikes});if(ft.length){var ht=ft[0];i(ht.x0)&&i(ht.y0)&&(ut=vt(ht),(!K.vLinePoint||K.vLinePoint.spikeDistance>ut.spikeDistance)&&(K.vLinePoint=ut))}var pt=ct.filter(function(t){return t.ya.showspikes});if(pt.length){var dt=pt[0];i(dt.x0)&&i(dt.y0)&&(ut=vt(dt),(!K.hLinePoint||K.hLinePoint.spikeDistance>ut.spikeDistance)&&(K.hLinePoint=ut))}}}}function gt(t,e){for(var r,n=null,i=1/0,a=0;a1||$.length>1)||"closest"===P&&Q&&$.length>1,zt=f.combine(u.plot_bgcolor||f.background,u.paper_bgcolor),Ot={hovermode:P,rotateLabels:Lt,bgColor:zt,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},It=A($,Ot,t);if(function(t,e,r){var n,i,a,o,s,l,c,u=0,f=1,h=t.map(function(t,n){var i=t[e],a="x"===i._id.charAt(0),o=i.range;return!n&&o&&o[0]>o[1]!==a&&(f=-1),[{i:n,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(a?x:1)/2,pmin:0,pmax:a?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref||f*(e[0].traceIndex-t[0].traceIndex)});function p(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(a<.01)){if(i<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(l=t[o]).pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(c<=0);o--)(l=t[o]).pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(;!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&v.pmin===m.pmin&&v.pmax===m.pmax){for(s=g.length-1;s>=0;s--)g[s].dp+=i;for(d.push.apply(d,g),h.splice(o+1,1),c=0,s=d.length-1;s>=0;s--)c+=d[s].dp;for(a=c/d.length,s=d.length-1;s>=0;s--)d[s].dp-=a;n=!1}else o++}h.forEach(p)}for(o=h.length-1;o>=0;o--){var y=h[o];for(s=y.length-1;s>=0;s--){var b=y[s],_=t[b.i];_.offset=b.dp,_.del=b.del}}}($,Lt?"xa":"ya",u),T(It,Lt),e.target&&e.target.tagName){var Pt=d.getComponentMethod("annotations","hasClickToShow")(t,Tt);c(n.select(e.target),Pt?"pointer":"")}if(!e.target||a||!function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber)||String(i.pointNumbers)!==String(a.pointNumbers))return!0}return!1}(t,0,At))return;At&&t.emit("plotly_unhover",{event:e,points:At});t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:w,yaxes:k,xvals:D,yvals:R})}(t,e,r,a)})},r.loneHover=function(t,e){var r={color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1},i=n.select(e.container),a=e.outerContainer?n.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=A([r],o,e.gd);return T(s,o.rotateLabels),s.node()},r.multiHovers=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return{color:t.color||f.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1}}),i=n.select(e.container),a=e.outerContainer?n.select(e.outerContainer):i,o={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||f.background,container:i,outerContainer:a},s=A(r,o,e.gd),l=0;return s.sort(function(t,e){return t.y0-e.y0}).each(function(t){var e=t.y0-t.by/2;t.offset=e-5([\s\S]*)<\/extra>/;function A(t,e,r){var i=e.hovermode,a=e.rotateLabels,s=e.bgColor,c=e.container,h=e.outerContainer,p=e.commonLabelOpts||{},d=e.fontFamily||v.HOVERFONT,g=e.fontSize||v.HOVERFONTSIZE,y=t[0],x=y.xa,b=y.ya,_="y"===i?"yLabel":"xLabel",A=y[_],T=(String(A)||"").split(" ")[0],S=h.node().getBoundingClientRect(),C=S.top,E=S.width,L=S.height,z=void 0!==A&&y.distance<=e.hoverdistance&&("x"===i||"y"===i);if(z){var O,I,P=!0;for(O=0;O-1&&c.length>b&&(c=b>3?c.substr(0,b-3)+"...":c.substr(0,b))}void 0!==t.zLabel?(void 0!==t.xLabel&&(h+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(h+="y: "+t.yLabel+"
"),h+=(h?"z: ":"")+t.zLabel):z&&t[i+"Label"]===A?h=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(h=t.yLabel):h=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(h+=(h?"
":"")+t.text),void 0!==t.extraText&&(h+=(h?"
":"")+t.extraText),""===h&&(""===c&&e.remove(),h=c);var _=t.hovertemplate||!1,T=t.hovertemplateLabels||t,S=t.eventData[0]||{};_&&(h=(h=o.hovertemplateString(_,T,S)).replace(M,function(t,e){return c=e,""}));var O=e.select("text.nums").call(u.font,t.fontFamily||d,t.fontSize||g,t.fontColor||x).text(h).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),I=e.select("text.name"),P=0;c&&c!==h?(I.call(u.font,t.fontFamily||d,t.fontSize||g,y).text(c).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),P=I.node().getBoundingClientRect().width+2*k):(I.remove(),e.select("rect").remove()),e.select("path").style({fill:v,stroke:x});var D,R,F=O.node().getBoundingClientRect(),B=t.xa._offset+(t.x0+t.x1)/2,N=t.ya._offset+(t.y0+t.y1)/2,j=Math.abs(t.x1-t.x0),V=Math.abs(t.y1-t.y0),U=F.width+w+k+P;t.ty0=C-F.top,t.bx=F.width+2*k,t.by=F.height+2*k,t.anchor="start",t.txwidth=F.width,t.tx2width=P,t.offset=0,a?(t.pos=B,D=N+V/2+U<=L,R=N-V/2-U>=0,"top"!==t.idealAlign&&D||!R?D?(N+=V/2,t.anchor="start"):t.anchor="middle":(N-=V/2,t.anchor="end")):(t.pos=N,D=B+j/2+U<=E,R=B-j/2-U>=0,"left"!==t.idealAlign&&D||!R?D?(B+=j/2,t.anchor="start"):t.anchor="middle":(B-=j/2,t.anchor="end")),O.attr("text-anchor",t.anchor),P&&I.attr("text-anchor",t.anchor),e.attr("transform","translate("+B+","+N+")"+(a?"rotate("+m+")":""))}),F}function T(t,e){t.each(function(t){var r=n.select(this);if(t.del)r.remove();else{var i="end"===t.anchor?-1:1,a=r.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],s=o*(w+k),c=s+o*(t.txwidth+k),f=0,h=t.offset;"middle"===t.anchor&&(s-=t.tx2width/2,c+=t.txwidth/2+k),e&&(h*=-_,f=t.offset*b),r.select("path").attr("d","middle"===t.anchor?"M-"+(t.bx/2+t.tx2width/2)+","+(h-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(i*w+f)+","+(w+h)+"v"+(t.by/2-w)+"h"+i*t.bx+"v-"+t.by+"H"+(i*w+f)+"V"+(h-w)+"Z"),a.call(l.positionText,s+f,h+t.ty0-t.by/2+k),t.tx2width&&(r.select("text.name").call(l.positionText,c+o*k+f,h+t.ty0-t.by/2+k),r.select("rect").call(u.setRect,c+(o-1)*t.tx2width/2+f,h-t.by/2-1,t.tx2width,t.by+2))}})}function S(t,e){var r=t.index,n=t.trace||{},i=t.cd[0],a=t.cd[r]||{},s=Array.isArray(r)?function(t,e){return o.castOption(i,r,t)||o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(a,n,t,e)};function l(e,r,n){var i=s(r,n);i&&(t[e]=i)}if(l("hoverinfo","hi","hoverinfo"),l("bgcolor","hbg","hoverlabel.bgcolor"),l("borderColor","hbc","hoverlabel.bordercolor"),l("fontFamily","htf","hoverlabel.font.family"),l("fontSize","hts","hoverlabel.font.size"),l("fontColor","htc","hoverlabel.font.color"),l("nameLength","hnl","hoverlabel.namelength"),t.posref="y"===e?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var c=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+c+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" \xb1 "+c,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var u=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+u+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" \xb1 "+u,"y"===e&&(t.distance+=1)}var f=t.hoverinfo||t.trace.hoverinfo;return f&&"all"!==f&&(-1===(f=Array.isArray(f)?f:f.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===f.indexOf("y")&&(t.yLabel=void 0),-1===f.indexOf("z")&&(t.zLabel=void 0),-1===f.indexOf("text")&&(t.text=void 0),-1===f.indexOf("name")&&(t.name=void 0)),t}function C(t,e){var r,n,i=e.container,o=e.fullLayout,s=e.event,l=!!t.hLinePoint,c=!!t.vLinePoint;if(i.selectAll(".spikeline").remove(),c||l){var h=f.combine(o.plot_bgcolor,o.paper_bgcolor);if(l){var p,d,g=t.hLinePoint;r=g&&g.xa,"cursor"===(n=g&&g.ya).spikesnap?(p=s.pointerX,d=s.pointerY):(p=r._offset+g.x,d=n._offset+g.y);var v,m,y=a.readability(g.color,h)<1.5?f.contrast(h):g.color,x=n.spikemode,b=n.spikethickness,_=n.spikecolor||y,w=n._boundingBox,k=(w.left+w.right)/20){for(var n=[],i=0;i-1?o="closest":(e._isHoriz=function(t){for(var e=!0,r=0;r1){h||p||d||"independent"===M("pattern")&&(h=!0),v._hasSubplotGrid=h;var x,b,_="top to bottom"===M("roworder"),w=h?.2:.1,k=h?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),v._domains={x:u("x",M,w,x,y),y:u("y",M,k,b,m,_)}}else delete e.grid}function M(t,e){return n.coerce(r,v,l,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,i,a,o,s,l,u,h=t.grid||{},p=e._subplots,d=r._hasSubplotGrid,g=r.rows,v=r.columns,m="independent"===r.pattern,y=r._axisMap={};if(d){var x=h.subplots||[];l=r.subplots=new Array(g);var b=1;for(n=0;n1);if(!1!==x||p.uirevision){var b=a.newContainer(e,"legend");if(w("uirevision",e.uirevision),!1!==x){if(w("bgcolor",e.paper_bgcolor),w("bordercolor"),w("borderwidth"),i.coerceFont(w,"font",e.font),w("orientation"),"h"===b.orientation){var _=t.xaxis;n.getComponentMethod("rangeslider","isVisible")(_)?(c=0,f="left",u=1.1,h="bottom"):(c=0,f="left",u=-.1,h="top")}w("traceorder",v),l.isGrouped(e.legend)&&w("tracegroupgap"),w("x",c),w("xanchor",f),w("y",u),w("yanchor",h),w("valign"),i.noneOrAll(p,b,["x","y"])}}function w(t,e){return i.coerce(p,b,o,t,e)}}},{"../../lib":692,"../../plot_api/plot_template":730,"../../plots/layout_attributes":795,"../../registry":823,"./attributes":618,"./helpers":624}],621:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib/events"),l=t("../dragelement"),c=t("../drawing"),u=t("../color"),f=t("../../lib/svg_text_utils"),h=t("./handle_click"),p=t("./constants"),d=t("../../constants/interactions"),g=t("../../constants/alignment"),v=g.LINE_SPACING,m=g.FROM_TL,y=g.FROM_BR,x=t("./get_legend_data"),b=t("./style"),_=t("./helpers"),w=d.DBLCLICKDELAY;function k(t,e,r,n,i){var a=r.data()[0][0].trace,o={event:i,node:r.node(),curveNumber:a.index,expandedIndex:a._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};if(a._group&&(o.group=a._group),"pie"===a.type&&(o.label=r.datum()[0].label),!1!==s.triggerHandler(t,"plotly_legendclick",o))if(1===n)e._clickTimeout=setTimeout(function(){h(r,t,n)},w);else if(2===n){e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==s.triggerHandler(t,"plotly_legenddoubleclick",o)&&h(r,t,n)}}function M(t,e,r){var n=t.data()[0][0],a=e._fullLayout,s=n.trace,l=o.traceIs(s,"pie"),u=s.index,h=l?n.label:s.name,d=e._context.edits.legendText&&!l,g=i.ensureSingle(t,"text","legendtext");function m(r){f.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,i,a=t.select("g[class*=math-group]"),o=a.node(),s=e._fullLayout.legend.font.size*v;if(o){var l=c.bBox(o);n=l.height,i=l.width,c.setTranslate(a,0,n/4)}else{var u=t.select(".legendtext"),h=f.lineCount(u),d=u.node();n=s*h,i=d?c.bBox(d).width:0;var g=s*(.3+(1-h)/2);f.positionText(u,p.textOffsetX,g),r.lineHeight=s}n=Math.max(n,16)+3,r.height=n,r.width=i}(t,e)})}g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,a.legend.font).text(d?A(h,r):h),f.positionText(g,p.textOffsetX,0),d?g.call(f.makeEditable,{gd:e,text:h}).call(m).on("edit",function(t){this.text(A(t,r)).call(m);var a=n.trace._fullInput||{},s={};if(o.hasTransform(a,"groupby")){var l=o.getTransformIndices(a,"groupby"),c=l[l.length-1],f=i.keyedContainer(a,"transforms["+c+"].styles","target","value.name");f.set(n.trace._group,t),s=f.constructUpdate()}else s.name=t;return o.call("_guiRestyle",e,s,u)}):m(g)}function A(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function T(t,e){var r,a=1,o=i.ensureSingle(t,"rect","legendtoggle",function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")});o.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimew&&(a=Math.max(a-1,1)),k(e,r,t,a,n.event)}})}function S(t,e,r){var i=t._fullLayout,a=i.legend,o=a.borderwidth,s=_.isGrouped(a),l=0;if(a._width=0,a._height=0,_.isVertical(a))s&&e.each(function(t,e){c.setTranslate(this,0,e*a.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;c.setTranslate(this,o,5+o+a._height+r/2),a._height+=r,a._width=Math.max(a._width,n)}),a._width+=45+2*o,a._height+=10+2*o,s&&(a._height+=(a._lgroupsLength-1)*a.tracegroupgap),l=40;else if(s){for(var u=[a._width],f=e.data(),h=0,p=f.length;ho+w-k,r.each(function(t){var e=t[0],r=v?40+t[0].width:x;o+b+k+r>i._size.w&&(b=0,m+=y,a._height=a._height+y,y=0),c.setTranslate(this,o+b,5+o+e.height/2+m),a._width+=k+r,a._height=Math.max(a._height,e.height),b+=k+r,y=Math.max(e.height,y)}),a._width+=2*o,a._height+=10+2*o}a._width=Math.ceil(a._width),a._height=Math.ceil(a._height);var M=t._context.edits.legendText||t._context.edits.legendPosition;r.each(function(t){var e=t[0],r=n.select(this).select(".legendtoggle");c.setRect(r,0,-e.height/2,(M?0:a._width)+l,e.height)})}function C(t){var e=t._fullLayout.legend,r="left";i.isRightAnchor(e)?r="right":i.isCenterAnchor(e)&&(r="center");var n="top";i.isBottomAnchor(e)?n="bottom":i.isMiddleAnchor(e)&&(n="middle"),a.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*m[r],r:e._width*y[r],b:e._height*y[n],t:e._height*m[n]})}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var s=e.legend,f=e.showlegend&&x(t.calcdata,s),h=e.hiddenlabels||[];if(!e.showlegend||!f.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),void a.autoMargin(t,"legend");for(var d=0,g=0;gf?function(t){var e=t._fullLayout.legend,r="left";i.isRightAnchor(e)?r="right":i.isCenterAnchor(e)&&(r="center");a.autoMargin(t,"legend",{x:e.x,y:.5,l:e._width*m[r],r:e._width*y[r],b:0,t:0})}(t):C(t);var h=e._size,d=h.l+h.w*s.x,g=h.t+h.h*(1-s.y);i.isRightAnchor(s)?d-=s._width:i.isCenterAnchor(s)&&(d-=s._width/2),i.isBottomAnchor(s)?g-=s._height:i.isMiddleAnchor(s)&&(g-=s._height/2);var v=s._width,x=h.w;v>x?(d=h.l,v=x):(d+v>u&&(d=u-v),d<0&&(d=0),v=Math.min(u-d,s._width));var b,_,w,M,A=s._height,T=h.h;if(A>T?(g=h.t,A=T):(g+A>f&&(g=f-A),g<0&&(g=0),A=Math.min(f-g,s._height)),c.setTranslate(L,d,g),P.on(".drag",null),L.on("wheel",null),s._height<=A||t._context.staticPlot)O.attr({width:v-s.borderwidth,height:A-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),c.setTranslate(I,0,0),z.select("rect").attr({width:v-2*s.borderwidth,height:A-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth}),c.setClipUrl(I,r,t),c.setRect(P,0,0,0,0),delete s._scrollY;else{var F,B,N=Math.max(p.scrollBarMinHeight,A*A/s._height),j=A-N-2*p.scrollBarMargin,V=s._height-A,U=j/V,q=Math.min(s._scrollY||0,V);O.attr({width:v-2*s.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-s.borderwidth,x:s.borderwidth/2,y:s.borderwidth/2}),z.select("rect").attr({width:v-2*s.borderwidth+p.scrollBarWidth+p.scrollBarMargin,height:A-2*s.borderwidth,x:s.borderwidth,y:s.borderwidth+q}),c.setClipUrl(I,r,t),G(q,N,U),L.on("wheel",function(){G(q=i.constrain(s._scrollY+n.event.deltaY/j*V,0,V),N,U),0!==q&&q!==V&&n.event.preventDefault()});var H=n.behavior.drag().on("dragstart",function(){F=n.event.sourceEvent.clientY,B=q}).on("drag",function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||G(q=i.constrain((t.clientY-F)/U+B,0,V),N,U)});P.call(H)}function G(e,r,n){s._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(I,0,-e),c.setRect(P,v,p.scrollBarMargin+e*n,p.scrollBarWidth,r),z.select("rect").attr({y:s.borderwidth+e})}t._context.edits.legendPosition&&(L.classed("cursor-move",!0),l.init({element:L.node(),gd:t,prepFn:function(){var t=c.getTranslate(L);w=t.x,M=t.y},moveFn:function(t,e){var r=w+t,n=M+e;c.setTranslate(L,r,n),b=l.align(r,0,h.l,h.l+h.w,s.xanchor),_=l.align(n,0,h.t+h.h,h.t,s.yanchor)},doneFn:function(){void 0!==b&&void 0!==_&&o.call("_guiRelayout",t,{"legend.x":b,"legend.y":_})},clickFn:function(r,n){var i=e._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});i.size()>0&&k(t,L,i,r,n)}}))}],t)}}},{"../../constants/alignment":664,"../../constants/interactions":668,"../../lib":692,"../../lib/events":681,"../../lib/svg_text_utils":716,"../../plots/plots":804,"../../registry":823,"../color":569,"../dragelement":587,"../drawing":590,"./constants":619,"./get_legend_data":622,"./handle_click":623,"./helpers":624,"./style":626,d3:148}],622:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("./helpers");e.exports=function(t,e){var r,a,o={},s=[],l=!1,c={},u=0;function f(t,r){if(""!==t&&i.isGrouped(e))-1===s.indexOf(t)?(s.push(t),l=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+u;s.push(n),o[n]=[[r]],u++}}for(r=0;rr[1])return r[1]}return i}function d(t){return t[0]}if(u||f||h){var g={},v={};if(u){g.mc=p("marker.color",d),g.mx=p("marker.symbol",d),g.mo=p("marker.opacity",a.mean,[.2,1]),g.mlc=p("marker.line.color",d),g.mlw=p("marker.line.width",a.mean,[0,5]),v.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var m=p("marker.size",a.mean,[2,16]);g.ms=m,v.marker.size=m}h&&(v.line={width:p("line.width",d,[0,10])}),f&&(g.tx="Aa",g.tp=p("textposition",d),g.ts=10,g.tc=p("textfont.color",d),g.tf=p("textfont.family",d)),r=[a.minExtend(s,g)],(i=a.minExtend(c,v)).selectedpoints=null}var y=n.select(this).select("g.legendpoints"),x=y.selectAll("path.scatterpts").data(u?r:[]);x.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),x.exit().remove(),x.call(o.pointStyle,i,e),u&&(r[0].mrc=3);var b=y.selectAll("g.pointtext").data(f?r:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,i,e)}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data("candlestick"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var i=e[r?"increasing":"decreasing"],a=i.line.width,o=n.select(this);o.style("stroke-width",a+"px").call(s.fill,i.fillcolor),a&&s.stroke(o,i.line.color)})}).each(function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data("ohlc"===e.type&&e.visible?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"}).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each(function(t,r){var i=e[r?"increasing":"decreasing"],a=i.line.width,l=n.select(this);l.style("fill","none").call(o.dashLine,i.line.dash,a),a&&s.stroke(l,i.line.color)})})}},{"../../lib":692,"../../registry":823,"../../traces/pie/style_one":1026,"../../traces/scatter/subtypes":1064,"../color":569,"../drawing":590,d3:148}],627:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),s=t("../../../build/ploticon"),l=o._,c=e.exports={};function u(t,e){var r,i,o=e.currentTarget,s=o.getAttribute("data-attr"),l=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},f=a.list(t,null,!0),h="on";if("zoom"===s){var p,d="in"===l?.5:2,g=(1+d)/2,v=(1-d)/2;for(i=0;i1?(k=["toggleHover"],M=["resetViews"]):h?(w=["zoomInGeo","zoomOutGeo"],k=["hoverClosestGeo"],M=["resetGeo"]):f?(k=["hoverClosest3d"],M=["resetCameraDefault3d","resetCameraLastSave3d"]):v?(k=["toggleHover"],M=["resetViewMapbox"]):k=d?["hoverClosestGl2d"]:p?["hoverClosestPie"]:["toggleHover"];u&&(k=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]);!u&&!d||y||(w=["zoomIn2d","zoomOut2d","autoScale2d"],"resetViews"!==M[0]&&(M=["resetScale2d"]));f?A=["zoom3d","pan3d","orbitRotation","tableRotation"]:(u||d)&&!y||g?A=["zoom2d","pan2d"]:v||h?A=["pan2d"]:m&&(A=["zoom2d"]);(function(t){for(var e=!1,r=0;r0)){var g=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),i=0,a=0;a0?h+c:c;return{ppad:c,ppadplus:u?d:g,ppadminus:u?g:d}}return{ppad:c}}function u(t,e,r,n,i){var s="category"===t.type||"multicategory"===t.type?t.r2c:t.d2c;if(void 0!==e)return[s(e),s(r)];if(n){var l,c,u,f,h=1/0,p=-1/0,d=n.match(a.segmentRE);for("date"===t.type&&(s=o.decodeDate(s)),l=0;lp&&(p=f)));return p>=h?[h,p]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:D?q(r.xanchor)+r.x0:q(r.x0),cy:R?H(r.yanchor)-r.y0:H(r.y0),r:a}).style(i).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:D?q(r.xanchor)+r.x1:q(r.x1),cy:R?H(r.yanchor)-r.y1:H(r.y1),r:a}).style(i).classed("cursor-grab",!0),n}():e,X={element:Y.node(),gd:t,prepFn:function(n){D&&(_=q(r.xanchor));R&&(w=H(r.yanchor));"path"===r.type?z=r.path:(m=D?r.x0:q(r.x0),y=R?r.y0:H(r.y0),x=D?r.x1:q(r.x1),b=R?r.y1:H(r.y1));mb?(k=y,S="y0",M=b,C="y1"):(k=b,S="y1",M=y,C="y0");Z(n),K(p,r),function(t,e,r){var n=e.xref,i=e.yref,o=a.getFromId(r,n),l=a.getFromId(r,i),c="";"paper"===n||o.autorange||(c+=n);"paper"===i||l.autorange||(c+=i);s.setClipUrl(t,c?"clip"+r._fullLayout._uid+c:null,r)}(e,r,t),X.moveFn="move"===O?$:J},doneFn:function(){u(e),Q(p),d(e,t,r),n.call("_guiRelayout",t,N.getUpdateObj())},clickFn:function(){Q(p)}};function Z(t){if(F)O="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=X.element.getBoundingClientRect(),n=r.right-r.left,i=r.bottom-r.top,a=t.clientX-r.left,o=t.clientY-r.top,s=!B&&n>I&&i>P&&!t.shiftKey?c.getCursor(a/n,1-o/i):"move";u(e,s),O=s.split("-")[0]}}function $(n,i){if("path"===r.type){var a=function(t){return t},o=a,s=a;D?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(q(t)+n)},V&&"date"===V.type&&(o=h.encodeDate(o))),R?j("yanchor",r.yanchor=W(w+i)):(s=function(t){return W(H(t)+i)},U&&"date"===U.type&&(s=h.encodeDate(s))),j("path",r.path=v(z,o,s))}else D?j("xanchor",r.xanchor=G(_+n)):(j("x0",r.x0=G(m+n)),j("x1",r.x1=G(x+n))),R?j("yanchor",r.yanchor=W(w+i)):(j("y0",r.y0=W(y+i)),j("y1",r.y1=W(b+i)));e.attr("d",g(t,r)),K(p,r)}function J(n,i){if(B){var a=function(t){return t},o=a,s=a;D?j("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(q(t)+n)},V&&"date"===V.type&&(o=h.encodeDate(o))),R?j("yanchor",r.yanchor=W(w+i)):(s=function(t){return W(H(t)+i)},U&&"date"===U.type&&(s=h.encodeDate(s))),j("path",r.path=v(z,o,s))}else if(F){if("resize-over-start-point"===O){var l=m+n,c=R?y-i:y+i;j("x0",r.x0=D?l:G(l)),j("y0",r.y0=R?c:W(c))}else if("resize-over-end-point"===O){var u=x+n,f=R?b-i:b+i;j("x1",r.x1=D?u:G(u)),j("y1",r.y1=R?f:W(f))}}else{var d=~O.indexOf("n")?k+i:k,N=~O.indexOf("s")?M+i:M,Y=~O.indexOf("w")?A+n:A,X=~O.indexOf("e")?T+n:T;~O.indexOf("n")&&R&&(d=k-i),~O.indexOf("s")&&R&&(N=M-i),(!R&&N-d>P||R&&d-N>P)&&(j(S,r[S]=R?d:W(d)),j(C,r[C]=R?N:W(N))),X-Y>I&&(j(E,r[E]=D?Y:G(Y)),j(L,r[L]=D?X:G(X)))}e.attr("d",g(t,r)),K(p,r)}function K(t,e){(D||R)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var a=q(D?e.xanchor:i.midRange(r?[e.x0,e.x1]:h.extractPathCoords(e.path,f.paramIsX))),o=H(R?e.yanchor:i.midRange(r?[e.y0,e.y1]:h.extractPathCoords(e.path,f.paramIsY)));if(a=h.roundPositionForSharpStrokeRendering(a,1),o=h.roundPositionForSharpStrokeRendering(o,1),D&&R){var s="M"+(a-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",s)}else if(D){var l="M"+(a-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",l)}else{var c="M"+(a-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",c)}}()}function Q(t){t.selectAll(".visual-cue").remove()}c.init(X),Y.node().onmousemove=Z}(t,x,r,e,p)}}function d(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");s.setClipUrl(t,n?"clip"+e._fullLayout._uid+n:null,e)}function g(t,e){var r,n,o,s,l,c,u,p,d=e.type,g=a.getFromId(t,e.xref),v=a.getFromId(t,e.yref),m=t._fullLayout._size;if(g?(r=h.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return m.l+m.w*t},v?(o=h.shapePositionToRange(v),s=function(t){return v._offset+v.r2p(o(t,!0))}):s=function(t){return m.t+m.h*(1-t)},"path"===d)return g&&"date"===g.type&&(n=h.decodeDate(n)),v&&"date"===v.type&&(s=h.decodeDate(s)),function(t,e,r){var n=t.path,a=t.xsizemode,o=t.ysizemode,s=t.xanchor,l=t.yanchor;return n.replace(f.segmentRE,function(t){var n=0,c=t.charAt(0),u=f.paramIsX[c],h=f.paramIsY[c],p=f.numParams[c],d=t.substr(1).replace(f.paramRE,function(t){return u[n]?t="pixel"===a?e(s)+Number(t):e(t):h[n]&&(t="pixel"===o?r(l)-Number(t):r(t)),++n>p&&(t="X"),t});return n>p&&(d=d.replace(/[\s,]*X.*/,""),i.log("Ignoring extra params in segment "+t)),c+d})}(e,n,s);if("pixel"===e.xsizemode){var y=n(e.xanchor);l=y+e.x0,c=y+e.x1}else l=n(e.x0),c=n(e.x1);if("pixel"===e.ysizemode){var x=s(e.yanchor);u=x-e.y0,p=x-e.y1}else u=s(e.y0),p=s(e.y1);if("line"===d)return"M"+l+","+u+"L"+c+","+p;if("rect"===d)return"M"+l+","+u+"H"+c+"V"+p+"H"+l+"Z";var b=(l+c)/2,_=(u+p)/2,w=Math.abs(b-l),k=Math.abs(_-u),M="A"+w+","+k,A=b+w+","+_;return"M"+A+M+" 0 1,1 "+(b+","+(_-k))+M+" 0 0,1 "+A+"Z"}function v(t,e,r){return t.replace(f.segmentRE,function(t){var n=0,i=t.charAt(0),a=f.paramIsX[i],o=f.paramIsY[i],s=f.numParams[i];return i+t.substr(1).replace(f.paramRE,function(t){return n>=s?t:(a[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var i=0;i0&&(s=s.transition().duration(e.transition.duration).ease(e.transition.easing)),s.attr("transform","translate("+(o-.5*u.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function S(t,e){var r=t._dims;return r.inputAreaStart+u.stepInset+(r.inputAreaLength-2*u.stepInset)*Math.min(1,Math.max(0,e))}function C(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-u.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*u.stepInset-2*r.inputAreaStart)))}function E(t,e,r){var n=r._dims,i=s.ensureSingle(t,"rect",u.railTouchRectClass,function(n){n.call(M,e,t,r).style("pointer-events","all")});i.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,u.tickOffset+r.ticklen+n.labelHeight)}).call(a.fill,r.bgcolor).attr("opacity",0),o.setTranslate(i,0,n.currentValueTotalHeight)}function L(t,e){var r=e._dims,n=r.inputAreaLength-2*u.railInset,i=s.ensureSingle(t,"rect",u.railRectClass);i.attr({width:n,height:u.railWidth,rx:u.railRadius,ry:u.railRadius,"shape-rendering":"crispEdges"}).call(a.stroke,e.bordercolor).call(a.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(i,u.railInset,.5*(r.inputAreaWidth-u.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[u.name],n=[],i=0;i0?[0]:[]);function s(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),i.autoMargin(t,g(e))}if(a.enter().append("g").classed(u.containerClassName,!0).style("cursor","ew-resize"),a.exit().each(function(){n.select(this).selectAll("g."+u.groupClassName).each(s)}).remove(),0!==r.length){var l=a.selectAll("g."+u.groupClassName).data(r,v);l.enter().append("g").classed(u.groupClassName,!0),l.exit().each(s).remove();for(var c=0;c0||h<0){var g={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[y.side];e.attr("transform","translate("+g+")")}}}I.call(P),z&&(T?I.on(".opacity",null):(k=0,M=!0,I.text(v).on("mouseover.opacity",function(){n.select(this).transition().duration(f.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(f.HIDE_PLACEHOLDER).style("opacity",0)})),I.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==m?o.call("_guiRestyle",t,g,e,m):o.call("_guiRelayout",t,g,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(P)}).on("input",function(t){this.text(t||" ").call(u.positionText,x.x,x.y)}));return I.classed("js-placeholder",M),_}};var h=/ [XY][0-9]* /},{"../../constants/interactions":668,"../../lib":692,"../../lib/svg_text_utils":716,"../../plots/plots":804,"../../registry":823,"../color":569,"../drawing":590,d3:148,"fast-isnumeric":214}],658:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes"),l=t("../../plot_api/plot_template").templatedArray,c=l("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(l("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:a(s({editType:"arraydraw"}),{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../../plots/font_attributes":767,"../../plots/pad_attributes":803,"../color/attributes":568}],659:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],660:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/array_container_defaults"),a=t("./attributes"),o=t("./constants").name,s=a.buttons;function l(t,e,r){function o(r,i){return n.coerce(t,e,a,r,i)}o("visible",i(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function r(r,i){return n.coerce(t,e,s,r,i)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("label"),r("execute"))}e.exports=function(t,e){i(t,e,{name:o,handleItemDefaults:l})}},{"../../lib":692,"../../plots/array_container_defaults":736,"./attributes":658,"./constants":659}],661:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plots/plots"),a=t("../color"),o=t("../drawing"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),c=t("../../plot_api/plot_template").arrayEditor,u=t("../../constants/alignment").LINE_SPACING,f=t("./constants"),h=t("./scrollbox");function p(t){return t._index}function d(t,e){return+t.attr(f.menuIndexAttrName)===e._index}function g(t,e,r,n,i,a,o,s){e.active=o,c(t.layout,f.name,e).applyUpdate("active",o),"buttons"===e.type?m(t,n,null,null,e):"dropdown"===e.type&&(i.attr(f.menuIndexAttrName,"-1"),v(t,n,i,a,e),s||m(t,n,i,a,e))}function v(t,e,r,n,i){var a=s.ensureSingle(e,"g",f.headerClassName,function(t){t.style("pointer-events","all")}),l=i._dims,c=i.active,u=i.buttons[c]||f.blankHeaderOpts,h={y:i.pad.t,yPad:0,x:i.pad.l,xPad:0,index:0},p={width:l.headerWidth,height:l.headerHeight};a.call(y,i,u,t).call(T,i,h,p),s.ensureSingle(e,"text",f.headerArrowClassName,function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,i.font).text(f.arrowSymbol[i.direction])}).attr({x:l.headerWidth-f.arrowOffsetX+i.pad.l,y:l.headerHeight/2+f.textOffsetY+i.pad.t}),a.on("click",function(){r.call(S,String(d(r,i)?-1:i._index)),m(t,e,r,n,i)}),a.on("mouseover",function(){a.call(w)}),a.on("mouseout",function(){a.call(k,i)}),o.setTranslate(e,l.lx,l.ly)}function m(t,e,r,a,o){r||(r=e).attr("pointer-events","all");var l=function(t){return-1==+t.attr(f.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?f.dropdownButtonClassName:f.buttonClassName,u=r.selectAll("g."+c).data(s.filterVisible(l)),h=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(h.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var d=0,v=0,m=o._dims,x=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(x?v=m.headerHeight+f.gapButtonHeader:d=m.headerWidth+f.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(v=-f.gapButtonHeader+f.gapButton-m.openHeight),"dropdown"===o.type&&"left"===o.direction&&(d=-f.gapButtonHeader+f.gapButton-m.openWidth);var b={x:m.lx+d+o.pad.l,y:m.ly+v+o.pad.t,yPad:f.gapButton,xPad:f.gapButton,index:0},M={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each(function(s,l){var c=n.select(this);c.call(y,o,s,t).call(T,o,b),c.on("click",function(){n.event.defaultPrevented||(g(t,o,0,e,r,a,l),s.execute&&i.executeAPICommand(t,s.method,s.args),t.emit("plotly_buttonclicked",{menu:o,button:s,active:o.active}))}),c.on("mouseover",function(){c.call(w)}),c.on("mouseout",function(){c.call(k,o),u.call(_,o)})}),u.call(_,o),x?(M.w=Math.max(m.openWidth,m.headerWidth),M.h=b.y-M.t):(M.w=b.x-M.l,M.h=Math.max(m.openHeight,m.headerHeight)),M.direction=o.direction,a&&(u.size()?function(t,e,r,n,i,a){var o,s,l,c=i.direction,u="up"===c||"down"===c,h=i._dims,p=i.active;if(u)for(s=0,l=0;l0?[0]:[]);if(o.enter().append("g").classed(f.containerClassName,!0).style("cursor","pointer"),o.exit().each(function(){n.select(this).selectAll("g."+f.headerGroupClassName).each(a)}).remove(),0!==r.length){var l=o.selectAll("g."+f.headerGroupClassName).data(r,p);l.enter().append("g").classed(f.headerGroupClassName,!0);for(var c=s.ensureSingle(o,"g",f.dropdownButtonGroupClassName,function(t){t.style("pointer-events","all")}),u=0;uw,A=s.barLength+2*s.barPad,T=s.barWidth+2*s.barPad,S=d,C=v+m;C+T>c&&(C=c-T);var E=this.container.selectAll("rect.scrollbar-horizontal").data(M?[0]:[]);E.exit().on(".drag",null).remove(),E.enter().append("rect").classed("scrollbar-horizontal",!0).call(i.fill,s.barColor),M?(this.hbar=E.attr({rx:s.barRadius,ry:s.barRadius,x:S,y:C,width:A,height:T}),this._hbarXMin=S+A/2,this._hbarTranslateMax=w-A):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var L=m>k,z=s.barWidth+2*s.barPad,O=s.barLength+2*s.barPad,I=d+g,P=v;I+z>l&&(I=l-z);var D=this.container.selectAll("rect.scrollbar-vertical").data(L?[0]:[]);D.exit().on(".drag",null).remove(),D.enter().append("rect").classed("scrollbar-vertical",!0).call(i.fill,s.barColor),L?(this.vbar=D.attr({rx:s.barRadius,ry:s.barRadius,x:I,y:P,width:z,height:O}),this._vbarYMin=P+O/2,this._vbarTranslateMax=k-O):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var R=this.id,F=u-.5,B=L?f+z+.5:f+.5,N=h-.5,j=M?p+T+.5:p+.5,V=o._topdefs.selectAll("#"+R).data(M||L?[0]:[]);if(V.exit().remove(),V.enter().append("clipPath").attr("id",R).append("rect"),M||L?(this._clipRect=V.select("rect").attr({x:Math.floor(F),y:Math.floor(N),width:Math.ceil(B)-Math.floor(F),height:Math.ceil(j)-Math.floor(N)}),this.container.call(a.setClipUrl,R,this.gd),this.bg.attr({x:d,y:v,width:g,height:m})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),M||L){var U=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(U);var q=n.behavior.drag().on("dragstart",function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));M&&this.hbar.on(".drag",null).call(q),L&&this.vbar.on(".drag",null).call(q)}this.setTranslate(e,r)},s.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},s.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},s.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},s.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,i=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,i)-r)/(i-r)*(this.position.w-this._box.w)}if(this.vbar){var a=e+this._vbarYMin,s=a+this._vbarTranslateMax;e=(o.constrain(n.event.y,a,s)-a)/(s-a)*(this.position.h-this._box.h)}this.setTranslate(t,e)},s.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(a.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var i=t/r;this.hbar.call(a.setTranslate,t+i*this._hbarTranslateMax,e)}if(this.vbar){var s=e/n;this.vbar.call(a.setTranslate,t,e+s*this._vbarTranslateMax)}}},{"../../lib":692,"../color":569,"../drawing":590,d3:148}],664:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,CAP_SHIFT:.7,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],665:[function(t,e,r){"use strict";e.exports={COMPARISON_OPS:["=","!=","<",">=",">","<="],COMPARISON_OPS2:["=","<",">=",">","<="],INTERVAL_OPS:["[]","()","[)","(]","][",")(","](",")["],SET_OPS:["{}","}{"],CONSTRAINT_REDUCTION:{"=":"=","<":"<","<=":"<",">":">",">=":">","[]":"[]","()":"[]","[)":"[]","(]":"[]","][":"][",")(":"][","](":"][",")[":"]["}}},{}],666:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],667:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],668:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DBLCLICKDELAY:300,DESELECTDIM:.2}},{}],669:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"\u2212"}},{}],670:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],671:[function(t,e,r){"use strict";r.version="1.43.0",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config")();for(var n=t("./registry"),i=r.register=n.register,a=t("./plot_api"),o=Object.keys(a),s=0;s1/3&&t.x<2/3},r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isTopAnchor=function(t){return"top"===t.yanchor||"auto"===t.yanchor&&t.y>=2/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3}},{}],674:[function(t,e,r){"use strict";var n=t("./mod"),i=n.mod,a=n.modHalf,o=Math.PI,s=2*o;function l(t){return Math.abs(t[1]-t[0])>s-1e-15}function c(t,e){return a(e-t,s)}function u(t,e){if(l(e))return!0;var r,n;e[0](n=i(n,s))&&(n+=s);var a=i(t,s),o=a+s;return a>=r&&a<=n||o>=r&&o<=n}function f(t,e,r,n,i,a,c){i=i||0,a=a||0;var u,f,h,p,d,g=l([r,n]);function v(t,e){return[t*Math.cos(e)+i,a-t*Math.sin(e)]}g?(u=0,f=o,h=s):r=i&&t<=a);var i,a},pathArc:function(t,e,r,n,i){return f(null,t,e,r,n,i,0)},pathSector:function(t,e,r,n,i){return f(null,t,e,r,n,i,1)},pathAnnulus:function(t,e,r,n,i,a){return f(t,e,r,n,i,a,1)}}},{"./mod":699}],675:[function(t,e,r){"use strict";var n=Array.isArray,i="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},a="undefined"==typeof DataView?function(){}:DataView;function o(t){return i.isView(t)&&!(t instanceof a)}function s(t){return n(t)||o(t)}function l(t,e,r){if(s(t)){if(s(t[0])){for(var n=r,i=0;ii.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var i="number"==typeof t;!0!==n.strict&&i?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return i(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o.get(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(u(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var i=n.regex||c(r);"string"==typeof t&&i.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!c(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var i=t.split("+"),a=0;a=n&&t<=i?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),m=t.charAt(0);!c||"G"!==m&&"g"!==m||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),k=t.match(w?x:y);if(!k)return u;var M=k[1],A=k[3]||"1",T=Number(k[5]||1),S=Number(k[7]||0),C=Number(k[9]||0),E=Number(k[11]||0);if(c){if(2===M.length)return u;var L;M=Number(M);try{var z=v.getComponentMethod("calendars","getCal")(e);if(w){var O="i"===A.charAt(A.length-1);A=parseInt(A,10),L=z.newDate(M,z.toMonthIndex(M,A,O),T)}else L=z.newDate(M,Number(A),T)}catch(t){return u}return L?(L.toJD()-g)*f+S*h+C*p+E*d:u}M=2===M.length?(Number(M)+2e3-b)%100+b:Number(M),A-=1;var I=new Date(Date.UTC(2e3,A,T,S,C));return I.setUTCFullYear(M),I.getUTCMonth()!==A?u:I.getUTCDate()!==T?u:I.getTime()+E*d},n=r.MIN_MS=r.dateTime2ms("-9999"),i=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==u};var k=90*f,M=3*h,A=5*p;function T(t,e,r,n,i){if((e||r||n||i)&&(t+=" "+w(e,2)+":"+w(r,2),(n||i)&&(t+=":"+w(n,2),i))){for(var a=4;i%10==0;)a-=1,i/=10;t+="."+w(i,a)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=i))return u;e||(e=0);var a,o,s,c,y,x,b=Math.floor(10*l(t+.05,1)),w=Math.round(t-b/10);if(_(r)){var S=Math.floor(w/f)+g,C=Math.floor(l(t,f));try{a=v.getComponentMethod("calendars","getCal")(r).fromJD(S).formatDate("yyyy-mm-dd")}catch(t){a=m("G%Y-%m-%d")(new Date(w))}if("-"===a.charAt(0))for(;a.length<11;)a="-0"+a.substr(1);else for(;a.length<10;)a="0"+a;o=e=n+f&&t<=i-f))return u;var e=Math.floor(10*l(t+.05,1)),r=new Date(Math.round(t-e/10));return T(a.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===u)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return s.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return s.error("unrecognized date",t),e;return t};var S=/%\d?f/g;function C(t,e,r,n){t=t.replace(S,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var i=new Date(Math.floor(e+.05));if(_(n))try{t=v.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(i)}var E=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,i,a){if(i=_(i)&&i,!e)if("y"===r)e=a.year;else if("m"===r)e=a.month;else{if("d"!==r)return function(t,e){var r=l(t+.05,f),n=w(Math.floor(r/h),2)+":"+w(l(Math.floor(r/p),60),2);if("M"!==e){o(e)||(e=0);var i=(100+Math.min(l(t/d,60),E[e])).toFixed(e).substr(1);e>0&&(i=i.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+i}return n}(t,r)+"\n"+C(a.dayMonthYear,t,n,i);e=a.dayMonth+"\n"+a.year}return C(e,t,n,i)};var L=3*f;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=l(t,f);if(t=Math.round(t-n),r)try{var i=Math.round(t/f)+g,a=v.getComponentMethod("calendars","getCal")(r),o=a.fromJD(i);return e%12?a.add(o,e,"m"):a.add(o,e/12,"y"),(o.toJD()-g)*f+n}catch(e){s.error("invalid ms "+t+" in calendar "+r)}var c=new Date(t+L);return c.setUTCMonth(c.getUTCMonth()+e)+n-L},r.findExactDates=function(t,e){for(var r,n,i=0,a=0,s=0,l=0,c=_(e)&&v.getComponentMethod("calendars","getCal")(e),u=0;u0&&(r.push(i),i=[])}return i.length>0&&r.push(i),r},r.makeLine=function(t){return 1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}},r.makePolygon=function(t){if(1===t.length)return{type:"Polygon",coordinates:t};for(var e=new Array(t.length),r=0;r1||g<0||g>1?null:{x:t+l*g,y:e+f*g}}function l(t,e,r,n,i){var a=n*t+i*e;if(a<0)return n*n+i*i;if(a>r){var o=n-t,s=i-e;return o*o+s*s}var l=n*e-i*t;return l*l/r}r.segmentsIntersect=s,r.segmentDistance=function(t,e,r,n,i,a,o,c){if(s(t,e,r,n,i,a,o,c))return 0;var u=r-t,f=n-e,h=o-i,p=c-a,d=u*u+f*f,g=h*h+p*p,v=Math.min(l(u,f,d,i-t,a-e),l(u,f,d,o-t,c-e),l(h,p,g,t-i,e-a),l(h,p,g,r-i,n-a));return Math.sqrt(v)},r.getTextLocation=function(t,e,r,s){if(t===i&&s===a||(n={},i=t,a=s),n[r])return n[r];var l=t.getPointAtLength(o(r-s/2,e)),c=t.getPointAtLength(o(r+s/2,e)),u=Math.atan((c.y-l.y)/(c.x-l.x)),f=t.getPointAtLength(o(r,e)),h={x:(4*f.x+l.x+c.x)/6,y:(4*f.y+l.y+c.y)/6,theta:u};return n[r]=h,h},r.clearLocationCache=function(){i=null},r.getVisibleSegment=function(t,e,r){var n,i,a=e.left,o=e.right,s=e.top,l=e.bottom,c=0,u=t.getTotalLength(),f=u;function h(e){var r=t.getPointAtLength(e);0===e?n=r:e===u&&(i=r);var c=r.xo?r.x-o:0,f=r.yl?r.y-l:0;return Math.sqrt(c*c+f*f)}for(var p=h(c);p;){if((c+=p+r)>f)return;p=h(c)}for(p=h(f);p;){if(c>(f-=p+r))return;p=h(f)}return{min:c,max:f,len:f-c,total:u,isClosed:0===c&&f===u&&Math.abs(n.x-i.x)<.1&&Math.abs(n.y-i.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var i,a,o,s=(n=n||{}).pathLength||t.getTotalLength(),l=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(s)[r]?-1:1,f=0,h=0,p=s;f0?p=i:h=i,f++}return a}},{"./mod":699}],688:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null==t)throw new Error("DOM element provided is null or undefined");return t}},{}],689:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("color-normalize"),o=t("../components/colorscale"),s=t("../components/color/attributes").defaultLine,l=t("./array").isArrayOrTypedArray,c=a(s),u=1;function f(t,e){var r=t;return r[3]*=e,r}function h(t){if(n(t))return c;var e=a(t);return e.length?e:c}function p(t){return n(t)?t:u}e.exports={formatColor:function(t,e,r){var n,i,s,d,g,v=t.color,m=l(v),y=l(e),x=[];if(n=void 0!==t.colorscale?o.makeColorScaleFunc(o.extractScale(t,{cLetter:"c"})):h,i=m?function(t,e){return void 0===t[e]?c:a(n(t[e]))}:h,s=y?function(t,e){return void 0===t[e]?u:p(t[e])}:p,m||y)for(var b=0;bo?s:i(t)?Number(t):s:s},l.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&(i(t)&&t>=0&&t%1==0)},l.noop=t("./noop"),l.identity=t("./identity"),l.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},l.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},l.simpleMap=function(t,e,r,n){for(var i=t.length,a=new Array(i),o=0;o=Math.pow(2,r)?i>10?(l.warn("randstr failed uniqueness"),c):t(e,r,n,(i||0)+1):c},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;r=s&&(i-=s*Math.floor(i/s)),i<0?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},l.syncOrAsync=function(t,e,r){var n;function i(){return l.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(i).then(void 0,l.promiseError);return r&&r(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,r){if(t){var n,i=!1,a=!0;for(n=0;n1?i+o[1]:"";if(a&&(o.length>1||s.length>4||r))for(;n.test(s);)s=s.replace(n,"$1"+a+"$2");return s+l};var T=/%{([^\s%{}:]*)(:[^}]*)?}/g,S=/^\w*$/;l.templateString=function(t,e){var r={};return t.replace(T,function(t,n){return S.test(n)?e[n]||"":(r[n]=r[n]||l.nestedProperty(e,n).get,r[n]()||"")})};var C=/^:/,E=0;l.hovertemplateString=function(t,e){var r=arguments,i={};return t.replace(T,function(t,a,o){var s,c,u;for(u=2;u=48&&o<=57,c=s>=48&&s<=57;if(l&&(n=10*n+o-48),c&&(i=10*i+s-48),!l||!c){if(n!==i)return n-i;if(o!==s)return o-s}}return i-n};var L=2e9;l.seedPseudoRandom=function(){L=2e9},l.pseudoRandom=function(){var t=L;return L=(69069*L+1)%4294967296,Math.abs(L-t)<429496729?l.pseudoRandom():L/4294967296}},{"../constants/numerical":669,"./anchor_utils":673,"./angles":674,"./array":675,"./clean_number":676,"./clear_responsive":678,"./coerce":679,"./dates":680,"./extend":682,"./filter_unique":683,"./filter_visible":684,"./geometry2d":687,"./get_graph_div":688,"./identity":691,"./is_plain_object":693,"./keyed_container":694,"./localize":695,"./loggers":696,"./make_trace_groups":697,"./matrix":698,"./mod":699,"./nested_property":700,"./noop":701,"./notifier":702,"./push_unique":706,"./regex":708,"./relative_attr":709,"./relink_private":710,"./search":711,"./stats":714,"./throttle":717,"./to_log_range":718,d3:148,"fast-isnumeric":214}],693:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],694:[function(t,e,r){"use strict";var n=t("./nested_property"),i=/^\w*$/;e.exports=function(t,e,r,a){var o,s,l;r=r||"name",a=a||"value";var c={};e&&e.length?(l=n(t,e),s=l.get()):s=t,e=e||"";var u={};if(s)for(o=0;o2)return c[e]=2|c[e],h.set(t,null);if(f){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;ee/2?t-Math.round(t/e)*e:t}}},{}],700:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("./array").isArrayOrTypedArray;e.exports=function(t,e){if(n(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,a,o,l=0,c=e.split(".");l/g),o=0;oa||c===i||cs||e&&l(t))}:function(t,e){var l=t[0],c=t[1];if(l===i||la||c===i||cs)return!1;var u,f,h,p,d,g=r.length,v=r[0][0],m=r[0][1],y=0;for(u=1;uMath.max(f,v)||c>Math.max(h,m)))if(cu||Math.abs(n(o,h))>i)return!0;return!1};a.filter=function(t,e){var r=[t[0]],n=0,i=0;function a(a){t.push(a);var s=r.length,l=n;r.splice(i+1);for(var c=l+1;c1&&a(t.pop());return{addPt:a,raw:t,filtered:r}}},{"../constants/numerical":669,"./matrix":698}],705:[function(t,e,r){(function(r){"use strict";var n=t("./show_no_webgl_msg"),i=t("regl");e.exports=function(t,e){var a=t._fullLayout,o=!0;return a._glcanvas.each(function(n){if(!n.regl&&(!n.pick||a._has("parcoords"))){try{n.regl=i({canvas:this,attributes:{antialias:!n.pick,preserveDrawingBuffer:!0},pixelRatio:t._context.plotGlPixelRatio||r.devicePixelRatio,extensions:e||[]})}catch(t){o=!1}o&&this.addEventListener("webglcontextlost",function(e){t&&t.emit&&t.emit("plotly_webglcontextlost",{event:e,layer:n.key})},!1)}}),o||n({container:a._glcontainer.node()}),o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./show_no_webgl_msg":713,regl:478}],706:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ri.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function c(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var a,u,f=0,h=e.length,p=0,d=h>1?(e[h-1]-e[0])/(h-1):1;for(u=d>=0?r?o:s:r?c:l,t+=1e-9*d*(r?-1:1)*(d>=0?1:-1);f90&&i.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;se[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;i0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||a;for(var r,n=1/0,i=0;ia.length)&&(o=a.length),n(e)||(e=!1),i(a[0])){for(l=new Array(o),s=0;st.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":675,"fast-isnumeric":214}],715:[function(t,e,r){"use strict";var n=t("color-normalize");e.exports=function(t){return t?n(t):[0,0,0,1]}},{"color-normalize":108}],716:[function(t,e,r){"use strict";var n=t("d3"),i=t("../lib"),a=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function s(t,e){return t.node().getBoundingClientRect()[e]}var l=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,v){var S=t.text(),C=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&S.match(l),L=n.select(t.node().parentNode);if(!L.empty()){var z=t.attr("class")?t.attr("class").split(" ")[0]:"text";return z+="-math",L.selectAll("svg."+z).remove(),L.selectAll("g."+z+"-group").remove(),t.style("display",null).attr({"data-unformatted":S,"data-math":"N"}),C?(e&&e._promises||[]).push(new Promise(function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),a={fontSize:r};!function(t,e,r){var a,o,s,l;MathJax.Hub.Queue(function(){return o=i.extendDeepAll({},MathJax.Hub.config),s=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})},function(){if("SVG"!==(a=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")},function(){var r="math-output-"+i.randstr({},64);return l=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(l.node())},function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(l.select(".MathJax_SVG").empty()||!l.select("svg").node())i.log("There was an error in the tex syntax.",t),r();else{var o=l.select("svg").node().getBoundingClientRect();r(l.select(".MathJax_SVG"),e,o)}if(l.remove(),"SVG"!==a)return MathJax.Hub.setRenderer(a)},function(){return void 0!==s&&(MathJax.Hub.processSectionDelay=s),MathJax.Hub.Config(o)})}(C[2],a,function(n,i,a){L.selectAll("svg."+z).remove(),L.selectAll("g."+z+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return O(),void e();var l=L.append("g").classed(z+"-group",!0).attr({"pointer-events":"none","data-unformatted":S,"data-math":"Y"});l.node().appendChild(o.node()),i&&i.node()&&o.node().insertBefore(i.node().cloneNode(!0),o.node().firstChild),o.attr({class:z,height:a.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black";o.select("g").attr({fill:c,stroke:c});var u=s(o,"width"),f=s(o,"height"),h=+t.attr("x")-u*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],p=-(r||s(t,"height"))/4;"y"===z[0]?(l.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-u/2,p-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===z[0]?o.attr({x:t.attr("x"),y:p-f/2}):"a"===z[0]?o.attr({x:0,y:p}):o.attr({x:h,y:+t.attr("y")+p-f/2}),v&&v.call(t,l),e(l)})})):O(),t}function O(){L.empty()||(z=t.attr("class")+"-math",L.select("svg."+z).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(m," ");var r,s=!1,l=[],c=-1;function u(){c++;var e=document.createElementNS(a.svg,"tspan");n.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),r=e;var i=l;if(l=[{node:e}],i.length>1)for(var s=1;s doesnt match end tag <"+t+">. Pretending it did match.",e),r=l[l.length-1].node}else i.log("Ignoring unexpected end tag .",e)}b.test(e)?u():(r=t,l=[{node:t}]);for(var L=e.split(y),z=0;z|>|>)/g;var f={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},h={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},d="\u200b",g=["http:","https:","mailto:","",void 0,":"],v=new RegExp("]*)?/?>","g"),m=/(\r\n?|\n)/g,y=/(<[^<>]*>)/,x=/<(\/?)([^ >]*)(\s+(.*))?>/i,b=//i,_=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,w=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,k=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,M=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function A(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&E(n)}var T=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(v," ")};var S={mu:"\u03bc",amp:"&",lt:"<",gt:">",nbsp:"\xa0",times:"\xd7",plusmn:"\xb1",deg:"\xb0"},C=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function E(t){return t.replace(C,function(t,e){return("#"===e.charAt(0)?function(t){if(t>1114111)return;var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):S[e])||t})}function L(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}r.convertEntities=E,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){var t=n.select(this);function i(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var a=i("x",e),o=i("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:a,y:o})})},r.makeEditable=function(t,e){var r=e.gd,i=e.delegate,a=n.dispatch("edit","input","cancel"),o=i||t;if(t.style({"pointer-events":i?"none":"all"}),1!==t.size())throw new Error("boo");function s(){!function(){var i=n.select(r).select(".svg-container"),o=i.append("div"),s=t.node().style,c=parseFloat(s.fontSize||12),u=e.text;void 0===u&&(u=t.attr("data-unformatted"));o.classed("plugin-editable editable",!0).style({position:"absolute","font-family":s.fontFamily||"Arial","font-size":c,color:e.fill||s.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-c/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(u).call(L(t,i,e)).on("blur",function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,i=n.select(this).attr("class");(e=i?"."+i.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),a.edit.call(t,o)}).on("focus",function(){var t=this;r._editing=!0,n.select(document).on("mouseup",function(){if(n.event.target===t)return!1;document.activeElement===o.node()&&o.node().blur()})}).on("keyup",function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),a.cancel.call(t,this.textContent)):(a.input.call(t,this.textContent),n.select(this).call(L(t,i,e)))}).on("keydown",function(){13===n.event.which&&this.blur()}).call(l)}(),t.style({opacity:0});var i,s=o.attr("class");(i=s?"."+s.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(i).style({opacity:0})}function l(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?s():o.on("click",s),n.rebind(t,a,"on")}},{"../constants/alignment":664,"../constants/xmlns_namespaces":670,"../lib":692,d3:148}],717:[function(t,e,r){"use strict";var n={};function i(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var a=n[t],o=Date.now();if(!a){for(var s in n)n[s].tsa.ts+e?l():a.timer=setTimeout(function(){l(),a.timer=null},e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)i(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],718:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":214}],719:[function(t,e,r){"use strict";var n=e.exports={},i=t("../plots/geo/constants").locationmodeToLayer,a=t("topojson-client").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../plots/geo/constants":769,"topojson-client":516}],720:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],721:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],722:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,i=n.layoutArrayContainers,a=n.layoutArrayRegexes,o=t.split("[")[0],s=0;s0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var a=(s.subplotsRegistry.cartesian||{}).attrRegex,l=(s.subplotsRegistry.polar||{}).attrRegex,u=(s.subplotsRegistry.ternary||{}).attrRegex,d=(s.subplotsRegistry.gl3d||{}).attrRegex,g=Object.keys(t);for(e=0;e3?(z.x=1.02,z.xanchor="left"):z.x<-2&&(z.x=-.02,z.xanchor="right"),z.y>3?(z.y=1.02,z.yanchor="bottom"):z.y<-2&&(z.y=-.02,z.yanchor="top")),p(t),"rotate"===t.dragmode&&(t.dragmode="orbit"),f.clean(t),t.template&&t.template.layout&&r.cleanLayout(t.template.layout),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=x(e);r;){if(r in t)return!0;r=x(r)}return!1};var b=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&a.warn("Full array edits are incompatible with other edits",f);var y=r[""][""];if(c(y))e.set(null);else{if(!Array.isArray(y))return a.warn("Unrecognized full array edit value",f,y),!0;e.set(y)}return!g&&(h(v,m),p(t),!0)}var x,b,_,w,k,M,A,T,S=Object.keys(r).map(Number).sort(o),C=e.get(),E=C||[],L=u(m,f).get(),z=[],O=-1,I=E.length;for(x=0;xE.length-(A?0:1))a.warn("index out of range",f,_);else if(void 0!==M)k.length>1&&a.warn("Insertion & removal are incompatible with edits to the same index.",f,_),c(M)?z.push(_):A?("add"===M&&(M={}),E.splice(_,0,M),L&&L.splice(_,0,{})):a.warn("Unrecognized full object edit value",f,_,M),-1===O&&(O=_);else for(b=0;b=0;x--)E.splice(z[x],1),L&&L.splice(z[x],1);if(E.length?C||e.set(E):e.set(null),g)return!1;if(h(v,m),d!==i){var P;if(-1===O)P=S;else{for(I=Math.max(E.length,I),P=[],x=0;x=O);x++)P.push(_);for(x=O;x=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||i<0&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function P(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),I(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&I(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function D(t,e,r,n,a){!function(t,e,r,n){var i=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if("undefined"==typeof r)throw new Error("indices must be an integer or array of integers");for(var a in I(t,r,"indices"),e){if(!Array.isArray(e[a])||e[a].length!==r.length)throw new Error("attribute "+a+" must be an array of length equal to indices array length");if(i&&(!(a in n)||!Array.isArray(n[a])||n[a].length!==e[a].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var l=function(t,e,r,n){var a,l,c,u,f,h=o.isPlainObject(n),p=[];for(var d in Array.isArray(r)||(r=[r]),r=O(r,t.data.length-1),e)for(var g=0;g-1?l(r,r.replace("titlefont","title.font")):r.indexOf("titleposition")>-1?l(r,r.replace("titleposition","title.position")):r.indexOf("titleside")>-1?l(r,r.replace("titleside","title.side")):r.indexOf("titleoffset")>-1&&l(r,r.replace("titleoffset","title.offset")):l(r,r.replace("title","title.text"));function l(e,r){t[r]=t[e],delete t[e]}}function q(t,e,r){if(t=o.getGraphDiv(t),k.clearPromiseQueue(t),t.framework&&t.framework.isPolar)return Promise.resolve(t);var n={};if("string"==typeof e)n[e]=r;else{if(!o.isPlainObject(e))return o.warn("Relayout fail.",e,r),Promise.reject();n=o.extendFlat({},e)}Object.keys(n).length&&(t.changed=!0);var i=Z(t,n),a=i.flags;a.calc&&(t.calcdata=void 0);var s=[h.previousPromises];a.layoutReplot?s.push(M.layoutReplot):Object.keys(n).length&&(H(t,a,i)||h.supplyDefaults(t),a.legend&&s.push(M.doLegend),a.layoutstyle&&s.push(M.layoutStyles),a.axrange&&G(s,i.rangesAltered),a.ticks&&s.push(M.doTicksRelayout),a.modebar&&s.push(M.doModeBar),a.camera&&s.push(M.doCamera),s.push(C)),s.push(h.rehover),c.add(t,q,[t,i.undoit],q,[t,i.redoit]);var l=o.syncOrAsync(s,t);return l&&l.then||(l=Promise.resolve(t)),l.then(function(){return t.emit("plotly_relayout",i.eventData),t})}function H(t,e,r){var n;if(!e.axrange)return!1;for(n in e)if("axrange"!==n&&e[n])return!1;for(n in r.rangesAltered){var i=d.id2name(n),a=t.layout[i],o=t._fullLayout[i];o.autorange=a.autorange,o.range=a.range.slice(),o.cleanRange()}return!0}function G(t,e){var r=e?function(t){var r={skipTitle:!0};for(var n in e)if(d.getFromId(t,n).automargin){r={};break}return d.draw(t,Object.keys(e),r)}:function(t){return d.draw(t,"redraw")};t.push(M.doAutoRangeAndConstraints,r,M.drawData,M.finalDraw)}r.plot=function(t,e,i,a){var s;if(t=o.getGraphDiv(t),l.init(t),o.isPlainObject(e)){var c=e;e=c.data,i=c.layout,a=c.config,s=c.frames}if(!1===l.triggerHandler(t,"plotly_beforeplot",[e,i,a]))return Promise.reject();e||i||o.isPlotDiv(t)||o.warn("Calling Plotly.plot as if redrawing but this container doesn't yet have a plot.",t),z(t,a),i||(i={}),n.select(t).classed("js-plotly-plot",!0),g.makeTester(),Array.isArray(t._promises)||(t._promises=[]);var f=0===(t.data||[]).length&&Array.isArray(e);if(Array.isArray(e)&&(k.cleanData(e),f?t.data=e:t.data.push.apply(t.data,e),t.empty=!1),t.layout&&!f||(t.layout=k.cleanLayout(i)),t._dragging&&!t._transitioning)return t._replotPending=!0,Promise.reject();t._replotPending=!1,h.supplyDefaults(t);var v=t._fullLayout,x=v._has("cartesian");if(!v._has("polar")&&e&&e[0]&&e[0].r)return o.log("Legacy polar charts are deprecated!"),function(t,e,r){var i=n.select(t).selectAll(".plot-container").data([0]);i.enter().insert("div",":first-child").classed("plot-container plotly",!0);var a=i.selectAll(".svg-container").data([0]);a.enter().append("div").classed("svg-container",!0).style("position","relative"),a.html(""),e&&(t.data=e);r&&(t.layout=r);p.manager.fillLayout(t),a.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=p.manager.framework(t),t.framework({data:t.data,layout:t.layout},a.node()),t.framework.setUndoPoint();var s=t.framework.svg(),l=1,c=t._fullLayout.title?t._fullLayout.title.text:"";""!==c&&c||(l=0);var u=function(){this.call(b.convertToTspans,t)},f=s.select(".title-group text").call(u);if(t._context.edits.titleText){var d=o._(t,"Click to enter Plot title");c&&c!==d||(l=.2,f.attr({"data-unformatted":d}).text(d).style({opacity:l}).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)}));var g=function(){this.call(b.makeEditable,{gd:t}).on("edit",function(e){t.framework({layout:{title:{text:e}}}),this.text(e).call(u),this.call(g)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(u)})};f.call(g)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),h.addLinks(t),Promise.resolve()}(t,e,i);v._replotting=!0,f&&st(t),t.framework!==st&&(t.framework=st,st(t)),g.initGradients(t),f&&d.saveShowSpikeInitial(t);var _=!t.calcdata||t.calcdata.length!==(t._fullData||[]).length;_&&h.doCalcdata(t);for(var w=0;w=0&&r=0&&r0&&"string"!=typeof I.parts[D];)D--;var R=I.parts[D],F=I.parts[D-1]+"."+R,j=I.parts.slice(0,D).join("."),V=s(t.layout,j).get(),q=s(l,j).get(),H=I.get();if(void 0!==P){M[O]=P,S[O]="reverse"===R?P:B(H);var G=f.getLayoutValObject(l,I.parts);if(G&&G.impliedEdits&&null!==P)for(var Z in G.impliedEdits)C(o.relativeAttr(O,Z),G.impliedEdits[Z]);if(-1!==["width","height"].indexOf(O))if(P){C("autosize",null);var J="height"===O?"width":"height";C(J,l[J])}else l[O]=t._initialAutoSize[O];else if("autosize"===O)C("width",P?null:l.width),C("height",P?null:l.height);else if(F.match(W))z(F),s(l,j+"._inputRange").set(null);else if(F.match(Y)){z(F),s(l,j+"._inputRange").set(null);var K=s(l,j).get();K._inputDomain&&(K._input.domain=K._inputDomain.slice())}else F.match(X)&&s(l,j+"._inputDomain").set(null);if("type"===R){var Q=V,tt="linear"===q.type&&"log"===P,et="log"===q.type&&"linear"===P;if(tt||et){if(Q&&Q.range)if(q.autorange)tt&&(Q.range=Q.range[1]>Q.range[0]?[1,2]:[2,1]);else{var rt=Q.range[0],nt=Q.range[1];tt?(rt<=0&&nt<=0&&C(j+".autorange",!0),rt<=0?rt=nt/1e6:nt<=0&&(nt=rt/1e6),C(j+".range[0]",Math.log(rt)/Math.LN10),C(j+".range[1]",Math.log(nt)/Math.LN10)):(C(j+".range[0]",Math.pow(10,rt)),C(j+".range[1]",Math.pow(10,nt)))}else C(j+".autorange",!0);Array.isArray(l._subplots.polar)&&l._subplots.polar.length&&l[I.parts[0]]&&"radialaxis"===I.parts[1]&&delete l[I.parts[0]]._subplot.viewInitial["radialaxis.range"],u.getComponentMethod("annotations","convertCoords")(t,q,P,C),u.getComponentMethod("images","convertCoords")(t,q,P,C)}else C(j+".autorange",!0),C(j+".range",null);s(l,j+"._inputRange").set(null)}else if(R.match(T)){var it=s(l,O).get(),at=(P||{}).type;at&&"-"!==at||(at="linear"),u.getComponentMethod("annotations","convertCoords")(t,it,at,C),u.getComponentMethod("images","convertCoords")(t,it,at,C)}var ot=w.containerArrayMatch(O);if(ot){r=ot.array,n=ot.index;var st=ot.property,lt=G||{editType:"calc"};""!==n&&""===st&&(w.isAddVal(P)?S[O]=null:w.isRemoveVal(P)?S[O]=(s(a,r).get()||[])[n]:o.warn("unrecognized full object value",e)),A.update(_,lt),m[r]||(m[r]={});var ct=m[r][n];ct||(ct=m[r][n]={}),ct[st]=P,delete e[O]}else"reverse"===R?(V.range?V.range.reverse():(C(j+".autorange",!0),V.range=[1,0]),q.autorange?_.calc=!0:_.plot=!0):(l._has("scatter-like")&&l._has("regl")&&"dragmode"===O&&("lasso"===P||"select"===P)&&"lasso"!==H&&"select"!==H?_.plot=!0:G?A.update(_,G):_.calc=!0,I.set(P))}}for(r in m){w.applyContainerArrayChanges(t,h(a,r),m[r],_,h)||(_.plot=!0)}var ut=l._axisConstraintGroups||[];for(E in L)for(n=0;n1;)if(n.pop(),void 0!==(r=s(e,n.join(".")+".uirevision").get()))return r;return e.uirevision}function nt(t,e){for(var r=0;r=i.length?i[0]:i[t]:i}function l(t){return Array.isArray(a)?t>=a.length?a[0]:a[t]:a}function c(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise(function(a,u){function f(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,h.transition(t,e.frame.data,e.frame.layout,k.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function p(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&f()};e()}var d,g,v=0;function m(t){return Array.isArray(i)?v>=i.length?t.transitionOpts=i[v]:t.transitionOpts=i[0]:t.transitionOpts=i,v++,t}var y=[],x=null==e,b=Array.isArray(e);if(!x&&!b&&o.isPlainObject(e))y.push({type:"object",data:m(o.extendFlat({},e))});else if(x||-1!==["string","number"].indexOf(typeof e))for(d=0;d0&&MM)&&A.push(g);y=A}}y.length>0?function(e){if(0!==e.length){for(var i=0;i=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,v=(u[g]||d[g]||{}).name,m=e[n].name,y=u[v]||d[v];v&&m&&"number"==typeof m&&y&&S<5&&(S++,o.warn('addFrames: overwriting frame "'+(u[v]||d[v]).name+'" with a frame whose name of type "number" also equates to "'+v+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),5===S&&o.warn("addFrames: This API call has yielded too many of these warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),d[g]={name:g},p.push({frame:h.supplyFrameDefaults(e[n]),index:r&&void 0!==r[n]&&null!==r[n]?r[n]:f+n})}p.sort(function(t,e){return t.index>e.index?-1:t.index=0;n--){if("number"==typeof(i=p[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!i.name)for(;u[i.name="frame "+t._transitionData._counter++];);if(u[i.name]){for(a=0;a=0;r--)n=e[r],a.push({type:"delete",index:n}),s.unshift({type:"insert",index:n,value:i[n]});var l=h.modifyFrames,u=h.modifyFrames,f=[t,s],p=[t,a];return c&&c.add(t,l,f,u,p),h.modifyFrames(t,a)},r.purge=function(t){var e=(t=o.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return h.cleanPlot([],{},r,e),h.purge(t),l.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":569,"../components/colorbar/connect":571,"../components/drawing":590,"../constants/xmlns_namespaces":670,"../lib":692,"../lib/events":681,"../lib/queue":707,"../lib/svg_text_utils":716,"../plots/cartesian/axes":740,"../plots/cartesian/constants":746,"../plots/cartesian/graph_interact":750,"../plots/plots":804,"../plots/polar/legacy":812,"../registry":823,"./edit_types":723,"./helpers":724,"./manage_arrays":726,"./plot_config":728,"./plot_schema":729,"./subroutines":731,d3:148,"fast-isnumeric":214,"has-hover":393}],728:[function(t,e,r){"use strict";e.exports={staticPlot:!1,plotlyServerURL:"https://plot.ly",editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,responsive:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,showSendToCloud:!1,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,toImageButtonOptions:{},displaylogo:!0,watermark:!1,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],729:[function(t,e,r){"use strict";var n=t("../registry"),i=t("../lib"),a=t("../plots/attributes"),o=t("../plots/layout_attributes"),s=t("../plots/frame_attributes"),l=t("../plots/animation_attributes"),c=t("../plots/polar/legacy/area_attributes"),u=t("../plots/polar/legacy/axis_attributes"),f=t("./edit_types"),h=i.extendFlat,p=i.extendDeepAll,d=i.isPlainObject,g="_isSubplotObj",v="_isLinkedToArray",m=[g,v,"_arrayAttrRegexps","_deprecated"];function y(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(x(e[r]))r++;else if(r=a.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!x(o))return!1;t=a[i][o]}else t=a[i]}else t=a}}return t}function x(t){return t===Math.round(t)&&t>=0}function b(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):d(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[v];if(!n)return;delete t[v],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),function(t){!function t(e){for(var r in e)if(d(e[r]))t(e[r]);else if(Array.isArray(e[r]))for(var n=0;n=l.length)return!1;i=(r=(n.transformsRegistry[l[u].type]||{}).attributes)&&r[e[2]],s=3}else if("area"===t.type)i=c[o];else{var f=t._module;if(f||(f=(n.modules[t.type||a.type.dflt]||{})._module),!f)return!1;if(!(i=(r=f.attributes)&&r[o])){var h=f.basePlotModule;h&&h.attributes&&(i=h.attributes[o])}i||(i=a[o])}return y(i,e,s)},r.getLayoutValObject=function(t,e){return y(function(t,e){var r,i,a,s,l=t._basePlotModules;if(l){var c;for(r=0;r=i&&(r._input||{})._templateitemname;s&&(o=i);var l,c=e+"["+o+"]";function u(){l={},s&&(l[c]={},l[c][a]=s)}function f(t,e){s?n.nestedProperty(l[c],t).set(e):l[c+"."+t]=e}function h(){var t=l;return u(),t}return u(),{modifyBase:function(t,e){l[t]=e},modifyItem:f,getUpdateObj:h,applyUpdate:function(e,r){e&&f(e,r);var i=h();for(var a in i)n.nestedProperty(t,a).set(i[a])}}}},{"../lib":692,"../plots/attributes":737}],731:[function(t,e,r){"use strict";var n=t("d3"),i=t("../registry"),a=t("../plots/plots"),o=t("../lib"),s=t("../lib/clear_gl_canvases"),l=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),f=t("../components/modebar"),h=t("../plots/cartesian/axes"),p=t("../constants/alignment"),d=t("../plots/cartesian/constraints"),g=d.enforce,v=d.clean,m=t("../plots/cartesian/autorange").doAutoRange,y="start",x="middle",b="end";function _(t,e,r){for(var n=0;n=t[1]||i[1]<=t[0])&&(a[0]e[0]))return!0}return!1}function w(t){var e,i,a,s,u,d,g=t._fullLayout,v=g._size,m=v.p,y=h.list(t,"",!0);if(g._paperdiv.style({width:t._context.responsive&&g.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":g.width+"px",height:t._context.responsive&&g.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":g.height+"px"}).selectAll(".main-svg").call(c.setSize,g.width,g.height),t._context.setBackground(t,g.paper_bgcolor),r.drawMainTitle(t),f.manage(t),!g._has("cartesian"))return t._promises.length&&Promise.all(t._promises);function x(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-m-n:e._offset+e._length+m+n:v.t+v.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+m+n:e._offset-m-n:v.l+v.w*(t.position||0)+n%1}for(e=0;ek?u.push({code:"unused",traceType:y,templateCount:w,dataCount:k}):k>w&&u.push({code:"reused",traceType:y,templateCount:w,dataCount:k})}}else u.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var a=e[n],o=p(e,n,r);i(a)?(Array.isArray(e)&&!1===a._template&&a.templateitemname&&u.push({code:"missing",path:o,templateitemname:a.templateitemname}),t(a,o)):Array.isArray(a)&&d(a)&&t(a,o)}}({data:v,layout:h},""),u.length)return u.map(g)}},{"../lib":692,"../plots/attributes":737,"../plots/plots":804,"./plot_config":728,"./plot_schema":729,"./plot_template":730}],733:[function(t,e,r){"use strict";var n=t("./plot_api"),i=t("../lib"),a=t("../snapshot/helpers"),o=t("../snapshot/tosvg"),s=t("../snapshot/svgtoimg"),l={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}},c=/^data:image\/\w+;base64,/;e.exports=function(t,e){var r,u,f;function h(t){return!(t in e)||i.validate(e[t],l[t])}if(e=e||{},i.isPlainObject(t)?(r=t.data||[],u=t.layout||{},f=t.config||{}):(t=i.getGraphDiv(t),r=i.extendDeep([],t.data),u=i.extendDeep({},t.layout),f=t._context),!h("width")||!h("height"))throw new Error("Height and width should be pixel values.");if(!h("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var p={};function d(t,r){return i.coerce(e,p,l,t,r)}var g=d("format"),v=d("width"),m=d("height"),y=d("scale"),x=d("setBackground"),b=d("imageDataOnly"),_=document.createElement("div");_.style.position="absolute",_.style.left="-5000px",document.body.appendChild(_);var w=i.extendFlat({},u);v&&(w.width=v),m&&(w.height=m);var k=i.extendFlat({},f,{_exportedPlot:!0,staticPlot:!0,setBackground:x}),M=a.getRedrawFunc(_);function A(){return new Promise(function(t){setTimeout(t,a.getDelay(_._fullLayout))})}function T(){return new Promise(function(t,e){var r=o(_,g,y),a=_._fullLayout.width,l=_._fullLayout.height;if(n.purge(_),document.body.removeChild(_),"svg"===g)return t(b?r:"data:image/svg+xml,"+encodeURIComponent(r));var c=document.createElement("canvas");c.id=i.randstr(),s({format:g,width:a,height:l,scale:y,canvas:c,svg:r,promise:!0}).then(t).catch(e)})}return new Promise(function(t,e){n.plot(_,r,w,k).then(M).then(A).then(T).then(function(e){t(function(t){return b?t.replace(c,""):t}(e))}).catch(function(t){e(t)})})}},{"../lib":692,"../snapshot/helpers":827,"../snapshot/svgtoimg":829,"../snapshot/tosvg":831,"./plot_api":727}],734:[function(t,e,r){"use strict";var n=t("../lib"),i=t("../plots/plots"),a=t("./plot_schema"),o=t("./plot_config"),s=n.isPlainObject,l=Array.isArray,c=n.isArrayOrTypedArray;function u(t,e,r,i,a,o){o=o||[];for(var f=Object.keys(t),h=0;hx.length&&i.push(p("unused",a,m.concat(x.length)));var M,A,T,S,C,E=x.length,L=Array.isArray(k);if(L&&(E=Math.min(E,k.length)),2===b.dimensions)for(A=0;Ax[A].length&&i.push(p("unused",a,m.concat(A,x[A].length)));var z=x[A].length;for(M=0;M<(L?Math.min(z,k[A].length):z);M++)T=L?k[A][M]:k,S=y[A][M],C=x[A][M],n.validate(S,T)?C!==S&&C!==+S&&i.push(p("dynamic",a,m.concat(A,M),S,C)):i.push(p("value",a,m.concat(A,M),S))}else i.push(p("array",a,m.concat(A),y[A]));else for(A=0;A1&&h.push(p("object","layout"))),i.supplyDefaults(d);for(var g=d._fullData,v=r.length,m=0;m0&&((b=A-o(v)-o(m))>T?_/b>S&&(y=v,x=m,S=_/b):_/A>S&&(y={val:v.val,pad:0},x={val:m.val,pad:0},S=_/A));if(h===p){var C=h-1,E=h+1;if(k)if(0===h)a=[0,1];else{var L=(h>0?f:u).reduce(function(t,e){return Math.max(t,o(e))},0),z=h/(1-Math.min(.5,L/A));a=h>0?[0,z]:[z,0]}else a=M?[Math.max(0,C),Math.max(1,E)]:[C,E]}else k?(y.val>=0&&(y={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):M&&(y.val-S*o(y)<0&&(y={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),S=(x.val-y.val)/(A-o(y)-o(x)),a=[y.val-S*o(y),x.val+S*o(x)];return d&&a.reverse(),i.simpleMap(a,e.l2r||Number)}function l(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function c(t,e){var r,n,i,a=e._id,o=t._fullData,s=t._fullLayout,l=[],c=[];function h(t,e){for(r=0;r=r&&(c.extrapad||!o)){s=!1;break}i(e,c.val)&&c.pad<=r&&(o||!c.extrapad)&&(t.splice(l,1),l--)}if(s){var u=a&&0===e;t.push({val:e,pad:u?0:r,extrapad:!u&&o})}}function p(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:s,makePadFn:l,doAutoRange:function(t,e){if(e.autorange){e.range=s(t,e),e._r=e.range.slice(),e._rl=i.simpleMap(e._r,e.r2l);var r=e._input,n={};n[e._attr+".range"]=e.range,n[e._attr+".autorange"]=e.autorange,o.call("_storeDirectGUIEdit",t.layout,t._fullLayout._preGUI,n),r.range=e.range.slice(),r.autorange=e.autorange}var a=e._anchorAxis;if(a&&a.rangeslider){var l=a.rangeslider[e._name];l&&"auto"===l.rangemode&&(l.range=s(t,e)),a._input.rangeslider[e._name]=i.extendFlat({},l)}},findExtremes:function(t,e,r){r||(r={});t._m||t.setScale();var i,o,s,l,c,h,d,g,v,m=[],y=[],x=e.length,b=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,k=!1;function M(t){if(Array.isArray(t))return k=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var A=M((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),T=M((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),S=M(r.vpadplus||r.vpad),C=M(r.vpadminus||r.vpad);if(!k){if(g=1/0,v=-1/0,w)for(i=0;i0&&(g=o),o>v&&o-a&&(g=o),o>v&&o=z;i--)L(i);return{min:m,max:y}},concatExtremes:c}},{"../../constants/numerical":669,"../../lib":692,"../../registry":823,"fast-isnumeric":214}],740:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),f=t("../../components/drawing"),h=t("./layout_attributes"),p=t("./clean_ticks"),d=t("../../constants/numerical"),g=d.ONEAVGYEAR,v=d.ONEAVGMONTH,m=d.ONEDAY,y=d.ONEHOUR,x=d.ONEMIN,b=d.ONESEC,_=d.MINUS_SIGN,w=d.BADNUM,k=t("../../constants/alignment").MID_SHIFT,M=t("../../constants/alignment").LINE_SPACING,A=e.exports={};A.setConvert=t("./set_convert");var T=t("./axis_autotype"),S=t("./axis_ids");A.id2name=S.id2name,A.name2id=S.name2id,A.cleanId=S.cleanId,A.list=S.list,A.listIds=S.listIds,A.getFromId=S.getFromId,A.getFromTrace=S.getFromTrace;var C=t("./autorange");A.getAutoRange=C.getAutoRange,A.findExtremes=C.findExtremes,A.coerceRef=function(t,e,r,n,i,a){var o=n.charAt(n.length-1),l=r._fullLayout._subplots[o+"axis"],c=n+"ref",u={};return i||(i=l[0]||a),a||(a=i),u[c]={valType:"enumerated",values:l.concat(a?[a]:[]),dflt:i},s.coerce(t,e,u,c)},A.coercePosition=function(t,e,r,n,i,a){var o,l;if("paper"===n||"pixel"===n)o=s.ensureNumber,l=r(i,a);else{var c=A.getFromId(e,n);l=r(i,a=c.fraction2r(a)),o=c.cleanPos}t[i]=o(l)},A.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?s.ensureNumber:A.getFromId(e,r).cleanPos)(t)};var E=A.getDataConversions=function(t,e,r,n){var i,a="x"===r||"y"===r||"z"===r?r:n;if(Array.isArray(a)){if(i={type:T(n),_categories:[]},A.setConvert(i),"category"===i.type)for(var o=0;o2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},A.saveRangeInitial=function(t,e){for(var r=A.list(t,"",!0),n=!1,i=0;i.3*h||u(n)||u(a))){var p=r.dtick/2;t+=t+p.8){var o=Number(r.substr(1));a.exactYears>.8&&o%12==0?t=A.tickIncrement(t,"M6","reverse")+1.5*m:a.exactMonths>.8?t=A.tickIncrement(t,"M1","reverse")+15.5*m:t-=m/2;var l=A.tickIncrement(t,r);if(l<=n)return l}return t}(x,t,y,c,a)),v=x,0;v<=u;)v=A.tickIncrement(v,y,!1,a),0;return{start:e.c2r(x,0,a),end:e.c2r(v,0,a),size:y,_dataSpan:u-c}},A.prepTicks=function(t){var e=s.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type||"multicategory"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=s.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),A.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),j(t)},A.calcTicks=function(t){A.prepTicks(t);var e=s.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e=t.tickvals,r=t.ticktext,n=new Array(e.length),i=s.simpleMap(t.range,t.r2l),a=1.0001*i[0]-1e-4*i[1],o=1.0001*i[1]-1e-4*i[0],l=Math.min(a,o),c=Math.max(a,o),u=0;Array.isArray(r)||(r=[]);var f="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(var h=0;hl&&p=n:c<=n)&&!(a.length>l||c===o);c=A.tickIncrement(c,t.dtick,i,t.calendar))o=c,a.push(c);et(t)&&360===Math.abs(e[1]-e[0])&&a.pop(),t._tmax=a[a.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var u=new Array(a.length),f=0;f10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=m&&a<=10||e>=15*m)t._tickround="d";else if(e>=x&&a<=16||e>=y)t._tickround="M";else if(e>=b&&a<=19||e>=x)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(a,o)-20,t._tickround<0&&(t._tickround=4)}}else if(i(e)||"L"===e.charAt(0)){var s=t.range.map(t.r2d||Number);i(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var l=Math.max(Math.abs(s[0]),Math.abs(s[1])),c=Math.floor(Math.log(l)/Math.LN10+.01);Math.abs(c)>3&&(q(t.exponentformat)&&!H(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function V(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}A.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=s.dateTick0(t.calendar);var a=2*e;a>g?(e/=g,r=n(10),t.dtick="M"+12*N(e,r,O)):a>v?(e/=v,t.dtick="M"+N(e,1,I)):a>m?(t.dtick=N(e,m,D),t.tick0=s.dateTick0(t.calendar,!0)):a>y?t.dtick=N(e,y,I):a>x?t.dtick=N(e,x,P):a>b?t.dtick=N(e,b,P):(r=n(10),t.dtick=N(e,r,O))}else if("log"===t.type){t.tick0=0;var o=s.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var l=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/l,r=n(10),t.dtick="L"+N(e,r,O)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type||"multicategory"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):et(t)?(t.tick0=0,r=1,t.dtick=N(e,r,B)):(t.tick0=0,r=n(10),t.dtick=N(e,r,O));if(0===t.dtick&&(t.dtick=1),!i(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},A.tickIncrement=function(t,e,r,a){var o=r?-1:1;if(i(e))return t+o*e;var l=e.charAt(0),c=o*Number(e.substr(1));if("M"===l)return s.incrementMonth(t,c,a);if("L"===l)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===l){var u="D2"===e?F:R,f=t+.01*o,h=s.roundUp(s.mod(f,1),u,r);return Math.floor(f)+Math.log(n.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(e)},A.tickFirst=function(t){var e=t.r2l||Number,r=s.simpleMap(t.range,e),a=r[1]"+l,t._prevDateHead=l));e.text=c}(t,a,r,l):"log"===c?function(t,e,r,n,a){var o=t.dtick,l=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);"never"===a&&(a="");n&&"L"!==u&&(o="L3",u="L");if(c||"L"===u)e.text=G(Math.pow(10,l),t,a,n);else if(i(o)||"D"===u&&s.mod(l+.01,1)<.1){var f=Math.round(l),h=Math.abs(f),p=t.exponentformat;"power"===p||q(p)&&H(f)?(e.text=0===f?1:1===f?"10":"10"+(f>1?"":_)+h+"",e.fontSize*=1.25):("e"===p||"E"===p)&&h>2?e.text="1"+p+(f>0?"+":_)+h:(e.text=G(Math.pow(10,l),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,s.mod(l,1)))),e.fontSize*=.75}if("D1"===t.dtick){var d=String(e.text).charAt(0);"0"!==d&&"1"!==d||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(l<0?.5:.25)))}}(t,a,0,l,d):"category"===c?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r="");e.text=String(r)}(t,a):"multicategory"===c?function(t,e,r){var n=Math.round(e.x),i=t._categories[n]||[],a=void 0===i[1]?"":String(i[1]),o=void 0===i[0]?"":String(i[0]);r?e.text=o+" - "+a:(e.text=a,e.text2=o)}(t,a,r):et(t)?function(t,e,r,n,i){if("radians"!==t.thetaunit||r)e.text=G(e.x,t,i,n);else{var a=e.x/180;if(0===a)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){var r=1;for(;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,i=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/i),Math.round(r/i)]}(a);if(o[1]>=100)e.text=G(s.deg2rad(e.x),t,i,n);else{var l=e.x<0;1===o[1]?1===o[0]?e.text="\u03c0":e.text=o[0]+"\u03c0":e.text=["",o[0],"","\u2044","",o[1],"","\u03c0"].join(""),l&&(e.text=_+e.text)}}}}(t,a,r,l,d):function(t,e,r,n,i){"never"===i?i="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide");e.text=G(e.x,t,i,n)}(t,a,0,l,d),t.tickprefix&&!p(t.showtickprefix)&&(a.text=t.tickprefix+a.text),t.ticksuffix&&!p(t.showticksuffix)&&(a.text+=t.ticksuffix),"boundaries"===t.tickson||t.showdividers){var g=function(e){var r=t.l2p(e);return r>=0&&r<=t._length?e:null};a.xbnd=[g(a.x-.5),g(a.x+t.dtick-.5)]}return a},A.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return A.hoverLabelText(t,e)+" - "+A.hoverLabelText(t,r);var n="log"===t.type&&e<=0,i=A.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+i:i};var U=["f","p","n","\u03bc","m","","k","M","G","T"];function q(t){return"SI"===t||"B"===t}function H(t){return t>14||t<-15}function G(t,e,r,n){var a=t<0,o=e._tickround,l=r||e.exponentformat||"B",c=e._tickexponent,u=A.getTickFormat(e),f=e.separatethousands;if(n){var h={exponentformat:l,dtick:"none"===e.showexponent?e.dtick:i(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};j(h),o=(Number(h._tickround)||0)+4,c=h._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,d=Math.pow(10,-o)/2;if("none"===l&&(c=0),(t=Math.abs(t))"+p+"":"B"===l&&9===c?t+="B":q(l)&&(t+=U[c/3+5]));return a?_+t:t}function W(t,e){var r=t._id.charAt(0),n=t._tickAngles[e]||0,i=s.deg2rad(n),a=Math.sin(i),o=Math.cos(i),l=0,c=0;return t._selections[e].each(function(){var t=Z(this),e=f.bBox(t.node()),r=e.width,n=e.height;l=Math.max(l,o*r,a*n),c=Math.max(c,a*r,o*n)}),{x:c,y:l}[r]}function Y(t){return[t.text,t.x,t.axInfo,t.font,t.fontSize,t.fontColor].join("_")}function X(t,e){var r=t.l2p(e);return r>1&&r=0,a=u(t,e[1])<=0;return(r||i)&&(n||a)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(i)))){r=n;break}break;case"log":for(e=0;e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},s=0;s2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":823,"./constants":746}],744:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){if("category"===e.type){var i,a=t.categoryarray,o=Array.isArray(a)&&a.length>0;o&&(i="array");var s,l=r("categoryorder",i);"array"===l&&(s=r("categoryarray")),o||"array"!==l||(l=e.categoryorder="trace"),"trace"===l?e._initialCategories=[]:"array"===l?e._initialCategories=s.slice():(s=function(t,e){var r,n,i,a=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;ns*x)||k)for(r=0;rI&&Rz&&(z=R);p/=(z-L)/(2*O),L=u.l2r(L),z=u.l2r(z),u.range=u._input.range=S=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function P(t,e,r,n,i){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",i+"Z")}function D(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function R(t,e,r,n,i,a){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),F(t,e,i,a)}function F(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function B(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function N(t){S&&t.data&&t._context.showTips&&(s.notifier(s._(t,"Double-click to zoom back out"),"long"),S=!1)}function j(t){return"lasso"===t||"select"===t}function V(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,T)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function U(t,e){if(a){var r=void 0!==t.onwheel?"wheel":"mousewheel";t._onwheel&&t.removeEventListener(r,t._onwheel),t._onwheel=e,t.addEventListener(r,e,{passive:!1})}else void 0!==t.onwheel?t.onwheel=e:void 0!==t.onmousewheel&&(t.onmousewheel=e)}function q(t){var e=[];for(var r in t)e.push(t[r]);return e}e.exports={makeDragBox:function(t,e,r,a,c,p,S,C){var F,H,G,W,Y,X,Z,$,J,K,Q,tt,et,rt,nt,it,at,ot,st,lt,ct,ut=t._fullLayout._zoomlayer,ft=S+C==="nsew",ht=1===(S+C).length;function pt(){if(F=e.xaxis,H=e.yaxis,J=F._length,K=H._length,Z=F._offset,$=H._offset,(G={})[F._id]=F,(W={})[H._id]=H,S&&C)for(var r=e.overlays,n=0;n-1&&w(i,t,Y,X,e.id,Tt),a.indexOf("event")>-1&&f.click(t,i,e.id);else if(1===r&&ht){var s=S?H:F,c="s"===S||"w"===C?0:1,u=s._name+".range["+c+"]",h=function(t,e){var r,i=t.range[e],a=Math.abs(i-t.range[1-e]);return"date"===t.type?i:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,i))):(r=Math.floor(Math.log(Math.abs(i))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,n.format("."+String(r)+"g")(i))}(s,c),p="left",d="middle";if(s.fixedrange)return;S?(d="n"===S?"top":"bottom","right"===s.side&&(p="right")):"e"===C&&(p="right"),t._context.showAxisRangeEntryBoxes&&n.select(gt).call(l.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(h),fill:s.tickfont?s.tickfont.color:"#444",horizontalAlign:p,verticalAlign:d}).on("edit",function(e){var r=s.d2r(e);void 0!==r&&o.call("_guiRelayout",t,u,r)})}}function Et(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min(J,e+vt)),i=Math.max(0,Math.min(K,r+mt)),a=Math.abs(n-vt),o=Math.abs(i-mt);function s(){wt="",yt.r=yt.l,yt.t=yt.b,Mt.attr("d","M0,0Z")}yt.l=Math.min(vt,n),yt.r=Math.max(vt,n),yt.t=Math.min(mt,i),yt.b=Math.max(mt,i),nt?a>T||o>T?(wt="xy",a/J>o/K?(o=a*K/J,mt>i?yt.t=mt-o:yt.b=mt+o):(a=o*J/K,vt>n?yt.l=vt-a:yt.r=vt+a),Mt.attr("d",V(yt))):s():!et||o10||r.scrollWidth-r.clientWidth>10)){clearTimeout(Pt);var n=-e.deltaY;if(isFinite(n)||(n=e.wheelDelta/10),isFinite(n)){var i,a=Math.exp(-Math.min(Math.max(n,-20),20)/200),o=Rt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-o.left)/o.width,c=(o.bottom-e.clientY)/o.height;if(it){for(C||(l=.5),i=0;ig[1]-.01&&(e.domain=s),i.noneOrAll(t.domain,e.domain,s)}return r("layer"),e}},{"../../lib":692,"fast-isnumeric":214}],757:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var i=[t.r2l(t.range[0]),t.r2l(t.range[1])],a=i[0]+(i[1]-i[0])*r;t.range=t._input.range=[t.l2r(a+(i[0]-a)*e),t.l2r(a+(i[1]-a)*e)]}},{"../../constants/alignment":664}],758:[function(t,e,r){"use strict";var n=t("polybooljs"),i=t("../../registry"),a=t("../../components/color"),o=t("../../components/fx"),s=t("../../lib/polygon"),l=t("../../lib/throttle"),c=t("../../components/fx/helpers").makeEventData,u=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),h=t("../../plot_api/subroutines").redrawReglTraces,p=t("./constants"),d=p.MINSELECT,g=s.filter,v=s.tester;function m(t){return t._id}function y(t,e,r,n,i,a,o){var s,l,c,u,f,h,p,d,g,v=e._hoverdata,m=e._fullLayout.clickmode.indexOf("event")>-1,y=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(v)){w(t,e,a);var x=function(t,e){var r,n,i=t[0],a=-1,o=[];for(n=0;n0?function(t,e){var r,n,i,a=[];for(i=0;i0&&a.push(r);if(1===a.length&&a[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(i=0;i1)return!1;if((i+=r.selectedpoints.length)>1)return!1}return 1===i}(s)&&(h=T(x))){for(o&&o.remove(),g=0;g0?"M"+i.join("M")+"Z":"M0,0Z",e.attr("d",n)}function T(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,i=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(i)>-1}function S(t,e,r){var n,a,o,s;for(n=0;n-1&&y(e,T,i.xaxes,i.yaxes,i.subplot,i,H),"event"===r&&T.emit("plotly_selected",void 0);o.click(T,e)})},i.doneFn=function(){W.remove(),l.done(Y).then(function(){l.clear(Y),i.gd.emit("plotly_selected",b),h&&i.selectionDefs&&(h.subtract=q,i.selectionDefs.push(h),i.mergedPolygons.length=0,[].push.apply(i.mergedPolygons,f))})}},clearSelect:E,selectOnClick:y}},{"../../components/color":569,"../../components/fx":608,"../../components/fx/helpers":604,"../../lib/clear_gl_canvases":677,"../../lib/polygon":704,"../../lib/throttle":717,"../../plot_api/subroutines":731,"../../registry":823,"./axis_ids":743,"./constants":746,polybooljs:456}],759:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=a.cleanNumber,s=a.ms2DateTime,l=a.dateTime2ms,c=a.ensureNumber,u=t("../../constants/numerical"),f=u.FP_SAFE,h=u.BADNUM,p=u.LOG_CLIP,d=t("./constants"),g=t("./axis_ids");function v(t){return Math.pow(10,t)}function m(t){return null!=t}e.exports=function(t,e){e=e||{};var r=(t._id||"x").charAt(0);function u(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-2*p*Math.abs(n-i))}return h}function y(e,r,n){var o=l(e,n||t.calendar);if(o===h){if(!i(e))return h;e=+e;var s=Math.floor(10*a.mod(e+.05,1)),c=Math.round(e-s/10);o=l(new Date(c))+s/10}return o}function x(e,r,n){return s(e,r,n||t.calendar)}function b(e){return t._categories[Math.round(e)]}function _(e){if(m(e)){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return h}function w(e){if(t._categoriesMap)return t._categoriesMap[e]}function k(t){var e=w(t);return void 0!==e?e:i(t)?+t:void 0}function M(e){return i(e)?n.round(t._b+t._m*e,2):h}function A(e){return(e-t._b)/t._m}t.c2l="log"===t.type?u:c,t.l2c="log"===t.type?v:c,t.l2p=M,t.p2l=A,t.c2p="log"===t.type?function(t,e){return M(u(t,e))}:M,t.p2c="log"===t.type?function(t){return v(A(t))}:A,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=A,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return u(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=u,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(A(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=A,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=a.identity,t.d2c=t.r2c=t.d2l=t.r2l=y,t.c2d=t.c2r=t.l2d=t.l2r=x,t.d2p=t.r2p=function(e,r,n){return t.l2p(y(e,0,n))},t.p2d=t.p2r=function(t,e,r){return x(A(t),e,r)},t.cleanPos=function(e){return a.cleanDate(e,h,t.calendar)}):"category"===t.type?(t.d2c=t.d2l=_,t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var r=k(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(A(t))},t.r2p=t.d2p,t.p2r=A,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}):"multicategory"===t.type&&(t.r2d=t.c2d=t.l2d=b,t.d2r=t.d2l_noadd=k,t.r2c=function(e){var r=k(e);return void 0!==r?r:t.fraction2r(.5)},t.r2c_just_indices=w,t.l2r=t.c2r=c,t.r2l=k,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return b(A(t))},t.r2p=t.d2p,t.p2r=A,t.cleanPos=function(t){return Array.isArray(t)||"string"==typeof t&&""!==t?t:c(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e,n){n||(n={}),e||(e="range");var o,s,l=a.nestedProperty(t,e).get();if(s=(s="date"===t.type?a.dfltRange(t.calendar):"y"===r?d.DFLTRANGEY:n.dfltRange||d.DFLTRANGEX).slice(),l&&2===l.length)for("date"===t.type&&(l[0]=a.cleanDate(l[0],h,t.calendar),l[1]=a.cleanDate(l[1],h,t.calendar)),o=0;o<2;o++)if("date"===t.type){if(!a.isDateTime(l[o],t.calendar)){t[e]=s;break}if(t.r2l(l[0])===t.r2l(l[1])){var c=a.constrain(t.r2l(l[0]),a.MIN_MS+1e3,a.MAX_MS-1e3);l[0]=t.l2r(c-1e3),l[1]=t.l2r(c+1e3);break}}else{if(!i(l[o])){if(!i(l[1-o])){t[e]=s;break}l[o]=l[1-o]*(o?10:.1)}if(l[o]<-f?l[o]=-f:l[o]>f&&(l[o]=f),l[0]===l[1]){var u=Math.max(1,Math.abs(1e-6*l[0]));l[0]-=u,l[1]+=u}}else a.nestedProperty(t,e).set(s)},t.setScale=function(n){var i=e._size;if(t.overlaying){var a=g.getFromId({_fullLayout:e},t.overlaying);t.domain=a.domain}var o=n&&t._r?"_r":"range",s=t.calendar;t.cleanRange(o);var l=t.r2l(t[o][0],s),c=t.r2l(t[o][1],s);if("y"===r?(t._offset=i.t+(1-t.domain[1])*i.h,t._length=i.h*(t.domain[1]-t.domain[0]),t._m=t._length/(l-c),t._b=-t._m*c):(t._offset=i.l+t.domain[0]*i.w,t._length=i.w*(t.domain[1]-t.domain[0]),t._m=t._length/(c-l),t._b=-t._m*l),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,i,o,s,l=t.type,c="date"===l&&e[r+"calendar"];if(r in e){if(n=e[r],s=e._length||a.minRowLength(n),a.isTypedArray(n)&&("linear"===l||"log"===l)){if(s===n.length)return n;if(n.subarray)return n.subarray(0,s)}if("multicategory"===l)return function(t,e){var r,n=new Array(e),i=new Array(e),o=[[0,{}],[0,{}]];if(a.isArrayOrTypedArray(t[0])&&a.isArrayOrTypedArray(t[1])){for(r=0;r rect").call(a.setTranslate,0,0).call(a.setScale,1,1),t.plot.call(a.setTranslate,e._offset,r._offset).call(a.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(a.setPointGroupScale,1,1),n.selectAll(".textpoint").call(a.setTextPointsScale,1,1),n.call(a.hideOutsideRangePoints,t)}function x(e,r){var n,s,l,u=g[e.xaxis._id],f=g[e.yaxis._id],h=[];if(u){s=(n=t._fullLayout[u.axisName])._r,l=u.to,h[0]=(s[0]*(1-r)+r*l[0]-s[0])/(s[1]-s[0])*e.xaxis._length;var p=s[1]-s[0],d=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[2]=e.xaxis._length*(1-r+r*d/p)}else h[0]=0,h[2]=e.xaxis._length;if(f){s=(n=t._fullLayout[f.axisName])._r,l=f.to,h[1]=(s[1]*(1-r)+r*l[1]-s[1])/(s[0]-s[1])*e.yaxis._length;var v=s[1]-s[0],m=l[1]-l[0];n.range[0]=s[0]*(1-r)+r*l[0],n.range[1]=s[1]*(1-r)+r*l[1],h[3]=e.yaxis._length*(1-r+r*m/v)}else h[1]=0,h[3]=e.yaxis._length;!function(e,r){var n,a=[e._id,r._id];function s(e,r,i){for(n=0;nr.duration?(function(){for(var e={},r=0;r0&&(i["_"+r+"axes"]||{})[e])return i;if((i[r+"axis"]||r)===e){if(o(i,r))return i;if((i[r]||[]).length||i[r+"0"])return i}}}(e,r,s);if(!l)return;if("histogram"===l.type&&s==={v:"y",h:"x"}[l.orientation||"v"])return void(t.type="linear");var c,u=s+"calendar",f=l[u],h={noMultiCategory:!n(l,"cartesian")||n(l,"noMultiCategory")};if(o(l,s)){var p=a(l),d=[];for(c=0;c0?".":"")+a;i.isPlainObject(o)?l(o,e,s,n+1):e(s,a,o)}})}r.manageCommandObserver=function(t,e,n,o){var s={},l=!0;e&&e._commandObserver&&(s=e._commandObserver),s.cache||(s.cache={}),s.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,n,s.lookupTable);if(e&&e._commandObserver){if(c)return s;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,s}if(c){a(t,c,s.cache),s.check=function(){if(l){var e=a(t,c,s.cache);return e.changed&&o&&void 0!==s.lookupTable[e.value]&&(s.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:s.lookupTable[e.value]})).then(s.enable,s.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],f=0;fi*Math.PI/180}return!1},r.getPath=function(){return n.geo.path().projection(r)},r.getBounds=function(t){return r.getPath().bounds(t)},r.fitExtent=function(t,e){var n=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=r.clipExtent&&r.clipExtent();r.scale(150).translate([0,0]),a&&r.clipExtent(null);var o=r.getBounds(e),s=Math.min(n/(o[1][0]-o[0][0]),i/(o[1][1]-o[0][1])),l=+t[0][0]+(n-s*(o[1][0]+o[0][0]))/2,c=+t[0][1]+(i-s*(o[1][1]+o[0][1]))/2;return a&&r.clipExtent(a),r.scale(150*s).translate([l,c])},r.precision(g.precision),i&&r.clipAngle(i-g.clipPad);return r}(e);u.center([c.lon-l.lon,c.lat-l.lat]).rotate([-l.lon,-l.lat,l.roll]).parallels(s.parallels);var f=[[r.l+r.w*o.x[0],r.t+r.h*(1-o.y[1])],[r.l+r.w*o.x[1],r.t+r.h*(1-o.y[0])]],h=e.lonaxis,p=e.lataxis,d=function(t,e){var r=g.clipPad,n=t[0]+r,i=t[1]-r,a=e[0]+r,o=e[1]-r;n>0&&i<0&&(i+=360);var s=(i-n)/4;return{type:"Polygon",coordinates:[[[n,a],[n,o],[n+s,o],[n+2*s,o],[n+3*s,o],[i,o],[i,a],[i-s,a],[i-2*s,a],[i-3*s,a],[n,a]]]}}(h.range,p.range);u.fitExtent(f,d);var v=this.bounds=u.getBounds(d),m=this.fitScale=u.scale(),y=u.translate();if(!isFinite(v[0][0])||!isFinite(v[0][1])||!isFinite(v[1][0])||!isFinite(v[1][1])||isNaN(y[0])||isNaN(y[0])){for(var x=this.graphDiv,b=["projection.rotation","center","lonaxis.range","lataxis.range"],_="Invalid geo settings, relayout'ing to default view.",w={},k=0;k-1&&p(n.event,a,[r.xaxis],[r.yaxis],r.id,g),c.indexOf("event")>-1&&l.click(a,n.event))})}function v(t){return r.projection.invert([t[0]+r.xaxis._offset,t[1]+r.yaxis._offset])}},x.makeFramework=function(){var t=this,e=t.graphDiv,r=e._fullLayout,i="clip"+r._uid+t.id;t.clipDef=r._clips.append("clipPath").attr("id",i),t.clipRect=t.clipDef.append("rect"),t.framework=n.select(t.container).append("g").attr("class","geo "+t.id).call(s.setClipUrl,i,e),t.project=function(e){var r=t.projection(e);return r?[r[0]-t.xaxis._offset,r[1]-t.yaxis._offset]:[null,null]},t.xaxis={_id:"x",c2p:function(e){return t.project(e)[0]}},t.yaxis={_id:"y",c2p:function(e){return t.project(e)[1]}},t.mockAxis={type:"linear",showexponent:"all",exponentformat:"B"},u.setConvert(t.mockAxis,r)},x.saveViewInitial=function(t){var e=t.center||{},r=t.projection,n=r.rotation||{};t._isScoped?this.viewInitial={"center.lon":e.lon,"center.lat":e.lat,"projection.scale":r.scale}:t._isClipped?this.viewInitial={"projection.scale":r.scale,"projection.rotation.lon":n.lon,"projection.rotation.lat":n.lat}:this.viewInitial={"center.lon":e.lon,"center.lat":e.lat,"projection.scale":r.scale,"projection.rotation.lon":n.lon}},x.render=function(){var t,e=this.projection,r=e.getPath();function n(t){var r=e(t.lonlat);return r?"translate("+r[0]+","+r[1]+")":null}function i(t){return e.isLonLatOverEdges(t.lonlat)?"none":null}for(t in this.basePaths)this.basePaths[t].attr("d",r);for(t in this.dataPaths)this.dataPaths[t].attr("d",function(t){return r(t.geojson)});for(t in this.dataPoints)this.dataPoints[t].attr("display",i).attr("transform",n)}},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../lib":692,"../../lib/topojson_utils":719,"../../registry":823,"../cartesian/axes":740,"../cartesian/select":758,"../plots":804,"./constants":769,"./projections":775,"./zoom":776,d3:148,"topojson-client":516}],771:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/get_data").getSubplotCalcData,a=t("../../lib").counterRegex,o="geo";r.name=o,r.attr=o,r.idRoot=o,r.idRegex=r.attrRegex=a(o),r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t.calcdata,a=e._subplots.geo;void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var s=0;s0&&k<0&&(k+=360);var M,A,T,S=(w+k)/2;if(!c){var C=u?s.projRotate:[S,0,0];M=r("projection.rotation.lon",C[0]),r("projection.rotation.lat",C[1]),r("projection.rotation.roll",C[2]),r("showcoastlines",!u)&&(r("coastlinecolor"),r("coastlinewidth")),r("showocean")&&r("oceancolor")}(c?(A=-96.6,T=38.7):(A=u?S:M,T=(_[0]+_[1])/2),r("center.lon",A),r("center.lat",T),f)&&r("projection.parallels",s.projParallels||[0,60]);r("projection.scale"),r("showland")&&r("landcolor"),r("showlakes")&&r("lakecolor"),r("showrivers")&&(r("rivercolor"),r("riverwidth")),r("showcountries",u&&"usa"!==a)&&(r("countrycolor"),r("countrywidth")),("usa"===a||"north america"===a&&50===n)&&(r("showsubunits",!0),r("subunitcolor"),r("subunitwidth")),u||r("showframe",!0)&&(r("framecolor"),r("framewidth")),r("bgcolor")}e.exports=function(t,e,r){n(t,e,r,{type:"geo",attributes:a,handleDefaults:s,partition:"y"})}},{"../../subplot_defaults":818,"../constants":769,"./layout_attributes":774}],774:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("../../domain").attributes,a=t("../constants"),o=t("../../../plot_api/edit_types").overrideAll,s={range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},showgrid:{valType:"boolean",dflt:!1},tick0:{valType:"number"},dtick:{valType:"number"},gridcolor:{valType:"color",dflt:n.lightLine},gridwidth:{valType:"number",min:0,dflt:1}};(e.exports=o({domain:i({name:"geo"},{}),resolution:{valType:"enumerated",values:[110,50],dflt:110,coerceNumber:!0},scope:{valType:"enumerated",values:Object.keys(a.scopeDefaults),dflt:"world"},projection:{type:{valType:"enumerated",values:Object.keys(a.projNames)},rotation:{lon:{valType:"number"},lat:{valType:"number"},roll:{valType:"number"}},parallels:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},scale:{valType:"number",min:0,dflt:1}},center:{lon:{valType:"number"},lat:{valType:"number"}},showcoastlines:{valType:"boolean"},coastlinecolor:{valType:"color",dflt:n.defaultLine},coastlinewidth:{valType:"number",min:0,dflt:1},showland:{valType:"boolean",dflt:!1},landcolor:{valType:"color",dflt:a.landColor},showocean:{valType:"boolean",dflt:!1},oceancolor:{valType:"color",dflt:a.waterColor},showlakes:{valType:"boolean",dflt:!1},lakecolor:{valType:"color",dflt:a.waterColor},showrivers:{valType:"boolean",dflt:!1},rivercolor:{valType:"color",dflt:a.waterColor},riverwidth:{valType:"number",min:0,dflt:1},showcountries:{valType:"boolean"},countrycolor:{valType:"color",dflt:n.defaultLine},countrywidth:{valType:"number",min:0,dflt:1},showsubunits:{valType:"boolean"},subunitcolor:{valType:"color",dflt:n.defaultLine},subunitwidth:{valType:"number",min:0,dflt:1},showframe:{valType:"boolean"},framecolor:{valType:"color",dflt:n.defaultLine},framewidth:{valType:"number",min:0,dflt:1},bgcolor:{valType:"color",dflt:n.background},lonaxis:s,lataxis:s},"plot","from-root")).uirevision={valType:"any",editType:"none"}},{"../../../components/color/attributes":568,"../../../plot_api/edit_types":723,"../../domain":766,"../constants":769}],775:[function(t,e,r){"use strict";e.exports=function(t){function e(t,e){return{type:"Feature",id:t.id,properties:t.properties,geometry:r(t.geometry,e)}}function r(e,n){if(!e)return null;if("GeometryCollection"===e.type)return{type:"GeometryCollection",geometries:object.geometries.map(function(t){return r(t,n)})};if(!c.hasOwnProperty(e.type))return null;var i=c[e.type];return t.geo.stream(e,n(i)),i.result()}t.geo.project=function(t,e){var i=e.stream;if(!i)throw new Error("not yet supported");return(t&&n.hasOwnProperty(t.type)?n[t.type]:r)(t,i)};var n={Feature:e,FeatureCollection:function(t,r){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,r)})}}},i=[],a=[],o={point:function(t,e){i.push([t,e])},result:function(){var t=i.length?i.length<2?{type:"Point",coordinates:i[0]}:{type:"MultiPoint",coordinates:i}:null;return i=[],t}},s={lineStart:u,point:function(t,e){i.push([t,e])},lineEnd:function(){i.length&&(a.push(i),i=[])},result:function(){var t=a.length?a.length<2?{type:"LineString",coordinates:a[0]}:{type:"MultiLineString",coordinates:a}:null;return a=[],t}},l={polygonStart:u,lineStart:u,point:function(t,e){i.push([t,e])},lineEnd:function(){var t=i.length;if(t){do{i.push(i[0].slice())}while(++t<4);a.push(i),i=[]}},polygonEnd:u,result:function(){if(!a.length)return null;var t=[],e=[];return a.forEach(function(r){!function(t){if((e=t.length)<4)return!1;for(var e,r=0,n=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++rn^p>n&&r<(h-c)*(n-u)/(p-u)+c&&(i=!i)}return i}(t[0],r))return t.push(e),!0})||t.push([e])}),a=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},c={Point:o,MultiPoint:o,LineString:s,MultiLineString:s,Polygon:l,MultiPolygon:l,Sphere:l};function u(){}var f=1e-6,h=f*f,p=Math.PI,d=p/2,g=(Math.sqrt(p),p/180),v=180/p;function m(t){return t>1?d:t<-1?-d:Math.asin(t)}function y(t){return t>1?0:t<-1?p:Math.acos(t)}var x=t.geo.projection,b=t.geo.projectionMutator;function _(t,e){var r=(2+d)*Math.sin(e);e/=2;for(var n=0,i=1/0;n<10&&Math.abs(i)>f;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(p*(4+p))*t*(1+Math.cos(e)),2*Math.sqrt(p/(4+p))*Math.sin(e)]}t.geo.interrupt=function(e){var r,n=[[[[-p,0],[0,d],[p,0]]],[[[-p,0],[0,-d],[p,0]]]];function i(t,r){for(var i=r<0?-1:1,a=n[+(r<0)],o=0,s=a.length-1;oa[o][2][0];++o);var l=e(t-a[o][1][0],r);return l[0]+=e(a[o][1][0],i*r>i*a[o][0][1]?a[o][0][1]:r)[0],l}e.invert&&(i.invert=function(t,a){for(var o=r[+(a<0)],s=n[+(a<0)],c=0,u=o.length;c=0;--i){var o=n[1][i],l=180*o[0][0]/p,c=180*o[0][1]/p,u=180*o[1][1]/p,f=180*o[2][0]/p,h=180*o[2][1]/p;r.push(s([[f-e,h-e],[f-e,u+e],[l+e,u+e],[l+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(r)]}}(),l)},i},a.lobes=function(t){return arguments.length?(n=t.map(function(t){return t.map(function(t){return[[t[0][0]*p/180,t[0][1]*p/180],[t[1][0]*p/180,t[1][1]*p/180],[t[2][0]*p/180,t[2][1]*p/180]]})}),r=n.map(function(t){return t.map(function(t){var r,n=e(t[0][0],t[0][1])[0],i=e(t[2][0],t[2][1])[0],a=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})}),a):n.map(function(t){return t.map(function(t){return[[180*t[0][0]/p,180*t[0][1]/p],[180*t[1][0]/p,180*t[1][1]/p],[180*t[2][0]/p,180*t[2][1]/p]]})})},a},_.invert=function(t,e){var r=.5*e*Math.sqrt((4+p)/p),n=m(r),i=Math.cos(n);return[t/(2/Math.sqrt(p*(4+p))*(1+i)),m((n+r*(i+2))/(2+d))]},(t.geo.eckert4=function(){return x(_)}).raw=_;var w=t.geo.azimuthalEqualArea.raw;function k(t,e){if(arguments.length<2&&(e=t),1===e)return w;if(e===1/0)return M;function r(r,n){var i=w(r/e,n);return i[0]*=t,i}return r.invert=function(r,n){var i=w.invert(r/t,n);return i[0]*=e,i},r}function M(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function A(t,e){return[3*t/(2*p)*Math.sqrt(p*p/3-e*e),e]}function T(t,e){return[t,1.25*Math.log(Math.tan(p/4+.4*e))]}function S(t){return function(e){var r,n=t*Math.sin(e),i=30;do{e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e))}while(Math.abs(r)>f&&--i>0);return e/2}}M.invert=function(t,e){var r=2*m(e/2);return[t*Math.cos(r/2)/Math.cos(r),r]},(t.geo.hammer=function(){var t=2,e=b(k),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}).raw=k,A.invert=function(t,e){return[2/3*p*t/Math.sqrt(p*p/3-e*e),e]},(t.geo.kavrayskiy7=function(){return x(A)}).raw=A,T.invert=function(t,e){return[t,2.5*Math.atan(Math.exp(.8*e))-.625*p]},(t.geo.miller=function(){return x(T)}).raw=T,S(p);var C=function(t,e,r){var n=S(r);function i(r,i){return[t*r*Math.cos(i=n(i)),e*Math.sin(i)]}return i.invert=function(n,i){var a=m(i/e);return[n/(t*Math.cos(a)),m((2*a+Math.sin(2*a))/r)]},i}(Math.SQRT2/d,Math.SQRT2,p);function E(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791)),e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))]}(t.geo.mollweide=function(){return x(C)}).raw=C,E.invert=function(t,e){var r,n=e,i=25;do{var a=n*n,o=a*a;n-=r=(n*(1.007226+a*(.015085+o*(.028874*a-.044475-.005916*o)))-e)/(1.007226+a*(.045255+o*(.259866*a-.311325-.005916*11*o)))}while(Math.abs(r)>f&&--i>0);return[t/(.8707+(a=n*n)*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979)),n]},(t.geo.naturalEarth=function(){return x(E)}).raw=E;var L=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];function z(t,e){var r,n=Math.min(18,36*Math.abs(e)/p),i=Math.floor(n),a=n-i,o=(r=L[i])[0],s=r[1],l=(r=L[++i])[0],c=r[1],u=(r=L[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?d:-d)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function O(t,e){return[t*Math.cos(e),e]}function I(t,e){var r,n=Math.cos(e),i=(r=y(n*Math.cos(t/=2)))?r/Math.sin(r):1;return[2*n*Math.sin(t)*i,Math.sin(e)*i]}function P(t,e){var r=I(t,e);return[(r[0]+t/d)/2,(r[1]+e)/2]}L.forEach(function(t){t[1]*=1.0144}),z.invert=function(t,e){var r=e/d,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=L[a][1],s=L[a+1][1],l=L[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,p=u/c,m=f*(1-p*f*(1-2*p*f));if(m>=0||1===a){n=(e>=0?5:-5)*(m+i);var y,x=50;do{m=(i=Math.min(18,Math.abs(n)/5))-(a=Math.floor(i)),o=L[a][1],s=L[a+1][1],l=L[Math.min(19,a+2)][1],n-=(y=(e>=0?d:-d)*(s+m*(l-o)/2+m*m*(l-2*s+o)/2)-e)*v}while(Math.abs(y)>h&&--x>0);break}}while(--a>=0);var b=L[a][0],_=L[a+1][0],w=L[Math.min(19,a+2)][0];return[t/(_+m*(w-b)/2+m*m*(w-2*_+b)/2),n*g]},(t.geo.robinson=function(){return x(z)}).raw=z,O.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return x(O)}).raw=O,I.invert=function(t,e){if(!(t*t+4*e*e>p*p+f)){var r=t,n=e,i=25;do{var a,o=Math.sin(r),s=Math.sin(r/2),l=Math.cos(r/2),c=Math.sin(n),u=Math.cos(n),h=Math.sin(2*n),d=c*c,g=u*u,v=s*s,m=1-g*l*l,x=m?y(u*l)*Math.sqrt(a=1/m):a=0,b=2*x*u*s-t,_=x*c-e,w=a*(g*v+x*u*l*d),k=a*(.5*o*h-2*x*c*s),M=.25*a*(h*s-x*c*g*o),A=a*(d*l+x*v*u),T=k*M-A*w;if(!T)break;var S=(_*k-b*A)/T,C=(b*M-_*w)/T;r-=S,n-=C}while((Math.abs(S)>f||Math.abs(C)>f)&&--i>0);return[r,n]}},(t.geo.aitoff=function(){return x(I)}).raw=I,P.invert=function(t,e){var r=t,n=e,i=25;do{var a,o=Math.cos(n),s=Math.sin(n),l=Math.sin(2*n),c=s*s,u=o*o,h=Math.sin(r),p=Math.cos(r/2),g=Math.sin(r/2),v=g*g,m=1-u*p*p,x=m?y(o*p)*Math.sqrt(a=1/m):a=0,b=.5*(2*x*o*g+r/d)-t,_=.5*(x*s+n)-e,w=.5*a*(u*v+x*o*p*c)+.5/d,k=a*(h*l/4-x*s*g),M=.125*a*(l*g-x*s*u*h),A=.5*a*(c*p+x*v*o)+.5,T=k*M-A*w,S=(_*k-b*A)/T,C=(b*M-_*w)/T;r-=S,n-=C}while((Math.abs(S)>f||Math.abs(C)>f)&&--i>0);return[r,n]},(t.geo.winkel3=function(){return x(P)}).raw=P}},{}],776:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../registry"),o=Math.PI/180,s=180/Math.PI,l={cursor:"pointer"},c={cursor:"auto"};function u(t,e){return n.behavior.zoom().translate(e.translate()).scale(e.scale())}function f(t,e,r){var n=t.id,o=t.graphDiv,s=o.layout,l=s[n],c=o._fullLayout,u=c[n],f={};function h(t,e){var r=i.nestedProperty(u,t);r.get()!==e&&(r.set(e),i.nestedProperty(l,t).set(e),f[n+"."+t]=e)}r(h),h("projection.scale",e.scale()/t.fitScale),a.call("_storeDirectGUIEdit",s,c._preGUI,f),o.emit("plotly_relayout",f)}function h(t,e){var r=u(0,e);function i(r){var n=e.invert(t.midPt);r("center.lon",n[0]),r("center.lat",n[1])}return r.on("zoomstart",function(){n.select(this).style(l)}).on("zoom",function(){e.scale(n.event.scale).translate(n.event.translate),t.render()}).on("zoomend",function(){n.select(this).style(c),f(t,e,i)}),r}function p(t,e){var r,i,a,o,s,h,p,d,g,v=u(0,e),m=2;function y(t){return e.invert(t)}function x(r){var n=e.rotate(),i=e.invert(t.midPt);r("projection.rotation.lon",-n[0]),r("center.lon",i[0]),r("center.lat",i[1])}return v.on("zoomstart",function(){n.select(this).style(l),r=n.mouse(this),i=e.rotate(),a=e.translate(),o=i,s=y(r)}).on("zoom",function(){if(h=n.mouse(this),function(t){var r=y(t);if(!r)return!0;var n=e(r);return Math.abs(n[0]-t[0])>m||Math.abs(n[1]-t[1])>m}(r))return v.scale(e.scale()),void v.translate(e.translate());e.scale(n.event.scale),e.translate([a[0],n.event.translate[1]]),s?y(h)&&(d=y(h),p=[o[0]+(d[0]-s[0]),i[1],i[2]],e.rotate(p),o=p):s=y(r=h),g=!0,t.render()}).on("zoomend",function(){n.select(this).style(c),g&&f(t,e,x)}),v}function d(t,e){var r,i={r:e.rotate(),k:e.scale()},a=u(0,e),h=function(t){var e=0,r=arguments.length,i=[];for(;++ed?(a=(f>0?90:-90)-p,i=0):(a=Math.asin(f/d)*s-p,i=Math.sqrt(d*d-f*f));var g=180-a-2*p,m=(Math.atan2(h,u)-Math.atan2(c,i))*s,x=(Math.atan2(h,u)-Math.atan2(c,-i))*s,b=v(r[0],r[1],a,m),_=v(r[0],r[1],g,x);return b<=_?[a,m,r[2]]:[g,x,r[2]]}(k,r,C);isFinite(M[0])&&isFinite(M[1])&&isFinite(M[2])||(M=C),e.rotate(M),C=M}}else r=g(e,T=b);h.of(this,arguments)({type:"zoom"})}),A=h.of(this,arguments),p++||A({type:"zoomstart"})}).on("zoomend",function(){var r;n.select(this).style(c),d.call(a,"zoom",null),r=h.of(this,arguments),--p||r({type:"zoomend"}),f(t,e,m)}).on("zoom.redraw",function(){t.render()}),n.rebind(a,h,"on")}function g(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&function(t){var e=t[0]*o,r=t[1]*o,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}(r)}function v(t,e,r,n){var i=m(r-t),a=m(n-e);return Math.sqrt(i*i+a*a)}function m(t){return(t%360+540)%360-180}function y(t,e,r){var n=r*o,i=t.slice(),a=0===e?1:0,s=2===e?1:2,l=Math.cos(n),c=Math.sin(n);return i[a]=t[a]*l-t[s]*c,i[s]=t[s]*l+t[a]*c,i}function x(t,e){for(var r=0,n=0,i=t.length;nMath.abs(s)?(c.boxEnd[1]=c.boxStart[1]+Math.abs(a)*_*(s>=0?1:-1),c.boxEnd[1]l[3]&&(c.boxEnd[1]=l[3],c.boxEnd[0]=c.boxStart[0]+(l[3]-c.boxStart[1])/Math.abs(_))):(c.boxEnd[0]=c.boxStart[0]+Math.abs(s)/_*(a>=0?1:-1),c.boxEnd[0]l[2]&&(c.boxEnd[0]=l[2],c.boxEnd[1]=c.boxStart[1]+(l[2]-c.boxStart[0])*Math.abs(_)))}}else c.boxEnabled?(a=c.boxStart[0]!==c.boxEnd[0],s=c.boxStart[1]!==c.boxEnd[1],a||s?(a&&(v(0,c.boxStart[0],c.boxEnd[0]),t.xaxis.autorange=!1),s&&(v(1,c.boxStart[1],c.boxEnd[1]),t.yaxis.autorange=!1),t.relayoutCallback()):t.glplot.setDirty(),c.boxEnabled=!1,c.boxInited=!1):c.boxInited&&(c.boxInited=!1);break;case"pan":c.boxEnabled=!1,c.boxInited=!1,e?(c.panning||(c.dragStart[0]=n,c.dragStart[1]=i),Math.abs(c.dragStart[0]-n)Math.abs(e))c.rotate(a,0,0,-t*r*Math.PI*d.rotateSpeed/window.innerWidth);else{var o=-d.zoomSpeed*i*e/window.innerHeight*(a-c.lastT())/20;c.pan(a,0,0,f*(Math.exp(o)-1))}}},!0),d};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset"),l=t("has-passive-events")},{"3d-view":45,"has-passive-events":394,"mouse-change":418,"mouse-event-offset":419,"mouse-wheel":421,"right-now":480}],783:[function(t,e,r){"use strict";var n=t("../../plot_api/edit_types").overrideAll,i=t("../../components/fx/layout_attributes"),a=t("./scene"),o=t("../get_data").getSubplotData,s=t("../../lib"),l=t("../../constants/xmlns_namespaces");r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=r.attrRegex=s.counterRegex("scene"),r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.baseLayoutAttrOverrides=n({hoverlabel:i.hoverlabel},"plot","nested"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=e._subplots.gl3d,i=0;i.999&&(p="turntable"):p="turntable"}else p="turntable";r("dragmode",p),r("hovermode",n.getDfltFromLayout("hovermode"))}e.exports=function(t,e,r){var i=e._basePlotModules.length>1;o(t,e,r,{type:"gl3d",attributes:l,handleDefaults:c,fullLayout:e,font:e.font,fullData:r,getDfltFromLayout:function(e){if(!i)return n.validate(t[e],l[e])?t[e]:void 0},paper_bgcolor:e.paper_bgcolor,calendar:e.calendar})}},{"../../../components/color":569,"../../../lib":692,"../../../registry":823,"../../subplot_defaults":818,"./axis_defaults":786,"./layout_attributes":789}],789:[function(t,e,r){"use strict";var n=t("./axis_attributes"),i=t("../../domain").attributes,a=t("../../../lib/extend").extendFlat,o=t("../../../lib").counterRegex;function s(t,e,r){return{x:{valType:"number",dflt:t,editType:"camera"},y:{valType:"number",dflt:e,editType:"camera"},z:{valType:"number",dflt:r,editType:"camera"},editType:"camera"}}e.exports={_arrayAttrRegexps:[o("scene",".annotations",!0)],bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"plot"},camera:{up:a(s(0,0,1),{}),center:a(s(0,0,0),{}),eye:a(s(1.25,1.25,1.25),{}),editType:"camera"},domain:i({name:"scene",editType:"plot"}),aspectmode:{valType:"enumerated",values:["auto","cube","data","manual"],dflt:"auto",editType:"plot",impliedEdits:{"aspectratio.x":void 0,"aspectratio.y":void 0,"aspectratio.z":void 0}},aspectratio:{x:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},y:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},z:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},editType:"plot",impliedEdits:{aspectmode:"manual"}},xaxis:n,yaxis:n,zaxis:n,dragmode:{valType:"enumerated",values:["orbit","turntable","zoom","pan",!1],editType:"plot"},hovermode:{valType:"enumerated",values:["closest",!1],dflt:"closest",editType:"modebar"},uirevision:{valType:"any",editType:"none"},editType:"plot",_deprecated:{cameraposition:{valType:"info_array",editType:"camera"}}}},{"../../../lib":692,"../../../lib/extend":682,"../../domain":766,"./axis_attributes":785}],790:[function(t,e,r){"use strict";var n=t("../../../lib/str2rgbarray"),i=["xaxis","yaxis","zaxis"];function a(){this.enabled=[!0,!0,!0],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.drawSides=[!0,!0,!0],this.lineWidth=[1,1,1]}a.prototype.merge=function(t){for(var e=0;e<3;++e){var r=t[i[e]];r.visible?(this.enabled[e]=r.showspikes,this.colors[e]=n(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness):(this.enabled[e]=!1,this.drawSides[e]=!1)}},e.exports=function(t){var e=new a;return e.merge(t),e}},{"../../../lib/str2rgbarray":715}],791:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.axesOptions,r=t.glplot.axesPixels,s=t.fullSceneLayout,l=[[],[],[]],c=0;c<3;++c){var u=s[a[c]];if(u._length=(r[c].hi-r[c].lo)*r[c].pixelsPerDataUnit/t.dataScale[c],Math.abs(u._length)===1/0||isNaN(u._length))l[c]=[];else{u._input_range=u.range.slice(),u.range[0]=r[c].lo/t.dataScale[c],u.range[1]=r[c].hi/t.dataScale[c],u._m=1/(t.dataScale[c]*r[c].pixelsPerDataUnit),u.range[0]===u.range[1]&&(u.range[0]-=1,u.range[1]+=1);var f=u.tickmode;if("auto"===u.tickmode){u.tickmode="linear";var h=u.nticks||i.constrain(u._length/40,4,9);n.autoTicks(u,Math.abs(u.range[1]-u.range[0])/h)}for(var p=n.calcTicks(u),d=0;d/g," "));l[c]=p,u.tickmode=f}}e.ticks=l;for(var c=0;c<3;++c){o[c]=.5*(t.glplot.bounds[0][c]+t.glplot.bounds[1][c]);for(var d=0;d<2;++d)e.bounds[d][c]=t.glplot.bounds[d][c]}t.contourLevels=function(t){for(var e=new Array(3),r=0;r<3;++r){for(var n=t[r],i=new Array(n.length),a=0;a")}else v=c.textLabel;t.fullSceneLayout.hovermode&&f.loneHover({x:(.5+.5*d[0]/d[3])*i,y:(.5-.5*d[1]/d[3])*a,xLabel:w,yLabel:k,zLabel:M,text:v,name:l.name,color:f.castHoverOption(e,m,"bgcolor")||l.color,borderColor:f.castHoverOption(e,m,"bordercolor"),fontFamily:f.castHoverOption(e,m,"font.family"),fontSize:f.castHoverOption(e,m,"font.size"),fontColor:f.castHoverOption(e,m,"font.color")},{container:r,gd:t.graphDiv});var T={x:c.traceCoordinate[0],y:c.traceCoordinate[1],z:c.traceCoordinate[2],data:e._input,fullData:e,curveNumber:e.index,pointNumber:m};e._module.eventData&&(T=e._module.eventData(T,c,e,{},m)),f.appendArrayPointValue(T,e,m);var S={points:[T]};c.buttons&&c.distance<5?t.graphDiv.emit("plotly_click",S):t.graphDiv.emit("plotly_hover",S),o=S}else f.loneUnhover(r),t.graphDiv.emit("plotly_unhover",o);t.drawAnnotations(t)}.bind(null,t),t.traces={},!0}function b(t,e){var r=document.createElement("div"),n=t.container;this.graphDiv=t.graphDiv;var i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.top=i.style.left="0px",i.style.width=i.style.height="100%",i.style["z-index"]=20,i.style["pointer-events"]="none",r.appendChild(i),this.svgContainer=i,r.id=t.id,r.style.position="absolute",r.style.top=r.style.left="0px",r.style.width=r.style.height="100%",n.appendChild(r),this.fullLayout=e,this.id=t.id||"scene",this.fullSceneLayout=e[this.id],this.plotArgs=[[],{},{}],this.axesOptions=v(e[this.id]),this.spikeOptions=m(e[this.id]),this.container=r,this.staticMode=!!t.staticPlot,this.pixelRatio=t.plotGlPixelRatio||2,this.dataScale=[1,1,1],this.contourLevels=[[],[],[]],this.convertAnnotations=l.getComponentMethod("annotations3d","convert"),this.drawAnnotations=l.getComponentMethod("annotations3d","draw"),x(this)}var _=b.prototype;_.recoverContext=function(){var t=this,e=this.glplot.gl,r=this.glplot.canvas;this.glplot.dispose(),requestAnimationFrame(function n(){e.isContextLost()?requestAnimationFrame(n):x(t,r,e)?t.plot.apply(t,t.plotArgs):c.error("Catastrophic and unrecoverable WebGL error. Context lost.")})};var w=["xaxis","yaxis","zaxis"];function k(t,e,r){for(var n=t.fullSceneLayout,i=0;i<3;i++){var a=w[i],o=a.charAt(0),s=n[a],l=e[o],u=e[o+"calendar"],f=e["_"+o+"length"];if(c.isArrayOrTypedArray(l))for(var h,p=0;p<(f||l.length);p++)if(c.isArrayOrTypedArray(l[p]))for(var d=0;dg[1][a])g[0][a]=-1,g[1][a]=1;else{var C=g[1][a]-g[0][a];g[0][a]-=C/32,g[1][a]+=C/32}if("reversed"===s.autorange){var E=g[0][a];g[0][a]=g[1][a],g[1][a]=E}}else{var L=s.range;g[0][a]=s.r2l(L[0]),g[1][a]=s.r2l(L[1])}g[0][a]===g[1][a]&&(g[0][a]-=1,g[1][a]+=1),v[a]=g[1][a]-g[0][a],this.glplot.bounds[0][a]=g[0][a]*p[a],this.glplot.bounds[1][a]=g[1][a]*p[a]}var z=[1,1,1];for(a=0;a<3;++a){var O=m[l=(s=c[w[a]]).type];z[a]=Math.pow(O.acc,1/O.count)/p[a]}var I;if("auto"===c.aspectmode)I=Math.max.apply(null,z)/Math.min.apply(null,z)<=4?z:[1,1,1];else if("cube"===c.aspectmode)I=[1,1,1];else if("data"===c.aspectmode)I=z;else{if("manual"!==c.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var P=c.aspectratio;I=[P.x,P.y,P.z]}c.aspectratio.x=u.aspectratio.x=I[0],c.aspectratio.y=u.aspectratio.y=I[1],c.aspectratio.z=u.aspectratio.z=I[2],this.glplot.aspect=I;var D=c.domain||null,R=e._size||null;if(D&&R){var F=this.container.style;F.position="absolute",F.left=R.l+D.x[0]*R.w+"px",F.top=R.t+(1-D.y[1])*R.h+"px",F.width=R.w*(D.x[1]-D.x[0])+"px",F.height=R.h*(D.y[1]-D.y[0])+"px"}this.glplot.redraw()}},_.destroy=function(){this.glplot&&(this.camera.mouseListener.enabled=!1,this.container.removeEventListener("wheel",this.camera.wheelListener),this.camera=this.glplot.camera=null,this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null)},_.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),M(this.glplot.camera)},_.setCamera=function(t){var e;this.glplot.camera.lookAt.apply(this,[[(e=t).eye.x,e.eye.y,e.eye.z],[e.center.x,e.center.y,e.center.z],[e.up.x,e.up.y,e.up.z]])},_.saveCamera=function(t){var e=this.getCamera(),r=c.nestedProperty(t,this.id+".camera"),n=r.get(),i=!1;function a(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}if(void 0===n)i=!0;else for(var o=0;o<3;o++)for(var s=0;s<3;s++)if(!a(e,n,o,s)){i=!0;break}if(i){r.set(e);var u=this.fullLayout;c.nestedProperty(u,this.id+".camera").set(e),l.call("_storeDirectGUIEdit",t,u._preGUI,e)}return i},_.updateFx=function(t,e){var r=this.camera;if(r)if("orbit"===t)r.mode="orbit",r.keyBindingMode="rotate";else if("turntable"===t){r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate";var n=this.graphDiv,i=n._fullLayout,a=this.fullSceneLayout.camera,o=a.up.x,s=a.up.y,u=a.up.z;if(u/Math.sqrt(o*o+s*s+u*u)>.999)return;var f=this.id+".camera.up",h={x:0,y:0,z:1},p={};p[f]=h;var d=n.layout;l.call("_storeDirectGUIEdit",d,i._preGUI,p),a.up=h,c.nestedProperty(d,f).set(h)}else r.keyBindingMode=t;this.fullSceneLayout.hovermode=e},_.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(n),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,i=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var a=new Uint8Array(r*i*4);e.readPixels(0,0,r,i,e.RGBA,e.UNSIGNED_BYTE,a);for(var o=0,s=i-1;o0)}function l(t){var e={},r={};switch(t.type){case"circle":n.extendFlat(r,{"circle-radius":t.circle.radius,"circle-color":t.color,"circle-opacity":t.opacity});break;case"line":n.extendFlat(r,{"line-width":t.line.width,"line-color":t.color,"line-opacity":t.opacity});break;case"fill":n.extendFlat(r,{"fill-color":t.color,"fill-outline-color":t.fill.outlinecolor,"fill-opacity":t.opacity});break;case"symbol":var a=t.symbol,o=i(a.textposition,a.iconsize);n.extendFlat(e,{"icon-image":a.icon+"-15","icon-size":a.iconsize/10,"text-field":a.text,"text-size":a.textfont.size,"text-anchor":o.anchor,"text-offset":o.offset}),n.extendFlat(r,{"icon-color":t.color,"text-color":a.textfont.color,"text-opacity":t.opacity})}return{layout:e,paint:r}}o.update=function(t){this.visible?this.needsNewSource(t)?(this.removeLayer(),this.updateSource(t),this.updateLayer(t)):this.needsNewLayer(t)?this.updateLayer(t):this.updateStyle(t):(this.updateSource(t),this.updateLayer(t)),this.visible=s(t)},o.needsNewSource=function(t){return this.sourceType!==t.sourcetype||this.source!==t.source||this.layerType!==t.type},o.needsNewLayer=function(t){return this.layerType!==t.type||this.below!==t.below},o.updateSource=function(t){var e=this.map;if(e.getSource(this.idSource)&&e.removeSource(this.idSource),this.sourceType=t.sourcetype,this.source=t.source,s(t)){var r=function(t){var e,r=t.sourcetype,n=t.source,i={type:r};"geojson"===r?e="data":"vector"===r&&(e="string"==typeof n?"url":"tiles");return i[e]=n,i}(t);e.addSource(this.idSource,r)}},o.updateLayer=function(t){var e=this.map,r=l(t);this.removeLayer(),this.layerType=t.type,s(t)&&e.addLayer({id:this.idLayer,source:this.idSource,"source-layer":t.sourcelayer||"",type:t.type,layout:r.layout,paint:r.paint},t.below)},o.updateStyle=function(t){if(s(t)){var e=l(t);this.mapbox.setOptions(this.idLayer,"setLayoutProperty",e.layout),this.mapbox.setOptions(this.idLayer,"setPaintProperty",e.paint)}},o.removeLayer=function(){var t=this.map;t.getLayer(this.idLayer)&&t.removeLayer(this.idLayer)},o.dispose=function(){var t=this.map;t.removeLayer(this.idLayer),t.removeSource(this.idSource)},e.exports=function(t,e,r){var n=new a(t,e);return n.update(r),n}},{"../../lib":692,"./convert_text_opts":797}],800:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color").defaultLine,a=t("../domain").attributes,o=t("../font_attributes"),s=t("../../traces/scatter/attributes").textposition,l=t("../../plot_api/edit_types").overrideAll,c=t("../../plot_api/plot_template").templatedArray,u=o({});u.family.dflt="Open Sans Regular, Arial Unicode MS Regular",(e.exports=l({_arrayAttrRegexps:[n.counterRegex("mapbox",".layers",!0)],domain:a({name:"mapbox"}),accesstoken:{valType:"string",noBlank:!0,strict:!0},style:{valType:"any",values:["basic","streets","outdoors","light","dark","satellite","satellite-streets"],dflt:"basic"},center:{lon:{valType:"number",dflt:0},lat:{valType:"number",dflt:0}},zoom:{valType:"number",dflt:1},bearing:{valType:"number",dflt:0},pitch:{valType:"number",dflt:0},layers:c("layer",{visible:{valType:"boolean",dflt:!0},sourcetype:{valType:"enumerated",values:["geojson","vector"],dflt:"geojson"},source:{valType:"any"},sourcelayer:{valType:"string",dflt:""},type:{valType:"enumerated",values:["circle","line","fill","symbol"],dflt:"circle"},below:{valType:"string",dflt:""},color:{valType:"color",dflt:i},opacity:{valType:"number",min:0,max:1,dflt:1},circle:{radius:{valType:"number",dflt:15}},line:{width:{valType:"number",dflt:2}},fill:{outlinecolor:{valType:"color",dflt:i}},symbol:{icon:{valType:"string",dflt:"marker"},iconsize:{valType:"number",dflt:10},text:{valType:"string",dflt:""},textfont:u,textposition:n.extendFlat({},s,{arrayOk:!1})}})},"plot","from-root")).uirevision={valType:"any",editType:"none"}},{"../../components/color":569,"../../lib":692,"../../plot_api/edit_types":723,"../../plot_api/plot_template":730,"../../traces/scatter/attributes":1040,"../domain":766,"../font_attributes":767}],801:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../subplot_defaults"),a=t("../array_container_defaults"),o=t("./layout_attributes");function s(t,e,r,n){r("accesstoken",n.accessToken),r("style"),r("center.lon"),r("center.lat"),r("zoom"),r("bearing"),r("pitch"),a(t,e,{name:"layers",handleItemDefaults:l}),e._input=t}function l(t,e){function r(r,i){return n.coerce(t,e,o.layers,r,i)}if(r("visible")){var i=r("sourcetype");r("source"),"vector"===i&&r("sourcelayer");var a=r("type");r("below"),r("color"),r("opacity"),"circle"===a&&r("circle.radius"),"line"===a&&r("line.width"),"fill"===a&&r("fill.outlinecolor"),"symbol"===a&&(r("symbol.icon"),r("symbol.iconsize"),r("symbol.text"),n.coerceFont(r,"symbol.textfont"),r("symbol.textposition"))}}e.exports=function(t,e,r){i(t,e,r,{type:"mapbox",attributes:o,handleDefaults:s,partition:"y",accessToken:e._mapboxAccessToken})}},{"../../lib":692,"../array_container_defaults":736,"../subplot_defaults":818,"./layout_attributes":800}],802:[function(t,e,r){"use strict";var n=t("mapbox-gl"),i=t("../../components/fx"),a=t("../../lib"),o=t("../../registry"),s=t("../../components/dragelement"),l=t("../cartesian/select").prepSelect,c=t("../cartesian/select").selectOnClick,u=t("./constants"),f=t("./layout_attributes"),h=t("./layers");function p(t){this.id=t.id,this.gd=t.gd,this.container=t.container,this.isStatic=t.staticPlot;var e=t.fullLayout;this.uid=e._uid+"-"+this.id,this.opts=e[this.id],this.div=null,this.xaxis=null,this.yaxis=null,this.createFramework(e),this.map=null,this.accessToken=null,this.styleObj=null,this.traceHash={},this.layerList=[]}var d=p.prototype;function g(t){var e=f.style.values,r=f.style.dflt,n={};return a.isPlainObject(t)?(n.id=t.id,n.style=t):"string"==typeof t?(n.id=t,n.style=-1!==e.indexOf(t)?v(t):t):(n.id=r,n.style=v(r)),n.transition={duration:0,delay:0},n}function v(t){return u.styleUrlPrefix+t+"-"+u.styleUrlSuffix}function m(t){return[t.lon,t.lat]}e.exports=function(t){return new p(t)},d.plot=function(t,e,r){var n,i=this,a=i.opts=e[this.id];i.map&&a.accesstoken!==i.accessToken&&(i.map.remove(),i.map=null,i.styleObj=null,i.traceHash=[],i.layerList={}),n=i.map?new Promise(function(r,n){i.updateMap(t,e,r,n)}):new Promise(function(r,n){i.createMap(t,e,r,n)}),r.push(n)},d.createMap=function(t,e,r,a){var s=this,l=s.gd,f=s.opts,h=s.styleObj=g(f.style);s.accessToken=f.accesstoken;var p=s.map=new n.Map({container:s.div,style:h.style,center:m(f.center),zoom:f.zoom,bearing:f.bearing,pitch:f.pitch,interactive:!s.isStatic,preserveDrawingBuffer:s.isStatic,doubleClickZoom:!1,boxZoom:!1}),d=u.controlContainerClassName,v=s.div.getElementsByClassName(d)[0];if(s.div.removeChild(v),p._canvas.style.left="0px",p._canvas.style.top="0px",s.rejectOnError(a),p.once("load",function(){s.updateData(t),s.updateLayout(e),s.resolveOnRender(r)}),!s.isStatic){var y=!1;p.on("moveend",function(t){if(s.map){if(t.originalEvent||y){var e=s.getView();f._input.center=f.center=e.center,f._input.zoom=f.zoom=e.zoom,f._input.bearing=f.bearing=e.bearing,f._input.pitch=f.pitch=e.pitch,b(e)}y=!1}}),p.on("wheel",function(){y=!0}),p.on("mousemove",function(t){var e=s.div.getBoundingClientRect();t.clientX=t.point.x+e.left,t.clientY=t.point.y+e.top,t.target.getBoundingClientRect=function(){return e},s.xaxis.p2c=function(){return t.lngLat.lng},s.yaxis.p2c=function(){return t.lngLat.lat},i.hover(l,t,s.id)}),p.on("dragstart",x),p.on("zoomstart",x),p.on("dblclick",function(){l.emit("plotly_doubleclick",null);var t=s.viewInitial;p.setCenter(m(t.center)),p.setZoom(t.zoom),p.setBearing(t.bearing),p.setPitch(t.pitch);var e=s.getView();f._input.center=f.center=e.center,f._input.zoom=f.zoom=e.zoom,f._input.bearing=f.bearing=e.bearing,f._input.pitch=f.pitch=e.pitch,b(e)}),s.clearSelect=function(){l._fullLayout._zoomlayer.selectAll(".select-outline").remove()},s.onClickInPanFn=function(t){return function(e){var r=l._fullLayout.clickmode;r.indexOf("select")>-1&&c(e.originalEvent,l,[s.xaxis],[s.yaxis],s.id,t),r.indexOf("event")>-1&&i.click(l,e.originalEvent)}}}function x(){i.loneUnhover(e._toppaper)}function b(t){var e=s.id,r={};for(var n in t)r[e+"."+n]=t[n];o.call("_storeDirectGUIEdit",l.layout,l._fullLayout._preGUI,r),l.emit("plotly_relayout",r)}},d.updateMap=function(t,e,r,n){var i=this,a=i.map;i.rejectOnError(n);var o=g(i.opts.style);i.styleObj.id!==o.id?(i.styleObj=o,a.setStyle(o.style),a.once("styledata",function(){i.traceHash={},i.updateData(t),i.updateLayout(e),i.resolveOnRender(r)})):(i.updateData(t),i.updateLayout(e),i.resolveOnRender(r))},d.updateData=function(t){var e,r,n,i,a=this.traceHash;for(n=0;n=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){v.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}(t,o),s.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),i=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return i.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),i.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var x,b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,i={};function o(t){for(var r=!0,a=0;a1&&I.length>1){for(a.getComponentMethod("grid","sizeDefaults")(c,s),o=0;o15&&I.length>15&&0===s.shapes.length&&0===s.images.length,s._hasCartesian=s._has("cartesian"),s._hasGeo=s._has("geo"),s._hasGL3D=s._has("gl3d"),s._hasGL2D=s._has("gl2d"),s._hasTernary=s._has("ternary"),s._hasPie=s._has("pie"),v.linkSubplots(f,s,u,i),v.cleanPlot(f,s,u,i),d(s,i),s._preGUI||(s._preGUI={}),s._tracePreGUI||(s._tracePreGUI={});var B,N=s._tracePreGUI,j={};for(B in N)j[B]="old";for(o=0;o0){var f=1-2*s;n=Math.round(f*n),a=Math.round(f*a)}}var h=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-a)>1;(g||d)&&(d&&(r.width=n),g&&(r.height=a)),t._initialAutoSize||(t._initialAutoSize={width:n,height:a}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var i,o,s,c=a.componentsRegistry,u=e._basePlotModules,f=a.subplotsRegistry.cartesian;for(i in c)(s=c[i]).includeBasePlot&&s.includeBasePlot(t,e);for(var h in u.length||u.push(f),e._has("cartesian")&&(a.getComponentMethod("grid","contentDefaults")(t,e),f.finalizeSubplots(t,e)),e._subplots)e._subplots[h].sort(l.subplotSort);for(o=0;o.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0);var l=void 0!==r.xl?r.xl:r.x,c=void 0!==r.xr?r.xr:r.x,u=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;i[e]={l:{val:l,size:r.l+o},r:{val:c,size:r.r+o},b:{val:f,size:r.b+o},t:{val:u,size:r.t+o}},a[e]=1}else delete i[e],delete a[e];n._replotting||v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),T(e);var r=e._size,n=JSON.stringify(r),o=e.margin,s=o.l,l=o.r,c=o.t,u=o.b,f=e._pushmargin,h=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var p in f)h[p]||delete f[p];for(var d in f.base={l:{val:0,size:s},r:{val:1,size:l},t:{val:1,size:c},b:{val:0,size:u}},f){var g=f[d].l||{},v=f[d].b||{},m=g.val,y=g.size,x=v.val,b=v.size;for(var _ in f){if(i(y)&&f[_].r){var w=f[_].r.val,k=f[_].r.size;if(w>m){var M=(y*w+(k-e.width)*m)/(w-m),A=(k*(1-m)+(y-e.width)*(1-w))/(w-m);M>=0&&A>=0&&M+A>s+l&&(s=M,l=A)}}if(i(b)&&f[_].t){var S=f[_].t.val,C=f[_].t.size;if(S>x){var E=(b*S+(C-e.height)*x)/(S-x),L=(C*(1-x)+(b-e.height)*(1-S))/(S-x);E>=0&&L>=0&&E+L>u+c&&(u=E,c=L)}}}}}if(r.l=Math.round(s),r.r=Math.round(l),r.t=Math.round(c),r.b=Math.round(u),r.p=Math.round(o.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1,a.call("plot",t)},v.graphJson=function(t,e,r,n,i){(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var a=i?t._fullData:t.data,o=i?t._fullLayout:t.layout,s=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(l.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!l.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;i[e]=c(t[e])}return i}return Array.isArray(t)?t.map(c):l.isTypedArray(t)?l.simpleMap(t,l.identity):l.isJSDate(t)?l.ms2DateTimeLocal(+t):t}var u={data:(a||[]).map(function(t){var r=c(t);return e&&delete r.fit,r})};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),s&&(u.frames=c(s)),"object"===n?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var r,n,i,a=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){p=!0}),i.redraw&&t._transitionData._interruptCallbacks.push(function(){return a.call("redraw",t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var n,s,c=0,u=0;function f(){return c++,function(){var r;u++,p||u!==c||(r=e,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then(function(){if(i.redraw)return a.call("redraw",t)}).then(function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])}).then(r)))}}var d=t._fullLayout._basePlotModules,g=!1;if(r)for(s=0;s=0;s--)if(o[s].enabled){r._indexToPoints=o[s]._indexToPoints;break}n&&n.calc&&(a=n.calc(t,r))}Array.isArray(a)&&a[0]||(a=[{x:u,y:u}]),a[0].t||(a[0].t={}),a[0].trace=r,d[e]=a}}for(y&&S(c),i=0;i1e-10?t:0}function h(t,e,r){e=e||0,r=r||0;for(var n=t.length,i=new Array(n),a=0;a0?r:1/0}),i=n.mod(r+1,e.length);return[e[r],e[i]]},findIntersectionXY:c,findXYatLength:function(t,e,r,n){var i=-e*r,a=e*e+1,o=2*(e*i-r),s=i*i+r*r-t*t,l=Math.sqrt(o*o-4*a*s),c=(-o+l)/(2*a),u=(-o-l)/(2*a);return[[c,e*c+i+n],[u,e*u+i+n]]},clampTiny:f,pathPolygon:function(t,e,r,n,i,a){return"M"+h(u(t,e,r,n),i,a).join("L")},pathPolygonAnnulus:function(t,e,r,n,i,a,o){var s,l;t=0?h.angularAxis.domain:n.extent(k),C=Math.abs(k[1]-k[0]);A&&!M&&(C=0);var E=S.slice();T&&M&&(E[1]+=C);var L=h.angularAxis.ticksCount||4;L>8&&(L=L/(L/8)+L%8),h.angularAxis.ticksStep&&(L=(E[1]-E[0])/L);var z=h.angularAxis.ticksStep||(E[1]-E[0])/(L*(h.minorTicks+1));w&&(z=Math.max(Math.round(z),1)),E[2]||(E[2]=z);var O=n.range.apply(this,E);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=n.scale.linear().domain(E.slice(0,2)).range("clockwise"===h.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=T?C:0,"undefined"==typeof(t=n.select(this).select("svg.chart-root"))||t.empty()){var I=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),P=this.appendChild(this.ownerDocument.importNode(I.documentElement,!0));t=n.select(P)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var D,R=t.select(".chart-group"),F={fill:"none",stroke:h.tickColor},B={"font-size":h.font.size,"font-family":h.font.family,fill:h.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+h.font.outlineColor}).join(",")};if(h.showLegend){D=t.select(".legend-group").attr({transform:"translate("+[x,h.margin.top]+")"}).style({display:"block"});var N=p.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:D,elements:N,reverseOrder:h.legend.reverseOrder})})();var j=D.node().getBBox();x=Math.min(h.width-j.width-h.margin.left-h.margin.right,h.height-h.margin.top-h.margin.bottom)/2,x=Math.max(10,x),_=[h.margin.left+x,h.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),D.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else D=t.select(".legend-group").style({display:"none"});t.attr({width:h.width,height:h.height}).style({opacity:h.opacity}),R.attr("transform","translate("+_+")").style({cursor:"crosshair"});var V=[(h.width-(h.margin.left+h.margin.right+2*x+(j?j.width:0)))/2,(h.height-(h.margin.top+h.margin.bottom+2*x))/2];if(V[0]=Math.max(0,V[0]),V[1]=Math.max(0,V[1]),t.select(".outer-group").attr("transform","translate("+V+")"),h.title&&h.title.text){var U=t.select("g.title-group text").style(B).text(h.title.text),q=U.node().getBBox();U.attr({x:_[0]-q.width/2,y:_[1]-x-20})}var H=t.select(".radial.axis-group");if(h.radialAxis.gridLinesVisible){var G=H.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(F),G.attr("r",r),G.exit().remove()}H.select("circle.outside-circle").attr({r:x}).style(F);var W=t.select("circle.background-circle").attr({r:x}).style({fill:h.backgroundColor,stroke:h.stroke});function Y(t,e){return s(t)%360+h.orientation}if(h.radialAxis.visible){var X=n.svg.axis().scale(r).ticks(5).tickSize(5);H.call(X).attr({transform:"rotate("+h.radialAxis.orientation+")"}),H.selectAll(".domain").style(F),H.selectAll("g>text").text(function(t,e){return this.textContent+h.radialAxis.ticksSuffix}).style(B).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===h.radialAxis.tickOrientation?"rotate("+-h.radialAxis.orientation+") translate("+[0,B["font-size"]]+")":"translate("+[0,B["font-size"]]+")"}}),H.selectAll("g>line").style({stroke:"black"})}var Z=t.select(".angular.axis-group").selectAll("g.angular-tick").data(O),$=Z.enter().append("g").classed("angular-tick",!0);Z.attr({transform:function(t,e){return"rotate("+Y(t)+")"}}).style({display:h.angularAxis.visible?"block":"none"}),Z.exit().remove(),$.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(h.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(h.minorTicks+1)==0)}).style(F),$.selectAll(".minor").style({stroke:h.minorTickColor}),Z.select("line.grid-line").attr({x1:h.tickLength?x-h.tickLength:0,x2:x}).style({display:h.angularAxis.gridLinesVisible?"block":"none"}),$.append("text").classed("axis-text",!0).style(B);var J=Z.select("text.axis-text").attr({x:x+h.labelOffset,dy:a+"em",transform:function(t,e){var r=Y(t),n=x+h.labelOffset,i=h.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:h.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(h.minorTicks+1)!=0?"":w?w[t]+h.angularAxis.ticksSuffix:t+h.angularAxis.ticksSuffix}).style(B);h.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(h.minorTicks+1)!=0?"":h.angularAxis.rewriteTicks(this.textContent,e)});var K=n.max(R.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));D.attr({transform:"translate("+[x+K,h.margin.top]+")"});var Q=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||Q){var et=[];p.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=s,n.container=tt.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=h.orientation,n.direction=h.direction,n.index=e,et.push({data:t,geometryConfig:n})});var rt=n.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(et),nt=[];rt.forEach(function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map(function(t,e){return[t]})):nt.push(t.values)}),nt.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return i(o[r].defaultConfig(),t)});o[r]().config(n)()})}var it,at,ot=t.select(".guides-group"),st=t.select(".tooltips-group"),lt=o.tooltipPanel().config({container:st,fontSize:8})(),ct=o.tooltipPanel().config({container:st,fontSize:8})(),ut=o.tooltipPanel().config({container:st,hasTick:!0})();if(!M){var ft=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});R.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(W).angle;ft.attr({x2:-x,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-h.orientation)%360;it=s.invert(n);var i=o.util.convertToCartesian(x+12,r+180);lt.text(o.util.round(it)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){ot.select("line").style({opacity:0})})}var ht=ot.select("circle").style({stroke:"grey",fill:"none"});R.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(W).radius;ht.attr({r:n}).style({opacity:.5}),at=r.invert(o.util.getMousePos(W).radius);var i=o.util.convertToCartesian(n,h.radialAxis.orientation);ct.text(o.util.round(at)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){ht.style({opacity:0}),ut.hide(),lt.hide(),ct.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var i=n.select(this),a=this.style.fill,s="black",l=this.style.opacity||1;if(i.attr({"data-opacity":l}),a&&"none"!==a){i.attr({"data-fill":a}),s=n.hsl(a).darker().toString(),i.style({fill:s,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};M&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=t.node().getBoundingClientRect(),p=[f.left+f.width/2-V[0]-h.left,f.top+f.height/2-V[1]-h.top];ut.config({color:s}).text(u),ut.move(p)}else a=this.style.stroke||"black",i.attr({"data-stroke":a}),s=n.hsl(a).darker().toString(),i.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ut.show()}).on("mouseout.tooltip",function(t,e){ut.hide();var r=n.select(this),i=r.attr("data-fill");i?r.style({fill:i,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(c),this},h.config=function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),i(l.data[e],o.Axis.defaultConfig().data[0]),i(l.data[e],t)}),i(l.layout,o.Axis.defaultConfig().layout),i(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return r},h.angularScale=function(t){return s},h.svg=function(){return t},n.rebind(h,f,"on"),h},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var i=e||6,a=[],o=[];n.range(0,360+i,i).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],i=e[1],a={};return a.x=r,a.y=i,a.pos=e,a.angle=180*(Math.atan2(i,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+i*i),a},o.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;i0)){var l=n.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:u(s),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return d.fill(r,i,a)},"fill-opacity":0,stroke:function(t,e){return d.stroke(r,i,a)},"stroke-width":function(t,e){return d["stroke-width"](r,i,a)},"stroke-dasharray":function(t,e){return d["stroke-dasharray"](r,i,a)},opacity:function(t,e){return d.opacity(r,i,a)},display:function(t,e){return d.display(r,i,a)}})}};var f=e.angularScale.range(),h=Math.abs(f[1]-f[0])/o[0].length*Math.PI/180,p=n.svg.arc().startAngle(function(t){return-h/2}).endAngle(function(t){return h/2}).innerRadius(function(t){return e.radialScale(l+(t[2]||0))}).outerRadius(function(t){return e.radialScale(l+(t[2]||0))+e.radialScale(t[1])});c.arc=function(t,r,i){n.select(this).attr({class:"mark arc",d:p,transform:function(t,r){return"rotate("+(e.orientation+s(t[0])+90)+")"}})};var d={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,i){return r[t[i].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return"undefined"==typeof t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var v=g.selectAll("path.mark").data(function(t,e){return t});v.enter().append("path").attr({class:"mark"}),v.style(d).each(c[e.geometryType]),v.exit().remove(),g.exit().remove()})}return a.config=function(e){return arguments.length?(e.forEach(function(e,r){t[r]||(t[r]={}),i(t[r],o.PolyChart.defaultConfig()),i(t[r],e)}),this):t},a.getColorScale=function(){},n.rebind(a,e,"on"),a},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,a=t.data.map(function(t,r){return[].concat(t).map(function(t,n){var a=i({},e.elements[r]);return a.name=t,a.color=[].concat(e.elements[r].color)[n],a})}),o=n.merge(a);o=o.filter(function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||"undefined"==typeof e.elements[r].visibleInLegend)}),e.reverseOrder&&(o=o.reverse());var s=e.container;("string"==typeof s||s.nodeName)&&(s=n.select(s));var l=o.map(function(t,e){return t.color}),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,f=u?e.height:c*o.length,h=s.classed("legend-group",!0).selectAll("svg").data([0]),p=h.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var d=n.range(o.length),g=n.scale[u?"linear":"ordinal"]().domain(d).range(l),v=n.scale[u?"linear":"ordinal"]().domain(d)[u?"range":"rangePoints"]([0,f]);if(u){var m=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);m.enter().append("stop"),m.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var y=h.select(".legend-marks").selectAll("path.legend-mark").data(o);y.enter().append("path").classed("legend-mark",!0),y.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var r,i,a,o=t.symbol;return a=3*(i=c),"line"===(r=o)?"M"+[[-i/2,-i/12],[i/2,-i/12],[i/2,i/12],[-i/2,i/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(a)():n.svg.symbol().type("square").size(a)()},fill:function(t,e){return g(e)}}),y.exit().remove()}var x=n.svg.axis().scale(v).orient("right"),b=h.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text(function(t,e){return o[e].name}),r}return r.config=function(e){return arguments.length?(i(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,a={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,c=function(){var n=(t=a.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:a.padding+l,dy:.3*+a.fontSize}),c};return c.text=function(i){var o=n.hsl(a.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=i||"";e.style({fill:u,"font-size":a.fontSize+"px"}).text(f);var h=a.padding,p=e.node().getBBox(),d={fill:a.color,stroke:s,"stroke-width":"2px"},g=p.width+2*h+l,v=p.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[a.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(d),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return i(a,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=i({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var a=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=a.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var s=i({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var l=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(s.margin).forEach(function(t,e){u[c[l.indexOf(t.key)]]=t.value}),s.margin=u}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r}};return t}},{"../../../constants/alignment":664,"../../../lib":692,d3:148}],814:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../../lib"),a=t("../../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=i.extendDeepAll,c=e.exports={};c.framework=function(t){var e,r,i,a,u,f=new s;function h(r,s){return s&&(u=s),n.select(n.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?l(e,r):r,i||(i=o.Axis()),a=o.adapter.plotly().convert(e),i.config(a).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return h.isPolar=!0,h.svg=function(){return i.svg()},h.getConfig=function(){return e},h.getLiveConfig=function(){return o.adapter.plotly().convert(i.getLiveConfig(),!0)},h.getLiveScales=function(){return{t:i.angularScale(),r:i.radialScale()}},h.setUndoPoint=function(){var t,n,i=this,a=o.util.cloneJson(e);t=a,n=r,f.add({undo:function(){n&&i(n)},redo:function(){i(t)}}),r=o.util.cloneJson(a)},h.undo=function(){f.undo()},h.redo=function(){f.redo()},h},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),i=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:a.background,_container:e,_paperdiv:r,_paper:i};t._fullLayout=l(o,t.layout)}},{"../../../components/color":569,"../../../lib":692,"./micropolar":813,"./undo_manager":815,d3:148}],815:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function i(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(i(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(i(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r0?1:-1}function N(t){return B(Math.cos(t))}function j(t){return B(Math.sin(t))}e.exports=function(t,e){return new z(t,e)},O.plot=function(t,e){var r=e[this.id];this._hasClipOnAxisFalse=!1;for(var n=0;n=90||s>90&&l>=450?1:u<=0&&h<=0?0:Math.max(u,h);e=s<=180&&l>=180||s>180&&l>=540?-1:c>=0&&f>=0?0:Math.min(c,f);r=s<=270&&l>=270||s>270&&l>=630?-1:u>=0&&h>=0?0:Math.min(u,h);n=l>=360?1:c<=0&&f<=0?0:Math.max(c,f);return[e,r,n,i]}(h),x=y[2]-y[0],b=y[3]-y[1],_=f/u,w=Math.abs(b/x);_>w?(p=u,m=(f-(d=u*w))/n.h/2,g=[o[0],o[1]],v=[c[0]+m,c[1]-m]):(d=f,m=(u-(p=f/w))/n.w/2,g=[o[0]+m,o[1]-m],v=[c[0],c[1]]),this.xLength2=p,this.yLength2=d,this.xDomain2=g,this.yDomain2=v;var k=this.xOffset2=n.l+n.w*g[0],M=this.yOffset2=n.t+n.h*(1-v[1]),A=this.radius=p/x,T=this.innerRadius=e.hole*A,S=this.cx=k-A*y[0],L=this.cy=M+A*y[3],z=this.cxx=S-k,O=this.cyy=L-M;this.radialAxis=this.mockAxis(t,e,i,{_id:"x",side:{counterclockwise:"top",clockwise:"bottom"}[i.side],domain:[T/n.w,A/n.w]}),this.angularAxis=this.mockAxis(t,e,a,{side:"right",domain:[0,Math.PI],autorange:!1}),this.doAutoRange(t,e),this.updateAngularAxis(t,e),this.updateRadialAxis(t,e),this.updateRadialAxisTitle(t,e),this.xaxis=this.mockCartesianAxis(t,e,{_id:"x",domain:g}),this.yaxis=this.mockCartesianAxis(t,e,{_id:"y",domain:v});var I=this.pathSubplot();this.clipPaths.forTraces.select("path").attr("d",I).attr("transform",R(z,O)),r.frontplot.attr("transform",R(k,M)).call(l.setClipUrl,this._hasClipOnAxisFalse?null:this.clipIds.forTraces,this.gd),r.bg.attr("d",I).attr("transform",R(S,L)).call(s.fill,e.bgcolor)},O.mockAxis=function(t,e,r,n){var i=o.extendFlat({anchor:"free",position:0},r,n);return h(i,e,t),i},O.mockCartesianAxis=function(t,e,r){var n=this,i=r._id,a=o.extendFlat({type:"linear"},r);f(a,t);var s={x:[0,2],y:[1,3]};return a.setRange=function(){var t=n.sectorBBox,r=s[i],o=n.radialAxis._rl,l=(o[1]-o[0])/(1-e.hole);a.range=[t[r[0]]*l,t[r[1]]*l]},a.isPtWithinRange="x"===i?function(t){return n.isPtInside(t)}:function(){return!0},a.setRange(),a.setScale(),a},O.doAutoRange=function(t,e){var r=this.gd,n=this.radialAxis,i=e.radialaxis;n.setScale(),p(r,n);var a=n.range;i.range=a.slice(),i._input.range=a.slice(),n._rl=[n.r2l(a[0],null,"gregorian"),n.r2l(a[1],null,"gregorian")]},O.updateRadialAxis=function(t,e){var r=this,n=r.gd,i=r.layers,a=r.radius,l=r.innerRadius,c=r.cx,f=r.cy,h=e.radialaxis,p=C(e.sector[0],360),d=r.radialAxis,g=l90&&p<=270&&(d.tickangle=180);var v=function(t){return"translate("+(d.l2p(t.x)+l)+",0)"},m=I(h);if(r.radialTickLayout!==m&&(i["radial-axis"].selectAll(".xtick").remove(),r.radialTickLayout=m),g){d.setScale();var y=u.calcTicks(d),x=u.clipEnds(d,y),b=u.makeLabelFns(d,0),_=u.getTickSigns(d)[2];u.drawTicks(n,d,{vals:y,layer:i["radial-axis"],path:u.makeTickPath(d,0,_),transFn:v,crisp:!1}),u.drawGrid(n,d,{vals:x,layer:i["radial-grid"],path:function(t){return r.pathArc(d.r2p(t.x)+l)},transFn:o.noop,crisp:!1}),u.drawLabels(n,d,{vals:y,layer:i["radial-axis"],transFn:v,labelXFn:b.labelXFn,labelYFn:b.labelYFn,labelAnchorFn:b.labelAnchorFn})}var w=r.radialAxisAngle=r.vangles?L(P(E(h.angle),r.vangles)):h.angle,k=R(c,f),M=k+F(-w);D(i["radial-axis"],g&&(h.showticklabels||h.ticks),{transform:M}),D(i["radial-grid"],g&&h.showgrid,{transform:k}),D(i["radial-line"].select("line"),g&&h.showline,{x1:l,y1:0,x2:a,y2:0,transform:M}).attr("stroke-width",h.linewidth).call(s.stroke,h.linecolor)},O.updateRadialAxisTitle=function(t,e,r){var n=this.gd,i=this.radius,a=this.cx,o=this.cy,s=e.radialaxis,c=this.id+"title",u=void 0!==r?r:this.radialAxisAngle,f=E(u),h=Math.cos(f),p=Math.sin(f),d=0;if(s.title){var g=l.bBox(this.layers["radial-axis"].node()).height,v=s.title.font.size;d="counterclockwise"===s.side?-g-.4*v:g+.8*v}this.layers["radial-axis-title"]=m.draw(n,c,{propContainer:s,propName:this.id+".radialaxis.title",placeholder:S(n,"Click to enter radial axis title"),attributes:{x:a+i/2*h+d*p,y:o-i/2*p+d*h,"text-anchor":"middle"},transform:{rotate:-u}})},O.updateAngularAxis=function(t,e){var r=this,n=r.gd,i=r.layers,a=r.radius,l=r.innerRadius,c=r.cx,f=r.cy,h=e.angularaxis,p=r.angularAxis;r.fillViewInitialKey("angularaxis.rotation",h.rotation),p.setGeometry(),p.setScale();var d=function(t){return p.t2g(t.x)};"linear"===p.type&&"radians"===p.thetaunit&&(p.tick0=L(p.tick0),p.dtick=L(p.dtick));var g=function(t){return R(c+a*Math.cos(t),f-a*Math.sin(t))},v=u.makeLabelFns(p,0),m=v.labelStandoff,y=v.labelShift,x="outside"!==h.ticks?.7:.5,b=(p.linewidth||1)/2,_=I(h);r.angularTickLayout!==_&&(i["angular-axis"].selectAll("."+p._id+"tick").remove(),r.angularTickLayout=_);var w,k=u.calcTicks(p);if("linear"===e.gridshape?(w=k.map(d),o.angleDelta(w[0],w[1])<0&&(w=w.slice().reverse())):w=null,r.vangles=w,"category"===p.type&&(k=k.filter(function(t){return o.isAngleInsideSector(d(t),r.sectorInRad)})),p.visible){var A="inside"===p.ticks?-1:1;u.drawTicks(n,p,{vals:k,layer:i["angular-axis"],path:"M"+A*b+",0h"+A*p.ticklen,transFn:function(t){var e=d(t);return g(e)+F(-L(e))},crisp:!1}),u.drawGrid(n,p,{vals:k,layer:i["angular-grid"],path:function(t){var e=d(t),r=Math.cos(e),n=Math.sin(e);return"M"+[c+l*r,f-l*n]+"L"+[c+a*r,f-a*n]},transFn:o.noop,crisp:!1}),u.drawLabels(n,p,{vals:k,layer:i["angular-axis"],repositionOnUpdate:!0,transFn:function(t){return g(d(t))},labelXFn:function(t){var e=d(t);return(0===j(e)?0:Math.cos(e)*(m+b+x*t.fontSize))+N(e)*(t.dx+m+b)},labelYFn:function(t){var e=d(t);return t.dy+t.fontSize*M-y+-Math.sin(e)*(m+b+x*t.fontSize)},labelAnchorFn:function(t,e){var r=d(e);return 0===j(r)?N(r)>0?"start":"end":"middle"}})}D(i["angular-line"].select("path"),h.showline,{d:r.pathSubplot(),transform:R(c,f)}).attr("stroke-width",h.linewidth).call(s.stroke,h.linecolor)},O.updateFx=function(t,e){this.gd._context.staticPlot||(this.updateAngularDrag(t),this.updateRadialDrag(t,e,0),this.updateRadialDrag(t,e,1),this.updateMainDrag(t))},O.updateMainDrag=function(t){var e=this,r=e.gd,o=e.layers,s=t._zoomlayer,l=A.MINZOOM,c=A.OFFEDGE,u=e.radius,f=e.innerRadius,h=e.cx,p=e.cy,m=e.cxx,_=e.cyy,w=e.sectorInRad,k=e.vangles,M=e.radialAxis,S=T.clampTiny,C=T.findXYatLength,E=T.findEnclosingVertexAngles,L=A.cornerHalfWidth,z=A.cornerLen/2,O=d.makeDragger(o,"path","maindrag","crosshair");n.select(O).attr("d",e.pathSubplot()).attr("transform",R(h,p));var I,P,D,F,B,N,j,V,U,q={element:O,gd:r,subplot:e.id,plotinfo:{id:e.id,xaxis:e.xaxis,yaxis:e.yaxis},xaxes:[e.xaxis],yaxes:[e.yaxis]};function H(t,e){return Math.sqrt(t*t+e*e)}function G(t,e){return H(t-m,e-_)}function W(t,e){return Math.atan2(_-e,t-m)}function Y(t,e){return[t*Math.cos(e),t*Math.sin(-e)]}function X(t,r){if(0===t)return e.pathSector(2*L);var n=z/t,i=r-n,a=r+n,o=Math.max(0,Math.min(t,u)),s=o-L,l=o+L;return"M"+Y(s,i)+"A"+[s,s]+" 0,0,0 "+Y(s,a)+"L"+Y(l,a)+"A"+[l,l]+" 0,0,1 "+Y(l,i)+"Z"}function Z(t,r,n){if(0===t)return e.pathSector(2*L);var i,a,o=Y(t,r),s=Y(t,n),l=S((o[0]+s[0])/2),c=S((o[1]+s[1])/2);if(l&&c){var u=c/l,f=-1/u,h=C(L,u,l,c);i=C(z,f,h[0][0],h[0][1]),a=C(z,f,h[1][0],h[1][1])}else{var p,d;c?(p=z,d=L):(p=L,d=z),i=[[l-p,c-d],[l+p,c-d]],a=[[l-p,c+d],[l+p,c+d]]}return"M"+i.join("L")+"L"+a.reverse().join("L")+"Z"}function $(t,e){return e=Math.max(Math.min(e,u),f),tl?(t-1&&1===t&&x(n,r,[e.xaxis],[e.yaxis],e.id,q),i.indexOf("event")>-1&&v.click(r,n,e.id)}q.prepFn=function(t,n,a){var o=r._fullLayout.dragmode,l=O.getBoundingClientRect();if(I=n-l.left,P=a-l.top,k){var c=T.findPolygonOffset(u,w[0],w[1],k);I+=m+c[0],P+=_+c[1]}switch(o){case"zoom":q.moveFn=k?tt:K,q.clickFn=rt,q.doneFn=et,function(){D=null,F=null,B=e.pathSubplot(),N=!1;var t=r._fullLayout[e.id];j=i(t.bgcolor).getLuminance(),(V=d.makeZoombox(s,j,h,p,B)).attr("fill-rule","evenodd"),U=d.makeCorners(s,h,p),b(s)}();break;case"select":case"lasso":y(t,n,a,q,o)}},O.onmousemove=function(t){v.hover(r,t,e.id),r._fullLayout._lasthover=O,r._fullLayout._hoversubplot=e.id},O.onmouseout=function(t){r._dragging||g.unhover(r,t)},g.init(q)},O.updateRadialDrag=function(t,e,r){var i=this,s=i.gd,l=i.layers,c=i.radius,u=i.innerRadius,f=i.cx,h=i.cy,p=i.radialAxis,v=A.radialDragBoxSize,m=v/2;if(p.visible){var y,x,_,M=E(i.radialAxisAngle),T=p._rl,S=T[0],C=T[1],z=T[r],O=.75*(T[1]-T[0])/(1-e.hole)/c;r?(y=f+(c+m)*Math.cos(M),x=h-(c+m)*Math.sin(M),_="radialdrag"):(y=f+(u-m)*Math.cos(M),x=h-(u-m)*Math.sin(M),_="radialdrag-inner");var I,B,N,j=d.makeRectDragger(l,_,"crosshair",-m,-m,v,v),V={element:j,gd:s};D(n.select(j),p.visible&&u0==(r?N>S:Nn?function(t){return t<=0}:function(t){return t>=0};t.c2g=function(r){var n=t.c2l(r)-e;return(s(n)?n:0)+o},t.g2c=function(r){return t.l2c(r+e-o)},t.g2p=function(t){return t*a},t.c2p=function(e){return t.g2p(t.c2g(e))}}}(t,e);break;case"angularaxis":!function(t,e){var r=t.type;if("linear"===r){var i=t.d2c,s=t.c2d;t.d2c=function(t,e){return function(t,e){return"degrees"===e?a(t):t}(i(t),e)},t.c2d=function(t,e){return s(function(t,e){return"degrees"===e?o(t):t}(t,e))}}t.makeCalcdata=function(e,i){var a,o,s=e[i],l=e._length,c=function(r){return t.d2c(r,e.thetaunit)};if(s){if(n.isTypedArray(s)&&"linear"===r){if(l===s.length)return s;if(s.subarray)return s.subarray(0,l)}for(a=new Array(l),o=0;o=u&&(p.min=0,g.min=0,v.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}function d(t,e,r,n){var i=f[e._name];function o(r,n){return a.coerce(t,e,i,r,n)}o("uirevision",n.uirevision),e.type="linear";var h=o("color"),p=h!==i.color.dflt?h:r.font.color,d=e._name.charAt(0).toUpperCase(),g="Component "+d,v=o("title.text",g);e._hovertitle=v===g?v:d,a.coerceFont(o,"title.font",{family:r.font.family,size:Math.round(1.2*r.font.size),color:p}),o("min"),c(t,e,o,"linear"),s(t,e,o,"linear",{}),l(t,e,o,{outerTicks:!0}),o("showticklabels")&&(a.coerceFont(o,"tickfont",{family:r.font.family,size:r.font.size,color:p}),o("tickangle"),o("tickformat")),u(t,e,o,{dfltColor:h,bgColor:r.bgColor,blend:60,showLine:!0,showGrid:!0,noZeroLine:!0,attributes:i}),o("hoverformat"),o("layer")}e.exports=function(t,e,r){o(t,e,r,{type:"ternary",attributes:f,handleDefaults:p,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../components/color":569,"../../lib":692,"../../plot_api/plot_template":730,"../cartesian/line_grid_defaults":755,"../cartesian/tick_label_defaults":760,"../cartesian/tick_mark_defaults":761,"../cartesian/tick_value_defaults":762,"../subplot_defaults":818,"./layout_attributes":820}],822:[function(t,e,r){"use strict";var n=t("d3"),i=t("tinycolor2"),a=t("../../registry"),o=t("../../lib"),s=o._,l=t("../../components/color"),c=t("../../components/drawing"),u=t("../cartesian/set_convert"),f=t("../../lib/extend").extendFlat,h=t("../plots"),p=t("../cartesian/axes"),d=t("../../components/dragelement"),g=t("../../components/fx"),v=t("../../components/titles"),m=t("../cartesian/select").prepSelect,y=t("../cartesian/select").selectOnClick,x=t("../cartesian/select").clearSelect,b=t("../cartesian/constants");function _(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework(e),this.aTickLayout=null,this.bTickLayout=null,this.cTickLayout=null}e.exports=_;var w=_.prototype;w.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={},this.layers={}},w.plot=function(t,e){var r=e[this.id],n=e._size;this._hasClipOnAxisFalse=!1;for(var i=0;ik*x?i=(a=x)*k:a=(i=y)/k,o=v*i/y,s=m*a/x,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-g)-a/2,h.x0=r,h.y0=n,h.w=i,h.h=a,h.sum=b,h.xaxis={type:"linear",range:[_+2*M-b,b-_-2*w],domain:[d-o/2,d+o/2],_id:"x"},u(h.xaxis,h.graphDiv._fullLayout),h.xaxis.setScale(),h.xaxis.isPtWithinRange=function(t){return t.a>=h.aaxis.range[0]&&t.a<=h.aaxis.range[1]&&t.b>=h.baxis.range[1]&&t.b<=h.baxis.range[0]&&t.c>=h.caxis.range[1]&&t.c<=h.caxis.range[0]},h.yaxis={type:"linear",range:[_,b-w-M],domain:[g-s/2,g+s/2],_id:"y"},u(h.yaxis,h.graphDiv._fullLayout),h.yaxis.setScale(),h.yaxis.isPtWithinRange=function(){return!0};var A=h.yaxis.domain[0],T=h.aaxis=f({},t.aaxis,{range:[_,b-w-M],side:"left",tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*k],anchor:"free",position:0,_id:"y",_length:i});u(T,h.graphDiv._fullLayout),T.setScale();var S=h.baxis=f({},t.baxis,{range:[b-_-M,w],side:"bottom",domain:h.xaxis.domain,anchor:"free",position:0,_id:"x",_length:i});u(S,h.graphDiv._fullLayout),S.setScale();var C=h.caxis=f({},t.caxis,{range:[b-_-w,M],side:"right",tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*k],anchor:"free",position:0,_id:"y",_length:i});u(C,h.graphDiv._fullLayout),C.setScale();var E="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";h.clipDef.select("path").attr("d",E),h.layers.plotbg.select("path").attr("d",E);var L="M0,"+a+"h"+i+"l-"+i/2+",-"+a+"Z";h.clipDefRelative.select("path").attr("d",L);var z="translate("+r+","+n+")";h.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",z),h.clipDefRelative.select("path").attr("transform",null);var O="translate("+(r-S._offset)+","+(n+a)+")";h.layers.baxis.attr("transform",O),h.layers.bgrid.attr("transform",O);var I="translate("+(r+i/2)+","+n+")rotate(30)translate(0,"+-T._offset+")";h.layers.aaxis.attr("transform",I),h.layers.agrid.attr("transform",I);var P="translate("+(r+i/2)+","+n+")rotate(-30)translate(0,"+-C._offset+")";h.layers.caxis.attr("transform",P),h.layers.cgrid.attr("transform",P),h.drawAxes(!0),h.layers.aline.select("path").attr("d",T.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(l.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),h.layers.bline.select("path").attr("d",S.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(l.stroke,S.linecolor||"#000").style("stroke-width",(S.linewidth||0)+"px"),h.layers.cline.select("path").attr("d",C.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(l.stroke,C.linecolor||"#000").style("stroke-width",(C.linewidth||0)+"px"),h.graphDiv._context.staticPlot||h.initInteractions(),c.setClipUrl(h.layers.frontplot,h._hasClipOnAxisFalse?null:h.clipId,h.graphDiv)},w.drawAxes=function(t){var e=this.graphDiv,r=this.id.substr(7)+"title",n=this.layers,i=this.aaxis,a=this.baxis,o=this.caxis;if(this.drawAx(i),this.drawAx(a),this.drawAx(o),t){var l=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0)),c=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;n["a-title"]=v.draw(e,"a"+r,{propContainer:i,propName:this.id+".aaxis.title",placeholder:s(e,"Click to enter Component A title"),attributes:{x:this.x0+this.w/2,y:this.y0-i.title.font.size/3-l,"text-anchor":"middle"}}),n["b-title"]=v.draw(e,"b"+r,{propContainer:a,propName:this.id+".baxis.title",placeholder:s(e,"Click to enter Component B title"),attributes:{x:this.x0-c,y:this.y0+this.h+.83*a.title.font.size+c,"text-anchor":"middle"}}),n["c-title"]=v.draw(e,"c"+r,{propContainer:o,propName:this.id+".caxis.title",placeholder:s(e,"Click to enter Component C title"),attributes:{x:this.x0+this.w+c,y:this.y0+this.h+.83*o.title.font.size+c,"text-anchor":"middle"}})}},w.drawAx=function(t){var e,r=this.graphDiv,n=t._name,i=n.charAt(0),a=t._id,s=this.layers[n],l=i+"tickLayout",c=(e=t).ticks+String(e.ticklen)+String(e.showticklabels);this[l]!==c&&(s.selectAll("."+a+"tick").remove(),this[l]=c),t.setScale();var u=p.calcTicks(t),f=p.clipEnds(t,u),h=p.makeTransFn(t),d=p.getTickSigns(t)[2],g=o.deg2rad(30),v=d*(t.linewidth||1)/2,m=d*t.ticklen,y=this.w,x=this.h,b="b"===i?"M0,"+v+"l"+Math.sin(g)*m+","+Math.cos(g)*m:"M"+v+",0l"+Math.cos(g)*m+","+-Math.sin(g)*m,_={a:"M0,0l"+x+",-"+y/2,b:"M0,0l-"+y/2+",-"+x,c:"M0,0l-"+x+","+y/2}[i];p.drawTicks(r,t,{vals:"inside"===t.ticks?f:u,layer:s,path:b,transFn:h,crisp:!1}),p.drawGrid(r,t,{vals:f,layer:this.layers[i+"grid"],path:_,transFn:h,crisp:!1});var w=p.makeLabelFns(t,0,30);p.drawLabels(r,t,{vals:u,layer:s,transFn:h,labelXFn:w.labelXFn,labelYFn:w.labelYFn,labelAnchorFn:w.labelAnchorFn})};var M=b.MINZOOM/2+.87,A="m-0.87,.5h"+M+"v3h-"+(M+5.2)+"l"+(M/2+2.6)+",-"+(.87*M+4.5)+"l2.6,1.5l-"+M/2+","+.87*M+"Z",T="m0.87,.5h-"+M+"v3h"+(M+5.2)+"l-"+(M/2+2.6)+",-"+(.87*M+4.5)+"l-2.6,1.5l"+M/2+","+.87*M+"Z",S="m0,1l"+M/2+","+.87*M+"l2.6,-1.5l-"+(M/2+2.6)+",-"+(.87*M+4.5)+"l-"+(M/2+2.6)+","+(.87*M+4.5)+"l2.6,1.5l"+M/2+",-"+.87*M+"Z",C="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;function L(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}w.initInteractions=function(){var t,e,r,n,u,f,h,p,v,_,w=this,M=w.layers.plotbg.select("path").node(),z=w.graphDiv,O=z._fullLayout._zoomlayer,I={element:M,gd:z,plotinfo:{id:w.id,xaxis:w.xaxis,yaxis:w.yaxis},subplot:w.id,prepFn:function(a,o,s){I.xaxes=[w.xaxis],I.yaxes=[w.yaxis];var c=z._fullLayout.dragmode;I.minDrag="lasso"===c?1:void 0,"zoom"===c?(I.moveFn=N,I.clickFn=D,I.doneFn=j,function(a,o,s){var c=M.getBoundingClientRect();t=o-c.left,e=s-c.top,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,n=w.aaxis.range[1]-r.a,f=i(w.graphDiv._fullLayout[w.id].bgcolor).getLuminance(),h="M0,"+w.h+"L"+w.w/2+", 0L"+w.w+","+w.h+"Z",p=!1,v=O.append("path").attr("class","zoombox").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:f>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",h),_=O.append("path").attr("class","zoombox-corners").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:l.background,stroke:l.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),x(O)}(0,o,s)):"pan"===c?(I.moveFn=V,I.clickFn=D,I.doneFn=U,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,x(O)):"select"!==c&&"lasso"!==c||m(a,o,s,I,c)}};function P(t){var e={};return e[w.id+".aaxis.min"]=t.a,e[w.id+".baxis.min"]=t.b,e[w.id+".caxis.min"]=t.c,e}function D(t,e){var r=z._fullLayout.clickmode;L(z),2===t&&(z.emit("plotly_doubleclick",null),a.call("_guiRelayout",z,P({a:0,b:0,c:0}))),r.indexOf("select")>-1&&1===t&&y(e,z,[w.xaxis],[w.yaxis],w.id,I),r.indexOf("event")>-1&&g.click(z,e,w.id)}function R(t,e){return 1-e/w.h}function F(t,e){return 1-(t+(w.h-e)/Math.sqrt(3))/w.w}function B(t,e){return(t-(w.h-e)/Math.sqrt(3))/w.w}function N(i,a){var o=t+i,s=e+a,l=Math.max(0,Math.min(1,R(0,e),R(0,s))),c=Math.max(0,Math.min(1,F(t,e),F(o,s))),d=Math.max(0,Math.min(1,B(t,e),B(o,s))),g=(l/2+d)*w.w,m=(1-l/2-c)*w.w,y=(g+m)/2,x=m-g,M=(1-l)*w.h,E=M-x/k;x.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),_.transition().style("opacity",1).duration(200),p=!0)}function j(){L(z),u!==r&&(a.call("_guiRelayout",z,P(u)),E&&z.data&&z._context.showTips&&(o.notifier(s(z,"Double-click to zoom back out"),"long"),E=!1))}function V(t,e){var n=t/w.xaxis._m,i=e/w.yaxis._m,a=[(u={a:r.a-i,b:r.b+(n+i)/2,c:r.c-(n-i)/2}).a,u.b,u.c].sort(),o=a.indexOf(u.a),s=a.indexOf(u.b),l=a.indexOf(u.c);a[0]<0&&(a[1]+a[0]/2<0?(a[2]+=a[0]+a[1],a[0]=a[1]=0):(a[2]+=a[0]/2,a[1]+=a[0]/2,a[0]=0),u={a:a[o],b:a[s],c:a[l]},e=(r.a-u.a)*w.yaxis._m,t=(r.c-u.c-r.b+u.b)*w.xaxis._m);var f="translate("+(w.x0+t)+","+(w.y0+e)+")";w.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",f);var h="translate("+-t+","+-e+")";w.clipDefRelative.select("path").attr("transform",h),w.aaxis.range=[u.a,w.sum-u.b-u.c],w.baxis.range=[w.sum-u.a-u.c,u.b],w.caxis.range=[w.sum-u.a-u.b,u.c],w.drawAxes(!1),w._hasClipOnAxisFalse&&w.plotContainer.select(".scatterlayer").selectAll(".trace").call(c.hideOutsideRangePoints,w)}function U(){a.call("_guiRelayout",z,P(u))}M.onmousemove=function(t){g.hover(z,t,w.id),z._fullLayout._lasthover=M,z._fullLayout._hoversubplot=w.id},M.onmouseout=function(t){z._dragging||d.unhover(z,t)},d.init(I)}},{"../../components/color":569,"../../components/dragelement":587,"../../components/drawing":590,"../../components/fx":608,"../../components/titles":657,"../../lib":692,"../../lib/extend":682,"../../registry":823,"../cartesian/axes":740,"../cartesian/constants":746,"../cartesian/select":758,"../cartesian/set_convert":759,"../plots":804,d3:148,tinycolor2:513}],823:[function(t,e,r){"use strict";var n=t("./lib/loggers"),i=t("./lib/noop"),a=t("./lib/push_unique"),o=t("./lib/is_plain_object"),s=t("./lib/extend"),l=t("./plots/attributes"),c=t("./plots/layout_attributes"),u=s.extendFlat,f=s.extendDeepAll;function h(t){var e=t.name,i=t.categories,a=t.meta;if(r.modules[e])n.log("Type "+e+" already registered");else{r.subplotsRegistry[t.basePlotModule.name]||function(t){var e=t.name;if(r.subplotsRegistry[e])return void n.log("Plot type "+e+" already registered.");for(var i in v(t),r.subplotsRegistry[e]=t,r.componentsRegistry)x(i,t.name)}(t.basePlotModule);for(var o={},s=0;s-1&&(u[h[r]].title={text:""});for(r=0;rpath, .legendlines>path, .cbfill").each(function(){var t=n.select(this),e=this.style.fill;e&&-1!==e.indexOf("url(")&&t.style("fill",e.replace(l,"TOBESTRIPPED"));var r=this.style.stroke;r&&-1!==r.indexOf("url(")&&t.style("stroke",r.replace(l,"TOBESTRIPPED"))}),"pdf"!==e&&"eps"!==e||h.selectAll("#MathJax_SVG_glyphs path").attr("stroke-width",0),h.node().setAttributeNS(s.xmlns,"xmlns",s.svg),h.node().setAttributeNS(s.xmlns,"xmlns:xlink",s.xlink),"svg"===e&&r&&(h.attr("width",r*d),h.attr("height",r*g),h.attr("viewBox","0 0 "+d+" "+g));var _=(new window.XMLSerializer).serializeToString(h.node());return _=function(t){var e=n.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":-1!==t.indexOf("<")||-1!==t.indexOf(">")?"":e.html(t).text()});return e.remove(),r}(_),_=(_=_.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),i.isIE()&&(_=(_=(_=_.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),_}},{"../components/color":569,"../components/drawing":590,"../constants/xmlns_namespaces":670,"../lib":692,d3:148}],832:[function(t,e,r){"use strict";var n=t("../../lib").mergeArray;e.exports=function(t,e){for(var r=0;rf+c||!n(u))&&(p=!0,g(h,t))}for(var v=0;va))return e}return void 0!==r?r:t.dflt},r.coerceColor=function(t,e,r){return i(e).isValid()?e:void 0!==r?r:t.dflt},r.coerceEnumerated=function(t,e,r){return t.coerceNumber&&(e=+e),-1!==t.values.indexOf(e)?e:void 0!==r?r:t.dflt},r.getValue=function(t,e){var r;return Array.isArray(t)?e.01?E:function(t,e){return Math.abs(t-e)>=2?E(t):t>e?Math.ceil(t):Math.floor(t)};_=C(_,w),w=C(w,_),k=C(k,M),M=C(M,k)}a.ensureSingle(A,"path").style("vector-effect","non-scaling-stroke").attr("d","M"+_+","+k+"V"+M+"H"+w+"V"+k+"Z").call(l.setClipUrl,e.layerClipId,t),function(t,e,r,n,i,s,c,u){var m;function y(e,r,n){var i=a.ensureSingle(e,"text").text(r).attr({class:"bartext bartext-"+m,transform:"","text-anchor":"middle","data-notex":1}).call(l.font,n).call(o.convertToTspans,t);return i}var x=r[0].trace,b=x.orientation,_=function(t,e){var r=p.getValue(t.text,e);return p.coerceString(f,r)}(x,n);if(m=function(t,e){var r=p.getValue(t.textposition,e);return p.coerceEnumerated(h,r)}(x,n),!_||"none"===m)return void e.select("text").remove();var w,k,M,A,T,S,C=t._fullLayout.font,E=d.getBarColor(r[n],x),L=d.getInsideTextFont(x,n,C,E),z=d.getOutsideTextFont(x,n,C),O=t._fullLayout.barmode,I="relative"===O,P="stack"===O||I,D=r[n],R=!P||D._outmost,F=Math.abs(s-i)-2*g,B=Math.abs(u-c)-2*g;"outside"===m&&(R||D.hasB||(m="inside"));if("auto"===m)if(R){m="inside",w=y(e,_,L),k=l.bBox(w.node()),M=k.width,A=k.height;var N=M>0&&A>0,j=M<=F&&A<=B,V=M<=B&&A<=F,U="h"===b?F>=M*(B/A):B>=A*(F/M);N&&(j||V||U)?m="inside":(m="outside",w.remove(),w=null)}else m="inside";if(!w&&(w=y(e,_,"outside"===m?z:L),k=l.bBox(w.node()),M=k.width,A=k.height,M<=0||A<=0))return void w.remove();"outside"===m?(S="both"===x.constraintext||"outside"===x.constraintext,T=function(t,e,r,n,i,a,o){var s,l="h"===a?Math.abs(n-r):Math.abs(e-t);l>2*g&&(s=g);var c=1;o&&(c="h"===a?Math.min(1,l/i.height):Math.min(1,l/i.width));var u,f,h,p,d=(i.left+i.right)/2,m=(i.top+i.bottom)/2;u=c*i.width,f=c*i.height,"h"===a?er?(h=(t+e)/2,p=n+s+f/2):(h=(t+e)/2,p=n-s-f/2);return v(d,m,h,p,c,!1)}(i,s,c,u,k,b,S)):(S="both"===x.constraintext||"inside"===x.constraintext,T=function(t,e,r,n,i,a,o){var s,l,c,u,f,h,p,d=i.width,m=i.height,y=(i.left+i.right)/2,x=(i.top+i.bottom)/2,b=Math.abs(e-t),_=Math.abs(n-r);b>2*g&&_>2*g?(b-=2*(f=g),_-=2*f):f=0;d<=b&&m<=_?(h=!1,p=1):d<=_&&m<=b?(h=!0,p=1):dr?(c=(t+e)/2,u=n-f-l/2):(c=(t+e)/2,u=n+f+l/2);return v(y,x,c,u,p,h)}(i,s,c,u,k,b,S));w.attr("transform",T)}(t,A,r,u,_,w,k,M),e.layerClipId&&l.hideOutsideRangePoint(c,A.select("text"),m,y,b.xcalendar,b.ycalendar)}else A.remove();function E(t){return 0===x.bargap&&0===x.bargroupgap?n.round(Math.round(t)-S,2):t}});var w=!1===u.trace.cliponaxis;l.setClipUrl(c,w?null:e.layerClipId,t)});c.getComponentMethod("errorbars","plot")(t,b,e)}},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../lib/svg_text_utils":716,"../../registry":823,"./attributes":833,"./helpers":838,"./style":846,d3:148,"fast-isnumeric":214}],844:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,i=t.xaxis,a=t.yaxis,o=[];if(!1===e)for(r=0;r1||0===a.bargap&&0===a.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),r.selectAll("g.points").each(function(e){p(n.select(this),e[0].trace,t)}),s.getComponentMethod("errorbars","style")(r)},styleOnSelect:function(t,e){var r=e[0].node3,i=e[0].trace;i.selectedpoints?function(t,e,r){a.selectedPointStyle(t.selectAll("path"),e),function(t,e,r){t.each(function(t){var i,s=n.select(this);if(t.selected){i=o.extendFlat({},d(s,t,e,r));var l=e.selected.textfont&&e.selected.textfont.color;l&&(i.color=l),a.font(s,i)}else a.selectedTextStyle(s,e)})}(t.selectAll("text"),e,r)}(r,i,t):p(r,i,t)},getInsideTextFont:v,getOutsideTextFont:m,getBarColor:x}},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../registry":823,"./attributes":833,"./helpers":838,d3:148}],847:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":569,"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580}],848:[function(t,e,r){"use strict";var n=t("../../lib/extend").extendFlat,i=t("../scatterpolar/attributes"),a=t("../bar/attributes");e.exports={r:i.r,theta:i.theta,r0:i.r0,dr:i.dr,theta0:i.theta0,dtheta:i.dtheta,thetaunit:i.thetaunit,base:n({},a.base,{}),offset:n({},a.offset,{}),width:n({},a.width,{}),text:n({},a.text,{}),marker:a.marker,hoverinfo:i.hoverinfo,selected:a.selected,unselected:a.unselected}},{"../../lib/extend":682,"../bar/attributes":833,"../scatterpolar/attributes":1102}],849:[function(t,e,r){"use strict";var n=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/calc"),a=t("../bar/arrays_to_calcdata"),o=t("../bar/cross_trace_calc").setGroupPositions,s=t("../scatter/calc_selection"),l=t("../../registry").traceIs,c=t("../../lib").extendFlat;e.exports={calc:function(t,e){for(var r=t._fullLayout,o=e.subplot,l=r[o].radialaxis,c=r[o].angularaxis,u=l.makeCalcdata(e,"r"),f=c.makeCalcdata(e,"theta"),h=e._length,p=new Array(h),d=u,g=f,v=0;vh.range[1]&&(x+=Math.PI);if(n.getClosest(c,function(t){return g(y,x,[t.rp0,t.rp1],[t.thetag0,t.thetag1],d)?v+Math.min(1,Math.abs(t.thetag1-t.thetag0)/m)-1+(t.rp1-y)/(t.rp1-t.rp0)-1:1/0},t),!1!==t.index){var b=c[t.index];t.x0=t.x1=b.ct[0],t.y0=t.y1=b.ct[1];var _=i.extendFlat({},b,{r:b.s,theta:b.p});return o(b,u,t),s(_,u,f,t),t.color=a(u,b),t.xLabelVal=t.yLabelVal=void 0,b.s<0&&(t.idealAlign="left"),[t]}}},{"../../components/fx":608,"../../lib":692,"../../plots/polar/helpers":806,"../bar/hover":839,"../scatter/fill_hover_text":1048,"../scatterpolar/hover":1105}],852:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"barpolar",basePlotModule:t("../../plots/polar"),categories:["polar","bar","showLegend"],attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc").calc,crossTraceCalc:t("./calc").crossTraceCalc,plot:t("./plot"),colorbar:t("../scatter/marker_colorbar"),style:t("../bar/style").style,hoverPoints:t("./hover"),selectPoints:t("../bar/select"),meta:{}}},{"../../plots/polar":807,"../bar/select":844,"../bar/style":846,"../scatter/marker_colorbar":1058,"./attributes":848,"./calc":849,"./defaults":850,"./hover":851,"./layout_attributes":853,"./layout_defaults":854,"./plot":855}],853:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","overlay"],dflt:"stack",editType:"calc"},bargap:{valType:"number",dflt:.1,min:0,max:1,editType:"calc"}}},{}],854:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,r){var a,o={};function s(r,o){return n.coerce(t[a]||{},e[a],i,r,o)}for(var l=0;l0?(c=o,u=l):(c=l,u=o);var f=s.findEnclosingVertexAngles(c,t.vangles)[0],h=s.findEnclosingVertexAngles(u,t.vangles)[1],p=[f,(c+u)/2,h];return s.pathPolygonAnnulus(n,i,c,u,p,e,r)};return function(t,n,i,o){return a.pathAnnulus(t,n,i,o,e,r)}}(e),p=e.layers.frontplot.select("g.barlayer");a.makeTraceGroups(p,r,"trace bars").each(function(r){var s=r[0].node3=n.select(this),p=a.ensureSingle(s,"g","points").selectAll("g.point").data(a.identity);p.enter().append("g").style("vector-effect","non-scaling-stroke").style("stroke-miterlimit",2).classed("point",!0),p.exit().remove(),p.each(function(t){var e,r=n.select(this),o=t.rp0=u.c2p(t.s0),s=t.rp1=u.c2p(t.s1),p=t.thetag0=f.c2g(t.p0),d=t.thetag1=f.c2g(t.p1);if(i(o)&&i(s)&&i(p)&&i(d)&&o!==s&&p!==d){var g=u.c2g(t.s1),v=(p+d)/2;t.ct=[l.c2p(g*Math.cos(v)),c.c2p(g*Math.sin(v))],e=h(o,s,p,d)}else e="M0,0Z";a.ensureSingle(r,"path").attr("d",e)}),o.setClipUrl(s,e._hasClipOnAxisFalse?e.clipIds.forTraces:null,t)})}},{"../../components/drawing":590,"../../lib":692,"../../plots/polar/helpers":806,d3:148,"fast-isnumeric":214}],856:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array",editType:"calc+clearAxisTypes"},x:{valType:"data_array",editType:"calc+clearAxisTypes"},x0:{valType:"any",editType:"calc+clearAxisTypes"},y0:{valType:"any",editType:"calc+clearAxisTypes"},name:{valType:"string",editType:"calc+clearAxisTypes"},text:a({},n.text,{}),whiskerwidth:{valType:"number",min:0,max:1,dflt:.5,editType:"calc"},notched:{valType:"boolean",editType:"calc"},notchwidth:{valType:"number",min:0,max:.5,dflt:.25,editType:"calc"},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers",editType:"calc"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1,editType:"calc"},jitter:{valType:"number",min:0,max:1,editType:"calc"},pointpos:{valType:"number",min:-2,max:2,editType:"calc"},orientation:{valType:"enumerated",values:["v","h"],editType:"calc+clearAxisTypes"},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)",editType:"style"},symbol:a({},o.symbol,{arrayOk:!1,editType:"plot"}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1,editType:"style"}),size:a({},o.size,{arrayOk:!1,editType:"calc"}),color:a({},o.color,{arrayOk:!1,editType:"style"}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine,editType:"style"}),width:a({},s.width,{arrayOk:!1,dflt:0,editType:"style"}),outliercolor:{valType:"color",editType:"style"},outlierwidth:{valType:"number",min:0,dflt:1,editType:"style"},editType:"style"},editType:"plot"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,selected:{marker:n.selected.marker,editType:"style"},unselected:{marker:n.unselected.marker,editType:"style"},hoveron:{valType:"flaglist",flags:["boxes","points"],dflt:"boxes+points",editType:"style"}}},{"../../components/color/attributes":568,"../../lib/extend":682,"../scatter/attributes":1040}],857:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=i._,o=t("../../plots/cartesian/axes");function s(t,e,r){var n={text:"tx"};for(var i in n)Array.isArray(e[i])&&(t[n[i]]=e[i][r])}function l(t,e){return t.v-e.v}function c(t){return t.v}e.exports=function(t,e){var r,u,f,h,p,d=t._fullLayout,g=o.getFromId(t,e.xaxis||"x"),v=o.getFromId(t,e.yaxis||"y"),m=[],y="violin"===e.type?"_numViolins":"_numBoxes";"h"===e.orientation?(u=g,f="x",h=v,p="y"):(u=v,f="y",h=g,p="x");var x=u.makeCalcdata(e,f),b=function(t,e,r,a,o){if(e in t)return r.makeCalcdata(t,e);var s;s=e+"0"in t?t[e+"0"]:"name"in t&&("category"===r.type||n(t.name)&&-1!==["linear","log"].indexOf(r.type)||i.isDateTime(t.name)&&"date"===r.type)?t.name:o;var l="multicategory"===r.type?r.r2c_just_indices(s):r.d2c(s,0,t[e+"calendar"]);return a.map(function(){return l})}(e,p,h,x,d[y]),_=i.distinctVals(b),w=_.vals,k=_.minDiff/2,M=function(t,e){for(var r=t.length,n=new Array(r+1),i=0;i=0&&C0){var L=T[r].sort(l),z=L.map(c),O=z.length,I={pos:w[r],pts:L};I.min=z[0],I.max=z[O-1],I.mean=i.mean(z,O),I.sd=i.stdev(z,O,I.mean),I.q1=i.interp(z,.25),I.med=i.interp(z,.5),I.q3=i.interp(z,.75),I.lf=Math.min(I.q1,z[Math.min(i.findBin(2.5*I.q1-1.5*I.q3,z,!0)+1,O-1)]),I.uf=Math.max(I.q3,z[Math.max(i.findBin(2.5*I.q3-1.5*I.q1,z),0)]),I.lo=4*I.q1-3*I.q3,I.uo=4*I.q3-3*I.q1;var P=1.57*(I.q3-I.q1)/Math.sqrt(O);I.ln=I.med-P,I.un=I.med+P,m.push(I)}!function(t,e){if(i.isArrayOrTypedArray(e.selectedpoints))for(var r=0;r0?(m[0].t={num:d[y],dPos:k,posLetter:p,valLetter:f,labels:{med:a(t,"median:"),min:a(t,"min:"),q1:a(t,"q1:"),q3:a(t,"q3:"),max:a(t,"max:"),mean:"sd"===e.boxmean?a(t,"mean \xb1 \u03c3:"):a(t,"mean:"),lf:a(t,"lower fence:"),uf:a(t,"upper fence:")}},d[y]++,m):[{t:{empty:!0}}]}},{"../../lib":692,"../../plots/cartesian/axes":740,"fast-isnumeric":214}],858:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib"),a=["v","h"];function o(t,e,r,a,o){var s,l,c,u=e.calcdata,f=e._fullLayout,h=[],p="violin"===t?"_numViolins":"_numBoxes";for(s=0;st.uf}),l=Math.max((t.max-t.min)/10,t.q3-t.q1),c=1e-9*l,p=l*s,d=[],g=0;if(r.jitter){if(0===l)for(g=1,d=new Array(a.length),e=0;et.lo&&(_.so=!0)}return a});d.enter().append("path").classed("point",!0),d.exit().remove(),d.call(a.translatePoints,l,c)}function u(t,e,r,a){var o,s,l=e.pos,c=e.val,u=a.bPos,f=a.bPosPxOffset||0,h=r.boxmean||(r.meanline||{}).visible;Array.isArray(a.bdPos)?(o=a.bdPos[0],s=a.bdPos[1]):(o=a.bdPos,s=a.bdPos);var p=t.selectAll("path.mean").data("box"===r.type&&r.boxmean||"violin"===r.type&&r.box.visible&&r.meanline.visible?i.identity:[]);p.enter().append("path").attr("class","mean").style({fill:"none","vector-effect":"non-scaling-stroke"}),p.exit().remove(),p.each(function(t){var e=l.c2p(t.pos+u,!0)+f,i=l.c2p(t.pos+u-o,!0)+f,a=l.c2p(t.pos+u+s,!0)+f,p=c.c2p(t.mean,!0),d=c.c2p(t.mean-t.sd,!0),g=c.c2p(t.mean+t.sd,!0);"h"===r.orientation?n.select(this).attr("d","M"+p+","+i+"V"+a+("sd"===h?"m0,0L"+d+","+e+"L"+p+","+i+"L"+g+","+e+"Z":"")):n.select(this).attr("d","M"+i+","+p+"H"+a+("sd"===h?"m0,0L"+e+","+d+"L"+i+","+p+"L"+e+","+g+"Z":""))})}e.exports={plot:function(t,e,r,a){var o=t._fullLayout,s=e.xaxis,f=e.yaxis,h=o._numBoxes,p=1-o.boxgap,d="group"===o.boxmode&&h>1;i.makeTraceGroups(a,r,"trace boxes").each(function(t){var r=n.select(this),i=t[0],a=i.t,g=i.trace;e.isRangePlot||(i.node3=r);var v,m,y=a.dPos*p*(1-o.boxgroupgap)/(d?h:1),x=d?2*a.dPos*((a.num+.5)/h-.5)*p:0,b=y*g.whiskerwidth;!0!==g.visible||a.empty?r.remove():("h"===g.orientation?(v=f,m=s):(v=s,m=f),a.bPos=x,a.bdPos=y,a.wdPos=b,a.wHover=a.dPos*(d?p/h:1),l(r,{pos:v,val:m},g,a),c(r,{x:s,y:f},g,a),u(r,{pos:v,val:m},g,a))})},plotBoxAndWhiskers:l,plotPoints:c,plotBoxMean:u}},{"../../components/drawing":590,"../../lib":692,d3:148}],866:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n,i=t.cd,a=t.xaxis,o=t.yaxis,s=[];if(!1===e)for(r=0;r=10)return null;var i=1/0;var a=-1/0;var o=e.length;for(var s=0;s0?Math.floor:Math.ceil,O=E>0?Math.ceil:Math.floor,I=E>0?Math.min:Math.max,P=E>0?Math.max:Math.min,D=z(S+L),R=O(C-L),F=[[f=T(S)]];for(a=D;a*E=0;i--)a[u-i]=t[f][i],o[u-i]=e[f][i];for(s.push({x:a,y:o,bicubic:l}),i=f,a=[],o=[];i>=0;i--)a[f-i]=t[i][0],o[f-i]=e[i][0];return s.push({x:a,y:o,bicubic:c}),s}},{}],880:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib/extend").extendFlat;e.exports=function(t,e,r){var a,o,s,l,c,u,f,h,p,d,g,v,m,y,x=t["_"+e],b=t[e+"axis"],_=b._gridlines=[],w=b._minorgridlines=[],k=b._boundarylines=[],M=t["_"+r],A=t[r+"axis"];"array"===b.tickmode&&(b.tickvals=x.slice());var T=t._xctrl,S=t._yctrl,C=T[0].length,E=T.length,L=t._a.length,z=t._b.length;n.prepTicks(b),"array"===b.tickmode&&delete b.tickvals;var O=b.smoothing?3:1;function I(n){var i,a,o,s,l,c,u,f,p,d,g,v,m=[],y=[],x={};if("b"===e)for(a=t.b2j(n),o=Math.floor(Math.max(0,Math.min(z-2,a))),s=a-o,x.length=z,x.crossLength=L,x.xy=function(e){return t.evalxy([],e,a)},x.dxy=function(e,r){return t.dxydi([],e,o,r,s)},i=0;i0&&(p=t.dxydi([],i-1,o,0,s),m.push(l[0]+p[0]/3),y.push(l[1]+p[1]/3),d=t.dxydi([],i-1,o,1,s),m.push(f[0]-d[0]/3),y.push(f[1]-d[1]/3)),m.push(f[0]),y.push(f[1]),l=f;else for(i=t.a2i(n),c=Math.floor(Math.max(0,Math.min(L-2,i))),u=i-c,x.length=L,x.crossLength=z,x.xy=function(e){return t.evalxy([],i,e)},x.dxy=function(e,r){return t.dxydj([],c,e,u,r)},a=0;a0&&(g=t.dxydj([],c,a-1,u,0),m.push(l[0]+g[0]/3),y.push(l[1]+g[1]/3),v=t.dxydj([],c,a-1,u,1),m.push(f[0]-v[0]/3),y.push(f[1]-v[1]/3)),m.push(f[0]),y.push(f[1]),l=f;return x.axisLetter=e,x.axis=b,x.crossAxis=A,x.value=n,x.constvar=r,x.index=h,x.x=m,x.y=y,x.smoothing=A.smoothing,x}function P(n){var i,a,o,s,l,c=[],u=[],f={};if(f.length=x.length,f.crossLength=M.length,"b"===e)for(o=Math.max(0,Math.min(z-2,n)),l=Math.min(1,Math.max(0,n-o)),f.xy=function(e){return t.evalxy([],e,n)},f.dxy=function(e,r){return t.dxydi([],e,o,r,l)},i=0;ix.length-1||_.push(i(P(o),{color:b.gridcolor,width:b.gridwidth}));for(h=u;hx.length-1||g<0||g>x.length-1))for(v=x[s],m=x[g],a=0;ax[x.length-1]||w.push(i(I(d),{color:b.minorgridcolor,width:b.minorgridwidth}));b.startline&&k.push(i(P(0),{color:b.startlinecolor,width:b.startlinewidth})),b.endline&&k.push(i(P(x.length-1),{color:b.endlinecolor,width:b.endlinewidth}))}else{for(l=5e-15,u=(c=[Math.floor((x[x.length-1]-b.tick0)/b.dtick*(1+l)),Math.ceil((x[0]-b.tick0)/b.dtick/(1+l))].sort(function(t,e){return t-e}))[0],f=c[1],h=u;h<=f;h++)p=b.tick0+b.dtick*h,_.push(i(I(p),{color:b.gridcolor,width:b.gridwidth}));for(h=u-1;hx[x.length-1]||w.push(i(I(d),{color:b.minorgridcolor,width:b.minorgridwidth}));b.startline&&k.push(i(I(x[0]),{color:b.startlinecolor,width:b.startlinewidth})),b.endline&&k.push(i(I(x[x.length-1]),{color:b.endlinecolor,width:b.endlinewidth}))}}},{"../../lib/extend":682,"../../plots/cartesian/axes":740}],881:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib/extend").extendFlat;e.exports=function(t,e){var r,a,o,s=e._labels=[],l=e._gridlines;for(r=0;re.length&&(t=t.slice(0,e.length)):t=[],i=0;i90&&(p-=180,l=-l),{angle:p,flip:l,p:t.c2p(n,e,r),offsetMultplier:c}}},{}],895:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../components/drawing"),a=t("./map_1d_array"),o=t("./makepath"),s=t("./orient_text"),l=t("../../lib/svg_text_utils"),c=t("../../lib"),u=t("../../constants/alignment");function f(t,e,r,i,s,l){var c="const-"+s+"-lines",u=r.selectAll("."+c).data(l);u.enter().append("path").classed(c,!0).style("vector-effect","non-scaling-stroke"),u.each(function(r){var i=r,s=i.x,l=i.y,c=a([],s,t.c2p),u=a([],l,e.c2p),f="M"+o(c,u,i.smoothing);n.select(this).attr("d",f).style("stroke-width",i.width).style("stroke",i.color).style("fill","none")}),u.exit().remove()}function h(t,e,r,a,o,c,u,f){var h=c.selectAll("text."+f).data(u);h.enter().append("text").classed(f,!0);var p=0,d={};return h.each(function(o,c){var u;if("auto"===o.axis.tickangle)u=s(a,e,r,o.xy,o.dxy);else{var f=(o.axis.tickangle+180)*Math.PI/180;u=s(a,e,r,o.xy,[Math.cos(f),Math.sin(f)])}c||(d={angle:u.angle,flip:u.flip});var h=(o.endAnchor?-1:1)*u.flip,g=n.select(this).attr({"text-anchor":h>0?"start":"end","data-notex":1}).call(i.font,o.font).text(o.text).call(l.convertToTspans,t),v=i.bBox(this);g.attr("transform","translate("+u.p[0]+","+u.p[1]+") rotate("+u.angle+")translate("+o.axis.labelpadding*h+","+.3*v.height+")"),p=Math.max(p,v.width+o.axis.labelpadding)}),h.exit().remove(),d.maxExtent=p,d}e.exports=function(t,e,r,i){var l=e.xaxis,u=e.yaxis,p=t._fullLayout._clips;c.makeTraceGroups(i,r,"trace").each(function(e){var r=n.select(this),i=e[0],d=i.trace,v=d.aaxis,m=d.baxis,y=c.ensureSingle(r,"g","minorlayer"),x=c.ensureSingle(r,"g","majorlayer"),b=c.ensureSingle(r,"g","boundarylayer"),_=c.ensureSingle(r,"g","labellayer");r.style("opacity",d.opacity),f(l,u,x,v,"a",v._gridlines),f(l,u,x,m,"b",m._gridlines),f(l,u,y,v,"a",v._minorgridlines),f(l,u,y,m,"b",m._minorgridlines),f(l,u,b,v,"a-boundary",v._boundarylines),f(l,u,b,m,"b-boundary",m._boundarylines);var w=h(t,l,u,d,i,_,v._labels,"a-label"),k=h(t,l,u,d,i,_,m._labels,"b-label");!function(t,e,r,n,i,a,o,l){var u,f,h,p;u=.5*(r.a[0]+r.a[r.a.length-1]),f=r.b[0],h=r.ab2xy(u,f,!0),p=r.dxyda_rough(u,f),void 0===o.angle&&c.extendFlat(o,s(r,i,a,h,r.dxydb_rough(u,f)));g(t,e,r,n,h,p,r.aaxis,i,a,o,"a-title"),u=r.a[0],f=.5*(r.b[0]+r.b[r.b.length-1]),h=r.ab2xy(u,f,!0),p=r.dxydb_rough(u,f),void 0===l.angle&&c.extendFlat(l,s(r,i,a,h,r.dxyda_rough(u,f)));g(t,e,r,n,h,p,r.baxis,i,a,l,"b-title")}(t,_,d,i,l,u,w,k),function(t,e,r,n,i){var s,l,u,f,h=r.select("#"+t._clipPathId);h.size()||(h=r.append("clipPath").classed("carpetclip",!0));var p=c.ensureSingle(h,"path","carpetboundary"),d=e.clipsegments,g=[];for(f=0;f90&&v<270,y=n.select(this);y.text(u.title.text).call(l.convertToTspans,t),m&&(x=(-l.lineCount(y)+d)*p*a-x),y.attr("transform","translate("+e.p[0]+","+e.p[1]+") rotate("+e.angle+") translate(0,"+x+")").classed("user-select-none",!0).attr("text-anchor","middle").call(i.font,u.title.font)}),y.exit().remove()}},{"../../components/drawing":590,"../../constants/alignment":664,"../../lib":692,"../../lib/svg_text_utils":716,"./makepath":892,"./map_1d_array":893,"./orient_text":894,d3:148}],896:[function(t,e,r){"use strict";var n=t("./constants"),i=t("../../lib/search").findBin,a=t("./compute_control_points"),o=t("./create_spline_evaluator"),s=t("./create_i_derivative_evaluator"),l=t("./create_j_derivative_evaluator");e.exports=function(t){var e=t._a,r=t._b,c=e.length,u=r.length,f=t.aaxis,h=t.baxis,p=e[0],d=e[c-1],g=r[0],v=r[u-1],m=e[e.length-1]-e[0],y=r[r.length-1]-r[0],x=m*n.RELATIVE_CULL_TOLERANCE,b=y*n.RELATIVE_CULL_TOLERANCE;p-=x,d+=x,g-=b,v+=b,t.isVisible=function(t,e){return t>p&&tg&&ed||ev},t.setScale=function(){var e=t._x,r=t._y,n=a(t._xctrl,t._yctrl,e,r,f.smoothing,h.smoothing);t._xctrl=n[0],t._yctrl=n[1],t.evalxy=o([t._xctrl,t._yctrl],c,u,f.smoothing,h.smoothing),t.dxydi=s([t._xctrl,t._yctrl],f.smoothing,h.smoothing),t.dxydj=l([t._xctrl,t._yctrl],f.smoothing,h.smoothing)},t.i2a=function(t){var r=Math.max(0,Math.floor(t[0]),c-2),n=t[0]-r;return(1-n)*e[r]+n*e[r+1]},t.j2b=function(t){var e=Math.max(0,Math.floor(t[1]),c-2),n=t[1]-e;return(1-n)*r[e]+n*r[e+1]},t.ij2ab=function(e){return[t.i2a(e[0]),t.j2b(e[1])]},t.a2i=function(t){var r=Math.max(0,Math.min(i(t,e),c-2)),n=e[r],a=e[r+1];return Math.max(0,Math.min(c-1,r+(t-n)/(a-n)))},t.b2j=function(t){var e=Math.max(0,Math.min(i(t,r),u-2)),n=r[e],a=r[e+1];return Math.max(0,Math.min(u-1,e+(t-n)/(a-n)))},t.ab2ij=function(e){return[t.a2i(e[0]),t.b2j(e[1])]},t.i2c=function(e,r){return t.evalxy([],e,r)},t.ab2xy=function(n,i,a){if(!a&&(ne[c-1]|ir[u-1]))return[!1,!1];var o=t.a2i(n),s=t.b2j(i),l=t.evalxy([],o,s);if(a){var f,h,p,d,g=0,v=0,m=[];ne[c-1]?(f=c-2,h=1,g=(n-e[c-1])/(e[c-1]-e[c-2])):h=o-(f=Math.max(0,Math.min(c-2,Math.floor(o)))),ir[u-1]?(p=u-2,d=1,v=(i-r[u-1])/(r[u-1]-r[u-2])):d=s-(p=Math.max(0,Math.min(u-2,Math.floor(s)))),g&&(t.dxydi(m,f,p,h,d),l[0]+=m[0]*g,l[1]+=m[1]*g),v&&(t.dxydj(m,f,p,h,d),l[0]+=m[0]*v,l[1]+=m[1]*v)}return l},t.c2p=function(t,e,r){return[e.c2p(t[0]),r.c2p(t[1])]},t.p2x=function(t,e,r){return[e.p2c(t[0]),r.p2c(t[1])]},t.dadi=function(t){var r=Math.max(0,Math.min(e.length-2,t));return e[r+1]-e[r]},t.dbdj=function(t){var e=Math.max(0,Math.min(r.length-2,t));return r[e+1]-r[e]},t.dxyda=function(e,r,n,i){var a=t.dxydi(null,e,r,n,i),o=t.dadi(e,n);return[a[0]/o,a[1]/o]},t.dxydb=function(e,r,n,i){var a=t.dxydj(null,e,r,n,i),o=t.dbdj(r,i);return[a[0]/o,a[1]/o]},t.dxyda_rough=function(e,r,n){var i=m*(n||.1),a=t.ab2xy(e+i,r,!0),o=t.ab2xy(e-i,r,!0);return[.5*(a[0]-o[0])/i,.5*(a[1]-o[1])/i]},t.dxydb_rough=function(e,r,n){var i=y*(n||.1),a=t.ab2xy(e,r+i,!0),o=t.ab2xy(e,r-i,!0);return[.5*(a[0]-o[0])/i,.5*(a[1]-o[1])/i]},t.dpdx=function(t){return t._m},t.dpdy=function(t){return t._m}}},{"../../lib/search":711,"./compute_control_points":884,"./constants":885,"./create_i_derivative_evaluator":886,"./create_j_derivative_evaluator":887,"./create_spline_evaluator":888}],897:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a,o,s=[],l=[],c=t[0].length,u=t.length;function f(e,r){var n,i=0,a=0;return e>0&&void 0!==(n=t[r][e-1])&&(a++,i+=n),e0&&void 0!==(n=t[r-1][e])&&(a++,i+=n),r0&&a0&&i1e-5);return n.log("Smoother converged to",M,"after",A,"iterations"),t}},{"../../lib":692}],898:[function(t,e,r){"use strict";var n=t("../../lib").isArray1D;e.exports=function(t,e,r){var i=r("x"),a=i&&i.length,o=r("y"),s=o&&o.length;if(!a&&!s)return!1;if(e._cheater=!i,a&&!n(i)||s&&!n(o))e._length=null;else{var l=a?i.length:1/0;s&&(l=Math.min(l,o.length)),e.a&&e.a.length&&(l=Math.min(l,e.a.length)),e.b&&e.b.length&&(l=Math.min(l,e.b.length)),e._length=l}return!0}},{"../../lib":692}],899:[function(t,e,r){"use strict";var n=t("../scattergeo/attributes"),i=t("../../components/colorscale/attributes"),a=t("../../components/colorbar/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat,l=n.marker.line;e.exports=s({locations:{valType:"data_array",editType:"calc"},locationmode:n.locationmode,z:{valType:"data_array",editType:"calc"},text:s({},n.text,{}),marker:{line:{color:l.color,width:s({},l.width,{dflt:1}),editType:"calc"},opacity:{valType:"number",arrayOk:!0,min:0,max:1,dflt:1,editType:"style"},editType:"calc"},selected:{marker:{opacity:n.selected.marker.opacity,editType:"plot"},editType:"plot"},unselected:{marker:{opacity:n.unselected.marker.opacity,editType:"plot"},editType:"plot"},hoverinfo:s({},o.hoverinfo,{editType:"calc",flags:["location","z","text","name"]})},i("",{cLetter:"z",editTypeOverride:"calc"}),{colorbar:a})},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../scattergeo/attributes":1080}],900:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../constants/numerical").BADNUM,a=t("../../components/colorscale/calc"),o=t("../scatter/arrays_to_calcdata"),s=t("../scatter/calc_selection");e.exports=function(t,e){for(var r=e._length,l=new Array(r),c=0;c")}(t,f,o,h.mockAxis),[t]}},{"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048,"./attributes":899}],904:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.eventData=t("./event_data"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":771,"../heatmap/colorbar":945,"./attributes":899,"./calc":900,"./defaults":901,"./event_data":902,"./hover":903,"./plot":905,"./select":906,"./style":907}],905:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../lib/polygon"),o=t("../../lib/topojson_utils").getTopojsonFeatures,s=t("../../lib/geo_location_utils").locationToFeature,l=t("./style").style;function c(t,e){for(var r=t[0].trace,n=t.length,i=o(r,e),a=0;a0&&t[e+1][0]<0)return e;return null}switch(e="RUS"===l||"FJI"===l?function(t){var e;if(null===u(t))e=t;else for(e=new Array(t.length),i=0;ie?r[n++]=[t[i][0]+360,t[i][1]]:i===e?(r[n++]=t[i],r[n++]=[t[i][0],-90]):r[n++]=t[i];var o=a.tester(r);o.pts.pop(),c.push(o)}:function(t){c.push(a.tester(t))},o.type){case"MultiPolygon":for(r=0;r":f.value>h&&(s.prefixBoundary=!0);break;case"<":f.valueh)&&(s.prefixBoundary=!0);break;case"][":a=Math.min.apply(null,f.value),o=Math.max.apply(null,f.value),ah&&(s.prefixBoundary=!0)}}},{}],916:[function(t,e,r){"use strict";var n=t("../../components/colorbar/draw"),i=t("./make_color_map"),a=t("./end_plus");e.exports=function(t,e){var r=e[0].trace,o="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+o).remove(),r.showscale){var s=e[0].t.cb=n(t,o),l=r.contours,c=r.line,u=l.size||1,f=l.coloring,h=i(r,{isColorbar:!0});s.fillgradient("heatmap"===f?r.colorscale:"").zrange("heatmap"===f?[r.zmin,r.zmax]:"").fillcolor("fill"===f?h:"").line({color:"lines"===f?h:c.color,width:!1!==l.showlines?c.width:0,dash:c.dash}).levels({start:l.start,end:a(l),size:u}).options(r.colorbar)()}}},{"../../components/colorbar/draw":574,"./end_plus":924,"./make_color_map":929}],917:[function(t,e,r){"use strict";e.exports={BOTTOMSTART:[1,9,13,104,713],TOPSTART:[4,6,7,104,713],LEFTSTART:[8,12,14,208,1114],RIGHTSTART:[2,3,11,208,1114],NEWDELTA:[null,[-1,0],[0,-1],[-1,0],[1,0],null,[0,-1],[-1,0],[0,1],[0,1],null,[0,1],[1,0],[1,0],[0,-1]],CHOOSESADDLE:{104:[4,1],208:[2,8],713:[7,13],1114:[11,14]},SADDLEREMAINDER:{1:4,2:8,4:1,7:13,8:2,11:14,13:7,14:11},LABELDISTANCE:2,LABELINCREASE:10,LABELMIN:3,LABELMAX:10,LABELOPTIMIZER:{EDGECOST:1,ANGLECOST:1,NEIGHBORCOST:5,SAMELEVELFACTOR:10,SAMELEVELDISTANCE:5,MAXCOST:100,INITIALSEARCHPOINTS:10,ITERATIONS:5}}},{}],918:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("./label_defaults"),a=t("../../components/color"),o=a.addOpacity,s=a.opacity,l=t("../../constants/filter_ops"),c=l.CONSTRAINT_REDUCTION,u=l.COMPARISON_OPS2;e.exports=function(t,e,r,a,l,f){var h,p,d,g=e.contours,v=r("contours.operation");(g._operation=c[v],function(t,e){var r;-1===u.indexOf(e.operation)?(t("contours.value",[0,1]),Array.isArray(e.value)?e.value.length>2?e.value=e.value.slice(2):0===e.length?e.value=[0,1]:e.length<2?(r=parseFloat(e.value[0]),e.value=[r,r+1]):e.value=[parseFloat(e.value[0]),parseFloat(e.value[1])]:n(e.value)&&(r=parseFloat(e.value),e.value=[r,r+1])):(t("contours.value",0),n(e.value)||(Array.isArray(e.value)?e.value=parseFloat(e.value[0]):e.value=0))}(r,g),"="===v?h=g.showlines=!0:(h=r("contours.showlines"),d=r("fillcolor",o((t.line||{}).color||l,.5))),h)&&(p=r("line.color",d&&s(d)?o(e.fillcolor,1):l),r("line.width",2),r("line.dash"));r("line.smoothing"),i(r,a,p,f)}},{"../../components/color":569,"../../constants/filter_ops":665,"./label_defaults":928,"fast-isnumeric":214}],919:[function(t,e,r){"use strict";var n=t("../../constants/filter_ops"),i=t("fast-isnumeric");function a(t,e){var r,a=Array.isArray(e);function o(t){return i(t)?+t:null}return-1!==n.COMPARISON_OPS2.indexOf(t)?r=o(a?e[0]:e):-1!==n.INTERVAL_OPS.indexOf(t)?r=a?[o(e[0]),o(e[1])]:[o(e),o(e)]:-1!==n.SET_OPS.indexOf(t)&&(r=a?e.map(o):[o(e)]),r}function o(t){return function(e){e=a(t,e);var r=Math.min(e[0],e[1]),n=Math.max(e[0],e[1]);return{start:r,end:n,size:n-r}}}function s(t){return function(e){return{start:e=a(t,e),end:1/0,size:1/0}}}e.exports={"[]":o("[]"),"][":o("]["),">":s(">"),"<":s("<"),"=":s("=")}},{"../../constants/filter_ops":665,"fast-isnumeric":214}],920:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var i=n("contours.start"),a=n("contours.end"),o=!1===i||!1===a,s=r("contours.size");!(o?e.autocontour=!0:r("autocontour",!1))&&s||r("ncontours")}},{}],921:[function(t,e,r){"use strict";var n=t("../../lib");function i(t){return n.extendFlat({},t,{edgepaths:n.extendDeep([],t.edgepaths),paths:n.extendDeep([],t.paths)})}e.exports=function(t,e){var r,a,o,s=function(t){return t.reverse()},l=function(t){return t};switch(e){case"=":case"<":return t;case">":for(1!==t.length&&n.warn("Contour data invalid for the specified inequality operation."),a=t[0],r=0;r1e3){n.warn("Too many contours, clipping at 1000",t);break}return l}},{"../../lib":692,"./constraint_mapping":919,"./end_plus":924}],924:[function(t,e,r){"use strict";e.exports=function(t){return t.end+t.size/1e6}},{}],925:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./constants");function a(t,e,r,n){return Math.abs(t[0]-e[0])20&&e?208===t||1114===t?n=0===r[0]?1:-1:a=0===r[1]?1:-1:-1!==i.BOTTOMSTART.indexOf(t)?a=1:-1!==i.LEFTSTART.indexOf(t)?n=1:-1!==i.TOPSTART.indexOf(t)?a=-1:n=-1;return[n,a]}(h,r,e),d=[s(t,e,[-p[0],-p[1]])],g=p.join(","),v=t.z.length,m=t.z[0].length;for(c=0;c<1e4;c++){if(h>20?(h=i.CHOOSESADDLE[h][(p[0]||p[1])<0?0:1],t.crossings[f]=i.SADDLEREMAINDER[h]):delete t.crossings[f],!(p=i.NEWDELTA[h])){n.log("Found bad marching index:",h,e,t.level);break}d.push(s(t,e,p)),e[0]+=p[0],e[1]+=p[1],a(d[d.length-1],d[d.length-2],o,l)&&d.pop(),f=e.join(",");var y=p[0]&&(e[0]<0||e[0]>m-2)||p[1]&&(e[1]<0||e[1]>v-2);if(f===u&&p.join(",")===g||r&&y)break;h=t.crossings[f]}1e4===c&&n.log("Infinite loop in contour?");var x,b,_,w,k,M,A,T,S,C,E,L,z,O,I,P=a(d[0],d[d.length-1],o,l),D=0,R=.2*t.smoothing,F=[],B=0;for(c=1;c=B;c--)if((x=F[c])=B&&x+F[b]T&&S--,t.edgepaths[S]=E.concat(d,C));break}U||(t.edgepaths[T]=d.concat(C))}for(T=0;Tt?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);return 5===r||10===r?t>(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4?5===r?713:1114:5===r?104:208:15===r?0:r}e.exports=function(t){var e,r,a,o,s,l,c,u,f,h=t[0].z,p=h.length,d=h[0].length,g=2===p||2===d;for(r=0;rt.level}return r?"M"+e.join("L")+"Z":""}(t,e),h=0,p=t.edgepaths.map(function(t,e){return e}),d=!0;function g(t){return Math.abs(t[1]-e[2][1])<.01}function v(t){return Math.abs(t[0]-e[0][0])<.01}function m(t){return Math.abs(t[0]-e[2][0])<.01}for(;p.length;){for(c=a.smoothopen(t.edgepaths[h],t.smoothing),f+=d?c:c.replace(/^M/,"L"),p.splice(p.indexOf(h),1),r=t.edgepaths[h][t.edgepaths[h].length-1],s=-1,o=0;o<4;o++){if(!r){i.log("Missing end?",h,t);break}for(u=r,Math.abs(u[1]-e[0][1])<.01&&!m(r)?n=e[1]:v(r)?n=e[0]:g(r)?n=e[3]:m(r)&&(n=e[2]),l=0;l=0&&(n=y,s=l):Math.abs(r[1]-n[1])<.01?Math.abs(r[1]-y[1])<.01&&(y[0]-r[0])*(n[0]-y[0])>=0&&(n=y,s=l):i.log("endpt to newendpt is not vert. or horz.",r,n,y)}if(r=n,s>=0)break;f+="L"+n}if(s===t.edgepaths.length){i.log("unclosed perimeter path");break}h=s,(d=-1===p.indexOf(h))&&(h=p[0],f+="Z")}for(h=0;hn.center?n.right-s:s-n.left)/(u+Math.abs(Math.sin(c)*o)),p=(l>n.middle?n.bottom-l:l-n.top)/(Math.abs(f)+Math.cos(c)*o);if(h<1||p<1)return 1/0;var d=v.EDGECOST*(1/(h-1)+1/(p-1));d+=v.ANGLECOST*c*c;for(var g=s-u,m=l-f,y=s+u,x=l+f,b=0;b2*v.MAXCOST)break;p&&(s/=2),l=(o=c-s/2)+1.5*s}if(h<=v.MAXCOST)return u},r.addLabelData=function(t,e,r,n){var i=e.width/2,a=e.height/2,o=t.x,s=t.y,l=t.theta,c=Math.sin(l),u=Math.cos(l),f=i*u,h=a*c,p=i*c,d=-a*u,g=[[o-f-h,s-p-d],[o+f-h,s+p-d],[o+f+h,s+p+d],[o-f+h,s-p+d]];r.push({text:e.text,x:o,y:s,dy:e.dy,theta:l,level:e.level,width:e.width,height:e.height}),n.push(g)},r.drawLabels=function(t,e,r,a,s){var l=t.selectAll("text").data(e,function(t){return t.text+","+t.x+","+t.y+","+t.theta});if(l.exit().remove(),l.enter().append("text").attr({"data-notex":1,"text-anchor":"middle"}).each(function(t){var e=t.x+Math.sin(t.theta)*t.dy,i=t.y-Math.cos(t.theta)*t.dy;n.select(this).text(t.text).attr({x:e,y:i,transform:"rotate("+180*t.theta/Math.PI+" "+e+" "+i+")"}).call(o.convertToTspans,r)}),s){for(var c="",u=0;ue.end&&(e.start=e.end=(e.start+e.end)/2),t._input.contours||(t._input.contours={}),i.extendFlat(t._input.contours,{start:e.start,end:e.end,size:e.size}),t._input.autocontour=!0}else if("constraint"!==e.type){var l,c=e.start,u=e.end,f=t._input.contours;if(c>u&&(e.start=f.start=u,u=e.end=f.end=c,c=e.start),!(e.size>0))l=c===u?1:a(c,u,t.ncontours).dtick,f.size=e.size=l}}},{"../../lib":692,"../../plots/cartesian/axes":740}],933:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../components/drawing"),a=t("../heatmap/style"),o=t("./make_color_map");e.exports=function(t){var e=n.select(t).selectAll("g.contour");e.style("opacity",function(t){return t[0].trace.opacity}),e.each(function(t){var e=n.select(this),r=t[0].trace,a=r.contours,s=r.line,l=a.size||1,c=a.start,u="constraint"===a.type,f=!u&&"lines"===a.coloring,h=!u&&"fill"===a.coloring,p=f||h?o(r):null;e.selectAll("g.contourlevel").each(function(t){n.select(this).selectAll("path").call(i.lineGroupStyle,s.width,f?p(t.level):s.color,s.dash)});var d=a.labelfont;if(e.selectAll("g.contourlabels text").each(function(t){i.font(n.select(this),{family:d.family,size:d.size,color:d.color||(f?p(t.level):s.color)})}),u)e.selectAll("g.contourfill path").style("fill",r.fillcolor);else if(h){var g;e.selectAll("g.contourfill path").style("fill",function(t){return void 0===g&&(g=t.level),p(t.level+.5*l)}),void 0===g&&(g=c),e.selectAll("g.contourbg path").style("fill",p(g-.5*l))}}),a(t)}},{"../../components/drawing":590,"../heatmap/style":954,"./make_color_map":929,d3:148}],934:[function(t,e,r){"use strict";var n=t("../../components/colorscale/defaults"),i=t("./label_defaults");e.exports=function(t,e,r,a,o){var s,l=r("contours.coloring"),c="";"fill"===l&&(s=r("contours.showlines")),!1!==s&&("lines"!==l&&(c=r("line.color","#000")),r("line.width",.5),r("line.dash")),"none"!==l&&(!0!==t.showlegend&&(e.showlegend=!1),e._dfltShowLegend=!1,n(t,e,a,r,{prefix:"",cLetter:"z"})),r("line.smoothing"),i(r,a,c,o)}},{"../../components/colorscale/defaults":579,"./label_defaults":928}],935:[function(t,e,r){"use strict";var n=t("../heatmap/attributes"),i=t("../contour/attributes"),a=i.contours,o=t("../scatter/attributes"),s=t("../../components/colorscale/attributes"),l=t("../../components/colorbar/attributes"),c=t("../../lib/extend").extendFlat,u=o.line;e.exports=c({carpet:{valType:"string",editType:"calc"},z:n.z,a:n.x,a0:n.x0,da:n.dx,b:n.y,b0:n.y0,db:n.dy,text:n.text,transpose:n.transpose,atype:n.xtype,btype:n.ytype,fillcolor:i.fillcolor,autocontour:i.autocontour,ncontours:i.ncontours,contours:{type:a.type,start:a.start,end:a.end,size:a.size,coloring:{valType:"enumerated",values:["fill","lines","none"],dflt:"fill",editType:"calc"},showlines:a.showlines,showlabels:a.showlabels,labelfont:a.labelfont,labelformat:a.labelformat,operation:a.operation,value:a.value,editType:"calc",impliedEdits:{autocontour:!1}},line:{color:c({},u.color,{}),width:u.width,dash:u.dash,smoothing:c({},u.smoothing,{}),editType:"plot"},transforms:void 0},s("",{cLetter:"z",autoColorDflt:!1}),{colorbar:l})},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../contour/attributes":913,"../heatmap/attributes":942,"../scatter/attributes":1040}],936:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc"),i=t("../../lib"),a=t("../heatmap/convert_column_xyz"),o=t("../heatmap/clean_2d_array"),s=t("../heatmap/interp2d"),l=t("../heatmap/find_empties"),c=t("../heatmap/make_bound_array"),u=t("./defaults"),f=t("../carpet/lookup_carpetid"),h=t("../contour/set_contours");e.exports=function(t,e){var r=e._carpetTrace=f(t,e);if(r&&r.visible&&"legendonly"!==r.visible){if(!e.a||!e.b){var p=t.data[r.index],d=t.data[e.index];d.a||(d.a=p.a),d.b||(d.b=p.b),u(d,e,e._defaultColor,t._fullLayout)}var g=function(t,e){var r,u,f,h,p,d,g,v=e._carpetTrace,m=v.aaxis,y=v.baxis;m._minDtick=0,y._minDtick=0,i.isArray1D(e.z)&&a(e,m,y,"a","b",["z"]);r=e._a=e._a||e.a,h=e._b=e._b||e.b,r=r?m.makeCalcdata(e,"_a"):[],h=h?y.makeCalcdata(e,"_b"):[],u=e.a0||0,f=e.da||1,p=e.b0||0,d=e.db||1,g=e._z=o(e._z||e.z,e.transpose),e._emptypoints=l(g),s(g,e._emptypoints);var x=i.maxRowLength(g),b="scaled"===e.xtype?"":r,_=c(e,b,u,f,x,m),w="scaled"===e.ytype?"":h,k=c(e,w,p,d,g.length,y),M={a:_,b:k,z:g};"levels"===e.contours.type&&"none"!==e.contours.coloring&&n(t,e,{vals:g,containerStr:"",cLetter:"z"});return[M]}(t,e);return h(e),g}}},{"../../components/colorscale/calc":577,"../../lib":692,"../carpet/lookup_carpetid":891,"../contour/set_contours":932,"../heatmap/clean_2d_array":944,"../heatmap/convert_column_xyz":946,"../heatmap/find_empties":948,"../heatmap/interp2d":951,"../heatmap/make_bound_array":952,"./defaults":937}],937:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../heatmap/xyz_defaults"),a=t("./attributes"),o=t("../contour/constraint_defaults"),s=t("../contour/contours_defaults"),l=t("../contour/style_defaults");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,a,r,i)}if(u("carpet"),t.a&&t.b){if(!i(t,e,u,c,"a","b"))return void(e.visible=!1);u("text"),"constraint"===u("contours.type")?o(t,e,u,c,r,{hasHover:!1}):(s(t,e,u,function(r){return n.coerce2(t,e,a,r)}),l(t,e,u,c,{hasHover:!1}))}else e._defaultColor=r,e._length=null}},{"../../lib":692,"../contour/constraint_defaults":918,"../contour/contours_defaults":920,"../contour/style_defaults":934,"../heatmap/xyz_defaults":956,"./attributes":935}],938:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../contour/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("../contour/style"),n.moduleType="trace",n.name="contourcarpet",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","carpet","contour","symbols","showLegend","hasLines","carpetDependent"],n.meta={},e.exports=n},{"../../plots/cartesian":752,"../contour/colorbar":916,"../contour/style":933,"./attributes":935,"./calc":936,"./defaults":937,"./plot":941}],939:[function(t,e,r){"use strict";var n=t("../../components/drawing"),i=t("../carpet/axis_aligned_line"),a=t("../../lib");e.exports=function(t,e,r,o,s,l,c,u){var f,h,p,d,g,v,m,y="",x=e.edgepaths.map(function(t,e){return e}),b=!0,_=1e-4*Math.abs(r[0][0]-r[2][0]),w=1e-4*Math.abs(r[0][1]-r[2][1]);function k(t){return Math.abs(t[1]-r[0][1])=0&&(p=E,g=v):Math.abs(h[1]-p[1])=0&&(p=E,g=v):a.log("endpt to newendpt is not vert. or horz.",h,p,E)}if(g>=0)break;y+=S(h,p),h=p}if(g===e.edgepaths.length){a.log("unclosed perimeter path");break}f=g,(b=-1===x.indexOf(f))&&(f=x[0],y+=S(h,p)+"Z",h=null)}for(f=0;f=0;V--)B=S.clipsegments[V],N=i([],B.x,w.c2p),j=i([],B.y,k.c2p),N.reverse(),j.reverse(),q.push(a(N,j,B.bicubic));var H="M"+q.join("L")+"Z";!function(t,e,r,n,o,l){var c,u,f,h,p=s.ensureSingle(t,"g","contourbg").selectAll("path").data("fill"!==l||o?[]:[0]);p.enter().append("path"),p.exit().remove();var d=[];for(h=0;hv&&(n.max=v);n.len=n.max-n.min}(this,r,t,n,c,e.height),!(n.len<(e.width+e.height)*f.LABELMIN)))for(var i=Math.min(Math.ceil(n.len/O),f.LABELMAX),a=0;aL){C("x scale is not linear");break}}if(g.length&&"fast"===T){var z=(g[g.length-1]-g[0])/(g.length-1),O=Math.abs(z/100);for(x=0;xO){C("y scale is not linear");break}}}var I=i.maxRowLength(y),P="scaled"===e.xtype?"":r,D=h(e,P,p,d,I,_),R="scaled"===e.ytype?"":g,F=h(e,R,v,m,y.length,w);A||(e._extremes[_._id]=a.findExtremes(_,D),e._extremes[w._id]=a.findExtremes(w,F));var B={x:D,y:F,z:y,text:e._text||e.text};if(P&&P.length===D.length-1&&(B.xCenter=P),R&&R.length===F.length-1&&(B.yCenter=R),M&&(B.xRanges=b.xRanges,B.yRanges=b.yRanges,B.pts=b.pts),k&&"constraint"===e.contours.type||s(t,e,{vals:y,containerStr:"",cLetter:"z"}),k&&e.contours&&"heatmap"===e.contours.coloring){var N={type:"contour"===e.type?"heatmap":"histogram2d",xcalendar:e.xcalendar,ycalendar:e.ycalendar};B.xfill=h(N,P,p,d,I,_),B.yfill=h(N,R,v,m,y.length,w)}return[B]}},{"../../components/colorscale/calc":577,"../../lib":692,"../../plots/cartesian/axes":740,"../../registry":823,"../histogram2d/calc":974,"./clean_2d_array":944,"./convert_column_xyz":946,"./find_empties":948,"./interp2d":951,"./make_bound_array":952}],944:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){var r,i,a,o,s,l;function c(t){if(n(t))return+t}if(e){for(r=0,s=0;s=0;o--)(s=((f[[(r=(a=h[o])[0])-1,i=a[1]]]||g)[2]+(f[[r+1,i]]||g)[2]+(f[[r,i-1]]||g)[2]+(f[[r,i+1]]||g)[2])/20)&&(l[a]=[r,i,s],h.splice(o,1),c=!0);if(!c)throw"findEmpties iterated with no new neighbors";for(a in l)f[a]=l[a],u.push(l[a])}return u.sort(function(t,e){return e[2]-t[2]})}},{"../../lib":692}],949:[function(t,e,r){"use strict";var n=t("../../components/fx"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e,r,o,s,l){var c,u,f,h,p=t.cd[0],d=p.trace,g=t.xa,v=t.ya,m=p.x,y=p.y,x=p.z,b=p.xCenter,_=p.yCenter,w=p.zmask,k=[d.zmin,d.zmax],M=d.zhoverformat,A=m,T=y;if(!1!==t.index){try{f=Math.round(t.index[1]),h=Math.round(t.index[0])}catch(e){return void i.error("Error hovering on heatmap, pointNumber must be [row,col], found:",t.index)}if(f<0||f>=x[0].length||h<0||h>x.length)return}else{if(n.inbox(e-m[0],e-m[m.length-1],0)>0||n.inbox(r-y[0],r-y[y.length-1],0)>0)return;if(l){var S;for(A=[2*m[0]-m[1]],S=1;Sg&&(m=Math.max(m,Math.abs(t[a][o]-d)/(v-g))))}return m}e.exports=function(t,e){var r,i=1;for(o(t,e),r=0;r.01;r++)i=o(t,e,a(i));return i>.01&&n.log("interp2d didn't converge quickly",i),t}},{"../../lib":692}],952:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib").isArrayOrTypedArray;e.exports=function(t,e,r,a,o,s){var l,c,u,f=[],h=n.traceIs(t,"contour"),p=n.traceIs(t,"histogram"),d=n.traceIs(t,"gl2d");if(i(e)&&e.length>1&&!p&&"category"!==s.type){var g=e.length;if(!(g<=o))return h?e.slice(0,o):e.slice(0,o+1);if(h||d)f=e.slice(0,o);else if(1===o)f=[e[0]-.5,e[0]+.5];else{for(f=[1.5*e[0]-.5*e[1]],u=1;u0;)h=p.c2p(k[y]),y--;for(h0;)m=d.c2p(M[y]),y--;if(m0&&(a=!0);for(var l=0;la){var o=a-r[t];return r[t]=a,o}}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]c?t>o?t>1.1*i?i:t>1.1*a?a:o:t>s?s:t>l?l:c:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function p(t,e,r,n,a,s){if(n&&t>o){var l=d(e,a,s),c=d(r,a,s),u=t===i?0:1;return l[u]!==c[u]}return Math.floor(r/t)-Math.floor(e/t)>.1}function d(t,e,r){var n=e.c2d(t,i,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}e.exports=function(t,e,r,n,a){var s,l,c=-1.1*e,h=-.1*e,p=t-h,d=r[0],g=r[1],v=Math.min(f(d+h,d+p,n,a),f(g+h,g+p,n,a)),m=Math.min(f(d+c,d+h,n,a),f(g+c,g+h,n,a));if(v>m&&mo){var y=s===i?1:6,x=s===i?"M12":"M1";return function(e,r){var o=n.c2d(e,i,a),s=o.indexOf("-",y);s>0&&(o=o.substr(0,s));var c=n.d2c(o,0,a);if(cr.r2l(z)&&(I=a.tickIncrement(I,_.size,!0,h)),S.start=r.l2r(I),L||i.nestedProperty(e,v+".start").set(S.start)}var P=_.end,D=r.r2l(T.end),R=void 0!==D;if((_.endFound||R)&&D!==r.r2l(P)){var F=R?D:i.aggNums(Math.max,null,p);S.end=r.l2r(F),R||i.nestedProperty(e,v+".start").set(S.end)}var B="autobin"+o;return!1===e._input[B]&&(e._input[v]=i.extendFlat({},e[v]||{}),delete e._input[B],delete e[B]),[S,p]}e.exports=function(t,e){if(!0===e.visible){var r,h,p,d,g=[],v=[],m=a.getFromId(t,"h"===e.orientation?e.yaxis||"y":e.xaxis||"x"),y="h"===e.orientation?"y":"x",x={x:"y",y:"x"}[y],b=e[y+"calendar"],_=e.cumulative,w=f(t,e,m,y),k=w[0],M=w[1],A="string"==typeof k.size,T=[],S=A?T:k,C=[],E=[],L=[],z=0,O=e.histnorm,I=e.histfunc,P=-1!==O.indexOf("density");_.enabled&&P&&(O=O.replace(/ ?density$/,""),P=!1);var D,R="max"===I||"min"===I?null:0,F=s.count,B=l[O],N=!1,j=function(t){return m.r2c(t,0,b)};for(i.isArrayOrTypedArray(e[x])&&"count"!==I&&(D=e[x],N="avg"===I,F=s[I]),r=j(k.start),p=j(k.end)+(r-a.tickIncrement(r,k.size,!1,b))/1e6;r=0&&d=0;n--)s(n);else if("increasing"===e){for(n=1;n=0;n--)t[n]+=t[n+1];"exclude"===r&&(t.push(0),t.shift())}}(v,_.direction,_.currentbin);var X=Math.min(g.length,v.length),Z=[],$=0,J=X-1;for(r=0;r=$;r--)if(v[r]){J=r;break}for(r=$;r<=J;r++)if(n(g[r])&&n(v[r])){var K={p:g[r],s:v[r],b:0};_.enabled||(K.pts=L[r],q?K.ph0=K.ph1=L[r].length?M[L[r][0]]:g[r]:(K.ph0=V(T[r]),K.ph1=V(T[r+1],!0))),Z.push(K)}return 1===Z.length&&(Z[0].width1=a.tickIncrement(Z[0].p,k.size,!1,b)-Z[0].p),o(Z,e),i.isArrayOrTypedArray(e.selectedpoints)&&i.tagSelected(Z,e,W),Z}}},{"../../lib":692,"../../plots/cartesian/axes":740,"../bar/arrays_to_calcdata":832,"./average":961,"./bin_functions":963,"./bin_label_vals":964,"./norm_functions":972,"fast-isnumeric":214}],966:[function(t,e,r){"use strict";e.exports={eventDataKeys:["binNumber"]}},{}],967:[function(t,e,r){"use strict";var n=t("../../lib"),i=n.nestedProperty,a=t("./attributes"),o={x:[{aStr:"xbins.start",name:"start"},{aStr:"xbins.end",name:"end"},{aStr:"xbins.size",name:"size"},{aStr:"nbinsx",name:"nbins"}],y:[{aStr:"ybins.start",name:"start"},{aStr:"ybins.end",name:"end"},{aStr:"ybins.size",name:"size"},{aStr:"nbinsy",name:"nbins"}]};e.exports=function(t,e){var r,s,l,c,u,f,h,p=e._histogramBinOpts={},d="overlay"===e.barmode;function g(t){return n.coerce(l._input,l,a,t)}for(r=0;rA&&v.splice(A,v.length-A),y.length>A&&y.splice(A,y.length-A),c(e,"x",v,g,_,k,x),c(e,"y",y,m,w,M,b);var T=[],S=[],C=[],E="string"==typeof e.xbins.size,L="string"==typeof e.ybins.size,z=[],O=[],I=E?z:e.xbins,P=L?O:e.ybins,D=0,R=[],F=[],B=e.histnorm,N=e.histfunc,j=-1!==B.indexOf("density"),V="max"===N||"min"===N?null:0,U=a.count,q=o[B],H=!1,G=[],W=[],Y="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";Y&&"count"!==N&&(H="avg"===N,U=a[N]);var X=e.xbins,Z=_(X.start),$=_(X.end)+(Z-i.tickIncrement(Z,X.size,!1,x))/1e6;for(r=Z;r<$;r=i.tickIncrement(r,X.size,!1,x))S.push(V),z.push(r),H&&C.push(0);z.push(r);var J=S.length,K=_(e.xbins.start),Q=(r-K)/J,tt=k(K+Q/2);for(Z=w((X=e.ybins).start),$=w(X.end)+(Z-i.tickIncrement(Z,X.size,!1,b))/1e6,r=Z;r<$;r=i.tickIncrement(r,X.size,!1,b)){T.push(S.slice()),O.push(r);var et=new Array(J);for(l=0;l=0&&p=0&&d0?Number(d):p;else if("string"!=typeof d)u.size=p;else{var g=d.charAt(0),v=d.substr(1);((v=n(v)?Number(v):0)<=0||"date"!==l||"M"!==g||v!==Math.round(v))&&(u.size=p)}}e.exports=function(t,e){var r,n,i,a;function u(t){return o.coerce(i._input,i,s,t)}for(r=0;r0)u=a(t.alphahull,f);else{var p=["x","y","z"].indexOf(t.delaunayaxis);u=i(f.map(function(t){return[t[(p+1)%3],t[(p+2)%3]]}))}var d={positions:f,cells:u,lightPosition:[t.lightposition.x,t.lightposition.y,t.lightposition.z],ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,vertexNormalsEpsilon:t.lighting.vertexnormalsepsilon,faceNormalsEpsilon:t.lighting.facenormalsepsilon,opacity:t.opacity,contourEnable:t.contour.show,contourColor:l(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",d.vertexIntensity=t.intensity,d.vertexIntensityBounds=[t.cmin,t.cmax],d.colormap=s(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolor[0],d.vertexColors=h(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],d.cellColors=h(t.facecolor)):(this.color=t.color,d.meshColor=l(t.color)),this.mesh.update(d)},f.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=function(t,e){var r=t.glplot.gl,i=n({gl:r}),a=new u(t,i,e.uid);return i._trace=a,a.update(e),t.glplot.add(i),a}},{"../../lib/gl_format_color":689,"../../lib/str2rgbarray":715,"../../plots/gl3d/zip3":794,"alpha-shape":52,"convex-hull":118,"delaunay-triangulate":150,"gl-mesh3d":268}],986:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}function c(t){var e=t.map(function(t){var e=l(t);return e&&i.isArrayOrTypedArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var u=c(["x","y","z"]),f=c(["i","j","k"]);u?(f&&f.forEach(function(t){for(var e=0;eg):d=w>x,g=w;var k=l(x,b,_,w);k.pos=y,k.yc=(x+w)/2,k.i=m,k.dir=d?"increasing":"decreasing",p&&(k.tx=e.text[m]),v.push(k)}}return e._extremes[s._id]=a.findExtremes(s,n.concat(f,u),{padded:!0}),v.length&&(v[0].t={labels:{open:i(t,"open:")+" ",high:i(t,"high:")+" ",low:i(t,"low:")+" ",close:i(t,"close:")+" "}}),v}e.exports={calc:function(t,e){var r=a.getFromId(t,e.xaxis),i=a.getFromId(t,e.yaxis),o=function(t,e,r){var i=r._minDiff;if(!i){var a,o=t._fullData,s=[];for(i=1/0,a=0;a"+u.labels[x]+n.hoverLabelText(s,b):((y=i.extendFlat({},h)).y0=y.y1=_,y.yLabelVal=b,y.yLabel=u.labels[x]+n.hoverLabelText(s,b),y.name="",f.push(y),v[b]=y)}return f}function f(t,e,r,i){var a=t.cd,o=t.ya,u=a[0].trace,f=a[0].t,h=c(t,e,r,i);if(!h)return[];var p=a[h.index],d=h.index=p.i,g=p.dir;function v(t){return f.labels[t]+n.hoverLabelText(o,u[t][d])}var m=p.hi||u.hoverinfo,y=m.split("+"),x="all"===m,b=x||-1!==y.indexOf("y"),_=x||-1!==y.indexOf("text"),w=b?[v("open"),v("high"),v("low"),v("close")+" "+l[g]]:[];return _&&s(p,u,w),h.extraText=w.join("
"),h.y0=h.y1=o.c2p(p.yc,!0),[h]}e.exports={hoverPoints:function(t,e,r,n){return t.cd[0].trace.hoverlabel.split?u(t,e,r,n):f(t,e,r,n)},hoverSplit:u,hoverOnPoints:f}},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048}],992:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"ohlc",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","showLegend"],meta:{},attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("./calc").calc,plot:t("./plot"),style:t("./style"),hoverPoints:t("./hover").hoverPoints,selectPoints:t("./select")}},{"../../plots/cartesian":752,"./attributes":988,"./calc":989,"./defaults":990,"./hover":991,"./plot":994,"./select":995,"./style":996}],993:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib");e.exports=function(t,e,r,a){var o=r("x"),s=r("open"),l=r("high"),c=r("low"),u=r("close");if(r("hoverlabel.split"),n.getComponentMethod("calendars","handleTraceDefaults")(t,e,["x"],a),s&&l&&c&&u){var f=Math.min(s.length,l.length,c.length,u.length);return o&&(f=Math.min(f,i.minRowLength(o))),e._length=f,f}}},{"../../lib":692,"../../registry":823}],994:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib");e.exports=function(t,e,r,a){var o=e.xaxis,s=e.yaxis;i.makeTraceGroups(a,r,"trace ohlc").each(function(t){var r=n.select(this),a=t[0],l=a.t,c=a.trace;if(e.isRangePlot||(a.node3=r),!0!==c.visible||l.empty)r.remove();else{var u=l.tickLen,f=r.selectAll("path").data(i.identity);f.enter().append("path"),f.exit().remove(),f.attr("d",function(t){var e=o.c2p(t.pos,!0),r=o.c2p(t.pos-u,!0),n=o.c2p(t.pos+u,!0);return"M"+r+","+s.c2p(t.o,!0)+"H"+e+"M"+e+","+s.c2p(t.h,!0)+"V"+s.c2p(t.l,!0)+"M"+n+","+s.c2p(t.c,!0)+"H"+e})}})}},{"../../lib":692,d3:148}],995:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,i=t.xaxis,a=t.yaxis,o=[],s=n[0].t.bPos||0;if(!1===e)for(r=0;r=t.length)return!1;if(void 0!==e[t[r]])return!1;e[t[r]]=!0}return!0}(t.map(function(t){return t.displayindex})))for(e=0;e0;c&&(o="array");var u=r("categoryorder",o);"array"===u?(r("categoryarray"),r("ticktext")):(delete t.categoryarray,delete t.ticktext),c||"array"!==u||(e.categoryorder="trace")}}e.exports=function(t,e,r,f){function h(r,i){return n.coerce(t,e,l,r,i)}var p=s(t,e,{name:"dimensions",handleItemDefaults:u}),d=function(t,e,r,o,s){s("line.shape");var l=s("line.color",o.colorway[0]);if(i(t,"line")&&n.isArrayOrTypedArray(l)){if(l.length)return s("line.colorscale"),a(t,e,o,s,{prefix:"line.",cLetter:"c"}),l.length;e.line.color=r}return 1/0}(t,e,r,f,h);o(e,f,h),Array.isArray(p)&&p.length||(e.visible=!1),c(e,p,"values",d),h("hoveron"),h("arrangement"),h("bundlecolors"),h("sortpaths"),h("counts");var g={family:f.font.family,size:Math.round(f.font.size),color:f.font.color};n.coerceFont(h,"labelfont",g);var v={family:f.font.family,size:Math.round(f.font.size/1.2),color:f.font.color};n.coerceFont(h,"tickfont",v)}},{"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/domain":766,"../parcoords/merge_length":1012,"./attributes":997}],1001:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.colorbar={container:"line",min:"cmin",max:"cmax"},n.moduleType="trace",n.name="parcats",n.basePlotModule=t("./base_plot"),n.categories=["noOpacity"],n.meta={},e.exports=n},{"./attributes":997,"./base_plot":998,"./calc":999,"./defaults":1e3,"./plot":1003}],1002:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plot_api/plot_api"),a=t("../../components/fx"),o=t("../../lib"),s=t("../../components/drawing"),l=t("tinycolor2"),c=t("../../lib/svg_text_utils");function u(t,e,r,i){var a=t.map(function(t,e,r){var n,i=r[0],a=e.margin||{l:80,r:80,t:100,b:80},o=i.trace,s=o.domain,l=e.width,c=e.height,u=Math.floor(l*(s.x[1]-s.x[0])),f=Math.floor(c*(s.y[1]-s.y[0])),h=s.x[0]*l+a.l,p=e.height-s.y[1]*e.height+a.t,d=o.line.shape;n="all"===o.hoverinfo?["count","probability"]:o.hoverinfo.split("+");var g={key:o.uid,model:i,x:h,y:p,width:u,height:f,hoveron:o.hoveron,hoverinfoItems:n,arrangement:o.arrangement,bundlecolors:o.bundlecolors,sortpaths:o.sortpaths,labelfont:o.labelfont,categorylabelfont:o.tickfont,pathShape:d,dragDimension:null,margin:a,paths:[],dimensions:[],graphDiv:t,traceSelection:null,pathSelection:null,dimensionSelection:null};i.dimensions&&(R(g),D(g));return g}.bind(0,e,r)),l=i.selectAll("g.parcatslayer").data([null]);l.enter().append("g").attr("class","parcatslayer").style("pointer-events","all");var u=l.selectAll("g.trace.parcats").data(a,f),v=u.enter().append("g").attr("class","trace parcats");u.attr("transform",function(t){return"translate("+t.x+", "+t.y+")"}),v.append("g").attr("class","paths");var x=u.select("g.paths").selectAll("path.path").data(function(t){return t.paths},f);x.attr("fill",function(t){return t.model.color});var w=x.enter().append("path").attr("class","path").attr("stroke-opacity",0).attr("fill",function(t){return t.model.color}).attr("fill-opacity",0);y(w),x.attr("d",function(t){return t.svgD}),w.empty()||x.sort(p),x.exit().remove(),x.on("mouseover",d).on("mouseout",g).on("click",m),v.append("g").attr("class","dimensions");var k=u.select("g.dimensions").selectAll("g.dimension").data(function(t){return t.dimensions},f);k.enter().append("g").attr("class","dimension"),k.attr("transform",function(t){return"translate("+t.x+", 0)"}),k.exit().remove();var M=k.selectAll("g.category").data(function(t){return t.categories},f),A=M.enter().append("g").attr("class","category");M.attr("transform",function(t){return"translate(0, "+t.y+")"}),A.append("rect").attr("class","catrect").attr("pointer-events","none"),M.select("rect.catrect").attr("fill","none").attr("width",function(t){return t.width}).attr("height",function(t){return t.height}),b(A);var z=M.selectAll("rect.bandrect").data(function(t){return t.bands},f);z.each(function(){o.raiseToTop(this)}),z.attr("fill",function(t){return t.color});var O=z.enter().append("rect").attr("class","bandrect").attr("stroke-opacity",0).attr("fill",function(t){return t.color}).attr("fill-opacity",0);z.attr("fill",function(t){return t.color}).attr("width",function(t){return t.width}).attr("height",function(t){return t.height}).attr("y",function(t){return t.y}).attr("cursor",function(t){return"fixed"===t.parcatsViewModel.arrangement?"default":"perpendicular"===t.parcatsViewModel.arrangement?"ns-resize":"move"}),_(O),z.exit().remove(),A.append("text").attr("class","catlabel").attr("pointer-events","none");var I=e._fullLayout.paper_bgcolor;M.select("text.catlabel").attr("text-anchor",function(t){return h(t)?"start":"end"}).attr("alignment-baseline","middle").style("text-shadow",I+" -1px 1px 2px, "+I+" 1px 1px 2px, "+I+" 1px -1px 2px, "+I+" -1px -1px 2px").style("fill","rgb(0, 0, 0)").attr("x",function(t){return h(t)?t.width+5:-5}).attr("y",function(t){return t.height/2}).text(function(t){return t.model.categoryLabel}).each(function(t){s.font(n.select(this),t.parcatsViewModel.categorylabelfont),c.convertToTspans(n.select(this),e)}),A.append("text").attr("class","dimlabel"),M.select("text.dimlabel").attr("text-anchor","middle").attr("alignment-baseline","baseline").attr("cursor",function(t){return"fixed"===t.parcatsViewModel.arrangement?"default":"ew-resize"}).attr("x",function(t){return t.width/2}).attr("y",-5).text(function(t,e){return 0===e?t.parcatsViewModel.model.dimensions[t.model.dimensionInd].dimensionLabel:null}).each(function(t){s.font(n.select(this),t.parcatsViewModel.labelfont)}),M.selectAll("rect.bandrect").on("mouseover",T).on("mouseout",S),M.exit().remove(),k.call(n.behavior.drag().origin(function(t){return{x:t.x,y:0}}).on("dragstart",C).on("drag",E).on("dragend",L)),u.each(function(t){t.traceSelection=n.select(this),t.pathSelection=n.select(this).selectAll("g.paths").selectAll("path.path"),t.dimensionSelection=n.select(this).selectAll("g.dimensions").selectAll("g.dimension")}),u.exit().remove()}function f(t){return t.key}function h(t){var e=t.parcatsViewModel.dimensions.length,r=t.parcatsViewModel.dimensions[e-1].model.dimensionInd;return t.model.dimensionInd===r}function p(t,e){return t.model.rawColor>e.model.rawColor?1:t.model.rawColor"),k=n.mouse(u)[0];a.loneHover({x:m-h.left+p.left,y:y-h.top+p.top,text:w,color:t.model.color,borderColor:"black",fontFamily:'Monaco, "Courier New", monospace',fontSize:10,fontColor:b,idealAlign:k1&&c.displayInd===l.dimensions.length-1?(r=o.left,i="left"):(r=o.left+o.width,i="right");var f=[];-1!==s.parcatsViewModel.hoverinfoItems.indexOf("count")&&f.push(["Count:",s.model.count].join(" ")),-1!==s.parcatsViewModel.hoverinfoItems.indexOf("probability")&&f.push(["P("+s.model.categoryLabel+"):",(s.model.count/s.parcatsViewModel.model.count).toFixed(3)].join(" "));var h=f.join("
");return{x:r-t.left,y:u-t.top,text:h,color:"lightgray",borderColor:"black",fontFamily:'Monaco, "Courier New", monospace',fontSize:12,fontColor:"black",idealAlign:i}}function T(t){if(!t.parcatsViewModel.dragDimension&&-1===t.parcatsViewModel.hoverinfoItems.indexOf("skip")){if(n.mouse(this)[1]<-1)return;var e,r=t.parcatsViewModel.graphDiv,i=r._fullLayout,s=i._paperdiv.node().getBoundingClientRect(),c=t.parcatsViewModel.hoveron;if("color"===c?(!function(t){var e=n.select(t).datum(),r=w(e);x(r),r.each(function(){o.raiseToTop(this)}),n.select(t.parentNode).selectAll("rect.bandrect").filter(function(t){return t.color===e.color}).each(function(){o.raiseToTop(this),n.select(this).attr("stroke","black").attr("stroke-width",1.5)})}(this),M(this,"plotly_hover",n.event)):(!function(t){n.select(t.parentNode).selectAll("rect.bandrect").each(function(t){var e=w(t);x(e),e.each(function(){o.raiseToTop(this)})}),n.select(t.parentNode).select("rect.catrect").attr("stroke","black").attr("stroke-width",2.5)}(this),k(this,"plotly_hover",n.event)),-1===t.parcatsViewModel.hoverinfoItems.indexOf("none"))"category"===c?e=A(s,this):"color"===c?e=function(t,e){var r,i,a=e.getBoundingClientRect(),o=n.select(e).datum(),s=o.categoryViewModel,c=s.parcatsViewModel,u=c.model.dimensions[s.model.dimensionInd],f=a.y+a.height/2;c.dimensions.length>1&&u.displayInd===c.dimensions.length-1?(r=a.left,i="left"):(r=a.left+a.width,i="right");var h=s.model.categoryLabel,p=o.parcatsViewModel.model.count,d=0;o.categoryViewModel.bands.forEach(function(t){t.color===o.color&&(d+=t.count)});var g=s.model.count,v=0;c.pathSelection.each(function(t){t.model.color===o.color&&(v+=t.model.count)});var m=[];if(-1!==s.parcatsViewModel.hoverinfoItems.indexOf("count")&&m.push(["Count:",d].join(" ")),-1!==s.parcatsViewModel.hoverinfoItems.indexOf("probability")){var y="P(color \u2229 "+h+"): "+(d/p).toFixed(3);m.push(y);var x="P("+h+" | color): "+(d/v).toFixed(3);m.push(x);var b="P(color | "+h+"): "+(d/g).toFixed(3);m.push(b)}var _=m.join("
"),w=l.mostReadable(o.color,["black","white"]);return{x:r-t.left,y:f-t.top,text:_,color:o.color,borderColor:"black",fontFamily:'Monaco, "Courier New", monospace',fontColor:w,fontSize:10,idealAlign:i}}(s,this):"dimension"===c&&(e=function(t,e){var r=[];return n.select(e.parentNode.parentNode).selectAll("g.category").select("rect.catrect").each(function(){r.push(A(t,this))}),r}(s,this)),e&&a.multiHovers(e,{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:r})}}function S(t){var e=t.parcatsViewModel;if(!e.dragDimension&&(y(e.pathSelection),b(e.dimensionSelection.selectAll("g.category")),_(e.dimensionSelection.selectAll("g.category").selectAll("rect.bandrect")),a.loneUnhover(e.graphDiv._fullLayout._hoverlayer.node()),e.pathSelection.sort(p),-1===e.hoverinfoItems.indexOf("skip"))){"color"===t.parcatsViewModel.hoveron?M(this,"plotly_unhover",n.event):k(this,"plotly_unhover",n.event)}}function C(t){"fixed"!==t.parcatsViewModel.arrangement&&(t.dragDimensionDisplayInd=t.model.displayInd,t.initialDragDimensionDisplayInds=t.parcatsViewModel.model.dimensions.map(function(t){return t.displayInd}),t.dragHasMoved=!1,t.dragCategoryDisplayInd=null,n.select(this).selectAll("g.category").select("rect.catrect").each(function(e){var r=n.mouse(this)[0],i=n.mouse(this)[1];-2<=r&&r<=e.width+2&&-2<=i&&i<=e.height+2&&(t.dragCategoryDisplayInd=e.model.displayInd,t.initialDragCategoryDisplayInds=t.model.categories.map(function(t){return t.displayInd}),e.model.dragY=e.y,o.raiseToTop(this.parentNode),n.select(this.parentNode).selectAll("rect.bandrect").each(function(e){e.yf.y+f.height/2&&(o.model.displayInd=f.model.displayInd,f.model.displayInd=l),t.dragCategoryDisplayInd=o.model.displayInd}if(null===t.dragCategoryDisplayInd||"freeform"===t.parcatsViewModel.arrangement){a.model.dragX=n.event.x;var h=t.parcatsViewModel.dimensions[r],p=t.parcatsViewModel.dimensions[i];void 0!==h&&a.model.dragXp.x&&(a.model.displayInd=p.model.displayInd,p.model.displayInd=t.dragDimensionDisplayInd),t.dragDimensionDisplayInd=a.model.displayInd}R(t.parcatsViewModel),D(t.parcatsViewModel),I(t.parcatsViewModel),O(t.parcatsViewModel)}}function L(t){if("fixed"!==t.parcatsViewModel.arrangement&&null!==t.dragDimensionDisplayInd){n.select(this).selectAll("text").attr("font-weight","normal");var e={},r=z(t.parcatsViewModel),a=t.parcatsViewModel.model.dimensions.map(function(t){return t.displayInd}),o=t.initialDragDimensionDisplayInds.some(function(t,e){return t!==a[e]});o&&a.forEach(function(r,n){var i=t.parcatsViewModel.model.dimensions[n].containerInd;e["dimensions["+i+"].displayindex"]=r});var s=!1;if(null!==t.dragCategoryDisplayInd){var l=t.model.categories.map(function(t){return t.displayInd});if(s=t.initialDragCategoryDisplayInds.some(function(t,e){return t!==l[e]})){var c=t.model.categories.slice().sort(function(t,e){return t.displayInd-e.displayInd}),u=c.map(function(t){return t.categoryValue}),f=c.map(function(t){return t.categoryLabel});e["dimensions["+t.model.containerInd+"].categoryarray"]=[u],e["dimensions["+t.model.containerInd+"].ticktext"]=[f],e["dimensions["+t.model.containerInd+"].categoryorder"]="array"}}if(-1===t.parcatsViewModel.hoverinfoItems.indexOf("skip")&&!t.dragHasMoved&&t.potentialClickBand&&("color"===t.parcatsViewModel.hoveron?M(t.potentialClickBand,"plotly_click",n.event.sourceEvent):k(t.potentialClickBand,"plotly_click",n.event.sourceEvent)),t.model.dragX=null,null!==t.dragCategoryDisplayInd)t.parcatsViewModel.dimensions[t.dragDimensionDisplayInd].categories[t.dragCategoryDisplayInd].model.dragY=null,t.dragCategoryDisplayInd=null;t.dragDimensionDisplayInd=null,t.parcatsViewModel.dragDimension=null,t.dragHasMoved=null,t.potentialClickBand=null,R(t.parcatsViewModel),D(t.parcatsViewModel),n.transition().duration(300).ease("cubic-in-out").each(function(){I(t.parcatsViewModel,!0),O(t.parcatsViewModel,!0)}).each("end",function(){(o||s)&&i.restyle(t.parcatsViewModel.graphDiv,e,[r])})}}function z(t){for(var e,r=t.graphDiv._fullData,n=0;n=0;s--)u+="C"+c[s]+","+(e[s+1]+i)+" "+l[s]+","+(e[s]+i)+" "+(t[s]+r[s])+","+(e[s]+i),u+="l-"+r[s]+",0 ";return u+="Z"}function D(t){var e=t.dimensions,r=t.model,n=e.map(function(t){return t.categories.map(function(t){return t.y})}),i=t.model.dimensions.map(function(t){return t.categories.map(function(t){return t.displayInd})}),a=t.model.dimensions.map(function(t){return t.displayInd}),o=t.dimensions.map(function(t){return t.model.dimensionInd}),s=e.map(function(t){return t.x}),l=e.map(function(t){return t.width}),c=[];for(var u in r.paths)r.paths.hasOwnProperty(u)&&c.push(r.paths[u]);function f(t){var e=t.categoryInds.map(function(t,e){return i[e][t]});return o.map(function(t){return e[t]})}c.sort(function(e,r){var n=f(e),i=f(r);return"backward"===t.sortpaths&&(n.reverse(),i.reverse()),n.push(e.valueInds[0]),i.push(r.valueInds[0]),t.bundlecolors&&(n.unshift(e.rawColor),i.unshift(r.rawColor)),ni?1:0});for(var h=new Array(c.length),p=e[0].model.count,d=e[0].categories.map(function(t){return t.height}).reduce(function(t,e){return t+e}),g=0;g0?d*(m.count/p):0;for(var y,x=new Array(n.length),b=0;b1?(t.width-80-16)/(n-1):0)*i;var a,o,s,l,c,u=[],f=t.model.maxCats,h=e.categories.length,p=e.count,d=t.height-8*(f-1),g=8*(f-h)/2,v=e.categories.map(function(t){return{displayInd:t.displayInd,categoryInd:t.categoryInd}});for(v.sort(function(t,e){return t.displayInd-e.displayInd}),c=0;c0?o.count/p*d:0,s={key:o.valueInds[0],model:o,width:16,height:a,y:null!==o.dragY?o.dragY:g,bands:[],parcatsViewModel:t},g=g+a+8,u.push(s);return{key:e.dimensionInd,x:null!==e.dragX?e.dragX:r,y:0,width:16,model:e,categories:u,parcatsViewModel:t,dragCategoryDisplayInd:null,dragDimensionDisplayInd:null,initialDragDimensionDisplayInds:null,initialDragCategoryDisplayInds:null,dragHasMoved:null,potentialClickBand:null}}e.exports=function(t,e,r,n){u(r,t,n,e)}},{"../../components/drawing":590,"../../components/fx":608,"../../lib":692,"../../lib/svg_text_utils":716,"../../plot_api/plot_api":727,d3:148,tinycolor2:513}],1003:[function(t,e,r){"use strict";var n=t("./parcats");e.exports=function(t,e,r,i){var a=t._fullLayout,o=a._paper,s=a._size;n(t,o,e,{width:s.w,height:s.h,margin:{t:s.t,r:s.r,b:s.b,l:s.l}},r,i)}},{"./parcats":1002}],1004:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../components/colorbar/attributes"),a=t("../../plots/cartesian/layout_attributes"),o=t("../../plots/font_attributes"),s=t("../../plots/domain").attributes,l=t("../../lib/extend").extendFlat,c=t("../../plot_api/plot_template").templatedArray;e.exports={domain:s({name:"parcoords",trace:!0,editType:"calc"}),hoverlabel:void 0,labelfont:o({editType:"calc"}),tickfont:o({editType:"calc"}),rangefont:o({editType:"calc"}),dimensions:c("dimension",{label:{valType:"string",editType:"calc"},tickvals:l({},a.tickvals,{editType:"calc"}),ticktext:l({},a.ticktext,{editType:"calc"}),tickformat:{valType:"string",dflt:"3s",editType:"calc"},visible:{valType:"boolean",dflt:!0,editType:"calc"},range:{valType:"info_array",items:[{valType:"number",editType:"calc"},{valType:"number",editType:"calc"}],editType:"calc"},constraintrange:{valType:"info_array",freeLength:!0,dimensions:"1-2",items:[{valType:"number",editType:"calc"},{valType:"number",editType:"calc"}],editType:"calc"},multiselect:{valType:"boolean",dflt:!0,editType:"calc"},values:{valType:"data_array",editType:"calc"},editType:"calc"}),line:l(n("line",{colorscaleDflt:"Viridis",autoColorDflt:!1,editTypeOverride:"calc"}),{colorbar:i,editType:"calc"})}},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/plot_template":730,"../../plots/cartesian/layout_attributes":753,"../../plots/domain":766,"../../plots/font_attributes":767}],1005:[function(t,e,r){"use strict";var n=t("./constants"),i=t("d3"),a=t("../../lib/gup").keyFun,o=t("../../lib/gup").repeat,s=t("../../lib").sorterAsc,l=n.bar.snapRatio;function c(t,e){return t*(1-l)+e*l}var u=n.bar.snapClose;function f(t,e){return t*(1-u)+e*u}function h(t,e,r){if(d(e,r))return e;for(var n=t[0],i=n,a=1;a=0;a--){var o=t[a];if(e>f(n,o))return c(n,i);if(e>o||a===t.length-1)return c(o,n);i=n,n=o}}function d(t,e){for(var r=0;r=e[r][0]&&t<=e[r][1])return!0;return!1}function g(t){t.attr("x",-n.bar.captureWidth/2).attr("width",n.bar.captureWidth)}function v(t){t.attr("visibility","visible").style("visibility","visible").attr("fill","yellow").attr("opacity",0)}function m(t){if(!t.brush.filterSpecified)return"0,"+t.height;for(var e,r,n,i=y(t.brush.filter.getConsolidated(),t.height),a=[0],o=i.length?i[0][0]:null,s=0;se){h=r;break}}if(a=u,isNaN(a)&&(a=isNaN(f)||isNaN(h)?isNaN(f)?h:f:e-c[f][1]t[1]+r||e=.9*t[1]+.1*t[0]?"n":e<=.9*t[0]+.1*t[1]?"s":"ns"}(d,e);g&&(o.interval=l[a],o.intervalPix=d,o.region=g)}}if(t.ordinal&&!o.region){var v=t.unitTickvals,m=t.unitToPaddedPx.invert(e);for(r=0;r=x[0]&&m<=x[1]){o.clickableOrdinalRange=x;break}}}return o}function k(t){t.on("mousemove",function(t){if(i.event.preventDefault(),!t.parent.inBrushDrag){var e=w(t,t.height-i.mouse(this)[1]-2*n.verticalPadding),r="crosshair";e.clickableOrdinalRange?r="pointer":e.region&&(r=e.region+"-resize"),i.select(document.body).style("cursor",r)}}).on("mouseleave",function(t){t.parent.inBrushDrag||x()}).call(i.behavior.drag().on("dragstart",function(t){i.event.sourceEvent.stopPropagation();var e=t.height-i.mouse(this)[1]-2*n.verticalPadding,r=t.unitToPaddedPx.invert(e),a=t.brush,o=w(t,e),s=o.interval,l=a.svgBrush;if(l.wasDragged=!1,l.grabbingBar="ns"===o.region,l.grabbingBar){var c=s.map(t.unitToPaddedPx);l.grabPoint=e-c[0]-n.verticalPadding,l.barLength=c[1]-c[0]}l.clickableOrdinalRange=o.clickableOrdinalRange,l.stayingIntervals=t.multiselect&&a.filterSpecified?a.filter.getConsolidated():[],s&&(l.stayingIntervals=l.stayingIntervals.filter(function(t){return t[0]!==s[0]&&t[1]!==s[1]})),l.startExtent=o.region?s["s"===o.region?1:0]:r,t.parent.inBrushDrag=!0,l.brushStartCallback()}).on("drag",function(t){i.event.sourceEvent.stopPropagation();var e=t.height-i.mouse(this)[1]-2*n.verticalPadding,r=t.brush.svgBrush;r.wasDragged=!0,r.grabbingBar?r.newExtent=[e-r.grabPoint,e+r.barLength-r.grabPoint].map(t.unitToPaddedPx.invert):r.newExtent=[r.startExtent,t.unitToPaddedPx.invert(e)].sort(s);var a=Math.max(0,-r.newExtent[0]),o=Math.max(0,r.newExtent[1]-1);r.newExtent[0]+=a,r.newExtent[1]-=o,r.grabbingBar&&(r.newExtent[1]+=a,r.newExtent[0]-=o),t.brush.filterSpecified=!0,r.extent=r.stayingIntervals.concat([r.newExtent]),r.brushCallback(t),_(this.parentNode)}).on("dragend",function(t){i.event.sourceEvent.stopPropagation();var e=t.brush,r=e.filter,n=e.svgBrush,a=n.grabbingBar;if(n.grabbingBar=!1,n.grabLocation=void 0,t.parent.inBrushDrag=!1,x(),!n.wasDragged)return n.wasDragged=void 0,n.clickableOrdinalRange?e.filterSpecified&&t.multiselect?n.extent.push(n.clickableOrdinalRange):(n.extent=[n.clickableOrdinalRange],e.filterSpecified=!0):a?(n.extent=n.stayingIntervals,0===n.extent.length&&A(e)):A(e),n.brushCallback(t),_(this.parentNode),void n.brushEndCallback(e.filterSpecified?r.getConsolidated():[]);var o=function(){r.set(r.getConsolidated())};if(t.ordinal){var s=t.unitTickvals;s[s.length-1]n.newExtent[0];n.extent=n.stayingIntervals.concat(l?[n.newExtent]:[]),n.extent.length||A(e),n.brushCallback(t),l?_(this.parentNode,o):(o(),_(this.parentNode))}else o();n.brushEndCallback(e.filterSpecified?r.getConsolidated():[])}))}function M(t,e){return t[0]-e[0]}function A(t){t.filterSpecified=!1,t.svgBrush.extent=[[0,1]]}function T(t){for(var e,r=t.slice(),n=[],i=r.shift();i;){for(e=i.slice();(i=r.shift())&&i[0]<=e[1];)e[1]=Math.max(e[1],i[1]);n.push(e)}return n}e.exports={makeBrush:function(t,e,r,n,i,a){var o,l=function(){var t,e,r=[];return{set:function(n){r=n.map(function(t){return t.slice().sort(s)}).sort(M),t=T(r),e=r.reduce(function(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1])]},[1/0,-1/0])},get:function(){return r.slice()},getConsolidated:function(){return t},getBounds:function(){return e}}}();return l.set(r),{filter:l,filterSpecified:e,svgBrush:{extent:[],brushStartCallback:n,brushCallback:(o=i,function(t){var e=t.brush,r=function(t){return t.svgBrush.extent.map(function(t){return t.slice()})}(e).slice();e.filter.set(r),o()}),brushEndCallback:a}}},ensureAxisBrush:function(t){var e=t.selectAll("."+n.cn.axisBrush).data(o,a);e.enter().append("g").classed(n.cn.axisBrush,!0),function(t){var e=t.selectAll(".background").data(o);e.enter().append("rect").classed("background",!0).call(g).call(v).style("pointer-events","auto").attr("transform","translate(0 "+n.verticalPadding+")"),e.call(k).attr("height",function(t){return t.height-n.verticalPadding});var r=t.selectAll(".highlight-shadow").data(o);r.enter().append("line").classed("highlight-shadow",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width+n.bar.strokeWidth).attr("stroke",n.bar.strokeColor).attr("opacity",n.bar.strokeOpacity).attr("stroke-linecap","butt"),r.attr("y1",function(t){return t.height}).call(b);var i=t.selectAll(".highlight").data(o);i.enter().append("line").classed("highlight",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width-n.bar.strokeWidth).attr("stroke",n.bar.fillColor).attr("opacity",n.bar.fillOpacity).attr("stroke-linecap","butt"),i.attr("y1",function(t){return t.height}).call(b)}(e)},cleanRanges:function(t,e){if(Array.isArray(t[0])?(t=t.map(function(t){return t.sort(s)}),t=e.multiselect?T(t.sort(M)):[t[0]]):t=[t.sort(s)],e.tickvals){var r=e.tickvals.slice().sort(s);if(!(t=t.map(function(t){var e=[h(r,t[0],[]),p(r,t[1],[])];if(e[1]>e[0])return e}).filter(function(t){return t})).length)return}return t.length>1?t:t[0]}}},{"../../lib":692,"../../lib/gup":690,"./constants":1008,d3:148}],1006:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plots/get_data").getModuleCalcData,a=t("./plot"),o=t("../../constants/xmlns_namespaces");r.name="parcoords",r.plot=function(t){var e=i(t.calcdata,"parcoords")[0];e.length&&a(t,e)},r.clean=function(t,e,r,n){var i=n._has&&n._has("parcoords"),a=e._has&&e._has("parcoords");i&&!a&&(n._paperdiv.selectAll(".parcoords").remove(),n._glimages.selectAll("*").remove())},r.toSVG=function(t){var e=t._fullLayout._glimages,r=n.select(t).selectAll(".svg-container");r.filter(function(t,e){return e===r.size()-1}).selectAll(".gl-canvas-context, .gl-canvas-focus").each(function(){var t=this.toDataURL("image/png");e.append("svg:image").attr({xmlns:o.svg,"xlink:href":t,preserveAspectRatio:"none",x:0,y:0,width:this.width,height:this.height})}),window.setTimeout(function(){n.selectAll("#filterBarPattern").attr("id","filterBarPattern")},60)}},{"../../constants/xmlns_namespaces":670,"../../plots/get_data":777,"./plot":1014,d3:148}],1007:[function(t,e,r){"use strict";var n=t("../../components/colorscale/helpers").hasColorscale,i=t("../../components/colorscale/calc"),a=t("../../lib"),o=t("../../lib/gup").wrap;e.exports=function(t,e){var r=!!e.line.colorscale&&a.isArrayOrTypedArray(e.line.color),s=r?e.line.color:function(t){for(var e=new Array(t),r=0;ru&&(n.log("parcoords traces support up to "+u+" dimensions at the moment"),d.splice(u));var g=s(t,e,{name:"dimensions",handleItemDefaults:h}),v=function(t,e,r,o,s){var l=s("line.color",r);if(i(t,"line")&&n.isArrayOrTypedArray(l)){if(l.length)return s("line.colorscale"),a(t,e,o,s,{prefix:"line.",cLetter:"c"}),l.length;e.line.color=r}return 1/0}(t,e,r,c,p);o(e,c,p),Array.isArray(g)&&g.length||(e.visible=!1),f(e,g,"values",v);var m={family:c.font.family,size:Math.round(c.font.size/1.2),color:c.font.color};n.coerceFont(p,"labelfont",m),n.coerceFont(p,"tickfont",m),n.coerceFont(p,"rangefont",m)}},{"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"../../lib":692,"../../plots/array_container_defaults":736,"../../plots/domain":766,"./attributes":1004,"./axisbrush":1005,"./constants":1008,"./merge_length":1012}],1010:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.colorbar={container:"line",min:"cmin",max:"cmax"},n.moduleType="trace",n.name="parcoords",n.basePlotModule=t("./base_plot"),n.categories=["gl","regl","noOpacity"],n.meta={},e.exports=n},{"./attributes":1004,"./base_plot":1006,"./calc":1007,"./defaults":1009,"./plot":1014}],1011:[function(t,e,r){"use strict";var n=t("glslify"),i=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\nuniform sampler2D mask;\nuniform float maskHeight;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec4 unit_1 = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit_1, unit_1);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nconst int bitsPerByte = 8;\n\nint mod2(int a) {\n return a - 2 * (a / 2);\n}\n\nint mod8(int a) {\n return a - 8 * (a / 8);\n}\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit_0 = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nbool withinBoundingBox(\n mat4 d[4],\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD\n ) {\n\n return mshow(d[0], loA, hiA) &&\n mshow(d[1], loB, hiB) &&\n mshow(d[2], loC, hiC) &&\n mshow(d[3], loD, hiD);\n}\n\nbool withinRasterMask(mat4 d[4], sampler2D mask, float height) {\n bool result = true;\n int bitInByteStepper;\n float valY, valueY, scaleX;\n int hit, bitmask, valX;\n for(int i = 0; i < 4; i++) {\n for(int j = 0; j < 4; j++) {\n for(int k = 0; k < 4; k++) {\n bitInByteStepper = mod8(j * 4 + k);\n valX = i * 2 + j / 2;\n valY = d[i][j][k];\n valueY = valY * (height - 1.0) + 0.5;\n scaleX = (float(valX) + 0.5) / 8.0;\n hit = int(texture2D(mask, vec2(scaleX, (valueY + 0.5) / height))[3] * 255.0) / int(pow(2.0, float(bitInByteStepper)));\n result = result && mod2(hit) == 1;\n }\n }\n }\n return result;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D,\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD,\n sampler2D mask, float maskHeight\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n float show = float(\n withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD)\n && withinRasterMask(dims, mask, maskHeight)\n );\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD,\n mask, maskHeight\n );\n\n float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);\n fragColor = texture2D(palette, vec2((clampedColorIndex * 255.0 + 0.5) / 256.0, 0.5));\n}\n"]),a=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec2 xyProjection = vec2(1, 1);\n\nvec4 unit = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit, unit);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depth,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D\n );\n\n float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);\n fragColor = texture2D(palette, vec2((clampedColorIndex * 255.0 + 0.5) / 256.0, 0.5));\n}\n"]),o=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D mask;\nuniform float maskHeight;\n\nuniform vec2 colorClamp;\n\nvarying vec4 fragColor;\n\nvec4 unit_1 = vec4(1, 1, 1, 1);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit_1, unit_1);\n}\n\nfloat axisY(\n float x,\n mat4 d[4],\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D\n ) {\n\n float y1 = val(d[0], dim1A) + val(d[1], dim1B) + val(d[2], dim1C) + val(d[3], dim1D);\n float y2 = val(d[0], dim2A) + val(d[1], dim2B) + val(d[2], dim2C) + val(d[3], dim2D);\n return y1 * (1.0 - x) + y2 * x;\n}\n\nconst int bitsPerByte = 8;\n\nint mod2(int a) {\n return a - 2 * (a / 2);\n}\n\nint mod8(int a) {\n return a - 8 * (a / 8);\n}\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit_0 = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nbool withinBoundingBox(\n mat4 d[4],\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD\n ) {\n\n return mshow(d[0], loA, hiA) &&\n mshow(d[1], loB, hiB) &&\n mshow(d[2], loC, hiC) &&\n mshow(d[3], loD, hiD);\n}\n\nbool withinRasterMask(mat4 d[4], sampler2D mask, float height) {\n bool result = true;\n int bitInByteStepper;\n float valY, valueY, scaleX;\n int hit, bitmask, valX;\n for(int i = 0; i < 4; i++) {\n for(int j = 0; j < 4; j++) {\n for(int k = 0; k < 4; k++) {\n bitInByteStepper = mod8(j * 4 + k);\n valX = i * 2 + j / 2;\n valY = d[i][j][k];\n valueY = valY * (height - 1.0) + 0.5;\n scaleX = (float(valX) + 0.5) / 8.0;\n hit = int(texture2D(mask, vec2(scaleX, (valueY + 0.5) / height))[3] * 255.0) / int(pow(2.0, float(bitInByteStepper)));\n result = result && mod2(hit) == 1;\n }\n }\n }\n return result;\n}\n\nvec4 position(\n float depth,\n vec2 resolution, vec2 viewBoxPosition, vec2 viewBoxSize,\n mat4 dims[4],\n float signum,\n mat4 dim1A, mat4 dim2A, mat4 dim1B, mat4 dim2B, mat4 dim1C, mat4 dim2C, mat4 dim1D, mat4 dim2D,\n mat4 loA, mat4 hiA, mat4 loB, mat4 hiB, mat4 loC, mat4 hiC, mat4 loD, mat4 hiD,\n sampler2D mask, float maskHeight\n ) {\n\n float x = 0.5 * signum + 0.5;\n float y = axisY(x, dims, dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D);\n\n float show = float(\n withinBoundingBox(dims, loA, hiA, loB, hiB, loC, hiC, loD, hiD)\n && withinRasterMask(dims, mask, maskHeight)\n );\n\n vec2 viewBoxXY = viewBoxPosition + viewBoxSize * vec2(x, y);\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n return vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n}\n\nvoid main() {\n\n float prominence = abs(pf[3]);\n\n mat4 p[4];\n p[0] = mat4(p0, p1, p2, p3);\n p[1] = mat4(p4, p5, p6, p7);\n p[2] = mat4(p8, p9, pa, pb);\n p[3] = mat4(pc, pd, pe, abs(pf));\n\n gl_Position = position(\n 1.0 - prominence,\n resolution, viewBoxPosition, viewBoxSize,\n p,\n sign(pf[3]),\n dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD,\n mask, maskHeight\n );\n\n fragColor = vec4(pf.rgb, 1.0);\n}\n"]),s=n(["precision lowp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}\n"]),l=t("../../lib"),c=1e-6,u=1e-7,f=2048,h=64,p=2,d=4,g=8,v=h/g,m=[119,119,119],y=new Uint8Array(4),x=new Uint8Array(4),b={shape:[256,1],format:"rgba",type:"uint8",mag:"nearest",min:"nearest"};function _(t,e,r,n,i){var a=t._gl;a.enable(a.SCISSOR_TEST),a.scissor(e,r,n,i),t.clear({color:[0,0,0,0],depth:1})}function w(t,e,r,n,i,a){var o=a.key;r.drawCompleted||(!function(t){t.read({x:0,y:0,width:1,height:1,data:y})}(t),r.drawCompleted=!0),function s(l){var c;c=Math.min(n,i-l*n),a.offset=p*l*n,a.count=p*c,0===l&&(window.cancelAnimationFrame(r.currentRafs[o]),delete r.currentRafs[o],_(t,a.scissorX,a.scissorY,a.scissorWidth,a.viewBoxSize[1])),r.clearOnly||(e(a),l*n+c>>8*e)%256/255}function M(t,e,r){var n,i,a,o=[];for(i=0;i=h-4?k(o,h-2-s):.5);return a}(d,p,i);!function(t,e,r){for(var n=0;n<16;n++)t["p"+n.toString(16)](M(e,r,n))}(E,d,o),L=S.texture(l.extendFlat({data:function(t,e,r){for(var n=[],i=0;i<256;i++){var a=t(i/255);n.push((e?m:a).concat(r))}return n}(r.unitToColor,A,Math.round(255*(A?a:1)))},b))}var I=[0,1];var P=[];function D(t,e,n,i,a,o,s,c,u,f,h){var p,d,g,v,m=[t,e],y=[0,1].map(function(){return[0,1,2,3].map(function(){return new Float32Array(16)})});for(p=0;p<2;p++)for(v=m[p],d=0;d<4;d++)for(g=0;g<16;g++)y[p][d][g]=g+16*d===v?1:0;var x=r.lines.canvasOverdrag,b=r.domain,_=r.canvasWidth,w=r.canvasHeight;return l.extendFlat({key:s,resolution:[_,w],viewBoxPosition:[n+x,i],viewBoxSize:[a,o],i:t,ii:e,dim1A:y[0][0],dim1B:y[0][1],dim1C:y[0][2],dim1D:y[0][3],dim2A:y[1][0],dim2B:y[1][1],dim2C:y[1][2],dim2D:y[1][3],colorClamp:I,scissorX:(c===u?0:n+x)+(r.pad.l-x)+r.layoutWidth*b.x[0],scissorWidth:(c===f?_-n+x:a+.5)+(c===u?n+x:0),scissorY:i+r.pad.b+r.layoutHeight*b.y[0],scissorHeight:o,viewportX:r.pad.l-x+r.layoutWidth*b.x[0],viewportY:r.pad.b+r.layoutHeight*b.y[0],viewportWidth:_,viewportHeight:w},h)}return{setColorDomain:function(t){I[0]=t[0],I[1]=t[1]},render:function(t,e,n){var i,a,o,s=t.length,l=1/0,c=-1/0;for(i=0;ic&&(c=t[i].dim2.canvasX,o=i),t[i].dim1.canvasXa._length&&(M=M.slice(0,a._length));var A,T=a.tickvals;function S(t,e){return{val:t,text:A[e]}}function C(t,e){return t.val-e.val}if(Array.isArray(T)&&T.length){A=a.ticktext,Array.isArray(A)&&A.length?A.length>T.length?A=A.slice(0,T.length):T.length>A.length&&(T=T.slice(0,A.length)):A=T.map(n.format(a.tickformat));for(var E=1;E=r||s>=i)return;var l=t.lineLayer.readPixel(o,i-1-s),c=0!==l[3],u=c?l[2]+256*(l[1]+256*l[0]):null,f={x:o,y:s,clientX:e.clientX,clientY:e.clientY,dataIndex:t.model.key,curveNumber:u};u!==M&&(c?d.hover(f):d.unhover&&d.unhover(f),M=u)}}),k.style("opacity",function(t){return t.pick?.01:1}),e.style("background","rgba(255, 255, 255, 0)");var A=e.selectAll("."+f.cn.parcoords).data(w,l);A.exit().remove(),A.enter().append("g").classed(f.cn.parcoords,!0).style("shape-rendering","crispEdges").style("pointer-events","none"),A.attr("transform",function(t){return"translate("+t.model.translateX+","+t.model.translateY+")"});var T=A.selectAll("."+f.cn.parcoordsControlView).data(c,l);T.enter().append("g").classed(f.cn.parcoordsControlView,!0),T.attr("transform",function(t){return"translate("+t.model.pad.l+","+t.model.pad.t+")"});var S=T.selectAll("."+f.cn.yAxis).data(function(t){return t.dimensions},l);function C(t,e){for(var r=e.panels||(e.panels=[]),n=t.data(),i=n.length-1,a=0;aline").attr("fill","none").attr("stroke","black").attr("stroke-opacity",.25).attr("stroke-width","1px"),L.selectAll("text").style("text-shadow","1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff").style("cursor","default").style("user-select","none");var z=E.selectAll("."+f.cn.axisHeading).data(c,l);z.enter().append("g").classed(f.cn.axisHeading,!0);var O=z.selectAll("."+f.cn.axisTitle).data(c,l);O.enter().append("text").classed(f.cn.axisTitle,!0).attr("text-anchor","middle").style("cursor","ew-resize").style("user-select","none").style("pointer-events","auto"),O.attr("transform","translate(0,"+-f.axisTitleOffset+")").text(function(t){return t.label}).each(function(t){a.font(n.select(this),t.model.labelFont)});var I=E.selectAll("."+f.cn.axisExtent).data(c,l);I.enter().append("g").classed(f.cn.axisExtent,!0);var P=I.selectAll("."+f.cn.axisExtentTop).data(c,l);P.enter().append("g").classed(f.cn.axisExtentTop,!0),P.attr("transform","translate(0,"+-f.axisExtentOffset+")");var D=P.selectAll("."+f.cn.axisExtentTopText).data(c,l);function R(t,e){if(t.ordinal)return"";var r=t.domainScale.domain();return n.format(t.tickFormat)(r[e?r.length-1:0])}D.enter().append("text").classed(f.cn.axisExtentTopText,!0).call(x),D.text(function(t){return R(t,!0)}).each(function(t){a.font(n.select(this),t.model.rangeFont)});var F=I.selectAll("."+f.cn.axisExtentBottom).data(c,l);F.enter().append("g").classed(f.cn.axisExtentBottom,!0),F.attr("transform",function(t){return"translate(0,"+(t.model.height+f.axisExtentOffset)+")"});var B=F.selectAll("."+f.cn.axisExtentBottomText).data(c,l);B.enter().append("text").classed(f.cn.axisExtentBottomText,!0).attr("dy","0.75em").call(x),B.text(function(t){return R(t)}).each(function(t){a.font(n.select(this),t.model.rangeFont)}),h.ensureAxisBrush(E)}},{"../../components/colorscale":581,"../../components/drawing":590,"../../lib":692,"../../lib/gup":690,"./axisbrush":1005,"./constants":1008,"./lines":1011,d3:148}],1014:[function(t,e,r){"use strict";var n=t("./parcoords"),i=t("../../lib/prepare_regl");e.exports=function(t,e){var r=t._fullLayout,a=r._toppaper,o=r._paperdiv,s=r._glcontainer;if(i(t)){var l={},c={},u={},f={},h=r._size;e.forEach(function(e,r){var n=e[0].trace;u[r]=n.index;var i=f[r]=n._fullInput.index;l[r]=t.data[i].dimensions,c[r]=t.data[i].dimensions.slice()});n(o,a,s,e,{width:h.w,height:h.h,margin:{t:h.t,r:h.r,b:h.b,l:h.l}},{filterChanged:function(e,n,i){var a=c[e][n],o=i.map(function(t){return t.slice()}),s="dimensions["+n+"].constraintrange",l=r._tracePreGUI[t._fullData[u[e]]._fullInput.uid];if(void 0===l[s]){var h=a.constraintrange;l[s]=h||null}var p=t._fullData[u[e]].dimensions[n];o.length?(1===o.length&&(o=o[0]),a.constraintrange=o,p.constraintrange=o.slice(),o=[o]):(delete a.constraintrange,delete p.constraintrange,o=null);var d={};d[s]=o,t.emit("plotly_restyle",[d,[f[e]]])},hover:function(e){t.emit("plotly_hover",e)},unhover:function(e){t.emit("plotly_unhover",e)},axesMoved:function(e,r){function n(t){return!("visible"in t)||t.visible}function i(t,e,r){var n=e.indexOf(r),i=t.indexOf(n);return-1===i&&(i+=e.length),i}var a=function(t){return function(e,n){return i(r,t,e)-i(r,t,n)}}(c[e].filter(n));l[e].sort(a),c[e].filter(function(t){return!n(t)}).sort(function(t){return c[e].indexOf(t)}).forEach(function(t){l[e].splice(l[e].indexOf(t),1),l[e].splice(c[e].indexOf(t),0,t)}),t.emit("plotly_restyle",[{dimensions:[l[e]]},[f[e]]])}})}}},{"../../lib/prepare_regl":705,"./parcoords":1013}],1015:[function(t,e,r){"use strict";var n=t("../../components/color/attributes"),i=t("../../plots/font_attributes"),a=t("../../plots/attributes"),o=t("../../components/fx/hovertemplate_attributes"),s=t("../../plots/domain").attributes,l=t("../../lib/extend").extendFlat,c=i({editType:"calc",arrayOk:!0,colorEditType:"plot"});e.exports={labels:{valType:"data_array",editType:"calc"},label0:{valType:"number",dflt:0,editType:"calc"},dlabel:{valType:"number",dflt:1,editType:"calc"},values:{valType:"data_array",editType:"calc"},marker:{colors:{valType:"data_array",editType:"calc"},line:{color:{valType:"color",dflt:n.defaultLine,arrayOk:!0,editType:"style"},width:{valType:"number",min:0,dflt:0,arrayOk:!0,editType:"style"},editType:"calc"},editType:"calc"},text:{valType:"data_array",editType:"calc"},hovertext:{valType:"string",dflt:"",arrayOk:!0,editType:"style"},scalegroup:{valType:"string",dflt:"",editType:"calc"},textinfo:{valType:"flaglist",flags:["label","text","value","percent"],extras:["none"],editType:"calc"},hoverinfo:l({},a.hoverinfo,{flags:["label","text","value","percent","name"]}),hovertemplate:o({},{keys:["label","color","value","percent","text"]}),textposition:{valType:"enumerated",values:["inside","outside","auto","none"],dflt:"auto",arrayOk:!0,editType:"calc"},textfont:l({},c,{}),insidetextfont:l({},c,{}),outsidetextfont:l({},c,{}),title:{text:{valType:"string",dflt:"",editType:"calc"},font:l({},c,{}),position:{valType:"enumerated",values:["top left","top center","top right","middle center","bottom left","bottom center","bottom right"],editType:"calc"},editType:"calc"},domain:s({name:"pie",trace:!0,editType:"calc"}),hole:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},sort:{valType:"boolean",dflt:!0,editType:"calc"},direction:{valType:"enumerated",values:["clockwise","counterclockwise"],dflt:"counterclockwise",editType:"calc"},rotation:{valType:"number",min:-360,max:360,dflt:0,editType:"calc"},pull:{valType:"number",min:0,max:1,dflt:0,arrayOk:!0,editType:"calc"},_deprecated:{title:{valType:"string",dflt:"",editType:"calc"},titlefont:l({},c,{}),titleposition:{valType:"enumerated",values:["top left","top center","top right","middle center","bottom left","bottom center","bottom right"],editType:"calc"}}}},{"../../components/color/attributes":568,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plots/attributes":737,"../../plots/domain":766,"../../plots/font_attributes":767}],1016:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../plots/get_data").getModuleCalcData;r.name="pie",r.plot=function(t){var e=n.getModule("pie"),r=i(t.calcdata,e)[0];r.length&&e.plot(t,r)},r.clean=function(t,e,r,n){var i=n._has&&n._has("pie"),a=e._has&&e._has("pie");i&&!a&&n._pielayer.selectAll("g.trace").remove()}},{"../../plots/get_data":777,"../../registry":823}],1017:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib").isArrayOrTypedArray,a=t("tinycolor2"),o=t("../../components/color"),s=t("./helpers");r.calc=function(t,e){var r,l,c,u,f,h=e.values,p=i(h)&&h.length,d=e.labels,g=e.marker.colors||[],v=[],m=t._fullLayout,y=m._piecolormap,x={},b=0,_=m.hiddenlabels||[];if(e.dlabel)for(d=new Array(h.length),r=0;r")}}return v},r.crossTraceCalc=function(t){var e=t._fullLayout,r=t.calcdata,n=e.piecolorway,i=e._piecolormap;e.extendpiecolors&&(n=function(t){var e,r=JSON.stringify(t),n=l[r];if(!n){for(n=t.slice(),e=0;e0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function p(t,e){var r=t.trace,n=e.h*(r.domain.y[1]-r.domain.y[0]);return Math.min(t.titleBox.height,n/2)}function d(t){var e,r=t.pull;if(Array.isArray(r))for(r=0,e=0;er&&(r=t.pull[e]);return r}e.exports=function(t,e){var r=t._fullLayout;!function(t,e){for(var r,n,i=0;ii.vTotal/2?1:0)}(e),g.attr("stroke-linejoin","round"),g.each(function(){var g=n.select(this).selectAll("g.slice").data(e);g.enter().append("g").classed("slice",!0),g.exit().remove();var y=[[[],[]],[[],[]]],x=!1;g.each(function(e){if(e.hidden)n.select(this).selectAll("path,g").remove();else{e.pointNumber=e.i,e.curveNumber=m.index,y[e.pxmid[1]<0?0:1][e.pxmid[0]<0?0:1].push(e);var p=v.cx,d=v.cy,g=n.select(this),b=g.selectAll("path.surface").data([e]),_=!1,w=!1;if(b.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),g.select("path.textline").remove(),g.on("mouseover",function(){var a=t._fullLayout,o=t._fullData[m.index];if(!t._dragging&&!1!==a.hovermode){var s=o.hoverinfo;if(Array.isArray(s)&&(s=i.castHoverinfo({hoverinfo:[c.castOption(s,e.pts)],_module:m._module},a,0)),"all"===s&&(s="label+text+value+percent+name"),o.hovertemplate||"none"!==s&&"skip"!==s&&s){var l=f(e,v),h=p+e.pxmid[0]*(1-l),g=d+e.pxmid[1]*(1-l),y=r.separators,x=[];if(s&&-1!==s.indexOf("label")&&x.push(e.label),e.text=c.castOption(o.hovertext||o.text,e.pts),s&&-1!==s.indexOf("text")){var b=e.text;b&&x.push(b)}e.value=e.v,e.valueLabel=c.formatPieValue(e.v,y),s&&-1!==s.indexOf("value")&&x.push(e.valueLabel),e.percent=e.v/v.vTotal,e.percentLabel=c.formatPiePercent(e.percent,y),s&&-1!==s.indexOf("percent")&&x.push(e.percentLabel);var k=m.hoverlabel,M=k.font;i.loneHover({x0:h-l*v.r,x1:h+l*v.r,y:g,text:x.join("
"),name:o.hovertemplate||-1!==s.indexOf("name")?o.name:void 0,idealAlign:e.pxmid[0]<0?"left":"right",color:c.castOption(k.bgcolor,e.pts)||e.color,borderColor:c.castOption(k.bordercolor,e.pts),fontFamily:c.castOption(M.family,e.pts),fontSize:c.castOption(M.size,e.pts),fontColor:c.castOption(M.color,e.pts),trace:o,hovertemplate:c.castOption(o.hovertemplate,e.pts),hovertemplateLabels:e,eventData:[u(e,o)]},{container:a._hoverlayer.node(),outerContainer:a._paper.node(),gd:t}),_=!0}t.emit("plotly_hover",{points:[u(e,o)],event:n.event}),w=!0}}).on("mouseout",function(r){var a=t._fullLayout,o=t._fullData[m.index];w&&(r.originalEvent=n.event,t.emit("plotly_unhover",{points:[u(e,o)],event:n.event}),w=!1),_&&(i.loneUnhover(a._hoverlayer.node()),_=!1)}).on("click",function(){var r=t._fullLayout,a=t._fullData[m.index];t._dragging||!1===r.hovermode||(t._hoverdata=[u(e,a)],i.click(t,n.event))}),m.pull){var k=+c.castOption(m.pull,e.pts)||0;k>0&&(p+=k*e.pxmid[0],d+=k*e.pxmid[1])}e.cxFinal=p,e.cyFinal=d;var M=m.hole;if(e.v===v.vTotal){var A="M"+(p+e.px0[0])+","+(d+e.px0[1])+L(e.px0,e.pxmid,!0,1)+L(e.pxmid,e.px0,!0,1)+"Z";M?b.attr("d","M"+(p+M*e.px0[0])+","+(d+M*e.px0[1])+L(e.px0,e.pxmid,!1,M)+L(e.pxmid,e.px0,!1,M)+"Z"+A):b.attr("d",A)}else{var T=L(e.px0,e.px1,!0,1);if(M){var S=1-M;b.attr("d","M"+(p+M*e.px1[0])+","+(d+M*e.px1[1])+L(e.px1,e.px0,!1,M)+"l"+S*e.px0[0]+","+S*e.px0[1]+T+"Z")}else b.attr("d","M"+p+","+d+"l"+e.px0[0]+","+e.px0[1]+T+"Z")}var C=c.castOption(m.textposition,e.pts),E=g.selectAll("g.slicetext").data(e.text&&"none"!==C?[0]:[]);E.enter().append("g").classed("slicetext",!0),E.exit().remove(),E.each(function(){var r=s.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});r.text(e.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(o.font,"outside"===C?function(t,e,r){var n=c.castOption(t.outsidetextfont.color,e.pts)||c.castOption(t.textfont.color,e.pts)||r.color,i=c.castOption(t.outsidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,a=c.castOption(t.outsidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n,family:i,size:a}}(m,e,t._fullLayout.font):function(t,e,r){var n=c.castOption(t.insidetextfont.color,e.pts);!n&&t._input.textfont&&(n=c.castOption(t._input.textfont.color,e.pts));var i=c.castOption(t.insidetextfont.family,e.pts)||c.castOption(t.textfont.family,e.pts)||r.family,o=c.castOption(t.insidetextfont.size,e.pts)||c.castOption(t.textfont.size,e.pts)||r.size;return{color:n||a.contrast(e.color),family:i,size:o}}(m,e,t._fullLayout.font)).call(l.convertToTspans,t);var i,u=o.bBox(r.node());"outside"===C?i=h(u,e):(i=function(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),i=t.width/t.height,a=Math.PI*Math.min(e.v/r.vTotal,.5),o=1-r.trace.hole,s=f(e,r),l={scale:s*r.r*2/n,rCenter:1-s,rotate:0};if(l.scale>=1)return l;var c=i+1/(2*Math.tan(a)),u=r.r*Math.min(1/(Math.sqrt(c*c+.5)+c),o/(Math.sqrt(i*i+o/2)+i)),h={scale:2*u/t.height,rCenter:Math.cos(u/r.r)-u*i/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},p=1/i,d=p+1/(2*Math.tan(a)),g=r.r*Math.min(1/(Math.sqrt(d*d+.5)+d),o/(Math.sqrt(p*p+o/2)+p)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/i/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return l.scale<1&&m.scale>l.scale?m:l}(u,e,v),"auto"===C&&i.scale<1&&(r.call(o.font,m.outsidetextfont),m.outsidetextfont.family===m.insidetextfont.family&&m.outsidetextfont.size===m.insidetextfont.size||(u=o.bBox(r.node())),i=h(u,e)));var g=p+e.pxmid[0]*i.rCenter+(i.x||0),y=d+e.pxmid[1]*i.rCenter+(i.y||0);i.outside&&(e.yLabelMin=y-u.height/2,e.yLabelMid=y,e.yLabelMax=y+u.height/2,e.labelExtraX=0,e.labelExtraY=0,x=!0),r.attr("transform","translate("+g+","+y+")"+(i.scale<1?"scale("+i.scale+")":"")+(i.rotate?"rotate("+i.rotate+")":"")+"translate("+-(u.left+u.right)/2+","+-(u.top+u.bottom)/2+")")})}function L(t,r,n,i){return"a"+i*v.r+","+i*v.r+" 0 "+e.largeArc+(n?" 1 ":" 0 ")+i*(r[0]-t[0])+","+i*(r[1]-t[1])}});var b=n.select(this).selectAll("g.titletext").data(m.title.text?[0]:[]);b.enter().append("g").classed("titletext",!0),b.exit().remove(),b.each(function(){var e,i=s.ensureSingle(n.select(this),"text","",function(t){t.attr("data-notex",1)});i.text(m.title.text).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(o.font,m.title.font).call(l.convertToTspans,t),e="middle center"===m.title.position?function(t){var e=Math.sqrt(t.titleBox.width*t.titleBox.width+t.titleBox.height*t.titleBox.height);return{x:t.cx,y:t.cy,scale:t.trace.hole*t.r*2/e,tx:0,ty:-t.titleBox.height/2+t.trace.title.font.size}}(v):function(t,e){var r,n,i=1,a=1,o=t.trace,s={x:t.cx,y:t.cy},l={tx:0,ty:0};l.ty+=o.title.font.size,n=d(o),-1!==o.title.position.indexOf("top")?(s.y-=(1+n)*t.r,l.ty-=t.titleBox.height):-1!==o.title.position.indexOf("bottom")&&(s.y+=(1+n)*t.r);-1!==o.title.position.indexOf("left")?(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,s.x-=(1+n)*t.r,l.tx+=t.titleBox.width/2):-1!==o.title.position.indexOf("center")?r=e.w*(o.domain.x[1]-o.domain.x[0]):-1!==o.title.position.indexOf("right")&&(r=e.w*(o.domain.x[1]-o.domain.x[0])/2+t.r,s.x+=(1+n)*t.r,l.tx-=t.titleBox.width/2);return i=r/t.titleBox.width,a=p(t,e)/t.titleBox.height,{x:s.x,y:s.y,scale:Math.min(i,a),tx:l.tx,ty:l.ty}}(v,r._size),i.attr("transform","translate("+e.x+","+e.y+")"+(e.scale<1?"scale("+e.scale+")":"")+"translate("+e.tx+","+e.ty+")")}),x&&function(t,e){var r,n,i,a,o,s,l,u,f,h,p,d,g;function v(t,e){return t.pxmid[1]-e.pxmid[1]}function m(t,e){return e.pxmid[1]-t.pxmid[1]}function y(t,r){r||(r={});var i,u,f,p,d,g,v=r.labelExtraY+(n?r.yLabelMax:r.yLabelMin),m=n?t.yLabelMin:t.yLabelMax,y=n?t.yLabelMax:t.yLabelMin,x=t.cyFinal+o(t.px0[1],t.px1[1]),b=v-m;if(b*l>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(u=0;u=(c.castOption(e.pull,f.pts)||0)||((t.pxmid[1]-f.pxmid[1])*l>0?(p=f.cyFinal+o(f.px0[1],f.px1[1]),(b=p-m-t.labelExtraY)*l>0&&(t.labelExtraY+=b)):(y+t.labelExtraY-x)*l>0&&(i=3*s*Math.abs(u-h.indexOf(t)),d=f.cxFinal+a(f.px0[0],f.px1[0]),(g=d+i-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*s>0&&(t.labelExtraX+=g)))}for(n=0;n<2;n++)for(i=n?v:m,o=n?Math.max:Math.min,l=n?1:-1,r=0;r<2;r++){for(a=r?Math.max:Math.min,s=r?1:-1,(u=t[n][r]).sort(i),f=t[1-n][r],h=f.concat(u),d=[],p=0;pMath.abs(c)?o+="l"+c*t.pxmid[0]/t.pxmid[1]+","+c+"H"+(i+t.labelExtraX+s):o+="l"+t.labelExtraX+","+l+"v"+(c-l)+"h"+s}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+s;e.append("path").classed("textline",!0).call(a.stroke,m.outsidetextfont.color).attr({"stroke-width":Math.min(2,m.outsidetextfont.size/8),d:o,fill:"none"})}})})});setTimeout(function(){g.selectAll("tspan").each(function(){var t=n.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":569,"../../components/drawing":590,"../../components/fx":608,"../../lib":692,"../../lib/svg_text_utils":716,"./event_data":1019,"./helpers":1020,d3:148}],1025:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each(function(t){n.select(this).call(i,t,e)})})}},{"./style_one":1026,d3:148}],1026:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("./helpers").castOption;e.exports=function(t,e,r){var a=r.marker.line,o=i(a.color,e.pts)||n.defaultLine,s=i(a.width,e.pts)||0;t.style({"stroke-width":s}).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":569,"./helpers":1020}],1027:[function(t,e,r){"use strict";var n=t("../scatter/attributes");e.exports={x:n.x,y:n.y,xy:{valType:"data_array",editType:"calc"},indices:{valType:"data_array",editType:"calc"},xbounds:{valType:"data_array",editType:"calc"},ybounds:{valType:"data_array",editType:"calc"},text:n.text,marker:{color:{valType:"color",arrayOk:!1,editType:"calc"},opacity:{valType:"number",min:0,max:1,dflt:1,arrayOk:!1,editType:"calc"},blend:{valType:"boolean",dflt:null,editType:"calc"},sizemin:{valType:"number",min:.1,max:2,dflt:.5,editType:"calc"},sizemax:{valType:"number",min:.1,dflt:20,editType:"calc"},border:{color:{valType:"color",arrayOk:!1,editType:"calc"},arearatio:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},editType:"calc"},editType:"calc"},transforms:void 0}},{"../scatter/attributes":1040}],1028:[function(t,e,r){"use strict";var n=t("gl-pointcloud2d"),i=t("../../lib/str2rgbarray"),a=t("../../plots/cartesian/autorange").findExtremes,o=t("../scatter/get_trace_color");function s(t,e){this.scene=t,this.uid=e,this.type="pointcloud",this.pickXData=[],this.pickYData=[],this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.idToIndex=new Int32Array(0),this.bounds=[0,0,0,0],this.pointcloudOptions={positions:new Float32Array(0),idToIndex:this.idToIndex,sizemin:.5,sizemax:12,color:[0,0,0,1],areaRatio:1,borderColor:[0,0,0,1]},this.pointcloud=n(t.glplot,this.pointcloudOptions),this.pointcloud._trace=this}var l=s.prototype;l.handlePick=function(t){var e=this.idToIndex[t.pointId];return{trace:this,dataCoord:t.dataCoord,traceCoord:this.pickXYData?[this.pickXYData[2*e],this.pickXYData[2*e+1]]:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:this.color,name:this.name,pointIndex:e,hoverinfo:this.hoverinfo}},l.update=function(t){this.index=t.index,this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-1/0,-1/0],this.updateFast(t),this.color=o(t,{})},l.updateFast=function(t){var e,r,n,o,s,l,c=this.xData=this.pickXData=t.x,u=this.yData=this.pickYData=t.y,f=this.pickXYData=t.xy,h=t.xbounds&&t.ybounds,p=t.indices,d=this.bounds;if(f){if(n=f,e=f.length>>>1,h)d[0]=t.xbounds[0],d[2]=t.xbounds[1],d[1]=t.ybounds[0],d[3]=t.ybounds[1];else for(l=0;ld[2]&&(d[2]=o),sd[3]&&(d[3]=s);if(p)r=p;else for(r=new Int32Array(e),l=0;ld[2]&&(d[2]=o),sd[3]&&(d[3]=s);this.idToIndex=r,this.pointcloudOptions.idToIndex=r,this.pointcloudOptions.positions=n;var g=i(t.marker.color),v=i(t.marker.border.color),m=t.opacity*t.marker.opacity;g[3]*=m,this.pointcloudOptions.color=g;var y=t.marker.blend;if(null===y){y=c.length<100||u.length<100}this.pointcloudOptions.blend=y,v[3]*=m,this.pointcloudOptions.borderColor=v;var x=t.marker.sizemin,b=Math.max(t.marker.sizemax,t.marker.sizemin);this.pointcloudOptions.sizeMin=x,this.pointcloudOptions.sizeMax=b,this.pointcloudOptions.areaRatio=t.marker.border.arearatio,this.pointcloud.update(this.pointcloudOptions);var _=this.scene.xaxis,w=this.scene.yaxis,k=b/2||.5;t._extremes[_._id]=a(_,[d[0],d[2]],{ppad:k}),t._extremes[w._id]=a(w,[d[1],d[3]],{ppad:k})},l.dispose=function(){this.pointcloud.dispose()},e.exports=function(t,e){var r=new s(t,e.uid);return r.update(e),r}},{"../../lib/str2rgbarray":715,"../../plots/cartesian/autorange":739,"../scatter/get_trace_color":1050,"gl-pointcloud2d":279}],1029:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r){function a(r,a){return n.coerce(t,e,i,r,a)}a("x"),a("y"),a("xbounds"),a("ybounds"),t.xy&&t.xy instanceof Float32Array&&(e.xy=t.xy),t.indices&&t.indices instanceof Int32Array&&(e.indices=t.indices),a("text"),a("marker.color",r),a("marker.opacity"),a("marker.blend"),a("marker.sizemin"),a("marker.sizemax"),a("marker.border.color",r),a("marker.border.arearatio"),e._length=null}},{"../../lib":692,"./attributes":1027}],1030:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../scatter3d/calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="pointcloud",n.basePlotModule=t("../../plots/gl2d"),n.categories=["gl","gl2d","showLegend"],n.meta={},e.exports=n},{"../../plots/gl2d":780,"../scatter3d/calc":1068,"./attributes":1027,"./convert":1028,"./defaults":1029}],1031:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../../plots/attributes"),a=t("../../components/color/attributes"),o=t("../../components/fx/attributes"),s=t("../../plots/domain").attributes,l=t("../../components/fx/hovertemplate_attributes"),c=t("../../lib/extend").extendFlat,u=t("../../plot_api/edit_types").overrideAll;(e.exports=u({hoverinfo:c({},i.hoverinfo,{flags:[],arrayOk:!1}),hoverlabel:o.hoverlabel,domain:s({name:"sankey",trace:!0}),orientation:{valType:"enumerated",values:["v","h"],dflt:"h"},valueformat:{valType:"string",dflt:".3s"},valuesuffix:{valType:"string",dflt:""},arrangement:{valType:"enumerated",values:["snap","perpendicular","freeform","fixed"],dflt:"snap"},textfont:n({}),node:{label:{valType:"data_array",dflt:[]},color:{valType:"color",arrayOk:!0},line:{color:{valType:"color",dflt:a.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:.5,arrayOk:!0}},pad:{valType:"number",arrayOk:!1,min:0,dflt:20},thickness:{valType:"number",arrayOk:!1,min:1,dflt:20},hoverinfo:{valType:"enumerated",values:["all","none","skip"],dflt:"all"},hoverlabel:o.hoverlabel,hovertemplate:l({},{keys:["value","label"]})},link:{label:{valType:"data_array",dflt:[]},color:{valType:"color",arrayOk:!0},line:{color:{valType:"color",dflt:a.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:0,arrayOk:!0}},source:{valType:"data_array",dflt:[]},target:{valType:"data_array",dflt:[]},value:{valType:"data_array",dflt:[]},hoverinfo:{valType:"enumerated",values:["all","none","skip"],dflt:"all"},hoverlabel:o.hoverlabel,hovertemplate:l({},{keys:["value","label"]})}},"calc","nested")).transforms=void 0},{"../../components/color/attributes":568,"../../components/fx/attributes":599,"../../components/fx/hovertemplate_attributes":607,"../../lib/extend":682,"../../plot_api/edit_types":723,"../../plots/attributes":737,"../../plots/domain":766,"../../plots/font_attributes":767}],1032:[function(t,e,r){"use strict";var n=t("../../plot_api/edit_types").overrideAll,i=t("../../plots/get_data").getModuleCalcData,a=t("./plot"),o=t("../../components/fx/layout_attributes");r.name="sankey",r.baseLayoutAttrOverrides=n({hoverlabel:o.hoverlabel},"plot","nested"),r.plot=function(t){var e=i(t.calcdata,"sankey")[0];a(t,e)},r.clean=function(t,e,r,n){var i=n._has&&n._has("sankey"),a=e._has&&e._has("sankey");i&&!a&&n._paperdiv.selectAll(".sankey").remove()}},{"../../components/fx/layout_attributes":609,"../../plot_api/edit_types":723,"../../plots/get_data":777,"./plot":1037}],1033:[function(t,e,r){"use strict";var n=t("strongly-connected-components"),i=t("../../lib"),a=t("../../lib/gup").wrap;e.exports=function(t,e){return function(t,e,r){for(var a=t.length,o=i.init2dArray(a,0),s=0;s1})}(e.node.label,e.link.source,e.link.target)&&(i.error("Circularity is present in the Sankey data. Removing all nodes and links."),e.link.label=[],e.link.source=[],e.link.target=[],e.link.value=[],e.link.color=[],e.node.label=[],e.node.color=[]),a({link:e.link,node:e.node})}},{"../../lib":692,"../../lib/gup":690,"strongly-connected-components":506}],1034:[function(t,e,r){"use strict";e.exports={nodeTextOffsetHorizontal:4,nodeTextOffsetVertical:3,nodePadAcross:10,sankeyIterations:50,forceIterations:5,forceTicksPerFrame:10,duration:500,ease:"cubic-in-out",cn:{sankey:"sankey",sankeyLinks:"sankey-links",sankeyLink:"sankey-link",sankeyNodeSet:"sankey-node-set",sankeyNode:"sankey-node",nodeRect:"node-rect",nodeCapture:"node-capture",nodeCentered:"node-entered",nodeLabelGuide:"node-label-guide",nodeLabel:"node-label",nodeLabelTextPath:"node-label-text-path"}}},{}],1035:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("../../components/color"),o=t("tinycolor2"),s=t("../../plots/domain").defaults,l=t("../../components/fx/hoverlabel_defaults"),c=t("../../plot_api/plot_template");e.exports=function(t,e,r,u){function f(r,a){return n.coerce(t,e,i,r,a)}var h=n.extendDeep(u.hoverlabel,t.hoverlabel),p=t.node,d=c.newContainer(e,"node");function g(t,e){return n.coerce(p,d,i.node,t,e)}g("label"),g("pad"),g("thickness"),g("line.color"),g("line.width"),g("hoverinfo",t.hoverinfo),l(p,d,g,h),g("hovertemplate");var v=u.colorway;g("color",d.label.map(function(t,e){return a.addOpacity(function(t){return v[t%v.length]}(e),.8)}));var m=t.link,y=c.newContainer(e,"link");function x(t,e){return n.coerce(m,y,i.link,t,e)}x("label"),x("source"),x("target"),x("value"),x("line.color"),x("line.width"),x("hoverinfo",t.hoverinfo),l(m,y,x,h),x("hovertemplate");var b=o(u.paper_bgcolor).getLuminance()<.333?"rgba(255, 255, 255, 0.6)":"rgba(0, 0, 0, 0.2)";x("color",n.repeat(b,y.value.length)),s(e,u,f),f("orientation"),f("valueformat"),f("valuesuffix"),f("arrangement"),n.coerceFont(f,"textfont",n.extendFlat({},u.font)),e._length=null}},{"../../components/color":569,"../../components/fx/hoverlabel_defaults":606,"../../lib":692,"../../plot_api/plot_template":730,"../../plots/domain":766,"./attributes":1031,tinycolor2:513}],1036:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.moduleType="trace",n.name="sankey",n.basePlotModule=t("./base_plot"),n.categories=["noOpacity"],n.meta={},e.exports=n},{"./attributes":1031,"./base_plot":1032,"./calc":1033,"./defaults":1035,"./plot":1037}],1037:[function(t,e,r){"use strict";var n=t("d3"),i=t("./render"),a=t("../../components/fx"),o=t("../../components/color"),s=t("../../lib"),l=t("./constants").cn,c=s._;function u(t){return""!==t}function f(t,e){return t.filter(function(t){return t.key===e.traceId})}function h(t,e){n.select(t).select("path").style("fill-opacity",e),n.select(t).select("rect").style("fill-opacity",e)}function p(t){n.select(t).select("text.name").style("fill","black")}function d(t){return function(e){return-1!==t.node.sourceLinks.indexOf(e.link)||-1!==t.node.targetLinks.indexOf(e.link)}}function g(t){return function(e){return-1!==e.node.sourceLinks.indexOf(t.link)||-1!==e.node.targetLinks.indexOf(t.link)}}function v(t,e,r){e&&r&&f(r,e).selectAll("."+l.sankeyLink).filter(d(e)).call(y.bind(0,e,r,!1))}function m(t,e,r){e&&r&&f(r,e).selectAll("."+l.sankeyLink).filter(d(e)).call(x.bind(0,e,r,!1))}function y(t,e,r,n){var i=n.datum().link.label;n.style("fill-opacity",.4),i&&f(e,t).selectAll("."+l.sankeyLink).filter(function(t){return t.link.label===i}).style("fill-opacity",.4),r&&f(e,t).selectAll("."+l.sankeyNode).filter(g(t)).call(v)}function x(t,e,r,n){var i=n.datum().link.label;n.style("fill-opacity",function(t){return t.tinyColorAlpha}),i&&f(e,t).selectAll("."+l.sankeyLink).filter(function(t){return t.link.label===i}).style("fill-opacity",function(t){return t.tinyColorAlpha}),r&&f(e,t).selectAll(l.sankeyNode).filter(g(t)).call(m)}function b(t,e){var r=t.hoverlabel||{},n=s.nestedProperty(r,e).get();return!Array.isArray(n)&&n}e.exports=function(t,e){var r=t._fullLayout,s=r._paper,f=r._size,d=c(t,"source:")+" ",g=c(t,"target:")+" ",_=c(t,"incoming flow count:")+" ",w=c(t,"outgoing flow count:")+" ";i(s,e,{width:f.w,height:f.h,margin:{t:f.t,r:f.r,b:f.b,l:f.l}},{linkEvents:{hover:function(e,r,i){!1!==t._fullLayout.hovermode&&(n.select(e).call(y.bind(0,r,i,!0)),"skip"!==r.link.trace.link.hoverinfo&&(r.link.fullData=r.link.trace,t.emit("plotly_hover",{event:n.event,points:[r.link]})))},follow:function(e,i){if(!1!==t._fullLayout.hovermode){var s=i.link.trace.link;if("none"!==s.hoverinfo&&"skip"!==s.hoverinfo){var l=t._fullLayout._paperdiv.node().getBoundingClientRect(),c=e.getBoundingClientRect(),f=c.left+c.width/2,v=c.top+c.height/2,m={valueLabel:n.format(i.valueFormat)(i.link.value)+i.valueSuffix};i.link.fullData=i.link.trace;var y=a.loneHover({x:f-l.left,y:v-l.top,name:m.valueLabel,text:[i.link.label||"",d+i.link.source.label,g+i.link.target.label].filter(u).join("
"),color:b(s,"bgcolor")||o.addOpacity(i.tinyColorHue,1),borderColor:b(s,"bordercolor"),fontFamily:b(s,"font.family"),fontSize:b(s,"font.size"),fontColor:b(s,"font.color"),idealAlign:n.event.x"),color:b(o,"bgcolor")||i.tinyColorHue,borderColor:b(o,"bordercolor"),fontFamily:b(o,"font.family"),fontSize:b(o,"font.size"),fontColor:b(o,"font.color"),idealAlign:"left",hovertemplate:o.hovertemplate,hovertemplateLabels:m,eventData:[i.node]},{container:r._hoverlayer.node(),outerContainer:r._paper.node(),gd:t});h(y,.85),p(y)}}},unhover:function(e,i,o){!1!==t._fullLayout.hovermode&&(n.select(e).call(m,i,o),"skip"!==i.node.trace.node.hoverinfo&&(i.node.fullData=i.node.trace,t.emit("plotly_unhover",{event:n.event,points:[i.node]})),a.loneUnhover(r._hoverlayer.node()))},select:function(e,r,i){var o=r.node;o.originalEvent=n.event,t._hoverdata=[o],n.select(e).call(m,r,i),a.click(t,{target:!0})}}})}},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"./constants":1034,"./render":1038,d3:148}],1038:[function(t,e,r){"use strict";var n=t("./constants"),i=t("d3"),a=t("tinycolor2"),o=t("../../components/color"),s=t("../../components/drawing"),l=t("@plotly/d3-sankey").sankey,c=t("d3-force"),u=t("../../lib"),f=u.isArrayOrTypedArray,h=u.isIndex,p=t("../../lib/gup"),d=p.keyFun,g=p.repeat,v=p.unwrap;function m(t){t.lastDraggedX=t.x,t.lastDraggedY=t.y}function y(t){return function(e){return e.node.originalX===t.node.originalX}}function x(t){for(var e=0;e1||t.linkLineWidth>0}function T(t){return"translate("+t.translateX+","+t.translateY+")"+(t.horizontal?"matrix(1 0 0 1 0 0)":"matrix(0 1 1 0 0 0)")}function S(t){return"translate("+(t.horizontal?0:t.labelY)+" "+(t.horizontal?t.labelY:0)+")"}function C(t){return i.svg.line()([[t.horizontal?t.left?-t.sizeAcross:t.visibleWidth+n.nodeTextOffsetHorizontal:n.nodeTextOffsetHorizontal,0],[t.horizontal?t.left?-n.nodeTextOffsetHorizontal:t.sizeAcross:t.visibleHeight-n.nodeTextOffsetHorizontal,0]])}function E(t){return t.horizontal?"matrix(1 0 0 1 0 0)":"matrix(0 1 1 0 0 0)"}function L(t){return t.horizontal?"scale(1 1)":"scale(-1 1)"}function z(t){return t.darkBackground&&!t.horizontal?"rgb(255,255,255)":"rgb(0,0,0)"}function O(t){return t.horizontal&&t.left?"100%":"0%"}function I(t,e,r){t.on(".basic",null).on("mouseover.basic",function(t){t.interactionState.dragInProgress||(r.hover(this,t,e),t.interactionState.hovered=[this,t])}).on("mousemove.basic",function(t){t.interactionState.dragInProgress||(r.follow(this,t),t.interactionState.hovered=[this,t])}).on("mouseout.basic",function(t){t.interactionState.dragInProgress||(r.unhover(this,t,e),t.interactionState.hovered=!1)}).on("click.basic",function(t){t.interactionState.hovered&&(r.unhover(this,t,e),t.interactionState.hovered=!1),t.interactionState.dragInProgress||r.select(this,t,e)})}function P(t,e,r){var a=i.behavior.drag().origin(function(t){return t.node}).on("dragstart",function(i){if("fixed"!==i.arrangement&&(u.raiseToTop(this),i.interactionState.dragInProgress=i.node,m(i.node),i.interactionState.hovered&&(r.nodeEvents.unhover.apply(0,i.interactionState.hovered),i.interactionState.hovered=!1),"snap"===i.arrangement)){var a=i.traceId+"|"+Math.floor(i.node.originalX);i.forceLayouts[a]?i.forceLayouts[a].alpha(1):function(t,e,r){var i=r.sankey.nodes().filter(function(t){return t.originalX===r.node.originalX});r.forceLayouts[e]=c.forceSimulation(i).alphaDecay(0).force("collide",c.forceCollide().radius(function(t){return t.dy/2+r.nodePad/2}).strength(1).iterations(n.forceIterations)).force("constrain",function(t,e,r,i){return function(){for(var t=0,a=0;a0&&i.forceLayouts[e].alpha(0)}}(0,e,i,r)).stop()}(0,a,i),function(t,e,r,i){window.requestAnimationFrame(function a(){for(var o=0;o0&&window.requestAnimationFrame(a)})}(t,e,i,a)}}).on("drag",function(r){if("fixed"!==r.arrangement){var n=i.event.x,a=i.event.y;"snap"===r.arrangement?(r.node.x=n,r.node.y=a):("freeform"===r.arrangement&&(r.node.x=n),r.node.y=Math.max(r.node.dy/2,Math.min(r.size-r.node.dy/2,a))),m(r.node),"snap"!==r.arrangement&&(r.sankey.relayout(),k(t.filter(y(r)),e))}}).on("dragend",function(t){t.interactionState.dragInProgress=!1});t.on(".drag",null).call(a)}e.exports=function(t,e,r,i){var c=t.selectAll("."+n.cn.sankey).data(e.filter(function(t){return v(t).trace.visible}).map(function(t,e,r){var i,a=v(e).trace,o=a.domain,s=a.node,c=a.link,p=a.arrangement,d="h"===a.orientation,g=a.node.pad,m=a.node.thickness,y=a.node.line.color,b=a.node.line.width,_=a.link.line.color,w=a.link.line.width,k=a.valueformat,M=a.valuesuffix,A=a.textfont,T=t.width*(o.x[1]-o.x[0]),S=t.height*(o.y[1]-o.y[0]),C=[],E=f(c.color),L={},z=s.label.length;for(i=0;i0&&h(I,z)&&h(P,z)&&(P=+P,L[I=+I]=L[P]=!0,C.push({pointNumber:i,label:c.label[i],color:E?c.color[i]:c.color,source:I,target:P,value:+O}))}var D=f(s.color),R=[],F=!1,B={};for(i=0;i5?t.node.label:""}).attr("text-anchor",function(t){return t.horizontal&&t.left?"end":"start"}),N.transition().ease(n.ease).duration(n.duration).attr("startOffset",O).style("fill",z)}},{"../../components/color":569,"../../components/drawing":590,"../../lib":692,"../../lib/gup":690,"./constants":1034,"@plotly/d3-sankey":46,d3:148,"d3-force":144,tinycolor2:513}],1039:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rs&&A[v].gap;)v--;for(y=A[v].s,d=A.length-1;d>v;d--)A[d].s=y;for(;sT[u]&&u=0;i--){var a=t[i];if("scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}}}}},{}],1047:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("./constants"),s=t("./subtypes"),l=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),f=t("./line_defaults"),h=t("./line_shape_defaults"),p=t("./text_defaults"),d=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function v(r,i){return n.coerce(t,e,a,r,i)}var m=l(t,e,g,v);if(m||(e.visible=!1),e.visible){var y=c(t,e,g,v),x=!y&&mG!=(F=O[L][1])>=G&&(P=O[L-1][0],D=O[L][0],F-R&&(I=P+(D-P)*(G-R)/(F-R),V=Math.min(V,I),U=Math.max(U,I)));V=Math.max(V,0),U=Math.min(U,h._length);var W=s.defaultLine;return s.opacity(f.fillcolor)?W=f.fillcolor:s.opacity((f.line||{}).color)&&(W=f.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:V,x1:U,y0:G,y1:G,color:W,hovertemplate:"%{name}"}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":569,"../../components/fx":608,"../../lib":692,"../../registry":823,"./fill_hover_text":1048,"./get_trace_color":1050}],1052:[function(t,e,r){"use strict";var n={},i=t("./subtypes");n.hasLines=i.hasLines,n.hasMarkers=i.hasMarkers,n.hasText=i.hasText,n.isBubble=i.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.crossTraceDefaults=t("./cross_trace_defaults"),n.calc=t("./calc").calc,n.crossTraceCalc=t("./cross_trace_calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./marker_colorbar"),n.style=t("./style").style,n.styleOnSelect=t("./style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":752,"./arrays_to_calcdata":1039,"./attributes":1040,"./calc":1041,"./cross_trace_calc":1045,"./cross_trace_defaults":1046,"./defaults":1047,"./hover":1051,"./marker_colorbar":1058,"./plot":1060,"./select":1061,"./style":1063,"./subtypes":1064}],1053:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s,l){var c=(t.marker||{}).color;(s("line.color",r),i(t,"line"))?a(t,e,o,s,{prefix:"line.",cLetter:"c",noScale:!0}):s("line.color",!n(c)&&c||r);s("line.width"),(l||{}).noDash||s("line.dash")}},{"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"../../lib":692}],1054:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),i=n.BADNUM,a=n.LOG_CLIP,o=a+.5,s=a-.5,l=t("../../lib"),c=l.segmentsIntersect,u=l.constrain,f=t("./constants");e.exports=function(t,e){var r,n,a,h,p,d,g,v,m,y,x,b,_,w,k,M,A,T,S=e.xaxis,C=e.yaxis,E="log"===S.type,L="log"===C.type,z=S._length,O=C._length,I=e.connectGaps,P=e.baseTolerance,D=e.shape,R="linear"===D,F=[],B=f.minTolerance,N=new Array(t.length),j=0;function V(e){var r=t[e];if(!r)return!1;var n=S.c2p(r.x),a=C.c2p(r.y);if(n===i){if(E&&(n=S.c2p(r.x,!0)),n===i)return!1;L&&a===i&&(n*=Math.abs(S._m*O*(S._m>0?o:s)/(C._m*z*(C._m>0?o:s)))),n*=1e3}if(a===i){if(L&&(a=C.c2p(r.y,!0)),a===i)return!1;a*=1e3}return[n,a]}function U(t,e,r,n){var i=r-t,a=n-e,o=.5-t,s=.5-e,l=i*i+a*a,c=i*o+a*s;if(c>0&&ctt||t[1]rt)return[u(t[0],Q,tt),u(t[1],et,rt)]}function at(t,e){return t[0]===e[0]&&(t[0]===Q||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function ot(t,e,r){return function(n,i){var a=it(n),o=it(i),s=[];if(a&&o&&at(a,o))return s;a&&s.push(a),o&&s.push(o);var c=2*l.constrain((n[t]+i[t])/2,e,r)-((a||n)[t]+(o||i)[t]);c&&((a&&o?c>0==a[t]>o[t]?a:o:a||o)[t]+=c);return s}}function st(t){var e=t[0],r=t[1],n=e===N[j-1][0],i=r===N[j-1][1];if(!n||!i)if(j>1){var a=e===N[j-2][0],o=r===N[j-2][1];n&&(e===Q||e===tt)&&a?o?j--:N[j-1]=t:i&&(r===et||r===rt)&&o?a?j--:N[j-1]=t:N[j++]=t}else N[j++]=t}function lt(t){N[j-1][0]!==t[0]&&N[j-1][1]!==t[1]&&st([Y,X]),st(t),Z=null,Y=X=0}function ct(t){if(A=t[0]/z,T=t[1]/O,G=t[0]tt?tt:0,W=t[1]rt?rt:0,G||W){if(j)if(Z){var e=J(Z,t);e.length>1&&(lt(e[0]),N[j++]=e[1])}else $=J(N[j-1],t)[0],N[j++]=$;else N[j++]=[G||t[0],W||t[1]];var r=N[j-1];G&&W&&(r[0]!==G||r[1]!==W)?(Z&&(Y!==G&&X!==W?st(Y&&X?(n=Z,a=(i=t)[0]-n[0],o=(i[1]-n[1])/a,(n[1]*i[0]-i[1]*n[0])/a>0?[o>0?Q:tt,rt]:[o>0?tt:Q,et]):[Y||G,X||W]):Y&&X&&st([Y,X])),st([G,W])):Y-G&&X-W&&st([G||Y,W||X]),Z=t,Y=G,X=W}else Z&<(J(Z,t)[0]),N[j++]=t;var n,i,a,o}for("linear"===D||"spline"===D?J=function(t,e){for(var r=[],n=0,i=0;i<4;i++){var a=nt[i],o=c(t[0],t[1],e[0],e[1],a[0],a[1],a[2],a[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&H(o,t)q(d,ut))break;a=d,(_=m[0]*v[0]+m[1]*v[1])>x?(x=_,h=d,g=!1):_=t.length||!d)break;ct(d),n=d}}else ct(h)}Z&&st([Y||Z[0],X||Z[1]]),F.push(N.slice(0,j))}return F}},{"../../constants/numerical":669,"../../lib":692,"./constants":1044}],1055:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],1056:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var i,a,o,s,l,c={},u=!1,f=-1,h=0,p=-1;for(a=0;a=0?l=p:(l=p=h,h++),l0?Math.max(e,i):0}}},{"fast-isnumeric":214}],1058:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],1059:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l,c){var u=o.isBubble(t),f=(t.line||{}).color;(c=c||{},f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),c.noLine||(l("marker.line.color",f&&!Array.isArray(f)&&e.marker.color!==f?f:u?n.background:n.defaultLine),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0)),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),c.gradient)&&("none"!==l("marker.gradient.type")&&l("marker.gradient.color"))}},{"../../components/color":569,"../../components/colorscale/defaults":579,"../../components/colorscale/helpers":580,"./subtypes":1064}],1060:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../registry"),a=t("../../lib"),o=a.ensureSingle,s=a.identity,l=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),f=t("./link_traces"),h=t("../../lib/polygon").tester;function p(t,e,r,f,p,d,g){var v;!function(t,e,r,i,o){var s=r.xaxis,l=r.yaxis,u=n.extent(a.simpleMap(s.range,s.r2c)),f=n.extent(a.simpleMap(l.range,l.r2c)),h=i[0].trace;if(!c.hasMarkers(h))return;var p=h.marker.maxdisplayed;if(0===p)return;var d=i.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=f[0]&&t.y<=f[1]}),g=Math.ceil(d.length/p),v=0;o.forEach(function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function y(t){return m?t.transition():t}var x=r.xaxis,b=r.yaxis,_=f[0].trace,w=_.line,k=n.select(d),M=o(k,"g","errorbars"),A=o(k,"g","lines"),T=o(k,"g","points"),S=o(k,"g","text");if(i.getComponentMethod("errorbars","plot")(t,M,r,g),!0===_.visible){var C,E;y(k).style("opacity",_.opacity);var L=_.fill.charAt(_.fill.length-1);"x"!==L&&"y"!==L&&(L=""),r.isRangePlot||(f[0].node3=k);var z="",O=[],I=_._prevtrace;I&&(z=I._prevRevpath||"",E=I._nextFill,O=I._polygons);var P,D,R,F,B,N,j,V,U,q="",H="",G=[],W=a.noop;if(C=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(E&&E.datum(f),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(R=l.steps(w.shape),F=l.steps(w.shape.split("").reverse().join(""))):R=F="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?l.smoothclosed(t.slice(1),w.smoothing):l.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},B=function(t){return F(t.reverse())},G=u(f,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify}),U=_._polygons=new Array(G.length),v=0;v1){var r=n.select(this);if(r.datum(f),t)y(r.style("opacity",0).attr("d",P).call(l.lineGroupStyle)).style("opacity",1);else{var i=y(r);i.attr("d",P),l.singleLineStyle(f,i)}}}}}var Y=A.selectAll(".js-line").data(G);y(Y.exit()).style("opacity",0).remove(),Y.each(W(!1)),Y.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(l.lineGroupStyle).each(W(!0)),l.setClipUrl(Y,r.layerClipId,t),G.length?(C?(C.datum(f),N&&V&&(L?("y"===L?N[1]=V[1]=b.c2p(0,!0):"x"===L&&(N[0]=V[0]=x.c2p(0,!0)),y(C).attr("d","M"+V+"L"+N+"L"+q.substr(1)).call(l.singleFillStyle)):y(C).attr("d",q+"Z").call(l.singleFillStyle))):E&&("tonext"===_.fill.substr(0,6)&&q&&z?("tonext"===_.fill?y(E).attr("d",q+"Z"+z+"Z").call(l.singleFillStyle):y(E).attr("d",q+"L"+z.substr(1)+"Z").call(l.singleFillStyle),_._polygons=_._polygons.concat(O)):(Z(E),_._polygons=null)),_._prevRevpath=H,_._prevPolygons=U):(C?Z(C):E&&Z(E),_._polygons=_._prevRevpath=_._prevPolygons=null),T.datum(f),S.datum(f),function(e,i,a){var o,u=a[0].trace,f=c.hasMarkers(u),h=c.hasText(u),p=tt(u),d=et,g=et;if(f||h){var v=s,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?v=w?J:$:_&&!w&&(v=K),f&&(d=v),h&&(g=v)}var k,M=(o=e.selectAll("path.point").data(d,p)).enter().append("path").classed("point",!0);m&&M.call(l.pointStyle,u,t).call(l.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),f&&(k=l.makePointStyleFns(u)),o.each(function(e){var i=n.select(this),a=y(i);l.translatePoint(e,a,x,b)?(l.singlePointStyle(e,a,u,k,t),r.layerClipId&&l.hideOutsideRangePoint(e,a,x,b,u.xcalendar,u.ycalendar),u.customdata&&i.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):a.remove()}),m?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=i.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each(function(t){var e=n.select(this),i=y(e.select("text"));l.translatePoint(t,i,x,b)?r.layerClipId&&l.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()}),o.selectAll("text").call(l.textPointStyle,u,t).each(function(t){var e=x.c2p(t.x),r=b.c2p(t.y);n.select(this).selectAll("tspan.line").each(function(){y(n.select(this)).attr({x:e,y:r})})}),o.exit().remove()}(T,S,f);var X=!1===_.cliponaxis?null:r.layerClipId;l.setClipUrl(T,X,t),l.setClipUrl(S,X,t)}function Z(t){y(t).attr("d","M0,0Z")}function $(t){return t.filter(function(t){return!t.gap&&t.vis})}function J(t){return t.filter(function(t){return t.vis})}function K(t){return t.filter(function(t){return!t.gap})}function Q(t){return t.id}function tt(t){if(t.ids)return Q}function et(){return!1}}e.exports=function(t,e,r,i,a,c){var u,h,d=!a,g=!!a&&a.duration>0,v=f(t,e,r);((u=i.selectAll("g.trace").data(v,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u.order(),function(t,e,r){e.each(function(e){var i=o(n.select(this),"g","fills");l.setClipUrl(i,r.layerClipId,t);var a=e[0].trace,c=[];a._ownfill&&c.push("_ownFill"),a._nexttrace&&c.push("_nextFill");var u=i.selectAll("g").data(c,s);u.enter().append("g"),u.exit().each(function(t){a[t]=null}).remove(),u.order().each(function(t){a[t]=o(n.select(this),"path","js-fill")})})}(t,u,e),g)?(c&&(h=c()),n.transition().duration(a.duration).ease(a.easing).each("end",function(){h&&h()}).each("interrupt",function(){h&&h()}).each(function(){i.selectAll("g.trace").each(function(r,n){p(t,n,e,r,v,this,a)})})):u.each(function(r,n){p(t,n,e,r,v,this,a)});d&&u.exit().remove(),i.selectAll("path:not([d])").remove()}},{"../../components/drawing":590,"../../lib":692,"../../lib/polygon":704,"../../registry":823,"./line_points":1054,"./link_traces":1056,"./subtypes":1064,d3:148}],1061:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,i,a,o,s=t.cd,l=t.xaxis,c=t.yaxis,u=[],f=s[0].trace;if(!n.hasMarkers(f)&&!n.hasText(f))return[];if(!1===e)for(r=0;r0){var h=i.c2l(u);i._lowerLogErrorBound||(i._lowerLogErrorBound=h),i._lowerErrorBound=Math.min(i._lowerLogErrorBound,h)}}else o[s]=[-l[0]*r,l[1]*r]}return o}e.exports=function(t,e,r){var n=[i(t.x,t.error_x,e[0],r.xaxis),i(t.y,t.error_y,e[1],r.yaxis),i(t.z,t.error_z,e[2],r.zaxis)],a=function(t){for(var e=0;e-1?-1:t.indexOf("right")>-1?1:0}function y(t){return null==t?0:t.indexOf("top")>-1?-1:t.indexOf("bottom")>-1?1:0}function x(t,e){return e(4*t)}function b(t){return p[t]}function _(t,e,r,n,i){var a=null;if(l.isArrayOrTypedArray(t)){a=[];for(var o=0;o=0){var g=function(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],l=[];for(n=0;n=0&&f("surfacecolor",h||p);for(var d=["x","y","z"],g=0;g<3;++g){var v="projection."+d[g];f(v+".show")&&(f(v+".opacity"),f(v+".scale"))}var m=n.getComponentMethod("errorbars","supplyDefaults");m(t,e,r,{axis:"z"}),m(t,e,r,{axis:"y",inherit:"z"}),m(t,e,r,{axis:"x",inherit:"z"})}else e.visible=!1}},{"../../lib":692,"../../registry":823,"../scatter/line_defaults":1053,"../scatter/marker_defaults":1059,"../scatter/subtypes":1064,"../scatter/text_defaults":1065,"./attributes":1067}],1072:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl3d_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","showLegend"],n.meta={},e.exports=n},{"../../constants/gl3d_markers":667,"../../plots/gl3d":783,"../scatter/marker_colorbar":1058,"./attributes":1067,"./calc":1068,"./convert":1070,"./defaults":1071}],1073:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../components/colorbar/attributes"),s=t("../../lib/extend").extendFlat,l=n.marker,c=n.line,u=l.line;e.exports={carpet:{valType:"string",editType:"calc"},a:{valType:"data_array",editType:"calc"},b:{valType:"data_array",editType:"calc"},mode:s({},n.mode,{dflt:"markers"}),text:s({},n.text,{}),line:{color:c.color,width:c.width,dash:c.dash,shape:s({},c.shape,{values:["linear","spline"]}),smoothing:c.smoothing,editType:"calc"},connectgaps:n.connectgaps,fill:s({},n.fill,{values:["none","toself","tonext"],dflt:"none"}),fillcolor:n.fillcolor,marker:s({symbol:l.symbol,opacity:l.opacity,maxdisplayed:l.maxdisplayed,size:l.size,sizeref:l.sizeref,sizemin:l.sizemin,sizemode:l.sizemode,line:s({width:u.width,editType:"calc"},a("marker.line")),gradient:l.gradient,editType:"calc"},a("marker"),{colorbar:o}),textfont:n.textfont,textposition:n.textposition,selected:n.selected,unselected:n.unselected,hoverinfo:s({},i.hoverinfo,{flags:["a","b","text","name"]}),hoveron:n.hoveron}},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plots/attributes":737,"../scatter/attributes":1040}],1074:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../scatter/colorscale_calc"),a=t("../scatter/arrays_to_calcdata"),o=t("../scatter/calc_selection"),s=t("../scatter/calc").calcMarkerSize,l=t("../carpet/lookup_carpetid");e.exports=function(t,e){var r=e._carpetTrace=l(t,e);if(r&&r.visible&&"legendonly"!==r.visible){var c;e.xaxis=r.xaxis,e.yaxis=r.yaxis;var u,f,h=e._length,p=new Array(h),d=!1;for(c=0;c"),a}function w(t,e){var r;r=t.labelprefix&&t.labelprefix.length>0?t.labelprefix.replace(/ = $/,""):t._hovertitle,g.push(r+": "+e.toFixed(3)+t.labelsuffix)}}},{"../scatter/hover":1051}],1078:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("../scatter/style").style,n.styleOnSelect=t("../scatter/style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("../scatter/select"),n.eventData=t("./event_data"),n.moduleType="trace",n.name="scattercarpet",n.basePlotModule=t("../../plots/cartesian"),n.categories=["svg","carpet","symbols","showLegend","carpetDependent","zoomScale"],n.meta={},e.exports=n},{"../../plots/cartesian":752,"../scatter/marker_colorbar":1058,"../scatter/select":1061,"../scatter/style":1063,"./attributes":1073,"./calc":1074,"./defaults":1075,"./event_data":1076,"./hover":1077,"./plot":1079}],1079:[function(t,e,r){"use strict";var n=t("../scatter/plot"),i=t("../../plots/cartesian/axes"),a=t("../../components/drawing");e.exports=function(t,e,r,o){var s,l,c,u=r[0][0].carpet,f={xaxis:i.getFromId(t,u.xaxis||"x"),yaxis:i.getFromId(t,u.yaxis||"y"),plot:e.plot};for(n(t,f,r,o),s=0;s")}(u,v,p.mockAxis,c[0].t.labels),[t]}}},{"../../components/fx":608,"../../constants/numerical":669,"../../plots/cartesian/axes":740,"../scatter/fill_hover_text":1048,"../scatter/get_trace_color":1050,"./attributes":1080}],1085:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOnSelect=t("../scatter/style").styleOnSelect,n.hoverPoints=t("./hover"),n.eventData=t("./event_data"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scattergeo",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","symbols","showLegend","scatter-like"],n.meta={},e.exports=n},{"../../plots/geo":771,"../scatter/marker_colorbar":1058,"../scatter/style":1063,"./attributes":1080,"./calc":1081,"./defaults":1082,"./event_data":1083,"./hover":1084,"./plot":1086,"./select":1087,"./style":1088}],1086:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../constants/numerical").BADNUM,o=t("../../lib/topojson_utils").getTopojsonFeatures,s=t("../../lib/geo_location_utils").locationToFeature,l=t("../../lib/geojson_utils"),c=t("../scatter/subtypes"),u=t("./style");function f(t,e){var r=t[0].trace;if(Array.isArray(r.locations))for(var n=o(r,e),i=r.locationmode,l=0;lp.TOO_MANY_POINTS?"rect":f.hasMarkers(e)?"rect":"round";if(c&&e.connectgaps){var h=n[0],d=n[1];for(i=0;i1?l[i]:l[0]:l,d=Array.isArray(c)?c.length>1?c[i]:c[0]:c,v=g[p],m=g[d],y=u?u/.8+1:0,x=-m*y-.5*m;o.offset[i]=[v*y/h,x/h]}}return o}}},{"../../components/drawing":590,"../../constants/interactions":668,"../../lib":692,"../../lib/gl_format_color":689,"../../plots/cartesian/axis_ids":743,"../../registry":823,"../scatter/make_bubble_size_func":1057,"../scatter/subtypes":1064,"./constants":1090,"color-normalize":108,"fast-isnumeric":214,"svg-path-sdf":511}],1092:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("../scatter/constants"),s=t("../scatter/subtypes"),l=t("../scatter/xy_defaults"),c=t("../scatter/marker_defaults"),u=t("../scatter/line_defaults"),f=t("../scatter/fillcolor_defaults"),h=t("../scatter/text_defaults");e.exports=function(t,e,r,p){function d(r,i){return n.coerce(t,e,a,r,i)}var g=!!t.marker&&/-open/.test(t.marker.symbol),v=s.isBubble(t),m=l(t,e,p,d);if(m){var y=m1&&u.extendFlat(o.line,M.linePositions(t,r,n)),o.errorX||o.errorY){var s=M.errorBarPositions(t,r,n,i,a);o.errorX&&u.extendFlat(o.errorX,s.x),o.errorY&&u.extendFlat(o.errorY,s.y)}return o.text&&(u.extendFlat(o.text,{positions:n},M.textPosition(t,r,o.text,o.marker)),u.extendFlat(o.textSel,{positions:n},M.textPosition(t,r,o.text,o.markerSel)),u.extendFlat(o.textUnsel,{positions:n},M.textPosition(t,r,o.text,o.markerUnsel))),o}(t,0,e,_,g,v),L=E(0,c);return x(a,e),f=T&&(S.marker.cluster=d.tree),L.lineOptions.push(S.line),L.errorXOptions.push(S.errorX),L.errorYOptions.push(S.errorY),L.fillOptions.push(S.fill),L.markerOptions.push(S.marker),L.markerSelectedOptions.push(S.markerSel),L.markerUnselectedOptions.push(S.markerUnsel),L.textOptions.push(S.text),L.textSelectedOptions.push(S.textSel),L.textUnselectedOptions.push(S.textUnsel),d._scene=L,d.index=L.count,d.x=g,d.y=v,d.positions=_,L.count++,[{x:!1,y:!1,t:d,trace:e}]},plot:function(t,e,r){if(r.length){var o,s,c=t._fullLayout,h=e._scene,p=e.xaxis,d=e.yaxis;if(h)if(f(t,["ANGLE_instanced_arrays","OES_element_index_uint"])){var g=c._glcanvas.data()[0].regl;if(_(t,e,r),h.dirty){if(!0===h.error2d&&(h.error2d=a(g)),!0===h.line2d&&(h.line2d=i(g)),!0===h.scatter2d&&(h.scatter2d=n(g)),!0===h.fill2d&&(h.fill2d=i(g)),!0===h.glText)for(h.glText=new Array(h.count),o=0;or&&(isNaN(e[n])||isNaN(e[n+1]));)n-=2;t.positions=e.slice(r,n+2)}return t}),h.line2d.update(h.lineOptions)),h.error2d){var v=(h.errorXOptions||[]).concat(h.errorYOptions||[]);h.error2d.update(v)}h.scatter2d&&h.scatter2d.update(h.markerOptions),h.fillOrder=u.repeat(null,h.count),h.fill2d&&(h.fillOptions=h.fillOptions.map(function(t,e){var n=r[e];if(t&&n&&n[0]&&n[0].trace){var i,a,o=n[0],s=o.trace,l=o.t,c=h.lineOptions[e],u=[];s._ownfill&&u.push(e),s._nexttrace&&u.push(e+1),u.length&&(h.fillOrder[e]=u);var f,p,d=[],g=c&&c.positions||l.positions;if("tozeroy"===s.fill){for(f=0;ff&&isNaN(g[p+1]);)p-=2;0!==g[f+1]&&(d=[g[f],0]),d=d.concat(g.slice(f,p+2)),0!==g[p+1]&&(d=d.concat([g[p],0]))}else if("tozerox"===s.fill){for(f=0;ff&&isNaN(g[p]);)p-=2;0!==g[f]&&(d=[0,g[f+1]]),d=d.concat(g.slice(f,p+2)),0!==g[p]&&(d=d.concat([0,g[p+1]]))}else if("toself"===s.fill||"tonext"===s.fill){for(d=[],i=0,a=0;a-1;for(o=0;o=0?Math.floor((e+180)/360):Math.ceil((e-180)/360)),d=e-p;if(n.getClosest(l,function(t){var e=t.lonlat;if(e[0]===s)return 1/0;var n=i.modHalf(e[0],360),a=e[1],o=h.project([n,a]),l=o.x-u.c2p([d,a]),c=o.y-f.c2p([n,r]),p=Math.max(3,t.mrc||0);return Math.max(Math.sqrt(l*l+c*c)-p,1-3/p)},t),!1!==t.index){var g=l[t.index],v=g.lonlat,m=[i.modHalf(v[0],360)+p,v[1]],y=u.c2p(m),x=f.c2p(m),b=g.mrc||1;return t.x0=y-b,t.x1=y+b,t.y0=x-b,t.y1=x+b,t.color=a(c,g),t.extraText=function(t,e,r){var n=(e.hi||t.hoverinfo).split("+"),i=-1!==n.indexOf("all"),a=-1!==n.indexOf("lon"),s=-1!==n.indexOf("lat"),l=e.lonlat,c=[];function u(t){return t+"\xb0"}i||a&&s?c.push("("+u(l[0])+", "+u(l[1])+")"):a?c.push(r.lon+u(l[0])):s&&c.push(r.lat+u(l[1]));(i||-1!==n.indexOf("text"))&&o(e,t,c);return c.join("
")}(c,g,l[0].t.labels),[t]}}},{"../../components/fx":608,"../../constants/numerical":669,"../../lib":692,"../scatter/fill_hover_text":1048,"../scatter/get_trace_color":1050}],1099:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("../scattergeo/calc"),n.plot=t("./plot"),n.hoverPoints=t("./hover"),n.eventData=t("./event_data"),n.selectPoints=t("./select"),n.style=function(t,e){e&&e[0].trace._glTrace.update(e)},n.moduleType="trace",n.name="scattermapbox",n.basePlotModule=t("../../plots/mapbox"),n.categories=["mapbox","gl","symbols","showLegend","scatterlike"],n.meta={},e.exports=n},{"../../plots/mapbox":798,"../scatter/marker_colorbar":1058,"../scattergeo/calc":1081,"./attributes":1094,"./defaults":1096,"./event_data":1097,"./hover":1098,"./plot":1100,"./select":1101}],1100:[function(t,e,r){"use strict";var n=t("./convert");function i(t,e){this.subplot=t,this.uid=e,this.sourceIds={fill:e+"-source-fill",line:e+"-source-line",circle:e+"-source-circle",symbol:e+"-source-symbol"},this.layerIds={fill:e+"-layer-fill",line:e+"-layer-line",circle:e+"-layer-circle",symbol:e+"-layer-symbol"},this.order=["fill","line","circle","symbol"]}var a=i.prototype;a.addSource=function(t,e){this.subplot.map.addSource(this.sourceIds[t],{type:"geojson",data:e.geojson})},a.setSourceData=function(t,e){this.subplot.map.getSource(this.sourceIds[t]).setData(e.geojson)},a.addLayer=function(t,e){this.subplot.map.addLayer({type:t,id:this.layerIds[t],source:this.sourceIds[t],layout:e.layout,paint:e.paint})},a.update=function(t){for(var e=this.subplot,r=n(t),i=0;i")}e.exports={hoverPoints:function(t,e,r,i){var a=n(t,e,r,i);if(a&&!1!==a[0].index){var s=a[0];if(void 0===s.index)return a;var l=t.subplot,c=s.cd[s.index],u=s.trace;if(l.isPtInside(c))return s.xLabelVal=void 0,s.yLabelVal=void 0,o(c,u,l,s),a}},makeHoverPointText:o}},{"../../lib":692,"../../plots/cartesian/axes":740,"../scatter/hover":1051}],1106:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"scatterpolar",basePlotModule:t("../../plots/polar"),categories:["polar","symbols","showLegend","scatter-like"],attributes:t("./attributes"),supplyDefaults:t("./defaults").supplyDefaults,colorbar:t("../scatter/marker_colorbar"),calc:t("./calc"),plot:t("./plot"),style:t("../scatter/style").style,hoverPoints:t("./hover").hoverPoints,selectPoints:t("../scatter/select"),meta:{}}},{"../../plots/polar":807,"../scatter/marker_colorbar":1058,"../scatter/select":1061,"../scatter/style":1063,"./attributes":1102,"./calc":1103,"./defaults":1104,"./hover":1105,"./plot":1107}],1107:[function(t,e,r){"use strict";var n=t("../scatter/plot"),i=t("../../constants/numerical").BADNUM;e.exports=function(t,e,r){for(var a=e.layers.frontplot.select("g.scatterlayer"),o={xaxis:e.xaxis,yaxis:e.yaxis,plot:e.framework,layerClipId:e._hasClipOnAxisFalse?e.clipIds.forTraces:null},s=e.radialAxis,l=e.angularAxis,c=0;c=h&&(y.marker.cluster=d.tree),y.marker&&(y.markerSel.positions=y.markerUnsel.positions=y.marker.positions=_),y.line&&_.length>1&&c.extendFlat(y.line,l.linePositions(t,p,_)),y.text&&(c.extendFlat(y.text,{positions:_},l.textPosition(t,p,y.text,y.marker)),c.extendFlat(y.textSel,{positions:_},l.textPosition(t,p,y.text,y.markerSel)),c.extendFlat(y.textUnsel,{positions:_},l.textPosition(t,p,y.text,y.markerUnsel))),y.fill&&!u.fill2d&&(u.fill2d=!0),y.marker&&!u.scatter2d&&(u.scatter2d=!0),y.line&&!u.line2d&&(u.line2d=!0),y.text&&!u.glText&&(u.glText=!0),u.lineOptions.push(y.line),u.fillOptions.push(y.fill),u.markerOptions.push(y.marker),u.markerSelectedOptions.push(y.markerSel),u.markerUnselectedOptions.push(y.markerUnsel),u.textOptions.push(y.text),u.textSelectedOptions.push(y.textSel),u.textUnselectedOptions.push(y.textUnsel),d.x=w,d.y=k,d.rawx=w,d.rawy=k,d.r=v,d.theta=m,d.positions=_,d._scene=u,d.index=u.count,u.count++}}),a.plot(t,e,r)}},hoverPoints:function(t,e,r,n){var i=t.cd[0].t,o=i.r,s=i.theta,l=a.hoverPoints(t,e,r,n);if(l&&!1!==l[0].index){var c=l[0];if(void 0===c.index)return l;var u=t.subplot,h=c.cd[c.index],p=c.trace;if(h.r=o[c.index],h.theta=s[c.index],u.isPtInside(h))return c.xLabelVal=void 0,c.yLabelVal=void 0,f(h,p,u,c),l}},selectPoints:a.selectPoints,meta:{}}},{"../../lib":692,"../../plots/cartesian/axes":740,"../../plots/polar":807,"../scatter/calc":1041,"../scatter/colorscale_calc":1043,"../scatter/marker_colorbar":1058,"../scattergl":1093,"../scattergl/constants":1090,"../scattergl/convert":1091,"../scatterpolar/hover":1105,"./attributes":1108,"./defaults":1109,"fast-isnumeric":214,"point-cluster":452}],1111:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../components/colorbar/attributes"),s=t("../../components/drawing/attributes").dash,l=t("../../lib/extend").extendFlat,c=n.marker,u=n.line,f=c.line;e.exports={a:{valType:"data_array",editType:"calc"},b:{valType:"data_array",editType:"calc"},c:{valType:"data_array",editType:"calc"},sum:{valType:"number",dflt:0,min:0,editType:"calc"},mode:l({},n.mode,{dflt:"markers"}),text:l({},n.text,{}),hovertext:l({},n.hovertext,{}),line:{color:u.color,width:u.width,dash:s,shape:l({},u.shape,{values:["linear","spline"]}),smoothing:u.smoothing,editType:"calc"},connectgaps:n.connectgaps,cliponaxis:n.cliponaxis,fill:l({},n.fill,{values:["none","toself","tonext"],dflt:"none"}),fillcolor:n.fillcolor,marker:l({symbol:c.symbol,opacity:c.opacity,maxdisplayed:c.maxdisplayed,size:c.size,sizeref:c.sizeref,sizemin:c.sizemin,sizemode:c.sizemode,line:l({width:f.width,editType:"calc"},a("marker.line")),gradient:c.gradient,editType:"calc"},a("marker"),{colorbar:o}),textfont:n.textfont,textposition:n.textposition,selected:n.selected,unselected:n.unselected,hoverinfo:l({},i.hoverinfo,{flags:["a","b","c","text","name"]}),hoveron:n.hoveron}},{"../../components/colorbar/attributes":570,"../../components/colorscale/attributes":576,"../../components/drawing/attributes":589,"../../lib/extend":682,"../../plots/attributes":737,"../scatter/attributes":1040}],1112:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../scatter/colorscale_calc"),a=t("../scatter/arrays_to_calcdata"),o=t("../scatter/calc_selection"),s=t("../scatter/calc").calcMarkerSize,l=["a","b","c"],c={a:["b","c"],b:["a","c"],c:["a","b"]};e.exports=function(t,e){var r,u,f,h,p,d,g=t._fullLayout[e.subplot].sum,v=e.sum||g,m={a:e.a,b:e.b,c:e.c};for(r=0;r"),o}function m(t,e){v.push(t._hovertitle+": "+i.tickText(t,e,"hover").text)}}},{"../../plots/cartesian/axes":740,"../scatter/hover":1051}],1116:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/marker_colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("../scatter/style").style,n.styleOnSelect=t("../scatter/style").styleOnSelect,n.hoverPoints=t("./hover"),n.selectPoints=t("../scatter/select"),n.eventData=t("./event_data"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","showLegend","scatter-like"],n.meta={},e.exports=n},{"../../plots/ternary":819,"../scatter/marker_colorbar":1058,"../scatter/select":1061,"../scatter/style":1063,"./attributes":1111,"./calc":1112,"./defaults":1113,"./event_data":1114,"./hover":1115,"./plot":1117}],1117:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e,r){var i=e.plotContainer;i.select(".scatterlayer").selectAll("*").remove();var a={xaxis:e.xaxis,yaxis:e.yaxis,plot:i,layerClipId:e._hasClipOnAxisFalse?e.clipIdRelative:null},o=e.layers.frontplot.select("g.scatterlayer");n(t,a,r,o)}},{"../scatter/plot":1060}],1118:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/colorscale/attributes"),a=t("../scattergl/attributes"),o=t("../../plots/cartesian/constants").idRegex,s=t("../../plot_api/plot_template").templatedArray,l=t("../../lib/extend").extendFlat,c=n.marker,u=c.line,f=l(i("marker.line",{editTypeOverride:"calc"}),{width:l({},u.width,{editType:"calc"}),editType:"calc"}),h=l(i("marker"),{symbol:c.symbol,size:l({},c.size,{editType:"markerSize"}),sizeref:c.sizeref,sizemin:c.sizemin,sizemode:c.sizemode,opacity:c.opacity,colorbar:c.colorbar,line:f,editType:"calc"});function p(t){return{valType:"info_array",freeLength:!0,editType:"calc",items:{valType:"subplotid",regex:o[t],editType:"plot"}}}h.color.editType=h.cmin.editType=h.cmax.editType="style",e.exports={dimensions:s("dimension",{visible:{valType:"boolean",dflt:!0,editType:"calc"},label:{valType:"string",editType:"calc"},values:{valType:"data_array",editType:"calc+clearAxisTypes"},axis:{type:{valType:"enumerated",values:["linear","log","date","category"],editType:"calc+clearAxisTypes"},editType:"calc+clearAxisTypes"},editType:"calc+clearAxisTypes"}),text:l({},a.text,{}),marker:h,xaxes:p("x"),yaxes:p("y"),diagonal:{visible:{valType:"boolean",dflt:!0,editType:"calc"},editType:"calc"},showupperhalf:{valType:"boolean",dflt:!0,editType:"calc"},showlowerhalf:{valType:"boolean",dflt:!0,editType:"calc"},selected:{marker:a.selected.marker,editType:"calc"},unselected:{marker:a.unselected.marker,editType:"calc"},opacity:a.opacity}},{"../../components/colorscale/attributes":576,"../../lib/extend":682,"../../plot_api/plot_template":730,"../../plots/cartesian/constants":746,"../scatter/attributes":1040,"../scattergl/attributes":1089}],1119:[function(t,e,r){"use strict";var n=t("regl-line2d"),i=t("../../registry"),a=t("../../lib/prepare_regl"),o=t("../../plots/get_data").getModuleCalcData,s=t("../../plots/cartesian"),l=t("../../plots/cartesian/axis_ids").getFromId,c=t("../../plots/cartesian/axes").shouldShowZeroLine,u="splom";function f(t,e,r){for(var n=r.matrixOptions.data.length,i=e._visibleDims,a=r.viewOpts.ranges=new Array(n),o=0;oa&&l?r._splomSubplots[S]=1:i-1,A="lasso"===y||"select"===y||!!h.selectedpoints||M;if(d.selectBatch=null,d.unselectBatch=null,A){var T=h._length;if(d.selectBatch||(d.selectBatch=[],d.unselectBatch=[]),h.selectedpoints){d.selectBatch=h.selectedpoints;var S=h.selectedpoints,C={};for(a=0;am?2*(x.sizeAvg||Math.max(x.size,3)):u(e,y),n=0;n2?t.slice(1,e-1):2===e?[(t[0]+t[1])/2]:t}function p(t){var e=t.length;return 1===e?[.5,.5]:[t[1]-t[0],t[e-1]-t[e-2]]}function d(t,e){var r=t.fullSceneLayout,i=t.dataScale,c=e._len,u={};function d(t,e){var n=r[e],o=i[l[e]];return a.simpleMap(t,function(t){return n.d2l(t)*o})}u.vectors=s(d(e.u,"xaxis"),d(e.v,"yaxis"),d(e.w,"zaxis"),c);var g=f(e.x.slice(0,c)),v=f(e.y.slice(0,c)),m=f(e.z.slice(0,c));if(g.length*v.length*m.length>c)return{positions:[],cells:[]};var y=d(g,"xaxis"),x=d(v,"yaxis"),b=d(m,"zaxis");if(u.meshgrid=[y,x,b],e.starts){var _=e._slen;u.startingPositions=s(d(e.starts.x.slice(0,_),"xaxis"),d(e.starts.y.slice(0,_),"yaxis"),d(e.starts.z.slice(0,_),"zaxis"))}else{for(var w=x[0],k=h(y),M=h(b),A=new Array(k.length*M.length),T=0,S=0;S0){r=h[n];break}return r}function v(t,e){if(!(t<1||e<1)){for(var r=d(t),n=d(e),i=1,a=0;ax;)r--,r/=g(r),++r1?n:1},f.refineCoords=function(t){for(var e=this.dataScaleX,r=this.dataScaleY,n=t[0].shape[0],o=t[0].shape[1],s=0|Math.floor(t[0].shape[0]*e+1),l=0|Math.floor(t[0].shape[1]*r+1),c=1+n+1,u=1+o+1,f=i(new Float32Array(c*u),[c,u]),h=0;ha&&(this.minValues[e]=a),this.maxValues[e]",maxDimensionCount:60,overdrag:45,releaseTransitionDuration:120,releaseTransitionEase:"cubic-out",scrollbarCaptureWidth:18,scrollbarHideDelay:1e3,scrollbarHideDuration:1e3,scrollbarOffset:5,scrollbarWidth:8,transitionDuration:100,transitionEase:"cubic-out",uplift:5,wrapSpacer:" ",wrapSplitCharacter:" ",cn:{table:"table",tableControlView:"table-control-view",scrollBackground:"scroll-background",yColumn:"y-column",columnBlock:"column-block",scrollAreaClip:"scroll-area-clip",scrollAreaClipRect:"scroll-area-clip-rect",columnBoundary:"column-boundary",columnBoundaryClippath:"column-boundary-clippath",columnBoundaryRect:"column-boundary-rect",columnCells:"column-cells",columnCell:"column-cell",cellRect:"cell-rect",cellText:"cell-text",cellTextHolder:"cell-text-holder",scrollbarKit:"scrollbar-kit",scrollbar:"scrollbar",scrollbarSlider:"scrollbar-slider",scrollbarGlyph:"scrollbar-glyph",scrollbarCaptureZone:"scrollbar-capture-zone"}}},{}],1136:[function(t,e,r){"use strict";var n=t("./constants"),i=t("../../lib/extend").extendFlat,a=t("fast-isnumeric");function o(t){if(Array.isArray(t)){for(var e=0,r=0;r=e||c===t.length-1)&&(n[i]=o,o.key=l++,o.firstRowIndex=s,o.lastRowIndex=c,o={firstRowIndex:null,lastRowIndex:null,rows:[]},i+=a,s=c+1,a=0);return n}e.exports=function(t,e){var r=l(e.cells.values),p=function(t){return t.slice(e.header.values.length,t.length)},d=l(e.header.values);d.length&&!d[0].length&&(d[0]=[""],d=l(d));var g=d.concat(p(r).map(function(){return c((d[0]||[""]).length)})),v=e.domain,m=Math.floor(t._fullLayout._size.w*(v.x[1]-v.x[0])),y=Math.floor(t._fullLayout._size.h*(v.y[1]-v.y[0])),x=e.header.values.length?g[0].map(function(){return e.header.height}):[n.emptyHeaderHeight],b=r.length?r[0].map(function(){return e.cells.height}):[],_=x.reduce(s,0),w=h(b,y-_+n.uplift),k=f(h(x,_),[]),M=f(w,k),A={},T=e._fullInput.columnorder.concat(p(r.map(function(t,e){return e}))),S=g.map(function(t,r){var n=Array.isArray(e.columnwidth)?e.columnwidth[Math.min(r,e.columnwidth.length-1)]:e.columnwidth;return a(n)?Number(n):1}),C=S.reduce(s,0);S=S.map(function(t){return t/C*m});var E=Math.max(o(e.header.line.width),o(e.cells.line.width)),L={key:e.uid+t._context.staticPlot,translateX:v.x[0]*t._fullLayout._size.w,translateY:t._fullLayout._size.h*(1-v.y[1]),size:t._fullLayout._size,width:m,maxLineWidth:E,height:y,columnOrder:T,groupHeight:y,rowBlocks:M,headerRowBlocks:k,scrollY:0,cells:i({},e.cells,{values:r}),headerCells:i({},e.header,{values:g}),gdColumns:g.map(function(t){return t[0]}),gdColumnsOriginalOrder:g.map(function(t){return t[0]}),prevPages:[0,0],scrollbarState:{scrollbarScrollInProgress:!1},columns:g.map(function(t,e){var r=A[t];return A[t]=(r||0)+1,{key:t+"__"+A[t],label:t,specIndex:e,xIndex:T[e],xScale:u,x:void 0,calcdata:void 0,columnWidth:S[e]}})};return L.columns.forEach(function(t){t.calcdata=L,t.x=u(t)}),L}},{"../../lib/extend":682,"./constants":1135,"fast-isnumeric":214}],1137:[function(t,e,r){"use strict";var n=t("../../lib/extend").extendFlat;r.splitToPanels=function(t){var e=[0,0],r=n({},t,{key:"header",type:"header",page:0,prevPages:e,currentRepaint:[null,null],dragHandle:!0,values:t.calcdata.headerCells.values[t.specIndex],rowBlocks:t.calcdata.headerRowBlocks,calcdata:n({},t.calcdata,{cells:t.calcdata.headerCells})});return[n({},t,{key:"cells1",type:"cells",page:0,prevPages:e,currentRepaint:[null,null],dragHandle:!1,values:t.calcdata.cells.values[t.specIndex],rowBlocks:t.calcdata.rowBlocks}),n({},t,{key:"cells2",type:"cells",page:1,prevPages:e,currentRepaint:[null,null],dragHandle:!1,values:t.calcdata.cells.values[t.specIndex],rowBlocks:t.calcdata.rowBlocks}),r]},r.splitToCells=function(t){var e=function(t){var e=t.rowBlocks[t.page],r=e?e.rows[0].rowIndex:0,n=e?r+e.rows.length:0;return[r,n]}(t);return(t.values||[]).slice(e[0],e[1]).map(function(r,n){return{keyWithinBlock:n+("string"==typeof r&&r.match(/[<$&> ]/)?"_keybuster_"+Math.random():""),key:e[0]+n,column:t,calcdata:t.calcdata,page:t.page,rowBlocks:t.rowBlocks,value:r}})}},{"../../lib/extend":682}],1138:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("../../plots/domain").defaults;e.exports=function(t,e,r,o){function s(r,a){return n.coerce(t,e,i,r,a)}a(e,o,s),s("columnwidth"),s("header.values"),s("header.format"),s("header.align"),s("header.prefix"),s("header.suffix"),s("header.height"),s("header.line.width"),s("header.line.color"),s("header.fill.color"),n.coerceFont(s,"header.font",n.extendFlat({},o.font)),function(t,e){for(var r=t.columnorder||[],n=t.header.values.length,i=r.slice(0,n),a=i.slice().sort(function(t,e){return t-e}),o=i.map(function(t){return a.indexOf(t)}),s=o.length;s/i),l=!o||s;t.mayHaveMarkup=o&&a.match(/[<&>]/);var c,u="string"==typeof(c=a)&&c.match(n.latexCheck);t.latex=u;var f,h,p=u?"":_(t.calcdata.cells.prefix,e,r)||"",d=u?"":_(t.calcdata.cells.suffix,e,r)||"",g=u?null:_(t.calcdata.cells.format,e,r)||null,v=p+(g?i.format(g)(t.value):t.value)+d;if(t.wrappingNeeded=!t.wrapped&&!l&&!u&&(f=b(v)),t.cellHeightMayIncrease=s||u||t.mayHaveMarkup||(void 0===f?b(v):f),t.needsConvertToTspans=t.mayHaveMarkup||t.wrappingNeeded||t.latex,t.wrappingNeeded){var m=(" "===n.wrapSplitCharacter?v.replace(/
i&&n.push(a),i+=l}return n}(i,l,s);1===c.length&&(c[0]===i.length-1?c.unshift(c[0]-1):c.push(c[0]+1)),c[0]%2&&c.reverse(),e.each(function(t,e){t.page=c[e],t.scrollY=l}),e.attr("transform",function(t){return"translate(0 "+(I(t.rowBlocks,t.page)-t.scrollY)+")"}),t&&(C(t,r,e,c,n.prevPages,n,0),C(t,r,e,c,n.prevPages,n,1),m(r,t))}}function S(t,e,r,a){return function(o){var s=o.calcdata?o.calcdata:o,l=e.filter(function(t){return s.key===t.key}),c=r||s.scrollbarState.dragMultiplier,u=s.scrollY;s.scrollY=void 0===a?s.scrollY+c*i.event.dy:a;var f=l.selectAll("."+n.cn.yColumn).selectAll("."+n.cn.columnBlock).filter(k);return T(t,f,l),s.scrollY===u}}function C(t,e,r,n,i,a,o){n[o]!==i[o]&&(clearTimeout(a.currentRepaint[o]),a.currentRepaint[o]=setTimeout(function(){var a=r.filter(function(t,e){return e===o&&n[e]!==i[e]});y(t,e,a,r),i[o]=n[o]}))}function E(t,e,r,a){return function(){var o=i.select(e.parentNode);o.each(function(t){var e=t.fragments;o.selectAll("tspan.line").each(function(t,r){e[r].width=this.getComputedTextLength()});var r,i,a=e[e.length-1].width,s=e.slice(0,-1),l=[],c=0,u=t.column.columnWidth-2*n.cellPad;for(t.value="";s.length;)c+(i=(r=s.shift()).width+a)>u&&(t.value+=l.join(n.wrapSpacer)+n.lineBreaker,l=[],c=0),l.push(r.text),c+=i;c&&(t.value+=l.join(n.wrapSpacer)),t.wrapped=!0}),o.selectAll("tspan.line").remove(),x(o.select("."+n.cn.cellText),r,t,a),i.select(e.parentNode.parentNode).call(O)}}function L(t,e,r,a,o){return function(){if(!o.settledY){var s=i.select(e.parentNode),l=R(o),c=o.key-l.firstRowIndex,u=l.rows[c].rowHeight,f=o.cellHeightMayIncrease?e.parentNode.getBoundingClientRect().height+2*n.cellPad:u,h=Math.max(f,u);h-l.rows[c].rowHeight&&(l.rows[c].rowHeight=h,t.selectAll("."+n.cn.columnCell).call(O),T(null,t.filter(k),0),m(r,a,!0)),s.attr("transform",function(){var t=this.parentNode.getBoundingClientRect(),e=i.select(this.parentNode).select("."+n.cn.cellRect).node().getBoundingClientRect(),r=this.transform.baseVal.consolidate(),a=e.top-t.top+(r?r.matrix.f:n.cellPad);return"translate("+z(o,i.select(this.parentNode).select("."+n.cn.cellTextHolder).node().getBoundingClientRect().width)+" "+a+")"}),o.settledY=!0}}}function z(t,e){switch(t.align){case"left":return n.cellPad;case"right":return t.column.columnWidth-(e||0)-n.cellPad;case"center":return(t.column.columnWidth-(e||0))/2;default:return n.cellPad}}function O(t){t.attr("transform",function(t){var e=t.rowBlocks[0].auxiliaryBlocks.reduce(function(t,e){return t+P(e,1/0)},0);return"translate(0 "+(P(R(t),t.key)+e)+")"}).selectAll("."+n.cn.cellRect).attr("height",function(t){return(e=R(t),r=t.key,e.rows[r-e.firstRowIndex]).rowHeight;var e,r})}function I(t,e){for(var r=0,n=e-1;n>=0;n--)r+=D(t[n]);return r}function P(t,e){for(var r=0,n=0;n0){var y,x,b,_,w,k=t.xa,M=t.ya;"h"===h.orientation?(w=e,y="y",b=M,x="x",_=k):(w=r,y="x",b=k,x="y",_=M);var A=f[t.index];if(w>=A.span[0]&&w<=A.span[1]){var T=n.extendFlat({},t),S=_.c2p(w,!0),C=o.getKdeValue(A,h,w),E=o.getPositionOnKdePath(A,h,S),L=b._offset,z=b._length;T[y+"0"]=E[0],T[y+"1"]=E[1],T[x+"0"]=T[x+"1"]=S,T[x+"Label"]=x+": "+i.hoverLabelText(_,w)+", "+f[0].t.labels.kde+" "+C.toFixed(3),T.spikeDistance=m[0].spikeDistance;var O=y+"Spike";T[O]=m[0][O],m[0].spikeDistance=void 0,m[0][O]=void 0,v.push(T),(u={stroke:t.color})[y+"1"]=n.constrain(L+E[0],L,L+z),u[y+"2"]=n.constrain(L+E[1],L,L+z),u[x+"1"]=u[x+"2"]=_._offset+S}}}-1!==p.indexOf("points")&&(c=a.hoverOnPoints(t,e,r));var I=l.selectAll(".violinline-"+h.uid).data(u?[0]:[]);return I.enter().append("line").classed("violinline-"+h.uid,!0).attr("stroke-width",1.5),I.exit().remove(),I.attr(u),"closest"===s?c?[c]:v:c?(v.push(c),v):v}},{"../../lib":692,"../../plots/cartesian/axes":740,"../box/hover":861,"./helpers":1145}],1147:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),crossTraceCalc:t("./cross_trace_calc"),plot:t("./plot"),style:t("./style"),styleOnSelect:t("../scatter/style").styleOnSelect,hoverPoints:t("./hover"),selectPoints:t("../box/select"),moduleType:"trace",name:"violin",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","symbols","oriented","box-violin","showLegend","violinLayout","zoomScale"],meta:{}}},{"../../plots/cartesian":752,"../box/select":866,"../scatter/style":1063,"./attributes":1141,"./calc":1142,"./cross_trace_calc":1143,"./defaults":1144,"./hover":1146,"./layout_attributes":1148,"./layout_defaults":1149,"./plot":1150,"./style":1151}],1148:[function(t,e,r){"use strict";var n=t("../box/layout_attributes"),i=t("../../lib").extendFlat;e.exports={violinmode:i({},n.boxmode,{}),violingap:i({},n.boxgap,{}),violingroupgap:i({},n.boxgroupgap,{})}},{"../../lib":692,"../box/layout_attributes":863}],1149:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes"),a=t("../box/layout_defaults");e.exports=function(t,e,r){a._supply(t,e,r,function(r,a){return n.coerce(t,e,i,r,a)},"violin")}},{"../../lib":692,"../box/layout_defaults":864,"./layout_attributes":1148}],1150:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../components/drawing"),o=t("../box/plot"),s=t("../scatter/line_points"),l=t("./helpers");e.exports=function(t,e,r,c){var u=t._fullLayout,f=e.xaxis,h=e.yaxis;function p(t){var e=s(t,{xaxis:f,yaxis:h,connectGaps:!0,baseTolerance:.75,shape:"spline",simplify:!0});return a.smoothopen(e[0],1)}i.makeTraceGroups(c,r,"trace violins").each(function(t){var r=n.select(this),a=t[0],s=a.t,c=a.trace;e.isRangePlot||(a.node3=r);var d=u._numViolins,g="group"===u.violinmode&&d>1,v=1-u.violingap,m=s.bdPos=s.dPos*v*(1-u.violingroupgap)/(g?d:1),y=s.bPos=g?2*s.dPos*((s.num+.5)/d-.5)*v:0;if(s.wHover=s.dPos*(g?v/d:1),!0!==c.visible||s.empty)r.remove();else{var x=e[s.valLetter+"axis"],b=e[s.posLetter+"axis"],_="both"===c.side,w=_||"positive"===c.side,k=_||"negative"===c.side,M=u._violinScaleGroupStats[c.scalegroup],A=r.selectAll("path.violin").data(i.identity);A.enter().append("path").style("vector-effect","non-scaling-stroke").attr("class","violin"),A.exit().remove(),A.each(function(t){var e,r,i,a,o,l,u,f,h=n.select(this),d=t.density,g=d.length,v=t.pos+y,A=b.c2p(v);switch(c.scalemode){case"width":e=M.maxWidth/m;break;case"count":e=M.maxWidth/m*(M.maxCount/t.pts.length)}if(w){for(u=new Array(g),o=0;oa&&(a=u,o=c)}}return a?i(o):s};case"rms":return function(t,e){for(var r=0,a=0,o=0;o":return function(t){return h(t)>s};case">=":return function(t){return h(t)>=s};case"[]":return function(t){var e=h(t);return e>=s[0]&&e<=s[1]};case"()":return function(t){var e=h(t);return e>s[0]&&e=s[0]&&es[0]&&e<=s[1]};case"][":return function(t){var e=h(t);return e<=s[0]||e>=s[1]};case")(":return function(t){var e=h(t);return es[1]};case"](":return function(t){var e=h(t);return e<=s[0]||e>s[1]};case")[":return function(t){var e=h(t);return e=s[1]};case"{}":return function(t){return-1!==s.indexOf(h(t))};case"}{":return function(t){return-1===s.indexOf(h(t))}}}(r,a.getDataToCoordFunc(t,e,s,i),h),x={},b={},_=0;d?(v=function(t){x[t.astr]=n.extendDeep([],t.get()),t.set(new Array(f))},m=function(t,e){var r=x[t.astr][e];t.get()[e]=r}):(v=function(t){x[t.astr]=n.extendDeep([],t.get()),t.set([])},m=function(t,e){var r=x[t.astr][e];t.get().push(r)}),M(v);for(var w=o(e.transforms,r),k=0;k1?"%{group} (%{trace})":"%{group}");var l=t.styles,c=o.styles=[];if(l)for(a=0;a